From 9bbd7f15ccbb540620cf13649429ce414a2259b3 Mon Sep 17 00:00:00 2001 From: tamilpp25 Date: Mon, 26 Dec 2022 14:06:01 +0530 Subject: [PATCH] Add scripts --- README.md | 7 +- .../Scripts/XBehavior/XLuaBehaviorAgent.lua | 34 + .../Scripts/XBehavior/XLuaBehaviorManager.lua | 61 + .../Scripts/XBehavior/XLuaBehaviorNode.lua | 89 + Resources/Scripts/XCommon/Fix.lua | 8 + Resources/Scripts/XCommon/Json.lua | 397 + Resources/Scripts/XCommon/XAnalyticsEvent.lua | 35 + Resources/Scripts/XCommon/XBindTools.lua | 171 + Resources/Scripts/XCommon/XCameraHelper.lua | 111 + Resources/Scripts/XCommon/XClass.lua | 81 + Resources/Scripts/XCommon/XCode.lua | 2526 +++++ Resources/Scripts/XCommon/XCountDown.lua | 123 + Resources/Scripts/XCommon/XDynamicList.lua | 268 + Resources/Scripts/XCommon/XEntityHelper.lua | 35 + Resources/Scripts/XCommon/XEventId.lua | 949 ++ Resources/Scripts/XCommon/XFightNetwork.lua | 164 + Resources/Scripts/XCommon/XGlobalFunc.lua | 117 + Resources/Scripts/XCommon/XGlobalVar.lua | 18 + Resources/Scripts/XCommon/XLog.lua | 188 + Resources/Scripts/XCommon/XLuaBehaviour.lua | 34 + Resources/Scripts/XCommon/XMath.lua | 59 + Resources/Scripts/XCommon/XNetwork.lua | 274 + Resources/Scripts/XCommon/XNpcAttribType.lua | 92 + Resources/Scripts/XCommon/XPerformance.lua | 82 + Resources/Scripts/XCommon/XPool.lua | 60 + Resources/Scripts/XCommon/XPrefs.lua | 53 + Resources/Scripts/XCommon/XQueue.lua | 46 + Resources/Scripts/XCommon/XRpc.lua | 99 + .../Scripts/XCommon/XRpcExceptionCode.lua | 14 + Resources/Scripts/XCommon/XSaveTool.lua | 146 + .../Scripts/XCommon/XScheduleManager.lua | 72 + .../Scripts/XCommon/XSignBoardPlayer.lua | 290 + Resources/Scripts/XCommon/XStack.lua | 45 + Resources/Scripts/XCommon/XString.lua | 411 + Resources/Scripts/XCommon/XTable.lua | 9911 +++++++++++++++++ Resources/Scripts/XCommon/XTime.lua | 265 + Resources/Scripts/XCommon/XTool.lua | 307 + Resources/Scripts/XCommon/XUiGravity.lua | 56 + Resources/Scripts/XCommon/XUiHelper.lua | 1111 ++ .../Scripts/XConfig/XActivityBriefConfigs.lua | 171 + .../Scripts/XConfig/XActivityConfigs.lua | 108 + Resources/Scripts/XConfig/XAppConfigs.lua | 9 + Resources/Scripts/XConfig/XArchiveConfigs.lua | 794 ++ Resources/Scripts/XConfig/XArenaConfigs.lua | 318 + .../Scripts/XConfig/XArenaOnlineConfigs.lua | 176 + Resources/Scripts/XConfig/XArrangeConfigs.lua | 64 + Resources/Scripts/XConfig/XAssistConfig.lua | 12 + Resources/Scripts/XConfig/XAttribConfigs.lua | 79 + .../Scripts/XConfig/XAutoFightConfig.lua | 13 + .../Scripts/XConfig/XAutoWindowConfigs.lua | 64 + .../Scripts/XConfig/XBaseEquipConfigs.lua | 20 + Resources/Scripts/XConfig/XBfrtConfigs.lua | 36 + .../Scripts/XConfig/XBountyTaskConfigs.lua | 51 + .../Scripts/XConfig/XCharacterConfigs.lua | 1508 +++ .../XConfig/XCharacterUiEffectConfig.lua | 75 + Resources/Scripts/XConfig/XChatConfigs.lua | 75 + .../Scripts/XConfig/XChessPursuitConfig.lua | 552 + .../Scripts/XConfig/XChristmasTreeConfig.lua | 91 + .../XConfig/XClickClearGameConfigs.lua | 81 + .../XConfig/XCollectionWallConfigs.lua | 236 + .../Scripts/XConfig/XComeAcrossConfig.lua | 184 + .../Scripts/XConfig/XCommunicationConfig.lua | 97 + .../Scripts/XConfig/XComposeGameConfig.lua | 145 + .../XConfig/XComposeMiniGameConfig.lua | 23 + Resources/Scripts/XConfig/XConfigCenter.lua | 175 + .../Scripts/XConfig/XCoupletGameConfigs.lua | 148 + .../Scripts/XConfig/XDailyDungeonConfigs.lua | 66 + Resources/Scripts/XConfig/XDisplayConfigs.lua | 40 + Resources/Scripts/XConfig/XDlcConfig.lua | 48 + Resources/Scripts/XConfig/XDormConfig.lua | 1035 ++ Resources/Scripts/XConfig/XDrawConfigs.lua | 259 + .../Scripts/XConfig/XEliminateGameConfig.lua | 90 + Resources/Scripts/XConfig/XEquipConfig.lua | 957 ++ .../Scripts/XConfig/XExhibitionConfigs.lua | 182 + .../Scripts/XConfig/XExpeditionConfig.lua | 374 + Resources/Scripts/XConfig/XFashionConfigs.lua | 39 + .../Scripts/XConfig/XFashionStoryConfigs.lua | 183 + .../Scripts/XConfig/XFavorabilityConfigs.lua | 610 + .../XConfig/XFestivalActivityConfig.lua | 64 + .../Scripts/XConfig/XFightWordsConfigs.lua | 25 + .../Scripts/XConfig/XFingerGuessingConfig.lua | 156 + .../XFubenActivityBossSingleConfigs.lua | 180 + .../XConfig/XFubenActivityBranchConfigs.lua | 85 + .../XConfig/XFubenActivityPuzzleConfigs.lua | 148 + .../Scripts/XConfig/XFubenAssignConfigs.lua | 50 + .../XConfig/XFubenBabelTowerConfigs.lua | 407 + .../XConfig/XFubenBossOnlineConfig.lua | 31 + .../XConfig/XFubenBossSingleConfigs.lua | 181 + Resources/Scripts/XConfig/XFubenConfigs.lua | 622 ++ .../XConfig/XFubenCoupleCombatConfig.lua | 64 + .../XConfig/XFubenExperimentConfigs.lua | 62 + .../Scripts/XConfig/XFubenExploreConfigs.lua | 104 + .../XConfig/XFubenExtraChapterConfigs.lua | 62 + .../Scripts/XConfig/XFubenHackConfig.lua | 86 + .../XConfig/XFubenInfestorExploreConfigs.lua | 907 ++ .../Scripts/XConfig/XFubenMainLineConfigs.lua | 72 + .../Scripts/XConfig/XFubenNewCharConfig.lua | 116 + .../XConfig/XFubenRepeatChallengeConfigs.lua | 113 + .../Scripts/XConfig/XFubenRogueLikeConfig.lua | 610 + .../XConfig/XFubenSimulatedCombatConfig.lua | 112 + .../XConfig/XFubenSpecialTrainConfig.lua | 149 + .../XConfig/XFubenUnionKillConfigs.lua | 286 + .../XConfig/XFubenUrgentEventConfig.lua | 18 + .../Scripts/XConfig/XFubenZhouMuConfigs.lua | 127 + Resources/Scripts/XConfig/XFunctionConfig.lua | 225 + .../Scripts/XConfig/XFurnitureConfigs.lua | 1217 ++ Resources/Scripts/XConfig/XGachaConfigs.lua | 210 + .../Scripts/XConfig/XGuardCampConfig.lua | 192 + Resources/Scripts/XConfig/XGuideConfig.lua | 83 + .../Scripts/XConfig/XGuildBossConfig.lua | 117 + Resources/Scripts/XConfig/XGuildConfig.lua | 489 + .../Scripts/XConfig/XHeadPortraitConfigs.lua | 29 + .../Scripts/XConfig/XHelpCourseConfig.lua | 44 + Resources/Scripts/XConfig/XHostelConfigs.lua | 141 + .../Scripts/XConfig/XInvertCardGameConfig.lua | 220 + Resources/Scripts/XConfig/XItemConfigs.lua | 208 + .../Scripts/XConfig/XKillZoneConfigs.lua | 626 ++ Resources/Scripts/XConfig/XLoadingConfig.lua | 27 + Resources/Scripts/XConfig/XLottoConfigs.lua | 104 + Resources/Scripts/XConfig/XMailConfigs.lua | 43 + .../XConfig/XMaintainerActionConfigs.lua | 163 + .../XConfig/XMarketingActivityConfigs.lua | 143 + Resources/Scripts/XConfig/XMedalConfigs.lua | 423 + .../Scripts/XConfig/XMentorSystemConfigs.lua | 134 + .../Scripts/XConfig/XMineSweepingConfigs.lua | 78 + Resources/Scripts/XConfig/XMoeWarConfig.lua | 1009 ++ .../Scripts/XConfig/XMovieAssembleConfig.lua | 112 + Resources/Scripts/XConfig/XMovieConfigs.lua | 166 + .../Scripts/XConfig/XMusicPlayerConfigs.lua | 79 + Resources/Scripts/XConfig/XNieRConfigs.lua | 591 + Resources/Scripts/XConfig/XPartnerConfigs.lua | 497 + .../XConfig/XPartnerTeachingConfigs.lua | 126 + .../Scripts/XConfig/XPassportConfigs.lua | 514 + Resources/Scripts/XConfig/XPayConfigs.lua | 73 + .../Scripts/XConfig/XPhotographConfigs.lua | 92 + .../Scripts/XConfig/XPlatformShareConfigs.lua | 58 + .../Scripts/XConfig/XPlayerInfoConfigs.lua | 86 + Resources/Scripts/XConfig/XPokemonConfigs.lua | 887 ++ .../Scripts/XConfig/XPokerGuessingConfig.lua | 143 + .../Scripts/XConfig/XPracticeConfigs.lua | 86 + Resources/Scripts/XConfig/XPrequelConfigs.lua | 119 + .../Scripts/XConfig/XPurchaseConfigs.lua | 393 + .../XConfig/XPuzzleActivityConfigs.lua | 36 + .../Scripts/XConfig/XRedEnvelopeConfigs.lua | 18 + Resources/Scripts/XConfig/XReformConfigs.lua | 184 + .../Scripts/XConfig/XRegressionConfigs.lua | 252 + Resources/Scripts/XConfig/XReportConfigs.lua | 13 + Resources/Scripts/XConfig/XRewardConfigs.lua | 20 + .../XConfig/XRoomCharFilterTipsConfigs.lua | 216 + .../Scripts/XConfig/XRpgMakerGameConfigs.lua | 1199 ++ Resources/Scripts/XConfig/XRpgTowerConfig.lua | 578 + .../Scripts/XConfig/XSceneModelConfigs.lua | 36 + .../Scripts/XConfig/XScratchTicketConfig.lua | 126 + Resources/Scripts/XConfig/XSetConfigs.lua | 100 + Resources/Scripts/XConfig/XShopConfigs.lua | 60 + .../Scripts/XConfig/XSignBoardConfigs.lua | 189 + Resources/Scripts/XConfig/XSignInConfigs.lua | 523 + .../Scripts/XConfig/XSpecialShopConfigs.lua | 108 + .../XSpringFestivalActivityConfigs.lua | 439 + .../Scripts/XConfig/XStrongholdConfigs.lua | 890 ++ .../Scripts/XConfig/XSuperTowerConfigs.lua | 758 ++ Resources/Scripts/XConfig/XTRPGConfigs.lua | 2109 ++++ Resources/Scripts/XConfig/XTaskConfig.lua | 217 + .../Scripts/XConfig/XTaskForceConfigs.lua | 76 + Resources/Scripts/XConfig/XTeamConfig.lua | 53 + Resources/Scripts/XConfig/XTrialConfigs.lua | 85 + Resources/Scripts/XConfig/XUiConfigs.lua | 46 + .../XUiFightButtonDefaultStyleConfig.lua | 38 + Resources/Scripts/XConfig/XUiPcConfig.lua | 46 + Resources/Scripts/XConfig/XVideoConfig.lua | 24 + .../Scripts/XConfig/XWeaponFashionConfigs.lua | 143 + .../Scripts/XConfig/XWhiteValentineConfig.lua | 216 + .../Scripts/XConfig/XWorldBossConfigs.lua | 173 + Resources/Scripts/XDebug/LuaDebug.lua | 2642 +++++ .../XEntity/XArchive/XArchiveCGEntity.lua | 91 + .../XArchive/XArchiveCommunicationEntity.lua | 92 + .../XEntity/XArchive/XArchiveMailEntity.lua | 63 + .../XArchive/XArchiveMonsterDetailEntity.lua | 68 + .../XArchive/XArchiveMonsterEntity.lua | 88 + .../XArchive/XArchiveNpcDetailEntity.lua | 59 + .../XEntity/XArchive/XArchiveNpcEntity.lua | 55 + .../XArchive/XArchivePartnerEntity.lua | 91 + .../XArchive/XArchivePartnerSettingEntity.lua | 59 + .../XArchive/XArchiveStoryChapterEntity.lua | 67 + .../XArchive/XArchiveStoryDetailEntity.lua | 75 + .../XBabelTower/XBabelTowerStageData.lua | 119 + .../XBabelTower/XBabelTowerTeamData.lua | 173 + .../Scripts/XEntity/XCharacter/XCharacter.lua | 207 + .../XCharacter/XCharacterSkillGroup.lua | 38 + .../XCharacter/XCharacterViewModel.lua | 229 + Resources/Scripts/XEntity/XChat/XChatData.lua | 228 + .../Scripts/XEntity/XChat/XChatEmoji.lua | 33 + .../XClickClearGameRewardData.lua | 39 + .../XCollectionWall/XCollectionWall.lua | 148 + .../XDrawGroupBtnBaseEntity.lua | 73 + .../XDrawMianButton/XDrawTabBtnEntity.lua | 107 + .../XLottoDrawGroupBtnEntity.lua | 78 + .../XNormalDrawGroupBtnEntity.lua | 100 + .../XEntity/XEquip/XAwarenessViewModel.lua | 23 + Resources/Scripts/XEntity/XEquip/XEquip.lua | 170 + .../Scripts/XEntity/XEquip/XEquipModel.lua | 79 + .../XEntity/XEquip/XEquipSuitPrefab.lua | 122 + .../XEntity/XEquip/XEquipViewModel.lua | 57 + .../Scripts/XEntity/XEquip/XSkillInfoObj.lua | 86 + .../Scripts/XEntity/XEquip/XWeaponFashion.lua | 64 + .../XEntity/XEquip/XWeaponViewModel.lua | 9 + .../XExpedition/XExpeditionActivity.lua | 274 + .../XExpedition/XExpeditionChapter.lua | 251 + .../XExpedition/XExpeditionCharacter.lua | 228 + .../XEntity/XExpedition/XExpeditionCombo.lua | 400 + .../XExpedition/XExpeditionComboList.lua | 128 + .../XExpedition/XExpeditionRecruitMembers.lua | 72 + .../XEntity/XExpedition/XExpeditionStage.lua | 254 + .../XEntity/XExpedition/XExpeditionTeam.lua | 372 + .../XExpedition/XExpeditionTeamPos.lua | 31 + .../XEntity/XFestival/XFestivalChapter.lua | 236 + .../XEntity/XFestival/XFestivalStage.lua | 258 + Resources/Scripts/XEntity/XFriend.lua | 34 + .../XEntity/XFunctional/XFunctionTime.lua | 95 + Resources/Scripts/XEntity/XGlobalDraw.lua | 102 + .../XEntity/XGuardCamp/XCampNotifyData.lua | 36 + .../XGuardCamp/XGuardActivityNotifyData.lua | 66 + .../XGuardCamp/XGuardCampActivityInfo.lua | 52 + .../Scripts/XEntity/XGuild/XGuildData.lua | 179 + .../XEntity/XGuild/XGuildMemberData.lua | 56 + .../XEntity/XGuild/XGuildVistorData.lua | 71 + .../XEntity/XHome/XHomeFurnitureData.lua | 86 + .../Scripts/XEntity/XHome/XHomeRoomData.lua | 353 + .../XInfestorExploreCharacter.lua | 67 + .../XInfestorExplore/XInfestorExploreCore.lua | 68 + .../XInfestorExploreMapNode.lua | 267 + .../XInfestorExploreOutPostStory.lua | 85 + .../XInfestorExplorePlayer.lua | 122 + .../XInfestorExplore/XInfestorExploreTeam.lua | 73 + .../XInvertCardGame/XInvertCardStage.lua | 176 + .../XEntity/XItem/XCharacterExpTemplate.lua | 34 + .../XEntity/XItem/XEquipExpTemplate.lua | 33 + .../Scripts/XEntity/XItem/XGiftTemplate.lua | 22 + Resources/Scripts/XEntity/XItem/XItem.lua | 73 + .../Scripts/XEntity/XItem/XItemTemplate.lua | 29 + .../XEntity/XItem/XPartnerExpTemplate.lua | 32 + Resources/Scripts/XEntity/XItem/XRecItem.lua | 106 + .../XEntity/XKillZone/XKillZonePlugin.lua | 105 + .../XEntity/XKillZone/XKillZoneStage.lua | 81 + .../XEntity/XLotto/XLottoDrawEntity.lua | 139 + .../XEntity/XLotto/XLottoGroupEntity.lua | 86 + .../XEntity/XLotto/XLottoRewardEntity.lua | 48 + .../XMaintainerAction/XBoxNodeEntity.lua | 44 + .../XCardChangeNodeEntity.lua | 34 + .../XDirectionChangeNodeEntity.lua | 12 + .../XMaintainerAction/XExploreNodeEntity.lua | 20 + .../XExtraActionPointNodeEntity.lua | 37 + .../XMaintainerAction/XFallBackNodeEntity.lua | 45 + .../XMaintainerAction/XFightNodeEntity.lua | 36 + .../XMaintainerAction/XForwardNodeEntity.lua | 45 + .../XMaintainerActionGameDataEntity.lua | 156 + .../XMaintainerActionNodeEntity.lua | 116 + .../XMaintainerActionPlayerEntity.lua | 65 + .../XMaintainerAction/XMentorNodeEntity.lua | 84 + .../XMaintainerAction/XNoneNodeEntity.lua | 11 + .../XSimulationFightNodeEntity.lua | 47 + .../XMaintainerAction/XStartNodeEntity.lua | 37 + .../XMaintainerAction/XUnKnowNodeEntity.lua | 29 + .../XWarehouseNodeEntity.lua | 43 + .../XMentorSystem/XMentorDataEntity.lua | 634 ++ .../XMineSweeping/XMineSweepingChapter.lua | 248 + .../XMineSweeping/XMineSweepingGame.lua | 148 + .../XMineSweeping/XMineSweepingGrid.lua | 45 + .../XMineSweeping/XMineSweepingStage.lua | 101 + .../XMiniGame/ComposeFactory/XComposeGame.lua | 316 + .../ComposeFactory/XComposeGameItem.lua | 259 + .../ComposeFactory/XComposeGameItemBag.lua | 221 + .../ComposeFactory/XComposeGameItemGrid.lua | 94 + .../XComposeGameProgressTreasure.lua | 113 + .../ComposeFactory/XComposeGameShop.lua | 59 + .../ComposeFactory/XComposeGameShopGrid.lua | 79 + .../XComposeGameTreasureBox.lua | 61 + .../XFingerGuessingGameController.lua | 193 + .../FingerGuessing/XFingerGuessingStage.lua | 301 + .../XFingerGuessingStageManager.lua | 77 + .../XWhiteValentineChara.lua | 153 + .../XWhiteValentineCharaManager.lua | 156 + .../XWhiteValentineGame.lua | 373 + .../XWhiteValentinePlace.lua | 218 + .../XWhiteValentinePlaceManager.lua | 79 + .../Scripts/XEntity/XMoeWar/XMoeWarMatch.lua | 172 + .../Scripts/XEntity/XMoeWar/XMoeWarPlayer.lua | 215 + .../XMoeWarPreparationAnswerRecord.lua | 44 + .../XMoeWar/XMoeWarPreparationAssistance.lua | 34 + .../XMoeWar/XMoeWarPreparationBaseData.lua | 273 + .../XMoeWar/XMoeWarPreparationHelper.lua | 206 + .../XMoeWar/XMoeWarPreparationQuestion.lua | 41 + .../XMoeWar/XMoeWarPreparationStage.lua | 119 + .../XMoeWar/XMoeWarPreparationVoteItem.lua | 30 + .../XEntity/XMoeWar/XMoeWarVoteItem.lua | 43 + .../Scripts/XEntity/XNameplate/XNameplate.lua | 137 + Resources/Scripts/XEntity/XNieR/XNieRBoss.lua | 30 + .../Scripts/XEntity/XNieR/XNieRChapter.lua | 112 + .../Scripts/XEntity/XNieR/XNieRCharacter.lua | 360 + .../Scripts/XEntity/XNieR/XNieRRepeat.lua | 113 + Resources/Scripts/XEntity/XNieR/XNierPOD.lua | 183 + .../Scripts/XEntity/XPartner/XPartner.lua | 732 ++ .../Scripts/XEntity/XPartner/XPartnerBase.lua | 163 + .../XPartner/XPartnerMainSkillGroup.lua | 119 + .../XPartner/XPartnerPassiveSkillGroup.lua | 36 + .../XPartner/XPartnerSkillGroupBase.lua | 69 + .../XEntity/XPartner/XPartnerStory.lua | 47 + .../XEntity/XPassport/XPassportBaseInfo.lua | 32 + .../XEntity/XPassport/XPassportInfo.lua | 42 + .../Scripts/XEntity/XPayAgent/XPayAgent.lua | 138 + .../XEntity/XPayAgent/XPayHeroAgent.lua | 82 + Resources/Scripts/XEntity/XPlayer.lua | 514 + .../XEntity/XPokemon/XPokemonMonster.lua | 272 + .../XEntity/XPokemon/XPokemonMonsterSkill.lua | 30 + .../XPokemon/XPokemonMonsterSkillGroup.lua | 83 + .../XEntity/XPokemon/XPokemonTeamPosData.lua | 40 + .../Scripts/XEntity/XPuzzleActivityData.lua | 29 + Resources/Scripts/XEntity/XReadOnlyTable.lua | 48 + .../XEntity/XReform/Buff/XReformBuff.lua | 51 + .../XEntity/XReform/Buff/XReformBuffGroup.lua | 43 + .../XReform/Enemy/XReformEnemyGroup.lua | 33 + .../XReform/Enemy/XReformEnemySource.lua | 168 + .../XReform/Enemy/XReformEnemyTarget.lua | 82 + .../Environment/XReformEnvironment.lua | 58 + .../Environment/XReformEnvironmentGroup.lua | 42 + .../XReform/Member/XReformMemberGroup.lua | 61 + .../XReform/Member/XReformMemberSource.lua | 181 + .../XReform/Member/XReformMemberTarget.lua | 77 + .../XReform/XReformBaseSourceGroup.lua | 55 + .../XEntity/XReform/XReformBaseStage.lua | 201 + .../XEntity/XReform/XReformEvolvableStage.lua | 313 + Resources/Scripts/XEntity/XRobot/XRobot.lua | 452 + .../Object/XRpgMakerGameBlock.lua | 23 + .../Object/XRpgMakerGameCube.lua | 21 + .../Object/XRpgMakerGameEndPoint.lua | 71 + .../XRpgMakerGame/Object/XRpgMakerGameGap.lua | 62 + .../Object/XRpgMakerGameMonsterData.lua | 340 + .../Object/XRpgMakerGameMonsterPatrolLine.lua | 20 + .../Object/XRpgMakerGameObject.lua | 506 + .../Object/XRpgMakerGamePlayer.lua | 149 + .../Object/XRpgMakerGameTriggerData.lua | 202 + .../XRpgMakerActivityStageDb.lua | 72 + .../XRpgMakerGame/XRpgMakerGameActivityDb.lua | 63 + .../XRpgMakerGameEnterStageDb.lua | 42 + .../XRpgMakerGame/XRpgMakerGamePosition.lua | 42 + .../XEntity/XRpgTower/XRpgTowerChapter.lua | 105 + .../XEntity/XRpgTower/XRpgTowerCharacter.lua | 431 + .../XEntity/XRpgTower/XRpgTowerItem.lua | 64 + .../XEntity/XRpgTower/XRpgTowerStage.lua | 129 + .../XEntity/XRpgTower/XRpgTowerTalent.lua | 175 + .../XScratchTicketActivityController.lua | 187 + .../XScratchTicket/XScratchTicketStage.lua | 176 + .../XSpringFestivalBoxGift.lua | 96 + .../XSpringFestivalFriendRequestInfo.lua | 76 + .../XStrongholdAssistantRecord.lua | 85 + .../XStronghold/XStrongholdGroupInfo.lua | 131 + .../XStronghold/XStrongholdMineRecord.lua | 47 + .../XEntity/XStronghold/XStrongholdPlugin.lua | 81 + .../XStronghold/XStrongholdStageData.lua | 42 + .../XEntity/XStronghold/XStrongholdTeam.lua | 465 + .../XStronghold/XStrongholdTeamMember.lua | 254 + .../Function/XSuperTowerFunction.lua | 88 + .../Function/XSuperTowerFunctionManager.lua | 96 + .../XSuperTower/Plugin/XSuperTowerPlugin.lua | 84 + .../XSuperTower/Role/XSuperTowerRole.lua | 173 + .../Role/XSuperTowerRoleManager.lua | 491 + .../Shop/XSuperTowerShopManager.lua | 128 + .../Stages/XSuperTowerStageManager.lua | 278 + .../Stages/XSuperTowerTargetStage.lua | 309 + .../XSuperTower/Stages/XSuperTowerTheme.lua | 600 + .../Stages/XSuperTowerTierManager.lua | 275 + .../Stages/XSuperTowerTierStage.lua | 73 + .../XSuperTower/XCollectionManager.lua | 84 + .../XSuperTower/XSuperTowerBagManager.lua | 316 + .../XSuperTowerPluginSlotManager.lua | 158 + .../XSuperTower/XSuperTowerTeamManager.lua | 231 + .../Scripts/XEntity/XTRPG/XTRPGBaseInfo.lua | 96 + .../Scripts/XEntity/XTRPG/XTRPGBossInfo.lua | 66 + .../XEntity/XTRPG/XTRPGClientShopInfo.lua | 41 + .../Scripts/XEntity/XTRPG/XTRPGExamine.lua | 182 + Resources/Scripts/XEntity/XTRPG/XTRPGMaze.lua | 262 + .../Scripts/XEntity/XTRPG/XTRPGMazeCard.lua | 234 + .../Scripts/XEntity/XTRPG/XTRPGMazeLayer.lua | 284 + .../Scripts/XEntity/XTRPG/XTRPGMazeNode.lua | 173 + Resources/Scripts/XEntity/XTRPG/XTRPGRole.lua | 215 + .../XEntity/XTRPG/XTRPGRoleAttribute.lua | 45 + .../Scripts/XEntity/XTRPG/XTRPGRoleTalent.lua | 39 + .../Scripts/XEntity/XTRPG/XTRPGShopInfo.lua | 55 + .../XEntity/XTRPG/XTRPGShopItemInfo.lua | 38 + .../XEntity/XTRPG/XTRPGThirdAreaInfo.lua | 42 + Resources/Scripts/XEntity/XTeam/XTeam.lua | 247 + .../XWorldBoss/XAttributeAreaEntity.lua | 192 + .../XWorldBoss/XAttributeStageEntity.lua | 81 + .../XEntity/XWorldBoss/XBossAreaEntity.lua | 145 + .../XEntity/XWorldBoss/XBuffEntity.lua | 89 + .../XWorldBoss/XPhasesRewardEntity.lua | 39 + .../XEntity/XWorldBoss/XSpecialSaleEntity.lua | 77 + .../XWorldBoss/XWorldBossActivityEntity.lua | 254 + Resources/Scripts/XFormula/XArithmetic.lua | 254 + .../Scripts/XFormula/XConditionFormula.lua | 106 + Resources/Scripts/XFormula/XFormula.lua | 16 + Resources/Scripts/XGame.lua | 156 + .../Scripts/XGuide/Agent/XGuideAgent.lua | 190 + ...XGuideCharacterEquipQualityCompareNode.lua | 45 + .../XGuideCharacterEquipWithPosExistNode.lua | 26 + .../XGuide/Node/XGuideDynamicIndexNode.lua | 36 + .../Scripts/XGuide/Node/XGuideEndNode.lua | 11 + .../XGuide/Node/XGuideFocusOnPanelNode.lua | 64 + .../Node/XGuideFocusOnScrollRectNode.lua | 22 + .../XGuide/Node/XGuideFocusSetActive.lua | 20 + .../XGuide/Node/XGuideForceStepNode.lua | 225 + .../Node/XGuideFubenJumpToStageNode.lua | 23 + .../XGuide/Node/XGuideHideDialogNode.lua | 7 + .../XGuide/Node/XGuideIsAnyClickNode.lua | 14 + .../Node/XGuideIsCharacterInTeamNode.lua | 23 + .../Node/XGuideIsGameObjectActiveNode.lua | 24 + .../XGuide/Node/XGuideIsJoinGuildNode.lua | 9 + .../XGuide/Node/XGuideIsUiOpenNode.lua | 24 + .../XGuide/Node/XGuideOpenDormitoryNode.lua | 21 + .../Scripts/XGuide/Node/XGuideRecordNode.lua | 33 + .../XGuide/Node/XGuideShowDialogNode.lua | 23 + .../XGuide/Node/XGuideShowMaskNode.lua | 26 + .../Scripts/XGuide/Node/XGuideStartNode.lua | 16 + .../XDorm/XHomeChar/XHomeBehaviorState.lua | 33 + .../XHome/XDorm/XHomeChar/XHomeCharAgent.lua | 164 + .../XDorm/XHomeChar/XHomeCharFSMFactory.lua | 36 + .../XHomeCharNode/XHomeCharBubbleNode.lua | 22 + .../XHomeCharChangeStateMachineNode.lua | 21 + .../XHomeCharNode/XHomeCharCheckClick.lua | 19 + ...XHomeCharCheckDisInteractFurnitureNode.lua | 9 + .../XHomeCharCheckDisgustedNode.lua | 5 + .../XHomeCharCheckEventExistNode.lua | 26 + .../XHomeCharCheckFriendNode.lua | 5 + .../XHomeCharCheckInteractNode.lua | 8 + .../XHomeCharCheckPlayAnimationNode.lua | 34 + .../XHomeCharCheckPointerUpNode.lua | 17 + .../XHomeCharCheckRayCastFurnitureNode.lua | 14 + .../XHomeCharCheckRelationNode.lua | 8 + .../XHomeCharCompletedFondleNode.lua | 6 + .../XHomeCharNode/XHomeCharDialogNode.lua | 21 + .../XHomeCharNode/XHomeCharDoEffectNode.lua | 25 + .../XHomeCharDoRoleActionOnlyNode.lua | 22 + .../XHomeCharEventRewardNode.lua | 6 + .../XHomeCharEventTypeCompareNode.lua | 26 + .../XHomeCharNode/XHomeCharFaceLockNode.lua | 22 + .../XHomeCharFondleTypeJudgeNode.lua | 29 + .../XHomeCharForwardToFurnitureNode.lua | 21 + .../XHomeCharNode/XHomeCharHideBubbleNode.lua | 6 + .../XHomeCharNode/XHomeCharHideEffectNode.lua | 6 + .../XHomeCharInteractFunitureActionNode.lua | 9 + .../XHomeCharNode/XHomeCharInteractNode.lua | 9 + .../XHomeCharInteractTypeCompareNode.lua | 25 + .../XHomeCharJudgeAttributeNode.lua | 59 + .../XHomeCharJudgeInteractPosNode.lua | 26 + .../XHomeCharObstacleEnableNode.lua | 22 + .../XHomeCharNode/XHomeCharPathFindNode.lua | 25 + .../XHomeCharRandomDialogNode.lua | 7 + .../XHomeCharNode/XHomeCharReachFurniture.lua | 6 + .../XHomeCharSetCharInteractTriggerNode.lua | 20 + .../XHomeCharSetInteractOffsetNode.lua | 6 + .../XHomeCharSetStayOffsetNode.lua | 7 + .../XHomeCharStateChangeNode.lua | 22 + .../XHomeCharStateCompareNode.lua | 26 + .../XDorm/XHomeChar/XHomeFSM/XHomeCharFSM.lua | 29 + .../XHomeFSM/XHomeCharFSMControl.lua | 13 + .../XHomeChar/XHomeFSM/XHomeCharFSMEmpty.lua | 15 + .../XHomeChar/XHomeFSM/XHomeCharFSMIdle.lua | 15 + .../XHomeFSM/XHomeCharFSMInteract.lua | 21 + .../XHomeChar/XHomeFSM/XHomeCharFSMMood.lua | 15 + .../Scripts/XHome/XDorm/XHomeCharManager.lua | 432 + .../Scripts/XHome/XDorm/XHomeCharObj.lua | 897 ++ .../Scripts/XHome/XDorm/XHomeDormManager.lua | 1095 ++ .../XHomeFurniture/XHomeFurnitureAgent.lua | 55 + ...meFurnitureChangeFurniturePositionNode.lua | 9 + .../XHomeFurnitureCheckPointerUpNode.lua | 17 + ...XHomeFurnitureCheckRayCastFunitureNode.lua | 14 + .../XHomeFurnitureDoActionOnlyNode.lua | 22 + .../XHomeFurnitureDoEffectNode.lua | 20 + .../XHomeFurnitureHideNode.lua | 6 + ...omeFurnitureResetFurniturePositionNode.lua | 6 + .../XHomeFurnitureSaveFurnitureInRoomNode.lua | 6 + .../XHomeFurnitureSaveSuccessNode.lua | 21 + .../XHomeFurnitureStateChangeNode.lua | 22 + .../Scripts/XHome/XDorm/XHomeFurnitureObj.lua | 1392 +++ .../Scripts/XHome/XDorm/XHomeRoomObj.lua | 1070 ++ Resources/Scripts/XHome/XHomeScene.lua | 172 + Resources/Scripts/XHome/XHomeSceneManager.lua | 212 + .../XHome/XInfrastructure/XDeviceObject.lua | 200 + .../XHomeInfrastructureManager.lua | 57 + .../XHome/XInfrastructure/XRoomObject.lua | 142 + .../Scripts/XHome/XSceneEntityManager.lua | 47 + Resources/Scripts/XHome/XSceneObject.lua | 66 + .../Scripts/XHome/XSceneResourceManager.lua | 100 + Resources/Scripts/XHotReload.lua | 131 + Resources/Scripts/XMain.lua | 212 + .../XManager/XActivityBriefManager.lua | 293 + .../Scripts/XManager/XActivityManager.lua | 417 + .../Scripts/XManager/XAgreementManager.lua | 99 + .../XManager/XAntiAddictionManager.lua | 88 + .../Scripts/XManager/XAppEventManager.lua | 170 + .../Scripts/XManager/XArchiveManager.lua | 2442 ++++ Resources/Scripts/XManager/XArenaManager.lua | 1578 +++ .../Scripts/XManager/XArenaOnlineManager.lua | 876 ++ Resources/Scripts/XManager/XAssistManager.lua | 50 + Resources/Scripts/XManager/XAttribManager.lua | 943 ++ .../Scripts/XManager/XAutoFightManager.lua | 227 + .../Scripts/XManager/XAutoWindowManager.lua | 212 + .../Scripts/XManager/XBaseEquipManager.lua | 702 ++ Resources/Scripts/XManager/XBfrtManager.lua | 935 ++ .../Scripts/XManager/XBountyTaskManager.lua | 573 + Resources/Scripts/XManager/XCdKeyManager.lua | 25 + .../Scripts/XManager/XCharacterManager.lua | 1650 +++ Resources/Scripts/XManager/XChatManager.lua | 1369 +++ .../Scripts/XManager/XChessPursuitManager.lua | 1045 ++ .../XManager/XChristmasTreeManager.lua | 528 + .../XManager/XClickClearGameManager.lua | 510 + .../XManager/XCollectionWallManager.lua | 489 + .../Scripts/XManager/XComeAcrossManager.lua | 127 + .../Scripts/XManager/XComposeGameManager.lua | 303 + .../Scripts/XManager/XConditionManager.lua | 1332 +++ .../Scripts/XManager/XCoupletGameManager.lua | 389 + Resources/Scripts/XManager/XDataCenter.lua | 201 + .../Scripts/XManager/XDisplayManager.lua | 219 + Resources/Scripts/XManager/XDormManager.lua | 2462 ++++ Resources/Scripts/XManager/XDrawManager.lua | 497 + .../XManager/XEliminateGameManager.lua | 465 + Resources/Scripts/XManager/XEquipManager.lua | 3249 ++++++ Resources/Scripts/XManager/XEventManager.lua | 142 + .../Scripts/XManager/XExhibitionManager.lua | 301 + .../Scripts/XManager/XExpeditionManager.lua | 789 ++ .../Scripts/XManager/XFashionManager.lua | 732 ++ .../Scripts/XManager/XFashionStoryManager.lua | 223 + .../Scripts/XManager/XFavorabilityManager.lua | 734 ++ .../XManager/XFightCharacterManager.lua | 273 + .../Scripts/XManager/XFightEquipManager.lua | 702 ++ .../XManager/XFightInfestorExploreManager.lua | 188 + .../Scripts/XManager/XFightPartnerManager.lua | 363 + .../Scripts/XManager/XFightUiManager.lua | 47 + .../Scripts/XManager/XFightWordsManager.lua | 147 + .../XManager/XFingerGuessingManager.lua | 153 + .../XManager/XFuBenActivityPuzzleManager.lua | 658 ++ .../XFubenActivityBossSingleManager.lua | 252 + .../XManager/XFubenActivityBranchManager.lua | 186 + .../Scripts/XManager/XFubenAssignManager.lua | 1222 ++ .../XManager/XFubenBabelTowerManager.lua | 812 ++ .../XManager/XFubenBossOnlineManager.lua | 393 + .../XManager/XFubenBossSingleManager.lua | 706 ++ .../XManager/XFubenCoupleCombatManager.lua | 407 + .../Scripts/XManager/XFubenDailyManager.lua | 297 + .../XManager/XFubenExperimentManager.lua | 414 + .../Scripts/XManager/XFubenExploreManager.lua | 374 + .../XManager/XFubenExtraChapterManager.lua | 787 ++ .../XFubenFestivalActivityManager.lua | 180 + .../Scripts/XManager/XFubenHackManager.lua | 687 ++ .../XManager/XFubenInfestorExploreManager.lua | 2270 ++++ .../XManager/XFubenMainLineManager.lua | 1005 ++ Resources/Scripts/XManager/XFubenManager.lua | 3096 +++++ .../XManager/XFubenNewCharActivityManager.lua | 396 + .../XManager/XFubenRepeatChallengeManager.lua | 466 + .../XManager/XFubenResourceManager.lua | 199 + .../XManager/XFubenRogueLikeManager.lua | 1193 ++ .../XManager/XFubenSimulatedCombatManager.lua | 881 ++ .../XManager/XFubenSpecialTrainManager.lua | 479 + .../XManager/XFubenUnionKillManager.lua | 675 ++ .../XManager/XFubenUnionKillRoomManager.lua | 497 + .../XManager/XFubenUrgentEventManager.lua | 93 + .../Scripts/XManager/XFubenZhouMuManager.lua | 231 + .../XFunctionCommunicationManager.lua | 214 + .../XManager/XFunctionEventManager.lua | 211 + .../Scripts/XManager/XFunctionManager.lua | 664 ++ .../XManager/XFunctionalSkipManager.lua | 1000 ++ .../Scripts/XManager/XFurnitureManager.lua | 1298 +++ Resources/Scripts/XManager/XGachaManager.lua | 415 + Resources/Scripts/XManager/XGmTestManager.lua | 532 + .../Scripts/XManager/XGoodsCommonManager.lua | 676 ++ .../Scripts/XManager/XGuardCampManager.lua | 390 + Resources/Scripts/XManager/XGuideManager.lua | 518 + .../Scripts/XManager/XGuildBossManager.lua | 919 ++ Resources/Scripts/XManager/XGuildManager.lua | 2298 ++++ .../Scripts/XManager/XHardwareManager.lua | 540 + .../Scripts/XManager/XHaruUserManager.lua | 76 + .../Scripts/XManager/XHeadPortraitManager.lua | 389 + .../Scripts/XManager/XHeroSdkManager.lua | 291 + Resources/Scripts/XManager/XHgSdkManager.lua | 534 + .../XManager/XHostelDelegateManager.lua | 191 + Resources/Scripts/XManager/XHostelManager.lua | 600 + Resources/Scripts/XManager/XHudManager.lua | 71 + .../XManager/XInvertCardGameManager.lua | 359 + Resources/Scripts/XManager/XItemManager.lua | 1564 +++ .../Scripts/XManager/XKillZoneManager.lua | 1105 ++ .../Scripts/XManager/XLoadingManager.lua | 82 + Resources/Scripts/XManager/XLoginManager.lua | 985 ++ Resources/Scripts/XManager/XLottoManager.lua | 108 + Resources/Scripts/XManager/XLuaUiManager.lua | 612 + .../Scripts/XManager/XMagicSkillManager.lua | 203 + Resources/Scripts/XManager/XMailManager.lua | 391 + .../XManager/XMaintainerActionManager.lua | 441 + .../XManager/XMarketingActivityManager.lua | 1022 ++ Resources/Scripts/XManager/XMedalManager.lua | 1095 ++ .../Scripts/XManager/XMentorSystemManager.lua | 926 ++ .../Scripts/XManager/XMineSweepingManager.lua | 281 + Resources/Scripts/XManager/XModelManager.lua | 573 + Resources/Scripts/XManager/XMoeWarManager.lua | 1220 ++ .../XManager/XMovieAssembleManager.lua | 38 + Resources/Scripts/XManager/XMovieManager.lua | 443 + .../Scripts/XManager/XMusicPlayerManager.lua | 38 + .../Scripts/XManager/XNewRoleShowManager.lua | 22 + Resources/Scripts/XManager/XNieRManager.lua | 1429 +++ Resources/Scripts/XManager/XNoticeManager.lua | 1244 +++ Resources/Scripts/XManager/XNotifyManager.lua | 210 + .../Scripts/XManager/XPartnerManager.lua | 882 ++ .../XManager/XPartnerTeachingManager.lua | 129 + .../Scripts/XManager/XPassportManager.lua | 381 + Resources/Scripts/XManager/XPayManager.lua | 240 + .../Scripts/XManager/XPermissionManager.lua | 82 + .../Scripts/XManager/XPersonalInfoManager.lua | 349 + .../Scripts/XManager/XPhotographManager.lua | 406 + .../XManager/XPlatformShareManager.lua | 133 + .../Scripts/XManager/XPlayerInfoManager.lua | 216 + Resources/Scripts/XManager/XPlayerManager.lua | 118 + .../Scripts/XManager/XPokemonManager.lua | 1003 ++ .../XManager/XPokerGuessingManager.lua | 238 + .../Scripts/XManager/XPracticeManager.lua | 202 + .../Scripts/XManager/XPrequelManager.lua | 483 + .../Scripts/XManager/XPurchaseManager.lua | 870 ++ .../XManager/XPuzzleActivityManager.lua | 192 + .../Scripts/XManager/XRTextureManager.lua | 33 + .../Scripts/XManager/XRedPointManager.lua | 189 + .../XManager/XReformActivityManager.lua | 555 + .../Scripts/XManager/XRegressionManager.lua | 562 + Resources/Scripts/XManager/XReportManager.lua | 36 + Resources/Scripts/XManager/XResetManager.lua | 80 + Resources/Scripts/XManager/XRewardManager.lua | 760 ++ Resources/Scripts/XManager/XRobotManager.lua | 285 + .../XManager/XRoomCharFilterTipsManager.lua | 357 + Resources/Scripts/XManager/XRoomManager.lua | 1949 ++++ .../Scripts/XManager/XRoomSingleManager.lua | 52 + .../Scripts/XManager/XRpgMakerGameManager.lua | 631 ++ .../Scripts/XManager/XRpgTowerManager.lua | 791 ++ .../XManager/XScratchTicketManager.lua | 134 + Resources/Scripts/XManager/XServerManager.lua | 245 + Resources/Scripts/XManager/XSetManager.lua | 209 + Resources/Scripts/XManager/XShopManager.lua | 827 ++ .../Scripts/XManager/XSignBoardManager.lua | 597 + Resources/Scripts/XManager/XSignInManager.lua | 308 + Resources/Scripts/XManager/XSocialManager.lua | 907 ++ Resources/Scripts/XManager/XSoundManager.lua | 264 + .../Scripts/XManager/XSpecialShopManager.lua | 168 + .../XSpringFestivalActivityManager.lua | 717 ++ Resources/Scripts/XManager/XStoryManager.lua | 30 + .../Scripts/XManager/XStrongholdManager.lua | 2905 +++++ .../Scripts/XManager/XSuperTowerManager.lua | 1054 ++ Resources/Scripts/XManager/XTRPGManager.lua | 2271 ++++ Resources/Scripts/XManager/XTableManager.lua | 670 ++ .../Scripts/XManager/XTaskForceManager.lua | 917 ++ Resources/Scripts/XManager/XTaskManager.lua | 2462 ++++ Resources/Scripts/XManager/XTeamManager.lua | 492 + Resources/Scripts/XManager/XTipManager.lua | 90 + Resources/Scripts/XManager/XTrialManager.lua | 473 + Resources/Scripts/XManager/XTypeManager.lua | 51 + Resources/Scripts/XManager/XUiManager.lua | 350 + Resources/Scripts/XManager/XUiPcManager.lua | 156 + .../Scripts/XManager/XUploadLogManager.lua | 75 + Resources/Scripts/XManager/XUserManager.lua | 211 + Resources/Scripts/XManager/XVideoManager.lua | 92 + Resources/Scripts/XManager/XVoteManager.lua | 152 + .../XManager/XWeaponFashionManager.lua | 274 + .../XManager/XWhiteValentineManager.lua | 281 + .../Scripts/XManager/XWorldBossManager.lua | 632 ++ .../Scripts/XMerge/XMergeAppEventChecker.lua | 73 + Resources/Scripts/XMerge/XMergeChecker.lua | 16 + .../XMovieActions/XMovieActionActorAppear.lua | 61 + .../XMovieActionActorChangeFace.lua | 26 + .../XMovieActionActorDisappear.lua | 49 + .../XMovieActions/XMovieActionActorShift.lua | 45 + .../XMovieActionAnimationPlay.lua | 22 + .../XMovieActionAudioInterrupt.lua | 15 + .../XMovieActions/XMovieActionBase.lua | 238 + .../XMovieActions/XMovieActionBgSwitch.lua | 84 + .../XMovieActions/XMovieActionDelaySkip.lua | 14 + .../XMovieActions/XMovieActionDialog.lua | 118 + .../XMovieActions/XMovieActionEffectPlay.lua | 59 + .../XMovieActionFullScreenDialog.lua | 187 + .../XMovieActionPrefabAnimation.lua | 69 + .../XMovieActions/XMovieActionSelection.lua | 124 + .../XMovieActions/XMovieActionSetGray.lua | 47 + .../XMovieActions/XMovieActionSoundPlay.lua | 78 + .../XMovieActions/XMovieActionStaff.lua | 155 + .../XMovieActions/XMovieActionTheme.lua | 22 + .../XMovieActions/XMovieActionUnLoad.lua | 49 + .../XMovieActions/XMovieActionVideoPlay.lua | 27 + .../XMovieActions/XMovieActionYieldResume.lua | 35 + .../XOverseas/XConfig/XSlotMachineConfigs.lua | 142 + .../XSlotMachine/XSlotMachineDataEntity.lua | 161 + .../XOverseas/XManager/XFireworksManager.lua | 169 + .../XManager/XSlotMachineManager.lua | 455 + .../XUi/XUiBubbleTip/XUiBubbleTip.lua | 18 + .../XUi/XUiFireworks/XUiFireworks.lua | 106 + .../XUi/XUiFireworks/XUiFireworksLog.lua | 34 + .../XUiFireworks/XUiFireworksPanelRecord.lua | 43 + .../XUiFireworks/XUiFireworksPanelRule.lua | 37 + .../XUi/XUiSlotMachine/XUiSlotMachine.lua | 259 + .../XUiSlotMachine/XUiSlotMachineIconItem.lua | 20 + .../XUiSlotMachine/XUiSlotMachinePanel.lua | 151 + .../XUiSlotMachineRewardItem.lua | 53 + .../XUiSlotMachineRewardPanel.lua | 135 + .../XUiSlotMachine/XUiSlotMachineRules.lua | 50 + .../XUiSlotMachineRulesItem.lua | 20 + .../XUiSlotMachineRulesPanel.lua | 42 + .../XUiSlotMachineRulesResearchLogItem.lua | 40 + .../XUiSlotMachineRulesResearchPanel.lua | 48 + .../XUi/XUiSlotMachine/XUiSlotMachineTask.lua | 72 + .../XUiSlotMachineTaskContentPanel.lua | 77 + .../XUiSlotMachine/XUiSlotMachineTaskGrid.lua | 89 + .../XUiSlotMachineTipsPanel.lua | 38 + .../XRedPoint/XRedPointConditionGroup.lua | 88 + .../Scripts/XRedPoint/XRedPointConditions.lua | 387 + ...ointConditionActivityBriefTaskFinished.lua | 18 + .../XRedPointConditionActivityDrawNew.lua | 19 + ...XRedPointConditionActivityNewAcitivies.lua | 19 + ...PointConditionActivityNewAcitiviesTogs.lua | 16 + ...intConditionActivityNewActivityNotices.lua | 16 + .../XRedPointConditionActivityNewNotices.lua | 16 + .../XRedPointConditionArchiveAwareness.lua | 23 + ...intConditionArchiveAwarenessGridNewTag.lua | 18 + ...edPointConditionArchiveAwarenessNewTag.lua | 19 + ...ConditionArchiveAwarenessSettingUnlock.lua | 19 + .../XRedPointConditionArchiveCGAll.lua | 17 + .../XRedPointConditionArchiveCGRed.lua | 17 + .../XRedPointConditionArchiveCGTypeRed.lua | 17 + .../XRedPointConditionArchiveMonsterAll.lua | 19 + .../XRedPointConditionArchiveMonsterInfo.lua | 16 + .../XRedPointConditionArchiveMonsterRed.lua | 20 + ...RedPointConditionArchiveMonsterSetting.lua | 16 + .../XRedPointConditionArchiveMonsterSkill.lua | 16 + .../XRedPointConditionArchiveMonsterTag.lua | 16 + ...RedPointConditionArchiveMonsterTypeRed.lua | 20 + ...RedPointConditionArchiveMonsterTypeTag.lua | 16 + .../XRedPointConditionArchiveWeapon.lua | 23 + ...dPointConditionArchiveWeaponGridNewTag.lua | 19 + .../XRedPointConditionArchiveWeaponNewTag.lua | 20 + ...intConditionArchiveWeaponSettingUnlock.lua | 19 + .../XRedPointConditionArenaApply.lua | 19 + .../XRedPointConditionArenaTask.lua | 16 + .../XRedPointConditionAssign.lua | 18 + .../XRedPointConditionBabelTower.lua | 37 + .../XRedPointConditionBabelTowerReward.lua | 12 + .../XRedPointConditionBaseEquip.lua | 24 + .../XRedPointConditionBfrtChapterReward.lua | 18 + .../XRedPointConditionBossSingle.lua | 35 + .../XRedPointConditionBossSingleReward.lua | 9 + .../XRedPointConditionBountyTask.lua | 25 + .../XRedPointConditionBriefEntry.lua | 42 + .../XRedPointConditionChapterReward.lua | 35 + ...XRedPointConditionChapterSectionReward.lua | 18 + .../XRedPointConditionCharacter.lua | 41 + .../XRedPointConditionCharacterGrade.lua | 30 + .../XRedPointConditionCharacterLevel.lua | 35 + .../XRedPointConditionCharacterQuality.lua | 29 + .../XRedPointConditionCharacterSkill.lua | 30 + .../XRedPointConditionCharacterUnlock.lua | 15 + .../XRedPointConditionChessPursuitReward.lua | 16 + .../XRedPointConditionChristmasTree.lua | 31 + .../XRedPointConditionChristmasTreeAward.lua | 17 + ...ntConditionChristmasTreeOrnamentActive.lua | 17 + ...ointConditionChristmasTreeOrnamentRead.lua | 17 + ...ointConditionClickClearDifficultUnlock.lua | 17 + .../XRedPointConditionClickClearReward.lua | 18 + .../XRedPointConditionCoupleCombatHard.lua | 25 + .../XRedPointConditionCoupleCombatNormal.lua | 25 + ...XRedPointConditionCoupletGamePlayVideo.lua | 17 + .../XRedPointConditionCoupletGameRed.lua | 39 + ...RedPointConditionCoupletGameRewardTask.lua | 17 + .../XRedPointConditionDefault.lua | 11 + .../XRedPointConditionDormMainTaskRed.lua | 21 + .../XRedPointConditionDormRed.lua | 34 + .../XRedPointConditionDormTaskType.lua | 18 + .../XRedPointConditionDormWork.lua | 16 + .../XRedPointConditionDragPuzzleAward.lua | 19 + ...XRedPointConditionDragPuzzleDecryption.lua | 18 + .../XRedPointConditionDragPuzzleSwitch.lua | 17 + .../XRedPointConditionDragPuzzleTab.lua | 21 + .../XRedPointConditionDragPuzzleVideo.lua | 18 + .../XRedPointConditionExhibitionNew.lua | 22 + .../XRedPointConditionExpeditionRecruit.lua | 30 + ...dPointConditionExperimentChapterReward.lua | 19 + .../XRedPointConditionExperimentRed.lua | 19 + .../XRedPointConditionExplore.lua | 11 + .../XRedPointConditionExtra.lua | 54 + ...dPointConditionExtraChapterExploreItem.lua | 17 + .../XRedPointConditionExtraChapterReward.lua | 31 + .../XRedPointConditionExtraTreasure.lua | 15 + ...RedPointConditionFashionStoryHaveStage.lua | 39 + .../XRedPointConditionFavorability.lua | 58 + .../XRedPointConditionFavorabilityAction.lua | 22 + .../XRedPointConditionFavorabilityAudio.lua | 22 + ...XRedPointConditionFavorabilityDocument.lua | 41 + .../XRedPointConditionFavorabilityGift.lua | 29 + .../XRedPointConditionFavorabilityInfo.lua | 24 + .../XRedPointConditionFavorabilityPlot.lua | 28 + .../XRedPointConditionFavorabilityRumor.lua | 22 + ...RedPointConditionFingerGuessingTaskRed.lua | 15 + .../XRedPointConditionFireworks.lua | 18 + .../XRedPointConditionFriendChatPrivate.lua | 22 + .../XRedPointConditionFriendContact.lua | 19 + .../XRedPointConditionFriendWaitPass.lua | 17 + ...edPointConditionFuBenClickClearGameRed.lua | 22 + ...edPointConditionFuBenDragPuzzleGameRed.lua | 36 + .../XRedPointConditionFubenDailyShop.lua | 15 + .../XRedPointConditionFubenHackBuff.lua | 20 + .../XRedPointConditionFubenHackStar.lua | 20 + .../XRedPointConditionFurnitureCreate.lua | 17 + .../XRedPointConditionGetCard.lua | 28 + .../XRedPointConditionGetFirstRecharge.lua | 9 + .../XRedPointConditionGuardCampRed.lua | 19 + .../XRedPointConditionGuildActiveGift.lua | 30 + .../XRedPointConditionGuildApplyList.lua | 25 + .../XRedPointConditionGuildBoss.lua | 27 + .../XRedPointConditionGuildBossHp.lua | 22 + .../XRedPointConditionGuildBossScore.lua | 18 + .../XRedPointConditionGuildChallenge.lua | 32 + .../XRedPointConditionGuildInformation.lua | 28 + .../XRedPointConditionGuildMember.lua | 22 + .../XRedPointConditionHeadPortraitNew.lua | 19 + .../XRedPointConditionInvertCardGameRed.lua | 16 + .../XRedPointConditionInvertCardGameTog.lua | 16 + .../XRedPointConditionKillZoneActivity.lua | 34 + ...dPointConditionKillZoneDailyStarReward.lua | 25 + .../XRedPointConditionKillZoneNewChapter.lua | 23 + .../XRedPointConditionKillZoneNewDiff.lua | 26 + ...RedPointConditionKillZonePluginOperate.lua | 27 + .../XRedPointConditionKillZoneStarReward.lua | 26 + .../XRedPointConditionKoroCharActivity.lua | 32 + ...ointConditionKoroCharActivityChallenge.lua | 15 + ...PointConditionKoroCharActivityTeaching.lua | 15 + .../XRedPointConditionMailPersonal.lua | 21 + .../XRedPointConditionMainChapter.lua | 19 + .../XRedPointConditionMainDispatch.lua | 22 + .../XRedPointConditionMainFriend.lua | 26 + .../XRedPointConditionMainLineExploreItem.lua | 19 + .../XRedPointConditionMainLineTreasure.lua | 16 + .../XRedPointConditionMainMail.lua | 15 + .../XRedPointConditionMainMember.lua | 36 + .../XRedPointConditionMainNewPlayerTask.lua | 37 + .../XRedPointConditionMainNotice.lua | 19 + .../XRedPointConditionMainSet.lua | 17 + .../XRedPointConditionMainSpecialShop.lua | 12 + .../XRedPointConditionMainTask.lua | 40 + .../XRedPointConditionMedalNew.lua | 21 + .../XRedPointConditionMentorApplyRed.lua | 22 + .../XRedPointConditionMentorRewardRed.lua | 36 + .../XRedPointConditionMentorTaskRed.lua | 39 + .../XRedPointConditionMineSweepingRed.lua | 18 + .../XRedPointConditionMoeWarDrawRed.lua | 18 + .../XRedPointConditionMoeWarPreparation.lua | 30 + ...intConditionMoeWarPreparationOpenStage.lua | 19 + ...dPointConditionMoeWarPreparationReward.lua | 33 + .../XRedPointConditionMoeWarRecruit.lua | 15 + .../XRedPointConditionMoeWarTask.lua | 22 + .../XRedPointConditionMoeWarTaskTab.lua | 16 + .../XRedPointConditionMovieAssemble01Red.lua | 15 + ...RedPointConditionMovieAssembleMovieRed.lua | 15 + .../XRedPointConditionMovieAssembleRed.lua | 15 + .../XRedPointConditionNewChallenge.lua | 16 + .../XRedPointConditionNewCharActTreasure.lua | 16 + ...RedPointConditionNewYearDiviningNotGet.lua | 7 + .../XRedPointConditionNieRCharacterRed.lua | 22 + .../XRedPointConditionNieRPODRed.lua | 29 + .../XRedPointConditionNieRRed.lua | 41 + .../XRedPointConditionNieRRepeatRed.lua | 30 + .../XRedPointConditionNieRTaskRed.lua | 16 + .../XRedPointConditionNierCanFight.lua | 23 + .../XRedPointConditionPartnerCanCompose.lua | 21 + .../XRedPointConditionPartnerNewSkill.lua | 20 + .../XRedPointConditionPassport.lua | 50 + .../XRedPointConditionPassportPanelReward.lua | 25 + ...XRedPointConditionPassportTaskActivity.lua | 22 + .../XRedPointConditionPassportTaskDaily.lua | 22 + .../XRedPointConditionPassportTaskWeekly.lua | 22 + ...intConditionPicCompositionTaskFinished.lua | 19 + .../XRedPointConditionPlayerAchieve.lua | 40 + .../XRedPointConditionPlayerAchieveType.lua | 21 + .../XRedPointConditionPlayerSetName.lua | 21 + ...dPointConditionPokemonCanGetTimeSupply.lua | 16 + .../XRedPointConditionPokemonNewRole.lua | 16 + .../XRedPointConditionPokemonRed.lua | 14 + .../XRedPointConditionPokemonTaskRed.lua | 11 + .../XRedPointConditionPokerGuessingRed.lua | 11 + .../XRedPointConditionPrequel.lua | 36 + .../XRedPointConditionPurchase.lua | 25 + .../XRedPointConditionPurchaseAccumulate.lua | 20 + .../XRedPointConditionPurchaseLB.lua | 16 + .../XRedPointConditionReceiveChat.lua | 19 + .../XRedPointConditionReformAllRedPoint.lua | 22 + .../XRedPointConditionReformBaseStageOpen.lua | 14 + ...intConditionReformEvolvableStageUnlock.lua | 15 + .../XRedPointConditionReformTaskGetReward.lua | 22 + .../XRedPointConditionRegression.lua | 25 + .../XRedPointConditionRegressionTask.lua | 21 + .../XRedPointConditionRegressionTaskType.lua | 20 + ...tConditionRepeatChallengeChapterReward.lua | 9 + ...RedPointConditionRepeatChallengeReward.lua | 23 + .../XRedPointConditionRogueLikeMain.lua | 24 + .../XRedPointConditionRpgMakerGame.lua | 11 + .../XRedPointConditionRpgTower.lua | 27 + ...edPointConditionRpgTowerDailyRewardRed.lua | 17 + .../XRedPointConditionRpgTowerTaskRed.lua | 15 + .../XRedPointConditionRpgTowerTeamRed.lua | 15 + .../XRedPointConditionSTRoleInDult.lua | 10 + .../XRedPointConditionSTRoleLevelUp.lua | 11 + .../XRedPointConditionSTRolePlugin.lua | 11 + .../XRedPointConditionShortStory.lua | 33 + .../XRedPointConditionSimulatedCombat.lua | 39 + ...PointConditionSimulatedCombatChallenge.lua | 32 + ...XRedPointConditionSimulatedCombatPoint.lua | 30 + .../XRedPointConditionSimulatedCombatStar.lua | 22 + .../XRedPointConditionSimulatedCombatTask.lua | 38 + .../XRedPointConditionSlotMachine.lua | 11 + .../XRedPointConditionSlotMachineL.lua | 11 + .../XRedPointConditionSpecialTrain.lua | 29 + .../XRedPointConditionSpecialTrainPoint.lua | 16 + ...XRedPointConditionSpringFestivalBagRed.lua | 17 + ...dPointConditionSpringFestivalRewardRed.lua | 29 + ...RedPointConditionSpringFestivalTaskRed.lua | 16 + ...RedPointConditionStrongholdMineralLeft.lua | 11 + ...edPointConditionStrongholdRewardCanGet.lua | 21 + .../XRedPointConditionSubMenuNewNotices.lua | 16 + .../XRedPointConditionTRPGChapterReward.lua | 16 + .../XRedPointConditionTRPGMainMode.lua | 30 + .../XRedPointConditionTRPGMainView.lua | 33 + .../XRedPointConditionTaskCourse.lua | 17 + .../XRedPointConditionTaskLimited.lua | 25 + .../XRedPointConditionTaskType.lua | 69 + .../XRedPointConditionTaskWeekActive.lua | 21 + .../XRedPointConditionTrial.lua | 31 + .../XRedPointConditionTrialReward.lua | 31 + .../XRedPointConditionTrialUnlock.lua | 18 + .../XRedPointConditionUnGuildNews.lua | 28 + .../XRedPointConditionWhite2021Encounter.lua | 17 + .../XRedPointConditionWhite2021Invite.lua | 16 + .../XRedPointConditionWhite2021Task.lua | 15 + ...RedPointConditionWhiteValentineTaskRed.lua | 17 + .../XRedPointConditionWindowsInlay.lua | 19 + .../XRedPointConditionWorldBossRed.lua | 26 + .../XRedPointConditionZhouMuTask.lua | 24 + .../XRedPointTRPGAreaReward.lua | 10 + .../XRedPointTRPGCollectionMemoir.lua | 39 + .../XRedPointTRPGRoleTalent.lua | 18 + .../XRedPointTRPGSecondMainReward.lua | 10 + .../XRedPointTRPGTruthRoadReward.lua | 22 + .../XRedPointTRPGWorldBossReward.lua | 18 + .../Scripts/XRedPoint/XRedPointEvent.lua | 143 + .../XRedPoint/XRedPointEventElement.lua | 27 + .../Scripts/XRedPoint/XRedPointListener.lua | 26 + .../Scripts/XUi/UiLoading/XUiLoading.lua | 40 + .../ScratchTicket/XUiScratchTicketGrid.lua | 102 + .../XUiScratchTicketPanelChose.lua | 32 + .../XUiScratchTicketPanelGrids.lua | 91 + .../XUiScratchTicketPanelLeft.lua | 131 + .../XUiScratchTicketPanelPlay.lua | 199 + .../XUiScratchTicketPanelPreview.lua | 29 + .../XUiScratchTicketPanelReady.lua | 71 + .../XUiScratchTicketPanelSelectChose.lua | 55 + .../XUiScratchTicketPanelTop.lua | 69 + .../XUi/XUiActivityBase/XUiActivityBase.lua | 134 + .../XUiActivityBase/XUiActivityBaseChild.lua | 421 + .../XUi/XUiActivityBase/XUiActivityLink.lua | 28 + .../XUi/XUiActivityBase/XUiConsumeReward.lua | 115 + .../XUiGridAcceptInvitation.lua | 25 + .../XUiActivityBase/XUiGridActivityLink.lua | 28 + .../XUiActivityBase/XUiGridConsumeReward.lua | 46 + .../XUiActivityBase/XUiGridPuzzlePiece.lua | 78 + .../XUiActivityBase/XUiGridSendInvitation.lua | 57 + .../XUi/XUiActivityBase/XUiJigsawPuzzle.lua | 124 + .../XUiPanelAcceptInvitation.lua | 143 + .../XUi/XUiActivityBase/XUiPanelLink.lua | 113 + .../XUiPanelSendInvitation.lua | 147 + .../XUi/XUiActivityBase/XUiPanelShop.lua | 182 + .../XUi/XUiActivityBase/XUiPanelSkip.lua | 23 + .../XUi/XUiActivityBase/XUiPanelTask.lua | 87 + .../XUi/XUiActivityBase/XUiScratchTicket.lua | 164 + .../XUiActivityBossSingle.lua | 304 + .../XUiActivityBossSingleReward.lua | 44 + .../XUiAttentionDesc.lua | 37 + .../XUiBossSingleTreasureGrid.lua | 99 + .../XUiGridActivityBossSingle.lua | 48 + .../XUiActivityBossSingleDetail.lua | 173 + .../XUiActivityBranch/XUiActivityBranch.lua | 283 + .../XUiActivityBranchReward.lua | 48 + .../XUiFubenBranchStageDetail.lua | 153 + .../XUiGridActivityBranchReward.lua | 74 + .../XUiActivityBrief/XActivityBrieButton.lua | 104 + .../XUiActivityBrief/XActivityBrieIsOpen.lua | 749 ++ .../XUiActivityBrief/XUiActivityBriefBase.lua | 203 + .../XUiActivityBriefRefreshButton.lua | 882 ++ .../XUiActivityBrief/XUiActivityBriefShop.lua | 265 + .../XUiActivityBriefStory.lua | 65 + .../XUiActivityBrief/XUiActivityBriefTask.lua | 118 + .../XUi/XUiActivityBrief/XUiPanelStory.lua | 66 + .../XUi/XUiArchive/XUiArchiveAwareness.lua | 313 + .../XUiArchive/XUiArchiveAwarenessDetail.lua | 336 + .../Scripts/XUi/XUiArchive/XUiArchiveCG.lua | 105 + .../XUi/XUiArchive/XUiArchiveCGDetail.lua | 154 + .../XUi/XUiArchive/XUiArchiveEmail.lua | 172 + .../Scripts/XUi/XUiArchive/XUiArchiveMain.lua | 52 + .../XUi/XUiArchive/XUiArchiveMonster.lua | 154 + .../XUiArchive/XUiArchiveMonsterComment.lua | 142 + .../XUiArchive/XUiArchiveMonsterDetail.lua | 433 + .../XUiArchive/XUiArchiveMonsterEvaluate.lua | 176 + .../XUi/XUiArchive/XUiArchiveMonsterInfo.lua | 86 + .../XUiArchive/XUiArchiveMonsterSelectTag.lua | 59 + .../XUiArchive/XUiArchiveMonsterSetting.lua | 80 + .../XUi/XUiArchive/XUiArchiveMonsterSkill.lua | 58 + .../XUiArchive/XUiArchiveMonsterSynopsis.lua | 416 + .../Scripts/XUi/XUiArchive/XUiArchiveNpc.lua | 258 + .../XUi/XUiArchive/XUiArchivePartner.lua | 88 + .../XUiArchive/XUiArchivePartnerDetail.lua | 354 + .../XUi/XUiArchive/XUiArchiveStory.lua | 100 + .../XUi/XUiArchive/XUiArchiveStoryDetail.lua | 132 + .../XUi/XUiArchive/XUiArchiveStoryDialog.lua | 70 + .../XUi/XUiArchive/XUiArchiveWeapon.lua | 390 + .../XUiArchiveWeaponAchievement.lua | 62 + .../XUi/XUiArchive/XUiArchiveWeaponDetail.lua | 290 + .../XUiArchiveWeaponsCollectionTips.lua | 28 + .../Scripts/XUi/XUiArchive/XUiGridArchive.lua | 106 + .../XUiArchive/XUiGridArchiveAwareness.lua | 137 + .../XUiGridArchiveAwarenessDetail.lua | 39 + .../XUiGridArchiveAwarenessSetting.lua | 20 + .../XUi/XUiArchive/XUiGridArchiveCG.lua | 80 + .../XUiGridArchiveCommunication.lua | 32 + .../XUi/XUiArchive/XUiGridArchiveEmail.lua | 54 + .../XUiArchive/XUiGridArchiveEquipSetting.lua | 49 + .../XUi/XUiArchive/XUiGridArchiveMonster.lua | 78 + .../XUi/XUiArchive/XUiGridArchiveNpc.lua | 234 + .../XUi/XUiArchive/XUiGridArchivePartner.lua | 49 + .../XUi/XUiArchive/XUiGridArchiveStory.lua | 59 + .../XUiArchive/XUiGridArchiveStoryDetail.lua | 39 + .../XUi/XUiArchive/XUiGridArchiveTag.lua | 58 + .../XUi/XUiArchive/XUiGridArchiveWeapon.lua | 86 + .../XUiGridArchiveWeaponAchievement.lua | 88 + Resources/Scripts/XUi/XUiArena/XUiArena.lua | 58 + .../XUi/XUiArena/XUiArenaContributeScore.lua | 29 + .../XUi/XUiArena/XUiArenaContributeTips.lua | 103 + .../XUiArena/XUiArenaContributeTipsGrid.lua | 19 + .../Scripts/XUi/XUiArena/XUiArenaGrid.lua | 50 + .../Scripts/XUi/XUiArena/XUiArenaRank.lua | 246 + .../Scripts/XUi/XUiArena/XUiArenaRankGrid.lua | 75 + .../Scripts/XUi/XUiArena/XUiPanelActive.lua | 341 + .../Scripts/XUi/XUiArena/XUiPanelPrepare.lua | 125 + .../XUiArenaActivityResult.lua | 100 + .../XUiArenaFightResult.lua | 300 + .../XUiGridArenaLevel.lua | 21 + .../ArenaLevelDetailCommon/XUiGridRegion.lua | 44 + .../XUiArenaLevelDetail.lua | 114 + .../XUiArenaOnline/XUiArenaOnlineChapter.lua | 103 + .../XUiArenaOnlineInvitation.lua | 199 + .../XUiArenaOnline/XUiArenaOnlineSection.lua | 122 + .../XUi/XUiArenaOnline/XUiChapterPrefab.lua | 130 + .../XUi/XUiArenaOnline/XUiGridSection.lua | 87 + .../XUi/XUiArenaOnline/XUiGridStage.lua | 49 + .../XUi/XUiArenaOnline/XUiPanelBuffDetail.lua | 63 + .../XUi/XUiArenaOnline/XUiPanelStagInfo.lua | 121 + .../XUiArenaOnline/XUiPanelStageDetail.lua | 176 + .../XUi/XUiArenaOnline/XUiPanelTargetInfo.lua | 102 + .../XUi/XUiArenaOnline/XUiSectionPrefab.lua | 225 + .../XUiGridArenaPassContent.lua | 51 + .../ArenaStageCommon/XUiGridArenaStage.lua | 75 + .../XUi/XUiArenaStage/XUiArenaStage.lua | 126 + .../XUi/XUiArenaStage/XUiPanelPassDetail.lua | 88 + .../Scripts/XUi/XUiArenaTask/XUiArenaTask.lua | 56 + .../Scripts/XUi/XUiArenaTeam/XUiArenaTeam.lua | 81 + .../XUiGridArenaMyTeamMember.lua | 110 + .../XUiArenaTeamCommon/XUiGridArenaTeam.lua | 84 + .../XUiGridArenaTeamApply.lua | 89 + .../XUiGridArenaTeamMember.lua | 58 + .../XUiGridArenaTeamSingle.lua | 133 + .../XUi/XUiArenaTeam/XUiPanelApply.lua | 73 + .../Scripts/XUi/XUiArenaTeam/XUiPanelHall.lua | 143 + .../XUi/XUiArenaTeam/XUiPanelInviteFriend.lua | 65 + .../XUi/XUiArenaTeam/XUiPanelMyTeam.lua | 117 + .../XUiGridArenaTeamRank.lua | 74 + .../XUiGridArenaTeamReward.lua | 46 + .../XUi/XUiArenaTeamRank/XUiArenaTeamRank.lua | 58 + .../XUiPanelRewardPreview.lua | 61 + .../XUi/XUiArenaTeamRank/XUiPanelTeamRank.lua | 83 + .../ArenaWarZoneCommon/XUiGridZone.lua | 102 + .../XUi/XUiArenaWarZone/XUiArenaWarZone.lua | 67 + .../XUi/XUiAssign/UiAssignSelectOccupy.lua | 142 + .../Scripts/XUi/XUiAssign/XUiAssignBuff.lua | 73 + .../XUi/XUiAssign/XUiAssignBuffAll.lua | 54 + .../XUi/XUiAssign/XUiAssignBuffPart.lua | 46 + .../Scripts/XUi/XUiAssign/XUiAssignDeploy.lua | 124 + .../Scripts/XUi/XUiAssign/XUiAssignInfo.lua | 179 + .../Scripts/XUi/XUiAssign/XUiAssignOccupy.lua | 113 + .../XUi/XUiAssign/XUiAssignPostWarCount.lua | 95 + .../XUi/XUiAssign/XUiAssignRoomCharacter.lua | 625 ++ .../XUi/XUiAssign/XUiAssignStageDetail.lua | 205 + .../XUi/XUiAssign/XUiGridAssignBuffPart.lua | 102 + .../XUi/XUiAssign/XUiGridAssignBuffText.lua | 21 + .../XUi/XUiAssign/XUiGridAssignChapter.lua | 88 + .../XUiAssign/XUiGridAssignDeployMember.lua | 124 + .../XUi/XUiAssign/XUiGridAssignDeployTeam.lua | 63 + .../XUiGridAssignFormationMember.lua | 165 + .../XUiAssign/XUiGridAssignFormationTeam.lua | 142 + .../XUiAssign/XUiGridAssignSelectOccupy.lua | 71 + .../XUi/XUiAssign/XUiGridAssignStage.lua | 50 + .../XUi/XUiAssign/XUiGridTeamInfoExp.lua | 60 + .../XUi/XUiAssign/XUiPanelAssignFormation.lua | 104 + .../XUi/XUiAssign/XUiPanelAssignMain.lua | 130 + .../XUi/XUiAssign/XUiPanelAssignStage.lua | 223 + .../XUiAutoFightDialog/XUiAutoFightDialog.lua | 148 + .../XUi/XUiAutoFightDialog/XUiImgIcon.lua | 41 + .../XUi/XUiAutoFightDialog/XUiPanelBtn.lua | 59 + .../XUi/XUiAutoFightList/XUiAutoFightList.lua | 117 + .../XUiAutoFightList/XUiAutoFightRecord.lua | 147 + .../XUiAutoFightReward/XUiAutoFightExp.lua | 47 + .../XUiAutoFightReward/XUiAutoFightReward.lua | 121 + .../XUiAutoFightRewardCharacter.lua | 46 + .../XUi/XUiAutoFightTip/XUiAutoFightTip.lua | 9 + .../XUi/XUiAutoWindow/XUiAutoWindow.lua | 116 + .../XUi/XUiAwarenessTf/XUiAwarenessTf.lua | 475 + .../XUiAwarenessTf/XUiAwarenessTfBtnPos.lua | 86 + .../XUiAwarenessTf/XUiAwarenessTfChoice.lua | 270 + .../XUiAwarenessTf/XUiAwarenessTfResult.lua | 145 + Resources/Scripts/XUi/XUiBag/XUiBag.lua | 804 ++ Resources/Scripts/XUi/XUiBag/XUiBagItem.lua | 683 ++ .../XUi/XUiBag/XUiBagItemInfoPanel.lua | 289 + .../Scripts/XUi/XUiBag/XUiGridSelectGift.lua | 137 + .../XUiBag/XUiGridSelectReplicatedGift.lua | 254 + .../Scripts/XUi/XUiBag/XUiPanelBagItem.lua | 92 + .../Scripts/XUi/XUiBag/XUiPanelBagRecycle.lua | 46 + .../Scripts/XUi/XUiBag/XUiPanelSelectGift.lua | 286 + .../XUiBag/XUiPanelSelectReplicatedGift.lua | 304 + .../Scripts/XUi/XUiBag/XUiPanelSidePopUp.lua | 533 + .../XUi/XUiBag/XUiRecyclingSettings.lua | 128 + Resources/Scripts/XUi/XUiBase/XPageView.lua | 202 + Resources/Scripts/XUi/XUiBase/XScrollGrid.lua | 31 + Resources/Scripts/XUi/XUiBase/XScrollView.lua | 364 + Resources/Scripts/XUi/XUiBase/XUiBtnTab.lua | 215 + .../Scripts/XUi/XUiBase/XUiChapterBtnTab.lua | 84 + .../Scripts/XUi/XUiBase/XUiTabBtnGroup.lua | 77 + .../Scripts/XUi/XUiBaseEquip/XUiBaseEquip.lua | 153 + .../XUi/XUiBaseEquip/XUiGridBaseEquip.lua | 218 + .../XUiBaseEquip/XUiPanelBaseEquipInfo.lua | 124 + .../XUiBaseEquip/XUiPanelBaseEquipPutOn.lua | 379 + .../XUiBaseEquip/XUiPanelBaseEquipRecycle.lua | 128 + .../XUi/XUiBaseEquip/XUiPanelPutOnShowTip.lua | 101 + .../Scripts/XUi/XUiBfrt/XUiBfrtDeploy.lua | 268 + Resources/Scripts/XUi/XUiBfrt/XUiBfrtInfo.lua | 132 + .../XUi/XUiBfrt/XUiBfrtPostWarCount.lua | 171 + .../XUi/XUiBfrt/XUiBfrtQuickDeploy.lua | 182 + .../XUi/XUiBfrt/XUiBfrtRoomCharacter.lua | 591 + .../XUi/XUiBfrt/XUiBfrtStageDetail.lua | 236 + .../XUi/XUiBfrt/XUiGridBfrtCharacter.lua | 121 + .../Scripts/XUi/XUiBfrt/XUiGridEchelon.lua | 219 + .../Scripts/XUi/XUiBfrt/XUiGridEchelonExp.lua | 138 + .../XUi/XUiBfrt/XUiGridEchelonMember.lua | 229 + .../XUi/XUiBfrt/XUiGridLogisticSkill.lua | 61 + .../XUi/XUiBfrt/XUiGridQuickDeployMember.lua | 65 + .../XUi/XUiBfrt/XUiGridQuickDeployTeam.lua | 137 + .../XUi/XUiBfrt/XUiTipBfrtLogisticSkill.lua | 128 + .../Scripts/XUi/XUiBuyAsset/XUiBattery.lua | 195 + .../Scripts/XUi/XUiBuyAsset/XUiBuyAsset.lua | 380 + .../XUi/XUiBuyAsset/XUiCoinPackage.lua | 107 + .../XUi/XUiBuyAsset/XUiUseCoinPackage.lua | 156 + .../Scripts/XUi/XUiBuyAsset/XUiUsePackage.lua | 225 + .../XUiCharacter/XUiCharSkillOtherParsing.lua | 47 + .../Scripts/XUi/XUiCharacter/XUiCharacter.lua | 516 + .../XUiCharacter/XUiCharacterCarerrTips.lua | 26 + .../XUiCharacterElementDetail.lua | 60 + .../XUiCharacter/XUiCharacterOwnedInfo.lua | 212 + .../XUiCharacter/XUiCharacterSkillSwich.lua | 53 + .../XUiCharacter/XUiCharacterUnOwnedInfo.lua | 78 + .../XUi/XUiCharacter/XUiGridCharacter.lua | 362 + .../XUiCharacter/XUiGridCharacterCareer.lua | 20 + .../XUi/XUiCharacter/XUiGridCharacterNew.lua | 150 + .../XUi/XUiCharacter/XUiGridElementDetail.lua | 18 + .../XUi/XUiCharacter/XUiGridSkillInfo.lua | 119 + .../XUi/XUiCharacter/XUiGridSkillItem.lua | 111 + .../XUi/XUiCharacter/XUiGridSubSkill.lua | 118 + .../XUi/XUiCharacter/XUiGridSwitchSkill.lua | 28 + .../XUi/XUiCharacter/XUiPanelCharGrade.lua | 477 + .../XUi/XUiCharacter/XUiPanelCharLevel.lua | 87 + .../XUi/XUiCharacter/XUiPanelCharProperty.lua | 228 + .../XUi/XUiCharacter/XUiPanelCharQuality.lua | 443 + .../XUi/XUiCharacter/XUiPanelCharSkill.lua | 133 + .../XUiPanelCharacterExchange.lua | 153 + .../XUi/XUiCharacter/XUiPanelCodition.lua | 67 + .../XUi/XUiCharacter/XUiPanelGradeUpgrade.lua | 204 + .../XUi/XUiCharacter/XUiPanelLevelUpgrade.lua | 97 + .../XUiCharacter/XUiPanelQualityPreview.lua | 49 + .../XUiCharacter/XUiPanelQualityUpgrade.lua | 96 + .../XUi/XUiCharacter/XUiPanelRoleModel.lua | 958 ++ .../XUiCharacter/XUiPanelSelectLevelItems.lua | 319 + .../XUi/XUiCharacter/XUiPanelSkillInfo.lua | 446 + .../XUiCharacter/XUiPanelSkillLevelDetail.lua | 97 + .../XUi/XUiCharacter/XUiPanelSkillTeach.lua | 63 + .../XUiCharacterDetail/XUiCharacterDetail.lua | 289 + .../XUiPanelDetailEquipItem.lua | 114 + .../XUiPanelDetailTeamItem.lua | 106 + .../XUiCharacterDetail/XUiPanelEquipInfo.lua | 109 + .../XUiCharacterDetail/XUiPanelTeamInfo.lua | 103 + .../ChatModel/EmojiModel/XUiEmojiItem.lua | 70 + .../ChatModel/EmojiModel/XUiPanelEmoji.lua | 186 + .../ChatModel/XUiBtnTitleItem.lua | 102 + .../Item/XUiGridChatChannelItem.lua | 36 + .../Item/XUiPanelWorldChatMyHelp.lua | 68 + .../Item/XUiPanelWorldChatMyMsgEmoji.lua | 126 + .../Item/XUiPanelWorldChatMyMsgItem.lua | 141 + .../Item/XUiPanelWorldChatSystemItem.lua | 11 + .../XUi/XUiChatServe/XUiChatServeMain.lua | 592 + .../XUi/XUiChatServe/XUiPanelChatContent.lua | 145 + .../XUi/XUiChatServe/XUiPanelChatPools.lua | 68 + .../XUi/XUiChessPursuit/XChessPursuitCtrl.lua | 126 + .../XData/XChessPursuitMapBoss.lua | 53 + .../XData/XChessPursuitMapDb.lua | 397 + .../XData/XChessPursuitRank.lua | 51 + .../XData/XChessPursuitRankGrid.lua | 92 + .../XData/XChessPursuitRankPlayer.lua | 80 + .../XData/XChessPursuitRankScore.lua | 37 + .../XData/XChessPursuitSyncAction.lua | 98 + .../XData/XChessPursuitSyncActionQueue.lua | 43 + .../XScene/XChessPursuitBoss.lua | 44 + .../XScene/XChessPursuitCube.lua | 16 + .../XScene/XChessPursuitModel.lua | 55 + .../XScene/XChessPursuitScene.lua | 55 + .../XScene/XChessPursuitSceneManager.lua | 44 + .../XScene/XChessPursuitTeam.lua | 67 + .../XUiChessPursuitGridQuickDeployMember.lua | 70 + .../XUiChessPursuitGridQuickDeployTeam.lua | 132 + .../XUiChessPursuitQuickDeploy.lua | 182 + .../XUi/Rank/XUiChessPursuitMyRankGrid.lua | 46 + .../Rank/XUiChessPursuitPanelRankReward.lua | 74 + .../XUiChessPursuitPanelRankRewardGrid.lua | 43 + .../XUi/Rank/XUiChessPursuitRank.lua | 103 + .../XUi/Rank/XUiChessPursuitRankGrid.lua | 49 + .../XUi/Rank/XUiChessPursuitRankLineup.lua | 71 + .../XUiChessPursuitRankLineupCardGrid.lua | 30 + .../Rank/XUiChessPursuitRankLineupGrid.lua | 80 + .../XUiChessPursuitRankLineupRoleGrid.lua | 23 + .../XUi/XUiCPMain/XCPFSM/XUiCPActionBase.lua | 91 + .../XCPFSM/XUiCPActionBeginBattle.lua | 43 + .../XCPFSM/XUiCPActionCardEffect.lua | 41 + .../XUiCPMain/XCPFSM/XUiCPActionEndBattle.lua | 25 + .../XCPFSM/XUiCPActionEndBattleHurt.lua | 27 + .../XUiCPMain/XCPFSM/XUiCPActionEndRound.lua | 32 + .../XUiCPMain/XCPFSM/XUiCPActionMachine.lua | 24 + .../XUi/XUiCPMain/XCPFSM/XUiCPActionMove.lua | 56 + .../XUiCPMain/XUiChessPursuitBuzhenGrid.lua | 236 + .../XUi/XUiCPMain/XUiChessPursuitCardGrid.lua | 98 + .../XUiCPMain/XUiChessPursuitGridFight.lua | 38 + .../XUiCPMain/XUiChessPursuitGuideGrid.lua | 36 + .../XUi/XUiCPMain/XUiChessPursuitMain.lua | 234 + .../XUiChessPursuitMainAnimQueue.lua | 76 + .../XUi/XUiCPMain/XUiChessPursuitMainBase.lua | 19 + .../XUiCPMain/XUiChessPursuitMainScene.lua | 1417 +++ .../XUiCPMain/XUiChessPursuitMainStage.lua | 232 + .../XUiChessPursuitPanelFightStage.lua | 38 + .../XUiChessPursuitSelectTipGrid.lua | 49 + .../XUiChessPursuitSkillEffectGrid.lua | 212 + .../XUiCPMain/XUiChessPursuitSkillGrid.lua | 135 + .../XUiCPMain/XUiChessPursuitStageGrid.lua | 152 + .../XUi/XUiChessPursuitBuffTips.lua | 60 + .../XUi/XUiChessPursuitBuffTipsGrid.lua | 31 + .../XUi/XUiChessPursuitCardsTip.lua | 19 + .../XUi/XUiChessPursuitFightResult.lua | 141 + .../XUi/XUiChessPursuitFightTips.lua | 190 + .../XUi/XUiChessPursuitNewRoomSingle.lua | 15 + .../XUiChessPursuitShop.lua | 120 + .../XUiChessPursuitShopGrid.lua | 45 + .../XUi/XUiChristmasTree/XUiChristmasTree.lua | 742 ++ .../XUiChristmasTree/XUiGridTreasureTask.lua | 150 + .../XUi/XUiChristmasTree/XUiOrnamentGrid.lua | 54 + .../XUiPlacedOrnamentGrid.lua | 100 + .../XUiClickClearGame/XUiClickClearGame.lua | 265 + .../XUiClickClearPanelCountdown.lua | 90 + .../XUiClickClearPanelGame.lua | 88 + .../XUiClickClearPanelGameBookMark.lua | 52 + .../XUiClickClearPanelGameRewardData.lua | 39 + .../XUiClickClearPanelGameTask.lua | 53 + .../XUiClickClearPanelGeneral.lua | 75 + .../XUiClickClearPanelGeneralClearance.lua | 25 + .../XUiClickClearPanelGeneralDefault.lua | 31 + .../XUiClickClearPanelGeneralFailure.lua | 20 + .../XUiClickClearGame/XUiClickClearReward.lua | 56 + .../XUiGridClickClearGameHead.lua | 82 + .../XUiGridClickClearGamePage.lua | 47 + .../XUiGridClickClearReward.lua | 89 + .../XUiCollectionWall/XUiCollectionWall.lua | 76 + .../XUiCollectionWallEdit.lua | 588 + .../XUiGridCollectionWall.lua | 122 + .../XUiGridPlacedCollection.lua | 220 + .../XUiGridPlacedCollectionOther.lua | 85 + .../XUiGridSelectItem.lua | 161 + .../XUiGridViewCollection.lua | 87 + .../XUiCollectionWallOther.lua | 78 + .../XUiCollectionWallSetting.lua | 175 + .../XUiCollectionWallView.lua | 162 + .../ComeAcrossClickGamePlayer.lua | 163 + .../ComeAcrossEliminateGamePlayer.lua | 200 + .../XUiComeAcross/ComeAcrossGamePlayer.lua | 334 + .../XUi/XUiComeAcross/XUiComeAcross.lua | 104 + .../XUi/XUiComeAcross/XUiComeAcrossGame.lua | 143 + .../XUi/XUiComeAcross/XUiGridElement.lua | 113 + .../XUi/XUiComeAcross/XUiGridLevel.lua | 79 + .../XUiPanelComeAcrossReward.lua | 73 + .../XUiComeAcross/XUiPanelEliminateGame.lua | 322 + .../XUi/XUiComeAcross/XUiPanelGame.lua | 352 + .../XUi/XUiComeAcross/XUiPanelStart.lua | 96 + .../XUi/XUiComeAcross/XUiPanelTick.lua | 54 + .../XUiCommon/XScrollView/XScrollConfig.lua | 29 + .../XUi/XUiCommon/XScrollView/XScrollFlow.lua | 93 + .../XUiCommon/XScrollView/XScrollFlowGrid.lua | 25 + .../XUi/XUiCommon/XUiBaseComponent.lua | 20 + .../Scripts/XUi/XUiCommon/XUiBaseView.lua | 86 + .../XUi/XUiCommon/XUiButtonLongClick.lua | 150 + .../Scripts/XUi/XUiCommon/XUiCommonAsset.lua | 88 + .../XUi/XUiCommon/XUiCommonAssetPanel.lua | 19 + .../Scripts/XUi/XUiCommon/XUiCommonEnum.lua | 35 + .../XUiDynamicTable/XDynamicTableCurve.lua | 218 + .../XDynamicTableIrregular.lua | 229 + .../XUiDynamicTable/XDynamicTableNormal.lua | 305 + .../XUi/XUiCommon/XUiMultClickHelper.lua | 113 + .../XUi/XUiCommon/XUiNewRoomFightControl.lua | 171 + .../Scripts/XUi/XUiCommon/XUiPanelAsset.lua | 186 + .../Scripts/XUi/XUiCommon/XUiPlayerHead.lua | 108 + .../Scripts/XUi/XUiCommon/XUiPlayerLevel.lua | 34 + .../Scripts/XUi/XUiCommon/XUiSkipTip.lua | 33 + .../XUi/XUiCommon/XUiStageFightControl.lua | 45 + .../XUi/XUiCommon/XUiStageFightEvent.lua | 27 + .../XUi/XUiCommon/XUiStageFightEventItem.lua | 13 + .../Scripts/XUi/XUiCommon/XUiTipLayer.lua | 159 + .../XUiSelectCharacterGrid.lua | 129 + .../XUiCommonWindow/XUiSelectCharacterWin.lua | 394 + .../XUi/XUiCoupletGame/XUiCoupletAward.lua | 61 + .../XUi/XUiCoupletGame/XUiCoupletGame.lua | 216 + .../XUiCoupletGame/XUiCoupletRollPanel.lua | 233 + .../XUiCoupletStageCtrlPanel.lua | 109 + .../XUi/XUiCoupletGame/XUiGridCoupletTask.lua | 73 + .../XUi/XUiCoupletGame/XUiGridWordImage.lua | 25 + .../XUi/XUiCoupletGame/XUiGridWordItem.lua | 98 + .../Scripts/XUi/XUiDialog/UiDialogDrag.lua | 134 + .../Scripts/XUi/XUiDialog/XUiAssertDialog.lua | 28 + .../Scripts/XUi/XUiDialog/XUiCueMark.lua | 68 + Resources/Scripts/XUi/XUiDialog/XUiDialog.lua | 134 + .../Scripts/XUi/XUiDialog/XUiSystemDialog.lua | 24 + .../XUiDorm/XUiBlackScreen/XUiBlackScreen.lua | 39 + .../XUiDormCommom/XUiFurnitureScore.lua | 34 + .../XUiDormCommom/XUiGridAttribute.lua | 84 + .../XUiGridAttributeComparable.lua | 26 + .../XUiDorm/XUiDormCommom/XUiRoomScore.lua | 39 + .../XUiFurnitureBuild/XUiFurnitureBuild.lua | 96 + .../XUiFurnitureBuild/XUiFurnitureCreate.lua | 419 + .../XUiFurnitureBuild/XUiGridCreate.lua | 235 + .../XUiFurnitureBuild/XUiGridInvestment.lua | 153 + .../XUiFurnitureBuild/XUiPanelCreate.lua | 79 + .../XUiFurnitureBuild/XUiPanelRefit.lua | 438 + .../XUiFurnitureAttrGrid.lua | 22 + .../XUiFurnitureReform/XUiFurnitureReform.lua | 815 ++ .../XUiFurnitureReform/XUiGridFurniture.lua | 227 + .../XUiFurnitureReform/XUiGridOption.lua | 60 + .../XUiFurnitureReform/XUiPanelMenu.lua | 196 + .../XUiPanelSViewFurniture.lua | 134 + .../Scripts/XUi/XUiDormBag/XUiDormBag.lua | 799 ++ .../XUi/XUiDormBag/XUiGridDormCharacter.lua | 71 + .../Scripts/XUi/XUiDormBag/XUiGridDraft.lua | 66 + .../XUi/XUiDormBag/XUiGridFurniture.lua | 143 + .../XUi/XUiDormBag/XUiPanelDormBagItem.lua | 50 + .../XUi/XUiDormBag/XUiRecyclePreview.lua | 203 + .../XUiDormBagRecycle/XUiDormBagRecycle.lua | 53 + .../XUiDormCharacterDetail.lua | 156 + .../XUiDormCharacterLikeInfo.lua | 41 + .../XUiGridDetailDormCharacter.lua | 21 + .../XUiGridLikeInfo.lua | 66 + .../XUiPanelCharacterLikeInfo.lua | 57 + .../XUi/XUiDormComponent/XUiDormComponent.lua | 338 + .../XUiDormComponent/XUiFurnitureAttrObj.lua | 49 + .../XUi/XUiDormComponent/XUiGrid3DObj.lua | 47 + .../XUi/XUiDormComponent/XUiGridDialogBox.lua | 91 + .../XUi/XUiDormComponent/XUiPanelExp.lua | 116 + .../XUiDormComponent/XUiPanelExpDetail.lua | 199 + .../XUi/XUiDormComponent/XUiPanelPutOn.lua | 103 + .../XUi/XUiDormComponent/XUiPanelTouch.lua | 75 + .../XUiDormFieldGuide/XUiDormFieldGuide.lua | 195 + .../XUiDormFieldGuideDes.lua | 76 + .../XUiDormFieldGuideDesListItem.lua | 22 + .../XUiDormFieldGuideGridItem.lua | 40 + .../XUiDormFieldGuideListItem.lua | 37 + .../XUiDormFieldGuideSeleItem.lua | 51 + .../XUiDormFieldGuideTab.lua | 21 + .../Scripts/XUi/XUiDormMain/XUiDormMain.lua | 370 + .../XUi/XUiDormMain/XUiDormMainAttItem.lua | 20 + .../XUi/XUiDormMain/XUiDormMainItem.lua | 115 + .../XUi/XUiDormPerson/XUiDormPerson.lua | 112 + .../XUiDormPerson/XUiDormPersonAttDesItem.lua | 28 + .../XUiDormPerson/XUiDormPersonListItem.lua | 85 + .../XUi/XUiDormPerson/XUiDormPersonSelect.lua | 217 + .../XUiDormPersonSelectListItem.lua | 141 + .../XUiDormPerson/XUiDormPersonSingleItem.lua | 102 + .../Scripts/XUi/XUiDormSecond/XUiDormBgm.lua | 226 + .../XUi/XUiDormSecond/XUiDormBgmGrid.lua | 43 + .../XUi/XUiDormSecond/XUiDormCaress.lua | 334 + .../XUi/XUiDormSecond/XUiDormNameGridItem.lua | 22 + .../XUi/XUiDormSecond/XUiDormReName.lua | 81 + .../XUi/XUiDormSecond/XUiDormSecond.lua | 1003 ++ .../XUi/XUiDormSecond/XUiDormSecondHead.lua | 175 + .../XUi/XUiDormSecond/XUiGridLikeInfo.lua | 17 + .../XUi/XUiDormSecond/XUiPanelEventShow.lua | 102 + .../XUiDormSecond/XUiPanelFurnitureLike.lua | 92 + .../Scripts/XUi/XUiDormTask/XUiDormTask.lua | 129 + .../XUiDormTask/XUiPanelDormTaskActivity.lua | 42 + .../XUi/XUiDormTask/XUiPanelDormTaskDaily.lua | 145 + .../XUi/XUiDormTask/XUiPanelDormTaskStory.lua | 43 + .../XUi/XUiDormTemplate/XUiDormTemplate.lua | 139 + .../XUiDormTemplate/XUiDormTemplateDetail.lua | 169 + .../XUiDormTemplate/XUiDormTemplateScene.lua | 200 + .../XUiDormTemplate/XUiDormTemplateShare.lua | 68 + .../XUiDormTemplate/XUiGridDormTemplate.lua | 95 + .../XUiGridFurnitreTemplate.lua | 34 + .../XUiDormTemplate/XUiGridTemplateDetail.lua | 60 + .../XUiDormTemplate/XUiGridTemplateSave.lua | 81 + .../XUiGridTemplateSelectRoom.lua | 53 + .../XUi/XUiDormTemplate/XUiPanelEncoding.lua | 68 + .../XUiDormTemplate/XUiPanelFunitureList.lua | 68 + .../XUiDormTemplate/XUiPanelRefitQuick.lua | 207 + .../XUi/XUiDormTemplate/XUiPanelSave.lua | 187 + .../XUiPanelTemlateSelectRoom.lua | 231 + .../Scripts/XUi/XUiDormVisit/XUiDormVisit.lua | 305 + .../XUi/XUiDormVisit/XUiDormVisitGridItem.lua | 123 + .../XUiDormVisit/XUiDormVisitTypeListItem.lua | 41 + .../XUi/XUiDormWork/XUiDormFoundryDetail.lua | 120 + .../XUiDormWork/XUiDormFoundryDetailItem.lua | 28 + .../XUiDormFoundryDetailRewardItem.lua | 44 + .../Scripts/XUi/XUiDormWork/XUiDormWork.lua | 383 + .../XUi/XUiDormWork/XUiDormWorkGridItem.lua | 178 + .../XUi/XUiDormWork/XUiDormWorkListItem.lua | 51 + .../XUi/XUiDormWork/XUiDormWorkMember.lua | 162 + .../XUiDormWork/XUiDormWorkMemberGridItem.lua | 76 + .../XUiDormWork/XUiDormWorkMemberListItem.lua | 90 + .../Scripts/XUi/XUiDraw/UiDrawPurchaseLB.lua | 256 + .../XUi/XUiDraw/XUiChangeCombination.lua | 87 + Resources/Scripts/XUi/XUiDraw/XUiDraw.lua | 613 + .../Scripts/XUi/XUiDraw/XUiDrawBuyVoucher.lua | 91 + .../Scripts/XUi/XUiDraw/XUiDrawControl.lua | 150 + .../Scripts/XUi/XUiDraw/XUiDrawGroup.lua | 137 + Resources/Scripts/XUi/XUiDraw/XUiDrawLog.lua | 309 + .../Scripts/XUi/XUiDraw/XUiDrawOptional.lua | 190 + .../Scripts/XUi/XUiDraw/XUiDrawPreview.lua | 137 + .../Scripts/XUi/XUiDraw/XUiDrawResult.lua | 169 + Resources/Scripts/XUi/XUiDraw/XUiDrawRule.lua | 108 + Resources/Scripts/XUi/XUiDraw/XUiDrawShow.lua | 607 + .../XUi/XUiDraw/XUiDrawSuitPreview.lua | 75 + .../XUi/XUiDraw/XUiDrawTools/XUiDrawBox.lua | 28 + .../XUiDraw/XUiDrawTools/XUiDrawCamera.lua | 37 + .../XUiDrawTools/XUiDrawCharacterRecord.lua | 46 + .../XUiDrawTools/XUiDrawRemainTime.lua | 32 + .../XUi/XUiDraw/XUiDrawTools/XUiDrawScene.lua | 69 + .../XUiDrawTools/XUiDrawShowEffect.lua | 84 + .../XUiDraw/XUiDrawTools/XUiDrawWeapon.lua | 52 + .../XUi/XUiDraw/XUiGridDrawGroupBanner.lua | 177 + .../Scripts/XUi/XUiDraw/XUiGridDrawSet.lua | 69 + Resources/Scripts/XUi/XUiDraw/XUiGridGain.lua | 52 + .../Scripts/XUi/XUiDraw/XUiNewDrawMain.lua | 307 + .../XUi/XUiDraw/XUiNewGridDrawBanner.lua | 172 + .../XUi/XUiDraw/XUiPanelCombination.lua | 220 + .../XUi/XUiDraw/XUiPanelProbability.lua | 84 + .../Scripts/XUi/XUiDraw/XUiTogDrawGroup.lua | 44 + .../XUi/XUiDraw/XUiTogDrawGroupTab.lua | 61 + .../XUi/XUiEnterFight/XUiEnterFight.lua | 164 + .../XUiEquipAwarenessPopup.lua | 363 + .../XUiEquipAwarenessReplace.lua | 774 ++ .../XUiEquipAwarenessSuitPrefab.lua | 488 + .../XUiEquipSuitPrefabConfirm.lua | 20 + .../XUiEquipSuitPrefabConflict.lua | 34 + .../XUiEquipSuitPrefabRename.lua | 35 + .../XUiEquipAwarenessReplace/XUiGridEquip.lua | 187 + .../XUiGridSuitDetail.lua | 205 + .../XUiGridSuitPrefab.lua | 55 + .../XUiGridSuitPrefabEquip.lua | 19 + .../XUiPanelEquipScroll.lua | 120 + .../XUiPanelSuitDetailScroll.lua | 45 + .../XUiPanelSuitSimpleScroll.lua | 44 + .../XUiEquipBreakThrough.lua | 132 + .../XUiEquipBreakThroughPopUp.lua | 61 + .../XUiEquipCanBreakthroughTip.lua | 35 + .../XUiEquipLevelUpTips.lua | 47 + .../XUiEquipBreakThrough/XUiGridCostItem.lua | 73 + .../XUi/XUiEquipDetail/XUiEquipDetail.lua | 282 + .../XUiEquipDetail/XUiEquipDetailChild.lua | 341 + .../XUiEquipReplaceNew/XUiEquipReplaceNew.lua | 348 + .../XUiEquipResonanceSkillDetailInfo.lua | 43 + .../XUiGridEquipReplaceAttr.lua | 75 + .../XUiEquipResonanceAwake.lua | 250 + .../XUiEquipResonanceSelect.lua | 525 + .../XUiEquipResonanceSelectAfter.lua | 185 + .../XUiEquipResonanceSelectCharacter.lua | 71 + .../XUiEquipResonanceSelectEquip.lua | 100 + .../XUiEquipResonanceSelectItem.lua | 138 + .../XUiEquipResonanceSkill.lua | 195 + .../XUiEquipResonanceSkillPreview.lua | 134 + .../XUiGridDoubleResonanceSkill.lua | 123 + .../XUiGridEquipResonanceSkillPreview.lua | 57 + .../XUiGridResonanceSkill.lua | 142 + .../XUiEquipStrengthen/XUiEquipStrengthen.lua | 486 + .../XUiGridEquipExpItem.lua | 147 + .../XUiEquipStrengthenSkip.lua | 33 + .../XUi/XUiExhibition/XUiExhibition.lua | 253 + .../XUiExhibition/XUiExhibitionGroupTip.lua | 22 + .../XUi/XUiExhibition/XUiExhibitionInfo.lua | 205 + .../XUiExhibition/XUiGridCharacterIcon.lua | 98 + .../XUiExhibition/XUiGridCharacterName.lua | 27 + .../XUi/XUiExhibition/XUiGridCondition.lua | 25 + .../XUi/XUiExhibition/XUiGridGroupIcon.lua | 29 + .../XUi/XUiExhibition/XUiGridGroupName.lua | 23 + .../XUi/XUiExhibition/XUiPanelCollection.lua | 55 + .../XUiExpeditionRoomCharListGrid.lua | 51 + .../XUiExpeditionRoomCharListPanel.lua | 55 + .../XUiExpeditionRoomCharacter.lua | 136 + .../Battle/XUiExpeditionInfinityCombo.lua | 16 + .../Battle/XUiExpeditionInfinityComboList.lua | 32 + .../Battle/XUiExpeditionInfinityHeadIcon.lua | 14 + .../Battle/XUiExpeditionInfinityWin.lua | 125 + .../Battle/XUiExpeditionNewRoomSingle.lua | 89 + .../Battle/XUiExpeditionSettleWin.lua | 195 + .../Battle/XUiExpeditionSettleWinHeadIcon.lua | 16 + .../XUiEXpeditionComboTipsHeadIcon.lua | 40 + .../ComboList/XUiExpeditionComboTips.lua | 128 + .../ComboList/XUiExpeditionComboTipsItem.lua | 37 + .../XUiExpeditionComboTipsItemPanel.lua | 80 + .../ComboList/XUiExpeditionComboTipsTab.lua | 35 + .../ChapterBuff/XUiExpeditionBuffTips.lua | 72 + .../ChapterBuff/XUiExpeditionBuffTipsItem.lua | 39 + .../ChapterBuff/XUiGlobalComboIcon.lua | 17 + .../XUiExpeditionStageBattleDetail.lua | 140 + .../XUiExpeditionStageBuffIcon.lua | 23 + .../XUiExpeditionStageInfinityDetail.lua | 99 + .../XUiExpeditionStageStoryDetail.lua | 49 + .../MainPage/XUiExpeditionChapter.lua | 40 + .../XUiExpeditionChapterComponent.lua | 207 + .../MainPage/XUiExpeditionMain.lua | 281 + .../MainPage/XUiExpeditionStageDetail.lua | 59 + .../XUiExpeditionStageDetailComponent.lua | 90 + .../Ranking/XUiExpeditionMyRank.lua | 36 + .../Ranking/XUiExpeditionRankGrid.lua | 95 + .../Ranking/XUiExpeditionRankInfo.lua | 30 + .../Ranking/XUiExpeditionRankList.lua | 36 + .../Ranking/XUiExpeditionRanking.lua | 81 + .../XUiExpeditionComboGrid.lua | 50 + .../XUiExpeditionComboPhase.lua | 14 + .../XUiExpeditionRecruitComboPanel.lua | 49 + .../Recruit/XUiExpeditionDrawPR.lua | 57 + .../XUiExpeditionLevelTips.lua | 10 + .../XUiExpeditionRecruitMemberGrid.lua | 57 + .../XUiExpeditionRecruitMemberPanel.lua | 47 + .../Recruit/XUiExpeditionPublicity.lua | 89 + .../Recruit/XUiExpeditionPublicityTitle.lua | 28 + .../Recruit/XUiExpeditionRecruit.lua | 152 + .../MessageBoard/XUiExpeditionGuesBook.lua | 70 + .../MessageBoard/XUiExpeditionMessageItem.lua | 61 + .../XUiExpeditionMessageItemList.lua | 136 + .../XUiExpeditionComboIconGrid.lua | 29 + .../XUiExpeditionComboIconPanel.lua | 46 + .../XUiExpeditionRoleDetails.lua | 127 + .../XUiExpeditionSkillIconGrid.lua | 20 + .../XUiExpeditionRecruitShopGrid.lua | 106 + .../XUiExpeditionRecruitShopPanel.lua | 40 + .../XUiExpeditionCharProperty.lua | 43 + .../XUiExpeditionCharSkill.lua | 133 + .../CharacterDetail/XUiExpeditionViewRole.lua | 89 + .../EquipDetail/XUiExpeditionEquipDetail.lua | 132 + .../XUiExpeditionEquipDetailChild.lua | 121 + .../XUiExpeditionEquipGrid.lua | 107 + .../RoleList/XUiExpeditionRoleList.lua | 140 + .../XUiExpeditionRoleListCharaInfo.lua | 133 + .../XUiExpeditionRoleListCharacterGrid.lua | 66 + .../XUiExpeditionRoleListCharacterList.lua | 47 + .../XUiExpeditionRoleListComboList.lua | 58 + .../Scripts/XUi/XUiFashion/XUiFashion.lua | 639 ++ .../XUi/XUiFashion/XUiFashionDetail.lua | 264 + .../Scripts/XUi/XUiFashion/XUiGridFashion.lua | 89 + .../XUi/XUiFashion/XUiGridWeaponFashion.lua | 94 + .../XUi/XUiFashion/XUiPanelFashionList.lua | 59 + .../XUi/XUiFavorability/XUiFavorability.lua | 283 + .../XUiFavorabilityLineRoomCharacter.lua | 197 + .../XUiFavorability/XUiFavorabilityNew.lua | 340 + .../XUiFavorability/XUiGridLikeActionItem.lua | 94 + .../XUiFavorability/XUiGridLikeAudioItem.lua | 99 + .../XUiFavorability/XUiGridLikeInfoItem.lua | 113 + .../XUiGridLikeMessageItem.lua | 134 + .../XUiFavorability/XUiGridLikePlotItem.lua | 66 + .../XUiFavorability/XUiGridLikeRoleItem.lua | 68 + .../XUiFavorability/XUiGridLikeRumorItem.lua | 134 + .../XUiGridLikeSendGiftItem.lua | 183 + .../XUiFavorability/XUiGridLineCharacter.lua | 18 + .../XUiPanelFavorabilityAction.lua | 210 + .../XUiPanelFavorabilityAudio.lua | 261 + .../XUiPanelFavorabilityDocument.lua | 104 + .../XUiPanelFavorabilityExchangeRole.lua | 122 + .../XUiPanelFavorabilityFile.lua | 81 + .../XUiPanelFavorabilityInfo.lua | 137 + .../XUiPanelFavorabilityMain.lua | 531 + .../XUiPanelFavorabilityMessage.lua | 127 + .../XUiPanelFavorabilityPlot.lua | 128 + .../XUiPanelFavorabilityRumors.lua | 142 + .../XUiFavorability/XUiPanelLikeGiveGift.lua | 449 + .../XUiFestivalActivityNewRoomSingle.lua | 23 + .../XUiFestivalStageItem.lua | 82 + .../XUiFubenChristmasMainLineChapter.lua | 451 + .../XUiFubenChristmasStageDetail.lua | 139 + .../XUiStoryChristmasStageDetail.lua | 57 + .../XUiFightButtonSettings.lua | 101 + .../XUiFightInfestorExplore.lua | 240 + .../XUiGridFightInfestorPlayer.lua | 24 + .../XUiGridFightInfestorRuler.lua | 17 + .../XUi/XUiFightWords/XUiFightWords.lua | 47 + .../XUi/XUiFirstGetPopUp/XUiFirstGetPopUp.lua | 75 + Resources/Scripts/XUi/XUiFuben/XUiFuben.lua | 261 + .../XUiFubenActivityBanner.lua | 417 + .../XUiGridActivityBanner.lua | 1157 ++ .../XUiFubenActivityPuzzle.lua | 237 + .../XUiFubenActivityPuzzleAreaRewardBtn.lua | 41 + .../XUiFubenActivityPuzzleGamePanel.lua | 358 + .../XUiFubenActivityPuzzlePassword.lua | 102 + ...FubenActivityPuzzlePasswordRewardPanel.lua | 111 + .../XUiFubenActivityPuzzlePieceItem.lua | 61 + .../XUiFubenActivityPuzzleRewardPanel.lua | 116 + .../XUiPuzzleDercyptionPasswordItem.lua | 41 + .../XUiFubenBabelTower/XUiBabelMemberHead.lua | 55 + .../XUiBabelMemberSmallHead.lua | 15 + .../XUiBabelTowerAutoFight.lua | 72 + .../XUiFubenBabelTower/XUiBabelTowerBase.lua | 267 + .../XUiBabelTowerChallengeChoice.lua | 172 + .../XUiBabelTowerChallengeSelect.lua | 47 + .../XUiBabelTowerChildChallenge.lua | 356 + .../XUiBabelTowerChildSupport.lua | 472 + .../XUiBabelTowerDetails.lua | 101 + .../XUiBabelTowerFightTips.lua | 345 + .../XUiBabelTowerMainNew.lua | 262 + .../XUiBabelTowerMyRankInfos.lua | 34 + .../XUiBabelTowerRankInfo.lua | 68 + .../XUiBabelTowerRankReward.lua | 56 + .../XUiBabelTowerRoomCharacter.lua | 541 + .../XUiBabelTowerSelectDiffcult.lua | 38 + .../XUiBabelTowerSelectTeam.lua | 41 + .../XUiBabelTowerSupportChoice.lua | 116 + .../XUiFubenBabelTower/XUiBabelTowerTask.lua | 135 + .../XUiBabelTowerTeamTips.lua | 262 + .../XUiBabelTowerTipsItem.lua | 42 + .../XUiFubenBabelTowerRank.lua | 87 + .../XUiGridAutoFightMember.lua | 21 + .../XUiGridBabelChallengeItem.lua | 47 + .../XUiGridBabelSelectDifficult.lua | 38 + .../XUiGridBabelSelectTeam.lua | 91 + .../XUiGridBabelStageItem.lua | 71 + .../XUiGridInfoBuffItem.lua | 31 + .../XUiGridInfoChallengeItem.lua | 42 + .../XUiGridInfoEnvironmentItem.lua | 20 + .../XUiGridInfoSupportCondition.lua | 33 + .../XUiGridRankItemInfo.lua | 40 + .../XUiGridRankRewardItem.lua | 46 + .../XUiFubenBossSingle/XUiFubenBossSingle.lua | 157 + .../XUiFubenBossSingleChooseLevelType.lua | 35 + .../XUiFubenBossSingleHide.lua | 115 + .../XUiFubenBossSingle/XUiGridBossRank.lua | 77 + .../XUiGridBossRankReward.lua | 63 + .../XUiFubenBossSingle/XUiGridBossScore.lua | 87 + .../XUiFubenBossSingle/XUiGridBossSkill.lua | 16 + .../XUiFubenBossSingle/XUiPanelAutoFight.lua | 146 + .../XUiFubenBossSingle/XUiPanelBossDetail.lua | 499 + .../XUiPanelBossDetailTip.lua | 102 + .../XUiFubenBossSingle/XUiPanelBossEnter.lua | 196 + .../XUiPanelBossRankInfo.lua | 204 + .../XUiFubenBossSingle/XUiPanelBossStgae.lua | 168 + .../XUiFubenBossSingle/XUiPanelGroupInfo.lua | 94 + .../XUiFubenBossSingle/XUiPanelMyBossRank.lua | 77 + .../XUiFubenBossSingle/XUiPanelRankReward.lua | 69 + .../XUiFubenBossSingle/XUiPanelScoreInfo.lua | 108 + .../XUiFubenChallengeBanner.lua | 172 + .../XUiGridChallengeBanner.lua | 390 + .../XUiFubenChallengeEMEX.lua | 249 + .../XUiFubenChallengeMap.lua | 377 + .../XUiGridChallengePlayerState.lua | 77 + .../XUiFubenChallengeMap/XUiPanelJieduan.lua | 94 + .../XUiFubenChallengeMapEmex.lua | 131 + .../XUiFubenChallengeUrgent.lua | 126 + .../XUiFubenChallengeYSHTX.lua | 70 + .../XUiPanelYSHTXStageTemplate.lua | 90 + .../XUiFubenCoinSkill/XUiFubenCoinSkill.lua | 214 + .../XUiFubenCoinSkill/XUiPanelFubenTab.lua | 86 + .../ChildItem/XUiStageItem.lua | 97 + .../ChildView/XUiCoupleCombatChapter.lua | 263 + .../ChildView/XUiPanelFeature.lua | 60 + .../Proxy/XUiCoupleCombatNewRoomSingle.lua | 108 + .../Proxy/XUiCoupleCombatRoomCharacter.lua | 122 + .../XUiCoupleCombatMain.lua | 176 + .../XUiFubenCoupleCombatDetail.lua | 231 + .../XUiFubenDailyBanner.lua | 59 + .../XUiFubenDailyBranch.lua | 232 + .../XUiFubenDailyBanner/XUiFubenDailyDrop.lua | 143 + .../XUiFubenDailyStage.lua | 115 + .../XUiGridDailyBanner.lua | 56 + .../XUiFubenDailyShop/XUiFubenDailyShop.lua | 153 + .../XUiFubenDailyShop/XUiGridWaferSelect.lua | 36 + .../XUi/XUiFubenDailyShop/XUiWaferSelect.lua | 105 + .../XUi/XUiFubenDialog/XUiFubenDialog.lua | 109 + .../XUiFubenExperiment/XUiFubenExperiment.lua | 232 + .../XUiFubenExperimentBanner.lua | 180 + .../XUiFubenExperimentDetail.lua | 330 + .../XUiFubenExperimentGridStar.lua | 25 + .../XUiFubenExperimentSkinTrialDetail.lua | 213 + .../XUiFubenExplore/XUiFubenExploreBuff.lua | 33 + .../XUiFubenExploreBuffDetail.lua | 47 + .../XUiFubenExploreChapter.lua | 143 + .../XUiFubenExplore/XUiFubenExploreLevel.lua | 286 + .../XUiFubenExploreLevelNode.lua | 87 + .../XUiFubenExploreQuickJumpBtn.lua | 19 + .../XUiExtraChapterStoryDetail.lua | 62 + .../XUiFubenExtra/XUiFubenExtraChapter.lua | 998 ++ .../XUiFubenExtraChapterDetail.lua | 287 + .../XUiFashionStoryChapter.lua | 183 + .../XUiFashionStoryStageFightDetail.lua | 111 + .../XUiFashionStoryStageStoryDetail.lua | 95 + .../XUiFashionStoryStageTrialDetail.lua | 101 + .../XUiFubenFashionStory.lua | 421 + .../XUiGridFashionStoryStage.lua | 112 + .../XUiGridFashionStoryTrial.lua | 90 + .../XUiFubenFlopReward/XUiFubenFlopReward.lua | 267 + .../XUiFubenFlopReward/XUiPanelRewardBox.lua | 213 + .../ChildItem/XUiGridLevelBuff.lua | 116 + .../ChildItem/XUiGridStageItem.lua | 106 + .../ChildItem/XUiGridStarReward.lua | 101 + .../ChildView/XUiPanelBuffDetail.lua | 100 + .../ChildView/XUiPanelLevelInfo.lua | 86 + .../ChildView/XUiPanelLineChapter.lua | 222 + .../Proxy/XUiHackNewRoomSingle.lua | 42 + .../Proxy/XUiHackRoomCharacter.lua | 46 + .../Scripts/XUi/XUiFubenHack/XUiFubenHack.lua | 217 + .../XUi/XUiFubenHack/XUiFubenHackDetails.lua | 49 + .../XUi/XUiFubenHack/XUiFubenHackSection.lua | 195 + .../XUi/XUiFubenHack/XUiHackDevelop.lua | 174 + .../XUi/XUiFubenHack/XUiHackLevelUpTips.lua | 34 + .../XUiGridChooseReward.lua | 68 + .../XUiGridFubenInfestorExploreChapter.lua | 55 + ...iGridFubenInfestorExploreChapter2Stage.lua | 35 + .../XUiGridFubenInfestorExploreMember.lua | 63 + ...GridFubenInfestorExploreOccupiedPlayer.lua | 22 + .../XUiGridFubenInfestorExploreStage.lua | 49 + .../XUiGridInfestorExploreBuff.lua | 15 + .../XUiGridInfestorExploreContract.lua | 33 + .../XUiGridInfestorExploreCore.lua | 73 + .../XUiGridInfestorExploreEvent.lua | 19 + .../XUiGridInfestorExploreOutPostStory.lua | 14 + .../XUiGridInfestorExplorePlayerMessage.lua | 34 + .../XUiGridInfestorExploreRank.lua | 65 + .../XUiGridInfestorExploreRegionTitle.lua | 26 + .../XUiGridInfestorExploreShopGoods.lua | 45 + .../XUiGridInfestorShopReward.lua | 45 + .../XUiInfestorExploreActivityResult.lua | 29 + .../XUiInfestorExploreChapter.lua | 85 + .../XUiInfestorExploreChapterDetail.lua | 108 + .../XUiInfestorExploreChapterPart2.lua | 93 + .../XUiInfestorExploreChapterPart2Detail.lua | 41 + .../XUiInfestorExploreChoose.lua | 109 + .../XUiInfestorExploreContract.lua | 125 + .../XUiInfestorExploreCore.lua | 216 + .../XUiInfestorExploreCoreDecompose.lua | 118 + .../XUiInfestorExploreCoreLevelUp.lua | 33 + .../XUiInfestorExploreCoreObtain.lua | 26 + .../XUiInfestorExploreCorePopup.lua | 103 + .../XUiInfestorExploreCoreShow.lua | 76 + .../XUiInfestorExploreDebuff.lua | 32 + .../XUiInfestorExploreFightResult.lua | 91 + .../XUiInfestorExploreGuestbook.lua | 74 + .../XUiInfestorExploreLevelDetail.lua | 85 + .../XUiInfestorExploreOutpost.lua | 275 + .../XUiInfestorExploreRank.lua | 151 + .../XUiInfestorExploreShop.lua | 164 + .../XUiInfestorExploreStage.lua | 269 + .../XUiInfestorExploreStageDetailEvent.lua | 149 + .../XUiInfestorExploreStageDetailFight.lua | 119 + .../XUiInfestorExploreStageDetailOutPost.lua | 107 + .../XUiInfestorExploreStageDetailRest.lua | 163 + .../XUiInfestorExploreStageDetailReward.lua | 82 + ...UiInfestorExploreStageDetailRewardGive.lua | 86 + .../XUiInfestorExploreStageDetailShop.lua | 75 + .../XUiInfestorExploreStageDetailSupply.lua | 78 + .../XUiInfestorExploreTeamEdit.lua | 415 + .../XUiPanelFubenInfestorExploreStages.lua | 134 + .../XUiPanelInfestorExploreBossRank.lua | 120 + .../XUiFubenMainLineBanner.lua | 499 + .../XUiGridChapterBfrt.lua | 59 + .../XUiGridChapterDz.lua | 83 + .../XUiGridChapterExtra.lua | 91 + .../XUiGridMainLineBanner.lua | 113 + .../XUiPanelChapterBfrt.lua | 48 + .../XUiPanelChapterDz.lua | 100 + .../XUiPanelChapterExtra.lua | 75 + .../XUiFubenExItemTip.lua | 60 + .../XUiFubenExploreDetail.lua | 281 + .../XUiFubenMainLineChapter.lua | 1159 ++ .../XUiFubenMainLineQuickJumpBtn.lua | 31 + .../XUiGridChapter.lua | 588 + .../XUiGridExploreChapter.lua | 357 + .../XUiGridExploreItem.lua | 60 + .../XUiFubenMainLineChapter/XUiGridStage.lua | 556 + .../XUiGridTreasureGrade.lua | 257 + .../XUiPanelAutoFight.lua | 123 + .../XUiPanelBountyTask.lua | 148 + .../XUiPanelBountyTaskInGrid.lua | 50 + .../XUiPanelEchelon.lua | 48 + .../XUiPanelFightActive.lua | 73 + .../XUiPanelHideStageNor.lua | 70 + .../XUiPanelHideTagNor.lua | 103 + .../XUiPanelRewardTips.lua | 60 + .../XUiPanelStageActive.lua | 70 + .../XUiPanelStageLock.lua | 66 + .../XUiPanelStageSelected.lua | 65 + .../XUiFubenMainLineChapter/XUiPanelStars.lua | 62 + .../XUiPanelStoryActive.lua | 89 + .../XUiPanelStorySelected.lua | 88 + .../XUiPanelStoryUnactive.lua | 72 + .../XUiFubenMainLineDetail.lua | 283 + .../XUiGridStageStar.lua | 56 + .../XUiGridPartnerTeachingBanner.lua | 92 + .../XUiGridPartnerTeachingStage.lua | 111 + .../XUiPartnerTeachingBanner.lua | 105 + .../XUiPartnerTeachingChapter.lua | 119 + .../XUiPartnerTeachingChapterContent.lua | 185 + .../XUiPartnerTeachingFightDetail.lua | 118 + .../XUiPartnerTeachingStoryDetail.lua | 88 + .../UiPracticeSingleDetail.lua | 93 + .../XUi/XUiFubenPractice/XUiFubenPractice.lua | 177 + .../XUiPanelPracticeAdvanced.lua | 119 + .../XUiPanelPracticeBasics.lua | 171 + .../XUiPanelPracticeCharacter.lua | 120 + .../XUiPracticeBasicsStage.lua | 73 + .../XUiPracticeSkillDetail.lua | 37 + .../XUiFubenRepeatChallengeNewChapter.lua | 47 + .../XUiFubenRepeatChallengeStageDetail.lua | 224 + .../XUiFubenRepeatchallenge.lua | 462 + .../XUiFubenRepeatchallengeLevelDes.lua | 45 + .../XUiGridFubenRepeatchallengeLevel.lua | 24 + .../XUiGridRewardLine.lua | 36 + .../XUiRepeatChallengeEnter.lua | 133 + .../XUiRepeatChallengeSettleWin.lua | 295 + .../XUiFubenResourceDetail.lua | 251 + .../XUiBlackShopBuyDetails.lua | 77 + .../XUiDayTopicCharacter.lua | 33 + .../XUiGridBlackShopItem.lua | 83 + .../XUiGridBuffDetailItem.lua | 33 + .../XUiFubenRogueLike/XUiGridBuffInfoItem.lua | 32 + .../XUiFubenRogueLike/XUiGridHelpRoleItem.lua | 20 + .../XUiFubenRogueLike/XUiGridNodeShopItem.lua | 107 + .../XUiGridRogueLikeCharacter.lua | 166 + .../XUiFubenRogueLike/XUiGridRoleInfoItem.lua | 20 + .../XUiFubenRogueLike/XUiGridTopicInfo.lua | 18 + .../XUiNodeShopBuyDetails.lua | 103 + .../XUiRogueLikeBoxEntrance.lua | 31 + .../XUiRogueLikeBuffStrengthen.lua | 164 + .../XUiRogueLikeCharItem.lua | 70 + .../XUiRogueLikeClearance.lua | 44 + .../XUiRogueLikeClearanceScoreItem.lua | 19 + .../XUiRogueLikeFightEntrance.lua | 128 + .../XUiRogueLikeFightTips.lua | 167 + .../XUiRogueLikeHelpRole.lua | 61 + .../XUiRogueLikeIllegalShop.lua | 271 + .../XUiFubenRogueLike/XUiRogueLikeMain.lua | 807 ++ .../XUiRogueLikeMemberHead.lua | 55 + .../XUiFubenRogueLike/XUiRogueLikeMyBuff.lua | 66 + .../XUiFubenRogueLike/XUiRogueLikeNode.lua | 279 + .../XUiRogueLikeObtainBuff.lua | 23 + .../XUiFubenRogueLike/XUiRogueLikeReset.lua | 33 + .../XUiRogueLikeRestEntrance.lua | 73 + .../XUiRogueLikeRoomCharacter.lua | 530 + .../XUiFubenRogueLike/XUiRogueLikeSetTeam.lua | 229 + .../XUiFubenRogueLike/XUiRogueLikeShop.lua | 220 + .../XUiRogueLikeShopEntrance.lua | 45 + .../XUiRogueLikeStoryEntrance.lua | 268 + .../XUiRogueLikeStoryResult.lua | 311 + .../XUiRogueLikeSupportCharItem.lua | 25 + .../XUiFubenRogueLike/XUiRogueLikeTask.lua | 106 + .../XUiRogueLikeThemeTips.lua | 119 + .../XUiRogueLikeTrialOpens.lua | 22 + .../XUiFubenRogueLike/XUiShopSpecialTool.lua | 52 + .../ChildItem/XUiBuffTipsItem.lua | 20 + .../ChildItem/XUiGridPointReward.lua | 85 + .../ChildItem/XUiGridRes.lua | 92 + .../ChildItem/XUiGridResAlloBuff.lua | 24 + .../ChildItem/XUiGridStageBuffIcon.lua | 24 + .../ChildItem/XUiGridStarReward.lua | 100 + .../ChildItem/XUiGridTask.lua | 199 + .../ChildItem/XUiRoomCharListGrid.lua | 56 + .../ChildItem/XUiStageItem.lua | 93 + .../CharacterDetail/XUiCharProperty.lua | 43 + .../RoleList/CharacterDetail/XUiCharaInfo.lua | 128 + .../RoleList/CharacterDetail/XUiViewRole.lua | 88 + .../CharacterPanel/XUiCharacterGrid.lua | 75 + .../CharacterPanel/XUiCharacterList.lua | 47 + .../RoleList/EquipDetail/XUiEquipDetail.lua | 132 + .../EquipDetail/XUiEquipDetailChild.lua | 123 + .../RoleList/EquipDetail/XUiEquipGrid.lua | 101 + .../RoleList/XUiRoleList.lua | 141 + .../XUiResAllo/XUiPanelCombatAdditions.lua | 66 + .../XUiResAllo/XUiPanelCombatMembers.lua | 51 + .../XUiResAllo/XUiSimulatedCombatResAllo.lua | 217 + .../XUiSettleWin/XUiGridCond.lua | 15 + .../XUiSettleWin/XUiGridWinRole.lua | 20 + .../XUiSimulatedCombatSettleWin.lua | 344 + .../XUiSimulatedCombatBossBuffTips.lua | 33 + .../XUiSimulatedCombatBuffTip.lua | 54 + .../XUiSimulatedCombatChapter.lua | 320 + .../XUiSimulatedCombatMain.lua | 298 + .../XUiSimulatedCombatNewRoomSingle.lua | 77 + .../XUiSimulatedCombatRoomCharacter.lua | 206 + .../XUiSimulatedCombatStageDetail.lua | 238 + .../XUiSimulatedCombatStarReward.lua | 52 + .../XUiSimulatedCombatTaskReward.lua | 125 + .../XUiFubenStageDetail.lua | 368 + .../XUiGridFubenStageDetailStar.lua | 64 + .../XUiFubenTaskReward/XUiFubenTaskReward.lua | 135 + .../XUi/XUiFubenTaskReward/XUiGridTask.lua | 199 + .../XUiGridUnionBuffItem.lua | 24 + .../XUiGridUnionCharacterItem.lua | 153 + .../XUiGridUnionDamageItem.lua | 36 + .../XUiGridUnionEventHead.lua | 18 + .../XUiGridUnionEventStageItem.lua | 160 + .../XUiGridUnionRankItem.lua | 62 + .../XUiGridUnionRankMember.lua | 25 + .../XUiFubenUnionKill/XUiGridUnionRankTab.lua | 22 + .../XUiGridUnionRewardItem.lua | 54 + .../XUiGridUnionShareCharItem.lua | 25 + .../XUiGridUnionStageMember.lua | 133 + .../XUiPanelUnionBuffDetails.lua | 40 + .../XUiPanelUnionDamageDetails.lua | 44 + .../XUiPanelUnionKillMainRank.lua | 206 + .../XUiPanelUnionKillMyRank.lua | 83 + .../XUiPanelUnionKillRankReward.lua | 57 + .../XUiPanelUnionSectionEnd.lua | 21 + .../XUiUnionKillDifficulty.lua | 36 + .../XUiUnionKillEnterFight.lua | 141 + .../XUiFubenUnionKill/XUiUnionKillGrade.lua | 97 + .../XUiUnionKillGridTeamCard.lua | 82 + .../XUiFubenUnionKill/XUiUnionKillMain.lua | 507 + .../XUiFubenUnionKill/XUiUnionKillMember.lua | 280 + .../XUiFubenUnionKill/XUiUnionKillRank.lua | 64 + .../XUiFubenUnionKill/XUiUnionKillRoom.lua | 489 + .../XUiUnionKillSelectRole.lua | 255 + .../XUiFubenUnionKill/XUiUnionKillStage.lua | 605 + .../XUiFubenUnionKill/XUiUnionKillTask.lua | 71 + .../XUiUnionKillTipCardShare.lua | 40 + .../XUiFunctionalOpen/XUiFunctionalOpen.lua | 388 + .../XUiFunctionalOpen/XUiHintFunctional.lua | 101 + .../XUiFurnitureDetail/XUiFurnitureDetail.lua | 259 + .../XUiFurnitureObtain.lua | 468 + .../XUiFurnitureRecycleObtain.lua | 49 + .../XUiGridObtain.lua | 80 + .../XUiFurnitureTypeSelect.lua | 443 + .../XUiGridCategory.lua | 60 + .../Scripts/XUi/XUiGacha/XUiDrawActivity.lua | 240 + .../XUi/XUiGacha/XUiDrawActivityControl.lua | 116 + .../XUi/XUiGacha/XUiDrawActivityLog.lua | 246 + .../XUi/XUiGacha/XUiDrawActivityShow.lua | 502 + .../XUiGachaOrganize/XUiGachaOrganize.lua | 432 + .../XUiGachaOrganizeDrawResult.lua | 165 + .../XUiGachaOrganize/XUiGachaPanelPreview.lua | 67 + .../XUiGachaOrganize/XUiGridGacha.lua | 66 + .../XUi/XUiGameNotice/XHtmlHandler.lua | 464 + .../XUi/XUiGameNotice/XUiGameNotice.lua | 396 + .../XUi/XUiGuardCamp/XUiChongzhiTanchuang.lua | 443 + .../XUiChongzhiTanchuangListItem.lua | 23 + .../XUi/XUiGuardCamp/XUiGuardCampMain.lua | 365 + .../XUi/XUiGuardCamp/XUiGuardCampTips.lua | 101 + .../Scripts/XUi/XUiGuide/XUiGuideNew.lua | 197 + .../XUiChildItem/XUiGridChallengeItem.lua | 60 + .../XUiChildItem/XUiGridChannelItem.lua | 34 + .../XUiChildItem/XUiGridChannelVistorItem.lua | 33 + .../XUiChildItem/XUiGridCustomNameItem.lua | 37 + .../XUiChildItem/XUiGridGuildBoxItem.lua | 102 + .../XUiChildItem/XUiGridGuildEnlistItem.lua | 96 + .../XUiChildItem/XUiGridGuildGiftItem.lua | 54 + .../XUiGridGuildHornorMemberGroup.lua | 32 + .../XUiChildItem/XUiGridGuildLogItem.lua | 27 + .../XUiChildItem/XUiGridGuildMemberCard.lua | 106 + .../XUiChildItem/XUiGridGuildPersonItem.lua | 48 + .../XUiChildItem/XUiGridGuildPresentItem.lua | 88 + .../XUiChildItem/XUiGridGuildTaskItem.lua | 74 + .../XUiChildItem/XUiGridMemberItem.lua | 169 + .../XUiChildItem/XUiGridMemberVistorItem.lua | 45 + .../XUiGuild/XUiChildItem/XUiGridNewsItem.lua | 61 + .../XUiChildItem/XUiGridParticularsItem.lua | 23 + .../XUiGuild/XUiChildItem/XUiGridRankItem.lua | 35 + .../XUiGridRankingListSwitchItem.lua | 35 + .../XUiGridRecommendationItem.lua | 52 + .../XUiChildItem/XUiGridTalentItem.lua | 100 + .../XUiChildItem/XUiGridTalentListItem.lua | 18 + .../XUiChildItem/XUiGridWelfareItem.lua | 48 + .../XUiChildItem/XUiGuildDonationItem.lua | 71 + .../XUiChildItem/XUiGuildGridShop.lua | 381 + .../XUiChildItem/XUiGuildHeadPortraitItem.lua | 33 + .../XUiChildItem/XUiGuildWelcomeWordItem.lua | 37 + .../XUiChildView/XUiGuildAdministration.lua | 345 + .../XUiChildView/XUiGuildEnlistNews.lua | 79 + .../XUiChildView/XUiGuildEnlistRecruit.lua | 79 + .../XUiChildView/XUiGuildMainInfo.lua | 122 + .../XUiChildView/XUiGuildMemberHornor.lua | 143 + .../XUiChildView/XUiGuildTaskDaily.lua | 41 + .../XUiChildView/XUiGuildTaskMainly.lua | 54 + .../XUiChildView/XUiGuildViewChallenge.lua | 73 + .../XUiGuildViewCharacterFilter.lua | 99 + .../XUiChildView/XUiGuildViewInformation.lua | 233 + .../XUiChildView/XUiGuildViewMember.lua | 186 + .../XUiChildView/XUiGuildViewParticulars.lua | 41 + .../XUiGuildViewSetHeadPortrait.lua | 87 + .../XUiGuildViewVistorInformation.lua | 107 + .../XUiChildView/XUiGuildViewVistorMember.lua | 59 + .../XUiChildView/XUiGuildViewWelfare.lua | 124 + .../XUiChildView/XUiGuildVistorInfo.lua | 93 + .../Scripts/XUi/XUiGuild/XUiGuildAsset.lua | 64 + .../Scripts/XUi/XUiGuild/XUiGuildBuild.lua | 181 + .../XUi/XUiGuild/XUiGuildChangePosition.lua | 268 + .../XUi/XUiGuild/XUiGuildCustomName.lua | 162 + .../Scripts/XUi/XUiGuild/XUiGuildDonation.lua | 101 + .../Scripts/XUi/XUiGuild/XUiGuildGift.lua | 242 + .../XUi/XUiGuild/XUiGuildGloryLevel.lua | 74 + .../XUi/XUiGuild/XUiGuildInformation.lua | 100 + .../Scripts/XUi/XUiGuild/XUiGuildLevelUp.lua | 42 + .../Scripts/XUi/XUiGuild/XUiGuildLog.lua | 134 + .../Scripts/XUi/XUiGuild/XUiGuildMain.lua | 549 + .../Scripts/XUi/XUiGuild/XUiGuildNews.lua | 54 + .../XUi/XUiGuild/XUiGuildPanelWelfare.lua | 32 + .../Scripts/XUi/XUiGuild/XUiGuildPerson.lua | 149 + .../XUi/XUiGuild/XUiGuildRankingList.lua | 190 + .../XUiGuild/XUiGuildRankingListSwitch.lua | 291 + .../XUi/XUiGuild/XUiGuildRecommendation.lua | 287 + .../Scripts/XUi/XUiGuild/XUiGuildRecruit.lua | 59 + .../Scripts/XUi/XUiGuild/XUiGuildRongyu.lua | 114 + .../Scripts/XUi/XUiGuild/XUiGuildShop.lua | 189 + .../Scripts/XUi/XUiGuild/XUiGuildSkill.lua | 102 + .../XUi/XUiGuild/XUiGuildSkillDetail.lua | 110 + .../Scripts/XUi/XUiGuild/XUiGuildTask.lua | 63 + .../Scripts/XUi/XUiGuild/XUiGuildVistor.lua | 84 + .../XUi/XUiGuild/XUiGuildWelcomeWord.lua | 70 + .../ChildView/XUiGuildBossHpReward.lua | 44 + .../Component/XUiGuildBossGuildRankItem.lua | 39 + .../Component/XUiGuildBossHpRewardItem.lua | 25 + .../Component/XUiGuildBossLevelGrid.lua | 62 + .../Component/XUiGuildBossLog.lua | 29 + .../Component/XUiGuildBossPlayerRankItem.lua | 36 + .../Component/XUiGuildBossRankItem.lua | 31 + .../Component/XUiGuildBossRankPanel.lua | 34 + .../Component/XUiGuildBossRankRewardItem.lua | 25 + .../Component/XUiGuildBossRewardItem.lua | 88 + .../Component/XUiGuildBossSkillGrid.lua | 31 + .../Component/XUiGuildBossStageLevel.lua | 70 + .../Component/XUiGuildBossStageRankItem.lua | 26 + .../Component/XUiGuildBossTeamList.lua | 42 + .../XUiGuildBossCurSubLevelInfo.lua | 158 + .../XUi/XUiGuildBoss/XUiGuildBossDetail.lua | 53 + .../XUi/XUiGuildBoss/XUiGuildBossDiff.lua | 40 + .../XUiGuildBoss/XUiGuildBossFightResult.lua | 65 + .../XUi/XUiGuildBoss/XUiGuildBossHall.lua | 235 + .../XUiGuildBossMainLevelInfo.lua | 110 + .../XUiGuildBossNewRoomSingle.lua | 78 + .../XUiGuildBossOtherSubLevelInfo.lua | 61 + .../XUi/XUiGuildBoss/XUiGuildBossRank.lua | 56 + .../XUiGuildBoss/XUiGuildBossRankReward.lua | 49 + .../XUi/XUiGuildBoss/XUiGuildBossSkill.lua | 40 + .../XUi/XUiGuildBoss/XUiGuildBossStage.lua | 569 + .../XUi/XUiGuildBoss/XUiGuildBossTip.lua | 29 + .../XUi/XUiHelpCourse/XUiGridHelpCourse.lua | 16 + .../Scripts/XUi/XUiHelpCourse/XUiHelp.lua | 43 + .../Scripts/XUi/XUiHelpCourse/XUiHelpNew.lua | 107 + .../Scripts/XUi/XUiHomeMain/XUiHomeMain.lua | 160 + .../XUiHostelCharacterWork.lua | 245 + .../XUiHostelDelegate/XUiHostelDelegate.lua | 194 + .../XUiGridDelegateReporter.lua | 58 + .../XUiHostelDelegateReporter.lua | 71 + .../XUiGridFuncUpgradeInfoItem.lua | 61 + .../XUiGridFunctionContenItem.lua | 60 + .../XUiHostelDeviceDetail.lua | 204 + .../XUiPanelDeviceUpgradeInfo.lua | 191 + .../XUiGridFuncUpgradeResItem.lua | 58 + .../XUiHostelDeviceUpgradeResult.lua | 121 + .../XUiHostelDeviceUpgrading.lua | 88 + .../XUiHostelMissionComplete.lua | 89 + .../Scripts/XUi/XUiHostelQte/XUiHostelQte.lua | 65 + .../XUi/XUiHostelRest/XUiGridFloorItem.lua | 98 + .../XUiHostelRest/XUiGridIdleCharacter.lua | 129 + .../XUi/XUiHostelRest/XUiGridRestCharItem.lua | 85 + .../XUi/XUiHostelRest/XUiHostelRest.lua | 393 + .../XUi/XUiHostelRest/XUiPanelRestModel.lua | 125 + .../XUi/XUiHostelRoom/XUiHostelRoom.lua | 80 + .../Scripts/XUi/XUiHud/XUiGridCoolTime.lua | 145 + .../Scripts/XUi/XUiHud/XUiGridDeviceState.lua | 155 + .../Scripts/XUi/XUiHud/XUiGridRoomUpgrade.lua | 160 + .../XUi/XUiHud/XUiGridWorkSlotState.lua | 152 + Resources/Scripts/XUi/XUiHud/XUiHud.lua | 151 + .../XUiInvertCardGame/XUiInvertCardGame.lua | 241 + .../XUiInvertCardGamePanel.lua | 326 + .../XUiInvertCardRewardItem.lua | 50 + .../XUiInvertCardRewardPanel.lua | 93 + .../XUiInvertGameCardItem.lua | 102 + .../XUi/XUiKillZone/XUiGridKillZonePlugin.lua | 32 + .../XUiKillZone/XUiGridKillZonePluginSlot.lua | 37 + .../XUi/XUiKillZone/XUiGridKillZoneStage.lua | 56 + .../XUi/XUiKillZone/XUiKillZoneBuffTips.lua | 48 + .../XUi/XUiKillZone/XUiKillZoneMain.lua | 386 + .../XUiKillZone/XUiKillZoneNewRoomSingle.lua | 54 + .../XUiGridKillZonePluginDesc.lua | 28 + .../XUiGridKillZonePluginGroup.lua | 53 + .../XUiGridKillZonePluginOperate.lua | 90 + .../XUiGridKillZonePluginSlotOperate.lua | 52 + .../XUiKillZonePlugin/XUiKillZonePlugin.lua | 175 + .../XUiKillZonePluginPopup.lua | 224 + .../XUiKillZonePluginReset.lua | 77 + .../XUiKillZoneReward/XUiGridDailyReward.lua | 62 + .../XUiKillZoneReward/XUiGridReward.lua | 68 + .../XUiKillZoneReward/XUiKillZoneDaily.lua | 90 + .../XUiKillZoneReward/XUiKillZoneReward.lua | 90 + .../XUi/XUiKillZone/XUiKillZoneSettleWin.lua | 202 + .../XUiKillZone/XUiKillZoneStageDetail.lua | 156 + .../XUi/XUiLeftPopupTip/UiLeftPopupTip.lua | 23 + .../XUi/XUiLogin/XLoginAttentionPanel.lua | 44 + .../XUi/XUiLogin/XLoginNoticePanel.lua | 40 + .../XUi/XUiLogin/XLoginSwitchAccountPanel.lua | 185 + .../Scripts/XUi/XUiLogin/XUiAccountSign.lua | 74 + .../Scripts/XUi/XUiLogin/XUiGridServer.lua | 84 + Resources/Scripts/XUi/XUiLogin/XUiLogin.lua | 464 + .../XUi/XUiLogin/XUiLoginAgreePanel.lua | 91 + .../XUi/XUiLogin/XUiLoginAgreement.lua | 16 + .../Scripts/XUi/XUiLogin/XUiLoginDialog.lua | 27 + .../XUi/XUiLogin/XUiLoginNetworkModePanel.lua | 67 + .../XUi/XUiLogin/XUiLoginTypePanel.lua | 56 + .../Scripts/XUi/XUiLogin/XUiSetAccount.lua | 100 + .../XUi/XUiLoginNotice/XUiLoginNotice.lua | 125 + .../XUiLoginVerification.lua | 143 + .../Scripts/XUi/XUiLotto/XUiGridTicket.lua | 65 + Resources/Scripts/XUi/XUiLotto/XUiLotto.lua | 170 + .../Scripts/XUi/XUiLotto/XUiLottoLog.lua | 242 + .../Scripts/XUi/XUiLotto/XUiLottoShow.lua | 495 + .../XUi/XUiLotto/XUiLottoTanchuang.lua | 76 + .../XUi/XUiLotto/XUiPanelLottoPreview.lua | 76 + Resources/Scripts/XUi/XUiMail/XUiGridItem.lua | 62 + .../Scripts/XUi/XUiMail/XUiGridTitle.lua | 93 + Resources/Scripts/XUi/XUiMail/XUiMail.lua | 296 + .../XUiChildItem/XUiGridSubMenuItem.lua | 46 + .../XUi/XUiMain/XUiChildView/XUiPanelAd.lua | 284 + .../XUiChildView/XUiPanelArenaOnline.lua | 133 + .../XUiChildView/XUiPanelSignBoard.lua | 543 + Resources/Scripts/XUi/XUiMain/XUiMain.lua | 344 + Resources/Scripts/XUi/XUiMain/XUiMainDown.lua | 69 + .../Scripts/XUi/XUiMain/XUiMainLeftBottom.lua | 231 + .../Scripts/XUi/XUiMain/XUiMainLeftMid.lua | 113 + .../Scripts/XUi/XUiMain/XUiMainLeftTop.lua | 127 + .../Scripts/XUi/XUiMain/XUiMainOther.lua | 43 + .../XUi/XUiMain/XUiMainRightBottom.lua | 82 + .../Scripts/XUi/XUiMain/XUiMainRightMid.lua | 563 + .../XUi/XUiMain/XUiMainRightMidSecond.lua | 104 + .../Scripts/XUi/XUiMain/XUiMainRightTop.lua | 254 + .../XUiFubenMaintaineraction.lua | 134 + .../XUiFubenMaintaineractionDetailsTips.lua | 49 + .../XUiFubenMaintaineractionFighting.lua | 68 + .../XUiFubenMaintaineractionRecording.lua | 37 + .../XUiFubenMaintaineractionTipLayer.lua | 78 + .../XUiFubenMaintaineractionTreasurechest.lua | 36 + .../XUi/XUiMaintainerAction/XUiGridCard.lua | 144 + .../XUiMaintainerAction/XUiGridMapNote.lua | 151 + .../XUi/XUiMaintainerAction/XUiGridPlayer.lua | 89 + .../XUi/XUiMaintainerAction/XUiGridRecord.lua | 27 + .../XUi/XUiMaintainerAction/XUiPanelBelow.lua | 157 + .../XUiPanelIntermediate.lua | 166 + .../XUi/XUiMedal/XUiCollectionStyle.lua | 60 + .../Scripts/XUi/XUiMedal/XUiCollectionTip.lua | 125 + .../XUi/XUiMedal/XUiGridCollection.lua | 73 + .../Scripts/XUi/XUiMedal/XUiGridMedal.lua | 47 + .../Scripts/XUi/XUiMedal/XUiMeadalDetail.lua | 93 + .../Scripts/XUi/XUiMedal/XUiMedalUnlock.lua | 64 + .../XUi/XUiMedal/XUiMedalUnlockTips.lua | 29 + .../XUi/XUiMedal/XUiObtainCollection.lua | 43 + .../XUi/XUiMedal/XUiOtherPlayerGridMedal.lua | 53 + .../Scripts/XUi/XUiMedal/XUiPanelMedal.lua | 219 + .../XUi/XUiMedal/XUiPanelMedalListView.lua | 79 + .../XUi/XUiMedal/XUiUpgradeCollection.lua | 23 + .../XUiMentorAnnouncement.lua | 47 + .../XUiMentorAwarenessGiveaway.lua | 402 + .../XUiMentorAwarenessPopup.lua | 112 + .../MentorFile/XUiGridPlayer.lua | 34 + .../MentorFile/XUiMentorFile.lua | 61 + .../MentorFile/XUiPanelStudent.lua | 66 + .../MentorFile/XUiPanelTeacher.lua | 30 + .../MentorGiftTisp/XUiMentorGiftTisp.lua | 49 + .../MentorMain/XUiGridStudent.lua | 91 + .../MentorMain/XUiGridTeacher.lua | 89 + .../MentorMain/XUiMentorMain.lua | 243 + .../MentorApplication/XUiGridGotManifesto.lua | 105 + .../XUiMentorApplication.lua | 97 + .../MentorDeclaration/XUiGridMentorLabel.lua | 51 + .../XUiMentorDeclaration.lua | 179 + .../MentorRecommendation/XUiGridManifesto.lua | 108 + .../XUiMentorRecommendation.lua | 150 + .../MentorRecording/XUiMentorRecording.lua | 35 + .../MentorGraduation/XUiMentorGraduation.lua | 52 + .../MentorReward/XUiGridPhasesReward.lua | 64 + .../MentorReward/XUiGridTeacherTask.lua | 127 + .../MentorReward/XUiMentorReward.lua | 70 + .../MentorReward/XUiMentorRewardTisp.lua | 41 + .../XUiPanelStudentGraduateReward.lua | 58 + .../MentorReward/XUiPanelStudentReward.lua | 85 + .../XUiPanelTeacherPhasesReward.lua | 82 + .../MentorReward/XUiPanelTeacherReward.lua | 130 + .../MentorShare/XUiGridSelectTask.lua | 79 + .../MentorShare/XUiMentorSelectTask.lua | 91 + .../MentorTask/XUiGridPhasesTask.lua | 61 + .../MentorTask/XUiGridStudentWeeklyTask.lua | 162 + .../MentorTask/XUiGridTaskAssist.lua | 76 + .../MentorTask/XUiGridTaskReward.lua | 144 + .../MentorTask/XUiMentorTask.lua | 88 + .../MentorTask/XUiPanelStudentPhasesTask.lua | 55 + .../MentorTask/XUiPanelStudentTask.lua | 68 + .../MentorTask/XUiPanelTeacherTask.lua | 157 + .../MentorTask/XUiPanelTeacherTaskAssist.lua | 47 + .../MentorTask/XUiPanelTeacherTaskReward.lua | 41 + .../XUi/XUiMineSweeping/XUiGridMine.lua | 90 + .../XUiMineSweeping/XUiGridStageReward.lua | 50 + .../XUiMineSweeping/XUiMineSweepingMain.lua | 264 + .../XUi/XUiMineSweeping/XUiPanelAllGrid.lua | 92 + .../XUi/XUiMineSweeping/XUiPanelCondition.lua | 23 + .../XUi/XUiMineSweeping/XUiPanelPlay.lua | 48 + .../XUi/XUiMineSweeping/XUiPanelSequence.lua | 59 + .../XUiMineSweeping/XUiPanelSequenceWin.lua | 38 + .../XUiMineSweeping/XUiPanelSettlement.lua | 57 + .../XUi/XUiMineSweeping/XUiPanelStart.lua | 58 + .../ComposeGame/XUiComposeGame.lua | 191 + .../ComposeGame/XUiComposeGameBagGrid.lua | 87 + .../ComposeGame/XUiComposeGamePanelBag.lua | 43 + .../XUiComposeGamePanelRefresh.lua | 46 + .../XUiComposeGamePanelSchedule.lua | 156 + .../ComposeGame/XUiComposeGamePanelShop.lua | 42 + .../ComposeGame/XUiComposeGameShopGrid.lua | 67 + .../XUiComposeGameStarPanelLevel.lua | 36 + .../ComposeGame/XUiComposeGameTreasureBox.lua | 60 + .../FingerGuessing/XUiFingerGuessFinger.lua | 30 + .../XUiFingerGuessGamePanel.lua | 137 + .../FingerGuessing/XUiFingerGuessPKPanel.lua | 150 + .../FingerGuessing/XUiFingerGuessResult.lua | 52 + .../XUiFingerGuessSSExplainPanel.lua | 47 + .../XUiFingerGuessSSLevelPanel.lua | 96 + .../XUiFingerGuessSSRolePanel.lua | 28 + .../XUiFingerGuessSSStartPanel.lua | 91 + .../XUiFingerGuessSSTitlePanel.lua | 72 + .../XUiFingerGuessScorePanel.lua | 76 + .../FingerGuessing/XUiFingerGuessStage.lua | 37 + .../XUiFingerGuessingEyePanel.lua | 118 + .../FingerGuessing/XUiFingerGuessingGame.lua | 125 + .../XUiFingerGuessingSelectStage.lua | 145 + .../FingerGuessing/XUiFingerGuessingTask.lua | 125 + .../XUiFingerGuessingTaskDynamicTable.lua | 46 + ...XUiWhiteValenDispatchMemberDynamicGrid.lua | 58 + ...UiWhiteValenDispatchMemberDynamicTable.lua | 68 + .../XUiWhiteValenDispatchPanelPlace.lua | 18 + .../XUiWhiteValenDispatchPanelReward.lua | 32 + .../XUiWhiteValenInviteCharaGrid.lua | 32 + .../XUiWhiteValenInviteMemberDynamicGrid.lua | 46 + .../XUiWhiteValenInviteMemberDynamicTable.lua | 56 + .../XUiWhiteValenItemGrid.lua | 32 + .../XUiWhiteValenMainButtonPanel.lua | 179 + .../XUiWhiteValenMainEventPanel.lua | 66 + .../WhiteValentine2021/XUiWhiteValenPlace.lua | 75 + .../XUiWhiteValenTaskDynamicTable.lua | 47 + .../XUiWhiteValentineDispatch.lua | 64 + .../XUiWhiteValentineInvite.lua | 60 + .../XUiWhiteValentineMain.lua | 197 + .../XUiWhiteValentineStory.lua | 36 + .../XUiWhiteValentineTask.lua | 135 + .../XUi/XUiMission/XUiGridConditionTxt.lua | 79 + .../Scripts/XUi/XUiMission/XUiGridLimit.lua | 74 + .../XUi/XUiMission/XUiGridMissionCommon.lua | 9 + .../XUi/XUiMission/XUiGridMisssionTeam.lua | 82 + .../Scripts/XUi/XUiMission/XUiMission.lua | 332 + .../XUi/XUiMission/XUiMissionAddSpeedTip.lua | 110 + .../XUi/XUiMission/XUiMissionChapter.lua | 99 + .../XUi/XUiMission/XUiMissionCompleted.lua | 131 + .../Scripts/XUi/XUiMission/XUiMissionTeam.lua | 265 + .../XUi/XUiMission/XUiMissionTeamLimit.lua | 101 + .../XUi/XUiMission/XUiMissionTeamSelect.lua | 172 + .../Scripts/XUi/XUiMission/XUiPanelArea.lua | 86 + .../XUiMission/XUiPanelMissionChapterGird.lua | 129 + .../XUiMission/XUiPanelMissionCharacter.lua | 120 + .../XUi/XUiMission/XUiPanelMissionGrid.lua | 291 + .../XUi/XUiMission/XUiPanelRewardBig.lua | 155 + .../XUi/XUiMission/XUiPanelRewardSmall.lua | 118 + .../XUiMoeWar/ChildItem/XUiGridGroupList.lua | 28 + .../XUiMoeWar/ChildItem/XUiGridPairGroup.lua | 51 + .../XUi/XUiMoeWar/ChildItem/XUiGridRank.lua | 52 + .../XUiMoeWar/ChildItem/XUiGridVoteItem.lua | 199 + .../ChildItem/XUiMessageGridAction.lua | 58 + .../ChildItem/XUiMessageGridPlayer.lua | 48 + .../ChildItem/XUiScheduleGridPair.lua | 82 + .../ChildItem/XUiScheduleGridPlayer.lua | 64 + .../Preparation/XUiMoeWarPreparation.lua | 372 + .../XUiMoeWarPreparationBtnTab.lua | 65 + .../XUiMoeWarPreparationRewardGrid.lua | 63 + .../XUiMoeWarPreparationStageGrid.lua | 132 + .../XUiMoeWar/Prepare/XUiMoeWarPrepare.lua | 377 + .../Prepare/XUiMoeWarPrepareConditionGrid.lua | 51 + .../XUiMoeWar/Recruit/XUiMoeWarChatPools.lua | 18 + .../XUiMoeWar/Recruit/XUiMoeWarRecruit.lua | 266 + .../Recruit/XUiMoeWarRecruitGrid.lua | 156 + .../Recruit/XUiMoeWarRecruitMsgPanel.lua | 391 + .../XUiMoeWar/Recruit/XUiPanelLineItem.lua | 12 + .../XUi/XUiMoeWar/Recruit/XUiPanelMsgItem.lua | 86 + .../SceneAnimation/UiMoeWarAnimationTips.lua | 7 + .../SceneAnimation/XMoeWarAnimationRole.lua | 262 + .../SceneAnimation/XUiMoeWarAnimation.lua | 294 + .../XUiMoeWar/SubPage/XUiPanelMatchFinal.lua | 136 + .../XUiMoeWar/SubPage/XUiPanelMatchLarge.lua | 115 + .../XUiMoeWar/SubPage/XUiPanelMatchSmall.lua | 59 + .../XUi/XUiMoeWar/SubPage/XUiPanelMyRank.lua | 75 + .../XUiMoeWar/SubPage/XUiPanelPlayerVote.lua | 148 + .../XUiMoeWar/Support/XUiMoeWarSupport.lua | 49 + .../Support/XUiMoeWarSupportGrid.lua | 31 + .../XUi/XUiMoeWar/XUiMoeWarCharacter.lua | 780 ++ .../XUi/XUiMoeWar/XUiMoeWarGroupList.lua | 72 + .../Scripts/XUi/XUiMoeWar/XUiMoeWarMain.lua | 348 + .../XUi/XUiMoeWar/XUiMoeWarMessage.lua | 252 + .../XUi/XUiMoeWar/XUiMoeWarPhotograph.lua | 46 + .../XUi/XUiMoeWar/XUiMoeWarPollTips.lua | 49 + .../XUi/XUiMoeWar/XUiMoeWarRankingList.lua | 226 + .../XUi/XUiMoeWar/XUiMoeWarSchedule.lua | 259 + .../Scripts/XUi/XUiMoeWar/XUiMoeWarShop.lua | 255 + .../XUi/XUiMoeWar/XUiMoeWarSupportTips.lua | 38 + .../Scripts/XUi/XUiMoeWar/XUiMoeWarTask.lua | 124 + .../Scripts/XUi/XUiMoeWar/XUiMoeWarVote.lua | 756 ++ .../XUi/XUiMoneyReward/XUiMoneyReward.lua | 338 + .../XUiMoneyRewardFightTipFind.lua | 74 + .../XUiMoneyRewardFightTips.lua | 79 + .../XUiMoneyRewardLevelUpTips.lua | 89 + .../XUi/XUiMoneyReward/XUiMoneyRewardRank.lua | 49 + .../XUi/XUiMoneyReward/XUiMoneyRewardTask.lua | 103 + .../XUiMoneyRewardTaskCardTip.lua | 82 + .../XUi/XUiMoneyReward/XUiPanelRewardGird.lua | 95 + .../XUi/XUiMoneyReward/XUiPanelTask.lua | 179 + .../XUi/XUiMoneyReward/XUiPanelTaskCard.lua | 143 + .../Scripts/XUi/XUiMovie/XUIGridStaff.lua | 17 + .../XUi/XUiMovie/XUiGridMovieActor.lua | 366 + .../XUi/XUiMovie/XUiGridReviewItem.lua | 24 + .../XUi/XUiMovie/XUiGridSingleDialog.lua | 47 + Resources/Scripts/XUi/XUiMovie/XUiMovie.lua | 144 + .../Scripts/XUi/XUiMovie/XUiMovieReview.lua | 53 + .../XUi/XUiMovie/XUiStorySkipDialog.lua | 33 + .../XUi/XUiMovieAssemble/XUiMovieAssemble.lua | 66 + .../XUiMovieAssembleStage.lua | 83 + .../XUiGridFightDataItem.lua | 15 + .../XUiGridFightGradeItem.lua | 102 + .../XUiMultiplayerFightGrade.lua | 108 + .../XUiGridInviteFriendItem.lua | 67 + .../XUiMultiplayerInviteFriend.lua | 83 + .../XUiGridMulitiplayerRoomChar.lua | 367 + .../XUiGridMultiplayerDifficultyItem.lua | 27 + .../XUiMultiplayerRoom/XUiMultiplayerRoom.lua | 1132 ++ .../XUiMultiplayerRoom/XUiPanelActiveBuff.lua | 38 + .../XUiPanelActiveBuffMian.lua | 83 + .../XUiPanelChangeStage.lua | 80 + .../XUi/XUiMusicPlayer/XUiGridMusicPlayer.lua | 27 + .../XUi/XUiMusicPlayer/XUiMusicPlayer.lua | 207 + .../XUiMusicPlayer/XUiPanelMusicSpectrum.lua | 49 + .../XUi/XUiNameplate/XUiGridNameplate.lua | 167 + .../XUi/XUiNameplate/XUiNameplateTip.lua | 134 + .../XUi/XUiNameplate/XUiObtainNameplate.lua | 54 + .../XUi/XUiNameplate/XUiPanelNameplate.lua | 46 + .../XUiGridAutoFightRewardLine.lua | 43 + .../XUiNewAutoFight/XUiNewAutoFightDialog.lua | 201 + .../XUiNewAutoFightSettleWin.lua | 148 + .../WeiLa/XUiFubenWeiLaStageItem.lua | 87 + .../WeiLa/XUiFubenWeiLaTutorial.lua | 186 + .../WeiLa/XUiPanelFubenWeiLaStage.lua | 252 + .../XUi/XUiNewChar/XUiFubenKoroStageItem.lua | 87 + .../XUiFunbenKoroTutoriaChallengeDetail.lua | 113 + .../XUiFunbenKoroTutoriaTeachingDetail.lua | 94 + .../XUi/XUiNewChar/XUiFunbenKoroTutorial.lua | 172 + .../XUi/XUiNewChar/XUiNewCharActivity.lua | 295 + .../XUiNewChar/XUiNewCharNewRoomSingle.lua | 38 + .../XUi/XUiNewChar/XUiNewCharStageItem.lua | 81 + .../XUi/XUiNewChar/XUiPanelFubenKoroStage.lua | 252 + .../XUi/XUiNewChar/XUiPanelLineChapter.lua | 323 + .../XUiNewPlayerTask/XUiBtnNewbieTaskTab.lua | 76 + .../XUiGridNewbieTaskItem.lua | 118 + .../XUi/XUiNewPlayerTask/XUiNewPlayerTask.lua | 293 + .../XUiNewPlayerTask/XUiPanelNewbieActive.lua | 134 + .../XUi/XUiNewPlayerTask/XUiPanelTaskItem.lua | 104 + .../XUi/XUiNewRoleShow/XUiNewRoleShow.lua | 235 + .../XUiNewRoomSingle/XUiBattleRoleRoom.lua | 425 + .../XUiBattleRoleRoomCaptain.lua | 94 + .../XUiBattleRoleRoomDefaultProxy.lua | 68 + .../XUiBattleRoomRoleDetail.lua | 306 + .../XUiBattleRoomRoleDetailDefaultProxy.lua | 98 + .../XUiBattleRoomRoleGrid.lua | 35 + .../XUi/XUiNewRoomSingle/XUiNewRoomSingle.lua | 2367 ++++ .../XUiNewRoomSingleProxy.lua | 147 + .../XUiNewRoomSingle/XUiNewRoomSingleTip.lua | 186 + .../XUiNewRoomSingle/XUiPanelActiveBuff.lua | 94 + .../XUiPanelActiveBuffTip.lua | 38 + .../XUiNewRoomSingle/XUiPanelArenaOnline.lua | 67 + .../XUiNewRoomSingle/XUiPanelBabelTower.lua | 102 + .../XUiDrawActivityControl.lua | 97 + .../XUiDrawBuyAssert.lua | 87 + .../XUiNewYearDrawActivity/XUiDrawNewYear.lua | 449 + .../XUiDrawNewYearActivityShow.lua | 562 + .../XUiNewYearDrawLog.lua | 56 + .../XUiCharacter/XGridNieRPODUpLvDetail.lua | 84 + .../XUiCharacter/XGridNieRUpLvDetail.lua | 91 + .../XUiNieR/XUiCharacter/XUiFuBenNierWork.lua | 211 + .../XUiCharacter/XUiFubenNierShengji.lua | 56 + .../XUiCharacter/XUiGridNierPODSkill.lua | 65 + .../XUiGrideNieRCharacterFoster.lua | 168 + .../XUiGrideNieRCharacterStory.lua | 46 + .../XUiNieR/XUiCharacter/XUiNierCharacter.lua | 125 + .../XUiCharacter/XUiNierCharacterSel.lua | 134 + .../XUiCharacter/XUiNierRoomSingle.lua | 125 + .../XUiPanelNierCharacterFoster.lua | 126 + .../XUiPanelNierCharacterStory.lua | 80 + .../XUiPanelNierCharacterTeaching.lua | 120 + .../Scripts/XUi/XUiNieR/XUiFubenNierEnter.lua | 158 + .../XUi/XUiNieR/XUiFubenNierGuanqiaNormal.lua | 340 + .../XUi/XUiNieR/XUiGridFubenNierPODSkill.lua | 43 + .../XUi/XUiNieR/XUiGridNieRTaskBtn.lua | 25 + .../XUi/XUiNieR/XUiGridNierChapter.lua | 92 + .../Scripts/XUi/XUiNieR/XUiGridNierStage.lua | 71 + .../XUiMainLine/XUiFubenNierLineChapter.lua | 131 + .../XUiMainLine/XUiPanelChapterStage.lua | 121 + .../XUiMainLine/XUiPanelMainlineChapter.lua | 85 + .../XUi/XUiNieR/XUiNieRBossFightResult.lua | 119 + .../XGridNieREasterEggChatList.lua | 23 + .../XPanelNieREasterEggAge.lua | 39 + .../XPanelNieREasterEggChat.lua | 194 + .../XPanelNieREasterEggChatList.lua | 49 + .../XPanelNieREasterEggTag.lua | 38 + .../XUiNieREasterEgg/XUiFightNieRTips.lua | 80 + .../XUiNieREasterEgg/XUiNieREasterEgg.lua | 257 + .../XUiNieREasterEgg/XUiNieRSaveData.lua | 39 + .../XUi/XUiNieR/XUiNieRNewRoomSingle.lua | 36 + Resources/Scripts/XUi/XUiNieR/XUiNieRTask.lua | 102 + .../XUi/XUiNieR/XUiNierMainLineBanner.lua | 99 + Resources/Scripts/XUi/XUiNieR/XUiNierShop.lua | 254 + .../Scripts/XUi/XUiNieR/XUiPanelNieRTask.lua | 58 + .../XUiNieR/XUiRepeat/XUiFubenNierRepeat.lua | 155 + .../XUiRepeat/XUiGridNierRepeatMainStage.lua | 148 + .../XUiRepeat/XUiGridNierRepeatStage.lua | 78 + .../XUiNieR/XUiRepeat/XUiNieRRepeatTag.lua | 66 + .../XUiRepeat/XUiNierRepeatLineBanner.lua | 149 + .../XUiRepeat/XUiPanelNieRRepeatBanner.lua | 52 + .../XUi/XUiNoticeTips/XUiNoticeTips.lua | 177 + .../Scripts/XUi/XUiObtain/XUiGridCommon.lua | 436 + Resources/Scripts/XUi/XUiObtain/XUiObtain.lua | 140 + .../XUiOnLineTranscript/XUiOnLineMatching.lua | 148 + .../XUiOnLineTranscript.lua | 242 + .../XUiOnlineBoss/UiOnlineBossActivity.lua | 2 + .../XUiOnlineBoss/XUiGridOnlineBossTask.lua | 55 + .../XUi/XUiOnlineBoss/XUiOnlineBoss.lua | 500 + .../XUi/XUiOnlineBoss/XUiPanelBossInfo.lua | 60 + .../XUi/XUiOnlineBoss/XUiPanelMatch.lua | 273 + .../XUi/XUiOnlineBoss/XUiPanelSkillBox.lua | 18 + .../XUi/XUiOnlineLoading/XUiOnLineLoading.lua | 76 + .../XUiPanelOnLineLoadingDetail.lua | 128 + .../XUiPanelOnLineLoadingDetailItem.lua | 104 + .../PartnerCarry/XUiGridPartnerCarry.lua | 63 + .../PartnerCarry/XUiPartnerCarry.lua | 271 + .../XUiPartner/PartnerCommon/XPartnerSort.lua | 285 + .../PartnerCommon/XUiGridBagPartner.lua | 43 + .../PartnerCommon/XUiGridPartnerAttrib.lua | 51 + .../XUiPartner/PartnerCommon/XUiGridSkill.lua | 99 + .../PartnerCommon/XUiPanelMainSkill.lua | 39 + .../PartnerCommon/XUiPartnerPopupTip.lua | 21 + .../PartnerCompose/XUiPartnerCompose.lua | 67 + .../PartnerInfo/XUiPartnerOwnedInfo.lua | 103 + .../PartnerInfo/XUiPartnerRename.lua | 45 + .../XUiPartner/PartnerMain/XUiGridPartner.lua | 110 + .../XUiPartner/PartnerMain/XUiPartnerMain.lua | 446 + .../PartnerPreview/XUiPartnerPreview.lua | 191 + .../PanelPartnerLevel/XUiPanelLevelBreak.lua | 107 + .../PanelPartnerLevel/XUiPanelLevelMax.lua | 51 + .../PanelPartnerLevel/XUiPanelLevelUp.lua | 310 + .../XUiPanelPartnerLevel.lua | 66 + .../XUiGridCanEatPartner.lua | 42 + .../XUiPanelPartnerQuality.lua | 110 + .../XUiPanelQualityMax.lua | 27 + .../XUiPanelQualityStar.lua | 205 + .../PanelPartnerQuality/XUiPanelQualityUp.lua | 51 + .../XUiPanelQualityUpConfirm.lua | 38 + .../UiPartnerSkillLevelUpAll.lua | 195 + .../PanelPartnerSkill/XUiGridSkillUp.lua | 47 + .../XUiPanelAnimationControl.lua | 114 + .../XUiPanelPartnerSkill.lua | 64 + .../PanelPartnerSkill/XUiPanelSkillUp.lua | 191 + .../XUiPanelSkillUpConfirm.lua | 69 + .../PanelPartnerStory/XUiGridStoryInfo.lua | 38 + .../XUiPanelPartnerStory.lua | 78 + .../PartnerProperty/XUiPartnerProperty.lua | 129 + .../PartnerShow/XUiPanelPartnerOverview.lua | 73 + .../XUiPanelPartnerPassiveSkill.lua | 21 + .../XUiPanelPartnerShowMainSkill.lua | 105 + .../XUiPanelPartnerShowMainSkillElement.lua | 72 + .../XUiPanelPartnerShowMainSkillOption.lua | 128 + .../PartnerShow/XUiPartnerPropertyOther.lua | 273 + .../PartnerShow/XUiPartnerShowSkillGrid.lua | 55 + .../MainSkill/XUiGridMainSkill.lua | 146 + .../MainSkill/XUiGridSkillElement.lua | 53 + .../MainSkill/XUiPanelElement.lua | 55 + .../MainSkill/XUiPanelMainSkillOption.lua | 74 + .../MainSkill/XUiPartnerActivateMainSkill.lua | 162 + .../PassiveSkill/XUiGridPassiveSkill.lua | 43 + .../XUiPartnerActivatePassiveSkill.lua | 144 + .../PartnerSkillPreview/XUiGridSkillDesc.lua | 36 + .../XUiPartnerSkillPreview.lua | 167 + .../XUiPartnerStrengthenSkip.lua | 33 + .../XUi/XUiPassport/Card/XUiPassportCard.lua | 132 + .../XUiPassport/Card/XUiPassportCardGrid.lua | 34 + .../UpLevel/XUiPassportUpLevel.lua | 250 + .../UpLevel/XUiPassportUpLevelGrid.lua | 68 + .../Scripts/XUi/XUiPassport/XUiPassport.lua | 290 + .../XUi/XUiPassport/XUiPassportPanel.lua | 204 + .../XUi/XUiPassport/XUiPassportPanelGrid.lua | 132 + .../XUiPassportPanelTaskActivity.lua | 68 + .../XUiPassport/XUiPassportPanelTaskDaily.lua | 64 + .../XUiPassportPanelTaskWeekly.lua | 83 + .../XUi/XUiPassport/XUiPassportTips.lua | 51 + .../PanelBoard/LeaveMsg/XUiPanelLeaveMsg.lua | 66 + .../LeaveMsg/XUiPanelLeaveMsgItem.lua | 90 + .../PanelBoard/MsgBoard/XUiPanelMsgBoard.lua | 87 + .../MsgBoard/XUiPanelMsgBoardItem.lua | 186 + .../MsgBoard/XUiPanelWriteDiary.lua | 105 + .../PanelPersonalDetails/XUiPanelJubao.lua | 136 + .../XUiPanelPersonalDetails.lua | 276 + .../XUiPanelPersonalDetailsCombat.lua | 85 + .../XUiPanelPersonalDetailsCombatItem.lua | 74 + .../PanelPersonalDetails/XUiPanelSupport.lua | 77 + .../XUi/XUiPersonalInfo/XUiPersonalInfo.lua | 134 + .../XUiGridPhotographCharacterBtn.lua | 37 + .../XUiGridPhotographOtherBtn.lua | 64 + .../XUiGridPhotographSceneBtn.lua | 43 + .../XUi/XUiPhotograph/XUiPhotograph.lua | 331 + .../XUiPhotographCapturePanel.lua | 35 + .../XUi/XUiPhotograph/XUiPhotographPanel.lua | 296 + .../XUiPhotograph/XUiPhotographSDKPanel.lua | 58 + .../XUiPicComposition/XUiGridEditDialogue.lua | 146 + .../XUiPicComposition/XUiGridHeadPortrait.lua | 46 + .../XUiGridNormalDialogue.lua | 33 + .../XUi/XUiPicComposition/XUiGridRank.lua | 60 + .../XUiHeadPortraitSelect.lua | 73 + .../XUi/XUiPicComposition/XUiPicChatRank.lua | 254 + .../XUiPicComposition/XUiPicComposition.lua | 823 ++ .../XUiPicCompositionPanelActive.lua | 54 + .../XUiPicCompositionTask.lua | 120 + .../XUi/XUiPlayer/XUiGridHeadFrame.lua | 96 + .../XUi/XUiPlayer/XUiGridHeadPortrait.lua | 96 + .../Scripts/XUi/XUiPlayer/XUiPanelAchieve.lua | 198 + .../XUi/XUiPlayer/XUiPanelHeadPortrait.lua | 90 + .../XUi/XUiPlayer/XUiPanelPlayerExp.lua | 65 + .../XUi/XUiPlayer/XUiPanelPlayerGloryExp.lua | 65 + .../XUi/XUiPlayer/XUiPanelPlayerInfo.lua | 471 + .../XUi/XUiPlayer/XUiPanelSetBirthday.lua | 94 + .../XUi/XUiPlayer/XUiPanelSetHeadPortrait.lua | 354 + .../Scripts/XUi/XUiPlayer/XUiPanelSetName.lua | 93 + .../Scripts/XUi/XUiPlayer/XUiPanelSetting.lua | 701 ++ Resources/Scripts/XUi/XUiPlayer/XUiPlayer.lua | 144 + .../XUiEquipDetailChildOther.lua | 225 + .../XUi/XUiPlayerInfo/XUiEquipDetailOther.lua | 88 + .../XUi/XUiPlayerInfo/XUiGridEquipOther.lua | 102 + .../XUiGridResonanceSkillOther.lua | 130 + .../XUiPlayerInfo/XUiGridSkillItemOther.lua | 67 + .../XUiPlayerInfo/XUiGridSubSkillOther.lua | 91 + .../XUiPlayerInfo/XUiPanelCharAllOther.lua | 114 + .../XUiPlayerInfo/XUiPanelCharGradeOther.lua | 190 + .../XUiPlayerInfo/XUiPanelCharLevelOther.lua | 46 + .../XUiPanelCharPropertyOther.lua | 181 + .../XUiPanelCharQualityOther.lua | 165 + .../XUiPlayerInfo/XUiPanelCharSkillOther.lua | 88 + .../XUiPlayerInfo/XUiPanelCharacterList.lua | 172 + .../XUiPanelCollectionScrollPlayerInfo.lua | 118 + .../XUiPanelFashionPlayerInfo.lua | 205 + .../XUi/XUiPlayerInfo/XUiPanelInfo.lua | 164 + .../XUiPlayerInfo/XUiPanelSkillInfoOther.lua | 248 + .../XUiPanelSkillLevelDetailOther.lua | 61 + .../XUi/XUiPlayerInfo/XUiPlayerInfo.lua | 380 + .../XUiPlayerInfo/XUiPlayerInfoAppearance.lua | 11 + .../XUi/XUiPlayerInfo/XUiPlayerInfoBase.lua | 110 + .../XUiPlayerInfoCharacterGrid.lua | 93 + .../XUiPlayerInfo/XUiPlayerInfoClothGrid.lua | 33 + .../XUiPlayerInfo/XUiPlayerInfoFetters.lua | 33 + .../XUi/XUiPlayerInfo/XUiPlayerInfoFight.lua | 11 + .../Scripts/XUi/XUiPlayerUp/XUiPlayerUp.lua | 275 + .../XUi/XUiPokemon/XUiGridPokemonChapter.lua | 43 + .../XUi/XUiPokemon/XUiGridPokemonPortrait.lua | 27 + .../XUi/XUiPokemon/XUiGridPokemonStage.lua | 42 + .../XUiPokemon/XUiGridPokemonStagePage.lua | 132 + .../XUiMonster/XUiGridPokemonMonster.lua | 133 + .../XUiGridPokemonMonsterSelectSkill.lua | 50 + .../XUiPokemon/XUiMonster/XUiPanelStars.lua | 34 + .../XUiMonster/XUiPokemonMonster.lua | 565 + .../XUiMonster/XUiPokemonMonsterObtain.lua | 44 + .../XUiMonster/XUiPokemonSkillDetails.lua | 34 + .../XUiMonster/XUiPokemonSkillSelect.lua | 62 + .../XUiMonster/XUiPokemonStarSuccess.lua | 53 + .../XUiMonster/XUiPokemonUpgradePreview.lua | 77 + .../XUiPokemon/XUiPanelPokemonStageDetail.lua | 144 + .../XUi/XUiPokemon/XUiPokemonActiveTask.lua | 66 + .../XUi/XUiPokemon/XUiPokemonFight.lua | 34 + .../XUiGridPokemonInfinityStageMonster.lua | 34 + .../XUiGridPokemonMemberMonster.lua | 137 + .../XUiGridPokemonStageMonster.lua | 32 + .../XUiPokemonFormation.lua | 561 + .../Scripts/XUi/XUiPokemon/XUiPokemonMain.lua | 342 + .../XUiPokemon/XUiPokemonMainLineBanner.lua | 160 + .../XUiFubenPokerGuessing.lua | 270 + .../XUiFubenPokerGuessingCardRecorder.lua | 56 + .../XUiFubenPokerGuessingTask.lua | 67 + .../XUiFubenPokerGuessingTips.lua | 65 + .../XUi/XUiPrequel/XUiGridChallengeItem.lua | 137 + .../XUi/XUiPrequel/XUiGridChallengeTab.lua | 59 + .../XUiGridPrequelCheckPointReward.lua | 126 + .../XUi/XUiPrequel/XUiGridPrequelPlotTab.lua | 91 + .../XUiPrequel/XUiPanelChallengeChapter.lua | 138 + .../XUi/XUiPrequel/XUiPanelChallengeMode.lua | 214 + .../XUi/XUiPrequel/XUiPanelChallengeTab.lua | 64 + .../XUi/XUiPrequel/XUiPanelCheckReward.lua | 115 + .../XUiPrequel/XUiPanelEnterFightDialog.lua | 122 + .../XUi/XUiPrequel/XUiPanelPlotTab.lua | 150 + .../XUi/XUiPrequel/XUiPanelPrequelChapter.lua | 183 + .../XUi/XUiPrequel/XUiPanelRegional.lua | 235 + .../XUiPrequel/XUiPanelUnlockChallenge.lua | 126 + .../Scripts/XUi/XUiPrequel/XUiPrequel.lua | 281 + .../XUiPrequelLineDetail.lua | 320 + .../XUi/XUiPromotionWay/XUiPromotionWay.lua | 74 + .../Scripts/XUi/XUiPurchase/XUiBatchPanel.lua | 180 + .../XUi/XUiPurchase/XUiGridPurchaseYK.lua | 247 + .../Scripts/XUi/XUiPurchase/XUiPurchase.lua | 547 + .../XUi/XUiPurchase/XUiPurchaseBuyTips.lua | 769 ++ .../XUi/XUiPurchase/XUiPurchaseCoatingLB.lua | 430 + .../XUiPurchaseCoatingLBListItem.lua | 305 + .../XUi/XUiPurchase/XUiPurchaseDetail.lua | 42 + .../Scripts/XUi/XUiPurchase/XUiPurchaseHK.lua | 91 + .../XUi/XUiPurchase/XUiPurchaseHKExchange.lua | 80 + .../XUiPurchaseHKExchangeListItem.lua | 80 + .../XUiPurchase/XUiPurchaseHKExchangeTips.lua | 75 + .../XUi/XUiPurchase/XUiPurchaseHKListItem.lua | 23 + .../XUi/XUiPurchase/XUiPurchaseHKShop.lua | 91 + .../XUiPurchase/XUiPurchaseHKShopListItem.lua | 100 + .../Scripts/XUi/XUiPurchase/XUiPurchaseLB.lua | 376 + .../XUi/XUiPurchase/XUiPurchaseLBListItem.lua | 320 + .../XUi/XUiPurchase/XUiPurchaseLBTips.lua | 330 + .../XUiPurchase/XUiPurchaseLBTipsListItem.lua | 23 + .../XUi/XUiPurchase/XUiPurchasePay.lua | 174 + .../XUi/XUiPurchase/XUiPurchasePayAdd.lua | 129 + .../XUiPurchase/XUiPurchasePayAddListItem.lua | 119 + .../XUiPurchase/XUiPurchasePayListItem.lua | 64 + .../XUiPurchaseSignTip/XUiPurchaseSignTip.lua | 81 + .../XUiPurchaseSignTipGridDay.lua | 37 + .../XUiPurchaseSignTipRound.lua | 326 + .../Scripts/XUi/XUiPurchase/XUiPurchaseYK.lua | 218 + .../XUi/XUiPurchase/XUiPurchaseYKListItem.lua | 23 + .../XUiRedEnvelope/XUiGridRedEnvelopeInfo.lua | 40 + .../XUi/XUiRedEnvelope/XUiRedEnvelope.lua | 79 + Resources/Scripts/XUi/XUiReform/XUiReform.lua | 502 + .../XUi/XUiReform/XUiReformBuffDetail.lua | 20 + .../XUi/XUiReform/XUiReformBuffPanel.lua | 125 + .../XUi/XUiReform/XUiReformBuffTips.lua | 49 + .../XUiReformCharacterDetailInfo.lua | 107 + .../XUi/XUiReform/XUiReformCharacterInfo.lua | 238 + .../XUiReform/XUiReformCombatSettleWin.lua | 138 + .../XUi/XUiReform/XUiReformEnemyPanel.lua | 489 + .../XUiReform/XUiReformEnvironmentPanel.lua | 108 + .../Scripts/XUi/XUiReform/XUiReformList.lua | 251 + .../XUi/XUiReform/XUiReformMemberPanel.lua | 434 + .../XUi/XUiReform/XUiReformNewRoomSingle.lua | 157 + .../XUi/XUiReform/XUiReformPreview.lua | 140 + .../XUi/XUiReform/XUiReformRoleList.lua | 198 + .../Scripts/XUi/XUiReform/XUiReformTeamUp.lua | 172 + .../XUi/XUiRegister/XUiGridAccount.lua | 22 + .../Scripts/XUi/XUiRegister/XUiRegister.lua | 74 + .../XUiGridRegressionTaskSchedule.lua | 56 + .../XUiPanelRegressionTaskCourse.lua | 42 + .../XUiPanelRegressionTaskDay.lua | 42 + .../XUiPanelRegressionTaskWeek.lua | 41 + .../XUi/XUiRegression/XUiRegression.lua | 108 + .../XUi/XUiRegression/XUiRegressionTask.lua | 181 + Resources/Scripts/XUi/XUiReport/XUiReport.lua | 105 + .../XUiGridFilterTagGroup.lua | 61 + .../XUi/XUiRoomCharacter/XUiRoomCharacter.lua | 1041 ++ .../XUiRoomCharacterFilterTips.lua | 141 + .../XUiRoomCharacterProxy.lua | 58 + .../XUi/XUiRoomTeamBuff/XUiRoomTeamBuff.lua | 19 + .../XUi/XUiRoomTeamPrefab/XUiGridTeam.lua | 237 + .../XUiGridTeamCharacter.lua | 55 + .../XUi/XUiRoomTeamPrefab/XUiGridTeamRole.lua | 92 + .../XUiRoomTeamPrefab/XUiPanelTeamSelect.lua | 180 + .../XUiRoomTeamPrefab/XUiRoomTeamPrefab.lua | 97 + .../XUiRoomTeamPrefab/XUiTeamPrefabReName.lua | 45 + .../Character/XUiRpgMakerGameCharacter.lua | 172 + .../XUiRpgMakerGameCharacterGrid.lua | 31 + .../Hint/XUiGridRpgMakerGameCardMini.lua | 94 + .../Hint/XUiGridRpgMakerGameMapNode.lua | 34 + .../Hint/XUiGridRpgMakerGameRecord.lua | 22 + .../Hint/XUiRpgMakerGameMapTip.lua | 72 + .../Main/XUiRpgMakerGameDetail.lua | 86 + .../Main/XUiRpgMakerGameMain.lua | 205 + .../Main/XUiRpgMakerGameStage.lua | 84 + .../Main/XUiRpgMakerGameStages.lua | 59 + .../Main/XUiRpgMakerGameTabBtn.lua | 63 + .../PlayMain/XUiRpgMakerGamePanelLoseTip.lua | 56 + .../PlayMain/XUiRpgMakerGamePanelWinTip.lua | 105 + .../PlayMain/XUiRpgMakerGamePlayMain.lua | 675 ++ .../PlayMain/XUiRpgMakerGamePlayScene.lua | 415 + .../PlayMain/XUiRpgMakerGameUnlockTip.lua | 29 + .../Task/XUiRpgMakerGamePlayTask.lua | 69 + .../XUiFubenRpgMakerGameMovie.lua | 17 + .../BattleResult/XUiRpgTowerSettleWin.lua | 188 + .../XUiRpgTowerRoomCharaListItem.lua | 56 + .../XUiRpgTowerRoomCharaListPanel.lua | 58 + .../ChangeMember/XUiRpgTowerRoomCharacter.lua | 137 + .../EditBattleUi/XUiRpgTowerNewRoomSingle.lua | 87 + .../XUiRpgTowerRoleListAdaptPage.lua | 41 + .../XUiRpgTowerRoleListAdaptPanel.lua | 71 + .../XUiRpgTowerRoleListTalentLevel.lua | 47 + .../XUiRpgTowerChangeMemberItem.lua | 50 + .../XUiRpgTowerChangeMemberList.lua | 71 + .../XUiRpgTowerRoleListChangeMember.lua | 44 + .../XUiRpgTowerRoleListChangeMemberPage.lua | 36 + .../XUiRpgTowerGrowPageLevelUpPanel.lua | 122 + .../XUiRpgTowerGrowPageNatureItem.lua | 38 + .../XUiRpgTowerGrowPageNatureLine.lua | 13 + .../XUiRpgTowerGrowPageNaturePanel.lua | 103 + .../GrowPage/XUiRpgTowerGrowPageTabsPanel.lua | 91 + .../GrowPage/XUiRpgTowerLevelUpTipsPanel.lua | 46 + .../GrowPage/XUiRpgTowerRoleListGrowPage.lua | 102 + .../MainPage/XUiRpgTowerCharaInfoInfo.lua | 42 + .../XUiRpgTowerCharaInfoSkillGrid.lua | 23 + .../MainPage/XUiRpgTowerCharaInfoSkills.lua | 36 + .../MainPage/XUiRpgTowerCharaInfoStatus.lua | 17 + .../MainPage/XUiRpgTowerRoleListCharaInfo.lua | 47 + .../MainPage/XUiRpgTowerRoleListMainPage.lua | 80 + .../XUiRpgTowerTeamList.lua | 72 + .../XUiRpgTowerTeamListItem.lua | 39 + .../SkillDetails/XUiRpgTowerSkillDetails.lua | 27 + .../TalentDetails/XUiRpgTowerNature.lua | 88 + .../TalentTotalView/XUiRpgTowerCollect.lua | 44 + .../XUiRpgTowerCollectPanelSkillInfo.lua | 45 + .../XUiRpgTowerCollectPanelStatus.lua | 19 + .../XUiRpgTowerCollectPanelTalent.lua | 27 + .../XUiRpgTowerCollectTalentGrid.lua | 13 + .../CharacterPage/XUiRpgTowerRoleList.lua | 227 + .../Common/XUiRpgTowerCharaItem.lua | 55 + .../Common/XUiRpgTowerItemIcon.lua | 24 + .../XUiRpgTower/Common/XUiRpgTowerLevelUp.lua | 37 + .../Common/XUiRpgTowerSettleWinExpBar.lua | 108 + .../Common/XUiRpgTowerStarPanel.lua | 22 + .../XUiRpgTower/Common/XUiRpgTowerTeamBar.lua | 145 + .../PanelMonsters/XUiRpgTowerMonsterGrid.lua | 69 + .../XUiRpgTowerMonstersPanel.lua | 49 + .../PanelRole/XUiRpgTowerRolePanel.lua | 38 + .../XUiRpgTowerStageBuffIcon.lua | 26 + .../XUiRpgTowerStageBuffPanel.lua | 49 + .../XUiRpgTowerStageDetails.lua | 67 + .../XUiRpgTowerStageRewardsPanel.lua | 44 + .../PanelStageList/XUiRpgTowerStageGrid.lua | 76 + .../PanelStageList/XUiRpgTowerStageList.lua | 71 + .../XUiRpgTower/MainPage/XUiRpgTowerMain.lua | 247 + .../XUi/XUiRpgTower/Task/XUiRpgTowerTask.lua | 135 + .../XUiRpgTower/Task/XUiRpgTowerTaskList.lua | 47 + .../XUi/XUiSet/ChildItem/XUiBtnKeyItem.lua | 75 + .../Scripts/XUi/XUiSet/XUiCombatTask.lua | 71 + .../Scripts/XUi/XUiSet/XUiInstruction.lua | 67 + .../XUi/XUiSet/XUiInstructionMonster.lua | 163 + .../Scripts/XUi/XUiSet/XUiPanelAccountSet.lua | 158 + .../Scripts/XUi/XUiSet/XUiPanelFightSet.lua | 405 + .../Scripts/XUi/XUiSet/XUiPanelFightSetPc.lua | 93 + .../XUi/XUiSet/XUiPanelGraphicsSet.lua | 739 ++ .../XUi/XUiSet/XUiPanelGraphicsSetPc.lua | 143 + .../Scripts/XUi/XUiSet/XUiPanelOtherSet.lua | 283 + .../Scripts/XUi/XUiSet/XUiPanelOtherSetPc.lua | 80 + .../Scripts/XUi/XUiSet/XUiPanelPushSet.lua | 112 + .../Scripts/XUi/XUiSet/XUiPanelVoiceSet.lua | 251 + Resources/Scripts/XUi/XUiSet/XUiSet.lua | 443 + .../XUi/XUiSettleLose/XUiGridLoseTip.lua | 67 + .../XUi/XUiSettleLose/XUiSettleLose.lua | 151 + .../XUiSettleUrgentEvent.lua | 41 + .../XUi/XUiSettleWin/XUiGridWinRole.lua | 105 + .../XUiSettleWin/XUiPanelSettleWinPokemon.lua | 76 + .../Scripts/XUi/XUiSettleWin/XUiSettleWin.lua | 461 + .../XUi/XUiSettleWinMainLine/XUiGridCond.lua | 46 + .../XUiSettleWinMainLine/XUiPanelExpBar.lua | 112 + .../XUiSettleWinMainLine.lua | 450 + .../XUiSettleWinSingleBoss.lua | 154 + .../XUi/XUiShop/XUiGridFashionShop.lua | 457 + Resources/Scripts/XUi/XUiShop/XUiGridShop.lua | 417 + .../XUi/XUiShop/XUiPanelActivityAsset.lua | 122 + .../XUi/XUiShop/XUiPanelFashionList.lua | 101 + .../Scripts/XUi/XUiShop/XUiPanelItemList.lua | 99 + .../Scripts/XUi/XUiShop/XUiPanelShopItem.lua | 553 + .../XUi/XUiShop/XUiPanelShopPeriod.lua | 182 + Resources/Scripts/XUi/XUiShop/XUiShop.lua | 367 + Resources/Scripts/XUi/XUiShop/XUiShopItem.lua | 463 + .../Scripts/XUi/XUiSignIn/XUiDiviningLog.lua | 127 + .../XUi/XUiSignIn/XUiNewYearSignIn.lua | 115 + Resources/Scripts/XUi/XUiSignIn/XUiSign.lua | 161 + .../Scripts/XUi/XUiSignIn/XUiSignBanner.lua | 90 + .../Scripts/XUi/XUiSignIn/XUiSignCard.lua | 118 + .../XUi/XUiSignIn/XUiSignEnKrNewyear.lua | 12 + .../XUi/XUiSignIn/XUiSignFirstRecharge.lua | 136 + .../Scripts/XUi/XUiSignIn/XUiSignGridDay.lua | 219 + .../XUiSignIn/XUiSignNewYearDrawActivity.lua | 36 + .../Scripts/XUi/XUiSignIn/XUiSignPrefab.lua | 250 + .../XUi/XUiSignIn/XUiSignPrefabContent.lua | 74 + Resources/Scripts/XUi/XUiSkip/XUiSkip.lua | 111 + .../AddContactModel/XUiGridAddContactItem.lua | 142 + .../XUiPanelAddContactView.lua | 184 + .../XUiPanelAddContactViewPools.lua | 56 + .../XUi/XUiSocial/Black/XUiBlackGrid.lua | 136 + .../XUi/XUiSocial/Black/XUiPanelBlackView.lua | 126 + .../ContactModel/XUiGridContactItem.lua | 236 + .../ContactModel/XUiPanelContactView.lua | 330 + .../XUi/XUiSocial/PanelTips/XUiPanelTips.lua | 115 + .../XUi/XUiSocial/PanelTips/XUiTipContent.lua | 45 + .../ItemModel/XUiGridTishi.lua | 89 + .../ItemModel/XUiTogFriendBox.lua | 67 + .../XUiPanelSocialMyMsgEmojiItem.lua | 83 + .../XUiPanelSocialMyMsgGiftItem.lua | 128 + .../NewItemModel/XUiPanelSocialMyMsgItem.lua | 110 + .../NewItemModel/XUiPanelSocialTipsItem.lua | 18 + .../Pools/XUiPanelGroupPools.lua | 57 + .../Pools/XUiPanelSocialPools.lua | 67 + .../XUiPanelPrivateChatView.lua | 321 + .../WaitPassModel/XUiGridWaitPassItem.lua | 133 + .../WaitPassModel/XUiPanelWaitForPassView.lua | 134 + .../Scripts/XUi/XUiSocial/XUiPanelDaily.lua | 92 + Resources/Scripts/XUi/XUiSocial/XUiSocial.lua | 239 + .../Scripts/XUi/XUiSocial/XUiSocialRename.lua | 50 + .../XUiSpecialFashionShop/XUiCommodity.lua | 370 + .../XUiGridCommodityLine.lua | 75 + .../XUiSpecialFashionShop.lua | 178 + .../XUiGridSpringFestivalBagItem.lua | 53 + .../XUiGridSpringFestivalCollectCard.lua | 197 + .../XUiGridSpringFestivalFriend.lua | 60 + .../XUiGridSpringFestivalGiveFriend.lua | 62 + .../XUiGridSpringFestivalGiveItem.lua | 58 + .../XUiGridSpringFestivalRequestItem.lua | 49 + .../CollectCard/XUiSpringFestivalBagTips.lua | 65 + .../XUiSpringFestivalCollectCard.lua | 172 + .../XUiSpringFestivalFriendsTip.lua | 46 + .../CollectCard/XUiSpringFestivalGiveTips.lua | 55 + .../XUiSpringFestivalHelpTips1.lua | 84 + .../XUiSpringFestivalHelpTips2.lua | 122 + .../CollectCard/XUiSpringFestivalTip.lua | 61 + .../XUiGridSpringFestivalBuffEffectItem.lua | 18 + .../XUiGridSpringFestivalSmashEggsReward.lua | 74 + .../SmashEggs/XUiSpringFestivalSmashEggs.lua | 589 + .../XUiFubenSpringFestivalChapter.lua | 112 + .../XUiFubenSpringFestivalStageDetail.lua | 138 + .../XUiPanelFubenSpringFestivalStage.lua | 190 + .../XUiSpringFestivalStageItem.lua | 69 + .../XUiStorySpringFestivalStageDetail.lua | 59 + .../XUiStoryStageDetail.lua | 62 + .../XUiGridQuickDeployMember.lua | 83 + .../XUiStronghold/XUiGridQuickDeployTeam.lua | 121 + .../XUi/XUiStronghold/XUiGridRewardLine.lua | 45 + .../XUiGridStrongHoldTeamMember.lua | 80 + .../XUiStronghold/XUiGridStrongholdBanner.lua | 31 + .../XUiStronghold/XUiGridStrongholdBuff.lua | 81 + .../XUiGridStrongholdCharacter.lua | 270 + .../XUiStronghold/XUiGridStrongholdGroup.lua | 107 + .../XUiStronghold/XUiGridStrongholdPlugin.lua | 32 + .../XUiGridStrongholdPluginSet.lua | 110 + .../XUiStronghold/XUiGridStrongholdTeam.lua | 195 + .../XUiStronghold/XUiGridTeamCharacter.lua | 106 + .../XUiPanelStrongholdChapter.lua | 168 + .../XUiPanelStrongholdRoomCharacterOthers.lua | 407 + .../XUiPanelStrongholdRoomCharacterSelf.lua | 464 + .../XUiStrongholdActivityResult.lua | 31 + .../XUiStronghold/XUiStrongholdAnimation.lua | 105 + .../XUiStrongholdChooseLevelType.lua | 49 + .../XUiStronghold/XUiStrongholdCoreTips.lua | 145 + .../XUi/XUiStronghold/XUiStrongholdDeploy.lua | 233 + .../XUi/XUiStronghold/XUiStrongholdDetail.lua | 193 + .../XUiStronghold/XUiStrongholdFightMain.lua | 141 + .../XUiStrongholdFightSettleWin.lua | 120 + .../XUi/XUiStronghold/XUiStrongholdHelp.lua | 105 + .../XUi/XUiStronghold/XUiStrongholdInfo.lua | 35 + .../XUiStrongholdJournal/XUiGridRecord.lua | 51 + .../XUiStrongholdJournal.lua | 72 + .../XUi/XUiStronghold/XUiStrongholdMain.lua | 560 + .../XUiStrongholdMainLineBanner.lua | 110 + .../XUiStronghold/XUiStrongholdMinerUp.lua | 54 + .../XUi/XUiStronghold/XUiStrongholdMining.lua | 90 + .../XUi/XUiStronghold/XUiStrongholdPower.lua | 196 + .../XUiStrongholdPowerExpectTips.lua | 47 + .../XUiStrongholdPowerExpectTipsGrid.lua | 28 + .../XUiStrongholdQuickDeploy.lua | 152 + .../XUiStrongholdReward/XUiGridRewardTip.lua | 103 + .../XUiStrongholdRewardTip.lua | 64 + .../XUiStrongholdRoomCharacter.lua | 218 + .../XUiStrongholdRune/XUiGridSubRune.lua | 34 + .../XUiStrongholdRune/XUiStrongholdRune.lua | 161 + .../XUiStrongholdSkillDetails.lua | 72 + .../XUiStrongholdSkillDetailsDialog.lua | 72 + .../XUiStrongholdSupportTips.lua | 82 + .../XUiGridSummerEpisodeSettleDataItem.lua | 15 + .../Settle/XUiGridSummerEpisodeSettleItem.lua | 99 + .../Settle/XUiSummerEpisodeSettle.lua | 105 + .../XUi/XUiSummerEpisode/XUiGridEliminate.lua | 118 + .../XUiSummerEpisode/XUiGridEliminateIcon.lua | 30 + .../XUiSummerEpisode/XUiGridMatchReward.lua | 48 + .../XUiGridNewSpecialReward.lua | 81 + .../XUiGridStageSpecialTrain.lua | 50 + .../XUiSummerEpisode/XUiGridStarReward.lua | 101 + .../XUiGridSummerEpisodeMap.lua | 30 + .../XUiGridSummerEpisodePicture.lua | 14 + .../XUiSummerEpisode/XUiGridSummerRank.lua | 100 + .../XUi/XUiSummerEpisode/XUiSummerEpisode.lua | 535 + .../XUiSummerEpisodeChapter.lua | 161 + .../XUiSummerEpisode/XUiSummerEpisodeMap.lua | 60 + .../XUiSummerEpisode/XUiSummerEpisodeNew.lua | 193 + .../XUiSummerEpisode/XUiSummerGridTask.lua | 198 + .../XUi/XUiSummerEpisode/XUiSummerMatch.lua | 566 + .../XUiSummerOnlineSection.lua | 190 + .../XUi/XUiSummerEpisode/XUiSummerRank.lua | 105 + .../XUiSummerEpisode/XUiSummerStageDetail.lua | 309 + .../XUiSummerEpisode/XUiSummerStarReward.lua | 57 + .../XUiSummerEpisode/XUiSummerTaskReward.lua | 133 + .../XUi/XUiSuperTower/Bag/XUiSTBagButton.lua | 19 + .../Bag/XUiSTBagCapacityPanel.lua | 24 + .../Bag/XUiSTBagCapacityUpgrade.lua | 32 + .../Bag/XUiSTBagDecomposionBtnPanel.lua | 20 + .../Bag/XUiSTBagDecomposionGrid.lua | 34 + .../Bag/XUiSTBagDecomposionPanel.lua | 134 + .../Bag/XUiSTBagIllusBookGrid.lua | 18 + .../Bag/XUiSTBagIllusFilterButton.lua | 29 + .../Bag/XUiSTBagIllustratedBookPanel.lua | 101 + .../Bag/XUiSTBagLineGraphPanel.lua | 38 + .../XUiSuperTower/Bag/XUiSTBagPluginsGrid.lua | 33 + .../Bag/XUiSTBagPluginsPanel.lua | 155 + .../Bag/XUiSTBagShopBtnPanel.lua | 20 + .../Bag/XUiSTBagToggleButton.lua | 29 + .../XUiSuperTower/Bag/XUiSTBagTogglePanel.lua | 38 + .../XUiSuperTower/Bag/XUiSuperTowerBag.lua | 203 + .../XUiSuperTower/Common/XUiSTChildPanel.lua | 86 + .../Common/XUiSTFunctionButton.lua | 124 + .../XUiSuperTower/Common/XUiSTMainPage.lua | 87 + .../Function/XUiSTFunctionIcon.lua | 28 + .../Function/XUiSTFunctionUnlock.lua | 40 + .../XUiSuperTower/Map/XUiGrid3DMapStage.lua | 119 + .../XUiSuperTower/Map/XUiGrid3DMapTheme.lua | 66 + .../XUiSuperTower/Map/XUiGridStageReward.lua | 41 + .../XUi/XUiSuperTower/Map/XUiPanel3DMap.lua | 114 + .../Map/XUiPanel3DMapChapter.lua | 151 + .../XUiSuperTower/Map/XUiPanelStageSelect.lua | 122 + .../XUiSuperTower/Map/XUiPanelThemeSelect.lua | 27 + .../XUiSuperTower/Map/XUiSuperTowerMain.lua | 290 + .../Map/XUiSuperTowerMultiStageDetail.lua | 114 + .../Map/XUiSuperTowerSingleStageDetail.lua | 101 + .../Plugins/XUiSTPluginDetailsRoleHead.lua | 33 + .../Plugins/XUiSTPluginLevelUp.lua | 52 + .../Plugins/XUiStCpPluginListPanel.lua | 222 + .../Plugins/XUiStCpPluginSlotPanel.lua | 71 + .../Plugins/XUiStCpRolePanel.lua | 27 + .../XUiSuperTower/Plugins/XUiStCpSlotGrid.lua | 67 + .../Plugins/XUiSuperTowerChoosePlugin.lua | 113 + .../Plugins/XUiSuperTowerEnhanceDetails.lua | 100 + .../Plugins/XUiSuperTowerEnhanceGrid.lua | 43 + .../Plugins/XUiSuperTowerMixGrid.lua | 91 + .../Plugins/XUiSuperTowerPluginDetails.lua | 140 + .../Plugins/XUiSuperTowerPluginGrid.lua | 131 + .../Role/XUiRoleLevelUpPanel.lua | 262 + .../Role/XUiSuperTowerRoleDetail.lua | 410 + .../Role/XUiSuperTowerRoleGrid.lua | 53 + .../Role/XUiSuperTowerRoleLevelUpPanel.lua | 263 + .../Role/XUiSuperTowerRolePluginUnlockTip.lua | 19 + .../Role/XUiSuperTowerTedianUP.lua | 72 + .../Role/XUiSupertowerExpansion.lua | 33 + .../Room/XUiSuperTowerBattleRoleRoom.lua | 78 + .../XUiSuperTowerBattleRoomChildPanel.lua | 90 + .../Room/XUiSuperTowerBattleRoomExpand.lua | 101 + .../XUiSuperTowerBattleRoomRoleDetail.lua | 208 + .../Shop/XUiGridSuperTowerShopItem.lua | 36 + .../XUiSuperTower/Shop/XUiSuperTowerShop.lua | 197 + .../Shop/XUiSuperTowerShopItem.lua | 111 + .../Target/XUiGridSTQuickDeployMember.lua | 68 + .../Target/XUiGridSTQuickDeployTeam.lua | 114 + .../Stages/Target/XUiGridSettleReward.lua | 70 + .../Stages/Target/XUiGridTargetStageTeam.lua | 144 + .../Target/XUiGridTargetStageTeamMember.lua | 73 + .../Stages/Target/XUiSuperTowerDeploy.lua | 146 + .../Stages/Target/XUiSuperTowerLoading.lua | 57 + .../Target/XUiSuperTowerQuickDeploy.lua | 184 + .../Stages/Target/XUiSuperTowerSettleWin.lua | 173 + .../Stages/Tier/XUiSTTierPrepare.lua | 126 + .../Stages/Tier/XUiStTdDynamicTablePanel.lua | 91 + .../Stages/Tier/XUiStTdInfoPanel.lua | 26 + .../Stages/Tier/XUiStTdTabPanel.lua | 43 + .../Stages/Tier/XUiStTdTitlePanel.lua | 24 + .../Stages/Tier/XUiStTierDrop.lua | 66 + .../Stages/Tier/XUiStTierGiveUp.lua | 79 + .../Stages/Tier/XUiStTierSettle.lua | 63 + .../Stages/Tier/XUiStTpDropGrid.lua | 13 + .../Stages/Tier/XUiStTpEnhancePanel.lua | 65 + .../Stages/Tier/XUiStTpMemberGrid.lua | 60 + .../Stages/Tier/XUiStTpPluginsPanel.lua | 124 + .../Stages/Tier/XUiStTpProgressPanel.lua | 11 + .../Stages/Tier/XUiStTpScorePanel.lua | 11 + .../Stages/Tier/XUiStTpTeamPanel.lua | 42 + .../Stages/Tier/XUiStTsEnhanceInfoPanel.lua | 31 + .../Stages/Tier/XUiStTsFloorPanel.lua | 15 + .../Stages/Tier/XUiStTsPluginInfoPanel.lua | 57 + .../Stages/Tier/XUiStTsRoleInfoPanel.lua | 49 + .../Stages/Tier/XUiStTsScoreItem.lua | 30 + .../Stages/Tier/XUiStTsScorePanel.lua | 92 + .../Scripts/XUi/XUiTRPG/UiTRPGMapTips.lua | 150 + .../Scripts/XUi/XUiTRPG/XUiGridTRPGBuff.lua | 31 + .../Scripts/XUi/XUiTRPG/XUiGridTRPGCard.lua | 105 + .../XUi/XUiTRPG/XUiGridTRPGCardRecord.lua | 22 + .../Scripts/XUi/XUiTRPG/XUiGridTRPGItem.lua | 95 + .../XUi/XUiTRPG/XUiGridTRPGMapCardMini.lua | 33 + .../XUi/XUiTRPG/XUiGridTRPGMapNode.lua | 46 + .../Scripts/XUi/XUiTRPG/XUiGridTRPGRole.lua | 34 + .../XUi/XUiTRPG/XUiGridTRPGRoleDetail.lua | 94 + .../XUi/XUiTRPG/XUiGridTRPGRoleTalent.lua | 45 + .../XUi/XUiTRPG/XUiGridTRPGTestAction.lua | 61 + .../XUi/XUiTRPG/XUiGridTRPGTestItem.lua | 62 + .../XUi/XUiTRPG/XUiGridTRPGTestRole.lua | 148 + .../XUi/XUiTRPG/XUiTRPGBag/XUiTRPGBag.lua | 100 + .../XUi/XUiTRPG/XUiTRPGBag/XUiTRPGBagGrid.lua | 16 + .../XUiTRPGBag/XUiTRPGItemUsePanel.lua | 165 + .../Scripts/XUi/XUiTRPG/XUiTRPGBuffDetail.lua | 32 + .../Scripts/XUi/XUiTRPG/XUiTRPGCollection.lua | 120 + .../Scripts/XUi/XUiTRPG/XUiTRPGCommitItem.lua | 40 + .../Scripts/XUi/XUiTRPG/XUiTRPGDialog.lua | 37 + .../XUi/XUiTRPG/XUiTRPGExploreChapter.lua | 109 + .../XUiTRPG/XUiTRPGExploreChapterStage.lua | 150 + .../XUiTRPGExploreRegion.lua | 145 + .../XUiTRPGExploreRegionChapter.lua | 80 + .../XUiTRPGExploreShop/XUiTRPGExploreShop.lua | 95 + .../XUiTRPGExploreShopRewardGrid.lua | 44 + .../XUiTRPGExploreShop/XUiTRPGShopItem.lua | 100 + .../Scripts/XUi/XUiTRPG/XUiTRPGFightTips.lua | 140 + Resources/Scripts/XUi/XUiTRPG/XUiTRPGMain.lua | 223 + .../XUi/XUiTRPG/XUiTRPGMainLineTreasure.lua | 34 + Resources/Scripts/XUi/XUiTRPG/XUiTRPGMaze.lua | 481 + .../XUi/XUiTRPG/XUiTRPGNewCharacter.lua | 48 + .../Scripts/XUi/XUiTRPG/XUiTRPGObtain.lua | 49 + .../XUiTRPGPanel/XUiTRPGPanelLevel.lua | 95 + .../XUiTRPGPanel/XUiTRPGPanelPlotTab.lua | 134 + .../XUiTRPG/XUiTRPGPanel/XUiTRPGPanelTask.lua | 329 + .../XUiTRPGRewardTip/XUiTRPGRewardGrid.lua | 115 + .../XUiTRPGRewardTip/XUiTRPGRewardTip.lua | 40 + .../XUiTRPGSecondMain/XUiTRPGSecondMain.lua | 86 + .../XUiTRPGTruthRoadSecondMain.lua | 178 + .../XUiTRPGTruthRoadSecondMainStage.lua | 44 + .../XUiTRPGTruthRoadSecondMainStages.lua | 157 + .../Scripts/XUi/XUiTRPG/XUiTRPGTalenTree.lua | 264 + .../XUi/XUiTRPG/XUiTRPGTalentOverView.lua | 53 + .../Scripts/XUi/XUiTRPG/XUiTRPGTaskTip.lua | 159 + Resources/Scripts/XUi/XUiTRPG/XUiTRPGTest.lua | 471 + .../XUi/XUiTRPG/XUiTRPGTestDetailsTips.lua | 173 + .../XUiTRPGTruthRoad/XUiTRPGTruthRoadMain.lua | 301 + .../XUiTRPGTruthRoadStage.lua | 44 + .../XUiTRPGTruthRoadStages.lua | 160 + .../XUiTRPGGridBossReward.lua | 60 + .../XUiTRPGWorldBoss/XUiTRPGPanelDetail.lua | 78 + .../XUiTRPGWorldBoss/XUiTRPGPanelEnter.lua | 87 + .../XUiTRPGWorldBoss/XUiTRPGWinWorldBoss.lua | 110 + .../XUiTRPGWorldBossBossArea.lua | 134 + .../Scripts/XUi/XUiTRPG/XUiTRPGYingDi.lua | 308 + .../XUi/XUiTask/XDynamicActivityTask.lua | 130 + .../Scripts/XUi/XUiTask/XDynamicDailyTask.lua | 336 + .../Scripts/XUi/XUiTask/XDynamicGridTask.lua | 242 + .../Scripts/XUi/XUiTask/XTaskContainer.lua | 99 + .../Scripts/XUi/XUiTask/XUiGridCourse.lua | 161 + Resources/Scripts/XUi/XUiTask/XUiGridTask.lua | 261 + .../Scripts/XUi/XUiTask/XUiPanelActive.lua | 58 + .../Scripts/XUi/XUiTask/XUiPanelCourse.lua | 118 + .../XUi/XUiTask/XUiPanelCourseReward.lua | 45 + .../XUi/XUiTask/XUiPanelTaskActivity.lua | 42 + .../Scripts/XUi/XUiTask/XUiPanelTaskDaily.lua | 179 + .../Scripts/XUi/XUiTask/XUiPanelTaskStory.lua | 115 + .../XUi/XUiTask/XUiPanelTaskWeekly.lua | 46 + Resources/Scripts/XUi/XUiTask/XUiTask.lua | 279 + Resources/Scripts/XUi/XUiTest/XUiTest.lua | 67 + Resources/Scripts/XUi/XUiTip/XUiGridSkip.lua | 39 + Resources/Scripts/XUi/XUiTip/XUiTip.lua | 270 + .../Scripts/XUi/XUiTipReward/XUiTipReward.lua | 99 + .../XUi/XUiTrial/XUiGridTrialDesItem.lua | 49 + .../XUi/XUiTrial/XUiGridTrialTypeItem.lua | 55 + .../Scripts/XUi/XUiTrial/XUiPanelTrialGet.lua | 71 + .../XUi/XUiTrial/XUiPanelTrialGrid.lua | 154 + .../XUi/XUiTrial/XUiPanelTrialMain.lua | 235 + .../XUi/XUiTrial/XUiPanelTrialSelect.lua | 201 + .../XUi/XUiTrial/XUiPanelTrialTaskList.lua | 160 + .../XUi/XUiTrial/XUiPanelTrialTips.lua | 63 + .../XUi/XUiTrial/XUiPanelTrialType.lua | 121 + Resources/Scripts/XUi/XUiTrial/XUiTrial.lua | 234 + .../XUi/XUiUnlockShow/XUiUnlockShow.lua | 31 + .../Scripts/XUi/XUiVideo/XUiVideoPlayer.lua | 62 + .../XUi/XUiWaterMask/XUiSuperWaterMarks.lua | 19 + .../Scripts/XUi/XUiWaterMask/XUiWaterMask.lua | 10 + .../XUi/XUiWindowsInlay/XUiWindowsInlay.lua | 85 + .../XUi/XUiWorldBoss/XUiChatUiWorldBoss.lua | 65 + .../XUiWorldBoss/XUiGridAttributeChapter.lua | 113 + .../XUiWorldBoss/XUiGridAttributeStage.lua | 104 + .../XUi/XUiWorldBoss/XUiGridBossReward.lua | 54 + .../XUiWorldBoss/XUiGridBtnAttributeArea.lua | 50 + .../XUi/XUiWorldBoss/XUiGridBtnBossArea.lua | 69 + .../Scripts/XUi/XUiWorldBoss/XUiGridBuff.lua | 46 + .../XUi/XUiWorldBoss/XUiGridLevelSelect.lua | 36 + .../XUi/XUiWorldBoss/XUiGridReportMsgItem.lua | 48 + .../XUi/XUiWorldBoss/XUiGridTipsInfo.lua | 22 + .../XUiGridWorldBossAreaRankItem.lua | 31 + .../XUiWorldBoss/XUiGridWorldBossTeamList.lua | 35 + .../XUi/XUiWorldBoss/XUiPanelDetail.lua | 128 + .../XUi/XUiWorldBoss/XUiPanelEnter.lua | 112 + .../XUiWorldBoss/XUiSettleWinWorldBoss.lua | 97 + .../XUi/XUiWorldBoss/XUiWorldBossAreaRank.lua | 58 + .../XUiWorldBossAttributeArea.lua | 227 + .../XUi/XUiWorldBoss/XUiWorldBossBossArea.lua | 130 + .../XUi/XUiWorldBoss/XUiWorldBossDetail.lua | 285 + .../XUi/XUiWorldBoss/XUiWorldBossFashion.lua | 118 + .../XUiWorldBoss/XUiWorldBossLevelSelect.lua | 36 + .../XUi/XUiWorldBoss/XUiWorldBossMain.lua | 224 + .../XUi/XUiWorldBoss/XUiWorldBossTask.lua | 70 + .../XUi/XUiWorldBoss/XUiWorldBossTips.lua | 41 + 3127 files changed, 495695 insertions(+), 1 deletion(-) create mode 100644 Resources/Scripts/XBehavior/XLuaBehaviorAgent.lua create mode 100644 Resources/Scripts/XBehavior/XLuaBehaviorManager.lua create mode 100644 Resources/Scripts/XBehavior/XLuaBehaviorNode.lua create mode 100644 Resources/Scripts/XCommon/Fix.lua create mode 100644 Resources/Scripts/XCommon/Json.lua create mode 100644 Resources/Scripts/XCommon/XAnalyticsEvent.lua create mode 100644 Resources/Scripts/XCommon/XBindTools.lua create mode 100644 Resources/Scripts/XCommon/XCameraHelper.lua create mode 100644 Resources/Scripts/XCommon/XClass.lua create mode 100644 Resources/Scripts/XCommon/XCode.lua create mode 100644 Resources/Scripts/XCommon/XCountDown.lua create mode 100644 Resources/Scripts/XCommon/XDynamicList.lua create mode 100644 Resources/Scripts/XCommon/XEntityHelper.lua create mode 100644 Resources/Scripts/XCommon/XEventId.lua create mode 100644 Resources/Scripts/XCommon/XFightNetwork.lua create mode 100644 Resources/Scripts/XCommon/XGlobalFunc.lua create mode 100644 Resources/Scripts/XCommon/XGlobalVar.lua create mode 100644 Resources/Scripts/XCommon/XLog.lua create mode 100644 Resources/Scripts/XCommon/XLuaBehaviour.lua create mode 100644 Resources/Scripts/XCommon/XMath.lua create mode 100644 Resources/Scripts/XCommon/XNetwork.lua create mode 100644 Resources/Scripts/XCommon/XNpcAttribType.lua create mode 100644 Resources/Scripts/XCommon/XPerformance.lua create mode 100644 Resources/Scripts/XCommon/XPool.lua create mode 100644 Resources/Scripts/XCommon/XPrefs.lua create mode 100644 Resources/Scripts/XCommon/XQueue.lua create mode 100644 Resources/Scripts/XCommon/XRpc.lua create mode 100644 Resources/Scripts/XCommon/XRpcExceptionCode.lua create mode 100644 Resources/Scripts/XCommon/XSaveTool.lua create mode 100644 Resources/Scripts/XCommon/XScheduleManager.lua create mode 100644 Resources/Scripts/XCommon/XSignBoardPlayer.lua create mode 100644 Resources/Scripts/XCommon/XStack.lua create mode 100644 Resources/Scripts/XCommon/XString.lua create mode 100644 Resources/Scripts/XCommon/XTable.lua create mode 100644 Resources/Scripts/XCommon/XTime.lua create mode 100644 Resources/Scripts/XCommon/XTool.lua create mode 100644 Resources/Scripts/XCommon/XUiGravity.lua create mode 100644 Resources/Scripts/XCommon/XUiHelper.lua create mode 100644 Resources/Scripts/XConfig/XActivityBriefConfigs.lua create mode 100644 Resources/Scripts/XConfig/XActivityConfigs.lua create mode 100644 Resources/Scripts/XConfig/XAppConfigs.lua create mode 100644 Resources/Scripts/XConfig/XArchiveConfigs.lua create mode 100644 Resources/Scripts/XConfig/XArenaConfigs.lua create mode 100644 Resources/Scripts/XConfig/XArenaOnlineConfigs.lua create mode 100644 Resources/Scripts/XConfig/XArrangeConfigs.lua create mode 100644 Resources/Scripts/XConfig/XAssistConfig.lua create mode 100644 Resources/Scripts/XConfig/XAttribConfigs.lua create mode 100644 Resources/Scripts/XConfig/XAutoFightConfig.lua create mode 100644 Resources/Scripts/XConfig/XAutoWindowConfigs.lua create mode 100644 Resources/Scripts/XConfig/XBaseEquipConfigs.lua create mode 100644 Resources/Scripts/XConfig/XBfrtConfigs.lua create mode 100644 Resources/Scripts/XConfig/XBountyTaskConfigs.lua create mode 100644 Resources/Scripts/XConfig/XCharacterConfigs.lua create mode 100644 Resources/Scripts/XConfig/XCharacterUiEffectConfig.lua create mode 100644 Resources/Scripts/XConfig/XChatConfigs.lua create mode 100644 Resources/Scripts/XConfig/XChessPursuitConfig.lua create mode 100644 Resources/Scripts/XConfig/XChristmasTreeConfig.lua create mode 100644 Resources/Scripts/XConfig/XClickClearGameConfigs.lua create mode 100644 Resources/Scripts/XConfig/XCollectionWallConfigs.lua create mode 100644 Resources/Scripts/XConfig/XComeAcrossConfig.lua create mode 100644 Resources/Scripts/XConfig/XCommunicationConfig.lua create mode 100644 Resources/Scripts/XConfig/XComposeGameConfig.lua create mode 100644 Resources/Scripts/XConfig/XComposeMiniGameConfig.lua create mode 100644 Resources/Scripts/XConfig/XConfigCenter.lua create mode 100644 Resources/Scripts/XConfig/XCoupletGameConfigs.lua create mode 100644 Resources/Scripts/XConfig/XDailyDungeonConfigs.lua create mode 100644 Resources/Scripts/XConfig/XDisplayConfigs.lua create mode 100644 Resources/Scripts/XConfig/XDlcConfig.lua create mode 100644 Resources/Scripts/XConfig/XDormConfig.lua create mode 100644 Resources/Scripts/XConfig/XDrawConfigs.lua create mode 100644 Resources/Scripts/XConfig/XEliminateGameConfig.lua create mode 100644 Resources/Scripts/XConfig/XEquipConfig.lua create mode 100644 Resources/Scripts/XConfig/XExhibitionConfigs.lua create mode 100644 Resources/Scripts/XConfig/XExpeditionConfig.lua create mode 100644 Resources/Scripts/XConfig/XFashionConfigs.lua create mode 100644 Resources/Scripts/XConfig/XFashionStoryConfigs.lua create mode 100644 Resources/Scripts/XConfig/XFavorabilityConfigs.lua create mode 100644 Resources/Scripts/XConfig/XFestivalActivityConfig.lua create mode 100644 Resources/Scripts/XConfig/XFightWordsConfigs.lua create mode 100644 Resources/Scripts/XConfig/XFingerGuessingConfig.lua create mode 100644 Resources/Scripts/XConfig/XFubenActivityBossSingleConfigs.lua create mode 100644 Resources/Scripts/XConfig/XFubenActivityBranchConfigs.lua create mode 100644 Resources/Scripts/XConfig/XFubenActivityPuzzleConfigs.lua create mode 100644 Resources/Scripts/XConfig/XFubenAssignConfigs.lua create mode 100644 Resources/Scripts/XConfig/XFubenBabelTowerConfigs.lua create mode 100644 Resources/Scripts/XConfig/XFubenBossOnlineConfig.lua create mode 100644 Resources/Scripts/XConfig/XFubenBossSingleConfigs.lua create mode 100644 Resources/Scripts/XConfig/XFubenConfigs.lua create mode 100644 Resources/Scripts/XConfig/XFubenCoupleCombatConfig.lua create mode 100644 Resources/Scripts/XConfig/XFubenExperimentConfigs.lua create mode 100644 Resources/Scripts/XConfig/XFubenExploreConfigs.lua create mode 100644 Resources/Scripts/XConfig/XFubenExtraChapterConfigs.lua create mode 100644 Resources/Scripts/XConfig/XFubenHackConfig.lua create mode 100644 Resources/Scripts/XConfig/XFubenInfestorExploreConfigs.lua create mode 100644 Resources/Scripts/XConfig/XFubenMainLineConfigs.lua create mode 100644 Resources/Scripts/XConfig/XFubenNewCharConfig.lua create mode 100644 Resources/Scripts/XConfig/XFubenRepeatChallengeConfigs.lua create mode 100644 Resources/Scripts/XConfig/XFubenRogueLikeConfig.lua create mode 100644 Resources/Scripts/XConfig/XFubenSimulatedCombatConfig.lua create mode 100644 Resources/Scripts/XConfig/XFubenSpecialTrainConfig.lua create mode 100644 Resources/Scripts/XConfig/XFubenUnionKillConfigs.lua create mode 100644 Resources/Scripts/XConfig/XFubenUrgentEventConfig.lua create mode 100644 Resources/Scripts/XConfig/XFubenZhouMuConfigs.lua create mode 100644 Resources/Scripts/XConfig/XFunctionConfig.lua create mode 100644 Resources/Scripts/XConfig/XFurnitureConfigs.lua create mode 100644 Resources/Scripts/XConfig/XGachaConfigs.lua create mode 100644 Resources/Scripts/XConfig/XGuardCampConfig.lua create mode 100644 Resources/Scripts/XConfig/XGuideConfig.lua create mode 100644 Resources/Scripts/XConfig/XGuildBossConfig.lua create mode 100644 Resources/Scripts/XConfig/XGuildConfig.lua create mode 100644 Resources/Scripts/XConfig/XHeadPortraitConfigs.lua create mode 100644 Resources/Scripts/XConfig/XHelpCourseConfig.lua create mode 100644 Resources/Scripts/XConfig/XHostelConfigs.lua create mode 100644 Resources/Scripts/XConfig/XInvertCardGameConfig.lua create mode 100644 Resources/Scripts/XConfig/XItemConfigs.lua create mode 100644 Resources/Scripts/XConfig/XKillZoneConfigs.lua create mode 100644 Resources/Scripts/XConfig/XLoadingConfig.lua create mode 100644 Resources/Scripts/XConfig/XLottoConfigs.lua create mode 100644 Resources/Scripts/XConfig/XMailConfigs.lua create mode 100644 Resources/Scripts/XConfig/XMaintainerActionConfigs.lua create mode 100644 Resources/Scripts/XConfig/XMarketingActivityConfigs.lua create mode 100644 Resources/Scripts/XConfig/XMedalConfigs.lua create mode 100644 Resources/Scripts/XConfig/XMentorSystemConfigs.lua create mode 100644 Resources/Scripts/XConfig/XMineSweepingConfigs.lua create mode 100644 Resources/Scripts/XConfig/XMoeWarConfig.lua create mode 100644 Resources/Scripts/XConfig/XMovieAssembleConfig.lua create mode 100644 Resources/Scripts/XConfig/XMovieConfigs.lua create mode 100644 Resources/Scripts/XConfig/XMusicPlayerConfigs.lua create mode 100644 Resources/Scripts/XConfig/XNieRConfigs.lua create mode 100644 Resources/Scripts/XConfig/XPartnerConfigs.lua create mode 100644 Resources/Scripts/XConfig/XPartnerTeachingConfigs.lua create mode 100644 Resources/Scripts/XConfig/XPassportConfigs.lua create mode 100644 Resources/Scripts/XConfig/XPayConfigs.lua create mode 100644 Resources/Scripts/XConfig/XPhotographConfigs.lua create mode 100644 Resources/Scripts/XConfig/XPlatformShareConfigs.lua create mode 100644 Resources/Scripts/XConfig/XPlayerInfoConfigs.lua create mode 100644 Resources/Scripts/XConfig/XPokemonConfigs.lua create mode 100644 Resources/Scripts/XConfig/XPokerGuessingConfig.lua create mode 100644 Resources/Scripts/XConfig/XPracticeConfigs.lua create mode 100644 Resources/Scripts/XConfig/XPrequelConfigs.lua create mode 100644 Resources/Scripts/XConfig/XPurchaseConfigs.lua create mode 100644 Resources/Scripts/XConfig/XPuzzleActivityConfigs.lua create mode 100644 Resources/Scripts/XConfig/XRedEnvelopeConfigs.lua create mode 100644 Resources/Scripts/XConfig/XReformConfigs.lua create mode 100644 Resources/Scripts/XConfig/XRegressionConfigs.lua create mode 100644 Resources/Scripts/XConfig/XReportConfigs.lua create mode 100644 Resources/Scripts/XConfig/XRewardConfigs.lua create mode 100644 Resources/Scripts/XConfig/XRoomCharFilterTipsConfigs.lua create mode 100644 Resources/Scripts/XConfig/XRpgMakerGameConfigs.lua create mode 100644 Resources/Scripts/XConfig/XRpgTowerConfig.lua create mode 100644 Resources/Scripts/XConfig/XSceneModelConfigs.lua create mode 100644 Resources/Scripts/XConfig/XScratchTicketConfig.lua create mode 100644 Resources/Scripts/XConfig/XSetConfigs.lua create mode 100644 Resources/Scripts/XConfig/XShopConfigs.lua create mode 100644 Resources/Scripts/XConfig/XSignBoardConfigs.lua create mode 100644 Resources/Scripts/XConfig/XSignInConfigs.lua create mode 100644 Resources/Scripts/XConfig/XSpecialShopConfigs.lua create mode 100644 Resources/Scripts/XConfig/XSpringFestivalActivityConfigs.lua create mode 100644 Resources/Scripts/XConfig/XStrongholdConfigs.lua create mode 100644 Resources/Scripts/XConfig/XSuperTowerConfigs.lua create mode 100644 Resources/Scripts/XConfig/XTRPGConfigs.lua create mode 100644 Resources/Scripts/XConfig/XTaskConfig.lua create mode 100644 Resources/Scripts/XConfig/XTaskForceConfigs.lua create mode 100644 Resources/Scripts/XConfig/XTeamConfig.lua create mode 100644 Resources/Scripts/XConfig/XTrialConfigs.lua create mode 100644 Resources/Scripts/XConfig/XUiConfigs.lua create mode 100644 Resources/Scripts/XConfig/XUiFightButtonDefaultStyleConfig.lua create mode 100644 Resources/Scripts/XConfig/XUiPcConfig.lua create mode 100644 Resources/Scripts/XConfig/XVideoConfig.lua create mode 100644 Resources/Scripts/XConfig/XWeaponFashionConfigs.lua create mode 100644 Resources/Scripts/XConfig/XWhiteValentineConfig.lua create mode 100644 Resources/Scripts/XConfig/XWorldBossConfigs.lua create mode 100644 Resources/Scripts/XDebug/LuaDebug.lua create mode 100644 Resources/Scripts/XEntity/XArchive/XArchiveCGEntity.lua create mode 100644 Resources/Scripts/XEntity/XArchive/XArchiveCommunicationEntity.lua create mode 100644 Resources/Scripts/XEntity/XArchive/XArchiveMailEntity.lua create mode 100644 Resources/Scripts/XEntity/XArchive/XArchiveMonsterDetailEntity.lua create mode 100644 Resources/Scripts/XEntity/XArchive/XArchiveMonsterEntity.lua create mode 100644 Resources/Scripts/XEntity/XArchive/XArchiveNpcDetailEntity.lua create mode 100644 Resources/Scripts/XEntity/XArchive/XArchiveNpcEntity.lua create mode 100644 Resources/Scripts/XEntity/XArchive/XArchivePartnerEntity.lua create mode 100644 Resources/Scripts/XEntity/XArchive/XArchivePartnerSettingEntity.lua create mode 100644 Resources/Scripts/XEntity/XArchive/XArchiveStoryChapterEntity.lua create mode 100644 Resources/Scripts/XEntity/XArchive/XArchiveStoryDetailEntity.lua create mode 100644 Resources/Scripts/XEntity/XBabelTower/XBabelTowerStageData.lua create mode 100644 Resources/Scripts/XEntity/XBabelTower/XBabelTowerTeamData.lua create mode 100644 Resources/Scripts/XEntity/XCharacter/XCharacter.lua create mode 100644 Resources/Scripts/XEntity/XCharacter/XCharacterSkillGroup.lua create mode 100644 Resources/Scripts/XEntity/XCharacter/XCharacterViewModel.lua create mode 100644 Resources/Scripts/XEntity/XChat/XChatData.lua create mode 100644 Resources/Scripts/XEntity/XChat/XChatEmoji.lua create mode 100644 Resources/Scripts/XEntity/XClickClearGame/XClickClearGameRewardData.lua create mode 100644 Resources/Scripts/XEntity/XCollectionWall/XCollectionWall.lua create mode 100644 Resources/Scripts/XEntity/XDrawMianButton/XDrawGroupBtnBaseEntity.lua create mode 100644 Resources/Scripts/XEntity/XDrawMianButton/XDrawTabBtnEntity.lua create mode 100644 Resources/Scripts/XEntity/XDrawMianButton/XLottoDrawGroupBtnEntity.lua create mode 100644 Resources/Scripts/XEntity/XDrawMianButton/XNormalDrawGroupBtnEntity.lua create mode 100644 Resources/Scripts/XEntity/XEquip/XAwarenessViewModel.lua create mode 100644 Resources/Scripts/XEntity/XEquip/XEquip.lua create mode 100644 Resources/Scripts/XEntity/XEquip/XEquipModel.lua create mode 100644 Resources/Scripts/XEntity/XEquip/XEquipSuitPrefab.lua create mode 100644 Resources/Scripts/XEntity/XEquip/XEquipViewModel.lua create mode 100644 Resources/Scripts/XEntity/XEquip/XSkillInfoObj.lua create mode 100644 Resources/Scripts/XEntity/XEquip/XWeaponFashion.lua create mode 100644 Resources/Scripts/XEntity/XEquip/XWeaponViewModel.lua create mode 100644 Resources/Scripts/XEntity/XExpedition/XExpeditionActivity.lua create mode 100644 Resources/Scripts/XEntity/XExpedition/XExpeditionChapter.lua create mode 100644 Resources/Scripts/XEntity/XExpedition/XExpeditionCharacter.lua create mode 100644 Resources/Scripts/XEntity/XExpedition/XExpeditionCombo.lua create mode 100644 Resources/Scripts/XEntity/XExpedition/XExpeditionComboList.lua create mode 100644 Resources/Scripts/XEntity/XExpedition/XExpeditionRecruitMembers.lua create mode 100644 Resources/Scripts/XEntity/XExpedition/XExpeditionStage.lua create mode 100644 Resources/Scripts/XEntity/XExpedition/XExpeditionTeam.lua create mode 100644 Resources/Scripts/XEntity/XExpedition/XExpeditionTeamPos.lua create mode 100644 Resources/Scripts/XEntity/XFestival/XFestivalChapter.lua create mode 100644 Resources/Scripts/XEntity/XFestival/XFestivalStage.lua create mode 100644 Resources/Scripts/XEntity/XFriend.lua create mode 100644 Resources/Scripts/XEntity/XFunctional/XFunctionTime.lua create mode 100644 Resources/Scripts/XEntity/XGlobalDraw.lua create mode 100644 Resources/Scripts/XEntity/XGuardCamp/XCampNotifyData.lua create mode 100644 Resources/Scripts/XEntity/XGuardCamp/XGuardActivityNotifyData.lua create mode 100644 Resources/Scripts/XEntity/XGuardCamp/XGuardCampActivityInfo.lua create mode 100644 Resources/Scripts/XEntity/XGuild/XGuildData.lua create mode 100644 Resources/Scripts/XEntity/XGuild/XGuildMemberData.lua create mode 100644 Resources/Scripts/XEntity/XGuild/XGuildVistorData.lua create mode 100644 Resources/Scripts/XEntity/XHome/XHomeFurnitureData.lua create mode 100644 Resources/Scripts/XEntity/XHome/XHomeRoomData.lua create mode 100644 Resources/Scripts/XEntity/XInfestorExplore/XInfestorExploreCharacter.lua create mode 100644 Resources/Scripts/XEntity/XInfestorExplore/XInfestorExploreCore.lua create mode 100644 Resources/Scripts/XEntity/XInfestorExplore/XInfestorExploreMapNode.lua create mode 100644 Resources/Scripts/XEntity/XInfestorExplore/XInfestorExploreOutPostStory.lua create mode 100644 Resources/Scripts/XEntity/XInfestorExplore/XInfestorExplorePlayer.lua create mode 100644 Resources/Scripts/XEntity/XInfestorExplore/XInfestorExploreTeam.lua create mode 100644 Resources/Scripts/XEntity/XInvertCardGame/XInvertCardStage.lua create mode 100644 Resources/Scripts/XEntity/XItem/XCharacterExpTemplate.lua create mode 100644 Resources/Scripts/XEntity/XItem/XEquipExpTemplate.lua create mode 100644 Resources/Scripts/XEntity/XItem/XGiftTemplate.lua create mode 100644 Resources/Scripts/XEntity/XItem/XItem.lua create mode 100644 Resources/Scripts/XEntity/XItem/XItemTemplate.lua create mode 100644 Resources/Scripts/XEntity/XItem/XPartnerExpTemplate.lua create mode 100644 Resources/Scripts/XEntity/XItem/XRecItem.lua create mode 100644 Resources/Scripts/XEntity/XKillZone/XKillZonePlugin.lua create mode 100644 Resources/Scripts/XEntity/XKillZone/XKillZoneStage.lua create mode 100644 Resources/Scripts/XEntity/XLotto/XLottoDrawEntity.lua create mode 100644 Resources/Scripts/XEntity/XLotto/XLottoGroupEntity.lua create mode 100644 Resources/Scripts/XEntity/XLotto/XLottoRewardEntity.lua create mode 100644 Resources/Scripts/XEntity/XMaintainerAction/XBoxNodeEntity.lua create mode 100644 Resources/Scripts/XEntity/XMaintainerAction/XCardChangeNodeEntity.lua create mode 100644 Resources/Scripts/XEntity/XMaintainerAction/XDirectionChangeNodeEntity.lua create mode 100644 Resources/Scripts/XEntity/XMaintainerAction/XExploreNodeEntity.lua create mode 100644 Resources/Scripts/XEntity/XMaintainerAction/XExtraActionPointNodeEntity.lua create mode 100644 Resources/Scripts/XEntity/XMaintainerAction/XFallBackNodeEntity.lua create mode 100644 Resources/Scripts/XEntity/XMaintainerAction/XFightNodeEntity.lua create mode 100644 Resources/Scripts/XEntity/XMaintainerAction/XForwardNodeEntity.lua create mode 100644 Resources/Scripts/XEntity/XMaintainerAction/XMaintainerActionGameDataEntity.lua create mode 100644 Resources/Scripts/XEntity/XMaintainerAction/XMaintainerActionNodeEntity.lua create mode 100644 Resources/Scripts/XEntity/XMaintainerAction/XMaintainerActionPlayerEntity.lua create mode 100644 Resources/Scripts/XEntity/XMaintainerAction/XMentorNodeEntity.lua create mode 100644 Resources/Scripts/XEntity/XMaintainerAction/XNoneNodeEntity.lua create mode 100644 Resources/Scripts/XEntity/XMaintainerAction/XSimulationFightNodeEntity.lua create mode 100644 Resources/Scripts/XEntity/XMaintainerAction/XStartNodeEntity.lua create mode 100644 Resources/Scripts/XEntity/XMaintainerAction/XUnKnowNodeEntity.lua create mode 100644 Resources/Scripts/XEntity/XMaintainerAction/XWarehouseNodeEntity.lua create mode 100644 Resources/Scripts/XEntity/XMentorSystem/XMentorDataEntity.lua create mode 100644 Resources/Scripts/XEntity/XMineSweeping/XMineSweepingChapter.lua create mode 100644 Resources/Scripts/XEntity/XMineSweeping/XMineSweepingGame.lua create mode 100644 Resources/Scripts/XEntity/XMineSweeping/XMineSweepingGrid.lua create mode 100644 Resources/Scripts/XEntity/XMineSweeping/XMineSweepingStage.lua create mode 100644 Resources/Scripts/XEntity/XMiniGame/ComposeFactory/XComposeGame.lua create mode 100644 Resources/Scripts/XEntity/XMiniGame/ComposeFactory/XComposeGameItem.lua create mode 100644 Resources/Scripts/XEntity/XMiniGame/ComposeFactory/XComposeGameItemBag.lua create mode 100644 Resources/Scripts/XEntity/XMiniGame/ComposeFactory/XComposeGameItemGrid.lua create mode 100644 Resources/Scripts/XEntity/XMiniGame/ComposeFactory/XComposeGameProgressTreasure.lua create mode 100644 Resources/Scripts/XEntity/XMiniGame/ComposeFactory/XComposeGameShop.lua create mode 100644 Resources/Scripts/XEntity/XMiniGame/ComposeFactory/XComposeGameShopGrid.lua create mode 100644 Resources/Scripts/XEntity/XMiniGame/ComposeFactory/XComposeGameTreasureBox.lua create mode 100644 Resources/Scripts/XEntity/XMiniGame/FingerGuessing/XFingerGuessingGameController.lua create mode 100644 Resources/Scripts/XEntity/XMiniGame/FingerGuessing/XFingerGuessingStage.lua create mode 100644 Resources/Scripts/XEntity/XMiniGame/FingerGuessing/XFingerGuessingStageManager.lua create mode 100644 Resources/Scripts/XEntity/XMiniGame/WhiteValentine2021/XWhiteValentineChara.lua create mode 100644 Resources/Scripts/XEntity/XMiniGame/WhiteValentine2021/XWhiteValentineCharaManager.lua create mode 100644 Resources/Scripts/XEntity/XMiniGame/WhiteValentine2021/XWhiteValentineGame.lua create mode 100644 Resources/Scripts/XEntity/XMiniGame/WhiteValentine2021/XWhiteValentinePlace.lua create mode 100644 Resources/Scripts/XEntity/XMiniGame/WhiteValentine2021/XWhiteValentinePlaceManager.lua create mode 100644 Resources/Scripts/XEntity/XMoeWar/XMoeWarMatch.lua create mode 100644 Resources/Scripts/XEntity/XMoeWar/XMoeWarPlayer.lua create mode 100644 Resources/Scripts/XEntity/XMoeWar/XMoeWarPreparationAnswerRecord.lua create mode 100644 Resources/Scripts/XEntity/XMoeWar/XMoeWarPreparationAssistance.lua create mode 100644 Resources/Scripts/XEntity/XMoeWar/XMoeWarPreparationBaseData.lua create mode 100644 Resources/Scripts/XEntity/XMoeWar/XMoeWarPreparationHelper.lua create mode 100644 Resources/Scripts/XEntity/XMoeWar/XMoeWarPreparationQuestion.lua create mode 100644 Resources/Scripts/XEntity/XMoeWar/XMoeWarPreparationStage.lua create mode 100644 Resources/Scripts/XEntity/XMoeWar/XMoeWarPreparationVoteItem.lua create mode 100644 Resources/Scripts/XEntity/XMoeWar/XMoeWarVoteItem.lua create mode 100644 Resources/Scripts/XEntity/XNameplate/XNameplate.lua create mode 100644 Resources/Scripts/XEntity/XNieR/XNieRBoss.lua create mode 100644 Resources/Scripts/XEntity/XNieR/XNieRChapter.lua create mode 100644 Resources/Scripts/XEntity/XNieR/XNieRCharacter.lua create mode 100644 Resources/Scripts/XEntity/XNieR/XNieRRepeat.lua create mode 100644 Resources/Scripts/XEntity/XNieR/XNierPOD.lua create mode 100644 Resources/Scripts/XEntity/XPartner/XPartner.lua create mode 100644 Resources/Scripts/XEntity/XPartner/XPartnerBase.lua create mode 100644 Resources/Scripts/XEntity/XPartner/XPartnerMainSkillGroup.lua create mode 100644 Resources/Scripts/XEntity/XPartner/XPartnerPassiveSkillGroup.lua create mode 100644 Resources/Scripts/XEntity/XPartner/XPartnerSkillGroupBase.lua create mode 100644 Resources/Scripts/XEntity/XPartner/XPartnerStory.lua create mode 100644 Resources/Scripts/XEntity/XPassport/XPassportBaseInfo.lua create mode 100644 Resources/Scripts/XEntity/XPassport/XPassportInfo.lua create mode 100644 Resources/Scripts/XEntity/XPayAgent/XPayAgent.lua create mode 100644 Resources/Scripts/XEntity/XPayAgent/XPayHeroAgent.lua create mode 100644 Resources/Scripts/XEntity/XPlayer.lua create mode 100644 Resources/Scripts/XEntity/XPokemon/XPokemonMonster.lua create mode 100644 Resources/Scripts/XEntity/XPokemon/XPokemonMonsterSkill.lua create mode 100644 Resources/Scripts/XEntity/XPokemon/XPokemonMonsterSkillGroup.lua create mode 100644 Resources/Scripts/XEntity/XPokemon/XPokemonTeamPosData.lua create mode 100644 Resources/Scripts/XEntity/XPuzzleActivityData.lua create mode 100644 Resources/Scripts/XEntity/XReadOnlyTable.lua create mode 100644 Resources/Scripts/XEntity/XReform/Buff/XReformBuff.lua create mode 100644 Resources/Scripts/XEntity/XReform/Buff/XReformBuffGroup.lua create mode 100644 Resources/Scripts/XEntity/XReform/Enemy/XReformEnemyGroup.lua create mode 100644 Resources/Scripts/XEntity/XReform/Enemy/XReformEnemySource.lua create mode 100644 Resources/Scripts/XEntity/XReform/Enemy/XReformEnemyTarget.lua create mode 100644 Resources/Scripts/XEntity/XReform/Environment/XReformEnvironment.lua create mode 100644 Resources/Scripts/XEntity/XReform/Environment/XReformEnvironmentGroup.lua create mode 100644 Resources/Scripts/XEntity/XReform/Member/XReformMemberGroup.lua create mode 100644 Resources/Scripts/XEntity/XReform/Member/XReformMemberSource.lua create mode 100644 Resources/Scripts/XEntity/XReform/Member/XReformMemberTarget.lua create mode 100644 Resources/Scripts/XEntity/XReform/XReformBaseSourceGroup.lua create mode 100644 Resources/Scripts/XEntity/XReform/XReformBaseStage.lua create mode 100644 Resources/Scripts/XEntity/XReform/XReformEvolvableStage.lua create mode 100644 Resources/Scripts/XEntity/XRobot/XRobot.lua create mode 100644 Resources/Scripts/XEntity/XRpgMakerGame/Object/XRpgMakerGameBlock.lua create mode 100644 Resources/Scripts/XEntity/XRpgMakerGame/Object/XRpgMakerGameCube.lua create mode 100644 Resources/Scripts/XEntity/XRpgMakerGame/Object/XRpgMakerGameEndPoint.lua create mode 100644 Resources/Scripts/XEntity/XRpgMakerGame/Object/XRpgMakerGameGap.lua create mode 100644 Resources/Scripts/XEntity/XRpgMakerGame/Object/XRpgMakerGameMonsterData.lua create mode 100644 Resources/Scripts/XEntity/XRpgMakerGame/Object/XRpgMakerGameMonsterPatrolLine.lua create mode 100644 Resources/Scripts/XEntity/XRpgMakerGame/Object/XRpgMakerGameObject.lua create mode 100644 Resources/Scripts/XEntity/XRpgMakerGame/Object/XRpgMakerGamePlayer.lua create mode 100644 Resources/Scripts/XEntity/XRpgMakerGame/Object/XRpgMakerGameTriggerData.lua create mode 100644 Resources/Scripts/XEntity/XRpgMakerGame/XRpgMakerActivityStageDb.lua create mode 100644 Resources/Scripts/XEntity/XRpgMakerGame/XRpgMakerGameActivityDb.lua create mode 100644 Resources/Scripts/XEntity/XRpgMakerGame/XRpgMakerGameEnterStageDb.lua create mode 100644 Resources/Scripts/XEntity/XRpgMakerGame/XRpgMakerGamePosition.lua create mode 100644 Resources/Scripts/XEntity/XRpgTower/XRpgTowerChapter.lua create mode 100644 Resources/Scripts/XEntity/XRpgTower/XRpgTowerCharacter.lua create mode 100644 Resources/Scripts/XEntity/XRpgTower/XRpgTowerItem.lua create mode 100644 Resources/Scripts/XEntity/XRpgTower/XRpgTowerStage.lua create mode 100644 Resources/Scripts/XEntity/XRpgTower/XRpgTowerTalent.lua create mode 100644 Resources/Scripts/XEntity/XScratchTicket/XScratchTicketActivityController.lua create mode 100644 Resources/Scripts/XEntity/XScratchTicket/XScratchTicketStage.lua create mode 100644 Resources/Scripts/XEntity/XSpringFestival/XSpringFestivalBoxGift.lua create mode 100644 Resources/Scripts/XEntity/XSpringFestival/XSpringFestivalFriendRequestInfo.lua create mode 100644 Resources/Scripts/XEntity/XStronghold/XStrongholdAssistantRecord.lua create mode 100644 Resources/Scripts/XEntity/XStronghold/XStrongholdGroupInfo.lua create mode 100644 Resources/Scripts/XEntity/XStronghold/XStrongholdMineRecord.lua create mode 100644 Resources/Scripts/XEntity/XStronghold/XStrongholdPlugin.lua create mode 100644 Resources/Scripts/XEntity/XStronghold/XStrongholdStageData.lua create mode 100644 Resources/Scripts/XEntity/XStronghold/XStrongholdTeam.lua create mode 100644 Resources/Scripts/XEntity/XStronghold/XStrongholdTeamMember.lua create mode 100644 Resources/Scripts/XEntity/XSuperTower/Function/XSuperTowerFunction.lua create mode 100644 Resources/Scripts/XEntity/XSuperTower/Function/XSuperTowerFunctionManager.lua create mode 100644 Resources/Scripts/XEntity/XSuperTower/Plugin/XSuperTowerPlugin.lua create mode 100644 Resources/Scripts/XEntity/XSuperTower/Role/XSuperTowerRole.lua create mode 100644 Resources/Scripts/XEntity/XSuperTower/Role/XSuperTowerRoleManager.lua create mode 100644 Resources/Scripts/XEntity/XSuperTower/Shop/XSuperTowerShopManager.lua create mode 100644 Resources/Scripts/XEntity/XSuperTower/Stages/XSuperTowerStageManager.lua create mode 100644 Resources/Scripts/XEntity/XSuperTower/Stages/XSuperTowerTargetStage.lua create mode 100644 Resources/Scripts/XEntity/XSuperTower/Stages/XSuperTowerTheme.lua create mode 100644 Resources/Scripts/XEntity/XSuperTower/Stages/XSuperTowerTierManager.lua create mode 100644 Resources/Scripts/XEntity/XSuperTower/Stages/XSuperTowerTierStage.lua create mode 100644 Resources/Scripts/XEntity/XSuperTower/XCollectionManager.lua create mode 100644 Resources/Scripts/XEntity/XSuperTower/XSuperTowerBagManager.lua create mode 100644 Resources/Scripts/XEntity/XSuperTower/XSuperTowerPluginSlotManager.lua create mode 100644 Resources/Scripts/XEntity/XSuperTower/XSuperTowerTeamManager.lua create mode 100644 Resources/Scripts/XEntity/XTRPG/XTRPGBaseInfo.lua create mode 100644 Resources/Scripts/XEntity/XTRPG/XTRPGBossInfo.lua create mode 100644 Resources/Scripts/XEntity/XTRPG/XTRPGClientShopInfo.lua create mode 100644 Resources/Scripts/XEntity/XTRPG/XTRPGExamine.lua create mode 100644 Resources/Scripts/XEntity/XTRPG/XTRPGMaze.lua create mode 100644 Resources/Scripts/XEntity/XTRPG/XTRPGMazeCard.lua create mode 100644 Resources/Scripts/XEntity/XTRPG/XTRPGMazeLayer.lua create mode 100644 Resources/Scripts/XEntity/XTRPG/XTRPGMazeNode.lua create mode 100644 Resources/Scripts/XEntity/XTRPG/XTRPGRole.lua create mode 100644 Resources/Scripts/XEntity/XTRPG/XTRPGRoleAttribute.lua create mode 100644 Resources/Scripts/XEntity/XTRPG/XTRPGRoleTalent.lua create mode 100644 Resources/Scripts/XEntity/XTRPG/XTRPGShopInfo.lua create mode 100644 Resources/Scripts/XEntity/XTRPG/XTRPGShopItemInfo.lua create mode 100644 Resources/Scripts/XEntity/XTRPG/XTRPGThirdAreaInfo.lua create mode 100644 Resources/Scripts/XEntity/XTeam/XTeam.lua create mode 100644 Resources/Scripts/XEntity/XWorldBoss/XAttributeAreaEntity.lua create mode 100644 Resources/Scripts/XEntity/XWorldBoss/XAttributeStageEntity.lua create mode 100644 Resources/Scripts/XEntity/XWorldBoss/XBossAreaEntity.lua create mode 100644 Resources/Scripts/XEntity/XWorldBoss/XBuffEntity.lua create mode 100644 Resources/Scripts/XEntity/XWorldBoss/XPhasesRewardEntity.lua create mode 100644 Resources/Scripts/XEntity/XWorldBoss/XSpecialSaleEntity.lua create mode 100644 Resources/Scripts/XEntity/XWorldBoss/XWorldBossActivityEntity.lua create mode 100644 Resources/Scripts/XFormula/XArithmetic.lua create mode 100644 Resources/Scripts/XFormula/XConditionFormula.lua create mode 100644 Resources/Scripts/XFormula/XFormula.lua create mode 100644 Resources/Scripts/XGame.lua create mode 100644 Resources/Scripts/XGuide/Agent/XGuideAgent.lua create mode 100644 Resources/Scripts/XGuide/Node/XGuideCharacterEquipQualityCompareNode.lua create mode 100644 Resources/Scripts/XGuide/Node/XGuideCharacterEquipWithPosExistNode.lua create mode 100644 Resources/Scripts/XGuide/Node/XGuideDynamicIndexNode.lua create mode 100644 Resources/Scripts/XGuide/Node/XGuideEndNode.lua create mode 100644 Resources/Scripts/XGuide/Node/XGuideFocusOnPanelNode.lua create mode 100644 Resources/Scripts/XGuide/Node/XGuideFocusOnScrollRectNode.lua create mode 100644 Resources/Scripts/XGuide/Node/XGuideFocusSetActive.lua create mode 100644 Resources/Scripts/XGuide/Node/XGuideForceStepNode.lua create mode 100644 Resources/Scripts/XGuide/Node/XGuideFubenJumpToStageNode.lua create mode 100644 Resources/Scripts/XGuide/Node/XGuideHideDialogNode.lua create mode 100644 Resources/Scripts/XGuide/Node/XGuideIsAnyClickNode.lua create mode 100644 Resources/Scripts/XGuide/Node/XGuideIsCharacterInTeamNode.lua create mode 100644 Resources/Scripts/XGuide/Node/XGuideIsGameObjectActiveNode.lua create mode 100644 Resources/Scripts/XGuide/Node/XGuideIsJoinGuildNode.lua create mode 100644 Resources/Scripts/XGuide/Node/XGuideIsUiOpenNode.lua create mode 100644 Resources/Scripts/XGuide/Node/XGuideOpenDormitoryNode.lua create mode 100644 Resources/Scripts/XGuide/Node/XGuideRecordNode.lua create mode 100644 Resources/Scripts/XGuide/Node/XGuideShowDialogNode.lua create mode 100644 Resources/Scripts/XGuide/Node/XGuideShowMaskNode.lua create mode 100644 Resources/Scripts/XGuide/Node/XGuideStartNode.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeChar/XHomeBehaviorState.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharAgent.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharFSMFactory.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharBubbleNode.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharChangeStateMachineNode.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharCheckClick.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharCheckDisInteractFurnitureNode.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharCheckDisgustedNode.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharCheckEventExistNode.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharCheckFriendNode.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharCheckInteractNode.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharCheckPlayAnimationNode.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharCheckPointerUpNode.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharCheckRayCastFurnitureNode.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharCheckRelationNode.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharCompletedFondleNode.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharDialogNode.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharDoEffectNode.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharDoRoleActionOnlyNode.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharEventRewardNode.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharEventTypeCompareNode.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharFaceLockNode.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharFondleTypeJudgeNode.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharForwardToFurnitureNode.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharHideBubbleNode.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharHideEffectNode.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharInteractFunitureActionNode.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharInteractNode.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharInteractTypeCompareNode.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharJudgeAttributeNode.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharJudgeInteractPosNode.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharObstacleEnableNode.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharPathFindNode.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharRandomDialogNode.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharReachFurniture.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharSetCharInteractTriggerNode.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharSetInteractOffsetNode.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharSetStayOffsetNode.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharStateChangeNode.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharStateCompareNode.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeChar/XHomeFSM/XHomeCharFSM.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeChar/XHomeFSM/XHomeCharFSMControl.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeChar/XHomeFSM/XHomeCharFSMEmpty.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeChar/XHomeFSM/XHomeCharFSMIdle.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeChar/XHomeFSM/XHomeCharFSMInteract.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeChar/XHomeFSM/XHomeCharFSMMood.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeCharManager.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeCharObj.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeDormManager.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeFurniture/XHomeFurnitureAgent.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeFurniture/XHomeFurnitureNode/XHomeFurnitureChangeFurniturePositionNode.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeFurniture/XHomeFurnitureNode/XHomeFurnitureCheckPointerUpNode.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeFurniture/XHomeFurnitureNode/XHomeFurnitureCheckRayCastFunitureNode.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeFurniture/XHomeFurnitureNode/XHomeFurnitureDoActionOnlyNode.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeFurniture/XHomeFurnitureNode/XHomeFurnitureDoEffectNode.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeFurniture/XHomeFurnitureNode/XHomeFurnitureHideNode.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeFurniture/XHomeFurnitureNode/XHomeFurnitureResetFurniturePositionNode.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeFurniture/XHomeFurnitureNode/XHomeFurnitureSaveFurnitureInRoomNode.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeFurniture/XHomeFurnitureNode/XHomeFurnitureSaveSuccessNode.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeFurniture/XHomeFurnitureNode/XHomeFurnitureStateChangeNode.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeFurnitureObj.lua create mode 100644 Resources/Scripts/XHome/XDorm/XHomeRoomObj.lua create mode 100644 Resources/Scripts/XHome/XHomeScene.lua create mode 100644 Resources/Scripts/XHome/XHomeSceneManager.lua create mode 100644 Resources/Scripts/XHome/XInfrastructure/XDeviceObject.lua create mode 100644 Resources/Scripts/XHome/XInfrastructure/XHomeInfrastructureManager.lua create mode 100644 Resources/Scripts/XHome/XInfrastructure/XRoomObject.lua create mode 100644 Resources/Scripts/XHome/XSceneEntityManager.lua create mode 100644 Resources/Scripts/XHome/XSceneObject.lua create mode 100644 Resources/Scripts/XHome/XSceneResourceManager.lua create mode 100644 Resources/Scripts/XHotReload.lua create mode 100644 Resources/Scripts/XMain.lua create mode 100644 Resources/Scripts/XManager/XActivityBriefManager.lua create mode 100644 Resources/Scripts/XManager/XActivityManager.lua create mode 100644 Resources/Scripts/XManager/XAgreementManager.lua create mode 100644 Resources/Scripts/XManager/XAntiAddictionManager.lua create mode 100644 Resources/Scripts/XManager/XAppEventManager.lua create mode 100644 Resources/Scripts/XManager/XArchiveManager.lua create mode 100644 Resources/Scripts/XManager/XArenaManager.lua create mode 100644 Resources/Scripts/XManager/XArenaOnlineManager.lua create mode 100644 Resources/Scripts/XManager/XAssistManager.lua create mode 100644 Resources/Scripts/XManager/XAttribManager.lua create mode 100644 Resources/Scripts/XManager/XAutoFightManager.lua create mode 100644 Resources/Scripts/XManager/XAutoWindowManager.lua create mode 100644 Resources/Scripts/XManager/XBaseEquipManager.lua create mode 100644 Resources/Scripts/XManager/XBfrtManager.lua create mode 100644 Resources/Scripts/XManager/XBountyTaskManager.lua create mode 100644 Resources/Scripts/XManager/XCdKeyManager.lua create mode 100644 Resources/Scripts/XManager/XCharacterManager.lua create mode 100644 Resources/Scripts/XManager/XChatManager.lua create mode 100644 Resources/Scripts/XManager/XChessPursuitManager.lua create mode 100644 Resources/Scripts/XManager/XChristmasTreeManager.lua create mode 100644 Resources/Scripts/XManager/XClickClearGameManager.lua create mode 100644 Resources/Scripts/XManager/XCollectionWallManager.lua create mode 100644 Resources/Scripts/XManager/XComeAcrossManager.lua create mode 100644 Resources/Scripts/XManager/XComposeGameManager.lua create mode 100644 Resources/Scripts/XManager/XConditionManager.lua create mode 100644 Resources/Scripts/XManager/XCoupletGameManager.lua create mode 100644 Resources/Scripts/XManager/XDataCenter.lua create mode 100644 Resources/Scripts/XManager/XDisplayManager.lua create mode 100644 Resources/Scripts/XManager/XDormManager.lua create mode 100644 Resources/Scripts/XManager/XDrawManager.lua create mode 100644 Resources/Scripts/XManager/XEliminateGameManager.lua create mode 100644 Resources/Scripts/XManager/XEquipManager.lua create mode 100644 Resources/Scripts/XManager/XEventManager.lua create mode 100644 Resources/Scripts/XManager/XExhibitionManager.lua create mode 100644 Resources/Scripts/XManager/XExpeditionManager.lua create mode 100644 Resources/Scripts/XManager/XFashionManager.lua create mode 100644 Resources/Scripts/XManager/XFashionStoryManager.lua create mode 100644 Resources/Scripts/XManager/XFavorabilityManager.lua create mode 100644 Resources/Scripts/XManager/XFightCharacterManager.lua create mode 100644 Resources/Scripts/XManager/XFightEquipManager.lua create mode 100644 Resources/Scripts/XManager/XFightInfestorExploreManager.lua create mode 100644 Resources/Scripts/XManager/XFightPartnerManager.lua create mode 100644 Resources/Scripts/XManager/XFightUiManager.lua create mode 100644 Resources/Scripts/XManager/XFightWordsManager.lua create mode 100644 Resources/Scripts/XManager/XFingerGuessingManager.lua create mode 100644 Resources/Scripts/XManager/XFuBenActivityPuzzleManager.lua create mode 100644 Resources/Scripts/XManager/XFubenActivityBossSingleManager.lua create mode 100644 Resources/Scripts/XManager/XFubenActivityBranchManager.lua create mode 100644 Resources/Scripts/XManager/XFubenAssignManager.lua create mode 100644 Resources/Scripts/XManager/XFubenBabelTowerManager.lua create mode 100644 Resources/Scripts/XManager/XFubenBossOnlineManager.lua create mode 100644 Resources/Scripts/XManager/XFubenBossSingleManager.lua create mode 100644 Resources/Scripts/XManager/XFubenCoupleCombatManager.lua create mode 100644 Resources/Scripts/XManager/XFubenDailyManager.lua create mode 100644 Resources/Scripts/XManager/XFubenExperimentManager.lua create mode 100644 Resources/Scripts/XManager/XFubenExploreManager.lua create mode 100644 Resources/Scripts/XManager/XFubenExtraChapterManager.lua create mode 100644 Resources/Scripts/XManager/XFubenFestivalActivityManager.lua create mode 100644 Resources/Scripts/XManager/XFubenHackManager.lua create mode 100644 Resources/Scripts/XManager/XFubenInfestorExploreManager.lua create mode 100644 Resources/Scripts/XManager/XFubenMainLineManager.lua create mode 100644 Resources/Scripts/XManager/XFubenManager.lua create mode 100644 Resources/Scripts/XManager/XFubenNewCharActivityManager.lua create mode 100644 Resources/Scripts/XManager/XFubenRepeatChallengeManager.lua create mode 100644 Resources/Scripts/XManager/XFubenResourceManager.lua create mode 100644 Resources/Scripts/XManager/XFubenRogueLikeManager.lua create mode 100644 Resources/Scripts/XManager/XFubenSimulatedCombatManager.lua create mode 100644 Resources/Scripts/XManager/XFubenSpecialTrainManager.lua create mode 100644 Resources/Scripts/XManager/XFubenUnionKillManager.lua create mode 100644 Resources/Scripts/XManager/XFubenUnionKillRoomManager.lua create mode 100644 Resources/Scripts/XManager/XFubenUrgentEventManager.lua create mode 100644 Resources/Scripts/XManager/XFubenZhouMuManager.lua create mode 100644 Resources/Scripts/XManager/XFunctionCommunicationManager.lua create mode 100644 Resources/Scripts/XManager/XFunctionEventManager.lua create mode 100644 Resources/Scripts/XManager/XFunctionManager.lua create mode 100644 Resources/Scripts/XManager/XFunctionalSkipManager.lua create mode 100644 Resources/Scripts/XManager/XFurnitureManager.lua create mode 100644 Resources/Scripts/XManager/XGachaManager.lua create mode 100644 Resources/Scripts/XManager/XGmTestManager.lua create mode 100644 Resources/Scripts/XManager/XGoodsCommonManager.lua create mode 100644 Resources/Scripts/XManager/XGuardCampManager.lua create mode 100644 Resources/Scripts/XManager/XGuideManager.lua create mode 100644 Resources/Scripts/XManager/XGuildBossManager.lua create mode 100644 Resources/Scripts/XManager/XGuildManager.lua create mode 100644 Resources/Scripts/XManager/XHardwareManager.lua create mode 100644 Resources/Scripts/XManager/XHaruUserManager.lua create mode 100644 Resources/Scripts/XManager/XHeadPortraitManager.lua create mode 100644 Resources/Scripts/XManager/XHeroSdkManager.lua create mode 100644 Resources/Scripts/XManager/XHgSdkManager.lua create mode 100644 Resources/Scripts/XManager/XHostelDelegateManager.lua create mode 100644 Resources/Scripts/XManager/XHostelManager.lua create mode 100644 Resources/Scripts/XManager/XHudManager.lua create mode 100644 Resources/Scripts/XManager/XInvertCardGameManager.lua create mode 100644 Resources/Scripts/XManager/XItemManager.lua create mode 100644 Resources/Scripts/XManager/XKillZoneManager.lua create mode 100644 Resources/Scripts/XManager/XLoadingManager.lua create mode 100644 Resources/Scripts/XManager/XLoginManager.lua create mode 100644 Resources/Scripts/XManager/XLottoManager.lua create mode 100644 Resources/Scripts/XManager/XLuaUiManager.lua create mode 100644 Resources/Scripts/XManager/XMagicSkillManager.lua create mode 100644 Resources/Scripts/XManager/XMailManager.lua create mode 100644 Resources/Scripts/XManager/XMaintainerActionManager.lua create mode 100644 Resources/Scripts/XManager/XMarketingActivityManager.lua create mode 100644 Resources/Scripts/XManager/XMedalManager.lua create mode 100644 Resources/Scripts/XManager/XMentorSystemManager.lua create mode 100644 Resources/Scripts/XManager/XMineSweepingManager.lua create mode 100644 Resources/Scripts/XManager/XModelManager.lua create mode 100644 Resources/Scripts/XManager/XMoeWarManager.lua create mode 100644 Resources/Scripts/XManager/XMovieAssembleManager.lua create mode 100644 Resources/Scripts/XManager/XMovieManager.lua create mode 100644 Resources/Scripts/XManager/XMusicPlayerManager.lua create mode 100644 Resources/Scripts/XManager/XNewRoleShowManager.lua create mode 100644 Resources/Scripts/XManager/XNieRManager.lua create mode 100644 Resources/Scripts/XManager/XNoticeManager.lua create mode 100644 Resources/Scripts/XManager/XNotifyManager.lua create mode 100644 Resources/Scripts/XManager/XPartnerManager.lua create mode 100644 Resources/Scripts/XManager/XPartnerTeachingManager.lua create mode 100644 Resources/Scripts/XManager/XPassportManager.lua create mode 100644 Resources/Scripts/XManager/XPayManager.lua create mode 100644 Resources/Scripts/XManager/XPermissionManager.lua create mode 100644 Resources/Scripts/XManager/XPersonalInfoManager.lua create mode 100644 Resources/Scripts/XManager/XPhotographManager.lua create mode 100644 Resources/Scripts/XManager/XPlatformShareManager.lua create mode 100644 Resources/Scripts/XManager/XPlayerInfoManager.lua create mode 100644 Resources/Scripts/XManager/XPlayerManager.lua create mode 100644 Resources/Scripts/XManager/XPokemonManager.lua create mode 100644 Resources/Scripts/XManager/XPokerGuessingManager.lua create mode 100644 Resources/Scripts/XManager/XPracticeManager.lua create mode 100644 Resources/Scripts/XManager/XPrequelManager.lua create mode 100644 Resources/Scripts/XManager/XPurchaseManager.lua create mode 100644 Resources/Scripts/XManager/XPuzzleActivityManager.lua create mode 100644 Resources/Scripts/XManager/XRTextureManager.lua create mode 100644 Resources/Scripts/XManager/XRedPointManager.lua create mode 100644 Resources/Scripts/XManager/XReformActivityManager.lua create mode 100644 Resources/Scripts/XManager/XRegressionManager.lua create mode 100644 Resources/Scripts/XManager/XReportManager.lua create mode 100644 Resources/Scripts/XManager/XResetManager.lua create mode 100644 Resources/Scripts/XManager/XRewardManager.lua create mode 100644 Resources/Scripts/XManager/XRobotManager.lua create mode 100644 Resources/Scripts/XManager/XRoomCharFilterTipsManager.lua create mode 100644 Resources/Scripts/XManager/XRoomManager.lua create mode 100644 Resources/Scripts/XManager/XRoomSingleManager.lua create mode 100644 Resources/Scripts/XManager/XRpgMakerGameManager.lua create mode 100644 Resources/Scripts/XManager/XRpgTowerManager.lua create mode 100644 Resources/Scripts/XManager/XScratchTicketManager.lua create mode 100644 Resources/Scripts/XManager/XServerManager.lua create mode 100644 Resources/Scripts/XManager/XSetManager.lua create mode 100644 Resources/Scripts/XManager/XShopManager.lua create mode 100644 Resources/Scripts/XManager/XSignBoardManager.lua create mode 100644 Resources/Scripts/XManager/XSignInManager.lua create mode 100644 Resources/Scripts/XManager/XSocialManager.lua create mode 100644 Resources/Scripts/XManager/XSoundManager.lua create mode 100644 Resources/Scripts/XManager/XSpecialShopManager.lua create mode 100644 Resources/Scripts/XManager/XSpringFestivalActivityManager.lua create mode 100644 Resources/Scripts/XManager/XStoryManager.lua create mode 100644 Resources/Scripts/XManager/XStrongholdManager.lua create mode 100644 Resources/Scripts/XManager/XSuperTowerManager.lua create mode 100644 Resources/Scripts/XManager/XTRPGManager.lua create mode 100644 Resources/Scripts/XManager/XTableManager.lua create mode 100644 Resources/Scripts/XManager/XTaskForceManager.lua create mode 100644 Resources/Scripts/XManager/XTaskManager.lua create mode 100644 Resources/Scripts/XManager/XTeamManager.lua create mode 100644 Resources/Scripts/XManager/XTipManager.lua create mode 100644 Resources/Scripts/XManager/XTrialManager.lua create mode 100644 Resources/Scripts/XManager/XTypeManager.lua create mode 100644 Resources/Scripts/XManager/XUiManager.lua create mode 100644 Resources/Scripts/XManager/XUiPcManager.lua create mode 100644 Resources/Scripts/XManager/XUploadLogManager.lua create mode 100644 Resources/Scripts/XManager/XUserManager.lua create mode 100644 Resources/Scripts/XManager/XVideoManager.lua create mode 100644 Resources/Scripts/XManager/XVoteManager.lua create mode 100644 Resources/Scripts/XManager/XWeaponFashionManager.lua create mode 100644 Resources/Scripts/XManager/XWhiteValentineManager.lua create mode 100644 Resources/Scripts/XManager/XWorldBossManager.lua create mode 100644 Resources/Scripts/XMerge/XMergeAppEventChecker.lua create mode 100644 Resources/Scripts/XMerge/XMergeChecker.lua create mode 100644 Resources/Scripts/XMovieActions/XMovieActionActorAppear.lua create mode 100644 Resources/Scripts/XMovieActions/XMovieActionActorChangeFace.lua create mode 100644 Resources/Scripts/XMovieActions/XMovieActionActorDisappear.lua create mode 100644 Resources/Scripts/XMovieActions/XMovieActionActorShift.lua create mode 100644 Resources/Scripts/XMovieActions/XMovieActionAnimationPlay.lua create mode 100644 Resources/Scripts/XMovieActions/XMovieActionAudioInterrupt.lua create mode 100644 Resources/Scripts/XMovieActions/XMovieActionBase.lua create mode 100644 Resources/Scripts/XMovieActions/XMovieActionBgSwitch.lua create mode 100644 Resources/Scripts/XMovieActions/XMovieActionDelaySkip.lua create mode 100644 Resources/Scripts/XMovieActions/XMovieActionDialog.lua create mode 100644 Resources/Scripts/XMovieActions/XMovieActionEffectPlay.lua create mode 100644 Resources/Scripts/XMovieActions/XMovieActionFullScreenDialog.lua create mode 100644 Resources/Scripts/XMovieActions/XMovieActionPrefabAnimation.lua create mode 100644 Resources/Scripts/XMovieActions/XMovieActionSelection.lua create mode 100644 Resources/Scripts/XMovieActions/XMovieActionSetGray.lua create mode 100644 Resources/Scripts/XMovieActions/XMovieActionSoundPlay.lua create mode 100644 Resources/Scripts/XMovieActions/XMovieActionStaff.lua create mode 100644 Resources/Scripts/XMovieActions/XMovieActionTheme.lua create mode 100644 Resources/Scripts/XMovieActions/XMovieActionUnLoad.lua create mode 100644 Resources/Scripts/XMovieActions/XMovieActionVideoPlay.lua create mode 100644 Resources/Scripts/XMovieActions/XMovieActionYieldResume.lua create mode 100644 Resources/Scripts/XOverseas/XConfig/XSlotMachineConfigs.lua create mode 100644 Resources/Scripts/XOverseas/XEntity/XSlotMachine/XSlotMachineDataEntity.lua create mode 100644 Resources/Scripts/XOverseas/XManager/XFireworksManager.lua create mode 100644 Resources/Scripts/XOverseas/XManager/XSlotMachineManager.lua create mode 100644 Resources/Scripts/XOverseas/XUi/XUiBubbleTip/XUiBubbleTip.lua create mode 100644 Resources/Scripts/XOverseas/XUi/XUiFireworks/XUiFireworks.lua create mode 100644 Resources/Scripts/XOverseas/XUi/XUiFireworks/XUiFireworksLog.lua create mode 100644 Resources/Scripts/XOverseas/XUi/XUiFireworks/XUiFireworksPanelRecord.lua create mode 100644 Resources/Scripts/XOverseas/XUi/XUiFireworks/XUiFireworksPanelRule.lua create mode 100644 Resources/Scripts/XOverseas/XUi/XUiSlotMachine/XUiSlotMachine.lua create mode 100644 Resources/Scripts/XOverseas/XUi/XUiSlotMachine/XUiSlotMachineIconItem.lua create mode 100644 Resources/Scripts/XOverseas/XUi/XUiSlotMachine/XUiSlotMachinePanel.lua create mode 100644 Resources/Scripts/XOverseas/XUi/XUiSlotMachine/XUiSlotMachineRewardItem.lua create mode 100644 Resources/Scripts/XOverseas/XUi/XUiSlotMachine/XUiSlotMachineRewardPanel.lua create mode 100644 Resources/Scripts/XOverseas/XUi/XUiSlotMachine/XUiSlotMachineRules.lua create mode 100644 Resources/Scripts/XOverseas/XUi/XUiSlotMachine/XUiSlotMachineRulesItem.lua create mode 100644 Resources/Scripts/XOverseas/XUi/XUiSlotMachine/XUiSlotMachineRulesPanel.lua create mode 100644 Resources/Scripts/XOverseas/XUi/XUiSlotMachine/XUiSlotMachineRulesResearchLogItem.lua create mode 100644 Resources/Scripts/XOverseas/XUi/XUiSlotMachine/XUiSlotMachineRulesResearchPanel.lua create mode 100644 Resources/Scripts/XOverseas/XUi/XUiSlotMachine/XUiSlotMachineTask.lua create mode 100644 Resources/Scripts/XOverseas/XUi/XUiSlotMachine/XUiSlotMachineTaskContentPanel.lua create mode 100644 Resources/Scripts/XOverseas/XUi/XUiSlotMachine/XUiSlotMachineTaskGrid.lua create mode 100644 Resources/Scripts/XOverseas/XUi/XUiSlotMachine/XUiSlotMachineTipsPanel.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditionGroup.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionActivityBriefTaskFinished.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionActivityDrawNew.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionActivityNewAcitivies.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionActivityNewAcitiviesTogs.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionActivityNewActivityNotices.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionActivityNewNotices.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveAwareness.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveAwarenessGridNewTag.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveAwarenessNewTag.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveAwarenessSettingUnlock.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveCGAll.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveCGRed.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveCGTypeRed.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveMonsterAll.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveMonsterInfo.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveMonsterRed.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveMonsterSetting.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveMonsterSkill.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveMonsterTag.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveMonsterTypeRed.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveMonsterTypeTag.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveWeapon.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveWeaponGridNewTag.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveWeaponNewTag.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveWeaponSettingUnlock.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArenaApply.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArenaTask.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionAssign.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionBabelTower.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionBabelTowerReward.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionBaseEquip.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionBfrtChapterReward.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionBossSingle.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionBossSingleReward.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionBountyTask.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionBriefEntry.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionChapterReward.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionChapterSectionReward.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionCharacter.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionCharacterGrade.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionCharacterLevel.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionCharacterQuality.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionCharacterSkill.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionCharacterUnlock.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionChessPursuitReward.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionChristmasTree.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionChristmasTreeAward.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionChristmasTreeOrnamentActive.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionChristmasTreeOrnamentRead.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionClickClearDifficultUnlock.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionClickClearReward.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionCoupleCombatHard.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionCoupleCombatNormal.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionCoupletGamePlayVideo.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionCoupletGameRed.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionCoupletGameRewardTask.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionDefault.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionDormMainTaskRed.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionDormRed.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionDormTaskType.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionDormWork.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionDragPuzzleAward.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionDragPuzzleDecryption.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionDragPuzzleSwitch.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionDragPuzzleTab.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionDragPuzzleVideo.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionExhibitionNew.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionExpeditionRecruit.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionExperimentChapterReward.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionExperimentRed.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionExplore.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionExtra.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionExtraChapterExploreItem.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionExtraChapterReward.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionExtraTreasure.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFashionStoryHaveStage.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFavorability.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFavorabilityAction.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFavorabilityAudio.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFavorabilityDocument.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFavorabilityGift.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFavorabilityInfo.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFavorabilityPlot.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFavorabilityRumor.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFingerGuessingTaskRed.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFireworks.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFriendChatPrivate.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFriendContact.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFriendWaitPass.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFuBenClickClearGameRed.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFuBenDragPuzzleGameRed.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFubenDailyShop.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFubenHackBuff.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFubenHackStar.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFurnitureCreate.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionGetCard.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionGetFirstRecharge.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionGuardCampRed.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionGuildActiveGift.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionGuildApplyList.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionGuildBoss.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionGuildBossHp.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionGuildBossScore.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionGuildChallenge.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionGuildInformation.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionGuildMember.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionHeadPortraitNew.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionInvertCardGameRed.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionInvertCardGameTog.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionKillZoneActivity.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionKillZoneDailyStarReward.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionKillZoneNewChapter.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionKillZoneNewDiff.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionKillZonePluginOperate.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionKillZoneStarReward.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionKoroCharActivity.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionKoroCharActivityChallenge.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionKoroCharActivityTeaching.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMailPersonal.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMainChapter.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMainDispatch.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMainFriend.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMainLineExploreItem.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMainLineTreasure.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMainMail.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMainMember.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMainNewPlayerTask.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMainNotice.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMainSet.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMainSpecialShop.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMainTask.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMedalNew.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMentorApplyRed.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMentorRewardRed.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMentorTaskRed.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMineSweepingRed.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMoeWarDrawRed.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMoeWarPreparation.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMoeWarPreparationOpenStage.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMoeWarPreparationReward.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMoeWarRecruit.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMoeWarTask.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMoeWarTaskTab.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMovieAssemble01Red.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMovieAssembleMovieRed.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMovieAssembleRed.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionNewChallenge.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionNewCharActTreasure.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionNewYearDiviningNotGet.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionNieRCharacterRed.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionNieRPODRed.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionNieRRed.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionNieRRepeatRed.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionNieRTaskRed.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionNierCanFight.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPartnerCanCompose.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPartnerNewSkill.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPassport.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPassportPanelReward.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPassportTaskActivity.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPassportTaskDaily.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPassportTaskWeekly.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPicCompositionTaskFinished.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPlayerAchieve.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPlayerAchieveType.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPlayerSetName.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPokemonCanGetTimeSupply.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPokemonNewRole.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPokemonRed.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPokemonTaskRed.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPokerGuessingRed.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPrequel.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPurchase.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPurchaseAccumulate.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPurchaseLB.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionReceiveChat.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionReformAllRedPoint.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionReformBaseStageOpen.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionReformEvolvableStageUnlock.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionReformTaskGetReward.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionRegression.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionRegressionTask.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionRegressionTaskType.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionRepeatChallengeChapterReward.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionRepeatChallengeReward.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionRogueLikeMain.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionRpgMakerGame.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionRpgTower.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionRpgTowerDailyRewardRed.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionRpgTowerTaskRed.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionRpgTowerTeamRed.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSTRoleInDult.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSTRoleLevelUp.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSTRolePlugin.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionShortStory.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSimulatedCombat.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSimulatedCombatChallenge.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSimulatedCombatPoint.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSimulatedCombatStar.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSimulatedCombatTask.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSlotMachine.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSlotMachineL.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSpecialTrain.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSpecialTrainPoint.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSpringFestivalBagRed.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSpringFestivalRewardRed.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSpringFestivalTaskRed.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionStrongholdMineralLeft.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionStrongholdRewardCanGet.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSubMenuNewNotices.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionTRPGChapterReward.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionTRPGMainMode.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionTRPGMainView.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionTaskCourse.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionTaskLimited.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionTaskType.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionTaskWeekActive.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionTrial.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionTrialReward.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionTrialUnlock.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionUnGuildNews.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionWhite2021Encounter.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionWhite2021Invite.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionWhite2021Task.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionWhiteValentineTaskRed.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionWindowsInlay.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionWorldBossRed.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionZhouMuTask.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointTRPGAreaReward.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointTRPGCollectionMemoir.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointTRPGRoleTalent.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointTRPGSecondMainReward.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointTRPGTruthRoadReward.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointTRPGWorldBossReward.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointEvent.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointEventElement.lua create mode 100644 Resources/Scripts/XRedPoint/XRedPointListener.lua create mode 100644 Resources/Scripts/XUi/UiLoading/XUiLoading.lua create mode 100644 Resources/Scripts/XUi/XUiActivityBase/ScratchTicket/XUiScratchTicketGrid.lua create mode 100644 Resources/Scripts/XUi/XUiActivityBase/ScratchTicket/XUiScratchTicketPanelChose.lua create mode 100644 Resources/Scripts/XUi/XUiActivityBase/ScratchTicket/XUiScratchTicketPanelGrids.lua create mode 100644 Resources/Scripts/XUi/XUiActivityBase/ScratchTicket/XUiScratchTicketPanelLeft.lua create mode 100644 Resources/Scripts/XUi/XUiActivityBase/ScratchTicket/XUiScratchTicketPanelPlay.lua create mode 100644 Resources/Scripts/XUi/XUiActivityBase/ScratchTicket/XUiScratchTicketPanelPreview.lua create mode 100644 Resources/Scripts/XUi/XUiActivityBase/ScratchTicket/XUiScratchTicketPanelReady.lua create mode 100644 Resources/Scripts/XUi/XUiActivityBase/ScratchTicket/XUiScratchTicketPanelSelectChose.lua create mode 100644 Resources/Scripts/XUi/XUiActivityBase/ScratchTicket/XUiScratchTicketPanelTop.lua create mode 100644 Resources/Scripts/XUi/XUiActivityBase/XUiActivityBase.lua create mode 100644 Resources/Scripts/XUi/XUiActivityBase/XUiActivityBaseChild.lua create mode 100644 Resources/Scripts/XUi/XUiActivityBase/XUiActivityLink.lua create mode 100644 Resources/Scripts/XUi/XUiActivityBase/XUiConsumeReward.lua create mode 100644 Resources/Scripts/XUi/XUiActivityBase/XUiGridAcceptInvitation.lua create mode 100644 Resources/Scripts/XUi/XUiActivityBase/XUiGridActivityLink.lua create mode 100644 Resources/Scripts/XUi/XUiActivityBase/XUiGridConsumeReward.lua create mode 100644 Resources/Scripts/XUi/XUiActivityBase/XUiGridPuzzlePiece.lua create mode 100644 Resources/Scripts/XUi/XUiActivityBase/XUiGridSendInvitation.lua create mode 100644 Resources/Scripts/XUi/XUiActivityBase/XUiJigsawPuzzle.lua create mode 100644 Resources/Scripts/XUi/XUiActivityBase/XUiPanelAcceptInvitation.lua create mode 100644 Resources/Scripts/XUi/XUiActivityBase/XUiPanelLink.lua create mode 100644 Resources/Scripts/XUi/XUiActivityBase/XUiPanelSendInvitation.lua create mode 100644 Resources/Scripts/XUi/XUiActivityBase/XUiPanelShop.lua create mode 100644 Resources/Scripts/XUi/XUiActivityBase/XUiPanelSkip.lua create mode 100644 Resources/Scripts/XUi/XUiActivityBase/XUiPanelTask.lua create mode 100644 Resources/Scripts/XUi/XUiActivityBase/XUiScratchTicket.lua create mode 100644 Resources/Scripts/XUi/XUiActivityBossSingle/XUiActivityBossSingle.lua create mode 100644 Resources/Scripts/XUi/XUiActivityBossSingle/XUiActivityBossSingleReward.lua create mode 100644 Resources/Scripts/XUi/XUiActivityBossSingle/XUiAttentionDesc.lua create mode 100644 Resources/Scripts/XUi/XUiActivityBossSingle/XUiBossSingleTreasureGrid.lua create mode 100644 Resources/Scripts/XUi/XUiActivityBossSingle/XUiGridActivityBossSingle.lua create mode 100644 Resources/Scripts/XUi/XUiActivityBossSingleDetail/XUiActivityBossSingleDetail.lua create mode 100644 Resources/Scripts/XUi/XUiActivityBranch/XUiActivityBranch.lua create mode 100644 Resources/Scripts/XUi/XUiActivityBranch/XUiActivityBranchReward.lua create mode 100644 Resources/Scripts/XUi/XUiActivityBranch/XUiFubenBranchStageDetail.lua create mode 100644 Resources/Scripts/XUi/XUiActivityBranch/XUiGridActivityBranchReward.lua create mode 100644 Resources/Scripts/XUi/XUiActivityBrief/XActivityBrieButton.lua create mode 100644 Resources/Scripts/XUi/XUiActivityBrief/XActivityBrieIsOpen.lua create mode 100644 Resources/Scripts/XUi/XUiActivityBrief/XUiActivityBriefBase.lua create mode 100644 Resources/Scripts/XUi/XUiActivityBrief/XUiActivityBriefRefreshButton.lua create mode 100644 Resources/Scripts/XUi/XUiActivityBrief/XUiActivityBriefShop.lua create mode 100644 Resources/Scripts/XUi/XUiActivityBrief/XUiActivityBriefStory.lua create mode 100644 Resources/Scripts/XUi/XUiActivityBrief/XUiActivityBriefTask.lua create mode 100644 Resources/Scripts/XUi/XUiActivityBrief/XUiPanelStory.lua create mode 100644 Resources/Scripts/XUi/XUiArchive/XUiArchiveAwareness.lua create mode 100644 Resources/Scripts/XUi/XUiArchive/XUiArchiveAwarenessDetail.lua create mode 100644 Resources/Scripts/XUi/XUiArchive/XUiArchiveCG.lua create mode 100644 Resources/Scripts/XUi/XUiArchive/XUiArchiveCGDetail.lua create mode 100644 Resources/Scripts/XUi/XUiArchive/XUiArchiveEmail.lua create mode 100644 Resources/Scripts/XUi/XUiArchive/XUiArchiveMain.lua create mode 100644 Resources/Scripts/XUi/XUiArchive/XUiArchiveMonster.lua create mode 100644 Resources/Scripts/XUi/XUiArchive/XUiArchiveMonsterComment.lua create mode 100644 Resources/Scripts/XUi/XUiArchive/XUiArchiveMonsterDetail.lua create mode 100644 Resources/Scripts/XUi/XUiArchive/XUiArchiveMonsterEvaluate.lua create mode 100644 Resources/Scripts/XUi/XUiArchive/XUiArchiveMonsterInfo.lua create mode 100644 Resources/Scripts/XUi/XUiArchive/XUiArchiveMonsterSelectTag.lua create mode 100644 Resources/Scripts/XUi/XUiArchive/XUiArchiveMonsterSetting.lua create mode 100644 Resources/Scripts/XUi/XUiArchive/XUiArchiveMonsterSkill.lua create mode 100644 Resources/Scripts/XUi/XUiArchive/XUiArchiveMonsterSynopsis.lua create mode 100644 Resources/Scripts/XUi/XUiArchive/XUiArchiveNpc.lua create mode 100644 Resources/Scripts/XUi/XUiArchive/XUiArchivePartner.lua create mode 100644 Resources/Scripts/XUi/XUiArchive/XUiArchivePartnerDetail.lua create mode 100644 Resources/Scripts/XUi/XUiArchive/XUiArchiveStory.lua create mode 100644 Resources/Scripts/XUi/XUiArchive/XUiArchiveStoryDetail.lua create mode 100644 Resources/Scripts/XUi/XUiArchive/XUiArchiveStoryDialog.lua create mode 100644 Resources/Scripts/XUi/XUiArchive/XUiArchiveWeapon.lua create mode 100644 Resources/Scripts/XUi/XUiArchive/XUiArchiveWeaponAchievement.lua create mode 100644 Resources/Scripts/XUi/XUiArchive/XUiArchiveWeaponDetail.lua create mode 100644 Resources/Scripts/XUi/XUiArchive/XUiArchiveWeaponsCollectionTips.lua create mode 100644 Resources/Scripts/XUi/XUiArchive/XUiGridArchive.lua create mode 100644 Resources/Scripts/XUi/XUiArchive/XUiGridArchiveAwareness.lua create mode 100644 Resources/Scripts/XUi/XUiArchive/XUiGridArchiveAwarenessDetail.lua create mode 100644 Resources/Scripts/XUi/XUiArchive/XUiGridArchiveAwarenessSetting.lua create mode 100644 Resources/Scripts/XUi/XUiArchive/XUiGridArchiveCG.lua create mode 100644 Resources/Scripts/XUi/XUiArchive/XUiGridArchiveCommunication.lua create mode 100644 Resources/Scripts/XUi/XUiArchive/XUiGridArchiveEmail.lua create mode 100644 Resources/Scripts/XUi/XUiArchive/XUiGridArchiveEquipSetting.lua create mode 100644 Resources/Scripts/XUi/XUiArchive/XUiGridArchiveMonster.lua create mode 100644 Resources/Scripts/XUi/XUiArchive/XUiGridArchiveNpc.lua create mode 100644 Resources/Scripts/XUi/XUiArchive/XUiGridArchivePartner.lua create mode 100644 Resources/Scripts/XUi/XUiArchive/XUiGridArchiveStory.lua create mode 100644 Resources/Scripts/XUi/XUiArchive/XUiGridArchiveStoryDetail.lua create mode 100644 Resources/Scripts/XUi/XUiArchive/XUiGridArchiveTag.lua create mode 100644 Resources/Scripts/XUi/XUiArchive/XUiGridArchiveWeapon.lua create mode 100644 Resources/Scripts/XUi/XUiArchive/XUiGridArchiveWeaponAchievement.lua create mode 100644 Resources/Scripts/XUi/XUiArena/XUiArena.lua create mode 100644 Resources/Scripts/XUi/XUiArena/XUiArenaContributeScore.lua create mode 100644 Resources/Scripts/XUi/XUiArena/XUiArenaContributeTips.lua create mode 100644 Resources/Scripts/XUi/XUiArena/XUiArenaContributeTipsGrid.lua create mode 100644 Resources/Scripts/XUi/XUiArena/XUiArenaGrid.lua create mode 100644 Resources/Scripts/XUi/XUiArena/XUiArenaRank.lua create mode 100644 Resources/Scripts/XUi/XUiArena/XUiArenaRankGrid.lua create mode 100644 Resources/Scripts/XUi/XUiArena/XUiPanelActive.lua create mode 100644 Resources/Scripts/XUi/XUiArena/XUiPanelPrepare.lua create mode 100644 Resources/Scripts/XUi/XUiArenaActivityResult/XUiArenaActivityResult.lua create mode 100644 Resources/Scripts/XUi/XUiArenaFightResult/XUiArenaFightResult.lua create mode 100644 Resources/Scripts/XUi/XUiArenaLevelDetail/ArenaLevelDetailCommon/XUiGridArenaLevel.lua create mode 100644 Resources/Scripts/XUi/XUiArenaLevelDetail/ArenaLevelDetailCommon/XUiGridRegion.lua create mode 100644 Resources/Scripts/XUi/XUiArenaLevelDetail/XUiArenaLevelDetail.lua create mode 100644 Resources/Scripts/XUi/XUiArenaOnline/XUiArenaOnlineChapter.lua create mode 100644 Resources/Scripts/XUi/XUiArenaOnline/XUiArenaOnlineInvitation.lua create mode 100644 Resources/Scripts/XUi/XUiArenaOnline/XUiArenaOnlineSection.lua create mode 100644 Resources/Scripts/XUi/XUiArenaOnline/XUiChapterPrefab.lua create mode 100644 Resources/Scripts/XUi/XUiArenaOnline/XUiGridSection.lua create mode 100644 Resources/Scripts/XUi/XUiArenaOnline/XUiGridStage.lua create mode 100644 Resources/Scripts/XUi/XUiArenaOnline/XUiPanelBuffDetail.lua create mode 100644 Resources/Scripts/XUi/XUiArenaOnline/XUiPanelStagInfo.lua create mode 100644 Resources/Scripts/XUi/XUiArenaOnline/XUiPanelStageDetail.lua create mode 100644 Resources/Scripts/XUi/XUiArenaOnline/XUiPanelTargetInfo.lua create mode 100644 Resources/Scripts/XUi/XUiArenaOnline/XUiSectionPrefab.lua create mode 100644 Resources/Scripts/XUi/XUiArenaStage/ArenaStageCommon/XUiGridArenaPassContent.lua create mode 100644 Resources/Scripts/XUi/XUiArenaStage/ArenaStageCommon/XUiGridArenaStage.lua create mode 100644 Resources/Scripts/XUi/XUiArenaStage/XUiArenaStage.lua create mode 100644 Resources/Scripts/XUi/XUiArenaStage/XUiPanelPassDetail.lua create mode 100644 Resources/Scripts/XUi/XUiArenaTask/XUiArenaTask.lua create mode 100644 Resources/Scripts/XUi/XUiArenaTeam/XUiArenaTeam.lua create mode 100644 Resources/Scripts/XUi/XUiArenaTeam/XUiArenaTeamCommon/XUiGridArenaMyTeamMember.lua create mode 100644 Resources/Scripts/XUi/XUiArenaTeam/XUiArenaTeamCommon/XUiGridArenaTeam.lua create mode 100644 Resources/Scripts/XUi/XUiArenaTeam/XUiArenaTeamCommon/XUiGridArenaTeamApply.lua create mode 100644 Resources/Scripts/XUi/XUiArenaTeam/XUiArenaTeamCommon/XUiGridArenaTeamMember.lua create mode 100644 Resources/Scripts/XUi/XUiArenaTeam/XUiArenaTeamCommon/XUiGridArenaTeamSingle.lua create mode 100644 Resources/Scripts/XUi/XUiArenaTeam/XUiPanelApply.lua create mode 100644 Resources/Scripts/XUi/XUiArenaTeam/XUiPanelHall.lua create mode 100644 Resources/Scripts/XUi/XUiArenaTeam/XUiPanelInviteFriend.lua create mode 100644 Resources/Scripts/XUi/XUiArenaTeam/XUiPanelMyTeam.lua create mode 100644 Resources/Scripts/XUi/XUiArenaTeamRank/ArenaTeamRankCommon/XUiGridArenaTeamRank.lua create mode 100644 Resources/Scripts/XUi/XUiArenaTeamRank/ArenaTeamRankCommon/XUiGridArenaTeamReward.lua create mode 100644 Resources/Scripts/XUi/XUiArenaTeamRank/XUiArenaTeamRank.lua create mode 100644 Resources/Scripts/XUi/XUiArenaTeamRank/XUiPanelRewardPreview.lua create mode 100644 Resources/Scripts/XUi/XUiArenaTeamRank/XUiPanelTeamRank.lua create mode 100644 Resources/Scripts/XUi/XUiArenaWarZone/ArenaWarZoneCommon/XUiGridZone.lua create mode 100644 Resources/Scripts/XUi/XUiArenaWarZone/XUiArenaWarZone.lua create mode 100644 Resources/Scripts/XUi/XUiAssign/UiAssignSelectOccupy.lua create mode 100644 Resources/Scripts/XUi/XUiAssign/XUiAssignBuff.lua create mode 100644 Resources/Scripts/XUi/XUiAssign/XUiAssignBuffAll.lua create mode 100644 Resources/Scripts/XUi/XUiAssign/XUiAssignBuffPart.lua create mode 100644 Resources/Scripts/XUi/XUiAssign/XUiAssignDeploy.lua create mode 100644 Resources/Scripts/XUi/XUiAssign/XUiAssignInfo.lua create mode 100644 Resources/Scripts/XUi/XUiAssign/XUiAssignOccupy.lua create mode 100644 Resources/Scripts/XUi/XUiAssign/XUiAssignPostWarCount.lua create mode 100644 Resources/Scripts/XUi/XUiAssign/XUiAssignRoomCharacter.lua create mode 100644 Resources/Scripts/XUi/XUiAssign/XUiAssignStageDetail.lua create mode 100644 Resources/Scripts/XUi/XUiAssign/XUiGridAssignBuffPart.lua create mode 100644 Resources/Scripts/XUi/XUiAssign/XUiGridAssignBuffText.lua create mode 100644 Resources/Scripts/XUi/XUiAssign/XUiGridAssignChapter.lua create mode 100644 Resources/Scripts/XUi/XUiAssign/XUiGridAssignDeployMember.lua create mode 100644 Resources/Scripts/XUi/XUiAssign/XUiGridAssignDeployTeam.lua create mode 100644 Resources/Scripts/XUi/XUiAssign/XUiGridAssignFormationMember.lua create mode 100644 Resources/Scripts/XUi/XUiAssign/XUiGridAssignFormationTeam.lua create mode 100644 Resources/Scripts/XUi/XUiAssign/XUiGridAssignSelectOccupy.lua create mode 100644 Resources/Scripts/XUi/XUiAssign/XUiGridAssignStage.lua create mode 100644 Resources/Scripts/XUi/XUiAssign/XUiGridTeamInfoExp.lua create mode 100644 Resources/Scripts/XUi/XUiAssign/XUiPanelAssignFormation.lua create mode 100644 Resources/Scripts/XUi/XUiAssign/XUiPanelAssignMain.lua create mode 100644 Resources/Scripts/XUi/XUiAssign/XUiPanelAssignStage.lua create mode 100644 Resources/Scripts/XUi/XUiAutoFightDialog/XUiAutoFightDialog.lua create mode 100644 Resources/Scripts/XUi/XUiAutoFightDialog/XUiImgIcon.lua create mode 100644 Resources/Scripts/XUi/XUiAutoFightDialog/XUiPanelBtn.lua create mode 100644 Resources/Scripts/XUi/XUiAutoFightList/XUiAutoFightList.lua create mode 100644 Resources/Scripts/XUi/XUiAutoFightList/XUiAutoFightRecord.lua create mode 100644 Resources/Scripts/XUi/XUiAutoFightReward/XUiAutoFightExp.lua create mode 100644 Resources/Scripts/XUi/XUiAutoFightReward/XUiAutoFightReward.lua create mode 100644 Resources/Scripts/XUi/XUiAutoFightReward/XUiAutoFightRewardCharacter.lua create mode 100644 Resources/Scripts/XUi/XUiAutoFightTip/XUiAutoFightTip.lua create mode 100644 Resources/Scripts/XUi/XUiAutoWindow/XUiAutoWindow.lua create mode 100644 Resources/Scripts/XUi/XUiAwarenessTf/XUiAwarenessTf.lua create mode 100644 Resources/Scripts/XUi/XUiAwarenessTf/XUiAwarenessTfBtnPos.lua create mode 100644 Resources/Scripts/XUi/XUiAwarenessTf/XUiAwarenessTfChoice.lua create mode 100644 Resources/Scripts/XUi/XUiAwarenessTf/XUiAwarenessTfResult.lua create mode 100644 Resources/Scripts/XUi/XUiBag/XUiBag.lua create mode 100644 Resources/Scripts/XUi/XUiBag/XUiBagItem.lua create mode 100644 Resources/Scripts/XUi/XUiBag/XUiBagItemInfoPanel.lua create mode 100644 Resources/Scripts/XUi/XUiBag/XUiGridSelectGift.lua create mode 100644 Resources/Scripts/XUi/XUiBag/XUiGridSelectReplicatedGift.lua create mode 100644 Resources/Scripts/XUi/XUiBag/XUiPanelBagItem.lua create mode 100644 Resources/Scripts/XUi/XUiBag/XUiPanelBagRecycle.lua create mode 100644 Resources/Scripts/XUi/XUiBag/XUiPanelSelectGift.lua create mode 100644 Resources/Scripts/XUi/XUiBag/XUiPanelSelectReplicatedGift.lua create mode 100644 Resources/Scripts/XUi/XUiBag/XUiPanelSidePopUp.lua create mode 100644 Resources/Scripts/XUi/XUiBag/XUiRecyclingSettings.lua create mode 100644 Resources/Scripts/XUi/XUiBase/XPageView.lua create mode 100644 Resources/Scripts/XUi/XUiBase/XScrollGrid.lua create mode 100644 Resources/Scripts/XUi/XUiBase/XScrollView.lua create mode 100644 Resources/Scripts/XUi/XUiBase/XUiBtnTab.lua create mode 100644 Resources/Scripts/XUi/XUiBase/XUiChapterBtnTab.lua create mode 100644 Resources/Scripts/XUi/XUiBase/XUiTabBtnGroup.lua create mode 100644 Resources/Scripts/XUi/XUiBaseEquip/XUiBaseEquip.lua create mode 100644 Resources/Scripts/XUi/XUiBaseEquip/XUiGridBaseEquip.lua create mode 100644 Resources/Scripts/XUi/XUiBaseEquip/XUiPanelBaseEquipInfo.lua create mode 100644 Resources/Scripts/XUi/XUiBaseEquip/XUiPanelBaseEquipPutOn.lua create mode 100644 Resources/Scripts/XUi/XUiBaseEquip/XUiPanelBaseEquipRecycle.lua create mode 100644 Resources/Scripts/XUi/XUiBaseEquip/XUiPanelPutOnShowTip.lua create mode 100644 Resources/Scripts/XUi/XUiBfrt/XUiBfrtDeploy.lua create mode 100644 Resources/Scripts/XUi/XUiBfrt/XUiBfrtInfo.lua create mode 100644 Resources/Scripts/XUi/XUiBfrt/XUiBfrtPostWarCount.lua create mode 100644 Resources/Scripts/XUi/XUiBfrt/XUiBfrtQuickDeploy.lua create mode 100644 Resources/Scripts/XUi/XUiBfrt/XUiBfrtRoomCharacter.lua create mode 100644 Resources/Scripts/XUi/XUiBfrt/XUiBfrtStageDetail.lua create mode 100644 Resources/Scripts/XUi/XUiBfrt/XUiGridBfrtCharacter.lua create mode 100644 Resources/Scripts/XUi/XUiBfrt/XUiGridEchelon.lua create mode 100644 Resources/Scripts/XUi/XUiBfrt/XUiGridEchelonExp.lua create mode 100644 Resources/Scripts/XUi/XUiBfrt/XUiGridEchelonMember.lua create mode 100644 Resources/Scripts/XUi/XUiBfrt/XUiGridLogisticSkill.lua create mode 100644 Resources/Scripts/XUi/XUiBfrt/XUiGridQuickDeployMember.lua create mode 100644 Resources/Scripts/XUi/XUiBfrt/XUiGridQuickDeployTeam.lua create mode 100644 Resources/Scripts/XUi/XUiBfrt/XUiTipBfrtLogisticSkill.lua create mode 100644 Resources/Scripts/XUi/XUiBuyAsset/XUiBattery.lua create mode 100644 Resources/Scripts/XUi/XUiBuyAsset/XUiBuyAsset.lua create mode 100644 Resources/Scripts/XUi/XUiBuyAsset/XUiCoinPackage.lua create mode 100644 Resources/Scripts/XUi/XUiBuyAsset/XUiUseCoinPackage.lua create mode 100644 Resources/Scripts/XUi/XUiBuyAsset/XUiUsePackage.lua create mode 100644 Resources/Scripts/XUi/XUiCharacter/XUiCharSkillOtherParsing.lua create mode 100644 Resources/Scripts/XUi/XUiCharacter/XUiCharacter.lua create mode 100644 Resources/Scripts/XUi/XUiCharacter/XUiCharacterCarerrTips.lua create mode 100644 Resources/Scripts/XUi/XUiCharacter/XUiCharacterElementDetail.lua create mode 100644 Resources/Scripts/XUi/XUiCharacter/XUiCharacterOwnedInfo.lua create mode 100644 Resources/Scripts/XUi/XUiCharacter/XUiCharacterSkillSwich.lua create mode 100644 Resources/Scripts/XUi/XUiCharacter/XUiCharacterUnOwnedInfo.lua create mode 100644 Resources/Scripts/XUi/XUiCharacter/XUiGridCharacter.lua create mode 100644 Resources/Scripts/XUi/XUiCharacter/XUiGridCharacterCareer.lua create mode 100644 Resources/Scripts/XUi/XUiCharacter/XUiGridCharacterNew.lua create mode 100644 Resources/Scripts/XUi/XUiCharacter/XUiGridElementDetail.lua create mode 100644 Resources/Scripts/XUi/XUiCharacter/XUiGridSkillInfo.lua create mode 100644 Resources/Scripts/XUi/XUiCharacter/XUiGridSkillItem.lua create mode 100644 Resources/Scripts/XUi/XUiCharacter/XUiGridSubSkill.lua create mode 100644 Resources/Scripts/XUi/XUiCharacter/XUiGridSwitchSkill.lua create mode 100644 Resources/Scripts/XUi/XUiCharacter/XUiPanelCharGrade.lua create mode 100644 Resources/Scripts/XUi/XUiCharacter/XUiPanelCharLevel.lua create mode 100644 Resources/Scripts/XUi/XUiCharacter/XUiPanelCharProperty.lua create mode 100644 Resources/Scripts/XUi/XUiCharacter/XUiPanelCharQuality.lua create mode 100644 Resources/Scripts/XUi/XUiCharacter/XUiPanelCharSkill.lua create mode 100644 Resources/Scripts/XUi/XUiCharacter/XUiPanelCharacterExchange.lua create mode 100644 Resources/Scripts/XUi/XUiCharacter/XUiPanelCodition.lua create mode 100644 Resources/Scripts/XUi/XUiCharacter/XUiPanelGradeUpgrade.lua create mode 100644 Resources/Scripts/XUi/XUiCharacter/XUiPanelLevelUpgrade.lua create mode 100644 Resources/Scripts/XUi/XUiCharacter/XUiPanelQualityPreview.lua create mode 100644 Resources/Scripts/XUi/XUiCharacter/XUiPanelQualityUpgrade.lua create mode 100644 Resources/Scripts/XUi/XUiCharacter/XUiPanelRoleModel.lua create mode 100644 Resources/Scripts/XUi/XUiCharacter/XUiPanelSelectLevelItems.lua create mode 100644 Resources/Scripts/XUi/XUiCharacter/XUiPanelSkillInfo.lua create mode 100644 Resources/Scripts/XUi/XUiCharacter/XUiPanelSkillLevelDetail.lua create mode 100644 Resources/Scripts/XUi/XUiCharacter/XUiPanelSkillTeach.lua create mode 100644 Resources/Scripts/XUi/XUiCharacterDetail/XUiCharacterDetail.lua create mode 100644 Resources/Scripts/XUi/XUiCharacterDetail/XUiPanelDetailEquipItem.lua create mode 100644 Resources/Scripts/XUi/XUiCharacterDetail/XUiPanelDetailTeamItem.lua create mode 100644 Resources/Scripts/XUi/XUiCharacterDetail/XUiPanelEquipInfo.lua create mode 100644 Resources/Scripts/XUi/XUiCharacterDetail/XUiPanelTeamInfo.lua create mode 100644 Resources/Scripts/XUi/XUiChatServe/ChatModel/EmojiModel/XUiEmojiItem.lua create mode 100644 Resources/Scripts/XUi/XUiChatServe/ChatModel/EmojiModel/XUiPanelEmoji.lua create mode 100644 Resources/Scripts/XUi/XUiChatServe/ChatModel/XUiBtnTitleItem.lua create mode 100644 Resources/Scripts/XUi/XUiChatServe/Item/XUiGridChatChannelItem.lua create mode 100644 Resources/Scripts/XUi/XUiChatServe/Item/XUiPanelWorldChatMyHelp.lua create mode 100644 Resources/Scripts/XUi/XUiChatServe/Item/XUiPanelWorldChatMyMsgEmoji.lua create mode 100644 Resources/Scripts/XUi/XUiChatServe/Item/XUiPanelWorldChatMyMsgItem.lua create mode 100644 Resources/Scripts/XUi/XUiChatServe/Item/XUiPanelWorldChatSystemItem.lua create mode 100644 Resources/Scripts/XUi/XUiChatServe/XUiChatServeMain.lua create mode 100644 Resources/Scripts/XUi/XUiChatServe/XUiPanelChatContent.lua create mode 100644 Resources/Scripts/XUi/XUiChatServe/XUiPanelChatPools.lua create mode 100644 Resources/Scripts/XUi/XUiChessPursuit/XChessPursuitCtrl.lua create mode 100644 Resources/Scripts/XUi/XUiChessPursuit/XData/XChessPursuitMapBoss.lua create mode 100644 Resources/Scripts/XUi/XUiChessPursuit/XData/XChessPursuitMapDb.lua create mode 100644 Resources/Scripts/XUi/XUiChessPursuit/XData/XChessPursuitRank.lua create mode 100644 Resources/Scripts/XUi/XUiChessPursuit/XData/XChessPursuitRankGrid.lua create mode 100644 Resources/Scripts/XUi/XUiChessPursuit/XData/XChessPursuitRankPlayer.lua create mode 100644 Resources/Scripts/XUi/XUiChessPursuit/XData/XChessPursuitRankScore.lua create mode 100644 Resources/Scripts/XUi/XUiChessPursuit/XData/XChessPursuitSyncAction.lua create mode 100644 Resources/Scripts/XUi/XUiChessPursuit/XData/XChessPursuitSyncActionQueue.lua create mode 100644 Resources/Scripts/XUi/XUiChessPursuit/XScene/XChessPursuitBoss.lua create mode 100644 Resources/Scripts/XUi/XUiChessPursuit/XScene/XChessPursuitCube.lua create mode 100644 Resources/Scripts/XUi/XUiChessPursuit/XScene/XChessPursuitModel.lua create mode 100644 Resources/Scripts/XUi/XUiChessPursuit/XScene/XChessPursuitScene.lua create mode 100644 Resources/Scripts/XUi/XUiChessPursuit/XScene/XChessPursuitSceneManager.lua create mode 100644 Resources/Scripts/XUi/XUiChessPursuit/XScene/XChessPursuitTeam.lua create mode 100644 Resources/Scripts/XUi/XUiChessPursuit/XUi/QuickDeploy/XUiChessPursuitGridQuickDeployMember.lua create mode 100644 Resources/Scripts/XUi/XUiChessPursuit/XUi/QuickDeploy/XUiChessPursuitGridQuickDeployTeam.lua create mode 100644 Resources/Scripts/XUi/XUiChessPursuit/XUi/QuickDeploy/XUiChessPursuitQuickDeploy.lua create mode 100644 Resources/Scripts/XUi/XUiChessPursuit/XUi/Rank/XUiChessPursuitMyRankGrid.lua create mode 100644 Resources/Scripts/XUi/XUiChessPursuit/XUi/Rank/XUiChessPursuitPanelRankReward.lua create mode 100644 Resources/Scripts/XUi/XUiChessPursuit/XUi/Rank/XUiChessPursuitPanelRankRewardGrid.lua create mode 100644 Resources/Scripts/XUi/XUiChessPursuit/XUi/Rank/XUiChessPursuitRank.lua create mode 100644 Resources/Scripts/XUi/XUiChessPursuit/XUi/Rank/XUiChessPursuitRankGrid.lua create mode 100644 Resources/Scripts/XUi/XUiChessPursuit/XUi/Rank/XUiChessPursuitRankLineup.lua create mode 100644 Resources/Scripts/XUi/XUiChessPursuit/XUi/Rank/XUiChessPursuitRankLineupCardGrid.lua create mode 100644 Resources/Scripts/XUi/XUiChessPursuit/XUi/Rank/XUiChessPursuitRankLineupGrid.lua create mode 100644 Resources/Scripts/XUi/XUiChessPursuit/XUi/Rank/XUiChessPursuitRankLineupRoleGrid.lua create mode 100644 Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XCPFSM/XUiCPActionBase.lua create mode 100644 Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XCPFSM/XUiCPActionBeginBattle.lua create mode 100644 Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XCPFSM/XUiCPActionCardEffect.lua create mode 100644 Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XCPFSM/XUiCPActionEndBattle.lua create mode 100644 Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XCPFSM/XUiCPActionEndBattleHurt.lua create mode 100644 Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XCPFSM/XUiCPActionEndRound.lua create mode 100644 Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XCPFSM/XUiCPActionMachine.lua create mode 100644 Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XCPFSM/XUiCPActionMove.lua create mode 100644 Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitBuzhenGrid.lua create mode 100644 Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitCardGrid.lua create mode 100644 Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitGridFight.lua create mode 100644 Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitGuideGrid.lua create mode 100644 Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitMain.lua create mode 100644 Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitMainAnimQueue.lua create mode 100644 Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitMainBase.lua create mode 100644 Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitMainScene.lua create mode 100644 Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitMainStage.lua create mode 100644 Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitPanelFightStage.lua create mode 100644 Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitSelectTipGrid.lua create mode 100644 Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitSkillEffectGrid.lua create mode 100644 Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitSkillGrid.lua create mode 100644 Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitStageGrid.lua create mode 100644 Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiChessPursuitBuffTips.lua create mode 100644 Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiChessPursuitBuffTipsGrid.lua create mode 100644 Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiChessPursuitCardsTip.lua create mode 100644 Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiChessPursuitFightResult.lua create mode 100644 Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiChessPursuitFightTips.lua create mode 100644 Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiChessPursuitNewRoomSingle.lua create mode 100644 Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiChessPursuitShop/XUiChessPursuitShop.lua create mode 100644 Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiChessPursuitShop/XUiChessPursuitShopGrid.lua create mode 100644 Resources/Scripts/XUi/XUiChristmasTree/XUiChristmasTree.lua create mode 100644 Resources/Scripts/XUi/XUiChristmasTree/XUiGridTreasureTask.lua create mode 100644 Resources/Scripts/XUi/XUiChristmasTree/XUiOrnamentGrid.lua create mode 100644 Resources/Scripts/XUi/XUiChristmasTree/XUiPlacedOrnamentGrid.lua create mode 100644 Resources/Scripts/XUi/XUiClickClearGame/XUiClickClearGame.lua create mode 100644 Resources/Scripts/XUi/XUiClickClearGame/XUiClickClearPanelCountdown.lua create mode 100644 Resources/Scripts/XUi/XUiClickClearGame/XUiClickClearPanelGame.lua create mode 100644 Resources/Scripts/XUi/XUiClickClearGame/XUiClickClearPanelGameBookMark.lua create mode 100644 Resources/Scripts/XUi/XUiClickClearGame/XUiClickClearPanelGameRewardData.lua create mode 100644 Resources/Scripts/XUi/XUiClickClearGame/XUiClickClearPanelGameTask.lua create mode 100644 Resources/Scripts/XUi/XUiClickClearGame/XUiClickClearPanelGeneral.lua create mode 100644 Resources/Scripts/XUi/XUiClickClearGame/XUiClickClearPanelGeneralClearance.lua create mode 100644 Resources/Scripts/XUi/XUiClickClearGame/XUiClickClearPanelGeneralDefault.lua create mode 100644 Resources/Scripts/XUi/XUiClickClearGame/XUiClickClearPanelGeneralFailure.lua create mode 100644 Resources/Scripts/XUi/XUiClickClearGame/XUiClickClearReward.lua create mode 100644 Resources/Scripts/XUi/XUiClickClearGame/XUiGridClickClearGameHead.lua create mode 100644 Resources/Scripts/XUi/XUiClickClearGame/XUiGridClickClearGamePage.lua create mode 100644 Resources/Scripts/XUi/XUiClickClearGame/XUiGridClickClearReward.lua create mode 100644 Resources/Scripts/XUi/XUiCollectionWall/XUiCollectionWall.lua create mode 100644 Resources/Scripts/XUi/XUiCollectionWall/XUiCollectionWallEdit.lua create mode 100644 Resources/Scripts/XUi/XUiCollectionWall/XUiCollectionWallGrid/XUiGridCollectionWall.lua create mode 100644 Resources/Scripts/XUi/XUiCollectionWall/XUiCollectionWallGrid/XUiGridPlacedCollection.lua create mode 100644 Resources/Scripts/XUi/XUiCollectionWall/XUiCollectionWallGrid/XUiGridPlacedCollectionOther.lua create mode 100644 Resources/Scripts/XUi/XUiCollectionWall/XUiCollectionWallGrid/XUiGridSelectItem.lua create mode 100644 Resources/Scripts/XUi/XUiCollectionWall/XUiCollectionWallGrid/XUiGridViewCollection.lua create mode 100644 Resources/Scripts/XUi/XUiCollectionWall/XUiCollectionWallOther.lua create mode 100644 Resources/Scripts/XUi/XUiCollectionWall/XUiCollectionWallSetting.lua create mode 100644 Resources/Scripts/XUi/XUiCollectionWall/XUiCollectionWallView.lua create mode 100644 Resources/Scripts/XUi/XUiComeAcross/ComeAcrossClickGamePlayer.lua create mode 100644 Resources/Scripts/XUi/XUiComeAcross/ComeAcrossEliminateGamePlayer.lua create mode 100644 Resources/Scripts/XUi/XUiComeAcross/ComeAcrossGamePlayer.lua create mode 100644 Resources/Scripts/XUi/XUiComeAcross/XUiComeAcross.lua create mode 100644 Resources/Scripts/XUi/XUiComeAcross/XUiComeAcrossGame.lua create mode 100644 Resources/Scripts/XUi/XUiComeAcross/XUiGridElement.lua create mode 100644 Resources/Scripts/XUi/XUiComeAcross/XUiGridLevel.lua create mode 100644 Resources/Scripts/XUi/XUiComeAcross/XUiPanelComeAcrossReward.lua create mode 100644 Resources/Scripts/XUi/XUiComeAcross/XUiPanelEliminateGame.lua create mode 100644 Resources/Scripts/XUi/XUiComeAcross/XUiPanelGame.lua create mode 100644 Resources/Scripts/XUi/XUiComeAcross/XUiPanelStart.lua create mode 100644 Resources/Scripts/XUi/XUiComeAcross/XUiPanelTick.lua create mode 100644 Resources/Scripts/XUi/XUiCommon/XScrollView/XScrollConfig.lua create mode 100644 Resources/Scripts/XUi/XUiCommon/XScrollView/XScrollFlow.lua create mode 100644 Resources/Scripts/XUi/XUiCommon/XScrollView/XScrollFlowGrid.lua create mode 100644 Resources/Scripts/XUi/XUiCommon/XUiBaseComponent.lua create mode 100644 Resources/Scripts/XUi/XUiCommon/XUiBaseView.lua create mode 100644 Resources/Scripts/XUi/XUiCommon/XUiButtonLongClick.lua create mode 100644 Resources/Scripts/XUi/XUiCommon/XUiCommonAsset.lua create mode 100644 Resources/Scripts/XUi/XUiCommon/XUiCommonAssetPanel.lua create mode 100644 Resources/Scripts/XUi/XUiCommon/XUiCommonEnum.lua create mode 100644 Resources/Scripts/XUi/XUiCommon/XUiDynamicTable/XDynamicTableCurve.lua create mode 100644 Resources/Scripts/XUi/XUiCommon/XUiDynamicTable/XDynamicTableIrregular.lua create mode 100644 Resources/Scripts/XUi/XUiCommon/XUiDynamicTable/XDynamicTableNormal.lua create mode 100644 Resources/Scripts/XUi/XUiCommon/XUiMultClickHelper.lua create mode 100644 Resources/Scripts/XUi/XUiCommon/XUiNewRoomFightControl.lua create mode 100644 Resources/Scripts/XUi/XUiCommon/XUiPanelAsset.lua create mode 100644 Resources/Scripts/XUi/XUiCommon/XUiPlayerHead.lua create mode 100644 Resources/Scripts/XUi/XUiCommon/XUiPlayerLevel.lua create mode 100644 Resources/Scripts/XUi/XUiCommon/XUiSkipTip.lua create mode 100644 Resources/Scripts/XUi/XUiCommon/XUiStageFightControl.lua create mode 100644 Resources/Scripts/XUi/XUiCommon/XUiStageFightEvent.lua create mode 100644 Resources/Scripts/XUi/XUiCommon/XUiStageFightEventItem.lua create mode 100644 Resources/Scripts/XUi/XUiCommon/XUiTipLayer.lua create mode 100644 Resources/Scripts/XUi/XUiCommonWindow/XUiSelectCharacterGrid.lua create mode 100644 Resources/Scripts/XUi/XUiCommonWindow/XUiSelectCharacterWin.lua create mode 100644 Resources/Scripts/XUi/XUiCoupletGame/XUiCoupletAward.lua create mode 100644 Resources/Scripts/XUi/XUiCoupletGame/XUiCoupletGame.lua create mode 100644 Resources/Scripts/XUi/XUiCoupletGame/XUiCoupletRollPanel.lua create mode 100644 Resources/Scripts/XUi/XUiCoupletGame/XUiCoupletStageCtrlPanel.lua create mode 100644 Resources/Scripts/XUi/XUiCoupletGame/XUiGridCoupletTask.lua create mode 100644 Resources/Scripts/XUi/XUiCoupletGame/XUiGridWordImage.lua create mode 100644 Resources/Scripts/XUi/XUiCoupletGame/XUiGridWordItem.lua create mode 100644 Resources/Scripts/XUi/XUiDialog/UiDialogDrag.lua create mode 100644 Resources/Scripts/XUi/XUiDialog/XUiAssertDialog.lua create mode 100644 Resources/Scripts/XUi/XUiDialog/XUiCueMark.lua create mode 100644 Resources/Scripts/XUi/XUiDialog/XUiDialog.lua create mode 100644 Resources/Scripts/XUi/XUiDialog/XUiSystemDialog.lua create mode 100644 Resources/Scripts/XUi/XUiDorm/XUiBlackScreen/XUiBlackScreen.lua create mode 100644 Resources/Scripts/XUi/XUiDorm/XUiDormCommom/XUiFurnitureScore.lua create mode 100644 Resources/Scripts/XUi/XUiDorm/XUiDormCommom/XUiGridAttribute.lua create mode 100644 Resources/Scripts/XUi/XUiDorm/XUiDormCommom/XUiGridAttributeComparable.lua create mode 100644 Resources/Scripts/XUi/XUiDorm/XUiDormCommom/XUiRoomScore.lua create mode 100644 Resources/Scripts/XUi/XUiDorm/XUiFurnitureBuild/XUiFurnitureBuild.lua create mode 100644 Resources/Scripts/XUi/XUiDorm/XUiFurnitureBuild/XUiFurnitureCreate.lua create mode 100644 Resources/Scripts/XUi/XUiDorm/XUiFurnitureBuild/XUiGridCreate.lua create mode 100644 Resources/Scripts/XUi/XUiDorm/XUiFurnitureBuild/XUiGridInvestment.lua create mode 100644 Resources/Scripts/XUi/XUiDorm/XUiFurnitureBuild/XUiPanelCreate.lua create mode 100644 Resources/Scripts/XUi/XUiDorm/XUiFurnitureBuild/XUiPanelRefit.lua create mode 100644 Resources/Scripts/XUi/XUiDorm/XUiFurnitureReform/XUiFurnitureAttrGrid.lua create mode 100644 Resources/Scripts/XUi/XUiDorm/XUiFurnitureReform/XUiFurnitureReform.lua create mode 100644 Resources/Scripts/XUi/XUiDorm/XUiFurnitureReform/XUiGridFurniture.lua create mode 100644 Resources/Scripts/XUi/XUiDorm/XUiFurnitureReform/XUiGridOption.lua create mode 100644 Resources/Scripts/XUi/XUiDorm/XUiFurnitureReform/XUiPanelMenu.lua create mode 100644 Resources/Scripts/XUi/XUiDorm/XUiFurnitureReform/XUiPanelSViewFurniture.lua create mode 100644 Resources/Scripts/XUi/XUiDormBag/XUiDormBag.lua create mode 100644 Resources/Scripts/XUi/XUiDormBag/XUiGridDormCharacter.lua create mode 100644 Resources/Scripts/XUi/XUiDormBag/XUiGridDraft.lua create mode 100644 Resources/Scripts/XUi/XUiDormBag/XUiGridFurniture.lua create mode 100644 Resources/Scripts/XUi/XUiDormBag/XUiPanelDormBagItem.lua create mode 100644 Resources/Scripts/XUi/XUiDormBag/XUiRecyclePreview.lua create mode 100644 Resources/Scripts/XUi/XUiDormBagRecycle/XUiDormBagRecycle.lua create mode 100644 Resources/Scripts/XUi/XUiDormCharacterDetail/XUiDormCharacterDetail.lua create mode 100644 Resources/Scripts/XUi/XUiDormCharacterDetail/XUiDormCharacterLikeInfo.lua create mode 100644 Resources/Scripts/XUi/XUiDormCharacterDetail/XUiGridDetailDormCharacter.lua create mode 100644 Resources/Scripts/XUi/XUiDormCharacterDetail/XUiGridLikeInfo.lua create mode 100644 Resources/Scripts/XUi/XUiDormCharacterDetail/XUiPanelCharacterLikeInfo.lua create mode 100644 Resources/Scripts/XUi/XUiDormComponent/XUiDormComponent.lua create mode 100644 Resources/Scripts/XUi/XUiDormComponent/XUiFurnitureAttrObj.lua create mode 100644 Resources/Scripts/XUi/XUiDormComponent/XUiGrid3DObj.lua create mode 100644 Resources/Scripts/XUi/XUiDormComponent/XUiGridDialogBox.lua create mode 100644 Resources/Scripts/XUi/XUiDormComponent/XUiPanelExp.lua create mode 100644 Resources/Scripts/XUi/XUiDormComponent/XUiPanelExpDetail.lua create mode 100644 Resources/Scripts/XUi/XUiDormComponent/XUiPanelPutOn.lua create mode 100644 Resources/Scripts/XUi/XUiDormComponent/XUiPanelTouch.lua create mode 100644 Resources/Scripts/XUi/XUiDormFieldGuide/XUiDormFieldGuide.lua create mode 100644 Resources/Scripts/XUi/XUiDormFieldGuide/XUiDormFieldGuideDes.lua create mode 100644 Resources/Scripts/XUi/XUiDormFieldGuide/XUiDormFieldGuideDesListItem.lua create mode 100644 Resources/Scripts/XUi/XUiDormFieldGuide/XUiDormFieldGuideGridItem.lua create mode 100644 Resources/Scripts/XUi/XUiDormFieldGuide/XUiDormFieldGuideListItem.lua create mode 100644 Resources/Scripts/XUi/XUiDormFieldGuide/XUiDormFieldGuideSeleItem.lua create mode 100644 Resources/Scripts/XUi/XUiDormFieldGuide/XUiDormFieldGuideTab.lua create mode 100644 Resources/Scripts/XUi/XUiDormMain/XUiDormMain.lua create mode 100644 Resources/Scripts/XUi/XUiDormMain/XUiDormMainAttItem.lua create mode 100644 Resources/Scripts/XUi/XUiDormMain/XUiDormMainItem.lua create mode 100644 Resources/Scripts/XUi/XUiDormPerson/XUiDormPerson.lua create mode 100644 Resources/Scripts/XUi/XUiDormPerson/XUiDormPersonAttDesItem.lua create mode 100644 Resources/Scripts/XUi/XUiDormPerson/XUiDormPersonListItem.lua create mode 100644 Resources/Scripts/XUi/XUiDormPerson/XUiDormPersonSelect.lua create mode 100644 Resources/Scripts/XUi/XUiDormPerson/XUiDormPersonSelectListItem.lua create mode 100644 Resources/Scripts/XUi/XUiDormPerson/XUiDormPersonSingleItem.lua create mode 100644 Resources/Scripts/XUi/XUiDormSecond/XUiDormBgm.lua create mode 100644 Resources/Scripts/XUi/XUiDormSecond/XUiDormBgmGrid.lua create mode 100644 Resources/Scripts/XUi/XUiDormSecond/XUiDormCaress.lua create mode 100644 Resources/Scripts/XUi/XUiDormSecond/XUiDormNameGridItem.lua create mode 100644 Resources/Scripts/XUi/XUiDormSecond/XUiDormReName.lua create mode 100644 Resources/Scripts/XUi/XUiDormSecond/XUiDormSecond.lua create mode 100644 Resources/Scripts/XUi/XUiDormSecond/XUiDormSecondHead.lua create mode 100644 Resources/Scripts/XUi/XUiDormSecond/XUiGridLikeInfo.lua create mode 100644 Resources/Scripts/XUi/XUiDormSecond/XUiPanelEventShow.lua create mode 100644 Resources/Scripts/XUi/XUiDormSecond/XUiPanelFurnitureLike.lua create mode 100644 Resources/Scripts/XUi/XUiDormTask/XUiDormTask.lua create mode 100644 Resources/Scripts/XUi/XUiDormTask/XUiPanelDormTaskActivity.lua create mode 100644 Resources/Scripts/XUi/XUiDormTask/XUiPanelDormTaskDaily.lua create mode 100644 Resources/Scripts/XUi/XUiDormTask/XUiPanelDormTaskStory.lua create mode 100644 Resources/Scripts/XUi/XUiDormTemplate/XUiDormTemplate.lua create mode 100644 Resources/Scripts/XUi/XUiDormTemplate/XUiDormTemplateDetail.lua create mode 100644 Resources/Scripts/XUi/XUiDormTemplate/XUiDormTemplateScene.lua create mode 100644 Resources/Scripts/XUi/XUiDormTemplate/XUiDormTemplateShare.lua create mode 100644 Resources/Scripts/XUi/XUiDormTemplate/XUiGridDormTemplate.lua create mode 100644 Resources/Scripts/XUi/XUiDormTemplate/XUiGridFurnitreTemplate.lua create mode 100644 Resources/Scripts/XUi/XUiDormTemplate/XUiGridTemplateDetail.lua create mode 100644 Resources/Scripts/XUi/XUiDormTemplate/XUiGridTemplateSave.lua create mode 100644 Resources/Scripts/XUi/XUiDormTemplate/XUiGridTemplateSelectRoom.lua create mode 100644 Resources/Scripts/XUi/XUiDormTemplate/XUiPanelEncoding.lua create mode 100644 Resources/Scripts/XUi/XUiDormTemplate/XUiPanelFunitureList.lua create mode 100644 Resources/Scripts/XUi/XUiDormTemplate/XUiPanelRefitQuick.lua create mode 100644 Resources/Scripts/XUi/XUiDormTemplate/XUiPanelSave.lua create mode 100644 Resources/Scripts/XUi/XUiDormTemplate/XUiPanelTemlateSelectRoom.lua create mode 100644 Resources/Scripts/XUi/XUiDormVisit/XUiDormVisit.lua create mode 100644 Resources/Scripts/XUi/XUiDormVisit/XUiDormVisitGridItem.lua create mode 100644 Resources/Scripts/XUi/XUiDormVisit/XUiDormVisitTypeListItem.lua create mode 100644 Resources/Scripts/XUi/XUiDormWork/XUiDormFoundryDetail.lua create mode 100644 Resources/Scripts/XUi/XUiDormWork/XUiDormFoundryDetailItem.lua create mode 100644 Resources/Scripts/XUi/XUiDormWork/XUiDormFoundryDetailRewardItem.lua create mode 100644 Resources/Scripts/XUi/XUiDormWork/XUiDormWork.lua create mode 100644 Resources/Scripts/XUi/XUiDormWork/XUiDormWorkGridItem.lua create mode 100644 Resources/Scripts/XUi/XUiDormWork/XUiDormWorkListItem.lua create mode 100644 Resources/Scripts/XUi/XUiDormWork/XUiDormWorkMember.lua create mode 100644 Resources/Scripts/XUi/XUiDormWork/XUiDormWorkMemberGridItem.lua create mode 100644 Resources/Scripts/XUi/XUiDormWork/XUiDormWorkMemberListItem.lua create mode 100644 Resources/Scripts/XUi/XUiDraw/UiDrawPurchaseLB.lua create mode 100644 Resources/Scripts/XUi/XUiDraw/XUiChangeCombination.lua create mode 100644 Resources/Scripts/XUi/XUiDraw/XUiDraw.lua create mode 100644 Resources/Scripts/XUi/XUiDraw/XUiDrawBuyVoucher.lua create mode 100644 Resources/Scripts/XUi/XUiDraw/XUiDrawControl.lua create mode 100644 Resources/Scripts/XUi/XUiDraw/XUiDrawGroup.lua create mode 100644 Resources/Scripts/XUi/XUiDraw/XUiDrawLog.lua create mode 100644 Resources/Scripts/XUi/XUiDraw/XUiDrawOptional.lua create mode 100644 Resources/Scripts/XUi/XUiDraw/XUiDrawPreview.lua create mode 100644 Resources/Scripts/XUi/XUiDraw/XUiDrawResult.lua create mode 100644 Resources/Scripts/XUi/XUiDraw/XUiDrawRule.lua create mode 100644 Resources/Scripts/XUi/XUiDraw/XUiDrawShow.lua create mode 100644 Resources/Scripts/XUi/XUiDraw/XUiDrawSuitPreview.lua create mode 100644 Resources/Scripts/XUi/XUiDraw/XUiDrawTools/XUiDrawBox.lua create mode 100644 Resources/Scripts/XUi/XUiDraw/XUiDrawTools/XUiDrawCamera.lua create mode 100644 Resources/Scripts/XUi/XUiDraw/XUiDrawTools/XUiDrawCharacterRecord.lua create mode 100644 Resources/Scripts/XUi/XUiDraw/XUiDrawTools/XUiDrawRemainTime.lua create mode 100644 Resources/Scripts/XUi/XUiDraw/XUiDrawTools/XUiDrawScene.lua create mode 100644 Resources/Scripts/XUi/XUiDraw/XUiDrawTools/XUiDrawShowEffect.lua create mode 100644 Resources/Scripts/XUi/XUiDraw/XUiDrawTools/XUiDrawWeapon.lua create mode 100644 Resources/Scripts/XUi/XUiDraw/XUiGridDrawGroupBanner.lua create mode 100644 Resources/Scripts/XUi/XUiDraw/XUiGridDrawSet.lua create mode 100644 Resources/Scripts/XUi/XUiDraw/XUiGridGain.lua create mode 100644 Resources/Scripts/XUi/XUiDraw/XUiNewDrawMain.lua create mode 100644 Resources/Scripts/XUi/XUiDraw/XUiNewGridDrawBanner.lua create mode 100644 Resources/Scripts/XUi/XUiDraw/XUiPanelCombination.lua create mode 100644 Resources/Scripts/XUi/XUiDraw/XUiPanelProbability.lua create mode 100644 Resources/Scripts/XUi/XUiDraw/XUiTogDrawGroup.lua create mode 100644 Resources/Scripts/XUi/XUiDraw/XUiTogDrawGroupTab.lua create mode 100644 Resources/Scripts/XUi/XUiEnterFight/XUiEnterFight.lua create mode 100644 Resources/Scripts/XUi/XUiEquipAwarenessReplace/XUiEquipAwarenessPopup.lua create mode 100644 Resources/Scripts/XUi/XUiEquipAwarenessReplace/XUiEquipAwarenessReplace.lua create mode 100644 Resources/Scripts/XUi/XUiEquipAwarenessReplace/XUiEquipAwarenessSuitPrefab.lua create mode 100644 Resources/Scripts/XUi/XUiEquipAwarenessReplace/XUiEquipSuitPrefabConfirm.lua create mode 100644 Resources/Scripts/XUi/XUiEquipAwarenessReplace/XUiEquipSuitPrefabConflict.lua create mode 100644 Resources/Scripts/XUi/XUiEquipAwarenessReplace/XUiEquipSuitPrefabRename.lua create mode 100644 Resources/Scripts/XUi/XUiEquipAwarenessReplace/XUiGridEquip.lua create mode 100644 Resources/Scripts/XUi/XUiEquipAwarenessReplace/XUiGridSuitDetail.lua create mode 100644 Resources/Scripts/XUi/XUiEquipAwarenessReplace/XUiGridSuitPrefab.lua create mode 100644 Resources/Scripts/XUi/XUiEquipAwarenessReplace/XUiGridSuitPrefabEquip.lua create mode 100644 Resources/Scripts/XUi/XUiEquipAwarenessReplace/XUiPanelEquipScroll.lua create mode 100644 Resources/Scripts/XUi/XUiEquipAwarenessReplace/XUiPanelSuitDetailScroll.lua create mode 100644 Resources/Scripts/XUi/XUiEquipAwarenessReplace/XUiPanelSuitSimpleScroll.lua create mode 100644 Resources/Scripts/XUi/XUiEquipBreakThrough/XUiEquipBreakThrough.lua create mode 100644 Resources/Scripts/XUi/XUiEquipBreakThrough/XUiEquipBreakThroughPopUp.lua create mode 100644 Resources/Scripts/XUi/XUiEquipBreakThrough/XUiEquipCanBreakthroughTip.lua create mode 100644 Resources/Scripts/XUi/XUiEquipBreakThrough/XUiEquipLevelUpTips.lua create mode 100644 Resources/Scripts/XUi/XUiEquipBreakThrough/XUiGridCostItem.lua create mode 100644 Resources/Scripts/XUi/XUiEquipDetail/XUiEquipDetail.lua create mode 100644 Resources/Scripts/XUi/XUiEquipDetail/XUiEquipDetailChild.lua create mode 100644 Resources/Scripts/XUi/XUiEquipReplaceNew/XUiEquipReplaceNew.lua create mode 100644 Resources/Scripts/XUi/XUiEquipReplaceNew/XUiEquipResonanceSkillDetailInfo.lua create mode 100644 Resources/Scripts/XUi/XUiEquipReplaceNew/XUiGridEquipReplaceAttr.lua create mode 100644 Resources/Scripts/XUi/XUiEquipResonanceSelect/XUiEquipResonanceAwake.lua create mode 100644 Resources/Scripts/XUi/XUiEquipResonanceSelect/XUiEquipResonanceSelect.lua create mode 100644 Resources/Scripts/XUi/XUiEquipResonanceSelect/XUiEquipResonanceSelectAfter.lua create mode 100644 Resources/Scripts/XUi/XUiEquipResonanceSelect/XUiEquipResonanceSelectCharacter.lua create mode 100644 Resources/Scripts/XUi/XUiEquipResonanceSelect/XUiEquipResonanceSelectEquip.lua create mode 100644 Resources/Scripts/XUi/XUiEquipResonanceSelect/XUiEquipResonanceSelectItem.lua create mode 100644 Resources/Scripts/XUi/XUiEquipResonanceSkill/XUiEquipResonanceSkill.lua create mode 100644 Resources/Scripts/XUi/XUiEquipResonanceSkill/XUiEquipResonanceSkillPreview.lua create mode 100644 Resources/Scripts/XUi/XUiEquipResonanceSkill/XUiGridDoubleResonanceSkill.lua create mode 100644 Resources/Scripts/XUi/XUiEquipResonanceSkill/XUiGridEquipResonanceSkillPreview.lua create mode 100644 Resources/Scripts/XUi/XUiEquipResonanceSkill/XUiGridResonanceSkill.lua create mode 100644 Resources/Scripts/XUi/XUiEquipStrengthen/XUiEquipStrengthen.lua create mode 100644 Resources/Scripts/XUi/XUiEquipStrengthen/XUiGridEquipExpItem.lua create mode 100644 Resources/Scripts/XUi/XUiEquipStrengthenSkip/XUiEquipStrengthenSkip.lua create mode 100644 Resources/Scripts/XUi/XUiExhibition/XUiExhibition.lua create mode 100644 Resources/Scripts/XUi/XUiExhibition/XUiExhibitionGroupTip.lua create mode 100644 Resources/Scripts/XUi/XUiExhibition/XUiExhibitionInfo.lua create mode 100644 Resources/Scripts/XUi/XUiExhibition/XUiGridCharacterIcon.lua create mode 100644 Resources/Scripts/XUi/XUiExhibition/XUiGridCharacterName.lua create mode 100644 Resources/Scripts/XUi/XUiExhibition/XUiGridCondition.lua create mode 100644 Resources/Scripts/XUi/XUiExhibition/XUiGridGroupIcon.lua create mode 100644 Resources/Scripts/XUi/XUiExhibition/XUiGridGroupName.lua create mode 100644 Resources/Scripts/XUi/XUiExhibition/XUiPanelCollection.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/Battle/ChangeMember/XUiExpeditionRoomCharListGrid.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/Battle/ChangeMember/XUiExpeditionRoomCharListPanel.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/Battle/ChangeMember/XUiExpeditionRoomCharacter.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/Battle/XUiExpeditionInfinityCombo.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/Battle/XUiExpeditionInfinityComboList.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/Battle/XUiExpeditionInfinityHeadIcon.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/Battle/XUiExpeditionInfinityWin.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/Battle/XUiExpeditionNewRoomSingle.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/Battle/XUiExpeditionSettleWin.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/Battle/XUiExpeditionSettleWinHeadIcon.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/ComboList/XUiEXpeditionComboTipsHeadIcon.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/ComboList/XUiExpeditionComboTips.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/ComboList/XUiExpeditionComboTipsItem.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/ComboList/XUiExpeditionComboTipsItemPanel.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/ComboList/XUiExpeditionComboTipsTab.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/MainPage/ChapterBuff/XUiExpeditionBuffTips.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/MainPage/ChapterBuff/XUiExpeditionBuffTipsItem.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/MainPage/ChapterBuff/XUiGlobalComboIcon.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/MainPage/StageDetail/XUiExpeditionStageBattleDetail.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/MainPage/StageDetail/XUiExpeditionStageBuffIcon.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/MainPage/StageDetail/XUiExpeditionStageInfinityDetail.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/MainPage/StageDetail/XUiExpeditionStageStoryDetail.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/MainPage/XUiExpeditionChapter.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/MainPage/XUiExpeditionChapterComponent.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/MainPage/XUiExpeditionMain.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/MainPage/XUiExpeditionStageDetail.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/MainPage/XUiExpeditionStageDetailComponent.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/Ranking/XUiExpeditionMyRank.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/Ranking/XUiExpeditionRankGrid.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/Ranking/XUiExpeditionRankInfo.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/Ranking/XUiExpeditionRankList.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/Ranking/XUiExpeditionRanking.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionComboPanel/XUiExpeditionComboGrid.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionComboPanel/XUiExpeditionComboPhase.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionComboPanel/XUiExpeditionRecruitComboPanel.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionDrawPR.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionLevelTips/XUiExpeditionLevelTips.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionMemberPanel/XUiExpeditionRecruitMemberGrid.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionMemberPanel/XUiExpeditionRecruitMemberPanel.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionPublicity.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionPublicityTitle.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionRecruit.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionRoleDetails/MessageBoard/XUiExpeditionGuesBook.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionRoleDetails/MessageBoard/XUiExpeditionMessageItem.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionRoleDetails/MessageBoard/XUiExpeditionMessageItemList.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionRoleDetails/XUiExpeditionComboIconGrid.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionRoleDetails/XUiExpeditionComboIconPanel.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionRoleDetails/XUiExpeditionRoleDetails.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionRoleDetails/XUiExpeditionSkillIconGrid.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionRoomChar/XUiExpeditionRecruitShopGrid.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionRoomChar/XUiExpeditionRecruitShopPanel.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/RoleList/CharacterDetail/XUiExpeditionCharProperty.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/RoleList/CharacterDetail/XUiExpeditionCharSkill.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/RoleList/CharacterDetail/XUiExpeditionViewRole.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/RoleList/EquipDetail/XUiExpeditionEquipDetail.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/RoleList/EquipDetail/XUiExpeditionEquipDetailChild.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/RoleList/XUiExpeditionEquipGrid/XUiExpeditionEquipGrid.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/RoleList/XUiExpeditionRoleList.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/RoleList/XUiExpeditionRoleListCharaInfo/XUiExpeditionRoleListCharaInfo.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/RoleList/XUiExpeditionRoleListCharacterPanel/XUiExpeditionRoleListCharacterGrid.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/RoleList/XUiExpeditionRoleListCharacterPanel/XUiExpeditionRoleListCharacterList.lua create mode 100644 Resources/Scripts/XUi/XUiExpedition/RoleList/XUiExpeditionRoleListComboPanel/XUiExpeditionRoleListComboList.lua create mode 100644 Resources/Scripts/XUi/XUiFashion/XUiFashion.lua create mode 100644 Resources/Scripts/XUi/XUiFashion/XUiFashionDetail.lua create mode 100644 Resources/Scripts/XUi/XUiFashion/XUiGridFashion.lua create mode 100644 Resources/Scripts/XUi/XUiFashion/XUiGridWeaponFashion.lua create mode 100644 Resources/Scripts/XUi/XUiFashion/XUiPanelFashionList.lua create mode 100644 Resources/Scripts/XUi/XUiFavorability/XUiFavorability.lua create mode 100644 Resources/Scripts/XUi/XUiFavorability/XUiFavorabilityLineRoomCharacter.lua create mode 100644 Resources/Scripts/XUi/XUiFavorability/XUiFavorabilityNew.lua create mode 100644 Resources/Scripts/XUi/XUiFavorability/XUiGridLikeActionItem.lua create mode 100644 Resources/Scripts/XUi/XUiFavorability/XUiGridLikeAudioItem.lua create mode 100644 Resources/Scripts/XUi/XUiFavorability/XUiGridLikeInfoItem.lua create mode 100644 Resources/Scripts/XUi/XUiFavorability/XUiGridLikeMessageItem.lua create mode 100644 Resources/Scripts/XUi/XUiFavorability/XUiGridLikePlotItem.lua create mode 100644 Resources/Scripts/XUi/XUiFavorability/XUiGridLikeRoleItem.lua create mode 100644 Resources/Scripts/XUi/XUiFavorability/XUiGridLikeRumorItem.lua create mode 100644 Resources/Scripts/XUi/XUiFavorability/XUiGridLikeSendGiftItem.lua create mode 100644 Resources/Scripts/XUi/XUiFavorability/XUiGridLineCharacter.lua create mode 100644 Resources/Scripts/XUi/XUiFavorability/XUiPanelFavorabilityAction.lua create mode 100644 Resources/Scripts/XUi/XUiFavorability/XUiPanelFavorabilityAudio.lua create mode 100644 Resources/Scripts/XUi/XUiFavorability/XUiPanelFavorabilityDocument.lua create mode 100644 Resources/Scripts/XUi/XUiFavorability/XUiPanelFavorabilityExchangeRole.lua create mode 100644 Resources/Scripts/XUi/XUiFavorability/XUiPanelFavorabilityFile.lua create mode 100644 Resources/Scripts/XUi/XUiFavorability/XUiPanelFavorabilityInfo.lua create mode 100644 Resources/Scripts/XUi/XUiFavorability/XUiPanelFavorabilityMain.lua create mode 100644 Resources/Scripts/XUi/XUiFavorability/XUiPanelFavorabilityMessage.lua create mode 100644 Resources/Scripts/XUi/XUiFavorability/XUiPanelFavorabilityPlot.lua create mode 100644 Resources/Scripts/XUi/XUiFavorability/XUiPanelFavorabilityRumors.lua create mode 100644 Resources/Scripts/XUi/XUiFavorability/XUiPanelLikeGiveGift.lua create mode 100644 Resources/Scripts/XUi/XUiFestivalActivity/XUiFestivalActivityNewRoomSingle.lua create mode 100644 Resources/Scripts/XUi/XUiFestivalActivity/XUiFestivalStageItem.lua create mode 100644 Resources/Scripts/XUi/XUiFestivalActivity/XUiFubenChristmasMainLineChapter.lua create mode 100644 Resources/Scripts/XUi/XUiFestivalActivity/XUiFubenChristmasStageDetail.lua create mode 100644 Resources/Scripts/XUi/XUiFestivalActivity/XUiStoryChristmasStageDetail.lua create mode 100644 Resources/Scripts/XUi/XUiFightButtonSettings/XUiFightButtonSettings.lua create mode 100644 Resources/Scripts/XUi/XUiFightInfestorExplore/XUiFightInfestorExplore.lua create mode 100644 Resources/Scripts/XUi/XUiFightInfestorExplore/XUiGridFightInfestorPlayer.lua create mode 100644 Resources/Scripts/XUi/XUiFightInfestorExplore/XUiGridFightInfestorRuler.lua create mode 100644 Resources/Scripts/XUi/XUiFightWords/XUiFightWords.lua create mode 100644 Resources/Scripts/XUi/XUiFirstGetPopUp/XUiFirstGetPopUp.lua create mode 100644 Resources/Scripts/XUi/XUiFuben/XUiFuben.lua create mode 100644 Resources/Scripts/XUi/XUiFubenActivityBanner/XUiFubenActivityBanner.lua create mode 100644 Resources/Scripts/XUi/XUiFubenActivityBanner/XUiGridActivityBanner.lua create mode 100644 Resources/Scripts/XUi/XUiFubenActivityPuzzle/XUiFubenActivityPuzzle.lua create mode 100644 Resources/Scripts/XUi/XUiFubenActivityPuzzle/XUiFubenActivityPuzzleAreaRewardBtn.lua create mode 100644 Resources/Scripts/XUi/XUiFubenActivityPuzzle/XUiFubenActivityPuzzleGamePanel.lua create mode 100644 Resources/Scripts/XUi/XUiFubenActivityPuzzle/XUiFubenActivityPuzzlePassword.lua create mode 100644 Resources/Scripts/XUi/XUiFubenActivityPuzzle/XUiFubenActivityPuzzlePasswordRewardPanel.lua create mode 100644 Resources/Scripts/XUi/XUiFubenActivityPuzzle/XUiFubenActivityPuzzlePieceItem.lua create mode 100644 Resources/Scripts/XUi/XUiFubenActivityPuzzle/XUiFubenActivityPuzzleRewardPanel.lua create mode 100644 Resources/Scripts/XUi/XUiFubenActivityPuzzle/XUiPuzzleDercyptionPasswordItem.lua create mode 100644 Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelMemberHead.lua create mode 100644 Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelMemberSmallHead.lua create mode 100644 Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerAutoFight.lua create mode 100644 Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerBase.lua create mode 100644 Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerChallengeChoice.lua create mode 100644 Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerChallengeSelect.lua create mode 100644 Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerChildChallenge.lua create mode 100644 Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerChildSupport.lua create mode 100644 Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerDetails.lua create mode 100644 Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerFightTips.lua create mode 100644 Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerMainNew.lua create mode 100644 Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerMyRankInfos.lua create mode 100644 Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerRankInfo.lua create mode 100644 Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerRankReward.lua create mode 100644 Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerRoomCharacter.lua create mode 100644 Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerSelectDiffcult.lua create mode 100644 Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerSelectTeam.lua create mode 100644 Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerSupportChoice.lua create mode 100644 Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerTask.lua create mode 100644 Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerTeamTips.lua create mode 100644 Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerTipsItem.lua create mode 100644 Resources/Scripts/XUi/XUiFubenBabelTower/XUiFubenBabelTowerRank.lua create mode 100644 Resources/Scripts/XUi/XUiFubenBabelTower/XUiGridAutoFightMember.lua create mode 100644 Resources/Scripts/XUi/XUiFubenBabelTower/XUiGridBabelChallengeItem.lua create mode 100644 Resources/Scripts/XUi/XUiFubenBabelTower/XUiGridBabelSelectDifficult.lua create mode 100644 Resources/Scripts/XUi/XUiFubenBabelTower/XUiGridBabelSelectTeam.lua create mode 100644 Resources/Scripts/XUi/XUiFubenBabelTower/XUiGridBabelStageItem.lua create mode 100644 Resources/Scripts/XUi/XUiFubenBabelTower/XUiGridInfoBuffItem.lua create mode 100644 Resources/Scripts/XUi/XUiFubenBabelTower/XUiGridInfoChallengeItem.lua create mode 100644 Resources/Scripts/XUi/XUiFubenBabelTower/XUiGridInfoEnvironmentItem.lua create mode 100644 Resources/Scripts/XUi/XUiFubenBabelTower/XUiGridInfoSupportCondition.lua create mode 100644 Resources/Scripts/XUi/XUiFubenBabelTower/XUiGridRankItemInfo.lua create mode 100644 Resources/Scripts/XUi/XUiFubenBabelTower/XUiGridRankRewardItem.lua create mode 100644 Resources/Scripts/XUi/XUiFubenBossSingle/XUiFubenBossSingle.lua create mode 100644 Resources/Scripts/XUi/XUiFubenBossSingle/XUiFubenBossSingleChooseLevelType.lua create mode 100644 Resources/Scripts/XUi/XUiFubenBossSingle/XUiFubenBossSingleHide.lua create mode 100644 Resources/Scripts/XUi/XUiFubenBossSingle/XUiGridBossRank.lua create mode 100644 Resources/Scripts/XUi/XUiFubenBossSingle/XUiGridBossRankReward.lua create mode 100644 Resources/Scripts/XUi/XUiFubenBossSingle/XUiGridBossScore.lua create mode 100644 Resources/Scripts/XUi/XUiFubenBossSingle/XUiGridBossSkill.lua create mode 100644 Resources/Scripts/XUi/XUiFubenBossSingle/XUiPanelAutoFight.lua create mode 100644 Resources/Scripts/XUi/XUiFubenBossSingle/XUiPanelBossDetail.lua create mode 100644 Resources/Scripts/XUi/XUiFubenBossSingle/XUiPanelBossDetailTip.lua create mode 100644 Resources/Scripts/XUi/XUiFubenBossSingle/XUiPanelBossEnter.lua create mode 100644 Resources/Scripts/XUi/XUiFubenBossSingle/XUiPanelBossRankInfo.lua create mode 100644 Resources/Scripts/XUi/XUiFubenBossSingle/XUiPanelBossStgae.lua create mode 100644 Resources/Scripts/XUi/XUiFubenBossSingle/XUiPanelGroupInfo.lua create mode 100644 Resources/Scripts/XUi/XUiFubenBossSingle/XUiPanelMyBossRank.lua create mode 100644 Resources/Scripts/XUi/XUiFubenBossSingle/XUiPanelRankReward.lua create mode 100644 Resources/Scripts/XUi/XUiFubenBossSingle/XUiPanelScoreInfo.lua create mode 100644 Resources/Scripts/XUi/XUiFubenChallengeBanner/XUiFubenChallengeBanner.lua create mode 100644 Resources/Scripts/XUi/XUiFubenChallengeBanner/XUiGridChallengeBanner.lua create mode 100644 Resources/Scripts/XUi/XUiFubenChallengeEMEX/XUiFubenChallengeEMEX.lua create mode 100644 Resources/Scripts/XUi/XUiFubenChallengeMap/XUiFubenChallengeMap.lua create mode 100644 Resources/Scripts/XUi/XUiFubenChallengeMap/XUiGridChallengePlayerState.lua create mode 100644 Resources/Scripts/XUi/XUiFubenChallengeMap/XUiPanelJieduan.lua create mode 100644 Resources/Scripts/XUi/XUiFubenChallengeMapEmex/XUiFubenChallengeMapEmex.lua create mode 100644 Resources/Scripts/XUi/XUiFubenChallengeUrgent/XUiFubenChallengeUrgent.lua create mode 100644 Resources/Scripts/XUi/XUiFubenChallengeYSHTX/XUiFubenChallengeYSHTX.lua create mode 100644 Resources/Scripts/XUi/XUiFubenChallengeYSHTX/XUiPanelYSHTXStageTemplate.lua create mode 100644 Resources/Scripts/XUi/XUiFubenCoinSkill/XUiFubenCoinSkill.lua create mode 100644 Resources/Scripts/XUi/XUiFubenCoinSkill/XUiPanelFubenTab.lua create mode 100644 Resources/Scripts/XUi/XUiFubenCoupleCombat/ChildItem/XUiStageItem.lua create mode 100644 Resources/Scripts/XUi/XUiFubenCoupleCombat/ChildView/XUiCoupleCombatChapter.lua create mode 100644 Resources/Scripts/XUi/XUiFubenCoupleCombat/ChildView/XUiPanelFeature.lua create mode 100644 Resources/Scripts/XUi/XUiFubenCoupleCombat/Proxy/XUiCoupleCombatNewRoomSingle.lua create mode 100644 Resources/Scripts/XUi/XUiFubenCoupleCombat/Proxy/XUiCoupleCombatRoomCharacter.lua create mode 100644 Resources/Scripts/XUi/XUiFubenCoupleCombat/XUiCoupleCombatMain.lua create mode 100644 Resources/Scripts/XUi/XUiFubenCoupleCombat/XUiFubenCoupleCombatDetail.lua create mode 100644 Resources/Scripts/XUi/XUiFubenDailyBanner/XUiFubenDailyBanner.lua create mode 100644 Resources/Scripts/XUi/XUiFubenDailyBanner/XUiFubenDailyBranch.lua create mode 100644 Resources/Scripts/XUi/XUiFubenDailyBanner/XUiFubenDailyDrop.lua create mode 100644 Resources/Scripts/XUi/XUiFubenDailyBanner/XUiFubenDailyStage.lua create mode 100644 Resources/Scripts/XUi/XUiFubenDailyBanner/XUiGridDailyBanner.lua create mode 100644 Resources/Scripts/XUi/XUiFubenDailyShop/XUiFubenDailyShop.lua create mode 100644 Resources/Scripts/XUi/XUiFubenDailyShop/XUiGridWaferSelect.lua create mode 100644 Resources/Scripts/XUi/XUiFubenDailyShop/XUiWaferSelect.lua create mode 100644 Resources/Scripts/XUi/XUiFubenDialog/XUiFubenDialog.lua create mode 100644 Resources/Scripts/XUi/XUiFubenExperiment/XUiFubenExperiment.lua create mode 100644 Resources/Scripts/XUi/XUiFubenExperiment/XUiFubenExperimentBanner.lua create mode 100644 Resources/Scripts/XUi/XUiFubenExperiment/XUiFubenExperimentDetail.lua create mode 100644 Resources/Scripts/XUi/XUiFubenExperiment/XUiFubenExperimentGridStar.lua create mode 100644 Resources/Scripts/XUi/XUiFubenExperiment/XUiFubenExperimentSkinTrialDetail.lua create mode 100644 Resources/Scripts/XUi/XUiFubenExplore/XUiFubenExploreBuff.lua create mode 100644 Resources/Scripts/XUi/XUiFubenExplore/XUiFubenExploreBuffDetail.lua create mode 100644 Resources/Scripts/XUi/XUiFubenExplore/XUiFubenExploreChapter.lua create mode 100644 Resources/Scripts/XUi/XUiFubenExplore/XUiFubenExploreLevel.lua create mode 100644 Resources/Scripts/XUi/XUiFubenExplore/XUiFubenExploreLevelNode.lua create mode 100644 Resources/Scripts/XUi/XUiFubenExplore/XUiFubenExploreQuickJumpBtn.lua create mode 100644 Resources/Scripts/XUi/XUiFubenExtra/XUiExtraChapterStoryDetail.lua create mode 100644 Resources/Scripts/XUi/XUiFubenExtra/XUiFubenExtraChapter.lua create mode 100644 Resources/Scripts/XUi/XUiFubenExtra/XUiFubenExtraChapterDetail.lua create mode 100644 Resources/Scripts/XUi/XUiFubenFashionStory/XUiFashionStoryChapter.lua create mode 100644 Resources/Scripts/XUi/XUiFubenFashionStory/XUiFashionStoryStageFightDetail.lua create mode 100644 Resources/Scripts/XUi/XUiFubenFashionStory/XUiFashionStoryStageStoryDetail.lua create mode 100644 Resources/Scripts/XUi/XUiFubenFashionStory/XUiFashionStoryStageTrialDetail.lua create mode 100644 Resources/Scripts/XUi/XUiFubenFashionStory/XUiFubenFashionStory.lua create mode 100644 Resources/Scripts/XUi/XUiFubenFashionStory/XUiGridFashionStoryStage.lua create mode 100644 Resources/Scripts/XUi/XUiFubenFashionStory/XUiGridFashionStoryTrial.lua create mode 100644 Resources/Scripts/XUi/XUiFubenFlopReward/XUiFubenFlopReward.lua create mode 100644 Resources/Scripts/XUi/XUiFubenFlopReward/XUiPanelRewardBox.lua create mode 100644 Resources/Scripts/XUi/XUiFubenHack/ChildItem/XUiGridLevelBuff.lua create mode 100644 Resources/Scripts/XUi/XUiFubenHack/ChildItem/XUiGridStageItem.lua create mode 100644 Resources/Scripts/XUi/XUiFubenHack/ChildItem/XUiGridStarReward.lua create mode 100644 Resources/Scripts/XUi/XUiFubenHack/ChildView/XUiPanelBuffDetail.lua create mode 100644 Resources/Scripts/XUi/XUiFubenHack/ChildView/XUiPanelLevelInfo.lua create mode 100644 Resources/Scripts/XUi/XUiFubenHack/ChildView/XUiPanelLineChapter.lua create mode 100644 Resources/Scripts/XUi/XUiFubenHack/Proxy/XUiHackNewRoomSingle.lua create mode 100644 Resources/Scripts/XUi/XUiFubenHack/Proxy/XUiHackRoomCharacter.lua create mode 100644 Resources/Scripts/XUi/XUiFubenHack/XUiFubenHack.lua create mode 100644 Resources/Scripts/XUi/XUiFubenHack/XUiFubenHackDetails.lua create mode 100644 Resources/Scripts/XUi/XUiFubenHack/XUiFubenHackSection.lua create mode 100644 Resources/Scripts/XUi/XUiFubenHack/XUiHackDevelop.lua create mode 100644 Resources/Scripts/XUi/XUiFubenHack/XUiHackLevelUpTips.lua create mode 100644 Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridChooseReward.lua create mode 100644 Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridFubenInfestorExploreChapter.lua create mode 100644 Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridFubenInfestorExploreChapter2Stage.lua create mode 100644 Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridFubenInfestorExploreMember.lua create mode 100644 Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridFubenInfestorExploreOccupiedPlayer.lua create mode 100644 Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridFubenInfestorExploreStage.lua create mode 100644 Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridInfestorExploreBuff.lua create mode 100644 Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridInfestorExploreContract.lua create mode 100644 Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridInfestorExploreCore.lua create mode 100644 Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridInfestorExploreEvent.lua create mode 100644 Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridInfestorExploreOutPostStory.lua create mode 100644 Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridInfestorExplorePlayerMessage.lua create mode 100644 Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridInfestorExploreRank.lua create mode 100644 Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridInfestorExploreRegionTitle.lua create mode 100644 Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridInfestorExploreShopGoods.lua create mode 100644 Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridInfestorShopReward.lua create mode 100644 Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreActivityResult.lua create mode 100644 Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreChapter.lua create mode 100644 Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreChapterDetail.lua create mode 100644 Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreChapterPart2.lua create mode 100644 Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreChapterPart2Detail.lua create mode 100644 Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreChoose.lua create mode 100644 Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreContract.lua create mode 100644 Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreCore.lua create mode 100644 Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreCoreDecompose.lua create mode 100644 Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreCoreLevelUp.lua create mode 100644 Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreCoreObtain.lua create mode 100644 Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreCorePopup.lua create mode 100644 Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreCoreShow.lua create mode 100644 Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreDebuff.lua create mode 100644 Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreFightResult.lua create mode 100644 Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreGuestbook.lua create mode 100644 Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreLevelDetail.lua create mode 100644 Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreOutpost.lua create mode 100644 Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreRank.lua create mode 100644 Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreShop.lua create mode 100644 Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreStage.lua create mode 100644 Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreStageDetailEvent.lua create mode 100644 Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreStageDetailFight.lua create mode 100644 Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreStageDetailOutPost.lua create mode 100644 Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreStageDetailRest.lua create mode 100644 Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreStageDetailReward.lua create mode 100644 Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreStageDetailRewardGive.lua create mode 100644 Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreStageDetailShop.lua create mode 100644 Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreStageDetailSupply.lua create mode 100644 Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreTeamEdit.lua create mode 100644 Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiPanelFubenInfestorExploreStages.lua create mode 100644 Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiPanelInfestorExploreBossRank.lua create mode 100644 Resources/Scripts/XUi/XUiFubenMainLineBanner/XUiFubenMainLineBanner.lua create mode 100644 Resources/Scripts/XUi/XUiFubenMainLineBanner/XUiGridChapterBfrt.lua create mode 100644 Resources/Scripts/XUi/XUiFubenMainLineBanner/XUiGridChapterDz.lua create mode 100644 Resources/Scripts/XUi/XUiFubenMainLineBanner/XUiGridChapterExtra.lua create mode 100644 Resources/Scripts/XUi/XUiFubenMainLineBanner/XUiGridMainLineBanner.lua create mode 100644 Resources/Scripts/XUi/XUiFubenMainLineBanner/XUiPanelChapterBfrt.lua create mode 100644 Resources/Scripts/XUi/XUiFubenMainLineBanner/XUiPanelChapterDz.lua create mode 100644 Resources/Scripts/XUi/XUiFubenMainLineBanner/XUiPanelChapterExtra.lua create mode 100644 Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiFubenExItemTip.lua create mode 100644 Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiFubenExploreDetail.lua create mode 100644 Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiFubenMainLineChapter.lua create mode 100644 Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiFubenMainLineQuickJumpBtn.lua create mode 100644 Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiGridChapter.lua create mode 100644 Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiGridExploreChapter.lua create mode 100644 Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiGridExploreItem.lua create mode 100644 Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiGridStage.lua create mode 100644 Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiGridTreasureGrade.lua create mode 100644 Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiPanelAutoFight.lua create mode 100644 Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiPanelBountyTask.lua create mode 100644 Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiPanelBountyTaskInGrid.lua create mode 100644 Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiPanelEchelon.lua create mode 100644 Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiPanelFightActive.lua create mode 100644 Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiPanelHideStageNor.lua create mode 100644 Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiPanelHideTagNor.lua create mode 100644 Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiPanelRewardTips.lua create mode 100644 Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiPanelStageActive.lua create mode 100644 Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiPanelStageLock.lua create mode 100644 Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiPanelStageSelected.lua create mode 100644 Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiPanelStars.lua create mode 100644 Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiPanelStoryActive.lua create mode 100644 Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiPanelStorySelected.lua create mode 100644 Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiPanelStoryUnactive.lua create mode 100644 Resources/Scripts/XUi/XUiFubenMainLineDetail/XUiFubenMainLineDetail.lua create mode 100644 Resources/Scripts/XUi/XUiFubenMainLineDetail/XUiGridStageStar.lua create mode 100644 Resources/Scripts/XUi/XUiFubenPartnerTeaching/XUiGridPartnerTeachingBanner.lua create mode 100644 Resources/Scripts/XUi/XUiFubenPartnerTeaching/XUiGridPartnerTeachingStage.lua create mode 100644 Resources/Scripts/XUi/XUiFubenPartnerTeaching/XUiPartnerTeachingBanner.lua create mode 100644 Resources/Scripts/XUi/XUiFubenPartnerTeaching/XUiPartnerTeachingChapter.lua create mode 100644 Resources/Scripts/XUi/XUiFubenPartnerTeaching/XUiPartnerTeachingChapterContent.lua create mode 100644 Resources/Scripts/XUi/XUiFubenPartnerTeaching/XUiPartnerTeachingFightDetail.lua create mode 100644 Resources/Scripts/XUi/XUiFubenPartnerTeaching/XUiPartnerTeachingStoryDetail.lua create mode 100644 Resources/Scripts/XUi/XUiFubenPractice/UiPracticeSingleDetail.lua create mode 100644 Resources/Scripts/XUi/XUiFubenPractice/XUiFubenPractice.lua create mode 100644 Resources/Scripts/XUi/XUiFubenPractice/XUiPanelPracticeAdvanced.lua create mode 100644 Resources/Scripts/XUi/XUiFubenPractice/XUiPanelPracticeBasics.lua create mode 100644 Resources/Scripts/XUi/XUiFubenPractice/XUiPanelPracticeCharacter.lua create mode 100644 Resources/Scripts/XUi/XUiFubenPractice/XUiPracticeBasicsStage.lua create mode 100644 Resources/Scripts/XUi/XUiFubenPractice/XUiPracticeSkillDetail.lua create mode 100644 Resources/Scripts/XUi/XUiFubenRepeatchallenge/XUiFubenRepeatChallengeNewChapter.lua create mode 100644 Resources/Scripts/XUi/XUiFubenRepeatchallenge/XUiFubenRepeatChallengeStageDetail.lua create mode 100644 Resources/Scripts/XUi/XUiFubenRepeatchallenge/XUiFubenRepeatchallenge.lua create mode 100644 Resources/Scripts/XUi/XUiFubenRepeatchallenge/XUiFubenRepeatchallengeLevelDes.lua create mode 100644 Resources/Scripts/XUi/XUiFubenRepeatchallenge/XUiGridFubenRepeatchallengeLevel.lua create mode 100644 Resources/Scripts/XUi/XUiFubenRepeatchallenge/XUiGridRewardLine.lua create mode 100644 Resources/Scripts/XUi/XUiFubenRepeatchallenge/XUiRepeatChallengeEnter.lua create mode 100644 Resources/Scripts/XUi/XUiFubenRepeatchallenge/XUiRepeatChallengeSettleWin.lua create mode 100644 Resources/Scripts/XUi/XUiFubenResourceDetail/XUiFubenResourceDetail.lua create mode 100644 Resources/Scripts/XUi/XUiFubenRogueLike/XUiBlackShopBuyDetails.lua create mode 100644 Resources/Scripts/XUi/XUiFubenRogueLike/XUiDayTopicCharacter.lua create mode 100644 Resources/Scripts/XUi/XUiFubenRogueLike/XUiGridBlackShopItem.lua create mode 100644 Resources/Scripts/XUi/XUiFubenRogueLike/XUiGridBuffDetailItem.lua create mode 100644 Resources/Scripts/XUi/XUiFubenRogueLike/XUiGridBuffInfoItem.lua create mode 100644 Resources/Scripts/XUi/XUiFubenRogueLike/XUiGridHelpRoleItem.lua create mode 100644 Resources/Scripts/XUi/XUiFubenRogueLike/XUiGridNodeShopItem.lua create mode 100644 Resources/Scripts/XUi/XUiFubenRogueLike/XUiGridRogueLikeCharacter.lua create mode 100644 Resources/Scripts/XUi/XUiFubenRogueLike/XUiGridRoleInfoItem.lua create mode 100644 Resources/Scripts/XUi/XUiFubenRogueLike/XUiGridTopicInfo.lua create mode 100644 Resources/Scripts/XUi/XUiFubenRogueLike/XUiNodeShopBuyDetails.lua create mode 100644 Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeBoxEntrance.lua create mode 100644 Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeBuffStrengthen.lua create mode 100644 Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeCharItem.lua create mode 100644 Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeClearance.lua create mode 100644 Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeClearanceScoreItem.lua create mode 100644 Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeFightEntrance.lua create mode 100644 Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeFightTips.lua create mode 100644 Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeHelpRole.lua create mode 100644 Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeIllegalShop.lua create mode 100644 Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeMain.lua create mode 100644 Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeMemberHead.lua create mode 100644 Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeMyBuff.lua create mode 100644 Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeNode.lua create mode 100644 Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeObtainBuff.lua create mode 100644 Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeReset.lua create mode 100644 Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeRestEntrance.lua create mode 100644 Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeRoomCharacter.lua create mode 100644 Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeSetTeam.lua create mode 100644 Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeShop.lua create mode 100644 Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeShopEntrance.lua create mode 100644 Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeStoryEntrance.lua create mode 100644 Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeStoryResult.lua create mode 100644 Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeSupportCharItem.lua create mode 100644 Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeTask.lua create mode 100644 Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeThemeTips.lua create mode 100644 Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeTrialOpens.lua create mode 100644 Resources/Scripts/XUi/XUiFubenRogueLike/XUiShopSpecialTool.lua create mode 100644 Resources/Scripts/XUi/XUiFubenSimulatedCombat/ChildItem/XUiBuffTipsItem.lua create mode 100644 Resources/Scripts/XUi/XUiFubenSimulatedCombat/ChildItem/XUiGridPointReward.lua create mode 100644 Resources/Scripts/XUi/XUiFubenSimulatedCombat/ChildItem/XUiGridRes.lua create mode 100644 Resources/Scripts/XUi/XUiFubenSimulatedCombat/ChildItem/XUiGridResAlloBuff.lua create mode 100644 Resources/Scripts/XUi/XUiFubenSimulatedCombat/ChildItem/XUiGridStageBuffIcon.lua create mode 100644 Resources/Scripts/XUi/XUiFubenSimulatedCombat/ChildItem/XUiGridStarReward.lua create mode 100644 Resources/Scripts/XUi/XUiFubenSimulatedCombat/ChildItem/XUiGridTask.lua create mode 100644 Resources/Scripts/XUi/XUiFubenSimulatedCombat/ChildItem/XUiRoomCharListGrid.lua create mode 100644 Resources/Scripts/XUi/XUiFubenSimulatedCombat/ChildItem/XUiStageItem.lua create mode 100644 Resources/Scripts/XUi/XUiFubenSimulatedCombat/RoleList/CharacterDetail/XUiCharProperty.lua create mode 100644 Resources/Scripts/XUi/XUiFubenSimulatedCombat/RoleList/CharacterDetail/XUiCharaInfo.lua create mode 100644 Resources/Scripts/XUi/XUiFubenSimulatedCombat/RoleList/CharacterDetail/XUiViewRole.lua create mode 100644 Resources/Scripts/XUi/XUiFubenSimulatedCombat/RoleList/CharacterPanel/XUiCharacterGrid.lua create mode 100644 Resources/Scripts/XUi/XUiFubenSimulatedCombat/RoleList/CharacterPanel/XUiCharacterList.lua create mode 100644 Resources/Scripts/XUi/XUiFubenSimulatedCombat/RoleList/EquipDetail/XUiEquipDetail.lua create mode 100644 Resources/Scripts/XUi/XUiFubenSimulatedCombat/RoleList/EquipDetail/XUiEquipDetailChild.lua create mode 100644 Resources/Scripts/XUi/XUiFubenSimulatedCombat/RoleList/EquipDetail/XUiEquipGrid.lua create mode 100644 Resources/Scripts/XUi/XUiFubenSimulatedCombat/RoleList/XUiRoleList.lua create mode 100644 Resources/Scripts/XUi/XUiFubenSimulatedCombat/XUiResAllo/XUiPanelCombatAdditions.lua create mode 100644 Resources/Scripts/XUi/XUiFubenSimulatedCombat/XUiResAllo/XUiPanelCombatMembers.lua create mode 100644 Resources/Scripts/XUi/XUiFubenSimulatedCombat/XUiResAllo/XUiSimulatedCombatResAllo.lua create mode 100644 Resources/Scripts/XUi/XUiFubenSimulatedCombat/XUiSettleWin/XUiGridCond.lua create mode 100644 Resources/Scripts/XUi/XUiFubenSimulatedCombat/XUiSettleWin/XUiGridWinRole.lua create mode 100644 Resources/Scripts/XUi/XUiFubenSimulatedCombat/XUiSettleWin/XUiSimulatedCombatSettleWin.lua create mode 100644 Resources/Scripts/XUi/XUiFubenSimulatedCombat/XUiSimulatedCombatBossBuffTips.lua create mode 100644 Resources/Scripts/XUi/XUiFubenSimulatedCombat/XUiSimulatedCombatBuffTip.lua create mode 100644 Resources/Scripts/XUi/XUiFubenSimulatedCombat/XUiSimulatedCombatChapter.lua create mode 100644 Resources/Scripts/XUi/XUiFubenSimulatedCombat/XUiSimulatedCombatMain.lua create mode 100644 Resources/Scripts/XUi/XUiFubenSimulatedCombat/XUiSimulatedCombatNewRoomSingle.lua create mode 100644 Resources/Scripts/XUi/XUiFubenSimulatedCombat/XUiSimulatedCombatRoomCharacter.lua create mode 100644 Resources/Scripts/XUi/XUiFubenSimulatedCombat/XUiSimulatedCombatStageDetail.lua create mode 100644 Resources/Scripts/XUi/XUiFubenSimulatedCombat/XUiSimulatedCombatStarReward.lua create mode 100644 Resources/Scripts/XUi/XUiFubenSimulatedCombat/XUiSimulatedCombatTaskReward.lua create mode 100644 Resources/Scripts/XUi/XUiFubenStageDetail/XUiFubenStageDetail.lua create mode 100644 Resources/Scripts/XUi/XUiFubenStageDetail/XUiGridFubenStageDetailStar.lua create mode 100644 Resources/Scripts/XUi/XUiFubenTaskReward/XUiFubenTaskReward.lua create mode 100644 Resources/Scripts/XUi/XUiFubenTaskReward/XUiGridTask.lua create mode 100644 Resources/Scripts/XUi/XUiFubenUnionKill/XUiGridUnionBuffItem.lua create mode 100644 Resources/Scripts/XUi/XUiFubenUnionKill/XUiGridUnionCharacterItem.lua create mode 100644 Resources/Scripts/XUi/XUiFubenUnionKill/XUiGridUnionDamageItem.lua create mode 100644 Resources/Scripts/XUi/XUiFubenUnionKill/XUiGridUnionEventHead.lua create mode 100644 Resources/Scripts/XUi/XUiFubenUnionKill/XUiGridUnionEventStageItem.lua create mode 100644 Resources/Scripts/XUi/XUiFubenUnionKill/XUiGridUnionRankItem.lua create mode 100644 Resources/Scripts/XUi/XUiFubenUnionKill/XUiGridUnionRankMember.lua create mode 100644 Resources/Scripts/XUi/XUiFubenUnionKill/XUiGridUnionRankTab.lua create mode 100644 Resources/Scripts/XUi/XUiFubenUnionKill/XUiGridUnionRewardItem.lua create mode 100644 Resources/Scripts/XUi/XUiFubenUnionKill/XUiGridUnionShareCharItem.lua create mode 100644 Resources/Scripts/XUi/XUiFubenUnionKill/XUiGridUnionStageMember.lua create mode 100644 Resources/Scripts/XUi/XUiFubenUnionKill/XUiPanelUnionBuffDetails.lua create mode 100644 Resources/Scripts/XUi/XUiFubenUnionKill/XUiPanelUnionDamageDetails.lua create mode 100644 Resources/Scripts/XUi/XUiFubenUnionKill/XUiPanelUnionKillMainRank.lua create mode 100644 Resources/Scripts/XUi/XUiFubenUnionKill/XUiPanelUnionKillMyRank.lua create mode 100644 Resources/Scripts/XUi/XUiFubenUnionKill/XUiPanelUnionKillRankReward.lua create mode 100644 Resources/Scripts/XUi/XUiFubenUnionKill/XUiPanelUnionSectionEnd.lua create mode 100644 Resources/Scripts/XUi/XUiFubenUnionKill/XUiUnionKillDifficulty.lua create mode 100644 Resources/Scripts/XUi/XUiFubenUnionKill/XUiUnionKillEnterFight.lua create mode 100644 Resources/Scripts/XUi/XUiFubenUnionKill/XUiUnionKillGrade.lua create mode 100644 Resources/Scripts/XUi/XUiFubenUnionKill/XUiUnionKillGridTeamCard.lua create mode 100644 Resources/Scripts/XUi/XUiFubenUnionKill/XUiUnionKillMain.lua create mode 100644 Resources/Scripts/XUi/XUiFubenUnionKill/XUiUnionKillMember.lua create mode 100644 Resources/Scripts/XUi/XUiFubenUnionKill/XUiUnionKillRank.lua create mode 100644 Resources/Scripts/XUi/XUiFubenUnionKill/XUiUnionKillRoom.lua create mode 100644 Resources/Scripts/XUi/XUiFubenUnionKill/XUiUnionKillSelectRole.lua create mode 100644 Resources/Scripts/XUi/XUiFubenUnionKill/XUiUnionKillStage.lua create mode 100644 Resources/Scripts/XUi/XUiFubenUnionKill/XUiUnionKillTask.lua create mode 100644 Resources/Scripts/XUi/XUiFubenUnionKill/XUiUnionKillTipCardShare.lua create mode 100644 Resources/Scripts/XUi/XUiFunctionalOpen/XUiFunctionalOpen.lua create mode 100644 Resources/Scripts/XUi/XUiFunctionalOpen/XUiHintFunctional.lua create mode 100644 Resources/Scripts/XUi/XUiFurnitureDetail/XUiFurnitureDetail.lua create mode 100644 Resources/Scripts/XUi/XUiFurnitureRecycleObtain/XUiFurnitureObtain.lua create mode 100644 Resources/Scripts/XUi/XUiFurnitureRecycleObtain/XUiFurnitureRecycleObtain.lua create mode 100644 Resources/Scripts/XUi/XUiFurnitureRecycleObtain/XUiGridObtain.lua create mode 100644 Resources/Scripts/XUi/XUiFurnitureTypeSelect/XUiFurnitureTypeSelect.lua create mode 100644 Resources/Scripts/XUi/XUiFurnitureTypeSelect/XUiGridCategory.lua create mode 100644 Resources/Scripts/XUi/XUiGacha/XUiDrawActivity.lua create mode 100644 Resources/Scripts/XUi/XUiGacha/XUiDrawActivityControl.lua create mode 100644 Resources/Scripts/XUi/XUiGacha/XUiDrawActivityLog.lua create mode 100644 Resources/Scripts/XUi/XUiGacha/XUiDrawActivityShow.lua create mode 100644 Resources/Scripts/XUi/XUiGacha/XUiGachaOrganize/XUiGachaOrganize.lua create mode 100644 Resources/Scripts/XUi/XUiGacha/XUiGachaOrganize/XUiGachaOrganizeDrawResult.lua create mode 100644 Resources/Scripts/XUi/XUiGacha/XUiGachaOrganize/XUiGachaPanelPreview.lua create mode 100644 Resources/Scripts/XUi/XUiGacha/XUiGachaOrganize/XUiGridGacha.lua create mode 100644 Resources/Scripts/XUi/XUiGameNotice/XHtmlHandler.lua create mode 100644 Resources/Scripts/XUi/XUiGameNotice/XUiGameNotice.lua create mode 100644 Resources/Scripts/XUi/XUiGuardCamp/XUiChongzhiTanchuang.lua create mode 100644 Resources/Scripts/XUi/XUiGuardCamp/XUiChongzhiTanchuangListItem.lua create mode 100644 Resources/Scripts/XUi/XUiGuardCamp/XUiGuardCampMain.lua create mode 100644 Resources/Scripts/XUi/XUiGuardCamp/XUiGuardCampTips.lua create mode 100644 Resources/Scripts/XUi/XUiGuide/XUiGuideNew.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridChallengeItem.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridChannelItem.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridChannelVistorItem.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridCustomNameItem.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridGuildBoxItem.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridGuildEnlistItem.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridGuildGiftItem.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridGuildHornorMemberGroup.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridGuildLogItem.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridGuildMemberCard.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridGuildPersonItem.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridGuildPresentItem.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridGuildTaskItem.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridMemberItem.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridMemberVistorItem.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridNewsItem.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridParticularsItem.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridRankItem.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridRankingListSwitchItem.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridRecommendationItem.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridTalentItem.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridTalentListItem.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridWelfareItem.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGuildDonationItem.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGuildGridShop.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGuildHeadPortraitItem.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGuildWelcomeWordItem.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildAdministration.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildEnlistNews.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildEnlistRecruit.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildMainInfo.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildMemberHornor.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildTaskDaily.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildTaskMainly.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildViewChallenge.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildViewCharacterFilter.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildViewInformation.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildViewMember.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildViewParticulars.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildViewSetHeadPortrait.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildViewVistorInformation.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildViewVistorMember.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildViewWelfare.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildVistorInfo.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiGuildAsset.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiGuildBuild.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiGuildChangePosition.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiGuildCustomName.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiGuildDonation.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiGuildGift.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiGuildGloryLevel.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiGuildInformation.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiGuildLevelUp.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiGuildLog.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiGuildMain.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiGuildNews.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiGuildPanelWelfare.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiGuildPerson.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiGuildRankingList.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiGuildRankingListSwitch.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiGuildRecommendation.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiGuildRecruit.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiGuildRongyu.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiGuildShop.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiGuildSkill.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiGuildSkillDetail.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiGuildTask.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiGuildVistor.lua create mode 100644 Resources/Scripts/XUi/XUiGuild/XUiGuildWelcomeWord.lua create mode 100644 Resources/Scripts/XUi/XUiGuildBoss/ChildView/XUiGuildBossHpReward.lua create mode 100644 Resources/Scripts/XUi/XUiGuildBoss/Component/XUiGuildBossGuildRankItem.lua create mode 100644 Resources/Scripts/XUi/XUiGuildBoss/Component/XUiGuildBossHpRewardItem.lua create mode 100644 Resources/Scripts/XUi/XUiGuildBoss/Component/XUiGuildBossLevelGrid.lua create mode 100644 Resources/Scripts/XUi/XUiGuildBoss/Component/XUiGuildBossLog.lua create mode 100644 Resources/Scripts/XUi/XUiGuildBoss/Component/XUiGuildBossPlayerRankItem.lua create mode 100644 Resources/Scripts/XUi/XUiGuildBoss/Component/XUiGuildBossRankItem.lua create mode 100644 Resources/Scripts/XUi/XUiGuildBoss/Component/XUiGuildBossRankPanel.lua create mode 100644 Resources/Scripts/XUi/XUiGuildBoss/Component/XUiGuildBossRankRewardItem.lua create mode 100644 Resources/Scripts/XUi/XUiGuildBoss/Component/XUiGuildBossRewardItem.lua create mode 100644 Resources/Scripts/XUi/XUiGuildBoss/Component/XUiGuildBossSkillGrid.lua create mode 100644 Resources/Scripts/XUi/XUiGuildBoss/Component/XUiGuildBossStageLevel.lua create mode 100644 Resources/Scripts/XUi/XUiGuildBoss/Component/XUiGuildBossStageRankItem.lua create mode 100644 Resources/Scripts/XUi/XUiGuildBoss/Component/XUiGuildBossTeamList.lua create mode 100644 Resources/Scripts/XUi/XUiGuildBoss/XUiGuildBossCurSubLevelInfo.lua create mode 100644 Resources/Scripts/XUi/XUiGuildBoss/XUiGuildBossDetail.lua create mode 100644 Resources/Scripts/XUi/XUiGuildBoss/XUiGuildBossDiff.lua create mode 100644 Resources/Scripts/XUi/XUiGuildBoss/XUiGuildBossFightResult.lua create mode 100644 Resources/Scripts/XUi/XUiGuildBoss/XUiGuildBossHall.lua create mode 100644 Resources/Scripts/XUi/XUiGuildBoss/XUiGuildBossMainLevelInfo.lua create mode 100644 Resources/Scripts/XUi/XUiGuildBoss/XUiGuildBossNewRoomSingle.lua create mode 100644 Resources/Scripts/XUi/XUiGuildBoss/XUiGuildBossOtherSubLevelInfo.lua create mode 100644 Resources/Scripts/XUi/XUiGuildBoss/XUiGuildBossRank.lua create mode 100644 Resources/Scripts/XUi/XUiGuildBoss/XUiGuildBossRankReward.lua create mode 100644 Resources/Scripts/XUi/XUiGuildBoss/XUiGuildBossSkill.lua create mode 100644 Resources/Scripts/XUi/XUiGuildBoss/XUiGuildBossStage.lua create mode 100644 Resources/Scripts/XUi/XUiGuildBoss/XUiGuildBossTip.lua create mode 100644 Resources/Scripts/XUi/XUiHelpCourse/XUiGridHelpCourse.lua create mode 100644 Resources/Scripts/XUi/XUiHelpCourse/XUiHelp.lua create mode 100644 Resources/Scripts/XUi/XUiHelpCourse/XUiHelpNew.lua create mode 100644 Resources/Scripts/XUi/XUiHomeMain/XUiHomeMain.lua create mode 100644 Resources/Scripts/XUi/XUiHostelCharacterWork/XUiHostelCharacterWork.lua create mode 100644 Resources/Scripts/XUi/XUiHostelDelegate/XUiHostelDelegate.lua create mode 100644 Resources/Scripts/XUi/XUiHostelDelegateReporter/XUiGridDelegateReporter.lua create mode 100644 Resources/Scripts/XUi/XUiHostelDelegateReporter/XUiHostelDelegateReporter.lua create mode 100644 Resources/Scripts/XUi/XUiHostelDeviceDetail/XUiGridFuncUpgradeInfoItem.lua create mode 100644 Resources/Scripts/XUi/XUiHostelDeviceDetail/XUiGridFunctionContenItem.lua create mode 100644 Resources/Scripts/XUi/XUiHostelDeviceDetail/XUiHostelDeviceDetail.lua create mode 100644 Resources/Scripts/XUi/XUiHostelDeviceDetail/XUiPanelDeviceUpgradeInfo.lua create mode 100644 Resources/Scripts/XUi/XUiHostelDeviceUpgradeResult/XUiGridFuncUpgradeResItem.lua create mode 100644 Resources/Scripts/XUi/XUiHostelDeviceUpgradeResult/XUiHostelDeviceUpgradeResult.lua create mode 100644 Resources/Scripts/XUi/XUiHostelDeviceUpgrading/XUiHostelDeviceUpgrading.lua create mode 100644 Resources/Scripts/XUi/XUiHostelMissionComplete/XUiHostelMissionComplete.lua create mode 100644 Resources/Scripts/XUi/XUiHostelQte/XUiHostelQte.lua create mode 100644 Resources/Scripts/XUi/XUiHostelRest/XUiGridFloorItem.lua create mode 100644 Resources/Scripts/XUi/XUiHostelRest/XUiGridIdleCharacter.lua create mode 100644 Resources/Scripts/XUi/XUiHostelRest/XUiGridRestCharItem.lua create mode 100644 Resources/Scripts/XUi/XUiHostelRest/XUiHostelRest.lua create mode 100644 Resources/Scripts/XUi/XUiHostelRest/XUiPanelRestModel.lua create mode 100644 Resources/Scripts/XUi/XUiHostelRoom/XUiHostelRoom.lua create mode 100644 Resources/Scripts/XUi/XUiHud/XUiGridCoolTime.lua create mode 100644 Resources/Scripts/XUi/XUiHud/XUiGridDeviceState.lua create mode 100644 Resources/Scripts/XUi/XUiHud/XUiGridRoomUpgrade.lua create mode 100644 Resources/Scripts/XUi/XUiHud/XUiGridWorkSlotState.lua create mode 100644 Resources/Scripts/XUi/XUiHud/XUiHud.lua create mode 100644 Resources/Scripts/XUi/XUiInvertCardGame/XUiInvertCardGame.lua create mode 100644 Resources/Scripts/XUi/XUiInvertCardGame/XUiInvertCardGamePanel.lua create mode 100644 Resources/Scripts/XUi/XUiInvertCardGame/XUiInvertCardRewardItem.lua create mode 100644 Resources/Scripts/XUi/XUiInvertCardGame/XUiInvertCardRewardPanel.lua create mode 100644 Resources/Scripts/XUi/XUiInvertCardGame/XUiInvertGameCardItem.lua create mode 100644 Resources/Scripts/XUi/XUiKillZone/XUiGridKillZonePlugin.lua create mode 100644 Resources/Scripts/XUi/XUiKillZone/XUiGridKillZonePluginSlot.lua create mode 100644 Resources/Scripts/XUi/XUiKillZone/XUiGridKillZoneStage.lua create mode 100644 Resources/Scripts/XUi/XUiKillZone/XUiKillZoneBuffTips.lua create mode 100644 Resources/Scripts/XUi/XUiKillZone/XUiKillZoneMain.lua create mode 100644 Resources/Scripts/XUi/XUiKillZone/XUiKillZoneNewRoomSingle.lua create mode 100644 Resources/Scripts/XUi/XUiKillZone/XUiKillZonePlugin/XUiGridKillZonePluginDesc.lua create mode 100644 Resources/Scripts/XUi/XUiKillZone/XUiKillZonePlugin/XUiGridKillZonePluginGroup.lua create mode 100644 Resources/Scripts/XUi/XUiKillZone/XUiKillZonePlugin/XUiGridKillZonePluginOperate.lua create mode 100644 Resources/Scripts/XUi/XUiKillZone/XUiKillZonePlugin/XUiGridKillZonePluginSlotOperate.lua create mode 100644 Resources/Scripts/XUi/XUiKillZone/XUiKillZonePlugin/XUiKillZonePlugin.lua create mode 100644 Resources/Scripts/XUi/XUiKillZone/XUiKillZonePlugin/XUiKillZonePluginPopup.lua create mode 100644 Resources/Scripts/XUi/XUiKillZone/XUiKillZonePlugin/XUiKillZonePluginReset.lua create mode 100644 Resources/Scripts/XUi/XUiKillZone/XUiKillZoneReward/XUiGridDailyReward.lua create mode 100644 Resources/Scripts/XUi/XUiKillZone/XUiKillZoneReward/XUiGridReward.lua create mode 100644 Resources/Scripts/XUi/XUiKillZone/XUiKillZoneReward/XUiKillZoneDaily.lua create mode 100644 Resources/Scripts/XUi/XUiKillZone/XUiKillZoneReward/XUiKillZoneReward.lua create mode 100644 Resources/Scripts/XUi/XUiKillZone/XUiKillZoneSettleWin.lua create mode 100644 Resources/Scripts/XUi/XUiKillZone/XUiKillZoneStageDetail.lua create mode 100644 Resources/Scripts/XUi/XUiLeftPopupTip/UiLeftPopupTip.lua create mode 100644 Resources/Scripts/XUi/XUiLogin/XLoginAttentionPanel.lua create mode 100644 Resources/Scripts/XUi/XUiLogin/XLoginNoticePanel.lua create mode 100644 Resources/Scripts/XUi/XUiLogin/XLoginSwitchAccountPanel.lua create mode 100644 Resources/Scripts/XUi/XUiLogin/XUiAccountSign.lua create mode 100644 Resources/Scripts/XUi/XUiLogin/XUiGridServer.lua create mode 100644 Resources/Scripts/XUi/XUiLogin/XUiLogin.lua create mode 100644 Resources/Scripts/XUi/XUiLogin/XUiLoginAgreePanel.lua create mode 100644 Resources/Scripts/XUi/XUiLogin/XUiLoginAgreement.lua create mode 100644 Resources/Scripts/XUi/XUiLogin/XUiLoginDialog.lua create mode 100644 Resources/Scripts/XUi/XUiLogin/XUiLoginNetworkModePanel.lua create mode 100644 Resources/Scripts/XUi/XUiLogin/XUiLoginTypePanel.lua create mode 100644 Resources/Scripts/XUi/XUiLogin/XUiSetAccount.lua create mode 100644 Resources/Scripts/XUi/XUiLoginNotice/XUiLoginNotice.lua create mode 100644 Resources/Scripts/XUi/XUiLoginVerification/XUiLoginVerification.lua create mode 100644 Resources/Scripts/XUi/XUiLotto/XUiGridTicket.lua create mode 100644 Resources/Scripts/XUi/XUiLotto/XUiLotto.lua create mode 100644 Resources/Scripts/XUi/XUiLotto/XUiLottoLog.lua create mode 100644 Resources/Scripts/XUi/XUiLotto/XUiLottoShow.lua create mode 100644 Resources/Scripts/XUi/XUiLotto/XUiLottoTanchuang.lua create mode 100644 Resources/Scripts/XUi/XUiLotto/XUiPanelLottoPreview.lua create mode 100644 Resources/Scripts/XUi/XUiMail/XUiGridItem.lua create mode 100644 Resources/Scripts/XUi/XUiMail/XUiGridTitle.lua create mode 100644 Resources/Scripts/XUi/XUiMail/XUiMail.lua create mode 100644 Resources/Scripts/XUi/XUiMain/XUiChildItem/XUiGridSubMenuItem.lua create mode 100644 Resources/Scripts/XUi/XUiMain/XUiChildView/XUiPanelAd.lua create mode 100644 Resources/Scripts/XUi/XUiMain/XUiChildView/XUiPanelArenaOnline.lua create mode 100644 Resources/Scripts/XUi/XUiMain/XUiChildView/XUiPanelSignBoard.lua create mode 100644 Resources/Scripts/XUi/XUiMain/XUiMain.lua create mode 100644 Resources/Scripts/XUi/XUiMain/XUiMainDown.lua create mode 100644 Resources/Scripts/XUi/XUiMain/XUiMainLeftBottom.lua create mode 100644 Resources/Scripts/XUi/XUiMain/XUiMainLeftMid.lua create mode 100644 Resources/Scripts/XUi/XUiMain/XUiMainLeftTop.lua create mode 100644 Resources/Scripts/XUi/XUiMain/XUiMainOther.lua create mode 100644 Resources/Scripts/XUi/XUiMain/XUiMainRightBottom.lua create mode 100644 Resources/Scripts/XUi/XUiMain/XUiMainRightMid.lua create mode 100644 Resources/Scripts/XUi/XUiMain/XUiMainRightMidSecond.lua create mode 100644 Resources/Scripts/XUi/XUiMain/XUiMainRightTop.lua create mode 100644 Resources/Scripts/XUi/XUiMaintainerAction/XUiFubenMaintaineraction.lua create mode 100644 Resources/Scripts/XUi/XUiMaintainerAction/XUiFubenMaintaineractionDetailsTips.lua create mode 100644 Resources/Scripts/XUi/XUiMaintainerAction/XUiFubenMaintaineractionFighting.lua create mode 100644 Resources/Scripts/XUi/XUiMaintainerAction/XUiFubenMaintaineractionRecording.lua create mode 100644 Resources/Scripts/XUi/XUiMaintainerAction/XUiFubenMaintaineractionTipLayer.lua create mode 100644 Resources/Scripts/XUi/XUiMaintainerAction/XUiFubenMaintaineractionTreasurechest.lua create mode 100644 Resources/Scripts/XUi/XUiMaintainerAction/XUiGridCard.lua create mode 100644 Resources/Scripts/XUi/XUiMaintainerAction/XUiGridMapNote.lua create mode 100644 Resources/Scripts/XUi/XUiMaintainerAction/XUiGridPlayer.lua create mode 100644 Resources/Scripts/XUi/XUiMaintainerAction/XUiGridRecord.lua create mode 100644 Resources/Scripts/XUi/XUiMaintainerAction/XUiPanelBelow.lua create mode 100644 Resources/Scripts/XUi/XUiMaintainerAction/XUiPanelIntermediate.lua create mode 100644 Resources/Scripts/XUi/XUiMedal/XUiCollectionStyle.lua create mode 100644 Resources/Scripts/XUi/XUiMedal/XUiCollectionTip.lua create mode 100644 Resources/Scripts/XUi/XUiMedal/XUiGridCollection.lua create mode 100644 Resources/Scripts/XUi/XUiMedal/XUiGridMedal.lua create mode 100644 Resources/Scripts/XUi/XUiMedal/XUiMeadalDetail.lua create mode 100644 Resources/Scripts/XUi/XUiMedal/XUiMedalUnlock.lua create mode 100644 Resources/Scripts/XUi/XUiMedal/XUiMedalUnlockTips.lua create mode 100644 Resources/Scripts/XUi/XUiMedal/XUiObtainCollection.lua create mode 100644 Resources/Scripts/XUi/XUiMedal/XUiOtherPlayerGridMedal.lua create mode 100644 Resources/Scripts/XUi/XUiMedal/XUiPanelMedal.lua create mode 100644 Resources/Scripts/XUi/XUiMedal/XUiPanelMedalListView.lua create mode 100644 Resources/Scripts/XUi/XUiMedal/XUiUpgradeCollection.lua create mode 100644 Resources/Scripts/XUi/XUiMentorSystem/MentorAnnouncement/XUiMentorAnnouncement.lua create mode 100644 Resources/Scripts/XUi/XUiMentorSystem/MentorAwarenessGiveaway/XUiMentorAwarenessGiveaway.lua create mode 100644 Resources/Scripts/XUi/XUiMentorSystem/MentorAwarenessGiveaway/XUiMentorAwarenessPopup.lua create mode 100644 Resources/Scripts/XUi/XUiMentorSystem/MentorFile/XUiGridPlayer.lua create mode 100644 Resources/Scripts/XUi/XUiMentorSystem/MentorFile/XUiMentorFile.lua create mode 100644 Resources/Scripts/XUi/XUiMentorSystem/MentorFile/XUiPanelStudent.lua create mode 100644 Resources/Scripts/XUi/XUiMentorSystem/MentorFile/XUiPanelTeacher.lua create mode 100644 Resources/Scripts/XUi/XUiMentorSystem/MentorGiftTisp/XUiMentorGiftTisp.lua create mode 100644 Resources/Scripts/XUi/XUiMentorSystem/MentorMain/XUiGridStudent.lua create mode 100644 Resources/Scripts/XUi/XUiMentorSystem/MentorMain/XUiGridTeacher.lua create mode 100644 Resources/Scripts/XUi/XUiMentorSystem/MentorMain/XUiMentorMain.lua create mode 100644 Resources/Scripts/XUi/XUiMentorSystem/MentorRecommendation/MentorApplication/XUiGridGotManifesto.lua create mode 100644 Resources/Scripts/XUi/XUiMentorSystem/MentorRecommendation/MentorApplication/XUiMentorApplication.lua create mode 100644 Resources/Scripts/XUi/XUiMentorSystem/MentorRecommendation/MentorDeclaration/XUiGridMentorLabel.lua create mode 100644 Resources/Scripts/XUi/XUiMentorSystem/MentorRecommendation/MentorDeclaration/XUiMentorDeclaration.lua create mode 100644 Resources/Scripts/XUi/XUiMentorSystem/MentorRecommendation/XUiGridManifesto.lua create mode 100644 Resources/Scripts/XUi/XUiMentorSystem/MentorRecommendation/XUiMentorRecommendation.lua create mode 100644 Resources/Scripts/XUi/XUiMentorSystem/MentorRecording/XUiMentorRecording.lua create mode 100644 Resources/Scripts/XUi/XUiMentorSystem/MentorReward/MentorGraduation/XUiMentorGraduation.lua create mode 100644 Resources/Scripts/XUi/XUiMentorSystem/MentorReward/XUiGridPhasesReward.lua create mode 100644 Resources/Scripts/XUi/XUiMentorSystem/MentorReward/XUiGridTeacherTask.lua create mode 100644 Resources/Scripts/XUi/XUiMentorSystem/MentorReward/XUiMentorReward.lua create mode 100644 Resources/Scripts/XUi/XUiMentorSystem/MentorReward/XUiMentorRewardTisp.lua create mode 100644 Resources/Scripts/XUi/XUiMentorSystem/MentorReward/XUiPanelStudentGraduateReward.lua create mode 100644 Resources/Scripts/XUi/XUiMentorSystem/MentorReward/XUiPanelStudentReward.lua create mode 100644 Resources/Scripts/XUi/XUiMentorSystem/MentorReward/XUiPanelTeacherPhasesReward.lua create mode 100644 Resources/Scripts/XUi/XUiMentorSystem/MentorReward/XUiPanelTeacherReward.lua create mode 100644 Resources/Scripts/XUi/XUiMentorSystem/MentorShare/XUiGridSelectTask.lua create mode 100644 Resources/Scripts/XUi/XUiMentorSystem/MentorShare/XUiMentorSelectTask.lua create mode 100644 Resources/Scripts/XUi/XUiMentorSystem/MentorTask/XUiGridPhasesTask.lua create mode 100644 Resources/Scripts/XUi/XUiMentorSystem/MentorTask/XUiGridStudentWeeklyTask.lua create mode 100644 Resources/Scripts/XUi/XUiMentorSystem/MentorTask/XUiGridTaskAssist.lua create mode 100644 Resources/Scripts/XUi/XUiMentorSystem/MentorTask/XUiGridTaskReward.lua create mode 100644 Resources/Scripts/XUi/XUiMentorSystem/MentorTask/XUiMentorTask.lua create mode 100644 Resources/Scripts/XUi/XUiMentorSystem/MentorTask/XUiPanelStudentPhasesTask.lua create mode 100644 Resources/Scripts/XUi/XUiMentorSystem/MentorTask/XUiPanelStudentTask.lua create mode 100644 Resources/Scripts/XUi/XUiMentorSystem/MentorTask/XUiPanelTeacherTask.lua create mode 100644 Resources/Scripts/XUi/XUiMentorSystem/MentorTask/XUiPanelTeacherTaskAssist.lua create mode 100644 Resources/Scripts/XUi/XUiMentorSystem/MentorTask/XUiPanelTeacherTaskReward.lua create mode 100644 Resources/Scripts/XUi/XUiMineSweeping/XUiGridMine.lua create mode 100644 Resources/Scripts/XUi/XUiMineSweeping/XUiGridStageReward.lua create mode 100644 Resources/Scripts/XUi/XUiMineSweeping/XUiMineSweepingMain.lua create mode 100644 Resources/Scripts/XUi/XUiMineSweeping/XUiPanelAllGrid.lua create mode 100644 Resources/Scripts/XUi/XUiMineSweeping/XUiPanelCondition.lua create mode 100644 Resources/Scripts/XUi/XUiMineSweeping/XUiPanelPlay.lua create mode 100644 Resources/Scripts/XUi/XUiMineSweeping/XUiPanelSequence.lua create mode 100644 Resources/Scripts/XUi/XUiMineSweeping/XUiPanelSequenceWin.lua create mode 100644 Resources/Scripts/XUi/XUiMineSweeping/XUiPanelSettlement.lua create mode 100644 Resources/Scripts/XUi/XUiMineSweeping/XUiPanelStart.lua create mode 100644 Resources/Scripts/XUi/XUiMiniGame/ComposeGame/XUiComposeGame.lua create mode 100644 Resources/Scripts/XUi/XUiMiniGame/ComposeGame/XUiComposeGameBagGrid.lua create mode 100644 Resources/Scripts/XUi/XUiMiniGame/ComposeGame/XUiComposeGamePanelBag.lua create mode 100644 Resources/Scripts/XUi/XUiMiniGame/ComposeGame/XUiComposeGamePanelRefresh.lua create mode 100644 Resources/Scripts/XUi/XUiMiniGame/ComposeGame/XUiComposeGamePanelSchedule.lua create mode 100644 Resources/Scripts/XUi/XUiMiniGame/ComposeGame/XUiComposeGamePanelShop.lua create mode 100644 Resources/Scripts/XUi/XUiMiniGame/ComposeGame/XUiComposeGameShopGrid.lua create mode 100644 Resources/Scripts/XUi/XUiMiniGame/ComposeGame/XUiComposeGameStarPanelLevel.lua create mode 100644 Resources/Scripts/XUi/XUiMiniGame/ComposeGame/XUiComposeGameTreasureBox.lua create mode 100644 Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessFinger.lua create mode 100644 Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessGamePanel.lua create mode 100644 Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessPKPanel.lua create mode 100644 Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessResult.lua create mode 100644 Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessSSExplainPanel.lua create mode 100644 Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessSSLevelPanel.lua create mode 100644 Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessSSRolePanel.lua create mode 100644 Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessSSStartPanel.lua create mode 100644 Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessSSTitlePanel.lua create mode 100644 Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessScorePanel.lua create mode 100644 Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessStage.lua create mode 100644 Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessingEyePanel.lua create mode 100644 Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessingGame.lua create mode 100644 Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessingSelectStage.lua create mode 100644 Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessingTask.lua create mode 100644 Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessingTaskDynamicTable.lua create mode 100644 Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenDispatchMemberDynamicGrid.lua create mode 100644 Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenDispatchMemberDynamicTable.lua create mode 100644 Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenDispatchPanelPlace.lua create mode 100644 Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenDispatchPanelReward.lua create mode 100644 Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenInviteCharaGrid.lua create mode 100644 Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenInviteMemberDynamicGrid.lua create mode 100644 Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenInviteMemberDynamicTable.lua create mode 100644 Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenItemGrid.lua create mode 100644 Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenMainButtonPanel.lua create mode 100644 Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenMainEventPanel.lua create mode 100644 Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenPlace.lua create mode 100644 Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenTaskDynamicTable.lua create mode 100644 Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValentineDispatch.lua create mode 100644 Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValentineInvite.lua create mode 100644 Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValentineMain.lua create mode 100644 Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValentineStory.lua create mode 100644 Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValentineTask.lua create mode 100644 Resources/Scripts/XUi/XUiMission/XUiGridConditionTxt.lua create mode 100644 Resources/Scripts/XUi/XUiMission/XUiGridLimit.lua create mode 100644 Resources/Scripts/XUi/XUiMission/XUiGridMissionCommon.lua create mode 100644 Resources/Scripts/XUi/XUiMission/XUiGridMisssionTeam.lua create mode 100644 Resources/Scripts/XUi/XUiMission/XUiMission.lua create mode 100644 Resources/Scripts/XUi/XUiMission/XUiMissionAddSpeedTip.lua create mode 100644 Resources/Scripts/XUi/XUiMission/XUiMissionChapter.lua create mode 100644 Resources/Scripts/XUi/XUiMission/XUiMissionCompleted.lua create mode 100644 Resources/Scripts/XUi/XUiMission/XUiMissionTeam.lua create mode 100644 Resources/Scripts/XUi/XUiMission/XUiMissionTeamLimit.lua create mode 100644 Resources/Scripts/XUi/XUiMission/XUiMissionTeamSelect.lua create mode 100644 Resources/Scripts/XUi/XUiMission/XUiPanelArea.lua create mode 100644 Resources/Scripts/XUi/XUiMission/XUiPanelMissionChapterGird.lua create mode 100644 Resources/Scripts/XUi/XUiMission/XUiPanelMissionCharacter.lua create mode 100644 Resources/Scripts/XUi/XUiMission/XUiPanelMissionGrid.lua create mode 100644 Resources/Scripts/XUi/XUiMission/XUiPanelRewardBig.lua create mode 100644 Resources/Scripts/XUi/XUiMission/XUiPanelRewardSmall.lua create mode 100644 Resources/Scripts/XUi/XUiMoeWar/ChildItem/XUiGridGroupList.lua create mode 100644 Resources/Scripts/XUi/XUiMoeWar/ChildItem/XUiGridPairGroup.lua create mode 100644 Resources/Scripts/XUi/XUiMoeWar/ChildItem/XUiGridRank.lua create mode 100644 Resources/Scripts/XUi/XUiMoeWar/ChildItem/XUiGridVoteItem.lua create mode 100644 Resources/Scripts/XUi/XUiMoeWar/ChildItem/XUiMessageGridAction.lua create mode 100644 Resources/Scripts/XUi/XUiMoeWar/ChildItem/XUiMessageGridPlayer.lua create mode 100644 Resources/Scripts/XUi/XUiMoeWar/ChildItem/XUiScheduleGridPair.lua create mode 100644 Resources/Scripts/XUi/XUiMoeWar/ChildItem/XUiScheduleGridPlayer.lua create mode 100644 Resources/Scripts/XUi/XUiMoeWar/Preparation/XUiMoeWarPreparation.lua create mode 100644 Resources/Scripts/XUi/XUiMoeWar/Preparation/XUiMoeWarPreparationBtnTab.lua create mode 100644 Resources/Scripts/XUi/XUiMoeWar/Preparation/XUiMoeWarPreparationRewardGrid.lua create mode 100644 Resources/Scripts/XUi/XUiMoeWar/Preparation/XUiMoeWarPreparationStageGrid.lua create mode 100644 Resources/Scripts/XUi/XUiMoeWar/Prepare/XUiMoeWarPrepare.lua create mode 100644 Resources/Scripts/XUi/XUiMoeWar/Prepare/XUiMoeWarPrepareConditionGrid.lua create mode 100644 Resources/Scripts/XUi/XUiMoeWar/Recruit/XUiMoeWarChatPools.lua create mode 100644 Resources/Scripts/XUi/XUiMoeWar/Recruit/XUiMoeWarRecruit.lua create mode 100644 Resources/Scripts/XUi/XUiMoeWar/Recruit/XUiMoeWarRecruitGrid.lua create mode 100644 Resources/Scripts/XUi/XUiMoeWar/Recruit/XUiMoeWarRecruitMsgPanel.lua create mode 100644 Resources/Scripts/XUi/XUiMoeWar/Recruit/XUiPanelLineItem.lua create mode 100644 Resources/Scripts/XUi/XUiMoeWar/Recruit/XUiPanelMsgItem.lua create mode 100644 Resources/Scripts/XUi/XUiMoeWar/SceneAnimation/UiMoeWarAnimationTips.lua create mode 100644 Resources/Scripts/XUi/XUiMoeWar/SceneAnimation/XMoeWarAnimationRole.lua create mode 100644 Resources/Scripts/XUi/XUiMoeWar/SceneAnimation/XUiMoeWarAnimation.lua create mode 100644 Resources/Scripts/XUi/XUiMoeWar/SubPage/XUiPanelMatchFinal.lua create mode 100644 Resources/Scripts/XUi/XUiMoeWar/SubPage/XUiPanelMatchLarge.lua create mode 100644 Resources/Scripts/XUi/XUiMoeWar/SubPage/XUiPanelMatchSmall.lua create mode 100644 Resources/Scripts/XUi/XUiMoeWar/SubPage/XUiPanelMyRank.lua create mode 100644 Resources/Scripts/XUi/XUiMoeWar/SubPage/XUiPanelPlayerVote.lua create mode 100644 Resources/Scripts/XUi/XUiMoeWar/Support/XUiMoeWarSupport.lua create mode 100644 Resources/Scripts/XUi/XUiMoeWar/Support/XUiMoeWarSupportGrid.lua create mode 100644 Resources/Scripts/XUi/XUiMoeWar/XUiMoeWarCharacter.lua create mode 100644 Resources/Scripts/XUi/XUiMoeWar/XUiMoeWarGroupList.lua create mode 100644 Resources/Scripts/XUi/XUiMoeWar/XUiMoeWarMain.lua create mode 100644 Resources/Scripts/XUi/XUiMoeWar/XUiMoeWarMessage.lua create mode 100644 Resources/Scripts/XUi/XUiMoeWar/XUiMoeWarPhotograph.lua create mode 100644 Resources/Scripts/XUi/XUiMoeWar/XUiMoeWarPollTips.lua create mode 100644 Resources/Scripts/XUi/XUiMoeWar/XUiMoeWarRankingList.lua create mode 100644 Resources/Scripts/XUi/XUiMoeWar/XUiMoeWarSchedule.lua create mode 100644 Resources/Scripts/XUi/XUiMoeWar/XUiMoeWarShop.lua create mode 100644 Resources/Scripts/XUi/XUiMoeWar/XUiMoeWarSupportTips.lua create mode 100644 Resources/Scripts/XUi/XUiMoeWar/XUiMoeWarTask.lua create mode 100644 Resources/Scripts/XUi/XUiMoeWar/XUiMoeWarVote.lua create mode 100644 Resources/Scripts/XUi/XUiMoneyReward/XUiMoneyReward.lua create mode 100644 Resources/Scripts/XUi/XUiMoneyReward/XUiMoneyRewardFightTipFind.lua create mode 100644 Resources/Scripts/XUi/XUiMoneyReward/XUiMoneyRewardFightTips.lua create mode 100644 Resources/Scripts/XUi/XUiMoneyReward/XUiMoneyRewardLevelUpTips.lua create mode 100644 Resources/Scripts/XUi/XUiMoneyReward/XUiMoneyRewardRank.lua create mode 100644 Resources/Scripts/XUi/XUiMoneyReward/XUiMoneyRewardTask.lua create mode 100644 Resources/Scripts/XUi/XUiMoneyReward/XUiMoneyRewardTaskCardTip.lua create mode 100644 Resources/Scripts/XUi/XUiMoneyReward/XUiPanelRewardGird.lua create mode 100644 Resources/Scripts/XUi/XUiMoneyReward/XUiPanelTask.lua create mode 100644 Resources/Scripts/XUi/XUiMoneyReward/XUiPanelTaskCard.lua create mode 100644 Resources/Scripts/XUi/XUiMovie/XUIGridStaff.lua create mode 100644 Resources/Scripts/XUi/XUiMovie/XUiGridMovieActor.lua create mode 100644 Resources/Scripts/XUi/XUiMovie/XUiGridReviewItem.lua create mode 100644 Resources/Scripts/XUi/XUiMovie/XUiGridSingleDialog.lua create mode 100644 Resources/Scripts/XUi/XUiMovie/XUiMovie.lua create mode 100644 Resources/Scripts/XUi/XUiMovie/XUiMovieReview.lua create mode 100644 Resources/Scripts/XUi/XUiMovie/XUiStorySkipDialog.lua create mode 100644 Resources/Scripts/XUi/XUiMovieAssemble/XUiMovieAssemble.lua create mode 100644 Resources/Scripts/XUi/XUiMovieAssemble/XUiMovieAssembleStage.lua create mode 100644 Resources/Scripts/XUi/XUiMultiplayerFightGrade/XUiGridFightDataItem.lua create mode 100644 Resources/Scripts/XUi/XUiMultiplayerFightGrade/XUiGridFightGradeItem.lua create mode 100644 Resources/Scripts/XUi/XUiMultiplayerFightGrade/XUiMultiplayerFightGrade.lua create mode 100644 Resources/Scripts/XUi/XUiMultiplayerInviteFriend/XUiGridInviteFriendItem.lua create mode 100644 Resources/Scripts/XUi/XUiMultiplayerInviteFriend/XUiMultiplayerInviteFriend.lua create mode 100644 Resources/Scripts/XUi/XUiMultiplayerRoom/XUiGridMulitiplayerRoomChar.lua create mode 100644 Resources/Scripts/XUi/XUiMultiplayerRoom/XUiGridMultiplayerDifficultyItem.lua create mode 100644 Resources/Scripts/XUi/XUiMultiplayerRoom/XUiMultiplayerRoom.lua create mode 100644 Resources/Scripts/XUi/XUiMultiplayerRoom/XUiPanelActiveBuff.lua create mode 100644 Resources/Scripts/XUi/XUiMultiplayerRoom/XUiPanelActiveBuffMian.lua create mode 100644 Resources/Scripts/XUi/XUiMultiplayerRoom/XUiPanelChangeStage.lua create mode 100644 Resources/Scripts/XUi/XUiMusicPlayer/XUiGridMusicPlayer.lua create mode 100644 Resources/Scripts/XUi/XUiMusicPlayer/XUiMusicPlayer.lua create mode 100644 Resources/Scripts/XUi/XUiMusicPlayer/XUiPanelMusicSpectrum.lua create mode 100644 Resources/Scripts/XUi/XUiNameplate/XUiGridNameplate.lua create mode 100644 Resources/Scripts/XUi/XUiNameplate/XUiNameplateTip.lua create mode 100644 Resources/Scripts/XUi/XUiNameplate/XUiObtainNameplate.lua create mode 100644 Resources/Scripts/XUi/XUiNameplate/XUiPanelNameplate.lua create mode 100644 Resources/Scripts/XUi/XUiNewAutoFight/XUiGridAutoFightRewardLine.lua create mode 100644 Resources/Scripts/XUi/XUiNewAutoFight/XUiNewAutoFightDialog.lua create mode 100644 Resources/Scripts/XUi/XUiNewAutoFight/XUiNewAutoFightSettleWin.lua create mode 100644 Resources/Scripts/XUi/XUiNewChar/WeiLa/XUiFubenWeiLaStageItem.lua create mode 100644 Resources/Scripts/XUi/XUiNewChar/WeiLa/XUiFubenWeiLaTutorial.lua create mode 100644 Resources/Scripts/XUi/XUiNewChar/WeiLa/XUiPanelFubenWeiLaStage.lua create mode 100644 Resources/Scripts/XUi/XUiNewChar/XUiFubenKoroStageItem.lua create mode 100644 Resources/Scripts/XUi/XUiNewChar/XUiFunbenKoroTutoriaChallengeDetail.lua create mode 100644 Resources/Scripts/XUi/XUiNewChar/XUiFunbenKoroTutoriaTeachingDetail.lua create mode 100644 Resources/Scripts/XUi/XUiNewChar/XUiFunbenKoroTutorial.lua create mode 100644 Resources/Scripts/XUi/XUiNewChar/XUiNewCharActivity.lua create mode 100644 Resources/Scripts/XUi/XUiNewChar/XUiNewCharNewRoomSingle.lua create mode 100644 Resources/Scripts/XUi/XUiNewChar/XUiNewCharStageItem.lua create mode 100644 Resources/Scripts/XUi/XUiNewChar/XUiPanelFubenKoroStage.lua create mode 100644 Resources/Scripts/XUi/XUiNewChar/XUiPanelLineChapter.lua create mode 100644 Resources/Scripts/XUi/XUiNewPlayerTask/XUiBtnNewbieTaskTab.lua create mode 100644 Resources/Scripts/XUi/XUiNewPlayerTask/XUiGridNewbieTaskItem.lua create mode 100644 Resources/Scripts/XUi/XUiNewPlayerTask/XUiNewPlayerTask.lua create mode 100644 Resources/Scripts/XUi/XUiNewPlayerTask/XUiPanelNewbieActive.lua create mode 100644 Resources/Scripts/XUi/XUiNewPlayerTask/XUiPanelTaskItem.lua create mode 100644 Resources/Scripts/XUi/XUiNewRoleShow/XUiNewRoleShow.lua create mode 100644 Resources/Scripts/XUi/XUiNewRoomSingle/XUiBattleRoleRoom.lua create mode 100644 Resources/Scripts/XUi/XUiNewRoomSingle/XUiBattleRoleRoomCaptain.lua create mode 100644 Resources/Scripts/XUi/XUiNewRoomSingle/XUiBattleRoleRoomDefaultProxy.lua create mode 100644 Resources/Scripts/XUi/XUiNewRoomSingle/XUiBattleRoomRoleDetail.lua create mode 100644 Resources/Scripts/XUi/XUiNewRoomSingle/XUiBattleRoomRoleDetailDefaultProxy.lua create mode 100644 Resources/Scripts/XUi/XUiNewRoomSingle/XUiBattleRoomRoleGrid.lua create mode 100644 Resources/Scripts/XUi/XUiNewRoomSingle/XUiNewRoomSingle.lua create mode 100644 Resources/Scripts/XUi/XUiNewRoomSingle/XUiNewRoomSingleProxy.lua create mode 100644 Resources/Scripts/XUi/XUiNewRoomSingle/XUiNewRoomSingleTip.lua create mode 100644 Resources/Scripts/XUi/XUiNewRoomSingle/XUiPanelActiveBuff.lua create mode 100644 Resources/Scripts/XUi/XUiNewRoomSingle/XUiPanelActiveBuffTip.lua create mode 100644 Resources/Scripts/XUi/XUiNewRoomSingle/XUiPanelArenaOnline.lua create mode 100644 Resources/Scripts/XUi/XUiNewRoomSingle/XUiPanelBabelTower.lua create mode 100644 Resources/Scripts/XUi/XUiNewYearDrawActivity/XUiDrawActivityControl.lua create mode 100644 Resources/Scripts/XUi/XUiNewYearDrawActivity/XUiDrawBuyAssert.lua create mode 100644 Resources/Scripts/XUi/XUiNewYearDrawActivity/XUiDrawNewYear.lua create mode 100644 Resources/Scripts/XUi/XUiNewYearDrawActivity/XUiDrawNewYearActivityShow.lua create mode 100644 Resources/Scripts/XUi/XUiNewYearDrawActivity/XUiNewYearDrawLog.lua create mode 100644 Resources/Scripts/XUi/XUiNieR/XUiCharacter/XGridNieRPODUpLvDetail.lua create mode 100644 Resources/Scripts/XUi/XUiNieR/XUiCharacter/XGridNieRUpLvDetail.lua create mode 100644 Resources/Scripts/XUi/XUiNieR/XUiCharacter/XUiFuBenNierWork.lua create mode 100644 Resources/Scripts/XUi/XUiNieR/XUiCharacter/XUiFubenNierShengji.lua create mode 100644 Resources/Scripts/XUi/XUiNieR/XUiCharacter/XUiGridNierPODSkill.lua create mode 100644 Resources/Scripts/XUi/XUiNieR/XUiCharacter/XUiGrideNieRCharacterFoster.lua create mode 100644 Resources/Scripts/XUi/XUiNieR/XUiCharacter/XUiGrideNieRCharacterStory.lua create mode 100644 Resources/Scripts/XUi/XUiNieR/XUiCharacter/XUiNierCharacter.lua create mode 100644 Resources/Scripts/XUi/XUiNieR/XUiCharacter/XUiNierCharacterSel.lua create mode 100644 Resources/Scripts/XUi/XUiNieR/XUiCharacter/XUiNierRoomSingle.lua create mode 100644 Resources/Scripts/XUi/XUiNieR/XUiCharacter/XUiPanelNierCharacterFoster.lua create mode 100644 Resources/Scripts/XUi/XUiNieR/XUiCharacter/XUiPanelNierCharacterStory.lua create mode 100644 Resources/Scripts/XUi/XUiNieR/XUiCharacter/XUiPanelNierCharacterTeaching.lua create mode 100644 Resources/Scripts/XUi/XUiNieR/XUiFubenNierEnter.lua create mode 100644 Resources/Scripts/XUi/XUiNieR/XUiFubenNierGuanqiaNormal.lua create mode 100644 Resources/Scripts/XUi/XUiNieR/XUiGridFubenNierPODSkill.lua create mode 100644 Resources/Scripts/XUi/XUiNieR/XUiGridNieRTaskBtn.lua create mode 100644 Resources/Scripts/XUi/XUiNieR/XUiGridNierChapter.lua create mode 100644 Resources/Scripts/XUi/XUiNieR/XUiGridNierStage.lua create mode 100644 Resources/Scripts/XUi/XUiNieR/XUiMainLine/XUiFubenNierLineChapter.lua create mode 100644 Resources/Scripts/XUi/XUiNieR/XUiMainLine/XUiPanelChapterStage.lua create mode 100644 Resources/Scripts/XUi/XUiNieR/XUiMainLine/XUiPanelMainlineChapter.lua create mode 100644 Resources/Scripts/XUi/XUiNieR/XUiNieRBossFightResult.lua create mode 100644 Resources/Scripts/XUi/XUiNieR/XUiNieREasterEgg/XGridNieREasterEggChatList.lua create mode 100644 Resources/Scripts/XUi/XUiNieR/XUiNieREasterEgg/XPanelNieREasterEggAge.lua create mode 100644 Resources/Scripts/XUi/XUiNieR/XUiNieREasterEgg/XPanelNieREasterEggChat.lua create mode 100644 Resources/Scripts/XUi/XUiNieR/XUiNieREasterEgg/XPanelNieREasterEggChatList.lua create mode 100644 Resources/Scripts/XUi/XUiNieR/XUiNieREasterEgg/XPanelNieREasterEggTag.lua create mode 100644 Resources/Scripts/XUi/XUiNieR/XUiNieREasterEgg/XUiFightNieRTips.lua create mode 100644 Resources/Scripts/XUi/XUiNieR/XUiNieREasterEgg/XUiNieREasterEgg.lua create mode 100644 Resources/Scripts/XUi/XUiNieR/XUiNieREasterEgg/XUiNieRSaveData.lua create mode 100644 Resources/Scripts/XUi/XUiNieR/XUiNieRNewRoomSingle.lua create mode 100644 Resources/Scripts/XUi/XUiNieR/XUiNieRTask.lua create mode 100644 Resources/Scripts/XUi/XUiNieR/XUiNierMainLineBanner.lua create mode 100644 Resources/Scripts/XUi/XUiNieR/XUiNierShop.lua create mode 100644 Resources/Scripts/XUi/XUiNieR/XUiPanelNieRTask.lua create mode 100644 Resources/Scripts/XUi/XUiNieR/XUiRepeat/XUiFubenNierRepeat.lua create mode 100644 Resources/Scripts/XUi/XUiNieR/XUiRepeat/XUiGridNierRepeatMainStage.lua create mode 100644 Resources/Scripts/XUi/XUiNieR/XUiRepeat/XUiGridNierRepeatStage.lua create mode 100644 Resources/Scripts/XUi/XUiNieR/XUiRepeat/XUiNieRRepeatTag.lua create mode 100644 Resources/Scripts/XUi/XUiNieR/XUiRepeat/XUiNierRepeatLineBanner.lua create mode 100644 Resources/Scripts/XUi/XUiNieR/XUiRepeat/XUiPanelNieRRepeatBanner.lua create mode 100644 Resources/Scripts/XUi/XUiNoticeTips/XUiNoticeTips.lua create mode 100644 Resources/Scripts/XUi/XUiObtain/XUiGridCommon.lua create mode 100644 Resources/Scripts/XUi/XUiObtain/XUiObtain.lua create mode 100644 Resources/Scripts/XUi/XUiOnLineTranscript/XUiOnLineMatching.lua create mode 100644 Resources/Scripts/XUi/XUiOnLineTranscript/XUiOnLineTranscript.lua create mode 100644 Resources/Scripts/XUi/XUiOnlineBoss/UiOnlineBossActivity.lua create mode 100644 Resources/Scripts/XUi/XUiOnlineBoss/XUiGridOnlineBossTask.lua create mode 100644 Resources/Scripts/XUi/XUiOnlineBoss/XUiOnlineBoss.lua create mode 100644 Resources/Scripts/XUi/XUiOnlineBoss/XUiPanelBossInfo.lua create mode 100644 Resources/Scripts/XUi/XUiOnlineBoss/XUiPanelMatch.lua create mode 100644 Resources/Scripts/XUi/XUiOnlineBoss/XUiPanelSkillBox.lua create mode 100644 Resources/Scripts/XUi/XUiOnlineLoading/XUiOnLineLoading.lua create mode 100644 Resources/Scripts/XUi/XUiOnlineLoading/XUiPanelOnLineLoadingDetail.lua create mode 100644 Resources/Scripts/XUi/XUiOnlineLoading/XUiPanelOnLineLoadingDetailItem.lua create mode 100644 Resources/Scripts/XUi/XUiPartner/PartnerCarry/XUiGridPartnerCarry.lua create mode 100644 Resources/Scripts/XUi/XUiPartner/PartnerCarry/XUiPartnerCarry.lua create mode 100644 Resources/Scripts/XUi/XUiPartner/PartnerCommon/XPartnerSort.lua create mode 100644 Resources/Scripts/XUi/XUiPartner/PartnerCommon/XUiGridBagPartner.lua create mode 100644 Resources/Scripts/XUi/XUiPartner/PartnerCommon/XUiGridPartnerAttrib.lua create mode 100644 Resources/Scripts/XUi/XUiPartner/PartnerCommon/XUiGridSkill.lua create mode 100644 Resources/Scripts/XUi/XUiPartner/PartnerCommon/XUiPanelMainSkill.lua create mode 100644 Resources/Scripts/XUi/XUiPartner/PartnerCommon/XUiPartnerPopupTip.lua create mode 100644 Resources/Scripts/XUi/XUiPartner/PartnerCompose/XUiPartnerCompose.lua create mode 100644 Resources/Scripts/XUi/XUiPartner/PartnerInfo/XUiPartnerOwnedInfo.lua create mode 100644 Resources/Scripts/XUi/XUiPartner/PartnerInfo/XUiPartnerRename.lua create mode 100644 Resources/Scripts/XUi/XUiPartner/PartnerMain/XUiGridPartner.lua create mode 100644 Resources/Scripts/XUi/XUiPartner/PartnerMain/XUiPartnerMain.lua create mode 100644 Resources/Scripts/XUi/XUiPartner/PartnerPreview/XUiPartnerPreview.lua create mode 100644 Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerLevel/XUiPanelLevelBreak.lua create mode 100644 Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerLevel/XUiPanelLevelMax.lua create mode 100644 Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerLevel/XUiPanelLevelUp.lua create mode 100644 Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerLevel/XUiPanelPartnerLevel.lua create mode 100644 Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerQuality/XUiGridCanEatPartner.lua create mode 100644 Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerQuality/XUiPanelPartnerQuality.lua create mode 100644 Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerQuality/XUiPanelQualityMax.lua create mode 100644 Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerQuality/XUiPanelQualityStar.lua create mode 100644 Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerQuality/XUiPanelQualityUp.lua create mode 100644 Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerQuality/XUiPanelQualityUpConfirm.lua create mode 100644 Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerSkill/UiPartnerSkillLevelUpAll.lua create mode 100644 Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerSkill/XUiGridSkillUp.lua create mode 100644 Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerSkill/XUiPanelAnimationControl.lua create mode 100644 Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerSkill/XUiPanelPartnerSkill.lua create mode 100644 Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerSkill/XUiPanelSkillUp.lua create mode 100644 Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerSkill/XUiPanelSkillUpConfirm.lua create mode 100644 Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerStory/XUiGridStoryInfo.lua create mode 100644 Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerStory/XUiPanelPartnerStory.lua create mode 100644 Resources/Scripts/XUi/XUiPartner/PartnerProperty/XUiPartnerProperty.lua create mode 100644 Resources/Scripts/XUi/XUiPartner/PartnerShow/XUiPanelPartnerOverview.lua create mode 100644 Resources/Scripts/XUi/XUiPartner/PartnerShow/XUiPanelPartnerPassiveSkill.lua create mode 100644 Resources/Scripts/XUi/XUiPartner/PartnerShow/XUiPanelPartnerShowMainSkill.lua create mode 100644 Resources/Scripts/XUi/XUiPartner/PartnerShow/XUiPanelPartnerShowMainSkillElement.lua create mode 100644 Resources/Scripts/XUi/XUiPartner/PartnerShow/XUiPanelPartnerShowMainSkillOption.lua create mode 100644 Resources/Scripts/XUi/XUiPartner/PartnerShow/XUiPartnerPropertyOther.lua create mode 100644 Resources/Scripts/XUi/XUiPartner/PartnerShow/XUiPartnerShowSkillGrid.lua create mode 100644 Resources/Scripts/XUi/XUiPartner/PartnerSkillInstall/MainSkill/XUiGridMainSkill.lua create mode 100644 Resources/Scripts/XUi/XUiPartner/PartnerSkillInstall/MainSkill/XUiGridSkillElement.lua create mode 100644 Resources/Scripts/XUi/XUiPartner/PartnerSkillInstall/MainSkill/XUiPanelElement.lua create mode 100644 Resources/Scripts/XUi/XUiPartner/PartnerSkillInstall/MainSkill/XUiPanelMainSkillOption.lua create mode 100644 Resources/Scripts/XUi/XUiPartner/PartnerSkillInstall/MainSkill/XUiPartnerActivateMainSkill.lua create mode 100644 Resources/Scripts/XUi/XUiPartner/PartnerSkillInstall/PassiveSkill/XUiGridPassiveSkill.lua create mode 100644 Resources/Scripts/XUi/XUiPartner/PartnerSkillInstall/PassiveSkill/XUiPartnerActivatePassiveSkill.lua create mode 100644 Resources/Scripts/XUi/XUiPartner/PartnerSkillPreview/XUiGridSkillDesc.lua create mode 100644 Resources/Scripts/XUi/XUiPartner/PartnerSkillPreview/XUiPartnerSkillPreview.lua create mode 100644 Resources/Scripts/XUi/XUiPartner/PartnerStrengthenSkip/XUiPartnerStrengthenSkip.lua create mode 100644 Resources/Scripts/XUi/XUiPassport/Card/XUiPassportCard.lua create mode 100644 Resources/Scripts/XUi/XUiPassport/Card/XUiPassportCardGrid.lua create mode 100644 Resources/Scripts/XUi/XUiPassport/UpLevel/XUiPassportUpLevel.lua create mode 100644 Resources/Scripts/XUi/XUiPassport/UpLevel/XUiPassportUpLevelGrid.lua create mode 100644 Resources/Scripts/XUi/XUiPassport/XUiPassport.lua create mode 100644 Resources/Scripts/XUi/XUiPassport/XUiPassportPanel.lua create mode 100644 Resources/Scripts/XUi/XUiPassport/XUiPassportPanelGrid.lua create mode 100644 Resources/Scripts/XUi/XUiPassport/XUiPassportPanelTaskActivity.lua create mode 100644 Resources/Scripts/XUi/XUiPassport/XUiPassportPanelTaskDaily.lua create mode 100644 Resources/Scripts/XUi/XUiPassport/XUiPassportPanelTaskWeekly.lua create mode 100644 Resources/Scripts/XUi/XUiPassport/XUiPassportTips.lua create mode 100644 Resources/Scripts/XUi/XUiPersonalInfo/PanelBoard/LeaveMsg/XUiPanelLeaveMsg.lua create mode 100644 Resources/Scripts/XUi/XUiPersonalInfo/PanelBoard/LeaveMsg/XUiPanelLeaveMsgItem.lua create mode 100644 Resources/Scripts/XUi/XUiPersonalInfo/PanelBoard/MsgBoard/XUiPanelMsgBoard.lua create mode 100644 Resources/Scripts/XUi/XUiPersonalInfo/PanelBoard/MsgBoard/XUiPanelMsgBoardItem.lua create mode 100644 Resources/Scripts/XUi/XUiPersonalInfo/PanelBoard/MsgBoard/XUiPanelWriteDiary.lua create mode 100644 Resources/Scripts/XUi/XUiPersonalInfo/PanelPersonalDetails/XUiPanelJubao.lua create mode 100644 Resources/Scripts/XUi/XUiPersonalInfo/PanelPersonalDetails/XUiPanelPersonalDetails.lua create mode 100644 Resources/Scripts/XUi/XUiPersonalInfo/PanelPersonalDetails/XUiPanelPersonalDetailsCombat.lua create mode 100644 Resources/Scripts/XUi/XUiPersonalInfo/PanelPersonalDetails/XUiPanelPersonalDetailsCombatItem.lua create mode 100644 Resources/Scripts/XUi/XUiPersonalInfo/PanelPersonalDetails/XUiPanelSupport.lua create mode 100644 Resources/Scripts/XUi/XUiPersonalInfo/XUiPersonalInfo.lua create mode 100644 Resources/Scripts/XUi/XUiPhotograph/XUiGridPhotographCharacterBtn.lua create mode 100644 Resources/Scripts/XUi/XUiPhotograph/XUiGridPhotographOtherBtn.lua create mode 100644 Resources/Scripts/XUi/XUiPhotograph/XUiGridPhotographSceneBtn.lua create mode 100644 Resources/Scripts/XUi/XUiPhotograph/XUiPhotograph.lua create mode 100644 Resources/Scripts/XUi/XUiPhotograph/XUiPhotographCapturePanel.lua create mode 100644 Resources/Scripts/XUi/XUiPhotograph/XUiPhotographPanel.lua create mode 100644 Resources/Scripts/XUi/XUiPhotograph/XUiPhotographSDKPanel.lua create mode 100644 Resources/Scripts/XUi/XUiPicComposition/XUiGridEditDialogue.lua create mode 100644 Resources/Scripts/XUi/XUiPicComposition/XUiGridHeadPortrait.lua create mode 100644 Resources/Scripts/XUi/XUiPicComposition/XUiGridNormalDialogue.lua create mode 100644 Resources/Scripts/XUi/XUiPicComposition/XUiGridRank.lua create mode 100644 Resources/Scripts/XUi/XUiPicComposition/XUiHeadPortraitSelect.lua create mode 100644 Resources/Scripts/XUi/XUiPicComposition/XUiPicChatRank.lua create mode 100644 Resources/Scripts/XUi/XUiPicComposition/XUiPicComposition.lua create mode 100644 Resources/Scripts/XUi/XUiPicComposition/XUiPicCompositionPanelActive.lua create mode 100644 Resources/Scripts/XUi/XUiPicComposition/XUiPicCompositionTask.lua create mode 100644 Resources/Scripts/XUi/XUiPlayer/XUiGridHeadFrame.lua create mode 100644 Resources/Scripts/XUi/XUiPlayer/XUiGridHeadPortrait.lua create mode 100644 Resources/Scripts/XUi/XUiPlayer/XUiPanelAchieve.lua create mode 100644 Resources/Scripts/XUi/XUiPlayer/XUiPanelHeadPortrait.lua create mode 100644 Resources/Scripts/XUi/XUiPlayer/XUiPanelPlayerExp.lua create mode 100644 Resources/Scripts/XUi/XUiPlayer/XUiPanelPlayerGloryExp.lua create mode 100644 Resources/Scripts/XUi/XUiPlayer/XUiPanelPlayerInfo.lua create mode 100644 Resources/Scripts/XUi/XUiPlayer/XUiPanelSetBirthday.lua create mode 100644 Resources/Scripts/XUi/XUiPlayer/XUiPanelSetHeadPortrait.lua create mode 100644 Resources/Scripts/XUi/XUiPlayer/XUiPanelSetName.lua create mode 100644 Resources/Scripts/XUi/XUiPlayer/XUiPanelSetting.lua create mode 100644 Resources/Scripts/XUi/XUiPlayer/XUiPlayer.lua create mode 100644 Resources/Scripts/XUi/XUiPlayerInfo/XUiEquipDetailChildOther.lua create mode 100644 Resources/Scripts/XUi/XUiPlayerInfo/XUiEquipDetailOther.lua create mode 100644 Resources/Scripts/XUi/XUiPlayerInfo/XUiGridEquipOther.lua create mode 100644 Resources/Scripts/XUi/XUiPlayerInfo/XUiGridResonanceSkillOther.lua create mode 100644 Resources/Scripts/XUi/XUiPlayerInfo/XUiGridSkillItemOther.lua create mode 100644 Resources/Scripts/XUi/XUiPlayerInfo/XUiGridSubSkillOther.lua create mode 100644 Resources/Scripts/XUi/XUiPlayerInfo/XUiPanelCharAllOther.lua create mode 100644 Resources/Scripts/XUi/XUiPlayerInfo/XUiPanelCharGradeOther.lua create mode 100644 Resources/Scripts/XUi/XUiPlayerInfo/XUiPanelCharLevelOther.lua create mode 100644 Resources/Scripts/XUi/XUiPlayerInfo/XUiPanelCharPropertyOther.lua create mode 100644 Resources/Scripts/XUi/XUiPlayerInfo/XUiPanelCharQualityOther.lua create mode 100644 Resources/Scripts/XUi/XUiPlayerInfo/XUiPanelCharSkillOther.lua create mode 100644 Resources/Scripts/XUi/XUiPlayerInfo/XUiPanelCharacterList.lua create mode 100644 Resources/Scripts/XUi/XUiPlayerInfo/XUiPanelCollectionScrollPlayerInfo.lua create mode 100644 Resources/Scripts/XUi/XUiPlayerInfo/XUiPanelFashionPlayerInfo.lua create mode 100644 Resources/Scripts/XUi/XUiPlayerInfo/XUiPanelInfo.lua create mode 100644 Resources/Scripts/XUi/XUiPlayerInfo/XUiPanelSkillInfoOther.lua create mode 100644 Resources/Scripts/XUi/XUiPlayerInfo/XUiPanelSkillLevelDetailOther.lua create mode 100644 Resources/Scripts/XUi/XUiPlayerInfo/XUiPlayerInfo.lua create mode 100644 Resources/Scripts/XUi/XUiPlayerInfo/XUiPlayerInfoAppearance.lua create mode 100644 Resources/Scripts/XUi/XUiPlayerInfo/XUiPlayerInfoBase.lua create mode 100644 Resources/Scripts/XUi/XUiPlayerInfo/XUiPlayerInfoCharacterGrid.lua create mode 100644 Resources/Scripts/XUi/XUiPlayerInfo/XUiPlayerInfoClothGrid.lua create mode 100644 Resources/Scripts/XUi/XUiPlayerInfo/XUiPlayerInfoFetters.lua create mode 100644 Resources/Scripts/XUi/XUiPlayerInfo/XUiPlayerInfoFight.lua create mode 100644 Resources/Scripts/XUi/XUiPlayerUp/XUiPlayerUp.lua create mode 100644 Resources/Scripts/XUi/XUiPokemon/XUiGridPokemonChapter.lua create mode 100644 Resources/Scripts/XUi/XUiPokemon/XUiGridPokemonPortrait.lua create mode 100644 Resources/Scripts/XUi/XUiPokemon/XUiGridPokemonStage.lua create mode 100644 Resources/Scripts/XUi/XUiPokemon/XUiGridPokemonStagePage.lua create mode 100644 Resources/Scripts/XUi/XUiPokemon/XUiMonster/XUiGridPokemonMonster.lua create mode 100644 Resources/Scripts/XUi/XUiPokemon/XUiMonster/XUiGridPokemonMonsterSelectSkill.lua create mode 100644 Resources/Scripts/XUi/XUiPokemon/XUiMonster/XUiPanelStars.lua create mode 100644 Resources/Scripts/XUi/XUiPokemon/XUiMonster/XUiPokemonMonster.lua create mode 100644 Resources/Scripts/XUi/XUiPokemon/XUiMonster/XUiPokemonMonsterObtain.lua create mode 100644 Resources/Scripts/XUi/XUiPokemon/XUiMonster/XUiPokemonSkillDetails.lua create mode 100644 Resources/Scripts/XUi/XUiPokemon/XUiMonster/XUiPokemonSkillSelect.lua create mode 100644 Resources/Scripts/XUi/XUiPokemon/XUiMonster/XUiPokemonStarSuccess.lua create mode 100644 Resources/Scripts/XUi/XUiPokemon/XUiMonster/XUiPokemonUpgradePreview.lua create mode 100644 Resources/Scripts/XUi/XUiPokemon/XUiPanelPokemonStageDetail.lua create mode 100644 Resources/Scripts/XUi/XUiPokemon/XUiPokemonActiveTask.lua create mode 100644 Resources/Scripts/XUi/XUiPokemon/XUiPokemonFight.lua create mode 100644 Resources/Scripts/XUi/XUiPokemon/XUiPokemonFormation/XUiGridPokemonInfinityStageMonster.lua create mode 100644 Resources/Scripts/XUi/XUiPokemon/XUiPokemonFormation/XUiGridPokemonMemberMonster.lua create mode 100644 Resources/Scripts/XUi/XUiPokemon/XUiPokemonFormation/XUiGridPokemonStageMonster.lua create mode 100644 Resources/Scripts/XUi/XUiPokemon/XUiPokemonFormation/XUiPokemonFormation.lua create mode 100644 Resources/Scripts/XUi/XUiPokemon/XUiPokemonMain.lua create mode 100644 Resources/Scripts/XUi/XUiPokemon/XUiPokemonMainLineBanner.lua create mode 100644 Resources/Scripts/XUi/XUiPokerGuessing/XUiFubenPokerGuessing.lua create mode 100644 Resources/Scripts/XUi/XUiPokerGuessing/XUiFubenPokerGuessingCardRecorder.lua create mode 100644 Resources/Scripts/XUi/XUiPokerGuessing/XUiFubenPokerGuessingTask.lua create mode 100644 Resources/Scripts/XUi/XUiPokerGuessing/XUiFubenPokerGuessingTips.lua create mode 100644 Resources/Scripts/XUi/XUiPrequel/XUiGridChallengeItem.lua create mode 100644 Resources/Scripts/XUi/XUiPrequel/XUiGridChallengeTab.lua create mode 100644 Resources/Scripts/XUi/XUiPrequel/XUiGridPrequelCheckPointReward.lua create mode 100644 Resources/Scripts/XUi/XUiPrequel/XUiGridPrequelPlotTab.lua create mode 100644 Resources/Scripts/XUi/XUiPrequel/XUiPanelChallengeChapter.lua create mode 100644 Resources/Scripts/XUi/XUiPrequel/XUiPanelChallengeMode.lua create mode 100644 Resources/Scripts/XUi/XUiPrequel/XUiPanelChallengeTab.lua create mode 100644 Resources/Scripts/XUi/XUiPrequel/XUiPanelCheckReward.lua create mode 100644 Resources/Scripts/XUi/XUiPrequel/XUiPanelEnterFightDialog.lua create mode 100644 Resources/Scripts/XUi/XUiPrequel/XUiPanelPlotTab.lua create mode 100644 Resources/Scripts/XUi/XUiPrequel/XUiPanelPrequelChapter.lua create mode 100644 Resources/Scripts/XUi/XUiPrequel/XUiPanelRegional.lua create mode 100644 Resources/Scripts/XUi/XUiPrequel/XUiPanelUnlockChallenge.lua create mode 100644 Resources/Scripts/XUi/XUiPrequel/XUiPrequel.lua create mode 100644 Resources/Scripts/XUi/XUiPrequelLineDetail/XUiPrequelLineDetail.lua create mode 100644 Resources/Scripts/XUi/XUiPromotionWay/XUiPromotionWay.lua create mode 100644 Resources/Scripts/XUi/XUiPurchase/XUiBatchPanel.lua create mode 100644 Resources/Scripts/XUi/XUiPurchase/XUiGridPurchaseYK.lua create mode 100644 Resources/Scripts/XUi/XUiPurchase/XUiPurchase.lua create mode 100644 Resources/Scripts/XUi/XUiPurchase/XUiPurchaseBuyTips.lua create mode 100644 Resources/Scripts/XUi/XUiPurchase/XUiPurchaseCoatingLB.lua create mode 100644 Resources/Scripts/XUi/XUiPurchase/XUiPurchaseCoatingLBListItem.lua create mode 100644 Resources/Scripts/XUi/XUiPurchase/XUiPurchaseDetail.lua create mode 100644 Resources/Scripts/XUi/XUiPurchase/XUiPurchaseHK.lua create mode 100644 Resources/Scripts/XUi/XUiPurchase/XUiPurchaseHKExchange.lua create mode 100644 Resources/Scripts/XUi/XUiPurchase/XUiPurchaseHKExchangeListItem.lua create mode 100644 Resources/Scripts/XUi/XUiPurchase/XUiPurchaseHKExchangeTips.lua create mode 100644 Resources/Scripts/XUi/XUiPurchase/XUiPurchaseHKListItem.lua create mode 100644 Resources/Scripts/XUi/XUiPurchase/XUiPurchaseHKShop.lua create mode 100644 Resources/Scripts/XUi/XUiPurchase/XUiPurchaseHKShopListItem.lua create mode 100644 Resources/Scripts/XUi/XUiPurchase/XUiPurchaseLB.lua create mode 100644 Resources/Scripts/XUi/XUiPurchase/XUiPurchaseLBListItem.lua create mode 100644 Resources/Scripts/XUi/XUiPurchase/XUiPurchaseLBTips.lua create mode 100644 Resources/Scripts/XUi/XUiPurchase/XUiPurchaseLBTipsListItem.lua create mode 100644 Resources/Scripts/XUi/XUiPurchase/XUiPurchasePay.lua create mode 100644 Resources/Scripts/XUi/XUiPurchase/XUiPurchasePayAdd.lua create mode 100644 Resources/Scripts/XUi/XUiPurchase/XUiPurchasePayAddListItem.lua create mode 100644 Resources/Scripts/XUi/XUiPurchase/XUiPurchasePayListItem.lua create mode 100644 Resources/Scripts/XUi/XUiPurchase/XUiPurchaseSignTip/XUiPurchaseSignTip.lua create mode 100644 Resources/Scripts/XUi/XUiPurchase/XUiPurchaseSignTip/XUiPurchaseSignTipGridDay.lua create mode 100644 Resources/Scripts/XUi/XUiPurchase/XUiPurchaseSignTip/XUiPurchaseSignTipRound.lua create mode 100644 Resources/Scripts/XUi/XUiPurchase/XUiPurchaseYK.lua create mode 100644 Resources/Scripts/XUi/XUiPurchase/XUiPurchaseYKListItem.lua create mode 100644 Resources/Scripts/XUi/XUiRedEnvelope/XUiGridRedEnvelopeInfo.lua create mode 100644 Resources/Scripts/XUi/XUiRedEnvelope/XUiRedEnvelope.lua create mode 100644 Resources/Scripts/XUi/XUiReform/XUiReform.lua create mode 100644 Resources/Scripts/XUi/XUiReform/XUiReformBuffDetail.lua create mode 100644 Resources/Scripts/XUi/XUiReform/XUiReformBuffPanel.lua create mode 100644 Resources/Scripts/XUi/XUiReform/XUiReformBuffTips.lua create mode 100644 Resources/Scripts/XUi/XUiReform/XUiReformCharacterDetailInfo.lua create mode 100644 Resources/Scripts/XUi/XUiReform/XUiReformCharacterInfo.lua create mode 100644 Resources/Scripts/XUi/XUiReform/XUiReformCombatSettleWin.lua create mode 100644 Resources/Scripts/XUi/XUiReform/XUiReformEnemyPanel.lua create mode 100644 Resources/Scripts/XUi/XUiReform/XUiReformEnvironmentPanel.lua create mode 100644 Resources/Scripts/XUi/XUiReform/XUiReformList.lua create mode 100644 Resources/Scripts/XUi/XUiReform/XUiReformMemberPanel.lua create mode 100644 Resources/Scripts/XUi/XUiReform/XUiReformNewRoomSingle.lua create mode 100644 Resources/Scripts/XUi/XUiReform/XUiReformPreview.lua create mode 100644 Resources/Scripts/XUi/XUiReform/XUiReformRoleList.lua create mode 100644 Resources/Scripts/XUi/XUiReform/XUiReformTeamUp.lua create mode 100644 Resources/Scripts/XUi/XUiRegister/XUiGridAccount.lua create mode 100644 Resources/Scripts/XUi/XUiRegister/XUiRegister.lua create mode 100644 Resources/Scripts/XUi/XUiRegression/XUiGridRegressionTaskSchedule.lua create mode 100644 Resources/Scripts/XUi/XUiRegression/XUiPanelRegressionTaskCourse.lua create mode 100644 Resources/Scripts/XUi/XUiRegression/XUiPanelRegressionTaskDay.lua create mode 100644 Resources/Scripts/XUi/XUiRegression/XUiPanelRegressionTaskWeek.lua create mode 100644 Resources/Scripts/XUi/XUiRegression/XUiRegression.lua create mode 100644 Resources/Scripts/XUi/XUiRegression/XUiRegressionTask.lua create mode 100644 Resources/Scripts/XUi/XUiReport/XUiReport.lua create mode 100644 Resources/Scripts/XUi/XUiRoomCharacter/XUiGridFilterTagGroup.lua create mode 100644 Resources/Scripts/XUi/XUiRoomCharacter/XUiRoomCharacter.lua create mode 100644 Resources/Scripts/XUi/XUiRoomCharacter/XUiRoomCharacterFilterTips.lua create mode 100644 Resources/Scripts/XUi/XUiRoomCharacter/XUiRoomCharacterProxy.lua create mode 100644 Resources/Scripts/XUi/XUiRoomTeamBuff/XUiRoomTeamBuff.lua create mode 100644 Resources/Scripts/XUi/XUiRoomTeamPrefab/XUiGridTeam.lua create mode 100644 Resources/Scripts/XUi/XUiRoomTeamPrefab/XUiGridTeamCharacter.lua create mode 100644 Resources/Scripts/XUi/XUiRoomTeamPrefab/XUiGridTeamRole.lua create mode 100644 Resources/Scripts/XUi/XUiRoomTeamPrefab/XUiPanelTeamSelect.lua create mode 100644 Resources/Scripts/XUi/XUiRoomTeamPrefab/XUiRoomTeamPrefab.lua create mode 100644 Resources/Scripts/XUi/XUiRoomTeamPrefab/XUiTeamPrefabReName.lua create mode 100644 Resources/Scripts/XUi/XUiRpgMakerGame/Character/XUiRpgMakerGameCharacter.lua create mode 100644 Resources/Scripts/XUi/XUiRpgMakerGame/Character/XUiRpgMakerGameCharacterGrid.lua create mode 100644 Resources/Scripts/XUi/XUiRpgMakerGame/Hint/XUiGridRpgMakerGameCardMini.lua create mode 100644 Resources/Scripts/XUi/XUiRpgMakerGame/Hint/XUiGridRpgMakerGameMapNode.lua create mode 100644 Resources/Scripts/XUi/XUiRpgMakerGame/Hint/XUiGridRpgMakerGameRecord.lua create mode 100644 Resources/Scripts/XUi/XUiRpgMakerGame/Hint/XUiRpgMakerGameMapTip.lua create mode 100644 Resources/Scripts/XUi/XUiRpgMakerGame/Main/XUiRpgMakerGameDetail.lua create mode 100644 Resources/Scripts/XUi/XUiRpgMakerGame/Main/XUiRpgMakerGameMain.lua create mode 100644 Resources/Scripts/XUi/XUiRpgMakerGame/Main/XUiRpgMakerGameStage.lua create mode 100644 Resources/Scripts/XUi/XUiRpgMakerGame/Main/XUiRpgMakerGameStages.lua create mode 100644 Resources/Scripts/XUi/XUiRpgMakerGame/Main/XUiRpgMakerGameTabBtn.lua create mode 100644 Resources/Scripts/XUi/XUiRpgMakerGame/PlayMain/XUiRpgMakerGamePanelLoseTip.lua create mode 100644 Resources/Scripts/XUi/XUiRpgMakerGame/PlayMain/XUiRpgMakerGamePanelWinTip.lua create mode 100644 Resources/Scripts/XUi/XUiRpgMakerGame/PlayMain/XUiRpgMakerGamePlayMain.lua create mode 100644 Resources/Scripts/XUi/XUiRpgMakerGame/PlayMain/XUiRpgMakerGamePlayScene.lua create mode 100644 Resources/Scripts/XUi/XUiRpgMakerGame/PlayMain/XUiRpgMakerGameUnlockTip.lua create mode 100644 Resources/Scripts/XUi/XUiRpgMakerGame/Task/XUiRpgMakerGamePlayTask.lua create mode 100644 Resources/Scripts/XUi/XUiRpgMakerGame/XUiFubenRpgMakerGameMovie.lua create mode 100644 Resources/Scripts/XUi/XUiRpgTower/Battle/BattleResult/XUiRpgTowerSettleWin.lua create mode 100644 Resources/Scripts/XUi/XUiRpgTower/Battle/ChangeMember/XUiRpgTowerRoomCharaListItem.lua create mode 100644 Resources/Scripts/XUi/XUiRpgTower/Battle/ChangeMember/XUiRpgTowerRoomCharaListPanel.lua create mode 100644 Resources/Scripts/XUi/XUiRpgTower/Battle/ChangeMember/XUiRpgTowerRoomCharacter.lua create mode 100644 Resources/Scripts/XUi/XUiRpgTower/Battle/EditBattleUi/XUiRpgTowerNewRoomSingle.lua create mode 100644 Resources/Scripts/XUi/XUiRpgTower/CharacterPage/AdaptPage/XUiRpgTowerRoleListAdaptPage.lua create mode 100644 Resources/Scripts/XUi/XUiRpgTower/CharacterPage/AdaptPage/XUiRpgTowerRoleListAdaptPanel.lua create mode 100644 Resources/Scripts/XUi/XUiRpgTower/CharacterPage/AdaptPage/XUiRpgTowerRoleListTalentLevel.lua create mode 100644 Resources/Scripts/XUi/XUiRpgTower/CharacterPage/ChangeMemberPage/XUiRpgTowerChangeMemberItem.lua create mode 100644 Resources/Scripts/XUi/XUiRpgTower/CharacterPage/ChangeMemberPage/XUiRpgTowerChangeMemberList.lua create mode 100644 Resources/Scripts/XUi/XUiRpgTower/CharacterPage/ChangeMemberPage/XUiRpgTowerRoleListChangeMember.lua create mode 100644 Resources/Scripts/XUi/XUiRpgTower/CharacterPage/ChangeMemberPage/XUiRpgTowerRoleListChangeMemberPage.lua create mode 100644 Resources/Scripts/XUi/XUiRpgTower/CharacterPage/GrowPage/XUiRpgTowerGrowPageLevelUpPanel.lua create mode 100644 Resources/Scripts/XUi/XUiRpgTower/CharacterPage/GrowPage/XUiRpgTowerGrowPageNatureItem.lua create mode 100644 Resources/Scripts/XUi/XUiRpgTower/CharacterPage/GrowPage/XUiRpgTowerGrowPageNatureLine.lua create mode 100644 Resources/Scripts/XUi/XUiRpgTower/CharacterPage/GrowPage/XUiRpgTowerGrowPageNaturePanel.lua create mode 100644 Resources/Scripts/XUi/XUiRpgTower/CharacterPage/GrowPage/XUiRpgTowerGrowPageTabsPanel.lua create mode 100644 Resources/Scripts/XUi/XUiRpgTower/CharacterPage/GrowPage/XUiRpgTowerLevelUpTipsPanel.lua create mode 100644 Resources/Scripts/XUi/XUiRpgTower/CharacterPage/GrowPage/XUiRpgTowerRoleListGrowPage.lua create mode 100644 Resources/Scripts/XUi/XUiRpgTower/CharacterPage/MainPage/XUiRpgTowerCharaInfoInfo.lua create mode 100644 Resources/Scripts/XUi/XUiRpgTower/CharacterPage/MainPage/XUiRpgTowerCharaInfoSkillGrid.lua create mode 100644 Resources/Scripts/XUi/XUiRpgTower/CharacterPage/MainPage/XUiRpgTowerCharaInfoSkills.lua create mode 100644 Resources/Scripts/XUi/XUiRpgTower/CharacterPage/MainPage/XUiRpgTowerCharaInfoStatus.lua create mode 100644 Resources/Scripts/XUi/XUiRpgTower/CharacterPage/MainPage/XUiRpgTowerRoleListCharaInfo.lua create mode 100644 Resources/Scripts/XUi/XUiRpgTower/CharacterPage/MainPage/XUiRpgTowerRoleListMainPage.lua create mode 100644 Resources/Scripts/XUi/XUiRpgTower/CharacterPage/PanelCharacterList/XUiRpgTowerTeamList.lua create mode 100644 Resources/Scripts/XUi/XUiRpgTower/CharacterPage/PanelCharacterList/XUiRpgTowerTeamListItem.lua create mode 100644 Resources/Scripts/XUi/XUiRpgTower/CharacterPage/SkillDetails/XUiRpgTowerSkillDetails.lua create mode 100644 Resources/Scripts/XUi/XUiRpgTower/CharacterPage/TalentDetails/XUiRpgTowerNature.lua create mode 100644 Resources/Scripts/XUi/XUiRpgTower/CharacterPage/TalentTotalView/XUiRpgTowerCollect.lua create mode 100644 Resources/Scripts/XUi/XUiRpgTower/CharacterPage/TalentTotalView/XUiRpgTowerCollectPanelSkillInfo.lua create mode 100644 Resources/Scripts/XUi/XUiRpgTower/CharacterPage/TalentTotalView/XUiRpgTowerCollectPanelStatus.lua create mode 100644 Resources/Scripts/XUi/XUiRpgTower/CharacterPage/TalentTotalView/XUiRpgTowerCollectPanelTalent.lua create mode 100644 Resources/Scripts/XUi/XUiRpgTower/CharacterPage/TalentTotalView/XUiRpgTowerCollectTalentGrid.lua create mode 100644 Resources/Scripts/XUi/XUiRpgTower/CharacterPage/XUiRpgTowerRoleList.lua create mode 100644 Resources/Scripts/XUi/XUiRpgTower/Common/XUiRpgTowerCharaItem.lua create mode 100644 Resources/Scripts/XUi/XUiRpgTower/Common/XUiRpgTowerItemIcon.lua create mode 100644 Resources/Scripts/XUi/XUiRpgTower/Common/XUiRpgTowerLevelUp.lua create mode 100644 Resources/Scripts/XUi/XUiRpgTower/Common/XUiRpgTowerSettleWinExpBar.lua create mode 100644 Resources/Scripts/XUi/XUiRpgTower/Common/XUiRpgTowerStarPanel.lua create mode 100644 Resources/Scripts/XUi/XUiRpgTower/Common/XUiRpgTowerTeamBar.lua create mode 100644 Resources/Scripts/XUi/XUiRpgTower/MainPage/PanelMonsters/XUiRpgTowerMonsterGrid.lua create mode 100644 Resources/Scripts/XUi/XUiRpgTower/MainPage/PanelMonsters/XUiRpgTowerMonstersPanel.lua create mode 100644 Resources/Scripts/XUi/XUiRpgTower/MainPage/PanelRole/XUiRpgTowerRolePanel.lua create mode 100644 Resources/Scripts/XUi/XUiRpgTower/MainPage/PanelStageDetails/XUiRpgTowerStageBuffIcon.lua create mode 100644 Resources/Scripts/XUi/XUiRpgTower/MainPage/PanelStageDetails/XUiRpgTowerStageBuffPanel.lua create mode 100644 Resources/Scripts/XUi/XUiRpgTower/MainPage/PanelStageDetails/XUiRpgTowerStageDetails.lua create mode 100644 Resources/Scripts/XUi/XUiRpgTower/MainPage/PanelStageDetails/XUiRpgTowerStageRewardsPanel.lua create mode 100644 Resources/Scripts/XUi/XUiRpgTower/MainPage/PanelStageList/XUiRpgTowerStageGrid.lua create mode 100644 Resources/Scripts/XUi/XUiRpgTower/MainPage/PanelStageList/XUiRpgTowerStageList.lua create mode 100644 Resources/Scripts/XUi/XUiRpgTower/MainPage/XUiRpgTowerMain.lua create mode 100644 Resources/Scripts/XUi/XUiRpgTower/Task/XUiRpgTowerTask.lua create mode 100644 Resources/Scripts/XUi/XUiRpgTower/Task/XUiRpgTowerTaskList.lua create mode 100644 Resources/Scripts/XUi/XUiSet/ChildItem/XUiBtnKeyItem.lua create mode 100644 Resources/Scripts/XUi/XUiSet/XUiCombatTask.lua create mode 100644 Resources/Scripts/XUi/XUiSet/XUiInstruction.lua create mode 100644 Resources/Scripts/XUi/XUiSet/XUiInstructionMonster.lua create mode 100644 Resources/Scripts/XUi/XUiSet/XUiPanelAccountSet.lua create mode 100644 Resources/Scripts/XUi/XUiSet/XUiPanelFightSet.lua create mode 100644 Resources/Scripts/XUi/XUiSet/XUiPanelFightSetPc.lua create mode 100644 Resources/Scripts/XUi/XUiSet/XUiPanelGraphicsSet.lua create mode 100644 Resources/Scripts/XUi/XUiSet/XUiPanelGraphicsSetPc.lua create mode 100644 Resources/Scripts/XUi/XUiSet/XUiPanelOtherSet.lua create mode 100644 Resources/Scripts/XUi/XUiSet/XUiPanelOtherSetPc.lua create mode 100644 Resources/Scripts/XUi/XUiSet/XUiPanelPushSet.lua create mode 100644 Resources/Scripts/XUi/XUiSet/XUiPanelVoiceSet.lua create mode 100644 Resources/Scripts/XUi/XUiSet/XUiSet.lua create mode 100644 Resources/Scripts/XUi/XUiSettleLose/XUiGridLoseTip.lua create mode 100644 Resources/Scripts/XUi/XUiSettleLose/XUiSettleLose.lua create mode 100644 Resources/Scripts/XUi/XUiSettleUrgentEvent/XUiSettleUrgentEvent.lua create mode 100644 Resources/Scripts/XUi/XUiSettleWin/XUiGridWinRole.lua create mode 100644 Resources/Scripts/XUi/XUiSettleWin/XUiPanelSettleWinPokemon.lua create mode 100644 Resources/Scripts/XUi/XUiSettleWin/XUiSettleWin.lua create mode 100644 Resources/Scripts/XUi/XUiSettleWinMainLine/XUiGridCond.lua create mode 100644 Resources/Scripts/XUi/XUiSettleWinMainLine/XUiPanelExpBar.lua create mode 100644 Resources/Scripts/XUi/XUiSettleWinMainLine/XUiSettleWinMainLine.lua create mode 100644 Resources/Scripts/XUi/XUiSettleWinSingleBoss/XUiSettleWinSingleBoss.lua create mode 100644 Resources/Scripts/XUi/XUiShop/XUiGridFashionShop.lua create mode 100644 Resources/Scripts/XUi/XUiShop/XUiGridShop.lua create mode 100644 Resources/Scripts/XUi/XUiShop/XUiPanelActivityAsset.lua create mode 100644 Resources/Scripts/XUi/XUiShop/XUiPanelFashionList.lua create mode 100644 Resources/Scripts/XUi/XUiShop/XUiPanelItemList.lua create mode 100644 Resources/Scripts/XUi/XUiShop/XUiPanelShopItem.lua create mode 100644 Resources/Scripts/XUi/XUiShop/XUiPanelShopPeriod.lua create mode 100644 Resources/Scripts/XUi/XUiShop/XUiShop.lua create mode 100644 Resources/Scripts/XUi/XUiShop/XUiShopItem.lua create mode 100644 Resources/Scripts/XUi/XUiSignIn/XUiDiviningLog.lua create mode 100644 Resources/Scripts/XUi/XUiSignIn/XUiNewYearSignIn.lua create mode 100644 Resources/Scripts/XUi/XUiSignIn/XUiSign.lua create mode 100644 Resources/Scripts/XUi/XUiSignIn/XUiSignBanner.lua create mode 100644 Resources/Scripts/XUi/XUiSignIn/XUiSignCard.lua create mode 100644 Resources/Scripts/XUi/XUiSignIn/XUiSignEnKrNewyear.lua create mode 100644 Resources/Scripts/XUi/XUiSignIn/XUiSignFirstRecharge.lua create mode 100644 Resources/Scripts/XUi/XUiSignIn/XUiSignGridDay.lua create mode 100644 Resources/Scripts/XUi/XUiSignIn/XUiSignNewYearDrawActivity.lua create mode 100644 Resources/Scripts/XUi/XUiSignIn/XUiSignPrefab.lua create mode 100644 Resources/Scripts/XUi/XUiSignIn/XUiSignPrefabContent.lua create mode 100644 Resources/Scripts/XUi/XUiSkip/XUiSkip.lua create mode 100644 Resources/Scripts/XUi/XUiSocial/AddContactModel/XUiGridAddContactItem.lua create mode 100644 Resources/Scripts/XUi/XUiSocial/AddContactModel/XUiPanelAddContactView.lua create mode 100644 Resources/Scripts/XUi/XUiSocial/AddContactModel/XUiPanelAddContactViewPools.lua create mode 100644 Resources/Scripts/XUi/XUiSocial/Black/XUiBlackGrid.lua create mode 100644 Resources/Scripts/XUi/XUiSocial/Black/XUiPanelBlackView.lua create mode 100644 Resources/Scripts/XUi/XUiSocial/ContactModel/XUiGridContactItem.lua create mode 100644 Resources/Scripts/XUi/XUiSocial/ContactModel/XUiPanelContactView.lua create mode 100644 Resources/Scripts/XUi/XUiSocial/PanelTips/XUiPanelTips.lua create mode 100644 Resources/Scripts/XUi/XUiSocial/PanelTips/XUiTipContent.lua create mode 100644 Resources/Scripts/XUi/XUiSocial/PrivateChatModel/ItemModel/XUiGridTishi.lua create mode 100644 Resources/Scripts/XUi/XUiSocial/PrivateChatModel/ItemModel/XUiTogFriendBox.lua create mode 100644 Resources/Scripts/XUi/XUiSocial/PrivateChatModel/NewItemModel/XUiPanelSocialMyMsgEmojiItem.lua create mode 100644 Resources/Scripts/XUi/XUiSocial/PrivateChatModel/NewItemModel/XUiPanelSocialMyMsgGiftItem.lua create mode 100644 Resources/Scripts/XUi/XUiSocial/PrivateChatModel/NewItemModel/XUiPanelSocialMyMsgItem.lua create mode 100644 Resources/Scripts/XUi/XUiSocial/PrivateChatModel/NewItemModel/XUiPanelSocialTipsItem.lua create mode 100644 Resources/Scripts/XUi/XUiSocial/PrivateChatModel/Pools/XUiPanelGroupPools.lua create mode 100644 Resources/Scripts/XUi/XUiSocial/PrivateChatModel/Pools/XUiPanelSocialPools.lua create mode 100644 Resources/Scripts/XUi/XUiSocial/PrivateChatModel/XUiPanelPrivateChatView.lua create mode 100644 Resources/Scripts/XUi/XUiSocial/WaitPassModel/XUiGridWaitPassItem.lua create mode 100644 Resources/Scripts/XUi/XUiSocial/WaitPassModel/XUiPanelWaitForPassView.lua create mode 100644 Resources/Scripts/XUi/XUiSocial/XUiPanelDaily.lua create mode 100644 Resources/Scripts/XUi/XUiSocial/XUiSocial.lua create mode 100644 Resources/Scripts/XUi/XUiSocial/XUiSocialRename.lua create mode 100644 Resources/Scripts/XUi/XUiSpecialFashionShop/XUiCommodity.lua create mode 100644 Resources/Scripts/XUi/XUiSpecialFashionShop/XUiGridCommodityLine.lua create mode 100644 Resources/Scripts/XUi/XUiSpecialFashionShop/XUiSpecialFashionShop.lua create mode 100644 Resources/Scripts/XUi/XUiSpringFestival/CollectCard/XUiGridSpringFestivalBagItem.lua create mode 100644 Resources/Scripts/XUi/XUiSpringFestival/CollectCard/XUiGridSpringFestivalCollectCard.lua create mode 100644 Resources/Scripts/XUi/XUiSpringFestival/CollectCard/XUiGridSpringFestivalFriend.lua create mode 100644 Resources/Scripts/XUi/XUiSpringFestival/CollectCard/XUiGridSpringFestivalGiveFriend.lua create mode 100644 Resources/Scripts/XUi/XUiSpringFestival/CollectCard/XUiGridSpringFestivalGiveItem.lua create mode 100644 Resources/Scripts/XUi/XUiSpringFestival/CollectCard/XUiGridSpringFestivalRequestItem.lua create mode 100644 Resources/Scripts/XUi/XUiSpringFestival/CollectCard/XUiSpringFestivalBagTips.lua create mode 100644 Resources/Scripts/XUi/XUiSpringFestival/CollectCard/XUiSpringFestivalCollectCard.lua create mode 100644 Resources/Scripts/XUi/XUiSpringFestival/CollectCard/XUiSpringFestivalFriendsTip.lua create mode 100644 Resources/Scripts/XUi/XUiSpringFestival/CollectCard/XUiSpringFestivalGiveTips.lua create mode 100644 Resources/Scripts/XUi/XUiSpringFestival/CollectCard/XUiSpringFestivalHelpTips1.lua create mode 100644 Resources/Scripts/XUi/XUiSpringFestival/CollectCard/XUiSpringFestivalHelpTips2.lua create mode 100644 Resources/Scripts/XUi/XUiSpringFestival/CollectCard/XUiSpringFestivalTip.lua create mode 100644 Resources/Scripts/XUi/XUiSpringFestival/SmashEggs/XUiGridSpringFestivalBuffEffectItem.lua create mode 100644 Resources/Scripts/XUi/XUiSpringFestival/SmashEggs/XUiGridSpringFestivalSmashEggsReward.lua create mode 100644 Resources/Scripts/XUi/XUiSpringFestival/SmashEggs/XUiSpringFestivalSmashEggs.lua create mode 100644 Resources/Scripts/XUi/XUiSpringFestival/XUiFubenSpringFestivalChapter.lua create mode 100644 Resources/Scripts/XUi/XUiSpringFestival/XUiFubenSpringFestivalStageDetail.lua create mode 100644 Resources/Scripts/XUi/XUiSpringFestival/XUiPanelFubenSpringFestivalStage.lua create mode 100644 Resources/Scripts/XUi/XUiSpringFestival/XUiSpringFestivalStageItem.lua create mode 100644 Resources/Scripts/XUi/XUiSpringFestival/XUiStorySpringFestivalStageDetail.lua create mode 100644 Resources/Scripts/XUi/XUiStoryStageDetail/XUiStoryStageDetail.lua create mode 100644 Resources/Scripts/XUi/XUiStronghold/XUiGridQuickDeployMember.lua create mode 100644 Resources/Scripts/XUi/XUiStronghold/XUiGridQuickDeployTeam.lua create mode 100644 Resources/Scripts/XUi/XUiStronghold/XUiGridRewardLine.lua create mode 100644 Resources/Scripts/XUi/XUiStronghold/XUiGridStrongHoldTeamMember.lua create mode 100644 Resources/Scripts/XUi/XUiStronghold/XUiGridStrongholdBanner.lua create mode 100644 Resources/Scripts/XUi/XUiStronghold/XUiGridStrongholdBuff.lua create mode 100644 Resources/Scripts/XUi/XUiStronghold/XUiGridStrongholdCharacter.lua create mode 100644 Resources/Scripts/XUi/XUiStronghold/XUiGridStrongholdGroup.lua create mode 100644 Resources/Scripts/XUi/XUiStronghold/XUiGridStrongholdPlugin.lua create mode 100644 Resources/Scripts/XUi/XUiStronghold/XUiGridStrongholdPluginSet.lua create mode 100644 Resources/Scripts/XUi/XUiStronghold/XUiGridStrongholdTeam.lua create mode 100644 Resources/Scripts/XUi/XUiStronghold/XUiGridTeamCharacter.lua create mode 100644 Resources/Scripts/XUi/XUiStronghold/XUiPanelStrongholdChapter.lua create mode 100644 Resources/Scripts/XUi/XUiStronghold/XUiPanelStrongholdRoomCharacterOthers.lua create mode 100644 Resources/Scripts/XUi/XUiStronghold/XUiPanelStrongholdRoomCharacterSelf.lua create mode 100644 Resources/Scripts/XUi/XUiStronghold/XUiStrongholdActivityResult.lua create mode 100644 Resources/Scripts/XUi/XUiStronghold/XUiStrongholdAnimation.lua create mode 100644 Resources/Scripts/XUi/XUiStronghold/XUiStrongholdChooseLevelType.lua create mode 100644 Resources/Scripts/XUi/XUiStronghold/XUiStrongholdCoreTips.lua create mode 100644 Resources/Scripts/XUi/XUiStronghold/XUiStrongholdDeploy.lua create mode 100644 Resources/Scripts/XUi/XUiStronghold/XUiStrongholdDetail.lua create mode 100644 Resources/Scripts/XUi/XUiStronghold/XUiStrongholdFightMain.lua create mode 100644 Resources/Scripts/XUi/XUiStronghold/XUiStrongholdFightSettleWin.lua create mode 100644 Resources/Scripts/XUi/XUiStronghold/XUiStrongholdHelp.lua create mode 100644 Resources/Scripts/XUi/XUiStronghold/XUiStrongholdInfo.lua create mode 100644 Resources/Scripts/XUi/XUiStronghold/XUiStrongholdJournal/XUiGridRecord.lua create mode 100644 Resources/Scripts/XUi/XUiStronghold/XUiStrongholdJournal/XUiStrongholdJournal.lua create mode 100644 Resources/Scripts/XUi/XUiStronghold/XUiStrongholdMain.lua create mode 100644 Resources/Scripts/XUi/XUiStronghold/XUiStrongholdMainLineBanner.lua create mode 100644 Resources/Scripts/XUi/XUiStronghold/XUiStrongholdMinerUp.lua create mode 100644 Resources/Scripts/XUi/XUiStronghold/XUiStrongholdMining.lua create mode 100644 Resources/Scripts/XUi/XUiStronghold/XUiStrongholdPower.lua create mode 100644 Resources/Scripts/XUi/XUiStronghold/XUiStrongholdPowerExpectTips/XUiStrongholdPowerExpectTips.lua create mode 100644 Resources/Scripts/XUi/XUiStronghold/XUiStrongholdPowerExpectTips/XUiStrongholdPowerExpectTipsGrid.lua create mode 100644 Resources/Scripts/XUi/XUiStronghold/XUiStrongholdQuickDeploy.lua create mode 100644 Resources/Scripts/XUi/XUiStronghold/XUiStrongholdReward/XUiGridRewardTip.lua create mode 100644 Resources/Scripts/XUi/XUiStronghold/XUiStrongholdReward/XUiStrongholdRewardTip.lua create mode 100644 Resources/Scripts/XUi/XUiStronghold/XUiStrongholdRoomCharacter.lua create mode 100644 Resources/Scripts/XUi/XUiStronghold/XUiStrongholdRune/XUiGridSubRune.lua create mode 100644 Resources/Scripts/XUi/XUiStronghold/XUiStrongholdRune/XUiStrongholdRune.lua create mode 100644 Resources/Scripts/XUi/XUiStronghold/XUiStrongholdSkillDetails.lua create mode 100644 Resources/Scripts/XUi/XUiStronghold/XUiStrongholdSkillDetailsDialog.lua create mode 100644 Resources/Scripts/XUi/XUiStronghold/XUiStrongholdSupportTips.lua create mode 100644 Resources/Scripts/XUi/XUiSummerEpisode/Settle/XUiGridSummerEpisodeSettleDataItem.lua create mode 100644 Resources/Scripts/XUi/XUiSummerEpisode/Settle/XUiGridSummerEpisodeSettleItem.lua create mode 100644 Resources/Scripts/XUi/XUiSummerEpisode/Settle/XUiSummerEpisodeSettle.lua create mode 100644 Resources/Scripts/XUi/XUiSummerEpisode/XUiGridEliminate.lua create mode 100644 Resources/Scripts/XUi/XUiSummerEpisode/XUiGridEliminateIcon.lua create mode 100644 Resources/Scripts/XUi/XUiSummerEpisode/XUiGridMatchReward.lua create mode 100644 Resources/Scripts/XUi/XUiSummerEpisode/XUiGridNewSpecialReward.lua create mode 100644 Resources/Scripts/XUi/XUiSummerEpisode/XUiGridStageSpecialTrain.lua create mode 100644 Resources/Scripts/XUi/XUiSummerEpisode/XUiGridStarReward.lua create mode 100644 Resources/Scripts/XUi/XUiSummerEpisode/XUiGridSummerEpisodeMap.lua create mode 100644 Resources/Scripts/XUi/XUiSummerEpisode/XUiGridSummerEpisodePicture.lua create mode 100644 Resources/Scripts/XUi/XUiSummerEpisode/XUiGridSummerRank.lua create mode 100644 Resources/Scripts/XUi/XUiSummerEpisode/XUiSummerEpisode.lua create mode 100644 Resources/Scripts/XUi/XUiSummerEpisode/XUiSummerEpisodeChapter.lua create mode 100644 Resources/Scripts/XUi/XUiSummerEpisode/XUiSummerEpisodeMap.lua create mode 100644 Resources/Scripts/XUi/XUiSummerEpisode/XUiSummerEpisodeNew.lua create mode 100644 Resources/Scripts/XUi/XUiSummerEpisode/XUiSummerGridTask.lua create mode 100644 Resources/Scripts/XUi/XUiSummerEpisode/XUiSummerMatch.lua create mode 100644 Resources/Scripts/XUi/XUiSummerEpisode/XUiSummerOnlineSection.lua create mode 100644 Resources/Scripts/XUi/XUiSummerEpisode/XUiSummerRank.lua create mode 100644 Resources/Scripts/XUi/XUiSummerEpisode/XUiSummerStageDetail.lua create mode 100644 Resources/Scripts/XUi/XUiSummerEpisode/XUiSummerStarReward.lua create mode 100644 Resources/Scripts/XUi/XUiSummerEpisode/XUiSummerTaskReward.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSTBagButton.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSTBagCapacityPanel.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSTBagCapacityUpgrade.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSTBagDecomposionBtnPanel.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSTBagDecomposionGrid.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSTBagDecomposionPanel.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSTBagIllusBookGrid.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSTBagIllusFilterButton.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSTBagIllustratedBookPanel.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSTBagLineGraphPanel.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSTBagPluginsGrid.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSTBagPluginsPanel.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSTBagShopBtnPanel.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSTBagToggleButton.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSTBagTogglePanel.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSuperTowerBag.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Common/XUiSTChildPanel.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Common/XUiSTFunctionButton.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Common/XUiSTMainPage.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Function/XUiSTFunctionIcon.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Function/XUiSTFunctionUnlock.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Map/XUiGrid3DMapStage.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Map/XUiGrid3DMapTheme.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Map/XUiGridStageReward.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Map/XUiPanel3DMap.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Map/XUiPanel3DMapChapter.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Map/XUiPanelStageSelect.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Map/XUiPanelThemeSelect.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Map/XUiSuperTowerMain.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Map/XUiSuperTowerMultiStageDetail.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Map/XUiSuperTowerSingleStageDetail.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Plugins/XUiSTPluginDetailsRoleHead.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Plugins/XUiSTPluginLevelUp.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Plugins/XUiStCpPluginListPanel.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Plugins/XUiStCpPluginSlotPanel.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Plugins/XUiStCpRolePanel.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Plugins/XUiStCpSlotGrid.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Plugins/XUiSuperTowerChoosePlugin.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Plugins/XUiSuperTowerEnhanceDetails.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Plugins/XUiSuperTowerEnhanceGrid.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Plugins/XUiSuperTowerMixGrid.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Plugins/XUiSuperTowerPluginDetails.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Plugins/XUiSuperTowerPluginGrid.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Role/XUiRoleLevelUpPanel.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Role/XUiSuperTowerRoleDetail.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Role/XUiSuperTowerRoleGrid.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Role/XUiSuperTowerRoleLevelUpPanel.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Role/XUiSuperTowerRolePluginUnlockTip.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Role/XUiSuperTowerTedianUP.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Role/XUiSupertowerExpansion.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Room/XUiSuperTowerBattleRoleRoom.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Room/XUiSuperTowerBattleRoomChildPanel.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Room/XUiSuperTowerBattleRoomExpand.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Room/XUiSuperTowerBattleRoomRoleDetail.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Shop/XUiGridSuperTowerShopItem.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Shop/XUiSuperTowerShop.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Shop/XUiSuperTowerShopItem.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Stages/Target/XUiGridSTQuickDeployMember.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Stages/Target/XUiGridSTQuickDeployTeam.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Stages/Target/XUiGridSettleReward.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Stages/Target/XUiGridTargetStageTeam.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Stages/Target/XUiGridTargetStageTeamMember.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Stages/Target/XUiSuperTowerDeploy.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Stages/Target/XUiSuperTowerLoading.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Stages/Target/XUiSuperTowerQuickDeploy.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Stages/Target/XUiSuperTowerSettleWin.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiSTTierPrepare.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTdDynamicTablePanel.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTdInfoPanel.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTdTabPanel.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTdTitlePanel.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTierDrop.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTierGiveUp.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTierSettle.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTpDropGrid.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTpEnhancePanel.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTpMemberGrid.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTpPluginsPanel.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTpProgressPanel.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTpScorePanel.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTpTeamPanel.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTsEnhanceInfoPanel.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTsFloorPanel.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTsPluginInfoPanel.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTsRoleInfoPanel.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTsScoreItem.lua create mode 100644 Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTsScorePanel.lua create mode 100644 Resources/Scripts/XUi/XUiTRPG/UiTRPGMapTips.lua create mode 100644 Resources/Scripts/XUi/XUiTRPG/XUiGridTRPGBuff.lua create mode 100644 Resources/Scripts/XUi/XUiTRPG/XUiGridTRPGCard.lua create mode 100644 Resources/Scripts/XUi/XUiTRPG/XUiGridTRPGCardRecord.lua create mode 100644 Resources/Scripts/XUi/XUiTRPG/XUiGridTRPGItem.lua create mode 100644 Resources/Scripts/XUi/XUiTRPG/XUiGridTRPGMapCardMini.lua create mode 100644 Resources/Scripts/XUi/XUiTRPG/XUiGridTRPGMapNode.lua create mode 100644 Resources/Scripts/XUi/XUiTRPG/XUiGridTRPGRole.lua create mode 100644 Resources/Scripts/XUi/XUiTRPG/XUiGridTRPGRoleDetail.lua create mode 100644 Resources/Scripts/XUi/XUiTRPG/XUiGridTRPGRoleTalent.lua create mode 100644 Resources/Scripts/XUi/XUiTRPG/XUiGridTRPGTestAction.lua create mode 100644 Resources/Scripts/XUi/XUiTRPG/XUiGridTRPGTestItem.lua create mode 100644 Resources/Scripts/XUi/XUiTRPG/XUiGridTRPGTestRole.lua create mode 100644 Resources/Scripts/XUi/XUiTRPG/XUiTRPGBag/XUiTRPGBag.lua create mode 100644 Resources/Scripts/XUi/XUiTRPG/XUiTRPGBag/XUiTRPGBagGrid.lua create mode 100644 Resources/Scripts/XUi/XUiTRPG/XUiTRPGBag/XUiTRPGItemUsePanel.lua create mode 100644 Resources/Scripts/XUi/XUiTRPG/XUiTRPGBuffDetail.lua create mode 100644 Resources/Scripts/XUi/XUiTRPG/XUiTRPGCollection.lua create mode 100644 Resources/Scripts/XUi/XUiTRPG/XUiTRPGCommitItem.lua create mode 100644 Resources/Scripts/XUi/XUiTRPG/XUiTRPGDialog.lua create mode 100644 Resources/Scripts/XUi/XUiTRPG/XUiTRPGExploreChapter.lua create mode 100644 Resources/Scripts/XUi/XUiTRPG/XUiTRPGExploreChapterStage.lua create mode 100644 Resources/Scripts/XUi/XUiTRPG/XUiTRPGExploreRegion/XUiTRPGExploreRegion.lua create mode 100644 Resources/Scripts/XUi/XUiTRPG/XUiTRPGExploreRegion/XUiTRPGExploreRegionChapter.lua create mode 100644 Resources/Scripts/XUi/XUiTRPG/XUiTRPGExploreShop/XUiTRPGExploreShop.lua create mode 100644 Resources/Scripts/XUi/XUiTRPG/XUiTRPGExploreShop/XUiTRPGExploreShopRewardGrid.lua create mode 100644 Resources/Scripts/XUi/XUiTRPG/XUiTRPGExploreShop/XUiTRPGShopItem.lua create mode 100644 Resources/Scripts/XUi/XUiTRPG/XUiTRPGFightTips.lua create mode 100644 Resources/Scripts/XUi/XUiTRPG/XUiTRPGMain.lua create mode 100644 Resources/Scripts/XUi/XUiTRPG/XUiTRPGMainLineTreasure.lua create mode 100644 Resources/Scripts/XUi/XUiTRPG/XUiTRPGMaze.lua create mode 100644 Resources/Scripts/XUi/XUiTRPG/XUiTRPGNewCharacter.lua create mode 100644 Resources/Scripts/XUi/XUiTRPG/XUiTRPGObtain.lua create mode 100644 Resources/Scripts/XUi/XUiTRPG/XUiTRPGPanel/XUiTRPGPanelLevel.lua create mode 100644 Resources/Scripts/XUi/XUiTRPG/XUiTRPGPanel/XUiTRPGPanelPlotTab.lua create mode 100644 Resources/Scripts/XUi/XUiTRPG/XUiTRPGPanel/XUiTRPGPanelTask.lua create mode 100644 Resources/Scripts/XUi/XUiTRPG/XUiTRPGRewardTip/XUiTRPGRewardGrid.lua create mode 100644 Resources/Scripts/XUi/XUiTRPG/XUiTRPGRewardTip/XUiTRPGRewardTip.lua create mode 100644 Resources/Scripts/XUi/XUiTRPG/XUiTRPGSecondMain/XUiTRPGSecondMain.lua create mode 100644 Resources/Scripts/XUi/XUiTRPG/XUiTRPGSecondMain/XUiTRPGTruthRoadSecondMain.lua create mode 100644 Resources/Scripts/XUi/XUiTRPG/XUiTRPGSecondMain/XUiTRPGTruthRoadSecondMainStage.lua create mode 100644 Resources/Scripts/XUi/XUiTRPG/XUiTRPGSecondMain/XUiTRPGTruthRoadSecondMainStages.lua create mode 100644 Resources/Scripts/XUi/XUiTRPG/XUiTRPGTalenTree.lua create mode 100644 Resources/Scripts/XUi/XUiTRPG/XUiTRPGTalentOverView.lua create mode 100644 Resources/Scripts/XUi/XUiTRPG/XUiTRPGTaskTip.lua create mode 100644 Resources/Scripts/XUi/XUiTRPG/XUiTRPGTest.lua create mode 100644 Resources/Scripts/XUi/XUiTRPG/XUiTRPGTestDetailsTips.lua create mode 100644 Resources/Scripts/XUi/XUiTRPG/XUiTRPGTruthRoad/XUiTRPGTruthRoadMain.lua create mode 100644 Resources/Scripts/XUi/XUiTRPG/XUiTRPGTruthRoad/XUiTRPGTruthRoadStage.lua create mode 100644 Resources/Scripts/XUi/XUiTRPG/XUiTRPGTruthRoad/XUiTRPGTruthRoadStages.lua create mode 100644 Resources/Scripts/XUi/XUiTRPG/XUiTRPGWorldBoss/XUiTRPGGridBossReward.lua create mode 100644 Resources/Scripts/XUi/XUiTRPG/XUiTRPGWorldBoss/XUiTRPGPanelDetail.lua create mode 100644 Resources/Scripts/XUi/XUiTRPG/XUiTRPGWorldBoss/XUiTRPGPanelEnter.lua create mode 100644 Resources/Scripts/XUi/XUiTRPG/XUiTRPGWorldBoss/XUiTRPGWinWorldBoss.lua create mode 100644 Resources/Scripts/XUi/XUiTRPG/XUiTRPGWorldBoss/XUiTRPGWorldBossBossArea.lua create mode 100644 Resources/Scripts/XUi/XUiTRPG/XUiTRPGYingDi.lua create mode 100644 Resources/Scripts/XUi/XUiTask/XDynamicActivityTask.lua create mode 100644 Resources/Scripts/XUi/XUiTask/XDynamicDailyTask.lua create mode 100644 Resources/Scripts/XUi/XUiTask/XDynamicGridTask.lua create mode 100644 Resources/Scripts/XUi/XUiTask/XTaskContainer.lua create mode 100644 Resources/Scripts/XUi/XUiTask/XUiGridCourse.lua create mode 100644 Resources/Scripts/XUi/XUiTask/XUiGridTask.lua create mode 100644 Resources/Scripts/XUi/XUiTask/XUiPanelActive.lua create mode 100644 Resources/Scripts/XUi/XUiTask/XUiPanelCourse.lua create mode 100644 Resources/Scripts/XUi/XUiTask/XUiPanelCourseReward.lua create mode 100644 Resources/Scripts/XUi/XUiTask/XUiPanelTaskActivity.lua create mode 100644 Resources/Scripts/XUi/XUiTask/XUiPanelTaskDaily.lua create mode 100644 Resources/Scripts/XUi/XUiTask/XUiPanelTaskStory.lua create mode 100644 Resources/Scripts/XUi/XUiTask/XUiPanelTaskWeekly.lua create mode 100644 Resources/Scripts/XUi/XUiTask/XUiTask.lua create mode 100644 Resources/Scripts/XUi/XUiTest/XUiTest.lua create mode 100644 Resources/Scripts/XUi/XUiTip/XUiGridSkip.lua create mode 100644 Resources/Scripts/XUi/XUiTip/XUiTip.lua create mode 100644 Resources/Scripts/XUi/XUiTipReward/XUiTipReward.lua create mode 100644 Resources/Scripts/XUi/XUiTrial/XUiGridTrialDesItem.lua create mode 100644 Resources/Scripts/XUi/XUiTrial/XUiGridTrialTypeItem.lua create mode 100644 Resources/Scripts/XUi/XUiTrial/XUiPanelTrialGet.lua create mode 100644 Resources/Scripts/XUi/XUiTrial/XUiPanelTrialGrid.lua create mode 100644 Resources/Scripts/XUi/XUiTrial/XUiPanelTrialMain.lua create mode 100644 Resources/Scripts/XUi/XUiTrial/XUiPanelTrialSelect.lua create mode 100644 Resources/Scripts/XUi/XUiTrial/XUiPanelTrialTaskList.lua create mode 100644 Resources/Scripts/XUi/XUiTrial/XUiPanelTrialTips.lua create mode 100644 Resources/Scripts/XUi/XUiTrial/XUiPanelTrialType.lua create mode 100644 Resources/Scripts/XUi/XUiTrial/XUiTrial.lua create mode 100644 Resources/Scripts/XUi/XUiUnlockShow/XUiUnlockShow.lua create mode 100644 Resources/Scripts/XUi/XUiVideo/XUiVideoPlayer.lua create mode 100644 Resources/Scripts/XUi/XUiWaterMask/XUiSuperWaterMarks.lua create mode 100644 Resources/Scripts/XUi/XUiWaterMask/XUiWaterMask.lua create mode 100644 Resources/Scripts/XUi/XUiWindowsInlay/XUiWindowsInlay.lua create mode 100644 Resources/Scripts/XUi/XUiWorldBoss/XUiChatUiWorldBoss.lua create mode 100644 Resources/Scripts/XUi/XUiWorldBoss/XUiGridAttributeChapter.lua create mode 100644 Resources/Scripts/XUi/XUiWorldBoss/XUiGridAttributeStage.lua create mode 100644 Resources/Scripts/XUi/XUiWorldBoss/XUiGridBossReward.lua create mode 100644 Resources/Scripts/XUi/XUiWorldBoss/XUiGridBtnAttributeArea.lua create mode 100644 Resources/Scripts/XUi/XUiWorldBoss/XUiGridBtnBossArea.lua create mode 100644 Resources/Scripts/XUi/XUiWorldBoss/XUiGridBuff.lua create mode 100644 Resources/Scripts/XUi/XUiWorldBoss/XUiGridLevelSelect.lua create mode 100644 Resources/Scripts/XUi/XUiWorldBoss/XUiGridReportMsgItem.lua create mode 100644 Resources/Scripts/XUi/XUiWorldBoss/XUiGridTipsInfo.lua create mode 100644 Resources/Scripts/XUi/XUiWorldBoss/XUiGridWorldBossAreaRankItem.lua create mode 100644 Resources/Scripts/XUi/XUiWorldBoss/XUiGridWorldBossTeamList.lua create mode 100644 Resources/Scripts/XUi/XUiWorldBoss/XUiPanelDetail.lua create mode 100644 Resources/Scripts/XUi/XUiWorldBoss/XUiPanelEnter.lua create mode 100644 Resources/Scripts/XUi/XUiWorldBoss/XUiSettleWinWorldBoss.lua create mode 100644 Resources/Scripts/XUi/XUiWorldBoss/XUiWorldBossAreaRank.lua create mode 100644 Resources/Scripts/XUi/XUiWorldBoss/XUiWorldBossAttributeArea.lua create mode 100644 Resources/Scripts/XUi/XUiWorldBoss/XUiWorldBossBossArea.lua create mode 100644 Resources/Scripts/XUi/XUiWorldBoss/XUiWorldBossDetail.lua create mode 100644 Resources/Scripts/XUi/XUiWorldBoss/XUiWorldBossFashion.lua create mode 100644 Resources/Scripts/XUi/XUiWorldBoss/XUiWorldBossLevelSelect.lua create mode 100644 Resources/Scripts/XUi/XUiWorldBoss/XUiWorldBossMain.lua create mode 100644 Resources/Scripts/XUi/XUiWorldBoss/XUiWorldBossTask.lua create mode 100644 Resources/Scripts/XUi/XUiWorldBoss/XUiWorldBossTips.lua diff --git a/README.md b/README.md index daaa1b8c..e79fe491 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ - Client - Share +- Scripts - Sha1 ## Known Issue @@ -12,4 +13,8 @@ Share\Fight\Map\Info\Scene01102\PathArea Share\Fight\Map\Info\Scene01103\PathArea Share\Fight\Map\Info\Scene01207\PathArea Share\Fight\Map\Info\Scene01306\PathArea -``` \ No newline at end of file +``` + +## Dump progress +Lua Scripts : dumped **3126/4096** with success rate **76%** \ +Data : dumped **3513/4095** with success rate **85%** \ No newline at end of file diff --git a/Resources/Scripts/XBehavior/XLuaBehaviorAgent.lua b/Resources/Scripts/XBehavior/XLuaBehaviorAgent.lua new file mode 100644 index 00000000..7c0e5e44 --- /dev/null +++ b/Resources/Scripts/XBehavior/XLuaBehaviorAgent.lua @@ -0,0 +1,34 @@ +XLuaBehaviorAgent = XClass(nil, "XLuaBehaviorAgent") + +function XLuaBehaviorAgent:Ctor(agentName, agentProxy) + self.Name = agentName + self.AgentProxy = agentProxy + self.Agent = agentProxy.BTAgent +end + +function XLuaBehaviorAgent:OnAwake() +end + +function XLuaBehaviorAgent:OnStart() +end + +function XLuaBehaviorAgent:OnEnable() +end + +function XLuaBehaviorAgent:OnDisable() +end + +function XLuaBehaviorAgent:OnDestroy() +end + +function XLuaBehaviorAgent:OnUpdate() + +end + +function XLuaBehaviorAgent:OnNotify() + +end + +function XLuaBehaviorAgent:OnGetEvents() + +end \ No newline at end of file diff --git a/Resources/Scripts/XBehavior/XLuaBehaviorManager.lua b/Resources/Scripts/XBehavior/XLuaBehaviorManager.lua new file mode 100644 index 00000000..32a00395 --- /dev/null +++ b/Resources/Scripts/XBehavior/XLuaBehaviorManager.lua @@ -0,0 +1,61 @@ +CsXBehaviorManager = CS.BehaviorTree.XBehaviorTreeManager +CsNodeStatus = CS.BehaviorTree.XNodeStatus +CsBehaviorNodeType = CS.BehaviorTree.XBehaviorNodeType + +XLuaBehaviorManager = {} + +local NodeClassType = {} +local AgentClassType = {} + +--注册行为节点 +function XLuaBehaviorManager.RegisterNode(super, classType, nodeType, islua, needUpdate) + super = XLuaBehaviorNode or super + CsXBehaviorManager.Instance:RegisterLuaNodeProxy(classType, nodeType, islua, needUpdate) + local behaviorNode = XClass(super, classType) + NodeClassType[classType] = behaviorNode + return behaviorNode +end + +--创建行为节点实例 +function XLuaBehaviorManager.NewLuaNodeProxy(className, nodeProxy) + local baseName = className + local class = NodeClassType[baseName] + if not class then + class = NodeClassType[baseName] + if not class then + XLog.Error("XLuaBehaviorManager.NewLuaNodeProxy error, class not exist, name: " .. className) + return nil + end + end + local obj = class.New(className, nodeProxy) + return obj +end + +--注册行为主体 +function XLuaBehaviorManager.RegisterAgent(super, classType) + super = XLuaBehaviorAgent or super + CsXBehaviorManager.Instance:RegisterLuaAgentProxy(classType) + local behaviorNode = XClass(super, classType) + AgentClassType[classType] = behaviorNode + return behaviorNode +end + +--创建行为主体实例 +function XLuaBehaviorManager.NewLuaAgentProxy(className, agentProxy) + local baseName = className + local class = AgentClassType[baseName] + if not class then + class = AgentClassType[baseName] + if not class then + XLog.Error("XLuaBehaviorManager.NewLuaAgentProxy error, class not exist, name: " .. className) + return nil + end + end + local obj = class.New(className, agentProxy) + return obj +end + + +function XLuaBehaviorManager.PlayId(id, agent) + agent:PlayBehavior(id) +end \ No newline at end of file diff --git a/Resources/Scripts/XBehavior/XLuaBehaviorNode.lua b/Resources/Scripts/XBehavior/XLuaBehaviorNode.lua new file mode 100644 index 00000000..3700efec --- /dev/null +++ b/Resources/Scripts/XBehavior/XLuaBehaviorNode.lua @@ -0,0 +1,89 @@ +XLuaBehaviorNode = XClass(nil, "XLuaBehaviorNode") + +function XLuaBehaviorNode:Ctor(className, nodeProxy) + self.Name = className + self.NodeProxy = nodeProxy + self.Node = nodeProxy.Node + self.BehaviorTree = nodeProxy.Node.BTree + self:InitNodeData() +end + +--初始化数据 +function XLuaBehaviorNode:InitNodeData() + + if not self.Node.Fields then + self.Fields = nil + return + end + + self.Fields = {} + + local fields = self.Node.Fields.Fields + + for _, v in pairs(fields) do + self.Fields[v.FieldName] = v.Value + end +end + + + +function XLuaBehaviorNode:OnAwake() + +end + +function XLuaBehaviorNode:SetAgent() + self.Agent = self.BehaviorTree.BTAgent + self.Proxy = self.Agent.Proxy + self.AgentProxy = self.Agent.Proxy.LuaAgentProxy + self:OnStart() +end + +function XLuaBehaviorNode:OnEnable() + +end + +function XLuaBehaviorNode:OnStart() + +end + +function XLuaBehaviorNode:OnRecycle() + self.Agent = nil + self.Proxy = nil + self.AgentProxy = nil +end + + +function XLuaBehaviorNode:OnDisable() + +end + +function XLuaBehaviorNode:OnEnter() + +end + +function XLuaBehaviorNode:OnExit() +end + +function XLuaBehaviorNode:OnReset() + +end + +function XLuaBehaviorNode:OnDestroy() + +end + +function XLuaBehaviorNode:OnUpdate(dt) + +end + +function XLuaBehaviorNode:OnFixedUpdate(dt) + +end + +function XLuaBehaviorNode:OnNotify(evt, ...) + +end + +function XLuaBehaviorNode:OnGetEvents() + +end \ No newline at end of file diff --git a/Resources/Scripts/XCommon/Fix.lua b/Resources/Scripts/XCommon/Fix.lua new file mode 100644 index 00000000..91b5140a --- /dev/null +++ b/Resources/Scripts/XCommon/Fix.lua @@ -0,0 +1,8 @@ +fix = CS.Mathematics.fix +fix.zero = CS.Mathematics.fix.zero +fix.hundred = CS.Mathematics.fix.hundred +fix.thousand = CS.Mathematics.fix.thousand +fix.deg2rad = CS.Mathematics.fix.deg2rad +FixParse = CS.FixExtension.Parse +FixToInt = CS.FixExtension.FixToInt +FixToDouble = CS.FixExtension.FixToDouble \ No newline at end of file diff --git a/Resources/Scripts/XCommon/Json.lua b/Resources/Scripts/XCommon/Json.lua new file mode 100644 index 00000000..fda1b83b --- /dev/null +++ b/Resources/Scripts/XCommon/Json.lua @@ -0,0 +1,397 @@ +-- +-- json.lua +-- +-- Copyright (c) 2019 rxi +-- +-- Permission is hereby granted, free of charge, to any person obtaining a copy of +-- this software and associated documentation files (the "Software"), to deal in +-- the Software without restriction, including without limitation the rights to +-- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +-- of the Software, and to permit persons to whom the Software is furnished to do +-- so, subject to the following conditions: +-- +-- The above copyright notice and this permission notice shall be included in all +-- copies or substantial portions of the Software. +-- +-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +-- SOFTWARE. +-- +local json = { _version = "0.1.2" } + +------------------------------------------------------------------------------- +-- Encode +------------------------------------------------------------------------------- +local encode + +local escape_char_map = { + ["\\"] = "\\\\", + ["\""] = "\\\"", + ["\b"] = "\\b", + ["\f"] = "\\f", + ["\n"] = "\\n", + ["\r"] = "\\r", + ["\t"] = "\\t", +} + +local escape_char_map_inv = {["\\/"] = "/" } +for k, v in pairs(escape_char_map) do + escape_char_map_inv[v] = k +end + + +local function escape_char(c) + return escape_char_map[c] or string.format("\\u%04x", c:byte()) +end + + +local function encode_nil() + return "null" +end + + +local function encode_table(val, stack) + local res = {} + stack = stack or {} + + -- Circular reference? + if stack[val] then error("circular reference") end + + stack[val] = true + + if rawget(val, 1) ~= nil or next(val) == nil then + -- Treat as array -- check keys are valid and it is not sparse + local n = 0 + for k in pairs(val) do + if type(k) ~= "number" then + error("invalid table: mixed or invalid key types") + end + n = n + 1 + end + if n ~= #val then + error("invalid table: sparse array") + end + -- Encode + for _, v in ipairs(val) do + table.insert(res, encode(v, stack)) + end + stack[val] = nil + return "[" .. table.concat(res, ",") .. "]" + + else + -- Treat as an object + for k, v in pairs(val) do + if type(k) ~= "string" then + error("invalid table: mixed or invalid key types") + end + table.insert(res, encode(k, stack) .. ":" .. encode(v, stack)) + end + stack[val] = nil + return "{" .. table.concat(res, ",") .. "}" + end +end + + +local function encode_string(val) + return '"' .. val:gsub('[%z\1-\31\\"]', escape_char) .. '"' +end + + +local function encode_number(val) + -- Check for NaN, -inf and inf + if val ~= val or val <= -math.huge or val >= math.huge then + error("unexpected number value '" .. tostring(val) .. "'") + end + return string.format("%.14g", val) +end + + +local type_func_map = { + ["nil" ] = encode_nil, + ["table"] = encode_table, + ["string"] = encode_string, + ["number"] = encode_number, + ["boolean"] = tostring, +} + + +encode = function(val, stack) + local t = type(val) + local f = type_func_map[t] + if f then + return f(val, stack) + end + error("unexpected type '" .. t .. "'") +end + + +function json.encode(val) + return (encode(val)) +end + + +------------------------------------------------------------------------------- +-- Decode +------------------------------------------------------------------------------- +local parse + +local function create_set(...) + local res = {} + for i = 1, select("#", ...) do + res[select(i, ...)] = true + end + return res +end + +local space_chars = create_set(" ", "\t", "\r", "\n") +local delim_chars = create_set(" ", "\t", "\r", "\n", "]", "}", ",") +local escape_chars = create_set("\\", "/", '"', "b", "f", "n", "r", "t", "u") +local literals = create_set("true", "false", "null") + +local literal_map = { + ["true"] = true, + ["false"] = false, + ["null"] = nil, +} + + +local function next_char(str, idx, set, negate) + for i = idx, #str do + if set[str:sub(i, i)] ~= negate then + return i + end + end + return #str + 1 +end + + +local function decode_error(str, idx, msg) + local line_count = 1 + local col_count = 1 + for i = 1, idx - 1 do + col_count = col_count + 1 + if str:sub(i, i) == "\n" then + line_count = line_count + 1 + col_count = 1 + end + end + error(string.format("%s at line %d col %d", msg, line_count, col_count)) +end + + +local function codepoint_to_utf8(n) + -- http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=iws-appendixa + local f = math.floor + if n <= 0x7f then + return string.char(n) + elseif n <= 0x7ff then + return string.char(f(n / 64) + 192, n % 64 + 128) + elseif n <= 0xffff then + return string.char(f(n / 4096) + 224, f(n % 4096 / 64) + 128, n % 64 + 128) + elseif n <= 0x10ffff then + return string.char(f(n / 262144) + 240, f(n % 262144 / 4096) + 128, + f(n % 4096 / 64) + 128, n % 64 + 128) + end + error(string.format("invalid unicode codepoint '%x'", n)) +end + + +local function parse_unicode_escape(s) + local n1 = tonumber(s:sub(3, 6), 16) + local n2 = tonumber(s:sub(9, 12), 16) + -- Surrogate pair? + if n2 then + return codepoint_to_utf8((n1 - 0xd800) * 0x400 + (n2 - 0xdc00) + 0x10000) + else + return codepoint_to_utf8(n1) + end +end + + +local function parse_string(str, i) + local has_unicode_escape = false + local has_surrogate_escape = false + local has_escape = false + local last + for j = i + 1, #str do + local x = str:byte(j) + + if x < 32 then + decode_error(str, j, "control character in string") + end + + if last == 92 then -- "\\" (escape char) + if x == 117 then -- "u" (unicode escape sequence) + local hex = str:sub(j + 1, j + 5) + if not hex:find("%x%x%x%x") then + decode_error(str, j, "invalid unicode escape in string") + end + if hex:find("^[dD][89aAbB]") then + has_surrogate_escape = true + else + has_unicode_escape = true + end + else + local c = string.char(x) + if not escape_chars[c] then + decode_error(str, j, "invalid escape char '" .. c .. "' in string") + end + has_escape = true + end + last = nil + + elseif x == 34 then -- '"' (end of string) + local s = str:sub(i + 1, j - 1) + if has_surrogate_escape then + s = s:gsub("\\u[dD][89aAbB]..\\u....", parse_unicode_escape) + end + if has_unicode_escape then + s = s:gsub("\\u....", parse_unicode_escape) + end + if has_escape then + s = s:gsub("\\.", escape_char_map_inv) + end + return s, j + 1 + + else + last = x + end + end + decode_error(str, i, "expected closing quote for string") +end + + +local function parse_number(str, i) + local x = next_char(str, i, delim_chars) + local s = str:sub(i, x - 1) + local n = tonumber(s) + if not n then + decode_error(str, i, "invalid number '" .. s .. "'") + end + return n, x +end + + +local function parse_literal(str, i) + local x = next_char(str, i, delim_chars) + local word = str:sub(i, x - 1) + if not literals[word] then + decode_error(str, i, "invalid literal '" .. word .. "'") + end + return literal_map[word], x +end + + +local function parse_array(str, i) + local res = {} + local n = 1 + i = i + 1 + while 1 do + local x + i = next_char(str, i, space_chars, true) + -- Empty / end of array? + if str:sub(i, i) == "]" then + i = i + 1 + break + end + -- Read token + x, i = parse(str, i) + res[n] = x + n = n + 1 + -- Next token + i = next_char(str, i, space_chars, true) + local chr = str:sub(i, i) + i = i + 1 + if chr == "]" then break end + if chr ~= "," then decode_error(str, i, "expected ']' or ','") end + end + return res, i +end + + +local function parse_object(str, i) + local res = {} + i = i + 1 + while 1 do + local key, val + i = next_char(str, i, space_chars, true) + -- Empty / end of object? + if str:sub(i, i) == "}" then + i = i + 1 + break + end + -- Read key + if str:sub(i, i) ~= '"' then + decode_error(str, i, "expected string for key") + end + key, i = parse(str, i) + -- Read ':' delimiter + i = next_char(str, i, space_chars, true) + if str:sub(i, i) ~= ":" then + decode_error(str, i, "expected ':' after key") + end + i = next_char(str, i + 1, space_chars, true) + -- Read value + val, i = parse(str, i) + -- Set + res[key] = val + -- Next token + i = next_char(str, i, space_chars, true) + local chr = str:sub(i, i) + i = i + 1 + if chr == "}" then break end + if chr ~= "," then decode_error(str, i, "expected '}' or ','") end + end + return res, i +end + + +local char_func_map = { + ['"'] = parse_string, + ["0"] = parse_number, + ["1"] = parse_number, + ["2"] = parse_number, + ["3"] = parse_number, + ["4"] = parse_number, + ["5"] = parse_number, + ["6"] = parse_number, + ["7"] = parse_number, + ["8"] = parse_number, + ["9"] = parse_number, + ["-"] = parse_number, + ["t"] = parse_literal, + ["f"] = parse_literal, + ["n"] = parse_literal, + ["["] = parse_array, + ["{"] = parse_object, +} + + +parse = function(str, idx) + local chr = str:sub(idx, idx) + local f = char_func_map[chr] + if f then + return f(str, idx) + end + decode_error(str, idx, "unexpected character '" .. chr .. "'") +end + + +function json.decode(str) + if type(str) ~= "string" then + error("expected argument of type string, got " .. type(str)) + end + local res, idx = parse(str, next_char(str, 1, space_chars, true)) + idx = next_char(str, idx, space_chars, true) + if idx <= #str then + decode_error(str, idx, "trailing garbage") + end + return res +end + + +return json \ No newline at end of file diff --git a/Resources/Scripts/XCommon/XAnalyticsEvent.lua b/Resources/Scripts/XCommon/XAnalyticsEvent.lua new file mode 100644 index 00000000..2c4cc18e --- /dev/null +++ b/Resources/Scripts/XCommon/XAnalyticsEvent.lua @@ -0,0 +1,35 @@ +--==============================-- +-- 通用数据收集事件 +--==============================-- +XAnalyticsEvent = XAnalyticsEvent or {} + +local OnRoleCreate = function() + if XUserManager.Channel == XUserManager.CHANNEL.HERO then + XHeroSdkManager.CreateNewRole() + end +end + +local OnLogin = function() + if XUserManager.Channel == XUserManager.CHANNEL.HERO then + XHeroSdkManager.EnterGame() + end + + CS.BuglyAgent.SetUserId(tostring(XPlayer.Id)) +end + +local OnLevelUp = function() + if XUserManager.Channel == XUserManager.CHANNEL.HERO then + XHeroSdkManager.RoleLevelUp() + end +end + +local OnLogout = function() + +end + +function XAnalyticsEvent.Init() + XEventManager.AddEventListener(XEventId.EVENT_NEW_PLAYER, OnRoleCreate) + XEventManager.AddEventListener(XEventId.EVENT_LOGIN_SUCCESS, OnLogin) + XEventManager.AddEventListener(XEventId.EVENT_PLAYER_LEVEL_CHANGE, OnLevelUp) + XEventManager.AddEventListener(XEventId.EVENT_USER_LOGOUT, OnLogout) +end diff --git a/Resources/Scripts/XCommon/XBindTools.lua b/Resources/Scripts/XCommon/XBindTools.lua new file mode 100644 index 00000000..756bfef6 --- /dev/null +++ b/Resources/Scripts/XCommon/XBindTools.lua @@ -0,0 +1,171 @@ +local rawget = rawget +local rawset = rawset +local getmetatable = getmetatable +local setmetatable = setmetatable + +XBindTool = XBindTool or {} + +local oldPairs = pairs + +local pairs = function(arr) + local meta_t = getmetatable(arr) + if meta_t and meta_t.__pairs then + return meta_t.__pairs(arr) + end + return oldPairs(arr) +end + +local function InitBind(obj) + if rawget(obj, "___isBinded") then return end + + local store = {} + for key, _ in pairs(obj) do + local v = rawget(obj, key) + if v ~= nil then + store[key] = v + obj[key] = nil + end + end + + local meta_t = getmetatable(obj) + if meta_t then setmetatable(store, meta_t) end + + setmetatable(obj, { + __index = function(_, index) + local ret = rawget(obj, index) + if ret ~= nil then return ret end + return store[index] + end, + __newindex = function(_, index, v) + local event = rawget(obj, "___bind_event") + local old_v = store[index] + store[index] = v + if old_v ~= v then + if event and event[index] then + event[index].running = true + for key, func in pairs(event[index].callList) do + if not event[index].removeList[key] then + func(v, old_v) + end + end + event[index].running = nil + if next(event[index].removeList) then + for removeIndex, _ in pairs(event[index].removeList) do + event[index].callList[removeIndex] = nil + end + event[index].removeList = {} + end + end + end + end, + __pairs = function(_) + return oldPairs(store) + end + }) + + rawset(obj, "___isBinded", true) + rawset(obj, "___bind_store", store) + rawset(obj, "___bind_event", {}) + rawset(obj, "___bind_id", 0) +end + +function XBindTool.BindAttr(obj, attr, callback) + InitBind(obj) + + local event = rawget(obj, "___bind_event") + local id = rawget(obj, "___bind_id") + event[attr] = event[attr] or { callList = {}, removeList = {} } + id = id + 1 + rawset(obj, "___bind_id", id) + event[attr].callList[id] = callback + + local value = obj[attr] + if value ~= nil then + callback(value) + end + return { obj = obj, attr = attr, id = id } +end + +function XBindTool.GetBindInfo(val) + if type(val) ~= "table" then return val, false end + if not rawget(val, "___isBinded") then return val, false end + return rawget(val, "___bind_store"), true +end + +function XBindTool.UnBind(handle) + local event = rawget(handle.obj, "___bind_event") + if event and event[handle.attr] then + if event[handle.attr].running then + event[handle.attr].removeList[handle.id] = true + else + event[handle.attr].callList[handle.id] = nil + end + end +end + +function XBindTool.UnBindObj(obj) + local event = rawget(obj, "___bind_event") + if event then + for _, attrListener in pairs(event) do + if attrListener.running then + for key, _ in pairs(attrListener.callList) do + attrListener.removeList[key] = true + end + end + end + rawset(obj, "___bind_event", {}) + end +end + +local NodeBindInfoRecord = {} + +function XBindTool.BindNode(node, obj, attr, func, unbindFunc) + if not NodeBindInfoRecord[node] then + NodeBindInfoRecord[node] = {} + end + local bindInfo = NodeBindInfoRecord[node] + bindInfo[obj] = bindInfo[obj] or { length = 0, record = {} } + local checkExist + if node.Exist then + checkExist = function() return node:Exist() end + else + local gameObject = node.GameObject or node.gameObject or node.Transform or node.transform + if gameObject and gameObject.Exist then + checkExist = function() return gameObject:Exist() end + end + + + end + local handle + if checkExist then + handle = XBindTool.BindAttr(obj, attr, function(...) + if not checkExist() then + XBindTool.UnBindNode(node) + if unbindFunc then + unbindFunc() + end + else + func(...) + end + end) + else + handle = XBindTool.BindAttr(obj, attr, func) + end + + bindInfo[obj].record[handle.id] = handle + bindInfo[obj].length = bindInfo[obj].length + 1 + return handle +end + +function XBindTool.UnBindNode(node) + local bindInfo = NodeBindInfoRecord[node] + if bindInfo then + for key, val in pairs(bindInfo) do + for _, item in pairs(val.record) do + XBindTool.UnBind(item) + end + bindInfo[key] = nil + end + NodeBindInfoRecord[node] = nil + end +end \ No newline at end of file diff --git a/Resources/Scripts/XCommon/XCameraHelper.lua b/Resources/Scripts/XCommon/XCameraHelper.lua new file mode 100644 index 00000000..52098119 --- /dev/null +++ b/Resources/Scripts/XCommon/XCameraHelper.lua @@ -0,0 +1,111 @@ +XCameraHelper = XCameraHelper or {} + +function XCameraHelper.SetCameraTarget(cameraCtrl, targetTrans, distance) + if cameraCtrl and cameraCtrl:Exist() then + distance = distance or 0 + cameraCtrl:SetLookAt(targetTrans, distance) + end +end + +XCameraHelper.SCREEN_SHOT_WIDTH = 1920; +XCameraHelper.SCREEN_SHOT_HEIGHT = 1080; +XCameraHelper.DefaultRect = CS.UnityEngine.Rect(0, 0, XCameraHelper.SCREEN_SHOT_WIDTH, XCameraHelper.SCREEN_SHOT_HEIGHT); +XCameraHelper.ScreenRect = CS.UnityEngine.Rect(0, 0, CS.UnityEngine.Screen.width, CS.UnityEngine.Screen.height) + +function XCameraHelper.ScreenShot(image, beginCb, cb) + if beginCb then + beginCb() + end + CS.XTool.WaitForEndOfFrame(function() + local screenShot = XCameraHelper.DoScreenShot(image) + if cb then + cb(screenShot) + end + end) +end + +-- 截取屏幕画面到image中 (注意内存开销,需使用后及时释放) +-- image Image组件 +-- cameraFar Camera组件 +-- cameraNear Camera组件(可选) +function XCameraHelper.DoScreenShot(image) + if XTool.UObjIsNil(image) then + XLog.Error("ScreenShot image is nil") + return + end + + -- if XTool.UObjIsNil(cameraFar) then + -- XLog.Error("ScreenShot cameraFar is nil") + -- return + -- end + + local rect = XCameraHelper.ScreenRect + -- -- 创建一个rt对象 + -- local rt = CS.UnityEngine.RenderTexture(rect.width, rect.height, 24) + -- rt.antiAliasing = 8 + + -- cameraFar.targetTexture = rt; + -- if not XTool.UObjIsNil(cameraNear) then + -- cameraNear.targetTexture = rt + -- end + + -- cameraFar:Render(); + -- if not XTool.UObjIsNil(cameraNear) then + -- cameraNear:Render() + -- end + + -- local currentRT = CS.UnityEngine.RenderTexture.active + -- -- 激活rt 读取像素 + -- CS.UnityEngine.RenderTexture.active = rt; + local screenShot = CS.UnityEngine.Texture2D(rect.width, rect.height, CS.UnityEngine.TextureFormat.RGB24, false); + screenShot:ReadPixels(rect, 0, 0); + screenShot:Apply(); + + -- 重置相关参数 + -- cameraFar.targetTexture = nil; + -- if not XTool.UObjIsNil(cameraNear) then + -- cameraNear.targetTexture = nil; + -- end + + -- CS.UnityEngine.RenderTexture.active = currentRT; + -- CS.UnityEngine.Object.Destroy(rt); + + local sprite = CS.UnityEngine.Sprite.Create(screenShot, rect, CS.UnityEngine.Vector2.zero); + image.sprite = sprite + + return screenShot +end + +-- 调用该接口,由ScreenCaptureWithCallBack回调函数传出的Texture用完后必须销毁 +function XCameraHelper.ScreenShotNew(image, camera, cb, beginCb) + if not image then + XLog.Error("ScreenShot Call invalid parameter:image is nil") + return + end + + if not camera then + XLog.Error("ScreenShot Call invalid parameter:camera is nil") + return + end + + if not cb then + XLog.Error("The ScreenShot API Must Need CallBack") + return + end + + -- if not XTool.UObjIsNil(image.mainTexture) and image.mainTexture.name ~= "UnityWhite" then -- 销毁texture2d (UnityWhite为默认的texture2d) + -- CS.UnityEngine.Object.Destroy(image.mainTexture) + -- end + + if beginCb then + beginCb() + end + CS.XScreenCapture.ScreenCaptureWithCallBack(camera,function(texture) + local rect = CS.UnityEngine.Rect(0, 0, texture.width, texture.height) + local sprite = CS.UnityEngine.Sprite.Create(texture, rect, CS.UnityEngine.Vector2.zero); + image.sprite = sprite + if cb then + cb(texture) + end + end) +end \ No newline at end of file diff --git a/Resources/Scripts/XCommon/XClass.lua b/Resources/Scripts/XCommon/XClass.lua new file mode 100644 index 00000000..45ac2ddc --- /dev/null +++ b/Resources/Scripts/XCommon/XClass.lua @@ -0,0 +1,81 @@ +local getinfo = debug.getinfo +local type = type + +local _class = {} +local _classNameDic = {} + +function XClass(super, className) + local class + + if XMain.IsEditorDebug then + local fullClassName = className .. getinfo(2, "S").source + class = _classNameDic[fullClassName] + if class then + return class + end + + class = {} + _classNameDic[fullClassName] = class + else + class = {} + end + + class.Ctor = false + class.Super = super + class.New = function(...) + local obj = {} + setmetatable(obj, { __index = _class[class] }) + do + local create + create = function(c, ...) + if c.Super then + create(c.Super, ...) + end + + if c.Ctor then + c.Ctor(obj, ...) + end + end + create(class, ...) + end + return obj + end + + local vtbl = {} + _class[class] = vtbl + + setmetatable(class, { + __newindex = function(_, k, v) + vtbl[k] = v + end, + __index = function(_, k) + return vtbl[k] + end + }) + + if super then + setmetatable(vtbl, { + __index = function(_, k) + local ret = _class[super][k] + vtbl[k] = ret + return ret + end + }) + end + + return class +end + +function UpdateClassType(newClass, oldClass) + if "table" ~= type(newClass) then return end + if "table" ~= type(oldClass) then return end + + if oldClass == newClass then return end + + local new_vtbl = _class[newClass] + local old_vtbl = _class[oldClass] + if not new_vtbl or not old_vtbl then return end + + _class[oldClass] = new_vtbl + _class[newClass] = nil +end \ No newline at end of file diff --git a/Resources/Scripts/XCommon/XCode.lua b/Resources/Scripts/XCommon/XCode.lua new file mode 100644 index 00000000..ab8a99d2 --- /dev/null +++ b/Resources/Scripts/XCommon/XCode.lua @@ -0,0 +1,2526 @@ +-- auto export form enum +-- Automatic generation of code, forbid to edit or delete +XCode = { + Success = 0, + Fail = 1, + ServerInternalError = 2, + ServiceUnavailable = 3, + InvalidRequest = 4, + ParamsError = 5, + GateServerNotOpen = 1001, + GateServerUpperLimit = 1002, + LoginApplicationVersionError = 1003, + LoginDocumentVersionError = 1004, + LoginTableError = 1005, + LoginInvalidStatus = 1006, + LoginInvalidLoginToken = 1007, + LoginInvalidUserId = 1008, + LoginAccessDenied = 1009, + LoginLoadMemberFailed = 1010, + LoginServiceInvalidLoginType = 1011, + LoginServiceInvalidToken = 1012, + LoginServiceRetry = 1013, + LoginServiceAlreadyLogin = 1014, + LoginServiceInternalError = 1015, + LoginServiceEnterGameServerFailed = 1016, + LoginServiceLoadPlayerDataFailed = 1017, + GateServerForceLogoutByAnotherLogin = 1018, + GateServerKcpInvalidRequest = 1019, + GateServerKcpSessionAlreadyCreated = 1020, + GameServerFullLoad = 1021, + KickOutByBanned = 1022, + KickOutByGm = 1023, + LoginDeviceIdLimit = 1024, + ReconnectInvalidToken = 1025, + ReconnectPlayerLogout = 1026, + ReconnectInvalidSeqNo = 1027, + ReconnectUnable = 1028, + PlayerFunctionNotOpen = 20000001, + PlayerFunctionShield = 20000002, + PlayerChangeDisplayCharIdCharIsNotOwned = 20000003, + PlayerMedalIsNotOwned = 20000004, + PlayerDataManagerGetPlayerMaxExpFail = 20002001, + PlayerDataManagerChangeNameTimeLimit = 20002002, + PlayerDataManagerChangeNameInvalid = 20002003, + PlayerDataManagerChangeSignInvalid = 20002004, + PlayerDataManagerChangeMarkInvalid = 20002005, + PlayerDataManagerAssistRoleIdIsSet = 20002006, + PlayerDataManagerBirthdayInValid = 20002007, + PlayerDataManagerBirthdayAlreadySet = 20002008, + PlayerDataManagerChangeCommunicationInvalid = 20002009, + PlayerDataManagerReportTimeLimit = 20002010, + PlayerDataManagerReportTagInvalid = 20002011, + PlayerDataManagerNameIsTooLong = 20002012, + PlayerDataManagerAssistCanNotSetInfection = 20002013, + PlayerDataManagerGetHonorLevelMaxExpFail = 20002014, + PlayerDataManagerLevelNotMaxLevel = 20002015, + PlayerDataManagerHonorLevelCartoonAlreadyOpen = 20002016, + FubenManagerCheckTreasureIsGet = 20003001, + FubenManagerCheckPreMapNotFound = 20003002, + FubenManagerCheckPreMapNotPass = 20003003, + FubenManagerCheckLevelNotEnough = 20003004, + FubenManagerCheckActionPointNotEnough = 20003005, + FubenManagerCheckChallengeNumNotEnough = 20003006, + FubenManagerCheckTreasureSectionIdInvalid = 20003007, + FubenManagerCheckTreasureIdInvalid = 20003008, + FubenManagerCheckTreasureStarsNotEnough = 20003009, + FubenManagerCheckTreasureRewardRepeat = 20003010, + FubenManagerCheckStageInfoNotFound = 20003011, + FubenManagerCheckPreFightStageInfoNotFound = 20003012, + FubenManagerCheckPreFightUrgentEventMapNotOpen = 20003013, + FubenManagerChallengeWinFightIdNotMatch = 20003014, + FubenManagerChallengeWinPreFightDataNotMatch = 20003015, + FubenManagerChallengeLoseFightIdNotMatch = 20003016, + FubenManagerChallengeLoseStageCfgNotFound = 20003017, + FubenManagerChallengeLosePreFightDataNotMatch = 20003018, + FubenManagerStageAllReadyMaxChallegeCount = 20003019, + FubenManagerStageAllReadyMaxBuyCount = 20003020, + FubenManagerFinishToStageStageNotFound = 20003021, + FubenManagerFightIntervalFast = 20003022, + FubenManagerRebootCountNotMatch = 20003023, + FubenManagerStageLocked = 20003024, + FubenManagerStageCharacterTypeError = 20003025, + FubenManagerCardIdTypeNotSame = 20003026, + FubenControlPreFightParamsError = 20003027, + FubenManagerBfrtNotGroup = 20003028, + FubenManagerBfrtPreIdNotFinish = 20003029, + FubenManagerBfrtNotChallengeCount = 20003030, + FubenManagerBfrtEchelonNotFound = 20003031, + FubenManagerBfrtWinParamError = 20003032, + FubenManagerBfrtTeamError = 20003033, + FubenManagerBfrtServerTeamError = 20003034, + FubenManagerBfrtServerTeamNotEqualClientTeam = 20003035, + FubenManagerBfrtClientCharacterIdNotInServerTeam = 20003036, + FubenManagerBfrtStageNotFinish = 20003037, + FubenManagerBfrtSetTeamFightInfoIdsNotEqualConfigIds = 20003038, + FubenManagerBfrtSetTeamLogisticsNotEqualConfigIds = 20003039, + FubenManagerFightRebootFightIdNotMatch = 20003040, + FubenManagerFightRebootCountNotMatch = 20003041, + FubenManagerFightRebootStageNotFound = 20003042, + FubenManagerGetFightRebootTemplateNotFound = 20003043, + FubenManagerGetFightRebootRebootCountIllegal = 20003044, + FubenManagerCheckFightRebootTeamIsEmpty = 20003045, + FubenBossSingleIsRefresh = 20003046, + FubenBossSingleChallengeCountNotEnough = 20003047, + FubenBossSingleCharacterPointsNotEnough = 20003048, + FubenBossSingleGetBossSingleDataLevelTypeIllegal = 20003049, + FubenBossBossStageListNotFound = 20003050, + FubenBossSingleScoreRewardIsNotExist = 20003051, + FubenBossSingleScoreRewardIsGot = 20003052, + FubenBossSingleScoreRewardTypeError = 20003053, + FubenBossSingleScoreIsNotEnough = 20003054, + FubenBossSingleHistoryIsNotExist = 20003055, + FubenBossSingleStageCanNotAutoFight = 20003056, + FubenBossSingleStageIsNotExist = 20003057, + FubenBossSingleSaveScoreIllegality = 20003058, + FubenBossSingleAutoFightCountNotEnough = 20003059, + FubenBossSingleCurScoreIsBigThanHistory = 20003060, + FubenBossSingleHideStageNotOpen = 20003061, + FubenBossSingleIsAutoFighting = 20003062, + FubenBossSingleAlreadySelectLevelType = 20003063, + FubenBossSingleLevelIdNotExist = 20003064, + FubenBossSingleLevelTypeBossNotExist = 20003065, + FubenBossSinglePreLevelTypeNotSatisfy = 20003066, + FubenBossSingleMaxScoreNotEnough = 20003067, + FubenBossSingleLevelTypeNotSelect = 20003068, + FubenBossOnlineSectionNotFound = 20003069, + FubenBossOnlineNotInTime = 20003070, + FubenMainLinePassTimesNotEnough = 20003071, + FubenMainLineChapterIsNotExist = 20003072, + FubenMainLineActivityHideChapterNotOpen = 20003073, + FubenPrequelStageNotPass = 20003074, + FubenPrequelStageRewardAlready = 20003075, + FubenPrequelStageIdError = 20003076, + FubenPrequelCoverIdError = 20003077, + FubenPrequelChallengeIdError = 20003078, + FubenPrequelChallengeLock = 20003079, + FubenPrequelChallengeUnlockAlready = 20003080, + FubenPrequelChallengeCountLimit = 20003081, + FubenManagerAutoFightStageNotExist = 20003082, + FubenManagerAutoFightStageInvalid = 20003083, + FubenManagerAutoFightHaventPassed = 20003084, + FubenManagerAutoFightPoolIsFull = 20003085, + FubenManagerAutoFightAlreadyRunning = 20003086, + FubenManagerAutoFightNotEnoughTimes = 20003087, + FubenManagerAutoFightNotEnoughActionPoint = 20003088, + FubenManagerAutoFightIndexInvalid = 20003089, + FubenManagerAutoFightStageNotMatch = 20003090, + FubenManagerAutoFightNotComplete = 20003091, + FubenManagerTrialIdIsNotFound = 20003092, + FubenManagerTrialPreIdIsNotPass = 20003093, + FubenManagerTrialIdIsNotPass = 20003094, + FubenManagerTrialPassRewardAlreadyGet = 20003095, + FubenManagerTrialTypeRewardIsNotExit = 20003096, + FubenManagerTrialTypeRewardAlreadyGet = 20003097, + FubenManagerTrialTypeRewardIsNotFinish = 20003098, + FubenManagerDailyChapterNotFound = 20003099, + FubenManagerDailySectionNotFound = 20003100, + FubenManagerDailyConditionInvalid = 20003101, + FubenManagerDailyTimeNotFit = 20003102, + FubenManagerAutoFightTimesError = 20003103, + FubenManagerBossSingleResetCanNotSaveScore = 20003104, + FubenManagerBossSingleDataIsRefresh = 20003105, + FubenManagerStartFightIntervalFast = 20003106, + FubenAssignChapterNotFound = 20003107, + FubenAssignGroupNotFound = 20003108, + FubenAssignTeamInfoNotFound = 20003109, + FubenAssignGroupFightCountLimit = 20003110, + FubenAssignGroupTeamNotSet = 20003111, + FubenAssignFightCardCountError = 20003112, + FubenAssignFightCardNotInTeam = 20003113, + FubenAssignFightGroupIdNotMatch = 20003114, + FubenAssignFightStageAlreadyFinish = 20003115, + FubenAssignFightPreStageNotFinish = 20003116, + FubenAssignWinStageNotMatch = 20003117, + FubenAssignWinGroupIdNotMatch = 20003118, + FubenAssignGroupTeamListNotFound = 20003119, + FubenAssignPreGroupNotFinish = 20003120, + FubenAssignTeamListIsEmpty = 20003121, + FubenAssignTeamCountError = 20003122, + FubenAssignTeamIsEmpty = 20003123, + FubenAssignTeamMemberCountLimit = 20003124, + FubenAssignTeamMemberRepeated = 20003125, + FubenAssignChapterNotFinish = 20003126, + FubenAssignChapterUseSameCharacter = 20003127, + FubenAssignChapterCharacterAlreadyUse = 20003128, + FubenAssignChapterRewardAlreadyGet = 20003129, + FubenManagerFightRestartFightIdNotMatch = 20003130, + FubenManagerFightRestartPreFightDataNotMatch = 20003131, + FubenBfrtChapterNotOpen = 20003132, + FubenBfrtTeamSetCharacterRepeat = 20003133, + FubenManagerStageConfigNotExist = 20003134, + FubenFightNpcIsNullOrEmpty = 20003135, + FubenRepeatedCharacter = 20003136, + FubenActivityReset = 20003137, + TeamManagerGetTeamIdFail = 20004001, + TeamManagerPrefabExceedMax = 20004002, + TeamManagerSetTeamParaError = 20004003, + TeamManagerPrefabCharacterTypeNotSame = 20004004, + FightProxyManagerEnterIsExist = 20007001, + FightProxyManagerGetFightProxyFail = 20007002, + FightProxyManagerGetFightProxyForPlayerFail = 20007003, + FightProxyManagerPlayerIdRepeat = 20007004, + FightProxyManagerFightProxyNotFound = 20007005, + FightProxyDoOperationNotRunning = 20008001, + FightProxyIsRunningFail = 20008002, + FightProxyFightCompleteNotInFight = 20008003, + FightProxyLoadCompleteFail = 20008004, + FightProxyGetFightDataPlayerIdNotFound = 20008005, + FightProxyDoOperationPlayerIdNotFound = 20008006, + FightProxyLoadTimeout = 20008007, + FightProxyFightTimeout = 20008008, + FightProxySettleTimeout = 20008009, + FightProxyJoinFightPlayerNotFound = 20008010, + FightProxyGetFightPlayerNotFound = 20008011, + FightProxyInvalidPlayerId = 20008012, + FightProxyInvalidToken = 20008013, + FightProxyInvalidFightId = 20008014, + FightProxyFightAlreadyStart = 20008015, + FightProxyFightAlreadyFinish = 20008016, + FightProxyInvalidFrameIndex = 20008017, + FightProxyRepeatJoin = 20008018, + CharacterManagerGetCharacterTemplateNotFound = 20009001, + CharacterManagerGetLevelUpTemplateNotFound = 20009002, + CharacterManagerGetGradeTemplateNotFound = 20009003, + CharacterManagerGetQualityFragmentTemplateNotFound = 20009004, + CharacterManagerGetQualityTemplateNotFound = 20009005, + CharacterManagerGetSkillUpgradeTemplateNotFound = 20009006, + CharacterManagerGetSkillTemplateNotFound = 20009007, + CharacterManagerSkillNotFound = 20009008, + CharacterManagerGetStarUseCountParamsError = 20009009, + CharacterManagerGetStarUseCountStarError = 20009010, + CharacterManagerGetCharacterByIdNotFound = 20009011, + CharacterManagerCreateCharacterFail = 20009012, + CharacterManagerNewCharacterDataIsNil = 20009013, + CharacterManagerLevelUpMaxLevel = 20009014, + CharacterManagerAddStarFail = 20009015, + CharacterManagerMaxQuality = 20009016, + CharacterManagerActivateStarMaxStar = 20009017, + CharacterManagerPromoteQualityStarNotEnough = 20009018, + CharacterManagerMaxGrade = 20009019, + CharacterManagerExchangeCharacterAlreadyOwn = 20009020, + CharacterManagerGetCharacterDataNotFound = 20009021, + CharacterManagerCreateCharacterAlreadyExist = 20009022, + CharacterManagerInformationNotFound = 20009023, + CharacterManagerRewardNotFound = 20009024, + CharacterManagerStoryNotFound = 20009025, + CharacterManagerStrangeNewsNotFound = 20009026, + CharacterManagerVoiceNotFound = 20009027, + CharacterManagerTrustLvNotEnough = 20009028, + CharacterManagerInformationAlreadyUnlock = 20009029, + CharacterManagerStoryAlreadyUnlock = 20009030, + CharacterManagerStrangeNewsAlreadyUnlock = 20009031, + CharacterManagerStrangeNewsCanNotUnlock = 20009032, + CharacterManagerVoiceAlreadyUnlock = 20009033, + CharacterManagerRewardAlreadyUnlock = 20009034, + CharacterManagerRewardCanNotUnlock = 20009035, + CharacterManagerTrustItemNotFound = 20009036, + CharacterManagerSendGiftParaError = 20009037, + CharacterManagerTrustLevelExpNotFound = 20009038, + CharacterManagerTrustGameNotCount = 20009039, + CharacterManagerTrustGameIdNotFound = 20009040, + CharacterManagerTrustGameRewardNotFound = 20009041, + CharacterManagerTrustGameFinishNumError = 20009042, + CharacterManagerTrustGameResultIllegal = 20009043, + CharacterMinSkillLevelNotFound = 20009044, + CharacterMaxSkillLevelNotFound = 20009045, + CharacterUnlockSkillNotNeed = 20009046, + CharacterSkillUnlocked = 20009047, + CharacterSkillIsNotFoundOrLock = 20009048, + CharacterSkillLevelIsMax = 20009049, + CharacterSkillPoolTemplateNotFound = 20009050, + CharacterSkillPoolIsEmpty = 20009051, + CharacterSkillLevelEffectTemplateNotFound = 20009052, + CharacterExtraDataNotFound = 20009053, + CharacterSkillSwitchIsSame = 20009054, + FashionManagerGetFashionNotFound = 20009055, + FashionIsUnOwned = 20009056, + FashionIsLock = 20009057, + FashionIsUnLock = 20009058, + CharacterGatherRewardHadGet = 20009059, + CharacterPreGatherRewardIsNotGet = 20009060, + CharacterManagerTrustLevelIsMax = 20009061, + ItemManagerGetItemTableFailed = 20012001, + ItemManagerGetItemNotFound = 20012002, + ItemManagerCheckIdValidFail = 20012003, + ItemCountNotEnough = 20012004, + ItemCapacityNotEnough = 20012005, + ItemAlreadyOwned = 20012006, + ItemManagerGetBuyAssetTableFail = 20012007, + ItemManagerBuyAssetMaxTimes = 20012008, + ItemNotFound = 20012009, + ItemSellCountError = 20012010, + ItemSellFragmentLimit = 20012011, + ItemCannotSell = 20012012, + ItemCannotBuy = 20012013, + ItemCannotConvertCharacterExp = 20012014, + ItemCannotConvertFurnitureConfig = 20012015, + ItemCannotUse = 20012016, + ItemNotEffect = 20012017, + ItemAlreadyInvalid = 20012018, + ItemUseGiftSelectRewardIsEmpty = 20012019, + ItemUseGiftSelectRewardAboveLimit = 20012020, + ItemUseGiftSelectRewardNotExist = 20012021, + ItemCreateError = 20012022, + ItemCountException = 20012023, + ItemBatchCountNotEnough = 20012024, + ItemBatchNotFound = 20012025, + ItemUseMultipleRewardTypeError = 20012026, + ItemCannotConvertEquipExp = 20012027, + ItemEquipExpUseEquipTypeError = 20012028, + ItemManagerBuyAssetNotAllowConsumeId = 20012029, + ItemCannotConvertPartnerExp = 20012030, + ArrangeManagerCalTypeFail = 20014001, + DropManagerGetDropGoodsFail = 20017001, + DropManagerGetDropBottomTableListFail = 20017002, + DropManagerDropItemFailed = 20017003, + DropManagerGetDropTableFail = 20017004, + DropManagerGetDropGroupTableFail = 20017005, + DropManagerGetDropSetTableFail = 20017006, + DrawManagerGetDrawGroupInfoNotFound = 20018001, + DrawManagerGetDrawInfoNotFound = 20018002, + DrawManagerDrawCountError = 20018003, + DrawManagerTodayTimesUseUp = 20018004, + DrawManagerTodayRemainTimesNotEnough = 20018005, + DrawManagerActivityTimesUseUp = 20018006, + DrawManagerActivityRemainTimesNotEnough = 20018007, + DrawManagerNotOptionalDrawId = 20018008, + DrawManagerNotInValidTime = 20018009, + DrawManagerDrawInfoNotFound = 20018010, + DrawManagerDrawInfoAlreadyExist = 20018011, + DrawManagerDrawGroupInfoNotFound = 20018012, + DrawManagerDrawGroupAlreadyExist = 20018013, + DrawManagerDrawGroupOptionalListIsEmpty = 20018014, + DrawManagerSetDrawIdCountLimit = 20018015, + DrawManagerDrawIdDoNotMatch = 20018016, + GuideManagerGetGuideGroupTableNotFound = 20019001, + GuideManagerGetGuideCompleteTableNotFound = 20019002, + GuideManagerCompleteGuideErrorAlreadyCompleted = 20019003, + GuideManagerCompleteGuideErrorNotNeedReq = 20019004, + GuildManagerGuildGroupIdNotFound = 20019005, + RewardManagerGetRewardTableFail = 20020001, + RewardManagerCreateRewardGoodsTypeNotSupport = 20020002, + RewardManagerGetRewardGoodsNotFound = 20020003, + EquipTemplateNotFound = 20021001, + EquipBreakthroughTemplateNotFound = 20021002, + EquipManagerGetLevelUpTemplateNotFound = 20021003, + EquipManagerGetEquipNotFound = 20021004, + EquipManagerNewEquipFail = 20021005, + EquipManagerLevelUpMaxLevel = 20021006, + EquipManagerLevelUpLevelLimit = 20021007, + EquipManagerAddBreakthroughFail = 20021008, + EquipManagerBreakthroughOverstep = 20021009, + EquipManagerBreakthroughMaxBreakthrough = 20021010, + EquipManagerBreakthroughLevelNotEnough = 20021011, + EquipManagerGetCharEquipBySiteNotFound = 20021012, + EquipManagerPutOnRepeat = 20021013, + EquipManagerPutOnSiteError = 20021014, + EquipManagerPutOnTypeError = 20021015, + EquipManagerPutOnCharacterTypeError = 20021016, + EquipManagerTakeOffNotBeenWorn = 20021017, + EquipManagerTakeOffCanNotTakeOff = 20021018, + EquipManagerDecomposeDoNot = 20021019, + EquipManagerDecomposeConfigNot = 20021020, + EquipWeaponCapacityNotEnough = 20021021, + EquipChipCapacityNotEnough = 20021022, + EquipSuitTemplateNotFound = 20021023, + EquipSuitEffectTemplateNotFound = 20021024, + EquipIsLocked = 20021025, + EquipIsUnLock = 20021026, + EquipCanNotPutOnByThisCharacter = 20021027, + EquipGetEatCostCoinNotFound = 20021028, + EquipLevelUpUseMaterialsIsEmpty = 20021029, + EquipEatUseRepeatEquip = 20021030, + EquipResonanceCanNotUseSelf = 20021031, + EquipResonanceCharacterNotOwned = 20021032, + EquipResonanceUnconfirmedInfoUntreated = 20021033, + EquipResonanceUseEquipTypeNotSame = 20021034, + EquipResonanceWeaponStarNotSame = 20021035, + EquipResonanceChipSuitIsNotSame = 20021036, + EquipResonanceTemplateNotFound = 20021037, + EquipResonanceUseItemTemplateNotFound = 20021038, + EquipResonanceCanNotUseThisItem = 20021039, + EquipWeaponSkillTemplateNotFound = 20021040, + EquipSkillPoolIsEmpty = 20021041, + EquipResonanceSlotConfigIsEmpty = 20021042, + EquipResonanceConfigError = 20021043, + EquipResonanceConfirmInfoIsEmpty = 20021044, + EquipLevelUpCanNotEatSelf = 20021045, + EquipResonanceNeedSelectCharacter = 20021046, + EquipDecomposeListIsEmpty = 20021047, + EquipSuitNotFound = 20021048, + EquipSuitCanNotTransform = 20021049, + EquipSuitSiteError = 20021050, + EquipTransformChipUseEquipCountError = 20021051, + EquipTransformChipUseEquipSuitError = 20021052, + EquipSuitSiteConfigNotFound = 20021053, + EquipResonancePoolIsEmpty = 20021054, + EquipResonanceWeaponSkillPoolIsEmpty = 20021055, + EquipResonanceCharacterSkillPoolIsEmpty = 20021056, + EquipResonanceAttribGroupPoolIsEmpty = 20021057, + EquipChipGroupCountLimit = 20021058, + EquipChipGroupNameTooLong = 20021059, + EquipChipGroupNameInvalid = 20021060, + EquipChipGroupEquipSiteError = 20021061, + EquipChipGroupSiteRepeated = 20021062, + EquipChipGroupNotFound = 20021063, + EquipAwakeTemplateNotFound = 20021064, + EquipAwakeWeaponNonsupport = 20021065, + EquipAwakeStarNotEnough = 20021066, + EquipAwakeNotMaxLevel = 20021067, + EquipAwakeSlotNonsupport = 20021068, + EquipAwakeSlotIsAlreadyAwake = 20021069, + EquipAwakeSlotNotResonance = 20021070, + EquipAwakeSlotAttribConfigNotFound = 20021071, + EquipResonanceSlotHasNotSkill = 20021072, + EquipResonanceNeedSameCharWhenNotCost = 20021073, + EquipResonanceMaterialIsEmpty = 20021074, + EquipResonanceCanSelectSkillAlreadyExist = 20021075, + EquipResonanceSelectSkillNotFound = 20021076, + EquipResonanceSelectSkillNeedSpecificItem = 20021077, + EquipResonanceWeaponSelectSkillNotNeedItem = 20021078, + EquipChipGroupCharacterNotMatch = 20021079, + EquipChipGroupCharacterCanNotChange = 20021080, + EquipChipGroupChipCanNotCost = 20021081, + EquipChipRecycleListIsEmpty = 20021082, + EquipChipRecycleTypeOnlyChip = 20021083, + EquipChipRecycleWearDoNot = 20021084, + EquipChipRecycleLevelUpDoNot = 20021085, + EquipChipRecycleChipGroupDoNot = 20021086, + EquipChipRecycleAwakeDoNot = 20021087, + EquipChipRecycleResonanceDoNot = 20021088, + EquipChipRecycleStarMoreThanFiveDoNot = 20021089, + EquipIsRecycle = 20021090, + EquipIsNotRecycle = 20021091, + EquipSetUpRecycleStarListIsInvalid = 20021092, + EquipSetUpRecycleDaysIsInvalid = 20021093, + TaskManagerInitFail = 20026001, + TaskManagerInitTaskConfigFail = 20026002, + TaskManagerGetTaskConditionFail = 20026003, + TaskManagerGetTaskTemplateFail = 20026004, + TaskManagerFinishTaskTaskNotFound = 20026005, + TaskManagerFinishTaskTaskAlreadyFinish = 20026006, + TaskManagerFinishTaskTaskNotAchieved = 20026007, + TaskManagerFinishTaskTaskExpired = 20026008, + TaskManagerTaskNotExist = 20026009, + TaskManagerGetActivenessStageRewardNotExist = 20026010, + TaskManagerGetActivenessRewardUnknownType = 20026011, + TaskManagerGetActivenessRewardAlreadyGeted = 20026012, + TaskManagerCourseRewardNotExist = 20026013, + TaskManagerCourseRewardAlreadyGeted = 20026014, + TaskManagerCourseStageAlreadyGeted = 20026015, + TaskManagerTaskUnOpen = 20026016, + TaskManagerTaskClose = 20026017, + TaskManagerTaskNotTimeLimit = 20026018, + TaskManagerNewPlayerActivenessIsNotExist = 20026019, + TaskManagerNewPlayerActivenessRewardIsNotExist = 20026020, + TaskManagerNewPlayerActivenessAlreadyGet = 20026021, + TaskManagerNewPlayerActivenessIsNotEnough = 20026022, + TaskManagerNewPlayerTaskTodayCanNotFinish = 20026023, + MailManagerGetMailFail = 20027001, + MailManagerGetRewardIsEmpty = 20027002, + MailManagerGetRewardRepeat = 20027003, + MailManagerMailNotEffect = 20027004, + MailManagerMailWasInvalid = 20027005, + MailManagerGetRewardWasInvalidOrRewardEmpty = 20027006, + MailManagerMailIdInvalid = 20027007, + MailManagerMailExist = 20027008, + MailManagerMailNotExist = 20027009, + MailManagerGetMailRewardListNotFoundReward = 20027010, + MailManagerGetMailRewardSomeGoodsMoreThanCapacity = 20027011, + MailManagerIsDeleted = 20027012, + MailManagerIsRead = 20027013, + MailCapacityNotEnough = 20027014, + AttribManagerGetAttribTemplateNotFound = 20029001, + AttribManagerGetPromotedAttribTemplateNotFound = 20029002, + AttribManagerGetGrowRateAttribTemplateNotFound = 20029003, + AttribManagerGetTotalPromotedAttribsParamArrayError = 20029004, + AttribManagerGetTotalPromotedAttribsLevelError = 20029005, + AttribManagerGetNpcAttribNpcNotFound = 20029006, + AttribGroupPoolNotFound = 20029007, + AttribGroupNotFound = 20029008, + AttribReviseTemplateNotFound = 20029009, + ShopManagerAddGoodsInfoAlreadyExist = 20030002, + ShopManagerShopUnOpen = 20030003, + ShopManagerShopClosed = 20030004, + ShopManagerGoodsUnOpen = 20030005, + ShopManagerGoodsClosed = 20030006, + ShopManagerShopNotExist = 20030007, + ShopManagerGoodsNotExist = 20030008, + ShopManagerGoodsGroupNotExist = 20030009, + ShopManagerNotResetTimes = 20030010, + ShopManagerShopNotBuyTimes = 20030011, + ShopManagerGoodsNotBuyTimes = 20030012, + ShopGoodsAlreadyExist = 20030013, + ShopIsUnShelve = 20030014, + ShopGoodsIsUnShelve = 20030015, + ShopRequestParamsException = 20030016, + ShopBuyGoodsCountLimit = 20030017, + ShopKindIsNotReset = 20030018, + ShopKindIsNotFixed = 20030019, + ShopOwnedUnknown = 20030020, + FriendManagerApplyFriendFailedIsRefused = 20031001, + FriendManagerApplyFriendFailedIsDeleted = 20031002, + FriendManagerApplyFriendFailedIsAlreadyFriend = 20031003, + FriendManagerApplyFriendFailedIsNotRepeatApply = 20031004, + FriendManagerAcceptFriendFailedApplyIsNotExist = 20031005, + FriendManagerAcceptFriendFailedSelfFriendCountOutOfMaxCount = 20031006, + FriendManagerRecommendFriendFailedRecommendCoolDownTime = 20031007, + FriendManagerCanNotOperateSelf = 20031008, + FriendManagerGetPlayerInfosFailedReqListIsNull = 20031009, + FriendManagerDeleteFriendsFailedReqListIsNull = 20031010, + FriendManagerApplySuccess = 20031011, + FriendManagerDeleteSuccess = 20031012, + FriendManagerCanNotPlayerForId = 20031013, + FriendManagerAcceptFriendFailedOtherFriendCountOutOfMaxCount = 20031014, + FriendManagerApplySelfFriendNumLimit = 20031015, + FriendManagerApplyOtherFriendNumLimit = 20031016, + FriendManagerApplyListFull = 20031017, + FriendManagerMyFriendFull = 20031018, + FriendManagerOtherFriendFull = 20031019, + FriendManagerAgreeIsFriend = 20031020, + FriendManagerIsNotFriend = 20031021, + FriendManagerInvalidRemark = 20031022, + FriendManagerDeleteRemark = 20031023, + FriendManagerNeedRemoveBlockStateFirst = 20031024, + FriendManagerAlreadyInBlacklist = 20031025, + FriendManagerBlacklistIsFull = 20031026, + FriendManagerBlacklistNeedRemoveMentorRelation = 20031027, + FriendManagerDoNotFindFromBlacklist = 20031028, + FightCheckManagerCodeNotMatch = 20032001, + FightCheckManagerCodesTooLong = 20032002, + FightCheckManagerCheckSkip = 20032003, + FightCheckManagerSettleCodeNotMatch = 20032004, + FightCheckManagerParamIllegal = 20032005, + FightCheckManagerNotSettle = 20032006, + FightCheckManagerFightExit = 20032007, + FightCheckManagerClientVersionError = 20032008, + ChatManagerSendChatErrorCannotSendGift = 20033001, + ChatManagerChatContentCanNotBeNull = 20033002, + ChatManagerGetGiftFailedInvalidGift = 20033003, + ChatManagerRefreshTimeCooling = 20033004, + ChatManagerGetGiftAlreadyMaxCount = 20033005, + ChatManagerEmojiIsLock = 20033006, + ChatManagerInvalidEmoji = 20033007, + ChatManagerNoSendGiftFriend = 20033008, + ChatManagerChatChannelInvalid = 20033009, + ChatManagerChatChannelIdInvalid = 20033010, + ChatContentTooLong = 20033011, + ChatIsBanned = 20033012, + ChatChannelNotExist = 20033013, + ConditionManagerParamsError = 20034001, + ConditionManagerGetConditionTemplateNotFound = 20034002, + ConditionManagerPlayerLevelNotEnough = 20034003, + ConditionManagerNotOwnCharacter = 20034004, + ConditionManagerOwnCharacterCanNotFight = 20034005, + ConditionManagerCharacterCountNotEnough = 20034006, + ConditionManagerCharacterSexIsError = 20034007, + ConditionManagerCharacterTypeIsError = 20034008, + ConditionManagerCharacterLevelIsError = 20034009, + ConditionManagerCharacterQualityIsError = 20034010, + ConditionManagerMapNotPassed = 20034011, + ConditionManagerCharacterSexNumIsError = 20034012, + ConditionManagerCharacterTypeNumIsError = 20034013, + ConditionManagerCharacterQualityNumIsError = 20034014, + ConditionManagerCharacterLevelNumIsError = 20034015, + ConditionManagerCharacterIdNumIsError = 20034016, + ConditionManagerRepeatChallengeLevelNotEnough = 20034017, + ConditionManagerCharacterAbilityNotEnough = 20034018, + ConditionManagerCharacterResonanceNotEnough = 20034019, + ConditionManagerCharacterNumIsError = 20034020, + ConditionManagerCharacterExhibitionLevelNotEnough = 20034021, + ConditionManagerCharacterLiberateLvNotEnough = 20034022, + ConditionManagerIsNotGetFirstPayReward = 20034023, + ConditionManagerIsNotOwnerFashion = 20034024, + ConditionManagerIsOwnerFashion = 20034025, + ConditionManagerExperimentIdIsNotFinish = 20034026, + ConditionManagerWeaponResonanceNotEnough = 20034027, + ConditionManagerChipResonanceNotEnough = 20034028, + ConditionManagerEquipResonanceNotEnough = 20034029, + ConditionManagerRedEnvelopeNotEnough = 20034030, + ConditionManagerKillBossTimeIsNotSatisfy = 20034031, + ConditionManagerBabelTowerLevelNotEnough = 20034032, + ConditionManagerMonsterKillCountNotEnough = 20034033, + ConditionManagerWeaponNotUnlock = 20034034, + ConditionManagerWeaponMaxLevelNotEnough = 20034035, + ConditionManagerWeaponBreakthroughNotEnough = 20034036, + ConditionManagerAwarenessSuitMaxLevelNotEnough = 20034037, + ConditionManagerAwarenessSuitMaxBreakthroughNotEnough = 20034038, + ConditionManagerAwarenessSuitNotEnough = 20034039, + ConditionManagerGuildNotIn = 20034040, + ConditionManagerGuildLevelNotEnough = 20034041, + ConditionManagerGuildJoinNotEnough = 20034042, + ConditionManagerGuildMemberNotEnough = 20034043, + ConditionManagerFubenExploreNotFinished = 20034044, + ConditionManagerRogueLikeMaxTierNotEnough = 20034045, + ConditionManagerArenaOnlineFirstPassNotEnough = 20034046, + ConditionManagerArenaOnlineAssistCountNotEnough = 20034047, + ConditionManagerTaskNotFinish = 20034048, + ConditionManagerSpecialTrainStarNotEnough = 20034049, + ConditionManagerBossActivityStarRewardNotGet = 20034050, + ConditionManagerCharacterTypeNumsNotEnough = 20034051, + ConditionManagerSpecialCollectionLevelNotEnough = 20034052, + ConditionManagerWorldBossAttributeStageFinishedNotEnough = 20034053, + ConditionManagerWorldBossHpPercentNotSatisfy = 20034054, + ConditionManagerWorldBossHpHurtNotEnough = 20034055, + ConditionManagerHonorLevelNotEnough = 20034056, + ConditionManagerDragPuzzleNotCompleted = 20034057, + ConditionManagerTrpgTargetNotFinish = 20034058, + ConditionManagerTrpgMazeCardNotFinish = 20034059, + ConditionManagerTrpgMazeCardIsFinish = 20034060, + ConditionManagerNieRCharacterLevelNotEnough = 20034061, + ConditionManagerNieRSupportLevelNotEnough = 20034062, + ConditionManagerNieRSupportSkillLevelNotEnough = 20034063, + ConditionManagerFuBenMainStarRateNotEnough = 20034064, + ConditionManagerChapterExtraStarRateNotEnough = 20034065, + ConditionManagerZhouMuNotFinish = 20034066, + ConditionManagerRegressionNotSatisfy = 20034067, + ConditionManagerEndlessStageNpcGroupNotEnough = 20034068, + ConditionManagerRecruitLevelNotEnough = 20034069, + ConditionManagerPartnerLevelNotEnough = 20034070, + ConditionManagerPartnerQualityNotEnough = 20034071, + ConditionManagerPartnerSkillLevelNotEnough = 20034072, + ConditionManagerPartnerTypeIsError = 20034073, + ConditionManagerRpgTeamLevelNotEnough = 20034074, + ConditionManagerPartnerHadNotOwner = 20034075, + ConditionManagerSpTargetProgressNotEnough = 20034076, + RobotManagerInitCharacterQualityFail = 20036001, + RobotManagerInitCharacterLevelFail = 20036002, + RobotManagerInitCharacterGradeFail = 20036003, + RobotManagerInitSkillLevelFail = 20036004, + RobotManagerInitWeapoonLevelFail = 20036005, + RobotManagerInitWeapoonAweakenFail = 20036006, + RobotManagerInitWeapoonBreakThroughFail = 20036007, + RobotManagerRobotNotExit = 20036008, + PersonalInfoQueryPlayerDataFail = 20037001, + PersonalInfoWithoutPermission = 20037002, + PersonalInfoNoShowCharacterWithThisId = 20037003, + PersonalInfoNoCharacterInfoWithThisId = 20037004, + DailyGiveALikeFail = 20038001, + DailyAddLikeSuccess = 20038002, + DailyDelLikeSuccess = 20038003, + DailyBanMsgFail = 20038004, + BaseEquipTemplateNoFound = 20039001, + BaseEquipAttribPoolsNoFound = 20039002, + BaseEquipBottomPoolTemplateNoFound = 20039003, + BaseEquipNotFound = 20039004, + BaseEquipEvaluated = 20039005, + BaseEquipNotEvaluate = 20039006, + BaseEquipWasPutOn = 20039007, + BaseEquipPutOnLevelLimit = 20039008, + BountyTaskHaveNoTask = 20040001, + BountyTaskUpperLimit = 20040002, + BountyTaskHasAccept = 20040003, + BountyTaskStatusError = 20040004, + BountyTaskRefreshUpperLimit = 20040005, + BountyTaskHaveNoTaskInTaskPool = 20040006, + BountyTaskRefreshFail = 20040007, + BountyTaskHadExpired = 20040008, + TaskForceTaskPoolIsFull = 20041001, + TaskForceCountLimit = 20041002, + TaskForceHaveNoThisTaskInTaskPool = 20041003, + TaskForceHaveNoThisTask = 20041004, + TaskForceCharacterLevelLimit = 20041005, + TaskForceTaskHasAccept = 20041006, + TaskForceHaveNoCharacter = 20041007, + TaskForceCharacterHasBeenDispatched = 20041008, + TaskForceNotAcceptThisTask = 20041009, + TaskForceTaskWasCompleted = 20041010, + TaskForceTaskTheTaskIsNotCompleted = 20041011, + VoteGroupTemplateNotFound = 20043001, + VoteIsNotEffect = 20043002, + VoteIsInvalid = 20043003, + VoteIsClosed = 20043004, + VoteTimesIsUseUp = 20043005, + VoteIdUnknown = 20043006, + ArenaActivityNotFound = 20044001, + ArenaActivityIsLoading = 20044002, + ArenaActivityFuncIsNotOpen = 20044003, + ArenaActivityChallengeRegulatorNotFound = 20044004, + ArenaActivityPlayerNotFound = 20044005, + ArenaActivityPlayerHaveTeam = 20044006, + ArenaActivityTeamIsFull = 20044007, + ArenaActivityPlayerIsInTeam = 20044008, + ArenaActivityPlayerNotHaveChallengeId = 20044009, + ArenaActivityArenaServiceIsNotFound = 20044010, + ArenaActivityTeamIsNotFound = 20044011, + ArenaActivityTeamIsAlreadyApply = 20044012, + ArenaActivityIsNotCaptain = 20044013, + ArenaActivityPlayerIsNotApply = 20044014, + ArenaActivityPlayerIsNotInTeam = 20044015, + ArenaActivityTargetIsNotFound = 20044016, + ArenaActivityTargetHaveTeam = 20044017, + ArenaActivityPlayerIsNotInviter = 20044018, + ArenaActivityPlayerGroupNotFound = 20044019, + ArenaActivityAreaIsNotOpen = 20044020, + ArenaActivityAreaIsAlreadyUnlock = 20044021, + ArenaActivityPlayerAlreadyJoin = 20044022, + ArenaActivityPlayerJoinFail = 20044023, + ArenaActivityStageIsError = 20044024, + ArenaActivityChallengeIdIsNotExist = 20044025, + ArenaActivityAreaIsNotUnlock = 20044026, + ArenaActivityAreaIdIsNotFound = 20044027, + ArenaActivityPreStageIsNotFinish = 20044028, + ArenaActivityPlayerIsNotJoin = 20044029, + ArenaActivityPlayerIsNotJoinBefore = 20044030, + ArenaActivityStatusIsCanNotOprea = 20044031, + ArenaActivityStatusCanNotFight = 20044032, + ArenaActivityNotHaveUnlockCount = 20044033, + ArenaActivityActivityRegulatorNotFound = 20044034, + ArenaActivityStageError = 20044035, + ArenaActivityOperateFail = 20044036, + ArenaActivityInviteTargetIsNotJoin = 20044037, + ArenaActivityStageCanNotAutoFight = 20044038, + ArenaActivityStageAutoFightNotUnlock = 20044039, + ArenaActivityStageMaxPointCanNotAutoFight = 20044040, + MatchCreateRoomFailed = 20045001, + MatchLevelLimit = 20045002, + MatchInvalidStageId = 20045003, + MatchRoomIsFull = 20045004, + MatchInvalidRoomId = 20045005, + MatchRoomNotFound = 20045006, + MatchRoomNotReady = 20045007, + MatchRoomInFight = 20045008, + MatchPlayerAlreadyInMatchPool = 20045009, + MatchPlayerNotInMatchPool = 20045010, + MatchPlayerAlreadyInRoom = 20045011, + MatchPlayerNotInRoom = 20045012, + MatchPlayerNotInThisRoom = 20045013, + MatchPlayerStateError = 20045014, + MatchPlayerNotLeader = 20045015, + MatchCanNotTransferLeaderToYourSelf = 20045016, + MatchPlayerNotFound = 20045017, + MatchRoomLeaderForceLeave = 20045018, + MatchRoomClose = 20045019, + MatchStartTimeout = 20045020, + MatchCharacterNotUnique = 20045021, + MatchPlayerOffline = 20045022, + MatchPlayerIsMatching = 20045023, + MatchPlayerCountNotEnough = 20045024, + MatchPlayerNotHaveSuitableCharacter = 20045025, + MatchMultiLevelControlNotExist = 20045026, + MatchServerMaintenance = 20045027, + MatchClientVersionError = 20045028, + ExploreChapterIsNotExist = 20046001, + ExploreChapterIsNotFinished = 20046002, + ExplorePreChapterIsNotFinished = 20046003, + ExploreChapterRewardIsGot = 20046004, + ExploreChapterNodeIsNotExist = 20046005, + ExplorePreNodeIsNotFinished = 20046006, + ExploreNodeIsFinished = 20046007, + ExploreEnduranceIsNotEnough = 20046008, + PayManagerGetPayTemplateNotFound = 20047001, + PayInsertReceiptFail = 20047002, + BranchChallengeIsNotExist = 20048001, + BranchPreStageNotFinish = 20048002, + BranchFightIsEnd = 20048003, + BranchSectionIdNotFound = 20048004, + BranchDifficultStageNotOpen = 20048005, + BossActivitySectionIsNotExist = 20049001, + BossActivitySectionIsNotHaveStage = 20049002, + BossActivitySectionPreStageNotFinish = 20049003, + BossActivityIsEnd = 20049004, + BossActivityStarRewardIdNotExist = 20049005, + BossActivityTotalStartNotEnough = 20049006, + BossActivityStarRewardAlreadyGet = 20049007, + SignIdIsNotExist = 20050001, + SignIdIsClose = 20050002, + SignInfoNotFound = 20050003, + SignRewardIsGot = 20050004, + SignRewardIsNotExist = 20050005, + SignInfoConditionNotFinish = 20050006, + SignInfoOutOfTime = 20050007, + SignIdIsNotPurchaseType = 20050008, + ExperimentGroupIsEnd = 20051001, + ExperimentLevelIdError = 20051002, + ExperimentGroupNotOpen = 20051003, + ExperimentIdNotHaveStarReward = 20051004, + ExperimentStarRewardIdNotExist = 20051005, + ExperimentIdNotFinish = 20051006, + ExperimentStarNumNotExist = 20051007, + ExperimentStarRewardAlreadyGet = 20051008, + ExperimentStarNotEnough = 20051009, + PracticeChapterIsNotFound = 20052001, + PracticeChapterStageIsError = 20052002, + PracticePreStageNotFinish = 20052003, + PracticeActivityStageNotFound = 20052004, + PurchaseTemplateNotFound = 20053001, + PurchaseTimeNotEffect = 20053002, + PurchaseTimeWasInvalid = 20053003, + PurchaseWasUnShelve = 20053004, + PurchaseBuyTimesLimit = 20053005, + PurchaseRemainDayLimit = 20053006, + PurchaseIntervalDayLimit = 20053007, + PurchasePrePurchaseLimit = 20053008, + PurchasePrePurchaseIsOnSale = 20053009, + PurchaseRecordNotFound = 20053010, + PurchaseDailyRewardAlreadyGet = 20053011, + PurchaseDailyRewardExpire = 20053012, + PurchaseNotContainDailyReward = 20053013, + PurchaseDiscountNotFound = 20053014, + PurchaseDiscountTimesLimit = 20053015, + PurchaseDiscountCountLimit = 20053016, + PurchaseAlreadyHaveForeverFashion = 20053017, + PurchaseExistMutexItem = 20053101, + CdKeyInvalid = 20054001, + CdKeyNotTimeYet = 20054002, + CdKeyTotalCountFull = 20054003, + CdKeyChannelWrong = 20054004, + CdKeyPlayerCountFull = 20054005, + CdKeyTimeOut = 20054006, + HeadPortraitTemplateNotFound = 20055001, + HeadPortraitNotOwned = 20055002, + HeadPortraitNotExist = 20055003, + HeadPortraitTimeout = 20055004, + HeadPortraitNotInTime = 20055005, + HeadFrameTemplateNotFound = 20055501, + HeadFrameNotOwned = 20055502, + HeadFrameNotExist = 20055503, + HeadFrameTimeout = 20055504, + HeadFrameNotInTime = 20055505, + FestivalActivityIsNotOpen = 20057001, + FestivalActivityIsOver = 20057002, + FestivalActivityIdNotFount = 20057003, + RedEnvelopeActivityInvalid = 20058001, + RedEnvelopeActivityNotOpen = 20058002, + RedEnvelopeActivityHaveClose = 20058003, + BabelTowerActivityNotOpen = 20059001, + BabelTowerActivityIsOver = 20059002, + BabelTowerFightIsEnd = 20059003, + BabelTowerStageIdError = 20059004, + BabelTowerCharacterIsInOtherStage = 20059005, + BabelTowerSupportPointIsNotEnough = 20059006, + BabelTowerStageGuideIdError = 20059007, + BabelTowerPreGuideInNotFinish = 20059008, + BabelTowerGuideChallengeBuffError = 20059009, + BabelTowerSelectChallengeBuffGroupError = 20059010, + BabelTowerSelectChallengeBuffNotInGroup = 20059011, + BabelTowerSelectChallengeBuffGroupNotRepeat = 20059012, + BabelTowerSelectChallengeBuffIsLocked = 20059013, + BabelTowerSelectSupportBuffGroupError = 20059014, + BabelTowerSelectSupportBuffNotInGroup = 20059015, + BabelTowerSelectSupportBuffGroupNotRepeat = 20059016, + BabelTowerCacheDataIsNull = 20059017, + BabelTowerStageIdIsNotSameCacheData = 20059018, + BabelTowerPreStageIsNotFinished = 20059019, + BabelTowerPreStageScoreNotEnough = 20059020, + BabelTowerStageNotOpen = 20059021, + BabelTowerPreFightTeamError = 20059022, + BabelTowerTowerStageInfoIsNull = 20059023, + BabelTowerTowerStageIsAlreadyReset = 20059024, + BabelTowerTowerStageIsNotReset = 20059025, + BabelTowerTeamCharacterIdIsBanned = 20059026, + BabelTowerNoRank = 20059027, + BabelTowerGetRankInfoFail = 20059028, + BabelTowerBuffGroupCfgNotExist = 20059029, + BabelTowerStageTeamDataNotFound = 20059030, + BabelTowerStageTeamIdError = 20059031, + BabelTowerStageTeamIdNotUnlock = 20059032, + BabelTowerStageLevelNotExist = 20059033, + DormDormitoryHasActivated = 20060001, + DormCannotFindDormitoryTemplate = 20060002, + DormItemNotEnough = 20060003, + DormDormitoryNotActivated = 20060004, + DormInvalidFurnitureId = 20060005, + DormGetRandomFurnitureConfigIdFails = 20060006, + DormGetFurnitureTemplateFails = 20060007, + DormStringInvalid = 20060008, + DormCharacterIdInvalid = 20060009, + DormCharacterEventTemplateIdInvalid = 20060010, + DormCharacterEventTypeTemplateIdInvalid = 20060011, + DormCharacterEventNotExist = 20060012, + DormGetFurnitureReturnFails = 20060013, + DormGetFurnitureLevelReturnFails = 20060014, + DormGetFurnitureRandomAdditionAttrFails = 20060015, + DormEventRateFails = 20060016, + DormEventCdFails = 20060017, + DormEventDailyCountFails = 20060018, + DormEventWeekCountFails = 20060019, + DormEventMoodNotFit = 20060020, + DormEventVitalityNotFit = 20060021, + DormCreateFurnitureBaseDataFails = 20060022, + DormVisitSelfDorm = 20060023, + DormRecommendCd = 20060024, + DormCharacterWorking = 20060025, + DormCharacterVitalityNotEnough = 20060026, + DormCharacterNotWorking = 20060027, + DormFurnitureCreating = 20060028, + DormFurnitureCreatePosInvalid = 20060029, + DormNoFurnitureCreating = 20060030, + DormFurnitureCreateNotComplete = 20060031, + DormCharacterFull = 20060032, + DormCharacterNotInDormitory = 20060033, + DormCharacterNotEnough = 20060034, + DormInvalidFurnitureAttrType = 20060035, + DormFurnitureAttrNotEnough = 20060036, + DormFurnitureTypeNotSame = 20060037, + DormCannotFindWorkTemplate = 20060038, + DormWorkSeatNotEnough = 20060039, + DormRequestDataInvalid = 20060040, + DormCharacterHaveInDormitory = 20060041, + DormWorkPosIsUsing = 20060042, + DormLoadPlayerFails = 20060043, + DormCharacterRewardTemplateNotFound = 20060044, + DormCharacterMoodNotEnough = 20060045, + DormNoCharacterCanVisit = 20060046, + DormGetFurnitureRewardTemplateFails = 20060047, + DormInvalidFurnitureLayout = 20060048, + DormCollectLayoutFull = 20060049, + DormLayoutBindNothing = 20060050, + DormCreateCountTooMuch = 20060051, + DormPutFurnitureCTooMuch = 20060052, + DormEncodeFurnitureLayoutItemListFailed = 20060053, + DormInvalidSnapshotId = 20060054, + DormSnapshotTimesLimited = 20060055, + DormWrongVisitId = 20060056, + DormFurnitureIsLocked = 20060057, + DormFondleInvalidCharacterId = 20060058, + DormFondleInvalidType = 20060059, + GachaTemplateNotFound = 20061001, + GachaRewardUseUp = 20061002, + GachaNotOpen = 20061003, + GachaClosed = 20061004, + GachaTimesUseUp = 20061005, + GachaTimesNotEnough = 20061006, + GachaOpenNeedGainAllPreMainReward = 20061007, + GachaOrganizeNotFound = 20061008, + GachaOrganizeNotFoundStartGacha = 20061009, + RepeatChallengeNotOpen = 20062001, + RepeatChallengeActivityCfgIsNull = 20062002, + RepeatChallengeStageCfgIsNull = 20062003, + RepeatChallengeChapterCfgIsNull = 20062004, + RepeatChallengeChapterNotInNormalChapterIds = 20062005, + RepeatChallengeChapterNotInHideChapterIds = 20062006, + RepeatChallengeChapterIsFinished = 20062007, + RepeatChallengeCountError = 20062008, + RepeatChallengeLevelCfgIsNull = 20062009, + RepeatChallengePreFightIsNull = 20062010, + RepeatChallengeFirstPassLimitCount = 20062011, + RepeatChallengeRewardNotExist = 20062012, + RepeatChallengeRewardIsGot = 20062013, + RepeatChallengeResultChallengeCountError = 20062014, + MultiChallengeCfgIsNotFound = 20062015, + RepeatChallengeHideChapterNotOpen = 20062016, + RepeatChallengeChapterNotOpen = 20062017, + RepeatChallengeHideConditionNotSatisfy = 20062018, + GuildServiceUnavaliable = 20063001, + GuildCreateGuildNameIsNull = 20063002, + GuildCreateGuildNameLengthError = 20063003, + GuildCreateGuildNameInvalid = 20063004, + GuildCreateGuildDeclarationIsNull = 20063005, + GuildCreateGuildDeclarationLengthError = 20063006, + GuildCreateGuildDeclarationInvalid = 20063007, + GuildCreateGuildIconIdIsZero = 20063008, + GuildCreateGuildInCreating = 20063009, + GuildCreateGuildPlayerHasGuild = 20063010, + GuildCreateGuildGuildExists = 20063011, + GuildCreateGuildNameDuplicated = 20063012, + GuildCreateGuildPlayerIdDuplicated = 20063013, + GuildCreateGuildIdDuplicated = 20063014, + GuildCreateGuildDataAsyncError = 20063015, + GuildCreateGuildInCd = 20063016, + GuildCreateErrorHeadPortrait = 20063017, + GuildCreateNotEnoughCost = 20063018, + GuildCreateServiceException = 20063019, + GuildCreateGuildInternalError = 20063020, + GuildApplyInCd = 20063021, + GuildApplyPlyaerHasGuild = 20063022, + GuildApplyPlyaerApplyMaxCount = 20063023, + GuildApplyApplyDuplicated = 20063024, + GuildApplyServiceException = 20063025, + GuildApplyGuildNotExist = 20063026, + GuildApplyGuildApplyMaxCount = 20063027, + GuildApplyReachCapacity = 20063028, + GuildAckApplyAckHasNotGuild = 20063029, + GuildAckApplyAckGuildNotExist = 20063030, + GuildAckApplyAckNotInThisGuild = 20063031, + GuildAckApplyAckLessRank = 20063032, + GuildAckApplyApplicantHasGuild = 20063033, + GuildAckApplyNotApply = 20063034, + GuildAckApplyReachCapacity = 20063035, + GuildAckApplyServiceException = 20063036, + GuildApplyBanApply = 20063037, + GuildApplyLessLevel = 20063038, + GuildApplyPass = 20063039, + GuildListRecommendHasGuild = 20063040, + GuildListRecommendServiceException = 20063041, + GuildListDetailGuildNotExist = 20063042, + GuildListDetailPlayerNotInGuild = 20063043, + GuildListDetailServiceException = 20063044, + GuildChangeIconHasNotGuild = 20063045, + GuildChangeIconGuildNotExist = 20063046, + GuildChangeIconNotInThisGuild = 20063047, + GuildChangeIconLessRank = 20063048, + GuildChangeIconErrorHeadPortrait = 20063049, + GuildChangeIconServiceException = 20063050, + GuildChangeDeclarationHasNotGuild = 20063051, + GuildChangeDeclarationLengthError = 20063052, + GuildChangeDeclarationInvalid = 20063053, + GuildChangeDeclarationGuildNotExist = 20063054, + GuildChangeDeclarationNotInThisGuild = 20063055, + GuildChangeDeclarationLessRank = 20063056, + GuildChangeDeclarationServiceException = 20063057, + GuildChangeRankNameHasNotGuild = 20063058, + GuildChangeRankNameInvalid = 20063059, + GuildChangeRankNameGuildNotExist = 20063060, + GuildChangeRankNameNotInThisGuild = 20063061, + GuildChangeRankNameLessRank = 20063062, + GuildChangeRankNameServiceException = 20063063, + GuildReleaseWishHasNotGuild = 20063064, + GuildReleaseWishErrorItemId = 20063065, + GuildReleaseWishMaxCount = 20063066, + GuildReleaseWishGuildNotExist = 20063067, + GuildReleaseWishNotInThisGuild = 20063068, + GuildReleaseWishServiceException = 20063069, + GuildListWishGuildNotExist = 20063070, + GuildListWishHasNotGuild = 20063071, + GuildListWishServiceException = 20063072, + GuildWishContributeGuildNotExist = 20063073, + GuildWishContributeHasNotGuild = 20063074, + GuildWishContributeItemNotEnough = 20063075, + GuildWishContributeCantToSelf = 20063076, + GuildWishContributeNotInThisGuild = 20063077, + GuildWishContributeMaxCount = 20063078, + GuildWishContributeErrorWish = 20063079, + GuildWishContributeOnlyOnce = 20063080, + GuildWishContributeServiceException = 20063081, + GuildChangeRankHasNotGuild = 20063082, + GuildChangeRankCantToSelf = 20063083, + GuildChangeRankErrorNewRank = 20063084, + GuildChangeRankGuildNotExist = 20063085, + GuildChangeRankNotInThisGuild = 20063086, + GuildChangeRankOtherNotInThisGuild = 20063087, + GuildChangeRankSameRank = 20063088, + GuildChangeRankLevelLtOther = 20063089, + GuildChangeRankLevelLtOtherNew = 20063090, + GuildChangeRankMaxCount = 20063091, + GuildChangeRankServiceException = 20063092, + GuildQuitHasNotGuild = 20063093, + GuildQuitGuildNotExist = 20063094, + GuildQuitNotInThisGuild = 20063095, + GuildQuitLeaderCantQuit = 20063096, + GuildQuitServiceException = 20063097, + GuildKickMemberHasNotGuild = 20063098, + GuildKickMemberGuildNotExist = 20063099, + GuildKickMemberKickSelf = 20063100, + GuildKickMemberOfficerNotInThisGuild = 20063101, + GuildKickMemberLessRank = 20063102, + GuildKickMemberOtherNotInThisGuild = 20063103, + GuildKickMemberRankLtOther = 20063104, + GuildKickMemberRunOut = 20063105, + GuildKickMemberServiceException = 20063106, + GuildListNewsHasNotGuild = 20063107, + GuildListNewsGuildNotExist = 20063108, + GuildListNewsServiceException = 20063109, + GuildGiveLikeHasNotGuild = 20063110, + GuildGiveLikeGiveSelf = 20063111, + GuildGiveLikeGuildNotExist = 20063112, + GuildGiveLikePlayerNotInThisGuild = 20063113, + GuildGiveLikeOtherNotInThisGuild = 20063114, + GuildGiveLikeItemNotEnough = 20063115, + GuildGiveLikeServiceException = 20063116, + GuildImpeachHasNotGuild = 20063117, + GuildImpeachPlayerNotInThisGuild = 20063118, + GuildImpeachSelf = 20063119, + GuildImpeachErrorDuration = 20063120, + GuildImpeachDuplicated = 20063121, + GuildChangeImpeachServiceException = 20063122, + GuildRejeactImpeachHasNotGuild = 20063123, + GuildChangeScriptHasNotGuild = 20063124, + GuildChangeScriptErrorIndex = 20063125, + GuildChangeScriptInvalid = 20063126, + GuildChangeScriptErrorLength = 20063127, + GuildChangeScriptMaxCount = 20063128, + GuildChangeScriptGuildNotExist = 20063129, + GuildChangeScriptOfficerNotInThisGuild = 20063130, + GuildChangeScriptLessRank = 20063131, + GuildChangeScriptServiceException = 20063132, + GuildListScriptHasNotGuild = 20063133, + GuildListScriptGuildNotExist = 20063134, + GuildListScriptOfficerNotInThisGuild = 20063135, + GuildListScriptLessRank = 20063136, + GuildListScriptServiceException = 20063137, + GuildTouristPlayerHasGuild = 20063138, + GuildTouristTouristHasGuild = 20063139, + GuildTouristGuildNotExist = 20063140, + GuildTouristTryAddFailed = 20063141, + GuildTouristMaxCount = 20063142, + GuildQuitTouristHasNotGuild = 20063143, + GuildQuitTouristNotInThisGuild = 20063144, + GuildRecruitRecommendHasNotGuild = 20063145, + GuildRecruitRecommendException = 20063146, + GuildRecruitRecommendGuildNotExist = 20063147, + GuildRecruitRecommendOfficerNotInThisGuild = 20063148, + GuildRecruitRecommendLessRank = 20063149, + GuildRecruitRecommendNeedRefresh = 20063150, + GuildUpdateRecruitRecommendGuildNotExist = 20063151, + GuildUpdateRecruitRecommendOfficerNotInThisGuild = 20063152, + GuildUpdateRecruitRecommendLessRank = 20063153, + GuildRecruitHasNotGuild = 20063154, + GuildRecruitServiceException = 20063155, + GuildRecruitGuildNotExist = 20063156, + GuildRecruitOfficerNotInThisGuild = 20063157, + GuildRecruitLessRank = 20063158, + GuildRecruitPlayerHasGuild = 20063159, + GuildRecruitPlayerNotInRecommend = 20063160, + GuildRecruitDuplicated = 20063161, + GuildRecruitGuildMaxCount = 20063162, + GuildListRecruitHasGuild = 20063163, + GuildListRecruitServiceException = 20063164, + GuildAckRecruitHasGuild = 20063165, + GuildAckRecruitServiceException = 20063166, + GuildAckRecruitGuildNotExist = 20063167, + GuildAckRecruitNoRecruit = 20063168, + GuildAckRecruitReachCapacity = 20063169, + GuildAckRecruitInCd = 20063170, + GuildLevelUpHasNotGuild = 20063171, + GuildLevelUpServiceException = 20063172, + GuildLevelUpGuildNotExist = 20063173, + GuildLevelUpOfficerNotInThisGuild = 20063174, + GuildLevelUpLessRank = 20063175, + GuildLevelUpLessBuild = 20063176, + GuildLevelUpMaxLevel = 20063177, + GuildPayMaintainHasNotGuild = 20063178, + GuildPayMaintainServiceException = 20063179, + GuildPayMaintainGuildNotExist = 20063180, + GuildPayMaintainOfficerNotInThisGuild = 20063181, + GuildPayMaintainLessRank = 20063182, + GuildPayMaintainNotEmergency = 20063183, + GuildPayMaintainLessContribute = 20063184, + GuildAddContributeHasNotGuild = 20063185, + GuildAddContributeServiceException = 20063186, + GuildAddContributeGuildNotExist = 20063187, + GuildListApplyHasNotGuild = 20063188, + GuildListApplyServiceException = 20063189, + GuildListApplyGuildNotExist = 20063190, + GuildListApplyOfficerNotInThisGuild = 20063191, + GuildListApplyLessRank = 20063192, + GuildAddContributePlayerNotInGuild = 20063193, + GuildGetGiftHasNotGuild = 20063194, + GuildGetGiftServiceException = 20063195, + GuildGetGiftInTwoGuild = 20063196, + GuildGetGiftGuildNotExist = 20063197, + GuildGetGiftNotInThisGuild = 20063198, + GuildGetGiftGiftNotExist = 20063199, + GuildGetGiftLessContribute = 20063200, + GuildGetGiftDuplicated = 20063201, + GuildGetContributeRewardHasNotGuild = 20063202, + GuildGetContributeRewardGot = 20063203, + GuildGetContributeRewardServiceException = 20063204, + GuildGetContributeRewardNotInThisGuild = 20063205, + GuildGetContributeRewardLessContribute = 20063206, + GuildMailServiceUnavaliable = 20063207, + GuildMailServiceException = 20063208, + GuildMailContentFormatError = 20063209, + GuildListChatHasNotGuild = 20063210, + GuildListChatServiceException = 20063211, + GuildListChatGuildNotExist = 20063212, + GuildListChatNotInThisGuild = 20063213, + GuildFindServiceException = 20063214, + GuildChangeApplyOptionHasNotGuild = 20063215, + GuildChangeApplyOptionServiceException = 20063216, + GuildChangeApplyOptionGuildNotExist = 20063217, + GuildChangeApplyOptionNotInThisGuild = 20063218, + GuildChangeApplyOptionLessRank = 20063219, + GuildServerInternalError = 20063220, + GuildGetMemberNotFound = 20063221, + GuildShopGetGuildNotExist = 20063222, + GuildBuyGoodsMemberLessRank = 20063223, + GuildRefreshShopMemberLessRank = 20063224, + GuildGetShopHasNotGuild = 20063225, + GuildGetShopServiceException = 20063226, + GuildBuyGoodsHasNotGuild = 20063227, + GuildBuyGoodsServiceException = 20063228, + GuildRefreshShopHasNotGuild = 20063229, + GuildRefreshShopServiceException = 20063230, + GuildListRankHasNotGuild = 20063231, + GuildListRankServiceException = 20063232, + GuildAddBuildGuildNotExist = 20063233, + GuildAddBuildNotInGuild = 20063234, + GuildRecruitGuildDailyCount = 20063235, + GuildGiveLikeItemInvalid = 20063236, + GuildChangeNameNotInGuild = 20063237, + GuildChangeNameGuildNameIsNull = 20063238, + GuildChangeNameGuildNameLengthError = 20063239, + GuildChangeNameGuildNameInvalid = 20063240, + GuildChangeNameGuildNameEqual = 20063241, + GuildChangeNameNotEnoughCost = 20063242, + GuildChangeNameGuildNameDuplicated = 20063243, + GuildChangeNameServiceException = 20063244, + GuildChangeNameLessRank = 20063245, + GuildListTalentException = 20063246, + GuildListTalentNotInGuild = 20063247, + GuildListTalentGuildNotExist = 20063248, + GuildUpgradeTalentNotInGuild = 20063249, + GuildUpgradeTalentGuildNotExist = 20063250, + GuildUpgradeTalentLessRank = 20063251, + GuildUpgradeTalentTalentNotExist = 20063252, + GuildUpgradeTalentLessLevel = 20063253, + GuildUpgradeTalentParentNotExist = 20063254, + GuildUpgradeTalentParentLessLevel = 20063255, + GuildUpgradeTalentMaxLevel = 20063256, + GuildUpgradeTalentPointNotEnough = 20063257, + GuildBossBossStatusGuildNotExist = 20063258, + GuildBossBossStatusNotInGuild = 20063259, + GuildBossBossStatusNotOpen = 20063260, + GuildBossBossInfoGuildNotExist = 20063261, + GuildBossBossInfoNotInGuild = 20063262, + GuildBossBossInfoNotOpen = 20063263, + GuildBossBossActivityGuildNotExist = 20063264, + GuildBossBossActivityNotInGuild = 20063265, + GuildBossBossActivityNotOpen = 20063266, + GuildBossCheckResetNotInGuild = 20063267, + GuildBossCheckResetNotOpen = 20063268, + GuildBossBossStageGuildNotExist = 20063269, + GuildBossBossStageNotInGuild = 20063270, + GuildBossBossStageNotExist = 20063271, + GuildBossBossStageNotOpen = 20063272, + GuildBossPlayerRankGuildNotExist = 20063273, + GuildBossPlayerRankNotInGuild = 20063274, + GuildBossPlayerStageRankGuildNotExist = 20063275, + GuildBossPlayerStageRankNotInGuild = 20063276, + GuildBossPlayerStageRankStageNotExist = 20063277, + GuildBossGuildRankGuildNotExist = 20063278, + GuildBossGuildRankNotInGuild = 20063279, + GuildBossHpBoxGuildNotExist = 20063280, + GuildBossHpBoxNotInGuild = 20063281, + GuildBossHpBoxDuplicated = 20063282, + GuildBossHpBoxRewardNotExist = 20063283, + GuildBossHpBoxConditionFail = 20063284, + GuildBossHpBoxNotOpen = 20063285, + GuildBossHpBoxActivityUpdate = 20063286, + GuildBossScoreBoxGuildNotExist = 20063287, + GuildBossScoreBoxNotInGuild = 20063288, + GuildBossScoreBoxDuplicated = 20063289, + GuildBossScoreBoxRewardNotExist = 20063290, + GuildBossScoreBoxConditionFail = 20063291, + GuildBossScoreBoxNotOpen = 20063292, + GuildBossScoreBoxActivityUpdate = 20063293, + GuildBossFightNoBoss = 20063294, + GuildBossFightNoStage = 20063295, + GuildBossFightNoRobot = 20063296, + GuildBossFightInvalidRobot = 20063297, + GuildBossFightStageNotMatch = 20063298, + GuildBossFightNoScoreRule = 20063299, + GuildBossUploadNotInGuild = 20063300, + GuildBossUploadStageNotMatch = 20063301, + GuildBossUploadDamageNotMatch = 20063302, + GuildBossUploadMaxCount = 20063303, + GuildBossDamageNotInGuild = 20063304, + GuildBossDamageActivityUpdate = 20063305, + GuildBossDamageNoStage = 20063306, + GuildBossDamageDuplicated = 20063307, + GuildBossDamageActivityNotOpen = 20063308, + GuildBossDamageNotBreak = 20063309, + GuildBossSetLevelNotInGuild = 20063310, + GuildBossSetLevelActivityUpdate = 20063311, + GuildBossSetLevelNotAdmin = 20063312, + GuildBossSetLevelNoLevelCfg = 20063313, + GuildBossSetLevelLessScore = 20063314, + GuildBossSetLevelGuildNotExist = 20063315, + GuildBossSetLevelNotOpen = 20063316, + GuildBossSetOrderNotInGuild = 20063317, + GuildBossSetOrderActivityUpdate = 20063318, + GuildBossSetOrderNotAdmin = 20063319, + GuildBossSetOrderGuildNotExist = 20063320, + GuildBossSetOrderNotOpen = 20063321, + RogueLikeActivityNotOpen = 20064001, + RogueLikeActionPointNotEnough = 20064002, + RogueLikeSectionInfoIsNull = 20064003, + RogueLikeNodeIsNull = 20064004, + RogueLikeNodeIsNotFightNode = 20064005, + RogueLikeNodeStageIsError = 20064006, + RogueLikeNodeIdNotInTierCfg = 20064007, + RogueLikeNodeLineError = 20064008, + RogueLikeNodePreFightDataIsNull = 20064009, + RogueLikeFightTeamCountIsError = 20064010, + RogueLikeAssistRobotNotEnough = 20064011, + RogueLikeAssistCharacterIdError = 20064012, + RogueLikeFightCharacterNotInSetTeam = 20064013, + RogueLikeFightNodeNotNeedSelect = 20064014, + RogueLikeTierAlreadySelectNode = 20064015, + RogueLikeFinishNodeMustSelectFirst = 20064016, + RogueLikeBlackShopIdError = 20064017, + RogueLikeBlackShopNotHaveItemId = 20064018, + RogueLikeShopCfgNotFound = 20064019, + RogueLikeShopItemCfgNotFound = 20064020, + RogueLikeBuyCountNotEnough = 20064021, + RogueLikeSelectNodeIsNull = 20064022, + RogueLikeSelectNodeIsError = 20064023, + RogueLikeEventNodeCfgIsNull = 20064024, + RogueLikeEventNodeIsNotRestType = 20064025, + RogueLikeBuffCfgIsNull = 20064026, + RogueLikeBuffCanNotIntensify = 20064027, + RogueLikeIntensifyBuffNotExist = 20064028, + RogueLikeNodeTypeError = 20064029, + RogueLikeNotOwnerBuff = 20064030, + RogueLikeShopInfoIsNull = 20064031, + RogueLikeNodeShopNotHaveItemId = 20064032, + RogueLikeSpecialEventIdError = 20064033, + RogueLikeSpecialEventCfgIsNull = 20064034, + RogueLikeEventTypeError = 20064035, + RogueLikeSpecialEventTypeError = 20064036, + RogueLikeRecoverCfgIsNull = 20064037, + RogueLikeShopBuyCountError = 20064038, + RogueLikeFightIsOver = 20064039, + RogueLikeSectionIdIsError = 20064040, + RogueLikeSupportStationCfgNotExist = 20064041, + RogueLikeSupportCountLimit = 20064042, + RogueLikeSpecialEventGroupCfgNotExist = 20064043, + RogueLikeSpecialEventGroupNotInEventCfg = 20064044, + RogueLikeNodeNoNeedSelect = 20064045, + RogueLikeBoxCfgNotFound = 20064046, + RogueLikeGroupTierCfgNotExist = 20064047, + RogueLikeEventGroupNotExist = 20064048, + RogueLikeGroupEventNotEnough = 20064049, + RogueLikeTeamAlreadySet = 20064050, + RogueLikeTeamSetFirst = 20064051, + RogueLikeRobotIsFull = 20064052, + RogueLikeHPFull = 20064053, + ArchiveInvalidEvaluateId = 20065001, + ArchiveInvalidMonsterId = 20065002, + ArchiveInvalidId = 20065003, + ArchiveConditionNotFit = 20065004, + ArchiveInvalidTag = 20065005, + ArchiveInvalidStoryId = 20065006, + ArchiveInvalidEvaluateType = 20065007, + RegressionActivityCfgNotExist = 20066001, + RegressionTaskActivityIsOver = 20066002, + RegressionGroupScheduleRewardCfgNotExist = 20066003, + RegressionScheduleRewardCfgNotExist = 20066004, + RegressionScheduleItemNotEnough = 20066005, + RegressionScheduleRewardAlreadyGet = 20066006, + RegressionInviteDissatisfied = 20066007, + RegressionInviteCodeDataAlreadyExist = 20066008, + RegressionInviteCodeDataNotExist = 20066009, + RegressionInviteLoadCodeDataIsNull = 20066010, + RegressionInviteCfgNotExist = 20066011, + RegressionInviteRewardIdError = 20066012, + RegressionInviteRewardAlreadyGet = 20066013, + RegressionInviteRewardCfgNotExist = 20066014, + RegressionInvitePeopleNotEnough = 20066015, + RegressionCanNotUseSelfCode = 20066016, + RegressionInviteCodeAlreadyUse = 20066017, + RegressionInviteCodeUseMax = 20066018, + RegressionInviteCodeNotExist = 20066019, + RegressionInviteCodeUseFail = 20066020, + RegressionInviteOperating = 20066021, + RegressionTaskGroupCfgNotExist = 20066022, + RegressionInviteCodeInvalid = 20066023, + ProductCommentActivityNotOpen = 20067001, + ProductCommentPraiseNotOpen = 20067002, + ProductCommentActivityCfgNotExist = 20067003, + ProductCommentPraiseItemNotEnough = 20067004, + ProductCommentHttpResponseError = 20067005, + ProductCommentContentCountExceedMaxNum = 20067006, + ProductCommentContentLengthExceedLength = 20067007, + ProductCommentContentIllegal = 20067008, + ProductCommentActivityIdError = 20067009, + ProductCommentUploadCountReachMax = 20067010, + ProductCommentTodayAlreadyUpload = 20067011, + ProductCommentUploadNotOpen = 20067012, + ProductCommentAlreadyPraiseComment = 20067013, + ProductCommentNotPraiseSelfComment = 20067014, + ProductCommentSystemError = 20067015, + ProductCommentSignError = 20067016, + ProductCommentUrlNotExist = 20067017, + ProductCommentUnKnowError = 20067018, + ProductCommentScheduleRewardAlreadyGet = 20067019, + ProductCommentScheduleRewardIdNotExist = 20067020, + ProductCommentScheduleNotEnough = 20067021, + ProductCommentHttpRequestError = 20067022, + ProductCommentIsPraising = 20067023, + ProductCommentIsUnloading = 20067024, + WeaponFashionTemplateNotFound = 20068001, + WeaponFashionTimeInvalid = 20068002, + WeaponFashionNotEffect = 20068003, + WeaponFashionExpired = 20068004, + WeaponFashionNotFound = 20068005, + WeaponFashionUseEquipTypeError = 20068006, + WeaponFashionTimeUseUp = 20068007, + WeaponFashionAddCountError = 20068008, + WeaponFashionCharacterDressRepeat = 20068009, + WeaponFashionIsOwnedPerpetual = 20068010, + WeaponFashionIsUnOwnedPerpetual = 20068011, + MatchServiceInvalidRoomId = 20069001, + MatchServiceRepeatRoomId = 20069002, + MatchServiceInvalidPlayerId = 20069003, + MatchServiceAlreadyInThisRoom = 20069004, + MatchServiceYouAreNotLeader = 20069005, + MatchServiceMatchCanceled = 20069006, + MatchServiceAlreadyInMatchPool = 20069007, + MatchServiceHavePlayerNotReady = 20069008, + MatchServiceRoomOptionNotExist = 20069009, + MatchServiceAutoMatchSetSameValue = 20069010, + MatchServicePlayerIsFull = 20069011, + MatchServiceRoomHasClosed = 20069012, + MatchServerPlayerHeartbeatTimeout = 20069013, + ArenaOnlineNotOpen = 20070001, + ArenaOnlineCharacterTooMuch = 20070002, + ArenaOnlineCharacterNotEnough = 20070003, + ArenaOnlineEnduranceNotEnough = 20070004, + ArenaOnlineRoomIdInvalid = 20070005, + ArenaOnlineStageIdInvalid = 20070006, + ArenaOnlineGetSelfPlayerParamFail = 20070007, + ArenaOnlineRoomParamMetaKeyInvalid = 20070008, + ArenaOnlineRoomPlayeridInvalid = 20070009, + ArenaOnlinePlayerParamMetaKeyInvalid = 20070010, + ArenaOnlinePlayerNotInRoom = 20070011, + ArenaOnlinePlayerHaveInRoom = 20070012, + ArenaOnlinePlayerIsNotLeader = 20070013, + ArenaOnlineCharacterIdInvalid = 20070014, + ArenaOnlineLeaderForceLeave = 20070015, + ArenaOnlinePlayerIsInMatching = 20070016, + ArenaOnlinePlayerNotInMatching = 20070017, + ArenaOnlinePlayerNotReady = 20070018, + ArenaOnlinePlayerLevelNotMatch = 20070019, + ArenaOnlineInFight = 20070020, + ArenaOnlineEnterRoomInFight = 20070021, + ArenaOnlineStageNotSingleStage = 20070022, + ArenaOnlineFightCharacterRepeat = 20070023, + InfestorExploreChapterNotFound = 20072001, + InfestorExploreMapNotFound = 20072002, + InfestorExploreGridNotFound = 20072003, + InfestorExploreGroupNotFound = 20072004, + InfestorExploreNodeNotFound = 20072005, + InfestorExploreRewardNotFound = 20072006, + InfestorExploreRewardPoolNotFound = 20072007, + InfestorExploreEventPoolNotFound = 20072008, + InfestorExploreDiffTemplateNotFound = 20072009, + InfestorExploreGroupLevelNotFound = 20072010, + InfestorExploreShopGoodsNotFound = 20072011, + InfestorExploreShopGoodsListNotFound = 20072012, + InfestorExploreShopNotFound = 20072013, + InfestorExploreCoreNotFound = 20072014, + InfestorExploreCoreLevelEffectNotFound = 20072015, + InfestorExploreBuffNotFound = 20072016, + InfestorExploreBuffListNotFound = 20072017, + InfestorExploreActivityNotFound = 20072018, + InfestorExploreEventShopGoodsNotFound = 20072019, + InfestorExploreBossScoreRuleNotFound = 20072020, + InfestorExploreTeamFull = 20072021, + InfestorExploreJoinTeamFail = 20072022, + InfestorExplorePlayerAlreadySignUp = 20072023, + InfestorExploreStatusIsUnOpen = 20072024, + InfestorExploreStatusIsReset = 20072025, + InfestorExploreCreatePlayerFail = 20072026, + InfestorExploreStatusIsNotStageExplore = 20072027, + InfestorExplorePlayerSignUpLevelLimit = 20072028, + InfestorExplorePlayerNotFound = 20072029, + InfestorExploreTeamNotFound = 20072030, + InfestorExploreMoveToGridRepeated = 20072031, + InfestorExploreMoveToGridCanNotMove = 20072032, + InfestorExploreMapNotContainGrid = 20072033, + InfestorExploreFrontGridNotFinish = 20072034, + InfestorExploreCoreUseIndexError = 20072035, + InfestorExploreCoreUnOwned = 20072036, + InfestorExploreCoreUseRepeated = 20072037, + InfestorExploreCoreIsUsed = 20072038, + InfestorExploreTakeOffIndexError = 20072039, + InfestorExploreTakeOffPosIsEmpty = 20072040, + InfestorExploreNodeTypeNotMatch = 20072041, + InfestorExploreFightStageIdNotMatch = 20072042, + InfestorExploreFightStageTeamError = 20072043, + InfestorExploreBuyFightRewardNotFound = 20072044, + InfestorExploreBuyFightRewardAlreadyBuy = 20072045, + InfestorExploreBuyGoodsNotExist = 20072046, + InfestorExploreBuyGoodsSellout = 20072047, + InfestorExploreCanNotChangeCharacter = 20072048, + InfestorExploreCanNotFoundSelectEvent = 20072049, + InfestorExploreRewardGridInfoNotFound = 20072050, + InfestorExploreSetRewardIdInvalid = 20072051, + InfestorExploreSetRewardMsgToLong = 20072052, + InfestorExploreMsgInvalid = 20072053, + InfestorExploreBossFightStageIdInvalid = 20072054, + InfestorExploreCanBuyEventGoodsThisStatus = 20072055, + InfestorExploreEventShopNotExist = 20072056, + InfestorExploreBuyEventGoodsLimit = 20072057, + InfestorExploreBuyEventGoodsIdInvalid = 20072058, + InfestorExploreLeaveMsgTimeLimit = 20072059, + InfestorExploreLeaveMsgChapterNotFound = 20072060, + InfestorExploreLeaveMsgToLong = 20072061, + InfestorExploreBfrtCharacterIdError = 20072062, + InfestorUpdateTeamCharacterTypeError = 20072063, + InfestorUpdateTeamPosTeamIsEmpty = 20072064, + InfestorExploreFightUnknownGridId = 20072065, + InfestorExploreFightStageUnMatch = 20072066, + UnionKillActivityNotOpen = 20080001, + UnionKillActivityCfgNotExist = 20080002, + UnionKillSectionIsNotCurSection = 20080003, + UnionKillSectionCfgNotExist = 20080004, + UnionKillSectionInfoNotExist = 20080005, + UnionKillSectionStagesNotExist = 20080006, + UnionKillEventStageCfgNotExist = 20080007, + UnionKillScoreRuleCfgNotExist = 20080008, + UnionKillWeatherCfgNotExist = 20080009, + UnionKillSectionNotOpen = 20080010, + UnionKillSectionIsClose = 20080011, + UnionKillStageNotInCurSectionCfg = 20080012, + UnionKillFightRoomNotExist = 20080013, + UnionKillPreFightShareCardInfosError = 20080014, + UnionKillChallengeEventStageReachMax = 20080015, + UnionKillFinishEventStageNotEnough = 20080016, + UnionKillFinishBossIsDead = 20080017, + UnionKillFinishBossNotDead = 20080018, + UnionKillBossNotEnough = 20080019, + UnionKillSectionRewardAlreadyGet = 20080020, + UnionKillPreFightShareCardInfoIsNull = 20080021, + UnionKillPreFightOneShareInfoIsNull = 20080022, + UnionKillShareCharacterNotExist = 20080023, + UnionKillCanNotPraiseSelf = 20080024, + UnionKillPraisePlayerNotExist = 20080025, + UnionKillPraiseCharacterIdError = 20080026, + UnionKillAlreadyPraisePlayer = 20080027, + UnionKillAlreadyHaveTeam = 20080028, + UnionKillRoomIdInvalid = 20080029, + UnionKillNotHaveTeam = 20080030, + UnionKillKickOut = 20080031, + UnionKillNotMatching = 20080032, + UnionKillFightIsOver = 20080033, + UnionKillPlayerIsFighting = 20080034, + UnionKillOperateFail = 20080035, + UnionKillIsMatching = 20080036, + UnionKillTrialStageCanNotUseShareCharacter = 20080037, + UnionKillFightCharacterRepeat = 20080038, + UnionKillFightCardNotEqualShareInfo = 20080039, + DailyLotteryInvalidId = 20081001, + DailyLotteryIdIsClosed = 20081002, + DailyLotteryDataNotFound = 20081003, + DailyLotteryRewardIsGot = 20081004, + DailyLotteryInvalidLotteryRewardId = 20081005, + FireworksNotUnlock = 20081101, + FireworksInvalidId = 20081102, + FireworksAlreadyFinish = 20081103, + FireworksNotOpen = 20081104, + FireworksTimesIsUpperLimit = 20081105, + CollectionScoreNotEnough = 20090001, + CollectionNotExist = 20090002, + CollectionCanOnlyPlacedOnce = 20090003, + CollectionNotInThisWall = 20090004, + CollectionWallNotUnlock = 20090005, + CollectionWallDecorationNotUnlock = 20090006, + CollectionWallDecorationTypeNotMatch = 20090007, + CollectionWallScoreTitleSizeNotMatch = 20090008, + EliminateGameNotInTime = 20091001, + EliminateGameNotInMove = 20091002, + EliminateGameNotInFlip = 20091003, + EliminateGameGridPosInvalid = 20091004, + EliminateGameGridHadFlip = 20091005, + EliminateGameInvalidGameId = 20091006, + EliminateGameInitError = 20091007, + EliminateGameNotExist = 20091008, + EliminateGameRewardNotExist = 20091009, + EliminateGameRewardNotEnough = 20091010, + EliminateGameRewardHadGet = 20091011, + EliminateGameTargetIsObstacle = 20091012, + EliminateGameTooFarAway = 20091013, + EliminateGameNotMove = 20091014, + SpecialTrainStarNotEnough = 20092001, + SpecialTrainRewardHaveGot = 20092002, + SpecialTrainRewardNotExist = 20092003, + SpecialTrainRewardCannotFoundChapter = 20092004, + SpecialTrainActivityNotInOpenTime = 20092005, + SpecialTrainPointRewardAlreadyGet = 20092006, + SpecialTrainPointRewardIdNotExist = 20092007, + SpecialTrainPointNotEnough = 20092008, + ChapterExtraPassTimesNotEnough = 20093001, + ChapterExtraInvalidStageId = 20093002, + ChapterExtraActivityHideChapterNotOpen = 20093003, + MarketVoteTokenUrlConnectFail = 20094001, + MarketVoteTokenUrlParamError = 20094002, + MarketVoteTokenUrlServerError = 20094003, + MarketVoteTokenUrlSignError = 20094004, + MarketVoteTokenUrlUnknownError = 20094005, + MarketGetVoteTokenFail = 20094006, + BriefStoryIdInvalid = 20095001, + BriefStoryIdIsFinished = 20095002, + WorldBossIsNotOpen = 20096001, + WorldBossAttributeAreaCfgNotFound = 20096002, + WorldBossAttributeStageCfgNotFound = 20096003, + WorldBossBossAreaCfgNotFound = 20096004, + WorldBossBossStageCfgNotFound = 20096005, + WorldBossStageLevelNotExist = 20096006, + WorldBossStageInfoNotFound = 20096007, + WorldBossBuffCfgNotFound = 20096008, + WorldBossScoreRuleCfgNotFound = 20096009, + WorldBossScorePhasesCfgNotFound = 20096010, + WorldBossScoreShopCfgNotFound = 20096011, + WorldBossAttributePreStageNotFinish = 20096012, + WorldBossAttributeStageNotFinish = 20096013, + WorldBossBossUnlockFinishedStageNotEnough = 20096014, + WorldBossChallengeCountNotEnough = 20096015, + WorldBossActionPointNotEnough = 20096016, + WorldBossPreFightRobotIdsIsNull = 20096017, + WorldBossCardIdCountNotEqualRobotIdCount = 20096018, + WorldBossRobotIdNotUnlock = 20096019, + WorldBossFightCharacterIdRepeat = 20096020, + WorldBossAttributeAreaNotFinished = 20096021, + WorldBossAttributeAreaRewardAlreadyGet = 20096022, + WorldBossAttributeAreaNotContainStageId = 20096023, + WorldBossAttributeStageNotHaveFinishReward = 20096024, + WorldBossAttributeStageFinishRewardAlreadyGet = 20096025, + WorldBossBossPhasesRewardIdsNotContainsPhasesId = 20096026, + WorldBossBossPhasesRewardHpPercentNotEnough = 20096027, + WorldBossBossPhasesRewardAlreadyGet = 20096028, + WorldBossShopIdAlreadyBuy = 20096029, + PuzzleActivityInvalidId = 20097001, + PuzzleActivityInvalidPieceId = 20097002, + PuzzleActivityPieceAlreadyFilped = 20097003, + PuzzleActivityRewardFailedPieceNotEnough = 20097004, + ClickClearCanNotFindActivityData = 20098001, + ClickClearCanNotFindStageConfig = 20098002, + ClickClearStageLock = 20098003, + ClickClearNotBestRecord = 20098004, + ClickClearRewardAlreadyGot = 20098005, + ClickClearNotPass = 20098006, + ClickClearTimeOut = 20098007, + ExpeditionNoRefreshTimes = 20099001, + ExpeditionExceedingRecruitTimes = 20099002, + ExpeditionExceedingMaxMemberNum = 20099003, + ExpeditionDailyLikeLimited = 20099004, + ExpeditionCannotFindChapterConfig = 20099005, + ExpeditionCannotFindStageConfig = 20099006, + ExpeditionRefreshException = 20099007, + ExpeditionCannotFindCharacterConfig = 20099008, + ExpeditionCharacterLevelWrong = 20099009, + ExpeditionCommentTooLong = 20099010, + ExpeditionNotOpen = 20099011, + ExpeditionHadCommented = 20099012, + ExpeditionCannotFindCommand = 20099013, + ExpeditionChapterRewardIsGot = 20099014, + ExpeditionChapterIsNotPassed = 20099015, + ExpeditionCanNotFindCharacterConfig = 20099016, + ExpeditionCanNotFindBaseCharacterConfig = 20099017, + ExpeditionCanNotFindDrawPrConfig = 20099018, + ExpeditionCanNotFindDrawStarConfig = 20099019, + ExpeditionCanNotFindChapterRewardConfig = 20099020, + ExpeditionActivityIsEnd = 20099021, + ExpeditionActivityIsReset = 20099022, + RpgNotOpen = 20100001, + RpgCanNotFindCharacter = 20100002, + RpgTalentPosHadActivated = 20100003, + RpgCanNotFindTalentConfig = 20100004, + RpgTalentPreLayerNotActivated = 20100005, + RpgTalentPointsNotEnough = 20100006, + RpgSameCharacter = 20100007, + RpgFightParamsError = 20100008, + RpgChallengeCountNotEnough = 20100009, + RpgTalentDoNotNeedReset = 20100010, + RpgHadReset = 20100011, + RpgTalentIsNotForThisCharacter = 20100012, + RpgCanNotFindTalentLayer = 20100013, + RpgPreTalentLayerDoNotActivated = 20100014, + RpgCanNotFindDailyReward = 20100015, + RpgHadGetDailyReward = 20100016, + BackgroundChoseSameScene = 20101001, + BackgroundIsLock = 20101002, + DragPuzzleActivityInvalidId = 20102001, + DragPuzzleActivityInvalidPuzzleId = 20102002, + DragPuzzleActivityInvalidPieceId = 20102003, + DragPuzzleActivityNoPieceCanBeExchanged = 20102004, + DragPuzzleActivityInvalidTargetIdx = 20102005, + DragPuzzleActivityPieceIdxIsCorrect = 20102006, + DragPuzzleActivityPieceIdxEqualsTargetIdx = 20102007, + DragPuzzleActivityCantSwapOnBoardPiece = 20102008, + DragPuzzleActivityInvalidRewardIdx = 20102009, + DragPuzzleActivityInvalidRewardIdxIsGot = 20102010, + DragPuzzleActivityCorrectPieceNotEnoughForReward = 20102011, + DragPuzzleActivityExchangePieceRandIdExisted = 20102012, + DragPuzzleActivityPasswordAlreadyCorrect = 20102013, + DragPuzzleActivityPuzzleStatusError = 20102014, + DragPuzzleActivityPuzzlePasswordFormatError = 20102015, + DragPuzzleActivityPuzzlePasswordOutRange = 20102016, + MaintainerActionWrongCard = 20103001, + MaintainerActionCardPoolError = 20103002, + MaintainerActionBoxFinish = 20103003, + MaintainerActionNodeEventValueError = 20103004, + MaintainerActionDailyActionPointLimit = 20103005, + MaintainerActionCurrentNodeException = 20103006, + MaintainerActionNodeTypeIsNotFight = 20103007, + MaintainerActionStageIdError = 20103008, + MaintainerActionFightFinish = 20103009, + MaintainerActionNodeNotTriggered = 20103010, + MaintainerActionNodeIsTriggered = 20103011, + MaintainerActionNotOpen = 20103012, + MaintainerActionHadReset = 20103013, + MaintainerActionCanNotFindFightNode = 20103014, + MaintainerActionFightNodeException = 20103015, + MaintainerActionExplorationIsComplete = 20103016, + MaintainerActionWarehouseFinish = 20103017, + TrpgTargetLinkIdExit = 20104001, + TrpgFuncNotOpen = 20104002, + TrpgTimeNotOpen = 20104003, + TrpgTargetCfgNotExist = 20104004, + TrpgTargetIsFinished = 20104005, + TrpgPreTargetNotFinished = 20104006, + TrpgFuncCfgNotExist = 20104007, + TrpgFuncIdNotNeedSave = 20104008, + TrpgFuncIdNotInGroup = 20104009, + TrpgFuncGroupPreFuncNotFinish = 20104010, + TrpgFuncIsFinished = 20104011, + TrpgFuncStageNotFinish = 20104012, + TrpgFuncExamineNotFinish = 20104013, + TrpgCharacterNotOwner = 20104014, + TrpgCharacterCfgNotExist = 20104015, + TrpgTalentCfgNotExit = 20104016, + TrpgTalentAlreadyActivate = 20104017, + TrpgTalentPreIdNotActivate = 20104018, + TrpgTalentPointNoEnough = 20104019, + TrpgCharacterTalentsIsEmpty = 20104020, + TrpgMazeIdNotExist = 20104021, + TrpgMazeInstNotExist = 20104022, + TrpgLayerIdNotInCurrentMaze = 20104023, + TrpgLayerCfgNotExist = 20104024, + TrpgMapCfgNotExist = 20104025, + TrpgSelectLayerIdIsError = 20104026, + TrpgSelectNodeIdIsError = 20104027, + TrpgSelectPosNodeIdNotExist = 20104028, + TrpgSelectPosIndexNotExist = 20104029, + TrpgSelectCardCfgNotExist = 20104030, + TrpgSelectPosIndexIsCross = 20104031, + TrpgSelectCardCanNotGiveUp = 20104032, + TrpgLevelNotEnough = 20104033, + TrpgBlockCardCanNotSelect = 20104034, + TrpgItemCfgNotExist = 20104035, + TrpgUseItemCountError = 20104036, + TrpgUseItemCountNotEnough = 20104037, + TrpgItemCanNotUse = 20104038, + TrpgExamineIdError = 20104039, + TrpgExamineActionIdError = 20104040, + TrpgEnduranceNotEnough = 20104041, + TrpgExamineInstNotExist = 20104042, + TrpgExamineReachMaxRound = 20104043, + TrpgExamineCurRoundNotFinish = 20104044, + TrpgExamineIdIsError = 20104045, + TrpgExamineAttributeIdNotExist = 20104046, + TrpgExamineRoundError = 20104047, + TrpgExamineCharacterAlreadyExamine = 20104048, + TrpgExamineUseItemNotExist = 20104049, + TrpgExamineUseItemEffectError = 20104050, + TrpgExamineUseItemAttributeError = 20104051, + TrpgExamineCharacterNotHaveScore = 20104052, + TrpgShopIdIsError = 20104053, + TrpgShopItemIdIsError = 20104054, + TrpgShopItemCfgNotExist = 20104055, + TrpgShopItemBuyCountNotEnough = 20104056, + TrpgMemoirIdIsError = 20104057, + TrpgMemoirIdAlreadyUnlock = 20104058, + TrpgMemoirUnlockItemNotEnough = 20104059, + TrpgRewardIdIsError = 20104060, + TrpgRewardIdAlreadyGet = 20104061, + TrpgBossNotInOpenTime = 20104062, + TrpgBossPhasesRewardIdIsError = 20104063, + TrpgBossPhasesRewardIdAlreadyGet = 20104064, + TrpgBossPercentNotEnough = 20104065, + TrpgBossCfgNotExist = 20104066, + TrpgBossChallengeCountNotEnough = 20104067, + TrpgPageStatusNotChange = 20104068, + TrpgConditionNotPass = 20104069, + TrpgSecondMainStageNotExist = 20104070, + NieRActivityIsNotOpen = 20105001, + NieRRepeatedCharacter = 20105002, + NieRFightNpcIsNullOrEmpty = 20105003, + NieRCanNotFindCharacterConfig = 20105004, + NieRCanNotFindCharacterLevelConfig = 20105005, + NieRCanNotFindCharacter = 20105006, + NieRWrongFightCharacter = 20105007, + NieRCharacterDoNotHasFashion = 20105008, + NieRCharacterIsLocked = 20105009, + NieRWrongItemType = 20105010, + NieRFightResultIsNull = 20105011, + NieRCanNotFindChapterConfig = 20105012, + NieRChapterNotInTime = 20105013, + NieRCanNotFindRepeatableStageConfig = 20105014, + NieRCanNotFindRepeatableStageStarConfig = 20105015, + NieRCanNotFindExStageConfig = 20105016, + NieRCanNotFindBossData = 20105017, + NieRCanNotFindActivityConfig = 20105018, + NieRCanNotFindSupportConfig = 20105019, + NieRCanNotFindSupportSkillConfig = 20105020, + NieRCanNotFindSupportLevelConfig = 20105021, + NieRCanNotFindSupportSkillLevelConfig = 20105022, + NieRCanNotFindSkillData = 20105023, + NieRCanNotFindSupportData = 20105024, + NieRSupportSkillMaxLevel = 20105025, + NieRActivityIsEnd = 20105026, + NieRActivityIsReset = 20105027, + NieRCanNotFindEasterEggMessageConfig = 20105028, + NieREasterEggAgeWrong = 20105029, + NieRCanNotFindEasterEggLabelConfig = 20105030, + NieREasterEggNotOpen = 20105031, + NieREasterEggStageNotPass = 20105032, + NieREasterEggHadFinished = 20105033, + NieREasterEggWrongFightCharacter = 20105034, + MentorServiceUnavailable = 20106001, + MentorNotExit = 20106002, + StudentNotExit = 20106003, + StudentNotPublish = 20106004, + MentorStudentFull = 20106005, + MentorStudentApplyFull = 20106006, + MentorApplyCd = 20106007, + MentorAckApplyNotApply = 20106008, + MentorAckApplyReachCapacity = 20106009, + MentorAckApplyStudentLevelError = 20106010, + MentorApplyFriendFailedIsNotRepeatApply = 20106011, + MentorApplyListFull = 20106012, + MentorAcceptFriendFailedApplyIsNotExist = 20106013, + MentorStudentDataError = 20106014, + MentorCannotApplyIsNotMentor = 20106015, + MentorCannotApplyToMyself = 20106016, + MentorYourStudentFull = 20106017, + MentorIsYourStudentAlready = 20106018, + MentorOnlyStudentCanAgreeTeacher = 20106019, + MentorNotSendAnnouncement = 20106020, + MentorCannotSendAnnouncement = 20106021, + MentorNoAuthority = 20106022, + MentorManagerApplyFailedIsRefused = 20106023, + MentorManagerApplyFriendFailedIsDeleted = 20106024, + MentorManagerRecommendFriendFailedRecommendCoolDownTime = 20106025, + MentorDailyApplyCountTooMuch = 20106026, + MentorManagerSearchFriendFailedRecommendCoolDownTime = 20106027, + MentorAddMemberMongoDbError = 20106028, + MentorTickMemberMongoDbError = 20106029, + MentorCannotTickMyself = 20106030, + MentorCannotApplyMentorForTheMoment = 20106031, + MentorCannotApplyStudentForTheMoment = 20106032, + MentorMailContentFormatError = 20106033, + MentorAddMemberFullForStudent = 20106034, + MentorAddMemberFullForTeacher = 20106035, + MentorAnnouncementTooLong = 20106036, + MentorCannotGetTaskRewardAfterGraduate = 20106037, + MentorCannotGetGraduateRewardCondition = 20106038, + MentorCannotGraduateMyself = 20106039, + MentorMasterStageNotExit = 20106040, + MentorAlreadyGetStageReward = 20106041, + MentorMasterStageNotReachCondition = 20106042, + MentorMasterGetRewardAfterStudentGraduate = 20106043, + MentorGraduateTaskNotExit = 20106044, + MentorGraduateTaskNotAchieved = 20106045, + MentorCannotGetGraduateTaskRewardTwice = 20106046, + MentorManagerRefreshFriendFailedRecommendCoolDownTime = 20106047, + MentorOnlyTeacherCanRefreshGraduateTask = 20106048, + MentorStudentAlreadyGraduate = 20106049, + MentorTaskNotExist = 20106050, + MentorTaskAlreadyReceived = 20106051, + MentorTaskAlreadyCompleted = 20106052, + MentorChangeTaskCountTooMany = 20106053, + MentorGetTaskCountTooMany = 20106054, + MentorGetWeeklyTaskCountTooMany = 20106055, + MentorTaskNotInCache = 20106056, + MentorEquipTooMany = 20106057, + MentorEquipNotExist = 20106058, + MentorEquipLevelWrong = 20106059, + MentorEquipStarWrong = 20106060, + MentorTaskStatusWrong = 20106061, + MentorEquipIsLock = 20106062, + MentorEquipTypeWrong = 20106063, + MentorEquipNotInCache = 20106064, + MentorEquipFull = 20106065, + MentorEquipAlreadyPutOn = 20106066, + MentorEquipTooFew = 20106067, + MentorCannotAgreeStudentForTheMoment = 20106068, + MentorApplyAlreadyTimeout = 20106069, + MentorMasterTaskExpire = 20106070, + MentorMonthlyStudentCountTooMany = 20106071, + MentorMonthlyStudentCountTooManyForMentor = 20106072, + MentorMessageBoardIsNull = 20106073, + MentorMessageBoardInvalid = 20106074, + MentorMessageBoardTooLong = 20106075, + MentorGiftNotEnough = 20106076, + MentorCanNotSendToMyself = 20106077, + MentorAlreadySendGift = 20106078, + MentorTaskAlreadyChange = 20106079, + MentorSendMessageNotExit = 20106080, + MentorCannotApplyMentorByBlockList = 20106081, + MentorCannotApplyStudentByBlockList = 20106082, + TeachingActivityIsNotOpen = 20107001, + TeachingActivityIdNotFount = 20107002, + TeachingActivityHaveNotPassedRecord = 20107003, + TeachingActivityTreasureRewardNotFound = 20107004, + TeachingActivityRobotCanNotUse = 20107005, + TeachingActivityStageNoThisRobot = 20107006, + TeachingActivityCharCountNotMatch = 20107007, + TeachingActivityRobotIdsIsNull = 20107008, + GuardCampActivityIdError = 20108001, + GuardCampIdError = 20108002, + GuardCampNotInOpenTime = 20108003, + GuardCampNotInSupportTime = 20108004, + GuardCampIsInSupportTime = 20108005, + GuardCampCenterDataNotFound = 20108006, + GuardCampWinCampAlreadySet = 20108007, + GuardCampAlreadySelected = 20108008, + GuardCampNotSelectCamp = 20108009, + GuardCampSupportCountNotEnough = 20108010, + GuardCampIsOperating = 20108011, + GuardCampNotJoinActivity = 20108012, + GuardCampResultRewardIsGet = 20108013, + GuardCampResultIsNotSet = 20108014, + GuardCampResultRewardIsEmpty = 20108015, + GuardCampGlobalDataNotFound = 20108016, + PokemonIsNotOpen = 20109001, + PokemonMonsterInvalidMonsterId = 20109002, + PokemonMonsterDataNotExist = 20109003, + PokemonFirstMonsterIsGot = 20109011, + PokemonFirstMonsterNotConfig = 20109012, + PokemonMonsterLevelConfigNotExist = 20109021, + PokemonMonsterMaxLevel = 20109022, + PokemonMonsterStarConfigNotExist = 20109023, + PokemonMonsterLevelNotEnoughForStarUp = 20109024, + PokemonMonsterMaxStar = 20109025, + PokemonMonsterInvalidSkillId = 20109031, + PokemonMonsterStarNotEnoughForSkill = 20109032, + PokemonFormationMonsterRepeated = 20109041, + PokemonFormationMonsterNotExist = 20109042, + PokemonFormationPositionLocked = 20109043, + PokemonFormationOutOfEnergy = 20109044, + PokemonMonsterTeamBossCountError = 20109045, + PokemonStageInvalidId = 20109051, + PokemonPokeChapterIsNotOpen = 20109052, + PokemonStageFailedToRandom = 20109053, + PokemonStageTimesNotEnough = 20109054, + PokemonStageActivityIdDoNotMatch = 20109055, + PokemonStageSkipRepeated = 20109056, + PokemonStageSkipTimesNotEnough = 20109057, + PokemonTimeSupplyTimeNotEnough = 20109061, + ComposeGameBagCapacityIsFull = 20110001, + ComposeGameRewardAlreadyGet = 20110002, + ComposeGameRewardScheduleNotEnough = 20110003, + ComposeGameCanNotFoundReward = 20110004, + ComposeGameCanNotFoundShopId = 20110005, + ComposeGameActivityIsNotOpen = 20110006, + ComposeGameActivityIsNotFound = 20110007, + ComposeGameShopIdAlreadySell = 20110008, + ComposeGameGoodNotFound = 20110009, + ComposeGameRefreshCountNotEnough = 20110010, + ComposeGameCanNotFoundCanRefreshGoods = 20110011, + ComposeGameFubenScheduleNotEnough = 20110012, + LottoNotOpen = 20111001, + LottoTemplateNotFound = 20111002, + LottoAlreadyGetMaxLimitTimes = 20111003, + LottoBuyTicketTemplateNotFound = 20111004, + LottoBuyTicketCanNotFindCostItemId = 20111005, + LottoBuyTicketCanNotFindCostItemCount = 20111006, + LottoBuyTicketRuleCountError = 20111007, + CoupletIndexError = 20112001, + DoubleClickCoupletIndexError = 20112002, + CoupletConfigError = 20112003, + CoupletSortError = 20112004, + StrongholdNotOpen = 20113001, + StrongholdActivityIdNotMatch = 20113002, + StrongholdAssistDataIsLoading = 20113003, + StrongholdSetAssistCharacterIsSame = 20113004, + StrongholdSetAssistCharacterIsInCd = 20113005, + StrongholdSetAssistCharacterFail = 20113006, + StrongholdFightNotBegin = 20113007, + StrongholdFightIsEnd = 20113008, + StrongholdNotMineralLeft = 20113009, + StrongholdNotHaveMineOutPutDetail = 20113010, + StrongholdResetGroupInfoNotExist = 20113011, + StrongholdElectricTeamMemberCountError = 20113012, + StrongholdPreTeamCountError = 20113013, + StrongholdPreTeamCharacterRepeat = 20113014, + StrongholdPluginIdNotExist = 20113015, + StrongholdElectricEnergyNotEnough = 20113016, + StrongholdCharacterIdIsInElectricTeam = 20113017, + StrongholdGroupIdNotExist = 20113018, + StrongholdGroupNotOpen = 20113019, + StrongholdEnduranceNotEnough = 20113020, + StrongholdGroupStageDataNotFound = 20113021, + StrongholdFightTeamCountError = 20113022, + StrongholdTeamSetCharacterError = 20113023, + StrongholdFinishedStageCanNotChangeTeam = 20113024, + StrongholdFightTeamCharacterRepeat = 20113025, + StrongholdCurFightTeamDataNotExist = 20113026, + StrongholdRobotIdIsNotExist = 20113027, + StrongholdRobotCharacterIdNotMatch = 20113028, + StrongholdRobotIsNotValid = 20113029, + StrongholdFightGroupIdError = 20113030, + StrongholdStageNotInCurActivity = 20113031, + StrongholdStageIsFinished = 20113032, + StrongholdPreStageNotFinish = 20113033, + StrongholdStageTeamNotExist = 20113034, + StrongholdPreFightDataTeamError = 20113035, + StrongholdBorrowDataNotExist = 20113036, + StrongholdBorrowCharacterIdError = 20113037, + StrongholdBorrowCharacterCountOverflow = 20113038, + StrongholdBorrowCountReachMax = 20113039, + StrongholdRewardIdIsError = 20113040, + StrongholdRewardIdIsOffline = 20113041, + StrongholdRewardIdIsAlreadyGet = 20113042, + StrongholdMinerCountNotEnough = 20113043, + StrongholdMineralNotEnough = 20113044, + StrongholdFinishGroupNotEnough = 20113045, + StrongholdGroupNotFinish = 20113046, + StrongholdGroupIsFinish = 20113047, + StrongholdPredictMineralCountNotEnough = 20113048, + StrongholdFightTeamNotFull = 20113049, + StrongholdFightTeamNotReachAbility = 20113050, + StrongholdHaveGroupNotFinished = 20113051, + StrongholdPreSetTeamCanNotAssistCharacter = 20113052, + StrongholdPreSetTeamCanNotRobot = 20113053, + StrongholdNotSelectLevelId = 20113054, + StrongholdAlreadySelectLevelId = 20113055, + StrongholdLevelIdCfgNotExit = 20113056, + StrongholdLevelIdNotMatch = 20113057, + StrongholdRewardLevelIdNotMatch = 20113058, + StrongholdCurDayCanNotStay = 20113059, + StrongholdCurDayIsStay = 20113060, + StrongholdGroupChapterError = 20113061, + StrongholdTeamSetRuneRepeat = 20113062, + StrongholdRuneCfgNotExist = 20113063, + StrongholdSetSubRuneError = 20113064, + StrongholdSetRuneIdIsNotOpen = 20113065, + StrongholdGroupStageNotFinish = 20113066, + PartnerTemplateNotFound = 20114001, + PartnerCapacityNotEnough = 20114002, + PartnerGetPartnerNotFound = 20114003, + PartnerChangeNameIsTooLong = 20114004, + PartnerChangeNameIsNotChange = 20114005, + PartnerChangeNameIsNull = 20114006, + PartnerChangeNameIsInvalid = 20114007, + PartnerNewPartnerFail = 20114008, + PartnerCanNotCarryByThisCharacterType = 20114009, + PartnerIsLocked = 20114010, + PartnerIsUnLock = 20114011, + PartnerLevelUpUseMaterialsIsEmpty = 20114012, + PartnerLevelUpIsMaxLevel = 20114013, + PartnerGetLevelUpTemplateNotFound = 20114014, + PartnerLevelUpLevelLimit = 20114015, + PartnerBreakThroughLevelNotEnough = 20114016, + PartnerBreakThroughIsMaxLevel = 20114017, + PartnerCostPartnerStatusIsLock = 20114018, + PartnerCostPartnerIsCarryByCharacter = 20114019, + PartnerCostPartnerIsDifferActivate = 20114020, + PartnerStarScheduleIsFull = 20114021, + PartnerStarScheduleIsNotFull = 20114022, + PartnerQualityIsMax = 20114023, + PartnerTemplateSkillNotFound = 20114024, + PartnerAllSkillAlreadyFullLevel = 20114025, + PartnerSkillIdIsNotActivate = 20114026, + PartnerSkillChangeTypeNotTheSame = 20114027, + PartnerMainSkillPosCanNotBeTakeOff = 20114028, + PartnerMainSkillPosCanNotBeWear = 20114029, + PartnerSkillPosHaveNotUnlock = 20114030, + PartnerSkillSwitchNotSameGroup = 20114031, + PartnerSkillSwitchElementNotFound = 20114032, + PartnerSkillPosNotChange = 20114033, + PartnerComposeChipNotEnough = 20114034, + PartnerHasNotBeCarry = 20114035, + PartnerBreakThroughTemplateNotFound = 20114036, + PartnerQualityTemplateNotFound = 20114037, + PartnerSkillEffectTemplateNotFound = 20114038, + PartnerStoryTemplateNotFound = 20114039, + PartnerCarryRepeat = 20114040, + PartnerCostPartnerIsCanNotBeSelf = 20114041, + PartnerSkillUpTimesMoreThanCanUpTimes = 20114042, + SimulatedCombatActivityNotOpen = 20115001, + SimulatedCombatActivityEnd = 20115002, + SimulatedCombatCanNotFindStarRewardConfig = 20115003, + SimulatedCombatTotalStarNotEnough = 20115004, + SimulatedCombatStarRewardHadGot = 20115005, + SimulatedCombatCanNotFindPointRewardConfig = 20115006, + SimulatedCombatTotalPointNotEnough = 20115007, + SimulatedCombatPointRewardHadGot = 20115008, + SimulatedCombatCanNotFindFunctionStageConfig = 20115009, + SimulatedCombatCanNotFindStageChallengeConfig = 20115010, + SimulatedCombatCanNotFindStageMemberConfig = 20115011, + SimulatedCombatMemberIsNullOrEmpty = 20115012, + SimulatedCombatMaxMemberLimit = 20115013, + SimulatedCombatNormalTypeMinMemberLimit = 20115014, + SimulatedCombatCanNotFindStageAdditionConfig = 20115015, + SimulatedCombatWrongConsumeType = 20115016, + SimulatedCombatCanNotFindMemberConfig = 20115017, + SimulatedCombatCanNotFindAdditionConfig = 20115018, + SimulatedCombatPreFightCacheDoNotExist = 20115019, + SimulatedCombatStarCacheDoNotExist = 20115020, + SimulatedCombatStageStarRewardDoNotExist = 20115021, + SimulatedCombatStageStarRewardDailyLimit = 20115022, + SimulatedCombatFightNpcIsNullOrEmpty = 20115023, + SimulatedCombatRepeatedCharacter = 20115024, + SimulatedCombatMemberConfigDoNotExist = 20115025, + SimulatedCombatRobotNotInMembers = 20115026, + SimulatedCombatChallengeModeWrongConsume = 20115027, + SimulatedCombatChallengeStageIsNotTheSameAsBuy = 20115028, + SimulatedCombatWrongChallengeIdCount = 20115029, + SimulatedCombatWrongMemberIdCount = 20115030, + SimulatedCombatWrongAdditionIdCount = 20115031, + CollectWordsCanNotGiveToSelf = 20116001, + CollectWordsCanNotFoundWord = 20116002, + CollectWordsNotRequestWord = 20116003, + CollectWordsCanNotRequestWord = 20116004, + CollectWordsCanNotGiveWord = 20116005, + CollectWordsActivityNotOpen = 20116006, + CollectWordsRequestWordTooFast = 20116007, + CollectWordsWordNotEnough = 20116008, + CollectWordsCantGiveToStranger = 20116009, + CollectWordsGiftBoxIsEmpty = 20116010, + CollectWordsGiftBoxIsFull = 20116011, + CollectWordsIsNotFriend = 20116012, + CollectWordsTodayCanNotRecv = 20116013, + CollectWordsOthersRequestListFulled = 20116014, + CollectWordsPlayerNotInGuild = 20116015, + CollectWordsNoRewardCanGet = 20116016, + CollectWordsNoGetRewardTimes = 20116017, + CollectWordsRequestNotExist = 20116018, + CollectWordsGiveWordToQuick = 20116019, + SmashEggsActivityNotOpen = 20116020, + SmashEggsEggIsBroken = 20116021, + SmashEggsGetActivityInfoFail = 20116022, + SmashEggsBuffItemNotEnough = 20116023, + SmashEggsBuffItemCanOnlyUseOneType = 20116024, + SmashEggsTodayRewardIsGot = 20116025, + SmashEggsThisStageNoReward = 20116026, + SmashEggsScoreNotEnough = 20116027, + SmashEggsCurrentScoreIsZero = 20116028, + SmashEggsCurrentScoreIsMax = 20116029, + WhiteValentinesDayActivityNotOpen = 20117001, + WhiteValentinesDayActivityCoinNotEnough = 20117002, + WhiteValentinesDayActivityInviteCountNotEnough = 20117003, + WhiteValentinesDayActivityRoleCfgNotExit = 20117004, + WhiteValentinesDayActivityLocationNotOpen = 20117005, + WhiteValentinesDayActivityLocationCfgLose = 20117006, + WhiteValentinesDayActivityEventCfgLose = 20117007, + WhiteValentinesDayActivityEventRankCfgLose = 20117008, + WhiteValentinesDayActivityEventOnWorking = 20117009, + WhiteValentinesDayActivityEnergyNotEnough = 20117010, + WhiteValentinesDayActivityRoleNotActive = 20117011, + WhiteValentinesDayActivityRoleOnEvent = 20117012, + WhiteValentinesDayActivityEventAlreadyFinish = 20117013, + WhiteValentinesDayActivityEventNoteDispatch = 20117014, + WhiteValentinesDayActivityRandomEventCfgLose = 20117015, + WhiteValentinesDayActivityAttrTypeNotMatch = 20117016, + WhiteValentinesDayActivityCfgLose = 20117017, + WhiteValentinesDayActivityRoleAlredyActive = 20117018, + MoeWarNotInVotingPeriod = 20118001, + MoeWarInnerError = 20118002, + MoeWarPlayerNotFound = 20118003, + MoeWarActivityNotOpen = 20118004, + MoeWarServiceUnavailable = 20118005, + MoeWarVoteDailyLimit = 20118006, + MoeWarVoteCountWrong = 20118007, + MoeWarVoteItemWrong = 20118008, + MoeWarVoteTotalDailyLimit = 20118009, + MoeWarPreparationNotOpen = 20119001, + MoeWarPreparationHadReset = 20119002, + MoeWarPreparationCanNotFindActivityTemplate = 20119003, + MoeWarPreparationCanNotFindMatchTemplate = 20119004, + MoeWarPreparationCanNotFindStageTemplate = 20119005, + MoeWarPreparationCanNotFindActivityGearId = 20119006, + MoeWarPreparationCanNotFindGearTemplate = 20119007, + MoeWarPreparationCanNotFindHelperTemplate = 20119008, + MoeWarPreparationCanNotFindMatchHelperTemplate = 20119009, + MoeWarPreparationCanNotFindQuestionTemplate = 20119010, + MoeWarPreparationCanNotFindAssistanceTemplate = 20119011, + MoeWarPreparationGearRewardHadGot = 20119012, + MoeWarPreparationGearRewardNotEnough = 20119013, + MoeWarPreparationHelperIsNotCommunicating = 20119014, + MoeWarPreparationHelperCommunicationEnd = 20119015, + MoeWarPreparationAssistanceCountNotEnough = 20119016, + MoeWarPreparationStageDataNotFind = 20119017, + MoeWarPreparationCanOnlyOneRoleFight = 20119018, + MoeWarPreparationCanOnlySelectHelperCharacter = 20119019, + MoeWarPreparationRecruitHelperFinish = 20119020, + MoeWarPreparationNoWrongAnswer = 20119021, + MoeWarPreparationCanNotSelectExcludeWrongAnswer = 20119022, + NameplateTemplateNotFound = 20120001, + NameplateNotAvailable = 20120002, + FingerGuessingGameActivityNotOpen = 20121001, + FingerGuessingGameStageNotUnlock = 20121002, + FingerGuessingGameStageIsChallenging = 20121003, + FingerGuessingGameStageNoChallenging = 20121004, + FingerGuessingGameRoundIsEnd = 20121005, + FingerGuessingGameNoRobotTrick = 20121006, + FingerGuessingGameCheatingCanNotClose = 20121007, + FingerGuessingGameTricksNotExist = 20121008, + FingerGuessingGameStageNotExist = 20121009, + FingerGuessingGameActivityInFoError = 20121010, + FingerGuessingGameCheatingStatusNotChange = 20121011, + PurchasePackageConvertPriceAll = 20122001, + FubenReformNotInTime = 20123001, + FubenReformStageNotActive = 20123002, + FubenReformStageCfgLose = 20123003, + FubenReformStageNotInTime = 20123004, + FubenReformStageDifficultyCfgLose = 20123005, + FubenReformStageCurDifficultyDbLose = 20123006, + FubenReformDifficultyCfgLose = 20123007, + FubenReformDifficultyNotActive = 20123008, + FubenReformEnemyOverMax = 20123009, + FubenReformEnemyGroupCfgLose = 20123010, + FubenReformEnemySourceCfgNotExist = 20123011, + FubenReformEnemyDifficultyNotExist = 20123012, + FubenReformEnemySourceRepeat = 20123013, + FubenReformEnemySourceCfgLose = 20123014, + FubenReformEnemyTargetCfgLose = 20123015, + FubenReformEnvCfgLose = 20123016, + FubenReformEnvGroupCfgLose = 20123017, + FubenReformEnvCfgNotExist = 20123018, + FubenReformBuffOverMax = 20123019, + FubenReformBuffNotExist = 20123020, + FubenReformBuffCfgLose = 20123021, + FubenReformBuffGroupCfgLose = 20123022, + FubenReformBuffDifficultyNotExist = 20123023, + FubenReformScoreNotEnougth = 20123024, + FubenReformBuffRepeat = 20123025, + FubenReformMemberSizeIsZero = 20123026, + FubenReformMemberSizeOverMax = 20123027, + FubenReformMemberGroupCfgLose = 20123028, + FubenReformMemberSourceRepeat = 20123029, + FubenReformMemberSourceCfgNotExist = 20123030, + FubenReformMemberSourceCfgLose = 20123031, + FubenReformMemberTargetCfgLose = 20123032, + FubenReformMemberTargetCfgNotExist = 20123033, + FubenReformMemberDifficultyNotExist = 20123034, + FubenReformUseRobotRepeat = 20123035, + FubenReformUseCustomCharacter = 20123036, + FubenReformEnvOverMax = 20123037, + ChristmasTreeActivityNotOpen = 20124001, + ChristmasTreeRecvDataError = 20124002, + ChristmasTreePartNotExist = 20124003, + ChristmasTreeOrnamentsNotActived = 20124004, + ChristmasTreeOrnamentsOnUsed = 20124005, + ChristmasTreeOrnamentsTabLoseConfig = 20124006, + ChristmasTreeOrnamentsWearPartError = 20124007, + ChristmasTreeOrnamentsActived = 20124008, + ChristmasTreeOrnamentsActiveNotFound = 20124009, + ChessPursuitMapNotEnterYet = 20125001, + ChessPursuitMapNoNeedToBattle = 20125002, + ChessPursuitMapCfgNotExist = 20125003, + ChessPursuitGroupCfgNotExist = 20125004, + ChessPursuitMapNotOpen = 20125005, + ChessPursuitMapBossCfgLose = 20125006, + ChessPursuitMapAlreadySetTeam = 20125007, + ChessPursuitMapMustSetTeam = 20125008, + ChessPursuitMapSetTeamOutOfRange = 20125009, + ZhuiMapCurGirdCouldNotSetTeam = 20125010, + ZhuiMapCurGirdRepeatSetTeam = 20125011, + ChessPursuitMapNeedBattleBoss = 20125012, + ChessPursuitSetCardRepeat = 20125013, + ChessPursuitSetCardPosOutOfRange = 20125014, + ChessPursuitSetCardNotByYet = 20125015, + ChessPursuitGridAlreadyHaveTream = 20125016, + ChessPursuitNeedSetGridTeamFirst = 20125017, + ChessPursuitBuyCardListIsNull = 20125018, + ChessPursuitBuyCardNotExist = 20125019, + ChessPursuitBuyCardRepeat = 20125020, + ChessPursuitCurMapIsNull = 20125021, + ChessPursuitCoinNotEnough = 20125022, + ChessPursuitBuyCardOverMax = 20125023, + ChessPursuitBossStepNotFinish = 20125024, + ChessPursuitCardEffectCfgNotInit = 20125025, + ChessPursuitCardCfgLose = 20125026, + ChessPursuitCardEffectCfgLose = 20125027, + ChessPursuitCardEffectBossActionIsNull = 20125028, + ChessPursuitMapInitFuncNotExist = 20125029, + ChessPursuitMapInitFuncNotInit = 20125030, + ChessPursuitInitFuncTypeCfgLose = 20125031, + ChessPursuitInitFuncParamCountLess = 20125032, + ChessPursuitReusedRoleOnSetTeam = 20125033, + ChessPursuitReusedRobotOnSetTeam = 20125034, + ChessPursuitCaptainPosErrorOnSetTeam = 20125035, + ChessPursuitFirstFightPosErrorOnSetTeam = 20125036, + ChessPursuitCountIsNullOnSetTeam = 20125037, + ChessPursuitCountOverMaxlOnSetTeam = 20125038, + ChessPursuitGridCantAutoFight = 20125039, + ChessPursuitGridCantAutoFightCaseNoTeamData = 20125040, + ChessPursuitGridTeamLose = 20125041, + ChessPursuitGridCantAutoFightCaseNotFightOnce = 20125042, + ChessPursuitSaoDangSomeGridNotFightYet = 20125043, + ChessPursuitBossDeath = 20125044, + ConditionManagerChessPursuitMapNotFinish = 20125045, + ChessPursuitCardUseTargetError = 20125046, + ChessPursuitDBMapNotExist = 20125047, + ChessPursuitDBMapRankError = 20125048, + ChessPursuitDBMapAlreadyTakeReward = 20125049, + ChessPursuitDBMapNotRewardTime = 20125050, + ChessPursuitDBMapNotPlayingTime = 20125051, + ChessPursuitGroupCfgLose = 20125052, + ChessPursuitGroupRewardCfgLose = 20125053, + ChessPursuitGroupRankNotOpen = 20125054, + ChessPursuitGroupRankLose = 20125055, + ChessPursuitLoseRank = 20125056, + ChessPursuitTestRoleCfgLose = 20125057, + ChessPursuitTestRoleNotExist = 20125058, + ChessPursuitRankPlayerNotExit = 20125059, + ChessPursuitMapCantAutoClear = 20125060, + InvertCardGameNotOpen = 20126001, + InvertCardGameActivityIdError = 20126002, + InvertCardGameCurStageStatusError = 20126003, + InvertCardGameCurStageIdDbNull = 20126004, + InvertCardGameCurStageIdCfgNull = 20126005, + InvertCardGameCoinCfgNull = 20126006, + InvertCardGameCardIndexOutRange = 20126007, + InvertCardGameCardIndexFinish = 20126008, + InvertCardGameCardIndexAlreadyInvert = 20126009, + InvertCardGameStageNotInDictonary = 20126010, + InvertCardGameCardNotInDictonary = 20126011, + InvertCardGameCardNotInRewardDict = 20126012, + InvertCardGameCardArrayShortDict = 20126013, + InvertCardGameCardRewardNull = 20126014, + InvertCardGameCardInvertListNull = 20126015, + HackActivityNotOpen = 20127001, + HackChapterIdError = 20127002, + HackStageCfgNotExist = 20127003, + HackPreStageNotFinish = 20127004, + HackPreStageStarNotEnough = 20127005, + HackRewardIdNotInCurChapter = 20127006, + HackRewardIdNotExist = 20127007, + HackRewardAlreadyGet = 20127008, + HackStageTotalStarNotEnough = 20127009, + HackSetBuffIndexError = 20127010, + HackSetBuffIdIsNotUnlock = 20127011, + HackSetBuffIdIsRepeated = 20127012, + HackFightCharacterRepeated = 20127013, + HackFightRobotError = 20127014, + HackDailyTicketAlreadyGet = 20127015, + HackNoDailyTicketGet = 20127016, + HackLevelCfgNotExist = 20127017, + HackBuffPosNotUnlock = 20127018, + PokerGuessingNotOpen = 20128001, + PokerGuessingPlayerStatusError = 20128002, + PokerGuessingGuessError = 20128003, + PokerGuessingLibraryEmpty = 20128004, + PokerGuessingCardCfgError = 20128005, + PartnerTeachingChapterIsNotFound = 20129001, + ScratchTicketActivityNotStart = 20130001, + ScratchTicketActivityAlreadyEnd = 20130002, + ScratchTicketActivityCfgLose = 20130003, + ScratchTicketGridCfgLose = 20130004, + ScratchTicketActivityOpenGridRepeatOpen = 20130005, + ScratchTicketActivityOpenGridOverMaxCount = 20130006, + ScratchTicketActivityCanNotReset = 20130007, + ScratchTicketActivityEnd = 20130008, + ScratchTicketCfgLose = 20130009, + ScratchTicketStarted = 20130010, + ScratchTicketNotFinish = 20130011, + ScratchTicketNotWin = 20130012, + ScratchTicketActivityNotOpen = 20130013, + ScratchTicketActivityFinish = 20130014, + ScratchTicketActivityOpenGridOutOfRange = 20130015, + KillZoneStarRewardStarNotEnough = 20131001, + KillZonePluginAlreadyActivity = 20131002, + KillZonePluginLevelCfgNotExist = 20131003, + KillZonePluginOnMaxLevel = 20131004, + KillZonePluginCfgNotExist = 20131005, + KillZonePluginNotActive = 20131006, + KillZonePluginNotUpgrade = 20131007, + KillZonePluginSlotCfgNotExist = 20131008, + KillZoneStarRewardChapterCfgLose = 20131009, + KillZoneStarRewardCfgLose = 20131010, + KillZoneStarRewardAlreadyTakeIt = 20131011, + TakeFarmRewardOnMaxCount = 20131012, + KillZoneStageCfgOnExist = 20131013, + KillZoneStageOnLock = 20131014, + KillZoneStageNotFarmYet = 20131015, + KillZoneStageNotRelateChapter = 20131016, + KillZoneRobotRepeatUse = 20131017, + KillZoneRobotIdNotInConfig = 20131018, + KillZoneStageNotInTime = 20131019, + KillZonePreStageNotFinish = 20131020, + KillZoneChapterPreStageIsLock = 20131021, + KillZoneChapterNotInTime = 20131022, + KillZoneActivityNotInTime = 20131023, + KillZoneTaleDailyStarRewardRepeat = 20131024, + KillZoneTaleDailyStarRewardCfgNotExist = 20131025, + KillZoneTaleDailyStarRewardStarNotEnough = 20131026, + KillZonePluginAlreadyUse = 20131027, + RpgMakerGameMapIdWrong = 20132001, + RpgMakerGameMapNotInit = 20132002, + RpgMakerGameMapAlreadyPass = 20132003, + RpgMakerGameMapPlayerAlreadyDead = 20132004, + RpgMakerGameMapCannotBackUp = 20132005, + RpgMakerGameMapRoundFinish = 20132006, + RpgMakerGameMapOperateTooOften = 20132007, + RpgMakerGameStageCfgNotExist = 20132008, + RpgMakerGameChapterNotExist = 20132009, + RpgMakerGameChapterNotInOpenTime = 20132010, + RpgMakerGameSelectRoleNotExist = 20132011, + RpgMakerGameSelectRoleIsLock = 20132012, + RpgMakerGamePreStageNotFinish = 20132013, + RpgMakerGameMapConfigError = 20132014, + RpgMakerGameMapInnerError = 20132015, + RpgMakerGameMapNotOpen = 20132016, + SuperTowerActivityNotOpen = 20133001, + SuperTowerMapCfgNotExist = 20133002, + SuperTowerMapNotOpen = 20133003, + SuperTowerOtherTierIsProceed = 20133004, + SupperTowerStageSubTypeNotDefine = 20133005, + SuperTowerStageNotHaveTiers = 20133006, + SuperTowerCurTierNotMatchStage = 20133007, + SuperTowerMapTierInfoNotExist = 20133008, + SuperTowerFightCharacterNotInMapTierTeam = 20133009, + SuperTowerBagIsFull = 20133010, + SuperTowerMapTierNotHaveProgress = 20133011, + SuperTowerPluginResolveNumNotEnough = 20133012, + SuperTowerTargetCfgNotExist = 20133013, + SuperTowerTargetStageNotOpen = 20133014, + SuperTowerPreTargetProgressNotReach = 20133015, + SuperTowerFightCharacterIdRepeat = 20133016, + SuperTowerPluginCfgNotExist = 20133017, + SuperTowerPluginCountError = 20133018, + SuperTowerPluginNotEnough = 20133019, + SuperTowerTeamPluginReachMax = 20133020, + SuperTowerFightTeamCountError = 20133021, + SuperTowerFightTeamCharacterCountError = 20133022, + SuperTowerNotSetFightTeam = 20133023, + SuperTowerStageNotMatchFightTeam = 20133024, + SuperTowerTargetPreStageNotFinish = 20133025, + SuperTowerTargetStageNotRepeatChallenge = 20133026, + SuperTowerTargetStageIndexError = 20133027, + SuperTowerRobotInvalid = 20133028, + SuperTowerRobotIsNotOpened = 20133029, + SuperTowerFightCharacterNotInSetTeam = 20133030, + SuperTowerFightPosNotMatchSetTeam = 20133031, + SuperTowerStageTeamNotFound = 20133032, + SuperTowerTargetStageTypeError = 20133033, + SuperTowerTargetResultNotProgress = 20133034, + SuperTowerTargetProgressRewardIsGet = 20133035, + StCharacterNotExist = 20133036, + StCharacterAlreadyMountPlugin = 20133037, + StCharacterCfgNotExist = 20133038, + StrongholdPluginNotExist = 20133039, + StMallRefreshCountIsZero = 20133040, + SuperTowerMallPluginNotExist = 20133041, + SuperTowerBagAddPluginFailed = 20133042, + StCharacterLevelCfgNotExist = 20133043, + SuperTowerBagCapacityNotEnough = 20133044, + SuperTowerPluginIdNotExistOnBuyList = 20133045, + SuperTowerBuyPluginRepeat = 20133046, + SuperTowerCharacterIsAllDie = 20133047, + SuperTowerCaptainPosIsError = 20133048, + SuperTowerFirstFightPosIsError = 20133049, + SuperTowerTierStageFightCharacterError = 20133050, + MineSweepingActivityNotOpen = 20134001, + MineSweepingCanNotFindChapterConfig = 20134002, + MineSweepingCanNotFindChapterData = 20134003, + MineSweepingStageNotStart = 20134004, + MineSweepingCanNotFindStageConfig = 20134005, + MineSweepingCanNotFindStageData = 20134006, + MineSweepingStageIndexYOutRange = 20134007, + MineSweepingStageIndexXOutRange = 20134008, + MineSweepingStageFlagError = 20134009, + MineSweepingStageHadStarted = 20134010, + MineSweepingPreChapterIsNotFinish = 20134011, + MineSweepingPreStageIsNotFinish = 20134012, + MineSweepingStageIsNotInThisChapter = 20134013, + MineSweepingGridIsSwept = 20134014, + FashionStoryChapterIsNotFound = 20135001, + FashionStoryChapterIsNotOpen = 20135002, + FashionStoryStageIsNotCfg = 20135003, + FashionStoryStageIsNotOpen = 20135004, + CoupleCombatNotOpen = 20136001, + CoupleCombatCanNotFindActivityTemplate = 20136002, + CoupleCombatCanNotFindStageData = 20136003, + CoupleCombatCanNotFindChapterTemplate = 20136004, + CoupleCombatCanNotFindStageTemplate = 20136005, + CoupleCombatFightMemberDoNotExist = 20136006, + CoupleCombatFightMemberCountLimit = 20136007, + CoupleCombatStageOpenDayLimit = 20136008, + CoupleCombatRobotHadBeenUsed = 20136009, + PassportActivityNotOpen = 20137001, + PassportInfoNotExist = 20137002, + PassportNotUnlock = 20137003, + PassportAlreadyUnlocked = 20137004, + PassportInfoActivityIdNotMatch = 20137005, + PassportLevelNotEnough = 20137006, + PassportNoRewardCanGet = 20137007, + PassportAlreadyMaxLevel = 20137008, + PassportLevelCfgNotExist = 20137009, + PassportRewardTemplateNotExist = 20137010, + PassportBuyLevelCanNotSmallerThanNow = 20137011, + PassportExpConfigError = 20137012, + PassportRewardAlreadyGot = 20137013, + LimitedLoginQuizIsNull = 20138001, + LimitedLoginVerifyInvalidIndex = 20138002, + LimitedLoginVerifyQuizAnswered = 20138003, + LimitedLoginVerifyQuizId = 20138004, + SlotMachinesTemplateNotFound = 20140001, + SlotMachinesIconTemplateNotFound = 20140002, + SlotMachinesActivityTemplateCanNotFound = 20140003, + SlotMachinesTemplateIconNotFound = 20140004, + SlotMachinesActivityNotOpen = 20140005, + SlotMachinesActivityIsNotFound = 20140006, + SlotMachinesScoreAlreadyFull = 20140007, + SlotMachinesStartConfigNeedPerUnlock = 20140008, + SlotMachinesPerDataIsNull = 20140009, + SlotMachinesNeedAchievePerUnlockScore = 20140010, + SlotMachinesReceiveRewardNotExist = 20140011, + SlotMachinesScoreIsNotEnough = 20140012, + SlotMachinesRewardIsAlreadyReceive = 20140013, + SlotMachinesRockTypeNotFound = 20140014, + SlotMachinesCoinEnoughNotNeedBuy = 20140015, + SlotMachinesBuyNumNoMatchNeedNum = 20140016, + RoootActivityNotOpen = 20140101, + RoootActivityIsEnd = 20140102, + RoootDataError = 20140103, + PlayerNotExist = 30002001, + ServerNodeNotFound = 30002002, + RequestError = 30002003, + PayLoginTypeNonsupport = 40001001, + PayCheckSignUnMatch = 40001002, + PayDecodeSignException = 40001003, + PayGetOrderInfoError = 40001004, + PayCheckReceiptGameNoIsNullOrEmpty = 40001005, + PayCheckReceiptGameOrderIsNullOrEmpty = 40001006, + PayReceiptNotFound = 40001007, + PayCheckReceiptGoodsIdUnMatch = 40001008, + PayCheckReceiptAmountUnMatch = 40001009, + PayCheckReceiptChannelIdUnMatch = 40001010, + PayCheckReceiptChannelUidUnMatch = 40001011, + PayUpdateReceiptStatusFail = 40001012, + PayFirstPayRewardIsGet = 40001013, + PayTotalPayMoneyNotEnough = 40001014, + PayOrderAlreadyRefund = 40001015, + PayUseKeyPlatformError = 40001016, + AccumulatedPayIdIsError = 40001017, + AccumulatedPayIdIsNotExist = 40001018, + AccumulatedPayIdNotInOpenTime = 40001019, + AccumulatedPayRewardIdIsError = 40001020, + AccumulatedPayRewardIdIsNotExist = 40001021, + AccumulatePayRewardIdIsGot = 40001022, + AccumulatePayRewardMoneyNotEnough = 40001023, + PayUnsupportedTargetType = 40001024, + PayInvalidPlatformForPay = 40001025, + PayPlatformPayKeyNotMatch = 40001026, + PayModuleNotHandled = 40001027, + PayPlatformShield = 40001028, +} diff --git a/Resources/Scripts/XCommon/XCountDown.lua b/Resources/Scripts/XCommon/XCountDown.lua new file mode 100644 index 00000000..7e729a01 --- /dev/null +++ b/Resources/Scripts/XCommon/XCountDown.lua @@ -0,0 +1,123 @@ +XCountDown = XCountDown or {} + +XCountDown.GTimerName = { + UrgentEvent = "UrgentEvent", + FubenInfestorExplore = "FubenInfestorExplore", + FubenInfestorExploreDaily = "FubenInfestorExploreDaily", + Stronghold = "Stronghold", --超级据点活动倒计时 + KillZone = "KillZone", --杀戮无双活动倒计时 +} + +-- 倒计时存储容器 +-- bindCnt : 当前倒计时的总数 +-- record : 倒计时 +-- record[name] : 通过倒计时命名来记录 +-- record[name].remainTime : 剩余时间 +-- record[name].lastTime : 最后一次绑定时间 +-- record[name].bindCnt : 单个命名绑定的倒计时的个数 +-- record[name].nodeList : 记录当前名字存下的节点 +-- timeHandle : 处理事件 +local TimerRecord = { bindCnt = 0, record = {}, timeHandle = nil } + +local function UpdateTimerRecord() + local now = XTime.GetServerNowTimestamp() + for _, v in pairs(TimerRecord.record) do + if v.bindCnt > 0 and v.remainTime > 0 then + v.remainTime = v.remainTime - (now - v.lastTime) + v.lastTime = now + if v.remainTime < 0 then + v.remainTime = 0 + end + end + end +end + +function XCountDown.CreateTimer(name, remainTime, now) + if not TimerRecord.record[name] then + TimerRecord.record[name] = { + bindCnt = 0, + } + end + now = now or XTime.GetServerNowTimestamp() + TimerRecord.record[name].remainTime = remainTime + TimerRecord.record[name].lastTime = now +end + +function XCountDown.RemoveTimer(name) + local record = TimerRecord.record[name] + if record then + TimerRecord.bindCnt = TimerRecord.bindCnt - record.bindCnt + XBindTool.UnBindObj(record) + TimerRecord.record[name] = nil + if TimerRecord.bindCnt == 0 and TimerRecord.timeHandle then + XScheduleManager.UnSchedule(TimerRecord.timeHandle) + TimerRecord.timeHandle = nil + end + end +end + +function XCountDown.GetRemainTime(name) + local record = TimerRecord.record[name] + if record then + local now = XTime.GetServerNowTimestamp() + if record.bindCnt > 0 and record.remainTime > 0 then + record.remainTime = record.remainTime - (now - record.lastTime) + record.lastTime = now + if record.remainTime < 0 then + record.remainTime = 0 + end + end + return record.remainTime + else + return 0 + end +end + +function XCountDown.BindTimer(node, name, cb) + local record = TimerRecord.record[name] + if record then + if not record.nodeList then + record.nodeList = {} + end + table.insert(record.nodeList, node) + + if not TimerRecord.timeHandle then + TimerRecord.timeHandle = XScheduleManager.ScheduleForever(function() + UpdateTimerRecord() + end, XScheduleManager.SECOND, 0) + UpdateTimerRecord() + end + + TimerRecord.bindCnt = TimerRecord.bindCnt + 1 + record.bindCnt = record.bindCnt + 1 + XBindTool.BindNode(node, record, "remainTime", cb, function() + TimerRecord.bindCnt = TimerRecord.bindCnt - 1 + record.bindCnt = record.bindCnt - 1 + if TimerRecord.bindCnt == 0 then + XScheduleManager.UnSchedule(TimerRecord.timeHandle) + TimerRecord.timeHandle = nil + end + end) + end +end + +function XCountDown.UnBindTimer(curNode, name) + XBindTool.UnBindNode(curNode) + + local record = TimerRecord.record[name] + if not record or not record.nodeList then + return + end + + for i = 1, #record.nodeList do + if record.nodeList[i] == curNode then + TimerRecord.bindCnt = TimerRecord.bindCnt - 1 + record.bindCnt = record.bindCnt - 1 + if TimerRecord.bindCnt == 0 then + XScheduleManager.UnSchedule(TimerRecord.timeHandle) + TimerRecord.timeHandle = nil + end + table.remove(record.nodeList, i) + end + end +end \ No newline at end of file diff --git a/Resources/Scripts/XCommon/XDynamicList.lua b/Resources/Scripts/XCommon/XDynamicList.lua new file mode 100644 index 00000000..37bcb65f --- /dev/null +++ b/Resources/Scripts/XCommon/XDynamicList.lua @@ -0,0 +1,268 @@ +XDynamicList = XClass(nil, "XDynamicList") + +DLDelegateEvent = { + DYNAMIC_GRID_TOUCHED = 5, + DYNAMIC_GRID_ATINDEX = 6, + DYNAMIC_GRID_RECYCLE = 7, +} + +DLInsertDataDir = { + None = 0, + Head = 1, + Tail = 2, +} + +DLScrollDataDir = { + None = 0, + Head = 1, + Tail = 2 +} + +function XDynamicList:DebugLog(...) + if self.showLog then + XLog.Error(...) + end +end + +function XDynamicList:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.ItemCache = {} + + self.showLog = false + + self:ResetData() + self:InitView() +end + +function XDynamicList:ResetData()--重置数据 + self.Data = {} + self.curDataMaxIndex = 0--当前数据最大的索引 + self.dataHeadIndex = -1 --当前数据头索引 + self.dataTailIndex = -1--当前数据尾索引 + self.NodeListData = {} + + self.curShowHeadIndex = -1--当前展示的头索引 + self.curShowTailIndex = -1--当前展示的尾索引 +end + +function XDynamicList:InitView() + self.DynamicList = self.Transform:GetComponent("XVerticalDynamicList") + self.DynamicListBar = self.DynamicList.verticalScrollbar + if self.DynamicList == nil then + XLog.Error("Not Find XVerticalDynamicList Component!") + return + end + self.DynamicList:SetViewSize(self.Transform:GetComponent("RectTransform").rect.size) +end + +function XDynamicList:SetData(data, cb)--设置数据 + self:DebugLog("------数据初始化----", data) + self:ResetData() + self.CallBack = cb + self.DynamicList.tableViewGridDelegate = function(evt, index, dir) + return self:GenerateItem(evt, dir, index) + end + self:FormatData(data) +end + +function XDynamicList:FormatData(data)--格式化数据 + if data == nil then + XLog.Error("------FormatData is error!------> data is nil! please check!") + return + end + self.dataHeadIndex = 1 + self.dataTailIndex = #data + self.NodeListData = {} + for i = 1, self.dataTailIndex do + self.curDataMaxIndex = self.curDataMaxIndex + 1 + local temp = {} + temp.data = data[i] + temp.index = self.curDataMaxIndex + temp.Pre = (i == 1) and -1 or self.curDataMaxIndex - 1 + temp.Next = (i == #data) and -1 or self.curDataMaxIndex + 1 + self.NodeListData[self.curDataMaxIndex] = temp + end + self:DebugLog("------FormatData------", self.NodeListData) + self:ReloadData() +end + +function XDynamicList:ReloadData() + -- if #self.NodeListData <= 0 then + -- return + -- end + self.curShowTailIndex = -1 + self.curShowHeadIndex = -1 + self.DynamicList.TotalCount = #self.NodeListData + self.DynamicList:ReloadData(true) + self:DebugLog("------ReloadData------", self.NodeListData) +end + +function XDynamicList:InsertData(insertData, dir, isReload)--插入数据 + if #insertData == 0 then + XLog.Error("-----------insertData is null--------------") + return + end + local tempDataHeadIndex = self.dataHeadIndex + local tempDataTailIndex = self.dataTailIndex + for i = 1, #insertData do + self.curDataMaxIndex = self.curDataMaxIndex + 1 + local temp = {} + temp.data = insertData[i] + temp.index = self.curDataMaxIndex + if dir == DLInsertDataDir.Head then + temp.Pre = (i == 1) and -1 or self.curDataMaxIndex - 1 + if #self.NodeListData == 0 then + temp.Next = -1 + else + temp.Next = (i == #insertData) and self.dataHeadIndex or self.curDataMaxIndex + 1 + end + if i == 1 then + tempDataHeadIndex = self.curDataMaxIndex + end + if i == #insertData and #self.NodeListData > 0 then + self.NodeListData[self.dataHeadIndex].Pre = self.curDataMaxIndex + end + elseif dir == DLInsertDataDir.Tail then + if #self.NodeListData == 0 then + temp.Pre = -1 + else + temp.Pre = (i == 1) and self.dataTailIndex or self.curDataMaxIndex - 1 + end + temp.Next = (i == #insertData) and -1 or self.curDataMaxIndex + 1 + if i == 1 and #self.NodeListData > 0 then + self.NodeListData[self.dataTailIndex].Next = self.curDataMaxIndex + end + if i == #insertData then + tempDataTailIndex = self.curDataMaxIndex + end + end + self.NodeListData[self.curDataMaxIndex] = temp + end + self.dataHeadIndex = tempDataHeadIndex + self.dataTailIndex = tempDataTailIndex + self:AddTotalCount(#insertData, dir) + if isReload then + self:ReloadData() + end +end + +function XDynamicList:AddTotalCount(addCount, dir) + self.DynamicList.TotalCount = self.DynamicList.TotalCount + addCount; + if dir == DLInsertDataDir.Head then + self.DynamicList.StartIndex = self.DynamicList.StartIndex + addCount + -- self.DynamicList.EndIndex = self.DynamicList.EndIndex + addCount + end +end + +function XDynamicList:GenerateItem(evt, dir, index) + if self.DynamicListBar then + if self:GetBarValue() <= 0 then--拉到底了 + XEventManager.DispatchEvent(XEventId.EVENT_PULL_SCROLLVIEW_END, 0) + -- 添加新事件系统触发 + CsXGameEventManager.Instance:Notify(XEventId.EVENT_PULL_SCROLLVIEW_END, 0) + elseif self:GetBarValue() >= 1 then--拉到顶了 + XEventManager.DispatchEvent(XEventId.EVENT_PULL_SCROLLVIEW_UP, 0) + -- 添加新事件系统触发 + CsXGameEventManager.Instance:Notify(XEventId.EVENT_PULL_SCROLLVIEW_UP, 0) + end + end + if not self.CallBack then + XLog.Error("You must be set callBack......") + return + end + if evt == DLDelegateEvent.DYNAMIC_GRID_ATINDEX then + if #self.NodeListData == 0 then + return true + end + local curShowDataIndex = nil--下一个需要展示的数据index + if dir == DLScrollDataDir.Head then + if not self.NodeListData[self.curShowHeadIndex] then + return true + end + if self.NodeListData[self.curShowHeadIndex].Pre == -1 then + return true + end + self.curShowHeadIndex = self.NodeListData[self.curShowHeadIndex].Pre + curShowDataIndex = self.curShowHeadIndex + elseif dir == DLScrollDataDir.Tail then + if self.curShowTailIndex == -1 and self.curShowHeadIndex == -1 then + self.curShowHeadIndex = self.dataHeadIndex + self.curShowTailIndex = self.dataHeadIndex + else + if not self.NodeListData[self.curShowTailIndex] then + return true + end + if self.NodeListData[self.curShowTailIndex].Next == -1 then + return true + end + self.curShowTailIndex = self.NodeListData[self.curShowTailIndex].Next + end + curShowDataIndex = self.curShowTailIndex + end + self.CallBack(self.NodeListData[curShowDataIndex].data, function(poolName, ctor) + local item = self.DynamicList:PreDequeueGrid(poolName, index) + local xlayoutNode = item:GetComponent("XLayoutNode") + if self.DynamicList and xlayoutNode then + xlayoutNode.minSize = CS.UnityEngine.Vector2(self.DynamicList.transform:GetComponent("RectTransform").rect.width, 0) + end + if item == nil then + XLog.Error("GenerateItem is Fail......index = ", index) + return false + end + local key = item.gameObject:GetHashCode() + local itemScript = self.ItemCache[key] + if itemScript ~= nil then + return itemScript + else + local newItemScript = ctor(item.gameObject) + self.ItemCache[key] = newItemScript + return newItemScript + end + + end) + return false + elseif evt == DLDelegateEvent.DYNAMIC_GRID_RECYCLE then + if dir == DLScrollDataDir.Head then + self.curShowHeadIndex = self.NodeListData[self.curShowHeadIndex].Next + elseif dir == DLScrollDataDir.Tail then + self.curShowTailIndex = self.NodeListData[self.curShowTailIndex].Pre + end + + end + +end + +--------------------------Set------------------- +function XDynamicList:SetReverse(code) + self.DynamicList.Reverse = code +end + +function XDynamicList:SetBarValue(value) + self.DynamicListBar.value = value +end + +function XDynamicList:SetViewSize(rectSize, isReload) + self.DynamicList:SetViewSize(rectSize) + if isReload then + self:ReloadData() + end +end + +---------------------------Get----------------- +function XDynamicList:GetBarValue() + if self.DynamicListBar then + return self.DynamicListBar.value + else + XLog.Error("------DynamicList Not ScrollBar Component!------") + return nil + end +end + +function XDynamicList:GetCurDataCount() + return #self.NodeListData +end + +function XDynamicList:AddObjectPools(poolName, prefab) + self.DynamicList.ObjectPool:Add(poolName, prefab) +end \ No newline at end of file diff --git a/Resources/Scripts/XCommon/XEntityHelper.lua b/Resources/Scripts/XCommon/XEntityHelper.lua new file mode 100644 index 00000000..95625ea7 --- /dev/null +++ b/Resources/Scripts/XCommon/XEntityHelper.lua @@ -0,0 +1,35 @@ +XEntityHelper = XEntityHelper or {} + +XEntityHelper.TEAM_MAX_ROLE_COUNT = 3 + +-- entityId : CharacterId or RobotId +function XEntityHelper.GetCharacterIdByEntityId(entityId) + if XRobotManager.CheckIsRobotId(entityId) then + return XRobotManager.GetRobotTemplate(entityId).CharacterId + else + return entityId + end +end + +function XEntityHelper.GetIsRobot(entityId) + return XRobotManager.CheckIsRobotId(entityId) +end + +function XEntityHelper.GetCharacterName(entityId) + local characterId = XEntityHelper.GetCharacterIdByEntityId(entityId) + local config = XCharacterConfigs.GetCharacterTemplate(characterId) + if not config then return "none" end + return config.Name +end + +function XEntityHelper.GetCharacterTradeName(entityId) + local characterId = XEntityHelper.GetCharacterIdByEntityId(entityId) + local config = XCharacterConfigs.GetCharacterTemplate(characterId) + if not config then return "none" end + return config.TradeName +end + +function XEntityHelper.GetCharacterSmallIcon(entityId) + local characterId = XEntityHelper.GetCharacterIdByEntityId(entityId) + return XDataCenter.CharacterManager.GetCharSmallHeadIcon(characterId, 0, true) +end \ No newline at end of file diff --git a/Resources/Scripts/XCommon/XEventId.lua b/Resources/Scripts/XCommon/XEventId.lua new file mode 100644 index 00000000..d3c6cdb4 --- /dev/null +++ b/Resources/Scripts/XCommon/XEventId.lua @@ -0,0 +1,949 @@ +--[[ id值为 EVENT_模块名_具体事件名]] +-- +XEventId = { + --社交 + EVENT_CHAT_RECEIVE_PRIVATECHAT = "EVENT_CHAT_RECEIVE_PRIVATECHAT", --收到私聊 + EVENT_CHAT_RECEIVE_WORLD_MSG = "EVENT_CHAT_RECEIVE_WORLD_MSG", --收到世界聊天信息 + EVENT_CHAT_RECEIVE_ROOM_MSG = "EVENT_CHAT_RECEIVE_ROOM_MSG", --收到房间聊天信息 + EVENT_CHAT_MSG_SYNC = "EVENT_CHAT_MSG_SYNC", --同步私聊 + EVENT_CHAT_OPEN = "EVENT_CHAT_OPEN", --打开聊天界面 + EVENT_CHAT_CLOSE = "EVENT_CHAT_CLOSE", --关闭聊天界面 + EVENT_CHAT_CHANNEL_CHANGED = "EVENT_CHAT_CHANNEL_CHANGED", --聊天频道id更换 + EVENT_CHAT_SERVER_CHANNEL_CHANGED = "EVENT_CHAT_SERVER_CHANNEL_CHANGED", --服务端主动更换聊天频道 + EVENT_CHAT_MATCH_EFFECT = "EVENT_CHAT_MATCH_EFFECT", --聊天关键字匹配播放特效 + + + EVENT_FRIEND_DELETE = "EVENT_FRIEND_DELETE", --删除好友 + EVENT_FRIEND_WAITING_PASS = "EVENT_FRIEND_WAITING_PASS", --等待通过,新的好友申请 + EVENT_FRIEND_OPEN_PRIVATE_VIEW = "EVENT_FRIEND_OPEN_PRIVATE_VIEW", --打开私聊界面 + EVENT_FRIEND_READ_PRIVATE_MSG = "EVENT_FRIEND_READ_PRIVATE_MSG", --读取私聊信息 + EVENT_FRIEND_REMARK_NAME = "EVENT_FRIEND_REMARK_NAME", --好友备注名改变 + EVENT_BLACK_DATA_CHANGE = "EVENT_BLACK_DATA_CHANGE", --黑名单列表改变 + + EVENT_PULL_SCROLLVIEW_END = "EVENT_PULL_SCROLLVIEW_END", --数据拉到底了 --后续会清掉 + EVENT_PULL_SCROLLVIEW_UP = "EVENT_PULL_SCROLLVIEW_UP", --数据拉到头了 --后续会清掉 + + --设置事件 + EVENT_CUSTOM_UI_SCHEME_CHANGED = "EVENT_CUSTOM_UI_SCHEME_CHANGED", -- 战斗自定义按键改变 + --邮件事件 + EVENT_MAIL_SYNC = "EVENT_MAIL_SYNC", --服务端同步邮件, + EVENT_MAIL_READ = "EVENT_MAIL_READ", --读取邮件, + EVENT_MAIL_DELETE = "EVENT_MAIL_DELETE", --删除邮件, + EVENT_MAIL_GET_MAIL_REWARD = 'EVENT_MAIL_GET_MAIL_REWARD', --领取邮件附件 + EVENT_MAIL_GET_ALL_MAIL_REWARD = 'EVENT_MAIL_GET_ALL_MAIL_REWARD', --一键领取附件 + EVENT_MAIL_COUNT_CHANGE = 'EVENT_MAIL_COUNT_CHANGE', --邮件数发生改变 + --角色事件 + EVENT_CHARACTER_ADD_SYNC = "EVENT_CHARACTER_ADD_SYNC", --添加构造体 + EVENT_CHARACTER_LEVEL_UP = "EVENT_CHARACTER_LEVEL_UP", --升级 + EVENT_CHARACTER_QUALITY_STAR_PROMOTE = "EVENT_CHARACTER_QUALITY_STAR_PROMOTE", --进化 + EVENT_CHARACTER_QUALITY_PROMOTE = "EVENT_CHARACTER_QUALITY_PROMOTE", --升品 + EVENT_CHARACTER_GRADE = "EVENT_CHARACTER_GRADE", --晋升,升星 + EVENT_CHARACTER_GRADE_PART = "EVENT_CHARACTER_GRADE_PART", --小晋升 + EVENT_CHARACTER_SKILL_UNLOCK = "EVENT_CHARACTER_SKILL_UNLOCK", --解锁技能 + EVENT_CHARACTER_SKILL_UP = "EVENT_CHARACTER_SKILL_UP", --升级技能 + EVENT_CHARACTER_INCREASE_TIP = "EVENT_CHARACTER_INCREASE_TIP", -- 角色属性提升后提醒 + EVENT_CHARACTER_FIRST_GET = "EVENT_CHARACTER_FIRST_GET", --首次获得角色 + EVENT_CHARACTER_SYN = "EVENT_CHARACTER_SYN", --角色信息变更 + EVENT_CHARACTER_SUPPORT = "EVENT_CHARACTER_SUPPORT", -- 角色编入支援 + + --联机Boss事件 + EVENT_ONLINEBOSS_UPDATE = "EVENT_ONLINEBOSS_UPDATE", --数据刷新 + EVENT_ONLINEBOSS_REFRESH = "EVENT_ONLINEBOSS_REFRESH", --活动刷新 + EVENT_ONLINEBOSS_DROPREWARD_NOTIFY = "EVENT_ONLINEBOSS_DROPREWARD_NOTIFY", --抽奖通知 + EVENT_ONLINE_BOSS_REFRESH = "EVENT_ONLINE_BOSS_REFRESH", --联机boss刷新 + + --房间事件 + EVENT_ROOM_REFRESH = "EVENT_ROOM_REFRESH", --房间刷新 + EVENT_ROOM_PLAYER_ENTER = "EVENT_ROOM_PLAYER_ENTER", --玩家加入 + EVENT_ROOM_PLAYER_LEAVE = "EVENT_ROOM_PLAYER_LEAVE", --玩家离开 + EVENT_ROOM_PLAYER_STAGE_REFRESH = "EVENT_ROOM_PLAYER_STAGE_REFRESH", --玩家状态更新 + EVENT_ROOM_PLAYER_NPC_REFRESH = "EVENT_ROOM_PLAYER_NPC_REFRESH", --玩家角色信息更新 + EVENT_ROOM_AUTO_MATCH_CHANGE = "EVENT_ROOM_AUTO_MATCH_CHANGE", --房间自动匹配状态修改 + EVENT_ROOM_STAGE_LEVEL_CHANGE = "EVENT_ROOM_STAGE_LEVEL_CHANGE", --房间难度等级修改 + EVENT_ROOM_STAGE_ABILITY_LIMIT_CHANGE = "EVENT_ROOM_STAGE_ABILITY_LIMIT_CHANGE", --房间战力修改 + EVENT_ROOM_STAGE_CHANGE = "EVENT_ROOM_STAGE_CHANGE", --房间状态修改 + + EVENT_ROOM_MATCH = "EVENT_ROOM_MATCH", --匹配 + EVENT_ROOM_CANCEL_MATCH = "EVENT_ROOM_CANCEL_MATCH", --取消匹配 + EVENT_ROOM_ENTER_ROOM = "EVENT_ROOM_ENTER_ROOM", --进入房间 + EVENT_ROOM_KICKOUT = "EVENT_ROOM_KICKOUT", --踢出房间 + EVENT_ROOM_LEAVE_ROOM = "EVENT_ROOM_LEAVE_ROOM", --离开房间(主动退出或被踢出房间) + EVENT_ROOM_COUNT_DOWN = "EVENT_ROOM_COUNT_DOWN", --倒计时 + EVENT_ROOM_CHANGE_STAGE = "EVENT_ROOM_CHANGE_STAGE", --切换关卡 + EVENT_ROOM_CHANGE_STAGE_SUMMER_EPISODE = "EVENT_ROOM_CHANGE_STAGE_SUMMER_EPISODE", --夏活照相关切换关卡 + + --UI + UiOpenPanel = "EVENT_UI_OPEN_PANEL", --参数:(bool, string),打开/关闭,ui名称 + EVENT_MAINUI_ENABLE = "EVENT_MAINUI_ENABLE", --主界面显示 + + EVENT_PLAYER_SETTING = "EVENT_PLAYER_SETTING", -- 玩家展示设置 + + --引导 + EVENT_GUIDE_REQ_OPEN_SUCCESS = "EVENT_GUIDE_REQ_OPEN_SUCCESS", --请求引导完成 + EVENT_GUIDE_START = "EVENT_GUIDE_START", --引导开始 + EVENT_GUIDE_END = "EVENT_GUIDE_END", --引导结束 + EVENT_GUIDE_COMPLETED_SUCCESS = "EVENT_GUIDE_COMPLETED_SUCCESS", --请求引导完成 + + + EVENT_GUIDE_STEP_OPEN_EVENT = "EVENT_GUIDE_STEP_OPEN_EVENT", --检测步骤 + + --功能开启 + EVENT_FUNCTION_OPEN_COMPLETE = "EVENT_FUNCTION_OPEN_COMPLETE", --功能开启 + + EVENT_FUNCTION_EVENT_START = "EVENT_FUNCTION_EVENT_START", --功能开始 + EVENT_FUNCTION_EVENT_COMPLETE = "EVENT_FUNCTION_EVENT_COMPLETE", --功能开启完成 + EVENT_FUNCTION_EVENT_END = "EVENT_FUNCTION_EVENT_END", --功能结束 + EVENT_FESTIVAL_COMMUNICATE_FUNCTION_EVENT_END = "EVENT_FESTIVAL_COMMUNICATE_FUNCTION_EVENT_END", --節日通訊功能结束 + -- 时间 + EVENT_TIMEID_BOUND_PREFIX = "EVENT_TIMEID_UPDATE_", + EVENT_ETCD_TIME_CHANGE = "EVENT_ETCD_TIME_CHANGE",--ETCD上某个TimeID对应的时间发生改变 + --紧急事件 + EVENT_URGENTEVENT_SYNC = "EVENT_URGENTEVENT_SYNC", -- 收到紧急事件 + + --副本 + EVENT_FUBEN_DAILY_REFRESH = "EVENT_FUBEN_DAILY_REFRESH", --日常副本刷新 + EVENT_FUBEN_REFRESH_STAGE_DATA = "EVENT_FUBEN_REFRESH_STAGE_DATA", --副本变更推送 + EVENT_FUBEN_CHAPTER_REWARD = "EVENT_FUBEN_CHAPTER_REWARD", --领取章节奖励 + EVENT_FUBEN_CLOSE_FUBENSTAGEDETAIL = "EVENT_FUBEN_CLOSE_FUBENSTAGEDETAIL", --关闭副本详细界面 + EVENT_FUBEN_ENTERFIGHT = "EVENT_FUBEN_ENTERFIGHT", --点击作战开始 + EVENT_FUBEN_STAGE_SYNC = "EVENT_FUBEN_STAGE_SYNC", --stage同步 + EVENT_FUBEN_NEW_STAGE = "EVENT_FUBEN_NEW_STAGE", --新的关卡 + EVENT_FUBEN_NEW_MAIN_LINE_CHAPTER = "EVENT_FUBEN_NEW_MAIN_LINE_CHAPTER", --新的主线章节 + EVENT_FUBEN_SETTLE_REWARD = "EVENT_FUBEN_SETTLE_REWARD", --副本结算奖励 + EVENT_FUBEN_SHOW_REWARD = "EVENT_FUBEN_SHOW_REWARD", --显示副本奖励 + EVENT_FUBEN_CHANGE_MAIN_LINE_DIFFICULT = "EVENT_FUBEN_CHANGE_MAIN_LINE_DIFFICULT", --修改主线副本难度 + EVENT_PRE_ENTER_FIGHT = "EVENT_PRE_ENTER_FIGHT", --进入战斗前 + EVENT_ENTER_FIGHT = "EVENT_ENTER_FIGHT", --进入战斗 + EVENT_FUBEN_EXPLORE_UPDATE = "EVENT_FUBEN_EXPLORE_UPDATE", --探索更新UI + EVENT_FUBEN_EXPLORE_UPDATEBUFF = "EVENT_FUBEN_EXPLORE_UPDATEBUFF", --更新探索buff UI + EVENT_FUBEN_RESOURCE_AUTOSELECT = "EVENT_FUBEN_RESOURCE_AUTOSELECT", --资源自动选中 + EVENT_FUBEN_PREQUEL_AUTOSELECT = "EVENT_FUBEN_PREQUEL_AUTOSELECT", --前传自动选中 + EVENT_FUBEN_MAINLINE_TAB_SELECT = "EVENT_FUBEN_MAINLINE_TAB_SELECT", --剧情界面子标签页自动选中 + EVENT_FUBEN_MAINLINE_DIFFICUTY_SELECT = "EVENT_FUBEN_MAINLINE_DIFFICUTY_SELECT", --主线难度标签页自动选中 + EVENT_FUBEN_SETTLE_FAIL = "EVENT_FUBEN_FIGHT_CHECK_FAIL", --副本结算失败 + EVENT_FUBEN_NEW_CHALLEGE = "EVENT_FUBEN_NEW_CHALLEGE", --副本挑战新玩法出现 + EVENT_FUBEN_EXTRACHAPTER_REWARD = "EVENT_FUBEN_EXTRACHAPTER_REWARD", --领取番外章节奖励 + EVENT_FUBEN_NEW_EXTRA_CHAPTER = "EVENT_FUBEN_NEW_EXTRA_CHAPTER", --新的番外章节 + EVENT_FUBEN_CHANGE_EXTRA_CHAPTER_DIFFICULT = "EVENT_FUBEN_CHANGE_EXTRA_CHAPTER_DIFFICULT", --更改番外副本难度 + EVENT_FUBEN_NEW_EXPEDITION_STAGE = "EVENT_FUBEN_NEW_EXPEDITION_STAGE", --虚像地平线解锁新关卡 + EVENT_FUBEN_NIER_STAGE_REWARD = "EVENT_FUBEN_NEW_NIER_STAGE", --尼尔玩法通关新副本 + EVENT_FUBEN_NEWCHARACT_REWARD = "EVENT_FUBEN_NEWCHARACT_REWARD", --领取新角色活动奖励 + EVENT_FUBEN_SIMUCOMBAT_UPDATE = "EVENT_FUBEN_SIMUCOMBAT_UPDATE", --模拟作战更新UI + EVENT_FUBEN_SIMUCOMBAT_REWARD = "EVENT_FUBEN_SIMUCOMBAT_REWARD", --模拟作战领取奖励 + EVENT_FUBEN_HACK_UPDATE = "EVENT_FUBEN_HACK_UPDATE", --骇入玩法更新UI + EVENT_FUBEN_HACK_CLICK = "EVENT_FUBEN_HACK_CLICK", --骇入玩法点击 + EVENT_FUBEN_COUPLECOMBAT_UPDATE = "EVENT_FUBEN_COUPLECOMBAT_UPDATE", --双人下场玩法更新UI + --活动相关 + EVENT_ACTIVITY_MAINLINE_STATE_CHANGE = "EVENT_ACTIVITY_MAINLINE_STATE_CHANGE", --主线副本抢先体验活动状态变更 + EVENT_ACTIVITY_EXTRACHAPTER_STATE_CHANGE = "EVENT_ACTIVITY_EXTRACHAPTER_STATE_CHANGE", --番外副本抢先体验活动状态变更 + EVENT_ACTIVITY_INFO_UPDATE = "EVENT_ACTIVITY_INFO_UPDATE", -- 活动状态或数据变化 + EVENT_ACTIVITY_ON_RESET = "EVENT_ACTIVITY_ON_RESET", -- 活动重置或结束时通知(用于出战界面等通用界面通知时间边界处理) + --主线探索玩法 + EVENT_MAINLINE_EXPLORE_ITEM_GET = "EVENT_MAINLINE_EXPLORE_ITEM_GET", --主线探索玩法获得隐藏道具 + EVENT_MAINLINE_EXPLORE_ITEMBOX_CLOSE = "EVENT_MAINLINE_EXPLORE_ITEMBOX_CLOSE", --主线探索玩法关闭道具包 + EVENT_EXTRACHAPTER_EXPLORE_ITEM_GET = "EVENT_EXTRACHAPTER_EXPLORE_ITEM_GET", --番外探索玩法获得隐藏道具 + EVENT_EXTRACHAPTER_EXPLORE_ITEMBOX_CLOSE = "EVENT_EXTRACHAPTER_EXPLORE_ITEMBOX_CLOSE", --番外探索玩法关闭道具包 + + --自动作战 + EVENT_AUTO_FIGHT_CHANGE = "EVENT_AUTO_FIGHT_CHANGE", --自动作战状态改变 + EVENT_AUTO_FIGHT_START = "EVENT_AUTO_FIGHT_START", --自动作战开始 + EVENT_AUTO_FIGHT_COMPLETE = "EVENT_AUTO_FIGHT_COMPLETE", --自动作战完成 + EVENT_AUTO_FIGHT_REMOVE = "EVENT_AUTO_FIGHT_REMOVE", --自动作战移除 + + --竞技 + EVENT_ARENA_TEAM_CHANGE = "EVENT_ARENA_TEAM_CHANGE", --竞技队伍变化 + EVENT_ARENA_TEAM_INITIATIVE_LEAVE = "EVENT_ARENA_TEAM_INITIATIVE_LEAVE", --竞技主动离队 + EVENT_ARENA_TEAM_RECEIVE_APPLY_DATA = "EVENT_ARENA_TEAM_RECEIVE_APPLY_DATA", --竞技得到申请列表 + EVENT_ARENA_TEAM_APPLY_CHANGE = "EVENT_ARENA_TEAM_APPLY_CHANGE", --竞技申请列表变化 + EVENT_ARENA_TEAM_NEW_APPLY_ENTER = "EVENT_ARENA_TEAM_NEW_APPLY_ENTER", --竞技新申请信息数量变化 + EVENT_ARENA_MAIN_INFO = "EVENT_ARENA_MAIN_INFO", --竞技主界面信息 + EVENT_ARENA_REFRESH_TEAM_RANK_INFO = "EVENT_ARENA_REFRESH_TEAM_RANK_INFO", --竞技刷新排行信息 + EVENT_ARENA_REFRESH_AREA_INFO = "EVENT_ARENA_REFRESH_AREA_INFO", --竞技刷新战区信息 + EVENT_ARENA_UNLOCK_AREA = "EVENT_ARENA_UNLOCK_AREA", --竞技解锁战区 + EVENT_ARENA_RESULT_CLOSE = "EVENT_ARENA_RESULT_CLOSE", --竞技关闭奖励界面 + EVENT_ARENA_RESULT_AUTOFIGHT = "EVENT_ARENA_RESULT_AUTOFIGHT", --战区自动作战 + + --任务 + EVENT_TASK_SYNC = "EVENT_TASK_SYNC", --任务改变 + EVENT_FINISH_TASK = "EVENT_FINISH_TASK", --任务改变 + EVENT_TASK_COURSE_REWAED = "EVENT_TASK_COURSE_REWAED", --领取历程奖励 + EVENT_TASK_TAB_CHANGE = "EVENT_TASK_TAB_CHANGE", --任务tab改变 + EVENT_TASK_FINISH_FAIL = "EVENT_TASK_FINISH_FAIL", --任务领取失败 + + --道具 + EVENT_ITEM_COUNT_UPDATE_PREFIX = "EVENT_ITEM_COUNT_UPDATE_", + EVENT_ITEM_BUYTIEMS_UPDATE_PREFIX = "EVENT_ITEM_BUYTIMES_UPDATE_", + EVENT_ITEM_BUYASSET = "EVENT_ITEM_BUYASSET", -- 购买道具 + EVENT_ITEM_USE = "EVENT_ITEM_USE", -- 使用道具 + EVENT_TIMELIMIT_ITEM_USE = "EVENT_TIMELIMIT_ITEM_USE", -- 使用限时道具 + EVENT_ITEM_RECYCLE = "EVENT_ITEM_RECYCLE", -- 回收道具 + EVENT_ITEM_MULTIPLY_USE = "EVENT_ITEM_MULTIPLY_USE", -- 使用多组道具 + EVENT_ITEM_FAST_TRADING = "EVENT_ITEM_FAST_TRADING", -- 快捷购买道具 + + --玩家 + EVENT_USERID_CHANGE = "EVENT_USERID_CHANGE", -- 更换账号 + EVENT_USERNAME_CHANGE = "EVENT_USERNAME_CHANGE", -- 更换账号 + EVENT_USER_LOGOUT = "EVENT_USER_LOGOUT", -- 登出 + EVENT_LOGIN_SUCCESS = "EVENT_LOGIN_SUCCESS", -- 登陆成功 + EVENT_LOGIN_DATA_LOAD_COMPLETE = "EVENT_LOGIN_DATA_LOAD_COMPLETE", -- 登录数据加载完毕 + EVENT_NETWORK_DISCONNECT = "EVENT_NETWORK_DISCONNECT", -- 断开连接 + EVENT_SERVER_LIST_CHANGE = "EVENT_SERVER_LIST_CHANGE", -- 服务器列表变更 + + EVENT_NEW_PLAYER = "EVENT_NEW_PLAYER", -- 新创建的玩家 + EVENT_PLAYER_SET_NAME = "EVENT_PLAYER_SET_NAME", -- 玩家改名 + EVENT_PLAYER_LEVEL_CHANGE = "EVENT_PLAYER_LEVEL_CHANGE", -- 等级发生变化 + + EVENT_PLAYER_LEVEL_UP_ANIMATION_END = "EVENT_PLAYER_LEVEL_UP_ANIMATION_END", --玩家等级提升动画结束 + + --赏金任务 + EVENT_BOUNTYTASK_INFO_CHANGE_NOTIFY = "EVENT_BOUNTYTASK_INFO_CHANGE_NOTIFY", --赏金任务改变推送 + EVENT_BOUNTYTASK_ACCEPT_TASK = "EVENT_BOUNTYTASK_ACCEPT_TASK", --接受赏金任务 + EVENT_BOUNTYTASK_ACCEPT_TASK_REWARD = "EVENT_BOUNTYTASK_ACCEPT_TASK_REWARD", --接受赏金任务 + EVENT_BOUNTYTASK_TASK_COMPLETE_NOTIFY = "EVENT_BOUNTYTASK_TASK_COMPLETE_NOTIFY", --任务完成 + EVENT_BOUNTYTASK_TASK_REFRESH = "EVENT_BOUNTYTASK_TASK_REFRESH", --任务池刷新 + + --派遣 + EVENT_TASKFORCE_INFO_NOTIFY = "EVENT_TASKFORCE_INFO_NOTIFY", --派遣推送 + EVENT_TASKFORCE_SECTIONCHANGE_NOTIFY = "EVENT_TASKFORCE_SECTIONCHANGE_NOTIFY", --派遣章节改变推送 + EVENT_TASKFORCE_MAXTASKFORCECOUNT_CHANGE_NOTIFY = "EVENT_TASKFORCE_MAXTASKFORCECOUNT_CHANGE_NOTIFY", --可派遣队伍最大数量改变推送 + EVENT_TASKFORCE_COMPLETE_NOTIFY = "EVENT_TASKFORCE_COMPLETE_NOTIFY", --派遣任务完成推送 + EVENT_TASKFORCE_GIVEUP_TASK_REQUEST = "EVENT_TASKFORCE_GIVEUP_TASK_REQUEST", --派遣放弃任务 + EVENT_TASKFORCE_ACCEPT_TASK_REQUEST = "EVENT_TASKFORCE_ACCEPT_TASK_REQUEST", --派遣接受任务 + EVENT_TASKFORCE_REFRESH_REQUEST = "EVENT_TASKFORCE_REFRESH_REQUEST", --派遣刷新任务池 + EVENT_TASKFORCE_TASKFINISH_REQUEST = "EVENT_TASKFORCE_TASKFINISH_REQUEST", --派遣立即完成任务 + EVENT_TASKFORCE_ACCEPT_REWARD_REQUEST = "EVENT_TASKFORCE_ACCEPT_REWARD_REQUEST", --派遣获得奖励 + EVENT_TASKFORCE_TIP_MISSION_END = "EVENT_TASKFORCE_TIP_MISSION_END", --派遣队伍开启动画结束 + + --战斗 + EVENT_FIGHT_BEGIN_PLAYMOVIE = "EVENT_FIGHT_BEGIN_PLAYMOVIE", --战斗开始前播放剧情 + EVENT_FIGHT_LOADINGFINISHED = "EVENT_FIGHT_LOADINGFINISHED", --战斗Loading已打开 + EVENT_FIGHT_PROGRESS = "EVENT_FIGHT_PROGRESS", --战斗loading进度 + EVENT_FIGHT_RESULT = "EVENT_FIGHT_RESULT", --战斗结果 + EVENT_FIGHT_RESULT_WIN = "EVENT_FIGHT_RESULT_WIN", --战斗结果 + EVENT_FIGHT_EXIT = "EVENT_FIGHT_EXIT", --战斗结束(cs事件) + EVENT_FIGHT_FINISH = "EVENT_FIGHT_FINISH", --战斗结束 + EVENT_FIGHT_FINISH_LOSEUI_CLOSE = "EVENT_FIGHT_FINISH_LOSEUI_CLOSE", --战斗失败界面关闭回调 + + --投票 + EVENT_VOTE_REFRESH = "EVENT_VOTE_REFRESH", --投票数据更新 + + --装备 + EVENT_EQUIP_PUTON_NOTYFY = "EVENT_EQUIP_PUTON_NOTYFY", --穿上 + EVENT_EQUIP_PUTON_WEAPON_NOTYFY = "EVENT_EQUIP_PUTON_WEAPON_NOTYFY", --穿上武器 + EVENT_EQUIP_TAKEOFF_NOTYFY = "EVENT_EQUIP_TAKEOFF_NOTYFY", --脱下单个 + EVENT_EQUIPLIST_TAKEOFF_NOTYFY = "EVENT_EQUIPLIST_TAKEOFF_NOTYFY", --脱下装备列表 + EVENT_EQUIP_LOCK_STATUS_CHANGE_NOTYFY = "EVENT_EQUIP_LOCK_STATUS_CHANGE_NOTYFY", --锁定状态变更 + EVENT_EQUIP_STRENGTHEN_NOTYFY = "EVENT_EQUIP_STRENGTHEN_NOTYFY", --强化 + EVENT_EQUIP_BREAKTHROUGH_NOTYFY = "EVENT_EQUIP_BREAKTHROUGH_NOTYFY", --突破 + EVENT_EQUIP_RESONANCE_NOTYFY = "EVENT_EQUIP_RESONANCE_NOTYFY", --共鸣随机技能返回 + EVENT_EQUIP_RESONANCE_ACK_NOTYFY = "EVENT_EQUIP_RESONANCE_ACK_NOTYFY", --共鸣确认选择技能 + EVENT_EQUIP_AWAKE_NOTYFY = "EVENT_EQUIP_AWAKE_NOTYFY", --觉醒 + EVENT_EQUIP_DATA_CHANGE_NOTIFY = "EVENT_EQUIP_DATA_CHANGE_NOTYFY", --装备数据变更 + EVENT_EQUIP_DATA_INIT_NOTIFY = "EVENT_EQUIP_DATA_INIT_NOTYFY", --装备数据初始化完成 + EVENT_EQUIP_CAN_BREAKTHROUGH_TIP_CLOSE = "EVENT_EQUIP_CAN_BREAKTHROUGH_TIP_CLOSE", --装备强化至满级开启突破弹条动画播放结束 + EVENT_EQUIP_DATA_LIST_UPDATE_NOTYFY = "EVENT_EQUIP_DATA_LIST_UPDATE_NOTYFY", --装备数据列表更新 + EVENT_EQUIP_SUIT_PREFAB_DATA_UPDATE_NOTIFY = "EVENT_EQUIP_SUIT_PREFAB_DATA_UPDATE_NOTIFY", --意识组合数据更新 + EVENT_EQUIP_RECYCLE_NOTIFY = "EVENT_EQUIP_RECYCLE_NOTIFY", --意识被回收 + EVENT_EQUIP_RECYCLE_STATUS_CHANGE_NOTYFY = "EVENT_EQUIP_RECYCLE_STATUS_CHANGE_NOTYFY", --待回收状态变更 + + --基地装备 + EVENT_BASE_EQUIP_DATA_CHANGE_NOTIFY = "EVENT_BASE_EQUIP_DATA_CHANGE_NOTYFY", --穿上基地装备 + EVENT_BASE_EQUIP_DATA_REFRESH = "EVENT_BASE_EQUIP_DATA_REFRESH", --基地装备数据刷新 + + -- 好感度偶遇 + EVENT_COMEACROSS_PLAY = "EVENT_COMEACROSS_PLAY", --开始游戏 + EVENT_COMEACROSS_PLAYRESULT = "EVENT_COMEACROSS_PLAYRESULT", --游戏结算 + + + -- 好感度 + EVENT_FAVORABILITY_MAIN_REFRESH = "EVENT_FAVORABILITY_MAIN_REFRESH", --好感度主界面信息同步 + EVENT_FAVORABILITY_RUMORS_PREVIEW = "EVENT_FAVORABILITY_RUMORS_PREVIEW", --异闻预览 + EVENT_FAVORABILITY_COLLECTGIFT = "EVENT_FAVORABILITY_COLLECTGIFT", --领取礼物 + EVENT_FAVORABILITY_PLOTUNLOCK = "EVENT_FAVORABILITY_PLOTUNLOCK", --剧情解锁 + EVENT_FAVORABILITY_INFOUNLOCK = "EVENT_FAVORABILITY_INFOUNLOCK", --资料解锁 + EVENT_FAVORABILITY_RUMERUNLOCK = "EVENT_FAVORABILITY_RUMERUNLOCK", --异闻解锁 + EVENT_FAVORABILITY_AUDIOUNLOCK = "EVENT_FAVORABILITY_AUDIOUNLOCK", --语音解锁 + EVENT_FAVORABILITY_ACTIONUNLOCK = "EVENT_FAVORABILITY_ACTIONUNLOCK", --动作解锁 + EVENT_FAVORABILITY_GIFT = "EVENT_FAVORABILITY_GIFT", --发送礼物 + EVENT_FAVORABILITY_LEVELCHANGED = "EVENT_FAVORABILITY_LEVELCHANGED", --好感度等级经验变化 + EVENT_FAVORABILITY_CHAR_ABILITY_CHANGED = "EVENT_FAVORABILITY_CHAR_ABILITY_CHANGED", --战斗参数变化 + EVENT_FAVORABILITY_CHAR_QUALITY_CHANGED = "EVENT_FAVORABILITY_CHAR_QUALITY_CHANGED", --角色品质变化 + EVENT_FAVORABILITY_ON_GIFT_CHANGED = "EVENT_FAVORABILITY_ON_GIFT_CHANGED", --选中的礼物变化 + + -- 新手任务 + EVENT_NEWBIETASK_DAYCHANGED = "EVENT_NEWBIETASK_DAYCHANGED", --新手目标天数变化 + EVENT_NEWBIETASK_PROGRESSCHANGED = "EVENT_NEWBIETASK_PROGRESSCHANGED", --新手进度 + + -- 队伍预设 + EVENT_TEAM_PREFAB_CHANGE = "EVENT_TEAM_PREFAB_CHANGE", --队伍预设改变 + EVENT_TEAM_PREFAB_SELECT = "EVENT_TEAM_PREFAB_SELECT", --队伍选中 + EVENT_TEAM_MEMBER_CHANGE = "EVENT_TEAM_MEMBER_CHANGE", --队伍成员发生变化 + + -- 公告 + EVENT_NOTICE_PIC_CHANGE = "EVENT_NOTICE_PIC_CHANGE", --宣传图改变 + EVENT_NOTICE_TYPE_CHANAGE = "EVENT_NOTICE_TYPE_CHANAGE", --公告页签改变 + EVENT_NOTICE_CLOSE_TEXT_NOTICE = "EVENT_NOTICE_CLOSE_TEXT_NOTICE", --关闭滚动公告 + EVENT_NOTICE_CONTENT_RESP = "EVENT_NOTICE_CONTENT_RESP", --公告内容返回 + + -- 活动系统 + EVENT_ACTIVITY_ACTIVITIES_READ_CHANGE = "EVENT_ACTIVITY_ACTIVITIES_READ_CHANGE", -- 活动已读状态改变 + EVENT_ACTIVITY_NOTICE_READ_CHANGE = "EVENT_ACTIVITY_NOTICE_READ_CHANGE", --公告已读状态改变 + + -- 运营相关 + EVENT_ACTIVITY_SUBMENU_READ_CHANGE = "EVENT_ACTIVITY_SUBMENU_READ_CHANGE", -- 主界面二级菜单已读状态改变 + + -- 试炼 + EVENT_TRIAL_LEVEL_FINISH = "EVENT_TRIAL_LEVEL_FINISH", --有对应关卡通关 + + + + -- 前传 + EVENT_NOTICE_REFRESHTIME_CHANGE = "EVENT_NOTICE_REFRESHTIME_CHANGE", --刷新时间 + EVENT_NOTICE_CHALLENGESTAGES_CHANGE = "EVENT_NOTICE_CHALLENGESTAGES_CHANGE", --挑战关卡刷新 + EVENT_NOTICE_SELECTCOVER_CHANGE = "EVENT_NOTICE_SELECTCOVER_CHANGE", -- + EVENT_NOTICE_PREQUELDETAIL_CLOSE = "EVENT_NOTICE_PREQUELDETAIL_CLOSE", --详情关闭 + + EVENT_NOTICE_TASKINITFINISHED = "EVENT_NOTICE_TASKINITFINISHED", + + -- 弹窗 + EVENT_UIDIALOG_VIEW_ENABLE = "EVENT_UIDIALOG_VIEW_ENABLE", -- 提示弹窗显示 + + -- 签到 + EVENT_SING_IN_OPEN_BTN = "EVENT_SING_IN_OPEN_BTN", -- 签到领取完成开启关闭按钮 + + --宿舍 + EVENT_CLICKFURNITURE_GRID = "EVENT_CLICKFURNITURE_GRID", -- 点击单个家具 + EVENT_CLICKDRAFT_GRID = "EVENT_CLICKDRAFT_GRID", -- 点击单个图纸 + EVENT_CLICKCATEGORY_GRID = "EVENT_CLICKCATEGORY_GRID", -- 点击单个家具类型 + EVENT_CLICKFURNITURE_ONROOM = "EVENT_CLICKFURNITURE_ONROOM", -- 点击场景中的家具 + EVENT_FURNITURE_CREATE_CHANGED = "EVENT_FURNITURE_CREATE_CHANGED", -- 家具建造可领取 + EVENT_FURNITURE_ONDRAGITEM_CHANGED = "EVENT_FURNITURE_ONDRAGITEM_CHANGED", -- 家具拖动变化 + EVENT_FURNITURE_REFRESH = "EVENT_FURNITURE_REFRESH", -- 刷新家具摆放界面 + EVENT_FURNITURE_CLEANROOM = "EVENT_FURNITURE_CLEANROOM", -- 通知全部收起家具 + EVENT_FURNITURE_ON_MODIFY = "EVENT_FURNITURE_ON_MODIFY", -- 通知家具改变(分解,合成) + EVENT_FURNITURE_Get_Furniture = "EVENT_FURNITURE_Get_Furniture", -- 领取家具 + EVENT_CHARACTER_MOOD_CHANGED = "EVENT_CHARACTER_MOOD_CHANGED", -- 构造体心情值变化 + EVENT_CHARACTER_VITALITY_CHANGED = "EVENT_CHARACTER_VITALITY_CHANGED", -- 构造体体力情值变化 + EVENT_CHARACTER_ADD_EVENT_NOTIFY = "EVENT_CHARACTER_ADD_EVENT_NOTIFY", -- 构造体事件通知 + EVENT_CHARACTER_SUB_EVENT_NOTIFY = "EVENT_CHARACTER_SUB_EVENT_NOTIFY", -- 构造体事件过期通知 + EVENT_CHARACTER_DORMMAIN_EVENT_NOTIFY = "EVENT_CHARACTER_DORMMAIN_EVENT_NOTIFY", -- 通知宿舍主界面有事件 + EVENT_CHARACTER_CHANGE_ROOM_CHARACTER = "EVENT_CHARACTER_CHANGE_ROOM_CHARACTER", -- 从房间新增或者移出构造体 + EVENT_DORM_ROOM = "EVENT_DORM_ROOM", -- 进入宿舍 + EXIT_DORM_ROOM = "EXIT_DORM_ROOM", -- 退出宿舍 + EVENT_DORM_ROOM_ACTIVE_SUCCESS = "EVENT_DORM_ROOM_ACTIVE_SUCCESS", -- 宿舍激活成功 + EVENT_DORM_CHARACTER_CLICK_SUCCESS = "EVENT_DORM_CHARACTER_CLICK_SUCCESS", -- 宿舍构造体点击 + EVENT_DORM_CHARACTER_POINTER_UP_SUCCESS = "EVENT_DORM_CHARACTER_POINTER_UP_SUCCESS", -- 宿舍构造体手指弹起 + EVENT_DORM_FURNITURE_POINTER_UP_SUCCESS = "EVENT_DORM_CHARACTER_POINTER_UP_SUCCESS", -- 宿舍家具手指弹起 + EVENT_DORM_FURNITURE_PUT_SUCCESS = "EVENT_DORM_CHARACTER_POINTER_UP_SUCCESS", -- 宿舍家具摆放 + EVENT_CHARACTER_SHOW_DIALOBOX = "EVENT_CHARACTER_SHOW_DIALOBOX", -- 对话气泡显示 + EVENT_CHARACTER_HIDE_DIALOBOX = "EVENT_CHARACTER_HIDE_DIALOBOX", -- 对话气泡隐藏 + EVENT_CHARACTER_SHOW_3DIOBJ = "EVENT_CHARACTER_SHOW_3DIOBJ", -- 3DUI显示 + EVENT_CHARACTER_HIDE_3DIOBJ = "EVENT_CHARACTER_HIDE_3DIOBJ", -- 3DUI隐藏 + EVENT_CHARACTER_CATCH = "EVENT_CHARACTER_CATCH", -- 抓起构造体 + EVENT_CHARACTER_EXIT = "EVENT_CHARACTER_EXIT", -- 抓起构造体读条放下 + EVENT_CHARACTER_PUT_ON = "EVENT_CHARACTER_PUT_ON", -- 构造体抓起读条 + EVENT_CHARACTER_PUT_DOWN = "EVENT_CHARACTER_PUT_DOWN", -- 放下构造体 + EVENT_DORM_TOUCH_ENTER = "EVENT_DORM_TOUCH_ENTER", -- 宿舍爱抚构造体进入 + EVENT_DORM_TOUCH_SHOW = "EVENT_DORM_TOUCH_SHOW", -- 宿舍爱抚构造体显示 + EVENT_DORM_TOUCH_SHOW_VIEW = "EVENT_DORM_TOUCH_SHOW_VIEW", -- 宿舍爱抚构造体显示(界面用) + EVENT_DORM_TOUCH_HIDE = "EVENT_DORM_TOUCH_HIDE", -- 宿舍爱抚构造体隐藏 + EVENT_DORM_EXP_DETAIL_SHOW = "EVENT_DORM_EXP_DETAIL_SHOW", -- 显示体力详情 + EVENT_DORM_EXP_DETAIL_HIDE = "EVENT_DORM_EXP_DETAIL_HIDE", -- 隐藏体力详情 + EVENT_DORM_HEAD_TOUCH = "EVENT_DORM_HEAD_TOUCH", -- 点击头像里的抚摸按钮 + EVENT_DORM_EXP_SHOW = "EVENT_DORM_EXP_SHOW", -- 显示心情条 + EVENT_DORM_EXP_HIDE = "EVENT_DORM_EXP_HIDE", -- 隐藏心情条 + EVENT_DORM_HIDE_COMPONET = "EVENT_DORM_HIDE_COMPONET", -- 隐藏所有组建 + EVENT_DORM_CLOSE_COMPONET = "EVENT_DORM_CLOSE_COMPONET", -- 关闭宿舍3D场景 + EVENT_HOME_CHARACTER_STATUS_CHANGE = "EVENT_HOME_CHARACTER_STATUS_CHANGE", --宿舍角色状态改变 + EVENT_DORM_SHOW_EVENT_CHANGE = "EVENT_DORM_SHOW_EVENT_CHANGE", --宿舍角色体力/心情/体力恢复速度/心情恢复速度改变 + EVENT_DORM_FURNITURE_ATTR_TAG = "EVENT_DORM_FURNITURE_ATTR_SHOW", -- 家具属性显示 + EVENT_DORM_FURNITURE_ATTR_TAG_DETAIL = "EVENT_DORM_FURNITURE_ATTR_TAG_DETAIL", -- 家具属性显示细节 + EVENT_DORM_FURNITURE_HIDE_ATTR_TAG_DETAIL = "EVENT_DORM_FURNITURE_HIDE_ATTR_TAG_DETAIL", -- 隐藏家具属性细节 + EVENT_DORM_FURNITURE_HIDE_ALL_ATTR_TAG_DETAIL = "EVENT_DORM_FURNITURE_HIDE_ALL_ATTR_TAG_DETAIL", -- 隐藏家具属性细节 + EVENT_DORM_BAG_REFRESH = "EVENT_DORM_BAG_REFRESH", -- 通知刷新家具背包页面 + + + + --展示厅 + EVENT_CHARACTER_EXHIBITION_REFRESH = "EVENT_CHARACTER_EXHIBITION_REFRESH", --展示厅奖励信息刷新 + EVENT_CHARACTER_EXHIBITION_AUTOSELECT = "EVENT_CHARACTER_EXHIBITION_AUTOSELECT", --展示厅跳转选中 + + --指挥官头像 + EVENT_HEAD_PORTRAIT_NOTIFY = "EVENT_HEAD_PORTRAIT_NOTIFY", --新头像解锁通知 + EVENT_HEAD_PORTRAIT_RESETINFO = "EVENT_HEAD_PORTRAIT_RESETINFO", --新头像解锁通知 + EVENT_HEAD_PORTRAIT_TIMEOUT = "EVENT_HEAD_PORTRAIT_TIMEOUT", --新头像过期通知 + --勋章 + EVENT_MEDAL_NOTIFY = "EVENT_MEDAL_NOTIFY", --勋章解锁通知 + EVENT_MEDAL_TIPSOVER = "EVENT_MEDAL_TIPSOVER", --勋章飘窗结束 + EVENT_MEDAL_REDPOINT_CHANGE = "EVENT_MEDAL_REDPOINT_CHANGE", --勋章红点变动 + EVENT_SCORETITLE_CHANGE = "EVENT_SCORETITLE_CHANGE", --计分徽章分数改变通知 + EVENT_SCORETITLE_NEW = "EVENT_SCORETITLE_NEW", --获取新收藏品通知 + EVENT_MEDAL_USE = "EVENT_MEDAL_USE", --装备/解锁勋章 + -- 教学关卡 + EVENT_PRACTICE_ON_DATA_REFRESH = "EVENT_PRACTICE_ON_DATA_REFRESH", --数据刷新 + + -- 单挑Boss相关 + EVENT_BOSS_SINGLE_GET_REWARD = "EVENT_BOSS_SINGLE_GET_REWARD", --领取积分奖励 + EVENT_FUBEN_SINGLE_BOSS_SYNC = "EVENT_FUBEN_SINGLE_BOSS_SYNC", --数据刷新 + EVENT_FUBEN_SINGLE_BOSS_RESET = "EVENT_FUBEN_SINGLE_BOSS_RESET", --数据周重置 + EVENT_FUBEN_SINGLE_BOSS_RANK_SYNC = "EVENT_FUBEN_SINGLE_BOSS_RANK_SYNC", --排行刷新 + + -- 礼包更新 + EVENT_LB_UPDATE = "EVENT_LB_UPDATE", --礼包 + EVENT_YK_UPDATE = "EVENT_YK_UPDATE", --月卡数据更新 + -- 礼包过期通知 + EVENT_LB_EXPIRE_NOTIFY = "EVENT_LB_EXPIRE_NOTIFY", + + -- 充值 + EVENT_CARD_REFRESH_WELFARE_BTN = "EVENT_CARD_REFRESH_WELFARE_BTN", + EVENT_DAYLY_REFESH_RECHARGE_BTN = "EVENT_DAYLY_REFESH_RECHARGE_BTN", + + -- 查询角色数据返回 + EVENT_REQUEST_PLAYER_INFO_BACK = "EVENT_REQUEST_PLAYER_INFO_BACK", + + -- 打脸 + EVENT_AUTO_WINDOW_STOP = "EVENT_AUTO_WINDOW_STOP", -- 打脸暂停 + EVENT_AUTO_WINDOW_END = "EVENT_AUTO_WINDOW_END", -- 打脸结束 + + -- 宿舍打工Reward + EVENT_DORM_WORK_REDARD = "EVENT_DORM_WORK_REDARD", + + -- 宿舍打工重置 + EVENT_DORM_WORK_RESET = "EVENT_DORM_WORK_RESET", + + -- 宿舍代工 + EVENT_DORM_DAI_GONE_REWARD = "EVENT_DORM_DAI_GONE_REWARD", + + -- 宿舍跳转 + EVENT_DORM_SKIP = "EVENT_DORM_SKIP", + EVENT_DORM_CLOSE_DETAIL = "EVENT_DORM_CLOSE_DETAIL", + + -- 拍照 + EVENT_PHOTO_ENTER = "EVENT_PHOTO_ENTER", -- 进入拍照状态 + EVENT_PHOTO_LEAVE = "EVENT_PHOTO_LEAVE", -- 离开拍照状态 + EVENT_PHOTO_CHANGE_SCENE = "EVENT_PHOTO_CHANGE_SCENE", -- 切换场景 + EVENT_PHOTO_CHANGE_MODEL = "EVENT_PHOTO_CHANGE_MODEL", -- 切换模型 + EVENT_PHOTO_PLAY_ACTION = "EVENT_PHOTO_PLAY_ACTION", -- 播放动作 + EVENT_PHOTO_PHOTOGRAPH = "EVENT_PHOTO_PHOTOGRAPH", -- 拍照 + + -- 爱护 + EVENT_CARESS_SHOW = "EVENT_CARESS_SHOW", + + -- 累计充值更新 + EVENT_ACCUMULATED_UPDATE = "EVENT_ACCUMULATED_UPDATE", + + -- 累计充值奖励领取 + EVENT_ACCUMULATED_REWARD = "EVENT_ACCUMULATED_REWARD", + + -- 宿舍二级界面显示情况 + EVENT_DORM_SECOND_STATE = "EVENT_DORM_SECOND_STATE", + + -- 抽奖活动奖池数改变 + EVENT_DRAW_ACTIVITYCOUNT_CHANGE = "EVENT_DRAW_ACTIVITYCOUNT_CHANGE", + + -- 抽奖活动奖池变化 + EVENT_DRAW_ACTIVITYDRAW_CHANGE = "EVENT_DRAW_ACTIVITYDRAW_CHANGE", + + --试玩区完成情况发生改变 + EVENT_UPDATE_EXPERIMENT = "EVENT_UPDATE_EXPERIMENT", + EVENT_EXPERIMENT_GET_STAR_REWARD = "EVENT_EXPERIMENT_GET_STAR_REWARD", -- 领取试玩区带有目标的奖励 + + -- 节日活动节目刷新 + EVENT_ON_FESTIVAL_CHANGED = "EVENT_ON_FESTIVAL_CHANGED", + + -- 极地活动 + EVENT_BRIEF_CHANGE_TAB = "EVENT_BRIEF_CHANGE_TAB", + + -- 宿舍访问跳转 + EVENT_DORM_VISTOR_SKIP = "EVENT_DORM_VISTOR_SKIP", + + -- 巴别塔刷新 + EVENT_BABEL_STAGE_INFO_ASYNC = "EVENT_BABEL_STAGE_INFO_ASYNC", + EVENT_BABEL_RESET_STATUES_CHANGED = "EVENT_BABEL_RESET_STATUES_CHANGED", + EVENT_BABEL_ACTIVITY_STATUS_CHANGED = "EVENT_BABEL_ACTIVITY_STATUS_CHANGED", + EVNET_BABEL_CHALLENGE_BUFF_CHANGED = "EVNET_BABEL_CHALLENGE_BUFF_CHANGED", + + -- 爬塔活动 + EVENT_ROGUELIKE_ACTIONPOINT_CHARACTER_CHANGED = "EVENT_ROGUELIKE_ACTIONPOINT_CHARACTER_CHANGED", --出站角色、行动点改变 + EVENT_ROGUELIKE_ASSISTROBOT_CHANGED = "EVENT_ROGUELIKE_ASSISTROBOT_CHANGED", --支援角色改变 + EVENT_ROGUELIKE_REFRESH_ALLNODES = "EVENT_ROGUELIKE_REFRESH_ALLNODES", --刷新节点 + EVENT_ROGUELIKE_BUFFIDS_CHANGES = "EVENT_ROGUELIKE_BUFFIDS_CHANGES", --玩家buff改变 + EVENT_ROGUELIKE_TEAMEFFECT_CHANGES = "EVENT_ROGUELIKE_TEAMEFFECT_CHANGES", --队伍效果改变 + EVENT_ROGUELIKE_NODE_ADJUSTION = "EVENT_ROGUELIKE_NODE_ADJUSTION", --节点位置调整 + EVENT_ROGUELIKE_TASK_RESET = "EVENT_ROGUELIKE_TASK_RESET", --重置任务 + EVENT_ROGUELIKE_ILLEGAL_SHOP_RESET = "EVENT_ROGUELIKE_ILLEGAL_SHOP_RESET", --重置黑市商店 + EVENT_ROGUELIKE_SECTIONTYPE_CHANGE = "EVENT_ROGUELIKE_SECTIONType_CHANGE", --试炼模式开启 + EVENT_ROGUELIKE_SECTION_REFRESH = "EVENT_ROGUELIKE_SECTION_REFRESH", --重置进度 + EVENT_ROGUELIKE_TRIALPOINT_CHANGE = "EVENT_ROGUELIKE_TRIALPOINT_CHANGE", --积分更新 + + -- 公会系统 + EVENT_GUILD_RECEIVE_CHAT = "EVENT_GUILD_RECEIVE_CHAT", --公会收到消息 + EVENT_GUILD_UPDATE_MEMBER_INFO = "EVENT_GUILD_UPDATE_MEMBER_INFO", --刷新公会信息,只刷不增加 + EVENT_GUILD_ALLRANKNAME_UPDATE = "EVENT_GUILD_ALLRANKNAME_UPDATE", --公会自定义职位修改 + EVENT_GUILD_LEVEL_CHANGED = "EVENT_GUILD_LEVEL_CHANGED", --公会等级变化 + EVENT_GUILD_MAINTAIN_STATE_CHANGED = "EVENT_GUILD_MAINTAIN_STATE_CHANGED", --公会维护状态变化 + EVENT_GUILD_BUILD_CHANGED = "EVENT_GUILD_BUILD_CHANGED", --公会建设度变化 + EVENT_GUILD_CONTRIBUTE_CHANGED = "EVENT_GUILD_CONTRIBUTE_CHANGED", --公会贡献变化 + EVENT_GUILD_GIFT_CONTRIBUTE_CHANGED = "EVENT_GUILD_GIFT_CONTRIBUTE_CHANGED", --公会礼包贡献进度变化 + EVENT_GUILD_APPLY_LIST_CHANGED = "EVENT_GUILD_APPLY_LIST_CHANGED", --公会申请列表变化 + EVENT_GUILD_MEMBER_CONTRIBUTE_CONDITION = "EVENT_GUILD_MEMBER_CONTRIBUTE_CONDITION", --公会成员领取贡献 + EVENT_GUILD_RANKLEVEL_CHANGED = "EVENT_GUILD_RANKLEVEL_CHANGED", --公会职位变化 + EVENT_GUILD_WEEKLY_RESET = "EVENT_GUILD_WEEKLY_RESET", --公会周重置 + EVENT_GUILD_LEADER_DISSMISS = "EVENT_GUILD_LEADER_DISSMISS", --会长罢免 + EVENT_GUILD_NOTICE = "EVENT_GUILD_NOTICE", --公会消息同步 + EVENT_GUILD_NAME_CHANGED = "EVENT_GUILD_NAME_CHANGED", -- 公会名称变化 + EVENT_GUILD_DECLARATION_CHANGED = "EVENT_GUILD_DECLARATION_CHANGED", -- 公会宣言变化 + EVENT_GUILD_INTERCOM_CHANGED = "EVENT_GUILD_INTERCOM_CHANGED", -- 公会内部通讯变化 + EVENT_GUILD_FILTER_FINISH = "EVENT_GUILD_FILTER_FINISH", -- 返回过滤后的内容 + EVENT_GUILD_TALENT_ASYNC = "EVENT_GUILD_TALENT_ASYNC", --公会天赋变化 + EVNET_GUILD_LEADER_NAME_CHANGED = "EVNET_GUILD_LEADER_NAME_CHANGED", --队长职位变化 + EVNET_GUILD_LEADER_CHANGED = "EVNET_GUILD_LEADER_CHANGED", --队员数据变化 + EVENT_GUILD_MEMBERCOUNT_CHANGED = "EVENT_GUILD_MEMBERCOUNT_CHANGED", --队员人数变化 + EVENT_GUILD_RECRUIT_LIST_CHANGED = "EVENT_GUILD_RECRUIT_LIST_CHANGED", --招募列表变化 + EVENT_GUILD_MEMBER_SET = "EVENT_GUILD_MEMBER_SET", --点击成员的设置面板 + + --工会boss + EVENT_GUILDBOSS_HPBOX_CHANGED = "EVENT_GUILDBOSS_HPBOX_CHANGED", --有工会bosshp奖励可以领 + EVENT_GUILDBOSS_SCOREBOX_CHANGED = "EVENT_GUILDBOSS_SCOREBOX_CHANGED", --有工会boss积分奖励可以领 + + --充值失败 + EVNET_FAIL_PAY = "EVNET_FAIL_PAY", + EVENT_HGSDK_SETPASS_RESULT = "EVENT_HGSDK_SETPASS_RESULT", + EVENT_LOGIN_ATTENTION = "EVENT_LOGIN_ATTENTION", + + --图鉴系统 + EVNET_ARCHIVE_MONSTER_KILLCOUNTCHANGE = "EVNET_ARCHIVE_MONSTER_KILLCOUNTCHANGE", --怪物击杀(任一怪物)数发生改变 + EVNET_ARCHIVE_MONSTER_UNLOCKMONSTER = "EVNET_ARCHIVE_MONSTER_UNLOCKMONSTER", --消除新怪红点 + EVNET_ARCHIVE_MONSTER_UNLOCKMONSTERINFO = "EVNET_ARCHIVE_MONSTER_UNLOCKMONSTERINFO", --消除怪物新信息红点 + EVNET_ARCHIVE_MONSTER_UNLOCKMONSTERSKILL = "EVNET_ARCHIVE_MONSTER_UNLOCKMONSTERSKILL", --消除怪物新技能红点 + EVNET_ARCHIVE_MONSTER_UNLOCKMONSTERSETTING = "EVNET_ARCHIVE_MONSTER_UNLOCKMONSTERSETTING", --消除怪物新设定红点 + + EVENET_ARCHIVE_NEW_WEAPON = "EVENET_ARCHIVE_NEW_WEAPON", --新的武器 + EVENET_ARCHIVE_UNLOCK_WEAPON = "EVENET_ARCHIVE_UNLOCK_WEAPON", --记录武器的红点 + EVENET_ARCHIVE_UNLOCK_WEAPON_SETTING = "EVENET_ARCHIVE_UNLOCK_WEAPON_SETTING", --记录武器设定的红点 + EVENET_ARCHIVE_NEW_AWARENESS_SUIT = "EVENET_ARCHIVE_NEW_AWARENESS_SUIT", --新的意识套装的红点 + EVENET_ARCHIVE_UNLOCK_AWARENESS_SUIT = "EVENET_ARCHIVE_UNLOCK_AWARENESS_SUIT", --记录意识的红点 + EVENET_ARCHIVE_UNLOCK_AWARENESS_SETTING = "EVENET_ARCHIVE_UNLOCK_AWARENESS_SETTING", --记录意识设定的红点 + + EVENET_ARCHIVE_NEW_CG = "EVENET_ARCHIVE_NEW_CG", --新的CG + EVENET_ARCHIVE_MARK_CG = "EVENET_ARCHIVE_MARK_CG", --解除新CG红点 + --剧情 + EVENT_MOVIE_BREAK_BLOCK = "EVENT_MOVIE_BREAK_BLOCK", --推动剧情下一步进展 + EVENT_MOVIE_UI_OPEN = "EVENT_MOVIE_UI_OPEN", + EVENT_MOVIE_UI_DESTROY = "EVENT_MOVIE_UI_DESTROY", + EVENT_MOVIE_UI_CLOSED = "EVENT_MOVIE_UI_CLOSED",--剧情UI完全关闭,所有节点清理行为结束 + EVENT_MOVIE_AUTO_PLAY = "EVENT_MOVIE_AUTO_PLAY", + + -- 狙击战 + EVENT_UNIONKILL_BOSSCOUNTCHANGE = "EVENT_UNIONKILL_BOSSCOUNTCHANGE", --击杀boss次数变化 + EVENT_UNIONKILL_STAGEINFOCHANGE = "EVENT_UNIONKILL_STAGEINFOCHANGE", --关卡数据变化 + EVENT_UNIONKILL_PLAYERINFOCHANGE = "EVENT_UNIONKILL_PLAYERINFOCHANGE", --玩家信息变化 + EVENT_UNIONKILL_BOSSHPCHANGE = "EVENT_UNIONKILL_BOSSHPCHANGE", --boss血量变化 + EVENT_UNIONKILL_LEAVEROOM = "EVENT_UNIONKILL_LEAVEROOM", --通知玩家离开房间 + EVENT_UNIONKILL_TIPSMESSAGE = "EVENT_UNIONKILL_TIPSMESSAGE", --通知消息 + EVENT_UNIONKILL_ROOMDATANOTIFY = "EVENT_UNIONKILL_ROOMDATANOTIFY", --收到进入联机副本消息 + EVENT_UNIONKILL_ACTIVITYINFO = "EVENT_UNIONKILL_ACTIVITYINFO", --活动信息变化 + EVENT_UNIONKILL_FIGHTSTATUS = "EVENT_UNIONKILL_FIGHTSTATUS", --战斗状态变化 + + EVENT_UNIONKILLROOM_MATCHRESULT = "EVENT_UNIONKILLROOM_MATCHRESULT", --匹配到房间 + EVENT_UNIONKILLROOM_KICKOUT = "EVENT_UNIONKILLROOM_KICKOUT", --被踢出队伍 + EVENT_UNIONKILLROOM_LEADER_CHANGED = "EVENT_UNIONKILLROOM_LEADER_CHANGED", --队长改变 + EVENT_UNIONKILLROOM_PLAYERSTATE_CHANGED = "EVENT_UNIONKILLROOM_PLAYERSTATE_CHANGED", --玩家状态改变 + EVENT_UNIONKILLROOM_FIGHTNPC_CHANGED = "EVENT_UNIONKILLROOM_FIGHTNPC_CHANGED", --玩家出站角色改变 + EVENT_UNIONKILLROOM_PLAYERENTER = "EVENT_UNIONKILLROOM_PLAYERENTER", --有玩家加入 + EVENT_UNIONKILLROOM_PLAYERLEAVE = "EVENT_UNIONKILLROOM_PLAYERLEAVE", --玩家离开 + EVENT_UNIONKILLROOM_AUTOMATCHCHANGE = "EVENT_UNIONKILLROOM_AUTOMATCHCHANGE", --快速匹配变化 + + --工会boss + EVENT_GUILDBOSS_UPDATEDIFF = "EVENT_GUILDBOSS_UPDATEDIFF", --设置下期难度后刷新难度页面 + EVENT_GUILDBOSS_UPDATEORDER = "EVENT_GUILDBOSS_UPDATEORDER", --设置战术布局后刷新难度页面 + + -- 边界公约 + EVENT_FUBEN_ASSIGN_STAGE_CLICK = "EVENT_FUBEN_ASSIGN_STAGE_CLICK", -- 点击关卡组 + EVENT_FUBEN_ASSIGN_STAGE_DETAIL_CLOSE = "EVENT_FUBEN_ASSIGN_STAGE_DETAIL_CLOSE", -- 关闭出战准备界面 + EVENT_FUBEN_ASSIGN_FORMATION_CONFIRM = "EVENT_FUBEN_ASSIGN_FORMATION_CONFIRM", -- 编队保存 + EVENT_ASSIGN_SELECT_OCCUPY_BEGIN = "EVENT_ASSIGN_SELECT_OCCUPY_BEGIN", -- 选择了驻守成员 + EVENT_ASSIGN_SELECT_OCCUPY_END = "EVENT_ASSIGN_SELECT_OCCUPY_END", -- 确认了所选的驻守成员 + EVENT_ON_ASSIGN_TEAM_CHANGED = "EVENT_ON_ASSIGN_TEAM_CHANGED", + EVENT_ASSIGN_REFRESH_FORMATION = "EVENT_ASSIGN_REFRESH_FORMATION", -- 刷新编队界面 + EVENET_ASSIGN_CAN_REWARD = "EVENET_ASSIGN_CAN_REWARD", -- 可领奖红点 + EVENT_REFRESH_CHRACTER_ABLIITY = "EVENT_REFRESH_CHRACTER_ABLIITY", -- 刷新战力 + + --回归活动 + EVENT_REGRESSION_OPEN_STATUS_UPDATE = "EVENT_REGRESSION_OPEN_STATUS_UPDATE", -- 回归活动状态更新 + EVENT_REGRESSION_TASK_SCHEDULE_UPDATE = "EVENT_REGRESSION_TASK_SCHEDULE_UPDATE", -- 回归活动进度和进度奖励刷新 + EVENT_REGRESSION_TASK_SCHEDULE_REWARD_GET = "EVENT_REGRESSION_TASK_SCHEDULE_REWARD_GET", --获取回归活动任务进度奖励 + EVENT_REGRESSION_SEND_INVITATION_INFO_UPDATE = "EVENT_REGRESSION_SEND_INVITATION_INFO_UPDATE", -- 获取邀请他人信息更新 + + -- 战斗字幕 + EVENT_FIGHT_WORDS_NEXT = "EVENT_FIGHT_WORDS_NEXT", -- 战斗字幕播放下一条 + + -- 区域联机 + EVENT_ARENAONLINE_WEEK_REFRESH = "EVENT_ARENAONLINE_WEEK_REFRESH", --区域连接周更新 + EVENT_ARENAONLINE_DAY_REFRESH = "EVENT_ARENAONLINE_DAY_REFRESH", --区域连接日更新 + + -- 看图作文 + EVENT_PICCOMPOSITION_GET_WORD = "EVENT_PICCOMPOSITION_GET_WORD", --获取屏蔽词 + EVENT_PICCOMPOSITION_GET_RANKDATA = "EVENT_PICCOMPOSITION_GET_RANKDATA", --获取排行数据 + EVENT_PICCOMPOSITION_GET_OTHERDATA = "EVENT_PICCOMPOSITION_GET_OTHERDATA", --获取过审作品数据 + EVENT_PICCOMPOSITION_GET_MYDATA = "EVENT_PICCOMPOSITION_GET_MYDATA", --获取自己作品数据 + + -- 副本商店 + EVENT_FUBEN_DAILY_SHOP_CHECK_NEW = "EVENT_FUBEN_DAILY_SHOP_CHECK_NEW", --获取套装更新 + + --特训关 + EVENT_FUBEN_SPECIAL_TRAIN_REWARD = "EVENT_FUBEN_SPECIAL_TRAIN_REWARD", --领奖 + EVENT_FUBEN_SPECIAL_TRAIN_ACTIVITY_CHANGE = "EVENT_FUBEN_SPECIAL_TRAIN_ACTIVITY_CHANGE", --领奖 + + --小游戏 + EVENT_ELIMINATEGAME_GET_REWARD = "EVENT_ELIMINATEGAME_GET_REWARD", --领奖 + EVENT_ELIMINATEGAME_RESET = "EVENT_ELIMINATEGAME_RESET", --重置 + + -- 点消小游戏 + EVENT_CLICKCLEARGAME_INIT_COMPLETE = "EVENT_CLICKCLEARGAME_INIT_COMPLETE", --点消小游戏初始化完成 + EVENT_CLICKCLEARGAME_HEAD_COUNT_CHANGED = "EVENT_CLICKCLEARGAME_HEAD_COUNT_CHANGED", -- 头像数据更新 + EVENT_CLICKCLEARGAME_GAME_PLAYING = "EVENT_CLICKCLEARGAME_GAME_PLAYING", -- 游戏开始游玩 + EVENT_CLICKCLEARGAME_GAME_PAUSE = "EVENT_CLICKCLEARGAME_GAME_PAUSE", -- 游戏暂停 + EVENT_CLICKCLEARGAME_GAME_ACCOUNT = "EVENT_CLICKCLEARGAME_GAME_ACCOUNT", -- 点消小游戏结算 + EVENT_CLICKCLEARGAME_GAME_RESET = "EVENT_CLICKCLEARGAME_GAME_RESET", -- 点消小游戏重置 + EVENT_CLICKCLEARGAME_GAME_PAGE_CHANGED = "XEventId.EVENT_CLICKCLEARGAME_GAME_PAGE_CHANGED", -- 头像页发生变动 + EVENT_CLICKCLEARGAME_TAKED_REWARD = "EVENT_CLICKCLEARGAME_TAKED_REWARD", -- 领取小游戏奖励 + EVENT_CLICKCLEARGAME_FINISHED_GAME = "EVENT_CLICKCLEARGAME_FINISHED_GAME", -- 点消小游戏完成 + + -- 拼图小游戏 + EVENT_DRAG_PUZZLE_GAME_GET_PIECE = "EVENT_DRAG_PUZZLE_GAME_GET_PIECE", -- 获取了拼图碎片 + EVENT_DRAG_PUZZLE_GAME_PUZZLE_CHANGED = "EVENT_DRAG_PUZZLE_GAME_PUZZLE_CHANGED", -- 拼图数据发生改变 + EVENT_DRAG_PUZZLE_GAME_PUZZLE_COMPLETE = "EVENT_DRAG_PUZZLE_GAME_PUZZLE_COMPLETE", -- 拼图完成 + EVENT_DRAG_PUZZLE_GAME_GOT_REWARD = "EVENT_DRAG_PUZZLE_GAME_GOT_REWARD", -- 获取了奖励 + EVENT_DRAG_PUZZLE_GAME_PLAYED_VIDEO = "EVENT_DRAG_PUZZLE_GAME_PLAYED_VIDEO", -- 播放了通关剧情 + EVENT_DRAG_PUZZLE_GAME_PUZZLE_DECRYPTION = "EVENT_DRAG_PUZZLE_GAME_PUZZLE_DECRYPTION", -- 进入解密状态 + EVENT_DRAG_PUZZLE_GAME_CHANGE_PASSWORD = "EVENT_DRAG_PUZZLE_GAME_CHANGE_PASSWORD", -- 更改解密密码 + EVENT_DRAG_PUZZLE_GAME_PUZZLE_CHECK_WORD_ERROR = "EVENT_DRAG_PUZZLE_GAME_PUZZLE_CHECK_WORD_ERROR", -- 校验了密码 + + -- 圣诞树装饰小游戏 + EVENT_CHRISTMAS_TREE_ORNAMENT_ACTIVE = "EVENT_CHRISTMAS_TREE_ORNAMENT_ACTIVE", -- 获取了饰品 + EVENT_CHRISTMAS_TREE_ORNAMENT_READ = "EVENT_CHRISTMAS_TREE_ORNAMENT_READ", -- 使用了饰品 + EVENT_CHRISTMAS_TREE_GOT_REWARD = "EVENT_CHRISTMAS_TREE_GOT_REWARD", -- 领取了奖励 + + -- 春节对联小游戏 + EVENT_COUPLET_GAME_GET_WORD = "EVENT_COUPLET_GAME_GET_WORD", -- 获取了文字 + EVENT_COUPLET_GAME_COMPLETE = "EVENT_COUPLET_GAME_COMPLETE", -- 成功完成对联 + EVENT_COUPLET_GAME_SENTENCE_ERROR = "EVENT_COUPLET_GAME_SENTENCE_ERROR", -- 校验对联失败 + EVENT_COUPLET_GAME_CHANGE_WORD = "EVENT_COUPLET_GAME_CHANGE_WORD", -- 交换了文字 + EVENT_COUPLET_GAME_FINISH_TASK = "EVENT_COUPLET_GAME_FINISH_TASK", -- 领取了任务奖励 + EVENT_COUPLET_GAME_PLAYED_VIDEO = "EVENT_COUPLET_GAME_PLAYED_VIDEO", -- 播放剧情 + + --武器涂装 + EVENT_FASHION_WEAPON_EXPIRED_REFRESH = "EVENT_FASHION_WEAPON_EXPIRED_REFRESH", --武器涂装过期刷新 + + --感染体玩法 + EVENT_INFESTOREXPLORE_REFRESH_PALYER_RANK = "EVENT_INFESTOREXPLORE_REFRESH_PALYER_RANK", --第一阶段玩家排行数据更新 + EVENT_INFESTOREXPLORE_SELECT_CORE = "EVENT_INFESTOREXPLORE_SELECT_CORE", --选择核心刷新弹窗UI + EVENT_INFESTOREXPLORE_CORE_PUTON = "EVENT_INFESTOREXPLORE_CORE_PUTON", --穿戴核心 + EVENT_INFESTOREXPLORE_CORE_TAKEOFF = "EVENT_INFESTOREXPLORE_CORE_TAKEOFF", --脱下核心 + EVENT_INFESTOREXPLORE_CORE_DECOMPOESE = "EVENT_INFESTOREXPLORE_CORE_DECOMPOESE", --分解核心 + EVENT_INFESTOREXPLORE_MOVE_TO_NEXT_NODE = "EVENT_INFESTOREXPLORE_MOVE_TO_NEXT_NODE", --移动到下一节点 + EVENT_INFESTOREXPLORE_CHAPTER_FINISH = "EVENT_INFESTOREXPLORE_CHAPTER_FINISH", --章节完成 + EVENT_FIGHT_INFESTOR_SCORE_CHANGE = "EVENT_FIGHT_INFESTOR_SCORE_CHANGE", --讨伐值变化 + EVENT_INFESTOREXPLORE_CONTRACT_DAILY_RESET = "EVENT_INFESTOREXPLORE_CONTRACT_DAILY_RESET", --灾厄合约每日重置 + EVENT_INFESTOREXPLORE_CHARACTER_HP_CHANGE = "EVENT_INFESTOREXPLORE_CHARACTER_HP_CHANGE", --队伍成员血量变化 + EVENT_INFESTOREXPLORE_RESET = "EVENT_INFESTOREXPLORE_RESET", --玩法阶段重置 + + --剧情相关 + EVENT_MOVIE_BEGIN = "EVENT_MOVIE_BEGIN", --开始播放剧情 + EVENT_MOVIE_END = "EVENT_MOVIE_END", --剧情结束 + --水上乐园 + EVENT_STORY_DISTORY = "EVENT_STORY_DISSTORY", --关闭新星辰剪影 + --虚像地平线 + EVENT_EXPEDITION_ACTIVECOMBOLIST_CHANGE = "EVENT_EXPEDITION_ACTIVECOMBOLIST_CHANGE", --激活羁绊发生变动时 + EVENT_EXPEDITION_MEMBERLIST_CHANGE = "EVENT_EXPEDITION_MEMBERLIST_CHANGE", --成员发生变动时 + EVENT_EXPEDITION_RECRUIT_REFRESH = "EVENT_EXPEDITION_RECRUIT_REFRESH", --招募成员刷新时 + EVENT_EXPEDITION_RECRUITTIME_REFRESH = "EVENT_EXPEDITION_RECRUITTIME_REFRESH", --招募次数刷新时 + EVENT_EXPEDITION_RANKING_REFRESH = "EVENT_EXPEDITION_RANKING_REFRESH", --排行榜刷新 + EVENT_EXPEDITION_COMMENTS_RECEIVE = "EVENT_EXPEDITION_COMMENTS_RECEIVE", --接收评论时 + EVENT_EXPEDITION_COMMENTS_DOLIKE = "EVENT_EXPEDITION_COMMENTS_DOLIKE", --点赞成功时 + EVENT_EXPEDITION_COMMENTS_SEND = "EVENT_EXPEDITION_COMMENTS_SEND", --发送自己信息成功时 + EVENT_EXPEDITION_ON_GET_CHAPTER_REWARD = "EVENT_EXPEDITION_ON_GET_CHAPTER_REWARD", --获取到章节奖励 + --世界boss相关 + EVENT_WORLDBOSS_SYNCDATA = "EVENT_WORLDBOSS_SYNCDATA", --同步世界boss公共数据 + EVENT_WORLDBOSS_TASK_RESET = "EVENT_WORLDBOSS_TASK_RESET", --重置任务 + EVENT_WORLDBOSS_REPORT = "EVENT_WORLDBOSS_REPORT", --同步战报 + --兵法蓝图 + EVENT_RPGTOWER_RESET = "EVENT_RPGTOWER_RESET", -- 兵法蓝图角色数据重置 + EVENT_RPGTOWER_MEMBERCHANGE = "EVENT_RPGTOWER_MEMBERCHANGE", -- 兵法蓝图角色数据变化时 + EVENT_RPGTOWER_ON_LEVELUP = "EVENT_RPGTOWER_ON_LEVELUP", -- 兵法蓝图角色升级成功时 + EVENT_RPGTOWER_ON_TALENT_UNLOCK = "EVENT_RPGTOWER_ON_TALENT_UNLOCK", -- 兵法蓝图角色天赋解锁成功时 + EVENT_RPGTOWER_REFRESH_DAILYREWARD = "EVENT_RPGTOWER_REFRESH_DAILYREWARD", -- 兵法蓝图获取每日补给 + --大富翁 + EVENT_MAINTAINERACTION_DAY_UPDATA = "EVENT_MAINTAINERACTION_DAY_UPDATA", --日更新 + EVENT_MAINTAINERACTION_WEEK_UPDATA = "EVENT_MAINTAINERACTION_WEEK_UPDATA", --周更新 + EVENT_MAINTAINERACTION_USECARD = "EVENT_MAINTAINERACTION_USECARD", --用卡 + EVENT_MAINTAINERACTION_SELECTCARD = "EVENT_MAINTAINERACTION_SELECTCARD", --选卡 + EVENT_MAINTAINERACTION_NODE_CHANGE = "EVENT_MAINTAINERACTION_NODE_CHANGE", --更换地图节点 + --跑团玩法 + EVENT_TRPG_MAZE_MOVE_NEXT = "EVENT_TRPG_MAZE_MOVE_NEXT", --迷宫前进 + EVENT_TRPG_MAZE_MOVE_TO = "EVENT_TRPG_MAZE_MOVE_TO", --迷宫跳转 + EVENT_TRPG_MAZE_RESTART = "EVENT_TRPG_MAZE_RESTART", --迷宫重新开始 + EVENT_TRPG_MAZE_RECORD_CARD = "EVENT_TRPG_MAZE_RECORD_CARD", --迷宫新增卡牌记录 + EVENT_TRPG_UPDATE_TARGET = "EVENT_TRPG_UPDATE_TARGET", --通知刷新目标 + EVENT_TRPG_WORLDBOSS_SYNCDATA = "EVENT_TRPG_WORLDBOSS_SYNCDATA", --同步世界boss数据 + EVENT_TRPG_EXAMINE_DATA_CHANGE = "EVENT_TRPG_EXAMINE_DATA_CHANGE", --检定数据改变 + EVENT_TRPG_EXAMINE_RESULT_SYN = "EVENT_TRPG_EXAMINE_RESULT_SYN", --检定结果通知 + EVENT_TRPG_EXAMINE_ROUND_CHANGE = "EVENT_TRPG_EXAMINE_ROUND_CHANGE", --检定轮次变更 + EVENT_TRPG_ROLES_DATA_CHANGE = "EVENT_TRPG_ROLES_DATA_CHANGE", --调查员数据改变 + EVENT_TRPG_FUNCTION_FINISH_SYN = "EVENT_TRPG_FUNCTION_FINISH_SYN", --功能完成通知 + EVENT_TRPG_SHOP_INFO_CHANGE = "EVENT_TRPG_SHOP_INFO_CHANGE", --商店数据发生改变 + EVENT_TRPG_BASE_INFO_CHANGE = "EVENT_TRPG_BASE_INFO_CHANGE", --经验、等级、耐力发生改变 + EVENT_TRPG_GET_MEMOIR_REWARD = "EVENT_TRPG_GET_MEMOIR_REWARD", --成功领取珍藏奖励 + EVENT_TRPG_GET_REWARD = "EVENT_TRPG_GET_REWARD", --成功领取奖励 + EVENT_TRPG_BOSS_HP_SYN = "EVENT_TRPG_BOSS_HP_SYN", --跑团世界BOSS血量通知 + EVENT_TRPG_FIRST_OPEN_TRUTH_ROAD = "EVENT_TRPG_FIRST_OPEN_TRUTH_ROAD", --首次打开求真之路 + EVENT_TRPG_FIRST_OPEN_COLLECTION = "EVENT_TRPG_FIRST_OPEN_COLLECTION", --首次打开珍藏 + EVENT_TRPG_OPEN_LEVEL_DIALOG = "EVENT_TRPG_OPEN_LEVEL_DIALOG", --打开等级说明弹窗 + + --师徒系统 + EVENT_CHAT_RECEIVE_MENTOR_MSG = "EVENT_CHAT_RECEIVE_MENTOR_MSG", --收到师徒聊天信息 + EVENT_MENTOR_GET_APPLY = "EVENT_MENTOR_GET_APPLY", --收到一条申请 + EVENT_MENTOR_OPERATION_APPLY = "EVENT_MENTOR_OPERATION_APPLY", --处理申请 + EVENT_MENTOR_GET_TEACHER = "EVENT_MENTOR_GET_TEACHER", --得到一个老师 + EVENT_MENTOR_GET_STUDENT = "EVENT_MENTOR_GET_STUDENT", --得到一个学生 + EVENT_MENTOR_LOSE_TEACHER = "EVENT_MENTOR_LOSE_TEACHER", --失去一个老师 + EVENT_MENTOR_LOSE_STUDENT = "EVENT_MENTOR_LOSE_STUDENT", --失去一个学生 + EVENT_MENTOR_TEACHERORSTUDENT_CHANGE = "EVENT_MENTOR_TEACHERORSTUDENT_CHANGE", --师生列表发生改变 + EVENT_MENTOR_SHIPCHANGE = "EVENT_MENTOR_SHIPCHANGE", --身份转变 + EVENT_MENTOR_CAN_GRADUATE = "EVENT_MENTOR_CAN_GRADUATE", --可毕业通知 + EVENT_MENTOR_GRADUATE_STUDENT = "EVENT_MENTOR_GRADUATE_STUDENT", --毕业一个学生 + EVENT_MENTOR_STUDENT_SYSTEMTASK_CHANGE = "EVENT_MENTOR_STUDENT_SYSTEMTASK_CHANGE", --学生的系统任务发生改变(学生身份) + EVENT_MENTOR_STUDENT_WEEKLYTASK_CHANGE = "EVENT_MENTOR_STUDENT_WEEKLYTASK_CHANGE", --学生的已接任务状态发生改变(学生身份) + EVENT_MENTOR_STUDENT_TASKCOUNT_CHANGE = "EVENT_MENTOR_STUDENT_TASKCOUNT_CHANGE", --学生的完成任务数发生改变 + EVENT_MENTOR_TEACHER_STUDENTWEEKLYTASK_CHANGE = "EVENT_MENTOR_TEACHER_STUDENTWEEKLYTASK_CHANGE", --学生的已接任务状态发生改变(老师身份) + EVENT_MENTOR_TEACHER_STUDENTSYSTEMTASK_CHANGE = "EVENT_MENTOR_TEACHER_STUDENTSYSTEMTASK_CHANGE", --学生的系统任务发生改变(老师身份) + EVENT_MENTOR_GETREWARD = "EVENT_MENTOR_GETREWARD", --学生或老师领取奖励 + EVENT_MENTOR_INTASKUI = "EVENT_MENTOR_INTASKUI", --进任务界面 + EVENT_MENTOR_DAY_RESET = "EVENT_MENTOR_DAY_RESET", --日更新 + EVENT_MENTOR_WEEK_RESET = "EVENT_MENTOR_WEEK_RESET", --周更新 + EVENT_MENTOR_TEACHER_CHANGECOUNT_PLUS = "EVENT_MENTOR_TEACHER_CHANGECOUNT_PLUS", --任务可更变数增加 + EVENT_MENTOR_MEMBERLEVEL_CHANGE = "EVENT_MENTOR_MEMBERLEVEL_CHANGE", --成员(老师/学生)等级改变 + EVENT_MENTOR_AUTO_GRADUATE = "EVENT_MENTOR_AUTO_GRADUATE", --到达等级后自动毕业 + EVENT_MENTOR_TEACHER_MONTHLYSTUDENTCOUNT_UPDATE = "EVENT_MENTOR_TEACHER_MONTHLYSTUDENTCOUNT_UPDATE", --通知老师本月已招募学员数改变 + EVENT_MENTOR_MESSAGE_UPDATE = "EVENT_MENTOR_MESSAGE_UPDATE", --通知所有人留言改变 + EVENT_MENTOR_ONLINE_UPDATE = "EVENT_MENTOR_ONLINE_UPDATE", --通知所有人在线状态 + EVENT_MENTOR_TEACHER_ACTIVATION_UPDATE = "EVENT_MENTOR_TEACHER_ACTIVATION_UPDATE",--通知老师获得活跃度礼物 + --尼尔玩法 + EVENT_NIER_ACTIVITY_REFRESH = "EVENT_NIER_ACTIVITY_REFRESH", + EVENT_NIER_ACTIVITY_END = "EVENT_NIER_ACTIVITY_END", + EVENT_NIER_CHARACTER_UPDATE = "EVENT_NIER_CHARACTER_UPDATE", --尼尔角色改变 + EVENT_NIER_POD_UPDATE = "EVENT_NIER_POD_UPDATE", --尼尔辅助机 + EVENT_NIER_REPEAT_CLICK = "EVENT_NIER_REPEAT_CLICK", + + --口袋妖怪 + EVENT_POKEMON_MONSTERS_DATA_CHANGE = "EVENT_POKEMON_MONSTERS_DATA_CHANGE", --怪物信息改变 + EVENT_POKEMON_MONSTERS_LEVEL_UP = "EVENT_POKEMON_MONSTERS_LEVEL_UP", --怪物升级 + EVENT_POKEMON_MONSTERS_STAR_UP = "EVENT_POKEMON_MONSTERS_STAR_UP", --怪物升星 + EVENT_POKEMON_MONSTERS_SKILL_SWITCH = "EVENT_POKEMON_MONSTERS_SKILL_SWITCH", --怪物技能切换 + EVENT_POKEMON_REMAINING_TIMES_CHANGE = "EVENT_POKEMON_REMAINING_TIMES_CHANGE", --剩余次数改变 + EVENT_POKEMON_PASSED_STAGE_CHANGE = "EVENT_POKEMON_PASSED_STAGE_CHANGE", --通关关卡改变 + EVENT_POKEMON_RED_POINT_TIME_SUPPLY = "EVENT_POKEMON_RED_POINT_TIME_SUPPLY", --时间奖励红点 + + --战斗属性同步 + EVENT_ATTRIBUTE_MANAGER_INIT = "EVENT_ATTRIBUTE_MANAGER_INIT", --属性manager初始化完成 + --炸服押注 + EVENT_GUARD_CAMP_ACTIVITY_DATA_CHANGE = "EVENT_GUARD_CAMP_ACTIVITY_DATA_CHANGE", --活动数据发生改变通知 + EVENT_GUARD_CAMP_ACTIVITY_OPEN_STATE_CHANGE = "EVENT_GUARD_CAMP_ACTIVITY_OPEN_STATE_CHANGE", --活动状态发生改变 + + --@region 追击玩法 + + --追击地图更新 + EVENT_CHESSPURSUIT_MAP_UPDATE = "EVENT_CHESSPURSUIT_MAP_UPDATE", + --保存队伍 + EVENT_CHESSPURSUIT_SAVETEAM = "EVENT_CHESSPURSUIT_SAVETEAM", + --战斗胜利 + EVENT_CHESSPURSUIT_FIGHT_FINISH_WIN = "EVENT_CHESSPURSUIT_FIGHT_FINISH_WIN", + --商店买卡 + EVENT_CHESSPURSUIT_BUY_CARD = "EVENT_CHESSPURSUIT_BUY_CARD", + + --@endregion + + --组合小游戏 + EVENT_COMPOSEGAME_BAGITEM_REFRESH = "EVENT_COMPOSEGAME_BAGITEM_REFRESH", --组合小游戏背包道具刷新 + EVENT_COMPOSEGAME_ITEM_COMPOSE = "EVENT_COMPOSEGAME_ITEM_COMPOSE", --组合小游戏道具合成事件 + EVENT_COMPOSEGAME_SHOP_REFRESH_TIME_CHANGE = "EVENT_COMPOSEGAME_SHOP_REFRESH_TIME_CHANGE", --组合小游戏商店刷新次数改变 + EVENT_COMPOSEGAME_SHOP_ITEM_REFRESH = "EVENT_COMPOSEGAME_SHOP_ITEM_REFRESH", --组合小游戏商店商品刷新 + EVENT_COMPOSEGAME_SCHEDULE_REFRESH = "EVENT_COMPOSEGAME_SCHEDULE_REFRESH", --组合小游戏进度刷新 + EVENT_COMPOSEGAME_TREASURE_GET = "EVENT_COMPOSEGAME_TREASURE_GET", --组合小游戏领取宝箱奖励时 + EVENT_COMPOSEGAME_RESET = "EVENT_COMPOSEGAME_RESET", --组合小游戏重置或关闭 + + --伙伴系统 + EVENT_PARTNER_DATAUPDATE = "EVENT_PARTNER_DATAUPDATE", --伙伴数据更新 + EVENT_PARTNER_OBTAIN = "EVENT_PARTNER_OBTAIN", --伙伴获得 + EVENT_PARTNER_SKILLCHANGE = "EVENT_PARTNER_SKILLCHANGE", --伙伴技能变动(等级激活) + EVENT_PARTNER_CARRY = "EVENT_PARTNER_CARRY", --伙伴携带状况变动 + EVENT_PARTNER_SKILLUNLOCK = "EVENT_PARTNER_SKILLUNLOCK", --伙伴技能解锁 + EVENT_PARTNER_QUALITYUP = "EVENT_PARTNER_QUALITYUP", --伙伴品质改变 + EVENT_PARTNER_SKILLUNLOCK_CLOSERED = "EVENT_PARTNER_SKILLUNLOCK_CLOSERED", --关闭技能解锁红点 + EVENT_PARTNER_ABLITYCHANGE = "EVENT_PARTNER_ABLITYCHANGE", --战力改变 + EVENT_PARTNER_DECOMPOSE = "EVENT_PARTNER_DECOMPOSE", --分解 + --春节集字活动 + EVENT_SPRING_FESTIVAL_COLLECT_CARD_REFRESH = "EVENT_SPRING_FESTIVAL_COLLECT_CARD_REFRESH", --集字界面刷新 + EVENT_SPRING_FESTIVAL_SMASH_EGGS_REFRESH = "EVENT_SPRING_FESTIVAL_SMASH_EGGS_REFRESH", --砸蛋界面刷新 + EVENT_SPRING_FESTIVAL_GIFT_BAG_REFRESH = "EVENT_SPRING_FESTIVAL_GIFT_BAG_REFRESH", --礼物界面刷新 + EVENT_SPRING_FESTIVAL_GIFT_BAG_RED = "EVENT_SPRING_FESTIVAL_GIFT_BAG_RED", --礼物界面红点 + EVENT_SPRING_FESTIVAL_REWARD_RED = "EVENT_SPRING_FESTIVAL_REWARD_RED", --礼物界面红点 + + --超级据点 + EVENT_STRONGHOLD_CUR_DAY_CHANGE = "EVENT_STRONGHOLD_CUR_DAY_CHANGE", --当前天数改变 + EVENT_STRONGHOLD_ACTIVITY_STATUS_CHANGE = "EVENT_STRONGHOLD_ACTIVITY_STATUS_CHANGE", --活动状态改变 + EVENT_STRONGHOLD_ACTIVITY_END = "EVENT_STRONGHOLD_ACTIVITY_END", --当期活动结束通知 + EVENT_STRONGHOLD_MINERAL_RECORD_CHANGE = "EVENT_STRONGHOLD_MINERAL_RECORD_CHANGE", --矿产记录变更 + EVENT_STRONGHOLD_MINERAL_LEFT_CHANGE = "EVENT_STRONGHOLD_MINERAL_LEFT_CHANGE", --可领取矿石数量变动 + EVENT_STRONGHOLD_MAX_ELECTRIC_CHANGE = "EVENT_STRONGHOLD_MAX_ELECTRIC_CHANGE", --电能上限变更 + EVENT_STRONGHOLD_ELECTRIC_CHARACTER_CHANGE = "EVENT_STRONGHOLD_ELECTRIC_CHARACTER_CHANGE", --电能队伍变更 + EVENT_STRONGHOLD_ENDURANCE_CHANGE = "EVENT_STRONGHOLD_ENDURANCE_CHANGE", --耐力变更 + EVENT_STRONGHOLD_BORROW_COUNT_CHANGE = "EVENT_STRONGHOLD_BORROW_COUNT_CHANGE", --援助次数变更 + EVENT_STRONGHOLD_FINISH_GROUP_CHANGE = "EVENT_STRONGHOLD_FINISH_GROUP_CHANGE", --据点进度变更 + EVENT_STRONGHOLD_NEW_FINISH_GROUP_CHANGE = "EVENT_STRONGHOLD_NEW_FINISH_GROUP_CHANGE", --最新通过据点变更 + EVENT_STRONGHOLD_FINISH_REWARDS_CHANGE = "EVENT_STRONGHOLD_FINISH_REWARDS_CHANGE", --已领取奖励变更 + EVENT_STRONGHOLD_SHARE_CHARACTER_CHANGE = "EVENT_STRONGHOLD_SHARE_CHARACTER_CHANGE", --共享角色变更 + EVENT_STRONGHOLD_PLUGIN_CHANGE_ACK = "EVENT_STRONGHOLD_PLUGIN_CHANGE_ACK", --插件调整确认 + EVENT_STRONGHOLD_TEAMLIST_CHANGE = "EVENT_STRONGHOLD_TEAMLIST_CHANGE", --队伍列表变更 + EVENT_STRONGHOLD_SUPPORT_CHANGE = "EVENT_STRONGHOLD_SUPPORT_CHANGE", --电能支援角色变更 + EVENT_STRONGHOLD_SUPPORT_CANCEL = "EVENT_STRONGHOLD_SUPPORT_CANCEL", --电能支援角色撤回 + EVENT_STRONGHOLD_ASSISTANT_CHARACTER_SET_CHANGE = "EVENT_STRONGHOLD_ASSISTANT_CHARACTER_SET_CHANGE", --援助角色变更 + EVENT_STRONGHOLD_ACTIVITY_RESULT_CHANGE = "EVENT_STRONGHOLD_ACTIVITY_RESULT_CHANGE", --活动战报变更 + EVENT_STRONGHOLD_PAUSE_DAY_CHANGE = "EVENT_STRONGHOLD_PAUSE_DAY_CHANGE", --暂停天数改变 + EVENT_STRONGHOLD_RUNE_CHANGE = "EVENT_STRONGHOLD_RUNE_CHANGE", --符文变更 + + --白色情人节约会活动 + EVENT_WHITEVALENTINE_REFRESH_PLACE = "EVENT_WHITEVALENTINE_REFRESH_PLACE", --白色情人节地点数据刷新 + EVENT_WHITEVALENTINE_SHOW_PLACE = "EVENT_WHITEVALENTINE_SHOW_PLACE", --白色情人节显示地点 + EVENT_WHITEVALENTINE_OPEN_PLACE = "EVENT_WHITEVALENTINE_OPEN_PLACE", --白色情人节新地点开放 + EVENT_WHITEVALENTINE_INVITE_CHARA = "EVENT_WHITEVALENTINE_INVITE_CHARA",--白色情人节邀请角色 + EVENT_WHITEVALENTINE_ENCOUNTER_CHARA = "EVENT_WHITEVALENTINE_ENCOUNTER_CHARA",--白色情人节偶遇角色 + EVENT_WHITEVALENTINE_ENERGY_REFRESH = "EVENT_WHITEVALENTINE_ENERGY_REFRESH",--刷新体力 + EVENT_WHITEVALENTINE_INVITE_CHANCE_REFRESH = "EVENT_WHITEVALENTINE_INVITE_CHANCE_REFRESH",--刷新邀约次数 + EVENT_WHITEVALENTINE_CHARA_CHANGE = "EVENT_WHITEVALENTINE_CHARA_CHANGE",--角色列表变动时 + + --萌战 + EVENT_MOE_WAR_PREPARATION_GEAR_REWARD = "EVENT_MOE_WAR_PREPARATION_GEAR_REWARD", --赛事筹备领取奖励 + EVENT_MOE_WAR_VOTE_SUCC = "EVENT_MOE_WAR_VOTE_SUCC", --投票成功 + EVENT_MOE_WAR_UPDATE = "EVENT_MOE_WAR_UPDATE", --服务端推送数据 + EVENT_MOE_WAR_ACTIVITY_END = "EVENT_MOE_WAR_ACTIVITY_END", --活动结束 + EVENT_MOE_WAR_VOTE_PANEL_UPDATE = "EVENT_MOE_WAR_VOTE_PANEL_UPDATE", --服务端推送数据 + EVENT_MOE_WAR_CHECK_RECRUIT_RED_POINT = "EVENT_MOE_WAR_CHECK_RECRUIT_RED_POINT", --检查招募通讯的红点 + EVENT_MOE_WAR_PREPARATION_UPDATE = "EVENT_MOE_WAR_PREPARATION_UPDATE", --服务端推送赛事筹备数据 + EVENT_MOE_WAR_PLAY_SCREEN_RECORD = "EVENT_MOE_WAR_PLAY_SCREEN_RECORD", --播放滚屏弹幕 + EVENT_MOE_WAR_PLAY_SCREEN_RECORD_ANIMATION = "EVENT_MOE_WAR_PLAY_SCREEN_RECORD_ANIMATION", --播放滚屏弹幕动作 + EVENT_MOE_WAR_PLAY_THANK_ANIMATION = "EVENT_MOE_WAR_PLAY_THANK_ANIMATION", --播放感谢动画 + EVENT_MOE_WAR_PREPARATION_NOTIFY_ASSISTANCE = "EVENT_MOE_WAR_PREPARATION_NOTIFY_ASSISTANCE", --推送赛事筹备援助变化 + EVENT_MOE_WAR_PREPARATION_DAILY_RESET = "EVENT_MOE_WAR_PREPARATION_DAILY_RESET", --赛事筹备每日重置推送 + + --猜拳小游戏 + EVENT_FINGER_GUESS_OPEN_EYE = "EVENT_FINGER_GUESS_OPEN_EYE", --开启天眼成功 + EVENT_FINGER_GUESS_PLAY_FINGER = "EVENT_FINGER_GUESS_PLAY_FINGER", --出拳成功 + EVENT_FINGER_GUESS_GAME_START = "EVENT_FINGER_GUESS_GAME_START", --开始游戏 + EVENT_FINGER_GUESS_CHECK_EVENT_FINISH = "EVENT_FINGER_GUESS_CHECK_EVENT_FINISH", --检查事件完结 + --库洛姆人物活动 + EVENT_KORO_CHAR_ACTIVITY_REDPOINTEVENT = "EVENT_KORO_CHAR_ACTIVITY_REDPOINTEVENT", --人物活动关卡通关事件 + + --铭牌相关事件 + EVENT_NAMEPLATE_CHANGE = "EVENT_NAMEPLATE_CHANGE", --铭牌更新 + + --翻牌猜大小 + EVENT_POKER_GUESSING_UPDATE_SCORE = "EVENT_POKER_GUESSING_UPDATE_SCORE", --翻牌积分更新 + EVENT_POKER_GUESSING_UPDATE_STATE = "EVENT_POKER_GUESSING_UPDATE_STATE", --比赛进程更新 + EVENT_POKER_GUESSING_UPDATE_RESULT = "EVENT_POKER_GUESSING_UPDATE_RESULT", --比赛结果推送 + EVENT_POKER_GUESSING_ACTIVITY_END = "EVENT_POKER_GUESSING_ACTIVITY_END", --活动结束推送 + + -- 改造玩法 + EVENT_REFORM_EVOLVABLE_GROUP_UPDATE = "EVENT_REFORM_EVOLVABLE_GROUP_UPDATE", -- 改造元素更新(敌人、成员、加成和环境) + + --刮刮卡 + EVENT_SCRATCH_TICKET_ACTIVITY_START = "EVENT_SCRATCH_TICKET_ACTIVITY_START", --刮刮卡活动信息更新 + EVENT_SCRATCH_TICKET_OPEN_GRID = "EVENT_SCRATCH_TICKET_OPEN_GRID", --刮刮卡预览格子成功时 + EVENT_SCRATCH_TICKET_SHOW_RESULT = "EVENT_SCRATCH_TICKET_SHOW_RESULT", --刮刮卡显示结果 + EVENT_SCRATCH_TICKET_RESET = "EVENT_SCRATCH_TICKET_RESET", --刮刮卡完成一局游戏后重置 + + --剧情合集 + EVENT_MOVIE_ASSEMBLE_WATCH_MOVIE = "EVENT_MOVIE_ASSEMBLE_WATCH_MOVIE", -- 剧情合集系统观看了剧情 + + --翻牌小游戏 + EVENT_INVERT_CARD_GAME_CARD_CHANGED = "EVENT_INVERT_CARD_GAME_CARD_CHANGED", -- 翻转卡牌事件 + EVENT_INVERT_CARD_GAME_GET_REWARD = "EVENT_INVERT_CARD_GAME_GET_REWARD", -- 获取奖励事件 + + -- 宠物教学 + EVENT_PARTNER_TEACHING_OPEN_STAGE_DETAIL = "EVENT_PARTNER_TEACHING_OPEN_STAGE_DETAIL", -- 宠物教学打开关卡详情 + EVENT_PARTNER_TEACHING_CLOSE_STAGE_DETAIL = "EVENT_PARTNER_TEACHING_CLOSE_STAGE_DETAIL", -- 宠物教学关闭关卡详情 + EVENT_PARTNER_TEACHING_STAGE_REFRESH = "EVENT_PARTNER_TEACHING_REFRESH", -- 宠物教学关卡刷新 + + --520端午活动 + EVENT_RPG_MAKER_GAME_ACTIVITY_END = "EVENT_RPG_MAKER_GAME_ACTIVITY_END", --活动结束 + + --扫雷活动 + EVENT_MINESWEEPING_STAGESTART = "EVENT_MINESWEEPING_STAGESTART", --开始关卡 + EVENT_MINESWEEPING_GRIDOPEN = "EVENT_MINESWEEPING_GRIDOPEN", --开启扫雷格子 + EVENT_MINESWEEPING_STORYPLAY = "EVENT_MINESWEEPING_STORYPLAY", --播放剧情 + -- 杀戮无双 + EVENT_KILLZONE_NEW_CHAPTER_CHANGE = "EVENT_KILLZONE_NEW_CHAPTER_CHANGE", --新章节变更 + EVENT_KILLZONE_NEW_DIFF_CHANGE = "EVENT_KILLZONE_NEW_DIFF_CHANGE", --新难度变更 + EVENT_KILLZONE_ACTIVITY_END = "EVENT_KILLZONE_ACTIVITY_END", --活动结束 + EVENT_KILLZONE_FARM_REWARD_OBTAIN_COUNT_CHANGE = "EVENT_KILLZONE_FARM_REWARD_OBTAIN_COUNT_CHANGE", --复刷奖励领取次数变更 + EVENT_KILLZONE_DAILYSTARREWARDINDEX_CHANGE = "EVENT_KILLZONE_DAILYSTARREWARDINDEX_CHANGE", --每日星级奖励档位变更 + EVENT_KILLZONE_STAGE_CHANGE = "EVENT_KILLZONE_STAGE_CHANGE", --通关记录变更 + EVENT_KILLZONE_STAR_REWARD_OBTAIN_RECORD_CHANGE = "EVENT_KILLZONE_STAR_REWARD_OBTAIN_RECORD_CHANGE", --星级奖励领取记录变更 + EVENT_KILLZONE_PLUGIN_CHANGE = "EVENT_KILLZONE_PLUGIN_CHANGE", --插件状态变更 + EVENT_KILLZONE_PLUGIN_SLOT_CHANGE = "EVENT_KILLZONE_PLUGIN_SLOT_CHANGE", --插件槽状态变更 + EVENT_KILLZONE_PLUGIN_OPERATE_CHANGE = "EVENT_KILLZONE_PLUGIN_OPERATE_CHANGE", --插件待操作Cookie变更 + + -- 系列涂装剧情活动 + EVENT_FASHION_STORY_OPEN_STAGE_DETAIL = "EVENT_FASHION_STORY_OPEN_STAGE_DETAIL", -- 打开章节关卡详情 + EVENT_FASHION_STORY_CLOSE_STAGE_DETAIL = "EVENT_FASHION_STORY_CLOSE_STAGE_DETAIL", -- 关闭章节关卡详情 + EVENT_FASHION_STORY_OPEN_TRIAL_DETAIL = "EVENT_FASHION_STORY_OPEN_TRIAL_DETAIL", -- 打开试玩关卡详情 + EVENT_FASHION_STORY_CHAPTER_REFRESH = "EVENT_FASHION_STORY_CHAPTER_REFRESH", -- 章节关刷新 + EVENT_FASHION_STORY_TRIAL_REFRESH = "EVENT_FASHION_STORY_TRIAL_REFRESH", -- 试玩关刷新 + + -- 超级爬塔 + EVENT_ST_FUNCTION_UNLOCK = "EVENT_ST_FUNCTION_UNLOCK", --特权解锁时 + EVENT_ST_MAP_THEME_SELECT = "EVENT_ST_MAP_THEME_SELECT", --主界面选某一个主题 + EVENT_ST_SHOP_REFRESH = "EVENT_ST_SHOP_REFRESH", --商店刷新 + EVENT_ST_PLUGIN_REFRESH = "EVENT_ST_PLUGIN_REFRESH", --插件刷新 + EVENT_ST_FINISH_FIGHT_COMPLETE = "EVENT_ST_FINISH_FIGHT_COMPLETE", --结束战斗处理完时 + --战斗通行证 + EVENT_NOTIFY_PASSPORT_BASE_INFO = "EVENT_NOTIFY_PASSPORT_BASE_INFO", --通知基础信息变化 + EVENT_BUY_PASSPORT_COMPLEATE = "EVENT_BUY_PASSPORT_COMPLEATE", --购买通行证成功 + EVENT_BUY_EXP_COMPLEATE = "EVENT_BUY_EXP_COMPLEATE", --购买等级成功 + EVENT_BUY_RECV_REWARD_COMPLEATE = "EVENT_BUY_RECV_REWARD_COMPLEATE", --领取单个奖励成功 + EVENT_BUY_RECV_ALL_REWARD_COMPLEATE = "EVENT_BUY_RECV_ALL_REWARD_COMPLEATE", --一键领取奖励 + EVENT_AUTO_GET_TASK_REWARD_LIST = "EVENT_AUTO_GET_TASK_REWARD_LIST", --通知自动领取任务奖励列表 + --日服定制化内容 + EVENT_BRIEF_CHANGE_TAB = "EVENT_BRIEF_CHANGE_TAB", + EVENT_MEDAL_IN_DETAIL = "EVENT_MEDAL_IN_DETAIL", --进入勋章详情 + EVNET_HGSDKLOGIN_SUCCESS = "EVNET_HGSDKLOGIN_SUCCESS", + EVENT_DORM_VISTOR_SKIP = "EVENT_DORM_VISTOR_SKIP", + + EVENT_PURCAHSE_YKMAINREFRESH = "EVENT_PURCAHSE_YKMAINREFRESH", + + --定制化内容 + EVENT_HGSDK_GET_BIND = "EVENT_HGSDK_GET_BIND", + EVENT_HGSDK_BIND_RESULT = "EVENT_HGSDK_BIND_RESULT", + EVENT_HGSDK_SETPASS_RESULT = "EVENT_HGSDK_SETPASS_RESULT", + EVENT_LOGIN_ATTENTION = "EVENT_LOGIN_ATTENTION", + + --商店直接使用日元购买 + EVENT_SHOP_BUYUSERIYUAN = "EVENT_SHOP_BUYUSERIYUAN", + --采购直接使用日元购买 + EVENT_PURCAHSE_BUYUSERIYUAN = "EVENT_PURCAHSE_BUYUSERIYUAN", + + --当用户协议更新完毕的时候 + EVENT_AGREEMENT_LOAD_FINISH = "EVENT_AGREEMENT_LOAD_FINISH", + EVENT_WHEN_CLOSE_LOGIN_NOTICE = "EVENT_WHEN_CLOSE_LOGIN_NOTICE", + + --购买失败的时候触发的消息,用来清空缓存 + EVENT_PURCHASEBUY_PAYCANCELORFAIL = "EVENT_PURCHASEBUY_PAYCANCELORFAIL", + + --新年运势关闭的时候刷新一次公告界面 + EVENT_NEWYEARYUNSHI_CLOSE_REFRESH = "EVENT_NEWYEARYUNSHI_CLOSE_REFRESH", + -- 海外定制老虎机小游戏 + EVENT_SLOT_MACHINE_STARTED = "EVENT_SLOT_MACHINE_STARTED", + EVENT_SLOT_MACHINE_GET_REWARD = "EVENT_SLOT_MACHINE_GET_REWARD", + EVENT_SLOT_MACHINE_FINISH_TASK = "EVENT_SLOT_MACHINE_FINISH_TASK", +} \ No newline at end of file diff --git a/Resources/Scripts/XCommon/XFightNetwork.lua b/Resources/Scripts/XCommon/XFightNetwork.lua new file mode 100644 index 00000000..ba343b45 --- /dev/null +++ b/Resources/Scripts/XCommon/XFightNetwork.lua @@ -0,0 +1,164 @@ +XFightNetwork = XFightNetwork or {} + +local IsConnected = false + +function XFightNetwork.IsConnected() + return IsConnected +end + +-- 心跳相关 +local FightHeartbeatRequest = "FightHeartbeatRequest" +local HeartbeatTimeout = CS.XGame.Config:GetInt("FightHeartbeatTimeout") +local HeartbeatInterval = CS.XGame.Config:GetInt("FightHeartbeatInterval") +local HeartbeatTimer +XFightNetwork.DoHeartbeat = function() + if not IsConnected then + return + end + + HeartbeatTimer = XScheduleManager.ScheduleOnce(function() + if CS.XNetwork.IsShowNetLog then + XLog.Debug("fight tcp heartbeat time out.") + end + -- 超时断开连接 + CS.XFightNetwork.Disconnect() + end, HeartbeatTimeout) + + if CS.XFightNetwork.IsShowNetLog then + XLog.Debug("fight tcp heartbeat request.") + end + XFightNetwork.Call(FightHeartbeatRequest, {}, function(res) + XScheduleManager.UnSchedule(HeartbeatTimer) + if CS.XFightNetwork.IsShowNetLog then + XLog.Debug("fight tcp heartbeat response.") + end + if res.Code ~= XCode.Success then + -- 心跳服务器返回错误,断开连接 + CS.XFightNetwork.Disconnect() + return + end + HeartbeatTimer = XScheduleManager.ScheduleOnce(function() + XFightNetwork.DoHeartbeat() + end, HeartbeatInterval) + end) +end + +function XFightNetwork.Connect(ip, port, cb) + if not ip or not port then + XLog.Debug("Lua.XFightNetwork.Connect error, ip is nil or port is nil") + return + end + + -- 成功回调 + CS.XFightNetwork.OnConnect = function() + XLog.Debug("Lua.XFightNetwork.Connect Success") + IsConnected = true + if cb then + cb(true) + end + end + + -- 网络错误回调 + CS.XFightNetwork.OnError = function(socketError) + XLog.Error("Lua.XFightNetwork.Connect error, " .. tostring(socketError:ToString())) + CS.XFightNetwork.Disconnect() + if cb then + cb(false) + end + end + + CS.XFightNetwork.OnDisconnect = function() + XLog.Debug("Lua.XFightNetwork.Connect OnDisconnect") + IsConnected = false + end + + CS.XFightNetwork.OnRemoteDisconnect = function() + XLog.Error("Lua.XFightNetwork.Connect OnRemoteDisconnect") + IsConnected = false + end + + CS.XFightNetwork.OnMessageError = function() + XLog.Error("Lua.XFightNetwork.Connect OnMessageError") + CS.XFightNetwork.Disconnect() + end + + CS.XFightNetwork.Connect(ip, tonumber(port)) +end + +local ConnectKcpTimer +local KcpConnectRequestInterval = 500 +function XFightNetwork.ConnectKcp(ip, port, remoteConv, cb) + XLog.Debug("Lua.XFightNetwork.ConnectKcp" .. " ip:" .. tostring(ip) .. " port:" .. tostring(port) .. " remoteConv:" .. tostring(remoteConv)) + CS.XFightNetwork.CreateUdpSession() + local networkMode = XSaveTool.GetData(XNetwork.NetworkModeKey) or XNetwork.NetworkMode.Auto + if networkMode == XNetwork.NetworkMode.Auto then + CS.XFightNetwork.UdpConnect(ip, port, CS.XNetwork.NetworkMode.Auto) + elseif networkMode == XNetwork.NetworkMode.Ipv4 then + CS.XFightNetwork.UdpConnect(ip, port, CS.XNetwork.NetworkMode.Ipv4) + elseif networkMode == XNetwork.NetworkMode.Ipv6 then + CS.XFightNetwork.UdpConnect(ip, port, CS.XNetwork.NetworkMode.Ipv6) + else -- Auto保底 + CS.XFightNetwork.UdpConnect(ip, port, CS.XNetwork.NetworkMode.Auto) + end + CS.XFightNetwork.CreateKcpSession(remoteConv) + if ConnectKcpTimer then + XScheduleManager.UnSchedule(ConnectKcpTimer) + ConnectKcpTimer = nil + end + + -- kcp握手请求 + local tryCount = 0 + local kcpConnected = false + local startTime = CS.XDateUtil.GetTime() + + ConnectKcpTimer = XScheduleManager.ScheduleForever(function() + -- 尝试次数超过10次且开始确认过去10秒 + if tryCount >= 10 and CS.XDateUtil.GetTime() - startTime >= 10 and not kcpConnected then + CS.XFightNetwork.DisconnectKcp() + XScheduleManager.UnSchedule(ConnectKcpTimer) + ConnectKcpTimer = nil + cb(false) + end + tryCount = tryCount + 1 + XLog.Debug("Lua.XFightNetwork.KcpConfirmRequest " .. tostring(tryCount)) + + local requestContent = XMessagePack.Encode({}) + CS.XFightNetwork.CallKcp("KcpConfirmRequest", requestContent, function() + XLog.Debug("KcpConfirmResponse") + if not kcpConnected then + XScheduleManager.UnSchedule(ConnectKcpTimer) + ConnectKcpTimer = nil + kcpConnected = true + cb(true) + end + end) + end, KcpConnectRequestInterval) +end + +function XFightNetwork.Send(handler, request) + local requestContent, error = XMessagePack.Encode(request) + if requestContent == nil then + XLog.Error("Lua.XFightNetwork.Send 函数错误, 客户端发送给服务端的数据编码处理失败, 失败原因:" .. error) + return + end + + CS.XFightNetwork.Send(handler, requestContent); +end + +function XFightNetwork.Call(handler, request, reply) + local requestContent, error = XMessagePack.Encode(request) + if requestContent == nil then + XLog.Error("Lua.XFightNetwork.Call 函数错误, 客户端发送给服务端的数据编码处理失败, 失败原因: " .. error) + return + end + + CS.XFightNetwork.Call(handler, requestContent, function(responseContent) + local response, err = XMessagePack.Decode(responseContent) + if response == nil then + XLog.Error("Lua.XFightNetwork.Call 函数错误, 服务端返回的数据解码失败, 失败原因: " .. err) + return + end + reply(response) + end) +end + diff --git a/Resources/Scripts/XCommon/XGlobalFunc.lua b/Resources/Scripts/XCommon/XGlobalFunc.lua new file mode 100644 index 00000000..bac2b025 --- /dev/null +++ b/Resources/Scripts/XCommon/XGlobalFunc.lua @@ -0,0 +1,117 @@ +local coroutineRunning = coroutine.running +local coroutineResume = coroutine.resume +local coroutineYiled = coroutine.yield +local coroutineWrap = coroutine.wrap +local tablePack = table.pack +local tableUnpack = table.unpack +local select = select + +function Handler(target, func) + return function(...) + return func(target, ...) + end +end +handler = Handler + +function LuaGC() + collectgarbage("collect") +end + +--回调转异步任务(需和RunAsyn配合使用) +---@param function类型, 最后一位参数为异步回调, 示例:local testFunc = function(..., callback) end +---@return 异步任务(不处理原函数返回值,异步需求默认void) +---@Examplemple +--[[ + local testFunc = function(str, cb) + XScheduleManager.ScheduleOnce(function() + XLog.Debug(str) + if cb then cb() end + end, XScheduleManager.SECOND) + end + + --callback hell + XLog.Debug("kkkttt test callback begin") + testFunc("kkkttt test callback CallBack 1" + , function() + testFunc("kkkttt test callback CallBack 2" + , function() + testFunc("kkkttt test callback CallBack 3") + end) + end) + XLog.Debug("kkkttt test callback end") + + --asyn task + XLog.Debug("kkkttt test asyn task begin") + local asynTest = asynTask(testFunc) + RunAsyn(function() + asynTest("kkkttt test asyn CallBack 1") + XLog.Debug("kkkttt test asyn after 1") + asynTest("kkkttt test asyn CallBack 2") + asynTest("kkkttt test asyn CallBack 3") + end) + XLog.Debug("kkkttt test asyn task end") +]] +function asynTask(func, caller) + return function(...) + local results = {} + + local running = coroutineRunning() + local args = { ... } + local length = select("#", ...) + 1 + args[length] = function() + coroutineResume(running, tableUnpack(results)) + end + + results = caller and tablePack(func(caller, tableUnpack(args))) or tablePack(func(tableUnpack(args))) + + return coroutineYiled() + end +end + +--异步等待second秒(需和RunAsyn配合使用) +function asynWaitSecond(second) + asynTask(function(cb) + XScheduleManager.ScheduleOnce(cb, second * XScheduleManager.SECOND) + end)() +end + +--异步执行 +function RunAsyn(asynFunc) + return coroutineWrap(asynFunc)() +end + +-- function string.split(input, delimiter) +-- input = tostring(input) +-- delimiter = tostring(delimiter) +-- if (delimiter=='') then return false end +-- local pos,arr = 0, {} +-- for st,sp in function() return string.find(input, delimiter, pos, true) end do +-- table.insert(arr, string.sub(input, pos, st - 1)) +-- pos = sp + 1 +-- end +-- table.insert(arr, string.sub(input, pos)) +-- return arr +-- end + +function appendArray(dst, src) + for i, v in ipairs(src)do + table.insert(dst, v) + end + return dst +end + +-- 保留digit位小数 +function getRoundingValue(value, digit) + return math.floor( value * math.pow(10, digit) ) / math.pow(10 , digit) +end + +function math.pow(a, b) + return a ^ b +end + +function table.indexof(array, value, begin) + for i = begin or 1, #array do + if array[i] == value then return i end + end + return false +end \ No newline at end of file diff --git a/Resources/Scripts/XCommon/XGlobalVar.lua b/Resources/Scripts/XCommon/XGlobalVar.lua new file mode 100644 index 00000000..6a338e50 --- /dev/null +++ b/Resources/Scripts/XCommon/XGlobalVar.lua @@ -0,0 +1,18 @@ +local IncId = 0 + +XGlobalVar = { + ScrollViewScrollDir = { + ScrollDown = "ScrollDown", --从上往下滚 + ScrollRight = "ScrollRight" --从左往右滚 + }, + + UiDesignSize = { --ui设计尺寸 + Width = 1920, + Height = 1080, + }, + + GetIncId = function() + IncId = IncId + 1 + return IncId + end +} \ No newline at end of file diff --git a/Resources/Scripts/XCommon/XLog.lua b/Resources/Scripts/XCommon/XLog.lua new file mode 100644 index 00000000..135de2de --- /dev/null +++ b/Resources/Scripts/XCommon/XLog.lua @@ -0,0 +1,188 @@ +XLog = XLog or {} + +local MAX_DEPTH = 5 + +local Type = type +local Tostring = tostring +local TableRemove = table.remove +local TableInsert = table.insert +local TableConcat = table.concat +local StringGub = string.gsub +local DebugTraceback = debug.traceback +local XLogDebug = CS.XLog.Debug +local XLogWarning = CS.XLog.Warning +local XLogError = CS.XLog.Error + +local Pairs = function(arr) + local meta_t = getmetatable(arr) + if meta_t and meta_t.__pairs then + return meta_t.__pairs(arr) + end + return pairs(arr) +end + + +local indentCache = { "" } +local function GetIndent(depth) + if not indentCache[depth] then + indentCache[depth] = GetIndent(depth - 1) .. " " + end + return indentCache[depth] +end + +local function Dump(target) + local content = {} + local stack = { + { + obj = target, + name = nil, + depth = 1, + symbol = nil, + } + } + + while #stack > 0 do + local top = TableRemove(stack) + local obj = top.obj + local name = top.name + local depth = top.depth + local symbol = top.symbol + + if Type(obj) == "table" then + if depth > MAX_DEPTH then + TableInsert(stack, { + obj = "too depth ...", + name = name, + depth = depth, + symbol = symbol, + }) + else + TableInsert(stack, { + obj = "}", + name = nil, + depth = depth, + symbol = symbol, + }) + + local temp = {} + for k, v in Pairs(obj) do + TableInsert(temp, { + obj = v, + name = k, + depth = depth + 1, + symbol = ",", + }) + end + + local count = #temp + for i = 1, count do + TableInsert(stack, temp[count - i + 1]) + end + + TableInsert(stack, { + obj = "{", + name = name, + depth = depth, + symbol = nil, + }) + end + else + TableInsert(content, GetIndent(depth)) + + if name then + if Type(name) == "string" then + TableInsert(content, "[\"") + TableInsert(content, name) + TableInsert(content, "\"]") + else + TableInsert(content, "[") + TableInsert(content, Tostring(name)) + TableInsert(content, "]") + end + + TableInsert(content, " = ") + end + + if obj and Type(obj) == "string" then + if obj ~= "{" and obj ~= "}" then + TableInsert(content, "\"") + TableInsert(content, obj) + TableInsert(content, "\"") + else + TableInsert(content, obj) + end + else + TableInsert(content, Tostring(obj)) + end + + if symbol then + TableInsert(content, symbol) + end + + TableInsert(content, "\n") + end + end + + return TableConcat(content) +end + +local Print = function(...) + local args = { ... } + local count = #args + + if count <= 0 then + return + end + + local content = {} + for i = 1, count do + if Type(args[i]) == "table" then + TableInsert(content, Dump(args[i])) + else + TableInsert(content, Tostring(args[i])) + TableInsert(content, "\n") + end + end + + return TableConcat(content) + -- return StringGub(StringGub(TableConcat(content), "{", "/{"), "}", "/}") +end + +XLog.Debug = function(...) + local content = Print(...) + if content then + XLogDebug(content .. "\n" .. DebugTraceback()) + else + XLogDebug("nil\n" .. DebugTraceback()) + end +end + +XLog.Warning = function(...) + local content = Print(...) + if content then + XLogWarning(content .. "\n" .. DebugTraceback()) + else + XLogWarning("nil\n" .. DebugTraceback()) + end +end + +XLog.Error = function(...) + local content = Print(...) + if content then + XLogError(content .. "\n" .. DebugTraceback()) + else + XLogError("nil\n" .. DebugTraceback()) + end +end + +-- 表格找不到数据错误统一输出接口 +XLog.ErrorTableDataNotFound = function(functionName, dataName, tablePath, paramName, paramValue) + XLog.Error(string.format("%s出错:找不到%s数据。搜索路径: %s 索引%s = %s", functionName, dataName, tablePath, paramName, paramValue)) +end + +XLog.Dump = function(value) + if type(value) ~= "table" then + return tostring(value) + end + return Dump(value) +end \ No newline at end of file diff --git a/Resources/Scripts/XCommon/XLuaBehaviour.lua b/Resources/Scripts/XCommon/XLuaBehaviour.lua new file mode 100644 index 00000000..1d704751 --- /dev/null +++ b/Resources/Scripts/XCommon/XLuaBehaviour.lua @@ -0,0 +1,34 @@ +XLuaBehaviour = XClass(nil, "XLuaBehaviour") + +function XLuaBehaviour:Ctor(rootUi, ui) + self.Transform = ui.transform + self.GameObject = ui.gameObject + + local behaviour = self.GameObject:GetComponent(typeof(CS.XLuaBehaviour)) + if not behaviour then + behaviour = self.GameObject:AddComponent(typeof(CS.XLuaBehaviour)) + end + + if self.Start then + behaviour.LuaStart = function() self:Start() end + end + + if self.Update then + behaviour.LuaUpdate = function() self:Update() end + end + + if self.LateUpdate then + behaviour.LuaLateUpdate = function() self:LateUpdate() end + end + + if self.OnDestroy then + behaviour.LuaOnDestroy = function() self:OnDestroy() end + end +end + +function XLuaBehaviour:Dispose() + local xLuaBehaviour = self.Transform:GetComponent(typeof(CS.XLuaBehaviour)) + if (xLuaBehaviour) then + CS.UnityEngine.GameObject.Destroy(xLuaBehaviour) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XCommon/XMath.lua b/Resources/Scripts/XCommon/XMath.lua new file mode 100644 index 00000000..0c3f8db5 --- /dev/null +++ b/Resources/Scripts/XCommon/XMath.lua @@ -0,0 +1,59 @@ +local math = math + +local mathFloor = math.floor +local mathRandom = math.random + +XMath = XMath or {} + +function XMath.RandByWeights(weights) + local weightSum = 0 + for i = 1, #weights do + weightSum = weightSum + weights[i] + end + + local rand = mathRandom(weightSum) + local curWeight = 0 + for i = 1, #weights do + local weight = weights[i] + curWeight = curWeight + weight + if rand < curWeight then + return i + end + end + + return #weights +end + +function XMath.Clamp(value, min, max) + if value < min then + return min + end + if value > max then + return max + end + return value +end + + +--==============================-- +--desc: 转换成整数,浮点数四舍五入 +--==============================-- +XMath.ToInt = function(val) + if not val then return end + return mathFloor(val + 0.5) +end + +--==============================-- +--desc: 转换成整数,浮点数向下取整数 +--==============================-- +XMath.ToMinInt = function(val) + if not val then return end + return mathFloor(val) +end + +--==============================-- +--desc: 最大整数,与C#一致 +--==============================-- +XMath.IntMax = function() + return 2147483647 +end \ No newline at end of file diff --git a/Resources/Scripts/XCommon/XNetwork.lua b/Resources/Scripts/XCommon/XNetwork.lua new file mode 100644 index 00000000..c4ecd2fd --- /dev/null +++ b/Resources/Scripts/XCommon/XNetwork.lua @@ -0,0 +1,274 @@ +XNetwork = XNetwork or {} + +local Ip +local Port +local LastIp +local LastPort +local XRpc = XRpc +local IsDebug = XMain.IsEditorDebug +local ShieldedProtocol = {} +local NeedShieldProtocol = false + +XNetwork.NetworkMode = { + Auto = 1, + Ipv4 = 2, + Ipv6 = 3, +} +XNetwork.NetworkModeKey = "NETWORK_MODE_KEY" + +local function GetIpAndPort() + return Ip, Port +end + +function XNetwork.SetGateAddress(ip, port) + Ip = ip + Port = port +end + +function XNetwork.CheckIsChangedGate() + return LastIp ~= Ip or LastPort ~= Port +end + +local LogTableFunc = IsDebug and XLog.Debug or XLog.Error + +local function TipTableDiff(sha1Table) + if not CS.XTableManager.NeedSha1 then -- 开发环境下不解析Sha1 + return + end + + XTool.LoopMap(CS.XTableManager.Sha1Table, function(k, v) + local sha1 = sha1Table[k] + if not sha1 then + LogTableFunc("多余表格: " .. k) + return + end + + if v ~= sha1 then + LogTableFunc("差异表格: " .. k .. ", 客户端sha1: " .. v .. " , 服务端sha1: " .. sha1) + end + + sha1Table[k] = nil + end) + + for k, _ in pairs(sha1Table) do + LogTableFunc("缺少表格: " .. k) + end +end + +XRpc.NotifyCheckTableSha1 = function(data) + TipTableDiff(data.Sha1Table) +end + +function XNetwork.ConnectGateServer(args) + if not args then + return + end + + if IsDebug then + XRpc.CheckLuaNetLogEnable() + end + + CS.XNetwork.OnConnect = function() + if args.IsReconnect then + local request = { PlayerId = XPlayer.Id, Token = XUserManager.ReconnectedToken, LastMsgSeqNo = CS.XNetwork.ServerMsgSeqNo } + if CS.XNetwork.IsShowNetLog then + XLog.Debug("PlayerId=" .. request.PlayerId .. ", Token=" .. request.Token .. ", LastMsgSeqNo=" .. request.LastMsgSeqNo) + end + + local request_func + request_func = function() + XNetwork.Call("ReconnectRequest", request, function(res) + if res.Code == XCode.ReconnectAgain then + if CS.XNetwork.IsShowNetLog then + XLog.Debug("服务器返回再次重连。" .. tostring(res.Code)) + end + + XScheduleManager.ScheduleOnce(function() + request_func() + end, 1000) + + elseif res.Code ~= XCode.Success then + if CS.XNetwork.IsShowNetLog then + XLog.Debug("服务器返回断线重连失败。" .. tostring(res.Code)) + end + XLoginManager.DoDisconnect() + else + XNetwork.Send("ReconnectAck") + if CS.XNetwork.IsShowNetLog then + XLog.Debug("服务器返回断线重连成功。") + end + XUserManager.ReconnectedToken = res.ReconnectToken + if args.ConnectCb then + args.ConnectCb() + end + + if res.OfflineMessages then + CS.XNetwork.ProcessReconnectMessageList(res.OfflineMessages) + end + CS.XNetwork.ReCall(res.RequestNo) + end + end) + end + + request_func() + else + XNetwork.Call("HandshakeRequest", { + ApplicationVersion = CS.XRemoteConfig.ApplicationVersion, + DocumentVersion = CS.XRemoteConfig.DocumentVersion, + Sha1 = CS.XTableManager.Sha1 + }, function(response) + if args.RemoveHandshakeTimerCb then + args.RemoveHandshakeTimerCb() + end + + if response.Code ~= XCode.Success then + local msgTab = {} + msgTab.error_code = response.Code + CS.XRecord.Record(msgTab, "24019", "HandshakeRequest") + if response.Code == XCode.GateServerNotOpen then + local localTimeStr = XTime.TimestampToLocalDateTimeString(response.UtcOpenTime, "yyyy-MM-dd HH:mm(G'M'T z)") + local context = CS.XTextManager.GetCodeText(response.Code) .. localTimeStr + XUiManager.SystemDialogTip("", context, XUiManager.DialogType.OnlySure) + elseif response.Code == XCode.LoginApplicationVersionError then + -- 处于调试模式时进错服显示取消按钮,否则不显示 + local cancelCb = XMain.IsDebug and function() end or nil + CS.XTool.WaitCoroutine(CS.XApplication.CoDialog(CS.XApplication.GetText("Tip"), + CS.XStringEx.Format(CS.XApplication.GetText("UpdateApplication"), + CS.XInfo.Version), cancelCb, function() CS.XTool.WaitCoroutine(CS.XApplication.GoToUpdateURL(GetAppUpgradeUrl()), nil) end)) + else + XUiManager.DialogTip("", CS.XTextManager.GetCodeText(response.Code), XUiManager.DialogType.OnlySure) + end + + if response.Code == XCode.LoginTableError then + XLog.Error("配置表客户端和服务端不一致") + TipTableDiff(response.Sha1Table) + end + + CS.XNetwork.Disconnect() + return + end + + CS.XRecord.Record("24020", "HandshakeRequestSuccess") + if args.ConnectCb then + args.ConnectCb() + end + end) + end + end + CS.XNetwork.OnDisconnect = function() + if args.DisconnectCb then + args.DisconnectCb() + end + end + CS.XNetwork.OnRemoteDisconnect = function() + if args.RemoteDisconnectCb then + args.RemoteDisconnectCb() + end + end + CS.XNetwork.OnError = function(error) + if args.ErrorCb then + args.ErrorCb(error) + end + end + CS.XNetwork.OnMessageError = function() + if args.MsgErrorCb then + args.MsgErrorCb() + end + end + CS.XNetwork.OnReconnectRequestFrequently = function() + if args.ReconnectRequestFrequentlyCb then + args.ReconnectRequestFrequentlyCb() + end + end + + local ip, port + if args.IsReconnect then + ip, port = LastIp, LastPort + else + ip, port = GetIpAndPort() + end + + XNetwork.ConnectServer(ip, port, args.IsReconnect) +end + +function XNetwork.ConnectServer(ip, port, bReconnect) + if not ip or not port then + return + end + + LastIp, LastPort = ip, port + local networkMode = XSaveTool.GetData(XNetwork.NetworkModeKey) or XNetwork.NetworkMode.Auto + if networkMode == XNetwork.NetworkMode.Auto then + CS.XNetwork.Connect(ip, tonumber(port), bReconnect, CS.XNetwork.NetworkMode.Auto) + elseif networkMode == XNetwork.NetworkMode.Ipv4 then + CS.XNetwork.Connect(ip, tonumber(port), bReconnect, CS.XNetwork.NetworkMode.Ipv4) + elseif networkMode == XNetwork.NetworkMode.Ipv6 then + CS.XNetwork.Connect(ip, tonumber(port), bReconnect, CS.XNetwork.NetworkMode.Ipv6) + else -- Auto保底 + CS.XNetwork.Connect(ip, tonumber(port), bReconnect, CS.XNetwork.NetworkMode.Auto) + end +end + +function XNetwork.Send(handler, request) + -- 检查是否是屏蔽协议 + if NeedShieldProtocol and ShieldedProtocol[handler] then + XUiManager.TipMsg(CS.XGame.ClientConfig:GetString("ShieldedProtocol")) + return + end + local requestContent, error = XMessagePack.Encode(request) + if IsDebug then + XRpc.DebugPrint(XRpc.DEBUG_TYPE.Send, handler, requestContent) + end + + if requestContent == nil then + XLog.Error("XNetwork.Send 函数错误, 客户端发送给服务端的数据编码处理失败, 失败原因:" .. error) + return + end + + CS.XNetwork.Send(handler, requestContent); +end + +function XNetwork.Call(handler, request, reply) + -- 检查是否是屏蔽协议 + if NeedShieldProtocol and ShieldedProtocol[handler] then + XUiManager.TipMsg(CS.XGame.ClientConfig:GetString("ShieldedProtocol")) + return + end + if IsDebug then + XRpc.DebugPrint(XRpc.DEBUG_TYPE.Send_Call, handler, request) + end + + local requestContent, error = XMessagePack.Encode(request) + if requestContent == nil then + XLog.Error("XNetwork.Call 函数错误, 客户端发送给服务端的数据编码处理失败, 失败原因: " .. error) + return + end + + CS.XNetwork.Call(handler, requestContent, function(responseContent) + local response, err = XMessagePack.Decode(responseContent) + if response == nil then + XLog.Error("XNetwork.Call 函数错误, 服务端返回的数据解码失败, 失败原因: " .. err) + return + end + + if IsDebug then + XRpc.DebugPrint(XRpc.DEBUG_TYPE.Recv_Call, handler, response) + end + + reply(response) + end) +end + +--================ +--设置协议屏蔽列表 +--@param protocolList:屏蔽协议名列表 +--================ +function XNetwork.SetShieldedProtocolList(protocolList) + if not protocolList then return end + ShieldedProtocol = {} + NeedShieldProtocol = false + for _, protocolName in pairs(protocolList) do + NeedShieldProtocol = true + ShieldedProtocol[protocolName] = true + end +end diff --git a/Resources/Scripts/XCommon/XNpcAttribType.lua b/Resources/Scripts/XCommon/XNpcAttribType.lua new file mode 100644 index 00000000..37e255a2 --- /dev/null +++ b/Resources/Scripts/XCommon/XNpcAttribType.lua @@ -0,0 +1,92 @@ +-- auto export form enum +-- Automatic generation of code, forbid to edit or delete +XNpcAttribType = { + Life = 1, -- 生命 + Energy = 2, -- 能量 + RunSpeed = 3, -- 跑速度 + WalkSpeed = 4, -- 走速度 + TurnRoundSpeed = 5, -- 转身角速度 + BallInterval = 6, -- 出球间隔帧 + DamageNormalImmunity = 7, -- 普通伤害免疫 + DamageMagicImmunity = 8, -- 元素伤害免疫 + AntiDamageNormalImmunity = 9, -- 反普通伤害免疫 + AntiDamageMagicImmunity = 10, -- 反元素伤害免疫 + AttackNormal = 11, -- 普通攻击 + AttackMagicBegin = 11, -- 元素攻击起始 + AttackMagic1 = 12, -- 元素1攻击 + AttackMagic2 = 13, -- 元素2攻击 + AttackMagic3 = 14, -- 元素3攻击 + AttackMagic4 = 15, -- 元素4攻击 + AttackMagicEnd = 16, -- 元素攻击结束 + AntiAttackNormal = 17, -- 反普通攻击 + AntiAttackMagicBegin = 17, -- 反元素攻击起始 + AntiAttackMagic1 = 18, -- 反元素1攻击 + AntiAttackMagic2 = 19, -- 反元素2攻击 + AntiAttackMagic3 = 20, -- 反元素3攻击 + AntiAttackMagic4 = 21, -- 反元素4攻击 + AntiAttackMagicEnd = 22, -- 反元素攻击结束 + DefenseNormal = 23, -- 普通防御 + AntiDefenseNormal = 24, -- 反普通防御 + DamageChangeP = 25, -- 总伤害加深率 + DamageNormalChangeP = 26, -- 普通伤害加深率 + DamageMagicChangePBegin = 26, -- 元素伤害加深率开始 + DamageMagic1ChangeP = 27, -- 元素1伤害加深率 + DamageMagic2ChangeP = 28, -- 元素2伤害加深率 + DamageMagic3ChangeP = 29, -- 元素3伤害加深率 + DamageMagic4ChangeP = 30, -- 元素4伤害加深率 + DamageMagicChangePEnd = 31, -- 元素伤害加深率结束 + AntiDamageChangeP = 32, -- 反总伤害加深率 + AntiDamageNormalChangeP = 33, -- 反普通伤害加深率 + AntiDamageMagicChangePBegin = 33, -- 反元素伤害加深率开始 + AntiDamageMagic1ChangeP = 34, -- 反元素1伤害加深率 + AntiDamageMagic2ChangeP = 35, -- 反元素2伤害加深率 + AntiDamageMagic3ChangeP = 36, -- 反元素3伤害加深率 + AntiDamageMagic4ChangeP = 37, -- 反元素4伤害加深率 + AntiDamageMagicChangePEnd = 38, -- 反元素伤害加深率结束 + DamagePBegin = 39, -- 类型伤害率开始 + Damage1P = 40, -- 类型1伤害率 + Damage2P = 41, -- 类型2伤害率 + Damage3P = 42, -- 类型3伤害率 + DamagePEnd = 43, -- 类型伤害率结束 + Crit = 44, -- 暴击 + CritP = 45, -- 暴击率 + CritDamageP = 46, -- 暴击伤害率 + AntiCritP = 47, -- 反暴击率 + AntiCritDamageP = 48, -- 反暴击伤害率 + Lifesteal = 49, -- 吸血 + LifestealP = 50, -- 吸血率 + CureChangeP = 51, -- 治疗加深率 + AntiCureChangeP = 52, -- 反治疗加深率 + Endure = 53, -- 霸体值 + ThreatRateP = 54, -- 仇恨生成速率 + DodgeEnergy = 55, -- 闪避能量值 + DodgeEnergyAutoRecovery = 56, -- 闪避能量自动回复 + CustomEnergy = 57, -- 自定义能量值 + AccuResistance1 = 58, -- 积蓄抗性1 + AccuResistance2 = 59, -- 积蓄抗性2 + AccuResistance3 = 60, -- 积蓄抗性3 + AccuResistance4 = 61, -- 积蓄抗性4 + AccuResistance5 = 62, -- 积蓄抗性5 + AccuResistance6 = 63, -- 积蓄抗性6 + AccuResistance7 = 64, -- 积蓄抗性7 + AccuResistance8 = 65, -- 积蓄抗性8 + AccuResistance9 = 66, -- 积蓄抗性9 + AccuResistance10 = 67, -- 积蓄抗性10 + SquatSpeed = 68, -- 蹲走速度 + NormalWeaknessP = 69, -- 物理弱点 + MagicWeaknessPBegin = 69, -- 元素弱点开始 + Magic1WeaknessP = 70, -- 元素弱点1 + Magic2WeaknessP = 71, -- 元素弱点2 + Magic3WeaknessP = 72, -- 元素弱点3 + Magic4WeaknessP = 73, -- 元素弱点4 + SprintSpeed = 74, -- 疾跑速度 + CustomEnergyGroup1 = 75, -- 自定义能量组1 + CustomEnergyGroup2 = 76, -- 自定义能量组2 + CustomEnergyGroup3 = 77, -- 自定义能量组3 + CustomEnergyGroup4 = 78, -- 自定义能量组4 + Hack = 79, -- 骇入值 + HackChangeP = 80, -- 骇入加深率 + AntiHackChangeP = 81, -- 骇入抵抗率 + HackAutoRecovery = 82, -- 骇入值自动回复 + End = 83, -- +} diff --git a/Resources/Scripts/XCommon/XPerformance.lua b/Resources/Scripts/XCommon/XPerformance.lua new file mode 100644 index 00000000..cfc0712a --- /dev/null +++ b/Resources/Scripts/XCommon/XPerformance.lua @@ -0,0 +1,82 @@ +XPerformance = XPerformance or {} + +local CsTime = CS.UnityEngine.Time +local IO = CS.System.IO +local collectgarbage = collectgarbage +local AutoSaveTime = 10 +local LastSaveTime = 0 +local TraceLevel = 5 + +XPerformance.SaveDataPath = XPerformance.SaveDataPath or string.format("Log/MemData_%s.tab", CS.System.DateTime.Now:ToString("MMddhhmm")) +XPerformance.SaveTimerId = XPerformance.SaveTimerId or 0 +XPerformance.LuaMemData = XPerformance.LuaMemData or {} + +-- 定期保存数据 +function XPerformance.StartLuaMenCollect() + if CS.UnityEngine.Application.platform ~= CS.UnityEngine.RuntimePlatform.WindowsEditor then + return + end + if XPerformance.SaveTimerId then + XScheduleManager.UnSchedule(XPerformance.SaveTimerId) + XPerformance.SaveTimerId = 0 + end + XPerformance.SaveTimerId = XScheduleManager.ScheduleForever(function() + if not next(XPerformance.LuaMemData) then + return + end + local nowTime = CsTime.realtimeSinceStartup + if nowTime - LastSaveTime > AutoSaveTime then + LastSaveTime = nowTime + XPerformance.SaveMemData() + end + end, AutoSaveTime * 1000) +end + +-- 保存数据 +function XPerformance.SaveMemData() + local sw + if not IO.File.Exists(XPerformance.SaveDataPath) then + sw = IO.File.CreateText(XPerformance.SaveDataPath) + sw:Write("traceName\tkey\tcostMem\tcurrentMem\n") + else + sw = IO.File.AppendText(XPerformance.SaveDataPath) + sw:Write("\n") + end + + local tab = {} + for key, str in pairs(XPerformance.LuaMemData) do + table.insert(tab, str) + end + XPerformance.LuaMemData = {} + local content = table.concat(tab, '\n') + sw:Write(content) + sw:Flush() + sw:Close() + + XLog.Debug("... save data:" .. content) +end + +-- 记录一段代码消耗的lua内存 +function XPerformance.RecordLuaMemData(name, func, isCollect) + if isCollect == nil then + isCollect = true + end + if isCollect then + collectgarbage("collect") + end + local beforeMem = collectgarbage("count") + func() + if isCollect then + collectgarbage("collect") + end + local currentMem = collectgarbage("count") + + local costMem = currentMem - beforeMem + costMem = math.floor(costMem / 1024 * 10000) / 10000 + currentMem = math.floor(beforeMem / 1024 * 10000) / 10000 + + -- 记录消耗 + local traceName = XTool.GetStackTraceName(TraceLevel) + local str = string.format("%s\t%s\t%s\t%s", traceName, name, costMem, currentMem) + table.insert(XPerformance.LuaMemData, str) +end \ No newline at end of file diff --git a/Resources/Scripts/XCommon/XPool.lua b/Resources/Scripts/XCommon/XPool.lua new file mode 100644 index 00000000..b09d79f0 --- /dev/null +++ b/Resources/Scripts/XCommon/XPool.lua @@ -0,0 +1,60 @@ +XPool = XClass(nil, "XPool") + +function XPool:Ctor(createFunc, onRelease) + if not createFunc then + XLog.Error("XPool:Ctor Error:createFunc is Empty.") + return + end + + self.__Container = XStack.New() + self.__CreateFunc = createFunc + self.__OnRelease = onRelease + self.__TotalCount = 0 +end + +function XPool:Clear() + self.__TotalCount = 0 + self.__Container:Clear() +end + +function XPool:GetItemFromPool() + local item = self.__Container:Pop() + if not item then + item = self.__CreateFunc() + if not item then + XLog.Error("XPool:GetItemFromPool Error:createFunc return nil.") + return + end + self.__TotalCount = self.__TotalCount + 1 + end + return item +end + +function XPool:ReturnItemToPool(item) + if not item then return end + + if self:UsingCount() < 1 then + return + end + + if self.__OnRelease then + self.__OnRelease(item) + end + + self.__Container:Push(item) +end + +--池中剩余对象数量 +function XPool:LeftCount() + return self.__Container:Count() +end + +--使用中对象数量 +function XPool:UsingCount() + return self.__TotalCount - self:LeftCount() +end + +--已创建对象数量 +function XPool:TotalCount() + return self.__TotalCount +end \ No newline at end of file diff --git a/Resources/Scripts/XCommon/XPrefs.lua b/Resources/Scripts/XCommon/XPrefs.lua new file mode 100644 index 00000000..3dd7d134 --- /dev/null +++ b/Resources/Scripts/XCommon/XPrefs.lua @@ -0,0 +1,53 @@ +XPrefs = XPrefs or {} + +-- 登陆模块 +XPrefs.UserId = "USER_ID" +XPrefs.UserName = "USER_NAME" +XPrefs.Channel = "CHANNEL" +XPrefs.Token = "TOKEN" +XPrefs.PasswordStatus = "PASSWORD_STATUS" + +XPrefs.ServerId = "SERVER_ID" +XPrefs.User_ServerId = "USER_SERVER_ID" + +XPrefs.CharacterStoryRecord = "CHARACTER_STORY_RECORD" + +XPrefs.AssistSwitch = "ASSIST_SWITCH" +XPrefs.GuideTrigger = "GUIDE_DISABLE" +XPrefs.CommunicationTrigger = "COMMUNICATION_DISABLE" +XPrefs.FunctionEventTrigger = "FUNCTION_EVENT_DISABLE" +XPrefs.LoginAnimTrigger = "LOGIN_ANIM_DISABLE" +XPrefs.AccountHistory = "ACCOUNT_HISTORY" +XPrefs.LuaNetLog = "LUA_NET_LOG" + +XPrefs.TowerTip = "TOWER_TIP" + +XPrefs.DormNewHint = "DORM_NEW_HINT_" +XPrefs.PayOrder = "PAY_ORDER_" + +XPrefs.BaseEquip = "BASE_EQUIP" + +XPrefs.AutoWindowEach = "AUTO_WINDOW_EACH" + +XPrefs.AutoWindowPeriod = "AUTO_WINDOW_PERIOD" + +XPrefs.YKLocalCache = "YK_LOCAL_CACHAE" +XPrefs.YKContinueBuy = "YK_CONTINUE_BUY" + +XPrefs.ArenaTeamResult = "Arena_Team_Result" + +XPrefs.ArenaOnlineInvit = "AreanOnline_Invit" + +XPrefs.ArenaOnlineFirstOpen = "AreanOnline_First_Open" + +-- 战斗设置 +XPrefs.DynamicJoystick = "DYNAMIC_JOYSTICK" +XPrefs.FocusType = "FOCUS_TYPE" +XPrefs.FocusButton = "FOCUS_BUTTON" +XPrefs.InviteButton = "INVITE_BUTTON" + +-- 武器显示设置 +XPrefs.WeaponTransType = "WEAPON_TRANS_TYPE" + +-- 累积充值显示设置 +XPrefs.RechargeType = "RECHARGE_TYPE" \ No newline at end of file diff --git a/Resources/Scripts/XCommon/XQueue.lua b/Resources/Scripts/XCommon/XQueue.lua new file mode 100644 index 00000000..a2e9281d --- /dev/null +++ b/Resources/Scripts/XCommon/XQueue.lua @@ -0,0 +1,46 @@ +XQueue = XClass(nil, "XQueue") + +function XQueue:Ctor() + self:Clear() +end + +function XQueue:Clear() + self.__Container = {} + self.__StartIndex = 1 + self.__EndIndex = 0 +end + +function XQueue:IsEmpty() + return self.__StartIndex > self.__EndIndex +end + +function XQueue:Count() + return self.__EndIndex - self.__StartIndex + 1 +end + +function XQueue:Enqueue(element) + if not element then return end + + local endIndex = self.__EndIndex + 1 + self.__EndIndex = endIndex + self.__Container[endIndex] = element +end + +function XQueue:Dequeue() + if self:IsEmpty() then + self:Clear() + return + end + + local startIndex = self.__StartIndex + local element = self.__Container[startIndex] + + self.__StartIndex = startIndex + 1 + self.__Container[startIndex] = nil + + return element +end + +function XQueue:Peek() + return self.__Container[self.__StartIndex] +end \ No newline at end of file diff --git a/Resources/Scripts/XCommon/XRpc.lua b/Resources/Scripts/XCommon/XRpc.lua new file mode 100644 index 00000000..efb90f86 --- /dev/null +++ b/Resources/Scripts/XCommon/XRpc.lua @@ -0,0 +1,99 @@ +XRpc = XRpc or {} + +------- 方便调试协议的打印 ------ +local IsPrintLuaRpc = false +if XMain.IsEditorDebug then + CS.XNetwork.IsShowNetLog = false +end +XRpc.IgnoreRpcNames = { ["HeartbeatRequest"] = true, ["HeartbeatResponse"] = true, ["KcpHeartbeatRequest"] = true, ["KcpHeartbeatResponse"] = true } +XRpc.DEBUG_TYPE = { + Send = "Send", + Send_Call = "Send_Call", + Recv = "Recv", + Recv_Call = "Recv_Call", +} +XRpc.DEBUG_TYPE_COLOR = { + Send = "#5bf54f", + Send_Call = "#5bf54f", + Recv = "#42a8fa", + Recv_Call = "#42a8fa", +} +-- 浅色主题用的字体颜色 +-- XRpc.DEBUG_TYPE_COLOR = { +-- Send = "green", +-- Send_Call = "green", +-- Recv = "blue", +-- Recv_Call = "blue", +-- } +XRpc.DebugKeyWords = {"GuildBoss"} -- 【关键协议】 + +function XRpc.CheckLuaNetLogEnable() + IsPrintLuaRpc = XMain.IsEditorDebug and XSaveTool.GetData(XPrefs.LuaNetLog) + return IsPrintLuaRpc +end + +function XRpc.SetLuaNetLogEnable(value) + IsPrintLuaRpc = value + XSaveTool.SaveData(XPrefs.LuaNetLog, IsPrintLuaRpc) +end + +function XRpc.DebugPrint(debugType, rpcName, request) + if not IsPrintLuaRpc or XRpc.IgnoreRpcNames[rpcName] then + return + end + local color = XRpc.DEBUG_TYPE_COLOR[debugType] + if XRpc.DebugKeyWords then + for i, keyWord in ipairs(XRpc.DebugKeyWords) do + if (string.find(rpcName, keyWord)) then + rpcName = "" .. rpcName .. "" -- 【关键协议】显示为红色 可本地自定义 + break + end + end + end + XLog.Debug(" " .. debugType .. ": " .. rpcName .. ", content: " .. XLog.Dump(request)) +end +------------------------------- + +local handlers = {} +local IsHotReloadOpen = XMain.IsEditorDebug + +function XRpc.Do(name, content) + local handler = handlers[name] + if handler == nil then + XLog.Error("XRpc.Do 函数错误, 没有定义相应的接收服务端数据的函数, 函数名是: " .. name) + return + end + + local request, error = XMessagePack.Decode(content) + if request == nil then + XLog.Error("XRpc.Do 函数错误, 服务端返回的数据解码错误, 错误原因: " .. error) + return + end + + XRpc.DebugPrint(XRpc.DEBUG_TYPE.Recv, name, request) + handler(request) +end + +setmetatable(XRpc, { + __newindex = function(_, name, handler) + if type(name) ~= "string" then + XLog.Error("XRpc.register 函数错误, 参数name必须是string类型, type: " .. type(name)) + return + end + + if type(handler) ~= "function" then + XLog.Error("XRpc.register 函数错误, 注册的接收服务端数据的函数的值必须是函数类型, type: " .. type(handler)) + return + end + + if handlers[name] and not IsHotReloadOpen then + XLog.Error("XRpc.register 函数错误, 存在相同名字的接收服务端数据的函数, 名字是: " .. name) + return + end + handlers[name] = handler + end, +}) + +XRpc.TestRequest = function(request) + XLog.Warning(request); +end \ No newline at end of file diff --git a/Resources/Scripts/XCommon/XRpcExceptionCode.lua b/Resources/Scripts/XCommon/XRpcExceptionCode.lua new file mode 100644 index 00000000..1e07fe61 --- /dev/null +++ b/Resources/Scripts/XCommon/XRpcExceptionCode.lua @@ -0,0 +1,14 @@ +-- auto export form enum +-- Automatic generation of code, forbid to edit or delete +XRpcExceptionCode = { + Success = 0, + DecodeError = 1, + ServerInternalError = 2, + RequestOutOfLimit = 3, + RpcTimeout = 4, + InvalidRequest = 5, + InvalidArgument = 6, + FeaturesNotOpen = 7, + RequestBlocked = 8, + ServiceUnavailable = 9, +} diff --git a/Resources/Scripts/XCommon/XSaveTool.lua b/Resources/Scripts/XCommon/XSaveTool.lua new file mode 100644 index 00000000..3ee712bb --- /dev/null +++ b/Resources/Scripts/XCommon/XSaveTool.lua @@ -0,0 +1,146 @@ +local tostring = tostring +local load = load +local type = type +local ipairs = ipairs +local pairs = pairs +local string = string +local table = table + +local stringDump = string.dump +local stringGmatch = string.gmatch +local tableUnpack = table.unpack +local tableInsert = table.insert +local tableSort = table.sort +local tableConcat = table.concat + + +XSaveTool = XSaveTool or {} +XSaveTool.LocalCache = {} + +local function fret(...) + local args = { ... } + return function() + return tableUnpack(args) + end +end + +--==============================-- +--desc: 数据字符串化 +--@val: 需要封装成字符串的数据 +--@needSort: 是否需要排序 +--@cache: 缓存处理,table引用死锁判断 +--@return 封装好的字符串 +--==============================-- +function XSaveTool.Stringify(val, needSort, cache) + cache = cache or {} + + return (({ + ["nil"] = fret "nil", + ["boolean"] = fret(tostring(val)), + ["number"] = fret(val), + ["function"] = function() + return "function(...)" .. + "return load(" .. + XSaveTool.Stringify(stringDump(val), needSort, cache) .. + ")(...)" .. + "end" + end, + ["string"] = function() + local s = "\"" + for c in stringGmatch(val, ".") do + s = s .. "\\" .. c:byte() + end + return s .. "\"" + end, + ["table"] = function() + if cache[val] then + XLog.Error("loop Stringify") + return + end + cache[val] = true + local members = {} + if needSort then + local keys = {} + for k, _ in pairs(val) do + tableInsert(keys, k) + end + tableSort(keys) + for _, v in ipairs(keys) do + tableInsert(members, "[" .. XSaveTool.Stringify(v, needSort, cache) .. "]=" .. XSaveTool.Stringify(val[v], needSort, cache)) + end + else + for k, v in pairs(val) do + tableInsert(members, "[" .. XSaveTool.Stringify(k, needSort, cache) .. "]=" .. XSaveTool.Stringify(v, needSort, cache)) + end + end + return "{" .. tableConcat(members, ",") .. "}" + end, + })[type(val)] or function() + XLog.Error("cannot Stringify type:" .. type(val), 2) + end)() +end + +--==============================-- +--desc: 本地数据持久化 +--@key: 存储key +--@value: 存储值 +--==============================-- +function XSaveTool.SaveData(key, value) + local k = XSaveTool.Stringify(key, true) + if value == false then + XSaveTool.LocalCache[k] = nil + else + XSaveTool.LocalCache[k] = value or XSaveTool.LocalCache[k] + end + CS.UnityEngine.PlayerPrefs.SetString("LuaData:" .. k, XSaveTool.Stringify(XSaveTool.LocalCache[k])) + CS.UnityEngine.PlayerPrefs.Save() +end + +--==============================-- +--desc: 持久化数据删除 +--@key: 数据key +--==============================-- +function XSaveTool.RemoveData(key) + local k = XSaveTool.Stringify(key, true) + XSaveTool.LocalCache[k] = nil + CS.UnityEngine.PlayerPrefs.DeleteKey("LuaData:" .. k) +end + +--==============================-- +--desc: 获取持久化数据 +--@key: 存储key +--@return 存储值 +--==============================-- +function XSaveTool.GetData(key) + local k = XSaveTool.Stringify(key, true) + if XSaveTool.LocalCache[k] then + return XSaveTool.LocalCache[k] + end + + local str = CS.UnityEngine.PlayerPrefs.GetString("LuaData:" .. k) + if str and str ~= "" then + local obj = load("return " .. str)() + XSaveTool.LocalCache[k] = obj + return obj + end + + return nil +end + +--==============================-- +--desc: 移除所有持久化数据(调试) +--==============================-- +function XSaveTool.RemoveAll() + local enable1 = XDataCenter.GuideManager.CheckFuncDisable() + local enable2 = XDataCenter.CommunicationManager.CheckFuncDisable() + local enable3 = XDataCenter.FunctionEventManager.CheckFuncDisable() + local enable4 = XRpc.CheckLuaNetLogEnable() + + XSaveTool.LocalCache = {} + CS.UnityEngine.PlayerPrefs.DeleteAll() + + XDataCenter.GuideManager.ChangeFuncDisable(enable1) + XDataCenter.CommunicationManager.ChangeFuncDisable(enable2) + XDataCenter.FunctionEventManager.ChangeFuncDisable(enable3) + XRpc.SetLuaNetLogEnable(enable4) +end \ No newline at end of file diff --git a/Resources/Scripts/XCommon/XScheduleManager.lua b/Resources/Scripts/XCommon/XScheduleManager.lua new file mode 100644 index 00000000..ec8b566c --- /dev/null +++ b/Resources/Scripts/XCommon/XScheduleManager.lua @@ -0,0 +1,72 @@ +XScheduleManager = XScheduleManager or {} + +local CSXScheduleManager = CS.XScheduleManager +XScheduleManager.SECOND = CSXScheduleManager.SECOND + +require("XCommon/XTool") +local XTool = XTool +local IsEditor = XMain.IsEditorDebug + +-- /// +-- /// 启动定时器 +-- /// +-- /// 处理函数 +-- /// 间隔毫秒(第一次执行在间隔时间后) +-- /// 循环次数 +-- /// 延迟毫秒 +-- /// 定时器id +function XScheduleManager.Schedule(func, interval, loop, delay) + local name = IsEditor and XTool.GetStackTraceName() or nil + return CSXScheduleManager.Schedule(func, interval, loop, delay or 0, name) +end + +-- /// +-- /// 启动单次定时器 +-- /// +-- /// 处理函数 +-- /// 延迟毫秒 +-- /// 定时器id +function XScheduleManager.ScheduleOnce(func, delay) + local name = IsEditor and XTool.GetStackTraceName() or nil + return CSXScheduleManager.ScheduleOnce(func, delay, name) +end + +-- /// +-- /// 启动指定时间单次定时器 +-- /// +-- /// 处理函数 +-- /// 需要启动的时间 +-- /// 定时器id +function XScheduleManager.ScheduleAtTimestamp(func, timeStamp) + local name = IsEditor and XTool.GetStackTraceName() or nil + local nowTime = XTime.GetServerNowTimestamp() + if timeStamp <= nowTime then + return + end + return CSXScheduleManager.ScheduleOnce(func, (timeStamp - nowTime) * XScheduleManager.SECOND, name) +end + +-- /// +-- /// 启动永久定时器 +-- /// +-- /// 处理函数 +-- /// 间隔毫秒 +-- /// 延迟毫秒 +-- /// 定时器id +function XScheduleManager.ScheduleForever(func, interval, delay) + local name = IsEditor and XTool.GetStackTraceName() or nil + return CSXScheduleManager.ScheduleForever(func, interval, delay or 0, name) +end + +-- /// +-- /// 取消定时器 +-- /// +-- /// 定时器id +function XScheduleManager.UnSchedule(id) + return CSXScheduleManager.UnSchedule(id) +end + +-- 释放所有定时器 +function XScheduleManager.UnScheduleAll() + return CSXScheduleManager.UnScheduleAll() +end \ No newline at end of file diff --git a/Resources/Scripts/XCommon/XSignBoardPlayer.lua b/Resources/Scripts/XCommon/XSignBoardPlayer.lua new file mode 100644 index 00000000..b6eaee3d --- /dev/null +++ b/Resources/Scripts/XCommon/XSignBoardPlayer.lua @@ -0,0 +1,290 @@ +local XSignBoardPlayer = {} + +local PlayerState = { + IDLE = 0, + PLAYING = 1, + CHANGING = 2, + PAUSE = 3 +} + +--创建一个播放器 +function XSignBoardPlayer.New(playUi, coolTime, delay) + if playUi == nil then + return nil + end + + local player = {} + setmetatable(player, { __index = XSignBoardPlayer }) + player:Init(playUi, coolTime, delay) + return player +end + +--初始化 +function XSignBoardPlayer:Init(playUi, coolTime, delay) + + self.CoolTime = coolTime --冷却时间 + self.PlayUi = playUi --执行Ui + self.Status = PlayerState.IDLE + self.DelayStart = XTime.GetServerNowTimestamp() + delay + self.LastPlayTime = -1 + self.Delay = delay + self.Time = XTime.GetServerNowTimestamp() + self.AutoPlay = true + self.PlayOne = false +end + + +-- self.PlayerData.PlayerList = {} --播放列表 +-- self.PlayerData..PlayingElement = nil --播放对象 +-- self.PlayerData.PlayedList = {} --播放过的列表 +-- self.LastPlayTime = -1 --上次播放时间 +function XSignBoardPlayer:SetPlayerData(data) + self.PlayerData = data +end + +--设置播放队列 +function XSignBoardPlayer:SetPlayList(playList) + if not playList or #playList <= 0 then + return + end + + self.PlayerData.PlayerList = {} + self.PlayerData.LastPlayTime = -1 + self.DelayStart = self.Time + self.Delay + + for _, element in ipairs(playList) do + table.insert(self.PlayerData.PlayerList, element) + end +end + +--播放 +function XSignBoardPlayer:Play(tab, cvType) + if not tab then + return false + end + + if not self:IsActive() then + return false + end + + if self.PlayerData.PlayingElement and self.PlayerData.PlayingElement.Id == tab.Id then + return false + end + + local element = {} + element.Id = tab.Id --Id + element.AddTime = self.Time -- 添加事件 + element.StartTime = -1 --开始播放的时间 + element.EndTime = -1 --结束时间 + + -- 获取相应语言的动作持续时间 + local duration + local defaultCvType = CS.XGame.Config:GetInt("DefaultCvType") + local curElementCvType = cvType or CS.UnityEngine.PlayerPrefs.GetInt("CV_TYPE", defaultCvType) + + if tab.Duration[curElementCvType] == nil then + if tab.Duration[defaultCvType] == nil then + XLog.Error(string.format("XSignBoardPlayer:Play函数错误,配置表SignboardFeedback.tab没有配置Id:%s的Duration数据", tostring(element.Id))) + return false + end + duration = tab.Duration[defaultCvType] + else + duration = tab.Duration[curElementCvType] + end + + element.Duration = duration + element.Validity = tab.Validity --有效期 + element.CoolTime = 0--tab.CoolTime --冷却时间 + element.Weight = tab.Weight --权重 + element.SignBoardConfig = tab + element.CvType = cvType + table.insert(self.PlayerData.PlayerList, 1, element) + + return true +end + +--播放下一个 +--isRecord决定是否要保存当前动作播放记录 +function XSignBoardPlayer:PlayNext(isRecord) + if not self:IsActive() then + return + end + + if not self.PlayerData.PlayerList or #self.PlayerData.PlayerList == 0 then + return + end + + --获取第一个在有限期之类的动画 + local head = nil + while #self.PlayerData.PlayerList > 0 and not head do + + local temp = table.remove(self.PlayerData.PlayerList, 1) + -- local lastPlayTime = self.PlayerData.PlayedList[temp.Id] + -- --如果还在冷却中 + -- if lastPlayTime and self.Time < lastPlayTime then + -- if #self.PlayerData.PlayerList <= 0 then + -- break + -- end + -- temp = table.remove(self.PlayerData.PlayerList, 1) + -- end + --检测是否过期 + if temp.Validity < 0 then + head = temp + else + local validity = temp.Validity + temp.AddTime + if validity > self.Time then + head = temp + end + end + end + + --如果找不到合适的动画 + if not head then + return + end + + head.StartTime = self.Time + + self.PlayerData.PlayingElement = head + self.Status = PlayerState.PLAYING + self.PlayerData.LastPlayTime = head.StartTime + head.Duration + + if isRecord then + -- 记录播放过的动作 + XDataCenter.SignBoardManager.RecordSignBoard(head.SignBoardConfig) + end + + self.PlayUi:Play(head) + + if self.PlayOne then + -- 清空播放列表,只播放当前权重最高的动画(head) + self.PlayerData.PlayerList = {} + end +end + +--停止 +function XSignBoardPlayer:Stop() + if self.PlayerData.PlayingElement == nil then + return + end + + self.PlayerData.PlayedList[self.PlayerData.PlayingElement.Id] = XTime.GetServerNowTimestamp() + self.PlayerData.PlayingElement.CoolTime + self.PlayUi:OnStop(self.PlayerData.PlayingElement) + self.PlayerData.PlayingElement = nil + self.Status = PlayerState.IDLE + self.LastPlayTime = XTime.GetServerNowTimestamp() +end + +--暂停 +function XSignBoardPlayer:Pause() + self.Status = PlayerState.PAUSE +end + +function XSignBoardPlayer:Freeze() + self.Status = PlayerState.STOP +end + +function XSignBoardPlayer:Resume() + self.LastPlayTime = XTime.GetServerNowTimestamp() + self.Status = PlayerState.IDLE +end + +--更新 +function XSignBoardPlayer:Update(deltaTime) + self.Time = self.Time + deltaTime + + if self.Time < self.DelayStart then + return + end + + if not self:IsActive() then + return + end + + if (not self.PlayerData.PlayerList or #self.PlayerData.PlayerList == 0) and self.PlayerData.PlayingElement == nil then + return + end + + if self.Status == PlayerState.STOP then + return + end + + if self.Status == PlayerState.PAUSE then + return + end + + local nextElementTime = self.PlayerData.LastPlayTime + self.CoolTime + + --存在播放中的动作 + if self.PlayerData.PlayingElement ~= nil and self.PlayerData.PlayingElement.Duration > 0 then + local deadline = self.PlayerData.PlayingElement.StartTime + self.PlayerData.PlayingElement.Duration + if deadline < self.Time then + if self.PlayUi.Parent.SetWhetherPlayChangeActionEffect then + --动作生命周期正常结束,不用播放打断特效 + self.PlayUi.Parent:SetWhetherPlayChangeActionEffect(false) + end + self:SetInterruptDetection(false) + self:Stop() + return + end + end + + --冷却时间 + if nextElementTime < self.Time and self.Status ~= PlayerState.PLAYING and self.AutoPlay then + self:PlayNext(true) + end +end + +function XSignBoardPlayer:SetInterruptDetection(boolValue) + self.IsInInterruptDetection = boolValue +end + +function XSignBoardPlayer:GetInterruptDetection() + return self.IsInInterruptDetection +end + +--强制运行 +function XSignBoardPlayer:ForcePlay(tab, cvType, isRecord) + if self.Status == PlayerState.STOP then + return + end + + if self:Play(tab, cvType) then + self:PlayNext(isRecord) + end +end + +function XSignBoardPlayer:IsPlaying() + return self.Status == PlayerState.PLAYING +end + +--设置自动播放 +function XSignBoardPlayer:SetAutoPlay(bAutoPlay) + self.AutoPlay = bAutoPlay +end + +-- 播放队列是否只播放权重最高的动画 +function XSignBoardPlayer:SetPlayOne(bPlayOne) + self.PlayOne = bPlayOne +end + +---生命周期---------------------------------------------- +function XSignBoardPlayer:IsActive() + return self.Active +end + +function XSignBoardPlayer:OnEnable() + self.Active = true + self:Resume() +end + +function XSignBoardPlayer:OnDisable() + self.Active = false + self:Stop() +end + +function XSignBoardPlayer:OnDestroy() + self:Stop() +end + +return XSignBoardPlayer \ No newline at end of file diff --git a/Resources/Scripts/XCommon/XStack.lua b/Resources/Scripts/XCommon/XStack.lua new file mode 100644 index 00000000..337283e4 --- /dev/null +++ b/Resources/Scripts/XCommon/XStack.lua @@ -0,0 +1,45 @@ +XStack = XClass(nil, "XStack") + +function XStack:Ctor() + self:Clear() +end + +function XStack:Clear() + self.__Container = {} + self.__EndIndex = 0 +end + +function XStack:IsEmpty() + return self.__EndIndex < 1 +end + +function XStack:Count() + return self.__EndIndex +end + +function XStack:Push(element) + if not element then return end + + local endIndex = self.__EndIndex + 1 + self.__EndIndex = endIndex + self.__Container[endIndex] = element +end + +function XStack:Pop() + if self:IsEmpty() then + self:Clear() + return + end + + local endIndex = self.__EndIndex + local element = self.__Container[endIndex] + + self.__EndIndex = endIndex - 1 + self.__Container[endIndex] = nil + + return element +end + +function XStack:Peek() + return self.__Container[self.__EndIndex] +end \ No newline at end of file diff --git a/Resources/Scripts/XCommon/XString.lua b/Resources/Scripts/XCommon/XString.lua new file mode 100644 index 00000000..0b1cdd1c --- /dev/null +++ b/Resources/Scripts/XCommon/XString.lua @@ -0,0 +1,411 @@ +--==============================-- +-- 字符串相关扩展方法 +--==============================-- +local tonumber = tonumber +local next = next +local pairs = pairs +local string = string +local table = table +local math = math + +local stringLen = string.len +local stringByte = string.byte +local stringSub = string.sub +local stringGsub = string.gsub +local stringFind = string.find +local stringMatch = string.match +local tableInsert = table.insert +local mathFloor = math.floor + +--==============================-- +--desc: 通过utf8获取字符串长度 +--@str: 字符串 +--@return 字符串长度 +--==============================-- +function string.Utf8Len(str) + local len = stringLen(str) + local left = len + local cnt = 0 + local arr = { 0, 192, 224, 240, 248, 252 } + while left ~= 0 do + local tmp = stringByte(str, -left) + local i = #arr + while arr[i] do + if tmp >= arr[i] then + left = left - i + break + end + i = i - 1 + end + cnt = cnt + 1 + end + return cnt +end + +--==============================-- +--desc: 通过utf8获取单个字符长度 +--@str: 单个字符 +--@return 字符串长度 +--==============================-- +function string.Utf8Size(char) + if not char then + return 0 + elseif char >= 252 then + return 6 + elseif char >= 248 then + return 5 + elseif char >= 240 then + return 4 + elseif char >= 225 then + return 3 + elseif char >= 192 then + return 2 + else + return 1 + end +end + +--==============================-- +--desc: 按utf8长度截取字符串 +--@str: 字符串 +--@return 字符串 +--==============================-- +function string.Utf8Sub(str, startChar, numChars) + local startIndex = 1 + while startChar > 1 do + local char = stringByte(str, startIndex) + startIndex = startIndex + string.Utf8Size(char) + startChar = startChar - 1 + end + + local currentIndex = startIndex + while numChars > 0 and currentIndex <= #str do + local char = stringByte(str, currentIndex) + currentIndex = currentIndex + string.Utf8Size(char) + numChars = numChars - 1 + end + return str:sub(startIndex, currentIndex - 1) +end + +--==============================-- +--desc: 将字符串分割成char table +--@str: 字符串 +--@return char table +--==============================-- +function string.SplitWordsToCharTab(str) + local len = stringLen(str) + local left = len + local chartab = {} + local arr = { 0, 192, 224, 240, 248, 252 } + while left ~= 0 do + local tmp = stringByte(str, -left) + local i = #arr + local value = left + + while arr[i] do + if tmp >= arr[i] then + left = left - i + break + end + i = i - 1 + end + + local char = stringSub(str, -value, -left - 1) + if stringSub(str, -left, -left + 1) == "\\n" then + left = left - 2 + char = char .. "\n" + end + tableInsert(chartab, char) + end + return chartab +end + +--==============================-- +--desc: 把有富文本格式的字符串变成char table +--@str: 富文本字符串 +--@return char table +--==============================-- +function string.CharsConvertToCharTab(str) + --str = "我只是用来{测一测}别xiabibi{红色试一试}试玩啦"-- + local leftindexs = {} + local rightindexs = {} + local startpos = 1 + while true do + local pos = stringFind(str, "{", startpos) + + if not pos then + break + end + + tableInsert(leftindexs, pos) + pos = stringFind(str, "}", pos + 1) + if not pos then + break + end + + tableInsert(rightindexs, pos) + startpos = pos + 1 + end + + local words = {} + if #leftindexs > 0 then + startpos = 1 + for i = 1, #leftindexs do + tableInsert(words, stringSub(str, startpos, leftindexs[i] - 1)) + tableInsert(words, stringSub(str, leftindexs[i] + 1, rightindexs[i] - 1)) + startpos = rightindexs[i] + 1 + end + + if rightindexs[#rightindexs] ~= stringLen(str) then + tableInsert(words, stringSub(str, startpos)) + end + else + tableInsert(words, str) + end + + local result = {} + for i = 1, #words do + local tab + local IsRichText + local format + + if stringSub(words[i], 1, 1) == "<" then + IsRichText = true + local pa = stringMatch(words[i], "%b>(.*)<") + format = stringGsub(words[i], "%b>#$#\|-_=+*()!@#$%^&*~` ]] +local FilterSymbolsTable = FilterSymbols:SplitWordsToCharTab() +function string.FilterWords(str) + local result = "" + for i = 1, string.Utf8Len(str) do + local nowStr = string.Utf8Sub(str, i, 1) + local isValid = true + for _, v in pairs(FilterSymbolsTable) do + if nowStr == v then + isValid = false + break + end + end + if isValid then + result = result .. nowStr + end + end + + return result +end + +--==============================-- +--desc: 字符串每隔X个字符插入 需要的字符串 +--@str: 字符串对象 +--@interval: 间隔多少个字符 +--@insertStr: 插入的字符串 +--@return 过滤后文本 +--==============================-- +function string.InsertStr(str, interval, insertStr) + local index = 1 + local worldCount = 0 + local result = "" + + while true do + local world = stringSub(str, index, index) + local byte = stringByte(world) + + if byte > 128 then + world = stringSub(str, index, index + 2) + index = index + 3 + else + index = index + 1 + end + + result = result .. world + worldCount = worldCount + 1 + if worldCount >= interval then + result = result .. insertStr + worldCount = 0 + end + + if index > #str then + break + end + end + + return result +end + +--判断字符串是否为合法IP"[0-255].[0-255].[0-255].[0-255]" +function string.IsIp(ip) + if string.IsNilOrEmpty(ip) then return false end + + local valueSet = table.pack(string.find(ip, "(%d+)%.(%d+)%.(%d+)%.(%d+)")) + + if not valueSet[1] then return false end + + local ipNum + for i = 3, 6 do + ipNum = tonumber(valueSet[i]) + if not ipNum or ipNum < 0 or ipNum > 255 then + return false + end + end + + return true +end \ No newline at end of file diff --git a/Resources/Scripts/XCommon/XTable.lua b/Resources/Scripts/XCommon/XTable.lua new file mode 100644 index 00000000..4ebe7fe5 --- /dev/null +++ b/Resources/Scripts/XCommon/XTable.lua @@ -0,0 +1,9911 @@ +XTable = { + XTableInfo = { + Name = {ValueType = "string"}, + Sha1 = {ValueType = "string"}, + }, + XTableConfig = { + Key = {ValueType = "string"}, + Type = {ValueType = "string"}, + Value = {ValueType = "string"}, + }, + XTableServerInfo = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + State = {ValueType = "int"}, + LoginUrl = {ValueType = "string"}, + }, + XTableCodeText = { + Id = {ValueType = "int"}, + Key = {ValueType = "string"}, + Text = {ValueType = "string"}, + }, + XTableText = { + Key = {ValueType = "string"}, + Text = {ValueType = "string"}, + }, + XTableGmText = { + Key = {ValueType = "string"}, + Text = {ValueType = "string"}, + }, + XTableCode = { + Code = {ValueType = "string"}, + }, + XTableGuideGroup = { + Id = {ValueType = "int"}, + Priority = {ValueType = "int"}, + Ignore = {ValueType = "int"}, + Desc = {ValueType = "string"}, + GuideType = {ValueType = "int"}, + ConditionId = {Type = 1, ValueType = "int"}, + CompleteId = {ValueType = "int"}, + ActiveUi = {ValueType = "string"}, + RewardId = {ValueType = "int"}, + GroupId = {ValueType = "int"}, + }, + XTableGuideStep = { + Id = {ValueType = "int"}, + NextStep = {ValueType = "int"}, + Mask = {ValueType = "int"}, + ConditionType = {ValueType = "int"}, + ConditionParam = {ValueType = "string"}, + CompleteType = {ValueType = "int"}, + CompleteParam = {ValueType = "string"}, + Effect = {ValueType = "string"}, + Arrow = {ValueType = "int"}, + UiName = {ValueType = "string"}, + IsFlow = {Type = 1, ValueType = "int"}, + FlowParam = {Type = 1, ValueType = "string"}, + ListIndex = {Type = 1, ValueType = "int"}, + Target = {Type = 1, ValueType = "string"}, + Record = {ValueType = "int"}, + RewardId = {ValueType = "int"}, + IconPos = {ValueType = "int"}, + Icon = {ValueType = "string"}, + Name = {ValueType = "string"}, + Text = {ValueType = "string"}, + }, + XTableGuideFightStep = { + Id = {ValueType = "int"}, + Type = {ValueType = "int"}, + DescriptionType = {ValueType = "int"}, + Name = {ValueType = "string"}, + Icon = {ValueType = "string"}, + Text = {ValueType = "string"}, + Duration = {ValueType = "int"}, + NeedSendCommonClick = {ValueType = "bool"}, + OffsetY = {ValueType = "float"}, + IsMask = {ValueType = "bool"}, + MaskTarget = {ValueType = "string"}, + Duration = {ValueType = "int"}, + UiType = {ValueType = "int"}, + ClickKey = {ValueType = "string"}, + NeedSendCommonClick = {ValueType = "bool"}, + }, + XTableFightTalkOption = { + Id = {ValueType = "int"}, + Option1 = {ValueType = "string"}, + Option2 = {ValueType = "string"}, + Option3 = {ValueType = "string"}, + Option4 = {ValueType = "string"}, + TimeToEnd = {ValueType = "int"}, + }, + XTableGuideFight = { + Id = {ValueType = "int"}, + StageId = {ValueType = "int"}, + NpcId = {Type = 1, ValueType = "int"}, + Weapon = {Type = 1, ValueType = "int"}, + }, + XTableGuideComplete = { + Id = {ValueType = "int"}, + Desc = {ValueType = "string"}, + Param = {Type = 1, ValueType = "int"}, + }, + XTableNpc = { + Id = {ValueType = "int"}, + UiResId = {ValueType = "int"}, + Type = {ValueType = "int"}, + Kind = {ValueType = "int"}, + Name = {ValueType = "string"}, + UseShadowMesh = {ValueType = "bool"}, + ShadowQuadScale = {ValueType = "float"}, + ModelId = {ValueType = "string"}, + ColliderType = {ValueType = "int"}, + PolygonId = {ValueType = "int"}, + BodyRadius = {ValueType = "fix"}, + HitRadius = {ValueType = "float"}, + BaseHeight = {ValueType = "float"}, + CameraCollideRadius = {ValueType = "float"}, + MoveUseFaceDir = {ValueType = "bool"}, + AttribId = {ValueType = "int"}, + AttribType = {ValueType = "int"}, + PromotedId = {ValueType = "int"}, + AttackSkillId = {ValueType = "int"}, + DodgeSkillId = {ValueType = "int"}, + ModelScale = {ValueType = "float"}, + EffectScale = {ValueType = "float"}, + MissileScale = {ValueType = "fix"}, + OffsetScale = {ValueType = "fix"}, + CatchType = {ValueType = "int"}, + BossHp = {ValueType = "bool"}, + HpWdigetCount = {ValueType = "int"}, + HpWidgetHeight = {ValueType = "float"}, + HpWidgetType = {ValueType = "int"}, + RollCharHeight = {ValueType = "float"}, + HasRunTilt = {ValueType = "bool"}, + HasSprintTilt = {ValueType = "bool"}, + HasRunToStand = {ValueType = "bool"}, + HasSprintToStand = {ValueType = "bool"}, + HasRunStart = {ValueType = "bool"}, + HasStandTransition = {ValueType = "bool"}, + HasSquatState = {ValueType = "bool"}, + HasSprintState = {ValueType = "bool"}, + WalkMotionOffset = {ValueType = "bool"}, + RunMotionOffset = {ValueType = "bool"}, + SquatMotionOffset = {ValueType = "bool"}, + SprintMotionOffset = {ValueType = "bool"}, + BeHitInterval = {ValueType = "fix"}, + LieOnFloorTime = {ValueType = "fix"}, + StandUpImmuneHitTime = {ValueType = "fix"}, + StandUpTailTime = {ValueType = "fix"}, + MaxHitValue = {ValueType = "int"}, + DeathTime = {ValueType = "fix"}, + NoThreat = {ValueType = "bool"}, + NotToThreatTarget = {ValueType = "bool"}, + CollisionPriority = {ValueType = "int"}, + IgnoreCollisionToNpc = {ValueType = "bool"}, + IgnoreCollisionFromNpc = {ValueType = "bool"}, + ForceSqueezeOut = {ValueType = "bool"}, + RobotBornMagic = {Type = 1, ValueType = "int"}, + BornMagic = {Type = 1, ValueType = "int"}, + DeathMagic = {Type = 1, ValueType = "int"}, + SkillId = {Type = 1, ValueType = "int"}, + Ball = {ValueType = "string"}, + RandomBall = {ValueType = "string"}, + ImmuneHitLevel = {ValueType = "int"}, + }, + XTableNpcRes = { + Id = {ValueType = "int"}, + ModelId = {ValueType = "string"}, + HeadImageName = {ValueType = "string"}, + }, + XTableNieRNpc = { + Id = {ValueType = "int"}, + AutoStateMachine = {ValueType = "bool"}, + ShowEffect = {Type = 1, ValueType = "string"}, + HideEffect = {Type = 1, ValueType = "string"}, + SwitchDelay = {Type = 1, ValueType = "float"}, + }, + XTableModel = { + Id = {ValueType = "string"}, + ModelPath = {ValueType = "string"}, + LowModelPath = {ValueType = "string"}, + ControllerPath = {ValueType = "string"}, + DisplayControllerPath = {ValueType = "string"}, + UiDefaultAnimationPath = {ValueType = "string"}, + }, + XTableUiModel = { + Id = {ValueType = "string"}, + ModelPath = {ValueType = "string"}, + LowModelPath = {ValueType = "string"}, + ControllerPath = {ValueType = "string"}, + DisplayControllerPath = {ValueType = "string"}, + UiDefaultAnimationPath = {ValueType = "string"}, + FashionControllerPath = {ValueType = "string"}, + }, + XTableSummonedNpcModel = { + NpcId = {ValueType = "int"}, + MasterModelId = {ValueType = "string"}, + ModelId = {ValueType = "string"}, + }, + XTableNpcAttrib = { + Id = {ValueType = "int"}, + Life = {ValueType = "fix"}, + Energy = {ValueType = "fix"}, + RunSpeed = {ValueType = "fix"}, + SprintSpeed = {ValueType = "fix"}, + WalkSpeed = {ValueType = "fix"}, + TurnRoundSpeed = {ValueType = "fix"}, + BallInterval = {ValueType = "fix"}, + DamageNormalImmunity = {ValueType = "fix"}, + DamageMagicImmunity = {ValueType = "fix"}, + AntiDamageNormalImmunity = {ValueType = "fix"}, + AntiDamageMagicImmunity = {ValueType = "fix"}, + AttackNormal = {ValueType = "fix"}, + AttackMagic1 = {ValueType = "fix"}, + AttackMagic2 = {ValueType = "fix"}, + AttackMagic3 = {ValueType = "fix"}, + AttackMagic4 = {ValueType = "fix"}, + AntiAttackNormal = {ValueType = "fix"}, + AntiAttackMagic1 = {ValueType = "fix"}, + AntiAttackMagic2 = {ValueType = "fix"}, + AntiAttackMagic3 = {ValueType = "fix"}, + AntiAttackMagic4 = {ValueType = "fix"}, + DefenseNormal = {ValueType = "fix"}, + AntiDefenseNormal = {ValueType = "fix"}, + DamageChangeP = {ValueType = "fix"}, + DamageNormalChangeP = {ValueType = "fix"}, + DamageMagic1ChangeP = {ValueType = "fix"}, + DamageMagic2ChangeP = {ValueType = "fix"}, + DamageMagic3ChangeP = {ValueType = "fix"}, + DamageMagic4ChangeP = {ValueType = "fix"}, + AntiDamageChangeP = {ValueType = "fix"}, + AntiDamageNormalChangeP = {ValueType = "fix"}, + AntiDamageMagic1ChangeP = {ValueType = "fix"}, + AntiDamageMagic2ChangeP = {ValueType = "fix"}, + AntiDamageMagic3ChangeP = {ValueType = "fix"}, + AntiDamageMagic4ChangeP = {ValueType = "fix"}, + Damage1P = {ValueType = "fix"}, + Damage2P = {ValueType = "fix"}, + Damage3P = {ValueType = "fix"}, + Crit = {ValueType = "fix"}, + CritP = {ValueType = "fix"}, + CritDamageP = {ValueType = "fix"}, + AntiCritP = {ValueType = "fix"}, + AntiCritDamageP = {ValueType = "fix"}, + Lifesteal = {ValueType = "fix"}, + LifestealP = {ValueType = "fix"}, + CureChangeP = {ValueType = "fix"}, + AntiCureChangeP = {ValueType = "fix"}, + Endure = {ValueType = "fix"}, + ThreatRateP = {ValueType = "fix"}, + DodgeEnergy = {ValueType = "fix"}, + DodgeEnergyAutoRecovery = {ValueType = "fix"}, + CustomEnergy = {ValueType = "fix"}, + AccuResistance1 = {ValueType = "fix"}, + AccuResistance2 = {ValueType = "fix"}, + AccuResistance3 = {ValueType = "fix"}, + AccuResistance4 = {ValueType = "fix"}, + AccuResistance5 = {ValueType = "fix"}, + AccuResistance6 = {ValueType = "fix"}, + AccuResistance7 = {ValueType = "fix"}, + AccuResistance8 = {ValueType = "fix"}, + AccuResistance9 = {ValueType = "fix"}, + AccuResistance10 = {ValueType = "fix"}, + SquatSpeed = {ValueType = "fix"}, + NormalWeaknessP = {ValueType = "fix"}, + Magic1WeaknessP = {ValueType = "fix"}, + Magic2WeaknessP = {ValueType = "fix"}, + Magic3WeaknessP = {ValueType = "fix"}, + Magic4WeaknessP = {ValueType = "fix"}, + CustomEnergyGroup1 = {ValueType = "fix"}, + CustomEnergyGroup2 = {ValueType = "fix"}, + CustomEnergyGroup3 = {ValueType = "fix"}, + CustomEnergyGroup4 = {ValueType = "fix"}, + Hack = {ValueType = "fix"}, + HackChangeP = {ValueType = "fix"}, + AntiHackChangeP = {ValueType = "fix"}, + HackAutoRecovery = {ValueType = "fix"}, + }, + XTableNpcAffix = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Level = {ValueType = "int"}, + Icon = {ValueType = "string"}, + Description = {ValueType = "string"}, + }, + XTableMap = { + Id = {ValueType = "int"}, + Behavior = {ValueType = "int"}, + Name = {ValueType = "string"}, + Environment = {ValueType = "string"}, + TerrainRoot = {ValueType = "string"}, + CloseLoadingDelay = {ValueType = "fix"}, + SwitchNpcCd = {ValueType = "fix"}, + SceneCamera = {ValueType = "string"}, + CameraId = {ValueType = "int"}, + Terrains = {Type = 1, ValueType = "int"}, + Position = {Type = 1, ValueType = "string"}, + Rotation = {Type = 1, ValueType = "string"}, + IsAsyncLoadNpc = {ValueType = "bool"}, + }, + XTableMapLut = { + Scene = {ValueType = "string"}, + Prefab = {ValueType = "string"}, + Size = {ValueType = "string"}, + Area = {ValueType = "string"}, + Position = {ValueType = "string"}, + }, + XTableNavMeshSize = { + CellWidth = {ValueType = "int"}, + CellHeight = {ValueType = "int"}, + OffsetX = {ValueType = "fix"}, + OffsetY = {ValueType = "fix"}, + RotationY = {ValueType = "fix"}, + UseAreaPathFind = {ValueType = "bool"}, + }, + XTableNavMeshArea = { + Key = {ValueType = "string"}, + CellX = {ValueType = "int"}, + CellY = {ValueType = "int"}, + Type = {ValueType = "int"}, + CollisionEffect = {ValueType = "bool"}, + }, + XTableNavMeshPosition = { + Info = {ValueType = "string"}, + Key = {ValueType = "string"}, + X = {ValueType = "int"}, + Y = {ValueType = "int"}, + }, + XTableMagicType = { + Name = {ValueType = "string"}, + Type = {ValueType = "string"}, + }, + XTableMagic = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Level = {Type = 1, ValueType = "string"}, + }, + XTableBuff = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Desc = {ValueType = "string"}, + Delay = {ValueType = "fix"}, + Duration = {ValueType = "fix"}, + Cd = {ValueType = "fix"}, + Limit = {ValueType = "int"}, + Kind = {ValueType = "string"}, + Mutex = {ValueType = "string"}, + Cover = {ValueType = "string"}, + Magic = {ValueType = "int"}, + Effect = {ValueType = "string"}, + EffectJoint = {ValueType = "string"}, + TriggerInterval = {ValueType = "fix"}, + TriggerMagic = {ValueType = "int"}, + TriggerOnAdd = {ValueType = "bool"}, + EffectType = {ValueType = "int"}, + AffixId = {ValueType = "int"}, + Icon = {ValueType = "string"}, + DyingRemove = {ValueType = "bool"}, + GroupIds = {Type = 1, ValueType = "int"}, + }, + XTableEmoji = { + Id = {ValueType = "int"}, + Order = {ValueType = "int"}, + Name = {ValueType = "string"}, + BigIcon = {ValueType = "string"}, + Path = {ValueType = "string"}, + Description = {ValueType = "string"}, + WorldDesc = {ValueType = "string"}, + IsFree = {ValueType = "int"}, + ConvertItemId = {ValueType = "int"}, + ConvertItemCount = {ValueType = "int"}, + TimeLimitType = {ValueType = "int"}, + ExpireTimeStr = {ValueType = "string"}, + Duration = {ValueType = "int"}, + }, + XTableNameplate = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Title = {ValueType = "string"}, + NameplateQuality = {ValueType = "int"}, + Group = {ValueType = "int"}, + Description = {ValueType = "string"}, + NameplateGameplayType = {ValueType = "string"}, + Hint = {Type = 1, ValueType = "string"}, + NameplateGetWay = {ValueType = "string"}, + NameplateUpgradeType = {ValueType = "int"}, + Params = {Type = 1, ValueType = "int"}, + DecomposeExp = {ValueType = "int"}, + UpgradeExp = {ValueType = "int"}, + ConvertItemId = {ValueType = "int"}, + ConvertItemCount = {ValueType = "int"}, + ExpireTimeStr = {ValueType = "string"}, + Duration = {ValueType = "int"}, + IconType = {ValueType = "int"}, + Icon = {ValueType = "string"}, + BackBoard = {ValueType = "string"}, + OutLineColor = {ValueType = "string"}, + QualityIcon = {ValueType = "string"}, + }, + XTableChatEffect = { + Id = {ValueType = "int"}, + BeginTimeStr = {ValueType = "string"}, + EndTimeStr = {ValueType = "string"}, + Keyword = {Type = 1, ValueType = "string"}, + Path = {Type = 1, ValueType = "string"}, + Weight = {Type = 1, ValueType = "int"}, + CoolTime = {ValueType = "string"}, + TriggerType = {ValueType = "int"}, + Channel = {Type = 1, ValueType = "int"}, + }, + XTableNpcMovie = { + Id = {ValueType = "string"}, + OffsetType = {ValueType = "int"}, + TotalFrame = {ValueType = "int"}, + UseStartPosition = {ValueType = "bool"}, + LauncherStartX = {ValueType = "fix"}, + LauncherStartZ = {ValueType = "fix"}, + LauncherStartRadian = {ValueType = "fix"}, + LauncherEndX = {ValueType = "fix"}, + LauncherEndZ = {ValueType = "fix"}, + LauncherEndRadian = {ValueType = "fix"}, + TargetEndX = {ValueType = "fix"}, + TargetEndZ = {ValueType = "fix"}, + TargetEndRadian = {ValueType = "fix"}, + NpcEndX = {Type = 1, ValueType = "fix"}, + NpcEndZ = {Type = 1, ValueType = "fix"}, + NpcEndRadian = {Type = 1, ValueType = "fix"}, + }, + XTableNpcAnimationEvent = { + Role = {ValueType = "string"}, + Animation = {ValueType = "string"}, + Layer = {ValueType = "int"}, + TotalFrame = {ValueType = "int"}, + TailLength = {ValueType = "fix"}, + Function = {ValueType = "string"}, + Params = {Type = 1, ValueType = "string"}, + EventDataDict = {Type = 2, KeyType = "int", ValueType = ""}, + }, + XTableNpcAnimationEventType = { + Id = {ValueType = "int"}, + Function = {ValueType = "string"}, + Params = {Type = 1, ValueType = "string"}, + }, + XTableNpcMovieMotion = { + Id = {ValueType = "string"}, + BindingKey = {ValueType = "string"}, + TotalFrame = {ValueType = "int"}, + TailLength = {ValueType = "fix"}, + OffsetX = {Type = 1, ValueType = "fix"}, + OffsetZ = {Type = 1, ValueType = "fix"}, + }, + XTableBehaviorNodeType = { + Name = {ValueType = "string"}, + Type = {ValueType = "string"}, + }, + XTableBehaviorNode = { + Id = {ValueType = "int"}, + Type = {ValueType = "int"}, + Negative = {ValueType = "bool"}, + Name = {ValueType = "string"}, + Param = {ValueType = "string"}, + Children = {Type = 1, ValueType = "int"}, + }, + XTableBehavior = { + Id = {ValueType = "int"}, + Type = {ValueType = "string"}, + Priority = {ValueType = "int"}, + PrefixRoot = {ValueType = "int"}, + Root = {ValueType = "int"}, + PreLoadRoot = {ValueType = "int"}, + }, + XTableSkill = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + SkillType = {ValueType = "int"}, + SkillMoveType = {ValueType = "int"}, + SkillFaceType = {ValueType = "int"}, + Animation = {ValueType = "string"}, + CastTime = {ValueType = "fix"}, + AfterTime = {ValueType = "fix"}, + Cd = {ValueType = "fix"}, + DistNoTarget = {ValueType = "fix"}, + SkillMoveTrackDistance = {ValueType = "fix"}, + DistAbort = {ValueType = "fix"}, + DodgeLimitTime = {ValueType = "fix"}, + MissileLockTarget = {ValueType = "bool"}, + CastMagicIds = {ValueType = "string"}, + FinalMagicIds = {ValueType = "string"}, + SkillPriority = {ValueType = "int"}, + SkillAnimationPriority = {ValueType = "int"}, + CoexistSkills = {ValueType = "string"}, + Snapshot = {ValueType = "bool"}, + StandStage = {ValueType = "int"}, + }, + XTableSkillKeyframe = { + Id = {ValueType = "int"}, + Key = {Type = 1, ValueType = "string"}, + }, + XTableMissile = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Shape = {ValueType = "int"}, + SizeX = {ValueType = "fix"}, + SizeY = {ValueType = "fix"}, + OffsetX = {ValueType = "fix"}, + OffsetY = {ValueType = "fix"}, + Speed = {ValueType = "fix"}, + HitSpeed = {ValueType = "fix"}, + Direction = {ValueType = "int"}, + LockLauncherFightTarget = {ValueType = "bool"}, + TargetType = {ValueType = "int"}, + TrackTarget = {ValueType = "bool"}, + SwitchTargetOnHit = {ValueType = "bool"}, + LiveTime = {ValueType = "fix"}, + FillTime = {ValueType = "fix"}, + ActiveDelayTime = {ValueType = "fix"}, + DeadExplosion = {ValueType = "bool"}, + HitCount = {ValueType = "int"}, + RepeatDamage = {ValueType = "bool"}, + HitEffectUseMissileDirection = {ValueType = "bool"}, + HitEffect = {Type = 1, ValueType = "string"}, + DamageInterval = {ValueType = "fix"}, + StartJoint = {ValueType = "string"}, + Effect = {ValueType = "string"}, + WaitTime = {ValueType = "fix"}, + DamageCount = {ValueType = "int"}, + DamageRange = {ValueType = "fix"}, + ExplodeOnFloor = {ValueType = "bool"}, + ExplosionEffect = {ValueType = "string"}, + LineType = {ValueType = "int"}, + LineParams = {Type = 1, ValueType = "fix"}, + Magic = {Type = 1, ValueType = "int"}, + MagicLauncherPlayer = {Type = 1, ValueType = "int"}, + MagicLauncherNpc = {Type = 1, ValueType = "int"}, + ScaleFunction = {ValueType = "int"}, + ScaleType = {ValueType = "int"}, + ScaleParams = {Type = 1, ValueType = "fix"}, + BornPosition = {ValueType = "int"}, + ChildDelay = {ValueType = "fix"}, + ChildInterval = {ValueType = "fix"}, + ChildCountLimit = {ValueType = "int"}, + ChildId = {ValueType = "string"}, + BornChildWhileDead = {ValueType = "bool"}, + NpcSearcherId = {ValueType = "int"}, + OverrideTarget = {ValueType = "bool"}, + BornDirectionType = {ValueType = "int"}, + BindLauncher = {ValueType = "int"}, + EffectHeight = {ValueType = "float"}, + HitOnJoint = {ValueType = "string"}, + ResizeEffect = {ValueType = "bool"}, + BeHitCenter = {ValueType = "int"}, + BeHitState = {ValueType = "int"}, + BindSkill = {ValueType = "bool"}, + DodgeLimitMark = {ValueType = "bool"}, + IgnoreNpcTimeScale = {ValueType = "bool"}, + ScaleTimeOnHit = {ValueType = "bool"}, + TimeScale = {ValueType = "fix"}, + TimeScaleDuration = {ValueType = "int"}, + TimeScaleEaseIn = {ValueType = "int"}, + TimeScaleEaseOut = {ValueType = "int"}, + HitShakeDuration = {ValueType = "float"}, + HitShakeIntensity = {ValueType = "float"}, + HitShakeDirection = {ValueType = "float"}, + MoveExcludeObstacle = {ValueType = "bool"}, + ActsExcludeObstacle = {ValueType = "bool"}, + ExplosionOnCollideObstacle = {ValueType = "bool"}, + ReboundTimes = {ValueType = "int"}, + ReboundType = {ValueType = "int"}, + DeathWithNpc = {ValueType = "int"}, + }, + XTableChain = { + Id = {ValueType = "int"}, + Effect = {ValueType = "string"}, + LeapInterval = {ValueType = "fix"}, + LeapRange = {ValueType = "fix"}, + LeapTimes = {ValueType = "int"}, + TargetType = {ValueType = "int"}, + WithBuffKind = {Type = 1, ValueType = "int"}, + WithoutBuffKind = {Type = 1, ValueType = "int"}, + Magics = {Type = 1, ValueType = "int"}, + LauncherMagics = {Type = 1, ValueType = "int"}, + Joint = {ValueType = "string"}, + HitEffect = {ValueType = "string"}, + BeHitState = {ValueType = "int"}, + BeHitDirection = {ValueType = "int"}, + HitShakeDuration = {ValueType = "float"}, + HitShakeIntensity = {ValueType = "float"}, + HitShakeEulerY = {ValueType = "float"}, + }, + XTableTrap = { + Name = {ValueType = "string"}, + CellX = {ValueType = "int"}, + CellY = {ValueType = "int"}, + }, + XTableAction = { + Name = {ValueType = "string"}, + ActionLoop = {ValueType = "int"}, + ActionDelay = {ValueType = "int"}, + ActionParamType = {ValueType = "string"}, + }, + XTableBigSprite = { + Tag = {ValueType = "string"}, + IsOneByOne = {ValueType = "int"}, + }, + XTableNpcBeHitState = { + Id = {ValueType = "int"}, + Type = {ValueType = "int"}, + OriginType = {ValueType = "int"}, + Time = {ValueType = "fix"}, + HoverTime = {ValueType = "fix"}, + ImmuneHitTime = {ValueType = "fix"}, + ImmuneHitValue = {ValueType = "int"}, + Speed = {ValueType = "fix"}, + Acceleration = {ValueType = "fix"}, + MoveTime = {ValueType = "fix"}, + HitFlyMoveSpeed = {ValueType = "fix"}, + HitFlyMoveAcceleration = {ValueType = "fix"}, + HitFlyUpSpeed = {ValueType = "fix"}, + HitFlyDownSpeed = {ValueType = "fix"}, + Rebound = {ValueType = "fix"}, + IgnoreImmuneLevel = {ValueType = "int"}, + }, + XTableNpcSearcher = { + Id = {ValueType = "int"}, + Range = {ValueType = "fix"}, + WithBuffs = {Type = 1, ValueType = "int"}, + WithoutBuffs = {Type = 1, ValueType = "int"}, + DistanceCoe = {ValueType = "fix"}, + AngleCoe = {ValueType = "fix"}, + }, + XTableNpcSkillBall = { + Id = {ValueType = "int"}, + Icon = {Type = 1, ValueType = "string"}, + LinkEffect = {Type = 1, ValueType = "string"}, + ReleaseEffect = {Type = 1, ValueType = "string"}, + ExEffect = {Type = 1, ValueType = "string"}, + ClickEffect = {Type = 1, ValueType = "string"}, + }, + XTableCharacter = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + TradeName = {ValueType = "string"}, + LogName = {ValueType = "string"}, + EnName = {ValueType = "string"}, + Type = {ValueType = "int"}, + Sex = {ValueType = "int"}, + StoryChapterId = {ValueType = "int"}, + Intro = {ValueType = "string"}, + ItemId = {ValueType = "int"}, + LevelUpTemplateId = {ValueType = "int"}, + Priority = {ValueType = "int"}, + EquipType = {ValueType = "int"}, + EquipId = {ValueType = "int"}, + EmotionIcon = {ValueType = "string"}, + Foreshow = {ValueType = "int"}, + DefaultNpcFashtionId = {ValueType = "int"}, + CaptainSkillId = {ValueType = "int"}, + MissionInfo = {ValueType = "string"}, + NeedFirstShow = {ValueType = "int"}, + Code = {ValueType = "string"}, + Element = {ValueType = "int"}, + ShowTimeId = {ValueType = "int"}, + }, + XTableGraph = { + Id = {ValueType = "int"}, + GraphName = {ValueType = "string"}, + }, + XTableCharacterInitData = { + Id = {ValueType = "int"}, + }, + XTableCharacterLevelUp = { + Level = {ValueType = "int"}, + Exp = {ValueType = "int"}, + }, + XTableCharDetail = { + Id = {ValueType = "int"}, + BigImgPath = {ValueType = "string"}, + ObtainElementList = {Type = 1, ValueType = "int"}, + ObtainElementValueList = {Type = 1, ValueType = "int"}, + ObtainSpeicalTitle = {Type = 1, ValueType = "string"}, + ObtainSpeicalDes = {Type = 1, ValueType = "string"}, + AttribGraphDes = {Type = 1, ValueType = "string"}, + AttribGraphNum = {Type = 1, ValueType = "int"}, + Career = {ValueType = "int"}, + DetailDes = {ValueType = "string"}, + CareerIcon = {ValueType = "string"}, + }, + XTableCharacterRecommend = { + Id = {ValueType = "int"}, + CharacterRecomend = {Type = 1, ValueType = "int"}, + }, + XTableEquipRecommend = { + Id = {ValueType = "int"}, + EquipRecomend = {ValueType = "int"}, + ChipRecomend = {Type = 1, ValueType = "int"}, + }, + XTableCharacterElement = { + Id = {ValueType = "int"}, + ElementName = {ValueType = "string"}, + Description = {ValueType = "string"}, + Icon = {ValueType = "string"}, + Icon2 = {ValueType = "string"}, + }, + XTableCharacterTabId = { + Id = {ValueType = "int"}, + CharacterId = {ValueType = "int"}, + TabId = {ValueType = "int"}, + TabName = {ValueType = "string"}, + RecommendType = {ValueType = "int"}, + GroupId = {ValueType = "int"}, + }, + XTableItem = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Description = {ValueType = "string"}, + WorldDesc = {ValueType = "string"}, + BigIcon = {ValueType = "string"}, + Icon = {ValueType = "string"}, + ItemType = {ValueType = "int"}, + Quality = {ValueType = "int"}, + Priority = {ValueType = "int"}, + MaxCount = {ValueType = "int"}, + GridCount = {ValueType = "int"}, + TimelinessType = {ValueType = "int"}, + StartTime = {ValueType = "string"}, + Duration = {ValueType = "int"}, + RecycleRewardId = {ValueType = "int"}, + RecycleByMail = {ValueType = "bool"}, + SellForId = {ValueType = "int"}, + SellForCount = {ValueType = "int"}, + RecType = {ValueType = "int"}, + RecTime = {ValueType = "string"}, + RecCount = {ValueType = "int"}, + SuitId = {ValueType = "int"}, + FastTrading = {ValueType = "int"}, + SkipIdParams = {Type = 1, ValueType = "int"}, + SubTypeParams = {Type = 1, ValueType = "int"}, + }, + XTableCharacterQualityFragment = { + Id = {ValueType = "int"}, + Quality = {ValueType = "int"}, + Type = {ValueType = "int"}, + DecomposeCount = {ValueType = "int"}, + ComposeCount = {ValueType = "int"}, + StarUseCount = {Type = 1, ValueType = "int"}, + PromoteItemId = {ValueType = "int"}, + PromoteUseCoin = {ValueType = "int"}, + }, + XTableCharacterQuality = { + Id = {ValueType = "int"}, + CharacterId = {ValueType = "int"}, + Quality = {ValueType = "int"}, + NpcId = {ValueType = "int"}, + AttrId = {Type = 1, ValueType = "int"}, + }, + XTableCharacterLiberation = { + Id = {ValueType = "int"}, + CharacterId = {ValueType = "int"}, + GrowUpLevel = {ValueType = "int"}, + ModelId = {ValueType = "string"}, + EffectRootName = {ValueType = "string"}, + EffectPath = {ValueType = "string"}, + Title = {ValueType = "string"}, + Desc = {ValueType = "string"}, + }, + XTableCharacterGrade = { + Id = {ValueType = "int"}, + CharacterId = {ValueType = "int"}, + Grade = {ValueType = "int"}, + UseItemKey = {ValueType = "int"}, + UseItemCount = {ValueType = "int"}, + AttrId = {ValueType = "int"}, + ConditionId = {Type = 1, ValueType = "int"}, + GradeBigIcon = {ValueType = "string"}, + GradeIcon = {ValueType = "string"}, + Star = {ValueType = "string"}, + NoStar = {ValueType = "string"}, + GradeName = {ValueType = "string"}, + }, + XTableCharacterSkill = { + CharacterId = {ValueType = "int"}, + SkillGroupId = {Type = 1, ValueType = "int"}, + Pos = {Type = 1, ValueType = "int"}, + }, + XTableCharacterSkillGroup = { + Id = {ValueType = "int"}, + SkillId = {Type = 1, ValueType = "int"}, + }, + XTableCharacterSkillUpgrade = { + Id = {ValueType = "int"}, + SkillId = {ValueType = "int"}, + Level = {ValueType = "int"}, + Name = {ValueType = "string"}, + Intro = {ValueType = "string"}, + Icon = {ValueType = "string"}, + ConditionId = {Type = 1, ValueType = "int"}, + UseSkillPoint = {ValueType = "int"}, + UseCoin = {ValueType = "int"}, + }, + XTableCharacterSkillUpgradeDes = { + Id = {ValueType = "int"}, + SkillId = {ValueType = "int"}, + Level = {ValueType = "int"}, + Name = {ValueType = "string"}, + WeaponSkillDes = {ValueType = "string"}, + Intro = {ValueType = "string"}, + Icon = {ValueType = "string"}, + EntryId = {Type = 1, ValueType = "int"}, + }, + XTableCharacterSkillEntry = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Description = {ValueType = "string"}, + }, + XTableCharacterSkillLevelEffect = { + Id = {ValueType = "int"}, + SkillId = {ValueType = "int"}, + Level = {ValueType = "int"}, + BornMagic = {Type = 1, ValueType = "int"}, + SubSkillId = {Type = 1, ValueType = "int"}, + SubMagicId = {Type = 1, ValueType = "int"}, + Ability = {ValueType = "int"}, + ResonanceAbility = {ValueType = "int"}, + PlusAbility = {ValueType = "int"}, + }, + XTableCharacterSkillType = { + Id = {ValueType = "int"}, + Type = {ValueType = "int"}, + }, + XTableCharacterSkillTypePlus = { + Id = {ValueType = "int"}, + CharacterType = {Type = 1, ValueType = "int"}, + SkillType = {Type = 1, ValueType = "int"}, + }, + XTableCharacterPos = { + CharacterId = {ValueType = "int"}, + MainSkillIcon = {Type = 1, ValueType = "string"}, + MainSkillName = {Type = 1, ValueType = "string"}, + MainSkillType = {Type = 1, ValueType = "string"}, + }, + XTableCharacterSkillTeach = { + Id = {ValueType = "int"}, + StageId = {ValueType = "int"}, + Title = {ValueType = "string"}, + WebUrl = {ValueType = "string"}, + Icon = {ValueType = "string"}, + TeachIcon = {ValueType = "string"}, + Description = {ValueType = "string"}, + }, + XTableNpcAnimatorAction = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + IsTrigger = {ValueType = "bool"}, + }, + XTableCharacterRes = { + Id = {ValueType = "int"}, + }, + XTableCharacterQualityIcon = { + Quality = {ValueType = "int"}, + Icon = {ValueType = "string"}, + IconCharacter = {ValueType = "string"}, + IconGoods = {ValueType = "string"}, + Desc = {ValueType = "string"}, + }, + XTablePartGrade = { + Id = {ValueType = "int"}, + PartId = {ValueType = "int"}, + Grade = {ValueType = "int"}, + Condition = {Type = 1, ValueType = "int"}, + NeedCoin = {ValueType = "int"}, + AttrId = {ValueType = "int"}, + GradeIcon = {ValueType = "string"}, + PartLevel = {ValueType = "int"}, + PartName = {ValueType = "string"}, + }, + XTablePart = { + Id = {ValueType = "int"}, + CharacterId = {ValueType = "int"}, + Part = {ValueType = "int"}, + Name = {ValueType = "string"}, + Icon = {ValueType = "string"}, + Desc = {ValueType = "string"}, + }, + XTableStage = { + StageId = {ValueType = "int"}, + EventId = {ValueType = "int"}, + NormalEventId = {Type = 1, ValueType = "int"}, + PreEventId = {Type = 1, ValueType = "int"}, + NormalEventIdOnPassed = {ValueType = "int"}, + UnlockEventId = {Type = 1, ValueType = "int"}, + RebootId = {ValueType = "int"}, + Name = {ValueType = "string"}, + Description = {ValueType = "string"}, + StarDesc = {Type = 1, ValueType = "string"}, + SettleLoseTipId = {ValueType = "int"}, + Icon = {ValueType = "string"}, + StoryIcon = {ValueType = "string"}, + OrderId = {ValueType = "int"}, + BgmId = {ValueType = "int"}, + AmbientSound = {ValueType = "int"}, + LoadingType = {ValueType = "string"}, + RewardTipId = {ValueType = "int"}, + RecommandLevel = {ValueType = "int"}, + IsMultiplayer = {ValueType = "bool"}, + RequireLevel = {ValueType = "int"}, + RequireActionPoint = {ValueType = "int"}, + CharacterLimitType = {ValueType = "int"}, + LimitBuffId = {ValueType = "int"}, + PassTimeLimit = {ValueType = "int"}, + PreStageId = {Type = 1, ValueType = "int"}, + FinishRewardShow = {ValueType = "int"}, + FirstRewardShow = {ValueType = "int"}, + FinishDropId = {ValueType = "int"}, + FirstRewardId = {ValueType = "int"}, + FlopRewardId = {ValueType = "int"}, + StarRewardId = {Type = 1, ValueType = "int"}, + TeamExp = {ValueType = "int"}, + CardExp = {ValueType = "int"}, + MaxChallengeNums = {ValueType = "int"}, + BuyChallengeCost = {ValueType = "int"}, + BuyChallengeCount = {ValueType = "int"}, + KeepPlayingStory = {ValueType = "int"}, + BeginStoryId = {ValueType = "string"}, + EndStoryId = {ValueType = "string"}, + OnlineLockChar = {ValueType = "bool"}, + OnlineLockEquipment = {ValueType = "bool"}, + OnlinePlayerLeast = {ValueType = "int"}, + OnlinePlayerLimit = {ValueType = "int"}, + MonsterIcon = {Type = 1, ValueType = "string"}, + HaveAssist = {ValueType = "int"}, + StandardUseTimeSec = {ValueType = "int"}, + SuggestedConditionId = {Type = 1, ValueType = "int"}, + ForceConditionId = {Type = 1, ValueType = "int"}, + HaveFirstPass = {ValueType = "bool"}, + FirstGotoSkipId = {ValueType = "int"}, + FunctionLeftBtn = {ValueType = "int"}, + FunctionRightBtn = {ValueType = "int"}, + RobotId = {Type = 1, ValueType = "int"}, + UrgentEventId = {Type = 1, ValueType = "int"}, + AutoFightId = {ValueType = "int"}, + StageType = {ValueType = "int"}, + StageGridStyle = {ValueType = "string"}, + FightControlId = {ValueType = "int"}, + NeedJobType = {Type = 1, ValueType = "int"}, + DisableJoystick = {ValueType = "bool"}, + MultiChallengeId = {ValueType = "int"}, + Restartable = {ValueType = "bool"}, + ResetHpCount = {Type = 1, ValueType = "int"}, + StoryUiStyle = {ValueType = "int"}, + OnlineMsgId = {ValueType = "int"}, + ForceAllyEffect = {ValueType = "bool"}, + DisableDeadEffect = {ValueType = "bool"}, + }, + XTableMultiChallengeStage = { + Id = {ValueType = "int"}, + ConsumeId = {Type = 1, ValueType = "int"}, + ConsumeNum = {Type = 1, ValueType = "int"}, + MultiChallengeMin = {ValueType = "int"}, + MultiChallengeMax = {ValueType = "int"}, + }, + XTableStageLevelControl = { + Id = {ValueType = "int"}, + StageId = {ValueType = "int"}, + MaxLevel = {ValueType = "int"}, + RecommendationLevel = {ValueType = "int"}, + FirstRewardShow = {ValueType = "int"}, + FinishRewardShow = {ValueType = "int"}, + FirstRewardId = {ValueType = "int"}, + FinishDropId = {ValueType = "int"}, + MonsterLevel = {Type = 1, ValueType = "int"}, + }, + XTableStageMultiplayerLevelControl = { + Id = {ValueType = "int"}, + StageId = {ValueType = "int"}, + Difficulty = {ValueType = "int"}, + DifficultyDesc = {ValueType = "string"}, + RecommendAbility = {ValueType = "int"}, + AdditionDest = {ValueType = "string"}, + FirstRewardId = {ValueType = "int"}, + FinishDropId = {ValueType = "int"}, + FlopRewardId = {ValueType = "int"}, + MonsterLevel = {Type = 1, ValueType = "int"}, + }, + XTableStageTransform = { + Id = {ValueType = "int"}, + PositionX = {ValueType = "float"}, + PositionY = {ValueType = "float"}, + PositionZ = {ValueType = "float"}, + RotationX = {ValueType = "float"}, + RotationY = {ValueType = "float"}, + RotationZ = {ValueType = "float"}, + Scale = {ValueType = "float"}, + ChildPosX = {ValueType = "float"}, + ChildPosY = {ValueType = "float"}, + ChildRotaionX = {ValueType = "float"}, + ChildRotaionY = {ValueType = "float"}, + ChildRotaionZ = {ValueType = "float"}, + }, + XTableChapterMain = { + Id = {ValueType = "int"}, + ChapterName = {ValueType = "string"}, + ChapterEn = {ValueType = "string"}, + Icon = {ValueType = "string"}, + OrderId = {ValueType = "int"}, + Difficult = {ValueType = "int"}, + BfrtId = {ValueType = "int"}, + ChapterId = {Type = 1, ValueType = "int"}, + ZhouMuId = {ValueType = "int"}, + }, + XTableChapterExtra = { + Id = {ValueType = "int"}, + ChapterName = {ValueType = "string"}, + ChapterEn = {ValueType = "string"}, + Icon = {ValueType = "string"}, + OrderId = {ValueType = "int"}, + ChapterId = {Type = 1, ValueType = "int"}, + ZhouMuId = {ValueType = "int"}, + }, + XTableChapter = { + ChapterId = {ValueType = "int"}, + OrderId = {ValueType = "int"}, + Difficult = {ValueType = "int"}, + ChapterEn = {ValueType = "string"}, + PrefabName = {ValueType = "string"}, + StageId = {Type = 1, ValueType = "int"}, + TreasureId = {Type = 1, ValueType = "int"}, + ChapterName = {ValueType = "string"}, + Bg = {ValueType = "string"}, + Icon = {ValueType = "string"}, + ActivityCondition = {ValueType = "int"}, + ExploreGroupId = {ValueType = "int"}, + OpenCondition = {ValueType = "int"}, + }, + XTableChapterExtraDetails = { + ChapterId = {ValueType = "int"}, + OrderId = {ValueType = "int"}, + Difficult = {ValueType = "int"}, + ChapterEn = {ValueType = "string"}, + PrefabName = {ValueType = "string"}, + StageId = {Type = 1, ValueType = "int"}, + TreasureId = {Type = 1, ValueType = "int"}, + ChapterName = {ValueType = "string"}, + MoveStageIndex = {ValueType = "int"}, + DatumLinePrecent = {ValueType = "float"}, + Icon = {ValueType = "string"}, + ActivityCondition = {ValueType = "int"}, + ExploreGroupId = {ValueType = "int"}, + StageTitle = {ValueType = "string"}, + OpenCondition = {ValueType = "int"}, + }, + XTableSection = { + SectionId = {ValueType = "int"}, + SectionName = {ValueType = "string"}, + Icon = {ValueType = "string"}, + OrderId = {ValueType = "int"}, + StageId = {Type = 1, ValueType = "int"}, + TreasureId = {Type = 1, ValueType = "int"}, + PosX = {ValueType = "float"}, + PosY = {ValueType = "float"}, + }, + XTableTreasure = { + TreasureId = {ValueType = "int"}, + RequireStar = {ValueType = "int"}, + RewardId = {ValueType = "int"}, + }, + XTableChapterExtraStarTreasure = { + TreasureId = {ValueType = "int"}, + RequireStar = {ValueType = "int"}, + RewardId = {ValueType = "int"}, + }, + XTableMainLineActivity = { + Id = {ValueType = "int"}, + ChapterId = {Type = 1, ValueType = "int"}, + BfrtChapter = {ValueType = "int"}, + ChapterTimeId = {ValueType = "int"}, + HideChapterTimeId = {ValueType = "int"}, + }, + XTableChapterExtraActivity = { + Id = {ValueType = "int"}, + ChapterId = {Type = 1, ValueType = "int"}, + ChapterTimeId = {ValueType = "int"}, + HideChapterTimeId = {ValueType = "int"}, + }, + XTableCharacterStoryChaper = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + ConditionId = {ValueType = "int"}, + TaskId = {ValueType = "int"}, + StoryStageId = {Type = 1, ValueType = "int"}, + }, + XTableCharacterStoryStage = { + Id = {ValueType = "int"}, + OpenConditionId = {ValueType = "int"}, + ConditionId = {Type = 1, ValueType = "int"}, + StageId = {ValueType = "int"}, + StoryId = {ValueType = "string"}, + Name = {ValueType = "string"}, + Desc = {ValueType = "string"}, + Picture = {ValueType = "string"}, + TaskId = {ValueType = "int"}, + }, + XTableAutoFight = { + Id = {ValueType = "int"}, + Limit = {ValueType = "int"}, + }, + XTableFightTips = { + Id = {ValueType = "int"}, + Type = {ValueType = "int"}, + Title = {ValueType = "string"}, + Desc = {ValueType = "string"}, + Time = {ValueType = "float"}, + }, + XTableDailyDungeonRules = { + Id = {ValueType = "int"}, + Type = {ValueType = "int"}, + Title = {ValueType = "string"}, + Describe = {ValueType = "string"}, + Remark = {ValueType = "string"}, + SpecialConditionId = {Type = 1, ValueType = "int"}, + Priority = {ValueType = "int"}, + Icon = {ValueType = "string"}, + OpenDayOfWeek = {Type = 1, ValueType = "int"}, + DungeonOfWeek = {Type = 1, ValueType = "int"}, + }, + XTableDailyDungeonData = { + Id = {ValueType = "int"}, + Code = {ValueType = "string"}, + Name = {ValueType = "string"}, + Description = {ValueType = "string"}, + BgImg = {ValueType = "string"}, + Difficult = {ValueType = "int"}, + StageId = {Type = 1, ValueType = "int"}, + ConditionId = {Type = 1, ValueType = "int"}, + ShopId = {ValueType = "int"}, + }, + XTableDailySpecialCondition = { + Id = {ValueType = "int"}, + Type = {ValueType = "int"}, + IntParam = {Type = 1, ValueType = "int"}, + StringParam = {Type = 1, ValueType = "string"}, + Text = {ValueType = "string"}, + }, + XTableDailyDropGroup = { + Id = {ValueType = "int"}, + DungeonId = {ValueType = "int"}, + OpenDayOfWeek = {ValueType = "int"}, + Remark = {ValueType = "string"}, + RandomRewardId = {ValueType = "int"}, + FixedRewardId = {ValueType = "int"}, + }, + XTableChallengeDayReward = { + DayOfWeek = {ValueType = "int"}, + RewardId = {ValueType = "int"}, + }, + XTableUrgentEvent = { + Id = {ValueType = "int"}, + SimpleDesc = {ValueType = "string"}, + Icon = {ValueType = "string"}, + Effect = {ValueType = "string"}, + StageIcon = {ValueType = "string"}, + StageEffect = {ValueType = "string"}, + BgEffect = {ValueType = "string"}, + BgColor = {ValueType = "string"}, + SuccessRate = {ValueType = "int"}, + DayMaxLimit = {ValueType = "int"}, + Time = {ValueType = "int"}, + IsFailDestory = {ValueType = "bool"}, + MinLevel = {ValueType = "int"}, + MaxLevel = {ValueType = "int"}, + ConditionId = {Type = 1, ValueType = "int"}, + StageId = {Type = 1, ValueType = "int"}, + Weight = {Type = 1, ValueType = "int"}, + FightEvent = {Type = 1, ValueType = "int"}, + }, + XTableFightPasswordMap = { + Id = {ValueType = "int"}, + ImgPath = {ValueType = "string"}, + Password = {ValueType = "int"}, + }, + XTableFightPasswordGame = { + Id = {ValueType = "int"}, + MinPasswordMapId = {ValueType = "int"}, + MaxPasswordMapId = {ValueType = "int"}, + CorrectPasswords = {Type = 1, ValueType = "int"}, + }, + XTableFightPreload = { + Type = {ValueType = "int"}, + AssetName = {ValueType = "string"}, + }, + XTableFightPreloadSprite = { + Url = {ValueType = "string"}, + BorderX = {ValueType = "int"}, + BorderY = {ValueType = "int"}, + BorderZ = {ValueType = "int"}, + BorderW = {ValueType = "int"}, + }, + XTableSpriteTextAsset = { + Url = {ValueType = "string"}, + }, + XTableFightEvent = { + Id = {ValueType = "int"}, + ConditionId = {Type = 1, ValueType = "int"}, + BornMagic = {Type = 1, ValueType = "int"}, + EnemyBornMagic = {Type = 1, ValueType = "int"}, + PartnerBornMagic = {Type = 1, ValueType = "int"}, + Description = {ValueType = "string"}, + }, + XTableStageFightEvent = { + StageId = {ValueType = "int"}, + FightEventIds = {Type = 1, ValueType = "int"}, + }, + XTableStageFightEventDetails = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Icon = {ValueType = "string"}, + Description = {ValueType = "string"}, + }, + XTableWords = { + Word = {ValueType = "string"}, + }, + XTableFubenOnlineMsg = { + Id = {ValueType = "int"}, + Msg = {Type = 1, ValueType = "string"}, + }, + XTableEquip = { + Id = {ValueType = "int"}, + Type = {ValueType = "int"}, + Site = {ValueType = "int"}, + Quality = {ValueType = "int"}, + Star = {ValueType = "int"}, + WeaponSkillId = {ValueType = "int"}, + Priority = {ValueType = "int"}, + CharacterId = {ValueType = "int"}, + DefaultLock = {ValueType = "bool"}, + SuitId = {ValueType = "int"}, + CharacterType = {ValueType = "int"}, + Name = {ValueType = "string"}, + LogName = {ValueType = "string"}, + Description = {ValueType = "string"}, + NeedFirstShow = {ValueType = "int"}, + }, + XTableEquipRes = { + Id = {ValueType = "int"}, + BigIconPath = {ValueType = "string"}, + IconPath = {ValueType = "string"}, + ModelTransId = {Type = 1, ValueType = "int"}, + ResonanceModelTransId1 = {Type = 1, ValueType = "int"}, + ResonanceModelTransId2 = {Type = 1, ValueType = "int"}, + ResonanceModelTransId3 = {Type = 1, ValueType = "int"}, + LiHuiPath = {ValueType = "string"}, + PainterName = {ValueType = "string"}, + }, + XTableEquipInit = { + Id = {ValueType = "int"}, + Count = {ValueType = "int"}, + }, + XTableEquipLevelUp = { + Level = {ValueType = "int"}, + Exp = {ValueType = "int"}, + AllExp = {ValueType = "int"}, + }, + XTableEquipBreakthrough = { + Id = {ValueType = "int"}, + EquipId = {ValueType = "int"}, + Times = {ValueType = "int"}, + LevelLimit = {ValueType = "int"}, + UseItemId = {ValueType = "int"}, + UseMoney = {ValueType = "int"}, + AttribId = {ValueType = "int"}, + AttribPromotedId = {ValueType = "int"}, + Exp = {ValueType = "int"}, + LevelUpTemplateId = {ValueType = "int"}, + ConditionId = {ValueType = "int"}, + ResId = {ValueType = "int"}, + ItemId = {Type = 1, ValueType = "int"}, + ItemCount = {Type = 1, ValueType = "int"}, + }, + XTableEquipSuit = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Description = {ValueType = "string"}, + IconPath = {ValueType = "string"}, + BigIconPath = {ValueType = "string"}, + SkillEffect = {Type = 2, KeyType = "int", ValueType = "int"}, + SkillDescription = {Type = 2, KeyType = "int", ValueType = "string"}, + }, + XTableEquipSuitEffect = { + Id = {ValueType = "int"}, + BornMagic = {Type = 1, ValueType = "int"}, + SkillId = {Type = 1, ValueType = "int"}, + Ability = {ValueType = "int"}, + }, + XTableEquipDecompose = { + Id = {ValueType = "int"}, + Site = {ValueType = "int"}, + Star = {ValueType = "int"}, + Breakthrough = {ValueType = "int"}, + ExpToOneCoin = {ValueType = "float"}, + ExpToItemId = {ValueType = "int"}, + RewardId = {ValueType = "int"}, + }, + XTablePlayer = { + Level = {ValueType = "int"}, + MaxExp = {ValueType = "int"}, + MaxActionPoint = {ValueType = "int"}, + FreeActionPoint = {ValueType = "int"}, + MaxFriendCount = {ValueType = "int"}, + }, + XTableEquipModel = { + Id = {ValueType = "int"}, + ModelName = {Type = 2, KeyType = "int", ValueType = "string"}, + ResonanceEffectPath = {Type = 2, KeyType = "int", ValueType = "string"}, + ResonanceEffectShowDelay = {Type = 2, KeyType = "int", ValueType = "int"}, + AnimController = {Type = 2, KeyType = "int", ValueType = "string"}, + UiAnimStateName = {Type = 2, KeyType = "int", ValueType = "string"}, + UiAnimCueId = {Type = 2, KeyType = "int", ValueType = "int"}, + UiAnimDelay = {Type = 2, KeyType = "int", ValueType = "int"}, + UiAutoRotateDelay = {Type = 2, KeyType = "int", ValueType = "int"}, + }, + XTableEquipAnim = { + ModelId = {ValueType = "string"}, + Params = {ValueType = "int"}, + }, + XTableEquipModelTransform = { + Id = {ValueType = "int"}, + IndexId = {ValueType = "int"}, + UiName = {ValueType = "string"}, + PositionX = {ValueType = "float"}, + PositionY = {ValueType = "float"}, + PositionZ = {ValueType = "float"}, + RotationX = {ValueType = "float"}, + RotationY = {ValueType = "float"}, + RotationZ = {ValueType = "float"}, + ScaleX = {ValueType = "float"}, + ScaleY = {ValueType = "float"}, + ScaleZ = {ValueType = "float"}, + }, + XTableEquipSkipId = { + Id = {ValueType = "int"}, + EatType = {ValueType = "int"}, + Site = {ValueType = "int"}, + SkipIdParams = {Type = 1, ValueType = "int"}, + }, + XTableUiModelTransform = { + Id = {ValueType = "int"}, + UiName = {ValueType = "string"}, + ModelName = {ValueType = "string"}, + PositionX = {ValueType = "float"}, + PositionY = {ValueType = "float"}, + PositionZ = {ValueType = "float"}, + RotationX = {ValueType = "float"}, + RotationY = {ValueType = "float"}, + RotationZ = {ValueType = "float"}, + ScaleX = {ValueType = "float"}, + ScaleY = {ValueType = "float"}, + ScaleZ = {ValueType = "float"}, + }, + XTableUiSceneTransform = { + Id = {ValueType = "int"}, + UiName = {ValueType = "string"}, + SceneUrl = {ValueType = "string"}, + PositionX = {ValueType = "float"}, + PositionY = {ValueType = "float"}, + PositionZ = {ValueType = "float"}, + RotationX = {ValueType = "float"}, + RotationY = {ValueType = "float"}, + RotationZ = {ValueType = "float"}, + ScaleX = {ValueType = "float"}, + ScaleY = {ValueType = "float"}, + ScaleZ = {ValueType = "float"}, + }, + XTableItemInitData = { + Id = {ValueType = "int"}, + Count = {ValueType = "int"}, + }, + XTableCameraParam = { + Id = {ValueType = "string"}, + Desc = {ValueType = "string"}, + IsDragOrRotate = {ValueType = "int"}, + IsTweenCamera = {ValueType = "int"}, + AllowZoom = {ValueType = "int"}, + Distance = {ValueType = "float"}, + MinDistance = {ValueType = "float"}, + MaxDistance = {ValueType = "float"}, + ZoomSpeed = {ValueType = "float"}, + AllowXAxis = {ValueType = "int"}, + TargetAngleX = {ValueType = "float"}, + MinAngleX = {ValueType = "float"}, + MaxAngleX = {ValueType = "float"}, + XAxisSpeed = {ValueType = "float"}, + AllowYAxis = {ValueType = "int"}, + TargetAngleY = {ValueType = "float"}, + MinAngleY = {ValueType = "float"}, + MaxAngleY = {ValueType = "float"}, + YAxisSpeed = {ValueType = "float"}, + AllowDrag = {ValueType = "int"}, + DragSpeed = {ValueType = "float"}, + OffsetViewportX = {ValueType = "float"}, + OffsetViewportY = {ValueType = "float"}, + IsLockOnViewportOffset = {ValueType = "int"}, + ViewportPointX = {ValueType = "float"}, + ViewportPointY = {ValueType = "float"}, + }, + XTableFlopReward = { + Id = {ValueType = "int"}, + ConsumeItemId = {ValueType = "int"}, + ConsumeItemCount = {ValueType = "int"}, + ExtraActionPoint = {ValueType = "int"}, + ShowRewardId = {ValueType = "int"}, + DropId = {ValueType = "int"}, + ShowDropId = {ValueType = "int"}, + }, + XTableDropGroup = { + Id = {ValueType = "int"}, + DropIds = {Type = 1, ValueType = "string"}, + Weights = {Type = 1, ValueType = "int"}, + }, + XTableDropSet = { + Id = {ValueType = "int"}, + GroupIds = {Type = 1, ValueType = "int"}, + Weights = {Type = 1, ValueType = "int"}, + }, + XTableDrop = { + Id = {ValueType = "int"}, + TargetIds = {Type = 1, ValueType = "int"}, + Layers = {Type = 1, ValueType = "int"}, + Probability = {Type = 1, ValueType = "int"}, + BottomIds = {Type = 1, ValueType = "int"}, + }, + XTableDropBottom = { + Id = {ValueType = "int"}, + BottomDropType = {ValueType = "int"}, + BottomDropId = {ValueType = "int"}, + MeasureSetIds = {ValueType = "string"}, + MeasureGroupIds = {ValueType = "string"}, + MeasureDropIds = {ValueType = "string"}, + Min = {ValueType = "int"}, + Max = {ValueType = "int"}, + Priority = {ValueType = "int"}, + IsClose = {ValueType = "int"}, + UsableCount = {ValueType = "int"}, + CycleNeedCount = {ValueType = "int"}, + }, + XTableDropBottomLimit = { + Id = {ValueType = "int"}, + StartTimeStr = {ValueType = "string"}, + EndTimeStr = {ValueType = "string"}, + }, + XTableDraw = { + Id = {ValueType = "int"}, + GroupId = {ValueType = "int"}, + DrawType = {ValueType = "int"}, + UseItemId = {ValueType = "int"}, + UseItemCount = {ValueType = "int"}, + DailyLimitTimes = {ValueType = "int"}, + ActivityLimitTimes = {ValueType = "int"}, + StartTime = {ValueType = "string"}, + EndTime = {ValueType = "string"}, + Banner = {ValueType = "string"}, + PrimaryIdsMap = {ValueType = "string"}, + ExtraIdsMap = {ValueType = "string"}, + BtnDrawCount = {Type = 1, ValueType = "int"}, + DrawBottomIds = {Type = 2, KeyType = "int", ValueType = "int"}, + Note = {ValueType = "string"}, + SpecifiedGoodsId = {ValueType = "int"}, + MaxNotTriggerCount = {ValueType = "int"}, + ShowPriority = {ValueType = "int"}, + PurchaseUiType = {ValueType = "int"}, + CapacityCheckType = {ValueType = "int"}, + PurchaseId = {Type = 1, ValueType = "int"}, + }, + XTableDrawGroupLogName = { + Id = {ValueType = "int"}, + LogName = {ValueType = "string"}, + }, + XTableDrawGroup = { + Id = {ValueType = "int"}, + Priority = {ValueType = "int"}, + Name = {ValueType = "string"}, + ClockId = {ValueType = "int"}, + StartTime = {ValueType = "string"}, + EndTime = {ValueType = "string"}, + SwitchDrawIdActivityId = {ValueType = "int"}, + MaxSwitchDrawIdCount = {ValueType = "int"}, + Banner = {ValueType = "string"}, + UiPrefab = {ValueType = "string"}, + UiBackGround = {ValueType = "string"}, + IsClosed = {ValueType = "bool"}, + Tag = {ValueType = "int"}, + OptionalDrawIdCount = {ValueType = "string"}, + GoodsLimitConfig = {Type = 1, ValueType = "int"}, + TransformSuitList = {Type = 1, ValueType = "int"}, + Type = {ValueType = "int"}, + Note = {ValueType = "string"}, + ExtraRewardId = {ValueType = "int"}, + ExtraRewardCycleTimes = {ValueType = "int"}, + }, + XTableDrawGoodsLimit = { + Id = {ValueType = "int"}, + MinTimes = {ValueType = "int"}, + MaxTimes = {ValueType = "int"}, + LimitCount = {ValueType = "int"}, + UsePoolId = {ValueType = "int"}, + }, + XTableDrawGoodsLimitPool = { + Id = {ValueType = "int"}, + PoolId = {ValueType = "int"}, + GoodsId = {ValueType = "int"}, + }, + XTableDrawProbShow = { + Id = {ValueType = "int"}, + DrawId = {ValueType = "int"}, + IsUp = {ValueType = "bool"}, + Name = {ValueType = "string"}, + Type = {ValueType = "string"}, + ProbShow = {ValueType = "string"}, + Sort = {ValueType = "int"}, + }, + XTableDrawPreview = { + Id = {ValueType = "int"}, + UpGoodsId = {Type = 1, ValueType = "int"}, + GoodsId = {Type = 1, ValueType = "int"}, + }, + XTableDrawCombinations = { + Id = {ValueType = "int"}, + Type = {ValueType = "int"}, + GoodsId = {Type = 1, ValueType = "int"}, + }, + XTableDrawGroupRule = { + Id = {ValueType = "int"}, + TitleCN = {ValueType = "string"}, + TitleEN = {ValueType = "string"}, + RareRank = {ValueType = "int"}, + GroupBtnBg = {ValueType = "string"}, + MainRules = {Type = 1, ValueType = "string"}, + BaseRuleTitles = {Type = 1, ValueType = "string"}, + BaseRules = {Type = 1, ValueType = "string"}, + EventRuleTitles = {Type = 1, ValueType = "string"}, + EventRules = {Type = 1, ValueType = "string"}, + UpType = {ValueType = "string"}, + UpQuality = {ValueType = "string"}, + UpProbability = {ValueType = "string"}, + BottomText = {ValueType = "string"}, + NewHandBottomCount = {ValueType = "int"}, + SpecialBottomMin = {ValueType = "int"}, + SpecialBottomMax = {ValueType = "int"}, + DrawBottomHint = {ValueType = "string"}, + }, + XTableDrawShow = { + Type = {ValueType = "int"}, + TypeText = {ValueType = "string"}, + QualityText = {Type = 1, ValueType = "string"}, + UiAnim = {ValueType = "string"}, + UiResultAnim = {ValueType = "string"}, + DrawEffectGroupId = {Type = 1, ValueType = "int"}, + GachaEffectGroupId = {Type = 1, ValueType = "int"}, + }, + XTableDrawNewYearActivityShow = { + Type = {ValueType = "int"}, + TypeText = {ValueType = "string"}, + QualityText = {Type = 1, ValueType = "string"}, + UiAnim = {ValueType = "string"}, + UiResultAnim = {ValueType = "string"}, + PanelOpenUp = {Type = 1, ValueType = "string"}, + PanelOpenDown = {Type = 1, ValueType = "string"}, + PanelCardShowOff = {Type = 1, ValueType = "string"}, + EffectOpenBox = {Type = 1, ValueType = "string"}, + SkipEffect = {ValueType = "string"}, + PanelGachaOpenUp = {Type = 1, ValueType = "string"}, + PanelGachaOpenDown = {Type = 1, ValueType = "string"}, + EffectOpenGacha = {Type = 1, ValueType = "string"}, + GachaSkipEffect = {ValueType = "string"}, + }, + XTableDrawShowEffect = { + EffectGroupId = {ValueType = "int"}, + Note = {ValueType = "string"}, + PanelOpenUp = {ValueType = "string"}, + PanelOpenDown = {ValueType = "string"}, + PanelCardShowOff = {ValueType = "string"}, + EffectOpenBox = {ValueType = "string"}, + SkipEffect = {ValueType = "string"}, + }, + XTableDrawGroupRelation = { + NormalGroupId = {ValueType = "int"}, + DestinyGroupId = {ValueType = "int"}, + }, + XTableDrawCamera = { + Id = {ValueType = "int"}, + AllowHDR = {ValueType = "bool"}, + Intensity = {ValueType = "float"}, + Threshold = {ValueType = "float"}, + Saturation = {ValueType = "float"}, + SoftKnee = {ValueType = "float"}, + Radius = {ValueType = "float"}, + Iterations = {ValueType = "int"}, + }, + XTableDrawTabs = { + Id = {ValueType = "int"}, + TxtName1 = {ValueType = "string"}, + TxtName2 = {ValueType = "string"}, + TxtName3 = {ValueType = "string"}, + TxtTagName = {ValueType = "string"}, + TabBg = {ValueType = "string"}, + Priority = {ValueType = "int"}, + ParentName = {ValueType = "string"}, + Condition = {Type = 1, ValueType = "int"}, + }, + XTableDrawSkip = { + DrawGroupId = {ValueType = "int"}, + SkipId = {Type = 1, ValueType = "int"}, + }, + XTableTeam = { + Id = {ValueType = "int"}, + IsCaptain = {ValueType = "bool"}, + IsFirstFight = {ValueType = "bool"}, + EffectPath = {ValueType = "string"}, + Color = {ValueType = "string"}, + }, + XTableTeamType = { + TeamId = {ValueType = "int"}, + TypeId = {ValueType = "int"}, + ChapterId = {Type = 1, ValueType = "int"}, + SectionId = {Type = 1, ValueType = "int"}, + StageId = {Type = 1, ValueType = "int"}, + }, + XTableAttribDesc = { + Index = {ValueType = "int"}, + Name = {ValueType = "string"}, + Attrib = {ValueType = "string"}, + }, + XTableAttribAbility = { + Key = {ValueType = "string"}, + Ability = {ValueType = "fix"}, + PartnerAbility = {ValueType = "fix"}, + }, + XTableDisplay = { + Id = {ValueType = "int"}, + Model = {ValueType = "string"}, + Action = {ValueType = "string"}, + ContentId = {ValueType = "int"}, + Weight = {ValueType = "int"}, + }, + XTableDisplayContent = { + Id = {ValueType = "int"}, + Sound = {ValueType = "int"}, + Text = {ValueType = "string"}, + Duration = {ValueType = "int"}, + }, + XTableNpcTypeIcon = { + Type = {ValueType = "int"}, + Icon = {ValueType = "string"}, + IconTranspose = {ValueType = "string"}, + Des = {ValueType = "string"}, + Name = {ValueType = "string"}, + }, + XTableSecondaryFunctional = { + Id = {ValueType = "int"}, + Priority = {ValueType = "int"}, + Name = {ValueType = "string"}, + Activate = {ValueType = "int"}, + OpenId = {ValueType = "int"}, + Picture = {ValueType = "string"}, + Redirection = {ValueType = "string"}, + Cover = {ValueType = "string"}, + Click = {ValueType = "string"}, + }, + XTableCamera = { + Id = {ValueType = "int"}, + NewScheme = {ValueType = "bool"}, + DefaultMovementCoefficient = {ValueType = "float"}, + FocusMovementCoefficient = {ValueType = "float"}, + DollyOutCoefficient = {ValueType = "float"}, + DollyInCoefficient = {ValueType = "float"}, + DefaultRotationCoefficient = {ValueType = "float"}, + RotationSpeed = {ValueType = "float"}, + ExpBase = {ValueType = "float"}, + BufferRadian = {ValueType = "float"}, + DeadZoneRadius = {ValueType = "float"}, + HardZoneRadius = {ValueType = "float"}, + DeadZoneHeight = {ValueType = "float"}, + DefaultOffset = {ValueType = "float"}, + DefaultDistance = {ValueType = "float"}, + DefaultMinDistance = {ValueType = "float"}, + DefaultMaxDistance = {ValueType = "float"}, + MaxDistance = {ValueType = "float"}, + FocusMinDistance = {ValueType = "float"}, + FocusMaxDistance = {ValueType = "float"}, + FocusHorizontalCoefficient = {ValueType = "float"}, + FocusVerticalCoefficient = {ValueType = "float"}, + FocusMaxAngle = {ValueType = "float"}, + DefaultHeight = {ValueType = "float"}, + FocusHeight = {ValueType = "float"}, + MinHeight = {ValueType = "float"}, + MaxHeight = {ValueType = "float"}, + HeightUpCoefficient = {ValueType = "float"}, + HeightDownCoefficient = {ValueType = "float"}, + HeightOffset = {ValueType = "float"}, + RecenterThreshold = {ValueType = "float"}, + RecenterCoefficient = {ValueType = "float"}, + HorizontalDragSensitivity = {ValueType = "float"}, + VerticalDragSensitivity = {ValueType = "float"}, + MaxHorizontalDragSpeed = {ValueType = "float"}, + MaxVerticalDragSpeed = {ValueType = "float"}, + HorizontalDragAcceleration = {ValueType = "float"}, + VerticalDragAcceleration = {ValueType = "float"}, + RotationOverrideTime = {ValueType = "float"}, + ScaleSensitivity = {ValueType = "float"}, + MaxScaleSpeed = {ValueType = "float"}, + ScaleAcceleration = {ValueType = "float"}, + DefaultFOV = {ValueType = "float"}, + FocusFOV = {ValueType = "float"}, + DefaultToFocusDuration = {ValueType = "float"}, + FocusToDefaultDuration = {ValueType = "float"}, + MinVerticalAngle = {ValueType = "float"}, + MaxVerticalAngle = {ValueType = "float"}, + }, + XTableFightRollChar = { + Key = {ValueType = "string"}, + UiTemplate = {ValueType = "string"}, + UiCotainer = {ValueType = "string"}, + RollCharRandomRangeHorizontal = {ValueType = "float"}, + RollCharRandomRangeVertical = {ValueType = "float"}, + RollCharMinDir = {ValueType = "float"}, + RollCharMaxDir = {ValueType = "float"}, + RollCharSpeed = {ValueType = "float"}, + RollCharLifeTime = {ValueType = "float"}, + RollCharBeginOpacity = {ValueType = "float"}, + RollCharEndOpacity = {ValueType = "float"}, + RollCharChangeOpacityTime = {ValueType = "float"}, + RollCharStayDuration = {ValueType = "float"}, + RollCharStayTime = {ValueType = "float"}, + RollCharOffsetX = {ValueType = "float"}, + RollCharOffsetY = {ValueType = "float"}, + }, + XTableFightDynamicHp = { + Id = {ValueType = "int"}, + Key = {ValueType = "string"}, + UiTemplate = {ValueType = "string"}, + }, + XTableStory = { + Id = {ValueType = "int"}, + Mask = {ValueType = "int"}, + BackgroundMusic = {ValueType = "string"}, + Title = {ValueType = "string"}, + Introduce = {ValueType = "string"}, + TitleIcon = {ValueType = "string"}, + SentenceId = {Type = 1, ValueType = "int"}, + }, + XTableSentence = { + SentenceId = {ValueType = "int"}, + OptionId = {ValueType = "int"}, + PlayTime = {ValueType = "float"}, + BackgroundMusic = {ValueType = "string"}, + DialogSoundEffect = {ValueType = "string"}, + DialogSoundMusic = {ValueType = "string"}, + RoleId = {ValueType = "int"}, + RoleName = {ValueType = "string"}, + IsNewRole = {ValueType = "bool"}, + PositionType = {ValueType = "int"}, + RoleIcon = {Type = 2, KeyType = "int", ValueType = "string"}, + RoleEffect = {Type = 2, KeyType = "int", ValueType = "string"}, + IsForce = {ValueType = "bool"}, + BgAimation = {ValueType = "string"}, + InAnimation = {Type = 2, KeyType = "int", ValueType = "string"}, + OutAnimation = {Type = 2, KeyType = "int", ValueType = "string"}, + BackgroundEffect = {ValueType = "string"}, + DialogBgImg = {ValueType = "string"}, + BackgroundImg = {ValueType = "string"}, + BackgroundImg2 = {ValueType = "string"}, + Content = {ValueType = "string"}, + }, + XTableObstacle = { + Id = {ValueType = "int"}, + Model = {ValueType = "string"}, + Shape = {ValueType = "int"}, + ShapeParams = {ValueType = "fix"}, + Lifetime = {ValueType = "fix"}, + Destructible = {ValueType = "bool"}, + Type = {ValueType = "int"}, + BlockNpc = {ValueType = "bool"}, + NpcTargetType = {ValueType = "int"}, + BlockMissile = {ValueType = "bool"}, + MissileKind = {ValueType = "int"}, + MissileTargetType = {ValueType = "int"}, + MissileInteractType = {ValueType = "int"}, + MissileInteractParams = {ValueType = "int"}, + }, + XTableOption = { + Id = {ValueType = "int"}, + StoryId = {Type = 1, ValueType = "int"}, + RewardId = {Type = 1, ValueType = "int"}, + Title = {Type = 1, ValueType = "string"}, + ConditionId = {Type = 1, ValueType = "int"}, + }, + XTableStoryRole = { + RoleId = {ValueType = "int"}, + Name = {ValueType = "string"}, + RoleIcon = {ValueType = "string"}, + Race = {ValueType = "string"}, + BodyId = {ValueType = "int"}, + BodyFeature = {ValueType = "string"}, + Age = {ValueType = "int"}, + BirthData = {ValueType = "string"}, + Height = {ValueType = "int"}, + Weight = {ValueType = "int"}, + BWH = {ValueType = "string"}, + BodyFace = {ValueType = "string"}, + Awareness = {ValueType = "string"}, + ActionStandard = {ValueType = "string"}, + CarrayDevice = {ValueType = "string"}, + IQ = {ValueType = "int"}, + EQ = {ValueType = "int"}, + Physical = {ValueType = "int"}, + Tactics = {ValueType = "int"}, + LeaderShip = {ValueType = "int"}, + }, + XTableMovieActor = { + RoleId = {ValueType = "int"}, + Name = {ValueType = "string"}, + RoleIcon = {ValueType = "string"}, + Race = {ValueType = "string"}, + Age = {ValueType = "int"}, + Height = {ValueType = "int"}, + Weight = {ValueType = "int"}, + Wepon = {ValueType = "string"}, + Team = {ValueType = "string"}, + FacePosX = {ValueType = "int"}, + FacePosY = {ValueType = "int"}, + }, + XTableMovieStaff = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + }, + XTableMovieRoleFace = { + RoleId = {ValueType = "int"}, + FaceLook = {Type = 1, ValueType = "string"}, + }, + XTableCondition = { + Id = {ValueType = "int"}, + Type = {ValueType = "int"}, + Params = {Type = 1, ValueType = "int"}, + Desc = {ValueType = "string"}, + Formula = {ValueType = "string"}, + }, + XTableAssist = { + AssistType = {ValueType = "int"}, + LevelKey = {ValueType = "int"}, + RoleMinLevel = {ValueType = "int"}, + RoleMaxLevel = {ValueType = "int"}, + TargetMinLevel = {ValueType = "int"}, + TargetMaxLevel = {ValueType = "int"}, + }, + XTableAssistCommon = { + AssistType = {ValueType = "int"}, + ShowNm = {ValueType = "int"}, + RoleRewardId = {ValueType = "int"}, + TargetRewardId = {ValueType = "int"}, + RoleRewardMaxNum = {ValueType = "int"}, + }, + XTableAssistRobot = { + Id = {ValueType = "int"}, + Level = {ValueType = "int"}, + NpcId = {ValueType = "int"}, + }, + XTableAssistRevise = { + Id = {ValueType = "int"}, + MaxValue = {ValueType = "int"}, + MinValue = {ValueType = "int"}, + AttribReviseId = {ValueType = "int"}, + }, + XTableAttribRevise = { + Id = {ValueType = "int"}, + AttribTypes = {Type = 1, ValueType = "int"}, + Values = {Type = 1, ValueType = "fix"}, + }, + XTableAssistRule = { + Id = {ValueType = "int"}, + DisplayRange = {Type = 1, ValueType = "int"}, + Weight = {ValueType = "int"}, + SuccessRate = {ValueType = "int"}, + Title = {ValueType = "string"}, + }, + XTableAssistType = { + Type = {ValueType = "int"}, + Name = {ValueType = "string"}, + Weight = {ValueType = "int"}, + }, + XTableReward = { + Id = {ValueType = "int"}, + SubIds = {Type = 1, ValueType = "int"}, + }, + XTableRewardGoods = { + Id = {ValueType = "int"}, + TemplateId = {ValueType = "int"}, + Count = {ValueType = "int"}, + Params = {Type = 1, ValueType = "int"}, + }, + XTableRewardItem = { + Id = {ValueType = "int"}, + ItemId = {ValueType = "int"}, + Count = {ValueType = "int"}, + }, + XTableRewardFashion = { + Id = {ValueType = "int"}, + ItemId = {ValueType = "int"}, + Count = {ValueType = "int"}, + }, + XTableRewardEquip = { + Id = {ValueType = "int"}, + TemplateId = {ValueType = "int"}, + Level = {ValueType = "int"}, + Star = {ValueType = "int"}, + BreakThrough = {ValueType = "int"}, + }, + XTableDropGoods = { + Id = {ValueType = "int"}, + TemplateId = {ValueType = "int"}, + MinCount = {ValueType = "int"}, + MaxCount = {ValueType = "int"}, + Span = {ValueType = "int"}, + Params = {Type = 1, ValueType = "int"}, + }, + XTableTask = { + Id = {ValueType = "int"}, + Type = {ValueType = "int"}, + Priority = {ValueType = "int"}, + Title = {ValueType = "string"}, + Desc = {ValueType = "string"}, + Icon = {ValueType = "string"}, + PreTaskId = {ValueType = "int"}, + ActivateCondition = {Type = 1, ValueType = "int"}, + Condition = {Type = 1, ValueType = "int"}, + Result = {ValueType = "int"}, + DropId = {ValueType = "int"}, + RewardId = {ValueType = "int"}, + SkipId = {ValueType = "int"}, + StartTime = {ValueType = "string"}, + EndTime = {ValueType = "string"}, + Suffix = {ValueType = "string"}, + ShowAfterTaskId = {ValueType = "int"}, + AchvType = {ValueType = "int"}, + GroupId = {ValueType = "int"}, + ShowAfterGroup = {ValueType = "int"}, + GroupTheme = {ValueType = "int"}, + ShowType = {ValueType = "int"}, + ShowCondition = {ValueType = "int"}, + }, + XTableCourse = { + StageId = {ValueType = "int"}, + RewardId = {ValueType = "int"}, + ShowId = {ValueType = "int"}, + Tip = {ValueType = "string"}, + TipEn = {ValueType = "string"}, + }, + XTableTaskPool = { + TaskPoolId = {ValueType = "int"}, + Desc = {ValueType = "string"}, + TaskId = {Type = 1, ValueType = "int"}, + }, + XTableTaskReset = { + ResetId = {ValueType = "int"}, + Type = {ValueType = "int"}, + LowerLevel = {ValueType = "int"}, + UpperLevel = {ValueType = "int"}, + TaskPool = {Type = 1, ValueType = "int"}, + }, + XTableTaskCondition = { + Id = {ValueType = "int"}, + Type = {ValueType = "int"}, + Params = {Type = 1, ValueType = "int"}, + }, + XTableTaskActiveness = { + Type = {ValueType = "int"}, + Activeness = {Type = 1, ValueType = "int"}, + RewardId = {Type = 1, ValueType = "int"}, + }, + XTableTaskTimeLimit = { + Id = {ValueType = "int"}, + TimeId = {ValueType = "int"}, + PlayerCondition = {Type = 1, ValueType = "int"}, + Duration = {ValueType = "int"}, + TaskId = {Type = 1, ValueType = "int"}, + DayTaskId = {Type = 1, ValueType = "int"}, + WeekTaskId = {Type = 1, ValueType = "int"}, + }, + XTableNewPlayerTaskGroup = { + Id = {ValueType = "int"}, + OpenDay = {ValueType = "int"}, + FirstTalk = {ValueType = "string"}, + TaskId = {Type = 1, ValueType = "int"}, + }, + XTableNewPlayerTaskTalk = { + Id = {ValueType = "int"}, + Title = {ValueType = "string"}, + StoryId = {ValueType = "string"}, + SpellName = {ValueType = "string"}, + RoleHalfIcon = {ValueType = "string"}, + ShowCharId = {ValueType = "int"}, + GetCount = {Type = 1, ValueType = "int"}, + TalkContent = {Type = 1, ValueType = "string"}, + }, + XTableBoneOffset = { + Role = {ValueType = "string"}, + Animation = {ValueType = "string"}, + Bone = {ValueType = "string"}, + Layer = {ValueType = "int"}, + OffsetX = {Type = 1, ValueType = "fix"}, + OffsetZ = {Type = 1, ValueType = "fix"}, + }, + XTableBuyAsset = { + Id = {ValueType = "int"}, + DailyLimit = {ValueType = "int"}, + Config = {Type = 1, ValueType = "int"}, + ExchangeType = {ValueType = "int"}, + CanMutiply = {ValueType = "int"}, + AutoClose = {ValueType = "int"}, + }, + XTableBuyAssetConfig = { + Id = {ValueType = "int"}, + Times = {ValueType = "int"}, + GainCount = {ValueType = "int"}, + ConsumeId = {Type = 1, ValueType = "int"}, + ConsumeCount = {Type = 1, ValueType = "int"}, + }, + XTableUiBuyAsset = { + Id = {ValueType = "int"}, + UiName = {ValueType = "string"}, + }, + XTableSkipFunctional = { + SkipId = {ValueType = "int"}, + Origin = {ValueType = "int"}, + UiName = {ValueType = "string"}, + ParamId = {ValueType = "int"}, + Explain = {ValueType = "string"}, + FunctionalId = {ValueType = "int"}, + TimeId = {ValueType = "int"}, + StartTime = {ValueType = "string"}, + CloseTime = {ValueType = "string"}, + CustomParams = {Type = 1, ValueType = "int"}, + IsHideFunc = {ValueType = "bool"}, + IsShowExplain = {ValueType = "bool"}, + }, + XTableFunctionalOpen = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Priority = {ValueType = "int"}, + Hint = {ValueType = "int"}, + Condition = {Type = 1, ValueType = "int"}, + Type = {ValueType = "int"}, + TimeId = {ValueType = "int"}, + }, + XTableShieldFunc = { + Id = {ValueType = "int"}, + UiName = {Type = 1, ValueType = "string"}, + }, + XTableFunctionalContents = { + Id = {ValueType = "int"}, + GroupId = {ValueType = "int"}, + Type = {ValueType = "int"}, + NpcName = {ValueType = "string"}, + NpcHalfIconPath = {ValueType = "string"}, + Contents = {ValueType = "string"}, + CueId = {ValueType = "int"}, + ContentsSkip = {ValueType = "int"}, + OptionTitle = {Type = 1, ValueType = "string"}, + Optionskip = {Type = 1, ValueType = "int"}, + }, + XTableFunctionalCommunication = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + ConditionIds = {Type = 1, ValueType = "int"}, + Priority = {ValueType = "int"}, + SkipId = {ValueType = "int"}, + BtnContent = {ValueType = "string"}, + NpcName = {ValueType = "string"}, + NpcHandIcon = {ValueType = "string"}, + Type = {ValueType = "int"}, + UiType = {ValueType = "int"}, + ContentsGroupId = {ValueType = "int"}, + }, + XTableFunctionalFestivalCommunication = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + ConditionIds = {Type = 1, ValueType = "int"}, + Priority = {ValueType = "int"}, + SkipId = {ValueType = "int"}, + BtnContent = {ValueType = "string"}, + NpcName = {ValueType = "string"}, + NpcHandIcon = {ValueType = "string"}, + Type = {ValueType = "int"}, + UiType = {ValueType = "int"}, + StartTimeStr = {ValueType = "string"}, + EndTimeStr = {ValueType = "string"}, + ContentsGroupId = {ValueType = "int"}, + }, + XTableMail = { + Id = {ValueType = "int"}, + Type = {ValueType = "int"}, + SendName = {ValueType = "string"}, + Title = {ValueType = "string"}, + Content = {ValueType = "string"}, + ValidTime = {ValueType = "int"}, + RewardIds = {Type = 1, ValueType = "int"}, + }, + XTableMailInitData = { + Ids = {Type = 1, ValueType = "int"}, + }, + XTableSound = { + Id = {ValueType = "int"}, + SoundType = {ValueType = "int"}, + Desc = {ValueType = "string"}, + Path = {ValueType = "string"}, + Volume = {ValueType = "int"}, + FadeCrossTime = {ValueType = "int"}, + Loop = {ValueType = "int"}, + LoopInterval = {ValueType = "int"}, + }, + XTableScreenEffect = { + Id = {ValueType = "int"}, + Type = {ValueType = "int"}, + Name = {ValueType = "string"}, + SortOrder = {ValueType = "int"}, + PlayAlone = {ValueType = "bool"}, + Hash = {ValueType = "int"}, + }, + XTableEffectsSound = { + Hash = {ValueType = "int"}, + SoundId = {ValueType = "int"}, + PlayRefType = {ValueType = "int"}, + }, + XTableMovementSound = { + Id = {ValueType = "int"}, + CharacterId = {ValueType = "string"}, + Motion = {ValueType = "string"}, + SoundId = {ValueType = "int"}, + }, + XTableMainAd = { + Id = {ValueType = "int"}, + Priority = {ValueType = "int"}, + PicType = {ValueType = "int"}, + PicAddr = {ValueType = "string"}, + JumpType = {ValueType = "int"}, + JumpAddr = {ValueType = "string"}, + ChannelId = {ValueType = "int"}, + }, + XTableMainActivitySkip = { + Id = {ValueType = "int"}, + SkipId = {ValueType = "int"}, + StageType = {ValueType = "int"}, + Icon = {ValueType = "string"}, + }, + XTableShop = { + Id = {ValueType = "int"}, + Owner = {ValueType = "int"}, + Type = {ValueType = "int"}, + SecondType = {ValueType = "int"}, + Name = {ValueType = "string"}, + Priority = {ValueType = "int"}, + ShowId = {Type = 1, ValueType = "int"}, + StartTimeStr = {ValueType = "string"}, + EndTimeStr = {ValueType = "string"}, + Kind = {ValueType = "int"}, + GoodsBuyTimesLimit = {ValueType = "int"}, + ManualResetTimesLimit = {ValueType = "int"}, + ResetCostId = {ValueType = "int"}, + ResetCostCountStr = {ValueType = "string"}, + AutoResetClockId = {ValueType = "int"}, + TargetId = {Type = 1, ValueType = "int"}, + IsResetManualTimes = {ValueType = "bool"}, + IsAddSelloutGoods = {ValueType = "bool"}, + IsUnShelve = {ValueType = "bool"}, + ConditionId = {Type = 1, ValueType = "int"}, + ScreenGroup = {Type = 1, ValueType = "int"}, + }, + XTableBaseEquip = { + Id = {ValueType = "int"}, + Type = {ValueType = "int"}, + Name = {ValueType = "string"}, + Description = {ValueType = "string"}, + Part = {ValueType = "int"}, + Star = {ValueType = "int"}, + Level = {ValueType = "int"}, + Quality = {ValueType = "int"}, + Priority = {ValueType = "int"}, + BigSuccessProbability = {ValueType = "int"}, + BigSuccessBottomId = {ValueType = "int"}, + PoolId = {Type = 1, ValueType = "int"}, + BigSuccessPoolId = {Type = 1, ValueType = "int"}, + RecoveryRewardId = {ValueType = "int"}, + NotEvaluatedDesc = {Type = 1, ValueType = "string"}, + Icon = {ValueType = "string"}, + BigIcon = {ValueType = "string"}, + Obtain = {ValueType = "int"}, + }, + XTableAttribGroup = { + Id = {ValueType = "int"}, + PoolId = {ValueType = "int"}, + Weight = {ValueType = "int"}, + AttribId = {ValueType = "int"}, + AttribGrowRateId = {ValueType = "int"}, + Description = {ValueType = "string"}, + Icon = {ValueType = "string"}, + Name = {ValueType = "string"}, + MaxAttribDesc = {ValueType = "string"}, + }, + XTableAttribPoolTmp = { + Id = {ValueType = "int"}, + PoolId = {ValueType = "int"}, + Weight = {ValueType = "int"}, + AttribId = {ValueType = "int"}, + AttribGrowRateId = {ValueType = "int"}, + Icon = {ValueType = "string"}, + Name = {ValueType = "string"}, + Description = {ValueType = "string"}, + MaxAttribDesc = {ValueType = "string"}, + }, + XTableBaseEquipBottomPool = { + Id = {ValueType = "int"}, + Min = {ValueType = "int"}, + Max = {ValueType = "int"}, + }, + XTableBaseEquipScore = { + Key = {ValueType = "string"}, + Numerical = {ValueType = "int"}, + GrowRate = {ValueType = "int"}, + }, + XTableFetter = { + Level = {ValueType = "int"}, + Exp = {ValueType = "int"}, + Add = {ValueType = "int"}, + }, + XTableFetterType = { + Id = {ValueType = "int"}, + Type = {ValueType = "int"}, + Min = {ValueType = "int"}, + Max = {ValueType = "int"}, + Count = {ValueType = "int"}, + }, + XTableGoods = { + Id = {ValueType = "int"}, + Priority = {ValueType = "int"}, + ObtainId = {ValueType = "int"}, + ObtainCount = {ValueType = "int"}, + ObtainParamStr = {ValueType = "string"}, + ConsumeId = {Type = 1, ValueType = "int"}, + ConsumeCount = {Type = 1, ValueType = "int"}, + IsShowWhenSaleTimeLimit = {ValueType = "bool"}, + StartTimeStr = {ValueType = "string"}, + EndTimeStr = {ValueType = "string"}, + BuyTimesLimit = {ValueType = "int"}, + OnSaleStr = {ValueType = "string"}, + AutoResetClockId = {ValueType = "int"}, + Weight = {ValueType = "int"}, + Tags = {ValueType = "int"}, + IsResetWhenShopReset = {ValueType = "bool"}, + ConditionId = {Type = 1, ValueType = "int"}, + IsUnShelve = {ValueType = "bool"}, + IsHideWhenConditionLimit = {ValueType = "bool"}, + GiftRewardId = {ValueType = "int"}, + PayKeySuffix = {ValueType = "string"}, + }, + XTableGoodsGroup = { + Id = {ValueType = "int"}, + ChancePercent = {ValueType = "int"}, + GoodsCount = {ValueType = "int"}, + GoodsIds = {Type = 1, ValueType = "int"}, + }, + XTableFashion = { + Id = {ValueType = "int"}, + CharacterId = {ValueType = "int"}, + ResourcesId = {ValueType = "int"}, + Name = {ValueType = "string"}, + Quality = {ValueType = "int"}, + Series = {ValueType = "int"}, + Description = {ValueType = "string"}, + WorldDescription = {ValueType = "string"}, + Icon = {ValueType = "string"}, + BigIcon = {ValueType = "string"}, + SkipIdParams = {Type = 1, ValueType = "int"}, + Priority = {ValueType = "int"}, + ItemKey = {ValueType = "int"}, + ItemCount = {ValueType = "int"}, + SmallHeadIcon = {ValueType = "string"}, + SmallHeadIconLiberation = {ValueType = "string"}, + BigHeadIcon = {ValueType = "string"}, + RoundnessNotItemHeadIcon = {ValueType = "string"}, + RoundnessNotItemHeadIconLiberation = {ValueType = "string"}, + RoundnessHeadIcon = {ValueType = "string"}, + BigRoundnessHeadIcon = {ValueType = "string"}, + HalfBodyImage = {ValueType = "string"}, + RoleCharacterBigImage = {ValueType = "string"}, + BigHeadIconLiberation = {ValueType = "string"}, + CharacterIcon = {ValueType = "string"}, + ShowTimeStr = {ValueType = "string"}, + SceneModelId = {ValueType = "int"}, + EffectRootName = {ValueType = "string"}, + EffectPath = {ValueType = "string"}, + }, + XTableFashionQuality = { + Id = {ValueType = "int"}, + IconDesc = {ValueType = "string"}, + }, + XTableCue = { + Id = {ValueType = "int"}, + CueSheetId = {ValueType = "int"}, + CueName = {ValueType = "string"}, + Is1pOr3p = {ValueType = "int"}, + }, + XTableCv = { + Id = {ValueType = "int"}, + Cvs = {Type = 1, ValueType = "int"}, + CvContent = {Type = 1, ValueType = "string"}, + }, + XTableCueSheet = { + Id = {ValueType = "int"}, + CueSheetName = {ValueType = "string"}, + CueAwb = {ValueType = "string"}, + HasAwb = {ValueType = "bool"}, + }, + XTableGraphic = { + Level = {ValueType = "int"}, + DisplayName = {ValueType = "string"}, + SubLevels = {Type = 1, ValueType = "int"}, + }, + XTableGraphicSetting = { + Name = {ValueType = "string"}, + DisplayName = {ValueType = "string"}, + Consumption = {ValueType = "int"}, + }, + XTableGpu = { + GpuName = {ValueType = "string"}, + Level = {ValueType = "int"}, + }, + XTableCpu = { + CpuName = {ValueType = "string"}, + Level = {ValueType = "int"}, + }, + XTableDormBgm = { + Id = {ValueType = "int"}, + BgmId = {ValueType = "int"}, + SuitNum = {ValueType = "int"}, + SuitId = {ValueType = "int"}, + Name = {ValueType = "string"}, + Order = {ValueType = "int"}, + }, + XTableDormRecommendLevel = { + LevelId = {ValueType = "int"}, + LowerLimit = {ValueType = "int"}, + UpperLimit = {ValueType = "int"}, + }, + XTableDormRecommendSearch = { + Level = {ValueType = "int"}, + RecommendList = {Type = 1, ValueType = "int"}, + }, + XTableCharacterFavorAttr = { + CharacterId = {ValueType = "int"}, + AttrType = {ValueType = "int"}, + }, + XTableDormCharacterWork = { + DormitoryNum = {ValueType = "int"}, + ItemId = {ValueType = "int"}, + Vitality = {ValueType = "int"}, + Time = {ValueType = "int"}, + Seat = {ValueType = "int"}, + Mood = {ValueType = "int"}, + ExtraReward = {ValueType = "int"}, + }, + XTableDormExceptionItem = { + Id = {ValueType = "int"}, + ConvertId = {ValueType = "int"}, + ConvertCount = {ValueType = "int"}, + }, + XTableFurniturePutNum = { + PutId = {ValueType = "int"}, + PutCount = {ValueType = "int"}, + }, + XTableDormitory = { + Id = {ValueType = "int"}, + IsFree = {ValueType = "int"}, + SceneId = {ValueType = "int"}, + Width = {ValueType = "int"}, + Height = {ValueType = "int"}, + CharCapacity = {ValueType = "int"}, + BigFurnitureCapacity = {ValueType = "int"}, + SmallFurnitureCapacity = {ValueType = "int"}, + DecorateCapacity = {ValueType = "int"}, + PetCapacity = {ValueType = "int"}, + ShieldCapacity = {ValueType = "int"}, + ConsumeItemId = {ValueType = "int"}, + ConsumeItemCount = {ValueType = "int"}, + InitNumber = {ValueType = "int"}, + InitName = {ValueType = "string"}, + InitFurniture = {Type = 1, ValueType = "int"}, + InitFurniturePos = {Type = 1, ValueType = "string"}, + InitFurnitureAttr = {Type = 1, ValueType = "int"}, + }, + XTableFurnitureType = { + Id = {ValueType = "int"}, + MajorType = {ValueType = "int"}, + MajorName = {ValueType = "string"}, + MinorType = {ValueType = "int"}, + MinorName = {ValueType = "string"}, + Category = {ValueType = "int"}, + CategoryName = {ValueType = "string"}, + PicNum = {ValueType = "int"}, + UseId = {ValueType = "int"}, + UseNum = {ValueType = "int"}, + Icon = {ValueType = "string"}, + TypeIcon = {ValueType = "string"}, + }, + XTableFurnitureLevel = { + Id = {ValueType = "int"}, + FurnitureType = {ValueType = "int"}, + AttrScore = {Type = 1, ValueType = "int"}, + MinScore = {ValueType = "int"}, + MaxScore = {ValueType = "int"}, + ReturnId = {ValueType = "int"}, + Quality = {ValueType = "int"}, + }, + XTableFurnitureReward = { + Id = {ValueType = "int"}, + FurnitureId = {ValueType = "int"}, + ExtraAttrId = {ValueType = "int"}, + AdditionId = {ValueType = "int"}, + Quality = {ValueType = "int"}, + Name = {ValueType = "string"}, + }, + XTableDormCharacterFondle = { + CharacterId = {ValueType = "int"}, + MaxCount = {ValueType = "int"}, + RecoveryTime = {ValueType = "int"}, + Lower = {Type = 1, ValueType = "int"}, + Upper = {Type = 1, ValueType = "int"}, + }, + XTableDormCharacterMoodBuff = { + Id = {ValueType = "int"}, + Type = {ValueType = "int"}, + Interval = {ValueType = "int"}, + MaxCount = {ValueType = "int"}, + Speed = {ValueType = "int"}, + }, + XTableDormCharacterEventReward = { + Id = {ValueType = "int"}, + BuffId = {ValueType = "int"}, + RewardId = {ValueType = "int"}, + }, + XTableFurniture = { + Id = {ValueType = "int"}, + MaxCount = {ValueType = "int"}, + Width = {ValueType = "int"}, + Height = {ValueType = "int"}, + Name = {ValueType = "string"}, + Icon = {ValueType = "string"}, + SmallIcon = {ValueType = "string"}, + Quality = {ValueType = "int"}, + Model = {ValueType = "string"}, + Desc = {ValueType = "string"}, + TypeId = {ValueType = "int"}, + LocateType = {ValueType = "int"}, + IsObstacle = {ValueType = "int"}, + SuitId = {ValueType = "int"}, + GainType = {ValueType = "int"}, + InitAttr = {ValueType = "int"}, + CreateTime = {ValueType = "int"}, + RandomGroupId = {ValueType = "int"}, + InteractRange = {ValueType = "int"}, + InteractWeight = {ValueType = "int"}, + InteractPos = {ValueType = "int"}, + InteractName = {ValueType = "string"}, + ReturnId = {ValueType = "int"}, + PicId = {ValueType = "int"}, + PicNum = {ValueType = "int"}, + MoneyNum = {ValueType = "int"}, + IlluminationSO = {ValueType = "string"}, + PointLight = {ValueType = "string"}, + BehaviorType = {Type = 1, ValueType = "string"}, + AttractBehaviorType = {Type = 1, ValueType = "string"}, + AnimationId = {ValueType = "int"}, + AttrTagY = {ValueType = "float"}, + FunitureBehaviorType = {ValueType = "string"}, + PutOnWidgetHight = {ValueType = "float"}, + HasBehavior = {ValueType = "bool"}, + PosChangeType = {ValueType = "int"}, + PutNumType = {ValueType = "int"}, + IsDefaultLocked = {ValueType = "bool"}, + }, + XTableFurnitureBehavior = { + Id = {ValueType = "int"}, + FurnitureId = {ValueType = "int"}, + State = {ValueType = "string"}, + BehaviorId = {ValueType = "string"}, + }, + XTableDormFunitureAnimation = { + Id = {ValueType = "int"}, + CharacterId = {Type = 1, ValueType = "int"}, + CharacterAnimationName = {Type = 1, ValueType = "string"}, + ClickType = {ValueType = "int"}, + OnceAnimationName = {ValueType = "string"}, + RepaatAnimationName = {Type = 1, ValueType = "string"}, + }, + XTableFurnitureAdditionalAttr = { + AttributeId = {ValueType = "int"}, + GroupId = {ValueType = "int"}, + Weight = {ValueType = "int"}, + AddType = {ValueType = "int"}, + AddValue = {Type = 1, ValueType = "int"}, + AddScore = {ValueType = "int"}, + RestrictedRole = {Type = 1, ValueType = "int"}, + Introduce = {ValueType = "string"}, + QualityType = {ValueType = "int"}, + }, + XTableFurnitureAdditionalAttrRandom = { + Id = {ValueType = "int"}, + GroupId = {ValueType = "int"}, + AttrId = {ValueType = "int"}, + Weight = {ValueType = "int"}, + Introduce = {ValueType = "string"}, + }, + XTableDormCharacterRecovery = { + Id = {ValueType = "int"}, + CharacterId = {ValueType = "int"}, + VitalityRecoveryType = {ValueType = "int"}, + VitalityRecovery = {ValueType = "int"}, + MoodRecoveryType = {ValueType = "int"}, + MoodRecovery = {ValueType = "int"}, + Pre = {ValueType = "int"}, + CompareType = {ValueType = "int"}, + AttrTotal = {ValueType = "int"}, + AttrCondition = {Type = 2, KeyType = "int", ValueType = "int"}, + Description = {ValueType = "string"}, + }, + XTableDormCharacterEvent = { + EventId = {ValueType = "int"}, + CharacterId = {ValueType = "int"}, + Type = {ValueType = "int"}, + Weight = {ValueType = "int"}, + BehaviorId = {ValueType = "string"}, + HappenReward = {ValueType = "int"}, + FinishReward = {ValueType = "int"}, + ConditionList = {Type = 1, ValueType = "int"}, + CompletedType = {Type = 1, ValueType = "int"}, + }, + XTableDormCharacterBehavior = { + Id = {ValueType = "int"}, + CharacterId = {ValueType = "int"}, + State = {ValueType = "string"}, + BehaviorId = {ValueType = "string"}, + CanClick = {ValueType = "int"}, + StateMachine = {ValueType = "string"}, + }, + XTableDormInteractiveEvent = { + Id = {ValueType = "int"}, + Weight = {ValueType = "int"}, + MinDis = {ValueType = "int"}, + MaxDis = {ValueType = "int"}, + CharacterIds = {Type = 1, ValueType = "int"}, + State = {Type = 1, ValueType = "string"}, + }, + XTableDormTemplate = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Order = {ValueType = "int"}, + IsShow = {ValueType = "bool"}, + PicturePath = {ValueType = "string"}, + FurnitureId = {Type = 1, ValueType = "int"}, + FurniturePos = {Type = 1, ValueType = "string"}, + }, + XTableDormTemplateCollect = { + Id = {ValueType = "int"}, + DefaultName = {ValueType = "string"}, + DefaultIcon = {ValueType = "string"}, + SkipTemplateId = {ValueType = "int"}, + CaptureCameraId = {ValueType = "int"}, + Order = {ValueType = "int"}, + }, + XTableDormTemplateGroup = { + Id = {ValueType = "int"}, + SecondIndex = {ValueType = "int"}, + Name = {ValueType = "string"}, + HasScond = {ValueType = "bool"}, + SecondTagType = {ValueType = "int"}, + DormType = {ValueType = "int"}, + DormId = {Type = 1, ValueType = "int"}, + }, + XTableDormCharacterEventType = { + Id = {ValueType = "int"}, + CompareOrder = {ValueType = "int"}, + EventType = {ValueType = "int"}, + EventNum = {ValueType = "int"}, + Condition = {Type = 1, ValueType = "int"}, + CharacterNum = {ValueType = "int"}, + CharacterCondition = {Type = 1, ValueType = "int"}, + }, + XTableDormEventCondition = { + Id = {ValueType = "int"}, + Type = {ValueType = "int"}, + Param = {Type = 1, ValueType = "int"}, + }, + XTableDormCharacterStyle = { + Id = {ValueType = "int"}, + Type = {ValueType = "int"}, + Model = {ValueType = "string"}, + Name = {ValueType = "string"}, + NameFrist = {ValueType = "string"}, + NameLast = {ValueType = "string"}, + HeadIcon = {ValueType = "string"}, + HeadRoundIcon = {ValueType = "string"}, + ExpFondleWidgetHeight = {ValueType = "float"}, + ExpDetailWidgetHeight = {ValueType = "float"}, + PutOnWidgetHight = {ValueType = "float"}, + DailogWidgetHight = {ValueType = "float"}, + DailogTouchHight = {ValueType = "float"}, + EffectWidgetHight = {ValueType = "float"}, + TouchWidgetHight = {ValueType = "float"}, + LoveType = {ValueType = "int"}, + LikeType = {ValueType = "int"}, + LikeCharIds = {Type = 1, ValueType = "int"}, + HateCharIds = {Type = 1, ValueType = "int"}, + }, + XTableDormCharacterReward = { + Id = {ValueType = "int"}, + CharacterId = {ValueType = "int"}, + Name = {ValueType = "string"}, + Quality = {ValueType = "int"}, + ConvertItemId = {ValueType = "int"}, + ConvertItemCount = {ValueType = "int"}, + Icon = {ValueType = "string"}, + SmallIcon = {ValueType = "string"}, + Description = {ValueType = "string"}, + WorldDescription = {ValueType = "string"}, + }, + XTableDormCharacterMood = { + Id = {ValueType = "int"}, + MoodMinValue = {ValueType = "int"}, + MoodMaxValue = {ValueType = "int"}, + Describe = {ValueType = "string"}, + Color = {ValueType = "string"}, + Icon = {ValueType = "string"}, + }, + XTableDormCharacterEffect = { + Id = {ValueType = "int"}, + Path = {ValueType = "string"}, + Hight = {ValueType = "float"}, + }, + XTableDormShowEvent = { + Id = {ValueType = "int"}, + ShowType = {ValueType = "int"}, + Description = {Type = 1, ValueType = "string"}, + State = {ValueType = "string"}, + }, + XTableDormF2CBehaviorRelation = { + Id = {ValueType = "int"}, + FurnitureId = {ValueType = "int"}, + CharacterId = {ValueType = "int"}, + PositionId = {ValueType = "int"}, + Behavior = {Type = 1, ValueType = "string"}, + BehaviorWeight = {Type = 1, ValueType = "int"}, + AttractBehavior = {Type = 1, ValueType = "string"}, + AttractBehaviorWeight = {Type = 1, ValueType = "int"}, + }, + XTableHostelRoom = { + Id = {ValueType = "int"}, + Floor = {ValueType = "int"}, + Name = {ValueType = "string"}, + CostId = {ValueType = "int"}, + CostCount = {ValueType = "int"}, + ConditionId = {Type = 1, ValueType = "int"}, + }, + XTableFurnitureCreateAttr = { + Id = {ValueType = "int"}, + FurnitureType = {ValueType = "int"}, + MinConsume = {ValueType = "int"}, + AttrTotal = {Type = 1, ValueType = "int"}, + AttrWeight = {Type = 1, ValueType = "int"}, + ExtraAttrTotal = {Type = 1, ValueType = "int"}, + ExtraAttrWeight = {Type = 1, ValueType = "int"}, + }, + XTableFunctionDevice = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Des = {ValueType = "string"}, + BelongType = {ValueType = "int"}, + Type = {ValueType = "int"}, + Level = {ValueType = "int"}, + ConditionId = {ValueType = "int"}, + CostId = {ValueType = "int"}, + CostCount = {ValueType = "int"}, + CostTime = {ValueType = "int"}, + FunctionParam = {Type = 1, ValueType = "int"}, + }, + XTableDormCharacterDialog = { + Id = {ValueType = "int"}, + CharacterId = {ValueType = "int"}, + MoodMinValue = {ValueType = "int"}, + MoodMaxValue = {ValueType = "int"}, + State = {ValueType = "string"}, + Content = {Type = 1, ValueType = "string"}, + Time = {Type = 1, ValueType = "int"}, + }, + XTableDormCharacterAction = { + Id = {ValueType = "int"}, + CharacterId = {ValueType = "int"}, + State = {ValueType = "int"}, + Name = {ValueType = "string"}, + }, + XTableHostelRest = { + Floor = {ValueType = "int"}, + Name = {ValueType = "string"}, + AreaName = {ValueType = "string"}, + Comfortable = {ValueType = "int"}, + RestCD = {ValueType = "int"}, + RecoveryValue = {ValueType = "int"}, + RestCharCount = {ValueType = "int"}, + }, + XTableRoleEffect = { + Id = {ValueType = "int"}, + Type = {ValueType = "int"}, + Order = {ValueType = "int"}, + Models = {Type = 1, ValueType = "bool"}, + Intensity = {ValueType = "float"}, + FadeIn = {ValueType = "float"}, + FadeOut = {ValueType = "float"}, + Params = {Type = 1, ValueType = "string"}, + }, + XTableHostelRoomNode = { + Id = {ValueType = "int"}, + Scene = {ValueType = "string"}, + Name = {ValueType = "string"}, + Desc = {ValueType = "string"}, + Path = {ValueType = "string"}, + }, + XTableHostelDeviceNode = { + Id = {ValueType = "int"}, + RoomType = {ValueType = "int"}, + Scene = {ValueType = "string"}, + Name = {ValueType = "string"}, + Desc = {ValueType = "string"}, + Path = {ValueType = "string"}, + OpenUI = {ValueType = "string"}, + }, + XTableHostelHud = { + Id = {ValueType = "int"}, + HudType = {ValueType = "int"}, + DeviceType = {ValueType = "int"}, + HudX = {ValueType = "float"}, + HudY = {ValueType = "float"}, + HudHeight = {ValueType = "float"}, + HudWidth = {ValueType = "float"}, + HudScale = {ValueType = "float"}, + }, + XTableHostelDelegate = { + Id = {ValueType = "int"}, + SlotType = {ValueType = "int"}, + DelegateType = {ValueType = "int"}, + DelegateName = {ValueType = "string"}, + DelegateDes = {ValueType = "string"}, + ReportDes = {ValueType = "string"}, + PublishAwardPercent = {ValueType = "int"}, + AssistAwardPercent = {ValueType = "int"}, + HuixinAward = {ValueType = "int"}, + SHuixinAward = {ValueType = "int"}, + DelegateCount = {ValueType = "int"}, + NormalReport = {ValueType = "string"}, + HuixinReport = {ValueType = "string"}, + SHuixinReport = {ValueType = "string"}, + }, + XTableRobot = { + Id = {ValueType = "int"}, + CharacterId = {ValueType = "int"}, + CharacterLevel = {ValueType = "int"}, + CharacterQuality = {ValueType = "int"}, + CharacterStar = {ValueType = "int"}, + CharacterGrade = {ValueType = "int"}, + SkillLevel = {ValueType = "int"}, + RemoveSkillId = {Type = 1, ValueType = "int"}, + FashionId = {ValueType = "int"}, + WeaponId = {ValueType = "int"}, + WeaponLevel = {ValueType = "int"}, + WeaponBeakThrough = {ValueType = "int"}, + WaferId = {Type = 1, ValueType = "int"}, + WaferLevel = {Type = 1, ValueType = "int"}, + WaferBreakThrough = {Type = 1, ValueType = "int"}, + ShowAbility = {ValueType = "int"}, + LiberateLv = {ValueType = "int"}, + WeaponFashion = {ValueType = "int"}, + WeaponResonance = {ValueType = "string"}, + WeaponResonanceType = {ValueType = "string"}, + WaferResonance = {Type = 2, KeyType = "int", ValueType = "string"}, + WaferResonanceType = {Type = 2, KeyType = "int", ValueType = "string"}, + WaferAwakeCount = {Type = 1, ValueType = "int"}, + RobotPartnerId = {ValueType = "int"}, + }, + XTableRobotPartner = { + Id = {ValueType = "int"}, + PartnerId = {ValueType = "int"}, + Level = {ValueType = "int"}, + BreakThrough = {ValueType = "int"}, + Quality = {ValueType = "int"}, + StarSchedule = {ValueType = "int"}, + MainSkillGroup = {ValueType = "int"}, + MainSkillLevel = {ValueType = "int"}, + PassiveSkillId = {Type = 1, ValueType = "int"}, + PassiveSkillLevel = {Type = 1, ValueType = "int"}, + }, + XTableSubGraphic = { + Level = {ValueType = "int"}, + DisplayName = {ValueType = "string"}, + }, + XTableBloom = { + Enable = {ValueType = "bool"}, + Threshold = {Type = 1, ValueType = "float"}, + BlurSize = {Type = 1, ValueType = "float"}, + Intensity = {Type = 1, ValueType = "float"}, + BlurIterations = {Type = 1, ValueType = "int"}, + Saturation = {Type = 1, ValueType = "float"}, + SoftKnee = {Type = 1, ValueType = "float"}, + Radius = {Type = 1, ValueType = "int"}, + Level = {ValueType = "int"}, + DisplayName = {ValueType = "string"}, + }, + XTableResolution = { + Scale = {ValueType = "float"}, + Level = {ValueType = "int"}, + DisplayName = {ValueType = "string"}, + }, + XTableResourceLut = { + Id = {ValueType = "string"}, + Url = {ValueType = "string"}, + }, + XTableHashResourceLut = { + Hash = {ValueType = "int"}, + Url = {ValueType = "string"}, + }, + XTableScreenQteLut = { + Id = {ValueType = "int"}, + BtnPath = {ValueType = "string"}, + SuccEffectName = {ValueType = "string"}, + FailEffectName = {ValueType = "string"}, + }, + XTablePhotoCapture = { + Id = {ValueType = "int"}, + Url = {ValueType = "string"}, + }, + XTableFillBarLut = { + Id = {ValueType = "string"}, + Url = {ValueType = "string"}, + }, + XTableShadow = { + ShadowType = {ValueType = "int"}, + SoftShadow = {ValueType = "bool"}, + TextureSize = {ValueType = "int"}, + Range = {ValueType = "int"}, + Layers = {Type = 1, ValueType = "int"}, + LightCameraDistance = {ValueType = "float"}, + Level = {ValueType = "int"}, + DisplayName = {ValueType = "string"}, + }, + XTableMirror = { + Enable = {ValueType = "bool"}, + Blur = {ValueType = "bool"}, + TextureSize = {ValueType = "int"}, + Layers = {Type = 1, ValueType = "int"}, + BlurIteration = {ValueType = "int"}, + BlurLerp = {ValueType = "float"}, + Level = {ValueType = "int"}, + DisplayName = {ValueType = "string"}, + }, + XTableDistortion = { + Enable = {ValueType = "bool"}, + DistortionType = {ValueType = "int"}, + DownSample = {ValueType = "int"}, + Level = {ValueType = "int"}, + DisplayName = {ValueType = "string"}, + }, + XTableNpcGraphic = { + Outline = {ValueType = "bool"}, + VertexLight = {ValueType = "bool"}, + Level = {ValueType = "int"}, + DisplayName = {ValueType = "string"}, + }, + XTableFxaa = { + Enable = {ValueType = "bool"}, + Quality = {ValueType = "int"}, + Level = {ValueType = "int"}, + DisplayName = {ValueType = "string"}, + }, + XTableRadialBlur = { + Enable = {ValueType = "bool"}, + Times = {ValueType = "int"}, + Level = {ValueType = "int"}, + DisplayName = {ValueType = "string"}, + }, + XTableAfterImage = { + MaxCount = {ValueType = "int"}, + Level = {ValueType = "int"}, + DisplayName = {ValueType = "string"}, + }, + XTableVignette = { + Id = {ValueType = "int"}, + Mode = {ValueType = "int"}, + Color = {ValueType = "string"}, + CenterX = {ValueType = "float"}, + CenterY = {ValueType = "float"}, + Intensity = {ValueType = "float"}, + Smoothness = {ValueType = "float"}, + Roundness = {ValueType = "float"}, + Rounded = {ValueType = "bool"}, + }, + XTableTerrain = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Info = {ValueType = "string"}, + BornPosition = {Type = 1, ValueType = "string"}, + LookPosition = {Type = 1, ValueType = "string"}, + DefaultObstacleArea = {Type = 1, ValueType = "string"}, + DefaultDynamicObject = {Type = 1, ValueType = "string"}, + }, + XTableTerrainLut = { + Name = {ValueType = "string"}, + Prefab = {ValueType = "string"}, + Size = {ValueType = "string"}, + Area = {ValueType = "string"}, + Position = {ValueType = "string"}, + PathArea = {ValueType = "string"}, + PathPosition = {ValueType = "string"}, + PathLink = {ValueType = "string"}, + UseFootStepEffect = {ValueType = "bool"}, + }, + XTableTip = { + Id = {ValueType = "int"}, + Description = {ValueType = "string"}, + }, + XTableMotionLut = { + Id = {ValueType = "string"}, + HasMotion = {ValueType = "bool"}, + }, + XTableAnimationMotion = { + Role = {ValueType = "string"}, + Layer = {ValueType = "int"}, + Animation = {ValueType = "string"}, + TotalFrame = {ValueType = "int"}, + TailLength = {ValueType = "fix"}, + OffsetX = {Type = 1, ValueType = "fix"}, + OffsetZ = {Type = 1, ValueType = "fix"}, + Cos = {Type = 1, ValueType = "fix"}, + Sin = {Type = 1, ValueType = "fix"}, + }, + XTableAnimationTransition = { + Role = {ValueType = "string"}, + Layer = {ValueType = "int"}, + State = {ValueType = "string"}, + Target = {ValueType = "string"}, + TransitionDuration = {ValueType = "float"}, + }, + XTableHeadPortrait = { + Id = {ValueType = "int"}, + Type = {ValueType = "int"}, + IsInit = {ValueType = "int"}, + Name = {ValueType = "string"}, + ImgSrc = {ValueType = "string"}, + LockDesc = {ValueType = "string"}, + ConvertItemId = {ValueType = "int"}, + ConvertItemCount = {ValueType = "int"}, + Description = {ValueType = "string"}, + WorldDesc = {ValueType = "string"}, + Effect = {ValueType = "string"}, + Priority = {ValueType = "int"}, + LimitType = {ValueType = "int"}, + TimeId = {ValueType = "int"}, + ShowTimeStr = {ValueType = "string"}, + Duration = {ValueType = "int"}, + IsRepetition = {ValueType = "int"}, + GroupId = {ValueType = "int"}, + Quality = {ValueType = "int"}, + }, + XTableBossSingleGrade = { + LevelType = {ValueType = "int"}, + Offline = {ValueType = "int"}, + MinPlayerLevel = {ValueType = "int"}, + MaxPlayerLevel = {ValueType = "int"}, + PreLevel = {ValueType = "int"}, + NeedScore = {ValueType = "int"}, + Icon = {ValueType = "string"}, + LevelName = {ValueType = "string"}, + HideBossOpen = {ValueType = "bool"}, + ChallengeCount = {ValueType = "int"}, + WeekChallengeCount = {ValueType = "int"}, + StaminaCount = {ValueType = "int"}, + BaseRankNum = {ValueType = "int"}, + GroupId = {Type = 1, ValueType = "int"}, + }, + XTableBossSingleGroup = { + Id = {ValueType = "int"}, + GroupIcon = {ValueType = "string"}, + GroupName = {ValueType = "string"}, + SectionId = {Type = 1, ValueType = "int"}, + }, + XTableBossSingleRankReward = { + Id = {ValueType = "int"}, + LevelType = {ValueType = "int"}, + MinRank = {ValueType = "float"}, + MaxRank = {ValueType = "float"}, + MailID = {ValueType = "int"}, + RankIcon = {ValueType = "string"}, + }, + XTableBossSingleScoreReward = { + Id = {ValueType = "int"}, + LevelType = {ValueType = "int"}, + Score = {ValueType = "int"}, + RewardId = {ValueType = "int"}, + RankIcon = {ValueType = "string"}, + }, + XTableBossSingleSection = { + Id = {ValueType = "int"}, + Desc = {ValueType = "string"}, + BossHeadIcon = {ValueType = "string"}, + Priority = {ValueType = "int"}, + StageId = {Type = 1, ValueType = "int"}, + ActivityTag = {Type = 1, ValueType = "string"}, + TeamBuffId = {ValueType = "int"}, + ActivityTimeId = {Type = 1, ValueType = "int"}, + SwitchTimeId = {ValueType = "int"}, + }, + XTableBossSingleStage = { + StageId = {ValueType = "int"}, + ModelId = {ValueType = "string"}, + BossName = {ValueType = "string"}, + Score = {ValueType = "int"}, + BossLoseHpScore = {ValueType = "int"}, + LeftTimeScore = {ValueType = "int"}, + LeftHpScore = {ValueType = "int"}, + DifficultyType = {ValueType = "int"}, + DifficultyDesc = {ValueType = "string"}, + DifficultyDescEn = {ValueType = "string"}, + AutoFight = {ValueType = "bool"}, + FightCharCount = {ValueType = "int"}, + PreFullScore = {Type = 1, ValueType = "int"}, + OpenCondition = {Type = 1, ValueType = "int"}, + BuffDetailsId = {Type = 1, ValueType = "int"}, + FeaturesId = {Type = 1, ValueType = "int"}, + ProposedLevel = {Type = 1, ValueType = "int"}, + SkillTitle = {Type = 1, ValueType = "string"}, + SkillDesc = {Type = 1, ValueType = "string"}, + AttackName = {Type = 1, ValueType = "string"}, + }, + XTableStageTeamBuff = { + Id = {ValueType = "int"}, + Quality = {Type = 1, ValueType = "int"}, + BuffId = {Type = 1, ValueType = "int"}, + OnIcon = {ValueType = "string"}, + OffIcon = {ValueType = "string"}, + Title = {ValueType = "string"}, + Desc = {ValueType = "string"}, + }, + XTableFubenFeatures = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Desc = {ValueType = "string"}, + }, + XTableBossSingleScoreRule = { + Id = {ValueType = "int"}, + BossLoseHp = {Type = 1, ValueType = "float"}, + BossLoseHpScore = {Type = 1, ValueType = "int"}, + BossTotalHp = {Type = 1, ValueType = "int"}, + LeftTime = {Type = 1, ValueType = "int"}, + LeftTimeScore = {Type = 1, ValueType = "float"}, + CharLeftHp = {Type = 1, ValueType = "float"}, + CharLeftHpSocre = {Type = 1, ValueType = "float"}, + }, + XTableRank = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + ClockId = {ValueType = "int"}, + PresetMemberCount = {ValueType = "int"}, + TimeStrToEffect = {ValueType = "string"}, + TimeStrToClose = {ValueType = "string"}, + TimeStrToInvalid = {ValueType = "string"}, + }, + XTableRankReward = { + Id = {ValueType = "int"}, + RankId = {ValueType = "int"}, + Type = {ValueType = "int"}, + Ranking = {ValueType = "int"}, + MailId = {ValueType = "int"}, + }, + XTableRobotPlayer = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Level = {ValueType = "int"}, + HeadPortrait = {ValueType = "int"}, + Sign = {ValueType = "string"}, + CharRobot = {Type = 1, ValueType = "int"}, + }, + XTableBossOnlineSection = { + Id = {ValueType = "int"}, + LastSectionId = {ValueType = "int"}, + Activity = {ValueType = "int"}, + Weight = {ValueType = "int"}, + DifficultType = {ValueType = "int"}, + ModelId = {ValueType = "string"}, + StageId = {ValueType = "int"}, + Animation = {ValueType = "string"}, + Scene = {ValueType = "string"}, + NpcPic = {ValueType = "string"}, + CameraSetting = {Type = 1, ValueType = "string"}, + Description = {Type = 1, ValueType = "string"}, + SkillName = {Type = 1, ValueType = "string"}, + SkillDes = {Type = 1, ValueType = "string"}, + }, + XTableBossOnlineChapter = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Type = {ValueType = "int"}, + Icon = {ValueType = "string"}, + }, + XTableBossOnlineRisk = { + Id = {ValueType = "int"}, + MinCount = {ValueType = "int"}, + MaxCount = {ValueType = "int"}, + Name = {ValueType = "string"}, + Color = {ValueType = "string"}, + }, + XTableSystemReset = { + ResetKey = {ValueType = "int"}, + ResetType = {ValueType = "int"}, + ResetTime = {ValueType = "string"}, + }, + XTableAlarmClock = { + ClockId = {ValueType = "int"}, + EpochTime = {ValueType = "int"}, + AlarmCycle = {ValueType = "int"}, + DayOfWeek = {ValueType = "string"}, + DayOfMonth = {ValueType = "string"}, + }, + XTableAccumulativeBuff = { + Id = {ValueType = "int"}, + Type = {ValueType = "int"}, + Value = {ValueType = "int"}, + }, + XTableAccumulativeBuffType = { + Type = {ValueType = "int"}, + Buff = {ValueType = "int"}, + Duration = {ValueType = "fix"}, + Cd = {ValueType = "fix"}, + Name = {ValueType = "string"}, + Icon = {ValueType = "string"}, + }, + XTableServer = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + GameIp = {ValueType = "string"}, + GamePort = {ValueType = "int"}, + AccountIp = {ValueType = "string"}, + AccountPort = {ValueType = "int"}, + }, + XTableIosModel = { + ModelId = {ValueType = "string"}, + Quality = {ValueType = "int"}, + }, + XTableBountyTaskRank = { + RankLevel = {ValueType = "int"}, + RankName = {ValueType = "string"}, + RankIcon = {ValueType = "string"}, + RewardId = {ValueType = "int"}, + LevelUpExp = {ValueType = "int"}, + MailId = {ValueType = "int"}, + }, + XTableBountyTask = { + Id = {ValueType = "int"}, + StageId = {ValueType = "int"}, + StageIcon = {ValueType = "string"}, + Name = {ValueType = "string"}, + Desc = {ValueType = "string"}, + RoleIcon = {ValueType = "string"}, + SmallRoleIcon = {ValueType = "string"}, + EnterAnimation = {Type = 1, ValueType = "string"}, + DifficultLevel = {ValueType = "int"}, + TextColor = {ValueType = "string"}, + DifficultLevelIcon = {ValueType = "string"}, + DifficultLevelIconX = {ValueType = "string"}, + TaskExp = {ValueType = "int"}, + RewardId = {ValueType = "int"}, + RandomWeightList = {Type = 1, ValueType = "int"}, + }, + XTableBountyTaskRandomEvent = { + EventId = {ValueType = "int"}, + EventName = {ValueType = "string"}, + RandomWeight = {ValueType = "int"}, + }, + XTableBountyTaskDifficultStage = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + RandomWeight = {ValueType = "int"}, + SkipId = {ValueType = "int"}, + }, + XTableTaskForceSection = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + ConditionId = {ValueType = "int"}, + TaskCount = {ValueType = "int"}, + TaskPoolId = {ValueType = "int"}, + SectionIcon = {ValueType = "string"}, + SectionChapterIcon = {ValueType = "string"}, + Desc = {Type = 1, ValueType = "string"}, + }, + XTableTaskForceTask = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + TaskPoolId = {ValueType = "int"}, + Quality = {ValueType = "int"}, + RandomWeight = {ValueType = "int"}, + ShowId = {ValueType = "int"}, + DropId = {ValueType = "int"}, + RewardId = {ValueType = "int"}, + Duration = {ValueType = "int"}, + Priority = {ValueType = "int"}, + ExtraRewardId = {ValueType = "int"}, + ExtraRewardConditionId = {ValueType = "int"}, + ConditionList = {Type = 1, ValueType = "int"}, + MemberCount = {ValueType = "int"}, + }, + XTableTaskForceConfig = { + Id = {ValueType = "int"}, + MaxTaskForceCount = {ValueType = "int"}, + ConditionId = {ValueType = "int"}, + }, + XTableTaskForceExpend = { + RefreshCount = {ValueType = "int"}, + ItemId = {ValueType = "int"}, + ItemCount = {ValueType = "int"}, + }, + XTableBfrtChapter = { + ChapterId = {ValueType = "int"}, + ChapterName = {ValueType = "string"}, + ChapterEn = {ValueType = "string"}, + OpenTimeStr = {ValueType = "string"}, + Bg = {ValueType = "string"}, + Icon = {ValueType = "string"}, + OrderId = {ValueType = "int"}, + GroupId = {Type = 1, ValueType = "int"}, + TaskId = {Type = 1, ValueType = "int"}, + PrefabName = {ValueType = "string"}, + ActivityCondition = {ValueType = "int"}, + Cover = {ValueType = "string"}, + }, + XTableBfrtGroup = { + GroupId = {ValueType = "int"}, + GroupName = {ValueType = "string"}, + Icon = {ValueType = "string"}, + Desc = {ValueType = "string"}, + PreGroupId = {ValueType = "int"}, + ChallengeNum = {ValueType = "int"}, + BaseStage = {ValueType = "int"}, + StageId = {Type = 1, ValueType = "int"}, + FightInfoId = {Type = 1, ValueType = "int"}, + TeamFightSeq = {ValueType = "string"}, + LogisticsInfoId = {Type = 1, ValueType = "int"}, + GroupOrderId = {ValueType = "int"}, + }, + XTableEchelonInfo = { + Id = {ValueType = "int"}, + BuffId = {ValueType = "int"}, + NeedCharacter = {ValueType = "int"}, + RequireAbility = {ValueType = "int"}, + Condition = {ValueType = "int"}, + }, + XTableFubenResourceLevelSection = { + Id = {ValueType = "int"}, + Type = {ValueType = "int"}, + MinLevel = {ValueType = "int"}, + DaliyCount = {ValueType = "int"}, + StageList = {Type = 1, ValueType = "int"}, + WeightList = {Type = 1, ValueType = "int"}, + DifficultyList = {Type = 1, ValueType = "string"}, + ColorChallengeList = {Type = 1, ValueType = "string"}, + ColorRewardList = {Type = 1, ValueType = "string"}, + }, + XFubenResourceChapter = { + Id = {ValueType = "int"}, + Type = {ValueType = "int"}, + Name = {ValueType = "string"}, + NameEn = {ValueType = "string"}, + Desc = {ValueType = "string"}, + SimpleDesc = {ValueType = "string"}, + DetailDesc = {ValueType = "string"}, + Icon = {ValueType = "string"}, + IsClose = {ValueType = "bool"}, + }, + XTableFightReboot = { + Id = {ValueType = "int"}, + Type = {ValueType = "int"}, + RebootItemId = {ValueType = "int"}, + MaxRebootCount = {ValueType = "int"}, + ConsumeCount = {Type = 1, ValueType = "int"}, + HpRetain = {ValueType = "fix"}, + MagicIds = {Type = 1, ValueType = "int"}, + RebootCondition = {Type = 1, ValueType = "int"}, + }, + XTableFightOnlineReboot = { + Id = {ValueType = "int"}, + MaxRebootCount = {ValueType = "int"}, + RescueDistance = {ValueType = "fix"}, + WaitingTime = {ValueType = "fix"}, + RescueTime = {ValueType = "fix"}, + HpRetain = {ValueType = "fix"}, + MagicIds = {Type = 1, ValueType = "int"}, + }, + XTableRecommendLevel = { + Id = {ValueType = "int"}, + LowerLevel = {ValueType = "int"}, + UpperLevel = {ValueType = "int"}, + }, + XTableRecommendSearch = { + Level = {ValueType = "int"}, + RecommendList = {Type = 1, ValueType = "int"}, + }, + XTableVoteGroup = { + Id = {ValueType = "int"}, + VotesResetClockId = {ValueType = "int"}, + VoteLimitClockId = {ValueType = "int"}, + TimeStrToEffect = {ValueType = "string"}, + TimeStrToClose = {ValueType = "string"}, + TimeStrToInvalid = {ValueType = "string"}, + VoteId = {Type = 1, ValueType = "int"}, + }, + XTableCharacterSkillPool = { + Id = {ValueType = "int"}, + PoolId = {ValueType = "int"}, + Weight = {ValueType = "int"}, + SkillId = {ValueType = "int"}, + Icon = {ValueType = "string"}, + Name = {ValueType = "string"}, + Description = {ValueType = "string"}, + }, + XTableWeaponAnimationTransition = { + Role = {ValueType = "string"}, + Layer = {ValueType = "int"}, + State = {ValueType = "string"}, + Target = {ValueType = "string"}, + }, + XTableWeaponSkillPool = { + Id = {ValueType = "int"}, + PoolId = {ValueType = "int"}, + Weight = {ValueType = "int"}, + CharacterId = {ValueType = "int"}, + SkillId = {Type = 1, ValueType = "int"}, + }, + XTableWeaponSkill = { + Id = {ValueType = "int"}, + BornMagic = {Type = 1, ValueType = "int"}, + SubSkillId = {Type = 1, ValueType = "int"}, + Ability = {ValueType = "int"}, + Icon = {ValueType = "string"}, + Name = {ValueType = "string"}, + Description = {ValueType = "string"}, + DesLinkCharacterSkillId = {ValueType = "int"}, + }, + XTableEquipResonance = { + Id = {ValueType = "int"}, + AttribPoolId = {Type = 2, KeyType = "int", ValueType = "int"}, + AttribPoolWeight = {Type = 2, KeyType = "int", ValueType = "int"}, + CharacterSkillPoolId = {Type = 2, KeyType = "int", ValueType = "int"}, + CharacterSkillPoolWeight = {Type = 2, KeyType = "int", ValueType = "int"}, + WeaponSkillPoolId = {Type = 2, KeyType = "int", ValueType = "int"}, + WeaponSkillPoolWeight = {Type = 2, KeyType = "int", ValueType = "int"}, + }, + XTableEquipResonanceUseItem = { + Id = {ValueType = "int"}, + ItemId = {Type = 1, ValueType = "int"}, + ItemCount = {Type = 1, ValueType = "int"}, + SelectSkillItemId = {Type = 1, ValueType = "int"}, + SelectSkillItemCount = {Type = 1, ValueType = "int"}, + }, + XTableEquipAwake = { + Id = {ValueType = "int"}, + AttribId = {Type = 2, KeyType = "int", ValueType = "int"}, + AttribDes1 = {Type = 1, ValueType = "string"}, + AttribDes2 = {Type = 1, ValueType = "string"}, + ItemId = {Type = 1, ValueType = "int"}, + ItemCount = {Type = 1, ValueType = "int"}, + ItemCrystalId = {Type = 1, ValueType = "int"}, + ItemCrystalCount = {Type = 1, ValueType = "int"}, + }, + XTableEatEquipCost = { + Id = {ValueType = "int"}, + Site = {ValueType = "int"}, + Star = {ValueType = "int"}, + UseMoney = {ValueType = "int"}, + }, + XTableSignBoardFeedback = { + Id = {ValueType = "int"}, + RoleId = {ValueType = "string"}, + ConditionId = {ValueType = "int"}, + ConditionParam = {ValueType = "int"}, + Content = {ValueType = "string"}, + CvId = {ValueType = "int"}, + FaceId = {ValueType = "int"}, + ActionId = {ValueType = "string"}, + Duration = {Type = 2, KeyType = "int", ValueType = "float"}, + Validity = {ValueType = "float"}, + CoolTime = {ValueType = "int"}, + Weight = {ValueType = "int"}, + FavorLimit = {ValueType = "string"}, + ShowButton = {ValueType = "string"}, + ActivityId = {ValueType = "int"}, + ShowTime = {ValueType = "string"}, + StandType = {ValueType = "int"}, + ChangeToStandType = {ValueType = "int"}, + ShowType = {ValueType = "int"}, + }, + XTableCharacterTrustExp = { + Id = {ValueType = "int"}, + CharacterId = {ValueType = "int"}, + TrustLv = {ValueType = "int"}, + Exp = {ValueType = "int"}, + Name = {ValueType = "string"}, + PlayId = {ValueType = "int"}, + }, + XTableCharacterBaseData = { + Id = {ValueType = "int"}, + CharacterId = {ValueType = "int"}, + ShapId = {ValueType = "int"}, + BaseDataTitle = {Type = 1, ValueType = "string"}, + BaseData = {Type = 1, ValueType = "string"}, + Cast = {Type = 1, ValueType = "string"}, + }, + XTableCharacterInformation = { + Id = {ValueType = "int"}, + CharacterId = {ValueType = "int"}, + UnlockLv = {ValueType = "int"}, + Title = {ValueType = "string"}, + Content = {ValueType = "string"}, + ConditionDescript = {ValueType = "string"}, + }, + XTableCharacterStrangeNews = { + Id = {ValueType = "int"}, + CharacterId = {ValueType = "int"}, + Type = {ValueType = "int"}, + UnlockType = {ValueType = "int"}, + UnlockPara = {ValueType = "int"}, + Title = {ValueType = "string"}, + Content = {ValueType = "string"}, + Picture = {ValueType = "string"}, + ConditionDescript = {ValueType = "string"}, + PreviewPicture = {ValueType = "string"}, + }, + XTableCharacterVoice = { + Id = {ValueType = "int"}, + CharacterId = {ValueType = "int"}, + Name = {ValueType = "string"}, + CvId = {ValueType = "int"}, + UnlockLv = {ValueType = "int"}, + ConditionDescript = {ValueType = "string"}, + SoundType = {ValueType = "int"}, + IsShow = {ValueType = "int"}, + }, + XTableCharacterStory = { + Id = {ValueType = "int"}, + CharacterId = {ValueType = "int"}, + Name = {ValueType = "string"}, + Icon = {ValueType = "string"}, + StoryId = {ValueType = "string"}, + UnlockLv = {ValueType = "int"}, + ConditionDescript = {ValueType = "string"}, + SectionNumber = {ValueType = "int"}, + }, + XTableCharacterTrustItem = { + Id = {ValueType = "int"}, + Exp = {ValueType = "int"}, + FavorCharacterId = {Type = 1, ValueType = "int"}, + FavorExp = {ValueType = "int"}, + TrustItemType = {ValueType = "int"}, + }, + XTableExhibitionReward = { + Id = {ValueType = "int"}, + CharacterId = {ValueType = "int"}, + LevelId = {ValueType = "int"}, + RewardId = {ValueType = "int"}, + HeadPortrait = {ValueType = "int"}, + ConditionIds = {Type = 1, ValueType = "int"}, + }, + XTableTrustGameConfig = { + Id = {ValueType = "int"}, + GameRewardId = {ValueType = "int"}, + Type = {ValueType = "int"}, + Difficult = {ValueType = "int"}, + Count = {ValueType = "int"}, + }, + XTableCharacterReward = { + Id = {ValueType = "int"}, + CharacterId = {ValueType = "int"}, + UnlockType = {ValueType = "int"}, + UnlockPara = {ValueType = "int"}, + ItemId = {ValueType = "int"}, + ItemCount = {ValueType = "int"}, + ConditionDescript = {ValueType = "string"}, + }, + XTableTrustGameReward = { + Id = {ValueType = "int"}, + FinishNum = {Type = 1, ValueType = "int"}, + TrustExp = {Type = 1, ValueType = "int"}, + RewardId = {Type = 1, ValueType = "int"}, + }, + XTableFavorabilityLevelConfig = { + Id = {ValueType = "int"}, + WordColor = {ValueType = "string"}, + LevelIcon = {ValueType = "string"}, + }, + XTableTrustGameClickPool = { + Id = {ValueType = "int"}, + Question = {ValueType = "string"}, + Answer = {ValueType = "string"}, + Time = {ValueType = "int"}, + Weight = {ValueType = "int"}, + Difficult = {ValueType = "int"}, + }, + XTableTrustGameEliminatePool = { + Id = {ValueType = "int"}, + Question = {ValueType = "string"}, + Answer = {ValueType = "string"}, + Times = {ValueType = "int"}, + LimitTimes = {ValueType = "int"}, + Weight = {ValueType = "int"}, + Difficult = {ValueType = "int"}, + }, + XTableTrustGamePosition = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + BgIcon = {ValueType = "string"}, + }, + XTableTrustGameTypeConfig = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Title = {ValueType = "string"}, + Desc = {ValueType = "string"}, + ResultTitle = {ValueType = "string"}, + ResultDesc = {ValueType = "string"}, + Icon = {ValueType = "string"}, + }, + XTableTrustGameGrid = { + Id = {ValueType = "int"}, + Type = {ValueType = "int"}, + SmallIcon = {ValueType = "string"}, + BigIcon = {ValueType = "string"}, + }, + XTableTrialChallenge = { + Id = {ValueType = "int"}, + Type = {ValueType = "int"}, + StageId = {ValueType = "int"}, + Picture = {ValueType = "string"}, + BigPicture = {ValueType = "string"}, + Explain = {ValueType = "string"}, + RewardId = {ValueType = "int"}, + PreId = {ValueType = "int"}, + AvgAbility = {ValueType = "int"}, + LimitTime = {ValueType = "int"}, + Unlocklevel = {ValueType = "int"}, + Name = {ValueType = "string"}, + Des = {Type = 1, ValueType = "string"}, + ConditionExplain = {Type = 1, ValueType = "string"}, + }, + XTableTrialTypeReward = { + Type = {ValueType = "int"}, + RewardId = {ValueType = "int"}, + MinIcon = {ValueType = "string"}, + BigIcon = {ValueType = "string"}, + Name = {ValueType = "string"}, + }, + XTableChallengeArea = { + ChallengeId = {ValueType = "int"}, + Name = {ValueType = "string"}, + ArenaLv = {ValueType = "int"}, + MinLv = {ValueType = "int"}, + MaxLv = {ValueType = "int"}, + DistributeId = {ValueType = "int"}, + JoinNum = {ValueType = "int"}, + DanUpRank = {ValueType = "int"}, + DanKeepRank = {ValueType = "int"}, + DanDownRank = {ValueType = "int"}, + UpRewardId = {ValueType = "int"}, + KeepRewardId = {ValueType = "int"}, + DownRewardId = {ValueType = "int"}, + DayUnlockNum = {ValueType = "int"}, + WeekEndUnlockNum = {ValueType = "int"}, + AreaId = {Type = 1, ValueType = "int"}, + BaseTeamRank = {ValueType = "int"}, + DifShowRate = {ValueType = "int"}, + AvgScore = {ValueType = "int"}, + MinScore = {ValueType = "int"}, + ContributeScore = {Type = 1, ValueType = "int"}, + }, + XTableAreaDistribute = { + Id = {ValueType = "int"}, + AreaGroupId = {Type = 1, ValueType = "int"}, + }, + XTableAreaGroup = { + Id = {ValueType = "int"}, + AreaId = {Type = 1, ValueType = "int"}, + }, + XTableAreaStage = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + BuffId = {ValueType = "int"}, + BuffDesc = {ValueType = "string"}, + StageId = {Type = 1, ValueType = "int"}, + MarkId = {Type = 1, ValueType = "int"}, + AutoFight = {Type = 1, ValueType = "int"}, + }, + XTableMark = { + MarkId = {ValueType = "int"}, + MinPoint = {ValueType = "int"}, + MaxPoint = {ValueType = "int"}, + EnemyHpPoint = {ValueType = "string"}, + MyHpPoint = {ValueType = "string"}, + TimePoint = {ValueType = "string"}, + MaxEnemyHpPoint = {ValueType = "int"}, + MaxMyHpPoint = {ValueType = "int"}, + MaxTimePoint = {ValueType = "int"}, + NpcGroupPoint = {ValueType = "string"}, + MaxNpcGroupPoint = {ValueType = "int"}, + }, + XTableArenaLevel = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Icon = {ValueType = "string"}, + }, + XTableArenaActivityControl = { + Id = {ValueType = "int"}, + BeginTime = {ValueType = "int"}, + EndTime = {ValueType = "int"}, + RestTime = {ValueType = "int"}, + FightTime = {ValueType = "int"}, + Desc = {ValueType = "string"}, + }, + XTableTeamRankReward = { + Id = {ValueType = "int"}, + ChallengeId = {ValueType = "int"}, + MinRank = {ValueType = "int"}, + MaxRank = {ValueType = "int"}, + MailId = {ValueType = "int"}, + }, + XTableWaveRevise = { + Id = {ValueType = "int"}, + ChallengeId = {ValueType = "int"}, + MinWave = {ValueType = "int"}, + MaxWave = {ValueType = "int"}, + AttribReviseId = {ValueType = "int"}, + }, + XTableNpcType = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + NpcId = {Type = 1, ValueType = "int"}, + Weight = {Type = 1, ValueType = "int"}, + }, + XTableNpcModel = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + IsSelect = {ValueType = "bool"}, + NpcId = {Type = 1, ValueType = "int"}, + }, + XTableNpcGroup = { + Id = {ValueType = "int"}, + TypeId = {Type = 1, ValueType = "int"}, + AffixGroupId = {ValueType = "int"}, + }, + XTableStageNpcBuffLimit = { + Id = {ValueType = "int"}, + ForbidBuffId = {Type = 1, ValueType = "int"}, + InevitablyBuffId = {Type = 1, ValueType = "int"}, + }, + XTableAffixType = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + BuffId = {Type = 1, ValueType = "int"}, + Weight = {Type = 1, ValueType = "int"}, + }, + XTableAffixGroup = { + Id = {ValueType = "int"}, + AffixTypeId = {Type = 1, ValueType = "string"}, + }, + XTableStageNpc = { + Id = {ValueType = "int"}, + NpcGroupId = {Type = 1, ValueType = "string"}, + }, + XTableNpcRefresh = { + Id = {ValueType = "int"}, + ModeLimit = {ValueType = "int"}, + ModeIdStr = {ValueType = "string"}, + NpcGroupIdStr = {Type = 1, ValueType = "string"}, + }, + XTableStageNpcRefresh = { + Id = {ValueType = "int"}, + RefreshId = {ValueType = "int"}, + UniformRefresh = {ValueType = "int"}, + }, + XTableArenaNpcLevel = { + Id = {ValueType = "int"}, + StageId = {ValueType = "int"}, + ChallengeId = {ValueType = "int"}, + NpcId = {Type = 1, ValueType = "int"}, + NpcLevel = {Type = 1, ValueType = "int"}, + }, + XTableArenaStage = { + StageId = {ValueType = "int"}, + DifficuIocn = {ValueType = "string"}, + Name = {ValueType = "string"}, + BgIconSmall = {ValueType = "string"}, + BgIconBig = {ValueType = "string"}, + MarkId = {ValueType = "int"}, + }, + XTablePrequelChapter = { + ChapterId = {ValueType = "int"}, + TimeId = {ValueType = "int"}, + ChapterName = {ValueType = "string"}, + Bg = {ValueType = "string"}, + Priority = {ValueType = "int"}, + ActivityBegin = {ValueType = "string"}, + ActivityEnd = {ValueType = "string"}, + ActivityCondition = {ValueType = "int"}, + OpenCondition = {Type = 1, ValueType = "int"}, + StageId = {Type = 1, ValueType = "int"}, + PrefabName = {ValueType = "string"}, + ConditionPriority = {ValueType = "int"}, + TabRawImagePath = {ValueType = "string"}, + RImgChapterNamePath = {ValueType = "string"}, + UiBgPath = {ValueType = "string"}, + UiFxPath = {ValueType = "string"}, + FunctionOpenId = {ValueType = "int"}, + }, + XTablePrequelCover = { + CoverId = {ValueType = "int"}, + CoverName = {ValueType = "string"}, + Priority = {ValueType = "int"}, + ChallengeCondition = {ValueType = "int"}, + ChallengeStage = {Type = 2, KeyType = "int", ValueType = "int"}, + ChallengeConsumeItem = {Type = 2, KeyType = "int", ValueType = "int"}, + ChallengeConsumeCount = {Type = 2, KeyType = "int", ValueType = "int"}, + ChapterId = {Type = 1, ValueType = "int"}, + ActiveTimes = {Type = 2, KeyType = "int", ValueType = "string"}, + ChallengePrefabName = {ValueType = "string"}, + ShopId = {ValueType = "int"}, + ChallengeFx = {ValueType = "string"}, + }, + XTablePrequelCoverInfo = { + CoverId = {ValueType = "int"}, + CoverBg = {ValueType = "string"}, + CoverName = {ValueType = "string"}, + CoverTitle = {ValueType = "string"}, + CoverDescription = {ValueType = "string"}, + ChallengeBg = {ValueType = "string"}, + }, + XTablePrequelChapterInfo = { + ChapterId = {ValueType = "int"}, + ChapterDescription = {ValueType = "string"}, + }, + XTableExperimentGroup = { + Id = {ValueType = "int"}, + SubIndex = {ValueType = "int"}, + Name = {ValueType = "string"}, + Order = {ValueType = "int"}, + Description = {ValueType = "string"}, + TimeId = {ValueType = "int"}, + ModeExplainText = {ValueType = "string"}, + }, + XTableExperimentLevel = { + Id = {ValueType = "int"}, + GroupID = {ValueType = "int"}, + Name = {ValueType = "string"}, + RecommendLevel = {ValueType = "int"}, + Order = {ValueType = "int"}, + Type = {ValueType = "int"}, + ConditionId = {Type = 1, ValueType = "int"}, + ShowPass = {ValueType = "int"}, + Ico = {ValueType = "string"}, + TrialID = {ValueType = "int"}, + TrialStatus = {ValueType = "int"}, + SingStageId = {ValueType = "int"}, + MultStageId = {ValueType = "int"}, + SingleDescription = {ValueType = "string"}, + MultDescription = {ValueType = "string"}, + DetailBackGroundIco = {ValueType = "string"}, + TimeId = {ValueType = "int"}, + HeadIcon = {ValueType = "string"}, + HelpCourseId = {ValueType = "int"}, + SkillExplainId = {ValueType = "int"}, + StarDesc = {Type = 1, ValueType = "string"}, + StarReward = {ValueType = "int"}, + SpinePath = {ValueType = "string"}, + }, + XTableExperimentSkillExplainId = { + Id = {ValueType = "int"}, + SkillTitle = {Type = 1, ValueType = "string"}, + SkillDesc = {Type = 1, ValueType = "string"}, + }, + XTableBattleExperiment = { + Id = {ValueType = "int"}, + CharacterID = {ValueType = "int"}, + Pic = {ValueType = "string"}, + Title = {ValueType = "string"}, + Description = {ValueType = "string"}, + NextTrialID = {ValueType = "int"}, + }, + XTableExperimentReward = { + Id = {ValueType = "int"}, + StarNum = {Type = 1, ValueType = "int"}, + RewardId = {Type = 1, ValueType = "int"}, + }, + XTableExploreChapter = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + BgPic = {ValueType = "string"}, + Icon = {ValueType = "string"}, + RewardId = {ValueType = "int"}, + RewardIcon = {ValueType = "string"}, + PreId = {ValueType = "int"}, + Endurance = {ValueType = "int"}, + StoryId = {ValueType = "string"}, + ChapterPrefab = {ValueType = "string"}, + }, + XTableExploreNode = { + Id = {ValueType = "int"}, + ChapterId = {ValueType = "int"}, + Name = {ValueType = "string"}, + Title = {ValueType = "string"}, + Explain = {ValueType = "string"}, + EnterIco = {ValueType = "string"}, + IsBossNode = {ValueType = "bool"}, + IsKeyNode = {ValueType = "bool"}, + Type = {ValueType = "int"}, + TypeValue = {ValueType = "string"}, + Icon = {ValueType = "string"}, + PreShowId = {Type = 1, ValueType = "int"}, + PreOpenId = {Type = 1, ValueType = "int"}, + CostEndurance = {ValueType = "int"}, + RewardId = {ValueType = "int"}, + RewardIcon = {ValueType = "string"}, + CharacterIcon = {ValueType = "string"}, + TimeDesc = {ValueType = "string"}, + Posision = {Type = 1, ValueType = "int"}, + }, + XTableExploreBuffItem = { + Id = {ValueType = "int"}, + ChapterId = {ValueType = "int"}, + UnlockEvent = {Type = 1, ValueType = "int"}, + GainDesc = {Type = 1, ValueType = "string"}, + Icon = {ValueType = "string"}, + BuffName = {ValueType = "string"}, + Explain = {ValueType = "string"}, + EventId = {ValueType = "int"}, + }, + XTableExploreStoryText = { + Id = {ValueType = "int"}, + ChapterId = {ValueType = "int"}, + Title = {ValueType = "string"}, + Text = {ValueType = "string"}, + UnlockNodeId = {ValueType = "int"}, + }, + XTableDormFurnitureSuit = { + Id = {ValueType = "int"}, + SuitName = {ValueType = "string"}, + }, + XTableFurnitureSuit = { + Id = {ValueType = "int"}, + SuitName = {ValueType = "string"}, + SuitIcon = {ValueType = "string"}, + }, + XTableFurnitureAttrType = { + Id = {ValueType = "int"}, + AttrName = {ValueType = "string"}, + AttrIcon = {ValueType = "string"}, + }, + XTablePay = { + Key = {ValueType = "string"}, + Platform = {ValueType = "int"}, + GoodsId = {ValueType = "string"}, + Amount = {ValueType = "float"}, + Name = {ValueType = "string"}, + Desc = {ValueType = "string"}, + MoneyCard = {ValueType = "int"}, + Icon = {ValueType = "string"}, + PayId = {ValueType = "int"}, + Type = {ValueType = "int"}, + ShowUIType = {ValueType = "int"}, + }, + XTablePayKeyPlatformPrefix = { + Platform = {ValueType = "int"}, + KeyPrefix = {ValueType = "string"}, + }, + XTableFirstPayReward = { + NeedPayMoney = {ValueType = "float"}, + BigRewardId = {ValueType = "int"}, + SmallRewardId = {ValueType = "int"}, + }, + XTableAccumulatedPay = { + Id = {ValueType = "int"}, + Type = {ValueType = "int"}, + TimeId = {ValueType = "int"}, + PayRewardId = {Type = 1, ValueType = "int"}, + }, + XTableAccumulatedPayReward = { + Id = {ValueType = "int"}, + Money = {ValueType = "int"}, + BigRewardId = {ValueType = "int"}, + SmallRewardId = {ValueType = "int"}, + MailId = {ValueType = "int"}, + }, + XTableFubenBranchActivity = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + ActivityTimeId = {ValueType = "int"}, + FightTimeId = {ValueType = "int"}, + ChallengeTimeId = {ValueType = "int"}, + }, + XTableFubenBranchSection = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Icon = {ValueType = "string"}, + MinLevel = {ValueType = "int"}, + MaxLevel = {ValueType = "int"}, + ShowRewardId = {ValueType = "int"}, + NormalId = {ValueType = "int"}, + DifficultyId = {ValueType = "int"}, + SkipId = {ValueType = "int"}, + }, + XTableFubenBranchChallenge = { + Id = {ValueType = "int"}, + OrderId = {ValueType = "string"}, + Name = {ValueType = "string"}, + OpenCondition = {ValueType = "int"}, + Description = {ValueType = "string"}, + Prefab = {ValueType = "string"}, + Cover = {ValueType = "string"}, + Bg1 = {ValueType = "string"}, + Bg2 = {ValueType = "string"}, + MoveStageIndex = {ValueType = "int"}, + DatumLinePrecent = {ValueType = "float"}, + StageId = {Type = 1, ValueType = "int"}, + }, + XTableBossActivity = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + ActivityTimeId = {ValueType = "int"}, + FightTimeId = {ValueType = "int"}, + }, + XTableBossSection = { + Id = {ValueType = "int"}, + OrderId = {ValueType = "string"}, + Name = {ValueType = "string"}, + ChapterName = {ValueType = "string"}, + Description = {ValueType = "string"}, + Cover = {ValueType = "string"}, + Icon = {ValueType = "string"}, + Prefab = {ValueType = "string"}, + MinLevel = {ValueType = "int"}, + MaxLevel = {ValueType = "int"}, + ShowRewardId = {ValueType = "int"}, + SkipId = {ValueType = "int"}, + ChallengeId = {Type = 1, ValueType = "int"}, + StarRewardId = {Type = 1, ValueType = "int"}, + }, + XTableBossChallenge = { + Id = {ValueType = "int"}, + StageId = {ValueType = "int"}, + StageAttention = {Type = 1, ValueType = "string"}, + StageAttentionTitle = {Type = 1, ValueType = "string"}, + EffectPath = {ValueType = "string"}, + }, + XTableBossStarReward = { + Id = {ValueType = "int"}, + RequireStar = {ValueType = "int"}, + RewardId = {ValueType = "int"}, + }, + XTableBossChallengeRes = { + Id = {ValueType = "int"}, + Icon = {ValueType = "string"}, + BgPath = {ValueType = "string"}, + EffectPath = {ValueType = "string"}, + }, + XTableBossOnlineActivity = { + Id = {ValueType = "int"}, + BeginTimeStr = {Type = 1, ValueType = "string"}, + EndTimeStr = {Type = 1, ValueType = "string"}, + }, + XTableBossOnlineOpenTime = { + Id = {ValueType = "int"}, + BeginTime = {ValueType = "string"}, + EndTime = {ValueType = "string"}, + BeginTimeSec = {ValueType = "int"}, + EndTimeSec = {ValueType = "int"}, + }, + XTableCharacterExhibition = { + Id = {ValueType = "int"}, + GroupId = {ValueType = "int"}, + GroupName = {ValueType = "string"}, + GroupLogo = {ValueType = "string"}, + GroupDescription = {ValueType = "string"}, + CharacterId = {ValueType = "int"}, + HeadPortrait = {ValueType = "string"}, + GraduationPortrait = {ValueType = "string"}, + Port = {ValueType = "int"}, + Type = {ValueType = "int"}, + InVisible = {ValueType = "int"}, + CanClickGroup = {ValueType = "int"}, + }, + XTableExhibitionLevel = { + LevelId = {ValueType = "int"}, + Name = {ValueType = "string"}, + Desc = {ValueType = "string"}, + IconFrame = {ValueType = "string"}, + LevelLogo = {ValueType = "string"}, + LevelFrame = {ValueType = "string"}, + LevelIcon = {ValueType = "string"}, + }, + XTableFurnitureAttr = { + Id = {ValueType = "int"}, + Type = {ValueType = "int"}, + Value = {ValueType = "int"}, + }, + XTableCheat = { + Command = {ValueType = "string"}, + StageId = {ValueType = "int"}, + Equip = {ValueType = "string"}, + Character = {Type = 1, ValueType = "string"}, + }, + XTableFurnitureBaseAttr = { + Id = {ValueType = "int"}, + Value = {ValueType = "int"}, + }, + XTableFurnitureExtraAttr = { + Id = {ValueType = "int"}, + BaseAttrId = {ValueType = "int"}, + AttrIds = {Type = 1, ValueType = "int"}, + }, + XTableFurnitureViewAngle = { + MinorType = {ValueType = "int"}, + MinorName = {ValueType = "string"}, + TargetAngleY = {ValueType = "int"}, + AllowYAxis = {ValueType = "int"}, + GroupId = {ValueType = "int"}, + }, + XTableFurntiureColour = { + Id = {ValueType = "int"}, + AttrIds = {Type = 1, ValueType = "int"}, + FurnitureMaterials = {Type = 1, ValueType = "string"}, + DefaultMaterial = {ValueType = "string"}, + FurnitureFx = {Type = 1, ValueType = "string"}, + DefaultFurnitureFx = {ValueType = "string"}, + FurnitureIcons = {Type = 1, ValueType = "string"}, + DefaultFurnitureIcon = {ValueType = "string"}, + }, + XTableSignIn = { + Id = {ValueType = "int"}, + TimeId = {ValueType = "int"}, + Name = {ValueType = "string"}, + PrefabPath = {ValueType = "string"}, + Type = {ValueType = "int"}, + RoundDays = {Type = 1, ValueType = "int"}, + SubRoundId = {Type = 1, ValueType = "int"}, + OpenLevel = {ValueType = "int"}, + OpenStage = {ValueType = "int"}, + PreSignId = {ValueType = "int"}, + IsShowWhenDayOver = {ValueType = "bool"}, + IsShowWhenSignOver = {ValueType = "bool"}, + }, + XTableSignInReward = { + Id = {ValueType = "int"}, + SignId = {ValueType = "int"}, + Pre = {ValueType = "int"}, + Round = {ValueType = "int"}, + Day = {ValueType = "int"}, + IsGrandPrix = {ValueType = "bool"}, + RewardType = {ValueType = "int"}, + RewardId = {ValueType = "int"}, + DropId = {ValueType = "int"}, + ShowRewardId = {ValueType = "int"}, + }, + XTableSignInSubround = { + Id = {ValueType = "int"}, + SubRoundDays = {Type = 1, ValueType = "int"}, + SubRoundName = {Type = 1, ValueType = "string"}, + SubRoundIcon = {Type = 1, ValueType = "string"}, + SubRoundDesc = {ValueType = "string"}, + }, + XTableSignCard = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + PrefabPath = {ValueType = "string"}, + CanBuyDay = {ValueType = "int"}, + Description = {ValueType = "string"}, + Param = {Type = 2, KeyType = "int", ValueType = "int"}, + }, + XTableSignFirstRecharge = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + PrefabPath = {ValueType = "string"}, + Description = {ValueType = "string"}, + }, + XTableWelfare = { + Id = {ValueType = "int"}, + FunctionType = {ValueType = "int"}, + SubConfigId = {ValueType = "int"}, + Sort = {ValueType = "int"}, + }, + XTableAutoWindowView = { + Id = {ValueType = "int"}, + BgIcon = {ValueType = "string"}, + SpineBg = {ValueType = "string"}, + SkipId = {ValueType = "int"}, + SkipURL = {ValueType = "string"}, + Type = {ValueType = "int"}, + }, + XTableAutoWindowController = { + Id = {ValueType = "int"}, + FunctionType = {ValueType = "int"}, + SkipId = {ValueType = "int"}, + Pre = {ValueType = "int"}, + TimeId = {ValueType = "int"}, + AutoType = {ValueType = "int"}, + AutoCount = {ValueType = "int"}, + ConditionId = {ValueType = "int"}, + ContinueOpen = {ValueType = "bool"}, + }, + XTableStageFightControl = { + Id = {ValueType = "int"}, + MaxRecommendFight = {ValueType = "int"}, + MaxShowFight = {ValueType = "int"}, + AvgRecommendFight = {ValueType = "int"}, + AvgShowFight = {ValueType = "int"}, + RecommendFight = {ValueType = "int"}, + ShowFight = {ValueType = "int"}, + CharacterFight = {ValueType = "int"}, + EquipFight = {ValueType = "int"}, + }, + XTablePracticeChapter = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + ChallengeType = {ValueType = "int"}, + ConditionId = {ValueType = "int"}, + IsOpen = {ValueType = "int"}, + StageId = {Type = 1, ValueType = "int"}, + }, + XTablePracticeActivity = { + StageId = {ValueType = "int"}, + ActivityTimeId = {ValueType = "int"}, + ActivityCondition = {Type = 1, ValueType = "int"}, + OpenCondition = {Type = 1, ValueType = "int"}, + }, + XTablePracticeChapterDetail = { + Id = {ValueType = "int"}, + Type = {ValueType = "int"}, + Name = {ValueType = "string"}, + Description = {ValueType = "string"}, + BgPath = {ValueType = "string"}, + PracticeContentPrefab = {ValueType = "string"}, + PracticeGridPrefab = {ValueType = "string"}, + }, + XTablePracticeSkillDetails = { + StageId = {ValueType = "int"}, + Title = {ValueType = "string"}, + Description = {ValueType = "string"}, + Icon = {ValueType = "string"}, + PhaseDescription = {ValueType = "string"}, + }, + XTableReportTag = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + ParentId = {ValueType = "int"}, + }, + XTableActivity = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + GroupId = {ValueType = "int"}, + SortId = {ValueType = "int"}, + TimeId = {ValueType = "int"}, + ActivityType = {ValueType = "int"}, + ActivityBgType = {ValueType = "int"}, + ActivityBg = {ValueType = "string"}, + ActivityTitle = {ValueType = "string"}, + ActivityDes = {ValueType = "string"}, + ActivityPrefabPath = {ValueType = "string"}, + Params = {Type = 1, ValueType = "int"}, + ConditionId = {ValueType = "int"}, + ShowBeginTime = {ValueType = "string"}, + ShowEndTime = {ValueType = "string"}, + }, + XTableActivityGroup = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + SortId = {ValueType = "int"}, + Bg = {ValueType = "string"}, + }, + XTableActivityLink = { + Id = {ValueType = "int"}, + LinkName = {ValueType = "string"}, + LinkUrl = {ValueType = "string"}, + Icon = {ValueType = "string"}, + }, + XTablePurchaseIconAssetPath = { + Icon = {ValueType = "string"}, + AssetPath = {ValueType = "string"}, + CoverImgPath = {ValueType = "string"}, + }, + XTablePurchaseTabControl = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + GroupId = {ValueType = "int"}, + GroupName = {ValueType = "string"}, + GroupIcon = {ValueType = "string"}, + GroupOrder = {ValueType = "int"}, + UiType = {ValueType = "int"}, + IsOpen = {ValueType = "int"}, + }, + XTablePurchaseUiType = { + UiType = {ValueType = "int"}, + UiPrefabStyle = {ValueType = "string"}, + GroupType = {ValueType = "int"}, + }, + XTablePurchaseItem = { + Id = {ValueType = "int"}, + ConsumeId = {ValueType = "int"}, + ConsumeCount = {ValueType = "int"}, + ObtainId = {ValueType = "int"}, + ObtainCount = {ValueType = "int"}, + FirstObtainId = {ValueType = "int"}, + FirstObtainCount = {ValueType = "int"}, + ExtraObtainId = {ValueType = "int"}, + ExtraObtainCount = {ValueType = "int"}, + FirstObtainStartTimeStr = {ValueType = "string"}, + FirstObtainEndTimeStr = {ValueType = "string"}, + Desc = {ValueType = "string"}, + Icon = {ValueType = "string"}, + UiType = {ValueType = "int"}, + Priority = {ValueType = "int"}, + LogType = {ValueType = "int"}, + PayKeySuffix = {ValueType = "string"}, + }, + XTablePurchasePackage = { + Id = {ValueType = "int"}, + ConsumeId = {ValueType = "int"}, + ConsumeCount = {ValueType = "int"}, + RewardId = {ValueType = "int"}, + MailId = {ValueType = "int"}, + MailCount = {ValueType = "int"}, + DailyRewardId = {ValueType = "int"}, + DailyRewardCount = {ValueType = "int"}, + TimeToEffectStr = {ValueType = "string"}, + TimeToInvalidStr = {ValueType = "string"}, + ShelvesType = {ValueType = "int"}, + ShelvesDays = {ValueType = "string"}, + BuyLimitTimes = {ValueType = "int"}, + BuyLimitType = {ValueType = "int"}, + BuyLimitParam = {ValueType = "int"}, + Name = {ValueType = "string"}, + Desc = {ValueType = "string"}, + Icon = {ValueType = "string"}, + IsSellOutShow = {ValueType = "bool"}, + PrePurchaseId = {ValueType = "int"}, + ConditionId = {Type = 1, ValueType = "int"}, + Tag = {ValueType = "int"}, + UiType = {ValueType = "int"}, + Priority = {ValueType = "int"}, + LogType = {ValueType = "int"}, + NormalDiscountStr = {ValueType = "string"}, + DiscountShowStr = {ValueType = "string"}, + DiscountItemId = {Type = 1, ValueType = "int"}, + DiscountItemCount = {Type = 1, ValueType = "int"}, + DiscountValue = {Type = 1, ValueType = "int"}, + DiscountBeginTimeStr = {Type = 2, KeyType = "int", ValueType = "string"}, + DiscountEndTimeStr = {Type = 2, KeyType = "int", ValueType = "string"}, + SignInId = {ValueType = "int"}, + PayKeySuffix = {ValueType = "string"}, + MutexPurchaseIdStr = {ValueType = "string"}, + ConvertSwitch = {ValueType = "int"}, + CanMultiply = {ValueType = "bool"}, + }, + XTablePurchasePackageConvert = { + Id = {ValueType = "int"}, + Note = {ValueType = "string"}, + PurchasePackageId = {ValueType = "int"}, + RewardGoodsId = {ValueType = "int"}, + Price = {ValueType = "int"}, + }, + XTableMoive = { + Id = {ValueType = "string"}, + Name = {ValueType = "string"}, + AssetUrl = {ValueType = "string"}, + }, + XTableMovieNew = { + Id = {ValueType = "int"}, + ActionId = {ValueType = "int"}, + NextActionId = {ValueType = "int"}, + Type = {ValueType = "int"}, + IsBlock = {ValueType = "int"}, + IsEnd = {ValueType = "int"}, + BeginAnim = {ValueType = "string"}, + EndAnim = {ValueType = "string"}, + BeginDelay = {ValueType = "int"}, + EndDelay = {ValueType = "int"}, + Params = {Type = 2, KeyType = "int", ValueType = "string"}, + }, + XTableVideoConfig = { + Id = {ValueType = "int"}, + Title = {ValueType = "string"}, + VideoUrl = {ValueType = "string"}, + }, + XTablePurchaseTagType = { + Tag = {ValueType = "int"}, + Des = {ValueType = "string"}, + Style = {ValueType = "string"}, + Effect = {ValueType = "string"}, + Type = {ValueType = "int"}, + }, + XTableUi = { + UiName = {ValueType = "string"}, + ParentUiName = {ValueType = "string"}, + LoadWithParent = {ValueType = "bool"}, + UiType = {ValueType = "string"}, + UiResType = {ValueType = "string"}, + ClassType = {ValueType = "string"}, + PrefabUrl = {ValueType = "string"}, + SceneUrl = {ValueType = "string"}, + ModelUrl = {ValueType = "string"}, + IgnoreFailure = {ValueType = "bool"}, + CacheTime = {ValueType = "int"}, + Recycle = {ValueType = "bool"}, + FightingStay = {ValueType = "int"}, + HideSetPosition = {ValueType = "bool"}, + }, + XTableUiComponent = { + Key = {ValueType = "string"}, + PrefabUrl = {ValueType = "string"}, + }, + XTableShopGroup = { + Id = {ValueType = "int"}, + TagName = {ValueType = "string"}, + }, + XTableLoading = { + Id = {ValueType = "int"}, + Type = {ValueType = "string"}, + Title = {ValueType = "string"}, + Desc = {ValueType = "string"}, + ImageUrl = {ValueType = "string"}, + Weight = {ValueType = "int"}, + }, + XTableHelpCourse = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Function = {ValueType = "string"}, + Describe = {ValueType = "string"}, + IsShowCourse = {ValueType = "int"}, + ImageAsset = {Type = 1, ValueType = "string"}, + }, + XTableFubenChallengeBanner = { + Id = {ValueType = "int"}, + Type = {ValueType = "int"}, + NameEn = {ValueType = "string"}, + SimpleDesc = {ValueType = "string"}, + Icon = {ValueType = "string"}, + IsClose = {ValueType = "bool"}, + ResetType = {ValueType = "int"}, + ResetTime = {ValueType = "string"}, + ResetInterval = {ValueType = "int"}, + ShopId = {ValueType = "int"}, + IsOpen = {ValueType = "int"}, + Priority = {ValueType = "int"}, + ShowNewStartTime = {ValueType = "string"}, + ShowNewEndTime = {ValueType = "string"}, + FunctionId = {ValueType = "int"}, + }, + XTableLoginCode = { + ErrCode = {ValueType = "int"}, + Msg = {ValueType = "string"}, + }, + XTableShopTypeName = { + Id = {ValueType = "int"}, + TypeName = {ValueType = "string"}, + Desc = {ValueType = "string"}, + }, + XTableShopBuyLimitLabel = { + ClockId = {ValueType = "int"}, + TextLimitLabel = {ValueType = "string"}, + }, + XTableDormGuideTask = { + Id = {ValueType = "int"}, + TaskId = {ValueType = "int"}, + }, + XTableMedal = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Desc = {ValueType = "string"}, + UnlockType = {ValueType = "int"}, + UnlockPara = {Type = 1, ValueType = "int"}, + UnlockDesc = {ValueType = "string"}, + SkillId = {Type = 1, ValueType = "int"}, + Priority = {ValueType = "int"}, + Medal3D = {ValueType = "string"}, + MedalImg = {ValueType = "string"}, + MedalIcon = {ValueType = "string"}, + MedalHeadframe = {ValueType = "string"}, + }, + XTableGuildCreate = { + Id = {ValueType = "int"}, + ItemId = {ValueType = "int"}, + ItemNum = {ValueType = "int"}, + }, + XTableGuildLevel = { + Level = {ValueType = "int"}, + Capacity = {ValueType = "int"}, + PositionNum = {Type = 1, ValueType = "int"}, + Build = {ValueType = "int"}, + Contribution = {ValueType = "int"}, + EmergencyMaintenance = {ValueType = "int"}, + EmergencyDay = {ValueType = "int"}, + WishMaxCount = {ValueType = "int"}, + WishItemCount = {ValueType = "int"}, + WishContributeMaxCount = {ValueType = "int"}, + TalentPoint = {ValueType = "int"}, + }, + XTableGuildHeadPortrait = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Describe = {ValueType = "string"}, + Icon = {ValueType = "string"}, + }, + XTableGuildGift = { + Id = {ValueType = "int"}, + GuildLevel = {ValueType = "int"}, + GiftLevel = {ValueType = "int"}, + GiftReward = {ValueType = "int"}, + GiftIcon = {ValueType = "string"}, + GiftContribute = {ValueType = "int"}, + }, + XTableGuildNews = { + Id = {ValueType = "int"}, + Content = {ValueType = "string"}, + ShowChat = {ValueType = "int"}, + Group = {ValueType = "int"}, + }, + XTableGuildPosition = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Priority = {ValueType = "int"}, + Authority = {Type = 1, ValueType = "int"}, + }, + XTablePurchaseLBByPass = { + Id = {ValueType = "int"}, + LBId = {ValueType = "int"}, + }, + XTableGuildWelfare = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + SkipId = {ValueType = "int"}, + WelfareBg = {ValueType = "string"}, + Condition = {ValueType = "int"}, + }, + XTableGuildChallengeDetails = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + SkipId = {ValueType = "int"}, + ChallengeBg = {ValueType = "string"}, + ChallengeType = {ValueType = "int"}, + Condition = {ValueType = "int"}, + }, + XTableGuildWelcome = { + Id = {ValueType = "int"}, + WelcomeWord = {ValueType = "string"}, + Select = {ValueType = "bool"}, + }, + XTableGuildCustomName = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + RankLevel = {ValueType = "int"}, + Enable = {ValueType = "bool"}, + }, + XTableUiFightButtonDefaultStyle = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Scheme = {ValueType = "int"}, + }, + XTableDormFurnitureType = { + Id = {ValueType = "int"}, + TypeName = {ValueType = "string"}, + TypeIcon = {ValueType = "string"}, + Color = {ValueType = "string"}, + }, + XTableDormFurnitureTagType = { + Id = {ValueType = "int"}, + TagName = {ValueType = "string"}, + AttrIndex = {ValueType = "int"}, + }, + XTableFurnitureSingleAttrLevel = { + Id = {ValueType = "int"}, + FurnitureType = {ValueType = "int"}, + AttrMinScore = {Type = 1, ValueType = "int"}, + AttrMaxScore = {Type = 1, ValueType = "int"}, + Quality = {ValueType = "int"}, + }, + XTableFestivalActivity = { + Id = {ValueType = "int"}, + TimeId = {ValueType = "int"}, + Name = {ValueType = "string"}, + Priority = {ValueType = "int"}, + SkipId = {ValueType = "int"}, + FunctionOpenId = {ValueType = "int"}, + StagePrefix = {ValueType = "string"}, + BannerBg = {ValueType = "string"}, + MainBackgound = {ValueType = "string"}, + EffectUrl = {ValueType = "string"}, + FubenPrefab = {ValueType = "string"}, + GridFubenPrefab = {ValueType = "string"}, + GridStoryPrefab = {ValueType = "string"}, + TitleIcon = {ValueType = "string"}, + TitleBg = {ValueType = "string"}, + ChapterType = {ValueType = "int"}, + ChapterBgm = {ValueType = "int"}, + StageId = {Type = 1, ValueType = "int"}, + StageName = {Type = 2, KeyType = "int", ValueType = "string"}, + StageStyle = {Type = 2, KeyType = "int", ValueType = "string"}, + }, + XTableBriefActivity = { + Id = {ValueType = "int"}, + TimeId = {ValueType = "int"}, + TaskInfoId = {ValueType = "int"}, + GachaId = {ValueType = "int"}, + AnimConditionId = {ValueType = "int"}, + GachaUi = {ValueType = "string"}, + Gacha3DBg = {ValueType = "string"}, + Main3DBg = {ValueType = "string"}, + ShopInfoId = {Type = 1, ValueType = "int"}, + UIModelId = {Type = 1, ValueType = "string"}, + SpinePath = {Type = 1, ValueType = "string"}, + }, + XTableActivityBriefShop = { + Id = {ValueType = "int"}, + ShopId = {ValueType = "int"}, + ShopItemBg = {ValueType = "string"}, + ShopBg = {ValueType = "string"}, + ShopIcon = {ValueType = "string"}, + }, + XTableActivityBriefTask = { + Id = {ValueType = "int"}, + TaskGroupId = {ValueType = "int"}, + TaskBg = {ValueType = "string"}, + TaskVipBg = {ValueType = "string"}, + TaskGotBg = {ValueType = "string"}, + TaskVipGotBg = {ValueType = "string"}, + ActivityPointId = {ValueType = "int"}, + MarkTaskId = {Type = 1, ValueType = "int"}, + }, + XTableActivityBriefGroup = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + SkipId = {ValueType = "int"}, + BtnName = {ValueType = "string"}, + }, + XTableActivityBriefStory = { + Id = {ValueType = "int"}, + BgImage = {ValueType = "string"}, + StoryId = {ValueType = "string"}, + UnlockBgImage = {ValueType = "string"}, + ConditionId = {ValueType = "int"}, + Priority = {ValueType = "int"}, + }, + XTableDrawShowCharacter = { + Id = {ValueType = "int"}, + AnimeID = {ValueType = "string"}, + VoiceId = {ValueType = "int"}, + }, + XTableInputSetDefaultKeyMap = { + Id = {ValueType = "int"}, + NpcOperationKey = {ValueType = "int"}, + XboxKeyCode = {ValueType = "string"}, + PsKeyCode = {ValueType = "string"}, + OtherKeyCode = {ValueType = "string"}, + }, + XTableInputSetKeyIco = { + Id = {ValueType = "int"}, + KeyCode = {ValueType = "int"}, + XboxIco = {ValueType = "string"}, + PsIco = {ValueType = "string"}, + OtherIco = {ValueType = "string"}, + }, + XTableInputSetRecommendKey = { + Id = {ValueType = "int"}, + NpcOperationKey = {ValueType = "int"}, + RecommendXboxIco = {Type = 1, ValueType = "string"}, + RecommendPsIco = {Type = 1, ValueType = "string"}, + RecommendOtherIco = {Type = 1, ValueType = "string"}, + }, + XTableInputSetKeyboardMap = { + Id = {ValueType = "int"}, + Type = {ValueType = "int"}, + Title = {ValueType = "string"}, + KeyName = {ValueType = "string"}, + }, + XTableKeyCodeString = { + Key = {ValueType = "int"}, + KeyCode = {ValueType = "int"}, + Str = {ValueType = "string"}, + }, + XTableInputSetControllerMap = { + Id = {ValueType = "int"}, + Type = {ValueType = "int"}, + NpcOperationKey = {ValueType = "int"}, + Title = {ValueType = "string"}, + }, + XTableIntList = { + Id = {ValueType = "int"}, + List = {Type = 1, ValueType = "int"}, + }, + XTableActivitySortRule = { + Id = {ValueType = "int"}, + Type = {ValueType = "int"}, + ActivityId = {ValueType = "int"}, + Priority = {ValueType = "int"}, + }, + XTableBabelTowerActivity = { + Id = {ValueType = "int"}, + ActivityTimeId = {ValueType = "int"}, + FightTimeId = {ValueType = "int"}, + ShowTimeId = {ValueType = "int"}, + RankType = {ValueType = "int"}, + BaseRankNum = {ValueType = "int"}, + StageId = {Type = 1, ValueType = "int"}, + }, + XTableBabelTowerStage = { + Id = {ValueType = "int"}, + BaseScore = {ValueType = "int"}, + BaseSupportPoint = {ValueType = "int"}, + PreStageScore = {ValueType = "int"}, + TimeId = {ValueType = "int"}, + StageGuideId = {Type = 1, ValueType = "int"}, + SupportConditionId = {Type = 1, ValueType = "int"}, + BaseBuffId = {Type = 1, ValueType = "int"}, + ChallengeBuffGroup = {Type = 1, ValueType = "int"}, + SupportBuffGroup = {Type = 1, ValueType = "int"}, + TeamCount = {ValueType = "int"}, + }, + XTableBabelTowerStageLevel = { + Id = {ValueType = "int"}, + StageId = {ValueType = "int"}, + Level = {ValueType = "int"}, + RecommendAblity = {ValueType = "int"}, + Name = {ValueType = "string"}, + Desc = {ValueType = "string"}, + ScoreRatio = {ValueType = "float"}, + FightEventId = {Type = 1, ValueType = "int"}, + LockBuffId = {Type = 1, ValueType = "int"}, + }, + XTableBabelTowerBuffGroup = { + Id = {ValueType = "int"}, + BuffId = {Type = 1, ValueType = "int"}, + }, + XTableBabelTowerBuff = { + Id = {ValueType = "int"}, + StageId = {ValueType = "int"}, + FightEventId = {ValueType = "int"}, + ScoreAdd = {ValueType = "int"}, + PointSub = {ValueType = "int"}, + BanCharacterId = {Type = 1, ValueType = "int"}, + }, + XTableBabelTowerSupportCondition = { + Id = {ValueType = "int"}, + Condition = {ValueType = "int"}, + PointAdd = {ValueType = "int"}, + }, + XTableBabelTowerRankLevel = { + Id = {ValueType = "int"}, + MinLevel = {ValueType = "int"}, + MaxLevel = {ValueType = "int"}, + }, + XTableBabelTowerStageGuide = { + Id = {ValueType = "int"}, + BuffGroup = {Type = 1, ValueType = "int"}, + BuffId = {Type = 1, ValueType = "int"}, + }, + XTableBabelTowerRankReward = { + Id = {ValueType = "int"}, + LevelId = {ValueType = "int"}, + MinRank = {ValueType = "float"}, + MaxRank = {ValueType = "float"}, + MailId = {ValueType = "int"}, + RankIcon = {ValueType = "string"}, + }, + XTableBabelTowerStageGuideDetails = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + GuideBg = {ValueType = "string"}, + Description = {ValueType = "string"}, + }, + XTableBabelTowerBuffDetails = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + BuffBg = {ValueType = "string"}, + BuffTriangleBg = {ValueType = "string"}, + Desc = {ValueType = "string"}, + }, + XTableBabelTowerBuffGroupDetails = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Desc = {ValueType = "string"}, + IsStress = {ValueType = "int"}, + BuffLv = {Type = 1, ValueType = "int"}, + }, + XTableBabelTowerActivityDifficulty = { + Id = {ValueType = "int"}, + Normal = {ValueType = "int"}, + NormalTitle = {ValueType = "string"}, + NormalStatus = {ValueType = "string"}, + Urgency = {ValueType = "int"}, + UrgencyTitle = {ValueType = "string"}, + UrgencyStatus = {ValueType = "string"}, + Critical = {ValueType = "int"}, + CriticalTitle = {ValueType = "string"}, + CriticalStatus = {ValueType = "string"}, + }, + XTableBabelTowerStageDetails = { + Id = {ValueType = "int"}, + MainUiBg = {ValueType = "string"}, + StagePrefab = {ValueType = "string"}, + StageGuidePrefab = {ValueType = "string"}, + Name = {ValueType = "string"}, + Title = {ValueType = "string"}, + Number = {ValueType = "int"}, + ChallengeUiBg = {ValueType = "string"}, + SupportUiBg = {ValueType = "string"}, + }, + XTableBabelTowerActivityDetails = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + BeginStoryId = {ValueType = "string"}, + RankTitle = {ValueType = "string"}, + }, + XTableBabelTowerConditionDetails = { + Id = {ValueType = "int"}, + Desc = {ValueType = "string"}, + }, + XTableRedEnvelopeItemDrop = { + Id = {ValueType = "int"}, + ItemId = {ValueType = "int"}, + ItemCountMax = {ValueType = "int"}, + ItemCountMin = {ValueType = "int"}, + Rate = {ValueType = "int"}, + BottomCount = {ValueType = "int"}, + DailyCount = {ValueType = "int"}, + ActivityCount = {ValueType = "int"}, + }, + XTableRedEnvelope = { + Id = {ValueType = "int"}, + TimeId = {ValueType = "int"}, + StageList = {Type = 1, ValueType = "int"}, + StageTypeList = {Type = 1, ValueType = "int"}, + DropIds = {Type = 1, ValueType = "int"}, + }, + XTableRedEnvelopeDrop = { + Id = {ValueType = "int"}, + ItemId = {ValueType = "int"}, + ItemCount = {ValueType = "int"}, + PlayerWeight = {ValueType = "int"}, + NpcIds = {Type = 1, ValueType = "int"}, + Weights = {Type = 1, ValueType = "int"}, + ReduceWeight = {ValueType = "int"}, + MinWeight = {ValueType = "int"}, + }, + XTableRedEnvelopeNpc = { + Id = {ValueType = "int"}, + NpcName = {ValueType = "string"}, + NpcHead = {ValueType = "string"}, + }, + XTableGacha = { + Id = {ValueType = "int"}, + StartTimeStr = {ValueType = "string"}, + EndTimeStr = {ValueType = "string"}, + ConsumeId = {ValueType = "int"}, + ConsumeCount = {ValueType = "int"}, + BtnGachaCount = {Type = 1, ValueType = "int"}, + PropStartTimes = {ValueType = "int"}, + PropAddInitVal = {ValueType = "int"}, + PropAdd = {ValueType = "int"}, + PropAddGroupId = {ValueType = "int"}, + GroupId = {Type = 1, ValueType = "int"}, + Weight = {Type = 1, ValueType = "int"}, + BtnGachaPurchaseID = {Type = 1, ValueType = "int"}, + PreGachaId = {ValueType = "int"}, + OrganizeId = {ValueType = "int"}, + OrganizeSort = {ValueType = "int"}, + GachaIcon = {ValueType = "string"}, + }, + XTableGachaReward = { + Id = {ValueType = "int"}, + GroupId = {ValueType = "int"}, + UsableTimes = {ValueType = "int"}, + TemplateId = {ValueType = "int"}, + Count = {ValueType = "int"}, + Params = {Type = 1, ValueType = "int"}, + Weight = {ValueType = "int"}, + Rare = {ValueType = "bool"}, + Priority = {ValueType = "int"}, + RewardType = {ValueType = "int"}, + Note = {ValueType = "string"}, + }, + XTableRepeatChallengeActivity = { + Id = {ValueType = "int"}, + ActivityTimeId = {ValueType = "int"}, + ChallengeTimeId = {ValueType = "int"}, + FightTimeId = {ValueType = "int"}, + ShopSkipId = {ValueType = "int"}, + Name = {ValueType = "string"}, + ActDescription = {ValueType = "string"}, + Cover = {ValueType = "string"}, + NpcRefreshClock = {ValueType = "int"}, + HideChapterConditionId = {ValueType = "int"}, + NormalChapter = {Type = 1, ValueType = "int"}, + HiddenChapter = {Type = 1, ValueType = "int"}, + }, + XTableRepeatChallengeChapter = { + Id = {ValueType = "int"}, + TimeId = {ValueType = "int"}, + Name = {ValueType = "string"}, + TitlePath = {ValueType = "string"}, + Bg = {ValueType = "string"}, + Prefab = {ValueType = "string"}, + EffectPath = {ValueType = "string"}, + OrderId = {ValueType = "string"}, + Type = {ValueType = "int"}, + BuffId = {ValueType = "int"}, + StageId = {Type = 1, ValueType = "int"}, + }, + XTableRepeatChallengeStage = { + Id = {ValueType = "int"}, + ExpAdd = {ValueType = "int"}, + }, + XTableRepeatChallengeLevel = { + Id = {ValueType = "int"}, + UpExp = {ValueType = "int"}, + NeedShow = {ValueType = "bool"}, + SimpleDesc = {ValueType = "string"}, + BuffId = {Type = 1, ValueType = "int"}, + }, + XTableRepeatChallengeReward = { + Id = {ValueType = "int"}, + Condition = {ValueType = "int"}, + RewardId = {ValueType = "int"}, + }, + XTableFestival = { + Id = {ValueType = "int"}, + StartTimeStr = {ValueType = "string"}, + EndTimeStr = {ValueType = "string"}, + Note = {ValueType = "string"}, + }, + XTableFestivalMail = { + Id = {ValueType = "int"}, + FestivalId = {ValueType = "int"}, + CharacterId = {ValueType = "int"}, + MailId = {ValueType = "int"}, + }, + XTableDailyLottery = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + PrefabPath = {ValueType = "string"}, + RoundDays = {Type = 1, ValueType = "int"}, + RoundIds = {Type = 1, ValueType = "int"}, + OpenLevel = {ValueType = "int"}, + OpenStage = {ValueType = "int"}, + StartTimeStr = {ValueType = "string"}, + CloseTimeStr = {ValueType = "string"}, + MaxRecordCount = {ValueType = "int"}, + RuleTitle = {Type = 1, ValueType = "string"}, + RuleContent = {Type = 1, ValueType = "string"}, + }, + XTableDailyLotteryReward = { + Id = {ValueType = "int"}, + RoundId = {ValueType = "int"}, + RewardId = {ValueType = "int"}, + Weight = {ValueType = "int"}, + RewardText = {ValueType = "string"}, + RewardSignPath = {ValueType = "string"}, + RewardSignDesc = {ValueType = "string"}, + }, + XTableShopScreenGroup = { + Id = {ValueType = "int"}, + GroupName = {ValueType = "string"}, + GroupIcon = {ValueType = "string"}, + ScreenName = {Type = 1, ValueType = "string"}, + ScreenID = {Type = 1, ValueType = "int"}, + }, + XTableArchiveMonster = { + Id = {ValueType = "int"}, + Order = {ValueType = "int"}, + Author = {ValueType = "string"}, + Name = {ValueType = "string"}, + Icon = {ValueType = "string"}, + Pic = {ValueType = "string"}, + LockPic = {ValueType = "string"}, + Type = {ValueType = "int"}, + TagGroupId = {ValueType = "int"}, + TagIds = {Type = 1, ValueType = "int"}, + StandbyAction = {ValueType = "string"}, + Actions = {Type = 1, ValueType = "string"}, + NpcId = {Type = 1, ValueType = "int"}, + StageIds = {Type = 1, ValueType = "int"}, + }, + XTableArchiveMonsterInfo = { + Id = {ValueType = "int"}, + GroupId = {ValueType = "int"}, + Order = {ValueType = "int"}, + Type = {ValueType = "int"}, + Title = {ValueType = "string"}, + Text = {ValueType = "string"}, + Condition = {ValueType = "int"}, + }, + XTableArchiveMonsterSkill = { + Id = {ValueType = "int"}, + GroupId = {ValueType = "int"}, + Order = {ValueType = "int"}, + Title = {ValueType = "string"}, + Text = {ValueType = "string"}, + Condition = {ValueType = "int"}, + }, + XTableArchive = { + Id = {ValueType = "int"}, + Order = {ValueType = "int"}, + Name = {ValueType = "string"}, + UnLockBg = {ValueType = "string"}, + LockBg = {ValueType = "string"}, + SkipId = {ValueType = "int"}, + TagText = {ValueType = "string"}, + ShowTag = {ValueType = "int"}, + }, + XTableArchiveTag = { + Id = {ValueType = "int"}, + Order = {ValueType = "int"}, + Color = {ValueType = "string"}, + Bg = {ValueType = "string"}, + Name = {ValueType = "string"}, + IsNotShow = {ValueType = "int"}, + TagGroupId = {Type = 1, ValueType = "int"}, + }, + XTableMonsterSetting = { + Id = {ValueType = "int"}, + GroupId = {ValueType = "int"}, + Order = {ValueType = "int"}, + Type = {ValueType = "int"}, + Title = {ValueType = "string"}, + Text = {ValueType = "string"}, + Condition = {ValueType = "int"}, + }, + XTableAwarenessSetting = { + Id = {ValueType = "int"}, + SuitId = {ValueType = "int"}, + Order = {ValueType = "int"}, + Type = {ValueType = "int"}, + Title = {ValueType = "string"}, + Text = {ValueType = "string"}, + Condition = {ValueType = "int"}, + }, + XTableWeaponSetting = { + Id = {ValueType = "int"}, + EquipId = {ValueType = "int"}, + Order = {ValueType = "int"}, + Type = {ValueType = "int"}, + Title = {ValueType = "string"}, + Text = {ValueType = "string"}, + Condition = {ValueType = "int"}, + }, + XTablePartnerSetting = { + Id = {ValueType = "int"}, + GroupId = {ValueType = "int"}, + Order = {ValueType = "int"}, + Type = {ValueType = "int"}, + Title = {ValueType = "string"}, + Text = {ValueType = "string"}, + Condition = {ValueType = "int"}, + }, + XTableArchiveWeaponGroup = { + Id = {ValueType = "int"}, + Order = {ValueType = "int"}, + GroupName = {ValueType = "string"}, + CollectionTitle = {Type = 1, ValueType = "string"}, + CollectionContent = {Type = 1, ValueType = "string"}, + CollectNum = {Type = 1, ValueType = "int"}, + IconPath = {Type = 1, ValueType = "string"}, + CgId = {Type = 1, ValueType = "int"}, + }, + XTableArchiveAwarenessGroup = { + Id = {ValueType = "int"}, + Type = {ValueType = "int"}, + Add = {ValueType = "string"}, + IconPath = {ValueType = "string"}, + }, + XTableSpecialActivity = { + Id = {ValueType = "int"}, + TimeId = {ValueType = "int"}, + Condition = {ValueType = "int"}, + SkipId = {ValueType = "int"}, + Bg = {ValueType = "string"}, + }, + XTableRogueLikeActivity = { + Id = {ValueType = "int"}, + ActivityTimeId = {ValueType = "int"}, + FightTimeId = {ValueType = "int"}, + TeamEffectId = {Type = 1, ValueType = "int"}, + ActionPoint = {ValueType = "int"}, + TeamMemberCount = {ValueType = "int"}, + BlackShopId = {ValueType = "int"}, + FightNeedPoint = {ValueType = "int"}, + RobotMax = {ValueType = "int"}, + CharacterLimitType = {ValueType = "int"}, + LimitBuffId = {ValueType = "int"}, + InitActionPoint = {ValueType = "int"}, + InitBuffId = {ValueType = "int"}, + }, + XTableRogueLikeTier = { + Id = {ValueType = "int"}, + Tier = {ValueType = "int"}, + Group = {ValueType = "int"}, + NodeId = {Type = 1, ValueType = "int"}, + FatherNode = {Type = 1, ValueType = "string"}, + }, + XTableRogueLikeTierSection = { + Id = {ValueType = "int"}, + TierType = {ValueType = "int"}, + MinTier = {ValueType = "int"}, + MaxTier = {ValueType = "int"}, + EventGroup = {ValueType = "int"}, + GroupId = {Type = 1, ValueType = "int"}, + }, + XTableRogueLikeNode = { + Id = {ValueType = "int"}, + Type = {ValueType = "int"}, + Param = {Type = 1, ValueType = "int"}, + }, + XTableRogueLikeBox = { + Id = {ValueType = "int"}, + Type = {ValueType = "int"}, + Param = {Type = 1, ValueType = "int"}, + }, + XTableRogueLikePoint = { + Type = {ValueType = "int"}, + Point = {ValueType = "int"}, + }, + XTableRogueLikeBuff = { + Id = {ValueType = "int"}, + Type = {ValueType = "int"}, + CustomType = {ValueType = "int"}, + FightEvent = {ValueType = "int"}, + Percent = {ValueType = "int"}, + ItemId = {ValueType = "int"}, + Discount = {ValueType = "int"}, + IntensifyId = {ValueType = "int"}, + CostItemId = {ValueType = "int"}, + CostItemCount = {ValueType = "int"}, + }, + XTableRogueLikeEvent = { + Id = {ValueType = "int"}, + Type = {ValueType = "int"}, + Group = {ValueType = "int"}, + Param = {Type = 1, ValueType = "int"}, + }, + XTableRogueLikeShop = { + Id = {ValueType = "int"}, + LimitCount = {ValueType = "int"}, + ShopItemId = {Type = 1, ValueType = "int"}, + BuyCount = {Type = 1, ValueType = "int"}, + }, + XTableRogueLikeShopItem = { + Id = {ValueType = "int"}, + Type = {ValueType = "int"}, + Param = {Type = 1, ValueType = "int"}, + ConsumeId = {Type = 1, ValueType = "int"}, + ConsumeNum = {Type = 1, ValueType = "int"}, + }, + XTableRogueLikeRobot = { + Id = {ValueType = "int"}, + }, + XTableRogueLikeSpecialEvent = { + Id = {ValueType = "int"}, + Type = {ValueType = "int"}, + Param = {Type = 1, ValueType = "int"}, + }, + XTableRogueLikeSpecialEventGroup = { + Id = {ValueType = "int"}, + EventId = {Type = 1, ValueType = "int"}, + }, + XTableRogueLikeRecover = { + Id = {ValueType = "int"}, + ActionPoint = {ValueType = "int"}, + HpPercent = {ValueType = "int"}, + CostSupportPoint = {ValueType = "int"}, + RewardId = {ValueType = "int"}, + }, + XTableRogueLikeTeamEffect = { + Id = {ValueType = "int"}, + BuffId = {Type = 1, ValueType = "int"}, + CharacterId = {Type = 1, ValueType = "int"}, + }, + XTableRogueLikeSupportStation = { + Id = {ValueType = "int"}, + Count = {ValueType = "int"}, + NeedPoint = {ValueType = "int"}, + SpecialEvent = {ValueType = "int"}, + }, + XTableRogueLikeActivityDetails = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + FunctionalOpenId = {ValueType = "int"}, + BeginStoryId = {ValueType = "string"}, + }, + XTableRogueLikeBuffDetails = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Description = {ValueType = "string"}, + Icon = {ValueType = "string"}, + BuffType = {ValueType = "int"}, + Priority = {ValueType = "int"}, + }, + XTableRogueLikeNodeDetails = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Description = {ValueType = "string"}, + Icon = {ValueType = "string"}, + Param = {Type = 1, ValueType = "int"}, + }, + XTableRogueLikeTierSectionDetails = { + Id = {ValueType = "int"}, + GroupId = {Type = 1, ValueType = "int"}, + GroupPrefab = {Type = 1, ValueType = "string"}, + }, + XTableRogueLikeSpecialEventDetails = { + Id = {ValueType = "int"}, + Description = {ValueType = "string"}, + Title = {ValueType = "string"}, + }, + XTableRogueLikeSupportStationDetails = { + Id = {ValueType = "int"}, + Title = {ValueType = "string"}, + Description = {ValueType = "string"}, + Icon = {ValueType = "string"}, + }, + XTableRogueLikeSpecialEventGroupDetails = { + Id = {ValueType = "int"}, + GroupItemId = {ValueType = "int"}, + HasLeave = {ValueType = "int"}, + IsEnd = {ValueType = "int"}, + OptionDesc = {Type = 1, ValueType = "string"}, + }, + XTableRogueLikeSpecialEventGroupItem = { + Id = {ValueType = "int"}, + Title = {ValueType = "string"}, + Icon = {ValueType = "string"}, + Description = {ValueType = "string"}, + IsEnd = {ValueType = "int"}, + HasLeave = {ValueType = "int"}, + OptionId = {Type = 1, ValueType = "int"}, + OptionDesc = {Type = 1, ValueType = "string"}, + }, + XTableRogueLikePurgatoryScoreDesDetail = { + Type = {ValueType = "int"}, + Title = {ValueType = "string"}, + Description = {ValueType = "string"}, + }, + XTableImageCell = { + ImageName = {ValueType = "string"}, + PosX = {ValueType = "int"}, + PosY = {ValueType = "int"}, + Url = {ValueType = "string"}, + }, + XTableUiRawImage = { + Key = {ValueType = "string"}, + Url = {ValueType = "string"}, + }, + XTableWorld = { + Id = {ValueType = "int"}, + WorldName = {ValueType = "string"}, + MainFightStageId = {ValueType = "int"}, + }, + XTableWorldSubFight = { + SubFightStageId = {ValueType = "int"}, + WorldId = {ValueType = "int"}, + }, + XTableScoreTitle = { + Id = {ValueType = "int"}, + Type = {ValueType = "int"}, + ScreenType = {ValueType = "int"}, + ActivityId = {ValueType = "int"}, + TimeId = {ValueType = "int"}, + ExtraParams = {Type = 1, ValueType = "int"}, + InitQuality = {ValueType = "int"}, + QualityConditions = {Type = 1, ValueType = "int"}, + Qualities = {Type = 1, ValueType = "int"}, + Condition = {ValueType = "int"}, + Name = {ValueType = "string"}, + MainDesc = {ValueType = "string"}, + WorldDesc = {ValueType = "string"}, + Hint = {Type = 1, ValueType = "string"}, + ExpandInfoId = {Type = 1, ValueType = "int"}, + GetDesc = {ValueType = "string"}, + Priority = {ValueType = "int"}, + ShowType = {ValueType = "int"}, + ShowScore = {ValueType = "int"}, + ShowQualityUpTip = {ValueType = "int"}, + IsNotShowGetTip = {ValueType = "int"}, + Medal3D = {ValueType = "string"}, + MedalImg = {ValueType = "string"}, + MedalIcon = {ValueType = "string"}, + ScoreParams = {Type = 1, ValueType = "string"}, + GroupId = {ValueType = "int"}, + GroupLv = {ValueType = "int"}, + PrefabPath = {ValueType = "string"}, + }, + XTableScoreTitleItem = { + Id = {ValueType = "int"}, + TitleId = {ValueType = "int"}, + }, + XTableScoreTitleExpandInfo = { + Id = {ValueType = "int"}, + StrServerKey = {ValueType = "string"}, + Desc = {ValueType = "string"}, + EmptyDesc = {ValueType = "string"}, + }, + XTableScoreScreenTag = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + }, + XTableScoreTitleActivityExtra = { + Id = {ValueType = "int"}, + ActivityId = {Type = 1, ValueType = "int"}, + }, + XTableArchiveStoryGroup = { + Id = {ValueType = "int"}, + Order = {ValueType = "int"}, + Name = {ValueType = "string"}, + }, + XTableArchiveStoryChapter = { + Id = {ValueType = "int"}, + GroupId = {ValueType = "int"}, + Order = {ValueType = "int"}, + Name = {ValueType = "string"}, + Bg = {ValueType = "string"}, + LockBg = {ValueType = "string"}, + BgWidth = {ValueType = "int"}, + BgHigh = {ValueType = "int"}, + BgOffSetX = {ValueType = "int"}, + BgOffSetY = {ValueType = "int"}, + }, + XTableArchiveStoryDetail = { + Id = {ValueType = "int"}, + ChapterId = {ValueType = "int"}, + Order = {ValueType = "int"}, + Name = {ValueType = "string"}, + SubName = {ValueType = "string"}, + Icon = {ValueType = "string"}, + DescTitle = {ValueType = "string"}, + Desc = {ValueType = "string"}, + Condition = {ValueType = "int"}, + UnLockTime = {ValueType = "string"}, + StoryId = {Type = 1, ValueType = "string"}, + }, + XTableSameNpcGroup = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + NpcId = {Type = 1, ValueType = "int"}, + }, + XTableDrawAimProbability = { + Id = {ValueType = "int"}, + Priority = {ValueType = "int"}, + UpProbability = {ValueType = "string"}, + TagImg = {ValueType = "string"}, + }, + XTableAssignChapter = { + ChapterId = {ValueType = "int"}, + ChapterName = {ValueType = "string"}, + ChapterEn = {ValueType = "string"}, + OrderId = {ValueType = "string"}, + Cover = {ValueType = "string"}, + SkillPlusId = {ValueType = "int"}, + AssignCondition = {Type = 1, ValueType = "int"}, + SelectCharCondition = {Type = 1, ValueType = "int"}, + GroupId = {Type = 1, ValueType = "int"}, + RewardId = {Type = 1, ValueType = "int"}, + }, + XTableAssignGroup = { + GroupId = {ValueType = "int"}, + PreGroupId = {ValueType = "int"}, + ChallengeNum = {ValueType = "int"}, + BaseStage = {ValueType = "int"}, + StageId = {Type = 1, ValueType = "int"}, + TeamInfoId = {Type = 1, ValueType = "int"}, + GroupOrderId = {ValueType = "string"}, + Name = {ValueType = "string"}, + Icon = {ValueType = "string"}, + }, + XTableAssignTeamInfo = { + Id = {ValueType = "int"}, + RequireAbility = {ValueType = "int"}, + NeedCharacter = {ValueType = "int"}, + Desc = {ValueType = "string"}, + }, + XTableCharacterSkillTypeInfo = { + Type = {ValueType = "int"}, + Name = {ValueType = "string"}, + }, + XTableMarketingActivity = { + Id = {ValueType = "int"}, + Priority = {ValueType = "int"}, + Type = {ValueType = "int"}, + Name = {ValueType = "string"}, + BeginTimeStr = {ValueType = "string"}, + EndTimeStr = {ValueType = "string"}, + Icon = {ValueType = "string"}, + SkipId = {ValueType = "int"}, + }, + XTablePicComposition = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Img = {ValueType = "string"}, + HelpId = {ValueType = "int"}, + }, + XTableCompositionCharacter = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Desc = {ValueType = "string"}, + Icon = {ValueType = "string"}, + }, + XTableRegressionActivity = { + Id = {ValueType = "int"}, + TimeId = {ValueType = "int"}, + Type = {ValueType = "int"}, + Condition = {ValueType = "int"}, + Condition2 = {ValueType = "int"}, + ContinueDays = {ValueType = "int"}, + ScheduleItemId = {ValueType = "int"}, + StoryId = {ValueType = "string"}, + HelpId = {ValueType = "int"}, + Param = {Type = 1, ValueType = "int"}, + }, + XTableRegressionTask = { + Id = {ValueType = "int"}, + TaskId = {Type = 1, ValueType = "int"}, + DailyTaskId = {Type = 1, ValueType = "int"}, + WeeklyTaskId = {Type = 1, ValueType = "int"}, + }, + XTableRegressionScheduleReward = { + Id = {ValueType = "int"}, + Group = {ValueType = "int"}, + Schedule = {ValueType = "int"}, + RewardId = {ValueType = "int"}, + }, + XTableRegressionCondition = { + Id = {ValueType = "int"}, + Level = {ValueType = "int"}, + FirstOfflineTime = {ValueType = "int"}, + SecondOfflineTime = {ValueType = "int"}, + }, + XTableRegressionInvite = { + Id = {ValueType = "int"}, + InvitePeopleMax = {ValueType = "int"}, + CodeLetter = {ValueType = "string"}, + InviteRewardId = {Type = 1, ValueType = "int"}, + UseCodeReward = {Type = 1, ValueType = "int"}, + }, + XTableRegressionInviteReward = { + Id = {ValueType = "int"}, + People = {ValueType = "int"}, + RewardId = {ValueType = "int"}, + }, + XTableNpcUiFightRes = { + Id = {ValueType = "int"}, + HeadImageName = {ValueType = "string"}, + OnlinePortrait = {ValueType = "string"}, + Model = {Type = 1, ValueType = "string"}, + EnergyBar = {Type = 1, ValueType = "string"}, + EnergyGroupBar = {Type = 1, ValueType = "string"}, + SPPrefab = {Type = 1, ValueType = "string"}, + AttackIconImage = {ValueType = "string"}, + DodgeIconImage = {ValueType = "string"}, + ExSkillIconImage = {ValueType = "string"}, + PartnerSkillIconImage0 = {ValueType = "string"}, + PartnerSkillIconImage1 = {ValueType = "string"}, + PartnerSPPrefab = {ValueType = "string"}, + AttackEffectPrefab = {ValueType = "string"}, + }, + XTableProductCommentActivity = { + Id = {ValueType = "int"}, + BeginTimeStr = {ValueType = "string"}, + UploadBeginTimeStr = {ValueType = "string"}, + UploadEndTimeStr = {ValueType = "string"}, + EndTimeStr = {ValueType = "string"}, + ProductionId = {ValueType = "int"}, + PraiseItemId = {ValueType = "int"}, + PraiseConsume = {ValueType = "int"}, + ScheduleItemId = {ValueType = "int"}, + ContentMaxNum = {ValueType = "int"}, + ContentMaxLength = {ValueType = "int"}, + RankNum = {ValueType = "int"}, + RankRewardGroup = {ValueType = "int"}, + LimitTaskId = {ValueType = "int"}, + }, + XTableProductCommentRankReward = { + Id = {ValueType = "int"}, + GroupId = {ValueType = "int"}, + MinRank = {ValueType = "int"}, + MaxRank = {ValueType = "int"}, + RewardId = {ValueType = "int"}, + }, + XTableProductCommentScheduleReward = { + Id = {ValueType = "int"}, + Schedule = {ValueType = "int"}, + RewardId = {ValueType = "int"}, + }, + XTablePathPosition = { + Id = {ValueType = "int"}, + X = {ValueType = "int"}, + Y = {ValueType = "int"}, + Area = {Type = 1, ValueType = "int"}, + }, + XTablePathLink = { + PathPositionA = {ValueType = "int"}, + PathPositionB = {ValueType = "int"}, + Cost = {ValueType = "int"}, + }, + XTableWindowsInlay = { + Id = {ValueType = "int"}, + Priority = {ValueType = "int"}, + Title = {ValueType = "string"}, + Desc = {ValueType = "string"}, + BeginTimeStr = {ValueType = "string"}, + EndTimeStr = {ValueType = "string"}, + Url = {ValueType = "string"}, + Type = {ValueType = "int"}, + }, + XTableMonsterNpcData = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + ModelId = {ValueType = "string"}, + }, + XTablePlatformShare = { + Id = {ValueType = "int"}, + ShareType = {ValueType = "int"}, + ShareParam = {Type = 1, ValueType = "string"}, + PlatformType = {Type = 1, ValueType = "int"}, + PlatformIcon = {Type = 1, ValueType = "string"}, + PlatformShowedText = {Type = 1, ValueType = "string"}, + }, + XTablePlatformShareOpen = { + Id = {ValueType = "string"}, + IsOpen = {ValueType = "bool"}, + }, + XTableMusicPlayerAlbum = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Composer = {ValueType = "string"}, + Cover = {ValueType = "string"}, + Bg = {ValueType = "string"}, + CueId = {ValueType = "int"}, + Priority = {ValueType = "int"}, + }, + XTableMainLineExploreGroup = { + Id = {ValueType = "int"}, + GroupId = {ValueType = "int"}, + StageIndex = {ValueType = "int"}, + PreShowIndex = {Type = 1, ValueType = "int"}, + }, + XTableExtraExploreGroup = { + Id = {ValueType = "int"}, + GroupId = {ValueType = "int"}, + StageIndex = {ValueType = "int"}, + PreShowIndex = {Type = 1, ValueType = "int"}, + }, + XTableRewardConfirm = { + Id = {ValueType = "int"}, + Priority = {ValueType = "int"}, + Title = {ValueType = "string"}, + Content = {ValueType = "string"}, + }, + XTableArenaOnlineChapter = { + Id = {ValueType = "int"}, + Type = {ValueType = "int"}, + MaxLevel = {ValueType = "int"}, + MinLevel = {ValueType = "int"}, + Name = {ValueType = "string"}, + Title = {ValueType = "string"}, + Icon = {ValueType = "string"}, + PrefabPath = {ValueType = "string"}, + StoryId = {ValueType = "string"}, + SectionId = {Type = 1, ValueType = "int"}, + }, + XTableArenaOnlineSection = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + LeftTimeDesc = {ValueType = "string"}, + PrefabPath = {ValueType = "string"}, + OpenDays = {Type = 1, ValueType = "int"}, + StageGroupId = {Type = 1, ValueType = "int"}, + }, + XTableArenaOnlineStageGroup = { + Id = {ValueType = "int"}, + RequireStar = {ValueType = "int"}, + StageIds = {Type = 1, ValueType = "int"}, + PrefabPath = {ValueType = "string"}, + Icon = {ValueType = "string"}, + }, + XTableArenaOnlineActiveBuff = { + Id = {ValueType = "int"}, + Quality = {ValueType = "int"}, + QualityCount = {ValueType = "int"}, + AffectQuality = {ValueType = "int"}, + FightEffectId = {ValueType = "int"}, + OnIcon = {ValueType = "string"}, + OffIcon = {ValueType = "string"}, + ActiveTip = {ValueType = "string"}, + Title = {ValueType = "string"}, + Desc = {ValueType = "string"}, + }, + XTableArenaOnlineStage = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Sort = {ValueType = "int"}, + BgIcon = {ValueType = "string"}, + NameIcon = {ValueType = "string"}, + StageId = {ValueType = "string"}, + EnduranceCost = {ValueType = "int"}, + SingleSwitch = {ValueType = "bool"}, + ConditionDesc = {ValueType = "string"}, + ActiveBuffId = {ValueType = "int"}, + BottomCount = {ValueType = "int"}, + ShowDropId = {ValueType = "int"}, + ShowBottomId = {ValueType = "int"}, + Difficulty = {Type = 1, ValueType = "int"}, + SingleDiff = {Type = 1, ValueType = "int"}, + SkillTitle = {Type = 1, ValueType = "string"}, + SkillDesc = {Type = 1, ValueType = "string"}, + EventId = {Type = 1, ValueType = "int"}, + }, + XTableWeaponFashion = { + Id = {ValueType = "int"}, + EquipType = {ValueType = "int"}, + ItemId = {ValueType = "int"}, + ItemCount = {ValueType = "int"}, + ItemCountByHour = {ValueType = "int"}, + WeaponSkillId = {ValueType = "int"}, + EffectTimeStr = {ValueType = "string"}, + ExpireTimeStr = {ValueType = "string"}, + }, + XTableFightWords = { + Group = {ValueType = "int"}, + Text = {ValueType = "string"}, + Duration = {ValueType = "float"}, + CueId = {ValueType = "int"}, + WordsIndex = {ValueType = "int"}, + }, + XTableWeaponFashionRes = { + Id = {ValueType = "int"}, + Quality = {ValueType = "int"}, + Priority = {ValueType = "int"}, + Name = {ValueType = "string"}, + Description = {ValueType = "string"}, + WorldDescription = {ValueType = "string"}, + Icon = {ValueType = "string"}, + BigIcon = {ValueType = "string"}, + SkipIdParams = {Type = 1, ValueType = "int"}, + ModelTransId = {Type = 1, ValueType = "int"}, + ResonanceModelTransId1 = {Type = 1, ValueType = "int"}, + ResonanceModelTransId2 = {Type = 1, ValueType = "int"}, + ResonanceModelTransId3 = {Type = 1, ValueType = "int"}, + ShopIcon = {ValueType = "string"}, + }, + XTableHeadPortraitHide = { + Id = {ValueType = "int"}, + BeginTimeStr = {ValueType = "string"}, + EndTimeStr = {ValueType = "string"}, + }, + XTableMainLineExploreItem = { + Id = {ValueType = "int"}, + MainChapterId = {ValueType = "int"}, + Icon = {ValueType = "string"}, + Name = {ValueType = "string"}, + Hint = {ValueType = "string"}, + Desc = {ValueType = "string"}, + }, + XTableExtraExploreItem = { + Id = {ValueType = "int"}, + MainChapterId = {ValueType = "int"}, + Icon = {ValueType = "string"}, + Name = {ValueType = "string"}, + Hint = {ValueType = "string"}, + Desc = {ValueType = "string"}, + }, + XTableUnionKillActivity = { + Id = {ValueType = "int"}, + TimeId = {ValueType = "int"}, + RankTimeId = {ValueType = "int"}, + PraiseBaseRank = {ValueType = "int"}, + TaskLimitId = {Type = 1, ValueType = "int"}, + SectionId = {Type = 1, ValueType = "int"}, + }, + XTableUnionKillSection = { + Id = {ValueType = "int"}, + TimeId = {ValueType = "int"}, + BoxRewardId = {ValueType = "int"}, + KillBossCount = {ValueType = "int"}, + UnlockBossStageLimit = {ValueType = "int"}, + EventStageLimit = {ValueType = "int"}, + SingleFightTime = {ValueType = "int"}, + BaseRankNum = {ValueType = "int"}, + BossStage = {ValueType = "int"}, + BossId = {ValueType = "int"}, + BossTotalHp = {ValueType = "int"}, + TrialStage = {ValueType = "int"}, + TrialUseShare = {ValueType = "int"}, + EventStageId = {Type = 1, ValueType = "int"}, + }, + XTableUnionKillEventStage = { + Id = {ValueType = "int"}, + EventId = {Type = 1, ValueType = "int"}, + }, + XTableUnionKillWeather = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + EventId = {Type = 1, ValueType = "int"}, + Weight = {ValueType = "int"}, + }, + XTableUnionKillWeatherChange = { + Id = {ValueType = "int"}, + Hour = {Type = 1, ValueType = "int"}, + }, + XTableUnionKillScoreRule = { + Id = {ValueType = "int"}, + DamageMaxScore = {ValueType = "int"}, + TimeMaxScore = {ValueType = "int"}, + HpMaxScore = {ValueType = "int"}, + BossLoseHp = {ValueType = "float"}, + BossLoseHpScore = {ValueType = "int"}, + BossTotalHp = {ValueType = "int"}, + LeftTime = {ValueType = "int"}, + LeftTimeScore = {ValueType = "int"}, + CharLeftHp = {ValueType = "float"}, + CharLeftHpScore = {ValueType = "int"}, + }, + XTableUnionKillRankReward = { + Id = {ValueType = "int"}, + LevelId = {ValueType = "int"}, + MinRank = {ValueType = "float"}, + MaxRank = {ValueType = "float"}, + MailId = {ValueType = "int"}, + RankIcon = {ValueType = "string"}, + }, + XTableUnionKillRankLevel = { + Id = {ValueType = "int"}, + MinLevel = {ValueType = "int"}, + MaxLevel = {ValueType = "int"}, + Name = {ValueType = "string"}, + Icon = {ValueType = "string"}, + }, + XTableUnionKillActivityDetails = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Icon = {ValueType = "string"}, + }, + XTableUnionKillWeatherDetails = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Description = {ValueType = "string"}, + Icon = {ValueType = "string"}, + }, + XTableUnionKillSectionDetails = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Icon = {ValueType = "string"}, + BossIcon = {ValueType = "string"}, + TrialIcon = {ValueType = "string"}, + BossBuffName = {ValueType = "string"}, + BossBuffText = {ValueType = "string"}, + MainPrefabName = {ValueType = "string"}, + ItemPrefabName = {ValueType = "string"}, + SectionIcon = {Type = 1, ValueType = "string"}, + }, + XTableUnionKillEventDetails = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Description = {ValueType = "string"}, + Icon = {ValueType = "string"}, + Level = {ValueType = "int"}, + }, + XTableCollectionLevel = { + Id = {ValueType = "int"}, + CurLevel = {ValueType = "int"}, + MaxLevel = {ValueType = "int"}, + Icon = {ValueType = "string"}, + }, + XTableShopShowType = { + Id = {ValueType = "int"}, + ShowType = {ValueType = "int"}, + }, + XTableEliminateGame = { + Id = {ValueType = "int"}, + TimeId = {ValueType = "int"}, + LineCount = {ValueType = "int"}, + HelpId = {ValueType = "int"}, + FlipItemId = {ValueType = "int"}, + FlipItemCount = {ValueType = "int"}, + MoveItemId = {ValueType = "int"}, + MoveItemCount = {ValueType = "int"}, + EliminateCount = {ValueType = "int"}, + Grids = {Type = 1, ValueType = "int"}, + }, + XTableEliminateGrid = { + Id = {ValueType = "int"}, + Type = {ValueType = "int"}, + DefaultState = {ValueType = "int"}, + }, + XTableEliminateGridType = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Type = {ValueType = "int"}, + TypePic = {ValueType = "string"}, + }, + XTableEliminateReward = { + Id = {ValueType = "int"}, + GameId = {ValueType = "int"}, + GridType = {ValueType = "int"}, + GridCount = {ValueType = "int"}, + RewardId = {ValueType = "int"}, + }, + XTableSpecialTrainStarReward = { + Id = {ValueType = "int"}, + RequireStar = {ValueType = "int"}, + RewardId = {ValueType = "int"}, + }, + XTableSpecialTrainChapter = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + SecondName = {ValueType = "string"}, + PrefixName = {ValueType = "string"}, + BgIcon = {ValueType = "string"}, + TabImage = {ValueType = "string"}, + RewardType = {ValueType = "int"}, + HelpId = {Type = 1, ValueType = "int"}, + RewardParams = {Type = 1, ValueType = "int"}, + StageIds = {Type = 1, ValueType = "int"}, + DailyOpentime = {Type = 1, ValueType = "string"}, + }, + XTableSpecialTrainActivity = { + Id = {ValueType = "int"}, + TimeId = {ValueType = "int"}, + Type = {ValueType = "int"}, + Name = {ValueType = "string"}, + Icon = {ValueType = "string"}, + ChapterIds = {Type = 1, ValueType = "int"}, + EliminateGameId = {ValueType = "int"}, + PointItemId = {ValueType = "int"}, + PointRewardId = {Type = 1, ValueType = "int"}, + }, + XTableSpecialTrainPointReward = { + Id = {ValueType = "int"}, + NeedPoint = {ValueType = "int"}, + RewardId = {ValueType = "int"}, + ShowItem = {ValueType = "int"}, + ShowItemNum = {ValueType = "int"}, + }, + XTableSpecialTrainStage = { + Id = {ValueType = "int"}, + Type = {ValueType = "int"}, + }, + XTableMonsterModelTrans = { + Id = {ValueType = "int"}, + NpcId = {ValueType = "int"}, + NpcState = {ValueType = "int"}, + StateText = {ValueType = "string"}, + StandAnime = {ValueType = "string"}, + HideNodeName = {Type = 1, ValueType = "string"}, + }, + XTableMonsterEffect = { + Id = {ValueType = "int"}, + NpcId = {ValueType = "int"}, + NpcState = {ValueType = "int"}, + EffectNodeName = {ValueType = "string"}, + EffectPath = {ValueType = "string"}, + }, + XTableGuildTalent = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + GuildLevel = {ValueType = "int"}, + CostPoint = {Type = 1, ValueType = "int"}, + Parent = {Type = 1, ValueType = "int"}, + BuffId = {ValueType = "int"}, + }, + XTableGuildTalentDetails = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + IndexInMap = {ValueType = "int"}, + TalentIcon = {ValueType = "string"}, + PrefabPath = {ValueType = "string"}, + Descriptions = {Type = 1, ValueType = "string"}, + }, + XTableGuildPresent = { + Id = {ValueType = "int"}, + PresentId = {ValueType = "int"}, + Popularity = {ValueType = "int"}, + GuildCoin = {ValueType = "int"}, + }, + XTableGuildBossData = { + Id = {ValueType = "int"}, + Desc = {ValueType = "string"}, + StageType = {ValueType = "int"}, + StageId = {Type = 1, ValueType = "string"}, + Robot = {Type = 1, ValueType = "int"}, + RobotCount = {ValueType = "int"}, + StageCount = {ValueType = "int"}, + }, + XTableGuildBossHpReward = { + Id = {ValueType = "int"}, + HpPercent = {ValueType = "int"}, + RewardId = {ValueType = "int"}, + NewRewardId = {ValueType = "int"}, + }, + XTableGuildBossScoreReward = { + Id = {ValueType = "int"}, + Score = {ValueType = "int"}, + RewardId = {ValueType = "int"}, + NewRewardId = {ValueType = "int"}, + }, + XTableGuildBossStageEffect = { + StageId = {ValueType = "int"}, + EffectId = {ValueType = "int"}, + }, + XTableGuildBossStageRobot = { + Id = {ValueType = "int"}, + RobotId = {Type = 1, ValueType = "int"}, + }, + XTableGuildBossScoreRule = { + Id = {ValueType = "int"}, + BaseScore = {ValueType = "int"}, + DamageScore = {ValueType = "int"}, + HpMaxScore = {ValueType = "int"}, + CharLeftHp = {ValueType = "float"}, + CharLeftHpScore = {ValueType = "int"}, + }, + XTableGuildBossRankReward = { + Id = {ValueType = "int"}, + Percent = {ValueType = "int"}, + RewardId = {ValueType = "int"}, + MailId = {ValueType = "int"}, + }, + XTableInfestorExploreGrid = { + Id = {ValueType = "int"}, + GroupId = {ValueType = "int"}, + FrontId = {Type = 1, ValueType = "int"}, + }, + XTableInfestorExploreNode = { + Id = {ValueType = "int"}, + GroupId = {ValueType = "int"}, + Weight = {ValueType = "int"}, + Type = {ValueType = "int"}, + ResType = {ValueType = "int"}, + RecHpPer = {ValueType = "int"}, + FightStageId = {ValueType = "int"}, + ShowRewardId = {ValueType = "int"}, + RewardPoolId = {ValueType = "int"}, + RewardCount = {ValueType = "int"}, + EventPoolId = {ValueType = "int"}, + SubHpProbability = {ValueType = "int"}, + SubHpMinPer = {ValueType = "int"}, + SubHpMaxPer = {ValueType = "int"}, + RewardMoneyCount = {ValueType = "int"}, + UseActionPoint = {ValueType = "int"}, + }, + XTableInfestorExploreReward = { + Id = {ValueType = "int"}, + PoolId = {ValueType = "int"}, + CoreId = {ValueType = "int"}, + CoreLevel = {ValueType = "int"}, + Weight = {ValueType = "int"}, + }, + XTableInfestorExploreEvent = { + Id = {ValueType = "int"}, + PoolId = {ValueType = "int"}, + Weight = {ValueType = "int"}, + Type = {ValueType = "int"}, + Params = {Type = 1, ValueType = "int"}, + Description = {ValueType = "string"}, + Name = {ValueType = "string"}, + Icon = {ValueType = "string"}, + }, + XTableInfestorExploreLevelGroup = { + Id = {ValueType = "int"}, + MinLevel = {ValueType = "int"}, + MaxLevel = {ValueType = "int"}, + }, + XTableInfestorExploreDiff = { + Id = {ValueType = "int"}, + GroupId = {ValueType = "int"}, + Diff = {ValueType = "int"}, + Icon = {ValueType = "string"}, + Name = {ValueType = "string"}, + JoinNum = {ValueType = "int"}, + UpNum = {ValueType = "int"}, + DownNum = {ValueType = "int"}, + UpMailId = {ValueType = "int"}, + KeepMailId = {ValueType = "int"}, + DownMailId = {ValueType = "int"}, + ShowScoreGap = {ValueType = "int"}, + ShowScoreLimit = {ValueType = "int"}, + }, + XTableInfestorExploreCore = { + Id = {ValueType = "int"}, + Quality = {ValueType = "int"}, + MaxLevel = {ValueType = "int"}, + Name = {ValueType = "string"}, + Icon = {ValueType = "string"}, + }, + XTableInfestorExploreCoreLevelEffect = { + Id = {ValueType = "int"}, + CoreId = {ValueType = "int"}, + CoreLevel = {ValueType = "int"}, + DecomposeMoney = {ValueType = "int"}, + Description = {ValueType = "string"}, + BuffId = {Type = 1, ValueType = "int"}, + }, + XTableInfestorExploreShopGoods = { + Id = {ValueType = "int"}, + ShopId = {ValueType = "int"}, + Weight = {ValueType = "int"}, + CoreId = {ValueType = "int"}, + CoreLevel = {ValueType = "int"}, + Cost = {ValueType = "int"}, + LimitCount = {ValueType = "int"}, + }, + XTableInfestorExploreShop = { + Id = {ValueType = "int"}, + GoodsCount = {ValueType = "int"}, + RefreshCost = {ValueType = "int"}, + }, + XTableInfestorExploreBuff = { + Id = {ValueType = "int"}, + PoolId = {ValueType = "int"}, + Weight = {ValueType = "int"}, + BuffId = {ValueType = "int"}, + }, + XTableInfestorFightRewardCost = { + Times = {ValueType = "int"}, + Cost = {ValueType = "int"}, + }, + XTableInfestorActivity = { + Id = {ValueType = "int"}, + ExploreChapterId = {Type = 1, ValueType = "int"}, + BossStageId = {Type = 1, ValueType = "int"}, + }, + XTableInfestorFightEvent = { + Id = {ValueType = "int"}, + ExploreFightEventId = {Type = 1, ValueType = "int"}, + BossFightEventId = {Type = 1, ValueType = "int"}, + }, + XTableInfestorEventGoods = { + EventId = {ValueType = "int"}, + Cost = {ValueType = "int"}, + }, + XTableInfestorBossScoreRule = { + StageId = {ValueType = "int"}, + TotalMaxScore = {ValueType = "int"}, + DamageFactor = {ValueType = "float"}, + DamageMaxScore = {ValueType = "int"}, + HpFactor = {ValueType = "float"}, + HpMaxScore = {ValueType = "int"}, + UseTimeFactor = {ValueType = "float"}, + UseTimeMaxScore = {ValueType = "int"}, + }, + XTableInfestorStageDiffControl = { + Id = {ValueType = "int"}, + StageId = {ValueType = "int"}, + GroupId = {ValueType = "int"}, + Diff = {ValueType = "int"}, + MonsterLevel = {Type = 1, ValueType = "int"}, + }, + XTableInfestorOutPostDesPool = { + Id = {ValueType = "int"}, + PoolId = {ValueType = "int"}, + Description = {ValueType = "string"}, + }, + XTableInfestorOutPostDes = { + Id = {ValueType = "int"}, + Key = {ValueType = "string"}, + PoolId = {Type = 1, ValueType = "int"}, + }, + XTableArchiveStoryNpc = { + Id = {ValueType = "int"}, + Order = {ValueType = "int"}, + Name = {ValueType = "string"}, + PicSmall = {ValueType = "string"}, + PicBig = {ValueType = "string"}, + UnLockTime = {ValueType = "string"}, + Condition = {ValueType = "int"}, + }, + XTableArchiveStoryNpcSetting = { + Id = {ValueType = "int"}, + GroupId = {ValueType = "int"}, + Order = {ValueType = "int"}, + Type = {ValueType = "int"}, + Title = {ValueType = "string"}, + Text = {ValueType = "string"}, + Condition = {ValueType = "int"}, + UnLockTime = {ValueType = "string"}, + }, + XTableCharacterUiEffect = { + Id = {ValueType = "int"}, + FashionId = {ValueType = "int"}, + ActionId = {ValueType = "string"}, + EffectRootName = {ValueType = "string"}, + EffectPath = {ValueType = "string"}, + }, + XTableArchiveCGGroup = { + Id = {ValueType = "int"}, + Order = {ValueType = "int"}, + Name = {ValueType = "string"}, + }, + XTableArchiveCGDetail = { + Id = {ValueType = "int"}, + GroupId = {ValueType = "int"}, + Order = {ValueType = "int"}, + Name = {ValueType = "string"}, + Desc = {ValueType = "string"}, + Author = {ValueType = "string"}, + Bg = {ValueType = "string"}, + SpineBg = {ValueType = "string"}, + LockBg = {ValueType = "string"}, + Condition = {ValueType = "int"}, + IsShowRedPoint = {ValueType = "int"}, + UnLockTime = {ValueType = "string"}, + BgWidth = {ValueType = "int"}, + BgHigh = {ValueType = "int"}, + BgOffSetX = {ValueType = "int"}, + BgOffSetY = {ValueType = "int"}, + }, + XTableArchiveCommunication = { + Id = {ValueType = "int"}, + GroupId = {ValueType = "int"}, + CommunicationId = {ValueType = "int"}, + CommunicationType = {ValueType = "int"}, + CommunicationIcon = {ValueType = "string"}, + Name = {ValueType = "string"}, + Condition = {ValueType = "int"}, + Order = {ValueType = "int"}, + BtnContent = {ValueType = "string"}, + UnLockTime = {ValueType = "string"}, + NpcName = {ValueType = "string"}, + NpcHandIcon = {ValueType = "string"}, + UiType = {ValueType = "int"}, + ContentsGroupId = {ValueType = "int"}, + }, + XTableArchiveMail = { + Id = {ValueType = "int"}, + GroupId = {ValueType = "int"}, + Condition = {ValueType = "int"}, + UnLockTime = {ValueType = "string"}, + Order = {ValueType = "int"}, + Title = {ValueType = "string"}, + SendName = {ValueType = "string"}, + Content = {ValueType = "string"}, + NpcHandIcon = {ValueType = "string"}, + }, + XTableArchiveEventDateGroup = { + Id = {ValueType = "int"}, + Order = {ValueType = "int"}, + Name = {ValueType = "string"}, + GroupType = {ValueType = "int"}, + }, + XTableInfestorExploreSection = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + }, + XTableInfestorExploreChapter = { + Id = {ValueType = "int"}, + PreChapterId = {ValueType = "int"}, + MapId = {ValueType = "int"}, + ShopId = {ValueType = "int"}, + TeamType = {ValueType = "int"}, + CharacterLimitType = {ValueType = "int"}, + LimitBuffId = {ValueType = "int"}, + Name = {ValueType = "string"}, + Description = {ValueType = "string"}, + Bg = {ValueType = "string"}, + Icon = {ValueType = "string"}, + Prefab = {ValueType = "string"}, + }, + XTableInfestorExploreFog = { + Id = {ValueType = "int"}, + Type = {ValueType = "int"}, + Depth = {ValueType = "int"}, + }, + XTableInfestorGroup = { + Id = {ValueType = "int"}, + MinLevel = {ValueType = "int"}, + MaxLevel = {ValueType = "int"}, + }, + XTableInfestorNodeType = { + Type = {ValueType = "int"}, + Icon = {ValueType = "string"}, + StageBg = {ValueType = "string"}, + }, + XTableInfestorEventPoolRes = { + PoolId = {ValueType = "int"}, + Name = {ValueType = "string"}, + Description = {ValueType = "string"}, + BtnName = {ValueType = "string"}, + EventId1 = {Type = 1, ValueType = "int"}, + EventId2 = {Type = 1, ValueType = "int"}, + EventId3 = {Type = 1, ValueType = "int"}, + }, + XTableInfestorBuffsRes = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Description = {ValueType = "string"}, + Icon = {ValueType = "string"}, + }, + XTableInfestorSupplyRewardRes = { + Id = {ValueType = "int"}, + Description = {ValueType = "string"}, + }, + XTableInfestorEventType = { + Type = {ValueType = "int"}, + Description = {ValueType = "string"}, + DescriptionRevert = {ValueType = "string"}, + DescriptionEmpty = {ValueType = "string"}, + }, + XTableInfestorStatus = { + Day = {Type = 1, ValueType = "int"}, + }, + XTableTimeLimitCtrlConfig = { + Id = {ValueType = "int"}, + StartTimeStr = {ValueType = "string"}, + EndTimeStr = {ValueType = "string"}, + Desc = {ValueType = "string"}, + }, + XTableDrawTypeChange = { + MainGroupId = {ValueType = "int"}, + MainTypeName = {ValueType = "string"}, + SubGroupId = {Type = 1, ValueType = "int"}, + SubTypeName = {Type = 1, ValueType = "string"}, + }, + XTableGuildBossStageInfo = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Code = {ValueType = "string"}, + BackGround = {ValueType = "string"}, + Icon = {ValueType = "string"}, + DetailIcon = {ValueType = "string"}, + BuffId = {ValueType = "int"}, + Limit = {ValueType = "string"}, + }, + XTableGuildBossLevel = { + Level = {ValueType = "int"}, + Name = {ValueType = "string"}, + BossHp = {ValueType = "int"}, + UnlockScore = {ValueType = "int"}, + AdditionPercent = {ValueType = "int"}, + }, + XTableGuildBossBuff = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Dis = {ValueType = "string"}, + }, + XTableArchiveAwarenessGroupType = { + GroupId = {ValueType = "int"}, + Order = {ValueType = "int"}, + GroupName = {ValueType = "string"}, + }, + XTableSpecialCollectionLevel = { + Index = {ValueType = "int"}, + Id = {ValueType = "int"}, + Score = {ValueType = "int"}, + Level = {ValueType = "int"}, + }, + XTableChallengeExtraTime = { + Id = {ValueType = "int"}, + DamageType = {ValueType = "int"}, + MaxDamage = {ValueType = "int"}, + Ruling = {ValueType = "int"}, + DamageIntervals = {Type = 1, ValueType = "int"}, + TimeIntervals = {Type = 1, ValueType = "int"}, + }, + XTableDamageTypeTip = { + Id = {ValueType = "int"}, + DamageTypeTip = {ValueType = "string"}, + IconPath = {ValueType = "string"}, + }, + XTableFubenStageCharacterLimit = { + Id = {ValueType = "int"}, + BuffId = {Type = 1, ValueType = "int"}, + }, + XTableWorldBossActivity = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + TimeId = {ValueType = "int"}, + BeginTimeStr = {ValueType = "string"}, + EndTimeStr = {ValueType = "string"}, + AttributeAreaId = {Type = 1, ValueType = "int"}, + BossAreaId = {Type = 1, ValueType = "int"}, + SpecialSaleId = {Type = 1, ValueType = "int"}, + ActionPointId = {ValueType = "int"}, + MaxActionPoint = {ValueType = "int"}, + ShopCurrencyId = {ValueType = "int"}, + TitleId = {ValueType = "int"}, + StartStoryId = {ValueType = "string"}, + Bg = {ValueType = "string"}, + }, + XTableWorldBossAttributeArea = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + EnglishName = {ValueType = "string"}, + MaxChallengeCount = {ValueType = "int"}, + FinishReward = {ValueType = "int"}, + BuffId = {Type = 1, ValueType = "int"}, + StageId = {Type = 1, ValueType = "int"}, + SystemReportId = {Type = 1, ValueType = "int"}, + PlayerReportId = {Type = 1, ValueType = "int"}, + StartStoryId = {ValueType = "string"}, + AreaImg = {ValueType = "string"}, + AreaDesc = {ValueType = "string"}, + PrefabName = {ValueType = "string"}, + }, + XTableWorldBossAttributeStage = { + Id = {ValueType = "int"}, + TotalFinishCount = {ValueType = "int"}, + PreStageId = {Type = 1, ValueType = "int"}, + FinishReward = {ValueType = "int"}, + BuffId = {Type = 1, ValueType = "int"}, + ConsumeId = {ValueType = "int"}, + ConsumeCount = {ValueType = "int"}, + StartStoryId = {ValueType = "string"}, + SystemReportId = {Type = 1, ValueType = "int"}, + }, + XTableWorldBossBossArea = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + UnlockNeedStageCount = {ValueType = "int"}, + MaxChallengeCount = {ValueType = "int"}, + StageId = {ValueType = "int"}, + PhasesRewardId = {Type = 1, ValueType = "int"}, + SystemReportId = {Type = 1, ValueType = "int"}, + PlayerReportId = {Type = 1, ValueType = "int"}, + StartStoryId = {ValueType = "string"}, + FinishStoryId = {ValueType = "string"}, + AreaImg = {ValueType = "string"}, + AreaLockImg = {ValueType = "string"}, + AreaDesc = {ValueType = "string"}, + ModelId = {ValueType = "string"}, + BossTaskId = {Type = 1, ValueType = "int"}, + }, + XTableWorldBossBossStage = { + Id = {ValueType = "int"}, + StageId = {ValueType = "int"}, + Level = {ValueType = "int"}, + Icon = {ValueType = "string"}, + Desc = {ValueType = "string"}, + DescColor = {ValueType = "string"}, + HurtHp = {ValueType = "int"}, + RecommendAbility = {ValueType = "int"}, + RewardId = {ValueType = "int"}, + MonsterLevel = {Type = 1, ValueType = "int"}, + }, + XTableWorldBossBuff = { + Id = {ValueType = "int"}, + Type = {ValueType = "int"}, + Priority = {ValueType = "int"}, + GroupId = {ValueType = "int"}, + Name = {ValueType = "string"}, + Level = {ValueType = "int"}, + CustomizeId = {ValueType = "int"}, + InfoTitle = {ValueType = "string"}, + InfoText = {ValueType = "string"}, + InfoConditionText = {ValueType = "string"}, + HintText = {ValueType = "string"}, + Icon = {ValueType = "string"}, + IsNotShow = {ValueType = "int"}, + }, + XTableWorldBossPhasesReward = { + Id = {ValueType = "int"}, + HpPercent = {ValueType = "int"}, + RewardId = {ValueType = "int"}, + }, + XTableWorldBossBossShop = { + Id = {ValueType = "int"}, + RewardId = {ValueType = "int"}, + ConsumeId = {ValueType = "int"}, + ConsumeCount = {ValueType = "int"}, + DiscountId = {Type = 1, ValueType = "int"}, + ShopImg = {ValueType = "string"}, + }, + XTableWorldBossBossShopDiscount = { + Id = {ValueType = "int"}, + HpPercent = {ValueType = "int"}, + Discount = {ValueType = "float"}, + BossId = {ValueType = "int"}, + DiscountText = {ValueType = "string"}, + }, + XTableWorldBossScoreRule = { + Id = {ValueType = "int"}, + Damage = {ValueType = "int"}, + DamageScore = {ValueType = "int"}, + MaxDamageScore = {ValueType = "int"}, + CharLeftHp = {ValueType = "float"}, + CharLeftHpScore = {ValueType = "int"}, + MaxCharacterScore = {ValueType = "int"}, + }, + XTableWorldBossStageScheduleControl = { + Id = {ValueType = "int"}, + ZoneName = {ValueType = "string"}, + StageId = {ValueType = "int"}, + MinCount = {Type = 1, ValueType = "int"}, + MaxCount = {Type = 1, ValueType = "int"}, + }, + XTableWorldBossHpControl = { + Id = {ValueType = "int"}, + ZoneName = {ValueType = "string"}, + Day = {ValueType = "int"}, + BossId = {ValueType = "int"}, + MaxLoseHp = {ValueType = "int"}, + MaxControlValue = {ValueType = "int"}, + MinPercent = {Type = 1, ValueType = "int"}, + MaxPercent = {Type = 1, ValueType = "int"}, + ControlValue = {Type = 1, ValueType = "int"}, + }, + XTableWorldBossHpConfig = { + Id = {ValueType = "int"}, + ZoneName = {ValueType = "string"}, + BossId = {ValueType = "int"}, + TotalHp = {ValueType = "int"}, + }, + XTableWorldBossFightReport = { + Id = {ValueType = "int"}, + Type = {ValueType = "int"}, + HeadIcon = {ValueType = "string"}, + Phases = {ValueType = "int"}, + Score = {ValueType = "int"}, + Message = {ValueType = "string"}, + }, + XTablePuzzleActivity = { + Id = {ValueType = "int"}, + TimeId = {ValueType = "int"}, + RewardId = {ValueType = "int"}, + BgImage = {ValueType = "string"}, + }, + XTablePuzzleActivityPiece = { + Id = {ValueType = "int"}, + ActId = {ValueType = "int"}, + ItemId = {ValueType = "int"}, + ItemCount = {ValueType = "int"}, + CoverImage = {ValueType = "string"}, + }, + XTableExpeditionConfig = { + Id = {ValueType = "int"}, + ActivityType = {ValueType = "int"}, + Name = {ValueType = "string"}, + RecruitInitNum = {ValueType = "int"}, + RecruitMaxNum = {ValueType = "int"}, + RecruitRecoverTime = {ValueType = "int"}, + RecruitDrawNum = {ValueType = "int"}, + RecruitPickNum = {ValueType = "int"}, + TimeId = {ValueType = "int"}, + Cycle = {ValueType = "int"}, + CommentMaxNum = {ValueType = "int"}, + DailyLikeMaxNum = {ValueType = "int"}, + ChapterIds = {Type = 1, ValueType = "int"}, + BannerTexturePath = {ValueType = "string"}, + RankIcon = {Type = 1, ValueType = "string"}, + }, + XTableExpeditionChapter = { + Id = {ValueType = "int"}, + RewardId = {Type = 1, ValueType = "int"}, + PrefabPath = {Type = 1, ValueType = "string"}, + CodeName = {ValueType = "string"}, + StageBgPath = {Type = 1, ValueType = "string"}, + BgFx = {Type = 1, ValueType = "string"}, + RewardIcon = {Type = 1, ValueType = "string"}, + ComboIds = {Type = 1, ValueType = "int"}, + }, + XTableExpeditionStage = { + Id = {ValueType = "int"}, + ChapterId = {ValueType = "int"}, + StageId = {ValueType = "int"}, + OrderId = {ValueType = "int"}, + StageType = {ValueType = "int"}, + Difficulty = {ValueType = "int"}, + DrawTimesReward = {ValueType = "int"}, + BossStageCover = {ValueType = "string"}, + RecommentStar = {ValueType = "int"}, + WarningStarCap = {ValueType = "int"}, + DangerStarCap = {ValueType = "int"}, + StageWords = {Type = 1, ValueType = "int"}, + StagePrefabPath = {ValueType = "string"}, + }, + XTableExpeditionBaseCharacter = { + Id = {ValueType = "int"}, + CharacterId = {ValueType = "int"}, + Type = {Type = 1, ValueType = "int"}, + LockSkill = {Type = 1, ValueType = "int"}, + SkillLevel = {Type = 1, ValueType = "int"}, + LockLevel = {Type = 1, ValueType = "int"}, + Elements = {Type = 1, ValueType = "int"}, + ReferenceComboId = {Type = 1, ValueType = "int"}, + }, + XTableExpeditionCharacter = { + Id = {ValueType = "int"}, + BaseId = {ValueType = "int"}, + Rank = {ValueType = "int"}, + RobotId = {ValueType = "int"}, + }, + XTableExpeditionCombo = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + ChildComboId = {ValueType = "int"}, + EffectDescription = {ValueType = "string"}, + ConditionDesc = {ValueType = "string"}, + ConditionLevel = {ValueType = "int"}, + ConditionNum = {ValueType = "int"}, + EffectId = {Type = 1, ValueType = "int"}, + EffectValid = {Type = 1, ValueType = "string"}, + EffectTarget = {Type = 1, ValueType = "string"}, + }, + XTableExpeditionChildCombo = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + ComboTypeId = {ValueType = "int"}, + IconPath = {ValueType = "string"}, + ConditionDescription = {ValueType = "string"}, + Condition = {ValueType = "int"}, + }, + XTableExpeditionCharacterWeight = { + Id = {ValueType = "int"}, + BaseId = {ValueType = "int"}, + Weight = {ValueType = "int"}, + ExtraWeight = {ValueType = "int"}, + MustAppearCount = {ValueType = "int"}, + }, + XTableExpeditionDrawConsume = { + Id = {ValueType = "int"}, + ConsumeId = {ValueType = "int"}, + ConsumeCount = {ValueType = "int"}, + }, + XTableExpeditionCharacterType = { + Id = {ValueType = "string"}, + TypeName = {ValueType = "string"}, + }, + XTableExpeditionRankUp = { + Id = {ValueType = "int"}, + Level1 = {ValueType = "int"}, + Level2 = {ValueType = "int"}, + Level3 = {ValueType = "int"}, + Level4 = {ValueType = "int"}, + }, + XTableExpeditionComboTypeName = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + }, + XTableExpeditionGlobalCombo = { + Id = {ValueType = "int"}, + IsVisible = {ValueType = "int"}, + Name = {ValueType = "string"}, + EffectDescription = {ValueType = "string"}, + IconPath = {ValueType = "string"}, + }, + XTableCharacterShowScore = { + CharacterId = {ValueType = "int"}, + Quality = {Type = 1, ValueType = "int"}, + }, + XTableExpeditionAssist = { + EffectId = {ValueType = "int"}, + AssistType = {ValueType = "int"}, + }, + XTableExpeditionDrawPR = { + Level = {ValueType = "int"}, + NeedRefreshTime = {ValueType = "int"}, + RankPR = {Type = 1, ValueType = "int"}, + }, + XTableExpeditionDrawRank = { + Id = {ValueType = "int"}, + Rank = {ValueType = "int"}, + }, + XTableExpeditionCharacterElements = { + Id = {ValueType = "int"}, + ElementName = {ValueType = "string"}, + Description = {ValueType = "string"}, + Icon = {ValueType = "string"}, + }, + XTableExpeditionTeamPos = { + Id = {ValueType = "int"}, + ChapterId = {ValueType = "int"}, + ConditionDes = {ValueType = "string"}, + ConditionId = {ValueType = "int"}, + }, + XTableHookRope = { + Id = {ValueType = "int"}, + AreaType = {ValueType = "int"}, + Radius = {ValueType = "fix"}, + Length = {ValueType = "fix"}, + Width = {ValueType = "fix"}, + PosX = {ValueType = "fix"}, + PosY = {ValueType = "fix"}, + PosZ = {ValueType = "fix"}, + face = {ValueType = "fix"}, + TargetIds = {Type = 1, ValueType = "int"}, + }, + XTableClickClearGame = { + Id = {ValueType = "int"}, + StartTimeStr = {ValueType = "string"}, + EndTimeStr = {ValueType = "string"}, + HelpId = {ValueType = "int"}, + }, + XTableClickClearGameStage = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + NameEn = {ValueType = "string"}, + UnlockCondition = {ValueType = "int"}, + TimeLimit = {ValueType = "int"}, + HeadNormalType = {ValueType = "int"}, + HeadNormalCount = {ValueType = "int"}, + NormalTypeDesc = {ValueType = "string"}, + HeadSpecialType = {ValueType = "int"}, + HeadSpecialCount = {ValueType = "int"}, + SpecialTypeDesc = {ValueType = "string"}, + HeadWrongType = {ValueType = "int"}, + WrongCostTime = {ValueType = "int"}, + RewardId = {ValueType = "int"}, + RewardConditionDesc = {ValueType = "string"}, + PageList = {Type = 1, ValueType = "string"}, + }, + XTableClickClearPage = { + Id = {ValueType = "int"}, + RowNumber = {Type = 1, ValueType = "string"}, + }, + XTableClickClearRow = { + Id = {ValueType = "int"}, + HeadId = {Type = 1, ValueType = "int"}, + }, + XTableClickClearHead = { + Id = {ValueType = "int"}, + Type = {ValueType = "int"}, + Url = {ValueType = "string"}, + }, + XTableHonorLevel = { + HonorLevel = {ValueType = "int"}, + MaxExp = {ValueType = "int"}, + MaxActionPoint = {ValueType = "int"}, + RewardId = {ValueType = "int"}, + MaxFriendCount = {ValueType = "int"}, + }, + XTableRpgConfig = { + Id = {ValueType = "int"}, + TimeId = {ValueType = "int"}, + MaxChallengeCount = {ValueType = "int"}, + TalentItemId = {ValueType = "int"}, + ActivityName = {ValueType = "string"}, + EntryTexture = {ValueType = "string"}, + CharacterIds = {Type = 1, ValueType = "int"}, + DailyRewards = {Type = 1, ValueType = "int"}, + }, + XTableRpgCharacter = { + Id = {ValueType = "int"}, + CharacterId = {ValueType = "int"}, + Level = {ValueType = "int"}, + RobotId = {ValueType = "int"}, + }, + XTableRpgBaseCharacter = { + Id = {ValueType = "int"}, + DisplayAttriName = {Type = 1, ValueType = "string"}, + DisplayAttriType = {Type = 1, ValueType = "int"}, + }, + XTableRpgTalent = { + TalentId = {ValueType = "int"}, + CharacterId = {ValueType = "int"}, + LayerId = {ValueType = "int"}, + ConsumeCount = {ValueType = "int"}, + AttribPoolGroupId = {ValueType = "int"}, + SkillIds = {Type = 1, ValueType = "int"}, + SkillLevels = {Type = 1, ValueType = "int"}, + EventIds = {Type = 1, ValueType = "int"}, + Name = {ValueType = "string"}, + Description = {ValueType = "string"}, + SpecialAbility = {ValueType = "int"}, + Icon = {ValueType = "string"}, + }, + XTableRpgStage = { + Id = {ValueType = "int"}, + ActivityId = {ValueType = "int"}, + StageId = {ValueType = "int"}, + OrderId = {ValueType = "int"}, + OrderName = {ValueType = "string"}, + Difficulty = {ValueType = "int"}, + StageBuffDesc = {ValueType = "string"}, + MonsterId = {Type = 1, ValueType = "int"}, + RecommendLevel = {ValueType = "int"}, + NpcAffixId = {Type = 1, ValueType = "int"}, + }, + XTableRpgTeamLevel = { + Level = {ValueType = "int"}, + PreLevel = {ValueType = "int"}, + Exp = {ValueType = "int"}, + AddTalentPoint = {ValueType = "int"}, + AddRoleLevel = {ValueType = "int"}, + AddSkillLv = {ValueType = "int"}, + }, + XTableRpgTalentLayer = { + LayerId = {ValueType = "int"}, + NeedTeamLevel = {ValueType = "int"}, + }, + XTableRpgMonsters = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + SubName = {ValueType = "string"}, + MonsterNpcDataId = {ValueType = "int"}, + IsBoss = {ValueType = "int"}, + Scale = {ValueType = "float"}, + PositionX = {ValueType = "float"}, + PositionY = {ValueType = "float"}, + PositionZ = {ValueType = "float"}, + RotationX = {ValueType = "float"}, + RotationY = {ValueType = "float"}, + RotationZ = {ValueType = "float"}, + }, + XTableRpgItemConfig = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Icon = {ValueType = "string"}, + Quality = {ValueType = "int"}, + WorldDesc = {ValueType = "string"}, + Description = {ValueType = "string"}, + }, + XTableMovieSkip = { + Id = {ValueType = "string"}, + SkipDesc = {ValueType = "string"}, + }, + XTableBackground = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Quality = {ValueType = "int"}, + Description = {ValueType = "string"}, + WorldDescription = {ValueType = "string"}, + Icon = {ValueType = "string"}, + BigIcon = {ValueType = "string"}, + IconPath = {ValueType = "string"}, + SceneModelId = {ValueType = "int"}, + LockDec = {ValueType = "string"}, + ShowStr = {ValueType = "string"}, + Priority = {ValueType = "int"}, + IsFree = {ValueType = "int"}, + IsMainScene = {ValueType = "int"}, + ParticleGroupName = {ValueType = "string"}, + }, + XTablePhotoModeShareInfo = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + IconPath = {ValueType = "string"}, + Text = {ValueType = "string"}, + Param = {Type = 1, ValueType = "string"}, + }, + XTablePhotoModeSharePlatformConfig = { + Id = {ValueType = "int"}, + SdkId = {Type = 1, ValueType = "int"}, + }, + XTableCharacterAction = { + Id = {ValueType = "int"}, + CharacterId = {ValueType = "int"}, + Name = {ValueType = "string"}, + SignBoardActionId = {ValueType = "int"}, + UnlockLv = {ValueType = "int"}, + ConditionDescript = {ValueType = "string"}, + }, + XTableCharacterCollaboration = { + CharacterId = {ValueType = "int"}, + languageSet = {ValueType = "string"}, + Text = {ValueType = "string"}, + IconPath = {ValueType = "string"}, + IconX = {ValueType = "float"}, + IconY = {ValueType = "float"}, + IconScale = {ValueType = "float"}, + }, + XTableTRPGRole = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Description = {ValueType = "string"}, + UnlockTarget = {ValueType = "int"}, + Image = {ValueType = "string"}, + HeadIcon = {ValueType = "string"}, + ModelId = {ValueType = "string"}, + InitAttribute = {Type = 2, KeyType = "int", ValueType = "int"}, + TalentGroupId = {ValueType = "int"}, + }, + XTableTRPGRoleTalent = { + Id = {ValueType = "int"}, + TalentPointIcon = {ValueType = "string"}, + ResetTalentItemId = {ValueType = "int"}, + ResetTalentItemCount = {ValueType = "int"}, + }, + XTableTRPGRoleAttribute = { + AttrType = {ValueType = "int"}, + Name = {ValueType = "string"}, + Icon = {ValueType = "string"}, + MaxValue = {ValueType = "int"}, + }, + XTableTRPGRoleTalentGroup = { + Id = {ValueType = "int"}, + PreId = {ValueType = "int"}, + IsCommonForShow = {ValueType = "int"}, + CostPoint = {ValueType = "int"}, + EventId = {ValueType = "int"}, + Icon = {ValueType = "string"}, + Intro = {ValueType = "string"}, + Description = {ValueType = "string"}, + Title = {ValueType = "string"}, + }, + XTableTRPGRoleTalentGroupClient = { + Id = {ValueType = "int"}, + Prefab = {ValueType = "string"}, + }, + XTableTRPGMainArea = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + SubAreaId = {Type = 1, ValueType = "int"}, + TargetLinkId = {Type = 1, ValueType = "int"}, + OpenTimeId = {ValueType = "int"}, + TRPGRewardId = {Type = 1, ValueType = "int"}, + TruthRoadGroupId = {Type = 1, ValueType = "int"}, + TruthRoadTabBg = {ValueType = "string"}, + SubAreaBg = {ValueType = "string"}, + TruthRoadBg = {ValueType = "string"}, + EnName = {ValueType = "string"}, + FirstOpenFunctionGroupId = {ValueType = "int"}, + Condition = {ValueType = "int"}, + }, + XTableTRPGSecondArea = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + SubAreaBg = {ValueType = "string"}, + Type = {ValueType = "int"}, + MazeId = {ValueType = "int"}, + SubAreaId = {Type = 1, ValueType = "int"}, + Condition = {ValueType = "int"}, + }, + XTableTRPGThirdArea = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + EnName = {ValueType = "string"}, + Icon = {ValueType = "string"}, + Bg = {ValueType = "string"}, + FuncGroup = {Type = 1, ValueType = "int"}, + Condition = {ValueType = "int"}, + }, + XTableTRPGTarget = { + Id = {ValueType = "int"}, + Type = {ValueType = "int"}, + Desc = {ValueType = "string"}, + Params = {Type = 1, ValueType = "string"}, + Name = {ValueType = "string"}, + AreaIcon = {ValueType = "string"}, + CardIcon = {ValueType = "string"}, + }, + XTableTRPGTargetLink = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + TargetId = {Type = 1, ValueType = "int"}, + PreTarget = {Type = 1, ValueType = "string"}, + TargetMissionType = {ValueType = "int"}, + PrefabAreaName = {ValueType = "string"}, + }, + XTableTRPGFunction = { + Id = {ValueType = "int"}, + Type = {ValueType = "int"}, + NeedSave = {ValueType = "int"}, + Params = {Type = 1, ValueType = "string"}, + RewardId = {ValueType = "int"}, + Desc = {ValueType = "string"}, + Icon = {ValueType = "string"}, + }, + XTableTRPGFunctionGroup = { + Id = {ValueType = "int"}, + FunctionId = {Type = 1, ValueType = "int"}, + Condition = {ValueType = "int"}, + }, + XTableTRPGMaze = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + StartLayerId = {ValueType = "int"}, + LayerId = {Type = 1, ValueType = "int"}, + }, + XTableTRPGMazeLayer = { + Id = {ValueType = "int"}, + StartNodeId = {ValueType = "int"}, + StartCardIndex = {ValueType = "int"}, + Name = {ValueType = "string"}, + MapId = {ValueType = "int"}, + BgImage = {ValueType = "string"}, + }, + XTableTRPGMazeMap = { + Id = {ValueType = "int"}, + CardId = {Type = 1, ValueType = "int"}, + }, + XTableTRPGMazeCard = { + Id = {ValueType = "int"}, + Disposeable = {ValueType = "int"}, + SingleDisposeable = {ValueType = "int"}, + RecordGroupId = {ValueType = "int"}, + Type = {ValueType = "int"}, + Param = {Type = 1, ValueType = "string"}, + Order = {ValueType = "string"}, + Name = {ValueType = "string"}, + Icon = {ValueType = "string"}, + IconR = {ValueType = "string"}, + MiniIcon = {ValueType = "string"}, + ConvertCardId = {ValueType = "int"}, + FightDes = {ValueType = "string"}, + QuickFightDes = {ValueType = "string"}, + ShowTag = {ValueType = "int"}, + MovieId = {ValueType = "string"}, + }, + XTableTRPGMazeCardType = { + Type = {ValueType = "int"}, + Icon = {ValueType = "string"}, + Prefab = {ValueType = "string"}, + }, + XTableTRPGMazeCardRecordGroup = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + MiniIcon = {ValueType = "string"}, + }, + XTableTRPGLevel = { + Id = {ValueType = "int"}, + UpExp = {ValueType = "int"}, + TalentPoint = {ValueType = "int"}, + }, + XTableTRPGShop = { + Id = {ValueType = "int"}, + OpenCondition = {ValueType = "int"}, + ShopItemId = {Type = 1, ValueType = "int"}, + ShopItemCount = {Type = 1, ValueType = "int"}, + Condition = {ValueType = "int"}, + }, + XTableTRPGShopItem = { + Id = {ValueType = "int"}, + ResetType = {ValueType = "int"}, + Condition = {ValueType = "int"}, + RewardId = {ValueType = "int"}, + ConsumeId = {ValueType = "int"}, + ConsumeCount = {ValueType = "int"}, + }, + XTableTRPGExamine = { + Id = {ValueType = "int"}, + Endurance = {ValueType = "int"}, + Title = {ValueType = "string"}, + Description = {ValueType = "string"}, + ActionId = {Type = 1, ValueType = "int"}, + PunishId = {Type = 1, ValueType = "int"}, + PunishWeight = {Type = 1, ValueType = "int"}, + SucDesc = {ValueType = "string"}, + FailDesc = {ValueType = "string"}, + StartMovieId = {ValueType = "string"}, + }, + XTableTRPGExamineAction = { + Id = {ValueType = "int"}, + Type = {ValueType = "int"}, + Round = {ValueType = "int"}, + ItemId = {ValueType = "int"}, + NeedValue = {ValueType = "int"}, + ResetCostId = {ValueType = "int"}, + ResetCostCount = {ValueType = "int"}, + Desc = {ValueType = "string"}, + }, + XTableTRPGExamineActionType = { + Type = {ValueType = "int"}, + Icon = {ValueType = "string"}, + Desc = {ValueType = "string"}, + DescEn = {ValueType = "string"}, + DefaultItemDesc = {ValueType = "string"}, + RangeDesc = {ValueType = "string"}, + AttrDesc = {ValueType = "string"}, + }, + XTableTRPGExamineActionDifficult = { + Difficult = {ValueType = "int"}, + Delta = {ValueType = "int"}, + Desc = {ValueType = "string"}, + }, + XTableTRPGExaminePoint = { + Id = {ValueType = "int"}, + RoleId = {ValueType = "int"}, + AttributeValue = {ValueType = "int"}, + Result = {Type = 1, ValueType = "int"}, + Weight = {Type = 1, ValueType = "int"}, + }, + XTableTRPGExaminePunish = { + Id = {ValueType = "int"}, + Type = {ValueType = "int"}, + Params = {Type = 1, ValueType = "int"}, + Desc = {ValueType = "string"}, + }, + XTableTRPGBuff = { + Id = {ValueType = "int"}, + EffectType = {ValueType = "int"}, + Type = {ValueType = "int"}, + Params = {Type = 1, ValueType = "int"}, + Name = {ValueType = "string"}, + Desc = {ValueType = "string"}, + Icon = {ValueType = "string"}, + }, + XTableTRPGReward = { + Id = {ValueType = "int"}, + Condition = {Type = 1, ValueType = "int"}, + RewardId = {ValueType = "int"}, + ReceiveDesc = {ValueType = "string"}, + SecondMainReceiveDesc = {ValueType = "string"}, + }, + XTableTRPGItem = { + Id = {ValueType = "int"}, + ItemType = {ValueType = "int"}, + Capacity = {ValueType = "int"}, + EffectType = {ValueType = "int"}, + Params = {Type = 1, ValueType = "int"}, + TagIcon = {ValueType = "string"}, + Desc = {ValueType = "string"}, + }, + XTableTRPGMemoirStory = { + Id = {ValueType = "int"}, + StoryId = {ValueType = "string"}, + UnlockItemId = {ValueType = "int"}, + UnlockItemCount = {ValueType = "int"}, + TabName = {ValueType = "string"}, + Name = {ValueType = "string"}, + Desc = {ValueType = "string"}, + ImgCG = {ValueType = "string"}, + }, + XTableTRPGBoss = { + Id = {ValueType = "int"}, + TimeId = {ValueType = "int"}, + StageId = {ValueType = "int"}, + FinishMailId = {ValueType = "int"}, + ModelId = {ValueType = "string"}, + ChallengeCount = {ValueType = "int"}, + Desc = {ValueType = "string"}, + StartStoryId = {ValueType = "string"}, + HideEntranceTimeStr = {ValueType = "string"}, + }, + XTableTRPGBossPhasesReward = { + Id = {ValueType = "int"}, + Percent = {ValueType = "int"}, + RewardId = {ValueType = "int"}, + Icon = {ValueType = "string"}, + }, + XTableTRPGBossHpConfig = { + Id = {ValueType = "int"}, + ZoneName = {ValueType = "string"}, + BossId = {ValueType = "int"}, + TotalHp = {ValueType = "int"}, + }, + XTableTRPGBossHpControl = { + Id = {ValueType = "int"}, + ZoneName = {ValueType = "string"}, + BossId = {ValueType = "int"}, + Day = {ValueType = "int"}, + MinHp = {Type = 1, ValueType = "int"}, + MaxHp = {Type = 1, ValueType = "int"}, + }, + XTableTRPGTargetCheckConfig = { + Id = {ValueType = "int"}, + TargetId = {Type = 1, ValueType = "int"}, + }, + XTableTRPGPanelPlotTab = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Bg = {ValueType = "string"}, + OpenUiName = {ValueType = "string"}, + Condition = {ValueType = "int"}, + }, + XTableTRPGTruthRoadGroup = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Condition = {ValueType = "int"}, + Prefab = {ValueType = "string"}, + TruthRoadId = {Type = 1, ValueType = "int"}, + SmallName = {ValueType = "string"}, + }, + XTableTRPGTruthRoad = { + Id = {ValueType = "int"}, + PrefabName = {ValueType = "string"}, + Icon = {ValueType = "string"}, + Name = {ValueType = "string"}, + Desc = {ValueType = "string"}, + Condition = {ValueType = "int"}, + StageId = {ValueType = "int"}, + StoryId = {ValueType = "string"}, + TRPGRewardId = {ValueType = "int"}, + DialogIcon = {ValueType = "string"}, + }, + XTableTRPGButtonCondition = { + Id = {ValueType = "int"}, + Condition = {ValueType = "int"}, + }, + XTableDragPuzzleActivity = { + Id = {ValueType = "int"}, + TimeId = {ValueType = "int"}, + HelpId = {ValueType = "int"}, + ItemId = {ValueType = "int"}, + }, + XTableDragPuzzleActivityPuzzle = { + Id = {ValueType = "int"}, + ActId = {ValueType = "int"}, + Name = {ValueType = "string"}, + SubName = {ValueType = "string"}, + RowSize = {ValueType = "int"}, + ColSize = {ValueType = "int"}, + PieceItemCount = {ValueType = "int"}, + BgUrl = {ValueType = "string"}, + CompleteStoryId = {ValueType = "string"}, + CompleteRewardId = {ValueType = "int"}, + CompleteHintText = {ValueType = "string"}, + RewardPiecesStr = {Type = 1, ValueType = "string"}, + RewardId = {Type = 1, ValueType = "int"}, + CompleteImageUrl = {ValueType = "string"}, + PuzzleType = {ValueType = "int"}, + }, + XTableDragPuzzleActivityPiece = { + Id = {ValueType = "int"}, + PuzzleId = {ValueType = "int"}, + CorrectIdx = {ValueType = "int"}, + FragmentUrl = {ValueType = "string"}, + }, + XTableDragPuzzleActivityPassword = { + Id = {ValueType = "int"}, + PuzzleId = {ValueType = "int"}, + Password = {Type = 1, ValueType = "int"}, + PasswordHint = {ValueType = "string"}, + HintMessage = {Type = 1, ValueType = "string"}, + DecryptionImgUrl = {ValueType = "string"}, + }, + XTableMaintainerActionConfig = { + Id = {ValueType = "int"}, + TimeId = {ValueType = "int"}, + Name = {ValueType = "string"}, + StoryId = {ValueType = "string"}, + MaxDailyActionCount = {ValueType = "int"}, + MaxFightWinCount = {ValueType = "int"}, + MaxBoxCount = {ValueType = "int"}, + MaxWarehouseFinishCount = {ValueType = "int"}, + NodeCount = {ValueType = "int"}, + MaxCardNumber = {ValueType = "int"}, + MaxHandCardCount = {ValueType = "int"}, + NodePoolId = {ValueType = "int"}, + TeacherMailId = {ValueType = "int"}, + StudentMailId = {ValueType = "int"}, + }, + XTableMaintainerActionFightNode = { + Id = {ValueType = "int"}, + Nodes = {Type = 1, ValueType = "int"}, + }, + XTableMaintainerActionEventNode = { + Id = {ValueType = "int"}, + PoolId = {ValueType = "int"}, + NodeInfoId = {ValueType = "int"}, + MinCount = {ValueType = "int"}, + MaxCount = {ValueType = "int"}, + Condition = {ValueType = "int"}, + }, + XTableMaintainerActionLevel = { + Level = {ValueType = "int"}, + StageIds = {Type = 1, ValueType = "int"}, + BoxRewardIds = {Type = 1, ValueType = "int"}, + }, + XTableMaintainerActionNodeInfo = { + Id = {ValueType = "int"}, + Type = {ValueType = "int"}, + Name = {ValueType = "string"}, + Seen = {ValueType = "bool"}, + Params = {Type = 1, ValueType = "int"}, + EventIds = {Type = 1, ValueType = "int"}, + }, + XTableMaintainerActionEvent = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + IsRecord = {ValueType = "int"}, + RecordText = {ValueType = "string"}, + HintText = {ValueType = "string"}, + DescText = {ValueType = "string"}, + EventIcon = {ValueType = "string"}, + }, + XTableNpcPart = { + Id = {ValueType = "int"}, + PartNpc = {ValueType = "int"}, + MainNpc = {ValueType = "int"}, + MapDamage = {ValueType = "bool"}, + BoneName = {ValueType = "string"}, + RenderBoneName = {ValueType = "string"}, + DeathSkillId = {ValueType = "int"}, + SkillId = {Type = 1, ValueType = "int"}, + }, + XTableTeaching = { + Id = {ValueType = "int"}, + Group = {ValueType = "int"}, + Name = {ValueType = "string"}, + Describe = {ValueType = "string"}, + IconType = {ValueType = "int"}, + Icon = {ValueType = "int"}, + Icon2 = {ValueType = "int"}, + TimeOut = {ValueType = "int"}, + OnlyTrue = {ValueType = "bool"}, + IsMySelf = {ValueType = "bool"}, + AndOr = {ValueType = "bool"}, + ForbidMoveType = {ValueType = "int"}, + MoveType = {ValueType = "int"}, + EffectType = {Type = 1, ValueType = "int"}, + EffectButton = {Type = 1, ValueType = "int"}, + SkillId = {Type = 1, ValueType = "int"}, + MissileId = {Type = 1, ValueType = "int"}, + }, + XTableNieRCharacterClient = { + CharacterId = {ValueType = "int"}, + UpLevelItem = {ValueType = "int"}, + Pos = {ValueType = "int"}, + SkipId = {ValueType = "int"}, + Icon = {ValueType = "string"}, + }, + XTableNieRCharacterInformation = { + Id = {ValueType = "int"}, + CharacterId = {ValueType = "int"}, + UnlockCondition = {ValueType = "int"}, + Priority = {ValueType = "int"}, + Title = {ValueType = "string"}, + Content = {ValueType = "string"}, + DescEx = {ValueType = "string"}, + }, + XTableNieRShopClient = { + ShopId = {ValueType = "int"}, + BtnName = {ValueType = "string"}, + ShopBg = {ValueType = "string"}, + ShopItemBg = {ValueType = "string"}, + ShopIcon = {ValueType = "string"}, + }, + XTableNieRRepeatableStageClient = { + StageId = {ValueType = "int"}, + RewardIcon = {ValueType = "string"}, + RewardTitle = {ValueType = "string"}, + RewardQuality = {ValueType = "int"}, + }, + XTableNieRActivity = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + TimeId = {ValueType = "int"}, + SupportId = {ValueType = "int"}, + RepeatableConsumeId = {ValueType = "int"}, + RepeatableConsumeInitCount = {ValueType = "int"}, + RepeatableConsumeDailyAdd = {ValueType = "int"}, + RepeatableConsumeMaxCount = {ValueType = "int"}, + BannerBg = {ValueType = "string"}, + ChapterIds = {Type = 1, ValueType = "int"}, + RepeatableStageIds = {Type = 1, ValueType = "int"}, + DevelopCharacterIds = {Type = 1, ValueType = "int"}, + ShopIds = {Type = 1, ValueType = "int"}, + TaskGroupIds = {Type = 1, ValueType = "int"}, + EasterEggStageId = {ValueType = "int"}, + EasterEggRewardId = {ValueType = "int"}, + EasterEggMinAge = {ValueType = "int"}, + EasterEggMaxAge = {ValueType = "int"}, + MaxEasterEggMessageCount = {ValueType = "int"}, + }, + XTableNieRChapter = { + ChapterId = {ValueType = "int"}, + TimeId = {ValueType = "int"}, + Condition = {ValueType = "int"}, + BossStageId = {ValueType = "int"}, + BossHp = {ValueType = "int"}, + BossScoreRuleId = {ValueType = "int"}, + TaskSkipId = {ValueType = "int"}, + RepeatPoStagePos = {ValueType = "int"}, + RobotIds = {Type = 1, ValueType = "int"}, + StageIds = {Type = 1, ValueType = "int"}, + Icon = {ValueType = "string"}, + Title = {ValueType = "string"}, + RepeatPoStageLabel = {ValueType = "string"}, + }, + XTableNieRRepeatableStage = { + RepeatableStageId = {ValueType = "int"}, + Condition = {ValueType = "int"}, + ConsumeCount = {ValueType = "int"}, + NormalReward = {ValueType = "int"}, + TaskSkipId = {ValueType = "int"}, + StarRewards = {Type = 1, ValueType = "int"}, + ExStageIds = {Type = 1, ValueType = "int"}, + ExStageConditions = {Type = 1, ValueType = "int"}, + ExConsumeIds = {Type = 1, ValueType = "int"}, + ExConsumeCounts = {Type = 1, ValueType = "int"}, + RobotIds = {Type = 1, ValueType = "int"}, + }, + XTableNieRCharacter = { + Id = {ValueType = "int"}, + CharacterId = {ValueType = "int"}, + InitLevel = {ValueType = "int"}, + Condition = {ValueType = "int"}, + AbilityGroupId = {ValueType = "int"}, + EasterEggFightTag = {ValueType = "int"}, + TeachingStageIds = {Type = 1, ValueType = "int"}, + }, + XTableNieRCharacterLevel = { + Id = {ValueType = "int"}, + CharacterId = {ValueType = "int"}, + Level = {ValueType = "int"}, + RobotId = {ValueType = "int"}, + MaxExp = {ValueType = "int"}, + WeaponLevel = {ValueType = "int"}, + WaferLevel = {ValueType = "int"}, + }, + XTableNieRAbilityGroup = { + Id = {ValueType = "int"}, + AbilityGroupId = {ValueType = "int"}, + Condition = {ValueType = "int"}, + SkillId = {ValueType = "int"}, + SkillLevel = {ValueType = "int"}, + FashionId = {ValueType = "int"}, + WeaponId = {ValueType = "int"}, + WeaponAweken = {ValueType = "int"}, + WeaponBreakThrough = {ValueType = "int"}, + WaferId = {Type = 1, ValueType = "int"}, + WaferAweken = {Type = 1, ValueType = "int"}, + WaferBreakThrough = {Type = 1, ValueType = "int"}, + Priority = {ValueType = "int"}, + TitleStr = {ValueType = "string"}, + }, + XTableTeachingActivity = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + TimeId = {ValueType = "int"}, + ChallengeStage = {Type = 1, ValueType = "int"}, + StageId = {Type = 1, ValueType = "int"}, + TreasureId = {Type = 1, ValueType = "int"}, + TotalStars = {ValueType = "int"}, + FubenPrefab = {ValueType = "string"}, + GridFubenPrefab = {ValueType = "string"}, + FubenChallengePrefab = {ValueType = "string"}, + GridFubenChallengePrefab = {ValueType = "string"}, + ConditionId = {ValueType = "int"}, + MainBgImg = {ValueType = "string"}, + StageBgImg = {ValueType = "string"}, + TitleImg = {ValueType = "string"}, + BannerBg = {ValueType = "string"}, + CharacterId = {ValueType = "int"}, + SkipIdDraw = {ValueType = "int"}, + SkipIdAct = {ValueType = "int"}, + SkipIdJZ = {ValueType = "int"}, + SkipIdChar = {ValueType = "int"}, + SkipIdSkin = {ValueType = "int"}, + NewCharType = {ValueType = "int"}, + MovieId = {ValueType = "int"}, + }, + XTableTeachingTreasure = { + TreasureId = {ValueType = "int"}, + RequireStar = {ValueType = "int"}, + RewardId = {ValueType = "int"}, + }, + XTableCharActiveMsg = { + Id = {ValueType = "int"}, + ActId = {ValueType = "int"}, + Order = {ValueType = "int"}, + Title = {ValueType = "string"}, + Content = {ValueType = "string"}, + IsLock = {ValueType = "bool"}, + ConditionId = {ValueType = "int"}, + BtnBg = {ValueType = "string"}, + }, + XTableCharDescDetail = { + StageId = {ValueType = "int"}, + DescDetail = {ValueType = "string"}, + ShowFightEventIds = {Type = 1, ValueType = "int"}, + }, + XTableNieRBossScoreRule = { + Id = {ValueType = "int"}, + BaseScore = {ValueType = "int"}, + DamageScore = {ValueType = "float"}, + CharacterLeftHpScore = {ValueType = "float"}, + MaxCharacterLeftHpScore = {ValueType = "int"}, + ScoreHpRatio = {ValueType = "float"}, + }, + XTableNieRSupport = { + SupportId = {ValueType = "int"}, + SkillIds = {Type = 1, ValueType = "int"}, + SkillPassiveFlags = {Type = 1, ValueType = "int"}, + SkillConditions = {Type = 1, ValueType = "int"}, + }, + XTableNieRSupportLevel = { + Id = {ValueType = "int"}, + SupportId = {ValueType = "int"}, + Level = {ValueType = "int"}, + MaxExp = {ValueType = "int"}, + Icon = {ValueType = "string"}, + HeadIcon = {ValueType = "string"}, + HeadBigIcon = {ValueType = "string"}, + Model = {ValueType = "string"}, + }, + XTableNieRSupportSkillLevel = { + Id = {ValueType = "int"}, + SkillId = {ValueType = "int"}, + Level = {ValueType = "int"}, + FightEventId = {ValueType = "int"}, + UpgradeCondition = {ValueType = "int"}, + UpgradeConsumeId = {ValueType = "int"}, + UpgradeConsumeCount = {ValueType = "int"}, + }, + XTableNieRTask = { + TaskGroupId = {ValueType = "int"}, + TitleStr = {ValueType = "string"}, + Priority = {ValueType = "int"}, + EasterEggTask = {ValueType = "int"}, + }, + XTableNieREasterEggClient = { + Id = {ValueType = "int"}, + GroupId = {ValueType = "int"}, + Type = {ValueType = "int"}, + ShowBullet = {ValueType = "int"}, + Desc = {ValueType = "string"}, + BtnExStr = {ValueType = "string"}, + BtnStr = {Type = 1, ValueType = "string"}, + BtnTag = {Type = 1, ValueType = "int"}, + }, + XTableNieREasterEggInitMessage = { + Id = {ValueType = "int"}, + PlayerName = {ValueType = "string"}, + MessageId = {ValueType = "int"}, + Age = {ValueType = "int"}, + LabelId = {ValueType = "int"}, + }, + XTableNieREasterEggMessage = { + Id = {ValueType = "int"}, + Message = {ValueType = "string"}, + }, + XTableNieREasterEggLabel = { + Id = {ValueType = "int"}, + Label = {ValueType = "string"}, + }, + XTableHackerPlayerPoint = { + ObjectId = {ValueType = "int"}, + WavelId = {ValueType = "int"}, + PlayerId = {ValueType = "int"}, + PositionX = {ValueType = "float"}, + PositionZ = {ValueType = "float"}, + Rotation = {ValueType = "float"}, + Enabled = {ValueType = "bool"}, + AndOr = {ValueType = "bool"}, + ColliderId = {ValueType = "int"}, + TimerId = {ValueType = "int"}, + GroupClear = {ValueType = "int"}, + }, + XTableHackerCollider = { + ObjectId = {ValueType = "int"}, + WavelId = {ValueType = "int"}, + PositionX = {ValueType = "float"}, + PositionZ = {ValueType = "float"}, + Rotation = {ValueType = "float"}, + ScaleX = {ValueType = "float"}, + ScaleZ = {ValueType = "float"}, + Enabled = {ValueType = "bool"}, + AndOr = {ValueType = "bool"}, + ColliderId = {ValueType = "int"}, + TimerId = {ValueType = "int"}, + GroupClear = {ValueType = "int"}, + }, + XTableHackerGenerator = { + ObjectId = {ValueType = "int"}, + WavelId = {ValueType = "int"}, + Group = {ValueType = "int"}, + EnemyId = {ValueType = "int"}, + PositionX = {ValueType = "float"}, + PositionZ = {ValueType = "float"}, + Rotation = {ValueType = "float"}, + Enabled = {ValueType = "bool"}, + AndOr = {ValueType = "bool"}, + ColliderId = {ValueType = "int"}, + TimerId = {ValueType = "int"}, + GroupClear = {ValueType = "int"}, + }, + XTableHackerObstacle = { + ObjectId = {ValueType = "int"}, + WavelId = {ValueType = "int"}, + HitTime = {ValueType = "int"}, + PositionX = {ValueType = "float"}, + PositionY = {ValueType = "float"}, + PositionZ = {ValueType = "float"}, + Rotation = {ValueType = "float"}, + ScaleX = {ValueType = "float"}, + ScaleY = {ValueType = "float"}, + ScaleZ = {ValueType = "float"}, + Enabled = {ValueType = "bool"}, + IsLogic = {ValueType = "bool"}, + AndOr = {ValueType = "bool"}, + ColliderId = {ValueType = "int"}, + TimerId = {ValueType = "int"}, + GroupClear = {ValueType = "int"}, + DisenableAndOr = {ValueType = "bool"}, + DisenableColliderId = {ValueType = "int"}, + DisenableTimerId = {ValueType = "int"}, + DisenableGroupClear = {ValueType = "int"}, + PrefabName = {ValueType = "string"}, + }, + XTableHackerTimer = { + ObjectId = {ValueType = "int"}, + WavelId = {ValueType = "int"}, + Time = {ValueType = "float"}, + Enabled = {ValueType = "bool"}, + AndOr = {ValueType = "bool"}, + ColliderId = {ValueType = "int"}, + TimerId = {ValueType = "int"}, + GroupClear = {ValueType = "int"}, + }, + XTableHackerNpc = { + Id = {ValueType = "int"}, + NpcType = {ValueType = "int"}, + Life = {ValueType = "int"}, + IsBoss = {ValueType = "bool"}, + MoveSpeed = {ValueType = "float"}, + LookAtPlayer = {ValueType = "bool"}, + RotateSpeed = {ValueType = "float"}, + ShootInterval = {ValueType = "float"}, + BulletAngel = {ValueType = "float"}, + DeathEffectPath = {ValueType = "string"}, + BulletId = {Type = 1, ValueType = "int"}, + }, + XTableHackerBullet = { + Id = {ValueType = "int"}, + BulletType = {ValueType = "int"}, + MoveSpeed = {ValueType = "float"}, + LookAtPlayer = {ValueType = "bool"}, + RotateSpeed = {ValueType = "float"}, + LiveTime = {ValueType = "float"}, + DeathEffectPath = {ValueType = "string"}, + }, + XTableHackerPlayer = { + Id = {ValueType = "int"}, + Life = {ValueType = "int"}, + MoveSpeed = {ValueType = "float"}, + ShootInterval = {ValueType = "float"}, + BulletMoveSpeed = {ValueType = "float"}, + BulletLiveTime = {ValueType = "float"}, + BehitShieldRadius = {ValueType = "float"}, + BehitShieldResetTime = {ValueType = "float"}, + }, + XHackerScenePrefab = { + Id = {ValueType = "int"}, + PrefabPath = {ValueType = "string"}, + CameraPath = {ValueType = "string"}, + }, + XTableStudentChallengeReward = { + TaskId = {ValueType = "int"}, + RewardId = {ValueType = "int"}, + }, + XTableMasterStageReward = { + Count = {ValueType = "int"}, + RewardId = {ValueType = "int"}, + }, + XTableStudentWeeklyReward = { + Id = {ValueType = "int"}, + Level = {ValueType = "int"}, + Count = {ValueType = "int"}, + RewardId = {ValueType = "int"}, + }, + XTableMentorConfig = { + Key = {ValueType = "string"}, + Comment = {ValueType = "string"}, + Value = {ValueType = "int"}, + }, + XTableMentorSystemTask = { + Id = {ValueType = "int"}, + TaskId = {ValueType = "int"}, + Weight = {ValueType = "int"}, + }, + XTableKizunaConfig = { + Id = {ValueType = "int"}, + Count = {ValueType = "int"}, + }, + XTableAnnouncement = { + Id = {ValueType = "int"}, + Des = {ValueType = "string"}, + Param = {Type = 1, ValueType = "string"}, + }, + XTableMentorTag = { + Id = {ValueType = "int"}, + Tab = {ValueType = "string"}, + Order = {ValueType = "int"}, + Bg = {ValueType = "string"}, + }, + XTableZhouMu = { + Id = {ValueType = "int"}, + ChapterId = {Type = 1, ValueType = "int"}, + TaskId = {Type = 1, ValueType = "int"}, + }, + XTableZhouMuChapter = { + Id = {ValueType = "int"}, + ConditionId = {Type = 1, ValueType = "int"}, + PrefabName = {ValueType = "string"}, + OrderId = {ValueType = "int"}, + StageId = {Type = 1, ValueType = "int"}, + }, + XTableCollectionWall = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Rank = {ValueType = "int"}, + Condition = {ValueType = "int"}, + InitBackgroundId = {ValueType = "int"}, + InitPedestalId = {ValueType = "int"}, + }, + XTableCollectionWallDecoration = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Type = {ValueType = "int"}, + Rank = {ValueType = "int"}, + UnlockType = {ValueType = "int"}, + Condition = {ValueType = "int"}, + Path = {ValueType = "string"}, + Icon = {ValueType = "string"}, + LockDesc = {ValueType = "string"}, + }, + XTableCollectionSize = { + Id = {ValueType = "int"}, + Size = {ValueType = "int"}, + GridNum = {ValueType = "int"}, + Scale = {ValueType = "float"}, + }, + XTableNieRSupportClient = { + SupportId = {ValueType = "int"}, + Name = {ValueType = "string"}, + UpLevelItem = {ValueType = "int"}, + UpSkillLevelItem = {ValueType = "int"}, + }, + XTableNieRSupportSkillClient = { + Id = {ValueType = "int"}, + SkillId = {ValueType = "int"}, + Level = {ValueType = "int"}, + Desc = {ValueType = "string"}, + Name = {ValueType = "string"}, + Icon = {ValueType = "string"}, + }, + XTableLuaFunctionParams = { + Id = {ValueType = "int"}, + FunctionName = {ValueType = "string"}, + Params = {Type = 1, ValueType = "string"}, + }, + XTableNpcBeHitChange = { + Id = {ValueType = "int"}, + LightHitTime = {ValueType = "fix"}, + HeavyHitTime = {ValueType = "fix"}, + HeavyHitChange = {ValueType = "int"}, + HitFlyChange = {ValueType = "int"}, + HitDownChange = {ValueType = "int"}, + SuppressChange = {ValueType = "int"}, + }, + XTableNpcFightEventImmunity = { + Id = {ValueType = "int"}, + }, + XTableMasterWeeklyTaskReward = { + TaskId = {ValueType = "int"}, + RewardId = {ValueType = "int"}, + }, + XTableChristmasTreeActivity = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + TimeId = {ValueType = "int"}, + TaskId = {Type = 1, ValueType = "int"}, + AttrName = {Type = 1, ValueType = "string"}, + OverallPrefab = {ValueType = "string"}, + PartPrefab = {Type = 1, ValueType = "string"}, + MaxDistance = {ValueType = "float"}, + LongClickOffset = {ValueType = "int"}, + StoryId = {Type = 1, ValueType = "string"}, + Time = {Type = 1, ValueType = "string"}, + }, + XTableChristmasTreeActivityOrnament = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + PartId = {Type = 1, ValueType = "int"}, + Attr = {Type = 1, ValueType = "int"}, + SubItemId = {ValueType = "int"}, + ItemId = {ValueType = "int"}, + SubItemCount = {ValueType = "int"}, + IsClearItem = {ValueType = "bool"}, + PosType = {Type = 1, ValueType = "int"}, + ResPath = {ValueType = "string"}, + Width = {ValueType = "int"}, + Height = {ValueType = "int"}, + PlaceScale = {ValueType = "float"}, + }, + XTableChristmasTreeActivityPart = { + Id = {ValueType = "int"}, + GroupId = {ValueType = "int"}, + SubId = {ValueType = "int"}, + Name = {ValueType = "string"}, + }, + XTableSceneModel = { + Id = {ValueType = "int"}, + ScenePath = {ValueType = "string"}, + ModelPath = {ValueType = "string"}, + }, + XTablePokemonActivity = { + Id = {ValueType = "int"}, + ActivityTimeId = {ValueType = "int"}, + Bg = {ValueType = "string"}, + Name = {ValueType = "string"}, + TaskTimeLimitId = {ValueType = "int"}, + }, + XTablePokemonInit = { + Id = {ValueType = "int"}, + DefaultEnergy = {ValueType = "int"}, + DefaultUnlockPositions = {Type = 1, ValueType = "int"}, + FirstMonsterIds = {Type = 1, ValueType = "int"}, + DefaultStageTimes = {ValueType = "int"}, + StageTimesMax = {ValueType = "int"}, + StageTimesRecoverInterval = {ValueType = "int"}, + DefaultTimeSupplyAccuTimes = {ValueType = "int"}, + TimeSupplyAccuInterval = {ValueType = "int"}, + TimeSupplyMaxCount = {ValueType = "int"}, + TimeSupplyRewardId = {ValueType = "int"}, + DramaId = {ValueType = "string"}, + HelpId = {ValueType = "int"}, + StageSkipTimesMax = {ValueType = "int"}, + SkipItemId = {ValueType = "int"}, + }, + XTablePokemonChapter = { + Id = {ValueType = "int"}, + ActivityId = {ValueType = "int"}, + ChapterType = {ValueType = "int"}, + TimeId = {ValueType = "int"}, + OpenCondition = {ValueType = "int"}, + }, + XTablePokemonChapterLocalConfig = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Background = {ValueType = "string"}, + Desc = {ValueType = "string"}, + ChapterTitleImage = {ValueType = "string"}, + ChapterScrollBg = {ValueType = "string"}, + PerPageStageCount = {ValueType = "int"}, + }, + XTablePokemonMonster = { + Id = {ValueType = "int"}, + Type = {ValueType = "int"}, + Career = {ValueType = "int"}, + NpcId = {ValueType = "int"}, + ModelId = {ValueType = "string"}, + EnergyCost = {ValueType = "int"}, + LevelTemplateId = {ValueType = "int"}, + StarTemplateId = {ValueType = "int"}, + AbilityRateMonster = {ValueType = "float"}, + AbilityRateHp = {ValueType = "float"}, + AbilityRateAttack = {ValueType = "float"}, + Name = {ValueType = "string"}, + Description = {ValueType = "string"}, + HeadIcon = {ValueType = "string"}, + SkillIds = {Type = 1, ValueType = "int"}, + RatingIcon = {ValueType = "string"}, + }, + XTablePokemonMonsterLevel = { + Level = {ValueType = "int"}, + CostItemId = {ValueType = "int"}, + CostItemCount = {ValueType = "int"}, + }, + XTablePokemonMonsterStar = { + Star = {ValueType = "int"}, + MaxLevel = {ValueType = "int"}, + CostItemId = {ValueType = "int"}, + CostItemCount = {ValueType = "int"}, + }, + XTablePokemonMonsterCareer = { + Career = {ValueType = "int"}, + RestraintCareer = {ValueType = "int"}, + Name = {ValueType = "string"}, + Icon = {ValueType = "string"}, + }, + XTablePokemonMonsterSkill = { + Id = {ValueType = "int"}, + Position = {ValueType = "int"}, + FightSkillId = {ValueType = "int"}, + UnlockStar = {ValueType = "int"}, + Name = {ValueType = "string"}, + Description = {ValueType = "string"}, + Icon = {ValueType = "string"}, + }, + XTablePokemonStage = { + Id = {ValueType = "int"}, + StageId = {ValueType = "int"}, + StageType = {ValueType = "int"}, + UnlockPosition = {ValueType = "int"}, + UnlockMaxEnergy = {ValueType = "int"}, + UnlockDesc = {ValueType = "string"}, + StageBg = {ValueType = "string"}, + BossHeadIcon = {ValueType = "string"}, + IsBossStage = {ValueType = "int"}, + ActivityId = {ValueType = "int"}, + ChapterId = {ValueType = "int"}, + StageMonsterId = {Type = 2, KeyType = "int", ValueType = "int"}, + ShowAbility = {Type = 2, KeyType = "int", ValueType = "int"}, + }, + XTablePokemonStageMonster = { + Id = {ValueType = "int"}, + Career = {ValueType = "int"}, + Level = {ValueType = "int"}, + Ability = {ValueType = "int"}, + HeadIcon = {ValueType = "string"}, + }, + XTablePokemonStageTemplate = { + Id = {ValueType = "int"}, + ChapterId = {ValueType = "int"}, + Index = {ValueType = "int"}, + Type = {ValueType = "int"}, + PosX = {ValueType = "int"}, + PosY = {ValueType = "int"}, + PosZ = {ValueType = "int"}, + ScaleX = {ValueType = "int"}, + ScaleY = {ValueType = "int"}, + ScaleZ = {ValueType = "int"}, + }, + XTableCharacterFilter = { + Id = {ValueType = "int"}, + TagGroups = {Type = 1, ValueType = "int"}, + }, + XTableCharacterFilterTagGroup = { + Id = {ValueType = "int"}, + GroupName = {ValueType = "string"}, + Tags = {Type = 1, ValueType = "int"}, + }, + XTableCharacterFilterTag = { + Id = {ValueType = "int"}, + TagName = {ValueType = "string"}, + CharacterType = {ValueType = "int"}, + Value = {ValueType = "int"}, + }, + XTableCharacterSort = { + Id = {ValueType = "int"}, + Tags = {Type = 1, ValueType = "int"}, + }, + XTableCharacterSortTag = { + Id = {ValueType = "int"}, + TagName = {ValueType = "string"}, + CharacterType = {ValueType = "int"}, + }, + XTableGuardCampActivity = { + Id = {ValueType = "int"}, + OpenTimeId = {ValueType = "int"}, + SupportTimeId = {ValueType = "int"}, + SupportItemId = {ValueType = "int"}, + RewardPondItemId = {ValueType = "int"}, + SelectCampNeedCount = {ValueType = "int"}, + PerSupportNum = {ValueType = "int"}, + TotalSupportCount = {ValueType = "int"}, + WinPersonalRate = {ValueType = "float"}, + WinPontRate = {ValueType = "float"}, + LosePersonalRate = {ValueType = "float"}, + LosePontRate = {ValueType = "float"}, + ResultMailId = {ValueType = "int"}, + CampId = {Type = 1, ValueType = "int"}, + JoinNum = {Type = 1, ValueType = "int"}, + PondAdd = {Type = 1, ValueType = "int"}, + DrawLotteryTime = {ValueType = "string"}, + ShowDrawLotteryTime = {ValueType = "string"}, + JoinCampPurchasePackageUiType = {ValueType = "int"}, + JoinCampPurchasePackageId = {ValueType = "int"}, + SupportCampPurchasePackageUiType = {ValueType = "int"}, + SupportCampPurchasePackageId = {ValueType = "int"}, + }, + XTableChessPursuitMapGroup = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Rank = {ValueType = "int"}, + TimeId = {ValueType = "int"}, + ActivityName = {ValueType = "string"}, + EntryTexture = {ValueType = "string"}, + }, + XTableChessPursuitMapGroupReward = { + Id = {ValueType = "int"}, + GroupId = {ValueType = "int"}, + StartRange = {ValueType = "int"}, + EndRange = {ValueType = "int"}, + RewardShowId = {ValueType = "int"}, + MailId = {ValueType = "int"}, + }, + XTableChessPursuitMap = { + Id = {ValueType = "int"}, + GroupId = {ValueType = "int"}, + CoinId = {ValueType = "int"}, + OpenCondition = {Type = 1, ValueType = "int"}, + InitCoin = {ValueType = "int"}, + InitFunc = {Type = 1, ValueType = "int"}, + BossId = {ValueType = "int"}, + GridCount = {ValueType = "int"}, + CardMaxCount = {ValueType = "int"}, + AddCoin = {ValueType = "int"}, + ShopCardId = {ValueType = "int"}, + TestRoleGroup = {Type = 1, ValueType = "int"}, + TeamGrid = {Type = 1, ValueType = "int"}, + TaskId = {ValueType = "int"}, + RewardId = {ValueType = "int"}, + Perfab = {ValueType = "string"}, + Stage = {ValueType = "int"}, + RewardShow = {ValueType = "int"}, + StageName = {ValueType = "string"}, + FinishAddCoin = {ValueType = "int"}, + IsCanAutoClear = {ValueType = "int"}, + }, + XTableChessPursuitMapInitFunc = { + Id = {ValueType = "int"}, + Type = {ValueType = "int"}, + Param = {Type = 1, ValueType = "int"}, + }, + XTableChessPursuitBoss = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Perfab = {ValueType = "string"}, + StageId = {ValueType = "int"}, + BossBg = {ValueType = "string"}, + HeadIcon = {ValueType = "string"}, + }, + XTableChessPursuitTestRole = { + Id = {ValueType = "int"}, + RoleId = {Type = 1, ValueType = "int"}, + }, + XTableChessPursuitCard = { + Id = {ValueType = "int"}, + TargetType = {ValueType = "int"}, + EffectId = {ValueType = "int"}, + SubCoin = {ValueType = "int"}, + Describe = {ValueType = "string"}, + Quality = {ValueType = "int"}, + Icon = {ValueType = "string"}, + QualityIcon = {ValueType = "string"}, + HeadIcon = {ValueType = "string"}, + Name = {ValueType = "string"}, + QualityIconSmall = {ValueType = "string"}, + Effect = {ValueType = "string"}, + ShopBgQualityIcon = {ValueType = "string"}, + TipsQualityIconBg = {ValueType = "string"}, + QualityIconTips = {ValueType = "string"}, + }, + XTableChessPursuitCardEffect = { + Id = {ValueType = "int"}, + EffctTrigger = {ValueType = "int"}, + EffectType = {ValueType = "int"}, + Param = {Type = 1, ValueType = "int"}, + KeepType = {ValueType = "int"}, + KeepCount = {ValueType = "int"}, + KeepTypeDesc = {ValueType = "string"}, + }, + XTableChessPursuitStep = { + Id = {ValueType = "int"}, + Step = {ValueType = "int"}, + Icon = {ValueType = "string"}, + }, + XTableChessPursuitMapCardShop = { + Id = {ValueType = "int"}, + CardId = {Type = 1, ValueType = "int"}, + }, + XTableGuardCamp = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + RewardId = {ValueType = "int"}, + }, + XTableCampTicketCorrection = { + Id = {ValueType = "int"}, + MinValue = {ValueType = "int"}, + MaxValue = {ValueType = "int"}, + }, + XTableFootStepEffect = { + FootStepSize = {ValueType = "int"}, + StepMaterialDic = {Type = 2, KeyType = "int", ValueType = "string"}, + }, + XTableFootStepSize = { + NpcId = {ValueType = "int"}, + FootStepSize = {ValueType = "int"}, + FallDownSize = {ValueType = "int"}, + }, + XTablePreloadPartnerSkill = { + Npc = {ValueType = "int"}, + Type = {ValueType = "int"}, + Skills = {Type = 1, ValueType = "int"}, + }, + XTablePreloadPartnerResByMagic = { + Npc = {ValueType = "int"}, + Magic = {ValueType = "int"}, + Model = {ValueType = "string"}, + Skills = {Type = 1, ValueType = "int"}, + }, + XTableGachaProbShow = { + Id = {ValueType = "int"}, + GachaId = {ValueType = "int"}, + IsRare = {ValueType = "bool"}, + Name = {ValueType = "string"}, + Type = {ValueType = "string"}, + ProbShow = {Type = 1, ValueType = "string"}, + }, + XTableGachaRule = { + Id = {ValueType = "int"}, + GachaName = {ValueType = "string"}, + GachaName2 = {ValueType = "string"}, + UiType = {ValueType = "int"}, + UiName = {ValueType = "string"}, + SceneModelId = {ValueType = "int"}, + RuleHint = {ValueType = "string"}, + PreviewShowCount = {ValueType = "int"}, + ItemNotEnoughSkipId = {ValueType = "int"}, + BaseRuleTitles = {Type = 1, ValueType = "string"}, + BaseRules = {Type = 1, ValueType = "string"}, + }, + XTableCanNotGiveWafer = { + WaferId = {ValueType = "int"}, + }, + XTableFestivalStage = { + StageId = {ValueType = "int"}, + StageName = {ValueType = "string"}, + StageStyle = {ValueType = "string"}, + OpenConditionId = {Type = 1, ValueType = "int"}, + }, + XTableComposeClientConfig = { + Id = {ValueType = "int"}, + ActId = {ValueType = "int"}, + ItemDefaultWorldDesc = {ValueType = "string"}, + ItemDefaultDescription = {ValueType = "string"}, + DebugMode = {ValueType = "int"}, + UseDebugTime = {ValueType = "int"}, + DebugStartTime = {ValueType = "string"}, + DebugEndTime = {ValueType = "string"}, + BeginStoryId = {ValueType = "string"}, + }, + XTableComposeGame = { + Id = {ValueType = "int"}, + TimeId = {ValueType = "int"}, + CoinId = {ValueType = "int"}, + RefreshCountLimit = {ValueType = "int"}, + RefreshTimeSec = {ValueType = "int"}, + MaxSchedule = {ValueType = "int"}, + ShopRandCount = {ValueType = "int"}, + Schedule = {Type = 1, ValueType = "int"}, + RewardId = {Type = 1, ValueType = "int"}, + }, + XTableComposeGoods = { + Id = {ValueType = "int"}, + ActId = {ValueType = "int"}, + OrderId = {ValueType = "int"}, + Name = {ValueType = "string"}, + BigIcon = {ValueType = "string"}, + SmallIcon = {ValueType = "string"}, + Star = {ValueType = "int"}, + Quality = {ValueType = "int"}, + ComposeId = {ValueType = "int"}, + ComposeNeedNum = {ValueType = "int"}, + CostCoinNum = {ValueType = "int"}, + GainSchedule = {ValueType = "int"}, + FinalSchedule = {ValueType = "int"}, + }, + XTableComposeShop = { + Id = {ValueType = "int"}, + ActId = {ValueType = "int"}, + Schedule = {Type = 1, ValueType = "int"}, + Goods = {Type = 1, ValueType = "int"}, + Weight = {Type = 1, ValueType = "int"}, + }, + XTableLotto = { + Id = {ValueType = "int"}, + TimeId = {ValueType = "int"}, + LottoGroupId = {ValueType = "int"}, + Priority = {ValueType = "int"}, + Banner = {ValueType = "string"}, + ReachRewardTimes = {ValueType = "int"}, + ExtraRewardId = {ValueType = "int"}, + ConsumeId = {ValueType = "int"}, + BuyTicketRuleIdList = {Type = 1, ValueType = "int"}, + ConsumeCountList = {Type = 1, ValueType = "int"}, + }, + XTableLottoReward = { + Id = {ValueType = "int"}, + LottoId = {ValueType = "int"}, + TemplateId = {ValueType = "int"}, + Count = {ValueType = "int"}, + Params = {Type = 1, ValueType = "int"}, + Weights = {Type = 1, ValueType = "int"}, + }, + XTableLottoProbShow = { + Id = {ValueType = "int"}, + LottoId = {ValueType = "int"}, + RareLevel = {ValueType = "int"}, + Priority = {ValueType = "int"}, + ProbShow = {Type = 1, ValueType = "string"}, + }, + XTableLottoGroupRule = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Tag = {ValueType = "int"}, + Priority = {ValueType = "int"}, + UiType = {ValueType = "int"}, + GroupBtnBg = {ValueType = "string"}, + UiPrefab = {ValueType = "string"}, + Banner = {ValueType = "string"}, + UiBackGround = {ValueType = "string"}, + RuleHint = {ValueType = "string"}, + BaseRuleTitles = {Type = 1, ValueType = "string"}, + BaseRules = {Type = 1, ValueType = "string"}, + }, + XTableLottoBuyTicketRule = { + Id = {ValueType = "int"}, + UseItemId = {Type = 2, KeyType = "int", ValueType = "int"}, + Sale = {Type = 2, KeyType = "int", ValueType = "string"}, + UseItemCount = {Type = 2, KeyType = "int", ValueType = "int"}, + UseItemImg = {Type = 2, KeyType = "int", ValueType = "string"}, + TargetItemCount = {ValueType = "int"}, + TargetItemImg = {ValueType = "string"}, + }, + XTableCommonBall = { + Id = {ValueType = "int"}, + Icon = {ValueType = "string"}, + ReleaseEffect = {ValueType = "string"}, + ExEffect = {ValueType = "string"}, + LinkEffect = {ValueType = "string"}, + ClickEffect = {ValueType = "string"}, + }, + XTableCoupletActivityBase = { + Id = {ValueType = "int"}, + TimeId = {ValueType = "int"}, + ConsumeItemId = {ValueType = "int"}, + HelpId = {ValueType = "int"}, + Title = {ValueType = "string"}, + TitleEn = {ValueType = "string"}, + EffectDelay = {ValueType = "string"}, + StoryId = {ValueType = "string"}, + }, + XTableCouplet = { + Id = {ValueType = "int"}, + ActivityId = {ValueType = "int"}, + ItemConsumeCount = {ValueType = "int"}, + TitleName = {ValueType = "string"}, + StoryStr = {ValueType = "string"}, + BatchUrl = {ValueType = "string"}, + DefaultBatchUrl = {ValueType = "string"}, + UpImgUrl = {ValueType = "string"}, + DownImgUrl = {ValueType = "string"}, + UpWordId = {Type = 1, ValueType = "int"}, + DownWordId = {Type = 1, ValueType = "string"}, + DownIdPool = {Type = 1, ValueType = "string"}, + }, + XTabelCoupletWord = { + Id = {ValueType = "int"}, + WordImageUrl = {ValueType = "string"}, + }, + XTableStrongholdActivity = { + Id = {ValueType = "int"}, + OpenTimeId = {ValueType = "int"}, + OneCycleSeconds = {ValueType = "int"}, + AutoBeginSeconds = {ValueType = "int"}, + FightContinueSeconds = {ValueType = "int"}, + IsNoPrize = {ValueType = "bool"}, + DistributionId = {Type = 1, ValueType = "int"}, + }, + XTableStrongholdCfg = { + Key = {ValueType = "string"}, + Value = {ValueType = "int"}, + Comment = {ValueType = "string"}, + }, + XTableStrongholdChapter = { + Id = {ValueType = "int"}, + GroupId = {Type = 1, ValueType = "int"}, + Name = {ValueType = "string"}, + Bg = {ValueType = "string"}, + Prefab = {ValueType = "string"}, + }, + XTableStrongholdBuff = { + Id = {ValueType = "int"}, + Condition = {Type = 1, ValueType = "int"}, + FightEventId = {Type = 1, ValueType = "int"}, + Icon = {ValueType = "string"}, + Name = {ValueType = "string"}, + Desc = {ValueType = "string"}, + }, + XTableStrongholdBuffGroup = { + Id = {ValueType = "int"}, + BuffId = {Type = 1, ValueType = "int"}, + }, + XTableStrongholdDistribution = { + Id = {ValueType = "int"}, + RuneRuleId = {ValueType = "int"}, + Group = {Type = 1, ValueType = "int"}, + ConstantStageGroupIndex = {Type = 1, ValueType = "string"}, + RandomStageGroupIndex = {Type = 1, ValueType = "string"}, + RandomStageGroupCount = {Type = 1, ValueType = "int"}, + SupportGroup = {Type = 1, ValueType = "string"}, + }, + XTableStrongholdElectric = { + Id = {ValueType = "int"}, + ElectricEnerge = {Type = 2, KeyType = "int", ValueType = "int"}, + }, + XTableStrongholdEndurance = { + Id = {ValueType = "int"}, + Endurance = {Type = 2, KeyType = "int", ValueType = "int"}, + }, + XTableStrongholdGroup = { + Id = {ValueType = "int"}, + PreId = {ValueType = "int"}, + Order = {ValueType = "string"}, + Name = {ValueType = "string"}, + DetailDesc = {ValueType = "string"}, + Prefab = {ValueType = "string"}, + IconBg = {ValueType = "string"}, + IconBoss = {ValueType = "string"}, + DetailBg = {ValueType = "string"}, + FinishRelatedId = {Type = 1, ValueType = "int"}, + Endurance = {ValueType = "int"}, + RewardId = {Type = 2, KeyType = "int", ValueType = "int"}, + TeamMember = {Type = 1, ValueType = "int"}, + DistributionGroup = {ValueType = "int"}, + BuffGroup = {Type = 1, ValueType = "string"}, + RobotGroup = {Type = 2, KeyType = "int", ValueType = "int"}, + StageIdGroup = {Type = 1, ValueType = "string"}, + BaseBuffId = {Type = 1, ValueType = "string"}, + StageBuffId = {Type = 1, ValueType = "string"}, + }, + XTableStrongholdPlugin = { + Id = {ValueType = "int"}, + BuffId = {ValueType = "int"}, + CountLimit = {ValueType = "int"}, + UseElectric = {ValueType = "int"}, + FightAbility = {ValueType = "int"}, + Name = {ValueType = "string"}, + Desc = {ValueType = "string"}, + Icon = {ValueType = "string"}, + }, + XTableStrongholdSupport = { + Id = {ValueType = "int"}, + RequireAbility = {ValueType = "int"}, + Condition = {Type = 1, ValueType = "int"}, + BuffId = {Type = 1, ValueType = "int"}, + }, + XTableStrongholdTeamElectric = { + Id = {ValueType = "int"}, + ElectricEnerge = {ValueType = "int"}, + }, + XTableStrongholdBorrowCost = { + Id = {ValueType = "int"}, + ItemId = {ValueType = "int"}, + ItemCount = {ValueType = "int"}, + }, + XTableStrongholdRobotGroup = { + Id = {ValueType = "int"}, + RobotId = {Type = 1, ValueType = "int"}, + }, + XTableStrongholdReward = { + Id = {ValueType = "int"}, + LevelId = {ValueType = "int"}, + Condition = {ValueType = "int"}, + RewardId = {ValueType = "int"}, + SkipId = {ValueType = "int"}, + Desc = {ValueType = "string"}, + Offline = {ValueType = "int"}, + }, + XTableStrongholdLevel = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Icon = {ValueType = "string"}, + MinLevel = {ValueType = "int"}, + MaxLevel = {ValueType = "int"}, + InitElectricEnergy = {ValueType = "int"}, + InitEndurance = {ValueType = "int"}, + Chapter = {Type = 1, ValueType = "int"}, + }, + XTableStrongholdStageLevelControl = { + Id = {ValueType = "int"}, + StageId = {ValueType = "int"}, + LevelId = {ValueType = "int"}, + MonsterLevel = {Type = 1, ValueType = "int"}, + }, + XTableStrongholdRune = { + Id = {ValueType = "int"}, + FightEventId = {ValueType = "int"}, + SubRuneId = {Type = 1, ValueType = "int"}, + Icon = {ValueType = "string"}, + Name = {ValueType = "string"}, + Desc = {ValueType = "string"}, + Brief = {ValueType = "string"}, + Color = {ValueType = "string"}, + }, + XTableStrongholdSubRune = { + Id = {ValueType = "int"}, + FightEventId = {ValueType = "int"}, + Icon = {ValueType = "string"}, + Name = {ValueType = "string"}, + Desc = {ValueType = "string"}, + }, + XTableStrongholdRuneRule = { + Id = {ValueType = "int"}, + RuneCount = {ValueType = "int"}, + RuneId = {Type = 1, ValueType = "int"}, + }, + XTableSpringFestivalActivity = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + TimeId = {ValueType = "int"}, + Background = {ValueType = "string"}, + ChapterId = {ValueType = "int"}, + ActivitySkipId = {ValueType = "int"}, + ShopSkipId = {ValueType = "int"}, + CollectSkipId = {ValueType = "int"}, + TaskActivityId = {ValueType = "int"}, + CollectActivityId = {ValueType = "int"}, + CollectHelpId = {ValueType = "int"}, + SmashEggsHelpId = {ValueType = "int"}, + CollectWordBg = {ValueType = "string"}, + }, + XTableCollectWordsActivity = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + TimeId = {ValueType = "int"}, + Background = {ValueType = "string"}, + }, + XTableCollectWords = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + CanGiven = {ValueType = "bool"}, + Type = {ValueType = "int"}, + }, + XTableCollectWordsReward = { + Id = {ValueType = "int"}, + MagnaItem = {ValueType = "int"}, + ActivityId = {ValueType = "int"}, + Name = {ValueType = "string"}, + CostItem = {Type = 1, ValueType = "int"}, + CostCount = {Type = 1, ValueType = "int"}, + Reward = {Type = 1, ValueType = "int"}, + }, + XTableCollectWordsFullReward = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Type = {ValueType = "int"}, + Weight = {ValueType = "int"}, + RewardCount = {ValueType = "int"}, + RewardId = {ValueType = "int"}, + }, + XTableCollectWordsJackpotRewardRate = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Type = {ValueType = "int"}, + Rate = {ValueType = "int"}, + }, + XTableSmashEggsActivity = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + TimeId = {ValueType = "int"}, + Background = {ValueType = "string"}, + }, + XTableSmashEggsActivation = { + Id = {ValueType = "int"}, + Day = {ValueType = "int"}, + Index = {ValueType = "int"}, + TargetScore = {ValueType = "int"}, + RewardId = {ValueType = "int"}, + DropId = {ValueType = "int"}, + }, + XTableSmashEggsScoreConfig = { + Id = {ValueType = "int"}, + InitScore = {ValueType = "int"}, + FirstScore = {ValueType = "int"}, + AddScoreType = {ValueType = "int"}, + AddScore = {ValueType = "int"}, + FailureReduceType = {ValueType = "int"}, + FailureScore = {ValueType = "int"}, + MaxScore = {ValueType = "int"}, + SucceedDropId = {ValueType = "int"}, + FailureDropId = {ValueType = "int"}, + ScoreConvertItemId = {ValueType = "int"}, + NeedTipCount = {ValueType = "int"}, + }, + XTableSmashEggsBuffItem = { + Id = {ValueType = "int"}, + ItemId = {ValueType = "int"}, + Name = {ValueType = "string"}, + IsFree = {ValueType = "bool"}, + InitCount = {ValueType = "int"}, + BuffType = {ValueType = "int"}, + BuffProb = {ValueType = "int"}, + SuccessRate = {Type = 1, ValueType = "int"}, + Desc = {ValueType = "string"}, + }, + XTableSmashEggsEggPlace = { + Id = {ValueType = "int"}, + PlaceCount = {ValueType = "int"}, + }, + XTableSettleLoseTip = { + Id = {ValueType = "int"}, + TipDesc = {Type = 1, ValueType = "string"}, + SkipId = {Type = 1, ValueType = "int"}, + }, + XTableRLNpcMultiModel = { + NpcId = {ValueType = "int"}, + Models = {Type = 1, ValueType = "string"}, + }, + XTablePartner = { + Id = {ValueType = "int"}, + NpcId = {ValueType = "int"}, + Name = {ValueType = "string"}, + Desc = {ValueType = "string"}, + RecommendElement = {Type = 1, ValueType = "int"}, + Icon = {ValueType = "string"}, + Priority = {ValueType = "int"}, + InitQuality = {ValueType = "int"}, + CarryCharacterType = {ValueType = "int"}, + ChipItemId = {ValueType = "int"}, + ChipNeedCount = {ValueType = "int"}, + DefaultLock = {ValueType = "bool"}, + GoodsDesc = {ValueType = "string"}, + GoodsWorldDesc = {ValueType = "string"}, + DecomposeItemId = {Type = 1, ValueType = "int"}, + DecomposeItemCount = {Type = 1, ValueType = "int"}, + }, + XTablePartnerLevelUp = { + Level = {ValueType = "int"}, + Exp = {ValueType = "int"}, + AllExp = {ValueType = "int"}, + }, + XTablePartnerBreakThrough = { + Id = {ValueType = "int"}, + PartnerId = {ValueType = "int"}, + BreakTimes = {ValueType = "int"}, + LevelLimit = {ValueType = "int"}, + AttribId = {ValueType = "int"}, + AttribPromotedId = {ValueType = "int"}, + LevelUpTemplateId = {ValueType = "int"}, + CostItemId = {Type = 1, ValueType = "int"}, + CostItemCount = {Type = 1, ValueType = "int"}, + }, + XTablePartnerQuality = { + Id = {ValueType = "int"}, + PartnerId = {ValueType = "int"}, + Quality = {ValueType = "int"}, + SkillColumnCount = {ValueType = "int"}, + EvolutionAttrId = {ValueType = "int"}, + EvolutionCostItemId = {Type = 1, ValueType = "int"}, + EvolutionCostItemCount = {Type = 1, ValueType = "int"}, + StarCostChipCount = {Type = 1, ValueType = "int"}, + AttrId = {Type = 1, ValueType = "int"}, + }, + XTablePartnerSkill = { + PartnerId = {ValueType = "int"}, + UpgradeCostItemId = {Type = 1, ValueType = "int"}, + UpgradeCostItemCount = {Type = 1, ValueType = "int"}, + DefaultMainSkillGroupId = {ValueType = "int"}, + MainSkillGroupId = {Type = 1, ValueType = "int"}, + PassiveSkillGroupId = {Type = 1, ValueType = "int"}, + }, + XTablePartnerMainSkillGroup = { + Id = {ValueType = "int"}, + ConditionId = {ValueType = "int"}, + SkillId = {Type = 2, KeyType = "int", ValueType = "int"}, + Element = {Type = 2, KeyType = "int", ValueType = "int"}, + }, + XTablePartnerPassiveSkillGroup = { + Id = {ValueType = "int"}, + SkillId = {Type = 1, ValueType = "int"}, + }, + XTablePartnerSkillEffect = { + Id = {ValueType = "int"}, + SkillId = {ValueType = "int"}, + Level = {ValueType = "int"}, + Ability = {ValueType = "int"}, + BornMagic = {Type = 1, ValueType = "int"}, + SubSkillId = {Type = 1, ValueType = "int"}, + SubMagicId = {Type = 1, ValueType = "int"}, + }, + XTablePartnerSkillInfo = { + Id = {ValueType = "int"}, + SkillId = {ValueType = "int"}, + Level = {ValueType = "int"}, + Name = {ValueType = "string"}, + Icon = {ValueType = "string"}, + Desc = {ValueType = "string"}, + }, + XTablePartnerSkillWeight = { + Level = {ValueType = "int"}, + Weight = {ValueType = "int"}, + }, + XTablePartnerModel = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + StandbyModel = {ValueType = "string"}, + CombatModel = {ValueType = "string"}, + SToCAnime = {ValueType = "string"}, + StandbyBornAnime = {ValueType = "string"}, + CToSAnime = {ValueType = "string"}, + CombatBornAnime = {ValueType = "string"}, + SToCVoice = {ValueType = "int"}, + CToSVoice = {ValueType = "int"}, + SToCEffect = {ValueType = "string"}, + StandbyBornEffect = {ValueType = "string"}, + CToSEffect = {ValueType = "string"}, + CombatBornEffect = {ValueType = "string"}, + }, + XTablePartnerStory = { + PartnerId = {ValueType = "int"}, + StoryId = {Type = 2, KeyType = "int", ValueType = "int"}, + ConditionId = {Type = 2, KeyType = "int", ValueType = "int"}, + }, + XTablePartnerStoryDetail = { + Id = {ValueType = "int"}, + Title = {ValueType = "string"}, + Desc = {ValueType = "string"}, + }, + XTablePartnerItemSkipId = { + PartnerId = {ValueType = "int"}, + LevelUpSkipIdParams = {Type = 1, ValueType = "int"}, + ClipSkipIdParams = {Type = 1, ValueType = "int"}, + StageSkipIdParam = {ValueType = "int"}, + }, + XTableSimulatedCombatActivity = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + HardConditionId = {ValueType = "int"}, + TimeId = {ValueType = "int"}, + ChapterPrefab = {Type = 1, ValueType = "string"}, + ConsumeIds = {Type = 1, ValueType = "int"}, + ConsumeCountLimit = {Type = 1, ValueType = "int"}, + ConsumeInitCounts = {Type = 1, ValueType = "int"}, + PointId = {ValueType = "int"}, + MaxDailyStageStarRewardCount = {ValueType = "int"}, + BannerBg = {ValueType = "string"}, + }, + XTableSimulatedCombatAddition = { + Id = {ValueType = "int"}, + FightEventId = {ValueType = "int"}, + Name = {ValueType = "string"}, + Description = {ValueType = "string"}, + Icon = {ValueType = "string"}, + Star = {ValueType = "int"}, + ConsumeCounts = {Type = 1, ValueType = "int"}, + }, + XTableSimulatedCombatChallenge = { + Id = {ValueType = "int"}, + Type = {ValueType = "int"}, + Num = {ValueType = "int"}, + Description = {ValueType = "string"}, + }, + XTableSimulatedCombatMember = { + Id = {ValueType = "int"}, + RobotId = {ValueType = "int"}, + Star = {ValueType = "int"}, + ConsumeCounts = {Type = 1, ValueType = "int"}, + FightEventIds = {Type = 1, ValueType = "int"}, + }, + XTableSimulatedCombatPointReward = { + Id = {ValueType = "int"}, + NeedPoint = {ValueType = "int"}, + RewardId = {ValueType = "int"}, + ShowItem = {ValueType = "int"}, + ShowItemNum = {ValueType = "int"}, + }, + XTableSimulatedCombatStage = { + Id = {ValueType = "int"}, + StageId = {ValueType = "int"}, + Type = {ValueType = "int"}, + PrefabPath = {ValueType = "string"}, + IconPath = {ValueType = "string"}, + MemberIds = {Type = 1, ValueType = "int"}, + Additions = {Type = 1, ValueType = "int"}, + StarRewardIds = {Type = 2, KeyType = "int", ValueType = "int"}, + ChallengeIds = {Type = 1, ValueType = "int"}, + ShowFightEventIds = {Type = 1, ValueType = "int"}, + }, + XTableSimulatedCombatStarReward = { + Id = {ValueType = "int"}, + RequireStar = {ValueType = "int"}, + RewardId = {ValueType = "int"}, + }, + XTableWhiteValentinesDayConfig = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + TimeId = {ValueType = "int"}, + OpenConditionId = {ValueType = "int"}, + BgPicturePath = {ValueType = "string"}, + BgEffectPath = {ValueType = "string"}, + DefaultEnergy = {ValueType = "int"}, + MaxEnergy = {ValueType = "int"}, + EnergyRecoverySpeed = {ValueType = "int"}, + EnergyIconPath = {ValueType = "string"}, + ContributionItemId = {ValueType = "int"}, + CoinItemId = {ValueType = "int"}, + RandomMeetCostCoin = {ValueType = "int"}, + DefaultRoleId = {Type = 1, ValueType = "int"}, + }, + XTableWhiteValentinesDayEvent = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Description = {ValueType = "string"}, + AttrType = {ValueType = "int"}, + RankType = {Type = 1, ValueType = "int"}, + RankWeight = {Type = 1, ValueType = "int"}, + }, + XTableWhiteValentinesDayPlace = { + Id = {ValueType = "int"}, + OrderId = {ValueType = "int"}, + PrePlaceId = {ValueType = "int"}, + BgPath = {ValueType = "string"}, + InviteNum = {ValueType = "int"}, + DefaultEventId = {ValueType = "int"}, + RandomEventId = {Type = 1, ValueType = "int"}, + }, + XTableWhiteValentinesDayRank = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + IconPath = {ValueType = "string"}, + CostEnergy = {ValueType = "int"}, + CostTime = {ValueType = "int"}, + RewardContribution = {ValueType = "int"}, + RewardCoin = {ValueType = "int"}, + }, + XTableWhiteValentinesDayRole = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + IconPath = {ValueType = "string"}, + AttrType = {ValueType = "int"}, + AttrValue = {ValueType = "int"}, + EncounterStoryId = {ValueType = "int"}, + InviteStoryId = {ValueType = "int"}, + CommuId = {ValueType = "int"}, + CutDownTime = {ValueType = "int"}, + ContributionBuff = {ValueType = "int"}, + }, + XTableWhiteValentinesDayAttr = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + IconPath = {ValueType = "string"}, + }, + XTableWhiteValentinesDayStory = { + Id = {ValueType = "int"}, + Title = {ValueType = "string"}, + StoryText = {ValueType = "string"}, + }, + XTableStageRecommend = { + StageId = {ValueType = "int"}, + CharacterType = {ValueType = "int"}, + CharacterElement = {ValueType = "int"}, + }, + XTableSpecialShop = { + Id = {ValueType = "int"}, + ShopId = {ValueType = "int"}, + TimeId = {ValueType = "int"}, + }, + XTableFashionSeries = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + }, + XTableMoeWarActivity = { + Id = {ValueType = "int"}, + ActivityTimeId = {ValueType = "int"}, + GroupName = {Type = 1, ValueType = "string"}, + CurrencyId = {Type = 1, ValueType = "int"}, + GroupSecondName = {Type = 1, ValueType = "string"}, + Name = {ValueType = "string"}, + Background = {ValueType = "string"}, + ShopIds = {Type = 1, ValueType = "int"}, + }, + XTableMoeWarActivityConfig = { + Id = {ValueType = "int"}, + GachaSkipId = {ValueType = "int"}, + ShowItem = {Type = 1, ValueType = "int"}, + RewardSkipId = {ValueType = "int"}, + WebUrl = {ValueType = "string"}, + BeginStoryId = {ValueType = "string"}, + MainHelpId = {ValueType = "int"}, + VoteHelpId = {ValueType = "int"}, + }, + XTableMoeWarMatch = { + Id = {ValueType = "int"}, + MatchName = {ValueType = "string"}, + MatchSubName = {ValueType = "string"}, + SessionId = {ValueType = "int"}, + Type = {ValueType = "int"}, + TypeName = {ValueType = "string"}, + TimeId = {ValueType = "int"}, + RefreshVoteHour = {Type = 1, ValueType = "int"}, + CoverImg = {ValueType = "string"}, + Des = {Type = 1, ValueType = "string"}, + DailyLimitCount = {ValueType = "int"}, + FinalImg = {ValueType = "string"}, + }, + XTableMoeWarIconConfig = { + Id = {ValueType = "int"}, + IconList = {Type = 1, ValueType = "string"}, + }, + XTableMoeWarPlayer = { + Id = {ValueType = "int"}, + Group = {ValueType = "int"}, + }, + XTableMoeRankGroup = { + RankType = {ValueType = "int"}, + TagName = {ValueType = "string"}, + HasSub = {ValueType = "bool"}, + IsSub = {ValueType = "bool"}, + Title = {ValueType = "string"}, + ResetTip = {ValueType = "string"}, + }, + XTableMoeWarPlayerLocal = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + ModelName = {ValueType = "string"}, + CareerName = {ValueType = "string"}, + CareerIcon = {ValueType = "string"}, + CampName = {ValueType = "string"}, + Description = {ValueType = "string"}, + IntroAnim = {ValueType = "string"}, + IntroCv = {ValueType = "int"}, + IntroLength = {ValueType = "float"}, + ThankAnim = {ValueType = "string"}, + ThankCv = {ValueType = "int"}, + ThankLength = {ValueType = "float"}, + SquareHead = {ValueType = "string"}, + CircleHead = {ValueType = "string"}, + ActionBg = {ValueType = "string"}, + BigCharacterImage = {ValueType = "string"}, + ShareImg = {ValueType = "string"}, + WinAnimGroupId = {Type = 1, ValueType = "int"}, + LoseAnimGroupId = {Type = 1, ValueType = "int"}, + }, + XTableMoeWarInitPair = { + Id = {ValueType = "int"}, + GroupId = {ValueType = "int"}, + PlayerId = {Type = 1, ValueType = "int"}, + }, + XTableMoeWarVoteItem = { + ItemId = {ValueType = "int"}, + Multiple = {ValueType = "int"}, + VoteFactor = {ValueType = "float"}, + CoinFactor = {ValueType = "float"}, + IsLimit = {ValueType = "int"}, + MatchId = {Type = 1, ValueType = "int"}, + DailyLimitCount = {Type = 1, ValueType = "int"}, + No = {ValueType = "int"}, + }, + XTableMoeWarMail = { + Id = {ValueType = "int"}, + Type = {ValueType = "int"}, + MailId = {ValueType = "int"}, + MatchId = {ValueType = "int"}, + Desc = {ValueType = "string"}, + }, + XTableMoeWarTaskGroup = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Type = {ValueType = "int"}, + Group = {ValueType = "int"}, + }, + XTableSignDrawNewYear = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + PrefabPath = {ValueType = "string"}, + OpenLevel = {ValueType = "int"}, + StartTimeStr = {ValueType = "string"}, + CloseTimeStr = {ValueType = "string"}, + RuleTitle = {Type = 1, ValueType = "string"}, + RuleContent = {Type = 1, ValueType = "string"}, + GaChaId = {ValueType = "int"}, + }, + XTableActivityBossOnlineOpenTime = { + Id = {ValueType = "int"}, + BeginTime = {ValueType = "string"}, + EndTime = {ValueType = "string"}, + }, + XTablePurchaseYKIcon = { + Id = {ValueType = "int"}, + Path = {ValueType = "string"}, + }, + XTableSlotMachines = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + DifferentAddScore = {ValueType = "int"}, + TwoSameAddScore = {ValueType = "int"}, + ConsumeItemId = {ValueType = "int"}, + ConsumeCount = {ValueType = "int"}, + UnlockNeedPreScore = {ValueType = "int"}, + ScoreLimit = {ValueType = "int"}, + BgImage = {ValueType = "string"}, + MachineImage = {ValueType = "string"}, + MachineLockImage = {ValueType = "string"}, + NextMachineBtnImage = {ValueType = "string"}, + NextMachineBtnText = {ValueType = "string"}, + RulesIds = {Type = 1, ValueType = "int"}, + Icons = {Type = 1, ValueType = "int"}, + Weights = {Type = 1, ValueType = "int"}, + RewardIds = {Type = 1, ValueType = "int"}, + RewardScores = {Type = 1, ValueType = "int"}, + PrixBottomTimes = {ValueType = "int"}, + TenTimesPrixLimit = {ValueType = "int"}, + TaskDailyLimitId = {ValueType = "int"}, + TaskCumulativeLimitId = {ValueType = "int"}, + MailId = {ValueType = "int"}, + }, + XTableSlotMachinesActivity = { + Id = {ValueType = "int"}, + StartTimeStr = {ValueType = "string"}, + EndTimeStr = {ValueType = "string"}, + ExchangeRatio = {ValueType = "int"}, + ExchangeType = {ValueType = "int"}, + SlotMachinesIds = {Type = 1, ValueType = "int"}, + }, + XTableSlotMachinesIcon = { + Id = {ValueType = "int"}, + IconName = {ValueType = "string"}, + IconImage = {ValueType = "string"}, + Score = {ValueType = "int"}, + IsPrix = {ValueType = "bool"}, + }, + XTableSlotMachinesRules = { + Id = {ValueType = "int"}, + Title = {ValueType = "string"}, + Desc = {ValueType = "string"}, + }, + XTableRooot = { + Id = {ValueType = "string"}, + RewardId = {ValueType = "int"}, + ExchangeTimes = {ValueType = "int"}, + }, + XTableRoootActivity = { + Id = {ValueType = "int"}, + ActivityTimeId = {ValueType = "int"}, + RegisterTimeId = {ValueType = "int"}, + MailId = {ValueType = "int"}, + }, + XTableAnniversary = { + Id = {ValueType = "string"}, + PlayerType = {ValueType = "int"}, + MailId = {ValueType = "int"}, + }, + XTableFireworks = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + PrefabPath = {ValueType = "string"}, + OpenLevel = {ValueType = "int"}, + OpenStage = {ValueType = "int"}, + StartTimeStr = {ValueType = "string"}, + CloseTimeStr = {ValueType = "string"}, + DailyResetTimes = {ValueType = "int"}, + }, + XTableFireworksReward = { + Id = {ValueType = "int"}, + FireworksId = {ValueType = "int"}, + DropId = {ValueType = "int"}, + Weight = {ValueType = "int"}, + FireworksEffects = {ValueType = "int"}, + FireworksDes = {ValueType = "string"}, + }, + XTableSignFireworks = { + Id = { ValueType = "int" }, + Name = { ValueType = "string" }, + PrefabPath = { ValueType = "string" } + }, + XTableFireworksRules = { + Id = { ValueType = "int" }, + RuleTitle = {Type = 1, ValueType = "string"}, + RuleContent = {Type = 1, ValueType = "string"} + }, + XTableFingerGuessingActivity = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + TimeId = {ValueType = "int"}, + CoinItemId = {ValueType = "int"}, + DefaultCoinNum = {ValueType = "int"}, + HeroName = {ValueType = "string"}, + HeroImage = {ValueType = "string"}, + PlayerPortraits = {ValueType = "string"}, + }, + XTableFingerGuessingStage = { + Id = {ValueType = "int"}, + StageId = {ValueType = "int"}, + StageName = {ValueType = "string"}, + LockStageName = {ValueType = "string"}, + Description = {ValueType = "string"}, + OpenEyeTipsTitle = {ValueType = "string"}, + OpenEyeTipsContent = {ValueType = "string"}, + WinTalk = {ValueType = "string"}, + LoseTalk = {ValueType = "string"}, + RobotImage = {ValueType = "string"}, + RobotPortraits = {ValueType = "string"}, + StageLockRobotPortraits = {ValueType = "string"}, + CostItemCount = {ValueType = "int"}, + CheatCount = {ValueType = "int"}, + PreStageId = {ValueType = "int"}, + WinScore = {ValueType = "int"}, + }, + XTableFingerGuessingStageRound = { + Id = {ValueType = "int"}, + StageId = {ValueType = "int"}, + Round = {ValueType = "int"}, + Tricks = {Type = 1, ValueType = "bool"}, + }, + XTableFingerGuessingFinger = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Icon = {ValueType = "string"}, + }, + XTableMoeWarPreparationActivity = { + Id = {ValueType = "int"}, + TimeId = {ValueType = "int"}, + MatchIds = {Type = 1, ValueType = "int"}, + InitStageCount = {ValueType = "int"}, + MaxStageCount = {ValueType = "int"}, + StageRecoveryTime = {ValueType = "int"}, + CommunicateItemId = {ValueType = "int"}, + PreparationGears = {Type = 1, ValueType = "int"}, + Name = {ValueType = "string"}, + RedminNum = {ValueType = "int"}, + }, + XTableMoeWarPreparationAssistance = { + EffectId = {ValueType = "int"}, + VoteItemId = {ValueType = "int"}, + VoteItemCount = {ValueType = "int"}, + Level = {ValueType = "int"}, + Order = {ValueType = "int"}, + EffectType = {ValueType = "int"}, + Param = {ValueType = "int"}, + IsShowInList = {ValueType = "int"}, + Desc = {ValueType = "string"}, + Title = {ValueType = "string"}, + }, + XTableMoeWarPreparationGear = { + Id = {ValueType = "int"}, + NeedCount = {ValueType = "int"}, + RewardId = {ValueType = "int"}, + ShowRewardId = {ValueType = "int"}, + }, + XTableMoeWarPreparationHelper = { + Id = {ValueType = "int"}, + RobotId = {ValueType = "int"}, + Order = {ValueType = "int"}, + LabelIds = {Type = 1, ValueType = "int"}, + Duration = {ValueType = "int"}, + QuestionBankIds = {Type = 1, ValueType = "int"}, + QuestionCounts = {Type = 1, ValueType = "int"}, + CommunicateItemId = {ValueType = "int"}, + CommunicateConsumeCount = {ValueType = "int"}, + CirleIcon = {ValueType = "string"}, + }, + XTableMoeWarPreparationMatch = { + Id = {ValueType = "int"}, + TimeId = {ValueType = "int"}, + Name = {ValueType = "string"}, + HelperIds = {Type = 1, ValueType = "int"}, + StageIds = {Type = 1, ValueType = "int"}, + NumText = {ValueType = "string"}, + }, + XTableMoeWarPreparationQuestion = { + Id = {ValueType = "int"}, + BankId = {ValueType = "int"}, + HelperId = {ValueType = "int"}, + Type = {ValueType = "int"}, + Chat = {ValueType = "string"}, + ChatReply = {ValueType = "string"}, + PreChatId = {ValueType = "int"}, + Weight = {ValueType = "int"}, + Question = {ValueType = "string"}, + RightAnswer = {ValueType = "int"}, + Answers = {Type = 2, KeyType = "int", ValueType = "string"}, + RightReply = {ValueType = "string"}, + WrongReply = {ValueType = "string"}, + HelperIcon = {ValueType = "string"}, + HelperName = {ValueType = "string"}, + }, + XTableMoeWarPreparationStage = { + StageId = {ValueType = "int"}, + NormalWeight = {ValueType = "int"}, + Weights = {Type = 1, ValueType = "int"}, + LabelIds = {Type = 1, ValueType = "int"}, + BestHelperFightEventId = {ValueType = "int"}, + BaseRewardId = {ValueType = "int"}, + ShowBaseRewardId = {ValueType = "int"}, + ExtraRewardIds = {Type = 1, ValueType = "int"}, + ShowExtraRewardIds = {Type = 1, ValueType = "int"}, + ShowSpecialRewardId = {ValueType = "int"}, + ShowAllRewardId = {ValueType = "int"}, + }, + XTableMoeWarPreparationStageTagLabel = { + Id = {ValueType = "int"}, + TagLabel = {ValueType = "string"}, + }, + XTableMoeWarPreparationStageEvaluationLabel = { + ReachNum = {ValueType = "int"}, + EvaluatioLabel = {ValueType = "string"}, + }, + XTableMoeWarAnimationGroup = { + Id = {ValueType = "int"}, + InitModelName = {ValueType = "string"}, + InitAnim = {ValueType = "string"}, + AnimationId = {Type = 1, ValueType = "int"}, + }, + XTableMoeWarAnimation = { + Id = {ValueType = "int"}, + ModelName = {ValueType = "string"}, + Speed = {ValueType = "float"}, + Distance = {ValueType = "float"}, + AnimName = {ValueType = "string"}, + RoleEffect = {ValueType = "string"}, + RoleEffectRoot = {ValueType = "string"}, + SceneEffect = {ValueType = "string"}, + SceneEffectRoot = {ValueType = "string"}, + }, + XTableArchivePartner = { + Id = {ValueType = "int"}, + GroupId = {ValueType = "int"}, + Order = {ValueType = "int"}, + LockIconPath = {ValueType = "string"}, + IconPath = {ValueType = "string"}, + StoryTitle = {ValueType = "string"}, + StoryId = {ValueType = "string"}, + }, + XTableArchivePartnerGroup = { + Id = {ValueType = "int"}, + Order = {ValueType = "int"}, + GroupName = {ValueType = "string"}, + }, + XTableInvertCardGame = { + Id = {ValueType = "int"}, + TimeId = {ValueType = "int"}, + ItemId = {ValueType = "int"}, + HelpId = {ValueType = "int"}, + StorySkipId = {ValueType = "int"}, + ActivityStageIds = {Type = 1, ValueType = "int"}, + }, + XTableInvertCardStage = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + RowCount = {ValueType = "int"}, + ColumnCount = {ValueType = "int"}, + ContainCards = {Type = 1, ValueType = "int"}, + CostCoinNum = {ValueType = "int"}, + MaxCostNum = {ValueType = "int"}, + TargetNum = {ValueType = "int"}, + FinishGroups = {Type = 1, ValueType = "string"}, + FinishProgress = {Type = 1, ValueType = "int"}, + Rewards = {Type = 1, ValueType = "int"}, + MaxOnCardsNum = {ValueType = "int"}, + FailedPunishNum = {ValueType = "int"}, + ClearConditionDesc = {ValueType = "string"}, + }, + XTableInvertCard = { + Id = {ValueType = "int"}, + BaseIcon = {ValueType = "string"}, + }, + XTableStrongholdGroupElement = { + StageIdGroupIndex = {ValueType = "int"}, + GridTitleBg = {ValueType = "string"}, + }, + XTableTeachingRobot = { + StageId = {ValueType = "int"}, + DescDetail = {ValueType = "string"}, + ShowFightEventIds = {Type = 1, ValueType = "int"}, + RobotId = {Type = 1, ValueType = "int"}, + }, + XTableHackActivity = { + Id = {ValueType = "int"}, + TimeId = {ValueType = "int"}, + TicketId = {ValueType = "int"}, + ExpId = {ValueType = "int"}, + TicketDays = {ValueType = "int"}, + DailyTicketCount = {ValueType = "int"}, + ChapterId = {Type = 1, ValueType = "int"}, + Name = {ValueType = "string"}, + BannerBg = {ValueType = "string"}, + GridPrefab = {Type = 1, ValueType = "string"}, + }, + XTableHackChapter = { + Id = {ValueType = "int"}, + TimeId = {ValueType = "int"}, + SelectBuffCount = {ValueType = "int"}, + UnGetRewardMailId = {ValueType = "int"}, + StageId = {Type = 1, ValueType = "int"}, + RewardId = {Type = 1, ValueType = "int"}, + RobotId = {Type = 1, ValueType = "int"}, + }, + XTableHackBuff = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Type = {ValueType = "int"}, + FightEvent = {ValueType = "int"}, + Icon = {ValueType = "string"}, + Description = {ValueType = "string"}, + AbilityBonus = {ValueType = "int"}, + }, + XTableHackCharacterEffect = { + Id = {ValueType = "int"}, + BuffId = {ValueType = "int"}, + }, + XTableHackExpLevel = { + Id = {ValueType = "int"}, + Level = {ValueType = "int"}, + ChapterId = {ValueType = "int"}, + UpExp = {ValueType = "int"}, + BuffId = {ValueType = "int"}, + UnlockBuffPos = {ValueType = "int"}, + }, + XTableHackReward = { + Id = {ValueType = "int"}, + NeedStars = {ValueType = "int"}, + RewardId = {ValueType = "int"}, + }, + XTableHackStage = { + Id = {ValueType = "int"}, + ConsumeTicket = {ValueType = "int"}, + GridName = {ValueType = "string"}, + ConditionDesc = {ValueType = "string"}, + FeatureTitle = {Type = 1, ValueType = "string"}, + FeatureDesc = {Type = 1, ValueType = "string"}, + }, + XTableMovieAssemble = { + Id = {ValueType = "int"}, + BgImgUrl = {ValueType = "string"}, + UiPrefab = {ValueType = "string"}, + MovieTmpPrefab = {ValueType = "string"}, + MovieTmpIds = {Type = 1, ValueType = "int"}, + }, + XTableMovieAssembleTemplate = { + Id = {ValueType = "int"}, + MovieId = {ValueType = "string"}, + ConditionId = {ValueType = "int"}, + LockedBgUrl = {ValueType = "string"}, + UnlockBgUrl = {ValueType = "string"}, + }, + XTablePartnerTeachingChapter = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + ActivityTimeId = {ValueType = "int"}, + StagePrefix = {ValueType = "string"}, + ActivityCondition = {Type = 1, ValueType = "int"}, + OpenCondition = {Type = 1, ValueType = "int"}, + BannerIcon = {ValueType = "string"}, + Background = {ValueType = "string"}, + FubenPrefab = {ValueType = "string"}, + FightStagePrefab = {ValueType = "string"}, + StoryStagePrefab = {ValueType = "string"}, + StoryStageDetailBg = {ValueType = "string"}, + StoryStageDetailIcon = {ValueType = "string"}, + StageIds = {Type = 1, ValueType = "int"}, + }, + XTableTRPGSecondMain = { + Id = {ValueType = "int"}, + Condition = {Type = 1, ValueType = "int"}, + Prefab = {ValueType = "string"}, + BG = {ValueType = "string"}, + SecondMainStageId = {Type = 1, ValueType = "int"}, + }, + XTableTRPGSecondMainStage = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Desc = {ValueType = "string"}, + Condition = {Type = 1, ValueType = "int"}, + StageId = {ValueType = "int"}, + TRPGRewardId = {ValueType = "int"}, + PrefabName = {ValueType = "string"}, + Icon = {ValueType = "string"}, + DialogIcon = {ValueType = "string"}, + }, + XTableReformBuff = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Icon = {ValueType = "string"}, + Des = {ValueType = "string"}, + StarLevel = {ValueType = "int"}, + SubScore = {ValueType = "int"}, + FightEventIds = {Type = 1, ValueType = "int"}, + }, + XTableReformEnemyBuffDetail = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Des = {ValueType = "string"}, + Icon = {ValueType = "string"}, + }, + XTableReformGroup = { + Id = {ValueType = "int"}, + SubId = {Type = 1, ValueType = "int"}, + }, + XTableReformCfg = { + Id = {ValueType = "int"}, + ScoreItemId = {ValueType = "int"}, + OpenTimeId = {ValueType = "int"}, + BannerIcon = {ValueType = "string"}, + Name = {ValueType = "string"}, + HelpName = {ValueType = "string"}, + ScoreHelpName = {ValueType = "string"}, + }, + XTableReformEnemySource = { + Id = {ValueType = "int"}, + NpcId = {ValueType = "int"}, + Level = {ValueType = "int"}, + Name = {ValueType = "string"}, + HeadIcon = {ValueType = "string"}, + AddScore = {ValueType = "int"}, + ShowLevel = {ValueType = "string"}, + BuffIds = {Type = 1, ValueType = "int"}, + TargetId = {Type = 1, ValueType = "int"}, + }, + XTableReformEnemyTarget = { + Id = {ValueType = "int"}, + NpcId = {ValueType = "int"}, + Level = {ValueType = "int"}, + Name = {ValueType = "string"}, + ShowLevel = {ValueType = "string"}, + HeadIcon = {ValueType = "string"}, + AddScore = {ValueType = "int"}, + BuffIds = {Type = 1, ValueType = "int"}, + }, + XTableReformEnv = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Des = {ValueType = "string"}, + Icon = {ValueType = "string"}, + TextIcon = {ValueType = "string"}, + AddScore = {ValueType = "int"}, + PreviewIcon = {ValueType = "string"}, + PreviewText = {ValueType = "string"}, + FightEventIds = {Type = 1, ValueType = "int"}, + }, + XTableReformMemberSource = { + Id = {ValueType = "int"}, + RobotId = {ValueType = "int"}, + StarLevel = {ValueType = "int"}, + SubScore = {ValueType = "int"}, + TargetId = {Type = 1, ValueType = "int"}, + }, + XTableReformMemberTarget = { + Id = {ValueType = "int"}, + RobotId = {ValueType = "int"}, + StarLevel = {ValueType = "int"}, + SubScore = {ValueType = "int"}, + FightEventIds = {Type = 1, ValueType = "int"}, + }, + XTableReformStage = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + BaseStageId = {ValueType = "int"}, + ShowNpcId = {ValueType = "int"}, + OpenTimeId = {ValueType = "int"}, + ShowFightEventIds = {Type = 1, ValueType = "int"}, + StageDiff = {Type = 1, ValueType = "int"}, + }, + XTableReformStageDifficulty = { + Id = {ValueType = "int"}, + Diff = {ValueType = "int"}, + UnlockScore = {ValueType = "int"}, + ReformEnv = {ValueType = "int"}, + ReformEnvMaxCount = {ValueType = "int"}, + ReformEnemy = {ValueType = "int"}, + ReformBuff = {ValueType = "int"}, + ReformBuffMaxCount = {ValueType = "int"}, + ReformMember = {ValueType = "int"}, + }, + XTableReformEvolvableGroupBtnSort = { + Id = {ValueType = "int"}, + Weight = {ValueType = "int"}, + }, + XTablePokerGuessingActivity = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + BannerBg = {ValueType = "string"}, + TaskTimeLimitId = {ValueType = "int"}, + PokerGroupId = {ValueType = "int"}, + BackAssetPath = {ValueType = "string"}, + CostItemID = {ValueType = "int"}, + CostItemCount = {ValueType = "int"}, + TaskType = {ValueType = "int"}, + ShopSkipId = {ValueType = "int"}, + }, + XTablePokerGroup = { + Id = {ValueType = "int"}, + PokerGroup = {ValueType = "int"}, + PokerNum = {ValueType = "int"}, + PokerSuitType = {ValueType = "int"}, + PokerSuitName = {ValueType = "string"}, + FrontAssetPath = {ValueType = "string"}, + }, + XTablePokerButtonGroup = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + }, + XTableRpgMakerGameMap = { + Id = {ValueType = "int"}, + Desc = {ValueType = "string"}, + Row = {ValueType = "int"}, + Col = {ValueType = "int"}, + MaxRound = {ValueType = "int"}, + StartPointId = {ValueType = "int"}, + EndPointId = {ValueType = "int"}, + Prefab = {ValueType = "string"}, + }, + XTableRpgMakerGameStartPoint = { + Id = {ValueType = "int"}, + Desc = {ValueType = "string"}, + X = {ValueType = "int"}, + Y = {ValueType = "int"}, + Direction = {ValueType = "int"}, + }, + XTableRpgMakerGameEndPoint = { + Id = {ValueType = "int"}, + Desc = {ValueType = "string"}, + X = {ValueType = "int"}, + Y = {ValueType = "int"}, + Type = {ValueType = "int"}, + }, + XTableRpgMakerGameBlock = { + Id = {ValueType = "int"}, + MapId = {ValueType = "int"}, + Row = {ValueType = "int"}, + Col = {Type = 1, ValueType = "int"}, + }, + XTableRpgMakerGameGap = { + Id = {ValueType = "int"}, + Desc = {ValueType = "string"}, + X = {ValueType = "int"}, + Y = {ValueType = "int"}, + MapId = {ValueType = "int"}, + Direction = {ValueType = "int"}, + }, + XTableRpgMakerGameMonster = { + Id = {ValueType = "int"}, + Desc = {ValueType = "string"}, + X = {ValueType = "int"}, + Y = {ValueType = "int"}, + MapId = {ValueType = "int"}, + Direction = {ValueType = "int"}, + ViewFront = {ValueType = "int"}, + ViewBack = {ValueType = "int"}, + ViewLeft = {ValueType = "int"}, + ViewRight = {ValueType = "int"}, + TriggerEnd = {ValueType = "int"}, + Type = {ValueType = "int"}, + PatrolId = {Type = 1, ValueType = "int"}, + Prefab = {ValueType = "string"}, + }, + XTableRpgMakerGameTrigger = { + Id = {ValueType = "int"}, + Desc = {ValueType = "string"}, + X = {ValueType = "int"}, + Y = {ValueType = "int"}, + MapId = {ValueType = "int"}, + Type = {ValueType = "int"}, + TargetId = {Type = 1, ValueType = "int"}, + DefaultBlock = {ValueType = "int"}, + }, + XTableRpgMakerGamePatrol = { + Id = {ValueType = "int"}, + PatrolDirection = {Type = 1, ValueType = "int"}, + PatrolStep = {Type = 1, ValueType = "int"}, + }, + XTableRpgMakerGameRole = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + UnlockChapterId = {ValueType = "int"}, + Style = {ValueType = "string"}, + ModelAssetPath = {ValueType = "string"}, + RoleOrder = {ValueType = "int"}, + Info = {ValueType = "string"}, + InfoName = {ValueType = "string"}, + HeadPath = {ValueType = "string"}, + LockTipsDesc = {ValueType = "string"}, + }, + XTableRpgMakerGameStage = { + Id = {ValueType = "int"}, + ChapterId = {ValueType = "int"}, + PreStage = {ValueType = "int"}, + MapId = {ValueType = "int"}, + Name = {ValueType = "string"}, + StageHint = {ValueType = "string"}, + BG = {ValueType = "string"}, + Prefab = {ValueType = "string"}, + LoseHint = {Type = 1, ValueType = "string"}, + NumberName = {ValueType = "string"}, + }, + XTableRpgMakerGameChapter = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + OpenTimeId = {ValueType = "int"}, + TagBtnBG = {ValueType = "string"}, + Prefab = {ValueType = "string"}, + }, + XTableRpgMakerGameStarCondition = { + Id = {ValueType = "int"}, + StageId = {ValueType = "int"}, + Star = {ValueType = "int"}, + StepCount = {ValueType = "int"}, + MonsterCount = {ValueType = "int"}, + MonsterBossCount = {ValueType = "int"}, + ConditionDesc = {ValueType = "string"}, + }, + XTableScratchTicket = { + Id = {ValueType = "int"}, + WinRewardItemId = {ValueType = "int"}, + WinRewardItemNum = {ValueType = "int"}, + LoseRewardItemId = {ValueType = "int"}, + LoseRewardItemNum = {ValueType = "int"}, + WinRewardId = {ValueType = "int"}, + LoseRewardId = {ValueType = "int"}, + GridIds = {Type = 1, ValueType = "int"}, + }, + XTableScratchTicketActivity = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + TimeId = {ValueType = "int"}, + IsCanReset = {ValueType = "bool"}, + PreviewCount = {ValueType = "int"}, + SpendItemCount = {ValueType = "int"}, + SpendItemId = {ValueType = "int"}, + GoldRewardItemId = {ValueType = "int"}, + GoldRewardItemNum = {ValueType = "int"}, + ScratchTicket = {Type = 1, ValueType = "int"}, + OpenTimeId = {ValueType = "int"}, + }, + XTableScratchTicketChose = { + Id = {ValueType = "int"}, + GridIndex = {Type = 1, ValueType = "int"}, + }, + XTableScratchTicketGrid = { + Id = {ValueType = "int"}, + LuckNumber = {ValueType = "int"}, + Num = {Type = 1, ValueType = "int"}, + CorrectChose = {Type = 1, ValueType = "int"}, + }, + XTableSharePaltformConfig = { + Id = {ValueType = "int"}, + SdkId = {Type = 1, ValueType = "int"}, + }, + XTableRepeatChatForbid = { + Id = {ValueType = "int"}, + CalculateTime = {ValueType = "float"}, + RepeatCount = {ValueType = "int"}, + StringFilter = {Type = 1, ValueType = "string"}, + }, + XTableSuperTowerActivity = { + Id = {ValueType = "int"}, + TimeId = {ValueType = "int"}, + Name = {ValueType = "string"}, + EntryImage = {ValueType = "string"}, + PrefaceStoryId = {ValueType = "string"}, + MapId = {Type = 1, ValueType = "int"}, + }, + XTableSuperTowerCharacterExclusive = { + Id = {ValueType = "int"}, + ActivatePlugin = {ValueType = "int"}, + FightEventId = {ValueType = "int"}, + Name = {ValueType = "string"}, + Icon = {ValueType = "string"}, + Desc = {ValueType = "string"}, + }, + XTableSuperTowerIndultCharacter = { + Id = {ValueType = "int"}, + TimeId = {ValueType = "int"}, + CharacterId = {Type = 1, ValueType = "int"}, + FightEventId = {ValueType = "int"}, + Icon = {ValueType = "string"}, + Desc = {ValueType = "string"}, + }, + XTableSuperTowerMap = { + Id = {ValueType = "int"}, + TimeId = {ValueType = "int"}, + Name = {ValueType = "string"}, + TierName = {ValueType = "string"}, + }, + XTableSuperTowerTargetStage = { + Id = {ValueType = "int"}, + SimpleName = {ValueType = "string"}, + OpenHour = {ValueType = "int"}, + MapId = {ValueType = "int"}, + PreId = {ValueType = "int"}, + PreProgress = {ValueType = "int"}, + Type = {ValueType = "int"}, + Progress = {ValueType = "int"}, + Bg = {ValueType = "string"}, + StageId = {Type = 1, ValueType = "int"}, + RewardId = {Type = 1, ValueType = "int"}, + StageAbility = {Type = 1, ValueType = "int"}, + MemberCount = {Type = 1, ValueType = "int"}, + }, + XTableSuperTowerPlugin = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + FightEventId = {ValueType = "int"}, + CharacterId = {ValueType = "int"}, + SynthesisId = {ValueType = "int"}, + SynthesisCount = {ValueType = "int"}, + Capacity = {ValueType = "int"}, + Quality = {ValueType = "int"}, + Icon = {ValueType = "string"}, + ResolveId = {ValueType = "int"}, + ResolveCount = {ValueType = "int"}, + Exp = {ValueType = "int"}, + Description = {ValueType = "string"}, + IsShowInLibrary = {ValueType = "int"}, + Priority = {ValueType = "int"}, + }, + XTableSuperTowerTier = { + Id = {ValueType = "int"}, + StageId = {ValueType = "int"}, + Tier = {ValueType = "int"}, + MapId = {ValueType = "int"}, + PluginDropId = {ValueType = "int"}, + Score = {Type = 1, ValueType = "int"}, + }, + XTableSuperTowerEnhancer = { + Id = {ValueType = "int"}, + Type = {ValueType = "int"}, + Level = {ValueType = "int"}, + Name = {ValueType = "string"}, + CharacterId = {ValueType = "int"}, + Quality = {ValueType = "int"}, + FightEventId = {ValueType = "int"}, + Icon = {ValueType = "string"}, + Description = {ValueType = "string"}, + Priority = {ValueType = "int"}, + }, + XTableSuperTowerTierEnhancerDrop = { + Id = {ValueType = "int"}, + MapId = {ValueType = "int"}, + Tier = {ValueType = "int"}, + CommonDropId = {ValueType = "int"}, + Weight = {Type = 1, ValueType = "int"}, + }, + XTableSuperTowerCharacterEnhancerDrop = { + Id = {ValueType = "int"}, + EnhancerType = {Type = 1, ValueType = "int"}, + }, + XTableSuperTowerCommonEnhancerDrop = { + Id = {ValueType = "int"}, + EnhancerType = {Type = 1, ValueType = "int"}, + Weight = {Type = 1, ValueType = "int"}, + }, + XTableSuperTowerCharacterLevel = { + Id = {ValueType = "int"}, + Level = {ValueType = "int"}, + CharacterId = {ValueType = "int"}, + UpExp = {ValueType = "int"}, + FightEventId = {ValueType = "int"}, + Ability = {ValueType = "int"}, + AttributeId = {Type = 1, ValueType = "int"}, + AttributeValue = {Type = 1, ValueType = "int"}, + }, + XTableSuperTowerCfg = { + Key = {ValueType = "string"}, + Value = {ValueType = "int"}, + Comment = {ValueType = "string"}, + }, + XTableSuperTowerRobot = { + Id = {ValueType = "int"}, + OpenHour = {ValueType = "int"}, + RobotId = {Type = 1, ValueType = "int"}, + }, + XTableSuperTowerMall = { + Id = {ValueType = "int"}, + OpenTimeId = {ValueType = "int"}, + SpendItemId = {ValueType = "int"}, + FreeRefreshCount = {ValueType = "int"}, + RefreshCD = {ValueType = "int"}, + ManualRefreshSpendItemId = {ValueType = "int"}, + VisiblePluginCount = {ValueType = "int"}, + ManualRefreshSpendItemCount = {Type = 1, ValueType = "int"}, + }, + XTableSuperTowerMallPlugin = { + Id = {ValueType = "int"}, + MallId = {ValueType = "int"}, + PluginId = {ValueType = "int"}, + Price = {ValueType = "int"}, + Weight = {ValueType = "int"}, + }, + XTableSuperTowerTierScoreRatio = { + Id = {ValueType = "int"}, + Desc = {ValueType = "string"}, + }, + XTableSuperTowerTierEnhancerAndDrop = { + Id = {ValueType = "int"}, + PluginsPreviewName = {Type = 1, ValueType = "string"}, + PluginsPreviewId = {Type = 1, ValueType = "int"}, + EnhancerDropGroupId = {ValueType = "int"}, + PluginsDropLevel = {Type = 1, ValueType = "int"}, + PluginsDropGroupId = {Type = 1, ValueType = "int"}, + }, + XTableSuperTowerPluginDrop = { + Id = {ValueType = "int"}, + PluginsDropGroupId = {ValueType = "int"}, + DropPlugins = {ValueType = "int"}, + }, + XTableSuperTowerEnhanceDrop = { + Id = {ValueType = "int"}, + EnhancerDropGroupId = {ValueType = "int"}, + DropEnhanceId = {ValueType = "int"}, + }, + XTableSuperTowerStarIcon = { + Quality = {ValueType = "int"}, + Icon = {ValueType = "string"}, + Bg = {ValueType = "string"}, + }, + XTableSuperTowerClientCfg = { + Key = {ValueType = "string"}, + Value = {ValueType = "int"}, + Comment = {ValueType = "string"}, + }, + XTableSuperTowerFunction = { + Key = {ValueType = "string"}, + Name = {ValueType = "string"}, + Icon = {ValueType = "string"}, + UnLockDescription = {ValueType = "string"}, + Order = {ValueType = "int"}, + ThemeWeek = {ValueType = "int"}, + ItemId = {ValueType = "int"}, + LockTips = {ValueType = "string"}, + }, + XTableSuperTowerStageElement = { + Element = {ValueType = "int"}, + StageElementIcon = {ValueType = "string"}, + }, + XTableSuperTowerMapEffect = { + ThemeId = {ValueType = "int"}, + MapNormalEffect = {ValueType = "string"}, + MapLockEffect = {ValueType = "string"}, + MapCurrentEffect = {ValueType = "string"}, + MapTerrainEffect = {ValueType = "string"}, + NorStageLockEffect = {ValueType = "string"}, + NorStageUnLockEffect = {ValueType = "string"}, + NorStageCurrentEffect = {ValueType = "string"}, + NorStageSelectEffect = {ValueType = "string"}, + SpStageLockEffect = {ValueType = "string"}, + SpStageUnLockEffect = {ValueType = "string"}, + SpStageCurrentEffect = {ValueType = "string"}, + SpStageSelectEffect = {ValueType = "string"}, + }, + XTableMineSweepingActivity = { + Id = {ValueType = "int"}, + TimeId = {ValueType = "int"}, + CoinItemId = {ValueType = "int"}, + ChapterIds = {Type = 1, ValueType = "int"}, + }, + XTableMineSweepingChapter = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + NameEn = {ValueType = "string"}, + ActivityStageIds = {Type = 1, ValueType = "int"}, + ShowActivityStageIds = {Type = 1, ValueType = "int"}, + CompleteStoryId = {ValueType = "string"}, + CompletePicture = {ValueType = "string"}, + AllMinePicture = {ValueType = "string"}, + MineEffect = {ValueType = "string"}, + WinGridEffect = {ValueType = "string"}, + MineIcon = {ValueType = "string"}, + }, + XTableMineSweepingStage = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + WinEffect = {ValueType = "string"}, + CostCoinNum = {ValueType = "int"}, + RowCount = {ValueType = "int"}, + ColumnCount = {ValueType = "int"}, + RewardId = {ValueType = "int"}, + CanFailedCounts = {Type = 1, ValueType = "int"}, + }, + XTableMineSweepingMine = { + Id = {ValueType = "int"}, + ActivityStageId = {ValueType = "int"}, + ColumnIndexes = {Type = 1, ValueType = "int"}, + }, + XTableRpgMakerGameHint = { + Id = {ValueType = "int"}, + MapId = {ValueType = "int"}, + Row = {ValueType = "int"}, + Col = {Type = 1, ValueType = "int"}, + }, + XTableRpgMakerGameHintIcon = { + Key = {ValueType = "string"}, + Icon = {ValueType = "string"}, + Name = {ValueType = "string"}, + }, + XTableRpgMakerGameActivity = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + TaskTimeLimitId = {ValueType = "int"}, + TimeId = {ValueType = "int"}, + }, + XTableRpgMakerGameRandomDialogBox = { + Id = {ValueType = "int"}, + PreStage = {ValueType = "int"}, + Text = {ValueType = "string"}, + Weight = {ValueType = "int"}, + Duration = {ValueType = "float"}, + }, + XTableRpgMakerGameHintDialogBox = { + StageId = {ValueType = "int"}, + Text = {ValueType = "string"}, + BackCount = {ValueType = "int"}, + }, + XTableRpgMakerGameModel = { + Key = {ValueType = "string"}, + ModelPath = {ValueType = "string"}, + }, + XTableRpgMakerGameAnimation = { + ModelName = {ValueType = "string"}, + StandAnimaName = {ValueType = "string"}, + RunAnimaName = {ValueType = "string"}, + AtkAnimaName = {ValueType = "string"}, + BeAtkEffectPath = {ValueType = "string"}, + EffectRoot = {ValueType = "string"}, + XOffSet = {ValueType = "float"}, + YOffSet = {ValueType = "float"}, + ZOffSet = {ValueType = "float"}, + }, + XTableCoupleCombatActivity = { + Id = {ValueType = "int"}, + TimeId = {ValueType = "int"}, + ChapterIds = {Type = 1, ValueType = "int"}, + FightEventId = {ValueType = "int"}, + Name = {ValueType = "string"}, + BannerBg = {ValueType = "string"}, + StageGridBg = {Type = 1, ValueType = "string"}, + GridPrefab = {ValueType = "string"}, + }, + XTableCoupleCombatChapter = { + Id = {ValueType = "int"}, + TimeId = {ValueType = "int"}, + StageIds = {Type = 1, ValueType = "int"}, + RobotIds = {Type = 1, ValueType = "int"}, + }, + XTableCoupleCombatFeature = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Icon = {ValueType = "string"}, + Description = {ValueType = "string"}, + }, + XTableCoupleCombatRobot = { + RobotId = {ValueType = "int"}, + Feature = {Type = 1, ValueType = "int"}, + }, + XTableCoupleCombatStage = { + Id = {ValueType = "int"}, + OpenDay = {ValueType = "int"}, + Intro = {Type = 1, ValueType = "string"}, + Feature = {Type = 1, ValueType = "int"}, + }, + XTableFashionStory = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + TimeId = {ValueType = "int"}, + ChapterPrefab = {ValueType = "string"}, + ActivityBannerIcon = {ValueType = "string"}, + ChapterBg = {ValueType = "string"}, + TrialBg = {ValueType = "string"}, + FightStagePrefab = {ValueType = "string"}, + StoryStagePrefab = {ValueType = "string"}, + SkipId = {Type = 1, ValueType = "int"}, + ChapterStages = {Type = 1, ValueType = "int"}, + TrialStages = {Type = 1, ValueType = "int"}, + StoryTimeId = {ValueType = "int"}, + StoryEntranceBg = {ValueType = "string"}, + StoryFinishTag = {ValueType = "string"}, + }, + XTableFashionStoryStage = { + StageId = {ValueType = "int"}, + TimeId = {ValueType = "int"}, + StoryStageDetailBg = {ValueType = "string"}, + StoryStageDetailIcon = {ValueType = "string"}, + TrialDetailBg = {ValueType = "string"}, + TrialDetailSpine = {ValueType = "string"}, + TrialDetailHeadIcon = {ValueType = "string"}, + TrialDetailRecommendLevel = {ValueType = "int"}, + TrialDetailDesc = {ValueType = "string"}, + FinishTag = {ValueType = "string"}, + }, + XTableKillZoneStage = { + Id = {ValueType = "int"}, + PreStageId = {ValueType = "int"}, + Name = {ValueType = "string"}, + Order = {ValueType = "string"}, + Bg = {ValueType = "string"}, + WinCondition = {Type = 1, ValueType = "int"}, + StarCondition = {Type = 1, ValueType = "int"}, + TestRobot = {Type = 1, ValueType = "int"}, + BuffId = {Type = 1, ValueType = "int"}, + StarDesc = {Type = 1, ValueType = "string"}, + FarmReward = {ValueType = "int"}, + MaxStar = {ValueType = "int"}, + }, + XTableKillZoneChapter = { + Id = {ValueType = "int"}, + Diff = {ValueType = "int"}, + PreStageId = {ValueType = "int"}, + Name = {ValueType = "string"}, + OpenTimeId = {ValueType = "int"}, + Bg = {ValueType = "string"}, + StageId = {Type = 1, ValueType = "int"}, + }, + XTableKillZonePlugin = { + Id = {ValueType = "int"}, + GroupId = {ValueType = "int"}, + LevelId = {Type = 1, ValueType = "int"}, + UnlockSpend = {ValueType = "int"}, + Name = {ValueType = "string"}, + Icon = {ValueType = "string"}, + }, + XTableKillZonePluginLevel = { + Id = {ValueType = "int"}, + FightEventId = {ValueType = "int"}, + UnlockSpend = {ValueType = "int"}, + SkillDesc = {ValueType = "string"}, + }, + XTableKillZonePluginSlot = { + Id = {ValueType = "int"}, + UnlockCondition = {ValueType = "int"}, + }, + XTableKillZoneStarReward = { + Id = {ValueType = "int"}, + Diff = {ValueType = "int"}, + Star = {ValueType = "int"}, + RewardId = {ValueType = "int"}, + }, + XTableKillZoneDailyStarReward = { + Id = {ValueType = "int"}, + ActivityId = {ValueType = "int"}, + Star = {ValueType = "int"}, + RewardId = {ValueType = "int"}, + }, + XTableKillZoneActivity = { + Id = {ValueType = "int"}, + OpenTimeId = {ValueType = "int"}, + ActivityBg = {ValueType = "string"}, + Name = {ValueType = "string"}, + ResetPluginSpend = {ValueType = "int"}, + TakeFarmRewardMaxCount = {ValueType = "int"}, + ChapterId = {Type = 1, ValueType = "int"}, + }, + XTableKillZonePluginGroup = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + }, + XTableKillZoneBuff = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Desc = {ValueType = "string"}, + Icon = {ValueType = "string"}, + }, + XTableSummerEpisodeMapConfig = { + Id = {ValueType = "int"}, + Bg = {ValueType = "string"}, + Picture = {ValueType = "string"}, + }, + XTableDlcStage = { + DlcId = {ValueType = "int"}, + StageIds = {Type = 1, ValueType = "int"}, + }, + XTableDlcFunc = { + DlcId = {ValueType = "int"}, + FuncIds = {Type = 1, ValueType = "int"}, + }, + XTableDlcDesc = { + DlcId = {ValueType = "int"}, + Title = {ValueType = "string"}, + Desc = {ValueType = "string"}, + }, + XTablePassportTypeInfo = { + Id = {ValueType = "int"}, + ActivityId = {ValueType = "int"}, + Name = {ValueType = "string"}, + CostItemId = {ValueType = "int"}, + CostItemCount = {ValueType = "int"}, + IsFree = {ValueType = "bool"}, + RewardId = {ValueType = "int"}, + Icon = {ValueType = "string"}, + BuyDesc = {ValueType = "string"}, + }, + XTablePassportReward = { + Id = {ValueType = "int"}, + ActivityId = {ValueType = "int"}, + PassportId = {ValueType = "int"}, + Level = {ValueType = "int"}, + RewardId = {ValueType = "int"}, + }, + XTablePassportLevel = { + Id = {ValueType = "int"}, + ActivityId = {ValueType = "int"}, + Level = {ValueType = "int"}, + TotalExp = {ValueType = "int"}, + CostItemId = {ValueType = "int"}, + CostItemCount = {ValueType = "int"}, + IsTargetLevel = {ValueType = "int"}, + }, + XTablePassportActivity = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + TimeId = {ValueType = "int"}, + DailyTaskGroup = {ValueType = "int"}, + WeekTaskGroup = {ValueType = "int"}, + BPTask = {Type = 1, ValueType = "int"}, + }, + XTablePassportTaskGroup = { + Id = {ValueType = "int"}, + Type = {ValueType = "int"}, + TimeId = {ValueType = "int"}, + Group = {ValueType = "int"}, + TaskId = {Type = 1, ValueType = "int"}, + }, + XTableLimitedLoginConst = { + Id = {ValueType = "int"}, + QuizCount = {ValueType = "int"}, + }, + XTableLimitedLoginQuiz = { + Id = {ValueType = "int"}, + Title = {ValueType = "string"}, + Answers = {Type = 1, ValueType = "string"}, + CorrectAnsIdxs = {Type = 1, ValueType = "int"}, + ImagePath = {ValueType = "string"}, + }, + XTablePassportBuyFashionShow = { + PassportId = {ValueType = "int"}, + Icon = {ValueType = "string"}, + FashionId = {ValueType = "int"}, + IsWeaponFahion = {ValueType = "int"}, + }, + XTablePassportBuyRewardShow = { + Id = {ValueType = "int"}, + PassportId = {ValueType = "int"}, + Level = {ValueType = "int"}, + RewardId = {ValueType = "int"}, + }, + XTableCombatStage = { + Id = {ValueType = "int"}, + TaskId = {Type = 1, ValueType = "int"}, + }, + XTableCombatTask = { + Id = {ValueType = "int"}, + Type = {ValueType = "int"}, + StartTime = {ValueType = "fix"}, + EndTime = {ValueType = "fix"}, + Success = {ValueType = "int"}, + Failure = {ValueType = "int"}, + }, + XTableCombatTaskInfo = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + Description = {ValueType = "string"}, + }, + XTableCombatTaskResult = { + Id = {ValueType = "int"}, + TargetType = {Type = 1, ValueType = "int"}, + BuffId = {Type = 1, ValueType = "int"}, + BuffLevel = {Type = 1, ValueType = "int"}, + }, + XTableCombatTaskResultInfo = { + Id = {ValueType = "int"}, + Description = {ValueType = "string"}, + }, + XTableCombatTaskTextConfig = { + Key = {ValueType = "string"}, + Value = {ValueType = "string"}, + }, + XTableSlotMachines = { + Id = {ValueType = "int"}, + Name = {ValueType = "string"}, + DifferentAddScore = {ValueType = "int"}, + TwoSameAddScore = {ValueType = "int"}, + ConsumeItemId = {ValueType = "int"}, + ConsumeCount = {ValueType = "int"}, + UnlockNeedPreScore = {ValueType = "int"}, + ScoreLimit = {ValueType = "int"}, + BgImage = {ValueType = "string"}, + MachineImage = {ValueType = "string"}, + MachineLockImage = {ValueType = "string"}, + NextMachineBtnImage = {ValueType = "string"}, + NextMachineBtnText = {ValueType = "string"}, + RulesIds = {Type = 1, ValueType = "int"}, + Icons = {Type = 1, ValueType = "int"}, + Weights = {Type = 1, ValueType = "int"}, + RewardIds = {Type = 1, ValueType = "int"}, + RewardScores = {Type = 1, ValueType = "int"}, + PrixBottomTimes = {ValueType = "int"}, + TenTimesPrixLimit = {ValueType = "int"}, + TaskDailyLimitId = {ValueType = "int"}, + TaskCumulativeLimitId = {ValueType = "int"}, + MailId = {ValueType = "int"}, + HighLight = {ValueType = "int"}, + }, + XTableSlotMachinesActivity = { + Id = {ValueType = "int"}, + StartTimeStr = {ValueType = "string"}, + EndTimeStr = {ValueType = "string"}, + ExchangeRatio = {ValueType = "int"}, + ExchangeType = {ValueType = "int"}, + SlotMachinesIds = {Type = 1, ValueType = "int"}, + }, + XTableSlotMachinesIcon = { + Id = {ValueType = "int"}, + IconName = {ValueType = "string"}, + IconImage = {ValueType = "string"}, + Score = {ValueType = "int"}, + IsPrix = {ValueType = "bool"}, + }, + XTableSlotMachinesRules = { + Id = {ValueType = "int"}, + Title = {ValueType = "string"}, + Desc = {ValueType = "string"}, + }, + XTableUiPcScreenResolution = { + Id = {ValueType = "int"}, + X = {ValueType = "int"}, + Y = {ValueType = "int"}, + }, + XTableDefaultKeyMap = { + NpcOperationKey = {ValueType = "int"}, + XboxKeyCode = {ValueType = "string"}, + PsKeyCode = {ValueType = "string"}, + KeyboardKeyCode = {ValueType = "string"}, + OtherKeyCode = {ValueType = "string"}, + }, + XTableRecommendKey = { + NpcOperationKey = {ValueType = "int"}, + RecommendXboxIco = {Type = 1, ValueType = "string"}, + RecommendPsIco = {Type = 1, ValueType = "string"}, + RecommendKeyboardIco = {Type = 1, ValueType = "string"}, + RecommendOtherIco = {Type = 1, ValueType = "string"}, + }, +} diff --git a/Resources/Scripts/XCommon/XTime.lua b/Resources/Scripts/XCommon/XTime.lua new file mode 100644 index 00000000..da800c52 --- /dev/null +++ b/Resources/Scripts/XCommon/XTime.lua @@ -0,0 +1,265 @@ +XTime = XTime or {} + +local floor = math.floor +local CsTime = CS.UnityEngine.Time + +local ServerTimeWhenStartupList = {} --客户端启动时,服务器的时间戳 +local ServerTimeMaxCount = 10 --保存服务端时间的最大个数 +local CurrentSaveIndex = 1 --当前保存到的下标 +local ServerTimeWhenStartupAverage = 0 --客户端启动时,服务器的时间戳平局值 + +-- 一星期中的第几天 (3)[1 - 6 = 星期天 - 星期六] +local WeekOfDay = { + Sun = 0, + Mon = 1, + Tues = 2, + Wed = 3, + Thur = 4, + Fri = 5, + Sat = 6, + NorSun = 7, +} + +local WeekOfDayIndex = { + [WeekOfDay.Mon] = 1, + [WeekOfDay.Tues] = 2, + [WeekOfDay.Wed] = 3, + [WeekOfDay.Thur] = 4, + [WeekOfDay.Fri] = 5, + [WeekOfDay.Sat] = 6, + [WeekOfDay.Sun] = 7, + [WeekOfDay.NorSun] = 7, +} +local WeekLength = 7 +local sec_of_a_day = 24 * 60 * 60 +local sec_of_refresh_time = 7 * 60 * 60 + +--==============================-- +--desc: 获取服务器当前时间戳 +--@return 长整型时间戳,单位(秒) +--==============================-- +function XTime.GetServerNowTimestamp() + local sinceStartup = CsTime.realtimeSinceStartup + return floor(ServerTimeWhenStartupAverage + sinceStartup) +end + +--==============================-- +--desc: 同步时间 +--@serverTime: 服务器时间 +--@reqTime: 发起请求时间 +--@resTime: 收到响应时间 +--==============================-- +function XTime.SyncTime(serverTime, reqTime, resTime) + local startup = (reqTime + resTime) * 0.5 + local span = serverTime - startup + + if CurrentSaveIndex > ServerTimeMaxCount then + CurrentSaveIndex = CurrentSaveIndex - ServerTimeMaxCount + end + ServerTimeWhenStartupList[CurrentSaveIndex] = span + CurrentSaveIndex = CurrentSaveIndex + 1 + + local count = #ServerTimeWhenStartupList + local total = 0 + for _, v in ipairs(ServerTimeWhenStartupList) do + total = total + v + end + ServerTimeWhenStartupAverage = total / count +end + +--==============================-- +--desc: 时间字符串转服务器时区时间戳 +--@dateTimeString: 时间字符串 +--@return 转失败返回nil +--==============================-- +function XTime.ParseToTimestamp(dateTimeString) + if dateTimeString == nil or dateTimeString == "" then + return + end + + local success, timestamp = CS.XDateUtil.TryParseToTimestamp(dateTimeString) + if not success then + XLog.Error("XTime.TryParseToTimestamp parse to timestamp failed. try use ParseToTimestampMDY: " .. tostring(dateTimeString)) + return XTime.ParseToTimestampMDY(dateTimeString) + end + + return timestamp +end + +function XTime.ParseToTimestampMDY(dateTimeString) + local arr = string.Split(dateTimeString, " ") + local date = arr[1] + local time = arr[2] + local dateArr = string.Split(date, "/") + local m = dateArr[1] + local d = dateArr[2] + local y = dateArr[3] + dateTimeString = y .. "/" .. m .. "/" .. d .. " " .. time + local success, timestamp = CS.XDateUtil.TryParseToTimestamp(dateTimeString) + if not success then + XLog.Error("XTime.TryParseToTimestamp parse to timestamp failed. invalid time argument: " .. tostring(dateTimeString)) + return -- 该类在CS中不存在,且在1.18版本出现时区格式问题 + -- return CS.XDate.GetTime(dateTimeString) + end + + return timestamp +end + +--时间戳转utc时间字符串 +function XTime.TimestampToUtcDateTimeString(timestamp, format) + format = format or "yyyy-MM-dd HH:mm:ss" + local dt = CS.XDateUtil.GetUtcDateTime(timestamp) + return dt:ToString(format) +end + +--时间戳转设备本地时间字符串 +function XTime.TimestampToLocalDateTimeString(timestamp, format) + format = format or "yyyy-MM-dd HH:mm:ss" + local dt = CS.XDateUtil.GetLocalDateTime(timestamp) + return dt:ToString(format) +end + +--时间戳转游戏指定时区时间字符串 +function XTime.TimestampToGameDateTimeString(timestamp, format) + format = format or "yyyy-MM-dd HH:mm:ss" + local dt = CS.XDateUtil.GetGameDateTime(timestamp) + return dt:ToString(format) +end + +-- c#星期枚举转整形数 +function XTime.DayOfWeekToInt(dayOfWeek, isNormlSunDay) + if dayOfWeek == CS.System.DayOfWeek.Sunday then + return isNormlSunDay and 7 or 0 + elseif dayOfWeek == CS.System.DayOfWeek.Monday then + return 1 + elseif dayOfWeek == CS.System.DayOfWeek.Tuesday then + return 2 + elseif dayOfWeek == CS.System.DayOfWeek.Wednesday then + return 3 + elseif dayOfWeek == CS.System.DayOfWeek.Thursday then + return 4 + elseif dayOfWeek == CS.System.DayOfWeek.Friday then + return 5 + else + return 6 + end +end + +--获取今天时间 +function XTime.GetTodayTime(hour, min, sec) + hour = hour or 0 + min = min or 0 + sec = sec or 0 + local nowTime = XTime.GetServerNowTimestamp() + local dt = CS.XDateUtil.GetGameDateTime(nowTime) + dt = dt.Date; + dt:AddSeconds(sec) + dt:AddMinutes(min) + dt:AddHours(hour) + return dt:ToTimestamp() +end + +function XTime.GeyServerTime(hour, min, sec) + hour = hour or 0 + min = min or 0 + sec = sec or 0 + local nowTime = XTime.GetServerNowTimestamp() + local dt = CS.XDateUtil.GetGameDateTime(nowTime) + dt = dt.Date; + dt = dt:AddSeconds(sec) + dt = dt:AddMinutes(min) + dt = dt:AddHours(hour) + return dt:ToTimestamp() +end + +-- 获取距离下一个星期x的时间,默认每周第一天为周一 +function XTime.GetNextWeekOfDayStartWithMon(weekOfDay, offsetTime) + local needTime + local nowTime = XTime.GetServerNowTimestamp() + local dateTime = CS.XDateUtil.GetGameDateTime(nowTime) + local weekZero = CS.XDateUtil.GetFirstDayOfThisWeek(dateTime):ToTimestamp() + + local resetTime = (WeekOfDayIndex[weekOfDay] - 1) * sec_of_a_day + offsetTime + weekZero + if nowTime < resetTime then + needTime = resetTime - nowTime + else + needTime = WeekLength * sec_of_a_day - (nowTime - resetTime) + end + + return needTime +end + +-- 获取最近一个未到达的星期X的服务器更新时间 +function XTime.GetSeverNextWeekOfDayRefreshTime(weekOfDay) + local needTime = XTime.GetNextWeekOfDayStartWithMon(weekOfDay, sec_of_refresh_time) + local nowTime = XTime.GetServerNowTimestamp() + return nowTime + needTime +end + +-- 获取服务器当天5点更新时间戳 +function XTime.GetSeverTodayFreshTime() + local now = XTime.GetServerNowTimestamp() + local dateTime = CS.XDateUtil.GetGameDateTime(now) + local dayZero = dateTime.Date:ToTimestamp() + + return dayZero + sec_of_refresh_time +end + +-- 获取服务器明天5点更新时间戳 +function XTime.GetSeverTomorrowFreshTime() + local dayFreshTime = XTime.GetSeverTodayFreshTime() + return dayFreshTime + sec_of_a_day +end + +-- 获取服务器昨天5点更新时间戳 +function XTime.GetSeverYesterdayFreshTime() + local dayFreshTime = XTime.GetSeverTodayFreshTime() + return dayFreshTime - sec_of_a_day +end + +--获取服务器下一次5点更新时间戳 +function XTime.GetSeverNextRefreshTime() + local nextRefreshTime + + local dayRefreshTime = XTime.GetSeverTodayFreshTime() + local nowTime = XTime.GetServerNowTimestamp() + nextRefreshTime = nowTime > dayRefreshTime and XTime.GetSeverTomorrowFreshTime() or dayRefreshTime + + return nextRefreshTime +end + +-- 判断服务器当下是否是周末 +function XTime.CheckWeekend() + local now = XTime.GetServerNowTimestamp() + local weekday = XTime.GetWeekDay(now, false) + + if weekday == WeekOfDay.Sun then + return true + elseif weekday == WeekOfDay.Sat then + local todayFreshTime = XTime.GetSeverTodayFreshTime() + return now >= todayFreshTime + elseif weekday == WeekOfDay.Mon then + local todayFreshTime = XTime.GetSeverTodayFreshTime() + return now < todayFreshTime + else + return false + end +end + +-- 判断时间戳是周几 +function XTime.GetWeekDay(time, isNormlSunDay) + local dateTime = CS.XDateUtil.GetGameDateTime(time) + local weekday = XTime.DayOfWeekToInt(dateTime.DayOfWeek, isNormlSunDay) + return weekday +end + +--获取一个时间戳的当天刷新的时间 +function XTime.GetTimeDayFreshTime(time) + local todayRefreshTime + + local dateTime = CS.XDateUtil.GetGameDateTime(time) + local dayZero = dateTime.Date:ToTimestamp() + todayRefreshTime = dayZero + sec_of_refresh_time + + return todayRefreshTime +end \ No newline at end of file diff --git a/Resources/Scripts/XCommon/XTool.lua b/Resources/Scripts/XCommon/XTool.lua new file mode 100644 index 00000000..a6200aa3 --- /dev/null +++ b/Resources/Scripts/XCommon/XTool.lua @@ -0,0 +1,307 @@ +local Json = require("XCommon/Json") +local type = type +local table = table +local string = string +local math = math +local next = next +local debug = debug +local tostring = tostring + +local tableInsert = table.insert +local stringMatch = string.match +local mathModf = math.modf + +XTool = XTool or {} + +XTool.UObjIsNil = function(uobj) + return uobj == nil or not uobj:Exist() +end + +XTool.LoopMap = function(map, func) + if type(map) == "userdata" then + if not map then + return + end + + local e = map:GetEnumerator() + while e:MoveNext() do + func(e.Current.Key, e.Current.Value) + end + e:Dispose() + elseif type(map) == "table" then + for key, value in pairs(map) do + func(key, value) + end + end +end + +XTool.LoopCollection = function(collection, func) + if type(collection) == "table" then + for _, value in pairs(collection) do + func(value) + end + elseif type(collection) == "userdata" then + for i = 0, collection.Count - 1 do + func(collection[i]) + end + end +end + +XTool.LoopArray = function(collection, func) + for i = 0, collection.Length - 1 do + func(collection[i]) + end +end + +XTool.CsList2LuaTable = function(collection) + local ret = {} + for i = 0, collection.Count - 1 do + tableInsert(ret, collection[i]) + end + return ret +end + +XTool.CsMap2LuaTable = function(map) + local ret = {} + local e = map:GetEnumerator() + while e:MoveNext() do + ret[e.Current.Key] = e.Current.Value + end + e:Dispose() + return ret +end + +XTool.CsObjectFields2LuaTable = function(CsObj) + if CsObj == nil or type(CsObj) ~= "userdata" then + return {} + end + local jsonStr = CS.XTool.SerializeObject(CsObj) + return Json.decode(jsonStr) +end + +XTool.Clone = function(t) + local cache = {} + + local function clone(o) + if type(o) ~= "table" then return o end + if cache[o] then return cache[o] end + + local newO = {} + for k, v in pairs(o) do + newO[clone(k)] = clone(v) + end + + local mTable = getmetatable(o) + if type(mTable) == "table" then + setmetatable(newO, mTable) + end + + cache[o] = newO + + return newO + end + + return clone(t) +end + +XTool.GetFileNameWithoutExtension = function(path) + return stringMatch(path, "[./]*([^/]*)%.%w+") +end + +XTool.GetFileName = function(path) + return stringMatch(path, "[./]*([^/]*%.%w+)") +end + +XTool.GetExtension = function(path) + return stringMatch(path, "[./]*(%.%w+)") +end + +XTool.GetTableCount = function(list) + if type(list) ~= "table" then + XLog.Error(" XTool.GetTableCount 函数错误 : 参数list需要是table类型的, list:" .. type(list)) + return + end + + local count = 0 + for _, _ in pairs(list) do + count = count + 1 + end + + return count +end + +local NumberText = { + [0] = "", + [1] = CS.XTextManager.GetText("One"), + [2] = CS.XTextManager.GetText("Two"), + [3] = CS.XTextManager.GetText("Three"), + [4] = CS.XTextManager.GetText("Four"), + [5] = CS.XTextManager.GetText("Five"), + [6] = CS.XTextManager.GetText("Six"), + [7] = CS.XTextManager.GetText("Seven"), + [8] = CS.XTextManager.GetText("Eight"), + [9] = CS.XTextManager.GetText("Nine"), + [10] = CS.XTextManager.GetText("Ten"), +} + +XTool.ParseNumberString = function(num) + return NumberText[mathModf(num / 10)] .. NumberText[num % 10] +end + +XTool.ConvertNumberString = function(num) + return NumberText[num] or "" +end + +XTool.MatchEmoji = function(text) + return stringMatch(text, '%[%d%d%d%d%d%]') +end + +XTool.CopyToClipboard = function(text) + CS.XAppPlatBridge.CopyStringToClipboard(tostring(text)) + XUiManager.TipText("Clipboard", XUiManager.UiTipType.Tip) +end + +XTool.ToArray = function(t) + local array = {} + for _, v in pairs(t) do + table.insert(array, v) + end + return array +end + +XTool.MergeArray = function(...) + local res = {} + for _, t in pairs({ ... }) do + if type(t) == "table" then + for _, v in pairs(t) do + table.insert(res, v) + end + end + end + return res +end + +function XTool.ReverseList(list) + if not list then return end + + local length = #list + local middle = math.floor(length * 0.5) + for i = 1, middle do + local reverseI = length - i + 1 + local tmp = list[i] + list[i] = list[reverseI] + list[reverseI] = tmp + end + + return list +end + +XTool.Waterfall = function(cbList) + local last + for i = #cbList, 1, -1 do + if type(cbList[i]) == "function" then + local nextCb = last + local cb = function() + cbList[i](nextCb) + end + last = cb + else + XLog.Error("XTool.Waterfall error, unit is not function") + end + end + if last then + last() + end +end + +XTool.InitUiObject = function(targetObj) + targetObj.Obj = targetObj.Transform:GetComponent("UiObject") + if targetObj.Obj ~= nil then + for i = 0, targetObj.Obj.NameList.Count - 1 do + targetObj[targetObj.Obj.NameList[i]] = targetObj.Obj.ObjList[i] + end + end +end + +XTool.InitUiObjectByUi = function(targetUi, uiPrefab) + targetUi.GameObject = uiPrefab.gameObject + targetUi.Transform = uiPrefab.transform + XTool.InitUiObject(targetUi) + return targetUi +end + +XTool.DestroyChildren = function(gameObject) + if not gameObject then + return + end + + if XTool.UObjIsNil(gameObject) then + return + end + + local transform = gameObject.transform + for i = 0, transform.childCount - 1, 1 do + CS.UnityEngine.Object.Destroy(transform:GetChild(i).gameObject) + end +end + +XTool.IsTableEmpty = function(tb) + return not tb or not next(tb) +end + +XTool.IsNumberValid = function(number) + return number and number ~= 0 +end + +XTool.GetStackTraceName = function(level) + level = level or 3 + local info + for i = level, 2, -1 do + info = debug.getinfo(i) + if info then + break + end + end + + local name = "lua:" .. tostring(info.source) .. "_" .. tostring(info.currentline) + return name +end + +-- datas : 只接受数组 +XTool.TableRemove = function(datas, removeValue) + local removePos = nil + for index, value in ipairs(datas) do + if value == removeValue then + removePos = index + break + end + end + if removePos then table.remove(datas, removePos) end +end + +-- 保留digit位小数 +XTool.MathGetRoundingValue = function(value, digit) + return math.floor( value * XTool.MathPow(10, digit) ) / XTool.MathPow(10 , digit) +end + +XTool.MathPow = function(a, b) + return a ^ b +end + +--随机打乱 +XTool.RandomBreakTableOrder = function(t) + local index + local temp + local total = #t + for i = 1, total, 1 do + for j = i + 1, total, 1 do + index = math.random(j, total); + temp = t[i]; + t[i] = t[index]; + t[index] = temp; + break + end + end + + return t +end \ No newline at end of file diff --git a/Resources/Scripts/XCommon/XUiGravity.lua b/Resources/Scripts/XCommon/XUiGravity.lua new file mode 100644 index 00000000..5ef58f31 --- /dev/null +++ b/Resources/Scripts/XCommon/XUiGravity.lua @@ -0,0 +1,56 @@ +XUiGravity = XClass(XLuaBehaviour, "XUiGravity") +-- 范围(防止画面抖动) +local range = 0.01 + +function XUiGravity:Ctor(rootUi, ui, minX, maxX, minY, maxY) + self.minX = minX + self.maxX = maxX + self.minY = minY + self.maxY = maxY + self.lastAttitude = CS.UnityEngine.Vector3.zero + self.testV = 0 + self.testSpeed = 0.01 +end + +function XUiGravity:Start() + CS.UnityEngine.Input.gyro.enabled = true +end + +function XUiGravity:Update() + self.testV = self.testV + self.testSpeed + if self.testV > 1 then + self.testSpeed = -0.01 + elseif self.testV < -1 then + self.testSpeed = 0.01 + end + local transform = self.Transform + -- local attitude = CS.UnityEngine.Vector3(CS.UnityEngine.Input.gyro.attitude.x, CS.UnityEngine.Input.gyro.attitude.y, 0) + local attitude = CS.UnityEngine.Vector3(self.testV, 0, 0) + --使安全范围内 - 1之1 + attitude.x = XMath.Clamp(attitude.x, -1, 1); + attitude.y = XMath.Clamp(attitude.y, -1, 1); + + local x = transform.localPosition.x + local y = transform.localPosition.y + + local isDirty = false + if math.abs(self.lastAttitude.x - attitude.x) >= range then + isDirty = true + local direction = attitude.x - self.lastAttitude.x + local position = direction * (self.maxX - self.minX) / 2 + x = XMath.Clamp(transform.localPosition.x - position, self.minX, self.maxX); + self.lastAttitude = attitude + end + if math.abs(self.lastAttitude.y - attitude.y) >= range then + isDirty = true + local direction = attitude.y - self.lastAttitude.y + local position = direction * (self.maxY - self.minY) / 2 + y = XMath.Clamp(transform.localPosition.y - position, self.minY, self.maxY); + self.lastAttitude = attitude + end + if isDirty then + transform.localPosition = CS.UnityEngine.Vector3(x, y, transform.localPosition.z); + end +end + +return XUiGravity \ No newline at end of file diff --git a/Resources/Scripts/XCommon/XUiHelper.lua b/Resources/Scripts/XCommon/XUiHelper.lua new file mode 100644 index 00000000..bf5fccc5 --- /dev/null +++ b/Resources/Scripts/XCommon/XUiHelper.lua @@ -0,0 +1,1111 @@ +local math = math +local string = string +local tonumber = tonumber +local mathFloor = math.floor +local mathCeil = math.ceil +local mathMin = math.min +local mathMax = math.max +local stringFormat = string.format +local stringSub = string.sub +local stringFind = string.find +local stringGsub = string.gsub +local tableSort = table.sort +local tableInsert = table.insert +local Vec3Lerp = CS.UnityEngine.Vector3.Lerp +local MathLerp = CS.UnityEngine.Mathf.Lerp +local CSTextManagerGetText = CS.XTextManager.GetText + +local STR_MONTH = CSTextManagerGetText("Mouth") +local STR_WEEK = CSTextManagerGetText("Week") +local STR_DAY = CSTextManagerGetText("Day") +local STR_HOUR = CSTextManagerGetText("Hour") +local STR_MINUTE = CSTextManagerGetText("Minute") +local STR_SECOND = CSTextManagerGetText("Second") + + +local S = 60 +local H = 3600 +local D = 3600 * 24 +local W = 3600 * 24 * 7 +local M = 3600 * 24 * 30 + +XUiHelper = XUiHelper or {} +XUiHelper.TimeFormatType = { + DEFAULT = 1, -- 默认时间格式(大于一天显示天数,小于一天显示xx小时xx分) + SHOP = 1, -- 商城时间格式 + TOWER = 2, -- 爬塔时间格式 + TOWER_RANK = 3, -- 爬塔排行消耗时间格式 + CHALLENGE = 4, -- 挑战的时间 + HOSTEL = 5, -- 宿舍倒计时 + DRAW = 6, -- 抽卡倒计时 + MAIN = 7, -- 主界面系统时间 + PURCHASELB = 8, -- 礼包时间 + ONLINE_BOSS = 9, -- 联机boss + ACTIVITY = 10, -- 活动 + MAINBATTERY = 11, -- 主界面血清剩余时间 + HEADPORTRAIT = 12, -- 头像时间 + DAILY_TASK = 13, --每日任务(显示X时X分,不足一分钟时显示一分钟) + GUILDCD = 14, -- 公会冷却倒计时 + CHATEMOJITIMER = 15, -- 倒计时(大于一天显示天数,小于一天大于一小时显示小时,小于一小时大于一分钟显示分钟,小于一分钟大于一秒钟显示秒钟) + ACTIVITY_LINEBREAK = 16, --日期会换行(例:10\n天) + NieRShow = 17, --尼尔玩法显示剩余时间(汉字替换为英文字符) + STRONGHOLD = 18, --超级据点时间格式 + TO_A_MINUTE = 19, --时间精确到分,不足一分钟时显示<1分钟,倒计时结束输出0分钟 + MOE_WAR = 20, --倒计时(大于一天显示天数,小于一天大于一小时显示小时,小于一小时大于一分钟显示分钟,小于一分钟大于一秒钟显示一分钟) + KillZone = 21, --杀戮无双(当剩余时间大于1天时,按天显示时间,当剩余时间小于1天时,按小时显示时间,剩余时间少于1小时,也显示1小时) + RPG_MAKER_GAME = 22, --21年端午活动,只显示天(向上取整) + PASSPORT = 23, --战斗通行证(时间≥1天时,显示【X天XX:XX】;小于1天时间时,显示【XX:XX】;小于一分钟大于一秒钟显示一分钟) +} + +XUiHelper.DelayType = { + Second = 1, + Minute = 2, + Hour = 3, + Day = 4, +} + +XUiHelper.ClientConfigType = { + String = 1, + Float = 2, + Int = 3, + Bool = 4, +} + +XUiHelper.TagBgPath = { + Red = CS.XGame.ClientConfig:GetString("UiBagItemRed"), + Yellow = CS.XGame.ClientConfig:GetString("UiBagItemYellow"), + Blue = CS.XGame.ClientConfig:GetString("UiBagItemBlue"), + Green = CS.XGame.ClientConfig:GetString("UiBagItemGreen"), +} + +function XUiHelper.CreateTemplates(rootUi, pool, datas, ctor, template, parent, onCreate) + for i = 1, #datas do + local data = datas[i] + local item + + if i <= #pool then + item = pool[i] + else + local go = CS.UnityEngine.Object.Instantiate(template) + go.transform:SetParent(parent, false) + item = ctor(rootUi, go) + pool[i] = item + end + + if onCreate then + onCreate(item, data) + end + end + + for i = #datas + 1, #pool do + local item = pool[i] + item.GameObject:SetActive(false) + end +end + +function XUiHelper.CreateScrollItem(datas, template, parent, cb, scrollstyle) + scrollstyle = scrollstyle or XGlobalVar.ScrollViewScrollDir.ScrollDown + local width, height = template.gameObject:GetComponent("RectTransform").rect.width, template.gameObject:GetComponent("RectTransform").rect.height + + if scrollstyle == XGlobalVar.ScrollViewScrollDir.ScrollDown then + parent:GetComponent("RectTransform").sizeDelta = CS.UnityEngine.Vector2(0, #datas * height) + elseif scrollstyle == XGlobalVar.ScrollViewScrollDir.ScrollRight then + parent:GetComponent("RectTransform").sizeDelta = CS.UnityEngine.Vector2(#datas * width, 0) + end + + for i = 1, #datas do + local obj = CS.UnityEngine.Object.Instantiate(template) + obj.gameObject:SetActive(true) + if scrollstyle == XGlobalVar.ScrollViewScrollDir.ScrollDown then + obj.transform.localPosition = CS.UnityEngine.Vector3(width / 2, -height / 2 - height * (i - 1), 0) + elseif scrollstyle == XGlobalVar.ScrollViewScrollDir.ScrollRight then + obj.transform.localPosition = CS.UnityEngine.Vector3(width * (i - 1), 0, 0) + end + obj.transform.localScale = CS.UnityEngine.Vector3(1, 1, 1) + obj.transform.localEulerAngles = CS.UnityEngine.Vector3(0, 0, 0) + obj.transform:SetParent(parent, false) + cb(obj, datas[i]) + end + +end + +function XUiHelper.TryGetComponent(transform, path, type) + local temp = transform:Find(path) + if temp then + if type then + return temp:GetComponent(type) + else + return temp + end + else + return nil + end +end + +function XUiHelper.SetQualityIcon(rootUi, imgQuality, quality) + local spriteName = XArrangeConfigs.GeQualityPath(quality) + rootUi:SetUiSprite(imgQuality, spriteName) +end + +function XUiHelper.GetPanelRoot(ui) + while ui.Parent do + ui = ui.Parent + end + return ui +end + +------------时间相关begin------------ +--==============================-- +--desc: 固定的时间格式 +--@second: 总秒数 +--@return: 固定的时间格式 +-- 时间大于1个月 则返回 X个月 +-- 时间大于1周 则返回 X周 +-- 时间大于1天 则返回 X天 +-- 其余 则返回 XX:XX:XX +--==============================-- +function XUiHelper.GetTime(second, timeFormatType) + timeFormatType = timeFormatType and timeFormatType or XUiHelper.TimeFormatType.DEFAULT + + local month, weeks, days, hours, minutes, seconds = XUiHelper.GetTimeNumber(second) + + if timeFormatType == XUiHelper.TimeFormatType.DEFAULT then + if month >= 1 then + return stringFormat("%d%s", month, STR_MONTH) + end + if weeks >= 1 then + return stringFormat("%d%s", weeks, STR_WEEK) + end + if days >= 1 then + return stringFormat("%d%s", days, STR_DAY) + end + return stringFormat("%02d:%02d:%02d", hours, minutes, seconds) + end + + if timeFormatType == XUiHelper.TimeFormatType.MAINBATTERY then + if month >= 1 then + return stringFormat("%d%s", month, STR_MONTH) + end + if weeks >= 1 then + return stringFormat("%d%s", weeks, STR_WEEK) + end + if days >= 1 then + return stringFormat("%d%s", days, STR_DAY) + end + if hours >= 1 then + return stringFormat("%d%s", hours, STR_HOUR) + end + local notZeroMin = minutes > 0 and minutes or 1 + return stringFormat("%d%s", notZeroMin, STR_MINUTE) + end + + if timeFormatType == XUiHelper.TimeFormatType.ACTIVITY then + local totalDays = mathFloor(second / D) + if totalDays >= 1 then + return stringFormat("%d%s", totalDays, STR_DAY) + end + if hours >= 1 then + return stringFormat("%d%s", hours, STR_HOUR) + end + if minutes >= 1 then + return stringFormat("%d%s", minutes, STR_MINUTE) + end + return stringFormat("%d%s", seconds, STR_SECOND) + end + + if timeFormatType == XUiHelper.TimeFormatType.ACTIVITY_LINEBREAK then + local totalDays = mathFloor(second / D) + if totalDays >= 1 then + return stringFormat("%d\n%s", totalDays, STR_DAY) + end + if hours >= 1 then + return stringFormat("%d\n%s", hours, STR_HOUR) + end + if minutes >= 1 then + return stringFormat("%d\n%s", minutes, STR_MINUTE) + end + return stringFormat("%d\n%s", seconds, STR_SECOND) + end + + if timeFormatType == XUiHelper.TimeFormatType.TOWER then + return stringFormat("%d%s%02d%s%02d%s", days, STR_DAY, hours, STR_HOUR, minutes, STR_MINUTE) + end + + if timeFormatType == XUiHelper.TimeFormatType.TOWER_RANK then + return stringFormat("%02d%s%02d%s", minutes, STR_MINUTE, seconds, STR_SECOND) + end + + if timeFormatType == XUiHelper.TimeFormatType.DAILY_TASK then + if minutes < 1 and seconds > 0 then + minutes = 1 + end + + return stringFormat("%02d%s%02d%s", hours, STR_HOUR, minutes, STR_MINUTE) + end + + if timeFormatType == XUiHelper.TimeFormatType.CHALLENGE or timeFormatType == XUiHelper.TimeFormatType.HOSTEL then + if month >= 1 then + return stringFormat("%d%s", month, STR_MONTH) + end + if weeks >= 1 then + return stringFormat("%d%s", weeks, STR_WEEK) + end + if days >= 1 then + return stringFormat("%d%s%d%s", days, STR_DAY, hours, STR_HOUR) + end + return stringFormat("%02d:%02d:%02d", hours, minutes, seconds) + end + + if timeFormatType == XUiHelper.TimeFormatType.DRAW then + local sumDas = mathFloor(second / D) + if sumDas >= 1 then + return stringFormat("%d%s", sumDas, STR_DAY) + end + if hours >= 1 then + return stringFormat("%d%s", hours, STR_HOUR) + end + if minutes >= 1 then + return stringFormat("%d%s", minutes, STR_MINUTE) + end + return stringFormat("%02d:%02d:%02d", hours, minutes, seconds) + end + + if timeFormatType == XUiHelper.TimeFormatType.GUILDCD then + return stringFormat("%01d:%02d:%02d", hours, minutes, seconds) + end + + if timeFormatType == XUiHelper.TimeFormatType.MAIN then + return stringFormat("%02d:%02d", hours, minutes) + end + + if timeFormatType == XUiHelper.TimeFormatType.PURCHASELB then + if month >= 1 or weeks >= 1 then + local sumDas = mathFloor(second / D) + return stringFormat("%d%s", sumDas, STR_DAY) + end + if days >= 1 then + return stringFormat("%d%s%d%s", days, STR_DAY, hours, STR_HOUR) + end + return stringFormat("%02d:%02d:%02d", hours, minutes, seconds) + end + + if timeFormatType == XUiHelper.TimeFormatType.ONLINE_BOSS then + local sumDas = mathFloor(second / D) + if sumDas >= 1 then + return stringFormat("%d%s", sumDas, STR_DAY) + end + if hours >= 1 then + return stringFormat("%d%s", hours, STR_HOUR) + end + return stringFormat("%02d:%02d", minutes, seconds) + end + + if timeFormatType == XUiHelper.TimeFormatType.HEADPORTRAIT then + local sumDas = mathFloor(second / D) + if sumDas >= 1 then + return stringFormat("%d%s", sumDas, STR_DAY) + end + + if hours >= 1 then + return stringFormat("%d%s", hours, STR_HOUR) + end + + if minutes < 1 and seconds > 0 then + minutes = 1 + end + + return stringFormat("%d%s", minutes, STR_MINUTE) + end + + if timeFormatType == XUiHelper.TimeFormatType.CHATEMOJITIMER then + local sumDas = mathFloor(second / D) + if sumDas >= 1 then + return stringFormat("%d%s", sumDas, STR_DAY) + end + + if hours >= 1 then + return stringFormat("%d%s", hours, STR_HOUR) + end + + if minutes < 1 and seconds > 0 then + return stringFormat("%d%s", seconds, STR_SECOND) + end + + return stringFormat("%d%s", minutes, STR_MINUTE) + end + + if timeFormatType == XUiHelper.TimeFormatType.NieRShow then + local sumDas = mathFloor(second / D) + if sumDas >= 1 then + return stringFormat("%d%s", sumDas, "DAY") + end + + if hours >= 1 then + return stringFormat("%d%s", hours, "Hour") + end + + if minutes < 1 and seconds > 0 then + return stringFormat("%d%s", seconds, "Second") + end + + return stringFormat("%d%s", minutes, "Minute") + end + + if timeFormatType == XUiHelper.TimeFormatType.STRONGHOLD then + local sumDas = mathFloor(second / D) + if sumDas >= 1 then + return stringFormat("%d%s%d%s", sumDas, STR_DAY, hours, STR_HOUR) + end + return stringFormat("%02d:%02d:%02d", hours, minutes, seconds) + end + + if timeFormatType == XUiHelper.TimeFormatType.TO_A_MINUTE then + if days >= 1 then + return stringFormat("%d%s%d%s%d%s", days, STR_DAY, hours, STR_HOUR, minutes, STR_MINUTE) + end + + if hours >= 1 then + return stringFormat("%d%s%d%s", hours, STR_HOUR, minutes, STR_MINUTE) + end + + if minutes < 1 and seconds > 0 then + return stringFormat("<1%s", STR_MINUTE) + end + + return stringFormat("%d%s", minutes, STR_MINUTE) + end + + if timeFormatType == XUiHelper.TimeFormatType.MOE_WAR then + local sumDas = mathFloor(second / D) + if sumDas >= 1 then + return stringFormat("%d%s", sumDas, STR_DAY) + end + + if hours >= 1 then + return stringFormat("%d%s", hours, STR_HOUR) + end + + if minutes < 1 and seconds > 0 then + minutes = 1 + end + + return stringFormat("%d%s", minutes, STR_MINUTE) + end + + if timeFormatType == XUiHelper.TimeFormatType.KillZone then + local sumDas = mathFloor(second / D) + if sumDas >= 1 then + return stringFormat("%d%s", sumDas, STR_DAY) + end + + if hours >= 1 then + return stringFormat("%d%s", hours, STR_HOUR) + end + + return stringFormat("%d%s", minutes, STR_MINUTE) + end + + if timeFormatType == XUiHelper.TimeFormatType.RPG_MAKER_GAME then + local sumDas = mathCeil(second / D) + if sumDas >= 1 then + return stringFormat("%d%s", sumDas, STR_DAY) + end + return stringFormat("%d%s", 0, STR_DAY) + end + + if timeFormatType == XUiHelper.TimeFormatType.PASSPORT then + if days >= 1 then + return stringFormat("%d%s%02d:%02d", days, STR_DAY, hours, minutes) + end + + if minutes < 1 and seconds > 0 then + minutes = 1 + end + return stringFormat("%02d:%02d", hours, minutes) + end +end + +function XUiHelper.GetTimeNumber(second) + local month = mathFloor(second / M) + local weeks = mathFloor((second % M) / W) + local days = mathFloor((second % W) / D) + local hours = mathFloor((second % D) / H) + local minutes = mathFloor((second % H) / S) + local seconds = mathFloor(second % S) + + return month, weeks, days, hours, minutes, seconds +end + +function XUiHelper.GetTimeOfDelay(time, delayTime, delayType)--获取延时后的时间戳 + if delayType == XUiHelper.DelayType.Second then + return time + delayTime + elseif delayType == XUiHelper.DelayType.Minute then + return time + delayTime * S + elseif delayType == XUiHelper.DelayType.Hour then + return time + delayTime * H + elseif delayType == XUiHelper.DelayType.Day then + return time + delayTime * D + end + return time + delayTime +end + +--背包限时道具时间样式 +function XUiHelper.GetBagTimeLimitTimeStrAndBg(second) + local timeStr, bgPath + + local weeks = mathFloor(second / W) + local days = mathFloor((second % W) / D) + local hours = mathFloor((second % D) / H) + local minutes = mathFloor((second % H) / S) + if weeks >= 1 then + timeStr = stringFormat("%d%s", weeks, STR_WEEK) + bgPath = XUiHelper.TagBgPath.Green + elseif days >= 1 then + timeStr = stringFormat("%d%s", days, STR_DAY) + bgPath = XUiHelper.TagBgPath.Yellow + elseif hours >= 1 then + timeStr = stringFormat("%d%s", hours, STR_HOUR) + bgPath = XUiHelper.TagBgPath.Red + else + local notZeroMin = minutes > 0 and minutes or 1 + timeStr = stringFormat("%d%s", notZeroMin, STR_MINUTE) + bgPath = XUiHelper.TagBgPath.Red + end + + return timeStr, bgPath +end + +-- length为可选参数,为要显示的长度,例如3601,1为1小时,3601,2为1小时1秒, +function XUiHelper.GetTimeDesc(second, length) + local minute = 60 + local hour = 3600 + local day = 3600 * 24 + + if second <= 0 then + return CSTextManagerGetText("IsExpire") + end + + if not length then + length = 1 + end + + local desc = "" + while length > 0 do + if second == 0 then + return desc + end + + if second < minute then + local s = mathFloor(second) + desc = desc .. s .. CSTextManagerGetText("Second") + second = 0 + else + if second < hour then + local m = mathFloor(second / minute) + desc = desc .. m .. CSTextManagerGetText("Minute") + second = second - m * minute + else + if second < day then + local h = mathFloor(second / hour) + desc = desc .. h .. CSTextManagerGetText("Hour") + second = second - h * hour + else + local d = mathFloor(second / day) + desc = desc .. d .. CSTextManagerGetText("Day") + second = second - d * day + end + end + end + + length = length - 1 + if length > 0 then + desc = desc .. " " + end + end + + return desc +end + +--返回X时间开启,或X时间结束,或已结束 +function XUiHelper.GetInTimeDesc(startTime, endTime) + local nowTime = XTime.GetServerNowTimestamp() + local timeStr + + if startTime and nowTime < startTime then + timeStr = XUiHelper.GetTime(startTime - nowTime, XUiHelper.TimeFormatType.ACTIVITY) + return CSTextManagerGetText("StartInTime", timeStr) + end + + if endTime and nowTime < endTime then + timeStr = XUiHelper.GetTime(endTime - nowTime, XUiHelper.TimeFormatType.ACTIVITY) + return CSTextManagerGetText("EndInTime", timeStr) + end + + return CSTextManagerGetText("TimeUp") +end + +--==============================-- +--desc: 获取最后登录时间描述 +--@time: 登录时间 +--@return 最后登录时间对应描述 +--==============================-- +function XUiHelper.CalcLatelyLoginTime(time, nowTime) + nowTime = nowTime or XTime.GetServerNowTimestamp() + local minute = mathFloor((nowTime - time) / 60) + local hourCount = mathFloor(minute / 60) + local dayCount = mathFloor(hourCount / 24) + local monthCount = mathFloor(dayCount / 30) + + if monthCount >= 1 then + return monthCount .. CSTextManagerGetText("ToolMonthBefore") + elseif dayCount >= 1 then + return dayCount .. CSTextManagerGetText("ToolDayBrfore") + elseif hourCount >= 1 then + return hourCount .. CSTextManagerGetText("ToolHourBefore") + else + return minute .. CSTextManagerGetText("ToolMinuteBefore") + end +end + +--==============================-- +--desc: 获取最后登录时间描述 +--@time: 登录时间 +--@defaultDay: 默认显示的天数 +--@return 最后登录时间对应描述 +--==============================-- +function XUiHelper.CalcLatelyLoginTimeWithDefault(time, defaultDay) + local minute = mathFloor((XTime.GetServerNowTimestamp() - time) / 60) + local hourCount = mathFloor(minute / 60) + local dayCount = mathFloor(hourCount / 24) + + if dayCount >= 1 then + if defaultDay and defaultDay < dayCount then + return defaultDay .. CSTextManagerGetText("ToolDayBrfore") + else + return dayCount .. CSTextManagerGetText("ToolDayBrfore") + end + elseif hourCount >= 1 then + return hourCount .. CSTextManagerGetText("ToolHourBefore") + else + return minute .. CSTextManagerGetText("ToolMinuteBefore") + end +end + +function XUiHelper.GetRemindTime(time, now) + now = now or XTime.GetServerNowTimestamp() + local remindTime = time - now + if remindTime > 86400 then + local day = mathFloor(remindTime / 86400) + 1 + return day .. CSTextManagerGetText("Day") + else + local h = mathFloor(remindTime / 3600) + local m = mathFloor((remindTime - h * 3600) / 60) + local s = mathFloor(remindTime % 60) + return stringFormat("%02d:%02d:%02d", h, m, s) + end +end +------------时间相关end------------ +--==============================-- +--desc: Hex Color 转成 color +--@hexColor: 如:B7C4FFFF或B7C4FF +--@return: color(r, g, b, a)或color(r, g, b) +--==============================-- +function XUiHelper.Hexcolor2Color(hexColor) + local str + str = stringSub(hexColor, 1, 2) + local r = tonumber(str, 16) / 255 + str = stringSub(hexColor, 3, 4) + local g = tonumber(str, 16) / 255 + str = stringSub(hexColor, 5, 6) + local b = tonumber(str, 16) / 255 + str = stringSub(hexColor, 7, 8) + local a = string.IsNilOrEmpty(str) and 1 or tonumber(str, 16) / 255 + return CS.UnityEngine.Color(r, g, b, a) +end + +-------------------------------------- +-- 将RGB Color(100, 100, 255) 转换成16进制颜色代码 #6464ff +-------------------------------------- +function XUiHelper.Color2Hex(color) + return string.format("#%.2x%.2x%.2x", color.r, color.g, color.b) +end + +------------动画相关begin------------ +--==============================-- +--desc: 打字机动画 +--@txtobj: 文本对象 +--@str: 打印的字符串 +--@interval: 时间间隔 +--@finishcallback: 结束回调 +--@return 定时器对象 +--==============================-- +function XUiHelper.ShowCharByTypeAnimation(txtobj, str, interval, callback, finishcallback) + local chartab = string.CharsConvertToCharTab(str) + local index = 1 + local timer + txtobj.text = "" + timer = XScheduleManager.ScheduleForever(function() + if index > #chartab then + XScheduleManager.UnSchedule(timer) + if finishcallback then + finishcallback() + end + else + local char = chartab[index] + if callback then + callback(char) + else + txtobj.text = txtobj.text .. char + end + index = index + 1 + end + end, interval) + return timer +end + +-- 如果是子Ui,得先定义Parent才能获取到UiAnimation组件。 +--弃用 +function XUiHelper.PlayAnimation(ui, name, onStart, onEnd) + if onStart then + onStart() + end + + if ui.GetType and ui:GetType():ToString() == "UnityEngine.GameObject" then + ui:PlayLegacyAnimation(name, onEnd) + else + ui.GameObject:PlayLegacyAnimation(name, onEnd) + end +end + +function XUiHelper.StopAnimation() +end + +function XUiHelper.PlayCallback(onStart, onFinish) + return CS.XUiAnimationManager.PlayCallback(onStart, onFinish) +end + +--==============================-- +--desc: 默认不会插入到全局播放列表。 +--@duration: 动画时长 +--@onRefresh: 刷新动作,返回值不为空或true时中断tween +--@onFinish: 结束回调 +--@easeMethod: 自定义曲线函数 +--@return 定时器 +--==============================-- +function XUiHelper.Tween(duration, onRefresh, onFinish, easeMethod) + local startTicks = CS.XTimerManager.Ticks + local refresh = function(timer) + local t = (CS.XTimerManager.Ticks - startTicks) / duration / CS.System.TimeSpan.TicksPerSecond + t = mathMin(1, t) + t = mathMax(0, t) + if easeMethod then + t = easeMethod(t) + end + + if onRefresh then + local stop = onRefresh(t) or t == 1 + if stop then + XScheduleManager.UnSchedule(timer) + if onFinish then + onFinish() + end + return + end + end + + end + return XScheduleManager.ScheduleForever(refresh, 0) +end + +XUiHelper.EaseType = { + Linear = 1, + Sin = 2, + Increase = 3, --由慢到快 +} + +function XUiHelper.Evaluate(easeType, t) + if easeType == XUiHelper.EaseType.Linear then + return t + elseif easeType == XUiHelper.EaseType.Sin then + return math.sin(t * math.pi / 2) + elseif easeType == XUiHelper.EaseType.Increase then + t = t * t + t = mathMin(1, t) + t = mathMax(0, t) + return t + end +end + +function XUiHelper.DoUiMove(rectTf, tarPos, duration, easeType, cb) + local startPos = rectTf.anchoredPosition3D + easeType = easeType or XUiHelper.EaseType.Linear + local timer = XUiHelper.Tween(duration, function(t) + if not rectTf:Exist() then + return true + end + rectTf.anchoredPosition3D = Vec3Lerp(startPos, tarPos, t) + end, cb, function(t) + return XUiHelper.Evaluate(easeType, t) + end) + return timer +end + +function XUiHelper.DoMove(rectTf, tarPos, duration, easeType, cb) + local startPos = rectTf.localPosition + easeType = easeType or XUiHelper.EaseType.Linear + local timer = XUiHelper.Tween(duration, function(t) + if not rectTf:Exist() then + return true + end + rectTf.localPosition = Vec3Lerp(startPos, tarPos, t) + end, cb, function(t) + return XUiHelper.Evaluate(easeType, t) + end) + return timer +end + +function XUiHelper.DoWorldMove(rectTf, tarPos, duration, easeType, cb) + local startPos = rectTf.position + easeType = easeType or XUiHelper.EaseType.Linear + local timer = XUiHelper.Tween(duration, function(t) + if not rectTf:Exist() then + return true + end + rectTf.position = Vec3Lerp(startPos, tarPos, t) + end, cb, function(t) + return XUiHelper.Evaluate(easeType, t) + end) + return timer +end + +function XUiHelper.DoScale(rectTf, startScale, tarScale, duration, easeType, cb) + easeType = easeType or XUiHelper.EaseType.Linear + local timer = XUiHelper.Tween(duration, function(t) + if not rectTf:Exist() then + return true + end + rectTf.localScale = Vec3Lerp(startScale, tarScale, t) + end, cb, function(t) + return XUiHelper.Evaluate(easeType, t) + end) + return timer +end + +function XUiHelper.DoAlpha(canvasGroup, startAlpha, tarAlpha, duration, easeType, cb) + easeType = easeType or XUiHelper.EaseType.Linear + local timer = XUiHelper.Tween(duration, function(t) + if not canvasGroup:Exist() then + return true + end + canvasGroup.alpha = MathLerp(startAlpha, tarAlpha, t) + end, cb, function(t) + return XUiHelper.Evaluate(easeType, t) + end) + return timer +end +------------动画相关end------------ +--==============================-- +--desc: 计算文本所占宽 +--@textObj: 文本对象 +--@return 所占宽度 +--==============================-- +function XUiHelper.CalcTextWidth(textObj) + local tg = textObj.cachedTextGeneratorForLayout + local set = textObj:GetGenerationSettings(CS.UnityEngine.Vector2.zero) + local text = textObj.text + return mathCeil(tg:GetPreferredWidth(text, set) / textObj.pixelsPerUnit) +end + +------------首次获得弹窗Begin------------ +local FirstGetIdWaitToShowList = {} +local DELAY_POPUP_UI = false + +local PopSortFunc = function(a, b) + --角色 > 装备 + if a.Type ~= b.Type then + return a.Type == XArrangeConfigs.Types.Weapon + end + + if a.Type == XArrangeConfigs.Types.Character then + local aCharacter = XDataCenter.CharacterManager.GetCharacter(a.Id) + local bCharacter = XDataCenter.CharacterManager.GetCharacter(b.Id) + if aCharacter and bCharacter then + --品质 + if aCharacter.Quality ~= bCharacter.Quality then + return aCharacter.Quality > bCharacter.Quality + end + + --优先级 + local priorityA = XCharacterConfigs.GetCharacterPriority(a.Id) + local priorityB = XCharacterConfigs.GetCharacterPriority(b.Id) + if priorityA ~= priorityB then + return priorityA < priorityB + end + end + end + + if a.Type == XArrangeConfigs.Types.Weapon then + --品质 + local aQuality = XDataCenter.EquipManager.GetEquipQuality(a.Id) + local bQuality = XDataCenter.EquipManager.GetEquipQuality(b.Id) + if aQuality ~= bQuality then + return aQuality > bQuality + end + + --优先级 + local priorityA = XDataCenter.EquipManager.GetEquipPriority(a.Id) + local priorityB = XDataCenter.EquipManager.GetEquipPriority(b.Id) + if priorityA ~= priorityB then + return priorityA < priorityB + end + end +end + +function XUiHelper.PushInFirstGetIdList(id, type) + local beginPopUi = not next(FirstGetIdWaitToShowList) + + local data = { Id = id, Type = type } + tableInsert(FirstGetIdWaitToShowList, data) + tableSort(FirstGetIdWaitToShowList, PopSortFunc) + + if beginPopUi and not DELAY_POPUP_UI and not XLuaUiManager.IsUiShow("UiFirstGetPopUp") then + XLuaUiManager.Open("UiFirstGetPopUp", FirstGetIdWaitToShowList) + end +end + +function XUiHelper.SetDelayPopupFirstGet(isDelay) + DELAY_POPUP_UI = isDelay +end + +function XUiHelper.PopupFirstGet() + if next(FirstGetIdWaitToShowList) then + XLuaUiManager.Open("UiFirstGetPopUp", FirstGetIdWaitToShowList) + end +end + +------------首次获得弹窗End------------ +function XUiHelper.RegisterClickEvent(table, component, handle, clear) + + clear = clear and true or true + + local func = function(...) + if handle then + handle(table, ...) + end + end + + CsXUiHelper.RegisterClickEvent(component, func, clear) + +end + +function XUiHelper.RegisterSliderChangeEvent(table, component, handle, clear) + + clear = clear and true or true + + local func = function(...) + if handle then + handle(table, ...) + end + end + + CsXUiHelper.RegisterSliderChangeEvent(component, func, clear) + +end + +function XUiHelper.GetToggleVal(val) + if val == XUiToggleState.Off then + return false + elseif val == XUiToggleState.On then + return true + end +end + +function XUiHelper.ReplaceWithPlayerName(str, replaceStr) + if not str or not replaceStr then return str end + if not stringFind(str, replaceStr) then return str end + + local playerName = XPlayer.Name + if not playerName then return str end + + local tmpPlayerName = stringGsub(playerName, "%%", "$") + str = stringGsub(str, replaceStr, tmpPlayerName) + str = stringGsub(str, "%$", "%%") + + return str +end + +--把大数字按照一定的规范转换成字符串 +--规范:小于6位不转换,大于等于6位转换为w并保留小数点后2位 +--比如 600000 返回 60w +function XUiHelper.GetLargeIntNumText(num) + local t = type(num) + if t == "number" then + if num >= 100000 then + local bigNum = num / 1000 + if math.floor(bigNum) < bigNum then + return CS.XTextManager.GetText("ShowLargeIntNumText", string.format("%.2f", bigNum))-- 日服W转换为万(日本人能看懂万字) + else + return CS.XTextManager.GetText("ShowLargeIntNumText", string.format("%d", bigNum)) + end + else + return tostring(num) + end + end +end + +--富文本字符串转普通文本 +---@param: 山穷水绝处回眸一遍你 +---@return: 山穷水绝处回眸一遍你 +function XUiHelper.RichTextToTextString(str) + if not str then return "" end + return stringGsub(str, "%b<>", "") +end + +--字符串换行符可用化 +function XUiHelper.ConvertLineBreakSymbol(str) + if not str then return "" end + return stringGsub(str, "\\n", "\n") +end + +--读取Text配置并保留换行符 +function XUiHelper.ReadTextWithNewLine(text, ...) + return stringGsub(CSTextManagerGetText(text, ...), "\\n", "\n") +end + +-- 获取屏幕点击位置到指定transform的位置 +function XUiHelper.GetScreenClickPosition(transform, camera) + local screenPoint + local platform = CS.UnityEngine.Application.platform + if platform == CS.UnityEngine.RuntimePlatform.WindowsEditor + or platform == CS.UnityEngine.RuntimePlatform.WindowsPlayer then + screenPoint = CS.UnityEngine.Vector2(CS.UnityEngine.Input.mousePosition.x, CS.UnityEngine.Input.mousePosition.y) + else + screenPoint = CS.UnityEngine.Input.GetTouch(0).position + end + local hasValue, v2 = CS.UnityEngine.RectTransformUtility.ScreenPointToLocalPointInRectangle(transform, screenPoint, camera) + if hasValue then + return CS.UnityEngine.Vector3(v2.x, v2.y, 0) + else + return CS.UnityEngine.Vector3.zero + end +end + +function XUiHelper.GetText(key, ...) + return CS.XTextManager.GetText(key, ...) +end + +function XUiHelper.GetClientConfig(key, configType) + if configType == XUiHelper.ClientConfigType.String then + return CS.XGame.ClientConfig:GetString(key) + elseif configType == XUiHelper.ClientConfigType.Int then + return CS.XGame.ClientConfig:GetInt(key) + elseif configType == XUiHelper.ClientConfigType.Float then + return CS.XGame.ClientConfig:GetFloat(key) + elseif configType == XUiHelper.ClientConfigType.Bool then + return CS.XGame.ClientConfig:GetBool(key) + else + return nil + end +end + +--背包道具时间(日服) +function XUiHelper.GetBagTimeStrAndBg(second) + local timeStr + local days = mathFloor(second / D) + local hours = mathFloor(second / H) + local minutes = mathFloor((second - hours * H) / S) + + if days >= 1 then + timeStr = stringFormat("%d%s", days, STR_DAY) + else + local notZeroMin = minutes > 0 and minutes or 1 + timeStr = stringFormat("%d:%d", hours, notZeroMin) + end + return timeStr +end + +function XUiHelper.TextHasBubble(textComponent, textContent) + if not textComponent then + XLog.Error("The Function \"TextHasBubble\" Param Must Not Be Nil") + return + end + if not textContent then + XLog.Warning("The Function \"TextHasBubble\" Param (textContent) is Nil, Maybe Cause Problem") + end + textComponent:SetTextEllipsis(textContent) -- 扩展方法,显示不全用省略号表示 + local textPointHandler = textComponent.gameObject:GetComponent(typeof(CS.XTextPointHandler)) + if XTool.UObjIsNil(textPointHandler) then + textPointHandler = textComponent.gameObject:AddComponent(typeof(CS.XTextPointHandler)) + end + textPointHandler:AddTouchBeganListener(function() + if XLuaUiManager.IsUiShow("UiBubbleTip") then return end + local touchData = nil + if CS.UnityEngine.Input.touchCount > 1 then + XLog.Debug("BubbleTip:TouchCount is "..CS.UnityEngine.Input.TouchCount) + touchData = CS.UnityEngine.Input.GetTouch(0) + elseif CS.UnityEngine.Input:GetMouseButtonDown(0) then + touchData = {position = CS.UnityEngine.Vector2(CS.UnityEngine.Input.mousePosition.x, CS.UnityEngine.Input.mousePosition.y)} + end + if not touchData then return end + XLuaUiManager.Open("UiBubbleTip", touchData, textContent or textComponent.text) + end) + textPointHandler:AddTouchEndListener(function() + if XLuaUiManager.IsUiShow("UiBubbleTip") then + XLuaUiManager.Close("UiBubbleTip") + end + end) + textPointHandler:AddTouchCancelListener(function() + if XLuaUiManager.IsUiShow("UiBubbleTip") then + XLuaUiManager.Close("UiBubbleTip") + end + end) +end + +function XUiHelper.TextHasBubble(textComponent, textContent) + if not textComponent then + XLog.Error("The Function \"TextHasBubble\" Param Must Not Be Nil") + return + end + if not textContent then + XLog.Warning("The Function \"TextHasBubble\" Param (textContent) is Nil, Maybe Cause Problem") + end + textComponent:SetTextEllipsis(textContent) -- 扩展方法,显示不全用省略号表示 + local textPointHandler = textComponent.gameObject:GetComponent(typeof(CS.XTextPointHandler)) + if XTool.UObjIsNil(textPointHandler) then + textPointHandler = textComponent.gameObject:AddComponent(typeof(CS.XTextPointHandler)) + end + textPointHandler:AddTouchBeganListener(function() + if XLuaUiManager.IsUiShow("UiBubbleTip") then return end + local touchData = nil + if CS.UnityEngine.Input.touchCount > 1 then + touchData = CS.UnityEngine.Input.GetTouch(0) + elseif CS.UnityEngine.Input:GetMouseButtonDown(0) then + touchData = {position = CS.UnityEngine.Vector2(CS.UnityEngine.Input.mousePosition.x, CS.UnityEngine.Input.mousePosition.y)} + end + if not touchData then return end + XLuaUiManager.Open("UiBubbleTip", touchData, textContent or textComponent.text) + end) + textPointHandler:AddTouchEndListener(function() + if XLuaUiManager.IsUiShow("UiBubbleTip") then + XLuaUiManager.Close("UiBubbleTip") + end + end) + textPointHandler:AddTouchCancelListener(function() + if XLuaUiManager.IsUiShow("UiBubbleTip") then + XLuaUiManager.Close("UiBubbleTip") + end + end) +end + +function XUiHelper.GetText(key, ...) + return CS.XTextManager.GetText(key, ...) +end + +--============================== + ---@desc text表中读到的\n会被Unity识别为\\n + ---@content 转换内容 + ---@return string +--============================== +function XUiHelper.ReplaceTextNewLine(content) + return string.gsub(content, "\\n", "\n") +end diff --git a/Resources/Scripts/XConfig/XActivityBriefConfigs.lua b/Resources/Scripts/XConfig/XActivityBriefConfigs.lua new file mode 100644 index 00000000..d72a36a0 --- /dev/null +++ b/Resources/Scripts/XConfig/XActivityBriefConfigs.lua @@ -0,0 +1,171 @@ +local TABLE_ACTIVITY_PATH = "Client/ActivityBrief/ActivityBrief.tab" +local TABLE_ACTIVITY_SHOP = "Client/ActivityBrief/ActivityBriefShop.tab" +local TABLE_ACTIVITY_TASK = "Client/ActivityBrief/ActivityBriefTask.tab" +local TABLE_ACTIVITY_GROUP_PATH = "Client/ActivityBrief/ActivityBriefGroup.tab" +local TABLE_ACTIVITY_SPECIAL = "Client/ActivityBrief/SpecialActivity.tab" +local TABLE_ACTIVITY_Story = "Share/ActivityBrief/ActivityBriefStory.tab" + +local ParseToTimestamp = XTime.ParseToTimestamp + +local ActivityTemplates = {} +local ActivityShopTemplates = {} +local ActivityTaskTemplates = {} +local ActivityGroupTemplates = {} +local SpecialActivityTemplates = {} +local ActivityStoryTemplates = {} +local SkipIdToRedPointConditionsDic = {} + +XActivityBriefConfigs = XActivityBriefConfigs or {} + +-- 活动名称Id(有需要新增,勿删改!) +XActivityBriefConfigs.ActivityGroupId = { + MainLine = 1, --主线活动 + Branch = 2, --支线活动 + BossSingle = 3, --单机Boss活动 + BossOnline = 4, --联机Boss活动 + Prequel = 5, --间章故事-角色A + BabelTower = 6, --巴别塔 + RougueLike = 7, --爬塔 + RepeatChallenge = 8, --复刷关 + ArenaOnline = 9, --区域联机 + UnionKill = 10, --狙击战 + ShortStories = 11, --短篇故事 + Prequel2 = 12, --间章故事-角色B + Labyrinth = 13, --迷宫 + Society = 14, --公会 + Resource = 15, --资源 + BigWar = 16, --大作战 + Extra = 17, --番外-普通 + WorldBoss = 18, --世界Boss + Expedition = 19, --自走棋 + FubenBossSingle = 20, --幻痛囚笼 + ActivityBriefShop = 21, --活动商店 + Extra2 = 22, --番外-隐藏 + MaintainerAction = 23, --大富翁 + RpgTower = 24, --RPG玩法 + ActivityDrawCard = 25, --活动抽卡 + TRPGMainLine = 26, --终焉福音-主线跑团活动 + NewCharActivity = 27, -- 新角色教学活动 + FubenActivityTrial = 28, -- 试玩关 + ShiTu = 29, -- 师徒系统 + Nier = 30, -- 尼尔玩法 + Pokemon = 31, -- 口袋战双 + Pursuit = 32, -- 追击玩法 + StrongHold = 33, --超级据点 + Simulate = 34, -- 模拟战 + Partner = 35, --伙伴系统 + MoeWar = 38, --萌战 + PetCard = 39, --宠物抽卡 + PetTrial = 40, --新宠物活动 + PokerGuessing = 41, --翻牌小游戏 + Hack = 42, --骇客 + RpgMaker = 43, --端午活动 + Reform = 44, --改造玩法 + CoupleCombat = 45, --双人同行 + SuperTower = 46, --超级爬塔 + SummerSeries = 47, --夏活系列关 + KillZone = 48, --杀戮无双 +} + +local InitSkipIdToRedPointConditionsDic = function() + SkipIdToRedPointConditionsDic[11739] = {XRedPointConditions.Types.CONDITION_GUARD_CAMP_RED} + SkipIdToRedPointConditionsDic[80011] = {XRedPointConditions.Types.CONDITION_WHITEVALENTINE2021_ENTRYRED} + SkipIdToRedPointConditionsDic[11753] = {XRedPointConditions.Types.CONDITION_FINGERGUESSING_TASK} + SkipIdToRedPointConditionsDic[11757] = {XRedPointConditions.Types.CONDITION_MOVIE_ASSEMBLE_01} + SkipIdToRedPointConditionsDic[11759] = {XRedPointConditions.Types.CONDITION_MINSWEEPING_RED} + SkipIdToRedPointConditionsDic[11761] = {XRedPointConditions.Types.CONDITION_FASHION_STORY_HAVE_STAGE} + SkipIdToRedPointConditionsDic[81103] = {XRedPointConditions.Types.CONDITION_RPG_MAKER_GAME_RED} + SkipIdToRedPointConditionsDic[1400008] = {XRedPointConditions.Types.CONDITION_SLOTMACHINE_RED} + SkipIdToRedPointConditionsDic[1400009] = {XRedPointConditions.Types.CONDITION_SLOTMACHINE_REDL} +end + +function XActivityBriefConfigs.Init() + ActivityTemplates = XTableManager.ReadByIntKey(TABLE_ACTIVITY_PATH, XTable.XTableBriefActivity, "Id") + ActivityShopTemplates= XTableManager.ReadByIntKey(TABLE_ACTIVITY_SHOP, XTable.XTableActivityBriefShop, "Id") + ActivityTaskTemplates= XTableManager.ReadByIntKey(TABLE_ACTIVITY_TASK, XTable.XTableActivityBriefTask, "Id") + ActivityGroupTemplates = XTableManager.ReadByIntKey(TABLE_ACTIVITY_GROUP_PATH, XTable.XTableActivityBriefGroup, "Id") + SpecialActivityTemplates = XTableManager.ReadByIntKey(TABLE_ACTIVITY_SPECIAL, XTable.XTableSpecialActivity, "Id") + ActivityStoryTemplates = XTableManager.ReadByIntKey(TABLE_ACTIVITY_Story, XTable.XTableActivityBriefStory, "Id") + + InitSkipIdToRedPointConditionsDic() +end + +function XActivityBriefConfigs.GetActivityBeginTime() + local config = XActivityBriefConfigs.GetActivityConfig() + return XFunctionManager.GetStartTimeByTimeId(config.TimeId) +end + +function XActivityBriefConfigs.GetActivityEndTime() + local config = XActivityBriefConfigs.GetActivityConfig() + return XFunctionManager.GetEndTimeByTimeId(config.TimeId) +end + +function XActivityBriefConfigs.GetActivityConfig() + return ActivityTemplates[1] +end + +function XActivityBriefConfigs.GetActivityModels() + local config = XActivityBriefConfigs.GetActivityConfig() + return config.UIModelId or {} +end + +function XActivityBriefConfigs.GetSpinePath(index) + local config = XActivityBriefConfigs.GetActivityConfig() + return config.SpinePath[index] or "" +end + +function XActivityBriefConfigs.GetActivityEntrySkipId(id) + return SpecialActivityTemplates[id].SkipId +end + +function XActivityBriefConfigs.GetAllActivityEntryConfig() + return SpecialActivityTemplates +end + +function XActivityBriefConfigs.GetActivityShopByInfoId(id) + return ActivityShopTemplates[id] +end + +function XActivityBriefConfigs.GetActivityTaskByInfoId(id) + return ActivityTaskTemplates[id] +end + +function XActivityBriefConfigs.GetActivityGroupConfig(groupId) + local groupConfig = ActivityGroupTemplates[groupId] + if not groupConfig then + XLog.ErrorTableDataNotFound("XActivityBriefConfigs.GetActivityGroupConfig", + "根据groupId获取的配置表项", TABLE_ACTIVITY_GROUP_PATH, "groupId", tostring(groupId)) + return + end + return groupConfig +end + +function XActivityBriefConfigs.TestOpenActivity() + local newTemplate = {} + for id, template in pairs(ActivityTemplates) do + if id ~= 1 then + newTemplate[id] = template + else + newTemplate[id] = XTool.Clone(template) + newTemplate[id].TimeId = 24 + end + end + ActivityTemplates = newTemplate +end + +function XActivityBriefConfigs.GetTableActivityPath() + return TABLE_ACTIVITY_PATH +end + +function XActivityBriefConfigs.GetActivityStoryConfig() + return ActivityStoryTemplates +end + +function XActivityBriefConfigs.GetActivityBriefGroup(id) + local config = XActivityBriefConfigs.GetActivityGroupConfig(id) + return config.Name +end + +function XActivityBriefConfigs.GetRedPointConditionsBySkipId(skipId) + return skipId and SkipIdToRedPointConditionsDic[skipId] +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XActivityConfigs.lua b/Resources/Scripts/XConfig/XActivityConfigs.lua new file mode 100644 index 00000000..8108e29c --- /dev/null +++ b/Resources/Scripts/XConfig/XActivityConfigs.lua @@ -0,0 +1,108 @@ +local ParseToTimestamp = XTime.ParseToTimestamp +local TimestampToGameDateTimeString = XTime.TimestampToGameDateTimeString + +local TABLE_ACTIVITY_PATH = "Client/Activity/Activity.tab" +local TABLE_ACTIVITY_GROUP_PATH = "Client/Activity/ActivityGroup.tab" +local TABLE_ACTIVITY_LINK_PATH = "Client/Activity/ActivityLink.tab" + +local ActivityTemplates = {} +local ActivityGroupTemplates = {} +local ActivityLinkTemplates = {} + +XActivityConfigs = XActivityConfigs or {} + +--活动类型 +XActivityConfigs.ActivityType = { + Task = 1, --任务 + Shop = 2, --商店 + Skip = 3, --跳转 + SendInvitation = 4, --邀请他人 + AcceptInvitation = 5, -- 接受邀请 + JigsawPuzzle = 6, -- 拼图 + Link = 7, --活动外链类型 + ConsumeReward = 8, -- 累消奖励 + ScratchTicket = 9, -- 普通刮刮乐 + ScratchTicketGolden = 10, -- 黄金刮刮乐 +} + +-- 活动背景类型 +XActivityConfigs.ActivityBgType = { + Image = 1, -- 普通图片 + Spine = 2, -- Spine动画 +} + +-- 任务面板跳转类型 +XActivityConfigs.TaskPanelSkipType = { + CanZhangHeMing_Qu = 20031, -- 拼图游戏(曲版本预热) + CanZhangHeMing_LuNa = 20036, -- 拼图游戏(露娜预热) + ChrismasTree_Dress = 20048, -- 装点圣诞树小游戏 + Couplet_Game = 20064, -- 春节对联游戏 + CanZhangHeMing_SP = 20070, -- 拼图游戏(SP角色预热) + InvertCard_Game = 20076, -- 翻牌小游戏 +} + +function XActivityConfigs.Init() + ActivityTemplates = XTableManager.ReadByIntKey(TABLE_ACTIVITY_PATH, XTable.XTableActivity, "Id") + ActivityGroupTemplates = XTableManager.ReadByIntKey(TABLE_ACTIVITY_GROUP_PATH, XTable.XTableActivityGroup, "Id") + ActivityLinkTemplates = XTableManager.ReadByIntKey(TABLE_ACTIVITY_LINK_PATH, XTable.XTableActivityLink, "Id") +end + +function XActivityConfigs.GetActivityTemplates() + return ActivityTemplates +end + +function XActivityConfigs.GetActivityGroupTemplates() + return ActivityGroupTemplates +end + +function XActivityConfigs.GetActivityTemplate(activityId) + return ActivityTemplates[activityId] +end + + +function XActivityConfigs.GetActivityTimeStr(activityId, beginTime, endTime) + local activityCfg = XActivityConfigs.GetActivityTemplate(activityId) + local format = "yyyy-MM-dd HH:mm" + local beginTimeStr = "" + local endTimeStr = "" + if not string.IsNilOrEmpty(activityCfg.ShowBeginTime) then + beginTimeStr = activityCfg.ShowBeginTime + else + if beginTime and beginTime ~= 0 then + beginTimeStr = TimestampToGameDateTimeString(beginTime, format) + else + beginTimeStr = TimestampToGameDateTimeString(XFunctionManager.GetStartTimeByTimeId(activityCfg.TimeId), format) + end + end + + if not string.IsNilOrEmpty(activityCfg.ShowEndTime) then + endTimeStr = activityCfg.ShowEndTime + else + if endTime and endTime ~= 0 then + endTimeStr = TimestampToGameDateTimeString(endTime, format) + else + endTimeStr = TimestampToGameDateTimeString(XFunctionManager.GetEndTimeByTimeId(activityCfg.TimeId), format) + end + end + + if not string.IsNilOrEmpty(beginTimeStr) and not string.IsNilOrEmpty(endTimeStr) then + return beginTimeStr .. "~" .. endTimeStr + else + if not string.IsNilOrEmpty(beginTimeStr) then + return beginTimeStr + elseif not string.IsNilOrEmpty(endTimeStr) then + return endTimeStr + else + return "" + end + end +end + +function XActivityConfigs.GetActivityLinkCfg(id) + return ActivityLinkTemplates[id] +end + +function XActivityConfigs.GetActivityLinkTemplate() + return ActivityLinkTemplates +end + diff --git a/Resources/Scripts/XConfig/XAppConfigs.lua b/Resources/Scripts/XConfig/XAppConfigs.lua new file mode 100644 index 00000000..8f4782b0 --- /dev/null +++ b/Resources/Scripts/XConfig/XAppConfigs.lua @@ -0,0 +1,9 @@ +-- +-- Author: wujie +-- Note: app lua层配置相关 + +XAppConfigs = XAppConfigs or {} + +XAppConfigs.PackageName = { + Hero = "com.kurogame.haru.hero", +} \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XArchiveConfigs.lua b/Resources/Scripts/XConfig/XArchiveConfigs.lua new file mode 100644 index 00000000..a88f785b --- /dev/null +++ b/Resources/Scripts/XConfig/XArchiveConfigs.lua @@ -0,0 +1,794 @@ +-- +-- Author: zhangshuang、wujie +-- Note: 图鉴配置相关 + +XArchiveConfigs = XArchiveConfigs or {} + + +XArchiveConfigs.SubSystemType = { + Monster = 1, + Weapon = 2, + Awareness = 3, + Story = 4, + CG = 5, + NPC = 6, + Email = 7, + Partner = 8, +} + +XArchiveConfigs.SettingType = { + All = 0, + Setting = 1, + Story = 2, +} + +-- 设定位置 +XArchiveConfigs.SettingIndex ={ + First = 1, +} + +XArchiveConfigs.WeaponCamera = { + Main = 1, -- 武器详情默认是主镜头 + Setting = 2, +} + +XArchiveConfigs.MonsterType = { + Pawn = 1, + Elite = 2, + Boss = 3, +} + +XArchiveConfigs.MonsterInfoType = { + Short = 1, + Long = 2, +} + +XArchiveConfigs.MonsterSettingType = { + Setting = 1, + Story = 2, +} + +XArchiveConfigs.MonsterDetailType = { + Synopsis = 1, + Info = 2, + Setting = 3, + Skill = 4, + Zoom = 5, + ScreenShot = 6, +} + +XArchiveConfigs.EquipStarType = { + All = 0, + One = 1, + Two = 2, + Three = 3, + Four = 4, + Five = 5, + Six = 6, +} + +XArchiveConfigs.EquipLikeType = { + NULL = 0, + Dis = 1, + Like = 2, +} + +XArchiveConfigs.StarToQualityName = { + [XArchiveConfigs.EquipStarType.All] = CS.XTextManager.GetText("ArchiveAwarenessFliterAll"), + [XArchiveConfigs.EquipStarType.Two] = CS.XTextManager.GetText("ArchiveAwarenessFliterTwoStar"), + [XArchiveConfigs.EquipStarType.Three] = CS.XTextManager.GetText("ArchiveAwarenessFliterThreeStar"), + [XArchiveConfigs.EquipStarType.Four] = CS.XTextManager.GetText("ArchiveAwarenessFliterFourStar"), + [XArchiveConfigs.EquipStarType.Five] = CS.XTextManager.GetText("ArchiveAwarenessFliterFiveStar"), + [XArchiveConfigs.EquipStarType.Six] = CS.XTextManager.GetText("ArchiveAwarenessFliterSixStar"), +} + +XArchiveConfigs.EvaluateOnForAll = CS.XGame.ClientConfig:GetInt("ArchiveEvaluateOnForAll") + +XArchiveConfigs.OnForAllState = { + Off = 0, + On = 1, +} + +XArchiveConfigs.NpcGridState = { + Open = 0, + Close = 1, +} + +XArchiveConfigs.EmailType = { + Email = 1, + Communication = 2, +} + +XArchiveConfigs.PartnerSettingType = { + Setting = 1, + Story = 2, +} + +XArchiveConfigs.MonsterDetailUiType = { + Default = 1, -- 默认图鉴打开 + Show = 2, -- 只负责显示,屏蔽玩家操作 +} + +local TABLE_TAG = "Share/Archive/Tag.tab" +local TABLE_ARCHIVE = "Share/Archive/Archive.tab" +local TABLE_MONSTER = "Share/Archive/Monster.tab" +local TABLE_MONSTERINFO = "Share/Archive/MonsterInfo.tab" +local TABLE_MONSTERSKILL = "Share/Archive/MonsterSkill.tab" +local TABLE_MONSTERSETTING = "Share/Archive/MonsterSetting.tab" +local TABLE_SAMENPCGROUP = "Share/Archive/SameNpcGroup.tab" +local TABLE_MONSTERNPCDATA = "Client/Archive/MonsterNpcData.tab" +local TABLE_AWARENESSSETTING = "Share/Archive/AwarenessSetting.tab" +local TABLE_WEAPONSETTING = "Share/Archive/WeaponSetting.tab" +local TABLE_MONSTERMODEL_TRANS = "Client/Archive/MonsterModelTrans.tab" +local TABLE_MONSTER_EFFECT = "Client/Archive/MonsterEffect.tab" + +local TABLE_STORYGROUP = "Share/Archive/StoryGroup.tab" +local TABLE_STORYCHAPTER = "Share/Archive/StoryChapter.tab" +local TABLE_STORYDETAIL = "Share/Archive/StoryDetail.tab" + +local TABLE_STORYNPC = "Share/Archive/StoryNpc.tab" +local TABLE_STORYNPCSETTING = "Share/Archive/StoryNpcSetting.tab" + +local TABLE_CGDETAIL = "Share/Archive/CGDetail.tab" +local TABLE_CGGROUP = "Share/Archive/CGGroup.tab" + +local TABLE_ARCHIVEMAIL = "Share/Archive/ArchiveMail.tab" +local TABLE_COMMUNICATION = "Share/Archive/Communication.tab" +local TABLE_EVENTDATEGROUP = "Share/Archive/EventDateGroup.tab" + +local TABLE_ARCHIVE_WEAPON_GROUP_PATH = "Client/Archive/ArchiveWeaponGroup.tab" +local TABLE_ARCHIVE_AWARENESS_GROUP_PATH = "Client/Archive/ArchiveAwarenessGroup.tab" +local TABLE_ARCHIVE_AWARENESS_GROUPTYPE_PATH = "Client/Archive/ArchiveAwarenessGroupType.tab" + +local TABLE_ARCHIVE_PARTNER_SETTING = "Share/Archive/PartnerSetting.tab" +local TABLE_ARCHIVE_PARTNER = "Client/Archive/ArchivePartner.tab" +local TABLE_ARCHIVE_PARTNER_GROUP = "Client/Archive/ArchivePartnerGroup.tab" + +local tableSort = table.sort + +local Tags = {} +local Archives = {} +local Monsters = {} +local MonsterInfos = {} +local MonsterSkills = {} +local MonsterSettings = {} +local AwarenessSettings = {} +local WeaponSettings = {} +local SameNpcGroups = {} +local MonsterNpcDatas = {} +local MonsterModelTrans = {} +local MonsterEffects = {} + +local StoryGroups = {} +local StoryChapters = {} +local StoryDetails = {} + +local StoryNpc = {} +local StoryNpcSetting = {} + +local CGGroups = {} +local CGDetails = {} + +local ArchiveMails = {} +local ArchiveCommunications = {} +local EventDateGroups = {} + +local WeaponGroup = {} +local WeaponTemplateIdToSettingListDic = {} +local ShowedWeaponTypeList = {} +local WeaponTypeToIdsDic = {} +local WeaponSumCollectNum = 0 + +local AwarenessGroup = {} +local AwarenessGroupType = {} +local AwarenessShowedStatusDic = {} +local AwarenessSumCollectNum = 0 +local AwarenessTypeToGroupDatasDic = {} +local AwarenessSuitIdToSettingListDic = {} + +local ArchiveTagAllList = {} +local ArchiveStoryGroupAllList = {} +local ArchiveSameNpc = {} +local ArchiveMonsterTransDic = {} +local ArchiveMonsterEffectDatasDic = {} + +local ArchivePartnerSettings = {} +local ArchivePartners = {} +local ArchivePartnerGroups = {} + +function XArchiveConfigs.Init() + Tags = XTableManager.ReadByIntKey(TABLE_TAG, XTable.XTableArchiveTag, "Id") + Archives = XTableManager.ReadByIntKey(TABLE_ARCHIVE, XTable.XTableArchive, "Id") + Monsters = XTableManager.ReadByIntKey(TABLE_MONSTER, XTable.XTableArchiveMonster, "Id") + MonsterInfos = XTableManager.ReadByIntKey(TABLE_MONSTERINFO, XTable.XTableArchiveMonsterInfo, "Id") + MonsterSkills = XTableManager.ReadByIntKey(TABLE_MONSTERSKILL, XTable.XTableArchiveMonsterSkill, "Id") + MonsterSettings = XTableManager.ReadByIntKey(TABLE_MONSTERSETTING, XTable.XTableMonsterSetting, "Id") + SameNpcGroups = XTableManager.ReadByIntKey(TABLE_SAMENPCGROUP, XTable.XTableSameNpcGroup, "Id") + + MonsterNpcDatas = XTableManager.ReadByIntKey(TABLE_MONSTERNPCDATA, XTable.XTableMonsterNpcData, "Id") + MonsterModelTrans = XTableManager.ReadByIntKey(TABLE_MONSTERMODEL_TRANS, XTable.XTableMonsterModelTrans, "Id") + MonsterEffects = XTableManager.ReadByIntKey(TABLE_MONSTER_EFFECT, XTable.XTableMonsterEffect, "Id") + + StoryGroups = XTableManager.ReadByIntKey(TABLE_STORYGROUP, XTable.XTableArchiveStoryGroup, "Id") + StoryChapters = XTableManager.ReadByIntKey(TABLE_STORYCHAPTER, XTable.XTableArchiveStoryChapter, "Id") + StoryDetails = XTableManager.ReadByIntKey(TABLE_STORYDETAIL, XTable.XTableArchiveStoryDetail, "Id") + + StoryNpc = XTableManager.ReadByIntKey(TABLE_STORYNPC, XTable.XTableArchiveStoryNpc, "Id") + StoryNpcSetting = XTableManager.ReadByIntKey(TABLE_STORYNPCSETTING, XTable.XTableArchiveStoryNpcSetting, "Id") + + CGGroups = XTableManager.ReadByIntKey(TABLE_CGGROUP, XTable.XTableArchiveCGGroup, "Id") + CGDetails = XTableManager.ReadByIntKey(TABLE_CGDETAIL, XTable.XTableArchiveCGDetail, "Id") + + ArchiveMails = XTableManager.ReadByIntKey(TABLE_ARCHIVEMAIL, XTable.XTableArchiveMail, "Id") + ArchiveCommunications = XTableManager.ReadByIntKey(TABLE_COMMUNICATION, XTable.XTableArchiveCommunication, "Id") + EventDateGroups = XTableManager.ReadByIntKey(TABLE_EVENTDATEGROUP, XTable.XTableArchiveEventDateGroup, "Id") + + WeaponGroup = XTableManager.ReadByIntKey(TABLE_ARCHIVE_WEAPON_GROUP_PATH, XTable.XTableArchiveWeaponGroup, "Id") + WeaponSettings = XTableManager.ReadByIntKey(TABLE_WEAPONSETTING, XTable.XTableWeaponSetting, "Id") + + AwarenessGroup = XTableManager.ReadByIntKey(TABLE_ARCHIVE_AWARENESS_GROUP_PATH, XTable.XTableArchiveAwarenessGroup, "Id") + AwarenessGroupType = XTableManager.ReadByIntKey(TABLE_ARCHIVE_AWARENESS_GROUPTYPE_PATH, XTable.XTableArchiveAwarenessGroupType, "GroupId") + AwarenessSettings = XTableManager.ReadByIntKey(TABLE_AWARENESSSETTING, XTable.XTableAwarenessSetting, "Id") + + ArchivePartnerSettings = XTableManager.ReadByIntKey(TABLE_ARCHIVE_PARTNER_SETTING, XTable.XTablePartnerSetting, "Id") + ArchivePartners = XTableManager.ReadByIntKey(TABLE_ARCHIVE_PARTNER, XTable.XTableArchivePartner, "Id") + ArchivePartnerGroups = XTableManager.ReadByIntKey(TABLE_ARCHIVE_PARTNER_GROUP, XTable.XTableArchivePartnerGroup, "Id") + + XArchiveConfigs.SetArchiveTagAllList() + XArchiveConfigs.SetArchiveSameNpc() + XArchiveConfigs.SetArchiveMonsterModelTransDic() + XArchiveConfigs.SetArchiveMonsterEffectsDic() + + XArchiveConfigs.CreateShowedWeaponTypeList() + XArchiveConfigs.CreateWeaponTemplateIdToSettingDataListDic() + XArchiveConfigs.SetWeaponSumCollectNum() + XArchiveConfigs.CreateWeaponTypeToIdsDic() + + XArchiveConfigs.CreateAwarenessShowedStatusDic() + XArchiveConfigs.SetAwarenessSumCollectNum() + XArchiveConfigs.CreateAwarenessTypeToGroupDatasDic() + XArchiveConfigs.CreateAwarenessSiteToBgPathDic() + XArchiveConfigs.CreateAwarenessSuitIdToSettingDataListDic() + + XArchiveConfigs.SetArchiveStoryGroupAllList() +end + +function XArchiveConfigs.GetArchiveConfigById(Id) + return Archives[Id] +end + +function XArchiveConfigs.GetArchiveConfigs() + return Archives +end + +function XArchiveConfigs.GetArchiveMonsterConfigs() + return Monsters +end + +function XArchiveConfigs.GetArchiveMonsterConfigById(id) + return Monsters[id] +end + +function XArchiveConfigs.GetArchiveMonsterInfoConfigs() + return MonsterInfos +end + +function XArchiveConfigs.GetArchiveMonsterInfoConfigById(id) + return MonsterInfos[id] +end + +function XArchiveConfigs.GetArchiveMonsterSkillConfigs() + return MonsterSkills +end + +function XArchiveConfigs.GetArchiveMonsterSkillConfigById(id) + return MonsterSkills[id] +end + +function XArchiveConfigs.GetArchiveMonsterSettingConfigs() + return MonsterSettings +end + +function XArchiveConfigs.GetArchiveMonsterSettingConfigById(id) + return MonsterSettings[id] +end + +function XArchiveConfigs.GetArchiveTagCfgById(id) + return Tags[id] +end + +function XArchiveConfigs.GetArchiveTagAllList() + return ArchiveTagAllList +end + +function XArchiveConfigs.GetSameNpcId(npcId) + return ArchiveSameNpc[npcId] and ArchiveSameNpc[npcId] or npcId +end + +function XArchiveConfigs.GetMonsterTransDataGroup(npcId) + return ArchiveMonsterTransDic[npcId] +end + +function XArchiveConfigs.GetMonsterTransDatas(npcId,npcState) + local archiveMonsterTransData = ArchiveMonsterTransDic[npcId] + return archiveMonsterTransData and archiveMonsterTransData[npcState] +end + +function XArchiveConfigs.GetMonsterEffectDatas(npcId,npcState) + local archiveMonsterEffectData = ArchiveMonsterEffectDatasDic[npcId] + return archiveMonsterEffectData and archiveMonsterEffectData[npcState] +end + +------------------------------------------------------------- + +function XArchiveConfigs.GetAwarenessSettingById(Id) + return AwarenessSettings[Id] +end + +function XArchiveConfigs.GetAwarenessSettings() + return AwarenessSettings +end + +function XArchiveConfigs.GetAwarenessGroupTypes() + local list = {} + for _,type in pairs(AwarenessGroupType) do + table.insert(list,type) + end + return XArchiveConfigs.SortByOrder(list) +end + +function XArchiveConfigs.GetWeaponSettingById(Id) + return WeaponSettings[Id] +end + +function XArchiveConfigs.GetWeaponSettings() + return WeaponSettings +end + +function XArchiveConfigs.GetMonsterNpcDataById(Id) + if not MonsterNpcDatas[Id] then + XLog.ErrorTableDataNotFound("XArchiveConfigs.GetMonsterNpcDataById", "配置表项", TABLE_MONSTERNPCDATA, "Id", tostring(Id)) + end + return MonsterNpcDatas[Id] or {} +end + + +-----------------------------怪物图鉴---------------------------- +function XArchiveConfigs.SetArchiveTagAllList() + ArchiveTagAllList = {} + for _, tag in pairs(Tags or {}) do + for _,groupId in pairs(tag.TagGroupId) do + if not ArchiveTagAllList[groupId] then + ArchiveTagAllList[groupId] = {} + end + if tag.IsNotShow == 0 then + table.insert(ArchiveTagAllList[groupId], tag) + end + end + end + for _,v in pairs(ArchiveTagAllList)do + XArchiveConfigs.SortByOrder(v) + end +end + +function XArchiveConfigs.SetArchiveSameNpc() + for _,group in pairs(SameNpcGroups or {}) do + for _,npcId in pairs(group.NpcId) do + ArchiveSameNpc[npcId] = group.Id + end + end +end + +function XArchiveConfigs.SetArchiveMonsterModelTransDic() + for _,transData in pairs(MonsterModelTrans or {}) do + local archiveMonsterTransData = ArchiveMonsterTransDic[transData.NpcId] + if not archiveMonsterTransData then + archiveMonsterTransData = {} + ArchiveMonsterTransDic[transData.NpcId] = archiveMonsterTransData + end + + archiveMonsterTransData[transData.NpcState] = transData + end +end + +function XArchiveConfigs.SetArchiveMonsterEffectsDic() + for _,transData in pairs(MonsterEffects or {}) do + local archiveMonsterEffectData = ArchiveMonsterEffectDatasDic[transData.NpcId] + if not archiveMonsterEffectData then + archiveMonsterEffectData = {} + ArchiveMonsterEffectDatasDic[transData.NpcId] = archiveMonsterEffectData + end + + local archiveMonsterEffect = archiveMonsterEffectData[transData.NpcState] + if not archiveMonsterEffect then + archiveMonsterEffect = {} + archiveMonsterEffectData[transData.NpcState] = archiveMonsterEffect + end + archiveMonsterEffect[transData.EffectNodeName] = transData.EffectPath + end +end + +function XArchiveConfigs.SortByOrder(list) + tableSort(list, function(a, b) + if a.Order then + if a.Order == b.Order then + return a.Id > b.Id + else + return a.Order < b.Order + end + else + if a:GetOrder() == b:GetOrder() then + return a:GetId() > b:GetId() + else + return a:GetOrder() < b:GetOrder() + end + end + end) + return list +end + +function XArchiveConfigs.GetMonsterRealName(id) + local name = XArchiveConfigs.GetMonsterNpcDataById(id).Name + if not name then + XLog.ErrorTableDataNotFound("XArchiveConfigs.GetMonsterRealName", "配置表项中的Name字段", TABLE_MONSTERNPCDATA, "id", tostring(id)) + return "" + end + return name +end + +function XArchiveConfigs.GetMonsterModel(id) + return XArchiveConfigs.GetMonsterNpcDataById(id).ModelId +end + +function XArchiveConfigs.GetCountUnitChange(count) + local newCount = count + if count >= 1000 then + newCount = count / 1000 + else + return newCount + end + local a,b = math.modf(newCount) + return b >= 0.05 and string.format("%.1fk", newCount) or string.format("%dk", a) +end + +-- 武器、意识相关------------->>> +function XArchiveConfigs.CreateShowedWeaponTypeList() + for _, group in pairs(WeaponGroup) do + table.insert(ShowedWeaponTypeList, group.Id) + end + + table.sort(ShowedWeaponTypeList,function(aType,bType) + local aData = XArchiveConfigs.GetWeaponGroupByType(aType) + local bData = XArchiveConfigs.GetWeaponGroupByType(bType) + return aData.Order < bData.Order + end) +end + +function XArchiveConfigs.CreateWeaponTemplateIdToSettingDataListDic() + local equipId + for _, settingData in pairs(WeaponSettings) do + equipId = settingData.EquipId + WeaponTemplateIdToSettingListDic[equipId] = WeaponTemplateIdToSettingListDic[equipId] or {} + table.insert(WeaponTemplateIdToSettingListDic[equipId], settingData) + end +end + +function XArchiveConfigs.SetWeaponSumCollectNum() + for _, _ in pairs(WeaponTemplateIdToSettingListDic) do + WeaponSumCollectNum = WeaponSumCollectNum + 1 + end +end + +function XArchiveConfigs.CreateWeaponTypeToIdsDic() + for type, _ in pairs(WeaponGroup) do + WeaponTypeToIdsDic[type] = {} + end + + local templateData + local equipType + for templateId, _ in pairs(WeaponTemplateIdToSettingListDic) do + templateData = XEquipConfig.GetEquipCfg(templateId) + equipType = templateData.Type + if WeaponTypeToIdsDic[equipType] then + table.insert(WeaponTypeToIdsDic[equipType], templateId) + end + end +end + +function XArchiveConfigs.CreateAwarenessShowedStatusDic() + local templateIdList + for suitId, _ in pairs(AwarenessGroup) do + templateIdList = XEquipConfig.GetEquipTemplateIdsBySuitId(suitId) + for _, templateId in ipairs(templateIdList) do + AwarenessShowedStatusDic[templateId] = true + end + end +end + +function XArchiveConfigs.SetAwarenessSumCollectNum() + for _, _ in pairs(AwarenessShowedStatusDic) do + AwarenessSumCollectNum = AwarenessSumCollectNum + 1 + end +end + +function XArchiveConfigs.CreateAwarenessTypeToGroupDatasDic() + for _, type in pairs(AwarenessGroupType) do + AwarenessTypeToGroupDatasDic[type.GroupId] = {} + end + + local groupType + for _, groupData in pairs(AwarenessGroup) do + groupType = groupData.Type + if AwarenessTypeToGroupDatasDic[groupType] then + table.insert(AwarenessTypeToGroupDatasDic[groupType], groupData) + end + end +end + +function XArchiveConfigs.CreateAwarenessSiteToBgPathDic() + XArchiveConfigs.SiteToBgPath = { + [XEquipConfig.EquipSite.Awareness.One] = CS.XGame.ClientConfig:GetString("ArchiveAwarenessSiteBgPath1"), + [XEquipConfig.EquipSite.Awareness.Two] = CS.XGame.ClientConfig:GetString("ArchiveAwarenessSiteBgPath2"), + [XEquipConfig.EquipSite.Awareness.Three] = CS.XGame.ClientConfig:GetString("ArchiveAwarenessSiteBgPath3"), + [XEquipConfig.EquipSite.Awareness.Four] = CS.XGame.ClientConfig:GetString("ArchiveAwarenessSiteBgPath4"), + [XEquipConfig.EquipSite.Awareness.Five] = CS.XGame.ClientConfig:GetString("ArchiveAwarenessSiteBgPath5"), + [XEquipConfig.EquipSite.Awareness.Six] = CS.XGame.ClientConfig:GetString("ArchiveAwarenessSiteBgPath6"), + } +end + +function XArchiveConfigs.CreateAwarenessSuitIdToSettingDataListDic() + local suitId + for _, settingData in pairs(AwarenessSettings) do + suitId = settingData.SuitId + AwarenessSuitIdToSettingListDic[suitId] = AwarenessSuitIdToSettingListDic[suitId] or {} + table.insert(AwarenessSuitIdToSettingListDic[suitId], settingData) + end +end + +function XArchiveConfigs.GetWeaponSumCollectNum() + return WeaponSumCollectNum +end + +function XArchiveConfigs.GetWeaponGroup() + return WeaponGroup +end + +function XArchiveConfigs.GetWeaponGroupByType(type) + return WeaponGroup[type] +end + +function XArchiveConfigs.GetWeaponGroupName(type) + return WeaponGroup[type].GroupName +end + +function XArchiveConfigs.GetShowedWeaponTypeList() + return ShowedWeaponTypeList +end + +function XArchiveConfigs.GetWeaponTypeToIdsDic() + return WeaponTypeToIdsDic +end + +function XArchiveConfigs.GetWeaponTemplateIdListByType(type) + return WeaponTypeToIdsDic[type] +end + +function XArchiveConfigs.GetAwarenessSumCollectNum() + return AwarenessSumCollectNum +end + +function XArchiveConfigs.GetAwarenessGroup() + return AwarenessGroup +end + +function XArchiveConfigs.GetAwarenessTypeToGroupDatasDic() + return AwarenessTypeToGroupDatasDic +end + +function XArchiveConfigs.GetAwarenessShowedStatusDic() + return AwarenessShowedStatusDic +end + +function XArchiveConfigs.GetAwarenessSuitInfoTemplate(suitId) + return AwarenessGroup[suitId] +end + +function XArchiveConfigs.GetAwarenessSuitInfoGetType(suitId) + return AwarenessGroup[suitId].Type +end + +function XArchiveConfigs.GetAwarenessSuitInfoIconPath(suitId) + return AwarenessGroup[suitId].IconPath +end + +function XArchiveConfigs.GetWeaponTemplateIdToSettingListDic() + return WeaponTemplateIdToSettingListDic +end + +-- 武器设定或故事 +function XArchiveConfigs.GetWeaponSettingList(id, settingType) + local list = {} + local settingDataList = WeaponTemplateIdToSettingListDic[id] + if settingDataList then + if not settingType or settingType == XArchiveConfigs.SettingType.All then + list = settingDataList + else + for _, settingData in pairs(settingDataList) do + if settingData.Type == settingType then + table.insert(list, settingData) + end + end + + end + end + return XArchiveConfigs.SortByOrder(list) +end + +function XArchiveConfigs.GetWeaponSettingType(id) + return WeaponSettings[id].Type +end + +function XArchiveConfigs.GetWeaponTemplateIdBySettingId(id) + return WeaponSettings[id].EquipId +end + +-- 意识设定或故事 +function XArchiveConfigs.GetAwarenessSettingList(id, settingType) + local list = {} + local settingDataList = AwarenessSuitIdToSettingListDic[id] + if settingDataList then + if not settingType or settingType == XArchiveConfigs.SettingType.All then + list = settingDataList + else + for _, settingData in pairs(settingDataList) do + if settingData.Type == settingType then + table.insert(list, settingData) + end + end + end + else + XLog.ErrorTableDataNotFound("XArchiveConfigs.GetAwarenessSettingList", "配置表项", TABLE_AWARENESSSETTING, "id", tostring(id)) + end + return XArchiveConfigs.SortByOrder(list) +end + +function XArchiveConfigs.GetAwarenessSettingType(id) + return AwarenessSettings[id].Type +end + +function XArchiveConfigs.GetAwarenessSuitIdBySettingId(id) + return AwarenessSettings[id].SuitId +end + +-- 武器、意识相关-------------<<< + +-- 剧情相关------------->>> + +function XArchiveConfigs.GetArchiveStoryGroupAllList() + return ArchiveStoryGroupAllList +end + +function XArchiveConfigs.GetArchiveStoryChapterConfigs() + return StoryChapters +end + +function XArchiveConfigs.GetArchiveStoryChapterConfigById(id) + return StoryChapters[id] +end + +function XArchiveConfigs.GetArchiveStoryDetailConfigs() + return StoryDetails +end + +function XArchiveConfigs.GetArchiveStoryDetailConfigById(id) + return StoryDetails[id] +end + +function XArchiveConfigs.SetArchiveStoryGroupAllList() + for _, group in pairs(StoryGroups or {}) do + table.insert(ArchiveStoryGroupAllList, group) + end + XArchiveConfigs.SortByOrder(ArchiveStoryGroupAllList) +end +-- 剧情相关-------------<<< + +-- NPC相关------------->>> + +function XArchiveConfigs.GetArchiveStoryNpcConfigs() + return StoryNpc +end + +function XArchiveConfigs.GetArchiveStoryNpcConfigById(id) + return StoryNpc[id] +end + +function XArchiveConfigs.GetArchiveStoryNpcSettingConfigs() + return StoryNpcSetting +end + +function XArchiveConfigs.GetArchiveStoryNpcSettingConfigById(id) + return StoryNpcSetting[id] +end +-- NPC相关-------------<<< + +-- CG相关------------->>> + +function XArchiveConfigs.GetArchiveCGGroupConfigs() + return CGGroups +end + +function XArchiveConfigs.GetArchiveCGDetailConfigs() + return CGDetails +end + +function XArchiveConfigs.GetArchiveCGDetailConfigById(id) + return CGDetails[id] +end + +-- CG相关-------------<<< + +-- 邮件通讯相关------------->>> + +function XArchiveConfigs.GetArchiveMailsConfigs() + return ArchiveMails +end + +function XArchiveConfigs.GetArchiveMailsConfigById(id) + return ArchiveMails[id] +end + +function XArchiveConfigs.GetArchiveCommunicationsConfigs() + return ArchiveCommunications +end + +function XArchiveConfigs.GetArchiveCommunicationsConfigById(id) + return ArchiveCommunications[id] +end + +function XArchiveConfigs.GetEventDateGroupsConfigs() + return EventDateGroups +end + +-- 邮件通讯相关-------------<<< +-- 伙伴相关------------->>> + +function XArchiveConfigs.GetPartnerSettingConfigs() + return ArchivePartnerSettings +end + +function XArchiveConfigs.GetPartnerSettingConfigById(id) + if not ArchivePartnerSettings[id] then + XLog.Error("Id is not exist in ".. TABLE_ARCHIVE_PARTNER_SETTING.." id = " .. id) + return + end + return ArchivePartnerSettings[id] +end + +function XArchiveConfigs.GetPartnerConfigs() + return ArchivePartners +end + +function XArchiveConfigs.GetPartnerConfigById(id) + if not ArchivePartners[id] then + XLog.Error("Id is not exist in ".. TABLE_ARCHIVE_PARTNER.." id = " .. id) + return + end + return ArchivePartners[id] +end + +function XArchiveConfigs.GetPartnerGroupConfigs() + return ArchivePartnerGroups +end + +function XArchiveConfigs.GetPartnerGroupConfigById(id) + if not ArchivePartnerGroups[id] then + XLog.Error("Id is not exist in ".. TABLE_ARCHIVE_PARTNER_GROUP.." id = " .. id) + return + end + return ArchivePartnerGroups[id] +end + +-- 伙伴相关-------------<<< +function XArchiveConfigs.GetWeaponSettingPath() + return TABLE_WEAPONSETTING +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XArenaConfigs.lua b/Resources/Scripts/XConfig/XArenaConfigs.lua new file mode 100644 index 00000000..dabfc2f5 --- /dev/null +++ b/Resources/Scripts/XConfig/XArenaConfigs.lua @@ -0,0 +1,318 @@ +--- +--- 竞技副本配置表 +--- +XArenaConfigs = XArenaConfigs or {} + +--战区贡献道具的id +XArenaConfigs.CONTRIBUTESCORE_ID = 54 + +XArenaActivityStatus = { + --game服和竞技服等待数据的时候用 + Loading = -1, + --默认状态 + Default = 0, + --休息状态 + Rest = 1, + --战斗状态 + Fight = 2, + --结束 + Over = 3, +} + +--个人排行区域 +XArenaPlayerRankRegion = { + UpRegion = 1, --晋级区 + KeepRegion = 2, --保级区 + DownRegion = 3, --降级区 +} + +--竞技副本通关评级 +XArenaAppraiseType = { + S = 1, + A = 2, + B = 3, + C = 4, + D = 5, +} + +XArenaConfigs.ArenaTimerName = "FubenArenaActivityTimer" +XArenaConfigs.SHOP_ID = CS.XGame.ClientConfig:GetInt("AreanShopId") + +local TABLE_ARENA_STAGE = "Client/Fuben/Arena/ArenaStage.tab" +local TABLE_ARENA_LEVEL = "Share/Fuben/Arena/ArenaLevel.tab" +local TABLE_CHALLENGE_AREA = "Share/Fuben/Arena/ChallengeArea.tab" +local TABLE_AREA_STAGE = "Share/Fuben/Arena/AreaStage.tab" +local TABLE_TEAM_RANK_REWARD = "Share/Fuben/Arena/TeamRankReward.tab" +local TABLE_MARK = "Share/Fuben/Arena/Mark.tab" + +local ArenaRankBottomCount --竞技排行基数 +local ArenaClientStageTemplate --競技客户端关卡表 +local ArenaLevelTemplate --竞技段位表 +local ChallengeAreaTemplate --挑战区域表 +local AreaStageTemplate --战区关卡配置表 +local TeamRankRewardTemplate --队伍排行奖励表 +local MarkTemplate --结算分数表 + +local MaxArenaLevel = 0 --最大竞技段位 +local PlayerLevelRangeToChallengeIds --玩家等级段索引挑战配置列表 +local MaxArenaStageCountPerArea = 0 --竞技战区最大关卡数 + +--私有方法定义 +local InitChallengeAreaCfg +local InitArenaLevelCfg +local InitAreaStageTemplate + +function XArenaConfigs.Init() + ArenaRankBottomCount = CS.XGame.Config:GetInt("ArenaTeamRankShow") + ArenaClientStageTemplate = XTableManager.ReadByIntKey(TABLE_ARENA_STAGE, XTable.XTableArenaStage, "StageId") + ArenaLevelTemplate = XTableManager.ReadByIntKey(TABLE_ARENA_LEVEL, XTable.XTableArenaLevel, "Id") + ChallengeAreaTemplate = XTableManager.ReadByIntKey(TABLE_CHALLENGE_AREA, XTable.XTableChallengeArea, "ChallengeId") + AreaStageTemplate = XTableManager.ReadByIntKey(TABLE_AREA_STAGE, XTable.XTableAreaStage, "Id") + TeamRankRewardTemplate = XTableManager.ReadByIntKey(TABLE_TEAM_RANK_REWARD, XTable.XTableTeamRankReward, "Id") + MarkTemplate = XTableManager.ReadByIntKey(TABLE_MARK, XTable.XTableMark, "MarkId") + + InitArenaLevelCfg() + InitChallengeAreaCfg() + InitAreaStageTemplate() +end + +InitArenaLevelCfg = function() + for _, cfg in pairs(ArenaLevelTemplate) do + if MaxArenaLevel < cfg.Id then + MaxArenaLevel = cfg.Id + end + end +end + +InitChallengeAreaCfg = function() + PlayerLevelRangeToChallengeIds = {} + + local tempMap = {} + local tempTypeId = 0 + + for id, cfg in pairs(ChallengeAreaTemplate) do + local typeId = tempMap[cfg.MinLv] + if not typeId then + typeId = tempTypeId + 1 + tempMap[cfg.MinLv] = typeId + tempTypeId = typeId + end + + local map = PlayerLevelRangeToChallengeIds[typeId] + if not map then + map = {} + PlayerLevelRangeToChallengeIds[typeId] = map + end + + map[id] = cfg + end +end + +InitAreaStageTemplate = function() + for _, cfg in pairs(AreaStageTemplate) do + if MaxArenaStageCountPerArea < #cfg.StageId then + MaxArenaStageCountPerArea = #cfg.StageId + end + end +end + +local GetChallengeCfgMapById = function(challengeId) + for _, map in ipairs(PlayerLevelRangeToChallengeIds) do + local cfg = map[challengeId] + if cfg then + return map + end + end + + return nil +end + +local SortChallenge = function(a, b) + return a.ArenaLv < b.ArenaLv +end + +local SorTeamRankReward = function(a, b) + return a.MinRank < b.MinRank +end + +-- 获取个人排行区文字 +function XArenaConfigs.GetRankRegionText(rankRegion) + if rankRegion == XArenaPlayerRankRegion.UpRegion then + return CS.XTextManager.GetText("ArenaActivityUpRegion") + elseif rankRegion == XArenaPlayerRankRegion.DownRegion then + return CS.XTextManager.GetText("ArenaActivityDownRegion") + else + return CS.XTextManager.GetText("ArenaActivityKeepRegion") + end +end + +-- 获取个人排行区文字带颜色 +function XArenaConfigs.GetRankRegionColorText(rankRegion) + if rankRegion == XArenaPlayerRankRegion.UpRegion then + return CS.XTextManager.GetText("ArenaActivityUpRegionColor") + elseif rankRegion == XArenaPlayerRankRegion.DownRegion then + return CS.XTextManager.GetText("ArenaActivityDownRegionColor") + else + return CS.XTextManager.GetText("ArenaActivityKeepRegionColor") + end +end + +-- 获取个人排行区描述 +function XArenaConfigs.GetRankRegionDescText(rankRegion, challengeCfg) + if rankRegion == XArenaPlayerRankRegion.UpRegion then + return CS.XTextManager.GetText("ArenaActivityUpRegionDesc", 1, challengeCfg.DanUpRank) + elseif rankRegion == XArenaPlayerRankRegion.DownRegion then + return CS.XTextManager.GetText("ArenaActivityDownRegionDesc", challengeCfg.DanKeepRank + 1, challengeCfg.DanDownRank) + else + return CS.XTextManager.GetText("ArenaActivityKeepRegionDesc", challengeCfg.DanUpRank + 1, challengeCfg.DanKeepRank) + end +end + +-- 获取个人排行不升段位描述 +function XArenaConfigs.GetRankNotRegionDescText(rankRegion) + if rankRegion == XArenaPlayerRankRegion.UpRegion then + return CS.XTextManager.GetText("ArenaActivityNotUpRegionDesc") + elseif rankRegion == XArenaPlayerRankRegion.DownRegion then + return CS.XTextManager.GetText("ArenaActivityNotDownRegionDesc") + else + return CS.XTextManager.GetText("ArenaActivityNotKeepRegionDesc") + end +end + +-- 获取个人排行区奖励id +function XArenaConfigs.GetRankRegionRewardId(rankRegion, challengeCfg) + if rankRegion == XArenaPlayerRankRegion.UpRegion then + return challengeCfg.UpRewardId + elseif rankRegion == XArenaPlayerRankRegion.DownRegion then + return challengeCfg.DownRewardId + else + return challengeCfg.KeepRewardId + end +end + +-- 是否是最大竞技段位 +function XArenaConfigs.IsMaxArenaLevel(level) + return level >= MaxArenaLevel +end + +-- 获取竞技副本评级文字 +function XArenaConfigs.GetArenaFightAppraiseText(appraiseType) + if appraiseType == XArenaAppraiseType.S then + return "S" + elseif appraiseType == XArenaAppraiseType.A then + return "A" + elseif appraiseType == XArenaAppraiseType.B then + return "B" + elseif appraiseType == XArenaAppraiseType.C then + return "C" + elseif appraiseType == XArenaAppraiseType.D then + return "D" + end +end + +-- 获取竞技队伍排行榜统计基数 +function XArenaConfigs.GetArenaRankBottomCount() + return ArenaRankBottomCount +end + +-- 获取竞技段位配置表 +function XArenaConfigs.GetArenaLevelCfgByLevel(level) + return ArenaLevelTemplate[level] +end + +-- 获取竞技段位配置表 +function XArenaConfigs.GetArenaStageConfig(stageId) + local t = ArenaClientStageTemplate[stageId] + if not t then + XLog.ErrorTableDataNotFound("XArenaConfigs.GetArenaStageConfig", "根据stageId获取的配置表项", TABLE_ARENA_STAGE, "stageId", tostring(stageId)) + return nil + end + return t +end + +-- 获取竞技挑战配置表 +function XArenaConfigs.GetChallengeArenaCfgById(challengeId) + return ChallengeAreaTemplate[challengeId] +end + +-- 获取竞技挑战配置列表 +function XArenaConfigs.GetChallengeCfgListById(challengeId) + local list = {} + + local map = GetChallengeCfgMapById(challengeId) + if map then + for _, cfg in pairs(map) do + table.insert(list, cfg) + end + table.sort(list, SortChallenge) + end + return list +end + +-- 获取竞技挑战最高等级 +function XArenaConfigs.GetChallengeMaxArenaLevel(challengeId) + local maxArenalLevel = 0 + + local map = GetChallengeCfgMapById(challengeId) + if map then + for _, cfg in pairs(map) do + if cfg.ArenaLv > maxArenalLevel then + maxArenalLevel = cfg.ArenaLv + end + end + end + + return maxArenalLevel +end + +function XArenaConfigs.GetArenaStageCfg() + return AreaStageTemplate +end + +-- 获取竞技区域关卡配置 +function XArenaConfigs.GetArenaAreaStageCfgByAreaId(areaId) + return AreaStageTemplate[areaId] +end + +-- 获取竞技战区最大关卡数量 +function XArenaConfigs.GetTheMaxStageCountOfArenaArea() + return MaxArenaStageCountPerArea +end + +-- 获取竞技队伍排行奖励配置列表 +function XArenaConfigs.GetTeamRankRewardCfgList(challengeId) + local list = {} + for _, cfg in pairs(TeamRankRewardTemplate) do + if cfg.ChallengeId == challengeId then + table.insert(list, cfg) + end + end + + if #list > 2 then + table.sort(list, SorTeamRankReward) + end + + return list +end + +-- 获取竞技队伍排行奖励配置 +function XArenaConfigs.GetTeamRankRewardCfgById(id) + return TeamRankRewardTemplate[id] +end + +-- 获取竞技结算分数配置 +function XArenaConfigs.GetMarkCfgById(id) + return MarkTemplate[id] +end + +-- 获取最大分数 +function XArenaConfigs.GetMarkMaxPointById(id) + return MarkTemplate[id].MaxPoint +end + +-- 获取竞技章节名字以及副本名字 +function XArenaConfigs.GetChapterAndStageName(areaId, stageId) + local chapterName = AreaStageTemplate[areaId].Name + local stageName = XDataCenter.FubenManager.GetStageCfg(stageId).Name + return chapterName, stageName +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XArenaOnlineConfigs.lua b/Resources/Scripts/XConfig/XArenaOnlineConfigs.lua new file mode 100644 index 00000000..1496c3fc --- /dev/null +++ b/Resources/Scripts/XConfig/XArenaOnlineConfigs.lua @@ -0,0 +1,176 @@ +XArenaOnlineConfigs = XArenaOnlineConfigs or {} + +local TABLE_ARENAONLINE_CHAPTER = "Share/Fuben/ArenaOnline/ArenaOnlineChapter.tab" +local TABLE_ARENAONLINE_SECTION = "Share/Fuben/ArenaOnline/ArenaOnlineSection.tab" +local TABLE_ARENAONLINE_STAGEGROUP = "Share/Fuben/ArenaOnline/ArenaOnlineStageGroup.tab" +local TABLE_ARENAONLINE_STAGE = "Share/Fuben/ArenaOnline/ArenaOnlineStage.tab" +local TABLE_ARENAONLINE_ACTIVEBUFF = "Share/Fuben/ArenaOnline/ArenaOnlineActiveBuff.tab" +--local TABLE_NPC_AFFIX = "Client/Fight/Npc/NpcAffix.tab" +local ArenaOnlineChapterCfg = {} +local ArenaOnlineSectionCfg = {} +local ArenaOnlineStageGroupCfg = {} +local ArenaOnlineStageCfg = {} +local ArenaOnlineActiveBuffCfg = {} +--local NpcAffixCfg = {} +XArenaOnlineConfigs.MAX_NAILI = CS.XGame.Config:GetInt("ArenaOnlineCharMaxEndurance") +XArenaOnlineConfigs.SHOW_TIME = CS.XGame.ClientConfig:GetInt("ArenaOnlineInviteShowTime") +XArenaOnlineConfigs.DEFAULT_CHAPTERID = CS.XGame.ClientConfig:GetInt("ArenaOnlineDefualtChapterId") + +XArenaOnlineConfigs.MaskArenOnlineUIName = { + UiPurchase = "UiPurchase", + UiDraw = "UiDraw", + UiMultiplayerRoom = "UiMultiplayerRoom", + UiMultiplayerInviteFriend = "UiMultiplayerInviteFriend", + UiSocial = "UiSocial", + UiRoomCharacter = "UiRoomCharacter", + UiDrawMain = "UiNewDrawMain", + UiLoading = "UiLoading" +} +function XArenaOnlineConfigs.Init() + ArenaOnlineChapterCfg = XTableManager.ReadByIntKey(TABLE_ARENAONLINE_CHAPTER, XTable.XTableArenaOnlineChapter, "Id") + ArenaOnlineSectionCfg = XTableManager.ReadByIntKey(TABLE_ARENAONLINE_SECTION, XTable.XTableArenaOnlineSection, "Id") + ArenaOnlineStageGroupCfg = XTableManager.ReadByIntKey(TABLE_ARENAONLINE_STAGEGROUP, XTable.XTableArenaOnlineStageGroup, "Id") + ArenaOnlineStageCfg = XTableManager.ReadByIntKey(TABLE_ARENAONLINE_STAGE, XTable.XTableArenaOnlineStage, "Id") + ArenaOnlineActiveBuffCfg = XTableManager.ReadByIntKey(TABLE_ARENAONLINE_ACTIVEBUFF, XTable.XTableArenaOnlineActiveBuff, "Id") + --NpcAffixCfg = XTableManager.ReadByIntKey(TABLE_NPC_AFFIX, XTable.XTableNpcAffix, "Id") + XArenaOnlineConfigs.ArenaOnlineShowTime = CS.XGame.ClientConfig:GetInt("ArenaOnlineShowTime") or -1 +end + +function XArenaOnlineConfigs.GetChapters() + return ArenaOnlineChapterCfg +end + +function XArenaOnlineConfigs.GetStages() + return ArenaOnlineStageCfg +end + +function XArenaOnlineConfigs.GetChapterById(chapterId) + local chapter = ArenaOnlineChapterCfg[chapterId] + + if not chapter then + XLog.ErrorTableDataNotFound("XArenaOnlineConfigs.GetChapterById", "chapter", TABLE_ARENAONLINE_CHAPTER, "chapterId", tostring(chapterId)) + return nil + end + + return chapter +end + +function XArenaOnlineConfigs.GetSectionById(sectionId) + local section = ArenaOnlineSectionCfg[sectionId] + + if not section then + XLog.ErrorTableDataNotFound("XArenaOnlineConfigs.GetSectionById", "section", TABLE_ARENAONLINE_SECTION, "sectionId", tostring(sectionId)) + return nil + end + + return section +end + +function XArenaOnlineConfigs.GetStageById(stageId) + local stage = ArenaOnlineStageCfg[stageId] + + if not stage then + XLog.ErrorTableDataNotFound("XArenaOnlineConfigs.GetStageById", "stage", TABLE_ARENAONLINE_STAGE, "stageId", tostring(stageId)) + return nil + end + + return stage +end + +function XArenaOnlineConfigs.GetStageGroupById(groupId) + local group = ArenaOnlineStageGroupCfg[groupId] + + if not group then + XLog.ErrorTableDataNotFound("XArenaOnlineConfigs.GetStageGroupById", "group", TABLE_ARENAONLINE_STAGEGROUP, "groupId", tostring(groupId)) + return nil + end + + return group +end + +function XArenaOnlineConfigs.GetStageGroupPrefabPathById(groupId) + local cfg = XArenaOnlineConfigs.GetStageGroupById(groupId) + if cfg then + return cfg.PrefabPath + end +end + +function XArenaOnlineConfigs.GetStageGroupIconById(groupId) + local cfg = XArenaOnlineConfigs.GetStageGroupById(groupId) + if cfg then + return cfg.Icon + end +end +function XArenaOnlineConfigs.GetActiveBuffById(activeBuffId) + local buff = ArenaOnlineActiveBuffCfg[activeBuffId] + + if not buff then + XLog.ErrorTableDataNotFound("XArenaOnlineConfigs.GetActiveBuffById", + "buff", TABLE_ARENAONLINE_ACTIVEBUFF, "activeBuffId", tostring(activeBuffId)) + return nil + end + + return buff +end + +function XArenaOnlineConfigs.GetNpcAffixById(buffId) + local npcAffix = nil + + if CS.XNpcManager.AffixTable:ContainsKey(buffId) then + npcAffix = CS.XNpcManager.AffixTable[buffId] + end + + if not npcAffix then + XLog.ErrorTableDataNotFound("XArenaOnlineConfigs.GetNpcAffixById", "npcAffix", TABLE_NPC_AFFIX, "buffId", tostring(buffId)) + return nil + end + + return npcAffix +end + + +function XArenaOnlineConfigs.GetChaprerNameByChapterId(chapterId) + local chapter = XArenaOnlineConfigs.GetChapterById(chapterId) + return chapter.Name +end + +function XArenaOnlineConfigs.GetStageSortByStageId(stageId) + local stage = XArenaOnlineConfigs.GetStageById(stageId) + return stage.Sort +end + +function XArenaOnlineConfigs.GetStageEnduranceCostByStageId(stageId) + local stage = XArenaOnlineConfigs.GetStageById(stageId) + return stage.EnduranceCost +end + +function XArenaOnlineConfigs.GetStageActiveBuffIdByStageId(stageId) + local stage = XArenaOnlineConfigs.GetStageById(stageId) + return stage.ActiveBuffId +end + +function XArenaOnlineConfigs.GetStageBottomCountByStageId(stageId) + local stage = XArenaOnlineConfigs.GetStageById(stageId) + return stage.BottomCount +end + +function XArenaOnlineConfigs.GetStageDropKeyByStageId(stageId) + local stage = XArenaOnlineConfigs.GetStageById(stageId) + return tostring(stage.ShowDropId) .. tostring(stage.ShowBottomId) +end + + +function XArenaOnlineConfigs.GetStageGroupRequireStar(groupId) + local group = XArenaOnlineConfigs.GetStageGroupById(groupId) + return group.RequireStar +end + +function XArenaOnlineConfigs.GetFirstChapterName() + local name = "" + for _, v in pairs(ArenaOnlineChapterCfg) do + name = v.Name + break + end + + return name +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XArrangeConfigs.lua b/Resources/Scripts/XConfig/XArrangeConfigs.lua new file mode 100644 index 00000000..f8c24d40 --- /dev/null +++ b/Resources/Scripts/XConfig/XArrangeConfigs.lua @@ -0,0 +1,64 @@ +local QualityBgPath = { + CS.XGame.ClientConfig:GetString("CommonBagWhite"), + CS.XGame.ClientConfig:GetString("CommonBagGreed"), + CS.XGame.ClientConfig:GetString("CommonBagBlue"), + CS.XGame.ClientConfig:GetString("CommonBagPurple"), + CS.XGame.ClientConfig:GetString("CommonBagGold"), + CS.XGame.ClientConfig:GetString("CommonBagRed"), + CS.XGame.ClientConfig:GetString("CommonBagRed"), +} + +local QualityPath = { + CS.XGame.ClientConfig:GetString("QualityIconColor1"), + CS.XGame.ClientConfig:GetString("QualityIconColor2"), + CS.XGame.ClientConfig:GetString("QualityIconColor3"), + CS.XGame.ClientConfig:GetString("QualityIconColor4"), + CS.XGame.ClientConfig:GetString("QualityIconColor5"), + CS.XGame.ClientConfig:GetString("QualityIconColor6"), + CS.XGame.ClientConfig:GetString("QualityIconColor7"), +} + + +XArrangeConfigs = XArrangeConfigs or {} + +XArrangeConfigs.Types = { + Error = 0, + Item = 1, --道具 + Character = 2, --成员 + Weapon = 3, --武器 + Wafer = 4, --意识 + Medal = 5, + Part = 6, + Fashion = 7, --时装 + BaseEquip = 8, --基地装备 + Furniture = 9, --家具 + HeadPortrait = 10, --头像 + DormCharacter = 11, --宿舍构造体 + ChatEmoji = 12, --聊天表情 + WeaponFashion = 13, --武器投影 + Collection = 14, --收藏 + Background = 15, --场景 + Pokemon = 16, --口袋战双 + Partner = 17,--伙伴 + Nameplate = 18, --铭牌 +} + +function XArrangeConfigs.GetType(id) + return math.floor(id / 1000000) + 1 +end + +function XArrangeConfigs.GeQualityBgPath(quality) + if not quality then + XLog.Error("XArrangeConfigs.GeQualityBgPath 函数错误: 参数quality不能为空") + return + end + return QualityBgPath[quality] +end + +function XArrangeConfigs.GeQualityPath(quality) + if not quality then + XLog.Error("XArrangeConfigs.GeQualityBgPath 函数错误: 参数quality不能为空") + return + end + return QualityPath[quality] +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XAssistConfig.lua b/Resources/Scripts/XConfig/XAssistConfig.lua new file mode 100644 index 00000000..b049111c --- /dev/null +++ b/Resources/Scripts/XConfig/XAssistConfig.lua @@ -0,0 +1,12 @@ +XAssistConfig = XAssistConfig or {} + +local AssistRuleTemplate = {} + +local TABLE_ASSISTRULE = "Share/Fuben/Assist/AssistRule.tab"; + +function XAssistConfig.Init() + AssistRuleTemplate = XTableManager.ReadByIntKey(TABLE_ASSISTRULE, XTable.XTableAssistRule, "Id") +end +function XAssistConfig.GetAssistRuleTemplate(id) + return AssistRuleTemplate[id] +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XAttribConfigs.lua b/Resources/Scripts/XConfig/XAttribConfigs.lua new file mode 100644 index 00000000..f860294f --- /dev/null +++ b/Resources/Scripts/XConfig/XAttribConfigs.lua @@ -0,0 +1,79 @@ +XAttribConfigs = XAttribConfigs or {} + +local TABLE_ATTRIB_DESC_PATH = "Share/Attrib/AttribDesc.tab" +local TABLE_ATTRIB_ABILITY_PATH = "Share/Attrib/AttribAbility.tab" +local TABLE_ATTRIB_PATH = "Share/Attrib/Attrib" +local TABLE_ATTRIB_PROMOTED_PATH = "Share/Attrib/AttribPromoted" +local TABLE_ATTRIB_GROW_RATE_PATH = "Share/Attrib/AttribGrowRate" +local TABLE_ATTRIB_POOL_PATH = "Share/Attrib/AttribPool/" +local TABLE_ATTRIB_REVISE_PATH = "Share/Attrib/AttribRevise/" +local TABLE_NPC_PATH = "Share/Fight/Npc/Npc/Npc.tab" + +local AttribAbilityTemplate = {} +local AttribTemplates = {} +local AttribPromotedTemplates = {} +local AttribGrowRateTemplates = {} +local AttribReviseTemplates = {} +local AttribGroupTemplates = {} +local AttribGroupPoolIdDic = {} --共鸣属性池字典 +--local NpcTemplates = {} +--属性名字配置表 +local AttribDescTemplates = {} + +local tableInsert = table.insert + +function XAttribConfigs.Init() + AttribTemplates = XTableManager.ReadByIntKey(TABLE_ATTRIB_PATH, XTable.XTableNpcAttrib, "Id") + AttribPromotedTemplates = XTableManager.ReadByIntKey(TABLE_ATTRIB_PROMOTED_PATH, XTable.XTableNpcAttrib, "Id") + AttribGrowRateTemplates = XTableManager.ReadByIntKey(TABLE_ATTRIB_GROW_RATE_PATH, XTable.XTableNpcAttrib, "Id") + AttribGroupTemplates = XTableManager.ReadByIntKey(TABLE_ATTRIB_POOL_PATH, XTable.XTableAttribGroup, "Id") + AttribReviseTemplates = XTableManager.ReadByIntKey(TABLE_ATTRIB_REVISE_PATH, XTable.XTableAttribRevise, "Id") + --NpcTemplates = XTableManager.ReadByIntKey(TABLE_NPC_PATH, XTable.XTableNpc, "Id") + AttribDescTemplates = XTableManager.ReadByIntKey(TABLE_ATTRIB_DESC_PATH, XTable.XTableAttribDesc, "Index") + AttribAbilityTemplate = XTableManager.ReadByStringKey(TABLE_ATTRIB_ABILITY_PATH, XTable.XTableAttribAbility, "Key") + + for _, template in pairs(AttribGroupTemplates) do + AttribGroupPoolIdDic[template.PoolId] = AttribGroupPoolIdDic[template.PoolId] or {} + tableInsert(AttribGroupPoolIdDic[template.PoolId], template) + end +end + +function XAttribConfigs.GetAttribTemplates() + return AttribTemplates +end + +function XAttribConfigs.GetAttribPromotedTemplates() + return AttribPromotedTemplates +end + +function XAttribConfigs.GetAttribGrowRateTemplates() + return AttribGrowRateTemplates +end + +function XAttribConfigs.GetAttribReviseTemplates() + return AttribReviseTemplates +end + +function XAttribConfigs.GetAttribGroupTemplates() + return AttribGroupTemplates +end + +function XAttribConfigs.GetAttribGroupCfgById(groupId) + return AttribGroupTemplates[groupId] +end + +function XAttribConfigs.GetNpcTemplates() + return NpcTemplates +end + +function XAttribConfigs.GetAttribDescTemplates() + return AttribDescTemplates +end + +function XAttribConfigs.GetAttribAbilityTemplate() + return AttribAbilityTemplate +end + +function XAttribConfigs.GetAttribGroupTemplateByPoolId(poolId) + return AttribGroupPoolIdDic[poolId] or {} +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XAutoFightConfig.lua b/Resources/Scripts/XConfig/XAutoFightConfig.lua new file mode 100644 index 00000000..7cb8c200 --- /dev/null +++ b/Resources/Scripts/XConfig/XAutoFightConfig.lua @@ -0,0 +1,13 @@ +XAutoFightConfig = XAutoFightConfig or {} + + +local AutoFightCfgs = {} +local TABLE_AUTO_FIGHT = "Share/Fuben/AutoFight.tab" + +function XAutoFightConfig.Init() + AutoFightCfgs = XTableManager.ReadByIntKey(TABLE_AUTO_FIGHT, XTable.XTableAutoFight, "Id") +end + +function XAutoFightConfig.GetCfg(autoFightId) + return AutoFightCfgs[autoFightId] +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XAutoWindowConfigs.lua b/Resources/Scripts/XConfig/XAutoWindowConfigs.lua new file mode 100644 index 00000000..f479f849 --- /dev/null +++ b/Resources/Scripts/XConfig/XAutoWindowConfigs.lua @@ -0,0 +1,64 @@ +XAutoWindowConfigs = XAutoWindowConfigs or {} + +XAutoWindowConfigs.AutoType = { + EachTime = 1, -- 每次登陆弹出 + EachDay = 2, -- 每天登陆弹出 + EachWeek = 3, -- 每周登陆弹出 + EachMonth = 4, -- 每月登陆弹出 + Period = 5, -- 周期内弹出 + EachDayOffset = 6, -- 有时间偏移的每天登录(目前每个服写死,暂不改表) +} + +XAutoWindowConfigs.AutoFunctionType = { + AutoWindowView = 1, -- 自动弹出公告 + Sign = 2, -- 签到 + FirstRecharge = 3, -- 首充 + Card = 4, -- 月卡 + Regression = 5, -- 回归活动(特殊处理类型) + + NewYearZhanBu = 500, -- 元旦占卜 + NewYearDrawActivity = 501, -- 元旦抽奖 + + Fireworks = 1001, --烟花活动 +} + +XAutoWindowConfigs.AutoWindowSkinType = { + None = 0, -- 未知 + BarSkin = 1, -- 条幅 + BigSkin = 2, -- 大图 + SpineSkin = 3, -- Spine动画 +} + +local TABLE_AUTO_WINDOW_VIEW = "Client/AutoWindow/AutoWindowView.tab" +local TABLE_AUTO_WINDOW_CONTROLLER = "Client/AutoWindow/AutoWindowController.tab" + +local AutoWindowViewConfig = {} -- 自动弹窗公告配置表 +local AutoWindowControllerConfig = {} -- 自动弹窗控制配置表 + +function XAutoWindowConfigs.Init() + AutoWindowViewConfig = XTableManager.ReadByIntKey(TABLE_AUTO_WINDOW_VIEW, XTable.XTableAutoWindowView, "Id") + AutoWindowControllerConfig = XTableManager.ReadByIntKey(TABLE_AUTO_WINDOW_CONTROLLER, XTable.XTableAutoWindowController, "Id") +end + +function XAutoWindowConfigs.GetAutoWindowConfig(id) + local t = AutoWindowViewConfig[id] + if not t then + XLog.ErrorTableDataNotFound("XAutoWindowConfigs.GetAutoWindowConfig", "配置表项", TABLE_AUTO_WINDOW_VIEW, "id", tostring(id)) + return nil + end + + return t +end + +function XAutoWindowConfigs.GetAutoWindowSkinType(id) + local t = XAutoWindowConfigs.GetAutoWindowConfig(id) + if t then + return t.Type + end + + return 0 +end + +function XAutoWindowConfigs.GetAutoWindowControllerConfig() + return AutoWindowControllerConfig +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XBaseEquipConfigs.lua b/Resources/Scripts/XConfig/XBaseEquipConfigs.lua new file mode 100644 index 00000000..45d15134 --- /dev/null +++ b/Resources/Scripts/XConfig/XBaseEquipConfigs.lua @@ -0,0 +1,20 @@ +XBaseEquipConfigs =XBaseEquipConfigs or {} + +local TABLE_BASE_EQUIP_PATH = "Share/BaseEquip/BaseEquip.tab" +local TABLE_BASE_EQUIP_SCORE = "Client/BaseEquip/BaseEquipScore.tab" + +local BaseEquipTemplates = {} -- 基地装备配置 +local BaseEquipScoreTemplates = {} -- 基地装备评分计算配置 + +function XBaseEquipConfigs.Init() + BaseEquipTemplates = XTableManager.ReadByIntKey(TABLE_BASE_EQUIP_PATH, XTable.XTableBaseEquip, "Id") + BaseEquipScoreTemplates = XTableManager.ReadByStringKey(TABLE_BASE_EQUIP_SCORE, XTable.XTableBaseEquipScore, "Key") +end + +function XBaseEquipConfigs.GetBaseEquipTemplates() + return BaseEquipTemplates +end + +function XBaseEquipConfigs.GetBaseEquipScoreTemplates() + return BaseEquipScoreTemplates +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XBfrtConfigs.lua b/Resources/Scripts/XConfig/XBfrtConfigs.lua new file mode 100644 index 00000000..0becdfa3 --- /dev/null +++ b/Resources/Scripts/XConfig/XBfrtConfigs.lua @@ -0,0 +1,36 @@ +local TABLE_BFRT_CHAPTER_PATH = "Share/Fuben/Bfrt/BfrtChapter.tab" +local TABLE_BFRT_GROUP_PATH = "Share/Fuben/Bfrt/BfrtGroup.tab" +local TABLE_ECHELON_INFO_PATH = "Share/Fuben/Bfrt/EchelonInfo.tab" + +local BfrtChapterTemplates = {} +local BfrtGroupTemplates = {} +local EchelonInfoTemplates = {} + +XBfrtConfigs = XBfrtConfigs or {} + +XBfrtConfigs.CAPTIAN_MEMBER_INDEX = 1 +XBfrtConfigs.FIRST_FIGHT_MEMBER_INDEX = 1 + +XBfrtConfigs.MEMBER_POS_COLOR = { + "FF1111FF", -- red + "4F99FFFF", -- blue + "F9CB35FF", -- yellow +} + +function XBfrtConfigs.Init() + BfrtChapterTemplates = XTableManager.ReadByIntKey(TABLE_BFRT_CHAPTER_PATH, XTable.XTableBfrtChapter, "ChapterId") + BfrtGroupTemplates = XTableManager.ReadByIntKey(TABLE_BFRT_GROUP_PATH, XTable.XTableBfrtGroup, "GroupId") + EchelonInfoTemplates = XTableManager.ReadByIntKey(TABLE_ECHELON_INFO_PATH, XTable.XTableEchelonInfo, "Id") +end + +function XBfrtConfigs.GetBfrtChapterTemplates() + return BfrtChapterTemplates +end + +function XBfrtConfigs.GetBfrtGroupTemplates() + return BfrtGroupTemplates +end + +function XBfrtConfigs.GetEchelonInfoTemplates() + return EchelonInfoTemplates +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XBountyTaskConfigs.lua b/Resources/Scripts/XConfig/XBountyTaskConfigs.lua new file mode 100644 index 00000000..48441dc1 --- /dev/null +++ b/Resources/Scripts/XConfig/XBountyTaskConfigs.lua @@ -0,0 +1,51 @@ +XBountyTaskConfigs = XBountyTaskConfigs or {} + +local TABLE_BOUNTYTASK_RANK_PATH = "Share/BountyTask/BountyTaskRank.tab" +local TABLE_BOUNTYTASK_PATH = "Share/BountyTask/BountyTask.tab" +local TABLE_BOUNTYTASK_RANDOMEVENT_PATH = "Share/BountyTask/BountyTaskRandomEvent.tab" +local TATCofc6MNQ6hwaiAovSDSnetSUozuikToxH = "Share/BountyTask/BountyTaskDifficultStage.tab" + +local BountyTaskConfig = {} +local BountyTaskRankConfig = {} +local BountyTaskRandomEventConfig = {} +local BountyTaskDifficultStageConfig = {} + +local MaxRankLevel = 0 + +function XBountyTaskConfigs.Init() + BountyTaskConfig = XTableManager.ReadByIntKey(TABLE_BOUNTYTASK_PATH, XTable.XTableBountyTask, "Id") + BountyTaskRankConfig = XTableManager.ReadByIntKey(TABLE_BOUNTYTASK_RANK_PATH, XTable.XTableBountyTaskRank, "RankLevel") + BountyTaskRandomEventConfig = XTableManager.ReadByIntKey(TABLE_BOUNTYTASK_RANDOMEVENT_PATH, XTable.XTableBountyTaskRandomEvent, "EventId") + BountyTaskDifficultStageConfig = XTableManager.ReadByIntKey(TATCofc6MNQ6hwaiAovSDSnetSUozuikToxH, XTable.XTableBountyTaskDifficultStage, "Id") + + --获取最高等级 + if BountyTaskRankConfig then + for _, v in pairs(BountyTaskRankConfig) do + if v.RankLevel > MaxRankLevel then + MaxRankLevel = v.RankLevel + end + end + end + + XBountyTaskConfigs.MaxRankLevel = MaxRankLevel +end + +function XBountyTaskConfigs.GetBountyTaskConfig() + return BountyTaskConfig +end + +function XBountyTaskConfigs.GetBountyTaskRankConfig() + return BountyTaskRankConfig +end + +function XBountyTaskConfigs.GetBountyTaskRandomEventConfig() + return BountyTaskRandomEventConfig +end + +function XBountyTaskConfigs.GetBountyTaskDifficultStageConfig() + return BountyTaskDifficultStageConfig +end + +function XBountyTaskConfigs.GetBountyTaskPath() + return TABLE_BOUNTYTASK_PATH +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XCharacterConfigs.lua b/Resources/Scripts/XConfig/XCharacterConfigs.lua new file mode 100644 index 00000000..64eb5135 --- /dev/null +++ b/Resources/Scripts/XConfig/XCharacterConfigs.lua @@ -0,0 +1,1508 @@ +local pairs = pairs +local table = table +local tableSort = table.sort +local tableInsert = table.insert + +XCharacterConfigs = XCharacterConfigs or {} + +-- 推荐类型 +XCharacterConfigs.CharacterType = { + Normal = 1, --构造体 + Isomer = 2, --异构体/感染体 +} + +--角色解放等级 +XCharacterConfigs.GrowUpLevel = { + New = 1, -- 新兵 + Lower = 2, -- 低级 + Middle = 3, -- 中级 + Higher = 4, -- 高级 + End = 4, +} + +-- 推荐类型 +XCharacterConfigs.RecommendType = { + Character = 1, --推荐角色 + Equip = 2, --推荐装备 +} + +XCharacterConfigs.XUiCharacter_Camera = { + MAIN = 0, + LEVEL = 1, + GRADE = 2, + QULITY = 3, + SKILL = 4, + EXCHANGE = 5 +} + +XCharacterConfigs.MAX_QUALITY_STAR = 10 + +--角色终阶解放技能ID约定配置 +XCharacterConfigs.MAX_LEBERATION_SKILL_POS_INDEX = 13 + +XCharacterConfigs.MAX_SHOW_SKILL_POS = 5--展示用技能组数量 + +local TABLE_CHARACTER_PATH = "Share/Character/Character.tab" +local TABLE_LEVEL_UP_TEMPLATE_PATH = "Share/Character/LevelUpTemplate/" +local TABLE_CHARACTER_QUALITY_FRAGMENT_PATH = "Share/Character/Quality/CharacterQualityFragment.tab" +local TABLE_CHARACTER_QUALITY_PATH = "Share/Character/Quality/CharacterQuality.tab" +local TABLE_CHARACTER_GRADE_PATH = "Share/Character/Grade/CharacterGrade.tab" +local TABLE_CHARACTER_CAREER_PATH = "Client/Character/CharacterCareer.tab" +local TABLE_CHARACTER_SKILL = "Share/Character/Skill/CharacterSkill.tab" +local TABLE_CHARACTER_SKILL_GROUP = "Share/Character/Skill/CharacterSkillGroup.tab" +local TABLE_CHARACTER_DETAIL = "Client/Character/CharacterDetail.tab" +local TABLE_CHARACTER_SKILL_TEACH = "Client/Character/Skill/CharacterSkillTeach.tab" +local TABLE_CHARACTER_ELEMENT_CONFIG = "Client/Character/CharacterElement.tab" +local TABLE_CHARACTER_SKILL_POS = "Share/Character/Skill/CharacterSkillPos.tab" +local TABLE_CHARACTER_SKILL_GRADE = "Share/Character/Skill/CharacterSkillUpgrade.tab" +local TABLE_CHARACTER_SKILL_GRADE_DES = "Client/Character/Skill/CharacterSkillUpgradeDes.tab" +local TABLE_CHARACTER_SKILL_LEVEL = "Share/Character/Skill/CharacterSkillLevelEffect.tab" +local TABLE_CHARACTER_SKILL_TYPE_INFO = "Client/Character/Skill/CharacterSkillTypeInfo.tab" +local TABLE_CHARACTER_SKILL_TYPE = "Share/Character/Skill/CharacterSkillType.tab" +local TABLE_CHARACTER_SKILL_TYPE_PLUS = "Share/Character/Skill/CharacterSkillTypePlus.tab" +local TABLE_CHARACTER_GRAPH_INFO = "Client/Character/CharacterGraph.tab" +local TABLE_CHARACTER_SKILL_POOL = "Share/Character/Skill/CharacterSkillPool.tab" +local TABLE_CHARACTER_DETAIL_PARNER = "Client/Character/CharacterRecommend.tab" +local TABLE_CHARACTER_DETAIL_EQUIP = "Client/Character/EquipRecommend.tab" +local TABLE_CHARACTER_RECOMMEND_TAB_CONFIG = "Client/Character/CharacterTabId.tab" +local TABLE_CHARACTER_QUALITY_ICON_PATH = "Client/Character/CharacterQualityIcon.tab" +local TABLE_NPC_PATH = "Share/Fight/Npc/Npc" +local TABLE_CHARACTER_LIBERATION_PATH = "Client/Character/CharacterLiberation.tab" +local TABLE_CHARACTER_SKILL_ENTRY = "Client/Character/Skill/CharacterSkillEntry.tab" + +-- 配置相关 +local CharacterTemplates = {} -- 角色配置 +local LevelUpTemplates = {} -- 升级模板 +local CharQualityTemplates = {} -- 角色品质配置 +local CharQualityFragmentTemplates = {} -- 品质对应碎片 +local CharQualityIconTemplates = {} -- 角色品质图标 +local CharGradeTemplates = {} -- 角色改造配置 +local CharBorderTemplates = {} -- 角色边界属性 +local CharacterCareerTemplates = {} -- npc类型图标配置 +local SubSkillMinMaxLevelDicGrade = {} -- 副技能最小最大等级配置(from TABLE_CHARACTER_SKILL_GRADE) +local SubSkillMinMaxLevelDicLevel = {} -- 副技能最小最大等级配置(from TABLE_CHARACTER_SKILL_LEVEL) +local CharDetailTemplates = {} -- 角色详细 +local CharTeachSkill = {} -- 角色技能教学 +local CharElementTemplates = {} -- 角色元素配置 +local SkillGradeConfig = {} -- 角色技能升级表 +local SkillGradeDesConfig = {} -- 角色技能升级描述表 +local SkillPosConfig = {} -- 角色技能大组显示配置 +local CharGraphTemplates = {} -- 角色六位图配置 +local CharSkillLevelDict = {} -- 角色技能Id,等级Id的属性表Map +local CharSkillLevelDesDict = {} -- 角色技能Id,等级Id的属性表Map +local CharSkillLevelEffectDict = {} -- 角色技能Id, 等级Id的升级表Map +local CharSkillPoolSkillIdDic = {} -- 角色技能共鸣池SkillId映射技能信息字典 +local SkillTypeInfoConfig = {} -- 角色技能分类名字 +local CharacterSkillType = {} -- 角色技能Id分类 +local SkillTypePlusConfig = {} -- 角色技能分类加成 +local CharPoolIdToSkillInfoDic = {} -- 角色技能共鸣池PoolId映射技能信息字典 +local CharSkillIdToCharacterIdDic = {} -- SkillId映射CharacterId字典 +local ItemIdToCharacterIdDic = {} -- 角色碎片Id映射CharacterId字典 +local CharLiberationTemplates = {} -- 角色解放配置 +local NpcTemplates = {} -- npc配置表 +local CharMaxLiberationSkillIdDic = {} -- 角色终阶解放技能Id字典 +local CharSkillGroupDic = {} -- 角色技能组配置 +local CharSkillIdToGroupDic = {} -- 角色技能Id,技能组字典 +local CharSkillTemplates = {} -- 角色子技能配置 +local CharacterSkillDictTemplates = {} -- 角色技能组配置 +local CharacterSkillEntryConfig = {} -- 角色技能词条表 + +local CharacterRecommendTemplates --角色推荐表 +local EquipRecommendTemplates --装备推荐表 +local CharacterTabToVoteGroupMap --角色标签转投票组表 +local CharacterTemplatesCount --角色总数量 + +local CompareQuality = function(templateId, quality) + local template = CharBorderTemplates[templateId] + if not template then + return + end + + if not template.MinQuality or template.MinQuality > quality then + template.MinQuality = quality + end + + if not template.MaxQuality or template.MaxQuality < quality then + template.MaxQuality = quality + end +end + +local CompareGrade = function(templateId, grade) + local template = CharBorderTemplates[templateId] + if not template then + return + end + + if not template.MinGrade or template.MinGrade > grade then + template.MinGrade = grade + end + + if not template.MaxGrade or template.MaxGrade < grade then + template.MaxGrade = grade + end +end + +local InitCharQualityConfig = function() + -- 角色品质对应配置 + local tab = XTableManager.ReadByIntKey(TABLE_CHARACTER_QUALITY_PATH, XTable.XTableCharacterQuality, "Id") + for _, config in pairs(tab) do + if not CharQualityTemplates[config.CharacterId] then + CharQualityTemplates[config.CharacterId] = {} + end + CharQualityTemplates[config.CharacterId][config.Quality] = config + CompareQuality(config.CharacterId, config.Quality) + end + + CharQualityIconTemplates = XTableManager.ReadByIntKey(TABLE_CHARACTER_QUALITY_ICON_PATH, XTable.XTableCharacterQualityIcon, "Quality") +end + + +local IniCharQualityFragmentConfig = function() + local templates = XTableManager.ReadByIntKey(TABLE_CHARACTER_QUALITY_FRAGMENT_PATH, XTable.XTableCharacterQualityFragment, "Id") + for _, config in pairs(templates) do + local characterType = config.Type + local characterTypeConfig = CharQualityFragmentTemplates[characterType] or {} + CharQualityFragmentTemplates[characterType] = characterTypeConfig + + local quality = config.Quality + characterTypeConfig[quality] = config + end +end + +local InitCharLiberationConfig = function() + local tab = XTableManager.ReadByIntKey(TABLE_CHARACTER_LIBERATION_PATH, XTable.XTableCharacterLiberation, "Id") + for _, config in pairs(tab) do + if not CharLiberationTemplates[config.CharacterId] then + CharLiberationTemplates[config.CharacterId] = {} + end + CharLiberationTemplates[config.CharacterId][config.GrowUpLevel] = config + end +end + +local InitCharGradeConfig = function() + -- 角色改造数据 + local tab = XTableManager.ReadByIntKey(TABLE_CHARACTER_GRADE_PATH, XTable.XTableCharacterGrade, "Id") + for _, config in pairs(tab) do + if not CharGradeTemplates[config.CharacterId] then + CharGradeTemplates[config.CharacterId] = {} + end + + CharGradeTemplates[config.CharacterId][config.Grade] = config + CompareGrade(config.CharacterId, config.Grade) + end +end + +local InitCharLevelConfig = function() + local paths = CS.XTableManager.GetPaths(TABLE_LEVEL_UP_TEMPLATE_PATH) + XTool.LoopCollection(paths, function(path) + local key = tonumber(XTool.GetFileNameWithoutExtension(path)) + LevelUpTemplates[key] = XTableManager.ReadByIntKey(path, XTable.XTableEquipLevelUp, "Level") + end) +end + +local InitMaxLevelConfig = function() + for id, template in pairs(CharacterTemplates) do + local levelTemplate = LevelUpTemplates[template.LevelUpTemplateId] + if not levelTemplate then + XLog.ErrorTableDataNotFound("InitMaxLevelConfig", + "LevelUpTemplates", TABLE_LEVEL_UP_TEMPLATE_PATH, "LevelUpTemplateId", tostring(template.LevelUpTemplateId)) + return + end + + CharBorderTemplates[id].MinLevel = 1 + CharBorderTemplates[id].MaxLevel = #levelTemplate + end +end + +local IntCharSubSkillConfig = function() + SkillGradeConfig = XTableManager.ReadByIntKey(TABLE_CHARACTER_SKILL_GRADE, XTable.XTableCharacterSkillUpgrade, "Id") + SkillGradeDesConfig = XTableManager.ReadByIntKey(TABLE_CHARACTER_SKILL_GRADE_DES, XTable.XTableCharacterSkillUpgradeDes, "Id") + SkillPosConfig = XTableManager.ReadByIntKey(TABLE_CHARACTER_SKILL_POS, XTable.XTableCharacterPos, "CharacterId") + local skillLevelConfig = XTableManager.ReadByIntKey(TABLE_CHARACTER_SKILL_LEVEL, XTable.XTableCharacterSkillLevelEffect, "Id") + SkillTypeInfoConfig = XTableManager.ReadByIntKey(TABLE_CHARACTER_SKILL_TYPE_INFO, XTable.XTableCharacterSkillTypeInfo, "Type") + SkillTypePlusConfig = XTableManager.ReadByIntKey(TABLE_CHARACTER_SKILL_TYPE_PLUS, XTable.XTableCharacterSkillTypePlus, "Id") + CharacterSkillType = XTableManager.ReadByIntKey(TABLE_CHARACTER_SKILL_TYPE, XTable.XTableCharacterSkillType, "Id") + CharSkillTemplates = XTableManager.ReadByIntKey(TABLE_CHARACTER_SKILL, XTable.XTableCharacterSkill, "CharacterId") + + for _, config in pairs(CharSkillTemplates) do + local characterId = config.CharacterId + + local characterSkillConfig = CharacterSkillDictTemplates[characterId] + if not characterSkillConfig then + characterSkillConfig = {} + CharacterSkillDictTemplates[characterId] = characterSkillConfig + end + + local posList = config.Pos + for index, skillGroupId in pairs(config.SkillGroupId) do + local pos = posList[index] + if not pos then + XLog.Error("XCharacterConfigs IntCharSubSkillConfig Error: 角色技能配置初始化错误, 找不到对应位置的技能组Id配置, skillGroupId: " .. skillGroupId .. ", 配置路径: " .. TABLE_CHARACTER_SKILL) + return + end + + local posSkillConfig = characterSkillConfig[pos] + if not posSkillConfig then + posSkillConfig = {} + characterSkillConfig[pos] = posSkillConfig + end + tableInsert(posSkillConfig, skillGroupId) + + CharSkillIdToCharacterIdDic[skillGroupId] = characterId + + if index == XCharacterConfigs.MAX_LEBERATION_SKILL_POS_INDEX then + CharMaxLiberationSkillIdDic[characterId] = skillGroupId + end + end + end + + local charSkillGroupTemplates = XTableManager.ReadByIntKey(TABLE_CHARACTER_SKILL_GROUP, XTable.XTableCharacterSkillGroup, "Id") + for _, config in pairs(charSkillGroupTemplates) do + local skillGroupId = config.Id + local skillIds = config.SkillId + + local skillIdConfig = CharSkillGroupDic[skillGroupId] + if not skillIdConfig then + skillIdConfig = {} + CharSkillGroupDic[skillGroupId] = skillIdConfig + end + + for index, skillId in pairs(skillIds) do + if skillId > 0 then + CharSkillIdToGroupDic[skillId] = { + Index = index, + GroupId = skillGroupId, + } + tableInsert(skillIdConfig, skillId) + end + end + end + + for k, v in pairs(SkillGradeConfig) do + if not CharSkillLevelDict[v.SkillId] then + CharSkillLevelDict[v.SkillId] = {} + end + CharSkillLevelDict[v.SkillId][v.Level] = k + end + + for k, v in pairs(SkillGradeDesConfig) do + if not CharSkillLevelDesDict[v.SkillId] then + CharSkillLevelDesDict[v.SkillId] = {} + end + CharSkillLevelDesDict[v.SkillId][v.Level] = k + end + + SubSkillMinMaxLevelDicLevel = {} + for _, v in pairs(skillLevelConfig) do + if not CharSkillLevelEffectDict[v.SkillId] then + CharSkillLevelEffectDict[v.SkillId] = {} + end + CharSkillLevelEffectDict[v.SkillId][v.Level] = v + + --初始化技能的最小,最大等级2 + SubSkillMinMaxLevelDicLevel[v.SkillId] = SubSkillMinMaxLevelDicLevel[v.SkillId] or {} + if not SubSkillMinMaxLevelDicLevel[v.SkillId].Min + or SubSkillMinMaxLevelDicLevel[v.SkillId].Min > v.Level then + SubSkillMinMaxLevelDicLevel[v.SkillId].Min = v.Level + end + + if not SubSkillMinMaxLevelDicLevel[v.SkillId].Max + or SubSkillMinMaxLevelDicLevel[v.SkillId].Max < v.Level then + SubSkillMinMaxLevelDicLevel[v.SkillId].Max = v.Level + end + end + + --初始化技能的最小,最大等级 + SubSkillMinMaxLevelDicGrade = {} + for _, v in pairs(SkillGradeConfig) do + local skillId = v.SkillId + if not SubSkillMinMaxLevelDicGrade[skillId] then + SubSkillMinMaxLevelDicGrade[skillId] = {} + SubSkillMinMaxLevelDicGrade[skillId].Min = v.Level + SubSkillMinMaxLevelDicGrade[skillId].Max = v.Level + end + + if v.Level < SubSkillMinMaxLevelDicGrade[skillId].Min then + SubSkillMinMaxLevelDicGrade[skillId].Min = v.Level + end + + if v.Level > SubSkillMinMaxLevelDicGrade[skillId].Max then + SubSkillMinMaxLevelDicGrade[skillId].Max = v.Level + end + end +end + +local InitCharacterSkillPoolConfig = function() + CharSkillPoolSkillIdDic = {} + + local skillPoolTemplate = XTableManager.ReadByIntKey(TABLE_CHARACTER_SKILL_POOL, XTable.XTableCharacterSkillPool, "Id") + for _, v in pairs(skillPoolTemplate) do + CharSkillPoolSkillIdDic[v.SkillId] = v + CharPoolIdToSkillInfoDic[v.PoolId] = CharPoolIdToSkillInfoDic[v.PoolId] or {} + + tableInsert(CharPoolIdToSkillInfoDic[v.PoolId], v) + end +end + +local function voteNumSort(dataA, dataB) + local voteA = XDataCenter.VoteManager.GetVote(dataA.Id).VoteNum + local voteB = XDataCenter.VoteManager.GetVote(dataB.Id).VoteNum + return voteA > voteB +end + +local InitRecommendConfig = function(templates) + CharacterTabToVoteGroupMap = {} + for _, config in pairs(templates) do + local typeMap = CharacterTabToVoteGroupMap[config.CharacterId] + if not typeMap then + typeMap = {} + CharacterTabToVoteGroupMap[config.CharacterId] = typeMap + end + + local tabMap = typeMap[config.RecommendType] + if not tabMap then + tabMap = {} + typeMap[config.RecommendType] = tabMap + end + + tabMap[config.TabId] = config + end +end + +function XCharacterConfigs.Init() + CharacterTemplates = XTableManager.ReadByIntKey(TABLE_CHARACTER_PATH, XTable.XTableCharacter, "Id") + CharDetailTemplates = XTableManager.ReadByIntKey(TABLE_CHARACTER_DETAIL, XTable.XTableCharDetail, "Id") + CharTeachSkill = XTableManager.ReadByIntKey(TABLE_CHARACTER_SKILL_TEACH, XTable.XTableCharacterSkillTeach, "Id") + CharElementTemplates = XTableManager.ReadByIntKey(TABLE_CHARACTER_ELEMENT_CONFIG, XTable.XTableCharacterElement, "Id") + CharGraphTemplates = XTableManager.ReadByIntKey(TABLE_CHARACTER_GRAPH_INFO, XTable.XTableGraph, "Id") + CharacterRecommendTemplates = XTableManager.ReadByIntKey(TABLE_CHARACTER_DETAIL_PARNER, XTable.XTableCharacterRecommend, "Id") + EquipRecommendTemplates = XTableManager.ReadByIntKey(TABLE_CHARACTER_DETAIL_EQUIP, XTable.XTableEquipRecommend, "Id") + NpcTemplates = XTableManager.ReadByIntKey(TABLE_NPC_PATH, XTable.XTableNpc, "Id") + CharacterCareerTemplates = XTableManager.ReadByIntKey(TABLE_CHARACTER_CAREER_PATH, XTable.XTableNpcTypeIcon, "Type") + CharacterSkillEntryConfig = XTableManager.ReadByIntKey(TABLE_CHARACTER_SKILL_ENTRY, XTable.XTableCharacterSkillEntry, "Id") + + local templates = XTableManager.ReadByIntKey(TABLE_CHARACTER_RECOMMEND_TAB_CONFIG, XTable.XTableCharacterTabId, "Id") + InitRecommendConfig(templates) + + local characterTemplatesCount = 0 + for id, template in pairs(CharacterTemplates) do + CharBorderTemplates[id] = {} + ItemIdToCharacterIdDic[template.ItemId] = id + characterTemplatesCount = characterTemplatesCount + 1 + end + CharacterTemplatesCount = characterTemplatesCount + + InitCharLevelConfig() + InitCharQualityConfig() + IniCharQualityFragmentConfig() + InitCharLiberationConfig() + InitCharGradeConfig() + InitMaxLevelConfig() + IntCharSubSkillConfig() + InitCharacterSkillPoolConfig() + + CharBorderTemplates = XReadOnlyTable.Create(CharBorderTemplates) + ItemIdToCharacterIdDic = XReadOnlyTable.Create(ItemIdToCharacterIdDic) +end + +local GetCharQualityFragmentConfig = function(characterType, quality) + local characterTypeConfig = CharQualityFragmentTemplates[characterType] + if not characterTypeConfig then + XLog.Error("XCharacterConfigs GetCharQualityFragmentConfig error:配置不存在, : " .. characterType .. ", 配置路径: " .. TABLE_CHARACTER_QUALITY_FRAGMENT_PATH) + return + end + + local config = characterTypeConfig[quality] + if not config then + XLog.Error("XCharacterConfigs GetCharQualityFragmentConfig error:配置不存在, : " .. quality .. ", 配置路径: " .. TABLE_CHARACTER_QUALITY_FRAGMENT_PATH) + return + end + + return config +end + +local function GetGroupSkillIds(skillGroupId) + return CharSkillGroupDic[skillGroupId] or {} +end +XCharacterConfigs.GetGroupSkillIdsByGroupId = GetGroupSkillIds + +function XCharacterConfigs.GetChracterSkillPosToGroupIdDic(characterId) + local config = CharacterSkillDictTemplates[characterId] + if not config then + XLog.ErrorTableDataNotFound("XCharacterConfigs.GetSkillGroupIds", + "CharacterSkillDictTemplates", TABLE_CHARACTER_SKILL, "templateId", characterId) + return + end + return config +end + +function XCharacterConfigs.GetSkillGroupIdAndIndex(skillId) + local skillInfo = CharSkillIdToGroupDic[skillId] + if not skillInfo then return end + return skillInfo.GroupId, skillInfo.Index +end + +function XCharacterConfigs.GetGroupSkillIds(skillId) + local skillGroupId = XCharacterConfigs.GetSkillGroupIdAndIndex(skillId) + if not skillGroupId then return {} end + return GetGroupSkillIds(skillGroupId) +end + +function XCharacterConfigs.CanSkillSwith(skillId) + return #XCharacterConfigs.GetGroupSkillIds(skillId) > 1 +end + +function XCharacterConfigs.GetGroupDefaultSkillId(skillGroupId) + return GetGroupSkillIds(skillGroupId)[1] or 0 +end + +function XCharacterConfigs.GetCharacterSkills(templateId) + local character = XDataCenter.CharacterManager.GetCharacter(templateId) + return XCharacterConfigs.GetCharacterSkillsByCharacter(character) +end + +function XCharacterConfigs.GetCharacterSkillsByCharacter(character) + local templateId = character.Id + + local skills = {} + for i = 1, XCharacterConfigs.MAX_SHOW_SKILL_POS do + skills[i] = {} + skills[i].subSkills = {} + skills[i].configDes = {} + + skills[i].config = {} + skills[i].config.Pos = i + + if not SkillPosConfig[templateId] then + XLog.ErrorTableDataNotFound("XCharacterConfigs.GetCharacterSkills", + "SkillPosConfig", TABLE_CHARACTER_SKILL_POS, "templateId", tostring(templateId)) + else + skills[i].Icon = SkillPosConfig[templateId].MainSkillIcon[i] + skills[i].Name = SkillPosConfig[templateId].MainSkillName[i] + skills[i].TypeDes = SkillPosConfig[templateId].MainSkillType[i] + skills[i].TotalLevel = 0 + + --skills[i].SkillIdList = CharacterSkillDictTemplates[templateId][i]-- todo optimize + --way1:construct a using skillId list + --way2:reconstruct this shit code + local skillIdList = {} + local posDic = XCharacterConfigs.GetChracterSkillPosToGroupIdDic(templateId) + local skillGroupIds = posDic[i] + + for _, skillGroupId in pairs(skillGroupIds) do + local skillId = character:GetGroupCurSkillId(skillGroupId) + if skillId > 0 then + tableInsert(skillIdList, skillId) + end + end + skills[i].SkillIdList = skillIdList--forgive me to choose way1 before deadline + + for _, skillId in pairs(skillIdList) do + local skillCo = {} + skillCo.SubSkillId = skillId + + local skillGroupId = XCharacterConfigs.GetSkillGroupIdAndIndex(skillId) + skillCo.Level = character:GetSkillLevel(skillGroupId) + skills[i].TotalLevel = skills[i].TotalLevel + skillCo.Level + + local tabId = CharSkillLevelDict[skillId][skillCo.Level] + if tabId then + skillCo.config = SkillGradeConfig[tabId] + end + + tabId = CharSkillLevelDesDict[skillId][skillCo.Level] + if tabId then + skillCo.configDes = SkillGradeDesConfig[tabId] + end + + tableInsert(skills[i].subSkills, skillCo) + end + end + end + + return skills +end + +function XCharacterConfigs.GetCharDetailParnerTemplate(templateId) + local config = CharacterRecommendTemplates[templateId] + if not config then + XLog.ErrorTableDataNotFound("XCharacterConfigs.GetCharDetailParnerTemplate", + "CharacterRecommendTemplates", TABLE_CHARACTER_DETAIL_EQUIP, "templateId", tostring(templateId)) + end + return config +end + +function XCharacterConfigs.GetCharacterRecommendListByIds(ids) + local list = {} + for _, id in ipairs(ids) do + local config = XCharacterConfigs.GetCharDetailParnerTemplate(id) + if config then + tableInsert(list, config) + end + end + + tableSort(list, voteNumSort) + + return list +end + +function XCharacterConfigs.GetCharDetailEquipTemplate(templateId) + local config = EquipRecommendTemplates[templateId] + if not config then + XLog.ErrorTableDataNotFound("XCharacterConfigs.GetCharDetailEquipTemplate", + "EquipRecommendTemplates", TABLE_CHARACTER_DETAIL_PARNER, "templateId", tostring(templateId)) + end + return config +end + +function XCharacterConfigs.GetEquipRecommendListByIds(ids) + local list = {} + for _, id in ipairs(ids) do + local config = XCharacterConfigs.GetCharDetailEquipTemplate(id) + if config then + tableInsert(list, config) + end + end + + tableSort(list, voteNumSort) + + return list +end + +function XCharacterConfigs.GetRecommendTabList(characterId, recommendType) + local tabIdList = {} + local typeMap = CharacterTabToVoteGroupMap[characterId] + if typeMap then + local tabMap = typeMap[recommendType] + if tabMap then + for tmpRecommendType, _ in pairs(tabMap) do + tableInsert(tabIdList, tmpRecommendType) + end + end + end + + if not next(tabIdList) then + XLog.ErrorTableDataNotFound("XCharacterConfigs.GetRecommendTabList", + "CharacterTabToVoteGroupMap", TABLE_CHARACTER_RECOMMEND_TAB_CONFIG, "CharacterId", tostring(characterId)) + + return nil + end + + tableSort(tabIdList) + return tabIdList +end + +function XCharacterConfigs.GetRecommendTabTemplate(characterId, tabId, recommendType) + local typeMap = CharacterTabToVoteGroupMap[characterId] + if not typeMap then + XLog.ErrorTableDataNotFound("XCharacterConfigs.GetRecommendTabTemplate", + "CharacterTabToVoteGroupMap", TABLE_CHARACTER_RECOMMEND_TAB_CONFIG, "characterId", tostring(characterId)) + return nil + end + + local tabMap = typeMap[recommendType] + if not tabMap then + XLog.ErrorTableDataNotFound("XCharacterConfigs.GetRecommendTabTemplate", + "typeMap", TABLE_CHARACTER_RECOMMEND_TAB_CONFIG, "recommendType", tostring(recommendType)) + return nil + end + + local config = tabMap[tabId] + if not config then + XLog.ErrorTableDataNotFound("XCharacterConfigs.GetRecommendTabTemplate", + "tabMap", TABLE_CHARACTER_RECOMMEND_TAB_CONFIG, "tabId", tostring(tabId)) + return nil + end + + return config +end + +function XCharacterConfigs.GetRecommendGroupId(characterId, tabId, recommendType) + local typeMap = CharacterTabToVoteGroupMap[characterId] + if not typeMap then + XLog.ErrorTableDataNotFound("XCharacterConfigs.GetRecommendGroupId", + "CharacterTabToVoteGroupMap", TABLE_CHARACTER_RECOMMEND_TAB_CONFIG, "characterId", tostring(characterId)) + return + end + + local tabMap = typeMap[recommendType] + if not tabMap then + XLog.ErrorTableDataNotFound("XCharacterConfigs.GetRecommendGroupId", + "typeMap", TABLE_CHARACTER_RECOMMEND_TAB_CONFIG, "recommendType", tostring(recommendType)) + return + end + + local config = tabMap[tabId] + if not config then + XLog.ErrorTableDataNotFound("XCharacterConfigs.GetRecommendGroupId", "tabMap", TABLE_CHARACTER_RECOMMEND_TAB_CONFIG, "tabId", tostring(tabId)) + return + end + + return config.GroupId +end + +function XCharacterConfigs.GetRecommendTabMap(characterId, recommendType) + local typeMap = CharacterTabToVoteGroupMap[characterId] + if not typeMap then + XLog.ErrorTableDataNotFound("XCharacterConfigs.GetRecommendTabMap", + "CharacterTabToVoteGroupMap", TABLE_CHARACTER_RECOMMEND_TAB_CONFIG, "characterId", tostring(characterId)) + return + end + + local tabMap = typeMap[recommendType] + if not tabMap then + XLog.ErrorTableDataNotFound("XCharacterConfigs.GetRecommendTabMap", + "typeMap", TABLE_CHARACTER_RECOMMEND_TAB_CONFIG, "recommendType", tostring(recommendType)) + return + end + + return tabMap +end + +function XCharacterConfigs.GetCharacterTemplate(templateId) + if XRobotManager.CheckIsRobotId(templateId) then + templateId = XRobotManager.GetCharacterId(templateId) + end + local template = CharacterTemplates[templateId] + if template == nil then + XLog.ErrorTableDataNotFound("XCharacterConfigs.GetCharacterTemplate", + "CharacterTemplates", TABLE_CHARACTER_PATH, "templateId", tostring(templateId)) + return + end + + return template +end + +function XCharacterConfigs.GetCharacterTemplates() + local characterList = {} + for _, config in pairs(CharacterTemplates) do + if XCharacterConfigs.IsCharacterInShowTime(config.Id) then + characterList[config.Id] = config + end + end + return characterList +end + +function XCharacterConfigs.GetCharacterTemplatesCount() + return CharacterTemplatesCount +end + +function XCharacterConfigs.GetAllCharElments() + return CharElementTemplates +end + +function XCharacterConfigs.GetCharElement(elementId) + local template = CharElementTemplates[elementId] + if template == nil then + XLog.ErrorTableDataNotFound("XCharacterConfigs.GetCharElement", + "CharElementTemplates", TABLE_CHARACTER_ELEMENT_CONFIG, "elementId", tostring(elementId)) + return + end + return template +end + + +function XCharacterConfigs.GetCharacterBorderTemplate(templateId) + local template = CharBorderTemplates[templateId] + if template == nil then + XLog.ErrorTableDataNotFound("XCharacterConfigs.GetCharacterBorderTemplate", + "CharBorderTemplates", TABLE_CHARACTER_ELEMENT_CONFIG, "templateId", tostring(templateId)) + return + end + + return template +end + +function XCharacterConfigs.GetCharacterDefaultEquipId(templateId) + local template = XCharacterConfigs.GetCharacterTemplate(templateId) + if template then + return template.EquipId + end +end + +function XCharacterConfigs.GetQualityTemplate(templateId, quality) + if templateId == nil or quality == nil then + XLog.Error("XCharacterConfigs.GetQualityTemplate函数参数不能为空") + return + end + + if quality <= 0 then + XLog.Error("XCharacterConfigs.GetQualityTemplate函数参数quality:" .. quality .. "不能小于等于0") + return + end + + local config = CharQualityTemplates[templateId] + if not config then + XLog.ErrorTableDataNotFound("XCharacterConfigs.GetQualityTemplate", + "CharQualityTemplates", TABLE_CHARACTER_QUALITY_PATH, "templateId", tostring(templateId)) + return + end + + local qualityConfig = config[quality] + if qualityConfig == nil then + XLog.ErrorTableDataNotFound("XCharacterConfigs.GetQualityTemplate", + "CharQualityTemplates", TABLE_CHARACTER_QUALITY_PATH, "templateId", tostring(templateId)) + return + end + + return qualityConfig +end + +function XCharacterConfigs.GetCharNpcId(templateId, quality) + local qualityConfig = XCharacterConfigs.GetQualityTemplate(templateId, quality) + if not qualityConfig then + return + end + + return qualityConfig.NpcId +end + +function XCharacterConfigs.GetAllCharacterCareerIds() + local typeIds = {} + for id, _ in pairs(CharacterCareerTemplates) do + tableInsert(typeIds, id) + end + return typeIds +end + +function XCharacterConfigs.GetNpcTypeTemplate(typeId) + local config = CharacterCareerTemplates[typeId] + if not config then + XLog.ErrorTableDataNotFound("XCharacterConfigs.GetNpcTypeTemplate", + "CharacterCareerTemplates", TABLE_CHARACTER_CAREER_PATH, "typeId", tostring(typeId)) + return + end + + return config +end + +function XCharacterConfigs.GetCareerName(typeId) + local config = XCharacterConfigs.GetNpcTypeTemplate(typeId) + return config.Name +end + +function XCharacterConfigs.GetCareerDes(typeId) + local config = XCharacterConfigs.GetNpcTypeTemplate(typeId) + return config.Des +end + +function XCharacterConfigs.GetNpcTypeIcon(typeId) + local config = XCharacterConfigs.GetNpcTypeTemplate(typeId) + return config.Icon +end + +function XCharacterConfigs.GetNpcTypeIconTranspose(typeId) + local config = XCharacterConfigs.GetNpcTypeTemplate(typeId) + return config.IconTranspose +end + +function XCharacterConfigs.GetCharacterEquipType(templateId) + return CharacterTemplates[templateId].EquipType +end + +function XCharacterConfigs.GetNpcPromotedAttribByQuality(templateId, quality) + local npcId = XCharacterConfigs.GetCharNpcId(templateId, quality) + local npcTemplate = CS.XNpcManager.GetNpcTemplate(npcId) + return XAttribManager.GetPromotedAttribs(npcTemplate.PromotedId) +end + +-- 卡牌信息begin -- +function XCharacterConfigs.GetCharacterName(templateId) + return CharacterTemplates[templateId].Name +end + +function XCharacterConfigs.GetCharacterTradeName(templateId) + return CharacterTemplates[templateId].TradeName +end + +function XCharacterConfigs.GetCharacterLogName(templateId) + return CharacterTemplates[templateId].LogName +end + +function XCharacterConfigs.GetCharacterEnName(templateId) + return CharacterTemplates[templateId].EnName +end + +function XCharacterConfigs.GetCharacterItemId(templateId) + return CharacterTemplates[templateId].ItemId +end + +function XCharacterConfigs.GetCharacterElement(templateId) + return CharacterTemplates[templateId].Element +end + +function XCharacterConfigs.IsCharacterForeShow(templateId) + return CharacterTemplates[templateId].Foreshow == 0 +end + +--是否在展示时间内 +function XCharacterConfigs.IsCharacterInShowTime(templateId) + if not CharacterTemplates[templateId] then return false end + local timeId = CharacterTemplates[templateId].ShowTimeId + return XFunctionManager.CheckInTimeByTimeId(timeId, true) +end + +function XCharacterConfigs.GetCharacterFullNameStr(templateId) + local name = XCharacterConfigs.GetCharacterName(templateId) + local tradeName = XCharacterConfigs.GetCharacterTradeName(templateId) + return CS.XTextManager.GetText("CharacterFullName", name, tradeName) +end + +function XCharacterConfigs.GetCharacterIntro(templateId) + return CharacterTemplates[templateId].Intro +end + +function XCharacterConfigs.GetCharacterPriority(templateId) + return CharacterTemplates[templateId].Priority +end + +function XCharacterConfigs.GetCharacterEmotionIcon(templateId) + return CharacterTemplates[templateId].EmotionIcon +end + +function XCharacterConfigs.GetCharacterCaptainSkill(templateId) + return CharacterTemplates[templateId].CaptainSkillId +end + +function XCharacterConfigs.GetCharacterStoryChapterId(templateId) + return CharacterTemplates[templateId].StoryChapterId +end + +function XCharacterConfigs.GetCharacterCodeStr(templateId) + return CharacterTemplates[templateId].Code +end + +function XCharacterConfigs.GetCharacterType(templateId) + local config = XCharacterConfigs.GetCharacterTemplate(templateId) + return config.Type +end + +function XCharacterConfigs.IsIsomer(templateId) + if not XTool.IsNumberValid(templateId) then return false end + return XCharacterConfigs.GetCharacterType(templateId) == XCharacterConfigs.CharacterType.Isomer +end + +--首次获得弹窗 +function XCharacterConfigs.GetCharacterNeedFirstShow(templateId) + return CharacterTemplates[templateId].NeedFirstShow +end +-- 卡牌信息end -- +-- 升级相关begin -- +function XCharacterConfigs.GetCharMaxLevel(tempalteId) + if not tempalteId then + XLog.Error("XCharacterConfigs.GetCharMaxLevel函数参数tempalteId不能为空") + return + end + + return CharBorderTemplates[tempalteId].MaxLevel +end + +function XCharacterConfigs.GetNextLevelExp(templateId, level) + local levelUpTemplateId = CharacterTemplates[templateId].LevelUpTemplateId + local levelUpTemplate = LevelUpTemplates[levelUpTemplateId] + + return levelUpTemplate[level].Exp +end + +function XCharacterConfigs.GetLevelUpTemplate(levelUpTemplateId) + return LevelUpTemplates[levelUpTemplateId] +end + +-- 升级相关end -- +-- 品质相关begin -- +function XCharacterConfigs.GetCharQualityIcon(quality) + if not quality or quality < 1 then + XLog.Error("XCharacterConfigs.GetCharQualityIcon函数参数不规范,参数是quality:" .. quality) + return + end + + local template = CharQualityIconTemplates[quality] + if not template then + XLog.ErrorTableDataNotFound("XCharacterConfigs.GetCharQualityIcon", + "CharQualityIconTemplates", TABLE_CHARACTER_QUALITY_ICON_PATH, "quality", tostring(quality)) + return + end + + return template.Icon +end + +function XCharacterConfigs.GetCharacterQualityIcon(quality) + if not quality or quality < 1 then + XLog.Error("XCharacterConfigs.GetCharacterQualityIcon函数参数不规范,参数是quality:" .. quality) + return + end + + local template = CharQualityIconTemplates[quality] + if not template then + XLog.ErrorTableDataNotFound("XCharacterConfigs.GetCharacterQualityIcon", + "CharQualityIconTemplates", TABLE_CHARACTER_QUALITY_ICON_PATH, "quality", tostring(quality)) + return + end + + return template.IconCharacter +end + +function XCharacterConfigs.GetCharQualityIconGoods(quality) + if not quality or quality < 1 then + XLog.Error("XCharacterConfigs.GetCharQualityIconGoods函数参数不规范,参数是quality:" .. quality) + return + end + + local template = CharQualityIconTemplates[quality] + if not template then + XLog.ErrorTableDataNotFound("XCharacterConfigs.GetCharQualityIconGoods", + "CharQualityIconTemplates", TABLE_CHARACTER_QUALITY_ICON_PATH, "quality", tostring(quality)) + return + end + + return template.IconGoods +end + +function XCharacterConfigs.GetCharQualityDesc(quality) + if not quality or quality < 1 then + XLog.Error("XCharacterConfigs.GetCharQualityIcon函数参数不规范,参数是quality:" .. quality) + return + end + + local template = CharQualityIconTemplates[quality] + if not template then + XLog.ErrorTableDataNotFound("XCharacterConfigs.GetCharQualityDesc", + "CharQualityIconTemplates", TABLE_CHARACTER_QUALITY_ICON_PATH, "quality", tostring(quality)) + return + end + + return template.Desc +end + +function XCharacterConfigs.GetDecomposeCount(characterType, quality) + local config = GetCharQualityFragmentConfig(characterType, quality) + return config.DecomposeCount +end + +function XCharacterConfigs.GetComposeCount(characterType, quality) + local config = GetCharQualityFragmentConfig(characterType, quality) + return config.ComposeCount +end + +function XCharacterConfigs.GetStarUseCount(characterType, quality, star) + if not quality or quality < 1 then + XLog.Error("XCharacterConfigs.GetStarUseCount函数参数不规范,参数是quality:" .. quality) + return + end + + if not star or (star < 1 or star > XCharacterConfigs.MAX_QUALITY_STAR) then + XLog.Error("XCharacterConfigs.GetStarUseCount函数参数不规范,参数是star:" .. star) + return + end + + local config = GetCharQualityFragmentConfig(characterType, quality) + local starUseCount = config.StarUseCount + return starUseCount[star] or 0 +end + +function XCharacterConfigs.GetPromoteUseCoin(characterType, quality) + local config = GetCharQualityFragmentConfig(characterType, quality) + return config.PromoteUseCoin +end + +function XCharacterConfigs.GetPromoteItemId(characterType, quality) + local config = GetCharQualityFragmentConfig(characterType, quality) + return config.PromoteItemId +end + +function XCharacterConfigs.GetCharStarAttribId(templateId, quality, star) + if not templateId then + XLog.Error("XCharacterConfigs.GetCharStarAttribIdca函数参数templateId为空") + return + end + + if not quality or (quality < 1 or quality > XCharacterConfigs.GetCharMaxQuality(templateId)) then + XLog.Error("XCharacterConfigs.GetCharStarAttribId函数参数不规范,参数是quality:" .. quality) + return + end + + if not star or (star < 1 or star > XCharacterConfigs.MAX_QUALITY_STAR) then + XLog.Error("XCharacterConfigs.GetCharStarAttribId函数参数不规范,参数是star:" .. star) + return + end + + local template = CharQualityTemplates[templateId] + if not template[quality] then + XLog.ErrorTableDataNotFound("XCharacterConfigs.GetCharStarAttribId", + "CharQualityTemplates", TABLE_CHARACTER_QUALITY_PATH, "templateId", tostring(templateId)) + return + end + + local attrIds = template[quality].AttrId + + if attrIds and attrIds[star] then + if attrIds[star] > 0 then + return attrIds[star] + end + end +end + +function XCharacterConfigs.GetCharStarAttribs(templateId, quality, star) + if not templateId and not quality and not star then + XLog.Error("XCharacterConfigs.GetCharStarAttribs函数参数不规范,参数是templateId, quality, star") + return + end + + if star < XCharacterConfigs.MAX_QUALITY_STAR then + local attrId = XCharacterConfigs.GetCharStarAttribId(templateId, quality, star + 1) + if not attrId then + XLog.ErrorTableDataNotFound("XCharacterConfigs.GetCharStarAttribs", + "CharQualityTemplates", TABLE_CHARACTER_QUALITY_PATH, "templateId", tostring(templateId)) + return + end + + return XAttribManager.GetBaseAttribs(attrId) + end +end + +function XCharacterConfigs.GetCharMinQuality(templateId) + if not templateId then + XLog.Error("XCharacterConfigs.GetCharMinQuality函数参数templateId不能为空") + return + end + + if not CharBorderTemplates[templateId] then + XLog.ErrorTableDataNotFound("XCharacterConfigs.GetCharMinQuality", + "CharBorderTemplates", TABLE_CHARACTER_ELEMENT_CONFIG, "templateId", tostring(templateId)) + return + end + + return CharBorderTemplates[templateId].MinQuality +end + +function XCharacterConfigs.GetCharMaxQuality(templateId) + if not templateId then + XLog.Error("XCharacterConfigs.GetCharMaxQuality函数参数templateId为空") + return + end + + return CharBorderTemplates[templateId].MaxQuality +end + +function XCharacterConfigs.GetCharGraphTemplate(graphId) + local template = CharGraphTemplates[graphId] + if not template then + XLog.ErrorTableDataNotFound("XCharacterConfigs.GetCharGraphTemplate", + "CharGraphTemplates", TABLE_CHARACTER_GRAPH_INFO, "graphId", tostring(graphId)) + return + end + return template +end +-- 品质相关end -- +-- 改造相关begin -- +function XCharacterConfigs.GetCharMaxGrade(templateId) + return CharBorderTemplates[templateId].MaxGrade +end + +function XCharacterConfigs.GetCharMinGrade(templateId) + return CharBorderTemplates[templateId].MinGrade +end + +function XCharacterConfigs.GetQualityUpgradeItemId(templateId, grade) + return CharGradeTemplates[templateId][grade].UseItemId +end + +function XCharacterConfigs.GetCharGradeIcon(templateId, grade) + return CharGradeTemplates[templateId][grade].GradeIcon +end + +function XCharacterConfigs.GetGradeTemplates(templateId, grade) + return CharGradeTemplates[templateId][grade] +end + +function XCharacterConfigs.GetCharGradeName(templateId, grade) + grade = grade or XCharacterConfigs.GetCharMinGrade(templateId) + return CharGradeTemplates[templateId][grade].GradeName +end + +function XCharacterConfigs.GetCharGradeUseMoney(templateId, grade) + local consumeItem = {} + consumeItem.Id = CharGradeTemplates[templateId][grade].UseItemKey + consumeItem.Count = CharGradeTemplates[templateId][grade].UseItemCount + return consumeItem +end + +function XCharacterConfigs.GetCharGradeAttrId(templateId, grade) + if not templateId or not grade then + XLog.Error("XCharacterConfigs.GetCharGradeAttrId函数参数错误,templateId为空或者grade为空") + return + end + + local template = CharGradeTemplates[templateId] + if not template then + return + end + + if template[grade] then + if template[grade].AttrId and template[grade].AttrId > 0 then + return template[grade].AttrId + end + end +end + +function XCharacterConfigs.GetNeedPartsGrade(templateId, grade) + return CharGradeTemplates[templateId][grade].PartsGrade +end + +function XCharacterConfigs.GetSubSkillMinMaxLevel(subSkillId) + return SubSkillMinMaxLevelDicGrade[subSkillId] +end + +-- 副技能最小最大等级配置(from TABLE_CHARACTER_SKILL_GRADE) +function XCharacterConfigs.ClampSubSkillLevelByGrade(skillId, skillLevel) + local fixSkillLevel = skillLevel + if SubSkillMinMaxLevelDicGrade[skillId].Max < fixSkillLevel then + fixSkillLevel = SubSkillMinMaxLevelDicGrade[skillId].Max + elseif SubSkillMinMaxLevelDicGrade[skillId].Min > fixSkillLevel then + fixSkillLevel = SubSkillMinMaxLevelDicGrade[skillId].Min + end + return fixSkillLevel +end + +-- 副技能最小最大等级配置(from TABLE_CHARACTER_SKILL_LEVEL) +function XCharacterConfigs.ClampSubSkillLeveByLevel(skillId, skillLevel) + local fixSkillLevel = skillLevel + if SubSkillMinMaxLevelDicLevel[skillId].Max < fixSkillLevel then + fixSkillLevel = SubSkillMinMaxLevelDicLevel[skillId].Max + elseif SubSkillMinMaxLevelDicLevel[skillId].Min > fixSkillLevel then + fixSkillLevel = SubSkillMinMaxLevelDicLevel[skillId].Min + end + return fixSkillLevel +end + +function XCharacterConfigs.GetCharTeachById(charId) + return CharTeachSkill[charId] +end + +--战中设置 +function XCharacterConfigs.GetCharTeachIconById(charId) + local cfg = CharTeachSkill[charId] + return cfg and cfg.TeachIcon or nil +end + +--战中设置 +function XCharacterConfigs.GetCharTeachDescriptionById(charId) + local cfg = CharTeachSkill[charId] + return cfg and cfg.Description or nil +end + +function XCharacterConfigs.GetCharTeachStageIdById(charId) + local cfg = CharTeachSkill[charId] + return cfg and cfg.StageId +end + +function XCharacterConfigs.GetCharTeachWebUrlById(charId) + local cfg = CharTeachSkill[charId] + return cfg and cfg.WebUrl +end + +function XCharacterConfigs.GetSubSkillAbility(subSkillId, level) + local config = XCharacterConfigs.GetSkillLevelEffectTemplate(subSkillId, level) + return config and config.Ability or 0 +end + +function XCharacterConfigs.GetResonanceSkillAbility(subSkillId, level) + local config = XCharacterConfigs.GetSkillLevelEffectTemplate(subSkillId, level) + return config and config.ResonanceAbility or 0 +end + +function XCharacterConfigs.GetPlusSkillAbility(subSkillId, level) + local config = XCharacterConfigs.GetSkillLevelEffectTemplate(subSkillId, level) + return config and config.PlusAbility or 0 +end + +function XCharacterConfigs.GetSkillLevelEffectTemplate(skillId, level) + local subSkills = CharSkillLevelEffectDict[skillId] + if (not subSkills) then + XLog.ErrorTableDataNotFound("XCharacterConfigs.GetSkillLevelEffectTemplate", + "CharSkillLevelEffectDict", TABLE_CHARACTER_SKILL_LEVEL, "skillId", tostring(skillId)) + return + end + + local config = subSkills[level] + if not config then + XLog.ErrorTableDataNotFound("XCharacterConfigs.GetSkillLevelEffectTemplate", + "CharSkillLevelEffectDict", TABLE_CHARACTER_SKILL_LEVEL, "skillId : level", tostring(skillId) .. " : " .. tostring(level)) + return + end + + return config +end + +--==============================-- +--desc: 获取队长技能描述 +--@characterId: 卡牌数据 +--@return 技能Data +--==============================-- +function XCharacterConfigs.GetCaptainSkillInfo(characterId, skillLevel) + local captianSkillId = XCharacterConfigs.GetCharacterCaptainSkill(characterId) + if not skillLevel then + local config = SubSkillMinMaxLevelDicGrade[captianSkillId] + if not config then + XLog.ErrorTableDataNotFound("XCharacterConfigs.GetCaptainSkillInfo", + "SubSkillMinMaxLevelDicGrade", TABLE_CHARACTER_SKILL_GRADE, "characterId", tostring(characterId)) + return + end + skillLevel = config.Min + end + + if not CharSkillLevelDesDict[captianSkillId] then + XLog.ErrorTableDataNotFound("XCharacterConfigs.GetCaptainSkillInfo", + "CharSkillLevelDesDict", TABLE_CHARACTER_SKILL_GRADE_DES, "characterId : skillLevel", tostring(characterId) .. " : " .. tostring(skillLevel)) + end + local tab = CharSkillLevelDesDict[captianSkillId][skillLevel] + local config = SkillGradeDesConfig[tab] + if not config then + XLog.ErrorTableDataNotFound("XCharacterConfigs.GetCaptainSkillInfo", + "CharSkillLevelDesDict", TABLE_CHARACTER_SKILL_GRADE_DES, "characterId : skillLevel", tostring(characterId) .. " : " .. tostring(skillLevel)) + end + + return config +end + +function XCharacterConfigs.GetSkillGradeConfig(subSkillId, subSkillLevel) + local skillLevelDict = CharSkillLevelDict[subSkillId] + if not skillLevelDict then + return + end + + local tabId = skillLevelDict[subSkillLevel] + if not tabId then + return + end + + return SkillGradeConfig[tabId] +end + +function XCharacterConfigs.GetSkillGradeDesConfig(subSkillId, subSkillLevel) + local skillLevelDict = CharSkillLevelDesDict[subSkillId] + if not skillLevelDict then + XLog.Error("XCharacterConfigs.GetSkillGradeDesConfig Error: 获取技能等级配置错误, subSkillId: " .. subSkillId .. ", 配置路径: " .. TABLE_CHARACTER_SKILL_GRADE_DES) + return + end + + local tabId = skillLevelDict[subSkillLevel] + if not tabId then + XLog.Error("XCharacterConfigs.GetSkillGradeDesConfig Error: 获取技能等级配置错误, subSkillId: " .. subSkillId .. " subSkillLevel: " .. subSkillLevel .. ", 配置路径: " .. TABLE_CHARACTER_SKILL_GRADE_DES) + return + end + + return SkillGradeDesConfig[tabId] +end + +function XCharacterConfigs.GetSkillGradeDesConfigSkillDes(subSkillId, subSkillLevel) + local config = XCharacterConfigs.GetSkillGradeDesConfig(subSkillId, subSkillLevel) + return config.Name, config.Intro +end + +function XCharacterConfigs.GetSkillGradeDesConfigWeaponSkillDes(subSkillId, subSkillLevel) + local config = XCharacterConfigs.GetSkillGradeDesConfig(subSkillId, subSkillLevel) + return config.WeaponSkillDes +end + +--获取角色技能词条描述列表 +function XCharacterConfigs.GetSkillGradeDesConfigEntryList(subSkillId, subSkillLevel) + local entryList = {} + local config = XCharacterConfigs.GetSkillGradeDesConfig(subSkillId, subSkillLevel) + for _, entryId in ipairs(config.EntryId) do + if XTool.IsNumberValid(entryId) then + tableInsert(entryList, { + Name = XCharacterConfigs.GetSkillEntryName(entryId), + Desc = XCharacterConfigs.GetSkillEntryDesc(entryId), + }) + end + end + return entryList +end + +function XCharacterConfigs.GetCharcterIdByFragmentItemId(itemId) + return ItemIdToCharacterIdDic[itemId] +end +-------------角色详细相关------------------ +function XCharacterConfigs.GetCharDetailTemplate(templateId) + return CharDetailTemplates[templateId] +end + +function XCharacterConfigs.GetCharacterQualityCfg(templateId) + local template = XCharacterConfigs.GetCharacterTemplate(templateId) + return template and template.Quality or 0 +end + +function XCharacterConfigs.GetCharDetailCareer(templateId) + local config = XCharacterConfigs.GetCharDetailTemplate(templateId) + return config and config.Career +end + +function XCharacterConfigs.GetCharDetailObtainElementList(templateId) + local config = XCharacterConfigs.GetCharDetailTemplate(templateId) + return config and config.ObtainElementList +end + +function XCharacterConfigs.GetCharacterSkillPoolSkillInfo(skillId) + if not CharSkillPoolSkillIdDic[skillId] then + XLog.ErrorTableDataNotFound("XCharacterConfigs.GetCharacterSkillPoolSkillInfo", + "CharSkillPoolSkillIdDic", TABLE_CHARACTER_SKILL_POOL, "skillId", tostring(skillId)) + end + + return CharSkillPoolSkillIdDic[skillId] +end + +function XCharacterConfigs.GetCharacterIdBySkillId(skillId) + local skillGroupId = XCharacterConfigs.GetSkillGroupIdAndIndex(skillId) + return CharSkillIdToCharacterIdDic[skillGroupId] +end + +function XCharacterConfigs.GetCharacterSkillPoolSkillInfos(poolId, characterId) + local skillInfos = {} + + if not CharPoolIdToSkillInfoDic[poolId] then return skillInfos end + for _, skillInfo in pairs(CharPoolIdToSkillInfoDic[poolId]) do + local skillId = skillInfo.SkillId + local skillGroupId = XCharacterConfigs.GetSkillGroupIdAndIndex(skillId) + if characterId and skillGroupId and CharSkillIdToCharacterIdDic[skillGroupId] == characterId then + tableInsert(skillInfos, skillInfo) + end + end + + return skillInfos +end + +function XCharacterConfigs.GetNpcTemplate(id) + local template = NpcTemplates[id] + if not template then + XLog.ErrorTableDataNotFound("XCharacterConfigs.GetNpcTemplate", "NpcTemplates", TABLE_NPC_PATH, "id", tostring(id)) + return + end + + return template +end + +local function GetCharLiberationConfig(characterId, growUpLevel) + local config = CharLiberationTemplates[tonumber(characterId)] + if not config then + return + end + + config = config[growUpLevel] + if not config then + return + end + + return config +end + +function XCharacterConfigs.GetCharLiberationLevelModelId(characterId, growUpLevel) + local config = GetCharLiberationConfig(characterId, growUpLevel) + return config and config.ModelId +end + +function XCharacterConfigs.GetCharLiberationLevelModelId(characterId, growUpLevel) + local config = GetCharLiberationConfig(characterId, growUpLevel) + return config and config.ModelId +end + +function XCharacterConfigs.GetCharLiberationLevelEffectRootAndPath(characterId, growUpLevel) + local config = GetCharLiberationConfig(characterId, growUpLevel) + if not config then return end + return config.EffectRootName, config.EffectPath +end + +function XCharacterConfigs.GetCharLiberationLevelTitle(characterId, growUpLevel) + local config = GetCharLiberationConfig(characterId, growUpLevel) + return config and config.Title or "" +end + +function XCharacterConfigs.GetCharLiberationLevelDesc(characterId, growUpLevel) + local config = GetCharLiberationConfig(characterId, growUpLevel) + return config and config.Desc or "" +end + +function XCharacterConfigs.GetCharMaxLiberationSkillGroupId(characterId) + return CharMaxLiberationSkillIdDic[characterId] +end + +function XCharacterConfigs.GetSkillTypePlusTemplate(id) + return SkillTypePlusConfig[id] +end + +function XCharacterConfigs.GetSkillTypeName(id) + local cfg = SkillTypeInfoConfig[id] + return cfg and cfg.Name or "" +end + +function XCharacterConfigs.GetSkillType(skillId) + local cfg = CharacterSkillType[skillId] + return cfg and cfg.Type or 0 +end + +function XCharacterConfigs.GetSkillPlusList(characterId, charType, plusId) + local skillTemplate = CharSkillTemplates[characterId] + if not skillTemplate then + return + end + + local plusTemplate = XCharacterConfigs.GetSkillTypePlusTemplate(plusId) + if not plusTemplate then + return + end + + local isValidType = false + for _, type in pairs(plusTemplate.CharacterType) do + if type == charType then + isValidType = true + break + end + end + + if not isValidType then + return + end + + local plusList = {} + for _, skillGroupId in pairs(skillTemplate.SkillGroupId) do + local skillIds = GetGroupSkillIds(skillGroupId) + for _, skillId in pairs(skillIds) do + local type = XCharacterConfigs.GetSkillType(skillId) + if type ~= 0 then + for _, skillType in pairs(plusTemplate.SkillType) do + if skillType == type then + tableInsert(plusList, skillId) + break + end + end + end + end + end + + return plusList +end + +function XCharacterConfigs.GetCharacterElementPath() + return TABLE_CHARACTER_ELEMENT_CONFIG +end + +--技能词条 begin-- +local function GetSkillEntryConfig(entryId) + local config = CharacterSkillEntryConfig[entryId] + if not config then + XLog.Error("XCharacterConfigs GetSkillEntryConfig error:配置不存在, entryId: " .. entryId .. ", 配置路径: " .. TABLE_CHARACTER_SKILL_ENTRY) + return + end + return config +end + +function XCharacterConfigs.GetSkillEntryName(entryId) + local config = GetSkillEntryConfig(entryId) + return config.Name +end + +function XCharacterConfigs.GetSkillEntryDesc(entryId) + local config = GetSkillEntryConfig(entryId) + return XUiHelper.ConvertLineBreakSymbol(config.Description) +end +--技能词条 end-- diff --git a/Resources/Scripts/XConfig/XCharacterUiEffectConfig.lua b/Resources/Scripts/XConfig/XCharacterUiEffectConfig.lua new file mode 100644 index 00000000..08955dad --- /dev/null +++ b/Resources/Scripts/XConfig/XCharacterUiEffectConfig.lua @@ -0,0 +1,75 @@ +XCharacterUiEffectConfig = XCharacterUiEffectConfig or {} +local TABLE_CHARACTER_UI_EFFECT = "Client/Character/CharacterUiEffect.tab" +local TABLE_FASHION = "Share/Fashion/Fashion.tab" +local CharacterUiEffectTable = {} +local EffectDictionary = {} +function XCharacterUiEffectConfig.Init() + EffectDictionary = {} + CharacterUiEffectTable = XTableManager.ReadByIntKey(TABLE_CHARACTER_UI_EFFECT, XTable.XTableCharacterUiEffect, "Id") + local FashionTemplates = XTableManager.ReadByIntKey(TABLE_FASHION, XTable.XTableFashion, "Id") + for _, v in pairs(CharacterUiEffectTable) do + if not v.FashionId then + XLog.Error(string.format("CharacterUiEffect表出错!存在没有填FashionId的数据!表地址:" .. TABLE_CHARACTER_UI_EFFECT)) + end + if not v.EffectPath then + XLog.Error(string.format("CharacterUiEffect表出错!存在没有填EffectPath的数据!表地址:" .. TABLE_CHARACTER_UI_EFFECT .. "Id:" .. v.Id)) + end + local fashionTemplate = FashionTemplates[v.FashionId] + if not fashionTemplate then + XLog.ErrorTableDataNotFound("CharacterUiEffectConfig.Init", "Fashion", TABLE_FASHION, "fashionId", tostring(v.FashionId)) + return + end + local characterId = fashionTemplate.CharacterId + local character = EffectDictionary[characterId] + if not character then + EffectDictionary[characterId] = {} + character = EffectDictionary[characterId] + end + local fashion = character[v.FashionId] + if not fashion then + character[v.FashionId] = {} + fashion = character[v.FashionId] + end + if v.ActionId then + fashion[v.ActionId] = v + else + if not fashion.DefaultEffect then + fashion.DefaultEffect = v + else + XLog.Error("CharacterUiEffect表出错!一个FashionId只能有一个不填写ActionId的数据项!FashionId: " .. v.FashionId) + end + end + end +end + +function XCharacterUiEffectConfig.GetCharacterUiEffectById(id) + return CharacterUiEffectTable[id] +end + +function XCharacterUiEffectConfig.GetEffectInfo(characterId, fashionId, actionId) + if not characterId or not fashionId then + XLog.Error(string.format("XCharacterUiEffectConfig.GetEffectInfo出错,必须参数存在空值,characterId: %s,fashionId: %s", + tostring(characterId), tostring(fashionId))) + return nil + end + local character = EffectDictionary[characterId] + if not character then + --XLog.ErrorTableDataNotFound("XCharacterUiEffectConfig.GetEffectInfo", "Ui角色动作特效", TABLE_CHARACTER_UI_EFFECT, "CharacterId", tostring(characterId)) + return nil + end + local fashion = character[fashionId] + if not fashion then + --XLog.ErrorTableDataNotFound("XCharacterUiEffectConfig.GetEffectInfo", "Ui角色动作特效", TABLE_CHARACTER_UI_EFFECT, "FashionId", tostring(fashionId)) + return nil + end + local cfg + if actionId then + cfg = fashion[actionId] + else + cfg = fashion.DefaultEffect + end + if not cfg then + return nil + end + return cfg.Id, cfg.EffectRootName, cfg.EffectPath +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XChatConfigs.lua b/Resources/Scripts/XConfig/XChatConfigs.lua new file mode 100644 index 00000000..44e58a3d --- /dev/null +++ b/Resources/Scripts/XConfig/XChatConfigs.lua @@ -0,0 +1,75 @@ +local tableInsert = table.insert +local tableSort = table.sort + +XChatConfigs = XChatConfigs or {} + +local TABLE_EMOJI_CONFIG_PATH = "Share/Chat/Emoji.tab" +local TABLE_EFFECT_CONFIG_PATH = "Client/Chat/KeywordEffect.tab" + +local EmojiTemplates = {} +local EffectTemplates = {} +XChatConfigs.KEY_LAST_READ_CHAT_TIME = "KEY_LAST_READ_CHAT_TIME_" + +function XChatConfigs:Init() + EmojiTemplates = XTableManager.ReadByIntKey(TABLE_EMOJI_CONFIG_PATH, XTable.XTableEmoji, "Id") + EffectTemplates = XTableManager.ReadByIntKey(TABLE_EFFECT_CONFIG_PATH, XTable.XTableChatEffect, "Id") +end + +--这里这里用于传出完整配置条目,外部谨允许局部域生命周期内使用,不允许持有!!!! +function XChatConfigs.GetEmojiConfigById(emojiId) + if not EmojiTemplates[emojiId] then + XLog.Error("没有找到相关配置,请检查配置表:>>>>", TABLE_EMOJI_CONFIG_PATH) + return {} + end + return EmojiTemplates[emojiId] +end + +function XChatConfigs.GetEmojiIcon(emojiId) + emojiId = tonumber(emojiId) + emojiId = emojiId or 0 + local cfg = EmojiTemplates[emojiId] + if cfg == nil then + return nil + end + return cfg.Path +end + +function XChatConfigs.GetEmojiQuality() + return 1 +end + +function XChatConfigs.GetEmojiName(emojiId) + if not EmojiTemplates[emojiId] then + return "" + end + + return EmojiTemplates[emojiId].Name +end + +function XChatConfigs.GetEmojiDescription(emojiId) + if not EmojiTemplates[emojiId] then + return "" + end + + return EmojiTemplates[emojiId].Description +end + +function XChatConfigs.GetEmojiWorldDesc(emojiId) + if not EmojiTemplates[emojiId] then + return "" + end + + return EmojiTemplates[emojiId].WorldDesc +end + +function XChatConfigs.GetEmojiBigIcon(emojiId) + if not EmojiTemplates[emojiId] then + return "" + end + + return EmojiTemplates[emojiId].BigIcon +end + +function XChatConfigs.GetEffectTemplates() + return EffectTemplates +end diff --git a/Resources/Scripts/XConfig/XChessPursuitConfig.lua b/Resources/Scripts/XConfig/XChessPursuitConfig.lua new file mode 100644 index 00000000..aa9f67b8 --- /dev/null +++ b/Resources/Scripts/XConfig/XChessPursuitConfig.lua @@ -0,0 +1,552 @@ +XChessPursuitConfig = XChessPursuitConfig or {} + +local TABLE_CHESSPURSUITBOSS_PATH = "Share/ChessPursuit/ChessPursuitBoss.tab" +local TABLE_CHESSPURSUITCARD_PATH = "Share/ChessPursuit/ChessPursuitCard.tab" +local TABLE_CHESSPURSUITCARDEFFECT_PATH = "Share/ChessPursuit/ChessPursuitCardEffect.tab" +local TABLE_CHESSPURSUITMAP_PATH = "Share/ChessPursuit/ChessPursuitMap.tab" +local TABLE_CHESSPURSUITMAPCARDSHOP_PATH = "Share/ChessPursuit/ChessPursuitMapCardShop.tab" +local TABLE_CHESSPURSUITMAPGROUP_PATH = "Share/ChessPursuit/ChessPursuitMapGroup.tab" +local TABLE_CHESSPURSUITMAPINITFUNC_PATH = "Share/ChessPursuit/ChessPursuitMapInitFunc.tab" +local TABLE_CHESSPURSUITTESTROLE_PATH = "Share/ChessPursuit/ChessPursuitTestRole.tab" +local TABLE_CHESSPURSUITSTEP_PATH = "Client/ChessPursuit/ChessPursuitStep.tab" +local TABLE_CHESS_PURSUIT_MAP_GROUP_REWARD_PATH = "Share/ChessPursuit/ChessPursuitMapGroupReward.tab" + +local ChessPursuitBossTemplate = {} +local ChessPursuitCardTemplate = {} +local ChessPursuitCardEffectTemplate = {} +local ChessPursuitMapTemplate = {} +local ChessPursuitMapCardShopTemplate = {} +local ChessPursuitMapGroupTemplate = {} +local ChessPursuitMapInitFuncTemplate = {} +local ChessPursuitTestRoleTemplate = {} +local ChessPursuitStepTemplate = {} +local ChessPursuitMapGroupRewardTemplate = {} + +local MapGroupRewardByGroupIdToIdDic = {} + +local CSXTextManagerGetText = CS.XTextManager.GetText + +--追击玩法商币道具的id +XChessPursuitConfig.SHOP_COIN_ITEM_ID = nil + +XChessPursuitConfig.Period = { + Stable = 0, --安稳期 + Fight = 1, --斗争期 +} + +XChessPursuitConfig.MEMBER_POS_COLOR = { + "FF1111FF", -- red + "4F99FFFF", -- blue + "F9CB35FF", -- yellow +} + +XChessPursuitConfig.InitFuncType = { + InitAddCoin = 1007, --完成x地图则增加y的初始货币 +} + +local function InitMapGroupRewardByGroupIdToIdDic() + for _, v in ipairs(ChessPursuitMapGroupRewardTemplate) do + if not MapGroupRewardByGroupIdToIdDic[v.GroupId] then + MapGroupRewardByGroupIdToIdDic[v.GroupId] = {} + end + table.insert(MapGroupRewardByGroupIdToIdDic[v.GroupId], v.Id) + end +end + +function XChessPursuitConfig.Init() + ChessPursuitBossTemplate = XTableManager.ReadByIntKey(TABLE_CHESSPURSUITBOSS_PATH, XTable.XTableChessPursuitBoss, "Id") + ChessPursuitCardTemplate = XTableManager.ReadByIntKey(TABLE_CHESSPURSUITCARD_PATH, XTable.XTableChessPursuitCard, "Id") + ChessPursuitCardEffectTemplate = XTableManager.ReadByIntKey(TABLE_CHESSPURSUITCARDEFFECT_PATH, XTable.XTableChessPursuitCardEffect, "Id") + ChessPursuitMapTemplate = XTableManager.ReadByIntKey(TABLE_CHESSPURSUITMAP_PATH, XTable.XTableChessPursuitMap, "Id") + ChessPursuitMapCardShopTemplate = XTableManager.ReadByIntKey(TABLE_CHESSPURSUITMAPCARDSHOP_PATH, XTable.XTableChessPursuitMapCardShop, "Id") + ChessPursuitMapGroupTemplate = XTableManager.ReadByIntKey(TABLE_CHESSPURSUITMAPGROUP_PATH, XTable.XTableChessPursuitMapGroup, "Id") + ChessPursuitMapInitFuncTemplate = XTableManager.ReadByIntKey(TABLE_CHESSPURSUITMAPINITFUNC_PATH, XTable.XTableChessPursuitMapInitFunc, "Id") + ChessPursuitTestRoleTemplate = XTableManager.ReadByIntKey(TABLE_CHESSPURSUITTESTROLE_PATH, XTable.XTableChessPursuitTestRole, "Id") + ChessPursuitStepTemplate = XTableManager.ReadByIntKey(TABLE_CHESSPURSUITSTEP_PATH, XTable.XTableChessPursuitStep, "Id") + ChessPursuitMapGroupRewardTemplate = XTableManager.ReadByIntKey(TABLE_CHESS_PURSUIT_MAP_GROUP_REWARD_PATH, XTable.XTableChessPursuitMapGroupReward, "Id") + + XChessPursuitConfig.SHOP_COIN_ITEM_ID = ChessPursuitMapTemplate[1].CoinId + InitMapGroupRewardByGroupIdToIdDic() +end + +--@region 各个表的主Get函数 +function XChessPursuitConfig.GetChessPursuitBossTemplate(id) + local data = ChessPursuitBossTemplate[id] + if not data then + XLog.ErrorTableDataNotFound("XChessPursuitConfig.GetChessPursuitBossTemplate", "data", TABLE_CHESSPURSUITBOSS_PATH, "id", tostring(id)) + return nil + end + + return data +end + +function XChessPursuitConfig.GetChessPursuitCardTemplate(id) + local data = ChessPursuitCardTemplate[id] + if not data then + XLog.ErrorTableDataNotFound("XChessPursuitConfig.GetChessPursuitCardTemplate", "data", TABLE_CHESSPURSUITCARD_PATH, "id", tostring(id)) + return nil + end + + return data +end + +function XChessPursuitConfig.GetChessPursuitCardEffectTemplate(id) + local data = ChessPursuitCardEffectTemplate[id] + if not data then + XLog.ErrorTableDataNotFound("XChessPursuitConfig.GetChessPursuitCardEffectTemplate", "data", TABLE_CHESSPURSUITCARDEFFECT_PATH, "id", tostring(id)) + return nil + end + + return data +end + +function XChessPursuitConfig.GetChessPursuitStepTemplate(id) + local data = ChessPursuitStepTemplate[id] + if not data then + XLog.ErrorTableDataNotFound("XChessPursuitConfig.GetChessPursuitStepTemplate", "data", TABLE_CHESSPURSUITSTEP_PATH, "id", tostring(id)) + return nil + end + + return data +end + +function XChessPursuitConfig.GetChessPursuitMapTemplate(id) + local data = ChessPursuitMapTemplate[id] + if not data then + XLog.ErrorTableDataNotFound("XChessPursuitConfig.GetChessPursuitMapTemplate", "data", TABLE_CHESSPURSUITMAP_PATH, "id", tostring(id)) + return nil + end + + return data +end + +function XChessPursuitConfig.GetChessPursuitMapCardShopTemplate(id) + local data = ChessPursuitMapCardShopTemplate[id] + if not data then + XLog.ErrorTableDataNotFound("XChessPursuitConfig.GetChessPursuitMapCardShopTemplate", "data", TABLE_CHESSPURSUITMAPCARDSHOP_PATH, "id", tostring(id)) + return nil + end + + return data +end + +function XChessPursuitConfig.GetChessPursuitMapGroupTemplate(id) + local data = ChessPursuitMapGroupTemplate[id] + if not data then + XLog.ErrorTableDataNotFound("XChessPursuitConfig.GetChessPursuitMapGroupTemplate", "data", TABLE_CHESSPURSUITMAPGROUP_PATH, "id", tostring(id)) + return nil + end + + return data +end + +function XChessPursuitConfig.GetChessPursuitMapInitFuncTemplate(id) + local data = ChessPursuitMapInitFuncTemplate[id] + if not data then + XLog.ErrorTableDataNotFound("XChessPursuitConfig.GetChessPursuitMapInitFuncTemplate", "data", TABLE_CHESSPURSUITMAPINITFUNC_PATH, "id", tostring(id)) + return nil + end + + return data +end + +function XChessPursuitConfig.GetChessPursuitTestRoleTemplate(id) + local data = ChessPursuitTestRoleTemplate[id] + if not data then + XLog.ErrorTableDataNotFound("XChessPursuitConfig.GetChessPursuitTestRoleTemplate", "data", TABLE_CHESSPURSUITTESTROLE_PATH, "id", tostring(id)) + return nil + end + + return data +end + +function XChessPursuitConfig.GetChessPursuitMapGroupRewardTemplate(id) + local data = ChessPursuitMapGroupRewardTemplate[id] + if not data then + XLog.ErrorTableDataNotFound("XChessPursuitConfig.GetChessPursuitMapGroupRewardTemplate", "data", TABLE_CHESS_PURSUIT_MAP_GROUP_REWARD_PATH, "id", tostring(id)) + return nil + end + + return data +end +--@endregion + +--@region 各表的衍生方法 + +function XChessPursuitConfig.GetChessPursuitTestRoleRoleIds(id) + local data = XChessPursuitConfig.GetChessPursuitTestRoleTemplate(id) + local roleIds = {} + for i,v in ipairs(data.RoleId) do + table.insert(roleIds, v) + end + + return roleIds +end + +function XChessPursuitConfig.GetAllChessPursuitBossTemplate() + return ChessPursuitBossTemplate +end + +function XChessPursuitConfig.GetChessPursuitMapsByGroupId(groupId) + local tl = {} + for i,v in ipairs(ChessPursuitMapTemplate) do + if v.GroupId == groupId then + table.insert(tl, v) + end + end + + return tl +end + + +function XChessPursuitConfig.GetChessPursuitMapByUiType(uiType) + local groupId = XChessPursuitConfig.GetCurrentGroupId() + local mapsCfg = XChessPursuitConfig.GetChessPursuitMapsByGroupId(groupId) + + for _,cfg in ipairs(mapsCfg) do + if uiType == cfg.Stage then + return cfg + end + end +end + + +function XChessPursuitConfig.CheckChessPursuitMapIsOpen(mapId) + local cfg = ChessPursuitMapTemplate[mapId] + for i,condition in ipairs(cfg.OpenCondition) do + if condition > 0 then + local isOpen, desc = XConditionManager.CheckCondition(condition) + return isOpen + end + end + + return true +end + +function XChessPursuitConfig.GetChessPursuitInTimeMapGroup() + local nowTime = XTime.GetServerNowTimestamp() + for i, config in pairs(ChessPursuitMapGroupTemplate) do + local beginTime = XFunctionManager.GetStartTimeByTimeId(config.TimeId) + local endTime = XFunctionManager.GetEndTimeByTimeId(config.TimeId) + if nowTime >= beginTime and nowTime < endTime then + return config + end + end +end + +function XChessPursuitConfig.GetActivityBeginTime() + local config = XChessPursuitConfig.GetChessPursuitInTimeMapGroup() + if not config then + return 0 + end + return XFunctionManager.GetStartTimeByTimeId(config.TimeId) +end + +function XChessPursuitConfig.GetActivityEndTime() + local config = XChessPursuitConfig.GetChessPursuitInTimeMapGroup() + if not config then + return 0 + end + return XFunctionManager.GetEndTimeByTimeId(config.TimeId) +end + +function XChessPursuitConfig.GetActivityFullBeginTime() + local config = ChessPursuitMapGroupTemplate[1] + if not config then + return 0 + end + return XFunctionManager.GetStartTimeByTimeId(config.TimeId) +end + +function XChessPursuitConfig.GetActivityFullEndTime() + local endTime = 0 + local endTimeTemp = 0 + for _, v in pairs(ChessPursuitMapGroupTemplate) do + endTimeTemp = XFunctionManager.GetEndTimeByTimeId(v.TimeId) + if endTimeTemp > endTime then + endTime = endTimeTemp + end + end + return endTime +end + +function XChessPursuitConfig.GetCurrentGroupId() + local cfg = XChessPursuitConfig.GetChessPursuitInTimeMapGroup() + if cfg then + return cfg.Id + end +end + +function XChessPursuitConfig.GetChessPursuitMapTeamGridList(mapId) + local cfg = XChessPursuitConfig.GetChessPursuitMapTemplate(mapId) + return cfg.TeamGrid +end + +function XChessPursuitConfig.GetTeamGridIndexByPos(id, pos) + local cfg = XChessPursuitConfig.GetChessPursuitMapTemplate(id) + for i,v in ipairs(cfg.TeamGrid) do + if pos == v then + return i + end + end +end + +function XChessPursuitConfig.GetChessPursuitStepTemplateByStep(step) + for i,v in ipairs(ChessPursuitStepTemplate) do + if v.Step == step then + return v + end + end +end + +function XChessPursuitConfig.CheckIsHaveStepCfgByCardEffectId(id) + local data = ChessPursuitStepTemplate[id] + + if data then + return true + else + return false + end +end + +function XChessPursuitConfig.IsChessPursuitMapGroupOpen(mapGroupId) + if not mapGroupId then + return false + end + local nowTime = XTime.GetServerNowTimestamp() + local config = XChessPursuitConfig.GetChessPursuitMapGroupTemplate(mapGroupId) + local beginTime = XFunctionManager.GetStartTimeByTimeId(config.TimeId) + local endTime = XFunctionManager.GetEndTimeByTimeId(config.TimeId) + if nowTime >= beginTime and nowTime < endTime then + return true + end + return false +end + +--判断当前的地图是否已经关闭 +function XChessPursuitConfig.IsTimeOutByMapId(mapId) + local cfg = XChessPursuitConfig.GetChessPursuitMapTemplate(mapId) + local groupCfg = XChessPursuitConfig.GetChessPursuitMapGroupTemplate(cfg.GroupId) + local endTime = XFunctionManager.GetEndTimeByTimeId(groupCfg.TimeId) + + local nowTime = XTime.GetServerNowTimestamp() + if nowTime >= endTime then + return true + else + return false + end +end + +--获取group处于哪个时期 +function XChessPursuitConfig.GetStageTypeByGroupId(groupId) + local mapsCfg = XChessPursuitConfig.GetChessPursuitMapsByGroupId(groupId) + + local cfg = mapsCfg[1] + if cfg.Stage == 1 then + return XChessPursuitCtrl.MAIN_UI_TYPE.STABLE + elseif cfg.Stage == 2 then + return XChessPursuitCtrl.MAIN_UI_TYPE.FIGHT_DEFAULT + elseif cfg.Stage == 3 then + return XChessPursuitCtrl.MAIN_UI_TYPE.FIGHT_HARD + end +end + +----------地图组 begin--------- +function XChessPursuitConfig.GetChessPursuitMapGroupRank(id) + local config = XChessPursuitConfig.GetChessPursuitMapGroupTemplate(id) + return config.Rank +end + +function XChessPursuitConfig.GetChessPursuitActivityNameByMapId(mapId) + local mapGroupId = XChessPursuitConfig.GetChessPursuitMapGroupId(mapId) + local config = XChessPursuitConfig.GetChessPursuitMapGroupTemplate(mapGroupId) + return config.ActivityName +end + +function XChessPursuitConfig.GetCurrentMapId() + local currGroupId = XChessPursuitConfig.GetCurrentGroupId() + local groupId, isOpen, mapId + for i = #ChessPursuitMapTemplate, 1, -1 do + groupId = ChessPursuitMapTemplate[i].GroupId + mapId = ChessPursuitMapTemplate[i].Id + isOpen = XChessPursuitConfig.CheckChessPursuitMapIsOpen(mapId) + if currGroupId == groupId and isOpen then + return mapId + end + end +end + +function XChessPursuitConfig.GetMapIdListByGroupId(groupId) + local mapIdList = {} + for _, v in ipairs(ChessPursuitMapTemplate) do + if v.GroupId == groupId then + table.insert(mapIdList, v.Id) + end + end + return mapIdList +end +----------地图组 end--------- + +----------地图 begin--------- +function XChessPursuitConfig.GetChessPursuitMapShopCardId(id) + local config = XChessPursuitConfig.GetChessPursuitMapTemplate(id) + return config.ShopCardId +end + +function XChessPursuitConfig.GetChessPursuitMapAddCoin(id) + local config = XChessPursuitConfig.GetChessPursuitMapTemplate(id) + return config.AddCoin +end + +function XChessPursuitConfig.GetChessPursuitMapCardMaxCount(id) + local config = XChessPursuitConfig.GetChessPursuitMapTemplate(id) + return config.CardMaxCount +end + +function XChessPursuitConfig.GetChessPursuitMapCoinId(id) + local config = XChessPursuitConfig.GetChessPursuitMapTemplate(id) + return config.CoinId +end + +function XChessPursuitConfig.GetChessPursuitMapGroupId(id) + local config = XChessPursuitConfig.GetChessPursuitMapTemplate(id) + return config.GroupId +end + +function XChessPursuitConfig.IsChessPursuitMapCanAutoClear(id) + local config = XChessPursuitConfig.GetChessPursuitMapTemplate(id) + return config.IsCanAutoClear == 1 +end + +function XChessPursuitConfig.GetChessPursuitMapBossId(id) + local config = XChessPursuitConfig.GetChessPursuitMapTemplate(id) + return config.BossId +end + +function XChessPursuitConfig.GetChessPursuitMapInitFuncList(id) + local config = XChessPursuitConfig.GetChessPursuitMapTemplate(id) + return config.InitFunc +end + +function XChessPursuitConfig.GetChessPursuitMapFinishAddCoin(id) + local config = XChessPursuitConfig.GetChessPursuitMapTemplate(id) + return config.FinishAddCoin +end +----------地图 end--------- + +-------商店 begin--------- +function XChessPursuitConfig.GetShopCardIdList(id) + local config = XChessPursuitConfig.GetChessPursuitMapCardShopTemplate(id) + local cardIdList = {} + for _, cardId in ipairs(config.CardId) do + if cardId > 0 then + table.insert(cardIdList, cardId) + end + end + return cardIdList +end +-------商店 end----------- + +-------卡牌 begin---------- +function XChessPursuitConfig.GetCardName(id) + local config = XChessPursuitConfig.GetChessPursuitCardTemplate(id) + return config.Name +end + +function XChessPursuitConfig.GetCardDescribe(id) + local config = XChessPursuitConfig.GetChessPursuitCardTemplate(id) + return string.gsub(config.Describe, "\\n", "\n") +end + +function XChessPursuitConfig.GetCardIcon(id) + local config = XChessPursuitConfig.GetChessPursuitCardTemplate(id) + return config.Icon +end + +function XChessPursuitConfig.GetCardQualityIcon(id) + local config = XChessPursuitConfig.GetChessPursuitCardTemplate(id) + return config.QualityIcon +end + +function XChessPursuitConfig.GetShopBgQualityIcon(id) + local config = XChessPursuitConfig.GetChessPursuitCardTemplate(id) + return config.ShopBgQualityIcon +end + +function XChessPursuitConfig.GetCardSubCoin(id) + local config = XChessPursuitConfig.GetChessPursuitCardTemplate(id) + return config.SubCoin +end + +function XChessPursuitConfig.GetCardQuality(id) + local config = XChessPursuitConfig.GetChessPursuitCardTemplate(id) + return config.Quality +end + +function XChessPursuitConfig.GetCardEffect(id) + local config = XChessPursuitConfig.GetChessPursuitCardTemplate(id) + return config.Effect +end + +function XChessPursuitConfig.GetCardTipsQualityIconBg(id) + local config = XChessPursuitConfig.GetChessPursuitCardTemplate(id) + return config.TipsQualityIconBg +end +-------卡牌 end---------- + +-------奖励 begin--------- +function XChessPursuitConfig.GetMapGroupRewardByGroupIdToIdDic(groupId) + return MapGroupRewardByGroupIdToIdDic[groupId] +end + +function XChessPursuitConfig.GetMapGroupRewardStartRange(id) + local config = XChessPursuitConfig.GetChessPursuitMapGroupRewardTemplate(id) + return config.StartRange +end + +function XChessPursuitConfig.GetMapGroupRewardEndRange(id) + local config = XChessPursuitConfig.GetChessPursuitMapGroupRewardTemplate(id) + return config.EndRange +end + +function XChessPursuitConfig.GetMapGroupRewardRewardShowId(id) + local config = XChessPursuitConfig.GetChessPursuitMapGroupRewardTemplate(id) + return config.RewardShowId +end +-------奖励 end----------- + +-------Boss begin--------- +function XChessPursuitConfig.GetChessPursuitBossStageIdByMapId(mapId) + local bossId = XChessPursuitConfig.GetChessPursuitMapBossId(mapId) + local config = XChessPursuitConfig.GetChessPursuitBossTemplate(bossId) + return config.StageId +end + +function XChessPursuitConfig.GetChessPursuitBossHeadIconByMapId(mapId) + local bossId = XChessPursuitConfig.GetChessPursuitMapBossId(mapId) + local config = XChessPursuitConfig.GetChessPursuitBossTemplate(bossId) + return config.HeadIcon +end +-------Boss end----------- + +------ChessPursuitMapInitFunc begin------- +function XChessPursuitConfig.GetMapInitFuncMapId(id) + local config = XChessPursuitConfig.GetChessPursuitMapInitFuncTemplate(id) + return config.Param[1] +end + +function XChessPursuitConfig.GetMapInitFuncType(id) + local config = XChessPursuitConfig.GetChessPursuitMapInitFuncTemplate(id) + return config.Type +end + +function XChessPursuitConfig.IsMapInitFuncAddCoinType(id) + local initFuncType = XChessPursuitConfig.GetMapInitFuncType(id) + return initFuncType == XChessPursuitConfig.InitFuncType.InitAddCoin +end +------ChessPursuitMapInitFunc end------- + +function XChessPursuitConfig.GetBabelRankIcon(num) + return CS.XGame.ClientConfig:GetString("BabelTowerRankIcon" .. num) +end +--@endregion \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XChristmasTreeConfig.lua b/Resources/Scripts/XConfig/XChristmasTreeConfig.lua new file mode 100644 index 00000000..5e9d4ca4 --- /dev/null +++ b/Resources/Scripts/XConfig/XChristmasTreeConfig.lua @@ -0,0 +1,91 @@ +local tableInsert = table.insert + +XChristmasTreeConfig = XChristmasTreeConfig or {} + +local CHRISTMAS_TREE_ACTIVITY_PATH = "Share/MiniActivity/ChristmasTree/ChristmasTree.tab" +local CHRISTMAS_TREE_ACTIVITY_ORNAMENT_PATH = "Share/MiniActivity/ChristmasTree/ChristmasTreeOrnaments.tab" +local CHRISTMAS_TREE_ACTIVITY_PART_PATH = "Share/MiniActivity/ChristmasTree/ChristmasTreePart.tab" + +local ActivityTemplates = {} +local ChristmasTreeOrnament = {} +local ChristmasTreeOrnamentGroup = {} +local ChristmasTreePart = {} +local ChristmasTreePartGroup = {} +local OrnamentAttrCount = {} +local PartCount, PartGrpCount + +function XChristmasTreeConfig.Init() + ActivityTemplates = XTableManager.ReadByIntKey(CHRISTMAS_TREE_ACTIVITY_PATH, XTable.XTableChristmasTreeActivity, "Id") + + ChristmasTreePart = XTableManager.ReadByIntKey(CHRISTMAS_TREE_ACTIVITY_PART_PATH, XTable.XTableChristmasTreeActivityPart, "Id") + PartCount, PartGrpCount = 0, 0 + for _, item in ipairs(ChristmasTreePart) do + if not ChristmasTreePartGroup[item.GroupId] then + PartGrpCount = PartGrpCount + 1 + ChristmasTreePartGroup[item.GroupId] = {} + end + tableInsert(ChristmasTreePartGroup[item.GroupId], item) + PartCount = PartCount + 1 + end + + ChristmasTreeOrnament = XTableManager.ReadByIntKey(CHRISTMAS_TREE_ACTIVITY_ORNAMENT_PATH, XTable.XTableChristmasTreeActivityOrnament, "Id") + for _, item in ipairs(ChristmasTreeOrnament) do + OrnamentAttrCount[item.Id] = 0 + for _, value in ipairs(item.Attr) do + OrnamentAttrCount[item.Id] = OrnamentAttrCount[item.Id] + value + end + for _, partId in ipairs(item.PartId) do + local groupId = XChristmasTreeConfig.GetGrpIdByTreePart(partId) + if not ChristmasTreeOrnamentGroup[groupId] then + ChristmasTreeOrnamentGroup[groupId] = {} + end + if not ChristmasTreeOrnamentGroup[groupId][item.Id] then + ChristmasTreeOrnamentGroup[groupId][item.Id] = item + end + end + end +end + +function XChristmasTreeConfig.GetActivityTemplates() + return ActivityTemplates +end + +function XChristmasTreeConfig.GetActivityTemplateById(Id) + if not ActivityTemplates then + return nil + end + + return ActivityTemplates[Id] +end + +function XChristmasTreeConfig.GetOrnamentCfg() + return ChristmasTreeOrnament +end + +function XChristmasTreeConfig.GetOrnamentById(id) + return ChristmasTreeOrnament[id] +end + +function XChristmasTreeConfig.GetOrnamentByGroup(grpId) + return ChristmasTreeOrnamentGroup[grpId] +end + +function XChristmasTreeConfig.GetTreePartCount() + return PartCount, PartGrpCount +end + +function XChristmasTreeConfig.GetAttrCount(id) + return OrnamentAttrCount[id] +end + +function XChristmasTreeConfig.GetTreePartById(id) + return ChristmasTreePart[id] +end + +function XChristmasTreeConfig.GetGrpIdByTreePart(id) + return ChristmasTreePart[id].GroupId +end + +function XChristmasTreeConfig.GetTreePartByGroup(grpId) + return ChristmasTreePartGroup[grpId] +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XClickClearGameConfigs.lua b/Resources/Scripts/XConfig/XClickClearGameConfigs.lua new file mode 100644 index 00000000..867c4c07 --- /dev/null +++ b/Resources/Scripts/XConfig/XClickClearGameConfigs.lua @@ -0,0 +1,81 @@ +local tableInsert = table.insert + +local TABLE_CLICKCLEAR_GAME_PATH = "Share/ClickClearGame/ClickClearGame.tab" +local TABLE_CLICKCLEAR_GAME_STAGE_PATH = "Share/ClickClearGame/ClickClearGameStage.tab" +local TABLE_CLICKCLEAR_PAGE_PATH = "Client/ClickClearGame/ClickClearPage.tab" +local TABLE_CLICKCLEAR_ROW_PATH = "Client/ClickClearGame/ClickClearRow.tab" +local TABLE_CLICKCLEAR_HEAD_PATH = "Client/ClickClearGame/ClickClearHead.tab" + +local GameTemplates = {} +local GameStageTemplates = {} +local PageTemplates = {} +local RowTemplates = {} +local HeadTemplates = {} +local HeadTypeList = {} + +XClickClearGameConfigs = XClickClearGameConfigs or {} + +function XClickClearGameConfigs.Init() + GameTemplates = XTableManager.ReadByIntKey(TABLE_CLICKCLEAR_GAME_PATH, XTable.XTableClickClearGame, "Id") + GameStageTemplates = XTableManager.ReadByIntKey(TABLE_CLICKCLEAR_GAME_STAGE_PATH, XTable.XTableClickClearGameStage, "Id") + PageTemplates = XTableManager.ReadByIntKey(TABLE_CLICKCLEAR_PAGE_PATH, XTable.XTableClickClearPage, "Id") + RowTemplates = XTableManager.ReadByIntKey(TABLE_CLICKCLEAR_ROW_PATH, XTable.XTableClickClearRow, "Id") + HeadTemplates = XTableManager.ReadByIntKey(TABLE_CLICKCLEAR_HEAD_PATH, XTable.XTableClickClearHead, "Id") + + for i,v in pairs(HeadTemplates) do + local type = v.Type + if not HeadTypeList[type] then + HeadTypeList[type] = {} + end + + tableInsert(HeadTypeList[type], i) + end +end + +function XClickClearGameConfigs.GetGameTemplates() + return GameTemplates +end + +function XClickClearGameConfigs.GetGameStageTemplates() + return GameStageTemplates +end + +function XClickClearGameConfigs.GetGameStageTemplateById(id) + if not GameStageTemplates or #GameStageTemplates <= 0 then + return nil + end + + return GameStageTemplates[id] +end + +function XClickClearGameConfigs.GetPageTemplateById(id) + if not PageTemplates or #PageTemplates <= 0 then + return nil + end + + return PageTemplates[id] +end + +function XClickClearGameConfigs.GetRowTemplateById(id) + if not RowTemplates or #RowTemplates <= 0 then + return nil + end + + return RowTemplates[id] +end + +function XClickClearGameConfigs.GetHeadTemplateById(id) + if not HeadTemplates or #HeadTemplates <= 0 then + return nil + end + + return HeadTemplates[id] +end + +function XClickClearGameConfigs.GetHeadTypeListByType(type) + if not HeadTypeList or #HeadTypeList <= 0 or not HeadTypeList[type] then + return nil + end + + return HeadTypeList[type] +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XCollectionWallConfigs.lua b/Resources/Scripts/XConfig/XCollectionWallConfigs.lua new file mode 100644 index 00000000..89f1e773 --- /dev/null +++ b/Resources/Scripts/XConfig/XCollectionWallConfigs.lua @@ -0,0 +1,236 @@ +XCollectionWallConfigs = XCollectionWallConfigs or {} + +local TABLE_COLLECTION_WALL = "Share/ScoreTitle/CollectionWall.tab" +local TABLE_COLLECTION_WALL_DECORATION = "Share/ScoreTitle/CollectionWallDecoration.tab" +local TABLE_COLLECTION_SIZE = "Client/CollectionWall/CollectionSize.tab" + +-- 装饰品种类 +XCollectionWallConfigs.EnumDecorationType = { + Background = 1, -- 背景 + Pedestal = 2, -- 底座 +} + +-- 收藏品墙的状态 +XCollectionWallConfigs.EnumWallState = { + Lock = 1, -- 未解锁 + None = 2, -- 空白 + Normal = 3, -- 正常 +} + +-- 收藏品墙格子的使用的种类 +XCollectionWallConfigs.EnumWallGridOpenType = { + Overview = 1, -- 管理界面 + Setting = 2, -- 设置界面 +} + +-- 收藏品墙装饰品的解锁类型 +XCollectionWallConfigs.EnumDecorationUnlockType = { + Condition = 1, -- 条件解锁 + Reward = 2, -- 奖励解锁 +} + +-- 编辑模式选择的种类 +XCollectionWallConfigs.EnumSelectType = { + BACKGROUND = 1, -- 墙面 + PEDESTAL = 2, -- 底座 + LITTL = 3, -- 模型小 + MIDDLE = 4, -- 模型中 + BIG = 5, -- 模型大 +} + +-- 墙面单元格尺寸为90*90 +XCollectionWallConfigs.CellSize = 90 + +local CollectionWallCfg = {} +local CollectionWallDecorationCfg = {} +local CollectionSizeCfg = {} + +function XCollectionWallConfigs.Init() + CollectionWallCfg = XTableManager.ReadByIntKey(TABLE_COLLECTION_WALL, XTable.XTableCollectionWall, "Id") + CollectionWallDecorationCfg = XTableManager.ReadByIntKey(TABLE_COLLECTION_WALL_DECORATION, XTable.XTableCollectionWallDecoration, "Id") + CollectionSizeCfg = XTableManager.ReadByIntKey(TABLE_COLLECTION_SIZE, XTable.XTableCollectionSize, "Id") +end + + +------------------------------------------------------------------ CollectionWall.tab数据读取 ------------------------------------------------------- + +--- +--- 根据'id'获取收藏品墙的配置 +--- 建议使用XCollectionWall.lua的接口来获取需要的数据 +---@param id number +---@return table +function XCollectionWallConfigs.GetCollectionWallCfg(id) + local config = CollectionWallCfg[id] + + if not config then + XLog.ErrorTableDataNotFound("XCollectionWallConfigs.GetCollectionWallCfg", + "收藏品墙配置", TABLE_COLLECTION_WALL, "Id", tostring(id)) + return {} + end + + return config +end + +--- +--- 获取所有收藏品墙的Id数组 +---@return table +function XCollectionWallConfigs.GetCollectionWallIdList() + local idList = {} + for id, _ in pairs(CollectionWallCfg) do + table.insert(idList, id) + end + return idList +end + + +------------------------------------------------------------------ CollectionWallDecoration.tab数据读取 ------------------------------------------------------- + +--- +--- 根据'id'获取收藏品墙饰品配置 +---@param id number +---@return table +local function GetColDecCfgList(id) + local config = CollectionWallDecorationCfg[id] + + if not config then + XLog.ErrorTableDataNotFound("XCollectionWallConfigs.GetColDecCfgList", + "收藏品墙饰品配置", TABLE_COLLECTION_WALL_DECORATION, "Id", tostring(id)) + return {} + end + + return config +end + +--- +--- 获取全部‘type’种类的收藏品墙饰品配置数组 +---@param type number +---@return table +function XCollectionWallConfigs.GetColDecCfgListByType(type) + local result = {} + + for _,data in pairs(CollectionWallDecorationCfg) do + if data.Type == type then + table.insert(result,data) + end + end + + return result +end + +--- +--- 根据'id'获取收藏品墙饰品的种类 +---@param id number +---@return number +function XCollectionWallConfigs.GetColDecType(id) + local cfg = GetColDecCfgList(id) + return cfg.Type +end + +--- +--- 根据'id'获取收藏品墙饰品的名称 +---@param id number +---@return string +function XCollectionWallConfigs.GetColDecName(id) + local cfg = GetColDecCfgList(id) + return cfg.Name +end + +--- +--- 根据'id'获取收藏品墙饰品的图标 +---@param id number +---@return string +function XCollectionWallConfigs.GetColDecIcon(id) + local cfg = GetColDecCfgList(id) + return cfg.Icon +end + +--- +--- 根据'id'获取收藏品墙饰品的路径 +---@param id number +---@return string +function XCollectionWallConfigs.GetColDecPath(id) + local cfg = GetColDecCfgList(id) + return cfg.Path +end + +--- +--- 根据'id'获取收藏品墙饰品的解锁类型 +---@param id number +---@return number +function XCollectionWallConfigs.GetColDecUnlockType(id) + local cfg = GetColDecCfgList(id) + return cfg.UnlockType +end + +--- +--- 根据'id'获取收藏品墙饰品的解锁条件 +---@param id number +---@return number +function XCollectionWallConfigs.GetColDecCondition(id) + local cfg = GetColDecCfgList(id) + return cfg.Condition +end + +--- +--- 根据'id'获取收藏品墙饰品的解锁描述 +---@param id number +---@return string +function XCollectionWallConfigs.GetColDecLockDesc(id) + local cfg = GetColDecCfgList(id) + return cfg.LockDesc +end + +--- +--- 根据'id'获取收藏品墙饰品的排序值 +---@param id number +---@return string +function XCollectionWallConfigs.GetColDecRank(id) + local cfg = GetColDecCfgList(id) + return cfg.Rank +end + + +------------------------------------------------------------------ CollectionSize.tab数据读取 ------------------------------------------------------- + +--- +--- 根据'id'获取收藏品尺寸数据 +---@param id number +---@return number +local function GetCollectionSizeCfg(id) + local config = CollectionSizeCfg[id] + + if not config then + XLog.ErrorTableDataNotFound("XCollectionWallConfigs.GetColDecCfgList", + "收藏品尺寸配置", TABLE_COLLECTION_SIZE, "Id", tostring(id)) + return {} + end + + return config +end + +--- +--- 根据'id'获取收藏品尺寸 +---@param id number +---@return number +function XCollectionWallConfigs.GetCollectionSize(id) + local cfg = GetCollectionSizeCfg(id) + return cfg.Size +end + +--- +--- 根据'id'获取收藏品缩放系数 +---@param id number +---@return number +function XCollectionWallConfigs.GetCollectionScale(id) + local cfg = GetCollectionSizeCfg(id) + return cfg.Scale +end + +--- +--- 根据'id'获取收藏品占用的格子 +---@param id number +---@return number +function XCollectionWallConfigs.GetCollectionGridNum(id) + local cfg = GetCollectionSizeCfg(id) + return cfg.GridNum +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XComeAcrossConfig.lua b/Resources/Scripts/XConfig/XComeAcrossConfig.lua new file mode 100644 index 00000000..03f50049 --- /dev/null +++ b/Resources/Scripts/XConfig/XComeAcrossConfig.lua @@ -0,0 +1,184 @@ +XComeAcrossConfig = XComeAcrossConfig or {} + +ComeAcrossGameType = { + GAME_CLICK = 1, + GAME_ELIMINATE = 2, +} + +local TABLE_COMEACROSS = "Share/Trust/TrustGameConfig.tab"; +local TABLE_COMEACROSS_CLICK_POOL = "Share/Trust/TrustGameClickPool.tab"; +local TABLE_COMEACROSS_ELIMINATE_POOL = "Share/Trust/TrustGameEliminatePool.tab"; +local TABLE_COMEACROSS_REWARD = "Share/Trust/TrustGameReward.tab"; +local TABLE_COMEACROSS_POSITION = "Share/Trust/TrustGamePosition.tab"; +local TABLE_COMEACROSS_GRID = "Share/Trust/TrustGameGrid.tab"; +local TABLE_COMEACROSS_GAMETYPE = "Share/Trust/TrustGameTypeConfig.tab"; + +local ComeAcrossConfig = {} +local ComeAcrossClickPoolConfig = {} +local ComeAcrossEliminatePoolConfig = {} +local ComeAcrossRewardConfig = {} +local ComeAcrossPositionConfig = {} +local ComeAcrossGridConfig = {} +local ComeAcrossGameTypeConfig = {} + +local GameTypePools = {} + +function XComeAcrossConfig.Init() + ComeAcrossConfig = XTableManager.ReadByIntKey(TABLE_COMEACROSS, XTable.XTableTrustGameConfig, "Id") + ComeAcrossRewardConfig = XTableManager.ReadByIntKey(TABLE_COMEACROSS_REWARD, XTable.XTableTrustGameReward, "Id") + ComeAcrossClickPoolConfig = XTableManager.ReadByIntKey(TABLE_COMEACROSS_CLICK_POOL, XTable.XTableTrustGameClickPool, "Id") + ComeAcrossEliminatePoolConfig = XTableManager.ReadByIntKey(TABLE_COMEACROSS_ELIMINATE_POOL, XTable.XTableTrustGameEliminatePool, "Id") + ComeAcrossPositionConfig = XTableManager.ReadByIntKey(TABLE_COMEACROSS_POSITION, XTable.XTableTrustGamePosition, "Id") + ComeAcrossGridConfig = XTableManager.ReadByIntKey(TABLE_COMEACROSS_GRID, XTable.XTableTrustGameGrid, "Id") + ComeAcrossGameTypeConfig = XTableManager.ReadByIntKey(TABLE_COMEACROSS_GAMETYPE, XTable.XTableTrustGameTypeConfig, "Id") + + GameTypePools[ComeAcrossGameType.GAME_CLICK] = ComeAcrossClickPoolConfig + GameTypePools[ComeAcrossGameType.GAME_ELIMINATE] = ComeAcrossEliminatePoolConfig +end + +--获取小游戏关卡表 +function XComeAcrossConfig.GetComeAcrossConfig() + return ComeAcrossConfig +end + +--获取小游戏关卡 +function XComeAcrossConfig.GetComeAcrossConfigById(id) + if not ComeAcrossConfig then + return + end + + return ComeAcrossConfig[id] +end + +--获取小游戏内容 +function XComeAcrossConfig.GetComeAcrossTypeConfigById(id) + if not ComeAcrossGameTypeConfig then + return + end + + return ComeAcrossGameTypeConfig[id] +end + +--获取小游戏位置 +function XComeAcrossConfig.GetComeAcrossPositionConfigById(id) + if not ComeAcrossPositionConfig then + return + end + + return ComeAcrossPositionConfig[id] +end + + +--获得奖励 +function XComeAcrossConfig.GetComeAcrossRewardConfigById(id) + if not ComeAcrossRewardConfig then + return + end + + return ComeAcrossRewardConfig[id] +end + +--根据类型获取小游戏消除元素 +function XComeAcrossConfig.GetComeAcrossGridConfigById(gridType) + if not ComeAcrossGridConfig then + return + end + + for _,v in ipairs(ComeAcrossGridConfig) do + if v.Type == gridType then + return v + end + end + + return nil +end + +--随机获取N个小游戏 +function XComeAcrossConfig.RandomNumberGetGameConfig(count) + if not ComeAcrossConfig then + return + end + + local length = #ComeAcrossConfig + if length <= count then + return ComeAcrossConfig + end + + local temp = {} + + for _, v in ipairs(ComeAcrossConfig) do + table.insert(temp, v) + end + + local games = {} + + for i = 1, count, 1 do + local sum = #temp + local rand = math.random(1, sum) + local gameTable = {} + gameTable.GameConfig = table.remove(temp, rand) + gameTable.TypeOfGames = XComeAcrossConfig.RandomNumberGetGameConfigFormPoolByType(gameTable.GameConfig.Count, gameTable.GameConfig.Type,gameTable.GameConfig.Difficult) + gameTable.Position = ComeAcrossPositionConfig[i] + table.insert(games, gameTable) + end + + return games +end + +--从游戏类型池随出特定类型和数量的游戏关卡 +function XComeAcrossConfig.RandomNumberGetGameConfigFormPoolByType(count, gameType,difficult) + local pools = GameTypePools[gameType] + + if not pools or #pools <= count then + return pools + end + + --筛选难度 + local pool = {} + for _,v in ipairs(pools) do + if v.Difficult == difficult then + table.insert(pool,v) + end + end + + if not pool or #pool <= count then + return pool + end + + --获取权重总和 + local sum = 0 + for _, v in ipairs(pool) do + sum = sum + v.Weight + end + + --设置随机数种子 + math.randomseed(os.time()) + + --随机数加上权重,越大的权重,数值越大 + local weightList = {} + for i, v in ipairs(pool) do + local rand = math.random(0, sum) + local seed = {} + seed.Index = i + seed.Weight = rand + v.Weight + table.insert(weightList, seed) + end + + --排序 + table.sort(weightList, function(x, y) + return x.Weight > y.Weight + end) + + --返回最大的权重值的前几个 + local typeOfGames = {} + + for i = 1, count, 1 do + local index = weightList[i].Index + if pool[index] then + table.insert(typeOfGames,pool[index] ) + end + end + + return typeOfGames +end + diff --git a/Resources/Scripts/XConfig/XCommunicationConfig.lua b/Resources/Scripts/XConfig/XCommunicationConfig.lua new file mode 100644 index 00000000..cb26f853 --- /dev/null +++ b/Resources/Scripts/XConfig/XCommunicationConfig.lua @@ -0,0 +1,97 @@ +XCommunicationConfig = XCommunicationConfig or {} + +local TABLE_FUNCTION_COMMUNICATION_PATH = "Share/Functional/FunctionalCommunication.tab" +local TABLE_FUNCTION_FESTIVAL_COMMUNICATION_PATH = "Share/Functional/FunctionalFestivalCommunication.tab" +local TABLE_FUNCTION_INITIATIVE_COMMUNICATION_PATH = "Share/Functional/FunctionalInitiativeCommunication.tab" +local TABLE_FUNCTION_INITIATIVE_CONTENTS_PATH = "Client/Functional/FunctionalContents.tab" + +local FunctionCommunicationConfig = {} +local FunctionFestivalCommunicationConfig = {} +local FunctionInitiativeCommunicationConfig = {} +local FunctionFestivalCommunicationDic = {} + +local FunctionalContentsConfig = {} +local FunctionalContentsGroupIdDic = {} + +XCommunicationConfig.ComminictionType = { + NormalType = 1, + OptionType = 2, +} + +function XCommunicationConfig.Init() + FunctionCommunicationConfig = XTableManager.ReadByIntKey(TABLE_FUNCTION_COMMUNICATION_PATH, XTable.XTableFunctionalCommunication, "Id") + FunctionFestivalCommunicationConfig = XTableManager.ReadByIntKey(TABLE_FUNCTION_FESTIVAL_COMMUNICATION_PATH, XTable.XTableFunctionalFestivalCommunication, "Id") + FunctionInitiativeCommunicationConfig = XTableManager.ReadByIntKey(TABLE_FUNCTION_INITIATIVE_COMMUNICATION_PATH, XTable.XTableFunctionalCommunication, "Id") + FunctionalContentsConfig = XTableManager.ReadByIntKey(TABLE_FUNCTION_INITIATIVE_CONTENTS_PATH, XTable.XTableFunctionalContents, "Id") + XCommunicationConfig.SetFunctionFestivalCommunicationDic() + XCommunicationConfig.InitFunctionalContentsGroup() +end + +function XCommunicationConfig.GetFunctionCommunicationConfig() + return FunctionCommunicationConfig +end + +function XCommunicationConfig.GetFunctionFestivalCommunicationConfig() + return FunctionFestivalCommunicationConfig +end + +function XCommunicationConfig.GetFunctionFestivalCommunicationDicByType(type) + return FunctionFestivalCommunicationDic[type] +end + +function XCommunicationConfig.GetFunctionInitiativeCommunicationConfig() + return FunctionInitiativeCommunicationConfig +end + +function XCommunicationConfig.GetFunctionInitiativeCommunicationConfigById(commuId) + return FunctionInitiativeCommunicationConfig[commuId] +end + +function XCommunicationConfig.SetFunctionFestivalCommunicationDic() + for _, communication in pairs(FunctionFestivalCommunicationConfig) do + local functionFestivalCommunicationType = FunctionFestivalCommunicationDic[communication.Type] + if not functionFestivalCommunicationType then + functionFestivalCommunicationType = {} + FunctionFestivalCommunicationDic[communication.Type] = functionFestivalCommunicationType + end + table.insert(functionFestivalCommunicationType, communication) + end +end + +function XCommunicationConfig.InitFunctionalContentsGroup() + for _, communication in pairs(FunctionalContentsConfig) do + local functionalComList = FunctionalContentsGroupIdDic[communication.GroupId] + if not functionalComList then + functionalComList = {} + FunctionalContentsGroupIdDic[communication.GroupId] = functionalComList + end + + if communication.Type == XCommunicationConfig.ComminictionType.NormalType and #communication.OptionTitle > 0 then + XLog.Error("XCommunicationConfig.InitFunctionalContentsGroup".."配置表项"..TABLE_FUNCTION_INITIATIVE_CONTENTS_PATH.."不应该配置按钮,ID:"..tostring(communication.Id)) + end + + table.insert(functionalComList, communication) + end + for _, communicationList in pairs(FunctionalContentsGroupIdDic) do + table.sort(communicationList,function(a, b) + return a.Id < b.Id + end) + end +end + +function XCommunicationConfig.GetFunctionalContentsInfoById(id) + if not FunctionalContentsConfig[id] then + XLog.ErrorTableDataNotFound("XCommunicationConfig.GetFunctionalContentsInfoById", "配置表项", TABLE_FUNCTION_INITIATIVE_CONTENTS_PATH, "Id", tostring(id)) + end + return FunctionalContentsConfig[id] +end + +function XCommunicationConfig.GetFunctionalContentsGroupFirstInfoByGroupId(groupId) + if not FunctionalContentsGroupIdDic[groupId] or not FunctionalContentsGroupIdDic[groupId][1] then + XLog.ErrorTableDataNotFound("XCommunicationConfig.GetFunctionalContentsGroupListByGroupId", "配置表项", TABLE_FUNCTION_INITIATIVE_CONTENTS_PATH, "GroupId", tostring(groupId)) + end + return FunctionalContentsGroupIdDic[groupId][1] +end + + + diff --git a/Resources/Scripts/XConfig/XComposeGameConfig.lua b/Resources/Scripts/XConfig/XComposeGameConfig.lua new file mode 100644 index 00000000..d71a0b87 --- /dev/null +++ b/Resources/Scripts/XConfig/XComposeGameConfig.lua @@ -0,0 +1,145 @@ +-- 组合小游戏Config +XComposeGameConfig = XComposeGameConfig or {} + +-- ===================表地址==================== +local SHARE_TABLE_PATH = "Share/MiniActivity/ComposeGame/" +local CLIENT_TABLE_PATH = "Client/MiniActivity/ComposeGame/" + +local TABLE_GAMECONFIGS = SHARE_TABLE_PATH .. "ComposeGame.tab" +local TABLE_GOODS = SHARE_TABLE_PATH .. "ComposeGoods.tab" +local TABLE_CLIENT_CONFIG = CLIENT_TABLE_PATH .. "ComposeClientConfig.tab" +--================================================= +-- ===================原表数据=================== +local GameConfigs = {} +local GoodsConfigs = {} +local ClientConfig = {} +--================================================= + +-- ================构建搜索用字典================ +local GameId2GoodsDic = {} +local GameId2ClientConfigDic = {} +--================================================= + +--==================初始化方法====================== +--=============== +--构建活动ID<-->活动道具列表字典 +--=============== +local CreateGameId2GoodsDic = function() + for _, good in pairs(GoodsConfigs) do + if not GameId2GoodsDic[good.ActId] then GameId2GoodsDic[good.ActId] = {} end + table.insert(GameId2GoodsDic[good.ActId], good) + end +end +--=============== +--构建活动ID<-->活动客户端配置字典 +--=============== +local CreateGameId2ClientConfigDic = function() + for id, config in pairs(ClientConfig) do + -- 通用配置不进入构建字典 + if id > 0 then GameId2ClientConfigDic[config.ActId] = config end + end +end +--=============== +--初始化表配置 +--=============== +function XComposeGameConfig.Init() + GameConfigs = XTableManager.ReadByIntKey(TABLE_GAMECONFIGS, XTable.XTableComposeGame, "Id") + GoodsConfigs = XTableManager.ReadByIntKey(TABLE_GOODS, XTable.XTableComposeGoods, "Id") + ClientConfig = XTableManager.ReadByIntKey(TABLE_CLIENT_CONFIG, XTable.XTableComposeClientConfig, "Id") + CreateGameId2GoodsDic() + CreateGameId2ClientConfigDic() +end +--================================================== +--==================读表方法====================== + +--=============== +--获取所有组合小游戏活动基础配置 +--=============== +function XComposeGameConfig.GetGameConfigs() + return GameConfigs +end +--=============== +--根据Id获取组合小游戏活动基础配置 +--@param gameId:活动ID +--=============== +function XComposeGameConfig.GetGameConfigsByGameId(gameId) + local config = GameConfigs[gameId] + if not config then + XLog.ErrorTableDataNotFound( + "XComposeGameConfig.GetGameConfigsByGameId", + "组合小游戏活动基础配置数据", + TABLE_GAMECONFIGS, + "Id", + tostring(gameId) + ) + return nil + end + return config +end +--=============== +--获取所有组合小游戏物品配置 +--=============== +function XComposeGameConfig.GetGoodsConfigs() + return GoodsConfigs +end +--=============== +--根据Id获取组合小游戏物品配置 +--@param itemId:物品ID +--=============== +function XComposeGameConfig.GetItemConfigByItemId(itemId) + local config = GoodsConfigs[itemId] + if not config then + XLog.ErrorTableDataNotFound( + "XComposeGameConfig.GetItemConfigByItemId", + "组合小游戏物品配置数据", + TABLE_GOODS, + "Id", + tostring(itemId) + ) + return nil + end + return config +end +--=============== +--根据活动Id获取活动对应的所有物品配置 +--@param gameId:活动ID +--=============== +function XComposeGameConfig.GetItemListConfigByGameId(gameId) + local itemCfgsList = GameId2GoodsDic[gameId] + if not itemCfgsList then + XLog.ErrorTableDataNotFound( + "XComposeGameConfig.GetItemListConfigByGameId", + "组合小游戏物品配置数据", + TABLE_GOODS, + "ActId", + tostring(gameId) + ) + return nil + end + return itemCfgsList +end +--=============== +--根据活动ID获取组合小游戏客户端配置(对个别组合小游戏的客户端配置) +--@param gameId:活动ID +--=============== +function XComposeGameConfig.GetClientConfigByGameId(gameId) + local config = GameId2ClientConfigDic[gameId] + if not config then + XLog.ErrorTableDataNotFound( + "XComposeGameConfig.GetClientConfigByGameId", + "组合小游戏活动客户端配置", + TABLE_CLIENT_CONFIG, + "ActId", + tostring(gameId) + ) + return nil + end + return config +end +--=============== +--获取组合小游戏默认客户端配置(全组合小游戏通用配置) +--=============== +function XComposeGameConfig.GetDefaultConfig() + return ClientConfig[0] +end +--================================================== \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XComposeMiniGameConfig.lua b/Resources/Scripts/XConfig/XComposeMiniGameConfig.lua new file mode 100644 index 00000000..3f2831ab --- /dev/null +++ b/Resources/Scripts/XConfig/XComposeMiniGameConfig.lua @@ -0,0 +1,23 @@ +XComposeMiniGameConfig = XComposeMiniGameConfig or {} + +-- ===================表地址 +local SHARE_TABLE_PATH = "Share/MiniActivity/ComposeGame/" +local CLIENT_TABLE_PATH = "Client/MiniActivity/ComposeGame/" + +local TABLE_COMPOSE_GAME = SHARE_TABLE_PATH .. "ComposeGame.tab" +local TABLE_COMPOSE_GOODS = SHARE_TABLE_PATH .. "ComposeGoods.tab" + +-- ===================原表数据 +local ComposeGameConfig = {} +local ComposeGoodsConfig = {} + +--================ +--初始化Config +--================ +function XComposeMiniGameConfig.Init() + XComposeMiniGameConfig.InitConfig() +end + +function XComposeMiniGameConfig.InitConfig() + +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XConfigCenter.lua b/Resources/Scripts/XConfig/XConfigCenter.lua new file mode 100644 index 00000000..2299d6c4 --- /dev/null +++ b/Resources/Scripts/XConfig/XConfigCenter.lua @@ -0,0 +1,175 @@ +XConfigCenter = XConfigCenter or {} + +local IsWindowsEditor = XMain.IsWindowsEditor +local ConfigCenterProfiler = nil + +local function InitConfig(config, key) + if IsWindowsEditor then + local profiler = ConfigCenterProfiler:CreateChild(key) + profiler:Start() + -- XPerformance.RecordLuaMemData(key, function() + config.Init() + -- end) + profiler:Stop() + else + config.Init() + end +end + +function XConfigCenter.Init() + ConfigCenterProfiler = XGame.Profiler:CreateChild("XConfigCenter") + ConfigCenterProfiler:Start() + + InitConfig(XDlcConfig,"XDlcConfig") + + -- 新拆分出的Config + InitConfig(XAssistConfig, "XAssistConfig") + InitConfig(XAutoFightConfig, "XAutoFightConfig") + InitConfig(XFubenBossOnlineConfig, "XFubenBossOnlineConfig") + InitConfig(XFubenUrgentEventConfig, "XFubenUrgentEventConfig") + InitConfig(XLoadingConfig, "XLoadingConfig") + InitConfig(XTeamConfig, "XTeamConfig") + InitConfig(XFunctionConfig, "XFunctionConfig") + + InitConfig(XAttribConfigs, "XAttribConfigs") + InitConfig(XUiConfigs, "XUiConfigs") + InitConfig(XGuideConfig, "XGuideConfig") + InitConfig(XItemConfigs, "XItemConfigs") + InitConfig(XCharacterConfigs, "XCharacterConfigs") + InitConfig(XSignBoardConfigs, "XSignBoardConfigs") + InitConfig(XEquipConfig, "XEquipConfig") + InitConfig(XComeAcrossConfig, "XComeAcrossConfig") + InitConfig(XFavorabilityConfigs, "XFavorabilityConfigs") + InitConfig(XArenaConfigs, "XArenaConfigs") + InitConfig(XArenaOnlineConfigs, "XArenaOnlineConfigs") + InitConfig(XTrialConfigs, "XTrialConfigs") + InitConfig(XCommunicationConfig, "XCommunicationConfig") + InitConfig(XPrequelConfigs, "XPrequelConfigs") + InitConfig(XTaskConfig, "XTaskConfig") + InitConfig(XFubenConfigs, "XFubenConfigs") + InitConfig(XTaskForceConfigs, "XTaskForceConfigs") + InitConfig(XDrawConfigs, "XDrawConfigs") + InitConfig(XGachaConfigs, "XGachaConfigs") + InitConfig(XFubenMainLineConfigs, "XFubenMainLineConfigs") + InitConfig(XFubenBossSingleConfigs, "XFubenBossSingleConfigs") + InitConfig(XFubenExperimentConfigs, "XFubenExperimentConfigs") + InitConfig(XMailConfigs, "XMailConfigs") + InitConfig(XBfrtConfigs, "XBfrtConfigs") + InitConfig(XBountyTaskConfigs, "XBountyTaskConfigs") + InitConfig(XHostelConfigs, "XHostelConfigs") + InitConfig(XBaseEquipConfigs, "XBaseEquipConfigs") + InitConfig(XFurnitureConfigs, "XFurnitureConfigs") + InitConfig(XPayConfigs, "XPayConfigs") + InitConfig(XFubenExploreConfigs, "XFubenExploreConfigs") + InitConfig(XFubenActivityBranchConfigs, "XFubenActivityBranchConfigs") + InitConfig(XFubenActivityBossSingleConfigs, "XFubenActivityBossSingleConfigs") + InitConfig(XFubenRepeatChallengeConfigs, "XFubenRepeatChallengeConfigs") + InitConfig(XDormConfig, "XDormConfig") + InitConfig(XMovieConfigs, "XMovieConfigs") + InitConfig(XExhibitionConfigs, "XExhibitionConfigs") + InitConfig(XAutoWindowConfigs, "XAutoWindowConfigs") + InitConfig(XPlayerInfoConfigs, "XPlayerInfoConfigs") + InitConfig(XSignInConfigs, "XSignInConfigs") + InitConfig(XReportConfigs, "XReportConfigs") + + InitConfig(XPracticeConfigs, "XPracticeConfigs") + InitConfig(XFubenUnionKillConfigs, "XFubenUnionKillConfigs") + InitConfig(XFubenSpecialTrainConfig, "XFubenSpecialTrainConfig") + InitConfig(XShopConfigs, "XShopConfigs") + InitConfig(XHelpCourseConfig, "XHelpCourseConfig") + InitConfig(XMedalConfigs, "XMedalConfigs") + InitConfig(XArchiveConfigs, "XArchiveConfigs") + InitConfig(XGuildConfig, "XGuildConfig") + InitConfig(XFestivalActivityConfig, "XFestivalActivityConfig") + InitConfig(XFubenBabelTowerConfigs, "XFubenBabelTowerConfigs") + InitConfig(XFubenRogueLikeConfig, "XFubenRogueLikeConfig") + InitConfig(XMarketingActivityConfigs, "XMarketingActivityConfigs") + InitConfig(XFubenAssignConfigs, "XFubenAssignConfigs") + InitConfig(XRegressionConfigs, "XRegressionConfigs") + InitConfig(XPlatformShareConfigs, "XPlatformShareConfigs") + InitConfig(XRewardConfigs, "XRewardConfigs") + InitConfig(XMusicPlayerConfigs, "XMusicPlayerConfigs") + InitConfig(XFubenExtraChapterConfigs, "XFubenExtraChapterConfigs") + InitConfig(XDailyDungeonConfigs, "XDailyDungeonConfigs") + InitConfig(XCharacterUiEffectConfig, "XCharacterUiEffectConfig") + InitConfig(XHeadPortraitConfigs, "XHeadPortraitConfigs") + InitConfig(XGuildBossConfig, "XGuildBossConfig") + InitConfig(XEliminateGameConfig, "XEliminateGameConfig") + InitConfig(XWorldBossConfigs, "XWorldBossConfigs") + InitConfig(XMaintainerActionConfigs, "XMaintainerActionConfigs") + + InitConfig(XExpeditionConfig, "XExpeditionConfig") + InitConfig(XRpgTowerConfig, "XRpgTowerConfig") + InitConfig(XClickClearGameConfigs, "XClickClearGameConfigs") + InitConfig(XFubenZhouMuConfigs, "XFubenZhouMuConfigs") + InitConfig(XNieRConfigs, "XNieRConfigs") + InitConfig(XMentorSystemConfigs, "XMentorSystemConfigs") + InitConfig(XCollectionWallConfigs, "XCollectionWallConfigs") + InitConfig(XActivityConfigs, "XActivityConfigs") + InitConfig(XPurchaseConfigs, "XPurchaseConfigs") + InitConfig(XActivityBriefConfigs, "XActivityBriefConfigs") + InitConfig(XSetConfigs, "XSetConfigs") + InitConfig(XRedEnvelopeConfigs, "XRedEnvelopeConfigs") + InitConfig(XVideoConfig, "XVideoConfig") + InitConfig(XWeaponFashionConfigs, "XWeaponFashionConfigs") + InitConfig(XFubenInfestorExploreConfigs, "XFubenInfestorExploreConfigs") + InitConfig(XPuzzleActivityConfigs, "XPuzzleActivityConfigs") + InitConfig(XChatConfigs, "XChatConfigs") + InitConfig(XPhotographConfigs, "XPhotographConfigs") + InitConfig(XTRPGConfigs, "XTRPGConfigs") + InitConfig(XPokemonConfigs, "XPokemonConfigs") + InitConfig(XSpringFestivalActivityConfigs, "XSpringFestivalActivityConfigs") + InitConfig(XFubenActivityPuzzleConfigs, "XFubenActivityPuzzleConfigs") + InitConfig(XFubenNewCharConfig, "XFubenNewCharConfig") + InitConfig(XSceneModelConfigs, "XSceneModelConfigs") + InitConfig(XRoomCharFilterTipsConfigs, "XRoomCharFilterTipsConfigs") + InitConfig(XChessPursuitConfig, "XChessPursuitConfig") + InitConfig(XComposeGameConfig, "XComposeGameConfig") + InitConfig(XLottoConfigs, "XLottoConfigs") + InitConfig(XPartnerConfigs, "XPartnerConfigs") + InitConfig(XWhiteValentineConfig, "XWhiteValentineConfig") + InitConfig(XSpecialShopConfigs, "XSpecialShopConfigs") + InitConfig(XFashionConfigs, "XFashionConfigs") + InitConfig(XFingerGuessingConfig, "XFingerGuessingConfig") + InitConfig(XReformConfigs, "XReformConfigs") + InitConfig(XPartnerTeachingConfigs, "XPartnerTeachingConfigs") + InitConfig(XScratchTicketConfig, "XScratchTicketConfig") + InitConfig(XRpgMakerGameConfigs, "XRpgMakerGameConfigs") + InitConfig(XInvertCardGameConfig, "XInvertCardGameConfig") + InitConfig(XMineSweepingConfigs, "XMineSweepingConfigs") + InitConfig(XSuperTowerConfigs, "XSuperTowerConfigs") + InitConfig(XFashionStoryConfigs, "XFashionStoryConfigs") + InitConfig(XPassportConfigs, "XPassportConfigs") + InitConfig(XGuardCampConfig, "XGuardCampConfig") + InitConfig(XFubenSimulatedCombatConfig, "XFubenSimulatedCombatConfig") + InitConfig(XChristmasTreeConfig, "XChristmasTreeConfig") + InitConfig(XCoupletGameConfigs, "XCoupletGameConfigs") + InitConfig(XStrongholdConfigs, "XStrongholdConfigs") + InitConfig(XMoeWarConfig, "XMoeWarConfig") + InitConfig(XMovieAssembleConfig, "XMovieAssembleConfig") + InitConfig(XFubenHackConfig, "XFubenHackConfig") + InitConfig(XFubenCoupleCombatConfig, "XFubenCoupleCombatConfig") + InitConfig(XPokerGuessingConfig, "XPokerGuessingConfig") + InitConfig(XKillZoneConfigs, "XKillZoneConfigs") + InitConfig(XSlotMachineConfigs, "XSlotMachineConfigs") + InitConfig(XReformConfigs, "XReformConfigs"); + InitConfig(XPartnerTeachingConfigs, "XPartnerTeachingConfigs"); + InitConfig(XScratchTicketConfig, "XScratchTicketConfig"); + InitConfig(XRpgMakerGameConfigs, "XRpgMakerGameConfigs"); + InitConfig(XInvertCardGameConfig, "XInvertCardGameConfig"); + InitConfig(XUiPcConfig, "XUiPcConfig"); + + XGuardCampConfig.Init() + XFubenSimulatedCombatConfig.Init() + XChristmasTreeConfig.Init() + XCoupletGameConfigs.Init() + XStrongholdConfigs.Init() + XMoeWarConfig.Init() + XMovieAssembleConfig.Init() + XFubenHackConfig.Init() + XFubenCoupleCombatConfig.Init() + XPokerGuessingConfig.Init() + XSlotMachineConfigs.Init() + + ConfigCenterProfiler:Stop() +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XCoupletGameConfigs.lua b/Resources/Scripts/XConfig/XCoupletGameConfigs.lua new file mode 100644 index 00000000..285736ec --- /dev/null +++ b/Resources/Scripts/XConfig/XCoupletGameConfigs.lua @@ -0,0 +1,148 @@ +local tableInsert = table.insert + +XCoupletGameConfigs = XCoupletGameConfigs or {} + +XCoupletGameConfigs.CouPletStatus = { + Incomplete = 0, + Complete = 1, +} + +XCoupletGameConfigs.PlayVideoState = { + UnPlay = 0, + Played = 1, +} + +XCoupletGameConfigs.HitFaceHelpState = { + NotHit = 0, + Hited = 1, +} + +XCoupletGameConfigs.HitFaceVideoState = { + UnPlay = 0, + Played = 1, +} + +-- XCoupletGameConfigs.COUPLET_GAME_DATA_KEY = "COUPLET_GAME_DATA_KEY" -- 对联游戏本地数据键 +XCoupletGameConfigs.COUPLET_GAME_HELP_HIT_KEY = "COUPLET_GAME_HELP_HIT_KEY" -- 对联游戏帮助打脸键 +XCoupletGameConfigs.COUPLET_GAME_VIDEO_HIT_KEY = "COUPLET_GAME_VIDEO_HIT_KEY" -- 对联游戏打脸剧情键 +XCoupletGameConfigs.PLAY_VIDEO_STATE_KEY = "COUPLET_PLAY_VIDEO_STATE_KEY" -- 剧情播放信息键 + +local COUPLET_ACTIVITY_BASE_PATH = "Share/MiniActivity/CoupletGame/CoupletActivityBase.tab" +local COUPLET_PATH = "Share/MiniActivity/CoupletGame/Couplet.tab" +local COUPLET_WORD_PATH = "Share/MiniActivity/CoupletGame/CoupletWord.tab" + +local ActivityBaseTemplates = {} +local CoupletTemplates = {} +local CoupletTemplatesWithAct = {} +local CoupletWordTemplates = {} +local DownWordArrList = {} + +function XCoupletGameConfigs.Init() + ActivityBaseTemplates = XTableManager.ReadByIntKey(COUPLET_ACTIVITY_BASE_PATH, XTable.XTableCoupletActivityBase, "Id") + CoupletTemplates = XTableManager.ReadByIntKey(COUPLET_PATH, XTable.XTableCouplet, "Id") + CoupletWordTemplates = XTableManager.ReadByIntKey(COUPLET_WORD_PATH, XTable.XTabelCoupletWord, "Id") + for _, coupletTemplet in ipairs(CoupletTemplates) do + if coupletTemplet.ActivityId then + if not CoupletTemplatesWithAct[coupletTemplet.ActivityId] then + CoupletTemplatesWithAct[coupletTemplet.ActivityId] = {} + end + end + + if CoupletTemplatesWithAct[coupletTemplet.ActivityId] then + tableInsert(CoupletTemplatesWithAct[coupletTemplet.ActivityId], coupletTemplet) + end + end + for _, coupletTemplate in pairs(CoupletTemplates) do + if DownWordArrList[coupletTemplate.Id] == nil then + DownWordArrList[coupletTemplate.Id] = {} + end + local downWordIdStrList = coupletTemplate.DownWordId + for _, downWordIdStr in ipairs(downWordIdStrList) do + local downWordIdArr = string.ToIntArray(downWordIdStr) + tableInsert(DownWordArrList[coupletTemplate.Id], downWordIdArr) + end + end +end + +function XCoupletGameConfigs.GetCoupletBaseActivityById(id) + if not ActivityBaseTemplates or not next(ActivityBaseTemplates) or not ActivityBaseTemplates[id] then + return + end + + return ActivityBaseTemplates[id] +end + +function XCoupletGameConfigs.GetCoupletTemplatesByActId(actId) + if not CoupletTemplatesWithAct or not next(CoupletTemplatesWithAct) or not CoupletTemplatesWithAct[actId] then + return + end + + return CoupletTemplatesWithAct[actId] +end + +function XCoupletGameConfigs.GetCoupletTemplateById(id) + if not CoupletTemplates or not next(CoupletTemplates) or not CoupletTemplates[id] then + return + end + + return CoupletTemplates[id] +end + +function XCoupletGameConfigs.GetCoupletWordImageById(wordId) + if not CoupletWordTemplates or not next(CoupletWordTemplates) or not CoupletWordTemplates[wordId] then + return + end + + return CoupletWordTemplates[wordId].WordImageUrl +end + +function XCoupletGameConfigs.GetCoupletUpWordsId(coupletId) + if not CoupletTemplates or not next(CoupletTemplates) or not CoupletTemplates[coupletId] then + return + end + + return CoupletTemplates[coupletId].UpWordId +end + +function XCoupletGameConfigs.GetCoupletBatch(coupletId) + if not CoupletTemplates or not CoupletTemplates[coupletId] then + return + end + + return CoupletTemplates[coupletId].BatchUrl +end + +function XCoupletGameConfigs.GetCoupletDefaultBatch(coupletId) + if not CoupletTemplates or not CoupletTemplates[coupletId] then + return + end + + return CoupletTemplates[coupletId].DefaultBatchUrl +end + +function XCoupletGameConfigs.GetCoupletUpImgUrl(coupletId) + if not CoupletTemplates or not CoupletTemplates[coupletId] then + return + end + + return CoupletTemplates[coupletId].UpImgUrl +end + +function XCoupletGameConfigs.GetCoupletDownImgUrl(coupletId) + if not CoupletTemplates or not CoupletTemplates[coupletId] then + return + end + + return CoupletTemplates[coupletId].DownImgUrl +end + +function XCoupletGameConfigs.GetCoupletDownIdArr(coupletId, Index) + if not DownWordArrList or not DownWordArrList[coupletId] then + return + end + + local coupletDownWordArr = DownWordArrList[coupletId] + if coupletDownWordArr and next(coupletDownWordArr) then + return coupletDownWordArr[Index] + end +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XDailyDungeonConfigs.lua b/Resources/Scripts/XConfig/XDailyDungeonConfigs.lua new file mode 100644 index 00000000..d4677051 --- /dev/null +++ b/Resources/Scripts/XConfig/XDailyDungeonConfigs.lua @@ -0,0 +1,66 @@ +XDailyDungeonConfigs = {} + +local TABLE_DAILY_DROP_GROUP = "Client/Fuben/Daily/DailyDropGroup.tab" +local TABLE_DAILT_DUNGEON_RULES = "Share/Fuben/Daily/DailyDungeonRules.tab" +local TABLE_DAILY_DUNGEON_DATA = "Share/Fuben/Daily/DailyDungeonData.tab" +local TABLE_DAILY_SPECOAL_CONDITION = "Share/Fuben/Daily/DailySpecialCondition.tab" + +local DailyDungeonRulesTemplates = {} +local DailyDungeonDataTemplates = {} +local DailySpecialConditionTemplates = {} +local DailyDropGroupTemplates = {} + +function XDailyDungeonConfigs.Init() + DailyDungeonRulesTemplates = XTableManager.ReadByIntKey(TABLE_DAILT_DUNGEON_RULES, XTable.XTableDailyDungeonRules, "Id") + DailyDungeonDataTemplates = XTableManager.ReadByIntKey(TABLE_DAILY_DUNGEON_DATA, XTable.XTableDailyDungeonData, "Id") + DailySpecialConditionTemplates = XTableManager.ReadByIntKey(TABLE_DAILY_SPECOAL_CONDITION, XTable.XTableDailySpecialCondition, "Id") + DailyDropGroupTemplates = XTableManager.ReadByIntKey(TABLE_DAILY_DROP_GROUP, XTable.XTableDailyDropGroup, "Id") +end + +function XDailyDungeonConfigs.GetDailyDungeonRulesList() + return DailyDungeonRulesTemplates +end + +function XDailyDungeonConfigs.GetDailyDungeonRulesById(id) + return DailyDungeonRulesTemplates[id] +end + +function XDailyDungeonConfigs.GetDailyDungeonDayOfWeek(Id) + local tmpTab = {} + for _, v in pairs(DailyDungeonRulesTemplates[Id].OpenDayOfWeek) do + table.insert(tmpTab, v) + end + return tmpTab +end + +function XDailyDungeonConfigs.GetDailyDungeonDataList() + return DailyDungeonDataTemplates +end + +function XDailyDungeonConfigs.GetDailyDungeonData(Id) + return DailyDungeonDataTemplates[Id] +end + +function XDailyDungeonConfigs.GetDailySpecialConditionList() + return DailySpecialConditionTemplates +end + +function XDailyDungeonConfigs.GetDailyDungeonIdByStageId(stageId) + for _, v in pairs(DailyDungeonDataTemplates) do + for _, v2 in pairs(v.StageId) do + if v2 == stageId then + return v.Id + end + end + end + return nil +end + +function XDailyDungeonConfigs.GetDailyDropGroupList() + return DailyDropGroupTemplates +end + +function XDailyDungeonConfigs.GetFubenDailyShopId(id) + local data = DailyDungeonDataTemplates[id] + return data and data.ShopId +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XDisplayConfigs.lua b/Resources/Scripts/XConfig/XDisplayConfigs.lua new file mode 100644 index 00000000..c49627c3 --- /dev/null +++ b/Resources/Scripts/XConfig/XDisplayConfigs.lua @@ -0,0 +1,40 @@ +XDisplayConfigs = XDisplayConfigs or {} + +local tableInsert = table.insert + +local TABLE_DISPLAY_PATH = "Client/Display/Display.tab" +local TABLE_CONTENT_PATH = "Client/Display/DisplayContent.tab" + +local DisplayTable = {} +local ContentTable = {} +local Groups = {} + +function XDisplayConfigs.Init() + DisplayTable = XTableManager.ReadByIntKey(TABLE_DISPLAY_PATH, XTable.XTableDisplay, "Id") + if not DisplayTable then + XLog.Error("XDisplayConfigs.Init 函数错误, 根据键值Id读取表 " .. TABLE_DISPLAY_PATH .. " 的时候出错") + end + + ContentTable = XTableManager.ReadByIntKey(TABLE_CONTENT_PATH, XTable.XTableDisplayContent, "Id") + for _, tab in pairs(DisplayTable) do + local group = Groups[tab.Model] + if not group then + group = { Ids = {}, Weights = {} } + Groups[tab.Model] = group + end + tableInsert(group.Ids, tab.Id) + tableInsert(group.Weights, tab.Weight) + end +end + +function XDisplayConfigs.GetDisplayTable() + return DisplayTable +end + +function XDisplayConfigs.GetContentTable() + return ContentTable +end + +function XDisplayConfigs.GetGroups() + return Groups +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XDlcConfig.lua b/Resources/Scripts/XConfig/XDlcConfig.lua new file mode 100644 index 00000000..7f60e47a --- /dev/null +++ b/Resources/Scripts/XConfig/XDlcConfig.lua @@ -0,0 +1,48 @@ +local TABLE_DLC_DESC_PATH = "Client/DlcRes/DlcDesc.tab" +local TABLE_DLC_STAGE_PATH = "Client/DlcRes/DlcStage.tab" +local TABLE_DLC_FUNC_PATH = "Client/DlcRes/DlcFunc.tab" + +local DlcDescConfig = {} +local DlcStageConfig = {} +local DlcFuncConfig = {} + +local StageToDlcIdDic = {} +local FuncToDlcIdDic = {} + + +XDlcConfig = XDlcConfig or {} + +function XDlcConfig.Init() + --XLog.Error("XDlcConfig init") + DlcDescConfig = XTableManager.ReadByIntKey(TABLE_DLC_DESC_PATH, XTable.XTableDlcDesc, "DlcId") + DlcStageConfig = XTableManager.ReadByIntKey(TABLE_DLC_STAGE_PATH, XTable.XTableDlcStage, "DlcId") + DlcFuncConfig = XTableManager.ReadByIntKey(TABLE_DLC_FUNC_PATH, XTable.XTableDlcFunc, "DlcId") + + for k,v in pairs(DlcStageConfig) do + --XLog.Error("DlcStageConfig["..k.."] = " .. v) + for k2,v2 in ipairs(v.StageIds) do + StageToDlcIdDic[v2] = k + --XLog.Error("StageToDlcIdDic["..v2.."] = " .. k) + end + end + + for k,v in pairs(DlcFuncConfig) do + --XLog.Error("DlcFuncConfig["..k.."] = " .. v) + for k2,v2 in ipairs(v.FuncIds) do + FuncToDlcIdDic[v2] = k + --XLog.Error("FuncToDlcIdDic["..v2.."] = " .. k) + end + end +end + +function XDlcConfig.StageToDlcId(stageId) + return StageToDlcIdDic[stageId] +end + +function XDlcConfig.FuncToDlcId(funcId) + return FuncToDlcIdDic[funcId] +end + +XDlcConfig.DlcDescConfig = DlcDescConfig +XDlcConfig.StageToDlcIdDic = StageToDlcIdDic +XDlcConfig.FuncToDlcIdDic = FuncToDlcIdDic \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XDormConfig.lua b/Resources/Scripts/XConfig/XDormConfig.lua new file mode 100644 index 00000000..26625977 --- /dev/null +++ b/Resources/Scripts/XConfig/XDormConfig.lua @@ -0,0 +1,1035 @@ +XDormConfig = XDormConfig or {} + +-- 加载宿舍类型 +XDormConfig.DormDataType = { + Self = 0, + Target = 1, + Template = 2, -- 模板宿舍 + Collect = 3, -- 收藏宿舍 + Provisional = 4, --导入宿舍 + CollectNone = 5, +} + +-- 构造体喜欢类型 +XDormConfig.CharacterLikeType = { + LoveType = "LoveType", + LikeType = "LikeType", +} + +-- 仓库Toggle +XDormConfig.DORM_BAG_PANEL_INDEX = { + FURNITURE = 1, -- 家具 + CHARACTER = 2, -- 构造体 + DRAFT = 3, -- 图纸 +} + +-- 仓库住户Toggle +XDormConfig.DORM_CHAR_INDEX = { + CHARACTER = 1, -- 构造体 + EMNEY = 2, -- 侵蚀体 + -- HUMAN = 3, -- 人类 + INFESTOR = 3, -- 授格者 + NIER = 4, -- 联动 +} + +-- 跳转类型 +XDormConfig.VisitDisplaySetType = { + MySelf = 1, + MyFriend = 2, + Stranger = 3 +} + +-- 访问类型 +XDormConfig.VisitTabTypeCfg = { + MyFriend = 1, + Visitor = 2 +} + +-- 宿舍激活状态 +XDormConfig.DormActiveState = { + Active = 0, + UnActive = 1 +} + +-- 宿舍构造体抚摸状态 +XDormConfig.TouchState = { + Hide = 0, -- 关闭 + Touch = 1, -- 抚摸 + WaterGun = 2, -- 水枪 + Play = 3, -- 玩耍 + TouchSuccess = 4, -- 抚摸成功 + WaterGunSuccess = 5, -- 水枪成功 + PlaySuccess = 6, --玩耍成功 + Hate = 7, -- 讨厌 + TouchHate = 8, --讨厌抚摸 +} + +-- 打工状态 +XDormConfig.WorkPosState = { + Working = 1, --打工中 + Worked = 0, --打工完成 + Empty = -1, --空的 + RewardEd = 2, --奖励领取完 + Lock = 3, +} + +-- 客户端展示事件Id +XDormConfig.ShowEventId = { + VitalityAdd = 101, -- 体力增加 + VitalityCut = 102, -- 体力减少 + MoodAdd = 103, -- 心情增加 + MoodCut = 104, -- 心情减少 + VitalitySpeedAdd = 105, -- 体力速度增加 + VitalitySpeedCut = 106, -- 体力速度减少 + MoodSpeedAdd = 107, -- 心情速度增加 + MoodSpeedCut = 108, -- 心情速度减少 +} + +-- 客户端展示事件Id +XDormConfig.ShowEffectType = { + Simple = 1, -- 单行模式 + Complex = 2, -- 多行模式 +} + +-- 客户端展示事件Id +XDormConfig.CompareType = { + Less = 0, -- 小于等于 + Greater = 1, -- 大于等于 + Equal = 2, -- 等于 +} + +-- 回复类型 +XDormConfig.RecoveryType = { + PutFurniture = 1, -- 放置家具 + PutCharacter = 2, -- 放置构造体 +} + +XDormConfig.DormSecondEnter = { + Task = 1, -- 任务 + Des = 2, -- 描述 + WareHouse = 3, --仓库 + ReName = 4, --改名 + FieldGuilde = 5, --图鉴 + Build = 6, --建造 + Shop = 7, --商店 + Person = 8, --人员 +} + +XDormConfig.DormAttDesIndex = { + [1] = "DormScoreAttrADes", + [2] = "DormScoreAttrBDes", + [3] = "DormScoreAttrCDes", +} + +-- 宿舍人物类型 +XDormConfig.DormSex = { + Man = 1, -- 男构造体 + Woman = 2, -- 女构造体 + Infect = 3, -- 侵蚀体 + Human = 4, -- 人类男 + Huwoman = 5, -- 人类女 + InfestorMale = 6, -- 授格体男 + InfestorFemale = 7, -- 授格体女 + NIER = 8, -- 授格体女 +} + +-- 宿舍角色性别 +XDormConfig.DormCharGender = { + None = 0, + Male = 1, + Female = 2, + Gan = 3, + Max = 4, +} + +-- 宿舍空间站枚举 +XDormConfig.SenceType = { + One = 1, + Tow = 2, +} + +XDormConfig.DORM_VITALITY_MAX_VALUE = math.floor(CS.XGame.Config:GetInt("DormVitalityMaxValue") / 100) +XDormConfig.DORM_MOOD_MAX_VALUE = math.floor(CS.XGame.Config:GetInt("DormMoodMaxValue") / 100) +XDormConfig.DORM_DRAFT_SHOP_ID = CS.XGame.ClientConfig:GetInt("DormDraftShopId") + +XDormConfig.TOUCH_LENGTH = CS.XGame.ClientConfig:GetInt("DormCharacterTouchLength") +XDormConfig.WATERGUN_TIME = CS.XGame.ClientConfig:GetInt("DormCharacterWaterGunTime") +XDormConfig.PLAY_TIME = CS.XGame.ClientConfig:GetInt("DormCharacterPlayTime") +XDormConfig.DISPPEAR_TIME = CS.XGame.ClientConfig:GetInt("DormDetailDisppearTime") +XDormConfig.DRAFT_DIS = CS.XGame.ClientConfig:GetInt("DormDraftDistance") +XDormConfig.TOUCH_CD = CS.XGame.ClientConfig:GetFloat("DormCharacterTouchCD") +XDormConfig.TOUCH_PROP = CS.XGame.ClientConfig:GetFloat("DormCharacterTouchProportion") +XDormConfig.GET_SHARE_ID_INTERVAL = CS.XGame.ClientConfig:GetInt("DormShareWaitTime") +XDormConfig.MAX_SHARE_COUNT = CS.XGame.ClientConfig:GetInt("DormMaxShareCount") + +XDormConfig.DormComfortTime = CS.XGame.ClientConfig:GetInt("DormComfortTime") or 1 +XDormConfig.CaptureAngleX = CS.XGame.ClientConfig:GetFloat("DormTemplateCaptureAngleX") +XDormConfig.CaptureAngleY = CS.XGame.ClientConfig:GetFloat("DormTemplateCaptureAngleY") +XDormConfig.CaptureDistance = CS.XGame.ClientConfig:GetFloat("DormTemplateCaptureDistance") +XDormConfig.ProvisionalMaXCount = CS.XGame.ClientConfig:GetInt("DormProvisionalMaxCount") +XDormConfig.ShareName = CS.XGame.ClientConfig:GetString("DormTemplateShareName") + +local TABLE_DORM_CHARACTER_EVENT_PATH = "Share/Dormitory/Character/DormCharacterEvent.tab" +local TABLE_DORM_CHARACTER_BEHAVIOR_PATH = "Share/Dormitory/Character/DormCharacterBehavior.tab" +local TABLE_DORMITORY_PATH = "Share/Dormitory/Dormitory.tab" +local TABLE_DORMCHARACTERWORK_PATH = "Share/Dormitory/Character/DormCharacterWork.tab" +local TABLE_DORM_CHARACTER_RECOVERY_PATH = "Share/Dormitory/Character/DormCharacterRecovery.tab" +local TABLE_DORM_CHARACTER_FONDLE_PATH = "Share/Dormitory/Character/DormCharacterFondle.tab" +local TABLE_CHARACTER_STYLE_PATH = "Share/Dormitory/Character/DormCharacterStyle.tab" +local TABLE_CHARACTER_REWARD_PATH = "Share/Dormitory/Character/DormCharacterReward.tab" +local TABLE_DORM_BGM_PATH = "Share/Dormitory/DormBgm.tab" +local TABLE_DORM_TEMPLATE_PATH = "Share/Dormitory/DormTemplate.tab" + +local TABLE_CHARACTER_MOOD_PATH = "Client/Dormitory/DormCharacterMood.tab" +local TABLE_MOOD_EFFECT_PATH = "Client/Dormitory/DormCharacterEffect.tab" +local TABLE_CHARACTER_DIALOG_PATH = "Client/Dormitory/DormCharacterDialog.tab" +local TABLE_CHARACTER_ACTION_PATH = "Client/Dormitory/DormCharacterAction.tab" +local TABLE_CHARACTER_INTERACTIVE_PATH = "Client/Dormitory/DormInteractiveEvent.tab" +local TABLE_SHOW_EVENT_PATH = "Client/Dormitory/DormShowEvent.tab" +local TABLE_DORM_GUIDE_TASK_PATH = "Client/Dormitory/DormGuideTask.tab" +local TABLE_DORM_TEMPLATE_COLLECT_PATH = "Client/Dormitory/DormTemplateCollect.tab" +local TABLE_DORM_TEMPLATE_GROUP_PATH = "Client/Dormitory/DormTemplateGroup.tab" +local TABLE_DORM_F2C_RELATION_PATH = "Client/Dormitory/DormF2CBehaviorRelation.tab" + +local CharacterEventTemplate = {} +local CharacterBehaviorTemplate = {} +local DormitoryTemplate = {} --宿舍配置表 +local CharacterBehaviorStateIndex = {} +local DormCharacterWork = {} --宿舍打工工位配置表 +local DormCharacterRecovery = {} --构造体回复配置表 table = {characterId = {config1, config2, ...}} +local CharacterStyleTemplate = {} --客户端构造体风格配置表 +local CharacterMoodTemplate = {} --客户端构造体心情配置表 +local MoodEffectTemplate = {} --构造体表情特效配置表 +local CharacterFondleTemplate = {} -- 爱抚配置表 +local ChaarcterShowEventTemplate = {} -- 事件客户端表现配置表 +local DormTaskGuideCfg = {} -- 宿舍指引任务 +local DormCharacterRewardCfg = {} +local DormTemplateCfg = {} -- 宿舍模板配置表 +local DormTemplateCollectCfg = {} -- 宿舍收藏模板配置表 +local DormTemplateGroupCfg = {} -- 宿舍模板组配置表 +local DormCharTypeCountDic = {} -- 可获得各类角色总数字典 + +local CharacterActionTemplate = {} --动作 +local CharacterInteractiveTemplate = {} --动作 + +local CharacterDialogTemplate = {} -- 构造体对话表 +local CharacterDialogStateIndex = {} +local CharacterActionIndex = {} +local CharacterInteractiveIndex = {} +local DormTaskGuideDic = nil + +local DormBgmTemplate = {} +local DormTemplateData = nil -- 宿舍模板数据 + +local DormF2CRelationConfig = {} +local DormF2CRelationDic = {} +-- 初始化构造体恢复表,并排序 +local function InitDormCharacterRecovery() + local recoverys = XTableManager.ReadByIntKey(TABLE_DORM_CHARACTER_RECOVERY_PATH, XTable.XTableDormCharacterRecovery, "Id") + for _, recovery in pairs(recoverys) do + if not DormCharacterRecovery[recovery.CharacterId] then + DormCharacterRecovery[recovery.CharacterId] = {} + end + + table.insert(DormCharacterRecovery[recovery.CharacterId], recovery) + end + + for _, recovery in pairs(DormCharacterRecovery) do + table.sort(recovery, function(a, b) + return a.Pre < b.Pre + end) + end +end +--================= +--构建家具-人物行为关系字典 +--================= +local function CreateDormF2CRelationDic() + for _, config in pairs(DormF2CRelationConfig) do + if not DormF2CRelationDic[config.FurnitureId] then + DormF2CRelationDic[config.FurnitureId] = {} + end + if not DormF2CRelationDic[config.FurnitureId][config.CharacterId] then + DormF2CRelationDic[config.FurnitureId][config.CharacterId] = {} + end + if config.PositionId then + DormF2CRelationDic[config.FurnitureId][config.CharacterId][config.PositionId] = config + else + DormF2CRelationDic[config.FurnitureId][config.CharacterId][1] = config + end + end +end + +function XDormConfig.Init() + CharacterEventTemplate = XTableManager.ReadByIntKey(TABLE_DORM_CHARACTER_EVENT_PATH, XTable.XTableDormCharacterEvent, "EventId") + CharacterBehaviorTemplate = XTableManager.ReadByIntKey(TABLE_DORM_CHARACTER_BEHAVIOR_PATH, XTable.XTableDormCharacterBehavior, "Id") + DormitoryTemplate = XTableManager.ReadByIntKey(TABLE_DORMITORY_PATH, XTable.XTableDormitory, "Id") + DormCharacterWork = XTableManager.ReadByIntKey(TABLE_DORMCHARACTERWORK_PATH, XTable.XTableDormCharacterWork, "DormitoryNum") + CharacterStyleTemplate = XTableManager.ReadByIntKey(TABLE_CHARACTER_STYLE_PATH, XTable.XTableDormCharacterStyle, "Id") + CharacterMoodTemplate = XTableManager.ReadByIntKey(TABLE_CHARACTER_MOOD_PATH, XTable.XTableDormCharacterMood, "Id") + MoodEffectTemplate = XTableManager.ReadByIntKey(TABLE_MOOD_EFFECT_PATH, XTable.XTableDormCharacterEffect, "Id") + CharacterDialogTemplate = XTableManager.ReadByIntKey(TABLE_CHARACTER_DIALOG_PATH, XTable.XTableDormCharacterDialog, "Id") + CharacterActionTemplate = XTableManager.ReadByIntKey(TABLE_CHARACTER_ACTION_PATH, XTable.XTableDormCharacterAction, "Id") + CharacterFondleTemplate = XTableManager.ReadByIntKey(TABLE_DORM_CHARACTER_FONDLE_PATH, XTable.XTableDormCharacterFondle, "CharacterId") + --CharacterActionTemplate = XTableManager.ReadByIntKey(TABLE_CHARACTER_ACTION_PATH, XTable.XTableDormCharacterAction, "Id") + CharacterInteractiveTemplate = XTableManager.ReadByIntKey(TABLE_CHARACTER_INTERACTIVE_PATH, XTable.XTableDormInteractiveEvent, "Id") + ChaarcterShowEventTemplate = XTableManager.ReadByIntKey(TABLE_SHOW_EVENT_PATH, XTable.XTableDormShowEvent, "Id") + DormBgmTemplate = XTableManager.ReadByIntKey(TABLE_DORM_BGM_PATH, XTable.XTableDormBgm, "Id") + DormTemplateCollectCfg = XTableManager.ReadByIntKey(TABLE_DORM_TEMPLATE_COLLECT_PATH, XTable.XTableDormTemplateCollect, "Id") + DormTemplateGroupCfg = XTableManager.ReadByIntKey(TABLE_DORM_TEMPLATE_GROUP_PATH, XTable.XTableDormTemplateGroup, "Id") + DormTemplateCfg = XTableManager.ReadByIntKey(TABLE_DORM_TEMPLATE_PATH, XTable.XTableDormTemplate, "Id") + DormTaskGuideCfg = XTableManager.ReadByIntKey(TABLE_DORM_GUIDE_TASK_PATH, XTable.XTableDormGuideTask, "Id") + DormCharacterRewardCfg = XTableManager.ReadByIntKey(TABLE_CHARACTER_REWARD_PATH, XTable.XTableDormCharacterReward, "Id") + DormF2CRelationConfig = XTableManager.ReadByIntKey(TABLE_DORM_F2C_RELATION_PATH, XTable.XTableDormF2CBehaviorRelation, "Id") + InitDormCharacterRecovery() + + CharacterBehaviorStateIndex = {} + + for _, v in pairs(CharacterBehaviorTemplate) do + CharacterBehaviorStateIndex[v.CharacterId] = CharacterBehaviorStateIndex[v.CharacterId] or {} + CharacterBehaviorStateIndex[v.CharacterId][v.State] = v + end + + for _, v in pairs(CharacterDialogTemplate) do + CharacterDialogStateIndex[v.CharacterId] = CharacterDialogStateIndex[v.CharacterId] or {} + CharacterDialogStateIndex[v.CharacterId][v.State] = CharacterDialogStateIndex[v.CharacterId][v.State] or {} + table.insert(CharacterDialogStateIndex[v.CharacterId][v.State], v) + end + + for _, v in pairs(CharacterActionTemplate) do + CharacterActionIndex[v.CharacterId] = CharacterActionIndex[v.CharacterId] or {} + CharacterActionIndex[v.CharacterId][v.Name] = v.State + end + + for _, v in pairs(CharacterInteractiveTemplate) do + local cha1 = v.CharacterIds[1] + local cha2 = v.CharacterIds[2] + CharacterInteractiveIndex[cha1] = CharacterInteractiveIndex[cha1] or {} + CharacterInteractiveIndex[cha1][cha2] = v + end + + for _, v in pairs(CharacterStyleTemplate) do + local count = DormCharTypeCountDic[v.Type] or 0 + count = count + 1 + DormCharTypeCountDic[v.Type] = count + end + + XDormConfig.DormAnimationMoveTime = CS.XGame.ClientConfig:GetInt("DormMainAnimationMoveTime") or 0 + XDormConfig.DormAnimationStaicTime = CS.XGame.ClientConfig:GetInt("DormMainAnimationStaicTime") or 0 + XDormConfig.DormSecondAnimationDelayTime = CS.XGame.ClientConfig:GetInt("DormSecondAnimationDelayTime") or 0 + + local collectMaxCount = CS.XGame.Config:GetInt("DormLayoutMaxCount") or 0 + local cfgCount = 0 + for _, _ in pairs(DormTemplateCollectCfg) do + cfgCount = cfgCount + 1 + end + + if collectMaxCount ~= cfgCount then + XLog.Error("XDormConfig.Init错误,错误原因: DormTemplateCollectCfg表(路径:" .. TABLE_DORM_TEMPLATE_COLLECT_PATH .. ")的表项个数与Share/Config/Config.tab表中DormLayoutMaxCount这一项的最大数量不同") + end + --构建家具-人物行为关系字典 + CreateDormF2CRelationDic() +end + +-- 获取构造体奖励名字 +function XDormConfig.GetDormCharacterRewardNameById(id) + local data = XDormConfig.GetDormCharacterRewardData(id) + if not data or not data.Name then + XLog.ErrorTableDataNotFound("XDormConfig.GetDormCharacterRewardNameById", "Name", TABLE_CHARACTER_REWARD_PATH, "id", tostring(id)) + return nil + end + + return data.Name +end + +-- 获取构造体奖励品质 +function XDormConfig.GetDormCharacterRewardQualityById(id) + local data = XDormConfig.GetDormCharacterRewardData(id) + if not data or not data.Quality then + XLog.ErrorTableDataNotFound("XDormConfig.GetDormCharacterRewardQualityById", "Quality", TABLE_CHARACTER_REWARD_PATH, "id", tostring(id)) + return nil + end + + return data.Quality +end + +-- 获取构造体奖励Icon +function XDormConfig.GetDormCharacterRewardIconById(id) + local data = XDormConfig.GetDormCharacterRewardData(id) + if not data or not data.Icon then + XLog.ErrorTableDataNotFound("XDormConfig.GetDormCharacterRewardIconById", "Icon", TABLE_CHARACTER_REWARD_PATH, "id", tostring(id)) + return nil + end + + return data.Icon +end + +-- 获取构造体奖励SmallIcon +function XDormConfig.GetDormCharacterRewardSmallIconById(id) + local data = XDormConfig.GetDormCharacterRewardData(id) + if not data or not data.SmallIcon then + XLog.ErrorTableDataNotFound("XDormConfig.GetDormCharacterRewardSmallIconById", "SmallIcon", TABLE_CHARACTER_REWARD_PATH, "id", tostring(id)) + return nil + end + + return data.SmallIcon +end + +-- 获取构造体奖励CharacterId +function XDormConfig.GetDormCharacterRewardCharIdById(id) + local data = XDormConfig.GetDormCharacterRewardData(id) + if not data or not data.CharacterId then + XLog.ErrorTableDataNotFound("XDormConfig.GetDormCharacterRewardCharIdById", "CharacterId", TABLE_CHARACTER_REWARD_PATH, "id", tostring(id)) + return nil + end + + return data.CharacterId +end + +-- 获取构造体奖励Description +function XDormConfig.GetDormDescriptionRewardCharIdById(id) + local data = XDormConfig.GetDormCharacterRewardData(id) + if not data or not data.Description then + XLog.ErrorTableDataNotFound("XDormConfig.GetDormDescriptionRewardCharIdById", "Description", TABLE_CHARACTER_REWARD_PATH, "id", tostring(id)) + return nil + end + + return data.Description +end + +-- 获取构造体奖励WorldDescription +function XDormConfig.GetDormWorldDescriptionRewardCharIdById(id) + local data = XDormConfig.GetDormCharacterRewardData(id) + if not data or not data.WorldDescription then + XLog.ErrorTableDataNotFound("XDormConfig.GetDormWorldDescriptionRewardCharIdById", + "WorldDescription", TABLE_CHARACTER_REWARD_PATH, "id", tostring(id)) + return nil + end + + return data.WorldDescription +end + +-- 获取模板宿舍Ishow +function XDormConfig.GetDormTemplateIsSwhoById(id) + local data = XDormConfig.GetDormTemplateCfg(id) + return data.IsShow +end + +function XDormConfig.GetDormTemplateCollectList() + local list = {} + for _, info in pairs(DormTemplateCollectCfg) do + table.insert(list, info) + end + + table.sort(list, function(a, b) + return a.Order < b.Order + end) + + return list +end + +function XDormConfig.GetDormTemplateGroupList() + local list = {} + for _, info in pairs(DormTemplateGroupCfg) do + table.insert(list, info) + end + return list +end + +function XDormConfig.GetDormTemplateSelecIndex(connectId) + local index = 0 + local default = 1 + for _, info in pairs(DormTemplateGroupCfg) do + index = index + 1 + for _, id in ipairs(info.DormId) do + if connectId == id then + return index + end + end + end + return default +end + +function XDormConfig.GetDormTemplateCfg(id) + local data = DormTemplateCfg[id] + if not data then + XLog.ErrorTableDataNotFound("XDormConfig.GetDormTemplateCfg", "data", TABLE_DORM_TEMPLATE_PATH, "id", tostring(id)) + return nil + end + + return data +end + +function XDormConfig.GetDormCharacterRewardData(id) + local data = DormCharacterRewardCfg[id] + return data +end + +-- 宿舍指引任务Dic +function XDormConfig.GetDormitoryGuideTaskCfg() + if DormTaskGuideDic then + return DormTaskGuideDic + end + + DormTaskGuideDic = {} + for _, v in pairs(DormTaskGuideCfg) do + DormTaskGuideDic[v.TaskId] = v.TaskId + end + return DormTaskGuideDic +end + +-- 获取所有宿舍 +function XDormConfig.GetTotalDormitoryCfg() + local t = DormitoryTemplate + return t +end + +function XDormConfig.DormCharSexTypeToGender(sexType) + if sexType == XDormConfig.DormSex.Man or sexType == XDormConfig.DormSex.Human or sexType == XDormConfig.DormSex.InfestorMale then + return XDormConfig.DormCharGender.Male + elseif sexType == XDormConfig.DormSex.Woman or sexType == XDormConfig.DormSex.Huwoman or sexType == XDormConfig.DormSex.InfestorFemale then + return XDormConfig.DormCharGender.Female + elseif sexType == XDormConfig.DormSex.Infect then + return XDormConfig.DormCharGender.Gan + elseif sexType == XDormConfig.DormSex.NIER then + return XDormConfig.DormCharGender.None + else + return XDormConfig.DormCharGender.None + end +end + +function XDormConfig.GetDormCharacterType(dormCharIndex) + if dormCharIndex == XDormConfig.DORM_CHAR_INDEX.CHARACTER then + return XDormConfig.DormSex.Man, XDormConfig.DormSex.Woman + elseif dormCharIndex == XDormConfig.DORM_CHAR_INDEX.EMNEY then + return XDormConfig.DormSex.Infect + -- elseif dormCharIndex == XDormConfig.DORM_CHAR_INDEX.HUMAN then + -- return XDormConfig.DormSex.Human, XDormConfig.DormSex.Huwoman + elseif dormCharIndex == XDormConfig.DORM_CHAR_INDEX.INFESTOR then + return XDormConfig.DormSex.InfestorMale, XDormConfig.DormSex.InfestorFemale + elseif dormCharIndex == XDormConfig.DORM_CHAR_INDEX.NIER then + return XDormConfig.DormSex.NIER + else + return + end +end + +-- 通过类型,获取宿舍角色总数量 +function XDormConfig.GetDormCharacterTemplatesCountByType(...) + local count = 0 + local types = { ... } + for _, k in ipairs(types) do + local t = DormCharTypeCountDic[k] or 0 + count = count + t + end + return count +end + +-- 配置的宿舍总数 +function XDormConfig.GetTotalDormitortCountCfg() + local count = 0 + local t = DormitoryTemplate or {} + for _, _ in pairs(t) do + count = count + 1 + end + + return count +end + +-- 获取宿舍配置 +function XDormConfig.GetDormitoryCfgById(id) + if not id then + return nil + end + + local t = DormitoryTemplate[id] + if not t then + XLog.ErrorTableDataNotFound("XDormConfig.GetDormitoryCfgById", "t", TABLE_DORMITORY_PATH, "id", tostring(id)) + return nil + end + + return t +end + +-- 获取宿舍配置 +function XDormConfig.GetDefaultDormitory() + for _, v in pairs(DormitoryTemplate) do + return v + end +end + +-- 获取宿舍空间转向 +function XDormConfig.GetDormSenceVector(dormitoryId) + local dormitoryConfig = XDormConfig.GetDormitoryCfgById(dormitoryId) + local v3 = CS.UnityEngine.Vector3.zero + if dormitoryConfig.SceneId == XDormConfig.SenceType.One then + v3 = CS.UnityEngine.Vector3(0, -180, 0) + elseif dormitoryConfig.SceneId == XDormConfig.SenceType.Tow then + v3 = CS.UnityEngine.Vector3(0, -180, 0) + end + + return v3 +end + +-- 获取宿舍号 +function XDormConfig.GetDormitoryNumById(dormitoryId) + local dormitoryConfig = XDormConfig.GetDormitoryCfgById(dormitoryId) + return dormitoryConfig.InitNumber +end + +-- 获取宿舍空间ID +function XDormConfig.GetDormitorySenceById(dormitoryId) + local dormitoryConfig = XDormConfig.GetDormitoryCfgById(dormitoryId) + return dormitoryConfig.SceneId +end + +-- 宿舍可住人数 +-- 获取宿舍配置 +function XDormConfig.GetDormPersonCount(id) + local t = XDormConfig.GetDormitoryCfgById(id) + if not t then + return 0 + end + + return t.CharCapacity or 0 +end + +--获取行为节点Id +function XDormConfig.GetCharacterBehavior(charId, state) + if not CharacterBehaviorStateIndex or not CharacterBehaviorStateIndex[charId] then + XLog.ErrorTableDataNotFound("XDormConfig.GetCharacterBehavior", "CharacterBehaviorStateIndex", + TABLE_DORM_CHARACTER_BEHAVIOR_PATH, "charId", tostring(charId)) + return + end + + if not CharacterBehaviorStateIndex[charId][state] then + --也用于检测有无角色行为,这里的报错日志注释掉 + --XLog.ErrorTableDataNotFound("XDormConfig.GetCharacterBehavior", "state", TABLE_DORM_CHARACTER_BEHAVIOR_PATH, "charId", tostring(charId)) + return + end + + return CharacterBehaviorStateIndex[charId][state] +end + + +--获取行为表 +function XDormConfig.GetCharacterBehaviorById(id) + if not CharacterBehaviorTemplate then + XLog.Error("配置表:" .. TABLE_DORM_CHARACTER_BEHAVIOR_PATH .. "读取失败") + return + end + + if not CharacterBehaviorTemplate[id] then + XLog.ErrorTableDataNotFound("XDormConfig.GetCharacterBehaviorById", "配置表项", TABLE_DORM_CHARACTER_BEHAVIOR_PATH, "id", tostring(id)) + return + end + + + return CharacterBehaviorTemplate[id] +end + + +--获取角色交互 +function XDormConfig.GetCharacterInteractiveIndex(id1, id2) + if not CharacterInteractiveIndex then + return false + end + + if CharacterInteractiveIndex[id1] and CharacterInteractiveIndex[id1][id2] then + local temp = CharacterInteractiveIndex[id1][id2] + return true, temp, temp.State[1], temp.State[2] + elseif CharacterInteractiveIndex[id2] and CharacterInteractiveIndex[id2][id1] then + local temp = CharacterInteractiveIndex[id2][id1] + return true, temp, temp.State[2], temp.State[1] + end + + return false +end + +--获取动作状态机 +function XDormConfig.GetCharacterActionState(charId, name) + if not CharacterActionIndex or not CharacterActionIndex[charId] or not CharacterActionIndex[charId][name] then + XLog.Error(string.format("CharacterActionIndex不存在 charId:%s name:%s 路径:%s", charId, name, TABLE_CHARACTER_ACTION_PATH)) + name = "QR2YongyechaoExcessiveBase01" + end + + return CharacterActionIndex[charId][name] +end + +--获取事件 +function XDormConfig.GetCharacterEventById(id) + if not CharacterEventTemplate then + XLog.Error("配置表:" .. TABLE_DORM_CHARACTER_EVENT_PATH .. "读取失败") + return + end + + if not CharacterEventTemplate[id] then + XLog.ErrorTableDataNotFound("XDormConfig.GetCharacterEventById", "配置表项", TABLE_DORM_CHARACTER_EVENT_PATH, "id", tostring(id)) + return + end + + return CharacterEventTemplate[id] +end + +function XDormConfig.GetDormCharacterWorkById(id) + if not id then + return + end + + return DormCharacterWork[id] +end + +function XDormConfig.GetDormCharacterWorkData() + return DormCharacterWork +end + +-- 获取构造体回复配置表 +function XDormConfig.GetCharRecoveryConfig(charId) + local t = DormCharacterRecovery[charId] + if not t then + XLog.ErrorTableDataNotFound("XDormConfig.GetCharRecoveryConfig", "配置表项", TABLE_DORM_CHARACTER_RECOVERY_PATH, "charId", tostring(charId)) + return nil + end + + return t +end + +-- 获取构造体表情特效 +function XDormConfig.GetMoodEffectConfig(id) + local t = MoodEffectTemplate[id] + if not t then + XLog.ErrorTableDataNotFound("XDormConfig.GetMoodEffectConfig", "配置表项", TABLE_MOOD_EFFECT_PATH, "id", tostring(id)) + return nil + end + + return t +end + +-- 获取构造体对话配置表 +function XDormConfig.GetCharacterDialogConfig(id) + local t = CharacterDialogTemplate[id] + if not t then + XLog.ErrorTableDataNotFound("XDormConfig.GetCharacterDialogConfig", "配置表项", TABLE_CHARACTER_DIALOG_PATH, "id", tostring(id)) + return nil + end + + return t +end + +-- 获取构造体信息配置 +function XDormConfig.GetCharacterStyleConfigById(id) + local t = CharacterStyleTemplate[id] + if not t then + XLog.ErrorTableDataNotFound("XDormConfig.GetCharacterStyleConfigById", "配置表项", TABLE_CHARACTER_STYLE_PATH, "id", tostring(id)) + return nil + end + + return t +end + +-- 获取构造体Q版头像(圆形) +function XDormConfig.GetCharacterStyleConfigQIconById(id) + local t = CharacterStyleTemplate[id] + if not t or not t.HeadRoundIcon then + XLog.ErrorTableDataNotFound("XDormConfig.GetCharacterStyleConfigQIconById", + "配置表项或者HeadRoundIcon", TABLE_CHARACTER_STYLE_PATH, "id", tostring(id)) + return nil + end + + return t.HeadRoundIcon +end + +-- 获取构造体Q版头像(圆形) +function XDormConfig.GetCharacterStyleConfigQSIconById(id) + local t = CharacterStyleTemplate[id] + if not t or not t.HeadIcon then + XLog.ErrorTableDataNotFound("XDormConfig.GetCharacterStyleConfigQSIconById", "配置表项或者HeadIcon", TABLE_CHARACTER_STYLE_PATH, "id", tostring(id)) + return nil + end + + return t.HeadIcon +end + +-- 获取构造体性别类型 +function XDormConfig.GetCharacterStyleConfigSexById(id) + local t = CharacterStyleTemplate[id] + if not t or not t.Type then + XLog.ErrorTableDataNotFound("XDormConfig.GetCharacterStyleConfigSexById", "配置表项或者Type", TABLE_CHARACTER_STYLE_PATH, "id", tostring(id)) + return nil + end + + return t.Type +end + +function XDormConfig.GetCharacterNameConfigById(id) + local t = CharacterStyleTemplate[id] + if not t then + XLog.ErrorTableDataNotFound("XDormConfig.GetCharacterNameConfigById", "配置表项", TABLE_CHARACTER_STYLE_PATH, "id", tostring(id)) + return nil + end + + return t.Name +end + +-- 获取构造体爱抚配置表 +function XDormConfig.GetCharacterFondleByCharId(characterId) + local t = CharacterFondleTemplate[characterId] + if not t then + XLog.ErrorTableDataNotFound("XDormConfig.GetCharacterFondleByCharId", + "配置表项", TABLE_DORM_CHARACTER_FONDLE_PATH, "characterId", tostring(characterId)) + return nil + end + + return t +end + +-- 获取构造体爱总次数 +function XDormConfig.GetCharacterFondleCount(characterId) + local t = XDormConfig.GetCharacterFondleByCharId(characterId) + return t.MaxCount +end + +-- 获取构造体爱恢复一次时间 +function XDormConfig.GetCharacterFondleRecoveryTime(characterId) + local t = XDormConfig.GetCharacterFondleByCharId(characterId) + return t.RecoveryTime +end + +-- 获取构造体事件客户表现表 +function XDormConfig.GetCharacterShowEvent(id) + local t = ChaarcterShowEventTemplate[id] + if not t then + XLog.ErrorTableDataNotFound("XDormConfig.GetCharacterShowEvent", "配置表项", TABLE_SHOW_EVENT_PATH, "id", tostring(id)) + return nil + end + + return t +end + +-- 获取构造体事件状态 +function XDormConfig.GetCharacterShowEventState(id) + local t = XDormConfig.GetCharacterShowEvent(id) + return t.State +end + +-- 获取构造体心情状态 +function XDormConfig.GetMoodStateByMoodValue(moodValue) + local t + + for _, v in pairs(CharacterMoodTemplate) do + if moodValue > v.MoodMinValue and moodValue <= v.MoodMaxValue then + t = v + break + end + end + + if not t then + XLog.Error("XDormConfig.GetMoodStateByMoodValue 参数不符合规范,moodValue: " .. tostring(moodValue)) + return nil + end + + return t +end + +-- 获取构造体心情状态描述 +function XDormConfig.GetMoodStateDesc(moodValue) + local desc = "" + + for _, v in pairs(CharacterMoodTemplate) do + if moodValue > v.MoodMinValue and moodValue <= v.MoodMaxValue then + desc = v.Describe + break + end + end + + return desc +end + +-- 获取构造体心情状态颜色值 +function XDormConfig.GetMoodStateColor(moodValue) + local color = "FFFFFFFF" + + for _, v in pairs(CharacterMoodTemplate) do + if moodValue > v.MoodMinValue and moodValue <= v.MoodMaxValue then + color = v.Color + break + end + end + + return XUiHelper.Hexcolor2Color(color) +end + +-- 获取图纸商店跳转ID +function XDormConfig.GetDraftShopId() + return XDormConfig.DORM_DRAFT_SHOP_ID +end + + +--获取对话表 +function XDormConfig.GetCharacterDialog(charData, state) + + local charId = charData.CharacterId + + if not CharacterDialogStateIndex or not CharacterDialogStateIndex[charId] then + XLog.ErrorTableDataNotFound("XDormConfig.GetCharacterDialog", "配置表项", TABLE_CHARACTER_DIALOG_PATH, "charId", tostring(charId)) + return + end + + if not CharacterDialogStateIndex[charId][state] then + XLog.ErrorTableDataNotFound("XDormConfig.GetCharacterDialog", "配置表项或者state", TABLE_CHARACTER_DIALOG_PATH, "charId", tostring(charId)) + return + end + + local dialogList = CharacterDialogStateIndex[charId][state] + + if not dialogList then + return + end + + local fitterList = {} + + for _, v in ipairs(dialogList) do + if charData.Mood >= v.MoodMinValue and charData.Mood <= v.MoodMaxValue then + table.insert(fitterList, v) + end + end + + if #fitterList <= 0 then + return + end + + math.randomseed(os.time()) + local index = math.random(0, #fitterList) + + return fitterList[index] + +end + +--获取套装的音乐信息 +function XDormConfig.GetDormSuitBgmInfo(suitId) + for _, v in pairs(DormBgmTemplate) do + if v.SuitId == suitId then + return v + end + end + + return nil +end + +--获取背景音乐 +function XDormConfig.GetDormBgm(furnitureList) + local musicList = {} + + for _, v in pairs(DormBgmTemplate) do + if v.SuitId == -1 then + table.insert(musicList, v) + end + end + + + if not furnitureList then + return false, musicList + end + + + local suitDic = {} + for _, v in pairs(furnitureList) do + suitDic[v.SuitId] = suitDic[v.SuitId] or {} + local isExist = false + for _, id in ipairs(suitDic[v.SuitId]) do + if id == v.Id then + isExist = true + break + end + end + + if not isExist then + table.insert(suitDic[v.SuitId], v.Id) + end + end + + + for _, v in pairs(DormBgmTemplate) do + if suitDic[v.SuitId] and #suitDic[v.SuitId] >= v.SuitNum then + table.insert(musicList, v) + end + end + + + if #musicList <= 1 then + return false, musicList + end + + + table.sort(musicList, function(a, b) + return a.Order > b.Order + end) + + + return true, musicList +end + +-- 是否是模板宿舍 +function XDormConfig.IsTemplateRoom(dormDataType) + if dormDataType == XDormConfig.DormDataType.Template or + dormDataType == XDormConfig.DormDataType.Collect or + dormDataType == XDormConfig.DormDataType.CollectNone or + dormDataType == XDormConfig.DormDataType.Provisional then + return true + end + + return false +end + +-- 初始化宿舍模板列表 +local function InitDormTemplate() + DormTemplateData = {} + for _, v in pairs(DormTemplateCfg) do + DormTemplateData[v.Id] = XHomeRoomData.New(v.Id) + DormTemplateData[v.Id]:SetPlayerId(XPlayer.Id) + DormTemplateData[v.Id]:SetRoomName(v.Name) + DormTemplateData[v.Id]:SetRoomUnlock(true) + DormTemplateData[v.Id]:SetRoomDataType(XDormConfig.DormDataType.Template) + DormTemplateData[v.Id]:SetRoomOrder(v.Order) + DormTemplateData[v.Id]:SetRoomPicturePath(v.PicturePath) + + for i = 1, #v.FurnitureId do + if not v.FurniturePos[i] then + XLog.ErrorTableDataNotFound("InitDormTemplate", "FurniturePos", TABLE_DORM_TEMPLATE_PATH, "Id", tostring(v.Id)) + break + end + + local posList = string.Split(v.FurniturePos[i], "|") + if not posList then + XLog.ErrorTableDataNotFound("InitDormTemplate", "FurnitureId", TABLE_DORM_TEMPLATE_PATH, "Id", tostring(v.Id)) + break + end + + local id = XGlobalVar.GetIncId() + local x = posList[1] and tonumber(posList[1]) or 0 + local y = posList[2] and tonumber(posList[2]) or 0 + local r = posList[3] and tonumber(posList[3]) or 0 + DormTemplateData[v.Id]:AddFurniture(id, v.FurnitureId[i], x, y, r) + end + end +end + +function XDormConfig.GetDormTemplateData() + InitDormTemplate() + return DormTemplateData +end + +function XDormConfig.GetDormitoryTablePath() + return TABLE_DORMITORY_PATH +end +--=================== +--获取家具-角色行为对照关系配置 +--@param furnitureId:家具Id +--@param characterId:角色Id +--@param positionId:接触点序号(不填默认为1,只有1个接触点的家具接触点序号默认1) +--=================== +function XDormConfig.GetDormF2CBehaviorRelative(furnitureId, characterId, positionId) + local config = DormF2CRelationDic[furnitureId] + if not config then return nil end + if not config[characterId] then return nil end + return config[characterId][positionId or 1] +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XDrawConfigs.lua b/Resources/Scripts/XConfig/XDrawConfigs.lua new file mode 100644 index 00000000..f663ed2c --- /dev/null +++ b/Resources/Scripts/XConfig/XDrawConfigs.lua @@ -0,0 +1,259 @@ +local table = table +local tableInsert = table.insert + +XDrawConfigs = XDrawConfigs or {} + +XDrawConfigs.CombinationsTypes = { + Normal = 1, + Aim = 2, + NewUp = 3, + Furniture = 4, + CharacterUp = 5, + EquipSuit = 6, +} + +XDrawConfigs.DrawSetType = { + Normal = 1, + Destiny = 2, +} + +XDrawConfigs.RareRank = { + A = 1, + S = 2, +} + +XDrawConfigs.RuleType = { + Tab = 0, + Normal = 1, + Lotto = 2, +} + +XDrawConfigs.GroupType = { + Normal = 1, + Destiny = 2, +} + +--- +--- 卡池可掉落的奖励类型 +XDrawConfigs.DrawCapacityCheckType = +{ + Partner = 1 -- 伙伴 +} + +local TABLE_DRAW_PREVIEW = "Client/Draw/DrawPreview.tab" +local TABLE_DRAW_PREVIEW_GOODS = "Client/Draw/DrawPreviewGoods.tab" +local TABLE_DRAW_COMBINATIONS = "Client/Draw/DrawCombinations.tab" +local TABLE_DRAW_PROB = "Client/Draw/DrawProbShow.tab" +local TABLE_GROUP_RULE = "Client/Draw/DrawGroupRule.tab" +local TABLE_AIMPROBABILITY = "Client/Draw/DrawAimProbability.tab" +local TABLE_DRAW_SHOW = "Client/Draw/DrawShow.tab" +local TABLE_DRAW_NEWYEARSHOW = "Client/Draw/JPDrawNewYearShow.tab" +local TABLE_DRAW_CAMERA = "Client/Draw/DrawCamera.tab" +local TABLE_DRAW_TABS = "Client/Draw/DrawTabs.tab" +local TABLE_DRAW_SHOW_CHARACTER = "Client/Draw/DrawShowCharacter.tab" +local TABLE_DRAW_TYPE_CHANGE = "Client/Draw/DrawTypeChange.tab" +local TABLE_DRAW_SHOW_EFFECT = "Client/Draw/DrawShowEffect.tab" +local TABLE_DRAW_GROUP_RELATION = "Client/Draw/DrawGroupRelation.tab" +local TABLE_DRAW_SKIP = "Client/Draw/DrawSkip.tab" + +local DrawPreviews = {} +local DrawCombinations = {} +local DrawProbs = {} +local DrawGroupRule = {} +local DrawAimProbability = {} +local DrawShow = {} +local DrawShowEffect = {} +local DrawCamera = {} +local DrawTabs = {} +local DrawShowCharacter = {} +local DrawTypeChangeCfg = {} +local DrawSubGroupDic = {} +local DrawGroupRelationCfg = {} +local DrawGroupRelationDic = {} +local DrawSkipCfg = {} +local DrawNewYearShow = {} + +function XDrawConfigs.Init() + DrawCombinations = XTableManager.ReadByIntKey(TABLE_DRAW_COMBINATIONS, XTable.XTableDrawCombinations, "Id") + DrawGroupRule = XTableManager.ReadByIntKey(TABLE_GROUP_RULE, XTable.XTableDrawGroupRule, "Id") + DrawShow = XTableManager.ReadByIntKey(TABLE_DRAW_SHOW, XTable.XTableDrawShow, "Type") + DrawCamera = XTableManager.ReadByIntKey(TABLE_DRAW_CAMERA, XTable.XTableDrawCamera, "Id") + DrawTabs = XTableManager.ReadByIntKey(TABLE_DRAW_TABS, XTable.XTableDrawTabs, "Id") + DrawShowCharacter = XTableManager.ReadByIntKey(TABLE_DRAW_SHOW_CHARACTER, XTable.XTableDrawShowCharacter, "Id") + DrawAimProbability = XTableManager.ReadByIntKey(TABLE_AIMPROBABILITY, XTable.XTableDrawAimProbability, "Id") + DrawTypeChangeCfg = XTableManager.ReadByIntKey(TABLE_DRAW_TYPE_CHANGE, XTable.XTableDrawTypeChange, "MainGroupId") + DrawShowEffect = XTableManager.ReadByIntKey(TABLE_DRAW_SHOW_EFFECT, XTable.XTableDrawShowEffect, "EffectGroupId") + DrawGroupRelationCfg = XTableManager.ReadByIntKey(TABLE_DRAW_GROUP_RELATION, XTable.XTableDrawGroupRelation, "NormalGroupId") + DrawSkipCfg = XTableManager.ReadByIntKey(TABLE_DRAW_SKIP, XTable.XTableDrawSkip, "DrawGroupId") + DrawNewYearShow = XTableManager.ReadByIntKey(TABLE_DRAW_NEWYEARSHOW, XTable.XTableDrawNewYearActivityShow, "Type") + + local previews = XTableManager.ReadByIntKey(TABLE_DRAW_PREVIEW, XTable.XTableDrawPreview, "Id") + local previewGoods = XTableManager.ReadByIntKey(TABLE_DRAW_PREVIEW_GOODS, XTable.XTableRewardGoods, "Id") + + for drawId, preview in pairs(previews) do + local upGoodsIds = preview.UpGoodsId + local upGoods = {} + for i = 1, #upGoodsIds do + tableInsert(upGoods, XRewardManager.CreateRewardGoodsByTemplate(previewGoods[upGoodsIds[i]])) + end + + local goodsIds = preview.GoodsId + local goods = {} + for i = 1, #goodsIds do + tableInsert(goods, XRewardManager.CreateRewardGoodsByTemplate(previewGoods[goodsIds[i]])) + end + + local drawPreview = {} + drawPreview.UpGoods = upGoods + drawPreview.Goods = goods + DrawPreviews[drawId] = drawPreview + end + + local drawProbList = XTableManager.ReadByIntKey(TABLE_DRAW_PROB, XTable.XTableDrawProbShow, "Id") + for _, v in pairs(drawProbList) do + if not DrawProbs[v.DrawId] then + DrawProbs[v.DrawId] = {} + end + tableInsert(DrawProbs[v.DrawId], v) + end + + XDrawConfigs.SetDrawSubGroupDic() + XDrawConfigs.SetGroupRelationDic() +end + +function XDrawConfigs.SetDrawSubGroupDic() + for _,typeChangeGroup in pairs(DrawTypeChangeCfg or {}) do + for _,subGroupId in pairs(typeChangeGroup.SubGroupId or {}) do + if not DrawSubGroupDic[subGroupId] then + DrawSubGroupDic[subGroupId] = typeChangeGroup.MainGroupId + end + end + end +end + +function XDrawConfigs.SetGroupRelationDic() + DrawGroupRelationDic = {} + for _,data in pairs (DrawGroupRelationCfg)do + if not DrawGroupRelationDic[data.NormalGroupId] then + DrawGroupRelationDic[data.NormalGroupId] = data.DestinyGroupId + else + XLog.Error("Can Not Use Same GroupId for NormalGroupId .GroupId:"..data.NormalGroupId) + end + + if not DrawGroupRelationDic[data.DestinyGroupId] then + DrawGroupRelationDic[data.DestinyGroupId] = data.NormalGroupId + else + XLog.Error("Can Not Use Same GroupId for DestinyGroupId .GroupId:"..data.DestinyGroupId) + end + end +end + +function XDrawConfigs.GetDrawGroupRelationDic() + return DrawGroupRelationDic +end + +function XDrawConfigs.GetDrawCombinations() + return DrawCombinations +end + +function XDrawConfigs.GetDrawGroupRule() + return DrawGroupRule +end + +function XDrawConfigs.GetDrawAimProbability() + return DrawAimProbability +end + +function XDrawConfigs.GetDrawShow() + return DrawShow +end + +function XDrawConfigs.GetDrawNewYearShow() + return DrawNewYearShow +end + +--- +--- 获取'drawGroupId'卡组的跳转ID数组 +function XDrawConfigs.GetDrawSkipList(drawGroupId) + if DrawSkipCfg[drawGroupId] then + return DrawSkipCfg[drawGroupId].SkipId + end + return {} +end + +function XDrawConfigs.GetDrawShowCharacter() + return DrawShowCharacter +end + +function XDrawConfigs.GetDrawCamera() + return DrawCamera +end + +function XDrawConfigs.GetDrawTabs() + return DrawTabs +end + +function XDrawConfigs.GetDrawPreviews() + return DrawPreviews +end + +function XDrawConfigs.GetDrawProbs() + return DrawProbs +end + +function XDrawConfigs.GetDrawTypeChangeCfg() + return DrawTypeChangeCfg +end + +function XDrawConfigs.GetDrawGroupRelationCfg() + return DrawGroupRelationCfg +end + +function XDrawConfigs.GetDrawTypeChangeCfgById(id) + return DrawTypeChangeCfg[id] +end + +function XDrawConfigs.GetDrawSubGroupDic() + return DrawSubGroupDic +end + +function XDrawConfigs.GetDrawTabById(id) + if not DrawTabs[id] then + XLog.Error("Client/Draw/DrawTabs.tab Id = " .. id .. " Is Null") + end + return DrawTabs[id] +end + +function XDrawConfigs.GetDrawGroupRuleById(id) + if not DrawGroupRule[id] then + XLog.Error("Client/Draw/DrawGroupRule.tab Id = " .. id .. " Is Null") + end + return DrawGroupRule[id] +end + +function XDrawConfigs.GetDrawShowEffectById(id) + if not DrawShowEffect[id] then + XLog.Error("Client/Draw/DrawShowEffect.tab Id = " .. id .. " Is Null") + end + return DrawShowEffect[id] +end + +function XDrawConfigs.GetOpenUpEffect(id) + return XDrawConfigs.GetDrawShowEffectById(id).PanelOpenUp +end + +function XDrawConfigs.GetOpenDownEffect(id) + return XDrawConfigs.GetDrawShowEffectById(id).PanelOpenDown +end + +function XDrawConfigs.GetCardShowOffEffect(id) + return XDrawConfigs.GetDrawShowEffectById(id).PanelCardShowOff +end + +function XDrawConfigs.GetOpenBoxEffect(id) + return XDrawConfigs.GetDrawShowEffectById(id).EffectOpenBox +end + +function XDrawConfigs.GetSkipEffect(id) + return XDrawConfigs.GetDrawShowEffectById(id).SkipEffect +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XEliminateGameConfig.lua b/Resources/Scripts/XConfig/XEliminateGameConfig.lua new file mode 100644 index 00000000..509032d4 --- /dev/null +++ b/Resources/Scripts/XConfig/XEliminateGameConfig.lua @@ -0,0 +1,90 @@ +XEliminateGameConfig = XEliminateGameConfig or {} + + +local TABLE_ELIMINATEGAME_GAME = "Share/EliminateGame/EliminateGame.tab" +local TABLE_ELIMINATEGAME_GRID = "Share/EliminateGame/EliminateGrid.tab" +local TABLE_ELIMINATEGAME_REWARD = "Share/EliminateGame/EliminateReward.tab" +local TABLE_ELIMINATEGAME_GRID_TYPE = "Share/EliminateGame/EliminateGridType.tab" + +local EliminateGameConfig = {} +local EliminateGridConfig = {} +local EliminateRewardConfig = {} +local EliminateGridTypeConfig = {} + +function XEliminateGameConfig.Init() + EliminateGameConfig = XTableManager.ReadByIntKey(TABLE_ELIMINATEGAME_GAME, XTable.XTableEliminateGame, "Id") + EliminateGridConfig = XTableManager.ReadByIntKey(TABLE_ELIMINATEGAME_GRID, XTable.XTableEliminateGrid, "Id") + EliminateRewardConfig = XTableManager.ReadByIntKey(TABLE_ELIMINATEGAME_REWARD, XTable.XTableEliminateReward, "Id") + EliminateGridTypeConfig = XTableManager.ReadByIntKey(TABLE_ELIMINATEGAME_GRID_TYPE, XTable.XTableEliminateGridType, "Id") +end + + +--获取消除游戏 +function XEliminateGameConfig.GetEliminateGame(id) + if not EliminateGameConfig or not EliminateGameConfig[id] then + XLog.ErrorTableDataNotFound("XEliminateGameConfig.GetEliminateGame", "Id", TABLE_ELIMINATEGAME_GAME, "id", tostring(id)) + return nil + end + + return EliminateGameConfig[id] +end + + +--获取消除游戏格子 +function XEliminateGameConfig.GetEliminateGameGrid(id) + if not EliminateGridConfig or not EliminateGridConfig[id] then + XLog.ErrorTableDataNotFound("XEliminateGameConfig.GetEliminateGameGrid", "Id", TABLE_ELIMINATEGAME_GRID, "id", tostring(id)) + return nil + end + + return EliminateGridConfig[id] +end + + +--获取消除游戏奖励 +function XEliminateGameConfig.GetEliminateGameReward(id) + if not EliminateRewardConfig or not EliminateRewardConfig[id] then + XLog.ErrorTableDataNotFound("XEliminateGameConfig.GetEliminateGameReward", "Id", TABLE_ELIMINATEGAME_REWARD, "id", tostring(id)) + return nil + end + + return EliminateRewardConfig[id] +end + + +--获取格子 +function XEliminateGameConfig.GetEliminateGameGridByType(typeId) + if not EliminateGridTypeConfig then + XLog.ErrorTableDataNotFound("XEliminateGameConfig.GetEliminateGameGridByType", "Id", TABLE_ELIMINATEGAME_GRID_TYPE, "typeId", tostring(typeId)) + return nil + end + + for i, v in pairs(EliminateGridTypeConfig) do + if v.Type == typeId then + return v + end + end + + return nil +end + + +-- --获取格子 +-- function XEliminateGameConfig.GetEliminateGameGridById(id) +-- if not EliminateGridTypeConfig or not EliminateGridTypeConfig[id] then +-- XLog.ErrorTableDataNotFound("XEliminateGameConfig.GetEliminateGameGridById", "Id", TABLE_ELIMINATEGAME_GRID_TYPE, "id", tostring(id)) +-- return nil +-- end +-- return EliminateGridTypeConfig[id] +-- end +--获取消除游戏奖励 +function XEliminateGameConfig.GetEliminateGameRewardByGameId(id) + local rewards = {} + for _, v in pairs(EliminateRewardConfig) do + if v.GameId == id then + table.insert(rewards, v) + end + end + + return rewards +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XEquipConfig.lua b/Resources/Scripts/XConfig/XEquipConfig.lua new file mode 100644 index 00000000..bbadda2f --- /dev/null +++ b/Resources/Scripts/XConfig/XEquipConfig.lua @@ -0,0 +1,957 @@ +local tableInsert = table.insert + +XEquipConfig = XEquipConfig or {} + +XEquipConfig.MAX_STAR_COUNT = 6 -- 最大星星数 +XEquipConfig.MAX_SUIT_SKILL_COUNT = 3 -- 最大套装激活技能个数 +XEquipConfig.MAX_RESONANCE_SKILL_COUNT = 3 -- 最大共鸣属性/技能个数 +XEquipConfig.MIN_RESONANCE_EQUIP_STAR_COUNT = 5 -- 装备共鸣最低星级 +XEquipConfig.MAX_SUIT_COUNT = 6 -- 套装最大数量 +XEquipConfig.DEFAULT_SUIT_ID = { -- 用来显示全部套装数量的默认套装Id + Normal = 1, --构造体 + Isomer = 2, --感染体 +} +XEquipConfig.CAN_NOT_AUTO_EAT_STAR = 5 -- 大于等于该星级的装备不会被当做默认狗粮选中 +XEquipConfig.AWAKE_SKILL_COUNT = 2 -- 觉醒技能数量 + +--武器类型 +XEquipConfig.EquipType = { + Universal = 0, -- 通用 + Suncha = 1, -- 双枪 + Sickle = 2, -- 太刀 + Mount = 3, -- 挂载 + Arrow = 4, -- 弓箭 + Chainsaw = 5, -- 电锯 + Sword = 6, -- 大剑 + Hcan = 7, -- 巨炮 + DoubleSwords = 8, -- 双短刀 + sickle = 9, --镰刀 + IsomerSword = 10, -- 感染者专用大剑 + Food = 99, -- 狗粮 +} + +XEquipConfig.UserType = { + All = 0, --通用 + Normal = 1, --构造体 + Isomer = 2, --异构体/感染体 +} + +XEquipConfig.AddAttrType = { + Numeric = 1, -- 数值 + Rate = 2, -- 基础属性的百分比 + Promoted = 3, -- 等级加成 +} + +XEquipConfig.UserType = { + All = 0, --通用 + Normal = 1, --构造体 + Isomer = 2, --异构体/感染体 +} + +--要显示的属性排序 +XEquipConfig.AttrSortType = { + XNpcAttribType.Life, + XNpcAttribType.AttackNormal, + XNpcAttribType.DefenseNormal, + XNpcAttribType.Crit, +} + +XEquipConfig.EquipSite = { + Weapon = 0, -- 武器 + Awareness = { -- 意识 + One = 1, -- 1号位 + Two = 2, -- 2号位 + Three = 3, -- 3号位 + Four = 4, -- 4号位 + Five = 5, -- 5号位 + Six = 6, -- 6号位 + }, +} + +XEquipConfig.AwarenessSiteToStr = { + [XEquipConfig.EquipSite.Awareness.One] = CS.XTextManager.GetText("AwarenessSiteOne"), + [XEquipConfig.EquipSite.Awareness.Two] = CS.XTextManager.GetText("AwarenessSiteTwo"), + [XEquipConfig.EquipSite.Awareness.Three] = CS.XTextManager.GetText("AwarenessSiteThree"), + [XEquipConfig.EquipSite.Awareness.Four] = CS.XTextManager.GetText("AwarenessSiteFour"), + [XEquipConfig.EquipSite.Awareness.Five] = CS.XTextManager.GetText("AwarenessSiteFive"), + [XEquipConfig.EquipSite.Awareness.Six] = CS.XTextManager.GetText("AwarenessSiteSix"), +} + +XEquipConfig.Classify = { + Weapon = 1, -- 武器 + Awareness = 2, -- 意识 +} + +XEquipConfig.EquipResonanceType = { + Attrib = 1, -- 属性共鸣 + CharacterSkill = 2, -- 角色技能共鸣 + WeaponSkill = 3, -- 武器技能共鸣 +} + +--排序优先级选项 +XEquipConfig.PriorSortType = { + Star = 0, -- 星级 + Breakthrough = 1, -- 突破次数 + Level = 2, -- 等级 + Proceed = 3, -- 入手顺序 +} + +-- 武器部位 +XEquipConfig.WeaponCase = { + Case1 = 1, + Case2 = 2, + Case3 = 3, +--[[支持继续扩展 + Case4 = 4, + ... +]] +} + +-- 狗粮类型 +XEquipConfig.EatType = { + Equip = 0, + Item = 1, +} + +-- 武器模型用途 +XEquipConfig.WeaponUsage = { + Role = 1, -- ui角色身上 + Battle = 2, -- 战斗 + Show = 3, -- ui单独展示 +} + +-- 装备详情UI页签 +XEquipConfig.EquipDetailBtnTabIndex = { + Detail = 1, + Strengthen = 2, + Resonance = 3, +} + +--武器超频界面页签状态 +XEquipConfig.EquipAwakeTabIndex = { + Material = 1, + CrystalMoney = 2, +} + +-- 共鸣后武器显示延时时间 +XEquipConfig.WeaponResonanceShowDelay = CS.XGame.ClientConfig:GetInt("WeaponResonanceShowDelay") + +-- 分解数量溢出提示文本 +XEquipConfig.DecomposeRewardOverLimitTip = { + [XEquipConfig.Classify.Weapon] = CS.XTextManager.GetText("WeaponBoxWillBeFull"), + [XEquipConfig.Classify.Awareness] = CS.XTextManager.GetText("WaferBoxWillBeFull"), +} + +local EquipBreakThroughIcon = { + [0] = CS.XGame.ClientConfig:GetString("EquipBreakThrough0"), + [1] = CS.XGame.ClientConfig:GetString("EquipBreakThrough1"), + [2] = CS.XGame.ClientConfig:GetString("EquipBreakThrough2"), + [3] = CS.XGame.ClientConfig:GetString("EquipBreakThrough3"), + [4] = CS.XGame.ClientConfig:GetString("EquipBreakThrough4"), +} + +local EquipBreakThroughSmallIcon = { + [1] = CS.XGame.ClientConfig:GetString("EquipBreakThroughSmall1"), + [2] = CS.XGame.ClientConfig:GetString("EquipBreakThroughSmall2"), + [3] = CS.XGame.ClientConfig:GetString("EquipBreakThroughSmall3"), + [4] = CS.XGame.ClientConfig:GetString("EquipBreakThroughSmall4"), +} + +local EquipBreakThroughBigIcon = { + [0] = CS.XGame.ClientConfig:GetString("EquipBreakThroughBig0"), + [1] = CS.XGame.ClientConfig:GetString("EquipBreakThroughBig1"), + [2] = CS.XGame.ClientConfig:GetString("EquipBreakThroughBig2"), + [3] = CS.XGame.ClientConfig:GetString("EquipBreakThroughBig3"), + [4] = CS.XGame.ClientConfig:GetString("EquipBreakThroughBig4"), +} + +-- 共鸣图标(觉醒后图标变更) +local EquipResonanceIconPath = { + [true] = CS.XGame.ClientConfig:GetString("EquipAwakenIcon"), + [false] = CS.XGame.ClientConfig:GetString("EquipResonanceIcon"), +} + +local TABLE_EQUIP_PATH = "Share/Equip/Equip.tab" +local TABLE_EQUIP_BREAKTHROUGH_PATH = "Share/Equip/EquipBreakThrough.tab" +local TABLE_EQUIP_SUIT_PATH = "Share/Equip/EquipSuit.tab" +local TABLE_EQUIP_SUIT_EFFECT_PATH = "Share/Equip/EquipSuitEffect.tab" +local TABLE_LEVEL_UP_TEMPLATE_PATH = "Share/Equip/LevelUpTemplate/" +local TABLE_EQUIP_DECOMPOSE_PATH = "Share/Equip/EquipDecompose.tab" +local TABLE_EAT_EQUIP_COST_PATH = "Share/Equip/EatEquipCost.tab" +local TABLE_EQUIP_RESONANCE_PATH = "Share/Equip/EquipResonance.tab" +local TABLE_EQUIP_RESONANCE_CONSUME_ITEM_PATH = "Share/Equip/EquipResonanceUseItem.tab" +local TABLE_WEAPON_SKILL_PATH = "Share/Equip/WeaponSkill.tab" +local TABLE_WEAPON_SKILL_POOL_PATH = "Share/Equip/WeaponSkillPool.tab" +local TABLE_EQUIP_AWAKE_PATH = "Share/Equip/EquipAwake.tab" +local TABLE_EQUIP_RES_PATH = "Client/Equip/EquipRes.tab" +local TABLE_EQUIP_MODEL_PATH = "Client/Equip/EquipModel.tab" +local TABLE_EQUIP_MODEL_TRANSFORM_PATH = "Client/Equip/EquipModelTransform.tab" +local TABLE_EQUIP_SKIPID_PATH = "Client/Equip/EquipSkipId.tab" +local TABLE_EQUIP_ANIM_PATH = "Client/Equip/EquipAnim.tab" + +local MAX_WEAPON_COUNT -- 武器拥有最大数量 +local MAX_AWARENESS_COUNT -- 意识拥有最大数量 +local EQUIP_EXP_INHERIT_PRECENT -- 强化时的经验继承百分比 +local EQUIP_RECYCLE_ITEM_PERCENT -- 回收获得道具数量百分比 +local MIN_RESONANCE_BIND_STAR -- 只有6星以上的意识才可以共鸣出绑定角色的技能 +local MIN_AWAKE_STAR -- 最低可觉醒星数 + +local EquipTemplates = {} -- 装备配置 +local EquipBreakthroughTemplate = {} -- 突破配置 +local EquipResonanceTemplate = {} -- 共鸣配置 +local EquipResonanceConsumeItemTemplates = {} -- 共鸣消耗物品配置 +local LevelUpTemplates = {} -- 升级模板 +local EquipSuitTemplate = {} -- 套装技能表 +local EquipSuitEffectTemplate = {} -- 套装效果表 +local WeaponSkillTemplate = {} -- 武器技能配置 +local WeaponSkillPoolTemplate = {} -- 武器技能池(共鸣用)配置 +local EatEquipCostTemplate = {} -- 装备强化消耗配置 +local EquipResTemplates = {} -- 装备资源配置 +local EquipModelTemplates = {} -- 武器模型配置 +local EquipModelTransformTemplates = {} -- 武器模型UI偏移配置 +local EquipSkipIdTemplates = {} -- 装备来源跳转ID配置 +local EquipAwakeTemplate = {} -- 觉醒配置 +local EquipAnimTemplates = {} -- 动画配置 + +local EquipBorderDic = {} -- 装备边界属性构造字典 +local EquipDecomposeDic = {} +local SuitIdToEquipTemplateIdsDic = {} -- 套装Id索引的装备Id字典 +local SuitSitesDic = {} -- 套装产出部位字典 + +--记录超频界面的页签状态 +local EquipAwakeTabIndex = XEquipConfig.EquipAwakeTabIndex.Material + +local CompareBreakthrough = function(templateId, breakthrough) + local template = EquipBorderDic[templateId] + if not template then + return + end + + if not template.MaxBreakthrough or template.MaxBreakthrough < breakthrough then + template.MaxBreakthrough = breakthrough + end +end + +local CheckEquipBorderConfig = function() + for k, v in pairs(EquipBorderDic) do + local template = EquipBorderDic[k] + template.MinLevel = 1 + local equipBreakthroughCfg = XEquipConfig.GetEquipBreakthroughCfg(k, v.MaxBreakthrough) + template.MaxLevel = equipBreakthroughCfg.LevelLimit + template.MinBreakthrough = 0 + end +end + +local InitEquipBreakthroughConfig = function() + local tab = XTableManager.ReadByIntKey(TABLE_EQUIP_BREAKTHROUGH_PATH, XTable.XTableEquipBreakthrough, "Id") + for _, config in pairs(tab) do + if not EquipBreakthroughTemplate[config.EquipId] then + EquipBreakthroughTemplate[config.EquipId] = {} + end + + if config.AttribPromotedId == 0 then + XLog.ErrorTableDataNotFound("InitEquipBreakthroughConfig", "EquipBreakthroughTemplate", + TABLE_EQUIP_BREAKTHROUGH_PATH, "config.EquipId", tostring(config.EquipId)) + end + + EquipBreakthroughTemplate[config.EquipId][config.Times] = config + CompareBreakthrough(config.EquipId, config.Times) + end +end + +local InitEquipLevelConfig = function() + local paths = CS.XTableManager.GetPaths(TABLE_LEVEL_UP_TEMPLATE_PATH) + XTool.LoopCollection(paths, function(path) + local key = tonumber(XTool.GetFileNameWithoutExtension(path)) + LevelUpTemplates[key] = XTableManager.ReadByIntKey(path, XTable.XTableEquipLevelUp, "Level") + end) +end + +local InitWeaponSkillPoolConfig = function() + local tab = XTableManager.ReadByIntKey(TABLE_WEAPON_SKILL_POOL_PATH, XTable.XTableWeaponSkillPool, "Id") + for _, config in pairs(tab) do + WeaponSkillPoolTemplate[config.PoolId] = WeaponSkillPoolTemplate[config.PoolId] or {} + WeaponSkillPoolTemplate[config.PoolId][config.CharacterId] = WeaponSkillPoolTemplate[config.PoolId][config.CharacterId] or {} + + for i, skillId in ipairs(config.SkillId) do + tableInsert(WeaponSkillPoolTemplate[config.PoolId][config.CharacterId], skillId) + end + end +end + +local InitEquipModelTransformConfig = function() + local tab = XTableManager.ReadByIntKey(TABLE_EQUIP_MODEL_TRANSFORM_PATH, XTable.XTableEquipModelTransform, "Id") + for id, config in pairs(tab) do + local indexId = config.IndexId + if not indexId then + XLog.ErrorTableDataNotFound("InitEquipModelTransformConfig", "tab", TABLE_EQUIP_MODEL_TRANSFORM_PATH, "id", tostring(id)) + end + EquipModelTransformTemplates[indexId] = EquipModelTransformTemplates[indexId] or {} + + local uiName = config.UiName + if not uiName then + XLog.ErrorTableDataNotFound("InitEquipModelTransformConfig", "配置表中UiName字段", TABLE_EQUIP_MODEL_TRANSFORM_PATH, "id", tostring(id)) + end + EquipModelTransformTemplates[indexId][uiName] = config + end +end + +local InitEquipSkipIdConfig = function() + local tab = XTableManager.ReadByIntKey(TABLE_EQUIP_SKIPID_PATH, XTable.XTableEquipSkipId, "Id") + for id, config in pairs(tab) do + local eatType = config.EatType + EquipSkipIdTemplates[eatType] = EquipSkipIdTemplates[eatType] or {} + + local site = config.Site + if not site then + XLog.ErrorTableDataNotFound("InitEquipSkipIdConfig", "配置表中Site字段", TABLE_EQUIP_SKIPID_PATH, "id", tostring(id)) + end + EquipSkipIdTemplates[eatType][site] = config + end +end + +local InitEquipSuitConfig = function() + EquipSuitTemplate = XTableManager.ReadByIntKey(TABLE_EQUIP_SUIT_PATH, XTable.XTableEquipSuit, "Id") + EquipSuitEffectTemplate = XTableManager.ReadByIntKey(TABLE_EQUIP_SUIT_EFFECT_PATH, XTable.XTableEquipSuitEffect, "Id") +end + +function XEquipConfig.Init() + MAX_WEAPON_COUNT = CS.XGame.Config:GetInt("EquipWeaponMaxCount") + MAX_AWARENESS_COUNT = CS.XGame.Config:GetInt("EquipChipMaxCount") + EQUIP_EXP_INHERIT_PRECENT = CS.XGame.Config:GetInt("EquipExpInheritPercent") + EQUIP_RECYCLE_ITEM_PERCENT = CS.XGame.Config:GetInt("EquipRecycleItemPercent") + MIN_RESONANCE_BIND_STAR = CS.XGame.Config:GetInt("MinResonanceBindStar") + MIN_AWAKE_STAR = CS.XGame.Config:GetInt("MinEquipAwakeStar") + + EquipTemplates = CS.XNpcManager.EquipTemplateTable + EquipResTemplates = XTableManager.ReadByIntKey(TABLE_EQUIP_RES_PATH, XTable.XTableEquipRes, "Id") + EquipAwakeTemplate = XTableManager.ReadByIntKey(TABLE_EQUIP_AWAKE_PATH, XTable.XTableEquipAwake, "Id") + XTool.LoopMap(EquipTemplates, function(id, equipCfg) + EquipBorderDic[id] = {} + local suitId = equipCfg.SuitId + if suitId and suitId > 0 then + SuitIdToEquipTemplateIdsDic[suitId] = SuitIdToEquipTemplateIdsDic[suitId] or {} + tableInsert(SuitIdToEquipTemplateIdsDic[suitId], id) + + SuitSitesDic[suitId] = SuitSitesDic[suitId] or {} + SuitSitesDic[suitId][equipCfg.Site] = true + end + end) + + InitEquipSuitConfig() + InitEquipBreakthroughConfig() + InitEquipLevelConfig() + InitWeaponSkillPoolConfig() + InitEquipModelTransformConfig() + InitEquipSkipIdConfig() + + CheckEquipBorderConfig() + + EquipBorderDic = XReadOnlyTable.Create(EquipBorderDic) + WeaponSkillTemplate = XTableManager.ReadByIntKey(TABLE_WEAPON_SKILL_PATH, XTable.XTableWeaponSkill, "Id") + EquipResonanceTemplate = XTableManager.ReadByIntKey(TABLE_EQUIP_RESONANCE_PATH, XTable.XTableEquipResonance, "Id") + EquipResonanceConsumeItemTemplates = XTableManager.ReadByIntKey(TABLE_EQUIP_RESONANCE_CONSUME_ITEM_PATH, XTable.XTableEquipResonanceUseItem, "Id") + EquipModelTemplates = XTableManager.ReadByIntKey(TABLE_EQUIP_MODEL_PATH, XTable.XTableEquipModel, "Id") + EquipAnimTemplates = XTableManager.ReadByStringKey(TABLE_EQUIP_ANIM_PATH, XTable.XTableEquipAnim, "ModelId") + + local decomposetab = XTableManager.ReadByIntKey(TABLE_EQUIP_DECOMPOSE_PATH, XTable.XTableEquipDecompose, "Id") + for _, v in pairs(decomposetab) do + EquipDecomposeDic[v.Site .. v.Star .. v.Breakthrough] = v + end + + local eatCostTab = XTableManager.ReadByIntKey(TABLE_EAT_EQUIP_COST_PATH, XTable.XTableEatEquipCost, "Id") + for _, v in pairs(eatCostTab) do + EatEquipCostTemplate[v.Site .. v.Star] = v.UseMoney + end +end + +function XEquipConfig.GetMaxWeaponCount() + return MAX_WEAPON_COUNT +end + +function XEquipConfig.GetMaxAwarenessCount() + return MAX_AWARENESS_COUNT +end + +function XEquipConfig.GetEquipExpInheritPercent() + return EQUIP_EXP_INHERIT_PRECENT +end + +function XEquipConfig.GetEquipRecycleItemId() + return XDataCenter.ItemManager.ItemId.EquipRecycleItemId +end + +function XEquipConfig.GetEquipRecycleItemPercent() + return EQUIP_RECYCLE_ITEM_PERCENT / 100 +end + +function XEquipConfig.GetMinResonanceBindStar() + return MIN_RESONANCE_BIND_STAR +end + +function XEquipConfig.GetMinAwakeStar() + return MIN_AWAKE_STAR +end + +function XEquipConfig.GetEquipCfg(templateId) + local equipCfg = nil + + if EquipTemplates:ContainsKey(templateId) then + equipCfg = EquipTemplates[templateId] + end + + if not equipCfg then + XLog.ErrorTableDataNotFound("XEquipConfig.GetEquipCfg", "equipCfg", TABLE_EQUIP_PATH, "templateId", tostring(templateId)) + return + end + + return equipCfg +end + +--todo 道具很多地方没有检查ID类型就调用了,临时处理下 +function XEquipConfig.CheckTemplateIdIsEquip(templateId) + local equipCfg = nil + + if EquipTemplates:ContainsKey(templateId) then + equipCfg = EquipTemplates[templateId] + end + + return templateId and equipCfg +end + +function XEquipConfig.GetEatEquipCostMoney(site, star) + if not site then + XLog.Error("XEquipConfig.GetEatEquipCostMoney函数参数错误,site不能为空") + return + end + if not star then + XLog.Error("XEquipConfig.GetEatEquipCostMoney函数参数错误,star不能为空") + return + end + + return EatEquipCostTemplate[site .. star] +end + +function XEquipConfig.GetEquipBorderCfg(templateId) + local template = EquipBorderDic[templateId] + if not template then + XLog.ErrorTableDataNotFound("XEquipConfig.GetEquipBorderCfg", "template", TABLE_EQUIP_PATH, "templateId", tostring(templateId)) + return + end + return template +end + +function XEquipConfig.GetEquipBreakthroughCfg(templateId, times) + local template = EquipBreakthroughTemplate[templateId] + if not template then + XLog.ErrorTableDataNotFound("XEquipConfig.GetEquipBreakthroughCfg", "template", + TABLE_EQUIP_BREAKTHROUGH_PATH, "templateId", tostring(templateId)) + return + end + + template = template[times] + if not template then + XLog.ErrorTableDataNotFound("XEquipConfig.GetEquipBreakthroughCfg", "template", + TABLE_EQUIP_BREAKTHROUGH_PATH, "templateId : times", tostring(templateId) .. " : " .. tostring(times)) + return + end + + return template +end + +function XEquipConfig.GetEquipResCfg(templateId, breakthroughTimes) + breakthroughTimes = breakthroughTimes or 0 + local breakthroughCfg = XEquipConfig.GetEquipBreakthroughCfg(templateId, breakthroughTimes) + + local resId = breakthroughCfg.ResId + if not resId then + XLog.ErrorTableDataNotFound("XEquipConfig.GetEquipResCfg", "resId", + TABLE_EQUIP_BREAKTHROUGH_PATH, "templateId : times", tostring(templateId) .. " : " .. tostring(breakthroughTimes)) + return + end + + local template = EquipResTemplates[resId] + if not template then + XLog.ErrorTableDataNotFound("XEquipConfig.GetEquipResCfg", "template", TABLE_EQUIP_RES_PATH, "resId", tostring(resId)) + return + end + + return template +end + +--=========== EquipModel接口(begin) =========== +function XEquipConfig.GetEquipModelName(modelTransId, usage) + local template = EquipModelTemplates[modelTransId] + + if not template then + XLog.ErrorTableDataNotFound("XEquipConfig.GetEquipModelName", "template", TABLE_EQUIP_MODEL_PATH, "modelTransId", tostring(modelTransId)) + return + end + + usage = usage or XEquipConfig.WeaponUsage.Role + return template.ModelName[usage] or template.ModelName[XEquipConfig.WeaponUsage.Role] +end + +function XEquipConfig.GetEquipAnimController(modelTransId, usage) + local template = EquipModelTemplates[modelTransId] + + if not template then + XLog.ErrorTableDataNotFound("XEquipConfig.GetEquipAnimController", "template", TABLE_EQUIP_MODEL_PATH, "modelTransId", tostring(modelTransId)) + return + end + + usage = usage or XEquipConfig.WeaponUsage.Role + + local controller = template.AnimController[usage] + if not controller and usage ~= XEquipConfig.WeaponUsage.Show then -- 单独展示不需默认值 + controller = template.AnimController[XEquipConfig.WeaponUsage.Role] + end + return controller +end + +function XEquipConfig.GetEquipUiAnimStateName(modelTransId, usage) + local template = EquipModelTemplates[modelTransId] + if not template then + XLog.ErrorTableDataNotFound("XEquipConfig.GetEquipUiAnimStateName", "template", TABLE_EQUIP_MODEL_PATH, "modelTransId", tostring(modelTransId)) + return + end + + usage = usage or XEquipConfig.WeaponUsage.Role + return template.UiAnimStateName[usage] or template.UiAnimStateName[XEquipConfig.WeaponUsage.Role] +end + +function XEquipConfig.GetEquipUiAnimCueId(modelTransId, usage) + local template = EquipModelTemplates[modelTransId] + if not template then + XLog.ErrorTableDataNotFound("XEquipConfig.GetEquipUiAnimCueId", "template", TABLE_EQUIP_MODEL_PATH, "modelTransId", tostring(modelTransId)) + return + end + + usage = usage or XEquipConfig.WeaponUsage.Role + return template.UiAnimCueId[usage] or template.UiAnimCueId[XEquipConfig.WeaponUsage.Role] +end + +function XEquipConfig.GetEquipUiAnimDelay(modelTransId, usage) + local template = EquipModelTemplates[modelTransId] + if not template then + XLog.ErrorTableDataNotFound("XEquipConfig.GetEquipUiAnimDelay", "template", TABLE_EQUIP_MODEL_PATH, "modelTransId", tostring(modelTransId)) + return + end + + usage = usage or XEquipConfig.WeaponUsage.Role + return template.UiAnimDelay[usage] or template.UiAnimDelay[XEquipConfig.WeaponUsage.Role] +end + +function XEquipConfig.GetEquipUiAutoRotateDelay(modelTransId, usage) + local template = EquipModelTemplates[modelTransId] + if not template then + XLog.ErrorTableDataNotFound("XEquipConfig.GetEquipUiAutoRotateDelay", "template", TABLE_EQUIP_MODEL_PATH, "modelTransId", tostring(modelTransId)) + return + end + + usage = usage or XEquipConfig.WeaponUsage.Show -- 默认ui展示 + return template.UiAutoRotateDelay[usage] or template.UiAutoRotateDelay[XEquipConfig.WeaponUsage.Role] +end + +function XEquipConfig.GetEquipModelEffectPath(modelTransId, usage) + local template = EquipModelTemplates[modelTransId] + + if not template then + XLog.ErrorTableDataNotFound("XEquipConfig.GetEquipModelEffectPath", "template", TABLE_EQUIP_MODEL_PATH, "modelTransId", tostring(modelTransId)) + return + end + + usage = usage or XEquipConfig.WeaponUsage.Role + return template.ResonanceEffectPath[usage] or template.ResonanceEffectPath[XEquipConfig.WeaponUsage.Role] +end +--=========== EquipModel接口(end) =========== +function XEquipConfig.GetEquipAnimParams(roleModelId) + local template = EquipAnimTemplates[roleModelId] + if not template then + return 0 + end + return template.Params or 0 +end + +function XEquipConfig.GetWeaponResonanceModelId(case, templateId, resonanceCount) + local modelId + local template = EquipResTemplates[templateId] + if not template then + XLog.ErrorTableDataNotFound("XEquipConfig.GetWeaponResonanceModelId", "template", TABLE_EQUIP_RES_PATH, "templateId", tostring(templateId)) + return + end + if resonanceCount == 1 then + modelId = template.ResonanceModelTransId1[case] + elseif resonanceCount == 2 then + modelId = template.ResonanceModelTransId2[case] + elseif resonanceCount == 3 then + modelId = template.ResonanceModelTransId3[case] + end + return modelId or template.ModelTransId[case] +end + +function XEquipConfig.GetWeaponResonanceEffectDelay(modelTransId) + local template = EquipModelTemplates[modelTransId] + + if not template then + XLog.ErrorTableDataNotFound("XEquipConfig.GetWeaponResonanceEffectDelay", + "template", TABLE_EQUIP_MODEL_PATH, "modelTransId", tostring(modelTransId)) + return + end + + return template.ResonanceEffectShowDelay[XEquipConfig.WeaponUsage.Show] or 0 +end + +--返回武器模型和位置配置(双枪只返回一把) +function XEquipConfig.GetEquipModelTransformCfg(templateId, uiName, resonanceCount, modelTransId, equipType) + local modelCfg, template + + --尝试用ModelTransId索引 + if not modelTransId then + modelTransId = XEquipConfig.GetWeaponResonanceModelId(XEquipConfig.WeaponCase.Case1, templateId, resonanceCount) + if not modelTransId then + XLog.ErrorTableDataNotFound("XEquipConfig.GetWeaponResonanceModelId", + "template", TABLE_EQUIP_RES_PATH, "templateId", tostring(templateId)) + return + end + end + + template = EquipModelTransformTemplates[modelTransId] + if template then + modelCfg = template[uiName] + end + + --读不到配置时用equipType索引 + if not modelCfg then + if not equipType then + local equipCfg = XEquipConfig.GetEquipCfg(templateId) + equipType = equipCfg.Type + end + + template = EquipModelTransformTemplates[equipType] + if not template then + XLog.ErrorTableDataNotFound("XEquipConfig.GetEquipModelTransformCfg", + "template", TABLE_EQUIP_MODEL_TRANSFORM_PATH, "equipType", tostring(equipType)) + return + end + + modelCfg = template[uiName] + if not modelCfg then + XLog.ErrorTableDataNotFound("XEquipConfig.GetEquipModelTransformCfg", + "uiName", TABLE_EQUIP_MODEL_TRANSFORM_PATH, "equipType", tostring(equipType)) + return + end + end + + return modelCfg +end + + +-- 获取一个武器所有的不同的模型列表 +function XEquipConfig.GetWeaponModelCfgList(templateId, uiName, breakthroughTimes) + local modelCfgList = {} + + if not templateId then + XLog.Error("XEquipManager.GetWeaponModelCfgList函数参数错误, templateId不能为空") + return modelCfgList + end + + local template = XEquipConfig.GetEquipResCfg(templateId, breakthroughTimes) + -- 目前只有共鸣改变形态,有可能有相同的模型,所以需要区别是否有相同的id,以左手id为准 + local resonanceCountList = {} + local resonanceDic = {} + local modelId + for i = 0, XEquipConfig.MAX_RESONANCE_SKILL_COUNT do + modelId = XEquipConfig.GetWeaponResonanceModelId(XEquipConfig.WeaponCase.Case1, template.Id, i) + if modelId and not resonanceDic[modelId] then + resonanceDic[modelId] = true + table.insert(resonanceCountList, i) + end + end + + local modelCfg + for _, resonanceCount in ipairs(resonanceCountList) do + modelCfg = {} + modelCfg.ModelId = XEquipConfig.GetWeaponResonanceModelId(XEquipConfig.WeaponCase.Case1, template.Id, resonanceCount) + modelCfg.TransformConfig = XEquipConfig.GetEquipModelTransformCfg(templateId, uiName, resonanceCount) + table.insert(modelCfgList, modelCfg) + end + + return modelCfgList +end + +function XEquipConfig.GetLevelUpCfg(templateId, times, level) + local breakthroughCfg = XEquipConfig.GetEquipBreakthroughCfg(templateId, times) + if not breakthroughCfg then + return + end + + templateId = breakthroughCfg.LevelUpTemplateId + + local template = LevelUpTemplates[templateId] + if not template then + XLog.ErrorTableDataNotFound("XEquipConfig.GetLevelUpCfg", "template", TABLE_LEVEL_UP_TEMPLATE_PATH, "templateId", tostring(templateId)) + return + end + + template = template[level] + if not template then + XLog.ErrorTableDataNotFound("XEquipConfig.GetLevelUpCfg", "level", TABLE_LEVEL_UP_TEMPLATE_PATH, "templateId", tostring(templateId)) + return + end + + return template +end + +function XEquipConfig.GetEquipSuitCfg(templateId) + local template = EquipSuitTemplate[templateId] + if not template then + XLog.ErrorTableDataNotFound("XEquipConfig.GetEquipSuitCfg", "template", TABLE_EQUIP_SUIT_PATH, "templateId", tostring(templateId)) + return + end + return template +end + +function XEquipConfig.GetEquipSuitEffectCfg(templateId) + local template = EquipSuitEffectTemplate[templateId] + if not template then + XLog.ErrorTableDataNotFound("XEquipConfig.GetEquipSuitEffectCfg", "template", + TABLE_EQUIP_SUIT_EFFECT_PATH, "templateId", tostring(templateId)) + return + end + + return template +end + +function XEquipConfig.GetEquipTemplateIdsBySuitId(suitId) + return SuitIdToEquipTemplateIdsDic[suitId] or {} +end + +function XEquipConfig.GetSuitSites(suitId) + return SuitSitesDic[suitId] or {} +end + +function XEquipConfig.GetMaxSuitCount() + return XTool.GetTableCount(SuitSitesDic) +end + +function XEquipConfig.GetEquipBgPath(templateId) + if not XEquipConfig.CheckTemplateIdIsEquip(templateId) then return end + local template = XEquipConfig.GetEquipCfg(templateId) + local quality = template.Quality + return XArrangeConfigs.GeQualityBgPath(quality) +end + +function XEquipConfig.GetEquipQualityPath(templateId) + local template = XEquipConfig.GetEquipCfg(templateId) + local quality = template.Quality + if not quality then + XLog.ErrorTableDataNotFound("XEquipConfig.GetEquipQualityPath", "Quality", TABLE_EQUIP_PATH, "templateId", tostring(templateId)) + return + end + return XArrangeConfigs.GeQualityPath(quality) +end + +function XEquipConfig.GetEquipResoanceIconPath(isAwaken) + return EquipResonanceIconPath[isAwaken] +end + +function XEquipConfig.GetEquipDecomposeCfg(templateId, breakthroughTimes) + if not XEquipConfig.CheckTemplateIdIsEquip(templateId) then return end + breakthroughTimes = breakthroughTimes or 0 + + local template = XEquipConfig.GetEquipCfg(templateId) + local site = template.Site + if not site then + XLog.ErrorTableDataNotFound("XEquipConfig.GetEquipDecomposeCfg", "Site", TABLE_EQUIP_PATH, "templateId", tostring(templateId)) + return + end + + local star = template.Star + if not star then + XLog.ErrorTableDataNotFound("XEquipConfig.GetEquipDecomposeCfg", "Star", TABLE_EQUIP_PATH, "templateId", tostring(templateId)) + return + end + + return EquipDecomposeDic[site .. star .. breakthroughTimes] +end + +function XEquipConfig.GetWeaponTypeIconPath(templateId) + return XGoodsCommonManager.GetGoodsShowParamsByTemplateId(templateId).Icon +end + +function XEquipConfig.GetEquipBreakThroughIcon(breakthroughTimes) + local icon = EquipBreakThroughIcon[breakthroughTimes] + if not icon then + XLog.Error("XEquipConfig.EquipBreakThroughIcon调用错误,得到的icon为空,原因:检查breakthroughTimes:" .. breakthroughTimes .. "和EquipBreakThroughIcon") + return + end + return icon +end + +function XEquipConfig.GetEquipBreakThroughSmallIcon(breakthroughTimes) + local icon = EquipBreakThroughSmallIcon[breakthroughTimes] + if not icon then + XLog.Error("XEquipConfig.GetEquipBreakThroughSmallIcon调用错误,得到的icon为空,原因:检查breakthroughTimes:" .. breakthroughTimes .. "和EquipBreakThroughSmallIcon") + return + end + return icon +end + +function XEquipConfig.GetEquipBreakThroughBigIcon(breakthroughTimes) + local icon = EquipBreakThroughBigIcon[breakthroughTimes] + if not icon then + XLog.Error("XEquipConfig.GetEquipBreakThroughBigIcon调用错误,得到的icon为空,原因:检查breakthroughTimes:" .. breakthroughTimes .. "和EquipBreakThroughBigIcon") + return + end + return icon +end + +function XEquipConfig.GetWeaponSkillTemplate(templateId) + local template = WeaponSkillTemplate[templateId] + if not template then + XLog.ErrorTableDataNotFound("XEquipConfig.GetWeaponSkillTemplate", "template", TABLE_WEAPON_SKILL_PATH, "templateId", tostring(templateId)) + return + end + + return template +end + +function XEquipConfig.GetWeaponSkillInfo(weaponSkillId) + local template = WeaponSkillTemplate[weaponSkillId] + if not template then + XLog.ErrorTableDataNotFound("XEquipConfig.GetWeaponSkillInfo", "template", TABLE_WEAPON_SKILL_PATH, "weaponSkillId", tostring(weaponSkillId)) + return + end + + return template +end + +function XEquipConfig.GetWeaponSkillAbility(weaponSkillId) + local template = WeaponSkillTemplate[weaponSkillId] + if not template then + XLog.ErrorTableDataNotFound("XEquipConfig.GetWeaponSkillAbility", "template", + TABLE_WEAPON_SKILL_PATH, "weaponSkillId", tostring(weaponSkillId)) + return + end + + return template.Ability +end + +function XEquipConfig.GetWeaponSkillPoolSkillIds(poolId, characterId) + local template = WeaponSkillPoolTemplate[poolId] + if not template then + XLog.ErrorTableDataNotFound("XEquipConfig.GetWeaponSkillPoolSkillIds", "template", TABLE_WEAPON_SKILL_POOL_PATH, "poolId", tostring(poolId)) + return + end + + local skillIds = template[characterId] + if not skillIds then + XLog.ErrorTableDataNotFound("XEquipConfig.GetWeaponSkillPoolSkillIds", + "characterId", TABLE_WEAPON_SKILL_POOL_PATH, "poolId", tostring(poolId)) + return + end + + return skillIds +end + +function XEquipConfig.GetEquipSkipIdTemplate(eatType, site) + local template = EquipSkipIdTemplates[eatType][site] + if not template then + XLog.ErrorTableDataNotFound("XEquipConfig.GetEquipSkipIdTemplate", "site", TABLE_WEAPON_SKILL_POOL_PATH, "eatType", tostring(eatType)) + return + end + return template +end + +function XEquipConfig.GetEquipResonanceCfg(templateId) + local equipResonanceCfg = EquipResonanceTemplate[templateId] + + if not equipResonanceCfg then + return + end + + return equipResonanceCfg +end + +function XEquipConfig.GetEquipCharacterType(templateId) + local config = XEquipConfig.GetEquipCfg(templateId) + return config.CharacterType +end + +function XEquipConfig.GetEquipResonanceConsumeItemCfg(templateId) + local equipResonanceItemCfg = EquipResonanceConsumeItemTemplates[templateId] + + if not equipResonanceItemCfg then + XLog.ErrorTableDataNotFound("XEquipConfig.GetEquipResonanceConsumeItemCfg", + "equipResonanceItemCfg", TABLE_EQUIP_RESONANCE_CONSUME_ITEM_PATH, "templateId", tostring(templateId)) + return + end + + return equipResonanceItemCfg +end + +function XEquipConfig.GetNeedFirstShow(templateId) + local template = XEquipConfig.GetEquipCfg(templateId) + return template.NeedFirstShow +end + +function XEquipConfig.GetEquipTemplates() + return EquipTemplates +end + +function XEquipConfig.GetEquipAwakeCfg(templateId) + local equipAwakeCfg = EquipAwakeTemplate[templateId] + if not equipAwakeCfg then + XLog.ErrorTableDataNotFound("XEquipConfig.GetEquipAwakeCfg", "equipAwakeCfg", TABLE_EQUIP_AWAKE_PATH, "templateId", tostring(templateId)) + return + end + return equipAwakeCfg +end + +function XEquipConfig.GetEquipAwakeCfgs() + return EquipAwakeTemplate +end + +function XEquipConfig.GetEquipAwakeSkillDesList(templateId, pos) + local equipAwakeCfg = XEquipConfig.GetEquipAwakeCfg(templateId) + local desList = equipAwakeCfg["AttribDes" .. pos] + if not desList then + local tempStr = "AttribDes" .. pos + XLog.ErrorTableDataNotFound("XEquipConfig.GetEquipAwakeSkillDesList", tempStr, TABLE_EQUIP_AWAKE_PATH, "templateId", tostring(templateId)) + return + end + return desList +end + +function XEquipConfig.GetEquipSuitPath() + return TABLE_EQUIP_SUIT_PATH +end + +function XEquipConfig.GetEquipPath() + return TABLE_EQUIP_PATH +end + +function XEquipConfig.GetWeaponSkillPath() + return TABLE_WEAPON_SKILL_PATH +end + +function XEquipConfig.IsDefaultSuitId(suitId) + return suitId == XEquipConfig.DEFAULT_SUIT_ID.Normal or suitId == XEquipConfig.DEFAULT_SUIT_ID.Isomer +end + +function XEquipConfig.GetDefaultSuitIdCount() + local count = 0 + for _, _ in pairs(XEquipConfig.DEFAULT_SUIT_ID) do + count = count + 1 + end + return count +end + +function XEquipConfig.GetEquipAwakeTabIndex() + return EquipAwakeTabIndex +end + +function XEquipConfig.SetEquipAwakeTabIndex(equipAwakeTabIndex) + EquipAwakeTabIndex = equipAwakeTabIndex +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XExhibitionConfigs.lua b/Resources/Scripts/XConfig/XExhibitionConfigs.lua new file mode 100644 index 00000000..2d86b44f --- /dev/null +++ b/Resources/Scripts/XConfig/XExhibitionConfigs.lua @@ -0,0 +1,182 @@ +XExhibitionConfigs = XExhibitionConfigs or {} + +local TABLE_CHARACTER_EXHIBITION = "Client/Exhibition/Exhibition.tab" +local TABLE_CHARACTER_EXHIBITION_LEVEL = "Client/Exhibition/ExhibitionLevel.tab" +local TABLE_CHARACTER_GROW_TASK_INFO = "Share/Exhibition/ExhibitionReward.tab" + +local DefaultPortraitImagePath = CS.XGame.ClientConfig:GetString("DefaultPortraitImagePath") +local ExhibitionLevelPoint = {} +local ExhibitionConfig = {} +local ExhibitionGroupNameConfig = {} +local ExhibitionGroupLogoConfig = {} +local ExhibitionGroupDescConfig = {} +local CharacterExhibitionLevelConfig = {} +local GrowUpTasksConfig = {} +local CharacterGrowUpTasksConfig = {} +local CharacterGrowUpTasksConfigByType = {} +local CharacterHeadPortrait = {} +local CharacterGraduationPortrait = {} +local ExhibitionConfigByTypeAndPort = {} +local ExhibitionConfigByTypeAndGroup = {} +local CharacterToExhibitionTypeTable = {} +local InVisibleGroupTable = {} +function XExhibitionConfigs.Init() + CharacterExhibitionLevelConfig = XTableManager.ReadByIntKey(TABLE_CHARACTER_EXHIBITION_LEVEL, XTable.XTableExhibitionLevel, "LevelId") + ExhibitionConfig = XTableManager.ReadByIntKey(TABLE_CHARACTER_EXHIBITION, XTable.XTableCharacterExhibition, "Id") + for _, v in pairs(ExhibitionConfig) do + if v.Port ~= nil then + CharacterHeadPortrait[v.CharacterId] = v.HeadPortrait + CharacterGraduationPortrait[v.CharacterId] = v.GraduationPortrait + ExhibitionGroupNameConfig[v.GroupId] = v.GroupName + ExhibitionGroupLogoConfig[v.GroupId] = v.GroupLogo + ExhibitionGroupDescConfig[v.GroupId] = v.GroupDescription + if v.Type and not ExhibitionConfigByTypeAndPort[v.Type] then + ExhibitionConfigByTypeAndPort[v.Type] = {} + ExhibitionConfigByTypeAndGroup[v.Type] = {} + end + ExhibitionConfigByTypeAndPort[v.Type][v.Port] = v + ExhibitionConfigByTypeAndGroup[v.Type][v.GroupId] = v + if v.Type then + if not InVisibleGroupTable[v.Type] then InVisibleGroupTable[v.Type] = {} end + if InVisibleGroupTable[v.Type][v.GroupId] == nil then InVisibleGroupTable[v.Type][v.GroupId] = true end + if v.InVisible == 1 then InVisibleGroupTable[v.Type][v.GroupId] = false end + end + end + if v.CharacterId and v.CharacterId ~= 0 and not CharacterToExhibitionTypeTable[v.CharacterId] then + CharacterToExhibitionTypeTable[v.CharacterId] = v.Type + end + end + GrowUpTasksConfig = XTableManager.ReadByIntKey(TABLE_CHARACTER_GROW_TASK_INFO, XTable.XTableExhibitionReward, "Id") + for task, v in pairs(GrowUpTasksConfig) do + if CharacterGrowUpTasksConfig[v.CharacterId] == nil then + CharacterGrowUpTasksConfig[v.CharacterId] = {} + end + CharacterGrowUpTasksConfig[v.CharacterId][task] = v + local type = CharacterToExhibitionTypeTable[v.CharacterId] or 1 + if not CharacterGrowUpTasksConfigByType[type] then CharacterGrowUpTasksConfigByType[type] = {} end + if not CharacterGrowUpTasksConfigByType[type][v.Id] then + CharacterGrowUpTasksConfigByType[type][v.Id] = v + end + end + ExhibitionLevelPoint[1] = CS.XGame.ClientConfig:GetInt("ExhibitionLevelPoint_01") + ExhibitionLevelPoint[2] = CS.XGame.ClientConfig:GetInt("ExhibitionLevelPoint_02") + ExhibitionLevelPoint[3] = CS.XGame.ClientConfig:GetInt("ExhibitionLevelPoint_03") + ExhibitionLevelPoint[4] = CS.XGame.ClientConfig:GetInt("ExhibitionLevelPoint_04") +end + +function XExhibitionConfigs.GetDefaultPortraitImagePath() + return DefaultPortraitImagePath +end + +function XExhibitionConfigs.GetExhibitionLevelPoints() + return ExhibitionLevelPoint +end + +function XExhibitionConfigs.GetGrowUpLevelMax() + local maxPoint = 0 + for i = 1, 4 do + maxPoint = maxPoint + ExhibitionLevelPoint[i] + end + return maxPoint +end + +function XExhibitionConfigs.GetExhibitionConfig() + return ExhibitionConfig +end + +function XExhibitionConfigs.GetExhibitionPortConfigByType(showType) + if not showType then return ExhibitionConfig end + return ExhibitionConfigByTypeAndPort[showType] or {} +end + +function XExhibitionConfigs.GetExhibitionGroupNameConfig() + return ExhibitionGroupNameConfig +end + +function XExhibitionConfigs.GetExhibitionGroupConfigByType(showType) + if not showType then return ExhibitionConfig end + return ExhibitionConfigByTypeAndGroup[showType] or {} +end + +function XExhibitionConfigs.GetExhibitionConfigByTypeAndGroup(showType, groupId) + return ExhibitionConfigByTypeAndGroup[showType][groupId] +end + +function XExhibitionConfigs.GetExhibitionTypeByCharacterId(characterId) + return CharacterToExhibitionTypeTable[characterId] +end + +function XExhibitionConfigs.GetExhibitionGroupLogoConfig() + return ExhibitionGroupLogoConfig +end + +function XExhibitionConfigs.GetExhibitionGroupDescConfig() + return ExhibitionGroupDescConfig +end + +function XExhibitionConfigs.GetExhibitionInVisbleGroupTable(exhibitionType) + return InVisibleGroupTable[exhibitionType] or {} +end + +function XExhibitionConfigs.GetIsExhibitionInVisbleGroup(exhibitionType, groupId) + return InVisibleGroupTable[exhibitionType] and InVisibleGroupTable[exhibitionType][groupId] or false +end + +function XExhibitionConfigs.GetExhibitionLevelConfig() + return CharacterExhibitionLevelConfig +end + +function XExhibitionConfigs.GetCharacterGrowUpTasks(characterId) + local config = CharacterGrowUpTasksConfig[characterId] + if not config then + XLog.Error("XExhibitionConfigs.GetCharacterGrowUpTasks error: 角色解放配置错误:characterId: " .. characterId .. " ,path: " .. TABLE_CHARACTER_GROW_TASK_INFO) + return + end + return config +end + +function XExhibitionConfigs.GetCharacterGrowUpTask(characterId, level) + local levelTasks = XExhibitionConfigs.GetCharacterGrowUpTasks(characterId) + for _, config in pairs(levelTasks) do + if config.LevelId == level then + return config + end + end +end + +function XExhibitionConfigs.GetCharacterGrowUpTasksConfig() + return CharacterGrowUpTasksConfig +end + +function XExhibitionConfigs.GetExhibitionGrowUpLevelConfig(level) + return CharacterExhibitionLevelConfig[level] +end + +function XExhibitionConfigs.GetExhibitionLevelNameByLevel(level) + return CharacterExhibitionLevelConfig[level].Name or "" +end + +function XExhibitionConfigs.GetExhibitionLevelDescByLevel(level) + return CharacterExhibitionLevelConfig[level].Desc or "" +end + +function XExhibitionConfigs.GetExhibitionLevelIconByLevel(level) + return CharacterExhibitionLevelConfig[level].LevelIcon or "" +end + +function XExhibitionConfigs.GetCharacterHeadPortrait(characterId) + return CharacterHeadPortrait[characterId] +end + +function XExhibitionConfigs.GetCharacterGraduationPortrait(characterId) + return CharacterGraduationPortrait[characterId] +end + +function XExhibitionConfigs.GetGrowUpTasksConfig() + return GrowUpTasksConfig +end + +function XExhibitionConfigs.GetGrowUpTasksConfigByType(exhibitionType) + if not exhibitionType then return GrowUpTasksConfig end + return CharacterGrowUpTasksConfigByType[exhibitionType] or {} +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XExpeditionConfig.lua b/Resources/Scripts/XConfig/XExpeditionConfig.lua new file mode 100644 index 00000000..6cd224d2 --- /dev/null +++ b/Resources/Scripts/XConfig/XExpeditionConfig.lua @@ -0,0 +1,374 @@ +XExpeditionConfig = XExpeditionConfig or {} +--基础角色表 +local TABLE_EXPEDITION_BASE_CHARACTER = "Share/Fuben/Expedition/ExpeditionBaseCharacter.tab" +--角色表 +local TABLE_EXPEDITION_CHARACTER = "Share/Fuben/Expedition/ExpeditionCharacter.tab" +--远征章节表 +local TABLE_EXPEDITION_CHAPTER = "Share/Fuben/Expedition/ExpeditionChapter.tab" +--远征关卡表 +local TABLE_EXPEDITION_STAGE = "Share/Fuben/Expedition/ExpeditionStage.tab" +--玩法配置 +local TABLE_EXPEDITION_CONFIG = "Share/Fuben/Expedition/ExpeditionConfig.tab" +--角色基础组合羁绊表 +local TABLE_EXPEDITION_COMBO = "Share/Fuben/Expedition/ExpeditionCombo.tab" +--角色组合羁绊子分类表 +local TABLE_EXPEDITION_CHILDCOMBO = "Share/Fuben/Expedition/ExpeditionChildCombo.tab" +--角色分类展示表 +local TABLE_EXPEDITION_CHARACTER_TYPE = "Share/Fuben/Expedition/ExpeditionCharacterType.tab" +--角色阶级升级表 +local TABLE_EXPEDITION_CHARACTER_ELEMENTS = "Client/Fuben/Expedition/ExpeditionCharacterElements.tab" +--羁绊大类表 +local TABLE_EXPEDITION_COMBO_TYPENAME = "Client/Fuben/Expedition/ExpeditionComboTypeName.tab" +--螺母购买刷新次数表 +local TABLE_EXPEDITION_DRAW_CONSUME = "Share/Fuben/Expedition/ExpeditionDrawConsume.tab" +--全局增益羁绊 +local TABLE_EXPEDITION_GLOBAL_COMBO = "Client/Fuben/Expedition/ExpeditionGlobalCombo.tab" +--队伍位置表 +local TABLE_EXPEDITION_TEAMPOS = "Share/Fuben/Expedition/ExpeditionTeamPos.tab" +--招募概率表 +local TABLE_EXPEDITION_DRAWPR = "Share/Fuben/Expedition/ExpeditionDrawPR.tab" +--招募概率星数对照表 +local TABLE_EXPEDITION_DRAWRANK = "Share/Fuben/Expedition/ExpeditionDrawRank.tab" + +local BaseConfig = {} +local ChildComboConfig = {} +local ComboConfig = {} +local CharacterTypeConfig = {} +local CharacterConfig = {} +local CharacterElements = {} +local BaseCharacterConfig = {} +local ChapterConfig = {} +local EStageConfig = {} +local ComboTypeNameConfig = {} +local DrawConsumeConfig = {} +local GlobalComboConfig = {} +local TeamPosConfig = {} +local DrawPRConfig = {} +local DrawRankConfig = {} + +local Type2CharacterDic = {} +local Rank2CharacterDic = {} +local Chapter2StageDic = {} +local Chapter2ConfigDic = {} +local Chapter2TeamPosDic = {} +local NewBaseConfigIndex = 0 + +local BaseComboStatus = {} -- 废弃 +local BaseComboDic = {} +local StageToEStageDic = {} +local ComboConditionList = { + [1] = "MemberNum", -- 检查合计数量 + [2] = "TotalRank", -- 检查合计等级 + [3] = "TargetMember", -- 检查对应角色等级 + [4] = "TargetTypeAndRank", -- 检查指定特征的高于指定等级的人 +} + +local InitConfig = function() + BaseConfig = XTableManager.ReadByIntKey(TABLE_EXPEDITION_CONFIG, XTable.XTableExpeditionConfig, "Id") + ComboConfig = XTableManager.ReadByIntKey(TABLE_EXPEDITION_COMBO, XTable.XTableExpeditionCombo, "Id") + ChildComboConfig = XTableManager.ReadByIntKey(TABLE_EXPEDITION_CHILDCOMBO, XTable.XTableExpeditionChildCombo, "Id") + ChapterConfig = XTableManager.ReadByIntKey(TABLE_EXPEDITION_CHAPTER, XTable.XTableExpeditionChapter, "Id") + EStageConfig = XTableManager.ReadByIntKey(TABLE_EXPEDITION_STAGE, XTable.XTableExpeditionStage, "Id") + BaseCharacterConfig = XTableManager.ReadByIntKey(TABLE_EXPEDITION_BASE_CHARACTER, XTable.XTableExpeditionBaseCharacter, "Id") + CharacterConfig = XTableManager.ReadByIntKey(TABLE_EXPEDITION_CHARACTER, XTable.XTableExpeditionCharacter, "Id") + CharacterTypeConfig = XTableManager.ReadByStringKey(TABLE_EXPEDITION_CHARACTER_TYPE, XTable.XTableExpeditionCharacterType, "Id") + ComboTypeNameConfig = XTableManager.ReadByIntKey(TABLE_EXPEDITION_COMBO_TYPENAME, XTable.XTableExpeditionComboTypeName, "Id") + DrawConsumeConfig = XTableManager.ReadByIntKey(TABLE_EXPEDITION_DRAW_CONSUME, XTable.XTableExpeditionDrawConsume, "Id") + GlobalComboConfig = XTableManager.ReadByIntKey(TABLE_EXPEDITION_GLOBAL_COMBO, XTable.XTableExpeditionGlobalCombo, "Id") + CharacterElements = XTableManager.ReadByIntKey(TABLE_EXPEDITION_CHARACTER_ELEMENTS, XTable.XTableExpeditionCharacterElements, "Id") + TeamPosConfig = XTableManager.ReadByIntKey(TABLE_EXPEDITION_TEAMPOS, XTable.XTableExpeditionTeamPos, "Id") + DrawPRConfig = XTableManager.ReadByIntKey(TABLE_EXPEDITION_DRAWPR, XTable.XTableExpeditionDrawPR, "Level") + DrawRankConfig = XTableManager.ReadByIntKey(TABLE_EXPEDITION_DRAWRANK, XTable.XTableExpeditionDrawRank, "Id") +end + +local GetNewBaseConfigId = function() + local startTime = 0 + for id, config in pairs(BaseConfig) do + if id > NewBaseConfigIndex then NewBaseConfigIndex = id end + end +end + +local InitComboConfig = function() + for i = 1, #ComboConfig do + if not BaseComboDic[ComboConfig[i].ChildComboId] then + BaseComboDic[ComboConfig[i].ChildComboId] = {} + end + table.insert(BaseComboDic[ComboConfig[i].ChildComboId], ComboConfig[i]) + end +end + +local InitStages = function() + for _, eStage in pairs(EStageConfig) do + if not Chapter2StageDic[eStage.ChapterId] then Chapter2StageDic[eStage.ChapterId] = {} end + Chapter2StageDic[eStage.ChapterId][eStage.OrderId] = eStage + if not StageToEStageDic[eStage.StageId] then + StageToEStageDic[eStage.StageId] = eStage + end + end +end + + +local InitCharacter = function() + for _, v in pairs(BaseCharacterConfig) do + for _, type in pairs(v.Type) do + if not Type2CharacterDic[type] then Type2CharacterDic[type] = {} end + if not Type2CharacterDic[type][v.Id] then Type2CharacterDic[type][v.Id] = 1 end + end + Rank2CharacterDic[v.Id] = {} + end +end + +local InitRank2CharacterDic = function() + for _, v in pairs(CharacterConfig) do + Rank2CharacterDic[v.BaseId][v.Rank] = v + if not Rank2CharacterDic[v.BaseId].MaxRank or Rank2CharacterDic[v.BaseId].MaxRank < v.Rank then + Rank2CharacterDic[v.BaseId].MaxRank = v.Rank + end + end +end + +local InitChapter2TeamPosDic = function() + for _, v in pairs(TeamPosConfig) do + if not Chapter2TeamPosDic[v.ChapterId] then Chapter2TeamPosDic[v.ChapterId] = {} end + table.insert(Chapter2TeamPosDic[v.ChapterId], v) + end +end + +function XExpeditionConfig.Init() + InitConfig() + GetNewBaseConfigId() + InitStages() + InitCharacter() + InitRank2CharacterDic() + InitComboConfig() + InitChapter2TeamPosDic() +end + +function XExpeditionConfig.GetExpeditionConfig() + return BaseConfig +end + +function XExpeditionConfig.GetExpeditionConfigById(Id) + return BaseConfig[Id] or BaseConfig[NewBaseConfigIndex] +end + +function XExpeditionConfig.GetLastestExpeditionConfig() + return BaseConfig[NewBaseConfigIndex] +end + +function XExpeditionConfig.GetEChapterCfg() + return ChapterConfig +end + +function XExpeditionConfig.GetChapterCfgById(chapterId) + if not ChapterConfig[chapterId] then + XLog.ErrorTableDataNotFound("XExpeditionConfig.GetChapterCfgById", "虚像地平线章节数据", + TABLE_EXPEDITION_CHAPTER, "Id", tostring(chapterId)) + return nil + end + return ChapterConfig[chapterId] +end + +function XExpeditionConfig.GetChapterRewardIdById(chapterId) + return ChapterConfig[chapterId] and ChapterConfig[chapterId].RewardId or 0 +end + +function XExpeditionConfig.GetEStageListByChapterId(chapterId) + return Chapter2StageDic[chapterId] +end + +function XExpeditionConfig.GetStageList() + return StageToEStageDic +end + +function XExpeditionConfig.GetEStageByStageId(stageId) + return StageToEStageDic[stageId] +end + +function XExpeditionConfig.GetEStageIdByStageId(stageId) + return StageToEStageDic[stageId] and StageToEStageDic[stageId].Id +end + +function XExpeditionConfig.GetOrderIdByStageId(stageId) + return StageToEStageDic[stageId].OrderId +end + +function XExpeditionConfig.GetBaseCharacterCfg() + return BaseCharacterConfig +end + +function XExpeditionConfig.GetBaseCharacterCfgById(baseId) + return BaseCharacterConfig[baseId] +end + +function XExpeditionConfig.GetBaseIdByECharId(eCharacterId) + return CharacterConfig[eCharacterId].BaseId +end + +function XExpeditionConfig.GetCharacterIdByBaseId(baseId) + return BaseCharacterConfig[baseId] and BaseCharacterConfig[baseId].CharacterId or 0 +end + +function XExpeditionConfig.GetCharacterElementByBaseId(baseId) + return BaseCharacterConfig[baseId] and BaseCharacterConfig[baseId].Elements or {} +end + +function XExpeditionConfig.GetCharacterMaxRankByBaseId(baseId) + return Rank2CharacterDic[baseId].MaxRank +end + +function XExpeditionConfig.GetCharacterCfgByBaseIdAndRank(baseId, rank) + local base = Rank2CharacterDic[baseId] + if not base then + return nil + end + if base.MaxRank < rank then + return base[base.MaxRank] + else + return base[rank] + end +end + +function XExpeditionConfig.GetCharacterCfgs() + return CharacterConfig +end + +function XExpeditionConfig.GetCharacterCfgById(Id) + if not CharacterConfig[Id] then + XLog.ErrorTableDataNotFound("XExpeditionConfig.GetCharacterById", "虚像地平线角色", TABLE_EXPEDITION_CHARACTER, "Id", tostring(Id)) + end + return CharacterConfig[Id] +end + +function XExpeditionConfig.GetEStageCfg(EStageId) + if not EStageConfig[EStageId] then + XLog.ErrorTableDataNotFound("XExpeditionConfig.GetEStageCfg", "虚像地平线关卡", TABLE_EXPEDITION_STAGE, "Id", tostring(EStageId)) + return nil + end + return EStageConfig[EStageId] +end + +function XExpeditionConfig.GetCharacterElementById(elementId) + return CharacterElements[elementId] +end + +function XExpeditionConfig.GetComboTable() + return ComboConfig +end + +function XExpeditionConfig.GetChildComboTable() + return ChildComboConfig +end +--================ +--根据子羁绊类型Id获取具体羁绊列表 +--================ +function XExpeditionConfig.GetComboByChildComboId(childComboId) + if not BaseComboDic[childComboId] then + XLog.ErrorTableDataNotFound( + "XExpeditionConfig.GetComboByChildComboId", + "虚像地平线成员组合数据", + TABLE_EXPEDITION_COMBO, + "ChildComboId", + tostring(childComboId)) + return nil + end + return BaseComboDic[childComboId] +end + +function XExpeditionConfig.GetChildComboById(id) + if not ChildComboConfig[id] then + XLog.ErrorTableDataNotFound("XExpeditionConfig.GetEStageCfg", + "虚像地平线羁绊子分类数据", TABLE_EXPEDITION_CHILDCOMBO, "Id", tostring(id)) + return nil + end + return ChildComboConfig[id] +end + +function XExpeditionConfig.GetComboById(comboId) + if not ComboConfig[comboId] then + XLog.ErrorTableDataNotFound("XExpeditionConfig.GetComboById", "虚像地平线阵容", TABLE_EXPEDITION_COMBO, "Id", tostring(comboId)) + return nil + end + return ComboConfig[comboId] +end + +function XExpeditionConfig.GetCharactersByCharacterType(typeId) + if not Type2CharacterDic[typeId] then + XLog.ErrorTableDataNotFound("XExpeditionConfig.GetCharactersByCharacterType", "虚像地平线角色词条", TABLE_EXPEDITION_CHARACTER_TYPE, "Id", tostring(typeId)) + return nil + end + return Type2CharacterDic[typeId] +end + +function XExpeditionConfig.IsCharacterHasTypes(characterId, typeIds) + for _, typeId in pairs(typeIds) do + local id = tonumber(typeId) + if not Type2CharacterDic[id] or not Type2CharacterDic[id][characterId] then + return false + end + end + return true +end + +function XExpeditionConfig.GetBaseComboTypeConfig() + return ComboTypeNameConfig +end + +function XExpeditionConfig.GetBaseComboTypeNameById(id) + return ComboTypeNameConfig[id].Name or "" +end + +function XExpeditionConfig.GetBuyDrawMaxTime() + return #DrawConsumeConfig +end + +function XExpeditionConfig.GetDrawPriceByCount(count) + return DrawConsumeConfig[count] and DrawConsumeConfig[count].ConsumeCount or 0 +end + +function XExpeditionConfig.GetGlobalConfigs() + return GlobalComboConfig +end + +function XExpeditionConfig.GetGlobalConfigById(comboId) + return GlobalComboConfig[comboId] +end + +function XExpeditionConfig.GetRankByRankWeightId(index) + return DrawRankConfig[index] and DrawRankConfig[index].Rank or 1 +end +--================ +--获取队伍位置数据 +--@param teamPosId:位置ID +--================ +function XExpeditionConfig.GetTeamPosCfgById(teamPosId) + if not TeamPosConfig[teamPosId] then + XLog.ErrorTableDataNotFound( + "XExpeditionConfig.GetTeamPosCfgById", + "虚像地平线队伍位置数据", + TABLE_EXPEDITION_TEAMPOS, + "Id", + tostring(teamPosId)) + return nil + end + return TeamPosConfig[teamPosId] +end +--================ +--获取队伍位置数量 +--================ +function XExpeditionConfig.GetTeamPosListByChapterId(currentChapterId) + if not TeamPosConfig or not Chapter2TeamPosDic or not Chapter2TeamPosDic[currentChapterId] then return 0 end + return Chapter2TeamPosDic[currentChapterId] +end +--================ +--获取招募概率配置表 +--================ +function XExpeditionConfig.GetDrawPRConfig() + return DrawPRConfig +end +--================ +--获取招募星数对照表配置 +--================ +function XExpeditionConfig.GetDrawRankConfig() + return DrawRankConfig +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XFashionConfigs.lua b/Resources/Scripts/XConfig/XFashionConfigs.lua new file mode 100644 index 00000000..4ed2e45f --- /dev/null +++ b/Resources/Scripts/XConfig/XFashionConfigs.lua @@ -0,0 +1,39 @@ +XFashionConfigs = XFashionConfigs or {} + +local TABLE_FASHION_SERIES = "Client/Fashion/FashionSeries.tab" +local FashionSeriesConfig = {} + +function XFashionConfigs.Init() + FashionSeriesConfig = XTableManager.ReadByIntKey(TABLE_FASHION_SERIES, XTable.XTableFashionSeries, "Id") +end + + +---------------------------------------------------FashionSeries.tab数据读取--------------------------------------------------------- + +local function GetFashionSeriesConfig(id) + local cfg = FashionSeriesConfig[id] + if cfg == nil then + XLog.ErrorTableDataNotFound("XFashionConfigs.GetFashionSeriesConfig", + "涂装系列", + TABLE_FASHION_SERIES, + "Id", + tostring(id)) + return {} + end + return cfg +end + +--- +--- 获取涂装系列名称 +function XFashionConfigs.GetSeriesName(id) + local cfg = GetFashionSeriesConfig(id) + if not cfg.Name then + XLog.ErrorTableDataNotFound("XFashionConfigs.GetSeriesName", + "涂装名称", + TABLE_FASHION_SERIES, + "Id", + tostring(id)) + return "" + end + return cfg.Name +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XFashionStoryConfigs.lua b/Resources/Scripts/XConfig/XFashionStoryConfigs.lua new file mode 100644 index 00000000..e0b784f9 --- /dev/null +++ b/Resources/Scripts/XConfig/XFashionStoryConfigs.lua @@ -0,0 +1,183 @@ +XFashionStoryConfigs = XFashionStoryConfigs or {} + +local TABLE_FASHION_STORY = "Share/Fuben/FashionStory/FashionStory.tab" +local TABLE_FASHION_STORY_STAGE = "Share/Fuben/FashionStory/FashionStoryStage.tab" + +-- 活动类型 +XFashionStoryConfigs.Type = { + Both = 1, -- 具有章节关与试玩关 + OnlyChapter = 2, -- 只有章节关 + OnlyTrial = 3, -- 只有试玩关 +} + +-- 玩法模式 +XFashionStoryConfigs.Mode = { + Chapter = 1, -- 章节关 + Trial = 2, -- 试玩关 +} + +XFashionStoryConfigs.StoryEntranceId = 0 + +local FashionStory = {} +local FashionStoryStage = {} + +function XFashionStoryConfigs.Init() + FashionStory = XTableManager.ReadByIntKey(TABLE_FASHION_STORY, XTable.XTableFashionStory, "Id") + FashionStoryStage = XTableManager.ReadByIntKey(TABLE_FASHION_STORY_STAGE, XTable.XTableFashionStoryStage, "StageId") +end + + +--------------------------------------------------内部接口--------------------------------------------------------------- + +local function GetFashionStoryCfg(id) + local cfg = FashionStory[id] + if not cfg then + XLog.ErrorTableDataNotFound("GetFashionStoryCfg", "系列涂装剧情活动配置", + TABLE_FASHION_STORY, "Id", tostring(id)) + return {} + end + return cfg +end + +local function GetFashionStoryStageCfg(stageId) + local cfg = FashionStoryStage[stageId] + if not cfg then + XLog.ErrorTableDataNotFound(" GetFashionStoryStageCfg", "活动关卡配置", + TABLE_FASHION_STORY_STAGE, "StageId", tostring(stageId)) + return {} + end + return cfg +end + + +----------------------------------------------FashionStory.tab---------------------------------------------------------- + +function XFashionStoryConfigs.GetAllFashionStoryId() + local allFashionStoryId = {} + for id, _ in pairs(FashionStory) do + table.insert(allFashionStoryId, id) + end + return allFashionStoryId +end + +function XFashionStoryConfigs.GetName(id) + local cfg = GetFashionStoryCfg(id) + return cfg.Name +end + +function XFashionStoryConfigs.GetActivityTimeId(id) + local cfg = GetFashionStoryCfg(id) + return cfg.TimeId +end + +function XFashionStoryConfigs.GetChapterPrefab(id) + local cfg = GetFashionStoryCfg(id) + return cfg.ChapterPrefab +end + +function XFashionStoryConfigs.GetActivityBannerIcon(id) + local cfg = GetFashionStoryCfg(id) + return cfg.ActivityBannerIcon +end + +function XFashionStoryConfigs.GetChapterBg(id) + local cfg = GetFashionStoryCfg(id) + return cfg.ChapterBg +end + +function XFashionStoryConfigs.GetTrialBg(id) + local cfg = GetFashionStoryCfg(id) + return cfg.TrialBg +end + +function XFashionStoryConfigs.GetSkipIdList(id) + local cfg = GetFashionStoryCfg(id) + return cfg.SkipId +end + +function XFashionStoryConfigs.GetChapterStagesList(id) + local cfg = GetFashionStoryCfg(id) + return cfg.ChapterStages +end + +function XFashionStoryConfigs.GetTrialStagesList(id) + local cfg = GetFashionStoryCfg(id) + return cfg.TrialStages +end + +function XFashionStoryConfigs.GetChapterFightStagePrefab(id) + local cfg = GetFashionStoryCfg(id) + return cfg.FightStagePrefab +end + +function XFashionStoryConfigs.GetChapterStoryStagePrefab(id) + local cfg = GetFashionStoryCfg(id) + return cfg.StoryStagePrefab +end + +function XFashionStoryConfigs.GetStoryEntranceBg(id) + local cfg = GetFashionStoryCfg(id) + return cfg.StoryEntranceBg +end + +function XFashionStoryConfigs.GetStoryEntranceFinishTag(id) + local cfg = GetFashionStoryCfg(id) + return cfg.StoryFinishTag +end + +function XFashionStoryConfigs.GetStoryTimeId(id) + local cfg = GetFashionStoryCfg(id) + return cfg.StoryTimeId +end + +function XFashionStoryConfigs.GetAllStageId(id) + return XTool.MergeArray(XFashionStoryConfigs.GetChapterStagesList(id), XFashionStoryConfigs.GetTrialStagesList(id)) +end + + +----------------------------------------------FashionStoryStage.tab---------------------------------------------------------- + +function XFashionStoryConfigs.GetStageTimeId(stageId) + local cfg = GetFashionStoryStageCfg(stageId) + return cfg.TimeId +end + +function XFashionStoryConfigs.GetStoryStageDetailBg(id) + local cfg = GetFashionStoryStageCfg(id) + return cfg.StoryStageDetailBg +end + +function XFashionStoryConfigs.GetStoryStageDetailIcon(id) + local cfg = GetFashionStoryStageCfg(id) + return cfg.StoryStageDetailIcon +end + +function XFashionStoryConfigs.GetTrialDetailBg(id) + local cfg = GetFashionStoryStageCfg(id) + return cfg.TrialDetailBg +end + +function XFashionStoryConfigs.GetTrialDetailSpine(id) + local cfg = GetFashionStoryStageCfg(id) + return cfg.TrialDetailSpine +end + +function XFashionStoryConfigs.GetTrialDetailHeadIcon(id) + local cfg = GetFashionStoryStageCfg(id) + return cfg.TrialDetailHeadIcon +end + +function XFashionStoryConfigs.GetTrialDetailRecommendLevel(id) + local cfg = GetFashionStoryStageCfg(id) + return cfg.TrialDetailRecommendLevel +end + +function XFashionStoryConfigs.GetTrialDetailDesc(id) + local cfg = GetFashionStoryStageCfg(id) + return cfg.TrialDetailDesc +end + +function XFashionStoryConfigs.GetTrialFinishTag(id) + local cfg = GetFashionStoryStageCfg(id) + return cfg.FinishTag +end diff --git a/Resources/Scripts/XConfig/XFavorabilityConfigs.lua b/Resources/Scripts/XConfig/XFavorabilityConfigs.lua new file mode 100644 index 00000000..87aee001 --- /dev/null +++ b/Resources/Scripts/XConfig/XFavorabilityConfigs.lua @@ -0,0 +1,610 @@ +XFavorabilityConfigs = XFavorabilityConfigs or {} + +XFavorabilityConfigs.RewardUnlockType = { + FightAbility = 1, + TrustLv = 2, + CharacterLv = 3, + Quality = 4, +} + +XFavorabilityConfigs.InfoState = { + Normal = 1, + Available = 2, + Lock = 3, +} + +XFavorabilityConfigs.StrangeNewsUnlockType = { + TrustLv = 1, + DormEvent = 2, +} + +XFavorabilityConfigs.SoundEventType = { + FirstTimeObtain = 1, -- 首次获得角色 + LevelUp = 2, -- 角色升级 + Evolve = 3, -- 角色进化 + GradeUp = 4, -- 角色升军阶 + SkillUp = 5, -- 角色技能升级 + WearWeapon = 6, -- 角色穿戴武器 + MemberJoinTeam = 7, --角色入队(队员) + CaptainJoinTeam = 8, --角色入队(队长) +} + +XFavorabilityConfigs.TrustItemType = { + Normal = 1, -- 普通 + Communication = 2, -- 触发通讯的道具 +} + +-- [礼物品质] +XFavorabilityConfigs.GiftQualityIcon = { + [1] = CS.XGame.ClientConfig:GetString("QualityIconColor1"), + [2] = CS.XGame.ClientConfig:GetString("QualityIconColor2"), + [3] = CS.XGame.ClientConfig:GetString("QualityIconColor3"), + [4] = CS.XGame.ClientConfig:GetString("QualityIconColor4"), + [5] = CS.XGame.ClientConfig:GetString("QualityIconColor5"), + [6] = CS.XGame.ClientConfig:GetString("QualityIconColor6"), +} + +local TABLE_LIKE_BASEDATA = "Client/Trust/CharacterBaseData.tab" +local TABLE_LIKE_INFORMATION = "Client/Trust/CharacterInformation.tab" +local TABLE_LIKE_STORY = "Client/Trust/CharacterStory.tab" +local TABLE_LIKE_STRANGENEWS = "Client/Trust/CharacterStrangeNews.tab" +local TABLE_LIKE_TRUSTEXP = "Share/Trust/CharacterTrustExp.tab" +local TABLE_LIKE_TRUSTITEM = "Share/Trust/CharacterTrustItem.tab" +local TABLE_LIKE_VOICE = "Client/Trust/CharacterVoice.tab" +local TABLE_LIKE_LEVELCONFIG = "Share/Trust/FavorabilityLevelConfig.tab" +local TABLE_LIKE_ACTION = "Client/Trust/CharacterAction.tab" + +--local TABLE_AUDIO_CV = "Client/Audio/Cv.tab" +local TABLE_CHARACTER_COLLABORATION = "Client/Trust/CharacterCollaboration.tab" + +local CharacterFavorabilityConfig = {} +local CharacterTrustExp = {} +local CharacterBaseData = {} +local CharacterInformation = {} +local CharacterInformationUnlockLv = {} +local CharacterRumors = {} +local CharacterVoice = {} +local CharacterVoiceUnlockLv = {} +local CharacterStory = {} +local CharacterStoryUnlockLv = {} +local CharacterSendGift = {} +local CharacterGiftReward = {} +local likeReward = {} +local CharacterAction = {} +local CharacterActionUnlockLv = {} +local CharacterCollaboration = {} + +--local AudioCV = {} +local DEFAULT_CV_TYPE = CS.XGame.Config:GetInt("DefaultCvType") + +function XFavorabilityConfigs.Init() + local baseData = XTableManager.ReadByIntKey(TABLE_LIKE_BASEDATA, XTable.XTableCharacterBaseData, "Id") + for _, v in pairs(baseData) do + if CharacterBaseData[v.CharacterId] == nil then + CharacterBaseData[v.CharacterId] = {} + end + + CharacterBaseData[v.CharacterId] = { + CharacterId = v.CharacterId, + BaseDataTitle = v.BaseDataTitle, + BaseData = v.BaseData, + Cast = v.Cast, + } + end + + local likeInformation = XTableManager.ReadByIntKey(TABLE_LIKE_INFORMATION, XTable.XTableCharacterInformation, "Id") + for _, v in pairs(likeInformation) do + if CharacterInformation[v.CharacterId] == nil then + CharacterInformation[v.CharacterId] = {} + end + + table.insert(CharacterInformation[v.CharacterId], { + Id = v.Id, + CharacterId = v.CharacterId, + UnlockLv = v.UnlockLv, + Title = v.Title, + Content = v.Content, + ConditionDescript = v.ConditionDescript + }) + if CharacterInformationUnlockLv[v.CharacterId] == nil then + CharacterInformationUnlockLv[v.CharacterId] = {} + end + CharacterInformationUnlockLv[v.CharacterId][v.Id] = v.UnlockLv + + end + for _, characterDatas in pairs(CharacterInformation) do + table.sort(characterDatas, function(infoA, infoB) + if infoA.UnlockLv == infoB.UnlockLv then + return infoA.Id < infoB.Id + end + return infoA.UnlockLv < infoB.UnlockLv + end) + end + + local likeStory = XTableManager.ReadByIntKey(TABLE_LIKE_STORY, XTable.XTableCharacterStory, "Id") + for _, v in pairs(likeStory) do + if CharacterStory[v.CharacterId] == nil then + CharacterStory[v.CharacterId] = {} + end + table.insert(CharacterStory[v.CharacterId], { + Id = v.Id, + Name = v.Name, + CharacterId = v.CharacterId, + StoryId = v.StoryId, + Icon = v.Icon, + UnlockLv = v.UnlockLv, + ConditionDescript = v.ConditionDescript, + SectionNumber = v.SectionNumber, + }) + + if CharacterStoryUnlockLv[v.CharacterId] == nil then + CharacterStoryUnlockLv[v.CharacterId] = {} + end + CharacterStoryUnlockLv[v.CharacterId][v.Id] = v.UnlockLv + end + for _, storys in pairs(CharacterStory) do + table.sort(storys, function(storyA, storyB) + if storyA.UnlockLv == storyB.UnlockLv then + return storyA.Id < storyB.Id + end + return storyA.UnlockLv < storyB.UnlockLv + end) + end + + local likeStrangeNews = XTableManager.ReadByIntKey(TABLE_LIKE_STRANGENEWS, XTable.XTableCharacterStrangeNews, "Id") + for _, v in pairs(likeStrangeNews) do + if CharacterRumors[v.CharacterId] == nil then + CharacterRumors[v.CharacterId] = {} + end + + table.insert(CharacterRumors[v.CharacterId], { + Id = v.Id, + CharacterId = v.CharacterId, + Type = v.Type, + UnlockType = v.UnlockType, + Title = v.Title, + Content = v.Content, + Picture = v.Picture, + UnlockPara = v.UnlockPara, + ConditionDescript = v.ConditionDescript, + PreviewPicture = v.PreviewPicture + }) + end + for _, strangeNews in pairs(CharacterRumors) do + table.sort(strangeNews, function(strangeNewsA, strangeNewsB) + return strangeNewsA.Id < strangeNewsB.Id + end) + end + + local likeTrustExp = XTableManager.ReadByIntKey(TABLE_LIKE_TRUSTEXP, XTable.XTableCharacterTrustExp, "Id") + for _, v in pairs(likeTrustExp) do + if CharacterTrustExp[v.CharacterId] == nil then + CharacterTrustExp[v.CharacterId] = {} + end + CharacterTrustExp[v.CharacterId][v.TrustLv] = { + Exp = v.Exp, + Name = v.Name, + PlayId = v.PlayId + } + end + + local likeTrustItem = XTableManager.ReadByIntKey(TABLE_LIKE_TRUSTITEM, XTable.XTableCharacterTrustItem, "Id") + for _, v in pairs(likeTrustItem) do + table.insert(CharacterSendGift, { + Id = v.Id, + Exp = v.Exp, + FavorCharacterId = v.FavorCharacterId, + FavorExp = v.FavorExp, + TrustItemType = v.TrustItemType, + }) + end + + local likeVoice = XTableManager.ReadByIntKey(TABLE_LIKE_VOICE, XTable.XTableCharacterVoice, "Id") + for _, v in pairs(likeVoice) do + if v.IsShow == 1 then + if CharacterVoice[v.CharacterId] == nil then + CharacterVoice[v.CharacterId] = {} + end + table.insert(CharacterVoice[v.CharacterId], { + Id = v.Id, + CharacterId = v.CharacterId, + Name = v.Name, + CvId = v.CvId, + UnlockLv = v.UnlockLv, + ConditionDescript = v.ConditionDescript, + SoundType = v.SoundType, + IsShow = v.IsShow, + }) + end + if CharacterVoiceUnlockLv[v.CharacterId] == nil then + CharacterVoiceUnlockLv[v.CharacterId] = {} + end + CharacterVoiceUnlockLv[v.CharacterId][v.Id] = v.UnlockLv + + end + for _, v in pairs(CharacterVoice) do + table.sort(v, XFavorabilityConfigs.SortVoice) + end + + local likeAction = XTableManager.ReadByIntKey(TABLE_LIKE_ACTION, XTable.XTableCharacterAction, "Id") + for _, v in pairs(likeAction) do + if CharacterAction[v.CharacterId] == nil then + CharacterAction[v.CharacterId] = {} + end + table.insert(CharacterAction[v.CharacterId], { + Id = v.Id, + CharacterId = v.CharacterId, + Name = v.Name, + SignBoardActionId = v.SignBoardActionId, + UnlockLv = v.UnlockLv, + ConditionDescript = v.ConditionDescript, + }) + if CharacterActionUnlockLv[v.CharacterId] == nil then + CharacterActionUnlockLv[v.CharacterId] = {} + end + CharacterActionUnlockLv[v.CharacterId][v.Id] = v.UnlockLv + end + for _, v in pairs(CharacterAction) do + table.sort(v, function(item1, item2) + if item1.UnlockLv == item2.UnlockLv then + return item1.Id < item2.Id + end + return item1.UnlockLv < item2.UnlockLv + end) + end + + CharacterFavorabilityConfig = XTableManager.ReadByIntKey(TABLE_LIKE_LEVELCONFIG, XTable.XTableFavorabilityLevelConfig, "Id") + CharacterCollaboration = XTableManager.ReadByIntKey(TABLE_CHARACTER_COLLABORATION, XTable.XTableCharacterCollaboration, "CharacterId") + + --AudioCV = XTableManager.ReadByIntKey(TABLE_AUDIO_CV, XTable.XTableCv, "Id") +end + +function XFavorabilityConfigs.SortVoice(a, b) + if a.UnlockLv == b.UnlockLv then + return a.Id < b.Id + end + return a.UnlockLv < b.UnlockLv +end + +-- [好感度等级经验] +function XFavorabilityConfigs.GetTrustExpById(characterId) + local trustExp = CharacterTrustExp[characterId] + if not trustExp then + XLog.ErrorTableDataNotFound("XFavorabilityConfigs.GetTrustExpById", "CharacterTrustExp", + TABLE_LIKE_TRUSTEXP, "characterId", tostring(characterId)) + return + end + return trustExp +end + +-- [好感度基础数据] +function XFavorabilityConfigs.GetCharacterBaseDataById(characterId) + local baseData = CharacterBaseData[characterId] + if not baseData then + XLog.ErrorTableDataNotFound("XFavorabilityConfigs.GetCharacterBaseDataById", + "CharacterBaseData", TABLE_LIKE_BASEDATA, "characterId", characterId) + return + end + return baseData +end + +-- 获取cv名字 +function XFavorabilityConfigs.GetCharacterCvById(characterId) + local baseData = XFavorabilityConfigs.GetCharacterBaseDataById(characterId) + if not baseData then return "" end + + local cvType = CS.UnityEngine.PlayerPrefs.GetInt("CV_TYPE", DEFAULT_CV_TYPE) + if baseData.Cast and baseData.Cast[cvType] then return baseData.Cast[cvType] end + return "" +end + +-- 获取cv名字 +function XFavorabilityConfigs.GetCharacterCvByIdAndType(characterId, cvType) + local baseData = XFavorabilityConfigs.GetCharacterBaseDataById(characterId) + if not baseData then return "" end + + if baseData.Cast and baseData.Cast[cvType] then return baseData.Cast[cvType] end + return "" +end + +-- [好感度档案-资料] +function XFavorabilityConfigs.GetCharacterInformationById(characterId) + local information = CharacterInformation[characterId] + return information +end + +--获取档案 +function XFavorabilityConfigs.GetCharacterInformation() + return CharacterInformation +end + + +-- [好感度档案-资料解锁等级] +function XFavorabilityConfigs.GetCharacterInformationUnlockLvById(characterId) + local informationUnlockDatas = CharacterInformationUnlockLv[characterId] + if not informationUnlockDatas then + XLog.ErrorTableDataNotFound("XFavorabilityConfigs.GetCharacterInformationUnlockLvById", + "UnlockLv", TABLE_LIKE_INFORMATION, "characterId", tostring(characterId)) + return + end + return informationUnlockDatas +end + +-- [好感度档案-异闻] +function XFavorabilityConfigs.GetCharacterRumorsById(characterId) + local rumors = CharacterRumors[characterId] + return rumors +end + +--获取异闻 +function XFavorabilityConfigs.GetCharacterRumors() + return CharacterRumors +end + +--获取剧情 +function XFavorabilityConfigs.GetCharacterStory() + return CharacterStory +end + +--获取语音 +function XFavorabilityConfigs.GetCharacterVoice() + return CharacterVoice +end + +--获取动作 +function XFavorabilityConfigs.GetCharacterAction() + return CharacterAction +end + +-- [好感度档案-动作] +function XFavorabilityConfigs.GetCharacterActionById(characterId) + if XRobotManager.CheckIsRobotId(characterId) then + characterId = XRobotManager.GetRobotTemplate(characterId).CharacterId + end + local action = CharacterAction[characterId] + return action +end + +-- [好感度档案-动作解锁等级] +function XFavorabilityConfigs.GetCharacterActionUnlockLvsById(characterId) + local actionUnlockDatas = CharacterActionUnlockLv[characterId] + if not actionUnlockDatas then + XLog.ErrorTableDataNotFound("XFavorabilityConfigs.GetCharacterActionUnlockLvsById", + "CharacterActionUnlockLv", TABLE_LIKE_ACTION, "characterId", tostring(characterId)) + return + end + return actionUnlockDatas +end + +-- [好感度档案-语音] +function XFavorabilityConfigs.GetCharacterVoiceById(characterId) + if XRobotManager.CheckIsRobotId(characterId) then + characterId = XRobotManager.GetRobotTemplate(characterId).CharacterId + end + local voice = CharacterVoice[characterId] + return voice +end + +-- [好感度档案-语音解锁等级] +function XFavorabilityConfigs.GetCharacterVoiceUnlockLvsById(characterId) + local voiceUnlockDatas = CharacterVoiceUnlockLv[characterId] + if not voiceUnlockDatas then + XLog.ErrorTableDataNotFound("XFavorabilityConfigs.GetCharacterVoiceUnlockLvsById", + "CharacterVoiceUnlockLv", TABLE_LIKE_VOICE, "characterId", tostring(characterId)) + return + end + return voiceUnlockDatas +end + +-- [好感度剧情] +function XFavorabilityConfigs.GetCharacterStoryById(characterId) + local storys = CharacterStory[characterId] + return storys +end + +-- [好感度剧情解锁等级] +function XFavorabilityConfigs.GetCharacterStoryUnlockLvsById(characterId) + local storyUnlockDatas = CharacterStoryUnlockLv[characterId] + if not storyUnlockDatas then + XLog.ErrorTableDataNotFound("XFavorabilityConfigs.GetCharacterStoryUnlockLvsById", + "CharacterStoryUnlockLv", TABLE_LIKE_STORY, "characterId", tostring(characterId)) + return + end + return storyUnlockDatas +end + +-- [好感度礼物-送礼] +function XFavorabilityConfigs.GetAllCharacterSendGift() + if not CharacterSendGift then + XLog.Error("XFavorabilityConfigs.GetAllCharacterSendGift 函数错误, 配置表:" .. TABLE_LIKE_TRUSTITEM .. " 读取失败, 检查配置表") + return + end + return CharacterSendGift +end + +-- [好感度礼物-奖励] +function XFavorabilityConfigs.GetCharacterGiftRewardById(characterId) + local giftReward = CharacterGiftReward[characterId] + if not giftReward then + XLog.Error("XFavorabilityConfigs.GetCharacterGiftRewardById error: not data found by characterId " .. tostring(characterId)) + return + end + return giftReward +end + +function XFavorabilityConfigs.GetLikeRewardById(rewardId) + if not likeReward then + XLog.Error("XFavorabilityConfigs.GetLikeRewardById error: not data found by rewardId " .. tostring(rewardId)) + return + end + return likeReward[rewardId] +end + +function XFavorabilityConfigs.GetFavorabilityLevelCfg(level) + local cfgs = CharacterFavorabilityConfig[level] + if not cfgs then + XLog.ErrorTableDataNotFound("XFavorabilityConfigs.GetFavorabilityLevelCfg", + "CharacterFavorabilityConfig", TABLE_LIKE_LEVELCONFIG, "level", tostring(level)) + end + return cfgs +end + +-- CharacterFavorabilityConfig +-- [好感度-等级名字] +function XFavorabilityConfigs.GetWordsWithColor(trustLv, name) + local color = XFavorabilityConfigs.GetFavorabilityLevelCfg(trustLv).WordColor + return string.format("%s", color, name) +end + +-- [好感度-名字-称号] +function XFavorabilityConfigs.GetCharacterNameWithTitle(name, title) + return string.format("%s %s", name, title) +end + +-- [好感度-等级图标] +function XFavorabilityConfigs.GetTrustLevelIconByLevel(level) + return XFavorabilityConfigs.GetFavorabilityLevelCfg(level).LevelIcon +end + +-- [好感度-品质图标] +function XFavorabilityConfigs.GetQualityIconByQuality(quality) + if quality == nil or XFavorabilityConfigs.GiftQualityIcon[quality] == nil then + return XFavorabilityConfigs.GiftQualityIcon[1] + end + return XFavorabilityConfigs.GiftQualityIcon[quality] +end + +function XFavorabilityConfigs.GetCvContent(cvId) + local cvData = nil + + if CS.XAudioManager.CvTemplates:ContainsKey(cvId) then + cvData = CS.XAudioManager.CvTemplates[cvId] + end + + if not cvData then return "" end + return cvData.CvContent[0] or "" +end + +function XFavorabilityConfigs.GetCvContentByIdAndType(cvId, cvType) + local cvData = nil + + if CS.XAudioManager.CvTemplates:ContainsKey(cvId) then + cvData = CS.XAudioManager.CvTemplates[cvId] + end + + if not cvData then return "" end + return cvData.CvContent[cvType - 1] or "" +end + +function XFavorabilityConfigs.GetMaxFavorabilityLevel(characterId) + local characterFavorabilityLevelDatas = CharacterTrustExp[characterId] + if not characterFavorabilityLevelDatas then + XLog.ErrorTableDataNotFound("XFavorabilityConfigs.GetMaxFavorabilityLevel", + "CharacterTrustExp", TABLE_LIKE_TRUSTEXP, "characterId", tostring(characterId)) + return + end + local maxLevel = 1 + for trustLv, levelDatas in pairs(characterFavorabilityLevelDatas) do + if levelDatas.Exp == 0 then + maxLevel = trustLv + break + end + end + + return maxLevel +end + +function XFavorabilityConfigs.GetFavorabilityLevel(characterId, totalExp, startLevel) + local characterFavorabilityLevelDatas = CharacterTrustExp[characterId] + if not characterFavorabilityLevelDatas then + XLog.ErrorTableDataNotFound("XFavorabilityConfigs.GetMaxFavorabilityLevel", + "CharacterTrustExp", TABLE_LIKE_TRUSTEXP, "characterId", tostring(characterId)) + return + end + startLevel = startLevel or 1 + local level = startLevel + local leftExp = totalExp + local levelExp = 0 + for trustLv, levelDatas in pairs(characterFavorabilityLevelDatas) do + if startLevel <= trustLv then + local exp = levelDatas.Exp + levelExp = exp + + if exp == 0 then + level = trustLv + break + end + + + if leftExp < exp then + level = trustLv + break + end + + if totalExp >= exp then + leftExp = leftExp - exp + end + end + end + + return level, leftExp, levelExp +end + +--是不是联动角色 +function XFavorabilityConfigs.IsCollaborationCharacter(characterId) + return CharacterCollaboration[characterId] +end + +--联动角色语种 +function XFavorabilityConfigs.GetCollaborationCharacterCvType(characterId) + if XFavorabilityConfigs.IsCollaborationCharacter(characterId) then + local cvType = string.Split(CharacterCollaboration[characterId].languageSet, "|") + + for k, v in pairs(cvType) do + cvType[k] = tonumber(v) + end + + return cvType + else + return nil + end +end + +--联动角色语种提示 +function XFavorabilityConfigs.GetCollaborationCharacterText(characterId) + if XFavorabilityConfigs.IsCollaborationCharacter(characterId) then + return CharacterCollaboration[characterId].Text + else + return nil + end +end + +--联动角色Logo +function XFavorabilityConfigs.GetCollaborationCharacterIcon(characterId) + if XFavorabilityConfigs.IsCollaborationCharacter(characterId) then + return CharacterCollaboration[characterId].IconPath + else + return nil + end +end + +--联动角色Logo位置 +function XFavorabilityConfigs.GetCollaborationCharacterIconPos(characterId) + if XFavorabilityConfigs.IsCollaborationCharacter(characterId) then + local pos = {} + pos.X = CharacterCollaboration[characterId].IconX + pos.Y = CharacterCollaboration[characterId].IconY + return pos + else + return nil + end +end + +--联动角色Logo缩放 +function XFavorabilityConfigs.GetCollaborationCharacterIconScale(characterId) + if XFavorabilityConfigs.IsCollaborationCharacter(characterId) then + return CharacterCollaboration[characterId].IconScale + else + return nil + end +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XFestivalActivityConfig.lua b/Resources/Scripts/XConfig/XFestivalActivityConfig.lua new file mode 100644 index 00000000..2ce54693 --- /dev/null +++ b/Resources/Scripts/XConfig/XFestivalActivityConfig.lua @@ -0,0 +1,64 @@ +XFestivalActivityConfig = XFestivalActivityConfig or {} + +local CLIENT_FESTIVAL_STAGE = "Client/Fuben/Festival/FestivalStage.tab" --庆典关卡客户端表 +local SHARE_FESTIVAL = "Share/Fuben/Festival/FestivalActivity.tab" + +local ShareFestival = {} +local ClientFestivalStages = {} + +--活动名称Id +XFestivalActivityConfig.ActivityId = { + Christmas = 1, + MainLine = 2, + NewYear = 3, + FoolsDay = 4, +} + +function XFestivalActivityConfig.Init() + ClientFestivalStages = XTableManager.ReadByIntKey(CLIENT_FESTIVAL_STAGE, XTable.XTableFestivalStage, "StageId") + ShareFestival = XTableManager.ReadByIntKey(SHARE_FESTIVAL, XTable.XTableFestivalActivity, "Id") +end + +function XFestivalActivityConfig.GetFestivalsTemplates() + return ShareFestival +end + +function XFestivalActivityConfig.GetFestivalById(id) + if not id then return end + local festivalDatas = ShareFestival[id] + if not festivalDatas then + XLog.ErrorTableDataNotFound("XFestivalActivityConfig.GetFestivalById", "FestivalActivity", SHARE_FESTIVAL, "Id", tostring(id)) + return + end + return festivalDatas +end + +function XFestivalActivityConfig.GetFestivalTime(id) + local config = XFestivalActivityConfig.GetFestivalById(id) + return XFunctionManager.GetTimeByTimeId(config.TimeId) +end + +function XFestivalActivityConfig.IsOffLine(id) + local config = XFestivalActivityConfig.GetFestivalById(id) + return not XTool.IsNumberValid(config.TimeId) +end + +--==================== +--获取庆典活动关卡配置 +--@param stageId:关卡ID +--@return 庆典活动关卡配置 +--==================== +function XFestivalActivityConfig.GetFestivalStageCfgByStageId(stageId) + if not ClientFestivalStages[stageId] then + --[[ + XLog.ErrorTableDataNotFound( + "XFestivalActivityConfig.GetFestivalStageCfgByStageId", + "庆典活动关卡", + CLIENT_FESTIVAL_STAGE, + "StageId", + tostring(stageId)) + ]] + return nil + end + return ClientFestivalStages[stageId] +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XFightWordsConfigs.lua b/Resources/Scripts/XConfig/XFightWordsConfigs.lua new file mode 100644 index 00000000..2c8d6a1f --- /dev/null +++ b/Resources/Scripts/XConfig/XFightWordsConfigs.lua @@ -0,0 +1,25 @@ +XFightWordsConfigs = XFightWordsConfigs or {} + +local TABLE_MOVIE_PATH_PREFIX = "Client/Fight/Words/Words.tab" +local WordsTemplates + +local function InitWordsTemplate(id) + if not WordsTemplates then + WordsTemplates = {} + local wordsArray = XTableManager.ReadArray(TABLE_MOVIE_PATH_PREFIX, XTable.XTableFightWords) + for i = 1, #wordsArray do + local group = wordsArray[i]["Group"] + if not WordsTemplates[group] then + WordsTemplates[group] = {} + end + table.insert(WordsTemplates[group],wordsArray[i]) + end + end +end + +function XFightWordsConfigs.GetMovieCfg(id) + if not WordsTemplates then + InitWordsTemplate(id) + end + return WordsTemplates[id] +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XFingerGuessingConfig.lua b/Resources/Scripts/XConfig/XFingerGuessingConfig.lua new file mode 100644 index 00000000..9c569438 --- /dev/null +++ b/Resources/Scripts/XConfig/XFingerGuessingConfig.lua @@ -0,0 +1,156 @@ +-- 猜拳小游戏配置表 +XFingerGuessingConfig = {} + +-- ===================表地址 +local SHARE_TABLE_PATH = "Share/MiniActivity/FingerGuessingGame/" +local CLIENT_TABLE_PATH = "Client/MiniActivity/FingerGuessingGame/" +local TABLE_ACTIVITY = SHARE_TABLE_PATH .. "FingerGuessingActivity.tab" +local TABLE_STAGE = SHARE_TABLE_PATH .. "FingerGuessingStage.tab" +local TABLE_ROUND = SHARE_TABLE_PATH .. "FingerGuessingStageRound.tab" +local TABLE_FINGER = SHARE_TABLE_PATH .. "FingerGuessingFinger.tab" +-- ===================原表数据 +local FingerGuessingActivityConfig = {} +local FingerGuessingStageConfig = {} +local FingerGuessingRoundConfig = {} +local FingerGuessingFingerConfig = {} +-- ===================构建字典 +local Stage2RoundDic = {} + +local CreateStage2RoundDic = function() + for _, roundConfig in pairs(FingerGuessingRoundConfig) do + local stageId = roundConfig.StageId + if not Stage2RoundDic[stageId] then Stage2RoundDic[stageId] = {} end + Stage2RoundDic[stageId][roundConfig.Round] = roundConfig + end +end +--================ +--初始化Config +--================ +function XFingerGuessingConfig.Init() + FingerGuessingActivityConfig = XTableManager.ReadByIntKey(TABLE_ACTIVITY, XTable.XTableFingerGuessingActivity, "Id") + FingerGuessingStageConfig = XTableManager.ReadByIntKey(TABLE_STAGE, XTable.XTableFingerGuessingStage, "Id") + FingerGuessingRoundConfig = XTableManager.ReadByIntKey(TABLE_ROUND, XTable.XTableFingerGuessingStageRound, "Id") + FingerGuessingFingerConfig = XTableManager.ReadByIntKey(TABLE_FINGER, XTable.XTableFingerGuessingFinger, "Id") + CreateStage2RoundDic() +end +--================ +--获取所有活动配置 +--================ +function XFingerGuessingConfig.GetAllActivityConfig() + return FingerGuessingActivityConfig +end +--================ +--获取最后的活动配置 +--================ +function XFingerGuessingConfig.GetLastestActivityConfig() + local id = 0 + for configId, _ in pairs(FingerGuessingActivityConfig) do + if configId > id then + id = configId + end + end + return FingerGuessingActivityConfig[id] +end +--================ +--根据活动Id获取活动配置 +--@param activityId:活动Id +--================ +function XFingerGuessingConfig.GetActivityConfigById(activityId) + local config = FingerGuessingActivityConfig[activityId] + if not config then + XLog.ErrorTableDataNotFound( + "XFingerGuessingConfig.GetActivityConfigById", + "猜拳小游戏基础配置", + TABLE_ACTIVITY, + "Id", + tostring(activityId)) + return nil + end + return config +end +--================ +--获取所有关卡配置 +--================ +function XFingerGuessingConfig.GetAllStageConfig() + return FingerGuessingStageConfig +end +--================ +--根据关卡Id获取关卡配置 +--@param stageId:关卡Id +--================ +function XFingerGuessingConfig.GetStageConfigById(stageId) + local config = FingerGuessingStageConfig[stageId] + if not config then + XLog.ErrorTableDataNotFound( + "XFingerGuessingConfig.GetStageConfigById", + "猜拳小游戏关卡配置", + TABLE_STAGE, + "Id", + tostring(stageId)) + return nil + end + return config +end +--================ +--获取所有小局配置 +--================ +function XFingerGuessingConfig.GetAllRoundConfig() + return FingerGuessingRoundConfig +end +--================ +--根据小局Id获取小局配置 +--@param roundId:小局Id +--================ +function XFingerGuessingConfig.GetRoundConfigById(roundId) + local config = FingerGuessingRoundConfig[roundId] + if not config then + XLog.ErrorTableDataNotFound( + "XFingerGuessingConfig.GetRoundConfigById", + "猜拳小游戏小局配置", + TABLE_ROUND, + "Id", + tostring(roundId)) + return nil + end + return config +end +--================ +--获取所有出拳配置 +--================ +function XFingerGuessingConfig.GetAllFingerConfig() + return FingerGuessingFingerConfig +end +--================ +--根据关卡Id获取该关卡的所有小局配置 +--@param stageId:关卡Id +--================ +function XFingerGuessingConfig.GetRoundConfigByStageId(stageId) + local configs = Stage2RoundDic[stageId] + if not configs then + XLog.ErrorTableDataNotFound( + "XFingerGuessingConfig.GetRoundConfigByStageId", + "猜拳小游戏小局配置", + TABLE_ROUND, + "StageId", + tostring(stageId)) + return {} + end + return configs +end +--================ +--根据出拳ID获取出拳配置 +--@param fingerId:出拳ID +--================ +function XFingerGuessingConfig.GetFingerConfigById(fingerId) + local config = FingerGuessingFingerConfig[fingerId] + if not config then + XLog.ErrorTableDataNotFound( + "XFingerGuessingConfig.GetFingerConfigById", + "猜拳小游戏出拳配置", + TABLE_FINGER, + "Id", + tostring(fingerId)) + return nil + end + return config +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XFubenActivityBossSingleConfigs.lua b/Resources/Scripts/XConfig/XFubenActivityBossSingleConfigs.lua new file mode 100644 index 00000000..ef87c559 --- /dev/null +++ b/Resources/Scripts/XConfig/XFubenActivityBossSingleConfigs.lua @@ -0,0 +1,180 @@ +local TABLE_BOSS_ACTIVITY_PATH = "Share/Fuben/BossActivity/BossActivity.tab" +local TABLE_BOSS_SECTION_PATH = "Share/Fuben/BossActivity/BossSection.tab" +local TABLE_BOSS_CHALLENGE_PATH = "Share/Fuben/BossActivity/BossChallenge.tab" +local TABLE_BOSS_CHALLENGE_RES_PATH = "Client/Fuben/BossActivity/BossChallengeRes.tab" +local TABLE_BOSS_STARREWARD_PATH = "Share/Fuben/BossActivity/BossStarReward.tab" + +local pairs = pairs + +local BossActivityTemplates = {} +local BossSectionTemplates = {} +local BossChallengeTemplates = {} +local BossChallengeResTemplates = {} +local BossStarRewardTemplates = {} + +local DefaultActivityId = 0 +local ChallengeIdToOrderIdDic = {} +local StageIdToChallengeIdDic = {} + +XFubenActivityBossSingleConfigs = XFubenActivityBossSingleConfigs or {} + +function XFubenActivityBossSingleConfigs.Init() + BossActivityTemplates = XTableManager.ReadByIntKey(TABLE_BOSS_ACTIVITY_PATH, XTable.XTableBossActivity, "Id") + BossSectionTemplates = XTableManager.ReadByIntKey(TABLE_BOSS_SECTION_PATH, XTable.XTableBossSection, "Id") + BossChallengeTemplates = XTableManager.ReadByIntKey(TABLE_BOSS_CHALLENGE_PATH, XTable.XTableBossChallenge, "Id") + BossChallengeResTemplates = XTableManager.ReadByIntKey(TABLE_BOSS_CHALLENGE_RES_PATH, XTable.XTableBossChallengeRes, "Id") + BossStarRewardTemplates = XTableManager.ReadByIntKey(TABLE_BOSS_STARREWARD_PATH, XTable.XTableBossStarReward, "Id") + + for activityId, config in pairs(BossActivityTemplates) do + if XTool.IsNumberValid(config.ActivityTimeId) then + DefaultActivityId = activityId + break + end + DefaultActivityId = activityId--若全部过期,取最后一行配置作为默认下次开启的活动ID + end + + for _, sectionCfg in pairs(BossSectionTemplates) do + for index, challengeId in ipairs(sectionCfg.ChallengeId) do + ChallengeIdToOrderIdDic[challengeId] = index + end + end + + for challengeId, challengeCfg in pairs(BossChallengeTemplates) do + StageIdToChallengeIdDic[challengeCfg.StageId] = challengeId + end +end + +function XFubenActivityBossSingleConfigs.GetSectionCfgs() + return BossSectionTemplates +end + +function XFubenActivityBossSingleConfigs.GetSectionCfg(sectionId) + local sectionCfg = BossSectionTemplates[sectionId] + if not sectionCfg then + XLog.ErrorTableDataNotFound("XFubenActivityBossSingleConfigs.GetSectionCfg", + "BossSection", TABLE_BOSS_SECTION_PATH, "sectionId", tostring(sectionId)) + return + end + return sectionCfg +end + +function XFubenActivityBossSingleConfigs.GetStageId(challengeId) + local challengeCfg = BossChallengeTemplates[challengeId] + if not challengeCfg then + XLog.ErrorTableDataNotFound("XFubenActivityBossSingleConfigs.GetStageId", + "BossChallenge", TABLE_BOSS_CHALLENGE_PATH, "challengeId", tostring(challengeId)) + return + end + return challengeCfg.StageId +end + +function XFubenActivityBossSingleConfigs.GetChanllengeIdByStageId(stageId) + return StageIdToChallengeIdDic[stageId] +end + +function XFubenActivityBossSingleConfigs.GetChallengeResCfg(challengeId) + local challengeResCfg = BossChallengeResTemplates[challengeId] + if not challengeResCfg then + XLog.ErrorTableDataNotFound("XFubenActivityBossSingleConfigs.GetChallengeResCfg", + "BossChallengeRes", TABLE_BOSS_CHALLENGE_RES_PATH, "challengeId", tostring(challengeId)) + return + end + return challengeResCfg +end + +function XFubenActivityBossSingleConfigs.GetChallengeOrderId(challengeId) + return ChallengeIdToOrderIdDic[challengeId] or 0 +end + +function XFubenActivityBossSingleConfigs.GetActivityConfig(activityId) + local activityCfg = BossActivityTemplates[activityId] + return activityCfg +end + +function XFubenActivityBossSingleConfigs.GetDefaultActivityId() + return DefaultActivityId +end + +function XFubenActivityBossSingleConfigs.GetBossChallengeTemplates() + return BossChallengeTemplates +end + +function XFubenActivityBossSingleConfigs.GetStageAttention(stageId) + if BossChallengeTemplates == nil then + return + end + local challengeId = XFubenActivityBossSingleConfigs.GetChanllengeIdByStageId(stageId) + if BossChallengeTemplates[challengeId].StageAttention ~= nil then + return BossChallengeTemplates[challengeId].StageAttention + end + return nil +end + +function XFubenActivityBossSingleConfigs.GetStageAttentionTitle(stageId) + if BossChallengeTemplates == nil then + return + end + local challengeId = XFubenActivityBossSingleConfigs.GetChanllengeIdByStageId(stageId) + if BossChallengeTemplates[challengeId].StageAttention ~= nil then + return BossChallengeTemplates[challengeId].StageAttentionTitle + end + return nil +end + +function XFubenActivityBossSingleConfigs.GetChallengeCount(sectionId) + return #BossSectionTemplates[sectionId].ChallengeId +end + +function XFubenActivityBossSingleConfigs.GetBossSectionRewardIds(sectionId) + return BossSectionTemplates[sectionId].StarRewardId +end + +function XFubenActivityBossSingleConfigs.GetStarRewardCfg(Id) + return BossStarRewardTemplates[Id] +end + +function XFubenActivityBossSingleConfigs.GetStarRewardTemplates() + return BossStarRewardTemplates +end + +function XFubenActivityBossSingleConfigs.GetBossChallengeEffectPath(stageId) + if BossChallengeTemplates == nil then + return + end + local challengeId = XFubenActivityBossSingleConfigs.GetChanllengeIdByStageId(stageId) + if BossChallengeTemplates[challengeId].EffectPath ~= nil then + return BossChallengeTemplates[challengeId].EffectPath + end + return nil +end + +function XFubenActivityBossSingleConfigs.GetLastBossActivityTemplates() + return BossActivityTemplates[#BossActivityTemplates] +end + +function XFubenActivityBossSingleConfigs.GetActivityBeginTime(activityId) + local config = XFubenActivityBossSingleConfigs.GetActivityConfig(activityId) + if not config then + config = XFubenActivityBossSingleConfigs.GetLastBossActivityTemplates() + end + + return config and XFunctionManager.GetStartTimeByTimeId(config.ActivityTimeId) or 0 +end + +function XFubenActivityBossSingleConfigs.GetActivityEndTime(activityId) + local config = XFubenActivityBossSingleConfigs.GetActivityConfig(activityId) + if not config then + config = XFubenActivityBossSingleConfigs.GetLastBossActivityTemplates() + end + + return config and XFunctionManager.GetEndTimeByTimeId(config.ActivityTimeId) or 0 +end + +function XFubenActivityBossSingleConfigs.GetFightEndTime(activityId) + local config = XFubenActivityBossSingleConfigs.GetActivityConfig(activityId) + if not config then + config = XFubenActivityBossSingleConfigs.GetLastBossActivityTemplates() + end + + return config and XFunctionManager.GetEndTimeByTimeId(config.FightTimeId) or 0 +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XFubenActivityBranchConfigs.lua b/Resources/Scripts/XConfig/XFubenActivityBranchConfigs.lua new file mode 100644 index 00000000..b18ab116 --- /dev/null +++ b/Resources/Scripts/XConfig/XFubenActivityBranchConfigs.lua @@ -0,0 +1,85 @@ +local TABLE_FUBEN_BRANCH_ACTIVITY_PATH = "Share/Fuben/FubenBranch/FubenBranchActivity.tab" +local TABLE_FUBEN_BRANCH_CHALLENGE_PATH = "Share/Fuben/FubenBranch/FubenBranchChallenge.tab" +local TABLE_FUBEN_BRANCH_SECTION_PATH = "Share/Fuben/FubenBranch/FubenBranchSection.tab" + +local pairs = pairs + +local FubenBranchTemplates = {} +local FubenBranchSectionTemplates = {} +local FubenBranchChallengeTemplates = {} + +local DefaultActivityId = 0 + +XFubenActivityBranchConfigs = XFubenActivityBranchConfigs or {} + +function XFubenActivityBranchConfigs.Init() + FubenBranchTemplates = XTableManager.ReadByIntKey(TABLE_FUBEN_BRANCH_ACTIVITY_PATH, XTable.XTableFubenBranchActivity, "Id") + FubenBranchSectionTemplates = XTableManager.ReadByIntKey(TABLE_FUBEN_BRANCH_SECTION_PATH, XTable.XTableFubenBranchSection, "Id") + FubenBranchChallengeTemplates = XTableManager.ReadByIntKey(TABLE_FUBEN_BRANCH_CHALLENGE_PATH, XTable.XTableFubenBranchChallenge, "Id") + + for activityId, config in pairs(FubenBranchTemplates) do + if XTool.IsNumberValid(config.ActivityTimeId) then + DefaultActivityId = activityId + break + end + DefaultActivityId = activityId--若全部过期,取最后一行配置作为默认下次开启的活动ID + end +end + +function XFubenActivityBranchConfigs.GetSectionCfgs() + return FubenBranchSectionTemplates +end + +function XFubenActivityBranchConfigs.GetChapterCfg(chapterId) + local chapterCfg = FubenBranchChallengeTemplates[chapterId] + if not chapterCfg then + XLog.ErrorTableDataNotFound("XFubenActivityBranchConfigs.GetChapterCfg", + "FubenBranchChallenge", TABLE_FUBEN_BRANCH_CHALLENGE_PATH, "chapterId", tostring(chapterId)) + return + end + return chapterCfg +end + +function XFubenActivityBranchConfigs.GetSectionCfg(sectionId) + local sectionCfg = FubenBranchSectionTemplates[sectionId] + if not sectionCfg then + XLog.ErrorTableDataNotFound("XFubenActivityBranchConfigs.GetSectionCfg", + "FubenBranchSection", TABLE_FUBEN_BRANCH_SECTION_PATH, "sectionId", tostring(sectionId)) + return + end + return sectionCfg +end + +function XFubenActivityBranchConfigs.GetActivityConfig(activityId) + local activityCfg = FubenBranchTemplates[activityId] + if not activityCfg then + XLog.ErrorTableDataNotFound("XFubenActivityBranchConfigs.GetActivityConfig", + "FubenBranch", TABLE_FUBEN_BRANCH_ACTIVITY_PATH, "activityId", tostring(activityId)) + return + end + return activityCfg +end + +function XFubenActivityBranchConfigs.GetDefaultActivityId() + return DefaultActivityId +end + +function XFubenActivityBranchConfigs.GetActivityBeginTime(activityId) + local config = XFubenActivityBranchConfigs.GetActivityConfig(activityId) + return XFunctionManager.GetStartTimeByTimeId(config.ActivityTimeId) +end + +function XFubenActivityBranchConfigs.GetActivityEndTime(activityId) + local config = XFubenActivityBranchConfigs.GetActivityConfig(activityId) + return XFunctionManager.GetEndTimeByTimeId(config.ActivityTimeId) +end + +function XFubenActivityBranchConfigs.GetChallengeBeginTime(activityId) + local config = XFubenActivityBranchConfigs.GetActivityConfig(activityId) + return XFunctionManager.GetStartTimeByTimeId(config.ChallengeTimeId) +end + +function XFubenActivityBranchConfigs.GetFightEndTime(activityId) + local config = XFubenActivityBranchConfigs.GetActivityConfig(activityId) + return XFunctionManager.GetEndTimeByTimeId(config.FightTimeId) +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XFubenActivityPuzzleConfigs.lua b/Resources/Scripts/XConfig/XFubenActivityPuzzleConfigs.lua new file mode 100644 index 00000000..7533ffbc --- /dev/null +++ b/Resources/Scripts/XConfig/XFubenActivityPuzzleConfigs.lua @@ -0,0 +1,148 @@ +local tableInsert = table.insert + +XFubenActivityPuzzleConfigs = XFubenActivityPuzzleConfigs or {} + +XFubenActivityPuzzleConfigs.PuzzleState = { + Incomplete = 0, + Complete = 1, + PuzzleCompleteButNotDecryption = 2, +} + +XFubenActivityPuzzleConfigs.CompleteRewardState = { + Unrewarded = 0, + Rewarded = 1, +} + +XFubenActivityPuzzleConfigs.PlayVideoState = { + UnPlay = 0, + Played = 1, +} + +XFubenActivityPuzzleConfigs.HelpHitFaceState = { + UnHit = 0, + Hited = 1, +} + +XFubenActivityPuzzleConfigs.PuzzleType = { + Define = 1, + Decryption = 2, +} + +XFubenActivityPuzzleConfigs.PLAY_VIDEO_STATE_KEY = "DRAG_PUZZLE_PLAY_VIDEO_STATE_KEY" +XFubenActivityPuzzleConfigs.HELP_HIT_FACE_KEY = "DRAG_PUZZLE_HELP_HIT_FACE_KEY" +XFubenActivityPuzzleConfigs.PASSWORD_HIT_MESSAGE_COUNT = "PASSWORD_HIT_MESSAGE_COUNT" + +local DRAG_PUZZLE_ACTIVITY_PATH = "Share/MiniActivity/DragPuzzle/DragPuzzleActivity.tab" +local DRAG_PUZZLE_ACTIVITY_PUZZLE_PATH = "Share/MiniActivity/DragPuzzle/DragPuzzleActivityPuzzle.tab" +local DRAG_PUZZLE_ACTIVITY_PIECE_PATH = "Share/MiniActivity/DragPuzzle/DragPuzzleActivityPiece.tab" +local DRAG_PUZZLE_ACTIVITY_PASSWORD_PATH = "Share/MiniActivity/DragPuzzle/DragPuzzleActivityPassword.tab" + +local ActivityTemplates = {} +local PuzzleTemplates = {} +local PuzzleTemplatesWithAct = {} +local PieceTemplates = {} +local PieceTemplatesWithPuzzle = {} +local PuzzleDecryptionPassword = {} + +function XFubenActivityPuzzleConfigs.Init() + ActivityTemplates = XTableManager.ReadByIntKey(DRAG_PUZZLE_ACTIVITY_PATH, XTable.XTableDragPuzzleActivity, "Id") + + PuzzleTemplates = XTableManager.ReadByIntKey(DRAG_PUZZLE_ACTIVITY_PUZZLE_PATH, XTable.XTableDragPuzzleActivityPuzzle, "Id") + for _, puzzleInfo in ipairs(PuzzleTemplates) do + if not PuzzleTemplatesWithAct[puzzleInfo.ActId] then + PuzzleTemplatesWithAct[puzzleInfo.ActId] = {} + end + tableInsert(PuzzleTemplatesWithAct[puzzleInfo.ActId], puzzleInfo) + end + + PieceTemplates = XTableManager.ReadByIntKey(DRAG_PUZZLE_ACTIVITY_PIECE_PATH, XTable.XTableDragPuzzleActivityPiece, "Id") + for _, pieceInfo in ipairs(PieceTemplates) do + if not PieceTemplatesWithPuzzle[pieceInfo.PuzzleId] then + PieceTemplatesWithPuzzle[pieceInfo.PuzzleId] = {} + end + tableInsert(PieceTemplatesWithPuzzle[pieceInfo.PuzzleId], pieceInfo) + end + + local puzzlePasswordTemplates = XTableManager.ReadByIntKey(DRAG_PUZZLE_ACTIVITY_PASSWORD_PATH, XTable.XTableDragPuzzleActivityPassword, "Id") + PuzzleDecryptionPassword = {} + for _, puzzlePasswordTemplate in ipairs(puzzlePasswordTemplates) do + PuzzleDecryptionPassword[puzzlePasswordTemplate.PuzzleId] = puzzlePasswordTemplate + end +end + +function XFubenActivityPuzzleConfigs.GetActivityTemplates() + if not ActivityTemplates then + return nil + end + + return ActivityTemplates +end + +function XFubenActivityPuzzleConfigs.GetActivityTemplateById(actId) + if not ActivityTemplates then + return nil + end + + return ActivityTemplates[actId] +end + +function XFubenActivityPuzzleConfigs.GetPuzzleTemplateById(id) + return PuzzleTemplates[id] +end + +function XFubenActivityPuzzleConfigs.GetPuzzleTemplatesByActId(actId) + if not PuzzleTemplatesWithAct then + return nil + end + + return PuzzleTemplatesWithAct[actId] +end + +function XFubenActivityPuzzleConfigs.GetPieceTemplatesByPuzzleId(puzzleId) + if not PieceTemplatesWithPuzzle then + return nil + end + + return PieceTemplatesWithPuzzle[puzzleId] +end + +function XFubenActivityPuzzleConfigs.GetPieceIconById(pieceId) + return PieceTemplates[pieceId].FragmentUrl +end + +function XFubenActivityPuzzleConfigs.GetPieceCorrectIdxById(pieceId) + return PieceTemplates[pieceId].CorrectIdx +end + +function XFubenActivityPuzzleConfigs.GetPuzzlePasswordHintById(puzzleId) + if not PuzzleDecryptionPassword[puzzleId] then + XLog.Error("Can Find Password Info By PieceId:" .. puzzleId .. ",Plase Check " ..DRAG_PUZZLE_ACTIVITY_PASSWORD_PATH) + end + + return PuzzleDecryptionPassword[puzzleId].PasswordHint +end + +function XFubenActivityBossSingleConfigs.GetPuzzlePasswordHintMessage(puzzleId) + if not PuzzleDecryptionPassword[puzzleId] then + XLog.Error("Can Find Password Info By PieceId:" .. puzzleId .. ",Plase Check " ..DRAG_PUZZLE_ACTIVITY_PASSWORD_PATH) + end + + return PuzzleDecryptionPassword[puzzleId].HintMessage +end + +function XFubenActivityPuzzleConfigs.GetPuzzlePasswordLengthById(puzzleId) + if not PuzzleDecryptionPassword[puzzleId] then + XLog.Error("Can Find Password Info By PieceId:" .. puzzleId .. ",Plase Check " ..DRAG_PUZZLE_ACTIVITY_PASSWORD_PATH) + return 0 + end + + return #PuzzleDecryptionPassword[puzzleId].Password +end + +function XFubenActivityPuzzleConfigs.GetPuzzleDecryptionImgUrl(puzzleId) + if not PuzzleDecryptionPassword[puzzleId] then + XLog.Error("Can Find Password Info By PieceId:" .. puzzleId .. ",Plase Check " ..DRAG_PUZZLE_ACTIVITY_PASSWORD_PATH) + end + + return PuzzleDecryptionPassword[puzzleId].DecryptionImgUrl +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XFubenAssignConfigs.lua b/Resources/Scripts/XConfig/XFubenAssignConfigs.lua new file mode 100644 index 00000000..86b0918d --- /dev/null +++ b/Resources/Scripts/XConfig/XFubenAssignConfigs.lua @@ -0,0 +1,50 @@ +XFubenAssignConfigs = XFubenAssignConfigs or {} + +local ChapterTemplates = {} +local GroupTemplates = {} +local TeamInfoTemplates = {} + +function XFubenAssignConfigs.Init() + ChapterTemplates = XTableManager.ReadByIntKey("Share/Fuben/Assign/AssignChapter.tab", XTable.XTableAssignChapter, "ChapterId") + GroupTemplates = XTableManager.ReadByIntKey("Share/Fuben/Assign/AssignGroup.tab", XTable.XTableAssignGroup, "GroupId") + TeamInfoTemplates = XTableManager.ReadByIntKey("Share/Fuben/Assign/AssignTeamInfo.tab", XTable.XTableAssignTeamInfo, "Id") +end + +function XFubenAssignConfigs.GetChapterTemplates() + return ChapterTemplates +end + +function XFubenAssignConfigs.GetGroupTemplates() + return GroupTemplates +end + +function XFubenAssignConfigs.GetTeamInfoTemplates() + return TeamInfoTemplates +end + +function XFubenAssignConfigs.GetChapterTemplateById(id) + local config = ChapterTemplates[id] + if not config then + XLog.ErrorTableDataNotFound("XFubenAssignConfigs.GetChapterTemplateById", + "AssignChapter", "Share/Fuben/Assign/AssignChapter.tab", "Id", tostring(id)) + end + return config +end + +function XFubenAssignConfigs.GetGroupTemplateById(id) + local config = GroupTemplates[id] + if not config then + XLog.ErrorTableDataNotFound("XFubenAssignConfigs.GetGroupTemplateById", + "AssignGroup", "Share/Fuben/Assign/AssignGroup.tab", "Id", tostring(id)) + end + return config +end + +function XFubenAssignConfigs.GetTeamInfoTemplateById(id) + local config = TeamInfoTemplates[id] + if not config then + XLog.ErrorTableDataNotFound("XFubenAssignConfigs.GetTeamInfoTemplateById", + "AssignTeamInfo", "Share/Fuben/Assign/AssignTeamInfo.tab", "Id", tostring(id)) + end + return config +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XFubenBabelTowerConfigs.lua b/Resources/Scripts/XConfig/XFubenBabelTowerConfigs.lua new file mode 100644 index 00000000..51339187 --- /dev/null +++ b/Resources/Scripts/XConfig/XFubenBabelTowerConfigs.lua @@ -0,0 +1,407 @@ +local tableInsert = table.insert + +XFubenBabelTowerConfigs = {} + +local SHARE_BABEL_ACTIVITY = "Share/Fuben/BabelTower/BabelTowerActivity.tab" +local SHARE_BABEL_BUFF = "Share/Fuben/BabelTower/BabelTowerBuff.tab" +local SHARE_BABEL_BUFFGROUP = "Share/Fuben/BabelTower/BabelTowerBuffGroup.tab" +local SHARE_BABEL_RANKLEVEL = "Share/Fuben/BabelTower/BabelTowerRankLevel.tab" +local SHARE_BABEL_STAGE = "Share/Fuben/BabelTower/BabelTowerStage.tab" +local SHARE_BABEL_STAGEGUIDE = "Share/Fuben/BabelTower/BabelTowerStageGuide.tab" +local SHARE_BABEL_SUPPORTCONDITION = "Share/Fuben/BabelTower/BabelTowerSupportCondition.tab" +local SHARE_BABEL_RANKREWARD = "Share/Fuben/BabelTower/BabelTowerRankReward.tab" +local SHARE_BABEL_STAGELEVEL = "Share/Fuben/BabelTower/BabelTowerStageLevel.tab" + +local CLIENT_BABEL_STAGEGUIDEDETAIL = "Client/Fuben/BabelTower/BabelTowerStageGuideDetails.tab" +local CLIENT_BABEL_BUFFDETAIL = "Client/Fuben/BabelTower/BabelTowerBuffDetails.tab" +local CLIENT_BABEL_BUFFGROUPDETAIL = "Client/Fuben/BabelTower/BabelTowerBuffGroupDetails.tab" +local CLIENT_BABEL_ACTIVITYDIFFICULTY = "Client/Fuben/BabelTower/BabelTowerActivityDifficulty.tab" +local CLIENT_BABEL_STAGEDETAIL = "Client/Fuben/BabelTower/BabelTowerStageDetails.tab" +local CLIENT_BABEL_ACTIVITYDETAIL = "Client/Fuben/BabelTower/BabelTowerActivityDetails.tab" +local CLIENT_BABEL_CONDITIONDETAIL = "Client/Fuben/BabelTower/BabelTowerConditionDetails.tab" + +local BabelActivityTemplate = {} +local BabelBuffTemplate = {} +local BabelBuffGroupTemplate = {} +local BabelRankLevelTemplate = {} +local BabelStageTemplate = {} +local BabelStageGuideTemplate = {} +local BabelSupportConditionTemplate = {} +local BabelRankRewardTemplate = {} +local BabelStageLevelDic = {} +local BabelStageLevelLockBuffIdDic = {} + +local BabelStageGuideDetailsConfigs = {} +local BabelBuffDetailsConfigs = {} +local BabelBuffGroupDetailsConfigs = {} +local BabelActivityDifficultyConfigs = {} +local BabelStageConfigs = {} +local BabelActivityDetailsConfigs = {} +local BabelConditionDetailsConfigs = {} + +XFubenBabelTowerConfigs.MAX_TEAM_MEMBER = 3 -- 最多出站人数 +XFubenBabelTowerConfigs.LEADER_POSITION = 1 -- 队长位置 +XFubenBabelTowerConfigs.FIRST_FIGHT_POSITION = 1 -- 首发位置 +XFubenBabelTowerConfigs.BabelTowerStatus = { + Close = 0, + Open = 1, + FightEnd = 2, + End = 3 +} + +XFubenBabelTowerConfigs.RankPlaform = { + Win = 0, + Android = 1, + IOS = 2, +} + +XFubenBabelTowerConfigs.RankType = { + NoRank = 0, + OnlyRank = 1, + RankAndReward = 2, +} + +XFubenBabelTowerConfigs.Difficult = { + Default = 0, + Easy = 1, + Normal = 2, + Middle = 3, + Hard = 4, + Count = 4, +} + +XFubenBabelTowerConfigs.RankIcon = { + [1] = CS.XGame.ClientConfig:GetString("BabelTowerRankIcon1"), + [2] = CS.XGame.ClientConfig:GetString("BabelTowerRankIcon2"), + [3] = CS.XGame.ClientConfig:GetString("BabelTowerRankIcon3"), +} + +XFubenBabelTowerConfigs.ChallengePhase = 1 -- 选择挑战阶段 +XFubenBabelTowerConfigs.SupportPhase = 2 -- 选择支援阶段 +XFubenBabelTowerConfigs.CHALLENGE_CHILD_UI = "UiBabelTowerChildChallenge" -- 挑战界面 +XFubenBabelTowerConfigs.SUPPORT_CHILD_UI = "UiBabelTowerChildSupport" -- 支援界面 + +XFubenBabelTowerConfigs.TIPSTYPE_ENVIRONMENT = 1 -- 环境情报 +XFubenBabelTowerConfigs.TIPSTYPE_CHALLENGE = 2 -- 挑战详情 +XFubenBabelTowerConfigs.TIPSTYPE_SUPPORT = 3 -- 支援详情 + +XFubenBabelTowerConfigs.TYPE_CHALLENGE = 1 --挑战类型 +XFubenBabelTowerConfigs.TYPE_SUPPORT = 2 --支援类型 + +-- 准备结束界面tips +XFubenBabelTowerConfigs.BattleReady = 1 +XFubenBabelTowerConfigs.BattleEnd = 2 +XFubenBabelTowerConfigs.MAX_BUFF_COUNT = 10 +XFubenBabelTowerConfigs.MAX_CHALLENGE_BUFF_COUNT = CS.XGame.ClientConfig:GetInt("BabelTowerMaxChallengeBuff") +XFubenBabelTowerConfigs.MAX_SUPPORT_BUFF_COUNT = CS.XGame.ClientConfig:GetInt("BabelTowerMaxSupportBuff") +XFubenBabelTowerConfigs.START_INDEX = 0 + +-- 事态类型 +XFubenBabelTowerConfigs.DIFFICULTY_NONE = 0 +XFubenBabelTowerConfigs.DIFFICULTY_NORMAL = 1 -- 普通 +XFubenBabelTowerConfigs.DIFFICULTY_URGENCY = 2 -- 紧急 +XFubenBabelTowerConfigs.DIFFICULTY_CRITICAL = 3 -- 高危 + +-- 上次选中的StageId key +XFubenBabelTowerConfigs.LAST_SELECT_KEY = "BabelTowerLastSelectedStageId" +-- 第一次查看环境 +XFubenBabelTowerConfigs.ENVIROMENT_DOT_KEY = "babelenvironment_%s_%s_%s" +-- 第一次播放剧情 +XFubenBabelTowerConfigs.HAS_PLAY_BEGINSTORY = "BabelTowerPlayBeginStory" + +local function InitStageLevelConfig() + local template = XTableManager.ReadByIntKey(SHARE_BABEL_STAGELEVEL, XTable.XTableBabelTowerStageLevel, "Id") + + for _, config in pairs(template) do + local stageId = config.StageId + + local stageConfig = BabelStageLevelDic[stageId] + if not stageConfig then + stageConfig = {} + BabelStageLevelDic[stageId] = stageConfig + end + + local level = config.Level + stageConfig[level] = config + + local stageLockBuffIdDic = BabelStageLevelLockBuffIdDic[stageId] + if not stageLockBuffIdDic then + stageLockBuffIdDic = {} + BabelStageLevelLockBuffIdDic[stageId] = stageLockBuffIdDic + end + + local lockBuffIds = config.LockBuffId + for _, buffId in pairs(lockBuffIds) do + if buffId ~= 0 then + local oldLevel = stageLockBuffIdDic[buffId] or 0 + if level > oldLevel then + stageLockBuffIdDic[buffId] = level + end + end + end + end +end + +function XFubenBabelTowerConfigs.Init() + BabelActivityTemplate = XTableManager.ReadByIntKey(SHARE_BABEL_ACTIVITY, XTable.XTableBabelTowerActivity, "Id") + BabelBuffTemplate = XTableManager.ReadByIntKey(SHARE_BABEL_BUFF, XTable.XTableBabelTowerBuff, "Id") + BabelBuffGroupTemplate = XTableManager.ReadByIntKey(SHARE_BABEL_BUFFGROUP, XTable.XTableBabelTowerBuffGroup, "Id") + BabelRankLevelTemplate = XTableManager.ReadByIntKey(SHARE_BABEL_RANKLEVEL, XTable.XTableBabelTowerRankLevel, "Id") + BabelStageTemplate = XTableManager.ReadByIntKey(SHARE_BABEL_STAGE, XTable.XTableBabelTowerStage, "Id") + BabelStageGuideTemplate = XTableManager.ReadByIntKey(SHARE_BABEL_STAGEGUIDE, XTable.XTableBabelTowerStageGuide, "Id") + BabelSupportConditionTemplate = XTableManager.ReadByIntKey(SHARE_BABEL_SUPPORTCONDITION, XTable.XTableBabelTowerSupportCondition, "Id") + BabelRankRewardTemplate = XTableManager.ReadByIntKey(SHARE_BABEL_RANKREWARD, XTable.XTableBabelTowerRankReward, "Id") + + BabelStageGuideDetailsConfigs = XTableManager.ReadByIntKey(CLIENT_BABEL_STAGEGUIDEDETAIL, XTable.XTableBabelTowerStageGuideDetails, "Id") + BabelBuffDetailsConfigs = XTableManager.ReadByIntKey(CLIENT_BABEL_BUFFDETAIL, XTable.XTableBabelTowerBuffDetails, "Id") + BabelBuffGroupDetailsConfigs = XTableManager.ReadByIntKey(CLIENT_BABEL_BUFFGROUPDETAIL, XTable.XTableBabelTowerBuffGroupDetails, "Id") + BabelActivityDifficultyConfigs = XTableManager.ReadByIntKey(CLIENT_BABEL_ACTIVITYDIFFICULTY, XTable.XTableBabelTowerActivityDifficulty, "Id") + BabelStageConfigs = XTableManager.ReadByIntKey(CLIENT_BABEL_STAGEDETAIL, XTable.XTableBabelTowerStageDetails, "Id") + BabelActivityDetailsConfigs = XTableManager.ReadByIntKey(CLIENT_BABEL_ACTIVITYDETAIL, XTable.XTableBabelTowerActivityDetails, "Id") + BabelConditionDetailsConfigs = XTableManager.ReadByIntKey(CLIENT_BABEL_CONDITIONDETAIL, XTable.XTableBabelTowerConditionDetails, "Id") + + InitStageLevelConfig() +end + +function XFubenBabelTowerConfigs.GetActivityName(id) + if not BabelActivityDetailsConfigs[id] then return "" end + return BabelActivityDetailsConfigs[id].Name +end + +function XFubenBabelTowerConfigs.GetActivityBeginStory(id) + if not BabelActivityDetailsConfigs[id] then return nil end + return BabelActivityDetailsConfigs[id].BeginStoryId +end + +function XFubenBabelTowerConfigs.GetActivityRankTitle(id) + if not BabelActivityDetailsConfigs[id] then return nil end + return BabelActivityDetailsConfigs[id].RankTitle +end + +function XFubenBabelTowerConfigs.GetConditionDescription(id) + if not BabelConditionDetailsConfigs[id] then return "" end + return BabelConditionDetailsConfigs[id].Desc +end + +function XFubenBabelTowerConfigs.GetAllBabelTowerActivityTemplate() + return BabelActivityTemplate +end + +function XFubenBabelTowerConfigs.GetBabelTowerActivityTemplateById(id) + if not BabelActivityTemplate[id] then + XLog.ErrorTableDataNotFound("XFubenBabelTowerConfigs.GetBabelTowerActivityTemplateById", + "BabelTowerActivity", SHARE_BABEL_ACTIVITY, "Id", tostring(id)) + return nil + end + return BabelActivityTemplate[id] +end + +-- 获取stage数据,加成相关 +function XFubenBabelTowerConfigs.GetBabelTowerStageTemplate(stageId) + if not BabelStageTemplate[stageId] then + XLog.ErrorTableDataNotFound("XFubenBabelTowerConfigs.GetBabelTowerStageTemplate", + "BabelTowerStage", SHARE_BABEL_STAGE, "stageId", tostring(stageId)) + return nil + end + return BabelStageTemplate[stageId] +end + +function XFubenBabelTowerConfigs.GetBaseBuffIds(stageId) + local buffIds = {} + + local config = XFubenBabelTowerConfigs.GetBabelTowerStageTemplate(stageId) + for _, buffId in pairs(config.BaseBuffId) do + if buffId > 0 then + tableInsert(buffIds, buffId) + end + end + + return buffIds +end + +function XFubenBabelTowerConfigs.GetStageTeamCount(stageId) + local config = XFubenBabelTowerConfigs.GetBabelTowerStageTemplate(stageId) + return config.TeamCount +end + +-- 引导的数据 +function XFubenBabelTowerConfigs.GetBabelTowerStageGuideTemplate(guideId) + if not BabelStageGuideTemplate[guideId] then + XLog.ErrorTableDataNotFound("XFubenBabelTowerConfigs.GetBabelTowerStageGuideTemplate", + "BabelTowerStageGuide", SHARE_BABEL_STAGEGUIDE, "guideId", tostring(guideId)) + return nil + end + return BabelStageGuideTemplate[guideId] +end + +-- 关卡引导的本地数据 +function XFubenBabelTowerConfigs.GetStageGuideConfigs(guideId) + if not BabelStageGuideDetailsConfigs[guideId] then + XLog.ErrorTableDataNotFound("XFubenBabelTowerConfigs.GetStageGuideConfigs", + "StageGuideDetails", CLIENT_BABEL_STAGEGUIDEDETAIL, "guideId", tostring(guideId)) + return nil + end + return BabelStageGuideDetailsConfigs[guideId] +end + +-- buffGroup组的本地数据 +function XFubenBabelTowerConfigs.GetBabelBuffGroupConfigs(buffGroupId) + if not BabelBuffGroupDetailsConfigs[buffGroupId] then + XLog.ErrorTableDataNotFound("XFubenBabelTowerConfigs.GetBuffGroupConfigs", + "BabelBuffGroupDetails", CLIENT_BABEL_BUFFGROUPDETAIL, "buffGroupId", tostring(buffGroupId)) + return nil + end + return BabelBuffGroupDetailsConfigs[buffGroupId] +end + +function XFubenBabelTowerConfigs.IsBuffGroupHard(buffGroupId) + local config = XFubenBabelTowerConfigs.GetBabelBuffGroupConfigs(buffGroupId) + return config and config.IsStress and config.IsStress ~= 0 +end + +-- buff的本地数据 +function XFubenBabelTowerConfigs.GetBabelBuffConfigs(buffId) + if not BabelBuffDetailsConfigs[buffId] then + XLog.ErrorTableDataNotFound("XFubenBabelTowerConfigs.GetBabelBuffConfigs", + "BabelBuffGroupDetails", CLIENT_BABEL_BUFFDETAIL, "buffId", tostring(buffId)) + return nil + end + return BabelBuffDetailsConfigs[buffId] +end + +function XFubenBabelTowerConfigs.GetBaseBuffNameWithSpilt(buffId) + local config = XFubenBabelTowerConfigs.GetBabelBuffConfigs(buffId) + return XUiHelper.RichTextToTextString(config.Name) +end + +-- stage本地数据 +function XFubenBabelTowerConfigs.GetBabelStageConfigs(stageId) + if not BabelStageConfigs[stageId] then + XLog.ErrorTableDataNotFound("XFubenBabelTowerConfigs.GetBabelStageConfigs", + "BabelStageDetails", CLIENT_BABEL_STAGEDETAIL, "stageId", tostring(stageId)) + return nil + end + return BabelStageConfigs[stageId] +end + +function XFubenBabelTowerConfigs.GetStageName(stageId) + local config = XFubenBabelTowerConfigs.GetBabelStageConfigs(stageId) + return config.Name +end + + +-- 排行榜分段 +function XFubenBabelTowerConfigs.GetBabelTowerRankLevelTemplate(id) + if not BabelRankLevelTemplate[id] then + XLog.ErrorTableDataNotFound("XFubenBabelTowerConfigs.GetBabelTowerRankLevelTemplate", "RankLevel", SHARE_BABEL_RANKLEVEL, "Id", tostring(id)) + return nil + end + return BabelRankLevelTemplate[id] +end + +-- 支援条件 +function XFubenBabelTowerConfigs.GetBabelTowerSupportConditonTemplate(supportId) + if not BabelSupportConditionTemplate[supportId] then + XLog.ErrorTableDataNotFound("XFubenBabelTowerConfigs.GetBabelTowerSupportConditonTemplate", + "SupportCondition", SHARE_BABEL_SUPPORTCONDITION, "supportId", tostring(supportId)) + return nil + end + return BabelSupportConditionTemplate[supportId] +end + +-- buff组 +function XFubenBabelTowerConfigs.GetBabelTowerBuffGroupTemplate(groupId) + if not BabelBuffGroupTemplate[groupId] then + XLog.ErrorTableDataNotFound("XFubenBabelTowerConfigs.GetBabelTowerBuffGroupTemplate", + "BabelTowerBuffGroup", SHARE_BABEL_BUFFGROUP, "groupId", tostring(groupId)) + return nil + end + return BabelBuffGroupTemplate[groupId] +end + +-- buff +function XFubenBabelTowerConfigs.GetBabelTowerBuffTemplate(buffId) + if not BabelBuffTemplate[buffId] then + XLog.ErrorTableDataNotFound("XFubenBabelTowerConfigs.GetBabelTowerBuffTemplate", "BabelBuff", SHARE_BABEL_BUFF, "buffId", tostring(buffId)) + return nil + end + return BabelBuffTemplate[buffId] +end + +function XFubenBabelTowerConfigs.GetBabelTowerDifficulty(stageId, challengePoints) + local difficultyConfigs = BabelActivityDifficultyConfigs[stageId] + if not difficultyConfigs then + return XFubenBabelTowerConfigs.DIFFICULTY_NONE, "", "" + end + + if challengePoints >= difficultyConfigs.Critical then + return XFubenBabelTowerConfigs.DIFFICULTY_CRITICAL, difficultyConfigs.CriticalTitle, difficultyConfigs.CriticalStatus + end + + if challengePoints >= difficultyConfigs.Urgency then + return XFubenBabelTowerConfigs.DIFFICULTY_URGENCY, difficultyConfigs.UrgencyTitle, difficultyConfigs.UrgencyStatus + end + + return XFubenBabelTowerConfigs.DIFFICULTY_NORMAL, difficultyConfigs.NormalTitle, difficultyConfigs.NormalStatus +end + +function XFubenBabelTowerConfigs.GetBabelTowerRankReward(rankLevel) + local rankRewards = {} + for _, rankReward in pairs(BabelRankRewardTemplate) do + if rankReward.LevelId == rankLevel then + table.insert(rankRewards, { + Id = rankReward.Id, + RankLevel = rankReward.LevelId, + MinRank = rankReward.MinRank, + MaxRank = rankReward.MaxRank, + MailId = rankReward.MailId, + RankIcon = rankReward.RankIcon + }) + end + end + table.sort(rankRewards, function(rank1, rank2) + return rank1.MinRank < rank2.MinRank + end) + return rankRewards +end + + +function XFubenBabelTowerConfigs.GetStageDifficultConfigs(stageId) + local config = BabelStageLevelDic[stageId] + if not config then + XLog.Error("XFubenBabelTowerConfigs.GetStageDifficultConfigs Error: stageId is: " .. stageId .. " ,path is: " .. SHARE_BABEL_STAGELEVEL) + return + end + return config +end + +function XFubenBabelTowerConfigs.GetStageDifficultConfig(stageId, difficult) + local configs = XFubenBabelTowerConfigs.GetStageDifficultConfigs(stageId) + local config = configs[difficult] + if not config then + XLog.Error("XFubenBabelTowerConfigs.GetStageDifficultConfig Error: difficult is: " .. difficult .. " ,path is: " .. SHARE_BABEL_STAGELEVEL, BabelStageLevelDic) + return + end + return config +end + +function XFubenBabelTowerConfigs.GetStageDifficultLockBuffIdOpenLevel(stageId, buffId) + local config = BabelStageLevelLockBuffIdDic[stageId] + if not config then return 0 end + return config[buffId] or 0 +end + +function XFubenBabelTowerConfigs.GetStageDifficultRecommendAblity(stageId, difficult) + local config = XFubenBabelTowerConfigs.GetStageDifficultConfig(stageId, difficult) + return config.RecommendAblity +end + +function XFubenBabelTowerConfigs.GetStageDifficultName(stageId, difficult) + local config = XFubenBabelTowerConfigs.GetStageDifficultConfig(stageId, difficult) + return config.Name +end + +function XFubenBabelTowerConfigs.GetStageDifficultRatio(stageId, difficult) + local config = XFubenBabelTowerConfigs.GetStageDifficultConfig(stageId, difficult) + return config.ScoreRatio +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XFubenBossOnlineConfig.lua b/Resources/Scripts/XConfig/XFubenBossOnlineConfig.lua new file mode 100644 index 00000000..8c9421c1 --- /dev/null +++ b/Resources/Scripts/XConfig/XFubenBossOnlineConfig.lua @@ -0,0 +1,31 @@ +XFubenBossOnlineConfig = XFubenBossOnlineConfig or {} + +local OnlineBossSectionTemplates = {} +local OnlineBossChapterTemplates = {} +local OnlineBossRiskTemplates = {} + +local TABLE_FUBEN_ONLINEBOSS_SECTION = "Share/Fuben/BossOnline/BossOnlineSection.tab" +local TABLE_FUBEN_ONLINEBOSS_CHAPTER = "Share/Fuben/BossOnline/BossOnlineChapter.tab" +local TABLE_FUBEN_ONLINEBOSS_RISK = "Share/Fuben/BossOnline/BossOnlineRisk.tab" + +function XFubenBossOnlineConfig.Init() + OnlineBossChapterTemplates = XTableManager.ReadByIntKey(TABLE_FUBEN_ONLINEBOSS_CHAPTER, XTable.XTableBossOnlineChapter, "Id") + OnlineBossSectionTemplates = XTableManager.ReadByIntKey(TABLE_FUBEN_ONLINEBOSS_SECTION, XTable.XTableBossOnlineSection, "Id") + OnlineBossRiskTemplates = XTableManager.ReadByIntKey(TABLE_FUBEN_ONLINEBOSS_RISK, XTable.XTableBossOnlineRisk, "Id") +end + +function XFubenBossOnlineConfig.GetChapterTemplates() + return OnlineBossChapterTemplates +end + +function XFubenBossOnlineConfig.GetSectionTemplates() + return OnlineBossSectionTemplates +end + +function XFubenBossOnlineConfig.GetRiskTemplate(count) + for _, v in pairs(OnlineBossRiskTemplates) do + if (v.MinCount <= 0 or count >= v.MinCount) and (v.MaxCount <= 0 or count <= v.MaxCount) then + return v + end + end +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XFubenBossSingleConfigs.lua b/Resources/Scripts/XConfig/XFubenBossSingleConfigs.lua new file mode 100644 index 00000000..4a5e086a --- /dev/null +++ b/Resources/Scripts/XConfig/XFubenBossSingleConfigs.lua @@ -0,0 +1,181 @@ +local table = table +local tableInsert = table.insert +local tableSort = table.sort + +XFubenBossSingleConfigs = XFubenBossSingleConfigs or {} + +XFubenBossSingleConfigs.Platform = { + Win = 0, + Android = 1, + IOS = 2, + All = 3 +} + +XFubenBossSingleConfigs.LevelType = { + Chooseable = 0, --未选择(高级区达成晋级终极区条件) + Normal = 1, --低级区 + Medium = 2, --中极区 + High = 3, --高级区 + Extreme = 4, --终极区 +} + +XFubenBossSingleConfigs.DifficultyType = { + experiment = 1, + elites = 2, + kinght = 3, + chaos = 4, + hell = 5, + Hide = 6, +} + +local TABLE_BOSS_SINGLE_GRADE = "Share/Fuben/BossSingle/BossSingleGrade.tab" +local TABLE_RABK_REWARD = "Share/Fuben/BossSingle/BossSingleRankReward.tab" +local TABLE_SCORE_REWARD = "Share/Fuben/BossSingle/BossSingleScoreReward.tab" +local TABLE_SECTION = "Share/Fuben/BossSingle/BossSingleSection.tab" +local TABLE_STAGE = "Share/Fuben/BossSingle/BossSingleStage.tab" +local TABLE_SOCRE_ROLE = "Share/Fuben/BossSingle/BossSingleScoreRule.tab" +local TABLE_GROUP = "Share/Fuben/BossSingle/BossSingleGroup.tab" + +-- templates +local BossSingleGradeCfg = {} +local RankRewardCfg = {} -- key = levelType, value = {cfg} +local ScoreRewardCfg = {} -- key = levelType, value = {cfg} +local BossSectionCfg = {} +local BossStageCfg = {} +local BossSectionInfo = {} +local RankRole = {} +local BossGourpCfg = {} + +XFubenBossSingleConfigs.AUTO_FIGHT_COUNT = CS.XGame.Config:GetInt("BossSingleAutoFightCount") +XFubenBossSingleConfigs.AUTO_FIGHT_REBATE = CS.XGame.Config:GetInt("BossSingleAutoFightRebate") + +function XFubenBossSingleConfigs.Init() + BossSingleGradeCfg = XTableManager.ReadByIntKey(TABLE_BOSS_SINGLE_GRADE, XTable.XTableBossSingleGrade, "LevelType") + local rankRewardCfg = XTableManager.ReadByIntKey(TABLE_RABK_REWARD, XTable.XTableBossSingleRankReward, "Id") + local scoreRewardCfg = XTableManager.ReadByIntKey(TABLE_SCORE_REWARD, XTable.XTableBossSingleScoreReward, "Id") + BossSectionCfg = XTableManager.ReadByIntKey(TABLE_SECTION, XTable.XTableBossSingleSection, "Id") + BossStageCfg = XTableManager.ReadByIntKey(TABLE_STAGE, XTable.XTableBossSingleStage, "StageId") + BossGourpCfg = XTableManager.ReadByIntKey(TABLE_GROUP, XTable.XTableBossSingleGroup, "Id") + RankRole = XTableManager.ReadByIntKey(TABLE_SOCRE_ROLE, XTable.XTableBossSingleScoreRule, "Id") + + -- 讨伐值奖励排序 + for _, cfg in pairs(scoreRewardCfg) do + if ScoreRewardCfg[cfg.LevelType] then + tableInsert(ScoreRewardCfg[cfg.LevelType], cfg) + else + ScoreRewardCfg[cfg.LevelType] = {} + tableInsert(ScoreRewardCfg[cfg.LevelType], cfg) + end + end + + for _, scoreList in pairs(ScoreRewardCfg) do + tableSort(scoreList, function(a, b) + if a.Score ~= b.Score then + return a.Score < b.Score + end + + return a.Id < b.Id + end) + end + + -- 排行奖励排序 + for _, cfg in pairs(rankRewardCfg) do + if RankRewardCfg[cfg.LevelType] then + tableInsert(RankRewardCfg[cfg.LevelType], cfg) + else + RankRewardCfg[cfg.LevelType] = {} + tableInsert(RankRewardCfg[cfg.LevelType], cfg) + end + end + + for _, rankList in pairs(RankRewardCfg) do + tableSort(rankList, function(a, b) + return a.Id < b.Id + end) + end + + -- BossSectionInfo = {key = bossId, value = {stageCfg}} + for id, cfg in pairs(BossSectionCfg) do + BossSectionInfo[id] = {} + for i = 1, #cfg.StageId do + local stageCfg = BossStageCfg[cfg.StageId[i]] + tableInsert(BossSectionInfo[id], stageCfg) + end + end + + for _, cfgs in pairs(BossSectionInfo) do + tableSort(cfgs, function(a, b) + if a.DifficultyType ~= b.DifficultyType then + return a.DifficultyType < b.DifficultyType + end + + return a.Id < b.Id + end) + end +end + +function XFubenBossSingleConfigs.GetBossSingleGradeCfg() + return BossSingleGradeCfg +end + +function XFubenBossSingleConfigs.GetBossSectionCfg() + return BossSectionCfg +end + +function XFubenBossSingleConfigs.GetBossSectionInfo() + return BossSectionInfo +end + +function XFubenBossSingleConfigs.GetBossStageCfg() + return BossStageCfg +end + +function XFubenBossSingleConfigs.GetRankRole() + return RankRole +end + +function XFubenBossSingleConfigs.GetScoreRewardCfg() + return ScoreRewardCfg +end + +function XFubenBossSingleConfigs.GetRankRewardCfg() + return RankRewardCfg +end + +function XFubenBossSingleConfigs.GetBossSingleGroupById(id) + return BossGourpCfg[id] +end + +function XFubenBossSingleConfigs.IsInBossSectionTime(bossId) + local sectionCfg = BossSectionCfg[bossId] + + local openTime = XFunctionManager.GetStartTimeByTimeId(sectionCfg.SwitchTimeId) + if not openTime or openTime <= 0 then + return true + end + + local closeTime = XFunctionManager.GetEndTimeByTimeId(sectionCfg.SwitchTimeId) + if not closeTime or closeTime <= 0 then + return true + end + + local nowTime = XTime.GetServerNowTimestamp() + return openTime <= nowTime and nowTime < closeTime +end + +function XFubenBossSingleConfigs.GetBossSectionLeftTime(bossId) + local sectionCfg = BossSectionCfg[bossId] + local closeTime = XFunctionManager.GetEndTimeByTimeId(sectionCfg.SwitchTimeId) + if not closeTime or closeTime <= 0 then + return 0 + end + + local nowTime = XTime.GetServerNowTimestamp() + local leftTime = closeTime - nowTime + return leftTime +end + +function XFubenBossSingleConfigs.GetBossSectionTeamBuffId(bossId) + local sectionCfg = BossSectionCfg[bossId] + return sectionCfg and sectionCfg.TeamBuffId +end diff --git a/Resources/Scripts/XConfig/XFubenConfigs.lua b/Resources/Scripts/XConfig/XFubenConfigs.lua new file mode 100644 index 00000000..e9a3f46e --- /dev/null +++ b/Resources/Scripts/XConfig/XFubenConfigs.lua @@ -0,0 +1,622 @@ +local CSXGameClientConfig = CS.XGame.ClientConfig +local CSXTextManagerGetText = CS.XTextManager.GetText + +XFubenConfigs = XFubenConfigs or {} + +local TABLE_STAGE = "Share/Fuben/Stage.tab" +local TABLE_MULTICHALLENGE_STAGE = "Share/Fuben/MultiChallengeStage.tab" +local TABLE_STAGE_TRANSFORM = "Share/Fuben/StageTransform.tab" +local TABLE_STAGE_LEVEL_CONTROL = "Share/Fuben/StageLevelControl.tab" +local TABLE_STAGE_MULTIPLAYER_LEVEL_CONTROL = "Share/Fuben/StageMultiplayerLevelControl.tab" +local TABLE_FLOP_REWARD = "Share/Fuben/FlopReward.tab" +local TABLE_STAGE_FIGHT_CONTROL = "Share/Fuben/StageFightControl.tab" --副本战力限制表 +local TABLE_CHALLENGE_BANNER = "Share/Fuben/FubenChallengeBanner.tab" +local TABLE_ACTIVITY_SORTRULE = "Client/Fuben/ActivitySortRule/ActivitySortRule.tab" +local TABLE_FUBENFEATURES = "Client/Fuben/FubenFeatures.tab" -- 特性展示表 +local TABLE_STAGE_CHARACTERLIMIT = "Share/Fuben/StageCharacterLimit.tab" -- 角色类型限制buff +local TABLE_BOSS_TEAMBUFF = "Share/Fuben/StageTeamBuff.tab" +local TABLE_STAGE_FIGHT_EVENT_DETAILS = "Client/Fuben/StageFightEventDetails.tab" +local TABLE_STAGE_FIGHT_EVENT = "Share/Fuben/StageFightEvent.tab" +local TABLE_SETTLE_LOST_TIP = "Client/Fuben/SettleLoseTip.tab" -- 失败结算界面提示 +local TABLE_STAGE_RECOMMEND_PATH = "Client/Fuben/StageRecommend.tab" -- 关卡推荐表 + +local StageCfg = {} +local StageTransformCfg = {} +local StageLevelControlCfg = {} +local StageMultiplayerLevelControlCfg = {} +local FlopRewardTemplates = {} +local StageFightControlCfg = {} +local FubenChallengeBanners = {} +local ActivitySortRules = {} +local FubenFeatures = {} +local MultiChallengeConfigs = {} +local FubenNewChallenge +local StageCharacterLimitBuffConfig = {} +local TeamBuffCfg = {} +local TeamBuffMaxCountDic = {} +local StageFightEvent = {} +local StageFightEventDetails = {} +local SettleLoseTipCfg = {} +local StageRecommendConfigs = {} + +XFubenConfigs.STAGETYPE_COMMON = 0 +XFubenConfigs.STAGETYPE_FIGHT = 1 +XFubenConfigs.STAGETYPE_STORY = 2 +XFubenConfigs.STAGETYPE_STORYEGG = 3 +XFubenConfigs.STAGETYPE_FIGHTEGG = 4 + +XFubenConfigs.FUBENTYPE_NORMAL = 0 +XFubenConfigs.FUBENTYPE_PREQUEL = 1 + +XFubenConfigs.ROOM_MAX_WORLD = CSXGameClientConfig:GetInt("MultiplayerRoomRowMaxWorld") +XFubenConfigs.ROOM_WORLD_TIME = CSXGameClientConfig:GetInt("MultiplayerRoomWorldTime") + +XFubenConfigs.CharacterLimitType = { + All = 0, --构造体/感染体 + Normal = 1, --构造体 + Isomer = 2, --感染体 + IsomerDebuff = 3, --构造体/感染体(Debuff) [AKA:低浓度区] + NormalDebuff = 4, --构造体(Debuff)/感染体 [AKA:重灾区] +} + +function XFubenConfigs.Init() + StageCfg = XTableManager.ReadByIntKey(TABLE_STAGE, XTable.XTableStage, "StageId") + MultiChallengeConfigs = XTableManager.ReadByIntKey(TABLE_MULTICHALLENGE_STAGE, XTable.XTableMultiChallengeStage, "Id") + StageLevelControlCfg = XTableManager.ReadByIntKey(TABLE_STAGE_LEVEL_CONTROL, XTable.XTableStageLevelControl, "Id") + StageMultiplayerLevelControlCfg = XTableManager.ReadByIntKey(TABLE_STAGE_MULTIPLAYER_LEVEL_CONTROL, XTable.XTableStageMultiplayerLevelControl, "Id") + StageTransformCfg = XTableManager.ReadByIntKey(TABLE_STAGE_TRANSFORM, XTable.XTableStageTransform, "Id") + --TowerSectionCfg = XTableManager.ReadByIntKey(TABLE_TOWER_SECTION, XTable.XTableTowerSection, "Id") + FlopRewardTemplates = XTableManager.ReadByIntKey(TABLE_FLOP_REWARD, XTable.XTableFlopReward, "Id") + StageFightControlCfg = XTableManager.ReadByIntKey(TABLE_STAGE_FIGHT_CONTROL, XTable.XTableStageFightControl, "Id") + ActivitySortRules = XTableManager.ReadByIntKey(TABLE_ACTIVITY_SORTRULE, XTable.XTableActivitySortRule, "Id") + FubenFeatures = XTableManager.ReadByIntKey(TABLE_FUBENFEATURES, XTable.XTableFubenFeatures, "Id") + StageCharacterLimitBuffConfig = XTableManager.ReadByIntKey(TABLE_STAGE_CHARACTERLIMIT, XTable.XTableFubenStageCharacterLimit, "Id") + StageFightEvent = XTableManager.ReadByIntKey(TABLE_STAGE_FIGHT_EVENT, XTable.XTableStageFightEvent, "StageId") + StageFightEventDetails = XTableManager.ReadByIntKey(TABLE_STAGE_FIGHT_EVENT_DETAILS, XTable.XTableStageFightEventDetails, "Id") + SettleLoseTipCfg = XTableManager.ReadByIntKey(TABLE_SETTLE_LOST_TIP, XTable.XTableSettleLoseTip, "Id") + StageRecommendConfigs = XTableManager.ReadByIntKey(TABLE_STAGE_RECOMMEND_PATH, XTable.XTableStageRecommend, "StageId") + + TeamBuffCfg = XTableManager.ReadByIntKey(TABLE_BOSS_TEAMBUFF, XTable.XTableStageTeamBuff, "Id") + for id, v in pairs(TeamBuffCfg) do + local maxCount = 0 + for _, buffId in ipairs(v.BuffId) do + if buffId > 0 then + maxCount = maxCount + 1 + end + end + TeamBuffMaxCountDic[id] = maxCount + end + + local banners = XTableManager.ReadByIntKey(TABLE_CHALLENGE_BANNER, XTable.XTableFubenChallengeBanner, "Id") + for _, v in pairs(banners) do + FubenChallengeBanners[v.Type] = v + end +end + +local function GetStageCfg(stageId) + local config = StageCfg[stageId] + if not config then + XLog.Error("XFubenConfigs.GetStageCfgs Error: StageId: " .. stageId) + return + end + return config +end + +local function GetTeamBuffCfg(teamBuffId) + local config = TeamBuffCfg[teamBuffId] + if not config then + XLog.Error("XFubenConfigs.GetTeamBuffCfg Error: teamBuffId: " .. teamBuffId) + return + end + return config +end + +local function GetSettleLoseTipCfg(settleLoseTipId) + local config = SettleLoseTipCfg[settleLoseTipId] + if not config then + XLog.ErrorTableDataNotFound( + "XFubenConfigs.GetSettleLoseTipCfg", + "失败提示", + TABLE_SETTLE_LOST_TIP, + "Id", + tostring(settleLoseTipId)) + return {} + end + return config +end + +function XFubenConfigs.GetStageCfgs() + return StageCfg +end + +function XFubenConfigs.GetBuffDes(buffId) + local fightEventCfg = buffId and buffId ~= 0 and CS.XNpcManager.GetFightEventTemplate(buffId) + return fightEventCfg and fightEventCfg.Description or "" +end + +function XFubenConfigs.GetStageLevelControlCfg() + return StageLevelControlCfg +end + +function XFubenConfigs.GetStageMultiplayerLevelControlCfg() + return StageMultiplayerLevelControlCfg +end + +function XFubenConfigs.GetStageMultiplayerLevelControlCfgById(id) + return StageMultiplayerLevelControlCfg[id] +end + +function XFubenConfigs.GetStageTransformCfg() + return StageTransformCfg +end + +function XFubenConfigs.GetFlopRewardTemplates() + return FlopRewardTemplates +end + +function XFubenConfigs.GetActivitySortRules() + return ActivitySortRules +end + +function XFubenConfigs.GetFeaturesById(id) + local t = FubenFeatures[id] + if not t then + XLog.ErrorTableDataNotFound("XFubenConfigs.GetFeaturesById", "FubenFeatures", TABLE_FUBENFEATURES, "Id", tostring(id)) + return nil + end + return t +end + +function XFubenConfigs.GetActivityPriorityByActivityIdAndType(activityId, type) + for _, v in pairs(ActivitySortRules) do + if v.ActivityId == activityId and v.Type == type then + return v.Priority + end + end + return 0 +end + +function XFubenConfigs.GetStageFightControl(id) + for _, v in pairs(StageFightControlCfg) do + if v.Id == id then + return v + end + end + return nil +end + +function XFubenConfigs.IsKeepPlayingStory(stageId) + local targetCfg = StageCfg[stageId] + if not targetCfg or not targetCfg.KeepPlayingStory then + return false + end + return targetCfg.KeepPlayingStory == 1 +end + +function XFubenConfigs.GetChapterBannerByType(bannerType) + return FubenChallengeBanners[bannerType] or {} +end + +function XFubenConfigs.InitNewChallengeConfigs() + FubenNewChallenge = {} + for _, v in pairs(FubenChallengeBanners) do + if v.ShowNewStartTime and v.ShowNewEndTime then + local timeNow = XTime.GetServerNowTimestamp() + local startTime = XTime.ParseToTimestamp(v.ShowNewStartTime) + local endTime = XTime.ParseToTimestamp(v.ShowNewEndTime) + if endTime and timeNow <= endTime then + table.insert(FubenNewChallenge, v) + end + if startTime > endTime then + XLog.Error("新挑战活动配置有误,起始时间晚于结束时间,表路径:" .. TABLE_CHALLENGE_BANNER .. " 问题Id :" .. tostring(v.Id)) + end + end + end + return FubenNewChallenge +end + +function XFubenConfigs.GetNewChallengeConfigs() -- 获取新挑战玩法数据 + return FubenNewChallenge or XFubenConfigs.InitNewChallengeConfigs() +end + +function XFubenConfigs.GetNewChallengeConfigById(id) -- 根据Id取得FubenChallengeBanner配置 + for i in pairs(FubenChallengeBanners) do + if FubenChallengeBanners[i].Id == id then + return FubenChallengeBanners[i] + end + end + return nil +end + +function XFubenConfigs.GetNewChallengeConfigsLength() -- 获取新活动数量 + local config = XFubenConfigs.GetNewChallengeConfigs() + return #config +end + +function XFubenConfigs.GetNewChallengeFunctionId(index) + local config = XFubenConfigs.GetNewChallengeConfigs() + return config[index].FunctionId +end + +function XFubenConfigs.GetNewChallengeId(index) -- 根据索引获取新挑战活动的Id + local config = XFubenConfigs.GetNewChallengeConfigs() + return config[index].Id +end + +function XFubenConfigs.GetNewChallengeStartTimeStamp(index) + local config = XFubenConfigs.GetNewChallengeConfigs() + return XTime.ParseToTimestamp(config[index].ShowNewStartTime) +end + +function XFubenConfigs.GetNewChallengeEndTimeStamp(index) + local config = XFubenConfigs.GetNewChallengeConfigs() + return XTime.ParseToTimestamp(config[index].ShowNewEndTime) +end + +function XFubenConfigs.IsNewChallengeStartByIndex(index) -- 根据索引获取新挑战时段是否已经开始 + return XFubenConfigs.GetNewChallengeStartTimeStamp(index) <= XTime.GetServerNowTimestamp() +end + +function XFubenConfigs.IsNewChallengeStartById(id) -- 根据挑战活动Id获取新挑战时段是否已经开始 + if not id then return false end + local cfg = XFubenConfigs.GetNewChallengeConfigById(id) + if not cfg or not cfg.ShowNewStartTime then return false end + return XTime.ParseToTimestamp(cfg.ShowNewStartTime) <= XTime.GetServerNowTimestamp() +end + +function XFubenConfigs.GetMultiChallengeStageConfigs() + return MultiChallengeConfigs +end + +function XFubenConfigs.GetTableStagePath() + return TABLE_STAGE +end + +--副本上阵角色类型限制相关: +local ROOM_CHARACTER_LIMIT_CONFIGS = { + [XFubenConfigs.CharacterLimitType.Normal] = { + Name = CSXTextManagerGetText("CharacterTypeLimitNameNormal"), + ImageTeamEdit = CSXGameClientConfig:GetString("TeamCharacterTypeNormalLimitImage"), + ImageSelectCharacter = CSXGameClientConfig:GetString("TeamRequireCharacterNormalImage"), + TextTeamEdit = CSXTextManagerGetText("TeamCharacterTypeNormalLimitText"), + TextSelectCharacter = CSXTextManagerGetText("TeamRequireCharacterNormalText"), + TextChapterLimit = CSXTextManagerGetText("ChapterCharacterTypeLimitNormal"), + }, + [XFubenConfigs.CharacterLimitType.Isomer] = { + Name = CSXTextManagerGetText("CharacterTypeLimitNameIsomer"), + ImageTeamEdit = CSXGameClientConfig:GetString("TeamCharacterTypeIsomerLimitImage"), + ImageSelectCharacter = CSXGameClientConfig:GetString("TeamRequireCharacterIsomerImage"), + TextTeamEdit = CSXTextManagerGetText("TeamCharacterTypeIsomerLimitText"), + TextSelectCharacter = CSXTextManagerGetText("TeamRequireCharacterIsomerText"), + TextChapterLimit = CSXTextManagerGetText("ChapterCharacterTypeLimitIsomer"), + }, + [XFubenConfigs.CharacterLimitType.IsomerDebuff] = { + Name = CSXTextManagerGetText("CharacterTypeLimitNameIsomerDebuff"), + ImageTeamEdit = CSXGameClientConfig:GetString("TeamCharacterTypeIsomerDebuffLimitImage"), + ImageSelectCharacter = CSXGameClientConfig:GetString("TeamRequireCharacterIsomerDebuffImage"), + TextTeamEdit = function(buffDes) return CSXTextManagerGetText("TeamCharacterTypeIsomerDebuffLimitText", buffDes) end, + TextTeamEditDefault = CSXTextManagerGetText("TeamCharacterTypeIsomerDebuffLimitDefaultText"), + TextSelectCharacter = function(buffDes) return CSXTextManagerGetText("TeamRequireCharacterIsomerDebuffText", buffDes) end, + TextSelectCharacterDefault = CSXTextManagerGetText("TeamRequireCharacterIsomerDebuffDefaultText"), + TextChapterLimit = function(buffDes) return CSXTextManagerGetText("ChapterCharacterTypeLimitIsomerDebuff", buffDes) end, + }, + [XFubenConfigs.CharacterLimitType.NormalDebuff] = { + Name = CSXTextManagerGetText("CharacterTypeLimitNameNormalDebuff"), + ImageTeamEdit = CSXGameClientConfig:GetString("TeamCharacterTypeNormalDebuffLimitImage"), + ImageSelectCharacter = CSXGameClientConfig:GetString("TeamRequireCharacterNormalDebuffImage"), + TextTeamEdit = function(buffDes) return CSXTextManagerGetText("TeamCharacterTypeNormalDebuffLimitText", buffDes) end, + TextTeamEditDefault = CSXTextManagerGetText("TeamCharacterTypeNormalDebuffLimitDefaultText"), + TextSelectCharacter = function(buffDes) return CSXTextManagerGetText("TeamRequireCharacterNormalDebuffText", buffDes) end, + TextSelectCharacterDefault = CSXTextManagerGetText("TeamRequireCharacterNormalDebuffDefaultText"), + TextChapterLimit = function(buffDes) return CSXTextManagerGetText("ChapterCharacterTypeLimitNormalDebuff", buffDes) end, + }, +} + +local function GetStageCharacterLimitConfig(characterLimitType) + return ROOM_CHARACTER_LIMIT_CONFIGS[characterLimitType] +end + +function XFubenConfigs.GetStageCharacterLimitType(stageId) + return GetStageCfg(stageId).CharacterLimitType +end + +function XFubenConfigs.GetStageCharacterLimitBuffId(stageId) + local limitBuffId = GetStageCfg(stageId).LimitBuffId + return XFubenConfigs.GetLimitShowBuffId(limitBuffId) +end + +function XFubenConfigs.GetLimitShowBuffId(limitBuffId) + local config = StageCharacterLimitBuffConfig[limitBuffId] + local buffIds = config and config.BuffId + return buffIds and buffIds[1] or 0 +end + +function XFubenConfigs.IsStageCharacterLimitConfigExist(characterLimitType) + return GetStageCharacterLimitConfig(characterLimitType) and true +end + +-- 编队界面限制角色类型Icon +function XFubenConfigs.GetStageCharacterLimitImageTeamEdit(characterLimitType) + local config = GetStageCharacterLimitConfig(characterLimitType) + if not config then return "" end + return config.ImageTeamEdit +end + +-- 编队界面限制角色类型文本 +function XFubenConfigs.GetStageCharacterLimitTextTeamEdit(characterLimitType, characterType, buffId) + local config = GetStageCharacterLimitConfig(characterLimitType) + if not config then return "" end + + local text = config.TextTeamEdit + local defaultText = config.TextTeamEditDefault + if not defaultText then + return text + end + + local defaultCharacterType = XDataCenter.FubenManager.GetDefaultCharacterTypeByCharacterLimitType(characterLimitType) + if characterType and characterType ~= defaultCharacterType then + if type(text) == "function" then + local buffDes = XFubenConfigs.GetBuffDes(buffId) + return text(buffDes) + end + else + return defaultText + end + + return text +end + +-- 选人界面限制角色类型Icon +function XFubenConfigs.GetStageCharacterLimitImageSelectCharacter(characterLimitType) + local config = GetStageCharacterLimitConfig(characterLimitType) + if not config then return "" end + return config.ImageSelectCharacter +end + +-- 选人界面限制角色类型文本 +function XFubenConfigs.GetStageCharacterLimitTextSelectCharacter(characterLimitType, characterType, buffId) + local config = GetStageCharacterLimitConfig(characterLimitType) + if not config then return "" end + + local text = config.TextSelectCharacter + local defaultText = config.TextSelectCharacterDefault + if not defaultText then + return text + end + + local defaultCharacterType = XDataCenter.FubenManager.GetDefaultCharacterTypeByCharacterLimitType(characterLimitType) + if characterType ~= defaultCharacterType then + if type(text) == "function" then + if not XTool.IsNumberValid(buffId) then + return defaultText + end + + local buffDes = XFubenConfigs.GetBuffDes(buffId) + return text(buffDes) + end + else + return defaultText + end + + return text +end + +-- 限制角色类型分区名称文本 +function XFubenConfigs.GetStageCharacterLimitName(characterLimitType) + local config = GetStageCharacterLimitConfig(characterLimitType) + if not config then return "" end + return config.Name +end + +-- 章节选人界面限制角色类型文本 +function XFubenConfigs.GetChapterCharacterLimitText(characterLimitType, buffId) + local config = GetStageCharacterLimitConfig(characterLimitType) + if not config then return "" end + + local text = config.TextChapterLimit + if type(text) == "function" then + local buffDes = XFubenConfigs.GetBuffDes(buffId) + return text(buffDes) + end + return text +end + +function XFubenConfigs.IsCharacterFitTeamBuff(teamBuffId, characterId) + if not teamBuffId or teamBuffId <= 0 then return false end + if not characterId or characterId <= 0 then return false end + + local config = GetTeamBuffCfg(teamBuffId) + + local initQuality = characterId and characterId > 0 and XCharacterConfigs.GetCharMinQuality(characterId) + if not initQuality or initQuality <= 0 then return false end + + for _, quality in pairs(config.Quality) do + if initQuality == quality then + return true + end + end + + return false +end + +function XFubenConfigs.GetTeamBuffFitCharacterCount(teamBuffId, characterIds) + local config = GetTeamBuffCfg(teamBuffId) + + local fitCount = 0 + + local checkDic = {} + for _, quality in pairs(config.Quality) do + checkDic[quality] = true + end + + for _, characterId in pairs(characterIds) do + local initQuality = characterId > 0 and XCharacterConfigs.GetCharMinQuality(characterId) + fitCount = checkDic[initQuality] and fitCount + 1 or fitCount + end + + return fitCount +end + +function XFubenConfigs.GetTeamBuffMaxBuffCount(teamBuffId) + return TeamBuffMaxCountDic[teamBuffId] or 0 +end + +function XFubenConfigs.GetTeamBuffOnIcon(teamBuffId) + local config = GetTeamBuffCfg(teamBuffId) + return config.OnIcon +end + +function XFubenConfigs.GetTeamBuffOffIcon(teamBuffId) + local config = GetTeamBuffCfg(teamBuffId) + return config.OffIcon +end + +function XFubenConfigs.GetTeamBuffTitle(teamBuffId) + local config = GetTeamBuffCfg(teamBuffId) + return config.Title +end + +function XFubenConfigs.GetTeamBuffDesc(teamBuffId) + local config = GetTeamBuffCfg(teamBuffId) + return string.gsub(config.Desc, "\\n", "\n") +end + +-- 根据符合初始品质要求的characterId列表获取对应的同调加成buffId +function XFubenConfigs.GetTeamBuffShowBuffId(teamBuffId, characterIds) + local config = GetTeamBuffCfg(teamBuffId) + local fitCount = XFubenConfigs.GetTeamBuffFitCharacterCount(teamBuffId, characterIds) + return config.BuffId[fitCount] +end + +-- 根据关卡ID查找关卡词缀列表 +function XFubenConfigs.GetStageFightEventByStageId(stageId) + if not StageFightEvent[stageId] then + XLog.ErrorTableDataNotFound( + "XFubenConfigs.GetStageFightEventByStageId", + "通用关卡词缀数据", + TABLE_STAGE_FIGHT_EVENT, + "StageId", + tostring(stageId) + ) + return {} + end + return StageFightEvent[stageId] +end +-- 根据ID查找词缀详细 +function XFubenConfigs.GetStageFightEventDetailsByStageFightEventId(eventId) + if not StageFightEventDetails[eventId] then + XLog.ErrorTableDataNotFound( + "XFubenConfigs.GetStageFightEventDetailsByStageFightEventId", + "通用关卡词缀数据", + TABLE_STAGE_FIGHT_EVENT_DETAILS, + "Id", + tostring(eventId) + ) + return nil + end + return StageFightEventDetails[eventId] +end + +--- +--- 获取 失败提示描述 数组 +function XFubenConfigs.GetTipDescList(settleLoseTipId) + local cfg = GetSettleLoseTipCfg(settleLoseTipId) + return cfg.TipDesc +end + +--- +--- 获取 失败提示跳转Id 数组 +function XFubenConfigs.GetSkipIdList(settleLoseTipId) + local cfg = GetSettleLoseTipCfg(settleLoseTipId) + return cfg.SkipId +end + +--获取关卡推荐角色类型(构造体/感染体) +function XFubenConfigs.GetStageRecommendCharacterType(stageId) + local config = StageRecommendConfigs[stageId] + if not config then return end + + local value = config.CharacterType + return value ~= 0 and value or nil +end + +--获取关卡推荐角色元素属性(物理/火/雷/冰/暗) +function XFubenConfigs.GetStageRecommendCharacterElement(stageId) + local config = StageRecommendConfigs[stageId] + if not config then return end + + local value = config.CharacterElement + return value ~= 0 and value or nil +end + +--是否为关卡推荐角色 +function XFubenConfigs.IsStageRecommendCharacterType(stageId, Id) + local characterId = XRobotManager.GetCharacterId(Id) + local characterType = XCharacterConfigs.GetCharacterType(characterId) + local recommendType = XFubenConfigs.GetStageRecommendCharacterType(stageId) + local element = XCharacterConfigs.GetCharacterElement(characterId) + local recommendElement = XFubenConfigs.GetStageRecommendCharacterElement(stageId) or 0 + --(废弃)特殊逻辑:如果为授格者,一定是推荐(废弃) + --if characterType == XCharacterConfigs.CharacterType.Isomer and recommendType == characterType then + -- return true + --end + + --特殊逻辑:当关卡推荐元素为0时推荐所有该角色类型(构造体/授格者)的构造体 + --(此处兼容之前废弃的《授格者一定推荐的特殊逻辑》,StageRecommend配置中的授格者类型下推荐属性都是0,故兼容) + + return XTool.IsNumberValid(recommendType) and + recommendType == characterType and + (element == recommendElement or recommendElement == 0) +end + +function XFubenConfigs.GetStageName(stageId) + local config = GetStageCfg(stageId) + return config and config.Name or "" +end + +function XFubenConfigs.GetStageType(stageId) + local config = GetStageCfg(stageId) + return config and config.StageType or "" +end + +--- +--- 关卡图标 +function XFubenConfigs.GetStageIcon(stageId) + local config = GetStageCfg(stageId) + return (config or {}).Icon +end + +--- +--- 三星条件描述数组 +function XFubenConfigs.GetStarDesc(stageId) + local config = GetStageCfg(stageId) + return (config or {}).StarDesc +end + +--- +--- 关卡需要消耗的体力 +function XFubenConfigs.GetRequireActionPoint(stageId) + local config = GetStageCfg(stageId) + return (config or {}).RequireActionPoint +end + +--- +--- 关卡首通奖励 +function XFubenConfigs.GetFirstRewardShow(stageId) + local config = GetStageCfg(stageId) + return (config or {}).FirstRewardShow +end + +--- +--- 关卡非首通奖励 +function XFubenConfigs.GetFinishRewardShow(stageId) + local config = GetStageCfg(stageId) + return (config or {}).FinishRewardShow +end + +--- +--- 获得战前剧情ID +function XFubenConfigs.GetBeginStoryId(stageId) + local config = GetStageCfg(stageId) + return (config or {}).BeginStoryId +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XFubenCoupleCombatConfig.lua b/Resources/Scripts/XConfig/XFubenCoupleCombatConfig.lua new file mode 100644 index 00000000..77d66a66 --- /dev/null +++ b/Resources/Scripts/XConfig/XFubenCoupleCombatConfig.lua @@ -0,0 +1,64 @@ +XFubenCoupleCombatConfig = XFubenCoupleCombatConfig or {} + +local TABLE_COUPLE_ACTIVITY = "Share/Fuben/CoupleCombat/CoupleCombatActivity.tab" +local TABLE_COUPLE_BUFF = "Share/Fuben/CoupleCombat/CoupleCombatFeature.tab" +local TABLE_COUPLE_CHAPTER = "Share/Fuben/CoupleCombat/CoupleCombatChapter.tab" +local TABLE_COUPLE_ROBOT = "Share/Fuben/CoupleCombat/CoupleCombatRobot.tab" +local TABLE_COUPLE_STAGE = "Share/Fuben/CoupleCombat/CoupleCombatStage.tab" + +local CoupleCombatActivity = {} +local CoupleCombatFeature = {} +local CoupleCombatChapter = {} +local CoupleCombatRobot = {} +local CoupleCombatStage = {} + +XFubenCoupleCombatConfig.StageType = { + Normal = 1, --普通 + Hard = 2, --挑战模式 +} + +function XFubenCoupleCombatConfig.Init() + CoupleCombatActivity = XTableManager.ReadByIntKey(TABLE_COUPLE_ACTIVITY, XTable.XTableCoupleCombatActivity, "Id") + CoupleCombatFeature = XTableManager.ReadByIntKey(TABLE_COUPLE_BUFF, XTable.XTableCoupleCombatFeature, "Id") + CoupleCombatChapter = XTableManager.ReadByIntKey(TABLE_COUPLE_CHAPTER, XTable.XTableCoupleCombatChapter, "Id") + CoupleCombatRobot = XTableManager.ReadByIntKey(TABLE_COUPLE_ROBOT, XTable.XTableCoupleCombatRobot, "RobotId") + CoupleCombatStage = XTableManager.ReadByIntKey(TABLE_COUPLE_STAGE, XTable.XTableCoupleCombatStage, "Id") + +end + +function XFubenCoupleCombatConfig.GetStageInfo(id) + local template = CoupleCombatStage[id] + if not template then + XLog.ErrorTableDataNotFound("XFubenCoupleCombatConfig.GetStageInfo", "CoupleCombatStage", TABLE_COUPLE_STAGE, "id", tostring(id)) + return + end + return template +end + +function XFubenCoupleCombatConfig.GetStages() + return CoupleCombatStage +end + +function XFubenCoupleCombatConfig.GetChapterTemplates() + return CoupleCombatChapter +end + +function XFubenCoupleCombatConfig.GetChapterTemplate(id) + return CoupleCombatChapter[id] +end + +function XFubenCoupleCombatConfig.GetActTemplates() + return CoupleCombatActivity +end + +function XFubenCoupleCombatConfig.GetActivityTemplateById(id) + return CoupleCombatActivity[id] +end + +function XFubenCoupleCombatConfig.GetRobotInfo(id) + return CoupleCombatRobot[id] +end + +function XFubenCoupleCombatConfig.GetFeatureById(id) + return CoupleCombatFeature[id] +end diff --git a/Resources/Scripts/XConfig/XFubenExperimentConfigs.lua b/Resources/Scripts/XConfig/XFubenExperimentConfigs.lua new file mode 100644 index 00000000..daf83d11 --- /dev/null +++ b/Resources/Scripts/XConfig/XFubenExperimentConfigs.lua @@ -0,0 +1,62 @@ +XFubenExperimentConfigs = XFubenExperimentConfigs or {} + +local TABLE_TRIAL_GROUP = "Share/Fuben/Experiment/ExperimentGroup.tab" +local TABLE_TRIAL_LEVEL = "Share/Fuben/Experiment/ExperimentLevel.tab" +local TABLE_TRIAL_BATTLETRIAL = "Share/Fuben/Experiment/BattleExperiment.tab" +local TABLE_TRIAL_LEVELSKILL = "Client/Fuben/Experiment/ExperimentSkillExplainId.tab" +local TABLE_TRIAL_REWARD = "Share/Fuben/Experiment/ExperimentReward.tab" + +local TrialGroupCfg = {} +local TrialLevelCfg = {} +local BattleTrialCfg = {} +local TrialSkillExplainCfg = {} +local TrialRewardCfg = {} + +function XFubenExperimentConfigs.Init() + TrialGroupCfg = XTableManager.ReadByIntKey(TABLE_TRIAL_GROUP, XTable.XTableExperimentGroup, "Id") + TrialLevelCfg = XTableManager.ReadByIntKey(TABLE_TRIAL_LEVEL, XTable.XTableExperimentLevel, "Id") + BattleTrialCfg = XTableManager.ReadByIntKey(TABLE_TRIAL_BATTLETRIAL, XTable.XTableBattleExperiment, "Id") + TrialSkillExplainCfg = XTableManager.ReadByIntKey(TABLE_TRIAL_LEVELSKILL, XTable.XTableExperimentSkillExplainId, "Id") + TrialRewardCfg = XTableManager.ReadByIntKey(TABLE_TRIAL_REWARD, XTable.XTableExperimentReward, "Id") +end + +function XFubenExperimentConfigs.GetTrialGroupCfg() + return TrialGroupCfg +end + +function XFubenExperimentConfigs.GetTrialLevelCfg() + return TrialLevelCfg +end + +function XFubenExperimentConfigs.GetTrialLevelCfgById(id) + for _, v in pairs(TrialLevelCfg) do + if v.Id == id then + return v + end + end +end + +function XFubenExperimentConfigs.GetBattleTrialCfg() + return BattleTrialCfg +end + +function XFubenExperimentConfigs.GetBattleTrialBegin(id) + for i = 1, #BattleTrialCfg do + if BattleTrialCfg[i].CharacterID == id then + return BattleTrialCfg[i] + end + end + return nil +end + +function XFubenExperimentConfigs.GetBattleTrial(id) + return BattleTrialCfg[id] +end + +function XFubenExperimentConfigs.GetExperimentSkillExplainById(id) + return TrialSkillExplainCfg[id] +end + +function XFubenExperimentConfigs.GetTrialStarRewardCfgById(rewardId) + return TrialRewardCfg[rewardId] +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XFubenExploreConfigs.lua b/Resources/Scripts/XConfig/XFubenExploreConfigs.lua new file mode 100644 index 00000000..fb2cc7e2 --- /dev/null +++ b/Resources/Scripts/XConfig/XFubenExploreConfigs.lua @@ -0,0 +1,104 @@ +XFubenExploreConfigs = XFubenExploreConfigs or {} + +local TABLE_EXPLORE_BUFF = "Share/Fuben/Explore/ExploreBuffItem.tab" +local TABLE_EXPLORE_CHAPTER = "Share/Fuben/Explore/ExploreChapter.tab" +local TABLE_EXPLORE_NODE = "Share/Fuben/Explore/ExploreNode.tab" +local TABLE_EXPLORE_STORYTEXT = "Share/Fuben/Explore/ExploreStoryText.tab" + +local ExploreBuffCfg = {} +local ExploreChapterCfg = {} +local ExploreNodeCfg = {} +local ExploreStoryTextCfg = {} + +XFubenExploreConfigs.NodeStateEnum = { + Complete = 1, --已完成 + Availavle = 2, --可打 + Visivle = 3, --可看到不可打 + Invisivle = 4, --不可见 +} + +XFubenExploreConfigs.NodeTypeEnum = { + Stage = 1, --战斗 + Story = 2, --剧情 + Arena = 3, --竞技 +} + +function XFubenExploreConfigs.Init() + ExploreBuffCfg = XTableManager.ReadByIntKey(TABLE_EXPLORE_BUFF, XTable.XTableExploreBuffItem, "Id") + ExploreChapterCfg = XTableManager.ReadByIntKey(TABLE_EXPLORE_CHAPTER, XTable.XTableExploreChapter, "Id") + ExploreNodeCfg = XTableManager.ReadByIntKey(TABLE_EXPLORE_NODE, XTable.XTableExploreNode, "Id") + ExploreStoryTextCfg = XTableManager.ReadByIntKey(TABLE_EXPLORE_STORYTEXT, XTable.XTableExploreStoryText, "Id") +end + +function XFubenExploreConfigs.GetExploreBuffCfg() + return ExploreBuffCfg +end + +function XFubenExploreConfigs.GetExploreChapterCfg() + return ExploreChapterCfg +end + +function XFubenExploreConfigs.GetExploreNodeCfg() + return ExploreNodeCfg +end + +function XFubenExploreConfigs.GetExploreStoryTextCfg() + return ExploreStoryTextCfg +end + +--获取某一章的全部关卡表数据 +function XFubenExploreConfigs.GetAllLevel(chapterId) + local tempList = {} + for _, v in pairs(ExploreNodeCfg) do + if v.ChapterId == chapterId then + table.insert(tempList, v) + end + end + return tempList +end + +--获取某一关的表数据 +function XFubenExploreConfigs.GetLevel(nodeId) + if ExploreNodeCfg[nodeId] then + return ExploreNodeCfg[nodeId] + end + XLog.ErrorTableDataNotFound("XFubenExploreConfigs.GetLevel", "ExploreNodeCfg", TABLE_EXPLORE_NODE, "nodeId", tostring(nodeId)) + return nil +end + +--获取某一章的表数据 +function XFubenExploreConfigs.GetChapterData(chapterId) + return ExploreChapterCfg[chapterId] +end + +--获取某一章的全部StoryText +function XFubenExploreConfigs.GetChapterStoryText(chapterId) + local tempList = {} + for i = 1, #ExploreStoryTextCfg do + if ExploreStoryTextCfg[i].ChapterId == chapterId then + table.insert(tempList, ExploreStoryTextCfg[i]) + end + end + return tempList +end + +--获取某一章所有的buff +function XFubenExploreConfigs.GetChapterBuff(chapterId) + local tempList = {} + for i = 1, #ExploreBuffCfg do + if ExploreBuffCfg[i].ChapterId == chapterId then + table.insert(tempList, ExploreBuffCfg[i]) + end + end + return tempList +end + +--获取某一个buff +function XFubenExploreConfigs.GetBuff(buffId) + for i = 1, #ExploreBuffCfg do + if ExploreBuffCfg[i].Id == buffId then + return ExploreBuffCfg[i] + end + end + return nil +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XFubenExtraChapterConfigs.lua b/Resources/Scripts/XConfig/XFubenExtraChapterConfigs.lua new file mode 100644 index 00000000..27406476 --- /dev/null +++ b/Resources/Scripts/XConfig/XFubenExtraChapterConfigs.lua @@ -0,0 +1,62 @@ +XFubenExtraChapterConfigs = {} + +local TABLE_CHAPTER_EXTRA = "Share/Fuben/ExtraChapter/ChapterExtra.tab" +local TABLE_CHAPTER_EXTRA_DETAILS = "Share/Fuben/ExtraChapter/ChapterExtraDetails.tab" +local TABLE_CHAPTER_EXTRA_STARTREASURE = "Share/Fuben/ExtraChapter/ChapterExtraStarTreasure.tab" +local TABLE_EXPLOREGROUP = "Client/Fuben/ExtraChapter/ExtraExploreGroup.tab" +local TABLE_EXPLOREITEM = "Client/Fuben/ExtraChapter/ExtraExploreItem.tab" + +local ExtraChapterCfgs = {} --TABLE_CHAPTER_EXTRA ChapterExtra.tab 番外章节数据,与Details表关联,难度指向不同的章节详细项 +local ExtraChapterDetailsCfgs = {} --TABLE_CHAPTER_EXTRA_DETAILS ChapterExtraDetails.tab 番外章节详细数据 +local ExtraChapterStarTreasureCfgs = {} --TABLE_CHAPTER_EXTRA_STARTREASURE ChapterExtraStarTreasure.tab +local ExtraExploreGroupCfgs = {} --TABLE_EXPLOREGROUP ExtraExploreGroup.tab 番外探索组 +local ExtraExploreItemCfgs = {} --TABLE_EXPLOREITEM ExtraExploreItem.tab 番外探索道具数据 + +function XFubenExtraChapterConfigs.Init() + ExtraChapterCfgs = XTableManager.ReadByIntKey(TABLE_CHAPTER_EXTRA, XTable.XTableChapterExtra, "Id") + ExtraChapterDetailsCfgs = XTableManager.ReadByIntKey(TABLE_CHAPTER_EXTRA_DETAILS, XTable.XTableChapterExtraDetails, "ChapterId") + ExtraChapterStarTreasureCfgs = XTableManager.ReadByIntKey(TABLE_CHAPTER_EXTRA_STARTREASURE, XTable.XTableChapterExtraStarTreasure, "TreasureId") + ExtraExploreGroupCfgs = XTableManager.ReadByIntKey(TABLE_EXPLOREGROUP, XTable.XTableExtraExploreGroup, "Id") + ExtraExploreItemCfgs = XTableManager.ReadByIntKey(TABLE_EXPLOREITEM, XTable.XTableExtraExploreItem, "Id") +end + +function XFubenExtraChapterConfigs.GetExtraChapterCfgs() + return ExtraChapterCfgs +end + +function XFubenExtraChapterConfigs.GetExtraChapterDetailsCfgs() + return ExtraChapterDetailsCfgs +end + +function XFubenExtraChapterConfigs.GetExtraChapterStarTreasuresCfgs() + return ExtraChapterStarTreasureCfgs +end + +function XFubenExtraChapterConfigs.GetExploreGroupCfg() + return ExtraExploreGroupCfgs +end + +function XFubenExtraChapterConfigs.GetExploreItemCfg() + return ExtraExploreItemCfgs +end + +function XFubenExtraChapterConfigs.GetExploreItemCfgById(id) + if not ExtraExploreItemCfgs[id] then + XLog.ErrorTableDataNotFound("XFubenExtraChapterConfigs.GetExploreItemCfgById", "ExtraExploreItem", TABLE_EXPLOREITEM, "Id", tostring(id)) + return nil + end + return ExtraExploreItemCfgs[id] +end + +--- +--- 根据'chapterMainId'获取章节的周目Id +---@param chapterMainId number +---@return number +function XFubenExtraChapterConfigs.GetZhouMuId(chapterMainId) + if (ExtraChapterCfgs or {})[chapterMainId] == nil then + XLog.ErrorTableDataNotFound("XFubenExtraChapterConfigs.GetZhouMuId", + "外篇章节", TABLE_CHAPTER_EXTRA, "Id", tostring(chapterMainId)) + return + end + return ExtraChapterCfgs[chapterMainId].ZhouMuId +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XFubenHackConfig.lua b/Resources/Scripts/XConfig/XFubenHackConfig.lua new file mode 100644 index 00000000..e41ea7e3 --- /dev/null +++ b/Resources/Scripts/XConfig/XFubenHackConfig.lua @@ -0,0 +1,86 @@ +XFubenHackConfig = XFubenHackConfig or {} + +local TABLE_HACK_ACTIVITY = "Share/Fuben/Hack/HackActivity.tab" +local TABLE_HACK_BUFF = "Share/Fuben/Hack/HackBuff.tab" +local TABLE_HACK_CHAPTER = "Share/Fuben/Hack/HackChapter.tab" +local TABLE_HACK_EFFECT = "Share/Fuben/Hack/HackCharacterEffect.tab" +local TABLE_HACK_EXPLEVEL = "Share/Fuben/Hack/HackExpLevel.tab" +local TABLE_HACK_REWARD = "Share/Fuben/Hack/HackReward.tab" +local TABLE_HACK_STAGE = "Share/Fuben/Hack/HackStage.tab" + +local HackActivity = {} +local HackBuff = {} +local HackChapter = {} +local HackCharEffect = {} +local HackExpLevel = {} +local HackStage = {} +local HackReward = {} +local HackLevelGroup = {} + +XFubenHackConfig.PopUpPos = { + Left = 1, + Right = 2, +} + +XFubenHackConfig.BuffBarCapacity = 3 + +function XFubenHackConfig.Init() + HackActivity = XTableManager.ReadByIntKey(TABLE_HACK_ACTIVITY, XTable.XTableHackActivity, "Id") + HackBuff = XTableManager.ReadByIntKey(TABLE_HACK_BUFF, XTable.XTableHackBuff, "Id") + HackChapter = XTableManager.ReadByIntKey(TABLE_HACK_CHAPTER, XTable.XTableHackChapter, "Id") + HackCharEffect = XTableManager.ReadByIntKey(TABLE_HACK_EFFECT, XTable.XTableHackCharacterEffect, "Id") + HackExpLevel = XTableManager.ReadByIntKey(TABLE_HACK_EXPLEVEL, XTable.XTableHackExpLevel, "Id") + HackStage = XTableManager.ReadByIntKey(TABLE_HACK_STAGE, XTable.XTableHackStage, "Id") + HackReward = XTableManager.ReadByIntKey(TABLE_HACK_REWARD, XTable.XTableHackReward, "Id") + for _, v in pairs(HackExpLevel) do + if not HackLevelGroup[v.ChapterId] then + HackLevelGroup[v.ChapterId] = {} + end + HackLevelGroup[v.ChapterId][v.Level] = v + end +end + +function XFubenHackConfig.GetStageInfo(id) + local template = HackStage[id] + if not template then + XLog.ErrorTableDataNotFound("XFubenHackConfig.GetStageInfo", "HackStage", TABLE_HACK_STAGE, "id", tostring(id)) + return + end + return template +end + +function XFubenHackConfig.GetStages() + return HackStage +end + +function XFubenHackConfig.GetChapterTemplate(id) + return HackChapter[id] +end + +function XFubenHackConfig.GetActTemplates() + return HackActivity +end + +function XFubenHackConfig.GetActivityTemplateById(id) + return HackActivity[id] +end + +function XFubenHackConfig.GetReward() + return HackReward +end + +function XFubenHackConfig.GetRewardById(id) + return HackReward[id] +end + +function XFubenHackConfig.GetBuffById(id) + return HackBuff[id] +end + +function XFubenHackConfig.GetLevelCfg(chapterId, level) + return HackLevelGroup[chapterId] and HackLevelGroup[chapterId][level] +end + +function XFubenHackConfig.GetLevelCfgs(chapterId) + return HackLevelGroup[chapterId] +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XFubenInfestorExploreConfigs.lua b/Resources/Scripts/XConfig/XFubenInfestorExploreConfigs.lua new file mode 100644 index 00000000..dc2aaa53 --- /dev/null +++ b/Resources/Scripts/XConfig/XFubenInfestorExploreConfigs.lua @@ -0,0 +1,907 @@ +local TABLE_SECTION_PATH = "Client/Fuben/InfestorExplore/ExploreSection.tab" +local TABLE_CHAPTER_PATH = "Share/Fuben/InfestorExplore/ExploreChapter.tab" +local TABLE_STAGE_PATH = "Share/Fuben/InfestorExplore/ExploreNode.tab" +local TABLE_LEVEL_GROUP_PATH = "Share/Fuben/InfestorExplore/InfestorGroup.tab" +local TABLE_DIFF_PATH = "Share/Fuben/InfestorExplore/InfestorDiff.tab" +local TABLE_FOG_PATH = "Client/Fuben/InfestorExplore/Fog.tab" +local TABLE_MAP_PATH = "Share/Fuben/InfestorExplore/Map/" +local TABLE_NODETYPE_PATH = "Client/Fuben/InfestorExplore/NodeType.tab" +local TABLE_EVENT_POOL_PATH = "Share/Fuben/InfestorExplore/ExploreEventPool.tab" +local TABLE_EVENT_POOL_RES_PATH = "Client/Fuben/InfestorExplore/ExploreEventPoolRes.tab" +local TABLE_FIGHTEVENT_PATH = "Share/Fuben/InfestorExplore/InfestorFightEvent.tab" +local TABLE_BUFF_PATH = "Client/Fuben/InfestorExplore/Buffs.tab" +local TABLE_CORE_PATH = "Share/Fuben/InfestorExplore/Core.tab" +local TABLE_CORE_LEVEL_PATH = "Share/Fuben/InfestorExplore/CoreLevelEffect.tab" +local TABLE_SUPPLY_REWARD_PATH = "Client/Fuben/InfestorExplore/SupplyReward.tab" +local TABLE_SHOP_PATH = "Share/Fuben/InfestorExplore/Shop.tab" +local TABLE_SHOP_GOODS_PATH = "Share/Fuben/InfestorExplore/ShopGoods.tab" +local TABLE_REWARD_PATH = "Share/Fuben/InfestorExplore/ExploreRewardPool.tab" +local TABLE_EVENT_GOODS_PATH = "Share/Fuben/InfestorExplore/InfestorEventGoods.tab" +local TABLE_EVENT_TYPE_PATH = "Client/Fuben/InfestorExplore/EventType.tab" +local TABLE_FIGHT_REWARD_COST_PATH = "Share/Fuben/InfestorExplore/FightRewardCost.tab" +local TABLE_ACTIVITY_PATH = "Share/Fuben/InfestorExplore/InfestorActivity.tab" +local TABLE_OUTPOST_DES_PATH = "Client/Fuben/InfestorExplore/OutPostDes.tab" +local TABLE_OUTPOST_DES_POOL_PATH = "Client/Fuben/InfestorExplore/OutPostDesPool.tab" +local TABLE_SCORE_RULE_PATH = "Share/Fuben/InfestorExplore/InfestorBossScoreRule.tab" + +local CSXTextManagerGetText = CS.XTextManager.GetText +local tableInsert = table.insert +local tableUnpack = table.unpack +local stringFormat = string.format + +local SectionTemplate = {} +local ChapterTemplate = {} +local StageTemplate = {} +local LevelGroupTemplate = {} +local NodeTypeTemplate = {} +local EventPoolMultionOptionsDic = {} +local EventTemplate = {} +local EventPoolTemplate = {} +local DiffConfigDic = {} +local MapTemplates = {} +local FogDepthDic = {} +local BuffTemplate = {} +local FightEventTemplate = {} +local CoreTemplate = {} +local CoreLevelDic = {} +local SupplyRewardTemplate = {} +local ShopTemplate = {} +local ShopGoodsTemplate = {} +local RewardTemplate = {} +local EventGoodsTemplate = {} +local EventTypeTemplate = {} +local FightRewardCostTemplate = {} +local ActivityTemplate = {} +local OutPostDesPoolDic = {} +local OutPostDesDic = {} +local ScoreRuleDict = {} + +local QualityIconPath = { + [1] = CS.XGame.ClientConfig:GetString("UiInfestorExploreCorePurple"), + [2] = CS.XGame.ClientConfig:GetString("UiInfestorExploreCorePurple"), + [3] = CS.XGame.ClientConfig:GetString("UiInfestorExploreCorePurple"), + [4] = CS.XGame.ClientConfig:GetString("UiInfestorExploreCorePurple"), + [5] = CS.XGame.ClientConfig:GetString("UiInfestorExploreCoreGold"), + [6] = CS.XGame.ClientConfig:GetString("UiInfestorExploreCoreRed"), +} + +local QualityLevel = { + Purple = 4, + Gold = 5, --插件单元金色品质 +} + +XFubenInfestorExploreConfigs = XFubenInfestorExploreConfigs or {} + +XFubenInfestorExploreConfigs.Region = { + UpRegion = 1, --晋级区 + KeepRegion = 2, --保级区 + DownRegion = 3, --降级区 +} + +XFubenInfestorExploreConfigs.EventType = { + Unknown = 0, + AddCore = 101, --获得战术核心 + LostCore = 102, --失去一个现有战术核心 + LevelUpCore = 103, --升级一个已有核心 + ChangeTeamHpPer = 201, --改变队伍百分比血量 + ChangeCharacterHpPer = 202, --改变成员百分比血量 + ChangeMoneyPer = 301, --获得or失去百分比代币 + ChangeMoney = 302, --获得or失去指定数量代币 + ChangeMoneyRandom = 303, --获得or失去随机数量代币 + ChangeActionPoint = 401, --获得or失去指定数量行动点 + AddBuff = 501, --获得一个buff + RemoveBuff = 502, --随机移除一个已有buff +} + +XFubenInfestorExploreConfigs.MaxWearingCoreNum = 6 --核心最大穿戴数量 +XFubenInfestorExploreConfigs.MaxEventOptionNum = 3 --可选择事件最大选项数量 + +local InitMapConfig = function() + local paths = CS.XTableManager.GetPaths(TABLE_MAP_PATH) + XTool.LoopCollection(paths, function(path) + local key = tonumber(XTool.GetFileNameWithoutExtension(path)) + MapTemplates[key] = XTableManager.ReadByIntKey(path, XTable.XTableInfestorExploreGrid, "Id") + end) +end + +local MAX_FOG_DEPTH = 5--最大迷雾深度 +local InitFogConfig = function() + local template = XTableManager.ReadByIntKey(TABLE_FOG_PATH, XTable.XTableInfestorExploreFog, "Id") + for _, config in pairs(template) do + local depth = config.Depth + if depth > MAX_FOG_DEPTH then + XLog.Error("XFubenInfestorExploreConfigs InitFogConfig Erorr: 感染体玩法地图深度配置错误:超过最大深度上限: " .. MAX_FOG_DEPTH .. ", 配置路径: " .. TABLE_FOG_PATH) + return + end + FogDepthDic[config.Type] = depth + end +end + +local InitDiffConfig = function() + local template = XTableManager.ReadByIntKey(TABLE_DIFF_PATH, XTable.XTableInfestorExploreDiff, "Id") + for _, config in pairs(template) do + local groupId = config.GroupId + local groupConfig = DiffConfigDic[groupId] or {} + DiffConfigDic[groupId] = groupConfig + + local diff = config.Diff + groupConfig[diff] = config + end +end + +local InitEventPoolResConfig = function() + local template = XTableManager.ReadByIntKey(TABLE_EVENT_POOL_RES_PATH, XTable.XTableInfestorEventPoolRes, "PoolId") + for _, config in pairs(template) do + local poolId = config.PoolId + local multiOption = EventPoolMultionOptionsDic[poolId] or {} + + for i = 1, XFubenInfestorExploreConfigs.MaxEventOptionNum do + local options = multiOption[i] or {} + multiOption[i] = options + + for index, eventId in pairs(config["EventId" .. i]) do + options[index] = eventId + end + end + + EventPoolMultionOptionsDic[poolId] = multiOption + end + EventPoolTemplate = template +end + +local InitCoreLevelConfig = function() + local template = XTableManager.ReadByIntKey(TABLE_CORE_LEVEL_PATH, XTable.XTableInfestorExploreCoreLevelEffect, "Id") + for _, config in pairs(template) do + local coreId = config.CoreId + local coreConfig = CoreLevelDic[coreId] or {} + CoreLevelDic[coreId] = coreConfig + + local level = config.CoreLevel + coreConfig[level] = config + end +end + +local InitOutPostDesPoolConfig = function() + local template = XTableManager.ReadByIntKey(TABLE_OUTPOST_DES_POOL_PATH, XTable.XTableInfestorOutPostDesPool, "Id") + for _, config in pairs(template) do + local poolId = config.PoolId + + local desList = OutPostDesPoolDic[poolId] or {} + OutPostDesPoolDic[poolId] = desList + + tableInsert(desList, config.Description) + end +end + +local InitOutPostDesConfig = function() + local template = XTableManager.ReadByIntKey(TABLE_OUTPOST_DES_PATH, XTable.XTableInfestorOutPostDes, "Id") + for _, config in pairs(template) do + local key = config.Key + OutPostDesDic[key] = config + end +end + +local InitScoreRuleConfig = function() + ScoreRuleDict = XTableManager.ReadByIntKey(TABLE_SCORE_RULE_PATH, XTable.XTableInfestorBossScoreRule, "StageId") +end + +function XFubenInfestorExploreConfigs.Init() + SectionTemplate = XTableManager.ReadByIntKey(TABLE_SECTION_PATH, XTable.XTableInfestorExploreSection, "Id") + ChapterTemplate = XTableManager.ReadByIntKey(TABLE_CHAPTER_PATH, XTable.XTableInfestorExploreChapter, "Id") + StageTemplate = XTableManager.ReadByIntKey(TABLE_STAGE_PATH, XTable.XTableInfestorExploreNode, "Id") + LevelGroupTemplate = XTableManager.ReadByIntKey(TABLE_LEVEL_GROUP_PATH, XTable.XTableInfestorGroup, "Id") + NodeTypeTemplate = XTableManager.ReadByIntKey(TABLE_NODETYPE_PATH, XTable.XTableInfestorNodeType, "Type") + BuffTemplate = XTableManager.ReadByIntKey(TABLE_BUFF_PATH, XTable.XTableInfestorBuffsRes, "Id") + FightEventTemplate = XTableManager.ReadByIntKey(TABLE_FIGHTEVENT_PATH, XTable.XTableInfestorFightEvent, "Id") + CoreTemplate = XTableManager.ReadByIntKey(TABLE_CORE_PATH, XTable.XTableInfestorExploreCore, "Id") + SupplyRewardTemplate = XTableManager.ReadByIntKey(TABLE_SUPPLY_REWARD_PATH, XTable.XTableInfestorSupplyRewardRes, "Id") + ShopTemplate = XTableManager.ReadByIntKey(TABLE_SHOP_PATH, XTable.XTableInfestorExploreShop, "Id") + ShopGoodsTemplate = XTableManager.ReadByIntKey(TABLE_SHOP_GOODS_PATH, XTable.XTableInfestorExploreShopGoods, "Id") + RewardTemplate = XTableManager.ReadByIntKey(TABLE_REWARD_PATH, XTable.XTableInfestorExploreReward, "Id") + EventGoodsTemplate = XTableManager.ReadByIntKey(TABLE_EVENT_GOODS_PATH, XTable.XTableInfestorEventGoods, "EventId") + EventTemplate = XTableManager.ReadByIntKey(TABLE_EVENT_POOL_PATH, XTable.XTableInfestorExploreEvent, "Id") + EventTypeTemplate = XTableManager.ReadByIntKey(TABLE_EVENT_TYPE_PATH, XTable.XTableInfestorEventType, "Type") + FightRewardCostTemplate = XTableManager.ReadByIntKey(TABLE_FIGHT_REWARD_COST_PATH, XTable.XTableInfestorFightRewardCost, "Times") + ActivityTemplate = XTableManager.ReadByIntKey(TABLE_ACTIVITY_PATH, XTable.XTableInfestorActivity, "Id") + InitDiffConfig() + InitMapConfig() + InitFogConfig() + InitEventPoolResConfig() + InitCoreLevelConfig() + InitOutPostDesPoolConfig() + InitOutPostDesConfig() + InitScoreRuleConfig() +end + +local GetOutPostDesPoolDesList = function(poolId) + local config = OutPostDesPoolDic[poolId] + if not config then + XLog.Error("XFubenInfestorExploreConfigs GetOutPostDesPoolConfig error:配置不存在, : " .. poolId .. ", 配置路径: " .. TABLE_OUTPOST_DES_POOL_PATH) + return + end + return config +end + +local GetOutPostDesConfig = function(key) + local config = OutPostDesDic[key] + if not config then + XLog.Error("XFubenInfestorExploreConfigs GetOutPostDesConfig error:配置不存在, : " .. key .. ", 配置路径: " .. TABLE_OUTPOST_DES_PATH) + return + end + return config +end + +local GetScoreRuleConfig = function(key) + local config = ScoreRuleDict[key] + if not config then + XLog.Error("XFubenInfestorExploreConfigs GetScoreRuleConfig error:配置不存在, : " .. key .. ", 配置路径: " .. TABLE_SCORE_RULE_PATH) + return + end + return config +end + +local GetActivityConfig = function(activityId) + local config = ActivityTemplate[activityId] + if not config then + XLog.Error("XFubenInfestorExploreConfigs GetActivityConfig error:配置不存在, : " .. activityId .. ", 配置路径: " .. TABLE_ACTIVITY_PATH) + return + end + return config +end + +local GetSectionConfig = function(sectionId) + local config = SectionTemplate[sectionId] + if not config then + XLog.Error("XFubenInfestorExploreConfigs GetChapterConfig error:配置不存在, sectionId: " .. sectionId .. ", 配置路径: " .. TABLE_SECTION_PATH) + return + end + return config +end + +local GetChapterConfig = function(chapterId) + local config = ChapterTemplate[chapterId] + if not config then + XLog.Error("XFubenInfestorExploreConfigs GetChapterConfig error:配置不存在, chapterId: " .. chapterId .. ", 配置路径: " .. TABLE_CHAPTER_PATH) + return + end + return config +end + +local GetStageConfig = function(stageId) + local config = StageTemplate[stageId] + if not config then + XLog.Error("XFubenInfestorExploreConfigs GetStageConfig error:配置不存在, stageId: " .. stageId .. ", 配置路径: " .. TABLE_STAGE_PATH) + return + end + return config +end + +local GetLevelGroupConfig = function(groupId) + local config = LevelGroupTemplate[groupId] + if not config then + XLog.Error("XFubenInfestorExploreConfigs GetLevelGroupConfig error:配置不存在, groupId: " .. groupId .. ", 配置路径: " .. TABLE_LEVEL_GROUP_PATH) + return + end + return config +end + +local GetGroupDiffConfigs = function(groupId) + local config = DiffConfigDic[groupId] + if not config then + XLog.Error("XFubenInfestorExploreConfigs GetGroupDiffConfigs error:配置不存在, groupId: " .. groupId .. ", 配置路径: " .. TABLE_DIFF_PATH) + return + end + return config +end + +local GetGroupDiffConfig = function(groupId, diff) + local config = GetGroupDiffConfigs(groupId)[diff] + if not config then + XLog.Error("XFubenInfestorExploreConfigs GetGroupDiffConfig error:配置不存在, diff: " .. diff .. ", 配置路径: " .. TABLE_DIFF_PATH) + return + end + return config +end + +local GetNodeTypeConfig = function(nodeType) + local config = NodeTypeTemplate[nodeType] + if not config then + XLog.Error("XFubenInfestorExploreConfigs GetNodeTypeConfig error:配置不存在, nodeType: " .. nodeType .. ", 配置路径: " .. TABLE_NODETYPE_PATH) + return + end + return config +end + +local GetEventConfig = function(eventId) + local config = EventTemplate[eventId] + if not config then + XLog.Error("XFubenInfestorExploreConfigs GetEventConfig error:配置不存在, eventId: " .. eventId .. ", 配置路径: " .. TABLE_EVENT_POOL_PATH) + return + end + return config +end + +local GetEventPoolConfig = function(poolId) + local config = EventPoolTemplate[poolId] + if not config then + XLog.Error("XFubenInfestorExploreConfigs GetEventPoolConfig error:配置不存在, poolId: " .. poolId .. ", 配置路径: " .. TABLE_EVENT_POOL_RES_PATH) + return + end + return config +end + +local GetBuffConfig = function(buffId) + local config = BuffTemplate[buffId] + if not config then + XLog.Error("XFubenInfestorExploreConfigs GetBuffConfig error:配置不存在, buffId: " .. buffId .. ", 配置路径: " .. TABLE_BUFF_PATH) + return + end + return config +end + +local GetFightEventConfig = function(fightEventId) + local config = FightEventTemplate[fightEventId] + if not config then + XLog.Error("XFubenInfestorExploreConfigs GetFightEventConfig error:配置不存在, fightEventId: " .. fightEventId .. ", 配置路径: " .. TABLE_FIGHTEVENT_PATH) + return + end + return config +end + +local GetCoreConfig = function(coreId) + local config = CoreTemplate[coreId] + if not config then + XLog.Error("XFubenInfestorExploreConfigs GetCoreConfig error:配置不存在, coreId : " .. coreId .. ", 配置路径: " .. TABLE_CORE_PATH) + return + end + return config +end + +local GetCoreLevelConfig = function(coreId, level) + local config = CoreLevelDic[coreId] + if not config then + XLog.Error("XFubenInfestorExploreConfigs GetCoreLevelConfig error:配置不存在, coreId : " .. coreId .. ", level : " .. level .. ", 配置路径: " .. TABLE_CORE_LEVEL_PATH) + return + end + + config = config[level] + if not config then + XLog.Error("XFubenInfestorExploreConfigs GetCoreLevelConfig error:配置不存在 coreId : " .. coreId .. ", level : " .. level .. ", 配置路径: " .. TABLE_CORE_LEVEL_PATH) + return + end + + return config +end + +local GetShopConfig = function(shopId) + local config = ShopTemplate[shopId] + if not config then + XLog.Error("XFubenInfestorExploreConfigs GetShopConfig error:配置不存在, shopId : " .. shopId .. ", 配置路径: " .. TABLE_SHOP_PATH) + return + end + return config +end + +local GetShopGoodsConfig = function(goodsId) + local config = ShopGoodsTemplate[goodsId] + if not config then + XLog.Error("XFubenInfestorExploreConfigs GetShopGoodsConfig error:配置不存在, goodsId : " .. goodsId .. ", 配置路径: " .. TABLE_SHOP_GOODS_PATH) + return + end + return config +end + +local GetRewardConfig = function(rewardId) + local config = RewardTemplate[rewardId] + if not config then + XLog.Error("XFubenInfestorExploreConfigs GetRewardConfig error:配置不存在, rewardId : " .. rewardId .. ", 配置路径: " .. TABLE_REWARD_PATH) + return + end + return config +end + +local GetEventGoodsConfig = function(eventId) + local config = EventGoodsTemplate[eventId] + if not config then + XLog.Error("XFubenInfestorExploreConfigs GetEventGoodsConfig error:配置不存在, eventId : " .. eventId .. ", 配置路径: " .. TABLE_EVENT_GOODS_PATH) + return + end + return config +end + +local function GetEventPoolMultiOptions(poolId) + local config = EventPoolMultionOptionsDic[poolId] + if not config then + XLog.Error("XFubenInfestorExploreConfigs GetEventGoodsConfig error:配置不存在, poolId : " .. poolId .. ", 配置路径: " .. TABLE_EVENT_POOL_RES_PATH) + return + end + return config +end + +local function GetEventTypeConfig(eventType) + local config = EventTypeTemplate[eventType] + if not config then + XLog.Error("XFubenInfestorExploreConfigs GetEventTypeConfig error:配置不存在, eventType : " .. eventType .. ", 配置路径: " .. TABLE_EVENT_TYPE_PATH) + return + end + return config +end + +local GetFightRewardCostConfig = function(times) + local config = FightRewardCostTemplate[times] + if not config then + XLog.Error("XFubenInfestorExploreConfigs GetFightRewardCostConfig error:配置不存在, times : " .. times .. ", 配置路径: " .. TABLE_FIGHT_REWARD_COST_PATH) + return + end + return config +end + +function XFubenInfestorExploreConfigs.GetBuffId(fightEventId) + return GetFightEventConfig(fightEventId).ExploreFightEventId[1] +end + +function XFubenInfestorExploreConfigs.GetBuffIdTwo(fightEventId) + return GetFightEventConfig(fightEventId).BossFightEventId[1] +end + +function XFubenInfestorExploreConfigs.GetBuffName(buffId) + return GetBuffConfig(buffId).Name +end + +function XFubenInfestorExploreConfigs.GetBuffDes(buffId) + return GetBuffConfig(buffId).Description +end + +function XFubenInfestorExploreConfigs.GetBuffIcon(buffId) + return GetBuffConfig(buffId).Icon +end + +function XFubenInfestorExploreConfigs.GetSectionName(sectionId) + return GetSectionConfig(sectionId).Name +end + +function XFubenInfestorExploreConfigs.GetChapterConfigs() + return ChapterTemplate +end + +function XFubenInfestorExploreConfigs.GetStageConfigs() + return StageTemplate +end + +function XFubenInfestorExploreConfigs.GetPreChapterId(chapterId) + return GetChapterConfig(chapterId).PreChapterId +end + +function XFubenInfestorExploreConfigs.GetNextChapterId(chapterId) + for paramChapterId in pairs(ChapterTemplate) do + if chapterId == XFubenInfestorExploreConfigs.GetPreChapterId(paramChapterId) then + return paramChapterId + end + end + return 0 +end + +function XFubenInfestorExploreConfigs.GetChapterName(chapterId) + return GetChapterConfig(chapterId).Name +end + +function XFubenInfestorExploreConfigs.GetChapterCharacterLimitType(chapterId) + return GetChapterConfig(chapterId).CharacterLimitType +end + +function XFubenInfestorExploreConfigs.GetChapterLimitBuffId(chapterId) + local limitBuffId = GetChapterConfig(chapterId).LimitBuffId + return XFubenConfigs.GetLimitShowBuffId(limitBuffId) +end + +function XFubenInfestorExploreConfigs.GetChapterPrefabPath(chapterId) + return GetChapterConfig(chapterId).Prefab +end + +function XFubenInfestorExploreConfigs.GetChapterDescription(chapterId) + return GetChapterConfig(chapterId).Description +end + +function XFubenInfestorExploreConfigs.GetChapterIcon(chapterId) + return GetChapterConfig(chapterId).Icon +end + +function XFubenInfestorExploreConfigs.GetChapterBg(chapterId) + return GetChapterConfig(chapterId).Bg +end + +function XFubenInfestorExploreConfigs.GetMapId(chapterId) + return GetChapterConfig(chapterId).MapId +end + +function XFubenInfestorExploreConfigs.GetNodeType(stageId) + return GetStageConfig(stageId).Type +end + +function XFubenInfestorExploreConfigs.GetNodeResType(stageId) + return GetStageConfig(stageId).ResType +end + +function XFubenInfestorExploreConfigs.GetFightStageId(stageId) + return GetStageConfig(stageId).FightStageId +end + +function XFubenInfestorExploreConfigs.GetShowRewardId(stageId) + return GetStageConfig(stageId).ShowRewardId +end + +function XFubenInfestorExploreConfigs.GetUseActionPoint(stageId) + return GetStageConfig(stageId).UseActionPoint +end + +function XFubenInfestorExploreConfigs.GetGroupLevelBorder(groupId) + local config = GetLevelGroupConfig(groupId) + return config.MinLevel, config.MaxLevel +end + +function XFubenInfestorExploreConfigs.GetDiffName(groupId, diff) + local config = GetGroupDiffConfig(groupId, diff) + return config.Name +end + +function XFubenInfestorExploreConfigs.GetDiffIcon(groupId, diff) + local config = GetGroupDiffConfig(groupId, diff) + return config.Icon +end + +function XFubenInfestorExploreConfigs.GetDiffUpNum(groupId, diff) + return GetGroupDiffConfig(groupId, diff).UpNum +end + +function XFubenInfestorExploreConfigs.GetDiffKeepNum(groupId, diff) + local joinNum = GetGroupDiffConfig(groupId, diff).JoinNum + local upNum = XFubenInfestorExploreConfigs.GetDiffUpNum(groupId, diff) + local downNum = XFubenInfestorExploreConfigs.GetDiffDownNum(groupId, diff) + return joinNum - upNum - downNum +end + +function XFubenInfestorExploreConfigs.GetDiffDownNum(groupId, diff) + return GetGroupDiffConfig(groupId, diff).DownNum +end + +function XFubenInfestorExploreConfigs.GetDiffShowScoreGap(groupId, diff) + return GetGroupDiffConfig(groupId, diff).ShowScoreGap +end + +function XFubenInfestorExploreConfigs.GetDiffShowScoreLimit(groupId, diff) + return GetGroupDiffConfig(groupId, diff).ShowScoreLimit +end + +function XFubenInfestorExploreConfigs.GetNodeTypeIcon(nodeResType) + return GetNodeTypeConfig(nodeResType).Icon +end + +function XFubenInfestorExploreConfigs.GetNodeTypeStageBg(nodeResType) + return GetNodeTypeConfig(nodeResType).StageBg +end + +function XFubenInfestorExploreConfigs.GetMapConfig(chapterId) + local mapId = XFubenInfestorExploreConfigs.GetMapId(chapterId) + return MapTemplates[mapId] +end + +function XFubenInfestorExploreConfigs.GetFogDepth(nodeType) + return FogDepthDic[nodeType] or 0 +end + +function XFubenInfestorExploreConfigs.GetEventPoolId(stageId) + return GetStageConfig(stageId).EventPoolId +end + +function XFubenInfestorExploreConfigs.GetEventPoolName(poolId) + return GetEventPoolConfig(poolId).Name +end + +function XFubenInfestorExploreConfigs.GetEventPoolDes(poolId) + return GetEventPoolConfig(poolId).Description +end + +function XFubenInfestorExploreConfigs.GetEventPoolBtnName(poolId) + return GetEventPoolConfig(poolId).BtnName +end + +function XFubenInfestorExploreConfigs.GetEventPoolMultiOptionEventIds(poolId, index) + local eventIds = {} + + local multiOptions = GetEventPoolMultiOptions(poolId) + local multiOption = multiOptions[index] + for _, eventId in pairs(multiOption) do + tableInsert(eventIds, eventId) + end + + return eventIds +end + +function XFubenInfestorExploreConfigs.GetEventPoolMultiOptionDesList(poolId, index) + local desList = {} + + local multiOption = XFubenInfestorExploreConfigs.GetEventPoolMultiOptionEventIds(poolId, index) + for _, eventId in pairs(multiOption) do + tableInsert(desList, XFubenInfestorExploreConfigs.GetEventDes(eventId)) + end + + return desList +end + +function XFubenInfestorExploreConfigs.GetEventDes(eventId) + return GetEventConfig(eventId).Description +end + +function XFubenInfestorExploreConfigs.GetEventName(eventId) + return GetEventConfig(eventId).Name +end + +function XFubenInfestorExploreConfigs.GetEventIcon(eventId) + return GetEventConfig(eventId).Icon +end + +function XFubenInfestorExploreConfigs.GetEventQuality(eventId) + return GetEventConfig(eventId).Quality +end + +function XFubenInfestorExploreConfigs.GetEventQualityIcon(eventId) + return QualityIconPath[XFubenInfestorExploreConfigs.GetEventQuality(eventId)] +end + + +local RankNotRegionText = { + [XFubenInfestorExploreConfigs.Region.UpRegion] = CSXTextManagerGetText("ArenaActivityNotUpRegionDesc"), + [XFubenInfestorExploreConfigs.Region.KeepRegion] = CSXTextManagerGetText("ArenaActivityNotKeepRegionDesc"), + [XFubenInfestorExploreConfigs.Region.DownRegion] = CSXTextManagerGetText("ArenaActivityNotDownRegionDesc"), +} + +function XFubenInfestorExploreConfigs.GetRankNotRegionDescText(rankRegion) + return RankNotRegionText[rankRegion] +end + +function XFubenInfestorExploreConfigs.GetRankRegionName(rankRegion) + if rankRegion == XFubenInfestorExploreConfigs.Region.UpRegion then + return CSXTextManagerGetText("ArenaActivityUpRegion") + elseif rankRegion == XFubenInfestorExploreConfigs.Region.KeepRegion then + return CSXTextManagerGetText("ArenaActivityKeepRegion") + elseif rankRegion == XFubenInfestorExploreConfigs.Region.DownRegion then + return CSXTextManagerGetText("ArenaActivityDownRegion") + else + XLog.Error("XFubenInfestorExploreConfigs.GetRankRegionName Error: 配置找不到, rankRegion" .. rankRegion) + end +end + +function XFubenInfestorExploreConfigs.GetRankRegionDescText(groupId, diff, rankRegion) + local config = GetGroupDiffConfig(groupId, diff) + if rankRegion == XFubenInfestorExploreConfigs.Region.UpRegion then + return CSXTextManagerGetText("ArenaActivityUpRegionDesc", 1, config.UpNum) + elseif rankRegion == XFubenInfestorExploreConfigs.Region.DownRegion then + return CSXTextManagerGetText("ArenaActivityDownRegionDesc", config.JoinNum - config.DownNum + 1, config.JoinNum) + elseif rankRegion == XFubenInfestorExploreConfigs.Region.KeepRegion then + return CSXTextManagerGetText("ArenaActivityKeepRegionDesc", config.UpNum + 1, config.JoinNum - config.DownNum) + else + XLog.Error("XFubenInfestorExploreConfigs.GetRankRegionDescText Error: 配置找不到, groupId: " .. groupId .. ", diff: " .. diff .. ", rankRegion" .. rankRegion) + end +end + +local RankRegionColorText = { + [XFubenInfestorExploreConfigs.Region.UpRegion] = CSXTextManagerGetText("ArenaActivityUpRegionColor"), + [XFubenInfestorExploreConfigs.Region.KeepRegion] = CSXTextManagerGetText("ArenaActivityKeepRegionColor"), + [XFubenInfestorExploreConfigs.Region.DownRegion] = CSXTextManagerGetText("ArenaActivityDownRegionColor"), +} + +function XFubenInfestorExploreConfigs.GetRankRegionColorText(rankRegion) + return RankRegionColorText[rankRegion] +end + +function XFubenInfestorExploreConfigs.GetRankRegionMailId(groupId, diff, rankRegion) + local config = GetGroupDiffConfig(groupId, diff) + if rankRegion == XFubenInfestorExploreConfigs.Region.UpRegion then + return config.UpMailId + elseif rankRegion == XFubenInfestorExploreConfigs.Region.DownRegion then + return config.DownMailId + else + return config.KeepMailId + end +end + +function XFubenInfestorExploreConfigs.GetCoreIcon(coreId) + return GetCoreConfig(coreId).Icon +end + +function XFubenInfestorExploreConfigs.GetCoreQuality(coreId) + return GetCoreConfig(coreId).Quality +end + +--获得等级 +function XFubenInfestorExploreConfigs.GetCoreQualityIcon(coreId) + return QualityIconPath[XFubenInfestorExploreConfigs.GetCoreQuality(coreId)] +end + +function XFubenInfestorExploreConfigs.GetCoreMaxLevel(coreId) + return GetCoreConfig(coreId).MaxLevel +end + +function XFubenInfestorExploreConfigs.GetCoreName(coreId) + return GetCoreConfig(coreId).Name +end + +function XFubenInfestorExploreConfigs.GetCoreLevelDes(coreId, level) + return GetCoreLevelConfig(coreId, level).Description +end + +function XFubenInfestorExploreConfigs.GetCoreDecomposeMoney(coreId, level) + return GetCoreLevelConfig(coreId, level).DecomposeMoney +end + +function XFubenInfestorExploreConfigs.GetSupplyRewardDesTotalNum() + return #SupplyRewardTemplate +end + +function XFubenInfestorExploreConfigs.GetSupplyRewardDes(index) + return SupplyRewardTemplate[index].Description or "" +end + +function XFubenInfestorExploreConfigs.GetShopRefreshCost(shopId) + return GetShopConfig(shopId).RefreshCost +end + +function XFubenInfestorExploreConfigs.GetGoodsCost(goodsId) + return GetShopGoodsConfig(goodsId).Cost +end + +function XFubenInfestorExploreConfigs.GetGoodsCoreId(goodsId) + return GetShopGoodsConfig(goodsId).CoreId +end + +function XFubenInfestorExploreConfigs.GetGoodsCoreLevel(goodsId) + return GetShopGoodsConfig(goodsId).CoreLevel +end + +function XFubenInfestorExploreConfigs.GetGoodsLimitCount(goodsId) + return GetShopGoodsConfig(goodsId).LimitCount or 0 +end + +function XFubenInfestorExploreConfigs.GetGoodsName(goodsId) + local coreId = XFubenInfestorExploreConfigs.GetGoodsCoreId(goodsId) + return XFubenInfestorExploreConfigs.GetCoreName(coreId) +end + +function XFubenInfestorExploreConfigs.GetRewardCoreId(rewardId) + return GetRewardConfig(rewardId).CoreId +end + +function XFubenInfestorExploreConfigs.GetRewardCoreLevel(rewardId) + return GetRewardConfig(rewardId).CoreLevel +end + +function XFubenInfestorExploreConfigs.GetEventGoodsCost(eventId) + return GetEventGoodsConfig(eventId).Cost +end + +function XFubenInfestorExploreConfigs.GetFightRewardCost(buyTimes) + return GetFightRewardCostConfig(buyTimes).Cost +end + +function XFubenInfestorExploreConfigs.GetActivityConfigs() + return ActivityTemplate +end + +function XFubenInfestorExploreConfigs.GetChapter2StageIds(activityId) + return GetActivityConfig(activityId).BossStageId +end + +function XFubenInfestorExploreConfigs.GetOutPostDesPoolIds(key) + return GetOutPostDesConfig(key).PoolId +end + +function XFubenInfestorExploreConfigs.GetScoreRuleConfig(stageId) + return GetScoreRuleConfig(stageId) +end + +local RandomInterver = 0 +function XFubenInfestorExploreConfigs.GetRandomOutPostDes(poolId) + local desList = GetOutPostDesPoolDesList(poolId) + + local totalDesNum = #desList + RandomInterver = RandomInterver + 100 + math.randomseed(os.time() + RandomInterver) + local ret = math.random(totalDesNum) + + return desList[ret] +end + +function XFubenInfestorExploreConfigs.GetEventTypeTipContent(eventType, eventArgs) + local des = GetEventTypeConfig(eventType).Description + + if eventType == XFubenInfestorExploreConfigs.EventType.LostCore then + local coreId = eventArgs and eventArgs[1] + if not XDataCenter.FubenInfestorExploreManager.IsHaveCore(coreId) then + return GetEventTypeConfig(eventType).DescriptionEmpty + end + local coreName = XFubenInfestorExploreConfigs.GetCoreName(coreId) + return stringFormat(des, coreName) + elseif eventType == XFubenInfestorExploreConfigs.EventType.ChangeTeamHpPer then + local hpPer = tableUnpack(eventArgs) + if hpPer < 0 then + des = GetEventTypeConfig(eventType).DescriptionRevert + hpPer = -hpPer + end + return stringFormat(des, hpPer) + elseif eventType == XFubenInfestorExploreConfigs.EventType.ChangeCharacterHpPer then + local hpPer, characterId = tableUnpack(eventArgs) + local characterName = XCharacterConfigs.GetCharacterFullNameStr(characterId) + if hpPer < 0 then + hpPer = -hpPer + des = GetEventTypeConfig(eventType).DescriptionRevert + end + return stringFormat(des, characterName, hpPer) + elseif eventType == XFubenInfestorExploreConfigs.EventType.ChangeMoneyPer + or eventType == XFubenInfestorExploreConfigs.EventType.ChangeMoney + or eventType == XFubenInfestorExploreConfigs.EventType.ChangeMoneyRandom then + local addMoney = eventArgs and eventArgs[1] + if not addMoney or addMoney == 0 then + des = GetEventTypeConfig(eventType).DescriptionEmpty + return stringFormat(des, 0) + end + if addMoney < 0 then + addMoney = -addMoney + if XDataCenter.FubenInfestorExploreManager.IsMoneyEmpty() then + des = GetEventTypeConfig(eventType).DescriptionEmpty + local oldMoney = XDataCenter.FubenInfestorExploreManager.GetOldMoneyCount() + return stringFormat(des, oldMoney) + end + des = GetEventTypeConfig(eventType).DescriptionRevert + end + return stringFormat(des, addMoney) + elseif eventType == XFubenInfestorExploreConfigs.EventType.ChangeActionPoint then + local addActionPoint = eventArgs and eventArgs[1] + if not addActionPoint or addActionPoint == 0 then + return GetEventTypeConfig(eventType).DescriptionEmpty + end + if addActionPoint < 0 then + addActionPoint = -addActionPoint + if XDataCenter.FubenInfestorExploreManager.IsActionPointEmpty() then + return GetEventTypeConfig(eventType).DescriptionEmpty + end + des = GetEventTypeConfig(eventType).DescriptionRevert + end + return stringFormat(des, addActionPoint) + elseif eventType == XFubenInfestorExploreConfigs.EventType.AddBuff then + local buffId = eventArgs and eventArgs[1] + if buffId then + local buffName = XFubenInfestorExploreConfigs.GetBuffName(buffId) + return stringFormat(des, buffName) + end + elseif eventType == XFubenInfestorExploreConfigs.EventType.RemoveBuff then + local buffIds = eventArgs + if not buffIds then + return GetEventTypeConfig(eventType).DescriptionEmpty + end + for _, buffId in pairs(buffIds) do + if XDataCenter.FubenInfestorExploreManager.CheckBuffExsit(buffIds) then + return des + end + end + elseif eventType == XFubenInfestorExploreConfigs.EventType.LevelUpCore then + if not eventArgs then + if XDataCenter.FubenInfestorExploreManager.IsHaveOnceCore() then + return GetEventTypeConfig(eventType).DescriptionRevert + else + return GetEventTypeConfig(eventType).DescriptionEmpty + end + end + return "" + end + + return stringFormat(des, tableUnpack(eventArgs)) +end + +--判断奖励的等级 +function XFubenInfestorExploreConfigs.IsPrecious(quality) + if quality >= QualityLevel.Gold then + return true + end +end + +XFubenInfestorExploreConfigs.GetGroupDiffConfigs = GetGroupDiffConfigs \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XFubenMainLineConfigs.lua b/Resources/Scripts/XConfig/XFubenMainLineConfigs.lua new file mode 100644 index 00000000..b652008d --- /dev/null +++ b/Resources/Scripts/XConfig/XFubenMainLineConfigs.lua @@ -0,0 +1,72 @@ +XFubenMainLineConfigs = XFubenMainLineConfigs or {} + +local TABLE_CHAPTER_MAIN = "Share/Fuben/MainLine/ChapterMain.tab" +local TABLE_CHAPTER = "Share/Fuben/MainLine/Chapter.tab" +local TABLE_TREASURE = "Share/Fuben/MainLine/Treasure.tab" +local TABLE_EXPLOREGROUP = "Client/Fuben/MainLine/ExploreGroup.tab" +local TABLE_EXPLOREITEM = "Client/Fuben/MainLine/ExploreItem.tab" + +local ChapterMainTemplates = {} +local ChapterCfg = {} +local TreasureCfg = {} +local ExploreGroupCfg = {} +local ExploreItemCfg = {} + +function XFubenMainLineConfigs.Init() + ChapterMainTemplates = XTableManager.ReadByIntKey(TABLE_CHAPTER_MAIN, XTable.XTableChapterMain, "Id") + ChapterCfg = XTableManager.ReadByIntKey(TABLE_CHAPTER, XTable.XTableChapter, "ChapterId") + TreasureCfg = XTableManager.ReadByIntKey(TABLE_TREASURE, XTable.XTableTreasure, "TreasureId") + ExploreGroupCfg = XTableManager.ReadByIntKey(TABLE_EXPLOREGROUP, XTable.XTableMainLineExploreGroup, "Id") + ExploreItemCfg = XTableManager.ReadByIntKey(TABLE_EXPLOREITEM, XTable.XTableMainLineExploreItem, "Id") +end + +function XFubenMainLineConfigs.GetChapterMainTemplates() + return ChapterMainTemplates +end + +function XFubenMainLineConfigs.GetChapterCfg() + return ChapterCfg +end + +function XFubenMainLineConfigs.GetTreasureCfg() + return TreasureCfg +end + +function XFubenMainLineConfigs.GetExploreGroupCfg() + return ExploreGroupCfg +end + +function XFubenMainLineConfigs.GetExploreItemCfg() + return ExploreItemCfg +end + +function XFubenMainLineConfigs.GetExploreItemCfgById(id) + return ExploreItemCfg[id] +end + +--- +--- 根据'chapterMainId'获取章节的周目Id +---@param chapterMainId number +---@return number +function XFubenMainLineConfigs.GetZhouMuId(chapterMainId) + if (ChapterMainTemplates or {})[chapterMainId] == nil then + XLog.ErrorTableDataNotFound("XFubenMainLineConfigs.GetZhouMuId", + "主线章节", TABLE_CHAPTER_MAIN, "Id", tostring(chapterMainId)) + return + end + return ChapterMainTemplates[chapterMainId].ZhouMuId +end + +local GetChapterMainConfig = function(id) + local config = ChapterMainTemplates[id] + if not config then + XLog.Error("XTRPGConfigs GetChapterMainConfig error:配置不存在, Id: " .. id .. ", 配置路径: " .. TABLE_CHAPTER_MAIN) + return + end + return config +end + +function XFubenMainLineConfigs.GetChapterMainChapterEn(id) + local config = GetChapterMainConfig(id) + return config.ChapterEn +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XFubenNewCharConfig.lua b/Resources/Scripts/XConfig/XFubenNewCharConfig.lua new file mode 100644 index 00000000..4022276e --- /dev/null +++ b/Resources/Scripts/XConfig/XFubenNewCharConfig.lua @@ -0,0 +1,116 @@ +XFubenNewCharConfig = XFubenNewCharConfig or {} + +local SHARE_NEWCHAR_TEACH = "Share/Fuben/Teaching/TeachingActivity.tab" +local SHARE_NEWCHAR_TREASURE = "Share/Fuben/Teaching/TeachingTreasure.tab" +local CLIENT_CHARMSG = "Client/Fuben/Teaching/CharActiveMsg.tab" +local SHARE_STAGE_DETAIL = "Share/Fuben/Teaching/TeachingRobot.tab" + +local NewCharTeachAct = {} +local NewCharTreasure = {} +local NewCharMsg = {} +local NewCharMsgGroup = {} +local NewCharStageDetail = {} + +XFubenNewCharConfig.NewCharType = +{ + YinMianZheGuang = 1, + KoroChar = 2, + WeiLa = 3, +} + +XFubenNewCharConfig.KoroPanelType = +{ + Normal = 1, + Teaching = 2, + Challenge = 3, +} + +function XFubenNewCharConfig.Init() + NewCharTeachAct = XTableManager.ReadByIntKey(SHARE_NEWCHAR_TEACH, XTable.XTableTeachingActivity, "Id") + NewCharTreasure = XTableManager.ReadByIntKey(SHARE_NEWCHAR_TREASURE, XTable.XTableTeachingTreasure, "TreasureId") + NewCharMsg = XTableManager.ReadByIntKey(CLIENT_CHARMSG, XTable.XTableCharActiveMsg, "Id") + NewCharStageDetail = XTableManager.ReadByIntKey(SHARE_STAGE_DETAIL, XTable.XTableTeachingRobot, "StageId") + for _, v in pairs(NewCharMsg) do + NewCharMsgGroup[v.ActId] = NewCharMsgGroup[v.ActId] or {} + local grp = NewCharMsgGroup[v.ActId] + table.insert(grp, v) + end + + for _, v in pairs(NewCharMsgGroup) do + table.sort(v, function(a, b) + if a.Order ~= b.Order then + return a.Order < b.Order + end + + return a.Id < b.Id + end) + end +end + +function XFubenNewCharConfig.GetDataById(id) + local template = NewCharTeachAct[id] + if not template then + XLog.ErrorTableDataNotFound("XFubenNewCharConfig.GetDataById", "TeachingActivity", SHARE_NEWCHAR_TEACH, "Id", tostring(id)) + return + end + return template +end + +function XFubenNewCharConfig.GetActTemplates() + return NewCharTeachAct +end + +function XFubenNewCharConfig.GetMsgGroupById(id) + local group = NewCharMsgGroup[id] + if not group then + XLog.ErrorTableDataNotFound("XFubenNewCharConfig.GetMsgGroupById", "CharActiveMsg", CLIENT_CHARMSG, "Id", tostring(id)) + return + end + return group +end + +function XFubenNewCharConfig.GetTreasureCfg(treasureId) + return NewCharTreasure[treasureId] +end + +function XFubenNewCharConfig.GetActivityTime(id) + local config = XFubenNewCharConfig.GetDataById(id) + return XFunctionManager.GetTimeByTimeId(config.TimeId) +end + +function XFubenNewCharConfig.GetNewCharType(id) + local config = NewCharTeachAct[id] + return config.NewCharType +end + +--获取详情描述 +function XFubenNewCharConfig.GetNewCharDescDetail(id) + local config = NewCharStageDetail[id] + return string.gsub(config.DescDetail, "\\n", "\n") +end + +function XFubenNewCharConfig.GetNewCharShowFightEventIds(id) + local config = NewCharStageDetail[id] + return config.ShowFightEventIds +end + +function XFubenNewCharConfig.GetNewCharKoroCfg() + local cfg = nil + + if NewCharTeachAct then + for _, v in pairs(NewCharTeachAct) do + if v.NewCharType == XFubenNewCharConfig.NewCharType.KoroChar then + cfg = v + break + end + end + end + + return cfg +end + +--获取试用角色 +function XFubenNewCharConfig:GetTryCharacterIds(id) + local config = NewCharStageDetail[id] + return config.RobotId +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XFubenRepeatChallengeConfigs.lua b/Resources/Scripts/XConfig/XFubenRepeatChallengeConfigs.lua new file mode 100644 index 00000000..73c71078 --- /dev/null +++ b/Resources/Scripts/XConfig/XFubenRepeatChallengeConfigs.lua @@ -0,0 +1,113 @@ +local TABLE_ACTIVITY_PATH = "Share/Fuben/RepeatChallenge/RepeatChallengeActivity.tab" +local TABLE_CHAPTER_PATH = "Share/Fuben/RepeatChallenge/RepeatChallengeChapter.tab" +local TABLE_STAGE_PATH = "Share/Fuben/RepeatChallenge/RepeatChallengeStage.tab" +local TABLE_LEVEL_PATH = "Share/Fuben/RepeatChallenge/RepeatChallengeLevel.tab" +local TABLE_REWARD_PATH = "Share/Fuben/RepeatChallenge/RepeatChallengeReward.tab" + +local pairs = pairs + +local RepeatChallengeActivityTemplates = {} +local RepeatChallengeChapterTemplates = {} +local RepeatChallengeStageTemplates = {} +local RepeatChallengeLevelTemplates = {} +local RepeatChallengeRewardTemplates = {} + +local DefaultActivityId = 0 +local StageIdToChapterIdDic = {} + +XFubenRepeatChallengeConfigs = XFubenRepeatChallengeConfigs or {} + +function XFubenRepeatChallengeConfigs.Init() + RepeatChallengeActivityTemplates = XTableManager.ReadByIntKey(TABLE_ACTIVITY_PATH, XTable.XTableRepeatChallengeActivity, "Id") + RepeatChallengeChapterTemplates = XTableManager.ReadByIntKey(TABLE_CHAPTER_PATH, XTable.XTableRepeatChallengeChapter, "Id") + RepeatChallengeStageTemplates = XTableManager.ReadByIntKey(TABLE_STAGE_PATH, XTable.XTableRepeatChallengeStage, "Id") + RepeatChallengeLevelTemplates = XTableManager.ReadByIntKey(TABLE_LEVEL_PATH, XTable.XTableRepeatChallengeLevel, "Id") + RepeatChallengeRewardTemplates = XTableManager.ReadByIntKey(TABLE_REWARD_PATH, XTable.XTableRepeatChallengeReward, "Id") + + for activityId, config in pairs(RepeatChallengeActivityTemplates) do + if XTool.IsNumberValid(config.ActivityTimeId) then + if DefaultActivityId == 0 or DefaultActivityId < activityId then + DefaultActivityId = activityId + end + end + DefaultActivityId = activityId--若全部过期,取最后一行配置作为默认下次开启的活动ID + end + for chapterId, chapterCfg in pairs(RepeatChallengeChapterTemplates) do + for _, stageId in pairs(chapterCfg.StageId) do + StageIdToChapterIdDic[stageId] = chapterId + end + end +end + +function XFubenRepeatChallengeConfigs.GetChapterCfgs() + return RepeatChallengeChapterTemplates +end + +function XFubenRepeatChallengeConfigs.GetChapterCfgPath() + return TABLE_CHAPTER_PATH +end + +function XFubenRepeatChallengeConfigs.GetChapterCfg(chapterId) + local chapterCfg = RepeatChallengeChapterTemplates[chapterId] + if not chapterCfg then + XLog.ErrorTableDataNotFound("XFubenRepeatChallengeConfigs.GetChapterCfg", + "RepeatChallengeChapter", TABLE_CHAPTER_PATH, "chapterId", tostring(chapterId)) + return + end + return chapterCfg +end + +function XFubenRepeatChallengeConfigs.GetActivityConfig(activityId) + local activityCfg = RepeatChallengeActivityTemplates[activityId] + if not activityCfg then + XLog.ErrorTableDataNotFound("XFubenRepeatChallengeConfigs.GetActivityConfig", + "RepeatChallengeActivity", TABLE_ACTIVITY_PATH, "activityId", tostring(activityId)) + return + end + return activityCfg +end + +function XFubenRepeatChallengeConfigs.GetLevelConfigs() + return RepeatChallengeLevelTemplates +end + +function XFubenRepeatChallengeConfigs.GetMaxLevel() + return #RepeatChallengeLevelTemplates +end + +function XFubenRepeatChallengeConfigs.GetLevelConfig(level) + local activityCfg = RepeatChallengeLevelTemplates[level] + if not activityCfg then + XLog.ErrorTableDataNotFound("XFubenRepeatChallengeConfigs.GetLevelConfig", "RepeatChallengeLevel", TABLE_LEVEL_PATH, "level", tostring(level)) + return + end + return activityCfg +end + +function XFubenRepeatChallengeConfigs.GetStageConfig(stageId) + local activityCfg = RepeatChallengeStageTemplates[stageId] + if not activityCfg then + XLog.ErrorTableDataNotFound("XFubenRepeatChallengeConfigs.GetStageConfig", + "RepeatChallengeStage", TABLE_STAGE_PATH, "stageId", tostring(stageId)) + return + end + return activityCfg +end + +function XFubenRepeatChallengeConfigs.GetChapterRewardConfig(chapterId) + local activityCfg = RepeatChallengeRewardTemplates[chapterId] + if not activityCfg then + XLog.ErrorTableDataNotFound("XFubenRepeatChallengeConfigs.GetChapterRewardConfig", + "RepeatChallengeReward", TABLE_REWARD_PATH, "chapterId", tostring(chapterId)) + return + end + return activityCfg +end + +function XFubenRepeatChallengeConfigs.GetDefaultActivityId() + return DefaultActivityId +end + +function XFubenRepeatChallengeConfigs.GetChapterIdByStageId(stageId) + return StageIdToChapterIdDic[stageId] +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XFubenRogueLikeConfig.lua b/Resources/Scripts/XConfig/XFubenRogueLikeConfig.lua new file mode 100644 index 00000000..e2739b59 --- /dev/null +++ b/Resources/Scripts/XConfig/XFubenRogueLikeConfig.lua @@ -0,0 +1,610 @@ +XFubenRogueLikeConfig = XFubenRogueLikeConfig or {} + +local CLIENT_ROGUELIKE_ACTIVITY = "Client/Fuben/RogueLike/RogueLikeActivityDetails.tab" +local CLIENT_ROGUELIKE_Buff = "Client/Fuben/RogueLike/RogueLikeBuffDetails.tab" + +local CLIENT_ROGUELIKE_TIER_SECTION = "Client/Fuben/RogueLike/RogueLikeTierSectionDetails.tab" +local CLIENT_ROGUELIKE_TIER_SPECIALEVENT = "Client/Fuben/RogueLike/RogueLikeSpecialEventDetails.tab" +local CLIENT_ROGUELIKE_SUPPORTSTATION = "Client/Fuben/RogueLike/RogueLikeSupportStationDetails.tab" +local CLIENT_ROGUELIKE_SPECIALEVENTGROUPITEM = "Client/Fuben/RogueLike/RogueLikeSpecialEventGroupItem.tab" +local CLIENT_ROGUELIKE_SPECIALEVENTGROUPDETAIL = "Client/Fuben/RogueLike/RogueLikeSpecialEventGroupDetails.tab" +local CLIENT_ROGUELIKE_SCORE_DETAIL = "Client/Fuben/RogueLike/RogueLikePurgatoryScoreDesDetail.tab" + +local SHARE_ROGUELIKE_ACTIVITY = "Share/Fuben/RogueLike/RogueLikeActivity.tab" +local SHARE_ROGUELIKE_BOX = "Share/Fuben/RogueLike/RogueLikeBox.tab" +local SHARE_ROGUELIKE_BUFF = "Share/Fuben/RogueLike/RogueLikeBuff.tab" +local SHARE_ROGUELIKE_EVENT = "Share/Fuben/RogueLike/RogueLikeEvent.tab" +local SHARE_ROGUELIKE_NODE = "Share/Fuben/RogueLike/RogueLikeNode.tab" +local SHARE_ROGUELIKE_ROBOT = "Share/Fuben/RogueLike/RogueLikeRobot.tab" +local SHARE_ROGUELIKE_SHOP = "Share/Fuben/RogueLike/RogueLikeShop.tab" +local SHARE_ROGUELIKE_SHOPITEM = "Share/Fuben/RogueLike/RogueLikeShopItem.tab" +local SHARE_ROGUELIKE_TIER = "Share/Fuben/RogueLike/RogueLikeTier.tab" +local SHARE_ROGUELIKE_TIER_SECTION = "Share/Fuben/RogueLike/RogueLikeTierSection.tab" +local SHARE_ROGUELIKE_RECOVER = "Share/Fuben/RogueLike/RogueLikeRecover.tab" +local SHARE_ROGUELIKE_SPECIALEVENT = "Share/Fuben/RogueLike/RogueLikeSpecialEvent.tab" +local SHARE_ROGUELIKE_TEAMEFFECT = "Share/Fuben/RogueLike/RogueLikeTeamEffect.tab" +local SHARE_ROGUELIKE_SUPPORTSTATION = "Share/Fuben/RogueLike/RogueLikeSupportStation.tab" +local SHARE_ROGUELIKE_SPECIALEVENTGROUP = "Share/Fuben/RogueLike/RogueLikeSpecialEventGroup.tab" +local SHARE_ROGUELIKE_NODE_DETAILS = "Share/Fuben/RogueLike/RogueLikeNodeDetails.tab" + + + +local ActivityConfig = {} +local BuffConfig = {} +local NodeConfig = {} +local TierSectionConfig = {} +local SpecialEventConfig = {} +local SupportStationConfig = {} +local SpecialEventGroupDetailsConfig = {} +local SpecialEventGroupItemConfig = {} + +local RogueLikeActivity = {} +local RogueLikeBox = {} +local RogueLikeBuff = {} +local RogueLikeEvent = {} +local RogueLikeNode = {} +local RogueLikeRobot = {} +local RogueLikeShop = {} +local RogueLikeShopItem = {} +local RogueLikeTier = {} +local RogueLikeTierSection = {} +local RogueLikeRecover = {} +local RogueLikeSpecialEvent = {} +local RogueLikeTeamEffect = {} +local RogueLikeSupportStation = {} +local RogueLikeSpecialEventGroup = {} +local RogueLikePurgatoryScoreDesConfig = {} + +local Section2GroupMap = {} +local Group2TierMap = {} + +local Group2NodeMap = {} +local NodeIndexMap = {} + +XFubenRogueLikeConfig.TEAM_NUMBER = CS.XGame.ClientConfig:GetInt("RogueLikeTeamMemberCount") +XFubenRogueLikeConfig.UNKNOW_ROBOT = CS.XGame.ClientConfig:GetString("RogueLikeUnknowRobot") + +XFubenRogueLikeConfig.NORMAL_NODE = CS.XGame.ClientConfig:GetString("RogueLikeNormalNode") +XFubenRogueLikeConfig.BOSS_NODE = CS.XGame.ClientConfig:GetString("RogueLikeBossNode") + +XFubenRogueLikeConfig.ChallengeCoin = CS.XGame.ClientConfig:GetInt("RogueLikeChallengeCoin") +XFubenRogueLikeConfig.PumpkinCoin = CS.XGame.ClientConfig:GetInt("RogueLikePumpkinCoin") +XFubenRogueLikeConfig.KeepsakeCoin = CS.XGame.ClientConfig:GetInt("RogueLikeKeepsakeCoin") + +XFubenRogueLikeConfig.CHECK_LINES = CS.XGame.ClientConfig:GetInt("RogueLikeCheckLineSwitch") + +XFubenRogueLikeConfig.KEY_PLAY_STORY = "KeyRogueLikePlayBeginStory" +XFubenRogueLikeConfig.KEY_SHOW_TIPS = "KeyRogueLikeShowTips" + +XFubenRogueLikeConfig.XRLNodeType = { + Fight = 1, --战斗//不需要请求 + Box = 2, --宝箱//不需要请求 + Rest = 3, --休息//不需要请求 + Shop = 4, --商店//需要请求 + Event = 5, --事件//需要请求 +} + +--这里是定义副本模式的枚举 +XFubenRogueLikeConfig.TierType = { + Normal = 1, --普通 + Purgatory = 2, --试炼 +} +-- 节点图标类型 +XFubenRogueLikeConfig.NodeTabBg = { + [XFubenRogueLikeConfig.XRLNodeType.Fight] = CS.XGame.ClientConfig:GetString("RogueLikeTabFightNor"), + [XFubenRogueLikeConfig.XRLNodeType.Box] = CS.XGame.ClientConfig:GetString("RogueLikeTabBox"), + [XFubenRogueLikeConfig.XRLNodeType.Rest] = CS.XGame.ClientConfig:GetString("RogueLikeTabRest"), + [XFubenRogueLikeConfig.XRLNodeType.Shop] = CS.XGame.ClientConfig:GetString("RogueLikeTabShop"), + [XFubenRogueLikeConfig.XRLNodeType.Event] = CS.XGame.ClientConfig:GetString("RogueLikeTabEvent"), +} +XFubenRogueLikeConfig.NodeTabDisBg = { + [XFubenRogueLikeConfig.XRLNodeType.Fight] = CS.XGame.ClientConfig:GetString("RogueLikeDisTabNor"), + [XFubenRogueLikeConfig.XRLNodeType.Box] = CS.XGame.ClientConfig:GetString("RogueLikeDisTabBox"), + [XFubenRogueLikeConfig.XRLNodeType.Rest] = CS.XGame.ClientConfig:GetString("RogueLikeDisTabRest"), + [XFubenRogueLikeConfig.XRLNodeType.Shop] = CS.XGame.ClientConfig:GetString("RogueLikeDisTabShop"), + [XFubenRogueLikeConfig.XRLNodeType.Event] = CS.XGame.ClientConfig:GetString("RogueLikeDisTabEvent"), +} +XFubenRogueLikeConfig.NodeFightType = { + Normal = 1, + Elite = 2, + Boss = 3 +} +XFubenRogueLikeConfig.NodeFightTabBg = { + [XFubenRogueLikeConfig.NodeFightType.Normal] = CS.XGame.ClientConfig:GetString("RogueLikeTabFightNor"), + [XFubenRogueLikeConfig.NodeFightType.Elite] = CS.XGame.ClientConfig:GetString("RogueLikeTabFightElite"), + [XFubenRogueLikeConfig.NodeFightType.Boss] = CS.XGame.ClientConfig:GetString("RogueLikeTabFightBoss"), +} +XFubenRogueLikeConfig.NodeFightTabDisBg = { + [XFubenRogueLikeConfig.NodeFightType.Normal] = CS.XGame.ClientConfig:GetString("RogueLikeDisTabNor"), + [XFubenRogueLikeConfig.NodeFightType.Elite] = CS.XGame.ClientConfig:GetString("RogueLikeDisTabElite"), + [XFubenRogueLikeConfig.NodeFightType.Boss] = CS.XGame.ClientConfig:GetString("RogueLikeDisTabBoss"), +} + +XFubenRogueLikeConfig.XRLBoxType = { + Item = 1, --物品 + Buff = 2, --buff +} + +XFubenRogueLikeConfig.XRLShopItemType = { + Item = 1, + Buff = 2, + Robot = 3, +} + +XFubenRogueLikeConfig.XRLEventType = { + NormalNode = 1, --普通节点事件 + Other = 2, --其他事件 +} + +XFubenRogueLikeConfig.XRLResetType = { + Recover = 1, --恢复行动点 + IntensifyBuff = 2, --强化buff +} + +-- buff类型 +XFubenRogueLikeConfig.BuffType = { + PositiveBuff = 1, + NegativeBuff = 2 +} + +-- 特殊事件结果类型 +XFubenRogueLikeConfig.SpecialResultType = { + SingleEvent = 1, + MultipleEvent = 2, +} + +-- 选择出站类型 +XFubenRogueLikeConfig.SelectCharacterType = { + Character = 1, + Robot = 2, +} + +XFubenRogueLikeConfig.XRLOtherEventType = { + --获得buff + AddBuff = 1, --测过 + --移除buff + RemoveBuff = 2, + --获得助战机器人 + AddRobot = 3, --测过 + --血量恢复 + AddHp = 4, + --增加行动点 + AddActionPoint = 5, --测过 + --减少行动点 + ActionPoint = 6, --测过 + --获得物品 + GainItem = 7, + --兑换物品 + ExchangeItem = 8, + --消耗物品 + ConsumeItem = 9, + -- 减少血量 + ReduceHp = 10, + -- 获得物品(百分比) + GainItemRate = 11, + -- 消耗物品(百分比) + ConsumeItemRate = 12, +} + +-- 休息点操作,回复行动点,强化buff,离开 +XFubenRogueLikeConfig.ClientRestCount = 3 +XFubenRogueLikeConfig.ClientRestClickType = { + Recover = 1, + IntensifyBuff = 2, + Leave = 3, +} +XFubenRogueLikeConfig.ClientRestClickName = { + [XFubenRogueLikeConfig.ClientRestClickType.Recover] = CS.XTextManager.GetText("RogueLikeAddActionPoint"), + [XFubenRogueLikeConfig.ClientRestClickType.IntensifyBuff] = CS.XTextManager.GetText("RogueLikeIntensifyBuff"), + [XFubenRogueLikeConfig.ClientRestClickType.Leave] = CS.XTextManager.GetText("RogueLikeRestLeave"), +} + +function XFubenRogueLikeConfig.Init() + RogueLikeActivity = XTableManager.ReadByIntKey(SHARE_ROGUELIKE_ACTIVITY, XTable.XTableRogueLikeActivity, "Id") + RogueLikeBox = XTableManager.ReadByIntKey(SHARE_ROGUELIKE_BOX, XTable.XTableRogueLikeBox, "Id") + RogueLikeBuff = XTableManager.ReadByIntKey(SHARE_ROGUELIKE_BUFF, XTable.XTableRogueLikeBuff, "Id") + RogueLikeEvent = XTableManager.ReadByIntKey(SHARE_ROGUELIKE_EVENT, XTable.XTableRogueLikeEvent, "Id") + RogueLikeNode = XTableManager.ReadByIntKey(SHARE_ROGUELIKE_NODE, XTable.XTableRogueLikeNode, "Id") + RogueLikeRobot = XTableManager.ReadByIntKey(SHARE_ROGUELIKE_ROBOT, XTable.XTableRogueLikeRobot, "Id") + RogueLikeShop = XTableManager.ReadByIntKey(SHARE_ROGUELIKE_SHOP, XTable.XTableRogueLikeShop, "Id") + RogueLikeShopItem = XTableManager.ReadByIntKey(SHARE_ROGUELIKE_SHOPITEM, XTable.XTableRogueLikeShopItem, "Id") + RogueLikeTier = XTableManager.ReadByIntKey(SHARE_ROGUELIKE_TIER, XTable.XTableRogueLikeTier, "Id") + RogueLikeTierSection = XTableManager.ReadByIntKey(SHARE_ROGUELIKE_TIER_SECTION, XTable.XTableRogueLikeTierSection, "Id") + RogueLikeRecover = XTableManager.ReadByIntKey(SHARE_ROGUELIKE_RECOVER, XTable.XTableRogueLikeRecover, "Id") + RogueLikeSpecialEvent = XTableManager.ReadByIntKey(SHARE_ROGUELIKE_SPECIALEVENT, XTable.XTableRogueLikeSpecialEvent, "Id") + RogueLikeTeamEffect = XTableManager.ReadByIntKey(SHARE_ROGUELIKE_TEAMEFFECT, XTable.XTableRogueLikeTeamEffect, "Id") + RogueLikeSupportStation = XTableManager.ReadByIntKey(SHARE_ROGUELIKE_SUPPORTSTATION, XTable.XTableRogueLikeSupportStation, "Id") + RogueLikeSpecialEventGroup = XTableManager.ReadByIntKey(SHARE_ROGUELIKE_SPECIALEVENTGROUP, XTable.XTableRogueLikeSpecialEventGroup, "Id") + + ActivityConfig = XTableManager.ReadByIntKey(CLIENT_ROGUELIKE_ACTIVITY, XTable.XTableRogueLikeActivityDetails, "Id") + BuffConfig = XTableManager.ReadByIntKey(CLIENT_ROGUELIKE_Buff, XTable.XTableRogueLikeBuffDetails, "Id") + NodeConfig = XTableManager.ReadByIntKey(SHARE_ROGUELIKE_NODE_DETAILS, XTable.XTableRogueLikeNodeDetails, "Id") + TierSectionConfig = XTableManager.ReadByIntKey(CLIENT_ROGUELIKE_TIER_SECTION, XTable.XTableRogueLikeTierSectionDetails, "Id") + SpecialEventConfig = XTableManager.ReadByIntKey(CLIENT_ROGUELIKE_TIER_SPECIALEVENT, XTable.XTableRogueLikeSpecialEventDetails, "Id") + SupportStationConfig = XTableManager.ReadByIntKey(CLIENT_ROGUELIKE_SUPPORTSTATION, XTable.XTableRogueLikeSupportStationDetails, "Id") + SpecialEventGroupDetailsConfig = XTableManager.ReadByIntKey(CLIENT_ROGUELIKE_SPECIALEVENTGROUPDETAIL, XTable.XTableRogueLikeSpecialEventGroupDetails, "Id") + SpecialEventGroupItemConfig = XTableManager.ReadByIntKey(CLIENT_ROGUELIKE_SPECIALEVENTGROUPITEM, XTable.XTableRogueLikeSpecialEventGroupItem, "Id") + + RogueLikePurgatoryScoreDesConfig = XTableManager.ReadByIntKey(CLIENT_ROGUELIKE_SCORE_DETAIL, XTable.XTableRogueLikePurgatoryScoreDesDetail, "Type") + + XFubenRogueLikeConfig.InitGroup2TierMap() +end + +function XFubenRogueLikeConfig.InitGroup2TierMap() + + -- 按照groupId, tier存储节点 + Group2TierMap = {} + for _, v in pairs(RogueLikeTier) do + if not Group2TierMap[v.Group] then + Group2TierMap[v.Group] = {} + end + if not Group2TierMap[v.Group][v.Tier] then + Group2TierMap[v.Group][v.Tier] = {} + end + + Group2TierMap[v.Group][v.Tier] = { + Nodes = v.NodeId, + FatherNodes = v.FatherNode, + } + end + + -- Section2GroupMap + for _, v in pairs(RogueLikeTierSection) do + for i = 1, #v.GroupId do + local groupId = v.GroupId[i] + if not Section2GroupMap[groupId] then + Section2GroupMap[groupId] = {} + end + + Section2GroupMap[groupId] = { + GroupId = groupId, + MinTier = v.MinTier, + MaxTier = v.MaxTier, + } + end + end + +end + +function XFubenRogueLikeConfig.GetNodesByGroupId(groupId) + if not Group2NodeMap[groupId] then + Group2NodeMap[groupId] = {} + NodeIndexMap[groupId] = {} + local SectionData = Section2GroupMap[groupId] + if not SectionData then + --XLog.Error("SectoinData not exist :" .. tostring(groupId)) + XLog.ErrorTableDataNotFound("XFubenRogueLikeConfig.GetNodesByGroupId", + "SectionData", SHARE_ROGUELIKE_TIER_SECTION, "groupId", tostring(groupId)) + end + local nodeIndex = 0 + for i = SectionData.MinTier, SectionData.MaxTier do + local nodeDatas = Group2TierMap[groupId][i] + for j = 1, #nodeDatas.Nodes do + nodeIndex = nodeIndex + 1 + Group2NodeMap[groupId][nodeIndex] = {} + Group2NodeMap[groupId][nodeIndex].Index = nodeIndex + Group2NodeMap[groupId][nodeIndex].Group = groupId + Group2NodeMap[groupId][nodeIndex].TierIndex = i + Group2NodeMap[groupId][nodeIndex].NodeId = nodeDatas.Nodes[j] + local fatherNodes = {} + if nodeDatas.FatherNodes[j] then + fatherNodes = string.Split(nodeDatas.FatherNodes[j], '|') + end + Group2NodeMap[groupId][nodeIndex].FatherNodes = {} + for fatherNodeIndex = 1, #fatherNodes do + Group2NodeMap[groupId][nodeIndex].FatherNodes[fatherNodeIndex] = tonumber(fatherNodes[fatherNodeIndex]) + end + NodeIndexMap[groupId][nodeDatas.Nodes[j]] = nodeIndex + end + end + end + + return Group2NodeMap[groupId], NodeIndexMap[groupId] +end + +function XFubenRogueLikeConfig.GetGroup2TierMapDatas(groupId, tierIndex) + return Group2TierMap[groupId][tierIndex] +end + +function XFubenRogueLikeConfig.GetNodesByGroup(group) + return Group2TierMap[group] +end + +function XFubenRogueLikeConfig.GetRougueLikeTemplateById(id) + if not RogueLikeActivity[id] then + XLog.ErrorTableDataNotFound("XFubenRogueLikeConfig.GetRougueLikeTemplateById", + "RogueLikeActivity", SHARE_ROGUELIKE_ACTIVITY, "Id", tostring(id)) + return + end + return RogueLikeActivity[id] +end + +function XFubenRogueLikeConfig.GetLastRogueLikeConfig() + local config = RogueLikeActivity[#RogueLikeActivity] + + if not config then + XLog.Error("配置表:RogueLikeActivity 没有配置数据") + return + end + return config +end + +function XFubenRogueLikeConfig.GetRogueLikeConfigById(id) + if not ActivityConfig[id] then + XLog.ErrorTableDataNotFound("XFubenRogueLikeConfig.GetRogueLikeConfigById", + "RogueLikeActivityDetails", CLIENT_ROGUELIKE_ACTIVITY, "Id", tostring(id)) + return + end + return ActivityConfig[id] +end + +function XFubenRogueLikeConfig.GetBoxTemplateById(id) + if not RogueLikeBox[id] then + XLog.ErrorTableDataNotFound("XFubenRogueLikeConfig.GetBoxTemplateById", "RogueLikeBox", SHARE_ROGUELIKE_BOX, "Id", tostring(id)) + return + end + return RogueLikeBox[id] +end + +function XFubenRogueLikeConfig.GetBuffTemplateById(id) + if not RogueLikeBuff[id] then + XLog.ErrorTableDataNotFound("XFubenRogueLikeConfig.GetBuffTemplateById", "RogueLikeBuff", SHARE_ROGUELIKE_BUFF, "Id", tostring(id)) + return + end + return RogueLikeBuff[id] +end + +function XFubenRogueLikeConfig.GetBuffConstItemIdById(id) + if not RogueLikeBuff[id] then + XLog.ErrorTableDataNotFound("XFubenRogueLikeConfig.GetBuffTemplateById", "RogueLikeBuff", SHARE_ROGUELIKE_BUFF, "Id", tostring(id)) + return + end + return RogueLikeBuff[id].CostItemId +end + +function XFubenRogueLikeConfig.GetBuffConstItemCountById(id) + if not RogueLikeBuff[id] then + XLog.ErrorTableDataNotFound("XFubenRogueLikeConfig.GetBuffTemplateById", "RogueLikeBuff", SHARE_ROGUELIKE_BUFF, "Id", tostring(id)) + return + end + return RogueLikeBuff[id].CostItemCount +end + +function XFubenRogueLikeConfig.IsBuffMaxLevel(id) + local buffTemplate = XFubenRogueLikeConfig.GetBuffTemplateById(id) + return buffTemplate.IntensifyId == nil or buffTemplate.IntensifyId == 0 +end + +function XFubenRogueLikeConfig.GetBuffConfigById(id) + if not BuffConfig[id] then + XLog.ErrorTableDataNotFound("XFubenRogueLikeConfig.GetBuffConfigById", "RogueLikeBuffDetails", CLIENT_ROGUELIKE_Buff, "Id", tostring(id)) + return + end + return BuffConfig[id] +end + +function XFubenRogueLikeConfig.GetEventTemplateById(id) + if not RogueLikeEvent[id] then + XLog.ErrorTableDataNotFound("XFubenRogueLikeConfig.GetEventTemplateById", "RogueLikeEvent", SHARE_ROGUELIKE_EVENT, "Id", tostring(id)) + return + end + return RogueLikeEvent[id] +end + +function XFubenRogueLikeConfig.GetNodeTemplateById(id) + if not RogueLikeNode[id] then + XLog.ErrorTableDataNotFound("XFubenRogueLikeConfig.GetNodeTemplateById", "RogueLikeNode", SHARE_ROGUELIKE_NODE, "Id", tostring(id)) + return + end + return RogueLikeNode[id] +end + +function XFubenRogueLikeConfig.GetAllNodes() + return RogueLikeNode +end + +function XFubenRogueLikeConfig.GetNodeConfigteById(id) + if not NodeConfig[id] then + XLog.ErrorTableDataNotFound("XFubenRogueLikeConfig.GetNodeConfigteById", "RogueLikeNodeDetails", SHARE_ROGUELIKE_NODE_DETAILS, "Id", tostring(id)) + return + end + return NodeConfig[id] +end + + +function XFubenRogueLikeConfig.GetRobotTemplateById(id) + if not RogueLikeRobot[id] then + XLog.ErrorTableDataNotFound("XFubenRogueLikeConfig.GetRobotTemplateById", "RogueLikeRobot", SHARE_ROGUELIKE_ROBOT, "Id", tostring(id)) + return + end + return RogueLikeRobot[id] +end + +function XFubenRogueLikeConfig.GetShopTemplateById(id) + if not RogueLikeShop[id] then + XLog.ErrorTableDataNotFound("XFubenRogueLikeConfig.GetShopTemplateById", "RogueLikeShop", SHARE_ROGUELIKE_SHOP, "Id", tostring(id)) + return + end + return RogueLikeShop[id] +end + +function XFubenRogueLikeConfig.GetShopItemTemplateById(id) + if not RogueLikeShopItem[id] then + XLog.ErrorTableDataNotFound("XFubenRogueLikeConfig.GetShopItemTemplateById", + "RogueLikeShopItem", SHARE_ROGUELIKE_SHOPITEM, "Id", tostring(id)) + return + end + return RogueLikeShopItem[id] +end + +function XFubenRogueLikeConfig.GetTierTemplateById(id) + if not RogueLikeTier[id] then + XLog.ErrorTableDataNotFound("XFubenRogueLikeConfig.GetTierTemplateById", "RogueLikeTier", SHARE_ROGUELIKE_TIER, "Id", tostring(id)) + return + end + return RogueLikeTier[id] +end + +function XFubenRogueLikeConfig.GetTierSectionTemplateById(id) + if not RogueLikeTierSection[id] then + XLog.ErrorTableDataNotFound("XFubenRogueLikeConfig.GetTierSectionTemplateById", + "RogueLikeTierSection", SHARE_ROGUELIKE_TIER_SECTION, "Id", tostring(id)) + return + end + return RogueLikeTierSection[id] +end + +function XFubenRogueLikeConfig.GetTierSectionTierTypeById(id) + return RogueLikeTierSection[id] and RogueLikeTierSection[id].TierType +end + +function XFubenRogueLikeConfig.GetTierSectionConfigById(id) + if not TierSectionConfig[id] then + XLog.ErrorTableDataNotFound("XFubenRogueLikeConfig.GetTierSectionConfigById", + "TierSectionDetails", CLIENT_ROGUELIKE_TIER_SECTION, "Id", tostring(id)) + return + end + return TierSectionConfig[id] +end + +function XFubenRogueLikeConfig.GetRecoverTemplateById(id) + if not RogueLikeRecover[id] then + XLog.ErrorTableDataNotFound("XFubenRogueLikeConfig.GetRecoverTemplateById", "RogueLikeRecover", SHARE_ROGUELIKE_RECOVER, "Id", tostring(id)) + return + end + return RogueLikeRecover[id] +end + +function XFubenRogueLikeConfig.GetRecoverHpPercentById(id) + if not RogueLikeRecover[id] then + XLog.ErrorTableDataNotFound("XFubenRogueLikeConfig.GetRecoverTemplateById", "RogueLikeRecover", SHARE_ROGUELIKE_RECOVER, "Id", tostring(id)) + return + end + return RogueLikeRecover[id].HpPercent +end + +-- 获取恢复血量所需支援配额 +function XFubenRogueLikeConfig.GetRecoverCostSupportPointById(id) + if not RogueLikeRecover[id] then + XLog.ErrorTableDataNotFound("XFubenRogueLikeConfig.GetRecoverTemplateById", "RogueLikeRecover", SHARE_ROGUELIKE_RECOVER, "Id", tostring(id)) + return + end + return RogueLikeRecover[id].CostSupportPoint +end + +function XFubenRogueLikeConfig.GetSpecialEventTemplateById(id) + if not RogueLikeSpecialEvent[id] then + XLog.ErrorTableDataNotFound("XFubenRogueLikeConfig.GetSpecialEventTemplateById", + "RogueLikeSpecialEvent", SHARE_ROGUELIKE_SPECIALEVENT, "Id", tostring(id)) + return + end + return RogueLikeSpecialEvent[id] +end + +function XFubenRogueLikeConfig.GetSpecialEventConfigById(id) + if not SpecialEventConfig[id] then + XLog.ErrorTableDataNotFound("XFubenRogueLikeConfig.GetSpecialEventConfigById", + "RogueLikeSpecialEventDetails", CLIENT_ROGUELIKE_TIER_SPECIALEVENT, "Id", tostring(id)) + return + end + return SpecialEventConfig[id] +end + +function XFubenRogueLikeConfig.GetTeamEffectTemplateById(id) + if not RogueLikeTeamEffect[id] then + XLog.ErrorTableDataNotFound("XFubenRogueLikeConfig.GetTeamEffectTemplateById", + "RogueLikeTeamEffect", SHARE_ROGUELIKE_TEAMEFFECT, "Id", tostring(id)) + return + end + return RogueLikeTeamEffect[id] +end + +function XFubenRogueLikeConfig.RogueLikeIsCheckLines() + return XFubenRogueLikeConfig.CHECK_LINES == 1 +end + +function XFubenRogueLikeConfig.GetAllSupports() + return RogueLikeSupportStation +end + +function XFubenRogueLikeConfig.GetSupportStationTemplateById(id) + if not RogueLikeSupportStation[id] then + XLog.ErrorTableDataNotFound("XFubenRogueLikeConfig.GetSupportStationTemplateById", + "RogueLikeSupportStation", SHARE_ROGUELIKE_SUPPORTSTATION, "Id", tostring(id)) + return + end + return RogueLikeSupportStation[id] +end + +function XFubenRogueLikeConfig.GetSupportStationConfigById(id) + if not SupportStationConfig[id] then + XLog.ErrorTableDataNotFound("XFubenRogueLikeConfig.GetSupportStationConfigById", + "SupportStationDetails", CLIENT_ROGUELIKE_SUPPORTSTATION, "Id", tostring(id)) + return + end + return SupportStationConfig[id] +end + +function XFubenRogueLikeConfig.GetSepcialEventGroupTemplateById(id) + if not RogueLikeSpecialEventGroup[id] then + XLog.ErrorTableDataNotFound("XFubenRogueLikeConfig.GetSepcialEventGroupTemplateById", + "RogueLikeSpecialEventGroup", SHARE_ROGUELIKE_SPECIALEVENTGROUP, "Id", tostring(id)) + return + end + return RogueLikeSpecialEventGroup[id] +end + +function XFubenRogueLikeConfig.GetSpecialEventGroupConfigById(id) + if not SpecialEventGroupDetailsConfig[id] then + XLog.ErrorTableDataNotFound("XFubenRogueLikeConfig.GetSpecialEventGroupConfigById", + "RogueLikeSpecialEventGroupDetails", CLIENT_ROGUELIKE_SPECIALEVENTGROUPDETAIL, "Id", tostring(id)) + return + end + return SpecialEventGroupDetailsConfig[id] +end + +function XFubenRogueLikeConfig.GetSpecialEventGroupItemConfigById(id) + if not SpecialEventGroupItemConfig[id] then + XLog.ErrorTableDataNotFound("XFubenRogueLikeConfig.GetSpecialEventGroupItemConfigById", + "RogueLikeSpecialEventGroupItem", CLIENT_ROGUELIKE_SPECIALEVENTGROUPITEM, "Id", tostring(id)) + return + end + return SpecialEventGroupItemConfig[id] +end + +-- 特殊事件组条件 +function XFubenRogueLikeConfig.IsSpecialGroupType(specialEventType) + return specialEventType == XFubenRogueLikeConfig.XRLOtherEventType.ReduceHp or + specialEventType == XFubenRogueLikeConfig.XRLOtherEventType.GainItemRate or + specialEventType == XFubenRogueLikeConfig.XRLOtherEventType.ConsumeItemRate +end + +-- 选择不需要发通知的类型 +function XFubenRogueLikeConfig.IsRequestBeforeSelectType(normalType) + return normalType == XFubenRogueLikeConfig.XRLNodeType.Fight or + normalType == XFubenRogueLikeConfig.XRLNodeType.Box +end + +function XFubenRogueLikeConfig.NoNeedCheckActionPointType(normalType) + return false -- normalType == XFubenRogueLikeConfig.XRLNodeType.Rest +end + + +function XFubenRogueLikeConfig.GetRogueLikePurgatoryScoreDescConfigByType(nodeType) + if not RogueLikePurgatoryScoreDesConfig[nodeType] then + XLog.ErrorTableDataNotFound("XFubenRogueLikeConfig.GetRogueLikePurgatoryScoreDescConfigByType", + "RogueLikePurgatoryScoreDesConfig", CLIENT_ROGUELIKE_SCORE_DETAIL, "Type", tostring(nodeType)) + return + end + return RogueLikePurgatoryScoreDesConfig[nodeType] +end + +function XFubenRogueLikeConfig.GetRogueLikePurgatoryScoreTitleByType(nodeType) + local conifg = XFubenRogueLikeConfig.GetRogueLikePurgatoryScoreDescConfigByType(nodeType) + return conifg and conifg.Title +end + +function XFubenRogueLikeConfig.GetRogueLikePurgatoryScoreDescriptionByType(nodeType) + local conifg = XFubenRogueLikeConfig.GetRogueLikePurgatoryScoreDescConfigByType(nodeType) + return conifg and conifg.Description +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XFubenSimulatedCombatConfig.lua b/Resources/Scripts/XConfig/XFubenSimulatedCombatConfig.lua new file mode 100644 index 00000000..8683e9d1 --- /dev/null +++ b/Resources/Scripts/XConfig/XFubenSimulatedCombatConfig.lua @@ -0,0 +1,112 @@ +XFubenSimulatedCombatConfig = XFubenSimulatedCombatConfig or {} + +local TABLE_SIMUCOMBAT_ACTIVITY = "Share/Fuben/SimulatedCombat/SimulatedCombatActivity.tab" +local TABLE_SIMUCOMBAT_ADDITION = "Share/Fuben/SimulatedCombat/SimulatedCombatAddition.tab" +local TABLE_SIMUCOMBAT_CHALLENGE = "Share/Fuben/SimulatedCombat/SimulatedCombatChallenge.tab" +local TABLE_SIMUCOMBAT_MEMBER = "Share/Fuben/SimulatedCombat/SimulatedCombatMember.tab" +local TABLE_SIMUCOMBAT_POINT_REWARD = "Share/Fuben/SimulatedCombat/SimulatedCombatPointReward.tab" +local TABLE_SIMUCOMBAT_STAGE = "Share/Fuben/SimulatedCombat/SimulatedCombatStage.tab" +local TABLE_SIMUCOMBAT_STAR_REWARD = "Share/Fuben/SimulatedCombat/SimulatedCombatStarReward.tab" + +local SimuCombatActivity = {} +local SimuCombatAddition = {} +local SimuCombatChallenge = {} +local SimuCombatMember = {} +local SimuCombatPointReward = {} +local SimuCombatStage = {} +local SimuCombatStarReward = {} +local SimuCombatStageIdToInterId = {} +local SimuCombatStageGroup = {} + +XFubenSimulatedCombatConfig.Color = { + NORMAL = XUiHelper.Hexcolor2Color("0F70BC"), + INSUFFICIENT = XUiHelper.Hexcolor2Color("C62310"), +} + +XFubenSimulatedCombatConfig.StageType = { + Normal = 1, --普通 + Challenge = 2, --挑战模式 +} + +XFubenSimulatedCombatConfig.ResType = { + Member = 1, + Addition = 2, +} + +XFubenSimulatedCombatConfig.TeamTemplate = { + ["CaptainPos"] = 1, + ["FirstFightPos"] = 1, + ["TeamData"] = {}, +} + +function XFubenSimulatedCombatConfig.Init() + SimuCombatActivity = XTableManager.ReadByIntKey(TABLE_SIMUCOMBAT_ACTIVITY, XTable.XTableSimulatedCombatActivity, "Id") + SimuCombatAddition = XTableManager.ReadByIntKey(TABLE_SIMUCOMBAT_ADDITION, XTable.XTableSimulatedCombatAddition, "Id") + SimuCombatChallenge = XTableManager.ReadByIntKey(TABLE_SIMUCOMBAT_CHALLENGE, XTable.XTableSimulatedCombatChallenge, "Id") + SimuCombatMember = XTableManager.ReadByIntKey(TABLE_SIMUCOMBAT_MEMBER, XTable.XTableSimulatedCombatMember, "Id") + SimuCombatPointReward = XTableManager.ReadByIntKey(TABLE_SIMUCOMBAT_POINT_REWARD, XTable.XTableSimulatedCombatPointReward, "Id") + SimuCombatStage = XTableManager.ReadByIntKey(TABLE_SIMUCOMBAT_STAGE, XTable.XTableSimulatedCombatStage, "Id") + SimuCombatStarReward = XTableManager.ReadByIntKey(TABLE_SIMUCOMBAT_STAR_REWARD, XTable.XTableSimulatedCombatStarReward, "Id") + for _, v in pairs(SimuCombatStage) do + SimuCombatStageIdToInterId[v.StageId] = v + if not SimuCombatStageGroup[v.Type] then + SimuCombatStageGroup[v.Type] = {} + end + table.insert(SimuCombatStageGroup[v.Type], v) + end + + for _, grp in pairs(SimuCombatStageGroup) do + table.sort(grp, function (a,b) + return a.Id < b.Id + end) + end + XFubenSimulatedCombatConfig.TeamTemplate = XReadOnlyTable.Create(XFubenSimulatedCombatConfig.TeamTemplate) +end + +function XFubenSimulatedCombatConfig.GetStageInterData(Id) + local template = SimuCombatStage[Id] + if not template then + XLog.ErrorTableDataNotFound("XFubenSimulatedCombatConfig.GetDataById", "SimulatedCombatActivity", SHARE_NEWCHAR_TEACH, "Id", tostring(id)) + return + end + return template +end + +function XFubenSimulatedCombatConfig.GetStageInterDataByType(type) + return SimuCombatStageGroup[type] +end + +function XFubenSimulatedCombatConfig.GetActTemplates() + return SimuCombatActivity +end + +function XFubenSimulatedCombatConfig.GetActivityTemplateById(Id) + return SimuCombatActivity[Id] +end + +function XFubenSimulatedCombatConfig.GetMemberById(Id) + return SimuCombatMember[Id] +end + +function XFubenSimulatedCombatConfig.GetAdditionById(Id) + return SimuCombatAddition[Id] +end + +function XFubenSimulatedCombatConfig.GetChallengeById(Id) + return SimuCombatChallenge[Id] +end + +function XFubenSimulatedCombatConfig.GetPointReward(Id) + return SimuCombatPointReward +end +function XFubenSimulatedCombatConfig.GetPointRewardById(Id) + return SimuCombatPointReward[Id] +end + +function XFubenSimulatedCombatConfig.GetStarReward(Id) + return SimuCombatStarReward +end +function XFubenSimulatedCombatConfig.GetStarRewardById(Id) + return SimuCombatStarReward[Id] +end + diff --git a/Resources/Scripts/XConfig/XFubenSpecialTrainConfig.lua b/Resources/Scripts/XConfig/XFubenSpecialTrainConfig.lua new file mode 100644 index 00000000..a1b8fdee --- /dev/null +++ b/Resources/Scripts/XConfig/XFubenSpecialTrainConfig.lua @@ -0,0 +1,149 @@ +XFubenSpecialTrainConfig = XFubenSpecialTrainConfig or {} + +local TABLE_SPECIALTRAIN_ACTIVITY = "Share/Fuben/SpecialTrain/Activity.tab" +local TABLE_SPECIALTRAIN_CHAPTER = "Share/Fuben/SpecialTrain/Chapter.tab" +local TABLE_SPECIALTRAIN_STARREWARD = "Share/Fuben/SpecialTrain/StarReward.tab" +local TABLE_SPECIALTRAIN_STAGE = "Share/Fuben/SpecialTrain/SpecialTrainStage.tab" +local TABLE_SPECIALTRAIN_POINTREWARD = "Share/Fuben/SpecialTrain/PointReward.tab" +--local TABLE_SUMMER_EPISODE_MAP_CONFIG = "Client/Fuben/SpecialTrain/SummerEpisodeMapConfig.tab" + +local StarRewardConfig +local ChapterConfig +local ActivityConfig +local SpecialTrainStageConfig +local SpecialPointRewardConfig +local SummerEpisodeMapConfig --夏活特训关 关卡选择界面的背景图片配置 + +XFubenSpecialTrainConfig.StageType = { + None = -1, + Normal = 0, + Broadsword = 1, + Alive = 2 +} + + + +function XFubenSpecialTrainConfig.Init() + StarRewardConfig = XTableManager.ReadByIntKey(TABLE_SPECIALTRAIN_STARREWARD, XTable.XTableSpecialTrainStarReward, "Id") + ChapterConfig = XTableManager.ReadByIntKey(TABLE_SPECIALTRAIN_CHAPTER, XTable.XTableSpecialTrainChapter, "Id") + ActivityConfig = XTableManager.ReadByIntKey(TABLE_SPECIALTRAIN_ACTIVITY, XTable.XTableSpecialTrainActivity, "Id") + SpecialTrainStageConfig = XTableManager.ReadByIntKey(TABLE_SPECIALTRAIN_STAGE, XTable.XTableSpecialTrainStage, "Id") + SpecialPointRewardConfig = XTableManager.ReadByIntKey(TABLE_SPECIALTRAIN_POINTREWARD, XTable.XTableSpecialTrainPointReward, "Id") + --SummerEpisodeMapConfig = XTableManager.ReadByIntKey(TABLE_SUMMER_EPISODE_MAP_CONFIG, XTable.XTableSummerEpisodeMapConfig, "Id") +end + +--获取活动数据 +function XFubenSpecialTrainConfig.GetActivityConfigById(id) + local retConfig + + --默认返回活动配置最后一行 + if not id then + for _, config in ipairs(ActivityConfig) do + retConfig = config + end + else + retConfig = ActivityConfig[id] + end + + if not retConfig then + XLog.ErrorTableDataNotFound("XFubenSpecialTrainConfig.GetActivityConfigById", + "ActivityConfig", TABLE_SPECIALTRAIN_ACTIVITY, "Id", tostring(id)) + return + end + + return retConfig +end + +--获取章节数据 +function XFubenSpecialTrainConfig.GetChapterConfigById(id) + if not ChapterConfig or not ChapterConfig[id] then + XLog.ErrorTableDataNotFound("XFubenSpecialTrainConfig.GetChapterConfigById", + "ChapterConfig", TABLE_SPECIALTRAIN_CHAPTER, "Id", tostring(id)) + return + end + + return ChapterConfig[id] +end + +--获取章节关卡数据 +function XFubenSpecialTrainConfig.GetSpecialTrainStageById(id) + if not SpecialTrainStageConfig or not SpecialTrainStageConfig[id] then + return + end + + return SpecialTrainStageConfig[id] +end + +--获取章节数据 +function XFubenSpecialTrainConfig.GetChapterConfig() + return ChapterConfig +end + +--获取星星奖励数据 +function XFubenSpecialTrainConfig.GetStarRewardConfigById(id) + if not StarRewardConfig or not StarRewardConfig[id] then + XLog.ErrorTableDataNotFound("XFubenSpecialTrainConfig.GetStarRewardConfigById", + "StarRewardConfig", TABLE_SPECIALTRAIN_STARREWARD, "Id", tostring(id)) + return + end + + return StarRewardConfig[id] +end + +--检测是否是特训关联机 +function XFubenSpecialTrainConfig.CheckIsSpecialTrainStage(stageId) + local config = XFubenSpecialTrainConfig.GetSpecialTrainStageById(stageId) + if not config then + return false + end + + if config.Type == XFubenSpecialTrainConfig.StageType.Broadsword then + return true + end + + if config.Type == XFubenSpecialTrainConfig.StageType.Alive then + return true + end + + return false +end + +--检测是否是特训关大刀联机 +function XFubenSpecialTrainConfig.CheckIsSpecialTrainBroadswordStage(stageId) + local config = XFubenSpecialTrainConfig.GetSpecialTrainStageById(stageId) + if not config then + return false + end + + if config.Type == XFubenSpecialTrainConfig.StageType.Broadsword then + return true + end + + return false +end + +function XFubenSpecialTrainConfig.GetSpecialPointRewardConfig(id) + if not SpecialPointRewardConfig or not SpecialPointRewardConfig[id] then + XLog.ErrorTableDataNotFound("XFubenSpecialTrainConfig.GetSpecialPointRewardConfig", + "GetSpecialPointRewardConfig", TABLE_SPECIALTRAIN_POINTREWARD, "Id", tostring(id)) + return + end + return SpecialPointRewardConfig[id] +end + +function XFubenSpecialTrainConfig.GetSummerEpisodeMapBg(stageId) + local config = SummerEpisodeMapConfig[stageId] + if not config then + XLog.Error("XFubenSpecialTrainConfig.GetSummerEpisodeMapBg ,配置不存在 stageId:", stageId) + return + end + return config.Bg +end + +function XFubenSpecialTrainConfig.GetSummerEpisodePictureList() + local list = {} + for _,config in pairs(SummerEpisodeMapConfig) do + table.insert(list,config.Picture) + end + return list +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XFubenUnionKillConfigs.lua b/Resources/Scripts/XConfig/XFubenUnionKillConfigs.lua new file mode 100644 index 00000000..d26ebb4f --- /dev/null +++ b/Resources/Scripts/XConfig/XFubenUnionKillConfigs.lua @@ -0,0 +1,286 @@ +XFubenUnionKillConfigs = {} + +local SHARE_UNION_ACTIVITY = "Share/Fuben/UnionKill/UnionKillActivity.tab" +local SHARE_UNION_EVENT_STAGE = "Share/Fuben/UnionKill/UnionKillEventStage.tab" +local SHARE_UNION_RANK_REWARD = "Share/Fuben/UnionKill/UnionKillRankReward.tab" +local SHARE_UNION_SCORE_RULE = "Share/Fuben/UnionKill/UnionKillScoreRule.tab" +local SHARE_UNION_SECTION = "Share/Fuben/UnionKill/UnionKillSection.tab" +local SHARE_UNION_WEATHER = "Share/Fuben/UnionKill/UnionKillWeather.tab" +local SHARE_UNION_RANK_LEVEL = "Share/Fuben/UnionKill/UnionKillRankLevel.tab" + + +local CLIENT_UNION_ACTIVITY = "Client/Fuben/UnionKill/UnionKillActivityDetails.tab" +local CLIENT_UNION_WEATHER = "Client/Fuben/UnionKill/UnionKillWeatherDetails.tab" +local CLIENT_UNION_SECTION = "Client/Fuben/UnionKill/UnionKillSectionDetails.tab" +local CLIENT_UNION_EVENT = "Client/Fuben/UnionKill/UnionKillEventDetails.tab" + +local UnionActivity = {} +local UnionEventStage = {} +local UnionRankReward = {} +local UnionScoreRule = {} +local UnionSection = {} +local UnionWeather = {} +local UnionRankLevel = {} + +local UnionActivityConfig = {} +local UnionWeatherConfig = {} +local UnionSectionConfig = {} +local UnionEventConfig = {} + + + +XFubenUnionKillConfigs.UnionRoomPlayerState = { + Normal = 0, --正常、未准备 + Ready = 1, --准备 + Select = 2, --编辑队伍 + Fight = 3 --战斗中 +} + +XFubenUnionKillConfigs.UnionRoomState = { + Normal = 0, + Fight = 1, -- 战斗 + Settle = 2, -- 结算 + Close = 3, -- 关闭 +} + +XFubenUnionKillConfigs.UnionKillStageType = { + EventStage = 1, -- 事件关 + BossStage = 2, -- boss关 + TrialStage = 3, -- 试炼关 +} +XFubenUnionKillConfigs.UnionKillCharType = { + Own = 1, -- 自己拥有标记 + Share = 2, -- 共享角色标记 +} +XFubenUnionKillConfigs.UnionRankType = { + ThumbsUp = 1, -- 点赞排名 + KillNumber = 2 -- 歼敌排名 +} +XFubenUnionKillConfigs.LeaveReason = { + LeaveTeam = 1, -- 离开队伍 + LeaveFight = 2, -- 离开战斗 + TimeOver = 3, -- 战斗事件结束 + KickOut = 4, -- 被踢 + Offline = 5, -- 离线 + Logout = 6, -- 登出 +} +XFubenUnionKillConfigs.TipsMessageType = { + Praise = 1, -- 点赞 + FightBrrow = 2, -- 我借用了玩家的xxx, + ResultBorrow = 3, -- 点赞 + LeaveStage = 4, -- 离开关卡 +} + +XFubenUnionKillConfigs.ActivityChangeType = { + None = 0, + ActivityOpen = 1, -- 活动开启 + ActivityClose = 2, -- 活动结束 + SectionChange = 3, -- 章节改变 + WeatherChange = 4, -- 天气改变 +} + +XFubenUnionKillConfigs.NotShowToday = "UnionKillTipsNotShowToday" +XFubenUnionKillConfigs.FirstShowHelp = "UnionKillTipsFirstShowHelp" + +XFubenUnionKillConfigs.MaxTeamCount = 4 -- 队伍人数 +XFubenUnionKillConfigs.MaxCharacterCount = 3 -- 出站人数 +XFubenUnionKillConfigs.PraiseInterval = CS.XGame.ClientConfig:GetInt("UnionPraiseInterval") -- 点赞界面倒计时 +XFubenUnionKillConfigs.RankRequestInterval = CS.XGame.ClientConfig:GetInt("UnionRankRequestInterval") -- 排名请求间隔 +XFubenUnionKillConfigs.AllReadyCount = CS.XGame.ClientConfig:GetInt("UnionAllReadyInterval") + +-- 测试用-以后改为读表 +XFubenUnionKillConfigs.PraiseWords = "UnionTipPraise" +-- 类型1, 0对应参数PlayerId, 1对应CharacterId +XFubenUnionKillConfigs.FightBorrowMine = "UnionTipsFightBorrow" +XFubenUnionKillConfigs.FightBorrowOthers = "UnionTipsBorrowOthers" +-- 类型2, playerId对应是谁说的话,ShareCharacterInfos对应用了哪个角色 +XFubenUnionKillConfigs.RefreshHighestPoint = "UnionTipHighestPoint" +-- 类型3, 0对应PlyaerId +local DefaultActivityId = 0 + +function XFubenUnionKillConfigs.Init() + UnionActivity = XTableManager.ReadByIntKey(SHARE_UNION_ACTIVITY, XTable.XTableUnionKillActivity, "Id") + UnionEventStage = XTableManager.ReadByIntKey(SHARE_UNION_EVENT_STAGE, XTable.XTableUnionKillEventStage, "Id") + UnionRankReward = XTableManager.ReadByIntKey(SHARE_UNION_RANK_REWARD, XTable.XTableUnionKillRankReward, "Id") + UnionScoreRule = XTableManager.ReadByIntKey(SHARE_UNION_SCORE_RULE, XTable.XTableUnionKillScoreRule, "Id") + UnionSection = XTableManager.ReadByIntKey(SHARE_UNION_SECTION, XTable.XTableUnionKillSection, "Id") + UnionWeather = XTableManager.ReadByIntKey(SHARE_UNION_WEATHER, XTable.XTableUnionKillWeather, "Id") + UnionRankLevel = XTableManager.ReadByIntKey(SHARE_UNION_RANK_LEVEL, XTable.XTableUnionKillRankLevel, "Id") + + UnionActivityConfig = XTableManager.ReadByIntKey(CLIENT_UNION_ACTIVITY, XTable.XTableUnionKillActivityDetails, "Id") + UnionWeatherConfig = XTableManager.ReadByIntKey(CLIENT_UNION_WEATHER, XTable.XTableUnionKillWeatherDetails, "Id") + UnionSectionConfig = XTableManager.ReadByIntKey(CLIENT_UNION_SECTION, XTable.XTableUnionKillSectionDetails, "Id") + UnionEventConfig = XTableManager.ReadByIntKey(CLIENT_UNION_EVENT, XTable.XTableUnionKillEventDetails, "Id") + + for activityId, config in pairs(UnionActivity) do + if XTool.IsNumberValid(config.TimeId) then + DefaultActivityId = activityId + break + end + DefaultActivityId = activityId--若全部过期,取最后一行配置作为默认下次开启的活动ID + end +end + +function XFubenUnionKillConfigs.GetUnionActivityById(id) + local activityTemplate = UnionActivity[id] + if not activityTemplate then + XLog.ErrorTableDataNotFound("XFubenUnionKillConfigs.GetUnionActivityById", "UnionKillActivity", SHARE_UNION_ACTIVITY, "Id", tostring(id)) + return + end + return activityTemplate +end + +function XFubenUnionKillConfigs.GetUnionActivityConfigById(id) + local activityConfig = UnionActivityConfig[id] + if not activityConfig then + XLog.ErrorTableDataNotFound("XFubenUnionKillConfigs.GetUnionActivityConfigById", + "UnionKillActivityDetails", CLIENT_UNION_ACTIVITY, "Id", tostring(id)) + return + end + return activityConfig +end + +function XFubenUnionKillConfigs.GetUnionEventStageById(id) + local eventStageTemplate = UnionEventStage[id] + if not eventStageTemplate then + XLog.ErrorTableDataNotFound("XFubenUnionKillConfigs.GetUnionEventStageById", + "UnionKillEventStage", SHARE_UNION_EVENT_STAGE, "Id", tostring(id)) + return + end + return eventStageTemplate +end + +function XFubenUnionKillConfigs.GetUnionEventConfigById(id) + local eventConfig = UnionEventConfig[id] + if not eventConfig then + XLog.ErrorTableDataNotFound("XFubenUnionKillConfigs.GetUnionEventConfigById", "UnionKillEventDetails", CLIENT_UNION_EVENT, "Id", tostring(id)) + return + end + return eventConfig +end + +function XFubenUnionKillConfigs.GetUnionRankRewardById(id) + local rankRewardTemplate = UnionRankReward[id] + if not rankRewardTemplate then + XLog.ErrorTableDataNotFound("XFubenUnionKillConfigs.GetUnionRankRewardById", + "UnionKillRankReward", SHARE_UNION_RANK_REWARD, "Id", tostring(id)) + return + end + return rankRewardTemplate +end + +function XFubenUnionKillConfigs.GetUnionRewardListByLevel(rankLevel) + local rankRewards = {} + for _, rankReward in pairs(UnionRankReward) do + if rankReward.LevelId == rankLevel then + table.insert(rankRewards, { + Id = rankReward.Id, + MinRank = rankReward.MinRank, + MaxRank = rankReward.MaxRank, + MailId = rankReward.MailId, + RankIcon = rankReward.RankIcon, + }) + end + end + + table.sort(rankRewards, function(rank1, rank2) + return rank1.MinRank < rank2.MinRank + end) + return rankRewards +end + +function XFubenUnionKillConfigs.GetUnionScoreRuleById(id) + local scoreRuleTemplate = UnionScoreRule[id] + if not scoreRuleTemplate then + XLog.ErrorTableDataNotFound("XFubenUnionKillConfigs.GetUnionScoreRuleById", "UnionKillScoreRule", SHARE_UNION_SCORE_RULE, "Id", tostring(id)) + return + end + return scoreRuleTemplate +end + +function XFubenUnionKillConfigs.GetUnionSectionById(id) + local sectionTemplate = UnionSection[id] + if not sectionTemplate then + XLog.ErrorTableDataNotFound("XFubenUnionKillConfigs.GetUnionSectionById", "UnionKillSection", SHARE_UNION_SECTION, "Id", tostring(id)) + return + end + return sectionTemplate +end + +function XFubenUnionKillConfigs.GetUnionSectionConfigById(id) + local sectionConfig = UnionSectionConfig[id] + if not sectionConfig then + XLog.ErrorTableDataNotFound("XFubenUnionKillConfigs.GetUnionSectionConfigById", + "UnionKillSectionDetails", CLIENT_UNION_SECTION, "Id", tostring(id)) + return + end + return sectionConfig +end + +function XFubenUnionKillConfigs.GetUnionWeatherById(id) + local weatherTemplate = UnionWeather[id] + if not weatherTemplate then + XLog.ErrorTableDataNotFound("XFubenUnionKillConfigs.GetUnionWeatherById", "UnionKillWeather", SHARE_UNION_WEATHER, "Id", tostring(id)) + return + end + return weatherTemplate +end + +function XFubenUnionKillConfigs.GetUnionWeatherConfigById(id) + local weatherConfig = UnionWeatherConfig[id] + if not weatherConfig then + XLog.ErrorTableDataNotFound("XFubenUnionKillConfigs.GetUnionWeatherConfigById", + "UnionKillWeatherDetails", CLIENT_UNION_WEATHER, "Id", tostring(id)) + return + end + return weatherConfig +end + +function XFubenUnionKillConfigs.GetUnionRankLevelById(id) + local levelTemplate = UnionRankLevel[id] + if not levelTemplate then + XLog.ErrorTableDataNotFound("XFubenUnionKillConfigs.GetUnionRankLevelById", "UnionKillRankLevel", SHARE_UNION_RANK_LEVEL, "Id", tostring(id)) + return + end + return levelTemplate +end + +function XFubenUnionKillConfigs.GetAllRankLevel() + return UnionRankLevel +end + +function XFubenUnionKillConfigs.GetUnionActivityTimes(activityId) + local activityTemplate = XFubenUnionKillConfigs.GetUnionActivityById(activityId) + if not activityTemplate then return nil, nil end + return XFunctionManager.GetTimeByTimeId(activityTemplate.TimeId) +end + +function XFubenUnionKillConfigs.GetUnionSectionTimes(sectionId) + local sectionTemplate = XFubenUnionKillConfigs.GetUnionSectionById(sectionId) + if not sectionTemplate then return nil, nil end + return XFunctionManager.GetTimeByTimeId(sectionTemplate.TimeId) +end + +-- 该玩法是否处于活动时间内 +function XFubenUnionKillConfigs.UnionKillInActivity(activityId) + local beginTime, EndTime = XFubenUnionKillConfigs.GetUnionActivityTimes(activityId) + return XFubenUnionKillConfigs.Between2Stamp(beginTime, EndTime) +end + +-- 每轮是否处于活动时间内 +function XFubenUnionKillConfigs.UnionKillInSectionTime(sectionId) + local beginTime, EndTime = XFubenUnionKillConfigs.GetUnionSectionTimes(sectionId) + return XFubenUnionKillConfigs.Between2Stamp(beginTime, EndTime) +end + +-- 是否在两个时间内 +function XFubenUnionKillConfigs.Between2Stamp(beginTime, endTime) + if not beginTime or not endTime then return false end + + local now = XTime.GetServerNowTimestamp() + return now >= beginTime and now <= endTime +end + +function XFubenUnionKillConfigs.GetUnionDefaultActivityId() + return DefaultActivityId +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XFubenUrgentEventConfig.lua b/Resources/Scripts/XConfig/XFubenUrgentEventConfig.lua new file mode 100644 index 00000000..c5a7a9fe --- /dev/null +++ b/Resources/Scripts/XConfig/XFubenUrgentEventConfig.lua @@ -0,0 +1,18 @@ +XFubenUrgentEventConfig = XFubenUrgentEventConfig or {} + +local UrgentEventCfg = {} + +local TABLE_URGENT_EVENT = "Share/Fuben/UrgentEvent/UrgentEvent.tab" + +function XFubenUrgentEventConfig.Init() + UrgentEventCfg = XTableManager.ReadByIntKey(TABLE_URGENT_EVENT, XTable.XTableUrgentEvent, "Id") +end +function XFubenUrgentEventConfig.GetUrgentEventCfg() + return UrgentEventCfg +end + +function XFubenUrgentEventConfig.GetUrgentEventCfgById(urgentId) + if UrgentEventCfg[urgentId] then + return UrgentEventCfg[urgentId] + end +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XFubenZhouMuConfigs.lua b/Resources/Scripts/XConfig/XFubenZhouMuConfigs.lua new file mode 100644 index 00000000..55b6eb2a --- /dev/null +++ b/Resources/Scripts/XConfig/XFubenZhouMuConfigs.lua @@ -0,0 +1,127 @@ + --- 一个主线或外篇章节对应一个周目(ZhouMuId),把周目(ZhouMuId)当成一个模式,第几周目对应周目的第几个周目章节(ZhouMuChapterId) + +XFubenZhouMuConfigs = XFubenZhouMuConfigs or {} + +local TABLE_ZHOUMU = "Share/Fuben/ZhouMu/ZhouMu.tab" +local TABLE_ZHOUMU_CHAPTER = "Share/Fuben/ZhouMu/ZhouMuChapter.tab" + +local ZhouMuCfg = {} +local ZhouMuChapterCfg = {} + +-- 播放周目弹窗动画的类型 +XFubenZhouMuConfigs.EnumZhouMuTipAnima = { + None = 1, -- 无动画 + PlayStart = 2, -- 周目开始 + PlayEndStart = 3, -- 先播放周目结束,然后再播放周目开启 + PlayEnd = 4, -- 周目结束 +} + +function XFubenZhouMuConfigs.Init() + ZhouMuCfg = XTableManager.ReadByIntKey(TABLE_ZHOUMU, XTable.XTableZhouMu, "Id") + ZhouMuChapterCfg = XTableManager.ReadByIntKey(TABLE_ZHOUMU_CHAPTER, XTable.XTableZhouMuChapter, "Id") +end + +------------------------------------------------------------------ ZhouMu.tab数据读取 ------------------------------------------------------- + +--- +--- 根据'zhouMuId'获取多周目章节配置 +---@param zhouMuChapterId number +---@return table +function XFubenZhouMuConfigs.GetZhouMuCfg(zhouMuId) + local config = ZhouMuCfg[zhouMuId] + + if not config then + XLog.ErrorTableDataNotFound("XFubenZhouMuConfigs.GetZhouMuCfg", + "多周目章节配置", TABLE_ZHOUMU, "Id", tostring(zhouMuId)) + return {} + end + + return config +end + +--- +--- 根据'zhouMuId'获取周目章节Id数组 +---@param zhouMuId number +---@return table +function XFubenZhouMuConfigs.GetZhouMuChapters(zhouMuId) + local config = XFubenZhouMuConfigs.GetZhouMuCfg(zhouMuId) + return config.ChapterId or {} +end + +--- +--- 根据'zhouMuId'获取周目挑战任务Id数组 +---@param zhouMuId number +---@return table +function XFubenZhouMuConfigs.GetZhouMuTasks(zhouMuId) + local config = XFubenZhouMuConfigs.GetZhouMuCfg(zhouMuId) + return config.TaskId or {} +end + +--- +--- 根据'zhouMuId'获取最后一个周目章节Id +---@param zhouMuId number +---@return number +function XFubenZhouMuConfigs.GetZhouMuLastChapter(zhouMuId) + local zhouMuChapters = XFubenZhouMuConfigs.GetZhouMuChapters(zhouMuId) + return zhouMuChapters[#zhouMuChapters] +end + + +------------------------------------------------------------------ ZhouMuChapter.tab数据读取 ------------------------------------------------------- + + --- + --- 获取整个ZhouMuChapter配表数据 + ---@return table + function XFubenZhouMuConfigs.GetAllZhouMuChapterCfg() + return ZhouMuChapterCfg + end + +--- +--- 根据'zhouMuChapterId'获取周目章节配置 +---@param zhouMuChapterId number +---@return table +function XFubenZhouMuConfigs.GetZhouMuChapterCfg(zhouMuChapterId) + local config = ZhouMuChapterCfg[zhouMuChapterId] + + if not config then + XLog.ErrorTableDataNotFound("XFubenZhouMuConfigs.GetZhouMuChapterCfg", + "多周目章节配置", TABLE_ZHOUMU_CHAPTER, "Id", tostring(zhouMuChapterId)) + return {} + end + + return config +end + +--- +--- 根据'zhouMuChapterId'获取周目章节的解锁条件数组 +---@param zhouMuChapterId number +---@return table +function XFubenZhouMuConfigs.GetZhouMuChapterCondition(zhouMuChapterId) + local config = XFubenZhouMuConfigs.GetZhouMuChapterCfg(zhouMuChapterId) + return config.ConditionId or {} +end + +--- +--- 根据'zhouMuChapterId'获取周目章节的关卡数组 +---@param zhouMuChapterId number +---@return table +function XFubenZhouMuConfigs.GetZhouMuChapterStages(zhouMuChapterId) + local config = XFubenZhouMuConfigs.GetZhouMuChapterCfg(zhouMuChapterId) + + if config.StageId == nil or #config.StageId == 0 then + XLog.ErrorTableDataNotFound("XFubenZhouMuConfigs.GetZhouMuChapterStages", + "多周目章节关卡", TABLE_ZHOUMU_CHAPTER, "Id", tostring(zhouMuChapterId)) + return {} + end + + return config.StageId +end + +--- +--- 根据'zhouMuChapterId'获取周目章节最后一个关卡Id +---@param zhouMuChapterId number +---@return number +function XFubenZhouMuConfigs.GetZhouMuChapterLastStage(zhouMuChapterId) + local stages = XFubenZhouMuConfigs.GetZhouMuChapterStages(zhouMuChapterId) + return stages[#stages] +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XFunctionConfig.lua b/Resources/Scripts/XConfig/XFunctionConfig.lua new file mode 100644 index 00000000..a1a06d7c --- /dev/null +++ b/Resources/Scripts/XConfig/XFunctionConfig.lua @@ -0,0 +1,225 @@ +XFunctionConfig = XFunctionConfig or {} + +local tableInsert = table.insert +--XFunctionManager.OpenCondition = { +-- Default = 0, -- 默认 +-- TeamLevel = 1, -- 战队等级 +-- FinishSection = 2, -- 通关副本 +-- FinishTask = 3, -- 完成任务 +-- FinishNoob = 4, -- 完成新手 +-- Main = 5, -- 掉线返回主界面 +--} + +-- XFunctionManager.OpenHint = { +-- TeamLevelToOpen, +-- CopyToOpen, +-- FinishToOpen +-- } + +local FunctionalOpenTemplates = {} --功能开启表 +local SecondaryFunctionalTemplates = {} --二级功能配置 +local SkipFunctionalTemplates = {} --跳转功能表 +-- local MainAdTemplates = {} --广告栏 +local MainActivitySkipTemplates = {} --活动便捷入口 +local ShieldFuncTemplates = {} -- 功能对应的界面名称 +local OpenList = {} + +local SHARE_FUNCTIONAL_OPEN = "Share/Functional/FunctionalOpen.tab" +local TABLE_SECONDARY_FUNCTIONAL_PATH = "Client/Functional/SecondaryFunctional.tab" +local TABLE_SKIP_FUNCTIONAL_PATH = "Client/Functional/SkipFunctional.tab" +--local TABLE_MAIN_AD = "Client/Functional/MainAd.tab" +local TABLE_MAIN_ACTIVITY_SKIP_PATH = "Client/Functional/MainActivitySkip.tab" +local TABLE_SHIELD_FUNC_PATH = "Client/Functional/ShieldFuncList.tab" + +function XFunctionConfig.Init() + FunctionalOpenTemplates = {} + OpenList = {} + SecondaryFunctionalTemplates = XTableManager.ReadByIntKey(TABLE_SECONDARY_FUNCTIONAL_PATH, XTable.XTableSecondaryFunctional, "Id") + SkipFunctionalTemplates = XTableManager.ReadByIntKey(TABLE_SKIP_FUNCTIONAL_PATH, XTable.XTableSkipFunctional, "SkipId") + MainActivitySkipTemplates = XTableManager.ReadByIntKey(TABLE_MAIN_ACTIVITY_SKIP_PATH, XTable.XTableMainActivitySkip, "Id") + ShieldFuncTemplates = XTableManager.ReadByIntKey(TABLE_SHIELD_FUNC_PATH, XTable.XTableShieldFunc, "Id") + + local listOpenFunctional = XTableManager.ReadByIntKey(SHARE_FUNCTIONAL_OPEN, XTable.XTableFunctionalOpen, "Id") + for k, v in pairs(listOpenFunctional) do + -- Check IsHasCondition + for _, id in pairs(v.Condition) do + if id ~= 0 then + FunctionalOpenTemplates[k] = v + tableInsert(OpenList, k) + break + end + end + end + + table.sort(OpenList, function(a, b) + if FunctionalOpenTemplates[a].Priority ~= FunctionalOpenTemplates[b].Priority then + return FunctionalOpenTemplates[a].Priority < FunctionalOpenTemplates[b].Priority + end + end) + OpenList = XReadOnlyTable.Create(OpenList) + + --local mainAdTemplates = XTableManager.ReadByIntKey(TABLE_MAIN_AD, XTable.XTableMainAd, "Id") + --for _, v in pairs(mainAdTemplates) do + -- if not MainAdTemplates[v.ChannelId] then + -- MainAdTemplates[v.ChannelId] = {} + -- end + -- + -- tableInsert(MainAdTemplates[v.ChannelId], v) + --end + --MainAdTemplates = XReadOnlyTable.Create(MainAdTemplates) +end + +function XFunctionConfig.GetFuncOpenCfg(id) + return FunctionalOpenTemplates[id] +end + +function XFunctionConfig.GetSkipFuncCfg(id) + return SkipFunctionalTemplates[id] +end + +function XFunctionConfig.GetMainActSkipCfg(id) + return MainActivitySkipTemplates[id] +end + +function XFunctionConfig.GetShieldFuncUiName(id) + if ShieldFuncTemplates[id] then + return ShieldFuncTemplates[id].UiName + else + return {} + end +end + +function XFunctionConfig.GetOpenList() + return OpenList +end + +function XFunctionConfig.GetSecondaryFunctionalList() + local list = {} + for _, v in pairs(SecondaryFunctionalTemplates) do + tableInsert(list, v) + end + --排序优先级 + tableSort(list, function(a, b) + if a.Priority ~= b.Priority then + return a.Priority < b.Priority + end + end) + return list +end + +function XFunctionConfig.GetSkipList(id) + return SkipFunctionalTemplates[id] +end + + +--function XFunctionConfig.GetUiName(id) +-- local uiName = SkipFunctionalTemplates[id].UiName +-- if uiName == nil then +-- XLog.Error("XFunctionConfig.GetUiName error: can not found UiName, id = " .. id) +-- end +-- return uiName +--end + +function XFunctionConfig.GetExplain(id) + local explain = SkipFunctionalTemplates[id].Explain + if explain == nil then + XLog.Error("XFunctionConfig.GetExplain error: can not found Explain, id = " .. id) + end + return explain +end + +function XFunctionConfig.GetParamId(id) + local paramId = SkipFunctionalTemplates[id].ParamId + if paramId == nil then + XLog.Error("XFunctionConfig.GetParamId error: can not found ParamId, id = " .. id) + end + return paramId +end + +function XFunctionConfig.GetIsShowExplain(id) + local isShowExplain = SkipFunctionalTemplates[id].IsShowExplain + if isShowExplain == nil then + XLog.Error("XFunctionConfig.GetIsShowExplain error: can not found isShowExplain, id = " .. id) + end + return isShowExplain +end + +--获取功能开启提醒方式 +function XFunctionConfig.GetOpenHint(id) + return FunctionalOpenTemplates[id].Hint +end + +--获取功能名字 +function XFunctionConfig.GetFunctionalName(id) + return FunctionalOpenTemplates[id].Name +end + +--获取功能类型 +function XFunctionConfig.GetFunctionalType(id) + return FunctionalOpenTemplates[id].Type +end + +--获取npc名字 +--function XFunctionConfig.GetNpcName(id) +-- return FunctionalOpenTemplates[id].NpcName +--end + +--获取npc头像 +--function XFunctionConfig.GetNpcHandIcon(id) +-- return FunctionalOpenTemplates[id].NpcHandIcon +--end + +--获取npc半身像 +--function XFunctionConfig.GetNpcHalfIcon(id) +-- return FunctionalOpenTemplates[id].NpcHalfIcon +--end + +--function XFunctionConfig.GetSkipToActivityIcon() +-- return MainActivitySkipTemplates[1].Icon +--end + +--function XFunctionManager.HandlerUiOpen(show, uiName) +-- if show then +-- if uiName ~= "UiHud" and uiName ~= "UiLogin" then +-- XFunctionManager.CheckOpen() +-- end +-- end +--end + +--功能开启 +--function XFunctionManager.GetFunctionOpenList(id) +-- --获取表 +-- local openList = FunctionalOpenTemplates[id] +-- if openList == nil then +-- return +-- end +-- return openList +--end + +-- 获取广告图列表 +--function XFunctionManager.GetMainAdList() +-- local channelId = 0 +-- +-- if XUserManager.Channel == XUserManager.CHANNEL.HERO then +-- channelId = CS.XHeroSdkAgent.GetChannelId() +-- end +-- +-- local list = {} +-- local templates = MainAdTemplates[channelId] +-- +-- if not templates then +-- templates = MainAdTemplates[0] +-- end +-- +-- for _, v in pairs(templates) do +-- tableInsert(list, v) +-- end +-- +-- tableSort(list, function(a, b) +-- if a.Priority ~= b.Priority then +-- return a.Priority < b.Priority +-- end +-- end) +-- +-- return list +--end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XFurnitureConfigs.lua b/Resources/Scripts/XConfig/XFurnitureConfigs.lua new file mode 100644 index 00000000..60334fc3 --- /dev/null +++ b/Resources/Scripts/XConfig/XFurnitureConfigs.lua @@ -0,0 +1,1217 @@ +XFurnitureConfigs = XFurnitureConfigs or {} + +--家具交互点被使用情况 +XFurnitureInteractUsedType = { + None = 1, --空,未被占用 + Character = 2, --被构造体占用 + Block = 4, --交互点被阻挡,无法使用 +} + +XFurnitureConfigs.FURNITURE_CATEGORY_ALL_ID = 0 +XFurnitureConfigs.MAX_FURNITURE_ATTR_LEVEL = 5 +XFurnitureConfigs.FURNITURE_SUIT_CATEGORY_ALL_ID = 1 + +XFurnitureConfigs.GainType = { + Create = 1, + Refit = 2 +} + +XFurnitureConfigs.XFurnitureAdditionType = { + Mood = 0, + Vitality = 1, + AttrA = 2, + AttrB = 3, + AttrC = 4, + AttrAPercent = 5, + AttrBPercent = 6, + AttrCPercent = 7, + AttrTotal = 8, + AttrTotalPercent = 9, + Count = 10 +} + +-- 家具摆放类型 +XFurniturePlaceType = { + Ground = 1, -- 地板 + Wall = 2, -- 墙 + Ceiling = 3, -- 天花板 + OnGround = 4, -- 摆放在地板上 + OnWall = 5, -- 摆放在墙上 +} + +-- 家具类型 +XFurnitureConfigs.HomeSurfaceBaseType = { + Ground = 25001, --地板 + Wall = 25002, --墙 + Ceiling = 25003, --天花板 +} + +-- 家具Attr类型 +XFurnitureConfigs.AttrType = { + AttrA = 1, --美观(红) + AttrB = 2, --舒适(黄) + AttrC = 3, --实用(蓝) + AttrAll = 4, --总值 +} + +-- 家具操作状态 +XFurnitureConfigs.FURNITURE_STATE = { + RECYCLE = 1, -- 回收状态 + DETAILS = 2, -- 查看详情状态 + SELECT = 3, -- 选择家具或者图纸状态 + SELECTSINGLE = 4 --家具单选状态 +} + +--- 家具摆放类型 +XFurnitureConfigs.HomeLocateType = { + Replace = 0, --直接替换 + LocateGround = 1, --摆放在地板上 + LocateWall = 2, --悬挂墙上 +} + +--- 增减 +XFurnitureConfigs.FurnitureOperate = { + Delete = 0, --增加 + Add = 1, --减少 +} + +--- 家具点击播放动画类型 +XFurnitureConfigs.FurnitureAnimationType = { + None = 0, -- 不播放 + Once = 1, -- 点击播放一次 + Repeat = 2, -- 连续播放动画 +} + +--- 家具额外属性 +XFurnitureConfigs.FurnitureAdditionType = { + Mood = 0, + Vitality = 1, + AttrTotal = 2, + AttrTotalPercent = 3, + Count = 4, +} + +XFurnitureConfigs.HomePlatType = { + Ground = 0, -- 地板 + Wall = 1, -- 墙 +} + +--排序优先级选项 +XFurnitureConfigs.PriorSortType = { + All = 0, -- 全选 + Unuse = 1, -- 未使用 + Use = 2, -- 使用中 +} + +--排序优先级选项 +XFurnitureConfigs.MajorType = { + Refit = 1, -- 改造 + Frunitue = 2, -- 家具 +} + +--家具位置交换类型 +XFurnitureConfigs.PosChangeType = { + None = 0, -- 不能交换 + Red = 1, -- 红方 + Black = 2, -- 黑方 + White = 3, -- 白方 + Greed = 4, -- 绿方 + Purple = 5, -- 紫方 + Gold = 6, -- 金方 +} + + +-- 属性分级颜色 +XFurnitureConfigs.FurnitureAttrColor = { + [1] = CS.XTextManager.GetText("FurnitureColorC"), + [2] = CS.XTextManager.GetText("FurnitureColorC"), + [3] = CS.XTextManager.GetText("FurnitureColorB"), + [4] = CS.XTextManager.GetText("FurnitureColorA"), + [5] = CS.XTextManager.GetText("FurnitureColorS"), +} + + +-- 属性标签分级颜色 +XFurnitureConfigs.FurnitureAttrTagColor = { + [1] = "#62DE4AFF", + [2] = "#62DE4AFF", + [3] = "#34AFF8FF", + [4] = "#D07EFFFF", + [5] = "#FFB400FF", +} + +XFurnitureConfigs.FurnitureAttrLevel = { + [1] = CS.XTextManager.GetText("FurnitureQualityC"), + [2] = CS.XTextManager.GetText("FurnitureQualityC"), + [3] = CS.XTextManager.GetText("FurnitureQualityB"), + [4] = CS.XTextManager.GetText("FurnitureQualityA"), + [5] = CS.XTextManager.GetText("FurnitureQualityS"), +} + +local CLIENT_FURNITURE_SUIT = "Client/Hostel/FurnitureSuit.tab" +local CLIENT_FURNITURE_VIEWANGLE = "Client/Hostel/FurnitureViewAngle.tab" +local CLIENT_FURNITURE_COLOUR = "Client/Hostel/FurnitureColour.tab" +local TABLE_DORM_FURNITURE_TYPE_PATH = "Client/Dormitory/DormFurnitureType.tab" +local TABLE_DORM_FURNITURE_TAG_TYPE_PATH = "Client/Dormitory/DormFurnitureTagType.tab" +local TABLE_DORM_FURNITURE_SINGLE_LEVEL_PATH = "Client/Dormitory/FurnitureSingleAttrLevel.tab" + +local TABLE_DORM_FURNITURE_ANIMATION_PATH = "Client/Dormitory/DormFurnitureAnimation.tab" + +local SHARE_FURNITURE = "Share/Dormitory/Furniture/Furniture.tab" +local SHARE_FURNITURE_LEVEL = "Share/Dormitory/Furniture/FurnitureLevel.tab" +local SHARE_FURNITURE_TYPE = "Share/Dormitory/Furniture/FurnitureType.tab" +local SHARE_FURNITURE_ADDITIONALATTR = "Share/Dormitory/Furniture/FurnitureAdditionalAttr.tab" +local SHARE_FURNITURE_FURNITURE_CREATEATTR = "Share/Dormitory/Furniture/FurnitureCreateAttr.tab" +local SHARE_FURNITURE_FURNITURE_BASE_ATTR = "Share/Dormitory/Furniture/FurnitureBaseAttr.tab" +local SHARE_FURNITURE_FURNITURE_EXTRA_ATTR = "Share/Dormitory/Furniture/FurnitureExtraAttr.tab" +local SHARE_FURNTIURE_REWARD = "Share/Dormitory/Furniture/FurnitureReward.tab" +local SHARE_FURNTIURE_BEHAVIOR = "Share/Dormitory/Furniture/FurnitureBehavior.tab" +local SHARE_FURNITURE_PUT_NUM = "Share/Dormitory/Furniture/FurniturePutNum.tab" + +local FurnitureSuitTemplates = {} +local FurnitureViewAngle = {} +local FurnitureColour = {} + +local FurnitureTemplates = {} +local FurnitureMinorDatas = {} --{Minor, {Category, {suitId, cfgs}}} +local FurnitureSuitDatas = {} --{suitId, cfgs} +local FurnitureLevelTemplates = {} +local FurnitureTypeTemplates = {} +local FurnitureTagTypeTemplates = {} +local FurnitureAdditionalAttr = {} +local FurnitureCreateAttr = {} +local FurnitureBaseAttrTemplate = {} +local FurnitureExtraAttrTemplate = {} +local FurnitureTypeList = {} +local FurnitureTypeGroupList = {} +local FurnitureRewardTemplate = {} +local FurnitureBehaviorTemplate = {} +local FurniturePutNumTemplates = {} + +local FurnitureSingleAttrLevelTemplate = {} +local FurnitureSingleAttrLevelIndex = {} + +local FurnitureToDrawingMap = {}--家具改装所需的图纸 +local DrawingToFurnitureMap = {}--图纸能改装的家具 +local DrawingPicMap = {} +local DormFurnitureTypeTemplate = {} -- 家具喜好度类型配置表 +local DormFurnitureTypeAttsDic = {} -- 家具属性 +local DormFurnitureAnimation = {} -- 家具动画配置表 + +XFurnitureConfigs.Incresment = CS.XGame.ClientConfig:GetInt("FurnitureInvestmentIncreaseStep") +XFurnitureConfigs.DefaultIcon = CS.XGame.ClientConfig:GetString("FurnitureDefaultIcon") +XFurnitureConfigs.DefaultName = CS.XGame.ClientConfig:GetString("FurnitureDefaultName") +XFurnitureConfigs.MaxCreateCount = CS.XGame.Config:GetInt("DormMaxCreateCount") +XFurnitureConfigs.MaxPutFurnitureCount = CS.XGame.Config:GetInt("DormMaxPutFurnitureCount") + +local function InitFurnitureTypeConfig() + local map = {} + for _, cfg in pairs(FurnitureTypeTemplates) do + local newId = cfg.MajorType * 100 + cfg.MinorType + + local data = map[newId] + if not data then + data = {} + data.MinorType = cfg.MinorType + data.MinorName = cfg.MinorName + data.CategoryMap = {} + map[newId] = data + end + + local category = {} + category.Category = cfg.Category + category.CategoryName = cfg.CategoryName + + data.CategoryMap[category.Category] = category + end + + for _, data in pairs(map) do + data.CategoryList = {} + + for _, v in pairs(data.CategoryMap) do + table.insert(data.CategoryList, v) + end + + data.CategoryMap = nil + if #data.CategoryList < 2 then + data.CategoryList = {} + else + local category = {} + category.Category = 0 + category.CategoryName = CS.XTextManager.GetText("FurnitureWholeText") + table.insert(data.CategoryList, 1, category) + end + + FurnitureTypeList[data.MinorType] = data + end +end + +local function InitFurnitureTypeGroupConfig() + local map = {} + for _, cfg in pairs(FurnitureTypeTemplates) do + local newId = cfg.MajorType * 100 + cfg.MinorType + + local data = map[newId] + if not data then + data = {} + data.MinorType = cfg.MinorType + data.MinorName = cfg.MinorName + data.CategoryMap = {} + map[newId] = data + end + + local category = {} + category.Category = cfg.Category + category.CategoryName = cfg.CategoryName + + data.CategoryMap[category.Category] = category + end + + for _, data in pairs(map) do + data.CategoryList = {} + + for _, v in pairs(data.CategoryMap) do + table.insert(data.CategoryList, v) + end + + data.CategoryMap = nil + if #data.CategoryList > 1 then + local category = {} + category.Category = 0 + category.CategoryName = CS.XTextManager.GetText("FurnitureWholeText") + table.insert(data.CategoryList, 1, category) + end + + table.insert(FurnitureTypeGroupList, data) + end +end + +local function InitFurnitureLevelConfigs(configs) + for _, config in pairs(configs) do + if not FurnitureLevelTemplates[config.FurnitureType] then + FurnitureLevelTemplates[config.FurnitureType] = {} + end + table.insert(FurnitureLevelTemplates[config.FurnitureType], config) + end +end + + +local function InitFurnitureSingleAttrLevelConfigs(configs) + for _, config in pairs(configs) do + if not FurnitureSingleAttrLevelIndex[config.FurnitureType] then + FurnitureSingleAttrLevelIndex[config.FurnitureType] = {} + end + table.insert(FurnitureSingleAttrLevelIndex[config.FurnitureType], config) + end +end + +local function InitFurnitureMinorTemplates(config) + local typeConfig = FurnitureTypeTemplates[config.TypeId] + if not typeConfig then + XLog.ErrorTableDataNotFound("XFurnitureConfigs.InitFurnitureMinorTemplates", + "FurnitureType", SHARE_FURNITURE_TYPE, "Id", tostring(config.TypeId)) + return + end + + if not FurnitureMinorDatas[typeConfig.MinorType] then + FurnitureMinorDatas[typeConfig.MinorType] = {} + end + + if not FurnitureMinorDatas[typeConfig.MinorType][typeConfig.Category] then + FurnitureMinorDatas[typeConfig.MinorType][typeConfig.Category] = {} + end + + if not FurnitureMinorDatas[typeConfig.MinorType][typeConfig.Category] then + FurnitureMinorDatas[typeConfig.MinorType][typeConfig.Category] = {} + end + + if not FurnitureMinorDatas[typeConfig.MinorType][typeConfig.Category][config.SuitId] then + FurnitureMinorDatas[typeConfig.MinorType][typeConfig.Category][config.SuitId] = {} + end + + table.insert(FurnitureMinorDatas[typeConfig.MinorType][typeConfig.Category][config.SuitId], config.Id) +end + +local function InitFurnitureBehaviorTemplates(configs) + for _, v in pairs(configs) do + FurnitureBehaviorTemplate[v.FurnitureId] = FurnitureBehaviorTemplate[v.FurnitureId] or {} + FurnitureBehaviorTemplate[v.FurnitureId][v.State] = v + end +end + +function XFurnitureConfigs.Init() + FurnitureSuitTemplates = XTableManager.ReadByIntKey(CLIENT_FURNITURE_SUIT, XTable.XTableFurnitureSuit, "Id") + FurnitureViewAngle = XTableManager.ReadByIntKey(CLIENT_FURNITURE_VIEWANGLE, XTable.XTableFurnitureViewAngle, "MinorType") + FurnitureColour = XTableManager.ReadByIntKey(CLIENT_FURNITURE_COLOUR, XTable.XTableFurntiureColour, "Id") + FurnitureTemplates = XTableManager.ReadByIntKey(SHARE_FURNITURE, XTable.XTableFurniture, "Id") + FurnitureTypeTemplates = XTableManager.ReadByIntKey(SHARE_FURNITURE_TYPE, XTable.XTableFurnitureType, "Id") + FurniturePutNumTemplates = XTableManager.ReadByIntKey(SHARE_FURNITURE_PUT_NUM, XTable.XTableFurniturePutNum, "PutId") + local typeCount = XFurnitureConfigs.GetFurnitureTemplateTypeCount() + if XFurnitureConfigs.MaxCreateCount < XFurnitureConfigs.GetFurnitureTemplateTypeCount() then + local tmpStr = "XFurnitureConfigs.Init error: DormMaxCreateCount is less than FurnitureType count, DormMaxCreateCount is " + XLog.Error(tmpStr .. tostring(XFurnitureConfigs.MaxCreateCount) .. ",DormMaxCreateCount is " .. tostring(typeCount)) + return + end + + FurnitureTagTypeTemplates = XTableManager.ReadByIntKey(TABLE_DORM_FURNITURE_TAG_TYPE_PATH, XTable.XTableDormFurnitureTagType, "Id") + FurnitureSingleAttrLevelTemplate = XTableManager.ReadByIntKey(TABLE_DORM_FURNITURE_SINGLE_LEVEL_PATH, XTable.XTableFurnitureSingleAttrLevel, "Id") + + FurnitureAdditionalAttr = XTableManager.ReadByIntKey(SHARE_FURNITURE_ADDITIONALATTR, XTable.XTableFurnitureAdditionalAttr, "AttributeId") + FurnitureCreateAttr = XTableManager.ReadByIntKey(SHARE_FURNITURE_FURNITURE_CREATEATTR, XTable.XTableFurnitureCreateAttr, "Id") + FurnitureBaseAttrTemplate = XTableManager.ReadByIntKey(SHARE_FURNITURE_FURNITURE_BASE_ATTR, XTable.XTableFurnitureBaseAttr, "Id") + FurnitureExtraAttrTemplate = XTableManager.ReadByIntKey(SHARE_FURNITURE_FURNITURE_EXTRA_ATTR, XTable.XTableFurnitureExtraAttr, "Id") + FurnitureRewardTemplate = XTableManager.ReadByIntKey(SHARE_FURNTIURE_REWARD, XTable.XTableFurnitureReward, "Id") + DormFurnitureTypeTemplate = XTableManager.ReadByIntKey(TABLE_DORM_FURNITURE_TYPE_PATH, XTable.XTableDormFurnitureType, "Id") + DormFurnitureAnimation = XTableManager.ReadByIntKey(TABLE_DORM_FURNITURE_ANIMATION_PATH, XTable.XTableDormFunitureAnimation, "Id") + local furnitureLevelTemplates = XTableManager.ReadByIntKey(SHARE_FURNITURE_LEVEL, XTable.XTableFurnitureLevel, "Id") + local furnitureBehaviorTemplate = XTableManager.ReadByIntKey(SHARE_FURNTIURE_BEHAVIOR, XTable.XTableFurnitureBehavior, "Id") + + InitFurnitureTypeConfig() + InitFurnitureTypeGroupConfig() + InitFurnitureLevelConfigs(furnitureLevelTemplates) + InitFurnitureSingleAttrLevelConfigs(FurnitureSingleAttrLevelTemplate) + InitFurnitureBehaviorTemplates(furnitureBehaviorTemplate) + + -- 改装功能家具映射 and 家具分类 + for k, v in pairs(FurnitureTemplates) do + if v.PicId ~= nil and v.PicId > 0 then + FurnitureToDrawingMap[k] = v.PicId + DrawingToFurnitureMap[v.PicId] = k + + if DrawingPicMap[v.TypeId] == nil then + DrawingPicMap[v.TypeId] = {} + end + table.insert(DrawingPicMap[v.TypeId], { + FurnitureId = v.Id, + TypeId = v.TypeId, + PicId = v.PicId, + GainType = v.GainType + }) + end + + local isAllSuit = XFurnitureConfigs.IsAllSuit(v.SuitId) + local id = isAllSuit and 0 or v.SuitId + if not FurnitureSuitDatas[id] then + FurnitureSuitDatas[id] = 0 + end + + if not FurnitureSuitDatas[0] then + FurnitureSuitDatas[0] = 0 + end + + if id ~= 0 then + FurnitureSuitDatas[0] = FurnitureSuitDatas[0] + 1 + end + + FurnitureSuitDatas[id] = FurnitureSuitDatas[id] + 1 + + if v.SuitId ~= 0 then + InitFurnitureMinorTemplates(v) + end + end +end + +-- 获取家具额外属性加成配置分数 +function XFurnitureConfigs.GetAdditionalAddScore(id) + local currentAttr = FurnitureAdditionalAttr[id] + + if not currentAttr then + XLog.ErrorTableDataNotFound("XFurnitureConfigs.GetAdditionalAddScore", + "FurnitureAdditionalAttr", SHARE_FURNITURE_ADDITIONALATTR, "Id", tostring(id)) + return 0 + end + + return currentAttr.AddScore or 0 +end + +-- 获取家具额外属性加成配置表 +function XFurnitureConfigs.GetAdditonAttrConfigById(id) + local t = FurnitureAdditionalAttr[id] + if not t then + XLog.ErrorTableDataNotFound("XFurnitureConfigs.GetAdditonAttrConfigById", + "FurnitureAdditionalAttr", SHARE_FURNITURE_ADDITIONALATTR, "Id", tostring(id)) + return nil + end + + return t +end + +-- 获取喜好度类型配置表 +function XFurnitureConfigs.GetDormFurnitureType(id) + local t = DormFurnitureTypeTemplate[id] + if not t then + XLog.ErrorTableDataNotFound("XFurnitureConfigs.GetDormFurnitureType", "DormFurnitureType", TABLE_DORM_FURNITURE_TYPE_PATH, "Id", tostring(id)) + return nil + end + + return t +end + +-- 获取家具动画配置表 +function XFurnitureConfigs.GetDormFurnitureAnimation(id) + local t = DormFurnitureAnimation[id] + if not t then + XLog.ErrorTableDataNotFound("XFurnitureConfigs.GetDormFurnitureAnimation", + "DormFurnitureAnimation", TABLE_DORM_FURNITURE_ANIMATION_PATH, "Id", tostring(id)) + return nil + end + + return t +end + +--获取行为节点Id +function XFurnitureConfigs.GetFurnitureBehavior(furnitureId, state) + if not FurnitureBehaviorTemplate or not FurnitureBehaviorTemplate[furnitureId] then + XLog.ErrorTableDataNotFound("XFurnitureConfigs.GetFurnitureBehavior", + "FurnitureBehavior", SHARE_FURNTIURE_BEHAVIOR, "furnitureId", tostring(furnitureId)) + return + end + + if not FurnitureBehaviorTemplate[furnitureId][state] then + XLog.Error("FurnitureBehaviorTemplate State not exist", furnitureId, state) + return + end + + return FurnitureBehaviorTemplate[furnitureId][state] +end + +function XFurnitureConfigs.GetOnceAnimationType(furnitureId) + local furniture = XFurnitureConfigs.GetFurnitureBaseTemplatesById(furnitureId) + if not furniture then + return nil + end + + local t = XFurnitureConfigs.GetDormFurnitureAnimation(furniture.AnimationId) + if not t then + return nil + end + + return t.ClickType +end + +-- 获取家具动画类型 +function XFurnitureConfigs.GetOnceAnimationType(furnitureId) + local furniture = XFurnitureConfigs.GetFurnitureBaseTemplatesById(furnitureId) + if not furniture then + return nil + end + + local t = XFurnitureConfigs.GetDormFurnitureAnimation(furniture.AnimationId) + if not t then + return nil + end + + return t.ClickType +end + +-- 根据构造体ID获取家具交互动画名 +function XFurnitureConfigs.GetDormFurnitureAnimationByCharId(furnitureId, charId) + local furniture = XFurnitureConfigs.GetFurnitureBaseTemplatesById(furnitureId) + if not furniture then + return nil + end + + local t = XFurnitureConfigs.GetDormFurnitureAnimation(furniture.AnimationId) + if not t then + return nil + end + + for k, v in pairs(t.CharacterId) do + if charId == v and t.CharacterAnimationName[k] then + return t.CharacterAnimationName[k] + end + end + + return nil +end + +-- 获取家具动画名 +function XFurnitureConfigs.GetOnceAnimationName(furnitureId) + local furniture = XFurnitureConfigs.GetFurnitureBaseTemplatesById(furnitureId) + if not furniture then + return nil + end + + local t = XFurnitureConfigs.GetDormFurnitureAnimation(furniture.AnimationId) + if not t then + return nil + end + + if t.ClickType == XFurnitureConfigs.FurnitureAnimationType.Once then + return t.OnceAnimationName + elseif t.ClickType == XFurnitureConfigs.FurnitureAnimationType.Repeat then + return t.RepaatAnimationName + end + + return nil +end + +-- 获取喜好度类型Icon +function XFurnitureConfigs.GetDormFurnitureTypeIcon(id) + local t = XFurnitureConfigs.GetDormFurnitureType(id) + return t.TypeIcon +end + +-- 获取喜好度类型Name +function XFurnitureConfigs.GetDormFurnitureTypeName(id) + local t = XFurnitureConfigs.GetDormFurnitureType(id) + return t.TypeName +end + +function XFurnitureConfigs.GetFurniturePutNumCfg(putId) + return FurniturePutNumTemplates[putId] +end + +-- 获取家具分类数据 +function XFurnitureConfigs.GetFurnitureTemplatePartType() + local parts = {} + for _, part in pairs(FurnitureTypeTemplates) do + if not parts[part.MinorType] then + parts[part.MinorType] = {} + parts[part.MinorType].MinorName = part.MinorName + parts[part.MinorType].Categorys = {} + end + local categoryInfo = {} + categoryInfo.Category = part.Category + categoryInfo.CategoryName = part.CategoryName + categoryInfo.Id = part.Id + + parts[part.MinorType].Categorys[part.Id] = categoryInfo + end + + return parts +end + +-- 获取家具分类数据数量 +function XFurnitureConfigs.GetFurnitureTemplateTypeCount() + local count = 0 + for _, _ in pairs(FurnitureTypeTemplates) do + count = count + 1 + end + + return count +end + +-- 获取家具分类数据List +function XFurnitureConfigs.GetFurnitureTemplateTypeList() + local list = {} + for _, part in pairs(FurnitureTypeTemplates) do + table.insert(list, part) + end + table.sort(list, function(a, b) + return a.Id < b.Id + end) + return list +end + +-- 随机属性描述 +function XFurnitureConfigs.GetAdditionalRandomIntroduce(id) + local currentAttr = FurnitureAdditionalAttr[id] + + if not currentAttr then + XLog.ErrorTableDataNotFound("XFurnitureConfigs.GetAdditionalRandomIntroduce", + "FurnitureAdditionalAttr", SHARE_FURNITURE_ADDITIONALATTR, "Id", tostring(id)) + return + end + + return currentAttr.Introduce or "" +end + +-- 获取评分词条 +function XFurnitureConfigs.GetAdditionalRandomEntry(id, removeScore) + local addRandom = XFurnitureConfigs.GetAdditonAttrConfigById(id) + local quality = addRandom.QualityType < 0 and 2 or addRandom.QualityType + local color = XFurnitureConfigs.FurnitureAttrColor[quality] + local level = XFurnitureConfigs.FurnitureAttrLevel[quality] + if removeScore then + return string.format("%s", color, level) + else + return string.format("%s%d", color, level, addRandom.AddScore) + end +end + +-- 获取一组随机属性描述 +function XFurnitureConfigs.GetGroupRandomIntroduce(groupId, removeScore) + if DormFurnitureTypeAttsDic[groupId] then + return DormFurnitureTypeAttsDic[groupId] + end + + local tmpRemoveScore = removeScore or false + local groupIntroduce = {} + local data = {} + for _, v in pairs(FurnitureAdditionalAttr) do + if groupId == v.GroupId then + table.insert(groupIntroduce, { + Id = v.AttributeId, + Introduce = v.Introduce, + QualityType = v.QualityType, + AddDes = XFurnitureConfigs.GetAdditionalRandomEntry(v.AttributeId, tmpRemoveScore) or "" + }) + end + end + + if _G.next(groupIntroduce) then + table.sort(groupIntroduce, function(a, b) + return a.QualityType > b.QualityType + end) + end + + for _, v in pairs(groupIntroduce) do + if not data[v.AddDes] then + data[v.AddDes] = {} + end + table.insert(data[v.AddDes], v) + end + + DormFurnitureTypeAttsDic[groupId] = data + + return data +end + +-- 家具风格套装 +function XFurnitureConfigs.GetFurnitureSuitTemplates() + return FurnitureSuitTemplates +end + +-- 家具风格套装 +function XFurnitureConfigs.GetFurnitureSuitTemplatesList() + local list = {} + for _, v in pairs(FurnitureSuitTemplates) do + table.insert(list, v) + end + table.sort(list, function(a, b) + return a.Id < b.Id + end) + return list +end + +-- 宿舍套装类型名字 +function XFurnitureConfigs.GetFurnitureSuitName(id) + local d = FurnitureSuitTemplates[id] + if not d then + return + end + + return d.SuitName +end + +function XFurnitureConfigs.IsAllSuit(suitId) + return suitId == nil or suitId == 0 or suitId == 1 +end + +-- 属性标签 +function XFurnitureConfigs.GetFurnitureTagTypeTemplates() + return FurnitureTagTypeTemplates +end + +-- 获取家具类型列表 +function XFurnitureConfigs.GetFurnitureTypeList() + local list = {} + for _, v in pairs(FurnitureTypeList) do + table.insert(list, v) + end + return list +end + +-- 获取家具类型下Minor个数 +function XFurnitureConfigs.GetCountByMinor(minor, suitId) + local minors = FurnitureMinorDatas[minor] + if not minors then + return 0 + end + + local count = 0 + local isAllSuit = XFurnitureConfigs.IsAllSuit(suitId) + for _, categorys in pairs(minors) do + for id, suits in pairs(categorys) do + if isAllSuit or id == suitId then + count = count + #suits + end + end + end + + return count +end + +-- 获取家具类型下Category个数 +function XFurnitureConfigs.GetCountByCategory(minor, category, suitId) + local minors = FurnitureMinorDatas[minor] + if not minors then + return 0 + end + + local categorys = minors[category] + if not categorys then + return 0 + end + + local count = 0 + local isAllSuit = XFurnitureConfigs.IsAllSuit(suitId) + for id, suits in pairs(categorys) do + if isAllSuit or id == suitId then + count = count + #suits + end + end + + return count +end + +-- 获取家具类型下List +function XFurnitureConfigs.GetFurnitureCfgList(minorId, categoryId, suitId) + local list = {} + local minors = FurnitureMinorDatas[minorId] + if not minors then + return list + end + + local isAllSuit = XFurnitureConfigs.IsAllSuit(suitId) + if not categoryId then + for _, categorys in pairs(minors) do + for id, suits in pairs(categorys) do + if isAllSuit or id == suitId then + for _, suit in ipairs(suits) do + local data = { ConfigId = suit } + table.insert(list, data) + end + end + end + end + else + local categorys = minors[categoryId] + if not categorys then + return list + end + + for id, suits in pairs(categorys) do + if isAllSuit or id == suitId then + for _, suit in ipairs(suits) do + local data = { ConfigId = suit } + table.insert(list, data) + end + end + end + end + + return list +end + +-- 获取某个套装家具总个数 +function XFurnitureConfigs.GetSuitCount(suitId) + if XFurnitureConfigs.IsAllSuit(suitId) then + suitId = 0 + end + return FurnitureSuitDatas[suitId] +end + +-- 获取家具类型列表,用于构建二级菜单 +function XFurnitureConfigs.GetFurnitureTypeGroupList() + return FurnitureTypeGroupList +end + +function XFurnitureConfigs.GetFurnitureSuitTemplatesById(suitId) + local currentSuitTemplate = FurnitureSuitTemplates[suitId] + + if not currentSuitTemplate then + XLog.ErrorTableDataNotFound("XFurnitureConfigs.GetFurnitureSuitTemplatesById", + "FurnitureSuit", CLIENT_FURNITURE_SUIT, "suitId", tostring(suitId)) + return + end + + return currentSuitTemplate +end + +-- 家具客户端数据 +function XFurnitureConfigs.GetFurnitureBaseTemplatesById(id) + local currentTemplates = FurnitureTemplates[id] + + if not currentTemplates then + XLog.ErrorTableDataNotFound("XFurnitureConfigs.GetFurnitureBaseTemplatesById", "Furniture", SHARE_FURNITURE, "Id", tostring(id)) + return + end + + return currentTemplates +end + +-- 家具名称 +function XFurnitureConfigs.GetFurnitureNameById(id) + local currentTemplates = XFurnitureConfigs.GetFurnitureBaseTemplatesById(id) + return currentTemplates.Name +end + +-- 家具Icon +function XFurnitureConfigs.GetFurnitureIconById(id) + local currentTemplates = XFurnitureConfigs.GetFurnitureBaseTemplatesById(id) + return currentTemplates.Icon +end + +-- 家具描述 +function XFurnitureConfigs.GetFurnitureDescriptionById(id) + local currentTemplates = XFurnitureConfigs.GetFurnitureBaseTemplatesById(id) + return currentTemplates.Desc +end + +-- 家具大图标 +function XFurnitureConfigs.GetFurnitureBigIconById(id) + local currentTemplates = XFurnitureConfigs.GetFurnitureBaseTemplatesById(id) + return currentTemplates.Icon +end + +-- 属性类型 +function XFurnitureConfigs.GetFurnitureAttrType() + local temp = {} + for k, v in pairs(DormFurnitureTypeTemplate) do + if k < XFurnitureConfigs.AttrType.AttrAll then + table.insert(temp, v) + end + end + + return temp +end + +-- 获取所有家具 +function XFurnitureConfigs.GetAllFurnitures() + return FurnitureTemplates +end + +-- 家具基础数据 +function XFurnitureConfigs.GetFurnitureTemplateById(id) + local currentTemplate = FurnitureTemplates[id] + + if not currentTemplate then + XLog.ErrorTableDataNotFound("XFurnitureConfigs.GetFurnitureTemplateById", "Furniture", SHARE_FURNITURE, "Id", tostring(id)) + return + end + + return currentTemplate +end + +-- 判断家具类型 +function XFurnitureConfigs.IsFurnitureMatchTypeByConfigId(configId, targetType) + local furnitureTemplates = XFurnitureConfigs.GetFurnitureTemplateById(configId) + if furnitureTemplates then + return furnitureTemplates.TypeId == targetType + end + return false +end + +-- 获取家具类型配置表通过 ConfigID +function XFurnitureConfigs.GetFurnitureTypeCfgByConfigId(configId) + local furnitureTemplate = XFurnitureConfigs.GetFurnitureTemplateById(configId) + if not furnitureTemplate then + return nil + end + + local typeTemplate = XFurnitureConfigs.GetFurnitureTypeById(furnitureTemplate.TypeId) + return typeTemplate +end + +-- 摆放类型转地表类型 +function XFurnitureConfigs.LocateTypeToXHomePlatType(locateType) + local type = nil + if locateType == XFurnitureConfigs.HomeLocateType.LocateGround then + type = CS.XHomePlatType.Ground + elseif locateType == XFurnitureConfigs.HomeLocateType.LocateWall then + type = CS.XHomePlatType.Wall + end + + return type +end + +-- 获取家具交互点列表 +function XFurnitureConfigs.GetFurnitureInteractPosList(posStr) + local list = {} + + local strs = string.Split(posStr, "|") + if strs and #strs > 0 then + for _, v in ipairs(strs) do + local xy = string.Split(v, "#") + if xy and #xy >= 2 then + local x = tonumber(xy[1]) + local y = tonumber(xy[2]) + if x and y then + local vec = {} + vec.x = x + vec.y = y + table.insert(list, vec) + end + end + end + end + + return list +end + +-- 获取家具等级配置表 +function XFurnitureConfigs.GetFurnitureLevelTemplate(furnitureType) + local currentTemplates = FurnitureLevelTemplates[furnitureType] + + if not currentTemplates then + XLog.ErrorTableDataNotFound("XFurnitureConfigs.GetFurnitureLevelTemplate", + "FurnitureLevel", SHARE_FURNITURE_LEVEL, "furnitureType", tostring(furnitureType)) + return + end + + return currentTemplates +end +-- 获取家具总属性分级描述 +function XFurnitureConfigs.GetFurnitureTotalAttrLevelDescription(furnitureType, totalScore) + local quality = XFurnitureConfigs.GetFurnitureTotalAttrLevel(furnitureType, totalScore) + local color = XFurnitureConfigs.FurnitureAttrColor[quality] or XFurnitureConfigs.FurnitureAttrColor[1] + local level = XFurnitureConfigs.FurnitureAttrLevel[quality] or XFurnitureConfigs.FurnitureAttrLevel[1] + return string.format(CS.XGame.ClientConfig:GetString("DormAttrFormat"), color, level, totalScore) +end + + +function XFurnitureConfigs.GetFurnitureTotalAttrLevelNewColorDescription(furnitureType, totalScore) + local quality = XFurnitureConfigs.GetFurnitureTotalAttrLevel(furnitureType, totalScore) + local color = XFurnitureConfigs.FurnitureAttrTagColor[3]-- XFurnitureConfigs.FurnitureAttrTagColor[quality] or XFurnitureConfigs.FurnitureAttrTagColor[3] + local level = XFurnitureConfigs.FurnitureAttrLevel[quality] or XFurnitureConfigs.FurnitureAttrLevel[1] + return string.format(CS.XGame.ClientConfig:GetString("DormAttrFormat"), color, level, totalScore) +end + +-- 获取家具总属性等级 +function XFurnitureConfigs.GetFurnitureTotalAttrLevel(furnitureType, totalScore) + local temp = -1 + local furntiureLevels = XFurnitureConfigs.GetFurnitureLevelTemplate(furnitureType) + local quality = 2 + local maxScore = 0 + local min = totalScore + for _, v in pairs(furntiureLevels) do + local minScore = v.MinScore + if totalScore >= minScore and minScore > temp then + temp = minScore + quality = v.Quality + min = v.MinScore + end + + if v.MaxScore > maxScore then + maxScore = v.MaxScore + end + end + return quality, maxScore, min +end + +-- 获取家具单个属性等级 +function XFurnitureConfigs.GetFurnitureSingleAttrLevel(furnitureType, attrIndex, score) + local temp = -1 + local furntiureLevels = FurnitureSingleAttrLevelIndex[furnitureType] + local quality = 2 + local maxScore = 0 + local mScore = score + + for _, v in pairs(furntiureLevels) do + local minScore = v.AttrMinScore[attrIndex] + if score >= minScore and minScore > temp then + temp = minScore + quality = v.Quality + mScore = minScore + end + + if v.AttrMaxScore[attrIndex] > maxScore then + maxScore = v.AttrMaxScore[attrIndex] + end + end + + return quality, maxScore, mScore +end + +-- 获取家具等级描述 +function XFurnitureConfigs.GetFurnitureAttrLevelDescription(furnitureType, attrType, score) + local quality = XFurnitureConfigs.GetFurnitureAttrlevel(furnitureType, attrType, score) + local color = XFurnitureConfigs.FurnitureAttrColor[quality] or XFurnitureConfigs.FurnitureAttrColor[1] + local level = XFurnitureConfigs.FurnitureAttrLevel[quality] or XFurnitureConfigs.FurnitureAttrLevel[1] + return string.format(CS.XGame.ClientConfig:GetString("DormAttrFormat"), color, level, score) +end + + +-- 获取家具等级描述 +function XFurnitureConfigs.GetFurnitureAttrLevelNewDescription(furnitureType, attrType, score) + local quality = XFurnitureConfigs.GetFurnitureAttrlevel(furnitureType, attrType, score) + local color = XFurnitureConfigs.FurnitureAttrTagColor[quality] or XFurnitureConfigs.FurnitureAttrTagColor[1] + local level = XFurnitureConfigs.FurnitureAttrLevel[quality] or XFurnitureConfigs.FurnitureAttrLevel[1] + return string.format(CS.XGame.ClientConfig:GetString("DormAttrFormat"), color, level, score) +end + + +-- 获取家具属性等级 +function XFurnitureConfigs.GetFurnitureAttrlevel(furnitureType, attrType, score) + local temp = -1 + local furntiureLevels = XFurnitureConfigs.GetFurnitureLevelTemplate(furnitureType) + local quality = 2 + + for _, v in pairs(furntiureLevels) do + local attrScore = v.AttrScore[attrType] or 0 + if score >= attrScore and attrScore > temp then + temp = attrScore + quality = v.Quality + end + end + return quality +end + +-- 获取家具摆放类型 +function XFurnitureConfigs.GetFurniturePlaceType(furnitureTypeId) + if not furnitureTypeId then + XLog.Error("XFurnitureConfigs.GetFurniturePlaceType furnitureTypeId is nil.") + return + end + + local typeCfg = FurnitureTypeTemplates[furnitureTypeId] + if not typeCfg then + XLog.ErrorTableDataNotFound("XFurnitureConfigs.GetFurniturePlaceType", "FurnitureType", SHARE_FURNITURE_TYPE, "Id", tostring(furnitureTypeId)) + return + end + + if typeCfg.MajorType == 1 and typeCfg.MinorType == 1 then + return XFurniturePlaceType.Ground + elseif typeCfg.MajorType == 1 and typeCfg.MinorType == 2 then + return XFurniturePlaceType.Wall + elseif typeCfg.MajorType == 1 and typeCfg.MinorType == 3 then + return XFurniturePlaceType.Ceiling + elseif typeCfg.MajorType == 2 and typeCfg.MinorType == 6 then + return XFurniturePlaceType.OnWall + else + return XFurniturePlaceType.OnGround + end +end + +-- 获取所有家具类型 +function XFurnitureConfigs.GetAllFurnitureTypes() + return FurnitureTypeTemplates +end + +-- 家具类型数据 +function XFurnitureConfigs.GetFurnitureTypeById(id) + local currentTemplates = FurnitureTypeTemplates[id] + + if not currentTemplates then + XLog.Error("XFurnitureConfigs.GetFurnitureType not found by id : " .. tostring(id)) + end + + return currentTemplates +end + +-- 家具属基础性数据 +function XFurnitureConfigs.GetFurnitureBaseAttrValueById(id) + local furnitureBaseAttrTemplate = FurnitureBaseAttrTemplate[id] + + if not furnitureBaseAttrTemplate then + return 0 + end + + return furnitureBaseAttrTemplate.Value +end + +-- 家具属额外性数据 +function XFurnitureConfigs.GetFurnitureExtraAttrsById(id) + local attrIds = {} + local furnitureExtraAttrTemplate = FurnitureExtraAttrTemplate[id] + + if not furnitureExtraAttrTemplate then + return attrIds + end + + return furnitureExtraAttrTemplate +end + +function XFurnitureConfigs.GetFurntiureExtraAttrTotalValue(id) + if not FurnitureExtraAttrTemplate[id] then + return 0 + end + + return XFurnitureConfigs.GetFurnitureBaseAttrValueById(FurnitureExtraAttrTemplate[id].BaseAttrId) +end + +-- 最低,最高档位 +function XFurnitureConfigs.GetFurnitureCreateMinAndMax() + local minConsume = FurnitureCreateAttr[1].MinConsume + local maxConsume = FurnitureCreateAttr[1].MinConsume + for _, v in pairs(FurnitureCreateAttr) do + if v.MinConsume < minConsume then + minConsume = v.MinConsume + end + if v.MinConsume > maxConsume then + maxConsume = v.MinConsume + end + end + return minConsume, maxConsume +end + +-- 根据家具拿到对应的图纸,一一对应,家具不一定有对应的图纸,如果没有则不能改装 +function XFurnitureConfigs.GetDrawingByFurnitureId(furnitureId) + return FurnitureToDrawingMap[furnitureId] +end + +-- 根据图纸拿到预览的家具,一一对应,图纸一定有对应的家具 +function XFurnitureConfigs.GetPreviewFurnitureByDrawingId(drawingId) + return DrawingToFurnitureMap[drawingId] +end + +function XFurnitureConfigs.GetRefitTypeDatas(typeId) + return DrawingPicMap[typeId] +end + +-- 根据家具基础类型设置视角 +function XFurnitureConfigs.GetFurnitureViewAngleByMinor(minor) + local currentViewAngle = FurnitureViewAngle[minor] + if not currentViewAngle then + XLog.Error("XFurnitureConfigs.GetFurnitureViewAngleByMinor is not found by minor :" .. tostring(minor)) + return + end + return currentViewAngle +end + +function XFurnitureConfigs.GetFurnitureColour(furnitureId) + return FurnitureColour[furnitureId] +end + +-- 获取家具套装 +function XFurnitureConfigs.GetFurnitureSuitConfig(configId) + local furnitureTemplate = XFurnitureConfigs.GetFurnitureTemplateById(configId) + if furnitureTemplate.SuitId <= 0 then + return nil + end + + return XFurnitureConfigs.GetFurnitureSuitTemplatesById(furnitureTemplate.SuitId) +end + +-- 图鉴显示配置数据 +function XFurnitureConfigs.GetFieldGuideDatas() + local data = {} + + for _, v in pairs(FurnitureTemplates) do + if v and v.SuitId and v.SuitId > 0 then + if not data[v.SuitId] then + data[v.SuitId] = {} + end + table.insert(data[v.SuitId], v) + end + end + + return data +end + +-- 获取家具回收奖励Id +function XFurnitureConfigs.GetFurnitureReturnId(configId) + local furnitureTemplate = XFurnitureConfigs.GetFurnitureTemplateById(configId) + if not furnitureTemplate.ReturnId or furnitureTemplate.ReturnId <= 0 then + return nil + end + + return furnitureTemplate.ReturnId +end + +function XFurnitureConfigs.GetFurnitureReward(id) + return FurnitureRewardTemplate[id] +end + +-- 计算恢复速度 +function XFurnitureConfigs.GetRecoverSpeed(speed) + local tempSpeed = string.format("%.1f", speed / 100) + + if tempSpeed * 10 % 10 == 0 then + tempSpeed = string.format("%d", tempSpeed) + end + + return tempSpeed +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XGachaConfigs.lua b/Resources/Scripts/XConfig/XGachaConfigs.lua new file mode 100644 index 00000000..6b2896fd --- /dev/null +++ b/Resources/Scripts/XConfig/XGachaConfigs.lua @@ -0,0 +1,210 @@ +XGachaConfigs = XGachaConfigs or {} + +local TABLE_GACHA = "Share/Gacha/Gacha.tab" +local TABLE_GACHA_REWARD = "Share/Gacha/GachaReward.tab" +local TABLE_GACHA_PROBSHOW = "Client/Gacha/GachaProbShow.tab" +local TABLE_GACHA_RULE = "Client/Gacha/GachaRule.tab" + +local Gachas = {} +local GachaRewards = {} +local GachaProbShow = {} +local GachaRule = {} +local AllRareGachaCount = {} + +-- Gacha卡池组字典 +-- Key:OrganizeId +-- Value:Gacha.tab配置项数组{gacha, gacha, ..., gacha} +local GachaOrganizeDic = {} + +XGachaConfigs.RewardType = { + Count = 0, + NotCount = 1, +} + +XGachaConfigs.RareType = { + Normal = false, + Rare = true, +} + +XGachaConfigs.UiType = { + Free = 1, + Pay = 2, +} + +-- 卡池组内卡池的状态 +XGachaConfigs.OrganizeGachaStatus = { + Normal = 1, -- 正常(可抽卡) + Lock = 2, -- 锁定 + SoldOut = 3, -- 售罄 +} + +function XGachaConfigs.Init() + Gachas = XTableManager.ReadByIntKey(TABLE_GACHA, XTable.XTableGacha, "Id") + GachaRewards = XTableManager.ReadByIntKey(TABLE_GACHA_REWARD, XTable.XTableGachaReward, "Id") + GachaProbShow = XTableManager.ReadByIntKey(TABLE_GACHA_PROBSHOW, XTable.XTableGachaProbShow, "Id") + GachaRule = XTableManager.ReadByIntKey(TABLE_GACHA_RULE, XTable.XTableGachaRule, "Id") + + for _, gacha in pairs(Gachas) do + if gacha.OrganizeId and gacha.OrganizeId ~= 0 then + if not GachaOrganizeDic[gacha.OrganizeId] then + GachaOrganizeDic[gacha.OrganizeId] = {} + end + table.insert(GachaOrganizeDic[gacha.OrganizeId], gacha) + end + end + + for _, gachas in pairs(GachaOrganizeDic) do + table.sort(gachas, function(a, b) + return a.OrganizeSort < b.OrganizeSort + end) + end + + for _, v in pairs(GachaRewards) do + if v.Rare then + AllRareGachaCount[v.TemplateId] = true + end + end +end + +function XGachaConfigs.GetGachaReward() + return GachaRewards +end + +function XGachaConfigs.GetAllRareGacha() + return AllRareGachaCount +end + +function XGachaConfigs.GetGachas() + return Gachas +end + +function XGachaConfigs.GetGachaCfgById(id) + if not Gachas[id] then + XLog.ErrorTableDataNotFound("XGachaConfigs.GetGachaCfgById", "Gacha", TABLE_GACHA, "id", tostring(id)) + return {} + end + return Gachas[id] +end + +function XGachaConfigs.GetGachaProbShows() + return GachaProbShow +end + +function XGachaConfigs.GetGachaRuleCfgById(id) + if not GachaRule[id] then + XLog.ErrorTableDataNotFound("XGachaConfigs.GetGachaRuleCfgById", "GachaRule", TABLE_GACHA_RULE, "id", tostring(id)) + return + end + return GachaRule[id] +end + + +-------------------------------------------Organize卡池组数据读取---------------------------------------------------------- + +--- +--- 内部接口 +--- 获取属于'organizeId'卡池组的卡池配置 +local function GetGchaOrganize(organizeId) + if not GachaOrganizeDic[organizeId] then + XLog.Error(string.format("XGachaConfigs:GetOrganize函数错误,GachaOrganizeDic不存在organizeId:%s的数据", + tostring(organizeId))) + return {} + end + return GachaOrganizeDic[organizeId] +end + +--- +--- 内部接口 +--- 获取'organizeId'卡池组的第一个卡池 +local function GetOrganizeFirstGacha(organizeId) + local organize = GetGchaOrganize(organizeId) + + local firstGacha = organize[1] + if not firstGacha then + XLog.Error(string.format("XGachaConfigs.GetOrganizeFirstGacha函数错误,卡池组%s没有PreGachaId为空或者0的卡池", + tostring(organizeId))) + return + end + return firstGacha +end + + +--- +--- 获取'organizeId'卡池组的所有卡池的Id数组 +function XGachaConfigs.GetOrganizeGahcaIdList(organizeId) + local organize = GetGchaOrganize(organizeId) + local idList = {} + for index, gacha in ipairs(organize) do + idList[index] = gacha.Id + end + return idList +end + +--- +--- 获取'organizeId'卡池组第一个卡池的GachaRule配置 +---@return table GachaRule配置 +function XGachaConfigs.GetOrganizeRuleCfg(organizeId) + local firstGacha = GetOrganizeFirstGacha(organizeId) + if not firstGacha then + return + end + return XGachaConfigs.GetGachaRuleCfgById(firstGacha.Id) +end + +--- +--- 获取'organizeId'卡池组第一个卡池的开始时间与结束时间 +---@return string 开始时间|结束时间 +function XGachaConfigs.GetOrganizeTime(organizeId) + local firstGacha = GetOrganizeFirstGacha(organizeId) + if not firstGacha then + return + end + return firstGacha.StartTimeStr, firstGacha.EndTimeStr +end + +--- +--- 获取'organizeId'卡池组'gachaId'在数组中的序号 +function XGachaConfigs.GetOrganizeIndex(organizeId, gachaId) + local organize = GetGchaOrganize(organizeId) + for i, gacha in ipairs(organize) do + if gacha.Id == gachaId then + return i + end + end + XLog.Error(string.format("XGachaConfigs.GetOrganizeIndex函数错误,卡池%s不在%s卡池组中", tostring(gachaId), tostring(organizeId))) +end + +--- +--- 获取'organizeId'卡池组'gachaId'前一个卡池的id +--- 如果'gachaId'是第一个卡池则返回0 +function XGachaConfigs.GetOrganizePreGachaId(gachaId) + local gacha = XGachaConfigs.GetGachaCfgById(gachaId) + return gacha.PreGachaId +end + +--- +--- 获取'organizeId'卡池组'gachaId'后一个卡池的id +--- 如果'gachaId'是最后一个卡池则返回0 +function XGachaConfigs.GetOrganizeNextGachaId(organizeId, gachaId) + local idList = XGachaConfigs.GetOrganizeGahcaIdList(organizeId) + + local index + for i, id in ipairs(idList) do + if id == gachaId then + index = i + 1 + end + end + if not index then + XLog.Error(string.format("XGachaConfigs.GetOrganizeNextGachaId函数错误,%s卡池组没有%s卡池数据", + tostring(organizeId), tostring(gachaId))) + return 0 + end + return idList[index] or 0 +end + +--- +--- 获取'gachaId'的卡池图标 +function XGachaConfigs.GetOrganizeGachaIcon(gachaId) + local gacha = XGachaConfigs.GetGachaCfgById(gachaId) + return gacha.GachaIcon +end diff --git a/Resources/Scripts/XConfig/XGuardCampConfig.lua b/Resources/Scripts/XConfig/XGuardCampConfig.lua new file mode 100644 index 00000000..e8629988 --- /dev/null +++ b/Resources/Scripts/XConfig/XGuardCampConfig.lua @@ -0,0 +1,192 @@ +local CSXTextManagerGetText = CS.XTextManager.GetText +local tableInsert = table.insert +local stringGsub = string.gsub +local ParseToTimestamp = XTime.ParseToTimestamp + +local TABLE_CAMP_PATH = "Share/GuardCamp/Camp.tab" +local TABLE_ACTIVITY_PATH = "Share/GuardCamp/Activity.tab" + +local CampTemplate = {} +local ActivityTemplate = {} +local CampIdList = {} + +local JoinMaxNum = 0 --参与人数配置最大数量 + +XGuardCampConfig = XGuardCampConfig or {} + +XGuardCampConfig.ActivityState = { + UnOpen = 1, --活动未开启 + SupportOpen = 2, --活动和应援开启 + SupportClose = 3, --应援关闭,等待开奖 + DrawLottery = 4, --开奖 + Close = 5, --活动关闭 +} +XGuardCampConfig.NotGuardId = 0 + +local InitCampIdList = function() + for id in pairs(CampTemplate) do + tableInsert(CampIdList, id) + end +end + +local InitJoinMaxNum = function() + for _, v in pairs(ActivityTemplate) do + local maxIndex = #v.JoinNum + JoinMaxNum = v.JoinNum[maxIndex] or 0 + end +end + +function XGuardCampConfig.Init() + CampTemplate = XTableManager.ReadByIntKey(TABLE_CAMP_PATH, XTable.XTableGuardCamp, "Id") + ActivityTemplate = XTableManager.ReadByIntKey(TABLE_ACTIVITY_PATH, XTable.XTableGuardCampActivity, "Id") + + InitCampIdList() + InitJoinMaxNum() +end + +local GetCampConfig = function(id) + local config = CampTemplate[id] + if not config then + XLog.Error("XTRPGConfigs GetCampConfig error:配置不存在, roleId: " .. id .. ", 配置路径: " .. TABLE_CAMP_PATH) + return + end + return config +end + +function XGuardCampConfig.GetCampIdList() + return CampIdList +end + +function XGuardCampConfig.GetCampId(index) + return CampIdList[index] +end + +function XGuardCampConfig.GetCampName(id) + local config = GetCampConfig(id) + return config.Name +end + +function XGuardCampConfig.GetCampRewardId(id) + local config = GetCampConfig(id) + return config.RewardId +end + +local GetActivityConfig = function(id) + local config = ActivityTemplate[id] + if not config then + XLog.Error("XTRPGConfigs GetActivityConfig error:配置不存在, roleId: " .. id .. ", 配置路径: " .. TABLE_ACTIVITY_PATH) + return + end + return config +end + +function XGuardCampConfig.GetActivityId() + local serverTimestamp = XTime.GetServerNowTimestamp() + local endTimestamp + local defaultActivityId + for id in pairs(ActivityTemplate) do + endTimestamp = XGuardCampConfig.GetActivityTime(id) + if endTimestamp > serverTimestamp then + return id + end + defaultActivityId = id + end + return defaultActivityId +end + +function XGuardCampConfig.GetActivityDrawLotteryTime(id) + local drawLotteryTimeStr = XGuardCampConfig.GetActivityDrawLotteryTimeStr(id) + return ParseToTimestamp(drawLotteryTimeStr) +end + +function XGuardCampConfig.GetActivityShowDrawLotteryTime(id) + local config = GetActivityConfig(id) + return config.ShowDrawLotteryTime +end + +function XGuardCampConfig.GetSupportOpenTimeStr(id) + local config = GetActivityConfig(id) + local timeId = config.SupportTimeId + local startTimestamp = XFunctionManager.GetStartTimeByTimeId(timeId) + return os.date("%Y/%m/%d %H:%M", startTimestamp) +end + +function XGuardCampConfig.GetActivityCloseTimeStr(id) + local config = GetActivityConfig(id) + local timeId = config.OpenTimeId + local startTimestamp = XFunctionManager.GetEndTimeByTimeId(timeId) + return os.date("%Y/%m/%d %H:%M", startTimestamp) +end + +function XGuardCampConfig.GetActivityTime(id) + local config = GetActivityConfig(id) + local timeId = config.OpenTimeId + local startTimestamp, endTimestamp = XFunctionManager.GetTimeByTimeId(timeId) + return startTimestamp, endTimestamp +end + +function XGuardCampConfig.GetActivitySupportLastTime(id) + local config = GetActivityConfig(id) + local timeId = config.SupportTimeId + local startTimestamp, endTimestamp = XFunctionManager.GetTimeByTimeId(timeId) + return startTimestamp, endTimestamp +end + +function XGuardCampConfig.GetActivitySupportItemId(id) + local config = GetActivityConfig(id) + return config.SupportItemId +end + +function XGuardCampConfig.GetActivityRewardPondItemId(id) + local config = GetActivityConfig(id) + return config.RewardPondItemId +end + +function XGuardCampConfig.GetActivitySelectCampNeedCount(id) + local config = GetActivityConfig(id) + return config.SelectCampNeedCount +end + +function XGuardCampConfig.GetActivityPerSupportNum(id) + local config = GetActivityConfig(id) + return config.PerSupportNum +end + +function XGuardCampConfig.GetActivityTotalSupportCount(id) + local config = GetActivityConfig(id) + return config.TotalSupportCount +end + +function XGuardCampConfig.GetActivityCampIdList(id) + local config = GetActivityConfig(id) + return config.CampId +end + +function XGuardCampConfig.GetActivityJoinNumList(id) + local config = GetActivityConfig(id) + return config.JoinNum +end + +function XGuardCampConfig.GetActivityPondAddList(id) + local config = GetActivityConfig(id) + return config.PondAdd +end + +function XGuardCampConfig.GetActivityJoinCampPurchasePackage(id) + local config = GetActivityConfig(id) + return config.JoinCampPurchasePackageUiType, config.JoinCampPurchasePackageId +end + +function XGuardCampConfig.GetActivitySupportCampPurchasePackage(id) + local config = GetActivityConfig(id) + return config.SupportCampPurchasePackageUiType, config.SupportCampPurchasePackageId +end + +function XGuardCampConfig.GetJoinMaxNum() + return JoinMaxNum +end + +function XGuardCampConfig.GetCaption(state) + local caption = state == XGuardCampConfig.ActivityState.DrawLottery and CSXTextManagerGetText("GuardCampCardPoolDrawLotteryCaption") or CSXTextManagerGetText("GuardCampCardPoolCaption") + return stringGsub(caption, "\\n", "\n") +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XGuideConfig.lua b/Resources/Scripts/XConfig/XGuideConfig.lua new file mode 100644 index 00000000..ab7e2392 --- /dev/null +++ b/Resources/Scripts/XConfig/XGuideConfig.lua @@ -0,0 +1,83 @@ +XGuideConfig = XGuideConfig or {} + +local TABLE_GUIDE_COMPLETE_PATH = "Share/Guide/GuideComplete.tab" +local TABLE_GUIDE_STEP_PATH = "Share/Guide/GuideStep.tab" +local TABLE_GUIDE_GROUP_PATH = "Share/Guide/GuideGroup.tab" +local TABLE_GUIDE_FIGHT_PATH = "Share/Guide/GuideFight.tab" + +-- 配置相关 +local GuideCompleteTemplates = {} +local GuideStepTemplates = {} +local GuideGroupTemplates = {} +local GuideFightTemplates = {} + +function XGuideConfig.Init() + GuideCompleteTemplates = XTableManager.ReadByIntKey(TABLE_GUIDE_COMPLETE_PATH, XTable.XTableGuideComplete, "Id") + GuideStepTemplates = XTableManager.ReadByIntKey(TABLE_GUIDE_STEP_PATH, XTable.XTableGuideStep, "Id") + GuideGroupTemplates = XTableManager.ReadByIntKey(TABLE_GUIDE_GROUP_PATH, XTable.XTableGuideGroup, "Id") + GuideFightTemplates = XTableManager.ReadByIntKey(TABLE_GUIDE_FIGHT_PATH, XTable.XTableGuideFight, "Id") + + for _, temp in pairs(GuideGroupTemplates) do + local completeTemp = GuideCompleteTemplates[temp.CompleteId] + if (not completeTemp) then + XLog.ErrorTableDataNotFound("XGuideConfig.Init", "GuideComplete", TABLE_GUIDE_COMPLETE_PATH, "Id", tostring(temp.CompleteId)) + end + + -- for i, stepId in ipairs(temp.StepIds) do + -- local stepTemp = GuideStepTemplates[stepId] + -- if (not stepTemp) then + -- XLog.Error("InitGuideGroupConfig error: can not found step template, step id is " .. stepId .. ", group id is " .. temp.Id) + -- end + -- end + end +end + +function XGuideConfig.GetGuideCompleteTemplates() + return GuideCompleteTemplates +end + +function XGuideConfig.GetGuideCompleteTemplatesById(id) + if not GuideCompleteTemplates then + return + end + + return GuideCompleteTemplates[id] +end + + +function XGuideConfig.GetGuideStepTemplates() + return GuideStepTemplates +end + +function XGuideConfig.GetGuideStepTemplatesById(id) + if not GuideStepTemplates then + return + end + + return GuideStepTemplates[id] +end + +function XGuideConfig.GetGuideGroupTemplates() + return GuideGroupTemplates +end + +function XGuideConfig.GetGuideGroupTemplatesById(id) + if not GuideGroupTemplates then + return + end + + return GuideGroupTemplates[id] +end + +function XGuideConfig.GetGuideFightTemplates() + return GuideFightTemplates +end + + +function XGuideConfig.GetGuideFightTemplatesById(id) + if not GuideFightTemplates then + return + end + + return GuideFightTemplates[id] +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XGuildBossConfig.lua b/Resources/Scripts/XConfig/XGuildBossConfig.lua new file mode 100644 index 00000000..55c93ae7 --- /dev/null +++ b/Resources/Scripts/XConfig/XGuildBossConfig.lua @@ -0,0 +1,117 @@ +XGuildBossConfig = XGuildBossConfig or {} + +local TABLE_GUILDBOSS_STAGEINFO = "Client/Guild/Boss/GuildStageInfo.tab" +local TABLE_GUILDBOSS_BUFF = "Client/Guild/Boss/GuildBossStageBuff.tab" +local TABLE_GUILDBOSS_LEVEL = "Share/Guild/Boss/GuildBossLevel.tab" +local TABLE_GUILDBOSS_HP_REWAED = "Share/Guild/Boss/GuildBossHpReward.tab" +local TABLE_GUILDBOSS_SCORE_REWAED = "Share/Guild/Boss/GuildBossScoreReward.tab" +local TABLE_GUILDBOSS_RANK_REWAED = "Share/Guild/Boss/GuildBossRankReward.tab" + + +local GuildBossStageInfos = {} +local GuildBossBuffs = {} +local GuildBossLevels = {} +local GuildBossHpRewards = {} +local GuildBossScoreRewards = {} +local GuildBossRankRewards = {} + +local HpRewardIdList = {} +local RankRewardIdList = {} +local RankRewardId2Index = {} + +--参考Share\Guild\Boss\GuildBossData.tab +GuildBossLevelType = +{ + Low = 1, + High = 2, + Boss = 3, +} + +GuildBossRewardType = +{ + Disable = 1,--未达到不能领取 + Available = 2,--达到了还未领取 + Acquired = 3,--已获取 +} + +function XGuildBossConfig.Init() + GuildBossStageInfos = XTableManager.ReadByIntKey(TABLE_GUILDBOSS_STAGEINFO, XTable.XTableGuildBossStageInfo, "Id") + GuildBossBuffs = XTableManager.ReadByIntKey(TABLE_GUILDBOSS_BUFF, XTable.XTableGuildBossBuff, "Id") + GuildBossLevels = XTableManager.ReadByIntKey(TABLE_GUILDBOSS_LEVEL, XTable.XTableGuildBossLevel, "Level") + GuildBossHpRewards = XTableManager.ReadByIntKey(TABLE_GUILDBOSS_HP_REWAED, XTable.XTableGuildBossHpReward, "Id") + GuildBossScoreRewards = XTableManager.ReadByIntKey(TABLE_GUILDBOSS_SCORE_REWAED, XTable.XTableGuildBossScoreReward, "Id") + GuildBossRankRewards = XTableManager.ReadByIntKey(TABLE_GUILDBOSS_RANK_REWAED, XTable.XTableGuildBossRankReward, "Id") + + for _, v in ipairs(GuildBossHpRewards) do + table.insert(HpRewardIdList, v.Id) + end + for i, v in ipairs(GuildBossRankRewards) do + RankRewardId2Index[v.Id] = i + table.insert(RankRewardIdList, v.Id) + end +end + +function XGuildBossConfig.GetBossStageInfo(id) + local info = GuildBossStageInfos[id] + if info == nil then + XLog.Error("表GuildStageInfo.tab中找不到Id:" .. id) + end + return info +end + +--获取所有难度数据 +function XGuildBossConfig.GetBossLevel() + return GuildBossLevels +end + +--获取buff信息 +function XGuildBossConfig.GetBuff(id) + local info = GuildBossBuffs[id] + if info == nil then + XLog.Error("GuildBossStageBuff.tab中找不到Id:" .. id) + end + return info +end + +--获取总分奖励信息 +function XGuildBossConfig.ScoreRewards() + return GuildBossScoreRewards +end + +--获取bossHp奖励信息 +function XGuildBossConfig.HpRewards() + return GuildBossHpRewards +end + +function XGuildBossConfig.GeHpRewardIdList() + return HpRewardIdList +end + +function XGuildBossConfig.GetHpPercent(id) + return GuildBossHpRewards[id].HpPercent +end + +-- 获取排名奖励配置 +function XGuildBossConfig.GeRankRewardIdList() + return RankRewardIdList +end + +function XGuildBossConfig.GetRankRewards() + return GuildBossRankRewards +end + +function XGuildBossConfig.GetRankRewardId(id) + return GuildBossRankRewards[id].RewardId +end + +-- 获取排名显示文本 +-- 返回'1%' 或 '1%-5%' +function XGuildBossConfig.GetRankPercentName(id) + local index = RankRewardId2Index[id] + local name = GuildBossRankRewards[id].Percent .. "%" + if index > 1 then + local lastId = RankRewardIdList[index - 1] + name = GuildBossRankRewards[lastId].Percent .. "%-" .. name + end + return name +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XGuildConfig.lua b/Resources/Scripts/XConfig/XGuildConfig.lua new file mode 100644 index 00000000..5ec39a80 --- /dev/null +++ b/Resources/Scripts/XConfig/XGuildConfig.lua @@ -0,0 +1,489 @@ +XGuildConfig = XGuildConfig or {} + +local CLIENT_GUILD_WELFARE = "Client/Guild/GuildWelfare.tab" +local CLIENT_GUILD_CHALLENGE = "Client/Guild/GuildChallengeDetails.tab" +local CLIENT_GUILD_TALENTDETAIL = "Client/Guild/GuildTalentDetails.tab" +local CLIENT_GUILD_WELCOME = "Client/Guild/GuildWelcome.tab" + +local SHARE_GUILD_LEVEL = "Share/Guild/GuildLevel.tab" +local SHARE_GUILD_POSITION = "Share/Guild/GuildPosition.tab" +local SHARE_GUILD_HEADPORTRAIT = "Share/Guild/GuildHeadPortrait.tab" +local SHARE_GUILD_GIFT = "Share/Guild/GuildGift.tab" +local SHARE_GUILD_NEWS = "Share/Guild/GuildNews.tab" +local SHARE_GUILD_PRESENT = "Share/Guild/GuildPresent.tab" +local SHARE_GUILD_TALENT = "Share/Guild/GuildTalent.tab" +local SHARE_GUILD_CUSTOMNAME = "Share/Guild/GuildCustomName.tab" + +-- 心愿发布 +local SHARE_GUILD_TRUSTITEM = "Share/Trust/CharacterTrustItem.tab" + +local GuildWelfare = {} +local GuildChallenge = {} +local GuildTalentDetails = {} + +local GuildCreate = {} +local GuildLevel = {} +local GuildPosition = {} +local GuildHeadPortrait = {} +local GuildGift = {} +local GuildNews = {} +local SortedGuildGift = {} +local GuildTrustItems = {} +local GuildTrustItemsList = {} +local GuildTrustItemsCharacterId = {} +local GuildTrustCharacterIdsList = {} +local GuildPresentTemplate = {} +local GuildTalentTemplate = {} +local GuildWelcomeTemplate = {} +local GuildCustomNameTemplate = {} + +local SortedTalentPoint = {} + +XGuildConfig.KEY_LAST_LEVEL = "KeyGuildLastLevel" +XGuildConfig.KEY_LAST_RANK = "KeyGuildLastRank" +XGuildConfig.KEY_CUR_RANK = "KeyGuildCurrentRank" + +XGuildConfig.GuildLikeCoin = 37 -- 点赞道具 +XGuildConfig.GuildContributeCoin = 38 -- 公会贡献 +XGuildConfig.GuildCoin = 39 -- 公会币 +XGuildConfig.GuildTalent = 46 -- 天赋 + +XGuildConfig.GuildPersonalShop = 4001 -- 公会个人商店 +XGuildConfig.GuildPurchaseShop = 9998 -- 公会采购商店 +XGuildConfig.GuildDefaultDay = 7 -- 默认天数 +XGuildConfig.GuildDefaultWelcomeWord = 4 -- 默认迎新语数量 + +XGuildConfig.RecommendLevel = CS.XGame.Config:GetInt("GuildPlayerRecommendLevel") --推荐等级 +XGuildConfig.RecommendCount = CS.XGame.Config:GetInt("GuildPlayerRecommendCountPage") --推荐数量 +XGuildConfig.RecommendPage = CS.XGame.Config:GetInt("GuildPlayerRecommendCountPage") --推荐页数 +XGuildConfig.RecommendRefresh = CS.XGame.Config:GetInt("GuildPlayerRecommendRefresh") --推荐刷新间隔 +XGuildConfig.GuildChatCacheCount = CS.XGame.ClientConfig:GetInt("GuildChatCacheCount") + +XGuildConfig.LikeItemId = CS.XGame.Config:GetInt("GuildLikedItemId") --点赞道具 +XGuildConfig.AddPopularity = CS.XGame.Config:GetInt("GuildAddPopularity") --点赞一次增加的人气数 +XGuildConfig.GloryPointsPerLevel = CS.XGame.Config:GetInt("GuildGloryPointsPerLevel") --荣耀等级每一级所需天赋点数 +XGuildConfig.GuildGloryMaxLevel = CS.XGame.Config:GetInt("GuildGloryMaxLevel") --最高荣耀等级 + +-- 公会宣言/内部通讯字数 +XGuildConfig.AnnouncementWordMaxCount = CS.XGame.ClientConfig:GetInt("GuildAnnouncementMaxLen") +XGuildConfig.InterComWordMaxCount = CS.XGame.ClientConfig:GetInt("GuildInterComMaxLen") + +-- 公会动态最大数量 +XGuildConfig.GuildNewsMaxCount = CS.XGame.ClientConfig:GetInt("GuildNewsMaxCount") +-- 公会招募刷新cd +XGuildConfig.GUildRefreshCDTime = CS.XGame.ClientConfig:GetInt("GuildRefreshRecruitTime") +-- 公会动态刷新频率 +XGuildConfig.GUildNewsRefreshFrequency = 3 +-- 公会主界面刷新cd +XGuildConfig.GuildMainRefreshCD = CS.XGame.ClientConfig:GetInt("GuildMainInfoRefreshTime") + +XGuildConfig.NewsType = { + Guild = 1, + Member = 2, + All = 3, +} + +XGuildConfig.NewsList = { + "All","Guild","Member", +} + +XGuildConfig.NewsName = { + [XGuildConfig.NewsType.All] = CS.XTextManager.GetText("GuildNewsAll"), + [XGuildConfig.NewsType.Guild] = CS.XTextManager.GetText("GuildNewsGuild"), + [XGuildConfig.NewsType.Member] = CS.XTextManager.GetText("GuildNewsMember"), +} + +-- 公会频道、本地缓存数量 +XGuildConfig.CHANNEL_MAX_COUNT = CS.XGame.ClientConfig:GetInt("GuildChannelMaxCount") + +XGuildConfig.EnlistType = { + Recruit = 1, + News = 2 +} + +-- 类型:申请设置、改变职位、公会改名 +XGuildConfig.TipsType = { + ApplySetting = 1, + ChangePosition = 2, + SetName = 3, +} + +-- 文字编辑类型:公告、内部通讯 +XGuildConfig.InformationType = { + Announcement = 1, + InternalCommunication = 2, +} + +-- 申请设置 +XGuildConfig.ApplySetting = { + NoneApply = 1, + NeedApply = 2, + Forbidden = 3, +} + +-- 维护状态 +XGuildConfig.GuildMaintainState = { + Normal = 0, + Urgent = 1, +} + +-- 公会任务 +XGuildConfig.GuildTaskType = { + Daily = 1, + Mainly = 2, +} + +-- 公会创建的ItemId +local GuildCreateCostItemType +-- 公会创建的Item的数量 +local GuildCreateCostItemCount +--公会人员等级 +XGuildConfig.GuildRankLevel = { + Leader = 1, --会长 + CoLeader = 2, --副会长 + Elder = 3, --精英 + Member = 4, --会员 + Tourist = 5, --游客 + Nothing = 9, --啥也不是 +} +XGuildConfig.GUildRankIcon = { + [XGuildConfig.GuildRankLevel.Leader] = CS.XGame.ClientConfig:GetString("GuildRankIcon1"), + [XGuildConfig.GuildRankLevel.CoLeader] = CS.XGame.ClientConfig:GetString("GuildRankIcon2"), + [XGuildConfig.GuildRankLevel.Elder] = CS.XGame.ClientConfig:GetString("GuildRankIcon3"), + [XGuildConfig.GuildRankLevel.Member] = CS.XGame.ClientConfig:GetString("GuildRankIcon4"), + [XGuildConfig.GuildRankLevel.Tourist] = CS.XGame.ClientConfig:GetString("GuildRankIcon5"), +} + +XGuildConfig.GuildChallengeEnter = { + GuildTask = 1, + GuildPet = 2, + GuildBoss = 3 +} + +XGuildConfig.GuildEventType = { + Contribute = 1, + Build = 2, + GiftContribute = 3, + Level = 4, + ApplyChanged = 5, + KickOut = 6, + ContributeReward = 7, + WeeklyReset = 8, + RankLevelChanged = 9, + Talent = 10,--value = 天赋id, value2 = 天赋等级 + TalentPoint = 11,--value = 天赋值 + MemberChanged = 12,--value = 最新人数 + Recruit = 13,--是否有公会邀请 + FreeChangeName = 14, -- 公会被强制改名,获得免费改名机会(仅会长收到) + GuildBossHpBox = 20, --有公会boss血量奖励可以领取 + GuildBossScoreBox = 21, --公会boss积分奖励可以领取 + GuildBossWeeklyTask = 22, --工会boss周长任务 +} + +XGuildConfig.GuildSortType = { + SortByContribute = 1, + SortByLevel = 2, + SortByRankLevel = 3, +} + +XGuildConfig.GuildSortName = { + [XGuildConfig.GuildSortType.SortByContribute] = CS.XTextManager.GetText("GuildSortByContribute"), + [XGuildConfig.GuildSortType.SortByLevel] = CS.XTextManager.GetText("GuildSortByLevel"), + [XGuildConfig.GuildSortType.SortByRankLevel] = CS.XTextManager.GetText("GuildSortByRankLevel"), +} + +--请求推荐数据时间间隔 +XGuildConfig.GuildRequestRecommandTime = CS.XGame.ClientConfig:GetInt("GuildReqRecommandCdTime") +--请求收到的招募数据时间间隔 +XGuildConfig.GuildRequestRecruitTime = 30 +--请求排行列表的时间间隔 +XGuildConfig.GuildRequestRankTime = 10 +--请求游客数据时间间隔 +XGuildConfig.GuildRequestVistorTime = 0 +--公会内部排名页面人数 +XGuildConfig.RankTopListCount = 5 +XGuildConfig.RankBottomPageCount = 6 + +function XGuildConfig.Init() + GuildWelfare = XTableManager.ReadByIntKey(CLIENT_GUILD_WELFARE, XTable.XTableGuildWelfare, "Id") + GuildChallenge = XTableManager.ReadByIntKey(CLIENT_GUILD_CHALLENGE, XTable.XTableGuildChallengeDetails, "Id") + GuildTalentDetails = XTableManager.ReadByIntKey(CLIENT_GUILD_TALENTDETAIL, XTable.XTableGuildTalentDetails, "Id") + + GuildLevel = XTableManager.ReadByIntKey(SHARE_GUILD_LEVEL, XTable.XTableGuildLevel, "Level") + GuildPosition = XTableManager.ReadByIntKey(SHARE_GUILD_POSITION, XTable.XTableGuildPosition, "Id") + GuildHeadPortrait = XTableManager.ReadByIntKey(SHARE_GUILD_HEADPORTRAIT, XTable.XTableGuildHeadPortrait, "Id") + GuildGift = XTableManager.ReadByIntKey(SHARE_GUILD_GIFT, XTable.XTableGuildGift, "Id") + GuildNews = XTableManager.ReadByIntKey(SHARE_GUILD_NEWS, XTable.XTableGuildNews, "Id") + GuildTrustItems = XTableManager.ReadByIntKey(SHARE_GUILD_TRUSTITEM, XTable.XTableCharacterTrustItem, "Id") + GuildCreateCostItemType = CS.XGame.Config:GetInt("GuildCreateCostItemType") + GuildCreateCostItemCount = CS.XGame.Config:GetInt("GuildCreateCostItemCount") + GuildTalentTemplate = XTableManager.ReadByIntKey(SHARE_GUILD_TALENT, XTable.XTableGuildTalent, "Id") + GuildPresentTemplate = XTableManager.ReadByIntKey(SHARE_GUILD_PRESENT, XTable.XTableGuildPresent, "Id") + + XGuildConfig.InitGuildGift() + XGuildConfig.InitGuildTalent() +end + +function XGuildConfig.InitGuildGift() + for _, v in pairs(GuildGift or {}) do + if not SortedGuildGift[v.GuildLevel] then + SortedGuildGift[v.GuildLevel] = {} + end + + if not SortedGuildGift[v.GuildLevel][v.GiftLevel] then + SortedGuildGift[v.GuildLevel][v.GiftLevel] = {} + end + + SortedGuildGift[v.GuildLevel][v.GiftLevel] = v + end +end + +function XGuildConfig.GetCreateCostItemType() + return GuildCreateCostItemType +end + +function XGuildConfig.GetCreateCostItemCount() + return GuildCreateCostItemCount +end + +function XGuildConfig.GetGuildWelfares() + return GuildWelfare +end + +function XGuildConfig.GetGuildWelfareById(id) + local welfareData = GuildWelfare[id] + if not welfareData then + XLog.ErrorTableDataNotFound("XGuildConfig.GetGuildWelfareById", "GuildWelfare", CLIENT_GUILD_WELFARE, "Id", tostring(id)) + return + end + return welfareData +end + +function XGuildConfig.GetGuildChallenges() + return GuildChallenge +end + +function XGuildConfig.GetGuildChallengeById(id) + local challengeData = GuildChallenge[id] + if not challengeData then + XLog.ErrorTableDataNotFound("XGuildConfig.GetGuildChallengeById", "GuildChallengeDetails", CLIENT_GUILD_CHALLENGE, "Id", tostring(id)) + return + end + return challengeData +end + +function XGuildConfig.GetGuildLevelDataBylevel(level) + local guildLevelData = GuildLevel[level] + if not guildLevelData then + return + end + return guildLevelData +end + +function XGuildConfig.GetGuildLevelDatas() + return GuildLevel +end + +--公会容量 +function XGuildConfig.GetGuildCapacityByLevel(level) + local guildLevelData = XGuildConfig.GetGuildLevelDataBylevel(level) + if not guildLevelData then + return + end + return guildLevelData.Capacity +end + +--每天可求助次数 +function XGuildConfig.GetGuildWishMaxCountByLevel(level) + local guildLevelData = XGuildConfig.GetGuildLevelDataBylevel(level) + if not guildLevelData then + return + end + return guildLevelData.WishMaxCount +end + +-- 每天可捐献次数 +function XGuildConfig.GetGuildWishContributeMaxCountByLevel(level) + local guildLevelData = XGuildConfig.GetGuildLevelDataBylevel(level) + if not guildLevelData then + return + end + return guildLevelData.WishContributeMaxCount +end + +function XGuildConfig.GetGuildPositionById(id) + local guildPositionData = GuildPosition[id] + if not guildPositionData then + XLog.ErrorTableDataNotFound("XGuildConfig.GetGuildPositionById", "GuildPosition", SHARE_GUILD_POSITION, "Id", tostring(id)) + return + end + return guildPositionData +end + +function XGuildConfig.GetAllGuildPositions() + return GuildPosition +end + +function XGuildConfig.GetGuildHeadPortraitById(id) + local headPortraitData = GuildHeadPortrait[id] + if not headPortraitData then + XLog.ErrorTableDataNotFound("XGuildConfig.GetGuildHeadPortraitById", "GuildHeadPortrait", SHARE_GUILD_HEADPORTRAIT, "Id", tostring(id)) + return + end + return headPortraitData +end + +function XGuildConfig.GetGuildHeadPortraitDatas() + return GuildHeadPortrait +end + +function XGuildConfig.GetGuildHeadPortraitIconById(id) + local headPortraitData = GuildHeadPortrait[id] + if not headPortraitData then + XLog.ErrorTableDataNotFound("XGuildConfig.GetGuildHeadPortraitById", "GuildHeadPortrait", SHARE_GUILD_HEADPORTRAIT, "Id", tostring(id)) + return + end + return headPortraitData.Icon +end + +function XGuildConfig.GetGuildGiftByGuildLevelAndGiftLevel(guildLv, giftLv) + if not SortedGuildGift[guildLv] or not SortedGuildGift[guildLv][giftLv] then + return + end + return SortedGuildGift[guildLv][giftLv] +end + +function XGuildConfig.GetGuildGiftByGuildLevel(guildLv) + if SortedGuildGift[guildLv] then + table.sort(SortedGuildGift[guildLv], function(gift1, gift2) + return gift1.GiftLevel < gift2.GiftLevel + end) + return SortedGuildGift[guildLv] + end +end + +function XGuildConfig.GetGuildGiftById(guildId) + if not GuildGift[guildId] then + XLog.ErrorTableDataNotFound("XGuildConfig.GetGuildGiftById", "GuildGift", SHARE_GUILD_GIFT, "guildId", tostring(guildId)) + return + end + return GuildGift[guildId] +end + +function XGuildConfig.GetGuildNewsById(msgId) + if not GuildNews[msgId] then + XLog.ErrorTableDataNotFound("XGuildConfig.GetGuildNewsById", "GuildNews", SHARE_GUILD_NEWS, "Id", tostring(msgId)) + return + end + return GuildNews[msgId] +end + +function XGuildConfig.InitCharacterTrustItems() + for _, v in pairs(GuildTrustItems) do + local favorCharacterIds = v.FavorCharacterId + for _, id in pairs(favorCharacterIds) do + if not GuildTrustItemsCharacterId[id] then + GuildTrustItemsCharacterId[id] = {} + table.insert(GuildTrustCharacterIdsList, { Id = id }) + end + table.insert(GuildTrustItemsCharacterId[id], v.Id) + end + end +end + +function XGuildConfig.GetTrustItemsByCharacterId(id) + if not next(GuildTrustItemsCharacterId) then + XGuildConfig.InitCharacterTrustItems() + end + return GuildTrustItemsCharacterId[id] +end + +function XGuildConfig.GetGuildTrustItemsList() + if not next(GuildTrustItemsList) then + for _, v in pairs(GuildTrustItems) do + if v.FavorCharacterId and #(v.FavorCharacterId) > 0 then + table.insert(GuildTrustItemsList, { Id = v.Id }) + end + end + end + return GuildTrustItemsList +end + +function XGuildConfig.GetTrustCharacterIds() + if not next(GuildTrustCharacterIdsList) then + XGuildConfig.InitCharacterTrustItems() + end + return GuildTrustCharacterIdsList +end + +-- 送礼 +function XGuildConfig.GetGuildPresentById(id) + if not GuildPresentTemplate[id] then + XLog.ErrorTableDataNotFound("XGuildConfig.GetGuildPresentById", "GuildPresentTemplate", SHARE_GUILD_PRESENT, "Id", tostring(id)) + return + end + return GuildPresentTemplate[id] +end + +function XGuildConfig.GetAllGuildPresent() + return GuildPresentTemplate +end + +-- 天赋 +function XGuildConfig.GetGuildTalentById(id) + if not GuildTalentTemplate[id] then + XLog.ErrorTableDataNotFound("XGuildConfig.GetGuildTalentById", "GuildTalentTemplate", SHARE_GUILD_TALENT, "Id", tostring(id)) + return + end + return GuildTalentTemplate[id] +end + +function XGuildConfig.GetGuildTalentConfigById(id) + if not GuildTalentDetails[id] then + XLog.ErrorTableDataNotFound("XGuildConfig.GetGuildTalentConfigById", "GuildTalentDetails", CLIENT_GUILD_TALENTDETAIL, "Id", tostring(id)) + return + end + return GuildTalentDetails[id] +end + +function XGuildConfig.InitGuildTalent() + for _, v in pairs(GuildTalentDetails) do + SortedTalentPoint[v.IndexInMap] = { + Id = v.Id, + IndexInMap = v.IndexInMap + } + end + for _, v in pairs(GuildTalentTemplate) do + local childIndex = GuildTalentDetails[v.Id].IndexInMap + for i = 1, #v.Parent do + local curId = v.Parent[i] + if curId > 0 then + local curIndex = GuildTalentDetails[curId].IndexInMap + if SortedTalentPoint[curIndex] then + if not SortedTalentPoint[curIndex].ChildNodes then + SortedTalentPoint[curIndex].ChildNodes = {} + end + SortedTalentPoint[curIndex].ChildNodes[v.Id] = childIndex + end + end + end + end +end + +function XGuildConfig.GetSortedTalentPoints() + return SortedTalentPoint +end + +function XGuildConfig.GetDefaultWelcomeWords() + if not next(GuildWelcomeTemplate) then + GuildWelcomeTemplate = XTableManager.ReadByIntKey(CLIENT_GUILD_WELCOME, XTable.XTableGuildWelcome, "Id") + end + return GuildWelcomeTemplate +end + +function XGuildConfig.GetCustomNameTemplate() + if not next(GuildCustomNameTemplate) then + GuildCustomNameTemplate = XTableManager.ReadByIntKey(SHARE_GUILD_CUSTOMNAME, XTable.XTableGuildCustomName, "Id") + end + return GuildCustomNameTemplate +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XHeadPortraitConfigs.lua b/Resources/Scripts/XConfig/XHeadPortraitConfigs.lua new file mode 100644 index 00000000..699862ae --- /dev/null +++ b/Resources/Scripts/XConfig/XHeadPortraitConfigs.lua @@ -0,0 +1,29 @@ +local TABLE_HEADPORTRAITS = "Share/HeadPortrait/HeadPortrait.tab" +XHeadPortraitConfigs = XHeadPortraitConfigs or {} + +XHeadPortraitConfigs.HeadTimeLimitType = { + Forever = 0, + Duration = 1, + FixedTime = 2, +} + +XHeadPortraitConfigs.HeadType = { + HeadPortrait = 1, + HeadFrame = 2, +} + +XHeadPortraitConfigs.BtnState = { + Use = 1, + NonUse = 2, +} + +local HeadPortraitsCfg = {} + +function XHeadPortraitConfigs.Init() + HeadPortraitsCfg = XTableManager.ReadByIntKey(TABLE_HEADPORTRAITS, XTable.XTableHeadPortrait, "Id") +end + +function XHeadPortraitConfigs.GetHeadPortraitsCfg() + return HeadPortraitsCfg +end + diff --git a/Resources/Scripts/XConfig/XHelpCourseConfig.lua b/Resources/Scripts/XConfig/XHelpCourseConfig.lua new file mode 100644 index 00000000..d2185e60 --- /dev/null +++ b/Resources/Scripts/XConfig/XHelpCourseConfig.lua @@ -0,0 +1,44 @@ +XHelpCourseConfig = XHelpCourseConfig or {} + +local TABLE_HELP_COURSE_PATH = "Client/HelpCourse/HelpCourse.tab" +local HelpCourseTemplate = {} +local HelpCourseTemplateIndex = {} + +function XHelpCourseConfig.Init() + HelpCourseTemplate = XTableManager.ReadByIntKey(TABLE_HELP_COURSE_PATH, XTable.XTableHelpCourse, "Id") + for _,v in pairs(HelpCourseTemplate) do + HelpCourseTemplateIndex[v.Function] = v + end + end + +--获取帮助教程表 +function XHelpCourseConfig.GetHelpCourseTemplate() + return HelpCourseTemplate +end + +--通过Id获取 +function XHelpCourseConfig.GetHelpCourseTemplateById(id) + if HelpCourseTemplate == nil then + return + end + + if not HelpCourseTemplate[id] then + XLog.ErrorTableDataNotFound("XHelpCourseConfig.GetHelpCourseTemplateById", "HelpCourse", TABLE_HELP_COURSE_PATH, "Id", tostring(id)) + end + + return HelpCourseTemplate[id] +end + +--通过功能获取 +function XHelpCourseConfig.GetHelpCourseTemplateByFunction(key) + if HelpCourseTemplateIndex == nil then + return + end + + if not HelpCourseTemplateIndex[key] then + XLog.ErrorTableDataNotFound("XHelpCourseConfig.GetHelpCourseTemplateByFunction", + "HelpCourse", TABLE_HELP_COURSE_PATH, "Function", tostring(key)) + end + + return HelpCourseTemplateIndex[key] +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XHostelConfigs.lua b/Resources/Scripts/XConfig/XHostelConfigs.lua new file mode 100644 index 00000000..66d6e211 --- /dev/null +++ b/Resources/Scripts/XConfig/XHostelConfigs.lua @@ -0,0 +1,141 @@ +XHostelConfigs = XHostelConfigs or {} + +local tableInsert = table.insert +local pairs = pairs + +local TABLE_HOSTELROOM_PATH = "Share/Hostel/HostelRoom.tab" +local TABLE_HOSTEL_FUNCDEVICE_PATH = "Share/Hostel/FunctionDevice.tab" +local TABLE_HOSTEL_REST_PATH = "Share/Hostel/HostelRest.tab" +local TABLE_HOSTEL_ROOM_NODE_PATH = "Client/Hostel/HostelRoomNode.tab" +local TABLE_HOSTEL_DEVICE_NODE_PATH = "Client/Hostel/HostelDeviceNode.tab" +local TABLE_HOSTEL_HUD_PATH = "Client/Hostel/HostelHud.tab" + +local SceneToHostelRoomNodeMap = {} +local SceneToHostelDeviceNodeMap = {} +local HostelRoomTemplate = {} +local HostelRoomFloorList = {} +local FunctionDeviceLvlTemplate = {} +local FunctionDeviceSubType = {} +local HostelRestTemplate = {} +local HostelHudTemplate = {} + +local HostelMaxFloor = 0 +local MaxCharacterVitality = 0 + +local FuncFindInList = function(tList, value) + for _, v in ipairs(tList) do + if v == value then + return true + end + end + return false +end + +function XHostelConfigs.Init() + local rooms = XTableManager.ReadByIntKey(TABLE_HOSTEL_ROOM_NODE_PATH, XTable.XTableHostelRoomNode, "Id") + for _, config in pairs(rooms) do + local sceneTab = SceneToHostelRoomNodeMap[config.Scene] + if not sceneTab then + sceneTab = {} + SceneToHostelRoomNodeMap[config.Scene] = sceneTab + end + + sceneTab[config.Id] = config + end + + local configs = XTableManager.ReadByIntKey(TABLE_HOSTEL_DEVICE_NODE_PATH, XTable.XTableHostelDeviceNode, "Id") + for _, config in pairs(configs) do + local sceneTab = SceneToHostelDeviceNodeMap[config.Scene] + if not sceneTab then + sceneTab = {} + SceneToHostelDeviceNodeMap[config.Scene] = sceneTab + end + + local roomTab = sceneTab[config.RoomType] + if not roomTab then + roomTab = {} + sceneTab[config.RoomType] = roomTab + end + + roomTab[config.Id] = config + end + + local hudConfigs = XTableManager.ReadByIntKey(TABLE_HOSTEL_HUD_PATH, XTable.XTableHostelHud, "Id") + for _, config in pairs(hudConfigs) do + local hudTypeMap = HostelHudTemplate[config.HudType] + if not hudTypeMap then + hudTypeMap = {} + HostelHudTemplate[config.HudType] = hudTypeMap + end + hudTypeMap[config.DeviceType] = config + end + + MaxCharacterVitality = CS.XGame.Config:GetInt("MaxCharacterVitality") + + HostelRoomTemplate = XTableManager.ReadByIntKey(TABLE_HOSTELROOM_PATH, XTable.XTableHostelRoom, "Id") + for k, v in pairs(HostelRoomTemplate) do + if not HostelRoomFloorList[v.Floor] then + HostelRoomFloorList[v.Floor] = {} + end + HostelRoomFloorList[v.Floor][k] = v + end + + local totalFuncDeviceData = XTableManager.ReadByIntKey(TABLE_HOSTEL_FUNCDEVICE_PATH, XTable.XTableFunctionDevice, "Id") + for _, v in pairs(totalFuncDeviceData) do + if not FunctionDeviceLvlTemplate[v.Type] then + FunctionDeviceLvlTemplate[v.Type] = {} + end + FunctionDeviceLvlTemplate[v.Type][v.Level] = v + if v.BelongType and v.BelongType ~= 0 then + if not FunctionDeviceSubType[v.BelongType] then + FunctionDeviceSubType[v.BelongType] = {} + end + local tTypeList = FunctionDeviceSubType[v.BelongType] + if not FuncFindInList(tTypeList, v.Type) then + tableInsert(tTypeList, v.Type) + end + end + end + + HostelRestTemplate = XTableManager.ReadByIntKey(TABLE_HOSTEL_REST_PATH, XTable.XTableHostelRest, "Floor") + for floor, _ in pairs(HostelRestTemplate) do + if floor > HostelMaxFloor then + HostelMaxFloor = floor + end + end + + XHostelConfigs.HostelMaxFloor = HostelMaxFloor + XHostelConfigs.MaxCharacterVitality = MaxCharacterVitality +end + +function XHostelConfigs.GetSceneToHostelRoomNodeMap() + return SceneToHostelRoomNodeMap +end + +function XHostelConfigs.GetSceneToHostelDeviceNodeMap() + return SceneToHostelDeviceNodeMap +end + +function XHostelConfigs.GetHostelRoomTemplate() + return HostelRoomTemplate +end + +function XHostelConfigs.GetHostelRoomFloorList() + return HostelRoomFloorList +end + +function XHostelConfigs.GetFunctionDeviceLvlTemplate() + return FunctionDeviceLvlTemplate +end + +function XHostelConfigs.GetFunctionDeviceSubType() + return FunctionDeviceSubType +end + +function XHostelConfigs.GetHostelRestTemplate() + return HostelRestTemplate +end + +function XHostelConfigs.GetHostelHudTemplate() + return HostelHudTemplate +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XInvertCardGameConfig.lua b/Resources/Scripts/XConfig/XInvertCardGameConfig.lua new file mode 100644 index 00000000..c3cb0c77 --- /dev/null +++ b/Resources/Scripts/XConfig/XInvertCardGameConfig.lua @@ -0,0 +1,220 @@ +local tableInsert = table.insert + +XInvertCardGameConfig = XInvertCardGameConfig or {} + +XInvertCardGameConfig.InvertCardGameStageStatusType = { + Lock = 0, -- 锁定状态 + Process = 1, -- 进行状态 + Finish = 2, -- 完成状态 +} + +XInvertCardGameConfig.InvertCardGameRewardTookState = { + NotFinish = 1, -- 未完成 + NotTook = 2, -- 完成未领取 + Took = 3, -- 已领取 +} + +XInvertCardGameConfig.InvertCardGameCardState = { + Back = 1, -- 背面 + Front = 2, -- 正面 + Finish = 3, -- 完成(消失状态) +} + +XInvertCardGameConfig.HitFaceHelpState = { + NotHit = 0, + Hited = 1, +} + +-- 开始游戏状态 +XInvertCardGameConfig.InvertCardGameStartStage = { + NotStart = 0, -- 没点击开始 + Started = 1, -- 开始过了 +} + +XInvertCardGameConfig.INVERT_CARD_GAME_HELP_HIT_KEY = "INVERT_CARD_GAME_HELP_HIT_KEY" -- 游戏帮助打脸键 +XInvertCardGameConfig.INVERT_CARD_GAME_START_STATE_KEY = "INVERT_CARD_GAME_START_STATE_KEY" -- 开始状态信息键 + +local INVERT_CARD_GAME_PATH = "Share/MiniActivity/InvertCardGame/InvertCardGame.tab" +local INVERT_CARD_STAGE_PATH = "Share/MiniActivity/InvertCardGame/InvertCardStage.tab" +local INVERT_CARD_CARD_PATH = "Share/MiniActivity/InvertCardGame/InvertCard.tab" + +local InvertCardGameTemplates = {} +local InvertCardStageTemplates = {} +local InvertCardGameCardTemplates = {} + +function XInvertCardGameConfig.Init() + InvertCardGameTemplates = XTableManager.ReadByIntKey(INVERT_CARD_GAME_PATH, XTable.XTableInvertCardGame, "Id") + InvertCardStageTemplates = XTableManager.ReadByIntKey(INVERT_CARD_STAGE_PATH, XTable.XTableInvertCardStage, "Id") + InvertCardGameCardTemplates = XTableManager.ReadByIntKey(INVERT_CARD_CARD_PATH, XTable.XTableInvertCard, "Id") +end + +function XInvertCardGameConfig.GetInvertCardGameTemplateById(id) + if not InvertCardGameTemplates or not InvertCardGameTemplates[id] then + XLog.Error("Can't Find Invert Card Game Template By Id:"..id.." Please Check "..INVERT_CARD_GAME_PATH) + return nil + end + + return InvertCardGameTemplates[id] +end + +function XInvertCardGameConfig.GetActivityTimeId(id) + local gameTemplate = XInvertCardGameConfig.GetInvertCardGameTemplateById(id) + if not gameTemplate then + return nil + end + + return gameTemplate.TimeId +end + +function XInvertCardGameConfig.GetConsumeItemId(id) + local gameTemplate = XInvertCardGameConfig.GetInvertCardGameTemplateById(id) + if not gameTemplate then + return nil + end + + return gameTemplate.ItemId +end + +function XInvertCardGameConfig.GetHelpId(id) + local gameTemplate = XInvertCardGameConfig.GetInvertCardGameTemplateById(id) + if not gameTemplate then + return nil + end + + return gameTemplate.HelpId +end + +function XInvertCardGameConfig.GetStorySkipId(id) + local gameTemplate = XInvertCardGameConfig.GetInvertCardGameTemplateById(id) + if not gameTemplate then + return nil + end + + return gameTemplate.StorySkipId +end + +function XInvertCardGameConfig.GetActivityStageIds(id) + local gameTemplate = XInvertCardGameConfig.GetInvertCardGameTemplateById(id) + if not gameTemplate then + return nil + end + + return gameTemplate.ActivityStageIds +end + +function XInvertCardGameConfig.GetInvertCardStageTemplateById(id) + if not InvertCardStageTemplates or not InvertCardStageTemplates[id] then + XLog.Error("Can't Find Invert Card Stage Template By Id:"..id.." Please Check "..INVERT_CARD_STAGE_PATH) + return nil + end + + return InvertCardStageTemplates[id] +end + +function XInvertCardGameConfig.GetStageNameById(id) + local stageTemplate = XInvertCardGameConfig.GetInvertCardStageTemplateById(id) + if not stageTemplate then + return nil + end + + return stageTemplate.Name +end + +function XInvertCardGameConfig.GetStageRowAndColumnCountById(id) + local stageTemplate = XInvertCardGameConfig.GetInvertCardStageTemplateById(id) + if not stageTemplate then + return nil + end + + return stageTemplate.RowCount, stageTemplate.ColumnCount +end + +function XInvertCardGameConfig.GetStageContainCardsById(id) + local stageTemplate = XInvertCardGameConfig.GetInvertCardStageTemplateById(id) + if not stageTemplate then + return nil + end + + return stageTemplate.ContainCards +end + +function XInvertCardGameConfig.GetStageCostCoinNumById(id) + local stageTemplate = XInvertCardGameConfig.GetInvertCardStageTemplateById(id) + if not stageTemplate then + return nil + end + + return stageTemplate.CostCoinNum +end + +function XInvertCardGameConfig.GetStageMaxCostNumById(id) + local stageTemplate = XInvertCardGameConfig.GetInvertCardStageTemplateById(id) + if not stageTemplate then + return nil + end + + return stageTemplate.MaxCostNum +end + +function XInvertCardGameConfig.GetStageTargetNumById(id) + local stageTemplate = XInvertCardGameConfig.GetInvertCardStageTemplateById(id) + if not stageTemplate then + return nil + end + + return stageTemplate.TargetNum +end + +function XInvertCardGameConfig.GetStageFinishProgressById(id) + local stageTemplate = XInvertCardGameConfig.GetInvertCardStageTemplateById(id) + if not stageTemplate then + return nil + end + + return stageTemplate.FinishProgress +end + +function XInvertCardGameConfig.GetStageRewardsById(id) + local stageTemplate = XInvertCardGameConfig.GetInvertCardStageTemplateById(id) + if not stageTemplate then + return nil + end + + return stageTemplate.Rewards +end + +function XInvertCardGameConfig.GetStageMaxOnCardsNumById(id) + local stageTemplate = XInvertCardGameConfig.GetInvertCardStageTemplateById(id) + if not stageTemplate then + return nil + end + + return stageTemplate.MaxOnCardsNum +end + +function XInvertCardGameConfig.GetStageFailedPunishNumById(id) + local stageTemplate = XInvertCardGameConfig.GetInvertCardStageTemplateById(id) + if not stageTemplate then + return nil + end + + return stageTemplate.FailedPunishNum +end + +function XInvertCardGameConfig.GetInvertCardTemplateById(id) + if not InvertCardGameCardTemplates or not InvertCardGameCardTemplates[id] then + XLog.Error("Can't Find Invert Card Template By Id:"..id.." Please Check "..INVERT_CARD_CARD_PATH) + return nil + end + + return InvertCardGameCardTemplates[id] +end + +function XInvertCardGameConfig.GetCardBaseIconById(id) + local cardTemplate = XInvertCardGameConfig.GetInvertCardTemplateById(id) + if not cardTemplate then + return nil + end + + return cardTemplate.BaseIcon +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XItemConfigs.lua b/Resources/Scripts/XConfig/XItemConfigs.lua new file mode 100644 index 00000000..1ed449f7 --- /dev/null +++ b/Resources/Scripts/XConfig/XItemConfigs.lua @@ -0,0 +1,208 @@ +local tableInsert = table.insert +local tableSort = table.sort + +XItemConfigs = XItemConfigs or {} + +local XItemTemplate = require("XEntity/XItem/XItemTemplate") +local XCharacterExpTemplate = require("XEntity/XItem/XCharacterExpTemplate") +local XEquipExpTemplate = require("XEntity/XItem/XEquipExpTemplate") +local XGiftTemplate = require("XEntity/XItem/XGiftTemplate") +local XPartnerExpTemplate = require("XEntity/XItem/XPartnerExpTemplate") + +local TABLE_ITEM_PATH = "Share/Item/Item.tab" +local TABLE_BUY_ASSET_PATH = "Share/Item/BuyAsset.tab" +local TABLE_BUY_ASSET_CONFIG_PATH = "Share/Item/BuyAssetConfig.tab" +local TABLE_UI_BUY_ASSET_PATH = "Share/Item/UiBuyAsset.tab" + +local BuyAssetTemplates = {} -- 购买资源配置表 +local BuyAssetDailyLimit = {} -- 购买资源每日限制 +local ItemTemplates = {} +local BuyAssetType = {} --购买资源的类型 +local BuyAssetCanMutiply = {} --是否可以批量购买 +local BuyAssetAutoClose = {} +local BuyAssetUis = {} -- 可以开启快捷购买的上一级Ui名 + +XItemConfigs.SuitAllType = { + DefaultAll = 0, + All = 1, +} + +XItemConfigs.Quality = { + One = 1, + Two = 2, + Three = 3, + Four = 4, + Five = 5, + Six = 6, +} + +XItemConfigs.FastTrading = { + NotFastTrading = 0, + CanFastTrading = 1, +} + +XItemConfigs.ItemType = { + Assert = 1 << 0, -- 资源 + Money = 1 << 1 | 1 << 0, -- 货币,包括金币和钻石 + Material = 1 << 2, -- 材料 + Fragment = 1 << 3, -- 碎片 + Gift = 1 << 4, -- 礼包 + WeaponFashion = 1 << 5, -- 武器时装增加时限道具 + + CardExp = 1 << 11 | 1 << 2, -- 卡牌exp + EquipExp = 1 << 12 | 1 << 2, -- 装备exp 4100 + EquipExpNotInBag = 1 << 12 | 1 << 3, -- 装备exp(不显示在背包中) 4104 + EquipResonanace = 1 << 13 | 1 << 2, -- 装备共鸣道具 + FurnitureItem = 1 << 14 | 1 << 2, -- 家具图纸 + + + ExchangeMoney = 1 << 16 | 1 << 2, -- 兑换货币 + SpExchangeMoney = 1 << 17 | 1 << 2, -- 特殊兑换货币 + UnShow = 1 << 18 | 1 << 2, -- 不显示物品 + FavorGift = 1 << 19 | 1 << 2, -- 好感度礼物 + ActiveMoney = 1 << 20 | 1 << 2, -- 活动货币 + PlayingMoney = 1 << 21 | 1 << 2, -- 玩法货币 + PlayingItem = 1 << 22 | 1 << 2, -- 玩法系统道具 + TRPGItem = 1 << 23 | 1 << 2, --跑图系统道具 + PartnerExp = 1 << 25 | 1 << 2, -- 宠物exp + +} + +-- 背包显示的材料 +XItemConfigs.Materials = { + XItemConfigs.ItemType.Gift, + XItemConfigs.ItemType.CardExp, + XItemConfigs.ItemType.EquipExp, + XItemConfigs.ItemType.Material, + XItemConfigs.ItemType.EquipResonanace, + XItemConfigs.ItemType.ExchangeMoney, + XItemConfigs.ItemType.SpExchangeMoney, + XItemConfigs.ItemType.FavorGift, + XItemConfigs.ItemType.ActiveMoney, + XItemConfigs.ItemType.PlayingItem, + XItemConfigs.ItemType.PartnerExp, +} + +--背包页签类型 +XItemConfigs.PageType = { + Equip = 1, --武器 + SuitCover = 2, --意识套装封面 + Material = 3, --材料 + Fragment = 4, --碎片 + Awareness = 5, --意识 + Partner = 6, --伙伴 +} + +function XItemConfigs.Init() + local itemTable = XTableManager.ReadByIntKey(TABLE_ITEM_PATH, XTable.XTableItem, "Id") + + for k, item in pairs(itemTable) do + local template = XItemTemplate.New(item) + + if item.ItemType == XItemConfigs.ItemType.CardExp then + template = XCharacterExpTemplate.New(template) + elseif item.ItemType == XItemConfigs.ItemType.EquipExp + or item.ItemType == XItemConfigs.ItemType.EquipExpNotInBag then + template = XEquipExpTemplate.New(template) + elseif item.ItemType == XItemConfigs.ItemType.Gift then + template = XGiftTemplate.New(template) + elseif item.ItemType == XItemConfigs.ItemType.PartnerExp then + template = XPartnerExpTemplate.New(template) + end + + ItemTemplates[k] = template + end + + local bATemplates = XTableManager.ReadByIntKey(TABLE_BUY_ASSET_PATH, XTable.XTableBuyAsset, "Id") + local bACTemplates = XTableManager.ReadByIntKey(TABLE_BUY_ASSET_CONFIG_PATH, XTable.XTableBuyAssetConfig, "Id") + BuyAssetUis = XTableManager.ReadByIntKey(TABLE_UI_BUY_ASSET_PATH, XTable.XTableUiBuyAsset, "Id") + + for id, tab in pairs(bATemplates) do + BuyAssetDailyLimit[id] = tab.DailyLimit + BuyAssetType[id] = tab.ExchangeType + BuyAssetCanMutiply[id] = tab.CanMutiply + BuyAssetAutoClose[id] = tab.AutoClose + + local configs = {} + for _, config in pairs(tab.Config) do + local buyConfig = bACTemplates[config] + if not buyConfig then + XLog.ErrorTableDataNotFound("XItemConfigs.Init", "BuyAssetConfig", + TABLE_BUY_ASSET_CONFIG_PATH, "Id", tostring(config) .. "来自关联表" .. TABLE_BUY_ASSET_PATH .. "Id :" .. tostring(id) .. " 的Config") + return + end + + for _, consume in pairs(buyConfig.ConsumeId) do + if not ItemTemplates[consume] then + local tmpStr = tostring(buyConfig.ConsumeId) .. "来自关联表" .. TABLE_BUY_ASSET_CONFIG_PATH .. "Id :" .. tostring(consume) .. " 的ConsumeId" + XLog.ErrorTableDataNotFound("XItemConfigs.Init", "Item", TABLE_ITEM_PATH, "Id", tmpStr) + return + end + end + + tableInsert(configs, bACTemplates[config]) + end + + tableSort(configs, function(a, b) + return a.Times < b.Times + end) + + BuyAssetTemplates[id] = configs + end +end + +function XItemConfigs.GetItemTemplates() + return ItemTemplates +end + +function XItemConfigs.GetBuyAssetDailyLimit() + return BuyAssetDailyLimit +end + +function XItemConfigs.GetBuyAssetTemplates() + return BuyAssetTemplates +end + +function XItemConfigs.GetBuyAssetType(id) + return BuyAssetType[id] +end + +function XItemConfigs.GetBuyAssetCanMutiply(id) + return BuyAssetCanMutiply[id] +end + +function XItemConfigs.GetBuyAssetLimit(id) + return BuyAssetDailyLimit[id] +end + +function XItemConfigs.GetBuyAssetAutoClose(id) + return BuyAssetAutoClose[id] +end + +function XItemConfigs.GetFastTrading(id) + if not ItemTemplates[id] then + return nil + end + + return ItemTemplates[id].FastTrading +end + +function XItemConfigs.GetUiBuyAsset() + return BuyAssetUis +end + +function XItemConfigs.GetItemNameById(id) + if not ItemTemplates[id] then + return "" + end + + return ItemTemplates[id].Name +end + +function XItemConfigs.GetItemIconById(id) + if not ItemTemplates[id] then + return nil + end + + return ItemTemplates[id].Icon +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XKillZoneConfigs.lua b/Resources/Scripts/XConfig/XKillZoneConfigs.lua new file mode 100644 index 00000000..8cf28949 --- /dev/null +++ b/Resources/Scripts/XConfig/XKillZoneConfigs.lua @@ -0,0 +1,626 @@ +local tonumber = tonumber +local tableInsert = table.insert +local tableSort = table.sort +local ipairs = ipairs +local pairs = pairs +local CSXTextManagerGetText = CS.XTextManager.GetText + +XKillZoneConfigs = XKillZoneConfigs or {} + +XKillZoneConfigs.ItemIdCoinA = 62411 --货币A +XKillZoneConfigs.ItemIdCoinB = 62412 --货币B + +-----------------活动相关 begin----------------- +local TABLE_ACITIVTY_PATH = "Share/Fuben/KillZone/KillZoneActivity.tab" + +local ActivityConfig = {} + +local function InitActivityConfig() + ActivityConfig = XTableManager.ReadByIntKey(TABLE_ACITIVTY_PATH, XTable.XTableKillZoneActivity, "Id") +end + +local function GetActivityConfig(activityId) + local config = ActivityConfig[activityId] + if not config then + XLog.Error("XKillZoneConfigs GetActivityConfig error:配置不存在, activityId:" .. activityId .. ",path: " .. TABLE_ACITIVTY_PATH) + return + end + return config +end + +local function GetActivityTimeId(activityId) + local config = GetActivityConfig(activityId) + return config.OpenTimeId +end + +function XKillZoneConfigs.GetDefaultActivityId() + local defaultActivityId = 0 + for activityId, config in pairs(ActivityConfig) do + defaultActivityId = activityId + if XTool.IsNumberValid(config.ActivityTimeId) + and XFunctionManager.CheckInTimeByTimeId(config.ActivityTimeId) then + break + end + end + return defaultActivityId +end + +function XKillZoneConfigs.GetActivityStartTime(activityId) + local config = GetActivityConfig(activityId) + return XFunctionManager.GetStartTimeByTimeId(GetActivityTimeId(activityId)) +end + +function XKillZoneConfigs.GetActivityEndTime(activityId) + return XFunctionManager.GetEndTimeByTimeId(GetActivityTimeId(activityId)) +end + +function XKillZoneConfigs.GetActivityBg(activityId) + local config = GetActivityConfig(activityId) + return config.ActivityBg or "" +end + +function XKillZoneConfigs.GetActivityName(activityId) + local config = GetActivityConfig(activityId) + return config.Name or "" +end + +function XKillZoneConfigs.GetActivityResetPluginSpend(activityId) + local config = GetActivityConfig(activityId) + return config.ResetPluginSpend or 0 +end + +function XKillZoneConfigs.GetActivityChapterIds(activityId) + local chapterIds = {} + local config = GetActivityConfig(activityId) + for _, chapterId in pairs(config.ChapterId) do + if XTool.IsNumberValid(chapterId) then + tableInsert(chapterIds, chapterId) + end + end + return chapterIds +end +-----------------活动相关 end------------------- +-----------------章节相关 begin------------------- +local TABLE_CHAPTER_PATH = "Share/Fuben/KillZone/KillZoneChapter.tab" + +local ChapterConfig = {} + +XKillZoneConfigs.Difficult = { + Normal = 1, + Hard = 2, +} + +local function InitChapterConfig() + ChapterConfig = XTableManager.ReadByIntKey(TABLE_CHAPTER_PATH, XTable.XTableKillZoneChapter, "Id") +end + +local function GetChapterConfig(chapterId) + local config = ChapterConfig[chapterId] + if not config then + XLog.Error("XKillZoneConfigs GetChapterConfig error:配置不存在, chapterId:" .. chapterId .. ",path: " .. TABLE_CHAPTER_PATH) + return + end + return config +end + +function XKillZoneConfigs.GetChapterConfigPath() + return TABLE_CHAPTER_PATH +end + +function XKillZoneConfigs.GetChapterDiff(chapterId) + local config = GetChapterConfig(chapterId) + return config.Diff +end + +function XKillZoneConfigs.GetChapterName(chapterId) + local config = GetChapterConfig(chapterId) + return config.Name or "" +end + +function XKillZoneConfigs.GetChapterBg(chapterId) + local config = GetChapterConfig(chapterId) + return config.Bg or "" +end + +function XKillZoneConfigs.GetChapterTimeId(chapterId) + local config = GetChapterConfig(chapterId) + return config.OpenTimeId +end + +function XKillZoneConfigs.GetChapterStageIds(chapterId) + local stageIds = {} + local config = GetChapterConfig(chapterId) + for _, stageId in pairs(config.StageId) do + if XTool.IsNumberValid(stageId) then + tableInsert(stageIds, stageId) + end + end + return stageIds +end + +function XKillZoneConfigs.GetChapterIdsByDiff(activityId, diff) + local diffChapterIds = {} + local chapterIds = XKillZoneConfigs.GetActivityChapterIds(activityId) + for _, chapterId in pairs(chapterIds) do + if diff == XKillZoneConfigs.GetChapterDiff(chapterId) then + tableInsert(diffChapterIds, chapterId) + end + end + return diffChapterIds +end + +function XKillZoneConfigs.GetTotalStageIdsByDiff(activityId, diff) + local totalStageIds = {} + + local chapterIds = XKillZoneConfigs.GetChapterIdsByDiff(activityId, diff) + for _, chapterId in pairs(chapterIds) do + local stageIds = XKillZoneConfigs.GetChapterStageIds(chapterId) + for _, stageId in pairs(stageIds) do + tableInsert(totalStageIds, stageId) + end + end + + return totalStageIds +end + +function XKillZoneConfigs.GetChapterPreStageId(chapterId) + local config = GetChapterConfig(chapterId) + return config.PreStageId +end + +function XKillZoneConfigs.GetChapterIdByStageId(stageId) + if not XTool.IsNumberValid(stageId) then return 0 end + for chapterId, config in pairs(ChapterConfig) do + for _, innerStageId in pairs(config.StageId) do + if innerStageId == stageId then + return chapterId + end + end + end + return 0 +end +-----------------章节相关 end------------------- +-----------------关卡相关 begin------------------- +local TABLE_STAGE_PATH = "Share/Fuben/KillZone/KillZoneStage.tab" +local TABLE_STAGE_BUFF_PATH = "Client/Fuben/KillZone/KillZoneBuff.tab" + +local StageConfig = {} +local StageBuffConfig = {} + +XKillZoneConfigs.MaxFarmRewardCount = 3 --复刷奖励最大领取次数 + +local function InitStageConfig() + StageConfig = XTableManager.ReadByIntKey(TABLE_STAGE_PATH, XTable.XTableKillZoneStage, "Id") + StageBuffConfig = XTableManager.ReadByIntKey(TABLE_STAGE_BUFF_PATH, XTable.XTableKillZoneBuff, "Id") +end + +local function GetStageConfig(stageId) + local config = StageConfig[stageId] + if not config then + XLog.Error("XKillZoneConfigs GetStageConfig error:配置不存在, stageId:" .. stageId .. ",path: " .. TABLE_STAGE_PATH) + return + end + return config +end + +local function GetStageBuffConfig(buffId) + local config = StageBuffConfig[buffId] + if not config then + XLog.Error("XKillZoneConfigs GetStageBuffConfig error:配置不存在, stageId:" .. buffId .. ",path: " .. TABLE_STAGE_BUFF_PATH) + return + end + return config +end + +function XKillZoneConfigs.GetAllStageIds() + local stageIds = {} + for stageId in pairs(StageConfig) do + tableInsert(stageIds, stageId) + end + return stageIds +end + +function XKillZoneConfigs.GetStageName(stageId) + local config = GetStageConfig(stageId) + return config.Name or "" +end + +function XKillZoneConfigs.GetStageOrder(stageId) + local config = GetStageConfig(stageId) + return config.Order or "" +end + +function XKillZoneConfigs.GetStageBg(stageId) + local config = GetStageConfig(stageId) + return config.Bg or "" +end + +function XKillZoneConfigs.GetStageFarmReward(stageId) + local config = GetStageConfig(stageId) + return config.FarmReward +end + +function XKillZoneConfigs.GetStageMaxStar(stageId) + local config = GetStageConfig(stageId) + return config.MaxStar +end + +function XKillZoneConfigs.GetStagePreStageId(stageId) + local config = GetStageConfig(stageId) + return config.PreStageId +end + +function XKillZoneConfigs.GetStageRobotIds(stageId) + local robotIds = {} + local config = GetStageConfig(stageId) + for _, robotId in pairs(config.TestRobot) do + if XTool.IsNumberValid(robotId) then + tableInsert(robotIds, robotId) + end + end + return robotIds +end + +--获取通关条件描述 +function XKillZoneConfigs.GetStagePassDesc(stageId) + local config = GetStageConfig(stageId) + return config.StarDesc[1] or "" +end + +--获取星级条件描述 +function XKillZoneConfigs.GetStageStarDescList(stageId) + local descList = {} + local config = GetStageConfig(stageId) + for index, desc in ipairs(config.StarDesc) do + if index > 1 then + tableInsert(descList, desc) + end + end + return descList +end + +function XKillZoneConfigs.GetStageBuffIds(stageId) + local buffIds = {} + local config = GetStageConfig(stageId) + for _, buffId in ipairs(config.BuffId) do + if XTool.IsNumberValid(buffId) then + tableInsert(buffIds, buffId) + end + end + return buffIds +end + +local function GetBuffConfig(buffId) + local config = StageBuffConfig[buffId] + if not config then + XLog.Error("XKillZoneConfigs GetBuffConfig error:配置不存在, buffId:" .. buffId .. ",path: " .. TABLE_STAGE_BUFF_PATH) + return + end + return config +end + +function XKillZoneConfigs.GetBuffName(buffId) + local config = GetBuffConfig(buffId) + return config.Name +end + +function XKillZoneConfigs.GetBuffDesc(buffId) + local config = GetBuffConfig(buffId) + return config.Desc +end + +function XKillZoneConfigs.GetBuffIcon(buffId) + local config = GetBuffConfig(buffId) + return config.Icon +end +-----------------关卡相关 end------------------- +-----------------星级奖励 begin------------------- +local TABLE_STAR_REWARD_PATH = "Share/Fuben/KillZone/KillZoneDiffStarReward.tab" + +local StarRewardConfig = {} + +local function InitStarRewardConfig() + StarRewardConfig = XTableManager.ReadByIntKey(TABLE_STAR_REWARD_PATH, XTable.XTableKillZoneStarReward, "Id") +end + +local function GetStarRewardConfig(starRewardId) + local config = StarRewardConfig[starRewardId] + if not config then + XLog.Error("XKillZoneConfigs GetStarRewardConfig error:配置不存在, starRewardId:" .. starRewardId .. ",path: " .. TABLE_STAR_REWARD_PATH) + return + end + return config +end + +function XKillZoneConfigs.GetStarRewardDiff(starRewardId) + local config = GetStarRewardConfig(starRewardId) + return config.Diff +end + +function XKillZoneConfigs.GetStarRewardStar(starRewardId) + local config = GetStarRewardConfig(starRewardId) + return config.Star +end + +function XKillZoneConfigs.GetStarRewardGoodsId(starRewardId) + local config = GetStarRewardConfig(starRewardId) + return config.RewardId +end + +function XKillZoneConfigs.GetStarRewardTitleByDiff(diff) + if diff == XKillZoneConfigs.Difficult.Normal then + return CsXTextManagerGetText("KillZoneTotalStarDescNormal") + elseif diff == XKillZoneConfigs.Difficult.Hard then + return CsXTextManagerGetText("KillZoneTotalStarDescHard") + else + return "" + end +end + +function XKillZoneConfigs.GetAllStarRewardIdsByDiff(diff) + local ids = {} + for starRewardId in pairs(StarRewardConfig) do + if XTool.IsNumberValid(starRewardId) + and XKillZoneConfigs.GetStarRewardDiff(starRewardId) == diff + then + tableInsert(ids, starRewardId) + end + end + tableSort(ids, function(a, b) + return a < b + end) + return ids +end +-----------------星级奖励 end------------------- +-----------------每日星级奖励 begin------------------- +local TABLE_DAILY_STAR_REWARD_PATH = "Share/Fuben/KillZone/KillZoneDailyStarReward.tab" + +local DailyStarRewardConfig = {} + +local function InitDailyStarRewardConfig() + DailyStarRewardConfig = XTableManager.ReadByIntKey(TABLE_DAILY_STAR_REWARD_PATH, XTable.XTableKillZoneDailyStarReward, "Id") +end + +local function GetDailyStarRewardConfig(id) + local config = DailyStarRewardConfig[id] + if not config then + XLog.Error("XKillZoneConfigs GetDailyStarRewardConfig error:配置不存在, id:" .. id .. ",path: " .. TABLE_DAILY_STAR_REWARD_PATH) + return + end + return config +end + +function XKillZoneConfigs.GetDailyStarRewardConfigPath() + return TABLE_DAILY_STAR_REWARD_PATH +end + +function XKillZoneConfigs.GetDailyStarRewardStar(id) + local config = GetDailyStarRewardConfig(id) + return config.Star +end + +function XKillZoneConfigs.GetDailyStarRewardGoodsId(id) + local config = GetDailyStarRewardConfig(id) + return config.RewardId +end + +function XKillZoneConfigs.GetAllDailyStarRewardIds(activityId) + local ids = {} + for id, config in pairs(DailyStarRewardConfig) do + if XTool.IsNumberValid(id) + and config.ActivityId == activityId + then + tableInsert(ids, id) + end + end + tableSort(ids, function(a, b) + return a < b + end) + return ids +end +-----------------每日星级奖励 end------------------- +-----------------插件相关 begin------------------- +local TABLE_PLUGIN_PATH = "Share/Fuben/KillZone/KillZonePlugin.tab" +local TABLE_PLUGIN_SLOT_PATH = "Share/Fuben/KillZone/KillZonePluginSlot.tab" +local TABLE_PLUGIN_LEVEL_PATH = "Share/Fuben/KillZone/KillZonePluginLevel.tab" +local TABLE_PLUGIN_GROUP_PATH = "Client/Fuben/KillZone/KillZonePluginGroup.tab" + +local PluginConfig = {} +local PluginSlotConfig = {} +local PluginLevelConfig = {} +local PluginGroupConfig = {} +local PluginIdGroupDic = {}--由GroupId索引的PluginId分组Dic + +local function InitPluginConfig() + PluginConfig = XTableManager.ReadByIntKey(TABLE_PLUGIN_PATH, XTable.XTableKillZonePlugin, "Id") + PluginSlotConfig = XTableManager.ReadByIntKey(TABLE_PLUGIN_SLOT_PATH, XTable.XTableKillZonePluginSlot, "Id") + PluginLevelConfig = XTableManager.ReadByIntKey(TABLE_PLUGIN_LEVEL_PATH, XTable.XTableKillZonePluginLevel, "Id") + PluginGroupConfig = XTableManager.ReadByIntKey(TABLE_PLUGIN_GROUP_PATH, XTable.XTableKillZonePluginGroup, "Id") + + for pluginId, config in pairs(PluginConfig) do + local groupId = config.GroupId + if XTool.IsNumberValid(groupId) + and XTool.IsNumberValid(pluginId) then + local group = PluginIdGroupDic[groupId] + if not group then + group = {} + PluginIdGroupDic[groupId] = group + end + tableInsert(group, pluginId) + end + end +end + +local function GetPluginConfig(pluginId) + local config = PluginConfig[pluginId] + if not config then + XLog.Error("XKillZoneConfigs GetPluginConfig error:配置不存在, pluginId:" .. pluginId .. ",path: " .. TABLE_PLUGIN_PATH) + return + end + return config +end + +local function GetPluginSlotConfig(slot) + local config = PluginSlotConfig[slot] + if not config then + XLog.Error("XKillZoneConfigs GetPluginSlotConfig error:配置不存在, slot:" .. slot .. ",path: " .. TABLE_PLUGIN_SLOT_PATH) + return + end + return config +end + +local function GetPluginGroupConfig(groupId) + local config = PluginGroupConfig[groupId] + if not config then + XLog.Error("XKillZoneConfigs GetPluginGroupConfig error:配置不存在, groupId:" .. groupId .. ",path: " .. TABLE_PLUGIN_GROUP_PATH) + return + end + return config +end + +local function GetPluginLevelIdConfig(levelId) + local config = PluginLevelConfig[levelId] + if not config then + XLog.Error("XKillZoneConfigs GetPluginLevelIdConfig error:配置不存在, levelId:" .. levelId .. ",path: " .. TABLE_PLUGIN_LEVEL_PATH) + return + end + return config +end + +local function GetPluginLevelConfig(pluginId, level) + local pluginConfig = GetPluginConfig(pluginId) + local levelId = pluginConfig.LevelId[level] + if not XTool.IsNumberValid(levelId) then + XLog.Error("XKillZoneConfigs GetPluginLevelConfig error:levelId不存在, pluginId:" .. pluginId .. ",level: " .. level .. ",path: " .. TABLE_PLUGIN_PATH) + return + end + return GetPluginLevelIdConfig(levelId) +end + +--插件槽位最大数量 +function XKillZoneConfigs.GetMaxPluginSlotNum() + return #PluginSlotConfig +end + +function XKillZoneConfigs.GetAllPluginIds() + local pluginIds = {} + for pluginId in pairs(PluginConfig) do + if XTool.IsNumberValid(pluginId) then + tableInsert(pluginIds, pluginId) + end + end + return pluginIds +end + +function XKillZoneConfigs.GetPluginGroupIds() + local groupIds = {} + for groupId in pairs(PluginIdGroupDic) do + if XTool.IsNumberValid(groupId) then + tableInsert(groupIds, groupId) + end + end + return groupIds +end + +function XKillZoneConfigs.GetPluginIdsByGroupId(groupId) + return PluginIdGroupDic[groupId] and PluginIdGroupDic[groupId] or {} +end + +function XKillZoneConfigs.GetPluginIcon(pluginId) + local config = GetPluginConfig(pluginId) + return config.Icon or "" +end + +function XKillZoneConfigs.GetPluginName(pluginId) + local config = GetPluginConfig(pluginId) + return config.Name or "" +end + +function XKillZoneConfigs.GetPluginMaxLevel(pluginId) + local config = GetPluginConfig(pluginId) + for level = #config.LevelId, 1, -1 do + local levelId = config.LevelId[level] + if XTool.IsNumberValid(levelId) then + return level + end + end + return 1 +end + +function XKillZoneConfigs.GetPluginSlotConditionId(slot) + local config = GetPluginSlotConfig(slot) + return config.UnlockCondition or 0 +end + +function XKillZoneConfigs.GetPluginSlotConditionDesc(slot) + local conditionId = XKillZoneConfigs.GetPluginSlotConditionId(slot) + return XTool.IsNumberValid(conditionId) and XConditionManager.GetConditionDescById(conditionId) or "" +end + +function XKillZoneConfigs.GetPluginGroupName(groupId) + local config = GetPluginGroupConfig(groupId) + return config.Name or "" +end + +--获取插件解锁消耗 +function XKillZoneConfigs.GetPluginUnlockCost(pluginId) + local config = GetPluginConfig(pluginId) + return XKillZoneConfigs.ItemIdCoinA, config.UnlockSpend +end + +--获取插件激活消耗 +function XKillZoneConfigs.GetPluginUnActiveCost(pluginId) + local config = GetPluginLevelConfig(pluginId, 1) + return XKillZoneConfigs.ItemIdCoinB, config.UnlockSpend +end + +--获取插件升级消耗 +function XKillZoneConfigs.GetPluginLevelUpCost(pluginId, level) + local config = GetPluginLevelConfig(pluginId, level) + return XKillZoneConfigs.ItemIdCoinB, config.UnlockSpend +end + +--获取插件列表重置消耗 +function XKillZoneConfigs.GetPluginsResetCost(pluginIds, activityId) + local costCount = XKillZoneConfigs.GetActivityResetPluginSpend(activityId) + return XDataCenter.ItemManager.ItemId.Coin, #pluginIds * costCount +end + +--获取插件升级总消耗(startLevel~targetLevel) +function XKillZoneConfigs.GetPluginLevelUpCostTotal(pluginId, startLevel, targetLevel) + local totalCost = 0 + startLevel = startLevel or 1 + targetLevel = targetLevel or XKillZoneConfigs.GetPluginMaxLevel(pluginId) + for level = startLevel, targetLevel do + local _, cost = XKillZoneConfigs.GetPluginLevelUpCost(pluginId, level) + totalCost = totalCost + cost + end + return XKillZoneConfigs.ItemIdCoinB, totalCost +end + +--获取插件等级对应技能描述 +function XKillZoneConfigs.GetPluginLevelSkillDesc(pluginId, level) + local config = GetPluginLevelConfig(pluginId, level) + return config.SkillDesc or "" +end + +--获取插件等级对应技能描述列表 +function XKillZoneConfigs.GetPluginLevelSkillDescList(pluginId) + local descList = {} + local config = GetPluginConfig(pluginId) + for level, levelId in ipairs(config.LevelId) do + if XTool.IsNumberValid(levelId) then + tableInsert(descList, XKillZoneConfigs.GetPluginLevelSkillDesc(pluginId, level)) + end + end + return descList +end +-----------------插件相关 end------------------- +function XKillZoneConfigs.Init() + InitActivityConfig() + InitChapterConfig() + InitStageConfig() + InitStarRewardConfig() + InitDailyStarRewardConfig() + InitPluginConfig() +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XLoadingConfig.lua b/Resources/Scripts/XConfig/XLoadingConfig.lua new file mode 100644 index 00000000..c8010ce1 --- /dev/null +++ b/Resources/Scripts/XConfig/XLoadingConfig.lua @@ -0,0 +1,27 @@ +XLoadingConfig = XLoadingConfig or {} + +local TypeDic = {} + +local TABLE_LOADING_PATH = "Client/Loading/Loading.tab" + +function XLoadingConfig.Init() + local LoadingTemplate = XTableManager.ReadByIntKey(TABLE_LOADING_PATH, XTable.XTableLoading, "Id") + + local typeDic = {} + + --过滤Type + for _, v in pairs(LoadingTemplate) do + local type = v.Type + local list = typeDic[type] + if list == nil then + list = {} + typeDic[type] = list + end + table.insert(list, v) + end + + TypeDic = typeDic +end +function XLoadingConfig.GetCfgByType(type) + return TypeDic[type] +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XLottoConfigs.lua b/Resources/Scripts/XConfig/XLottoConfigs.lua new file mode 100644 index 00000000..f805e5ac --- /dev/null +++ b/Resources/Scripts/XConfig/XLottoConfigs.lua @@ -0,0 +1,104 @@ +XLottoConfigs = XLottoConfigs or {} + +local TABLE_LOTTO = "Share/Lotto/Lotto.tab" +local TABLE_LOTTO_REWARD = "Share/Lotto/LottoReward.tab" +local TABLE_LOTTO_BUY_TICKET_RULE = "Share/Lotto/LottoBuyTicketRule.tab" +local TABLE_LOTTO_PROBSHOW = "Client/Lotto/LottoProbShow.tab" +local TABLE_LOTTO_GROUP_RULE = "Client/Lotto/LottoGroupRule.tab" + +local Lottos = {} +local LottoRewards = {} +local LottoProbShow = {} +local LottoRewardDic = {} +local LottoGroupRule = {} +local LottoBuyTicketRules = {} + +XLottoConfigs.RareLevel = { + One = 1, + Two = 2, + Three = 3, + Four = 4, +} + +XLottoConfigs.ExtraRewardState = { + CanNotGet = 0, + CanGet = 1, + Geted = 2, +} + +function XLottoConfigs.Init() + Lottos = XTableManager.ReadByIntKey(TABLE_LOTTO, XTable.XTableLotto, "Id") + LottoRewards = XTableManager.ReadByIntKey(TABLE_LOTTO_REWARD, XTable.XTableLottoReward, "Id") + LottoProbShow = XTableManager.ReadByIntKey(TABLE_LOTTO_PROBSHOW, XTable.XTableLottoProbShow, "Id") + LottoGroupRule = XTableManager.ReadByIntKey(TABLE_LOTTO_GROUP_RULE, XTable.XTableLottoGroupRule, "Id") + LottoBuyTicketRules = XTableManager.ReadByIntKey(TABLE_LOTTO_BUY_TICKET_RULE, XTable.XTableLottoBuyTicketRule, "Id") + + XLottoConfigs.SetLottoRewardDic() +end + +function XLottoConfigs.GetLottoReward() + return LottoRewards +end + +function XLottoConfigs.GetLottos() + return Lottos +end + +function XLottoConfigs.GetLottoCfgById(id) + if not Lottos[id] then + XLog.Error("id is not exist in "..TABLE_LOTTO.." id = " .. id) + return + end + return Lottos[id] +end + +function XLottoConfigs.GetLottoProbShows() + return LottoProbShow +end + +function XLottoConfigs.GetLottoProbShowCfgById(id) + if not LottoProbShow[id] then + XLog.Error("id is not exist in "..TABLE_LOTTO_PROBSHOW.." id = " .. id) + return + end + return LottoProbShow[id] +end + +function XLottoConfigs.GetLottoRewardCfgById(id) + if not LottoRewards[id] then + XLog.Error("id is not exist in "..TABLE_LOTTO_REWARD.." id = " .. id) + return + end + return LottoRewards[id] +end + +function XLottoConfigs.GetLottoGroupRuleCfgById(id) + if not LottoGroupRule[id] then + XLog.Error("id is not exist in "..LottoGroupRule.." id = " .. id) + return + end + return LottoGroupRule[id] +end + +function XLottoConfigs.GetLottoRewardListById(lottoId) + if not LottoRewardDic[lottoId] then + XLog.Error("id is not exist in "..TABLE_LOTTO_REWARD.." id = " .. lottoId) + return + end + return LottoRewardDic[lottoId] +end + +function XLottoConfigs.GetLottoBuyTicketRuleById(id) + if not LottoBuyTicketRules[id] then + XLog.Error("id is not exist in "..TABLE_LOTTO_BUY_TICKET_RULE.." id = " .. id) + return + end + return LottoBuyTicketRules[id] +end + +function XLottoConfigs.SetLottoRewardDic() + for _,reward in pairs(LottoRewards) do + LottoRewardDic[reward.LottoId] = LottoRewardDic[reward.LottoId] or {} + table.insert(LottoRewardDic[reward.LottoId],reward) + end +end diff --git a/Resources/Scripts/XConfig/XMailConfigs.lua b/Resources/Scripts/XConfig/XMailConfigs.lua new file mode 100644 index 00000000..adff8cfc --- /dev/null +++ b/Resources/Scripts/XConfig/XMailConfigs.lua @@ -0,0 +1,43 @@ +local tableInsert = table.insert + +XMailConfigs = XMailConfigs or {} + +local TABLE_MAIL_PATH = "Share/Mail/Mail.tab" +local TABLE_MAIL_REWARD_GOODS_PATH = "Share/Mail/MailRewardGoods.tab" + +local MailRewardTemplates = {} + + +function XMailConfigs.Init() + local mailTable = XTableManager.ReadByIntKey(TABLE_MAIL_PATH, XTable.XTableMail, "Id") + local rewardGoodsTable = XTableManager.ReadByIntKey(TABLE_MAIL_REWARD_GOODS_PATH, XTable.XTableRewardGoods, "Id") + + for k, v in pairs(mailTable) do + local list = {} + for _, id in pairs(v.RewardIds) do + local tab = rewardGoodsTable[id] + if not tab then + XLog.ErrorTableDataNotFound("XMailConfigs.Init", "tab", TABLE_MAIL_REWARD_GOODS_PATH, "id", tostring(id)) + return + end + tableInsert(list, XRewardManager.CreateRewardGoodsByTemplate(tab)) + end + MailRewardTemplates[k] = list + end + + MailRewardTemplates = XReadOnlyTable.Create(MailRewardTemplates) +end + +function XMailConfigs.GetMailRewardTemplates() + return MailRewardTemplates +end + +function XMailConfigs.GetRewardList(mailId) + local rewardList = MailRewardTemplates[mailId] + if not rewardList then + XLog.ErrorTableDataNotFound("XMailConfigs.GetRewardList", "tab", TABLE_MAIL_REWARD_GOODS_PATH, "id", tostring(mailId)) + return + end + + return rewardList +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XMaintainerActionConfigs.lua b/Resources/Scripts/XConfig/XMaintainerActionConfigs.lua new file mode 100644 index 00000000..425ff673 --- /dev/null +++ b/Resources/Scripts/XConfig/XMaintainerActionConfigs.lua @@ -0,0 +1,163 @@ + +XMaintainerActionConfigs = XMaintainerActionConfigs or {} + +local TABLE_ACTIONCFG = "Share/Fuben/MaintainerAction/MaintainerActionConfig.tab" +local TABLE_STAGE_LEVEL = "Share/Fuben/MaintainerAction/MaintainerActionLevel.tab" +local TABLE_EVENT = "Share/Fuben/MaintainerAction/MaintainerActionEvent.tab" + +local tableSort = table.sort + +local MaintainerActionTemplates = {} +local MaintainerActionLevelTemplates = {} +local MaintainerActionEventTemplates = {} + +local MaintainerActionRecordInfoDic = {} + +XMaintainerActionConfigs.NodeType = { + UnKnow = 0, + Start = 1, + Fight = 2, + Box = 3, + None = 4, + Forward = 5, + FallBack = 6, + CardChange = 7, + DirectionChange = 8, + ActionPoint = 9, + SimulationFight = 10, + Warehouse = 11, + Explore = 12, + Mentor = 13, +} + +XMaintainerActionConfigs.EventType = { + Fight = 2, +} + +XMaintainerActionConfigs.NodeState = { + Normal = 1, + OnRoute = 2, + Target = 3, +} + +XMaintainerActionConfigs.CardState = { + Normal = 1, + Select = 2, + Disable = 3, +} + +XMaintainerActionConfigs.MessageType = { + DayUpdate = 1, + WeekUpdate = 2, + FightComplete = 3, + EventComplete = 4, + MentorComplete = 5, +} + +XMaintainerActionConfigs.RecordType = { + PlayMove = 1, + NodeEvent = 2, + FubenWin = 3, +} + +XMaintainerActionConfigs.TipType = { + FightComplete = 1, + EventComplete = 2, + MentorComplete = 3, +} + +XMaintainerActionConfigs.MonterNodeStatus = { + NotActive = 0, + ActiveSelf = 1, + ActiveOther = 2, + Finish = 3, +} + +function XMaintainerActionConfigs.Init() + MaintainerActionTemplates = XTableManager.ReadByIntKey(TABLE_ACTIONCFG, XTable.XTableMaintainerActionConfig, "Id") + MaintainerActionLevelTemplates = XTableManager.ReadByIntKey(TABLE_STAGE_LEVEL, XTable.XTableMaintainerActionLevel, "Level") + MaintainerActionEventTemplates = XTableManager.ReadByIntKey(TABLE_EVENT, XTable.XTableMaintainerActionEvent, "Id") +end + +function XMaintainerActionConfigs.CreateRecordInfoDic() + for _,record in pairs(MaintainerActionRecordTemplates)do + MaintainerActionRecordInfoDic = MaintainerActionRecordInfoDic or {} + MaintainerActionRecordInfoDic[record.GroupType] = MaintainerActionRecordInfoDic[record.GroupType] or {} + MaintainerActionRecordInfoDic[record.GroupType][record.SubType] = record + end +end + +function XMaintainerActionConfigs.GetMaintainerActionTemplates() + local defaultId = XMaintainerActionConfigs.GetDefaultId() + return MaintainerActionTemplates[defaultId] +end + +function XMaintainerActionConfigs.GetDefaultId() + local defaultId = 0 + local spareId = 0 + local nowTime = XTime.GetServerNowTimestamp() + local miniEndTime + local MaxBeginTime + for id,cfg in pairs(MaintainerActionTemplates) do + local beginTime, endTime = XFunctionManager.GetTimeByTimeId(cfg.TimeId) + if endTime > nowTime then + if miniEndTime == nil or miniEndTime == 0 or endTime < miniEndTime then + defaultId = id + miniEndTime = endTime + end + else + if endTime == 0 then + if miniEndTime == nil then + defaultId = id + miniEndTime = endTime + end + end + end + + if MaxBeginTime == nil or beginTime > MaxBeginTime then + spareId = id + MaxBeginTime = beginTime + end + end + + defaultId = defaultId == 0 and spareId or defaultId + + return defaultId +end + +function XMaintainerActionConfigs.GetMaintainerActionLevelTemplates() + return MaintainerActionLevelTemplates +end + +function XMaintainerActionConfigs.GetMaintainerActionEventTemplates() + return MaintainerActionEventTemplates +end + +function XMaintainerActionConfigs.GetMaintainerActionRecordInfoByType(GroupType,SubType) + return MaintainerActionRecordInfoDic and + MaintainerActionRecordInfoDic[GroupType] and + MaintainerActionRecordInfoDic[GroupType][SubType] +end + +function XMaintainerActionConfigs.GetMaintainerActionTemplateById(id) + if not MaintainerActionTemplates[id] then + XLog.Error("Share/Fuben/MaintainerAction/MaintainerActionConfig.tab Id = " .. id .. " Is Null") + end + return MaintainerActionTemplates[id] +end + +function XMaintainerActionConfigs.GetMaintainerActionEventTemplateById(id) + if not MaintainerActionEventTemplates[id] then + XLog.Error("Share/Fuben/MaintainerAction/MaintainerActionEvent.tab Id = " .. id .. " Is Null") + end + return MaintainerActionEventTemplates[id] +end + +function XMaintainerActionConfigs.IsFightEvent(id) + if not MaintainerActionEventTemplates[id] then + XLog.Error("Share/Fuben/MaintainerAction/MaintainerActionEvent.tab Id = " .. id .. " Is Null") + end + return MaintainerActionEventTemplates[id].Id == XMaintainerActionConfigs.EventType.Fight +end + + diff --git a/Resources/Scripts/XConfig/XMarketingActivityConfigs.lua b/Resources/Scripts/XConfig/XMarketingActivityConfigs.lua new file mode 100644 index 00000000..c3baf4e1 --- /dev/null +++ b/Resources/Scripts/XConfig/XMarketingActivityConfigs.lua @@ -0,0 +1,143 @@ +XMarketingActivityConfigs = XMarketingActivityConfigs or {} + +local TABLE_MARKETING = "Client/MarketingActivity/MarketingActivity.tab" +local TABLE_PICCOMPOSITION = "Client/MarketingActivity/PicComposition.tab" +local TABLE_COMPOSITIONCHARACTER = "Client/MarketingActivity/CompositionCharacter.tab" + +local TABLE_PRODUCTCOMMENTACTIVITY = "Share/ProductComment/ProductCommentActivity.tab" +local TABLE_PRODUCTCOMMENTRANKREWARD = "Share/ProductComment/ProductCommentRankReward.tab" +local TABLE_PRODUCTCOMMENTSCHEDULEREWARD = "Share/ProductComment/ProductCommentScheduleReward.tab" + +local TABLE_WINDOWSINLAY = "Client/MarketingActivity/WindowsInlay.tab" + +local tableSort = table.sort + +local MarketingActivities = {} +local PicCompositions = {} +local PicCompositionActivityInfos = {} +local CompositionCharacters = {} +local PicCompositionRankRewardInfos = {} +local PicCompositionScheduleRewardInfos = {} + +local WindowsInlayActivities = {} + + +XMarketingActivityConfigs.CompositionType = { + Examining = 0, + Examined = 1, + UnExamine = 2, + Memo = 3, +} + +XMarketingActivityConfigs.SortType = { + Hot = 1, + Time = 2, +} + +XMarketingActivityConfigs.GetType = { + Before = 1, + After = 2, +} + +XMarketingActivityConfigs.TimeType = { + In = 0, + Before = 1, + After = 2, + Out = 3, +} + +XMarketingActivityConfigs.TimeDataType = { + BeginTime = 0, + EndTime = 1, + UploadBeginTime = 2, + UploadEndTime = 3, +} + +XMarketingActivityConfigs.SeverId = { + SparkServer = "1000", + BeaconServer = "1001", +} + +XMarketingActivityConfigs.ActivityType = { + WindowsInlay = 1, +} + +XMarketingActivityConfigs.WebType = { + Normal = 0, + Vote = 1, +} + + +function XMarketingActivityConfigs.Init() + MarketingActivities = XTableManager.ReadByIntKey(TABLE_MARKETING, XTable.XTableMarketingActivity, "Id") + PicCompositions = XTableManager.ReadByIntKey(TABLE_PICCOMPOSITION, XTable.XTablePicComposition, "Id") + CompositionCharacters = XTableManager.ReadByIntKey(TABLE_COMPOSITIONCHARACTER, XTable.XTableCompositionCharacter, "Id") + PicCompositionActivityInfos = XTableManager.ReadByIntKey(TABLE_PRODUCTCOMMENTACTIVITY, XTable.XTableProductCommentActivity, "Id") + PicCompositionRankRewardInfos = XTableManager.ReadByIntKey(TABLE_PRODUCTCOMMENTRANKREWARD, XTable.XTableProductCommentRankReward, "Id") + PicCompositionScheduleRewardInfos = XTableManager.ReadByIntKey(TABLE_PRODUCTCOMMENTSCHEDULEREWARD, XTable.XTableProductCommentScheduleReward, "Id") + WindowsInlayActivities = XTableManager.ReadByIntKey(TABLE_WINDOWSINLAY, XTable.XTableWindowsInlay, "Id") +end +------------------------------看图作文相关---------------------------------->>> +function XMarketingActivityConfigs.GetMarketingActivityConfig() + return MarketingActivities +end + +function XMarketingActivityConfigs.GetPicCompositionConfigs() + return PicCompositions[1] +end + +function XMarketingActivityConfigs.GetCompositionCharacterConfigs() + return CompositionCharacters +end + +function XMarketingActivityConfigs.GetCompositionCharacterConfigById(id) + return CompositionCharacters[id] +end + +function XMarketingActivityConfigs.GetPicCompositionActivityInfoConfigs() + return PicCompositionActivityInfos +end + +function XMarketingActivityConfigs.GetPicCompositionRankRewardInfoConfigs() + return PicCompositionRankRewardInfos +end + +function XMarketingActivityConfigs.GetPicCompositionScheduleRewardInfoConfigs() + return PicCompositionScheduleRewardInfos +end + +function XMarketingActivityConfigs.GetPicCompositionScheduleRewardTotal() + local count = 0 + for _, _ in pairs(PicCompositionScheduleRewardInfos or {}) do + count = count + 1 + end + return count +end + +function XMarketingActivityConfigs.SortByPriority(list) + tableSort(list, function(a, b) + if a.Priority == b.Priority then + return a.Id > b.Id + else + return a.Priority > b.Priority + end + end) + return list +end + +function XMarketingActivityConfigs.GetCountUnitChange(count) + local newCount = count + if count >= 1000 then + newCount = count / 1000 + else + return math.floor(newCount) + end + local a, b = math.modf(newCount) + return b >= 0.05 and string.format("%.1fk", newCount) or string.format("%dk", a) +end +------------------------------看图作文相关----------------------------------<<< +------------------------------内嵌浏览器相关---------------------------------->>> +function XMarketingActivityConfigs.GetWindowsInlayActivityConfig() + return WindowsInlayActivities +end +------------------------------内嵌浏览器相关----------------------------------<<< \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XMedalConfigs.lua b/Resources/Scripts/XConfig/XMedalConfigs.lua new file mode 100644 index 00000000..5d0660c3 --- /dev/null +++ b/Resources/Scripts/XConfig/XMedalConfigs.lua @@ -0,0 +1,423 @@ +XMedalConfigs = XMedalConfigs or {} + +local TABLE_MEDAL = "Share/Medal/Medal.tab" +local TABLE_SCORETITLE = "Share/ScoreTitle/ScoreTitle.tab" +local TABLE_EXPAND_INFO = "Share/ScoreTitle/ScoreTitleExpandInfo.tab" +local TABLE_SCORESCREEN_TAG = "Share/ScoreTitle/ScoreScreenTag.tab" +local TABLE_SPECOAL_COLLECTION_LEVEL = "Share/ScoreTitle/SpecialCollectionLevel.tab" +local TABLE_COLLECTION_LEVEL = "Client/Medal/CollectionLevel.tab" +local TABLE_SHARE_NAMEPLATE = "Share/Nameplate/Nameplate.tab" + + + +local Meadals = {} +local ScoreTitles = {} +local ScoreScreenTag = {} +local CollectionLevel = {} +local SpecialCollectionLevels = {} +local SpecialCollectionLevelDic = {} +local NameplateConfigs = {} +local NameplateGroupDic = {} + +local ExpandInfo = {} + +local tableSort = table.sort + +XMedalConfigs.ViewType = { + Medal = 1,--勋章 + Collection = 2,--收藏品 + Nameplate = 3,--铭牌 +} + +-- 收藏页的收藏品字号 +XMedalConfigs.EnumCollectionScoreTextSize = { + CS.XGame.ClientConfig:GetInt("CollectionScoreTextSize1"), + CS.XGame.ClientConfig:GetInt("CollectionScoreTextSize2"), + CS.XGame.ClientConfig:GetInt("CollectionScoreTextSize3"), + CS.XGame.ClientConfig:GetInt("CollectionScoreTextSize4"), + CS.XGame.ClientConfig:GetInt("CollectionScoreTextSize5"), +} + +XMedalConfigs.XNameplatePanelPath = CS.XGame.ClientConfig:GetString("NameplatePanelPath") + +XMedalConfigs.MedalType = { + Normal = 1, + Babel = 2, + Experience = 6, + Anniversary = 9, +} + +XMedalConfigs.ShowScore = { + OFF = 0, + ON = 1, +} + +XMedalConfigs.MedalId = { + BossSingle = 3, --百万讨伐勋章 +} + +-- 周年庆收藏品扩展信息 +XMedalConfigs.ExpandInfoType = { + CreateTime = "1", -- 创建时间 + MaxFubenBfrt = "2", -- 据点战最高章节 + MaxAssignChapter = "3", -- 边界公约最高章节 + MaxCharacterLiberateLvCount = "4" -- 终解成员数 +} + +XMedalConfigs.Hide = { OFF = 0, ON = 1 }--0显示,1隐藏 + +XMedalConfigs.NameplateQuality = { + Copper = 1, --青铜 + Silver = 2, --白银 + Gold = 3, --黄金 +} + +XMedalConfigs.NameplateGetType = { + TypeOne = 1, --同组低品质替换高品质 + TypeTwo = 2, --达成条件后获得,提升品质 + TypeThree = 3, --重复获得转换经验 + TypeFour = 4 --重复获得转换其他道具 +} + +XMedalConfigs.NameplateShow = { + ShowIcon = 1, --单独显示资源 + ShowBackAndTitle = 2, --资源加title +} + +function XMedalConfigs.Init() + Meadals = XTableManager.ReadByIntKey(TABLE_MEDAL, XTable.XTableMedal, "Id") + ScoreTitles = XTableManager.ReadByIntKey(TABLE_SCORETITLE, XTable.XTableScoreTitle, "Id") + ExpandInfo = XTableManager.ReadByIntKey(TABLE_EXPAND_INFO, XTable.XTableScoreTitleExpandInfo, "Id") + ScoreScreenTag = XTableManager.ReadByIntKey(TABLE_SCORESCREEN_TAG, XTable.XTableScoreScreenTag, "Id") + CollectionLevel = XTableManager.ReadByIntKey(TABLE_COLLECTION_LEVEL, XTable.XTableCollectionLevel, "Id") + SpecialCollectionLevels = XTableManager.ReadByIntKey(TABLE_SPECOAL_COLLECTION_LEVEL, XTable.XTableSpecialCollectionLevel, "Index") + NameplateConfigs = XTableManager.ReadByIntKey(TABLE_SHARE_NAMEPLATE, XTable.XTableNameplate, "Id") + + XMedalConfigs.SetSpecialCollectionLevelDic() + + XMedalConfigs.InitNameplateConfig() +end + +function XMedalConfigs.InitNameplateConfig() + for _, config in pairs(NameplateConfigs) do + if config.Title and config.IconType == 2 then + if config.Title and string.Utf8Len(config.Title) > 14 then + XLog.Error("铭牌Title字符数量超过十四个----Id = "..config.Id.." "..config.Title) + end + elseif not config.Title and config.IconType == 2 then + XLog.Error("铭牌Title为空请检查"..config.Id) + end + NameplateGroupDic[config.Group] = NameplateGroupDic[config.Group] or {} + table.insert(NameplateGroupDic[config.Group], config) + end +end + +local GetExpandInfoById = function(id) + local config = ExpandInfo[id] + + if not config then + XLog.ErrorTableDataNotFound("XMedalConfigs.GetExpandInfoById", + "ExpandInfo", TABLE_EXPAND_INFO, "Id", tostring(id)) + return {} + end + + return config +end + +function XMedalConfigs.GetExpandInfoStrServerKeyById(id) + local cfg = GetExpandInfoById(id) + return cfg.StrServerKey +end + +function XMedalConfigs.GetExpandInfoDescById(id) + local cfg = GetExpandInfoById(id) + return cfg.Desc +end + +function XMedalConfigs.GetExpandInfoEmptyDescById(id) + local cfg = GetExpandInfoById(id) + return cfg.EmptyDesc +end + +function XMedalConfigs.GetMeadalConfigById(Id) + return Meadals[Id] +end + +function XMedalConfigs.GetMeadalConfigs() + return Meadals +end + +function XMedalConfigs.GetScoreTitlesConfigs() + return ScoreTitles +end + +function XMedalConfigs.GetScoreScreenTagConfigs() + return ScoreScreenTag +end + +function XMedalConfigs.GetCollectionDefaultQualityById(id) + return ScoreTitles[id].InitQuality +end + +function XMedalConfigs.GetCollectionNameById(id) + return ScoreTitles[id].Name +end + +function XMedalConfigs.GetShowScoreById(id) + return ScoreTitles[id].ShowScore +end + +function XMedalConfigs.GetCollectionDescById(id) + return ScoreTitles[id].MainDesc +end + +function XMedalConfigs.GetCollectionWorldDescById(id) + return ScoreTitles[id].WorldDesc +end + +function XMedalConfigs.GetCollectionIconById(id) + return ScoreTitles[id].MedalImg +end + +function XMedalConfigs.GetCollectionGroupById(id) + return ScoreTitles[id].GroupId +end + +function XMedalConfigs.GetCollectionPriorityById(id) + return ScoreTitles[id].Priority +end + +function XMedalConfigs.GetCollectionPrefabPath(id) + return ScoreTitles[id].PrefabPath +end + +function XMedalConfigs.GetCollectionDefaultLevelConfigs() + return CollectionLevel +end + +function XMedalConfigs.GetCollectionDefaultLevelById(id) + local levelIcon = nil + local qualities = ScoreTitles[id].Qualities + if qualities and #qualities > 0 then + for _, level in pairs(CollectionLevel) do + if level.CurLevel == 0 and level.MaxLevel == #qualities then + levelIcon = level.Icon + end + end + end + return levelIcon +end + +function XMedalConfigs.SetSpecialCollectionLevelDic() + if not SpecialCollectionLevels then + return + end + for _, level in pairs(SpecialCollectionLevels) do + if not SpecialCollectionLevelDic[level.Id] then + SpecialCollectionLevelDic[level.Id] = {} + end + table.insert(SpecialCollectionLevelDic[level.Id], level) + end + for _, LevelList in pairs(SpecialCollectionLevelDic) do + table.sort(LevelList, function(a, b) + return a.Score < b.Score + end) + end +end + +function XMedalConfigs.GetSpecialCollectionCurLevelAndNextScoreByScore(id, score) + local levelData = SpecialCollectionLevelDic[id] + if not levelData then + return 0 + end + local curLevel + local nextExp + local maxLevel + local maxExp + local exScore = 0 + for index, data in pairs(levelData) do + if data.Score > score then + curLevel = data.Level + nextExp = (index > 1) and levelData[index].Score - levelData[index - 1].Score or levelData[index].Score + exScore = (index > 1) and levelData[index - 1].Score - 1 or 0 + break + else + maxLevel = data.Level + maxExp = (index > 1) and levelData[index].Score - levelData[index - 1].Score or levelData[index].Score + exScore = (index > 1) and levelData[index - 1].Score - 1 or 0 + end + + end + + if curLevel then + return curLevel, nextExp, exScore + else + if maxLevel then + return maxLevel, maxExp, exScore-------关于满级等级是否+1这一点存在一些歧义 + end + end + + return 0, 0, 0 +end + +function XMedalConfigs.SortByPriority(list) + tableSort(list, function(a, b) + if a.Priority == b.Priority then + return a.Id < b.Id + else + return a.Priority < b.Priority + end + end) + return list +end + +function XMedalConfigs.DeepCopy(orig) + local copy + if type(orig) == "table" then + copy = {} + for orig_key, orig_value in next, orig, nil do + copy[XMedalConfigs.DeepCopy(orig_key)] = XMedalConfigs.DeepCopy(orig_value) + end + setmetatable(copy, XMedalConfigs.DeepCopy(getmetatable(orig))) + else + copy = orig + end + return copy +end + + +function XMedalConfigs.GetNameplateConfigById(id) + if not NameplateConfigs or not NameplateConfigs[id] then + XLog.ErrorTableDataNotFound("XMedalConfigs.GetNameplateConfigById", "铭牌", + TABLE_SHARE_NAMEPLATE, "id", tostring(id)) + end + return NameplateConfigs[id] +end + +function XMedalConfigs.GetNameplateConfigsByGroup(group) + if not NameplateGroupDic or not NameplateGroupDic[group] then + XLog.ErrorTableDataNotFound("XMedalConfigs.GetNameplateConfigsByGroup", "铭牌", + TABLE_SHARE_NAMEPLATE, "group", tostring(group)) + end + return NameplateGroupDic[group] +end + +function XMedalConfigs.GetNextNameplateConfigByGroup(group, quality) + local groupList = XMedalConfigs.GetNameplateConfigsByGroup(group) + local tmpConfig + for _, config in pairs(groupList) do + if (not tmpConfig or tmpConfig.NameplateQuality > config.NameplateQuality) and config.NameplateQuality > quality then + tmpConfig = config + end + end + return tmpConfig +end + +function XMedalConfigs.GetNameplateGroup(id) + local config = XMedalConfigs.GetNameplateConfigById(id) + if config then + return config.Group + end + return 0 +end + +function XMedalConfigs.GetNameplateIconType(id) + local config = XMedalConfigs.GetNameplateConfigById(id) + if config then + return config.IconType + end + return 0 +end + +function XMedalConfigs.GetNameplateIcon(id) + local config = XMedalConfigs.GetNameplateConfigById(id) + if config then + if config.IconType == XMedalConfigs.NameplateShow.ShowIcon then + return config.Icon + else + return config.BackBoard, config.Title + end + end + return "", "" +end + +-- function XMedalConfigs.GetNameplateBackBoard(id) +-- local config = XMedalConfigs.GetNameplateConfigById(id) +-- if config then +-- return config.BackBoard +-- end +-- return "" +-- end + + +-- function XMedalConfigs.GetNameplateTitle(id) +-- local config = XMedalConfigs.GetNameplateConfigById(id) +-- if config then +-- return config.Title +-- end +-- return "" +-- end + +function XMedalConfigs.GetNameplateQuality(id) + local config = XMedalConfigs.GetNameplateConfigById(id) + if config then + return config.NameplateQuality + end + return 0 +end + +function XMedalConfigs.GetNameplateOutLineColor(id) + local config = XMedalConfigs.GetNameplateConfigById(id) + if config then + return config.OutLineColor + end + return "" +end + +function XMedalConfigs.GetNameplateName(id) + local config = XMedalConfigs.GetNameplateConfigById(id) + if config then + return config.Name + end + return "" +end + +function XMedalConfigs.GetNameplateDescription(id) + local config = XMedalConfigs.GetNameplateConfigById(id) + if config then + return config.Description + end + return "" +end + +function XMedalConfigs.GetNameplateHint(id) + local config = XMedalConfigs.GetNameplateConfigById(id) + if config then + return config.Hint + end + return "" +end + +function XMedalConfigs.GetNameplateGetWay(id) + local config = XMedalConfigs.GetNameplateConfigById(id) + if config then + return config.NameplateGetWay + end + return "" +end + +function XMedalConfigs.GetNameplateUpgradeType(id) + local config = XMedalConfigs.GetNameplateConfigById(id) + if config then + return config.NameplateUpgradeType + end + return "" +end + +function XMedalConfigs.GetNameplateQualityIcon(id) + local config = XMedalConfigs.GetNameplateConfigById(id) + if config then + return config.QualityIcon + end + return "" +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XMentorSystemConfigs.lua b/Resources/Scripts/XConfig/XMentorSystemConfigs.lua new file mode 100644 index 00000000..a6cd7adb --- /dev/null +++ b/Resources/Scripts/XConfig/XMentorSystemConfigs.lua @@ -0,0 +1,134 @@ +XMentorSystemConfigs = XMentorSystemConfigs or {} + +local TABLE_MENTORSYSTEM = "Share/Mentorship/MentorConfig.tab" +local TABLE_MANIFESTO_TAG = "Share/Mentorship/ManifestoTag.tab" +local TABLE_ONLINE_TAG = "Share/Mentorship/OnlineTag.tab" +local TABLE_MASTER_STAGEREWARD = "Share/Mentorship/MasterStageReward.tab" +local TABLE_STUDENT_WEEKLYREWARD = "Share/Mentorship/StudentWeeklyReward.tab" +local TABLE_TEACHER_WEEKLYTASKREWARD = "Share/Mentorship/MasterWeeklyTaskReward.tab" +local TABLE_TEACHER_CHALLENGEREWARD = "Share/Mentorship/StudentChallengeReward.tab" +local TABLE_CANNOTGIVE_WAFER = "Share/Mentorship/CanNotGiveWafer.tab" + +local MentorSystemCfg = {} +local ManifestoTagCfg = {} +local OnlineTagCfg = {} +local MasterStageRewardCfg = {} +local StudentWeeklyRewardCfg = {} +local TeacherWeeklyTaskRewardCfg = {} +local TeacherChallengeRewardCfg = {} +local CanNotGiveWaferCfg = {} + +XMentorSystemConfigs.IdentityType = { + None = 0, + Teacher = 1, + Student = 2, +} + +XMentorSystemConfigs.MessageType = { + GetTeacher = 0, + GetStudent = 1, + LoseTeacher = 2,--被老师开除 + LoseStudent = 3,--被学生解雇 + GraduateStudent = 3,--学生毕业 +} + +XMentorSystemConfigs.TagType = { + Normal = 1, + Time = 2, +} + +XMentorSystemConfigs.StudentRewardType = { + Grow = 1, + Graduate = 2, +} + +XMentorSystemConfigs.TeacherTaskType = { + Assist = 1, + Reward = 2, +} + +XMentorSystemConfigs.TaskStatus = { + Init = 0,--未领取 + Received = 1,--已领取任务 + Completed = 2,--徒弟已完成任务 + GetReward = 3,--师傅已领取奖励 + GiveEquip = 4,--已赠送意识 + ReceiveEquip = 5--已领取意识 +} + +XMentorSystemConfigs.MySelfIndex = 1 + +function XMentorSystemConfigs.Init() + MentorSystemCfg = XTableManager.ReadByStringKey(TABLE_MENTORSYSTEM, XTable.XTableMentorConfig, "Key") + ManifestoTagCfg = XTableManager.ReadByIntKey(TABLE_MANIFESTO_TAG, XTable.XTableMentorTag, "Id") + OnlineTagCfg = XTableManager.ReadByIntKey(TABLE_ONLINE_TAG, XTable.XTableMentorTag, "Id") + MasterStageRewardCfg = XTableManager.ReadByIntKey(TABLE_MASTER_STAGEREWARD, XTable.XTableMasterStageReward, "Count") + StudentWeeklyRewardCfg = XTableManager.ReadByIntKey(TABLE_STUDENT_WEEKLYREWARD, XTable.XTableStudentWeeklyReward, "Id") + TeacherWeeklyTaskRewardCfg = XTableManager.ReadByIntKey(TABLE_TEACHER_WEEKLYTASKREWARD, XTable.XTableMasterWeeklyTaskReward, "TaskId") + TeacherChallengeRewardCfg = XTableManager.ReadByIntKey(TABLE_TEACHER_CHALLENGEREWARD, XTable.XTableStudentChallengeReward, "TaskId") + CanNotGiveWaferCfg = XTableManager.ReadByIntKey(TABLE_CANNOTGIVE_WAFER, XTable.XTableCanNotGiveWafer, "WaferId") +end + +function XMentorSystemConfigs.GetMentorSystemData(key) + if not MentorSystemCfg[key] then + XLog.Error(key.." Is Not Existence By :Share/Mentorship/MentorConfig.tab") + return 0 + end + return MentorSystemCfg[key].Value +end + +function XMentorSystemConfigs.GetManifestoTags() + return ManifestoTagCfg +end + +function XMentorSystemConfigs.GetOnlineTags() + return OnlineTagCfg +end + +function XMentorSystemConfigs.GetMasterStageRewards() + return MasterStageRewardCfg +end + +function XMentorSystemConfigs.GetStudentWeeklyRewards() + return StudentWeeklyRewardCfg +end + +function XMentorSystemConfigs.GetManifestoTagById(id) + if not ManifestoTagCfg[id] then + XLog.Error(id.." Is Not Existence By :Share/Mentorship/ManifestoTag.tab") + return 0 + end + return ManifestoTagCfg[id] +end + +function XMentorSystemConfigs.GetOnlineTagById(id) + if not OnlineTagCfg[id] then + XLog.Error(id.." Is Not Existence By :Share/Mentorship/OnlineTag.tab") + return 0 + end + return OnlineTagCfg[id] +end + +function XMentorSystemConfigs.GetTeacherWeeklyTaskRewardById(id) + if not TeacherWeeklyTaskRewardCfg[id] then + XLog.Error(id.." Is Not Existence By :Share/Mentorship/MasterWeeklyTaskReward.tab") + return 0 + end + return TeacherWeeklyTaskRewardCfg[id] +end + +function XMentorSystemConfigs.GetTeacherChallengeRewardById(id) + if not TeacherChallengeRewardCfg[id] then + XLog.Error(id.." Is Not Existence By :Share/Mentorship/StudentChallengeReward.tab") + return 0 + end + return TeacherChallengeRewardCfg[id] +end + +function XMentorSystemConfigs.IsCanNotGiveWafer(id) + if not CanNotGiveWaferCfg[id] then + return false + else + return true + end +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XMineSweepingConfigs.lua b/Resources/Scripts/XConfig/XMineSweepingConfigs.lua new file mode 100644 index 00000000..e86c92ea --- /dev/null +++ b/Resources/Scripts/XConfig/XMineSweepingConfigs.lua @@ -0,0 +1,78 @@ +XMineSweepingConfigs = XMineSweepingConfigs or {} + +local TABLE_MINESWEEPING_ACTIVITY = "Share/MiniActivity/MineSweepingGame/MineSweepingActivity.tab" +local TABLE_MINESWEEPING_CHAPTER = "Share/MiniActivity/MineSweepingGame/MineSweepingChapter.tab" +local TABLE_MINESWEEPING_STAGE = "Share/MiniActivity/MineSweepingGame/MineSweepingStage.tab" + +local MineSweepingActivityCfgs = {} +local MineSweepingChapterCfgs = {} +local MineSweepingStageCfgs = {} + +XMineSweepingConfigs.GridType = { + Unknown = 0, + Safe = 1, + Mine = 2, + Flag = 3, +} + +XMineSweepingConfigs.StageState = { + Prepare = 1, + Sweeping = 2, + Finish = 3, + Failed = 4, +} + +XMineSweepingConfigs.SpecialState = { + None = 0, + StageWin = 1, + StageLose = 2, + ChapterWin = 3, +} + +function XMineSweepingConfigs.Init() + MineSweepingActivityCfgs = XTableManager.ReadByIntKey(TABLE_MINESWEEPING_ACTIVITY, XTable.XTableMineSweepingActivity, "Id") + MineSweepingChapterCfgs = XTableManager.ReadByIntKey(TABLE_MINESWEEPING_CHAPTER, XTable.XTableMineSweepingChapter, "Id") + MineSweepingStageCfgs = XTableManager.ReadByIntKey(TABLE_MINESWEEPING_STAGE, XTable.XTableMineSweepingStage, "Id") +end + +function XMineSweepingConfigs.GetMineSweepingActivityCfgs() + return MineSweepingActivityCfgs +end + +function XMineSweepingConfigs.GetMineSweepingChapterCfgs() + return MineSweepingChapterCfgs +end + +function XMineSweepingConfigs.GetMineSweepingStageCfgs() + return MineSweepingStageCfgs +end + +function XMineSweepingConfigs.GetMineSweepingActivityById(id) + if not MineSweepingActivityCfgs[id] then + XLog.Error("id is not exist in "..TABLE_MINESWEEPING_ACTIVITY.." id = " .. id) + return + end + return MineSweepingActivityCfgs[id] +end + +function XMineSweepingConfigs.GetMineSweepingChapterById(id) + if not MineSweepingChapterCfgs[id] then + XLog.Error("id is not exist in "..TABLE_MINESWEEPING_CHAPTER.." id = " .. id) + return + end + return MineSweepingChapterCfgs[id] +end + +function XMineSweepingConfigs.GetMineSweepingStageById(id) + if not MineSweepingStageCfgs[id] then + XLog.Error("id is not exist in "..TABLE_MINESWEEPING_STAGE.." id = " .. id) + return + end + return MineSweepingStageCfgs[id] +end + +function XMineSweepingConfigs.GetGridKeyByPos(x, y) + local pos_X = x or 0 + local pos_Y = y or 0 + return string.format("%d_%d", pos_X, pos_Y) +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XMoeWarConfig.lua b/Resources/Scripts/XConfig/XMoeWarConfig.lua new file mode 100644 index 00000000..d88e7e92 --- /dev/null +++ b/Resources/Scripts/XConfig/XMoeWarConfig.lua @@ -0,0 +1,1009 @@ +XMoeWarConfig = XMoeWarConfig or {} + +local tableInsert = table.insert +local tableSort = table.sort + +local TABLE_MOEWAR_ACTIVITY = "Share/MoeWar/MoeWarActivity.tab" +local TABLE_MOEWAR_INIT_PAIR = "Share/MoeWar/MoeWarInitPair.tab" +local TABLE_MOEWAR_MAIL = "Share/MoeWar/MoeWarMail.tab" +local TABLE_MOEWAR_MATCH = "Share/MoeWar/MoeWarMatch.tab" +local TABLE_MOEWAR_PLAYER_GROUP = "Share/MoeWar/MoeWarPlayer.tab" +local TABLE_MOEWAR_VOTE_ITEM = "Share/MoeWar/MoeWarVoteItem.tab" +local TABLE_MOEWAR_PLAYER_CONFIG = "Client/MoeWar/MoeWarPlayerLocal.tab" +local TABLE_MOEWAR_TASK_GROUP = "Client/MoeWar/MoeWarTaskGroup.tab" +local TABLE_MOEWAR_RANK_GROUP = "Client/MoeWar/MoeWarRankGroup.tab" +local TABLE_MOEWAR_PREPARATION_ACTIVITY = "Share/MoeWar/Preparation/MoeWarPreparationActivity.tab" +local TABLE_MOEWAR_PREPARATION_ASSISTANCE = "Share/MoeWar/Preparation/MoeWarPreparationAssistance.tab" +local TABLE_MOEWAR_PREPARATION_GEAR = "Share/MoeWar/Preparation/MoeWarPreparationGear.tab" +local TABLE_MOEWAR_PREPARATION_HELPER = "Share/MoeWar/Preparation/MoeWarPreparationHelper.tab" +local TABLE_MOEWAR_PREPARATION_MATCH = "Share/MoeWar/Preparation/MoeWarPreparationMatch.tab" +local TABLE_MOEWAR_PREPARATION_QUESHION = "Share/MoeWar/Preparation/MoeWarPreparationQuestion.tab" +local TABLE_MOEWAR_PREPARATION_STAGE = "Share/MoeWar/Preparation/MoeWarPreparationStage.tab" +local TABLE_MOEWAR_PREPARATION_STAGE_TAG_LABEL = "Client/MoeWar/MoeWarPreparationStageTagLabel.tab" +local TABLE_MOEWAR_PREPARATION_STAGE_EVALUATION_LABEL = "Client/MoeWar/MoeWarPreparationStageEvaluationLabel.tab" +local TABLE_MOEWAR_ANIMATION = "Client/MoeWar/MoeWarAnimation.tab" +local TABLE_MOEWAR_ANIMATION_GROUP = "Client/MoeWar/MoeWarAnimationGroup.tab" +local TABLE_MOEWAR_ICON_CONFIG = "Client/MoeWar/MoeWarIconConfig.tab" +local TABLE_MOEWAR_ACTIVITY_CONFIG = "Client/MoeWar/MoeWarActivityConfig.tab" + +local MoeWarActivity = {} +local MoeWarInitPair = {} +local MoeWarMail = {} +local MoeWarMatch = {} +local MoeWarPlayers = {} +local MoeWarGroups = {} +local MoeWarVoteItem = {} +local MoeWarPlayerCfg = {} +local MoeWarTaskGroup = {} +local MoeWarRankGroup = {} +local MoeWarAnimation = {} +local MoeWarAnimationGroup = {} +local MoeWarIconConfig = {} +local MoeWarActivityConfig = {} + +local DefaultActivityId = 1 +local MoeWarPreparationActivity = {} +local MoeWarPreparationAssistance = {} +local MoeWarPreparationGear = {} +local MoeWarPreparationHelper = {} +local MoeWarPreparationMatch = {} +local MoeWarPreparationQuestion = {} +local MoeWarPreparationStage = {} +local MoeWarPreparationStageTagLabel = {} +local MoeWarPreparationStageEvaluationLabel = {} +local PreparationAssistanceEffectIdList = {} + + +XMoeWarConfig.KEY_GROUP_TAB_INDEX = "MOE_WAR_GROUP_TAB_INDEX_KEY" +XMoeWarConfig.SKIP_KEY_PREFIX = "MOE_WAR_SKIP" +XMoeWarConfig.DEFAULT_SELECT_KEY_PREFIX ="MOE_WAR_DEFAULT_SELECT" +XMoeWarConfig.MOE_WAR_VOTE_ANIMATION_RECORD = "MOE_WAR_VOTE_ANIMATION_RECORD" +XMoeWarConfig.ScheNameColor = { + NORMAL = XUiHelper.Hexcolor2Color("1B1B1B"), + WIN = XUiHelper.Hexcolor2Color("1B1B1B"), +} + +XMoeWarConfig.ScheNumColor = { + NORMAL = XUiHelper.Hexcolor2Color("6B6E6E"), + WIN = XUiHelper.Hexcolor2Color("6B6E6E"), +} + +XMoeWarConfig.RankIcon = { + [1] = CS.XGame.ClientConfig:GetString("BabelTowerRankIcon1"), + [2] = CS.XGame.ClientConfig:GetString("BabelTowerRankIcon2"), + [3] = CS.XGame.ClientConfig:GetString("BabelTowerRankIcon3"), +} + +XMoeWarConfig.ScheduleIcon = { + [1] = CS.XGame.ClientConfig:GetString("MoeWarScheduleIcon1"), + [2] = CS.XGame.ClientConfig:GetString("MoeWarScheduleIcon2"), + [3] = CS.XGame.ClientConfig:GetString("MoeWarScheduleIcon3"), +} + +XMoeWarConfig.MatchType = { + Voting = 1, --投票期 + Publicity = 2, --公示期 +} + +XMoeWarConfig.SessionType = { + Game24In12 = 1, + Game12In6 = 2, + Game6In3 = 3, + Game3In1 = 4, +} + +XMoeWarConfig.SessionName = { + "Game24In12", + "Game12In6", + "Game6In3", + "Game3In1", +} + +XMoeWarConfig.RankType = { + Daily = 1, + Player = 2, +} + +XMoeWarConfig.EventType = { + Open = 1, + Change = 2, + VoteChange = 3, +} + +XMoeWarConfig.MailType = { + LastDay = 1, + ResultOut = 2, + VoteStart = 3, + VoteEnd = 4, +} + +XMoeWarConfig.SubTagType = { + Top = 0, --顶部 + Mid = 1, --中间 + Btm = 2, --底部 + All = 3, --唯一 +} + +XMoeWarConfig.TaskType = { + Daily = 1, --每日任务 + Normal = 2, --累计任务 +} + +XMoeWarConfig.ActionType = { + Intro = 1, + Thank = 2, +} + +--帮手状态 +XMoeWarConfig.PreparationHelperStatus = { + NotCommunicating = 0, --未通讯 + Communicating = 1, --通讯中 + CommunicationEnd = 2, --通讯结束 + RecruitFinish = 3, --已招募 +} + +--场外援助效果类型 +XMoeWarConfig.PreparationAssistanceEffectType = { + Null = 0, --空 + MaxCount = 1, --援助上限 + ExcludeWrongAnswer = 2, --排除错误选项 + RecoveryTime = 3, --恢复间隔 + HelperDuration = 4, --增加帮手时长 +} + +--招募答题信息类型 +XMoeWarConfig.RecruitMsgType = { + MyMsg = 1, + OtherMsg = 2, + MyNo = 3, + MyYes = 4, + Line = 5 +} + +--问题类型 +XMoeWarConfig.QuestionType = { + QuestionStart = 1, --开局问候 + RandomQuestion = 2, --随机问题 + RecruitRight = 3, --招募成功结语 + RecruitLose = 4, --招募失败结语 +} + +--赛事筹备开启状态 +XMoeWarConfig.MatchState = { + ["NotOpen"] = 1, --未开启 + ["Open"] = 2, --开启中 + ["Over"] = 3, --已结束 +} + +local InitPreparationAssistanceEffectIdList = function() + local cfg = {} + for effectId, v in pairs(MoeWarPreparationAssistance) do + tableInsert(cfg, v) + end + tableSort(cfg, function(a, b) + if a.Order ~= b.Order then + return a.Order < b.Order + end + return a.EffectId < b.EffectId + end) + for _, v in pairs(cfg) do + tableInsert(PreparationAssistanceEffectIdList, v.EffectId) + end +end + +function XMoeWarConfig.Init() + MoeWarActivity = XTableManager.ReadByIntKey(TABLE_MOEWAR_ACTIVITY, XTable.XTableMoeWarActivity, "Id") + MoeWarInitPair = XTableManager.ReadByIntKey(TABLE_MOEWAR_INIT_PAIR, XTable.XTableMoeWarInitPair, "Id") + MoeWarMail = XTableManager.ReadByIntKey(TABLE_MOEWAR_MAIL, XTable.XTableMoeWarMail, "Id") + MoeWarMatch = XTableManager.ReadByIntKey(TABLE_MOEWAR_MATCH, XTable.XTableMoeWarMatch, "Id") + MoeWarPlayers = XTableManager.ReadByIntKey(TABLE_MOEWAR_PLAYER_GROUP, XTable.XTableMoeWarPlayer, "Id") + MoeWarVoteItem = XTableManager.ReadByIntKey(TABLE_MOEWAR_VOTE_ITEM, XTable.XTableMoeWarVoteItem, "No") + MoeWarPlayerCfg = XTableManager.ReadByIntKey(TABLE_MOEWAR_PLAYER_CONFIG, XTable.XTableMoeWarPlayerLocal, "Id") + MoeWarTaskGroup = XTableManager.ReadByIntKey(TABLE_MOEWAR_TASK_GROUP, XTable.XTableMoeWarTaskGroup, "Id") + MoeWarRankGroup = XTableManager.ReadByIntKey(TABLE_MOEWAR_RANK_GROUP, XTable.XTableMoeRankGroup, "RankType") + MoeWarPreparationActivity = XTableManager.ReadByIntKey(TABLE_MOEWAR_PREPARATION_ACTIVITY, XTable.XTableMoeWarPreparationActivity, "Id") + MoeWarPreparationAssistance = XTableManager.ReadByIntKey(TABLE_MOEWAR_PREPARATION_ASSISTANCE, XTable.XTableMoeWarPreparationAssistance, "EffectId") + MoeWarPreparationGear = XTableManager.ReadByIntKey(TABLE_MOEWAR_PREPARATION_GEAR, XTable.XTableMoeWarPreparationGear, "Id") + MoeWarPreparationHelper = XTableManager.ReadByIntKey(TABLE_MOEWAR_PREPARATION_HELPER, XTable.XTableMoeWarPreparationHelper, "Id") + MoeWarPreparationMatch = XTableManager.ReadByIntKey(TABLE_MOEWAR_PREPARATION_MATCH, XTable.XTableMoeWarPreparationMatch, "Id") + MoeWarPreparationQuestion = XTableManager.ReadByIntKey(TABLE_MOEWAR_PREPARATION_QUESHION, XTable.XTableMoeWarPreparationQuestion, "Id") + MoeWarPreparationStage = XTableManager.ReadByIntKey(TABLE_MOEWAR_PREPARATION_STAGE, XTable.XTableMoeWarPreparationStage, "StageId") + MoeWarPreparationStageTagLabel = XTableManager.ReadByIntKey(TABLE_MOEWAR_PREPARATION_STAGE_TAG_LABEL, XTable.XTableMoeWarPreparationStageTagLabel, "Id") + MoeWarPreparationStageEvaluationLabel = XTableManager.ReadByIntKey(TABLE_MOEWAR_PREPARATION_STAGE_EVALUATION_LABEL, XTable.XTableMoeWarPreparationStageEvaluationLabel, "ReachNum") + MoeWarIconConfig = XTableManager.ReadByIntKey(TABLE_MOEWAR_ICON_CONFIG,XTable.XTableMoeWarIconConfig,"Id") + MoeWarActivityConfig = XTableManager.ReadByIntKey(TABLE_MOEWAR_ACTIVITY_CONFIG,XTable.XTableMoeWarActivityConfig,"Id") + MoeWarAnimation = XTableManager.ReadByIntKey(TABLE_MOEWAR_ANIMATION, XTable.XTableMoeWarAnimation, "Id") + MoeWarAnimationGroup = XTableManager.ReadByIntKey(TABLE_MOEWAR_ANIMATION_GROUP, XTable.XTableMoeWarAnimationGroup, "Id") + for _, v in ipairs(MoeWarPlayers) do + if not MoeWarGroups[v.Group] then + MoeWarGroups[v.Group] = {} + end + tableInsert(MoeWarGroups[v.Group], v) + end + + InitPreparationAssistanceEffectIdList() +end + +function XMoeWarConfig.GetPlayers() + return MoeWarPlayers +end + +function XMoeWarConfig.GetPlayerGroup(id) + return MoeWarPlayers[id].Group +end + +function XMoeWarConfig.GetGroups() + return MoeWarGroups +end + +function XMoeWarConfig.GetRankGroups() + return MoeWarRankGroup +end + +function XMoeWarConfig.GetRankGroupByType(type) + return MoeWarRankGroup[type] +end + +function XMoeWarConfig.GetGroupById(id) + return MoeWarGroups[id] +end + +function XMoeWarConfig.GetPlayerCfg(id) + local template = MoeWarPlayerCfg[id] + if not template then + XLog.ErrorTableDataNotFound("XMoeWarConfig.GetPlayerCfg", "MoeWarPlayerCfg", TABLE_MOEWAR_PLAYER_CONFIG, "Id", tostring(id)) + return + end + return template +end + +function XMoeWarConfig.GetActTemplates() + return MoeWarActivity +end + +function XMoeWarConfig.GetActivityTemplateById(id) + id = id or DefaultActivityId + if not MoeWarActivity[id] then + XLog.ErrorTableDataNotFound("XMoeWarConfig.GetActivityTemplateById", "MoeWarActivity", TABLE_MOEWAR_ACTIVITY, "Id", tostring(id)) + return + end + return MoeWarActivity[id] +end + +function XMoeWarConfig.GetInitPair(id) + return MoeWarInitPair[id] +end + +function XMoeWarConfig.GetMail(id) + return MoeWarMail[id] +end +function XMoeWarConfig.GetInitPairsByGroupId(groupId) + local tempList = {} + for k, v in pairs(MoeWarInitPair) do + if v.GroupId == groupId then + tableInsert(tempList, v) + end + end + return tempList +end + +function XMoeWarConfig.GetMatch(id) + return MoeWarMatch[id] +end + +function XMoeWarConfig.GetMatchCfgs() + return MoeWarMatch +end + +function XMoeWarConfig.GetVoteItems() + return MoeWarVoteItem +end + +function XMoeWarConfig.GetVoteItemById(id) + return MoeWarVoteItem[id] +end + +function XMoeWarConfig.GetVoteByItemId(ItemId) + return MoeWarVoteItem[ItemId] +end + +function XMoeWarConfig.GetTaskGroupCount() + return #MoeWarTaskGroup +end + +function XMoeWarConfig.GetTaskType(id) + if not MoeWarTaskGroup[id] then + XLog.ErrorTableDataNotFound("XMoeWarConfig.GetTaskType", "MoeWarTaskGroup", TABLE_MOEWAR_TASK_GROUP, "Id", tostring(id)) + return + end + return MoeWarTaskGroup[id].Type +end + +function XMoeWarConfig.GetTaskName(id) + if not MoeWarTaskGroup[id] then + XLog.ErrorTableDataNotFound("XMoeWarConfig.GetTaskName", "MoeWarTaskGroup", TABLE_MOEWAR_TASK_GROUP, "Id", tostring(id)) + return + end + return MoeWarTaskGroup[id].Name +end + +function XMoeWarConfig.GetTaskGroupId(id) + if not MoeWarTaskGroup[id] then + XLog.ErrorTableDataNotFound("XMoeWarConfig.GetTaskName", "MoeWarTaskGroup", TABLE_MOEWAR_TASK_GROUP, "Id", tostring(id)) + return + end + return MoeWarTaskGroup[id].Group +end + +function XMoeWarConfig.GetIconList(sessionId) + return MoeWarIconConfig[sessionId].IconList +end + +function XMoeWarConfig.GetActivityTimeId(id) + local template = XMoeWarConfig.GetActivityTemplateById(id) + return template.ActivityTimeId +end + +function XMoeWarConfig.GetActivityName(id) + local template = XMoeWarConfig.GetActivityTemplateById(id) + return template.Name +end + +function XMoeWarConfig.GetActivityBg(id) + local template = XMoeWarConfig.GetActivityTemplateById(id) + return template.Background +end + +function XMoeWarConfig.GetGachaSkipId() + return MoeWarActivityConfig[1].GachaSkipId +end + +function XMoeWarConfig.GetRewardSkipId() + return MoeWarActivityConfig[1].RewardSkipId +end + +function XMoeWarConfig.GetWebUrl() + return MoeWarActivityConfig[1].WebUrl +end + +function XMoeWarConfig.GetBeginStoryId() + return MoeWarActivityConfig[1].BeginStoryId +end + +function XMoeWarConfig.GetShowItems() + return MoeWarActivityConfig[1].ShowItem +end + +function XMoeWarConfig.GetMainHelpId() + return MoeWarActivityConfig[1].MainHelpId +end +function XMoeWarConfig.GetVoteHelpId() + return MoeWarActivityConfig[1].VoteHelpId +end +---------MoeWarPreparationActivity begin--------- +local GetPreparationActivity = function(id) + local template = MoeWarPreparationActivity[id] + if not template then + XLog.ErrorTableDataNotFound("XMoeWarConfig.GetMoeWarPreparationActivity", "MoeWarPreparationActivity", TABLE_MOEWAR_PREPARATION_ACTIVITY, "Id", tostring(id)) + return + end + return template +end + +function XMoeWarConfig.GetPreparationDefaultActivityId() + return MoeWarPreparationActivity[1] and MoeWarPreparationActivity[1].Id +end + +function XMoeWarConfig.GetPreparationActivityIdInTime(isGetDefaultActivityId) + local nowTime = XTime.GetServerNowTimestamp() + local lastOverEndTime = 0 + local defaultActivityId + for _, v in pairs(MoeWarPreparationActivity) do + if XFunctionManager.CheckInTimeByTimeId(v.TimeId) then + return v.Id + end + + --活动没有开启返回最新已结束的活动id + if isGetDefaultActivityId then + local endTime = XFunctionManager.GetEndTimeByTimeId(v.TimeId) + if nowTime >= endTime and endTime > lastOverEndTime then + lastOverEndTime = endTime + defaultActivityId = v.Id + end + end + end + return defaultActivityId +end + +function XMoeWarConfig.GetPreparationActivityTimeId(id) + local config = GetPreparationActivity(id) + return config.TimeId +end + +function XMoeWarConfig.GetPreparationActivityMatchIds(id) + local config = GetPreparationActivity(id) + local matchIds = {} + for _, matchId in ipairs(config.MatchIds) do + if matchId > 0 then + tableInsert(matchIds, matchId) + end + end + return matchIds +end + +function XMoeWarConfig.GetPreparationActivityMaxStageCount(id) + local config = GetPreparationActivity(id) + return config.MaxStageCount +end + +function XMoeWarConfig.GetPreparationActivityStageRecoveryTime(id) + local config = GetPreparationActivity(id) + return config.StageRecoveryTime +end + +function XMoeWarConfig.GetPreparationActivityPreparationGears(id) + local config = GetPreparationActivity(id) + return config.PreparationGears +end + +function XMoeWarConfig.GetPreparationActivityPrePreparationGear(id, preparationGearId) + local preparationGears = XMoeWarConfig.GetPreparationActivityPreparationGears(id) + for i, gearId in ipairs(preparationGears) do + if gearId == preparationGearId then + return preparationGears[i - 1] + end + end +end + +function XMoeWarConfig.GetPreparationActivityName(id) + local config = GetPreparationActivity(id) + return config.Name +end + +function XMoeWarConfig.GetPreparationActivityRedminNum(id) + local config = GetPreparationActivity(id) + return config.RedminNum +end +---------MoeWarPreparationActivity end----------- +---------MoeWarPreparationAssistance begin--------- +local GetMoeWarPreparationAssistance = function(id) + local template = MoeWarPreparationAssistance[id] + if not template then + XLog.ErrorTableDataNotFound("XMoeWarConfig.GetMoeWarPreparationAssistance", "MoeWarPreparationAssistance", TABLE_MOEWAR_PREPARATION_ASSISTANCE, "Id", tostring(id)) + return + end + return template +end + +local GetPreparationAssistanceIsShowInList = function(id) + local config = GetMoeWarPreparationAssistance(id) + return config.IsShowInList +end + +function XMoeWarConfig.GetPreparationAssistanceSupportMaxCount() + local voteItemId + local level = 0 + local maxCount = 0 + for _, v in pairs(MoeWarPreparationAssistance) do + if v.EffectType == XMoeWarConfig.PreparationAssistanceEffectType.MaxCount then + voteItemId = XDataCenter.MoeWarManager.GetSupportVoteItemCount(v.VoteItemId) + if voteItemId >= v.VoteItemCount and v.Level > level then + level = v.Level + maxCount = v.Param + end + end + end + return maxCount +end + +function XMoeWarConfig.GetPreparationAssistanceAllDifferVoteItemId() + local allDifferVoteItemIdDic = {} + local allDifferVoteItemIdList = {} + for _, v in pairs(MoeWarPreparationAssistance) do + if not allDifferVoteItemIdDic[v.VoteItemId] then + allDifferVoteItemIdDic[v.VoteItemId] = true + tableInsert(allDifferVoteItemIdList, v.VoteItemId) + end + end + return allDifferVoteItemIdList +end + +function XMoeWarConfig.GetPreparationAssistanceVoteItemId(id) + local config = GetMoeWarPreparationAssistance(id) + return config.VoteItemId +end + +function XMoeWarConfig.GetPreparationAssistanceVoteItemCount(id) + local config = GetMoeWarPreparationAssistance(id) + return config.VoteItemCount +end + +function XMoeWarConfig.GetPreparationAssistanceTitle(id) + local config = GetMoeWarPreparationAssistance(id) + return config.Title +end + +function XMoeWarConfig.GetPreparationAssistanceDesc(id) + local config = GetMoeWarPreparationAssistance(id) + return config.Desc +end + +function XMoeWarConfig.GetPreparationAssistanceEffectIdList(isNotShowInList) + if isNotShowInList then + local effectIdList = {} + local isShowInList + for _, effectId in ipairs(PreparationAssistanceEffectIdList) do + isShowInList = GetPreparationAssistanceIsShowInList(effectId) + if isShowInList == 1 then + tableInsert(effectIdList, effectId) + end + end + return effectIdList + end + + return PreparationAssistanceEffectIdList +end + +function XMoeWarConfig.GetPreparationAssistanceEffectType(id) + local config = GetMoeWarPreparationAssistance(id) + return config.EffectType +end + +function XMoeWarConfig.GetPreparationAssistanceParam(id) + local config = GetMoeWarPreparationAssistance(id) + return config.Param +end + +function XMoeWarConfig.GetPreparationAssistanceLevel(id) + local config = GetMoeWarPreparationAssistance(id) + return config.Level +end +---------MoeWarPreparationAssistance end----------- +---------MoeWarPreparationGear begin--------- +local GetMoeWarPreparationGear = function(id) + local template = MoeWarPreparationGear[id] + if not template then + XLog.ErrorTableDataNotFound("XMoeWarConfig.GetMoeWarPreparationGear", "MoeWarPreparationGear", TABLE_MOEWAR_PREPARATION_GEAR, "Id", tostring(id)) + return + end + return template +end + +function XMoeWarConfig.GetPreparationGearNeedCount(id) + local config = GetMoeWarPreparationGear(id) + return config.NeedCount +end + +function XMoeWarConfig.GetPreparationGearShowRewardId(id) + local config = GetMoeWarPreparationGear(id) + return config.ShowRewardId +end + +function XMoeWarConfig.GetPreparationGearMaxNeedCount(activityId) + local gears = XMoeWarConfig.GetPreparationActivityPreparationGears(activityId) + local maxNeedCount = 0 + local needCount + for _, gearId in ipairs(gears) do + needCount = XMoeWarConfig.GetPreparationGearNeedCount(gearId) + if needCount > maxNeedCount then + maxNeedCount = needCount + end + end + return maxNeedCount +end +---------MoeWarPreparationGear end----------- +---------MoeWarPreparationHelper begin--------- +local GetMoeWarPreparationHelper = function(id) + local template = MoeWarPreparationHelper[id] + if not template then + XLog.ErrorTableDataNotFound("XMoeWarConfig.GetMoeWarPreparationHelper", "MoeWarPreparationHelper", TABLE_MOEWAR_PREPARATION_HELPER, "Id", tostring(id)) + return + end + return template +end + +function XMoeWarConfig.GetMoeWarPreparationHelperRobotId(id) + local config = GetMoeWarPreparationHelper(id) + return config.RobotId +end + +function XMoeWarConfig.GetMoeWarPreparationHelperLabelIds(id) + local config = GetMoeWarPreparationHelper(id) + return config.LabelIds +end + +function XMoeWarConfig.GetMoeWarPreparationHelperTotalQuestionCount(id) + local questionCounts = XMoeWarConfig.GetMoeWarPreparationHelperQuestionCounts(id) + local questionBankIds = XMoeWarConfig.GetMoeWarPreparationHelperQuestionBankIds(id) + local totalCount = 0 + local questionBankIdCount + local realQuestionCount + for i, questionCount in ipairs(questionCounts) do + questionBankIdCount = XMoeWarConfig.GetPreparationQuestionBankIdCount(questionBankIds[i]) + realQuestionCount = questionBankIdCount < questionCount and questionBankIdCount or questionCount + totalCount = totalCount + realQuestionCount + end + return totalCount +end + +function XMoeWarConfig.GetMoeWarPreparationCommunicateConsumeCount(id) + local config = GetMoeWarPreparationHelper(id) + return config.CommunicateConsumeCount +end + +function XMoeWarConfig.GetCharacterFullNameByHelperId(helperId) + local robotId = XMoeWarConfig.GetMoeWarPreparationHelperRobotId(helperId) + local characterId = XRobotManager.GetCharacterId(robotId) + return XCharacterConfigs.GetCharacterFullNameStr(characterId) +end + +function XMoeWarConfig.GetMoeWarPreparationHelperQuestionCounts(id) + local config = GetMoeWarPreparationHelper(id) + return config.QuestionCounts +end + +function XMoeWarConfig.GetMoeWarPreparationHelperQuestionBankIds(id) + local config = GetMoeWarPreparationHelper(id) + return config.QuestionBankIds +end + +function XMoeWarConfig.GetMoeWarPreparationHelperCirleIcon(id) + local config = GetMoeWarPreparationHelper(id) + return config.CirleIcon +end +---------MoeWarPreparationHelper end----------- +---------MoeWarPreparationMatch begin--------- +local GetMoeWarPreparationMatch = function(id) + local template = MoeWarPreparationMatch[id] + if not template then + XLog.ErrorTableDataNotFound("XMoeWarConfig.GetMoeWarPreparationMatch", "MoeWarPreparationMatch", TABLE_MOEWAR_PREPARATION_MATCH, "Id", tostring(id)) + return + end + return template +end + +function XMoeWarConfig.GetPreparationMatchTimeId(id) + local config = GetMoeWarPreparationMatch(id) + return config.TimeId +end + +function XMoeWarConfig.GetPreparationMatchHelperIds(id) + local config = GetMoeWarPreparationMatch(id) + return config.HelperIds +end + +function XMoeWarConfig.GetPreparationMatchName(id) + local config = GetMoeWarPreparationMatch(id) + return config.Name +end + +function XMoeWarConfig.GetPreparationCurrOpenMatchId() + local timeId + for _, v in pairs(MoeWarPreparationMatch) do + timeId = XMoeWarConfig.GetPreparationMatchTimeId(v.Id) + if XFunctionManager.CheckInTimeByTimeId(timeId) then + return v.Id + end + end +end + +function XMoeWarConfig.IsFillPreparationStageLabel(stageLableId, helperId) + if not stageLableId or (not helperId or helperId == 0) then + return false + end + local helperLabelIds = XMoeWarConfig.GetMoeWarPreparationHelperLabelIds(helperId) + for index, helperLabelId in ipairs(helperLabelIds) do + if stageLableId == helperLabelId then + return true + end + end + return false +end + +function XMoeWarConfig.GetPreparationMatchNumText(id) + local config = GetMoeWarPreparationMatch(id) + return config.NumText or "" +end +---------MoeWarPreparationMatch end----------- +---------MoeWarPreparationQuestion begin--------- +local GetMoeWarPreparationQuestion = function(id) + local template = MoeWarPreparationQuestion[id] + if not template then + XLog.ErrorTableDataNotFound("XMoeWarConfig.GetMoeWarPreparationQuestion", "MoeWarPreparationQuestion", TABLE_MOEWAR_PREPARATION_QUESHION, "Id", tostring(id)) + return + end + return template +end + +function XMoeWarConfig.GetPreparationQuestionAnswers(id) + local config = GetMoeWarPreparationQuestion(id) + return config.Answers +end + +function XMoeWarConfig.GetPreparationQuestionAnswer(id, index) + local questionAnswers = XMoeWarConfig.GetPreparationQuestionAnswers(id) + return questionAnswers and questionAnswers[index] +end + +function XMoeWarConfig.GetPreparationQuestionPreChatId(id) + local config = GetMoeWarPreparationQuestion(id) + return config.PreChatId +end + +function XMoeWarConfig.GetPreparationQuestionIdListByType(helperId, questionType) + local questionIdList = {} + for _, v in pairs(MoeWarPreparationQuestion) do + if v.HelperId == helperId and v.Type == questionType then + tableInsert(questionIdList, v.Id) + end + end + + local questionSortIdList = {} + local questionIdDic = {} + local preChatId + local isStop = false + while not isStop do + isStop = true + for i, id in ipairs(questionIdList) do + preChatId = XMoeWarConfig.GetPreparationQuestionPreChatId(id) + if preChatId == 0 or questionIdDic[preChatId] then + tableInsert(questionSortIdList, id) + questionIdDic[id] = true + table.remove(questionIdList, i) + isStop = false + break + end + end + end + return questionSortIdList +end + +function XMoeWarConfig.GetPreparationQuestionType(id) + local config = GetMoeWarPreparationQuestion(id) + return config.Type +end + +function XMoeWarConfig.GetPreparationQuestion(id) + local config = GetMoeWarPreparationQuestion(id) + return config.Question +end + +function XMoeWarConfig.GetPreparationQuestionRightReply(id) + local config = GetMoeWarPreparationQuestion(id) + return config.RightReply +end + +function XMoeWarConfig.GetPreparationQuestionWrongReply(id) + local config = GetMoeWarPreparationQuestion(id) + return config.WrongReply +end + +function XMoeWarConfig.GetPreparationQuestionChat(id) + local config = GetMoeWarPreparationQuestion(id) + return config.Chat or "" +end + +function XMoeWarConfig.GetPreparationQuestionChatReply(id) + local config = GetMoeWarPreparationQuestion(id) + return config.ChatReply +end + +function XMoeWarConfig.GetPreparationQuestionHelperIcon(id) + local config = GetMoeWarPreparationQuestion(id) + return config.HelperIcon +end + +function XMoeWarConfig.GetPreparationQuestionId(helperId, questionType) + for _, v in pairs(MoeWarPreparationQuestion) do + if v.HelperId == helperId and questionType == v.Type then + return v.Id + end + end +end + +function XMoeWarConfig.GetPreparationQuestionBankIdCount(bankId) + local count = 0 + for _, v in pairs(MoeWarPreparationQuestion) do + if v.BankId == bankId then + count = count + 1 + end + end + return count +end + +function XMoeWarConfig.GetPreparationQuestionHelperName(id) + local config = GetMoeWarPreparationQuestion(id) + return config.HelperName +end +---------MoeWarPreparationQuestion end----------- +---------MoeWarPreparationStage begin--------- +local GetMoeWarPreparationStage = function(id) + local template = MoeWarPreparationStage[id] + if not template then + XLog.ErrorTableDataNotFound("XMoeWarConfig.GetMoeWarPreparationStage", "MoeWarPreparationStage", TABLE_MOEWAR_PREPARATION_STAGE, "Id", tostring(id)) + return + end + return template +end + +--筹备关卡界面的基本奖励 +function XMoeWarConfig.GetPreparationStageShowBaseRewardId(id) + local config = GetMoeWarPreparationStage(id) + return config.ShowBaseRewardId +end + +function XMoeWarConfig.GetPreparationStageLabelIds(id) + local config = GetMoeWarPreparationStage(id) + local labelIds = {} + for i, labelId in ipairs(config.LabelIds or {}) do + if labelId > 0 then + tableInsert(labelIds, labelId) + end + end + return labelIds +end + +function XMoeWarConfig.GetPreparationStageExtraRewardCount(stageId, showExtraRewardIdsIndex) + local showExtraRewardIds = XMoeWarConfig.GetPreparationStageShowExtraRewardIds(stageId) + local rewardId = showExtraRewardIds[showExtraRewardIdsIndex] + if not rewardId then + return 0 + end + + local rewardList = XRewardManager.GetRewardList(rewardId) + return rewardList[1].Count +end + +function XMoeWarConfig.GetPreparationStageShowExtraRewardIds(stageId) + local config = GetMoeWarPreparationStage(stageId) + return config.ShowExtraRewardIds +end + +function XMoeWarConfig.GetPreparationStageShowExtraRewardId(stageId, index) + local config = GetMoeWarPreparationStage(stageId) + local showExtraRewardIds = config.ShowExtraRewardIds + return showExtraRewardIds[index] +end + +function XMoeWarConfig.GetPreparationStageShowExtraRewardName(stageId, showExtraRewardIdsIndex) + local showExtraRewardIds = XMoeWarConfig.GetPreparationStageShowExtraRewardIds(stageId) + for index, showExtraRewardId in ipairs(showExtraRewardIds) do + if index == showExtraRewardIdsIndex then + local rewards = XRewardManager.GetRewardList(showExtraRewardId) + local templateId = rewards[1] and rewards[1].TemplateId + return (templateId and templateId > 0 and XGoodsCommonManager.GetGoodsName(templateId)) or "" + end + end + return "" +end + +function XMoeWarConfig.GetPreparationFillConditionCount(stageId, helperId) + local labelIds = XMoeWarConfig.GetPreparationStageLabelIds(stageId) + local fillConditionCount = 0 + for _, stageLabelId in ipairs(labelIds) do + if XMoeWarConfig.IsFillPreparationStageLabel(stageLabelId, helperId) then + fillConditionCount = fillConditionCount + 1 + end + end + return fillConditionCount +end + +--通讯次数奖励 +function XMoeWarConfig.GetPreparationStageShowSpecialRewardId(id) + local config = GetMoeWarPreparationStage(id) + return config.ShowSpecialRewardId +end + +--筹备界面每个关卡的奖励 +function XMoeWarConfig.GetPreparationStageShowAllRewardId(id) + local config = GetMoeWarPreparationStage(id) + return config.ShowAllRewardId +end +---------MoeWarPreparationStage end----------- +---------MoeWarPreparationStageTagLabel begin--------- +local GetPreparationStageTagLabel = function(id) + local template = MoeWarPreparationStageTagLabel[id] + if not template then + XLog.ErrorTableDataNotFound("XMoeWarConfig.GetMoeWarPreparationStageTagLabel", "MoeWarPreparationStageTagLabel", TABLE_MOEWAR_PREPARATION_STAGE_TAG_LABEL, "Id", tostring(id)) + return + end + return template +end + +function XMoeWarConfig.GetPreparationStageTagLabelById(id) + local config = GetPreparationStageTagLabel(id) + return config.TagLabel +end +---------MoeWarPreparationStageTagLabel end----------- +---------MoeWarPreparationStageEvaluationLabel begin---------- +local GetPreparationStageEvaluationLabel = function(id) + local template = MoeWarPreparationStageEvaluationLabel[id] + if not template then + XLog.ErrorTableDataNotFound("XMoeWarConfig.GetMoeWarPreparationStageEvaluationLabel", "MoeWarPreparationStageEvaluationLabel", TABLE_MOEWAR_PREPARATION_STAGE_EVALUATION_LABEL, "ReachNum", tostring(id)) + return + end + return template +end + +function XMoeWarConfig.GetPreparationStageEvaluationEvaluatioLabel(reachNum) + local config = GetPreparationStageEvaluationLabel(reachNum) + return config.EvaluatioLabel +end +---------MoeWarPreparationStageEvaluationLabel end------------ +---------------------场景动画相关 begin-------------------- +local function GetAnimationGroupConfig(groupId) + local config = MoeWarAnimationGroup[groupId] + if not config then + XLog.Error("XMoeWarConfig GetAnimationGroupConfig error:配置不存在, groupId: " .. groupId .. ", 配置路径: " .. TABLE_MOEWAR_ANIMATION_GROUP) + return + end + return config +end + +function XMoeWarConfig.GetAnimationIds(groupId) + local animationIds = {} + + local config = GetAnimationGroupConfig(groupId) + for _, animationId in ipairs(config.AnimationId) do + if XTool.IsNumberValid(animationId) then + tableInsert(animationIds, animationId) + end + end + + return animationIds +end + +function XMoeWarConfig.GetAnimationGroupInitModelName(groupId) + local config = GetAnimationGroupConfig(groupId) + return config.InitModelName +end + +function XMoeWarConfig.GetAnimationGroupInitAnim(groupId) + local config = GetAnimationGroupConfig(groupId) + return config.InitAnim +end + +local function GetAnimationConfig(animationId) + local config = MoeWarAnimation[animationId] + if not config then + XLog.Error("XMoeWarConfig GetAnimationConfig error:配置不存在, animationId: " .. animationId .. ", 配置路径: " .. TABLE_MOEWAR_ANIMATION) + return + end + return config +end + +function XMoeWarConfig.GetAnimationModelName(animationId) + local config = GetAnimationConfig(animationId) + return config.ModelName +end + +function XMoeWarConfig.GetAnimationAnimName(animationId) + local config = GetAnimationConfig(animationId) + return config.AnimName +end + +function XMoeWarConfig.GetAnimationSpeed(animationId) + local config = GetAnimationConfig(animationId) + return config.Speed +end + +function XMoeWarConfig.GetAnimationDistance(animationId) + local config = GetAnimationConfig(animationId) + return config.Distance +end + +function XMoeWarConfig.GetAnimationRoleEffect(animationId) + local config = GetAnimationConfig(animationId) + return config.RoleEffect, config.RoleEffectRoot +end + +function XMoeWarConfig.GetAnimationSceneEffect(animationId) + local config = GetAnimationConfig(animationId) + return config.SceneEffect, config.SceneEffectRoot +end + +XMoeWarConfig.ReloadAnimationConfigs = function() + MoeWarAnimation = XTableManager.ReadByIntKey(TABLE_MOEWAR_ANIMATION, XTable.XTableMoeWarAnimation, "Id") + MoeWarAnimationGroup = XTableManager.ReadByIntKey(TABLE_MOEWAR_ANIMATION_GROUP, XTable.XTableMoeWarAnimationGroup, "Id") +end +---------------------场景动画相关 end-------------------- diff --git a/Resources/Scripts/XConfig/XMovieAssembleConfig.lua b/Resources/Scripts/XConfig/XMovieAssembleConfig.lua new file mode 100644 index 00000000..b7a45079 --- /dev/null +++ b/Resources/Scripts/XConfig/XMovieAssembleConfig.lua @@ -0,0 +1,112 @@ +local tableInsert = table.insert + +XMovieAssembleConfig = XMovieAssembleConfig or {} + +local MOVIE_ASSEMBLE_PATH = "Client/MovieAssemble/MovieAssemble.tab" +local MOVIE_ASSEMBLE_TEMPLATE_PATH = "Client/MovieAssemble/MovieAssembleTemplate.tab" + +XMovieAssembleConfig.MovieAssembleWatchedKey = "MOVIE_ASSEMBLE_WATCHED_KEY" +XMovieAssembleConfig.MovieWatchedState = { + NotWatch = 0, + Watched = 1, +} + +local MovieAssembles = {} +local MovieAssembleTemplates = {} + +function XMovieAssembleConfig.Init() + MovieAssembles = XTableManager.ReadByIntKey(MOVIE_ASSEMBLE_PATH, XTable.XTableMovieAssemble, "Id") + MovieAssembleTemplates = XTableManager.ReadByIntKey(MOVIE_ASSEMBLE_TEMPLATE_PATH, XTable.XTableMovieAssembleTemplate, "Id") +end + +function XMovieAssembleConfig.GetMovieAssembleById(id) + if not MovieAssembles or not next(MovieAssembles) or not MovieAssembles[id] then + XLog.Error("Can't Find Movie Assemble Config By Id:"..id.." Please Check "..MOVIE_ASSEMBLE_PATH) + return nil + end + + return MovieAssembles[id] +end + +function XMovieAssembleConfig.GetMovieAssembleTmpById(id) + if not MovieAssembleTemplates or not next(MovieAssembleTemplates) or not MovieAssembleTemplates[id] then + XLog.Error("Can't Find Movie Assemble Template Config By Id:"..id.." Please Check "..MOVIE_ASSEMBLE_TEMPLATE_PATH) + return nil + end + + return MovieAssembleTemplates[id] +end + +-- MovieAssembleConfig +function XMovieAssembleConfig.GetBgImgUrlById(id) + local movieAssebleTmp = XMovieAssembleConfig.GetMovieAssembleById(id) + if not movieAssebleTmp then + return nil + end + + return movieAssebleTmp.BgImgUrl +end + +function XMovieAssembleConfig.GetUiPrefabById(id) + local movieAssebleTmp = XMovieAssembleConfig.GetMovieAssembleById(id) + if not movieAssebleTmp then + return nil + end + + return movieAssebleTmp.UiPrefab +end + +function XMovieAssembleConfig.GetMovieTmpPrefabById(id) + local movieAssebleTmp = XMovieAssembleConfig.GetMovieAssembleById(id) + if not movieAssebleTmp then + return nil + end + + return movieAssebleTmp.MovieTmpPrefab +end + +function XMovieAssembleConfig.GetMovieTmpIdsById(id) + local movieAssebleTmp = XMovieAssembleConfig.GetMovieAssembleById(id) + if not movieAssebleTmp then + return nil + end + + return movieAssebleTmp.MovieTmpIds +end + +-- MovieTemplateConfig +function XMovieAssembleConfig.GetMovieIdById(id) + local movieTmp = XMovieAssembleConfig.GetMovieAssembleTmpById(id) + if not movieTmp then + return nil + end + + return movieTmp.MovieId +end + +function XMovieAssembleConfig.GetMovieConditionIdById(id) + local movieTmp = XMovieAssembleConfig.GetMovieAssembleTmpById(id) + if not movieTmp then + return nil + end + + return movieTmp.ConditionId +end + +function XMovieAssembleConfig.GetMovieLockedBgUrlById(id) + local movieTmp = XMovieAssembleConfig.GetMovieAssembleTmpById(id) + if not movieTmp then + return nil + end + + return movieTmp.LockedBgUrl +end + +function XMovieAssembleConfig.GetMovieUnlockBgUrlById(id) + local movieTmp = XMovieAssembleConfig.GetMovieAssembleTmpById(id) + if not movieTmp then + return nil + end + + return movieTmp.UnlockBgUrl +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XMovieConfigs.lua b/Resources/Scripts/XConfig/XMovieConfigs.lua new file mode 100644 index 00000000..239bbcd5 --- /dev/null +++ b/Resources/Scripts/XConfig/XMovieConfigs.lua @@ -0,0 +1,166 @@ +local TABLE_MOVIE_PATH_PREFIX = "Client/Movie/Movies/Movie%s.tab" +local TABLE_MOVIE_ACTOR_PATH = "Client/Movie/MovieActor.tab" +local TABLE_MOVIE_ROLE_FACE_PATH = "Client/Movie/MovieRoleFace.tab" +local TABLE_MOVIE_SKIP_PATH = "Client/Movie/MovieSkips" +local TABLE_MOVIE_STAFF_PATH = "Client/Movie/MovieStaffs/" + +local stringFormat = string.format +local checkTableExist = CS.XTableManager.CheckTableExist +local vector = CS.UnityEngine.Vector2 +local tableInsert = table.insert +local pairs = pairs +local stringGsub = string.gsub + +local MovieTemplates = {} +local MovieActorTemplates = {} +local MovieRoleFaceTemplates = {} +local MovieSkipTemplates = {} +local MovieStaffTemplates = {} + +XMovieConfigs = XMovieConfigs or {} + +XMovieConfigs.PLAYER_NAME_REPLACEMENT = "【kuroname】" +XMovieConfigs.TYPE_WRITER_SPEED = 0.04 --打字机打一字速度 +XMovieConfigs.AutoPlayDelay = 1000 --自动播放对话默认停留时间 +XMovieConfigs.MAX_ACTOR_NUM = 5 +XMovieConfigs.MAX_ACTOR_ROLE_NUM = 3 + +local InitStaffConfigs = function() + local paths = CS.XTableManager.GetPaths(TABLE_MOVIE_STAFF_PATH) + XTool.LoopCollection(paths, function(path) + local key = XTool.GetFileNameWithoutExtension(path) + MovieStaffTemplates[key] = XTableManager.ReadByIntKey(path, XTable.XTableMovieStaff, "Id") + end) +end + +function XMovieConfigs.Init() + MovieActorTemplates = XTableManager.ReadByIntKey(TABLE_MOVIE_ACTOR_PATH, XTable.XTableMovieActor, "RoleId") + MovieRoleFaceTemplates = XTableManager.ReadByIntKey(TABLE_MOVIE_ROLE_FACE_PATH, XTable.XTableMovieRoleFace, "RoleId") + MovieSkipTemplates = XTableManager.ReadByStringKey(TABLE_MOVIE_SKIP_PATH, XTable.XTableMovieSkip, "Id") + + InitStaffConfigs() +end + +local function InitMovieTemplate(movieId) + local path = stringFormat(TABLE_MOVIE_PATH_PREFIX, movieId) + MovieTemplates[movieId] = XTableManager.ReadByIntKey(path, XTable.XTableMovieNew, "Id") +end + +function XMovieConfigs.CheckMovieConfigExist(movieId) + local path = stringFormat(TABLE_MOVIE_PATH_PREFIX, movieId) + return checkTableExist(path) +end + +function XMovieConfigs.GetMovieCfg(movieId) + if not MovieTemplates[movieId] then + InitMovieTemplate(movieId) + end + + local config = MovieTemplates[movieId] + if not config then + XLog.ErrorTableDataNotFound("XMovieConfigs.GetMovieCfg", "MovieConfig", stringFormat(TABLE_MOVIE_PATH_PREFIX, movieId), "Id", tostring(movieId)) + return + end + return config +end + +function XMovieConfigs.DeleteMovieCfgs() + MovieTemplates = {} +end + +function XMovieConfigs.GetActorImgPath(actorId) + local config = MovieActorTemplates[actorId] + if not config then + XLog.ErrorTableDataNotFound("XMovieConfigs.GetActorImgPath", "MovieActor", TABLE_MOVIE_ACTOR_PATH, "actorId", tostring(actorId)) + return + end + return config.RoleIcon +end + +function XMovieConfigs.GetActorFacePosVector2(actorId) + local config = MovieActorTemplates[actorId] + if not config then + XLog.ErrorTableDataNotFound("XMovieConfigs.GetActorFacePosVector2", "MovieActor", TABLE_MOVIE_ACTOR_PATH, "actorId", tostring(actorId)) + return + end + return vector(config.FacePosX, config.FacePosY) +end + +function XMovieConfigs.GetActorFaceImgPath(actorId, faceId) + local config = MovieRoleFaceTemplates[actorId] + if not config then + XLog.ErrorTableDataNotFound("XMovieConfigs.GetActorFaceImgPath", "MovieRoleFace", TABLE_MOVIE_ROLE_FACE_PATH, "actorId", tostring(actorId)) + return + end + + local face = config.FaceLook[faceId] + if not face then + XLog.ErrorTableDataNotFound("XMovieConfigs.GetActorFaceImgPath", "FaceLook", TABLE_MOVIE_ROLE_FACE_PATH, "actorId", tostring(actorId) .. " faceId :" .. tostring(faceId)) + return + end + + return face +end + +local function GetMovieSkipConfig(movieId) + local config = MovieSkipTemplates[movieId] + if not config then + XLog.ErrorTableDataNotFound("XMovieConfigs.GetMovieSkipHaveSkipDesc", "MovieSkip", TABLE_MOVIE_SKIP_PATH, "movieId", tostring(movieId)) + return + end + return config +end + +function XMovieConfigs.GetMovieSkipSkipDesc(movieId) + if not XMovieConfigs.IsMovieSkipHaveSkipDesc(movieId) then return "" end + + local config = GetMovieSkipConfig(movieId) + local skipDesc = config.SkipDesc + if not skipDesc then + XLog.ErrorTableDataNotFound("XMovieConfigs.GetMovieSkipHaveSkipDesc", "SkipDesc", TABLE_MOVIE_SKIP_PATH, "movieId", tostring(movieId)) + return "" + end + return string.gsub(skipDesc, "\\n", "\n") +end + +--C#这边也有调用 +function XMovieConfigs.IsMovieSkipHaveSkipDesc(movieId) + return MovieSkipTemplates[movieId] and true or false +end + +--职员表 begin-- +local GetStaffConfigs = function(staffPath) + local config = MovieStaffTemplates[staffPath] + if not config then + XLog.Error("XMovieConfigs GetStaffConfig error:配置不存在, Id: " .. staffPath .. ", 配置路径: " .. TABLE_MOVIE_STAFF_PATH) + return + end + return config +end + +local GetStaffConfig = function(staffPath, staffId) + local configs = GetStaffConfigs(staffPath) + local config = configs[staffId] + if not config then + XLog.Error("XMovieConfigs GetStaffConfig error:配置不存在, Id: " .. staffId .. ", 配置路径: " .. TABLE_MOVIE_STAFF_PATH) + return + end + return config +end + +function XMovieConfigs.GetStaffIdList(staffPath) + local staffIds = {} + + local config = GetStaffConfigs(staffPath) + for staffId in pairs(config) do + tableInsert(staffIds, staffId) + end + + return staffIds +end + +function XMovieConfigs.GetStaffName(staffPath, staffId) + local config = GetStaffConfig(staffPath, staffId) + return stringGsub(config.Name, "\\n", "\n") +end +--职员表 end-- diff --git a/Resources/Scripts/XConfig/XMusicPlayerConfigs.lua b/Resources/Scripts/XConfig/XMusicPlayerConfigs.lua new file mode 100644 index 00000000..0544a9eb --- /dev/null +++ b/Resources/Scripts/XConfig/XMusicPlayerConfigs.lua @@ -0,0 +1,79 @@ +-- +-- Author: wujie +-- Note: 音乐播放器配置相关 + +XMusicPlayerConfigs = XMusicPlayerConfigs or {} + +XMusicPlayerConfigs.UiMainSavedAlbumIdKey = "UiMainSavedAlbumId" + +local TABLE_ALBUM = "Client/MusicPlayer/MusicPlayerAlbum.tab" + +local AlbumTemplates +local AlbumIdList = {} + +function XMusicPlayerConfigs.Init() + XMusicPlayerConfigs.InitAlbum() + XMusicPlayerConfigs.CreateAlbumIdList() +end + +function XMusicPlayerConfigs.InitAlbum() + AlbumTemplates = XTableManager.ReadByIntKey(TABLE_ALBUM, XTable.XTableMusicPlayerAlbum,"Id") + + local cueIdDic = {} + local id + local cueId + local priority + for _, template in pairs(AlbumTemplates) do + id = template.Id + cueId = template.CueId + if not cueId or cueId == 0 then + XLog.ErrorTableDataNotFound("XMusicPlayerConfigs.InitAlbum", "cueId", TABLE_ALBUM, "id", tostring(id)) + end + + if not cueIdDic[cueId] then + cueIdDic[cueId] = true + else + XLog.Error("XMusicPlayerConfigs.InitAlbum 函数错误, 存在相同的cueId: " .. cueId .. "检查配置表: " .. TABLE_ALBUM) + end + + priority = template.Priority + if not priority or priority == 0 then + XLog.ErrorTableDataNotFound("XMusicPlayerConfigs.InitAlbum", "Priority", TABLE_ALBUM, "id", tostring(id)) + end + end +end + +function XMusicPlayerConfigs.CreateAlbumIdList() + for _, template in pairs(AlbumTemplates) do + table.insert(AlbumIdList, template.Id) + end + table.sort(AlbumIdList, function(aId, bId) + local aTemplate = AlbumTemplates[aId] + local bTemplate = AlbumTemplates[bId] + return aTemplate.Priority > bTemplate.Priority + end) +end + +function XMusicPlayerConfigs.GetAlbumIdList() + return AlbumIdList +end + +function XMusicPlayerConfigs.GetAlbumTemplateById(id) + local template = AlbumTemplates[id] + if template then + return template + end + XLog.ErrorTableDataNotFound("XMusicPlayerConfigs.GetAlbumTemplateById", "template", TABLE_ALBUM, "id", tostring(id)) +end + +function XMusicPlayerConfigs.IsHaveAlbumById(id) + return AlbumTemplates[id] ~= nil +end + +function XMusicPlayerConfigs.GetAlbumTemplateByCueId(cueId) + for _, template in pairs(AlbumTemplates) do + if template.CueId == cueId then + return template + end + end +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XNieRConfigs.lua b/Resources/Scripts/XConfig/XNieRConfigs.lua new file mode 100644 index 00000000..ea431c00 --- /dev/null +++ b/Resources/Scripts/XConfig/XNieRConfigs.lua @@ -0,0 +1,591 @@ +XNieRConfigs = XNieRConfigs or {} +local CLIENT_NIER_CHARACTERINFOMATION = "Client/Fuben/NieR/NieRCharacterInformation.tab" +local CLIENT_NIER_CHARACTERCLIENT = "Client/Fuben/NieR/NieRCharacterClient.tab" +local CLIENT_NIER_SHOP = "Client/Fuben/NieR/NieRShop.tab" +local CLIENT_NIER_REPEATSTAGECLIENT = "Client/Fuben/NieR/NieRRepeatableStageClient.tab" +local CLIENT_NIER_SUPPORTCLIENT = "Client/Fuben/NieR/NieRSupportClient.tab" +local CLIENT_NIER_SUPPORTSKILLCLIENT = "Client/Fuben/NieR/NieRSupportSkillClient.tab" +local CLIENT_NIER_TASK = "Client/Fuben/NieR/NieRTask.tab" +local CLIENT_NIER_EASTEREGGCLIENT = "Client/Fuben/NieR/NieREasterEggClient.tab" + +local SHARE_NIER_ACTIVITY = "Share/Fuben/NieR/NieRActivity.tab" +local SHARE_NIER_CHAPTER = "Share/Fuben/NieR/NieRChapter.tab" +local SHARE_NIER_CHARACTER = "Share/Fuben/NieR/NieRCharacter.tab" +local SHARE_NIER_CHARACTERLEVEL = "Share/Fuben/NieR/NieRCharacterLevel.tab" +local SHARE_NIER_REPSTAGE = "Share/Fuben/NieR/NieRRepeatableStage.tab" +local SHARE_NIER_ABILITYGROUP = "Share/Fuben/NieR/NieRAbilityGroup.tab" + +local SHARE_NIER_SUPPORT = "Share/Fuben/NieR/NieRSupport.tab" +local SHARE_NIER_SUPPORTLEVEL = "Share/Fuben/NieR/NieRSupportLevel.tab" +local SHARE_NIER_SUPPORTSKILLLEVEL = "Share/Fuben/NieR/NieRSupportSkillLevel.tab" + +local SHARE_NIER_EASTEREGGCOM = "Share/Fuben/NieR/NieREasterEggCommunication.tab" +local SHARE_NIER_EASTEREGGINITMESSAGE = "Share/Fuben/NieR/NieREasterEggInitMessage.tab" +local SHARE_NIER_EASTEREGGLABLE = "Share/Fuben/NieR/NieREasterEggLabel.tab" +local SHARE_NIER_EASTEREGGMESSAGE = "Share/Fuben/NieR/NieREasterEggMessage.tab" + +local NieRCharacterInforConfig = {} +local NieRCharacterInforDic = {} +local NieRCharacterClient = {} +local NieRCharacterShopClient = {} +local NieRRepeatableStageClient = {} +local ActivityConfig = {} +local ChapterConfig = {} +local CharacterConfig = {} +local CharacterLevelConfig = {} +local RepeatableStageConfig = {} +local AbilityGroupConfig = {} + +local NieREasterEggConfigCom = {} +local NieREasterEggClientConfig = {} +local NieREasterEggInitMessageConfig = {} +local NieREasterEggLabelConfig = {} +local NieREasterEggMessageConfig = {} +local NieREasterEggClientDic = {} + +local NieRSupportConfig = {} +local NieRSupportLevelConfig = {} +local NieRSupportLevelDic = {} +local NieRSupportMaxLevelDic = {} +local NieRSupportSkillLevelConfig = {} +local NieRSupportSkillLevelDic = {} +local NieRSupportMaxSkillLevelDic = {} +local NierRSupportConfigClient = {} +local NierRSupportSkillConfigClient = {} +local NieRSupportSkillLevelClientDic = {} + +local CharacterList = {} +local CharacterLevelDic = {} +local CharacterMaxLevelDic = {} +local AbilityGroupDic = {} +local AbilityIdToType = {} + +local NieRTaskConfig = {} + + +XNieRConfigs.NieRChInforStatue = { + Lock = 1, + UnLock = 2, + CanUnLock = 3, +} + +XNieRConfigs.NieRStageType = { + AssignStage = 1, + RepeatPoStage = 2, + BossStage = 3, + Teaching = 4, + RepeatStage = 5 +} + +XNieRConfigs.NieRPodSkillType = { + ActiveSkill = 0, + PassiveSkill = 1, +} + +XNieRConfigs.AbilityType = { + Skill = 1, + Fashion = 2, + Weapon = 3, + FourWafer = 4, + TwoWafer = 5, +} + +XNieRConfigs.EasterEggStoryType = { + NoThing = 0, + Leave = 1, + Revive = 2, +} +local DefaultActivityId = 0 +function XNieRConfigs.Init() + NieRCharacterInforConfig = XTableManager.ReadByIntKey(CLIENT_NIER_CHARACTERINFOMATION, XTable.XTableNieRCharacterInformation, "Id") + NieRCharacterClient = XTableManager.ReadByIntKey(CLIENT_NIER_CHARACTERCLIENT, XTable.XTableNieRCharacterClient, "CharacterId") + NieRCharacterShopClient = XTableManager.ReadByIntKey(CLIENT_NIER_SHOP, XTable.XTableNieRShopClient, "ShopId") + NieRRepeatableStageClient = XTableManager.ReadByIntKey(CLIENT_NIER_REPEATSTAGECLIENT, XTable.XTableNieRRepeatableStageClient, "StageId") + NierRSupportConfigClient = XTableManager.ReadByIntKey(CLIENT_NIER_SUPPORTCLIENT, XTable.XTableNieRSupportClient, "SupportId") + NierRSupportSkillConfigClient = XTableManager.ReadByIntKey(CLIENT_NIER_SUPPORTSKILLCLIENT, XTable.XTableNieRSupportSkillClient, "Id") + + ActivityConfig = XTableManager.ReadByIntKey(SHARE_NIER_ACTIVITY, XTable.XTableNieRActivity, "Id") + ChapterConfig = XTableManager.ReadByIntKey(SHARE_NIER_CHAPTER, XTable.XTableNieRChapter, "ChapterId") + CharacterConfig = XTableManager.ReadByIntKey(SHARE_NIER_CHARACTER, XTable.XTableNieRCharacter, "CharacterId") + CharacterLevelConfig = XTableManager.ReadByIntKey(SHARE_NIER_CHARACTERLEVEL, XTable.XTableNieRCharacterLevel, "Id") + RepeatableStageConfig = XTableManager.ReadByIntKey(SHARE_NIER_REPSTAGE, XTable.XTableNieRRepeatableStage, "RepeatableStageId") + AbilityGroupConfig = XTableManager.ReadByIntKey(SHARE_NIER_ABILITYGROUP, XTable.XTableNieRAbilityGroup, "Id") + + NieRSupportConfig = XTableManager.ReadByIntKey(SHARE_NIER_SUPPORT, XTable.XTableNieRSupport, "SupportId") + NieRSupportLevelConfig = XTableManager.ReadByIntKey(SHARE_NIER_SUPPORTLEVEL, XTable.XTableNieRSupportLevel, "Id") + NieRSupportSkillLevelConfig = XTableManager.ReadByIntKey(SHARE_NIER_SUPPORTSKILLLEVEL, XTable.XTableNieRSupportSkillLevel, "Id") + NieRTaskConfig = XTableManager.ReadByIntKey(CLIENT_NIER_TASK, XTable.XTableNieRTask, "TaskGroupId") + + NieREasterEggConfigCom = XTableManager.ReadByIntKey(SHARE_NIER_EASTEREGGCOM, XTable.XTableFunctionalCommunication, "Id") + NieREasterEggClientConfig = XTableManager.ReadByIntKey(CLIENT_NIER_EASTEREGGCLIENT, XTable.XTableNieREasterEggClient, "Id") + NieREasterEggInitMessageConfig = XTableManager.ReadByIntKey(SHARE_NIER_EASTEREGGINITMESSAGE, XTable.XTableNieREasterEggInitMessage, "Id") + NieREasterEggLabelConfig = XTableManager.ReadByIntKey(SHARE_NIER_EASTEREGGLABLE, XTable.XTableNieREasterEggLabel, "Id") + NieREasterEggMessageConfig = XTableManager.ReadByIntKey(SHARE_NIER_EASTEREGGMESSAGE, XTable.XTableNieREasterEggMessage, "Id") + + for _, config in pairs(CharacterConfig) do + table.insert(CharacterList, config) + end + table.sort(CharacterList, function(a, b) + return a.CharacterId < b.CharacterId + end) + + for _, config in pairs(CharacterLevelConfig) do + CharacterLevelDic[config.CharacterId] = CharacterLevelDic[config.CharacterId] or {} + CharacterLevelDic[config.CharacterId][config.Level] = config + + if not CharacterMaxLevelDic[config.CharacterId] or CharacterMaxLevelDic[config.CharacterId] < config.Level then + CharacterMaxLevelDic[config.CharacterId] = config.Level + end + end + + for activityId, config in pairs(ActivityConfig) do + if XTool.IsNumberValid(config.TimeId) then + DefaultActivityId = activityId + break + end + DefaultActivityId = activityId + end + XNieRConfigs.InitAbilityConfig() + XNieRConfigs.InitCharacterInformation() + XNieRConfigs.InitSupportCfg() + XNieRConfigs.InitNieREasterEggClientCfg() +end + +function XNieRConfigs.GetDefaultActivityId() + return DefaultActivityId +end + +function XNieRConfigs.InitNieREasterEggClientCfg() + NieREasterEggClientDic = {} + for _, config in pairs(NieREasterEggClientConfig) do + -- NieREasterEggClientDic[config.GroupId] = NieREasterEggClientDic[config.GroupId] or {} + -- table.insert(NieREasterEggClientDic[config.GroupId], config) + if not NieREasterEggClientDic[config.GroupId] or NieREasterEggClientDic[config.GroupId].Id > config.Id then + NieREasterEggClientDic[config.GroupId] = config + end + end +end + +function XNieRConfigs.InitCharacterInformation() + NieRCharacterInforDic = {} + for _, config in pairs(NieRCharacterInforConfig) do + NieRCharacterInforDic[config.CharacterId] = NieRCharacterInforDic[config.CharacterId] or {} + table.insert(NieRCharacterInforDic[config.CharacterId], config) + end +end + +function XNieRConfigs.InitAbilityConfig() + AbilityIdToType = {} + AbilityGroupDic = {} + for _, config in pairs(AbilityGroupConfig) do + AbilityGroupDic[config.AbilityGroupId] = AbilityGroupDic[config.AbilityGroupId] or {} + if config.SkillId ~= 0 then + if config.FashionId ~= 0 or config.WeaponId ~= 0 or #(config.WaferId) > 0 then + XLog.ErrorTableDataNotFound("XNieRConfigs.InitAbilityConfig", + SHARE_NIER_ABILITYGROUP, "Id", tostring(config.Id), "数据异常:每条数据仅允许配置一条生效属性") + end + AbilityIdToType[config.Id] = XNieRConfigs.AbilityType.Skill + elseif config.FashionId ~= 0 then + if config.SkillId ~= 0 or config.WeaponId ~= 0 or #(config.WaferId) > 0 then + XLog.ErrorTableDataNotFound("XNieRConfigs.InitAbilityConfig", + SHARE_NIER_ABILITYGROUP, "Id", tostring(config.Id), "数据异常:每条数据仅允许配置一条生效属性") + end + AbilityIdToType[config.Id] = XNieRConfigs.AbilityType.Fashion + elseif config.WeaponId ~= 0 then + if config.SkillId ~= 0 or config.FashionId ~= 0 or #(config.WaferId) > 0 then + XLog.ErrorTableDataNotFound("XNieRConfigs.InitAbilityConfig", + SHARE_NIER_ABILITYGROUP, "Id", tostring(config.Id), "数据异常:每条数据仅允许配置一条生效属性") + end + AbilityIdToType[config.Id] = XNieRConfigs.AbilityType.Weapon + elseif #(config.WaferId) > 0 then + if config.SkillId ~= 0 or config.FashionId ~= 0 or config.WeaponId ~= 0 then + XLog.ErrorTableDataNotFound("XNieRConfigs.InitAbilityConfig", + SHARE_NIER_ABILITYGROUP, "Id", tostring(config.Id), "数据异常:每条数据仅允许配置一条生效属性") + elseif (#(config.WaferId) ~= 2 and #(config.WaferId) ~= 4) then + XLog.ErrorTableDataNotFound("XNieRConfigs.InitAbilityConfig", + SHARE_NIER_ABILITYGROUP, "Id", tostring(config.Id), "数据异常:意识数目应为2或4") + end + if (#(config.WaferId) == 4) then + AbilityIdToType[config.Id] = XNieRConfigs.AbilityType.FourWafer + else + AbilityIdToType[config.Id] = XNieRConfigs.AbilityType.TwoWafer + end + + end + table.insert(AbilityGroupDic[config.AbilityGroupId], config) + end +end + +function XNieRConfigs.InitSupportCfg() + NieRSupportLevelDic = {} + NieRSupportMaxLevelDic = {} + for _, cfg in pairs(NieRSupportLevelConfig) do + NieRSupportLevelDic[cfg.SupportId] = NieRSupportLevelDic[cfg.SupportId] or {} + NieRSupportLevelDic[cfg.SupportId][cfg.Level] = cfg + if not NieRSupportMaxLevelDic[cfg.SupportId] or NieRSupportMaxLevelDic[cfg.SupportId] < cfg.Level then + NieRSupportMaxLevelDic[cfg.SupportId] = cfg.Level + end + end + + NieRSupportSkillLevelDic = {} + NieRSupportMaxSkillLevelDic = {} + for _, cfg in pairs(NieRSupportSkillLevelConfig) do + NieRSupportSkillLevelDic[cfg.SkillId] = NieRSupportSkillLevelDic[cfg.SkillId] or {} + NieRSupportSkillLevelDic[cfg.SkillId][cfg.Level] = cfg + if not NieRSupportMaxSkillLevelDic[cfg.SkillId] or NieRSupportMaxSkillLevelDic[cfg.SkillId] < cfg.Level then + NieRSupportMaxSkillLevelDic[cfg.SkillId] = cfg.Level + end + end + + NieRSupportSkillLevelClientDic = {} + for _, cfg in pairs(NierRSupportSkillConfigClient) do + NieRSupportSkillLevelClientDic[cfg.SkillId] = NieRSupportSkillLevelClientDic[cfg.SkillId] or {} + NieRSupportSkillLevelClientDic[cfg.SkillId][cfg.Level] = cfg + end + +end + +function XNieRConfigs.GetNieRCharacterInforById(id) + if not NieRCharacterInforConfig or not NieRCharacterInforConfig[id] then + XLog.ErrorTableDataNotFound("XNieRConfigs.GetNieRCharacterInforById", "数据异常", + CLIENT_NIER_CHARACTERINFOMATION, "id", tostring(id)) + end + return NieRCharacterInforConfig[id] +end + +function XNieRConfigs.GetNieRCharacterInforListById(characterId) + if not NieRCharacterInforDic or not NieRCharacterInforDic[characterId] then + XLog.ErrorTableDataNotFound("XNieRConfigs.GetNieRCharacterInforListById", "数据异常", + CLIENT_NIER_CHARACTERINFOMATION, "characterId", tostring(characterId)) + end + return NieRCharacterInforDic[characterId] +end + +function XNieRConfigs.GetActivityConfigById(activityId) + if not ActivityConfig or not ActivityConfig[activityId] then + XLog.ErrorTableDataNotFound("XNieRConfigs.GetActivityConfig", "数据异常", + SHARE_NIER_ACTIVITY, "activityId", tostring(activityId)) + end + return ActivityConfig[activityId] or {} +end + +function XNieRConfigs.GetAllActivityConfig() + if not ActivityConfig then + XLog.ErrorTableDataNotFound("XNieRConfigs.GetActivityConfig", "数据异常", + SHARE_NIER_ACTIVITY) + end + return ActivityConfig or {} +end + +--根据Id获取章节配置 +function XNieRConfigs.GetChapterConfigById(chapterId) + if not ChapterConfig or not ChapterConfig[chapterId] then + XLog.ErrorTableDataNotFound("XNieRConfigs.GetChapterConfigById", "数据异常", + SHARE_NIER_CHAPTER, "chapterId", tostring(chapterId)) + end + return ChapterConfig[chapterId] or {} +end + +--获取章节配置 +function XNieRConfigs.GetAllChapterConfig() + if not ChapterConfig then + XLog.ErrorTableDataNotFound("XNieRConfigs.GetChapterConfigById", "数据异常", + SHARE_NIER_CHAPTER) + end + return ChapterConfig or {} +end + +--根据Id获取角色配置 +function XNieRConfigs.GetCharacterConfigById(characterId) + if not CharacterConfig or not CharacterConfig[characterId] then + XLog.ErrorTableDataNotFound("XNieRConfigs.GetCharacterConfigById", "数据异常", + SHARE_NIER_CHARACTER, "characterId", tostring(characterId)) + end + return CharacterConfig[characterId] or {} +end + +--获取角色配置 +function XNieRConfigs.GetAllCharacterConfig() + if not CharacterConfig then + XLog.ErrorTableDataNotFound("XNieRConfigs.GetCharacterConfigById", "数据异常", + SHARE_NIER_CHARACTER) + end + return CharacterConfig or {} +end + +--获取客户端配置 +function XNieRConfigs.GetCharacterClientConfigById(characterId) + if not NieRCharacterClient or not NieRCharacterClient[characterId] then + XLog.ErrorTableDataNotFound("XNieRConfigs.GetCharacterClientConfigById", "数据异常", + CLIENT_NIER_CHARACTERCLIENT, "characterId", tostring(characterId)) + end + return NieRCharacterClient[characterId] or {} +end + +--获取角色等级配置 +function XNieRConfigs.GetCharacterLevelConfig(characterId, level) + if not CharacterLevelDic or not CharacterLevelDic[characterId] or not CharacterLevelDic[characterId][level] then + XLog.ErrorTableDataNotFound("XNieRConfigs.GetCharacterLevelConfig", "数据异常", + SHARE_NIER_CHARACTERLEVEL, "characterId = " .. tostring(characterId), "level = " .. tostring(level)) + return {} + end + return CharacterLevelDic[characterId][level] +end + +--获取角色最大等级 +function XNieRConfigs.GetCharacterMaxLevelById(characterId) + if not CharacterMaxLevelDic or not CharacterMaxLevelDic[characterId] then + XLog.ErrorTableDataNotFound("XNieRConfigs.GetCharacterMaxLevelById", "数据异常", + SHARE_NIER_CHARACTERLEVEL, "characterId", tostring(characterId)) + return {} + end + return CharacterMaxLevelDic[characterId] +end + +--根据Id获取能力配置 +function XNieRConfigs.GetAbilityGroupConfigById(Id) + if not AbilityGroupConfig or not AbilityGroupConfig[Id] then + XLog.ErrorTableDataNotFound("XNieRConfigs.GetAbilityGroupConfigById", "数据异常", + SHARE_NIER_ABILITYGROUP, "Id", tostring(Id)) + end + return AbilityGroupConfig[Id] or {} +end + +--根据Id获取能力配置 +function XNieRConfigs.GetAbilityGroupConfigByGroupId(abilityGroupId) + if not AbilityGroupDic or not AbilityGroupDic[abilityGroupId] then + XLog.ErrorTableDataNotFound("XNieRConfigs.GetAbilityGroupConfigByGroupId", "数据异常", + SHARE_NIER_ABILITYGROUP, "abilityGroupId", tostring(abilityGroupId)) + end + return AbilityGroupDic[abilityGroupId] or {} +end + +-- +function XNieRConfigs.GetAbilityTypeById(id) + if not AbilityIdToType or not AbilityIdToType[id] then + XLog.ErrorTableDataNotFound("XNieRConfigs.GetAbilityTypeById", "AbilityType没有初始化或配置异常", + SHARE_NIER_ABILITYGROUP, "id", tostring(id)) + end + return AbilityIdToType[id] or 0 +end + +--根据Id获取复刷关配置 +function XNieRConfigs.GetRepeatableStageConfigById(repeatableStageId) + if not RepeatableStageConfig or not RepeatableStageConfig[repeatableStageId] then + XLog.ErrorTableDataNotFound("XNieRConfigs.GetRepeatableStageConfigById", "数据异常", + SHARE_NIER_REPSTAGE, "repeatableStageId", tostring(repeatableStageId)) + end + return RepeatableStageConfig[repeatableStageId] or {} +end + +--获取复刷关配置 +function XNieRConfigs.GetRepeatableStageConfig() + if not RepeatableStageConfig then + XLog.ErrorTableDataNotFound("XNieRConfigs.GetRepeatableStageConfigById", "数据异常", + SHARE_NIER_REPSTAGE) + end + return RepeatableStageConfig or {} +end + +function XNieRConfigs.GetNieRShopById(shopId) + if not NieRCharacterShopClient or not NieRCharacterShopClient[shopId] then + XLog.ErrorTableDataNotFound("XNieRConfigs.GetNieRShopById", "数据异常", + CLIENT_NIER_SHOP, "shopId", tostring(shopId)) + end + return NieRCharacterShopClient[shopId] +end + +function XNieRConfigs.GetNieRRepeatableStageClient(stageId) + if not NieRRepeatableStageClient or not NieRRepeatableStageClient[stageId] then + XLog.ErrorTableDataNotFound("XNieRConfigs.GetNieRRepeatableStageClient", "数据异常", + CLIENT_NIER_SHOP, "stageId", tostring(stageId)) + end + return NieRRepeatableStageClient[stageId] +end + +--获取尼尔角色列表 +function XNieRConfigs.GetCharacterList() + return CharacterList +end + +--获取辅助机配置 +function XNieRConfigs.GetNieRSupportConfig(supportId) + if not NieRSupportConfig or not NieRSupportConfig[supportId] then + XLog.ErrorTableDataNotFound("XNieRConfigs.GetNieRSupportConfig", "数据异常", + SHARE_NIER_SUPPORT, "supportId", tostring(supportId)) + end + return NieRSupportConfig[supportId] +end + +--获取辅助机等级配置 +function XNieRConfigs.GetNieRSupportLevelConfig(id) + if not NieRSupportLevelConfig or not NieRSupportLevelConfig[id] then + XLog.ErrorTableDataNotFound("XNieRConfigs.GetNieRSupportLevelConfig", "数据异常", + SHARE_NIER_SUPPORTLEVEL, "id", tostring(id)) + end + return NieRSupportLevelConfig[id] +end + +--获取辅助机等级配置 +function XNieRConfigs.GetNieRSupportLevelCfgBuyIdAndLevel(supportId, level) + if not NieRSupportLevelDic or not NieRSupportLevelDic[supportId] or not NieRSupportLevelDic[supportId][level] then + XLog.ErrorTableDataNotFound("XNieRConfigs.GetNieRSupportLevelCfgBuyIdAndLevel", + SHARE_NIER_SUPPORTLEVEL, "supportId = " .. tostring(supportId), "level = " .. tostring(level)) + end + return NieRSupportLevelDic[supportId][level] +end + +--获取辅助机最大等级 +function XNieRConfigs.GetNieRSupportMaxLevelById(supportId) + if not NieRSupportMaxLevelDic or not NieRSupportMaxLevelDic[supportId] then + XLog.ErrorTableDataNotFound("XNieRConfigs.GetNieRSupportMaxLevelById", "数据异常", + SHARE_NIER_SUPPORTLEVEL, "supportId", tostring(supportId)) + end + return NieRSupportMaxLevelDic[supportId] +end + +--获取所有辅助机技能 +function XNieRConfigs.GetAllNieRSupportSkillLevelConfig() + if not NieRSupportSkillLevelConfig then + XLog.ErrorTableDataNotFound("XNieRConfigs.GetNieRSupportSkillLevelConfig", "数据异常", + SHARE_NIER_SUPPORTSKILLLEVEL) + end + return NieRSupportSkillLevelConfig +end + +--获取辅助机技能配置 +function XNieRConfigs.GetNieRSupportSkillLevelConfig(skillId) + if not NieRSupportSkillLevelConfig or not NieRSupportSkillLevelConfig[skillId] then + XLog.ErrorTableDataNotFound("XNieRConfigs.GetNieRSupportSkillLevelConfig", "数据异常", + SHARE_NIER_SUPPORTSKILLLEVEL, "skillId", tostring(skillId)) + end + return NieRSupportSkillLevelConfig[skillId] +end + +--根据id和等级获取辅助机技能配置 +function XNieRConfigs.GetNieRSupportSkillLevelCfgBuyIdAndLevel(skillId, level) + if not NieRSupportSkillLevelDic or not NieRSupportSkillLevelDic[skillId] or not NieRSupportSkillLevelDic[skillId][level] then + XLog.ErrorTableDataNotFound("XNieRConfigs.GetNieRSupportSkillLevelCfgBuyIdAndLevel", "数据异常", + SHARE_NIER_SUPPORTSKILLLEVEL, "skillId =" .. tostring(skillId), "level =" .. tostring(level)) + end + return NieRSupportSkillLevelDic[skillId][level] +end + +--获取辅助机技能最大等级 +function XNieRConfigs.GetNieRSupportMaxSkillLevelById(skillId) + if not NieRSupportMaxSkillLevelDic or not NieRSupportMaxSkillLevelDic[skillId] then + XLog.ErrorTableDataNotFound("XNieRConfigs.GetNieRSupportMaxSkillLevelById", "数据异常", + SHARE_NIER_SUPPORTSKILLLEVEL, "skillId", tostring(skillId)) + end + return NieRSupportMaxSkillLevelDic[skillId] +end + +--获取辅助机客户端配置 +function XNieRConfigs.GetNieRSupportClientConfig(id) + if not NierRSupportConfigClient or not NierRSupportConfigClient[id] then + XLog.ErrorTableDataNotFound("XNieRConfigs.GetNieRSupportClientConfig", "数据异常", + CLIENT_NIER_SUPPORTCLIENT, "id", tostring(id)) + end + return NierRSupportConfigClient[id] +end + +--根据Id和lv获取辅助机技能客户端配置 +function XNieRConfigs.GetNieRSupportSkillClientConfig(id, level) + if not NieRSupportSkillLevelClientDic or not NieRSupportSkillLevelClientDic[id] or not NieRSupportSkillLevelClientDic[id][level] then + XLog.ErrorTableDataNotFound("XNieRConfigs.GetNieRSupportSkillClientConfig", "数据异常", + CLIENT_NIER_SUPPORTSKILLCLIENT, "id = " .. tostring(id), "level = " .. tostring(level)) + end + return NieRSupportSkillLevelClientDic[id][level] +end + +--根据groupId获取尼尔任务 +function XNieRConfigs.GetNieRTaskGroupByGroupId(groupId) + if not NieRTaskConfig or not NieRTaskConfig[groupId] then + XLog.ErrorTableDataNotFound("XNieRConfigs.GetNieRTaskGroupByGroupId", "数据异常", + CLIENT_NIER_TASK, "groupId = ", tostring(groupId)) + end + return NieRTaskConfig[groupId] +end + +--获取彩蛋关播放剧情 +function XNieRConfigs.GetNieREasterEggComConfig() + if not NieREasterEggConfigCom or not NieREasterEggConfigCom[1] then + XLog.ErrorTableDataNotFound("XNieRConfigs.GetNieREasterEggComConfig", "数据异常", + SHARE_NIER_EASTEREGGCOM, "Id = ", tostring(1)) + end + return NieREasterEggConfigCom[1] +end + +--获取彩蛋关死亡剧情 +function XNieRConfigs.GetNieREasterEggClientConfigById(id) + if not NieREasterEggClientConfig or not NieREasterEggClientConfig[id] then + XLog.ErrorTableDataNotFound("XNieRConfigs.GetNieREasterEggClientConfigById", "数据异常", + CLIENT_NIER_EASTEREGGCLIENT, "Id = ", tostring(id)) + end + return NieREasterEggClientConfig[id] +end + +--获取彩蛋关死亡剧情 +function XNieRConfigs.GetNieREasterEggClientConfigByGroupId(id) + if not NieREasterEggClientDic or not NieREasterEggClientDic[id] then + XLog.ErrorTableDataNotFound("XNieRConfigs.GetNieREasterEggClientConfigByGroupId", "数据异常", + CLIENT_NIER_EASTEREGGCLIENT, "Id = ", tostring(id)) + end + return NieREasterEggClientDic[id] +end + +function XNieRConfigs.GetNieREasterEggInitMessageConfig() + local list = {} + for _, config in pairs(NieREasterEggInitMessageConfig) do + table.insert(list, config) + end + local mgsCount = #list + for i = 1, mgsCount / 2 do + local index1 = math.random(1, mgsCount) + local index2 = math.random(1, mgsCount) + local config = list[index1] + list[index1] = list[index2] + list[index2] = config + end + return list +end + +function XNieRConfigs.GetNieREasterEggLabelConfigById(id) + if not NieREasterEggLabelConfig or not NieREasterEggLabelConfig[id] then + XLog.ErrorTableDataNotFound("XNieRConfigs.GetNieREasterEggLabelConfigs", "数据异常", + SHARE_NIER_EASTEREGGLABLE, "Id = ", tostring(id)) + end + return NieREasterEggLabelConfig[id] +end + +function XNieRConfigs.GetNieREasterEggLabelConfigs() + if not NieREasterEggLabelConfig then + XLog.ErrorTableDataNotFound("XNieRConfigs.GetNieREasterEggLabelConfigs", "数据异常", + SHARE_NIER_EASTEREGGLABLE) + end + local list = {} + for _, config in pairs(NieREasterEggLabelConfig) do + table.insert(list, config) + end + return list +end + +function XNieRConfigs.GetNieREasterEggMessageConfigById(id) + if not NieREasterEggMessageConfig or not NieREasterEggMessageConfig[id] then + XLog.ErrorTableDataNotFound("XNieRConfigs.GetNieREasterEggMessageConfigs", "数据异常", + SHARE_NIER_EASTEREGGLABLE, "Id = ", tostring(id)) + end + return NieREasterEggMessageConfig[id] +end + +function XNieRConfigs.GetNieREasterEggMessageConfigs() + if not NieREasterEggMessageConfig then + XLog.ErrorTableDataNotFound("XNieRConfigs.GetNieREasterEggMessageConfigs", "数据异常", + SHARE_NIER_EASTEREGGLABLE) + end + local list = {} + for _, config in pairs(NieREasterEggMessageConfig) do + table.insert(list, config) + end + return list +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XPartnerConfigs.lua b/Resources/Scripts/XConfig/XPartnerConfigs.lua new file mode 100644 index 00000000..4f605a97 --- /dev/null +++ b/Resources/Scripts/XConfig/XPartnerConfigs.lua @@ -0,0 +1,497 @@ +XPartnerConfigs = XPartnerConfigs or {} + +local TABLE_PARTNER = "Share/Partner/Partner.tab" +local TABLE_PARTNER_LEVELUP_PATH = "Share/Partner/LevelUpTemplate" +local TABLE_PARTNER_BREAK_THROIGH = "Share/Partner/PartnerBreakThrough.tab" +local TABLE_PARTNER_QUALITY = "Share/Partner/PartnerQuality.tab" +local TABLE_PARTNER_SKILL = "Share/Partner/PartnerSkill.tab" +local TABLE_PARTNER_MAINSKILL_GROUP = "Share/Partner/PartnerMainSkillGroup.tab" +local TABLE_PARTNER_PASSIVESKILL_GROUP = "Share/Partner/PartnerPassiveSkillGroup.tab" +local TABLE_PARTNER_SKILLEFFECT = "Share/Partner/PartnerSkillEffect.tab" +local TABLE_PARTNER_SKILLINFO = "Client/Partner/PartnerSkillInfo.tab" +local TABLE_PARTNER_MODEL = "Client/Partner/PartnerModel.tab" +local TABLE_PARTNER_ITEM_SKIP = "Client/Partner/PartnerItemSkipId.tab" + +local PartnerTemplateCfg = {} +local PartnerBreakthroughCfg = {} +local PartnerQualityCfg = {} +local PartnerSkillCfg = {} +local PartnerMainSkillGroupCfg = {} +local PartnerPassiveSkillGroupCfg = {} +local PartnerSkillEffectCfg = {} +local PartnerSkillInfoCfg = {} +local PartnerModelCfg = {} +local PartnerItemSkipIdCfg = {} + +local PartnerBreakthroughDic = {} +local PartnerQualityDic = {} +local PartnerSkillEffectDic = {} +local PartnerSkillInfoDic = {} +local PartnerMainSkillGroupDic = {} +local PartnerPassiveSkillGroupDic = {} +local LevelUpTemplates = {} + +XPartnerConfigs.SkillType = { + MainSkill = 1, + PassiveSkill = 2, + } + +XPartnerConfigs.SkillElement = { + Physics = 1, + Fire = 2, + Ice = 3, + Thunder = 4, + Dark = 5, +} + +XPartnerConfigs.SortType = { + Ability = 1,--战力 + Quality = 2,--品质 + Breakthrough = 3,--突破 + Level = 4,--等级 + SkillLevel = 5,--技能等级 + Lock = 6,--上锁 + Priority = 7,--优先级 + Stack = 8,--堆叠 + CanCompose = 9,--可以合成 + Carry = 10,--是否佩戴 +} + +XPartnerConfigs.MainUiState = { + None = 0, + Overview = 1,--总览 + Compose = 2,--合成 + Property = 3,--养成 +} + +XPartnerConfigs.PartnerState = { + Standby = 1,--待机模式 + Combat = 2,--战斗模式 +} + +XPartnerConfigs.PartnerType = { + All = 0, + Normal = 1, + Isomer = 2, +} + +XPartnerConfigs.CameraType = { + Standby = 1, + Combat = 2, + Overview = 2, + Compose = 3, + Level = 4, + Quality = 5, + Skill = 6, + Story = 7, + StandbyNoSelect = 8, + CombatNoSelect = 9, +} + +XPartnerConfigs.DataSyncType = { + Obtain = 1, + Skill = 2, + Carry = 3, + UnlockSkillGroup = 4, + QualityUp = 5, +} + +XPartnerConfigs.AttrSortType = { + XNpcAttribType.AttackNormal, +} + +XPartnerConfigs.BagShowType = { + View = 1, + Decompose = 2, +} + +XPartnerConfigs.BagSortType = { + [0] = XPartnerConfigs.SortType.Quality, + [1] = XPartnerConfigs.SortType.Breakthrough, + [2] = XPartnerConfigs.SortType.Level, +} + +XPartnerConfigs.QualityString = { + [1] = "B", + [2] = "A", + [3] = "S", + [4] = "SS", + [5] = "SSS", + [6] = "SSS+", +} + +local PartnerBreakThroughIcon = { + [0] = CS.XGame.ClientConfig:GetString("PartnerBreakThrough0"), + [1] = CS.XGame.ClientConfig:GetString("PartnerBreakThrough1"), + [2] = CS.XGame.ClientConfig:GetString("PartnerBreakThrough2"), + [3] = CS.XGame.ClientConfig:GetString("PartnerBreakThrough3"), +} + +local QualityBgPath = { + CS.XGame.ClientConfig:GetString("CommonBagGold"), + CS.XGame.ClientConfig:GetString("CommonBagGold"), + CS.XGame.ClientConfig:GetString("CommonBagRed"), + CS.XGame.ClientConfig:GetString("CommonBagRed"), + CS.XGame.ClientConfig:GetString("CommonBagRed"), + CS.XGame.ClientConfig:GetString("CommonBagRed"), +} + + +XPartnerConfigs.MainSkillCount = 1 + +XPartnerConfigs.PassiveSkillCount = 5 + + +function XPartnerConfigs.Init() + PartnerTemplateCfg = XTableManager.ReadByIntKey(TABLE_PARTNER, XTable.XTablePartner, "Id") + PartnerBreakthroughCfg = XTableManager.ReadByIntKey(TABLE_PARTNER_BREAK_THROIGH, XTable.XTablePartnerBreakThrough, "Id") + PartnerQualityCfg = XTableManager.ReadByIntKey(TABLE_PARTNER_QUALITY, XTable.XTablePartnerQuality, "Id") + PartnerSkillCfg = XTableManager.ReadByIntKey(TABLE_PARTNER_SKILL, XTable.XTablePartnerSkill, "PartnerId") + PartnerMainSkillGroupCfg = XTableManager.ReadByIntKey(TABLE_PARTNER_MAINSKILL_GROUP, XTable.XTablePartnerMainSkillGroup, "Id") + PartnerPassiveSkillGroupCfg = XTableManager.ReadByIntKey(TABLE_PARTNER_PASSIVESKILL_GROUP, XTable.XTablePartnerPassiveSkillGroup, "Id") + PartnerSkillEffectCfg = XTableManager.ReadByIntKey(TABLE_PARTNER_SKILLEFFECT, XTable.XTablePartnerSkillEffect, "Id") + PartnerSkillInfoCfg = XTableManager.ReadByIntKey(TABLE_PARTNER_SKILLINFO, XTable.XTablePartnerSkillInfo, "Id") + PartnerModelCfg = XTableManager.ReadByIntKey(TABLE_PARTNER_MODEL, XTable.XTablePartnerModel, "Id") + PartnerItemSkipIdCfg = XTableManager.ReadByIntKey(TABLE_PARTNER_ITEM_SKIP, XTable.XTablePartnerItemSkipId, "PartnerId") + + local paths = CS.XTableManager.GetPaths(TABLE_PARTNER_LEVELUP_PATH) + XTool.LoopCollection(paths, function(path) + local key = tonumber(XTool.GetFileNameWithoutExtension(path)) + LevelUpTemplates[key] = XTableManager.ReadByIntKey(path, XTable.XTablePartnerLevelUp, "Level") + end) + + XPartnerConfigs.CreatePartnerBreakthroughDic() + XPartnerConfigs.CreatePartnerQualityDic() + XPartnerConfigs.CreatePartnerSkillEffectDic() + XPartnerConfigs.CreatePartnerSkillInfoDic() + XPartnerConfigs.CreateMainSkillGroupDic() + XPartnerConfigs.CreatePassiveSkillGroupDic() +end + +function XPartnerConfigs.CreatePartnerBreakthroughDic() + PartnerBreakthroughDic = {} + for _,breakThrough in pairs(PartnerBreakthroughCfg) do + PartnerBreakthroughDic[breakThrough.PartnerId] = + PartnerBreakthroughDic[breakThrough.PartnerId] or {} + + PartnerBreakthroughDic[breakThrough.PartnerId][breakThrough.BreakTimes] = + PartnerBreakthroughDic[breakThrough.PartnerId][breakThrough.BreakTimes] or breakThrough + end +end + +function XPartnerConfigs.CreatePartnerQualityDic() + PartnerQualityDic = {} + for _,qualityInfo in pairs(PartnerQualityCfg) do + PartnerQualityDic[qualityInfo.PartnerId] = + PartnerQualityDic[qualityInfo.PartnerId] or {} + + PartnerQualityDic[qualityInfo.PartnerId][qualityInfo.Quality] = + PartnerQualityDic[qualityInfo.PartnerId][qualityInfo.Quality] or qualityInfo + end +end + +function XPartnerConfigs.CreatePartnerSkillEffectDic() + PartnerSkillEffectDic = {} + for _,effect in pairs(PartnerSkillEffectCfg) do + PartnerSkillEffectDic[effect.SkillId] = + PartnerSkillEffectDic[effect.SkillId] or {} + + PartnerSkillEffectDic[effect.SkillId][effect.Level] = + PartnerSkillEffectDic[effect.SkillId][effect.Level] or effect + end +end + +function XPartnerConfigs.CreatePartnerSkillInfoDic() + PartnerSkillInfoDic = {} + for _,Info in pairs(PartnerSkillInfoCfg) do + PartnerSkillInfoDic[Info.SkillId] = + PartnerSkillInfoDic[Info.SkillId] or {} + + PartnerSkillInfoDic[Info.SkillId][Info.Level] = + PartnerSkillInfoDic[Info.SkillId][Info.Level] or Info + end +end + +function XPartnerConfigs.CreateMainSkillGroupDic() + PartnerMainSkillGroupDic = {} + for _,groupInfo in pairs(PartnerMainSkillGroupCfg) do + for _,skillId in pairs(groupInfo.SkillId) do + if not PartnerMainSkillGroupDic[skillId] then + PartnerMainSkillGroupDic[skillId] = groupInfo.Id + else + XLog.Error("skillId id Reuse in tab:"..TABLE_PARTNER_MAINSKILL_GROUP) + end + end + end +end + +function XPartnerConfigs.CreatePassiveSkillGroupDic() + PartnerPassiveSkillGroupDic = {} + for _,groupInfo in pairs(PartnerPassiveSkillGroupCfg) do + for _,skillId in pairs(groupInfo.SkillId) do + if not PartnerPassiveSkillGroupDic[skillId] then + PartnerPassiveSkillGroupDic[skillId] = groupInfo.Id + else + XLog.Error("skillId id Reuse in tab:"..TABLE_PARTNER_PASSIVESKILL_GROUP) + end + end + end +end + +function XPartnerConfigs.GetPartnerTemplateCfg() + return PartnerTemplateCfg +end + +function XPartnerConfigs.GetPartnerBreakthroughCfg() + return PartnerBreakthroughCfg +end + +function XPartnerConfigs.GetPartnerQualityCfg() + return PartnerQualityCfg +end + +function XPartnerConfigs.GetPartnerTemplateById(id) + if not PartnerTemplateCfg[id] then + XLog.Error("id is not exist in "..TABLE_PARTNER.." id = " .. id) + return + end + return PartnerTemplateCfg[id] +end + +function XPartnerConfigs.GeQualityBgPath(quality) + if not quality then + XLog.Error("XPartnerConfigs.GeQualityBgPath 函数错误: 参数quality不能为空") + return + end + return QualityBgPath[quality] +end + +function XPartnerConfigs.GetPartnerTemplateName(id) + return XPartnerConfigs.GetPartnerTemplateById(id).Name +end + +function XPartnerConfigs.GetPartnerTemplateIcon(id) + return XPartnerConfigs.GetPartnerTemplateById(id).Icon +end + +function XPartnerConfigs.GetPartnerTemplateQuality(id) + return XPartnerConfigs.GetPartnerTemplateById(id).InitQuality +end + +function XPartnerConfigs.GetPartnerTemplateGoodsDesc(id) + return XPartnerConfigs.GetPartnerTemplateById(id).GoodsDesc +end + +function XPartnerConfigs.GetPartnerTemplateGoodsWorldDesc(id) + return XPartnerConfigs.GetPartnerTemplateById(id).GoodsWorldDesc +end + +function XPartnerConfigs.GetPartnerSkillById(id) + if not PartnerSkillCfg[id] then + XLog.Error("id is not exist in "..TABLE_PARTNER_SKILL.." id = " .. id) + return + end + return PartnerSkillCfg[id] +end + +function XPartnerConfigs.GetPartnerMainSkillGroupById(id) + if not PartnerMainSkillGroupCfg[id] then + XLog.Error("id is not exist in "..TABLE_PARTNER_MAINSKILL_GROUP.." id = " .. id) + return + end + return PartnerMainSkillGroupCfg[id] +end + +function XPartnerConfigs.GetPartnerPassiveSkillGroupById(id) + if not PartnerPassiveSkillGroupCfg[id] then + XLog.Error("id is not exist in "..TABLE_PARTNER_PASSIVESKILL_GROUP.." id = " .. id) + return + end + return PartnerPassiveSkillGroupCfg[id] +end + +function XPartnerConfigs.GetPartnerBreakthroughByIdAndNum(partnerId, breakTimes) + if not PartnerBreakthroughDic[partnerId] then + XLog.Error("id is not exist in "..TABLE_PARTNER_BREAK_THROIGH.." id = " .. partnerId) + return + end + if not PartnerBreakthroughDic[partnerId][breakTimes] then + XLog.Error("breakTimes is not exist in "..TABLE_PARTNER_BREAK_THROIGH.." breakTimes = " .. breakTimes) + return + end + return PartnerBreakthroughDic[partnerId][breakTimes] +end + +function XPartnerConfigs.GetPartnerBreakthroughLimit(partnerId) + if not PartnerBreakthroughDic[partnerId] then + XLog.Error("id is not exist in "..TABLE_PARTNER_BREAK_THROIGH.." id = " .. partnerId) + return + end + local tmpMax = 0 + for breakTimes,_ in pairs(PartnerBreakthroughDic[partnerId]) do + if breakTimes > tmpMax then + tmpMax = breakTimes + end + end + return tmpMax +end + +function XPartnerConfigs.GePartnerQualityByIdAndNum(partnerId, quality) + if not PartnerQualityDic[partnerId] then + XLog.Error("id is not exist in "..TABLE_PARTNER_QUALITY.." id = " .. partnerId) + return + end + if not PartnerQualityDic[partnerId][quality] then + XLog.Error("quality is not exist in "..TABLE_PARTNER_QUALITY.." quality = " .. quality) + return + end + return PartnerQualityDic[partnerId][quality] +end + +function XPartnerConfigs.GetQualityLimit(partnerId) + if not PartnerQualityDic[partnerId] then + XLog.Error("id is not exist in "..TABLE_PARTNER_QUALITY.." id = " .. partnerId) + return + end + local tmpMax = 0 + for quality,_ in pairs(PartnerQualityDic[partnerId]) do + if quality > tmpMax then + tmpMax = quality + end + end + return tmpMax +end + +function XPartnerConfigs.GetPartnerSkillEffectByIdAndLevel(skillId, level) + if not PartnerSkillEffectDic[skillId] then + XLog.Error("id is not exist in "..TABLE_PARTNER_SKILLEFFECT.." id = " .. skillId) + return + end + if not PartnerSkillEffectDic[skillId][level] then + XLog.Error("level is not exist in "..TABLE_PARTNER_SKILLEFFECT.." level = " .. level) + return + end + return PartnerSkillEffectDic[skillId][level] +end + +function XPartnerConfigs.GetPartnerSkillInfoByIdAndLevel(skillId, level) + if not PartnerSkillInfoDic[skillId] then + XLog.Error("id is not exist in "..TABLE_PARTNER_SKILLINFO.." id = " .. skillId) + return + end + if not PartnerSkillInfoDic[skillId][level] then + XLog.Error("level is not exist in "..TABLE_PARTNER_SKILLINFO.." level = " .. level) + return + end + return PartnerSkillInfoDic[skillId][level] +end + + +function XPartnerConfigs.GetMainSkillGroupById(skillId) + if not PartnerMainSkillGroupDic[skillId] then + XLog.Error("skillId is not exist in "..TABLE_PARTNER_MAINSKILL_GROUP.." skillId = " .. skillId) + return + end + return PartnerMainSkillGroupDic[skillId] +end + +function XPartnerConfigs.GetPassiveSkillGroupById(skillId) + if not PartnerPassiveSkillGroupDic[skillId] then + XLog.Error("skillId is not exist in "..TABLE_PARTNER_PASSIVESKILL_GROUP.." skillId = " .. skillId) + return + end + return PartnerPassiveSkillGroupDic[skillId] +end + +function XPartnerConfigs.GetPartnerSkillLevelLimit(skillId) + if not PartnerSkillEffectDic[skillId] then + XLog.Error("id is not exist in "..TABLE_PARTNER_SKILLEFFECT.." id = " .. skillId) + return + end + local tmpMax = 0 + for skillLevel,_ in pairs(PartnerSkillEffectDic[skillId]) do + if skillLevel > tmpMax then + tmpMax = skillLevel + end + end + return tmpMax +end + +function XPartnerConfigs.GetPartnerModelById(id) + if not PartnerModelCfg[id] then + XLog.Error("id is not exist in "..TABLE_PARTNER_MODEL.." id = " .. id) + return {} + end + return PartnerModelCfg[id] +end + +function XPartnerConfigs.GetPartnerBreakThroughIcon(breakthroughTimes) + local icon = PartnerBreakThroughIcon[breakthroughTimes] + if not icon then + XLog.Error("XPartnerConfigs.PartnerBreakThroughIcon调用错误,得到的icon为空,原因:检查breakthroughTimes:" .. breakthroughTimes .. "和PartnerBreakThroughIcon的Index不匹配") + return + end + return icon +end + +--- +--- 获取'id'伙伴待机模型 +function XPartnerConfigs.GetPartnerModelStandbyModel(id) + return XPartnerConfigs.GetPartnerModelById(id).StandbyModel +end + +--- +--- 获取'id'伙伴战斗模型 +function XPartnerConfigs.GetPartnerModelCombatModel(id) + return XPartnerConfigs.GetPartnerModelById(id).CombatModel +end + +--- +--- 获取'id'伙伴 待机->战斗 动画 +function XPartnerConfigs.GetPartnerModelSToCAnime(id) + return XPartnerConfigs.GetPartnerModelById(id).SToCAnime +end + +--- +--- 获取'id'伙伴战斗模型出生动画 +function XPartnerConfigs.GetPartnerModelCombatBornAnime(id) + return XPartnerConfigs.GetPartnerModelById(id).CombatBornAnime +end + +--- +--- 获取'id'伙伴 待机->战斗 音效 +function XPartnerConfigs.GetPartnerModelSToCVoice(id) + return XPartnerConfigs.GetPartnerModelById(id).SToCVoice +end + +--- +--- 获取'id'伙伴的 待机->战斗 变形特效 +function XPartnerConfigs.GetPartnerModelSToCEffect(id) + return XPartnerConfigs.GetPartnerModelById(id).SToCEffect +end + +--- +--- 获取'id'伙伴的 待机->战斗 出生特效 +function XPartnerConfigs.GetPartnerModelCombatBornEffect(id) + return XPartnerConfigs.GetPartnerModelById(id).CombatBornEffect +end + +function XPartnerConfigs.GetPartnerLevelUpTemplateByIdAndLevel(id,level) + if not LevelUpTemplates[id] then + XLog.Error("id is not exist in "..TABLE_PARTNER_LEVELUP_PATH.." id = " .. id) + return + end + if not LevelUpTemplates[id][level] then + XLog.Error("level is not exist in "..TABLE_PARTNER_LEVELUP_PATH.." level = " .. level) + return + end + return LevelUpTemplates[id][level] +end + +function XPartnerConfigs.GetPartnerItemSkipById(id) + if not PartnerItemSkipIdCfg[id] then + XLog.Error("id is not exist in "..TABLE_PARTNER_ITEM_SKIP.." id = " .. id) + return + end + return PartnerItemSkipIdCfg[id] +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XPartnerTeachingConfigs.lua b/Resources/Scripts/XConfig/XPartnerTeachingConfigs.lua new file mode 100644 index 00000000..5f9d302c --- /dev/null +++ b/Resources/Scripts/XConfig/XPartnerTeachingConfigs.lua @@ -0,0 +1,126 @@ +XPartnerTeachingConfigs = XPartnerTeachingConfigs or {} + +local TABLE_PARTNER_TEACHING_CHAPTER = "Share/Fuben/PartnerTeaching/PartnerTeachingChapter.tab" + +local PartnerTeachingChapter = {} + +function XPartnerTeachingConfigs.Init() + PartnerTeachingChapter = XTableManager.ReadByIntKey(TABLE_PARTNER_TEACHING_CHAPTER, XTable.XTablePartnerTeachingChapter, "Id") +end + +local function GetPartnerTeachingChapterCfg(chapterId) + local config = PartnerTeachingChapter[chapterId] + if not config then + XLog.ErrorTableDataNotFound("XPartnerTeachingConfigs.GetPartnerTeachingChapterCfg", + "辅助机教学章节", TABLE_PARTNER_TEACHING_CHAPTER, "Id", tostring(chapterId)) + return {} + end + return config +end + +--- +--- 获取所有的教学章节Id +function XPartnerTeachingConfigs.GetAllChapterId() + local result = {} + for id, _ in pairs(PartnerTeachingChapter) do + table.insert(result, id) + end + return result +end + +--- +--- 根据 'chapterId' 获取章节名称 +function XPartnerTeachingConfigs.GetChapterName(chapterId) + local cfg = GetPartnerTeachingChapterCfg(chapterId) + return cfg.Name +end + +--- +--- 根据 'chapterId' 获取活动时间 +function XPartnerTeachingConfigs.GetChapterActivityTimeId(chapterId) + local cfg = GetPartnerTeachingChapterCfg(chapterId) + return cfg.ActivityTimeId +end + +--- +---@return table +--- 根据 'chapterId' 获取活动开启条件数组 +function XPartnerTeachingConfigs.GetChapterActivityCondition(chapterId) + local cfg = GetPartnerTeachingChapterCfg(chapterId) + return cfg.ActivityCondition +end + +--- +--- 根据 'chapterId' 获取开启条件数据 +---@return table +function XPartnerTeachingConfigs.GetChapterOpenCondition(chapterId) + local cfg = GetPartnerTeachingChapterCfg(chapterId) + return cfg.OpenCondition +end + +--- +--- 根据 'chapterId' 获取章节图标 +function XPartnerTeachingConfigs.GetChapterBannerIcon(chapterId) + local cfg = GetPartnerTeachingChapterCfg(chapterId) + return cfg.BannerIcon +end + +--- +--- 根据 'chapterId' 获取章节背景 +function XPartnerTeachingConfigs.GetChapterBackground(chapterId) + local cfg = GetPartnerTeachingChapterCfg(chapterId) + return cfg.Background +end + +--- +--- 根据 'chapterId' 获取章节预制体 +function XPartnerTeachingConfigs.GetChapterFubenPrefab(chapterId) + local cfg = GetPartnerTeachingChapterCfg(chapterId) + return cfg.FubenPrefab +end + +--- +--- 根据 'chapterId' 获取战斗关卡预制体 +function XPartnerTeachingConfigs.GetChapterFightStagePrefab(chapterId) + local cfg = GetPartnerTeachingChapterCfg(chapterId) + return cfg.FightStagePrefab +end + +--- +--- 根据 'chapterId' 获取故事关卡预制体 +function XPartnerTeachingConfigs.GetChapterStoryStagePrefab(chapterId) + local cfg = GetPartnerTeachingChapterCfg(chapterId) + return cfg.StoryStagePrefab +end + +--- +--- 根据 'chapterId' 获取关卡数组 +---@return table +function XPartnerTeachingConfigs.GetChapterStageIds(chapterId) + local cfg = GetPartnerTeachingChapterCfg(chapterId) + return cfg.StageIds +end + +--- +--- 根据 'chapterId' 获取关卡编号前缀 +---@return string +function XPartnerTeachingConfigs.GetChapterStagePrefix(chapterId) + local cfg = GetPartnerTeachingChapterCfg(chapterId) + return cfg.StagePrefix +end + +--- +--- 根据 'chapterId' 获取剧情关卡详情的背景图 +---@return string +function XPartnerTeachingConfigs.GetChapterStoryStageDetailBg(chapterId) + local cfg = GetPartnerTeachingChapterCfg(chapterId) + return cfg.StoryStageDetailBg +end + +--- +--- 根据 'chapterId' 获取剧情关卡详情开始按钮的图标 +---@return string +function XPartnerTeachingConfigs.GetChapterStoryStageDetailIcon(chapterId) + local cfg = GetPartnerTeachingChapterCfg(chapterId) + return cfg.StoryStageDetailIcon +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XPassportConfigs.lua b/Resources/Scripts/XConfig/XPassportConfigs.lua new file mode 100644 index 00000000..d8d99d76 --- /dev/null +++ b/Resources/Scripts/XConfig/XPassportConfigs.lua @@ -0,0 +1,514 @@ +local tableInsert = table.insert +local tableSort = table.sort +local ipairs = ipairs +local pairs = pairs +local stringGsub = string.gsub +local CSXTextManagerGetText = CS.XTextManager.GetText + +local TABLE_PASSPORT_ACTIVITY_PATH = "Share/Passport/PassportActivity.tab" +local TABLE_PASSPORT_LEVEL_PATH = "Share/Passport/PassportLevel.tab" +local TABLE_PASSPORT_REWARD_PATH = "Share/Passport/PassportReward.tab" +local TABLE_PASSPORT_TYPE_INFO_PATH = "Share/Passport/PassportTypeInfo.tab" +local TABLE_PASSPORT_TASK_GROUP_PATH = "Share/Passport/PassportTaskGroup.tab" +local TABLE_PASSPORT_BUY_FASHION_SHOW_PATH = "Client/Passport/PassportBuyFashionShow.tab" +local TABLE_PASSPORT_BUY_REWARD_SHOW_PATH = "Client/Passport/PassportBuyRewardShow.tab" +local PassportActivityConfigs = {} +local PassportLevelConfigs = {} +local PassportRewardConfigs = {} +local PassportTypeInfoConfigs = {} +local PassportTaskGroupConfigs = {} +local PassportBuyFashionShowConfigs = {} +local PassportBuyRewardShowConfigs = {} + +local PassportActivityIdToLevelIdList = {} +local PassportRewardIdDic = {} +local PassportActivityIdToTypeInfoIdList = {} +local PassportActivityAndLevelToLevelIdDic = {} +local PassportIdToPassportRewardIdList = {} +local PassportIdToBuyRewardShowIdList = {} + +local DefaultActivityId = 1 + +XPassportConfigs = XPassportConfigs or {} + +--任务类型 +XPassportConfigs.TaskType = { + Activity = 0, --活动任务(前端自定义) + Daily = 1, --每日任务 + Weekly = 2, --每周任务 +} + +local InitPassportActivityId = function() + for activityId, config in pairs(PassportActivityConfigs) do + if XTool.IsNumberValid(config.TimeId) then + DefaultActivityId = activityId + break + end + DefaultActivityId = activityId + end +end + +local InitPassportActivityIdToLevelIdList = function() + for _, v in pairs(PassportLevelConfigs) do + if not PassportActivityIdToLevelIdList[v.ActivityId] then + PassportActivityIdToLevelIdList[v.ActivityId] = {} + end + tableInsert(PassportActivityIdToLevelIdList[v.ActivityId], v.Id) + end + + for _, idList in pairs(PassportActivityIdToLevelIdList) do + tableSort(idList, function(a, b) + return a < b + end) + end +end + +local InitPassportRewardIdDic = function() + for _, v in pairs(PassportRewardConfigs) do + if not PassportRewardIdDic[v.PassportId] then + PassportRewardIdDic[v.PassportId] = {} + end + PassportRewardIdDic[v.PassportId][v.Level] = v.Id + end +end + +local InitPassportIdToPassportRewardIdList = function() + for _, v in pairs(PassportRewardConfigs) do + if not PassportIdToPassportRewardIdList[v.PassportId] then + PassportIdToPassportRewardIdList[v.PassportId] = {} + end + tableInsert(PassportIdToPassportRewardIdList[v.PassportId], v.Id) + end + + for _, idList in pairs(PassportIdToPassportRewardIdList) do + tableSort(idList, function(a, b) + local levelA = XPassportConfigs.GetPassportRewardLevel(a) + local levelB = XPassportConfigs.GetPassportRewardLevel(b) + if levelA ~= levelB then + return levelA < levelB + end + return a < b + end) + end +end + +local InitPassportActivityIdToTypeInfoIdList = function() + for _, v in pairs(PassportTypeInfoConfigs) do + if not PassportActivityIdToTypeInfoIdList[v.ActivityId] then + PassportActivityIdToTypeInfoIdList[v.ActivityId] = {} + end + tableInsert(PassportActivityIdToTypeInfoIdList[v.ActivityId], v.Id) + end + + for _, idList in pairs(PassportActivityIdToTypeInfoIdList) do + tableSort(idList, function(a, b) + return a < b + end) + end +end + +local InitPassportActivityAndLevelToLevelIdDic = function() + for _, v in pairs(PassportLevelConfigs) do + if not PassportActivityAndLevelToLevelIdDic[v.ActivityId] then + PassportActivityAndLevelToLevelIdDic[v.ActivityId] = {} + end + PassportActivityAndLevelToLevelIdDic[v.ActivityId][v.Level] = v.Id + end +end + +local InitPassportIdToBuyRewardShowIdList = function() + for _, v in pairs(PassportBuyRewardShowConfigs) do + if not PassportIdToBuyRewardShowIdList[v.PassportId] then + PassportIdToBuyRewardShowIdList[v.PassportId] = {} + end + tableInsert(PassportIdToBuyRewardShowIdList[v.PassportId], v.Id) + end + + for _, idList in pairs(PassportIdToBuyRewardShowIdList) do + tableSort(idList, function(a, b) + local levelA = XPassportConfigs.GetPassportBuyRewardShowLevel(a) + local levelB = XPassportConfigs.GetPassportBuyRewardShowLevel(b) + if levelA ~= levelB then + return levelA > levelB + end + return a < b + end) + end +end + +function XPassportConfigs.Init() + PassportActivityConfigs = XTableManager.ReadByIntKey(TABLE_PASSPORT_ACTIVITY_PATH, XTable.XTablePassportActivity, "Id") + PassportLevelConfigs = XTableManager.ReadByIntKey(TABLE_PASSPORT_LEVEL_PATH, XTable.XTablePassportLevel, "Id") + PassportRewardConfigs = XTableManager.ReadByIntKey(TABLE_PASSPORT_REWARD_PATH, XTable.XTablePassportReward, "Id") + PassportTypeInfoConfigs = XTableManager.ReadByIntKey(TABLE_PASSPORT_TYPE_INFO_PATH, XTable.XTablePassportTypeInfo, "Id") + PassportTaskGroupConfigs = XTableManager.ReadByIntKey(TABLE_PASSPORT_TASK_GROUP_PATH, XTable.XTablePassportTaskGroup, "Id") + PassportBuyFashionShowConfigs = XTableManager.ReadByIntKey(TABLE_PASSPORT_BUY_FASHION_SHOW_PATH, XTable.XTablePassportBuyFashionShow, "PassportId") + PassportBuyRewardShowConfigs = XTableManager.ReadByIntKey(TABLE_PASSPORT_BUY_REWARD_SHOW_PATH, XTable.XTablePassportBuyRewardShow, "Id") + + InitPassportActivityId() + InitPassportActivityIdToLevelIdList() + InitPassportRewardIdDic() + InitPassportIdToPassportRewardIdList() + InitPassportActivityIdToTypeInfoIdList() + InitPassportActivityAndLevelToLevelIdDic() + InitPassportIdToBuyRewardShowIdList() +end + +-----------------PassportActivity 活动相关 begin----------------------- +local GetPassportActivityConfig = function(id) + local config = PassportActivityConfigs[id] + if not config then + XLog.ErrorTableDataNotFound("XPassportConfigs.GetPassportActivityConfig", "PassportActivityConfigs", TABLE_PASSPORT_ACTIVITY_PATH, "Id", id) + return + end + return config +end + +function XPassportConfigs.SetDefaultActivityId(activityId) + DefaultActivityId = activityId +end + +function XPassportConfigs.GetDefaultActivityId() + return DefaultActivityId +end + +function XPassportConfigs.GetPassportActivityTimeId() + local activityId = XPassportConfigs.GetDefaultActivityId() + local config = GetPassportActivityConfig(activityId) + return config.TimeId +end + +function XPassportConfigs.GetPassportDailyTaskGroup() + local activityId = XPassportConfigs.GetDefaultActivityId() + local config = GetPassportActivityConfig(activityId) + return config.DailyTaskGroup +end + +function XPassportConfigs.GetPassportWeekTaskGroup() + local activityId = XPassportConfigs.GetDefaultActivityId() + local config = GetPassportActivityConfig(activityId) + return config.WeekTaskGroup +end + +function XPassportConfigs.GetPassportBPTask() + local activityId = XPassportConfigs.GetDefaultActivityId() + local config = GetPassportActivityConfig(activityId) + return config and config.BPTask or {} +end + +function XPassportConfigs.GetPassportBPTaskTotalCount() + local taskList = XPassportConfigs.GetPassportBPTask() + return #taskList +end +-----------------PassportActivity 活动相关 end------------------------- + +-----------------PassportLevel 等级 begin----------------------- +local GetPassportLevelConfig = function(id) + local config = PassportLevelConfigs[id] + if not config then + XLog.ErrorTableDataNotFound("XPassportConfigs.GetPassportLevelConfig", "PassportLevelConfigs", TABLE_PASSPORT_LEVEL_PATH, "Id", id) + return + end + return config +end + +function XPassportConfigs.GetPassportLevelIdList(activityId) + return PassportActivityIdToLevelIdList[activityId] or {} +end + +function XPassportConfigs.GetPassportLevel(id) + local config = GetPassportLevelConfig(id) + return config.Level +end + +function XPassportConfigs.GetPassportLevelTotalExp(id) + local config = GetPassportLevelConfig(id) + return config.TotalExp +end + +function XPassportConfigs.GetPassportLevelCostItemId(id) + local config = GetPassportLevelConfig(id) + return config.CostItemId +end + +function XPassportConfigs.GetPassportLevelCostItemCount(id) + local config = GetPassportLevelConfig(id) + return config.CostItemCount +end + +function XPassportConfigs.GetPassportMaxLevel() + local activityId = XPassportConfigs.GetDefaultActivityId() + local levelIdList = XPassportConfigs.GetPassportLevelIdList(activityId) + local maxLevel = 0 + local levelCfg + for _, levelId in ipairs(levelIdList) do + levelCfg = XPassportConfigs.GetPassportLevel(levelId) + if levelCfg > maxLevel then + maxLevel = levelCfg + end + end + return maxLevel +end + +function XPassportConfigs.GetPassportLevelId(level) + local activityId = XPassportConfigs.GetDefaultActivityId() + return PassportActivityAndLevelToLevelIdDic[activityId] and PassportActivityAndLevelToLevelIdDic[activityId][level] +end + +function XPassportConfigs.IsPassportTargetLevel(id) + local config = GetPassportLevelConfig(id) + return XTool.IsNumberValid(config.IsTargetLevel) +end + +--返回下一个目标的等级 +function XPassportConfigs.GetPassportTargetLevel(currLevel) + local activityId = XPassportConfigs.GetDefaultActivityId() + local levelIdList = XPassportConfigs.GetPassportLevelIdList(activityId) + local lastLevelIdIndex = #levelIdList + local levelCfg + + for i, levelId in ipairs(levelIdList) do + levelCfg = XPassportConfigs.GetPassportLevel(levelId) + if (levelCfg >= currLevel or i == lastLevelIdIndex) and XPassportConfigs.IsPassportTargetLevel(levelId) then + return levelCfg + end + end +end + +function XPassportConfigs.GetBuyLevelCostItemId() + local activityId = XPassportConfigs.GetDefaultActivityId() + local levelIdList = XPassportConfigs.GetPassportLevelIdList(activityId) + for _, levelId in ipairs(levelIdList) do + return XPassportConfigs.GetPassportLevelCostItemId(levelId) + end +end +-----------------PassportLevel 等级 end------------------------- + +-----------------PassportReward 奖励 begin----------------------- +local GetPassportRewardConfig = function(id) + local config = PassportRewardConfigs[id] + if not config then + XLog.ErrorTableDataNotFound("XPassportConfigs.GetPassportRewardConfig", "PassportRewardConfigs", TABLE_PASSPORT_REWARD_PATH, "Id", id) + return + end + return config +end + +function XPassportConfigs.GetPassportRewardPassportId(id) + local config = GetPassportRewardConfig(id) + return config.PassportId +end + +function XPassportConfigs.GetPassportRewardId(id) + local config = GetPassportRewardConfig(id) + return config.RewardId +end + +function XPassportConfigs.GetPassportRewardData(passportRewardId) + local rewardId = XPassportConfigs.GetPassportRewardId(passportRewardId) + local rewards = XTool.IsNumberValid(rewardId) and XRewardManager.GetRewardList(rewardId) + return rewards and rewards[1] +end + +function XPassportConfigs.GetPassportRewardLevel(id) + local config = GetPassportRewardConfig(id) + return config.Level +end + +function XPassportConfigs.GetPassportRewardIdList(passportId) + return PassportIdToPassportRewardIdList[passportId] +end + +--获得奖励表的id +function XPassportConfigs.GetRewardIdByPassportIdAndLevel(passportId, level) + return PassportRewardIdDic[passportId] and PassportRewardIdDic[passportId][level] +end + +--返回对应等级的已解锁的通行证奖励 +function XPassportConfigs.GetUnLockPassportRewardIdListByLevel(level) + local typeInfoIdList = XPassportConfigs.GetPassportActivityIdToTypeInfoIdList() + local unLockPassportRewardIdList = {} + local rewardId + local passportRewardId + + for _, passportId in ipairs(typeInfoIdList) do + if XDataCenter.PassportManager.GetPassportInfos(passportId) then + passportRewardId = XPassportConfigs.GetRewardIdByPassportIdAndLevel(passportId, level) + if passportRewardId then + tableInsert(unLockPassportRewardIdList, passportRewardId) + end + end + end + return unLockPassportRewardIdList +end +-----------------PassportReward 奖励 end------------------------- + +-----------------PassportTypeInfo 通行证类型 begin----------------------- +local GetPassportTypeInfoConfig = function(id) + local config = PassportTypeInfoConfigs[id] + if not config then + XLog.ErrorTableDataNotFound("XPassportConfigs.GetPassportTypeInfoConfig", "PassportTypeInfoConfigs", TABLE_PASSPORT_TYPE_INFO_PATH, "Id", id) + return + end + return config +end + +function XPassportConfigs.GetPassportTypeInfoRewardId(id) + local config = GetPassportTypeInfoConfig(id) + return config.RewardId +end + +function XPassportConfigs.GetPassportTypeInfoName(id) + local config = GetPassportTypeInfoConfig(id) + return config.Name or "" +end + +function XPassportConfigs.GetPassportTypeInfoCostItemId(id) + local config = GetPassportTypeInfoConfig(id) + return config.CostItemId +end + +function XPassportConfigs.GetPassportTypeInfoCostItemCount(id) + local config = GetPassportTypeInfoConfig(id) + return config.CostItemCount +end + +function XPassportConfigs.GetPassportTypeInfoIsFree(id) + local config = GetPassportTypeInfoConfig(id) + return config.IsFree +end + +function XPassportConfigs.GetPassportTypeInfoRewardId(id) + local config = GetPassportTypeInfoConfig(id) + return config.RewardId +end + +function XPassportConfigs.GetPassportTypeInfoBuyDesc(id) + local config = GetPassportTypeInfoConfig(id) + return config.BuyDesc or "" +end + +function XPassportConfigs.GetPassportTypeInfoIcon(id) + local config = GetPassportTypeInfoConfig(id) + return config.Icon +end + +function XPassportConfigs.GetPassportActivityIdToTypeInfoIdList() + local activityId = XPassportConfigs.GetDefaultActivityId() + return PassportActivityIdToTypeInfoIdList[activityId] +end +-----------------PassportTypeInfo 通行证类型 end------------------------- + +-----------------PassportTaskGroup 任务 begin-------------------------- +local GetPassportTaskGroupConfig = function(id) + local config = PassportTaskGroupConfigs[id] + if not config then + XLog.ErrorTableDataNotFound("XPassportConfigs.GetPassportTaskGroupConfig", "PassportTaskGroupConfigs", TABLE_PASSPORT_TASK_GROUP_PATH, "Id", id) + return + end + return config +end + +function XPassportConfigs.GetPassportTaskGroupTaskIdList(id) + local config = GetPassportTaskGroupConfig(id) + return config.TaskId +end + +function XPassportConfigs.GetPassportTaskGroupTimeId(id) + local config = GetPassportTaskGroupConfig(id) + return config.TimeId +end + +function XPassportConfigs.GetPassportTaskGroupCurrOpenTaskIdList(type) + for _, v in pairs(PassportTaskGroupConfigs) do + if v.Type == type and XFunctionManager.CheckInTimeByTimeId(v.TimeId) then + return XPassportConfigs.GetPassportTaskGroupTaskIdList(v.Id) + end + end + return {} +end + +function XPassportConfigs.GetPassportTaskGroupIdByType(type) + for _, v in pairs(PassportTaskGroupConfigs) do + if v.Type == type and XFunctionManager.CheckInTimeByTimeId(v.TimeId) then + return v.Id + end + end +end + +--获得总周数和当前第几周 +function XPassportConfigs.GetPassportWeeklyTaskGroupCountAndCurrWeekly() + local nowServerTime = XTime.GetServerNowTimestamp() + local weekTaskGroup = XPassportConfigs.GetPassportWeekTaskGroup() + local totalCount = 0 + local currWeekly = 0 + local startTime + + for _, v in pairs(PassportTaskGroupConfigs) do + startTime = XFunctionManager.GetStartTimeByTimeId(v.TimeId) + if v.Type == XPassportConfigs.TaskType.Weekly and v.Group == weekTaskGroup and nowServerTime >= startTime then + currWeekly = currWeekly + 1 + end + if v.Type == XPassportConfigs.TaskType.Weekly then + totalCount = totalCount + 1 + end + end + + currWeekly = XTool.IsNumberValid(currWeekly) and currWeekly or 1 --默认第1周 + return totalCount, currWeekly +end + +-----------------PassportTaskGroup 任务 end---------------------------- + +-----------------PassportBuyFashionShowConfig 购买通行证界面展示的时装相关 start---------------------------- +local GetPassportBuyFashionShowConfig = function(id) + local config = PassportBuyFashionShowConfigs[id] + if not config then + XLog.ErrorTableDataNotFound("XPassportConfigs.GetPassportBuyFashionShowConfig", "PassportBuyFashionShowConfigs", TABLE_PASSPORT_BUY_FASHION_SHOW_PATH, "PassportId", id) + return + end + return config +end + +function XPassportConfigs.GetPassportBuyFashionShowIcon(id) + local config = GetPassportBuyFashionShowConfig(id) + return config.Icon +end + +function XPassportConfigs.GetPassportBuyFashionShowFashionId(id) + local config = GetPassportBuyFashionShowConfig(id) + return config.FashionId +end + +function XPassportConfigs.IsPassportBuyFashionShowIsWeaponFahion(id) + local config = GetPassportBuyFashionShowConfig(id) + return XTool.IsNumberValid(config.IsWeaponFahion) and true or false +end +-----------------PassportBuyFashionShowConfig 购买通行证界面展示的时装相关 end------------------------------ + +-----------------PassportBuyRewardShowConfig 购买通行证界面展示的道具相关 start---------------------------- +local GetPassportBuyRewardShowConfig = function(id) + local config = PassportBuyRewardShowConfigs[id] + if not config then + XLog.ErrorTableDataNotFound("XPassportConfigs.GetPassportBuyRewardShowConfig", "PassportBuyRewardShowConfigs", TABLE_PASSPORT_BUY_REWARD_SHOW_PATH, "Id", id) + return + end + return config +end + +function XPassportConfigs.GetPassportBuyRewardShowLevel(id) + local config = GetPassportBuyRewardShowConfig(id) + return config.Level +end + +function XPassportConfigs.GetPassportBuyRewardShowRewardData(id, isNotCount) + local config = GetPassportBuyRewardShowConfig(id) + local rewardId = config.RewardId + local rewards = isNotCount and XRewardManager.GetRewardListNotCount(rewardId) or XRewardManager.GetRewardList(rewardId) + return rewards and rewards[1] +end + +function XPassportConfigs.GetBuyRewardShowIdList(passportId) + return PassportIdToBuyRewardShowIdList[passportId] +end +-----------------PassportBuyRewardShowConfig 购买通行证界面展示的道具相关 end------------------------------ \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XPayConfigs.lua b/Resources/Scripts/XConfig/XPayConfigs.lua new file mode 100644 index 00000000..a63b7065 --- /dev/null +++ b/Resources/Scripts/XConfig/XPayConfigs.lua @@ -0,0 +1,73 @@ +XPayConfigs = XPayConfigs or {} + +local TABLE_PAY_PATH = "Share/Pay/Pay.tab" +local TABLE_FIRST_PAY_PATH = "Share/Pay/FirstPayReward.tab" +local TABLE_PAYKEY_PLATFORMPREFIX = "Share/Pay/PayKeyPlatformPrefix.tab" +local Application = CS.UnityEngine.Application +local Platform = Application.platform +local RuntimePlatform = CS.UnityEngine.RuntimePlatform + +local PayTemplates = {} +local FirstPayTemplates = {} +local PayPlatformTemplates = {} +local PayListDataConfig = nil + +function XPayConfigs.Init() + PayTemplates = XTableManager.ReadByStringKey(TABLE_PAY_PATH, XTable.XTablePay, "Key") + FirstPayTemplates = XTableManager.ReadByIntKey(TABLE_FIRST_PAY_PATH, XTable.XTableFirstPayReward, "NeedPayMoney") + PayPlatformTemplates = XTableManager.ReadByIntKey(TABLE_PAYKEY_PLATFORMPREFIX, XTable.XTablePayKeyPlatformPrefix, "Platform") +end + +function XPayConfigs.GetPayTemplate(key) + local template = PayTemplates[key] + if not template then + XLog.ErrorTableDataNotFound("XPayConfigs.GetPayTemplate", "template", TABLE_PAY_PATH, "key", tostring(key)) + return + end + + return template +end + +function XPayConfigs.GetPayConfig() + if not PayListDataConfig then + PayListDataConfig = {} + for _,v in pairs(PayTemplates)do + if v.ShowUIType == 1 then + if v.Platform == 1 and Platform == RuntimePlatform.Android then + table.insert(PayListDataConfig,v) + elseif v.Platform == 2 and Platform == RuntimePlatform.IPhonePlayer then + table.insert(PayListDataConfig,v) + else + if v.Platform == 1 and Platform ~= RuntimePlatform.Android and Platform ~= RuntimePlatform.IPhonePlayer then + table.insert(PayListDataConfig,v) + end + end + end + end + end + return PayListDataConfig +end + + +function XPayConfigs.CheckFirstPay(totalPayMoney) + for _, v in pairs(FirstPayTemplates) do + return totalPayMoney >= v.NeedPayMoney + end +end + +function XPayConfigs.GetSmallRewards() + for _, v in pairs(FirstPayTemplates) do + return v.SmallRewardId + end +end + +function XPayConfigs.GetBigRewards() + for _, v in pairs(FirstPayTemplates) do + return v.BigRewardId + end +end + +--获取对应平台的字符串,用来请求的时候拼接 +function XPayConfigs.GetPlatformConfig(id) + return PayPlatformTemplates[id].KeyPrefix +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XPhotographConfigs.lua b/Resources/Scripts/XConfig/XPhotographConfigs.lua new file mode 100644 index 00000000..5aff24c3 --- /dev/null +++ b/Resources/Scripts/XConfig/XPhotographConfigs.lua @@ -0,0 +1,92 @@ +XPhotographConfigs = XPhotographConfigs or {} + +XPhotographConfigs.PhotographViewState = { + Normal = 1, + Capture = 2, + SDK = 3, +} + +local TABLE_BACK_GROUND = "Share/PhotoMode/Background.tab" +local TABLE_PHOTOMODE_SHARE_INFO = "Client/PhotoMode/ShareInfo.tab" + +-- XTablePhotoModeSdk + +local SceneTemplates = {} +local ShareInfo = {} + +function XPhotographConfigs.Init() + SceneTemplates = XTableManager.ReadByIntKey(TABLE_BACK_GROUND, XTable.XTableBackground, "Id") + ShareInfo = XTableManager.ReadByIntKey(TABLE_PHOTOMODE_SHARE_INFO, XTable.XTablePhotoModeShareInfo, "Id") +end + +function XPhotographConfigs.GetSceneTemplates() + return SceneTemplates +end + +function XPhotographConfigs.GetShareInfoByType(platformType) + return ShareInfo[platformType] +end + +function XPhotographConfigs.GetSceneTemplateById(id) + if not SceneTemplates then + return nil + end + + return SceneTemplates[id] +end + +function XPhotographConfigs.GetBackgroundNameById(id) + if not SceneTemplates then + return nil + end + + return SceneTemplates[id].Name +end + +function XPhotographConfigs.GetBackgroundQualityById(id) + if not SceneTemplates then + return nil + end + + return SceneTemplates[id].Quality +end + +function XPhotographConfigs.GetBackgroundDescriptionById(id) + if not SceneTemplates then + return nil + end + + return SceneTemplates[id].Description +end + +function XPhotographConfigs.GetBackgroundWorldDescriptionById(id) + if not SceneTemplates then + return nil + end + + return SceneTemplates[id].WorldDescription +end + +function XPhotographConfigs.GetBackgroundIconById(id) + if not SceneTemplates then + return nil + end + + return SceneTemplates[id].Icon +end + +function XPhotographConfigs.GetBackgroundBigIconById(id) + if not SceneTemplates then + return nil + end + + return SceneTemplates[id].BigIcon +end + +function XPhotographConfigs.GetBackgroundPriorityById(id) + if not SceneTemplates then + return nil + end + + return SceneTemplates[id].Priority +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XPlatformShareConfigs.lua b/Resources/Scripts/XConfig/XPlatformShareConfigs.lua new file mode 100644 index 00000000..0f5151c3 --- /dev/null +++ b/Resources/Scripts/XConfig/XPlatformShareConfigs.lua @@ -0,0 +1,58 @@ +XPlatformShareConfigs = XPlatformShareConfigs or {} + +XPlatformShareConfigs.PlatformType = { + QQ = 1, + QQSpace = 2, + WeChat = 3, + WeChatTimeline = 4, + Weibo = 5, + Local = 100, +} + +XPlatformShareConfigs.PlatformTypeToHeroSharePlatform = { + [XPlatformShareConfigs.PlatformType.QQ] = CS.SharePlatform.QQ, + [XPlatformShareConfigs.PlatformType.QQSpace] = CS.SharePlatform.QQ_Space, + [XPlatformShareConfigs.PlatformType.WeChat] = CS.SharePlatform.WeChat, + [XPlatformShareConfigs.PlatformType.WeChatTimeline] = CS.SharePlatform.WXTimeLine, + [XPlatformShareConfigs.PlatformType.Weibo] = CS.SharePlatform.Weibo, +} + +XPlatformShareConfigs.ShareType = { + Image = 1, + Link = 2, + Text = 3, +} + +XPlatformShareConfigs.ShareTypeToHeroShareType = { + [XPlatformShareConfigs.ShareType.Image] = CS.ShareType.Image, + [XPlatformShareConfigs.ShareType.Link] = CS.ShareType.Link, + [XPlatformShareConfigs.ShareType.Text] = CS.ShareType.Text, +} + +XPlatformShareConfigs.ShareResult = { + Successful = 0, + Failed = 1, + Canceled = -1, +} + +local TABLE_PLATFORM_SHARE = "Client/PlatformShare/PlatformShare.tab" +local TABLE_PLATFORM_SHARE_OPEN = "Client/PlatformShare/PlatformShareOpen.tab" --根据服务器id控制是否开启分享功能 + +local PlatformShareTemplates +local PlatformShareOpenTemplates + +function XPlatformShareConfigs.Init() + PlatformShareTemplates = XTableManager.ReadByIntKey(TABLE_PLATFORM_SHARE, XTable.XTablePlatformShare, "Id") + PlatformShareOpenTemplates = XTableManager.ReadByStringKey(TABLE_PLATFORM_SHARE_OPEN, XTable.XTablePlatformShareOpen, "Id") +end + +function XPlatformShareConfigs.GetPlatformShareTemplate(id) + local template = PlatformShareTemplates[id] + if template then return template end + XLog.ErrorTableDataNotFound("XPlatformShareConfigs.GetPlatformShareTemplate", "template", TABLE_PLATFORM_SHARE, "id", tostring(id)) +end + +function XPlatformShareConfigs.IsPlatformShareOpen(id) + local template = PlatformShareOpenTemplates[id] + return template ~= nil and template.IsOpen +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XPlayerInfoConfigs.lua b/Resources/Scripts/XConfig/XPlayerInfoConfigs.lua new file mode 100644 index 00000000..84c0e7a6 --- /dev/null +++ b/Resources/Scripts/XConfig/XPlayerInfoConfigs.lua @@ -0,0 +1,86 @@ +XPlayerInfoConfigs = XPlayerInfoConfigs or {} + +local TABLE_FETTERS_PATH = "Share/Social/FettersLevel.tab" +local TABLE_CHARACTER_SHOW_SCORE_PATH = "Client/Character/CharacterShowScore.tab" + +local FettersCfg = {} +local CharacterShowScoreCfg = {} + +-- 成员展示选项 +XPlayerInfoConfigs.CharactersAppearanceType = { + All = 0, --展示全部成员 + Select = 1 --选择展示成员 +} + +XPlayerInfoConfigs.FashionType = { + Character = 0, --成员涂装 + Weapon = 1 --武器涂装 +} + +function XPlayerInfoConfigs.Init() + FettersCfg = XTableManager.ReadByIntKey(TABLE_FETTERS_PATH, XTable.XTableFetter, "Level") + CharacterShowScoreCfg = XTableManager.ReadByIntKey(TABLE_CHARACTER_SHOW_SCORE_PATH, XTable.XTableCharacterShowScore, "CharacterId") +end + +function XPlayerInfoConfigs.GetLevelByExp(exp) + local Level = 1 + for k, v in pairs(FettersCfg) do + Level = k + if exp == 0 then + Level = 1 + break + elseif v.Exp > exp then + break + elseif v.Exp == exp then + if Level >= FettersCfg[#FettersCfg].Level then + break + end + Level = Level + 1 + break + end + end + return Level +end + +function XPlayerInfoConfigs.GetLevelDataByExp(exp) + --默认1级 + local result = FettersCfg[1] + if exp >= FettersCfg[#FettersCfg].Exp then + return FettersCfg[#FettersCfg] + else + for i = #FettersCfg, 1, -1 do + if exp >= FettersCfg[i].Exp then + result = FettersCfg[i + 1] + break + end + end + end + return result +end + +function XPlayerInfoConfigs.GetCurLevelExp(level) + if level == 0 then + return 0 + end + for i = #FettersCfg, 1, -1 do + if level == FettersCfg[i].Level then + return FettersCfg[i].Exp + end + end + --满级 + return FettersCfg[#FettersCfg] +end + +function XPlayerInfoConfigs.GetFettersCfg() + return FettersCfg +end + +-- 品质做表头,存放的是对应品质的评分 +function XPlayerInfoConfigs.GetCharacterShowScore(characterId) + if not CharacterShowScoreCfg[characterId] then + XLog.Error(string.format("XPlayerInfoConfigs.GetCharacterShowScore函数错误,没有角色Id:%s的评分数据,路径为%s" + , characterId, TABLE_CHARACTER_SHOW_SCORE_PATH)) + return {} + end + return CharacterShowScoreCfg[characterId].Quality +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XPokemonConfigs.lua b/Resources/Scripts/XConfig/XPokemonConfigs.lua new file mode 100644 index 00000000..0a02ae85 --- /dev/null +++ b/Resources/Scripts/XConfig/XPokemonConfigs.lua @@ -0,0 +1,887 @@ +local tonumber = tonumber +local tableInsert = table.insert +local tableSort = table.sort +local ipairs = ipairs +local pairs = pairs +local CSXTextManagerGetText = CS.XTextManager.GetText + +local TABLE_MONSTER_PATH = "Share/Pokemon/Monster/PokemonMonster.tab" +local TABLE_MONSTER_SKILL_PATH = "Share/Pokemon/Monster/PokemonMonsterSkill.tab" +local TABLE_MONSTER_LEVEL_PATH = "Share/Pokemon/Monster/LevelTemplate/" +local TABLE_MONSTER_STAR_PATH = "Share/Pokemon/Monster/StarTemplate/" +local TABLE_MONSTER_CAREER_PATH = "Client/Pokemon/PokemonMonsterCareer.tab" +local TABLE_CHAPTER_CONFIG_PATH = "Client/Pokemon/PokemonChapterLocalConfig.tab" +local TABLE_STAGE_TEMPLATE_PATH = "Client/Pokemon/PokemonStageTemplate.tab" +local TABLE_STAGE_PATH = "Share/Pokemon/PokemonStage.tab" +local TABLE_Chapter_PATH = "Share/Pokemon/PokemonChapter.tab" +local TABLE_STAGE_MONSTER_PATH = "Client/Pokemon/PokemonStageMonster.tab" +local TABLE_POKEMON_ACTIVITY_PATH = "Share/Pokemon/PokemonActivity.tab" +local TABLE_POKEMON_INIT_PATH = "Share/Pokemon/PokemonInit.tab" + +local MonsterTemplate = {} +local MonsterLevelTemplate = {} +local MonsterStarTemplate = {} +local MonsterSkillTemplate = {} +local MonsterCareerTemplate = {} +local ItemIdCheckDic = {}--记录所有配置物品Id +local StageTemplate = {} +local StageUITemplate = {} +local StageRawTemplate = {} +local StageMonsterTemplate = {} +local PokemonActivityCfgs = {} +local PokemonInitCfgs = {} +local NpcIdToMonsterIdDic = {} +local FightStageIdToStageIdDic = {} +local Chapters = {} +local ChapterConfig = {} + +local DefaultActivityId = 1 + +XPokemonConfigs = XPokemonConfigs or {} +XPokemonConfigs.PokemonNewRoleClickedPrefix = "POKEMON_NEW_ROLE_CLICKED" + +local InitMonsterConfig = function() + MonsterTemplate = XTableManager.ReadByIntKey(TABLE_MONSTER_PATH, XTable.XTablePokemonMonster, "Id") + + for monsterId, config in pairs(MonsterTemplate) do + local npcId = config.NpcId + if npcId > 0 then + NpcIdToMonsterIdDic[npcId] = monsterId + end + end +end + +local InitMonsterLevelConfigs = function() + local paths = CS.XTableManager.GetPaths(TABLE_MONSTER_LEVEL_PATH) + XTool.LoopCollection(paths, function(path) + local key = XTool.GetFileNameWithoutExtension(path) + local template = XTableManager.ReadByIntKey(path, XTable.XTablePokemonMonsterLevel, "Level") + + for _, config in pairs(template) do + local itemId = config.CostItemId + if itemId and itemId > 0 then + ItemIdCheckDic[itemId] = itemId + end + end + + MonsterLevelTemplate[tonumber(key)] = template + end) +end + +local InitMonsterStarConfigs = function() + local paths = CS.XTableManager.GetPaths(TABLE_MONSTER_STAR_PATH) + XTool.LoopCollection(paths, function(path) + local key = XTool.GetFileNameWithoutExtension(path) + local template = XTableManager.ReadByIntKey(path, XTable.XTablePokemonMonsterStar, "Star") + + for _, config in pairs(template) do + local itemId = config.CostItemId + if itemId and itemId > 0 then + ItemIdCheckDic[itemId] = itemId + end + end + + MonsterStarTemplate[tonumber(key)] = template + end) +end + + +local InitStageConfigs = function() + StageRawTemplate = XTableManager.ReadByIntKey(TABLE_STAGE_PATH, XTable.XTablePokemonStage, "Id") + local sortTemplate = {} + for _, stage in pairs(StageRawTemplate) do + local activityId = stage.ActivityId + + if activityId then + sortTemplate[activityId] = sortTemplate[activityId] or {} + --if sortTemplate[activityId] then + -- tableInsert(sortTemplate[activityId], v) + --else + -- sortTemplate[activityId] = {} + -- tableInsert(sortTemplate[activityId], v) + --end + sortTemplate[activityId][stage.ChapterId] = sortTemplate[activityId][stage.ChapterId] or {} + tableInsert(sortTemplate[activityId][stage.ChapterId],stage) + end + end + + for k, v in pairs(sortTemplate) do + for _,chapter in pairs(v) do + tableSort(chapter, function(a, b) return a.Id < b.Id end) + end + end + for activityId,activityStages in pairs(sortTemplate) do + StageTemplate[activityId] = {} + FightStageIdToStageIdDic[activityId] = {} + local sortKey = {} + for chapterId,chapterStages in pairs(activityStages) do + tableInsert(sortKey,chapterId) + end + tableSort(sortKey) + for i = 1,#sortKey do + local index = 1 + StageTemplate[activityId][sortKey[i]] = activityStages[sortKey[i]] + for _,stage in pairs(activityStages[sortKey[i]]) do + local fightStageId = stage.StageId + if fightStageId and fightStageId > 0 then + FightStageIdToStageIdDic[activityId][fightStageId] = index + end + index = index + 1 + end + end + end +end + +local InitActivityConfig = function() + PokemonActivityCfgs = XTableManager.ReadByIntKey(TABLE_POKEMON_ACTIVITY_PATH, XTable.XTablePokemonActivity, "Id") + for activityId, config in pairs(PokemonActivityCfgs) do + if XTool.IsNumberValid(config.ActivityTimeId) then + DefaultActivityId = activityId + break + end + DefaultActivityId = activityId + end +end + +function XPokemonConfigs.Init() + MonsterCareerTemplate = XTableManager.ReadByIntKey(TABLE_MONSTER_CAREER_PATH, XTable.XTablePokemonMonsterCareer, "Career") + MonsterSkillTemplate = XTableManager.ReadByIntKey(TABLE_MONSTER_SKILL_PATH, XTable.XTablePokemonMonsterSkill, "Id") + StageMonsterTemplate = XTableManager.ReadByIntKey(TABLE_STAGE_MONSTER_PATH, XTable.XTablePokemonStageMonster, "Id") + PokemonInitCfgs = XTableManager.ReadByIntKey(TABLE_POKEMON_INIT_PATH, XTable.XTablePokemonInit, "Id") + ChapterConfig = XTableManager.ReadByIntKey(TABLE_CHAPTER_CONFIG_PATH,XTable.XTablePokemonChapterLocalConfig,"Id") + Chapters = XTableManager.ReadByIntKey(TABLE_Chapter_PATH,XTable.XTablePokemonChapter,"Id") + StageUITemplate = XTableManager.ReadByIntKey(TABLE_STAGE_TEMPLATE_PATH,XTable.XTablePokemonStageTemplate,"Id") + InitActivityConfig() + InitMonsterConfig() + InitMonsterLevelConfigs() + InitMonsterStarConfigs() + InitStageConfigs() +end + +-----------------怪物相关 begin-------------------- +--怪物类型 +XPokemonConfigs.MonsterType = { + Default = -1, + Member = 0, --小队成员 + Boss = 1, --团队核心 +} + +XPokemonConfigs.MonsterCareer = { + Shooter = 4, --射手 + Shield = 1, --盾卫 + Knight = 2, --骑士 + Assassin = 3, --刺客 +} + +--怪物 begin-- +local GetMonsterConfig = function(monsterId) + local config = MonsterTemplate[monsterId] + if not config then + XLog.Error("XPokemonConfigs GetMonsterConfig error:配置不存在, monsterId: " .. monsterId .. ", 配置路径: " .. TABLE_MONSTER_PATH) + return + end + return config +end + +function XPokemonConfigs.CheckMonsterType(monsterId, monsterType) + if not monsterId or monsterId == 0 then return false end + local config = GetMonsterConfig(monsterId) + return config.Type == monsterType +end + +function XPokemonConfigs.CheckMonsterCareer(monsterId, careerType) + if not monsterId or monsterId == 0 then return false end + local config = GetMonsterConfig(monsterId) + return config.Career == careerType +end + +function XPokemonConfigs.GetMonsterHeadIcon(monsterId) + local config = GetMonsterConfig(monsterId) + return config.HeadIcon +end + +function XPokemonConfigs.GetMonsterModelId(monsterId) + local config = GetMonsterConfig(monsterId) + return config.ModelId +end + +function XPokemonConfigs.GetMonsterName(monsterId) + local config = GetMonsterConfig(monsterId) + return config.Name +end + +function XPokemonConfigs.GetMonsterLevelTemplateId(monsterId) + local config = GetMonsterConfig(monsterId) + return config.LevelTemplateId +end + +function XPokemonConfigs.GetMonsterStarTemplateId(monsterId) + local config = GetMonsterConfig(monsterId) + return config.StarTemplateId +end + +function XPokemonConfigs.GetMonsterNpcId(monsterId) + local config = GetMonsterConfig(monsterId) + return config.NpcId +end + +function XPokemonConfigs.GetMonsterEnergyCost(monsterId) + local config = GetMonsterConfig(monsterId) + return config.EnergyCost +end + +function XPokemonConfigs.GetMonsterAbilityRate(monsterId) + local config = GetMonsterConfig(monsterId) + return config.AbilityRateMonster, config.AbilityRateHp, config.AbilityRateAttack +end + +function XPokemonConfigs.GetMonsterSkillIds(monsterId) + local skillIds = {} + local config = GetMonsterConfig(monsterId) + for _, skillId in ipairs(config.SkillIds) do + tableInsert(skillIds, skillId) + end + return skillIds +end + +function XPokemonConfigs.GetMonsterRatingIcon(monsterId) + local config = GetMonsterConfig(monsterId) + return config.RatingIcon or "" +end + +--怪物 end-- +--怪物职业 begin-- +function XPokemonConfigs.GetMonsterCareer(monsterId) + local config = GetMonsterConfig(monsterId) + return config.Career +end + +function XPokemonConfigs.GetMonsterCareerName(monsterId) + local career = XPokemonConfigs.GetMonsterCareer(monsterId) + return XPokemonConfigs.GetCareerName(career) +end + +function XPokemonConfigs.GetMonsterCareerIcon(monsterId) + local career = XPokemonConfigs.GetMonsterCareer(monsterId) + return XPokemonConfigs.GetCareerIcon(career) +end + +--本职业是否克制比较职业 +function XPokemonConfigs.IsMonsterCareerUp(monsterId, compareCareer) + local career = XPokemonConfigs.GetMonsterCareer(monsterId) + local restraintCareer = XPokemonConfigs.GetMonsterCareerRestraintCareer(career) + return compareCareer and restraintCareer == compareCareer or false +end + +--本职业是否被比较职业克制 +function XPokemonConfigs.IsMonsterCareerDown(monsterId, compareCareer) + local career = XPokemonConfigs.GetMonsterCareer(monsterId) + local restraintCareer = XPokemonConfigs.GetMonsterCareerRestraintCareer(compareCareer) + return restraintCareer and restraintCareer == career or false +end +--怪物职业 end-- +--怪物等级 begin-- +local GetMonsterLevelTemplate = function(monsterId) + local templateId = XPokemonConfigs.GetMonsterLevelTemplateId(monsterId) + local template = MonsterLevelTemplate[templateId] + if not template then + XLog.Error("XPokemonConfigs GetMonsterLevelTemplate error:配置不存在, templateId: " .. templateId .. ", 配置路径: " .. TABLE_MONSTER_LEVEL_PATH) + return + end + return template +end + +local GetMonsterLevelConfig = function(monsterId, level) + local template = GetMonsterLevelTemplate(monsterId) + local config = template[level] + if not config then + XLog.Error("XPokemonConfigs GetMonsterLevelConfig error:配置不存在, monsterId: " .. monsterId .. ", level: " .. level .. ", 配置路径: " .. TABLE_MONSTER_LEVEL_PATH) + return + end + return config +end + +function XPokemonConfigs.GetMonsterLevelCostItemInfo(monsterId, level) + local config = GetMonsterLevelConfig(monsterId, level) + return config.CostItemId, config.CostItemCount +end +--怪物等级 end-- +--怪物星级 begin-- +local GetMonsterStarTemplate = function(monsterId) + local templateId = XPokemonConfigs.GetMonsterStarTemplateId(monsterId) + local template = MonsterStarTemplate[templateId] + if not template then + XLog.Error("XPokemonConfigs GetMonsterStarTemplate error:配置不存在, templateId: " .. templateId .. ", 配置路径: " .. TABLE_MONSTER_STAR_PATH) + return + end + return template +end + +local GetMonsterStarConfig = function(monsterId, star) + local template = GetMonsterStarTemplate(monsterId) + local config = template[star] + if not config then + XLog.Error("XPokemonConfigs GetMonsterStarConfig error:配置不存在, monsterId: " .. monsterId .. ", star: " .. star .. ", 配置路径: " .. TABLE_MONSTER_STAR_PATH) + return + end + return config +end + +function XPokemonConfigs.GetMonsterStarCostItemInfo(monsterId, star) + local config = GetMonsterStarConfig(monsterId, star) + return config.CostItemId, config.CostItemCount +end + +function XPokemonConfigs.GetMonsterStarMaxLevel(monsterId, star) + local config = GetMonsterStarConfig(monsterId, star) + return config.MaxLevel +end + +function XPokemonConfigs.GetMonsterStarMaxStar(monsterId) + local template = GetMonsterStarTemplate(monsterId) + return #template +end +--怪物星级 end-- +--怪物技能 begin-- +local GetMonsterSkillConfig = function(skillId) + local config = MonsterSkillTemplate[skillId] + if not config then + XLog.Error("XPokemonConfigs GetMonsterSkillConfig error:配置不存在, skillId: " .. skillId .. ", 配置路径: " .. TABLE_MONSTER_SKILL_PATH) + return + end + return config +end + +function XPokemonConfigs.GetMonsterSkillName(skillId) + local config = GetMonsterSkillConfig(skillId) + return config.Name +end + +function XPokemonConfigs.GetMonsterSkillDescription(skillId) + local config = GetMonsterSkillConfig(skillId) + return config.Description +end + +function XPokemonConfigs.GetMonsterSkillUnlockStar(skillId) + local config = GetMonsterSkillConfig(skillId) + return config.UnlockStar +end + +function XPokemonConfigs.GetMonsterSkillIcon(skillId) + local config = GetMonsterSkillConfig(skillId) + return config.Icon +end + +function XPokemonConfigs.GetMonsterSkillGroupId(skillId) + local config = GetMonsterSkillConfig(skillId) + return config.Position +end +--怪物技能 end-- +--战中设置 begin-- +function XPokemonConfigs.GetMonsterIdByNpcId(npcId) + return NpcIdToMonsterIdDic[npcId] or 0 +end +--战中设置 end-- +-----------------怪物相关 end-------------------- +-----------------职业相关 begin-------------------- +local GetCareerConfig = function(career) + local config = MonsterCareerTemplate[career] + if not config then + XLog.Error("XPokemonConfigs GetCareerConfig error:配置不存在, career: " .. career .. ", 配置路径: " .. TABLE_MONSTER_CAREER_PATH) + return + end + return config +end + +XPokemonConfigs.DefaultAllCareer = -1 --代表全部职业 +function XPokemonConfigs.GetAllCareers() + local careers = {} + for career in pairs(MonsterCareerTemplate) do + tableInsert(careers, career) + end + tableInsert(careers, XPokemonConfigs.DefaultAllCareer) + return careers +end + +function XPokemonConfigs.GetCareerName(career) + if career == XPokemonConfigs.DefaultAllCareer then + return CsXTextManagerGetText("PokemonMonsterAllCareer") + end + + local config = GetCareerConfig(career) + return config.Name +end + +local DefaultIconPath = CS.XGame.ClientConfig:GetString("PokemonAllCareerIcon") +function XPokemonConfigs.GetCareerIcon(career) + if career == XPokemonConfigs.DefaultAllCareer then + return DefaultIconPath + end + + local config = GetCareerConfig(career) + return config.Icon +end + +--获取克制职业 +function XPokemonConfigs.GetMonsterCareerRestraintCareer(career) + if not career then return end + local config = GetCareerConfig(career) + return config.RestraintCareer +end + +--获取被克制职业 +function XPokemonConfigs.GetMonsterCareerRecommendCareer(career) + if not career then return end + for paramCareer in pairs(MonsterCareerTemplate) do + local restraintCareer = XPokemonConfigs.GetMonsterCareerRestraintCareer(paramCareer) + if restraintCareer == career then + return paramCareer + end + end +end +-----------------职业相关 end-------------------- +-----------------章节相关 begin------------------ +local GetChapterLocalConfig = function(chapterId) + local config = ChapterConfig[chapterId] + if not config then + XLog.Error("XPokemonConfigs.GetChapterLocalConfig 章节配置不存在, chapterId:",chapterId) + return + end + return config +end + +local GetChapter = function(chapterId) + local config = Chapters[chapterId] + if not config then + XLog.Error("XPokemonConfigs.GetChapter 章节配置不存在, chapterId:",chapterId) + return + end + return config +end + +function XPokemonConfigs.GetChapterName(chapterId) + local config = GetChapterLocalConfig(chapterId) + return config.Name +end + +function XPokemonConfigs.GetChapterBackground(chapterId) + local config = GetChapterLocalConfig(chapterId) + return config.Background +end + +function XPokemonConfigs.GetChapterDesc(chapterId) + local config = GetChapterLocalConfig(chapterId) + return config.Desc +end + +function XPokemonConfigs.GetChapterTitleImage(chapterId) + local config = GetChapterLocalConfig(chapterId) + return config.ChapterTitleImage +end + +function XPokemonConfigs.GetChapterScrollBg(chapterId) + local config = GetChapterLocalConfig(chapterId) + return config.ChapterScrollBg +end + +function XPokemonConfigs.GetChapterPerPageStageCount(chapterId) + local config = GetChapterLocalConfig(chapterId) + return config.PerPageStageCount +end + +function XPokemonConfigs.GetChapters(activityId) + local chapters = {} + for _,chapter in pairs(Chapters) do + if chapter.ActivityId == activityId then + tableInsert(chapters,chapter) + end + end + return chapters +end + +function XPokemonConfigs.GetChapterTimeId(chapterId) + local config = GetChapter(chapterId) + return config.TimeId +end + +function XPokemonConfigs.GetChapterOpenCondition(chapterId) + local config = GetChapter(chapterId) + return config.OpenCondition +end + +function XPokemonConfigs.GetChapterType(chapter) + local config = GetChapter(chapter) + return config.ChapterType +end + +-----------------章节相关 end-------------------- +-----------------关卡相关 begin------------------ +XPokemonConfigs.StageType = { + Normal = 1, --普通关 + --Infinity = 2 --无尽关 + Skip = 2, --可跳关 +} + +XPokemonConfigs.ChapterType = { + Normal = 1, --前四章不可跳关章节 + Skip = 2, --第五章可调关章节 +} + +XPokemonConfigs.TeamNum = 6 --关卡布阵队伍成员数量 +XPokemonConfigs.PerPageCount = 4 --每页关卡数量 + +local GetStageConfig = function(stageId, activityId, chapterId) + local stageDic = StageTemplate[activityId] + if not stageDic then + XLog.Error("XPokemonConfigs GetStageConfig error:该活动的关卡配置不存在, activityId:" .. activityId) + return + end + local chapterStages = stageDic[chapterId] + for index,stage in ipairs(chapterStages) do + if index == stageId then + return stage + end + end +end + +function XPokemonConfigs.GetFightStageIds() + local fightStageIds = {} + for _, chapters in pairs(StageTemplate) do + for _,chapterStages in pairs(chapters) do + for _,stage in pairs(chapterStages) do + if stage.StageId > 0 then + tableInsert(fightStageIds, stage.StageId) + end + end + end + end + return fightStageIds +end + +function XPokemonConfigs.GetRawConfigFightStageId(id) + local template = StageRawTemplate[id] + if not template then + return + end + return template.StageId +end + +function XPokemonConfigs.GetPokemonStageId(index,activityId,chapterId) + local config = GetStageConfig(index, activityId, chapterId) + return config.Id +end + +function XPokemonConfigs.GetStageChapterIdByFightStageId(activityId,fightStageId) + for _k,v in pairs(StageRawTemplate) do + if v.ActivityId == activityId and v.StageId == fightStageId then + return v.ChapterId + end + end + return 0 +end + +function XPokemonConfigs.GetStageUnlockDesc(stageId, activityId, chapterId) + local config = GetStageConfig(stageId, activityId, chapterId) + return config.UnlockDesc +end + +function XPokemonConfigs.GetStageFightStageId(stageId, activityId, chapterId) + local config = GetStageConfig(stageId, activityId, chapterId) + return config.StageId +end + +function XPokemonConfigs.GetStageMonsterIds(stageId, activityId, chapterId) + local stageMonsterIds = {} + local config = GetStageConfig(stageId, activityId, chapterId) + for index = 1, XPokemonConfigs.TeamNum do + local stageMonsterId = config.StageMonsterId[index - 1] + if stageMonsterId and stageMonsterId > 0 then + stageMonsterIds[index] = stageMonsterId + end + end + return stageMonsterIds +end + +function XPokemonConfigs.GetStageIcon(stageId, activityId,chapterId) + local fightStageId = XPokemonConfigs.GetStageFightStageId(stageId, activityId,chapterId) + return XDataCenter.FubenManager.GetStageIcon(fightStageId) +end + +function XPokemonConfigs.GetStageName(stageId, activityId,chapterId) + local fightStageId = XPokemonConfigs.GetStageFightStageId(stageId, activityId,chapterId) + return XDataCenter.FubenManager.GetStageName(fightStageId) +end + +function XPokemonConfigs.GetStageBg(stageId, activityId,chapterId) + local config = GetStageConfig(stageId, activityId,chapterId) + return config.StageBg +end + +function XPokemonConfigs.GetStageBossHeadIcon(stageId, activityId,chapterId) + local config = GetStageConfig(stageId, activityId,chapterId) + return config.BossHeadIcon +end + +function XPokemonConfigs.IsBossStage(stageId, activityId,chapterId) + local config = GetStageConfig(stageId, activityId,chapterId) + return config.IsBossStage > 0 +end + +function XPokemonConfigs.IsInfinityStage(stageId, activityId,chapterId) + --local config = GetStageConfig(stageId, activityId,chapterId) + --return config.StageType == XPokemonConfigs.StageType.Infinity + return false +end + +function XPokemonConfigs.IsCanSkipStage(stageId, activityId, chapterId) + local config = GetStageConfig(stageId, activityId,chapterId) + return config.StageType == XPokemonConfigs.StageType.Skip +end + +function XPokemonConfigs.GetStageCountByType(type, activityId,chapterId) + local count = 0 + local configs = StageTemplate[activityId][chapterId] + if not configs then + XLog.Error("XPokemonConfigs.GetStageCountByType 该活动的关卡配置不存在:activityId:", activityId) + return 0 + end + for k, v in pairs(configs) do + if v.StageType == type then + count = count + 1 + end + end + return count +end + +function XPokemonConfigs.GetStageCountByChapter(activityId, chapterId) + local count = 0 + local configs = StageTemplate[activityId][chapterId] + if not configs then + XLog.Error("XPokemonConfigs.GetStageCountByChapter 该活动的关卡配置不存在:activityId:", activityId) + return 0 + end + for _ in pairs(configs) do + count = count + 1 + end + return count +end + +function XPokemonConfigs.GetStageIdByFightStageId(activityId,fightStageId) + return FightStageIdToStageIdDic[activityId][fightStageId] or 0 +end + +function XPokemonConfigs.GetShowAbility(stageId, activityId, pos,chapterId) + local config = GetStageConfig(stageId, activityId,chapterId) + return config.ShowAbility[pos - 1] or 0 +end + +--关卡怪物 begin-- +local GetStageMonsterConfig = function(stageMonsterId) + local config = StageMonsterTemplate[stageMonsterId] + if not config then + XLog.Error("XPokemonConfigs GetStageMonsterConfig error:配置不存在, stageMonsterId:" .. stageMonsterId) + return + end + return config +end + +function XPokemonConfigs.GetStageMonsterHeadIcon(stageMonsterId) + local config = GetStageMonsterConfig(stageMonsterId) + return config.HeadIcon +end + +function XPokemonConfigs.GetStageMonsterLevel(stageMonsterId) + local config = GetStageMonsterConfig(stageMonsterId) + return config.Level +end + +function XPokemonConfigs.GetStageMonsterAbility(stageMonsterId) + local config = GetStageMonsterConfig(stageMonsterId) + return config.Ability +end + +function XPokemonConfigs.GetStageMonsterCareer(stageMonsterId) + local config = GetStageMonsterConfig(stageMonsterId) + return config.Career +end + +function XPokemonConfigs.GetStageMonsterCareerName(stageMonsterId) + local career = XPokemonConfigs.GetStageMonsterCareer(stageMonsterId) + return XPokemonConfigs.GetCareerName(career) +end + +function XPokemonConfigs.GetStageMonsterCareerIcon(stageMonsterId) + local career = XPokemonConfigs.GetStageMonsterCareer(stageMonsterId) + return XPokemonConfigs.GetCareerIcon(career) +end +--关卡怪物 end-- +-----------------关卡相关 end-------------------- +-----------------活动相关 begin----------------- +local function GetPokemonActivityCfgs(activityId) + local config = PokemonActivityCfgs[activityId] + if not config then + XLog.Error("XPokemonConfigs GetPokemonActivityCfgs error:配置不存在, activityId:" .. activityId) + return + end + return config +end + +local function GetActivityTimeId(activityId) + local config = GetPokemonActivityCfgs(activityId) + return config.ActivityTimeId +end + +function XPokemonConfigs.GetDefaultActivityId() + return DefaultActivityId +end + +function XPokemonConfigs.IsActivityInTime(activityId) + return XFunctionManager.CheckInTimeByTimeId(GetActivityTimeId(activityId)) +end + +function XPokemonConfigs.HasActivityInTime() + for k, v in pairs(PokemonActivityCfgs) do + if XFunctionManager.CheckInTimeByTimeId(v.ActivityTimeId) then + return true + end + end + return false +end + +function XPokemonConfigs.GetInTimeActivityId() + for k, v in pairs(PokemonActivityCfgs) do + if XFunctionManager.CheckInTimeByTimeId(v.ActivityTimeId) then + return v.Id + end + end +end + +function XPokemonConfigs.GetActivityTaskTimeLimitId(activityId) + local config = GetPokemonActivityCfgs(activityId) + return config.TaskTimeLimitId +end + +function XPokemonConfigs.GetActivityStartTime(activityId) + return XFunctionManager.GetStartTimeByTimeId(GetActivityTimeId(activityId)) +end + +function XPokemonConfigs.GetActivityEndTime(activityId) + return XFunctionManager.GetEndTimeByTimeId(GetActivityTimeId(activityId)) +end + +function XPokemonConfigs.GetActivityBg(activityId) + local config = GetPokemonActivityCfgs(activityId) + return config.Bg or "" +end + +function XPokemonConfigs.GetActivityName(activityId) + local config = GetPokemonActivityCfgs(activityId) + return config.Name or "" +end + + +-----------------活动相关 end------------------- +-----------------杂项 begin-------------------- +local function GetPokemonInitCfgs(id) + local config = PokemonInitCfgs[id] + if not config then + XLog.Error("XPokemonConfigs GetPokemonInitCfgs error:配置不存在, id:" .. id) + return + end + return config +end + +function XPokemonConfigs.GetTimeSupplyInterval() + local config = GetPokemonInitCfgs(1) + return config.TimeSupplyAccuInterval +end + +function XPokemonConfigs.GetTimeSupplyMaxCount() + local config = GetPokemonInitCfgs(1) + return config.TimeSupplyMaxCount +end + +function XPokemonConfigs.GetToCheckItemIdEventIds() + local eventIds = {} + for itemId in pairs(ItemIdCheckDic) do + tableInsert(eventIds, XEventId.EVENT_ITEM_COUNT_UPDATE_PREFIX .. itemId) + end + return eventIds +end + +function XPokemonConfigs.GetDefaultStageTimes() + local config = GetPokemonInitCfgs(1) + return config.DefaultStageTimes +end + +function XPokemonConfigs.GetEnterMovieId() + local config = GetPokemonInitCfgs(1) + return config.DramaId +end + +function XPokemonConfigs.GetDefaultStageTimesRecoverInterval() + local config = GetPokemonInitCfgs(1) + return config.StageTimesRecoverInterval +end + +function XPokemonConfigs.GetHelpId() + local config = GetPokemonInitCfgs(1) + return config.HelpId +end + +function XPokemonConfigs.GetSkipMaxTime() + local config = GetPokemonInitCfgs(1) + return config.StageSkipTimesMax +end + +function XPokemonConfigs.GetSkipItemId() + local config = GetPokemonInitCfgs(1) + return config.SkipItemId +end + +-----------------杂项 end-------------------- + +-----------------关卡UI模板 Begin------------------- +--设置的对象类型 +XPokemonConfigs.ObjType = { + Stage = 1, --关卡 + Line = 2, --关卡上的线 +} + +local DefaultTemplate = { + PosX = 0, + PosY = 0, + PosZ = 0, + ScaleX = 1, + ScaleY = 1, + ScaleZ = 1, +} + +function XPokemonConfigs.GetUiTemplate(chapterId, index, type) + local result + for _,template in pairs(StageUITemplate) do + if chapterId == template.ChapterId and index == template.Index and type == template.Type then + result = { + PosX = template.PosX, + PosY = template.PosY, + PosZ = template.PosZ, + ScaleX = template.ScaleX, + ScaleY = template.ScaleY, + ScaleZ = template.ScaleZ + } + end + end + return result or DefaultTemplate +end + +function XPokemonConfigs.GetUiTemplateCountByChapter(chapterId) + local count = 0 + for _, template in pairs(StageUITemplate) do + if template.ChapterId == chapterId then + count = count + 1 + end + end + return count +end + +-----------------关卡UI模板 End ------------------- \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XPokerGuessingConfig.lua b/Resources/Scripts/XConfig/XPokerGuessingConfig.lua new file mode 100644 index 00000000..017e6e68 --- /dev/null +++ b/Resources/Scripts/XConfig/XPokerGuessingConfig.lua @@ -0,0 +1,143 @@ +XPokerGuessingConfig = XPokerGuessingConfig or {} +local pairs = pairs +XPokerGuessingConfig.GameStatus = { + Initialize = 0, --初始化(未点开始时) + Process = 1, --进行中(猜牌前) + Failed = 2, --失败(猜错) + Victory = 3, --普通胜利(猜对可以继续) + LibraryEmpty = 4, --牌库空(决定是否继续) + Drawn = 5, --平局 +} + +XPokerGuessingConfig.GuessType = { + Less = 0, --小于 + Greater = 1, --大于 + Equal = 2, --等于 +} + +local TABLE_POKER_GUESSING_ACTIVITY_PATH = "Share/MiniActivity/PokerGuessing/PokerGuessingActivity.tab" +local TABLE_POKER_GUESSING_GROUP_PATH = "Share/MiniActivity/PokerGuessing/PokerGroup.tab" +local TABLE_POKER_GUESSInG_BUTTON_GROUP_PATH = "Client/MiniActivity/PokerGuessing/PokerGuessingButtonGroup.tab" + +local _PokerGuessingActivityTemplate = {} +local _PokerGuessingGroupTemplate = {} +local _PokerGuessingButtonGroupTemplate = {} +local _DefaultActivityId = 1 + +function XPokerGuessingConfig.Init() + _PokerGuessingActivityTemplate = XTableManager.ReadByIntKey(TABLE_POKER_GUESSING_ACTIVITY_PATH,XTable.XTablePokerGuessingActivity,"Id") + for id,config in pairs(_PokerGuessingActivityTemplate) do + if XTool.IsNumberValid(config.TaskTimeLimitId) then + _DefaultActivityId = id + break + end + _DefaultActivityId = id + end + _PokerGuessingGroupTemplate = XTableManager.ReadByIntKey(TABLE_POKER_GUESSING_GROUP_PATH,XTable.XTablePokerGroup,"Id") + _PokerGuessingButtonGroupTemplate = XTableManager.ReadByIntKey(TABLE_POKER_GUESSInG_BUTTON_GROUP_PATH,XTable.XTablePokerButtonGroup,"Id") +end + +local GetActivityConfig = function(id) + local config = _PokerGuessingActivityTemplate[id] + if not config then + XLog.Error("XPokerGuessingConfig.GetActivityConfig 配置不存在,id:",id) + return + end + return config +end + +function XPokerGuessingConfig.GetActivityName(id) + local config = GetActivityConfig(id) + return config.Name +end + +function XPokerGuessingConfig.GetActivityTimeId(id) + local config = GetActivityConfig(id) + return config.TaskTimeLimitId +end + +function XPokerGuessingConfig.GetBackAssetPath(id) + local config = GetActivityConfig(id) + return config.BackAssetPath +end + +function XPokerGuessingConfig.GetCostItemName(id) + local config = GetActivityConfig(id) + return XDataCenter.ItemManager.GetItemName(config.CostItemID) +end + +function XPokerGuessingConfig.GetCostItemIcon(id) + local config = GetActivityConfig(id) + return XDataCenter.ItemManager.GetItemIcon(config.CostItemID) +end + +function XPokerGuessingConfig.GetCostItemCount(id) + local config = GetActivityConfig(id) + return config.CostItemCount +end + +function XPokerGuessingConfig.GetTaskType(id) + local config = GetActivityConfig(id) + return config.TaskType +end + +function XPokerGuessingConfig.GetPokerGroup(id) + local config = GetActivityConfig(id) + return config.PokerGroupId +end + +function XPokerGuessingConfig.GetBannerBg(id) + local config = GetActivityConfig(id) + return config.BannerBg +end + +function XPokerGuessingConfig.GetShopSkipId(id) + local config = GetActivityConfig(id) + return config.ShopSkipId +end + +function XPokerGuessingConfig.GetDefaultActivityId() + return _DefaultActivityId +end + +function XPokerGuessingConfig.GetButtonGroupConfig() + return _PokerGuessingButtonGroupTemplate +end + +local GetCardConfigById = function(id) + local config = _PokerGuessingGroupTemplate[id] + if not config then + XLog.Error("XPokerGuessingConfig.GetCardConfigById 配置不存在,id:",id) + return + end + return config +end + +function XPokerGuessingConfig.GetCardFrontAssetPath(id) + local config = GetCardConfigById(id) + return config.FrontAssetPath +end + +function XPokerGuessingConfig.GetCardListByGroupId(groupId) + local tempList = {} + for id, card in pairs(_PokerGuessingGroupTemplate) do + if card.PokerGroup == groupId then + table.insert(tempList, { Id = id, FrontImg = card.FrontAssetPath }) + end + end + return tempList +end + +function XPokerGuessingConfig.GetCardListByType(suitType,groupId) + local tempList = {} + for id, card in pairs(_PokerGuessingGroupTemplate) do + if card.PokerSuitType == suitType and card.PokerGroup == groupId then + table.insert(tempList, { Id = id, FrontImg = card.FrontAssetPath }) + end + end + return tempList +end +function XPokerGuessingConfig.GetCardNumber(id) + local config = GetCardConfigById(id) + return config.PokerNum +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XPracticeConfigs.lua b/Resources/Scripts/XConfig/XPracticeConfigs.lua new file mode 100644 index 00000000..5e3ffa6b --- /dev/null +++ b/Resources/Scripts/XConfig/XPracticeConfigs.lua @@ -0,0 +1,86 @@ +XPracticeConfigs = XPracticeConfigs or {} + +local CLIENT_PRACTICE_CHAPTERDETAIL = "Client/Fuben/Practice/PracticeChapterDetail.tab" +local CLIENT_PRACTICE_SKILLDETAIL = "Client/Fuben/Practice/PracticeSkillDetails.tab" + +local SHARE_PRACTICE_CHAPTER = "Share/Fuben/Practice/PracticeChapter.tab" +local SHARE_PRACTICE_ACTIVITY = "Share/Fuben/Practice/PracticeActivity.tab" + +local PracticeChapterDetails = {} +local PracticeSkillDetails = {} +local PracticeActivityInfo = {} + +local PracticeChapters = {} + +XPracticeConfigs.PracticeType = { + Basics = 1, + Advanced = 2, + Character = 3, +} + +function XPracticeConfigs.Init() + PracticeChapterDetails = XTableManager.ReadByIntKey(CLIENT_PRACTICE_CHAPTERDETAIL, XTable.XTablePracticeChapterDetail, "Id") + PracticeSkillDetails = XTableManager.ReadByIntKey(CLIENT_PRACTICE_SKILLDETAIL, XTable.XTablePracticeSkillDetails, "StageId") + PracticeChapters = XTableManager.ReadByIntKey(SHARE_PRACTICE_CHAPTER, XTable.XTablePracticeChapter, "Id") + PracticeActivityInfo = XTableManager.ReadByIntKey(SHARE_PRACTICE_ACTIVITY, XTable.XTablePracticeActivity, "StageId") +end + +function XPracticeConfigs.GetPracticeChapters() + return PracticeChapters +end + +function XPracticeConfigs.GetPracticeChapterById(id) + local currentChapter = PracticeChapters[id] + + if not currentChapter then + XLog.ErrorTableDataNotFound("XPracticeConfigs.GetPracticeChapterById", "currentChapter", SHARE_PRACTICE_CHAPTER, "id", tostring(id)) + return + end + + return currentChapter +end + +function XPracticeConfigs.GetPracticeChapterConditionById(id) + local currentChapter = XPracticeConfigs.GetPracticeChapterById(id) + return currentChapter.ConditionId +end + +function XPracticeConfigs.GetPracticeChapterDetails() + return PracticeChapterDetails +end + +function XPracticeConfigs.GetPracticeChapterDetailById(id) + local currentChapterDetail = PracticeChapterDetails[id] + + if not currentChapterDetail then + XLog.ErrorTableDataNotFound("XPracticeConfigs.GetPracticeChapterDetailById", "currentChapterDetail", CLIENT_PRACTICE_CHAPTERDETAIL, "id", tostring(id)) + return + end + + return currentChapterDetail +end + +function XPracticeConfigs.GetPracticeDescriptionById(id) + local details = XPracticeConfigs.GetPracticeChapterDetailById(id) + if not details then return "" end + return details.Description or "" +end + +function XPracticeConfigs.GetPracticeChapterTypeById(id) + local details = XPracticeConfigs.GetPracticeChapterDetailById(id) + if not details then return end + return details.Type +end + +function XPracticeConfigs.GetPracticeActivityInfo(stageId) + return PracticeActivityInfo[stageId] +end + +function XPracticeConfigs.GetPracticeSkillDetailById(id) + local currentDetail = PracticeSkillDetails[id] + if not currentDetail then + XLog.ErrorTableDataNotFound("XPracticeConfigs.GetPracticeSkillDetailById", "currentDetail", CLIENT_PRACTICE_SKILLDETAIL, "id", tostring(id)) + return + end + return currentDetail +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XPrequelConfigs.lua b/Resources/Scripts/XConfig/XPrequelConfigs.lua new file mode 100644 index 00000000..57419d81 --- /dev/null +++ b/Resources/Scripts/XConfig/XPrequelConfigs.lua @@ -0,0 +1,119 @@ +XPrequelConfigs = XPrequelConfigs or {} + +local TABLE_PREQUEL_CHAPTER = "Share/Fuben/Prequel/Chapter.tab" +local TABLE_PREQUEL_COVER = "Share/Fuben/Prequel/Cover.tab" +local TABLE_PREQUEL_COVERINFO = "Client/Fuben/Prequel/CoverInfo.tab" +local TABLE_PREQUEL_CHAPTERINFO = "Client/Fuben/Prequel/ChapterInfo.tab" + +local PrequelChapter = {} +local PrequelCover = {} +local PrequelCoverInfo = {} +local PrequelChapterInfo = {} + +-- config层 +local Chapter2CoverMap = {}--记录chapter对应的cover +local Stage2ChapterMap = {}--记录stage对应的chapter + + +function XPrequelConfigs.Init() + PrequelChapter = XTableManager.ReadByIntKey(TABLE_PREQUEL_CHAPTER, XTable.XTablePrequelChapter, "ChapterId") + PrequelCover = XTableManager.ReadByIntKey(TABLE_PREQUEL_COVER, XTable.XTablePrequelCover, "CoverId") + PrequelCoverInfo = XTableManager.ReadByIntKey(TABLE_PREQUEL_COVERINFO, XTable.XTablePrequelCoverInfo, "CoverId") + PrequelChapterInfo = XTableManager.ReadByIntKey(TABLE_PREQUEL_CHAPTERINFO, XTable.XTablePrequelChapterInfo, "ChapterId") + + XPrequelConfigs.InitCoverChapterMapping() +end + +function XPrequelConfigs.InitCoverChapterMapping() + -- Chapter2CoverMap[chapterId] = coverId + for coverId, coverInfo in pairs(PrequelCover) do + for _, chapterId in pairs(coverInfo.ChapterId) do + Chapter2CoverMap[chapterId] = coverId + end + end + -- Stage2ChapterMap[stageId] = chapterId + for chapterId, chapterInfo in pairs(PrequelChapter) do + for _, stageId in pairs(chapterInfo.StageId) do + Stage2ChapterMap[stageId] = chapterId + end + end +end + +function XPrequelConfigs.GetCoverByChapterId(chapterId) + return Chapter2CoverMap[chapterId] +end + +function XPrequelConfigs.GetChapterByStageId(stageId) + return Stage2ChapterMap[stageId] +end + +function XPrequelConfigs.GetPrequelCoverInfoById(coverId) + + local coverInfo = PrequelCoverInfo[coverId] + if not coverInfo then + XLog.ErrorTableDataNotFound("XPrequelConfigs.GetPrequelCoverInfoById", "coverInfo", TABLE_PREQUEL_COVERINFO, "coverId", tostring(coverId)) + return + end + + return coverInfo +end + +function XPrequelConfigs.GetPrequelChapterInfoById(chapterId) + local chapterInfo = PrequelChapterInfo[chapterId] + + if not chapterInfo then + XLog.ErrorTableDataNotFound("XPrequelConfigs.GetPrequelChapterInfoById", "chapterInfo", TABLE_PREQUEL_CHAPTERINFO, "chapterId", tostring(chapterId)) + end + + return chapterInfo +end + +function XPrequelConfigs.GetPrequelCoverList() + return PrequelCover +end + +function XPrequelConfigs.GetPrequelCoverById(coverId) + if not PrequelCover then + return nil + end + + return PrequelCover[coverId] +end + +function XPrequelConfigs.GetPrequelCoverById(coverId) + local coverData = PrequelCover[coverId] + + if not coverData then + XLog.ErrorTableDataNotFound("XPrequelConfigs.GetPrequelCoverById", "coverData", TABLE_PREQUEL_COVER, "coverId", tostring(coverId)) + return + end + + return coverData +end + +function XPrequelConfigs.GetPrequelChapterById(chapterId) + local chapterData = PrequelChapter[chapterId] + + if not chapterData then + XLog.ErrorTableDataNotFound("XPrequelConfigs.GetPrequelChapterById", "chapterData", TABLE_PREQUEL_CHAPTER, "chapterId", tostring(chapterId)) + return + end + + return chapterData +end + +function XPrequelConfigs.GetPequelAllChapter() + return PrequelChapter +end + +function XPrequelConfigs.GetRegionalProgress(current, total) + return string.format("%d/%d", current, total) +end + +function XPrequelConfigs.GetNotEnoughCost(costNum) + return string.format("%d", costNum) +end +--[[修改过的PreStageId +XUiGridCourse +XFubenManager +--]] \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XPurchaseConfigs.lua b/Resources/Scripts/XConfig/XPurchaseConfigs.lua new file mode 100644 index 00000000..38455047 --- /dev/null +++ b/Resources/Scripts/XConfig/XPurchaseConfigs.lua @@ -0,0 +1,393 @@ +XPurchaseConfigs = XPurchaseConfigs or {} +-- local TABLE_PURCHASE_GIFT = "Share/Purchase/PurchasePackage.tab" +-- local TABLE_PURCHASE_ITEM = "Share/Purchase/PurchaseItem.tab" +-- local TABLE_PAY = "Share/Pay/Pay.tab" +local TABLE_PURCHASE_ICON_ASSETPATH = "Client/Purchase/PurchaseIconAssetPath.tab" +local TABLE_PURCHASE_TAB_CONTROL = "Client/Purchase/PurchaseTabControl.tab" +local TABLE_PURCHASE_UITYPE = "Client/Purchase/PurchaseUiType.tab" +local TABLE_PURCHASE_TAGTYPE = "Client/Purchase/PurchaseTagType.tab" +local TABLE_ACCUMULATED_PAY = "Share/Pay/AccumulatedPay.tab" +local TABLE_ACCUMULATED_PAY_REWARD = "Share/Pay/AccumulatedPayReward.tab" +local TABLE_LB_BY_PASS = "Client/Purchase/PurchaseLBByPass.tab" +local TABLE_PURCHASE_YK_ICON = "Client/Purchase/PurchaseYKIcon.tab" + +-- local PayConfig = {} +local PurchaseIconAssetPathConfig = {} +local PurchaseTabControlConfig = {} +local PurchaseUiTypeConfig = {} +local PurchaseTagTypeConfig = {} +local PurchaseYkIconConfig = {} + +local AccumulatedPayConfig = {} +local AccumulatedPayRewardConfig = {} +local PurchaseLBByPassConfig = {} + +local PurchaseUiTypeGroupConfig = nil + +local PurchaseTabGroupConfig = nil +local PurchaseTabByUiTypeConfig = nil +local PurchasePayUiTypeConfig = nil +local PurchaseLBUiTypeListConfig = nil +local PurchaseLBUiTypeDic = nil +local PurchaseYKUiTypeConfig = nil +local PurchaseHKUiTypeConfig = nil +local PurchaseLBByPassIDDic = nil +local PurchaseYKUiTypeDic = nil + +local PurchaseLBUiTypeDic = nil +local PurchaseYKUiTypeDic = nil + +XPurchaseConfigs.PurchaseDataConfig = { + Pay = 1, --充值 + LB = 2, --礼包 + YK = 3, --月卡 + HKDH = 4, --黑卡兑换 + HKShop = 5, --黑卡商店 +} + +XPurchaseConfigs.TabsConfig = { + Pay = 1, --充值 + LB = 2, --礼包 + YK = 3, --月卡 + HK = 4--黑卡 +} + +XPurchaseConfigs.ConsumeTypeConfig = { + RMB = 1, --人名币 + ITEM = 2, --道具 + FREE = 3, --免费 +} + +XPurchaseConfigs.RestTypeConfig = { + Day = 0, --每日 + Week = 1, --每周 + Month = 2, --每月 + Interval = 3, --间隔 + RemainDay = 4, +} + +XPurchaseConfigs.LBGetTypeConfig = { + Direct = 1, --直接 + Day = 2, --每日 +} + +XPurchaseConfigs.PanelNameConfig = { + PanelRecharge = "PanelRecharge", + PanelLb = "PanelLb", + --PanelYk = "PanelYk", + PanelHksd = "PanelHksd", + PanelDh = "PanelDh" +} + +XPurchaseConfigs.PanelExNameConfig = { + PanelRecharge = "PanelRechargeEx", + PanelLb = "PanelLbEx", + PanelYk = "PanelYkEx", + PanelHksd = "PanelHksdEx", + PanelDh = "PanelDhEx", + PanelCoatingLb = "PanelCoatingLbEx" +} + +XPurchaseConfigs.TabExConfig = { + Sample = 1, --没有页签 + EXTable = 2, --左边有页签 +} + +XPurchaseConfigs.PurchaseRewardAddState = { + CanGet = 1, --能领,没有领。 + Geted = 2, --已经领 + CanotGet = 3, --不能领,钱不够。 +} + +XPurchaseConfigs.PurchaseTagType = { + Normal = 0, -- 默认 + Discount = 1 -- 打折 +} + +XPurchaseConfigs.PayAddType = { + Activity = 1, -- 活动累充类型 + Forever = 2, -- 永久累充类型 +} + +-- 累积充值显示状态 +XPurchaseConfigs.LjczLookState = { + Hide = 1, + Show = 2, +} + +XPurchaseConfigs.YKType = +{ + Day = 14, --日卡 + Week = 13, --周卡 + Month = 2, --月卡 +} + +XPurchaseConfigs.LjczLookStateKey = "LJCZ_LOOK_STATE_KEY" +XPurchaseConfigs.PurchaseLJCZDefaultLookStateKey = "PurchaseLJCZDefaultLookState" + +function XPurchaseConfigs.Init() + XPurchaseConfigs.PurChaseGiftTips = CS.XGame.ClientConfig:GetInt("PurChaseGiftTips") or 1 + XPurchaseConfigs.PurChaseCardUiType = CS.XGame.ClientConfig:GetInt("PurchaseCardUiType") or 0 + XPurchaseConfigs.PurChaseCardId = CS.XGame.ClientConfig:GetInt("PurchaseCardId") + XPurchaseConfigs.PurChaseCardId1 = CS.XGame.ClientConfig:GetInt("PurchaseCardId1") or 0 + XPurchaseConfigs.PurYKContinueBuyDays = CS.XGame.ClientConfig:GetInt("PurYKContinueBuyDays") or 0 + + + if XPurchaseConfigs.PurChaseCardUiType == 0 then + XLog.Error("配置错误请检查ClinetConfig表PurchaseCardUiType是否存在") + end + + if XPurchaseConfigs.PurChaseCardId == 0 then + XLog.Error("配置错误请检查ClinetConfig表PurchaseCardId是否存在") + end + + if XPurchaseConfigs.PurChaseCardId1 == 0 then + XLog.Error("配置错误请检查ClinetConfig表PurchaseCardId1是否存在") + end + + -- PayConfig = XTableManager.ReadByStringKey(TABLE_PAY, XTable.XTablePay, "Key") + PurchaseIconAssetPathConfig = XTableManager.ReadByStringKey(TABLE_PURCHASE_ICON_ASSETPATH, XTable.XTablePurchaseIconAssetPath, "Icon") + PurchaseTabControlConfig = XTableManager.ReadByStringKey(TABLE_PURCHASE_TAB_CONTROL, XTable.XTablePurchaseTabControl, "Id") + PurchaseUiTypeConfig = XTableManager.ReadByIntKey(TABLE_PURCHASE_UITYPE, XTable.XTablePurchaseUiType, "UiType") + PurchaseTagTypeConfig = XTableManager.ReadByIntKey(TABLE_PURCHASE_TAGTYPE, XTable.XTablePurchaseTagType, "Tag") + AccumulatedPayConfig = XTableManager.ReadByIntKey(TABLE_ACCUMULATED_PAY, XTable.XTableAccumulatedPay, "Id") + AccumulatedPayRewardConfig = XTableManager.ReadByIntKey(TABLE_ACCUMULATED_PAY_REWARD, XTable.XTableAccumulatedPayReward, "Id") + -- PurchaseLBByPassConfig = XTableManager.ReadByIntKey(TABLE_LB_BY_PASS, XTable.XTablePurchaseLBByPass, "Id") + PurchaseYkIconConfig = XTableManager.ReadByIntKey(TABLE_PURCHASE_YK_ICON, XTable.XTablePurchaseYKIcon, "Id") +end + +function XPurchaseConfigs.GetIconPathByIconName(iconName) + return PurchaseIconAssetPathConfig[iconName] +end + +function XPurchaseConfigs.GetPurchaseLBByPassIDDic() + if PurchaseLBByPassIDDic then + return PurchaseLBByPassIDDic + end + + PurchaseLBByPassIDDic = {} + PurchaseLBByPassConfig = XTableManager.ReadByIntKey(TABLE_LB_BY_PASS, XTable.XTablePurchaseLBByPass, "Id") or {} + for _, v in pairs(PurchaseLBByPassConfig) do + if v then + PurchaseLBByPassIDDic[v.LBId] = v.LBId + end + end + return PurchaseLBByPassIDDic +end + +function XPurchaseConfigs.IsLBByPassID(id) + if not id then + return false + end + + local config = XPurchaseConfigs.GetPurchaseLBByPassIDDic() + if config then + return config[id] ~= nil + end + + return false +end + +function XPurchaseConfigs.GetGroupConfigType() + if not PurchaseTabGroupConfig then + PurchaseTabGroupConfig = {} + for _, v in pairs(PurchaseTabControlConfig) do + if v.IsOpen == 1 then + if not PurchaseTabGroupConfig[v.GroupId] then + local d = {} + d.GroupOrder = v.GroupOrder + d.GroupName = v.GroupName + d.GroupId = v.GroupId + d.GroupIcon = v.GroupIcon + d.Childs = {} + PurchaseTabGroupConfig[v.GroupId] = d + else + local groupOrder = PurchaseTabGroupConfig[v.GroupId].GroupOrder + if groupOrder > v.GroupOrder then + PurchaseTabGroupConfig[v.GroupId].GroupOrder = v.GroupOrder + end + end + table.insert(PurchaseTabGroupConfig[v.GroupId].Childs, v) + end + table.sort(PurchaseTabGroupConfig[v.GroupId].Childs, function(a, b) + return a.GroupOrder < b.GroupOrder + end) + end + table.sort(PurchaseTabGroupConfig, function(a, b) + return a.GroupOrder < b.GroupOrder + end) + end + return PurchaseTabGroupConfig +end + +function XPurchaseConfigs.GetUiTypeGroupConfig() + if not PurchaseUiTypeGroupConfig then + PurchaseUiTypeGroupConfig = {} + XPurchaseConfigs.GetGroupConfigType() + for _, v in pairs(PurchaseUiTypeConfig) do + if not PurchaseUiTypeGroupConfig[v.GroupType] then + PurchaseUiTypeGroupConfig[v.GroupType] = {} + end + + table.insert(PurchaseUiTypeGroupConfig[v.GroupType], v) + end + end +end + +-- 参数XPurchaseConfigs.TabsConfig,所有的uiType +function XPurchaseConfigs.GetUiTypesByTab(t) + XPurchaseConfigs.GetUiTypeGroupConfig() + return PurchaseUiTypeGroupConfig[t] +end + +-- 充值的uiType +function XPurchaseConfigs.GetPayUiTypes() + if not PurchasePayUiTypeConfig then + PurchasePayUiTypeConfig = {} + local cfg = XPurchaseConfigs.GetUiTypesByTab(XPurchaseConfigs.TabsConfig.Pay) + for _, v in pairs(cfg) do + PurchasePayUiTypeConfig[v.UiType] = v.UiType + end + end + + return PurchasePayUiTypeConfig +end + +-- 礼包的uiType的list +function XPurchaseConfigs.GetLBUiTypesList() + if not PurchaseLBUiTypeListConfig then + PurchaseLBUiTypeListConfig = {} + local cfg = XPurchaseConfigs.GetUiTypesByTab(XPurchaseConfigs.TabsConfig.LB) + for _, v in pairs(cfg) do + table.insert(PurchaseLBUiTypeListConfig, v.UiType) + end + end + + return PurchaseLBUiTypeListConfig +end + +-- 礼包的uiType的Dic +function XPurchaseConfigs.GetLBUiTypesDic() + if not PurchaseLBUiTypeDic then + PurchaseLBUiTypeDic = {} + local cfg = XPurchaseConfigs.GetUiTypesByTab(XPurchaseConfigs.TabsConfig.LB) + for _,v in pairs(cfg) do + PurchaseLBUiTypeDic[v.UiType] = true + end + end + + return PurchaseLBUiTypeDic +end + +function XPurchaseConfigs.GetYKUiTypesDic() + if not PurchaseYKUiTypeDic then + PurchaseYKUiTypeDic = {} + local cfg = XPurchaseConfigs.GetUiTypesByTab(XPurchaseConfigs.TabsConfig.YK) + for _,v in pairs(cfg)do + PurchaseYKUiTypeDic[v.UiType] = true + end + end + + return PurchaseYKUiTypeDic +end + +-- 月卡的uiType +function XPurchaseConfigs.GetYKUiTypes() + if not PurchaseYKUiTypeConfig then + PurchaseYKUiTypeConfig = {} + local cfg = XPurchaseConfigs.GetUiTypesByTab(XPurchaseConfigs.TabsConfig.YK) or {} + for _, v in pairs(cfg) do + table.insert(PurchaseYKUiTypeConfig, v.UiType) + end + end + + return PurchaseYKUiTypeConfig +end + +-- 黑卡的uiType +function XPurchaseConfigs.GetHKUiTypes() + if not PurchaseHKUiTypeConfig then + PurchaseHKUiTypeConfig = {} + local cfg = XPurchaseConfigs.GetUiTypesByTab(XPurchaseConfigs.TabsConfig.HK) + for _, v in pairs(cfg) do + table.insert(PurchaseHKUiTypeConfig, v.UiType) + end + end + + return PurchaseHKUiTypeConfig +end + +function XPurchaseConfigs.GetTabControlUiTypeConfig() + if not PurchaseTabByUiTypeConfig then + PurchaseTabByUiTypeConfig = {} + for _, v in pairs(PurchaseTabControlConfig) do + PurchaseTabByUiTypeConfig[v.UiType] = v + end + end + + return PurchaseTabByUiTypeConfig +end + +function XPurchaseConfigs.GetUiTypeConfigByType(uiType) + return PurchaseUiTypeConfig[uiType] +end + +function XPurchaseConfigs.GetTagDes(tag) + if not PurchaseTagTypeConfig[tag] then + return "" + end + return PurchaseTagTypeConfig[tag].Des +end + +function XPurchaseConfigs.GetTagBgPath(tag) + if not PurchaseTagTypeConfig[tag] then + return nil + end + return PurchaseTagTypeConfig[tag].Style +end + +function XPurchaseConfigs.GetTagEffectPath(tag) + if not PurchaseTagTypeConfig[tag] then + return nil + end + return PurchaseTagTypeConfig[tag].Effect +end + +function XPurchaseConfigs.GetTagType(tag) + if not PurchaseTagTypeConfig[tag] then + return nil + end + return PurchaseTagTypeConfig[tag].Type +end + +function XPurchaseConfigs.GetAccumulatePayConfigById(id) + if not id or not AccumulatedPayConfig[id] then + return + end + + return AccumulatedPayConfig[id] +end + +function XPurchaseConfigs.GetAccumulateRewardConfigById(id) + if not id or not AccumulatedPayRewardConfig[id] then + return + end + + return AccumulatedPayRewardConfig[id] +end + +function XPurchaseConfigs.GetPurchaseNameByUiType(uitype) + local name + + for _, v in pairs(PurchaseTabControlConfig) do + if v.UiType == uitype then + name = v.Name + end + end + + return name +end + +function XPurchaseConfigs.GetPurchaseYKIconById(id) + return PurchaseYkIconConfig[id] +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XPuzzleActivityConfigs.lua b/Resources/Scripts/XConfig/XPuzzleActivityConfigs.lua new file mode 100644 index 00000000..c482c464 --- /dev/null +++ b/Resources/Scripts/XConfig/XPuzzleActivityConfigs.lua @@ -0,0 +1,36 @@ +local TABLE_PUZZLE_ACTIVITY_PATH = "Share/MiniActivity/PuzzleActivity.tab" +local TABLE_PUZZLE_ACTIVITY_PIECE_PATH = "Share/MiniActivity/PuzzleActivityPiece.tab" + +local PuzzleActivityTemplates = nil +local PuzzleActivityPieceTemplates = nil + +XPuzzleActivityConfigs = XPuzzleActivityConfigs or {} + +XPuzzleActivityConfigs.PuzzleCondition = { + NotCollected = 0, -- 未翻转 + Activated = 1, -- 已翻转 + Inactivated = 2, -- 未翻转,可翻转 +} + +XPuzzleActivityConfigs.PuzzleRewardState = { + Unrewarded = 0,-- 未领取 + Rewarded = 1, -- 已领取 + CanReward = 2, -- 未领取,可领取 +} + +XPuzzleActivityConfigs.PieceFlipKey = "PuzzleActivityPieceFlip" +XPuzzleActivityConfigs.RewardKey = "PuzzleActivityReward" + +function XPuzzleActivityConfigs.Init() + PuzzleActivityTemplates = XTableManager.ReadByIntKey(TABLE_PUZZLE_ACTIVITY_PATH, XTable.XTablePuzzleActivity, "Id") + PuzzleActivityPieceTemplates = XTableManager.ReadByIntKey(TABLE_PUZZLE_ACTIVITY_PIECE_PATH, XTable.XTablePuzzleActivityPiece, "Id") + +end + +function XPuzzleActivityConfigs.GetTemplates() + return PuzzleActivityTemplates +end + +function XPuzzleActivityConfigs.GetPieceTemplates() + return PuzzleActivityPieceTemplates +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XRedEnvelopeConfigs.lua b/Resources/Scripts/XConfig/XRedEnvelopeConfigs.lua new file mode 100644 index 00000000..da6ecbe2 --- /dev/null +++ b/Resources/Scripts/XConfig/XRedEnvelopeConfigs.lua @@ -0,0 +1,18 @@ +XRedEnvelopeConfigs = XRedEnvelopeConfigs or {} + +local TABLE_REDENVELOPE_NPC_PATH = "Share/RedEnvelope/RedEnvelopeNpc.tab" + +local RedEnvelopeNpcTemplates = {} + +function XRedEnvelopeConfigs.Init() + RedEnvelopeNpcTemplates = XTableManager.ReadByIntKey(TABLE_REDENVELOPE_NPC_PATH, XTable.XTableRedEnvelopeNpc, "Id") +end + +function XRedEnvelopeConfigs.GetNpcConfig(id) + local template = RedEnvelopeNpcTemplates[id] + if not template then + XLog.ErrorTableDataNotFound("XRedEnvelopeConfigs.GetNpcConfig", "template", TABLE_REDENVELOPE_NPC_PATH, "id", tostring(id)) + return + end + return template +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XReformConfigs.lua b/Resources/Scripts/XConfig/XReformConfigs.lua new file mode 100644 index 00000000..9a5cb5e9 --- /dev/null +++ b/Resources/Scripts/XConfig/XReformConfigs.lua @@ -0,0 +1,184 @@ +XReformConfigs = XReformConfigs or {} +-- 配置表路径 +local SHARE_TABLE_ROOT_PATH = "Share/Fuben/Reform/" +local CLIENT_TABLE_ROOT_PATH = "Client/Fuben/Reform/" +-- 配置数据 +-- 基础关卡配置信息 +local StageConfig = nil +-- 改造关卡配置信息 +local StageDiffConfig = nil +-- 敌人组配置信息 +local EnemyGroupConfig = nil +-- 敌人源配置信息 +local EnemySourceConfig = nil +-- 敌人替换目标配置信息 +local EnemyTargetConfig = nil +-- 成员组配置信息 +local MemberGroupConfig = nil +-- 成员源配置信息 +local MemberSourceConfig = nil +-- 成员替换目标配置信息 +local MemberTargetConfig = nil +-- 环境组配置信息 +local EnvironmentGroupConfig = nil +-- 环境配置信息 +local EnvironmentConfig = nil +-- 加成组配置信息 +local BuffGroupConfig = nil +-- 加成配置信息 +local BuffConfig = nil +-- 活动相关配置 +local ActivityConfig = nil +local EnemyBuffDetailConfig = nil +local EvolvableGroupBtnSortConfig = nil + +-- 枚举 +XReformConfigs.EntityType = { + Entity = 1, + Add = 2, +} +-- 改造页签类型 +XReformConfigs.EvolvableGroupType = { + Enemy = 1, + Environment = 2, + Buff = 3, + Member = 4, +} + +-- 表现相关配置 +XReformConfigs.ScrollTime = 0.3 -- 源面板滚动时间 +XReformConfigs.MinDistance = 150 -- 滚动检测最小距离 +XReformConfigs.MaxDistance = 500 -- 滚动检测最大距离 +XReformConfigs.ScrollOffset = 50 -- 滚动偏移 + +function XReformConfigs.Init() + local xTableManager = XTableManager + local xTable = XTable + StageConfig = xTableManager.ReadByIntKey(SHARE_TABLE_ROOT_PATH .. "ReformStage.tab", xTable.XTableReformStage, "Id") + StageDiffConfig = xTableManager.ReadByIntKey(SHARE_TABLE_ROOT_PATH .. "ReformStageDiff.tab", xTable.XTableReformStageDifficulty, "Id") + EnemyGroupConfig = xTableManager.ReadByIntKey(SHARE_TABLE_ROOT_PATH .. "ReformEnemyGroup.tab", xTable.XTableReformGroup, "Id") + EnemySourceConfig = xTableManager.ReadByIntKey(SHARE_TABLE_ROOT_PATH .. "ReformEnemySource.tab", xTable.XTableReformEnemySource, "Id") + EnemyTargetConfig = xTableManager.ReadByIntKey(SHARE_TABLE_ROOT_PATH .. "ReformEnemyTarget.tab", xTable.XTableReformEnemyTarget, "Id") + MemberGroupConfig = xTableManager.ReadByIntKey(SHARE_TABLE_ROOT_PATH .. "ReformMemberGroup.tab", xTable.XTableReformGroup, "Id") + MemberSourceConfig = xTableManager.ReadByIntKey(SHARE_TABLE_ROOT_PATH .. "ReformMemberSource.tab", xTable.XTableReformMemberSource, "Id") + MemberTargetConfig = xTableManager.ReadByIntKey(SHARE_TABLE_ROOT_PATH .. "ReformMemberTarget.tab", xTable.XTableReformMemberTarget, "Id") + EnvironmentGroupConfig = xTableManager.ReadByIntKey(SHARE_TABLE_ROOT_PATH .. "ReformEnvGroup.tab", xTable.XTableReformGroup, "Id") + EnvironmentConfig = xTableManager.ReadByIntKey(SHARE_TABLE_ROOT_PATH .. "ReformEnv.tab", xTable.XTableReformEnv, "Id") + BuffGroupConfig = xTableManager.ReadByIntKey(SHARE_TABLE_ROOT_PATH .. "ReformBuffGroup.tab", xTable.XTableReformGroup, "Id") + BuffConfig = xTableManager.ReadByIntKey(SHARE_TABLE_ROOT_PATH .. "ReformBuff.tab", xTable.XTableReformBuff, "Id") + ActivityConfig = xTableManager.ReadByIntKey(SHARE_TABLE_ROOT_PATH .. "ReformCfg.tab", xTable.XTableReformCfg, "Id") + EnemyBuffDetailConfig = xTableManager.ReadByIntKey(CLIENT_TABLE_ROOT_PATH .. "ReformEnemyBuffDetail.tab", xTable.XTableReformEnemyBuffDetail, "Id") + EvolvableGroupBtnSortConfig = xTableManager.ReadByIntKey(CLIENT_TABLE_ROOT_PATH .. "ReformEvolvableGroupBtnSort.tab", xTable.XTableReformEvolvableGroupBtnSort, "Id") +end + +function XReformConfigs.GetEnemyBuffDetail(id) + return EnemyBuffDetailConfig[id] +end + +function XReformConfigs.GetGroupTypeSortWeight(groupType) + return EvolvableGroupBtnSortConfig[groupType].Weight +end + +function XReformConfigs.GetActivityConfig(id) + local result = ActivityConfig[id] + if result == nil then + for _, config in pairs(ActivityConfig) do + if XFunctionManager.CheckInTimeByTimeId(config.OpenTimeId) then + result = config + break + end + end + end + -- 还是空的就拿默认的 + if result == nil then + result = ActivityConfig[1] + end + return result +end + +-- 获取所有基础关卡数据 +function XReformConfigs.GetStageConfigDic() + return StageConfig +end + +function XReformConfigs.GetStageConfigIds() + if XReformConfigs.__StageConfigIds == nil then + XReformConfigs.__StageConfigIds = {} + for configId, _ in pairs(StageConfig) do + table.insert(XReformConfigs.__StageConfigIds, configId) + end + table.sort(XReformConfigs.__StageConfigIds, function(idA, idB) + return idA < idB + end) + end + return XReformConfigs.__StageConfigIds +end + +function XReformConfigs.GetStageConfigById(id) + return StageConfig[id] +end + +-- 获取基础关卡对应的改造关卡数据 +function XReformConfigs.GetStageDiffConfigsByStageId(id) + local result = {} + local config = StageConfig[id] + if config == nil then return result end + for _, stageDiffId in ipairs(config.StageDiff) do + table.insert(result, StageDiffConfig[stageDiffId]) + end + return result +end + +function XReformConfigs.GetStageDiffConfigById(id) + return StageDiffConfig[id] +end + +-- 获取敌人组配置数据 +function XReformConfigs.GetEnemyGroupConfig(id) + return EnemyGroupConfig[id] +end + +-- 获取敌人源配置 +function XReformConfigs.GetEnemySourceConfig(id) + return EnemySourceConfig[id] +end + +-- 获取敌人目标配置 +function XReformConfigs.GetEnemyTargetConfig(id) + return EnemyTargetConfig[id] +end + +-- 获取成员组配置数据 +function XReformConfigs.GetMemberGroupConfig(id) + return MemberGroupConfig[id] +end + +-- 获取成员源配置 +function XReformConfigs.GetMemberSourceConfig(id) + return MemberSourceConfig[id] +end + +-- 获取成员目标配置 +function XReformConfigs.GetMemberTargetConfig(id) + return MemberTargetConfig[id] +end + +-- 获取环境组配置数据 +function XReformConfigs.GetEnvironmentGroupConfig(id) + return EnvironmentGroupConfig[id] +end + +-- 获取环境配置数据 +function XReformConfigs.GetEnvironmentConfig(id) + return EnvironmentConfig[id] +end + +-- 获取加成组配置数据 +function XReformConfigs.GetBuffGroupConfig(id) + return BuffGroupConfig[id] +end + +-- 获取加成配置数据 +function XReformConfigs.GetBuffConfig(id) + return BuffConfig[id] +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XRegressionConfigs.lua b/Resources/Scripts/XConfig/XRegressionConfigs.lua new file mode 100644 index 00000000..170dfb3e --- /dev/null +++ b/Resources/Scripts/XConfig/XRegressionConfigs.lua @@ -0,0 +1,252 @@ +XRegressionConfigs = XRegressionConfigs or {} + +XRegressionConfigs.ActivityType = { + Task = 1, + Invitation = 2, + Shop = 3, +} + +XRegressionConfigs.ActivitySubType = { + Task = 1, + SendInvitation = 2, + AcceptInvitation = 3, +} + +XRegressionConfigs.TaskType = { + All = 0, + Course = 1, + Day = 2, + Week = 3, +} + +XRegressionConfigs.IndexToTaskType = { + XRegressionConfigs.TaskType.Course, + XRegressionConfigs.TaskType.Day, + XRegressionConfigs.TaskType.Week, +} + +-- 子活动类型对应的的标签文本 +XRegressionConfigs.ActivityTypeToTabText = { + [XRegressionConfigs.ActivityType.Task] = CS.XTextManager.GetText("RegressionTabTextTask"), +} + +-- 回归活动主界面展示的活动类型列表 +XRegressionConfigs.MainViewShowedTypeList = { + XRegressionConfigs.ActivityType.Task +} + +XRegressionConfigs.AutoWindowKey = "RegressionAutoWindow" +XRegressionConfigs.AutoStoryKey = "RegressionAutoStory" +XRegressionConfigs.SendInvitationReadKey = "RegressionSendInvitationReadKey" +XRegressionConfigs.AcceptInvitationReadKey = "RegressionAcceptInvitationReadKey" + +XRegressionConfigs.InvitationStatus = { + SendInvitation = 1, + AcceptInvitation = 2, + Both = 3, +} + +local TABLE_ACTIVITY = "Share/Regression/RegressionActivity.tab" +local TABLE_TASK = "Share/Regression/RegressionTask.tab" +local TABLE_TASK_SCHEDULE_REWARD = "Share/Regression/RegressionScheduleReward.tab" +local TABLE_INVITATION = "Share/Regression/RegressionInvite.tab" +local TABLE_SEND_INVITATION_REWARD = "Share/Regression/RegressionInviteReward.tab" + +local ActivityTemplates +local TaskTemplates +local TaskScheduleRewardTemplates +local InvitationTemplates +local SendInvitationRewardTemplates + +local TaskIdToTaskTypeDic = {} +local GroupIdToScheduleRewardListDic = {} + +function XRegressionConfigs.Init() + ActivityTemplates = XTableManager.ReadByIntKey(TABLE_ACTIVITY, XTable.XTableRegressionActivity, "Id") + TaskTemplates = XTableManager.ReadByIntKey(TABLE_TASK, XTable.XTableRegressionTask, "Id") + TaskScheduleRewardTemplates = XTableManager.ReadByIntKey(TABLE_TASK_SCHEDULE_REWARD, XTable.XTableRegressionScheduleReward, "Id") + InvitationTemplates = XTableManager.ReadByIntKey(TABLE_INVITATION, XTable.XTableRegressionInvite, "Id") + SendInvitationRewardTemplates = XTableManager.ReadByIntKey(TABLE_SEND_INVITATION_REWARD, XTable.XTableRegressionInviteReward, "Id") + + XRegressionConfigs.CreateActivityTypeToRedPointCondition() + XRegressionConfigs.CreateTaskIdToTaskTypeDic() + XRegressionConfigs.CreateGroupIdToTaskScheduleListDic() +end + +function XRegressionConfigs.CreateActivityTypeToRedPointCondition() + XRegressionConfigs.ActivityTypeToRedPointCondition = { + [XRegressionConfigs.ActivityType.Task] = XRedPointConditions.Types.CONDITION_REGRESSION_TASK, + } +end + +function XRegressionConfigs.CreateTaskIdToTaskTypeDic() + local taskIdList + local type + for _, template in pairs(TaskTemplates) do + type = XRegressionConfigs.TaskType.Course + taskIdList = template.TaskId + for _, taskId in ipairs(taskIdList) do + TaskIdToTaskTypeDic[taskId] = type + end + + type = XRegressionConfigs.TaskType.Day + taskIdList = template.DailyTaskId + for _, taskId in ipairs(taskIdList) do + TaskIdToTaskTypeDic[taskId] = type + end + + type = XRegressionConfigs.TaskType.Week + taskIdList = template.WeeklyTaskId + for _, taskId in ipairs(taskIdList) do + TaskIdToTaskTypeDic[taskId] = type + end + end +end + +function XRegressionConfigs.CreateGroupIdToTaskScheduleListDic() + local groupId + for _, template in pairs(TaskScheduleRewardTemplates) do + groupId = template.Group + GroupIdToScheduleRewardListDic[groupId] = GroupIdToScheduleRewardListDic[groupId] or {} + table.insert(GroupIdToScheduleRewardListDic[groupId], template) + end + + local sortFunc = function(a, b) + return a.Schedule < b.Schedule + end + for _, rewardList in pairs(GroupIdToScheduleRewardListDic) do + table.sort(rewardList, sortFunc) + end +end + +function XRegressionConfigs.GetActivityTemplates() + return ActivityTemplates +end + +function XRegressionConfigs.GetActivityTemplateByActivityId(activityId) + return ActivityTemplates[activityId] +end + +function XRegressionConfigs.GetActivityTime(activityId) + local config = XRegressionConfigs.GetActivityTemplateByActivityId(activityId) + return XFunctionManager.GetTimeByTimeId(config.TimeId) +end + +function XRegressionConfigs.GetTaskGroupIdByActivityId(activityId) + local activityTemplate = ActivityTemplates[activityId] + if activityTemplate and activityTemplate.Type == XRegressionConfigs.ActivityType.Task then + return activityTemplate.Param[1] + end + XLog.ErrorTableDataNotFound("XRegressionConfigs.GetTaskGroupIdByActivityId", "RegressionActivity", TABLE_ACTIVITY, "activityId", tostring(activityId)) +end + +function XRegressionConfigs.GetTaskIdListByIdAndType(id, taskType) + local taskTemplate = TaskTemplates[id] + if taskTemplate == nil then + XLog.ErrorTableDataNotFound("XRegressionConfigs.GetTaskIdListByIdAndType", "RegressionTask", TABLE_TASK, "id", tostring(id)) + return + end + local taskIdList + if taskType == XRegressionConfigs.TaskType.Course then + taskIdList = taskTemplate.TaskId + elseif taskType == XRegressionConfigs.TaskType.Day then + taskIdList = taskTemplate.DailyTaskId + elseif taskType == XRegressionConfigs.TaskType.Week then + taskIdList = taskTemplate.WeeklyTaskId + end + return taskIdList +end + +function XRegressionConfigs.GetScheduleItemIdByActivityId(activityId) + local activityTemplate = ActivityTemplates[activityId] + if activityTemplate and activityTemplate.Type == XRegressionConfigs.ActivityType.Task then + return activityTemplate.ScheduleItemId + end + XLog.ErrorTableDataNotFound("XRegressionConfigs.GetScheduleItemIdByActivityId", "RegressionActivity", TABLE_ACTIVITY, "activityId", tostring(activityId)) + return +end + +function XRegressionConfigs.GetTaskScheduleGroupId(activityId) + local activityTemplate = ActivityTemplates[activityId] + if activityTemplate and activityTemplate.Type == XRegressionConfigs.ActivityType.Task then + return activityTemplate.Param[2] + end +end + +function XRegressionConfigs.GetActivityStoryId(activityId) + local activityTemplate = ActivityTemplates[activityId] + if activityTemplate then + return activityTemplate.StoryId + end + XLog.ErrorTableDataNotFound("XRegressionConfigs.GetActivityStoryId", "RegressionActivity", TABLE_ACTIVITY, "activityId", tostring(activityId)) +end + +function XRegressionConfigs.GetInvitationTemplateId(activityId) + local activityTemplate = ActivityTemplates[activityId] + if activityTemplate and activityTemplate.Type == XRegressionConfigs.ActivityType.Invitation then + return activityTemplate.Param[1] + end +end + +function XRegressionConfigs.GetTaskTypeById(id) + local type = TaskIdToTaskTypeDic[id] + if not type then + XLog.ErrorTableDataNotFound("XRegressionConfigs.GetTaskTypeById", "RegressionTask", TABLE_TASK, "id", tostring(id)) + type = XRegressionConfigs.TaskType.Course + end + return type +end + +function XRegressionConfigs.GetTaskScheduleRewardList(groupId) + local rewardList = GroupIdToScheduleRewardListDic[groupId] + if not rewardList then + XLog.ErrorTableDataNotFound("XRegressionConfigs.GetTaskScheduleRewardList", "RegressionScheduleReward", TABLE_TASK_SCHEDULE_REWARD, "groupId", tostring(groupId)) + end + return rewardList +end + +function XRegressionConfigs.GetTaskMaxTargetSchedule(groupId) + local rewardList = GroupIdToScheduleRewardListDic[groupId] + if rewardList then + return rewardList[#rewardList].Schedule + end + return 0 +end + +function XRegressionConfigs.GetInvitationTemplate(templateId) + local invitationTemplate = InvitationTemplates[templateId] + if invitationTemplate then + return invitationTemplate + end + XLog.ErrorTableDataNotFound("XRegressionConfigs.GetInvitationTemplate", "RegressionInvite", TABLE_INVITATION, "Id", tostring(templateId)) +end + +function XRegressionConfigs.GetSendInvitationRewardNeedCount(id) + local template = SendInvitationRewardTemplates[id] + if template then + return template.People + end + XLog.ErrorTableDataNotFound("XRegressionConfigs.GetSendInvitationRewardNeedCount", "RegressionInviteReward", + TABLE_SEND_INVITATION_REWARD, "Id", tostring(id)) + return 0 +end + +function XRegressionConfigs.GetSendInvitationRewardTemplate(id) + local template = SendInvitationRewardTemplates[id] + if template then + return template + end + XLog.ErrorTableDataNotFound("XRegressionConfigs.GetSendInvitationRewardTemplate", "RegressionInviteReward", + TABLE_SEND_INVITATION_REWARD, "Id", tostring(id)) +end + +-- 获取发送邀请奖励的最大人数 +function XRegressionConfigs.GetInvitationRewardMaxPeople(id) + local invitationTemplate = XRegressionConfigs.GetInvitationTemplate(id) + local inviteRewardCount = #invitationTemplate.InviteRewardId + if inviteRewardCount == 0 then + return 0 + end + local inviteRewardId = invitationTemplate.InviteRewardId[inviteRewardCount] + return XRegressionConfigs.GetSendInvitationRewardNeedCount(inviteRewardId) +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XReportConfigs.lua b/Resources/Scripts/XConfig/XReportConfigs.lua new file mode 100644 index 00000000..abed1af3 --- /dev/null +++ b/Resources/Scripts/XConfig/XReportConfigs.lua @@ -0,0 +1,13 @@ +XReportConfigs = XReportConfigs or {} + +local TABLE_REPORT_PATH = "Share/Report/ReportTag.tab" + +local ReportCfg = {} + +function XReportConfigs.Init() + ReportCfg = XTableManager.ReadByIntKey(TABLE_REPORT_PATH, XTable.XTableReportTag, "Id") +end + +function XReportConfigs.GetReportCfg() + return ReportCfg +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XRewardConfigs.lua b/Resources/Scripts/XConfig/XRewardConfigs.lua new file mode 100644 index 00000000..37274cd4 --- /dev/null +++ b/Resources/Scripts/XConfig/XRewardConfigs.lua @@ -0,0 +1,20 @@ +XRewardConfigs = XRewardConfigs or {} + +local TABLE_REWARD_CONFIRM = "Client/Reward/RewardConfirm.tab" + +local RewardConfirmTemplates + +function XRewardConfigs.Init() + RewardConfirmTemplates = XTableManager.ReadByIntKey(TABLE_REWARD_CONFIRM, XTable.XTableRewardConfirm, "Id") +end + +function XRewardConfigs.IsRewardNeedConfirm(Id) + return RewardConfirmTemplates[Id] ~= nil +end + +function XRewardConfigs.GetRewardConfirmTemplate(Id) + local template = RewardConfirmTemplates[Id] + if template then + return RewardConfirmTemplates[Id] + end +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XRoomCharFilterTipsConfigs.lua b/Resources/Scripts/XConfig/XRoomCharFilterTipsConfigs.lua new file mode 100644 index 00000000..4b6edab4 --- /dev/null +++ b/Resources/Scripts/XConfig/XRoomCharFilterTipsConfigs.lua @@ -0,0 +1,216 @@ +XRoomCharFilterTipsConfigs = XRoomCharFilterTipsConfigs or {} + +local TABLE_CHARACTER_FILTER = "Client/Character/CharacterFilter.tab" +local TABLE_CHARACTER_FILTER_TAG_GROUP = "Client/Character/CharacterFilterTagGroup.tab" +local TABLE_CHARACTER_FILTER_TAG = "Client/Character/CharacterFilterTag.tab" + +local TABLE_CHARACTER_SORT = "Client/Character/CharacterSort.tab" +local TABLE_CHARACTER_SORT_TAG = "Client/Character/CharacterSortTag.tab" + + +local CharacterFilterConfig -- 筛选配置项,包含标签组 +local CharacterFilterTagGroupConfig -- 筛选标签组,包含标签 +local CharacterFilterTagConfig -- 筛选标签 + +local CharacterSortConfig -- 排序组,包含标签 +local CharacterSortTagConfig -- 排序标签 + +XRoomCharFilterTipsConfigs.DEFAULT_SORT_TAG_INDEX = 1 + +--- +--- 筛选配置,对应CharacterFilter.tab中的Id +XRoomCharFilterTipsConfigs.EnumFilterType = { + Common = 1, -- 通用 + BabelTower = 2, -- 巴别塔 + Bfrt = 3, -- 据点占领 + Assign = 4, -- 边界公约 + RogueLike = 5, -- 爬塔 + SuperTower = 6, -- 超级爬塔 +} + +--- +--- 筛选组,对应CharacterFilterTagGroup.tab中的Id +XRoomCharFilterTipsConfigs.EnumFilterTagGroup = { + Career = 1, -- 职业 + Element = 2, -- 能量 +} + +--- +--- 排序配置,对应CharacterSort.tab中的Id +XRoomCharFilterTipsConfigs.EnumSortType = { + Common = 1, -- 通用 + BabelTower = 2, -- 巴别塔 + Bfrt = 3, -- 据点占领 + Assign = 4, -- 边界公约 + RogueLike = 5, -- 爬塔 + SuperTower = 6, -- 超级爬塔 +} + +--- +--- 排序标签,对应CharacterSortTag.tab中的Id +XRoomCharFilterTipsConfigs.EnumSortTag = { + Default = 1, -- 默认 + Level = 2, -- 等级 + Quality = 3, -- 阶级 + Ability = 4, -- 战力 + SuperLevel = 5, -- 超限等级,超级爬塔活动 +} + +function XRoomCharFilterTipsConfigs.Init() + CharacterFilterConfig = XTableManager.ReadByIntKey(TABLE_CHARACTER_FILTER, XTable.XTableCharacterFilter, "Id") + CharacterFilterTagGroupConfig = XTableManager.ReadByIntKey(TABLE_CHARACTER_FILTER_TAG_GROUP, XTable.XTableCharacterFilterTagGroup, "Id") + CharacterFilterTagConfig = XTableManager.ReadByIntKey(TABLE_CHARACTER_FILTER_TAG, XTable.XTableCharacterFilterTag, "Id") + + CharacterSortConfig = XTableManager.ReadByIntKey(TABLE_CHARACTER_SORT, XTable.XTableCharacterSort, "Id") + CharacterSortTagConfig = XTableManager.ReadByIntKey(TABLE_CHARACTER_SORT_TAG, XTable.XTableCharacterSortTag, "Id") +end + + +------------------------------------------------------------------ 内部接口 ------------------------------------------------------- + +local GetCharacterFilterCfg = function(id) + local config = CharacterFilterConfig[id] + + if not config then + XLog.ErrorTableDataNotFound("XRoomCharFilterTipsConfigs.GetCharacterFilterCfg", + "编队角色筛选", TABLE_CHARACTER_FILTER, "Id", tostring(id)) + return {} + end + + return config +end + +local GetCharacterFilterTagGroupCfg = function(id) + local config = CharacterFilterTagGroupConfig[id] + + if not config then + XLog.ErrorTableDataNotFound("XRoomCharFilterTipsConfigs.GetCharacterFilterTagGroupCfg", + "编队角色筛选组", TABLE_CHARACTER_FILTER_TAG_GROUP, "Id", tostring(id)) + return {} + end + + return config +end + +local GetCharacterFilterTagCfg = function(id) + local config = CharacterFilterTagConfig[id] + + if not config then + XLog.ErrorTableDataNotFound("XRoomCharFilterTipsConfigs.GetCharacterFilterTagCfg", + "编队角色筛选标签", TABLE_CHARACTER_FILTER_TAG, "Id", tostring(id)) + return {} + end + + return config +end + +local GetCharacterSortCfg = function(id) + local config = CharacterSortConfig[id] + + if not config then + XLog.ErrorTableDataNotFound("XRoomCharFilterTipsConfigs.GetCharacterSortCfg", + "编队角色排序", TABLE_CHARACTER_SORT, "Id", tostring(id)) + return {} + end + + return config +end + +local GetCharacterSortTagCfg = function(id) + local config = CharacterSortTagConfig[id] + + if not config then + XLog.ErrorTableDataNotFound("XRoomCharFilterTipsConfigs.GetCharacterSortTagCfg", + "编队角色排序标签", TABLE_CHARACTER_SORT_TAG, "Id", tostring(id)) + return {} + end + + return config +end + + +------------------------------------------------------------------ CharacterFilter.tab ------------------------------------------------------- + +--- +--- 根据'id'获取筛选配置的筛选组 +---@return table +function XRoomCharFilterTipsConfigs.GetFilterTagGroups(id) + local cfg = GetCharacterFilterCfg(id) + return cfg.TagGroups +end + + +------------------------------------------------------------------ CharacterFilterTagGroup.tab ------------------------------------------------------- + +--- +--- 根据'id'获取筛选组的名称 +---@return string +function XRoomCharFilterTipsConfigs.GetFilterTagGroupName(id) + local cfg = GetCharacterFilterTagGroupCfg(id) + return cfg.GroupName +end + +--- +--- 根据'id'获取筛选组包含的筛选标签 +---@return table +function XRoomCharFilterTipsConfigs.GetFilterTagGroupTags(id) + local cfg = GetCharacterFilterTagGroupCfg(id) + return cfg.Tags +end + + +------------------------------------------------------------------ CharacterFilterTag.tab ------------------------------------------------------- + +--- +--- 根据'id'获取筛选标签的名称 +---@return string +function XRoomCharFilterTipsConfigs.GetFilterTagName(id) + local cfg = GetCharacterFilterTagCfg(id) + return cfg.TagName +end + +--- +--- 根据'id'获取筛选标签的角色类型,0通用、1构造体、2授格者 +---@return number +function XRoomCharFilterTipsConfigs.GetFilterTagCharType(id) + local cfg = GetCharacterFilterTagCfg(id) + return cfg.CharacterType +end + +--- +--- 根据'id'获取筛选标签所代表的值 +---@return number +function XRoomCharFilterTipsConfigs.GetFilterTagValue(id) + local cfg = GetCharacterFilterTagCfg(id) + return cfg.Value +end + + +------------------------------------------------------------------ CharacterSort.tab ------------------------------------------------------- + +--- +--- 根据'id'获取排序配置包含的标签 +---@return table +function XRoomCharFilterTipsConfigs.GetCharacterSortTags(id) + local cfg = GetCharacterSortCfg(id) + return cfg.Tags +end + + +------------------------------------------------------------------ CharacterSortTag.tab ------------------------------------------------------- + +--- +--- 根据'id'获取排序标签的名称 +---@return string +function XRoomCharFilterTipsConfigs.GetCharacterSortTagName(id) + local cfg = GetCharacterSortTagCfg(id) + return cfg.TagName +end + +--- +--- 根据'id'获取排序标签的角色类型,0通用、1构造体、2授格者 +---@return number +function XRoomCharFilterTipsConfigs.GetCharacterSortTagCharType(id) + local cfg = GetCharacterSortTagCfg(id) + return cfg.CharacterType +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XRpgMakerGameConfigs.lua b/Resources/Scripts/XConfig/XRpgMakerGameConfigs.lua new file mode 100644 index 00000000..6ab8fb54 --- /dev/null +++ b/Resources/Scripts/XConfig/XRpgMakerGameConfigs.lua @@ -0,0 +1,1199 @@ +local tableInsert = table.insert +local tableSort = table.sort +local ipairs = ipairs +local pairs = pairs +local stringGsub = string.gsub +local CSXTextManagerGetText = CS.XTextManager.GetText + +local TABLE_CHAPTER_PATH = "Share/MiniActivity/RpgMakerGame/RpgMakerGameChapter.tab" +local TABLE_STAGE_PATH = "Share/MiniActivity/RpgMakerGame/RpgMakerGameStage.tab" +local TABLE_STAR_CONDITION_PATH = "Share/MiniActivity/RpgMakerGame/RpgMakerGameStarCondition.tab" +local TABLE_ROLE_PATH = "Share/MiniActivity/RpgMakerGame/RpgMakerGameRole.tab" +local TABLE_MAP_PATH = "Share/MiniActivity/RpgMakerGame/RpgMakerGameMap.tab" -- +local TABLE_START_POINT_PATH = "Share/MiniActivity/RpgMakerGame/RpgMakerGameStartPoint.tab" +local TABLE_END_POINT_PATH = "Share/MiniActivity/RpgMakerGame/RpgMakerGameEndPoint.tab" +local TABLE_BLOCK_PATH = "Share/MiniActivity/RpgMakerGame/RpgMakerGameBlock.tab" +local TABLE_GAP_PATH = "Share/MiniActivity/RpgMakerGame/RpgMakerGameGap.tab" +local TABLE_MONSTER_PATH = "Share/MiniActivity/RpgMakerGame/RpgMakerGameMonster.tab" +local TABLE_TRIGGER_PATH = "Share/MiniActivity/RpgMakerGame/RpgMakerGameTrigger.tab" +local TABLE_ACTIVITY_PATH = "Share/MiniActivity/RpgMakerGame/RpgMakerGameActivity.tab" +local TABLE_HINT_PATH = "Client/MiniActivity/RpgMakerGame/RpgMakerGameHint.tab" +local TABLE_HINT_ICON_PATH = "Client/MiniActivity/RpgMakerGame/RpgMakerGameHintIcon.tab" +local TABLE_RANDOM_DIALOG_BOX_PATH = "Client/MiniActivity/RpgMakerGame/RpgMakerGameRandomDialogBox.tab" +local TABLE_HINT_DIALOG_BOX_PATH = "Client/MiniActivity/RpgMakerGame/RpgMakerGameHintDialogBox.tab" +local TABLE_MODEL_PATH = "Client/MiniActivity/RpgMakerGame/RpgMakerGameModel.tab" +local TABLE_ANIMATION_PATH = "Client/MiniActivity/RpgMakerGame/RpgMakerGameAnimation.tab" +local RpgMakerGameChapterConfigs = {} +local RpgMakerGameStageConfigs = {} +local RpgMakerGameStarConditionConfigs = {} +local RpgMakerGameRoleConfigs = {} +local RpgMakerGameMapConfigs = {} +local RpgMakerGameStartPointConfigs = {} +local RpgMakerGameEndPointConfigs = {} +local RpgMakerGameBlockConfigs = {} +local RpgMakerGameGapConfigs = {} +local RpgMakerGameMonsterConfigs = {} +local RpgMakerGameTriggerConfigs = {} +local RpgMakerGameHintConfigs = {} +local RpgMakerGameHintIconConfigs = {} +local RpgMakerGameActivityConfigs = {} +local RpgMakerGameRandomDialogBoxConfigs = {} +local RpgMakerGameHintDialogBoxConfigs = {} +local RpgMakerGameModelConfigs = {} +local RpgMakerGameAnimationConfigs = {} + +local RpgMakerGameChapterIdList = {} +local RpgMakerGameChapterIdToStageIdListDic = {} +local RpgMakerGameStageIdToStarConditionIdListDic = {} +local RpgMakerGameRoleIdList = {} +local RpgMakerGameStageIdList = {} +local RpgMakerGameMapIdToBlockIdList = {} +local RpgMakerGameMapIdToGapIdList = {} +local RpgMakerGameMapIdToMonsterIdList = {} +local RpgMakerGameMapIdToTriggerIdList = {} +local RpgMakerGameMapIdToHintIdList = {} +local RpgMakerGameRandomDialogBoxIdList = {} + +local DefaultActivityId = 1 + +XRpgMakerGameConfigs = XRpgMakerGameConfigs or {} + +--关卡状态 +XRpgMakerGameConfigs.RpgMakerGameStageStatus = { + Lock = 1, --未开启 + UnLock = 2, --已开启 + Clear = 3, --已通关 +} + +--方向 +XRpgMakerGameConfigs.RpgMakerGameMoveDirection = { + MoveLeft = 1, + MoveRight = 2, + MoveUp = 3, + MoveDown = 4, +} + +--行动类型 +XRpgMakerGameConfigs.RpgMakerGameActionType = { + ActionNone = 0, + ActionPlayerMove = 1, --玩家移动 + ActionKillMonster = 2, --杀死怪物 + ActionStageWin = 3, --关卡胜利 + ActionEndPointOpen = 4, --终点开启 + ActionMonsterRunAway = 5, --怪物逃跑 + ActionMonsterChangeDirection = 6, --怪物调整方向 + ActionMonsterKillPlayer = 7, --怪物杀死玩家 + ActionTriggerStatusChange = 8, --机关状态改变 + ActionMonsterPatrol = 9, --怪物巡逻 + ActionUnlockRole = 10, --解锁角色 + ActionMonsterPatrolLine = 11, --怪物巡逻路线 +} + +--缝隙类型 +XRpgMakerGameConfigs.RpgMakerGapDirection = { + GridLeft = 1, --格子左边线 + GridRight = 2, --格子右边线 + GridTop = 3, --格子顶部线 + GridBottom = 4, --格子底部线 +} + +--终点类型 +XRpgMakerGameConfigs.XRpgMakerGameEndPointType = { + DefaultClose = 0, --默认关闭 + DefaultOpen = 1, --默认开启 +} + +--阻挡状态 +XRpgMakerGameConfigs.XRpgMakerGameBlockStatus = { + UnBlock = 0, --不阻挡 + Block = 1, --阻挡 +} + +--怪物类型 +XRpgMakerGameConfigs.XRpgMakerGameMonsterType = { + Normal = 1, + BOSS = 2, +} + +--怪物攻击范围方向 +XRpgMakerGameConfigs.XRpgMakerGameMonsterViewAreaType = { + ViewFront = 1, --怪物的前方 + ViewBack = 2, --怪物的后面 + ViewLeft = 3, --怪物的左边 + ViewRight = 4, --怪物的右边 +} + +--机关类型 +XRpgMakerGameConfigs.XRpgMakerGameTriggerType = { + Trigger1 = 1, --本身是不能阻挡,可以触发类型2的机关状态转变 + Trigger2 = 2, --由类型1触发 + Trigger3 = 3, --玩家通过后,会从通过状态转变为阻挡状态 +} + +--一个关卡最多星星数 +XRpgMakerGameConfigs.MaxStarCount = 3 + +--延迟被攻击回调的时间 +XRpgMakerGameConfigs.BeAtkEffectDelayCallbackTime = CS.XGame.ClientConfig:GetInt("RpgMakerGamePlayBeAtkEffectDelayCallbackTime") + +local InitRpgMakerGameChapterIdList = function() + for id in pairs(RpgMakerGameChapterConfigs) do + tableInsert(RpgMakerGameChapterIdList, id) + end + + tableSort(RpgMakerGameChapterIdList, function(a, b) + return a < b + end) +end + +local InitRpgMakerGameChapterIdToStageIdListDic = function() + local chapterId + for _, v in pairs(RpgMakerGameStageConfigs) do + chapterId = v.ChapterId + if not RpgMakerGameChapterIdToStageIdListDic[chapterId] then + RpgMakerGameChapterIdToStageIdListDic[chapterId] = {} + end + tableInsert(RpgMakerGameChapterIdToStageIdListDic[chapterId], v.Id) + end + + for chapterId, stageIdList in pairs(RpgMakerGameChapterIdToStageIdListDic) do + tableSort(stageIdList, function(a, b) + return a < b + end) + end +end + +local InitRpgMakerGameStageIdToStarConditionIdListDic = function() + local stageId + for _, v in pairs(RpgMakerGameStarConditionConfigs) do + stageId = v.StageId + if not RpgMakerGameStageIdToStarConditionIdListDic[stageId] then + RpgMakerGameStageIdToStarConditionIdListDic[stageId] = {} + end + + tableInsert(RpgMakerGameStageIdToStarConditionIdListDic[stageId], v.Id) + end +end + +local InitRpgMakerGameRoleIdList = function() + local tempTable = {} + for _, v in pairs(RpgMakerGameRoleConfigs) do + tableInsert(tempTable, v) + end + tableSort(tempTable, function(a, b) + if a.RoleOrder ~= b.RoleOrder then + return a.RoleOrder < b.RoleOrder + end + return a.Id < b.Id + end) + + for _, v in ipairs(tempTable) do + tableInsert(RpgMakerGameRoleIdList, v.Id) + end +end + +local InitRpgMakerGameStageIdList = function() + for _, v in pairs(RpgMakerGameStageConfigs) do + tableInsert(RpgMakerGameStageIdList, v.Id) + end + tableSort(RpgMakerGameStageIdList, function(a, b) + return a < b + end) +end + +local InitRpgMakerGameMapIdToBlockIdList = function() + local mapId + for _, v in pairs(RpgMakerGameBlockConfigs) do + mapId = v.MapId + if not RpgMakerGameMapIdToBlockIdList[mapId] then + RpgMakerGameMapIdToBlockIdList[mapId] = {} + end + tableInsert(RpgMakerGameMapIdToBlockIdList[mapId], v.Id) + end +end + +local InitRpgMakerGameMapIdToGapIdList = function() + local mapId + for _, v in pairs(RpgMakerGameGapConfigs) do + mapId = v.MapId + if not RpgMakerGameMapIdToGapIdList[mapId] then + RpgMakerGameMapIdToGapIdList[mapId] = {} + end + tableInsert(RpgMakerGameMapIdToGapIdList[mapId], v.Id) + end +end + +local InitRpgMakerGameMapIdToMonsterIdList = function() + local mapId + for _, v in pairs(RpgMakerGameMonsterConfigs) do + mapId = v.MapId + if not RpgMakerGameMapIdToMonsterIdList[mapId] then + RpgMakerGameMapIdToMonsterIdList[mapId] = {} + end + tableInsert(RpgMakerGameMapIdToMonsterIdList[mapId], v.Id) + end +end + +local InitRpgMakerGameMapIdToTriggerIdList = function() + local mapId + for _, v in pairs(RpgMakerGameTriggerConfigs) do + mapId = v.MapId + if not RpgMakerGameMapIdToTriggerIdList[mapId] then + RpgMakerGameMapIdToTriggerIdList[mapId] = {} + end + tableInsert(RpgMakerGameMapIdToTriggerIdList[mapId], v.Id) + end +end + +local InitRpgMakerGameMapIdToHintIdList = function() + local mapId + for _, v in pairs(RpgMakerGameHintConfigs) do + mapId = v.MapId + if not RpgMakerGameMapIdToHintIdList[mapId] then + RpgMakerGameMapIdToHintIdList[mapId] = {} + end + tableInsert(RpgMakerGameMapIdToHintIdList[mapId], v.Id) + end +end + +local InitActivityConfig = function() + for activityId, config in pairs(RpgMakerGameActivityConfigs) do + if XTool.IsNumberValid(config.ActivityTimeId) then + DefaultActivityId = activityId + break + end + DefaultActivityId = activityId + end +end + +local InitRpgMakerGameRandomDialogBoxIdList = function() + for _, v in pairs(RpgMakerGameRandomDialogBoxConfigs) do + tableInsert(RpgMakerGameRandomDialogBoxIdList, v.Id) + end + tableSort(RpgMakerGameRandomDialogBoxIdList, function(a, b) + return a < b + end) +end + +function XRpgMakerGameConfigs.Init() + RpgMakerGameChapterConfigs = XTableManager.ReadByIntKey(TABLE_CHAPTER_PATH, XTable.XTableRpgMakerGameChapter, "Id") + RpgMakerGameStageConfigs = XTableManager.ReadByIntKey(TABLE_STAGE_PATH, XTable.XTableRpgMakerGameStage, "Id") + RpgMakerGameStarConditionConfigs = XTableManager.ReadByIntKey(TABLE_STAR_CONDITION_PATH, XTable.XTableRpgMakerGameStarCondition, "Id") + RpgMakerGameRoleConfigs = XTableManager.ReadByIntKey(TABLE_ROLE_PATH, XTable.XTableRpgMakerGameRole, "Id") + RpgMakerGameMapConfigs = XTableManager.ReadByIntKey(TABLE_MAP_PATH, XTable.XTableRpgMakerGameMap, "Id") + RpgMakerGameStartPointConfigs = XTableManager.ReadByIntKey(TABLE_START_POINT_PATH, XTable.XTableRpgMakerGameStartPoint, "Id") + RpgMakerGameEndPointConfigs = XTableManager.ReadByIntKey(TABLE_END_POINT_PATH, XTable.XTableRpgMakerGameEndPoint, "Id") + RpgMakerGameBlockConfigs = XTableManager.ReadByIntKey(TABLE_BLOCK_PATH, XTable.XTableRpgMakerGameBlock, "Id") + RpgMakerGameGapConfigs = XTableManager.ReadByIntKey(TABLE_GAP_PATH, XTable.XTableRpgMakerGameGap, "Id") + RpgMakerGameMonsterConfigs = XTableManager.ReadByIntKey(TABLE_MONSTER_PATH, XTable.XTableRpgMakerGameMonster, "Id") + RpgMakerGameTriggerConfigs = XTableManager.ReadByIntKey(TABLE_TRIGGER_PATH, XTable.XTableRpgMakerGameTrigger, "Id") + RpgMakerGameHintConfigs = XTableManager.ReadByIntKey(TABLE_HINT_PATH, XTable.XTableRpgMakerGameHint, "Id") + RpgMakerGameHintIconConfigs = XTableManager.ReadByStringKey(TABLE_HINT_ICON_PATH, XTable.XTableRpgMakerGameHintIcon, "Key") + RpgMakerGameActivityConfigs = XTableManager.ReadByIntKey(TABLE_ACTIVITY_PATH, XTable.XTableRpgMakerGameActivity, "Id") + RpgMakerGameRandomDialogBoxConfigs = XTableManager.ReadByIntKey(TABLE_RANDOM_DIALOG_BOX_PATH, XTable.XTableRpgMakerGameRandomDialogBox, "Id") + RpgMakerGameHintDialogBoxConfigs = XTableManager.ReadByIntKey(TABLE_HINT_DIALOG_BOX_PATH, XTable.XTableRpgMakerGameHintDialogBox, "StageId") + RpgMakerGameModelConfigs = XTableManager.ReadByStringKey(TABLE_MODEL_PATH, XTable.XTableRpgMakerGameModel, "Key") + RpgMakerGameAnimationConfigs = XTableManager.ReadByStringKey(TABLE_ANIMATION_PATH, XTable.XTableRpgMakerGameAnimation, "ModelName") + + InitRpgMakerGameChapterIdList() + InitRpgMakerGameChapterIdToStageIdListDic() + InitRpgMakerGameStageIdToStarConditionIdListDic() + InitRpgMakerGameRoleIdList() + InitRpgMakerGameStageIdList() + InitRpgMakerGameMapIdToBlockIdList() + InitRpgMakerGameMapIdToGapIdList() + InitRpgMakerGameMapIdToMonsterIdList() + InitRpgMakerGameMapIdToTriggerIdList() + InitRpgMakerGameMapIdToHintIdList() + InitActivityConfig() + InitRpgMakerGameRandomDialogBoxIdList() +end + +-----------------RpgMakerGameChapter begin-------------------- +local GetRpgMakerGameChapterConfig = function(id) + local config = RpgMakerGameChapterConfigs[id] + if not config then + XLog.ErrorTableDataNotFound("XRpgMakerGameConfigs.GetRpgMakerGameChapterConfig", "RpgMakerGameChapterCfg", TABLE_CHAPTER_PATH, "Id", tostring(id)) + return + end + return config +end + +function XRpgMakerGameConfigs.GetRpgMakerGameChapterIdList() + return RpgMakerGameChapterIdList +end + +function XRpgMakerGameConfigs.GetRpgMakerGameChapterId(index) + return RpgMakerGameChapterIdList[index] +end + +function XRpgMakerGameConfigs.GetRpgMakerGameChapterOpenTimeId(id) + local config = GetRpgMakerGameChapterConfig(id) + return config.OpenTimeId +end + +function XRpgMakerGameConfigs.GetRpgMakerGameChapterName(id) + local config = GetRpgMakerGameChapterConfig(id) + return config.Name +end + +function XRpgMakerGameConfigs.GetRpgMakerGameChapterTagBtnBG(id) + local config = GetRpgMakerGameChapterConfig(id) + return config.TagBtnBG +end + +function XRpgMakerGameConfigs.GetRpgMakerGameChapterPrefab(id) + local config = GetRpgMakerGameChapterConfig(id) + return config.Prefab +end + +function XRpgMakerGameConfigs.GetRpgMakerGameStageIdList(chapterId) + return RpgMakerGameChapterIdToStageIdListDic[chapterId] +end +-----------------RpgMakerGameChapter end-------------------- + +-----------------RpgMakerGameStage begin-------------------- +local GetRpgMakerGameStageConfig = function(id) + local config = RpgMakerGameStageConfigs[id] + if not config then + XLog.ErrorTableDataNotFound("XRpgMakerGameConfigs.GetRpgMakerGameStageConfig", "RpgMakerGameStageConfig", TABLE_STAGE_PATH, "Id", tostring(id)) + return + end + return config +end + +function XRpgMakerGameConfigs.GetRpgMakerGameStageChapterId(id) + local config = GetRpgMakerGameStageConfig(id) + return config.ChapterId +end + +function XRpgMakerGameConfigs.GetRpgMakerGameStagePreStage(id) + local config = GetRpgMakerGameStageConfig(id) + return config.PreStage +end + +function XRpgMakerGameConfigs.GetRpgMakerGameStageBG(id) + local config = GetRpgMakerGameStageConfig(id) + return config.BG +end + +function XRpgMakerGameConfigs.GetRpgMakerGameStagePrefab(id) + local config = GetRpgMakerGameStageConfig(id) + return config.Prefab +end + +function XRpgMakerGameConfigs.GetRpgMakerGameStarConditionIdList(stageId) + return RpgMakerGameStageIdToStarConditionIdListDic[stageId] +end + +function XRpgMakerGameConfigs.GetRpgMakerGameStageName(id) + local config = GetRpgMakerGameStageConfig(id) + return config.Name or "" +end + +function XRpgMakerGameConfigs.GetRpgMakerGameStageHint(id) + local config = GetRpgMakerGameStageConfig(id) + return config.StageHint or "" +end + +function XRpgMakerGameConfigs.GetRpgMakerGameAllStageIdList() + return RpgMakerGameStageIdList +end + +function XRpgMakerGameConfigs.GetRpgMakerGameNextStageId(currStageId) + local chapterId = XRpgMakerGameConfigs.GetRpgMakerGameStageChapterId(currStageId) + local stageIdList = XRpgMakerGameConfigs.GetRpgMakerGameStageIdList(chapterId) + local nextStageId = 0 + for i, stageId in ipairs(stageIdList or {}) do + if stageId == currStageId then + nextStageId = stageIdList[i + 1] or 0 + return nextStageId + end + end + + return nextStageId +end + +function XRpgMakerGameConfigs.GetRpgMakerGameStageLoseHintList(id) + local config = GetRpgMakerGameStageConfig(id) + return config.LoseHint or "" +end + +function XRpgMakerGameConfigs.GetRpgMakerGameNumberName(id) + local config = GetRpgMakerGameStageConfig(id) + return config.NumberName or "" +end +-----------------RpgMakerGameStage end-------------------- + +-----------------RpgMakerGameStarCondition 通关获得的星星条件 begin-------------------- +local GetRpgMakerGameStarConditionConfig = function(id) + local config = RpgMakerGameStarConditionConfigs[id] + if not config then + XLog.ErrorTableDataNotFound("XRpgMakerGameConfigs.GetRpgMakerGameStarConditionConfig", "RpgMakerGameStarConditionConfig", TABLE_STAR_CONDITION_PATH, "Id", tostring(id)) + return + end + return config +end + +function XRpgMakerGameConfigs.GetRpgMakerGameStarConditionStar(id) + local config = GetRpgMakerGameStarConditionConfig(id) + return config.Star +end + +function XRpgMakerGameConfigs.GetRpgMakerGameStarConditionStepCount(id) + local config = GetRpgMakerGameStarConditionConfig(id) + return config.StepCount +end + +function XRpgMakerGameConfigs.GetRpgMakerGameStarConditionMonsterCount(id) + local config = GetRpgMakerGameStarConditionConfig(id) + return config.MonsterCount +end + +function XRpgMakerGameConfigs.GetRpgMakerGameStarConditionMonsterBossCount(id) + local config = GetRpgMakerGameStarConditionConfig(id) + return config.MonsterBossCount or 0 +end + +function XRpgMakerGameConfigs.GetRpgMakerGameStarConditionDesc(id) + local config = GetRpgMakerGameStarConditionConfig(id) + return config.ConditionDesc +end + +function XRpgMakerGameConfigs.GetRpgMakerGameTotalStar(chapterId) + local stageIdList = XRpgMakerGameConfigs.GetRpgMakerGameStageIdList(chapterId) + local starConditionIdList + local totalStarCount = 0 + for _, stageId in ipairs(stageIdList) do + starConditionIdList = XRpgMakerGameConfigs.GetRpgMakerGameStarConditionIdList(stageId) + for _, starConditionId in ipairs(starConditionIdList) do + totalStarCount = totalStarCount + XRpgMakerGameConfigs.GetRpgMakerGameStarConditionStar(starConditionId) + end + end + return totalStarCount +end + +function XRpgMakerGameConfigs.GetRpgMakerGameStageTotalStar(stageId) + local starConditionIdList = XRpgMakerGameConfigs.GetRpgMakerGameStarConditionIdList(stageId) + local totalCount = 0 + for _, starConditionId in ipairs(starConditionIdList) do + totalCount = totalCount + XRpgMakerGameConfigs.GetRpgMakerGameStarConditionStar(starConditionId) + end + return totalCount +end +-----------------RpgMakerGameStarCondition 通关获得的星星条件 end---------------------- + +-----------------RpgMakerGameRole 角色列表 begin-------------------- +local GetRpgMakerGameRoleConfig = function(id) + local config = RpgMakerGameRoleConfigs[id] + if not config then + XLog.ErrorTableDataNotFound("XRpgMakerGameConfigs.GetRpgMakerGameRoleConfig", "RpgMakerGameRoleConfigs", TABLE_ROLE_PATH, "Id", tostring(id)) + return + end + return config +end + +function XRpgMakerGameConfigs.GetRpgMakerGameRoleIdList() + return RpgMakerGameRoleIdList +end + +function XRpgMakerGameConfigs.GetRpgMakerGameRoleUnlockChapterId(id) + local config = GetRpgMakerGameRoleConfig(id) + return config.UnlockChapterId +end + +function XRpgMakerGameConfigs.GetRpgMakerGameRoleName(id) + local config = GetRpgMakerGameRoleConfig(id) + return config.Name or "" +end + +function XRpgMakerGameConfigs.GetRpgMakerGameRoleStyle(id) + local config = GetRpgMakerGameRoleConfig(id) + return config.Style or "" +end + +function XRpgMakerGameConfigs.GetRpgMakerGameRoleModelAssetPath(id) + local config = GetRpgMakerGameRoleConfig(id) + return config.ModelAssetPath +end + +function XRpgMakerGameConfigs.GetRpgMakerGameRoleInfoName(id) + local config = GetRpgMakerGameRoleConfig(id) + return config.InfoName or "" +end + +function XRpgMakerGameConfigs.GetRpgMakerGameRoleInfo(id) + local config = GetRpgMakerGameRoleConfig(id) + return config.Info or "" +end + +function XRpgMakerGameConfigs.GetRpgMakerGameRoleHeadPath(id) + local config = GetRpgMakerGameRoleConfig(id) + return config.HeadPath +end + +function XRpgMakerGameConfigs.GetRpgMakerGameRoleLockTipsDesc(id) + local config = GetRpgMakerGameRoleConfig(id) + return config.LockTipsDesc or "" +end + +--根据解锁的关卡id,返回对应的角色id列表 +function XRpgMakerGameConfigs.GetRpgMakerGameRoleIdListByUnlockChapterId(unlockChapterId) + local roleIdList = XRpgMakerGameConfigs.GetRpgMakerGameRoleIdList() + local unlockChapterIdCfg + local roleIdList = {} + for _, roleId in ipairs(roleIdList) do + unlockChapterIdCfg = XRpgMakerGameConfigs.GetRpgMakerGameRoleUnlockChapterId(roleId) + if unlockChapterIdCfg == unlockChapterId then + tableInsert(roleIdList, roleId) + end + end + return roleIdList +end +-----------------RpgMakerGameRole 角色列表 end-------------------- + +-----------------RpgMakerGameMap 地图 begin----------------------- +local GetRpgMakerGameMapConfigs = function(id) + local config = RpgMakerGameMapConfigs[id] + if not config then + XLog.ErrorTableDataNotFound("XRpgMakerGameConfigs.GetRpgMakerGameMapConfigs", "RpgMakerGameMapConfigs", TABLE_MAP_PATH, "Id", tostring(id)) + return + end + return config +end + +function XRpgMakerGameConfigs.GetRpgMakerGameMaxRound(id) + local config = GetRpgMakerGameMapConfigs(id) + return config.MaxRound +end + +function XRpgMakerGameConfigs.GetRpgMakerGameStartPointId(id) + local config = GetRpgMakerGameMapConfigs(id) + return config.StartPointId +end + +function XRpgMakerGameConfigs.GetRpgMakerGameEndPointId(id) + local config = GetRpgMakerGameMapConfigs(id) + return config.EndPointId +end + +function XRpgMakerGameConfigs.GetRpgMakerGamePrefab(id) + local config = GetRpgMakerGameMapConfigs(id) + return config.Prefab +end + +--行 +function XRpgMakerGameConfigs.GetRpgMakerGameRow(id) + local config = GetRpgMakerGameMapConfigs(id) + return config.Row +end + +--列 +function XRpgMakerGameConfigs.GetRpgMakerGameCol(id) + local config = GetRpgMakerGameMapConfigs(id) + return config.Col +end +-----------------RpgMakerGameMap 地图 end------------------------- + +-----------------RpgMakerGameStartPoint 玩家起点 begin----------------------- +local GetRpgMakerGameStartPointConfigs = function(id) + local config = RpgMakerGameStartPointConfigs[id] + if not config then + XLog.ErrorTableDataNotFound("XRpgMakerGameConfigs.GetRpgMakerGameStartPointConfigs", "RpgMakerGameStartPointConfigs", TABLE_START_POINT_PATH, "Id", tostring(id)) + return + end + return config +end + +function XRpgMakerGameConfigs.GetRpgMakerGameStartPointX(id) + local config = GetRpgMakerGameStartPointConfigs(id) + return config.X +end + +function XRpgMakerGameConfigs.GetRpgMakerGameStartPointY(id) + local config = GetRpgMakerGameStartPointConfigs(id) + return config.Y +end + +function XRpgMakerGameConfigs.GetRpgMakerGameStartPointDirection(id) + local config = GetRpgMakerGameStartPointConfigs(id) + return config.Direction +end + +function XRpgMakerGameConfigs.IsRpgMakerGameStartPoint(mapId, x, y) + local startPointId = XRpgMakerGameConfigs.GetRpgMakerGameStartPointId(mapId) + local startPointX = XRpgMakerGameConfigs.GetRpgMakerGameStartPointX(startPointId) + local startPointY = XRpgMakerGameConfigs.GetRpgMakerGameStartPointY(startPointId) + return startPointX == x and startPointY == y +end +-----------------RpgMakerGameStartPoint 玩家起点 end------------------------- + +-----------------RpgMakerGameEndPoint 终点 begin----------------------- +local GetRpgMakerGameEndPointConfigs = function(id) + local config = RpgMakerGameEndPointConfigs[id] + if not config then + XLog.ErrorTableDataNotFound("XRpgMakerGameConfigs.GetRpgMakerGameEndPointConfigs", "RpgMakerGameEndPointConfigs", TABLE_END_POINT_PATH, "Id", tostring(id)) + return + end + return config +end + +function XRpgMakerGameConfigs.GetRpgMakerGameEndPointX(id) + local config = GetRpgMakerGameEndPointConfigs(id) + return config.X +end + +function XRpgMakerGameConfigs.GetRpgMakerGameEndPointY(id) + local config = GetRpgMakerGameEndPointConfigs(id) + return config.Y +end + +function XRpgMakerGameConfigs.GetRpgMakerGameEndPointType(id) + local config = GetRpgMakerGameEndPointConfigs(id) + return config.Type +end + +function XRpgMakerGameConfigs.IsRpgMakerGameEndPoint(mapId, x, y) + local endPointId = XRpgMakerGameConfigs.GetRpgMakerGameEndPointId(mapId) + local endPointX = XRpgMakerGameConfigs.GetRpgMakerGameEndPointX(endPointId) + local endPointY = XRpgMakerGameConfigs.GetRpgMakerGameEndPointY(endPointId) + return endPointX == x and endPointY == y +end +-----------------RpgMakerGameEndPoint 终点 end------------------------- + +-----------------RpgMakerGameBlock 阻挡物 begin----------------------- +local GetRpgMakerGameBlockConfigs = function(id) + local config = RpgMakerGameBlockConfigs[id] + if not config then + XLog.ErrorTableDataNotFound("XRpgMakerGameConfigs.GetRpgMakerGameBlockConfigs", "RpgMakerGameBlockConfigs", TABLE_BLOCK_PATH, "Id", tostring(id)) + return + end + return config +end + +function XRpgMakerGameConfigs.GetRpgMakerGameBlockRow(id) + local config = GetRpgMakerGameBlockConfigs(id) + return config.Row +end + +function XRpgMakerGameConfigs.GetRpgMakerGameBlockColList(id) + local config = GetRpgMakerGameBlockConfigs(id) + return config.Col +end + +function XRpgMakerGameConfigs.GetRpgMakerGameMapIdToBlockIdList(mapId) + return RpgMakerGameMapIdToBlockIdList[mapId] or {} +end + +function XRpgMakerGameConfigs.IsRpgMakerGameHaveBlock(mapId) + local blockIdList = XRpgMakerGameConfigs.GetRpgMakerGameMapIdToBlockIdList(mapId) + local colList + for _, blockId in ipairs(blockIdList) do + colList = XRpgMakerGameConfigs.GetRpgMakerGameBlockColList(blockId) + for _, col in ipairs(colList) do + if not XTool.IsNumberValid(col) then + return true + end + end + end + return false +end +-----------------RpgMakerGameBlock 阻挡物 end------------------------- + +-----------------RpgMakerGameGap 墙 begin----------------------- +local GetRpgMakerGameGapConfigs = function(id) + local config = RpgMakerGameGapConfigs[id] + if not config then + XLog.ErrorTableDataNotFound("XRpgMakerGameConfigs.GetRpgMakerGameGapConfigs", "RpgMakerGameGapConfigs", TABLE_GAP_PATH, "Id", tostring(id)) + return + end + return config +end + +function XRpgMakerGameConfigs.GetRpgMakerGameGapX(id) + local config = GetRpgMakerGameGapConfigs(id) + return config.X +end + +function XRpgMakerGameConfigs.GetRpgMakerGameGapY(id) + local config = GetRpgMakerGameGapConfigs(id) + return config.Y +end + +function XRpgMakerGameConfigs.GetRpgMakerGameGapDirection(id) + local config = GetRpgMakerGameGapConfigs(id) + return config.Direction +end + +function XRpgMakerGameConfigs.GetRpgMakerGameMapIdToGapIdList(id) + return RpgMakerGameMapIdToGapIdList[id] or {} +end + +--获得相同x和y坐标的gapId列表 +function XRpgMakerGameConfigs.GetRpgMakerGameSameXYGapIdIdList(mapId, x, y) + local gapIdList = XRpgMakerGameConfigs.GetRpgMakerGameMapIdToGapIdList(mapId) + local gapX + local gapY + local sameXYGapIdList = {} + for _, gapId in ipairs(gapIdList) do + gapX = XRpgMakerGameConfigs.GetRpgMakerGameGapX(gapId) + gapY = XRpgMakerGameConfigs.GetRpgMakerGameGapY(gapId) + if gapX == x and gapY == y then + tableInsert(sameXYGapIdList, gapId) + end + end + return sameXYGapIdList +end +-----------------RpgMakerGameGap 墙 end------------------------- + +-----------------RpgMakerGameMonster 怪物 begin----------------------- +local GetRpgMakerGameMonsterConfigs = function(id) + local config = RpgMakerGameMonsterConfigs[id] + if not config then + XLog.ErrorTableDataNotFound("XRpgMakerGameConfigs.GetRpgMakerGameMonsterConfigs", "RpgMakerGameMonsterConfigs", TABLE_MONSTER_PATH, "Id", tostring(id)) + return + end + return config +end + +function XRpgMakerGameConfigs.GetRpgMakerGameMonsterType(id) + local config = GetRpgMakerGameMonsterConfigs(id) + return config.Type +end + +function XRpgMakerGameConfigs.GetRpgMakerGameMonsterX(id) + local config = GetRpgMakerGameMonsterConfigs(id) + return config.X +end + +function XRpgMakerGameConfigs.GetRpgMakerGameMonsterY(id) + local config = GetRpgMakerGameMonsterConfigs(id) + return config.Y +end + +function XRpgMakerGameConfigs.GetRpgMakerGameMonsterDirection(id) + local config = GetRpgMakerGameMonsterConfigs(id) + return config.Direction +end + +function XRpgMakerGameConfigs.GetRpgMakerGameMonsterViewFront(id) + local config = GetRpgMakerGameMonsterConfigs(id) + return config.ViewFront +end + +function XRpgMakerGameConfigs.GetRpgMakerGameMonsterViewBack(id) + local config = GetRpgMakerGameMonsterConfigs(id) + return config.ViewBack +end + +function XRpgMakerGameConfigs.GetRpgMakerGameMonsterViewLeft(id) + local config = GetRpgMakerGameMonsterConfigs(id) + return config.ViewLeft +end + +function XRpgMakerGameConfigs.GetRpgMakerGameMonsterViewRight(id) + local config = GetRpgMakerGameMonsterConfigs(id) + return config.ViewRight +end + +function XRpgMakerGameConfigs.GetRpgMakerGameMapIdToMonsterIdList(mapId) + return RpgMakerGameMapIdToMonsterIdList[mapId] or {} +end + +function XRpgMakerGameConfigs.GetRpgMakerGameMonsterPrefab(id) + local config = GetRpgMakerGameMonsterConfigs(id) + return config.Prefab +end + +function XRpgMakerGameConfigs.GetRpgMakerGameMonsterId(mapId, x, y) + local monsterIdList = XRpgMakerGameConfigs.GetRpgMakerGameMapIdToMonsterIdList(mapId) + local monsterX + local monsterY + for _, monsterId in ipairs(monsterIdList) do + monsterX = XRpgMakerGameConfigs.GetRpgMakerGameMonsterX(monsterId) + monsterY = XRpgMakerGameConfigs.GetRpgMakerGameMonsterY(monsterId) + if monsterX == x and monsterY == y then + return monsterId + end + end +end + +function XRpgMakerGameConfigs.GetRpgMakerGameMonsterPatrolIdList(id) + local config = GetRpgMakerGameMonsterConfigs(id) + return config.PatrolId +end + +function XRpgMakerGameConfigs.IsRpgMakerGameMonsterTriggerEnd(id) + local config = GetRpgMakerGameMonsterConfigs(id) + return XTool.IsNumberValid(config.TriggerEnd) +end + +function XRpgMakerGameConfigs.IsRpgMakerGameHaveMonster(mapId, monsterType) + local monsterIdList = XRpgMakerGameConfigs.GetRpgMakerGameMapIdToMonsterIdList(mapId) + local typeCfg + for _, monsterId in ipairs(monsterIdList) do + typeCfg = XRpgMakerGameConfigs.GetRpgMakerGameMonsterType(monsterId) + if typeCfg == monsterType then + return true + end + end + return false +end +-----------------RpgMakerGameMonster 怪物 end------------------------- + +-----------------RpgMakerGameTrigger 机关 begin----------------------- +local GetRpgMakerGameTriggerConfigs = function(id) + local config = RpgMakerGameTriggerConfigs[id] + if not config then + XLog.ErrorTableDataNotFound("XRpgMakerGameConfigs.GetRpgMakerGameTriggerConfigs", "RpgMakerGameTriggerConfigs", TABLE_TRIGGER_PATH, "Id", tostring(id)) + return + end + return config +end + +function XRpgMakerGameConfigs.GetRpgMakerGameTriggerX(id) + local config = GetRpgMakerGameTriggerConfigs(id) + return config.X +end + +function XRpgMakerGameConfigs.GetRpgMakerGameTriggerY(id) + local config = GetRpgMakerGameTriggerConfigs(id) + return config.Y +end + +function XRpgMakerGameConfigs.GetRpgMakerGameTriggerDefaultBlock(id) + local config = GetRpgMakerGameTriggerConfigs(id) + return config.DefaultBlock +end + +function XRpgMakerGameConfigs.GetRpgMakerGameTriggerType(id) + local config = GetRpgMakerGameTriggerConfigs(id) + return config.Type +end + +function XRpgMakerGameConfigs.GetRpgMakerGameMapIdToTriggerIdList(mapId) + return RpgMakerGameMapIdToTriggerIdList[mapId] or {} +end + +function XRpgMakerGameConfigs.GetRpgMakerGameTriggerId(mapId, x, y) + local triggerIdList = XRpgMakerGameConfigs.GetRpgMakerGameMapIdToTriggerIdList(mapId) + local triggerX + local triggerY + for _, triggerId in ipairs(triggerIdList) do + triggerX = XRpgMakerGameConfigs.GetRpgMakerGameTriggerX(triggerId) + triggerY = XRpgMakerGameConfigs.GetRpgMakerGameTriggerY(triggerId) + if triggerX == x and triggerY == y then + return triggerId + end + end +end + +function XRpgMakerGameConfigs.IsRpgMakerGameHaveTrigger(mapId) + local isHaveType1Trigger, isHaveType2Trigger, isHaveType3Trigger + local triggerIdList = XRpgMakerGameConfigs.GetRpgMakerGameMapIdToTriggerIdList(mapId) + local typeCfg + for _, triggerId in ipairs(triggerIdList) do + typeCfg = XRpgMakerGameConfigs.GetRpgMakerGameTriggerType(triggerId) + if typeCfg == XRpgMakerGameConfigs.XRpgMakerGameTriggerType.Trigger1 then + isHaveType1Trigger = true + elseif typeCfg == XRpgMakerGameConfigs.XRpgMakerGameTriggerType.Trigger2 then + isHaveType2Trigger = true + elseif typeCfg == XRpgMakerGameConfigs.XRpgMakerGameTriggerType.Trigger3 then + isHaveType3Trigger = true + end + + if isHaveType1Trigger and isHaveType2Trigger and isHaveType3Trigger then + break + end + end + return isHaveType1Trigger, isHaveType2Trigger, isHaveType3Trigger +end +-----------------RpgMakerGameTrigger 机关 end------------------------- + +-----------------RpgMakerGameHint 通关提示 begin----------------------- +local GetRpgMakerGameHintConfig = function(id) + local config = RpgMakerGameHintConfigs[id] + if not config then + XLog.ErrorTableDataNotFound("XRpgMakerGameConfigs.GetRpgMakerGameHintConfigs", "RpgMakerGameHintConfigs", TABLE_HINT_PATH, "Id", tostring(id)) + return + end + return config +end + +function XRpgMakerGameConfigs.GetRpgMakerGameHintRow(id) + local config = GetRpgMakerGameHintConfig(id) + return config.Row +end + +function XRpgMakerGameConfigs.GetRpgMakerGameHintColList(id) + local config = GetRpgMakerGameHintConfig(id) + return config.Col +end + +function XRpgMakerGameConfigs.GetRpgMakerGameHintIdList(mapId) + return RpgMakerGameMapIdToHintIdList[mapId] +end + +function XRpgMakerGameConfigs.IsRpgMakerGameHintShowMoveLine(mapId, row, colIndex) + local hintIdList = XRpgMakerGameConfigs.GetRpgMakerGameHintIdList(mapId) + local rowCfg + local colList + for _, hintId in ipairs(hintIdList or {}) do + rowCfg = XRpgMakerGameConfigs.GetRpgMakerGameHintRow(hintId) + colList = XRpgMakerGameConfigs.GetRpgMakerGameHintColList(hintId) + if rowCfg == row then + return colList and XTool.IsNumberValid(colList[colIndex]) --不为0则显示移动路线图标 + end + end + return false +end +-----------------RpgMakerGameHint 通关提示 end------------------------- + +-----------------RpgMakerGameHintIcon 通关提示图标 begin----------------------- +local GetRpgMakerGameHintIconConfig = function(key) + local config = RpgMakerGameHintIconConfigs[key] + if not config then + XLog.ErrorTableDataNotFound("XRpgMakerGameConfigs.GetRpgMakerGameHintIconConfig", "RpgMakerGameHintIconConfigs", TABLE_HINT_ICON_PATH, "Key", key) + return + end + return config +end + +function XRpgMakerGameConfigs.GetRpgMakerGameHintIconKeyList() + local hintIconKeyList = {} + for k in pairs(RpgMakerGameHintIconConfigs) do + tableInsert(hintIconKeyList, k) + end + return hintIconKeyList +end + +--只获取该地图上有对应对象的图标 +function XRpgMakerGameConfigs.GetRpgMakerGameHintIconKeyListByMapId(mapId) + local hintIconKeyList = {} + if not XTool.IsNumberValid(mapId) then + return hintIconKeyList + end + + local isHaveBlock = XRpgMakerGameConfigs.IsRpgMakerGameHaveBlock(mapId) + local isHaveMonster = XRpgMakerGameConfigs.IsRpgMakerGameHaveMonster(mapId, XRpgMakerGameConfigs.XRpgMakerGameMonsterType.Normal) + local isHaveBoss = XRpgMakerGameConfigs.IsRpgMakerGameHaveMonster(mapId, XRpgMakerGameConfigs.XRpgMakerGameMonsterType.Boss) + local isHaveType1Trigger, isHaveType2Trigger, isHaveType3Trigger = XRpgMakerGameConfigs.IsRpgMakerGameHaveTrigger(mapId) + local isHaveGap = not XTool.IsTableEmpty(XRpgMakerGameConfigs.GetRpgMakerGameMapIdToGapIdList(mapId)) + + local isInsert = true + for k in pairs(RpgMakerGameHintIconConfigs) do + if k == "BlockIcon" then + isInsert = isHaveBlock + elseif k == "NormalMonsterIcon" then + isInsert = isHaveMonster + elseif k == "BossIcon" then + isInsert = isHaveBoss + elseif k == "TriggerIcon1" then + isInsert = isHaveType1Trigger + elseif k == "TriggerIcon2" then + isInsert = isHaveType2Trigger + elseif k == "TriggerIcon3" then + isInsert = isHaveType3Trigger + elseif k == "GapIcon" then + isInsert = isHaveGap + end + + if isInsert then + tableInsert(hintIconKeyList, k) + end + isInsert = true + end + return hintIconKeyList +end + +function XRpgMakerGameConfigs.GetRpgMakerGameHintIcon(key) + local config = GetRpgMakerGameHintIconConfig(key) + return config.Icon +end + +function XRpgMakerGameConfigs.GetRpgMakerGameHintIconName(key) + local config = GetRpgMakerGameHintIconConfig(key) + return config.Name +end + +function XRpgMakerGameConfigs.GetNormalMonsterIcon(monsterType) + if XRpgMakerGameConfigs.XRpgMakerGameMonsterType.BOSS == monsterType then + return XRpgMakerGameConfigs.GetRpgMakerGameHintIcon("BossIcon") + end + return XRpgMakerGameConfigs.GetRpgMakerGameHintIcon("NormalMonsterIcon") +end + +function XRpgMakerGameConfigs.GetTriggerIcon(triggerType) + if triggerType == XRpgMakerGameConfigs.XRpgMakerGameTriggerType.Trigger1 then + return XRpgMakerGameConfigs.GetRpgMakerGameHintIcon("TriggerIcon1") + end + + if triggerType == XRpgMakerGameConfigs.XRpgMakerGameTriggerType.Trigger2 then + return XRpgMakerGameConfigs.GetRpgMakerGameHintIcon("TriggerIcon2") + end + + return XRpgMakerGameConfigs.GetRpgMakerGameHintIcon("TriggerIcon3") +end +-----------------RpgMakerGameHintIcon 通关提示图标 end------------------------- + +-----------------RpgMakerGameActivity 活动相关 begin----------------------- +local GetRpgMakerGameActivityConfig = function(id) + local config = RpgMakerGameActivityConfigs[id] + if not config then + XLog.ErrorTableDataNotFound("XRpgMakerGameConfigs.GetRpgMakerGameActivityConfig", "RpgMakerGameActivityConfigs", TABLE_ACTIVITY_PATH, "Id", id) + return + end + return config +end + +function XRpgMakerGameConfigs.GetDefaultActivityId() + return DefaultActivityId +end + +function XRpgMakerGameConfigs.GetRpgMakerGameActivityTaskTimeLimitId(id) + local config = GetRpgMakerGameActivityConfig(id) + return config.TaskTimeLimitId +end + +function XRpgMakerGameConfigs.GetRpgMakerGameActivityTimeId(id) + local config = GetRpgMakerGameActivityConfig(id) + return config.TimeId +end +-----------------RpgMakerGameActivity 活动相关 end------------------------- + +-----------------RpgMakerGameRandomDialogBox 随机提示 begin----------------------- +local GetRpgMakerGameRandomDialogBoxConfigs = function(id) + local config = RpgMakerGameRandomDialogBoxConfigs[id] + if not config then + XLog.ErrorTableDataNotFound("XRpgMakerGameConfigs.GetRpgMakerGameRandomDialogBoxConfigs", "RpgMakerGameRandomDialogBoxConfigs", TABLE_RANDOM_DIALOG_BOX_PATH, "Id", id) + return + end + return config +end + +function XRpgMakerGameConfigs.GetRpgMakerGameRandomDialogBoxIdList() + return RpgMakerGameRandomDialogBoxIdList +end + +function XRpgMakerGameConfigs.GetRpgMakerGameRandomDialogBoxPreStage(id) + local config = GetRpgMakerGameRandomDialogBoxConfigs(id) + return config.PreStage +end + +function XRpgMakerGameConfigs.GetRpgMakerGameRandomDialogBoxText(id) + local config = GetRpgMakerGameRandomDialogBoxConfigs(id) + return config.Text or "" +end + +function XRpgMakerGameConfigs.GetRpgMakerGameRandomDialogBoxWeight(id) + local config = GetRpgMakerGameRandomDialogBoxConfigs(id) + return config.Weight +end + +function XRpgMakerGameConfigs.GetRpgMakerGameRandomDialogBoxDuration(id) + local config = GetRpgMakerGameRandomDialogBoxConfigs(id) + return config.Duration +end +-----------------RpgMakerGameRandomDialogBox 随机提示 end------------------------- + +-----------------RpgMakerGameHintDialogBox 点击头像提示 begin----------------------- +local GetRpgMakerGameHintDialogBoxConfigs = function(id) + local config = RpgMakerGameHintDialogBoxConfigs[id] + if not config then + XLog.ErrorTableDataNotFound("XRpgMakerGameConfigs.GetRpgMakerGameHintDialogBoxConfigs", "RpgMakerGameHintDialogBoxConfigs", TABLE_HINT_DIALOG_BOX_PATH, "Id", id) + return + end + return config +end + +function XRpgMakerGameConfigs.GetRpgMakerGameHintDialogBoxText(id) + local config = GetRpgMakerGameHintDialogBoxConfigs(id) + return config.Text or "" +end + +function XRpgMakerGameConfigs.GetRpgMakerGameHintDialogBoxBackCount(id) + local config = GetRpgMakerGameHintDialogBoxConfigs(id) + return config.BackCount +end +-----------------RpgMakerGameHintDialogBox 点击头像提示 end------------------------- + +-----------------RpgMakerGameModel 模型相关 begin----------------------- +local GetRpgMakerGameModelConfig = function(key) + local config = RpgMakerGameModelConfigs[key] + if not config then + XLog.ErrorTableDataNotFound("XRpgMakerGameConfigs.RpgMakerGameModelConfig", "RpgMakerGameModelConfigs", TABLE_MODEL_PATH, "Key", key) + return + end + return config +end + +function XRpgMakerGameConfigs.GetRpgMakerGameModelPath(key) + local config = GetRpgMakerGameModelConfig(key) + return config.ModelPath or "" +end + +function XRpgMakerGameConfigs.GetRpgMakerGameTriggerPath(triggerType) + if triggerType == XRpgMakerGameConfigs.XRpgMakerGameTriggerType.Trigger1 then + return XRpgMakerGameConfigs.GetRpgMakerGameModelPath("TriggerType1") + end + + if triggerType == XRpgMakerGameConfigs.XRpgMakerGameTriggerType.Trigger2 then + return XRpgMakerGameConfigs.GetRpgMakerGameModelPath("TriggerType2") + end + + if triggerType == XRpgMakerGameConfigs.XRpgMakerGameTriggerType.Trigger3 then + return XRpgMakerGameConfigs.GetRpgMakerGameModelPath("TriggerType3") + end +end +-----------------RpgMakerGameModel 模型相关 end----------------------- + +-----------------RpgMakerGameAnimation 动画相关 begin----------------------- +local GetRpgMakerGameAnimationConfig = function(modelName) + local config = RpgMakerGameAnimationConfigs[modelName] + if not config then + XLog.ErrorTableDataNotFound("XRpgMakerGameConfigs.RpgMakerGameAnimationConfig", "RpgMakerGameAnimationConfigs", TABLE_ANIMATION_PATH, "ModelName", modelName) + return + end + return config +end + +function XRpgMakerGameConfigs.GetRpgMakerGameStandAnimaName(modelName) + local config = GetRpgMakerGameAnimationConfig(modelName) + return config.StandAnimaName or "" +end + +function XRpgMakerGameConfigs.GetRpgMakerGameRunAnimaName(modelName) + local config = GetRpgMakerGameAnimationConfig(modelName) + return config.RunAnimaName or "" +end + +function XRpgMakerGameConfigs.GetRpgMakerGameAtkAnimaName(modelName) + local config = GetRpgMakerGameAnimationConfig(modelName) + return config.AtkAnimaName or "" +end + +function XRpgMakerGameConfigs.GetRpgMakerGameBeAtkEffectPath(modelName) + local config = GetRpgMakerGameAnimationConfig(modelName) + return config.BeAtkEffectPath or "" +end + +function XRpgMakerGameConfigs.GetRpgMakerGameEffectRoot(modelName) + local config = GetRpgMakerGameAnimationConfig(modelName) + return config.EffectRoot or "" +end + +function XRpgMakerGameConfigs.GetRpgMakerGameXOffSet(modelName) + local config = GetRpgMakerGameAnimationConfig(modelName) + return config.XOffSet or 0 +end + +function XRpgMakerGameConfigs.GetRpgMakerGameYOffSet(modelName) + local config = GetRpgMakerGameAnimationConfig(modelName) + return config.YOffSet or 0 +end + +function XRpgMakerGameConfigs.GetRpgMakerGameZOffSet(modelName) + local config = GetRpgMakerGameAnimationConfig(modelName) + return config.ZOffSet or 0 +end +-----------------RpgMakerGameAnimation 动画相关 end----------------------- \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XRpgTowerConfig.lua b/Resources/Scripts/XConfig/XRpgTowerConfig.lua new file mode 100644 index 00000000..f1e6c4be --- /dev/null +++ b/Resources/Scripts/XConfig/XRpgTowerConfig.lua @@ -0,0 +1,578 @@ +--玩法兵法蓝图配置类 +XRpgTowerConfig = XRpgTowerConfig or {} + +-- ===================表地址 +local SHARE_TABLE_PATH = "Share/Fuben/Rpg/" +local CLIENT_TABLE_PATH = "Client/Fuben/Rpg/" + +local TABLE_CHARACTER = SHARE_TABLE_PATH .. "RpgCharacter.tab" +local TABLE_CONFIG = SHARE_TABLE_PATH .. "RpgConfig.tab" +local TABLE_TALENT = SHARE_TABLE_PATH .. "RpgTalent.tab" +local TABLE_STAGE = SHARE_TABLE_PATH .. "RpgStage.tab" +local TABLE_TEAM_LEVEL = SHARE_TABLE_PATH .. "RpgTeamLevel.tab" +local TABLE_TALENT_LAYER = SHARE_TABLE_PATH .. "RpgTalentLayer.tab" +local TABLE_MONSTER = CLIENT_TABLE_PATH .. "RpgMonsters.tab" +local TABLE_BASE_CHARACTER = CLIENT_TABLE_PATH .. "RpgBaseCharacter.tab" +local TABLE_ITEM_CONFIG = CLIENT_TABLE_PATH .. "RpgItemConfig.tab" +-- ===================原表数据 +local RpgTowerConfig = {} +local RCharacterConfig = {} +local RCharaTalentConfig = {} +local RCharaTalentLayerConfig = {} +local RStageConfig = {} +local RMonsterConfig = {} +local RBaseCharacterConfig = {} +local RItemConfig = {} +local RTeamLevelConfig = {} +-- ===================构建搜索用字典 +local CharacterAndLevel2RCharacterDic = {} +local RCharacter2TalentDic = {} +local StageId2RStageCfgDic = {} +local ActivityId2RStageListDic = {} +local CharacterId2TalentsDic = {} + +-- ===================变量 +local TheLatestConfigIndex +local CharaMaxLevel = 1 +local TeamMaxLevel = 1 +--[[ +================ +获取最新的玩法基础配置ID +================ +]] +local GetLatestConfigId = function() + TheLatestConfigIndex = -1 + local now = XTime.GetServerNowTimestamp() + for id, config in pairs(RpgTowerConfig) do + local startTime = XFunctionManager.GetStartTimeByTimeId(config.TimeId) + local endTime = XFunctionManager.GetEndTimeByTimeId(config.TimeId) + if startTime <= now and now <= endTime then + TheLatestConfigIndex = id + break + end + end + if TheLatestConfigIndex == -1 then + local tempTime = 0 + local tempId = -1 + for id, config in pairs(RpgTowerConfig) do + local startTime = XFunctionManager.GetStartTimeByTimeId(config.TimeId) + if startTime > now then + local delta = startTime - now + if tempTime == 0 or tempTime > delta then + tempTime = delta + tempId = id + end + end + end + if tempId ~= -1 then + TheLatestConfigIndex = tempId + else + tempTime = 0 + for id, config in pairs(RpgTowerConfig) do + local endTime = XFunctionManager.GetEndTimeByTimeId(config.TimeId) + if endTime < now then + local delta = now - endTime + if tempTime == 0 or tempTime > delta then + tempTime = delta + tempId = id + end + end + end + if tempId ~= -1 then + TheLatestConfigIndex = tempId + else + TheLatestConfigIndex = 1 + end + end + end +end +--=============== +--获取满级级数 +--=============== +local GetTeamMaxLevel = function() + local maxLevel = 0 + for _, _ in pairs(RTeamLevelConfig) do + maxLevel = maxLevel + 1 + end + TeamMaxLevel = maxLevel +end +--[[ +================ +初始化玩法基础配置 +================ +]] +local InitConfig = function() + RpgTowerConfig = XTableManager.ReadByIntKey(TABLE_CONFIG, XTable.XTableRpgConfig, "Id") + RTeamLevelConfig = XTableManager.ReadByIntKey(TABLE_TEAM_LEVEL, XTable.XTableRpgTeamLevel, "Level") + RCharaTalentLayerConfig = XTableManager.ReadByIntKey(TABLE_TALENT_LAYER, XTable.XTableRpgTalentLayer, "LayerId") + GetTeamMaxLevel() +end + +--[[ +================ +构建字典:角色ID+等级搜索玩法角色 +================ +]] +local CreateCharaAndLevel2RCharaDic = function() + for _, rCharaCfg in pairs(RCharacterConfig) do + if not CharacterAndLevel2RCharacterDic[rCharaCfg.CharacterId] then + CharacterAndLevel2RCharacterDic[rCharaCfg.CharacterId] = {} + end + CharacterAndLevel2RCharacterDic[rCharaCfg.CharacterId][rCharaCfg.Level] = rCharaCfg + if rCharaCfg.Level > CharaMaxLevel then CharaMaxLevel = rCharaCfg.Level end + end +end + +--[[ +================ +初始化角色配置表 +================ +]] +local InitCharacterConfig = function() + RCharacterConfig = XTableManager.ReadByIntKey(TABLE_CHARACTER, XTable.XTableRpgCharacter, "Id") + RBaseCharacterConfig = XTableManager.ReadByIntKey(TABLE_BASE_CHARACTER, XTable.XTableRpgBaseCharacter, "Id") + CreateCharaAndLevel2RCharaDic() +end + +--[[ +================ +构建字典:StageId转到RStage +================ +]] +local CreateStageId2RStageCfgDic = function() + for _, rStageCfg in pairs(RStageConfig) do + if not StageId2RStageCfgDic[rStageCfg.StageId] then + StageId2RStageCfgDic[rStageCfg.StageId] = rStageCfg + end + end +end + +--[[ +================ +构建字典:ActivityId检索对应RStage列表 +================ +]] +local CreateActivityId2RStageListDic = function() + for _, rStageCfg in pairs(RStageConfig) do + if not ActivityId2RStageListDic[rStageCfg.ActivityId] then + ActivityId2RStageListDic[rStageCfg.ActivityId] = {} + end + ActivityId2RStageListDic[rStageCfg.ActivityId][rStageCfg.OrderId] = rStageCfg + end +end +--[[ +================ +初始化玩法关卡表 +================ +]] +local InitStageConfig = function() + RStageConfig = XTableManager.ReadByIntKey(TABLE_STAGE, XTable.XTableRpgStage, "Id") + CreateStageId2RStageCfgDic() + CreateActivityId2RStageListDic() +end +--[[ +================ +初始化怪物数据表 +================ +]] +local InitMonsterConfig = function() + RMonsterConfig = XTableManager.ReadByIntKey(TABLE_MONSTER, XTable.XTableRpgMonsters, "Id") +end +--[[ +================ +构建角色ID映射对应角色天赋列表字典 +================ +]] +local CreateCharacterId2TalentsDic = function() + for _, talentCfg in pairs(RCharaTalentConfig) do + if not CharacterId2TalentsDic[talentCfg.CharacterId] then + CharacterId2TalentsDic[talentCfg.CharacterId] = {} + end + if not CharacterId2TalentsDic[talentCfg.CharacterId][talentCfg.LayerId] then + CharacterId2TalentsDic[talentCfg.CharacterId][talentCfg.LayerId] = {} + end + table.insert(CharacterId2TalentsDic[talentCfg.CharacterId][talentCfg.LayerId], talentCfg) + end +end +--[[ +================ +初始化天赋数据表 +================ +]] +local InitTalentConfig = function() + RCharaTalentConfig = XTableManager.ReadByIntKey(TABLE_TALENT, XTable.XTableRpgTalent, "TalentId") + CreateCharacterId2TalentsDic() +end +--[[ +================ +初始化玩法道具表 +================ +]] +local InitItemConfig = function() + RItemConfig = XTableManager.ReadByIntKey(TABLE_ITEM_CONFIG, XTable.XTableRpgItemConfig, "Id") +end +--[[ +================ +初始化Config +================ +]] +function XRpgTowerConfig.Init() + InitConfig() + InitCharacterConfig() + InitStageConfig() + InitMonsterConfig() + InitTalentConfig() + InitItemConfig() +end + +--[[ +================ +获取开始时间最晚的玩法配置 +================ +]] +function XRpgTowerConfig.GetLatestConfig() + GetLatestConfigId() + if not RpgTowerConfig[TheLatestConfigIndex] then + XLog.Error(string.format("兵法蓝图玩法配置为空,请检查!%s", + TABLE_CONFIG)) + return + end + return RpgTowerConfig[TheLatestConfigIndex] +end + +--[[ +================ +获取指定ID的玩法配置 +@param id:兵法蓝图配置ID +================ +]] +function XRpgTowerConfig.GetRpgTowerConfigById(id) + if not RpgTowerConfig[id] then + XLog.ErrorTableDataNotFound( + "XRpgTowerConfig.GetRpgTowerConfigById", + "RpgConfig", + TABLE_CONFIG, + "Id", + tostring(id)) + return RpgTowerConfig[TheLatestConfigIndex] + end + return RpgTowerConfig[id] +end + +--[[ +================ +获取指定ID的玩法角色配置 +@param rCharaId:兵法蓝图角色ID +================ +]] +function XRpgTowerConfig.GetRCharacterCfgById(rCharaId) + if not RCharacterConfig[rCharaId] then + XLog.ErrorTableDataNotFound( + "XRpgTowerConfig.GetRCharacterCfgById", + "RCharacter", + TABLE_CHARACTER, + "Id", + tostring(rCharaId)) + return nil + end + return RCharacterConfig[rCharaId] +end + +--[[ +================ +获取指定角色ID和星级的玩法角色配置 +@param characterId:角色ID +@param level:角色玩法内的星级 +================ +]] +function XRpgTowerConfig.GetRCharacterCfgByCharacterIdAndLevel(characterId, level) + if not CharacterAndLevel2RCharacterDic[characterId] then + XLog.Error(string.format("要查找的角色ID没有对应的兵法蓝图角色,请检查%s, 角色ID为%d", + TABLE_CHARACTER, + characterId)) + return nil + elseif not CharacterAndLevel2RCharacterDic[characterId][level] then + XLog.Error(string.format("查找的兵法蓝图角色没有对应等级配置,请检查%s, 角色ID为%d, 等级为%d", + TABLE_CHARACTER, + characterId, + level)) + return nil + end + return CharacterAndLevel2RCharacterDic[characterId][level] +end + +--[[ +================ +获取角色最大星级数 +================ +]] +function XRpgTowerConfig.GetCharaMaxLevel() + return CharaMaxLevel +end + +--[[ +================ +获取配置内所有关卡列表 +================ +]] +function XRpgTowerConfig.GetRStageList() + return RStageConfig +end +--[[ +================ +通过活动ID获取活动所属所有关卡列表 +================ +]] +function XRpgTowerConfig.GetRStageListByActivityId(activityId) + if not ActivityId2RStageListDic[activityId] then + XLog.Error(string.format("兵法蓝图关卡表并不存在属于给定的活动ID的数据,请检查!表地址:%s, ActivityId:%s", + TABLE_STAGE, + tostring(activityId))) + return nil + end + return ActivityId2RStageListDic[activityId] +end +--[[ +================ +获取指定关卡ID的玩法关卡配置 +@param rStageId:兵法蓝图关卡ID +================ +]] +function XRpgTowerConfig.GetRStageCfgById(rStageId) + if not RStageConfig[rStageId] then + XLog.ErrorTableDataNotFound( + "XRpgTowerConfig.GetRStageCfgById", + "兵法蓝图关卡", + TABLE_STAGE, + "Id", + tostring(rStageId) + ) + return nil + end + return RStageConfig[rStageId] +end + +--[[ +================ +使用关卡ID查找相应的兵法蓝图关卡配置 +@param stageId:关卡ID +================ +]] +function XRpgTowerConfig.GetRStageCfgByStageId(stageId) + if not StageId2RStageCfgDic[stageId] then + XLog.Error( + string.format("指定关卡ID不在兵法蓝图关卡表中!请检查!表地址:%s,StageId:%s", + TABLE_STAGE, + tostring(stageId)) + ) + return nil + end + return StageId2RStageCfgDic[stageId] +end + +--[[ +================ +使用关卡ID查找相应的兵法蓝图关卡Id +@param stageId:关卡ID +================ +]] +function XRpgTowerConfig.GetRStageIdByStageId(stageId) + if not StageId2RStageCfgDic[stageId] then + XLog.Error( + string.format("指定关卡ID不在兵法蓝图关卡表中!请检查!表地址:%s,StageId:%s", + TABLE_STAGE, + tostring(stageId)) + ) + return nil + end + return StageId2RStageCfgDic[stageId].Id +end + +--[[ +================ +使用玩法怪物ID查找兵法蓝图玩法怪物配置 +@param rMonsterId:玩法怪物ID +================ +]] +function XRpgTowerConfig.GetRMonsterCfgById(rMonsterId) + if not RMonsterConfig[rMonsterId] then + XLog.ErrorTableDataNotFound( + "XRpgTowerConfig.GetRMonsterCfgById", + "兵法蓝图怪物数据", + TABLE_MONSTER, + "Id", + tostring(rMonsterId) + ) + return nil + end + return RMonsterConfig[rMonsterId] +end +--[[ +================ +使用玩法怪物ID查找MonsterNpcDataId +@param rMonsterId:玩法怪物ID +================ +]] +function XRpgTowerConfig.GetMonsterNpcDataIdByRMonsterId(rMonsterId) + if not RMonsterConfig[rMonsterId] then + XLog.ErrorTableDataNotFound( + "XRpgTowerConfig.GetMonsterNpcDataIdByRMonsterId", + "兵法蓝图怪物数据", + TABLE_MONSTER, + "Id", + tostring(rMonsterId) + ) + return nil + end + return RMonsterConfig[rMonsterId].MonsterNpcDataId +end + +--[[ +================ +使用玩法怪物ID查找配置字段IsBoss +@param rMonsterId:玩法怪物ID +================ +]] +function XRpgTowerConfig.GetMonsterIsBossByRMonsterId(rMonsterId) + if not rMonsterId then return false end + if not RMonsterConfig[rMonsterId] then + XLog.ErrorTableDataNotFound( + "XRpgTowerConfig.GetMonsterIsBossByRMonsterId", + "兵法蓝图怪物数据", + TABLE_MONSTER, + "Id", + tostring(rMonsterId) + ) + return nil + end + return RMonsterConfig[rMonsterId].IsBoss == 1 +end + + +--[[ +================ +使用角色ID查找玩法角色基础配置 +@param characterId:角色Id +================ +]] +function XRpgTowerConfig.GetRBaseCharaCfgByCharacterId(characterId) + if not RBaseCharacterConfig[characterId] then + XLog.ErrorTableDataNotFound( + "XRpgTowerConfig.GetRBaseCharaCfgByCharacterId", + "兵法蓝图Base角色数据", + TABLE_BASE_CHARACTER, + "Id", + tostring(characterId) + ) + return nil + end + return RBaseCharacterConfig[characterId] +end + +--[[ +================ +使用天赋ID查找天赋表配置 +@param talentId:天赋表talentId +================ +]] +function XRpgTowerConfig.GetTalentCfgById(talentId) + if not RCharaTalentConfig[talentId] then + XLog.ErrorTableDataNotFound( + "XRpgTowerConfig.GetTalentCfgById", + "兵法蓝图角色天赋数据", + TABLE_TALENT, + "talentId", + tostring(talentId) + ) + return nil + end + return RCharaTalentConfig[talentId] +end + +--[[ +================ +使用角色ID查找对应的天赋列表 +@param characterId:角色ID +================ +]] +function XRpgTowerConfig.GetTalentCfgsByCharacterId(characterId) + if not CharacterId2TalentsDic[characterId] then + XLog.ErrorTableDataNotFound( + "XRpgTowerConfig.GetTalentCfgsByCharacterId", + "兵法蓝图角色天赋数据", + TABLE_TALENT, + "CharacterId", + tostring(characterId) + ) + return nil + end + return CharacterId2TalentsDic[characterId] +end +--[[ +================ +使用天赋位置ID查找对应的天赋前置位置列表 +@param posId:位置ID +================ +]] +function XRpgTowerConfig.GetTalentByCharaIdAndLayerId(charaId, layerId) + local charaTalents = CharacterId2TalentsDic[charaId] + if charaTalents then + return CharacterId2TalentsDic[charaId][layerId] + end + return nil +end +--[[ +================ +使用玩法道具ID查找道具配置 +@param rItemId:玩法道具ID +================ +]] +function XRpgTowerConfig.GetRItemConfigByRItemId(rItemId) + if not RItemConfig[rItemId] then + XLog.ErrorTableDataNotFound( + "XRpgTowerConfig.GetRItemConfigByRItemId", + "兵法蓝图道具数据", + TABLE_ITEM_CONFIG, + "Id", + tostring(rItemId) + ) + return nil + end + return RItemConfig[rItemId] +end +--================= +--获取最高等级 +--================= +function XRpgTowerConfig.GetTeamMaxLevel() + return TeamMaxLevel +end +--================= +--根据等级获取队伍等级配置 +--@param level:队伍等级 +--================= +function XRpgTowerConfig.GetTeamLevelCfgByLevel(level) + if not RTeamLevelConfig[level] then + XLog.ErrorTableDataNotFound( + "XRpgTowerConfig.GetTeamLevelCfgByLevel", + "Rpg玩法队伍等级", + TABLE_TEAM_LEVEL, + "Level", + tostring(level) + ) + return nil + end + return RTeamLevelConfig[level] +end +--================= +--获取所有天赋等级配置 +--================= +function XRpgTowerConfig.GetAllTalentLayerCfgs() + return RCharaTalentLayerConfig +end +--================= +--根据等级获取天赋配置 +--@param level:天赋等级 +--================= +function XRpgTowerConfig.GetTalentLayerCfgByLayerId(layerId) + return RCharaTalentLayerConfig[layerId] +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XSceneModelConfigs.lua b/Resources/Scripts/XConfig/XSceneModelConfigs.lua new file mode 100644 index 00000000..c82755ef --- /dev/null +++ b/Resources/Scripts/XConfig/XSceneModelConfigs.lua @@ -0,0 +1,36 @@ +XSceneModelConfigs = XSceneModelConfigs or {} + +local TABLE_SCENEMODEL_PATH = "Client/SceneModel/SceneModel.tab" + +local SceneModelTemplates = {} + +function XSceneModelConfigs.Init() + SceneModelTemplates = XTableManager.ReadByIntKey(TABLE_SCENEMODEL_PATH, XTable.XTableSceneModel, "Id") +end + +function XSceneModelConfigs.GetSceneAndModelPathById(id) + if not SceneModelTemplates[id] then + XLog.Error("Not Find Scene and Model Define In Path:"..TABLE_SCENEMODEL_PATH, "Id:"..id) + return nil + end + + return SceneModelTemplates[id].ScenePath, SceneModelTemplates[id].ModelPath +end + +function XSceneModelConfigs.GetScenePathById(id) + if not SceneModelTemplates[id] then + XLog.Error("Not Find Scene and Model Define In Path:"..TABLE_SCENEMODEL_PATH, "Id:"..id) + return nil + end + + return SceneModelTemplates[id].ScenePath +end + +function XSceneModelConfigs.GetModelPathById(id) + if not SceneModelTemplates[id] then + XLog.Error("Not Find Scene and Model Define In Path:"..TABLE_SCENEMODEL_PATH, "Id:"..id) + return nil + end + + return SceneModelTemplates[id].ModelPath +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XScratchTicketConfig.lua b/Resources/Scripts/XConfig/XScratchTicketConfig.lua new file mode 100644 index 00000000..e976359e --- /dev/null +++ b/Resources/Scripts/XConfig/XScratchTicketConfig.lua @@ -0,0 +1,126 @@ +-- 刮刮乐玩法配置 +XScratchTicketConfig = XScratchTicketConfig or {} +-- ===================表地址 +local SHARE_TABLE_PATH = "Share/MiniActivity/ScratchTicket/" +local CLIENT_TABLE_PATH = "Client/MiniActivity/ScratchTicket/" + +local TABLE_STAGE = SHARE_TABLE_PATH .. "ScratchTicket.tab" +local TABLE_ACTIVITY = SHARE_TABLE_PATH .. "ScratchTicketActivity.tab" +local TABLE_CHOSE = SHARE_TABLE_PATH .. "ScratchTicketChose.tab" +local TABLE_GRID = SHARE_TABLE_PATH .. "ScratchTicketGrid.tab" +-- ===================原表数据 +local StageConfig = {} +local ActivityConfig = {} +local ChoseConfig = {} +local GridConfig = {} + +--================= +--初始化 +--================= +function XScratchTicketConfig.Init() + StageConfig = XTableManager.ReadByIntKey(TABLE_STAGE, XTable.XTableScratchTicket, "Id") + ActivityConfig = XTableManager.ReadByIntKey(TABLE_ACTIVITY, XTable.XTableScratchTicketActivity, "Id") + ChoseConfig = XTableManager.ReadByIntKey(TABLE_CHOSE, XTable.XTableScratchTicketChose, "Id") + GridConfig = XTableManager.ReadByIntKey(TABLE_GRID, XTable.XTableScratchTicketGrid, "Id") +end + +--================= +--获取所有活动配置 +--================= +function XScratchTicketConfig.GetAllActivityConfig() + return ActivityConfig +end + +--================= +--根据ID获取活动配置 +--@param id:关卡配置表Id +--@param noLog:默认显示 true不显示报错提示 +--================= +function XScratchTicketConfig.GetActivityConfigById(id, noLog) + if not noLog and not ActivityConfig[id] then + XLog.ErrorTableDataNotFound( + "XScratchTicketConfig.GetActivityConfigById", + "ScratchTicketActivity", + TABLE_ACTIVITY, + "Id", + tostring(id)) + return + end + return ActivityConfig[id] +end + + +--================= +--获取所有关卡配置 +--================= +function XScratchTicketConfig.GetAllStageConfig() + return StageConfig +end + +--================= +--根据ID获取关卡配置 +--@param id:关卡配置表Id +--@param noLog:默认显示 true不显示报错提示 +--================= +function XScratchTicketConfig.GetStageConfigById(id, noLog) + if not noLog and not StageConfig[id] then + XLog.ErrorTableDataNotFound( + "XScratchTicketConfig.GetStageConfigById", + "ScratchTicket", + TABLE_STAGE, + "Id", + tostring(id)) + return + end + return StageConfig[id] +end + +--================= +--获取所有行列配置 +--================= +function XScratchTicketConfig.GetAllChoseConfig() + return ChoseConfig +end + +--================= +--根据ID获取行列配置 +--@param id:行列配置表Id +--@param noLog:默认显示 true不显示报错提示 +--================= +function XScratchTicketConfig.GetChoseConfigById(id, noLog) + if not noLog and not ChoseConfig[id] then + XLog.ErrorTableDataNotFound( + "XScratchTicketConfig.GetChoseConfigById", + "ScratchTicketChose", + TABLE_CHOSE, + "Id", + tostring(id)) + return + end + return ChoseConfig[id] +end + +--================= +--获取所有九宫格配置 +--================= +function XScratchTicketConfig.GetAllGridConfig() + return GridConfig +end + +--================= +--根据ID获取九宫格配置 +--@param id:九宫格配置表Id +--@param noLog:默认显示 true不显示报错提示 +--================= +function XScratchTicketConfig.GetGridConfigById(id, noLog) + if not noLog and not GridConfig[id] then + XLog.ErrorTableDataNotFound( + "XScratchTicketConfig.GetGridConfigById", + "ScratchTicketGrid", + TABLE_GRID, + "Id", + tostring(id)) + return + end + return GridConfig[id] +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XSetConfigs.lua b/Resources/Scripts/XConfig/XSetConfigs.lua new file mode 100644 index 00000000..4e15b5b2 --- /dev/null +++ b/Resources/Scripts/XConfig/XSetConfigs.lua @@ -0,0 +1,100 @@ +XSetConfigs = XSetConfigs or {} + +XSetConfigs.SelfNumKeyConfig = { + SelfNumSmall = "SelfNumSmall", + SelfNumMiddle = "SelfNumMiddle", + SelfNumBig = "SelfNumBig", +} + +XSetConfigs.SelfNumKeyIndexConfig = { + [1] = 0, + [2] = XSetConfigs.SelfNumKeyConfig.SelfNumSmall, + [3] = XSetConfigs.SelfNumKeyConfig.SelfNumMiddle, + [4] = XSetConfigs.SelfNumKeyConfig.SelfNumBig, +} + +local TABLE_KEYBOARD_MAP_PATH = "Client/KeySet/KeyboardMap.tab" +local TABLE_CONTROLLER_MAP_PATH = "Client/KeySet/ControllerMap.tab" +local KeyboardMapTemplates = {} +local ControllerMapTemplates = {} + +XSetConfigs.SelfNumEnum = { + Close = 1, + Small = 2, + Middle = 3, + Big = 4, +} + +XSetConfigs.FriendNumEnum = { + Close = 1, + Open = 2, +} + +XSetConfigs.FriendEffectEnum = { + Close = 1, + Open = 2, +} + +XSetConfigs.WeaponTransEnum = { + Close = 1, + Open = 2, +} + +XSetConfigs.RechargeEnum = { + Close = 1, + Open = 2, +} + +XSetConfigs.ControllerSetItemType = { + Section = 1, -- 副标题 + SetButton = 2, -- 键位设置按键 + Slider = 3, -- 滑动条(仅支持镜头灵敏度调节) +} + +XSetConfigs.SelfNum = "SelfNum"---自身伤害数字 +XSetConfigs.FriendNum = "FriendNum"--队友伤害数字 +XSetConfigs.FriendEffect = "FriendEffect"--队友特效 +XSetConfigs.IsFirstFriendEffect = "IsFirstFriendEffect"--是否是第一次在联机页面开启队友特效 +XSetConfigs.ScreenOff = "ScreenOff" +XSetConfigs.DefaultDynamicJoystickKey = "DefaultDynamicJoystick" +XSetConfigs.DefaultFocusTypeKey = "DefaultFocusType" +XSetConfigs.DefaultFocusButtonKey = "DefaultFocusButton" +XSetConfigs.DefaultInviteButtonKey = "DefaultInviteButton" +XSetConfigs.DefaultWeaponTransTypeKey = "DefaultWeaponTransType" +XSetConfigs.DefaultRechargeTypeKey = "DefaultRechargeType" + +XSetConfigs.SelfNumSizes = {} + +function XSetConfigs.Init() + local key1 = XSetConfigs.SelfNumKeyConfig.SelfNumSmall + local key2 = XSetConfigs.SelfNumKeyConfig.SelfNumMiddle + local key3 = XSetConfigs.SelfNumKeyConfig.SelfNumBig + XSetConfigs.SelfNumSizes[key1] = CS.XGame.ClientConfig:GetInt(key1) or 0 + XSetConfigs.SelfNumSizes[key2] = CS.XGame.ClientConfig:GetInt(key2) or 0 + XSetConfigs.SelfNumSizes[key3] = CS.XGame.ClientConfig:GetInt(key3) or 0 + XSetConfigs.DefaultDynamicJoystick = CS.XGame.ClientConfig:GetInt(XSetConfigs.DefaultDynamicJoystickKey) + XSetConfigs.DefaultFocusType = CS.XGame.ClientConfig:GetInt(XSetConfigs.DefaultFocusTypeKey) + XSetConfigs.DefaultFocusButton = CS.XGame.ClientConfig:GetInt(XSetConfigs.DefaultFocusButtonKey) + XSetConfigs.DefaultInviteButton = CS.XGame.ClientConfig:GetInt(XSetConfigs.DefaultInviteButtonKey) + XSetConfigs.DefaultWeaponTransType = CS.XGame.ClientConfig:GetInt(XSetConfigs.DefaultWeaponTransTypeKey) + XSetConfigs.DefaultRechargeType = CS.XGame.ClientConfig:GetInt(XSetConfigs.DefaultRechargeTypeKey) + KeyboardMapTemplates = XTableManager.ReadByIntKey(TABLE_KEYBOARD_MAP_PATH, XTable.XTableInputSetKeyboardMap, "Id") + ControllerMapTemplates = XTableManager.ReadByIntKey(TABLE_CONTROLLER_MAP_PATH, XTable.XTableInputSetControllerMap, "Id") +end + +function XSetConfigs.GetKeyboardMapCfg() + return KeyboardMapTemplates +end + +function XSetConfigs.GetControllerMapCfg() + return ControllerMapTemplates +end + +function XSetConfigs.GetControllerKeyText(npcOperationKey) + for i, config in pairs(ControllerMapTemplates) do + if config.NpcOperationKey == npcOperationKey then + return config.Title + end + end + return false +end diff --git a/Resources/Scripts/XConfig/XShopConfigs.lua b/Resources/Scripts/XConfig/XShopConfigs.lua new file mode 100644 index 00000000..7aa83908 --- /dev/null +++ b/Resources/Scripts/XConfig/XShopConfigs.lua @@ -0,0 +1,60 @@ +XShopConfigs = {} + +local ShopGroupTemplate = {} +local ShopTypeNameTemplate = {} +local ScreenGroupTemplate = {} +local ShowTypeTemplate = {} +local ShopBuyLimitLabel = {} + +local TABLE_SHOP_GROUP = "Client/Shop/ShopGroup.tab" +local TABLE_SHOP_TYPENAME = "Client/Shop/ShopTypeName.tab" +local TABLE_SHOP_SCREENGROUP = "Client/Shop/ScreenGroup.tab" +local TABLE_SHOP_SHOWTYPE = "Client/Shop/ShopShowType.tab" +local TABLE_SHOP_BUY_LIMIT_LABEL = "Client/Shop/ShopBuyLimitLabel.tab" + +XShopConfigs.ShowType = { + Normal = 0, --通常 + Fashion = 1 --时装 +} + +XShopConfigs.BuyType = { + Shop = 1, --商店进入 + Purchase = 2 --礼包界面进入 +} + +function XShopConfigs.Init() + ShopGroupTemplate = XTableManager.ReadByIntKey(TABLE_SHOP_GROUP, XTable.XTableShopGroup, "Id") + ShopTypeNameTemplate = XTableManager.ReadByIntKey(TABLE_SHOP_TYPENAME, XTable.XTableShopTypeName, "Id") + ScreenGroupTemplate = XTableManager.ReadByIntKey(TABLE_SHOP_SCREENGROUP, XTable.XTableShopScreenGroup, "Id") + ShowTypeTemplate = XTableManager.ReadByIntKey(TABLE_SHOP_SHOWTYPE, XTable.XTableShopShowType, "Id") + ShopBuyLimitLabel = XTableManager.ReadByIntKey(TABLE_SHOP_BUY_LIMIT_LABEL, XTable.XTableShopBuyLimitLabel, "ClockId") +end + +function XShopConfigs.GetShopGroupTemplate() + return ShopGroupTemplate +end + +function XShopConfigs.GetShopTypeNameTemplate() + return ShopTypeNameTemplate +end + +function XShopConfigs.GetShopScreenGroupTemplate() + return ScreenGroupTemplate +end + +function XShopConfigs.GetShopShowTypeTemplateById(id) + return ShowTypeTemplate[id] +end + +--- +--- 获取商店中商品的限购提示 +function XShopConfigs.GetBuyLimitLabel(clockId) + local id = clockId or 0 + local cfg = ShopBuyLimitLabel[id] + + if not cfg then + XLog.ErrorTableDataNotFound("XShopConfigs.GetBuyLimitLabel", "限购描述", TABLE_SHOP_BUY_LIMIT_LABEL, "ClockId", tostring(clockId)) + cfg = ShopBuyLimitLabel[0] + end + return cfg.TextLimitLabel +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XSignBoardConfigs.lua b/Resources/Scripts/XConfig/XSignBoardConfigs.lua new file mode 100644 index 00000000..76b09024 --- /dev/null +++ b/Resources/Scripts/XConfig/XSignBoardConfigs.lua @@ -0,0 +1,189 @@ +XSignBoardConfigs = XSignBoardConfigs or {} + +XSignBoardEventType = { + CLICK = 10001, --点击 + ROCK = 10002, --摇晃 + LOGIN = 101, --登录 + COMEBACK = 102, --n天未登录 + WIN = 103, --胜利 + WINBUT = 104, -- 胜利,看板不在队里 + LOST = 105, --失败 + LOSTBUT = 106, --失败,不在队伍 + MAIL = 107, --邮件 + TASK = 108, --任务奖励 + DAILY_REWARD = 109, --日常活跃奖励 + LOW_POWER = 110, -- 低电量 + PLAY_TIME = 111, --游戏时长 + RECEIVE_GIFT = 112, --收到礼物 + GIVE_GIFT = 113, --赠送礼物 + IDLE = 1, --待机 + FAVOR_UP = 2, --好感度提升 + CHANGE = 120, --改变角色 +} + + +local TABLE_SIGNBOARD_FEEDBACK = "Client/Signboard/SignBoardFeedback.tab"; +--总表 +local TableSignBoardFeedback = nil +--以角色Id为索引 +local TableSignBoardRoleIdIndexs = {} +--无角色限制 +local TableSignBoardIndexs = {} +local TableSignBoardBreak = nil + +--初始化 +function XSignBoardConfigs.Init() + TableSignBoardFeedback = XTableManager.ReadByIntKey(TABLE_SIGNBOARD_FEEDBACK, XTable.XTableSignBoardFeedback, "Id") + + TableSignBoardRoleIdIndexs = {} + + for _, var in pairs(TableSignBoardFeedback) do + if not var.RoleId then + TableSignBoardIndexs = TableSignBoardIndexs or {} + TableSignBoardIndexs[var.ConditionId] = TableSignBoardIndexs[var.ConditionId] or {} + table.insert(TableSignBoardIndexs[var.ConditionId], var) + elseif var.RoleId == "None" then + TableSignBoardBreak = var + else + local roleIds = string.Split(var.RoleId, "|") + if roleIds then + for _, roleId in ipairs(roleIds) do + roleId = tonumber(roleId) + TableSignBoardRoleIdIndexs[roleId] = TableSignBoardRoleIdIndexs[roleId] or {} + TableSignBoardRoleIdIndexs[roleId][var.ConditionId] = TableSignBoardRoleIdIndexs[roleId][var.ConditionId] or {} + table.insert(TableSignBoardRoleIdIndexs[roleId][var.ConditionId], var) + end + end + end + end +end + +--获取表数据 +function XSignBoardConfigs.GetSignBoardConfig() + if not TableSignBoardFeedback then + return nil + end + + return TableSignBoardFeedback +end + +--获取被动事件 +function XSignBoardConfigs.GetPassiveSignBoardConfig(roleId) + if not TableSignBoardFeedback then + return nil + end + + local roleConfigs = XSignBoardConfigs.GetSignBoardConfigByRoldId(roleId) + if not roleConfigs then + return + end + + local configs = {} + for _, v in ipairs(roleConfigs) do + if v.ConditionId < 10000 and v.ConditionId >= 100 then --被动事件少于10000 大于=100 + table.insert(configs, v) + end + end + + return configs +end + +--获取打断的播放 +function XSignBoardConfigs.GetBreakPlayElements() + return TableSignBoardBreak +end + +--获取 +function XSignBoardConfigs.GetSignBoardConfigById(id) + if not TableSignBoardFeedback then + return + end + + return TableSignBoardFeedback[id] +end + + +--获取角色所有事件 +function XSignBoardConfigs.GetSignBoardConfigByRoldId(roleId) + local all = {} + + if TableSignBoardRoleIdIndexs and TableSignBoardRoleIdIndexs[roleId] then + for _, v in pairs(TableSignBoardRoleIdIndexs[roleId]) do + for _, var in ipairs(v) do + table.insert(all, var) + end + end + end + + if TableSignBoardIndexs then + for _, v in pairs(TableSignBoardIndexs) do + for _, var in ipairs(v) do + table.insert(all, var) + end + end + end + + return all +end + + +--获取角色所有事件 +function XSignBoardConfigs.GetSignBoardConfigByRoldIdAndCondition(roleId, conditionId) + local all = {} + + if TableSignBoardRoleIdIndexs and TableSignBoardRoleIdIndexs[roleId] then + local configs = TableSignBoardRoleIdIndexs[roleId][conditionId] + if configs then + for _, v in ipairs(configs) do + table.insert(all, v) + end + end + end + + if TableSignBoardIndexs and TableSignBoardIndexs[conditionId] then + for _, v in ipairs(TableSignBoardIndexs[conditionId]) do + table.insert(all, v) + end + end + + return all +end + +--根据操作获取表数据 +function XSignBoardConfigs.GetSignBoardConfigByFeedback(roleId, conditionId, param) + if not TableSignBoardRoleIdIndexs then + return + end + + local configs = XSignBoardConfigs.GetSignBoardConfigByRoldIdAndCondition(roleId, conditionId) + + + if not configs or #configs <= 0 then + return + end + + if not param or param < 0 then + return configs + end + + + local fitterCfg = {} + + if conditionId == XSignBoardEventType.CLICK then + + for _, var in ipairs(configs) do + if var.ConditionParam < 0 or var.ConditionParam == param then + table.insert(fitterCfg, var) + end + end + elseif conditionId == XSignBoardEventType.ROCK then + + for _, var in ipairs(configs) do + if var.ConditionParam == math.ceil(param) then + table.insert(fitterCfg, var) + end + end + end + + return fitterCfg +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XSignInConfigs.lua b/Resources/Scripts/XConfig/XSignInConfigs.lua new file mode 100644 index 00000000..e8689789 --- /dev/null +++ b/Resources/Scripts/XConfig/XSignInConfigs.lua @@ -0,0 +1,523 @@ +XSignInConfigs = XSignInConfigs or {} + +XSignInConfigs.SignType = { + Daily = 1, -- 日常签到 + Activity = 2, -- 活动签到 + PurchasePackage = 3, -- 礼包签到 +} + +XSignInConfigs.SignOpen = { + Default = 1, -- 默认打开 + Level = 2, -- 等级 + PreFunction = 3, -- 前置功能 +} + +local TABLE_SIGN_IN = "Share/SignIn/SignIn.tab" +local TABLE_SIGN_IN_REWARD = "Share/SignIn/SignInReward.tab" +local TABLE_SIGN_IN_SUBROUND = "Client/SignIn/SubRound.tab" +local TABLE_SIGN_CARD = "Client/SignIn/SignCard.tab" +local TABLE_SIGN_RECHARGE = "Client/SignIn/SignFirstRecharge.tab" +local TABLE_SIGN_WELFARE = "Client/SignIn/Welfare.tab" +--元旦抽签表 +local TABLE_SIGN_NEWYEAR_SIGN_IN = "Share/DailyLottery/DailyLottery.tab" +local TABLE_SIGN_DAILYLOTTERY_REWARD = "Share/DailyLottery/DailyLotteryReward.tab" +local TABLE_SIGN_DRAW_NEWYEAR = "Client/SignIn/SignDrawNewYear.tab" +--烟花活动表 +local TABLE_SIGN_FIREWORKS = "Client/SignIn/SignFireworks.tab" + +local SignInConfig = {} -- 签到配置表 +local SignInRewardConfig = {} -- 签到奖励配置表[key = signId, value = (key = round, value = {conifig1, config2 ...})] +local SignInSubRound = {} -- 客户端显示子轮次配置表 +local SignCard = {} -- 客户端月卡签到表 +local SignRecharge = {} -- 首充签到表 +local SignWelfareList = {} -- 福利配置表List +local SignWelfareDir = {} -- 福利配置表dir +local SignInNewYearConfig = {} -- 元旦活动签到表 +local SignDrawNewYearConfig = {} -- 元旦抽奖数据表 +local SignInDailyLotteryRewardConfig = {} +local SignFireworksConfig = {} -- 烟花活动配置表 + +function XSignInConfigs.Init() + SignInConfig = XTableManager.ReadByIntKey(TABLE_SIGN_IN, XTable.XTableSignIn, "Id") + SignInSubRound = XTableManager.ReadByIntKey(TABLE_SIGN_IN_SUBROUND, XTable.XTableSignInSubround, "Id") + SignCard = XTableManager.ReadByIntKey(TABLE_SIGN_CARD, XTable.XTableSignCard, "Id") + SignRecharge = XTableManager.ReadByIntKey(TABLE_SIGN_RECHARGE, XTable.XTableSignFirstRecharge, "Id") + SignWelfareDir = XTableManager.ReadByIntKey(TABLE_SIGN_WELFARE, XTable.XTableWelfare, "Id") + local signInReward = XTableManager.ReadByIntKey(TABLE_SIGN_IN_REWARD, XTable.XTableSignInReward, "Id") + SignInNewYearConfig = XTableManager.ReadByIntKey(TABLE_SIGN_NEWYEAR_SIGN_IN, XTable.XTableDailyLottery, "Id") + SignInDailyLotteryRewardConfig = XTableManager.ReadByIntKey(TABLE_SIGN_DAILYLOTTERY_REWARD, XTable.XTableDailyLotteryReward, "Id") + SignDrawNewYearConfig = XTableManager.ReadByIntKey(TABLE_SIGN_DRAW_NEWYEAR, XTable.XTableSignDrawNewYear, "Id") + SignFireworksConfig = XTableManager.ReadByIntKey(TABLE_SIGN_FIREWORKS, XTable.XTableSignFireworks, "Id"); + local signInRewardSort = {} + -- 按SignId 建表 + for _, v in pairs(signInReward) do + if not signInRewardSort[v.SignId] then + signInRewardSort[v.SignId] = {} + end + + table.insert(signInRewardSort[v.SignId], v) + end + + -- 按Pre排序 + for _, v in pairs(signInRewardSort) do + table.sort(v, function(a, b) + return a.Pre < b.Pre + end) + end + + for _, v in pairs(signInRewardSort) do + for _, v2 in ipairs(v) do + if not SignInRewardConfig[v2.SignId] then + SignInRewardConfig[v2.SignId] = {} + end + + if not SignInRewardConfig[v2.SignId][v2.Round] then + SignInRewardConfig[v2.SignId][v2.Round] = {} + end + + table.insert(SignInRewardConfig[v2.SignId][v2.Round], v2) + end + end + + -- 福利表 + for _, v in pairs(SignWelfareDir) do + table.insert(SignWelfareList, v) + end + + table.sort(SignWelfareList, function(a, b) + return a.Sort < b.Sort + end) +end + +-- 获取福利配置表 +function XSignInConfigs.GetWelfareConfigs() + local setConfig = function(id, name, path, functionType, welfareId) + local config = {} + config.Id = id + config.Name = name + config.PrefabPath = path + config.FunctionType = functionType + config.WelfareId = welfareId + return config + end + + local welfareConfigs = {} + for _, v in pairs(SignWelfareList) do + if v.FunctionType == XAutoWindowConfigs.AutoFunctionType.Sign then + if XDataCenter.SignInManager.IsShowSignIn(v.SubConfigId, true) and + not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.SignIn) then + local cfg = XSignInConfigs.GetSignInConfig(v.SubConfigId) + table.insert(welfareConfigs, setConfig(cfg.Id, cfg.Name, cfg.PrefabPath, v.FunctionType, v.Id)) + end + elseif v.FunctionType == XAutoWindowConfigs.AutoFunctionType.FirstRecharge then + if not XDataCenter.PayManager.GetFirstRechargeReward() then + local cfg = XSignInConfigs.GetFirstRechargeConfig(v.SubConfigId) + table.insert(welfareConfigs, setConfig(cfg.Id, cfg.Name, cfg.PrefabPath, v.FunctionType, v.Id)) + end + elseif v.FunctionType == XAutoWindowConfigs.AutoFunctionType.Card then + -- local cfg = XSignInConfigs.GetSignCardConfig(v.SubConfigId) + -- table.insert(welfareConfigs, setConfig(cfg.Id, cfg.Name, cfg.PrefabPath, v.FunctionType, v.Id)) + local t = XSignInConfigs.GetSignCardConfig(v.SubConfigId); + local param = t.Param; + --如果已购买当前月卡或者没有购买当前月卡和互斥的月卡就显示当前的月卡 + if XDataCenter.PurchaseManager.IsYkBuyed(param[1], param[2]) or (not XDataCenter.PurchaseManager.IsYkBuyed(param[1], param[2]) + and not XDataCenter.PurchaseManager.CheckMutexPurchaseYKBuy(param[1], param[2])) then + table.insert(welfareConfigs, setConfig(t.Id, t.Name, t.PrefabPath, v.FunctionType, v.Id)) + end + elseif v.FunctionType == XAutoWindowConfigs.AutoFunctionType.NewYearZhanBu then + if XSignInConfigs.IsShowDivining(v.SubConfigId) then + local t = XSignInConfigs.GetNewYearSignInConfig(v.SubConfigId) + if XPlayer.Level and XPlayer.Level >= t.OpenLevel then + table.insert(welfareConfigs, setConfig(t.Id, t.Name, t.PrefabPath, v.FunctionType, v.Id)) + end + end + elseif v.FunctionType == XAutoWindowConfigs.AutoFunctionType.NewYearDrawActivity then + if XSignInConfigs.IsShowDrawNewYear(v.SubConfigId) then + local t = XSignInConfigs.GetSignDrawNewYearConfig(v.SubConfigId) + if XPlayer.Level and XPlayer.Level >= t.OpenLevel then + table.insert(welfareConfigs, setConfig(t.Id, t.Name, t.PrefabPath, v.FunctionType, v.Id)) + end + end + elseif v.FunctionType == XAutoWindowConfigs.AutoFunctionType.Fireworks then + if XDataCenter.FireworksManager.IsActivityOpen() then + local t = SignFireworksConfig[1]; + if t ~= nil then + table.insert(welfareConfigs, setConfig(t.Id, t.Name, t.PrefabPath, v.FunctionType, v.Id)); + end + end + end + end + + return welfareConfigs +end + +-- 获取福利配置表 +function XSignInConfigs.GetWelfareConfig(id) + local cfg = SignWelfareDir[id] + if not cfg then + XLog.ErrorTableDataNotFound("XSignInConfigs.GetWelfareConfig", "Welfare", TABLE_SIGN_WELFARE, "Id", tostring(id)) + return nil + end + + return cfg +end + +-- 通过福利表Id获取PrefabPath +function XSignInConfigs.GetPrefabPath(id) + local config = XSignInConfigs.GetWelfareConfig(id) + + if config.FunctionType == XAutoWindowConfigs.AutoFunctionType.Sign then + local cfg = XSignInConfigs.GetSignInConfig(config.SubConfigId) + return cfg.PrefabPath + elseif config.FunctionType == XAutoWindowConfigs.AutoFunctionType.FirstRecharge then + local cfg = XSignInConfigs.GetFirstRechargeConfig(config.SubConfigId) + return cfg.PrefabPath + elseif config.FunctionType == XAutoWindowConfigs.AutoFunctionType.Card then + local cfg = XSignInConfigs.GetSignCardConfig(config.SubConfigId) + return cfg.PrefabPath + elseif config.FunctionType == XAutoWindowConfigs.AutoFunctionType.NewYearZhanBu then + local t = XSignInConfigs.GetNewYearSignInConfig(config.SubConfigId) + return t.PrefabPath + elseif config.FunctionType == XAutoWindowConfigs.AutoFunctionType.NewYearDrawActivity then + local t = XSignInConfigs.GetSignDrawNewYearConfig(config.SubConfigId) + return t.PrefabPath + elseif config.FunctionType == XAutoWindowConfigs.AutoFuncitonType.Fireworks then + local t = SignFireworksConfig[1]; + return t.PrefabPath; + end + + return nil +end + +-- 获取签到配置表 +function XSignInConfigs.GetSignInConfig(signInId) + local cfg = SignInConfig[signInId] + if not cfg then + XLog.ErrorTableDataNotFound("XSignInConfigs.GetSignInConfig", "SignIn", TABLE_SIGN_IN, "Id", tostring(signInId)) + return nil + end + + return cfg +end + +--获取元旦占卜配置表 +function XSignInConfigs.GetNewYearSignInConfig(signInId) + return SignInNewYearConfig[signInId] +end + +--获取元旦抽奖配置表 +function XSignInConfigs.GetSignDrawNewYearConfig(id) + return SignDrawNewYearConfig[id] +end + +function XSignInConfigs.GetDiviningSignRewardConfig(id) + return SignInDailyLotteryRewardConfig[id] +end + +-- 获取子轮次配置表 +function XSignInConfigs.GetSubRoundConfig(subRoundId) + local cfg = SignInSubRound[subRoundId] + if not cfg then + XLog.ErrorTableDataNotFound("XSignInConfigs.GetSubRoundConfig", "SubRound", TABLE_SIGN_IN_SUBROUND, "Id", tostring(subRoundId)) + return nil + end + + return cfg +end + +-- 获取月卡签到配置表 +function XSignInConfigs.GetSignCardConfig(id) + local cfg = SignCard[id] + if not cfg then + XLog.ErrorTableDataNotFound("XSignInConfigs.GetSignCardConfig", "SignCard", TABLE_SIGN_CARD, "Id", tostring(id)) + return nil + end + + return cfg +end + +-- 获取首充签到配置表 +function XSignInConfigs.GetFirstRechargeConfig(id) + local cfg = SignRecharge[id] + if not cfg then + XLog.ErrorTableDataNotFound("XSignInConfigs.GetFirstRechargeConfig", "SignFirstRecharge", TABLE_SIGN_RECHARGE, "Id", tostring(id)) + return nil + end + + return cfg +end + +-- 获取月卡签到配置表 +function XSignInConfigs.GetSignCardConfigs(id) + return SignCard; +end + +-- 获取当签到结束是否继续显示签到 +function XSignInConfigs.GetSignInShowWhenDayOver(signInId) + local cfg = XSignInConfigs.GetSignInConfig(signInId) + return cfg.IsShowWhenDayOver +end + +--- +--- 获取签到轮次数据List +--- 日常签到轮次:轮次数由SubRound.tab的数组决定,不同轮次属于同一个SubRound数据行,数组第N个信息就是第N个轮次 +--- +--- 其余签到轮次:轮次数由SignIn.tab的数组决定,数组第N个信息就是第N个轮次, +--- 不同轮次有不同的SubRound数据行,只取数组的第一个信息 +function XSignInConfigs.GetSignInInfos(signInId) + local cfg = XSignInConfigs.GetSignInConfig(signInId) + local signInfos = {} + + if cfg.Type == XSignInConfigs.SignType.Activity + or cfg.Type == XSignInConfigs.SignType.PurchasePackage then + -- 读取SignIn.tab配置的 全部 SubRoundId在SubRound.tab中的数据 + for i = 1, #cfg.SubRoundId do + local subRoundCfg = XSignInConfigs.GetSubRoundConfig(cfg.SubRoundId[i]) + local signInfo = {} + + -- 只读取SubRoundId配置的第一个信息 + signInfo.RoundName = subRoundCfg.SubRoundName[1] or "" + signInfo.Round = i + signInfo.Day = subRoundCfg.SubRoundDays[1] or 0 + signInfo.Icon = subRoundCfg.SubRoundIcon[1] or 0 + signInfo.Description = subRoundCfg.SubRoundDesc or "" + table.insert(signInfos, signInfo) + end + else + -- 只读取SignIn.tab配置的 第round个 SubRoundId在SubRound.tab中的数据(日常签到的round一直为1) + local round = XDataCenter.SignInManager.GetSignRound(signInId) + local subRoundCfg = XSignInConfigs.GetSubRoundConfig(cfg.SubRoundId[round]) + + -- 读取SubRoundId配置的全部轮次奖池信息 + for i = 1, #subRoundCfg.SubRoundDays do + local signInfo = {} + signInfo.RoundName = subRoundCfg.SubRoundName[i] or "" + signInfo.Round = i + signInfo.Day = subRoundCfg.SubRoundDays[i] or 0 + signInfo.Icon = subRoundCfg.SubRoundIcon[i] or 0 + signInfo.Description = subRoundCfg.SubRoundDesc or "" + table.insert(signInfos, signInfo) + end + end + + return signInfos +end + +local GetDailyRewardConfigs = function(data, sunRoundId, subRound) + local subRoundCfg = XSignInConfigs.GetSubRoundConfig(sunRoundId) + local dailyData = {} + local startIndex = 1 + local endIndex = 1 + + for i = 1, #subRoundCfg.SubRoundDays do + if subRound == i then + endIndex = endIndex + subRoundCfg.SubRoundDays[i] - 1 + break + else + startIndex = startIndex + subRoundCfg.SubRoundDays[i] + endIndex = startIndex + end + end + + for i = startIndex, endIndex do + table.insert(dailyData, data[i]) + end + + return dailyData +end + +-- 获得每轮奖励配置表List +function XSignInConfigs.GetSignInRewardConfigs(signInId, round) + local signInInfo = SignInRewardConfig[signInId] + local config = XSignInConfigs.GetSignInConfig(signInId) + + if not signInInfo then + XLog.ErrorTableDataNotFound("XSignInConfigs.GetSignInRewardConfigs", "SignInReward", TABLE_SIGN_IN_REWARD, "SignId", tostring(signInId)) + return nil + end + + if config.Type == XSignInConfigs.SignType.Daily then + local curRound = XDataCenter.SignInManager.GetSignRound(signInId) + local sunRoundId = config.SubRoundId[curRound] + + local cfg = signInInfo[curRound] + local dailyData = GetDailyRewardConfigs(cfg, sunRoundId, round) + return dailyData + else + local cfg = signInInfo[round] + if not cfg then + XLog.Error(string.format("%s出错:找不到%s数据。搜索路径: %s 索引SignId = %s, Round = %s", "XSignInConfigs.GetSignInRewardConfigs", "SignInReward", TABLE_SIGN_IN_REWARD, tostring(signInId), tostring(round))) + return nil + end + return cfg + end +end + +-- 获取签到与当天差距天数 +function XSignInConfigs.GetDayOffsize(signInId, curRound, curDay, targetRound, targetDay) + local offsizeDay = 0 + local signInInfo = SignInRewardConfig[signInId] + if not signInInfo then + XLog.ErrorTableDataNotFound("XSignInConfigs.GetDayOffsize", "SignInReward", TABLE_SIGN_IN_REWARD, "SignId", tostring(signInId)) + return offsizeDay + end + local config = XSignInConfigs.GetSignInConfig(signInId) + if config.Type == XSignInConfigs.SignType.Daily then + offsizeDay = offsizeDay + targetDay - curDay + 1 + else + for i = curRound, targetRound do + local roundDays = #signInInfo[i] + if i == curRound and i == targetRound then + offsizeDay = offsizeDay + targetDay - curDay + 1 + elseif i == curRound then + offsizeDay = offsizeDay + roundDays - curDay + 1 + elseif i == targetRound then + offsizeDay = offsizeDay + targetDay + else + offsizeDay = offsizeDay + roundDays + end + end + end + + return offsizeDay +end + +--- +--- 判断签到是处于开放时间 +function XSignInConfigs.IsShowSignIn(signInId) + local cfg = XSignInConfigs.GetSignInConfig(signInId) + + if cfg.Type == XSignInConfigs.SignType.PurchasePackage then + -- 礼包签到不受TimeId控制 + return true + end + + local timeId = cfg.TimeId + if not XTool.IsNumberValid(timeId) then + return false + end + + local startTime, closeTime = XFunctionManager.GetTimeByTimeId(timeId) + if not startTime or not closeTime then + return false + end + + local now = XTime.GetServerNowTimestamp() + if now <= startTime or now > closeTime then + return false + end + + return true +end + +-- 判断占卜是否显示 +function XSignInConfigs.IsShowDivining(signInId) + local isShowSignIn = false + local t = XSignInConfigs.GetNewYearSignInConfig(signInId) + if not t then + return false + end + local _, startTime = CS.XDateUtil.TryParseToTimestamp(t.StartTimeStr) + local _, closeTime = CS.XDateUtil.TryParseToTimestamp(t.CloseTimeStr) + local now = XTime.GetServerNowTimestamp() + if now <= startTime or now > closeTime then + return false + end + + return true +end + +--判断元旦抽奖是否显示 +function XSignInConfigs.IsShowDrawNewYear(id) + local isShowSignIn = false + local t = XSignInConfigs.GetSignDrawNewYearConfig(id) + local _, startTime = CS.XDateUtil.TryParseToTimestamp(t.StartTimeStr) + local _, closeTime = CS.XDateUtil.TryParseToTimestamp(t.CloseTimeStr) + local now = XTime.GetServerNowTimestamp() + + if now <= startTime or now > closeTime then + return false + end + + return true +end + +-- 判断最后一轮最后一天获得后是否继续再福利界面显示 +function XSignInConfigs.JudgeLastDayGet(signInId, signData) + local config = XSignInConfigs.GetSignInConfig(signInId) + if config.Type == XSignInConfigs.SignType.Daily then + return true + end + + -- 判断是不是最后一轮 + local cfg = XSignInConfigs.GetSignInConfig(signInId) + if #cfg.RoundDays > signData.Round then + return true + end + + -- 判断是不是最后一天 + if cfg.RoundDays[#cfg.RoundDays] > signData.Day then + return true + end + + -- 最后一天是否签到 + if not signData.Got then + return true + end + + -- 配置表是否继续显示 + return config.IsShowWhenSignOver +end + +-- 判断是否当前轮的最后一天 +function XSignInConfigs.JudgeLastRoundDay(signInId, round, day) + local cfg = XSignInConfigs.GetSignInConfig(signInId) + if not cfg then + return false + end + + if cfg.Type == XSignInConfigs.SignType.Daily then + local subRoundCfg = XSignInConfigs.GetSubRoundConfig(cfg.SubRoundId[round]) + local subDay = 0 + local isLastDay = false + local subRound = 1 + for i = 1, #subRoundCfg.SubRoundDays do + subDay = subDay + subRoundCfg.SubRoundDays[i] + if day <= subDay then + subRound = i + + if day == subDay then + isLastDay = true + end + + break + end + end + + return isLastDay, subRound + else + local allDay = cfg.RoundDays[round] + return day >= allDay, round + end +end + +--- +--- 获取签到类型 +function XSignInConfigs.GetSignInType(signInId) + local cfg = XSignInConfigs.GetSignInConfig(signInId) + return cfg.Type +end + +--- +--- 获取签到预制体路径 +function XSignInConfigs.GetSignPrefabPath(signInId) + local cfg = XSignInConfigs.GetSignInConfig(signInId) + return cfg.PrefabPath +end + +--- +--- 获取签到的开放时间 +function XSignInConfigs.GetSignTimeId(signInId) + local cfg = XSignInConfigs.GetSignInConfig(signInId) + return cfg.TimeId +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XSpecialShopConfigs.lua b/Resources/Scripts/XConfig/XSpecialShopConfigs.lua new file mode 100644 index 00000000..b39e5e64 --- /dev/null +++ b/Resources/Scripts/XConfig/XSpecialShopConfigs.lua @@ -0,0 +1,108 @@ +XSpecialShopConfigs = XSpecialShopConfigs or {} + +XSpecialShopConfigs.MAX_COUNT = 5 -- 商店每一行最大的商品数量 + +local TABLE_SPECIAL_SHOP = "Client/SpecialShop/SpecialShop.tab" +local SpecialShopConfig = {} + +function XSpecialShopConfigs.Init() + SpecialShopConfig = XTableManager.ReadByIntKey(TABLE_SPECIAL_SHOP, XTable.XTableSpecialShop, "Id") +end + + +---------------------------------------------------SpecialShop.tab数据读取--------------------------------------------------------- + +--- +--- 内部接口获取配置 +--- 'cfgId'默认为1 +---@overload fun():table +---@return table +local function GetSpecialShopCfg(cfgId) + local paramId = cfgId or 1 + local cfg = SpecialShopConfig[paramId] + if cfg == nil then + XLog.ErrorTableDataNotFound("XSpecialShopConfigs.GetSpecialShopCfg", + "商店信息", + TABLE_SPECIAL_SHOP, + "Id", + tostring(paramId)) + return {} + end + return cfg +end + +--- +--- 获取商店Id +--- 'cfgId'默认为1 +---@overload fun():number +---@return number +function XSpecialShopConfigs.GetShopId(cfgId) + local cfg = GetSpecialShopCfg(cfgId) + if not cfg.ShopId then + XLog.ErrorTableDataNotFound("XSpecialShopConfigs.GetShopId", + "商店Id", + TABLE_SPECIAL_SHOP, + "Id", + tostring(cfgId)) + return 0 + end + return cfg.ShopId +end + +--- +--- 获取商店TimeId +--- 'cfgId'默认为1 +---@overload fun():number +---@return number +function XSpecialShopConfigs.GetTimeId(cfgId) + local cfg = GetSpecialShopCfg(cfgId) + if not cfg.TimeId then + XLog.ErrorTableDataNotFound("XSpecialShopConfigs.GetTimeId", + "商店持续时间", + TABLE_SPECIAL_SHOP, + "Id", + tostring(cfgId)) + return 0 + end + return cfg.TimeId +end + +--- +--- 获取商店持续时间(开启与关闭时间)的时间戳 +--- 'cfgId'默认为1 +---@overload fun():number,number +---@return number 开启时间 +---@return number 结束时间 +function XSpecialShopConfigs.GetDurationTimeStamp(cfgId) + local cfg = GetSpecialShopCfg(cfgId) + if not cfg.TimeId then + XLog.ErrorTableDataNotFound("XSpecialShopConfigs.GetDurationTime", + "商店持续时间", + TABLE_SPECIAL_SHOP, + "Id", + tostring(cfgId)) + return 0, 0 + end + return XFunctionManager.GetTimeByTimeId(cfg.TimeId) +end + +--- +--- 获取商店持续时间(开启与关闭时间)的字符串 +--- 'cfgId'默认为1 +---@overload fun():number,number +---@return string 开启时间 +---@return string 结束时间 +function XSpecialShopConfigs.GetDurationTimeStr(cfgId) + local cfg = GetSpecialShopCfg(cfgId) + if not cfg.TimeId then + XLog.ErrorTableDataNotFound("XSpecialShopConfigs.GetDurationTime", + "商店持续时间", + TABLE_SPECIAL_SHOP, + "Id", + tostring(cfgId)) + return "0", "0" + end + + local startTime, endTime = XFunctionManager.GetTimeByTimeId(cfg.TimeId) + return XTime.TimestampToGameDateTimeString(startTime, "MM/dd hh:mm"), XTime.TimestampToGameDateTimeString(endTime, "MM/dd hh:mm") +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XSpringFestivalActivityConfigs.lua b/Resources/Scripts/XConfig/XSpringFestivalActivityConfigs.lua new file mode 100644 index 00000000..3149a052 --- /dev/null +++ b/Resources/Scripts/XConfig/XSpringFestivalActivityConfigs.lua @@ -0,0 +1,439 @@ +local TABLE_COLLECT_CARD_ITEM_CONFIG = "Share/FestivalActivity/CollectWords/CollectWords.tab" +local TABLE_COLLECT_CARD_REWARD = "Share/FestivalActivity/CollectWords/CollectWordsReward.tab" +local TABLE_SMASH_EGGS_BUFF_ITEM = "Share/FestivalActivity/SmashEggs/SmashEggsBuffItem.tab" +local TABLE_SMASH_EGGS_REWARD = "Share/FestivalActivity/SmashEggs/SmashEggsActivationReward.tab" +local TABLE_SMASH_EGGS_SCORE_CONFIG = "Share/FestivalActivity/SmashEggs/SmashEggsScoreConfig.tab" +local TABLE_SPRING_FESTIVAL_ACTIVITY = "Share/FestivalActivity/SpringFestivalActivity.tab" + +local pairs = pairs +local tableInsert = table.insert +local tableSort = table.sort +XSpringFestivalActivityConfigs = XSpringFestivalActivityConfigs or {} +XSpringFestivalActivityConfigs.CollectCardType = { + Up = 1, --上阕 + Down = 2, --下阕 + Universal = 3, --万能字 +} +XSpringFestivalActivityConfigs.COLLECT_WORD_HELP_KEY = "COLLECT_WORD_HELP_KEY" +XSpringFestivalActivityConfigs.SMASH_EGGS_HELP_KEY = "SMASH_EGGS_HELP_KEY" +XSpringFestivalActivityConfigs.CollectWordsRewardType = { + Up = 1, --上阕奖励 + Down = 2, --下阕奖励 + Final = 3, --终极大奖 +} + +XSpringFestivalActivityConfigs.ShowItem = { + [XSpringFestivalActivityConfigs.CollectWordsRewardType.Up] = 62310, + [XSpringFestivalActivityConfigs.CollectWordsRewardType.Down] = 62311, + [XSpringFestivalActivityConfigs.CollectWordsRewardType.Final] = 62312 +} + +XSpringFestivalActivityConfigs.WordsGiftFromType = { + None = 0, + Friend = 1, --好友 + Guild = 2, --工会 +} + +XSpringFestivalActivityConfigs.BuffItem = { + SilverHammer = 1, + GoldHammer = 2, + LuckyBag = 3, + Amulet = 4, + Money = 5, +} + +XSpringFestivalActivityConfigs.BuffType = { + Hammer = 1, --锤子 + Additive = 2, --加成道具 + Guaranteed = 3, --保底道具 +} + +XSpringFestivalActivityConfigs.SmashSoundId = { + HammerFail = 844, + EggFail = 845, + HammerSuccess = 846, + EggSuccess = 847, + SuccessEffectSound = 848 +} +local CollectWordsTemplate = {} +local CollectWordsActivityConfig = {} +local CollectWordsReward = {} +local SmashEggsBuffItem = {} +local SmashEggsActivityConfig = {} +local SmashEggsRewardTemplate = {} +local SmashEggsScoreConfig = {} +local CollectWordsDic = {} +local SpringFestivalActivity = {} + +local InitCollectWordsTemplate = function() + CollectWordsTemplate = XTableManager.ReadByIntKey(TABLE_COLLECT_CARD_ITEM_CONFIG, XTable.XTableCollectWords, "Id") + for k, v in pairs(CollectWordsTemplate) do + local type = v.Type + if type and type > 0 then + if CollectWordsDic[type] then + tableInsert(CollectWordsDic[type], v) + else + CollectWordsDic[type] = { v } + end + end + end +end + +function XSpringFestivalActivityConfigs.Init() + InitCollectWordsTemplate() + SmashEggsBuffItem = XTableManager.ReadByIntKey(TABLE_SMASH_EGGS_BUFF_ITEM, XTable.XTableSmashEggsBuffItem, "Id") + SmashEggsRewardTemplate = XTableManager.ReadByIntKey(TABLE_SMASH_EGGS_REWARD, XTable.XTableSmashEggsActivation, "Id") + SmashEggsScoreConfig = XTableManager.ReadByIntKey(TABLE_SMASH_EGGS_SCORE_CONFIG, XTable.XTableSmashEggsScoreConfig, "Id") + CollectWordsReward = XTableManager.ReadByIntKey(TABLE_COLLECT_CARD_REWARD, XTable.XTableCollectWordsReward, "Id") + SpringFestivalActivity = XTableManager.ReadByIntKey(TABLE_SPRING_FESTIVAL_ACTIVITY,XTable.XTableSpringFestivalActivity,"Id") +end + + + +---------------------集字相关 begin---------------------- +local GetCollectWordsActivity = function(id) + local template = CollectWordsActivityConfig[id] + if not template then + XLog.Error("XSpringFestivalActivityConfigs GetCollectWordsActivity:配置不存在,活动id:" .. id) + return + end + return template +end + +function XSpringFestivalActivityConfigs.GetCollectWordsActivityTimeId() + local config = GetCollectWordsActivity(1) + return config.TimeId +end + +function XSpringFestivalActivityConfigs.GetCollectWordsActivityName() + local config = GetCollectWordsActivity(1) + return config.Name +end + +function XSpringFestivalActivityConfigs.GetCollectWordsActivityBg() + local config = GetCollectWordsActivity(1) + return config.Background +end + +local GetCollectWordsRewardTemplate = function(id) + local template = CollectWordsReward[id] + if not template then + XLog.Error("XSpringFestivalActivityConfigs GetCollectWordsRewardTemplate:配置不存在 id:" .. id) + return + end + return template +end + +function XSpringFestivalActivityConfigs.GetCollectWordsRewardMagnaItem(id) + local config = GetCollectWordsRewardTemplate(id) + return config.MagnaItem +end + +function XSpringFestivalActivityConfigs.GetCollectWordsRewardsList(id) + local config = GetCollectWordsRewardTemplate(id) + return config.Reward +end + +function XSpringFestivalActivityConfigs.GetCollectWordsRewardCostItemList(id) + local config = GetCollectWordsRewardTemplate(id) + return config.CostItem +end + +function XSpringFestivalActivityConfigs.GetCollectWordsRewardCostCountList(id) + local config = GetCollectWordsRewardTemplate(id) + return config.CostCount +end + +function XSpringFestivalActivityConfigs.GetCollectWordsRewardMaxCount(id) + local itemList = XSpringFestivalActivityConfigs.GetCollectWordsRewardsList(id) + return #itemList +end + +function XSpringFestivalActivityConfigs.GetWordsItemListByType(type) + if not CollectWordsDic[type] then + XLog.Error("XSpringFestivalActivityConfigs.GetWordsItemByType 没有对应类型的字:type:" .. type) + return {} + end + local temp = {} + for _, wordTemplate in pairs(CollectWordsDic[type]) do + tableInsert(temp, wordTemplate) + end + tableSort(temp, function(a, b) + return a.Id < b.Id + end) + return temp +end + +function XSpringFestivalActivityConfigs.GetCollectWordsTemplate() + return CollectWordsTemplate +end +function XSpringFestivalActivityConfigs.GetCollectWordsTemplateOrderFunc(compareFunc) + local list = {} + for _,v in pairs(CollectWordsTemplate) do + tableInsert(list,v) + end + tableSort(list,compareFunc) + return list +end + +function XSpringFestivalActivityConfigs.GetWordItemsEventId() + local events = {} + for id,_ in pairs(CollectWordsTemplate) do + tableInsert(events,XEventId.EVENT_ITEM_COUNT_UPDATE_PREFIX..id) + end + return events +end +---------------------集字相关 end------------------------ +---------------------砸蛋相关 begin------------------------ +local GetSmashEggsActivity = function(id) + local template = SmashEggsActivityConfig[id] + if not template then + XLog.Error("XSpringFestivalActivityConfigs GetSmashEggsActivity:配置不存在,活动id:" .. id) + return + end + return template +end + +function XSpringFestivalActivityConfigs.GetSmashEggsActivityTimeId() + local config = GetSmashEggsActivity(1) + return config.TimeId +end + +function XSpringFestivalActivityConfigs.GetSmashEggsActivityName() + local config = GetSmashEggsActivity(1) + return config.Name +end + +function XSpringFestivalActivityConfigs.GetSmashEggsActivityBackground() + local config = GetSmashEggsActivity(1) + return config.Background +end + +local GetSmashEggsBuffItem = function(id) + local template = SmashEggsBuffItem[id] + if not template then + XLog.Error("XSpringFestivalActivityConfigs GetSmashEggsBuffItem:配置不存在,Id:" .. id) + return + end + return template +end + +function XSpringFestivalActivityConfigs.GetBuffItemDesc(id) + local config = GetSmashEggsBuffItem(id) + return config.Desc +end + +function XSpringFestivalActivityConfigs.GetBuffItemItemId(id) + local config = GetSmashEggsBuffItem(id) + return config.ItemId +end + +function XSpringFestivalActivityConfigs.GetBuffItemName(id) + local config = GetSmashEggsBuffItem(id) + return config.Name +end + +function XSpringFestivalActivityConfigs.IsBuffItemFree(id) + local config = GetSmashEggsBuffItem(id) + return config.IsFree +end + +function XSpringFestivalActivityConfigs.GetBuffItemInitCount(id) + local config = GetSmashEggsBuffItem(id) + return config.InitCount +end + +function XSpringFestivalActivityConfigs.GetBuffItemBuffType(id) + local config = GetSmashEggsBuffItem(id) + return config.BuffType +end + +function XSpringFestivalActivityConfigs.GetBuffItemBuffProb(id) + local config = GetSmashEggsBuffItem(id) + return config.BuffProb +end + +function XSpringFestivalActivityConfigs.GetBuffItemReduction(id) + local config = GetSmashEggsBuffItem(id) + return config.Reduction +end + +function XSpringFestivalActivityConfigs.GetBuffItemsByType(type) + local list = {} + for k, v in pairs(SmashEggsBuffItem) do + if v.BuffType and v.BuffType == type then + tableInsert(list,v) + end + end + return list +end + +local GetSmashEggsScoreConfig = function(id) + local template = SmashEggsScoreConfig[id] + if not template then + XLog.Error("XSpringFestivalActivityConfigs GetSmashEggsScoreConfig 配置不存在,id:" .. id) + return + end + return template +end + +function XSpringFestivalActivityConfigs.GetInitScore() + local config = GetSmashEggsScoreConfig(1) + return config.InitScore +end + +function XSpringFestivalActivityConfigs.GetAddScore() + local config = GetSmashEggsScoreConfig(1) + return config.AddScore +end + +function XSpringFestivalActivityConfigs.GetFailureScore() + local config = GetSmashEggsScoreConfig(1) + return config.FailureScore +end + +function XSpringFestivalActivityConfigs.GetMaxScore() + local config = GetSmashEggsScoreConfig(1) + return config.MaxScore +end + +function XSpringFestivalActivityConfigs.GetSucceedDropId() + local config = GetSmashEggsScoreConfig(1) + return config.SucceedDropId +end + +function XSpringFestivalActivityConfigs.GetFailureDropId() + local config = GetSmashEggsScoreConfig(1) + return config.FailureDropId +end + +function XSpringFestivalActivityConfigs.GetScoreConvertItemId() + local config = GetSmashEggsScoreConfig(1) + return config.ScoreConvertItemId +end + +function XSpringFestivalActivityConfigs.GetNeedTipCount() + local config = GetSmashEggsScoreConfig(1) + return config.NeedTipCount +end + +local GetSmashEggsRewardTemplate = function(day, index) + for k, v in pairs(SmashEggsRewardTemplate) do + if v.Day == day and v.Index == index then + return v + end + end + XLog.Error("XSpringFestivalActivityConfig GetSmashEggsRewardTemplate:配置不存在 day:{0},index:{1}", day, index) + return {} +end + +local GetSmashEggsRewardTemplateByDay = function(day) + local temp = {} + for k, v in pairs(SmashEggsRewardTemplate) do + if v.Day == day then + tableInsert(temp, v) + end + end + return temp +end + +function XSpringFestivalActivityConfigs.GetSmashRewardTemplateByNowDay(day) + return GetSmashEggsRewardTemplateByDay(day) +end + +function XSpringFestivalActivityConfigs.GetSmashRewardMaxScoreByDay(day) + local template = GetSmashEggsRewardTemplateByDay(day) + local max = 0 + for _,info in pairs(template) do + if info.TargetScore > max then + max = info.TargetScore + end + end + return max +end + +function XSpringFestivalActivityConfigs.GetSmashEggsRewardTargetScore(day, index) + local config = GetSmashEggsRewardTemplate(day, index) + return config.TargetScore or 0 +end + +function XSpringFestivalActivityConfigs.GetSmashEggsRewardRewardId(day, index) + local config = GetSmashEggsRewardTemplate(day, index) + return config.RewardId +end + +function XSpringFestivalActivityConfigs.GetSmashEggsRewardDropid(day, index) + local config = GetSmashEggsRewardTemplate(day, index) + return config.DropId or 0 +end + +---------------------砸蛋相关 end------------------------ + +local GetSpringFestivalActivityConfig = function() + local config = SpringFestivalActivity[1] + if not config then + XLog.Error("XSpringFestivalActivityConfigs.GetSpringFestivalActivityConfig:配置不存在") + return + end + return config +end + +function XSpringFestivalActivityConfigs.GetSpringFestivalActivityId() + local config = GetSpringFestivalActivityConfig() + return config.Id +end + +function XSpringFestivalActivityConfigs.GetSpringFestivalActivityBg() + local config = GetSpringFestivalActivityConfig() + return config.Background +end + +function XSpringFestivalActivityConfigs.GetSpringFestivalActivityTimeId() + local config = GetSpringFestivalActivityConfig() + return config.TimeId +end + +function XSpringFestivalActivityConfigs.GetSpringFestivalActivityName() + local config = GetSpringFestivalActivityConfig() + return config.Name +end + +function XSpringFestivalActivityConfigs.GetSpringFestivalActivityChapterId() + local config = GetSpringFestivalActivityConfig() + return config.ChapterId +end + +function XSpringFestivalActivityConfigs.GetSpringFestivalActivitySkipId() + local config = GetSpringFestivalActivityConfig() + return config.ActivitySkipId +end + +function XSpringFestivalActivityConfigs.GetSpringFestivalActivityShopSkipId() + local config = GetSpringFestivalActivityConfig() + return config.ShopSkipId +end + +function XSpringFestivalActivityConfigs.GetSpringFestivalActivityTaskActivityId() + local config = GetSpringFestivalActivityConfig() + return config.TaskActivityId +end + +function XSpringFestivalActivityConfigs.GetSpringFestivalActivityCollectSkipId() + local config = GetSpringFestivalActivityConfig() + return config.CollectSkipId +end + +function XSpringFestivalActivityConfigs.GetSpringFestivalCollectActivityId() + local config = GetSpringFestivalActivityConfig() + return config.CollectActivityId +end + +function XSpringFestivalActivityConfigs.GetCollectHelpId() + local config = GetSpringFestivalActivityConfig() + return config.CollectHelpId +end + +function XSpringFestivalActivityConfigs.GetSmashEggsHelpId() + local config = GetSpringFestivalActivityConfig() + return config.SmashEggsHelpId +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XStrongholdConfigs.lua b/Resources/Scripts/XConfig/XStrongholdConfigs.lua new file mode 100644 index 00000000..2b45f2a8 --- /dev/null +++ b/Resources/Scripts/XConfig/XStrongholdConfigs.lua @@ -0,0 +1,890 @@ +local tonumber = tonumber +local tableInsert = table.insert +local tableSort = table.sort +local mathCeil = math.ceil +local ipairs = ipairs +local pairs = pairs +local stringSplit = string.Split +local CSXTextManagerGetText = CS.XTextManager.GetText +local IsNumberValid = XTool.IsNumberValid + +local TABLE_ACTIVITY_PATH = "Share/Fuben/Stronghold/StrongholdActivity.tab" +local TABLE_COMMON_CONFIG_PATH = "Share/Fuben/Stronghold/StrongholdCfg.tab" +local TABLE_ENDURANCE_PATH = "Share/Fuben/Stronghold/StrongholdEndurance.tab" +local TABLE_CHPATER_PATH = "Share/Fuben/Stronghold/StrongholdChapter.tab" +local TABLE_GROUP_PATH = "Share/Fuben/Stronghold/StrongholdGroup.tab" +local TABLE_REWARD_PATH = "Share/Fuben/Stronghold/StrongholdReward.tab" +local TABLE_PLUGIN_PATH = "Share/Fuben/Stronghold/StrongholdPlugin.tab" +local TABLE_ELECTRICTEAM_PATH = "Share/Fuben/Stronghold/StrongholdTeamElectric.tab" +local TABLE_ELECTRIC_PATH = "Share/Fuben/Stronghold/StrongholdElectric.tab" +local TABLE_BUFF_PATH = "Share/Fuben/Stronghold/StrongholdBuff.tab" +local TABLE_SUPPORT_PATH = "Share/Fuben/Stronghold/StrongholdSupport.tab" +local TABLE_ROBOT_GROUP_PATH = "Share/Fuben/Stronghold/StrongholdRobotGroup.tab" +local TABLE_BOWRROW_PATH = "Share/Fuben/Stronghold/StrongholdBorrowCost.tab" +local TABLE_STRONGHOLD_GROUP_ELEMENT_PATH = "Client/Fuben/Stronghold/StrongholdGroupElement.tab" +local TABLE_LEVEL_PATH = "Share/Fuben/Stronghold/StrongholdLevel.tab" +local TABLE_RUNE_PATH = "Share/Fuben/Stronghold/StrongholdRune.tab" +local TABLE_SUB_RUNE_PATH = "Share/Fuben/Stronghold/StrongholdSubRune.tab" + +local ActivityTemplate = {} +local CommonConfig = {} +local EnduranceConfig = {} +local ChapterConfig = {} +local GroupConfig = {} +local RewardConfig = {} +local LevelIdToRewardIdsDic = {} +local PluginConfig = {} +local TeamAbilityExtraElectricList = {} +local ElectricConfig = {} +local BuffConfig = {} +local SupportConfig = {} +local RobotGroupConfig = {} +local BorrowCostConfig = {} +local StrongholdGroupElementConfig = {} +local StrongholdLevelConfig = {} +local StrongholdRuneConfig = {} +local StrongholdSubRuneConfig = {} + +local DefaultActivityId = 1 +local ActivityIdList = {} --活动Id列表(倒序排布) + +XStrongholdConfigs = XStrongholdConfigs or {} + +local InitActivityConfig = function() + ActivityTemplate = XTableManager.ReadByIntKey(TABLE_ACTIVITY_PATH, XTable.XTableStrongholdActivity, "Id") + + for activityId, config in pairs(ActivityTemplate) do + tableInsert(ActivityIdList, activityId) + end + + tableSort(ActivityIdList, function(aId, bId) + return aId > bId --倒序排布 + end) + + DefaultActivityId = ActivityIdList[1] +end + +local InitElectricTeamConfig = function() + local templates = XTableManager.ReadByStringKey(TABLE_ELECTRICTEAM_PATH, XTable.XTableStrongholdTeamElectric, "Id") + + for _, template in pairs(templates) do + local config = { + Ability = template.Id, + Electric = template.ElectricEnerge, + } + tableInsert(TeamAbilityExtraElectricList, config) + end + + tableSort(TeamAbilityExtraElectricList, function(a, b) + return a.Ability < b.Ability + end) +end + +local InitRewardConfig = function() + RewardConfig = XTableManager.ReadByIntKey(TABLE_REWARD_PATH, XTable.XTableStrongholdReward, "Id") + + local levelId + for id, config in pairs(RewardConfig) do + levelId = config.LevelId + + local rewardIds = LevelIdToRewardIdsDic[levelId] + if not rewardIds then + rewardIds = {} + LevelIdToRewardIdsDic[levelId] = rewardIds + end + + tableInsert(rewardIds, id) + end +end + +function XStrongholdConfigs.Init() + CommonConfig = XTableManager.ReadByStringKey(TABLE_COMMON_CONFIG_PATH, XTable.XTableStrongholdCfg, "Key") + EnduranceConfig = XTableManager.ReadByIntKey(TABLE_ENDURANCE_PATH, XTable.XTableStrongholdEndurance, "Id") + ChapterConfig = XTableManager.ReadByIntKey(TABLE_CHPATER_PATH, XTable.XTableStrongholdChapter, "Id") + GroupConfig = XTableManager.ReadByIntKey(TABLE_GROUP_PATH, XTable.XTableStrongholdGroup, "Id") + PluginConfig = XTableManager.ReadByIntKey(TABLE_PLUGIN_PATH, XTable.XTableStrongholdPlugin, "Id") + ElectricConfig = XTableManager.ReadByIntKey(TABLE_ELECTRIC_PATH, XTable.XTableStrongholdElectric, "Id") + BuffConfig = XTableManager.ReadByIntKey(TABLE_BUFF_PATH, XTable.XTableStrongholdBuff, "Id") + SupportConfig = XTableManager.ReadByIntKey(TABLE_SUPPORT_PATH, XTable.XTableStrongholdSupport, "Id") + RobotGroupConfig = XTableManager.ReadByIntKey(TABLE_ROBOT_GROUP_PATH, XTable.XTableStrongholdRobotGroup, "Id") + BorrowCostConfig = XTableManager.ReadByIntKey(TABLE_BOWRROW_PATH, XTable.XTableStrongholdBorrowCost, "Id") + StrongholdGroupElementConfig = XTableManager.ReadByIntKey(TABLE_STRONGHOLD_GROUP_ELEMENT_PATH, XTable.XTableStrongholdGroupElement, "StageIdGroupIndex") + StrongholdLevelConfig = XTableManager.ReadByIntKey(TABLE_LEVEL_PATH, XTable.XTableStrongholdLevel, "Id") + StrongholdRuneConfig = XTableManager.ReadByIntKey(TABLE_RUNE_PATH, XTable.XTableStrongholdRune, "Id") + StrongholdSubRuneConfig = XTableManager.ReadByIntKey(TABLE_SUB_RUNE_PATH, XTable.XTableStrongholdSubRune, "Id") + + InitActivityConfig() + InitElectricTeamConfig() + InitRewardConfig() +end + +-----------------活动时间相关 begin-------------------- +--活动期数自循环,example:{1, 10} 当活动期数大于等于10的时候读取id为10的一行,否则读取id为1的一行 +local function GetActivityConfig(activityId) + activityId = IsNumberValid(activityId) and activityId or DefaultActivityId + + local circleId = 0 + for _, configId in ipairs(ActivityIdList) do + if configId <= activityId then + circleId = configId + break + end + end + + local config = ActivityTemplate[circleId] + if not config then + XLog.Error("XStrongholdConfigs GetActivityConfig error:配置不存在, activityId: " .. activityId .. ", 配置路径: " .. TABLE_ACTIVITY_PATH) + return + end + + return config +end + +function XStrongholdConfigs.GetActivityFightAutoBeginSeconds(activityId) + local config = GetActivityConfig(activityId) + return config.AutoBeginSeconds +end + +function XStrongholdConfigs.GetActivityFightContinueSeconds(activityId) + local config = GetActivityConfig(activityId) + return config.FightContinueSeconds +end + +function XStrongholdConfigs.GetActivityFightTotalDay(activityId) + local seconds = XStrongholdConfigs.GetActivityFightContinueSeconds(activityId) + return mathCeil(seconds / 86400) +end + +function XStrongholdConfigs.GetActivityOneCycleSeconds(activityId) + local config = GetActivityConfig(activityId) + return config.OneCycleSeconds +end + +function XStrongholdConfigs.GetActivityDefaultOpenTime() + local config = GetActivityConfig(DefaultActivityId) + local timeId = config.OpenTimeId + if not IsNumberValid(timeId) then return 0 end + return XFunctionManager.GetStartTimeByTimeId(timeId) +end + +function XStrongholdConfigs.GetActivityDefaultEndTime() + local openTime = XStrongholdConfigs.GetActivityDefaultOpenTime() + return openTime + XStrongholdConfigs.GetActivityOneCycleSeconds(DefaultActivityId) +end +-----------------活动时间相关 end-------------------- +-----------------耐力相关 begin-------------------- +local function GetEnduranceConfig(day) + local config = EnduranceConfig[day] + if not config then + XLog.Error("XStrongholdConfigs GetEnduranceConfig error:配置不存在, day: " .. day .. ", 配置路径: " .. TABLE_ENDURANCE_PATH) + return + end + return config +end + +function XStrongholdConfigs.GetMaxEndurance(curDay, levelId) + if not IsNumberValid(curDay) then + return 0 + end + + local maxEndurance = 0 + local enduracnce, config + for day = 1, curDay do + config = GetEnduranceConfig(day) + enduracnce = config.Endurance[levelId] or 0 + maxEndurance = maxEndurance + enduracnce + end + return maxEndurance +end +-----------------耐力相关 end-------------------- +-----------------副本相关 begin-------------------- +local function GetChapterConfig(chapterId) + local config = ChapterConfig[chapterId] + if not config then + XLog.Error("XStrongholdConfigs GetChapterConfig error:配置不存在, chapterId: " .. chapterId .. ", 配置路径: " .. TABLE_CHPATER_PATH) + return + end + return config +end + +local function GetGroupConfig(groupId) + local config = GroupConfig[groupId] + if not config then + XLog.Error("XStrongholdConfigs GetGroupConfig error:配置不存在, groupId: " .. groupId .. ", 配置路径: " .. TABLE_GROUP_PATH) + return + end + return config +end + +function XStrongholdConfigs.GetNextChapterId(chapterId) + local nextChapterId = chapterId + 1 + local chapterIds = XStrongholdConfigs.GetAllChapterIds() + local chapterCount = #chapterIds + if nextChapterId > chapterCount then return end + return nextChapterId +end + +function XStrongholdConfigs.GetGroupIds(chapterId) + local groupIds = {} + + local config = GetChapterConfig(chapterId) + for _, groupId in ipairs(config.GroupId) do + if IsNumberValid(groupId) then + tableInsert(groupIds, groupId) + end + end + + return groupIds +end + +function XStrongholdConfigs.GetAllGroupIds() + local groupIds = {} + + local chapterIds = XStrongholdConfigs.GetAllChapterIds() + for _, chapterId in pairs(chapterIds) do + local config = GetChapterConfig(chapterId) + for _, groupId in ipairs(config.GroupId) do + if IsNumberValid(groupId) then + tableInsert(groupIds, groupId) + end + end + end + + return groupIds +end + +function XStrongholdConfigs.GetChapterName(chapterId) + local config = GetChapterConfig(chapterId) + return config.Name or "" +end + +function XStrongholdConfigs.GetChapterBg(chapterId) + local config = GetChapterConfig(chapterId) + return config.Bg or "" +end + +function XStrongholdConfigs.GetChapterPrefabPath(chapterId) + local config = GetChapterConfig(chapterId) + return config.Prefab or "" +end + +function XStrongholdConfigs.GetChapterFirstGroupId(chapterId) + local config = GetChapterConfig(chapterId) + return config.GroupId and config.GroupId[1] or 0 +end + +--是否为章节关底据点 +function XStrongholdConfigs.IsChapterLastGroupId(groupId) + local chapterIds = XStrongholdConfigs.GetAllChapterIds() + for _, chapterId in pairs(chapterIds) do + local groupIds = XStrongholdConfigs.GetGroupIds(chapterId) + if groupId == groupIds[#groupIds] then + return true + end + end + return false +end + +function XStrongholdConfigs.GetChapterLastGroupId(chapterId) + local groupIds = XStrongholdConfigs.GetGroupIds(chapterId) + return groupIds[#groupIds] +end + +--获取章节Id +function XStrongholdConfigs.GetChapterIdByGroupId(groupId) + if not IsNumberValid(groupId) then return end + local chapterIds = XStrongholdConfigs.GetAllChapterIds() + for _, chapterId in pairs(chapterIds) do + local groupIds = XStrongholdConfigs.GetGroupIds(chapterId) + for _, inGroupId in pairs(groupIds) do + if inGroupId == groupId then + return chapterId + end + end + end + XLog.Error("XStrongholdConfigs.GetChapterIdByGroupId error: 找不到据点Id对应章节配置, groupId: " .. groupId .. ", 配置路径:" .. TABLE_CHPATER_PATH) +end + +function XStrongholdConfigs.GetGroupPreGroupId(groupId) + local config = GetGroupConfig(groupId) + return config.PreId or 0 +end + +function XStrongholdConfigs.GetGroupOrder(groupId) + local config = GetGroupConfig(groupId) + return config.Order or "" +end + +function XStrongholdConfigs.GetGroupName(groupId) + local config = GetGroupConfig(groupId) + return config.Name or "" +end + +function XStrongholdConfigs.GetGroupPrefabPath(groupId) + local config = GetGroupConfig(groupId) + return config.Prefab or "" +end + +function XStrongholdConfigs.GetGroupIconBg(groupId) + local config = GetGroupConfig(groupId) + return config.IconBg +end + +function XStrongholdConfigs.GetGroupIconBoss(groupId) + local config = GetGroupConfig(groupId) + return config.IconBoss +end + +--获取据点基础BUFF(每关都有) +function XStrongholdConfigs.GetGroupBaseBuffIds(groupId, activityId) + local buffIds = {} + + local activityBuffNum + local activityBuffIndex + local activityBuffIds = {} + + local config = GetGroupConfig(groupId) + for _, buffIdStr in pairs(config.BaseBuffId) do + + activityBuffIds = stringSplit(buffIdStr, "|") + activityBuffNum = activityBuffNum or #activityBuffIds + activityBuffIndex = activityBuffIndex or (activityId % activityBuffNum) + activityBuffIndex = activityBuffIndex == 0 and activityBuffNum or activityBuffIndex + + local buffId = tonumber(activityBuffIds[activityBuffIndex]) + if buffId > 0 then + tableInsert(buffIds, buffId) + end + + end + + return buffIds +end + +--获取据点关底BUFF(关底才有,满足条件之后减少一个) +function XStrongholdConfigs.GetGroupBossBuffIds(groupId, activityId) + local buffIds = {} + + local activityBuffNum + local activityBuffIndex + local activityBuffIds = {} + + local config = GetGroupConfig(groupId) + for _, buffIdStr in pairs(config.StageBuffId) do + + activityBuffIds = stringSplit(buffIdStr, "|") + activityBuffNum = activityBuffNum or #activityBuffIds + activityBuffIndex = activityBuffIndex or (activityId % activityBuffNum) + activityBuffIndex = activityBuffIndex == 0 and activityBuffNum or activityBuffIndex + + local buffId = tonumber(activityBuffIds[activityBuffIndex]) + if buffId > 0 then + tableInsert(buffIds, buffId) + end + + end + + return buffIds +end + +function XStrongholdConfigs.CheckHasGroupBossBuffId(groupId, activityId) + local buffIds = XStrongholdConfigs.GetGroupBossBuffIds(groupId, activityId) + for _, buffId in pairs(buffIds) do + if buffId > 0 then + return true + end + end + return false +end + +--获取完成该据点时连带完成的据点Id +function XStrongholdConfigs.GetGroupFinishRelatedId(groupId) + local groupIds = {} + + local config = GetGroupConfig(groupId) + for _, groupId in pairs(config.FinishRelatedId) do + if groupId > 0 then + tableInsert(groupIds, groupId) + end + end + + return groupIds +end + +function XStrongholdConfigs.GetGroupCostEndurance(groupId) + local config = GetGroupConfig(groupId) + return config.Endurance +end + +function XStrongholdConfigs.GetGroupRewardId(groupId, activityId) + local config = GetGroupConfig(groupId) + return config.RewardId[activityId] +end + +function XStrongholdConfigs.GetGroupDetailBg(groupId) + local config = GetGroupConfig(groupId) + return config.DetailBg +end + +function XStrongholdConfigs.GetGroupDetailDesc(groupId) + local config = GetGroupConfig(groupId) + return config.DetailDesc +end + +function XStrongholdConfigs.GetGroupRequireTeamMemberNum(groupId, teamId) + local requireTeamMemberNum = XStrongholdConfigs.GetMaxTeamMemberNum() + if groupId then + local config = GetGroupConfig(groupId) + requireTeamMemberNum = config.TeamMember[teamId] or 0 + end + return requireTeamMemberNum +end + +--获取据点试玩角色(机器人)列表 +function XStrongholdConfigs.GetGroupCanUseRobotIds(groupId, characterType, levelId) + local config = GetGroupConfig(groupId) + local roubotGroupId = config.RobotGroup[levelId] + return XStrongholdConfigs.GetRobotGroupRobotIds(roubotGroupId, characterType)--修改为整个玩法通用试玩角色 +end + +function XStrongholdConfigs.GetGroupStageIdGroupIndex(groupId, stageId) + local config = GetGroupConfig(groupId) + local stageIdGroupList = config.StageIdGroup + local stageIds + for index, stageIdGroup in ipairs(stageIdGroupList) do + stageIds = string.Split(stageIdGroup) + for _, stageIdStr in pairs(stageIds) do + if stageId == tonumber(stageIdStr) then + return index + end + end + end +end +-----------------副本相关 end-------------------- +-----------------词缀相关 begin-------------------- +local function GetBuffConfig(buffId) + local config = BuffConfig[buffId] + if not config then + XLog.Error("XStrongholdConfigs GetBuffConfig error:配置不存在, buffId: " .. buffId .. ", 配置路径: " .. TABLE_BUFF_PATH) + return + end + return config +end + +function XStrongholdConfigs.GetBuffIcon(buffId) + local config = GetBuffConfig(buffId) + return config.Icon +end + +function XStrongholdConfigs.GetBuffName(buffId) + local config = GetBuffConfig(buffId) + return config.Name +end + +function XStrongholdConfigs.GetBuffDesc(buffId) + local config = GetBuffConfig(buffId) + return XUiHelper.ConvertLineBreakSymbol(config.Desc) +end + +function XStrongholdConfigs.GetBuffConditionId(buffId) + local config = GetBuffConfig(buffId) + return config.Condition[1] +end + +function XStrongholdConfigs.CheckBuffHasCondition(buffId) + local conditionId = XStrongholdConfigs.GetBuffConditionId(buffId) + return conditionId and conditionId > 0 +end +-----------------词缀相关 end-------------------- +-----------------支援方案 begin-------------------- +local function GetSupportConfig(supportId) + local config = SupportConfig[supportId] + if not config then + XLog.Error("XStrongholdConfigs GetSupportConfig error:配置不存在, supportId: " .. supportId .. ", 配置路径: " .. TABLE_SUPPORT_PATH) + return + end + return config +end + +function XStrongholdConfigs.GetSupportConditionIds(supportId) + local conditionIds = {} + local config = GetSupportConfig(supportId) + for _, conditionId in pairs(config.Condition) do + if conditionId > 0 then + tableInsert(conditionIds, conditionId) + end + end + return conditionIds +end + +function XStrongholdConfigs.GetSupportRequireAbility(supportId) + local config = GetSupportConfig(supportId) + return config.RequireAbility +end + +function XStrongholdConfigs.GetSupportBuffIds(supportId) + local buffIds = {} + local config = GetSupportConfig(supportId) + for _, buffId in pairs(config.BuffId) do + if buffId > 0 then + tableInsert(buffIds, buffId) + end + end + return buffIds +end +-----------------支援方案 end-------------------- +-----------------奖励(任务)相关 begin-------------------- +local function GetRewardConfig(rewardId) + local config = RewardConfig[rewardId] + if not config then + XLog.Error("XStrongholdConfigs GetRewardConfig error:配置不存在, rewardId: " .. rewardId .. ", 配置路径: " .. TABLE_REWARD_PATH) + return + end + return config +end + +local function CheckRewardOffline(rewardId) + local config = GetRewardConfig(rewardId) + return IsNumberValid(config.Offline) +end + +function XStrongholdConfigs.GetAllRewardIds(levelId) + local ids = {} + local rewardIds = LevelIdToRewardIdsDic[levelId] or {} + for _, id in pairs(rewardIds) do + if not CheckRewardOffline(id) then + tableInsert(ids, id) + end + end + return ids +end + +function XStrongholdConfigs.GetRewardDesc(rewardId) + local config = GetRewardConfig(rewardId) + return config.Desc or "" +end + +function XStrongholdConfigs.GetRewardSkipId(rewardId) + local config = GetRewardConfig(rewardId) + return config.SkipId +end + +function XStrongholdConfigs.GetRewardConditionId(rewardId) + local config = GetRewardConfig(rewardId) + return config.Condition +end + +function XStrongholdConfigs.GetRewardGoodsId(rewardId) + local config = GetRewardConfig(rewardId) + return config.RewardId +end +-----------------奖励(任务)相关 end-------------------- +-----------------队伍相关 begin-------------------- +local MAX_TEAM_NUM = 5--最大队伍数量 +function XStrongholdConfigs.GetMaxTeamNum() + return MAX_TEAM_NUM +end + +local MAX_TEAM_MEMBER_NUM = 3--最大队伍成员数量 +function XStrongholdConfigs.GetMaxTeamMemberNum() + return MAX_TEAM_MEMBER_NUM +end + +local function GetRobotGroupConfig(roubotGroupId) + local config = RobotGroupConfig[roubotGroupId] + if not config then + XLog.Error("XStrongholdConfigs GetRobotGroupConfig error:配置不存在, roubotGroupId: " .. roubotGroupId .. ", 配置路径: " .. TABLE_ROBOT_GROUP_PATH) + return + end + return config +end + +function XStrongholdConfigs.GetRobotGroupRobotIds(roubotGroupId, characterType) + local robotIds = {} + local config = GetRobotGroupConfig(roubotGroupId) + + local num, index + local robotIds = {} + for _, robotId in pairs(config.RobotId) do + if IsNumberValid(characterType) then + local robotType = XRobotManager.GetRobotCharacterType(robotId) + if robotType == characterType then + tableInsert(robotIds, robotId) + end + else + tableInsert(robotIds, robotId) + end + end + return robotIds +end + + +local function GetBorrowCostConfig(times) + local config = BorrowCostConfig[times] + if not config then + XLog.Error("XStrongholdConfigs GetBorrowCostConfig error:配置不存在, times: " .. times .. ", 配置路径: " .. TABLE_BOWRROW_PATH) + return + end + return config +end + +function XStrongholdConfigs.GetBorrowCostItemInfo(times) + times = times + 1 + + local maxTimes = XStrongholdConfigs.GetBorrowMaxTimes() + times = times > maxTimes and maxTimes or times + + local config = GetBorrowCostConfig(times) + return config.ItemId, config.ItemCount +end + +function XStrongholdConfigs.GetBorrowMaxTimes() + return #BorrowCostConfig +end +-----------------队伍相关 end-------------------- +-----------------插件相关 begin-------------------- +local function GetPluginConfig(pluginId) + local config = PluginConfig[pluginId] + if not config then + XLog.Error("XStrongholdConfigs GetPluginConfig error:配置不存在, pluginId: " .. pluginId .. ", 配置路径: " .. TABLE_PLUGIN_PATH) + return + end + return config +end + +function XStrongholdConfigs.GetPluginIds() + local pluginIds = {} + for pluginId in ipairs(PluginConfig) do + tableInsert(pluginIds, pluginId) + end + return pluginIds +end + +function XStrongholdConfigs.GetPluginUseElectric(pluginId) + local config = GetPluginConfig(pluginId) + return config.UseElectric +end + +function XStrongholdConfigs.GetPluginAddAbility(pluginId) + local config = GetPluginConfig(pluginId) + return config.FightAbility +end + +function XStrongholdConfigs.GetPluginIcon(pluginId) + local config = GetPluginConfig(pluginId) + return config.Icon +end + +function XStrongholdConfigs.GetPluginName(pluginId) + local config = GetPluginConfig(pluginId) + return config.Name +end + +function XStrongholdConfigs.GetPluginDesc(pluginId) + local config = GetPluginConfig(pluginId) + return config.Desc +end + +function XStrongholdConfigs.GetPluginCountLimit(pluginId) + local config = GetPluginConfig(pluginId) + return IsNumberValid(config.CountLimit) and config.CountLimit or XMath.IntMax() +end +-----------------插件相关 end-------------------- +-----------------电能相关 begin-------------------- +local function GetElectricConfig(day) + local config = ElectricConfig[day] + if not config then + return + end + return config +end + +function XStrongholdConfigs.GetElectricAdd(day, levelId) + local config = GetElectricConfig(day) + return config and config.ElectricEnerge and config.ElectricEnerge[levelId] or 0 +end + +function XStrongholdConfigs.GetTeamAbilityExtraElectricList() + return XTool.Clone(TeamAbilityExtraElectricList) +end + +function XStrongholdConfigs.GetTeamAbilityToExtraElectric(totalAbility) + local extraElectric = 0 + for _, config in ipairs(TeamAbilityExtraElectricList) do + if totalAbility > config.Ability then + extraElectric = config.Electric + end + end + return extraElectric +end + +local ElectricIcon = CS.XGame.ClientConfig:GetString("StrongholdElectricIcon") +function XStrongholdConfigs.GetElectricIcon() + return ElectricIcon +end + +function XStrongholdConfigs.GetElectricIdList() + local electricIdList = {} + for id in pairs(ElectricConfig) do + tableInsert(electricIdList, id) + end + return electricIdList +end +-----------------电能相关 end-------------------- +-----------------配置杂项 begin-------------------- +function XStrongholdConfigs.GetCommonConfig(key) + local config = CommonConfig[key] + if not config then + XLog.Error("XStrongholdConfigs.GetCommonConfig error:配置不存在, key: " .. key .. ", 配置路径: " .. TABLE_COMMON_CONFIG_PATH) + return + end + return config.Value or 0 +end + +--活动名称 +function XStrongholdConfigs.GetActivityName() + return CSXTextManagerGetText("StrongholdActivityName") +end +-----------------配置杂项 end-------------------- +-----------------关卡组对应的属性相关 begin-------------------- +local function GetStrongholdGroupElement(stageIdGroupIndex) + local template = StrongholdGroupElementConfig[stageIdGroupIndex] + if not template then + XLog.ErrorTableDataNotFound("XStrongholdConfigs.GetStrongholdGroupElement", "StrongholdGroupElement", TABLE_STRONGHOLD_GROUP_ELEMENT_PATH, "StageIdGroupIndex", tostring(stageIdGroupIndex)) + return + end + return template +end + +function XStrongholdConfigs.GetStrongholdGroupElementGridTitleBg(stageIdGroupIndex) + local config = GetStrongholdGroupElement(stageIdGroupIndex) + return config.GridTitleBg +end +-----------------关卡组对应的属性相关 end---------------------- +-----------------等级分区 begin-------------------- +XStrongholdConfigs.LevelType = { + Choosable = 0, --未选择 + Normal = 1, --低级区 + Medium = 2, --中级区 + High = 3, --高级区 +} + +local function GetLevelConfig(levelId) + local config = StrongholdLevelConfig[levelId] + if not config then + XLog.Error("XStrongholdConfigs GetLevelConfig error:配置不存在, levelId: " .. levelId .. ", 配置路径: " .. TABLE_LEVEL_PATH) + return + end + return config +end + +function XStrongholdConfigs.GetLevelName(levelId) + local config = GetLevelConfig(levelId) + return config.Name +end + +function XStrongholdConfigs.GetLevelLimit(levelId) + local config = GetLevelConfig(levelId) + return config.MinLevel, config.MaxLevel +end + +function XStrongholdConfigs.GetLevelIcon(levelId) + local config = GetLevelConfig(levelId) + return config.Icon +end + +function XStrongholdConfigs.GetLevelInitElectricEnergy(levelId) + local config = GetLevelConfig(levelId) + return config.InitElectricEnergy +end + +function XStrongholdConfigs.GetLevelInitEndurance(levelId) + local config = GetLevelConfig(levelId) + return config.InitEndurance +end + +function XStrongholdConfigs.GetAllChapterIds() + local ids = {} + + local levelId = XDataCenter.StrongholdManager.GetLevelId() + if not IsNumberValid(levelId) then return ids end + + local config = GetLevelConfig(levelId) + for id in ipairs(config.Chapter) do + if IsNumberValid(id) then + tableInsert(ids, id) + end + end + return ids +end +-----------------等级分区 end-------------------- +-----------------符文 begin-------------------- +local function GetRuneConfig(runeId) + local config = StrongholdRuneConfig[runeId] + if not config then + XLog.Error("XStrongholdConfigs GetRuneConfig error:配置不存在, runeId: " .. runeId .. ", 配置路径: " .. TABLE_RUNE_PATH) + return + end + return config +end + +local function GetSubRuneConfig(subRuneId) + local config = StrongholdSubRuneConfig[subRuneId] + if not config then + XLog.Error("XStrongholdConfigs GetSubRuneConfig error:配置不存在, subRuneId: " .. subRuneId .. ", 配置路径: " .. TABLE_SUB_RUNE_PATH) + return + end + return config +end + +function XStrongholdConfigs.GetRuneName(runeId) + local config = GetRuneConfig(runeId) + return config.Name or "" +end + +function XStrongholdConfigs.GetRuneIcon(runeId) + local config = GetRuneConfig(runeId) + return config.Icon or "" +end + +function XStrongholdConfigs.GetRuneDesc(runeId) + local config = GetRuneConfig(runeId) + return XUiHelper.ConvertLineBreakSymbol(config.Desc) +end + +function XStrongholdConfigs.GetRuneBrief(runeId) + local config = GetRuneConfig(runeId) + return config.Brief or "" +end + +function XStrongholdConfigs.GetRuneColor(runeId) + local config = GetRuneConfig(runeId) + return XUiHelper.Hexcolor2Color(config.Color) +end + +function XStrongholdConfigs.GetSubRuneIds(runeId) + local subRuneIds = {} + local config = GetRuneConfig(runeId) + for _, subRuneId in ipairs(config.SubRuneId) do + if XTool.IsNumberValid(subRuneId) then + tableInsert(subRuneIds, subRuneId) + end + end + return subRuneIds +end + +function XStrongholdConfigs.GetSubRuneName(subRuneId) + local config = GetSubRuneConfig(subRuneId) + return config.Name or "" +end + +function XStrongholdConfigs.GetSubRuneIcon(subRuneId) + local config = GetSubRuneConfig(subRuneId) + return config.Icon or "" +end + +function XStrongholdConfigs.GetSubRuneDesc(subRuneId) + local config = GetSubRuneConfig(subRuneId) + return XUiHelper.ConvertLineBreakSymbol(config.Desc) +end +-----------------符文 end-------------------- \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XSuperTowerConfigs.lua b/Resources/Scripts/XConfig/XSuperTowerConfigs.lua new file mode 100644 index 00000000..6f510c76 --- /dev/null +++ b/Resources/Scripts/XConfig/XSuperTowerConfigs.lua @@ -0,0 +1,758 @@ +--=========================== +--超级爬塔配置读写 +--模块负责:吕天元,陈思亮,张爽 +--=========================== +XSuperTowerConfigs = XSuperTowerConfigs or {} +------------------------------------------------------------------ +-- 配置表地址 -- +------------------------------------------------------------------ +local SHARE_TABLE_PATH = "Share/Fuben/SuperTower/" +local SHARE_CHARACTER_TABLE_PATH = "Share/Fuben/SuperTower/Character/" +local CLIENT_TABLE_PATH = "Client/Fuben/SuperTower/" + +local TABLE_ACTIVITY = SHARE_TABLE_PATH .. "SuperTowerActivity.tab" +local TABLE_CONFIG = SHARE_TABLE_PATH .. "SuperTowerCfg.tab" +local TABLE_MAP = SHARE_TABLE_PATH .. "SuperTowerMap.tab" +local TABLE_PLUGIN = SHARE_TABLE_PATH .. "SuperTowerPlugin.tab" +local TABLE_PLUGIN_DROP = CLIENT_TABLE_PATH .. "SuperTowerPluginDrop.tab" +local TABLE_ENHANCE_DROP = CLIENT_TABLE_PATH .. "SuperTowerEnhanceDrop.tab" +local TABLE_ENHANCER = SHARE_TABLE_PATH .. "SuperTowerEnhancer.tab" +--local TABLE_ENHANCER_DROP = SHARE_TABLE_PATH .. "SuperTowerEnhancerDrop.tab" +local TABLE_MALL = SHARE_TABLE_PATH .. "SuperTowerMall.tab" +local TABLE_MALL_PLUGIN = SHARE_TABLE_PATH .. "SuperTowerMallPlugin.tab" +local TABLE_TARGET_STAGE = SHARE_TABLE_PATH .. "SuperTowerTargetStage.tab" +local TABLE_TIER_STAGE = SHARE_TABLE_PATH .. "SuperTowerTier.tab" +local TABLE_TIER_ENHANCER_AND_DROP = CLIENT_TABLE_PATH .. "SuperTowerTierEnhancerAndDrop.tab" +local TABLE_TIER_SCORE_RATIO = CLIENT_TABLE_PATH .. "SuperTowerTierScoreRatio.tab" +local TABLE_STAR_ICON = CLIENT_TABLE_PATH .. "SuperTowerStarIcon.tab" +local TABLE_CHARACTER_LEVEL = SHARE_TABLE_PATH .. "Character/SuperTowerCharacterLevel.tab" +local TABLE_FUNCTION = CLIENT_TABLE_PATH .. "SuperTowerFunction.tab" +local TABLE_GRANT_ROBOT = SHARE_TABLE_PATH .. "SuperTowerRobot.tab" +local TABLE_CHARACTER_PLUGIN = SHARE_CHARACTER_TABLE_PATH .. "SuperTowerCharacterExclusive.tab" +local TABLE_CHARACTER_INDULT = SHARE_CHARACTER_TABLE_PATH .. "SuperTowerIndultCharacter.tab" +local TABLE_CLIENT_CONFIG = CLIENT_TABLE_PATH .. "SuperTowerClientCfg.tab" +local TABLE_STAGE_ELEMENT = CLIENT_TABLE_PATH .. "SuperTowerStageElement.tab" +local TABLE_MAP_EFFECT = CLIENT_TABLE_PATH .. "SuperTowerMapEffect.tab" +------------------------------------------------------------------ +-- 配置表数据 -- +------------------------------------------------------------------ +local BaseConfigs = {} -- 超级爬塔基础配置 TABLE_CONFIG +local ActivityConfigs = {} -- 活动配置表 TABLE_ACTIVITY +local ThemeConfigs = {} -- 主题配置表 TABLE_MAP +local TargetStageConfigs = {} -- 普通关卡配置表 TABLE_TARGET_STAGE +local TierStageConfigs = {} -- 爬塔关卡(层)配置表 TABLE_TIER_STAGE +local TierEnDConfigs = {} -- (客户端表)爬塔增益与插件掉落展示配置表 TABLE_TIER_ENHANCER_AND_DROP +local TierScoreRatioConfigs = {} -- (客户端表)爬塔结算分数系数配置表 TABLE_TIER_SCORE_RATIO +local PluginConfigs = {} -- 插件配置表 TABLE_PLUGIN +local PluginDropConfigs = {} -- (客户端表)插件掉落表 TABLE_PLUGIN_DROP +local EnhanceDropConfigs = {} -- (客户端表)增益掉落表 TABLE_ENHANCE_DROP +local StarIconConfigs = {} --(客户端表)星级图标表 TABLE_STAR_ICON +local CharacterId2LevelConfigs = {} -- 角色Id映射等级培养配置 TABLE_CHARACTER_LEVEL +local FunctionConfigs = {} --(客户端表)特权表 TABLE_FUNCTION +local GrantRobotConfigs = {} -- 机器人发放配置 TABLE_GRANT_ROBOT +local CharacterPluginConfigs = {} -- 角色专属插件配置 TABLE_CHARACTER_PLUGIN +local CharacterInDultConfigs = {} -- 角色特典配置 TABLE_CHARACTER_INDULT +local ClientConfigs = {} -- (客户端表)客户端基础配置 TABLE_CLIENT_CONFIG +local EnhanceConfigs = {} -- 爬塔增益表 TABLE_ENHANCER +local StageElementConfigs = {} -- 目标关卡倾向属性 TABLE_STAGE_ELEMENT +local MallConfig = {} --商店配置 TABLE_MALL +local MallPluginConfig = {} --商店插件信息配置 TABLE_MALL_PLUGIN +local MapEffectConfig = {} --地图特效配置 TABLE_MAP_EFFECT +local CharacterSpecialPluginIdDic = {} -- 角色专属槽插件id字典 TABLE_CHARACTER_PLUGIN +------------------------------------------------------------------ +-- 搜索用字典 -- +------------------------------------------------------------------ +local Theme2TargetStageDic = {} -- 主题Id<->目标字典 +local Theme2TierStageDic = {} -- 主题Id<->爬塔关卡字典 +local CharacterId2PluginDic = {} -- 角色Id<->绑定插件字典 +local WithOutCharacterPluginList = {} -- 非绑定角色插件列表 +local CharacterId2MaxLevelConfig = {} -- 角色Id对应最大超限等级 +local CharacterId2InDultConfigs = {} -- 特典角色配置 TABLE_CHARACTER_INDULT +local DropGroupId2EnhanceIdListDic = {} -- 掉落组ID<->增益ID列表字典 +local DropGroupId2PluginIdListDic = {} -- 掉落组ID<->插件ID列表字典 +------------------------------------------------------------------ +-- 逻辑定义 -- +------------------------------------------------------------------ +XSuperTowerConfigs.MaxMultiTeamCount = 5 -- 多队伍关卡最大多队伍数量 +------------------------------------------------------------------ +-- 关卡配置初始化方法 -- +------------------------------------------------------------------ +--=================== +--创建主题ID<->普通关卡字典 +--=================== +local CreateTheme2TargetStageDic = function() + for _, cfg in pairs(TargetStageConfigs) do + if not Theme2TargetStageDic[cfg.MapId] then + Theme2TargetStageDic[cfg.MapId] = {} + end + table.insert(Theme2TargetStageDic[cfg.MapId], cfg) + end +end +--=================== +--创建主题ID<->爬塔关卡字典 +--=================== +local CreateTheme2TierStageDic = function() + for _, cfg in pairs(TierStageConfigs) do + if not Theme2TierStageDic[cfg.MapId] then + Theme2TierStageDic[cfg.MapId] = {} + end + Theme2TierStageDic[cfg.MapId][cfg.Tier] = cfg + end +end +--=================== +--初始化关卡配置表和关系字典 +--=================== +local InitStageCfgs = function() + ThemeConfigs = XTableManager.ReadByIntKey(TABLE_MAP, XTable.XTableSuperTowerMap, "Id") + TargetStageConfigs = XTableManager.ReadByIntKey(TABLE_TARGET_STAGE, XTable.XTableSuperTowerTargetStage, "Id") + TierStageConfigs = XTableManager.ReadByIntKey(TABLE_TIER_STAGE, XTable.XTableSuperTowerTier, "Id") + CreateTheme2TargetStageDic() + CreateTheme2TierStageDic() +end +--=================== +--创建增益掉落组相关字典 +--=================== +local CreateEnhanceDropGroupId2Dic = function() + for _, cfg in pairs(EnhanceDropConfigs) do + if not DropGroupId2EnhanceIdListDic[cfg.EnhancerDropGroupId] then + DropGroupId2EnhanceIdListDic[cfg.EnhancerDropGroupId] = {} + end + table.insert(DropGroupId2EnhanceIdListDic[cfg.EnhancerDropGroupId], cfg.DropEnhanceId) + end +end +--=================== +--初始化爬塔相关配置 +--=================== +local InitTierCfgs = function() + EnhanceConfigs = XTableManager.ReadByIntKey(TABLE_ENHANCER, XTable.XTableSuperTowerEnhancer, "Id") + EnhanceDropConfigs = XTableManager.ReadByIntKey(TABLE_ENHANCE_DROP, XTable.XTableSuperTowerEnhanceDrop, "Id") + TierEnDConfigs = XTableManager.ReadByIntKey(TABLE_TIER_ENHANCER_AND_DROP, XTable.XTableSuperTowerTierEnhancerAndDrop, "Id") + TierScoreRatioConfigs = XTableManager.ReadByIntKey(TABLE_TIER_SCORE_RATIO, XTable.XTableSuperTowerTierScoreRatio, "Id") + CreateEnhanceDropGroupId2Dic() +end +--=================== +--初始化角色ID<->插件关系字典与列表 +--=================== +local CreateCharacterIdPluginRelative = function() + for _, plugin in pairs(PluginConfigs) do + if plugin.CharacterId and plugin.CharacterId > 0 then + if not CharacterId2PluginDic[plugin.CharacterId] then + CharacterId2PluginDic[plugin.CharacterId] = {} + end + CharacterId2PluginDic[plugin.CharacterId][plugin.Id] = plugin + else + WithOutCharacterPluginList[plugin.Id] = plugin + end + end +end +--=================== +--创建插件掉落组相关字典 +--=================== +local CreatePluginDropGroupId2Dic = function() + for _, cfg in pairs(PluginDropConfigs) do + if not DropGroupId2PluginIdListDic[cfg.PluginsDropGroupId] then + DropGroupId2PluginIdListDic[cfg.PluginsDropGroupId] = {} + end + table.insert(DropGroupId2PluginIdListDic[cfg.PluginsDropGroupId], cfg.DropPlugins) + end +end +--=================== +--初始化插件相关配置 +--=================== +local InitPluginCfgs = function() + PluginConfigs = XTableManager.ReadByIntKey(TABLE_PLUGIN, XTable.XTableSuperTowerPlugin, "Id") + PluginDropConfigs = XTableManager.ReadByIntKey(TABLE_PLUGIN_DROP, XTable.XTableSuperTowerPluginDrop, "Id") + StarIconConfigs = XTableManager.ReadByIntKey(TABLE_STAR_ICON, XTable.XTableSuperTowerStarIcon, "Quality") + CreateCharacterIdPluginRelative() + CreatePluginDropGroupId2Dic() +end +--=================== +--初始化角色相关配置 +--=================== +local InitCharacterCfgs = function() + local characterLevelConfigs = XTableManager.ReadByIntKey(TABLE_CHARACTER_LEVEL, XTable.XTableSuperTowerCharacterLevel, "Id") + local characterId2LevelConfigs = {} + for id, config in pairs(characterLevelConfigs) do + characterId2LevelConfigs[config.CharacterId] = characterId2LevelConfigs[config.CharacterId] or {} + characterId2LevelConfigs[config.CharacterId][config.Level] = config + -- 最大等级映射 + CharacterId2MaxLevelConfig[config.CharacterId] = CharacterId2MaxLevelConfig[config.CharacterId] or 0 + CharacterId2MaxLevelConfig[config.CharacterId] = math.max(CharacterId2MaxLevelConfig[config.CharacterId], config.Level) + end + CharacterId2LevelConfigs = characterId2LevelConfigs + GrantRobotConfigs = XTableManager.ReadByIntKey(TABLE_GRANT_ROBOT, XTable.XTableSuperTowerRobot, "Id") + CharacterPluginConfigs = XTableManager.ReadByIntKey(TABLE_CHARACTER_PLUGIN, XTable.XTableSuperTowerCharacterExclusive, "Id") + for _, config in pairs(CharacterPluginConfigs) do + CharacterSpecialPluginIdDic[config.ActivatePlugin] = true + end + -- 特典角色配置,改成根据角色id获取配置信息 + CharacterInDultConfigs = XTableManager.ReadByIntKey(TABLE_CHARACTER_INDULT, XTable.XTableSuperTowerIndultCharacter, "Id") + for _, config in pairs(CharacterInDultConfigs) do + for _, characterId in ipairs(config.CharacterId) do + -- 这里是为了每个id有配置重复的角色,因此角色id是对应配置数组 + CharacterId2InDultConfigs[characterId] = CharacterId2InDultConfigs[characterId] or {} + table.insert(CharacterId2InDultConfigs[characterId], config) + end + end +end +--============= +--初始化 +--============= +function XSuperTowerConfigs.Init() + BaseConfigs = XTableManager.ReadByStringKey(TABLE_CONFIG, XTable.XTableSuperTowerCfg, "Key") + ActivityConfigs = XTableManager.ReadByIntKey(TABLE_ACTIVITY, XTable.XTableSuperTowerActivity, "Id") + ClientConfigs = XTableManager.ReadByStringKey(TABLE_CLIENT_CONFIG, XTable.XTableSuperTowerClientCfg, "Key") + FunctionConfigs = XTableManager.ReadByStringKey(TABLE_FUNCTION, XTable.XTableSuperTowerFunction, "Key") + StageElementConfigs = XTableManager.ReadByIntKey(TABLE_STAGE_ELEMENT, XTable.XTableSuperTowerStageElement, "Element") + MallConfig = XTableManager.ReadByIntKey(TABLE_MALL, XTable.XTableSuperTowerMall, "Id") + MallPluginConfig = XTableManager.ReadByIntKey(TABLE_MALL_PLUGIN, XTable.XTableSuperTowerMallPlugin, "Id") + MapEffectConfig = XTableManager.ReadByIntKey(TABLE_MAP_EFFECT, XTable.XTableSuperTowerMapEffect, "ThemeId") + InitStageCfgs() + InitTierCfgs() + InitPluginCfgs() + InitCharacterCfgs() +end +------------------------------------------------------------------ +-- 配置表读取 -- +------------------------------------------------------------------ +--============= +--根据键值获取基础配置 +--@param key:配置项键值,XSuperTowerConfigs.BaseCfgKey +--============= +function XSuperTowerConfigs.GetBaseConfigByKey(key) + if (not key) or (not BaseConfigs[key]) then + XLog.ErrorTableDataNotFound( + "XSuperTowerConfigs.GetBaseConfigByKey", + "基础配置_Cfg", + TABLE_CONFIG, + "Key", + tostring(key)) + return + end + return BaseConfigs[key].Value +end +--============= +--根据键值获取客户端基础配置 +--@param key:配置项键值,XSuperTowerConfigs.BaseCfgKey +--============= +function XSuperTowerConfigs.GetClientBaseConfigByKey(key, noTips) + if (not key) or (not ClientConfigs[key]) then + if not noTips then + XLog.ErrorTableDataNotFound( + "XSuperTowerConfigs.GetClientBaseConfigByKey", + "Client基础配置_ClientCfg", + TABLE_CLIENT_CONFIG, + "Key", + tostring(key)) + end + return + end + return ClientConfigs[key].Value +end +--============= +--根据活动ID获取活动配置 +--@param activityId:活动表Id +--@param noTips:默认false,会打印错误日志。true不会打出错误日志。 +--============= +function XSuperTowerConfigs.GetActivityById(activityId, noTips) + if not ActivityConfigs[activityId] then + if not noTips then + XLog.ErrorTableDataNotFound( + "XSuperTowerConfigs.GetActivityById", + "活动配置_Activity", + TABLE_ACTIVITY, + "Id", + tostring(activityId)) + end + return nil + end + return ActivityConfigs[activityId] +end +--============= +--通过当前配置了TimeId的活动ID获取活动配置(只能有一个活动配有TimeId) +--============= +function XSuperTowerConfigs.GetCurrentActivity() + for _, cfg in pairs(ActivityConfigs) do + if cfg.TimeId and cfg.TimeId > 0 then + return cfg + end + end + XLog.Error("XSuperTowerConfigs.GetCurrentActivity:没有任何一项配置了TimeId!请检查表格:" .. TABLE_ACTIVITY) + return nil +end +--============= +--根据主题ID获取主题配置 +--@param themeId:主题表Id +--@param noTips:默认false,会打印错误日志。true不会打出错误日志。 +--============= +function XSuperTowerConfigs.GetThemeById(themeId, noTips) + if not ThemeConfigs[themeId] then + if not noTips then + XLog.ErrorTableDataNotFound( + "XSuperTowerConfigs.GetThemeById", + "主题配置_Map", + TABLE_MAP, + "Id", + tostring(themeId)) + end + return nil + end + return ThemeConfigs[themeId] +end +--============= +--根据目标关卡表Id获取关卡配置 +--@param targetStageId:目标关卡表Id +--@param noTips:默认false,会打印错误日志。true不会打出错误日志。 +--============= +function XSuperTowerConfigs.GetTargetStageById(targetStageId, noTips) + if not TargetStageConfigs[targetStageId] then + if not noTips then + XLog.ErrorTableDataNotFound( + "XSuperTowerConfigs.GetTargetStageById", + "目标关卡配置_TargetStage", + TABLE_TARGET_STAGE, + "Id", + tostring(targetStageId)) + end + return nil + end + return TargetStageConfigs[targetStageId] +end +--============= +--根据主题ID获取该主题下的普通关卡配置 +--@param themeId:主题表Id +--@param noTips:默认false,会打印错误日志。true不会打出错误日志。 +--============= +function XSuperTowerConfigs.GetTargetStagesByThemeId(themeId, noTips) + if not Theme2TargetStageDic[themeId] then + if not noTips then + XLog.ErrorTableDataNotFound( + "XSuperTowerConfigs.GetTargetStagesByThemeId", + "目标关卡配置_TargetStage", + TABLE_TARGET_STAGE, + "MapId", + tostring(themeId)) + end + return nil + end + return Theme2TargetStageDic[themeId] +end +--============= +--根据爬塔关卡表Id获取关卡配置 +--@param tierStageId:爬塔关卡表Id +--@param noTips:默认false,会打印错误日志。true不会打出错误日志。 +--============= +function XSuperTowerConfigs.GetTierStageById(tierStageId, noTips) + if not TierStageConfigs[tierStageId] then + if not noTips then + XLog.ErrorTableDataNotFound( + "XSuperTowerConfigs.GetTierStageById", + "爬塔关卡配置_TierStage", + TABLE_TIER_STAGE, + "Id", + tostring(tierStageId)) + end + return nil + end + return TierStageConfigs[tierStageId] +end +--============= +--根据主题ID获取该主题下的爬塔关卡配置 +--@param themeId:主题表Id +--@param noTips:默认false,会打印错误日志。true不会打出错误日志。 +--============= +function XSuperTowerConfigs.GetTierStagesByThemeId(themeId, noTips) + if not Theme2TierStageDic[themeId] then + if not noTips then + XLog.ErrorTableDataNotFound( + "XSuperTowerConfigs.GetTierStagesByThemeId", + "爬塔关卡配置_Tier", + TABLE_TIER_STAGE, + "MapId", + tostring(themeId)) + end + return nil + end + return Theme2TierStageDic[themeId] +end +--============= +--根据增益ID获取增益配置 +--@param enhanceId:增益Id +--@param noTips:默认false,会打印错误日志。true不会打出错误日志。 +--============= +function XSuperTowerConfigs.GetEnhanceCfgById(enhanceId, noTips) + if not EnhanceConfigs[enhanceId] then + if not noTips then + XLog.ErrorTableDataNotFound( + "XSuperTowerConfigs.GetEnhanceCfgById", + "爬塔增益配置_Enhancer", + TABLE_ENHANCER, + "Id", + tostring(enhanceId)) + end + return nil + end + return EnhanceConfigs[enhanceId] +end +--============= +--根据主题Id获取主题爬塔收益配置 +--@param themeId:主题Id +--@param noTips:默认false,会打印错误日志。true不会打出错误日志。 +--============= +function XSuperTowerConfigs.GetEnDConfigByThemeId(themeId, noTips) + if not TierEnDConfigs[themeId] then + if not noTips then + XLog.ErrorTableDataNotFound( + "XSuperTowerConfigs.GetEnDConfigByThemeId", + "爬塔收益配置_TierEnhancerAndDrop", + TABLE_TIER_ENHANCER_AND_DROP, + "Id", + tostring(themeId)) + end + return nil + end + return TierEnDConfigs[themeId] +end +--============= +--获取没有绑定角色的插件列表 +--============= +function XSuperTowerConfigs.GetWithOutCharacterPluginCfg() + return WithOutCharacterPluginList +end +--============= +--获取所有插件配置 +--============= +function XSuperTowerConfigs.GetAllPluginCfgs() + return PluginConfigs +end +--============= +--根据插件ID获取插件配置 +--@param pluginId:插件Id +--@param noTips:默认false,会打印错误日志。true不会打出错误日志。 +--============= +function XSuperTowerConfigs.GetPluginCfgById(pluginId, noTips) + if not PluginConfigs[pluginId] then + if not noTips then + XLog.ErrorTableDataNotFound( + "XSuperTowerConfigs.GetPluginCfgById", + "插件配置_Plugin", + TABLE_PLUGIN, + "Id", + tostring(pluginId)) + end + return nil + end + return PluginConfigs[pluginId] +end +--============= +--根据角色ID获取绑定该角色的插件列表 +--============= +function XSuperTowerConfigs.GetPluginCfgsByCharacterId(characterId) + return CharacterId2PluginDic[characterId] or {} +end +--============= +--根据掉落组Id获取插件掉落配置 +--@param dropId:掉落组Id +--============= +function XSuperTowerConfigs.GetPluginDropByDropId(dropId) + if not PluginDropConfigs[dropId] then + XLog.ErrorTableDataNotFound( + "XSuperTowerConfigs.GetPluginDropByDropId", + "插件掉落配置_PluginDrop", + TABLE_PLUGIN_DROP, + "Id", + tostring(dropId)) + end + return PluginDropConfigs[dropId] +end +--============= +--根据星数获取星数图标地址 +--@param quality:星数 +--============= +function XSuperTowerConfigs.GetStarIconByQuality(quality) + if not StarIconConfigs[quality] then + XLog.ErrorTableDataNotFound( + "XSuperTowerConfigs.GetStarIconByStar", + "星级图标配置_StarIcon", + TABLE_STAR_ICON, + "Quality", + tostring(quality)) + end + return StarIconConfigs[quality].Icon +end +--============= +--根据星数获取星数图标地址 +--@param quality:星数 +--============= +function XSuperTowerConfigs.GetStarBgByQuality(quality) + if not StarIconConfigs[quality] then + XLog.ErrorTableDataNotFound( + "XSuperTowerConfigs.GetStarIconByStar", + "星级图标配置_StarIcon", + TABLE_STAR_ICON, + "Quality", + tostring(quality)) + end + return StarIconConfigs[quality].Bg +end +--============= +--根据角色id和等级获取角色等级培养配置 +--============= +function XSuperTowerConfigs.GetCharacterLevelConfig(characterId, level, noTips) + if not CharacterId2LevelConfigs[characterId] then + if noTips then return end + XLog.ErrorTableDataNotFound( + "XSuperTowerConfigs.GetCharacterLevelConfig", + "角色等级培养配置_CharacterId", + TABLE_CHARACTER_LEVEL, + "CharacterId", + tostring(characterId)) + end + if not CharacterId2LevelConfigs[characterId][level] then + if noTips then return end + XLog.ErrorTableDataNotFound( + "XSuperTowerConfigs.GetCharacterLevelConfig", + "角色等级培养配置_Level", + TABLE_CHARACTER_LEVEL, + "Level", + tostring(level)) + end + return CharacterId2LevelConfigs[characterId][level] +end +--============= +--获取所有特权配置 +--============= +function XSuperTowerConfigs.GetAllFunctionCfgs() + return FunctionConfigs +end +--============= +--根据键值获取特权配置 +--@param key:键值 +--============= +function XSuperTowerConfigs.GetFunctionCfgByKey(key) + if not FunctionConfigs[key] then + XLog.ErrorTableDataNotFound( + "XSuperTowerConfigs.GetFunctionCfgByKey", + "特权配置_Function", + TABLE_FUNCTION, + "Key", + tostring(key)) + end + return FunctionConfigs[key] +end +--============= +--获取所有目标关卡属性配置 +--============= +function XSuperTowerConfigs.GetStageElementCfgs() + return StageElementConfigs +end +--============= +--根据属性ID获取目标关卡属性配置 +--@param element:属性ID +--============= +function XSuperTowerConfigs.GetStageElementCfgByKey(element) + if not StageElementConfigs[element] then + XLog.ErrorTableDataNotFound( + "XSuperTowerConfigs.GetStageElementCfgByKey", + "目标关卡属性_StageElement", + TABLE_STAGE_ELEMENT, + "Element", + tostring(element)) + end + return StageElementConfigs[element] +end +--============= +--根据属性ID获取目标关卡属性图标 +--@param element:属性ID +--============= +function XSuperTowerConfigs.GetElementIconByKey(element) + return XSuperTowerConfigs.GetStageElementCfgByKey(element).StageElementIcon +end +--============= +--获取所有地图特效配置 +--============= +function XSuperTowerConfigs.GetMapEffectCfgs() + return MapEffectConfig +end +--============= +--根据主题ID获取地图特效配置 +--@param themeId:主题ID +--============= +function XSuperTowerConfigs.GetMapEffectCfgByKey(themeId) + if not MapEffectConfig[themeId] then + XLog.ErrorTableDataNotFound( + "XSuperTowerConfigs.GetMapEffectCfgByKey", + "地图特效_MapEffect", + TABLE_MAP_EFFECT, + "themeId", + tostring(themeId)) + end + return MapEffectConfig[themeId] +end +--============= +--获取机器人发放配置数据 +--============= +function XSuperTowerConfigs.GetGrantRobotConfigs() + return GrantRobotConfigs +end +--============= +--根据id获取机器人发放配置数据 +--============= +function XSuperTowerConfigs.GetGrantRobotConfig(id) + if not GrantRobotConfigs[id] then + XLog.ErrorTableDataNotFound( + "XSuperTowerConfigs.GetGrantRobotConfig", + "发放机器人配置_Id", + TABLE_GRANT_ROBOT, + "Id", + tostring(id)) + end + return GrantRobotConfigs[id] +end +--============= +--根据角色id获取专属插件配置 +--============= +function XSuperTowerConfigs.GetCharacterPluginConfig(id) + if not CharacterPluginConfigs[id] then + XLog.ErrorTableDataNotFound( + "XSuperTowerConfigs.GetCharacterPlugin", + "角色专属插件_Id", + TABLE_CHARACTER_PLUGIN, + "Id", + tostring(id)) + end + return CharacterPluginConfigs[id] +end +--============= +--根据角色id获取特典配置信息数组,返回数组的原因是防止策划配置重复的角色Id +--============= +function XSuperTowerConfigs.GetCharacterInDultConfigs(id) + -- if not CharacterId2InDultConfigs[id] then + -- XLog.ErrorTableDataNotFound( + -- "XSuperTowerConfigs.GetCharacterInDultConfigs", + -- "特典角色配置_Id", + -- TABLE_CHARACTER_INDULT, + -- "Id", + -- tostring(id)) + -- end + return CharacterId2InDultConfigs[id] +end +--============= +--根据角色id获取最大超限等级 +--============= +function XSuperTowerConfigs.GetCharacterMaxLevel(id) + if not CharacterId2MaxLevelConfig[id] then + XLog.ErrorTableDataNotFound( + "XSuperTowerConfigs.GetCharacterMaxLevel", + "角色超限最大等级_Id", + TABLE_CHARACTER_LEVEL, + "Id", + tostring(id)) + end + return CharacterId2MaxLevelConfig[id] +end +--============= +--获取所有角色特典配置 +--============= +function XSuperTowerConfigs.GetAllCharacterInDultConfigs() + return CharacterInDultConfigs +end +--============= +--获取所有爬塔关卡分数配置 +--============= +function XSuperTowerConfigs.GetAllTierScoreRatioCfg() + return TierScoreRatioConfigs +end +--============= +--根据Id获取爬塔关卡分数配置 +--============= +function XSuperTowerConfigs.GetTierScoreRatioCfgById(id) + if not TierScoreRatioConfigs[id] then + XLog.ErrorTableDataNotFound( + "XSuperTowerConfigs.GetTierScoreRatioCfgById", + "超级爬塔爬塔关卡分数配置_Id", + TABLE_TIER_SCORE_RATIO, + "Id", + tostring(id)) + end + return TierScoreRatioConfigs[id] +end +--============= +--根据掉落组Id获取超级爬塔增益掉落展示Id列表 +--============= +function XSuperTowerConfigs.GetEnhanceIdListByGroupId(id) + if not DropGroupId2EnhanceIdListDic[id] then + XLog.ErrorTableDataNotFound( + "XSuperTowerConfigs.GetEnhanceIdListByGroupId", + "超级爬塔增益掉落展示配置_EnhancerDropGroupId", + TABLE_ENHANCE_DROP, + "EnhancerDropGroupId", + tostring(id)) + return + end + return DropGroupId2EnhanceIdListDic[id] +end +--============= +--根据掉落组Id获取超级爬塔插件掉落展示Id列表 +--============= +function XSuperTowerConfigs.GetPluginIdListByGroupId(id) + if not DropGroupId2PluginIdListDic[id] then + XLog.ErrorTableDataNotFound( + "XSuperTowerConfigs.GetPluginIdListByGroupId", + "超级爬塔插件掉落展示配置_PluginsDropGroupId", + TABLE_PLUGIN_DROP, + "PluginsDropGroupId", + tostring(id)) + return + end + return DropGroupId2PluginIdListDic[id] +end + + +--============= +--获取商店配置 +--============= +function XSuperTowerConfigs.GetMallConfig(id) + if not MallConfig[id] then + XLog.ErrorTableDataNotFound( + "XSuperTowerConfigs.GetMallConfig", + "商店配置不存在", + TABLE_MALL, + "Id", + tostring(id)) + end + return MallConfig[id] +end +--============= +--获取商店插件配置 +--============= +function XSuperTowerConfigs.GetMallPluginConfig(id) + if not MallPluginConfig[id] then + XLog.ErrorTableDataNotFound( + "XSuperTowerConfigs.GetMallConfig", + "商店插件配置不存在", + TABLE_MALL, + "Id", + tostring(id)) + end + return MallPluginConfig[id] +end +--============= +--获取资源物品id数组 +--============= +function XSuperTowerConfigs.GetMainAssetsPanelItemIds() + local itemIds = {} + for i = 1, 3 do + local itemId = XSuperTowerConfigs.GetClientBaseConfigByKey(XDataCenter.SuperTowerManager.BaseCfgKey["MainAssetsPanelItem" .. i], true) + if itemId and itemId > 0 then + table.insert(itemIds, itemId) + end + end + return itemIds +end +--============= +--获取插件id是否属于角色专属槽插件 +--============= +function XSuperTowerConfigs.GetPluginIdIsCharacterSlot(pluginId) + return CharacterSpecialPluginIdDic[pluginId] or false +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XTRPGConfigs.lua b/Resources/Scripts/XConfig/XTRPGConfigs.lua new file mode 100644 index 00000000..974964c3 --- /dev/null +++ b/Resources/Scripts/XConfig/XTRPGConfigs.lua @@ -0,0 +1,2109 @@ +local tableInsert = table.insert +local ipairs = ipairs +local pairs = pairs +local stringGsub = string.gsub +local CSXTextManagerGetText = CS.XTextManager.GetText + +local TABLE_ROLE_PATH = "Share/TRPG/TRPGRole.tab" +local TABLE_ROLE_TALENT_GROUP_PATH = "Share/TRPG/RoleTalentGroup/" +local TABLE_ROLE_TALENT_GROUP_CLIENT_PATH = "Client/TRPG/TRPGTalentGroup.tab" +local TABLE_ROLE_TALENT_PATH = "Share/TRPG/TRPGRoleTalent.tab" +local TABLE_ROLE_ATTRIBUTE_PATH = "Client/TRPG/TRPGRoleAttribute.tab" +local TABLE_MAIN_AREA_PATH = "Share/TRPG/TRPGMainArea.tab" --主区域 +local TABLE_TARGET_LINK_PATH = "Share/TRPG/TRPGTargetLink.tab" --目标链表 +local TABLE_TARGET_PATH = "Share/TRPG/TRPGTarget.tab" --目标表 +local TABLE_MAZE_PATH = "Share/TRPG/TRPGMaze.tab" +local TABLE_MAZE_LAYER_PATH = "Share/TRPG/TRPGMazeLayer.tab" +local TABLE_MAZE_MAP_PATH = "Share/TRPG/MazeMap/" +local TABLE_MAZE_CARD_PATH = "Share/TRPG/TRPGMazeCard.tab" +local TABLE_MAZE_CARD_TYPE_PATH = "Client/TRPG/TRPGMazeCardType.tab" +local TABLE_MAZE_CARD_RECORD_GROUP_PATH = "Client/TRPG/TRPGMazeCardRecordGroup.tab" +local TABLE_LEVEL_PATH = "Share/TRPG/TRPGLevel.tab" +local TABLE_BUFF_PATH = "Share/TRPG/TRPGBuff.tab" +local TABLE_REWARD_PATH = "Share/TRPG/TRPGReward.tab" +local TABLE_SECOND_AREA_PATH = "Share/TRPG/TRPGSecondArea.tab" +local TABLE_THIRD_AREA_PATH = "Share/TRPG/TRPGThirdArea.tab" +local TABLE_SHOP_PATH = "Share/TRPG/TRPGShop.tab" +local TABLE_SHOP_ITEM_PATH = "Share/TRPG/TRPGShopItem.tab" +local TABLE_ITEM_PATH = "Share/TRPG/TRPGItem.tab" +local TABLE_TRUTH_ROAD_GROUP_PATH = "Share/TRPG/TruthRoad/TRPGTruthRoadGroup.tab" +local TABLE_TRUTH_ROAD_PATH = "Share/TRPG/TruthRoad/TRPGTruthRoad.tab" +local TABLE_BOSS_PATH = "Share/TRPG/Boss/TRPGBoss.tab" +local TABLE_BOSS_PHASES_REWARD = "Share/TRPG/Boss/TRPGBossPhasesReward.tab" +local TABLE_MEMOIRE_STORY = "Share/TRPG/TRPGMemoirStory.tab" +local TABLE_PANEL_PLOT_TAB_PATH = "Client/TRPG/TRPGPanelPlotTab.tab" +local TABLE_FUNCTION_GROUP_PATH = "Share/TRPG/TRPGFunctionGroup.tab" +local TABLE_FUNCTION_PATH = "Share/TRPG/TRPGFunction.tab" +local TABLE_EXAMINE_PATH = "Share/TRPG/Examine/TRPGExamine.tab" +local TABLE_EXAMINE_ACTION_PATH = "Share/TRPG/Examine/TRPGExamineAction.tab" +local TABLE_EXAMINE_ACTION_TYPE_PATH = "Client/TRPG/TRPGExamineActionType.tab" +local TABLE_EXAMINE_ACTION_DIFFICULT_PATH = "Client/TRPG/TRPGExamineActionDifficult.tab" +local TABLE_EXAMINE_PUNISH_PATH = "Share/TRPG/Examine/TRPGExaminePunish.tab" +local TABLE_BUTTON_CONDITION_PATH = "Client/TRPG/TRPGButtonCondition.tab" +local TABLE_SECOND_MAIN_PATH = "Share/TRPG/SecondMain/TRPGSecondMain.tab" +local TABLE_SECOND_MAIN_STAGE_PATH = "Share/TRPG/SecondMain/TRPGSecondMainStage.tab" + +local RoleTemplate = {} +local RoleTalentGroupTemplate = {} +local RoleTalentGroupClientTemplate = {} +local RoleTalentTemplate = {} +local RoleAttributeTemplate = {} +local MainAreaTemplate = {} +local SecondAreaTemplate = {} +local ThirdAreaTemplate = {} +local TargetLinkTemplate = {} +local TargetTemplate = {} +local RewardTemplate = {} +local MazeTemplate = {} +local MazeLayerTemplate = {} +local MazeMapTemplates = {} +local MazeCardTemplate = {} +local MazeCardTypeTemplate = {} +local MazeCardRecordGroupTemplate = {} +local LevelTemplate = {} +local BuffTemplate = {} +local ShopTemplate = {} +local ShopItemTemplate = {} +local ItemTemplate = {} +local TruthRoadGroupTemplate = {} +local TruthRoadTemplate = {} +local BossTemplate = {} +local BossPhasesRewardTemplate = {} +local MemoireStoryTemplate = {} +local PanelPlotTabTemplate = {} +local MovieIdToTargetIdDic = {} --剧情Id索引目标Id字典 +local TargetOfPreTargetList = {} --所有目标的前置目标 +local ShopItemCountList = {} --商店道具限购列表 +local FunctionGroupTemplate = {} +local FunctionTemplate = {} +local ExamineTemplate = {} +local ExamineActionTemplate = {} +local ExamineActionTypeTemplate = {} +local PunishTemplate = {} +local ExamineActionDifficultTemplate = {} +local SecondAreaIdToMazeIdDic = {} +local ButtonConditionTemplate = {} +local SecondMainTemplate = {} +local SecondMainIdList = {} +local SecondMainStageTemplate = {} + +local TruthRoadGroupMaxNum = 0 +local TargetTotalNum = 0 +local DefaultMainLineTargetDesc = CSXTextManagerGetText("TRPGDefaultMainLineTargetDesc") +local DefaultTargetDesc = CSXTextManagerGetText("TRPGDefaultTargetDesc") +local DefaultTargetName = CSXTextManagerGetText("MainLineMission") +local NotPreTargetId = CS.XGame.ClientConfig:GetInt("TRPGNotPreTargetId") +local TaskPanelNewShowTime = CS.XGame.ClientConfig:GetFloat("TRPGTaskPanelNewShowTime") + +XTRPGConfigs = XTRPGConfigs or {} + +XTRPGConfigs.RoleAttributeType = { + Power = 1, --力量 + Speed = 2, --敏捷 + Intelligence = 3, --智力 +} + +XTRPGConfigs.TRPGSecondAreaType = { + Normal = 1, --普通区域 + Maze = 2, --迷宫 +} + +XTRPGConfigs.TRPGTargetType = { + Story = 1, --剧情 + GainRole = 2, --获得探员 + FinishStage = 3, --关卡 + GainItem = 4, --获得道具 + CommitItem = 5, --交付道具 + Examine = 6, --检定事件 +} + +XTRPGConfigs.TRPGFunctionType = { + Story = 1, --完成剧情 + Shop = 2, --打开商店 + CommitItem = 3, --提交物品 + FinishStage = 4, --完成关卡 + Examine = 5, --检定事件 +} + +XTRPGConfigs.TRPGBuffEffectType = { + RoleTalent = 1, --天赋效果 + Positive = 2, --正面效果 + Negative = 3, --负面效果 +} + +XTRPGConfigs.TRPGBuffType = { + Fight = 1, --战斗buff + AttributeAdd = 2, --属性增加 + ExamineGainItem = 3, --检定获得物品 + ExamineAddWeight = 4, --检定增加权重 + SafeWeightAdd = 5, --安全权重增加 +} + +XTRPGConfigs.CardType = { + Default = 0, + Block = 1, --阻塞牌 + Pass = 2, --通行牌 + FightWin = 3, --战斗通关牌 + Story = 4, --剧情牌 + Examine = 5, --检定牌 + Reward = 6, --奖励牌 + Random = 7, --随机牌 + Skip = 8, --跳转牌 + Fight = 9, --战斗牌 + Over = 10, --结束牌 +} + +XTRPGConfigs.MissionType = { + MainLine = 1, --主线 + SubLine = 2, --支线 +} + +XTRPGConfigs.ItemType = { + Normal = 1, --普通物品 + Special = 2, --特殊物品 +} + +XTRPGConfigs.ItemEffect = { + NoEffect = 0, --无使用效果 + ClearBuff = 1, --清除角色负面buff + AddBuff = 2, --添加角色buff + AddExamineAttribute = 3, --增加检定属性 +} +XTRPGConfigs.ItemEffectDefaultItemId = -1--不选择物品的基础属性展示 + +XTRPGConfigs.MissionTypeName = { + [XTRPGConfigs.MissionType.MainLine] = CSXTextManagerGetText("MainLineMission"), + [XTRPGConfigs.MissionType.SubLine] = CSXTextManagerGetText("SubLineMission"), +} + +XTRPGConfigs.DefaultDesc = { + [XTRPGConfigs.MissionType.MainLine] = CSXTextManagerGetText("TRPGDefaultMainLineTargetDesc"), + [XTRPGConfigs.MissionType.SubLine] = CSXTextManagerGetText("TRPGDefaultTargetDesc"), +} +XTRPGConfigs.NotTargetLinkDefaultId = 0 --目标链id不存在时的默认值 + +XTRPGConfigs.AreaStateType = { + NotOpen = 1, --未解锁 + Open = 2, --已解锁 + Over = 3, --当前区域主线探索完毕 或 世界BOSS活动已结束 +} + +XTRPGConfigs.TRPGExamineActionType = { + Strength = 1, --力量检定 + Agility = 2, --敏捷检定 + Intelligence = 3, --智力检定 + ConsumeItem = 4, --道具检定 +} + +XTRPGConfigs.TRPGExamineActionDifficult = { + Default = 0, --无难度(使用道具) + Easy = 1, --简单 + Strength = 1, --普通 + Hard = 2, --困难 + UnPass = 3, --不可通过 +} + +--检定状态 +XTRPGConfigs.ExmaineStatus = { + Dead = 0, --检定数据失效,等待下一轮检定开始 + Normal = 1, --正常检定流程 + Suc = 2, --检定成功 + Fail = 3, --检定失败 +} + +--惩罚类型 +XTRPGConfigs.PunishType = { + Fight = 1, --进入战斗 + DeBuff = 2, --添加负面buff + LoseItem = 3, --丢失物品 + GoToOrigin = 4, --回到起点 +} + +--商店道具明日是否重置 +XTRPGConfigs.ShopItemResetType = { + NotReset = 0, + Reset = 1, +} + +XTRPGConfigs.ButtonConditionId = { + Talent = 1, --天赋 + Collection = 2, --珍藏 +} + +local InitRoleTalentConfigs = function() + local paths = CS.XTableManager.GetPaths(TABLE_ROLE_TALENT_GROUP_PATH) + XTool.LoopCollection(paths, function(path) + local key = XTool.GetFileNameWithoutExtension(path) + RoleTalentGroupTemplate[key] = XTableManager.ReadByIntKey(path, XTable.XTableTRPGRoleTalentGroup, "Id") + end) +end + +local InitTarget = function() + TargetTemplate = XTableManager.ReadByIntKey(TABLE_TARGET_PATH, XTable.XTableTRPGTarget, "Id") + for targetId, config in pairs(TargetTemplate) do + if config.Type == XTRPGConfigs.TRPGTargetType.Story then + local movieId = config.Params[1] + MovieIdToTargetIdDic[movieId] = targetId + end + end +end + +local InitTargetLink = function() + TargetLinkTemplate = XTableManager.ReadByIntKey(TABLE_TARGET_LINK_PATH, XTable.XTableTRPGTargetLink, "Id") + for _, v in pairs(TargetLinkTemplate) do + for targetIndex, targetId in ipairs(v.TargetId) do + if not TargetOfPreTargetList[targetId] then + TargetOfPreTargetList[targetId] = v.PreTarget[targetIndex] + TargetTotalNum = TargetTotalNum + 1 + elseif TargetOfPreTargetList[targetId] ~= v.PreTarget[targetIndex] then + XLog.Error("XTRPGConfigs InitTargetLink error:配置存在相同的TargetId且PreTarget不同,Id:" .. v.Id .. " TargetId:" .. targetId .. " PreTarget:" .. v.PreTarget[targetIndex] .. ",配置路径:" .. TABLE_TARGET_LINK_PATH) + end + end + end +end + +local InitTruthRoadGroupMaxNum = function() + for _, v in pairs(MainAreaTemplate) do + if #v.TruthRoadGroupId > TruthRoadGroupMaxNum then + TruthRoadGroupMaxNum = #v.TruthRoadGroupId + end + end +end + +local InitMazeMapConfigs = function() + local paths = CS.XTableManager.GetPaths(TABLE_MAZE_MAP_PATH) + XTool.LoopCollection(paths, function(path) + local key = XTool.GetFileNameWithoutExtension(path) + MazeMapTemplates[key] = XTableManager.ReadByIntKey(path, XTable.XTableTRPGMazeMap, "Id") + end) +end + +local InitShopItemCountList = function() + for _, v in pairs(ShopTemplate) do + ShopItemCountList[v.Id] = {} + for i, shopItemId in ipairs(v.ShopItemId) do + ShopItemCountList[v.Id][shopItemId] = v.ShopItemCount[i] + end + end +end + +local InitMazeIdList = function() + local areaType + for _, v in pairs(SecondAreaTemplate) do + areaType = XTRPGConfigs.GetSecondAreaType(v.Id) + if areaType == XTRPGConfigs.TRPGSecondAreaType.Maze and v.MazeId > 0 then + SecondAreaIdToMazeIdDic[v.Id] = v.MazeId + end + end +end + +local InitSecondMainIdList = function() + for _, v in pairs(SecondMainTemplate) do + tableInsert(SecondMainIdList, v.Id) + end +end + +function XTRPGConfigs.Init() + RoleTemplate = XTableManager.ReadByIntKey(TABLE_ROLE_PATH, XTable.XTableTRPGRole, "Id") + RoleAttributeTemplate = XTableManager.ReadByIntKey(TABLE_ROLE_ATTRIBUTE_PATH, XTable.XTableTRPGRoleAttribute, "AttrType") + RoleTalentTemplate = XTableManager.ReadByIntKey(TABLE_ROLE_TALENT_PATH, XTable.XTableTRPGRoleTalent, "Id") + RoleTalentGroupClientTemplate = XTableManager.ReadByIntKey(TABLE_ROLE_TALENT_GROUP_CLIENT_PATH, XTable.XTableTRPGRoleTalentGroupClient, "Id") + MainAreaTemplate = XTableManager.ReadByIntKey(TABLE_MAIN_AREA_PATH, XTable.XTableTRPGMainArea, "Id") + MazeTemplate = XTableManager.ReadByIntKey(TABLE_MAZE_PATH, XTable.XTableTRPGMaze, "Id") + MazeLayerTemplate = XTableManager.ReadByIntKey(TABLE_MAZE_LAYER_PATH, XTable.XTableTRPGMazeLayer, "Id") + MazeCardTemplate = XTableManager.ReadByIntKey(TABLE_MAZE_CARD_PATH, XTable.XTableTRPGMazeCard, "Id") + MazeCardTypeTemplate = XTableManager.ReadByIntKey(TABLE_MAZE_CARD_TYPE_PATH, XTable.XTableTRPGMazeCardType, "Type") + MazeCardRecordGroupTemplate = XTableManager.ReadByIntKey(TABLE_MAZE_CARD_RECORD_GROUP_PATH, XTable.XTableTRPGMazeCardRecordGroup, "Id") + LevelTemplate = XTableManager.ReadByIntKey(TABLE_LEVEL_PATH, XTable.XTableTRPGLevel, "Id") + BuffTemplate = XTableManager.ReadByIntKey(TABLE_BUFF_PATH, XTable.XTableTRPGBuff, "Id") + RewardTemplate = XTableManager.ReadByIntKey(TABLE_REWARD_PATH, XTable.XTableTRPGReward, "Id") + SecondAreaTemplate = XTableManager.ReadByIntKey(TABLE_SECOND_AREA_PATH, XTable.XTableTRPGSecondArea, "Id") + ThirdAreaTemplate = XTableManager.ReadByIntKey(TABLE_THIRD_AREA_PATH, XTable.XTableTRPGThirdArea, "Id") + ShopTemplate = XTableManager.ReadByIntKey(TABLE_SHOP_PATH, XTable.XTableTRPGShop, "Id") + ShopItemTemplate = XTableManager.ReadByIntKey(TABLE_SHOP_ITEM_PATH, XTable.XTableTRPGShopItem, "Id") + ItemTemplate = XTableManager.ReadByIntKey(TABLE_ITEM_PATH, XTable.XTableTRPGItem, "Id") + TruthRoadGroupTemplate = XTableManager.ReadByIntKey(TABLE_TRUTH_ROAD_GROUP_PATH, XTable.XTableTRPGTruthRoadGroup, "Id") + TruthRoadTemplate = XTableManager.ReadByIntKey(TABLE_TRUTH_ROAD_PATH, XTable.XTableTRPGTruthRoad, "Id") + BossTemplate = XTableManager.ReadByIntKey(TABLE_BOSS_PATH, XTable.XTableTRPGBoss, "Id") + BossPhasesRewardTemplate = XTableManager.ReadByIntKey(TABLE_BOSS_PHASES_REWARD, XTable.XTableTRPGBossPhasesReward, "Id") + MemoireStoryTemplate = XTableManager.ReadByIntKey(TABLE_MEMOIRE_STORY, XTable.XTableTRPGMemoirStory, "Id") + PanelPlotTabTemplate = XTableManager.ReadByIntKey(TABLE_PANEL_PLOT_TAB_PATH, XTable.XTableTRPGPanelPlotTab, "Id") + FunctionGroupTemplate = XTableManager.ReadByIntKey(TABLE_FUNCTION_GROUP_PATH, XTable.XTableTRPGFunctionGroup, "Id") + FunctionTemplate = XTableManager.ReadByIntKey(TABLE_FUNCTION_PATH, XTable.XTableTRPGFunction, "Id") + ExamineTemplate = XTableManager.ReadByIntKey(TABLE_EXAMINE_PATH, XTable.XTableTRPGExamine, "Id") + ExamineActionTemplate = XTableManager.ReadByIntKey(TABLE_EXAMINE_ACTION_PATH, XTable.XTableTRPGExamineAction, "Id") + ExamineActionTypeTemplate = XTableManager.ReadByIntKey(TABLE_EXAMINE_ACTION_TYPE_PATH, XTable.XTableTRPGExamineActionType, "Type") + PunishTemplate = XTableManager.ReadByIntKey(TABLE_EXAMINE_PUNISH_PATH, XTable.XTableTRPGExaminePunish, "Id") + ExamineActionDifficultTemplate = XTableManager.ReadByIntKey(TABLE_EXAMINE_ACTION_DIFFICULT_PATH, XTable.XTableTRPGExamineActionDifficult, "Difficult") + ButtonConditionTemplate = XTableManager.ReadByIntKey(TABLE_BUTTON_CONDITION_PATH, XTable.XTableTRPGButtonCondition, "Id") + SecondMainTemplate = XTableManager.ReadByIntKey(TABLE_SECOND_MAIN_PATH, XTable.XTableTRPGSecondMain, "Id") + SecondMainStageTemplate = XTableManager.ReadByIntKey(TABLE_SECOND_MAIN_STAGE_PATH, XTable.XTableTRPGSecondMainStage, "Id") + + InitRoleTalentConfigs() + InitTarget() + InitTargetLink() + InitTruthRoadGroupMaxNum() + InitMazeMapConfigs() + InitShopItemCountList() + InitMazeIdList() + InitSecondMainIdList() +end + +-----------------调查员 begin-------------------- +local GetRoleConfig = function(roleId) + local config = RoleTemplate[roleId] + if not config then + XLog.Error("XTRPGConfigs GetRoleConfig error:配置不存在, roleId: " .. roleId .. ", 配置路径: " .. TABLE_ROLE_PATH) + return + end + return config +end + +function XTRPGConfigs.GetAllRoleIds() + local roleIds = {} + for roleId in pairs(RoleTemplate) do + tableInsert(roleIds, roleId) + end + return roleIds +end + +function XTRPGConfigs.GetRoleInitAttribute(roleId, attributeType) + local config = GetRoleConfig(roleId) + return config.InitAttribute[attributeType] or 0 +end + +function XTRPGConfigs.GetRoleImage(roleId) + local config = GetRoleConfig(roleId) + return config.Image +end + +function XTRPGConfigs.GetRoleHeadIcon(roleId) + local config = GetRoleConfig(roleId) + return config.HeadIcon +end + +function XTRPGConfigs.GetRoleName(roleId) + local config = GetRoleConfig(roleId) + return config.Name +end + +function XTRPGConfigs.GetRoleDesc(roleId) + local config = GetRoleConfig(roleId) + return stringGsub(config.Description, "\\n", "\n") +end + +function XTRPGConfigs.GetRoleModelId(roleId) + local config = GetRoleConfig(roleId) + return config.ModelId +end + +--属性 begin-- +local GetRoleAttributeConfig = function(attrType) + local config = RoleAttributeTemplate[attrType] + if not config then + XLog.Error("XTRPGConfigs GetRoleAttributeConfig error:配置不存在, attrType: " .. attrType .. ", 配置路径: " .. TABLE_ROLE_ATTRIBUTE_PATH) + return + end + return config +end + +function XTRPGConfigs.GetRoleAttributeName(attrType) + local config = GetRoleAttributeConfig(attrType) + return config.Name +end + +function XTRPGConfigs.GetRoleAttributeIcon(attrType) + local config = GetRoleAttributeConfig(attrType) + return config.Icon +end + +function XTRPGConfigs.GetRoleAttributeMaxValue(attrType) + local config = GetRoleAttributeConfig(attrType) + return config.MaxValue +end +--属性 end-- +--天赋 begin-- +local function GetRoleTalentGroupId(roleId) + local config = GetRoleConfig(roleId) + local talentId = config.TalentGroupId + if not talentId or talentId == 0 then + XLog.Error("XTRPGConfigs GetRoleTalentGroupId error:角色天赋Id未配置, roleId: " .. roleId .. ", 配置路径: " .. TABLE_ROLE_PATH) + return + end + return talentId +end + +local GetRoleTalentGroupConfig = function(talentGroupId) + local config = RoleTalentGroupTemplate[tostring(talentGroupId)] + if not config then + XLog.Error("XTRPGConfigs GetRoleTalentGroupConfig error:配置不存在, talentGroupId: " .. talentGroupId .. ", 配置路径: " .. TABLE_ROLE_TALENT_GROUP_PATH) + return + end + return config +end + +function XTRPGConfigs.GetRoleTalentGroupConfig(roleId) + local talentGroupId = GetRoleTalentGroupId(roleId) + return GetRoleTalentGroupConfig(talentGroupId) +end + +local GetRoleTalentConfig = function(roleId, talentId) + local talentGroupId = GetRoleTalentGroupId(roleId) + local configs = GetRoleTalentGroupConfig(talentGroupId) + local config = configs[talentId] + if not config then + XLog.Error("XTRPGConfigs GetRoleTalentConfig error:配置不存在, talentId: " .. talentId .. ", 配置路径: " .. TABLE_ROLE_TALENT_GROUP_PATH) + return + end + return config +end + +function XTRPGConfigs.GetRoleTalentPreId(roleId, talentId) + local config = GetRoleTalentConfig(roleId, talentId) + return config.PreId +end + +function XTRPGConfigs.GetRoleTalentCostPoint(roleId, talentId) + local config = GetRoleTalentConfig(roleId, talentId) + return config.CostPoint +end + +function XTRPGConfigs.GetRoleTalentDescription(roleId, talentId) + local config = GetRoleTalentConfig(roleId, talentId) + return stringGsub(config.Description, "\\n", "\n") +end + +function XTRPGConfigs.GetRoleTalentTitle(roleId, talentId) + local config = GetRoleTalentConfig(roleId, talentId) + return config.Title +end + +function XTRPGConfigs.GetRoleTalentIcon(roleId, talentId) + local config = GetRoleTalentConfig(roleId, talentId) + return config.Icon +end + +function XTRPGConfigs.GetRoleTalentIntro(roleId, talentId) + local config = GetRoleTalentConfig(roleId, talentId) + return stringGsub(config.Intro, "\\n", "\n") +end + +function XTRPGConfigs.IsRoleTalentCommonForShow(roleId, talentId) + local config = GetRoleTalentConfig(roleId, talentId) + return config.IsCommonForShow ~= 0 +end + +local GetRoleTalentDefaultConfig = function() + local config = RoleTalentTemplate[1] + if not config then + XLog.Error("XTRPGConfigs GetRoleTalentDefaultConfig error:配置不存在, 配置路径: " .. TABLE_ROLE_TALENT_PATH) + return + end + return config +end + +function XTRPGConfigs.GetTalentResetCostItemId() + local config = GetRoleTalentDefaultConfig() + return config.ResetTalentItemId +end + +function XTRPGConfigs.GetTalentResetCostItemIcon() + local costItemId = XTRPGConfigs.GetTalentResetCostItemId() + return XItemConfigs.GetItemIconById(costItemId) +end + +function XTRPGConfigs.GetTalentResetCostItemCount() + local config = GetRoleTalentDefaultConfig() + return config.ResetTalentItemCount +end + +function XTRPGConfigs.GetTalentPointIcon() + local config = GetRoleTalentDefaultConfig() + return config.TalentPointIcon +end + +local GetRoleTalentGroupClientConfig = function(talentGroupId) + local config = RoleTalentGroupClientTemplate[talentGroupId] + if not config then + XLog.Error("XTRPGConfigs GetRoleTalentGroupClientConfig error:配置不存在, talentGroupId: " .. talentGroupId .. ", 配置路径: " .. TABLE_ROLE_TALENT_GROUP_CLIENT_PATH) + return + end + return config +end + +function XTRPGConfigs.GetRoleTalentTreePrefab(roleId) + local talentGroupId = GetRoleTalentGroupId(roleId) + local config = GetRoleTalentGroupClientConfig(talentGroupId) + return config.Prefab +end +--天赋 end-- +--BUFF begin-- +local GetBuffConfig = function(buffId) + local config = BuffTemplate[buffId] + if not config then + XLog.Error("XTRPGConfigs GetBuffConfig error:配置不存在, buffId: " .. buffId .. ", 配置路径: " .. TABLE_BUFF_PATH) + return + end + return config +end + +function XTRPGConfigs.IsBuffUp(buffId) + local config = GetBuffConfig(buffId) + return config.EffectType == XTRPGConfigs.TRPGBuffEffectType.Positive +end + +function XTRPGConfigs.IsBuffDown(buffId) + local config = GetBuffConfig(buffId) + return config.EffectType == XTRPGConfigs.TRPGBuffEffectType.Negative +end + +function XTRPGConfigs.GetBuffIcon(buffId) + local config = GetBuffConfig(buffId) + return config.Icon +end + +function XTRPGConfigs.GetBuffName(buffId) + local config = GetBuffConfig(buffId) + return config.Name +end + +function XTRPGConfigs.GetBuffDesc(buffId) + local config = GetBuffConfig(buffId) + return stringGsub(config.Desc, "\\n", "\n") +end +--BUFF end-- +-----------------调查员 end-------------------- +-----------------求真之路begin-------------- +local GetTruthRoadGroupConfig = function(id) + local config = TruthRoadGroupTemplate[id] + if not config then + XLog.Error("XTRPGConfigs GetTruthRoadGroupConfig error:配置不存在, Id: " .. id .. ", 配置路径: " .. TABLE_TRUTH_ROAD_GROUP_PATH) + return + end + return config +end + +local GetTruthRoadConfig = function(id) + local config = TruthRoadTemplate[id] + if not config then + XLog.Error("XTRPGConfigs GetTruthRoadConfig error:配置不存在, Id: " .. id .. ", 配置路径: " .. TABLE_TRUTH_ROAD_PATH) + return + end + return config +end + +function XTRPGConfigs.GetTruthRoadGroupTemplate() + return TruthRoadGroupTemplate +end + +function XTRPGConfigs.GetTruthRoadRewardIdList(truthRoadGroupId) + local truthRoadIdList = XTRPGConfigs.GetTruthRoadIdList(truthRoadGroupId) + local trpgRewardId + local trpgRewardIdList = {} + for _, truthRoadId in pairs(truthRoadIdList) do + trpgRewardId = XTRPGConfigs.GetTruthRoadTRPGRewardId(truthRoadId) + if trpgRewardId and trpgRewardId > 0 then + table.insert(trpgRewardIdList, trpgRewardId) + end + end + return trpgRewardIdList +end + +--返回求真之路奖励可领取的进度 +function XTRPGConfigs.GetTruthRoadRewardRecivePercent(truthRoadGroupId, trpgRewardId) + local truthRoadIdList = XTRPGConfigs.GetTruthRoadIdList(truthRoadGroupId) + local truthRoadMaxNum = #truthRoadIdList + local trpgRewardIdCfg + for i, truthRoadId in ipairs(truthRoadIdList) do + trpgRewardIdCfg = XTRPGConfigs.GetTruthRoadTRPGRewardId(truthRoadId) + if trpgRewardIdCfg == trpgRewardId then + return i / truthRoadMaxNum + end + end + return 0 +end + +function XTRPGConfigs.GetTruthRoadGroupName(truthRoadGroupId) + local config = GetTruthRoadGroupConfig(truthRoadGroupId) + return config.Name +end + +function XTRPGConfigs.GetTruthRoadGroupPrefab(truthRoadGroupId) + local config = GetTruthRoadGroupConfig(truthRoadGroupId) + return config.Prefab +end + +function XTRPGConfigs.GetTruthRoadGroupCondition(truthRoadGroupId) + local config = GetTruthRoadGroupConfig(truthRoadGroupId) + return config.Condition +end + +function XTRPGConfigs.GetTruthRoadGroupSmallName(truthRoadGroupId) + local config = GetTruthRoadGroupConfig(truthRoadGroupId) + return config.SmallName +end + +function XTRPGConfigs.GetTruthRoadIdList(truthRoadGroupId) + local config = GetTruthRoadGroupConfig(truthRoadGroupId) + return config.TruthRoadId +end + +function XTRPGConfigs.GetTruthRoadName(id) + local config = GetTruthRoadConfig(id) + return config.Name +end + +function XTRPGConfigs.GetTruthRoadPrafabName(id) + local config = GetTruthRoadConfig(id) + return config.PrefabName +end + +function XTRPGConfigs.GetTruthRoadTRPGRewardId(id) + local config = GetTruthRoadConfig(id) + return config.TRPGRewardId +end + +function XTRPGConfigs.GetTruthRoadCondition(id) + local config = GetTruthRoadConfig(id) + return config.Condition +end + +function XTRPGConfigs.GetTruthRoadIcon(id) + local config = GetTruthRoadConfig(id) + return config.Icon +end + +function XTRPGConfigs.GetTruthRoadDesc(id) + local config = GetTruthRoadConfig(id) + return config.Desc +end + +function XTRPGConfigs.GetTruthRoadStageId(id) + local config = GetTruthRoadConfig(id) + return config.StageId +end + +function XTRPGConfigs.GetTruthRoadStoryId(id) + local config = GetTruthRoadConfig(id) + return config.StoryId +end + +function XTRPGConfigs.GetTruthRoadDialogIcon(id) + local config = GetTruthRoadConfig(id) + return config.DialogIcon +end +-----------------求真之路end---------------- +-----------------主区域begin---------------- +local GetMainAreaConfig = function(id) + local config = MainAreaTemplate[id] + if not config then + XLog.Error("XTRPGConfigs GetMainAreaConfig error:配置不存在, Id: " .. id .. ", 配置路径: " .. TABLE_MAIN_AREA_PATH) + return + end + return config +end + +function XTRPGConfigs.GetMainAreaName(id) + local config = GetMainAreaConfig(id) + return config.Name +end + +function XTRPGConfigs.GetSecondAreaIdList(id) + local config = GetMainAreaConfig(id) + return config.SubAreaId +end + +function XTRPGConfigs.GetTargetLinkIdList(id) + local config = GetMainAreaConfig(id) + return config.TargetLinkId +end + +function XTRPGConfigs.GetAreaOpenLastTimeStamp(id) + local config = GetMainAreaConfig(id) + local timeId = config.OpenTimeId + local openTimestamp = XFunctionManager.GetStartTimeByTimeId(timeId) + local serverTimestamp = XTime.GetServerNowTimestamp() + return openTimestamp - serverTimestamp +end + +function XTRPGConfigs.GetTargetLinkId(areaId, targetLinkIndex) + local targetLinkIdList = XTRPGConfigs.GetTargetLinkIdList(areaId) + return targetLinkIdList[targetLinkIndex] +end + +function XTRPGConfigs.GetTruthRoadGroupMaxNum() + return TruthRoadGroupMaxNum +end + +function XTRPGConfigs.GetMainAreaMaxNum() + return #MainAreaTemplate +end + +function XTRPGConfigs.GetAreaRewardIdList(areaId) + local config = GetMainAreaConfig(areaId) + return config.TRPGRewardId +end + +function XTRPGConfigs.GetTruthRoadGroupIdList(areaId) + local config = GetMainAreaConfig(areaId) + return config.TruthRoadGroupId +end + +function XTRPGConfigs.GetTruthRoadGroupId(areaId, index) + local truthRoadGroupIdList = XTRPGConfigs.GetTruthRoadGroupIdList(areaId) + local truthRoadGroupId = truthRoadGroupIdList[index] + return truthRoadGroupId +end + +function XTRPGConfigs.GetTruthRoadTabBg(areaId) + local config = GetMainAreaConfig(areaId) + return config.TruthRoadTabBg +end + +function XTRPGConfigs.GetSecondAreaBg(areaId) + local config = GetMainAreaConfig(areaId) + return config.SubAreaBg +end + +function XTRPGConfigs.GetTruthRoadBg(areaId) + local config = GetMainAreaConfig(areaId) + return config.TruthRoadBg +end + +function XTRPGConfigs.GetMainAreaEnName(areaId) + local config = GetMainAreaConfig(areaId) + return config.EnName +end + +function XTRPGConfigs.GetMainAreaFirstOpenFunctionGroupId(areaId) + local config = GetMainAreaConfig(areaId) + return config.FirstOpenFunctionGroupId +end + +function XTRPGConfigs.GetMainAreaTemplate() + return MainAreaTemplate +end + +function XTRPGConfigs.GetMainAreaCondition(areaId) + local config = GetMainAreaConfig(areaId) + return config.Condition +end +-----------------主区域end------------------ +-----------------第二区域begin---------------- +local GetSecondAreaConfig = function(id) + local config = SecondAreaTemplate[id] + if not config then + XLog.Error("XTRPGConfigs GetSecondAreaConfig error:配置不存在, Id: " .. id .. ", 配置路径: " .. TABLE_SECOND_AREA_PATH) + return + end + return config +end + +function XTRPGConfigs.GetSecondAreaName(id) + local config = GetSecondAreaConfig(id) + return config.Name +end + +function XTRPGConfigs.GetExploreChapterBg(id) + local config = GetSecondAreaConfig(id) + return config.SubAreaBg +end + +function XTRPGConfigs.GetSecondAreaType(id) + local config = GetSecondAreaConfig(id) + return config.Type +end + +function XTRPGConfigs.GetSecondAreaMazeId(id) + local config = GetSecondAreaConfig(id) + return config.MazeId +end + +function XTRPGConfigs.GetThirdAreaIdList(id) + local config = GetSecondAreaConfig(id) + return config.SubAreaId +end + +function XTRPGConfigs.GetSecondAreaCondition(id) + local config = GetSecondAreaConfig(id) + return config.Condition +end + +function XTRPGConfigs.GetSecondAreaIdToMazeIdDic() + return SecondAreaIdToMazeIdDic +end +-----------------第二区域end---------------- +-----------------第三区域 begin---------------- +local GetThirdAreaConfig = function(thirdAreaId) + local config = ThirdAreaTemplate[thirdAreaId] + if not config then + XLog.Error("XTRPGConfigs GetThirdAreaConfig error:配置不存在, Id: " .. thirdAreaId .. ", 配置路径: " .. TABLE_THIRD_AREA_PATH) + return + end + return config +end + +function XTRPGConfigs.GetThirdAreaName(thirdAreaId) + local config = GetThirdAreaConfig(thirdAreaId) + return config.Name +end + +function XTRPGConfigs.GetThirdAreaCondition(id) + local config = GetThirdAreaConfig(id) + return config.Condition +end + +function XTRPGConfigs.GetThirdAreaIcon(id) + local config = GetThirdAreaConfig(id) + return config.Icon +end + +function XTRPGConfigs.GetThirdAreaFuncGroupList(id) + local config = GetThirdAreaConfig(id) + return config.FuncGroup +end +-----------------第三区域end---------------- +function XTRPGConfigs.GetThirdAreaEnName(thirdAreaId) + local config = GetThirdAreaConfig(thirdAreaId) + return config.EnName +end + +function XTRPGConfigs.GetThirdAreaIcon(thirdAreaId) + local config = GetThirdAreaConfig(thirdAreaId) + return config.Icon +end + +function XTRPGConfigs.GetThirdAreaBg(thirdAreaId) + local config = GetThirdAreaConfig(thirdAreaId) + return config.Bg +end + +function XTRPGConfigs.GetThirdAreaFunctionGroupIds(thirdAreaId) + local functionGroupIds = {} + + local config = GetThirdAreaConfig(thirdAreaId) + for _, groupId in ipairs(config.FuncGroup) do + if groupId ~= 0 then + tableInsert(functionGroupIds, groupId) + end + end + + return functionGroupIds +end + +local GetFunctionGroupConfig = function(functionGroupId) + local config = FunctionGroupTemplate[functionGroupId] + if not config then + XLog.Error("XTRPGConfigs GetFunctionGroupConfig error:配置不存在, Id: " .. functionGroupId .. ", 配置路径: " .. TABLE_FUNCTION_GROUP_PATH) + return + end + return config +end + +function XTRPGConfigs.GetFunctionGroupConditionId(functionGroupId) + local config = GetFunctionGroupConfig(functionGroupId) + return config.Condition +end + +function XTRPGConfigs.GetFunctionGroupFunctionIds(functionGroupId) + local config = GetFunctionGroupConfig(functionGroupId) + return config.FunctionId +end + +local GetFunctionConfig = function(functionId) + local config = FunctionTemplate[functionId] + if not config then + XLog.Error("XTRPGConfigs GetFunctionConfig error:配置不存在, Id: " .. functionId .. ", 配置路径: " .. TABLE_FUNCTION_PATH) + return + end + return config +end + +function XTRPGConfigs.GetFunctionStageIds() + local stageIds = {} + + for functionId, config in pairs(FunctionTemplate) do + if XTRPGConfigs.CheckFunctionType(functionId, XTRPGConfigs.TRPGFunctionType.FinishStage) then + local stageId = config.Params[1] + stageIds[stageId] = stageId + end + end + + return stageIds +end + +function XTRPGConfigs.GetFunctionIcon(functionId) + local config = GetFunctionConfig(functionId) + return config.Icon +end + +function XTRPGConfigs.CheckFunctionNeedSave(functionId) + local config = GetFunctionConfig(functionId) + return config.NeedSave ~= 0 +end + +function XTRPGConfigs.GetFunctionDesc(functionId) + local config = GetFunctionConfig(functionId) + return stringGsub(config.Desc, "\\n", "\n") +end + +local function GetFunctionType(functionId) + local config = GetFunctionConfig(functionId) + return config.Type +end + +function XTRPGConfigs.CheckFunctionType(functionId, functionType) + return GetFunctionType(functionId) == functionType +end + +function XTRPGConfigs.GetFunctionParams(functionId) + local config = GetFunctionConfig(functionId) + return config.Params +end + +function XTRPGConfigs.IsFunctionShowTag(functionId) + return XTRPGConfigs.CheckFunctionType(functionId, XTRPGConfigs.TRPGFunctionType.Examine) +end +-----------------第三区域 end---------------- +-----------------检定相关 begin---------------- +local GetExamineConfig = function(examineId) + local config = ExamineTemplate[examineId] + if not config then + XLog.Error("XTRPGConfigs GetExamineConfig error:配置不存在, Id: " .. examineId .. ", 配置路径: " .. TABLE_EXAMINE_PATH) + return + end + return config +end + +function XTRPGConfigs.GetExamineCostEndurance(examineId) + local config = GetExamineConfig(examineId) + return config.Endurance +end + +function XTRPGConfigs.GetExamineTitle(examineId) + local config = GetExamineConfig(examineId) + return config.Title +end + +function XTRPGConfigs.GetExamineDescription(examineId) + local config = GetExamineConfig(examineId) + return stringGsub(config.Description, "\\n", "\n") +end + +function XTRPGConfigs.GetExamineSucDesc(examineId) + local config = GetExamineConfig(examineId) + return stringGsub(config.SucDesc, "\\n", "\n") +end + +function XTRPGConfigs.GetExamineFailDesc(examineId) + local config = GetExamineConfig(examineId) + return stringGsub(config.FailDesc, "\\n", "\n") +end + +function XTRPGConfigs.GetExamineStartMovieId(examineId) + local config = GetExamineConfig(examineId) + return config.StartMovieId +end + +function XTRPGConfigs.GetExamineActionIds(examineId) + local actionIds = {} + local config = GetExamineConfig(examineId) + for _, actionId in pairs(config.ActionId) do + if actionId ~= 0 then + tableInsert(actionIds, actionId) + end + end + return actionIds +end + +local GetExamineActionConfig = function(actionId) + local config = ExamineActionTemplate[actionId] + if not config then + XLog.Error("XTRPGConfigs GetExamineActionConfig error:配置不存在, Id: " .. actionId .. ", 配置路径: " .. TABLE_EXAMINE_ACTION_PATH) + return + end + return config +end + +function XTRPGConfigs.GetExamineActionDesc(actionId) + local config = GetExamineActionConfig(actionId) + return config.Desc +end + +function XTRPGConfigs.GetExamineActionItemId(actionId) + local config = GetExamineActionConfig(actionId) + return config.ItemId +end + +function XTRPGConfigs.GetExamineActionItemIcon(actionId) + local itemId = XTRPGConfigs.GetExamineActionItemId(actionId) + return XItemConfigs.GetItemIconById(itemId) +end + +function XTRPGConfigs.GetExamineActionItemName(actionId) + local itemId = XTRPGConfigs.GetExamineActionItemId(actionId) + return XItemConfigs.GetItemNameById(itemId) +end + +function XTRPGConfigs.GetExamineActionRound(actionId) + local config = GetExamineActionConfig(actionId) + return config.Round +end + +function XTRPGConfigs.GetExamineActionNeedValue(actionId) + local config = GetExamineActionConfig(actionId) + return config.NeedValue +end + +function XTRPGConfigs.GetExamineActionResetCostItemInfo(actionId) + local config = GetExamineActionConfig(actionId) + return config.ResetCostId, config.ResetCostCount +end + +local function GetExamineActionType(actionId) + local config = GetExamineActionConfig(actionId) + return config.Type +end + +function XTRPGConfigs.CheckExamineActionType(actionId, actionType) + return GetExamineActionType(actionId) == actionType +end + +local ActionTypeToAttrType = { + [XTRPGConfigs.TRPGExamineActionType.Strength] = XTRPGConfigs.RoleAttributeType.Power, + [XTRPGConfigs.TRPGExamineActionType.Agility] = XTRPGConfigs.RoleAttributeType.Speed, + [XTRPGConfigs.TRPGExamineActionType.Intelligence] = XTRPGConfigs.RoleAttributeType.Intelligence, +} +function XTRPGConfigs.GetExamineActionNeedAttrType(actionId) + local actionType = GetExamineActionType(actionId) + return ActionTypeToAttrType[actionType] +end + +local GetExamineActionTypeConfig = function(actionType) + local config = ExamineActionTypeTemplate[actionType] + if not config then + XLog.Error("XTRPGConfigs GetExamineActionTypeConfig error:配置不存在, Id: " .. actionType .. ", 配置路径: " .. TABLE_EXAMINE_ACTION_TYPE_PATH) + return + end + return config +end + +function XTRPGConfigs.GetExamineActionIcon(actionId) + if XTRPGConfigs.CheckExamineActionType(actionId, XTRPGConfigs.TRPGExamineActionType.ConsumeItem) then + return XTRPGConfigs.GetExamineActionItemIcon(actionId) + end + + local actionType = GetExamineActionType(actionId) + local config = GetExamineActionTypeConfig(actionType) + return config.Icon +end + +function XTRPGConfigs.GetExamineActionTypeDesc(actionId) + if XTRPGConfigs.CheckExamineActionType(actionId, XTRPGConfigs.TRPGExamineActionType.ConsumeItem) then + return CSXTextManagerGetText("TRPGExploreExmaineUseItem") + end + + local actionType = GetExamineActionType(actionId) + local config = GetExamineActionTypeConfig(actionType) + return config.Desc +end + +function XTRPGConfigs.GetExamineActionTypeDescEn(actionId) + local actionType = GetExamineActionType(actionId) + local config = GetExamineActionTypeConfig(actionType) + return config.DescEn +end + +function XTRPGConfigs.GetExamineActionTypeDefaultItemDesc(actionId) + local actionType = GetExamineActionType(actionId) + local config = GetExamineActionTypeConfig(actionType) + return config.DefaultItemDesc +end + +function XTRPGConfigs.GetExamineActionTypeRangeDesc(actionId) + if XTRPGConfigs.CheckExamineActionType(actionId, XTRPGConfigs.TRPGExamineActionType.ConsumeItem) then + return "" + end + + local actionType = GetExamineActionType(actionId) + local config = GetExamineActionTypeConfig(actionType) + return config.RangeDesc +end + +function XTRPGConfigs.GetExamineActionTypeAttrDesc(actionId) + if XTRPGConfigs.CheckExamineActionType(actionId, XTRPGConfigs.TRPGExamineActionType.ConsumeItem) then + return "" + end + + local actionType = GetExamineActionType(actionId) + local config = GetExamineActionTypeConfig(actionType) + return config.AttrDesc +end + +local GetExamineDifficultConfig = function(actionDifficult) + local config = ExamineActionDifficultTemplate[actionDifficult] + if not config then + XLog.Error("XTRPGConfigs GetExamineDifficultConfig error:配置不存在, Id: " .. actionDifficult .. ", 配置路径: " .. TABLE_EXAMINE_ACTION_DIFFICULT_PATH) + return + end + return config +end + +function XTRPGConfigs.GetExamineActionDifficultByDelta(delta) + for difficult, config in ipairs(ExamineActionDifficultTemplate) do + if delta >= config.Delta then + return difficult + end + end + return #ExamineActionDifficultTemplate +end + +function XTRPGConfigs.GetExamineActionDifficultDesc(actionDifficult) + if actionDifficult == XTRPGConfigs.TRPGExamineActionDifficult.Default then + return "" + end + + local config = GetExamineDifficultConfig(actionDifficult) + return config.Desc +end +-----------------检定相关 end---------------- +-----------------惩罚相关 end---------------- +local GetPunishConfig = function(punishId) + local config = PunishTemplate[punishId] + if not config then + XLog.Error("XTRPGConfigs GetPunishConfig error:配置不存在, Id: " .. punishId .. ", 配置路径: " .. TABLE_EXAMINE_PUNISH_PATH) + return + end + return config +end + +function XTRPGConfigs.CheckPunishType(punishId, punishType) + return GetPunishConfig(punishId).Type == punishType +end + +function XTRPGConfigs.GetPunishDesc(punishId) + local config = GetPunishConfig(punishId) + return stringGsub(config.Desc, "\\n", "\n") +end + +function XTRPGConfigs.GetPunishParams(punishId) + local config = GetPunishConfig(punishId) + return config.Params +end +-----------------惩罚相关 end---------------- +-----------------目标链表begin---------------- +local GetTargetLinkConfig = function(id) + local config = TargetLinkTemplate[id] + if not config then + XLog.Error("XTRPGConfigs GetTargetLinkConfig error:配置不存在, Id: " .. id .. ", 配置路径: " .. TABLE_TARGET_LINK_PATH) + return + end + return config +end + +function XTRPGConfigs.GetTargetLinkTemplate() + return TargetLinkTemplate +end + +function XTRPGConfigs.GetTargetLink(id) + return GetTargetLinkConfig(id) +end + +function XTRPGConfigs.GetTargetLinkName(id) + if not id or id == NotPreTargetId then + return DefaultTargetName + end + local config = GetTargetLinkConfig(id) + return config.Name +end + +function XTRPGConfigs.GetTargetIdList(id) + local config = GetTargetLinkConfig(id) + return config.TargetId +end + +function XTRPGConfigs.GetTargetId(id, index) + local targetIdList = XTRPGConfigs.GetTargetIdList(id) + return targetIdList[index] +end + +function XTRPGConfigs.GetRewardIdList(id) + local config = GetTargetLinkConfig(id) + return config.RewardId +end + +function XTRPGConfigs.GetTargetOfPreTargetList() + return TargetOfPreTargetList +end + +function XTRPGConfigs.GetPreTargetByTargetId(targetId) + local targetOfPreTargetList = XTRPGConfigs.GetTargetOfPreTargetList() + if not targetOfPreTargetList[targetId] then + XLog.Error("当前目标没有前置目标,目标id:" .. targetId .. ",检查配置路径:" .. TABLE_TARGET_LINK_PATH) + return + end + return targetOfPreTargetList[targetId] +end + +function XTRPGConfigs.GetNotPreTargetId() + return NotPreTargetId +end + +function XTRPGConfigs.GetTargetLinkMissionType(id) + if not id or id == NotPreTargetId then + return XTRPGConfigs.MissionType.MainLine + end + local config = GetTargetLinkConfig(id) + return config.TargetMissionType +end + +function XTRPGConfigs.GetTargetLinkMissionTypeName(missionType) + return XTRPGConfigs.MissionTypeName[missionType] +end +-----------------目标链表end------------------ +-----------------目标表begin---------------- +local GetTargetConfig = function(id) + local config = TargetTemplate[id] + if not config then + XLog.Error("XTRPGConfigs GetTargetConfig error:配置不存在, Id: " .. id .. ", 配置路径: " .. TABLE_TARGET_PATH) + return + end + return config +end + +function XTRPGConfigs.GetMovieTargetId(movieId) + return MovieIdToTargetIdDic[movieId] +end + +function XTRPGConfigs.GetTargetTemplate() + return TargetTemplate +end + +function XTRPGConfigs.GetTarget(id) + return GetTargetConfig(id) +end + +function XTRPGConfigs.GetTargetPrefabName(id) + local config = GetTargetConfig(id) + return config.PrefabName +end + +function XTRPGConfigs.GetTargetIcon(id) + local config = GetTargetConfig(id) + return config.Icon +end + +function XTRPGConfigs.GetTargetName(id) + if not id or id == NotPreTargetId then + return DefaultTargetName + end + local config = GetTargetConfig(id) + return config.Name +end + +function XTRPGConfigs.GetTargetDesc(targetId, targetLinkId) + if XDataCenter.TRPGManager.IsTargetAllFinish() then + return DefaultTargetDesc + end + if not targetId or targetId == NotPreTargetId then + local missionType = XTRPGConfigs.GetTargetLinkMissionType(targetLinkId) + return XTRPGConfigs.DefaultDesc[missionType] + end + + local config = GetTargetConfig(targetId) + return config.Desc +end + +function XTRPGConfigs.GetTargetTotalNum() + return TargetTotalNum +end + +function XTRPGConfigs.GetTargetAreaIcon(targetId) + if not targetId or targetId == NotPreTargetId then + return "" + end + local config = GetTargetConfig(targetId) + return config.AreaIcon +end + +function XTRPGConfigs.GetTargetCardIcon(targetId) + if not targetId or targetId == NotPreTargetId then + return + end + local config = GetTargetConfig(targetId) + return config.CardIcon +end + +function XTRPGConfigs.GetTaskPanelNewShowTime() + return TaskPanelNewShowTime +end +-----------------目标表end---------------- +-----------------奖励表begin-------------------- +local GetRewardConfig = function(id) + local config = RewardTemplate[id] + if not config then + XLog.Error("XTRPGConfigs GetRewardConfig error:配置不存在, Id: " .. id .. ", 配置路径: " .. TABLE_REWARD_PATH) + return + end + return config +end + +function XTRPGConfigs.GetRewardCondition(id) + local config = GetRewardConfig(id) + return config.Condition +end + +function XTRPGConfigs.GetRewardId(id) + local config = GetRewardConfig(id) + return config.RewardId +end + +function XTRPGConfigs.GetRewardReceiveDesc(id) + local config = GetRewardConfig(id) + return config.ReceiveDesc +end + +function XTRPGConfigs.GetSecondMainReceiveDesc(id) + local config = GetRewardConfig(id) + return config.SecondMainReceiveDesc +end +-----------------奖励表end---------------------- +-----------------道具表begin-------------------- +local GetItemConfig = function(id) + local config = ItemTemplate[id] + if not config then + XLog.Error("XTRPGConfigs GetItemConfig error:配置不存在, Id: " .. id .. ", 配置路径: " .. TABLE_ITEM_PATH) + return + end + return config +end + +local CheckItemConfig = function(id) + return ItemTemplate[id] and true or false +end +XTRPGConfigs.CheckItemConfig = CheckItemConfig + +function XTRPGConfigs.IsItemPrecious(id) + local config = GetItemConfig(id) + return config.ItemType == XTRPGConfigs.ItemType.Special +end + +function XTRPGConfigs.GetItemTagIcon(id) + local config = GetItemConfig(id) + return config.TagIcon +end + +function XTRPGConfigs.GetItemParamDesc(itemId) + local config = GetItemConfig(itemId) + return config.Desc +end + +function XTRPGConfigs.CheckItemAddAttributeType(itemId, attrType) + local config = GetItemConfig(itemId) + return config.Params[1] == attrType +end + +function XTRPGConfigs.GetItemAddAttribute(itemId) + if XTRPGConfigs.CheckDefaultEffectItemId(itemId) then return 0 end + local config = GetItemConfig(itemId) + return config.Params[2] +end + +function XTRPGConfigs.GetItemMaxCount(id) + if not CheckItemConfig(id) then + return XDataCenter.ItemManager.GetMaxCount(id) + end + + local config = GetItemConfig(id) + return config.Capacity +end + +function XTRPGConfigs.GetItemType(id) + local config = GetItemConfig(id) + return config.ItemType +end + +function XTRPGConfigs.CheckItemEffectType(itemId, effectType) + local config = GetItemConfig(itemId) + return config.EffectType == effectType +end + +function XTRPGConfigs.CheckDefaultEffectItemId(itemId) + return itemId == XTRPGConfigs.ItemEffectDefaultItemId +end + +function XTRPGConfigs.GetExamineBuffItemIds(actionId) + local itemIds = {} + + local attrType = XTRPGConfigs.GetExamineActionNeedAttrType(actionId) + for itemId in pairs(ItemTemplate) do + if XTRPGConfigs.CheckItemEffectType(itemId, XTRPGConfigs.ItemEffect.AddExamineAttribute) + and XTRPGConfigs.CheckItemAddAttributeType(itemId, attrType) then + tableInsert(itemIds, itemId) + end + end + tableInsert(itemIds, XTRPGConfigs.ItemEffectDefaultItemId) + + return itemIds +end + +function XTRPGConfigs.GetItemParams(id) + local config = GetItemConfig(id) + return config.Params +end + +function XTRPGConfigs.GetItemEffectType(id) + local config = GetItemConfig(id) + return config.EffectType +end + +--道具是否需要选择角色使用 +function XTRPGConfigs.IsItemSelectCharacter(id) + local effectType = XTRPGConfigs.GetItemEffectType(id) + if effectType == XTRPGConfigs.ItemEffect.ClearBuff or effectType == XTRPGConfigs.ItemEffect.AddBuff then + return true + end + return false +end + +function XTRPGConfigs.IsItemShowUse(id) + local itemType = XTRPGConfigs.GetItemType(id) + local itemEffectType = XTRPGConfigs.GetItemEffectType(id) + return itemType ~= XTRPGConfigs.ItemType.Special and itemEffectType ~= XTRPGConfigs.ItemEffect.AddExamineAttribute +end +-----------------道具表end---------------------- +-----------------商店begin-------------------- +local GetShopConfig = function(id) + local config = ShopTemplate[id] + if not config then + XLog.Error("XTRPGConfigs GetShopConfig error:配置不存在, Id: " .. id .. ", 配置路径: " .. TABLE_SHOP_PATH) + return + end + return config +end + +function XTRPGConfigs.GetShopItemIdList(id) + local config = GetShopConfig(id) + return config.ShopItemId +end + +function XTRPGConfigs.GetShopItemCount(shopId, shopItemId) + return ShopItemCountList[shopId] and ShopItemCountList[shopId][shopItemId] or 0 +end + +local GetShopItemConfig = function(id) + local config = ShopItemTemplate[id] + if not config then + XLog.Error("XTRPGConfigs GetShopItemConfig error:配置不存在, Id: " .. id .. ", 配置路径: " .. TABLE_SHOP_ITEM_PATH) + return + end + return config +end + +function XTRPGConfigs.GetShopItemRewardId(id) + local config = GetShopItemConfig(id) + return config.RewardId +end + +function XTRPGConfigs.GetShopItemCondition(id) + local config = GetShopItemConfig(id) + return config.Condition +end + +function XTRPGConfigs.GetShopItemConsumeId(id) + local config = GetShopItemConfig(id) + return config.ConsumeId +end + +function XTRPGConfigs.GetShopItemConsumeCount(id) + local config = GetShopItemConfig(id) + return config.ConsumeCount +end + +function XTRPGConfigs.GetShopItemDesc(id) + local config = GetShopItemConfig(id) + return config.Desc +end + +--返回外部道具表的id +function XTRPGConfigs.GetItemIdByShopItemId(shopItemId) + local rewardId = XTRPGConfigs.GetShopItemRewardId(shopItemId) + local rewardGoodsId = XRewardManager.GetRewardSubId(rewardId, 1) + local rewardList = XRewardManager.GetRewardList(rewardId) + return rewardList[1].TemplateId +end + +function XTRPGConfigs.GetItemResetType(id) + local config = GetShopItemConfig(id) + return config.ResetType +end +-----------------商店end---------------------- +-----------------迷宫 begin---------------------- +local GetMazeConfig = function(mazeId) + local config = MazeTemplate[mazeId] + if not config then + XLog.Error("XTRPGConfigs GetMazeConfig error:配置不存在, mazeId: " .. mazeId .. ", 配置路径: " .. TABLE_MAZE_PATH) + return + end + return config +end + +function XTRPGConfigs.GetMazeIds() + return MazeTemplate +end + +function XTRPGConfigs.GetMazeLayerIds(mazeId) + local config = GetMazeConfig(mazeId) + return config.LayerId +end + +function XTRPGConfigs.GetMazeName(mazeId) + local config = GetMazeConfig(mazeId) + return config.Name +end + +function XTRPGConfigs.GetMazeStartLayerId(mazeId) + local config = GetMazeConfig(mazeId) + return config.StartLayerId +end + +local GetMazeLayerConfig = function(layerId) + local config = MazeLayerTemplate[layerId] + if not config then + XLog.Error("XTRPGConfigs GetMazeLayerConfig error:配置不存在, layerId: " .. layerId .. ", 配置路径: " .. TABLE_MAZE_LAYER_PATH) + return + end + return config +end + +local GetMazeLayerMapId = function(layerId) + local config = GetMazeLayerConfig(layerId) + local mapId = config.MapId + if not mapId or mapId == 0 then + XLog.Error("XTRPGConfigs GetMazeLayerMapId error:配置不存在, layerId: " .. layerId .. ", 配置路径: " .. TABLE_MAZE_LAYER_PATH) + return + end + return mapId +end + +function XTRPGConfigs.GetMazeLayerBgImage(mazeId) + local config = GetMazeLayerConfig(mazeId) + return config.BgImage +end + +function XTRPGConfigs.GetMazeLayerName(layerId) + local config = GetMazeLayerConfig(layerId) + return config.Name +end + +function XTRPGConfigs.GetMazeLayerStartNodeId(layerId) + local config = GetMazeLayerConfig(layerId) + return config.StartNodeId +end + +function XTRPGConfigs.GetMazeLayerStartCardIndex(layerId) + local config = GetMazeLayerConfig(layerId) + return config.StartCardIndex +end + +local GetMazeMapConfigs = function(mapId) + local configs = MazeMapTemplates[tostring(mapId)] + if not configs then + XLog.Error("XTRPGConfigs GetMazeMapConfigs error:配置不存在, mapId: " .. mapId .. ", 配置路径: " .. TABLE_MAZE_MAP_PATH) + return + end + return configs +end + +function XTRPGConfigs.GetMazeMapConfigs(layerId) + local mapId = GetMazeLayerMapId(layerId) + return GetMazeMapConfigs(mapId) +end + +local GetMazeCardConfig = function(cardId) + local config = MazeCardTemplate[cardId] + if not config then + XLog.Error("XTRPGConfigs GetMazeCardConfig error:配置不存在, cardId: " .. cardId .. ", 配置路径: " .. TABLE_MAZE_CARD_PATH) + return + end + return config +end + +function XTRPGConfigs.GetMazeCardType(cardId) + local config = GetMazeCardConfig(cardId) + return config.Type +end + +function XTRPGConfigs.CheckMazeCardType(cardId, paramCardType) + local cardType = XTRPGConfigs.GetMazeCardType(cardId) + return cardType == paramCardType +end + +function XTRPGConfigs.GetMazeCardConvertCardId(cardId) + local config = GetMazeCardConfig(cardId) + return config.ConvertCardId +end + +function XTRPGConfigs.GetMazeCardParam(cardId) + local config = GetMazeCardConfig(cardId) + return config.Param +end + +function XTRPGConfigs.GetMazeCardOrder(cardId) + local config = GetMazeCardConfig(cardId) + return config.Order +end + +function XTRPGConfigs.IsMazeCardShowTag(cardId) + local config = GetMazeCardConfig(cardId) + return config.ShowTag ~= 0 +end + +function XTRPGConfigs.GetMazeCardName(cardId) + local config = GetMazeCardConfig(cardId) + return config.Name +end + +function XTRPGConfigs.GetMazeCardFightDes(cardId) + local config = GetMazeCardConfig(cardId) + return stringGsub(config.FightDes, "\\n", "\n") +end + +function XTRPGConfigs.GetMazeCardQuickFightDes(cardId) + local config = GetMazeCardConfig(cardId) + return stringGsub(config.QuickFightDes, "\\n", "\n") +end + +function XTRPGConfigs.GetMazeCardIcon(cardId) + if not XTRPGConfigs.IsIconFromConfig(cardId) then return end + local config = GetMazeCardConfig(cardId) + return config.Icon +end + +function XTRPGConfigs.GetMazeCardMovieId(cardId) + if not XTRPGConfigs.CheckMazeCardType(cardId,XTRPGConfigs.CardType.FightWin) then return end + local config = GetMazeCardConfig(cardId) + return config.MovieId +end + +function XTRPGConfigs.GetMazeCardIconR(cardId) + if not XTRPGConfigs.IsIconFromConfig(cardId) then return end + local config = GetMazeCardConfig(cardId) + return config.IconR +end + +function XTRPGConfigs.GetMazeCardMiniIcon(cardId) + local config = GetMazeCardConfig(cardId) + return config.MiniIcon +end + +function XTRPGConfigs.IsMazeCardDisposeable(cardId) + local config = GetMazeCardConfig(cardId) + return config.Disposeable ~= 0 +end + +function XTRPGConfigs.IsMazeCardSingleDisposeable(cardId) + local config = GetMazeCardConfig(cardId) + return config.SingleDisposeable ~= 0 +end + +function XTRPGConfigs.GetMazeCardRecordGroupId(cardId) + local config = GetMazeCardConfig(cardId) + return config.RecordGroupId +end + +local GetMazeCardTypeConfig = function(cardType) + local config = MazeCardTypeTemplate[cardType] + if not config then + XLog.Error("XTRPGConfigs GetMazeCardTypeConfig error:配置不存在, cardType: " .. cardType .. ", 配置路径: " .. TABLE_MAZE_CARD_TYPE_PATH) + return + end + return config +end + +--预制体中预设好的的卡牌图片不需要读配置 +function XTRPGConfigs.IsIconFromConfig(cardId) + local cardType = XTRPGConfigs.GetMazeCardType(cardId) + + -- 满纸荒唐言 + -- if cardType == XTRPGConfigs.CardType.Block + -- if cardType == XTRPGConfigs.CardType.Random + -- then + -- return false + -- end + return true +end + +function XTRPGConfigs.GetMazeCardPrefab(cardId) + local cardType = XTRPGConfigs.GetMazeCardType(cardId) + local config = GetMazeCardTypeConfig(cardType) + return config.Prefab +end + +function XTRPGConfigs.GetMazeCardTypeIcon(cardId) + local cardType = XTRPGConfigs.GetMazeCardType(cardId) + local config = GetMazeCardTypeConfig(cardType) + return config.Icon +end + +local GetMazeCardRecordGroupConfig = function(cardRecordGroupId) + local config = MazeCardRecordGroupTemplate[cardRecordGroupId] + if not config then + XLog.Error("XTRPGConfigs GetMazeCardRecordGroupConfig error:配置不存在, cardRecordGroupId: " .. cardRecordGroupId .. ", 配置路径: " .. TABLE_MAZE_CARD_RECORD_GROUP_PATH) + return + end + return config +end + +function XTRPGConfigs.GetMazeCardRecordGroupMiniIcon(cardRecordGroupId) + local config = GetMazeCardRecordGroupConfig(cardRecordGroupId) + return config.MiniIcon +end + +function XTRPGConfigs.GetMazeCardRecordGroupName(cardRecordGroupId) + local config = GetMazeCardRecordGroupConfig(cardRecordGroupId) + return config.Name +end + +function XTRPGConfigs.GetMazeCardRecordGroupIdList() + local cardRecordGroupIds = {} + for id in pairs(MazeCardRecordGroupTemplate) do + tableInsert(cardRecordGroupIds, id) + end + return cardRecordGroupIds +end +-----------------迷宫 end---------------------- +-----------------等级 begin---------------------- +local GetLevelConfig = function(level) + local config = LevelTemplate[level] + if not config then + XLog.Error("XTRPGConfigs GetLevelConfig error:配置不存在, level: " .. level .. ", 配置路径: " .. TABLE_LEVEL_PATH) + return + end + return config +end + +function XTRPGConfigs.GetMaxExp(level) + local config = GetLevelConfig(level) + return config.UpExp +end + +function XTRPGConfigs.GetMaxTalentPoint(level) + local config = GetLevelConfig(level) + return config.TalentPoint +end + +function XTRPGConfigs.IsMaxLevel(level) + local maxExp = XTRPGConfigs.GetMaxExp(level) + return maxExp == 0 +end +-----------------等级 end---------------------- +-----------------世界BOSS begin---------------- +local GetBossConfig = function(id) + local config = BossTemplate[id] + if not config then + XLog.Error("XTRPGConfigs GetBossConfig error:配置不存在, id: " .. id .. ", 配置路径: " .. TABLE_BOSS_PATH) + return + end + return config +end + +function XTRPGConfigs.GetBossModelId() + local config = GetBossConfig(1) + return config.ModelId +end + +function XTRPGConfigs.GetBossTimeId() + local config = GetBossConfig(1) + return config.TimeId +end + +function XTRPGConfigs.GetBossChallengeCount() + local config = GetBossConfig(1) + return config.ChallengeCount +end + +function XTRPGConfigs.GetBossDesc() + local config = GetBossConfig(1) + return config.Desc +end + +function XTRPGConfigs.GetBossStageId() + local config = GetBossConfig(1) + return config.StageId +end + +function XTRPGConfigs.IsBossStage(stageId) + local bossStageId = XTRPGConfigs.GetBossStageId() + return bossStageId == stageId +end + +function XTRPGConfigs.GetBossStartStoryId() + local config = GetBossConfig(1) + return config.StartStoryId +end + +function XTRPGConfigs.GetBossHideEntranceTimeStr() + local config = GetBossConfig(1) + return config.HideEntranceTimeStr +end + +local GetBossPhasesRewardConfig = function(id) + local config = BossPhasesRewardTemplate[id] + if not config then + XLog.Error("XTRPGConfigs GetBossPhasesRewardConfig error:配置不存在, id: " .. id .. ", 配置路径: " .. TABLE_BOSS_PHASES_REWARD) + return + end + return config +end + +function XTRPGConfigs.GetBossPhasesRewardMaxNum() + return #BossPhasesRewardTemplate +end + +function XTRPGConfigs.GetBossPhasesRewardPercent(id) + local config = BossPhasesRewardTemplate[id] + return config.Percent +end + +function XTRPGConfigs.GetBossPhasesRewardId(id) + local config = BossPhasesRewardTemplate[id] + return config.RewardId +end + +function XTRPGConfigs.GetBossIcon(id) + local config = BossPhasesRewardTemplate[id] + return config.Icon +end + +function XTRPGConfigs.GetBossPhasesRewardTemplate() + return BossPhasesRewardTemplate +end +-----------------世界BOSS end------------------ +-----------------珍藏-回忆 begin--------------- +local GetMemoireStoryConfig = function(id) + local config = MemoireStoryTemplate[id] + if not config then + XLog.Error("XTRPGConfigs GetMemoireStoryConfig error:配置不存在, id: " .. id .. ", 配置路径: " .. TABLE_MEMOIRE_STORY) + return + end + return config +end + +function XTRPGConfigs.GetMemoirStoryMaxNum() + return #MemoireStoryTemplate +end + +function XTRPGConfigs.GetMemoirStoryTemplate() + return MemoireStoryTemplate +end + +function XTRPGConfigs.GetMemoireStoryId(id) + local config = GetMemoireStoryConfig(id) + return config.StoryId +end + +function XTRPGConfigs.GetMemoireStoryUnlockItemId(id) + local config = GetMemoireStoryConfig(id) + return config.UnlockItemId +end + +function XTRPGConfigs.GetMemoireStoryUnlockItemCount(id) + local config = GetMemoireStoryConfig(id) + return config.UnlockItemCount +end + +function XTRPGConfigs.GetMemoireStoryTabName(id) + local config = GetMemoireStoryConfig(id) + return config.TabName +end + +function XTRPGConfigs.GetMemoireStoryName(id) + local config = GetMemoireStoryConfig(id) + return config.Name +end + +function XTRPGConfigs.GetMemoireStoryDesc(id) + local config = GetMemoireStoryConfig(id) + local desc = config.Desc + return string.gsub(desc, "\\n", "\n") +end + +function XTRPGConfigs.GetMemoireStoryImgCG(id) + local config = GetMemoireStoryConfig(id) + return config.ImgCG +end +-----------------珍藏-回忆 end--------------- +-----------------TRPGSecondMain begin--------------- +local GetSecondMainConfig = function(id) + local config = SecondMainTemplate[id] + if not config then + XLog.Error("XTRPGConfigs GetSecondMainConfig error:配置不存在, id: " .. id .. ", 配置路径: " .. TABLE_SECOND_MAIN_PATH) + return + end + return config +end + +function XTRPGConfigs.GetSecondMainIdList() + return SecondMainIdList +end + +function XTRPGConfigs.GetSecondMainCondition(id) + local config = GetSecondMainConfig(id) + return config.Condition +end + +function XTRPGConfigs.GetSecondMainStageId(id) + local config = GetSecondMainConfig(id) + return config.SecondMainStageId +end + +function XTRPGConfigs.GetSecondMainPrefab(id) + local config = GetSecondMainConfig(id) + return config.Prefab +end + +function XTRPGConfigs.GetSecondMainBG(id) + local config = GetSecondMainConfig(id) + return config.BG +end +-----------------TRPGSecondMain end----------------- +-----------------TRPGSecondMainStage begin--------------- +local GetSecondMainStageConfig = function(id) + local config = SecondMainStageTemplate[id] + if not config then + XLog.Error("XTRPGConfigs GetSecondMainStageConfig error:配置不存在, id: " .. id .. ", 配置路径: " .. TABLE_SECOND_MAIN_STAGE_PATH) + return + end + return config +end + +function XTRPGConfigs.GetSecondMainStageName(id) + local config = GetSecondMainStageConfig(id) + return config.Name +end + +function XTRPGConfigs.GetSecondMainStageDesc(id) + local config = GetSecondMainStageConfig(id) + return config.Desc +end + +function XTRPGConfigs.GetSecondMainStageIcon(id) + local config = GetSecondMainStageConfig(id) + return config.Icon +end + +function XTRPGConfigs.GetSecondMainStageStageId(id) + local config = GetSecondMainStageConfig(id) + return config.StageId +end + +function XTRPGConfigs.GetSecondMainStageStoryId(id) + local config = GetSecondMainStageConfig(id) + return config.StoryId +end + +function XTRPGConfigs.GetSecondMainStageDialogIcon(id) + local config = GetSecondMainStageConfig(id) + return config.DialogIcon +end + +function XTRPGConfigs.GetSecondMainStageRewardId(id) + local config = GetSecondMainStageConfig(id) + return config.TRPGRewardId +end + +function XTRPGConfigs.GetSecondMainStageCondition(id) + local config = GetSecondMainStageConfig(id) + return config.Condition +end + +function XTRPGConfigs.GetSecondMainStagePrefabName(id) + local config = GetSecondMainStageConfig(id) + return config.PrefabName +end + +function XTRPGConfigs.GetSecondMainStageRewardIdList(secondMainId) + local secondMainStageIdList = XTRPGConfigs.GetSecondMainStageId(secondMainId) + local trpgRewardId + local trpgRewardIdList = {} + for _, secondMainStageId in ipairs(secondMainStageIdList) do + trpgRewardId = XTRPGConfigs.GetSecondMainStageRewardId(secondMainStageId) + if XTool.IsNumberValid(trpgRewardId) then + table.insert(trpgRewardIdList, trpgRewardId) + end + end + return trpgRewardIdList +end + +--返回常规主线奖励可领取的进度 +function XTRPGConfigs.GetSecondMainRewardRecivePercent(secondMainId, trpgRewardId) + local secondMainStageIdList = XTRPGConfigs.GetSecondMainStageId(secondMainId) + local secondMainStageMaxNum = #secondMainStageIdList + local trpgRewardIdCfg + for i, secondMainStageId in ipairs(secondMainStageIdList) do + trpgRewardIdCfg = XTRPGConfigs.GetSecondMainStageRewardId(secondMainStageId) + if trpgRewardIdCfg == trpgRewardId then + return i / secondMainStageMaxNum + end + end + return 0 +end +-----------------TRPGSecondMainStage end----------------- +-----------------客户端配置-求真之路和探索营地标签 begin------------- +local GetPanelPlotTabConfig = function(id) + local config = PanelPlotTabTemplate[id] + if not config then + XLog.Error("XTRPGConfigs GetPanelPlotTabConfig error:配置不存在, id: " .. id .. ", 配置路径: " .. TABLE_PANEL_PLOT_TAB_PATH) + return + end + return config +end + +function XTRPGConfigs.GetPanelPlotTabTemplate() + return PanelPlotTabTemplate +end + +function XTRPGConfigs.GetPanelPlotTabName(id) + local config = GetPanelPlotTabConfig(id) + return config.Name +end + +function XTRPGConfigs.GetPanelPlotTabBg(id) + local config = GetPanelPlotTabConfig(id) + return config.Bg +end + +function XTRPGConfigs.GetPanelPlotTabOpenUiName(id) + local config = GetPanelPlotTabConfig(id) + return config.OpenUiName +end + +function XTRPGConfigs.CheckPanelPlotTabCondition(id) + local config = GetPanelPlotTabConfig(id) + local condition = config.Condition + if condition == 0 then + return true, "" + end + return XConditionManager.CheckCondition(condition) +end +-----------------客户端配置-求真之路和探索营地标签 end------------- +-----------------客户端配置-按钮条件 begin------------- +local GetButtonConditionConfig = function(id) + local config = ButtonConditionTemplate[id] + if not config then + XLog.Error("XTRPGConfigs GetButtonConditionConfig error:配置不存在, id: " .. id .. ", 配置路径: " .. TABLE_BUTTON_CONDITION_PATH) + return + end + return config +end + +function XTRPGConfigs.CheckButtonCondition(id) + local config = GetButtonConditionConfig(id) + local condition = config.Condition + if condition == 0 then + return true, "" + end + return XConditionManager.CheckCondition(condition) +end +-----------------客户端配置-按钮条件 end------------- \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XTaskConfig.lua b/Resources/Scripts/XConfig/XTaskConfig.lua new file mode 100644 index 00000000..056f09b7 --- /dev/null +++ b/Resources/Scripts/XConfig/XTaskConfig.lua @@ -0,0 +1,217 @@ +XTaskConfig = XTaskConfig or {} + +XTaskConfig.ActivenessRewardType = { + Daily = 1, + Weekly = 2, + Newbie = 3 +} + +XTaskConfig.PANELINDEX = { + Story = 1, + Daily = 2, +} + +local TaskTemplate = {} +local TaskActivenessTemplate = {} +local NewPlayerTaskGroupTemplate = {} +local NewPlayerTaskTalkTemplate = {} +local TaskNewbieActivenessTemplate = {} +local CourseTemplate = {} +local DailyActivenessTemplate = {} +local WeeklyActivenessTemplate = {} +local TimeLimitTaskTemplate = {} +local TimeLimitDailyTasksCheckTable = {} +local TimeLimitWeeklyTasksCheckTable = {} +local TaskConditionTemplate = {} +local AlarmClockTemplate = {} + +local DailyActivenessTotal = 0 + +local TABLE_TASK_PATH = "Share/Task/Task.tab" +local TABLE_TASK_ACTIVENESS_PATH = "Share/Task/TaskActiveness.tab" +local TABLE_NEW_PLAYER_TASK_GROUP_PATH = "Share/Task/NewPlayerTaskGroup.tab" +local TABLE_NEW_PLAYER_TASK_TALK_PATH = "Client/Task/NewPlayerTaskTalk.tab" +local TABLE_TASK_COURSE_PATH = "Share/Task/Course.tab" +local TABLE_TASK_TIME_LIMIT_PATH = "Share/Task/TaskTimeLimit.tab" +local TABLE_TASK_CONDITION_PATH = "Share/Task/Condition.tab" +local TABLE_ALARMCLOCK_PATH = "Share/AlarmClock/AlarmClock.tab" +local NextTaskIds = {} + +local function SetNextTaskId() + for id, task in pairs(TaskTemplate) do + NextTaskIds[task.ShowAfterTaskId] = id + end +end + +-- 限时任务类型中每日/周刷新的打上标记 +local function InitTimeLimitWithRefreshableTasks() + for _, config in pairs(TimeLimitTaskTemplate) do + for _, taskId in pairs(config.DayTaskId) do + TimeLimitDailyTasksCheckTable[taskId] = true + end + for _, taskId in pairs(config.WeekTaskId) do + TimeLimitWeeklyTasksCheckTable[taskId] = true + end + end +end + +function XTaskConfig.Init() + TaskTemplate = XTableManager.ReadByIntKey(TABLE_TASK_PATH, XTable.XTableTask, "Id") + TaskConditionTemplate = XTableManager.ReadByIntKey(TABLE_TASK_CONDITION_PATH, XTable.XTableTaskCondition, "Id") + SetNextTaskId() + TaskActivenessTemplate = XTableManager.ReadByIntKey(TABLE_TASK_ACTIVENESS_PATH, XTable.XTableTaskActiveness, "Type") + NewPlayerTaskGroupTemplate = XTableManager.ReadByIntKey(TABLE_NEW_PLAYER_TASK_GROUP_PATH, XTable.XTableNewPlayerTaskGroup, "Id") + NewPlayerTaskTalkTemplate = XTableManager.ReadByIntKey(TABLE_NEW_PLAYER_TASK_TALK_PATH, XTable.XTableNewPlayerTaskTalk, "Id") + CourseTemplate = XTableManager.ReadByIntKey(TABLE_TASK_COURSE_PATH, XTable.XTableCourse, "StageId") + TimeLimitTaskTemplate = XTableManager.ReadByIntKey(TABLE_TASK_TIME_LIMIT_PATH, XTable.XTableTaskTimeLimit, "Id") + AlarmClockTemplate = XTableManager.ReadByIntKey(TABLE_ALARMCLOCK_PATH, XTable.XTableAlarmClock, "ClockId") + InitTimeLimitWithRefreshableTasks() + + DailyActivenessTemplate = TaskActivenessTemplate[XTaskConfig.ActivenessRewardType.Daily] + WeeklyActivenessTemplate = TaskActivenessTemplate[XTaskConfig.ActivenessRewardType.Weekly] + TaskNewbieActivenessTemplate = TaskActivenessTemplate[XTaskConfig.ActivenessRewardType.Newbie] + + local count = #DailyActivenessTemplate.Activeness + DailyActivenessTotal = DailyActivenessTemplate.Activeness[count] +end + +----------------------------------------- 配置表对外暴露的get方法开始 ----------------------------------------- +function XTaskConfig.GetTaskTemplate() + return TaskTemplate +end + +function XTaskConfig.GetTaskCfgById(id) + return TaskTemplate[id] +end + +function XTaskConfig.GetTaskRewardId(id) + return TaskTemplate[id].RewardId +end + +function XTaskConfig.GetCourseTemplate() + return CourseTemplate +end + +function XTaskConfig.GetNewPlayerTaskGroupTemplate() + return NewPlayerTaskGroupTemplate +end + +function XTaskConfig.GetNewPlayerTaskTalkTemplate() + return NewPlayerTaskTalkTemplate +end + +function XTaskConfig.GetTaskNewbieActivenessTemplate() + return TaskNewbieActivenessTemplate +end + +----------------------------------------- 配置表对外暴露的get方法结束 ----------------------------------------- +function XTaskConfig.GetNextTaskId(id) + return NextTaskIds[id] +end + +function XTaskConfig.GetDailyActivenessTotal() + return DailyActivenessTotal +end + +function XTaskConfig.GetDailyActiveness() + return DailyActivenessTemplate.Activeness +end + +function XTaskConfig.GetDailyActivenessRewardIds() + return DailyActivenessTemplate.RewardId +end + +function XTaskConfig.GetWeeklyActiveness() + return WeeklyActivenessTemplate.Activeness +end + +function XTaskConfig.GetWeeklyActivenessRewardIds() + return WeeklyActivenessTemplate.RewardId +end + +function XTaskConfig.GetTimeLimitTaskCfg(id) + local cfg = TimeLimitTaskTemplate[id] + if not cfg then + XLog.ErrorTableDataNotFound("XTaskConfig.GetTimeLimitTaskCfg", "TaskTimeLimit", TABLE_TASK_TIME_LIMIT_PATH, "Id", tostring(id)) + return + end + return cfg +end + +function XTaskConfig.IsTimeLimitTaskOffLine(id) + local timeId = XTaskConfig.GetTimeLimitTaskTimeId(id) + return not timeId or timeId == 0 +end + +function XTaskConfig.IsTimeLimitTaskInTime(id) + if XTaskConfig.IsTimeLimitTaskOffLine(id) then return false end + local config = XTaskConfig.GetTimeLimitTaskCfg(id) + return XFunctionManager.CheckInTimeByTimeId(config.TimeId) +end + +function XTaskConfig.GetTimeLimitTaskTimeId(id) + local config = XTaskConfig.GetTimeLimitTaskCfg(id) + return config.TimeId +end + +function XTaskConfig.GetTimeLimitTaskTime(id) + if XTaskConfig.IsTimeLimitTaskOffLine(id) then + return + end + + local timeId = XTaskConfig.GetTimeLimitTaskTimeId(id) + if not timeId then + return + end + + return XFunctionManager.GetTimeByTimeId(timeId) +end + +function XTaskConfig.GetTimeLimitDailyTasksCheckTable() + return TimeLimitDailyTasksCheckTable +end + +function XTaskConfig.GetTimeLimitWeeklyTasksCheckTable() + return TimeLimitWeeklyTasksCheckTable +end + +function XTaskConfig.GetTaskCondition(conditionId) + return TaskConditionTemplate[conditionId] +end + +function XTaskConfig.GetAlarmClockById(id) + local template = AlarmClockTemplate[id] + if not template then + XLog.ErrorTableDataNotFound("XTaskConfig.GetAlarmClockById", "AlarmClock", TABLE_ALARMCLOCK_PATH, "Id", tostring(id)) + return + end + return template +end + +function XTaskConfig.GetTaskCoursePath() + return TABLE_TASK_COURSE_PATH +end + +function XTaskConfig.GetTaskPath() + return TABLE_TASK_PATH +end + +function XTaskConfig.GetTaskConditionConfigs(taskId) + local result = {} + local taskConfig = XTaskConfig.GetTaskCfgById(taskId) + for _, conditionId in ipairs(taskConfig.Condition) do + table.insert(result, XTaskConfig.GetTaskCondition(conditionId)) + end + return result +end + +function XTaskConfig.GetTaskConfigById(id) + local taskCfg = TaskTemplate[id] + + if not taskCfg then + XLog.Error("读取配置表" .. TABLE_TASK_PATH .. "出错") + return + end + + return taskCfg +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XTaskForceConfigs.lua b/Resources/Scripts/XConfig/XTaskForceConfigs.lua new file mode 100644 index 00000000..434bd593 --- /dev/null +++ b/Resources/Scripts/XConfig/XTaskForceConfigs.lua @@ -0,0 +1,76 @@ +XTaskForceConfigs = XTaskForceConfigs or {} + + +--派遣表 +local TABLE_TASKFORCE_CONFIG = "Share/TaskForce/TaskForceConfig.tab" +local TABLE_TASKFORCE_EXPEND = "Share/TaskForce/TaskForceExpend.tab" +local TABLE_TASKFORCE_SECTION = "Share/TaskForce/TaskForceSection.tab" +local TABLE_TASKFORCE_TASKPOOL = "Share/TaskForce/TaskForceTaskPool.tab" + +local TaskForceConfig = {} +local TaskForceExpendConfig = {} +local TaskForceSectionConfig = {} +local TaskForceTaskPoolConfig = {} +local TaskForceCountConfig = {} + +local MaxRefreshTimes = 0 --最大刷新次数,可以超过 +local TotalFreeRefreshTimes = 0 -- 总的免费次数 +local TotalSectionCount = 0 -- 总的章节数 + +--初始化表 +function XTaskForceConfigs.Init() + TaskForceConfig = XTableManager.ReadByIntKey(TABLE_TASKFORCE_CONFIG, XTable.XTableTaskForceConfig, "Id") + TaskForceExpendConfig = XTableManager.ReadByIntKey(TABLE_TASKFORCE_EXPEND, XTable.XTableTaskForceExpend, "RefreshCount") + TaskForceSectionConfig = XTableManager.ReadByIntKey(TABLE_TASKFORCE_SECTION, XTable.XTableTaskForceSection, "Id") + TaskForceTaskPoolConfig = XTableManager.ReadByIntKey(TABLE_TASKFORCE_TASKPOOL, XTable.XTableTaskForceTask, "Id") + + --初始化刷新花费相关 + if TaskForceExpendConfig then + TotalFreeRefreshTimes = 0 + for k, v in pairs(TaskForceExpendConfig) do + if k > MaxRefreshTimes then + MaxRefreshTimes = k + end + + if v.ItemCount == 0 then + TotalFreeRefreshTimes = TotalFreeRefreshTimes + 1 + end + end + end + + if TaskForceSectionConfig then + TotalSectionCount = #TaskForceSectionConfig + end + + --用MaxTaskForceCount作为key + if TaskForceConfig then + for _, v in pairs(TaskForceConfig) do + TaskForceCountConfig[v.MaxTaskForceCount] = v + end + end + + XTaskForceConfigs.MaxRefreshTimes = MaxRefreshTimes + XTaskForceConfigs.TotalFreeRefreshTimes = TotalFreeRefreshTimes + XTaskForceConfigs.TotalSectionCount = TotalSectionCount +end + +XTaskForceConfigs.GetTaskForceConfig = function() + return TaskForceConfig +end + +XTaskForceConfigs.GetTaskForceExpendConfig = function() + return TaskForceExpendConfig +end + +XTaskForceConfigs.GetTaskForceSectionConfig = function() + return TaskForceSectionConfig +end + +XTaskForceConfigs.GetTaskForceTaskPoolConfig = function() + return TaskForceTaskPoolConfig +end + +XTaskForceConfigs.GetTaskForceCountConfig = function() + return TaskForceCountConfig +end + diff --git a/Resources/Scripts/XConfig/XTeamConfig.lua b/Resources/Scripts/XConfig/XTeamConfig.lua new file mode 100644 index 00000000..f98e31cb --- /dev/null +++ b/Resources/Scripts/XConfig/XTeamConfig.lua @@ -0,0 +1,53 @@ +XTeamConfig = XTeamConfig or {} + +local TABLE_TEAMTYPE = "Share/Team/TeamType.tab" +local TABLE_PATH = "Share/Team/Team.tab" +local TeamTypeCfg +local TeamCfg +local TeamTypeDic = {} + +function XTeamConfig.Init() + TeamTypeCfg = XTableManager.ReadByIntKey(TABLE_TEAMTYPE, XTable.XTableTeamType, "TeamId") + TeamCfg = XTableManager.ReadByIntKey(TABLE_PATH, XTable.XTableTeam, "Id") + if TeamTypeCfg == nil then + XLog.Error("XTeamManager Init 错误, 配置表读取失败, 配置表的路径是: " .. TABLE_TEAMTYPE) + return + end + + XTeamConfig.ConstructTeamCfg() +end + + +function XTeamConfig.ConstructTeamCfg() + TeamTypeDic = {} + for _, tcfg in pairs(TeamTypeCfg) do + local typeId = tcfg.TypeId + if typeId > 0 then + if TeamTypeDic[typeId] == nil then + TeamTypeDic[typeId] = {} + end + + table.insert(TeamTypeDic[typeId], tcfg) + end + end +end + +function XTeamConfig.GetTeamCfg() + return TeamCfg +end + +function XTeamConfig.GetTeamCfgById(id) + return TeamCfg[id] +end + +function XTeamConfig.GetTeamTypeCfg(type) + return TeamTypeCfg[type] +end + +-- 通过类型获取限定的队伍配置 +function XTeamConfig.GetTeamsByTypeId(typeId) + if TeamTypeDic[typeId] == nil then + return nil + end + return TeamTypeDic[typeId] +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XTrialConfigs.lua b/Resources/Scripts/XConfig/XTrialConfigs.lua new file mode 100644 index 00000000..746e3591 --- /dev/null +++ b/Resources/Scripts/XConfig/XTrialConfigs.lua @@ -0,0 +1,85 @@ +XTrialConfigs = XTrialConfigs or {} +local TABLE_LIKE_TRIALCHALLENGE = "Share/Fuben/Trial/TrialChallenge.tab" +local TABLE_LIKE_TRIALTYPEREWARD = "Share/Fuben/Trial/TrialTypeReward.tab" + +local TrialChallengeConfig = {} +local TrialTypeRewardConfig = {} + +function XTrialConfigs.Init() + -- 读TrialChallenge表 + local challengeData = XTableManager.ReadByIntKey(TABLE_LIKE_TRIALCHALLENGE, XTable.XTableTrialChallenge, "Id") + for _, v in pairs(challengeData) do + if TrialChallengeConfig[v.Type] == nil then + TrialChallengeConfig[v.Type] = {} + end + table.insert(TrialChallengeConfig[v.Type], v) + end + + --读TrialTypeReward表 + local typerewardData = XTableManager.ReadByIntKey(TABLE_LIKE_TRIALTYPEREWARD, XTable.XTableTrialTypeReward, "Type") + for _, v in pairs(typerewardData) do + TrialTypeRewardConfig[v.Type] = v + end + +end + +-- 取回所有前段关卡的数据 +function XTrialConfigs.GetForTotalData() + return TrialChallengeConfig[1] +end + +-- 取回所有后段关卡的数据 +function XTrialConfigs.GetBackEndTotalData() + return TrialChallengeConfig[2] +end + +-- 取前段第level个关卡的数据 +function XTrialConfigs.GetForDataByLevel(level) + local cfg = XTrialConfigs.GetForTotalData() + return cfg[level] +end + +-- 取后段第level个关卡的数据 +function XTrialConfigs.GetBackEndDataByLevel(level) + local cfg = XTrialConfigs.GetBackEndTotalData() + return cfg[level] +end + +-- 取所有类型的数据 +function XTrialConfigs.GetTotalTrialTypeCfg() + return TrialTypeRewardConfig +end + +-- 通过trialtype取类型的数据 +function XTrialConfigs.GetTrialTypeCfg(trialtype) + return TrialTypeRewardConfig[trialtype] +end + +-- 取回所有前段关卡总长度 +function XTrialConfigs.GetForTotalLength() + return #TrialChallengeConfig[1] +end + +-- 取回所有后段关卡总长度 +function XTrialConfigs.GetBackEndTotalLength() + return #TrialChallengeConfig[2] +end + +--根据stageid取回数据 +function XTrialConfigs.GetCfgDataByStageId(stageid) + local forcfg = XTrialConfigs.GetForTotalData() + + for _, v in pairs(forcfg) do + if v.StageId == stageid then + return v + end + end + + local endcfg = XTrialConfigs.GetBackEndTotalData() + + for _, v in pairs(endcfg) do + if v.StageId == stageid then + return v + end + end +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XUiConfigs.lua b/Resources/Scripts/XConfig/XUiConfigs.lua new file mode 100644 index 00000000..0bbd0929 --- /dev/null +++ b/Resources/Scripts/XConfig/XUiConfigs.lua @@ -0,0 +1,46 @@ +XUiConfigs = XUiConfigs or {} + +local TABLE_UICOMPONENT_PATH = "Client/Ui/UiComponent.tab" +--local TABLE_UI_PATH = "Client/Ui/Ui.tab" +local UiComponentTemplates = {} +--local UiTemplates = {} + +--UI界面枚举 处理打开这个界面的界面类型 +XUiConfigs.OpenUiType = { + NieRCharacterUI = 1, +} + +function XUiConfigs.Init() + UiComponentTemplates = XTableManager.ReadByStringKey(TABLE_UICOMPONENT_PATH, XTable.XTableUiComponent, "Key") + -- UiTemplates = XTableManager.ReadByStringKey(TABLE_UI_PATH, XTable.XTableUi, "UiName") +end + +function XUiConfigs.GetComponentUrl(key) + local template = UiComponentTemplates[key] + + if not template then + XLog.ErrorTableDataNotFound("XUiConfigs.GetComponentUrl", "UiComponent", TABLE_UICOMPONENT_PATH, "key", key) + return + end + + return template.PrefabUrl +end + +function XUiConfigs.GetUiModelUrl(uiName) + if not uiName then + return + end + + local uiTemplate = nil -- CS.XUiManager.Instance.UiTemplate[uiName] + + if CS.XUiManager.Instance.UiTemplate:ContainsKey(uiName) then + uiTemplate = CS.XUiManager.Instance.UiTemplate[uiName] + end + + if not uiTemplate then + XLog.ErrorTableDataNotFound("XUiConfigs.GetUiModelUrl", "Ui", TABLE_UI_PATH, "UiName", uiName) + return + end + + return uiTemplate.ModelUrl +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XUiFightButtonDefaultStyleConfig.lua b/Resources/Scripts/XConfig/XUiFightButtonDefaultStyleConfig.lua new file mode 100644 index 00000000..913c641c --- /dev/null +++ b/Resources/Scripts/XConfig/XUiFightButtonDefaultStyleConfig.lua @@ -0,0 +1,38 @@ +XUiFightButtonDefaultStyleConfig = XUiFightButtonDefaultStyleConfig or {} +local TABLE_UIFIGHT_BUTTON_DEFAULTSTYLE = "Client/Fight/UiFightButtonDefaultStyle.tab" +local UiFightButtonDefaultStyle = nil + +function XUiFightButtonDefaultStyleConfig.Init() + UiFightButtonDefaultStyle = XTableManager.ReadByIntKey(TABLE_UIFIGHT_BUTTON_DEFAULTSTYLE, XTable.XTableUiFightButtonDefaultStyle, "Id") +end + +function XUiFightButtonDefaultStyleConfig.GetStyleById(id) + return UiFightButtonDefaultStyle[id] +end + +function XUiFightButtonDefaultStyleConfig.SaveDefaultStyleById(id) + if not UiFightButtonDefaultStyle then + UiFightButtonDefaultStyle = XTableManager.ReadByIntKey(TABLE_UIFIGHT_BUTTON_DEFAULTSTYLE, XTable.XTableUiFightButtonDefaultStyle, "Id") + end + + if not UiFightButtonDefaultStyle then + return + end + + local config = UiFightButtonDefaultStyle[id] + if config and config.Scheme then + CS.XCustomUi.Instance:SaveButtonCustom(config.Scheme) + end +end + +function XUiFightButtonDefaultStyleConfig.GetDefaultStyle() + return CS.UnityEngine.PlayerPrefs.GetString("CustomUI"); +end + +function XUiFightButtonDefaultStyleConfig.GetCurSchemeStyle() + return CS.XCustomUi.Instance.CurScheme or 0 +end + +function XUiFightButtonDefaultStyleConfig.IsHaveCurSchemeStyle() + return CS.UnityEngine.PlayerPrefs.HasKey("CustomUI") +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XUiPcConfig.lua b/Resources/Scripts/XConfig/XUiPcConfig.lua new file mode 100644 index 00000000..483711f9 --- /dev/null +++ b/Resources/Scripts/XConfig/XUiPcConfig.lua @@ -0,0 +1,46 @@ +---@class XUiPcConfig +XUiPcConfig = XUiPcConfig or {} + +function XUiPcConfig.Init() +end + +local _TabUiPcReplace +local function GetTabUiPcReplace() + if not _TabUiPcReplace then + _TabUiPcReplace = XTableManager.ReadByStringKey("Client/Ui/UiPcReplace.tab", XTable.XTableUiPcReplace, "Key") + end + return _TabUiPcReplace +end + +local _TabUiPcScreenResolution +local function GetTabUiPcResolution() + if not _TabUiPcScreenResolution then + _TabUiPcScreenResolution = XTableManager.ReadByStringKey("Client/UiPc/UiPcScreenResolution.tab", + XTable.XTableUiPcScreenResolution, "Id") + local config = {} + for i, size in pairs(_TabUiPcScreenResolution) do + -- 把大写的x和y换回小写 + config[#config + 1] = { x = size.X, y = size.Y } + end + _TabUiPcScreenResolution = config + table.sort(config, function(a, b) + return a.x < b.x + end) + end + return _TabUiPcScreenResolution +end + +function XUiPcConfig.GetTabUiPcReplace(sceneName) + local replaceData = {} + local scenePath = string.format("Assets/Product/Ui/Prefab/%s.prefab", sceneName) + for key, config in pairs(GetTabUiPcReplace()) do + if config.ScenePath == scenePath then + replaceData[#replaceData + 1] = config + end + end + return replaceData +end + +function XUiPcConfig.GetTabUiPcResolution() + return GetTabUiPcResolution() +end diff --git a/Resources/Scripts/XConfig/XVideoConfig.lua b/Resources/Scripts/XConfig/XVideoConfig.lua new file mode 100644 index 00000000..cc542579 --- /dev/null +++ b/Resources/Scripts/XConfig/XVideoConfig.lua @@ -0,0 +1,24 @@ +XVideoConfig = XVideoConfig or {} + +local TABLE_MOIVE_CONFIG = "Client/Video/VideoConfig.tab" +local VideoTemplate = {} +function XVideoConfig.Init() + VideoTemplate = XTableManager.ReadByIntKey(TABLE_MOIVE_CONFIG, XTable.XTableVideoConfig, "Id") +end + + +function XVideoConfig.GetMovieById(id) + if not VideoTemplate or not VideoTemplate[id] then + XLog.ErrorTableDataNotFound("XVideoConfig.GetMovieById", "VideoConfig", TABLE_MOIVE_CONFIG, "Id", tostring(id)) + return + end + return VideoTemplate[id] +end + +function XVideoConfig.GetMovieUrlById(id) + if not VideoTemplate or not VideoTemplate[id] then + XLog.ErrorTableDataNotFound("XVideoConfig.GetMovieUrlById", "VideoConfig", TABLE_MOIVE_CONFIG, "Id", tostring(id)) + return + end + return VideoTemplate[id].VideoUrl +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XWeaponFashionConfigs.lua b/Resources/Scripts/XConfig/XWeaponFashionConfigs.lua new file mode 100644 index 00000000..3d294206 --- /dev/null +++ b/Resources/Scripts/XConfig/XWeaponFashionConfigs.lua @@ -0,0 +1,143 @@ +local pairs = pairs +local tableInsert = table.insert +local ParseToTimestamp = XTime.ParseToTimestamp + +local TABLE_WEAPON_FASHION_PATH = "Share/WeaponFashion/WeaponFashion.tab" +local TABLE_WEAPON_FASHION_RES_PATH = "Client/WeaponFashion/WeaponFashionRes.tab" + +local WeaponFashionTemplates = {} +local WeaponFashionResTemplates = {} + +local EquipTypeToWeaponFashionIdDic = {} + +local function GetConfig(fashionId) + local tab = WeaponFashionTemplates[fashionId] + if tab == nil then + XLog.ErrorTableDataNotFound("XWeaponFashionConfigs.GetConfig", "WeaponFashion", TABLE_WEAPON_FASHION_PATH, "Id", tostring(fashionId)) + end + return tab +end + +local function GetResConfig(fashionId) + local tab = WeaponFashionResTemplates[fashionId] + if tab == nil then + XLog.ErrorTableDataNotFound("XWeaponFashionConfigs.GetResConfig", "WeaponFashionRes", TABLE_WEAPON_FASHION_RES_PATH, "Id", tostring(fashionId)) + end + return tab +end + +XWeaponFashionConfigs = XWeaponFashionConfigs or {} + +XWeaponFashionConfigs.DefaultWeaponFashionId = 0 + +function XWeaponFashionConfigs.Init() + WeaponFashionTemplates = XTableManager.ReadByIntKey(TABLE_WEAPON_FASHION_PATH, XTable.XTableWeaponFashion, "Id") + WeaponFashionResTemplates = XTableManager.ReadByIntKey(TABLE_WEAPON_FASHION_RES_PATH, XTable.XTableWeaponFashionRes, "Id") + + for _, config in pairs(WeaponFashionTemplates) do + local equipType = config.EquipType + local fashionIds = EquipTypeToWeaponFashionIdDic[equipType] or {} + tableInsert(fashionIds, config.Id) + EquipTypeToWeaponFashionIdDic[equipType] = fashionIds + end +end + +function XWeaponFashionConfigs.IsDefaultId(fashionId) + return fashionId == XWeaponFashionConfigs.DefaultWeaponFashionId +end + +function XWeaponFashionConfigs.GetFashionEquipType(fashionId) + return GetConfig(fashionId).EquipType +end + +function XWeaponFashionConfigs.GetWeaponFashionIdsByEquipType(equipType) + return EquipTypeToWeaponFashionIdDic[equipType] or {} +end + +function XWeaponFashionConfigs.GetFashionBeginTime(fashionId) + local timeStr = GetConfig(fashionId).EffectTimeStr + return timeStr and ParseToTimestamp(timeStr) or 0 +end + +function XWeaponFashionConfigs.GetFashionExpireTime(fashionId) + local timeStr = GetConfig(fashionId).ExpireTimeStr + return timeStr and ParseToTimestamp(timeStr) or 0 +end + +function XWeaponFashionConfigs.GetFashionIcon(fashionId) + return GetResConfig(fashionId).Icon +end + +function XWeaponFashionConfigs.GetFashionBigIcon(fashionId) + return GetResConfig(fashionId).BigIcon +end + +function XWeaponFashionConfigs.GetFashionShopIcon(fashionId) + return GetResConfig(fashionId).ShopIcon +end + +function XWeaponFashionConfigs.GetFashionName(fashionId) + return GetResConfig(fashionId).Name +end + +function XWeaponFashionConfigs.GetFashionQuality(fashionId) + return GetResConfig(fashionId).Quality +end + +function XWeaponFashionConfigs.GetFashionDesc(fashionId) + return GetResConfig(fashionId).Description +end + +function XWeaponFashionConfigs.GetFashionWorldDescription(fashionId) + return GetResConfig(fashionId).WorldDescription +end + +function XWeaponFashionConfigs.GetFashionSkipIdParams(fashionId) + return GetResConfig(fashionId).SkipIdParams +end + +function XWeaponFashionConfigs.GetFashionPriority(fashionId) + return GetResConfig(fashionId).Priority +end + +function XWeaponFashionConfigs.GetWeaponResonanceModelId(case, fashionId, resonanceCount) + resonanceCount = resonanceCount or 0 + local config = GetResConfig(fashionId) + local resonanceModelTransIds = config["ResonanceModelTransId" .. resonanceCount] + return resonanceModelTransIds and resonanceModelTransIds[case] or config.ModelTransId[case] +end + +function XWeaponFashionConfigs.GetWeaponFashionResTemplates() + return XTool.Clone(WeaponFashionResTemplates) +end + +-- 获取有效时间内的全部武器涂装 +function XWeaponFashionConfigs.GetWeaponFashionResTemplatesInTime() + local weaponFashionResTemplates = XTool.Clone(WeaponFashionResTemplates) + local weaponFashionResTemplateDic = {} + local timeStamp = XTime.GetServerNowTimestamp() + for _, WeaponFashionResTemplate in pairs(weaponFashionResTemplates) do + local WeaponFashionTemplate = WeaponFashionTemplates[WeaponFashionResTemplate.Id] + if WeaponFashionTemplate then + local effectTimeStr = WeaponFashionTemplate.EffectTimeStr + local expireTimeStr = WeaponFashionTemplate.ExpireTimeStr + if effectTimeStr and expireTimeStr then + if(timeStamp >= XTime.ParseToTimestamp(effectTimeStr) and timeStamp <= XTime.ParseToTimestamp(expireTimeStr)) then + weaponFashionResTemplateDic[WeaponFashionResTemplate.Id] = WeaponFashionResTemplate + end + elseif effectTimeStr then + if(timeStamp >= XTime.ParseToTimestamp(effectTimeStr)) then + weaponFashionResTemplateDic[WeaponFashionResTemplate.Id] = WeaponFashionResTemplate + end + elseif expireTimeStr then + if(timeStamp <= XTime.ParseToTimestamp(expireTimeStr)) then + weaponFashionResTemplateDic[WeaponFashionResTemplate.Id] = WeaponFashionResTemplate + end + else + weaponFashionResTemplateDic[WeaponFashionResTemplate.Id] = WeaponFashionResTemplate + end + end + end + + return weaponFashionResTemplateDic +end \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XWhiteValentineConfig.lua b/Resources/Scripts/XConfig/XWhiteValentineConfig.lua new file mode 100644 index 00000000..3a424cd9 --- /dev/null +++ b/Resources/Scripts/XConfig/XWhiteValentineConfig.lua @@ -0,0 +1,216 @@ +--白情约会小游戏配置管理器 +XWhiteValentineConfig = XWhiteValentineConfig or {} +-- ===================表地址 +local SHARE_TABLE_PATH = "Share/MiniActivity/WhiteValentine2021/" +local CLIENT_TABLE_PATH = "Client/MiniActivity/WhiteValentine2021/" +-- 约会小游戏基础配置表 +local TABLE_GAMECONFIG = SHARE_TABLE_PATH .. "WhiteValentinesDayConfig.tab" +-- 约会小游戏地点配置表 +local TABLE_PLACE = SHARE_TABLE_PATH .. "WhiteValentinesDayPlace.tab" +-- 约会小游戏事件配置表 +local TABLE_EVENT = SHARE_TABLE_PATH .. "WhiteValentinesDayEvent.tab" +-- 约会小游戏角色配置表 +local TABLE_CHARA = SHARE_TABLE_PATH .. "WhiteValentinesDayRole.tab" +-- 约会小游戏故事内容配置表 +local TABLE_STORY = CLIENT_TABLE_PATH .. "WhiteValentinesDayStory.tab" +-- 约会小游戏事件阶级详细表 +local TABLE_RANK = SHARE_TABLE_PATH .. "WhiteValentinesDayRank.tab" +-- 约会小游戏角色属性详细表 +local TABLE_ATTR = CLIENT_TABLE_PATH .. "WhiteValentinesDayAttr.tab" +-- ===================原表数据 +-- 约会小游戏基础配置表 +local WhiteValentineConfig = {} +-- 约会小游戏地点配置表 +local WhiteValentinePlace = {} +-- 约会小游戏事件配置表 +local WhiteValentineEvent = {} +-- 约会小游戏角色配置表 +local WhiteValentineChara = {} +-- 约会小游戏故事内容配置表 +local WhiteValentineStory = {} +-- 约会小游戏事件阶级详细表 +local WhiteValentineRank = {} +-- 约会小游戏角色属性详细表 +local WhiteValentineAttr = {} +--==================初始化方法====================== +--=============== +--初始化表配置 +--=============== +function XWhiteValentineConfig.Init() + WhiteValentineConfig = XTableManager.ReadByIntKey(TABLE_GAMECONFIG, XTable.XTableWhiteValentinesDayConfig, "Id") + WhiteValentinePlace = XTableManager.ReadByIntKey(TABLE_PLACE, XTable.XTableWhiteValentinesDayPlace, "Id") + WhiteValentineEvent = XTableManager.ReadByIntKey(TABLE_EVENT, XTable.XTableWhiteValentinesDayEvent, "Id") + WhiteValentineChara = XTableManager.ReadByIntKey(TABLE_CHARA, XTable.XTableWhiteValentinesDayRole, "Id") + WhiteValentineStory = XTableManager.ReadByIntKey(TABLE_STORY, XTable.XTableWhiteValentinesDayStory, "Id") + WhiteValentineRank = XTableManager.ReadByIntKey(TABLE_RANK, XTable.XTableWhiteValentinesDayRank, "Id") + WhiteValentineAttr = XTableManager.ReadByIntKey(TABLE_ATTR, XTable.XTableWhiteValentinesDayAttr, "Id") +end +--================================================== +--==================读表方法====================== +--=============== +--获取所有活动基础配置 +--=============== +function XWhiteValentineConfig.GetAllWhiteValentineConfig() + return WhiteValentineConfig +end +--=============== +--获取最新的基础配置Id +--=============== +function XWhiteValentineConfig.GetLastConfigId() + local id = 0 + for configId, _ in pairs(WhiteValentineConfig) do + if id < configId then id = configId end + end + return id +end +--=============== +--根据GameId获取游戏基础配置 +--@param gameId:游戏ID +--=============== +function XWhiteValentineConfig.GetWhiteValentineConfigByGameId(gameId) + local config = WhiteValentineConfig[gameId] + if not config then + XLog.ErrorTableDataNotFound( + "XWhiteValentineConfig.GetWhiteValentineConfigByGameId", + "组合小游戏活动基础配置数据", + TABLE_GAMECONFIG, + "GameId", + tostring(gameId) + ) + return nil + end + return config +end +--=============== +--获取所有地点配置 +--=============== +function XWhiteValentineConfig.GetAllWhiteValentinePlace() + return WhiteValentinePlace +end +--=============== +--根据PlaceId获取地点配置 +--@param placeId:地点ID +--=============== +function XWhiteValentineConfig.GetWhiteValentinePlaceByPlaceId(placeId) + local config = WhiteValentinePlace[placeId] + if not config then + XLog.ErrorTableDataNotFound( + "XWhiteValentineConfig.GetWhiteValentinePlaceByPlaceId", + "约会小游戏活动地点配置数据", + TABLE_PLACE, + "PlaceId", + tostring(placeId) + ) + return nil + end + return config +end +--=============== +--获取所有事件配置 +--=============== +function XWhiteValentineConfig.GetAllWhiteValentineEvent() + return WhiteValentineEvent +end +--=============== +--根据EventId获取地点配置 +--@param eventId:地点ID +--=============== +function XWhiteValentineConfig.GetWhiteValentineEventByEventId(eventId) + local config = WhiteValentineEvent[eventId] + if not config then + XLog.ErrorTableDataNotFound( + "XWhiteValentineConfig.GetWhiteValentineEventByEventId", + "约会小游戏活动事件配置数据", + TABLE_EVENT, + "eventId", + tostring(eventId) + ) + return nil + end + return config +end +--=============== +--获取所有角色配置 +--=============== +function XWhiteValentineConfig.GetAllWhiteValentineChara() + return WhiteValentineChara +end +--=============== +--根据CharaId获取地点配置 +--@param charaId:角色ID +--=============== +function XWhiteValentineConfig.GetWhiteValentineCharaByCharaId(charaId) + local config = WhiteValentineChara[charaId] + if not config then + XLog.ErrorTableDataNotFound( + "XWhiteValentineConfig.GetWhiteValentineCharaByCharaId", + "约会小游戏活动角色配置数据", + TABLE_CHARA, + "charaId", + tostring(charaId) + ) + return nil + end + return config +end +--=============== +--根据Id获取约会内容配置 +--@param id:约会ID +--=============== +function XWhiteValentineConfig.GetWhiteValentineStoryById(id) + local config = WhiteValentineStory[id] + if not config then + XLog.ErrorTableDataNotFound( + "XWhiteValentineConfig.GetWhiteValentineStoryById", + "约会小游戏活动约会内容配置数据", + TABLE_STORY, + "Id", + tostring(id) + ) + return nil + end + return config +end +--=============== +--根据Id获取约会阶级详细配置 +--@param id:阶级ID +--=============== +function XWhiteValentineConfig.GetWhiteValentineRankConfigById(id) + local config = WhiteValentineRank[id] + if not config then + XLog.ErrorTableDataNotFound( + "XWhiteValentineConfig.GetWhiteValentineRankConfigById", + "约会小游戏活动阶级详细配置数据", + TABLE_RANK, + "Id", + tostring(id) + ) + return nil + end + return config +end +--=============== +--获取所有角色属性详细配置 +--=============== +function XWhiteValentineConfig.GetAllWhiteValentineAttr() + return WhiteValentineAttr +end +--=============== +--根据Id获取角色属性详细配置 +--@param id:属性ID +--=============== +function XWhiteValentineConfig.GetWhiteValentineAttrById(id) + local config = WhiteValentineAttr[id] + if not config then + XLog.ErrorTableDataNotFound( + "XWhiteValentineConfig.GetWhiteValentineAttrById", + "约会小游戏活动角色属性详细配置数据", + TABLE_ATTR, + "Id", + tostring(id) + ) + return nil + end + return config +end +--================================================== \ No newline at end of file diff --git a/Resources/Scripts/XConfig/XWorldBossConfigs.lua b/Resources/Scripts/XConfig/XWorldBossConfigs.lua new file mode 100644 index 00000000..68a9fd02 --- /dev/null +++ b/Resources/Scripts/XConfig/XWorldBossConfigs.lua @@ -0,0 +1,173 @@ +local TABLE_WORLDBOSS_ACTIVITY = "Share/Fuben/WorldBoss/WorldBossActivity.tab" +local TABLE_WORLDBOSS_ATTRIBUTE_AREA = "Share/Fuben/WorldBoss/WorldBossAttributeArea.tab" +local TABLE_WORLDBOSS_ATTRIBUTE_STAGE = "Share/Fuben/WorldBoss/WorldBossAttributeStage.tab" +local TABLE_WORLDBOSS_BOSS_AREA = "Share/Fuben/WorldBoss/WorldBossBossArea.tab" +local TABLE_WORLDBOSS_BOSS_SHOP = "Share/Fuben/WorldBoss/WorldBossBossShop.tab" +local TABLE_WORLDBOSS_BOSS_SHOP_DISCOUNT = "Share/Fuben/WorldBoss/WorldBossBossShopDiscount.tab" +local TABLE_WORLDBOSS_BOSS_STAGE = "Share/Fuben/WorldBoss/WorldBossBossStage.tab" +local TABLE_WORLDBOSS_BUFF = "Share/Fuben/WorldBoss/WorldBossBuff.tab" +local TABLE_WORLDBOSS_PHASESREWARD = "Share/Fuben/WorldBoss/WorldBossPhasesReward.tab" +local TABLE_WORLDBOSS_REPORT = "Share/Fuben/WorldBoss/WorldBossFightReport.tab" + + +local ActivityTemplates = {} +local AttributeAreaTemplates = {} +local AttributeStageTemplates = {} +local BossAreaTemplates = {} +local BossShopTemplates = {} +local BossShopDiscountTemplates = {} +local BossStageTemplates = {} +local BuffTemplates = {} +local ReportTemplates = {} +local PhasesRewardemplates = {} +local BossStageDic = {} + +XWorldBossConfigs = XWorldBossConfigs or {} + +XWorldBossConfigs.BuffType = { + Buff = 1, + Robot = 2 +} + +XWorldBossConfigs.AreaType = { + Attribute = 1, + Boss = 2 +} + +XWorldBossConfigs.ReportType = { + System = 1, + Player = 2 +} + +XWorldBossConfigs.DefaultTeam = { + ["CaptainPos"] = 1, + ["FirstFightPos"] = 1, + ["TeamData"] = { 1021001, 0, 0 }, +} + +function XWorldBossConfigs.Init() + ActivityTemplates = XTableManager.ReadByIntKey(TABLE_WORLDBOSS_ACTIVITY, XTable.XTableWorldBossActivity, "Id") + AttributeAreaTemplates = XTableManager.ReadByIntKey(TABLE_WORLDBOSS_ATTRIBUTE_AREA, XTable.XTableWorldBossAttributeArea, "Id") + AttributeStageTemplates = XTableManager.ReadByIntKey(TABLE_WORLDBOSS_ATTRIBUTE_STAGE, XTable.XTableWorldBossAttributeStage, "Id") + BossAreaTemplates = XTableManager.ReadByIntKey(TABLE_WORLDBOSS_BOSS_AREA, XTable.XTableWorldBossBossArea, "Id") + BossShopTemplates = XTableManager.ReadByIntKey(TABLE_WORLDBOSS_BOSS_SHOP, XTable.XTableWorldBossBossShop, "Id") + BossShopDiscountTemplates = XTableManager.ReadByIntKey(TABLE_WORLDBOSS_BOSS_SHOP_DISCOUNT, XTable.XTableWorldBossBossShopDiscount, "Id") + BossStageTemplates = XTableManager.ReadByIntKey(TABLE_WORLDBOSS_BOSS_STAGE, XTable.XTableWorldBossBossStage, "Id") + BuffTemplates = XTableManager.ReadByIntKey(TABLE_WORLDBOSS_BUFF, XTable.XTableWorldBossBuff, "Id") + PhasesRewardemplates = XTableManager.ReadByIntKey(TABLE_WORLDBOSS_PHASESREWARD, XTable.XTableWorldBossPhasesReward, "Id") + ReportTemplates = XTableManager.ReadByIntKey(TABLE_WORLDBOSS_REPORT, XTable.XTableWorldBossFightReport, "Id") +end + +function XWorldBossConfigs.GetActivityTemplates() + return ActivityTemplates +end + +function XWorldBossConfigs.GetAttributeAreaTemplates() + return AttributeAreaTemplates +end + +function XWorldBossConfigs.GetAttributeStageTemplates() + return AttributeStageTemplates +end + +function XWorldBossConfigs.GetBossAreaTemplates() + return BossAreaTemplates +end + +function XWorldBossConfigs.GetBossShopTemplates() + return BossShopTemplates +end + +function XWorldBossConfigs.GetBossShopDiscountTemplates() + return BossShopDiscountTemplates +end + +function XWorldBossConfigs.GetBossStageTemplates() + return BossStageTemplates +end + +function XWorldBossConfigs.GetBuffTemplates() + return BuffTemplates +end + +function XWorldBossConfigs.GetPhasesRewardemplates() + return PhasesRewardemplates +end + +function XWorldBossConfigs.GetActivityTemplatesById(id) + if not ActivityTemplates[id] then + XLog.Error("Share/Fuben/WorldBoss/WorldBossActivity.tab Id = " .. id .. " Is Null") + end + return ActivityTemplates[id] +end + +function XWorldBossConfigs.GetAttributeAreaTemplatesById(id) + if not AttributeAreaTemplates[id] then + XLog.Error("Share/Fuben/WorldBoss/WorldBossAttributeArea.tab Id = " .. id .. " Is Null") + end + return AttributeAreaTemplates[id] +end + +function XWorldBossConfigs.GetAttributeStageTemplatesById(id) + if not AttributeStageTemplates[id] then + XLog.Error("Share/Fuben/WorldBoss/WorldBossAttributeStage.tab Id = " .. id .. " Is Null") + end + return AttributeStageTemplates[id] +end + +function XWorldBossConfigs.GetBossAreaTemplatesById(id) + if not BossAreaTemplates[id] then + XLog.Error("Share/Fuben/WorldBoss/WorldBossBossArea.tab Id = " .. id .. " Is Null") + end + return BossAreaTemplates[id] +end + +function XWorldBossConfigs.GetBossShopTemplatesById(id) + if not BossShopTemplates[id] then + XLog.Error("Share/Fuben/WorldBoss/WorldBossBossShop.tab Id = " .. id .. " Is Null") + end + return BossShopTemplates[id] +end + +function XWorldBossConfigs.GetBossShopDiscountTemplatesById(id) + if not BossShopDiscountTemplates[id] then + XLog.Error("Share/Fuben/WorldBoss/WorldBossBossShopDiscount.tab Id = " .. id .. " Is Null") + end + return BossShopDiscountTemplates[id] +end + +function XWorldBossConfigs.GetBossStageTemplatesById(id) + if not BossStageTemplates[id] then + XLog.Error("Share/Fuben/WorldBoss/WorldBossBossStage.tab Id = " .. id .. " Is Null") + end + return BossStageTemplates[id] +end + +function XWorldBossConfigs.GetBuffTemplatesById(id) + if not BuffTemplates[id] then + XLog.Error("Share/Fuben/WorldBoss/WorldBossBuff.tab Id = " .. id .. " Is Null") + end + return BuffTemplates[id] +end + +function XWorldBossConfigs.GetPhasesRewardemplatesById(id) + if not PhasesRewardemplates[id] then + XLog.Error("Share/Fuben/WorldBoss/WorldBossPhasesReward.tab Id = " .. id .. " Is Null") + end + return PhasesRewardemplates[id] +end + +function XWorldBossConfigs.GetReportTemplatesById(id) + if not ReportTemplates[id] then + XLog.Error("Share/Fuben/WorldBoss/WorldBossFightReport.tab Id = " .. id .. " Is Null") + end + return ReportTemplates[id] +end + +function XWorldBossConfigs.GetActivityLastTemplate() + local templat = {} + for _, activityTemplate in pairs(ActivityTemplates) do + templat = activityTemplate + end + return templat +end diff --git a/Resources/Scripts/XDebug/LuaDebug.lua b/Resources/Scripts/XDebug/LuaDebug.lua new file mode 100644 index 00000000..46c696de --- /dev/null +++ b/Resources/Scripts/XDebug/LuaDebug.lua @@ -0,0 +1,2642 @@ +local debugger_reLoadFile =nil +local debugger_xpcall = nil +local debugger_stackInfo = nil +local coro_debugger = nil +local debugger_require = require +local debugger_exeLuaString = nil +local checkSetVar = nil +local loadstring_ = nil +local debugger_sendMsg = nil +if (loadstring) then + loadstring_ = loadstring +else + loadstring_ = load +end +--只针对 luadebug 调试 jit版本不存在这个问题 +local setfenv = setfenv +if (not setfenv) then + setfenv = + function(fn, env) + local i = 1 + while true do + local name = debug.getupvalue(fn, i) + if name == "_ENV" then + debug.upvaluejoin( + fn, + i, + (function() + return env + end), + 1 + ) + break + elseif not name then + break + end + + i = i + 1 + end + return fn + end +end +local ZZBase64 = {} +local LuaDebugTool_ = nil +if (LuaDebugTool) then + LuaDebugTool_ = LuaDebugTool +elseif (CS and CS.LuaDebugTool) then + LuaDebugTool_ = CS.LuaDebugTool +end +local LuaDebugTool = LuaDebugTool_ +local loadstring = loadstring_ +local getinfo = debug.getinfo +local function createSocket() + local base = _G + local string = require("string") + local math = require("math") + local socket = require("socket.core") + + local _M = socket + + ----------------------------------------------------------------------------- + -- Exported auxiliar functions + ----------------------------------------------------------------------------- + function _M.connect4(address, port, laddress, lport) + return socket.connect(address, port, laddress, lport, "inet") + end + + function _M.connect6(address, port, laddress, lport) + return socket.connect(address, port, laddress, lport, "inet6") + end + + if (not _M.connect) then + function _M.connect(address, port, laddress, lport) + local sock, err = socket.tcp() + if not sock then + return nil, err + end + if laddress then + local res, err = sock:bind(laddress, lport, -1) + if not res then + return nil, err + end + end + local res, err = sock:connect(address, port) + if not res then + return nil, err + end + return sock + end + end + function _M.bind(host, port, backlog) + if host == "*" then + host = "0.0.0.0" + end + local addrinfo, err = socket.dns.getaddrinfo(host) + if not addrinfo then + return nil, err + end + local sock, res + err = "no info on address" + for i, alt in base.ipairs(addrinfo) do + if alt.family == "inet" then + sock, err = socket.tcp4() + else + sock, err = socket.tcp6() + end + if not sock then + return nil, err + end + sock:setoption("reuseaddr", true) + res, err = sock:bind(alt.addr, port) + if not res then + sock:close() + else + res, err = sock:listen(backlog) + if not res then + sock:close() + else + return sock + end + end + end + return nil, err + end + + _M.try = _M.newtry() + + function _M.choose(table) + return function(name, opt1, opt2) + if base.type(name) ~= "string" then + name, opt1, opt2 = "default", name, opt1 + end + local f = table[name or "nil"] + if not f then + base.error("unknown key (" .. base.tostring(name) .. ")", 3) + else + return f(opt1, opt2) + end + end + end + + ----------------------------------------------------------------------------- + -- Socket sources and sinks, conforming to LTN12 + ----------------------------------------------------------------------------- + -- create namespaces inside LuaSocket namespace + local sourcet, sinkt = {}, {} + _M.sourcet = sourcet + _M.sinkt = sinkt + + _M.BLOCKSIZE = 2048 + + sinkt["close-when-done"] = + function(sock) + return base.setmetatable( + { + getfd = function() + return sock:getfd() + end, + dirty = function() + return sock:dirty() + end + }, + { + __call = function(self, chunk, err) + if not chunk then + sock:close() + return 1 + else + return sock:send(chunk) + end + end + } + ) + end + + sinkt["keep-open"] = + function(sock) + return base.setmetatable( + { + getfd = function() + return sock:getfd() + end, + dirty = function() + return sock:dirty() + end + }, + { + __call = function(self, chunk, err) + if chunk then + return sock:send(chunk) + else + return 1 + end + end + } + ) + end + + sinkt["default"] = sinkt["keep-open"] + + _M.sink = _M.choose(sinkt) + + sourcet["by-length"] = + function(sock, length) + return base.setmetatable( + { + getfd = function() + return sock:getfd() + end, + dirty = function() + return sock:dirty() + end + }, + { + __call = function() + if length <= 0 then + return nil + end + local size = math.min(socket.BLOCKSIZE, length) + local chunk, err = sock:receive(size) + if err then + return nil, err + end + length = length - string.len(chunk) + return chunk + end + } + ) + end + + sourcet["until-closed"] = + function(sock) + local done + return base.setmetatable( + { + getfd = function() + return sock:getfd() + end, + dirty = function() + return sock:dirty() + end + }, + { + __call = function() + if done then + return nil + end + local chunk, err, partial = sock:receive(socket.BLOCKSIZE) + if not err then + return chunk + elseif err == "closed" then + sock:close() + done = 1 + return partial + else + return nil, err + end + end + } + ) + end + + sourcet["default"] = sourcet["until-closed"] + + _M.source = _M.choose(sourcet) + + return _M +end + +local function createJson() + local math = require("math") + local string = require("string") + local table = require("table") + local object = nil + ----------------------------------------------------------------------------- + -- Module declaration + ----------------------------------------------------------------------------- + local json = {} -- Public namespace + local json_private = {} -- Private namespace + + -- Public constants + json.EMPTY_ARRAY = {} + json.EMPTY_OBJECT = {} + -- Public functions + + -- Private functions + local decode_scanArray + local decode_scanComment + local decode_scanConstant + local decode_scanNumber + local decode_scanObject + local decode_scanString + local decode_scanWhitespace + local encodeString + local isArray + local isEncodable + + ----------------------------------------------------------------------------- + -- PUBLIC FUNCTIONS + ----------------------------------------------------------------------------- + --- Encodes an arbitrary Lua object / variable. + -- @param v The Lua object / variable to be JSON encoded. + -- @return String containing the JSON encoding in internal Lua string format (i.e. not unicode) + function json.encode(v) + -- Handle nil values + if v == nil then + return "null" + end + + local vtype = type(v) + + -- Handle strings + if vtype == "string" then + return '"' .. json_private.encodeString(v) .. '"' -- Need to handle encoding in string + end + + -- Handle booleans + if vtype == "number" or vtype == "boolean" then + return tostring(v) + end + + -- Handle tables + if vtype == "table" then + local rval = {} + -- Consider arrays separately + local bArray, maxCount = isArray(v) + if bArray then + for i = 1, maxCount do + table.insert(rval, json.encode(v[i])) + end + else -- An object, not an array + for i, j in pairs(v) do + if isEncodable(i) and isEncodable(j) then + table.insert(rval, '"' .. json_private.encodeString(i) .. '":' .. json.encode(j)) + end + end + end + if bArray then + return "[" .. table.concat(rval, ",") .. "]" + else + return "{" .. table.concat(rval, ",") .. "}" + end + end + + -- Handle null values + if vtype == "function" and v == json.null then + return "null" + end + + assert(false, "encode attempt to encode unsupported type " .. vtype .. ":" .. tostring(v)) + end + + --- Decodes a JSON string and returns the decoded value as a Lua data structure / value. + -- @param s The string to scan. + -- @param [startPos] Optional starting position where the JSON string is located. Defaults to 1. + -- @param Lua object, number The object that was scanned, as a Lua table / string / number / boolean or nil, + -- and the position of the first character after + -- the scanned JSON object. + function json.decode(s, startPos) + startPos = startPos and startPos or 1 + startPos = decode_scanWhitespace(s, startPos) + assert(startPos <= string.len(s), "Unterminated JSON encoded object found at position in [" .. s .. "]") + local curChar = string.sub(s, startPos, startPos) + -- Object + if curChar == "{" then + return decode_scanObject(s, startPos) + end + -- Array + if curChar == "[" then + return decode_scanArray(s, startPos) + end + -- Number + if string.find("+-0123456789.e", curChar, 1, true) then + return decode_scanNumber(s, startPos) + end + -- String + if curChar == '"' or curChar == [[']] then + return decode_scanString(s, startPos) + end + if string.sub(s, startPos, startPos + 1) == "/*" then + return json.decode(s, decode_scanComment(s, startPos)) + end + -- Otherwise, it must be a constant + return decode_scanConstant(s, startPos) + end + + --- The null function allows one to specify a null value in an associative array (which is otherwise + -- discarded if you set the value with 'nil' in Lua. Simply set t = { first=json.null } + function json.null() + return json.null -- so json.null() will also return null ;-) + end + ----------------------------------------------------------------------------- + -- Internal, PRIVATE functions. + -- Following a Python-like convention, I have prefixed all these 'PRIVATE' + -- functions with an underscore. + ----------------------------------------------------------------------------- + --- Scans an array from JSON into a Lua object + -- startPos begins at the start of the array. + -- Returns the array and the next starting position + -- @param s The string being scanned. + -- @param startPos The starting position for the scan. + -- @return table, int The scanned array as a table, and the position of the next character to scan. + function decode_scanArray(s, startPos) + local array = {} -- The return value + local stringLen = string.len(s) + assert( + string.sub(s, startPos, startPos) == "[", + "decode_scanArray called but array does not start at position " .. startPos .. " in string:\n" .. s + ) + startPos = startPos + 1 + -- Infinite loop for array elements + repeat + startPos = decode_scanWhitespace(s, startPos) + assert(startPos <= stringLen, "JSON String ended unexpectedly scanning array.") + local curChar = string.sub(s, startPos, startPos) + if (curChar == "]") then + return array, startPos + 1 + end + if (curChar == ",") then + startPos = decode_scanWhitespace(s, startPos + 1) + end + assert(startPos <= stringLen, "JSON String ended unexpectedly scanning array.") + object, startPos = json.decode(s, startPos) + table.insert(array, object) + until false + end + + --- Scans a comment and discards the comment. + -- Returns the position of the next character following the comment. + -- @param string s The JSON string to scan. + -- @param int startPos The starting position of the comment + function decode_scanComment(s, startPos) + assert( + string.sub(s, startPos, startPos + 1) == "/*", + "decode_scanComment called but comment does not start at position " .. startPos + ) + local endPos = string.find(s, "*/", startPos + 2) + assert(endPos ~= nil, "Unterminated comment in string at " .. startPos) + return endPos + 2 + end + + --- Scans for given constants: true, false or null + -- Returns the appropriate Lua type, and the position of the next character to read. + -- @param s The string being scanned. + -- @param startPos The position in the string at which to start scanning. + -- @return object, int The object (true, false or nil) and the position at which the next character should be + -- scanned. + function decode_scanConstant(s, startPos) + local consts = {["true"] = true, ["false"] = false, ["null"] = nil} + local constNames = {"true", "false", "null"} + + for i, k in pairs(constNames) do + if string.sub(s, startPos, startPos + string.len(k) - 1) == k then + return consts[k], startPos + string.len(k) + end + end + assert(nil, "Failed to scan constant from string " .. s .. " at starting position " .. startPos) + end + + --- Scans a number from the JSON encoded string. + -- (in fact, also is able to scan numeric +- eqns, which is not + -- in the JSON spec.) + -- Returns the number, and the position of the next character + -- after the number. + -- @param s The string being scanned. + -- @param startPos The position at which to start scanning. + -- @return number, int The extracted number and the position of the next character to scan. + function decode_scanNumber(s, startPos) + local endPos = startPos + 1 + local stringLen = string.len(s) + local acceptableChars = "+-0123456789.e" + while (string.find(acceptableChars, string.sub(s, endPos, endPos), 1, true) and endPos <= stringLen) do + endPos = endPos + 1 + end + local stringValue = "return " .. string.sub(s, startPos, endPos - 1) + local stringEval = loadstring(stringValue) + assert( + stringEval, + "Failed to scan number [ " .. stringValue .. "] in JSON string at position " .. startPos .. " : " .. endPos + ) + return stringEval(), endPos + end + + --- Scans a JSON object into a Lua object. + -- startPos begins at the start of the object. + -- Returns the object and the next starting position. + -- @param s The string being scanned. + -- @param startPos The starting position of the scan. + -- @return table, int The scanned object as a table and the position of the next character to scan. + function decode_scanObject(s, startPos) + local object = {} + local stringLen = string.len(s) + local key, value + assert( + string.sub(s, startPos, startPos) == "{", + "decode_scanObject called but object does not start at position " .. startPos .. " in string:\n" .. s + ) + startPos = startPos + 1 + repeat + startPos = decode_scanWhitespace(s, startPos) + assert(startPos <= stringLen, "JSON string ended unexpectedly while scanning object.") + local curChar = string.sub(s, startPos, startPos) + if (curChar == "}") then + return object, startPos + 1 + end + if (curChar == ",") then + startPos = decode_scanWhitespace(s, startPos + 1) + end + assert(startPos <= stringLen, "JSON string ended unexpectedly scanning object.") + -- Scan the key + key, startPos = json.decode(s, startPos) + assert(startPos <= stringLen, "JSON string ended unexpectedly searching for value of key " .. key) + startPos = decode_scanWhitespace(s, startPos) + assert(startPos <= stringLen, "JSON string ended unexpectedly searching for value of key " .. key) + assert( + string.sub(s, startPos, startPos) == ":", + "JSON object key-value assignment mal-formed at " .. startPos + ) + startPos = decode_scanWhitespace(s, startPos + 1) + assert(startPos <= stringLen, "JSON string ended unexpectedly searching for value of key " .. key) + value, startPos = json.decode(s, startPos) + object[key] = value + until false -- infinite loop while key-value pairs are found + end + + -- START SoniEx2 + -- Initialize some things used by decode_scanString + -- You know, for efficiency + local escapeSequences = { + ["\\t"] = "\t", + ["\\f"] = "\f", + ["\\r"] = "\r", + ["\\n"] = "\n", + ["\\b"] = "" + } + setmetatable( + escapeSequences, + { + __index = function(t, k) + -- skip "\" aka strip escape + return string.sub(k, 2) + end + } + ) + -- END SoniEx2 + --- Scans a JSON string from the opening inverted comma or single quote to the + -- end of the string. + -- Returns the string extracted as a Lua string, + -- and the position of the next non-string character + -- (after the closing inverted comma or single quote). + -- @param s The string being scanned. + -- @param startPos The starting position of the scan. + -- @return string, int The extracted string as a Lua string, and the next character to parse. + function decode_scanString(s, startPos) + assert(startPos, "decode_scanString(..) called without start position") + local startChar = string.sub(s, startPos, startPos) + -- START SoniEx2 + -- PS: I don't think single quotes are valid JSON + assert(startChar == '"' or startChar == [[']], "decode_scanString called for a non-string") + --assert(startPos, "String decoding failed: missing closing " .. startChar .. " for string at position " .. oldStart) + local t = {} + local i, j = startPos, startPos + while string.find(s, startChar, j + 1) ~= j + 1 do + local oldj = j + i, j = string.find(s, "\\.", j + 1) + local x, y = string.find(s, startChar, oldj + 1) + if not i or x < i then + i, j = x, y - 1 + end + table.insert(t, string.sub(s, oldj + 1, i - 1)) + if string.sub(s, i, j) == "\\u" then + local a = string.sub(s, j + 1, j + 4) + j = j + 4 + local n = tonumber(a, 16) + assert(n, "String decoding failed: bad Unicode escape " .. a .. " at position " .. i .. " : " .. j) + -- math.floor(x/2^y) == lazy right shift + -- a % 2^b == bitwise_and(a, (2^b)-1) + -- 64 = 2^6 + -- 4096 = 2^12 (or 2^6 * 2^6) + local x + if n < 128 then + x = string.char(n % 128) + elseif n < 2048 then + -- [110x xxxx] [10xx xxxx] + x = string.char(192 + (math.floor(n / 64) % 32), 128 + (n % 64)) + else + -- [1110 xxxx] [10xx xxxx] [10xx xxxx] + x = string.char(224 + (math.floor(n / 4096) % 16), 128 + (math.floor(n / 64) % 64), 128 + (n % 64)) + end + table.insert(t, x) + else + table.insert(t, escapeSequences[string.sub(s, i, j)]) + end + end + table.insert(t, string.sub(j, j + 1)) + assert( + string.find(s, startChar, j + 1), + "String decoding failed: missing closing " .. + startChar .. " at position " .. j .. "(for string at position " .. startPos .. ")" + ) + return table.concat(t, ""), j + 2 + -- END SoniEx2 + end + + --- Scans a JSON string skipping all whitespace from the current start position. + -- Returns the position of the first non-whitespace character, or nil if the whole end of string is reached. + -- @param s The string being scanned + -- @param startPos The starting position where we should begin removing whitespace. + -- @return int The first position where non-whitespace was encountered, or string.len(s)+1 if the end of string + -- was reached. + function decode_scanWhitespace(s, startPos) + local whitespace = " \n\r\t" + local stringLen = string.len(s) + while (string.find(whitespace, string.sub(s, startPos, startPos), 1, true) and startPos <= stringLen) do + startPos = startPos + 1 + end + return startPos + end + + --- Encodes a string to be JSON-compatible. + -- This just involves back-quoting inverted commas, back-quotes and newlines, I think ;-) + -- @param s The string to return as a JSON encoded (i.e. backquoted string) + -- @return The string appropriately escaped. + local escapeList = { + ['"'] = '\\"', + ["\\"] = "\\\\", + ["/"] = "\\/", + [""] = "\\b", + ["\f"] = "\\f", + ["\n"] = "\\n", + ["\r"] = "\\r", + ["\t"] = "\\t" + } + + function json_private.encodeString(s) + local s = tostring(s) + return s:gsub( + ".", + function(c) + return escapeList[c] + end + ) -- SoniEx2: 5.0 compat + end + + -- Determines whether the given Lua type is an array or a table / dictionary. + -- We consider any table an array if it has indexes 1..n for its n items, and no + -- other data in the table. + -- I think this method is currently a little 'flaky', but can't think of a good way around it yet... + -- @param t The table to evaluate as an array + -- @return boolean, number True if the table can be represented as an array, false otherwise. If true, + -- the second returned value is the maximum + -- number of indexed elements in the array. + function isArray(t) + -- Next we count all the elements, ensuring that any non-indexed elements are not-encodable + -- (with the possible exception of 'n') + if (t == json.EMPTY_ARRAY) then + return true, 0 + end + if (t == json.EMPTY_OBJECT) then + return false + end + + local maxIndex = 0 + for k, v in pairs(t) do + if (type(k) == "number" and math.floor(k) == k and 1 <= k) then -- k,v is an indexed pair + if (not isEncodable(v)) then + return false + end -- All array elements must be encodable + maxIndex = math.max(maxIndex, k) + else + if (k == "n") then + if v ~= (t.n or #t) then + return false + end -- False if n does not hold the number of elements + else -- Else of (k=='n') + if isEncodable(v) then + return false + end + end -- End of (k~='n') + end -- End of k,v not an indexed pair + end -- End of loop across all pairs + return true, maxIndex + end + + --- Determines whether the given Lua object / table / variable can be JSON encoded. The only + -- types that are JSON encodable are: string, boolean, number, nil, table and json.null. + -- In this implementation, all other types are ignored. + -- @param o The object to examine. + -- @return boolean True if the object should be JSON encoded, false if it should be ignored. + function isEncodable(o) + local t = type(o) + return (t == "string" or t == "boolean" or t == "number" or t == "nil" or t == "table") or + (t == "function" and o == json.null) + end + + return json +end +local debugger_print = print +local debug_server = nil +local breakInfoSocket = nil +local json = createJson() +local LuaDebugger = { + fileMaps = {}, + Run = true, --表示正常运行只检测断点 + StepIn = false, + StepInLevel = 0, + StepNext = false, + StepNextLevel = 0, + StepOut = false, + breakInfos = {}, + runTimeType = nil, + isHook = true, + pathCachePaths = {}, + isProntToConsole = 1, + isFoxGloryProject = false, + isDebugPrint = true, + hookType = "lrc", + currentFileName = "", + currentTempFunc = nil, + --分割字符串缓存 + splitFilePaths = {}, + DebugLuaFie = "", + version = "0.9.3", + serVarLevel = 4 +} +local debug_hook = nil +local _resume = coroutine.resume +coroutine.resume = function(co, ...) + if (LuaDebugger.isHook) then + if coroutine.status(co) ~= "dead" then + debug.sethook(co, debug_hook, "lrc") + end + end + return _resume(co, ...) +end +local _wrap = coroutine.wrap +coroutine.wrap = function(fun,dd) + local newFun =_wrap(function() + debug.sethook(debug_hook, "lrc") + return fun(); + end) + return newFun +end + +LuaDebugger.event = { + S2C_SetBreakPoints = 1, + C2S_SetBreakPoints = 2, + S2C_RUN = 3, + C2S_HITBreakPoint = 4, + S2C_ReqVar = 5, + C2S_ReqVar = 6, + --单步跳过请求 + S2C_NextRequest = 7, + --单步跳过反馈 + C2S_NextResponse = 8, + -- 单步跳过 结束 没有下一步 + C2S_NextResponseOver = 9, + --单步跳入 + S2C_StepInRequest = 10, + C2S_StepInResponse = 11, + --单步跳出 + S2C_StepOutRequest = 12, + --单步跳出返回 + C2S_StepOutResponse = 13, + --打印 + C2S_LuaPrint = 14, + S2C_LoadLuaScript = 16, + C2S_SetSocketName = 17, + C2S_LoadLuaScript = 18, + C2S_DebugXpCall = 20, + S2C_DebugClose = 21, + S2C_SerVar = 24, + C2S_SerVar = 25, + S2C_ReLoadFile = 26, + C2S_ReLoadFile = 27, +} +--@region print +function print(...) + if (LuaDebugger.isProntToConsole == 1 or LuaDebugger.isProntToConsole == 3) then + debugger_print(...) + end + if (LuaDebugger.isProntToConsole == 1 or LuaDebugger.isProntToConsole == 2) then + if (debug_server) then + local arg = {...} --这里的...和{}符号中间需要有空格号,否则会出错 + local str = "" + if (#arg == 0) then + arg = {"nil"} + end + for k, v in pairs(arg) do + str = str .. tostring(v) .. "\t" + end + local sendMsg = { + event = LuaDebugger.event.C2S_LuaPrint, + data = {msg = ZZBase64.encode(str), type = 1} + } + local sendStr = json.encode(sendMsg) + debug_server:send(sendStr .. "__debugger_k0204__") + end + end +end + +function luaIdePrintWarn(...) + if (LuaDebugger.isProntToConsole == 1 or LuaDebugger.isProntToConsole == 3) then + debugger_print(...) + end + if (LuaDebugger.isProntToConsole == 1 or LuaDebugger.isProntToConsole == 2) then + if (debug_server) then + local arg = {...} --这里的...和{}符号中间需要有空格号,否则会出错 + local str = "" + if (#arg == 0) then + arg = {"nil"} + end + for k, v in pairs(arg) do + str = str .. tostring(v) .. "\t" + end + local sendMsg = { + event = LuaDebugger.event.C2S_LuaPrint, + data = {msg = ZZBase64.encode(str), type = 2} + } + local sendStr = json.encode(sendMsg) + debug_server:send(sendStr .. "__debugger_k0204__") + end + end +end +function luaIdePrintErr(...) + if (LuaDebugger.isProntToConsole == 1 or LuaDebugger.isProntToConsole == 3) then + debugger_print(...) + end + if (LuaDebugger.isProntToConsole == 1 or LuaDebugger.isProntToConsole == 2) then + if (debug_server) then + local arg = {...} --这里的...和{}符号中间需要有空格号,否则会出错 + local str = "" + if (#arg == 0) then + arg = {"nil"} + end + for k, v in pairs(arg) do + str = str .. tostring(v) .. "\t" + end + local sendMsg = { + event = LuaDebugger.event.C2S_LuaPrint, + data = {msg = ZZBase64.encode(str), type = 3} + } + local sendStr = json.encode(sendMsg) + debug_server:send(sendStr .. "__debugger_k0204__") + end + end +end +--@endregion + +--@region 辅助方法 +local function debugger_lastIndex(str, p) + local startIndex = string.find(str, p, 1) + while startIndex do + local findstartIndex = string.find(str, p, startIndex + 1) + if (not findstartIndex) then + break + else + startIndex = findstartIndex + end + end + return startIndex +end +local function debugger_convertParentDir(dir) + local index, endindex = string.find(dir, "/%.%./") + if (index) then + local file1 = string.sub(dir, 1, index - 1) + local startIndex = debugger_lastIndex(file1, "/") + file1 = string.sub(file1, 1, startIndex - 1) + local file2 = string.sub(dir, endindex) + dir = file1 .. file2 + dir = debugger_convertParentDir(dir) + return dir + else + return dir + end +end + +local function debugger_getFilePathInfo(file) + local fileName = nil + local dir = nil + file = file:gsub("/.\\", "/") + file = file:gsub("\\", "/") + file = file:gsub("//", "/") + + + if file:find("@") == 1 then + file = file:sub(2) + end + local findex = file:find("%./") + if (findex == 1) then + file = file:sub(3) + end + + file = debugger_convertParentDir(file) + local fileLength = string.len(file) + local suffixNames = { + ".lua", + ".lua.txt", + ".txt", + ".bytes" + } + table.sort( + suffixNames, + function(name1, name2) + return string.len(name1) > string.len(name2) + end + ) + local suffixLengs = {} + for i, suffixName in ipairs(suffixNames) do + table.insert(suffixLengs, string.len(suffixName)) + end + + local fileLength = string.len(file) + for i, suffix in ipairs(suffixNames) do + local suffixName = string.sub(file, fileLength - suffixLengs[i] + 1) + if (suffixName == suffix) then + file = string.sub(file, 1, fileLength - suffixLengs[i]) + break + end + end + local fileNameStartIndex = debugger_lastIndex(file, "/") + if (fileNameStartIndex) then + fileName = string.sub(file, fileNameStartIndex + 1) + + dir = string.sub(file, 1, fileNameStartIndex) + file = dir .. fileName + else + fileNameStartIndex = debugger_lastIndex(file, "%.") + if (not fileNameStartIndex) then + fileName = file + dir = "" + else + dir = string.sub(file, 1, fileNameStartIndex) + dir = dir:gsub("%.", "/") + fileName = string.sub(file, fileNameStartIndex + 1) + file = dir .. fileName + end + end + + return file, dir, fileName +end + +--@endregion + + + +----=============================工具方法============================================= +--@region 工具方法 + + +local function debugger_strSplit(input, delimiter) + input = tostring(input) + delimiter = tostring(delimiter) + if (delimiter == "") then + return false + end + local pos, arr = 0, {} + -- for each divider found + for st, sp in function() + return string.find(input, delimiter, pos, true) + end do + table.insert(arr, string.sub(input, pos, st - 1)) + pos = sp + 1 + end + table.insert(arr, string.sub(input, pos)) + return arr +end +local function debugger_strTrim(input) + input = string.gsub(input, "^[ \t\n\r]+", "") + return string.gsub(input, "[ \t\n\r]+$", "") +end +local function debugger_dump(value, desciption, nesting) + if type(nesting) ~= "number" then + nesting = 3 + end + local lookupTable = {} + local result = {} + local function _v(v) + if type(v) == "string" then + v = '"' .. v .. '"' + end + return tostring(v) + end + local traceback = debugger_strSplit(debug.traceback("", 2), "\n") + print("dump from: " .. debugger_strTrim(traceback[3])) + local function _dump(value, desciption, indent, nest, keylen) + desciption = desciption or "" + local spc = "" + if type(keylen) == "number" then + spc = string.rep(" ", keylen - string.len(_v(desciption))) + end + if type(value) ~= "table" then + result[#result + 1] = string.format("%s%s%s = %s", indent, _v(desciption), spc, _v(value)) + elseif lookupTable[value] then + result[#result + 1] = string.format("%s%s%s = *REF*", indent, desciption, spc) + else + lookupTable[value] = true + if nest > nesting then + result[#result + 1] = string.format("%s%s = *MAX NESTING*", indent, desciption) + else + result[#result + 1] = string.format("%s%s = {", indent, _v(desciption)) + local indent2 = indent .. " " + local keys = {} + local keylen = 0 + local values = {} + for k, v in pairs(value) do + keys[#keys + 1] = k + local vk = _v(k) + local vkl = string.len(vk) + if vkl > keylen then + keylen = vkl + end + values[k] = v + end + table.sort( + keys, + function(a, b) + if type(a) == "number" and type(b) == "number" then + return a < b + else + return tostring(a) < tostring(b) + end + end + ) + for i, k in ipairs(keys) do + _dump(values[k], k, indent2, nest + 1, keylen) + end + result[#result + 1] = string.format("%s}", indent) + end + end + end + _dump(value, desciption, "- ", 1) + for i, line in ipairs(result) do + print(line) + end +end +--@endregion +local function debugger_valueToString(v) + local vtype = type(v) + local vstr = nil + if (vtype == "userdata") then + if (LuaDebugger.isFoxGloryProject) then + + return "userdata",vtype + + else + return tostring(v), vtype + end + elseif (vtype == "table" or vtype == "function" or vtype == "boolean") then + local value = vtype + xpcall(function() + value = tostring(v) + end,function() + value = vtype + end) + return value, vtype + elseif (vtype == "number" or vtype == "string" ) then + return v, vtype + else + return tostring(v), vtype + end +end +local function debugger_setVarInfo(name, value) + local valueStr, valueType = debugger_valueToString(value) + local nameStr,nameType = debugger_valueToString(name) + if(valueStr == nil) then + valueStr = valueType + end + local valueInfo = { + name =nameStr, + valueType = valueType, + valueStr = ZZBase64.encode(valueStr) + } + + return valueInfo +end + +local function debugger_getvalue(f) + local i = 1 + local locals = {} + -- get locals + while true do + local name, value = debug.getlocal(f, i) + if not name then + break + end + if (name ~= "(*temporary)") then + locals[name] = value + end + i = i + 1 + end + local func = getinfo(f, "f").func + i = 1 + local ups = {} + while func do -- check for func as it may be nil for tail calls + local name, value = debug.getupvalue(func, i) + if not name then + break + end + if (name == "_ENV") then + ups["_ENV_"] = value + else + ups[name] = value + end + i = i + 1 + end + + return {locals = locals, ups = ups} +end +--获取堆栈 +debugger_stackInfo = + function(ignoreCount, event) + local datas = {} + local stack = {} + local varInfos = {} + local funcs = {} + local index = 0 + for i = ignoreCount, 100 do + local source = getinfo(i) + local isadd = true + if (i == ignoreCount) then + local file = source.source + if (file:find(LuaDebugger.DebugLuaFie)) then + return + end + if (file == "=[C]") then + isadd = false + end + end + if not source then + break + end + if (isadd) then + local fullName, dir, fileName = debugger_getFilePathInfo(source.source) + local info = { + src = fullName, + scoreName = source.name, + currentline = source.currentline, + linedefined = source.linedefined, + what = source.what, + nameWhat = source.namewhat + } + index = i + local vars = debugger_getvalue(i + 1) + table.insert(stack, info) + table.insert(varInfos, vars) + table.insert(funcs, source.func) + end + if source.what == "main" then + break + end + end + + local stackInfo = {stack = stack, vars = varInfos, funcs = funcs} + local data = { + stack = stackInfo.stack, + vars = stackInfo.vars, + funcs = stackInfo.funcs, + event = event, + funcsLength = #stackInfo.funcs, + upFunc = getinfo(ignoreCount - 3, "f").func + } + LuaDebugger.currentTempFunc = data.funcs[1] + return data +end + +--===========================点断信息================================================== +--根据不同的游戏引擎进行定时获取断点信息 +--CCDirector:sharedDirector():getScheduler() +local debugger_setBreak = nil +local function debugger_receiveDebugBreakInfo() + -- if (jit) then + -- if (LuaDebugger.debugLuaType ~= "jit") then + -- local msg = "当前luajit版本为: " .. jit.version .. " 请使用LuaDebugjit 进行调试!" + -- print(msg) + -- end + -- end + if (breakInfoSocket) then + local msg, status = breakInfoSocket:receive() + if(LuaDebugger.isLaunch and status == "closed") then + os.exit() + end + if (msg) then + local netData = json.decode(msg) + if netData.event == LuaDebugger.event.S2C_SetBreakPoints then + debugger_setBreak(netData.data) + elseif netData.event == LuaDebugger.event.S2C_LoadLuaScript then + LuaDebugger.loadScriptBody = netData.data + debugger_exeLuaString() + debugger_sendMsg(breakInfoSocket,LuaDebugger.event.C2S_LoadLuaScript,LuaDebugger.loadScriptBody) + elseif netData.event == LuaDebugger.event.S2C_ReLoadFile then + LuaDebugger.reLoadFileBody = netData.data + LuaDebugger.isReLoadFile = false + LuaDebugger.reLoadFileBody.isReLoad = debugger_reLoadFile(LuaDebugger.reLoadFileBody) + print("重载结果:",LuaDebugger.reLoadFileBody.isReLoad) + LuaDebugger.reLoadFileBody.script = nil + debugger_sendMsg( + breakInfoSocket, + LuaDebugger.event.C2S_ReLoadFile, + { + stack = LuaDebugger.reLoadFileBody + + } + ) + end + end + end +end +local function splitFilePath(path) + if (LuaDebugger.splitFilePaths[path]) then + return LuaDebugger.splitFilePaths[path] + end + local pos, arr = 0, {} + -- for each divider found + for st, sp in function() + return string.find(path, "/", pos, true) + end do + local pathStr = string.sub(path, pos, st - 1) + table.insert(arr, pathStr) + pos = sp + 1 + end + local pathStr = string.sub(path, pos) + table.insert(arr, pathStr) + LuaDebugger.splitFilePaths[path] = arr + return arr +end +debugger_setBreak = + function(datas) + local breakInfos = LuaDebugger.breakInfos + for i, data in ipairs(datas) do + data.fileName = string.lower(data.fileName) + data.serverPath = string.lower(data.serverPath) + local breakInfo = breakInfos[data.fileName] + if (not breakInfo) then + breakInfos[data.fileName] = {} + breakInfo = breakInfos[data.fileName] + end + if (not data.breakDatas or #data.breakDatas == 0) then + breakInfo[data.serverPath] = nil + else + local fileBreakInfo = breakInfo[data.serverPath] + if (not fileBreakInfo) then + fileBreakInfo = { + pathNames = splitFilePath(data.serverPath), + --命中次數判斷計數器 + hitCounts = {} + } + breakInfo[data.serverPath] = fileBreakInfo + end + local lineInfos = {} + for li, breakData in ipairs(data.breakDatas) do + lineInfos[breakData.line] = breakData + if (breakData.hitCondition and breakData.hitCondition ~= "") then + breakData.hitCondition = tonumber(breakData.hitCondition) + else + breakData.hitCondition = 0 + end + if (not fileBreakInfo.hitCounts[breakData.line]) then + fileBreakInfo.hitCounts[breakData.line] = 0 + end + end + fileBreakInfo.lines = lineInfos + --這裡添加命中次數判斷 + for line, count in pairs(fileBreakInfo.hitCounts) do + if (not lineInfos[line]) then + fileBreakInfo.hitCounts[line] = nil + end + end + end + local count = 0 + for i, linesInfo in pairs(breakInfo) do + count = count + 1 + end + if (count == 0) then + breakInfos[data.fileName] = nil + end + end + --debugger_dump(breakInfos, "breakInfos", 6) + --检查是否需要断点 + local isHook = false + for k, v in pairs(breakInfos) do + isHook = true + break + end + + --这样做的原因是为了最大限度的使手机调试更加流畅 注意这里会连续的进行n次 + if (isHook) then + if (not LuaDebugger.isHook) then + debug.sethook(debug_hook, "lrc") + end + LuaDebugger.isHook = true + else + if (LuaDebugger.isHook) then + debug.sethook() + end + LuaDebugger.isHook = false + end +end +local function debugger_checkFileIsBreak(fileName) + return LuaDebugger.breakInfos[fileName] +end +--=====================================断点信息 end ---------------------------------------------- +local controller_host = "192.168.1.102" +local controller_port = 7003 +debugger_sendMsg = function(serverSocket, eventName, data) + local sendMsg = { + event = eventName, + data = data + } + local sendStr = json.encode(sendMsg) + serverSocket:send(sendStr .. "__debugger_k0204__") +end +function debugger_conditionStr(condition, vars, callBack) + local function loadScript() + local currentTabble = {} + + local locals = vars[1].locals + local ups = vars[1].ups + if (ups) then + for k, v in pairs(ups) do + currentTabble[k] = v + end + end + + if (locals) then + for k, v in pairs(locals) do + currentTabble[k] = v + end + end + setmetatable(currentTabble, {__index = _G}) + local fun = loadstring("return " .. condition) + setfenv(fun, currentTabble) + return fun() + end + local status, + msg = + xpcall( + loadScript, + function(error) + print(error) + end + ) + if (status and msg) then + callBack() + end +end +--执行lua字符串 +debugger_exeLuaString = function() + + local function loadScript() + + local script = LuaDebugger.loadScriptBody.script + if (LuaDebugger.loadScriptBody.isBreak) then + local currentTabble = {_G = _G} + local frameId = LuaDebugger.loadScriptBody.frameId + frameId = frameId + local func = LuaDebugger.currentDebuggerData.funcs[frameId] + local vars = LuaDebugger.currentDebuggerData.vars[frameId] + local locals = vars.locals + local ups = vars.ups + for k, v in pairs(ups) do + currentTabble[k] = v + end + for k, v in pairs(locals) do + currentTabble[k] = v + end + setmetatable(currentTabble, {__index = _G}) + + local fun = loadstring(script) + setfenv(fun, currentTabble) + fun() + else + local fun = loadstring(script) + fun() + end + end + local status, + msg = + xpcall( + loadScript, + function(error) + + -- debugger_sendMsg(debug_server, LuaDebugger.event.C2S_LoadLuaScript, LuaDebugger.loadScriptBody) + end + ) + LuaDebugger.loadScriptBody.script = nil + if (LuaDebugger.loadScriptBody.isBreak) then + LuaDebugger.serVarLevel = LuaDebugger.serVarLevel+1 + LuaDebugger.currentDebuggerData = debugger_stackInfo(LuaDebugger.serVarLevel, LuaDebugger.event.C2S_HITBreakPoint) + LuaDebugger.loadScriptBody.stack = LuaDebugger.currentDebuggerData.stack + end + LuaDebugger.loadScriptBody.complete = true + +end +--@region 调试中修改变量值 + + +--根据key 值在 value 查找 +local function debugger_getTablekey(key,keyType,value) + if(keyType == -1) then + return key + elseif(keyType == 1) then + return tonumber(key) + elseif(keyType == 2) then + local valueKey = nil + for k,v in pairs(value) do + local nameType = type(k) + if(nameType == "userdata" or nameType == "table") then + if (not LuaDebugger.isFoxGloryProject) then + valueKey = tostring(k) + if(key == valueKey) then + return k + end + break + end + end + end + + end +end + +local function debugger_setVarValue(server, data) + + local newValue = nil + local level = LuaDebugger.serVarLevel+LuaDebugger.setVarBody.frameId + local firstKeyName = data.keys[1] + --@region vars check + local localValueChangeIndex = -1 + local upValueChangeIndex = -1 + local upValueFun = nil + local oldValue = nil + local i = 1 + local locals = {} + -- get locals + while true do + local name, value = debug.getlocal(level, i) + if not name then + break + end + if(firstKeyName == name) then + localValueChangeIndex = i + oldValue = value + end + if (name ~= "(*temporary)") then + locals[name] = value + end + i = i + 1 + end + local func = getinfo(level, "f").func + i = 1 + local ups = {} + while func do -- check for func as it may be nil for tail calls + local name, value = debug.getupvalue(func, i) + + if not name then + break + end + if(localValueChangeIndex == -1 and firstKeyName == name) then + upValueFun = func + oldValue = value + upValueChangeIndex = i + end + if (name == "_ENV") then + ups["_ENV_"] = value + else + ups[name] = value + end + i = i + 1 + end +--@endregion + local vars = {locals = locals, ups = ups} + + local function loadScript() + local currentTabble = {} + local locals = vars.locals + local ups = vars.ups + if (ups) then + for k, v in pairs(ups) do + currentTabble[k] = v + end + end + + if (locals) then + for k, v in pairs(locals) do + currentTabble[k] = v + end + end + setmetatable(currentTabble, {__index = _G}) + local fun = loadstring("return " .. data.value) + setfenv(fun, currentTabble) + newValue = fun() + end + local status, + msg = + xpcall( + loadScript, + function(error) + print(error, "============================") + end + ) + + local i = 1 + + -- local 查找并替换 + local keyLength = #data.keys + + if(keyLength == 1) then + if(localValueChangeIndex ~= -1) then + + debug.setlocal(level, localValueChangeIndex, newValue) + elseif(upValueFun ~= nil) then + debug.setupvalue( upValueFun, upValueChangeIndex, newValue ) + else + --全局变量查找 + if(_G[firstKeyName]) then + _G[firstKeyName] = newValue + end + end + else + if(not oldValue) then + if(_G[firstKeyName]) then + oldValue = _G[firstKeyName] + end + end + local tempValue = oldValue + for i=2,keyLength-1 do + if(tempValue) then + oldValue = oldValue[debugger_getTablekey(data.keys[i],data.numberTypes[i],oldValue)] + end + end + if(tempValue) then + oldValue[debugger_getTablekey(data.keys[keyLength],data.numberTypes[keyLength],oldValue)] = newValue + end + end + local varInfo = debugger_setVarInfo(data.varName, newValue) + data.varInfo = varInfo + LuaDebugger.serVarLevel = LuaDebugger.serVarLevel+1 + LuaDebugger.currentDebuggerData = debugger_stackInfo(LuaDebugger.serVarLevel, LuaDebugger.event.C2S_HITBreakPoint) + +end +--@endregion + + + + +--调试修改变量值统一的 _resume +checkSetVar = + function() + if (LuaDebugger.isSetVar) then + LuaDebugger.isSetVar = false + debugger_setVarValue(debug_server,LuaDebugger.setVarBody) + LuaDebugger.serVarLevel = LuaDebugger.serVarLevel+1 + _resume(coro_debugger, LuaDebugger.setVarBody) + xpcall( + checkSetVar, + function(error) + print("设置变量", error) + end + ) + elseif(LuaDebugger.isLoadLuaScript) then + LuaDebugger.isLoadLuaScript = false + debugger_exeLuaString() + LuaDebugger.serVarLevel = LuaDebugger.serVarLevel+1 + _resume(coro_debugger, LuaDebugger.reLoadFileBody) + xpcall( + checkSetVar, + function(error) + print("执行代码", error) + end + ) + elseif(LuaDebugger.isReLoadFile) then + LuaDebugger.isReLoadFile = false + LuaDebugger.reLoadFileBody.isReLoad = debugger_reLoadFile(LuaDebugger.reLoadFileBody) + print("重载结果:",LuaDebugger.reLoadFileBody.isReLoad) + LuaDebugger.reLoadFileBody.script = nil + LuaDebugger.serVarLevel = LuaDebugger.serVarLevel+1 + _resume(coro_debugger, LuaDebugger.reLoadFileBody) + xpcall( + checkSetVar, + function(error) + print("重新加载文件", error) + end + ) + end +end + + + +local function getSource(source) + source = string.lower(source) + if (LuaDebugger.pathCachePaths[source]) then + LuaDebugger.currentLineFile = LuaDebugger.pathCachePaths[source] + return LuaDebugger.pathCachePaths[source] + end + + local fullName, dir, fileName = debugger_getFilePathInfo(source) + LuaDebugger.currentLineFile = fullName + LuaDebugger.pathCachePaths[source] = fileName + + return fileName +end +local function debugger_GeVarInfoBytUserData(server, var) + local fileds = LuaDebugTool.getUserDataInfo(var) + + local varInfos = {} + + + --c# vars + for i = 1, fileds.Count do + local filed = fileds[i - 1] + local valueInfo = { + name = filed.name, + valueType = filed.valueType, + valueStr = ZZBase64.encode(filed.valueStr), + isValue = filed.isValue, + csharp = true + } + + table.insert(varInfos, valueInfo) + end + return varInfos +end + +local function debugger_getValueByScript(value, script) + local val = nil + local status, + msg = + xpcall( + function() + local fun = loadstring("return " .. script) + setfenv(fun, value) + val = fun() + end, + function(error) + print(error, "====>") + val = nil + end + ) + + return val +end +local function debugger_getVarByKeys(value, keys, index) + local str = "" + local keyLength = #keys + for i = index, keyLength do + local key = keys[i] + if (key == "[metatable]") then + else + if (i == index) then + if (string.find(key, "%.")) then + if (str == "") then + i = index + 1 + value = value[key] + end + if (i >= #keys) then + return index, value + end + + return debugger_getVarByKeys(value, keys, i) + else + str = key + end + else + if (string.find(key, "%[")) then + str = str .. key + elseif (type(key) == "string") then + if (string.find(key, "table:") or string.find(key, "userdata:") or string.find(key, "function:")) then + if (str ~= "") then + local vl = debugger_getValueByScript(value, str) + value = vl + if (value) then + for k, v in pairs(value) do + local ktype = type(k) + + if (ktype == "userdata" or ktype == "table" or ktype == "function") then + local keyName = debugger_valueToString(k) + if (keyName == key) then + value = v + break + end + end + end + end + str = "" + if (i == keyLength) then + return #keys, value + else + return debugger_getVarByKeys(value, keys, i + 1) + end + else + str = str .. '["' .. key .. '"]' + end + else + str = str .. '["' .. key .. '"]' + end + else + str = str .. "[" .. key .. "]" + end + end + end + end + + local v = debugger_getValueByScript(value, str) + + return #keys, v +end +--[[ + @desc: 查找c# 值 + author:k0204 + time:2018-04-07 21:32:31 + return +]] +local function debugger_getCSharpValue(value, searchIndex, keys) + local key = keys[searchIndex] + local val = LuaDebugTool.getCSharpValue(value, key) + if (val) then + --1最后一个 直接返回 + if (searchIndex == #keys) then + return #keys, val + else + --2再次获得 如果没有找到那么 进行lua 层面查找 + local vindex, val1 = debugger_getCSharpValue(val, searchIndex + 1, keys) + if (not val1) then + --组建新的keys + local tempKeys = {} + for i = vindex, #keys do + table.insert(tempKeys, keys[i]) + end + local vindx, val1 = debugger_searchVarByKeys(value, searckKeys, 1) + return vindx, val1 + else + return vindex, val1 + end + end + else + --3最终这里返回 所以2 中 没有当val1 不为空的处理 + return searchIndex, val + end +end +local function debugger_searchVarByKeys(value, keys, searckKeys) + local index, val = debugger_getVarByKeys(value, searckKeys, 1) + + if (not LuaDebugTool or not LuaDebugTool.getCSharpValue or type(LuaDebugTool.getCSharpValue) ~= "function") then + return index, val + end + if (val) then + if (index == #keys) then + return index, val + else + local searchStr = "" + --进行c# 值查找 + local keysLength = #keys + local searchIndex = index + 1 + local sindex, val = debugger_getCSharpValue(val, searchIndex, keys) + return sindex, val + end + else + --进行递减 + local tempKeys = {} + for i = 1, #searckKeys - 1 do + table.insert(tempKeys, keys[i]) + end + if (#tempKeys == 0) then + return #keys, nil + end + return debugger_searchVarByKeys(value, keys, tempKeys) + end +end +--[[ + @desc: 获取metatable 信息 + author:k0204 + time:2018-04-06 20:27:12 + return +]] +local function debugger_getmetatable(value, metatable, vinfos, server, variablesReference, debugSpeedIndex, metatables) + for i, mtable in ipairs(metatables) do + if (metatable == mtable) then + return vinfos + end + end + table.insert(metatables, metatable) + for k, v in pairs(metatable) do + local val = nil + if (type(k) == "string") then + xpcall( + function() + val = value[k] + end, + function(error) + val = nil + end + ) + if (val == nil) then + xpcall( + function() + if (string.find(k, "__")) then + val = v + end + end, + function(error) + val = nil + end + ) + end + end + if (val) then + local vinfo = debugger_setVarInfo(k, val) + table.insert(vinfos, vinfo) + if (#vinfos > 10) then + debugger_sendMsg( + server, + LuaDebugger.event.C2S_ReqVar, + { + variablesReference = variablesReference, + debugSpeedIndex = debugSpeedIndex, + vars = vinfos, + isComplete = 0 + } + ) + vinfos = {} + end + end + end + local m = getmetatable(metatable) + if (m) then + return debugger_getmetatable(value, m, vinfos, server, variablesReference, debugSpeedIndex, metatables) + else + return vinfos + end +end +local function debugger_sendTableField(luatable, vinfos, server, variablesReference, debugSpeedIndex, valueType) + if (valueType == "userdata") then + if (tolua and tolua.getpeer) then + luatable = tolua.getpeer(luatable) + else + return vinfos + end + end + if (luatable == nil) then + return vinfos + end + for k, v in pairs(luatable) do + local vinfo = debugger_setVarInfo(k, v) + table.insert(vinfos, vinfo) + if (#vinfos > 10) then + debugger_sendMsg( + server, + LuaDebugger.event.C2S_ReqVar, + { + variablesReference = variablesReference, + debugSpeedIndex = debugSpeedIndex, + vars = vinfos, + isComplete = 0 + } + ) + vinfos = {} + end + end + + return vinfos +end +local function debugger_sendTableValues(value, server, variablesReference, debugSpeedIndex) + local vinfos = {} + local luatable = {} + local valueType = type(value) + local userDataInfos = {} + local m = nil + + if (valueType == "userdata") then + m = getmetatable(value) + + vinfos = debugger_sendTableField(value, vinfos, server, variablesReference, debugSpeedIndex, valueType) + + if (LuaDebugTool) then + local varInfos = debugger_GeVarInfoBytUserData(server, value, variablesReference, debugSpeedIndex) + + for i, v in ipairs(varInfos) do + if (v.valueType == "System.Byte[]" and value[v.name] and type(value[v.name]) == "string") then + local valueInfo = { + name = v.name, + valueType = "string", + valueStr = ZZBase64.encode(value[v.name]) + } + table.insert(vinfos, valueInfo) + else + table.insert(vinfos, v) + end + if (#vinfos > 10) then + debugger_sendMsg( + server, + LuaDebugger.event.C2S_ReqVar, + { + variablesReference = variablesReference, + debugSpeedIndex = debugSpeedIndex, + vars = vinfos, + isComplete = 0 + } + ) + vinfos = {} + end + end + + end + else + m = getmetatable(value) + vinfos = debugger_sendTableField(value, vinfos, server, variablesReference, debugSpeedIndex, valueType) + end + + if (m) then + vinfos = debugger_getmetatable(value, m, vinfos, server, variablesReference, debugSpeedIndex, {}) + end + debugger_sendMsg( + server, + LuaDebugger.event.C2S_ReqVar, + { + variablesReference = variablesReference, + debugSpeedIndex = debugSpeedIndex, + vars = vinfos, + isComplete = 1 + } + ) +end + +--获取lua 变量的方法 +local function debugger_getBreakVar(body, server) + local variablesReference = body.variablesReference + local debugSpeedIndex = body.debugSpeedIndex + local vinfos = {} + local function exe() + local frameId = body.frameId + local type_ = body.type + local keys = body.keys + --找到对应的var + local vars = nil + if (type_ == 1) then + vars = LuaDebugger.currentDebuggerData.vars[frameId + 1] + vars = vars.locals + elseif (type_ == 2) then + vars = LuaDebugger.currentDebuggerData.vars[frameId + 1] + vars = vars.ups + elseif (type_ == 3) then + vars = _G + end + if (#keys == 0) then + debugger_sendTableValues(vars, server, variablesReference, debugSpeedIndex) + return + end + local index, value = debugger_searchVarByKeys(vars, keys, keys) + if (value) then + local valueType = type(value) + if (valueType == "table" or valueType == "userdata") then + + debugger_sendTableValues(value, server, variablesReference, debugSpeedIndex) + else + if (valueType == "function") then + value = tostring(value) + end + debugger_sendMsg( + server, + LuaDebugger.event.C2S_ReqVar, + { + variablesReference = variablesReference, + debugSpeedIndex = debugSpeedIndex, + vars = ZZBase64.encode(value), + isComplete = 1, + varType = valueType + } + ) + end + else + debugger_sendMsg( + server, + LuaDebugger.event.C2S_ReqVar, + { + variablesReference = variablesReference, + debugSpeedIndex = debugSpeedIndex, + vars = {}, + isComplete = 1, + varType = "nil" + } + ) + end + end + xpcall( + exe, + function(error) + -- print("获取变量错误 错误消息-----------------") + -- print(error) + -- print(debug.traceback("", 2)) + debugger_sendMsg( + server, + LuaDebugger.event.C2S_ReqVar, + { + variablesReference = variablesReference, + debugSpeedIndex = debugSpeedIndex, + vars = { + { + name = "error", + valueType = "string", + valueStr = ZZBase64.encode("无法获取属性值:" .. error .. "->" .. debug.traceback("", 2)), + isValue = false + } + }, + isComplete = 1 + } + ) + end + ) +end +local function ResetDebugInfo() + LuaDebugger.Run = false + LuaDebugger.StepIn = false + LuaDebugger.StepNext = false + LuaDebugger.StepOut = false + LuaDebugger.StepNextLevel = 0 +end +local function debugger_loop(server) + server = debug_server + --命令 + local command + local eval_env = {} + local arg + while true do + local line, status = server:receive() + if (status == "closed") then + if(LuaDebugger.isLaunch) then + os.exit() + else + debug.sethook() + coroutine.yield() + end + end + if (line) then + local netData = json.decode(line) + local event = netData.event + local body = netData.data + if (event == LuaDebugger.event.S2C_DebugClose) then + if(LuaDebugger.isLaunch) then + os.exit() + else + debug.sethook() + coroutine.yield() + end + + elseif event == LuaDebugger.event.S2C_SetBreakPoints then + --设置断点信息 + local function setB() + debugger_setBreak(body) + end + xpcall( + setB, + function(error) + print(error) + end + ) + elseif event == LuaDebugger.event.S2C_RUN then --开始运行 + LuaDebugger.runTimeType = body.runTimeType + LuaDebugger.isProntToConsole = body.isProntToConsole + LuaDebugger.isFoxGloryProject = body.isFoxGloryProject + LuaDebugger.isLaunch = body.isLaunch + ResetDebugInfo() + LuaDebugger.Run = true + local data = coroutine.yield() + LuaDebugger.serVarLevel = 4 + LuaDebugger.currentDebuggerData = data + debugger_sendMsg( + server, + data.event, + { + stack = data.stack + } + ) + elseif event == LuaDebugger.event.S2C_ReqVar then -- 获取变量信息 + --请求数据信息 + debugger_getBreakVar(body, server) + elseif event == LuaDebugger.event.S2C_NextRequest then -- 设置单步跳过 + ResetDebugInfo() + LuaDebugger.StepNext = true + LuaDebugger.StepNextLevel = 0 + --设置当前文件名和当前行数 + local data = coroutine.yield() + LuaDebugger.serVarLevel = 4 + --重置调试信息 + LuaDebugger.currentDebuggerData = data + debugger_sendMsg( + server, + data.event, + { + stack = data.stack + } + ) + elseif (event == LuaDebugger.event.S2C_StepInRequest) then --单步跳入 + --单步跳入 + ResetDebugInfo() + LuaDebugger.StepIn = true + + local data = coroutine.yield() + LuaDebugger.serVarLevel = 4 + --重置调试信息 + LuaDebugger.currentDebuggerData = data + debugger_sendMsg( + server, + data.event, + { + stack = data.stack, + eventType = data.eventType + } + ) + elseif (event == LuaDebugger.event.S2C_StepOutRequest) then + --单步跳出 + ResetDebugInfo() + LuaDebugger.StepOut = true + local data = coroutine.yield() + LuaDebugger.serVarLevel = 4 + --重置调试信息 + LuaDebugger.currentDebuggerData = data + debugger_sendMsg( + server, + data.event, + { + stack = data.stack, + eventType = data.eventType + } + ) + elseif event == LuaDebugger.event.S2C_LoadLuaScript then + LuaDebugger.loadScriptBody = body + LuaDebugger.isLoadLuaScript = true + local data = coroutine.yield() + debugger_sendMsg( + server, + LuaDebugger.event.C2S_LoadLuaScript, + LuaDebugger.loadScriptBody + ) + elseif event == LuaDebugger.event.S2C_SerVar then + LuaDebugger.isSetVar = true + LuaDebugger.setVarBody = body + local data = coroutine.yield() + debugger_sendMsg( + server, + LuaDebugger.event.C2S_SerVar, + { + stack = data, + eventType = data.eventType + } + ) + elseif event == LuaDebugger.event.S2C_ReLoadFile then + LuaDebugger.isReLoadFile = true + LuaDebugger.reLoadFileBody = body + local data = coroutine.yield() + debugger_sendMsg( + server, + LuaDebugger.event.C2S_ReLoadFile, + { + stack = data, + eventType = data.eventType + } + ) + end + end + end +end +coro_debugger = coroutine.create(debugger_loop) +debug_hook = function(event, line) + + if(not LuaDebugger.isHook) then + return + end + + if(LuaDebugger.Run) then + if(event == "line") then + local isCheck = false + for k, breakInfo in pairs(LuaDebugger.breakInfos) do + + for bk, linesInfo in pairs(breakInfo) do + + if(linesInfo.lines and linesInfo.lines[line]) then + isCheck = true + break + end + end + if(isCheck) then + break + end + end + + if(not isCheck) then + return + end + else + LuaDebugger.currentFileName = nil + LuaDebugger.currentTempFunc = nil + return + end + end + --跳出 + if (LuaDebugger.StepOut) then + if (event == "line" or event == "call") then + return + end + local tempFun = getinfo(2, "f").func + + if (LuaDebugger.currentDebuggerData.funcsLength == 1) then + ResetDebugInfo() + LuaDebugger.Run = true + else + if (LuaDebugger.currentDebuggerData.funcs[2] == tempFun) then + local data = debugger_stackInfo(3, LuaDebugger.event.C2S_StepInResponse) + --挂起等待调试器作出反应 + + _resume(coro_debugger, data) + checkSetVar() + end + end + return + end + -- debugger_dump(LuaDebugger,"LuaDebugger") + -- print(LuaDebugger.StepNextLevel,"LuaDebugger.StepNextLevel") + local file = nil + if (event == "call") then + -- end + -- if(not LuaDebugger.StepOut) then + if (not LuaDebugger.Run) then + LuaDebugger.StepNextLevel = LuaDebugger.StepNextLevel + 1 + end + -- print("stepIn",LuaDebugger.StepNextLevel) + + local stepInfo = getinfo(2, "S") + local source = stepInfo.source + if (source:find(LuaDebugger.DebugLuaFie) or source == "=[C]") then + return + end + + file = getSource(source) + LuaDebugger.currentFileName = file + elseif (event == "return" or event == "tail return") then + -- end + -- if(not LuaDebugger.StepOut) then + + if (not LuaDebugger.Run) then + LuaDebugger.StepNextLevel = LuaDebugger.StepNextLevel - 1 + end + + LuaDebugger.currentFileName = nil + elseif (event == "line") then + --@region 判断命中断点 + --判断命中断点 + --判断命中断点 + --判断命中断点 + --判断命中断点 + local isHit = false + local stepInfo = nil + if (not LuaDebugger.currentFileName) then + stepInfo = getinfo(2, "S") + local source = stepInfo.source + if (source == "=[C]" or source:find(LuaDebugger.DebugLuaFie)) then + return + end + file = getSource(source) + LuaDebugger.currentFileName = file + end + file = LuaDebugger.currentFileName + + --判断断点 + local breakInfo = LuaDebugger.breakInfos[file] + local breakData = nil + + if (breakInfo) then + + local ischeck = false + for k, lineInfo in pairs(breakInfo) do + local lines = lineInfo.lines + if (lines and lines[line]) then + ischeck = true + break + end + end + + if (ischeck) then + --并且在断点中 + -- local info = stepInfo + -- if (not info) then + -- print("info ---------------") + -- info = getinfo(2) + -- end + local hitPathNames = splitFilePath(LuaDebugger.currentLineFile) + + local hitCounts = {} + local debugHitCounts = nil + + for k, lineInfo in pairs(breakInfo) do + + local lines = lineInfo.lines + local pathNames = lineInfo.pathNames + debugHitCounts = lineInfo.hitCounts + if (lines and lines[line]) then + breakData = lines[line] + --判断路径 + hitCounts[k] = 0 + local hitPathNamesCount = #hitPathNames + + local pathNamesCount = #pathNames + local checkCount = 0; + + while (true) do + + if (pathNames[pathNamesCount] ~= hitPathNames[hitPathNamesCount]) then + break + else + hitCounts[k] = hitCounts[k] + 1 + end + pathNamesCount = pathNamesCount - 1 + hitPathNamesCount = hitPathNamesCount - 1 + checkCount = checkCount+1 + + if (pathNamesCount <= 0 or hitPathNamesCount <= 0) then + break + end + end + if(checkCount>0) then + break; + end + if(checkCount==0) then + breakData = nil + -- break; + end + else + breakData = nil + end + end + if (breakData) then + local hitFieName = "" + local maxCount = 0 + for k, v in pairs(hitCounts) do + if (v > maxCount) then + maxCount = v + hitFieName = k + end + end + local hitPathNamesLength = #hitPathNames + if (hitPathNamesLength == 1 or (hitPathNamesLength > 1 and maxCount > 1)) then + if (hitFieName ~= "") then + local hitCount = breakData.hitCondition + local clientHitCount = debugHitCounts[breakData.line] + clientHitCount = clientHitCount + 1 + debugHitCounts[breakData.line] = clientHitCount + + if (clientHitCount >= hitCount) then + isHit = true + end + end + end + end + end + end + --@endregion + if (LuaDebugger.StepIn) then + local data = debugger_stackInfo(3, LuaDebugger.event.C2S_NextResponse) + --挂起等待调试器作出反应 + if (data) then + LuaDebugger.currentTempFunc = data.funcs[1] + + _resume(coro_debugger, data) + checkSetVar() + return + end + end + if (LuaDebugger.StepNext) then + if (LuaDebugger.StepNextLevel <= 0) then + local data = debugger_stackInfo(3, LuaDebugger.event.C2S_NextResponse) + -- 挂起等待调试器作出反应 + if (data) then + LuaDebugger.currentTempFunc = data.funcs[1] + + _resume(coro_debugger, data) + checkSetVar() + return + end + end + end + if (isHit) then + local data = debugger_stackInfo(3, LuaDebugger.event.C2S_HITBreakPoint) + if (breakData and breakData.condition) then + debugger_conditionStr( + breakData.condition, + data.vars, + function() + _resume(coro_debugger, data) + checkSetVar() + end + ) + else + --挂起等待调试器作出反应 + _resume(coro_debugger, data) + checkSetVar() + end + end + end +end +debugger_xpcall = function() + --调用 coro_debugger 并传入 参数 + local data = debugger_stackInfo(4, LuaDebugger.event.C2S_HITBreakPoint) + if(data.stack and data.stack[1]) then + data.stack[1].isXpCall = true + end + --挂起等待调试器作出反应 + _resume(coro_debugger, data) + checkSetVar() +end +--调试开始 +local function start() + local fullName, dirName, fileName = debugger_getFilePathInfo(getinfo(1).source) + LuaDebugger.DebugLuaFie = fileName + local socket = createSocket() + print(controller_host) + print(controller_port) + + local server = socket.connect(controller_host, controller_port) + debug_server = server + if server then + --创建breakInfo socket + socket = createSocket() + breakInfoSocket = socket.connect(controller_host, controller_port) + if (breakInfoSocket) then + breakInfoSocket:settimeout(0) + debugger_sendMsg( + breakInfoSocket, + LuaDebugger.event.C2S_SetSocketName, + { + name = "breakPointSocket" + } + ) + debugger_sendMsg( + server, + LuaDebugger.event.C2S_SetSocketName, + { + name = "mainSocket", + version = LuaDebugger.version + } + ) + xpcall( + function() + debug.sethook(debug_hook, "lrc") + end, + function(error) + print("error:", error) + end + ) + -- if (jit) then + -- if (LuaDebugger.debugLuaType ~= "jit") then + -- print("error======================================================") + -- local msg = "当前luajit版本为: " .. jit.version .. " 请使用LuaDebugjit 进行调试!" + + -- print(msg) + -- end + -- end + _resume(coro_debugger, server) + end + end +end +function StartDebug(host, port,reLoad) + if (not host) then + print("error host nil") + end + if (not port) then + print("error prot nil") + end + if (type(host) ~= "string") then + print("error host not string") + end + if (type(port) ~= "number") then + print("error host not number") + end + controller_host = host + controller_port = port + xpcall( + start, + function(error) + -- body + print(error) + end + ) + --代码重载 + if(isReLoad) then + xpcall(function() + debugger_reLoadFile = require("luaideReLoadFile") + end,function() + print("左侧luaide按钮->打开luaIde最新调试文件所在文件夹->luaideReLoadFile.lua->拷贝到项目中") + print("具体使用方式请看luaideReLoadFile中文件注释") + debugger_reLoadFile = function() print("未实现代码重载") end + end) + end + + return debugger_receiveDebugBreakInfo, debugger_xpcall +end + +--base64 + +local string = string + +ZZBase64.__code = { + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', + 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', + 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', + 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/', +}; +ZZBase64.__decode = {} +for k,v in pairs(ZZBase64.__code) do + ZZBase64.__decode[string.byte(v,1)] = k - 1 +end + +function ZZBase64.encode(text) + local len = string.len(text) + local left = len % 3 + len = len - left + local res = {} + local index = 1 + for i = 1, len, 3 do + local a = string.byte(text, i ) + local b = string.byte(text, i + 1) + local c = string.byte(text, i + 2) + -- num = a<<16 + b<<8 + c + local num = a * 65536 + b * 256 + c + for j = 1, 4 do + --tmp = num >> ((4 -j) * 6) + local tmp = math.floor(num / (2 ^ ((4-j) * 6))) + --curPos = tmp&0x3f + local curPos = tmp % 64 + 1 + res[index] = ZZBase64.__code[curPos] + index = index + 1 + end + end + + if left == 1 then + ZZBase64.__left1(res, index, text, len) + elseif left == 2 then + ZZBase64.__left2(res, index, text, len) + end + return table.concat(res) +end + +function ZZBase64.__left2(res, index, text, len) + local num1 = string.byte(text, len + 1) + num1 = num1 * 1024 --lshift 10 + local num2 = string.byte(text, len + 2) + num2 = num2 * 4 --lshift 2 + local num = num1 + num2 + + local tmp1 = math.floor(num / 4096) --rShift 12 + local curPos = tmp1 % 64 + 1 + res[index] = ZZBase64.__code[curPos] + + local tmp2 = math.floor(num / 64) + curPos = tmp2 % 64 + 1 + res[index + 1] = ZZBase64.__code[curPos] + + curPos = num % 64 + 1 + res[index + 2] = ZZBase64.__code[curPos] + + res[index + 3] = "=" +end + +function ZZBase64.__left1(res, index,text, len) + local num = string.byte(text, len + 1) + num = num * 16 + + local tmp = math.floor(num / 64) + local curPos = tmp % 64 + 1 + res[index ] = ZZBase64.__code[curPos] + + curPos = num % 64 + 1 + res[index + 1] = ZZBase64.__code[curPos] + + res[index + 2] = "=" + res[index + 3] = "=" +end + +function ZZBase64.decode(text) + local len = string.len(text) + local left = 0 + if string.sub(text, len - 1) == "==" then + left = 2 + len = len - 4 + elseif string.sub(text, len) == "=" then + left = 1 + len = len - 4 + end + + local res = {} + local index = 1 + local decode = ZZBase64.__decode + for i =1, len, 4 do + local a = decode[string.byte(text,i )] + local b = decode[string.byte(text,i + 1)] + local c = decode[string.byte(text,i + 2)] + local d = decode[string.byte(text,i + 3)] + + --num = a<<18 + b<<12 + c<<6 + d + local num = a * 262144 + b * 4096 + c * 64 + d + + local e = string.char(num % 256) + num = math.floor(num / 256) + local f = string.char(num % 256) + num = math.floor(num / 256) + res[index ] = string.char(num % 256) + res[index + 1] = f + res[index + 2] = e + index = index + 3 + end + + if left == 1 then + ZZBase64.__decodeLeft1(res, index, text, len) + elseif left == 2 then + ZZBase64.__decodeLeft2(res, index, text, len) + end + return table.concat(res) +end + +function ZZBase64.__decodeLeft1(res, index, text, len) + local decode = ZZBase64.__decode + local a = decode[string.byte(text, len + 1)] + local b = decode[string.byte(text, len + 2)] + local c = decode[string.byte(text, len + 3)] + local num = a * 4096 + b * 64 + c + + local num1 = math.floor(num / 1024) % 256 + local num2 = math.floor(num / 4) % 256 + res[index] = string.char(num1) + res[index + 1] = string.char(num2) +end + +function ZZBase64.__decodeLeft2(res, index, text, len) + local decode = ZZBase64.__decode + local a = decode[string.byte(text, len + 1)] + local b = decode[string.byte(text, len + 2)] + local num = a * 64 + b + num = math.floor(num / 16) + res[index] = string.char(num) +end + + + + +return StartDebug diff --git a/Resources/Scripts/XEntity/XArchive/XArchiveCGEntity.lua b/Resources/Scripts/XEntity/XArchive/XArchiveCGEntity.lua new file mode 100644 index 00000000..b50d9145 --- /dev/null +++ b/Resources/Scripts/XEntity/XArchive/XArchiveCGEntity.lua @@ -0,0 +1,91 @@ +local XArchiveCGEntity = XClass(nil, "XArchiveCGEntity") + +function XArchiveCGEntity:Ctor(id) + self.Id = id + self.IsLock = true + self.LockDesc = "" +end + +function XArchiveCGEntity:UpdateData(playerData) + for key, value in pairs(playerData) do + self[key] = value + end +end + +function XArchiveCGEntity:GetCfg() + return XArchiveConfigs.GetArchiveCGDetailConfigById(self.Id) +end + +function XArchiveCGEntity:GetId() + return self.Id +end + +function XArchiveCGEntity:GetIsLock() + return self.IsLock +end + +function XArchiveCGEntity:GetLockDesc() + return self.LockDesc +end + +function XArchiveCGEntity:GetGroupId() + return self:GetCfg().GroupId +end + +function XArchiveCGEntity:GetOrder() + return self:GetCfg().Order +end + +function XArchiveCGEntity:GetName() + return self:GetCfg().Name +end + +function XArchiveCGEntity:GetDesc() + return self:GetCfg().Desc +end + +function XArchiveCGEntity:GetAuthor() + return self:GetCfg().Author +end + +function XArchiveCGEntity:GetBg() + return self:GetCfg().Bg +end + +function XArchiveCGEntity:GetSpineBg() + return self:GetCfg().SpineBg +end + +function XArchiveCGEntity:GetLockBg() + return self:GetCfg().LockBg +end + +function XArchiveCGEntity:GetUnLockTime() + return self:GetCfg().UnLockTime +end + +function XArchiveCGEntity:GetCondition() + return self:GetCfg().Condition +end + +function XArchiveCGEntity:GetIsShowRedPoint() + return self:GetCfg().IsShowRedPoint +end + +function XArchiveCGEntity:GetBgWidth() + return self:GetCfg().BgWidth +end + +function XArchiveCGEntity:GetBgHigh() + return self:GetCfg().BgHigh +end + +function XArchiveCGEntity:GetBgOffSetX() + return self:GetCfg().BgOffSetX +end + +function XArchiveCGEntity:GetBgOffSetY() + return self:GetCfg().BgOffSetY +end + +return XArchiveCGEntity \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XArchive/XArchiveCommunicationEntity.lua b/Resources/Scripts/XEntity/XArchive/XArchiveCommunicationEntity.lua new file mode 100644 index 00000000..275c7ba6 --- /dev/null +++ b/Resources/Scripts/XEntity/XArchive/XArchiveCommunicationEntity.lua @@ -0,0 +1,92 @@ +local XArchiveCommunicationEntity = XClass(nil, "XArchiveCommunicationEntity") + +function XArchiveCommunicationEntity:Ctor(id) + self.Id = id + self.IsLock = true + self.LockDesc = "" +end + +function XArchiveCommunicationEntity:UpdateData(playerData) + for key, value in pairs(playerData) do + self[key] = value + end +end + +function XArchiveCommunicationEntity:GetCfg() + return XArchiveConfigs.GetArchiveCommunicationsConfigById(self.Id) +end + +function XArchiveCommunicationEntity:GetId() + return self.Id +end + +function XArchiveCommunicationEntity:GetIsLock() + return self.IsLock +end + +function XArchiveCommunicationEntity:GetLockDesc() + return self.LockDesc +end + +function XArchiveCommunicationEntity:GetOrder() + return self:GetCfg().Order +end + +function XArchiveCommunicationEntity:GetCommunicationId() + return self:GetCfg().CommunicationId +end + +function XArchiveCommunicationEntity:GetCommunicationType() + return self:GetCfg().CommunicationType +end + +function XArchiveCommunicationEntity:GetCommunicationIcon() + return self:GetCfg().CommunicationIcon +end + +function XArchiveCommunicationEntity:GetGroupId() + return self:GetCfg().GroupId +end + +function XArchiveCommunicationEntity:GetName() + return self:GetCfg().Name +end + +function XArchiveCommunicationEntity:GetCondition() + return self:GetCfg().Condition +end + +function XArchiveCommunicationEntity:GetUnLockTime() + return self:GetCfg().UnLockTime +end + +function XArchiveCommunicationEntity:GetBtnContent() + return self:GetCfg().BtnContent +end + +function XArchiveCommunicationEntity:GetNpcName() + return self:GetCfg().NpcName +end + +function XArchiveCommunicationEntity:GetNpcHandIcon() + return self:GetCfg().NpcHandIcon +end + +function XArchiveCommunicationEntity:GetNpcHalfIcon() + return self:GetCfg().NpcHalfIcon +end + +function XArchiveCommunicationEntity:GetContents(index) + if index then + return self:GetCfg().Contents[index] + else + return self:GetCfg().Contents + end + +end + +function XArchiveCommunicationEntity:GetUiType() + return self:GetCfg().UiType +end + +return XArchiveCommunicationEntity \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XArchive/XArchiveMailEntity.lua b/Resources/Scripts/XEntity/XArchive/XArchiveMailEntity.lua new file mode 100644 index 00000000..72b7de0e --- /dev/null +++ b/Resources/Scripts/XEntity/XArchive/XArchiveMailEntity.lua @@ -0,0 +1,63 @@ +local XArchiveMailEntity = XClass(nil, "XArchiveMailEntity") + +function XArchiveMailEntity:Ctor(id) + self.Id = id + self.IsLock = true + self.LockDesc = "" +end + +function XArchiveMailEntity:UpdateData(playerData) + for key, value in pairs(playerData) do + self[key] = value + end +end + +function XArchiveMailEntity:GetCfg() + return XArchiveConfigs.GetArchiveMailsConfigById(self.Id) +end + +function XArchiveMailEntity:GetId() + return self.Id +end + +function XArchiveMailEntity:GetIsLock() + return self.IsLock +end + +function XArchiveMailEntity:GetLockDesc() + return self.LockDesc +end + +function XArchiveMailEntity:GetOrder() + return self:GetCfg().Order +end + +function XArchiveMailEntity:GetGroupId() + return self:GetCfg().GroupId +end + +function XArchiveMailEntity:GetCondition() + return self:GetCfg().Condition +end + +function XArchiveMailEntity:GetUnLockTime() + return self:GetCfg().UnLockTime +end + +function XArchiveMailEntity:GetTitle() + return self:GetCfg().Title +end + +function XArchiveMailEntity:GetSendName() + return self:GetCfg().SendName +end + +function XArchiveMailEntity:GetContent() + return self:GetCfg().Content +end + +function XArchiveMailEntity:GetNpcHandIcon() + return self:GetCfg().NpcHandIcon +end + +return XArchiveMailEntity \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XArchive/XArchiveMonsterDetailEntity.lua b/Resources/Scripts/XEntity/XArchive/XArchiveMonsterDetailEntity.lua new file mode 100644 index 00000000..fd63e75d --- /dev/null +++ b/Resources/Scripts/XEntity/XArchive/XArchiveMonsterDetailEntity.lua @@ -0,0 +1,68 @@ +local XArchiveMonsterDetailEntity = XClass(nil, "XArchiveMonsterDetailEntity") + +local EntityType = { + Info = 1, + Setting = 2, + Skill = 3, +} + +function XArchiveMonsterDetailEntity:Ctor(type,id) + self.Id = id + self.IsLock = true + self.LockDesc = "" + self.Type = type +end + +function XArchiveMonsterDetailEntity:UpdateData(playerData) + for key, value in pairs(playerData) do + self[key] = value + end +end + +function XArchiveMonsterDetailEntity:GetCfg() + if self.Type == EntityType.Info then + return XArchiveConfigs.GetArchiveMonsterInfoConfigById(self.Id) + elseif self.Type == EntityType.Setting then + return XArchiveConfigs.GetArchiveMonsterSettingConfigById(self.Id) + elseif self.Type == EntityType.Skill then + return XArchiveConfigs.GetArchiveMonsterSkillConfigById(self.Id) + end +end + +function XArchiveMonsterDetailEntity:GetId() + return self.Id +end + +function XArchiveMonsterDetailEntity:GetIsLock() + return self.IsLock +end + +function XArchiveMonsterDetailEntity:GetLockDesc() + return self.LockDesc +end + +function XArchiveMonsterDetailEntity:GetGroupId() + return self:GetCfg().GroupId +end + +function XArchiveMonsterDetailEntity:GetOrder() + return self:GetCfg().Order +end + +function XArchiveMonsterDetailEntity:GetTitle() + return self:GetCfg().Title +end + +function XArchiveMonsterDetailEntity:GetText() + return self:GetCfg().Text +end + +function XArchiveMonsterDetailEntity:GetType() + return self:GetCfg().Type +end + +function XArchiveMonsterDetailEntity:GetCondition() + return self:GetCfg().Condition +end + +return XArchiveMonsterDetailEntity \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XArchive/XArchiveMonsterEntity.lua b/Resources/Scripts/XEntity/XArchive/XArchiveMonsterEntity.lua new file mode 100644 index 00000000..c193d01a --- /dev/null +++ b/Resources/Scripts/XEntity/XArchive/XArchiveMonsterEntity.lua @@ -0,0 +1,88 @@ +local XArchiveMonsterEntity = XClass(nil, "XArchiveMonsterEntity") + +function XArchiveMonsterEntity:Ctor(id) + self.Id = id + self.IsLockMain = true + self.Kill = {} + self.RealName = {} + for _,npcid in pairs(self:GetNpcId() or {}) do + self.Kill[npcid] = 0 + self.RealName[npcid] = XArchiveConfigs.GetMonsterRealName(npcid) + end +end + +function XArchiveMonsterEntity:UpdateData(playerData) + for key, value in pairs(playerData) do + self[key] = value + end +end + +function XArchiveMonsterEntity:GetCfg() + return XArchiveConfigs.GetArchiveMonsterConfigById(self.Id) +end + +function XArchiveMonsterEntity:GetId() + return self.Id +end + +function XArchiveMonsterEntity:GetIsLockMain() + return self.IsLockMain +end + +function XArchiveMonsterEntity:GetKill(npcId) + if npcId then + return self.Kill[npcId] + else + return self.Kill + end +end + +function XArchiveMonsterEntity:GetRealName(npcId) + if npcId then + return self.RealName[npcId] + else + return self.RealName + end +end + +function XArchiveMonsterEntity:GetOrder() + return self:GetCfg().Order +end + +function XArchiveMonsterEntity:GetNpcId(index) + if index then + return self:GetCfg().NpcId[index] + else + return self:GetCfg().NpcId + end +end + +function XArchiveMonsterEntity:GetName() + return self:GetCfg().Name +end + +function XArchiveMonsterEntity:GetIcon() + return self:GetCfg().Icon +end + +function XArchiveMonsterEntity:GetPic() + return self:GetCfg().Pic +end + +function XArchiveMonsterEntity:GetLockPic() + return self:GetCfg().LockPic +end + +function XArchiveMonsterEntity:GetType() + return self:GetCfg().Type +end + +function XArchiveMonsterEntity:GetTagIds() + return self:GetCfg().TagIds +end + +function XArchiveMonsterEntity:GetTagGroupId() + return self:GetCfg().TagGroupId +end + +return XArchiveMonsterEntity \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XArchive/XArchiveNpcDetailEntity.lua b/Resources/Scripts/XEntity/XArchive/XArchiveNpcDetailEntity.lua new file mode 100644 index 00000000..cffff32e --- /dev/null +++ b/Resources/Scripts/XEntity/XArchive/XArchiveNpcDetailEntity.lua @@ -0,0 +1,59 @@ +local XArchiveNpcDetailEntity = XClass(nil, "XArchiveNpcDetailEntity") + +function XArchiveNpcDetailEntity:Ctor(id) + self.Id = id + self.IsLock = true + self.LockDesc = "" +end + +function XArchiveNpcDetailEntity:UpdateData(playerData) + for key, value in pairs(playerData) do + self[key] = value + end +end + +function XArchiveNpcDetailEntity:GetCfg() + return XArchiveConfigs.GetArchiveStoryNpcSettingConfigById(self.Id) +end + +function XArchiveNpcDetailEntity:GetId() + return self.Id +end + +function XArchiveNpcDetailEntity:GetIsLock() + return self.IsLock +end + +function XArchiveNpcDetailEntity:GetLockDesc() + return self.LockDesc +end + +function XArchiveNpcDetailEntity:GetGroupId() + return self:GetCfg().GroupId +end + +function XArchiveNpcDetailEntity:GetOrder() + return self:GetCfg().Order +end + +function XArchiveNpcDetailEntity:GetType() + return self:GetCfg().Type +end + +function XArchiveNpcDetailEntity:GetTitle() + return self:GetCfg().Title +end + +function XArchiveNpcDetailEntity:GetText() + return self:GetCfg().Text +end + +function XArchiveNpcDetailEntity:GetCondition() + return self:GetCfg().Condition +end + +function XArchiveNpcDetailEntity:GetUnLockTime() + return self:GetCfg().UnLockTime +end + +return XArchiveNpcDetailEntity \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XArchive/XArchiveNpcEntity.lua b/Resources/Scripts/XEntity/XArchive/XArchiveNpcEntity.lua new file mode 100644 index 00000000..ea750411 --- /dev/null +++ b/Resources/Scripts/XEntity/XArchive/XArchiveNpcEntity.lua @@ -0,0 +1,55 @@ +local XArchiveNpcEntity = XClass(nil, "XArchiveNpcEntity") + +function XArchiveNpcEntity:Ctor(id) + self.Id = id + self.IsLock = true + self.LockDesc = "" +end + +function XArchiveNpcEntity:UpdateData(playerData) + for key, value in pairs(playerData) do + self[key] = value + end +end + +function XArchiveNpcEntity:GetCfg() + return XArchiveConfigs.GetArchiveStoryNpcConfigById(self.Id) +end + +function XArchiveNpcEntity:GetId() + return self.Id +end + +function XArchiveNpcEntity:GetIsLock() + return self.IsLock +end + +function XArchiveNpcEntity:GetLockDesc() + return self.LockDesc +end + +function XArchiveNpcEntity:GetPicSmall() + return self:GetCfg().PicSmall +end + +function XArchiveNpcEntity:GetOrder() + return self:GetCfg().Order +end + +function XArchiveNpcEntity:GetName() + return self:GetCfg().Name +end + +function XArchiveNpcEntity:GetPicBig() + return self:GetCfg().PicBig +end + +function XArchiveNpcEntity:GetUnLockTime() + return self:GetCfg().UnLockTime +end + +function XArchiveNpcEntity:GetCondition() + return self:GetCfg().Condition +end + +return XArchiveNpcEntity \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XArchive/XArchivePartnerEntity.lua b/Resources/Scripts/XEntity/XArchive/XArchivePartnerEntity.lua new file mode 100644 index 00000000..f640bb0d --- /dev/null +++ b/Resources/Scripts/XEntity/XArchive/XArchivePartnerEntity.lua @@ -0,0 +1,91 @@ +local XPartnerBase = require("XEntity/XPartner/XPartnerBase") +local XArchivePartnerEntity = XClass(XPartnerBase, "XArchivePartnerEntity") + +function XArchivePartnerEntity:Ctor(id, storyEntityList, settingEntityList) + self.Id = id + self.TemplateId = id--伙伴Id + self.IsArchiveLock = true + self.StoryEntityDic = {} + self.StorySettingDic = {} +------------------------------------------------- + + self:CreateStoryEntityDic(storyEntityList) + self:CreateSettingEntityDic(settingEntityList) +end + +function XArchivePartnerEntity:UpdateData(data) + for key, value in pairs(data or {}) do + self[key] = value + end +end + +-------------------------宠物功能属性-------------------------- +function XArchivePartnerEntity:GetId() + return self.Id +end + +function XArchivePartnerEntity:GetTemplateId() + return self.TemplateId +end + +function XArchivePartnerEntity:GetIsArchiveLock() + return self.IsArchiveLock +end + +----------------------------宠物图鉴基础属性-------------------------------- +function XArchivePartnerEntity:GetArchivePartnerCfg() + return XArchiveConfigs.GetPartnerConfigById(self.TemplateId) +end + +function XArchivePartnerEntity:GetGroupId() + return self:GetArchivePartnerCfg().GroupId +end + +function XArchivePartnerEntity:GetOrder() + return self:GetArchivePartnerCfg().Order +end + +function XArchivePartnerEntity:GetLockIcon() + return self:GetArchivePartnerCfg().LockIconPath +end + +function XArchivePartnerEntity:GetIcon() + return self:GetArchivePartnerCfg().IconPath +end + +function XArchivePartnerEntity:GetStoryTitle() + return self:GetArchivePartnerCfg().StoryTitle +end + +function XArchivePartnerEntity:GetStoryId() + return self:GetArchivePartnerCfg().StoryId +end + +-------------------------------------宠物故事--------------------------------- + +function XArchivePartnerEntity:CreateStoryEntityDic(storyEntityList) + self.StoryEntityDic = {} + for _,Entity in pairs(storyEntityList or {}) do + self.StoryEntityDic[Entity:GetId()] = Entity + end +end + +function XArchivePartnerEntity:CreateSettingEntityDic(settingEntityList) + self.StorySettingDic = {} + for _,Entity in pairs(settingEntityList or {}) do + self.StorySettingDic[Entity:GetId()] = Entity + end +end + +function XArchivePartnerEntity:UpdateStoryAndSettingEntity(unLockStoryList) + for _,id in pairs(unLockStoryList or {}) do + if self.StoryEntityDic[id] then + self.StoryEntityDic[id]:UpdateData({IsLock = false}) + end + if self.StorySettingDic[id] then + self.StorySettingDic[id]:UpdateData({IsLock = false}) + end + end +end + +return XArchivePartnerEntity \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XArchive/XArchivePartnerSettingEntity.lua b/Resources/Scripts/XEntity/XArchive/XArchivePartnerSettingEntity.lua new file mode 100644 index 00000000..d443ce68 --- /dev/null +++ b/Resources/Scripts/XEntity/XArchive/XArchivePartnerSettingEntity.lua @@ -0,0 +1,59 @@ +local XArchivePartnerSettingEntity = XClass(nil, "XArchivePartnerSettingEntity") + +function XArchivePartnerSettingEntity:Ctor(id) + self.Id = id + self.IsLock = true +end + +function XArchivePartnerSettingEntity:UpdateData(playerData) + for key, value in pairs(playerData) do + self[key] = value + end +end + +function XArchivePartnerSettingEntity:GetCfg() + return XArchiveConfigs.GetPartnerSettingConfigById(self.Id) +end + +function XArchivePartnerSettingEntity:GetId() + return self.Id +end + +function XArchivePartnerSettingEntity:GetIsLock() + return self.IsLock +end + +function XArchivePartnerSettingEntity:GetConditionDesc() + local desc = "" + local condition = self:GetCondition() + if condition ~= 0 then + desc = XConditionManager.GetConditionDescById(condition) + end + return desc +end + +function XArchivePartnerSettingEntity:GetGroupId() + return self:GetCfg().GroupId +end + +function XArchivePartnerSettingEntity:GetOrder() + return self:GetCfg().Order +end + +function XArchivePartnerSettingEntity:GetType() + return self:GetCfg().Type +end + +function XArchivePartnerSettingEntity:GetTitle() + return self:GetCfg().Title +end + +function XArchivePartnerSettingEntity:GetText() + return self:GetCfg().Text +end + +function XArchivePartnerSettingEntity:GetCondition() + return self:GetCfg().Condition +end + +return XArchivePartnerSettingEntity \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XArchive/XArchiveStoryChapterEntity.lua b/Resources/Scripts/XEntity/XArchive/XArchiveStoryChapterEntity.lua new file mode 100644 index 00000000..a55e9e66 --- /dev/null +++ b/Resources/Scripts/XEntity/XArchive/XArchiveStoryChapterEntity.lua @@ -0,0 +1,67 @@ +local XArchiveStoryChapterEntity = XClass(nil, "XArchiveStoryChapterEntity") + +function XArchiveStoryChapterEntity:Ctor(id) + self.Id = id + self.IsLock = true + self.LockDesc = "" +end + +function XArchiveStoryChapterEntity:UpdateData(playerData) + for key, value in pairs(playerData) do + self[key] = value + end +end + +function XArchiveStoryChapterEntity:GetCfg() + return XArchiveConfigs.GetArchiveStoryChapterConfigById(self.Id) +end + +function XArchiveStoryChapterEntity:GetId() + return self.Id +end + +function XArchiveStoryChapterEntity:GetIsLock() + return self.IsLock +end + +function XArchiveStoryChapterEntity:GetLockDesc() + return self.LockDesc +end + +function XArchiveStoryChapterEntity:GetGroupId() + return self:GetCfg().GroupId +end + +function XArchiveStoryChapterEntity:GetOrder() + return self:GetCfg().Order +end + +function XArchiveStoryChapterEntity:GetName() + return self:GetCfg().Name +end + +function XArchiveStoryChapterEntity:GetBg() + return self:GetCfg().Bg +end + +function XArchiveStoryChapterEntity:GetLockBg() + return self:GetCfg().LockBg +end + +function XArchiveStoryChapterEntity:GetBgWidth() + return self:GetCfg().BgWidth +end + +function XArchiveStoryChapterEntity:GetBgHigh() + return self:GetCfg().BgHigh +end + +function XArchiveStoryChapterEntity:GetBgOffSetX() + return self:GetCfg().BgOffSetX +end + +function XArchiveStoryChapterEntity:GetBgOffSetY() + return self:GetCfg().BgOffSetY +end + +return XArchiveStoryChapterEntity \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XArchive/XArchiveStoryDetailEntity.lua b/Resources/Scripts/XEntity/XArchive/XArchiveStoryDetailEntity.lua new file mode 100644 index 00000000..64c4ef73 --- /dev/null +++ b/Resources/Scripts/XEntity/XArchive/XArchiveStoryDetailEntity.lua @@ -0,0 +1,75 @@ +local XArchiveStoryDetailEntity = XClass(nil, "XArchiveStoryDetailEntity") + +function XArchiveStoryDetailEntity:Ctor(id) + self.Id = id + self.IsLock = true + self.LockDesc = "" +end + +function XArchiveStoryDetailEntity:UpdateData(playerData) + for key, value in pairs(playerData) do + self[key] = value + end +end + +function XArchiveStoryDetailEntity:GetCfg() + return XArchiveConfigs.GetArchiveStoryDetailConfigById(self.Id) +end + +function XArchiveStoryDetailEntity:GetId() + return self.Id +end + +function XArchiveStoryDetailEntity:GetIsLock() + return self.IsLock +end + +function XArchiveStoryDetailEntity:GetLockDesc() + return self.LockDesc +end + +function XArchiveStoryDetailEntity:GetOrder() + return self:GetCfg().Order +end + +function XArchiveStoryDetailEntity:GetChapterId() + return self:GetCfg().ChapterId +end + +function XArchiveStoryDetailEntity:GetName() + return self:GetCfg().Name +end + +function XArchiveStoryDetailEntity:GetSubName() + return self:GetCfg().SubName +end + +function XArchiveStoryDetailEntity:GetIcon() + return self:GetCfg().Icon +end + +function XArchiveStoryDetailEntity:GetDescTitle() + return self:GetCfg().DescTitle +end + +function XArchiveStoryDetailEntity:GetDesc() + return self:GetCfg().Desc +end + +function XArchiveStoryDetailEntity:GetCondition() + return self:GetCfg().Condition +end + +function XArchiveStoryDetailEntity:GetUnLockTime() + return self:GetCfg().UnLockTime +end + +function XArchiveStoryDetailEntity:GetStoryId(id) + if id then + return self:GetCfg().StoryId[id] + else + return self:GetCfg().StoryId + end +end + +return XArchiveStoryDetailEntity \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XBabelTower/XBabelTowerStageData.lua b/Resources/Scripts/XEntity/XBabelTower/XBabelTowerStageData.lua new file mode 100644 index 00000000..5e3aebc9 --- /dev/null +++ b/Resources/Scripts/XEntity/XBabelTower/XBabelTowerStageData.lua @@ -0,0 +1,119 @@ +local XBabelTowerTeamData = require("XEntity/XBabelTower/XBabelTowerTeamData") + +local tableInsert = table.insert + +local XBabelTowerStageData = XClass(nil, "XBabelTowerStageData") + +local Default = { + StageId = 0, + GuideId = 0, + MaxScore = 0, + IsSyn = false, --是否与服务端数据同步 + TeamDatas = {}, +} + +function XBabelTowerStageData:Ctor(stageId) + for key, v in pairs(Default) do + if type(v) == "table" then + self[key] = {} + else + self[key] = v + end + end + + self.StageId = stageId + self:InitTeamDatas() +end + +function XBabelTowerStageData:InitTeamDatas() + local teamCount = XFubenBabelTowerConfigs.GetStageTeamCount(self.StageId) + for teamId = 1, teamCount do + self.TeamDatas[teamId] = XBabelTowerTeamData.New(teamId) + end +end + +function XBabelTowerStageData:UpdateData(data) + self.StageId = data.Id + self.GuideId = data.GuildId + self.MaxScore = data.MaxScore + self.IsSyn = true + self:UpdateTeamDatas(data.TeamDatas) +end + +function XBabelTowerStageData:IsSyned() + return self.IsSyn +end + +function XBabelTowerStageData:Syn() + self.IsSyn = true +end + +function XBabelTowerStageData:GetTeamData(teamId) + local teamData = self.TeamDatas[teamId] + if not teamData then + XLog.Error("XBabelTowerStageData:GetTeamData Error:获取活动关卡队伍信息失败, stageId: " .. self.StageId .. ", teamId: " .. teamId) + return + end + return teamData +end + +function XBabelTowerStageData:UpdateTeamDatas(teamDatas) + for _, clientTeamData in pairs(self.TeamDatas) do + clientTeamData:ResetSyn() + end + for _, teamData in pairs(teamDatas or {}) do + local teamId = teamData.Id + local clientTeamData = self:GetTeamData(teamId) + clientTeamData:UpdateData(teamData) + end +end + +function XBabelTowerStageData:GetTotalUsedCharacterIds(paramTeamId) + local totalCharacterIds = {} + + for _, teamData in pairs(self.TeamDatas) do + if not teamData:IsReseted() and teamData:GetTeamId() ~= paramTeamId then + local characterIds = teamData:GetCharacterIds() + for _, characterId in pairs(characterIds) do + if characterId > 0 then + totalCharacterIds[characterId] = characterId + end + end + end + end + + return totalCharacterIds +end + +function XBabelTowerStageData:GetTotalScore() + local totalScore = 0 + for _, teamData in pairs(self.TeamDatas) do + totalScore = totalScore + teamData:GetScore() + end + return totalScore +end + +function XBabelTowerStageData:GetGudieId() + return self.GuideId +end + +function XBabelTowerStageData:GetTeamIdList() + local teamIdList = {} + for _, teamData in ipairs(self.TeamDatas) do + tableInsert(teamIdList, teamData:GetTeamId()) + end + return teamIdList +end + +function XBabelTowerStageData:GetSynTeamNum() + local teamNum = 0 + for _, teamData in ipairs(self.TeamDatas) do + if not teamData:IsSyned() then + break + end + teamNum = teamNum + 1 + end + return teamNum +end + +return XBabelTowerStageData \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XBabelTower/XBabelTowerTeamData.lua b/Resources/Scripts/XEntity/XBabelTower/XBabelTowerTeamData.lua new file mode 100644 index 00000000..68f1c347 --- /dev/null +++ b/Resources/Scripts/XEntity/XBabelTower/XBabelTowerTeamData.lua @@ -0,0 +1,173 @@ +local XBabelTowerTeamData = XClass(nil, "XBabelTowerTeamData") + +local Default = { + TeamId = 0, + CurScore = 0, + MaxScore = 0, + IsReset = false, + IsSyn = false, --是否与服务端数据同步 + CaptainPos = 0, + CharacterIds = { 0, 0, 0 }, + ChallengeBuffDic = {}, + SupportBuffDic = {}, + StageLevel = 0, +} + +local TeamMaxCount = 3 + +function XBabelTowerTeamData:Ctor(teamId) + for key, v in pairs(Default) do + if type(v) == "table" then + self[key] = {} + else + self[key] = v + end + end + self.TeamId = teamId + self.CharacterIds = { 0, 0, 0 } + self.StageLevel = XFubenBabelTowerConfigs.Difficult.Easy + self.CaptainPos = XFubenBabelTowerConfigs.LEADER_POSITION + self.FirstFightPos = XFubenBabelTowerConfigs.FIRST_FIGHT_POSITION +end + +-- 更新服务器下发的队伍数据 +function XBabelTowerTeamData:UpdateData(data) + self.TeamId = data.Id + self.CurScore = data.CurScore + self.MaxScore = data.MaxScore or 0 + self.IsReset = data.IsReset + self:UpdateCharacter(data.TeamList) + self.IsSyn = true + self.StageLevel = data.StageLevel and data.StageLevel ~= 0 and data.StageLevel or XFubenBabelTowerConfigs.Difficult.Easy + self.CaptainPos = data.CaptainPos and data.CaptainPos ~= 0 and data.CaptainPos or XFubenBabelTowerConfigs.LEADER_POSITION + self.FirstFightPos = data.FirstFightPos and data.FirstFightPos ~= 0 and data.FirstFightPos or XFubenBabelTowerConfigs.FIRST_FIGHT_POSITION + + self:UpdateChallengeBuffDic(data.ChallengeBuffInfos) + + self.SupportBuffDic = {} + for _, buffData in pairs(data.SupportBuffInfos or {}) do + self.SupportBuffDic[buffData.GroupId] = buffData.BufferId + end +end + +function XBabelTowerTeamData:UpdateCharacter(teamList) + self.CharacterIds = {} + for _, charId in ipairs(teamList) do + table.insert(self.CharacterIds, charId) + end + if #self.CharacterIds < TeamMaxCount then + for i = #self.CharacterIds + 1, TeamMaxCount do + table.insert(self.CharacterIds, 0) + end + end +end + +function XBabelTowerTeamData:ResetSyn() + self.IsSyn = false +end + +function XBabelTowerTeamData:IsSyned() + return self.IsSyn +end + +function XBabelTowerTeamData:IsReseted() + return self.IsReset +end + +function XBabelTowerTeamData:Reset() + self.IsReset = true +end + +function XBabelTowerTeamData:Recover() + self.IsReset = false +end + +function XBabelTowerTeamData:GetTeamId() + return self.TeamId +end + +function XBabelTowerTeamData:GetChallengeBuffDic() + return XTool.Clone(self.ChallengeBuffDic) +end + +function XBabelTowerTeamData:UpdateChallengeBuffDic(buffDatas) + for _, buffData in pairs(buffDatas or {}) do + self.ChallengeBuffDic[buffData.GroupId] = buffData.BufferId + end +end + +function XBabelTowerTeamData:GetSupportBuffDic() + return XTool.Clone(self.SupportBuffDic) +end + +function XBabelTowerTeamData:UpdateSupportBuffDic(buffDatas) + self.SupportBuffDic = {} + for _, buffData in pairs(buffDatas or {}) do + self.SupportBuffDic[buffData.GroupId] = buffData.BufferId + end +end + +function XBabelTowerTeamData:GetCharacterIds(includeReset) + if includeReset then + return XTool.Clone(self.CharacterIds) + end + + if self:IsReseted() then + return { 0, 0, 0 } + end + + return XTool.Clone(self.CharacterIds) +end + +function XBabelTowerTeamData:UpdateCharacterIds(characterIds) + if not characterIds then return end + self.CharacterIds = XTool.Clone(characterIds) +end + +function XBabelTowerTeamData:ClearCharacterIds() + self.CharacterIds = { 0, 0, 0 } + self.CaptainPos = XFubenBabelTowerConfigs.LEADER_POSITION + self.FirstFightPos = XFubenBabelTowerConfigs.FIRST_FIGHT_POSITION +end + +function XBabelTowerTeamData:GetScore(ignoreReset) + if ignoreReset then + return self.CurScore or 0 + end + return not self.IsReset and self.CurScore or 0 +end + +function XBabelTowerTeamData:GetMaxScore() + return self.MaxScore +end + +function XBabelTowerTeamData:GetSelectDiffcult() + return self.StageLevel +end + +function XBabelTowerTeamData:SelectDiffcult(difficult) + self.StageLevel = difficult +end + +function XBabelTowerTeamData:GetCaptainPos() + return self.CaptainPos +end + +function XBabelTowerTeamData:GetFirstFightPos() + return self.FirstFightPos +end + +function XBabelTowerTeamData:SetCaptainPos(captainPos) + self.CaptainPos = captainPos +end + +function XBabelTowerTeamData:SetFirstFightPos(firstFightPos) + self.FirstFightPos = firstFightPos +end + +function XBabelTowerTeamData:HasCaptain() + local characterId = self.CharacterIds[self.CaptainPos] + return characterId and characterId ~= 0 +end + +return XBabelTowerTeamData \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XCharacter/XCharacter.lua b/Resources/Scripts/XEntity/XCharacter/XCharacter.lua new file mode 100644 index 00000000..c7757024 --- /dev/null +++ b/Resources/Scripts/XEntity/XCharacter/XCharacter.lua @@ -0,0 +1,207 @@ +local XCharacterViewModel = require("XEntity/XCharacter/XCharacterViewModel") +local XCharacterSkillGroup = require("XEntity/XCharacter/XCharacterSkillGroup") + +local type = type + +XCharacter = XClass(nil, "XCharacter") + +local Default = { + Id = 0, + Level = 1, + Exp = 0, + Quality = 1, + Star = 0, + Grade = 1, -- 军阶等级 + CreateTime = 0, + Ability = 0, + TrustLv = 0, + TrustExp = 0, + Type = 0, -- 职业类型 + NpcId = 0, + Attribs = {}, + __SkillGroupDatas = {}, +} + +function XCharacter.GetDefaultFields() + return Default +end + +function XCharacter:Ctor(data) + -- XCharacterViewModel + self.CharacterViewModel = nil + self.UpdatedData = nil + for key, value in pairs(Default) do + if type(value) == "table" then + self[key] = {} + else + self[key] = value + end + end + + XEventManager.AddEventListener(XEventId.EVENT_LOGIN_DATA_LOAD_COMPLETE, self.RefreshAttribsByEvent, self) + XEventManager.AddEventListener(XEventId.EVENT_EQUIP_PUTON_NOTYFY, self.RefreshAttribsByEvent, self) + XEventManager.AddEventListener(XEventId.EVENT_EQUIPLIST_TAKEOFF_NOTYFY, self.RefreshAttribsByEvent, self) + XEventManager.AddEventListener(XEventId.EVENT_EQUIP_STRENGTHEN_NOTYFY, self.RefreshAttribsByEvent, self) + XEventManager.AddEventListener(XEventId.EVENT_EQUIP_BREAKTHROUGH_NOTYFY, self.RefreshAttribsByEvent, self) + XEventManager.AddEventListener(XEventId.EVENT_EQUIP_RESONANCE_NOTYFY, self.RefreshAttribsByEvent, self) + XEventManager.AddEventListener(XEventId.EVENT_EQUIP_RESONANCE_ACK_NOTYFY, self.RefreshAttribsByEvent, self) + XEventManager.AddEventListener(XEventId.EVENT_EQUIP_AWAKE_NOTYFY, self.RefreshAttribsByEvent, self) + XEventManager.AddEventListener(XEventId.EVENT_BASE_EQUIP_DATA_CHANGE_NOTIFY, self.RefreshAttribsByEvent, self) + XEventManager.AddEventListener(XEventId.EVENT_REFRESH_CHRACTER_ABLIITY, self.RefreshAbility, self) + XEventManager.AddEventListener(XEventId.EVENT_PARTNER_ABLITYCHANGE, self.RefreshAbility, self) + + if data then self:Sync(data) end +end + +function XCharacter:RemoveEventListeners() + XEventManager.RemoveEventListener(XEventId.EVENT_LOGIN_DATA_LOAD_COMPLETE, self.RefreshAttribsByEvent, self) + XEventManager.RemoveEventListener(XEventId.EVENT_EQUIP_PUTON_NOTYFY, self.RefreshAttribsByEvent, self) + XEventManager.RemoveEventListener(XEventId.EVENT_EQUIPLIST_TAKEOFF_NOTYFY, self.RefreshAttribsByEvent, self) + XEventManager.RemoveEventListener(XEventId.EVENT_EQUIP_STRENGTHEN_NOTYFY, self.RefreshAttribsByEvent, self) + XEventManager.RemoveEventListener(XEventId.EVENT_EQUIP_BREAKTHROUGH_NOTYFY, self.RefreshAttribsByEvent, self) + XEventManager.RemoveEventListener(XEventId.EVENT_EQUIP_RESONANCE_NOTYFY, self.RefreshAttribsByEvent, self) + XEventManager.RemoveEventListener(XEventId.EVENT_EQUIP_RESONANCE_ACK_NOTYFY, self.RefreshAttribsByEvent, self) + XEventManager.RemoveEventListener(XEventId.EVENT_EQUIP_AWAKE_NOTYFY, self.RefreshAttribsByEvent, self) + XEventManager.RemoveEventListener(XEventId.EVENT_BASE_EQUIP_DATA_CHANGE_NOTIFY, self.RefreshAttribsByEvent, self) + XEventManager.RemoveEventListener(XEventId.EVENT_REFRESH_CHRACTER_ABLIITY, self.RefreshAbility, self) + XEventManager.RemoveEventListener(XEventId.EVENT_PARTNER_ABLITYCHANGE, self.RefreshAbility, self) +end + +function XCharacter:Sync(data) + for k, v in pairs(data) do + self[k] = v + end + self.UpdatedData = data + -- 对视图数据更新 + if self.CharacterViewModel and self.CharacterViewModel:GetUpdatedData() ~= data then + self.CharacterViewModel:UpdateWithData(data) + end + self:ChangeNpcId() + self:UpdateSkillData(data.SkillList, true) + self:RefreshAttribs(true) + self:RefreshAbility() +end + +function XCharacter:GetSkillGroupData(skillGroupId) + return self.__SkillGroupDatas[skillGroupId] +end + +function XCharacter:UpdateSkillData(skillList, ignoreChangeAbility) + XTool.LoopCollection(skillList, function(data) + local skillId = data.Id + + local skillGroupId = XCharacterConfigs.GetSkillGroupIdAndIndex(skillId) + if not skillGroupId then + XLog.Error("XCharacter:UpdateSkillData Error: 角色技能数据同步错误,技能Id未配置在技能组中, skillId: " .. skillId) + return + end + + local skillGroupData = self:GetSkillGroupData(skillGroupId) + if not skillGroupData then + skillGroupData = XCharacterSkillGroup.New() + self.__SkillGroupDatas[skillGroupId] = skillGroupData + end + + skillGroupData:UpdateData(data) + end) + + if not ignoreChangeAbility then + self:RefreshAbility() + end +end + +function XCharacter:SwithSkill(skillId) + local skillGroupId = XCharacterConfigs.GetSkillGroupIdAndIndex(skillId) + local skillGroupData = self:GetSkillGroupData(skillGroupId) + if not skillGroupData then return end + skillGroupData:SwitchSkill(skillId) +end + +function XCharacter:GetSkillLevelBySkillId(skillId) + local skillGroupId = XCharacterConfigs.GetSkillGroupIdAndIndex(skillId) + return self:GetSkillLevel(skillGroupId) +end + +function XCharacter:GetSkillLevel(skillGroupId) + local skillGroupData = self:GetSkillGroupData(skillGroupId) + return skillGroupData and skillGroupData:GetLevel() or 0 +end + +function XCharacter:GetGroupCurSkillId(skillGroupId) + local skillGroupData = self:GetSkillGroupData(skillGroupId) + if not skillGroupData then + return XCharacterConfigs.GetGroupDefaultSkillId(skillGroupId) + end + return skillGroupData:GetCurSKillId() or 0 +end + +function XCharacter:IsSkillUsing(skillId) + if not skillId or skillId == 0 then return false end + local skillGroupId = XCharacterConfigs.GetSkillGroupIdAndIndex(skillId) + return self:GetGroupCurSkillId(skillGroupId) == skillId +end + +function XCharacter:RefreshAttribs(ignoreChangeAbility) + local attribs = XDataCenter.CharacterManager.GetCharacterAttribs(self) + if attribs then + self.Attribs = attribs + end + + if not ignoreChangeAbility then + self:RefreshAbility() + end +end + +function XCharacter:RefreshAttribsByEvent() + self:RefreshAttribs() +end + +function XCharacter:GetAttributes() + return self.Attribs +end + +function XCharacter:RefreshAbility() + self.Ability = XDataCenter.CharacterManager.GetCharacterAbility(self) +end + +function XCharacter:ChangeNpcId() + local npcId = XCharacterConfigs.GetCharNpcId(self.Id, self.Quality) + if npcId == nil then + return + end + + if self.NpcId and self.NpcId ~= npcId then + self.NpcId = npcId + self:ChangeType() + end +end + +function XCharacter:ChangeType() + local npcTemplate = CS.XNpcManager.GetNpcTemplate(self.NpcId) + if not npcTemplate then + XLog.Error("XCharacter:ChangeType error: can not found npc template, npcId is " .. self.NpcId) + return + end + + self.Type = npcTemplate.Type +end + +function XCharacter:IsContains(container, item) + for _, v in pairs(container or {}) do + if v == item then + return true + end + end + return false +end + +-- return : XCharacterViewModel +function XCharacter:GetCharacterViewModel() + if self.CharacterViewModel == nil then + self.CharacterViewModel = XCharacterViewModel.New(self.Id) + self.CharacterViewModel:UpdateWithData(self.UpdatedData) + self.CharacterViewModel:UpdateCharacter(self) + self.CharacterViewModel:UpdateIsBelongPlayer(true) + end + return self.CharacterViewModel +end \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XCharacter/XCharacterSkillGroup.lua b/Resources/Scripts/XEntity/XCharacter/XCharacterSkillGroup.lua new file mode 100644 index 00000000..a6cc0720 --- /dev/null +++ b/Resources/Scripts/XEntity/XCharacter/XCharacterSkillGroup.lua @@ -0,0 +1,38 @@ +local Default = { + __SkillGroupId = 0, + __Level = 0, + __CurSkillId = 0, +} + +local XCharacterSkillGroup = XClass(nil, "XCharacterSkillGroup") + +function XCharacterSkillGroup:Ctor(skillGroupId) + for key, value in pairs(Default) do + if type(value) == "table" then + self[key] = {} + else + self[key] = value + end + end + + self.__SkillGroupId = skillGroupId +end + +function XCharacterSkillGroup:UpdateData(data) + self.__CurSkillId = data.Id + self.__Level = data.Level or 0 +end + +function XCharacterSkillGroup:GetLevel() + return self.__Level +end + +function XCharacterSkillGroup:SwitchSkill(skillId) + self.__CurSkillId = skillId +end + +function XCharacterSkillGroup:GetCurSKillId() + return self.__CurSkillId +end + +return XCharacterSkillGroup \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XCharacter/XCharacterViewModel.lua b/Resources/Scripts/XEntity/XCharacter/XCharacterViewModel.lua new file mode 100644 index 00000000..54504ca2 --- /dev/null +++ b/Resources/Scripts/XEntity/XCharacter/XCharacterViewModel.lua @@ -0,0 +1,229 @@ +local XCharacterViewModel = XClass(nil, "XCharacterViewModel") + +--######################## 静态方法 begin ######################## + +-- 已废弃,使用XEntityHelper.GetCharacterName +function XCharacterViewModel.GetNameById(id) + local config = XCharacterConfigs.GetCharacterTemplate(id) + if not config then return "none" end + return config.Name +end + +-- 已废弃,使用XEntityHelper.GetCharacterSmallIcon +function XCharacterViewModel.GetSmallIconById(id) + return XDataCenter.CharacterManager.GetCharSmallHeadIcon(id, 0, true) +end + +--######################## 静态方法 end ######################## + +function XCharacterViewModel:Ctor(characterCid) + self.Config = XCharacterConfigs.GetCharacterTemplate(characterCid) + self.ProfessionType = nil + -- 解放等级 + self.LiberateLv = 0 + self.FashionId = nil + -- 该角色是否属于玩家 + self.IsBelongPlayer = false + -- XCharacter + self.Character = nil + self.UpdatedData = nil + -- 来源实体Id,默认读取角色的 + self.SourceEntityId = characterCid + -- 初始化来自XCharacter的默认字段,保持一致性 + for key, value in pairs(XCharacter.GetDefaultFields()) do + if type(value) == "table" then + self[key] = XTool.Clone(value) + else + self[key] = value + end + end + self.Id = self.Config.Id +end + +-- data : 同XCharacter.GetDefaultFields()一致 +function XCharacterViewModel:UpdateWithData(data) + self.UpdatedData = data + for key, value in pairs(data) do + self[key] = value + end +end + +function XCharacterViewModel:UpdateAbility(value) + self.Ability = value +end + +function XCharacterViewModel:UpdateSourceEntityId(value) + self.SourceEntityId = value +end + +function XCharacterViewModel:UpdateFashionId(value) + self.FashionId = value +end + +function XCharacterViewModel:UpdateLiberateLv(value) + self.LiberateLv = value +end + +function XCharacterViewModel:UpdateIsBelongPlayer(value) + self.IsBelongPlayer = value +end + +-- value : XCharacter +function XCharacterViewModel:UpdateCharacter(value) + self.Character = value +end + +function XCharacterViewModel:GetId() + return self.Id +end + +function XCharacterViewModel:GetCharacter() + if self.Character == nil then + self.Character = XCharacter.New(self.UpdatedData) + self.Character:RemoveEventListeners() + end + return self.Character +end + +function XCharacterViewModel:GetSourceEntityId() + return self.SourceEntityId +end + +function XCharacterViewModel:GetConfigId() + return self.Config.Id +end + +function XCharacterViewModel:GetUpdatedData() + return self.UpdatedData +end + +function XCharacterViewModel:GetName() + return self.Config.Name +end + +function XCharacterViewModel:GetLogName() + return self.Config.LogName +end + +function XCharacterViewModel:GetFashionId() + return self.FashionId +end + +function XCharacterViewModel:GetLevel() + return self.Level +end + +function XCharacterViewModel:GetQuality() + return self.Quality +end + +-- 型号名称 +function XCharacterViewModel:GetTradeName() + return self.Config.TradeName +end + +-- 职业类型 +function XCharacterViewModel:GetProfessionType() + if self.ProfessionType == nil then + local npcId = XCharacterConfigs.GetCharNpcId(self.Config.Id, self.Quality) + local npcConfig = XCharacterConfigs.GetNpcTemplate(npcId) + self.ProfessionType = npcConfig and npcConfig.Type or 0 + end + return self.ProfessionType +end + +-- 职业图标 +function XCharacterViewModel:GetProfessionIcon() + return XCharacterConfigs.GetNpcTypeIcon(self:GetProfessionType()) +end + +-- 品质图标 +function XCharacterViewModel:GetQualityIcon() + return XCharacterConfigs.GetCharacterQualityIcon(self.Quality) +end + +function XCharacterViewModel:GetSmallHeadIcon() + return XDataCenter.CharacterManager.GetCharSmallHeadIcon(self.Config.Id, self.LiberateLv, not self.IsBelongPlayer, self.FashionId) +end + +function XCharacterViewModel:GetBigHeadIcon() + return XDataCenter.CharacterManager.GetCharBigHeadIcon(self.Config.Id, self.LiberateLv, not self.IsBelongPlayer, self.FashionId) +end + +function XCharacterViewModel:GetHalfBodyIcon() --获得角色半身像(剧情用) + return XDataCenter.CharacterManager.GetCharHalfBodyBigImage(self.Config.Id) +end + +function XCharacterViewModel:GetHalfBodyCommonIcon() --获得角色半身像(通用) + return XDataCenter.CharacterManager.GetCharHalfBodyImage(self.Config.Id) +end + +function XCharacterViewModel:GetGradeLevel() + return self.Grade +end + +function XCharacterViewModel:GetGradeIcon() + return XCharacterConfigs.GetCharGradeIcon(self.Config.Id, self.Grade) +end + +function XCharacterViewModel:GetAbility() + if self.IsBelongPlayer and self.Character then + return self.Character.Ability + end + return self.Ability +end + +function XCharacterViewModel:GetCareer() + return XCharacterConfigs.GetCharDetailTemplate(self.Config.Id).Career +end + +-- 获取能量元素(物理,火,暗...) +function XCharacterViewModel:GetObtainElements() + return XCharacterConfigs.GetCharDetailTemplate(self.Config.Id).ObtainElementList +end + +-- 获取能量元素图标(物理,火,暗...) +function XCharacterViewModel:GetObtainElementIcons() + local result = {} + local obtainElements = self:GetObtainElements() + local elementConfig = nil + for _, v in ipairs(obtainElements) do + elementConfig = XCharacterConfigs.GetCharElement(v) + table.insert(result, elementConfig.Icon) + end + return result +end + +-- equipViewModels : XEquipViewModel array +function XCharacterViewModel:GetAttributes(equipViewModels) + local character = self:GetCharacter() + -- 如果是属于自身玩家的数据,直接返回原来的写法 + if self.IsBelongPlayer then + return character:GetAttributes() + end + local equips = {} + for _, value in ipairs(equipViewModels or {}) do + table.insert(equips, value:GetEquip()) + end + self.Attribs = XDataCenter.CharacterManager.GetCharacterAttribsOther(character, equips) + return self.Attribs +end + +-- 获取队长技能信息 +function XCharacterViewModel:GetCaptainSkillInfo() + local result + if XRobotManager.CheckIsRobotId(self.SourceEntityId) then + result = XRobotManager.GetRobotCaptainSkillInfo(self.SourceEntityId) + elseif self.IsBelongPlayer then + result = XDataCenter.CharacterManager.GetCaptainSkillInfo(self.SourceEntityId) + -- 可能存在第三种情况,是角色同时不属于玩家本身,后面有业务需求再扩展 + end + return result +end + +-- return : XCharacterConfigs.CharacterType +function XCharacterViewModel:GetCharacterType() + return XCharacterConfigs.GetCharacterType(self.Config.Id) +end + +return XCharacterViewModel \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XChat/XChatData.lua b/Resources/Scripts/XEntity/XChat/XChatData.lua new file mode 100644 index 00000000..a73c341e --- /dev/null +++ b/Resources/Scripts/XEntity/XChat/XChatData.lua @@ -0,0 +1,228 @@ +--从服务器接收的格式 +XChatData = XClass(nil, "XChatData") + +local Default = { + MessageId = 0, + ChannelType = 0, + MsgType = 0, + SenderId = 0, + Icon = 0, + NickName = "", + TargetId = 0, + CreateTime = 0, + Content = 0, + GiftId = 0, + GiftCount = 0, + GiftStatus = 0, + IsRead = false, + CurrMedalId = 0, + BabelTowerLevel = 0, + BabelTowerTitleId = 0, + GuildRankLevel = 0, + GuildName = "", + CollectWordId = 0, + NameplateId = 0, +} + +function XChatData:Ctor(chatData) + for key in pairs(Default) do + self[key] = Default[key] + end + + if chatData == nil then + return + end + + self.MessageId = chatData.MessageId + self.ChannelType = chatData.ChannelType + self.MsgType = chatData.MsgType + self.SenderId = chatData.SenderId + self.Icon = chatData.Icon + self.HeadFrameId = chatData.HeadFrameId + self.NickName = chatData.NickName + self.TargetId = chatData.TargetId + self.CreateTime = chatData.CreateTime + self.Content = chatData.Content + self.GiftId = chatData.GiftId + self.GiftCount = chatData.GiftCount + self.GiftStatus = chatData.GiftStatus + self.CurrMedalId = chatData.CurrMedalId + self.BabelTowerLevel = chatData.BabelTowerTitleInfo and chatData.BabelTowerTitleInfo.Score or 0 + self.BabelTowerTitleId = chatData.BabelTowerTitleInfo and chatData.BabelTowerTitleInfo.Id or nil + self.CustomContent = chatData.CustomContent + self.GuildRankLevel = chatData.GuildRankLevel + self.GuildName = chatData.GuildName + self.CollectWordId = chatData.CollectWordId + self.IsRead = false + self.NameplateId = chatData.NameplateId or 0 +end + +function XChatData:GetSendTime() + local time = XTime.TimestampToGameDateTimeString(self.CreateTime, "HH:mm:ss") + return time +end + +function XChatData.EncodeRoomMsg(...) + local content = "" + + for _, v in ipairs { ... } do + content = content .. v .. "|" + end + + return content +end + +function XChatData.DecodeRoomMsg(content) + return content:Split("|") +end + +function XChatData:GetRoomMsgContent() + if self.Content:IsNilOrEmpty() then + return "" + end + + local contentData = XChatData.DecodeRoomMsg(self.Content) + if not contentData then + return "" + end + + local contentId = tonumber(contentData[1]) + local playerId = tonumber(contentData[2]) + local stageId = tonumber(contentData[3]) + local roomId = contentData[4] + local roomType = tonumber(contentData[5]) + local stageLevel = tonumber(contentData[6]) + + if contentId == RoomMsgContentId.FrinedInvite then + -- 普通联机 + if MultipleRoomType.Normal == roomType or MultipleRoomType.ArenaOnline == roomType then + local playerName + if playerId == XPlayer.Id then + playerName = XPlayer.Name + else + playerName = XDataCenter.SocialManager.GetPlayerRemark(playerId, "") + end + + local stageName = "" + if MultipleRoomType.ArenaOnline == roomType then + local tempStageId = XDataCenter.ArenaOnlineManager.GetStageIdByIdAndLevel(stageId, stageLevel) + if tempStageId then + stageName = XDataCenter.FubenManager.GetStageCfg(tempStageId).Name + end + else + stageName = XDataCenter.FubenManager.GetStageCfg(stageId).Name + end + + local inviteWords = CS.XTextManager.GetText("OnlineInviteLink", string.format("%s|%s|%s|%s", roomId, tostring(stageId), tostring(roomType), tostring(stageLevel))) + return CS.XTextManager.GetText("OnlineInviteFriend", playerName, stageName, inviteWords) + end + -- 狙击战联机 + if MultipleRoomType.UnionKill == roomType then + local playerName + if playerId == XPlayer.Id then + playerName = XPlayer.Name + else + playerName = XDataCenter.SocialManager.GetPlayerRemark(playerId, "") + end + + local unionInfo = XDataCenter.FubenUnionKillManager.GetUnionKillInfo() + local activityName + if not unionInfo then + activityName = "" + else + local currentUnionActivityConfig = XFubenUnionKillConfigs.GetUnionActivityConfigById(unionInfo.Id) + activityName = currentUnionActivityConfig.Name + end + + local inviteWords = CS.XTextManager.GetText("OnlineInviteLink", string.format("%s|%s|%s|%s", roomId, tostring(stageId), tostring(roomType), tostring(stageLevel))) + return CS.XTextManager.GetText("OnlineInviteFriend", playerName, activityName, inviteWords) + end + end + + return "" +end + +--检测是否自己发送的 +function XChatData:CheckIsSelfChat() + return self.SenderId == XPlayer.Id +end + +function XChatData:GetChatTargetId()--获取聊天对象的id + if (self:CheckIsSelfChat()) then + return self.TargetId + else + return self.SenderId + end +end + +--该礼物消息属于送礼还是收礼 +function XChatData:GetGiftChatType() + if self.CreateTime == self.GiftCreateTime then + return GiftChatType.Send + else + return GiftChatType.Receive + end +end + +--是否有自己可领取的礼物 +function XChatData:CheckHaveGift() + if (not self:CheckIsSelfChat() and + self.MsgType == ChatMsgType.Gift and + self.GiftStatus == ChatGiftState.WaitReceive) then + return true + else + return false + end +end + +--发送或者接收的消息的类型 +ChatChannelType = { + System = 1, --系统 + World = 2, --世界 + Private = 3, --私聊 + Room = 4, --房间 + Battle = 5, --战斗 + Guild = 6, --公会 + Mentor = 7,--师徒 +} + +ChatMsgType = { + Normal = 1, --普通消息 + Emoji = 2, --表情消息 + Gift = 3, --礼物消息 + Tips = 4, --提示消息 + RoomMsg = 5, -- 联机房间消息 + System = 6, --公会系统消息 + SpringFestival = 7, --春节集字活动消息 +} + +-- PrivateChatPrefabType = { +-- SelfChatBox = 1, +-- SelfChatEmojiBox = 2, +-- OtherChatBox = 3, +-- OtherChatEmojiBox = 4, +-- SelfGiftBox = 5, +-- OtherGiftBox = 6 +-- } + +ChatGiftState = { + None = 0, + WaitReceive = 1, --等待接收状态 + Received = 2, --已领取 + Fetched = 3, --不能领取 +} + +GiftChatType = { + Send = 1, + Receive = 2, +} + +RoomMsgContentId = { + FrinedInvite = 1, +} + +MultipleRoomType = { + Normal = 1, + UnionKill = 2, + ArenaOnline = 3, +} \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XChat/XChatEmoji.lua b/Resources/Scripts/XEntity/XChat/XChatEmoji.lua new file mode 100644 index 00000000..bcf841f4 --- /dev/null +++ b/Resources/Scripts/XEntity/XChat/XChatEmoji.lua @@ -0,0 +1,33 @@ +XChatEmoji = XClass(nil, "XChatEmoji") + +function XChatEmoji:Ctor(data) + self:InitChatEmoji(data) +end + +function XChatEmoji:InitChatEmoji(data) + self.Id = data.Id or 0 + self.EndTime = data.EndTime or 0 +end + +function XChatEmoji:GetEmojiId() + return self.Id +end + +function XChatEmoji:GetEmojiEndTime() + return self.EndTime +end + +function XChatEmoji:IsLimitEmoji() + return self.EndTime > 0 +end + +function XChatEmoji:IsEmojiValid(emojiId) + return self.Id == emojiId +end + +function XChatEmoji:GetEmojiOrder() + return XChatConfigs.GetEmojiConfigById(self.Id).Order +end +function XChatEmoji:GetEmojiIcon() + return XChatConfigs.GetEmojiIcon(self.Id) +end \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XClickClearGame/XClickClearGameRewardData.lua b/Resources/Scripts/XEntity/XClickClearGame/XClickClearGameRewardData.lua new file mode 100644 index 00000000..6d4a9127 --- /dev/null +++ b/Resources/Scripts/XEntity/XClickClearGame/XClickClearGameRewardData.lua @@ -0,0 +1,39 @@ +local XClickClearGameRewardData = XClass(nil, "XClickClearGameRewardData") + +function XClickClearGameRewardData:Ctor(gameStageId, rewardId, rewardConditionDesc) + self.GameStageId = gameStageId + self.RewardId = rewardId + self.ConditionDesc = rewardConditionDesc + self.IsTaked = false + self.IsCanTake = false +end + +function XClickClearGameRewardData:GetGameStageId() + return self.GameStageId +end + +function XClickClearGameRewardData:GetRewardId() + return self.RewardId +end + +function XClickClearGameRewardData:GetConditionDesc() + return self.ConditionDesc +end + +function XClickClearGameRewardData:CheckIsTaked() + return self.IsTaked +end + +function XClickClearGameRewardData:SetIsTaked(isTaked) + self.IsTaked = isTaked +end + +function XClickClearGameRewardData:CheckCanTake() + return self.IsCanTake +end + +function XClickClearGameRewardData:SetCanTake(canTake) + self.IsCanTake = canTake +end + +return XClickClearGameRewardData \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XCollectionWall/XCollectionWall.lua b/Resources/Scripts/XEntity/XCollectionWall/XCollectionWall.lua new file mode 100644 index 00000000..b2e065ac --- /dev/null +++ b/Resources/Scripts/XEntity/XCollectionWall/XCollectionWall.lua @@ -0,0 +1,148 @@ +local XCollectionWall = XClass(nil, "XCollectionWall") + +--[[ +XCollectionWall = +{ + 1、Id, -- CollectionWall表的Id标识 + 2、IsShow, -- 是否展示,boolean值 + 3、State, -- 墙的状态,类型为XCollectionWallConfigs.EnumWallState(服务器不派发,需要客户端自己计算并更新) + 4、BackgroundId, -- 背景Id,关联表CollectionWallDecoration + 5、PedestalId, -- 底座Id,关联表CollectionWallDecoration + + 6、CollectionSetInfos = -- 墙上摆放的收藏品 + { + index = { + Id, -- 收藏品Id + X, -- 坐标X + Y, -- 坐标Y + SizeId -- 尺寸Id + } + }, + + -- 存储在config中的数据 + 7、Rank, -- 排序值 + 8、Name, -- 墙的名称 + 9、Condition, -- 解锁条件 +} +--]] + +function XCollectionWall:Ctor(id) + self.Id = id + self.IsShow = true + self.State = XCollectionWallConfigs.EnumWallState.Lock + self.BackgroundId = 0 + self.PedestalId = 0 + + self.CollectionSetInfos = {} +end + +--- +--- 根据'data'的内容来更新相应的属性 +--- 需要注意的是key的名称和类型要与属性一致 +---@param date table +function XCollectionWall:UpdateDate(date) + for key, value in pairs(date) do + self[key] = value + end +end + +--- +--- 1、获取Id +---@return number +function XCollectionWall:GetId() + return self.Id +end + +--- +--- 2、获取是否展示属性 +---@return boolean +function XCollectionWall:GetIsShow() + return self.IsShow +end + +--- +--- 3、获取状态 +---@return boolean +function XCollectionWall:GetState() + return self.State +end + +--- +--- 4、获取背景Id +---@return number +function XCollectionWall:GetBackgroundId() + if self.BackgroundId <= 0 then + XLog.Error("XCollectionWall:GeBackground函数错误,BackgroundId数据未更新") + return self:GetCfg().InitBackgroundId + else + return self.BackgroundId + end +end + +--- +--- 5、获取底座Id +---@return number +function XCollectionWall:GetPedestalId() + if self.PedestalId <= 0 then + XLog.Error("XCollectionWall:GePedestal函数错误,PedestalId数据未更新") + return self:GetCfg().InitPedestalId + else + return self.PedestalId + end +end + +--- +--- 6、获取摆放的收藏品数组,数据结构在开头的注释说明中有写明 +---@return number +function XCollectionWall:GetCollectionSetInfos() + return self.CollectionSetInfos +end + +function XCollectionWall:GetWallPicture(cb) + if not cb then + XLog.Error("The ScreenShot API Must Need CallBack") + return + end + + local fileName = XDataCenter.CollectionWallManager.GetCaptureImgName(self.Id) + local textureCache = XDataCenter.CollectionWallManager.GetLocalCaptureCache(fileName) + + if textureCache then + cb(textureCache) + return + end + + CS.XTool.LoadLocalCaptureImgWithoutSuffix(fileName, function(texture) + XDataCenter.CollectionWallManager.SetLocalCaptureCache(fileName, texture) + cb(texture) + end) +end + +-----------------------------------------------存储在config中的数据-------------------------------------------------------- + +function XCollectionWall:GetCfg() + return XCollectionWallConfigs.GetCollectionWallCfg(self.Id) +end + +--- +--- 7、从配表中获取排序值 +---@return number +function XCollectionWall:GetRank() + return self:GetCfg().Rank +end + +--- +--- 8、从配表中获取名称 +---@return string +function XCollectionWall:GetName() + return self:GetCfg().Name +end + +--- +--- 9、从配表中获取解锁条件 +---@return number +function XCollectionWall:GetCondition() + return self:GetCfg().Condition +end + +return XCollectionWall \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XDrawMianButton/XDrawGroupBtnBaseEntity.lua b/Resources/Scripts/XEntity/XDrawMianButton/XDrawGroupBtnBaseEntity.lua new file mode 100644 index 00000000..b4603a73 --- /dev/null +++ b/Resources/Scripts/XEntity/XDrawMianButton/XDrawGroupBtnBaseEntity.lua @@ -0,0 +1,73 @@ +local XDrawGroupBtnBaseEntity = XClass(nil, "XDrawGroupBtnBaseEntity") +function XDrawGroupBtnBaseEntity:Ctor() + self.Id = 0 + self.Banner = "" + self.UiPrefab = "" + self.UiBackGround = "" + self.Tag = 0 + self.BannerBeginTime = 0 + self.BannerEndTime = 0 + self.BottomTimes = 0 + self.MaxBottomTimes = 0 + self.SwitchDrawIdCount = 0 + self.MaxSwitchDrawIdCount = 0 +end + +function XDrawGroupBtnBaseEntity:GetId() + return self.Id +end + +function XDrawGroupBtnBaseEntity:GetBanner() + return self.Banner +end + +function XDrawGroupBtnBaseEntity:GetUiPrefab() + return self.UiPrefab +end + +function XDrawGroupBtnBaseEntity:GetUiBackGround() + return self.UiBackGround +end + +function XDrawGroupBtnBaseEntity:GetTag() + return self.Tag +end + +function XDrawGroupBtnBaseEntity:GetBannerBeginTime() + return self.BannerBeginTime +end + +function XDrawGroupBtnBaseEntity:GetBannerEndTime() + return self.BannerEndTime +end + +function XDrawGroupBtnBaseEntity:GetBottomTimes() + return self.BottomTimes +end + +function XDrawGroupBtnBaseEntity:GetMaxBottomTimes() + return self.MaxBottomTimes +end + +function XDrawGroupBtnBaseEntity:GetUseItemIdList() + return self.UseItemIdList +end + +function XDrawGroupBtnBaseEntity:GetSwitchDrawIdCount() + return self.SwitchDrawIdCount +end + +function XDrawGroupBtnBaseEntity:GetMaxSwitchDrawIdCount() + return self.MaxSwitchDrawIdCount +end + +function XDrawGroupBtnBaseEntity:DoSelect(root) + root:CreateBanner(self) + return true +end + +function XDrawGroupBtnBaseEntity:IsMainButton() + return false +end + +return XDrawGroupBtnBaseEntity \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XDrawMianButton/XDrawTabBtnEntity.lua b/Resources/Scripts/XEntity/XDrawMianButton/XDrawTabBtnEntity.lua new file mode 100644 index 00000000..5f576ca8 --- /dev/null +++ b/Resources/Scripts/XEntity/XDrawMianButton/XDrawTabBtnEntity.lua @@ -0,0 +1,107 @@ +local XDrawTabBtnEntity = XClass(nil, "XDrawTabBtnEntity") + +function XDrawTabBtnEntity:Ctor(id) + self.Id = id + self.DrawGroupList = {} +end + +function XDrawTabBtnEntity:GetCfg() + return XDrawConfigs.GetDrawTabById(self.Id) +end + +function XDrawTabBtnEntity:GetId() + return self.Id +end + +function XDrawTabBtnEntity:GetDrawGroupList() + return self.DrawGroupList +end + +function XDrawTabBtnEntity:GetRuleType() + return XDrawConfigs.RuleType.Tab +end + +function XDrawTabBtnEntity:GetTxtName1() + return self:GetCfg().TxtName1 +end + +function XDrawTabBtnEntity:GetTxtName2() + return self:GetCfg().TxtName2 +end + +function XDrawTabBtnEntity:GetTxtName3() + return self:GetCfg().TxtName3 +end + +function XDrawTabBtnEntity:GetTxtTagName()--暂时没用 + return self:GetCfg().TxtTagName +end + +function XDrawTabBtnEntity:GetTabBg() + return self:GetCfg().TabBg +end + +function XDrawTabBtnEntity:GetPriority() + return self:GetCfg().Priority +end + +function XDrawTabBtnEntity:GetParentName() + return self:GetCfg().ParentName +end + +function XDrawTabBtnEntity:GetConditions() + return self:GetCfg().Condition +end + +function XDrawTabBtnEntity:JudgeCanOpen(IsShowHint) + local IsOpen = true + local desc = "" + for _, v in pairs(self:GetConditions()) do + if v and v ~= 0 then + IsOpen,desc = XConditionManager.CheckCondition(v) + if not IsOpen then + break + end + end + end + if IsShowHint then + if not IsOpen then + XUiManager.TipError(desc) + end + return IsOpen + else + return IsOpen + end +end + +function XDrawTabBtnEntity:InsertDrawGroupList(data) + self.DrawGroupList = self.DrawGroupList or {} + table.insert(self.DrawGroupList, data) +end + +function XDrawTabBtnEntity:DoSelect() + return self:JudgeCanOpen(true) +end + +function XDrawTabBtnEntity:IsShowTag() + local IsShowNewTag = false + local IsUnLock = self:JudgeCanOpen(false) + + if IsUnLock then + for _, drawGroupInfo in pairs(self.DrawGroupList or {}) do + if drawGroupInfo:GetBannerBeginTime() > 0 then + if XDataCenter.DrawManager.IsShowNewTag(drawGroupInfo:GetBannerBeginTime(), drawGroupInfo:GetRuleType(), drawGroupInfo:GetId()) then + IsShowNewTag = true + break + end + end + end + end + return IsShowNewTag +end + +function XDrawTabBtnEntity:IsMainButton() + return true +end + +return XDrawTabBtnEntity \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XDrawMianButton/XLottoDrawGroupBtnEntity.lua b/Resources/Scripts/XEntity/XDrawMianButton/XLottoDrawGroupBtnEntity.lua new file mode 100644 index 00000000..6789b62b --- /dev/null +++ b/Resources/Scripts/XEntity/XDrawMianButton/XLottoDrawGroupBtnEntity.lua @@ -0,0 +1,78 @@ +local XDrawGroupBtnBaseEntity = require("XEntity/XDrawMianButton/XDrawGroupBtnBaseEntity") +local XLottoDrawGroupBtnEntity = XClass(XDrawGroupBtnBaseEntity, "XLottoDrawGroupBtnEntity") + +function XLottoDrawGroupBtnEntity:Ctor() + self.data = {} +end + +function XLottoDrawGroupBtnEntity:UpdateData(data) + self.data = data or {} + self.Id = data:GetId() + self.Banner = data:GetBanner() + self.UiPrefab = data:GetUiPrefab() + self.UiBackGround = data:GetUiBackGround() + self.Tag = data:GetTag() + local drawData = data:GetDrawData() + self.BannerBeginTime = drawData:GetBeginTime() + self.BannerEndTime = drawData:GetEndTime() + self.BottomTimes = drawData:GetCurRewardCount() + self.MaxBottomTimes = drawData:GetMaxRewardCount() + + self.UseItemIdList = {} + table.insert(self.UseItemIdList, XDataCenter.ItemManager.ItemId.FreeGem) + table.insert(self.UseItemIdList, drawData:GetConsumeId()) +end + +function XLottoDrawGroupBtnEntity:GetRuleType() + return XDrawConfigs.RuleType.Lotto +end + +function XLottoDrawGroupBtnEntity:GetName() + return self.data:GetName() or "" +end + +function XLottoDrawGroupBtnEntity:GetRareRank() + return 0 +end + +function XLottoDrawGroupBtnEntity:GetGroupBtnBg() + return self.data:GetGroupBtnBg() +end + +function XLottoDrawGroupBtnEntity:GetTopRewardData() + local drawData = self.data:GetDrawData() + return drawData:GetTopRewardData() +end + +function XLottoDrawGroupBtnEntity:GetBottomText() + local bottomText = CS.XTextManager.GetText("NewDrawMainBottomText") + return string.format("%s%d/%d", bottomText, self.BottomTimes, self.MaxBottomTimes) +end + +function XLottoDrawGroupBtnEntity:GetSwitchText() + return "" +end + +function XLottoDrawGroupBtnEntity:GoDraw(cb) + if cb then cb() end + local skipid = tonumber(self.UiPrefab) + if skipid then + XFunctionManager.SkipInterface(skipid) + else + XLuaUiManager.Open(self:GetUiPrefab(), self.data, function() + end, self:GetUiBackGround()) + end +end + +function XLottoDrawGroupBtnEntity:IsShowTag() + local IsShowNewTag = false + + if self.BannerBeginTime > 0 then + if XDataCenter.DrawManager.IsShowNewTag(self.BannerBeginTime, XDrawConfigs.RuleType.Lotto, self.Id) then + IsShowNewTag = true + end + end + return IsShowNewTag +end + +return XLottoDrawGroupBtnEntity \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XDrawMianButton/XNormalDrawGroupBtnEntity.lua b/Resources/Scripts/XEntity/XDrawMianButton/XNormalDrawGroupBtnEntity.lua new file mode 100644 index 00000000..0758e732 --- /dev/null +++ b/Resources/Scripts/XEntity/XDrawMianButton/XNormalDrawGroupBtnEntity.lua @@ -0,0 +1,100 @@ +local XDrawGroupBtnBaseEntity = require("XEntity/XDrawMianButton/XDrawGroupBtnBaseEntity") +local XNormalDrawGroupBtnEntity = XClass(XDrawGroupBtnBaseEntity, "XNormalDrawGroupBtnEntity") +local CSTextManagerGetText = CS.XTextManager.GetText +function XNormalDrawGroupBtnEntity:Ctor() + +end + +function XNormalDrawGroupBtnEntity:GetCfg() + return XDrawConfigs.GetDrawGroupRuleById(self.Id) +end + +function XNormalDrawGroupBtnEntity:UpdateData(data) + self.Id = data.Id + self.Banner = data.Banner + self.UiPrefab = data.UiPrefab + self.UiBackGround = data.UiBackGround + self.Tag = data.Tag + self.BannerBeginTime = data.BannerBeginTime; + self.BannerEndTime = data.BannerEndTime; + self.BottomTimes = data.BottomTimes; + self.MaxBottomTimes = data.MaxBottomTimes; + self.SwitchDrawIdCount = data.SwitchDrawIdCount + self.MaxSwitchDrawIdCount = data.MaxSwitchDrawIdCount + + self.UseItemIdList = {} + table.insert(self.UseItemIdList, XDataCenter.ItemManager.ItemId.FreeGem) + table.insert(self.UseItemIdList, data.UseItemId) +end + +function XNormalDrawGroupBtnEntity:GetRuleType() + return XDrawConfigs.RuleType.Normal +end + +function XNormalDrawGroupBtnEntity:GetRuleType() + return XDrawConfigs.RuleType.Normal +end + +function XNormalDrawGroupBtnEntity:GetName() + return self:GetCfg().TitleCN +end + +function XNormalDrawGroupBtnEntity:GetRareRank() + return self:GetCfg().RareRank +end + +function XNormalDrawGroupBtnEntity:GetGroupBtnBg() + return self:GetCfg().GroupBtnBg +end + +function XNormalDrawGroupBtnEntity:GetGroupBtnBg() + return self:GetCfg().GroupBtnBg +end + +function XNormalDrawGroupBtnEntity:GetNewHandBottomCount() + return self:GetCfg().NewHandBottomCount +end + +function XNormalDrawGroupBtnEntity:GetGroupType() + return self:GetCfg().SpecialBottomMin > 0 and + self:GetCfg().SpecialBottomMax > 0 and + XDrawConfigs.GroupType.Destiny or XDrawConfigs.GroupType.Normal +end + +function XNormalDrawGroupBtnEntity:GetBottomText() + local bottomText = CSTextManagerGetText("NewDrawMainBottomText") + if self:GetCfg().SpecialBottomMin > 0 and self:GetCfg().SpecialBottomMax > 0 then + return string.format("%s%d/%d~%d", bottomText, self.BottomTimes, self:GetCfg().SpecialBottomMin, self:GetCfg().SpecialBottomMax) + else + return string.format("%s%d/%d", bottomText, self.BottomTimes, self.MaxBottomTimes) + end +end + +function XNormalDrawGroupBtnEntity:GetSwitchText() + if self.MaxSwitchDrawIdCount > 0 then + local count = self.MaxSwitchDrawIdCount - self.SwitchDrawIdCount + return count > 0 and CSTextManagerGetText("DrawBannerSelectCountText", count) or CSTextManagerGetText("DrawBannerSelectNotCountText") + end + return "" +end + +function XNormalDrawGroupBtnEntity:GoDraw(cb) + XDataCenter.DrawManager.GetDrawInfoList(self:GetId(), function() + if cb then cb() end + XLuaUiManager.Open(self:GetUiPrefab(), self:GetId(), function() + end, self:GetUiBackGround()) + end) +end + +function XNormalDrawGroupBtnEntity:IsShowTag() + local IsShowNewTag = false + + if self.BannerBeginTime > 0 then + if XDataCenter.DrawManager.IsShowNewTag(self.BannerBeginTime, XDrawConfigs.RuleType.Normal, self.Id) then + IsShowNewTag = true + end + end + return IsShowNewTag +end + +return XNormalDrawGroupBtnEntity \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XEquip/XAwarenessViewModel.lua b/Resources/Scripts/XEntity/XEquip/XAwarenessViewModel.lua new file mode 100644 index 00000000..3ac98869 --- /dev/null +++ b/Resources/Scripts/XEntity/XEquip/XAwarenessViewModel.lua @@ -0,0 +1,23 @@ +local XEquipViewModel = require("XEntity/XEquip/XEquipViewModel") +local XAwarenessViewModel = XClass(XEquipViewModel, "XAwarenessViewModel") + +function XAwarenessViewModel:CheckPosIsAwaken(pos) + if not self.AwakeSlotList then return end + for _, slot in pairs(self.AwakeSlotList) do + if slot == pos then + return true + end + end + return false +end + +-- 适配XEquip方法 +function XAwarenessViewModel:IsEquipPosAwaken(pos) + return self:GetEquip():IsEquipPosAwaken(pos) +end + +function XAwarenessViewModel:GetSite() + return self.__SlotPos +end + +return XAwarenessViewModel \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XEquip/XEquip.lua b/Resources/Scripts/XEntity/XEquip/XEquip.lua new file mode 100644 index 00000000..f9e313c7 --- /dev/null +++ b/Resources/Scripts/XEntity/XEquip/XEquip.lua @@ -0,0 +1,170 @@ +local next = next +local tableInsert = table.insert + +local XEquip = XClass(nil, "XEquip") + +local Default = { + Id = 0, + TemplateId = 0, + CharacterId = 0, + Level = 1, + Exp = 0, + Breakthrough = 0, + CreateTime = 0, + IsLock = false, + IsRecycle = false, + AwakeSlotList = {}, + AwakeSlotListCheck = {}, +} + +function XEquip.GetDefaultFields() + return Default +end + +--[[装备共鸣表结构 +ResonanceInfo = { + Slot = slot, + Type = XEquipConfig.EquipResonanceType.Attrib, + CharacterId = 0, + TemplateId = 0, +} +]] +--[[/// 意识自动回收设置 +[MessagePackObject(keyAsPropertyName: true)] +public class XChipRecycleSite +{ + // 设置的回收星级 + public List RecycleStar = new List(); + // 设置回收天数, 0为不回收 + public int Days; +} +]] +function XEquip:Ctor(protoData) + for key, v in pairs(Default) do + self[key] = v + end + self:SyncData(protoData) +end + +function XEquip:SyncData(protoData) + self.Id = protoData.Id + self.TemplateId = protoData.TemplateId + self.CharacterId = protoData.CharacterId + self.Level = protoData.Level + self.Exp = protoData.Exp + self.Breakthrough = protoData.Breakthrough + self.CreateTime = protoData.CreateTime + self.IsLock = protoData.IsLock + self.IsRecycle = protoData.IsRecycle + + if protoData.ResonanceInfo and next(protoData.ResonanceInfo) then + self.ResonanceInfo = {} + + for _, info in pairs(protoData.ResonanceInfo) do + self.ResonanceInfo[info.Slot] = info + end + else + self.ResonanceInfo = nil + end + + if protoData.UnconfirmedResonanceInfo and next(protoData.UnconfirmedResonanceInfo) then + self.UnconfirmedResonanceInfo = {} + for _, info in pairs(protoData.UnconfirmedResonanceInfo) do + self.UnconfirmedResonanceInfo[info.Slot] = info + end + else + self.UnconfirmedResonanceInfo = nil + end + + self.AwakeSlotListCheck = {} + if protoData.AwakeSlotList and next(protoData.AwakeSlotList) then + self.AwakeSlotList = protoData.AwakeSlotList + for _, slot in pairs(self.AwakeSlotList) do + self.AwakeSlotListCheck[slot] = true + end + end +end + +--@isSelect: 是否自选的技能 +function XEquip:Resonance(resonanceInfo, isSelect) + local slot = resonanceInfo.Slot + local info = self.ResonanceInfo and self.ResonanceInfo[slot] + + if not info then + self.ResonanceInfo = self.ResonanceInfo and self.ResonanceInfo or {} + self.ResonanceInfo[slot] = resonanceInfo + else + if not isSelect then + self.UnconfirmedResonanceInfo = self.UnconfirmedResonanceInfo and self.UnconfirmedResonanceInfo or {} + if resonanceInfo and next(resonanceInfo) then + self.UnconfirmedResonanceInfo[slot] = resonanceInfo + end + else + self.ResonanceInfo[slot] = resonanceInfo + end + end + self:SetRecycle(false) +end + +function XEquip:ResonanceConfirm(slot, isUse) + local info = self.UnconfirmedResonanceInfo and self.UnconfirmedResonanceInfo[slot] + if not info then return end + self.ResonanceInfo[slot] = isUse and info or self.ResonanceInfo[slot] + if self.UnconfirmedResonanceInfo then + self.UnconfirmedResonanceInfo[slot] = nil + self.UnconfirmedResonanceInfo = next(self.UnconfirmedResonanceInfo) and self.UnconfirmedResonanceInfo or nil + end + self:SetRecycle(false) +end + +function XEquip:SetAwake(slot) + local awakeSlotList = {} + self.AwakeSlotListCheck[slot] = true + for tmpSlot in pairs(self.AwakeSlotListCheck) do + tableInsert(awakeSlotList, tmpSlot) + end + self.AwakeSlotList = awakeSlotList + self:SetRecycle(false) +end + +function XEquip:PutOn(characterId) + characterId = characterId or 0 + self.CharacterId = characterId + self:SetRecycle(false) +end + +function XEquip:TakeOff() + self.CharacterId = 0 +end + +function XEquip:SetLock(isLock) + self.IsLock = isLock and true or false + self:SetRecycle(false) +end + +function XEquip:SetRecycle(isRecycle) + self.IsRecycle = isRecycle and true or false +end + +function XEquip:BreakthroughOneTime() + self.Breakthrough = self.Breakthrough + 1 + self.Level = 1 + self.Exp = 0 + self:SetRecycle(false) +end + +function XEquip:SetLevel(level) + self.Level = level + self:SetRecycle(false) +end + +function XEquip:SetExp(exp) + self.Exp = exp +end + +function XEquip:IsEquipPosAwaken(slot) + return self.AwakeSlotListCheck[slot] and true or false +end + + +return XEquip \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XEquip/XEquipModel.lua b/Resources/Scripts/XEntity/XEquip/XEquipModel.lua new file mode 100644 index 00000000..2b6dcf11 --- /dev/null +++ b/Resources/Scripts/XEntity/XEquip/XEquipModel.lua @@ -0,0 +1,79 @@ +local XEquipModel = XClass(nil, "XEquipModel") + +-- go 为绑定生命周期的对象 +-- luaBehaviour (XLuaBehaviour组件)提供生命周期回调 +function XEquipModel:Ctor(go, luaBehaviour) + self.GameObject = go + self.LuaBehaviour = luaBehaviour + luaBehaviour.LuaOnDisable = function() self:OnDisable() end + luaBehaviour.LuaOnDestroy = function() self:OnDestroy() end + + self.AudioInfoDict = {} +end + +function XEquipModel:OnDisable() + -- 清除音效 + self:ClearAudioInfo() +end + +function XEquipModel:OnDestroy() + self:UnScheduleRotate() + XModelManager.RemoveLuaBehaviour(self.GameObject) +end + +-- 记录模型音效 +function XEquipModel:AddAudioInfo(audioInfo) + self.AudioInfoDict[audioInfo] = true +end + +-- 停止模型音效 +function XEquipModel:ClearAudioInfo() + if next(self.AudioInfoDict) then + for audioInfo, _ in pairs(self.AudioInfoDict) do + audioInfo:Stop() + end + self.AudioInfoDict = {} + end +end + + +--==============================-- +--desc: 自转 +--@rootGo: 根结点 提供XAutoRotation组件 +--@model: 武器模型 +--@modelId: 武器模型id +--==============================-- +function XEquipModel:AutoRotateWeapon(rootGo, model, modelId) + self:UnScheduleRotate() + + local delay = XEquipConfig.GetEquipUiAutoRotateDelay(modelId) + if delay and delay > 0 then + self.RotateScheduleId = XScheduleManager.ScheduleOnce(function() + self:DoAutoRotateWeapon(rootGo, model) + end, delay) + else + self:DoAutoRotateWeapon(rootGo, model) + end +end + +function XEquipModel:DoAutoRotateWeapon(rootGo, model) + if XTool.UObjIsNil(rootGo) or XTool.UObjIsNil(model) then + return + end + + local rotate = rootGo:GetComponent("XAutoRotation") + if rotate then + rotate.RotateSelf = false + rotate.Inited = false + rotate.Target = model.transform + end +end + +function XEquipModel:UnScheduleRotate() + if self.RotateScheduleId then + XScheduleManager.UnSchedule(self.RotateScheduleId) + self.RotateScheduleId = nil + end +end + +return XEquipModel \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XEquip/XEquipSuitPrefab.lua b/Resources/Scripts/XEntity/XEquip/XEquipSuitPrefab.lua new file mode 100644 index 00000000..5b60e5a8 --- /dev/null +++ b/Resources/Scripts/XEntity/XEquip/XEquipSuitPrefab.lua @@ -0,0 +1,122 @@ +local PresentSuitEquipsCount = 4 -- 已装备的意识中同一套的装备数量代表值 + +local XEquipSuitPrefab = XClass(nil, "XEquipSuitPrefab") + +local Default = { + EquipCount = 0, + PresentSuitId = nil, + SiteToEquipIdDic = {}, + EquipIdCheckTable = {}, + --Original Data + GroupId = 0, + Name = "", + ChipIdList = {}, + CharacterId = 0, +} +--[[ +public class XChipGroupData +{ + // 组合id + public int GroupId; + // 组合名字 + public string Name; + // 意识id列表 + public List ChipIdList; + // 专属组合角色Id,通用组合为0 + public int CharacterId; +} +]] +function XEquipSuitPrefab:Ctor(equipGroupData) + for key, v in pairs(Default) do + self[key] = v + end + + self:UpdateData(equipGroupData) +end + +function XEquipSuitPrefab:UpdateData(equipGroupData) + self.GroupId = equipGroupData.GroupId or self.GroupId + self.Name = equipGroupData.Name or self.Name + self.CharacterId = equipGroupData.CharacterId or self.CharacterId + self.ChipIdList = equipGroupData.ChipIdList + + self.SiteToEquipIdDic = {} + self.EquipIdCheckTable = {} + for _, equipId in pairs(self.ChipIdList) do + local equipSite = XDataCenter.EquipManager.GetEquipSite(equipId) + self.SiteToEquipIdDic[equipSite] = equipId + self.EquipIdCheckTable[equipId] = true + end + + local count = 0 + for _, _ in pairs(self.SiteToEquipIdDic) do + count = count + 1 + end + self.EquipCount = count + + local presentEquipId = nil + local suitIdCountDic = {} + for site = XEquipConfig.EquipSite.Awareness.One, XEquipConfig.EquipSite.Awareness.Six do + local equipId = self.SiteToEquipIdDic[site] + if equipId then + presentEquipId = presentEquipId or equipId + + local suitId = XDataCenter.EquipManager.GetSuitId(equipId) + local tmpCount = suitIdCountDic[suitId] or 0 + tmpCount = tmpCount + 1 + if tmpCount == PresentSuitEquipsCount then + presentEquipId = equipId + break + end + suitIdCountDic[suitId] = tmpCount + end + end + self.PresentSuitId = presentEquipId and XDataCenter.EquipManager.GetSuitId(presentEquipId) +end + +function XEquipSuitPrefab:GetGroupId() + return self.GroupId +end + +function XEquipSuitPrefab:GetName() + return self.Name +end + +function XEquipSuitPrefab:SetName(newName) + self.Name = newName +end + +function XEquipSuitPrefab:GetEquipCount() + return self.EquipCount +end + +function XEquipSuitPrefab:GetPresentSuitId() + return self.PresentSuitId +end + +function XEquipSuitPrefab:GetEquipId(site) + return self.SiteToEquipIdDic[site] +end + +function XEquipSuitPrefab:GetEquipIds() + return self.ChipIdList +end + +-- 专属组合角色Id,通用组合为0 +function XEquipSuitPrefab:GetCharacterId() + return self.CharacterId +end + +function XEquipSuitPrefab:IsEquipIn(equipId) + return self.EquipIdCheckTable[equipId] +end + +function XEquipSuitPrefab:GetCharacterType() + for _, equipId in pairs(self.ChipIdList) do + local templateId = XDataCenter.EquipManager.GetEquipTemplateId(equipId) + return XEquipConfig.GetEquipCharacterType(templateId) + end + return XEquipConfig.UserType.All +end + +return XEquipSuitPrefab \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XEquip/XEquipViewModel.lua b/Resources/Scripts/XEntity/XEquip/XEquipViewModel.lua new file mode 100644 index 00000000..4a9b4079 --- /dev/null +++ b/Resources/Scripts/XEntity/XEquip/XEquipViewModel.lua @@ -0,0 +1,57 @@ +local XEquip = require("XEntity/XEquip/XEquip") +local XEquipViewModel = XClass(nil, "XEquipViewModel") + +function XEquipViewModel:Ctor(equipCid) + self.Config = XEquipConfig.GetEquipCfg(equipCid) + -- XEquip + self.Equip = nil + self.UpdatedData = nil + -- 初始化来自XEquip的默认字段,保持一致性 + for key, value in pairs(XEquip.GetDefaultFields()) do + if type(value) == "table" then + self[key] = XTool.Clone(value) + else + self[key] = value + end + end +end + +function XEquipViewModel:UpdateWithData(data) + self.UpdatedData = data + for key, value in pairs(data) do + self[key] = value + end +end + +function XEquipViewModel:GetName() + return self.Config.Name or "" +end + +function XEquipViewModel:GetLevel() + return self.Level +end + +function XEquipViewModel:GetQualityIcon() + return XDataCenter.EquipManager.GetEquipQualityPath(self.Config.Id) +end + +function XEquipViewModel:GetIcon() + return XDataCenter.EquipManager.GetEquipIconBagPath(self.Config.Id, self.Breakthrough) +end + +function XEquipViewModel:GetResonanceInfos() + return self.ResonanceInfo +end + +function XEquipViewModel:GetBreakthrough() + return self.Breakthrough +end + +function XEquipViewModel:GetEquip() + if self.Equip == nil then + self.Equip = XEquip.New(self.UpdatedData) + end + return self.Equip +end + +return XEquipViewModel \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XEquip/XSkillInfoObj.lua b/Resources/Scripts/XEntity/XEquip/XSkillInfoObj.lua new file mode 100644 index 00000000..e366eabd --- /dev/null +++ b/Resources/Scripts/XEntity/XEquip/XSkillInfoObj.lua @@ -0,0 +1,86 @@ +local XSkillInfoObj = {} + +local function Setmetatable(M, config) + local mt = { + __metatable = "readonly table", + __index = function(_, k) + if M[k] then + return M[k] + else + return config[k] + end + end, + __newindex = function() + XLog.Error("attempt to update a readonly table") + end, + } + + return setmetatable({}, mt) +end + +local function GetResonanceSkillInfoByType(equipResonanceType, templateId) + if equipResonanceType == XEquipConfig.EquipResonanceType.Attrib then + return XAttribManager.TryGetAttribGroupTemplate(templateId) + elseif equipResonanceType == XEquipConfig.EquipResonanceType.CharacterSkill then + return XCharacterConfigs.GetCharacterSkillPoolSkillInfo(templateId) + elseif equipResonanceType == XEquipConfig.EquipResonanceType.WeaponSkill then + return XEquipConfig.GetWeaponSkillInfo(templateId) + end +end + +local function GetDescription(equipResonanceType, config) + if equipResonanceType == XEquipConfig.EquipResonanceType.WeaponSkill then + local linkCharacterSkillId = config.DesLinkCharacterSkillId + if linkCharacterSkillId and linkCharacterSkillId ~= 0 then + return XDataCenter.CharacterManager.GetSpecialWeaponSkillDes(linkCharacterSkillId) + else + return config.Description + end + else + return config.Description + end +end + +--[[ + @desc: 意识、武器、属性的工厂类 + --@equipResonanceType: 枚举XEquipConfig.EquipResonanceType + --@id: 对应config内的id字段 +]] +function XSkillInfoObj.New(equipResonanceType, id) + local config = GetResonanceSkillInfoByType(equipResonanceType, id) + + if not config then + XLog.Error(string.format("没有找到对应的配置 equipResonanceType:%s id:%s", equipResonanceType, id)) + return + end + + local M = {} + M.EquipResonanceType = equipResonanceType + M.Description = GetDescription(equipResonanceType, config) + + function M:IsSame(skillInfoObj) + if skillInfoObj then + if self.EquipResonanceType == skillInfoObj.EquipResonanceType and self.Id == skillInfoObj.Id then + return true + else + return false + end + else + return false + end + end + + --用于服务端的Id + function M:GetSkillIdToServer() + if XEquipConfig.EquipResonanceType.CharacterSkill == self.EquipResonanceType then + return self.SkillId + else + return self.Id + end + end + + return Setmetatable(M, config) +end + + +return XSkillInfoObj diff --git a/Resources/Scripts/XEntity/XEquip/XWeaponFashion.lua b/Resources/Scripts/XEntity/XEquip/XWeaponFashion.lua new file mode 100644 index 00000000..7136c6f5 --- /dev/null +++ b/Resources/Scripts/XEntity/XEquip/XWeaponFashion.lua @@ -0,0 +1,64 @@ +--[[ +public sealed class XWeaponFashionData +{ + public int Id; + public long ExpireTime; + public List UseCharacterList = new List(); +} +]] + +local Default = { + Id = 0, + ExpireTime = 0, + UseCharacterIdCheckTable = {}, +} + +local XWeaponFashion = XClass(nil, "XWeaponFashion") + +function XWeaponFashion:Ctor(data) + for key, v in pairs(Default) do + self[key] = v + end + + self:UpdateData(data) +end + +function XWeaponFashion:UpdateData(data) + self.Id = data.Id or self.Id + self.ExpireTime = data.ExpireTime or self.ExpireTime + + self.UseCharacterIdCheckTable = {} + for _, characterId in pairs(data.UseCharacterList) do + self.UseCharacterIdCheckTable[characterId] = characterId + end +end + +function XWeaponFashion:GetId() + return self.Id +end + +function XWeaponFashion:GetLeftTime() + local nowTime = XTime.GetServerNowTimestamp() + local endTime = self.ExpireTime + local leftTime = endTime - nowTime + leftTime = leftTime > 0 and leftTime or 0 + return leftTime +end + +function XWeaponFashion:Dress(characterId) + self.UseCharacterIdCheckTable[characterId] = characterId +end + +function XWeaponFashion:TakeOff(characterId) + self.UseCharacterIdCheckTable[characterId] = nil +end + +function XWeaponFashion:IsDressed(characterId) + return self.UseCharacterIdCheckTable[characterId] +end + +function XWeaponFashion:IsTimeLimit() + return self.ExpireTime > 0 +end + +return XWeaponFashion \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XEquip/XWeaponViewModel.lua b/Resources/Scripts/XEntity/XEquip/XWeaponViewModel.lua new file mode 100644 index 00000000..34ab0640 --- /dev/null +++ b/Resources/Scripts/XEntity/XEquip/XWeaponViewModel.lua @@ -0,0 +1,9 @@ +local XEquipViewModel = require("XEntity/XEquip/XEquipViewModel") +local XWeaponViewModel = XClass(XEquipViewModel, "XWeaponViewModel") + +-- 适配XEquip方法 +function XWeaponViewModel:IsEquipPosAwaken(pos) + return self:GetEquip():IsEquipPosAwaken(pos) +end + +return XWeaponViewModel \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XExpedition/XExpeditionActivity.lua b/Resources/Scripts/XEntity/XExpedition/XExpeditionActivity.lua new file mode 100644 index 00000000..bfc38977 --- /dev/null +++ b/Resources/Scripts/XEntity/XExpedition/XExpeditionActivity.lua @@ -0,0 +1,274 @@ +--虚像地平线活动对象 +local XExpeditionActivity = XClass(nil, "XExpeditionActivity") +local XChapter = require("XEntity/XExpedition/XExpeditionChapter") +--================ +--构造函数 +--================ +function XExpeditionActivity:Ctor() + self:Init() +end +--================ +--初始化 +--================ +function XExpeditionActivity:Init() + self.CurrentChapterOrderId = 1 + self.RecruitLevel = 1 --招募等级 + self.RecruitTimes = 0 --剩余时间回复的可招募的次数 + self.NextRecruitAddTime = 0 --下一次自然恢复招募点时间 + self.ExtraDrawTimes = 0 --额外可招募的次数 + self.RecruitNum = 0 --已经招募过的次数 + self.ResetTime = 0 --重置时间 + self.DailyLikeCount = 0 --每天留言板可点赞次数,功能暂时已弃用 + self.Wave = 0 + self.ActivityCfg = XExpeditionConfig.GetExpeditionConfigById() --不填ID表示取默认最新 +end +--================ +--设置活动ID +--@param activityId:活动ID +--================ +function XExpeditionActivity:SetActivityId(activityId) + self.ActivityCfg = XExpeditionConfig.GetExpeditionConfigById(activityId) +end +--================ +--刷新活动参数 +--@param data:服务器通知的活动参数 +--================ +function XExpeditionActivity:RefreshActivity(data) + self.ResetTime = data.ResetTime + self.DailyLikeCount = data.DailyLikeCount + self:UpdateRecruitTimes(data) +end +--================ +--刷新招募相关参数 +--================ +function XExpeditionActivity:UpdateRecruitTimes(data, checkLevel) + self.RecruitTimes = data.CanRefreshTimes or 0 + self.NextRecruitAddTime = data.RefreshTimesRecoveryTime or 0 + self.BuyRecruitTime = data.BuyRefreshTimes or 0 + self.ExtraDrawTimes = data.ExtraRefreshTimes or 0 + self.RecruitNum = data.RefreshTimes or 0 + self.Wave = data.NpcGroup or self.Wave + local isRecruitLevelUp = false + if checkLevel then + isRecruitLevelUp = self.RecruitLevel < data.RecruitLevel + end + self.RecruitLevel = data.RecruitLevel or 0 + CsXGameEventManager.Instance:Notify(XEventId.EVENT_EXPEDITION_RECRUITTIME_REFRESH, isRecruitLevelUp) +end +--================ +--获取时间ID +--================ +function XExpeditionActivity:GetActivityTimeId() + return self.ActivityCfg and self.ActivityCfg.TimeId +end +--================ +--获取活动名称 +--================ +function XExpeditionActivity:GetActivityName() + return self.ActivityCfg and self.ActivityCfg.Name +end +--================ +--获取活动入口图片路径 +--================ +function XExpeditionActivity:GetBannerTexturePath() + return self.ActivityCfg and self.ActivityCfg.BannerTexturePath +end +--================ +--设置现在的章节Id并刷新 +--@param chapterId:现在的章节序号 +--================ +function XExpeditionActivity:SetChapterOrderId(chapterId) + self.CurrentChapterOrderId = chapterId + self:RefreshChapter() + XDataCenter.ExpeditionManager.GetTeam():InitTeamPos(chapterId or 1) +end +--================ +--获取现在的章节Id +--================ +function XExpeditionActivity:GetCurrentChapterId() + local chapterIds = self.ActivityCfg.ChapterIds + if not chapterIds then return end + if not chapterIds[self.CurrentChapterOrderId] then return chapterIds[1] end + return chapterIds[self.CurrentChapterOrderId] +end +--================ +--刷新章节 +--================ +function XExpeditionActivity:RefreshChapter() + if not self.Chapter then + self.Chapter = XChapter.New(self:GetCurrentChapterId()) + self.Chapter:SetNightMareWave(self.Wave) + else + self.Chapter:RefreshChapter(self:GetCurrentChapterId()) + self.Chapter:SetNightMareWave(self.Wave) + end +end +--================ +--获取章节对象 +--================ +function XExpeditionActivity:GetCurrentChapter() + return self.Chapter +end +--================ +--获取玩家螺母购买招募机会的购买次数 +--================ +function XExpeditionActivity:GetBuyRecruitTimes() + return self.BuyRecruitTime or 0 +end +--================ +--获取下次自然恢复时间点 +--================ +function XExpeditionActivity:GetNextRecruitAddTime() + return self.NextRecruitAddTime or 0 +end +--================ +--获取招募数量 +--================ +function XExpeditionActivity:GetRecruitNum() + return self.RecruitNum or 0 +end +--================ +--获取招募等级 +--================ +function XExpeditionActivity:GetRecruitLevel() + return self.RecruitLevel or 1 +end +--================ +--获取当前招募次数 +--================ +function XExpeditionActivity:GetRecruitTimes() + return self.RecruitTimes or 0 +end +--================ +--获取额外招募次数 +--================ +function XExpeditionActivity:GetExtraRecruitTimes() + return self.ExtraDrawTimes or 0 +end +--================ +--获取当前招募次数 +--================ +function XExpeditionActivity:GetTotalRecruitTimes() + return self:GetRecruitTimes() + self:GetExtraRecruitTimes() +end +--================ +--获取当前招募上限次数 +--================ +function XExpeditionActivity:GetRecruitMaxTime() + return self.ActivityCfg and self.ActivityCfg.RecruitMaxNum +end +--================ +--获取当前招募次数展示字符串 +--================ +function XExpeditionActivity:GetRecruitTimesStr() + return string.format("%d/%d", self:GetTotalRecruitTimes(), self:GetRecruitMaxTime()) +end +--================ +--获取本次活动一次招募的数量 +--================ +function XExpeditionActivity:GetRecruitDrawNum() + return self.ActivityCfg and self.ActivityCfg.RecruitDrawNum +end +--================ +--获取本次活动一次招募的数量 +--================ +function XExpeditionActivity:GetRecruitTimeFull() + return self:GetRecruitTimes() >= self:GetRecruitMaxTime() +end +--================ +--获取当前章节无尽关卡波数 +--================ +function XExpeditionActivity:GetWave() + return self:GetCurrentChapter():GetNightMareWave() +end +--================ +--设置当前章节无尽关卡波数 +--@param wave:波数 +--================ +function XExpeditionActivity:SetWave(wave) + self.Wave = wave + self:GetCurrentChapter():SetNightMareWave(wave) +end +--================ +--获取是否有招募次数 +--================ +function XExpeditionActivity:GetCanRecruit() + return self:GetTotalRecruitTimes() > 0 +end +--================ +--获取能不能螺母买抽卡 +--================ +function XExpeditionActivity:GetCanBuyDraw() + return self:GetBuyRecruitTimes() < XExpeditionConfig.GetBuyDrawMaxTime() +end +--================ +--获取重置时间 +--================ +function XExpeditionActivity:GetResetTime() + return self.ResetTime +end +--================ +--获取TimeId +--================ +function XExpeditionActivity:GetTimeId() + return self.ActivityCfg and self.ActivityCfg.TimeId +end +--================ +--获取每日点赞 +--================ +function XExpeditionActivity:GetDailyLikeMaxNum() + return self.ActivityCfg and self.ActivityCfg.DailyLikeMaxNum +end +--================ +--刷新排行榜数据 +--================ +function XExpeditionActivity:UpdateRankingData(rankingData) + self.SelfRank = rankingData.Ranking + self.TotalRankPlayers = rankingData.TotalCount + self.RankingList = rankingData.RankList +end +--================ +--刷新我的排行榜数据 +--================ +function XExpeditionActivity:UpdateMyRankingData(rankingData) + self.SelfRank = rankingData.Ranking + self.TotalRankPlayers = rankingData.TotalCount +end +--================ +--获取自身排行数 +--================ +function XExpeditionActivity:GetSelfRank() + return self.SelfRank or 0 +end +--================ +--获取排行榜总玩家数 +--================ +function XExpeditionActivity:GetTotalRankPlayers() + return self.TotalRankPlayers > 0 and self.TotalRankPlayers or 1 +end +--================ +--获取自己排行数字符串 +--================ +function XExpeditionActivity:GetSelfRankStr() + local selfR = self:GetSelfRank() + if selfR == 0 then return CS.XTextManager.GetText("ExpeditionNoRanking") end + if selfR ~= 0 and selfR <= 100 then return selfR end + local percent = selfR / self:GetTotalRankPlayers() + local result = math.ceil(percent * 100) + return string.format("%d%s", (result > 99 and 99 or result), "%") +end +--================ +--获取前百排行榜数据 +--================ +function XExpeditionActivity:GetRankingList() + return self.RankingList or {} +end +--================ +--获取排位图片 +--================ +function XExpeditionActivity:GetRankSpecialIcon(ranking) + if not self.ActivityCfg then return nil end + local maxNum = self.ActivityCfg.RankIcon and #self.ActivityCfg.RankIcon or 0 + return maxNum > 0 and self.ActivityCfg.RankIcon[ranking] or nil +end +return XExpeditionActivity \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XExpedition/XExpeditionChapter.lua b/Resources/Scripts/XEntity/XExpedition/XExpeditionChapter.lua new file mode 100644 index 00000000..fcf984a9 --- /dev/null +++ b/Resources/Scripts/XEntity/XExpedition/XExpeditionChapter.lua @@ -0,0 +1,251 @@ +-- 虚像地平线章节对象 +local XExpeditionChapter = XClass(nil, "XExpeditionChapter") +--================ +--构造函数 +--================ +function XExpeditionChapter:Ctor(chapterId) + self:Init(chapterId) +end +--================ +--初始化 +--================ +function XExpeditionChapter:Init(chapterId) + self.NormalStageLastPassIndex = 1 + self.NightMareStageLastPassIndex = 1 + self.NightMareWave = 0 + self:RefreshChapter(chapterId) +end +--================ +--刷新章节 +--================ +function XExpeditionChapter:RefreshChapter(chapterId) + self.ChapterId = chapterId + self.ChapterCfg = XExpeditionConfig.GetChapterCfgById(chapterId) + self:InitStage() + self.NormalStageLastPassIndex = 1 + self.NightMareStageLastPassIndex = 1 + self:RefreshNormalStage() + self:RefreshNightMareStage() +end +--================ +--初始化关卡数据 +--================ +function XExpeditionChapter:InitStage() + local eStageCfgs = XExpeditionConfig.GetEStageListByChapterId(self:GetChapterId()) + self.NormalStages = {} + self.NightMareStages = {} + self.AllStages = {} + for _, eStageCfg in pairs(eStageCfgs) do + local eStage = XDataCenter.ExpeditionManager.GetEStageByEStageId(eStageCfg.Id) + if eStage then + if eStage:GetIsNightMareStage() then + table.insert(self.NightMareStages, eStage) + else + table.insert(self.NormalStages, eStage) + end + end + end + self.TotalNormalStageNum = #self.NormalStages or 0 + self.TotalNightMareStageNum = #self.NightMareStages or 0 +end +--================ +--刷新普通关卡数据 +--================ +function XExpeditionChapter:RefreshNormalStage() + self.NormalAllClear = true + for index = self.NormalStageLastPassIndex > 0 and self.NormalStageLastPassIndex or 1, #self.NormalStages do + local eStage = self.NormalStages[index] + if index == 1 and (not eStage:GetIsPass()) then + self.NormalStageLastPassIndex = 0 + elseif eStage:GetIsPass() then + self.NormalStageLastPassIndex = index + else + self.NormalAllClear = false + end + end + -- 获取当前关卡进度 + self.CurrentNormalIndex = (self.NormalStageLastPassIndex < self.TotalNormalStageNum and (self.NormalStageLastPassIndex + 1)) or self.TotalNormalStageNum +end +--================ +--刷新噩梦关卡数据 +--================ +function XExpeditionChapter:RefreshNightMareStage() + self.NightMareAllClear = true + for index = self.NightMareStageLastPassIndex > 0 and self.NightMareStageLastPassIndex or 1, #self.NightMareStages do + local eStage = self.NightMareStages[index] + if index == 1 and (not eStage:GetIsPass()) then + self.NightMareStageLastPassIndex = 0 + elseif eStage:GetIsPass() then + self.NightMareStageLastPassIndex = index + else + self.NightMareAllClear = false + end + end + -- 获取当前关卡进度 + self.CurrentNightMareIndex = (self.NightMareStageLastPassIndex < self.TotalNightMareStageNum and (self.NightMareStageLastPassIndex + 1)) or self.TotalNightMareStageNum +end + +function XExpeditionChapter:GetStageCompletePercent(difficulty) + if difficulty == XDataCenter.ExpeditionManager.StageDifficulty.Normal then + return self.NormalStageLastPassIndex / self.TotalNormalStageNum + else + return self.NightMareStageLastPassIndex / self.TotalNightMareStageNum + end +end + +--================ +--获取章节进度字符串 +--================ +function XExpeditionChapter:GetStageCompleteStr(difficulty) + if difficulty == XDataCenter.ExpeditionManager.StageDifficulty.Normal then + return self:GetNormalStageCompleteStr() + else + return self:GetNightMareStageCompleteStr() + end +end +--================ +--获取普通关卡进度字符串 +--================ +function XExpeditionChapter:GetNormalStageCompleteStr() + return string.format("%d/%d", self.NormalStageLastPassIndex, self.TotalNormalStageNum) +end +--================ +--获取噩梦关卡进度字符串 +--================ +function XExpeditionChapter:GetNightMareStageCompleteStr() + return string.format("%d/%d", self.NightMareStageLastPassIndex, self.TotalNightMareStageNum) +end +--================ +--获取章节ID +--================ +function XExpeditionChapter:GetChapterId() + return self.ChapterId +end +--================ +--根据难度获取章节预制体 +--@param difficulty:难度 +--================ +function XExpeditionChapter:GetChapterPrefabByDifficulty(difficulty) + return self.ChapterCfg and self.ChapterCfg.PrefabPath and self.ChapterCfg.PrefabPath[difficulty] +end +--================ +--根据难度获取关卡背景图 +--@param difficulty:难度 +--================ +function XExpeditionChapter:GetStageBgByDifficult(difficulty) + return self.ChapterCfg and self.ChapterCfg.StageBgPath and self.ChapterCfg.StageBgPath[difficulty] +end +--================ +--根据难度获取关卡背景特效 +--@param difficulty:难度 +--================ +function XExpeditionChapter:GetChapterBgFxByDifficult(difficulty) + return self.ChapterCfg and self.ChapterCfg.BgFx and self.ChapterCfg.BgFx[difficulty] +end +--================ +--根据难度获取章节奖励图标地址 +--@param difficulty:难度 +--================ +function XExpeditionChapter:GetRewardIconByDifficult(difficulty) + return self.ChapterCfg and self.ChapterCfg.RewardIcon and self.ChapterCfg.RewardIcon[difficulty] +end +--================ +--根据难度获取关卡对象列表 +--================ +function XExpeditionChapter:GetStagesByDifficulty(difficulty) + if difficulty == XDataCenter.ExpeditionManager.StageDifficulty.Normal then + return self:GetNoramlEStages() + else + return self:GetNightMareEStages() + end +end +--================ +--获取普通关卡对象列表 +--================ +function XExpeditionChapter:GetNoramlEStages() + return self.NormalStages +end +--================ +--获取噩梦关卡对象列表 +--================ +function XExpeditionChapter:GetNightMareEStages() + return self.NightMareStages +end +--================ +--根据难度获取该难度关卡是否全部完成 +--================ +function XExpeditionChapter:GetIsClearByDifficulty(difficulty) + if difficulty == XDataCenter.ExpeditionManager.StageDifficulty.Normal then + return self:GetIsNormalClear() + else + return self:GetIsNightMareClear() + end +end +--================ +--获取普通关卡是否全部完成 +--================ +function XExpeditionChapter:GetIsNormalClear() + return self.NormalAllClear +end +--================ +--获取噩梦关卡是否全部完成 +--================ +function XExpeditionChapter:GetIsNightMareClear() + return self.NightMareAllClear +end +--================ +--根据难度获取当前关卡 +--================ +function XExpeditionChapter:GetCurrentIndexByDifficulty(difficulty) + if difficulty == XDataCenter.ExpeditionManager.StageDifficulty.Normal then + return self:GetNoramlCurrentIndex() + else + return self:GetNightMareCurrentIndex() + end +end +--================ +--获取当前章节通关的最后关卡 +--================ +function XExpeditionChapter:GetLastStage() + if self:GetIsNormalClear() then + if self.NightMareStageLastPassIndex == 0 then return self.NormalStages[self.NormalStageLastPassIndex] end + local lastIndex = self.NightMareStageLastPassIndex + return self.NightMareStages[lastIndex] + else + if self.NormalStageLastPassIndex == 0 then return nil end + return self.NormalStages[self.NormalStageLastPassIndex] + end +end +--================ +--获取普通关卡当前关卡 +--================ +function XExpeditionChapter:GetNoramlCurrentIndex() + return self.CurrentNormalIndex or 1 +end +--================ +--获取噩梦关卡当前关卡 +--================ +function XExpeditionChapter:GetNightMareCurrentIndex() + return self.CurrentNightMareIndex or 1 +end +--================ +--获取噩梦无尽关卡当前波数 +--================ +function XExpeditionChapter:GetNightMareWave() + return (self.NightMareWave and self.NightMareWave > 0 and (self.NightMareWave - 1)) or 0 +end +--================ +--设置噩梦无尽关卡当前波数 +--@param wave:波数 +--================ +function XExpeditionChapter:SetNightMareWave(wave) + self.NightMareWave = wave +end +--================ +--根据难度获取通关奖励ID +--@param difficulty:难度 +--================ +function XExpeditionChapter:GetChapterReward(difficulty) + return self.ChapterCfg and self.ChapterCfg.RewardId[difficulty] +end +return XExpeditionChapter \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XExpedition/XExpeditionCharacter.lua b/Resources/Scripts/XEntity/XExpedition/XExpeditionCharacter.lua new file mode 100644 index 00000000..92fa0fb9 --- /dev/null +++ b/Resources/Scripts/XEntity/XExpedition/XExpeditionCharacter.lua @@ -0,0 +1,228 @@ +-- 虚像地平线角色对象 +local XExpeditionCharacter = XClass(nil, "XExpeditionCharacter") +--================ +--构造函数 +--================ +function XExpeditionCharacter:Ctor(baseCharaId, startRank) + self:InitData(startRank, baseCharaId) +end +--================ +--初始化数据 +--================ +function XExpeditionCharacter:InitData(startRank, baseCharaId) + self:ResetData(startRank) + self:RefreshData(baseCharaId) +end +--================ +--使用玩法基础角色ID刷新角色数据 +--@param baseCharaId:虚像地平线基础角色ID +--================ +function XExpeditionCharacter:RefreshData(baseCharaId) + if not baseCharaId then return end + self.BaseECharaCfg = XExpeditionConfig.GetBaseCharacterCfgById(baseCharaId) + self.ECharaCfg = XExpeditionConfig.GetCharacterCfgByBaseIdAndRank(baseCharaId, self.Rank) + self.MaxRank = XExpeditionConfig.GetCharacterMaxRankByBaseId(baseCharaId) +end +--================ +--初始化角色数据 +--================ +function XExpeditionCharacter:ResetData(startRank) + self.Rank = startRank or 1 + self.Ability = nil + self.IsInTeam = false + self.Attrib = nil +end +--================ +--获取角色现在等级 +--================ +function XExpeditionCharacter:GetRank() + return self.Rank or 1 +end +--================ +--获取角色等级展示字符串 +--================ +function XExpeditionCharacter:GetRankStr() + local rank = self:GetRank() + if rank >= self.MaxRank then return CS.XTextManager.GetText("ExpeditionMaxRank") end + return rank +end +--================ +--获取角色能量列表 +--================ +function XExpeditionCharacter:GetCharacterElements() + return XExpeditionConfig.GetCharacterElementByBaseId(self:GetBaseId()) +end +--================ +--获取角色关联的羁绊列表 +--================ +function XExpeditionCharacter:GetCharacterComboIds() + return self.BaseECharaCfg and self.BaseECharaCfg.ReferenceComboId or {} +end +--================ +--获取预览羁绊列表 +--================ +function XExpeditionCharacter:GetPreviewCombos() + return XDataCenter.ExpeditionManager.GetComboList():GetPreviewCombosWhenRecruit() +end +--================ +--获取角色是否在队伍里 +--================ +function XExpeditionCharacter:GetIsInTeam() + return self.IsInTeam +end +--================ +--设置角色是否在队伍里 +--================ +function XExpeditionCharacter:SetIsInTeam(isInTeam) + self.IsInTeam = isInTeam +end +--================ +--设置角色等级 +--@param newRank:要设置的角色等级 +--================ +function XExpeditionCharacter:SetRank(newRank) + if (not newRank) or (newRank <= 0) then return end + if newRank > self.MaxRank then newRank = self.MaxRank end + self.Rank = newRank + self.ECharaCfg = XExpeditionConfig.GetCharacterCfgByBaseIdAndRank(self.BaseECharaCfg.Id, self:GetRank()) + self.Ability = nil + self.Attrib = nil +end +--================ +--角色升级 +--@param rankUpNum:升级数 +--================ +function XExpeditionCharacter:RankUp(rankUpNum) + self:SetRank(self:GetRank() + rankUpNum) +end +--================ +--获取角色机器人ID +--================ +function XExpeditionCharacter:GetRobotId() + return self.ECharaCfg and self.ECharaCfg.RobotId +end +--================ +--获取角色的游戏角色基础ID(非玩法角色Id,Character表) +--================ +function XExpeditionCharacter:GetCharacterId() + return self.BaseECharaCfg and self.BaseECharaCfg.CharacterId +end +--================ +--获取角色基础Id +--================ +function XExpeditionCharacter:GetBaseId() + return self.BaseECharaCfg and self.BaseECharaCfg.Id +end +--================ +--获取角色具体星级配置ID +--================ +function XExpeditionCharacter:GetECharaId() + return self.ECharaCfg and self.ECharaCfg.Id +end +--================ +--获取角色小头像 +--================ +function XExpeditionCharacter:GetSmallHeadIcon() + local fashionId = XCharacterConfigs.GetCharacterTemplate(self:GetCharacterId()).DefaultNpcFashtionId + return XDataCenter.FashionManager.GetFashionSmallHeadIcon(fashionId) +end +--================ +--获取角色大头像 +--================ +function XExpeditionCharacter:GetBigHeadIcon() + local fashionId = XCharacterConfigs.GetCharacterTemplate(self:GetCharacterId()).DefaultNpcFashtionId + return XDataCenter.FashionManager.GetFashionBigHeadIcon(fashionId) +end +--================ +--获取角色战力 +--================ +function XExpeditionCharacter:GetAbility() + if self.Ability then return self.Ability end + --这里的只计算机器人战力(含机器人装备) + self.Ability = XRobotManager.GetRobotAbility(self:GetRobotId()) + return self.Ability +end +--================ +--获取角色名称 +--================ +function XExpeditionCharacter:GetCharaName() + return XCharacterConfigs.GetCharacterName(self:GetCharacterId()) +end +--================ +--获取角色机型名称 +--================ +function XExpeditionCharacter:GetCharacterTradeName() + return XCharacterConfigs.GetCharacterTradeName(self:GetCharacterId()) +end + +function XExpeditionCharacter:GetCharaFullName() + return XCharacterConfigs.GetCharacterFullNameStr(self:GetCharacterId()) +end +--================ +--获取角色属性值 +--================ +function XExpeditionCharacter:GetCharaAttributes() + if not self.Attrib then self.Attrib = XRobotManager.GetRobotAttribs(self:GetRobotId()) end + return self.Attrib +end +--================ +--获取角色职业图标 +--================ +function XExpeditionCharacter:GetJobTypeIcon() + local jobType = XRobotManager.GetRobotJobType(self:GetRobotId()) + return XCharacterConfigs.GetNpcTypeIcon(jobType) +end +--================ +--获取角色可解锁技能列表 +--================ +function XExpeditionCharacter:GetLockSkill() + if (not self.BaseECharaCfg) or (not self.BaseECharaCfg.LockSkill) then + return {} + end + local skills = {} + for index, skillId in pairs(self.BaseECharaCfg.LockSkill) do + local skillInfo = XCharacterConfigs.GetSkillGradeDesConfig(skillId, self.BaseECharaCfg.SkillLevel[index]) + local skillData = { + IconPath = skillInfo.Icon, + Level = self.BaseECharaCfg.SkillLevel[index], + SkillInfo = skillInfo, + LockLevel = self.BaseECharaCfg.LockLevel[index], + IsLock = self:GetRank() < self.BaseECharaCfg.LockLevel[index] + } + table.insert(skills, skillData) + end + return skills +end +--================ +--获取角色是否已满级 +--================ +function XExpeditionCharacter:GetIsMaxLevel() + return self:GetRank() >= self.MaxRank +end +--================ +--获取角色是否状态被更新(用于招募后判断是否播放更新特效,一次性取值) +--================ +function XExpeditionCharacter:GetIsNew() + if self.IsNew then self.IsNew = false return true end + return false +end +--================ +--设置角色被更新状态 +--================ +function XExpeditionCharacter:SetIsNew() + self.IsNew = true +end +--================ +--获取是否空白角色对象 +--================ +function XExpeditionCharacter:GetIsBlank() + return not self.BaseECharaCfg +end +--================ +--获取角色基础Id +--================ +function XExpeditionCharacter:Fired() + self:ResetData() + self.ECharaCfg = XExpeditionConfig.GetCharacterCfgByBaseIdAndRank(self:GetBaseId(), self:GetRank()) +end +return XExpeditionCharacter \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XExpedition/XExpeditionCombo.lua b/Resources/Scripts/XEntity/XExpedition/XExpeditionCombo.lua new file mode 100644 index 00000000..6d564f5f --- /dev/null +++ b/Resources/Scripts/XEntity/XExpedition/XExpeditionCombo.lua @@ -0,0 +1,400 @@ +-- 虚像地平线组合对象 +local XExpeditionCombo = XClass(nil, "XExpeditionCombo") +local FunctionName = { + [1] = "MemberNum", -- 检查合计数量 + [2] = "TotalRank", -- 检查合计等级 + [3] = "TargetRank", -- 高于指定等级 +} + +local SortByIdFunc = function(a, b) + return a.Id < b.Id +end + +local SortByBaseIdFunc = function(a, b) + return a.EChara:GetBaseId() <= b.EChara:GetBaseId() +end + +local SortByLevelFunc = function(a, b) + return a.EChara:GetRank() < b.EChara:GetRank() +end + +local SortByLevelAndBaseIdFunc = function(a, b) + if a.IsBlank then return false end + if b.IsBlank then return true end + if not a.IsActive and b.IsActive then return false end + if not b.IsActive and a.IsActive then return true end + local rankA = a.EChara:GetRank() + local rankB = b.EChara:GetRank() + if rankA ~= rankB then + return rankA < rankB + else + return a.EChara:GetBaseId() < b.EChara:GetBaseId() + end +end + +local SortByBaseIdAndActiveFunc = function(a, b) + if not a.IsActive and b.IsActive then return true end + return a.EChara:GetBaseId() < b.EChara:GetBaseId() +end +--================ +--构造函数 +--================ +function XExpeditionCombo:Ctor(comboCfg, team) + self.Team = team + self:InitCombo(comboCfg) + self.Phase = 1 + self.IsActive = false +end +--================ +--初始化羁绊 +--================ +function XExpeditionCombo:InitCombo(comboCfg) + self.ComboCfg = comboCfg + local phaseCombo = XExpeditionConfig.GetComboByChildComboId(comboCfg.Id) + self.PhaseCombo = {} + for _, phaseCfg in pairs(phaseCombo) do + table.insert(self.PhaseCombo, phaseCfg) + end + table.sort(self.PhaseCombo, SortByIdFunc) + self.PhaseNum = #self.PhaseCombo + self.CheckList = {} + self.CheckListLength = 0 +end +--================ +--获取羁绊Id +--================ +function XExpeditionCombo:GetComboId() + return self.ComboCfg and self.ComboCfg.Id +end +--================ +--获取羁绊名称 +--================ +function XExpeditionCombo:GetName() + return self.ComboCfg and self.ComboCfg.Name or "UnNamed" +end +--================ +--获取羁绊有效层数 +--================ +function XExpeditionCombo:GetPhase() + return self.Phase +end +--================ +--获取羁绊阶段详细 +--================ +function XExpeditionCombo:GetPhaseCombo() + return self.PhaseCombo +end +--================ +--获取预览羁绊是否提升 +--================ +function XExpeditionCombo:GetPreviewUp() + return ((not self:GetComboActive()) and self:GetPreviewActive()) or (self.PreviewPhase > self:GetPhase()) +end +--================ +--获取预览羁绊是否有效 +--================ +function XExpeditionCombo:GetPreviewActive() + return self.PreviewActive +end +--================ +--获取羁绊是否有效 +--================ +function XExpeditionCombo:GetComboActive() + return self.IsActive +end +--================ +--获取羁绊总层数 +--================ +function XExpeditionCombo:GetPhaseNum() + return self.PhaseNum +end +--================ +--获取羁绊分类 +--================ +function XExpeditionCombo:GetComboTypeId() + return self.ComboCfg and self.ComboCfg.ComboTypeId or 1 +end +--================ +--获取羁绊现层数展示字符串(格式例子:"1/4") +--================ +function XExpeditionCombo:GetCurrentPhaseStr() + return string.format("%d/%d", self:GetComboActive() and self:GetPhase() or 0, self:GetPhaseNum()) +end +--================ +--获取羁绊图标路径 +--================ +function XExpeditionCombo:GetIconPath() + return self.ComboCfg and self.ComboCfg.IconPath +end +--================ +--获取组合需求条件数量 +--================ +function XExpeditionCombo:GetConditionCharaNum() + return self:GetConditionNum(self:GetPhase()) +end +--================ +--获取达成的条件数 +--================ +function XExpeditionCombo:GetReachConditionNum() + return self.ReachConditionNum +end +--================ +--根据阶段获取组合的要求人数 +--@param phaseIndex:阶段 +--================ +function XExpeditionCombo:GetConditionNum(phaseIndex) + if not self.PhaseCombo[phaseIndex] then return 0 end + return self.PhaseCombo[phaseIndex].ConditionNum +end +--================ +--根据阶段获取组合的要求等级 +--@param phaseIndex:阶段 +--================ +function XExpeditionCombo:GetConditionLevel(phaseIndex) + if not self.PhaseCombo[phaseIndex] then return 0 end + return self.PhaseCombo[phaseIndex].ConditionLevel +end +--================ +--根据阶段获取阶段效果描述 +--@param phaseIndex:阶段 +--================ +function XExpeditionCombo:GetPhaseComboEffectDes(phaseIndex) + local des = self.PhaseCombo[phaseIndex] and self.PhaseCombo[phaseIndex].EffectDescription or "" + des = string.gsub(des, "\\n", "\n") + return des +end +--================ +--根据阶段获取阶段条件描述 +--@param phaseIndex:阶段 +--================ +function XExpeditionCombo:GetPhaseComboConditionDes(phaseIndex) + return self.PhaseCombo[phaseIndex] and self.PhaseCombo[phaseIndex].ConditionDesc or "" +end +--================ +--设置固有成员列表(暂仅对条件3类型) +--@param eBaseId:玩法基础角色ID +--================ +function XExpeditionCombo:SetDefaultReferenceCharaList(eBaseId) + if not self.DefaultReferenceList then self.DefaultReferenceList = {} end + if not self.DefaultReferenceList[eBaseId] then self.DefaultReferenceList[eBaseId] = true end +end +--================ +--获取固有成员列表(暂仅对条件3类型) +--================ +function XExpeditionCombo:GetDefaultReferenceCharaList() + if not self.DefaultReferenceList then return nil end + self.DefaultReferenceECharList = {} + local XChara = require("XEntity/XExpedition/XExpeditionCharacter") + for charaId, _ in pairs(self.DefaultReferenceList) do + local eChara = self.Team and self.Team:GetCharaByEBaseId(charaId) + local displayData = { + EChara = eChara or XChara.New(charaId), + IsActive = eChara ~= nil, + IsBlank = false + } + table.insert(self.DefaultReferenceECharList, displayData) + end + table.sort(self.DefaultReferenceECharList, SortByBaseIdAndActiveFunc) + return self.DefaultReferenceECharList +end +--================ +--新增关联成员 +--@param eChara:新增成员 +--================ +function XExpeditionCombo:AddCheckList(eChara) + if not self.CheckList[eChara:GetBaseId()] then + self.CheckListLength = self.CheckListLength + 1 + end + self.CheckList[eChara:GetBaseId()] = eChara +end +--================ +--清空关联成员 +--================ +function XExpeditionCombo:ResetCheckList() + self.CheckList = {} + self.CheckListLength = 0 + self.IsActive = false + self.Phase = 1 + self.ReachConditionNum = 0 +end +--================ +--检查组合状态 +--================ +function XExpeditionCombo:Check() + self.Phase, self.ReachConditionNum, self.IsActive = self:CheckActiveStatus() +end +--================ +--预览组合有效状态,返回状态结果 +--@param eChara:玩法角色 +--================ +function XExpeditionCombo:PreviewCheckNew(eChara) + local preList = XTool.Clone(self.CheckList) + if preList[eChara:GetBaseId()] then + preList[eChara:GetBaseId()]:RankUp(eChara:GetRank()) + else + preList[eChara:GetBaseId()] = eChara + end + local phase, num, result = self:CheckActiveStatus(preList) + self.PrePhaseUp = phase > self:GetPhase() -- 是否升级 + self.PreActive = result -- 是否激活 +end +--================ +--获取预览组合是否升级 +--================ +function XExpeditionCombo:GetPrePhaseUp() + return self.PrePhaseUp +end +--================ +--获取预览组合的激活状态 +--================ +function XExpeditionCombo:GetPreActive() + return self.PreActive +end +--================ +--获取预览组合是否变成激活 +--================ +function XExpeditionCombo:GetIsWillActive() + return (not self:GetComboActive()) and self:GetPreActive() +end +--================ +--检查组合有效状态,返回状态结果 +--@return phase:有效层数 +--@return activeReferenceNum:达到下一层有效的关联角色数 +--================ +function XExpeditionCombo:CheckActiveStatus(tempList) + local phase = 1 + local reachConditionNum = 0 + local isActive = false + local conditionPass + for index = 1, self:GetPhaseNum() do + local functionName = FunctionName[self.ComboCfg.Condition] + conditionPass, reachConditionNum = self["Condition" .. functionName](self, index, tempList) + if conditionPass then + isActive = true + phase = index + else + break + end + end + return phase, reachConditionNum, isActive +end +--================ +--检查列表角色的个数 +--@param index:层数 +--@param tempList:临时检查列表,省略则表示检查玩家现有队伍 +--================ +function XExpeditionCombo:ConditionMemberNum(index, tempList) + local checkList = tempList or self.CheckList + local targetNum = 0 + return self.CheckListLength >= self:GetConditionNum(), self.CheckListLength +end +--================ +--检查列表角色的总等级 +--@param index:层数 +--@param tempList:临时检查列表,省略则表示检查玩家现有队伍 +--================ +function XExpeditionCombo:ConditionTotalRank(index, tempList) + local checkList = tempList or self.CheckList + local totalRank = 0 + for _, eChara in pairs(checkList) do + totalRank = totalRank + eChara:GetRank() + end + return totalRank >= self:GetConditionLevel(index), self.CheckListLength +end +--================ +--检查列表角色各自的级数 +--@param index:层数 +--@param tempList:临时检查列表,省略则表示检查玩家现有队伍 +--================ +function XExpeditionCombo:ConditionTargetRank(index, tempList) + local checkList = tempList or self.CheckList + local count = 0 + for _, eChara in pairs(checkList) do + if eChara:GetRank() >= self:GetConditionLevel(index) then + count = count + 1 + end + end + return count >= self:GetConditionNum(index), count +end +--================ +--获取成员展示界面 +--================ +function XExpeditionCombo:GetDisplayReferenceList() + if self.DefaultReferenceList then return self:GetDefaultReferenceCharaList() end + local functionName = FunctionName[self.ComboCfg.Condition] + local list = self["DisplayReference" .. functionName](self, self:GetPhase()) + return list +end +--================ +--获取成员组合页面成员展示列表 +--================ +function XExpeditionCombo:DisplayReferenceMemberNum() + local tempList = {} + local count = 0 + for _, v in pairs(self.CheckList) do + if count > self:GetConditionNum(self:GetPhase()) then break end + local displayData = { + EChara = v, + IsActive = true, + IsBlank = false + } + table.insert(tempList, displayData) + count = count + 1 + end + table.sort(tempList, SortByBaseIdFunc) + return tempList +end +--================ +--获取成员展示界面 +--================ +function XExpeditionCombo:DisplayReferenceTotalRank() + local tempList = {} + local tempRank = 0 + local targetRank = self:GetConditionLevel(self:GetPhase()) + for _, v in pairs(self.CheckList) do + tempRank = tempRank + v:GetRank() + local displayData = { + EChara = v, + IsActive = true, + IsBlank = false + } + table.insert(tempList, displayData) + if tempRank >= targetRank then break end + end + table.sort(tempList, SortByLevelFunc) + return tempList +end +--================ +--获取成员展示界面 +--================ +function XExpeditionCombo:DisplayReferenceTargetRank() + local tempList = {} + local targetRank = self:GetConditionLevel(self:GetPhase()) + for _, v in pairs(self.CheckList) do + if v:GetRank() >= targetRank then + local displayData = { + EChara = v, + IsActive = true, + IsBlank = false + } + table.insert(tempList, displayData) + else + local displayData = { + EChara = v, + IsActive = false, + IsBlank = false + } + table.insert(tempList, displayData) + end + end + for i = #tempList + 1, self:GetConditionCharaNum() do + local displayData = { + IsActive = false, + IsBlank = true + } + table.insert(tempList, displayData) + end + table.sort(tempList, SortByLevelAndBaseIdFunc) + return tempList +end +return XExpeditionCombo \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XExpedition/XExpeditionComboList.lua b/Resources/Scripts/XEntity/XExpedition/XExpeditionComboList.lua new file mode 100644 index 00000000..e901d733 --- /dev/null +++ b/Resources/Scripts/XEntity/XExpedition/XExpeditionComboList.lua @@ -0,0 +1,128 @@ +-- 虚像地平线组合对象列表 +local XExpeditionComboList = XClass(nil, "XExpeditionComboList") +local XCombo = require("XEntity/XExpedition/XExpeditionCombo") +local COMBOTYPE_TACTICS = 1 -- 战术连携 +--================ +--构造函数 +--================ +function XExpeditionComboList:Ctor(team) + self.Team = team + self:InitCombos() +end +--================ +--初始化羁绊 +--================ +function XExpeditionComboList:InitCombos() + self.Combos = {} + local childComboList = XExpeditionConfig.GetChildComboTable() + for id, combo in pairs(childComboList) do + self.Combos[id] = XCombo.New(combo, self.Team) + end + self:InitComboReferences() +end +--================ +--初始化所有羁绊的固定关联人员列表 +--================ +function XExpeditionComboList:InitComboReferences() + local allCharas = XExpeditionConfig.GetBaseCharacterCfg() + for eBaseId, eBaseCharaCfg in pairs(allCharas) do + for _, comboId in pairs(eBaseCharaCfg.ReferenceComboId) do + if self.Combos[comboId] and self.Combos[comboId]:GetComboTypeId() == COMBOTYPE_TACTICS then + self.Combos[comboId]:SetDefaultReferenceCharaList(eBaseId) + end + end + end +end +--================ +--获取所有羁绊对象列表(包括没激活的) +--================ +function XExpeditionComboList:GetAllCombos() + return self.Combos +end +--================ +--获取指定Id的组合对象 +--@param comboId:组合ID +--================ +function XExpeditionComboList:GetComboByComboId(comboId) + if not self.Combos[comboId] then + return nil + end + return self.Combos[comboId] +end +--================ +--检查队伍羁绊列表 +--@param team:队伍 +--================ +function XExpeditionComboList:CheckCombos(team) + if not team then return end + local tempIds = {} + self:ResetComboCheckList() + self.CurrentCombos = {} + for _, teamChara in pairs(team) do + local comboIds = teamChara:GetCharacterComboIds() + for _, comboId in pairs(comboIds) do + local combo = self:GetComboByComboId(comboId) + if not tempIds[comboId] then + tempIds[comboId] = true + table.insert(self.CurrentCombos, combo) + end + combo:AddCheckList(teamChara) + end + end + self:CheckActiveStatus() +end +--================ +--获取所有现在关联的羁绊列表(包括没激活的) +--================ +function XExpeditionComboList:GetCurrentCombos(team) + self:CheckCombos(team) + return self.CurrentCombos +end +--================ +--重置当前组合状态列表的所有组合检查列表 +--================ +function XExpeditionComboList:ResetComboCheckList() + if not self.CurrentCombos then return end + for _, combo in pairs(self.Combos) do + combo:ResetCheckList() + end +end +--================ +--刷新当前组合状态列表的所有组合状态 +--================ +function XExpeditionComboList:CheckActiveStatus() + for _, combo in pairs(self.CurrentCombos) do + combo:Check() + end +end +--================ +--获取角色有效的羁绊ID列表 +--================ +function XExpeditionComboList:GetActiveComboIdsByEChara(eChara) + local previewList = {} + + local comboIds = eChara:GetCharacterComboIds() + for _, comboId in pairs(comboIds) do + local combo = self:GetComboByComboId(comboId) + --if combo:GetComboActive() then + table.insert(previewList, comboId) + --end + end + return previewList +end +--================ +--返回招募时的预览羁绊ID列表 +--================ +function XExpeditionComboList:GetPreviewCombosWhenRecruit(eChara) + local previewList = {} + local comboIds = eChara:GetCharacterComboIds() + for _, comboId in pairs(comboIds) do + local combo = self:GetComboByComboId(comboId) + combo:PreviewCheckNew(eChara) + --if combo:GetPreActive() then + table.insert(previewList, comboId) + --end + end + return previewList +end +return XExpeditionComboList \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XExpedition/XExpeditionRecruitMembers.lua b/Resources/Scripts/XEntity/XExpedition/XExpeditionRecruitMembers.lua new file mode 100644 index 00000000..d48e70d8 --- /dev/null +++ b/Resources/Scripts/XEntity/XExpedition/XExpeditionRecruitMembers.lua @@ -0,0 +1,72 @@ +-- 虚像地平线招募商店成员对象 +local XExpeditionRecruitMembers = XClass(nil, "XExpeditionRecruitMembers") +local XChara = require("XEntity/XExpedition/XExpeditionCharacter") +--=================== +--构造函数 +--@param drawNum: 一次招募的数量 +--=================== +function XExpeditionRecruitMembers:Ctor(drawNum) + self.DrawNum = drawNum + self:InitMembers() + self:Reset() +end +--=================== +--重置状态 +--=================== +function XExpeditionRecruitMembers:Reset() + self.IsPicked = false + self.RecruitPos = -1 + self.IsBlank = true +end +--=================== +--初始化招募角色列表 +--=================== +function XExpeditionRecruitMembers:InitMembers() + self.Members = {} + for i = 1, self.DrawNum do + self.Members[i] = XChara.New() + end +end +--=================== +--初始化招募角色列表 +--=================== +function XExpeditionRecruitMembers:GetIsPicked() + return self.IsPicked +end +--=================== +--初始化招募角色列表 +--=================== +function XExpeditionRecruitMembers:SetIsPicked(isPicked) + self.IsPicked = isPicked +end +--=================== +--获取被招募角色的位置 +--=================== +function XExpeditionRecruitMembers:GetRecruitPos() + return self.RecruitPos +end +--=================== +--设置角色是否被招募 +--=================== +function XExpeditionRecruitMembers:SetRecruitPos(pos) + self.RecruitPos = pos + self:SetIsPicked(true) +end + +function XExpeditionRecruitMembers:GetIsBlank() + return self.IsBlank +end + +function XExpeditionRecruitMembers:GetCharaByPos(pos) + return self.Members[pos] +end +--=================== +--重置招募角色 +--=================== +function XExpeditionRecruitMembers:ResetCharaData(pos, eCharaId) + local member = self:GetCharaByPos(pos) + local eCharaCfg = XExpeditionConfig.GetCharacterCfgById(eCharaId) + member:ResetData(eCharaCfg.Rank) + member:RefreshData(eCharaCfg.BaseId) +end +return XExpeditionRecruitMembers \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XExpedition/XExpeditionStage.lua b/Resources/Scripts/XEntity/XExpedition/XExpeditionStage.lua new file mode 100644 index 00000000..8cc1e21e --- /dev/null +++ b/Resources/Scripts/XEntity/XExpedition/XExpeditionStage.lua @@ -0,0 +1,254 @@ +-- 虚像地平线关卡对象 +local XExpeditionStage = XClass(nil, "XExpeditionStage") + +local StageType = { + Story = 1, + Battle = 2, + Infinity = 3 + } +--================ +--构造函数 +--@param eStageId:虚像地平线关卡ID +--================ +function XExpeditionStage:Ctor(eStageId) + self:Init(eStageId) +end +--================ +--定义StageInfo +--@param eStageId:虚像地平线关卡ID +--================ +local InitStageInfo = function(stageInfo) + stageInfo.Type = XDataCenter.FubenManager.StageType.Expedition +end +--================ +--初始化 +--@param eStageId:虚像地平线关卡ID +--================ +function XExpeditionStage:Init(eStageId) + self.EStageCfg = XExpeditionConfig.GetEStageCfg(eStageId) + self.StageCfg = XDataCenter.FubenManager.GetStageCfg(self.EStageCfg.StageId) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(self.EStageCfg.StageId) + InitStageInfo(stageInfo) +end +--================ +--获取关卡基础配置 +--================ +function XExpeditionStage:GetStageCfg() + return self.StageCfg +end +--================ +--获取关卡Id +--================ +function XExpeditionStage:GetStageId() + return self.EStageCfg and self.EStageCfg.StageId +end +--================ +--获取关卡类型 +--================ +function XExpeditionStage:GetStageType() + return self.EStageCfg and self.EStageCfg.StageType or 1 +end +--================ +--获取是否无尽关卡 +--================ +function XExpeditionStage:GetIsInfinity() + return self:GetStageType() == StageType.Infinity +end +--================ +--获取故事ID +--================ +function XExpeditionStage:GetBeginStoryId() + return self.StageCfg and self.StageCfg.BeginStoryId +end +--================ +--获取关卡序号 +--================ +function XExpeditionStage:GetOrderId() + return self.EStageCfg and self.EStageCfg.OrderId or 1 +end +--================ +--获取关卡奖励招募次数 +--================ +function XExpeditionStage:GetDrawTimesReward() + return self.EStageCfg and self.EStageCfg.DrawTimesReward or 0 +end +--================ +--获取关卡奖励招募次数字符串 +--================ +function XExpeditionStage:GetDrawTimesRewardStr() + local str = "" + if not self:GetIsPass() then + str = CS.XTextManager.GetText("ExpeditionRecruitTimes", self:GetDrawTimesReward()) + end + return str +end +--================ +--获取关卡首通奖励ID +--================ +function XExpeditionStage:GetFirstRewardId() + return self.StageCfg and self.StageCfg.FirstRewardId +end +--================ +--获取关卡预制体地址 +--================ +function XExpeditionStage:GetPrefabPath() + return self.EStageCfg and self.EStageCfg.StagePrefabPath or "" +end +--================ +--获取关卡是否通过 +--================ +function XExpeditionStage:GetIsPass() + local stageId = self:GetStageId() + if not stageId then return false end + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + return stageInfo and stageInfo.Passed +end +--================ +--获取关卡是否解锁 +--================ +function XExpeditionStage:GetIsUnlock() + local stageId = self:GetStageId() + if not stageId then return false end + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + return stageInfo and stageInfo.Unlock +end +--================ +--获取关卡难度 +--================ +function XExpeditionStage:GetDifficulty() + return self.EStageCfg and self.EStageCfg.Difficulty +end +--================ +--获取是否噩梦关卡 +--================ +function XExpeditionStage:GetIsNightMareStage() + if self.IsNightMare ~= nil then return self.IsNightMare end + local difficulty = self:GetDifficulty() + self.IsNightMare = difficulty == XDataCenter.ExpeditionManager.StageDifficulty.NightMare + return self.IsNightMare +end +--================ +--获取关卡名称 +--================ +function XExpeditionStage:GetStageName() + return self.EStageCfg and self.StageCfg.Name +end +--================ +--获取关卡封面(BOSS关卡使用) +--================ +function XExpeditionStage:GetStageCover() + return self.EStageCfg and self.EStageCfg.BossStageCover +end +--================ +--获取关卡描述 +--================ +function XExpeditionStage:GetStageDes() + return self.StageCfg and self.StageCfg.Description +end +--================ +--获取关卡星数描述 +--================ +function XExpeditionStage:GetStageTargetDesc() + return self.StageCfg and self.StageCfg.StarDesc +end +--================ +--获取关卡词缀ID +--================ +function XExpeditionStage:GetStageWords() + return self.EStageCfg and self.EStageCfg.StageWords +end +--================ +--获取关卡词缀配置 +--================ +function XExpeditionStage:GetStageEvents() + local events = {} + local stageFightEvent = self:GetStageWords() + if stageFightEvent then + for i = 1, #stageFightEvent do + events[i] = XFubenConfigs.GetStageFightEventDetailsByStageFightEventId(stageFightEvent[i]) + end + end + return events or {} +end +--================ +--获取关卡推荐等级 +--================ +function XExpeditionStage:GetRecommentStar() + return self.EStageCfg and self.EStageCfg.RecommentStar +end +--================ +--获取困难警告差值 +--================ +function XExpeditionStage:GetWarningCap() + return self.EStageCfg and self.EStageCfg.WarningStarCap +end +--================ +--获取危险警告差值 +--================ +function XExpeditionStage:GetDangerCap() + return self.EStageCfg and self.EStageCfg.DangerStarCap +end +--================ +--获取关卡警告等级(根据全队队员星级) +--================ +function XExpeditionStage:GetStageIsDanger() + local recommentStar = self:GetRecommentStar() + if not recommentStar then return XDataCenter.ExpeditionManager.StageWarning.NoWarning end + local average = XDataCenter.ExpeditionManager.GetTeamAverageStar() + local levelCap = self:GetRecommentStar() - average + if levelCap < self:GetWarningCap() then + return XDataCenter.ExpeditionManager.StageWarning.NoWarning + elseif levelCap >= self:GetWarningCap() and levelCap < self:GetDangerCap() then + return XDataCenter.ExpeditionManager.StageWarning.Warning + else + return XDataCenter.ExpeditionManager.StageWarning.Danger + end +end +--================ +--获取出战界面警告等级(随出战队伍变化而变化) +--================ +function XExpeditionStage:GetStageIsDangerByBattleTeam(curTeam) + local teamData = curTeam or XDataCenter.ExpeditionManager.GetExpeditionTeam() + local totalStar = 0 + local memberNum = 0 + for _, eBaseId in pairs(teamData.TeamData) do + if eBaseId > 0 then + local eChara = XDataCenter.ExpeditionManager.GetTeam():GetCharaByEBaseId(eBaseId) + if eChara then + memberNum = memberNum + 1 + totalStar = totalStar + eChara:GetRank() + end + end + end + if memberNum == 0 then return XDataCenter.ExpeditionManager.StageWarning.Danger end + local average = math.floor(totalStar / memberNum) + local levelCap = self:GetRecommentStar() - average + if levelCap < self:GetWarningCap() then + return XDataCenter.ExpeditionManager.StageWarning.NoWarning + elseif levelCap < self:GetDangerCap() and levelCap >= self:GetWarningCap() then + return XDataCenter.ExpeditionManager.StageWarning.Warning + else + return XDataCenter.ExpeditionManager.StageWarning.Danger + end +end +--================ +--设置关卡通关(应用于剧情关) +--================ +function XExpeditionStage:SetPass() + local stageId = self:GetStageId() + if not stageId then return end + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + stageInfo.Passed = true +end +--================ +--重置关卡通过状态 +--================ +function XExpeditionStage:Reset() + local stageId = self:GetStageId() + if not stageId then return end + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + if not stageInfo then return end + if self:GetOrderId() ~= 1 then stageInfo.Unlock = false end + stageInfo.Passed = false +end +return XExpeditionStage \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XExpedition/XExpeditionTeam.lua b/Resources/Scripts/XEntity/XExpedition/XExpeditionTeam.lua new file mode 100644 index 00000000..15da73a1 --- /dev/null +++ b/Resources/Scripts/XEntity/XExpedition/XExpeditionTeam.lua @@ -0,0 +1,372 @@ +-- 虚像地平线队伍对象 +local XExpeditionTeam = XClass(nil, "XExpeditionTeam") +local XTeamPos = require("XEntity/XExpedition/XExpeditionTeamPos") +local XComboList = require("XEntity/XExpedition/XExpeditionComboList") +local XEChara = require("XEntity/XExpedition/XExpeditionCharacter") +--================ +--加入队员失败 +--================ +local AddMemberFailed = function() + XLog.Debug("加入成员失败!") +end +--================ +--展示队伍排序 +--================ +local SortDisplayTeamFunc = function(a, b) + return a:GetBaseId() > b:GetBaseId() +end +--================ +--按大小排序,大的往前 +--================ +local SortByBigger = function(a, b) + return a > b +end +--================ +--展示组合排序 +--================ +local SortByComboId = function(a, b) + return a:GetComboId() > b:GetComboId() +end +--================ +--展示组合排序 +--================ +local SortDisplayComboFunc = function(a, b) + if a:GetComboActive() and not b:GetComboActive() then return true end + if not a:GetComboActive() and b:GetComboActive() then return false end + return a:GetComboId() > b:GetComboId() +end +--================ +--当队员变化时 +--@param isPlayEffect:是否播放特效 +--================ +local OnMemberChange = function(isPlayEffect) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_EXPEDITION_MEMBERLIST_CHANGE, isPlayEffect) +end +--================ +--构造函数 +--================ +function XExpeditionTeam:Ctor() + self:InitBaseMembers() + self:InitTeamChara() + self:InitComboList() +end +--================ +--初始化所有基础成员 +--================ +function XExpeditionTeam:InitBaseMembers() + local allMembers = XExpeditionConfig.GetBaseCharacterCfg() + self.BaseMembers = {} + for eBaseId, member in pairs(allMembers) do + self.BaseMembers[eBaseId] = XEChara.New(eBaseId) + end +end +--================ +--初始化队伍位置 +--@param chapterId:当前章节ID +--================ +function XExpeditionTeam:InitTeamPos(chapterId) + self.TeamPos = {} + local posList = XExpeditionConfig.GetTeamPosListByChapterId(chapterId) + for _, posCfg in pairs(posList) do + table.insert(self.TeamPos, XTeamPos.New(posCfg.Id)) + end +end +--================ +--初始化队伍角色 +--================ +function XExpeditionTeam:InitTeamChara() + self.TeamChara = {} +end +--================ +--初始化队伍角色 +--================ +function XExpeditionTeam:InitComboList() + self.ComboList = XComboList.New(self) +end +--================ +--重置队伍 +--================ +function XExpeditionTeam:Reset() + self.TeamChara = {} + for _, chara in pairs(self.BaseMembers) do + chara:Fired() + end + self:ResetDisplayTeam() +end +--================ +--使用角色对象检查角色是否在队伍中 +--@param eChara:玩法角色对象 +--================ +function XExpeditionTeam:CheckInTeamByEChara(eChara) + return eChara:GetIsInTeam() +end +--================ +--使用玩法角色ID检查角色是否在队伍中 +--@param eBaseId:玩法角色基础Id +--================ +function XExpeditionTeam:CheckInTeamByEBaseId(eBaseId) + local eChara = self.BaseMembers[eBaseId] + return eChara:GetIsInTeam() +end +--================ +--检查有没空格子 +--================ +function XExpeditionTeam:CheckHaveNewPos() + local unLockPosNum = 0 + for _, pos in pairs(self.TeamPos) do + if pos:GetIsUnLock() then + unLockPosNum = unLockPosNum + 1 + end + end + return unLockPosNum > self:GetTeamNum() +end +--================ +--使用ECharaId列表批量加入成员并更新 +--@param eCharaIds:ECharacterId列表 +--================ +function XExpeditionTeam:AddMemberListByECharaIds(eCharaIds) + if not eCharaIds then return end + for _, eCharaId in pairs(eCharaIds) do + if eCharaId > 0 then + local eCharaCfg = XExpeditionConfig.GetCharacterCfgById(eCharaId) + self:AddMemberByEBaseIdAndRank(eCharaCfg.BaseId, eCharaCfg.Rank, false) + end + end + self.ComboList:CheckCombos(self.TeamChara) + self:ResetDisplayTeam() +end +--================ +--用玩法角色ID和初始等级把角色加入队伍 +--@param eBaseId:加入队伍的玩法角色ID +--@param rank:初始等级 +--================ +function XExpeditionTeam:AddMemberByEBaseIdAndRank(eBaseId, rank, needCheck) + local canAdd, isExist = self:GetCanAddMember(eBaseId) + if not canAdd then AddMemberFailed() return end + if isExist then + self.TeamChara[eBaseId]:RankUp(rank) + else + local eChara = self.BaseMembers[eBaseId] + self.TeamChara[eBaseId] = eChara + eChara:SetRank(rank) + eChara:SetIsInTeam(true) + end + if needCheck then + self.ComboList:CheckCombos(self.TeamChara) + self:ResetDisplayTeam() + end +end +--================ +--用EChara对象把角色加入队伍(用于招募角色时) +--@param eChara:加入队伍的角色对象 +--================ +function XExpeditionTeam:AddMemberByEChara(eChara) + if not eChara then return end + local eBaseId = eChara:GetBaseId() + self:AddMemberByEBaseIdAndRank(eBaseId, eChara:GetRank(), true) + self.TeamChara[eBaseId]:GetIsNew() + self.ComboList:CheckCombos(self.TeamChara) + self:OnTeamMemberChange() +end +--================ +--检查能不能加入新成员 +--@param eBaseId:要加入队伍的玩法角色ID +--================ +function XExpeditionTeam:GetCanAddMember(eBaseId) + if self.TeamChara[eBaseId] then + return not self.TeamChara[eBaseId]:GetIsMaxLevel(), true + else + return self:CheckHaveNewPos(), false + end +end +--================ +--从队伍移除角色 +--@param pos:要移除的角色位置 +--================ +function XExpeditionTeam:RemoveMember(eBaseId) + if (not eBaseId) or (not self.TeamChara[eBaseId]) then return end + self.TeamChara[eBaseId]:Fired() + self.TeamChara[eBaseId] = nil + self:OnTeamMemberChange() +end + +--================ +--获取队伍位置 +--================ +function XExpeditionTeam:GetTeamPos() + return self.TeamPos +end +--================ +--获取队伍队员对象列表 +--================ +function XExpeditionTeam:GetTeam() + return self.TeamChara +end +--================ +--获取队伍队员数量 +--================ +function XExpeditionTeam:GetTeamNum() + local count = 0 + for i in pairs(self:GetTeam()) do + count = count + 1 + end + return count +end +--================ +--获取所有羁绊对象列表(包括没激活的) +--================ +function XExpeditionTeam:GetAllCombos() + return self.ComboList:GetAllCombos() +end +--================ +--获取所有队员组合对象列表 +--================ +function XExpeditionTeam:GetTeamComboList() + local team = self:GetTeam() + local comboList = self.ComboList:GetCurrentCombos(team) + table.sort(comboList, SortDisplayComboFunc) + return comboList +end +--================ +--获取所有有效的队员组合对象列表 +--================ +function XExpeditionTeam:GetActiveTeamComboList() + local team = self:GetTeam() + local comboList = self.ComboList:GetCurrentCombos(team) + local activeList = {} + for _, combo in pairs(comboList) do + if combo:GetComboActive() then + table.insert(activeList, combo) + end + end + table.sort(activeList, SortByComboId) + return activeList +end +--================ +--获取所有羁绊列表对象 +--================ +function XExpeditionTeam:GetComboList() + return self.ComboList +end +--================ +--队伍成员变动时调用方法 +--================ +function XExpeditionTeam:OnTeamMemberChange() + self:ResetDisplayTeam() + self.AverageLevel = nil + OnMemberChange() +end +--================ +--重置队伍展示列表状态 +--================ +function XExpeditionTeam:ResetDisplayTeam() + self.DisplayTeamList = nil +end +--================ +--获取招募界面队伍显示列表 +--================ +function XExpeditionTeam:GetTeamPosDisplayList() + local displayTeamPosList = {} + local unLockPosList = {} + local lockPosList = {} + for _, teamPos in pairs(self.TeamPos) do + if teamPos:GetIsUnLock() then + table.insert(unLockPosList, teamPos) + else + table.insert(lockPosList, teamPos) + end + end + for i in pairs(unLockPosList) do + table.insert(displayTeamPosList, unLockPosList[i]) + end + for i in pairs(lockPosList) do + table.insert(displayTeamPosList, lockPosList[i]) + end + return displayTeamPosList +end +--================ +--获取展示用队伍成员显示列表 +--================ +function XExpeditionTeam:GetDisplayTeamList() + if not self.DisplayTeamList then + self.DisplayTeamList = {} + for _, chara in pairs(self.TeamChara) do + table.insert(self.DisplayTeamList, chara) + end + table.sort(self.DisplayTeamList, SortDisplayTeamFunc) + end + return self.DisplayTeamList +end +--================ +--根据位置获取展示用队伍成员显示列表中的成员 +--================ +function XExpeditionTeam:GetCharaByDisplayPos(pos) + if not self.DisplayTeamList then + return self:GetDisplayTeamList() and self.DisplayTeamList[pos] + end + return self.DisplayTeamList and self.DisplayTeamList[pos] +end +--================ +--检查成员展示列表中是否含有指定序号的成员 +--================ +function XExpeditionTeam:CheckCharaInDisplayListByPos(pos) + return self.DisplayTeamList and self.DisplayTeamList[pos] ~= nil +end +--================ +--根据玩法角色Id获取成员展示列表中指定角色的序号 +--================ +function XExpeditionTeam:GetCharaDisplayIndexByBaseId(eBaseId) + if not self.DisplayTeamList then + self:GetDisplayTeamList() + end + for index, v in pairs(self.DisplayTeamList) do + if v:GetBaseId() == eBaseId then return index end + end + return -1 +end +--================ +--根据成员展示列表中指定角色的序号获取角色对象 +--================ +function XExpeditionTeam:GetECharaByDisplayIndex(displayIndex) + for index, v in pairs(self.DisplayTeamList) do + if index == displayIndex then return v end + end +end +--================ +--根据玩法角色Id获取成员对象 +--================ +function XExpeditionTeam:GetCharaByEBaseId(eBaseId) + return self.TeamChara[eBaseId] +end +--================ +--获取出战队伍平均星级 +--================ +function XExpeditionTeam:GetAverageStar() + local list = {} + for _, eChara in pairs(self.TeamChara) do + table.insert(list, eChara:GetRank()) + end + table.sort(list, SortByBigger) + local totalLevel = 0 + for i = 1, 3 do + totalLevel = totalLevel + (list and list[i] ~= nil and list[i] or 0) + end + return math.floor(totalLevel / (#list > 0 and #list <= 3 and #list or 3)) +end +--================ +--获取出战队伍对象 +--================ +function XExpeditionTeam:GetBattleTeam() + local team = XDataCenter.ExpeditionManager.GetExpeditionTeam() + local teamData = team.TeamData + local eCharaList = {} + for _, eBaseId in pairs(teamData) do + if eBaseId > 0 then + local eChara = self.TeamChara[eBaseId] + if eChara then table.insert(eCharaList, eChara) end + end + end + table.sort(eCharaList, SortDisplayTeamFunc) + return eCharaList +end +return XExpeditionTeam \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XExpedition/XExpeditionTeamPos.lua b/Resources/Scripts/XEntity/XExpedition/XExpeditionTeamPos.lua new file mode 100644 index 00000000..e1b245d8 --- /dev/null +++ b/Resources/Scripts/XEntity/XExpedition/XExpeditionTeamPos.lua @@ -0,0 +1,31 @@ +-- 虚像地平线招募位置对象 +local XExpeditionTeamPos = XClass(nil, "XExpeditionTeamPos") +--================ +--构造函数 +--================ +function XExpeditionTeamPos:Ctor(teamPosId) + self.TeamPosCfg = XExpeditionConfig.GetTeamPosCfgById(teamPosId) +end +--================ +--获取是否解锁 +--================ +function XExpeditionTeamPos:GetIsUnLock() + if not self.TeamPosCfg.ConditionId or self.TeamPosCfg.ConditionId == 0 then + return true + else + return XConditionManager.CheckCondition(self.TeamPosCfg.ConditionId) + end +end +--================ +--获取条件描述 +--================ +function XExpeditionTeamPos:GetConditionDes() + return self.TeamPosCfg and self.TeamPosCfg.ConditionDes +end +--================ +--获取位置Id +--================ +function XExpeditionTeamPos:GetTeamPosId() + return self.TeamPosCfg and self.TeamPosCfg.Id +end +return XExpeditionTeamPos \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XFestival/XFestivalChapter.lua b/Resources/Scripts/XEntity/XFestival/XFestivalChapter.lua new file mode 100644 index 00000000..35421d8c --- /dev/null +++ b/Resources/Scripts/XEntity/XFestival/XFestivalChapter.lua @@ -0,0 +1,236 @@ +-- 庆典类活动章节对象 +local XFestivalChapter = XClass(nil, "XFestivalChapter") +--==================== +--构造函数 +--@param chapterId:章节ID +--==================== +function XFestivalChapter:Ctor(chapterId) + self.ChapterId = chapterId + self:InitChapter() + self:InitStages() +end +--==================== +--初始化章节配置 +--==================== +function XFestivalChapter:InitChapter() + self.ChapterCfg = XFestivalActivityConfig.GetFestivalById(self.ChapterId) +end +--==================== +--初始化关卡对象 +--==================== +function XFestivalChapter:InitStages() + self.Stages = {} + self.StageId2Stage = {} + self.StagePassCount = 0 + self.StageTotalCount = 0 + if not self.ChapterCfg then return end + local XFestivalStage = require("XEntity/XFestival/XFestivalStage") + for index, stageId in pairs(self.ChapterCfg.StageId or {}) do + local newStage = XFestivalStage.New(stageId, index, self) + self.Stages[index] = newStage + self.StageId2Stage[stageId] = newStage + if not newStage:GetIsEggStage() then self.StageTotalCount = self.StageTotalCount + 1 end + XDataCenter.FubenFestivalActivityManager.AddStageId2ChapterId(stageId, self.ChapterId) + end +end + +function XFestivalChapter:RefreshStages() + for _, stage in pairs(self.Stages) do + stage:RefreshStage() + end +end +--==================== +--获取章节ID +--==================== +function XFestivalChapter:GetChapterId() + return self.ChapterId +end +--==================== +--获取是否开放 +--==================== +function XFestivalChapter:GetIsOffline() + return self.ChapterCfg and self.ChapterCfg.Offline and self.ChapterCfg.Offline > 0 or false +end +--==================== +--获取时间ID +--==================== +function XFestivalChapter:GetTimeId() + return self.ChapterCfg and self.ChapterCfg.TimeId or 0 +end +--==================== +--获取章节名称 +--==================== +function XFestivalChapter:GetName() + return self.ChapterCfg and self.ChapterCfg.Name +end +--==================== +--获取章节优先度 +--==================== +function XFestivalChapter:GetPriority() + return self.ChapterCfg and self.ChapterCfg.Priority +end +--==================== +--获取功能开放ID +--==================== +function XFestivalChapter:GetFunctionOpenId() + return self.ChapterCfg and self.ChapterCfg.FunctionOpenId +end +--==================== +--获取主界面跳转页Id +--==================== +function XFestivalChapter:GetSkipId() + return self.ChapterCfg and self.ChapterCfg.SkipId +end +--==================== +--获取章节关卡名前缀 +--==================== +function XFestivalChapter:GetStagePrefix() + return self.ChapterCfg and self.ChapterCfg.StagePrefix +end +--==================== +--获取入口图 +--==================== +function XFestivalChapter:GetBannerBg() + return self.ChapterCfg and self.ChapterCfg.BannerBg +end +--==================== +--获取章节类型 +--==================== +function XFestivalChapter:GetChapterType() + return self.ChapterCfg and self.ChapterCfg.ChapterType +end +--==================== +--获取主页面背景图 +--==================== +function XFestivalChapter:GetMainBackgound() + return self.ChapterCfg and self.ChapterCfg.MainBackgound +end +--==================== +--获取关卡路线图预制体 +--==================== +function XFestivalChapter:GetFubenPrefab() + return self.ChapterCfg and self.ChapterCfg.FubenPrefab +end +--==================== +--获取战斗关卡预制体 +--==================== +function XFestivalChapter:GetGridFubenPrefab() + return self.ChapterCfg and self.ChapterCfg.GridFubenPrefab +end +--==================== +--获取故事关卡预制体 +--==================== +function XFestivalChapter:GetGridStoryPrefab() + return self.ChapterCfg and self.ChapterCfg.GridStoryPrefab +end +--==================== +--获取标题图标 +--==================== +function XFestivalChapter:GetTitleIcon() + return self.ChapterCfg and self.ChapterCfg.TitleIcon +end +--==================== +--获取标题背景图 +--==================== +function XFestivalChapter:GetTitleBg() + return self.ChapterCfg and self.ChapterCfg.TitleBg +end +--==================== +--获取背景音乐ID +--==================== +function XFestivalChapter:GetChapterBgm() + return self.ChapterCfg and self.ChapterCfg.ChapterBgm +end +--==================== +--获取总关卡数 +--==================== +function XFestivalChapter:GetStageTotalCount() + return self.StageTotalCount or 0 +end +--==================== +--获取总通关关卡数 +--==================== +function XFestivalChapter:GetStagePassCount() + return self.StagePassCount or 0 +end +--==================== +--根据关卡序号获取关卡对象 +--@param orderIndex:关卡序号 +--==================== +function XFestivalChapter:GetStageByOrderIndex(orderIndex) + return self.Stages[orderIndex] +end +--==================== +--根据关卡ID获取关卡对象 +--@param stageId:关卡Id +--==================== +function XFestivalChapter:GetStageByStageId(stageId) + return self.StageId2Stage[stageId] +end +--==================== +--获取关卡ID列表 +--==================== +function XFestivalChapter:GetStageIdList() + return self.ChapterCfg and self.ChapterCfg.StageId +end +--==================== +--根据关卡ID获取关卡是否已通过 +--@param stageId:关卡Id +--==================== +function XFestivalChapter:GetChapterStageIsPass(stageId) + if not stageId or stageId == 0 then return true end + local stage = self.StageId2Stage[stageId] + if not stage then + stage = XDataCenter.FubenManager.GetStageInfo(stageId) + return stage and stage.Passed or false + end + return stage:GetIsPass() +end +--==================== +--刷新章节关卡信息 +--==================== +function XFestivalChapter:RefreshChapterStageInfos() + self.StagePassCount = 0 + for _, stage in pairs(self.Stages) do + if stage then + stage:RefreshStageInfo() + if stage:GetIsPass() then self.StagePassCount = self.StagePassCount + 1 end + end + end +end +--==================== +--获取章节是否在活动时间内 +--==================== +function XFestivalChapter:GetIsInTime() + if self:GetIsOffline() then return false end + local startTime, endTime = XFunctionManager.GetTimeByTimeId(self:GetTimeId()) + local nowTime = XTime.GetServerNowTimestamp() + return (nowTime >= startTime) and (nowTime < endTime) +end +--==================== +--获取章节是否在活动时间内及对应提示文本 +--==================== +function XFestivalChapter:GetIsInTimeAndTips() + if self:GetIsOffline() then return false, CS.XTextManager.GetText("EliminateNotOpen") end + local nowTime = XTime.GetServerNowTimestamp() + local beginTime, endTime = XFunctionManager.GetTimeByTimeId(self:GetTimeId()) + if beginTime ~= 0 and nowTime < beginTime then + return false, CS.XTextManager.GetText("EliminateNotOpen") + elseif endTime ~= 0 and nowTime > endTime then + return false, CS.XTextManager.GetText("EliminateTimeOut") + end + return true, "" +end +--==================== +--获取章节是否开放 +--==================== +function XFestivalChapter:GetIsOpen() + return (not XFunctionManager.CheckFunctionFitter(self:GetFunctionOpenId())) and self:GetIsInTime() +end +--==================== +--获取章节结束时间 +--==================== +function XFestivalChapter:GetEndTime() + return XFunctionManager.GetEndTimeByTimeId(self:GetTimeId()) +end +return XFestivalChapter \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XFestival/XFestivalStage.lua b/Resources/Scripts/XEntity/XFestival/XFestivalStage.lua new file mode 100644 index 00000000..bdafd23c --- /dev/null +++ b/Resources/Scripts/XEntity/XFestival/XFestivalStage.lua @@ -0,0 +1,258 @@ +-- 庆典类活动关卡对象 +local XFestivalStage = XClass(nil, "XFestivalStage") +--==================== +--构造函数 +--@param stageId:关卡ID +--@param orderIndex:关卡在章节中的序号 +--@param chapter:章节对象 +--==================== +function XFestivalStage:Ctor(stageId, orderIndex, chapter) + self.StageId = stageId + self.Chapter = chapter + self.OrderIndex = orderIndex + self:InitStage() +end +--==================== +--初始化关卡配置 +--==================== +function XFestivalStage:InitStage() + self.FestivalStageCfg = XFestivalActivityConfig.GetFestivalStageCfgByStageId(self.StageId) + self.StageCfg = XDataCenter.FubenManager.GetStageCfg(self.StageId) + self.StageInfo = XDataCenter.FubenManager.GetStageInfo(self.StageId) + self.StageInfo.Type = XDataCenter.FubenManager.StageType.Festival + self.PassCount = 0 +end + +function XFestivalStage:RefreshStage() + self.StageInfo = XDataCenter.FubenManager.GetStageInfo(self.StageId) + self.StageInfo.Type = XDataCenter.FubenManager.StageType.Festival + self:RefreshStageInfo() +end +--==================== +--获取关卡ID +--==================== +function XFestivalStage:GetStageId() + return self.StageId +end +--==================== +--获取所属章节对象 +--==================== +function XFestivalStage:GetChapter() + return self.Chapter +end +--==================== +--获取关卡基本配置 +--==================== +function XFestivalStage:GetStageCfg() + return self.StageCfg +end +--==================== +--获取关卡序号名称 +--==================== +function XFestivalStage:GetOrderName() + return self.Chapter and string.format("%s%d", self.Chapter:GetStagePrefix(), self.OrderIndex) +end +--==================== +--获取关卡名称 +--==================== +function XFestivalStage:GetName() + return (self.FestivalStageCfg and self.FestivalStageCfg.StageName) or self.StageCfg.Name +end +--==================== +--获取关卡序号 +--==================== +function XFestivalStage:GetOrderIndex() + return self.OrderIndex +end +--==================== +--获取开放条件ID +--==================== +function XFestivalStage:GetOpenConditionId() + return self.FestivalStageCfg and self.FestivalStageCfg.OpenConditionId or {} +end +--==================== +--获取关卡是否开启 +--==================== +function XFestivalStage:GetCanOpen() + if not self.StageInfo.Unlock then return false, CS.XTextManager.GetText("FubenNotUnlock") end + if self.StageCfg.RequireLevel > 0 and XPlayer.Level < self.StageCfg.RequireLevel then + return false, CS.XTextManager.GetText("TeamLevelToOpen", self.StageCfg.RequireLevel) + end + for _, conditionId in pairs(self:GetOpenConditionId()) do + local ret, desc = XConditionManager.CheckCondition(conditionId) + if not ret then + return false, desc + end + end + -- 如果是彩蛋关 + if self:GetIsEggStage() then + if self.StageInfo.Unlock and XDataCenter.FubenManager.GetUnlockHideStageById(self.StageId) then + -- 彩蛋已经解锁 + return true, "" + else + -- 彩蛋未解锁 + return false, CS.XTextManager.GetText("FubenNotUnlock") + end + end + return true, "" +end +--==================== +--获取关卡类型 +--==================== +function XFestivalStage:GetStageType() + return self.StageCfg and self.StageCfg.StageType +end +--==================== +--获取是否彩蛋关 +--==================== +function XFestivalStage:GetIsEggStage() + local stageType = self:GetStageType() + return stageType and ((stageType == XFubenConfigs.STAGETYPE_STORYEGG) or (stageType == XFubenConfigs.STAGETYPE_FIGHTEGG)) +end +--==================== +--获取关卡预制体 +--==================== +function XFestivalStage:GetStagePrefab() + if self.FestivalStageCfg and self.FestivalStageCfg.StageStyle then + return self.FestivalStageCfg.StageStyle + elseif self.StageCfg.StageType == XFubenConfigs.STAGETYPE_FIGHT then + return self.Chapter and self.Chapter:GetGridFubenPrefab() + elseif self.StageCfg.StageType == XFubenConfigs.STAGETYPE_STORY then + return self.Chapter and self.Chapter:GetGridStoryPrefab() + else + return self.Chapter and self.Chapter:GetGridFubenPrefab() + end + return nil +end +--==================== +--获取关卡显示类型 +--==================== +function XFestivalStage:GetStageShowType() + local stageType = self:GetStageType() + if stageType == XFubenConfigs.STAGETYPE_FIGHT or stageType == XFubenConfigs.STAGETYPE_FIGHTEGG then + return XDataCenter.FubenFestivalActivityManager.StageFuben + elseif stageType == XFubenConfigs.STAGETYPE_STORY or stageType == XFubenConfigs.STAGETYPE_STORYEGG then + return XDataCenter.FubenFestivalActivityManager.StageStory + else + return XDataCenter.FubenFestivalActivityManager.StageFuben + end +end +--==================== +--设置关卡通过状态 +--@param isPass:要设置的关卡通过状态 +--==================== +function XFestivalStage:SetIsPass(isPass) + self.StageInfo.Passed = isPass + self.Passed = isPass +end +--==================== +--获取关卡是否通过 +--==================== +function XFestivalStage:GetIsPass() + return self.Passed or self.StageInfo.Passed or false +end +--==================== +--获取关卡是否开放 +--==================== +function XFestivalStage:GetIsOpen() + return self.StageInfo.IsOpen or false +end +--==================== +--设置关卡通关次数 +--@param count:设置的次数 +--==================== +function XFestivalStage:SetPassCount(count) + self.PassCount = count +end +--==================== +--增加关卡通关次数 +--@param addCount:增加的次数 +--==================== +function XFestivalStage:AddPassCount(addCount) + self.PassCount = self.PassCount + addCount +end +--==================== +--获取关卡通关次数 +--==================== +function XFestivalStage:GetPassCount() + return self.PassCount +end +--==================== +--获取前置关卡ID组 +--==================== +function XFestivalStage:GetPreStageId() + return self.StageCfg and self.StageCfg.PreStageId or {} +end +--==================== +--获取关卡通关三星描述 +--==================== +function XFestivalStage:GetStarDesc() + return self.StageCfg and self.StageCfg.StarDesc +end +--==================== +--根据序号获取关卡通关星数条件描述 +--@param index:条件序号 +--==================== +function XFestivalStage:GetStarDescByIndex(index) + local desc = self:GetStarDesc() + if not desc then return "" end + return desc[index] +end +--==================== +--获取关卡通关星数字典 +--==================== +function XFestivalStage:GetStarMaps() + return self.StageInfo and self.StageInfo.StarMaps +end +--==================== +--根据序号获取该项通关星数是否通过 +--==================== +function XFestivalStage:GetStarMapsByIndex(index) + local maps = self:GetStarMaps() + if not maps then return end + return maps[index] +end +--==================== +--获取关卡挑战上限数 +--==================== +function XFestivalStage:GetMaxChallengeNum() + return XDataCenter.FubenManager.GetStageMaxChallengeNums(self.StageId) +end +--==================== +--获取关卡挑战所需体力 +--==================== +function XFestivalStage:GetRequireActionPoint() + return self.StageCfg and self.StageCfg.RequireActionPoint or 0 +end +--==================== +--获取关卡图标 +--==================== +function XFestivalStage:GetIcon() + return self.StageCfg and self.StageCfg.Icon +end +--==================== +--获取关卡首通奖励 +--==================== +function XFestivalStage:GetFirstRewardShow() + return self.StageCfg and self.StageCfg.FirstRewardShow +end +--==================== +--获取关卡非首通通关奖励 +--==================== +function XFestivalStage:GetFinishRewardShow() + return self.StageCfg and self.StageCfg.FinishRewardShow +end +--==================== +--刷新关卡信息 +--==================== +function XFestivalStage:RefreshStageInfo() + self.StageInfo.Unlock = true + for _, prestageId in pairs(self:GetPreStageId()) do + if not self.Chapter:GetChapterStageIsPass(prestageId) then + self.StageInfo.Unlock = false + break + end + end + self.StageInfo.IsOpen = self:GetCanOpen() +end +return XFestivalStage \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XFriend.lua b/Resources/Scripts/XEntity/XFriend.lua new file mode 100644 index 00000000..b968b976 --- /dev/null +++ b/Resources/Scripts/XEntity/XFriend.lua @@ -0,0 +1,34 @@ +XFriend = XClass(nil, "XFriend") + +local Default = { + FriendId = 0, + NickName = "", + Icon = 0, + Level = 0, + Sign = "", + IsOnline = false, + LastLoginTime = 0, + FriendExp = 0, +} + +function XFriend:Ctor(friendId, createTime) + for key in pairs(Default) do + self[key] = Default[key] + end + + self.FriendId = friendId + self.CreateTime = createTime +end + +function XFriend:Update(playerInfo) + self.FriendId = playerInfo.Id + self.NickName = playerInfo.Name + self.Icon = playerInfo.CurrHeadPortraitId + self.Level = playerInfo.Level + self.Sign = playerInfo.Sign + self.IsOnline = playerInfo.IsOnline + self.LastLoginTime = playerInfo.LastLoginTime + self.FriendExp = playerInfo.FriendExp + self.CurrMedalId = playerInfo.CurrMedalId + self.HeadFrameId = playerInfo.CurrHeadFrameId +end \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XFunctional/XFunctionTime.lua b/Resources/Scripts/XEntity/XFunctional/XFunctionTime.lua new file mode 100644 index 00000000..7652efbd --- /dev/null +++ b/Resources/Scripts/XEntity/XFunctional/XFunctionTime.lua @@ -0,0 +1,95 @@ +local XFunctionTime = XClass(nil, "XFunctionTime") + +local Default = { + TimeId = 0, + StartTime = 0, + EndTime = 0, + Timer = nil, +} + +function XFunctionTime:Ctor(timeId) + for key, v in pairs(Default) do + self[key] = v + end + + self.TimeId = timeId +end + +function XFunctionTime:CreateTimer() + if self.Timer then + return + end + + if self:NotOpen() then + self.Timer = XScheduleManager.ScheduleAtTimestamp(function() + XEventManager.DispatchEvent(XEventId.EVENT_TIMEID_BOUND_PREFIX .. self.TimeId, XFunctionManager.TimeState.Start, self.TimeId) + self.Timer = self:CreateExitTimer() + end, self.StartTime) + elseif self:IsEnd() then + XEventManager.DispatchEvent(XEventId.EVENT_TIMEID_BOUND_PREFIX .. self.TimeId, XFunctionManager.TimeState.End, self.TimeId) + else + XEventManager.DispatchEvent(XEventId.EVENT_TIMEID_BOUND_PREFIX .. self.TimeId, XFunctionManager.TimeState.Start, self.TimeId) + self.Timer = self:CreateExitTimer() + end +end + +function XFunctionTime:CreateExitTimer() + return XScheduleManager.ScheduleAtTimestamp(function() + XEventManager.DispatchEvent(XEventId.EVENT_TIMEID_BOUND_PREFIX .. self.TimeId, XFunctionManager.TimeState.End, self.TimeId) + self.Timer = nil + end, self.EndTime) +end + +function XFunctionTime:UpdateData(data) + self.StartTime = data.StartTime or 0 + self.EndTime = data.EndTime or 0 + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + self:CreateTimer() + end +end + +function XFunctionTime:GetStartTime() + return self.StartTime +end + +function XFunctionTime:GetEndTime() + return self.EndTime +end + +function XFunctionTime:NotOpen() + local nowTime = XTime.GetServerNowTimestamp() + local startTime = self:GetStartTime() + if startTime > 0 and nowTime < startTime then + return true + end +end + +function XFunctionTime:IsEnd() + local nowTime = XTime.GetServerNowTimestamp() + local endTime = self:GetEndTime() + if endTime > 0 and nowTime >= endTime then + return true + end +end + +function XFunctionTime:IsInTime() + local nowTime = XTime.GetServerNowTimestamp() + + --startTime未配置默认无开启时间限制 + local startTime = self:GetStartTime() + if startTime > 0 and nowTime < startTime then + return false + end + + --endTime未配置默认无结束时间限制 + local endTime = self:GetEndTime() + if endTime > 0 and nowTime >= endTime then + return false + end + + return true +end + +return XFunctionTime \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XGlobalDraw.lua b/Resources/Scripts/XEntity/XGlobalDraw.lua new file mode 100644 index 00000000..34946e41 --- /dev/null +++ b/Resources/Scripts/XEntity/XGlobalDraw.lua @@ -0,0 +1,102 @@ +XGlobalDraw = XClass(nil, "XGlobalDraw") + +local Default = { + Id = 0, + IsActivity = false, + DrawName = "", + DrawType = 0, + DrawId = 0, + ActivityTime = {}, + Desc = "", + UseItemId = 0, + UseItemCount = 0, + LimitCountParam = {}, + PrimaryStorage = {}, + ExtraStorage = {}, + BtnCount = {}, + Banner = "", + ProbabilityId = {}, + RuleId = {}, + TicketId = 0, + TicketCount = 0, + Discount = {}, + DiscountTime = {}, + ContentItems = {}, +} + +function XGlobalDraw:Ctor(data) + for key in pairs(Default) do + self[key] = Default[key] + end + self:Update(data) +end + +function XGlobalDraw:Update(data) + self.Id = data.DrawTrunkId and data.DrawTrunkId or 0 + self.IsActivity = not data.IsDefault + self.DrawName = data.DrawName + self.DrawType = data.DrawType and data.DrawType or 0 + self.DrawId = data.DrawId and data.DrawId or 0 + self.ActivityTime = {} + self.ActivityTime.StartTime = data.Time.StartTime + self.ActivityTime.EndTime = data.Time.EndTime + self.Desc = data.Desc + self.UseItemId = data.UseItemId and data.UseItemId or 0 + self.UseItemCount = data.UseItemCount and data.UseItemCount or 0 + self.LimitCountParam = {} + XTool.LoopCollection(data.LimintCountParam, function(param) + table.insert(self.LimitCountParam, param) + end) + + self.PrimaryStorage = {} + XTool.LoopMap(data.PrimaryIdsMap, function(key, value) + self.PrimaryStorage[key] = value + end) + self.ExtraStorage = {} + XTool.LoopMap(data.ExtraIdsMap, function(key, value) + self.ExtraStorage[key] = value + end) + + self.BtnCount = {} + XTool.LoopCollection(data.BtnCount, function(count) + table.insert(self.BtnCount, count) + end) + + self.Banner = {} + local bans = string.Split(data.Banner, "|") + for _, ban in ipairs(bans) do + table.insert(self.Banner, ban) + end + + self.ProbabilityId = string.Split(data.ProbabilityId, "|") + self.RuleId = string.Split(data.RuleId, "|") + self.TicketId = data.TicketId and data.TicketId or 0 + self.TicketCount = data.TicketCount and data.TicketCount or 0 + + self.Discount = {} + XTool.LoopCollection(data.Discount, function(count) + table.insert(self.Discount, count) + end) + + self.DiscountTime = {} + if (data.DiscountTime) then + self.DiscountTime.StartTime = data.DiscountTime.StartTime + self.DiscountTime.EndTime = data.DiscountTime.EndTime + else + self.DiscountTime.StartTime = 0 + self.DiscountTime.EndTime = 0 + end + + local upNewInfos = string.Split(data.ContentItems, "|") + self.ContentItems = {} + for _, upNewInfo in ipairs(upNewInfos) do + local infos = string.Split(upNewInfo, "_") + if (#infos >= 3) then + local info = {} + info.itemId = tonumber(infos[1]) + info.up = tonumber(infos[2]) + info.new = tonumber(infos[3]) + table.insert(self.ContentItems, info) + end + end +end diff --git a/Resources/Scripts/XEntity/XGuardCamp/XCampNotifyData.lua b/Resources/Scripts/XEntity/XGuardCamp/XCampNotifyData.lua new file mode 100644 index 00000000..162ed1be --- /dev/null +++ b/Resources/Scripts/XEntity/XGuardCamp/XCampNotifyData.lua @@ -0,0 +1,36 @@ +local type = type + +local XCampNotifyData = XClass(nil, "XCampNotifyData") + +local Default = { + __Id = 0, --阵营id + __JoinNum = 0, --加入人数 + __SupportNum = 0, --支援数量 +} + +function XCampNotifyData:Ctor(id) + for key, value in pairs(Default) do + if type(value) == "table" then + self[key] = {} + else + self[key] = value + end + end + self.__Id = id +end + +function XCampNotifyData:UpdateData(data) + if XTool.IsTableEmpty(data) then return end + self.__JoinNum = data.JoinNum + self.__SupportNum = data.SupportNum +end + +function XCampNotifyData:GetJoinNum() + return self.__JoinNum +end + +function XCampNotifyData:GetSupportNum() + return self.__SupportNum +end + +return XCampNotifyData \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XGuardCamp/XGuardActivityNotifyData.lua b/Resources/Scripts/XEntity/XGuardCamp/XGuardActivityNotifyData.lua new file mode 100644 index 00000000..8eb9f382 --- /dev/null +++ b/Resources/Scripts/XEntity/XGuardCamp/XGuardActivityNotifyData.lua @@ -0,0 +1,66 @@ +local XCampNotifyData = require("XEntity/XGuardCamp/XCampNotifyData") + +local type = type + +local XGuardActivityNotifyData = XClass(nil, "XGuardActivityNotifyData") + +local Default = { + __Id = 0, --活动id + __WinCampId = 0, --胜利阵营 + __PondCount = 0, --奖池数量 + __CampDatas = {}, --阵营信息 +} + +function XGuardActivityNotifyData:Ctor(id) + for key, value in pairs(Default) do + if type(value) == "table" then + self[key] = {} + else + self[key] = value + end + end + self.__Id = id +end + +function XGuardActivityNotifyData:UpdateData(data) + if XTool.IsTableEmpty(data) then return end + self.__WinCampId = data.WinCampId + self.__PondCount = data.PondCount + + if not XTool.IsTableEmpty(data.CampDatas) then + for _, v in ipairs(data.CampDatas) do + if not self.__CampDatas[v.Id] then + self.__CampDatas[v.Id] = XCampNotifyData.New(v.Id) + end + self.__CampDatas[v.Id]:UpdateData(v) + end + end +end + +function XGuardActivityNotifyData:GetWinCampId() + return self.__WinCampId +end + +function XGuardActivityNotifyData:GetPondCount() + return self.__PondCount +end + +function XGuardActivityNotifyData:GetJoinNumByCampId(campId) + return self.__CampDatas[campId] and self.__CampDatas[campId]:GetJoinNum() or 0 +end + +function XGuardActivityNotifyData:GetSupportNumByCampId(campId) + return self.__CampDatas[campId] and self.__CampDatas[campId]:GetSupportNum() or 0 +end + +function XGuardActivityNotifyData:GetJoinTotalNum() + local totalNum = 0 + local joinNum + for id in pairs(self.__CampDatas) do + joinNum = self:GetJoinNumByCampId(id) + totalNum = totalNum + joinNum + end + return totalNum +end + +return XGuardActivityNotifyData \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XGuardCamp/XGuardCampActivityInfo.lua b/Resources/Scripts/XEntity/XGuardCamp/XGuardCampActivityInfo.lua new file mode 100644 index 00000000..f2953f0b --- /dev/null +++ b/Resources/Scripts/XEntity/XGuardCamp/XGuardCampActivityInfo.lua @@ -0,0 +1,52 @@ +local type = type + +local XGuardCampActivityInfo = XClass(nil, "XGuardCampActivityInfo") + +local Default = { + __Id = 0, --活动id + __SelectCampId = 0, --选择阵营 + __CampInfos = {}, --阵营信息 + __IsGetReward = false, --是否已领奖 +} + +function XGuardCampActivityInfo:Ctor(id) + for key, value in pairs(Default) do + if type(value) == "table" then + self[key] = {} + else + self[key] = value + end + end + self.__Id = id +end + +function XGuardCampActivityInfo:UpdateData(data) + if XTool.IsTableEmpty(data) then return end + self.__SelectCampId = data.SelectCampId + + if not XTool.IsTableEmpty(data.CampInfos) then + for _, v in ipairs(data.CampInfos) do + self.__CampInfos[v.Id] = v.SupportCount --阵营id和支援数量 + end + end + + self:SetIsGetReward(data.IsGetReward) +end + +function XGuardCampActivityInfo:GetSelectCampId() + return self.__SelectCampId +end + +function XGuardCampActivityInfo:GetSupportCountByCampId(campId) + return campId and self.__CampInfos[campId] or 0 +end + +function XGuardCampActivityInfo:IsGetReward() + return self.__IsGetReward +end + +function XGuardCampActivityInfo:SetIsGetReward(isGetReward) + self.__IsGetReward = isGetReward +end + +return XGuardCampActivityInfo \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XGuild/XGuildData.lua b/Resources/Scripts/XEntity/XGuild/XGuildData.lua new file mode 100644 index 00000000..c0921a20 --- /dev/null +++ b/Resources/Scripts/XEntity/XGuild/XGuildData.lua @@ -0,0 +1,179 @@ +--从服务器接收的格式 +XGuildData = XClass(nil, "XGuildData") + +local Json = require("XCommon/Json") + +local Default = { + -- 公会基本信息 + GuildId = 0, + GuildName = "", + GuildIconId = 0, + GuildLevel = 0, + GuildMemberCount = 0, + GuildMemberMaxCount = 0, + GuildTouristCount = 0, + GuildTouristMaxCount = 0, + GuildContributeLeft = 0, + GuildContributeIn7Days = 0, + GuildRank = {}, + GuildLeaderName = "", + GuildDeclaration = "", + GuildInterCom = "", + RankNames = "", + + GiftContribute = 0, + GiftGuildLevel = 0, + GiftLevel = 0, + GiftLevelGot = {}, + GiftGuildGot = 0, + + Build = 0, + Option = XGuildConfig.ApplySetting.NeedApply, + MinLevel = 1, + MaintainState = 0, + EmergenceTime = 0, + TalentPointFromBuild = 0, + TalentSumLevel = 0, + AllTalentLevelMax = false, + GuildLastLevel = -1, +} + +function XGuildData:Ctor(guildData) + for key in pairs(Default) do + self[key] = Default[key] + end + + self.MemberData = {} + self.DecodeRankNames = {} + self.GuildRankLevel = 0 + self.IsInitData = false + self:UpdateGuildData(guildData) +end + +function XGuildData:IsInit() + return self.IsInitData +end + +function XGuildData:UpdateGuildData(guildData) + if guildData == nil then + return + end + self.IsInitData = true + + self.GuildId = guildData.GuildId + self.GuildName = guildData.GuildName + self.GuildIconId = guildData.GuildIconId + self.GuildLevel = guildData.GuildLevel + self.GuildMemberCount = guildData.GuildMemberCount + self.GuildMemberMaxCount = guildData.GuildMemberMaxCount + self.GuildTouristCount = guildData.GuildTouristCount + self.GuildTouristMaxCount = guildData.GuildTouristMaxCount + self.GuildContributeLeft = guildData.GuildContributeLeft + self.GuildContributeIn7Days = guildData.GuildContributeIn7Days + self.GuildLeaderName = guildData.GuildLeaderName + self.GuildDeclaration = guildData.GuildDeclaration + self.GuildInterCom = guildData.Notice + self:UpdateAllRankNames(guildData.RankNames) + + self.GiftContribute = guildData.GiftContribute + self.GiftGuildLevel = guildData.GiftGuildLevel + self.GiftLevel = guildData.GiftLevel + self.GiftLevelGot = {} + for _, level in pairs(guildData.GiftLevelGot or {}) do + self.GiftLevelGot[level] = true + end + self.GiftGuildGot = guildData.GiftGuildGot + + self.Build = guildData.Build + self.MaintainState = guildData.MaintainState + self.EmergenceTime = guildData.EmergenceTime + if guildData.Option ~= 0 then + self.Option = guildData.Option + else + self.Option = XGuildConfig.ApplySetting.NeedApply + end + self.MinLevel = guildData.MinLevel + self.TalentPointFromBuild = guildData.TalentPointFromBuild + self.TalentSumLevel = guildData.TalentSumLevel +end + +function XGuildData:UpdateAllRankNames(rankNames) + self.RankNames = rankNames + -- 清空职位名 + if not self.RankNames then + self.DecodeRankNames = {} + return + end + if self.RankNames ~= "" then + local decode_custom = Json.decode(self.RankNames) + for _, rankInfo in pairs(decode_custom or {}) do + self.DecodeRankNames[rankInfo.Id] = rankInfo.Name + end + end +end + +function XGuildData:UpdateGuildMembers(guildMemberData, memberCount) + local memberInfos = {} + for _, memberInfo in pairs(guildMemberData or {}) do + local oldMemberInfo = self.MemberData[memberInfo.Id] + if oldMemberInfo then + oldMemberInfo:UpdateMemberData(memberInfo) + memberInfos[memberInfo.Id] = oldMemberInfo + else + memberInfos[memberInfo.Id] = XGuildMemberData.New(memberInfo) + end + end + self.MemberData = memberInfos + self.GuildMemberCount = memberCount or self.GuildMemberCount +end + +function XGuildData:GetGuildMembers() + return self.MemberData +end + +function XGuildData:ClearGuildMembers() + self.MemberData = {} +end + +function XGuildData:RemoveMember(playerId) + if not playerId then return end + self.MemberData[playerId] = nil + self.GuildMemberCount = self.GuildMemberCount - 1 +end + +-- 是否已经加入公会 +function XGuildData:IsJoinGuild() + return self.GuildId ~= nil and self.GuildId ~= 0 +end + +-- 获取职位名字、读不到自定义的则去表读取 +function XGuildData:GetRankNameByLevel(level) + if level <= 0 then + return "" + end + local rankTemplate = XGuildConfig.GetGuildPositionById(level) + local decodeRankName = self.DecodeRankNames[level] + if decodeRankName == nil or decodeRankName == "" then + if not rankTemplate then return "" end + return rankTemplate.Name + end + return decodeRankName or "" +end + +-- 是否为管理员 +function XGuildData:IsGuildAdministor() + if not self.GuildRankLevel or self.GuildRankLevel == 0 then + return false + end + + return self.GuildRankLevel < XGuildConfig.GuildRankLevel.Elder +end + +-- 是否为会长 +function XGuildData:IsLeader() + if not self.GuildRankLevel or self.GuildRankLevel == 0 then + return false + end + return self.GuildRankLevel == XGuildConfig.GuildRankLevel.Leader +end + diff --git a/Resources/Scripts/XEntity/XGuild/XGuildMemberData.lua b/Resources/Scripts/XEntity/XGuild/XGuildMemberData.lua new file mode 100644 index 00000000..264887e4 --- /dev/null +++ b/Resources/Scripts/XEntity/XGuild/XGuildMemberData.lua @@ -0,0 +1,56 @@ +--从服务器接收的格式 +XGuildMemberData = XClass(nil, "XGuildMemberData") + +local Default = { + -- 公会成员基本信息 + Id = nil, + Name = "", + HeadPortraitId = 0, + HeadFrameId = 0, + Level = 1, + RankLevel = 0, + ContributeIn7Days = 0, + ContributeAct = 0, + ContributeHistory = 0, + Popularity = 0, + LastLoginTime = 0, + OnlineFlag = 0, +} + +local STATE_ONLINE = 1 + +function XGuildMemberData:Ctor(guildMemberData) + for key in pairs(Default) do + self[key] = Default[key] + end + self:UpdateMemberData(guildMemberData) +end + +function XGuildMemberData:UpdateMemberData(guildMemberData) + if guildMemberData == nil then + return + end + self.Id = guildMemberData.Id + self.Name = guildMemberData.Name + self.HeadPortraitId = guildMemberData.HeadPortraitId + self.HeadFrameId = guildMemberData.HeadFrameId + self.Level = guildMemberData.Level + self.RankLevel = guildMemberData.RankLevel + self.ContributeIn7Days = guildMemberData.ContributeIn7Days + self.ContributeAct = guildMemberData.ContributeAct + self.ContributeHistory = guildMemberData.ContributeHistory + self.Popularity = guildMemberData.Popularity + self.LastLoginTime = guildMemberData.LastLoginTime + self.OnlineFlag = guildMemberData.OnlineFlag +end + +function XGuildMemberData:UpdateRankLevel(rankLevel) + self.RankLevel = rankLevel +end + +function XGuildMemberData:IsOnline() + return self.OnlineFlag == STATE_ONLINE +end + + + diff --git a/Resources/Scripts/XEntity/XGuild/XGuildVistorData.lua b/Resources/Scripts/XEntity/XGuild/XGuildVistorData.lua new file mode 100644 index 00000000..3c9b7a83 --- /dev/null +++ b/Resources/Scripts/XEntity/XGuild/XGuildVistorData.lua @@ -0,0 +1,71 @@ +XGuildVistorData = XClass(nil, "XGuildVistorData") +local Json = require("XCommon/Json") + +function XGuildVistorData:Ctor() + self.MembersDatas = {} +end + +function XGuildVistorData:UpdateGuildData(guildData) + self.GuildId = guildData.GuildId + self.GuildName = guildData.GuildName + self.GuildIconId = guildData.GuildIconId + self.GuildLevel = guildData.GuildLevel + self.GuildMemberCount = guildData.GuildMemberCount + self.GuildMemberMaxCount = guildData.GuildMemberMaxCount + self.GuildContributeIn7Days = guildData.GuildContributeIn7Days + self.GuildLeaderName = guildData.GuildLeaderName + self.GuildDeclaration = guildData.GuildDeclaration + self.GuildTouristCount = guildData.GuildTouristCount + self.GuildTouristMaxCount = guildData.GuildTouristMaxCount + self.MaintainState = guildData.MaintainState + self.EmergenceTime = guildData.EmergenceTime + self.GiftGuildLevel = guildData.GiftGuildLevel + self.Option = guildData.Option + self.GiftGuildGot = guildData.GiftGuildGot + self.Build = guildData.Build + self.GiftContribute = guildData.GiftContribute + self.DataRefreshTime = XTime.GetServerNowTimestamp() + local decodeRankNames = {} + if guildData.RankNames ~= "" then + local decode_custom = Json.decode(guildData.RankNames) + for _, rankInfo in pairs(decode_custom or {}) do + decodeRankNames[rankInfo.Id] = rankInfo.Name + end + end + self.DecodeRankNames = decodeRankNames + local membersDatas = {} + for _, memberData in pairs(guildData.MembersData or {}) do + table.insert(membersDatas, memberData) + end + self.MembersDatas = membersDatas +end + +function XGuildVistorData:UpdateGuildMembers(guildMemberData) + local memberInfos = {} + for _, memberInfo in pairs(guildMemberData or {}) do + local oldMemberInfo = self.MembersDatas[memberInfo.Id] + if oldMemberInfo then + oldMemberInfo:UpdateMemberData(memberInfo) + memberInfos[memberInfo.Id] = oldMemberInfo + else + memberInfos[memberInfo.Id] = XGuildMemberData.New(memberInfo) + end + end + self.MembersDatas = memberInfos +end + +function XGuildVistorData:GetGuildMembers() + return self.MembersDatas +end + +function XGuildVistorData:ClearGuildMembers() + self.MembersDatas = {} +end + +function XGuildVistorData:IsHaveVistorGuildDetailsById() + if XTime.GetServerNowTimestamp() - self.DataRefreshTime > XGuildConfig.GuildRequestVistorTime then + return false + end + + return true +end \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XHome/XHomeFurnitureData.lua b/Resources/Scripts/XEntity/XHome/XHomeFurnitureData.lua new file mode 100644 index 00000000..c1e1208e --- /dev/null +++ b/Resources/Scripts/XEntity/XHome/XHomeFurnitureData.lua @@ -0,0 +1,86 @@ +XHomeFurnitureData = XClass(nil, "XHomeFurnitureData") + +function XHomeFurnitureData:Ctor(data) + self.Id = data.Id or 0 + self.PlayerId = 0 + self.ConfigId = data.ConfigId or 0 + self.X = data.X + self.Y = data.Y + self.Angle = data.Angle + self.DormitoryId = data.DormitoryId or 0 + self.Addition = data.Addition + self.AttrList = data.AttrList + self.IsLocked = data.IsLocked +end + +function XHomeFurnitureData:GetInstanceID() + return self.Id +end + +function XHomeFurnitureData:SetConfigId(cfgId) + self.ConfigId = cfgId +end + +function XHomeFurnitureData:GetConfigId() + return self.ConfigId +end + +function XHomeFurnitureData:SetUsedDormitoryId(dormitoryId) + self.DormitoryId = dormitoryId +end + +function XHomeFurnitureData:CheckIsUsed() + return self.DormitoryId > 0 +end + +function XHomeFurnitureData:GetScore() + local score = 0 + if self.Addition > 0 then + score = score + XFurnitureConfigs.GetAdditionalAddScore(self.Addition) + end + + for _, attr in ipairs(self.AttrList) do + score = score + attr + end + return score +end + +function XHomeFurnitureData:GeAttrtScore(attrType, attrScore) + local score = attrScore or 0 + if self.Addition <= 0 then + return score + end + + local additionConfig = XFurnitureConfigs.GetAdditonAttrConfigById(self.Addition) + if additionConfig == nil then + return score + end + + if additionConfig.AddType == XFurnitureConfigs.FurnitureAdditionType.AttrTotal then + score = additionConfig.AddValue[attrType] + score + elseif additionConfig.AddType == XFurnitureConfigs.FurnitureAdditionType.AttrTotalPercent then + score = math.floor(additionConfig.AddValue[attrType] * score / 100) + score + end + + return score +end + +function XHomeFurnitureData:GetRedScore() + return self:GeAttrtScore(XFurnitureConfigs.AttrType.AttrA, self.AttrList[XFurnitureConfigs.AttrType.AttrA]) +end + +function XHomeFurnitureData:GetYellowScore() + return self:GeAttrtScore(XFurnitureConfigs.AttrType.AttrB, self.AttrList[XFurnitureConfigs.AttrType.AttrB]) +end + +function XHomeFurnitureData:GetBlueScore() + return self:GeAttrtScore(XFurnitureConfigs.AttrType.AttrC, self.AttrList[XFurnitureConfigs.AttrType.AttrC]) +end + +function XHomeFurnitureData:GetIsLocked() + return self.IsLocked +end + +function XHomeFurnitureData:SetIsLocked(isLocked) + self.IsLocked = isLocked +end \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XHome/XHomeRoomData.lua b/Resources/Scripts/XEntity/XHome/XHomeRoomData.lua new file mode 100644 index 00000000..6d780afd --- /dev/null +++ b/Resources/Scripts/XEntity/XHome/XHomeRoomData.lua @@ -0,0 +1,353 @@ +XHomeRoomData = XClass(nil, "XHomeRoomData") + +function XHomeRoomData:Ctor(id) + self.Id = id or 0 + self.PlayerId = XPlayer.Id + self.Name = nil + self.IsUnlock = false + self.RoomDataType = XDormConfig.DormDataType.Self + self.Order = 0 + self.CreateTieme = 0 + self.PicturePath = nil + self.ConnectDormId = 0 + self.ShareId = nil -- 分享ID + self.FurnitureCount = 0 + + self.FurnitureDic = {} + self.Character = {} + self.FurnitureConfigDic = {} -- 家具config表{k:configId, v:{ids}} + + self.GroundFurniture = nil + self.CeillingFurniture = nil + self.WallFurniture = nil +end + +-- 判断数据是自己还是其他人的 +function XHomeRoomData:IsSelfData() + return self.PlayerId == XPlayer.Id +end + +function XHomeRoomData:SetPlayerId(id) + self.PlayerId = id +end + +function XHomeRoomData:GetPlayerId() + return self.PlayerId +end + +function XHomeRoomData:GetRoomId() + return self.Id +end + +function XHomeRoomData:SetRoomName(name) + self.Name = name +end + +function XHomeRoomData:GetRoomName() + return self.Name +end + +function XHomeRoomData:SetShareId(id) + self.ShareId = id +end + +function XHomeRoomData:GetShareId() + return self.ShareId +end + +function XHomeRoomData:SetRoomUnlock(isUnlock) + self.IsUnlock = isUnlock +end + +function XHomeRoomData:WhetherRoomUnlock() + return self.IsUnlock +end + +function XHomeRoomData:AddFurniture(instId, cfgId, x, y, rotateAngle) + local furniture = {} + furniture.Id = instId or 0 + furniture.ConfigId = cfgId + furniture.GridX = x + furniture.GridY = y + furniture.RotateAngle = rotateAngle + + self.FurnitureDic[instId] = furniture + self:SetBaseData(furniture) + + if not self.FurnitureConfigDic[cfgId] then + self.FurnitureConfigDic[cfgId] = {} + end + + self.FurnitureCount = self.FurnitureCount + 1 + table.insert(self.FurnitureConfigDic[cfgId], instId) +end + +-- 设置地板,天花板,墙 +function XHomeRoomData:SetBaseData(furniture) + local baseType = XFurnitureConfigs.HomeSurfaceBaseType + if XFurnitureConfigs.IsFurnitureMatchTypeByConfigId(furniture.ConfigId, baseType.Ground) then + self.GroundFurniture = furniture + elseif XFurnitureConfigs.IsFurnitureMatchTypeByConfigId(furniture.ConfigId, baseType.Ceiling) then + self.CeillingFurniture = furniture + elseif XFurnitureConfigs.IsFurnitureMatchTypeByConfigId(furniture.ConfigId, baseType.Wall) then + self.WallFurniture = furniture + end +end + +-- 获取地板 +function XHomeRoomData:GetGroundFurniture() + return self.GroundFurniture +end + +-- 获取天花板 +function XHomeRoomData:GetCeillingFurniture() + return self.CeillingFurniture +end + +-- 获取墙 +function XHomeRoomData:GetWallFurniture() + return self.WallFurniture +end + +function XHomeRoomData:SetFurnitureDic(furnitureDic) + if not furnitureDic then + return + end + + self.FurnitureDic = furnitureDic + self:SetFurnitureConfigDic() +end + +function XHomeRoomData:ClearFruniture() + self.FurnitureCount = 0 + self.FurnitureDic = {} + self.FurnitureConfigDic = {} +end + +function XHomeRoomData:GetFurnitureDic() + return self.FurnitureDic +end + +function XHomeRoomData:SetFurnitureConfigDic() + self.FurnitureConfigDic = {} + self.FurnitureCount = 0 + for _, v in pairs(self.FurnitureDic) do + self:SetBaseData(v) + + if not self.FurnitureConfigDic[v.ConfigId] then + self.FurnitureConfigDic[v.ConfigId] = {} + end + + self.FurnitureCount = self.FurnitureCount + 1 + table.insert(self.FurnitureConfigDic[v.ConfigId], v.Id) + end +end + +function XHomeRoomData:GetFurnitureConfigDic() + return self.FurnitureConfigDic +end + +function XHomeRoomData:GetFurnitureConfigByConfigId(configId) + return self.FurnitureConfigDic[configId] or {} +end + +--添加角色 +function XHomeRoomData:AddCharacter(character) + table.insert(self.Character, character) +end + +--移除角色 +function XHomeRoomData:RemoveCharacter(id) + if self.Character == nil then + return + end + + local index = -1 + for i, v in ipairs(self.Character) do + if v.CharacterId == id then + index = i + break + end + end + + if index > 0 then + table.remove(self.Character, index) + end +end + +function XHomeRoomData:GetCharacterById(CharacterId) + for _, v in ipairs(self.Character) do + if v.CharacterId == CharacterId then + return v + end + end + + return nil +end + +function XHomeRoomData:GetCharacter() + return self.Character +end + +function XHomeRoomData:GetCharacterIds() + local ids = {} + if not self.Character or #self.Character <= 0 then + return ids + end + + for _, data in ipairs(self.Character) do + table.insert(ids, data.CharacterId) + end + + return ids +end + +function XHomeRoomData:SetRoomDataType(roomType) + self.RoomDataType = roomType +end + +function XHomeRoomData:GetRoomDataType() + return self.RoomDataType +end + +function XHomeRoomData:SetRoomOrder(order) + self.Order = order +end + +function XHomeRoomData:GetRoomOrder() + return self.Order +end + +function XHomeRoomData:SetRoomCreateTime(createTime) + self.CreateTieme = createTime +end + +function XHomeRoomData:GetRoomCreateTime() + return self.CreateTieme +end + +function XHomeRoomData:SetRoomPicturePath(picturePath) + self.PicturePath = picturePath +end + +function XHomeRoomData:GetRoomPicturePath() + return self.PicturePath +end + +function XHomeRoomData:SetConnectDormId(connectDormId) + self.ConnectDormId = connectDormId +end + +function XHomeRoomData:GetConnectDormId() + return self.ConnectDormId +end + +function XHomeRoomData:GetRoomPicture(cb) + local fileName = tostring(XPlayer.Id) .. tostring(self.Id) + local textureCache = XDataCenter.DormManager.GetLocalCaptureCache(fileName) + if textureCache then + if cb then + cb(textureCache) + end + + return + end + + CS.XTool.LoadLocalCaptureImg(fileName, function(textrue) + XDataCenter.DormManager.SetLocalCaptureCache(fileName, textrue) + if cb then + cb(textrue) + end + end) +end + +local FurnitrueSortFunc = function(a, b) + if a.MinorType ~= b.MinorType then + return a.MinorType < b.MinorType + end + + return a.ConfigId < b.ConfigId +end + +-- 获取对标宿舍足够的家具 +function XHomeRoomData:GetEnoughFurnitures() + local list = {} + if self.ConnectDormId <= 0 then + return list + end + + for k, v in pairs(self.FurnitureConfigDic) do + local myCount = #v + local roomType = XDormConfig.DormDataType.Self + local targetCount = XDataCenter.DormManager.GetFunritureCountInDorm(self.ConnectDormId, roomType, k, true) + if targetCount >= myCount then + local data = {} + data.ConfigId = k + data.Count = myCount + data.TargetCount = targetCount + data.ConnectDormId = self.ConnectDormId + table.insert(list, data) + end + end + + table.sort(list, FurnitrueSortFunc) + return list +end + +-- 获取对标宿舍不足够的家具 +function XHomeRoomData:GetNotEnoughFurnitures() + local list = {} + if self.ConnectDormId <= 0 then + return list + end + + for k, v in pairs(self.FurnitureConfigDic) do + local myCount = #v + local roomType = XDormConfig.DormDataType.Self + local targetCount = XDataCenter.DormManager.GetFunritureCountInDorm(self.ConnectDormId, roomType, k, true) + if targetCount < myCount then + local data = {} + data.ConfigId = k + data.Count = myCount + data.TargetCount = targetCount + data.ConnectDormId = self.ConnectDormId + table.insert(list, data) + end + end + + table.sort(list, FurnitrueSortFunc) + return list +end + +-- 获取宿舍所有家具 +function XHomeRoomData:GetAllFurnitures() + if self.ConnectDormId > 0 then + local list = {} + for k, v in pairs(self.FurnitureConfigDic) do + local myCount = #v + local roomType = XDormConfig.DormDataType.Self + local targetCount = XDataCenter.DormManager.GetFunritureCountInDorm(self.ConnectDormId, roomType, k, true) + local data = {} + data.ConfigId = k + data.Count = myCount + data.TargetCount = targetCount + data.ConnectDormId = self.ConnectDormId + table.insert(list, data) + end + + table.sort(list, FurnitrueSortFunc) + return list + else + local list = {} + for k, v in pairs(self.FurnitureConfigDic) do + local data = {} + data.ConfigId = k + data.Count = #v + data.ConnectDormId = self.ConnectDormId + table.insert(list, data) + end + + table.sort(list, FurnitrueSortFunc) + return list + end +end \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XInfestorExplore/XInfestorExploreCharacter.lua b/Resources/Scripts/XEntity/XInfestorExplore/XInfestorExploreCharacter.lua new file mode 100644 index 00000000..950fabb5 --- /dev/null +++ b/Resources/Scripts/XEntity/XInfestorExplore/XInfestorExploreCharacter.lua @@ -0,0 +1,67 @@ +local XInfestorExploreCharacter = XClass(nil, "XInfestorExploreCharacter") + +--[[{ + // 玩家id + public int CharacterId; + // 血量百分比 + public int HpPer; + // 上阵位置 + public int TeamPos; + // 是否是队长 + public bool IsCaptain; + // 是否是第一个出场 + public bool IsFirstFight +}]] +local Default = { + CharacterId = 0, + HpPer = 100, + TeamPos = 0, + IsCaptain = nil, + IsFirstFight = nil, +} + +function XInfestorExploreCharacter:Ctor() + for key, value in pairs(Default) do + self[key] = value + end +end + +function XInfestorExploreCharacter:UpdateData(playerData) + for key, value in pairs(playerData) do + self[key] = value + end +end + +function XInfestorExploreCharacter:GetCharacterId() + return self.CharacterId +end + +function XInfestorExploreCharacter:GetHpPercent() + return self.HpPer +end + +function XInfestorExploreCharacter:GetTeamPos() + return self.TeamPos +end + +function XInfestorExploreCharacter:IsMeCaptain() + return self.IsCaptain and true or false +end + +function XInfestorExploreCharacter:IsMeFirstFight() + return self.IsFirstFight and true or false +end + +function XInfestorExploreCharacter:SetTeamInfo(teamPos, isCaptain, isFirstFight) + self.TeamPos = teamPos + self.IsCaptain = isCaptain and true or nil + self.IsFirstFight = isFirstFight +end + +function XInfestorExploreCharacter:ClearTeamInfo() + self.TeamPos = 0 + self.IsCaptain = nil + self.IsFirstFight = nil +end + +return XInfestorExploreCharacter \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XInfestorExplore/XInfestorExploreCore.lua b/Resources/Scripts/XEntity/XInfestorExplore/XInfestorExploreCore.lua new file mode 100644 index 00000000..8bec10e2 --- /dev/null +++ b/Resources/Scripts/XEntity/XInfestorExplore/XInfestorExploreCore.lua @@ -0,0 +1,68 @@ +local XInfestorExploreCore = XClass(nil, "XInfestorExploreCore") + +--[[{ + // 玩家id + public int Id; + // 等级 + public int Level; +}]] +local Default = { + Id = 0, + Level = 0, + WearingPos = 0, +} + +function XInfestorExploreCore:Ctor() + for key, value in pairs(Default) do + self[key] = value + end +end + +function XInfestorExploreCore:UpdateData(data) + for key, value in pairs(data) do + self[key] = value + end +end + +function XInfestorExploreCore:GetId() + return self.Id +end + +function XInfestorExploreCore:SetLevel(newLevel) + self.Level = newLevel +end + +function XInfestorExploreCore:GetLevel() + return self.Level +end + +function XInfestorExploreCore:GetMaxLevel() + return XFubenInfestorExploreConfigs.GetCoreMaxLevel(self.Id) +end + +function XInfestorExploreCore:IsMaxLevel() + local maxLevel = self:GetMaxLevel() + return self.Level >= maxLevel +end + +function XInfestorExploreCore:GetName() + return XFubenInfestorExploreConfigs.GetCoreName(self.Id) +end + +function XInfestorExploreCore:GetDecomposeMoney() + return XFubenInfestorExploreConfigs.GetCoreDecomposeMoney(self.Id, self.Level) +end + +function XInfestorExploreCore:PutOn(pos) + self.WearingPos = pos +end + +function XInfestorExploreCore:TakeOff() + self.WearingPos = 0 +end + +function XInfestorExploreCore:IsWearing() + return self.WearingPos > 0 +end + +return XInfestorExploreCore \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XInfestorExplore/XInfestorExploreMapNode.lua b/Resources/Scripts/XEntity/XInfestorExplore/XInfestorExploreMapNode.lua new file mode 100644 index 00000000..7bfdcce9 --- /dev/null +++ b/Resources/Scripts/XEntity/XInfestorExplore/XInfestorExploreMapNode.lua @@ -0,0 +1,267 @@ +local XInfestorExploreOutPostStory = require("XEntity/XInfestorExplore/XInfestorExploreOutPostStory") + +local next = next +local type = type +local tableInsert = table.insert + +local MAX_SUPPLY_OPTION_NUM = 3 + +local XInfestorExploreMapNode = XClass(nil, "XInfestorExploreMapNode") + +local NodeType = { + Empty = 1, --空白点(起点) + Rest = 2, --休息点 + Fight = 3, --战斗点 + Shop = 4, --商店 + Supply = 5, --补给点 + Reward = 6, --奖励点 + SelectEvent = 7, --可选择事件点 + AutoEvent = 8, --自动事件点 + OutPost = 9, --据点 +} + +local NodeStatus = { + UnReach = 1, --够不着 + Fog = 2, --迷雾 + Current = 3, --当前 + Reach = 4, --可到达 + Passed = 5, --走过的 +} + +local NodePrefabPath = { + [NodeStatus.UnReach] = CS.XGame.ClientConfig:GetString("GridFubenInfestorExploreStageUnReach"), + [NodeStatus.Fog] = CS.XGame.ClientConfig:GetString("GridFubenInfestorExploreStageFog"), + [NodeStatus.Current] = CS.XGame.ClientConfig:GetString("GridFubenInfestorExploreStageCurrent"), + [NodeStatus.Reach] = CS.XGame.ClientConfig:GetString("GridFubenInfestorExploreStageReach"), + [NodeStatus.Passed] = CS.XGame.ClientConfig:GetString("GridFubenInfestorExploreStagePassed"), +} + +local NodeUiName = { + [NodeType.Fight] = "UiInfestorExploreStageDetailFight", + [NodeType.Shop] = "UiInfestorExploreStageDetailShop", + [NodeType.AutoEvent] = "UiInfestorExploreStageDetailEvent", + [NodeType.Rest] = "UiInfestorExploreStageDetailRest", + [NodeType.Supply] = "UiInfestorExploreStageDetailSupply", + [NodeType.Reward] = "UiInfestorExploreStageDetailReward", + [NodeType.SelectEvent] = "UiInfestorExploreStageDetailEvent", + [NodeType.OutPost] = "UiInfestorExploreStageDetailOutPost", +} + +local Default = { + NodeId = 0, + StageId = 0, + Type = NodeType.Empty, + ResType = 0, + Status = NodeStatus.UnReach, + ParentIds = {}, + ChildIds = {}, + PlayerIdCheckTable = {}, + OutPostStory = nil, + SupplyRandomDesList = {}, +} + +function XInfestorExploreMapNode:Ctor(nodeId) + self:Reset() + self.NodeId = nodeId +end + +function XInfestorExploreMapNode:Reset() + for key, v in pairs(Default) do + if type(v) == "table" then + self[key] = {} + else + self[key] = v + end + end +end + +function XInfestorExploreMapNode:SetParentId(parentId) + self.ParentIds[parentId] = true +end + +function XInfestorExploreMapNode:SetChildId(childId) + self.ChildIds[childId] = true +end + +function XInfestorExploreMapNode:SetStageId(stageId) + self.StageId = stageId or 0 + self.ResType = XFubenInfestorExploreConfigs.GetNodeResType(stageId) + self.Type = XFubenInfestorExploreConfigs.GetNodeType(stageId) + + if self.Type == NodeType.OutPost then + self.OutPostStory = XInfestorExploreOutPostStory.New() + elseif self.Type == NodeType.Supply then + self.SupplyRandomDesList = XDataCenter.FubenInfestorExploreManager.GetRandomSupplyRewardDesList(MAX_SUPPLY_OPTION_NUM) + end +end + +function XInfestorExploreMapNode:SetStatusCurrent() + self.Status = NodeStatus.Current +end + +function XInfestorExploreMapNode:SetStatusFog() + if self.Status == NodeStatus.Fog + or self.Status == NodeStatus.Passed + or self.Status == NodeStatus.Reach + then return end + + if self:IsStart() + or self:IsEnd() + then return end + + if self.Type == NodeType.Shop + or self.Type == NodeType.Rest + then return end + + self.Status = NodeStatus.Fog +end + +function XInfestorExploreMapNode:SetStatusReach() + self.Status = NodeStatus.Reach +end + +function XInfestorExploreMapNode:SetStatusUnReach() + self.Status = NodeStatus.UnReach +end + +function XInfestorExploreMapNode:SetStatusPassed() + self.Status = NodeStatus.Passed +end + +function XInfestorExploreMapNode:SetOccupiedPlayerId(playerId) + self.PlayerIdCheckTable[playerId] = playerId +end + +function XInfestorExploreMapNode:ClearOccupiedPlayerId(playerId) + self.PlayerIdCheckTable[playerId] = nil +end + +function XInfestorExploreMapNode:GetOccupiedPlayerIds() + local playerIds = {} + for _, playerId in pairs(self.PlayerIdCheckTable) do + tableInsert(playerIds, playerId) + end + return playerIds +end + +function XInfestorExploreMapNode:GetOutPostStory() + if self.Type ~= NodeType.OutPost then + XLog.Error("XInfestorExploreMapNode:GetOutPostStory Error: 感染体玩法节点类型错误, 该类型没有据点战斗剧情配置, nodeId: " .. self.NodeId .. ",type: " .. self.Type) + return + end + return self.OutPostStory +end + +function XInfestorExploreMapNode:GetSupplyDesList() + if self.Type ~= NodeType.Supply then + XLog.Error("XInfestorExploreMapNode:GetSupplyDesList Error: 感染体玩法节点类型错误, 该类型没有补给点随机描述配置, nodeId: " .. self.NodeId .. ",type: " .. self.Type) + return + end + return self.SupplyRandomDesList +end + +function XInfestorExploreMapNode:GetNodeId() + return self.NodeId +end + +function XInfestorExploreMapNode:GetParentIds() + return self.ParentIds +end + +function XInfestorExploreMapNode:GetChildIds() + return self.ChildIds +end + +function XInfestorExploreMapNode:GetPrefabPath() + return NodePrefabPath[self.Status] +end + +function XInfestorExploreMapNode:GetTypeIcon() + return XFubenInfestorExploreConfigs.GetNodeTypeIcon(self.ResType) +end + +function XInfestorExploreMapNode:GetNodeTypeUiName() + if self.Type == NodeType.Empty then return end + local uiName = NodeUiName[self.Type] + if not uiName then + XLog.Error("XInfestorExploreMapNode:GetNodeTypeUiName Error: 感染体玩法节点类型错误, 该类型没有对应详情UI, nodeId: " .. self.NodeId .. ",type: " .. self.Type) + return + end + return uiName +end + +function XInfestorExploreMapNode:GetUseActionPoint() + return XFubenInfestorExploreConfigs.GetUseActionPoint(self.StageId) +end + +function XInfestorExploreMapNode:GetEventPoolId() + if self.Type ~= NodeType.AutoEvent + and self.Type ~= NodeType.SelectEvent then + XLog.Error("XInfestorExploreMapNode:GetEventId Error: 感染体玩法节点类型错误, 该类型没有事件Id配置, nodeId: " .. self.NodeId .. ",type: " .. self.Type) + return + end + return XFubenInfestorExploreConfigs.GetEventPoolId(self.StageId) +end + +function XInfestorExploreMapNode:GetStageBg() + return XFubenInfestorExploreConfigs.GetNodeTypeStageBg(self.ResType) +end + +function XInfestorExploreMapNode:GetFightStageId() + if self.Type ~= NodeType.Fight then + XLog.Error("XInfestorExploreMapNode:GetFightStageId Error: 感染体玩法节点类型错误, 该类型没有关卡Id配置, nodeId: " .. self.NodeId .. ",type: " .. self.Type) + return + end + return XFubenInfestorExploreConfigs.GetFightStageId(self.StageId) +end + +function XInfestorExploreMapNode:GetShowRewardId() + if self.Type ~= NodeType.OutPost + and self.Type ~= NodeType.Fight then + XLog.Error("XInfestorExploreMapNode:GetShowRewardId Error: 感染体玩法节点类型错误, 该类型没有奖励Id配置, nodeId: " .. self.NodeId .. ",type: " .. self.Type) + return + end + return XFubenInfestorExploreConfigs.GetShowRewardId(self.StageId) +end + +function XInfestorExploreMapNode:IsStart() + return not next(self.ParentIds) +end + +function XInfestorExploreMapNode:IsEnd() + return not next(self.ChildIds) +end + +function XInfestorExploreMapNode:IsCurrent() + return self.Status == NodeStatus.Current +end + +function XInfestorExploreMapNode:IsReach() + return self.Status == NodeStatus.Reach +end + +function XInfestorExploreMapNode:IsUnReach() + return self.Status == NodeStatus.UnReach +end + +function XInfestorExploreMapNode:IsPassed() + return self.Status == NodeStatus.Passed +end + +function XInfestorExploreMapNode:IsFog() + return self.Status == NodeStatus.Fog +end + +function XInfestorExploreMapNode:IsSelectEvent() + return self.Type == NodeType.SelectEvent +end + +function XInfestorExploreMapNode:IsAutoEvent() + return self.Type == NodeType.AutoEvent +end + +function XInfestorExploreMapNode:IsShop() + return self.Type == NodeType.Shop +end + +return XInfestorExploreMapNode \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XInfestorExplore/XInfestorExploreOutPostStory.lua b/Resources/Scripts/XEntity/XInfestorExplore/XInfestorExploreOutPostStory.lua new file mode 100644 index 00000000..bfb1f9a1 --- /dev/null +++ b/Resources/Scripts/XEntity/XInfestorExplore/XInfestorExploreOutPostStory.lua @@ -0,0 +1,85 @@ +local ipairs = ipairs +local stringGsub = string.gsub + +local CHARACTER_NAME_REPLACE_FLAG = "【kurocharacter】"--角色名称替换标记 +local CHARACTER_HP_REPLACE_FLAG = "【kurohp】"--损失生命值替换标记 + +local XInfestorExploreOutPostStory = XClass(nil, "XInfestorExploreOutPostStory") + +local Default = { + Start = "", --据点信息描述 + + --回合战斗内容 + --选项1 + Option1 = "", + MyTurn1 = "", --我的回合 + HisTurnWithDamage1 = "", --他的回合(扣血) + HisTurnInPeace1 = "", --他的回合(不扣血) + --选项2 + Option2 = "", + MyTurn2 = "", --我的回合 + HisTurnWithDamage2 = "", --他的回合(扣血) + HisTurnInPeace2 = "", --他的回合(不扣血) + + End = "", --固定结果描述(需要显示扣血总数值) +} + +function XInfestorExploreOutPostStory:Ctor() + self.Start = self:LetsRoll("Start") + self.Option1 = self:LetsRoll("Option1") + self.Option2 = self:LetsRoll("Option2") +end + +function XInfestorExploreOutPostStory:LetsRoll(key, characterName, hp) + local str = "" + + local poolIds = XFubenInfestorExploreConfigs.GetOutPostDesPoolIds(key) + for _, poolId in ipairs(poolIds) do + local randomDes = XFubenInfestorExploreConfigs.GetRandomOutPostDes(poolId) + str = str .. randomDes + end + + if characterName then + str = stringGsub(str, CHARACTER_NAME_REPLACE_FLAG, characterName) + end + + if hp then + str = stringGsub(str, CHARACTER_HP_REPLACE_FLAG, hp) + end + + return str +end + +function XInfestorExploreOutPostStory:GetStartDes() + return self.Start +end + +function XInfestorExploreOutPostStory:GetOption1Txt() + return self.Option1 +end + +function XInfestorExploreOutPostStory:GetOption2Txt() + return self.Option2 +end + +function XInfestorExploreOutPostStory:GetMyTurnDes(option, characterName) + local key = "MyTurn" .. option + local str = self:LetsRoll(key, characterName) + return str +end + +function XInfestorExploreOutPostStory:GetHisTurnDes(option, isHurt, characterName, hp) + local key = isHurt and "HisTurnWithDamage" .. option or "HisTurnInPeace" .. option + local str = self:LetsRoll(key, characterName, hp) + return str +end + +function XInfestorExploreOutPostStory:GetEndDes(characterName, hp) + local key = "End" + local str = self:LetsRoll(key, characterName, hp) + return str +end + + + +return XInfestorExploreOutPostStory \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XInfestorExplore/XInfestorExplorePlayer.lua b/Resources/Scripts/XEntity/XInfestorExplore/XInfestorExplorePlayer.lua new file mode 100644 index 00000000..08c21f8f --- /dev/null +++ b/Resources/Scripts/XEntity/XInfestorExplore/XInfestorExplorePlayer.lua @@ -0,0 +1,122 @@ +local DefaultSign = CS.XTextManager.GetText("CharacterSignTip") + +local XInfestorExplorePlayer = XClass(nil, "XInfestorExplorePlayer") + +--[[{ + // 玩家id + public int Id; + // 等级 + public int Level; + // 名字 + public string Name; + // 签名 + public string Sign; + // 头像 + public int HeadPortraitId; + // 分数 + public int Score; + // 所在章节id + public int ChapterId; + // 所在格子id + public int GridId; +}]] +local Default = { + Id = 0, + Level = 0, + Name = "", + Sign = "", + HeadPortraitId = 0, + HeadFrameId = 0, + Score = 0, + ChapterId = 0, + GridId = 0, + GroupId = 0, + Diff = 0, +} + +function XInfestorExplorePlayer:Ctor() + for key, value in pairs(Default) do + self[key] = value + end +end + +function XInfestorExplorePlayer:UpdateData(playerData) + for key, value in pairs(playerData) do + self[key] = value + end +end + +function XInfestorExplorePlayer:GetPlayerId() + return self.Id +end + +function XInfestorExplorePlayer:SetScore(score) + self.Score = score +end + +function XInfestorExplorePlayer:GetScore() + return self.Score +end + +function XInfestorExplorePlayer:GetHeadPortraitId() + return self.HeadPortraitId +end + +function XInfestorExplorePlayer:GetHeadFrameId() + return self.HeadFrameId +end + +function XInfestorExplorePlayer:GetChapterId() + return self.ChapterId +end + +function XInfestorExplorePlayer:GetGridId() + return self.GridId +end + +function XInfestorExplorePlayer:GetName() + return self.Name +end + +function XInfestorExplorePlayer:GetLevel() + return self.Level +end + +function XInfestorExplorePlayer:GetSign() + local str = self.Sign + return not string.IsNilOrEmpty(str) and str or DefaultSign +end + +function XInfestorExplorePlayer:GetHeadIcon() + return XDataCenter.HeadPortraitManager.GetHeadPortraitImgSrcById(self.HeadPortraitId) +end + +function XInfestorExplorePlayer:GetHeadEffectPath() + return XDataCenter.HeadPortraitManager.GetHeadPortraitEffectById(self.HeadPortraitId) +end + +function XInfestorExplorePlayer:GetHeadFrame() + return XDataCenter.HeadPortraitManager.GetHeadPortraitImgSrcById(self.HeadFrameId) +end + +function XInfestorExplorePlayer:GetHeadFrameEffectPath() + return XDataCenter.HeadPortraitManager.GetHeadPortraitEffectById(self.HeadFrameId) +end + +function XInfestorExplorePlayer:GetDiffName() + local groupId = self.GroupId + local diff = self.Diff + if groupId > 0 and diff > 0 then + return XFubenInfestorExploreConfigs.GetDiffName(groupId, diff) + end +end + +function XInfestorExplorePlayer:GetDiffIcon() + local groupId = self.GroupId + local diff = self.Diff + if groupId > 0 and diff > 0 then + return XFubenInfestorExploreConfigs.GetDiffIcon(groupId, diff) + end +end + +return XInfestorExplorePlayer \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XInfestorExplore/XInfestorExploreTeam.lua b/Resources/Scripts/XEntity/XInfestorExplore/XInfestorExploreTeam.lua new file mode 100644 index 00000000..5b5fe9d6 --- /dev/null +++ b/Resources/Scripts/XEntity/XInfestorExplore/XInfestorExploreTeam.lua @@ -0,0 +1,73 @@ +local XInfestorExploreTeam = XClass(nil, "XInfestorExploreTeam") + +local Default = { + TeamType = 0, + CaptainPos = 1, + FirstFightPos = 1, + MemberNum = 0, + CharacterIds = { 0, 0, 0 }, + IsSyn = false, --是否与服务端同步过 +} + +function XInfestorExploreTeam:Ctor(teamType) + for key, value in pairs(Default) do + self[key] = value + end + self.TeamType = teamType +end + +function XInfestorExploreTeam:IsSyned() + return self.IsSyn +end + +function XInfestorExploreTeam:Syn() + self.IsSyn = true +end + +function XInfestorExploreTeam:SetCaptainPos(captainPos) + self.CaptainPos = captainPos +end + +function XInfestorExploreTeam:SetFirstFightPos(firstFightPos) + self.FirstFightPos = firstFightPos +end + +function XInfestorExploreTeam:GetCaptainPos() + return self.CaptainPos +end + +function XInfestorExploreTeam:GetFirstFightPos() + return self.FirstFightPos +end + +function XInfestorExploreTeam:SetCharacterIds(characterIds) + self.CharacterIds = characterIds + + local memeberNum = 0 + for _, characterId in pairs(characterIds) do + if characterId > 0 then + memeberNum = memeberNum + 1 + end + end + self.MemberNum = memeberNum +end + +function XInfestorExploreTeam:GetCharacterIds() + return XTool.Clone(self.CharacterIds) +end + +function XInfestorExploreTeam:IsEmpty() + return self.MemberNum == 0 +end + +function XInfestorExploreTeam:IsCaptainExist() + local captainCharacterId = self.CharacterIds[self.CaptainPos] + return captainCharacterId and captainCharacterId > 0 +end + +function XInfestorExploreTeam:IsFirstFightExist() + local firstFightCharacterId = self.CharacterIds[self.FirstFightPos] + return firstFightCharacterId and firstFightCharacterId > 0 +end + +return XInfestorExploreTeam \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XInvertCardGame/XInvertCardStage.lua b/Resources/Scripts/XEntity/XInvertCardGame/XInvertCardStage.lua new file mode 100644 index 00000000..4dd917fa --- /dev/null +++ b/Resources/Scripts/XEntity/XInvertCardGame/XInvertCardStage.lua @@ -0,0 +1,176 @@ +local XInvertCardStage = XClass(nil, "XInvertCardStage") +local tableRemove = table.remove +local tableInsert = table.insert + +local Default = { + -- Client + Id = 0, + Tmp = {}, -- 配置数据 + -- Sever + Status = XInvertCardGameConfig.InvertCardGameStageStatusType.Lock, -- 关卡状态 + RandomCardList = {}, -- 卡牌列表 + TotalCounts = 0, -- 累积翻牌次数 + InvertList = {}, -- 已翻牌链表 + Progress = 0, -- 关卡进度 + RewardListIdx = {} -- 奖励进度列表 +} + +function XInvertCardStage:Ctor(template, stageData) + for key in pairs(Default) do + self[key] = Default[key] + end + + if template then + self.Tmp = template + self.Id = template.Id + end + + self:RefreshItem(stageData) +end + +function XInvertCardStage:RefreshItem(stageData) + if not stageData then + return + end + + if stageData.Status then + self.Status = stageData.Status + end + + if stageData.RandomCardList then + self.RandomCardList = stageData.RandomCardList + end + + if stageData.TotalCounts then + self.TotalCounts = stageData.TotalCounts + end + + if stageData.InvertList then + self.InvertList = stageData.InvertList + end + + if stageData.Progress then + self.Progress = stageData.Progress + end + + if stageData.RewardListIdx then + self.RewardListIdx = stageData.RewardListIdx + end +end + +-- Begain Get +-- Client +function XInvertCardStage:GetId() + return self.Id +end + +function XInvertCardStage:GetName() + return self.Tmp.Name +end + +function XInvertCardStage:GetRowAndColumnCount() + return self.Tmp.RowCount, self.Tmp.ColumnCount +end + +function XInvertCardStage:GetContainCards() + return self.Tmp.ContainCards +end + +function XInvertCardStage:GetCostCoinNum() + return self.Tmp.CostCoinNum +end + +function XInvertCardStage:GetMaxCostNum() + return self.Tmp.MaxCostNum +end + +function XInvertCardStage:GetTargetNum() + return self.Tmp.TargetNum +end + +function XInvertCardStage:GetFinishProgress() + return self.Tmp.FinishProgress +end + +function XInvertCardStage:GetRewards() + return self.Tmp.Rewards +end + +function XInvertCardStage:GetMaxOnCardsNum() + return self.Tmp.MaxOnCardsNum +end + +function XInvertCardStage:GetFailedPunishNum() + return self.Tmp.FailedPunishNum +end + +function XInvertCardStage:GetClearConditionDesc() + return self.Tmp.ClearConditionDesc +end + +-- Sever +function XInvertCardStage:GetStatus() + return self.Status +end + +function XInvertCardStage:GetRandomCardList() + return self.RandomCardList +end + +function XInvertCardStage:GetTotalCounts() + return self.TotalCounts +end + +function XInvertCardStage:GetInvertList() + return self.InvertList +end + +function XInvertCardStage:GetProgress() + return self.Progress +end + +function XInvertCardStage:GetRewardListIdx() + return self.RewardListIdx +end +-- End Get + +-- Begain Set +function XInvertCardStage:SetProgress(progress) + self.Progress = progress +end + +function XInvertCardStage:SetStatus(status) + self.Status = status +end + +function XInvertCardStage:SetCardFinish(idx) + self:SetCardPunish(idx) + self.RandomCardList[idx].IsFinish = true +end + +function XInvertCardStage:SetCardPunish(idx) + for index, invertIdx in ipairs(self.InvertList) do + if invertIdx == idx then + tableRemove(self.InvertList, index) + end + end +end + +function XInvertCardStage:SetCardInvert(idx) + if self.InvertList then + tableInsert(self.InvertList, idx) + end +end + +function XInvertCardStage:SetRewardListIdx(rewardListIdx) + self.RewardListIdx = rewardListIdx +end + +function XInvertCardStage:AddTotalCounts() + if self.TotalCounts then + self.TotalCounts = self.TotalCounts + 1 + end +end +-- End Set + +return XInvertCardStage \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XItem/XCharacterExpTemplate.lua b/Resources/Scripts/XEntity/XItem/XCharacterExpTemplate.lua new file mode 100644 index 00000000..0a2d529a --- /dev/null +++ b/Resources/Scripts/XEntity/XItem/XCharacterExpTemplate.lua @@ -0,0 +1,34 @@ +local XCharacterExpTemplate = {} + +function XCharacterExpTemplate.New(itemTemplate) + local extendObj = { + UpType = itemTemplate.SubTypeParams[1], + Exp = itemTemplate.SubTypeParams[2], + UpPercentage = itemTemplate.SubTypeParams[3] / 100 - 100, + UpMultiple = itemTemplate.SubTypeParams[3] / 10000 + } + + extendObj.GetExp = function(cardType) + if cardType == extendObj.UpType then + return XMath.ToMinInt(extendObj.Exp * extendObj.UpMultiple) + end + + return extendObj.Exp + end + + return setmetatable({}, { + __metatable = "readonly table", + __index = function(_, k) + if extendObj[k] ~= nil then + return extendObj[k] + else + return itemTemplate[k] + end + end, + __newindex = function() + XLog.Error("attempt to update a readonly table") + end, + }) +end + +return XCharacterExpTemplate \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XItem/XEquipExpTemplate.lua b/Resources/Scripts/XEntity/XItem/XEquipExpTemplate.lua new file mode 100644 index 00000000..3ff7229d --- /dev/null +++ b/Resources/Scripts/XEntity/XItem/XEquipExpTemplate.lua @@ -0,0 +1,33 @@ +local XEquipExpTemplate = {} + +function XEquipExpTemplate.New(itemTemplate) + local extendObj = { + Classify = itemTemplate.SubTypeParams[1], + Exp = itemTemplate.SubTypeParams[2], + Cost = itemTemplate.SubTypeParams[3], + } + + extendObj.GetExp = function() + return extendObj.Exp + end + + extendObj.GetCost = function() + return extendObj.Cost + end + + return setmetatable({}, { + __metatable = "readonly table", + __index = function(_, k) + if extendObj[k] ~= nil then + return extendObj[k] + else + return itemTemplate[k] + end + end, + __newindex = function() + XLog.Error("attempt to update a readonly table") + end, + }) +end + +return XEquipExpTemplate \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XItem/XGiftTemplate.lua b/Resources/Scripts/XEntity/XItem/XGiftTemplate.lua new file mode 100644 index 00000000..4f3d54d5 --- /dev/null +++ b/Resources/Scripts/XEntity/XItem/XGiftTemplate.lua @@ -0,0 +1,22 @@ +local XGiftTemplate = {} + +function XGiftTemplate.New(itemTemplate) + local extendObj = { + GiftType = itemTemplate.SubTypeParams[1], + RewardId = itemTemplate.SubTypeParams[2], + SelectCount = itemTemplate.SubTypeParams[3], + } + + return setmetatable({}, { + __metatable = false, + __index = function(_, k) + if extendObj[k] ~= nil then + return extendObj[k] + else + return itemTemplate[k] + end + end, + }) +end + +return XGiftTemplate \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XItem/XItem.lua b/Resources/Scripts/XEntity/XItem/XItem.lua new file mode 100644 index 00000000..334277f7 --- /dev/null +++ b/Resources/Scripts/XEntity/XItem/XItem.lua @@ -0,0 +1,73 @@ +XItem = XClass(nil, "XItem") + +local Default = { + Id = 0, + Count = 0, + BuyTimes = 0, + RefreshTime = 0, + CreateTime = 0, +} + +function XItem:Ctor(itemData, template) + for key in pairs(Default) do + self[key] = Default[key] + end + + if template then + self.Template = template + self.Id = template.Id + end + + self:RefreshItem(itemData) +end + +function XItem:RefreshItem(itemData) + if not itemData then + return + end + + if itemData.Count then + self:SetCount(itemData.Count) + end + + if itemData.BuyTimes then + self:SetBuyTimes(itemData.BuyTimes) + end + + if itemData.RefreshTime then + self.RefreshTime = itemData.RefreshTime + end + + if itemData.CreateTime then + self.CreateTime = itemData.CreateTime + end +end + +function XItem:SetCount(count) + if self.Count == count then + return + end + + self.Count = count + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_ITEM_COUNT_UPDATE_PREFIX .. self.Id, self.Id, self.Count) + XEventManager.DispatchEvent(XEventId.EVENT_ITEM_COUNT_UPDATE_PREFIX .. self.Id, self.Id, self.Count) +end + +function XItem:SetBuyTimes(buyTimes) + if buyTimes == self.BuyTimes then + return + end + + self.BuyTimes = buyTimes + + XEventManager.DispatchEvent(XEventId.EVENT_ITEM_BUYTIEMS_UPDATE_PREFIX .. self.Id, self.Id, self.BuyTimes) +end + +function XItem:GetCount() + return self.Count +end + +function XItem:GetMaxCount() + return self.Template.MaxCount +end \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XItem/XItemTemplate.lua b/Resources/Scripts/XEntity/XItem/XItemTemplate.lua new file mode 100644 index 00000000..61d51757 --- /dev/null +++ b/Resources/Scripts/XEntity/XItem/XItemTemplate.lua @@ -0,0 +1,29 @@ +local XItemTemplate = {} + + +function XItemTemplate.New(itemTable) + local extendObj = {} + + if itemTable.RecType ~= XResetManager.ResetType.NoNeed then + local secondes, days = XResetManager.GetResetTimeByString(itemTable.RecType, itemTable.RecTime) + extendObj["RecSeconds"] = secondes + extendObj["RecDays"] = days + end + + return setmetatable({}, { + __metatable = "readonly table", + __index = function(_, k) + if extendObj[k] ~= nil then + return extendObj[k] + else + return itemTable[k] + end + end, + __newindex = function() + XLog.Error("attempt to update a readonly table") + end, + }) +end + + +return XItemTemplate \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XItem/XPartnerExpTemplate.lua b/Resources/Scripts/XEntity/XItem/XPartnerExpTemplate.lua new file mode 100644 index 00000000..ef563b2f --- /dev/null +++ b/Resources/Scripts/XEntity/XItem/XPartnerExpTemplate.lua @@ -0,0 +1,32 @@ +local XPartnerExpTemplate = {} + +function XPartnerExpTemplate.New(itemTemplate) + local extendObj = { + Exp = itemTemplate.SubTypeParams[1], + Cost = itemTemplate.SubTypeParams[2], + } + + extendObj.GetExp = function() + return extendObj.Exp + end + + extendObj.GetCost = function() + return extendObj.Cost + end + + return setmetatable({}, { + __metatable = "readonly table", + __index = function(_, k) + if extendObj[k] ~= nil then + return extendObj[k] + else + return itemTemplate[k] + end + end, + __newindex = function() + XLog.Error("attempt to update a readonly table") + end, + }) +end + +return XPartnerExpTemplate \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XItem/XRecItem.lua b/Resources/Scripts/XEntity/XItem/XRecItem.lua new file mode 100644 index 00000000..3623aed8 --- /dev/null +++ b/Resources/Scripts/XEntity/XItem/XRecItem.lua @@ -0,0 +1,106 @@ +XRecItem = XClass(XItem, "XRecItem") + +local max = math.max +local min = math.min +local abs = math.abs + +function XRecItem:Ctor(itemData, template) + if template then + self.Template = template + self.Id = template.Id + end + + self.NextRefreshTime = 0 + self:RefreshItem(itemData) +end + +function XRecItem:GetRecMaxCount() + if self.Id == XDataCenter.ItemManager.ItemId.ActionPoint then + return XPlayerManager.GetMaxActionPoint(XPlayer.GetLevelOrHonorLevel(), XPlayer.IsHonorLevelOpen()) + else + return self.Template.MaxCount + end +end + +function XRecItem:GetMaxCount() + return self:GetRecMaxCount() +end + +function XRecItem:RefreshCount() + local now = XTime.GetServerNowTimestamp() + local second = now - self.RefreshTime + if second < 0 then + return + end + + local recSecond = self.Template.RecSeconds[1] + local recCount = self.Template.RecCount + local addCount = XMath.ToMinInt(second / recSecond * recCount) + local maxCount = max(self.Count, self:GetRecMaxCount()) + + if addCount == 0 then + return + end + + local count = self.Count + addCount + if count >= maxCount then + count = maxCount + self.RefreshTime = now + elseif count <= 0 then + count = 0 + self.RefreshTime = now + else + self.RefreshTime = self.RefreshTime + abs(addCount) * recSecond + end + + self:SetCount(max(min(count, maxCount), 0)) +end + +function XRecItem:CheckRefreshTime() + self.NextRefreshTime = XResetManager.GetNextResetTime(self.Template.RecType, self.RefreshTime, self.Template.RecSeconds, self.Template.RecDays) +end + +function XRecItem:ResetCount() + self.RefreshTime = XTime.GetServerNowTimestamp() + self:SetCount(max(min(self.Template.RecCount + self.Count, self.Template.MaxCount), 0)) + self:CheckRefreshTime() +end + +function XRecItem:CheckCount() + if self.Template.RecType == XResetManager.ResetType.Interval then + self:RefreshCount() + else + if self.NextRefreshTime > 0 then + if XTime.GetServerNowTimestamp() >= self.NextRefreshTime then + self:ResetCount() + end + + return + end + + self:CheckRefreshTime() + + local isReset, _ = CS.XReset.IsTime2Reset(self.Template.RecType, self.RefreshTime, self.Template.RecSeconds, self.Template.RecDays) + if isReset then + self:ResetCount() + end + end +end + +function XRecItem:GetCount() + self:CheckCount() + return self.Count +end + +function XRecItem:GetRefreshResidueSecond() + if self.Count >= self:GetRecMaxCount() then + return 0 + end + + local second = XTime.GetServerNowTimestamp() - self.RefreshTime + if second < 0 then + return 0 + end + + return self.Template.RecSeconds[1] - second +end \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XKillZone/XKillZonePlugin.lua b/Resources/Scripts/XEntity/XKillZone/XKillZonePlugin.lua new file mode 100644 index 00000000..7b96b338 --- /dev/null +++ b/Resources/Scripts/XEntity/XKillZone/XKillZonePlugin.lua @@ -0,0 +1,105 @@ +local type = type +local pairs = pairs + +--[[ +public class XKillZonePluginDb +{ + public int Id; + /// + /// 等级索引 + /// + public int LevelIndex; +} +]] +local Default = { + _Id = 0, --插件Id + _Level = -1, --等级 + _Slot = 0, --穿戴槽位 +} + +local XKillZonePlugin = XClass(nil, "XKillZonePlugin") + +function XKillZonePlugin:Ctor(id) + self:Init(id) +end + +function XKillZonePlugin:Init(id) + for key, value in pairs(Default) do + if type(value) == "table" then + self[key] = {} + else + self[key] = value + end + end + + self._Id = id +end + +function XKillZonePlugin:Reset() + for key, value in pairs(Default) do + if key ~= "_Id" then + if type(value) == "table" then + self[key] = {} + else + self[key] = value + end + end + end +end + +function XKillZonePlugin:UpdateData(info) + self._Level = info.LevelIndex and info.LevelIndex + 1 or self._Level +end + +function XKillZonePlugin:GetLevel() + return self._Level +end + +--获取插件展示等级(包含未解锁/未激活/正常/最大等级) +local MaxLevelStr = CS.XTextManager.GetText("KillZonePlguinMaxLevelStr") +function XKillZonePlugin:GetShowLevelStr() + local level = self._Level + + if self:IsLock() + or self:IsUnActive() + then + level = 1 + end + + if level == XKillZoneConfigs.GetPluginMaxLevel(self._Id) then + return MaxLevelStr + end + + return tostring(level) +end + +function XKillZonePlugin:PutOn(slot) + self._Slot = slot +end + +function XKillZonePlugin:TakeOff() + self._Slot = 0 +end + +--是否未解锁 +function XKillZonePlugin:IsLock() + return self:GetLevel() < 0 +end + +--是否未激活 +function XKillZonePlugin:IsUnActive() + return self:GetLevel() == 0 +end + +--是否达到最大等级 +function XKillZonePlugin:IsMaxLevel() + return self:GetLevel() == XKillZoneConfigs.GetPluginMaxLevel(self._Id) +end + +--获取升级消耗 +function XKillZonePlugin:GetLevelUpCost() + local itemId, itemCount = XKillZoneConfigs.GetPluginLevelUpCost(self._Id, self._Level + 1) + return itemId, itemCount +end + +return XKillZonePlugin \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XKillZone/XKillZoneStage.lua b/Resources/Scripts/XEntity/XKillZone/XKillZoneStage.lua new file mode 100644 index 00000000..ea546109 --- /dev/null +++ b/Resources/Scripts/XEntity/XKillZone/XKillZoneStage.lua @@ -0,0 +1,81 @@ + +local type = type +local pairs = pairs + +--[[ +public class XKillZoneStageDb +{ + public int Id; + + /// + /// 星级统计 + /// + public int Star { get; set; } + + /// + /// 胜利次数 + /// + public int WinCount; + + /// + /// 击败敌人数目 + /// + public int KillEnemyCount; +} +]] +local Default = { + _Id = 0, --关卡Id + _Star = 0, --星级统计 + _WinCount = 0, --胜利次数 + _KillEnemyCount = 0, --击败敌人数目 +} + +local XKillZoneStage = XClass(nil, "XKillZoneStage") + +function XKillZoneStage:Ctor(id) + self:Init(id) +end + +function XKillZoneStage:Init(id) + for key, value in pairs(Default) do + if type(value) == "table" then + self[key] = {} + else + self[key] = value + end + end + + self._Id = id +end + +function XKillZoneStage:UpdateData(info) + self._Star = info.Star or self._Star + self._WinCount = info.WinCount or self._WinCount + self._KillEnemyCount = info.KillEnemyCount or self._KillEnemyCount +end + +function XKillZoneStage:GetId() + return self._Id +end + +function XKillZoneStage:GetKillEnemyCount() + return self._KillEnemyCount +end + +function XKillZoneStage:GetStar() + return self._Star +end + +function XKillZoneStage:GetMaxStar() + return XKillZoneConfigs.GetStageMaxStar(self._Id) +end + +function XKillZoneStage:IsFinishedPerfect() + return self:GetStar() == self:GetMaxStar() +end + +function XKillZoneStage:IsFinished() + return self._WinCount > 0 +end + +return XKillZoneStage \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XLotto/XLottoDrawEntity.lua b/Resources/Scripts/XEntity/XLotto/XLottoDrawEntity.lua new file mode 100644 index 00000000..c4d56b20 --- /dev/null +++ b/Resources/Scripts/XEntity/XLotto/XLottoDrawEntity.lua @@ -0,0 +1,139 @@ +local XLottoDrawEntity = XClass(nil, "XLottoDrawEntity") +local XLottoRewardEntity = require("XEntity/XLotto/XLottoRewardEntity") + +function XLottoDrawEntity:Ctor(id) + self.Id = id + self.ExtraRewardState = XLottoConfigs.ExtraRewardState.CanNotGet--额外奖励状态 + self.RewardDataList = {} + self.LottoRecords = {} + self.LottoRewards = {} + self:CreateRewardDataList() +end + +function XLottoDrawEntity:UpdateData(data) + for key, value in pairs(data) do + self[key] = value + end + self:UpdateRewardDataList() +end + +function XLottoDrawEntity:CreateRewardDataList() + local lottoRewardList = XLottoConfigs.GetLottoRewardListById(self.Id) + for _,reward in pairs(lottoRewardList or {}) do + local entity = XLottoRewardEntity.New(reward.Id) + table.insert(self.RewardDataList,entity) + end + table.sort(self.RewardDataList,function (a, b) + return a:GetPriority() < b:GetPriority() + end) +end + +function XLottoDrawEntity:UpdateRewardDataList() + for _,entity in pairs(self.RewardDataList or {}) do + for _,id in pairs(self.LottoRewards or {}) do + if id == entity:GetId() then + entity:MarkGeted() + break + end + end + end +end + +function XLottoDrawEntity:GetCfg() + return XLottoConfigs.GetLottoCfgById(self.Id) +end + +function XLottoDrawEntity:GetId() + return self.Id +end + +function XLottoDrawEntity:GetLottoRewardList() + return self.LottoRewards +end + +function XLottoDrawEntity:GetExtraRewardState() + return self.ExtraRewardState +end + +function XLottoDrawEntity:GetRewardDataList() + return self.RewardDataList +end + +function XLottoDrawEntity:GetCurRewardCount() + return self.LottoRewards and #self.LottoRewards or 0 +end + +function XLottoDrawEntity:GetMaxRewardCount() + return self.RewardDataList and #self.RewardDataList or 0 +end + +function XLottoDrawEntity:GetLottoRecordList() + return self.LottoRecords +end + +function XLottoDrawEntity:GetTimeId() + return self:GetCfg().TimeId +end + +function XLottoDrawEntity:GetLottoGroupId() + return self:GetCfg().LottoGroupId +end + +function XLottoDrawEntity:GetBanner() + return self:GetCfg().Banner +end + +function XLottoDrawEntity:GetExtraRewardId() + return self:GetCfg().ExtraRewardId +end + +function XLottoDrawEntity:GetExtraRewardCount()----达到额外奖励所需要的抽奖次数 + return self:GetCfg().ReachRewardTimes +end + +function XLottoDrawEntity:GetBuyTicketRuleIdList() + return self:GetCfg().BuyTicketRuleIdList +end + +function XLottoDrawEntity:GetBuyTicketRuleId() + return self:GetCfg().BuyTicketRuleIdList and self:GetCfg().BuyTicketRuleIdList[self:GetCurRewardCount() + 1] or 0 +end + +function XLottoDrawEntity:GetConsumeId() + return self:GetCfg().ConsumeId +end + +function XLottoDrawEntity:GetConsumeCountList() + return self:GetCfg().ConsumeCountList +end + +function XLottoDrawEntity:GetConsumeCount() + return self:GetCfg().ConsumeCountList and self:GetCfg().ConsumeCountList[self:GetCurRewardCount() + 1] or -1 +end + +function XLottoDrawEntity:GetTopRewardData() + local rewardData = {} + for _,data in pairs(self.RewardDataList) do + if data:GetRareLevel() == XLottoConfigs.RareLevel.One then + rewardData = data + break + end + end + return rewardData +end + +function XLottoDrawEntity:IsLottoCountFinish() + return self:GetCurRewardCount() >= self:GetMaxRewardCount() +end + +function XLottoDrawEntity:GetBeginTime() + local time = XFunctionManager.GetStartTimeByTimeId(self:GetTimeId()) + return time +end + +function XLottoDrawEntity:GetEndTime() + local time = XFunctionManager.GetEndTimeByTimeId(self:GetTimeId()) + return time +end + +return XLottoDrawEntity \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XLotto/XLottoGroupEntity.lua b/Resources/Scripts/XEntity/XLotto/XLottoGroupEntity.lua new file mode 100644 index 00000000..c01f32ce --- /dev/null +++ b/Resources/Scripts/XEntity/XLotto/XLottoGroupEntity.lua @@ -0,0 +1,86 @@ +local XLottoGroupEntity = XClass(nil, "XLottoGroupEntity") +local XLottoDrawEntity = require("XEntity/XLotto/XLottoDrawEntity") + +function XLottoGroupEntity:Ctor(id) + self.Id = id + self.CurIndex = 1 --当前逻辑下只可能每一个group中有且仅有一个draw + self.DrawInfoList = {} + self.DrawDataDic = {} +end + +function XLottoGroupEntity:UpdateData(data) + for key, value in pairs(data) do + self[key] = value + end + self:CreateDrawDataDic() +end + +function XLottoGroupEntity:CreateDrawDataDic() + self.DrawDataDic = {} + for _,drawInfo in pairs(self.DrawInfoList) do + local entity = XLottoDrawEntity.New(drawInfo.Id) + entity:UpdateData(drawInfo) + self.DrawDataDic[drawInfo.Id] = entity + end +end + +function XLottoGroupEntity:GetCfg() + return XLottoConfigs.GetLottoGroupRuleCfgById(self.Id) +end + +function XLottoGroupEntity:GetId() + return self.Id +end + +function XLottoGroupEntity:GetDrawData()--当前逻辑下只可能每一个group中有且仅有一个draw + local id = self.DrawInfoList[self.CurIndex].Id + return self.DrawDataDic[id] +end + +function XLottoGroupEntity:GetName() + return self:GetCfg().Name +end + +function XLottoGroupEntity:GetTag() + return self:GetCfg().Tag +end + +function XLottoGroupEntity:GetPriority() + return self:GetCfg().Priority +end + +function XLottoGroupEntity:GetUiType() + return self:GetCfg().UiType +end + +function XLottoGroupEntity:GetGroupBtnBg() + return self:GetCfg().GroupBtnBg +end + +function XLottoGroupEntity:GetUiPrefab() + return self:GetCfg().UiPrefab +end + +function XLottoGroupEntity:GetBanner() + local drawData = self:GetDrawData() + local banner = drawData:GetBanner() + return banner or self:GetCfg().Banner +end + +function XLottoGroupEntity:GetUiBackGround() + return self:GetCfg().UiBackGround +end + +function XLottoGroupEntity:GetRuleHint() + return self:GetCfg().RuleHint +end + +function XLottoGroupEntity:GetBaseRuleTitleList() + return self:GetCfg().BaseRuleTitles +end + +function XLottoGroupEntity:GetBaseRulesList() + return self:GetCfg().BaseRules +end + +return XLottoGroupEntity \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XLotto/XLottoRewardEntity.lua b/Resources/Scripts/XEntity/XLotto/XLottoRewardEntity.lua new file mode 100644 index 00000000..4af96c62 --- /dev/null +++ b/Resources/Scripts/XEntity/XLotto/XLottoRewardEntity.lua @@ -0,0 +1,48 @@ +local XLottoRewardEntity = XClass(nil, "XLottoRewardEntity") + +function XLottoRewardEntity:Ctor(id) + self.Id = id + self.IsGeted = false +end + +function XLottoRewardEntity:MarkGeted() + self.IsGeted = true +end + +function XLottoRewardEntity:GetRewardCfg() + return XLottoConfigs.GetLottoRewardCfgById(self.Id) +end + +function XLottoRewardEntity:GetProbCfg() + return XLottoConfigs.GetLottoProbShowCfgById(self.Id) +end + +function XLottoRewardEntity:GetId() + return self.Id +end + +function XLottoRewardEntity:GetIsGeted() + return self.IsGeted +end + +function XLottoRewardEntity:GetTemplateId() + return self:GetRewardCfg().TemplateId +end + +function XLottoRewardEntity:GetCount() + return self:GetRewardCfg().Count +end + +function XLottoRewardEntity:GetRareLevel() + return self:GetProbCfg().RareLevel +end + +function XLottoRewardEntity:GetPriority() + return self:GetProbCfg().Priority +end + +function XLottoRewardEntity:GetProbShowList() + return self:GetProbCfg().ProbShow +end + +return XLottoRewardEntity \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XMaintainerAction/XBoxNodeEntity.lua b/Resources/Scripts/XEntity/XMaintainerAction/XBoxNodeEntity.lua new file mode 100644 index 00000000..6ef1a882 --- /dev/null +++ b/Resources/Scripts/XEntity/XMaintainerAction/XBoxNodeEntity.lua @@ -0,0 +1,44 @@ +local XMaintainerActionNodeEntity = require("XEntity/XMaintainerAction/XMaintainerActionNodeEntity") +local XBoxNodeEntity = XClass(XMaintainerActionNodeEntity, "XBoxNodeEntity") +local CSTextManagerGetText = CS.XTextManager.GetText + +function XBoxNodeEntity:Ctor() + self.RewardId = 0 +end + +function XBoxNodeEntity:GetRewardId() + return self.RewardId +end + +function XBoxNodeEntity:GetRewardTitle() + return CS.XTextManager.GetText("MaintainerActionBoxReward") +end + +function XBoxNodeEntity:OpenDescTip() + XLuaUiManager.Open("UiFubenMaintaineractionDetailsTips", self, true) +end + +function XBoxNodeEntity:DoEvent(data) + if not data then return end + local gameData = XDataCenter.MaintainerActionManager.GetGameData() + gameData:PlusBoxCount() + + XLuaUiManager.Open("UiFubenMaintaineractionTreasurechest", self:GetRewardId(), nil, + CSTextManagerGetText("MaintainerActionBoxGetTitleText"), + CSTextManagerGetText("MaintainerActionBoxGetSubTitleText"), + gameData:GetBoxCount(), + gameData:GetMaxBoxCount(),function () + local IsAllComplete = XDataCenter.MaintainerActionManager.CheckIsAllComplete() + if IsAllComplete then + XDataCenter.MaintainerActionManager.AddMessageType(XMaintainerActionConfigs.MessageType.EventComplete) + XScheduleManager.ScheduleOnce(function() + XDataCenter.MaintainerActionManager.CheckEventCompleteMessage() + end, 100) + end + end) + + data.player:MarkNodeEvent() + if data.cb then data.cb() end +end + +return XBoxNodeEntity \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XMaintainerAction/XCardChangeNodeEntity.lua b/Resources/Scripts/XEntity/XMaintainerAction/XCardChangeNodeEntity.lua new file mode 100644 index 00000000..52111ed4 --- /dev/null +++ b/Resources/Scripts/XEntity/XMaintainerAction/XCardChangeNodeEntity.lua @@ -0,0 +1,34 @@ +local XMaintainerActionNodeEntity = require("XEntity/XMaintainerAction/XMaintainerActionNodeEntity") +local XCardChangeNodeEntity = XClass(XMaintainerActionNodeEntity, "XCardChangeNodeEntity") +local CSTextManagerGetText = CS.XTextManager.GetText + +function XCardChangeNodeEntity:Ctor() + self.OldCard = 0 + self.NewCard = 0 +end + +function XCardChangeNodeEntity:GetOldCard() + return self.OldCard +end + +function XCardChangeNodeEntity:GetNewCard() + return self.NewCard +end + +function XCardChangeNodeEntity:OpenHintTip(cb) + if self:GetHint() then + XUiManager.TipMsg(string.format(self:GetHint(),self.OldCard,self.NewCard), nil, cb) + else + if cb then cb() end + end +end + +function XCardChangeNodeEntity:DoEvent(data) + if not data then return end + local oldCard = self:GetOldCard() + local newCard = self:GetNewCard() + data.mainUi.BelowPanel:ChangeCard(oldCard, newCard, data.cb) + data.player:MarkNodeEvent() +end + +return XCardChangeNodeEntity \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XMaintainerAction/XDirectionChangeNodeEntity.lua b/Resources/Scripts/XEntity/XMaintainerAction/XDirectionChangeNodeEntity.lua new file mode 100644 index 00000000..5c55d0bf --- /dev/null +++ b/Resources/Scripts/XEntity/XMaintainerAction/XDirectionChangeNodeEntity.lua @@ -0,0 +1,12 @@ +local XMaintainerActionNodeEntity = require("XEntity/XMaintainerAction/XMaintainerActionNodeEntity") +local XDirectionChangeNodeEntity = XClass(XMaintainerActionNodeEntity, "XDirectionChangeNodeEntity") +local CSTextManagerGetText = CS.XTextManager.GetText + +function XDirectionChangeNodeEntity:DoEvent(data) + if not data then return end + data.player:DoChangeDirection() + data.player:MarkNodeEvent() + if data.cb then data.cb() end +end + +return XDirectionChangeNodeEntity \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XMaintainerAction/XExploreNodeEntity.lua b/Resources/Scripts/XEntity/XMaintainerAction/XExploreNodeEntity.lua new file mode 100644 index 00000000..d4e0bf27 --- /dev/null +++ b/Resources/Scripts/XEntity/XMaintainerAction/XExploreNodeEntity.lua @@ -0,0 +1,20 @@ +local XMaintainerActionNodeEntity = require("XEntity/XMaintainerAction/XMaintainerActionNodeEntity") +local XExploreNodeEntity = XClass(XMaintainerActionNodeEntity, "XExploreNodeEntity") +local CSTextManagerGetText = CS.XTextManager.GetText + +function XExploreNodeEntity:Ctor() + self.Node = {} +end + +function XExploreNodeEntity:GetNode() + return self.Node +end + +function XExploreNodeEntity:DoEvent(data) + if not data then return end + data.player:MarkNodeEvent() + XDataCenter.MaintainerActionManager.CreateNode(self:GetNode()) + if data.cb then data.cb() end +end + +return XExploreNodeEntity \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XMaintainerAction/XExtraActionPointNodeEntity.lua b/Resources/Scripts/XEntity/XMaintainerAction/XExtraActionPointNodeEntity.lua new file mode 100644 index 00000000..1d8a6e16 --- /dev/null +++ b/Resources/Scripts/XEntity/XMaintainerAction/XExtraActionPointNodeEntity.lua @@ -0,0 +1,37 @@ +local XMaintainerActionNodeEntity = require("XEntity/XMaintainerAction/XMaintainerActionNodeEntity") +local XExtraActionNodeEntity = XClass(XMaintainerActionNodeEntity, "XExtraActionNodeEntity") +local CSTextManagerGetText = CS.XTextManager.GetText + +function XExtraActionNodeEntity:Ctor() + self.ExtraActionPoint = 0 +end + +function XExtraActionNodeEntity:GetExtraActionCount() + return self.ExtraActionPoint +end + +function XExtraActionNodeEntity:GetName() + return string.format(self:GetCfg().Name,self.ExtraActionPoint) +end + +function XExtraActionNodeEntity:GetDesc() + return string.format(self:GetCfg().DescText,self.ExtraActionPoint) +end + +function XExtraActionNodeEntity:OpenHintTip(cb) + if self:GetHint() then + XUiManager.TipMsg(string.format(self:GetHint(),self.ExtraActionPoint), nil, cb) + else + if cb then cb() end + end +end + +function XExtraActionNodeEntity:DoEvent(data) + if not data then return end + local gameData = XDataCenter.MaintainerActionManager.GetGameData() + gameData:PlusExtraActionCount(self:GetExtraActionCount()) + data.player:MarkNodeEvent() + if data.cb then data.cb() end +end + +return XExtraActionNodeEntity \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XMaintainerAction/XFallBackNodeEntity.lua b/Resources/Scripts/XEntity/XMaintainerAction/XFallBackNodeEntity.lua new file mode 100644 index 00000000..4388cccf --- /dev/null +++ b/Resources/Scripts/XEntity/XMaintainerAction/XFallBackNodeEntity.lua @@ -0,0 +1,45 @@ +local XMaintainerActionNodeEntity = require("XEntity/XMaintainerAction/XMaintainerActionNodeEntity") +local XFallBackNodeEntity = XClass(XMaintainerActionNodeEntity, "XFallBackNodeEntity") +local CSTextManagerGetText = CS.XTextManager.GetText + +function XFallBackNodeEntity:Ctor() + self.Step = 0 + self.TargetNodeId = 0 +end + +function XFallBackNodeEntity:GetStep() + return self.Step +end + +function XFallBackNodeEntity:GetTargetNodeId() + return self.TargetNodeId +end + +function XFallBackNodeEntity:GetName() + return string.format(self:GetCfg().Name,self.Step) +end + +function XFallBackNodeEntity:GetDesc() + return string.format(self:GetCfg().DescText,self.Step) +end + +function XFallBackNodeEntity:OpenHintTip(cb) + if self:GetHint() then + XUiManager.TipMsg(string.format(self:GetHint(),self.Step), nil, cb) + else + if cb then cb() end + end +end + +function XFallBackNodeEntity:DoEvent(data) + if not data then return end + local targetNodeId = self:GetTargetNodeId() + if data.cb then data.cb() end + data.mainUi.IntermediatePanel:ReverseMovePlayerById(XPlayer.Id,targetNodeId,function () + data.mainUi:CheckEvent(targetNodeId, true, function () + if data.cb then data.cb() end + end) + end) +end + +return XFallBackNodeEntity \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XMaintainerAction/XFightNodeEntity.lua b/Resources/Scripts/XEntity/XMaintainerAction/XFightNodeEntity.lua new file mode 100644 index 00000000..c2d6f409 --- /dev/null +++ b/Resources/Scripts/XEntity/XMaintainerAction/XFightNodeEntity.lua @@ -0,0 +1,36 @@ +local XMaintainerActionNodeEntity = require("XEntity/XMaintainerAction/XMaintainerActionNodeEntity") +local XFightNodeEntity = XClass(XMaintainerActionNodeEntity, "XFightNodeEntity") +local CSTextManagerGetText = CS.XTextManager.GetText + +function XFightNodeEntity:Ctor() + self.StageId = 0 +end + +function XFightNodeEntity:GetStageId() + return self.StageId +end + +function XFightNodeEntity:GetRewardId() + local stageCfg = XDataCenter.FubenManager.GetStageCfg(self.StageId) + local stageLevelcfg = XDataCenter.FubenManager.GetStageLevelControl(self.StageId) + return (stageLevelcfg and stageLevelcfg.FinishRewardShow > 0 and stageLevelcfg.FinishRewardShow) or + (stageCfg and stageCfg.FinishRewardShow > 0 and stageCfg.FinishRewardShow) or 0 +end + +function XFightNodeEntity:GetRewardTitle() + return CS.XTextManager.GetText("MaintainerActionFightReward") +end + +function XFightNodeEntity:OpenDescTip() + XLuaUiManager.Open("UiFubenMaintaineractionDetailsTips", self, true) +end + +function XFightNodeEntity:DoEvent(data) + if not data then return end + if not XLuaUiManager.IsUiShow("UiFubenMaintaineractionFighting") then + XLuaUiManager.Open("UiFubenMaintaineractionFighting", self:GetStageId()) + if data.cb then data.cb() end + end +end + +return XFightNodeEntity \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XMaintainerAction/XForwardNodeEntity.lua b/Resources/Scripts/XEntity/XMaintainerAction/XForwardNodeEntity.lua new file mode 100644 index 00000000..8ddad254 --- /dev/null +++ b/Resources/Scripts/XEntity/XMaintainerAction/XForwardNodeEntity.lua @@ -0,0 +1,45 @@ +local XMaintainerActionNodeEntity = require("XEntity/XMaintainerAction/XMaintainerActionNodeEntity") +local XForwardNodeEntity = XClass(XMaintainerActionNodeEntity, "XForwardNodeEntity") +local CSTextManagerGetText = CS.XTextManager.GetText + +function XForwardNodeEntity:Ctor() + self.Step = 0 + self.TargetNodeId = 0 +end + +function XForwardNodeEntity:GetStep() + return self.Step +end + +function XForwardNodeEntity:GetTargetNodeId() + return self.TargetNodeId +end + +function XForwardNodeEntity:GetName() + return string.format(self:GetCfg().Name,self.Step) +end + +function XForwardNodeEntity:GetDesc() + return string.format(self:GetCfg().DescText,self.Step) +end + +function XForwardNodeEntity:OpenHintTip(cb) + if self:GetHint() then + XUiManager.TipMsg(string.format(self:GetHint(),self.Step), nil, cb) + else + if cb then cb() end + end +end + +function XForwardNodeEntity:DoEvent(data) + if not data then return end + local targetNodeId = self:GetTargetNodeId() + if data.cb then data.cb() end + data.mainUi.IntermediatePanel:MovePlayerById(XPlayer.Id,targetNodeId,function () + data.mainUi:CheckEvent(targetNodeId, true, function () + if data.cb then data.cb() end + end) + end) +end + +return XForwardNodeEntity \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XMaintainerAction/XMaintainerActionGameDataEntity.lua b/Resources/Scripts/XEntity/XMaintainerAction/XMaintainerActionGameDataEntity.lua new file mode 100644 index 00000000..168c1a6a --- /dev/null +++ b/Resources/Scripts/XEntity/XMaintainerAction/XMaintainerActionGameDataEntity.lua @@ -0,0 +1,156 @@ +local XMaintainerActionGameDataEntity = XClass(nil, "XMaintainerActionGameDataEntity") +local CSTextManagerGetText = CS.XTextManager.GetText + +function XMaintainerActionGameDataEntity:Ctor() + self.Id = 1--服务器发来的数据会更新 + self.Cards = {} + self.FightWinCount = 0 + self.BoxCount = 0 + self.UsedActionCount = 0 + self.ExtraActionCount = 0 + self.ResetTime = 0 + self.HasWarehouseNode = false + self.WarehouseFinishCount = 0 + self.HasMentorNode = false + --添加字段需要在管理器的数据创建方法中添加相关的赋值 + self.MentorStatus = XMaintainerActionConfigs.MonterNodeStatus.NotActive +end + +function XMaintainerActionGameDataEntity:UpdateData(Data) + for key, value in pairs(Data) do + self[key] = value + end +end + +function XMaintainerActionGameDataEntity:GetId() + return self.Id +end + +function XMaintainerActionGameDataEntity:GetResetTime() + return self.ResetTime +end + +function XMaintainerActionGameDataEntity:GetCards() + return self.Cards +end + +function XMaintainerActionGameDataEntity:GetFightWinCount() + return self.FightWinCount +end + +function XMaintainerActionGameDataEntity:GetBoxCount() + return self.BoxCount +end + +function XMaintainerActionGameDataEntity:GetUsedActionCount() + return self.UsedActionCount +end + +function XMaintainerActionGameDataEntity:GetExtraActionCount() + return self.ExtraActionCount +end + +function XMaintainerActionGameDataEntity:GetHasWarehouseNode() + return self.HasWarehouseNode +end + +function XMaintainerActionGameDataEntity:GetWarehouseFinishCount() + return self.WarehouseFinishCount +end + +function XMaintainerActionGameDataEntity:GetHasMentorNode() + return self.HasMentorNode +end + +function XMaintainerActionGameDataEntity:GetMentorStatus() + return self.MentorStatus +end + +function XMaintainerActionGameDataEntity:GetCfg() + return XMaintainerActionConfigs.GetMaintainerActionTemplateById(self.Id) +end + +function XMaintainerActionGameDataEntity:GetTimeId() + return self:GetCfg().TimeId +end + +function XMaintainerActionGameDataEntity:GetName() + return self:GetCfg().Name +end + +function XMaintainerActionGameDataEntity:GetStoryId() + return self:GetCfg().StoryId +end + +function XMaintainerActionGameDataEntity:GetMaxDailyActionCount() + return self:GetCfg().MaxDailyActionCount +end + +function XMaintainerActionGameDataEntity:GetMaxFightWinCount() + return self:GetCfg().MaxFightWinCount +end + +function XMaintainerActionGameDataEntity:GetMaxBoxCount() + return self:GetCfg().MaxBoxCount +end + +function XMaintainerActionGameDataEntity:GetMaxWarehouseFinishCount() + return self:GetCfg().MaxWarehouseFinishCount +end + +function XMaintainerActionGameDataEntity:GetTeacherMailId() + return self:GetCfg().TeacherMailId +end + +function XMaintainerActionGameDataEntity:GetStudentMailId() + return self:GetCfg().StudentMailId +end + +function XMaintainerActionGameDataEntity:PlusExtraActionCount(num) + self.ExtraActionCount = self.ExtraActionCount + num +end + +function XMaintainerActionGameDataEntity:PlusBoxCount() + self.BoxCount = self.BoxCount + 1 +end + +function XMaintainerActionGameDataEntity:PlusFightWinCount() + self.FightWinCount = self.FightWinCount + 1 +end + +function XMaintainerActionGameDataEntity:PlusWarehouseFinishCount() + self.WarehouseFinishCount = self.WarehouseFinishCount + 1 +end + +function XMaintainerActionGameDataEntity:SetMentorStatus(status) + self.MentorStatus = status +end + +function XMaintainerActionGameDataEntity:CardChange(oldCard,newCard) + for index,card in pairs(self.Cards) do + if card == oldCard then + table.remove(self.Cards, index) + table.insert(self.Cards,newCard) + break + end + end +end + +function XMaintainerActionGameDataEntity:IsFightOver() + return self:GetFightWinCount() >= self:GetMaxFightWinCount() + +end + +function XMaintainerActionGameDataEntity:IsBoxOver() + return self:GetBoxCount() >= self:GetMaxBoxCount() +end + +function XMaintainerActionGameDataEntity:IsWarehouseOver() + return self:GetWarehouseFinishCount() >= self:GetMaxWarehouseFinishCount() +end + +function XMaintainerActionGameDataEntity:IsMentorOver() + return self:GetMentorStatus() == XMaintainerActionConfigs.MonterNodeStatus.Finish +end + +return XMaintainerActionGameDataEntity \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XMaintainerAction/XMaintainerActionNodeEntity.lua b/Resources/Scripts/XEntity/XMaintainerAction/XMaintainerActionNodeEntity.lua new file mode 100644 index 00000000..23cd3add --- /dev/null +++ b/Resources/Scripts/XEntity/XMaintainerAction/XMaintainerActionNodeEntity.lua @@ -0,0 +1,116 @@ +local XMaintainerActionNodeEntity = XClass(nil, "XMaintainerActionNodeEntity") +local CSTextManagerGetText = CS.XTextManager.GetText +local Json = require("XCommon/Json") +function XMaintainerActionNodeEntity:Ctor(id,type) + self.NodeId = id + self.NodeType = type + self.EventId = 0 + self.Value = nil +end + +function XMaintainerActionNodeEntity:UpdateData(Data) + for key, value in pairs(Data) do + self[key] = value + end + if self.Value then + local result = Json.decode(self.Value) + if result then + for key, value in pairs(result) do + self[key] = value + end + end + self.Value = nil + end +end + +function XMaintainerActionNodeEntity:GetCfg() + return XMaintainerActionConfigs.GetMaintainerActionEventTemplateById(self.EventId) +end + +function XMaintainerActionNodeEntity:GetId() + return self.NodeId +end + +function XMaintainerActionNodeEntity:GetType() + return self.NodeType +end + +function XMaintainerActionNodeEntity:GetName() + return self:GetCfg().Name +end + +function XMaintainerActionNodeEntity:GetEventId() + return self.EventId +end + +function XMaintainerActionNodeEntity:GetIsUnKonwn() + return self.NodeType == XMaintainerActionConfigs.NodeType.UnKnow +end + +function XMaintainerActionNodeEntity:GetIsFight() + return self.NodeType == XMaintainerActionConfigs.NodeType.Fight +end + +function XMaintainerActionNodeEntity:GetIsNone() + return self.NodeType == XMaintainerActionConfigs.NodeType.None +end + +function XMaintainerActionNodeEntity:GetIsStart() + return self.NodeType == XMaintainerActionConfigs.NodeType.Start +end + +function XMaintainerActionNodeEntity:GetIsMentor() + return self.NodeType == XMaintainerActionConfigs.NodeType.Mentor +end + +function XMaintainerActionNodeEntity:GetIsNeedPlayAnime() + return not self:GetIsUnKonwn() and + not self:GetIsFight()and + not self:GetIsStart() +end + +function XMaintainerActionNodeEntity:GetHint() + return self:GetCfg().HintText +end + +function XMaintainerActionNodeEntity:GetDesc() + return self:GetCfg().DescText +end + +function XMaintainerActionNodeEntity:GetEventIcon() + return self:GetCfg().EventIcon +end + +function XMaintainerActionNodeEntity:OpenHintTip(cb) + if self:GetHint() then + XUiManager.TipMsg(self:GetHint(), nil, cb) + else + if cb then cb() end + end +end + +function XMaintainerActionNodeEntity:OpenDescTip() + local desc = self:GetDesc() + if desc then + XLuaUiManager.Open("UiFubenMaintaineractionDetailsTips", self, false) + end +end + +function XMaintainerActionNodeEntity:EventRequest(mainUi, player, cb) + XDataCenter.MaintainerActionManager.NodeEventRequest(function (data) + self:UpdateData(data) + self:OpenHintTip(function () + local tmpData = { + player = player, + cb = cb, + mainUi = mainUi + } + self:DoEvent(tmpData) + end) + end,function () + player:MarkNodeEvent() + if cb then cb() end + end) +end + +return XMaintainerActionNodeEntity \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XMaintainerAction/XMaintainerActionPlayerEntity.lua b/Resources/Scripts/XEntity/XMaintainerAction/XMaintainerActionPlayerEntity.lua new file mode 100644 index 00000000..b75d6c11 --- /dev/null +++ b/Resources/Scripts/XEntity/XMaintainerAction/XMaintainerActionPlayerEntity.lua @@ -0,0 +1,65 @@ +local XMaintainerActionPlayerEntity = XClass(nil, "XMaintainerActionPlayerEntity") +local CSTextManagerGetText = CS.XTextManager.GetText + +function XMaintainerActionPlayerEntity:Ctor(id) + self.PlayerId = id + self.PlayerName = "" + self.HeadPortraitId = 0 + self.HeadFrameId = 0 + self.NodeId = 0 + self.Reverse = false + self.IsNodeTriggered = false +end + +function XMaintainerActionPlayerEntity:UpdateData(Data) + for key, value in pairs(Data) do + self[key] = value + end +end + +function XMaintainerActionPlayerEntity:GetPlayerId() + return self.PlayerId +end + +function XMaintainerActionPlayerEntity:GetPlayerName() + return self.PlayerName +end + +function XMaintainerActionPlayerEntity:GetHeadPortraitId() + return self.HeadPortraitId +end + +function XMaintainerActionPlayerEntity:GetHeadFrameId() + return self.HeadFrameId +end + +function XMaintainerActionPlayerEntity:GetPosNodeId() + return self.NodeId +end + +function XMaintainerActionPlayerEntity:GetIsReverse()--是否反向 + return self.Reverse +end + +function XMaintainerActionPlayerEntity:GetIsNodeTriggered()--所在格子是否已被触发 + return self.IsNodeTriggered +end + +function XMaintainerActionPlayerEntity:DoChangeDirection() + self.Reverse = not self.Reverse +end + +function XMaintainerActionPlayerEntity:MarkNodeEvent() + self.IsNodeTriggered = true + XDataCenter.MaintainerActionManager.ClearRecordData() +end + +function XMaintainerActionPlayerEntity:UnMarkNodeEvent() + self.IsNodeTriggered = false +end + +function XMaintainerActionPlayerEntity:MoveTo(nodeId) + self.NodeId = nodeId +end + +return XMaintainerActionPlayerEntity \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XMaintainerAction/XMentorNodeEntity.lua b/Resources/Scripts/XEntity/XMaintainerAction/XMentorNodeEntity.lua new file mode 100644 index 00000000..bfe8d64c --- /dev/null +++ b/Resources/Scripts/XEntity/XMaintainerAction/XMentorNodeEntity.lua @@ -0,0 +1,84 @@ +local XMaintainerActionNodeEntity = require("XEntity/XMaintainerAction/XMaintainerActionNodeEntity") +local XMentorNodeEntity = XClass(XMaintainerActionNodeEntity, "XMentorNodeEntity") +local CSTextManagerGetText = CS.XTextManager.GetText + +function XMentorNodeEntity:Ctor() + self.MemberName = "" + self.MentorStatus = XMaintainerActionConfigs.MonterNodeStatus.NotActive + self.OldEventId = nil +end + +function XMentorNodeEntity:GetMemberName() + return self.MemberName +end + +function XMentorNodeEntity:GetMentorStatus() + return self.MentorStatus +end + +function XMentorNodeEntity:GetOldEventId() + return self.OldEventId +end + +function XMentorNodeEntity:GetOldCfg() + if self.OldEventId then + return XMaintainerActionConfigs.GetMaintainerActionEventTemplateById(self.OldEventId) + else + return XMaintainerActionConfigs.GetMaintainerActionEventTemplateById(self.EventId) + end +end + +function XMentorNodeEntity:GetHint() + return self:GetOldCfg().HintText +end + +function XMentorNodeEntity:GetRewardList() + local rewardList = {} + local gameData = XDataCenter.MaintainerActionManager.GetGameData() + local mentorData = XDataCenter.MentorSystemManager.GetMentorData() + if mentorData:IsTeacher() then + rewardList = XDataCenter.MailManager.GetRewardList(gameData:GetTeacherMailId()) + elseif mentorData:IsStudent() then + rewardList = XDataCenter.MailManager.GetRewardList(gameData:GetStudentMailId()) + end + return rewardList +end + +function XMentorNodeEntity:GetRewardTitle() + return CS.XTextManager.GetText("MaintainerActionMentorReward") +end + +function XMentorNodeEntity:OpenDescTip() + XLuaUiManager.Open("UiFubenMaintaineractionDetailsTips", self, true) +end + +function XMentorNodeEntity:GetDesc() + return string.format(self:GetCfg().DescText,self.MemberName) +end + +function XMentorNodeEntity:DoEvent(data) + if not data then return end + data.player:MarkNodeEvent() + local gameData = XDataCenter.MaintainerActionManager.GetGameData() + gameData:SetMentorStatus(self:GetMentorStatus()) + if data.cb then data.cb() end +end + +function XMentorNodeEntity:EventRequest(mainUi, player, cb) + XDataCenter.MaintainerActionManager.NodeEventRequest(function (data) + self:UpdateData(data) + self:OpenHintTip(function () + local tmpData = { + player = player, + cb = cb, + mainUi = mainUi + } + self:DoEvent(tmpData) + end) + end,function () + player:MarkNodeEvent() + if cb then cb() end + end) +end + +return XMentorNodeEntity \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XMaintainerAction/XNoneNodeEntity.lua b/Resources/Scripts/XEntity/XMaintainerAction/XNoneNodeEntity.lua new file mode 100644 index 00000000..9e97844b --- /dev/null +++ b/Resources/Scripts/XEntity/XMaintainerAction/XNoneNodeEntity.lua @@ -0,0 +1,11 @@ +local XMaintainerActionNodeEntity = require("XEntity/XMaintainerAction/XMaintainerActionNodeEntity") +local XNoneNodeEntity = XClass(XMaintainerActionNodeEntity, "XNoneNodeEntity") +local CSTextManagerGetText = CS.XTextManager.GetText + +function XNoneNodeEntity:DoEvent(data) + if not data then return end + data.player:MarkNodeEvent() + if data.cb then data.cb() end +end + +return XNoneNodeEntity \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XMaintainerAction/XSimulationFightNodeEntity.lua b/Resources/Scripts/XEntity/XMaintainerAction/XSimulationFightNodeEntity.lua new file mode 100644 index 00000000..8f7f879d --- /dev/null +++ b/Resources/Scripts/XEntity/XMaintainerAction/XSimulationFightNodeEntity.lua @@ -0,0 +1,47 @@ +local XMaintainerActionNodeEntity = require("XEntity/XMaintainerAction/XMaintainerActionNodeEntity") +local XSimulationFightNodeEntity = XClass(XMaintainerActionNodeEntity, "XSimulationFightNodeEntity") +local CSTextManagerGetText = CS.XTextManager.GetText +function XSimulationFightNodeEntity:Ctor() + self.RewardGoodsList = {} + self.StageId = {} +end + +function XSimulationFightNodeEntity:GetRewardGoodsList() + return self.RewardGoodsList +end + +function XSimulationFightNodeEntity:GetStageId() + return self.StageId +end + +function XSimulationFightNodeEntity:DoEvent(data) + if not data then return end + local rewardGoodsList = self:GetRewardGoodsList() + local gameData = XDataCenter.MaintainerActionManager.GetGameData() + gameData:PlusFightWinCount() + + XLuaUiManager.Open("UiFubenMaintaineractionTreasurechest", nil, rewardGoodsList, + CSTextManagerGetText("MaintainerActionAutoFightGetTitleText"), + CSTextManagerGetText("MaintainerActionAutoFightGetSubTitleText"), + gameData:GetFightWinCount(), + gameData:GetMaxFightWinCount(),function () + local IsFightComplete = XDataCenter.MaintainerActionManager.CheckIsFightComplete() + local IsAllComplete = XDataCenter.MaintainerActionManager.CheckIsAllComplete() + if IsAllComplete then + XDataCenter.MaintainerActionManager.AddMessageType(XMaintainerActionConfigs.MessageType.EventComplete) + XScheduleManager.ScheduleOnce(function() + XDataCenter.MaintainerActionManager.CheckEventCompleteMessage() + end, 100) + elseif IsFightComplete then + XDataCenter.MaintainerActionManager.AddMessageType(XMaintainerActionConfigs.MessageType.FightComplete) + XScheduleManager.ScheduleOnce(function() + XDataCenter.MaintainerActionManager.CheckFightCompleteMessage() + end, 100) + end + end) + + data.player:MarkNodeEvent() + if data.cb then data.cb() end +end + +return XSimulationFightNodeEntity \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XMaintainerAction/XStartNodeEntity.lua b/Resources/Scripts/XEntity/XMaintainerAction/XStartNodeEntity.lua new file mode 100644 index 00000000..3fd93dda --- /dev/null +++ b/Resources/Scripts/XEntity/XMaintainerAction/XStartNodeEntity.lua @@ -0,0 +1,37 @@ +local XMaintainerActionNodeEntity = require("XEntity/XMaintainerAction/XMaintainerActionNodeEntity") +local XStartNodeEntity = XClass(XMaintainerActionNodeEntity, "XStartNodeEntity") +local CSTextManagerGetText = CS.XTextManager.GetText + +function XStartNodeEntity:Ctor() + self.ExtraActionPoint = 0 +end + +function XStartNodeEntity:GetExtraActionCount() + return self.ExtraActionPoint +end + +function XStartNodeEntity:GetName() + return string.format(self:GetCfg().Name,self.ExtraActionPoint) +end + +function XStartNodeEntity:GetDesc() + return string.format(self:GetCfg().DescText,self.ExtraActionPoint) +end + +function XStartNodeEntity:OpenHintTip(cb) + if self:GetHint() then + XUiManager.TipMsg(string.format(self:GetHint(),self.ExtraActionPoint), nil, cb) + else + if cb then cb() end + end +end + +function XStartNodeEntity:DoEvent(data) + if not data then return end + local gameData = XDataCenter.MaintainerActionManager.GetGameData() + gameData:PlusExtraActionCount(self:GetExtraActionCount()) + data.player:MarkNodeEvent() + if data.cb then data.cb() end +end + +return XStartNodeEntity \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XMaintainerAction/XUnKnowNodeEntity.lua b/Resources/Scripts/XEntity/XMaintainerAction/XUnKnowNodeEntity.lua new file mode 100644 index 00000000..f1c40346 --- /dev/null +++ b/Resources/Scripts/XEntity/XMaintainerAction/XUnKnowNodeEntity.lua @@ -0,0 +1,29 @@ +local XMaintainerActionNodeEntity = require("XEntity/XMaintainerAction/XMaintainerActionNodeEntity") +local XUnKnowNodeEntity = XClass(XMaintainerActionNodeEntity, "XUnKnowNodeEntity") +local CSTextManagerGetText = CS.XTextManager.GetText + +function XUnKnowNodeEntity:DoEvent(data) + if not data then return end + data.player:MarkNodeEvent() + if data.cb then data.cb() end +end + +function XUnKnowNodeEntity:EventRequest(mainUi, player, cb) + XDataCenter.MaintainerActionManager.NodeEventRequest(function (data) + local node = XDataCenter.MaintainerActionManager.CreateNode(data) + node:OpenHintTip(function () + local tmpData = { + player = player, + cb = cb, + mainUi = mainUi + } + node:DoEvent(tmpData) + end) + end,function (data) + XDataCenter.MaintainerActionManager.CreateNode(data) + player:MarkNodeEvent() + if cb then cb() end + end) +end + +return XUnKnowNodeEntity \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XMaintainerAction/XWarehouseNodeEntity.lua b/Resources/Scripts/XEntity/XMaintainerAction/XWarehouseNodeEntity.lua new file mode 100644 index 00000000..a02d0d18 --- /dev/null +++ b/Resources/Scripts/XEntity/XMaintainerAction/XWarehouseNodeEntity.lua @@ -0,0 +1,43 @@ +local XMaintainerActionNodeEntity = require("XEntity/XMaintainerAction/XMaintainerActionNodeEntity") +local XWarehouseNodeEntity = XClass(XMaintainerActionNodeEntity, "XWarehouseNodeEntity") +local CSTextManagerGetText = CS.XTextManager.GetText + +function XWarehouseNodeEntity:Ctor() + self.RewardId = 0 +end + +function XWarehouseNodeEntity:GetRewardId() + return self.RewardId +end + +function XWarehouseNodeEntity:GetRewardTitle() + return CS.XTextManager.GetText("MaintainerActionWarehouseReward") +end + +function XWarehouseNodeEntity:OpenDescTip() + XLuaUiManager.Open("UiFubenMaintaineractionDetailsTips", self, true) +end + +function XWarehouseNodeEntity:DoEvent(data) + if not data then return end + local gameData = XDataCenter.MaintainerActionManager.GetGameData() + gameData:PlusWarehouseFinishCount() + + XLuaUiManager.Open("UiFubenMaintaineractionTreasurechest", self:GetRewardId(), nil, + CSTextManagerGetText("MaintainerActionWarehouseGetTitleText"), + CSTextManagerGetText("MaintainerActionWarehouseGetSubTitleText"), + gameData:GetWarehouseFinishCount(), + gameData:GetMaxWarehouseFinishCount(),function () + local IsAllComplete = XDataCenter.MaintainerActionManager.CheckIsAllComplete() + if IsAllComplete then + XDataCenter.MaintainerActionManager.AddMessageType(XMaintainerActionConfigs.MessageType.EventComplete) + XScheduleManager.ScheduleOnce(function() + XDataCenter.MaintainerActionManager.CheckEventCompleteMessage() + end, 100) + end + end) + data.player:MarkNodeEvent() + if data.cb then data.cb() end +end + +return XWarehouseNodeEntity \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XMentorSystem/XMentorDataEntity.lua b/Resources/Scripts/XEntity/XMentorSystem/XMentorDataEntity.lua new file mode 100644 index 00000000..206f0f69 --- /dev/null +++ b/Resources/Scripts/XEntity/XMentorSystem/XMentorDataEntity.lua @@ -0,0 +1,634 @@ +local XMentorDataEntity = XClass(nil, "XMentorDataEntity") + +function XMentorDataEntity:Ctor() + self.PlayerType = XMentorSystemConfigs.IdentityType.None --玩家类型0无,1老师,2学生 + self:InitManifesto() +end + +function XMentorDataEntity:InitManifesto() + self.Teacher = {}--师傅信息 + self.Students = {}--徒弟信息 + self.ApplyList = {}--申请信息 + self.Tag = {}--个性标签 + self.OnlineTag = {}--在线时段标签 + self.Announcement = ""--宣言 + self.GraduateStudentCount = 0--自己是师父时毕业徒弟数量 + self.StageReward = {}--已领取的出师阶段奖励 + self.WeeklyTaskReward = {}--徒弟每周进度奖励 + self.DailyChangeTaskCount = 0--师傅今天更换了几个任务 + self.WeeklyTaskCompleteCount = 0--徒弟本周已完成几个每周任务 + self.WeeklyLevel = 0 + self.MonthlyStudentCount = 0--本月收徒数量 + self.Message = {MessageText = "", PublishTime = 0} +end + +function XMentorDataEntity:UpdateData(Data) + for key, value in pairs(Data) do + self[key] = value + end +end + +function XMentorDataEntity:GetIdentity() + return self.PlayerType +end + +function XMentorDataEntity:GetTeacherData() + return self.Teacher +end + +function XMentorDataEntity:GetTag() + return self.Tag +end + +function XMentorDataEntity:GetOnlineTag() + return self.OnlineTag +end + +function XMentorDataEntity:GetAnnouncement() + return self.Announcement +end + +function XMentorDataEntity:GetGraduateStudentCount() + return self.GraduateStudentCount +end + +function XMentorDataEntity:GetWeeklyTaskCompleteCount() + return self.WeeklyTaskCompleteCount +end + +function XMentorDataEntity:GetStageReward() + return self.StageReward +end + +function XMentorDataEntity:GetWeeklyTaskReward() + return self.WeeklyTaskReward +end + +function XMentorDataEntity:GetDailyChangeTaskCount() + return self.DailyChangeTaskCount +end + +function XMentorDataEntity:GetWeeklyLevel() + return self.WeeklyLevel +end + +function XMentorDataEntity:GetMonthlyStudentCount() + return self.MonthlyStudentCount +end + +function XMentorDataEntity:GetMessageData() + return self.Message +end + +function XMentorDataEntity:GetWeeklyActivation() + return self.WeeklyActivation +end + +function XMentorDataEntity:GetTeacherGift() + local itemId = XMentorSystemConfigs.GetMentorSystemData("ActivationItemId") + local count = XDataCenter.ItemManager.GetCount(itemId) + return {Id = itemId,Count = count} +end + +function XMentorDataEntity:PlusDailyChangeTaskCount() + self.DailyChangeTaskCount = self.DailyChangeTaskCount +1 +end + +function XMentorDataEntity:AddWeeklyTaskReward(count) + table.insert(self.WeeklyTaskReward,count) +end + +function XMentorDataEntity:AddStageReward(count) + table.insert(self.StageReward,count) +end + +function XMentorDataEntity:WeekReset() + self.WeeklyTaskCompleteCount = 0 + self.WeeklyTaskReward = {} + for _,student in pairs(self.Students or {}) do + student.WeeklyTask = {} + end +end + +function XMentorDataEntity:DayReset() + self.DailyChangeTaskCount = 0 +end + +function XMentorDataEntity:GetLeftStudentCount() + local maxStudentCount = XMentorSystemConfigs.GetMentorSystemData("MaxStudentCount") + return maxStudentCount - self:GetStudentCount() +end + +function XMentorDataEntity:GetStudentDataList() + table.sort(self.Students, function(a, b) + if a.PlayerId == XPlayer.Id or b.PlayerId == XPlayer.Id then + return a.PlayerId == XPlayer.Id + else + if a.IsGraduate ~= b.IsGraduate then + return a.IsGraduate + else + if a.Level ~= b.Level then + return a.Level > b.Level + else + return a.PlayerId > b.PlayerId + end + end + end + end) + return self.Students +end + +function XMentorDataEntity:GetNotGraduateStudentDataList() + local list = {} + for _,student in pairs(self.Students or {}) do + if not student.IsGraduate then + table.insert(list, student) + end + end + table.sort(list, function(a, b) + if a.PlayerId == XPlayer.Id or b.PlayerId == XPlayer.Id then + return a.PlayerId == XPlayer.Id + else + if a.Level ~= b.Level then + return a.Level > b.Level + else + return a.PlayerId > b.PlayerId + end + end + end) + return list +end + +function XMentorDataEntity:CheckStudentSystemTaskIsEnmtyByIndex(index) + local student = self:GetNotGraduateStudentDataByIndex(index) + if student and student.SystemTask and next(student.SystemTask) then + return true + else + return false + end +end + +function XMentorDataEntity:CheckStudentCanSendGiftByIndex(index) + local student = self:GetNotGraduateStudentDataByIndex(index) + if student and student.SendGiftCount == 0 then + return true + else + return false + end +end + +function XMentorDataEntity:GetStudentDataByIndex(index) + return self:GetStudentDataList()[index] +end + +function XMentorDataEntity:GetNotGraduateStudentDataByIndex(index) + return self:GetNotGraduateStudentDataList()[index] +end + +function XMentorDataEntity:GetStudentCount() + local count = 0 + for _,student in pairs(self.Students or {}) do + if not student.IsGraduate then + count = count + 1 + end + end + return count +end + +function XMentorDataEntity:GetStudentSystemTaskCountByIndex(index)--本日接受的任务 + local studentData = self:GetNotGraduateStudentDataByIndex(index) + local count = 0 + if studentData then + local taskList = studentData.SystemTask + for _,task in pairs(taskList or {})do + if task.Status > XMentorSystemConfigs.TaskStatus.Init then + count = count + 1 + end + end + end + return count +end + +function XMentorDataEntity:GetStudentWeeklyTaskCountByIndex(index)--本周接受的任务 + local studentData = self:GetNotGraduateStudentDataByIndex(index) + local count = 0 + if studentData then + count = #studentData.WeeklyTask + end + return count +end + +function XMentorDataEntity:GetStudentWeeklyTaskCompleteCountByIndex(index)--本周的任务完成数 + local studentData = self:GetNotGraduateStudentDataByIndex(index) + local count = 0 + if studentData then + local taskList = studentData.WeeklyTask + for _,task in pairs(taskList or {})do + if task.Status ~= XMentorSystemConfigs.TaskStatus.Init and + task.Status ~= XMentorSystemConfigs.TaskStatus.Received then + count = count + 1 + end + end + end + return count +end + +function XMentorDataEntity:GetTeacherStageRewardList() + local stageRewards = XMentorSystemConfigs.GetMasterStageRewards() + local list = {} + for _,reward in pairs(stageRewards or {}) do + table.insert(list,reward) + end + table.sort(list, function(a, b) + return a.Count < b.Count + end) + return list +end + +function XMentorDataEntity:GetLastTeacherStageRewardCount() + local list = self:GetTeacherStageRewardList() + return list[#list].Count +end + +function XMentorDataEntity:GetTeacherStageRewardNum() + local list = self:GetTeacherStageRewardList() + return #list +end + +function XMentorDataEntity:GetTeacherStageRewardTotalPercent() + local maxCount = self:GetLastTeacherStageRewardCount() + local percent = self.GraduateStudentCount / maxCount + return percent <= 1 and percent or 1 +end + +function XMentorDataEntity:GetTeacherStageRewardAVGTotalPercent() + local dataList = self:GetTeacherStageRewardList() + local curBai = 0 + local curTotal = self:GetLastTeacherStageRewardCount() + for index,data in pairs(dataList or {}) do + if self.GraduateStudentCount > data.Count then + curBai = index + else + curTotal = data.Count + break + end + end + + local percent = (curBai + (self.GraduateStudentCount / curTotal)) / #dataList + return percent <= 1 and percent or 1 +end + +function XMentorDataEntity:GetTeacherStageRewardPercentByCount(count) + local maxCount = self:GetLastTeacherStageRewardCount() + local percent = count / maxCount + return percent <= 1 and percent or 1 +end + +function XMentorDataEntity:GetTeacherStageRewardPercentByIndex(index) + local maxNum = self:GetTeacherStageRewardNum() + local percent = maxNum > 0 and index / maxNum or 0 + return percent <= 1 and percent or 1 +end + + +function XMentorDataEntity:CheckTeacherStageRewardCanGetByCount(count) + return self.GraduateStudentCount >= count +end + +function XMentorDataEntity:CheckTeacherStageRewardGetedByCount(count) + local IsGeted = false + for _,tmpCount in pairs(self.StageReward or {}) do + if tmpCount == count then + IsGeted = true + break + end + end + return IsGeted +end + +function XMentorDataEntity:GetStudentWeeklyRewardList() + local weeklyRewards = XMentorSystemConfigs.GetStudentWeeklyRewards() + local list = {} + local curLevel = 0 + for _,reward in pairs(weeklyRewards or {}) do + list[reward.Level] = list[reward.Level] or {} + table.insert(list[reward.Level],reward) + end + for level,group in pairs(list or {}) do + if self.WeeklyLevel >= level and level > curLevel then + curLevel = level + end + table.sort(group, function(a, b) + return a.Count < b.Count + end) + end + + return list[curLevel] +end + +function XMentorDataEntity:GetLastStudentWeeklyRewardCount() + local list = self:GetStudentWeeklyRewardList() + return list[#list].Count +end + +function XMentorDataEntity:GetStudentWeeklyRewardTotalPercent() + local maxCount = self:GetLastStudentWeeklyRewardCount() + local percent = self.WeeklyTaskCompleteCount / maxCount + return percent <= 1 and percent or 1 +end + +function XMentorDataEntity:GetStudentWeeklyRewardPercentByCount(count) + local maxCount = self:GetLastStudentWeeklyRewardCount() + local percent = count / maxCount + return percent <= 1 and percent or 1 +end + +function XMentorDataEntity:CheckStudentWeeklyRewardCanGetByCount(count) + return self.WeeklyTaskCompleteCount >= count +end + +function XMentorDataEntity:CheckStudentWeeklyRewardGetedByCount(count) + local IsGeted = false + for _,tmpCount in pairs(self.WeeklyTaskReward or {}) do + if tmpCount == count then + IsGeted = true + break + end + end + return IsGeted +end + +function XMentorDataEntity:AddTeacher(teacher,students,message) + self.Teacher = teacher + self.Students = students or {} + self.Message = message +end + +function XMentorDataEntity:RemoveTeacher() + self.Teacher = {} + for index = #self.Students, 1, -1 do + if self.Students[index].PlayerId ~= XPlayer.Id then + table.remove(self.Students,index) + end + end +end + +function XMentorDataEntity:AddStudent(student) + table.insert(self.Students,student) +end + +function XMentorDataEntity:RemoveStudent(student) + for index = #self.Students, 1, -1 do + if self.Students[index].PlayerId == student.PlayerId then + table.remove(self.Students,index) + break + end + end +end + +function XMentorDataEntity:GraduateStudent(student) + for index,tmpStudent in pairs(self.Students or {}) do + if tmpStudent.PlayerId == student.PlayerId and not tmpStudent.IsGraduate then + tmpStudent.IsGraduate = true + self.GraduateStudentCount = self.GraduateStudentCount + 1 + break + end + end +end + +function XMentorDataEntity:UpdateStudentSystemTaskById(systemTask, id)--新学生的系统发布任务 + for index,student in pairs(self.Students or {}) do + if student.PlayerId == id then + student.SystemTask = systemTask + break + end + end +end + +function XMentorDataEntity:UpdateStudentWeeklyTaskById(weeklyTask, id)--更新学生的已接任务 + for index,student in pairs(self.Students or {}) do + if student.PlayerId == id then + student.WeeklyTask = weeklyTask + break + end + end +end + +function XMentorDataEntity:UpdateMemberLevelById(level, id)--更新学生的等级 + if self.Teacher.PlayerId == id then + self.Teacher.Level = level + return + end + for index,student in pairs(self.Students or {}) do + if student.PlayerId == id then + student.Level = level + break + end + end +end + +function XMentorDataEntity:UpdateStudentSendGiftCount(id)--更新学生送礼数量 + for index,student in pairs(self.Students or {}) do + if student.PlayerId == id then + student.SendGiftCount = 1 + break + end + end +end + +function XMentorDataEntity:UpdateMemberOnLineState(IsOnLine, lastLoginTime, id)--更新学生的在线状况 + if self.Teacher.PlayerId == id then + self.Teacher.IsOnline = IsOnLine + self.Teacher.LastLoginTime = lastLoginTime + return + end + for index,student in pairs(self.Students or {}) do + if student.PlayerId == id then + student.IsOnline = IsOnLine + student.LastLoginTime = lastLoginTime + break + end + end +end + +function XMentorDataEntity:GetApplyList() + return self.ApplyList +end + +function XMentorDataEntity:GetApplyIdList() + local idList = {} + for _,tmp in pairs(self.ApplyList or {}) do + if not XDataCenter.SocialManager.GetBlackData(tmp.ApplyId) then + table.insert(idList, tmp.ApplyId) + end + end + return idList +end + +function XMentorDataEntity:AddApplyId(apply) + local IsNotIn = true + for _,tmp in pairs(self.ApplyList or {}) do + if tmp.ApplyId == apply.ApplyId then + IsNotIn = false + break + end + end + if IsNotIn then + table.insert(self.ApplyList,apply) + end + return IsNotIn +end + +function XMentorDataEntity:RemoveApplyId(applyId) + for index = #self.ApplyList, 1, -1 do + if self.ApplyList[index].ApplyId == applyId then + table.remove(self.ApplyList,index) + end + end +end + +function XMentorDataEntity:ClearApplyIdList() + self.ApplyList = {} +end + +function XMentorDataEntity:IsTeacher() + return self.PlayerType == XMentorSystemConfigs.IdentityType.Teacher +end + +function XMentorDataEntity:IsStudent() + return self.PlayerType == XMentorSystemConfigs.IdentityType.Student +end + +function XMentorDataEntity:IsMyMentorShip(id) + local IsMy = false + local studentList = self:GetNotGraduateStudentDataList() + for _,student in pairs(studentList or {}) do + if student.PlayerId == id then + IsMy = true + break + end + end + + IsMy = IsMy or (self.Teacher and self.Teacher.PlayerId == id) + return IsMy +end + +function XMentorDataEntity:GetMenberLastLoginTimeById(id) + local lastLoginTime = 0 + local IsMy = false + local studentList = self:GetNotGraduateStudentDataList() + for _,student in pairs(studentList or {}) do + if student.PlayerId == id then + lastLoginTime = student.LastLoginTime + IsMy = true + break + end + end + + if lastLoginTime == 0 and (self.Teacher and self.Teacher.PlayerId == id) then + lastLoginTime = self.Teacher.LastLoginTime + IsMy = true + end + + if not IsMy then + XLog.Error("This Player Is Not Own MentorShip") + end + + return lastLoginTime +end + +function XMentorDataEntity:IsHasApply() + local applyIdList = self:GetApplyIdList() + if not XTool.IsTableEmpty(applyIdList) then + return true + else + return false + end +end + +function XMentorDataEntity:IsHasTeacher() + if next(self.Teacher) and self.Teacher.PlayerId and self.Teacher.PlayerId > 0 then + return true + else + return false + end +end + +function XMentorDataEntity:IsHasStudent() + if self:GetStudentCount() > 0 then + return true + else + return false + end +end + +function XMentorDataEntity:IsStudentFull() + local maxStudentCount = XMentorSystemConfigs.GetMentorSystemData("MaxStudentCount") + if self:GetStudentCount() >= maxStudentCount then + return true + else + return false + end +end + +function XMentorDataEntity:IsCanDoApply(IsShowHint) + if self.PlayerType == XMentorSystemConfigs.IdentityType.Teacher then + if self:IsStudentFull() then + if IsShowHint then + XUiManager.TipText("MentorStudentFullText") + end + return false + end + elseif self.PlayerType == XMentorSystemConfigs.IdentityType.Student then + if self:IsHasTeacher() then + if IsShowHint then + XUiManager.TipText("MentorTeacherFullText") + end + return false + end + local graduateLv = XMentorSystemConfigs.GetMentorSystemData("GraduateLv") + if XPlayer.Level >= graduateLv then + if IsShowHint then + XUiManager.TipText("MentorStudentCandApplyOfGraduationedText") + end + return false + end + elseif self.PlayerType == XMentorSystemConfigs.IdentityType.None then + return false + end + return true +end + +function XMentorDataEntity:CheckIdentity(IsShowHint)--检查玩家是否拥有身份 + if self.PlayerType == XMentorSystemConfigs.IdentityType.None then + local beStudentLv = XMentorSystemConfigs.GetMentorSystemData("BeStudentLv") + if IsShowHint then + XUiManager.TipText("MentorSystemPreStudentHint",beStudentLv) + end + return false + end + return true +end + +function XMentorDataEntity:CheckCanUseChat(IsShowHint)--检查玩家是否能使用聊天 + if self.PlayerType == XMentorSystemConfigs.IdentityType.Teacher then + if not self:IsHasStudent() then + if IsShowHint then + XUiManager.TipText("MentorSystemNoStudentHint") + end + return false + end + elseif self.PlayerType == XMentorSystemConfigs.IdentityType.Student then + if not self:IsHasTeacher() then + if IsShowHint then + XUiManager.TipText("MentorSystemNoMentorHint") + end + return false + end + elseif self.PlayerType == XMentorSystemConfigs.IdentityType.None then + return false + end + return true +end + +return XMentorDataEntity \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XMineSweeping/XMineSweepingChapter.lua b/Resources/Scripts/XEntity/XMineSweeping/XMineSweepingChapter.lua new file mode 100644 index 00000000..35247723 --- /dev/null +++ b/Resources/Scripts/XEntity/XMineSweeping/XMineSweepingChapter.lua @@ -0,0 +1,248 @@ +local XMineSweepingChapter = XClass(nil, "XMineSweepingChapter") +local XMineSweepingStage = require("XEntity/XMineSweeping/XMineSweepingStage") +local XMineSweepingGrid = require("XEntity/XMineSweeping/XMineSweepingGrid") +function XMineSweepingChapter:Ctor(id) + self.ChapterId = id + self.ChallengeCounts = 0 + self.ChapterStatus = XMineSweepingConfigs.StageState.Prepare --章节状态就取自当前关卡状态 + + self.ActivityStageList = {} + self.StageEntityDic = {} + self.CurActivityStageId = 0 + + self.AllGridEntityDic = {} + self.CurGridEntityDic = {} + self.CurGridList = {} + + self.IsChapterLock = true + self.IsInit = true +end + +function XMineSweepingChapter:UpdateData(data) + for key, value in pairs(data or {}) do + self[key] = value + end + + if data["ActivityStageList"] then + self:UpdateAllStageData() + end + + self:UpdateCurActivityStageId() + + if self.IsInit then + self:UpdateAllGridData() + self.IsInit = false + end + + if data["CurGridList"] then + self:UpdateCurGridData() + end + + if data["ActivityStageList"] then + self:UpdateChapterStatus() + end +end + +function XMineSweepingChapter:CreateAllStageData() + for _,stageId in pairs(self:GetActivityStageIds() or {}) do + if not self.StageEntityDic[stageId] then + self.StageEntityDic[stageId] = XMineSweepingStage.New(stageId) + end + end +end + +function XMineSweepingChapter:UpdateAllStageData() + for _,stageInfo in pairs(self.ActivityStageList or {}) do + local id = stageInfo.ActivityStageId + if self.StageEntityDic[id] then + self.StageEntityDic[id]:UpdateData(stageInfo) + end + end + self:UpdateStageLock() +end + +function XMineSweepingChapter:UpdateAllGridData() + local curStageId = self.CurActivityStageId + if not self.AllGridEntityDic[curStageId] then + self.AllGridEntityDic[curStageId] = {} + local curStageEntity = self.StageEntityDic[curStageId] + if curStageEntity and next(curStageEntity) then + local rowCount = curStageEntity:GetRowCount() + local columnCount = curStageEntity:GetColumnCount() + for y = 1, rowCount do + for x = 1, columnCount do + local entity = XMineSweepingGrid.New(x, y) + local key = XMineSweepingConfigs.GetGridKeyByPos(x, y) + self.AllGridEntityDic[curStageId][key] = entity + end + end + end + end + self.CurGridEntityDic = self.AllGridEntityDic[curStageId] +end + +function XMineSweepingChapter:UpdateCurGridData() + for _,gridData in pairs(self.CurGridList or {}) do + local key = XMineSweepingConfigs.GetGridKeyByPos(gridData.XIndex, gridData.YIndex) + local entity = self.CurGridEntityDic and self.CurGridEntityDic[key] + if entity then + entity:UpdateData(gridData) + end + end +end + +function XMineSweepingChapter:UpdateStageLock() + for _,entity in pairs(self.StageEntityDic or {}) do + local preStage = XDataCenter.MineSweepingManager.GetPreStageByStageId(entity:GetStageId()) + if preStage and (not next(preStage) or preStage:IsFinish()) then + entity:UpdateData({IsStageLock = false}) + end + end +end + +function XMineSweepingChapter:GetGridEntityByPos(x, y) + local key = XMineSweepingConfigs.GetGridKeyByPos(x, y) + return self.CurGridEntityDic and self.CurGridEntityDic[key] +end + +function XMineSweepingChapter:ResetGrid() + self:UpdateAllGridData() + + for _,gridEntity in pairs(self.CurGridEntityDic or {}) do + gridEntity:ResetGridType() + end +end + +function XMineSweepingChapter:UpdateCurActivityStageId() + for _,id in pairs(self:GetActivityStageIds() or {}) do + self.CurActivityStageId = id + if not self.StageEntityDic[id]:IsFinish() then + break + end + end +end + +function XMineSweepingChapter:UpdateChapterStatus() + local curStageEntity = self:GetCurStageEntity() + self.ChapterStatus = curStageEntity:GetStageStatus() + self.IsChapterLock = curStageEntity:IsLock() +end + +function XMineSweepingChapter:GetChapterId() + return self.ChapterId +end + +function XMineSweepingChapter:GetChallengeCounts() + return self.ChallengeCounts +end + +function XMineSweepingChapter:GetCurStageEntity() + return self.StageEntityDic[self.CurActivityStageId] +end + +function XMineSweepingChapter:GetStageEntityDic() + return self.StageEntityDic +end + +function XMineSweepingChapter:GetStageEntityById(id) + return self.StageEntityDic[id] +end + +function XMineSweepingChapter:GetCurGridList() + return self.CurGridList +end + +function XMineSweepingChapter:GetAllGridEntityDic() + return self.AllGridEntityDic +end + +function XMineSweepingChapter:GetActivityStageList() + return self.ActivityStageList +end + +function XMineSweepingChapter:GetStageIndexById(id) + for index,stageId in pairs(self:GetActivityStageIds()) do + if id == stageId then + return index + end + end + return +end + +function XMineSweepingChapter:IsLock() + return self.IsChapterLock +end + +function XMineSweepingChapter:IsPrepare() + return self.ChapterStatus == XMineSweepingConfigs.StageState.Prepare +end + +function XMineSweepingChapter:IsSweeping() + return self.ChapterStatus == XMineSweepingConfigs.StageState.Sweeping +end + +function XMineSweepingChapter:IsFinish() + return self.ChapterStatus == XMineSweepingConfigs.StageState.Finish +end + +function XMineSweepingChapter:IsFailed() + return self.ChapterStatus == XMineSweepingConfigs.StageState.Failed +end + +function XMineSweepingChapter:GetCfg() + return XMineSweepingConfigs.GetMineSweepingChapterById(self.ChapterId) +end + +function XMineSweepingChapter:GetName() + return self:GetCfg().Name +end + +function XMineSweepingChapter:GetNameEn() + return self:GetCfg().NameEn +end + +function XMineSweepingChapter:GetActivityStageIds() + return self:GetCfg().ActivityStageIds +end + +function XMineSweepingChapter:GetActivityStageIdByIndex(index) + return self:GetCfg().ActivityStageIds[index] +end + +function XMineSweepingChapter:GetStageCount() + return #self:GetCfg().ActivityStageIds +end + +function XMineSweepingChapter:GetShowActivityStageIds() + return self:GetCfg().ShowActivityStageIds +end + +function XMineSweepingChapter:GetShowActivityStageIdByIndex(index) + return self:GetCfg().ShowActivityStageIds[index] +end + +function XMineSweepingChapter:GetCompleteStoryId() + return self:GetCfg().CompleteStoryId +end + +function XMineSweepingChapter:GetCompleteImg() + return self:GetCfg().CompletePicture +end + +function XMineSweepingChapter:GetAllMineImg() + return self:GetCfg().AllMinePicture +end + +function XMineSweepingChapter:GetMineEffect() + return self:GetCfg().MineEffect +end + +function XMineSweepingChapter:GetWinGridEffect() + return self:GetCfg().WinGridEffect +end + +function XMineSweepingChapter:GetMineIcon() + return self:GetCfg().MineIcon +end + +return XMineSweepingChapter \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XMineSweeping/XMineSweepingGame.lua b/Resources/Scripts/XEntity/XMineSweeping/XMineSweepingGame.lua new file mode 100644 index 00000000..100ec399 --- /dev/null +++ b/Resources/Scripts/XEntity/XMineSweeping/XMineSweepingGame.lua @@ -0,0 +1,148 @@ +local XMineSweepingGame = XClass(nil, "XMineSweepingGame") +local XMineSweepingChapter = require("XEntity/XMineSweeping/XMineSweepingChapter") + +function XMineSweepingGame:Ctor() + self.ActivityId = self:GetDefaultId() + self.MineSweepingList = {} + self.ChapterEntityDic = {} +end + +function XMineSweepingGame.GetDefaultId() + local defaultId = 0 + local spareId = 0 + local nowTime = XTime.GetServerNowTimestamp() + local activityCfgs = XMineSweepingConfigs.GetMineSweepingActivityCfgs() + local miniEndTime + local MaxBeginTime + for id,cfg in pairs(activityCfgs) do + local beginTime, endTime = XFunctionManager.GetTimeByTimeId(cfg.TimeId) + if endTime > nowTime then + if miniEndTime == nil or miniEndTime == 0 or endTime < miniEndTime then + defaultId = id + miniEndTime = endTime + end + else + if endTime == 0 then + if miniEndTime == nil then + defaultId = id + miniEndTime = endTime + end + end + end + + if MaxBeginTime == nil or beginTime > MaxBeginTime then + spareId = id + MaxBeginTime = beginTime + end + end + + defaultId = defaultId == 0 and spareId or defaultId + + return defaultId +end + +function XMineSweepingGame:UpdateData(data) + for key, value in pairs(data or {}) do + self[key] = value + if key == "MineSweepingList" then + self:CreateChapterData() + self:UpdateChapterData() + end + end +end + +function XMineSweepingGame:CreateChapterData() + for _,chapterData in pairs(self.MineSweepingList) do + local entity = self.ChapterEntityDic[chapterData.ActivityChapterId] + if not entity then + entity = XMineSweepingChapter.New(chapterData.ActivityChapterId) + entity:CreateAllStageData() + self.ChapterEntityDic[chapterData.ActivityChapterId] = entity + end + end + self:CreatePreStageDic() +end + +function XMineSweepingGame:UpdateChapterData() + for _,chapterData in pairs(self.MineSweepingList) do + local entity = self.ChapterEntityDic[chapterData.ActivityChapterId] + if entity then + entity:UpdateData(chapterData) + end + end +end + +function XMineSweepingGame:CreatePreStageDic() + self.PreStageDic = {} + local exChapterLastStage + for _,chapterId in pairs(self:GetChapterIds() or {}) do + local chapterEntity = self.ChapterEntityDic[chapterId] + local stageIdList = chapterEntity and chapterEntity:GetActivityStageIds() + for stageIndex,stageId in pairs(stageIdList or {}) do + local stageEntity = chapterEntity:GetStageEntityById(stageId) + if stageIndex == 1 then + if exChapterLastStage then + self.PreStageDic[stageId] = exChapterLastStage + else + self.PreStageDic[stageId] = {} + end + else + self.PreStageDic[stageId] = chapterEntity:GetStageEntityById(stageIdList[stageIndex - 1]) + end + exChapterLastStage = stageEntity + end + end +end + +function XMineSweepingGame:GetActivityId() + return (not self.ActivityId or self.ActivityId == 0) and self:GetDefaultId() or self.ActivityId +end + +function XMineSweepingGame:GetMineSweepingList() + return self.MineSweepingList +end + +function XMineSweepingGame:GetChapterEntityDic() + return self.ChapterEntityDic +end + +function XMineSweepingGame:GetPreStageDic() + return self.PreStageDic +end + +function XMineSweepingGame:GetNewChapterIndex() + local tagIndex = 0 + for index, id in pairs(self:GetChapterIds()) do + local chapterEntity = self.ChapterEntityDic[id] + if chapterEntity and not chapterEntity:IsLock() then + tagIndex = index + end + end + return tagIndex +end + +function XMineSweepingGame:GetChapterEntityById(id) + return self.ChapterEntityDic and self.ChapterEntityDic[id] +end + +function XMineSweepingGame:GetCfg() + return XMineSweepingConfigs.GetMineSweepingActivityById(self:GetActivityId()) +end + +function XMineSweepingGame:GetTimeId() + return self:GetCfg().TimeId +end + +function XMineSweepingGame:GetCoinItemId() + return self:GetCfg().CoinItemId +end + +function XMineSweepingGame:GetChapterIds() + return self:GetCfg().ChapterIds +end + +function XMineSweepingGame:GetChapterIdByIndex(index) + return self:GetCfg().ChapterIds[index] +end + +return XMineSweepingGame \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XMineSweeping/XMineSweepingGrid.lua b/Resources/Scripts/XEntity/XMineSweeping/XMineSweepingGrid.lua new file mode 100644 index 00000000..de270e08 --- /dev/null +++ b/Resources/Scripts/XEntity/XMineSweeping/XMineSweepingGrid.lua @@ -0,0 +1,45 @@ +local XMineSweepingGrid = XClass(nil, "XMineSweepingGrid") + +function XMineSweepingGrid:Ctor(x, y) + self.XIndex = x + self.YIndex = y + self.Type = XMineSweepingConfigs.GridType.Unknown + self.RoundMineNumber = 0 +end + +function XMineSweepingGrid:UpdateData(data) + for key, value in pairs(data or {}) do + self[key] = value + end +end + +function XMineSweepingGrid:GetPosIndex() + return self.XIndex, self.YIndex +end + +function XMineSweepingGrid:IsUnknown() + return self.Type == XMineSweepingConfigs.GridType.Unknown +end + +function XMineSweepingGrid:IsSafe() + return self.Type == XMineSweepingConfigs.GridType.Safe +end + +function XMineSweepingGrid:IsMine() + return self.Type == XMineSweepingConfigs.GridType.Mine +end + +function XMineSweepingGrid:IsFlag() + return self.Type == XMineSweepingConfigs.GridType.Flag +end + +function XMineSweepingGrid:ResetGridType() + self.Type = XMineSweepingConfigs.GridType.Unknown + self.RoundMineNumber = 0 +end + +function XMineSweepingGrid:GetRoundMineNumber() + return self.RoundMineNumber +end + +return XMineSweepingGrid \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XMineSweeping/XMineSweepingStage.lua b/Resources/Scripts/XEntity/XMineSweeping/XMineSweepingStage.lua new file mode 100644 index 00000000..632a76e7 --- /dev/null +++ b/Resources/Scripts/XEntity/XMineSweeping/XMineSweepingStage.lua @@ -0,0 +1,101 @@ +local XMineSweepingStage = XClass(nil, "XMineSweepingStage") + +function XMineSweepingStage:Ctor(id) + self.StageId = id + self.WhiteGridTotalNumber = 1--白色格总数(胜利条件) + self.AllowMineNumber = 1--允许踩到雷格最大数(失败条件) + self.WhiteGridOpenNumber = 0--已翻开白色格数 + self.MineGridOpenNumber = 0--已翻开雷格数 + self.FailedCounts = 0--已失败次数 + self.Status = XMineSweepingConfigs.StageState.Prepare --此状态代表关卡状态,章节状态就取自当前关卡状态 + self.IsStageLock = true +end + +function XMineSweepingStage:UpdateData(data) + for key, value in pairs(data or {}) do + self[key] = value + end +end + +function XMineSweepingStage:GetStageId() + return self.StageId +end + +function XMineSweepingStage:GetWhiteGridTotalNumber() + return self.WhiteGridTotalNumber +end + +function XMineSweepingStage:GetAllowMineNumber() + return self.AllowMineNumber +end + +function XMineSweepingStage:GetWhiteGridOpenNumber() + return self.WhiteGridOpenNumber +end + +function XMineSweepingStage:GetMineGridOpenNumber() + return self.MineGridOpenNumber +end + +function XMineSweepingStage:GetFailedCounts() + return self.FailedCounts +end + +function XMineSweepingStage:GetStageStatus() + return self.Status +end + +function XMineSweepingStage:IsOngoing() + return not self:IsFinish() and not self:IsFailed() +end + +function XMineSweepingStage:IsLock() + return self.IsStageLock +end + +function XMineSweepingStage:IsFinish() + return self.Status == XMineSweepingConfigs.StageState.Finish +end + +function XMineSweepingStage:IsFailed() + return self.Status == XMineSweepingConfigs.StageState.Failed +end + +function XMineSweepingStage:GetCfg() + return XMineSweepingConfigs.GetMineSweepingStageById(self.StageId) +end + +function XMineSweepingStage:GetName() + local tmpName = self:GetCfg().Name + return string.gsub(tmpName,"_","-") +end + +function XMineSweepingStage:GetCostCoinNum() + return self:GetCfg().CostCoinNum +end + +function XMineSweepingStage:GetRowCount() + return self:GetCfg().RowCount +end + +function XMineSweepingStage:GetColumnCount() + return self:GetCfg().ColumnCount +end + +function XMineSweepingStage:GetRewardId() + return self:GetCfg().RewardId +end + +function XMineSweepingStage:GetWinEffect() + return self:GetCfg().WinEffect +end + +function XMineSweepingStage:GetCanFailedCounts() + return self:GetCfg().CanFailedCounts +end + +function XMineSweepingStage:GetCanFailedCountByIndex(index) + return self:GetCfg().CanFailedCounts[index] or 0 +end + +return XMineSweepingStage \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XMiniGame/ComposeFactory/XComposeGame.lua b/Resources/Scripts/XEntity/XMiniGame/ComposeFactory/XComposeGame.lua new file mode 100644 index 00000000..e5cca488 --- /dev/null +++ b/Resources/Scripts/XEntity/XMiniGame/ComposeFactory/XComposeGame.lua @@ -0,0 +1,316 @@ +-- 合成小游戏Game对象 +local XComposeGame = XClass(nil, "XComposeGame") +--=============数据结构================ +--======活动信息ComposeGameDataDb============= +-- 活动Id +-- int ActId +-- 当前进度 +-- int Schedule +-- 刷新次数 +-- int RefreshCount +-- 增加刷新次数时间戳(为 0 表示已达上限) +-- int RefreshTime +-- 商品列表 +-- List GoodsList +-- 商店列表 +-- List ShopInfos +-- 已领取奖励列表 +-- List RecvSchedule +--============================================= + +--==========商品信息ComposeShopInfo============= +-- 标志Id +-- int Id +-- 商品Id +-- int Goods +-- 是否已出售 +-- bool IsSell +--============================================= +--=================== END ===================== + +--==========构造函数,初始化,实体操作========== + +--================== +--构造函数 +--@param ComposeGameDataDb:NotifyComposeActivityInfo通知活动信息 +--================== +function XComposeGame:Ctor(ComposeGameDataDb) + self.GameConfig = XComposeGameConfig.GetGameConfigsByGameId(ComposeGameDataDb.ActId or 1) + self:InitBag(ComposeGameDataDb) + self:InitShop(ComposeGameDataDb) + self:InitTreasure(ComposeGameDataDb) + self:SetRefreshStatus(ComposeGameDataDb) +end +--================== +--初始化此活动背包 +--@param ComposeGameDataDb:NotifyComposeActivityInfo通知活动信息 +--================== +function XComposeGame:InitBag(ComposeGameDataDb) + local XItemBag = require("XEntity/XMiniGame/ComposeFactory/XComposeGameItemBag") + self.Bag = XItemBag.New(self, ComposeGameDataDb) +end +--================== +--初始化此活动商店 +--@param ComposeGameDataDb:NotifyComposeActivityInfo通知活动信息 +--================== +function XComposeGame:InitShop(ComposeGameDataDb) + local XShop = require("XEntity/XMiniGame/ComposeFactory/XComposeGameShop") + self.Shop = XShop.New(self, ComposeGameDataDb) +end +--================== +--初始化此活动进度宝箱 +--@param ComposeGameDataDb:NotifyComposeActivityInfo通知活动信息 +--================== +function XComposeGame:InitTreasure(ComposeGameDataDb) + local XTreasure = require("XEntity/XMiniGame/ComposeFactory/XComposeGameProgressTreasure") + self.Treasure = XTreasure.New(self, ComposeGameDataDb) +end +--================== +--初始化此活动刷新 +--@param ComposeGameDataDb:NotifyComposeActivityInfo通知活动信息 +--================== +function XComposeGame:SetRefreshStatus(ComposeGameDataDb) + if not ComposeGameDataDb then return end + self.RefreshCount = ComposeGameDataDb.RefreshCount or 0 + self.RefreshTime = ComposeGameDataDb.RefreshTime or 0 + CsXGameEventManager.Instance:Notify(XEventId.EVENT_COMPOSEGAME_SHOP_REFRESH_TIME_CHANGE) +end +--================== +--根据通知活动信息刷新活动 +--@param ComposeGameDataDb:NotifyComposeActivityInfo通知活动信息 +--================== +function XComposeGame:RefreshComposeGameData(ComposeGameDataDb) + self.Bag:RefreshComposeGameData(ComposeGameDataDb) + self.Shop:RefreshComposeGameData(ComposeGameDataDb) + self.Treasure:RefreshComposeGameData(ComposeGameDataDb) + self:SetRefreshStatus(ComposeGameDataDb) +end +--================== +--根据通知活动信息刷新背包 +--@param ComposeGoodsInfo:NotifyComposeGoodsInfo通知活动信息 +--================== +function XComposeGame:RefreshBagGoodsList(ComposeGoodsInfo) + self.Bag:RefreshComposeGameData(ComposeGoodsInfo) +end +--================== +--根据通知活动信息刷新商店 +--@param ComposeGoodsInfo:NotifyComposeGoodsInfo通知活动信息 +--================== +function XComposeGame:RefreshShopInfoList(ComposeShopInfos) + self.Shop:RefreshShopByShopInfos(ComposeShopInfos) +end +--================== +--购买道具 +--================== +function XComposeGame:BuyItem(itemId) + self.Bag:BuyItem(itemId) +end +--================== +--根据道具ID合成道具 +--@param itemId:要合成的道具 +--================== +function XComposeGame:ComposeItem(item) + self:RefreshBagGrids() + CsXGameEventManager.Instance:Notify(XEventId.EVENT_COMPOSEGAME_ITEM_COMPOSE, item) + self.Treasure:SetSchedule(item:GetGainSchedule()) +end +--================== +--刷新背包格 +--================== +function XComposeGame:RefreshBagGrids() + self.Bag:RefreshGridsByItems() +end +--=================== END ===================== + +--=================对外接口(Get,Set,Check等接口)================ +--================== +--获取活动ID +--================== +function XComposeGame:GetGameId() + return self.GameConfig and self.GameConfig.Id or 0 +end +--================== +--获取活动时间ID +--================== +function XComposeGame:GetTimeId() + return self.GameConfig and self.GameConfig.TimeId or 0 +end +--================== +--获取活动通用货币的道具ID +--================== +function XComposeGame:GetCoinId() + return self.GameConfig and self.GameConfig.CoinId or 0 +end +--================== +--获取活动刷新次数上限 +--================== +function XComposeGame:GetRefreshCountLimit() + return self.GameConfig and self.GameConfig.RefreshCountLimit or 0 +end +--================== +--获取活动商店刷新次数时长 +--================== +function XComposeGame:GetRefreshTimeSec() + return self.GameConfig and self.GameConfig.RefreshTimeSec or 0 +end +--================== +--获取活动最大进度 +--================== +function XComposeGame:GetMaxSchedule() + return self.GameConfig and self.GameConfig.MaxSchedule or 0 +end +--================== +--获取当前活动进度 +--================== +function XComposeGame:GetCurrentSchedule() + return self.Treasure and self.Treasure:GetCurrentSchedule() or 0 +end +--================== +--获取活动商店随机数量 +--================== +function XComposeGame:GetShopRandCount() + return self.GameConfig and self.GameConfig.ShopRandCount or 0 +end +--================== +--获取活动进度刻度列表 +--================== +function XComposeGame:GetSchedule() + return self.GameConfig and self.GameConfig.Schedule or {} +end +--================== +--获取活动奖励ID列表 +--================== +function XComposeGame:GetRewardId() + return self.GameConfig and self.GameConfig.RewardId or {} +end +--================== +--获取活动商店现在可刷新次数 +--================== +function XComposeGame:GetRefreshCount() + return self.RefreshCount +end +--================== +--获取活动下一次增加刷新次数的时间戳 +--================== +function XComposeGame:GetRefreshTime() + return self.RefreshTime +end +--================== +--获取活动代币刷新次数的价格 +--================== +function XComposeGame:GetRefreshPrice() + return self.GameConfig and self.GameConfig.RefreshPrice or 1 +end + +function XComposeGame:GetRefreshTimeIsMax() + return self:GetRefreshCount() >= self:GetRefreshCountLimit() +end + +function XComposeGame:CheckCanRefresh() + local count = self:GetRefreshCount() + return count > 0 +end + +function XComposeGame:CheckCanBuyRefresh() + return false --self:CheckEnoughCoin(self:GetRefreshPrice()) +end +--================== +--根据道具ID获取背包中该ID的道具数量 +--@param itemId:玩法道具ID +--================== +function XComposeGame:GetItemCount(itemId) + return self.Bag:GetItemCount(itemId) +end +--================== +--根据道具ID获取背包中该ID是否新获得 +--@param itemId:玩法道具ID +--================== +function XComposeGame:GetItemIsNew(itemId) + return self.Bag:GetItemIsNew(itemId) +end +--================ +--获取当前刷新次数展示字符串 +--================ +function XComposeGame:GetRefreshStr() + return string.format("%d/%d", self:GetRefreshCount(), self:GetRefreshCountLimit()) +end + +function XComposeGame:GetBeginStoryId() + local GameCfg = XComposeGameConfig.GetClientConfigByGameId(self:GetGameId()) + if not GameCfg then return end + local storyId = GameCfg.BeginStoryId or GameCfg.DebugStartTime --因为要热更更新,不能更改C#的XTable,暂时用已有字段DebugStartTime项代用,以后使用BeginStoryId + return storyId or "" +end +--================== +--获取活动是否开启时间 +--================== +function XComposeGame:CheckIsOpenTime() + local timeNow = XTime.GetServerNowTimestamp() + local isEnd = timeNow >= self:GetEndTime() + local isStart = timeNow >= self:GetStartTime() + local inTime = (not isEnd) and (isStart) + return inTime, (timeNow < self:GetStartTime()) +end +--================== +--获取活动结束时间 +--================== +function XComposeGame:GetEndTime() + return XFunctionManager.GetEndTimeByTimeId(self:GetTimeId()) or 0 +end +--================== +--获取活动开始时间 +--================== +function XComposeGame:GetStartTime() + return XFunctionManager.GetStartTimeByTimeId(self:GetTimeId()) or 0 +end +--================== +--获取现有代币数量 +--================== +function XComposeGame:GetCoinNum() + return XDataCenter.ItemManager.GetCount(self:GetCoinId()) or 0 +end +--================== +--获取商店格列表 +--================== +function XComposeGame:GetShopGrids() + return self.Shop:GetShopGrids() +end +--================== +--获取背包格列表 +--================== +function XComposeGame:GetBagGrids() + return self.Bag:GetGrids() +end +--================== +--获取进度宝箱列表 +--================== +function XComposeGame:GetTreasureBoxes() + return self.Treasure and self.Treasure:GetTreasureBoxes() or {} +end +--================== +--获取活动开始时间 +--================== +function XComposeGame:CheckCanBuyItem(item) + if not self:CheckEnoughCoin(item:GetCostCoinNum()) then + return false, CS.XTextManager.GetText("ComposeGameCoinNotEnough") + end + if not self:CheckEnoughGrids() then + return false, CS.XTextManager.GetText("ComposeGameGridsNotEnough") + end + return true +end +--================== +--检查是否有足够代币 +--================== +function XComposeGame:CheckEnoughCoin(checkNum) + local coinNum = self:GetCoinNum() + return coinNum >= checkNum +end +--================== +--检查是否背包有空位 +--================== +function XComposeGame:CheckEnoughGrids() + return not self.Bag:CheckIsFull() +end +--=================== END ===================== +return XComposeGame \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XMiniGame/ComposeFactory/XComposeGameItem.lua b/Resources/Scripts/XEntity/XMiniGame/ComposeFactory/XComposeGameItem.lua new file mode 100644 index 00000000..632ca5b7 --- /dev/null +++ b/Resources/Scripts/XEntity/XMiniGame/ComposeFactory/XComposeGameItem.lua @@ -0,0 +1,259 @@ +-- 组合小游戏玩法道具对象 +local XComposeGameItem = XClass(nil, "XComposeGameItem") +--==========构造函数,初始化,实体操作========== +--================== +--获取背包格的道具 +--================== +function XComposeGameItem:Ctor(itemId, forDisplay) + self.ForDisplay = forDisplay + self:Reset() + if itemId then self:RefreshItem(itemId) end +end +--================== +--获取背包格的道具 +--================== +function XComposeGameItem:Reset() + self.Num = 0 +end +--==================== END ======================== + +--=================对外接口(Get,Set,Check等接口)================ +--================== +--根据道具ID刷新道具实体 +--@param itemId:活动道具ID +--================== +function XComposeGameItem:RefreshItem(itemId) + self.ItemCfg = XComposeGameConfig.GetItemConfigByItemId(itemId) +end +--================== +--获取道具ID +--================== +function XComposeGameItem:GetId() + return self.ItemCfg and self.ItemCfg.Id +end +--================== +--获取道具的排序ID +--================== +function XComposeGameItem:GetOrderId() + return self.ItemCfg and self.ItemCfg.OrderId or 1 +end +--================== +--获取道具所属活动ID +--================== +function XComposeGameItem:GetGameId() + return self.ItemCfg and self.ItemCfg.ActId +end +--================== +--获取道具名称 +--================== +function XComposeGameItem:GetName() + return self.ItemCfg and self.ItemCfg.Name or "" +end +--=============== +--获取物品的大图标 +--=============== +function XComposeGameItem:GetBigIcon() + return self.ItemCfg and self.ItemCfg.BigIcon or "" +end +--=============== +--获取物品的小图标 +--=============== +function XComposeGameItem:GetSmallIcon() + return self.ItemCfg and self.ItemCfg.SmallIcon or "" +end +--=============== +--获取物品的星数 +--=============== +function XComposeGameItem:GetStar() + return self.ItemCfg and self.ItemCfg.Star or 1 +end +--================== +--获取道具合成后变成的道具ID +--================== +function XComposeGameItem:GetComposeId() + return self.ItemCfg and self.ItemCfg.ComposeId or 0 +end +--================== +--获取道具需要多少个进行合成 +--================== +function XComposeGameItem:GetComposeNeedNum() + return self.ItemCfg and self.ItemCfg.ComposeNeedNum +end +--================== +--获取花费代币量 +--================== +function XComposeGameItem:GetCostCoinNum() + return self.ItemCfg and self.ItemCfg.CostCoinNum or 1 +end +--================== +--获取该道具推进的活动进度值 +--================== +function XComposeGameItem:GetGainSchedule() + return self.ItemCfg and self.ItemCfg.GainSchedule +end +--=============== +--获取最终产物Id +--=============== +function XComposeGameItem:GetFinalSchedule() + return self.ItemCfg and self.ItemCfg.FinalSchedule +end +--=============== +--获取物品的质量 +--=============== +function XComposeGameItem:GetQuality() + return self.ItemCfg and self.ItemCfg.Quality or 1 +end +--=============== +--获取物品的世界观描述 +--=============== +function XComposeGameItem:GetWorldDesc() + local GameCfg = XComposeGameConfig.GetClientConfigByGameId(self:GetGameId()) + if not GameCfg then return end + local str = GameCfg.ItemDefaultWorldDesc + str = string.gsub(str, "\\n", "\n") + str = string.format(str, self:GetName(), self:GetName(), self:GetName(), self:GetName()) + return str +end +--=============== +--获取物品的描述 +--=============== +function XComposeGameItem:GetDescription() + local GameCfg = XComposeGameConfig.GetClientConfigByGameId(self:GetGameId()) + if not GameCfg then return end + local str = GameCfg.ItemDefaultDescription + str = string.gsub(str, "\\n", "\n") + str = string.format(str, self:GetFinalSchedule()) + return str +end +--=============== +--获取物品的临时展示信息(用于XUiTip) +--=============== +function XComposeGameItem:GetTempItemData() + local tempItemData = { + IsTempItemData = true, + Name = self:GetName(), + Count = self:GetNum(), + Icon = self:GetBigIcon(), + Quality = self:GetQuality(), + WorldDesc = self:GetWorldDesc(), + Description = self:GetDescription() + } + return tempItemData +end +--================== +--获取该道具数量 +--================== +function XComposeGameItem:GetNum() + return self.Num +end +--================== +--设置该道具数量 +--================== +function XComposeGameItem:SetNum(num) + self.Num = num + if self:CheckCanCompose(num) then + self:Compose() + end +end +--================== +--增加一个道具 +--================== +function XComposeGameItem:AddNum(isInit) + local tempNum = self:GetNum() + local addNum = tempNum + 1 + self:SetNum(addNum) + if not isInit then self.NewItem = self:GetNum() > 0 end + if self:GetIsFinalItem() then + local Game = XDataCenter.ComposeGameManager.GetGameById(self:GetGameId()) + if Game then + Game:ComposeItem(self) + end + end +end +--================== +--检查这个道具是否新增的 +--================== +function XComposeGameItem:GetIsNewItem() + local result = self:GetIsFinalItem() or self.NewItem + self.NewItem = false + return result +end +--================== +--减少一个道具 +--================== +function XComposeGameItem:MinusNum() + local tempNum = self:GetNum() + if tempNum <= 0 then + tempNum = 0 + else + tempNum = tempNum - 1 + end + self:SetNum(tempNum) +end +--================== +--获取该道具是否终端产品 +--================== +function XComposeGameItem:GetIsFinalItem() + return self:GetComposeId() == nil or self:GetComposeId() == 0 +end +--================== +--检查要设置的道具数量是否达到合成数量 +--@param setNum:要设置的道具数量 +--================== +function XComposeGameItem:CheckCanCompose(setNum) + return not self:GetIsFinalItem() and setNum >= self:GetComposeNeedNum() +end +--================== +--合成道具 +--================== +function XComposeGameItem:Compose() + if not self:GetIsFinalItem() then + self:SetNum(self:GetNum() - self:GetComposeNeedNum()) + local Game = XDataCenter.ComposeGameManager.GetGameById(self:GetGameId()) + if Game then + Game:BuyItem(self:GetComposeId()) + end + end +end +--================== +--清空道具 +--================== +function XComposeGameItem:Empty() + if self.ForDisplay then + self.ItemCfg = nil + else + self.Num = 0 + local Game = XDataCenter.ComposeGameManager.GetGameById(self:GetGameId()) + if Game then + Game:RefreshBagGrids() + end + end +end +--================== +--检查道具是否为空(没有数据或数量为0) +--================== +function XComposeGameItem:CheckIsEmpty() + if self.ForDisplay then + return self.ItemCfg == nil + else + return self.Num == 0 + end +end +--================== +--检查道具是否差一个升星 +--================== +function XComposeGameItem:CheckIsLevelUp() + if self:GetIsFinalItem() then return false end + if self.ForDisplay then + local Game = XDataCenter.ComposeGameManager.GetGameById(self:GetGameId()) + if Game then + local count = Game:GetItemCount(self:GetId()) + return count == self:GetComposeNeedNum() - 1 + end + else + return self:GetNum() == self:GetComposeNeedNum() - 1 + end + return false +end +--==================== END ======================== +return XComposeGameItem \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XMiniGame/ComposeFactory/XComposeGameItemBag.lua b/Resources/Scripts/XEntity/XMiniGame/ComposeFactory/XComposeGameItemBag.lua new file mode 100644 index 00000000..b876c963 --- /dev/null +++ b/Resources/Scripts/XEntity/XMiniGame/ComposeFactory/XComposeGameItemBag.lua @@ -0,0 +1,221 @@ +-- 组合小游戏背包对象 +local XComposeGameItemBag = XClass(nil, "XComposeGameItemBag") +--=============数据结构================ +--======活动信息ComposeGameDataDb============= +-- 活动Id +-- int ActId +-- 当前进度 +-- int Schedule +-- 刷新次数 +-- int RefreshCount +-- 增加刷新次数时间戳(为 0 表示已达上限) +-- int RefreshTime +-- 商品列表 +-- List GoodsList +-- 商店列表 +-- List ShopInfos +-- 已领取奖励列表 +-- List RecvSchedule +--============================================= + +--==========商品信息ComposeShopInfo============= +-- 标志Id +-- int Id +-- 商品Id +-- int Goods +-- 是否已出售 +-- bool IsSell +--============================================= +--=================== END ===================== + +--================== 本地方法 ================== +--================== +--背包格排序方法 +--================== +local SortGrids = function(gridA, gridB) + if (not gridA) or (gridA:GetItem():CheckIsEmpty()) then return false end + if (not gridB) or (gridB:GetItem():CheckIsEmpty()) then return true end + if gridA:GetItemStar() ~= gridB:GetItemStar() then + return gridA:GetItemStar() > gridB:GetItemStar() + else + return gridA:GetOrderId() >= gridB:GetOrderId() + end +end +--=================== END ===================== + +--==========构造函数,初始化,实体操作========== +--================== +--构造函数 +--@param Game:所属的活动对象 +--@param ComposeGameDataDb:NotifyComposeActivityInfo通知活动信息 +--================== +function XComposeGameItemBag:Ctor(Game, ComposeGameDataDb) + self.Game = Game + self:InitItemGrids() + self:InitGoods(ComposeGameDataDb.GoodsList) +end +--================== +--初始化背包格子 +--================== +function XComposeGameItemBag:InitItemGrids() + self.Grids = {} + local BAG_GRIDS_NUM = XDataCenter.ComposeGameManager.BAG_GRIDS_NUM + local XItemGrid = require("XEntity/XMiniGame/ComposeFactory/XComposeGameItemGrid") + for i = 1, BAG_GRIDS_NUM do + self.Grids[i] = XItemGrid.New(self) + end +end +--================== +--初始化背包格子 +--@param GoodsIdList:背包物品ID列表 +--================== +function XComposeGameItemBag:InitGoods(GoodsIdList) + self.Items = {} + if not GoodsIdList then return end + local XItem = require("XEntity/XMiniGame/ComposeFactory/XComposeGameItem") + for i = 1, #GoodsIdList do + if not self.Items[GoodsIdList[i]] then + self.Items[GoodsIdList[i]] = XItem.New(GoodsIdList[i], false) + end + self.Items[GoodsIdList[i]]:AddNum(true) + end + for i = 1, #self.Grids do + if GoodsIdList[i] then + self.Grids[i]:AddItem(GoodsIdList[i]) + end + end +end +--================== +--根据通知活动信息刷新背包 +--@param ComposeGameDataDb:NotifyComposeActivityInfo通知活动信息 +--================== +function XComposeGameItemBag:RefreshComposeGameData(ComposeGameDataDb) + self:RefreshItems(ComposeGameDataDb.GoodsList) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_COMPOSEGAME_BAGITEM_REFRESH) +end +--================== +--根据背包物品刷新背包格 +--@param GoodsIdList:背包物品ID列表 +--================== +function XComposeGameItemBag:RefreshGridsByItems() + local itemIdList = {} + for _, item in pairs(self.Items) do + for i = 1, item:GetNum() do + table.insert(itemIdList, item:GetId()) + end + end + self:RefreshGrids(itemIdList) +end +--================== +--刷新背包物品 +--@param GoodsIdList:背包物品ID列表 +--================== +function XComposeGameItemBag:RefreshItems(GoodsIdList) + self:EmptyItems() + if not GoodsIdList then return end + local XItem = require("XEntity/XMiniGame/ComposeFactory/XComposeGameItem") + for i = 1, #GoodsIdList do + if not self.Items[GoodsIdList[i]] then + self.Items[GoodsIdList[i]] = XItem.New(GoodsIdList[i], false) + end + self.Items[GoodsIdList[i]]:AddNum() + end + self:RefreshGrids(GoodsIdList) +end +--================== +--刷新背包格子 +--@param GoodsIdList:背包物品ID列表 +--================== +function XComposeGameItemBag:RefreshGrids(GoodsIdList) + self:EmptyGrids() + for i = 1, #self.Grids do + self.Grids[i]:AddItem(GoodsIdList[i]) + end + table.sort(self.Grids, SortGrids) +end +--================== +--清空所有背包道具信息 +--================== +function XComposeGameItemBag:EmptyItems() + for _, item in pairs(self.Items) do + item:Empty() + end +end +--================== +--清空所有背包格子的道具信息 +--================== +function XComposeGameItemBag:EmptyGrids() + for _, grid in pairs(self.Grids) do + grid:Empty() + end +end +--================== +--清空拥有指定道具ID的背包格子 +--@param itemId:道具ID +--================== +function XComposeGameItemBag:EmptyGridsByItemId(itemId) + for _, grid in pairs(self.Grids) do + grid:EmptyByItemId(itemId) + end + table.sort(self.Grids, SortGrids) +end +--================== +--根据物品ID增加道具 +--@param itemId:道具ID +--================== +function XComposeGameItemBag:AddItemByItemId(itemId) + if not self.Items[itemId] then + local XItem = require("XEntity/XMiniGame/ComposeFactory/XComposeGameItem") + self.Items[itemId] = XItem.New(itemId, false) + end + self.Items[itemId]:AddNum() +end +--==================== END ======================== + +--=================对外接口(Get,Set,Check等接口)================ +--================== +--获取背包格子列表 +--================== +function XComposeGameItemBag:GetGrids() + return self.Grids +end +--================== +--根据道具ID获取背包中该ID的道具数量 +--@param itemId:玩法道具ID +--================== +function XComposeGameItemBag:GetItemCount(itemId) + local item = self.Items[itemId] + if not item then return 0 end + return item:GetNum() +end +--================== +--检查能否增加道具进背包格 +--================== +function XComposeGameItemBag:CheckIsFull() + local totalNum = 0 + for _, item in pairs(self.Items) do + totalNum = totalNum + item:GetNum() + end + return totalNum >= XDataCenter.ComposeGameManager.BAG_GRIDS_NUM +end + +function XComposeGameItemBag:CheckIsFinalItem(itemId) + return self.Items[itemId] and self.Items[itemId]:GetComposeNeedNum() +end +--================== +--购买道具处理 +--@param itemId:购买道具的Id +--================== +function XComposeGameItemBag:BuyItem(itemId) + self:AddItemByItemId(itemId) + self:RefreshGridsByItems() +end +--================== +--获取指定ID道具是否为新道具 +--@param itemId:活动道具Id +--================== +function XComposeGameItemBag:GetItemIsNew(itemId) + return self.Items[itemId] and self.Items[itemId]:GetIsNewItem() or false +end +--==================== END ======================== +return XComposeGameItemBag \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XMiniGame/ComposeFactory/XComposeGameItemGrid.lua b/Resources/Scripts/XEntity/XMiniGame/ComposeFactory/XComposeGameItemGrid.lua new file mode 100644 index 00000000..0487bc03 --- /dev/null +++ b/Resources/Scripts/XEntity/XMiniGame/ComposeFactory/XComposeGameItemGrid.lua @@ -0,0 +1,94 @@ +-- 组合小游戏背包格对象 +local XComposeGameItemGrid = XClass(nil, "XComposeGameItemGrid") + +--==========构造函数,初始化,实体操作========== +--================== +--构造函数 +--@param bag:背包对象 +--================== +function XComposeGameItemGrid:Ctor(bag) + self.Bag = bag + self:Reset() +end +--================== +--重置背包格状态 +--================== +function XComposeGameItemGrid:Reset() + self:ResetItem() +end +--================== +--重置背包格道具状态 +--================== +function XComposeGameItemGrid:ResetItem() + if not self.Item then + local XItem = require("XEntity/XMiniGame/ComposeFactory/XComposeGameItem") + self.Item = XItem.New(nil, true) + else + self.Item:Reset() + end +end +--================== +--向背包格添加指定ID的道具 +--@param itemId:玩法道具ID +--================== +function XComposeGameItemGrid:AddItem(itemId) + if not itemId then + XDataCenter.ComposeGameManager.DebugLog( + "XComposeGameItemGrid:AddItem往背包格添加道具展示失败,错误原因:要添加的道具Id为空。" + ) + return + elseif not self.Item:CheckIsEmpty() then + XDataCenter.ComposeGameManager.DebugLog( + "XComposeGameItemGrid:AddItem往背包格添加道具展示失败,错误原因:往已有展示道具的背包格添加道具。" + ) + return + end + self:GetItem():RefreshItem(itemId) +end +--================== +--清空背包格的道具 +--================== +function XComposeGameItemGrid:Empty() + self:GetItem():Empty() +end +--================== +--检查背包格是否为指定ID的道具,是的话清空背包格的道具 +--@param itemId:玩法道具ID +--================== +function XComposeGameItemGrid:EmptyByItemId(itemId) + if self:GetItem():GetId() == itemId then + self:Empty() + end +end +--==================== END ======================== + +--=================对外接口(Get,Set,Check等接口)================ +--================== +--获取背包格的道具 +--================== +function XComposeGameItemGrid:GetItem() + if not self.Item then + self:ResetItem() + end + return self.Item +end +--================== +--获取背包格道具星级 +--================== +function XComposeGameItemGrid:GetItemStar() + return self:GetItem():GetStar() +end +--================== +--获取背包格道具顺序序号 +--================== +function XComposeGameItemGrid:GetOrderId() + return self:GetItem():GetOrderId() +end +--================== +--检查背包格是否为空 +--================== +function XComposeGameItemGrid:CheckIsEmpty() + return self:GetItem():CheckIsEmpty() +end +--==================== END ======================== +return XComposeGameItemGrid \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XMiniGame/ComposeFactory/XComposeGameProgressTreasure.lua b/Resources/Scripts/XEntity/XMiniGame/ComposeFactory/XComposeGameProgressTreasure.lua new file mode 100644 index 00000000..637d9033 --- /dev/null +++ b/Resources/Scripts/XEntity/XMiniGame/ComposeFactory/XComposeGameProgressTreasure.lua @@ -0,0 +1,113 @@ +-- 组合小游戏进度宝箱对象 +local XComposeGameProgressTreasure = XClass(nil, "XComposeGameProgressTreasure") +local SortBySchedule = function(a, b) + return a:GetSchedule() < b:GetSchedule() +end +--=============数据结构================ +--======活动信息ComposeGameDataDb============= +-- 活动Id +-- int ActId +-- 当前进度 +-- int Schedule +-- 刷新次数 +-- int RefreshCount +-- 增加刷新次数时间戳(为 0 表示已达上限) +-- int RefreshTime +-- 商品列表 +-- List GoodsList +-- 商店列表 +-- List ShopInfos +-- 已领取奖励列表 +-- List RecvSchedule +--============================================= + +--==========商品信息ComposeShopInfo============= +-- 标志Id +-- int Id +-- 商品Id +-- int Goods +-- 是否已出售 +-- bool IsSell +--============================================= +--=================== END ===================== + + +--==========构造函数,初始化,实体操作========== +--================== +--构造函数 +--@param Game:所属的活动对象 +--@param ComposeGameDataDb:NotifyComposeActivityInfo通知活动信息 +--================== +function XComposeGameProgressTreasure:Ctor(Game, ComposeGameDataDb) + self.Game = Game + self:Init() + self:RefreshData(ComposeGameDataDb) +end +--================== +--初始化 +--================== +function XComposeGameProgressTreasure:Init() + self.Schedule = 0 + self.Treasures = {} +end +--================== +--刷新数据 +--@param ComposeGameDataDb:NotifyComposeActivityInfo通知活动信息 +--================== +function XComposeGameProgressTreasure:RefreshData(ComposeGameDataDb) + if self.Schedule ~= ComposeGameDataDb.Schedule then + self.Schedule = ComposeGameDataDb.Schedule + CsXGameEventManager.Instance:Notify(XEventId.EVENT_COMPOSEGAME_SCHEDULE_REFRESH) + end + local XTreasure = require("XEntity/XMiniGame/ComposeFactory/XComposeGameTreasureBox") + local schedules = self.Game:GetSchedule() + local rewardIds = self.Game:GetRewardId() + local recvDic = {} + for _, sche in pairs(ComposeGameDataDb.RecvSchedule) do + recvDic[sche] = true + end + for i = 1, #schedules do + local schedule = schedules[i] + local rewardId = rewardIds[i] + self.Treasures[schedule] = XTreasure.New(self, schedule, rewardId, recvDic[schedule]) + end +end + +function XComposeGameProgressTreasure:SetSchedule(schedule) + local targetSchedule = self.Schedule + schedule + if self.Schedule ~= targetSchedule then + self.Schedule = targetSchedule + CsXGameEventManager.Instance:Notify(XEventId.EVENT_COMPOSEGAME_SCHEDULE_REFRESH) + end +end +--=================== END ===================== + +--=================对外接口(Get,Set,Check等接口)================ +--================== +--获取背包格子列表 +--================== +function XComposeGameProgressTreasure:SetIsReceiveBySchedule(schedule) + if not self.Treasures[schedule] then + return + end + self.Treasures[schedule]:SetIsReceive(true) +end +--================== +--获取当前进度 +--================== +function XComposeGameProgressTreasure:GetCurrentSchedule() + return self.Schedule +end +--================== +--获取经过排序的宝箱对象列表 +--================== +function XComposeGameProgressTreasure:GetTreasureBoxes() + local list = {} + for _, box in pairs(self.Treasures) do + table.insert(list, box) + end + table.sort(list, SortBySchedule) + return list +end +--=================== END ===================== +return XComposeGameProgressTreasure \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XMiniGame/ComposeFactory/XComposeGameShop.lua b/Resources/Scripts/XEntity/XMiniGame/ComposeFactory/XComposeGameShop.lua new file mode 100644 index 00000000..9ca58425 --- /dev/null +++ b/Resources/Scripts/XEntity/XMiniGame/ComposeFactory/XComposeGameShop.lua @@ -0,0 +1,59 @@ +-- 组合小游戏商店 +local XComposeGameShop = XClass(nil, "XComposeGameShop") +--=============数据结构================ +--======活动信息ComposeGameDataDb============= +-- 活动Id +-- int ActId +-- 当前进度 +-- int Schedule +-- 刷新次数 +-- int RefreshCount +-- 增加刷新次数时间戳(为 0 表示已达上限) +-- int RefreshTime +-- 商品列表 +-- List GoodsList +-- 商店列表 +-- List ShopInfos +-- 已领取奖励列表 +-- List RecvSchedule +--============================================= + +--==========商品信息ComposeShopInfo============= +-- 标志Id +-- int Id +-- 商品Id +-- int Goods +-- 是否已出售 +-- bool IsSell +--============================================= +--=================== END ===================== + +function XComposeGameShop:Ctor(Game, ComposeGameDataDb) + self.Game = Game + self:InitShop(ComposeGameDataDb.ShopInfos) +end + +function XComposeGameShop:InitShop(shopInfos) + self.Grids = {} + local XShopGrid = require("XEntity/XMiniGame/ComposeFactory/XComposeGameShopGrid") + for index, info in pairs(shopInfos) do + self.Grids[index] = XShopGrid.New(self, info) + end +end + +function XComposeGameShop:RefreshShopByShopInfos(shopInfos) + local XShopGrid = require("XEntity/XMiniGame/ComposeFactory/XComposeGameShopGrid") + for index, info in pairs(shopInfos) do + if self.Grids[index] then + self.Grids[index]:RefreshInfo(info) + else + self.Grids[index] = XShopGrid.New(self, info) + end + end +end + +function XComposeGameShop:GetShopGrids() + return self.Grids +end + +return XComposeGameShop \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XMiniGame/ComposeFactory/XComposeGameShopGrid.lua b/Resources/Scripts/XEntity/XMiniGame/ComposeFactory/XComposeGameShopGrid.lua new file mode 100644 index 00000000..2a0c02d2 --- /dev/null +++ b/Resources/Scripts/XEntity/XMiniGame/ComposeFactory/XComposeGameShopGrid.lua @@ -0,0 +1,79 @@ +-- 组合小游戏商店格对象 +local XComposeGameShopGrid = XClass(nil, "XComposeGameShopGrid") +--=============数据结构================ +--==========商品信息ComposeShopInfo============= +-- 标志Id +-- int Id +-- 商品Id +-- int Goods +-- 是否已出售 +-- bool IsSell +--============================================= +--=================== END ===================== + +--==========构造函数,初始化,实体操作========== +--================== +--构造函数 +--@param Shop:对应商店对象 +--@param ShopInfo:商品信息 +--================== +function XComposeGameShopGrid:Ctor(Shop, ShopInfo) + self.Shop = Shop + self:Init() + if ShopInfo then + self:RefreshInfo(ShopInfo) + end +end +--================== +--初始化 +--================== +function XComposeGameShopGrid:Init() + self:InitItem() +end +--================== +--初始化展示道具 +--================== +function XComposeGameShopGrid:InitItem() + local XItem = require("XEntity/XMiniGame/ComposeFactory/XComposeGameItem") + self.Item = XItem.New(nil, true) +end +--================== +--刷新商品信息 +--================== +function XComposeGameShopGrid:RefreshInfo(ShopInfo) + self.BuyId = ShopInfo.Id + self.IsSell = ShopInfo.IsSell + local item = self:GetItem() + item:RefreshItem(ShopInfo.Goods) +end +--==================== END ======================== + +--=================对外接口(Get,Set,Check等接口)================ + +function XComposeGameShopGrid:Buy() + self.IsSell = true + CsXGameEventManager.Instance:Notify(XEventId.EVENT_COMPOSEGAME_SHOP_ITEM_REFRESH) +end +--================== +--获取展示道具对象 +--================== +function XComposeGameShopGrid:GetItem() + if not self.Item then + self:InitItem() + end + return self.Item +end +--================== +--获取商店购买ID(购买商品时使用) +--================== +function XComposeGameShopGrid:GetBuyId() + return self.BuyId +end +--================== +--检查此商品是否已售 +--================== +function XComposeGameShopGrid:CheckIsSell() + return self.IsSell +end +--==================== END ======================== +return XComposeGameShopGrid \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XMiniGame/ComposeFactory/XComposeGameTreasureBox.lua b/Resources/Scripts/XEntity/XMiniGame/ComposeFactory/XComposeGameTreasureBox.lua new file mode 100644 index 00000000..810d9e30 --- /dev/null +++ b/Resources/Scripts/XEntity/XMiniGame/ComposeFactory/XComposeGameTreasureBox.lua @@ -0,0 +1,61 @@ +-- 组合小游戏奖励宝箱 +local XComposeGameTreasureBox = XClass(nil, "XComposeGameTreasureBox") + +--==========构造函数,初始化,实体操作========== +--================== +--构造函数 +--@param Progress:对应的宝箱列表对象 +--@param Schedule:宝箱对应进度 +--@param RewardId:宝箱奖励ID +--@param IsReceive:是否已领取 +--================== +function XComposeGameTreasureBox:Ctor(Progress, Schedule, RewardId, IsReceive) + self.Progress = Progress + self:Init(Schedule, RewardId, IsReceive) +end +--================== +--初始化 +--@param Schedule:宝箱对应进度 +--@param RewardId:宝箱奖励ID +--@param IsReceive:是否已领取 +--================== +function XComposeGameTreasureBox:Init(Schedule, RewardId, IsReceive) + self.Schedule = Schedule or 0 + self.RewardId = RewardId or 0 + self.IsReceive = IsReceive == true +end +--=================== END ===================== + +--=================对外接口(Get,Set,Check等接口)================ +--================== +--获取进度 +--================== +function XComposeGameTreasureBox:GetSchedule() + return self.Schedule or 0 +end +--================== +--获取奖励ID +--================== +function XComposeGameTreasureBox:GetRewardId() + return self.RewardId or 0 +end +--================== +--检查是否可领取奖励 +--================== +function XComposeGameTreasureBox:CheckCanReceive() + return self.Progress:GetCurrentSchedule() >= self:GetSchedule() and not self:CheckIsReceive() +end +--================== +--检查是否已领取奖励 +--================== +function XComposeGameTreasureBox:CheckIsReceive() + return self.IsReceive +end +--================== +--设置领取奖励状态 +--================== +function XComposeGameTreasureBox:SetIsReceive(isReceive) + self.IsReceive = isReceive +end +--=================== END ===================== +return XComposeGameTreasureBox \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XMiniGame/FingerGuessing/XFingerGuessingGameController.lua b/Resources/Scripts/XEntity/XMiniGame/FingerGuessing/XFingerGuessingGameController.lua new file mode 100644 index 00000000..b4cf42e5 --- /dev/null +++ b/Resources/Scripts/XEntity/XMiniGame/FingerGuessing/XFingerGuessingGameController.lua @@ -0,0 +1,193 @@ +-- 猜拳小游戏游戏进程控制器 +local XFingerGuessingGameController = XClass(nil, "XFingerGuessingGameController") +local UNNAMED_STR = "UnNamed" +function XFingerGuessingGameController:Ctor() + self.GameConfig = XFingerGuessingConfig.GetLastestActivityConfig() + self:InitStageManager() + self:ResetStatus() +end +--================ +--初始化关卡管理器 +--================ +function XFingerGuessingGameController:InitStageManager() + local XStageManager = require("XEntity/XMiniGame/FingerGuessing/XFingerGuessingStageManager") + self.StageManager = XStageManager.New(self) +end +--======================= +--刷新活动数据 +--@param data: { +-- int ActivityId //当前活动Id +-- List FingerGuessingStageData //已开启的关卡信息 +-- +--} +--======================= +--FingerGuessingCurrentStageInfo = { +-- int StageId //关卡Id +-- int PlayerScore // 玩家分数 +-- int RobotScore // 机器人分数 +-- int CurrentRound // 当前处于回合数 +--} +function XFingerGuessingGameController:RefreshActivityData(data) + self:InitConfigById(data.ActivityId) + self:SetIsOpenEye(data.IsCheating) + self:RefreshStageData(data.FingerGuessingStageData) + self:RefreshCurrentStage(data.CurrentStageData) +end +--======================= +--刷新关卡通常数据 +--@param data = +-- List FingerGuessingStageData //已开启的关卡信息 +--======================= +function XFingerGuessingGameController:RefreshStageData(data) + self.StageManager:RefreshStageList(data) +end +--======================= +--刷新当前关卡数据 +--@param data = +-- FingerGuessingCurrentStageInfo CurrentStageData //当前关卡信息 +--======================= +function XFingerGuessingGameController:RefreshCurrentStage(data) + self.StageManager:RefreshCurrentStage(data) + self.IsGaming = data.StageId ~= 0 + if data.StageId == 0 then self.PreStageId = self.CurrentStageId end + self.CurrentStageId = data.StageId +end +--================ +--根据Id初始化游戏配置 +--================ +function XFingerGuessingGameController:InitConfigById(activityId) + if self:GetId() == activityId then return end + self.GameConfig = XFingerGuessingConfig.GetActivityConfigById(activityId) +end +--================ +--重置成员属性 +--================ +function XFingerGuessingGameController:ResetStatus() + +end +--================ +--获取活动ID +--================ +function XFingerGuessingGameController:GetId() + return self.GameConfig and self.GameConfig.Id or 0 +end +--================ +--获取活动时间TimeId +--================ +function XFingerGuessingGameController:GetTimeId() + return self.GameConfig and self.GameConfig.TimeId or 0 +end +--================ +--获取活动代币道具ID +--================ +function XFingerGuessingGameController:GetCoinItemId() + return self.GameConfig and self.GameConfig.CoinItemId or 0 +end +--================== +--获取金币图标 +--================== +function XFingerGuessingGameController:GetCoinItemIcon() + if self.ItemIcon then return self.ItemIcon end + local itemId = self:GetCoinItemId() + if not itemId then return nil end + self.ItemIcon = XDataCenter.ItemManager.GetItemIcon(itemId) + return self.ItemIcon +end +--================ +--获取活动名称 +--================ +function XFingerGuessingGameController:GetName() + return self.GameConfig and self.GameConfig.Name or UNNAMED_STR +end +--================ +--获取主角名称 +--================ +function XFingerGuessingGameController:GetHeroName() + return self.GameConfig and self.GameConfig.HeroName +end +--================ +--获取主角全身图 +--================ +function XFingerGuessingGameController:GetHeroImage() + return self.GameConfig and self.GameConfig.HeroImage +end +--================ +--获取主角头像 +--================ +function XFingerGuessingGameController:GetPlayerPortraits() + return self.GameConfig and self.GameConfig.PlayerPortraits +end +--================ +--获取所有关卡对象 +--================ +function XFingerGuessingGameController:GetAllStages() + return self.StageManager:GetAllStages() +end +--================== +--获取活动开始时间 +--================== +function XFingerGuessingGameController:GetActivityStartTime() + return XFunctionManager.GetStartTimeByTimeId(self:GetTimeId()) or 0 +end +--================== +--获取活动结束时间 +--================== +function XFingerGuessingGameController:GetActivityEndTime() + return XFunctionManager.GetEndTimeByTimeId(self:GetTimeId()) or 0 +end +--================== +--获取是否正在游戏 +--================== +function XFingerGuessingGameController:GetIsGaming() + return self.IsGaming +end +--================== +--设置是否正在游戏 +--================== +function XFingerGuessingGameController:SetIsGaming(isGaming) + self.IsGaming = isGaming +end +--================== +--获取当前进行的关卡对象(若没有当前进行的关卡则取最近一次进行的关卡) +--================== +function XFingerGuessingGameController:GetCurrentStage() + local stageId = 0 + if self.CurrentStageId == 0 then + stageId = self.PreStageId or 0 + else + stageId = self.CurrentStageId + end + return self.StageManager:GetStageByStageId(stageId) +end +--================== +--根据关卡Id获取关卡对象 +--================== +function XFingerGuessingGameController:GetStageByStageId(stageId) + return self.StageManager:GetStageByStageId(stageId) +end + +function XFingerGuessingGameController:GetLastStageId() + return self.StageManager:GetLastStageId() +end +--================== +--检查金币是否足够 +--================== +function XFingerGuessingGameController:CheckCoinEnough(coin) + local itemId = self:GetCoinItemId() + if not itemId then return false end + local num = XDataCenter.ItemManager.GetCount(itemId) + return num >= coin +end +--================== +--获取是否开了天眼系统 +--================== +function XFingerGuessingGameController:GetIsOpenEye() + return self.OpenEye +end +--================== +--设置是否开了天眼系统 +--================== +function XFingerGuessingGameController:SetIsOpenEye(openEye) + self.OpenEye = openEye +end +return XFingerGuessingGameController \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XMiniGame/FingerGuessing/XFingerGuessingStage.lua b/Resources/Scripts/XEntity/XMiniGame/FingerGuessing/XFingerGuessingStage.lua new file mode 100644 index 00000000..39c3a40d --- /dev/null +++ b/Resources/Scripts/XEntity/XMiniGame/FingerGuessing/XFingerGuessingStage.lua @@ -0,0 +1,301 @@ +-- 猜拳小游戏关卡 +local XFingerGuessingStage = XClass(nil, "XFingerGuessingStage") +local UNNAMED_STR = "未配置字段" +local FINGER_NUM_NOT_OPEN_TEXT = "?" +local FINGER_TYPE = { + Rock = 0, -- 石头 + Paper = 1, -- 布 + Scissors = 2, -- 剪刀 +} +function XFingerGuessingStage:Ctor(config, controller) + self.GameController = controller + self.Config = config + self:ResetStatus() +end +--================== +--重置状态 +--================== +function XFingerGuessingStage:ResetStatus() + self.IsClear = false + self.IsOpen = false + self.IsPlaying = false + self.CurrentRound = 1 + self.OpenEyeFingerList = {} + self.FingerDeck = {[FINGER_TYPE.Rock] = 0, [FINGER_TYPE.Paper] = 0, [FINGER_TYPE.Scissors] = 0} + self.ActionDeck = {} + self.ChallengeTimes = 0 + self.HighScore = 0 +end +--======================= +--FingerGuessingStageInfo +-- int StageId // 关卡Id +-- int ChallengeTimes // 挑战次数 +-- bool StageStatus // 关卡状态 +-- int HighScore // 最高分 +-- List RobotTricksList // 机器人行动列表 +-- bool IsCheating // 是否开启天眼 +-- List SelectRobotTricks // 天眼预测的行动种类 +--======================= +function XFingerGuessingStage:RefreshStageInfo(stageInfo) + self.IsOpen = true + self.ChallengeTimes = stageInfo.ChallengeTimes + self.IsClear = stageInfo.StageStatus + self.HighScore = stageInfo.HighScore + self:SetOpenEyeFingerList(stageInfo.SelectRobotTricks) + self:SetNpcDecks(stageInfo.RobotTricksList) +end +--================================== +--FingerGuessingCurrentStageInfo = { +-- int StageId //关卡Id +-- int PlayerScore // 玩家分数 +-- int RobotScore // 机器人分数 +-- int CurrentRound // 当前处于回合数 +--} +--================================== +function XFingerGuessingStage:RefreshCurrent(currentStageInfo) + if self:GetStageId() ~= currentStageInfo.StageId then return end + if currentStageInfo.CurrentRound > 1 then + local action = self:GetActionByRound(self:GetCurrentRound()) + self.FingerDeck[action] = self.FingerDeck[action] - 1 + end + self.HeroScore = currentStageInfo.PlayerScore + self.EnemyScore = currentStageInfo.RobotScore + self.CurrentRound = currentStageInfo.CurrentRound +end +--================== +--获取关卡配置Id +--================== +function XFingerGuessingStage:GetId() + return self.Config and self.Config.Id +end +--================== +--获取关卡Id +--================== +function XFingerGuessingStage:GetStageId() + return self.Config and self.Config.StageId +end +--================== +--根据关卡开放状态获取关卡名称 +--================== +function XFingerGuessingStage:GetName() + if self.IsOpen then + return self:GetStageName() + else + return self:GetLockStageName() + end +end +--================== +--获取关卡名称(开放关卡时) +--================== +function XFingerGuessingStage:GetStageName() + return self.Config and self.Config.StageName or UNNAMED_STR +end +--================== +--获取关卡名称(未开放关卡时) +--================== +function XFingerGuessingStage:GetLockStageName() + local lockName = self.Config and self.Config.LockStageName + return lockName or self:GetStageName() +end +--================== +--获取关卡描述 +--================== +function XFingerGuessingStage:GetDescription() + return self.Config and string.gsub(self.Config.Description, "\\n", "\n") or UNNAMED_STR +end +--================== +--获取开启天眼二级确认窗口标题 +--================== +function XFingerGuessingStage:GetOpenEyeTipsTitle() + return self.Config and self.Config.OpenEyeTipsTitle +end +--================== +--获取开启天眼二级确认窗口内容 +--================== +function XFingerGuessingStage:GetOpenEyeTipsContent() + return self.Config and self.Config.OpenEyeTipsContent +end +--================== +--根据关卡开放状态获取敌人头像 +--================== +function XFingerGuessingStage:GetPortraits() + if self.IsOpen then + return self:GetRobotPortraits() + else + return self:GetStageLockRobotPortraits() + end +end +--================== +--获取敌人头像(开放关卡时)地址 +--================== +function XFingerGuessingStage:GetRobotPortraits() + return self.Config and self.Config.RobotPortraits +end +--================== +--获取敌人头像(未解锁关卡时)地址 +--================== +function XFingerGuessingStage:GetStageLockRobotPortraits() + return self.Config and self.Config.StageLockRobotPortraits +end +--================== +--获取机器人全图像 +--================== +function XFingerGuessingStage:GetRobotImage() + return self.Config and self.Config.RobotImage +end +--================== +--获取消耗材料多少 +--================== +function XFingerGuessingStage:GetCostItemCount() + return self.Config and self.Config.CostItemCount or 0 +end +--================== +--获取天眼看的种类数 +--================== +function XFingerGuessingStage:GetCheatCount() + return self.Config and self.Config.CheatCount or 0 +end +--================== +--获取前一个关卡Id +--================== +function XFingerGuessingStage:GetPreStageId() + return self.Config and self.Config.PreStageId +end +--================== +--获取胜利分数 +--================== +function XFingerGuessingStage:GetWinScore() + return self.Config and self.Config.WinScore or 0 +end +--================== +--获取关卡胜利台词 +--================== +function XFingerGuessingStage:GetWinTalk() + return self.Config and self.Config.WinTalk +end +--================== +--获取关卡失败台词 +--================== +function XFingerGuessingStage:GetLoseTalk() + return self.Config and self.Config.LoseTalk +end +--================== +--获取游戏总轮数 +--================== +function XFingerGuessingStage:GetRoundNum() + if self.RoundNum then return self.RoundNum end + self.RoundNum = #XFingerGuessingConfig.GetRoundConfigByStageId(self:GetStageId()) + return self.RoundNum +end +--================== +--获取现在的轮数 +--================== +function XFingerGuessingStage:GetCurrentRound() + return self.CurrentRound or 1 +end +--================== +--设置现在的轮数 +--================== +function XFingerGuessingStage:SetCurrentRound(roundNum) + self.CurrentRound = roundNum + self.RoundConfig = XFingerGuessingConfig.GetRoundConfigById(self.CurrentRound) +end +--================== +--获取关卡是否解锁 +--================== +function XFingerGuessingStage:GetIsOpen() + return self.IsOpen +end +--================== +--获取关卡是否已完成 +--================== +function XFingerGuessingStage:GetIsClear() + return self.IsClear +end +--================== +--设置天眼预测Id列表 +--================== +function XFingerGuessingStage:SetOpenEyeFingerList(fingerIdList) + self.OpenEyeFingerList = {} + for _, fingerId in pairs(fingerIdList) do + self.OpenEyeFingerList[fingerId] = true + end +end +--================== +--获取天眼预测Id列表 +--================== +function XFingerGuessingStage:GetOpenEyeFingerList() + return self.OpenEyeFingerList +end +--================== +--设置NPC卡组与行动序列 +--================== +function XFingerGuessingStage:SetNpcDecks(dataList) + self.FingerDeck = {} + self.ActionDeck = {} + for _, data in pairs(dataList) do + self.ActionDeck[data.Round] = data.Tricks + self.FingerDeck[data.Tricks] = (self.FingerDeck[data.Tricks] or 0) + 1 + end +end +--================== +--设置NPC卡组与行动序列 +--================== +function XFingerGuessingStage:GetFingerNumByFingerId(fingerId) + return self.FingerDeck[fingerId] or 0 +end +--================== +--获取天眼拳型数量的文本 +--================== +function XFingerGuessingStage:GetFingerTextByFingerId(fingerId) + if self:GetIsOpenEye() and self.OpenEyeFingerList[fingerId] then + return self:GetFingerNumByFingerId(fingerId) + else + return FINGER_NUM_NOT_OPEN_TEXT + end +end +--================== +--获取是否打开天眼 +--================== +function XFingerGuessingStage:GetIsOpenEye() + return self.GameController:GetIsOpenEye() +end +--================== +--获取NPC卡组与行动序列 +--================== +function XFingerGuessingStage:GetActionByRound(round) + return self.ActionDeck[round] +end +--================== +--获取当前回合NPC出拳图标 +--================== +function XFingerGuessingStage:GetActionImg() + local fingerId = self:GetActionByRound(self:GetCurrentRound()) + local fingerConfig = XFingerGuessingConfig.GetFingerConfigById(fingerId) + return fingerConfig and fingerConfig.Icon +end +--================== +--获取玩家得分 +--================== +function XFingerGuessingStage:GetHeroScore() + return self.HeroScore or 0 +end +--================== +--获取敌人得分 +--================== +function XFingerGuessingStage:GetEnemyScore() + return self.EnemyScore or 0 +end +--================== +--获取历史最高分 +--================== +function XFingerGuessingStage:GetHighScore() + return self.HighScore or 0 +end +--================== +--检查是否第一次进入关卡 +--================== +function XFingerGuessingStage:CheckIsFirstEntry() + return self.ChallengeTimes and self.ChallengeTimes == 0 +end +return XFingerGuessingStage \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XMiniGame/FingerGuessing/XFingerGuessingStageManager.lua b/Resources/Scripts/XEntity/XMiniGame/FingerGuessing/XFingerGuessingStageManager.lua new file mode 100644 index 00000000..2359df47 --- /dev/null +++ b/Resources/Scripts/XEntity/XMiniGame/FingerGuessing/XFingerGuessingStageManager.lua @@ -0,0 +1,77 @@ +-- 猜拳小游戏关卡管理器 +local XFingerGuessingStageManager = XClass(nil, "XFingerGuessingStageManager") + +local SortStagesByStageId = function(stage1, stage2) + return stage1:GetStageId() < stage2:GetStageId() +end + +function XFingerGuessingStageManager:Ctor(gameController) + self.GameController = gameController + self:InitStages() +end +--================ +--初始化关卡 +--================ +function XFingerGuessingStageManager:InitStages() + self.Stages = {} + local XStage = require("XEntity/XMiniGame/FingerGuessing/XFingerGuessingStage") + local stageConfigs = XFingerGuessingConfig.GetAllStageConfig() + for _, config in pairs(stageConfigs) do + self.Stages[config.StageId] = XStage.New(config, self.GameController) + end +end +--======================= +--刷新活动数据 +--@param data: +-- List FingerGuessingStageData //已开启的关卡信息 +--======================= +--FingerGuessingStageInfo +-- int StageId // 关卡Id +-- int ChallengeTimes // 挑战次数 +-- int StageStatus // 关卡状态 +-- int HighScore // 最高分 +-- List RobotTricksList // 机器人行动列表 +-- bool IsCheating // 是否开启天眼 +-- List SelectRobotTricks // 天眼预测的行动种类 +--======================= +function XFingerGuessingStageManager:RefreshStageList(data) + for _, stageInfo in pairs(data) do + local stage = self:GetStageByStageId(stageInfo.StageId) + if stage then + stage:RefreshStageInfo(stageInfo) + end + end +end + +function XFingerGuessingStageManager:RefreshCurrentStage(data) + local stage = self:GetStageByStageId(data.StageId) + if stage then + stage:RefreshCurrent(data) + end +end +--================ +--获取所有关卡对象 +--================ +function XFingerGuessingStageManager:GetAllStages() + local stageList = {} + for _, stage in pairs(self.Stages) do + table.insert(stageList, stage) + end + table.sort(stageList, SortStagesByStageId) + return stageList +end +--================ +--根据关卡Id获取关卡对象 +--@param stageId:关卡Id +--================ +function XFingerGuessingStageManager:GetStageByStageId(stageId) + return self.Stages[stageId] +end + +function XFingerGuessingStageManager:GetLastStageId() + local stageList = self:GetAllStages() + for _, stage in pairs(stageList) do + + end +end +return XFingerGuessingStageManager \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XMiniGame/WhiteValentine2021/XWhiteValentineChara.lua b/Resources/Scripts/XEntity/XMiniGame/WhiteValentine2021/XWhiteValentineChara.lua new file mode 100644 index 00000000..3b998dd9 --- /dev/null +++ b/Resources/Scripts/XEntity/XMiniGame/WhiteValentine2021/XWhiteValentineChara.lua @@ -0,0 +1,153 @@ +-- 约会小游戏角色对象 +local XWhiteValentineChara = XClass(nil, "XWhiteValentineChara") +--==========构造函数,初始化,实体操作========== +--================== +--构造函数 +--================== +function XWhiteValentineChara:Ctor(CharaManager, CharaId, CharaData) + self.CharaManager = CharaManager + self:InitConfig(CharaId) + self:RefreshData(CharaData) +end +--================== +--初始化配置 +--================== +function XWhiteValentineChara:InitConfig(CharaId) + self:ResetStatus() + self.Config = XWhiteValentineConfig.GetWhiteValentineCharaByCharaId(CharaId) + self.AttrCfg = XWhiteValentineConfig.GetWhiteValentineAttrById(self:GetAttrType()) +end +--================== +--重置状态 +--================== +function XWhiteValentineChara:ResetStatus() + self.Dispatching = false + self:SetInTeam(false) + self:SetFinishEventCount(0) +end +--================== +--刷新数据 +--@param CharaData:{int Id //角色ID,long EventEndTime //事件完成时间, int FinishEventCount //完成的事件次数} +--================== +function XWhiteValentineChara:RefreshData(CharaData) + if not CharaData then return end + self:SetInTeam(true) + self.Dispatching = CharaData.EventEndTime > 0 + self:SetFinishEventCount(CharaData.FinishEventCount) +end +--=================== END ===================== +--=================Get,Set,Check================ +--================== +--获取游戏ID +--================== +function XWhiteValentineChara:GetGameId() + return self.CharaManager:GetGameId() +end +--================== +--获取角色ID +--================== +function XWhiteValentineChara:GetCharaId() + return self.Config and self.Config.Id +end +--================== +--获取角色名 +--================== +function XWhiteValentineChara:GetName() + return self.Config and self.Config.Name +end +--================== +--获取角色图标 +--================== +function XWhiteValentineChara:GetIconPath() + return self.Config and self.Config.IconPath +end +--================== +--获取角色属性类型 +--================== +function XWhiteValentineChara:GetAttrType() + return self.Config and self.Config.AttrType +end +--================== +--获取角色属性数值 +--================== +function XWhiteValentineChara:GetAttrValue() + return self.Config and self.Config.AttrValue +end +--================== +--获取角色属性图标 +--================== +function XWhiteValentineChara:GetAttrIcon() + return self.AttrCfg and self.AttrCfg.IconPath +end +--================== +--获取偶遇约会ID +--================== +function XWhiteValentineChara:GetEncounterStoryId() + return self.Config and self.Config.EncounterStoryId +end +--================== +--获取邀约约会ID +--================== +function XWhiteValentineChara:GetInviteStoryId() + return self.Config and self.Config.InviteStoryId +end +--================== +--获取约会故事配置 +--@param storyType:WhiteValentineManager.StoryType 故事类型 +--================== +function XWhiteValentineChara:GetStoryByStoryType(storyType) + local storyName = XDataCenter.WhiteValentineManager.StoryTypeName[storyType] + local storyId = storyName and 0 or -1 + if storyId == -1 then return nil end + if self["Get" .. storyName .. "StoryId"] then + storyId = self["Get" .. storyName .. "StoryId"](self) + end + local storyCfg = XWhiteValentineConfig.GetWhiteValentineStoryById(storyId) + return storyCfg +end +--================== +--获取特殊通讯ID +--================== +function XWhiteValentineChara:GetCommuId() + return self.Config and self.Config.CommuId +end +--================== +--获取节省时间百分比 +--================== +function XWhiteValentineChara:GetCutDownTime() + return self.Config and self.Config.CutDownTime +end +--================== +--获取增加贡献值奖励百分比 +--================== +function XWhiteValentineChara:GetContributionBuff() + return self.Config and self.Config.ContributionBuff +end +--================== +--设置已完成约会数目 +--================== +function XWhiteValentineChara:SetFinishEventCount(finishEventCount) + if not finishEventCount then return end + if finishEventCount < 0 then finishEventCount = 0 end + self.FinishEventCount = finishEventCount +end +--================== +--获取角色是否已获取 +--================== +function XWhiteValentineChara:GetInTeam() + return self.InTeam +end +--================== +--设置角色获取状态 +--================== +function XWhiteValentineChara:SetInTeam(isInTeam) + self.InTeam = isInTeam +end +--================== +--获取角色是否已派遣 +--================== +function XWhiteValentineChara:GetDispatching() + return self.Dispatching +end +--=================== END ===================== +return XWhiteValentineChara \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XMiniGame/WhiteValentine2021/XWhiteValentineCharaManager.lua b/Resources/Scripts/XEntity/XMiniGame/WhiteValentine2021/XWhiteValentineCharaManager.lua new file mode 100644 index 00000000..acfc7580 --- /dev/null +++ b/Resources/Scripts/XEntity/XMiniGame/WhiteValentine2021/XWhiteValentineCharaManager.lua @@ -0,0 +1,156 @@ +--白情约会小游戏活动角色管理器 +local XWhiteValentineCharaManager = XClass(nil, "XWhiteValentineCharaManager") +--================== +--角色列表排序方法(只比较配置ID) +--@param chara1,chara2:比较的角色 +--================== +local SortCharaListByCharaId = function(chara1, chara2) + if chara1:GetAttrType() ~= chara2:GetAttrType() then + return chara1:GetAttrType() < chara2:GetAttrType() + elseif chara1:GetAttrValue() ~= chara2:GetAttrValue() then + return chara1:GetAttrValue() > chara2:GetAttrValue() + else + return chara1:GetCharaId() < chara2:GetCharaId() + end +end +--================== +--构造函数 +--================== +function XWhiteValentineCharaManager:Ctor(Game) + self.Game = Game + self:InitCharas() +end +--================== +--初始化所有角色 +--================== +function XWhiteValentineCharaManager:InitCharas() + self.Charas = {} + local allChara = XWhiteValentineConfig.GetAllWhiteValentineChara() + local XChara = require("XEntity/XMiniGame/WhiteValentine2021/XWhiteValentineChara") + for _, charaData in pairs(allChara) do + local newChara = XChara.New(self, charaData.Id) + self.Charas[charaData.Id] = newChara + end +end +--================== +--刷新数据 +--@param CharaDb:CharaData列表。CharaData = {int Id //角色ID +-- long EventEndTime //结束时间戳,0 表示未派遣角色 +-- int FinishEventCount //此角色的完成事件计数} +--================== +function XWhiteValentineCharaManager:RefreshData(CharaDb) + if not CharaDb then return end + for _, charaData in pairs(CharaDb) do + local chara = self.Charas[charaData.Id] + if chara then chara:RefreshData(charaData) end + end +end +--================== +--添加新成员 +--@param charaId:角色Id +--================== +function XWhiteValentineCharaManager:AddNewChara(charaId) + local chara = self.Charas[charaId] + chara:SetInTeam(true) +end +--================== +--刷新单个成员数据 +--@param charaData:成员数据 = {int Id //角色ID +-- long EventEndTime //结束时间戳,0 表示未派遣角色 +-- int FinishEventCount //此角色的完成事件计数} +--================== +function XWhiteValentineCharaManager:RefreshChara(charaData) + local chara = self.Charas[charaData.Id] + if not chara then return end + chara:RefreshData(charaData) +end +--================== +--获取成员对象 +--@param charaId:角色Id +--================== +function XWhiteValentineCharaManager:GetChara(charaId) + if not charaId then return nil end + return self.Charas[charaId] +end +--================== +--获取所有已被邀请的成员对象 +--================== +function XWhiteValentineCharaManager:GetAllInTeamChara() + local charaList = {} + for _, chara in pairs(self.Charas) do + if chara:GetInTeam() then + table.insert(charaList, chara) + end + end + return charaList +end +--================== +--获取所有没被邀请的成员对象 +--================== +function XWhiteValentineCharaManager:GetAllOutTeamChara() + local charaList = {} + for _, chara in pairs(self.Charas) do + if not chara:GetInTeam() then + table.insert(charaList, chara) + end + end + table.sort(charaList, SortCharaListByCharaId) + return charaList +end +--================== +--获取根据角色ID与派遣状况排列的角色列表 +--================== +function XWhiteValentineCharaManager:GetCharaListSortByDispatching(attrType) + local charaList = {} + local attrCharaList = {} + local otherCharaList = {} + local dispatchingCharaList = {} + for _, chara in pairs(self:GetAllInTeamChara()) do + if chara:GetDispatching() then + table.insert(dispatchingCharaList, chara) + elseif chara:GetAttrType() == attrType then + table.insert(attrCharaList, chara) + else + table.insert(otherCharaList, chara) + end + end + table.sort(attrCharaList, SortCharaListByCharaId) + table.sort(otherCharaList, SortCharaListByCharaId) + table.sort(dispatchingCharaList, SortCharaListByCharaId) + for _, chara in pairs(attrCharaList) do + table.insert(charaList, chara) + end + for _, chara in pairs(otherCharaList) do + table.insert(charaList, chara) + end + for _, chara in pairs(dispatchingCharaList) do + table.insert(charaList, chara) + end + return charaList +end +--================== +--获取根据角色属性排列的邀约角色列表 +--================== +function XWhiteValentineCharaManager:GetOutTeamCharaByAttrType(attrType) + local charaList = {} + local allChara = self:GetAllOutTeamChara() + for _, chara in pairs(allChara) do + if chara:GetAttrType() == attrType then + table.insert(charaList, chara) + end + end + return charaList +end +--================== +--检查是否有未邀约的角色 +--================== +function XWhiteValentineCharaManager:CheckOutTeamCharaExist() + for _, chara in pairs(self.Charas) do + if not chara:GetInTeam() then + return true + end + end + return false +end + +return XWhiteValentineCharaManager \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XMiniGame/WhiteValentine2021/XWhiteValentineGame.lua b/Resources/Scripts/XEntity/XMiniGame/WhiteValentine2021/XWhiteValentineGame.lua new file mode 100644 index 00000000..b8cc2f86 --- /dev/null +++ b/Resources/Scripts/XEntity/XMiniGame/WhiteValentine2021/XWhiteValentineGame.lua @@ -0,0 +1,373 @@ +-- 白色情人节约会小游戏活动对象 +local XWhiteValentineGame = XClass(nil, "XWhiteValentineGame") +--==========构造函数,初始化,实体操作========== +--================== +--构造函数 +--@param GameData:通知活动信息 +--================== +function XWhiteValentineGame:Ctor() + self.GameConfig = XWhiteValentineConfig.GetWhiteValentineConfigByGameId(XWhiteValentineConfig.GetLastConfigId()) + self:InitPlaceManager() + self:InitCharaManager() + self:InitStatus() +end +--================== +--初始化地点 +--================== +function XWhiteValentineGame:InitPlaceManager() + local PlaceManager = require("XEntity/XMiniGame/WhiteValentine2021/XWhiteValentinePlaceManager") + self.PlaceManager = PlaceManager.New(self) +end +--================== +--初始化角色管理器 +--================== +function XWhiteValentineGame:InitCharaManager() + local CharaManager = require("XEntity/XMiniGame/WhiteValentine2021/XWhiteValentineCharaManager") + self.CharaManager = CharaManager.New(self) +end +--================== +--初始化活动数值 +--================== +function XWhiteValentineGame:InitStatus() + self:ResetStatus() +end +--================== +--重置活动数值 +--================== +function XWhiteValentineGame:ResetStatus() + self:SetEnergy(0) + self:SetInviteChance(0) + self.ContributionIcon = nil + self.ItemIcon = nil +end +--================== +--刷新活动数据 +--@param enterActivityData:活动数据 +--enterActivityData : { int Energy //体力,int InviteCount //邀请次数, +-- List RoleDb //角色列表 +-- List PlaceDb //地点列表 +-- LastRefreshTimestamp //最后一个更新体力时间} +--================== +function XWhiteValentineGame:RefreshData(enterActivityData) + self:SetEnergy(enterActivityData.Energy) + self:SetInviteChance(enterActivityData.InviteCount) + self:SetNextEnergyRecoveryTimeStamp(enterActivityData.LastRefreshTimestamp) + --先刷新角色状态,再刷新地点状态(地点需要用到新的角色状态) + self.CharaManager:RefreshData(enterActivityData.RoleDb) + self.PlaceManager:RefreshData(enterActivityData.PlaceDb) +end +--================== +--检查是否有事件结束 +--================== +function XWhiteValentineGame:CheckCanFinishEvent() + self.CanFinishEvent = self.PlaceManager:CheckCanFinishEvent() +end +--================== +--刷新活动数据 +--@param charaData:角色数据 +--================== +function XWhiteValentineGame:RefreshChara(charaData) + self.CharaManager:RefreshChara(charaData) +end +--================== +--刷新地点数据 +--@param placeData:地点数据 +--================== +function XWhiteValentineGame:RefreshPlace(placeData) + self.PlaceManager:RefreshPlace(placeData) +end +--================== +--批量刷新地点数据 +--@param charaData:角色数据集合 +--================== +function XWhiteValentineGame:RefreshPlaceRange(placeDatas) + self.PlaceManager:RefreshPlaceRange(placeDatas) + for _, placeData in pairs(placeDatas) do + local place = self.PlaceManager:GetPlaceByPlaceId(placeData.Id) + local count = place:GetInviteNum() + self:SetInviteChance(self:GetInviteChance() + count) + end +end +--================== +--派遣角色 +--@param placeData:被派遣的地点刷新数据 +--@param charaData:派遣的角色刷新数据 +--@param costEnergy:消耗的体力 +--@param nextEnergyRecoveryTimestamp:下一个体力更新的时间戳 +--================== +function XWhiteValentineGame:CharaDispatch(placeData, charaData, costEnergy, nextEnergyRecoveryTimestamp) + self:RefreshChara(charaData) + self:RefreshPlace(placeData) + self:CostEnergy(costEnergy) + self:SetNextEnergyRecoveryTimeStamp(nextEnergyRecoveryTimestamp) + self:CalculateNextEnergyRecoveryTimeStamp() +end +--================== +--增加新角色 +--@param charaId:角色Id +--================== +function XWhiteValentineGame:AddNewChara(charaId) + self.CharaManager:AddNewChara(charaId) +end +--================== +--计算并设置下一个体力回复的时间戳 +--================== +function XWhiteValentineGame:CalculateNextEnergyRecoveryTimeStamp() + local timeStamp = self:GetNextEnergyRecoveryTimeStamp() + if timeStamp == 0 then return end + local nextTimeStamp = timeStamp + self:GetEnergyRecoverySpeed() + self:SetNextEnergyRecoveryTimeStamp(nextTimeStamp) +end +--================== +--计算时间戳差值,补回体力恢复(处理本地计算体力刷新边际问题) +--================== +function XWhiteValentineGame:CalculateDeltaEnergyRecoveryTimeStamp() + local now = XTime.GetServerNowTimestamp() + local delta = now - self:GetNextEnergyRecoveryTimeStamp() + local deltaEnergy = math.floor(delta / self:GetEnergyRecoverySpeed()) + while(self:GetNextEnergyRecoveryTimeStamp() < now) do + self:CalculateNextEnergyRecoveryTimeStamp() + end + self:SetEnergy(self:GetEnergy() + deltaEnergy) +end +--================== +--体力自增1 +--================== +function XWhiteValentineGame:AddOneEnergy() + self:SetEnergy(self:GetEnergy() + 1) +end +--=================== END ===================== + +--=================Get,Set,Check================ +--================== +--获取活动ID +--================== +function XWhiteValentineGame:GetGameId() + return self.GameConfig and self.GameConfig.GameId +end +--================== +--获取活动标题 +--================== +function XWhiteValentineGame:GetName() + return self.GameConfig and self.GameConfig.Name +end +--================== +--获取活动TimeID +--================== +function XWhiteValentineGame:GetTimeId() + return self.GameConfig and self.GameConfig.TimeId +end +--================== +--获取活动条件ID +--================== +function XWhiteValentineGame:GetOpenConditionId() + return self.GameConfig and self.GameConfig.OpenConditionId +end +--================== +--获取背景图片地址 +--================== +function XWhiteValentineGame:GetBgPicturePath() + return self.GameConfig and self.GameConfig.BgPicturePath +end +--================== +--获取背景特效地址 +--================== +function XWhiteValentineGame:GetBgEffectPath() + return self.GameConfig and self.GameConfig.BgEffectPath +end +--================== +--获取活动体力最大值 +--================== +function XWhiteValentineGame:GetMaxEnergy() + return self.GameConfig and self.GameConfig.MaxEnergy +end +--================== +--获取活动体力恢复速度(单位:秒) +--================== +function XWhiteValentineGame:GetEnergyRecoverySpeed() + return self.GameConfig and self.GameConfig.EnergyRecoverySpeed +end +--================== +--获取活动体力图标 +--================== +function XWhiteValentineGame:GetEnergyIconPath() + return self.GameConfig and self.GameConfig.EnergyIconPath +end +--================== +--获取贡献值道具ID +--================== +function XWhiteValentineGame:GetContributionItemId() + return self.GameConfig and self.GameConfig.ContributionItemId +end +--================== +--获取贡献值道具图标 +--================== +function XWhiteValentineGame:GetContributionItemIcon() + if self.ContributionIcon then return self.ContributionIcon end + local itemId = self:GetContributionItemId() + if not itemId then return nil end + self.ContributionIcon = XDataCenter.ItemManager.GetItemIcon(itemId) + return self.ContributionIcon +end +--================== +--获取金币道具ID +--================== +function XWhiteValentineGame:GetCoinItemId() + return self.GameConfig and self.GameConfig.CoinItemId +end +--================== +--获取金币图标 +--================== +function XWhiteValentineGame:GetCoinItemIcon() + if self.ItemIcon then return self.ItemIcon end + local itemId = self:GetCoinItemId() + if not itemId then return nil end + self.ItemIcon = XDataCenter.ItemManager.GetItemIcon(itemId) + return self.ItemIcon +end +--================== +--获取偶遇消耗金币数 +--================== +function XWhiteValentineGame:GetRandomMeetCostCoin() + return self.GameConfig and self.GameConfig.RandomMeetCostCoin or 0 +end +--================== +--获取活动开始时间 +--================== +function XWhiteValentineGame:GetActivityStartTime() + return XFunctionManager.GetStartTimeByTimeId(self:GetTimeId()) or 0 +end +--================== +--获取活动结束时间 +--================== +function XWhiteValentineGame:GetActivityEndTime() + return XFunctionManager.GetEndTimeByTimeId(self:GetTimeId()) or 0 +end +--================== +--获取体力值 +--================== +function XWhiteValentineGame:GetEnergy() + return self.Energy +end +--================== +--设置体力值 +--@param energy:体力值 +--================== +function XWhiteValentineGame:SetEnergy(energy) + if not energy then return end + if energy < 0 then energy = 0 end + self.Energy = energy > self:GetMaxEnergy() and self:GetMaxEnergy() or energy + XEventManager.DispatchEvent(XEventId.EVENT_WHITEVALENTINE_ENERGY_REFRESH) +end +--================== +--消耗体力值 +--================== +function XWhiteValentineGame:CostEnergy(cost) + if not cost then return end + local resultEnergy = self:GetEnergy() - cost + self:SetEnergy(resultEnergy) +end +--================== +--获取邀请值 +--================== +function XWhiteValentineGame:GetInviteChance() + return self.InviteChance +end +--================== +--设置邀请值 +--================== +function XWhiteValentineGame:SetInviteChance(inviteChance) + if not inviteChance then return end + if inviteChance < 0 then inviteChance = 0 end + self.InviteChance = inviteChance + XEventManager.DispatchEvent(XEventId.EVENT_WHITEVALENTINE_INVITE_CHANCE_REFRESH, self.InviteChance) +end +--================== +--根据角色ID获取角色 +--@param charaId:角色Id +--================== +function XWhiteValentineGame:GetChara(charaId) + return self.CharaManager:GetChara(charaId) +end +--================== +--获取金币数量 +--================== +function XWhiteValentineGame:GetCoin() + local coinId = self:GetCoinItemId() + if not coinId then return 0 end + return XDataCenter.ItemManager.GetCount(coinId) +end +--================== +--检查是否能偶遇 +--================== +function XWhiteValentineGame:CheckCanEncounter() + return self:CheckEncounterCoinEnough() and self:CheckOutTeamCharaExist() +end +--================== +--检查偶遇金币是否足够 +--================== +function XWhiteValentineGame:CheckEncounterCoinEnough() + return self:GetCoin() >= self:GetRandomMeetCostCoin() +end +--================== +--检查是否还有未邀约的角色 +--================== +function XWhiteValentineGame:CheckOutTeamCharaExist() + return self.CharaManager:CheckOutTeamCharaExist() +end +--================== +--获取地点管理器 +--================== +function XWhiteValentineGame:GetPlaceManager() + return self.PlaceManager +end +--================== +--获取角色管理器 +--================== +function XWhiteValentineGame:GetCharaManager() + return self.CharaManager +end +--================== +--获取下一次更新体力的时间戳 +--================== +function XWhiteValentineGame:GetNextEnergyRecoveryTimeStamp() + return self.NextEnergyRecoveryTimeStamp or 0 +end +--================== +--获取是否有完成事件未领取奖励 +--================== +function XWhiteValentineGame:GetCanFinishEvent() + return self.CanFinishEvent +end +--================== +--检查是否满能量 +--================== +function XWhiteValentineGame:CheckIsMaxEnergy() + return self:GetEnergy() >= self:GetMaxEnergy() +end +--================== +--设置下一次更新体力的时间戳 +--================== +function XWhiteValentineGame:SetNextEnergyRecoveryTimeStamp(timeStamp) + if timeStamp < 0 then timeStamp = 0 end + self.NextEnergyRecoveryTimeStamp = timeStamp +end +--================== +--检查是否有未邀约的角色 +--================== +function XWhiteValentineGame:CheckCanInviteChara() + return self:GetInviteChance() > 0 and self.CharaManager:CheckOutTeamCharaExist() +end +--================== +--检查是否能派遣 +--================== +function XWhiteValentineGame:CheckCanDispatch(place) + if not place then return false end + if self:GetEnergy() < place:GetCostEnergy() then + XUiManager.TipMsg(CS.XTextManager.GetText("WhiteValentineEnergyNotEnough")) + return false + end + return true +end +--=================== END ===================== +return XWhiteValentineGame \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XMiniGame/WhiteValentine2021/XWhiteValentinePlace.lua b/Resources/Scripts/XEntity/XMiniGame/WhiteValentine2021/XWhiteValentinePlace.lua new file mode 100644 index 00000000..12c0ee89 --- /dev/null +++ b/Resources/Scripts/XEntity/XMiniGame/WhiteValentine2021/XWhiteValentinePlace.lua @@ -0,0 +1,218 @@ +-- 约会活动地点对象 +local XWhiteValentinePlace = XClass(nil, "XWhiteValentinePlace") +--==========构造函数,初始化,实体操作========== +--================== +--构造函数 +--@param Game:约会Game对象 +--@param PlaceId:地点ID +--@param PlaceData:地点数据(可缺省) +--================== +function XWhiteValentinePlace:Ctor(GameController, PlaceId) + self.GameController = GameController + self:InitConfig(PlaceId) +end + +function XWhiteValentinePlace:InitConfig(PlaceId) + self:ResetStatus() + self.Config = XWhiteValentineConfig.GetWhiteValentinePlaceByPlaceId(PlaceId) +end +--================== +--重置地点配置以外数据 +--================== +function XWhiteValentinePlace:ResetStatus() + self.EventCfg = nil + self.EventRankCfg = nil + self.EventAttrCfg = nil + self.EventFinishCount = 0 + self.DispatchingChara = nil + self.EventEndTime = 0 +end +--================== +--刷新数据 +--@param PlaceData:{int Id //地点ID,int RoleId //在该地点派遣的角色Id, int EventCfgId //事件Id, +-- long EventEndTime //结束时间戳,0 表示未派遣角色 +-- int EventFinishCount //此地点的完成事件计数} +--================== +function XWhiteValentinePlace:RefreshData(PlaceData) + if not PlaceData then return end + self.EventCfg = XWhiteValentineConfig.GetWhiteValentineEventByEventId(PlaceData.EventCfgId) + self.EventRankCfg = XWhiteValentineConfig.GetWhiteValentineRankConfigById(PlaceData.EventRankType) + self.EventAttrCfg = XWhiteValentineConfig.GetWhiteValentineAttrById(self.EventCfg.AttrType) + self.EventFinishCount = PlaceData.EventFinishCount + self.EventEndTime = PlaceData.EventEndTime + self:SetDispatchingChara(self.GameController:GetChara(PlaceData.RoleId)) +end +--=================== END ===================== +--=================对外接口(Get,Set,Check等接口)================ +--================== +--获取游戏ID +--================== +function XWhiteValentinePlace:GetGameId() + return self.GameController and self.GameController:GetGameId() +end +--================== +--获取地点ID +--================== +function XWhiteValentinePlace:GetPlaceId() + return self.Config and self.Config.Id +end +--================== +--获取地点序号 +--================== +function XWhiteValentinePlace:GetOrderId() + return self.Config and self.Config.OrderId +end +--================== +--获取地点开放前置 +--================== +function XWhiteValentinePlace:GetPrePlaceId() + return self.Config and self.Config.PrePlaceId +end +--================== +--获取地点附赠邀请次数 +--================== +function XWhiteValentinePlace:GetInviteNum() + return self.Config and self.Config.InviteNum +end +--================== +--获取默认事件 +--================== +function XWhiteValentinePlace:GetDefaultEventId() + return self.Config and self.Config.DefaultEventId +end +--================== +--获取随机事件池 +--================== +function XWhiteValentinePlace:GetRandomEventId() + return self.Config and self.Config.RandomEventId +end +--================== +--获取地点是否开放 +--================== +function XWhiteValentinePlace:GetIsOpen() + return self.EventCfg ~= nil +end +--================== +--获取事件名称 +--================== +function XWhiteValentinePlace:GetEventName() + return self.EventCfg and self.EventCfg.Name +end +--================== +--获取事件描述 +--================== +function XWhiteValentinePlace:GetEventDescription() + return self.EventCfg and self.EventCfg.Description +end +--================== +--获取阶级名称 +--================== +function XWhiteValentinePlace:GetEventRankName() + return self.EventRankCfg and self.EventRankCfg.Name +end +--================== +--获取事件阶级图标 +--================== +function XWhiteValentinePlace:GetRankIcon() + return self.EventRankCfg and self.EventRankCfg.IconPath +end +--================== +--获取事件阶级贡献值奖励 +--================== +function XWhiteValentinePlace:GetRankContributionReward() + return self.EventRankCfg and self.EventRankCfg.RewardContribution +end +--================== +--获取事件阶级消耗时间 +--================== +function XWhiteValentinePlace:GetCostTime() + return self.EventRankCfg and self.EventRankCfg.CostTime +end +--================== +--获取事件阶级金币奖励 +--================== +function XWhiteValentinePlace:GetRankCoinReward() + return self.EventRankCfg and self.EventRankCfg.RewardCoin +end +--================== +--获取地点背景图 +--================== +function XWhiteValentinePlace:GetBgPath() + return self.Config and self.Config.BgPath +end +--================== +--获取地点事件消耗体力 +--================== +function XWhiteValentinePlace:GetCostEnergy() + return self.EventRankCfg and self.EventRankCfg.CostEnergy or 0 +end +--================== +--获取地点事件属性图标 +--================== +function XWhiteValentinePlace:GetEventAttrIcon() + return self.EventAttrCfg and self.EventAttrCfg.IconPath +end +--================== +--获取地点事件属性种类 +--================== +function XWhiteValentinePlace:GetEventAttrType() + return self.EventAttrCfg and self.EventAttrCfg.Id +end +--================== +--获取派遣至此地点的角色 +--================== +function XWhiteValentinePlace:GetDispatchingChara() + return self.DispatchingChara +end +--================== +--设置派遣至此地点的角色 +--================== +function XWhiteValentinePlace:SetDispatchingChara(chara) + self.DispatchingChara = chara +end +--================== +--获取派遣结束时间,为0表示没有派遣 +--================== +function XWhiteValentinePlace:GetEventEndTime() + return self.EventEndTime or 0 +end +--================== +--获取离派遣结束的时间 +--================== +function XWhiteValentinePlace:GetEventEndTimeString() + local timeEnd = self:GetEventEndTime() + local timeNow = XTime.GetServerNowTimestamp() + local leftTime = timeEnd - timeNow + if leftTime < 0 then leftTime = 0 end + local string = CS.XTextManager.GetText("WhiteValentinePlaceCountDownStr", XUiHelper.GetTime(leftTime, XUiHelper.TimeFormatType.TO_A_MINUTE)) + return string +end +--================== +--获取是否正在派遣倒计时中,未派遣或已完成都会返回false +--================== +function XWhiteValentinePlace:GetIsDispatching() + local timeNow = XTime.GetServerNowTimestamp() + return (self.EventEndTime > 0) and (timeNow < self:GetEventEndTime()) +end +--================== +--检查本地点事件是否已完成 +--================== +function XWhiteValentinePlace:CheckCanFinishEvent() + if self:GetEventEndTime() == 0 then return false end + local timeNow = XTime.GetServerNowTimestamp() + return timeNow >= self.EventEndTime +end +--================== +--获取贡献值道具图标 +--================== +function XWhiteValentinePlace:GetContributionItemIcon() + return self.GameController:GetContributionItemIcon() +end +--================== +--获取金币图标 +--================== +function XWhiteValentinePlace:GetCoinItemIcon() + return self.GameController:GetCoinItemIcon() +end +--=================== END ===================== +return XWhiteValentinePlace \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XMiniGame/WhiteValentine2021/XWhiteValentinePlaceManager.lua b/Resources/Scripts/XEntity/XMiniGame/WhiteValentine2021/XWhiteValentinePlaceManager.lua new file mode 100644 index 00000000..23d0d2f7 --- /dev/null +++ b/Resources/Scripts/XEntity/XMiniGame/WhiteValentine2021/XWhiteValentinePlaceManager.lua @@ -0,0 +1,79 @@ +-- 白情活动地点管理器 +local XWhiteValentinePlaceManager = XClass(nil, "XWhiteValentinePlaceManager") + +function XWhiteValentinePlaceManager:Ctor(Game) + self.Game = Game + self:InitPlaces() +end +--================== +--初始化地点 +--================== +function XWhiteValentinePlaceManager:InitPlaces() + self.Places = {} + local PlaceObj = require("XEntity/XMiniGame/WhiteValentine2021/XWhiteValentinePlace") + local AllPlaces = XWhiteValentineConfig.GetAllWhiteValentinePlace() + for placeId, _ in pairs(AllPlaces) do + local newPlace = PlaceObj.New(self.Game, placeId) + self.Places[placeId] = newPlace + end +end +--================== +--刷新数据 +--@param PlaceDb:PlaceData集合。PlaceData = {int Id //地点ID,int RoleId //在该地点派遣的角色Id, int EventCfgId //事件Id, +-- long EventEndTime //结束时间戳,0 表示未派遣角色 +-- int EventFinishCount //此地点的完成事件计数} +--================== +function XWhiteValentinePlaceManager:RefreshData(PlaceDb) + if not PlaceDb then return end + for _, placeData in pairs(PlaceDb) do + local place = self.Places[placeData.Id] + if place then place:RefreshData(placeData) end + end +end +--================== +--刷新地点数据 +--@param PlaceData = {int Id //地点ID,int RoleId //在该地点派遣的角色Id, int EventCfgId //事件Id, +-- long EventEndTime //结束时间戳,0 表示未派遣角色 +-- int EventFinishCount //此地点的完成事件计数} +--================== +function XWhiteValentinePlaceManager:RefreshPlace(PlaceData) + local place = self.Places[PlaceData.Id] + if place then place:RefreshData(PlaceData) end +end +--================== +--批量刷新地点数据 +--@param PlaceDatas:PlaceData集合。PlaceData = {int Id //地点ID,int RoleId //在该地点派遣的角色Id, int EventCfgId //事件Id, +-- long EventEndTime //结束时间戳,0 表示未派遣角色 +-- int EventFinishCount //此地点的完成事件计数} +--================== +function XWhiteValentinePlaceManager:RefreshPlaceRange(PlaceDatas) + if not PlaceDatas then return end + for _, placeData in pairs(PlaceDatas) do + self:RefreshPlace(placeData) + end +end +--================== +--获取地点列表 +--================== +function XWhiteValentinePlaceManager:GetPlaceList() + return self.Places +end +--================== +--根据ID获取地点 +--@param placeId:地点ID +--================== +function XWhiteValentinePlaceManager:GetPlaceByPlaceId(placeId) + return self.Places[placeId] +end +--================== +--检查是否有事件已经结束 +--================== +function XWhiteValentinePlaceManager:CheckCanFinishEvent() + for _, place in pairs(self.Places) do + if place:CheckCanFinishEvent() then + return true + end + end + return false +end +return XWhiteValentinePlaceManager \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XMoeWar/XMoeWarMatch.lua b/Resources/Scripts/XEntity/XMoeWar/XMoeWarMatch.lua new file mode 100644 index 00000000..2211edc5 --- /dev/null +++ b/Resources/Scripts/XEntity/XMoeWar/XMoeWarMatch.lua @@ -0,0 +1,172 @@ +local XMoeWarMatch = XClass(nil, "XMoeWarMatch") + +local tableInsert = table.insert +local tableSort = table.sort +local stringFormat = string.format +local pairs = pairs +local ipairs = ipairs +local CsXTextManagerGetText = CS.XTextManager.GetText +local VoteEndShiftTime = CS.XGame.ClientConfig:GetInt("MoeWarVoteEndShiftTime") + +local Default = { + -- 赛事基本信息 + LastRefreshTime = 0, + RefreshTimeStr = nil, +} + +function XMoeWarMatch:Ctor(Id) + for key in pairs(Default) do + self[key] = Default[key] + end + + self.PlayerVoteDic = {} + self.PairList = {} + self:LoadMatchCfg(Id) +end + +function XMoeWarMatch:LoadMatchCfg(Id) + self.Id = Id + self.Cfg = XMoeWarConfig.GetMatch(Id) +end + +function XMoeWarMatch:UpdateInfo(data) + for i, playerInfo in ipairs(data.Players) do + self.PlayerVoteDic[playerInfo.PlayerId] = playerInfo.VoteShow + end + + -- 服务端定义的数据结构 + --public class XMoeWarPlayerPair <==> pairInfo + --{ + -- public int WinnerId; + -- public int SecondId; + -- public List Players = new List(); + --} + + self.PairList = {} + for _, pairInfo in ipairs(data.Pairs) do + for _, playerId in ipairs(pairInfo.Players) do + local player = XDataCenter.MoeWarManager.GetPlayer(playerId) + if player then + player:UpdateMatchVote(self, self.PlayerVoteDic[playerId], pairInfo) + end + end + table.sort(pairInfo.Players,function(a,b) + return a < b + end) + tableInsert(self.PairList, pairInfo) + end +end + +function XMoeWarMatch:GetName() + return self.Cfg.MatchName +end + +function XMoeWarMatch:GetSubName() + return self.Cfg.MatchSubName +end + +function XMoeWarMatch:GetType() + return self.Cfg.Type +end + +function XMoeWarMatch:GetInTime(isRealTime) + local nowTime = XTime.GetServerNowTimestamp() + return nowTime >= self:GetStartTime() and nowTime <= self:GetEndTime(isRealTime) +end + +function XMoeWarMatch:GetNotOpen() + local nowTime = XTime.GetServerNowTimestamp() + return nowTime <= self:GetStartTime() +end + +function XMoeWarMatch:GetIsEnd(isRealTime) + local nowTime = XTime.GetServerNowTimestamp() + return nowTime >= self:GetEndTime(isRealTime) +end + +function XMoeWarMatch:GetVoteEnd() + if self.Cfg.Type == XMoeWarConfig.MatchType.Voting then + return XTime.GetServerNowTimestamp() >= self:GetEndTime() + end + local twin = XDataCenter.MoeWarManager.GetVoteMatch(self:GetSessionId()) + return twin:GetIsEnd() +end + +function XMoeWarMatch:GetResultOut() + local match = XDataCenter.MoeWarManager.GetMatch(self:GetSessionId()) + if match:GetType() == XMoeWarConfig.MatchType.Publicity then + return true + end + return false +end + +function XMoeWarMatch:GetDailyLimitCount() + return CS.XGame.Config:GetInt("MoeWarDailyVoteLimit") +end + +function XMoeWarMatch:GetStartTime() + return XFunctionManager.GetStartTimeByTimeId(self.Cfg.TimeId) or 0 +end + +-- isRealTime : true则返回配置里定义的时间,否则投票期返回减去统计所需时间 +function XMoeWarMatch:GetEndTime(isRealTime) + if not isRealTime and self.Cfg.Type == XMoeWarConfig.MatchType.Voting then + local endTime = XFunctionManager.GetEndTimeByTimeId(self.Cfg.TimeId) + return endTime and endTime - VoteEndShiftTime or 0 + else + return XFunctionManager.GetEndTimeByTimeId(self.Cfg.TimeId) or 0 + end +end + +function XMoeWarMatch:GetSessionId() + return self.Cfg.SessionId +end + +function XMoeWarMatch:GetRefreshVoteTimeInDay() + return self.Cfg.RefreshVoteHour +end + +function XMoeWarMatch:GetCoverImg() + return self.Cfg.CoverImg +end + +function XMoeWarMatch:GetPairList() + return self.PairList +end + +function XMoeWarMatch:GetDesc() + return self.Cfg.Des +end + +function XMoeWarMatch:GetFinalImg() + return self.Cfg.FinalImg +end + +function XMoeWarMatch:GetPairListByGroupId(groupId) + local groupPairList = {} + for i = 1,#self.PairList do + local id = XMoeWarConfig.GetPlayerGroup(self.PairList[i].Players[1]) + if groupId == id then + tableInsert(groupPairList,self.PairList[i]) + end + end + return groupPairList +end + +function XMoeWarMatch:GetRefreshVoteText() + if self.Cfg.Type == XMoeWarConfig.MatchType.Publicity then + return "" + end + + if not self.RefreshTimeStr then + local refreshTimeStrList = {} + for i, v in ipairs(self.Cfg.RefreshVoteHour) do + refreshTimeStrList[i] = CsXTextManagerGetText("MoeWarMatchVoteRefreshTimeUnit", v) + end + self.RefreshTimeStr = table.concat(refreshTimeStrList, CsXTextManagerGetText("MoeWarMatchVoteRefreshTimeSplit")) + end + + return CsXTextManagerGetText("MoeWarMatchVoteRefresh", self.RefreshTimeStr) +end + +return XMoeWarMatch \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XMoeWar/XMoeWarPlayer.lua b/Resources/Scripts/XEntity/XMoeWar/XMoeWarPlayer.lua new file mode 100644 index 00000000..72748f94 --- /dev/null +++ b/Resources/Scripts/XEntity/XMoeWar/XMoeWarPlayer.lua @@ -0,0 +1,215 @@ +local XMoeWarPlayer = XClass(nil, "XMoeWarPlayer") + +local tableInsert = table.insert +local tableSort = table.sort +local stringFormat = string.format +local pairs = pairs +local ipairs = ipairs + +local Default = { + -- 选手基本信息 + TodaySupport = 0, + SupportTotal = 0, + MyVote = 0, + IsEliminate = false +} + +function XMoeWarPlayer:Ctor(Id) + for key in pairs(Default) do + self[key] = Default[key] + end + + self.Data = {} + self.MatchInfoDic = {} + self.DailyVoteDic = {} + self:LoadPlayerCfg(Id) +end + +function XMoeWarPlayer:LoadPlayerCfg(Id) + self.Id = Id + self.Cfg = XMoeWarConfig.GetPlayerCfg(Id) + self.Group = XMoeWarConfig.GetPlayerGroup(Id) +end + +--function XMoeWarPlayer:GetGroup() +-- return self.Group +--end +function XMoeWarPlayer:GetGroupName() + return XDataCenter.MoeWarManager.GetActivityInfo().GroupName[self.Group] +end + +function XMoeWarPlayer:GetName() + return self.Cfg.Name +end + +function XMoeWarPlayer:GetDesc() + return self.Cfg.Description +end + +function XMoeWarPlayer:GetModel() + return self.Cfg.ModelName +end + +function XMoeWarPlayer:GetJob() + return self.Cfg.CareerName +end + +function XMoeWarPlayer:GetCareerIcon() + return self.Cfg.CareerIcon +end + +function XMoeWarPlayer:GetCamp() + return self.Cfg.CampName +end + +function XMoeWarPlayer:GetAnim(actionType) + if actionType == XMoeWarConfig.ActionType.Intro then + return self.Cfg.IntroAnim + elseif actionType == XMoeWarConfig.ActionType.Thank then + return self.Cfg.ThankAnim + end +end + +function XMoeWarPlayer:GetCv(actionType) + if actionType == XMoeWarConfig.ActionType.Intro then + return self.Cfg.IntroCv + elseif actionType == XMoeWarConfig.ActionType.Thank then + return self.Cfg.ThankCv + end +end + +function XMoeWarPlayer:GetLength(actionType) + if actionType == XMoeWarConfig.ActionType.Intro then + return self.Cfg.IntroLength + elseif actionType == XMoeWarConfig.ActionType.Thank then + return self.Cfg.ThankLength + end +end + +function XMoeWarPlayer:GetActionBg() + return self.Cfg.ActionBg +end + +function XMoeWarPlayer:GetSquareHead() + return self.Cfg.SquareHead +end + +function XMoeWarPlayer:GetCircleHead() + return self.Cfg.CircleHead +end + +function XMoeWarPlayer:GetBigCharacterImage() + return self.Cfg.BigCharacterImage +end + +function XMoeWarPlayer:GetSupportCount(matchId) + if matchId then + local matchInfo = self.MatchInfoDic[matchId] + if matchInfo then + return matchInfo.VoteCount + else + return 0 + end + else + return self.SupportTotal + end +end + +function XMoeWarPlayer:GetMySupportCount(sId) + local match = XDataCenter.MoeWarManager.GetVoteMatch(sId) + if match then + local matchInfo = self.MatchInfoDic[match.Id] + if matchInfo and matchInfo.MyVote then + return matchInfo.MyVote + else + return 0 + end + else + return self.MyVote + end +end + +function XMoeWarPlayer:GetIsEliminate() + return self.IsEliminate +end + +function XMoeWarPlayer:GetShareImage() + return self.Cfg.ShareImg +end + +function XMoeWarPlayer:GetWinAnimGroupId(sessionId) + return self.Cfg.WinAnimGroupId[sessionId] +end + +function XMoeWarPlayer:GetLoseAnimGroupId(sessionId) + return self.Cfg.LoseAnimGroupId[sessionId] +end + +local SECOND_SESSIONID = 5--仅决赛时出现第二名(三人比赛),固定配置列5 +function XMoeWarPlayer:GetSecondAnimGroupId() + return self.Cfg.LoseAnimGroupId[SECOND_SESSIONID] +end + +function XMoeWarPlayer:UpdateDailyVote(itemId,voteCount) + self.DailyVoteDic[itemId] = voteCount +end + +function XMoeWarPlayer:GetDailyVoteByItemId(itemId) + return self.DailyVoteDic[itemId] or 0 +end + +function XMoeWarPlayer:UpdateMatchVote(match, voteCount, pairInfo) + local info = self.MatchInfoDic[match.Id] or {} + info.IsWin = pairInfo.WinnerId == self.Id + info.IsSecond = pairInfo.SecondId == self.Id + info.MyVote = info.MyVote or 0 + info.VoteCount = voteCount + self.SupportTotal = self.SupportTotal + voteCount + info.MatchEntity = match + -- 已结束 + if pairInfo.WinnerId ~= 0 then + info.IsOver = true + if not info.IsWin then + self.IsEliminate = true + end + end + self.MatchInfoDic[match.Id] = info +end + +function XMoeWarPlayer:UpdateMatchMyVote(data) + local matchInfo = self.MatchInfoDic[data.MatchId] + matchInfo.MyVote = data.MyVote or 0 + self.MyVote = self.MyVote + matchInfo.MyVote + + if matchInfo.IsOver then + self.MatchInfoDic[data.MatchId] = XReadOnlyTable.Create(matchInfo) + end +end + +--萌战投票请求 +function XMoeWarPlayer:RequestVote(itemNo, count, cb) + local req = { PlayerId = self.Id, + ItemId = XMoeWarConfig.GetVoteItemById(itemNo).ItemId, + Count = count } + XNetwork.Call("MoeWarVoteRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + if self.DailyVoteDic[req.ItemId] then + self.DailyVoteDic[req.ItemId] = self.DailyVoteDic[req.ItemId] + count + else + self.DailyVoteDic[req.ItemId] = count + end + XDataCenter.MoeWarManager.UpdateDailyVoteCount(res.Vote) + local matchInfo = self.MatchInfoDic[XDataCenter.MoeWarManager.GetCurMatchId()] + matchInfo.MyVote = matchInfo.MyVote + res.Vote + self.MyVote = self.MyVote + res.Vote + if cb then + cb(count) + end + XEventManager.DispatchEvent(XEventId.EVENT_MOE_WAR_VOTE_SUCC) + end) +end + +return XMoeWarPlayer \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XMoeWar/XMoeWarPreparationAnswerRecord.lua b/Resources/Scripts/XEntity/XMoeWar/XMoeWarPreparationAnswerRecord.lua new file mode 100644 index 00000000..da8dd53b --- /dev/null +++ b/Resources/Scripts/XEntity/XMoeWar/XMoeWarPreparationAnswerRecord.lua @@ -0,0 +1,44 @@ +--萌战赛事筹备--问题 +local type = type + +local XMoeWarPreparationAnswerRecord = XClass(nil, "XMoeWarPreparationAnswerRecord") + +local DefaultMain = { + QuestionId = 0, --问题 id + AnswerId = 0, --回答 id, 0 表示未回答 + IsRight = false, --是否正确 +} + +function XMoeWarPreparationAnswerRecord:Ctor() + for key, value in pairs(DefaultMain) do + if type(value) == "table" then + self[key] = {} + else + self[key] = value + end + end +end + +function XMoeWarPreparationAnswerRecord:UpdateData(data) + self.QuestionId = data.QuestionId + self.AnswerId = data.AnswerId + self.IsRight = data.IsRight +end + +function XMoeWarPreparationAnswerRecord:GetQuestionId() + return self.QuestionId +end + +function XMoeWarPreparationAnswerRecord:GetAnswerId() + return self.AnswerId +end + +function XMoeWarPreparationAnswerRecord:QuestionIsRight() + return self.IsRight +end + +function XMoeWarPreparationAnswerRecord:SetQuestionId(questionId) + self.QuestionId = questionId +end + +return XMoeWarPreparationAnswerRecord \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XMoeWar/XMoeWarPreparationAssistance.lua b/Resources/Scripts/XEntity/XMoeWar/XMoeWarPreparationAssistance.lua new file mode 100644 index 00000000..ec6ac159 --- /dev/null +++ b/Resources/Scripts/XEntity/XMoeWar/XMoeWarPreparationAssistance.lua @@ -0,0 +1,34 @@ +--萌战赛事筹备--援助数据 +local type = type + +local XMoeWarPreparationAssistance = XClass(nil, "XMoeWarPreparationAssistance") + +local DefaultMain = { + AssistanceCount = 0, --援助次数 + RecoveryTime = 0, --恢复时间点 +} + +function XMoeWarPreparationAssistance:Ctor() + for key, value in pairs(DefaultMain) do + if type(value) == "table" then + self[key] = {} + else + self[key] = value + end + end +end + +function XMoeWarPreparationAssistance:UpdateData(data) + self.AssistanceCount = data.AssistanceCount + self.RecoveryTime = data.RecoveryTime +end + +function XMoeWarPreparationAssistance:GetAssistanceCount() + return self.AssistanceCount +end + +function XMoeWarPreparationAssistance:GetRecoveryTime() + return self.RecoveryTime +end + +return XMoeWarPreparationAssistance \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XMoeWar/XMoeWarPreparationBaseData.lua b/Resources/Scripts/XEntity/XMoeWar/XMoeWarPreparationBaseData.lua new file mode 100644 index 00000000..c611dc43 --- /dev/null +++ b/Resources/Scripts/XEntity/XMoeWar/XMoeWarPreparationBaseData.lua @@ -0,0 +1,273 @@ +--萌战赛事筹备--基本数据 +local type = type +local tableInsert = table.insert + +local XMoeWarPreparationHelper = require("XEntity/XMoeWar/XMoeWarPreparationHelper") +local XMoeWarPreparationAssistance = require("XEntity/XMoeWar/XMoeWarPreparationAssistance") +local XMoeWarPreparationVoteItem = require("XEntity/XMoeWar/XMoeWarPreparationVoteItem") +local XMoeWarPreparationStage = require("XEntity/XMoeWar/XMoeWarPreparationStage") + +local XMoeWarPreparationBaseData = XClass(nil, "XMoeWarPreparationBaseData") + +local DefaultMain = { + ActivityId = 0, --活动id + MatchId = 0, --赛事阶段id + Stage = {}, --关卡对象 + GetRewardGears = {}, --已领取奖励的档位字典 + HelpersDic = {}, --帮手字典(服务端是列表) + Assistance = {}, --援助数据 + VoteItemsDic = {}, --应援道具 +} + +function XMoeWarPreparationBaseData:Ctor() + for key, value in pairs(DefaultMain) do + if type(value) == "table" then + self[key] = {} + else + self[key] = value + end + end + self.Assistance = XMoeWarPreparationAssistance.New() + self.Stage = XMoeWarPreparationStage.New() +end + +function XMoeWarPreparationBaseData:UpdateData(data) + if not data then return end + self.ActivityId = data.ActivityId + self.MatchId = data.MatchId + self.GetRewardGears = data.GetRewardGears + self:UpdateAssistance(data.Assistance) + self:UpdateHelper(data.Helpers) + self:UpdateVoteItems(data.VoteItems) + self:UpdateStage(data.Stage) +end + +------关卡对象 begin---------- +function XMoeWarPreparationBaseData:UpdateStage(stage) + self.Stage:UpdateData(stage) +end + +function XMoeWarPreparationBaseData:GetStages() + return self.Stage:GetStages() +end + +function XMoeWarPreparationBaseData:GetStagesAndOneReserveStage() + return self.Stage:GetStagesAndOneReserveStage() +end + +function XMoeWarPreparationBaseData:GetReserveStageTimeByIndex(index) + return self.Stage:GetReserveStageTimeByIndex(index) +end + +function XMoeWarPreparationBaseData:GetAllOpenStageIdList() + return self.Stage:GetAllOpenStageIdList() +end + +function XMoeWarPreparationBaseData:GetAllOpenStageCount() + return self.Stage:GetAllOpenStageCount() +end +------关卡对象 end---------- + +------应援数据 begin---------- +function XMoeWarPreparationBaseData:UpdateVoteItems(voteItems) + for _, voteItem in pairs(voteItems) do + self:UpdateVoteItem(voteItem) + end +end + +function XMoeWarPreparationBaseData:UpdateVoteItem(voteItem) + if not self.VoteItemsDic[voteItem.ItemId] then + self.VoteItemsDic[voteItem.ItemId] = XMoeWarPreparationVoteItem.New() + end + self.VoteItemsDic[voteItem.ItemId]:UpdateData(voteItem) +end + +function XMoeWarPreparationBaseData:GetVoteItemCount(itemId) + return self.VoteItemsDic[itemId] and self.VoteItemsDic[itemId]:GetItemCount() or 0 +end +------应援数据 end---------- + +--------帮手 begin---------- +function XMoeWarPreparationBaseData:GetHelper(helperId) + if not self.HelpersDic[helperId] then + self.HelpersDic[helperId] = XMoeWarPreparationHelper.New() + self.HelpersDic[helperId]:SetId(helperId) + end + return self.HelpersDic[helperId] +end + +function XMoeWarPreparationBaseData:UpdateHelper(helpers) + self.HelpersDic = {} + for _, helperData in ipairs(helpers) do + local helper = self:GetHelper(helperData.Id) + helper:UpdateData(helperData) + end +end + +function XMoeWarPreparationBaseData:GetHelperStatus(helperId) + if not XTool.IsNumberValid(helperId) then + return 0 + end + local helper = self:GetHelper(helperId) + return helper:GetStatus() +end + +function XMoeWarPreparationBaseData:GetHelperExpirationTime(helperId) + if not XTool.IsNumberValid(helperId) then + return 0 + end + local helper = self:GetHelper(helperId) + return helper:GetExpirationTime() +end + +function XMoeWarPreparationBaseData:GetTotalQuestionCount(helperId) + if not XTool.IsNumberValid(helperId) then + return 0 + end + local helper = self:GetHelper(helperId) + return helper:GetTotalQuestionCount() +end + +function XMoeWarPreparationBaseData:GetAnswerRecords(helperId) + if not XTool.IsNumberValid(helperId) then + return 0 + end + local helper = self:GetHelper(helperId) + return helper:GetAnswerRecords() +end + +function XMoeWarPreparationBaseData:GetFinishQuestionCount(helperId) + if not XTool.IsNumberValid(helperId) then + return 0 + end + local helper = self:GetHelper(helperId) + return helper:GetFinishQuestionCount() +end + +function XMoeWarPreparationBaseData:GetAllHelpersDic() + return self.HelpersDic +end + +function XMoeWarPreparationBaseData:InsertQuestion(helperId, questionId) + if not XTool.IsNumberValid(helperId) then + return + end + local helper = self:GetHelper(helperId) + helper:InsertQuestion(questionId) +end + +function XMoeWarPreparationBaseData:UpdateAnswerRecord(helperId, answerId, isRight) + if not XTool.IsNumberValid(helperId) then + return + end + local helper = self:GetHelper(helperId) + helper:UpdateAnswerRecord(answerId, isRight) +end + +function XMoeWarPreparationBaseData:SetCurrQuestionId(helperId, questionId) + if not XTool.IsNumberValid(helperId) then + return + end + local helper = self:GetHelper(helperId) + helper:SetCurrQuestionId(questionId) +end + +function XMoeWarPreparationBaseData:GetCurrQuestionId(helperId) + if not XTool.IsNumberValid(helperId) then + return + end + local helper = self:GetHelper(helperId) + return helper:GetCurrQuestionId() +end + +function XMoeWarPreparationBaseData:SetHelperStatus(helperId, status) + if not XTool.IsNumberValid(helperId) then + return + end + local helper = self:GetHelper(helperId) + helper:SetStatus(status) +end + +function XMoeWarPreparationBaseData:SetHelperExpirationTime(helperId, expirationTime) + if not XTool.IsNumberValid(helperId) then + return + end + local helper = self:GetHelper(helperId) + helper:SetExpirationTime(expirationTime) +end + +function XMoeWarPreparationBaseData:ClearAnswerRecords(helperId) + if not XTool.IsNumberValid(helperId) then + return + end + local helper = self:GetHelper(helperId) + helper:ClearAnswerRecords() +end + +function XMoeWarPreparationBaseData:AddOnceFinishQuestionCount(helperId) + if not XTool.IsNumberValid(helperId) then + return + end + local helper = self:GetHelper(helperId) + helper:AddOnceFinishQuestionCount() +end + +function XMoeWarPreparationBaseData:QuestionIsRight(helperId, questionId) + if not XTool.IsNumberValid(helperId) or not XTool.IsNumberValid(questionId) then + return false + end + + local helper = self:GetHelper(helperId) + return helper:QuestionIsRight(questionId) +end + +function XMoeWarPreparationBaseData:GetAnswerId(helperId, questionId) + if not XTool.IsNumberValid(helperId) or not XTool.IsNumberValid(questionId) then + return false + end + + local helper = self:GetHelper(helperId) + return helper:GetAnswerId(questionId) +end +--------帮手 end----------- + +------援助数据 begin---------- +function XMoeWarPreparationBaseData:UpdateAssistance(assistance) + self.Assistance:UpdateData(assistance) +end + +function XMoeWarPreparationBaseData:GetAssistanceCount() + return self.Assistance:GetAssistanceCount() +end + +function XMoeWarPreparationBaseData:GetAssistanceRecoveryTime() + return self.Assistance:GetRecoveryTime() +end +------援助数据 end---------- + +function XMoeWarPreparationBaseData:GetMatchId() + return self.MatchId +end + +function XMoeWarPreparationBaseData:GetActivityId() + return self.ActivityId +end + +function XMoeWarPreparationBaseData:SetOverReceiveRewardGear(gearId) + tableInsert(self.GetRewardGears, gearId) +end + +function XMoeWarPreparationBaseData:IsGetRewardGears(gear) + for _, gearId in pairs(self.GetRewardGears) do + if gear == gearId then + return true + end + end + return false +end + +function XMoeWarPreparationBaseData:ClearGetRewardGears() + self.GetRewardGears = {} +end + +return XMoeWarPreparationBaseData \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XMoeWar/XMoeWarPreparationHelper.lua b/Resources/Scripts/XEntity/XMoeWar/XMoeWarPreparationHelper.lua new file mode 100644 index 00000000..1705f4d7 --- /dev/null +++ b/Resources/Scripts/XEntity/XMoeWar/XMoeWarPreparationHelper.lua @@ -0,0 +1,206 @@ +--萌战赛事筹备--帮手数据 +local type = type +local tableInsert = table.insert +local tableRemove = table.remove + +local XMoeWarPreparationAnswerRecord = require("XEntity/XMoeWar/XMoeWarPreparationAnswerRecord") + +local XMoeWarPreparationHelper = XClass(nil, "XMoeWarPreparationHelper") + +local DefaultMain = { + Id = 0, --帮手id + ExpirationTime = 0, --过期时间点,0表示不会过期 + TotalQuestionCount = 0, --题目总数 + FinishQuestionCount = 0, --回答正确的题目数量 + Status = 0, --帮手状态 + AnswerRecords = {}, --回答记录 +} + +function XMoeWarPreparationHelper:Ctor() + for key, value in pairs(DefaultMain) do + if type(value) == "table" then + self[key] = {} + else + self[key] = value + end + end + self.CurrQuestionId = 0 +end + +function XMoeWarPreparationHelper:UpdateData(data) + self.Id = data.Id + self.TotalQuestionCount = data.TotalQuestionCount + self.FinishQuestionCount = data.FinishQuestionCount + self.ExpirationTime = data.ExpirationTime + self.Status = data.Status + self:UpdateAnswerRecords(data.AnswerRecords) +end + +function XMoeWarPreparationHelper:SetId(id) + self.Id = id +end + +function XMoeWarPreparationHelper:UpdateAnswerRecords(answerRecords) + self.AnswerRecords = {} + self:CheckQuestionStart() + + local answerRecord + for _, anserRecordData in ipairs(answerRecords) do + answerRecord = XMoeWarPreparationAnswerRecord.New() + answerRecord:UpdateData(anserRecordData) + tableInsert(self.AnswerRecords, answerRecord) + end +end + +function XMoeWarPreparationHelper:GetAnswerRecords() + return self.AnswerRecords +end + +function XMoeWarPreparationHelper:CheckQuestionStart() + local status = self:GetStatus() + if status ~= XMoeWarConfig.PreparationHelperStatus.Communicating then + return + end + + local isHasQuestionStart = false + for _, answerRecord in ipairs(self.AnswerRecords) do + local questionId = answerRecord:GetQuestionId() + local questionType = XMoeWarConfig.GetPreparationQuestionType(questionId) + if questionType == XMoeWarConfig.QuestionType.QuestionStart then + isHasQuestionStart = true + break + end + end + if not isHasQuestionStart then + local questionStartList = XMoeWarConfig.GetPreparationQuestionIdListByType(self.Id, XMoeWarConfig.QuestionType.QuestionStart) + local answerRecord + for _, questionId in ipairs(questionStartList) do + answerRecord = XMoeWarPreparationAnswerRecord.New() + answerRecord:SetQuestionId(questionId) + tableInsert(self.AnswerRecords, answerRecord) + end + end +end + +--检查问题是否都完了,插入结束语 +function XMoeWarPreparationHelper:CheckQuestionEnd() + local isHasQuestionEnd = false + for _, answerRecord in ipairs(self.AnswerRecords) do + local questionId = answerRecord:GetQuestionId() + local questionType = XMoeWarConfig.GetPreparationQuestionType(questionId) + if questionType == XMoeWarConfig.QuestionType.RecruitRight or questionType == XMoeWarConfig.QuestionType.RecruitLose then + isHasQuestionEnd = true + break + end + end + if (not isHasQuestionEnd) and (self.Status == XMoeWarConfig.PreparationHelperStatus.CommunicationEnd or self.Status == XMoeWarConfig.PreparationHelperStatus.RecruitFinish) then + local questionType = self.Status == XMoeWarConfig.PreparationHelperStatus.CommunicationEnd and XMoeWarConfig.QuestionType.RecruitLose or XMoeWarConfig.QuestionType.RecruitRight + local questionId = XMoeWarConfig.GetPreparationQuestionId(self.Id, questionType) + local answerRecord = XMoeWarPreparationAnswerRecord.New() + answerRecord:SetQuestionId(questionId) + tableInsert(self.AnswerRecords, answerRecord) + end +end + +function XMoeWarPreparationHelper:InsertQuestion(questionId) + local answerRecord = self:GetAnswerRecordByQuestionId(questionId) + if answerRecord then + return + end + self:CheckQuestionStart() + answerRecord = XMoeWarPreparationAnswerRecord.New() + answerRecord:SetQuestionId(questionId) + tableInsert(self.AnswerRecords, answerRecord) +end + +function XMoeWarPreparationHelper:UpdateAnswerRecord(answerId, isRight) + local questionId = self:GetCurrQuestionId() + local answerRecord = self:GetAnswerRecordByQuestionId(questionId) + if answerRecord then + answerRecord:UpdateData({QuestionId = questionId, AnswerId = answerId, IsRight = isRight}) + end +end + +function XMoeWarPreparationHelper:GetAnswerRecordByQuestionId(questionId) + for _, answerRecord in ipairs(self.AnswerRecords) do + if answerRecord:GetQuestionId() == questionId then + return answerRecord + end + end +end + +function XMoeWarPreparationHelper:SetStatus(status) + self.Status = status + if status == XMoeWarConfig.PreparationHelperStatus.CommunicationEnd or status == XMoeWarConfig.PreparationHelperStatus.RecruitFinish then + self:CheckQuestionEnd() + end + if status == XMoeWarConfig.PreparationHelperStatus.NotCommunicating then + self:ResetData() + end +end + +function XMoeWarPreparationHelper:ResetData() + self.FinishQuestionCount = 0 + self:ClearAnswerRecords() +end + +function XMoeWarPreparationHelper:SetCurrQuestionId(currQuestionId) + self.CurrQuestionId = currQuestionId +end + +function XMoeWarPreparationHelper:SetExpirationTime(expirationTime) + self.ExpirationTime = expirationTime +end + +function XMoeWarPreparationHelper:ClearAnswerRecords() + self.AnswerRecords = {} +end + +function XMoeWarPreparationHelper:GetCurrQuestionId() + return self.CurrQuestionId +end + +function XMoeWarPreparationHelper:GetId() + return self.Id +end + +function XMoeWarPreparationHelper:GetTotalQuestionCount() + return self.TotalQuestionCount +end + +function XMoeWarPreparationHelper:GetStatus() + return self.Status +end + +function XMoeWarPreparationHelper:GetExpirationTime() + return self.ExpirationTime +end + +function XMoeWarPreparationHelper:AddOnceFinishQuestionCount() + self.FinishQuestionCount = self.FinishQuestionCount + 1 +end + +function XMoeWarPreparationHelper:GetFinishQuestionCount() + return self.FinishQuestionCount +end + +function XMoeWarPreparationHelper:GetAnswerRecord(questionId) + local answerRecords = self:GetAnswerRecords() + for _, v in ipairs(answerRecords) do + if v:GetQuestionId() == questionId then + return v + end + end +end + +function XMoeWarPreparationHelper:QuestionIsRight(questionId) + local answerRecord = self:GetAnswerRecord(questionId) + return answerRecord and answerRecord:QuestionIsRight() or 0 +end + +function XMoeWarPreparationHelper:GetAnswerId(questionId) + local answerRecord = self:GetAnswerRecord(questionId) + return answerRecord and answerRecord:GetAnswerId() or 0 +end + +return XMoeWarPreparationHelper \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XMoeWar/XMoeWarPreparationQuestion.lua b/Resources/Scripts/XEntity/XMoeWar/XMoeWarPreparationQuestion.lua new file mode 100644 index 00000000..7ccd1d98 --- /dev/null +++ b/Resources/Scripts/XEntity/XMoeWar/XMoeWarPreparationQuestion.lua @@ -0,0 +1,41 @@ +--萌战赛事筹备--帮手数据 +local type = type + +local XMoeWarPreparationQuestion = XClass(nil, "XMoeWarPreparationQuestion") + +local DefaultMain = { + QuestionId = 0, --问题 id + AnswerId = 0, --回答 id, 0 表示未回答 + IsRight = 0, --是否正确,0 表示不正确 +} + +function XMoeWarPreparationQuestion:Ctor(data) + for key, value in pairs(DefaultMain) do + if type(value) == "table" then + self[key] = {} + else + self[key] = value + end + end + self:UpdateData(data) +end + +function XMoeWarPreparationQuestion:UpdateData(data) + self.QuestionId = data.QuestionId + self.AnswerId = data.AnswerId + self.IsRight = data.IsRight +end + +function XMoeWarPreparationQuestion:GetQuestionId() + return self.QuestionId +end + +function XMoeWarPreparationQuestion:GetAnswerId() + return self.AnswerId +end + +function XMoeWarPreparationQuestion:IsRight() + return self.IsRight == 1 +end + +return XMoeWarPreparationQuestion \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XMoeWar/XMoeWarPreparationStage.lua b/Resources/Scripts/XEntity/XMoeWar/XMoeWarPreparationStage.lua new file mode 100644 index 00000000..d08c2279 --- /dev/null +++ b/Resources/Scripts/XEntity/XMoeWar/XMoeWarPreparationStage.lua @@ -0,0 +1,119 @@ +--萌战赛事筹备--关卡数据 +local type = type +local tableInsert = table.insert + +local XMoeWarPreparationStage = XClass(nil, "XMoeWarPreparationStage") + +local DefaultMain = { + LastStageRecoveryTime = 0, --上次关卡恢复时间点 + Stages = {}, --关卡列表 + ReserveStages = {}, --后备关卡 +} + +function XMoeWarPreparationStage:Ctor() + for key, value in pairs(DefaultMain) do + if type(value) == "table" then + self[key] = {} + else + self[key] = value + end + end + self.StagesTimeList = {} +end + +function XMoeWarPreparationStage:UpdateData(data) + self.LastStageRecoveryTime = data.LastStageRecoveryTime + self.Stages = data.Stages + self.ReserveStages = data.ReserveStages + self:UpdateStagesTime() +end + +function XMoeWarPreparationStage:UpdateStagesTime() + local activityId = XMoeWarConfig.GetPreparationActivityIdInTime(true) or XMoeWarConfig.GetPreparationDefaultActivityId() --服务器下发数据时,etcd时间可能还没下发 + if not activityId then + return + end + + local stages = self:GetStages() + local reserveStages = self:GetReserveStages() + local lastStageRecoveryTime = self:GetLastStageRecoveryTime() + + self.StagesTimeList = {} + for i in ipairs(stages) do + self.StagesTimeList[i] = 0 + end + + local stageRecoveryTime = XMoeWarConfig.GetPreparationActivityStageRecoveryTime(activityId) + local stagesNewIndex = #stages + for i in ipairs(reserveStages) do + stagesNewIndex = stagesNewIndex + 1 + self.StagesTimeList[stagesNewIndex] = lastStageRecoveryTime + stageRecoveryTime * i + end +end + +function XMoeWarPreparationStage:GetStages() + return self.Stages +end + +function XMoeWarPreparationStage:GetReserveStages() + return self.ReserveStages +end + +function XMoeWarPreparationStage:GetLastStageRecoveryTime() + return self.LastStageRecoveryTime +end + +--返回所有已开启的关卡和一个未开启的后备关卡 +function XMoeWarPreparationStage:GetStagesAndOneReserveStage() + local stageIds = {} + local stages = self:GetStages() + local reserveStages = self:GetReserveStages() + + for _, stageId in ipairs(stages) do + tableInsert(stageIds, stageId) + end + + local nowServerTime = XTime.GetServerNowTimestamp() + local stagesNewIndex = #stageIds + local reserveStageTime + for _, stageId in ipairs(reserveStages) do + stagesNewIndex = stagesNewIndex + 1 + reserveStageTime = self:GetReserveStageTimeByIndex(stagesNewIndex) + tableInsert(stageIds, stageId) + if reserveStageTime > nowServerTime then + break + end + end + return stageIds +end + +function XMoeWarPreparationStage:GetAllOpenStageIdList() + local stages = self:GetStages() + local stagesClone = XTool.Clone(stages) + local reserveStages = self:GetReserveStages() + + local nowServerTime = XTime.GetServerNowTimestamp() + local reserveStageTime + local stagesNewIndex = #stagesClone + for _, stageId in ipairs(reserveStages) do + stagesNewIndex = stagesNewIndex + 1 + reserveStageTime = self:GetReserveStageTimeByIndex(stagesNewIndex) + if reserveStageTime <= nowServerTime then + tableInsert(stagesClone, stageId) + else + break + end + end + return stagesClone +end + +function XMoeWarPreparationStage:GetAllOpenStageCount() + local allOpenStageList = self:GetAllOpenStageIdList() + return #allOpenStageList +end + +function XMoeWarPreparationStage:GetReserveStageTimeByIndex(index) + return self.StagesTimeList[index] or 0 +end + +return XMoeWarPreparationStage \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XMoeWar/XMoeWarPreparationVoteItem.lua b/Resources/Scripts/XEntity/XMoeWar/XMoeWarPreparationVoteItem.lua new file mode 100644 index 00000000..565ea37a --- /dev/null +++ b/Resources/Scripts/XEntity/XMoeWar/XMoeWarPreparationVoteItem.lua @@ -0,0 +1,30 @@ +--萌战赛事筹备--应援数据 +local type = type + +local XMoeWarPreparationVoteItem = XClass(nil, "XMoeWarPreparationVoteItem") + +local DefaultMain = { + ItemId = 0, --道具id + ItemCount = 0, --道具数量 +} + +function XMoeWarPreparationVoteItem:Ctor() + for key, value in pairs(DefaultMain) do + if type(value) == "table" then + self[key] = {} + else + self[key] = value + end + end +end + +function XMoeWarPreparationVoteItem:UpdateData(data) + self.ItemId = data.ItemId + self.ItemCount = data.ItemCount +end + +function XMoeWarPreparationVoteItem:GetItemCount() + return self.ItemCount +end + +return XMoeWarPreparationVoteItem \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XMoeWar/XMoeWarVoteItem.lua b/Resources/Scripts/XEntity/XMoeWar/XMoeWarVoteItem.lua new file mode 100644 index 00000000..b16996e6 --- /dev/null +++ b/Resources/Scripts/XEntity/XMoeWar/XMoeWarVoteItem.lua @@ -0,0 +1,43 @@ +local XMoeWarVoteItem = XClass(nil, "XMoeWarVoteItem") + +function XMoeWarVoteItem:Ctor(id) + self.Cfg = XMoeWarConfig.GetVoteItemById(id) + self:InitDailyLimitData() +end + +function XMoeWarVoteItem:InitDailyLimitData() + self.DailyLimitDic = {} + for i = 1, #self.Cfg.MatchId do + self.DailyLimitDic[self.Cfg.MatchId[i]] = self.Cfg.DailyLimitCount[i] + end +end + +function XMoeWarVoteItem:GetVoteItemId() + return self.Cfg.ItemId +end + +function XMoeWarVoteItem:GetVoteFactor() + return self.Cfg.VoteFactor +end + +function XMoeWarVoteItem:GetMultiple() + return self.Cfg.Multiple +end + +function XMoeWarVoteItem:GetCoinFactor() + return self.Cfg.CoinFactor +end + +function XMoeWarVoteItem:IsLimitVote() + return self.Cfg.IsLimit == 1 +end + +function XMoeWarVoteItem:GetDailyLimitCountByMatchId(matchId) + return self.DailyLimitDic[matchId] or 0 +end + +function XMoeWarVoteItem:GetLimitText() + +end + +return XMoeWarVoteItem \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XNameplate/XNameplate.lua b/Resources/Scripts/XEntity/XNameplate/XNameplate.lua new file mode 100644 index 00000000..8c0e8006 --- /dev/null +++ b/Resources/Scripts/XEntity/XNameplate/XNameplate.lua @@ -0,0 +1,137 @@ +local XNameplate = XClass(nil, "XNameplate") + +function XNameplate:Ctor(data) + self:UpdateData(data) +end + +function XNameplate:UpdateData(data) + self.Id = data.Id + self.LastExp = self.Exp or data.Exp + self.Exp = data.Exp + self.EndTime = (self.EndTime and self.EndTime > data.EndTime) and self.EndTime or data.EndTime + self.GetTime = data.GetTime + self.Config = XMedalConfigs.GetNameplateConfigById(self.Id) +end + + +function XNameplate:GetNameplateId() + return self.Id +end + +function XNameplate:GetNamepalteEndTime() + return self.EndTime +end + +function XNameplate:GetNamepalteExp() + return self.Exp +end + +function XNameplate:GetNamepalteLastExp() + return self.LastExp +end + +function XNameplate:GetNamepalteGetTime() + return self.GetTime +end + +function XNameplate:GetNamepalteGetTimeToString() + if self.GetTime ~= 0 then + local dayFormat = CS.XTextManager.GetText("UnionCnFormatDate") + return XTime.TimestampToGameDateTimeString(self.GetTime, dayFormat) + end + return +end + +function XNameplate:GetNamepalteLeftTime() + return self.EndTime - XTime.GetServerNowTimestamp() +end + +--判断铭牌是否过期 +function XNameplate:IsNamepalteExpire() + if not self:IsNamepalteForever() then + local nowTime = XTime.GetServerNowTimestamp() + if nowTime >= self.EndTime then + return true + end + end + return false +end + +--判断铭牌是否是被穿戴的 +function XNameplate:IsNameplateDress() + return not self:IsNamepalteExpire() and XDataCenter.MedalManager.GetNameplateCurId() == self.Id +end + +function XNameplate:IsNameplateNew() + return XDataCenter.MedalManager.CheckHaveNewNameplateById(self.Id) and not self:IsNamepalteExpire() +end + +function XNameplate:GetNameplateName() + return self.Config.Name +end + +function XNameplate:GetNameplateQuality() + return self.Config.NameplateQuality +end + +function XNameplate:GetNameplateGroup() + return self.Config.Group +end + +function XNameplate:GetNameplateDescription() + return self.Config.Description +end + +function XNameplate:GetNameplateGetWay() + return self.Config.NameplateGetWay +end + +function XNameplate:GetNameplateHint() + return self.Config.Hint +end + +function XNameplate:GetNameplateUpgradeType() + return self.Config.NameplateUpgradeType +end + +function XNameplate:GetNameplateConvertItemId() + return self.Config.ConvertItemId +end + +function XNameplate:GetNameplateConvertItemCount() + return self.Config.ConvertItemCount +end + +function XNameplate:GetNameplateTitle() + return self.Config.Title +end + +function XNameplate:GetNameplateIconType() + return self.Config.IconType +end + +function XNameplate:GetNameplateIcon() + return self.Config.Icon +end + +function XNameplate:GetNameplateBackBoard() + return self.Config.BackBoard +end + +function XNameplate:GetNameplateOutLineColor() + return self.Config.OutLineColor +end + +function XNameplate:GetNameplateQualityIcon() + return self.Config.QualityIcon +end + +function XNameplate:IsNamepalteForever() + return self.EndTime == 0 +end + +function XNameplate:GetNameplateUpgradeExp() + return self.Config.UpgradeExp +end + +return XNameplate diff --git a/Resources/Scripts/XEntity/XNieR/XNieRBoss.lua b/Resources/Scripts/XEntity/XNieR/XNieRBoss.lua new file mode 100644 index 00000000..c4d2129e --- /dev/null +++ b/Resources/Scripts/XEntity/XNieR/XNieRBoss.lua @@ -0,0 +1,30 @@ +local XNieRBoss = XClass(nil, "XNieRBoss") + +function XNieRBoss:Ctor(data, chapterId) + self:UpdateData(data, chapterId) +end + +function XNieRBoss:UpdateData(data, chapterId) + self.StageId = data.StageId + self.LeftHp = data.LeftHp + self.Score = data.Score + self.MaxHp = data.MaxHp +end + +function XNieRBoss:GetLeftHp() + return self.LeftHp +end + +function XNieRBoss:GetScore() + return self.Score +end + +function XNieRBoss:GetMaxHp() + return self.MaxHp +end + +function XNieRBoss:IsBossDeath() + return self.LeftHp <= 0 +end + +return XNieRBoss \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XNieR/XNieRChapter.lua b/Resources/Scripts/XEntity/XNieR/XNieRChapter.lua new file mode 100644 index 00000000..6f04d5d2 --- /dev/null +++ b/Resources/Scripts/XEntity/XNieR/XNieRChapter.lua @@ -0,0 +1,112 @@ +local XNieRChapter = XClass(nil, "XNieRChapter") + +function XNieRChapter:Ctor(id, index) + self.Id = id + self.Index = index + self.ChapterCfg = XNieRConfigs.GetChapterConfigById(id) +end + +function XNieRChapter:SetLastBossAtk(lastBossAtk) + self.LastBossAtk = lastBossAtk +end + +function XNieRChapter:GetLastBossAtk() + return self.LastBossAtk +end + +function XNieRChapter:CheckNieRChapterUnLock() + local chapterStartTime = self:GetNierChapterStartTime() + local chapterEndTime = self:GetNierChapterEndTime() + local nowTime = XTime.GetServerNowTimestamp() + local isUnLock, desc = true, "" + if self.ChapterCfg.Condition ~= 0 then + isUnLock, desc = XConditionManager.CheckCondition(self.ChapterCfg.Condition) + end + if isUnLock then + if chapterStartTime ~= 0 then + if nowTime >= chapterStartTime and nowTime <= chapterEndTime then + desc = CS.XTextManager.GetText("NieRActivityChapterLock", os.date("%Y/%m/%d", chapterStartTime)) + + elseif nowTime < chapterStartTime then + isUnLock = false + desc = CS.XTextManager.GetText("NieRActivityChapterLock", os.date("%Y/%m/%d", chapterStartTime)) + elseif nowTime > chapterEndTime then + isUnLock = false + desc = CS.XTextManager.GetText("NieRActivityChapterEnd") + end + end + end + return isUnLock, desc +end + +function XNieRChapter:GetChapterId() + return self.Id +end + +function XNieRChapter:GetIndex() + return self.Index +end + +function XNieRChapter:GetNierChapterCfg() + return self.ChapterCfg +end + +function XNieRChapter:GetNierChapterStageIds() + return self.ChapterCfg.StageIds +end + +function XNieRChapter:GetNieRBossStageId() + return self.ChapterCfg.BossStageId +end + +function XNieRChapter:GetNierChapterRobotIds() + return self.ChapterCfg.RobotIds +end + +function XNieRChapter:GetNierChapterStartTime() + if not self.ChapterCfg then return 0 end + return self.ChapterCfg.TimeId ~= 0 and XFunctionManager.GetStartTimeByTimeId(self.ChapterCfg.TimeId) or 0 +end + +function XNieRChapter:GetNierChapterEndTime() + if not self.ChapterCfg then return 0 end + return self.ChapterCfg.TimeId ~= 0 and XFunctionManager.GetEndTimeByTimeId(self.ChapterCfg.TimeId) or 0 +end + +function XNieRChapter:GetNieRChapterName() + return self.ChapterCfg.Title +end + +function XNieRChapter:GetNieRChapterIcon() + return self.ChapterCfg.Icon +end + +function XNieRChapter:GetNieRChapterTaskSkipId() + return self.ChapterCfg.TaskSkipId +end + +function XNieRChapter:GetNieRRepeatPoStagePos() + return self.ChapterCfg.RepeatPoStagePos +end + +function XNieRChapter:GetNieRRepeatPoStageId() + local pos = self.ChapterCfg.RepeatPoStagePos + local stageIds = self.ChapterCfg.StageIds + return stageIds[pos] +end + + +function XNieRChapter:GetNieRRepeatPoStageLabel() + return self.ChapterCfg.RepeatPoStageLabel +end + + +function XNieRChapter:GetNieRChapterPhaseStr() + if XDataCenter.FubenManager.CheckStageIsUnlock(self:GetNieRBossStageId()) then + return CS.XTextManager.GetText("NieRChapterPhaseStr", 2) + else + return CS.XTextManager.GetText("NieRChapterPhaseStr", 1) + end +end + +return XNieRChapter \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XNieR/XNieRCharacter.lua b/Resources/Scripts/XEntity/XNieR/XNieRCharacter.lua new file mode 100644 index 00000000..e8168e7c --- /dev/null +++ b/Resources/Scripts/XEntity/XNieR/XNieRCharacter.lua @@ -0,0 +1,360 @@ +local XNieRCharacter = XClass(nil, "XNieRCharacter") + +function XNieRCharacter:Ctor(data) + self:UpdateNieRCharacter(data) +end + +function XNieRCharacter:UpdateNieRCharacter(data) + self.Id = data.CharacterId + self.Level = data.Level + self.Exp = data.Exp + self.FashionId = data.FashionId + self.Config = XNieRConfigs.GetCharacterConfigById(data.CharacterId) + self.ClientConfig = XNieRConfigs.GetCharacterClientConfigById(data.CharacterId) + if not self.LastLevel or self.LastLevel ~= self.Level then + self.LevelConfig = XNieRConfigs.GetCharacterLevelConfig(data.CharacterId, data.Level) + end + self.LastLevel = data.Level + self.NeedUpdateNieRCharAbility = true +end + +function XNieRCharacter:ResetNeedUpdateNieRCharAbility() + self.NeedUpdateNieRCharAbility = true +end + +function XNieRCharacter:GetAllNieRAbilityConfigList() + return XNieRConfigs.GetAbilityGroupConfigByGroupId(self.Config.AbilityGroupId) or {} +end + +function XNieRCharacter:UpdateCharacterAbility() + if not self.NeedUpdateNieRCharAbility then return end + self.NeedUpdateNieRCharAbility = false + local configList = XNieRConfigs.GetAbilityGroupConfigByGroupId(self.Config.AbilityGroupId) + table.sort(configList, function(a, b) + return a.Id > b.Id + end) + + local tmpConfig = {} + local configCount = #configList + --tmpConfig.Skills = {} + tmpConfig.SkillsData = {} + tmpConfig.FashionIds = {} + for index = 1, configCount, 1 do + local config = configList[index] + + if config.Condition == 0 or XConditionManager.CheckCondition(config.Condition) then + + if config.SkillId ~= 0 and config.SkillLevel ~= 0 and (not tmpConfig.SkillsData[config.SkillId] or (tmpConfig.SkillsData[config.SkillId] and tmpConfig.SkillsData[config.SkillId]) < config.SkillLevel) then + --tmpConfig.Skills[config.SkillId] = config.Id + tmpConfig.SkillsData[config.SkillId] = config.SkillLevel + elseif config.FashionId ~= 0 then + tmpConfig.FashionIds[config.FashionId] = config.Id + elseif not tmpConfig.WeaponConfigId and config.WeaponId ~= 0 then + tmpConfig.WeaponConfigId = config.Id + tmpConfig.WeaponId = config.WeaponId + elseif not tmpConfig.FourWafer and #(config.WaferId) == 4 then + tmpConfig.FourWafer = config.Id + elseif not tmpConfig.TwoWafer and #(config.WaferId) == 2 then + tmpConfig.TwoWafer = config.Id + end + + end + end + + + tmpConfig.Wafers = {} + if tmpConfig.FourWafer and tmpConfig.FourWafer ~= 0 then + local config = XNieRConfigs.GetAbilityGroupConfigById(tmpConfig.FourWafer) + for key, waferId in pairs(config.WaferId) do + tmpConfig.Wafers[waferId] = config.WaferBreakThrough[key] + end + end + + if tmpConfig.TwoWafer and tmpConfig.TwoWafer ~= 0 then + local config = XNieRConfigs.GetAbilityGroupConfigById(tmpConfig.TwoWafer) + for key, waferId in pairs(config.WaferId) do + tmpConfig.Wafers[waferId] = config.WaferBreakThrough[key] + end + end + self.AbilityConfig = tmpConfig +end + +function XNieRCharacter:GetNieRCharacterId() + return self.Id +end + +function XNieRCharacter:GetNieRCharacterLevel() + return self.Level or 0 +end + +function XNieRCharacter:GetNieRCharacterExp() + return self.Exp or 0 +end + +function XNieRCharacter:GetNieRCharacterCfgEasterEggFightTag() + return self.Config.EasterEggFightTag +end + +function XNieRCharacter:ChangeNieRFashionId(fashionId) + self.FashionId = fashionId +end + +function XNieRCharacter:CheckNieRCharacterMaxLevel() + local maxLevel = XNieRConfigs.GetCharacterMaxLevelById(self:GetNieRCharacterId()) + return self:GetNieRCharacterLevel() >= maxLevel +end + +function XNieRCharacter:CheckNieRCharacterCondition() + local check, desc = true, "" + if self.Config.Condition ~= 0 then + check, desc = XConditionManager.CheckCondition(self.Config.Condition) + end + return check, desc +end + +function XNieRCharacter:GetNieRFashionId() + local fashionId = self.FashionId + if not fashionId or fashionId == 0 then + local robotCfg = XRobotManager.GetRobotTemplate(self:GetNieRCharacterRobotId()) + fashionId = robotCfg.FashionId + end + return fashionId +end + +function XNieRCharacter:GetNieRFashionList() + self:UpdateCharacterAbility() + local fashionList = {} + for fId, confId in pairs(self.AbilityConfig.FashionIds) do + table.insert(fashionList, fId) + end + local dressFashionId = self:GetNieRFashionId() + if #fashionList > 1 then + table.sort(fashionList, function(a, b) + local status1, status2 = a == dressFashionId and 1 or 0, b == dressFashionId and 1 or 0 + + if status1 ~= status2 then + return status1 > status2 + end + + return XDataCenter.FashionManager.GetFashionPriority(a) > XDataCenter.FashionManager.GetFashionPriority(b) + end) + end + return fashionList +end + +function XNieRCharacter:GetNieRCharacterMaxExp() + return self.LevelConfig.MaxExp +end + +function XNieRCharacter:GetNieRCharacterRobotId() + return self.LevelConfig.RobotId +end + +function XNieRCharacter:GetNieRWeaponId() + self:UpdateCharacterAbility() + local weaponId = self.AbilityConfig.WeaponId + if not weaponId or weaponId == 0 then + local robotCfg = XRobotManager.GetRobotTemplate(self:GetNieRCharacterRobotId()) + weaponId = robotCfg.WeaponId + end + return weaponId +end + +function XNieRCharacter:GetNieRWeaponLevel() + self:UpdateCharacterAbility() + local weaponLevel = self.LevelConfig.WeaponLevel + local limitLevel = 0 + if self.AbilityConfig.WeaponId then + limitLevel = XDataCenter.EquipManager.GetBreakthroughLevelLimitByTemplateId(self.AbilityConfig.WeaponId, self:GetNieRWeaponBreakThrough()) + weaponLevel = weaponLevel > limitLevel and limitLevel or weaponLevel + else + weaponLevel = 1 + end + + return weaponLevel +end + +function XNieRCharacter:GetNieRWeaponBreakThrough() + self:UpdateCharacterAbility() + if not self.AbilityConfig.WeaponConfigId then + return 0 + end + return XNieRConfigs.GetAbilityGroupConfigById(self.AbilityConfig.WeaponConfigId).WeaponBreakThrough +end + +function XNieRCharacter:GetNieRWaferLevel(waferId) + self:UpdateCharacterAbility() + local waferLevel = self.LevelConfig.WaferLevel + local limitLevel = 0 + if self.AbilityConfig.Wafers[waferId] then + limitLevel = XDataCenter.EquipManager.GetBreakthroughLevelLimitByTemplateId(waferId, self:GetNieRWaferBreakThroughById(waferId)) + waferLevel = waferLevel > limitLevel and limitLevel or waferLevel + else + waferLevel = 1 + end + return waferLevel +end + +function XNieRCharacter:GetNieRWaferBreakThroughById(id) + self:UpdateCharacterAbility() + return self.AbilityConfig.Wafers[id] or 0 +end + +function XNieRCharacter:GetAbilityList() + local configList = XNieRConfigs.GetAbilityGroupConfigByGroupId(self.Config.AbilityGroupId) + local abilityList = {} + local tmpAbility = {} + for _, cfg in pairs(configList) do + if cfg.Condition ~= 0 then + if cfg.SkillId ~= 0 then + tmpAbility = {} + tmpAbility.ConfigId = cfg.Id + tmpAbility.Type = XNieRConfigs.AbilityType.Skill + elseif cfg.FashionId ~= 0 then + tmpAbility = {} + tmpAbility.ConfigId = cfg.Id + tmpAbility.Type = XNieRConfigs.AbilityType.Fashion + elseif cfg.WeaponId ~= 0 then + tmpAbility = {} + tmpAbility.ConfigId = cfg.Id + tmpAbility.Type = XNieRConfigs.AbilityType.Weapon + elseif #(cfg.WaferId) == 4 then + tmpAbility = {} + tmpAbility.ConfigId = cfg.Id + tmpAbility.Type = XNieRConfigs.AbilityType.FourWafer + elseif #(cfg.WaferId) == 2 then + tmpAbility = {} + tmpAbility.ConfigId = cfg.Id + tmpAbility.Type = XNieRConfigs.AbilityType.TwoWafer + end + table.insert(abilityList, tmpAbility) + end + end + + table.sort(abilityList, function(a, b) + local aPriority, bPriority = XNieRConfigs.GetAbilityGroupConfigById(a.ConfigId).Priority or 0, XNieRConfigs.GetAbilityGroupConfigById(b.ConfigId).Priority or 0 + return aPriority < bPriority + end) + + return abilityList +end + +function XNieRCharacter:UpdateAttribs() + self:UpdateCharacterAbility() + + local robotId = self:GetNieRCharacterRobotId() + local robotCfg = XRobotManager.GetRobotTemplate(robotId) + local robotTemp = XRobotManager.GetRobotTemp(robotId) + + local equips = {} + if self.AbilityConfig.WeaponId and self.AbilityConfig.WeaponId ~= 0 then + local weapon = { + AwakeSlotList = {}, + TemplateId = self.AbilityConfig.WeaponId, + Level = self:GetNieRWeaponLevel(), + ResonanceInfo = {}, + Breakthrough = self:GetNieRWeaponBreakThrough() + } + table.insert(equips, weapon) + else + local weapon = { + AwakeSlotList = {}, + TemplateId = robotCfg.WeaponId, + Level = robotCfg.WeaponLevel, + ResonanceInfo = {}, + Breakthrough = robotCfg.WeaponBeakThrough + } + table.insert(equips, weapon) + end + if self.AbilityConfig.Wafers and next(self.AbilityConfig.Wafers) ~= nil then + for waferId, breakthrough in pairs(self.AbilityConfig.Wafers) do + local newAware = { + AwakeSlotList = {}, + TemplateId = waferId, + Level = self:GetNieRWaferLevel(waferId), + ResonanceInfo = {}, + Breakthrough = breakthrough + } + table.insert(equips, newAware) + end + else + for index, waferId in ipairs(robotCfg.WaferId) do + local newAware = { + AwakeSlotList = {}, + TemplateId = waferId, + Level = robotCfg.WaferLevel[index], + ResonanceInfo = {}, + Breakthrough = robotCfg.WaferBreakThrough[index] + } + table.insert(equips, newAware) + end + end + robotTemp:SetEquips(equips) + + self.Attribs = robotTemp:GetAtrributes() +end + +function XNieRCharacter:GetAttribs() + self:UpdateAttribs() + return self.Attribs +end + +function XNieRCharacter:UpdateAbility() + self:UpdateCharacterAbility() + local attribs = self:GetAttribs() + local attribAbility = XAttribManager.GetAttribAbility(attribs) + local skillData = XRobotManager.GetRobotSkillLevelDic(self:GetNieRCharacterRobotId()) + if next(self.AbilityConfig.SkillsData) ~= nil then + for skillId, skillLevel in pairs(self.AbilityConfig.SkillsData) do + skillData[skillId] = skillLevel + end + end + local skillAbility = XDataCenter.CharacterManager.GetSkillAbility(skillData) + self.AbilityNum = attribAbility + skillAbility +end + +function XNieRCharacter:GetAbilityNum() + self:UpdateAbility() + return self.AbilityNum +end + +function XNieRCharacter:GetTeachingStageIds() + return self.Config.TeachingStageIds +end + +function XNieRCharacter:GetRobotCharacterId() + return XRobotManager.GetCharacterId(self:GetNieRCharacterRobotId()) +end + +function XNieRCharacter:GetRobotCharacterCareerType() + local characterDetailCfg = XCharacterConfigs.GetCharDetailTemplate(self:GetRobotCharacterId()) + return characterDetailCfg.Career +end + +function XNieRCharacter:GetNieRCharacterUpLevelItemId() + return self.ClientConfig.UpLevelItem or 0 +end + +function XNieRCharacter:GetNieRCharacterIcon() + return self.ClientConfig.Icon +end + +function XNieRCharacter:GetNieRClientPos() + return self.ClientConfig.Pos +end + +function XNieRCharacter:GetNieRClientSkipId() + return self.ClientConfig.SkipId +end + +function XNieRCharacter:GetNieRCharName() + local characterId = self:GetRobotCharacterId() + local charConfig = XCharacterConfigs.GetCharacterTemplate(characterId) + local nameStr = charConfig.Name + -- if charConfig.TradeName ~= "" then + -- nameStr = nameStr .. "·" .. charConfig.TradeName + -- end + return nameStr +end + +return XNieRCharacter \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XNieR/XNieRRepeat.lua b/Resources/Scripts/XEntity/XNieR/XNieRRepeat.lua new file mode 100644 index 00000000..535e67fd --- /dev/null +++ b/Resources/Scripts/XEntity/XNieR/XNieRRepeat.lua @@ -0,0 +1,113 @@ +local XNieRRepeat = XClass(nil, "XNieRRepeat") + +function XNieRRepeat:Ctor(id, index) + self.Id = id + self.Index = index + self.RepeatCfg = XNieRConfigs.GetRepeatableStageConfigById(id) + self:InitInfo() +end + +function XNieRRepeat:InitInfo() + self.ExConditionDic = {} + self.ExConsumeDic = {} + for index, stageId in ipairs(self.RepeatCfg.ExStageIds) do + local tmpConsume = {} + tmpConsume.Id = self.RepeatCfg.ExConsumeIds[index] or 0 + tmpConsume.Count = self.RepeatCfg.ExConsumeCounts[index] or 0 + self.ExConsumeDic[stageId] = tmpConsume + self.ExConditionDic[stageId] = self.RepeatCfg.ExStageConditions[index] or 0 + end +end + +function XNieRRepeat:GetNieRExStageIds() + return self.RepeatCfg.ExStageIds +end + +function XNieRRepeat:GetNieRExStageConditions() + return self.RepeatCfg.ExStageConditions +end + +function XNieRRepeat:CheckNieRRepeatMainStageUnlock() + local condit, desc + if self.RepeatCfg.Condition == 0 then + condit, desc = true, "" + else + condit, desc = XConditionManager.CheckCondition(self.RepeatCfg.Condition) + end + if condit then + local stageInfo = XDataCenter.FubenManager.GetStageInfo(self.Id) + if not stageInfo.Unlock then + condit, desc = false, XDataCenter.FubenManager.GetFubenOpenTips(self.Id) + end + end + return condit, desc +end + +function XNieRRepeat:CheckNieRRepeatStageUnlock(stageId) + local condit, desc + if not self.ExConditionDic[stageId] or self.ExConditionDic[stageId] == 0 then + condit, desc = true, "" + else + condit, desc = XConditionManager.CheckCondition(self.ExConditionDic[stageId]) + end + if condit then + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + if not stageInfo.Unlock then + condit, desc = false, XDataCenter.FubenManager.GetFubenOpenTips(stageId) + end + end + return condit, desc +end + +function XNieRRepeat:CheckNieRRepeatStagePass(stageId) + return XDataCenter.FubenManager.CheckStageIsPass(stageId) +end + +function XNieRRepeat:GetNieRRepeatStar() + local starNum = 0 + for _, stageId in ipairs(self.RepeatCfg.ExStageIds) do + if XDataCenter.FubenManager.CheckStageIsPass(stageId) then + starNum = starNum + 1 + end + end + return starNum +end + +function XNieRRepeat:GetNieRRepeatStageId() + return self.Id +end + +function XNieRRepeat:GetNieRNorStarReward() + return self.RepeatCfg.NormalReward +end + +function XNieRRepeat:GetNieRExStarReward(starNum) + return self.RepeatCfg.StarRewards[starNum] or 0 +end + +function XNieRRepeat:GetNieRNormalReward() + return self.RepeatCfg.NormalReward +end + +function XNieRRepeat:GetExConsumIdAndCount(stageId) + local tmpConsume = self.ExConsumeDic[stageId] + return tmpConsume.Id, tmpConsume.Count +end + +function XNieRRepeat:GetNieRExStageCondit(stageId) + return self.ExConditionDic[stageId] +end + +function XNieRRepeat:GetNierRepeatStageConsumeCount() + return self.RepeatCfg.ConsumeCount +end + +function XNieRRepeat:GetNieRRepeatRobotIds() + return self.RepeatCfg.RobotIds +end + +function XNieRRepeat:GetNieRRepeatTaskSkipId() + return self.RepeatCfg.TaskSkipId +end + +return XNieRRepeat \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XNieR/XNierPOD.lua b/Resources/Scripts/XEntity/XNieR/XNierPOD.lua new file mode 100644 index 00000000..77a7e617 --- /dev/null +++ b/Resources/Scripts/XEntity/XNieR/XNierPOD.lua @@ -0,0 +1,183 @@ +local XNierPOD = XClass(nil, "XNierPOD") + +local Default = { + Id = 0, + Level = 0, + Exp = 0 +} + +function XNierPOD:Ctor(data) + self:UpdateNierPOD(data) +end + +function XNierPOD:UpdateNierPOD(data) + self.Id = data.SupportId + self.Level = data.Level + self.Exp = data.Exp + self.SelectSkillId = data.SelectSkillId + self.Config = XNieRConfigs.GetNieRSupportConfig(self.Id) + self.SkillLevelDic = {} + self.SkillInfoDic = {} + for _, skill in ipairs(data.Skills) do + self.SkillLevelDic[skill.SkillId] = skill.SkillLevel + end + + self:InitSkillId() +end + +function XNierPOD:InitSkillId() + self.SkillList = {} + for index, skillId in ipairs(self.Config.SkillIds) do + local tmpSkill = {} + tmpSkill.SkillId = skillId + tmpSkill.PassiveFlags = self.Config.SkillPassiveFlags[index] or 0 + tmpSkill.Condit = self.Config.SkillConditions[index] or 0 + table.insert(self.SkillList, tmpSkill) + self.SkillInfoDic[skillId] = tmpSkill + end +end + +function XNierPOD:GetNieRPODId() + return self.Id +end + +function XNierPOD:GetNieRPODLevel() + return self.Level +end + +function XNierPOD:GetNieRPODExp() + return self.Exp +end + +function XNierPOD:SetNieRPODSelectSkillId(skillId) + self.SelectSkillId = skillId +end + +function XNierPOD:GetNieRPODSelectSkillId() + return self.SelectSkillId +end + +function XNierPOD:GetFightSkillList() + local skillList = {} + for _, skillInfo in ipairs(self.SkillList) do + + if skillInfo.PassiveFlags == XNieRConfigs.NieRPodSkillType.ActiveSkill then + local tmpSkillInfo = {} + tmpSkillInfo.SkillId = skillInfo.SkillId + tmpSkillInfo.IsActive, tmpSkillInfo.Desc = self:CheckNieRPODSkillActive(skillInfo.SkillId) + table.insert(skillList, tmpSkillInfo) + end + end + table.sort(skillList, function(a, b) + if a.IsActive and not b.IsActive then + return true + elseif (a.IsActive and b.IsActive) or ( not a.IsActive and not b.IsActive ) then + return a.SkillId < b.SkillId + end + return false + end) + return skillList +end + +function XNierPOD:CheckNieRPODMaxLevel() + return self:GetNieRPODLevel() >= XNieRConfigs.GetNieRSupportMaxLevelById(self:GetNieRPODId()) +end + +function XNierPOD:GetNieRPODMaxExp() + return XNieRConfigs.GetNieRSupportLevelCfgBuyIdAndLevel(self:GetNieRPODId(), self:GetNieRPODLevel()).MaxExp +end + +function XNierPOD:GetNieRPODIcon() + return XNieRConfigs.GetNieRSupportLevelCfgBuyIdAndLevel(self:GetNieRPODId(), self:GetNieRPODLevel()).Icon +end + +function XNierPOD:GetNieRPODHeadIcon() + return XNieRConfigs.GetNieRSupportLevelCfgBuyIdAndLevel(self:GetNieRPODId(), self:GetNieRPODLevel()).HeadIcon +end + +function XNierPOD:GetNieRPODHeadBigIcon() + return XNieRConfigs.GetNieRSupportLevelCfgBuyIdAndLevel(self:GetNieRPODId(), self:GetNieRPODLevel()).HeadBigIcon +end + +function XNierPOD:GetNieRPODModel() + return XNieRConfigs.GetNieRSupportLevelCfgBuyIdAndLevel(self:GetNieRPODId(), self:GetNieRPODLevel()).Model +end + +function XNierPOD:GetNieRPODSkillList() + return self.SkillList +end + +function XNierPOD:GetNieRPODSkillLevelById(skillId) + return self.SkillLevelDic[skillId] or 1 +end + +function XNierPOD:AddNieRPODSkillLevelById(skillId) + if XNieRConfigs.GetNieRSupportMaxSkillLevelById(skillId) > self.SkillLevelDic[skillId] then + self.SkillLevelDic[skillId] = self.SkillLevelDic[skillId] + 1 + end +end + +function XNierPOD:GetNieRPODName() + return XNieRConfigs.GetNieRSupportClientConfig(self:GetNieRPODId()).Name +end + +function XNierPOD:GetNieRPODUpLevelItemId() + return XNieRConfigs.GetNieRSupportClientConfig(self:GetNieRPODId()).UpLevelItem +end + +function XNierPOD:CheckNieRPODSkillActive(skillId) + local info = self.SkillInfoDic[skillId] + local condit, desc = true, "" + if info.Condit and info.Condit ~= 0 then + condit, desc = XConditionManager.CheckCondition(info.Condit) + end + return condit, desc +end + +function XNierPOD:CheckNieRPODSkillActiveSkill(skillId) + local info = self.SkillInfoDic[skillId] + if info and info.PassiveFlags == XNieRConfigs.NieRPodSkillType.ActiveSkill then + return true + end + return false +end + +function XNierPOD:CheckNieRPODSkillUpLevel(skillId) + local info = XNieRConfigs.GetNieRSupportSkillLevelCfgBuyIdAndLevel(skillId, self:GetNieRPODSkillLevelById(skillId)) + local level = self:GetNieRPODSkillLevelById(skillId) + local maxLevel = XNieRConfigs.GetNieRSupportMaxSkillLevelById(skillId) + if level >= maxLevel then + return false, "" + end + local condit, desc = true, "" + if info.UpgradeCondition and info.UpgradeCondition ~= 0 then + condit, desc = XConditionManager.CheckCondition(info.UpgradeCondition) + end + return condit, desc +end + +function XNierPOD:GetNieRPODSkillUpLevelItem(skillId) + local info = XNieRConfigs.GetNieRSupportSkillLevelCfgBuyIdAndLevel(skillId, self:GetNieRPODSkillLevelById(skillId)) + return info.UpgradeConsumeId, info.UpgradeConsumeCount +end + +function XNierPOD:GetNieRPODSkillName(skillId) + local info = XNieRConfigs.GetNieRSupportSkillClientConfig(skillId, self:GetNieRPODSkillLevelById(skillId)) + return info.Name +end + +function XNierPOD:GetNieRPODSkillIcon(skillId) + local info = XNieRConfigs.GetNieRSupportSkillClientConfig(skillId, self:GetNieRPODSkillLevelById(skillId)) + return info.Icon +end + +function XNierPOD:GetNieRPODSkillDesc(skillId) + local info = XNieRConfigs.GetNieRSupportSkillClientConfig(skillId, self:GetNieRPODSkillLevelById(skillId)) + return info.Desc +end + +function XNierPOD:GetUpSkillLevelItem() + return XNieRConfigs.GetNieRSupportClientConfig(self:GetNieRPODId()).UpSkillLevelItem +end + +return XNierPOD \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XPartner/XPartner.lua b/Resources/Scripts/XEntity/XPartner/XPartner.lua new file mode 100644 index 00000000..b3223697 --- /dev/null +++ b/Resources/Scripts/XEntity/XPartner/XPartner.lua @@ -0,0 +1,732 @@ +local XPartnerMainSkillGroup = require("XEntity/XPartner/XPartnerMainSkillGroup") +local XPartnerPassiveSkillGroup = require("XEntity/XPartner/XPartnerPassiveSkillGroup") +local XPartnerBase = require("XEntity/XPartner/XPartnerBase") + +local XPartner = XClass(XPartnerBase, "XPartner") +local DefaultQuality = 1 +local DefaultBreakthrough = 0 +local MoneyIndex = 1 + +function XPartner:Ctor(id, templateId, isComplete, IsPreview) + self.Id = id--Id + self.TemplateId = templateId--伙伴Id + self.Name = ""--名字 + self.CharacterId = 0--被携带的角色 + self.Level = 1--等级 + self.Exp = 0--经验值 + self.BreakThrough = 0--突破次数 + self.Quality = self:GetInitQuality() + self.IsLock = false--是否上锁 + self.StarSchedule = 0--进化节点进度 + self.SkillList = {}--技能列表 + self.UnlockSkillGroup = {}--解锁技能组列表 + self.CreateTime = 0--创建时间 + +-------------------------------------------------------- + self.IsPreview = IsPreview--是否是预览模式 为true时主动技能会按照默认装备技能组来初始化可以不用设置SkillList和UnlockSkillGroup + self.Ability = nil + self.IsComplete = isComplete--是否完整(合成界面非完整) + self.ChipBaseCount = 0--当前持有碎片 + self.StackCount = 0--堆叠数 + self.BreakthroughLimit = XPartnerConfigs.GetPartnerBreakthroughLimit(self.TemplateId)--最大突破次数 + self.QualityLimit = XPartnerConfigs.GetQualityLimit(self.TemplateId)--最大品质 + self.MainSkillGroupEntityDic = {} + self.PassiveSkillGroupEntityDic = {} + self.UnlockSkillGroupDic = {} + self.StoryEntityDic = {} +------------------------------------------------- + -- 是否属于自身玩家的或非玩家的(好友) + -- 默认都是属于自己的,目前在好友展示详情创建的伙伴数据是不属于自己的 + self.IsBelongSelf = true + + self:InitChipBaseCount() + self:InitPartnerSkill() + self:CreateSkillEntityDic() + self:CreateStoryEntityDic() +end + +function XPartner:UpdateData(data) + if type(data) == "table" then + for key, value in pairs(data or {}) do + self[key] = value + end + else + local tmpData = XTool.CsObjectFields2LuaTable(data) + for key, value in pairs(tmpData or {}) do + self[key] = value + end + end + self:ResetAbility() + self:UpdateSkillEntity() +end + +function XPartner:InitPartnerSkill() + local mainSkillCount = self:GeMainSkillCount() +end + +function XPartner:InitChipBaseCount()--设置基础碎片 + if self.IsComplete then + self.ChipBaseCount = self:GetChipNeedCount() + end +end + +function XPartner:ResetAbility()--重置战力 + self.Ability = nil +end +-------------------------宠物功能属性-------------------------- +function XPartner:GetId() + return self.Id +end + +function XPartner:GetName() + if not self.IsBelongSelf then + return self:GetOriginalName() + end + if not self.Name or self.Name == "" then + return self:GetOriginalName() + end + return self.Name +end + +function XPartner:GetTemplateId() + return self.TemplateId +end + +function XPartner:GetCharacterId() + return self.CharacterId +end + +function XPartner:GetCreateTime() + return self.CreateTime +end + +function XPartner:GetQuality() + return self.Quality == 0 and self:GetInitQuality() or self.Quality +end + +function XPartner:GetQualityIcon() + return XCharacterConfigs.GetCharQualityIcon(self:GetQuality()) +end + +function XPartner:GetCharacterQualityIcon() + return XCharacterConfigs.GetCharacterQualityIcon(self:GetQuality()) +end + +function XPartner:GetQualityLimit() + return self.QualityLimit +end + +function XPartner:GetLevel() + return self.Level +end + +function XPartner:GetExp() + return self.Exp +end + +function XPartner:GetBreakthrough() + return self.BreakThrough +end + +function XPartner:GetBreakthroughIcon() + return XPartnerConfigs.GetPartnerBreakThroughIcon(self.BreakThrough) +end + +function XPartner:GetBreakthroughLimit() + return self.BreakthroughLimit +end + +function XPartner:GetIsLock() + return self.IsLock +end + +function XPartner:SetIsLock(isLock) --设置是否上锁 + self.IsLock = isLock +end + +function XPartner:GetStarSchedule() + return self.StarSchedule +end + +function XPartner:GetSkillList() + return self.SkillList +end + +function XPartner:GetStackCount() + return self:GetIsByOneself() and self.StackCount or 0 +end + +function XPartner:GetChipCurCount()--当前持有碎片数(基础+升阶进度) + return self.ChipBaseCount + self.StarSchedule +end + +function XPartner:GetIsCanCompose()--能够合成(必须要非完整) + return not self.IsComplete and self.ChipBaseCount >= self:GetChipNeedCount() +end + +function XPartner:GetIsCarry()--是否被装备 + return self.CharacterId > 0 +end + +function XPartner:GetIsByOneself() + local IsNotHasExp = self.Exp == 0 + local IsNotBreakthrough = self.BreakThrough == 0 + local IsNotLevel = self.Level == 1 + local IsNotEatPartner = self:GetStarSchedule() == 0 + local IsNotUpQuality = self.Quality == self:GetInitQuality() + local IsNotUpSkill = self:CheckIsNotUpSkill() + local IsNotChangeSkill = self:IsNotChangeSkill() + local IsNotLock = not self.IsLock + local IsNotUsed = not self:GetIsCarry() + local IsNotChangeName = self:GetName() == self:GetOriginalName() + + return IsNotHasExp and + IsNotBreakthrough and + IsNotLevel and + IsNotEatPartner and + IsNotUpQuality and + IsNotUpSkill and + IsNotChangeSkill and + IsNotLock and + IsNotUsed and + IsNotChangeName +end + +function XPartner:GetIsNotTraining() + local IsNotHasExp = self.Exp == 0 + local IsNotBreakthrough = self.BreakThrough == 0 + local IsNotLevel = self.Level == 1 + local IsNotEatPartner = self:GetStarSchedule() == 0 + local IsNotUpQuality = self.Quality == self:GetInitQuality() + local IsNotUpSkill = self:CheckIsNotUpSkill() + + + return IsNotHasExp and + IsNotBreakthrough and + IsNotLevel and + IsNotEatPartner and + IsNotUpQuality and + IsNotUpSkill +end + +function XPartner:GetIsMaxBreakthrough() + return self.BreakThrough >= self.BreakthroughLimit +end + +function XPartner:GetIsMaxQuality() + return self.Quality >= self.QualityLimit +end + +function XPartner:GetAttribs(level) + return XFightPartnerManager.GetPartnerAttribs(self, level) +end + +function XPartner:GetPartnerAttrMap(level) + local partnerAttrMap = XDataCenter.PartnerManager.ConstructPartnerAttrMap(self:GetAttribs(level), false, false) + return partnerAttrMap +end + +function XPartner:GetSkillAbility() + local skillAbility = 0 + for _, groupEntity in pairs(self.MainSkillGroupEntityDic or {}) do + if groupEntity:GetIsCarry() then + skillAbility = skillAbility + groupEntity:GetActiveSkillAbility() + end + end + + for _, groupEntity in pairs(self.PassiveSkillGroupEntityDic or {}) do + if groupEntity:GetIsCarry() then + skillAbility = skillAbility + groupEntity:GetActiveSkillAbility() + end + end + return skillAbility +end + +function XPartner:GetAbility() --获取宠物战力 + if not self.Ability then + local baseAbility = XAttribManager.GetPartnerAttribAbility(self:GetAttribs()) or 0 + local skillAbility = self:GetSkillAbility() + self.Ability = XMath.ToMinInt(baseAbility + skillAbility) + end + return self.Ability +end + +-----------------------------宠物品质-------------------------------- +function XPartner:GetQualityCfg(tagQuality)--无参代表当前品质 + return XPartnerConfigs.GePartnerQualityByIdAndNum(self.TemplateId, tagQuality or self.Quality) or {} +end + +function XPartner:GetQualitySkillColumnCount(tagQuality) + return self:GetQualityCfg(tagQuality).SkillColumnCount +end + +function XPartner:GetQualityEvolutionAttribId(tagQuality) + return self:GetQualityCfg(tagQuality).EvolutionAttrId +end + +function XPartner:GetQualityEvolutionCostItemId(tagQuality) + return self:GetQualityCfg(tagQuality).EvolutionCostItemId +end + +function XPartner:GetQualityEvolutionCostItemCount(tagQuality) + return self:GetQualityCfg(tagQuality).EvolutionCostItemCount +end + +function XPartner:GetQualityEvolutionCostItem(tagQuality) + local itemlist = {} + local itemIdlist = self:GetQualityEvolutionCostItemId(tagQuality) + local itemCountlist = self:GetQualityEvolutionCostItemCount(tagQuality) + for index,id in pairs(itemIdlist or {}) do + local tmpData = { + Id = id, + Count = itemCountlist[index] or 0, + } + itemlist[index] = tmpData + end + return itemlist +end + +function XPartner:GetQualityEvolutionMoney(tagQuality) + return self:GetQualityEvolutionCostItem(tagQuality)[MoneyIndex] +end + +function XPartner:GetQualityEvolutionItem(tagQuality) + local list = self:GetQualityEvolutionCostItem(tagQuality) + table.remove(list, MoneyIndex) + return list +end + +function XPartner:GetQualityStarCostChipCount(tagQuality) + return self:GetQualityCfg(tagQuality).StarCostChipCount +end + +function XPartner:GetQualityStarAttribId(tagQuality) + return self:GetQualityCfg(tagQuality).AttrId +end + +function XPartner:GetQualityStarAttribs(tagQuality) + local attribList = {} + local attribIdList = self:GetQualityStarAttribId(tagQuality) + for _,id in pairs(attribIdList or {}) do + table.insert(attribList, XAttribManager.GetBaseAttribs(id)) + end + return attribList +end + +function XPartner:GetCanActivateStarCount(tagQuality, chipCount)--已激活多少个星 + local starCostList = self:GetQualityStarCostChipCount(tagQuality) + local curStarCount = 0 + local curChipCount = chipCount or self.StarSchedule + for index,starCost in pairs(starCostList or {}) do + if curChipCount >= starCost and index > curStarCount then + curStarCount = index + end + end + return curStarCount +end + +function XPartner:GetMaxStarCount(tagQuality) + local starCostList = self:GetQualityStarCostChipCount(tagQuality) + return #starCostList +end + +function XPartner:GetCanUpQuality(tagQuality) + local curStarCount = self:GetCanActivateStarCount(tagQuality) + return curStarCount >= self:GetMaxStarCount() +end + +function XPartner:GetClipMaxCount(tagQuality) + local starCostList = self:GetQualityStarCostChipCount(tagQuality) + return starCostList[#starCostList] +end +-----------------------------宠物突破------------------------------------ +function XPartner:GetBreakthroughCfg(tagBreakthrough)--无参代表当前突破层数 + return XPartnerConfigs.GetPartnerBreakthroughByIdAndNum(self.TemplateId, tagBreakthrough or self.BreakThrough) or {} +end + +function XPartner:GetBreakthroughLevelLimit(tagBreakthrough) + return self:GetBreakthroughCfg(tagBreakthrough).LevelLimit +end + +function XPartner:GetBreakthroughAttribId(tagBreakthrough) + return self:GetBreakthroughCfg(tagBreakthrough).AttribId +end + +function XPartner:GetBreakthroughAttribPromotedId(tagBreakthrough) + return self:GetBreakthroughCfg(tagBreakthrough).AttribPromotedId +end + +function XPartner:GetBreakthroughLevelUpTemplateId(tagBreakthrough) + return self:GetBreakthroughCfg(tagBreakthrough).LevelUpTemplateId +end + +function XPartner:GetBreakthroughCostItemId(tagBreakthrough) + return self:GetBreakthroughCfg(tagBreakthrough).CostItemId +end + +function XPartner:GetBreakthroughCostItemCount(tagBreakthrough) + return self:GetBreakthroughCfg(tagBreakthrough).CostItemCount +end + +function XPartner:GetBreakthroughCostItem(tagBreakthrough) + local itemlist = {} + local itemIdlist = self:GetBreakthroughCostItemId(tagBreakthrough) + local itemCountlist = self:GetBreakthroughCostItemCount(tagBreakthrough) + for index,id in pairs(itemIdlist or {}) do + local tmpData = { + Id = id, + Count = itemCountlist[index] or 0, + } + itemlist[index] = tmpData + end + return itemlist +end + +function XPartner:GetBreakthroughMoney(tagBreakthrough) + return self:GetBreakthroughCostItem(tagBreakthrough)[MoneyIndex] +end + +function XPartner:GetBreakthroughItem(tagBreakthrough) + local list = self:GetBreakthroughCostItem(tagBreakthrough) + table.remove(list, MoneyIndex) + return list +end + +function XPartner:GetIsLevelMax(tagBreakthrough) + return self.Level >= self:GetBreakthroughLevelLimit(tagBreakthrough) +end + +function XPartner:GetBreakthroughPromotedAttrMap(preBreakthrough) + local attribPromotedId = self:GetBreakthroughAttribPromotedId(preBreakthrough) + local map = XAttribManager.GetPromotedAttribs(attribPromotedId) + return XDataCenter.PartnerManager.ConstructPartnerAttrMap(map, false, true) +end +-------------------------宠物等级------------------------------------ + +function XPartner:GetLevelUpCfg(tagBreakthrough, level) + local levelUpTemplateId = self:GetBreakthroughLevelUpTemplateId(tagBreakthrough) + return XPartnerConfigs.GetPartnerLevelUpTemplateByIdAndLevel(levelUpTemplateId, level or self.Level) or {} +end + +function XPartner:GetLevelUpInfoExp(tagBreakthrough, level) + return self:GetLevelUpCfg(tagBreakthrough, level).Exp +end + +function XPartner:GetLevelUpInfoAllExp(tagBreakthrough, level) + return self:GetLevelUpCfg(tagBreakthrough, level).AllExp +end + +function XPartner:GetPartnerLevelTotalNeedExp(targetLevel) + local totalExp = 0 + for level = self.Level, targetLevel - 1 do + totalExp = totalExp + self:GetLevelUpInfoExp(nil, level) + end + totalExp = totalExp - self:GetExp() + return totalExp +end + +-------------------------宠物技能------------------------------------ +function XPartner:CreateSkillEntityDic() + self.MainSkillGroupEntityDic = {} + self.PassiveSkillGroupEntityDic = {} + + for _,mainSkillGrpupId in pairs(self:GetMainSkillGroupIdList() or {}) do + local IsDefaultSkillGroup = mainSkillGrpupId == self:GetDefaultSkillGroupId() + self.MainSkillGroupEntityDic[mainSkillGrpupId] = XPartnerMainSkillGroup.New(mainSkillGrpupId, IsDefaultSkillGroup, self.IsPreview) + end + for _,passiveSkillGrpupId in pairs(self:GetPassiveSkillGroupIdList() or {}) do + self.PassiveSkillGroupEntityDic[passiveSkillGrpupId] = XPartnerPassiveSkillGroup.New(passiveSkillGrpupId) + end +end + +function XPartner:UpdateSkillEntity() + self.UnlockSkillGroupDic = {} + for _,skillId in pairs(self.UnlockSkillGroup or {}) do + self.UnlockSkillGroupDic[skillId] = true + end + -------------------------更新当前技能数据----------------------------- + local carringMainSkillLevel = 1 --暂时只有一个主技能组 + for _,skilldata in pairs(self.SkillList or {}) do + local tmpData = {} + tmpData.Level = skilldata.Level + tmpData.IsCarry = skilldata.IsWear + tmpData.ActiveSkillId = skilldata.Id + + if skilldata.Type == XPartnerConfigs.SkillType.MainSkill then + local groupId = XPartnerConfigs.GetMainSkillGroupById(skilldata.Id) + self.MainSkillGroupEntityDic[groupId]:UpdateData(tmpData) + carringMainSkillLevel = tmpData.Level----暂时只有一个主技能组 + elseif skilldata.Type == XPartnerConfigs.SkillType.PassiveSkill then + local groupId = XPartnerConfigs.GetPassiveSkillGroupById(skilldata.Id) + self.PassiveSkillGroupEntityDic[groupId]:UpdateData(tmpData) + end + end + --------------------------------------------------------------------- + -------------------------更新未装备主技能数据-------------------------- + for _,skillGroup in pairs(self.MainSkillGroupEntityDic or {}) do + if not skillGroup:GetIsCarry() then + local tmpData = {} + tmpData.Level = carringMainSkillLevel + tmpData.IsCarry = false + if self:GetIsCarry() then + local charId = self:GetCharacterId() + local charElement = XCharacterConfigs.GetCharacterElement(charId) + local skillId = skillGroup:GetSkillIdByElement(charElement) + tmpData.ActiveSkillId = skillId + else + skillGroup:SetDefaultActiveSkillId() + end + skillGroup:UpdateData(tmpData) + end + end + --------------------------------------------------------------------- + -------------------------更新主技能解锁数据---------------------------- + for groupId,IsOpen in pairs(self.UnlockSkillGroupDic or {}) do + local mainSkilldata = self.MainSkillGroupEntityDic[groupId] + local passiveSkilldata = self.PassiveSkillGroupEntityDic[groupId] + + if mainSkilldata then + mainSkilldata:UpdateData({IsLock = not IsOpen}) + end + end +end + +function XPartner:GetMainSkillGroupEntityDic() + return self.MainSkillGroupEntityDic +end + +function XPartner:GetPassiveSkillGroupEntityDic() + return self.PassiveSkillGroupEntityDic +end + +function XPartner:GetMainSkillGroupList() + local list = {} + for _,entity in pairs(self.MainSkillGroupEntityDic or {}) do + table.insert(list, entity) + end + XPartnerSort.SkillSort(list) + return list +end + +function XPartner:GetPassiveSkillGroupList() + local list = {} + for _,entity in pairs(self.PassiveSkillGroupEntityDic or {}) do + table.insert(list, entity) + end + XPartnerSort.SkillSort(list) + return list +end + +function XPartner:GetCarryMainSkillGroupList() + local list = {} + for _,entity in pairs(self.MainSkillGroupEntityDic or {}) do + if entity:GetIsCarry() then + table.insert(list, entity) + end + end + XPartnerSort.SkillSort(list) + return list +end + +function XPartner:GetCarryPassiveSkillGroupList() + local list = {} + for _,entity in pairs(self.PassiveSkillGroupEntityDic or {}) do + if entity:GetIsCarry() then + table.insert(list, entity) + end + end + XPartnerSort.SkillSort(list) + return list +end + +function XPartner:GetSkillById(skillId) + for _,entity in pairs(self.MainSkillGroupEntityDic or {}) do + if entity:GetActiveSkillId() == skillId then + return entity + end + end + for _,entity in pairs(self.PassiveSkillGroupEntityDic or {}) do + if entity:GetActiveSkillId() == skillId then + return entity + end + end + return +end + +function XPartner:CheckIsNotUpSkill() + for _,entity in pairs(self.MainSkillGroupEntityDic or {}) do + if entity:GetLevel() > 1 then + return false + end + end + for _,entity in pairs(self.PassiveSkillGroupEntityDic or {}) do + if entity:GetLevel() > 1 then + return false + end + end + return true +end + +function XPartner:IsNotChangeSkill() + return self:IsNotChangeMainSkill() and self:IsNotChangePassiveSkill() +end + +function XPartner:IsNotChangeMainSkill() + for _,entity in pairs(self.MainSkillGroupEntityDic or {}) do + if entity:GetIsCarry() and entity:GetId() ~= self:GetDefaultSkillGroupId() then + return false + end + end + return true +end + +function XPartner:IsNotChangePassiveSkill() + for _,entity in pairs(self.PassiveSkillGroupEntityDic or {}) do + if entity:GetIsCarry() then + return false + end + end + return true +end + +function XPartner:GetSkillCfg() + return XPartnerConfigs.GetPartnerSkillById(self.TemplateId) +end + +function XPartner:GetSkillUpgradeCostItemId() + return self:GetSkillCfg().UpgradeCostItemId +end + +function XPartner:GetSkillUpgradeCostItemCount() + return self:GetSkillCfg().UpgradeCostItemCount +end + +function XPartner:GetSkillUpgradeCostItem() + local itemlist = {} + local itemIdlist = self:GetSkillUpgradeCostItemId() + local itemCountlist = self:GetSkillUpgradeCostItemCount() + for index,id in pairs(itemIdlist or {}) do + local tmpData = { + Id = id, + Count = itemCountlist[index] or 0, + } + itemlist[index] = tmpData + end + return itemlist +end + +function XPartner:GetSkillUpgradeMoney() + return self:GetSkillUpgradeCostItem()[MoneyIndex] +end + +function XPartner:GetSkillUpgradeItem() + local list = self:GetSkillUpgradeCostItem() + table.remove(list, MoneyIndex) + return list +end + +function XPartner:GetDefaultSkillGroupId() + return self:GetSkillCfg().DefaultMainSkillGroupId +end + +function XPartner:GetMainSkillGroupIdList() + return self:GetSkillCfg().MainSkillGroupId +end + +function XPartner:GetPassiveSkillGroupIdList() + return self:GetSkillCfg().PassiveSkillGroupId +end + +function XPartner:GetTotalSkillLevel()--总当前技能等级 + local level = 0 + for _,entity in pairs(self.MainSkillGroupEntityDic or {}) do + if entity:GetIsCarry() then + level = level + entity:GetLevel()--总技能共享等级,只需要取其中一个的等级即可 + break + end + end + for _,entity in pairs(self.PassiveSkillGroupEntityDic or {}) do + level = level + entity:GetLevel() + end + + return level +end + +function XPartner:GetTotalSkillLevelLimit()--总技能等级 + local levelLimit = 0 + for _,entity in pairs(self.MainSkillGroupEntityDic or {}) do + if entity:GetIsCarry() then + levelLimit = levelLimit + entity:GetLevelLimit()--总技能共享等级,只需要取其中一个的等级即可 + break + end + end + for _,entity in pairs(self.PassiveSkillGroupEntityDic or {}) do + levelLimit = levelLimit + entity:GetLevelLimit() + end + + return levelLimit +end + +function XPartner:GetMiniSkillLevelLimit()--最小技能等级 + local levelLimit = 0 + for _,entity in pairs(self.MainSkillGroupEntityDic or {}) do + if entity:GetIsCarry() then + levelLimit = levelLimit + 1 + break + end + end + for _,entity in pairs(self.PassiveSkillGroupEntityDic or {}) do + levelLimit = levelLimit + 1 + end + + return levelLimit +end + +function XPartner:GetIsTotalSkillLevelMax()--总技能等级已满 + return self:GetTotalSkillLevel() >= self:GetTotalSkillLevelLimit() +end + +function XPartner:GetSkillLevelGap()--总技能等级与满技能等级的差值 + return self:GetTotalSkillLevelLimit() - self:GetTotalSkillLevel() +end +-------------------------------------宠物故事--------------------------------- + +function XPartner:CreateStoryEntityDic() + self.StoryEntityDic = {} + local storyEntityList = XDataCenter.ArchiveManager.GetArchivePartnerSetting(self.TemplateId,XArchiveConfigs.PartnerSettingType.Story) + for _,Entity in pairs(storyEntityList or {}) do + self.StoryEntityDic[Entity:GetId()] = Entity + end +end + +function XPartner:UpdateStoryEntity(unLockStoryList) + for _,id in pairs(unLockStoryList or {}) do + if self.StoryEntityDic[id] then + self.StoryEntityDic[id]:UpdateData({IsLock = false}) + end + end +end + +-------------------------------物品跳转---------------------------------- +function XPartner:GetItemSkipCfg() + return XPartnerConfigs.GetPartnerItemSkipById(self.TemplateId) +end + +function XPartner:GetLevelUpSkipIdList() + return self:GetItemSkipCfg().LevelUpSkipIdParams or {} +end + +function XPartner:GetClipSkipIdList() + return self:GetItemSkipCfg().ClipSkipIdParams or {} +end + +function XPartner:GetStageSkipId() + return self:GetItemSkipCfg().StageSkipIdParam +end + +-------------------------------宠物来源---------------------------------- +function XPartner:SetIsBelongSelf(value) + self.IsBelongSelf = value +end + +return XPartner \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XPartner/XPartnerBase.lua b/Resources/Scripts/XEntity/XPartner/XPartnerBase.lua new file mode 100644 index 00000000..a42bc61a --- /dev/null +++ b/Resources/Scripts/XEntity/XPartner/XPartnerBase.lua @@ -0,0 +1,163 @@ +local XPartnerBase = XClass(nil, "XPartnerBase") + +function XPartnerBase:Ctor(templateId) + self.TemplateId = templateId + self.StoryEntityDic = {} + self.StorySettingDic = {} +end + +----------------------------宠物基础属性-------------------------------- +function XPartnerBase:GetPartnerCfg() + return XPartnerConfigs.GetPartnerTemplateById(self.TemplateId) +end + +function XPartnerBase:GetOriginalName() + return self:GetPartnerCfg().Name +end + +function XPartnerBase:GetDesc() + return self:GetPartnerCfg().Desc +end + +function XPartnerBase:GetRecommendElement() + return self:GetPartnerCfg().RecommendElement +end + +function XPartnerBase:GetIcon() + return self:GetPartnerCfg().Icon +end + +function XPartnerBase:GetPriority() + return self:GetPartnerCfg().Priority +end + +function XPartnerBase:GetInitQuality() + return self:GetPartnerCfg().InitQuality +end + +function XPartnerBase:GetCarryCharacterType() + return self:GetPartnerCfg().CarryCharacterType +end + +function XPartnerBase:GetChipItemId() + return self:GetPartnerCfg().ChipItemId +end + +function XPartnerBase:GetChipNeedCount() + return self:GetPartnerCfg().ChipNeedCount +end + +function XPartnerBase:GetDefaultLock() + return self:GetPartnerCfg().DefaultLock +end + +function XPartnerBase:GeMainSkillCount() + return self:GetPartnerCfg().MainSkillCount +end + +function XPartnerBase:GetPassiveSkillCount() + return self:GetPartnerCfg().PassiveSkillCount +end + +function XPartnerBase:GetDecomposeItemId() + return self:GetPartnerCfg().DecomposeItemId +end + +function XPartnerBase:GetDecomposeItemCount() + return self:GetPartnerCfg().DecomposeItemCount +end + +function XPartnerBase:GetDecomposeBackItem() + local itemlist = {} + local itemIdlist = self:GetDecomposeItemId() + local itemCountlist = self:GetDecomposeItemCount() + for index,id in pairs(itemIdlist or {}) do + local tmpData = { + Id = id, + Count = itemCountlist[index] or 0, + } + itemlist[index] = tmpData + end + return itemlist +end + +----------------------------------宠物模型------------------------------- +function XPartnerBase:GetModelCfg() + return XPartnerConfigs.GetPartnerModelById(self.TemplateId) +end + +function XPartnerBase:GetStandbyModel() + return self:GetModelCfg().StandbyModel +end + +function XPartnerBase:GetCombatModel() + return self:GetModelCfg().CombatModel +end + +function XPartnerBase:GetSToCAnime()--待机转战斗动画 + return self:GetModelCfg().SToCAnime +end + +function XPartnerBase:GetStandbyBornAnime()--出生动画 + return self:GetModelCfg().StandbyBornAnime +end + +function XPartnerBase:GetCToSAnime()--动画转待机动画 + return self:GetModelCfg().CToSAnime +end + +function XPartnerBase:GetCombatBornAnime()--出生动画 + return self:GetModelCfg().CombatBornAnime +end + +function XPartnerBase:GetSToCVoice()--待机转战斗音效 + return self:GetModelCfg().SToCVoice +end + +function XPartnerBase:GetCToSVoice()--动画转待机音效 + return self:GetModelCfg().CToSVoice +end + +function XPartnerBase:GetSToCEffect()--待机转战斗特效 + return self:GetModelCfg().SToCEffect +end + +function XPartnerBase:GetStandbyBornEffect()--待机出生特效 + return self:GetModelCfg().StandbyBornEffect +end + +function XPartnerBase:GetCToSEffect()--战斗转待机特效 + return self:GetModelCfg().CToSEffect +end + +function XPartnerBase:GetCombatBornEffect()--战斗出生特效 + return self:GetModelCfg().CombatBornEffect +end + +-------------------------------------宠物故事--------------------------------- + +function XPartnerBase:GetStoryEntityDic() + return self.StoryEntityDic +end + +function XPartnerBase:GetStorySettingDic() + return self.StorySettingDic +end + +function XPartnerBase:GetStoryEntityList() + local list = {} + for _,entity in pairs(self.StoryEntityDic or {}) do + table.insert(list, entity) + end + return XArchiveConfigs.SortByOrder(list) +end + +function XPartnerBase:GetSettingEntityList() + local list = {} + for _,entity in pairs(self.StorySettingDic or {}) do + table.insert(list, entity) + end + return XArchiveConfigs.SortByOrder(list) +end + +return XPartnerBase \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XPartner/XPartnerMainSkillGroup.lua b/Resources/Scripts/XEntity/XPartner/XPartnerMainSkillGroup.lua new file mode 100644 index 00000000..d31545d9 --- /dev/null +++ b/Resources/Scripts/XEntity/XPartner/XPartnerMainSkillGroup.lua @@ -0,0 +1,119 @@ +local XPartnerSkillGroupBase = require("XEntity/XPartner/XPartnerSkillGroupBase") +local XPartnerMainSkillGroup = XClass(XPartnerSkillGroupBase, "XPartnerMainSkillGroup") +local DefaultIndex = 1 + +function XPartnerMainSkillGroup:Ctor(id, IsDefaultSkillGroup, IsPreview) + self.Id = id + self.Level = 1 + + if IsPreview then + self.IsCarry = IsDefaultSkillGroup + self.IsLock = not IsDefaultSkillGroup + else + self.IsCarry = false + self.IsLock = true + end + + self:SetDefaultActiveSkillId() + self.LevelLimit = XPartnerConfigs.GetPartnerSkillLevelLimit(self.ActiveSkillId) +end + +function XPartnerMainSkillGroup:UpdateData(data) + for key, value in pairs(data) do + self[key] = value + end +end + +function XPartnerMainSkillGroup:GetSkillType() + return XPartnerConfigs.SkillType.MainSkill +end + +function XPartnerMainSkillGroup:SetDefaultActiveSkillId() + self.ActiveSkillId = self:GetSkillIdList()[DefaultIndex] +end + +function XPartnerMainSkillGroup:GetCfg() + return XPartnerConfigs.GetPartnerMainSkillGroupById(self.Id) +end + +function XPartnerMainSkillGroup:GetConditionId() + return self:GetCfg().ConditionId +end + +function XPartnerMainSkillGroup:GetSkillIdList() + return self:GetCfg().SkillId +end + +function XPartnerMainSkillGroup:GetElementList() + return self:GetCfg().Element +end + +-- return : XPartnerMainSkillGroup list +function XPartnerMainSkillGroup:GetSelfElementSkillS() + local result = {} + for _, element in ipairs(self:GetElementList()) do + local skill = XPartnerMainSkillGroup.New(self:GetId()) + local initData = { + Level = self:GetLevel(), + IsLock = self:GetIsLock(), + ActiveSkillId = self:GetSkillIdByElement(element), + Type = XPartnerConfigs.SkillType.MainSkill, + } + skill:UpdateData(initData) + table.insert(result, skill) + end + return result +end + +function XPartnerMainSkillGroup:GetConditionDesc() + local desc = "" + if self:GetConditionId() ~= 0 then + desc = XConditionManager.GetConditionDescById(self:GetConditionId()) + end + return desc +end + +function XPartnerMainSkillGroup:GetActiveElement() + return self:GetElementBySkillId(self.ActiveSkillId) +end + +function XPartnerMainSkillGroup:GetSkillIdByElement(activeElement) + for index,element in pairs(self:GetElementList() or {}) do + if element == activeElement then + if self:GetSkillIdList()[index] then + return self:GetSkillIdList()[index] + else + XLog.Error("elementSkill is not exist by element :" .. activeElement) + return self:GetSkillIdList()[DefaultIndex] + end + end + end + XLog.Error("element is not exist by element :" .. activeElement) + return self:GetSkillIdList()[DefaultIndex] +end + +function XPartnerMainSkillGroup:GetSkillIdByElementIndex(index) + return self:GetSkillIdList()[index] or self:GetSkillIdList()[DefaultIndex] +end + +function XPartnerMainSkillGroup:GetElementBySkillId(skillId) + for index,element in pairs(self:GetElementList() or {}) do + if self:GetSkillIdList()[index] == skillId then + return element + end + end + XLog.Error("element is Null or skillId is not exist") + return XPartnerConfigs.SkillElement.Physics +end + +function XPartnerMainSkillGroup:GetElementIndexBySkillId(skillId) + for index,_ in pairs(self:GetElementList() or {}) do + if self:GetSkillIdList()[index] == skillId then + return index + end + end + XLog.Error("element is Null or skillId is not exist") + return DefaultIndex +end + +return XPartnerMainSkillGroup \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XPartner/XPartnerPassiveSkillGroup.lua b/Resources/Scripts/XEntity/XPartner/XPartnerPassiveSkillGroup.lua new file mode 100644 index 00000000..f9351aca --- /dev/null +++ b/Resources/Scripts/XEntity/XPartner/XPartnerPassiveSkillGroup.lua @@ -0,0 +1,36 @@ +local XPartnerSkillGroupBase = require("XEntity/XPartner/XPartnerSkillGroupBase") +local XPartnerPassiveGroupSkill = XClass(XPartnerSkillGroupBase, "XPartnerPassiveGroupSkill") +local DefaultIndex = 1 + +function XPartnerPassiveGroupSkill:Ctor(id) + self.Id = id + self.Level = 1 + self.IsCarry = false + self.IsLock = false--被动技能暂时不会上锁 + self:SetDefaultActiveSkillId() + self.LevelLimit = XPartnerConfigs.GetPartnerSkillLevelLimit(self.ActiveSkillId) +end + +function XPartnerPassiveGroupSkill:UpdateData(data) + for key, value in pairs(data) do + self[key] = value + end +end + +function XPartnerPassiveGroupSkill:GetSkillType() + return XPartnerConfigs.SkillType.PassiveSkill +end + +function XPartnerPassiveGroupSkill:SetDefaultActiveSkillId() + self.ActiveSkillId = self:GetSkillIdList()[DefaultIndex] +end + +function XPartnerPassiveGroupSkill:GetCfg() + return XPartnerConfigs.GetPartnerPassiveSkillGroupById(self.Id) +end + +function XPartnerPassiveGroupSkill:GetSkillIdList() + return self:GetCfg().SkillId +end + +return XPartnerPassiveGroupSkill \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XPartner/XPartnerSkillGroupBase.lua b/Resources/Scripts/XEntity/XPartner/XPartnerSkillGroupBase.lua new file mode 100644 index 00000000..5b1fb247 --- /dev/null +++ b/Resources/Scripts/XEntity/XPartner/XPartnerSkillGroupBase.lua @@ -0,0 +1,69 @@ +local XPartnerSkillGroupBase = XClass(nil, "XPartnerSkillGroupBase") + +function XPartnerSkillGroupBase:GetId() + return self.Id +end + +function XPartnerSkillGroupBase:GetLevel() + return self.Level +end + +function XPartnerSkillGroupBase:GetLevelStr() + return self.Level < self.LevelLimit and self.Level or "MAX" +end + +function XPartnerSkillGroupBase:GetActiveSkillId() + return self.ActiveSkillId +end + +function XPartnerSkillGroupBase:GetLevelLimit() + return self.LevelLimit +end + +function XPartnerSkillGroupBase:GetIsLock() + return self.IsLock +end + +function XPartnerSkillGroupBase:GetIsCarry() + return self.IsCarry +end + +--------------------------------------------SkillInfo--------------------------------------------------- +function XPartnerSkillGroupBase:GetSkillInfoCfgByLevel(skillId, level) + return XPartnerConfigs.GetPartnerSkillInfoByIdAndLevel(skillId or self.ActiveSkillId, level or self.Level) or {} +end + +function XPartnerSkillGroupBase:GetSkillName(skillId, level) + return self:GetSkillInfoCfgByLevel(skillId, level).Name +end + +function XPartnerSkillGroupBase:GetSkillIcon(skillId, level) + return self:GetSkillInfoCfgByLevel(skillId, level).Icon +end + +function XPartnerSkillGroupBase:GetSkillDesc(skillId, level) + return self:GetSkillInfoCfgByLevel(skillId, level).Desc +end + +------------------------------------------SkillEffect----------------------------------------------------- +function XPartnerSkillGroupBase:GetActiveSkillEffectCfgByLevel(level) + return XPartnerConfigs.GetPartnerSkillEffectByIdAndLevel(self.ActiveSkillId, level or self.Level) or {} +end + +function XPartnerSkillGroupBase:GetActiveSkillAbility(level) + return self:GetActiveSkillEffectCfgByLevel(level).Ability +end + +function XPartnerSkillGroupBase:GetActiveSkillBornMagic(level) + return self:GetActiveSkillEffectCfgByLevel(level).BornMagic +end + +function XPartnerSkillGroupBase:GetActiveSkillSubSkillId(level) + return self:GetActiveSkillEffectCfgByLevel(level).SubSkillId +end + +function XPartnerSkillGroupBase:GetActiveSkillSubMagicId(level) + return self:GetActiveSkillEffectCfgByLevel(level).SubMagicId +end + +return XPartnerSkillGroupBase \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XPartner/XPartnerStory.lua b/Resources/Scripts/XEntity/XPartner/XPartnerStory.lua new file mode 100644 index 00000000..39130ea4 --- /dev/null +++ b/Resources/Scripts/XEntity/XPartner/XPartnerStory.lua @@ -0,0 +1,47 @@ +local XPartnerStory = XClass(nil, "XPartnerStory") + +function XPartnerStory:Ctor(id, condition) + self.Id = id + self.IsLock = true + self.Condition = condition +end + +function XPartnerStory:UpdateData(data) + for key, value in pairs(data or {}) do + self[key] = value + end +end + +function XPartnerStory:GetId() + return self.Id +end + +function XPartnerStory:GetIsLock() + return self.IsLock +end + +function XPartnerStory:GetCondition() + return self.Condition +end + +function XPartnerStory:GetConditionDesc() + local desc = "" + if self.Condition ~= 0 then + desc = XConditionManager.GetConditionDescById(self.Condition) + end + return desc +end + +function XPartnerStory:GetCfg() + +end + +function XPartnerStory:GetTitle() + return self:GetCfg().Title +end + +function XPartnerStory:GetDesc() + return self:GetCfg().Desc +end + +return XPartnerStory \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XPassport/XPassportBaseInfo.lua b/Resources/Scripts/XEntity/XPassport/XPassportBaseInfo.lua new file mode 100644 index 00000000..4f7afcfd --- /dev/null +++ b/Resources/Scripts/XEntity/XPassport/XPassportBaseInfo.lua @@ -0,0 +1,32 @@ +local type = type + +--通行证基础信息 +local XPassportBaseInfo = XClass(nil, "XPassportBaseInfo") + +local Default = { + _Level = 0, --等级 +} + +function XPassportBaseInfo:Ctor() + for key, value in pairs(Default) do + if type(value) == "table" then + self[key] = {} + else + self[key] = value + end + end +end + +function XPassportBaseInfo:UpdateData(level) + self._Level = level +end + +function XPassportBaseInfo:SetToLevel(toLevel) + self._Level = toLevel +end + +function XPassportBaseInfo:GetLevel() + return self._Level +end + +return XPassportBaseInfo \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XPassport/XPassportInfo.lua b/Resources/Scripts/XEntity/XPassport/XPassportInfo.lua new file mode 100644 index 00000000..364c4980 --- /dev/null +++ b/Resources/Scripts/XEntity/XPassport/XPassportInfo.lua @@ -0,0 +1,42 @@ +local type = type + +--玩家通行证信息 +local XPassportInfo = XClass(nil, "XPassportInfo") + +local Default = { + _Id = 1, --通行证Id + _GotRewardDic = {}, --奖励领取记录 +} + +function XPassportInfo:Ctor() + for key, value in pairs(Default) do + if type(value) == "table" then + self[key] = {} + else + self[key] = value + end + end +end + +function XPassportInfo:UpdateData(data) + if XTool.IsTableEmpty(data) then return end + self._Id = data.Id + + for _, passportRewardId in ipairs(data.GotRewardList) do + self:SetReceiveReward(passportRewardId) + end +end + +function XPassportInfo:GetId() + return self._Id +end + +function XPassportInfo:SetReceiveReward(passportRewardId) + self._GotRewardDic[passportRewardId] = true +end + +function XPassportInfo:IsReceiveReward(passportRewardId) + return self._GotRewardDic[passportRewardId] +end + +return XPassportInfo \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XPayAgent/XPayAgent.lua b/Resources/Scripts/XEntity/XPayAgent/XPayAgent.lua new file mode 100644 index 00000000..0735c159 --- /dev/null +++ b/Resources/Scripts/XEntity/XPayAgent/XPayAgent.lua @@ -0,0 +1,138 @@ +XPayAgent = XClass(nil, "XPayAgent") + +local Json = require("XCommon/Json") +local table = table +local tableInsert = table.insert +local tableRemove = table.remove + +local pairs = pairs + +local TipsQueue = {} + +local OnSaveOrders = function(playerId, orders) + local orderStr = Json.encode(orders) + CS.UnityEngine.PlayerPrefs.SetString(XPrefs.PayOrder .. playerId, orderStr) + CS.UnityEngine.PlayerPrefs.Save() +end + +local OnLoadOrders = function(playerId) + local orderStr = CS.UnityEngine.PlayerPrefs.GetString(XPrefs.PayOrder .. playerId) + if orderStr and #orderStr > 0 then + local orders = Json.decode(orderStr) + + return orders + end + + return {} +end + +function XPayAgent:Ctor(playerId) + self.PlayerId = playerId + self.IsPaying = false + self.OrderDict = OnLoadOrders(playerId) + + CsXGameEventManager.Instance:RegisterEvent(XEventId.EVENT_FIGHT_EXIT, function() + self:TipsPaySuccess() + end) +end + +-- override this +function XPayAgent:Pay() + --XUiManager.TipText("PaySuccess", XUiManager.UiTipType.Success) +end + +function XPayAgent:AddOrder(order) + local orderId = order.OrderId + if not orderId or #orderId <= 0 then + XLog.Error("XPayAgent.AddOrder error: order CpOrderId is nil") + return + end + + if not order.PlayerId or order.PlayerId ~= self.PlayerId then + XLog.Error("XPayAgent.AddOrder error: order PlayerId is error, Order PlayerId is " .. order.PlayerId .. ", PlayerId is " .. self.PlayerId) + return + end + + if self.OrderDict[orderId] then + XLog.Error("XPayAgent.AddOrder error: order is exsit, CpOrderId is " .. orderId) + return + end + + self.OrderDict[orderId] = order + OnSaveOrders(self.PlayerId, self.OrderDict) +end + +function XPayAgent:RemoveOrder(orderId) + if not self.OrderDict[orderId] then + return + end + + self.OrderDict[orderId] = nil + OnSaveOrders(self.PlayerId, self.OrderDict) +end + +-- function XPayAgent:UpdateOrderCheckTimes() +-- local list = {} +-- for id, order in pairs(self.OrderDict) do +-- local times = order.Times and order.Times + 1 or 1 +-- if times >= ORDER_CHECK_TIMES_LIMIT then +-- tableInsert(list, id) +-- else +-- order.Times = times +-- end +-- end +-- for _, id in pairs(list) do +-- self.OrderDict[id] = nil +-- end +-- OnSaveOrders(self.PlayerId, self.OrderDict) +-- end +-- override this +function XPayAgent:OnPaySuccess(order) + self:AddOrder(order) + XUiManager.TipText("PayAcceptTips", XUiManager.UiTipType.Success) +end + +function XPayAgent:TipsPaySuccess() + if CS.XFight.IsRunning then + return + end + + if not next(TipsQueue) then + return + end + + tableRemove(TipsQueue, 1) + local text = CS.XTextManager.GetText("PaySuccess") + XUiManager.TipMsg(text, XUiManager.UiTipType.Success, function() + self:TipsPaySuccess() + end) +end + +--==============================-- +--desc: 交易成功,处理缓存订单 +--@orderList: 游戏订单列表 +--==============================-- +function XPayAgent:OnDealSuccess(orderList) + -- XLog.Error("充值结果回调--XPayAgent:OnDealSuccess(orderList)") + -- XLog.Error(orderList) + if not orderList or #orderList <= 0 then + return + end + + for _, order in pairs(orderList) do + if order.GameOrder then + self:RemoveOrder(order.GameOrder) + end + + if order.OrderNo then + self:RemoveOrder(order.OrderNo) + end + + tableInsert(TipsQueue, order.PayKey) + end + + -- 测试充值 + -- XLog.Error("充值结果回调--self:TipsPaySuccess()") + -- XLog.Error(TipsQueue) + self:TipsPaySuccess() +end \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XPayAgent/XPayHeroAgent.lua b/Resources/Scripts/XEntity/XPayAgent/XPayHeroAgent.lua new file mode 100644 index 00000000..b5921b48 --- /dev/null +++ b/Resources/Scripts/XEntity/XPayAgent/XPayHeroAgent.lua @@ -0,0 +1,82 @@ +XPayHeroAgent = XClass(XPayAgent, "XPayHeroAgent") + +local Application = CS.UnityEngine.Application +local Platform = Application.platform +local RuntimePlatform = CS.UnityEngine.RuntimePlatform + +local function TipPayFail() + local text = CS.XTextManager.GetText("PayFail") + XUiManager.DialogTip("", text, XUiManager.DialogType.OnlySure) + XEventManager.DispatchEvent(XEventId.EVNET_FAIL_PAY) +end + +local function PayAndroid(self, productKey, cpOrderId, goodsId, cb) + -- -- 测试充值 + -- XLog.Error("安卓进行充值") + XHgSdkManager.Pay(productKey, cpOrderId, goodsId, function(err, info) + -- XLog.Error("productKey"..tostring(productKey)) + -- XLog.Error("cpOrderId"..tostring(cpOrderId)) + -- XLog.Error("goodsId"..tostring(goodsId)) + -- XLog.Error("错误err") + -- XLog.Error(err) + -- XLog.Error("信息info") + -- XLog.Error(info) + if err then + TipPayFail() + return + end + + self:OnPaySuccess({ + ProductKey = productKey, + OrderId = cpOrderId, + GoodsId = goodsId, + PlayerId = XPlayer.Id + }) + + if cb then + cb() + end + end) +end + +local function PayIOS(self, productKey, cpOrderId, goodsId) + -- -- 测试充值 + -- XLog.Error("IOS进行充值") + -- XLog.Error("productKey"..tostring(productKey)) + -- XLog.Error("cpOrderId"..tostring(cpOrderId)) + -- XLog.Error("goodsId"..tostring(goodsId)) + XHgSdkManager.Pay(productKey, cpOrderId, goodsId) +end + +function XPayHeroAgent:Ctor() + if Platform == RuntimePlatform.Android then + self.Pay = PayAndroid + elseif Platform == RuntimePlatform.IPhonePlayer then + XHgSdkManager.RegisterIOSCallback(function(err, orderId) + self:OnIOSPayCallback(err, orderId) + end) + + self.Pay = PayIOS + else + XLog.error("XPayHeroAgent Ctor: unsupport platform, platform is ", Platform) + end +end + +-- function XPayHeroAgent:OnPaySuccess(order) +-- XPayHeroAgent.Super.OnPaySuccess(self, order) +-- end +-- function XPayHeroAgent:OnDealSuccess(orderList) +-- XPayHeroAgent.Super.OnDealSuccess(self, orderList) +-- self:UpdateOrderCheckTimes() +-- end +function XPayHeroAgent:OnIOSPayCallback(err, orderId) + if err then + TipPayFail() + return + end + + self:OnPaySuccess({ + OrderId = orderId, + PlayerId = XPlayer.Id + }) +end \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XPlayer.lua b/Resources/Scripts/XEntity/XPlayer.lua new file mode 100644 index 00000000..d64414b8 --- /dev/null +++ b/Resources/Scripts/XEntity/XPlayer.lua @@ -0,0 +1,514 @@ +local setmetatable = setmetatable +local table = table +local math = math + +local tableInsert = table.insert +local mathFloor = math.floor +local mathCeil = math.ceil + +local GETTER_KEY_PREFIX = "Getter" +local OPEN_HONOR_LEVEL = "openHonorLevel" + +local METHOD_NAME = { + ChangePlayerName = "ChangePlayerNameRequest", + ChangePlayerSign = "ChangePlayerSignRequest", + ChangePlayerMark = "ChangePlayerMarkRequest", + ChangePlayerBirthday = "ChangePlayerBirthdayRequest", + ChangePlayerMedal = "SetCurrentMedalRequest", + ChangeCommunication = "ChangeCommunicationRequest", + ChangeAppearance = "SetAppearanceRequest", -- 设置展示信息 + GetDormitoryList = "DormitoryListRequest", -- 得到宿舍列表 +} + +local NextChangeNameTime +local TempDormitoryList -- 宿舍列表缓存,只有登录的时候才会更新,进入宿舍系统后不再使用此数据,使用宿舍系统的数据 + +local PlayerData = {} -- 玩家数据,外部只读 +local Player = {} -- 玩家对象,公有方法 +local Getter = {} -- 属性get + +local function New() + return setmetatable({}, { + __metatable = "readonly", + __index = function(_, k) + if Player[k] ~= nil then + return Player[k] + end + + local getterKey = GETTER_KEY_PREFIX .. k + if Getter[getterKey] then + return Getter[getterKey]() + end + + return PlayerData[k] + end, + __newindex = function() + XLog.Error("attempt to update a readonly object") + end, + }) +end + +function Player.Init(playerData) + PlayerData = playerData + if PlayerData.Marks then + PlayerData.MarkDic = PlayerData.MarkDic or {} + for _, v in pairs(PlayerData.Marks) do + PlayerData.MarkDic[v] = true + end + end + XLog.Debug(string.format("PlayerId:%s, Name:%s", playerData.Id, playerData.Name)) + NextChangeNameTime = playerData.ChangeNameTime + XPlayerManager.PlayerChangeNameInterval + CS.Movie.XMovieManager.Instance.PlayerName = PlayerData.Name + Player.IsFirstOpenHonor = XSaveTool.GetData(OPEN_HONOR_LEVEL) + TempDormitoryList = {} +end + +function Getter.GetterExp() + local item = XDataCenter.ItemManager.GetItem(XDataCenter.ItemManager.ItemId.TeamExp) + if not item then + return 0 + else + return item:GetCount() + end +end + +function Player.GetAppearanceShowType() + return PlayerData.AppearanceShowType ~= nil and XTool.Clone(PlayerData.AppearanceShowType) or {} +end + +--- +--- 获取玩家展示设置 +function Player.GetAppearanceSettingInfo() + if PlayerData.AppearanceSettingInfo ~= nil then + return XTool.Clone(PlayerData.AppearanceSettingInfo) + else + XLog.Error("Player.GetAppearanceSettingInfo函数错误,没有AppearanceSettingInfo数据") + return { TitleType = XUiAppearanceShowType.ToAll, + FashionType = XUiAppearanceShowType.ToAll, + WeaponFashionType = XUiAppearanceShowType.ToAll, + DormitoryType = XUiAppearanceShowType.ToAll, + DormitoryId = 0, + } + end +end + +function Player.IsNewPlayerTaskUIGroupActive(index) + return (PlayerData.NewPlayerTaskActiveUi & (1 << index)) > 0 +end + +function Player.IsMark(id) + if PlayerData.MarkDic and PlayerData.MarkDic[id] then + return true + end + return false +end + + +--检测检测通讯系统 +function Player.IsCommunicationMark(id) + local marks = PlayerData.Communications or {} + for _, v in pairs(marks) do + if v == id then + return true + end + end + + return false +end + +function Player.IsGetDailyActivenessReward(index) + index = index - 1 + return (PlayerData.DailyActivenessRewardStatus & (1 << index)) > 0 +end + +function Player.IsGetWeeklyActivenessReward(index) + index = index - 1 + return (PlayerData.WeeklyActivenessRewardStatus & (1 << index)) > 0 +end + +function Player.HandlerPlayLevelUpAnimation() + if Player.NeedPlayLevelUp then + XLuaUiManager.Open("UiPlayerUp", Player.LevelUpAnimationData.OldLevel, Player.LevelUpAnimationData.NewLevel) + Player.NeedPlayLevelUp = false + Player.LevelUpAnimationData = nil + return true + end + return false +end + +-----------------服务端数据同步----------------- +-- 看板娘Id +function Player.SetDisplayCharId(charId) + PlayerData.DisplayCharId = charId +end + +function Player.AddMark(id) + if not PlayerData.MarkDic then + PlayerData.MarkDic = {} + end + PlayerData.MarkDic[id] = true +end + +--添加通讯系统标志 +function Player.AddCommunicationMark(id) + if not PlayerData.Communications then + PlayerData.Communications = {} + end + + tableInsert(PlayerData.Communications, id) +end + +function Player.SetNewPlayerTaskActiveUi(result) + PlayerData.NewPlayerTaskActiveUi = result +end + +function Player.SetPlayerLikes(count) + PlayerData.Likes = count +end + +function Player.GetUnlockedMedalInfoById(id) + return PlayerData.UnlockedMedalInfos[id] +end + +function Player.SetHeadPortrait(id) + PlayerData.CurrHeadPortraitId = id +end + +function Player.SetHeadFrame(id) + PlayerData.CurrHeadFrameId = id +end + +--荣耀勋阶是否开放 +function Player.IsHonorLevelOpen() + return XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.HonorLevel) +end + +function Player.CheckIsMaxLevel(level) + return level >= XPlayerManager.PlayerMaxLevel +end + +--荣耀勋阶 +function Player.GetHonorLevel() + return PlayerData.HonorLevel or 1 +end + +--小队等级 +function Player.GetLevel() + return PlayerData.Level or 1 +end + +--如果小队等级超过指定最大值(120),转为荣耀勋阶 +function Player.GetLevelOrHonorLevel() + if Player.IsHonorLevelOpen() then + return Player.GetHonorLevel() + else + return Player.GetLevel() + end +end + +function Player.GetMaxExp() + local level = Player.GetLevelOrHonorLevel() + return XPlayerManager.GetMaxExp(level, Player.IsHonorLevelOpen()) +end + +function Player.GetMaxLevel() + return XPlayerManager.PlayerMaxLevel +end + +--是否首次打开荣誉界面 +function Player.CheckIsFirstOpenHonor() + local isFirstOpenHonor = Player.IsFirstOpenHonor + if isFirstOpenHonor then + Player.IsFirstOpenHonor = nil + XSaveTool.RemoveData(OPEN_HONOR_LEVEL) + end + + return isFirstOpenHonor +end + +--@region XRpc + +-- 功能开发标记 +XRpc.NotifyPlayerMarks = function(data) + XTool.LoopCollection(data.Ids, function(id) + Player.AddMark(id) + end) +end + +-- 玩家名字 +XRpc.NotifyPlayerName = function(data) + PlayerData.Name = data.Name + CS.Movie.XMovieManager.Instance.PlayerName = PlayerData.Name +end + +-- 玩家签名 +XRpc.NotifySign = function(data) + PlayerData.Sign = data.Sign +end + +-- 新手目标相关 +XRpc.NotifyNewPlayerTaskStatus = function(data) + PlayerData.NewPlayerTaskActiveDay = data.NewPlayerTaskActiveDay + Player.SetNewPlayerTaskActiveUi(data.NewPlayerTaskActiveUi) + XEventManager.DispatchEvent(XEventId.EVENT_NEWBIETASK_DAYCHANGED) + local maxTab = #XTaskConfig.GetNewPlayerTaskGroupTemplate() + local activeDay = (data.NewPlayerTaskActiveDay > maxTab) and maxTab or data.NewPlayerTaskActiveDay + XDataCenter.TaskManager.SaveNewPlayerHint(XDataCenter.TaskManager.NewPlayerLastSelectTab, activeDay) +end + +XRpc.NotifyActivenessStatus = function(data) + PlayerData.DailyActivenessRewardStatus = data.DailyActivenessRewardStatus + PlayerData.WeeklyActivenessRewardStatus = data.WeeklyActivenessRewardStatus +end + +--@region 玩家升级 + +local function LevelUpAnimation(oldLevel, newLevel) + Player.LevelUpAnimationData = { + OldLevel = oldLevel, + NewLevel = newLevel + } + Player.NeedPlayLevelUp = true + XEventManager.DispatchEvent(XEventId.EVENT_PLAYER_LEVEL_CHANGE, newLevel) +end + +XRpc.NotifyPlayerLevel = function(data) + if PlayerData.Level >= data.Level then + return + end + + local oldLevel = PlayerData.Level + PlayerData.Level = data.Level + LevelUpAnimation(oldLevel, data.Level) + + --荣耀勋阶开放,用于打开个人信息界面时候播放一下特效 + if PlayerData.Level == XPlayerManager.PlayerMaxLevel then + Player.IsFirstOpenHonor = true + XSaveTool.SaveData(OPEN_HONOR_LEVEL, true) + end + --CheckPoint: APPEVENT_LEVEL + XAppEventManager.LevelAppLogEvent(data.Level) +end + +XRpc.NotifyHonorLevel = function(data) + if PlayerData.HonorLevel >= data.HonorLevel then + return + end + local oldLevel = PlayerData.HonorLevel + PlayerData.HonorLevel = data.HonorLevel + LevelUpAnimation(oldLevel, data.HonorLevel) +end + +--@endregion + + +XRpc.NotifyDailyReciveGiftCount = function(data) + PlayerData.DailyReceiveGiftCount = data.DailyReceiveGiftCount +end + +XRpc.NotifyTips = function(res) + XUiManager.TipCode(res.Code) +end +-- 推送协议屏蔽更改 +XRpc.NotifyShieldedProtocol = function(data) + XNetwork.SetShieldedProtocolList(data.ShieldedProtocolList) +end + +--@endregion + +--@region 服务端接口方法 +-----------------服务端数据同步----------------- +local DoChangeResultError = function(code, nextCanChangeTime) + if code == XCode.PlayerDataManagerChangeNameTimeLimit then + NextChangeNameTime = nextCanChangeTime + + local timeLimit = nextCanChangeTime - XTime.GetServerNowTimestamp() + local hour = mathFloor(timeLimit / 3600) + local minute = mathCeil(timeLimit % 3600 / 60) + + if minute == 60 then + hour = hour + 1 + minute = 0 + end + + XUiManager.TipCode(code, hour, minute) + return + end + + XUiManager.TipCode(code) +end + +function Player.ChangeName(name, cb) + if NextChangeNameTime > XTime.GetServerNowTimestamp() then + DoChangeResultError(XCode.PlayerDataManagerChangeNameTimeLimit, NextChangeNameTime) + return + end + + XNetwork.Call(METHOD_NAME.ChangePlayerName, { Name = name }, + function(response) + if response.Code == XCode.Success then + NextChangeNameTime = response.NextCanChangeTime + PlayerData.ChangeNameTime = response.NextCanChangeTime - XPlayerManager.PlayerChangeNameInterval + cb() + return + end + + DoChangeResultError(response.Code, response.NextCanChangeTime) + end) +end + +local CheckCanChangeBirthday = function() + return not (PlayerData.Birthday and PlayerData.Birthday.Mon and PlayerData.Birthday.Day) +end + +--修改生日 +function Player.ChangeBirthday(mon, day, cb) + if not CheckCanChangeBirthday() then + XUiManager.TipCode(XCode.PlayerDataManagerBirthdayAlreadySet) + return + end + + XNetwork.Call(METHOD_NAME.ChangePlayerBirthday, { Mon = mon, Day = day }, + function(response) + if response.Code ~= XCode.Success then + XUiManager.TipCode(response.Code) + return + end + + PlayerData.Birthday = { + Mon = mon, + Day = day + } + + cb() + end) +end + +--保存展示信息 +function Player.SetAppearance(charactersAppearanceType, characterIds, appearanceSettingInfo, cb) + XNetwork.Call(METHOD_NAME.ChangeAppearance, + { CharactersAppearanceType = charactersAppearanceType, Characters = characterIds, AppearanceSettingInfo = appearanceSettingInfo }, + function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XUiManager.TipText("SetAppearanceSuccess") + PlayerData.ShowCharacters = characterIds + PlayerData.AppearanceShowType = charactersAppearanceType + PlayerData.AppearanceSettingInfo = appearanceSettingInfo + if cb then + cb() + end + end) +end + +--- +--- 获取玩家的宿舍列表,结构为{ DormitoryId, DormitoryName } +function Player.GetDormitoryList(cb) + -- 宿舍系统要进入的时候才会请求并初始化宿舍数据 + local dormData = XDataCenter.DormManager.GetDormitoryData() + if next(dormData) then + -- 进入过宿舍系统 + local dormitoryList = {} + for id, dormRoomData in pairs(dormData) do + if dormRoomData:WhetherRoomUnlock() then + local temp = {} + temp.DormitoryId = id + temp.DormitoryName = dormRoomData:GetRoomName() + + table.insert(dormitoryList, temp) + end + end + if cb then + cb(dormitoryList) + end + else + -- 还未进入过宿舍系统,使用请求的宿舍列表 + if next(TempDormitoryList) then + if cb then + cb(TempDormitoryList) + end + else + XNetwork.Call(METHOD_NAME.GetDormitoryList, nil, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + TempDormitoryList = res.DormitoryList + if cb then + cb(res.DormitoryList) + end + end) + end + end +end + +--添加标记 +function Player.ChangeMarks(id) + Player.AddMark(id) + XNetwork.Call(METHOD_NAME.ChangePlayerMark, { MaskId = id }, function() + -- if res.Code == XCode.Success then + -- Player.AddMark(id) + -- end + end) +end + +--添加标记 +function Player.ChangeCommunicationMarks(id) + Player.AddCommunicationMark(id) + XNetwork.Call(METHOD_NAME.ChangeCommunication, { Id = id }, function() + -- if res.Code == XCode.Success then + + -- end + end) +end + + +function Player.ChangeSign(msg, cb) + XNetwork.Call(METHOD_NAME.ChangePlayerSign, { Msg = msg }, + function(response) + if response.Code ~= XCode.Success then + XUiManager.TipCode(response.Code) + return + end + + PlayerData.Sign = msg + cb() + end) +end + +function Player.ChangeMedal(id, cb) + XNetwork.Call(METHOD_NAME.ChangePlayerMedal, { Id = id }, + function(response) + if (response.Code == XCode.Success) then + PlayerData.CurrMedalId = id + cb() + XEventManager.DispatchEvent(XEventId.EVENT_MEDAL_USE) + else + XUiManager.TipCode(response.Code) + end + end) +end + + +function Player.IsMedalUnlock(medalId) + if not PlayerData.UnlockedMedalInfos then return false end + return PlayerData.UnlockedMedalInfos[medalId] and true or false +end + +function Player.AsyncMedalIds(MedalIds, IsAddNew) + if not PlayerData.UnlockedMedalInfos then PlayerData.UnlockedMedalInfos = {} end + for _, v in pairs(MedalIds or {}) do + if IsAddNew then + XDataCenter.MedalManager.AddNewMedal(v, XMedalConfigs.MedalType.Normal) + PlayerData.UnlockedMedalInfos[MedalIds.Id] = MedalIds + PlayerData.NewMedalInfo = MedalIds + else + PlayerData.UnlockedMedalInfos[v.Id] = v + end + end +end +--@endregion + +XPlayer = XPlayer or New() diff --git a/Resources/Scripts/XEntity/XPokemon/XPokemonMonster.lua b/Resources/Scripts/XEntity/XPokemon/XPokemonMonster.lua new file mode 100644 index 00000000..1b4958cf --- /dev/null +++ b/Resources/Scripts/XEntity/XPokemon/XPokemonMonster.lua @@ -0,0 +1,272 @@ +local XPokemonMonsterSkillGroup = require("XEntity/XPokemon/XPokemonMonsterSkillGroup") + +local type = type +local pairs = pairs +local ipairs = ipairs +local tableInsert = table.insert +local MonsterType = XPokemonConfigs.MonsterType +local FixToInt = FixToInt + +local Default = { + _Id = 0, + _Level = 0, + _Star = 0, + _CreateTime = 0, + _Ability = 0, --战力 + _SkillGroupIdList = {}, + _SkillGroupDic = {}, + _Attribute = {}, +} + +local XPokemonMonster = XClass(nil, "XPokemonMonster") + +function XPokemonMonster:Ctor(monsterId) + for key, value in pairs(Default) do + if type(value) == "table" then + self[key] = {} + else + self[key] = value + end + end + + self._Id = monsterId + self:InitSkillGroups() + + XEventManager.AddEventListener(XEventId.EVENT_ATTRIBUTE_MANAGER_INIT, handler(self, self.DelayUpdateAttribute)) +end + +function XPokemonMonster:UpdateData(data) + if not data then return end + + self._CreateTime = data.CreateTime + + self:UpdateStar(data.Star) + self:UpdateLevel(data.Level) + self:UpdateUsingSkills(data.SkillIdList) +end + +----------------------------------------------等级/星级相关 begin-------------------------------- +function XPokemonMonster:GetStar() + return self._Star +end + +function XPokemonMonster:IsMaxStar() + return self._Star == XPokemonConfigs.GetMonsterStarMaxStar(self._Id) +end + +function XPokemonMonster:UpStar(addStar) + local newStar = self._Star + addStar + self:UpdateStar(newStar) +end + +function XPokemonMonster:UpdateStar(star) + if not star then return end + + self._Star = star + self:TryUnlockSkills() +end + +function XPokemonMonster:GetLevel() + return self._Level +end + +function XPokemonMonster:GetMaxLevel() + return XPokemonConfigs.GetMonsterStarMaxLevel(self._Id, self._Star) +end + +function XPokemonMonster:IsMaxLevel() + return self._Level == self:GetMaxLevel() +end + +function XPokemonMonster:UpLevel(addLevel) + local newLevel = self._Level + addLevel + self:UpdateLevel(newLevel) +end + +function XPokemonMonster:UpdateLevel(level) + if not level then return end + + self._Level = level + self:UpdateAttribute() +end + +function XPokemonMonster:GetLevelUpCostItemInfo() + if self:IsMaxLevel() then return 0, 0 end + return XPokemonConfigs.GetMonsterLevelCostItemInfo(self._Id, self._Level) +end + +function XPokemonMonster:GetStarUpCostItemInfo() + if self:IsMaxStar() then return 0, 0 end + return XPokemonConfigs.GetMonsterStarCostItemInfo(self._Id, self._Star) +end +----------------------------------------------等级/星级相关 end-------------------------------- +----------------------------------------------属性相关 begin-------------------------------- +local _WaitForUpdateAttr--属性表加载慢于属性同步接口,延迟更新 +function XPokemonMonster:DelayUpdateAttribute() + if not _WaitForUpdateAttr then + return + end + + self:UpdateAttribute() + _WaitForUpdateAttr = nil +end + +function XPokemonMonster:UpdateAttribute() + if not XAttribManager.IsInited() then + _WaitForUpdateAttr = true + return + end + + local monsterId = self._Id + local npcId = XPokemonConfigs.GetMonsterNpcId(monsterId) + + self._Attribute = XAttribManager.GetNpcBaseAttribsByNpcIdWithReviseId(npcId, self._Level) + self:UpdateAbility() +end + +function XPokemonMonster:UpdateAbility() + local rateMonster, rateHp, rateAttack = XPokemonConfigs.GetMonsterAbilityRate(self._Id) + self._Ability = XMath.ToMinInt(rateMonster + self:GetHp() * rateHp + self:GetAttack() * rateAttack) +end + +function XPokemonMonster:GetAbility() + return self._Ability +end + +function XPokemonMonster:GetHp() + return FixToInt(self._Attribute[XNpcAttribType.Life]) +end + +function XPokemonMonster:GetAttack() + return FixToInt(self._Attribute[XNpcAttribType.AttackNormal]) +end + +function XPokemonMonster:GetPreHpAndPreAttack(preLevel) + local maxLevel = self:GetMaxLevel() + preLevel = preLevel < maxLevel and preLevel or maxLevel + local npcId = XPokemonConfigs.GetMonsterNpcId(self._Id) + local attribute = XAttribManager.GetNpcBaseAttribsByNpcIdWithReviseId(npcId, preLevel) + return FixToInt(attribute[XNpcAttribType.Life]), FixToInt(attribute[XNpcAttribType.AttackNormal]) +end +----------------------------------------------属性相关 end-------------------------------- +----------------------------------------------技能相关 begin-------------------------------- +function XPokemonMonster:InitSkillGroups() + local monsterId = self._Id + local skillIds = XPokemonConfigs.GetMonsterSkillIds(monsterId) + self._SkillGroupDic = {} + self._SkillGroupIdList = {} + for _, skillId in pairs(skillIds) do + local skillGroupId = XPokemonConfigs.GetMonsterSkillGroupId(skillId) + + local skillGroup = self._SkillGroupDic[skillGroupId] + if not skillGroup then + skillGroup = XPokemonMonsterSkillGroup.New(skillGroupId) + self._SkillGroupDic[skillGroupId] = skillGroup + + tableInsert(self._SkillGroupIdList, skillGroupId) + end + skillGroup:InitSkill(skillId) + end +end + +function XPokemonMonster:GetSkillGroup(skillGroupId) + local skillGroup = self._SkillGroupDic[skillGroupId] + if not skillGroup then + XLog.Error("XPokemonMonster:GetSkillGroup error: 口袋妖怪怪物技能组获取失败, skillGroupId: " .. skillGroupId .. "monsterId: " .. self._Id) + return + end + return skillGroup +end + +function XPokemonMonster:GetUsingSkillIdList() + local skillIds = {} + + for _, skillGroupId in ipairs(self._SkillGroupIdList) do + local skillGroup = self:GetSkillGroup(skillGroupId) + local skillId = skillGroup:GetUsingSkillId() + if skillId > 0 then + tableInsert(skillIds, skillId) + end + end + + return skillIds +end + +function XPokemonMonster:GetCanSwitchSkillIds(skillId) + local skillGroup = self:GetSkillGroupBySkillId(skillId) + return skillGroup:GetSkillIds() +end + +function XPokemonMonster:GetSkillGroupBySkillId(skillId) + local skillGroupId = XPokemonConfigs.GetMonsterSkillGroupId(skillId) + return self:GetSkillGroup(skillGroupId) +end + +--设置使用中的技能 +function XPokemonMonster:UpdateUsingSkills(usingSkillIds) + if usingSkillIds then + for _, skillId in pairs(usingSkillIds) do + self:SwitchSkill(skillId) + end + end +end + +function XPokemonMonster:IsSkillUsing(skillId) + local skillGroup = self:GetSkillGroupBySkillId(skillId) + return skillGroup:IsSkillUsing(skillId) +end + +function XPokemonMonster:IsSkillUnlock(skillId) + local skillGroup = self:GetSkillGroupBySkillId(skillId) + return skillGroup:IsSkillUnlock(skillId) +end + +function XPokemonMonster:IsSkillCanSwitch(skillId) + local skillGroup = self:GetSkillGroupBySkillId(skillId) + return skillGroup:IsSkillCanSwitch() +end + +function XPokemonMonster:SwitchSkill(skillId) + local skillGroup = self:GetSkillGroupBySkillId(skillId) + skillGroup:SwitchSkill(skillId) +end + +--获取该星级可解锁技能Id列表 +function XPokemonMonster:GetStarUnlockSkillIds(star) + local unlockSkillIds = {} + for _, skillGroup in pairs(self._SkillGroupDic) do + local skillIds = skillGroup:GetSkillIds() + + for _, skillId in pairs(skillIds) do + local unlockStar = XPokemonConfigs.GetMonsterSkillUnlockStar(skillId) + if unlockStar == star then + tableInsert(unlockSkillIds, skillId) + end + end + end + return unlockSkillIds +end + +--根据星级解锁所有技能 +function XPokemonMonster:TryUnlockSkills() + for _, skillGroup in pairs(self._SkillGroupDic) do + local skillIds = skillGroup:GetSkillIds() + for _, skillId in pairs(skillIds) do + self:TryUnlockSkill(skillId) + end + end +end + +function XPokemonMonster:IsSkillCanUnlock(skillId) + local unlockStar = XPokemonConfigs.GetMonsterSkillUnlockStar(skillId) + return self._Star >= unlockStar +end + +function XPokemonMonster:TryUnlockSkill(skillId) + if not self:IsSkillCanUnlock(skillId) then return end + + local skillGroup = self:GetSkillGroupBySkillId(skillId) + skillGroup:UnlockSkill(skillId) +end +----------------------------------------------技能相关 end-------------------------------- +return XPokemonMonster \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XPokemon/XPokemonMonsterSkill.lua b/Resources/Scripts/XEntity/XPokemon/XPokemonMonsterSkill.lua new file mode 100644 index 00000000..4069dc3b --- /dev/null +++ b/Resources/Scripts/XEntity/XPokemon/XPokemonMonsterSkill.lua @@ -0,0 +1,30 @@ +local type = type + +local Default = { + _Id = 0, + _IsUnlock = false, +} + +local XPokemonMonsterSkill = XClass(nil, "XPokemonMonsterSkill") + +function XPokemonMonsterSkill:Ctor(id) + for key, value in pairs(Default) do + if type(value) == "table" then + self[key] = {} + else + self[key] = value + end + end + + self._Id = id +end + +function XPokemonMonsterSkill:IsUnlock() + return self._IsUnlock or false +end + +function XPokemonMonsterSkill:Unlock(value) + self._IsUnlock = true +end + +return XPokemonMonsterSkill \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XPokemon/XPokemonMonsterSkillGroup.lua b/Resources/Scripts/XEntity/XPokemon/XPokemonMonsterSkillGroup.lua new file mode 100644 index 00000000..2b51cf83 --- /dev/null +++ b/Resources/Scripts/XEntity/XPokemon/XPokemonMonsterSkillGroup.lua @@ -0,0 +1,83 @@ +local XPokemonMonsterSkill = require("XEntity/XPokemon/XPokemonMonsterSkill") + +local type = type +local tableInsert = table.insert + +local Default = { + _Id = 0, + _UsingSkillId = 0, + _SkillIdList = {}, + _SkillDic = {}, +} + +local XPokemonMonsterSkillGroup = XClass(nil, "XPokemonMonsterSkillGroup") + +function XPokemonMonsterSkillGroup:Ctor(id) + for key, value in pairs(Default) do + if type(value) == "table" then + self[key] = {} + else + self[key] = value + end + end + + self._Id = id +end + +function XPokemonMonsterSkillGroup:InitSkill(skillId) + if self._SkillDic[skillId] then + XLog.Error("XPokemonMonsterSkillGroup:InitSkill error: 口袋妖怪怪物技能配置重复, skillId: " .. skillId .. "skillGroupId: " .. self._Id) + return + end + + self._SkillDic[skillId] = XPokemonMonsterSkill.New(skillId) + tableInsert(self._SkillIdList, skillId) +end + +function XPokemonMonsterSkillGroup:GetSkill(skillId) + local skill = self._SkillDic[skillId] + if not skill then + XLog.Error("XPokemonMonsterSkillGroup:GetSkill error: 口袋妖怪怪物技能获取失败, skillId: " .. skillId .. "skillGroupId: " .. self._Id) + return + end + return skill +end + +function XPokemonMonsterSkillGroup:GetSkillIds() + return XTool.Clone(self._SkillIdList) +end + +function XPokemonMonsterSkillGroup:GetUsingSkillId() + return self._UsingSkillId +end + +function XPokemonMonsterSkillGroup:IsSkillUnlock(skillId) + local skill = self:GetSkill(skillId) + return skill:IsUnlock() +end + +function XPokemonMonsterSkillGroup:IsSkillUsing(skillId) + return self._UsingSkillId == skillId +end + +function XPokemonMonsterSkillGroup:UnlockSkill(skillId) + local skill = self:GetSkill(skillId) + skill:Unlock() + + --默认使用第一个解锁的技能 + if self:GetUsingSkillId() == 0 then + self:SwitchSkill(skillId) + end +end + +function XPokemonMonsterSkillGroup:IsSkillCanSwitch() + return #self._SkillIdList > 1 +end + +function XPokemonMonsterSkillGroup:SwitchSkill(skillId) + if not self:IsSkillUnlock(skillId) then return end + + self._UsingSkillId = skillId +end + +return XPokemonMonsterSkillGroup \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XPokemon/XPokemonTeamPosData.lua b/Resources/Scripts/XEntity/XPokemon/XPokemonTeamPosData.lua new file mode 100644 index 00000000..175d35ad --- /dev/null +++ b/Resources/Scripts/XEntity/XPokemon/XPokemonTeamPosData.lua @@ -0,0 +1,40 @@ +local type = type +local pairs = pairs + +local Default = { + _Pos = 0, + _IsLock = true, + _MonsterId = 0, +} + +local XPokemonTeamPosData = XClass(nil, "XPokemonTeamPosData") + +function XPokemonTeamPosData:Ctor(pos) + for key, value in pairs(Default) do + if type(value) == "table" then + self[key] = {} + else + self[key] = value + end + end + + self._Pos = pos +end + +function XPokemonTeamPosData:IsLock() + return self._IsLock +end + +function XPokemonTeamPosData:Unlock() + self._IsLock = false +end + +function XPokemonTeamPosData:SetMonsterId(monsterId) + self._MonsterId = monsterId or 0 +end + +function XPokemonTeamPosData:GetMonsterId() + return self._MonsterId +end + +return XPokemonTeamPosData \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XPuzzleActivityData.lua b/Resources/Scripts/XEntity/XPuzzleActivityData.lua new file mode 100644 index 00000000..06b9733c --- /dev/null +++ b/Resources/Scripts/XEntity/XPuzzleActivityData.lua @@ -0,0 +1,29 @@ +--从服务器接收的格式 +local XPuzzleActivityData = XClass(nil, "XPuzzleActivityData") + +function XPuzzleActivityData:Ctor(id) + + self.GroupCfg = nil + self.PieceCfgs = {} + self.RewardState = XPuzzleActivityConfigs.PuzzleRewardState.Unrewarded + + local activityGroupTemplates = XPuzzleActivityConfigs.GetTemplates() + self.GroupCfg = activityGroupTemplates[id] + if not self.GroupCfg then return end + local pieceTemplates = XPuzzleActivityConfigs.GetPieceTemplates() + for _, template in pairs(pieceTemplates) do + if id == template.ActId then + table.insert(self.PieceCfgs, template) + end + end +end + +function XPuzzleActivityData:SetRewardState(state) + self.RewardState = state +end + +function XPuzzleActivityData:GetPieceAmount() + return #self.PieceCfgs +end + +return XPuzzleActivityData \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XReadOnlyTable.lua b/Resources/Scripts/XEntity/XReadOnlyTable.lua new file mode 100644 index 00000000..4696973b --- /dev/null +++ b/Resources/Scripts/XEntity/XReadOnlyTable.lua @@ -0,0 +1,48 @@ +XReadOnlyTable = XReadOnlyTable or {} + +local NeedSetReadonly = CS.XLuaEngine.LuaReadonlyTableMode ~= CS.XMode.Release + +XReadOnlyTable.HotLoad = false + +XReadOnlyTable.Create = function(t) + if not NeedSetReadonly or XReadOnlyTable.HotLoad then + -- release 模式运行 + return t + end + + for x, y in pairs(t) do + if type(x) == "table" then + if type(y) == "table" then + t[XReadOnlyTable.Create(x)] = XReadOnlyTable.Create(y) + else + t[XReadOnlyTable.Create(x)] = y + end + elseif type(y) == "table" then + t[x] = XReadOnlyTable.Create(y) + end + end + + local mt = { + __metatable = "readonly table", + __index = t, + __newindex = function(t,k,v) + if XReadOnlyTable.HotLoad then + rawset(t,k,v) + else + XLog.Error("attempt to update a readonly table") + end + end, + __len = function() + return #t + end, + __pairs = function() + local function stateless_iter(tbl, k) + local nk, nv = next(tbl, k) + if nk then return nk, nv end + end + return stateless_iter, t, nil + end + } + + return setmetatable({}, mt) +end \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XReform/Buff/XReformBuff.lua b/Resources/Scripts/XEntity/XReform/Buff/XReformBuff.lua new file mode 100644 index 00000000..4a782885 --- /dev/null +++ b/Resources/Scripts/XEntity/XReform/Buff/XReformBuff.lua @@ -0,0 +1,51 @@ +local XReformBuff = XClass(nil, "XReformBuff") + +-- config : XReformConfigs.BuffConfig +function XReformBuff:Ctor(config) + self.Config = config + self.IsActive = false + self.Id = self.Config.Id +end + +function XReformBuff:GetReformType() + return XReformConfigs.EvolvableGroupType.Buff +end + +function XReformBuff:GetId() + return self.Config.Id +end + +-- 名称 +function XReformBuff:GetName() + return self.Config.Name +end + +-- 星级 +function XReformBuff:GetStarLevel() + return self.Config.StarLevel +end + +function XReformBuff:GetDes() + return self.Config.Des +end + +-- 图标 +function XReformBuff:GetIcon() + return self.Config.Icon +end + +-- 积分 +function XReformBuff:GetScore() + return self.Config.SubScore +end + +function XReformBuff:SetIsActive(value) + self.IsActive = value +end + +-- 是否已激活 +function XReformBuff:GetIsActive() + return self.IsActive +end + +return XReformBuff \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XReform/Buff/XReformBuffGroup.lua b/Resources/Scripts/XEntity/XReform/Buff/XReformBuffGroup.lua new file mode 100644 index 00000000..0f89941d --- /dev/null +++ b/Resources/Scripts/XEntity/XReform/Buff/XReformBuffGroup.lua @@ -0,0 +1,43 @@ +local XReformBuff = require("XEntity/XReform/Buff/XReformBuff") +local XReformBuffGroup = XClass(nil, "XReformBuffGroup") + +-- config : XReformConfigs.BuffGroupConfig +function XReformBuffGroup:Ctor(config) + self.Config = config + -- XReformBuff + self.Buffs = {} + -- key : id, value : XReformBuff + self.BuffDic = {} + self:InitBuffs() +end + +-- 所有加成数据 +function XReformBuffGroup:GetBuffs() + return self.Buffs +end + +function XReformBuffGroup:GetBuffById(id) + return self.BuffDic[id] +end + +function XReformBuffGroup:GetName() + return CS.XTextManager.GetText("ReformEvolvableBuffNameText") +end + +--######################## 私有方法 ######################## + +function XReformBuffGroup:InitBuffs() + local config = nil + local data = nil + for _, id in ipairs(self.Config.SubId) do + config = XReformConfigs.GetBuffConfig(id) + if config then + data = XReformBuff.New(config) + table.insert(self.Buffs, data) + self.BuffDic[data:GetId()] = data + end + + end +end + +return XReformBuffGroup \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XReform/Enemy/XReformEnemyGroup.lua b/Resources/Scripts/XEntity/XReform/Enemy/XReformEnemyGroup.lua new file mode 100644 index 00000000..ebf8b24a --- /dev/null +++ b/Resources/Scripts/XEntity/XReform/Enemy/XReformEnemyGroup.lua @@ -0,0 +1,33 @@ +local XReformEnemySource = require("XEntity/XReform/Enemy/XReformEnemySource") +local XReformBaseSourceGroup = require("XEntity/XReform/XReformBaseSourceGroup") +local XReformEnemyGroup = XClass(XReformBaseSourceGroup, "XReformEnemyGroup") + +-- config : XReformConfigs.EnemyGroupConfig +function XReformEnemyGroup:Ctor(config) + self:InitSources() +end + +function XReformEnemyGroup:UpdateReplaceIdDic(replaceIdDic) + for _, source in ipairs(self.Sources) do + source:UpdateTargetId(replaceIdDic[source:GetId()]) + end +end + +function XReformEnemyGroup:GetName() + return CS.XTextManager.GetText("ReformEvolvableEnemyNameText") +end + +--######################## 私有方法 ######################## + +function XReformEnemyGroup:InitSources() + local config = nil + local data = nil + for _, sourceId in ipairs(self.Config.SubId) do + config = XReformConfigs.GetEnemySourceConfig(sourceId) + data = XReformEnemySource.New(config) + table.insert(self.Sources, data) + self.SourceDic[data:GetId()] = data + end +end + +return XReformEnemyGroup \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XReform/Enemy/XReformEnemySource.lua b/Resources/Scripts/XEntity/XReform/Enemy/XReformEnemySource.lua new file mode 100644 index 00000000..6b326166 --- /dev/null +++ b/Resources/Scripts/XEntity/XReform/Enemy/XReformEnemySource.lua @@ -0,0 +1,168 @@ +local XReformEnemyTarget = require("XEntity/XReform/Enemy/XReformEnemyTarget") +local XReformEnemySource = XClass(nil, "XReformEnemySource") + +-- config : XReformConfigs.EnemySourceConfig +function XReformEnemySource:Ctor(config) + self.Config = config + -- XReformEnemyTarget + self.Targets = {} + -- key : id value : XReformEnemyTarget + self.TargetDic = {} + self:InitTargets() + -- XArchiveMonsterEntity + self.MonsterEntity = nil + self.TargetId = nil + self.Id = self.Config.Id +end + +function XReformEnemySource:GetReformType() + return XReformConfigs.EvolvableGroupType.Enemy +end + +function XReformEnemySource:UpdateTargetId(targetId) + if targetId == 0 then targetId = nil end + local target = self:GetTargetById(self.TargetId) + if target then + target:UpdateSourceId(nil) + end + self.TargetId = targetId + if self.TargetId ~= nil then + target = self:GetTargetById(self.TargetId) + target:UpdateSourceId(self:GetId()) + end +end + +function XReformEnemySource:GetEntityType() + if self.Config.NpcId == 0 then + return XReformConfigs.EntityType.Add + end + return XReformConfigs.EntityType.Entity +end + +function XReformEnemySource:GetTargetId() + return self.TargetId +end + +function XReformEnemySource:GetCurrentTarget() + return self:GetTargetById(self.TargetId) +end + +function XReformEnemySource:GetTargets() + return self.Targets +end + +function XReformEnemySource:GetTargetById(id) + if id == nil then return nil end + return self.TargetDic[id] +end + +function XReformEnemySource:GetId() + return self.Config.Id +end + +function XReformEnemySource:GetIcon() + local target = self:GetCurrentTarget() + if target then + return target:GetIcon() + end + return self.Config.HeadIcon +end + +function XReformEnemySource:GetIsActive() + return self.TargetId ~= nil +end + +function XReformEnemySource:GetName() + local target = self:GetCurrentTarget() + if target then + return target:GetName() + end + return self.Config.Name +end + +function XReformEnemySource:GetLevel() + local target = self:GetCurrentTarget() + if target then + return target:GetLevel() + end + return self.Config.Level +end + +function XReformEnemySource:GetShowLevel() + local target = self:GetCurrentTarget() + if target then + return target:GetShowLevel() + end + return self.Config.ShowLevel +end + +function XReformEnemySource:GetBuffDetailViewModels() + local result = {} + local buffIdDic = {} + local target = self:GetCurrentTarget() + if target then + for _, buffId in ipairs(target:GetBuffIds()) do + if buffId ~= 0 then + buffIdDic[buffId] = true + end + end + end + for _, buffId in ipairs(self.Config.BuffIds) do + if buffId ~= 0 then + buffIdDic[buffId] = true + end + end + local data = nil + for buffId, _ in pairs(buffIdDic) do + data = XReformConfigs.GetEnemyBuffDetail(buffId) + if data then + table.insert(result, { + Name = data.Name, + Icon = data.Icon, + Description = data.Des + }) + end + end + return result +end + +function XReformEnemySource:GetScore() + return self.Config.AddScore +end + +function XReformEnemySource:GetTargetScore() + local target = self:GetCurrentTarget() + if target then + return target:GetScore() + end + return 0 +end + +-- return : XArchiveMonsterEntity +function XReformEnemySource:GetMonsterEntity() + local target = self:GetCurrentTarget() + if target then + return target:GetMonsterEntity() + end + if self.MonsterEntity == nil then + self.MonsterEntity = XDataCenter.ArchiveManager.GetArchiveMonsterEntityByNpcId(self.Config.NpcId) + end + return self.MonsterEntity +end + +--######################## 私有方法 ######################## + +function XReformEnemySource:InitTargets() + local config = nil + local data = nil + for _, targetId in ipairs(self.Config.TargetId) do + config = XReformConfigs.GetEnemyTargetConfig(targetId) + if config then + data = XReformEnemyTarget.New(config) + table.insert(self.Targets, data) + self.TargetDic[data:GetId()] = data + end + end +end + +return XReformEnemySource \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XReform/Enemy/XReformEnemyTarget.lua b/Resources/Scripts/XEntity/XReform/Enemy/XReformEnemyTarget.lua new file mode 100644 index 00000000..cf8c9cc5 --- /dev/null +++ b/Resources/Scripts/XEntity/XReform/Enemy/XReformEnemyTarget.lua @@ -0,0 +1,82 @@ +local XReformEnemyTarget = XClass(nil, "XReformEnemyTarget") + +-- config : XReformConfigs.EnemyTargetConfig +function XReformEnemyTarget:Ctor(config) + self.Config = config + -- XArchiveMonsterEntity + self.MonsterEntity = nil + self.SourceId = nil + self.Id = self.Config.Id +end + +function XReformEnemyTarget:UpdateSourceId(id) + self.SourceId = id +end + +function XReformEnemyTarget:GetSourceId() + return self.SourceId +end + +function XReformEnemyTarget:GetIsActive() + return self.SourceId ~= nil and self.SourceId ~= 0 +end + +function XReformEnemyTarget:GetId() + return self.Config.Id +end + +function XReformEnemyTarget:GetIcon() + return self.Config.HeadIcon +end + +function XReformEnemyTarget:GetName() + return self.Config.Name +end + +function XReformEnemyTarget:GetLevel() + return self.Config.Level +end + +function XReformEnemyTarget:GetShowLevel() + return self.Config.ShowLevel +end + +function XReformEnemyTarget:GetScore() + return self.Config.AddScore +end + +function XReformEnemyTarget:GetBuffIds() + return self.Config.BuffIds +end + +function XReformEnemyTarget:GetBuffDetailViewModels() + local result = {} + local buffIdDic = {} + for _, buffId in ipairs(self.Config.BuffIds) do + if buffId ~= 0 then + buffIdDic[buffId] = true + end + end + local data = nil + for buffId, _ in pairs(buffIdDic) do + data = XReformConfigs.GetEnemyBuffDetail(buffId) + if data then + table.insert(result, { + Name = data.Name, + Icon = data.Icon, + Description = data.Des + }) + end + end + return result +end + +-- return : XArchiveMonsterEntity +function XReformEnemyTarget:GetMonsterEntity() + if self.MonsterEntity == nil then + self.MonsterEntity = XDataCenter.ArchiveManager.GetArchiveMonsterEntityByNpcId(self.Config.NpcId) + end + return self.MonsterEntity +end + +return XReformEnemyTarget \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XReform/Environment/XReformEnvironment.lua b/Resources/Scripts/XEntity/XReform/Environment/XReformEnvironment.lua new file mode 100644 index 00000000..6281ebb5 --- /dev/null +++ b/Resources/Scripts/XEntity/XReform/Environment/XReformEnvironment.lua @@ -0,0 +1,58 @@ +local XReformEnvironment = XClass(nil, "XReformEnvironment") + +-- XReformConfigs.EnvironmentConfig +function XReformEnvironment:Ctor(config) + self.Config = config + self.IsActive = false + self.Id = self.Config.Id +end + +function XReformEnvironment:GetReformType() + return XReformConfigs.EvolvableGroupType.Environment +end + +function XReformEnvironment:GetId() + return self.Config.Id +end + +-- 名称 +function XReformEnvironment:GetName() + return self.Config.Name +end + +-- 描述 +function XReformEnvironment:GetDes() + return self.Config.Des +end + +function XReformEnvironment:GetIcon() + return self.Config.Icon +end + +function XReformEnvironment:GetTextIcon() + return self.Config.TextIcon +end + +function XReformEnvironment:GetPreviewIcon() + return self.Config.PreviewIcon +end + +function XReformEnvironment:GetPreviewText() + return self.Config.PreviewText +end + +-- 积分 +function XReformEnvironment:GetScore() + return self.Config.AddScore +end + +function XReformEnvironment:SetIsActive(value) + self.IsActive = value +end + +-- 是否已激活 +function XReformEnvironment:GetIsActive() + return self.IsActive +end + +return XReformEnvironment \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XReform/Environment/XReformEnvironmentGroup.lua b/Resources/Scripts/XEntity/XReform/Environment/XReformEnvironmentGroup.lua new file mode 100644 index 00000000..7dfdc13d --- /dev/null +++ b/Resources/Scripts/XEntity/XReform/Environment/XReformEnvironmentGroup.lua @@ -0,0 +1,42 @@ +local XReformEnvironment = require("XEntity/XReform/Environment/XReformEnvironment") +local XReformEnvironmentGroup = XClass(nil, "XReformEnvironmentGroup") + +-- config : XReformConfigs.EnvironmentGroupConfig +function XReformEnvironmentGroup:Ctor(config) + -- XReformEnvironment + self.Environments = {} + -- key : id, value : XReformEnvironment + self.EnvironmentDic = {} + self.Config = config + self:InitEnvironments() +end + +-- 所有环境数据 +function XReformEnvironmentGroup:GetEnvironments() + return self.Environments +end + +function XReformEnvironmentGroup:GetName() + return CS.XTextManager.GetText("ReformEvolvableEnvNameText") +end + +function XReformEnvironmentGroup:GetEnvironmentById(id) + return self.EnvironmentDic[id] +end + +--######################## 私有方法 ######################## + +function XReformEnvironmentGroup:InitEnvironments() + local config = nil + local data = nil + for _, id in ipairs(self.Config.SubId) do + config = XReformConfigs.GetEnvironmentConfig(id) + if config then + data = XReformEnvironment.New(config) + table.insert(self.Environments, data) + self.EnvironmentDic[data:GetId()] = data + end + end +end + +return XReformEnvironmentGroup \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XReform/Member/XReformMemberGroup.lua b/Resources/Scripts/XEntity/XReform/Member/XReformMemberGroup.lua new file mode 100644 index 00000000..31b9e371 --- /dev/null +++ b/Resources/Scripts/XEntity/XReform/Member/XReformMemberGroup.lua @@ -0,0 +1,61 @@ +local XReformMemberSource = require("XEntity/XReform/Member/XReformMemberSource") +local XReformBaseSourceGroup = require("XEntity/XReform/XReformBaseSourceGroup") +local XReformMemberGroup = XClass(XReformBaseSourceGroup, "XReformMemberGroup") + +-- config : XReformConfigs.MemberGroupConfig +function XReformMemberGroup:Ctor(config) + self:InitSources() +end + +function XReformMemberGroup:UpdateReplaceIdDic(replaceIdDic) + for _, source in ipairs(self.Sources) do + source:UpdateTargetId(replaceIdDic[source:GetId()]) + end +end + +function XReformMemberGroup:GetMemberSourcesWithRobot() + local result = {} + local starLevelResult = {} + for _, source in ipairs(self.Sources) do + -- 查找实体 + if source:GetEntityType() == XReformConfigs.EntityType.Entity + or source:GetTargetId() ~= nil then + table.insert(result, source:GetRobot()) + table.insert(starLevelResult, source:GetStarLevel()) + end + end + return result, starLevelResult +end + +function XReformMemberGroup:GetName() + return CS.XTextManager.GetText("ReformEvolvableMemberNameText") +end + +function XReformMemberGroup:GetAllCanJoinTeamSources() + local result = {} + local robotId = nil + for _, source in ipairs(self.Sources) do + robotId = source:GetRobotId() + if robotId ~= 0 and robotId ~= nil then + table.insert(result, source) + end + end + return result +end + +--######################## 私有方法 ######################## + +function XReformMemberGroup:InitSources() + local config = nil + local data = nil + for _, sourceId in ipairs(self.Config.SubId) do + config = XReformConfigs.GetMemberSourceConfig(sourceId) + if config then + data = XReformMemberSource.New(config) + table.insert(self.Sources, data) + self.SourceDic[data:GetId()] = data + end + end +end + +return XReformMemberGroup \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XReform/Member/XReformMemberSource.lua b/Resources/Scripts/XEntity/XReform/Member/XReformMemberSource.lua new file mode 100644 index 00000000..564854c7 --- /dev/null +++ b/Resources/Scripts/XEntity/XReform/Member/XReformMemberSource.lua @@ -0,0 +1,181 @@ +local XRobot = require("XEntity/XRobot/XRobot") +local XReformMemberTarget = require("XEntity/XReform/Member/XReformMemberTarget") +local XReformMemberSource = XClass(nil, "XReformMemberSource") + +-- config : XReformConfigs.MemberSourceConfig +function XReformMemberSource:Ctor(config) + self.Config = config + -- XReformMemberTarget + self.Targets = {} + -- key : id value : XReformMemberTarget + self.TargetDic = {} + self:InitTargets() + self.TargetId = nil + -- XRobot + self.Robot = nil + -- XCharacterViewModel + self.CharacterViewModel = nil + self.Id = self.Config.Id +end + +function XReformMemberSource:GetReformType() + return XReformConfigs.EvolvableGroupType.Member +end + +function XReformMemberSource:GetId() + return self.Config.Id +end + +function XReformMemberSource:GetScore() + return self.Config.SubScore +end + +function XReformMemberSource:GetStarLevel() + local target = self:GetCurrentTarget() + if target then + return target:GetStarLevel() + end + return self.Config.StarLevel +end + +function XReformMemberSource:GetRobotId() + local target = self:GetCurrentTarget() + if target then + return target:GetRobotId() + end + return self.Config.RobotId +end + +function XReformMemberSource:GetRobot() + local target = self:GetCurrentTarget() + if target then + return target:GetRobot() + end + if self.Robot == nil then + self.Robot = XRobot.New(self.Config.RobotId) + end + return self.Robot +end + +function XReformMemberSource:GetCharacterViewModel() + if self.CharacterViewModel == nil then + self.CharacterViewModel = self:GetRobot():GetCharacterViewModel() + end + return self.CharacterViewModel +end + +function XReformMemberSource:GetName() + local target = self:GetCurrentTarget() + if target then + return target:GetName() + end + return self:GetCharacterViewModel():GetName() +end + +function XReformMemberSource:GetLogName() + local target = self:GetCurrentTarget() + if target then + return target:GetLogName() + end + return self:GetCharacterViewModel():GetLogName() +end + +function XReformMemberSource:GetLevel() + local target = self:GetCurrentTarget() + if target then + return target:GetLevel() + end + return self:GetCharacterViewModel():GetLevel() +end + +function XReformMemberSource:GetIsActive() + return self.TargetId ~= nil +end + +function XReformMemberSource:GetIcon() + return self:GetSmallHeadIcon() +end + +function XReformMemberSource:GetBigHeadIcon() + local target = self:GetCurrentTarget() + if target then + return target:GetBigHeadIcon() + end + return self:GetCharacterViewModel():GetBigHeadIcon() +end + +function XReformMemberSource:GetSmallHeadIcon() + local target = self:GetCurrentTarget() + if target then + return target:GetSmallHeadIcon() + end + return self:GetCharacterViewModel():GetSmallHeadIcon() +end + + +function XReformMemberSource:GetTargets() + return self.Targets +end + +function XReformMemberSource:GetEntityType() + if self.Config.RobotId == 0 then + return XReformConfigs.EntityType.Add + end + return XReformConfigs.EntityType.Entity +end + +function XReformMemberSource:GetTargetId() + return self.TargetId +end + +function XReformMemberSource:UpdateTargetId(targetId) + if targetId == 0 then targetId = nil end + local memberTarget = self:GetTargetById(self.TargetId) + if memberTarget then + memberTarget:UpdateSourceId(nil) + end + self.TargetId = targetId + if self.TargetId ~= nil then + memberTarget = self:GetTargetById(self.TargetId) + memberTarget:UpdateSourceId(self:GetId()) + end +end + +function XReformMemberSource:GetTargetById(id) + if id == nil then return nil end + return self.TargetDic[id] +end + +function XReformMemberSource:GetTargetById(id) + if id == nil then return nil end + return self.TargetDic[id] +end + +function XReformMemberSource:GetCurrentTarget() + return self:GetTargetById(self.TargetId) +end + +function XReformMemberSource:GetTargetScore() + local target = self:GetCurrentTarget() + if target then + return target:GetScore() + end + return 0 +end + +--######################## 私有方法 ######################## + +function XReformMemberSource:InitTargets() + local config = nil + local data = nil + for _, targetId in ipairs(self.Config.TargetId) do + config = XReformConfigs.GetMemberTargetConfig(targetId) + if config then + data = XReformMemberTarget.New(config) + table.insert(self.Targets, data) + self.TargetDic[data:GetId()] = data + end + end +end + +return XReformMemberSource \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XReform/Member/XReformMemberTarget.lua b/Resources/Scripts/XEntity/XReform/Member/XReformMemberTarget.lua new file mode 100644 index 00000000..6ed49beb --- /dev/null +++ b/Resources/Scripts/XEntity/XReform/Member/XReformMemberTarget.lua @@ -0,0 +1,77 @@ +local XRobot = require("XEntity/XRobot/XRobot") +local XReformMemberTarget = XClass(nil, "XReformMemberTarget") + +-- config : XReformConfigs.MemberTargetConfig +function XReformMemberTarget:Ctor(config) + self.Config = config + self.SourceId = nil + -- XRobot + self.Robot = nil + -- XCharacterViewModel + self.CharacterViewModel = nil + self.Id = self.Config.Id +end + +function XReformMemberTarget:GetId() + return self.Config.Id +end + +function XReformMemberTarget:GetSourceId() + return self.SourceId +end + +function XReformMemberTarget:GetIsActive() + return self.SourceId ~= nil and self.SourceId ~= 0 +end + +function XReformMemberTarget:GetName() + return self:GetCharacterViewModel():GetName() +end + +function XReformMemberTarget:GetLogName() + return self:GetCharacterViewModel():GetLogName() +end + +function XReformMemberTarget:GetStarLevel() + return self.Config.StarLevel +end + +function XReformMemberTarget:GetScore() + return self.Config.SubScore +end + +function XReformMemberTarget:GetSmallHeadIcon() + return self:GetCharacterViewModel():GetSmallHeadIcon() +end + +function XReformMemberTarget:GetLevel() + return self:GetCharacterViewModel():GetLevel() +end + +function XReformMemberTarget:GetBigHeadIcon() + return self:GetCharacterViewModel():GetBigHeadIcon() +end + +function XReformMemberTarget:UpdateSourceId(id) + self.SourceId = id +end + +function XReformMemberTarget:GetRobotId() + return self.Config.RobotId +end + +function XReformMemberTarget:GetRobot() + if self.Robot == nil then + self.Robot = XRobot.New(self.Config.RobotId) + end + return self.Robot +end + +function XReformMemberTarget:GetCharacterViewModel() + if self.CharacterViewModel == nil then + self.CharacterViewModel = self:GetRobot():GetCharacterViewModel() + end + return self.CharacterViewModel +end + +return XReformMemberTarget \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XReform/XReformBaseSourceGroup.lua b/Resources/Scripts/XEntity/XReform/XReformBaseSourceGroup.lua new file mode 100644 index 00000000..fe36b734 --- /dev/null +++ b/Resources/Scripts/XEntity/XReform/XReformBaseSourceGroup.lua @@ -0,0 +1,55 @@ +local XReformBaseSourceGroup = XClass(nil, "XReformBaseSourceGroup") + +function XReformBaseSourceGroup:Ctor(config) + self.Config = config + -- XReformMemberSource | XReformEnemySource + self.Sources = {} + -- key : id , vlaue : XReformMemberSource | XReformEnemySource + self.SourceDic = {} +end + +function XReformBaseSourceGroup:GetSourceById(id) + return self.SourceDic[id] +end + +function XReformBaseSourceGroup:GetSourcesWithEntity(checkAdd) + if checkAdd == nil then checkAdd = true end + local result = {} -- 携带有实体的源 + local nextAddSource = nil -- 下一个待添加的源 + local emptyPosCount = 0 -- 剩余空位置数量 + for _, source in ipairs(self.Sources) do + -- 查找实体 + if source:GetEntityType() == XReformConfigs.EntityType.Entity + or source:GetTargetId() ~= nil then + table.insert(result, source) + elseif checkAdd and source:GetEntityType() == XReformConfigs.EntityType.Add + and source:GetTargetId() == nil then + emptyPosCount = emptyPosCount + 1 + if nextAddSource == nil then nextAddSource = source end + end + end + return result, nextAddSource, emptyPosCount +end + +-- 剩余空位置的数量 +function XReformBaseSourceGroup:GetEmptyPosCount() + local result = 0 + for _, source in ipairs(self.Sources) do + if source:GetEntityType() == XReformConfigs.EntityType.Add + and source:GetTargetId() == nil then + result = result + 1 + end + end + return result +end + +function XReformBaseSourceGroup:GetSourceIndexById(id) + for index, sourceId in ipairs(self.Config.SubId) do + if sourceId == id then + return index + end + end + return -1 +end + +return XReformBaseSourceGroup \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XReform/XReformBaseStage.lua b/Resources/Scripts/XEntity/XReform/XReformBaseStage.lua new file mode 100644 index 00000000..cdd18d70 --- /dev/null +++ b/Resources/Scripts/XEntity/XReform/XReformBaseStage.lua @@ -0,0 +1,201 @@ +local XReformEvolvableStage = require("XEntity/XReform/XReformEvolvableStage") +local XReformBaseStage = XClass(nil, "XReformBaseStage") + +local MAX_DIFF_INDEX = 4 + +-- config : XReformConfigs.StageConfig +function XReformBaseStage:Ctor(config) + -- XReformEvolvableStage + self.EvolvableStageDic = {} + -- XReformConfigs.StageConfig + self.Config = config + -- 当前难度 + self.CurDiffIndex = 1 + -- 未解锁的难度 + self.UnlockDiffIndex = 1 + -- stage配置表 + self.StageConfig = XDataCenter.FubenManager.GetStageCfg(config.Id) + -- 引导Id + self.Id = self.Config.Id +end + +-- data : XReformStageDb +function XReformBaseStage:InitWithServerData(data) + -- 默认选择当前最大难度 + self.CurDiffIndex = data.CurDiffIndex + 1 + self.UnlockDiffIndex = data.UnlockDiffIndex + 1 + local evolvableStage = nil + -- difficultDb : ReformStageDifficultyDb + for _, difficultDb in ipairs(data.DifficultyDbs) do + evolvableStage = self:GetEvolvableStageById(difficultDb.Id) + if evolvableStage == nil then + XLog.Warning(string.format("服务器改造难度Id%s在本地配置找不到", difficultDb.Id)) + else + evolvableStage:InitWithServerData(difficultDb) + XDataCenter.ReformActivityManager.AddEvolvableMaxScore(self.Config.Id, evolvableStage:GetDifficulty(), difficultDb.Score) + end + end +end + +function XReformBaseStage:UpdateUnlockDiffIndex(value) + self.UnlockDiffIndex = value +end + +function XReformBaseStage:SetCurrentDiffIndex(value) + self.CurDiffIndex = value +end + +function XReformBaseStage:GetUnlockDiffIndex() + return self.UnlockDiffIndex +end + +function XReformBaseStage:GetIsPlayReformUnlockEffect() + local result = false + local isPass = self:GetIsPassed() + local isPlayed = XSaveTool.GetData(self:GetId() .. XPlayer.Id .. "GetIsPlayReformUnlockEffect" + .. XDataCenter.ReformActivityManager.GetId()) or false + if not isPlayed and isPass then + result = true + XSaveTool.SaveData(self:GetId() .. XPlayer.Id .. "GetIsPlayReformUnlockEffect" + .. XDataCenter.ReformActivityManager.GetId(), true) + end + return result +end + +function XReformBaseStage:GetIsShowEvolvableDiffTip() + if self.CurDiffIndex >= 4 then + return false + end + local isOpen = self:GetDifficultyIsOpen(self.CurDiffIndex + 1) + local isTiped = XSaveTool.GetData(self:GetId() .. XPlayer.Id .. "GetIsShowEvolvableDiffTip" .. self.CurDiffIndex + 1 + .. XDataCenter.ReformActivityManager.GetId()) or false + if isOpen and not isTiped then + if self.CurDiffIndex == 1 and not self:GetIsPassed() then + return false + end + XSaveTool.SaveData(self:GetId() .. XPlayer.Id .. "GetIsShowEvolvableDiffTip" .. self.CurDiffIndex + 1 + .. XDataCenter.ReformActivityManager.GetId(), true) + return true, self:GetEvolvableStageByDiffIndex(self.CurDiffIndex + 1) + end + return false +end + +function XReformBaseStage:GetEvolvableStageById(id) + local evolvableStage = self.EvolvableStageDic[id] + if evolvableStage == nil then + local config = XReformConfigs.GetStageDiffConfigById(id) + evolvableStage = XReformEvolvableStage.New(config) + evolvableStage:SetSaveTeamDataKey("REFORM_" .. self:GetId() .. "_" .. evolvableStage:GetId()) + self.EvolvableStageDic[id] = evolvableStage + end + return evolvableStage +end + +-- diffIndex : 从1开始,1是基础关卡信息配置 +function XReformBaseStage:GetEvolvableStageByDiffIndex(diffIndex) + diffIndex = diffIndex or self.CurDiffIndex + return self:GetEvolvableStageById(self.Config.StageDiff[diffIndex]) +end + +function XReformBaseStage:GetId() + return self.Config.Id +end + +-- 名称 +function XReformBaseStage:GetName() + return self.Config.Name +end + +function XReformBaseStage:GetShowNpcId() + return self.Config.ShowNpcId +end + +-- 是否锁定 +function XReformBaseStage:GetIsUnlock() + return XFunctionManager.CheckInTimeByTimeId(self.Config.OpenTimeId) +end + +function XReformBaseStage:GetCurrentEvolvableStageTeamData() + local evolvableStage = self:GetCurrentEvolvableStage() + local memberGroup = evolvableStage:GetEvolvableGroupByType(XReformConfigs.EvolvableGroupType.Member) + return evolvableStage:GetTeamData() +end + +function XReformBaseStage:GetCurrentEvolvableStageGroup(groupType) + local evolvableStage = self:GetCurrentEvolvableStage() + return evolvableStage:GetEvolvableGroupByType(groupType) +end + +function XReformBaseStage:SaveCurrentEvolvableTeamData(teamData) + self:GetCurrentEvolvableStage():SaveTeamData(teamData) +end + +-- 获取解锁时间信息 +function XReformBaseStage:GetUnlockTimeStr() + local startTime = XFunctionManager.GetStartTimeByTimeId(self.Config.OpenTimeId) + local nowTime = XTime.GetServerNowTimestamp() + return XUiHelper.GetTime(startTime - nowTime, XUiHelper.TimeFormatType.ACTIVITY) +end + +function XReformBaseStage:GetCurrentEvolvableStage() + return self:GetEvolvableStageByDiffIndex(self.CurDiffIndex) +end + +function XReformBaseStage:GetCurrentDifficulty() + return self.CurDiffIndex +end + +function XReformBaseStage:GetFirstRewards() + return XRewardManager.GetRewardList(self.StageConfig.FirstRewardId) +end + +-- 是否已通关 +function XReformBaseStage:GetIsPassed() + return self.UnlockDiffIndex >= 2 +end + +function XReformBaseStage:GetDifficultyIsOpen(diffIndex) + if diffIndex <= 0 then return true end + local lastStage = self:GetEvolvableStageByDiffIndex(diffIndex - 1) + local nextStage = self:GetEvolvableStageByDiffIndex(diffIndex) + return lastStage:GetMaxScore() >= nextStage:GetUnlockScore() +end + +-- 获取改造关卡数据 +function XReformBaseStage:GetEvolvableStages() + local result = {} + local evolvableStage = nil + for i = 2, #self.Config.StageDiff do + evolvableStage = self:GetEvolvableStageById(self.Config.StageDiff[i]) + table.insert(result, evolvableStage) + end + return result +end + +-- 累计积分 +function XReformBaseStage:GetAccumulativeScore() + local result = 0 + for _, evolvableStage in pairs(self.EvolvableStageDic) do + result = result + evolvableStage:GetMaxScore() + end + return result +end + +function XReformBaseStage:GetEvolvableStageDic() + return self.EvolvableStageDic +end + +function XReformBaseStage:GetShowTips() + return self.StageConfig.StarDesc +end + +-- return : XFubenConfigs.StageFightEventDetails +function XReformBaseStage:GetShowFightEvents() + local result = {} + for _, fightEventId in ipairs(self.Config.ShowFightEventIds) do + table.insert(result, XFubenConfigs.GetStageFightEventDetailsByStageFightEventId(fightEventId)) + end + return result +end + +return XReformBaseStage \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XReform/XReformEvolvableStage.lua b/Resources/Scripts/XEntity/XReform/XReformEvolvableStage.lua new file mode 100644 index 00000000..fa3de923 --- /dev/null +++ b/Resources/Scripts/XEntity/XReform/XReformEvolvableStage.lua @@ -0,0 +1,313 @@ +local XReformEnemyGroup = require("XEntity/XReform/Enemy/XReformEnemyGroup") +local XReformMemberGroup = require("XEntity/XReform/Member/XReformMemberGroup") +local XReformEnvironmentGroup = require("XEntity/XReform/Environment/XReformEnvironmentGroup") +local XReformBuffGroup = require("XEntity/XReform/Buff/XReformBuffGroup") +local XReformEvolvableStage = XClass(nil, "XReformEvolvableStage") + +-- config : XReformConfigs.StageDiffConfig +function XReformEvolvableStage:Ctor(config) + -- XReformConfigs.StageDiffConfig + self.Config = config + -- XReformEnemyGroup | XReformMemberGroup | XReformEnvironmentGroup | XReformBuffGroup + self.EvolvableGroupDic = {} + -- 当前关卡敌人替换的数据 + -- key : sourceId, value : targetId + self.EnemyReplaceIdDic = {} + -- 当前关卡成员替换的数据 + -- key : sourceId, value : targetId + self.MemberReplaceIdDic = {} + -- 当前关卡拥有的环境id + self.EnvIds = {} + -- 当前关卡拥有的加成id + self.BuffIds = {} + -- 当前选择的挑战分数 + self.ChallengeScore = 0 + -- 历史最高积分 + self.MaxScore = 0 + -- 当前改造关队伍数据 + self.TeamData = nil + self.SaveTeamDataKey = nil + self:InitEnemyGroup() + self:InitMemberGroup() + self:InitEnvironmentGroup() + self:InitBuffGroup() + self.Id = self.Config.Id +end + +-- data : ReformStageDifficultyDb +function XReformEvolvableStage:InitWithServerData(data) + self.MaxScore = data.Score + self:UpdateEnemyReplaceIds(data.EnemyReplaceIds, false) + self:UpdateMemberReplaceIds(data.MemberReplaceIds, false) + self:UpdateEnvironmentIds(data.EnvIds, false) + self:UpdateBuffIds(data.BuffIds, false) + self:UpdateChallengeScore() +end + +function XReformEvolvableStage:UpdateMaxScore(value) + self.MaxScore = value +end + +function XReformEvolvableStage:SetSaveTeamDataKey(value) + self.SaveTeamDataKey = value .. XPlayer.Id .. XDataCenter.ReformActivityManager.GetId() + self.TeamData = XSaveTool.GetData(self.SaveTeamDataKey) +end + +function XReformEvolvableStage:GetId() + return self.Config.Id +end + +function XReformEvolvableStage:GetTeamData() + if self.TeamData == nil then + local memberGroup = self:GetEvolvableGroupByType(XReformConfigs.EvolvableGroupType.Member) + self.TeamData = { + -- 默认都是空位置 + SourceIdsInTeam = {0, 0, 0}, + FirstFightPos = 1, + CaptainPos = 1, + } + end + return self.TeamData +end + +function XReformEvolvableStage:SaveTeamData(data) + self.TeamData = data + if self.SaveTeamDataKey then + XSaveTool.SaveData(self.SaveTeamDataKey, data) + end +end + +function XReformEvolvableStage:CheckEnvironmentMaxCount() + return #self.EnvIds < self.Config.ReformEnvMaxCount +end + +function XReformEvolvableStage:CheckBuffMaxCount() + return #self.BuffIds < self.Config.ReformBuffMaxCount +end + +function XReformEvolvableStage:GetMaxEnvrionmentCount() + return self.Config.ReformEnvMaxCount +end + +function XReformEvolvableStage:GetMaxBuffCount() + return self.Config.ReformBuffMaxCount +end + +function XReformEvolvableStage:GetMemberReplaceIdDic() + return self.MemberReplaceIdDic +end + +function XReformEvolvableStage:GetUnlockScore() + return self.Config.UnlockScore +end + +function XReformEvolvableStage:GetEnemyReplaceIdDic() + return self.EnemyReplaceIdDic +end + +function XReformEvolvableStage:UpdateEnemyReplaceIds(replaceIdDbs, isUpdateChallengeScore) + self.EnemyReplaceIdDic = {} + for _, replaceIdDb in ipairs(replaceIdDbs) do + self.EnemyReplaceIdDic[replaceIdDb.SourceId] = replaceIdDb.TargetId + end + local enemyGroup = self.EvolvableGroupDic[XReformConfigs.EvolvableGroupType.Enemy] + if not enemyGroup then return end + if isUpdateChallengeScore == nil then isUpdateChallengeScore = true end + enemyGroup:UpdateReplaceIdDic(self.EnemyReplaceIdDic) + if isUpdateChallengeScore then + self:UpdateChallengeScore() + end +end + +function XReformEvolvableStage:UpdateMemberReplaceIds(replaceIdDbs, isUpdateChallengeScore) + self.MemberReplaceIdDic = {} + for _, replaceIdDb in ipairs(replaceIdDbs) do + self.MemberReplaceIdDic[replaceIdDb.SourceId] = replaceIdDb.TargetId + end + local memberGroup = self.EvolvableGroupDic[XReformConfigs.EvolvableGroupType.Member] + if not memberGroup then return end + if isUpdateChallengeScore == nil then isUpdateChallengeScore = true end + memberGroup:UpdateReplaceIdDic(self.MemberReplaceIdDic) + if isUpdateChallengeScore then + self:UpdateChallengeScore() + end + -- 清除队伍数据 + local source + local teamData = self:GetTeamData() + for i, sourceId in ipairs(teamData.SourceIdsInTeam) do + source = memberGroup:GetSourceById(sourceId) + if source == nil or source:GetRobotId() == 0 then + teamData.SourceIdsInTeam[i] = 0 + end + end + self:SaveTeamData(teamData) +end + +function XReformEvolvableStage:UpdateBuffIds(buffIds, isUpdateChallengeScore) + self.BuffIds = buffIds + local buffGroup = self.EvolvableGroupDic[XReformConfigs.EvolvableGroupType.Buff] + if not buffGroup then return end + if isUpdateChallengeScore == nil then isUpdateChallengeScore = true end + for _, buff in ipairs(buffGroup:GetBuffs()) do + buff:SetIsActive(false) + end + local buff = nil + for _, buffId in ipairs(buffIds) do + buff = buffGroup:GetBuffById(buffId) + if buff == nil then + XLog.Warning(string.format("服务器加成Id%s在本地配置找不到", buffId)) + else + buff:SetIsActive(true) + end + end + if isUpdateChallengeScore then + self:UpdateChallengeScore() + end +end + +function XReformEvolvableStage:UpdateEnvironmentIds(environmentIds, isUpdateChallengeScore) + self.EnvIds = environmentIds + local environmentGroup = self.EvolvableGroupDic[XReformConfigs.EvolvableGroupType.Environment] + if not environmentGroup then return end + if isUpdateChallengeScore == nil then isUpdateChallengeScore = true end + for _, env in ipairs(environmentGroup:GetEnvironments()) do + env:SetIsActive(false) + end + local env = nil + for _, envId in ipairs(environmentIds) do + env = environmentGroup:GetEnvironmentById(envId) + if env == nil then + XLog.Warning(string.format("服务器环境Id%s在本地配置找不到", envId)) + else + env:SetIsActive(true) + end + end + if isUpdateChallengeScore then + self:UpdateChallengeScore() + end +end + +function XReformEvolvableStage:UpdateChallengeScore() + local result = 0 + -- 敌人 + local enemyTargetConfig = nil + local enemySourceConfig = nil + for sourceId, targetId in pairs(self.EnemyReplaceIdDic) do + enemyTargetConfig = XReformConfigs.GetEnemyTargetConfig(targetId) + if enemyTargetConfig then + enemySourceConfig = XReformConfigs.GetEnemySourceConfig(sourceId) + if enemySourceConfig.NpcId == 0 then + result = result + enemySourceConfig.AddScore + end + result = result + enemyTargetConfig.AddScore + end + end + -- 成员 + local memberTargetConfig = nil + local memberSourceConfig = nil + for sourceId, targetId in pairs(self.MemberReplaceIdDic) do + memberTargetConfig = XReformConfigs.GetMemberTargetConfig(targetId) + if memberTargetConfig then + memberSourceConfig = XReformConfigs.GetMemberSourceConfig(sourceId) + if memberSourceConfig.RobotId == 0 then + result = result - memberSourceConfig.SubScore + end + result = result - memberTargetConfig.SubScore + end + end + -- 加成 + local buffConfig = nil + for _, buffId in ipairs(self.BuffIds) do + buffConfig = XReformConfigs.GetBuffConfig(buffId) + result = result - buffConfig.SubScore + end + -- 环境 + local envConfig = nil + for _, envId in ipairs(self.EnvIds) do + envConfig = XReformConfigs.GetEnvironmentConfig(envId) + result = result + envConfig.AddScore + end + self.ChallengeScore = result +end + +function XReformEvolvableStage:GetBuffIds() + return self.BuffIds +end + +function XReformEvolvableStage:GetEnvIds() + return self.EnvIds +end + +function XReformEvolvableStage:GetDifficulty() + -- 因为配置表从0开始,为了匹配lua下标特意+1 + return self.Config.Diff + 1 +end + +function XReformEvolvableStage:GetChallengeScore() + return self.ChallengeScore +end + +function XReformEvolvableStage:GetEvolvableGroupByType(groupType) + return self.EvolvableGroupDic[groupType] +end + +function XReformEvolvableStage:GetDefaultFirstGroupType() + local result = {} + for _, groupType in pairs(XReformConfigs.EvolvableGroupType) do + if self:GetEvolvableGroupByType(groupType) then + table.insert(result, groupType) + end + end + table.sort(result, function(groupTypeA, groupTypeB) + return XReformConfigs.GetGroupTypeSortWeight(groupTypeA) < XReformConfigs.GetGroupTypeSortWeight(groupTypeB) + end) + return result[1] +end + +function XReformEvolvableStage:GetMaxScore() + return self.MaxScore +end + +function XReformEvolvableStage:GetName() + return CS.XTextManager.GetText("ReformEvolvableStageName" .. self.Config.Diff) +end + +--######################## 私有方法 ######################## + +function XReformEvolvableStage:InitEnemyGroup() + local enemyGroupConfig = XReformConfigs.GetEnemyGroupConfig(self.Config.ReformEnemy) + local enemyGroup = nil + if enemyGroupConfig then + enemyGroup = XReformEnemyGroup.New(enemyGroupConfig) + self.EvolvableGroupDic[XReformConfigs.EvolvableGroupType.Enemy] = enemyGroup + end +end + +function XReformEvolvableStage:InitMemberGroup() + local memberGroupConfig = XReformConfigs.GetMemberGroupConfig(self.Config.ReformMember) + local memberGroup = nil + if memberGroupConfig then + memberGroup = XReformMemberGroup.New(memberGroupConfig) + self.EvolvableGroupDic[XReformConfigs.EvolvableGroupType.Member] = memberGroup + end +end + +function XReformEvolvableStage:InitEnvironmentGroup() + local environmentGroupConfig = XReformConfigs.GetEnvironmentGroupConfig(self.Config.ReformEnv) + local environmentGroup = nil + if environmentGroupConfig then + environmentGroup = XReformEnvironmentGroup.New(environmentGroupConfig) + self.EvolvableGroupDic[XReformConfigs.EvolvableGroupType.Environment] = environmentGroup + end +end + +function XReformEvolvableStage:InitBuffGroup() + local buffGroupConfig = XReformConfigs.GetBuffGroupConfig(self.Config.ReformBuff) + local buffGroup = nil + if buffGroupConfig then + buffGroup = XReformBuffGroup.New(buffGroupConfig) + self.EvolvableGroupDic[XReformConfigs.EvolvableGroupType.Buff] = buffGroup + end +end + +return XReformEvolvableStage \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XRobot/XRobot.lua b/Resources/Scripts/XEntity/XRobot/XRobot.lua new file mode 100644 index 00000000..0784be9d --- /dev/null +++ b/Resources/Scripts/XEntity/XRobot/XRobot.lua @@ -0,0 +1,452 @@ +local type = type +local tonumber = tonumber +local mathFloor = math.floor +local stringSplit = string.Split +local tableInsert = table.insert +local XCharacterViewModel = require("XEntity/XCharacter/XCharacterViewModel") +local XWeaponViewModel = require("XEntity/XEquip/XWeaponViewModel") +local XAwarenessViewModel = require("XEntity/XEquip/XAwarenessViewModel") +local XPartner = require("XEntity/XPartner/XPartner") +local XPartnerMainSkillGroup = require("XEntity/XPartner/XPartnerMainSkillGroup") +local XRobot = XClass(nil, "XRobot") + +local Default = { + Id = 0, + Ability = 0, + CharacterId = 0, + + Character = {}, + Equips = {}, + Partner = {}, + Attribs = {}, + NpcData = {}, +} + +function XRobot:Ctor(id) + for key, value in pairs(Default) do + if type(value) == "table" then + self[key] = {} + else + self[key] = value + end + end + + self.Id = id + -- XCharacterViewModel + self.CharacterViewModel = nil + -- XWeaponViewModel + self.WeaponViewModel = nil + -- XAwarenessViewModel dic + self.AwarenessViewModelDic = nil + self:Init() +end + +function XRobot:Init() + self:InitBase() + self:InitCharacter() + self:InitEquips() + self:InitPartner() + self:UpdateAttribs() + self:UpdateAbility() +end + +function XRobot:InitBase() + local robotId = self.Id + local robotCfg = XRobotManager.GetRobotTemplate(robotId) + + self.CharacterId = robotCfg.CharacterId +end + +function XRobot:InitCharacter() + local robotId = self.Id + local robotCfg = XRobotManager.GetRobotTemplate(robotId) + + self.Character = { + Id = robotCfg.CharacterId, + Quality = robotCfg.CharacterQuality, + Level = robotCfg.CharacterLevel, + Grade = robotCfg.CharacterGrade, + Star = robotCfg.CharacterStar, + SkillList = self:GenarateRobotSkillList(), + } +end + +function XRobot:InitEquips() + local equips = {} + + local robotId = self.Id + local robotCfg = XRobotManager.GetRobotTemplate(robotId) + + --武器 + if XTool.IsNumberValid(robotCfg.WeaponId) then + local weapon = { + TemplateId = robotCfg.WeaponId, + Level = robotCfg.WeaponLevel, + Breakthrough = robotCfg.WeaponBeakThrough, + ResonanceInfo = self:GenarateRobotEquipResonanceInfo(), + } + tableInsert(equips, weapon) + end + + --意识 + for _, pos in pairs(XEquipConfig.EquipSite.Awareness) do + local equipId = robotCfg.WaferId[pos] + + if XTool.IsNumberValid(equipId) then + local newAware = { + TemplateId = equipId, + Level = robotCfg.WaferLevel[pos], + Breakthrough = robotCfg.WaferBreakThrough[pos], + ResonanceInfo = self:GenarateRobotEquipResonanceInfo(pos), + AwakeSlotList = self:GenarateRobotAwakeSlotList(pos), + __SlotPos = pos, + } + tableInsert(equips, newAware) + end + end + + self.Equips = equips +end + +local CreatePartnerSkillData = function(robotPartnerCfg, charId)--未配技能置项均为默认值 + local skillList = {} + local unlockSkillGroup = {} + local mainSkillGroup = robotPartnerCfg.MainSkillGroup + local mainskill = XPartnerMainSkillGroup.New(robotPartnerCfg.MainSkillGroup) + local charElement = XCharacterConfigs.GetCharacterElement(charId) + local mainskillId = mainskill:GetSkillIdByElement(charElement) + + local tmpData = { + Type = XPartnerConfigs.SkillType.MainSkill, + Level = robotPartnerCfg.MainSkillLevel, + IsWear = true, + Id = mainskillId + } + table.insert(skillList, tmpData) + table.insert(unlockSkillGroup, mainskillId) + + for index, skillId in pairs(robotPartnerCfg.PassiveSkillId) do + local tmpData = { + Type = XPartnerConfigs.SkillType.PassiveSkill, + Level = robotPartnerCfg.PassiveSkillLevel[index] or 1, + IsWear = true, + Id = skillId + } + table.insert(skillList, tmpData) + end + + return skillList, unlockSkillGroup +end + +function XRobot:InitPartner() + local robotId = self.Id + local robotCfg = XRobotManager.GetRobotTemplate(robotId) + + if robotCfg.RobotPartnerId and robotCfg.RobotPartnerId > 0 then + local robotPartnerCfg = XRobotManager.GetRobotPartnerTemplate(robotCfg.RobotPartnerId) + + self.Partner = XPartner.New(robotCfg.RobotPartnerId, robotPartnerCfg.PartnerId, true) + local skillList, unlockSkillGroup = CreatePartnerSkillData(robotPartnerCfg, robotCfg.CharacterId) + local tmpData = { + CharacterId = robotCfg.CharacterId, + Level = robotPartnerCfg.Level, + BreakThrough = robotPartnerCfg.BreakThrough, + Quality = robotPartnerCfg.Quality, + StarSchedule = robotPartnerCfg.StarSchedule, + SkillList = skillList, + UnlockSkillGroup = unlockSkillGroup, + } + + self.Partner:UpdateData(tmpData) + end +end + +function XRobot:UpdateAttribs() + local npcData = self:GetNpcData() + self.Attribs = XAttribManager.GetNpcAttribs(npcData) +end + +function XRobot:UpdateAbility() + local robotId = self.Id + local characterId = self.CharacterId + local npcData = self:GetNpcData() + + --属性战力 + local baseAbility = XAttribManager.GetAttribAbility(self.Attribs) or 0 + + --构建机器人技能数据 + local skillData = XFightCharacterManager.GetCharSkillLevelMap(npcData) + local skillAbility = XDataCenter.CharacterManager.GetSkillAbility(skillData) + + --装备共鸣战力 + local resonanceSkillLevel = XFightCharacterManager.GetResonanceSkillLevelMap(npcData) + local resonanceSkillAbility = XDataCenter.CharacterManager.GetResonanceSkillAbility(resonanceSkillLevel, skillData) + + --装备技能战力 + local equipAbility = XDataCenter.EquipManager.GetEquipSkillAbilityOther(self.Character, self.Equips) + + --伙伴战力 + local partnerAbility = not XTool.IsTableEmpty(self.Partner) and XDataCenter.PartnerManager.GetCarryPartnerAbility(self.Partner) or 0 + + self.Ability = mathFloor(baseAbility + skillAbility + resonanceSkillAbility + equipAbility + partnerAbility) +end +function XRobot:GetConfig() + return XRobotManager.GetRobotTemplate(self.Id) +end + +------------属性生成 begin---------------- +--武器/意识共鸣列表 +function XRobot:GenarateRobotEquipResonanceInfo(pos) + local resonanceList = {} + + local robotId = self.Id + local config = XRobotManager.GetRobotTemplate(robotId) + + local configResonance, configResonanceType + if pos then + configResonanceType = config.WaferResonanceType[pos] + configResonance = config.WaferResonance[pos] + else + configResonanceType = config.WeaponResonanceType + configResonance = config.WeaponResonance + end + + local templateIdList = stringSplit(configResonance) + local resonanceTypeList = stringSplit(configResonanceType) + + for slot, templateId in pairs(templateIdList) do + templateId = tonumber(templateId) + local resonanceType = tonumber(resonanceTypeList[slot]) + + if not XTool.IsNumberValid(templateId) + or not XTool.IsNumberValid(resonanceType) + then + local path = XRobotManager.GetConfigPath() + XLog.Error("XRobot:GenarateRobotEquipResonanceInfo error: 机器人共鸣类型(WaferResonanceType)与共鸣技能Id(WaferResonance)不匹配, robotId: " .. robotId .. ", path: " .. path) + break + end + + local resonanceInfo = { + Slot = slot, + Type = resonanceType, + CharacterId = config.CharacterId, + TemplateId = templateId, + } + tableInsert(resonanceList, resonanceInfo) + end + + return resonanceList +end + +--意识觉醒列表 +function XRobot:GenarateRobotAwakeSlotList(pos) + local awakenSlotList = {} + + local robotId = self.Id + local config = XRobotManager.GetRobotTemplate(robotId) + + local waferAwekenCount = config.WaferAwakeCount[pos] + for slot = 1, waferAwekenCount do + tableInsert(awakenSlotList, slot) + end + + return awakenSlotList +end + +--技能列表 +--@param needMaxMin:是否要读取适用技能等级上下限 +function XRobot:GenarateRobotSkillList() + local skillList = {} + + local robotId = self.Id + local config = XRobotManager.GetRobotTemplate(robotId) + local removeDic = XRobotManager.GetRobotSkillRemoveDic(robotId) + local characterId = XRobotManager.GetCharacterId(robotId) + local robotSkillLevel = config.SkillLevel + + local skillDic = XCharacterConfigs.GetChracterSkillPosToGroupIdDic(characterId) + for _, skillGroup in pairs(skillDic) do + for _, skillGroupId in pairs(skillGroup) do + local skillIds = XCharacterConfigs.GetGroupSkillIdsByGroupId(skillGroupId) + + local skillId = skillIds[1] + if XTool.IsNumberValid(skillId) + and not removeDic[skillId] then + local skillInfo = { + Id = skillId, + Level = XCharacterConfigs.ClampSubSkillLeveByLevel(skillId, robotSkillLevel), + } + tableInsert(skillList, skillInfo) + end + end + end + + return skillList +end +------------属性生成 end---------------- +------------外部Setter接口(需调用后XRobotManager.GetRobotTemp再使用) begin---------------- +function XRobot:SetEquips(equips) + self.Equips = equips + + self:UpdateAttribs() + self:UpdateAbility() +end + +function XRobot:SetPartner(partner) + self.Partner = partner + + self:UpdateAbility() +end +------------外部Setter接口(需调用后XRobotManager.GetRobotTemp再使用) end---------------- +------------外部Getter接口 begin---------------- +function XRobot:GetNpcData() + local npcData = self.NpcData + + if XTool.IsTableEmpty(npcData) then + npcData = { + Character = self.Character, + Equips = self.Equips, + } + self.NpcData = npcData + end + + return npcData +end + +function XRobot:GetAtrributes() + return self.Attribs +end + +function XRobot:GetAbility() + return self.Ability or 0 +end + +--生成装备共鸣增加额外属性列表(Debug调试用) +function XRobot:ConstructResonanceAbilityList() + local list = {} + + for _, equip in pairs(self.Equips) do + local infoList = equip.ResonanceInfo + if not XTool.IsTableEmpty(infoList) then + for _, info in pairs(infoList) do + if tonumber(info.Type) == tonumber(XEquipConfig.EquipResonanceType.Attrib) then + local _, attrs = XAttribManager.GetAttribGroupTemplate(info.TemplateId) + tableInsert(list, { + EquipId = equip.Id, + Site = XDataCenter.EquipManager.GetEquipSiteByEquipData(equip), + Slot = info.Slot, + Attr = attrs, + }) + end + end + end + end + + return list +end + +--生成装备觉醒(超频)增加额外属性列表(Debug调试用) +function XRobot:ConstructAwakenAbilityList() + local list = {} + + for _, equip in pairs(self.Equips) do + local infoList = equip.AwakeSlotList + if not XTool.IsTableEmpty(infoList) then + local template = XEquipConfig.GetEquipAwakeCfg(equip.TemplateId) + for _, slot in pairs(infoList) do + local attribId = template.AttribId[slot] + local _, attrs = XAttribManager.GetAttribByAttribId(attribId) + tableInsert(list, { + EquipId = equip.Id, + Site = XDataCenter.EquipManager.GetEquipSiteByEquipData(equip), + Slot = slot, + Attr = attrs, + }) + end + end + end + + return list +end + +function XRobot:GetSkillLevelDic(forDisplay) + if forDisplay and (not self.Character.DisplaySkillList) then + self.Character.DisplaySkillList = self:GenarateRobotSkillList() + end + local skillLevelDic = {} + for _, skillData in pairs(forDisplay and self.Character.DisplaySkillList or self.Character.SkillList) do + skillLevelDic[skillData.Id] = skillData.Level + end + return skillLevelDic +end + +function XRobot:GetPartner() + if self.Partner ~= nil and next(self.Partner) == nil then + return nil + end + return self.Partner +end + +-- 优先获取展示的机器人战力 +function XRobot:GetAbilityWithCheckShowAbility() + local ability = XRobotManager.GetRobotShowAbility(self.Id) + if XTool.IsNumberValid(ability) then + return ability + end + return self:GetAbility() +end + +------------外部Getter接口 end---------------- +------------ 视图数据 begin---------------- +function XRobot:GetCharacterViewModel() + if self.CharacterViewModel == nil then + local robotConfig = XRobotManager.GetRobotTemplate(self.Id) + self.CharacterViewModel = XCharacterViewModel.New(robotConfig.CharacterId) + self.CharacterViewModel:UpdateWithData(self.Character) + self.CharacterViewModel:UpdateAbility(self:GetAbilityWithCheckShowAbility()) + self.CharacterViewModel:UpdateFashionId(robotConfig.FashionId) + self.CharacterViewModel:UpdateLiberateLv(robotConfig.LiberateLv) + self.CharacterViewModel:UpdateSourceEntityId(self.Id) + end + return self.CharacterViewModel +end + +function XRobot:GetWeaponViewModel() + if self.WeaponViewModel == nil then + local templateId = nil + for _, euqipData in pairs(self.Equips) do + templateId = euqipData.TemplateId + if XDataCenter.EquipManager.IsClassifyEqualByTemplateId(templateId, XEquipConfig.Classify.Weapon) then + self.WeaponViewModel = XWeaponViewModel.New(templateId) + self.WeaponViewModel:UpdateWithData(euqipData) + break + end + end + end + return self.WeaponViewModel +end + +function XRobot:GetAwarenessViewModelDic() + if self.AwarenessViewModelDic == nil then + self.AwarenessViewModelDic = {} + local templateId = nil + for _, euqipData in pairs(self.Equips) do + templateId = euqipData.TemplateId + if XDataCenter.EquipManager.IsClassifyEqualByTemplateId(templateId, XEquipConfig.Classify.Awareness) then + self.AwarenessViewModelDic[euqipData.__SlotPos] = XAwarenessViewModel.New(templateId) + self.AwarenessViewModelDic[euqipData.__SlotPos]:UpdateWithData(euqipData) + end + end + end + return self.AwarenessViewModelDic +end + +function XRobot:GetEquipViewModels() + local result = { self:GetWeaponViewModel() } + for _, v in pairs(self:GetAwarenessViewModelDic()) do + table.insert(result, v) + end + return result +end +------------ 视图数据 end---------------- +return XRobot \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XRpgMakerGame/Object/XRpgMakerGameBlock.lua b/Resources/Scripts/XEntity/XRpgMakerGame/Object/XRpgMakerGameBlock.lua new file mode 100644 index 00000000..61cc56d2 --- /dev/null +++ b/Resources/Scripts/XEntity/XRpgMakerGame/Object/XRpgMakerGameBlock.lua @@ -0,0 +1,23 @@ +local XRpgMakerGameObject = require("XEntity/XRpgMakerGame/Object/XRpgMakerGameObject") + +local type = type +local pairs = pairs + +local Default = { + _BlockStatus = 0, --状态,1阻挡,0不阻挡 +} + +--阻挡物对象 +local XRpgMakerGameBlock = XClass(XRpgMakerGameObject, "XRpgMakerGameBlock") + +function XRpgMakerGameBlock:Ctor(id) + for key, value in pairs(Default) do + if type(value) == "table" then + self[key] = {} + else + self[key] = value + end + end +end + +return XRpgMakerGameBlock \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XRpgMakerGame/Object/XRpgMakerGameCube.lua b/Resources/Scripts/XEntity/XRpgMakerGame/Object/XRpgMakerGameCube.lua new file mode 100644 index 00000000..86577999 --- /dev/null +++ b/Resources/Scripts/XEntity/XRpgMakerGame/Object/XRpgMakerGameCube.lua @@ -0,0 +1,21 @@ +local XRpgMakerGameObject = require("XEntity/XRpgMakerGame/Object/XRpgMakerGameObject") + +local type = type +local pairs = pairs +local Vector3 = CS.UnityEngine.Vector3 + +--地图格子对象 +local XRpgMakerGameCube = XClass(XRpgMakerGameObject, "XRpgMakerGameCube") + +function XRpgMakerGameCube:Ctor(id, gameObject) + +end + +--获得格子对象上方中心的坐标 +function XRpgMakerGameCube:GetGameObjUpCenterPosition() + local transform = self:GetTransform() + local centerPoint = XUiHelper.TryGetComponent(transform, "CenterPoint") + return centerPoint and centerPoint.transform.position +end + +return XRpgMakerGameCube \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XRpgMakerGame/Object/XRpgMakerGameEndPoint.lua b/Resources/Scripts/XEntity/XRpgMakerGame/Object/XRpgMakerGameEndPoint.lua new file mode 100644 index 00000000..40307ed3 --- /dev/null +++ b/Resources/Scripts/XEntity/XRpgMakerGame/Object/XRpgMakerGameEndPoint.lua @@ -0,0 +1,71 @@ +local XRpgMakerGameObject = require("XEntity/XRpgMakerGame/Object/XRpgMakerGameObject") + +local type = type +local pairs = pairs + +local Default = { + _OpenStatus = 0, --状态,1开启,0关闭 +} + +--终点对象 +local XRpgMakerGameEndPoint = XClass(XRpgMakerGameObject, "XRpgMakerGameEndPoint") + +function XRpgMakerGameEndPoint:Ctor(id) + for key, value in pairs(Default) do + if type(value) == "table" then + self[key] = {} + else + self[key] = value + end + end +end + +function XRpgMakerGameEndPoint:InitData(mapId) + self.StatusIsChange = false --新的状态是否和旧的不同 + local endPointId = XRpgMakerGameConfigs.GetRpgMakerGameEndPointId(mapId) + local pointX = XRpgMakerGameConfigs.GetRpgMakerGameEndPointX(endPointId) + local pointY = XRpgMakerGameConfigs.GetRpgMakerGameEndPointY(endPointId) + local endPointType = XRpgMakerGameConfigs.GetRpgMakerGameEndPointType(endPointId) + + self:SetId(endPointId) + self:UpdatePosition({PositionX = pointX, PositionY = pointY}) + self:UpdateData({OpenStatus = endPointType}) +end + +function XRpgMakerGameEndPoint:UpdateData(data) + self:SetStatusIsChange(self._OpenStatus ~= data.OpenStatus) + self._OpenStatus = data.OpenStatus +end + +function XRpgMakerGameEndPoint:SetStatusIsChange(isChange) + self.StatusIsChange = isChange +end + +function XRpgMakerGameEndPoint:IsOpen() + return self._OpenStatus == XRpgMakerGameConfigs.XRpgMakerGameEndPointType.DefaultOpen +end + +function XRpgMakerGameEndPoint:EndPointOpen() + self:SetStatusIsChange(true) + self._OpenStatus = XRpgMakerGameConfigs.XRpgMakerGameEndPointType.DefaultOpen +end + +function XRpgMakerGameEndPoint:UpdateObjStatus() + self:PlayEndPointStatusChangeAction() +end + +function XRpgMakerGameEndPoint:PlayEndPointStatusChangeAction(action, cb) + local modelPath = self:IsOpen() and XRpgMakerGameConfigs.GetRpgMakerGameModelPath("GoldOpen") or XRpgMakerGameConfigs.GetRpgMakerGameModelPath("GoldClose") + local sceneObjRoot = self:GetGameObjModelRoot() + self:LoadModel(modelPath, sceneObjRoot) + + if self.StatusIsChange then + XSoundManager.PlaySoundByType(XSoundManager.UiBasicsMusic.RpgMakerGame_EndPointOpen, XSoundManager.SoundType.Sound) + end + + if cb then + cb() + end +end + +return XRpgMakerGameEndPoint \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XRpgMakerGame/Object/XRpgMakerGameGap.lua b/Resources/Scripts/XEntity/XRpgMakerGame/Object/XRpgMakerGameGap.lua new file mode 100644 index 00000000..2af55511 --- /dev/null +++ b/Resources/Scripts/XEntity/XRpgMakerGame/Object/XRpgMakerGameGap.lua @@ -0,0 +1,62 @@ +local XRpgMakerGameObject = require("XEntity/XRpgMakerGame/Object/XRpgMakerGameObject") + +local type = type +local pairs = pairs +local Vector3 = CS.UnityEngine.Vector3 +local LookRotation = CS.UnityEngine.Quaternion.LookRotation + +local Default = { + _BlockStatus = 0, --状态,1阻挡,0不阻挡 +} + +--缝隙对象 +local XRpgMakerGameGap = XClass(XRpgMakerGameObject, "XRpgMakerGameGap") + +function XRpgMakerGameGap:Ctor(id) + for key, value in pairs(Default) do + if type(value) == "table" then + self[key] = {} + else + self[key] = value + end + end +end + +--改变方向 +function XRpgMakerGameGap:ChangeDirectionAction(action, cb) + local transform = self:GetTransform() + if XTool.UObjIsNil(transform) then + return + end + + local gapId = self:GetId() + local x = XRpgMakerGameConfigs.GetRpgMakerGameGapX(gapId) + local y = XRpgMakerGameConfigs.GetRpgMakerGameGapY(gapId) + local cube = self:GetCubeObj(y, x) + local cubePosition = cube:GetGameObjUpCenterPosition() + local cubeSize = cube:GetGameObjSize() + + local objPosition = transform.position + local direction = action.Direction + local directionPos + if direction == XRpgMakerGameConfigs.RpgMakerGapDirection.GridLeft then + directionPos = objPosition - Vector3(cubeSize.x / 2, 0, 0) + elseif direction == XRpgMakerGameConfigs.RpgMakerGapDirection.GridRight then + directionPos = objPosition + Vector3(cubeSize.x / 2, 0, 0) + elseif direction == XRpgMakerGameConfigs.RpgMakerGapDirection.GridTop then + directionPos = objPosition + Vector3(0, 0, cubeSize.z / 2) + elseif direction == XRpgMakerGameConfigs.RpgMakerGapDirection.GridBottom then + directionPos = objPosition - Vector3(0, 0, cubeSize.z / 2) + end + + local transform = self:GetTransform() + local lookRotation = LookRotation(directionPos - objPosition) + self:SetGameObjectRotation(lookRotation) + self:SetGameObjectPosition(directionPos) + + if cb then + cb() + end +end + +return XRpgMakerGameGap \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XRpgMakerGame/Object/XRpgMakerGameMonsterData.lua b/Resources/Scripts/XEntity/XRpgMakerGame/Object/XRpgMakerGameMonsterData.lua new file mode 100644 index 00000000..c46a3b93 --- /dev/null +++ b/Resources/Scripts/XEntity/XRpgMakerGame/Object/XRpgMakerGameMonsterData.lua @@ -0,0 +1,340 @@ +local XRpgMakerGameObject = require("XEntity/XRpgMakerGame/Object/XRpgMakerGameObject") +local XRpgMakerGameMonsterPatrolLine = require("XEntity/XRpgMakerGame/Object/XRpgMakerGameMonsterPatrolLine") + +local type = type +local pairs = pairs +local tableInsert = table.insert +local IsNumberValid = XTool.IsNumberValid +local CSXResourceManagerLoad = CS.XResourceManager.Load +local Vector3 = CS.UnityEngine.Vector3 +local _ViewFront = XRpgMakerGameConfigs.XRpgMakerGameMonsterViewAreaType.ViewFront --怪物的前方 +local _ViewBack = XRpgMakerGameConfigs.XRpgMakerGameMonsterViewAreaType.ViewBack --怪物的后面 +local _ViewLeft = XRpgMakerGameConfigs.XRpgMakerGameMonsterViewAreaType.ViewLeft --怪物的左边 +local _ViewRight = XRpgMakerGameConfigs.XRpgMakerGameMonsterViewAreaType.ViewRight --怪物的右边 + +local DefaultHp = 100 + +local Default = { + _CurrentHp = 100, --当前血量 + _FaceDirection = 0, --朝向 +} + +--往某个方向设置移动路线特效 +local MoveLineEffectType = { + Horizontal = 1, --往水平方向设置特效 + Vertical = 2, --往垂直方向设置特效 +} + +--怪物对象 +local XRpgMakerGameMonsterData = XClass(XRpgMakerGameObject, "XRpgMakerGameMonsterData") + +function XRpgMakerGameMonsterData:Ctor(id) + for key, value in pairs(Default) do + if type(value) == "table" then + self[key] = {} + else + self[key] = value + end + end + self.PatrolLineObjs = {} --场景中生成的移动路线对象 + self.ViewAreaModels = {} --场景中生成的视野范围模型 + self:InitData() +end + +function XRpgMakerGameMonsterData:Dispose() + self:RemovePatrolLineObjs() + self:RemoveViewAreaModels() + XRpgMakerGameMonsterData.Super.Dispose(self) +end + +function XRpgMakerGameMonsterData:RemovePatrolLineObjs() + for _, v in pairs(self.PatrolLineObjs) do + v:Dispose() + end + self.PatrolLineObjs = {} +end + +function XRpgMakerGameMonsterData:RemoveViewAreaModels() + for _, v in pairs(self.ViewAreaModels) do + CS.UnityEngine.GameObject.Destroy(v) + end + self.ViewAreaModels = {} +end + +function XRpgMakerGameMonsterData:InitData() + local monsterId = self:GetId() + local pointX = XRpgMakerGameConfigs.GetRpgMakerGameMonsterX(monsterId) + local pointY = XRpgMakerGameConfigs.GetRpgMakerGameMonsterY(monsterId) + local direction = XRpgMakerGameConfigs.GetRpgMakerGameMonsterDirection(monsterId) + self:UpdatePosition({PositionX = pointX, PositionY = pointY}) + self:SetFaceDirection(direction) + self:SetCurrentHp(DefaultHp) + + self:RemovePatrolLineObjs() + self:RemoveViewAreaModels() +end + +function XRpgMakerGameMonsterData:UpdateData(data) + self._CurrentHp = data.CurrentHp + self._FaceDirection = data.FaceDirection + self:UpdatePosition(data) +end + +function XRpgMakerGameMonsterData:SetCurrentHp(hp) + self._CurrentHp = hp +end + +function XRpgMakerGameMonsterData:SetFaceDirection(faceDirection) + self._FaceDirection = faceDirection +end + +function XRpgMakerGameMonsterData:GetFaceDirection() + return self._FaceDirection +end + +function XRpgMakerGameMonsterData:GetCurrentHp() + return self._CurrentHp +end + +function XRpgMakerGameMonsterData:IsDeath() + local currentHp = self:GetCurrentHp() + return currentHp <= 0 +end + +function XRpgMakerGameMonsterData:Die() + self:SetCurrentHp(0) +end + +--设置视野范围 +function XRpgMakerGameMonsterData:SetGameObjectViewArea() + self:RemoveViewAreaModels() + + if self:IsDeath() then + return + end + + local transform = self:GetTransform() + if XTool.UObjIsNil(transform) then + return + end + + local modelKey = "ViewArea" + local effectPath = XRpgMakerGameConfigs.GetRpgMakerGameModelPath(modelKey) + local resource = CSXResourceManagerLoad(effectPath) + + if resource == nil or not resource.Asset then + XLog.Error(string.format("XRpgMakerGameMonsterData加载视野范围特效:%s失败", effectPath)) + return + end + + local monsterId = self:GetId() + local viewFront = XRpgMakerGameConfigs.GetRpgMakerGameMonsterViewFront(monsterId) + local viewBack = XRpgMakerGameConfigs.GetRpgMakerGameMonsterViewBack(monsterId) + local viewLeft = XRpgMakerGameConfigs.GetRpgMakerGameMonsterViewLeft(monsterId) + local viewRight = XRpgMakerGameConfigs.GetRpgMakerGameMonsterViewRight(monsterId) + local direction = self:GetFaceDirection() + local viewAreaEffectPos = self:GetViewAreaEffectPos() + local asset = resource.Asset + local model + local cubeTransform + local cubeUpCenterPosition + local row, col + + if IsNumberValid(viewFront) then + local currentScene = XDataCenter.RpgMakerGameManager.GetCurrentScene() + row, col = viewAreaEffectPos[_ViewFront].row, viewAreaEffectPos[_ViewFront].col + cubeTransform = self:GetCubeTransform(row, col) + if cubeTransform then + cubeUpCenterPosition = self:GetCubeUpCenterPosition(row, col) + model = self:LoadEffect(asset, cubeUpCenterPosition, cubeTransform) + tableInsert(self.ViewAreaModels, model) + end + end + + if IsNumberValid(viewBack) then + row, col = viewAreaEffectPos[_ViewBack].row, viewAreaEffectPos[_ViewBack].col + cubeTransform = self:GetCubeTransform(row, col) + if cubeTransform then + cubeUpCenterPosition = self:GetCubeUpCenterPosition(row, col) + model = self:LoadEffect(asset, cubeUpCenterPosition, cubeTransform) + tableInsert(self.ViewAreaModels, model) + end + end + + if IsNumberValid(viewLeft) then + row, col = viewAreaEffectPos[_ViewLeft].row, viewAreaEffectPos[_ViewLeft].col + cubeTransform = self:GetCubeTransform(row, col) + if cubeTransform then + cubeUpCenterPosition = self:GetCubeUpCenterPosition(row, col) + model = self:LoadEffect(asset, cubeUpCenterPosition, cubeTransform) + tableInsert(self.ViewAreaModels, model) + end + end + + if IsNumberValid(viewRight) then + row, col = viewAreaEffectPos[_ViewRight].row, viewAreaEffectPos[_ViewRight].col + cubeTransform = self:GetCubeTransform(row, col) + if cubeTransform then + cubeUpCenterPosition = self:GetCubeUpCenterPosition(row, col) + model = self:LoadEffect(asset, cubeUpCenterPosition, cubeTransform) + tableInsert(self.ViewAreaModels, model) + end + end +end + +function XRpgMakerGameMonsterData:GetViewAreaEffectPos() + local direction = self:GetFaceDirection() + local positionX = self:GetPositionX() + local positionY = self:GetPositionY() + local intervalPos = 1 --间隔多少位置设置 + + local viewAreaPos = {} + if direction == XRpgMakerGameConfigs.RpgMakerGameMoveDirection.MoveLeft then + viewAreaPos[_ViewFront] = {row = positionY, col = positionX - intervalPos} + viewAreaPos[_ViewBack] = {row = positionY, col = positionX + intervalPos} + viewAreaPos[_ViewLeft] = {row = positionY - intervalPos, col = positionX} + viewAreaPos[_ViewRight] = {row = positionY + intervalPos, col = positionX} + + elseif direction == XRpgMakerGameConfigs.RpgMakerGameMoveDirection.MoveRight then + viewAreaPos[_ViewFront] = {row = positionY, col = positionX + intervalPos} + viewAreaPos[_ViewBack] = {row = positionY, col = positionX - intervalPos} + viewAreaPos[_ViewLeft] = {row = positionY + intervalPos, col = positionX} + viewAreaPos[_ViewRight] = {row = positionY - intervalPos, col = positionX} + + elseif direction == XRpgMakerGameConfigs.RpgMakerGameMoveDirection.MoveUp then + viewAreaPos[_ViewFront] = {row = positionY + intervalPos, col = positionX} + viewAreaPos[_ViewBack] = {row = positionY - intervalPos, col = positionX} + viewAreaPos[_ViewLeft] = {row = positionY, col = positionX - intervalPos} + viewAreaPos[_ViewRight] = {row = positionY, col = positionX + intervalPos} + + elseif direction == XRpgMakerGameConfigs.RpgMakerGameMoveDirection.MoveDown then + viewAreaPos[_ViewFront] = {row = positionY - intervalPos, col = positionX} + viewAreaPos[_ViewBack] = {row = positionY + intervalPos, col = positionX} + viewAreaPos[_ViewLeft] = {row = positionY, col = positionX - intervalPos} + viewAreaPos[_ViewRight] = {row = positionY, col = positionX + intervalPos} + end + return viewAreaPos +end + +function XRpgMakerGameMonsterData:UpdateObjPosAndDirection() + local transform = self:GetTransform() + if XTool.UObjIsNil(transform) then + return + end + + local x = self:GetPositionX() + local y = self:GetPositionY() + local direction = self:GetFaceDirection() + local cubePosition = self:GetCubeUpCenterPosition(y, x) + cubePosition.y = transform.position.y + self:SetGameObjectPosition(cubePosition) + self:ChangeDirectionAction({Direction = direction}) +end + +--设置下一回合的移动路线 +function XRpgMakerGameMonsterData:SetMoveLine(action) + self:RemovePatrolLineObjs() + + local direction = action.Direction + local startPosition = action.StartPosition + local endPosition = action.EndPosition + + local moveLinePath = XRpgMakerGameConfigs.GetRpgMakerGameModelPath("MoveLine") + + local horizontal = 0 --往水平方向设置特效 + local vertical = 0 --往垂直方向设置特效 + local intervalPos = 1 --间隔多少位置设置 + + if direction == XRpgMakerGameConfigs.RpgMakerGameMoveDirection.MoveLeft then + horizontal = -intervalPos + elseif direction == XRpgMakerGameConfigs.RpgMakerGameMoveDirection.MoveRight then + horizontal = intervalPos + elseif direction == XRpgMakerGameConfigs.RpgMakerGameMoveDirection.MoveUp then + vertical = intervalPos + elseif direction == XRpgMakerGameConfigs.RpgMakerGameMoveDirection.MoveDown then + vertical = -intervalPos + end + + if XTool.IsNumberValid(horizontal) then + self:LoadMoveLineEffect(horizontal, MoveLineEffectType.Horizontal, startPosition, endPosition, direction) + elseif XTool.IsNumberValid(vertical) then + self:LoadMoveLineEffect(vertical, MoveLineEffectType.Vertical, startPosition, endPosition, direction) + end +end + +function XRpgMakerGameMonsterData:LoadMoveLineEffect(num, moveLineEffectType, startPosition, endPosition, direction) + local moveLinePath = XRpgMakerGameConfigs.GetRpgMakerGameModelPath("MoveLine") + local startPosX = startPosition.PositionX + local startPosY = startPosition.PositionY + local endPosX = endPosition.PositionX + local endPosY = endPosition.PositionY + local cubeUpCenterPos + local patrolLineObj + + while true do + if startPosX == endPosX and startPosY == endPosY then + return + end + + if moveLineEffectType == MoveLineEffectType.Horizontal then + startPosX = startPosX + num + elseif moveLineEffectType == MoveLineEffectType.Vertical then + startPosY = startPosY + num + else + return + end + + cubeUpCenterPos = self:GetCubeUpCenterPosition(startPosY, startPosX) + if not cubeUpCenterPos then + return + end + + patrolLineObj = XRpgMakerGameMonsterPatrolLine.New() + patrolLineObj:LoadPatrolLine(moveLinePath, startPosX, startPosY, direction) + tableInsert(self.PatrolLineObjs, patrolLineObj) + end +end + +function XRpgMakerGameMonsterData:CheckLoadTriggerEndEffect() + local monsterId = self:GetId() + if not XRpgMakerGameConfigs.IsRpgMakerGameMonsterTriggerEnd(monsterId) then + return + end + + local effectPath = XRpgMakerGameConfigs.GetRpgMakerGameModelPath("MonsterTriggerEffect") + local resource = CSXResourceManagerLoad(effectPath) + if resource == nil or not resource.Asset then + XLog.Error(string.format("XRpgMakerGameMonsterData加载开启终点的指示特效:%s失败", effectPath)) + return + end + + local modelName = self:GetModelName() + local effectRootName = XRpgMakerGameConfigs.GetRpgMakerGameEffectRoot(modelName) + local transform = self:GetTransform() + local effectRoot = transform:FindTransform(effectRootName) + if XTool.UObjIsNil(effectRoot) then + XLog.Error(string.format("XRpgMakerGameObject:CheckLoadTriggerEndEffect error: 终点指示特效父节点找不到, effectRootName: %s,modelName:%s", effectRootName, modelName)) + return + end + + local asset = resource.Asset + local position = Vector3.zero + local effectObj = self:LoadEffect(asset, effectRoot.transform.position, effectRoot) +end + +--杀死玩家 +function XRpgMakerGameMonsterData:PlayKillPlayerAction(action, cb) + local cb = cb + self:PlayAtkAction(function() + local playerObj = XDataCenter.RpgMakerGameManager.GetPlayerObj() + playerObj:PlayBeAtkAction(cb) + end) +end + +--检查是否死亡并设置模型显示状态 +function XRpgMakerGameMonsterData:CheckIsDeath() + local isDeath = self:IsDeath() + self:SetActive(not isDeath) +end + +return XRpgMakerGameMonsterData \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XRpgMakerGame/Object/XRpgMakerGameMonsterPatrolLine.lua b/Resources/Scripts/XEntity/XRpgMakerGame/Object/XRpgMakerGameMonsterPatrolLine.lua new file mode 100644 index 00000000..c398b990 --- /dev/null +++ b/Resources/Scripts/XEntity/XRpgMakerGame/Object/XRpgMakerGameMonsterPatrolLine.lua @@ -0,0 +1,20 @@ +local XRpgMakerGameObject = require("XEntity/XRpgMakerGame/Object/XRpgMakerGameObject") + +local type = type +local pairs = pairs +local Vector3 = CS.UnityEngine.Vector3 + +--巡逻路线 +local XRpgMakerGameMonsterPatrolLine = XClass(XRpgMakerGameObject, "XRpgMakerGameMonsterPatrolLine") + +function XRpgMakerGameMonsterPatrolLine:LoadPatrolLine(modelPath, x, y, direction) + local cubeObj = self:GetCubeTransform(y, x) + self:LoadModel(modelPath, cubeObj) --特效绑定在cube上,绑定在怪物上会被改变旋转角度 + + local objPos = self:GetCubeUpCenterPosition(y, x) + self:SetGameObjectPosition(objPos) + + self:SetGameObjectLookRotation(direction) +end + +return XRpgMakerGameMonsterPatrolLine \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XRpgMakerGame/Object/XRpgMakerGameObject.lua b/Resources/Scripts/XEntity/XRpgMakerGame/Object/XRpgMakerGameObject.lua new file mode 100644 index 00000000..56145555 --- /dev/null +++ b/Resources/Scripts/XEntity/XRpgMakerGame/Object/XRpgMakerGameObject.lua @@ -0,0 +1,506 @@ +local XRpgMakerGamePosition = require("XEntity/XRpgMakerGame/XRpgMakerGamePosition") + +local type = type +local pairs = pairs +local Vector3 = CS.UnityEngine.Vector3 +local CSXScheduleManagerUnSchedule = XScheduleManager.UnSchedule +local LookRotation = CS.UnityEngine.Quaternion.LookRotation +local CSXResourceManagerLoad = CS.XResourceManager.Load + +local Default = { + _Id = 0, +} + +local MoveSpeed = CS.XGame.ClientConfig:GetInt("RpgMakeGameMoveSpeed") + +local XRpgMakerGameObject = XClass(XRpgMakerGamePosition, "XRpgMakerGameObject") + +function XRpgMakerGameObject:Ctor(id, gameObject) + for key, value in pairs(Default) do + if type(value) == "table" then + self[key] = {} + else + self[key] = value + end + end + + self._Id = id + self.Animator = nil --动画控制器 + self.ModelPath = nil --模型路径 + self.ModelRoot = nil --模型根节点 + self.ModelName = nil --模型名,作为key检索其他配置表用,可为nil + + if not XTool.UObjIsNil(gameObject) then + self:SetModel(gameObject) + end +end + +function XRpgMakerGameObject:Dispose() + if not XTool.UObjIsNil(self.BeAtkEffect) then + CS.UnityEngine.GameObject.Destroy(self.BeAtkEffect) + self.BeAtkEffect = nil + end + + if self.BeAtkResource then + self.BeAtkResource:Release() + self.BeAtkResource = nil + end + + if not XTool.UObjIsNil(self.GameObject) then + CS.UnityEngine.GameObject.Destroy(self.GameObject) + self.GameObject = nil + self.Transform = nil + end + + if self.ModelResource then + self.ModelResource:Release() + self.ModelResource = nil + end + + self.ModelPath = nil +end + +function XRpgMakerGameObject:SetId(id) + self._Id = id +end + +function XRpgMakerGameObject:GetId() + return self._Id +end + +--------------场景对象相关 begin---------------- +--移动 +function XRpgMakerGameObject:PlayMoveAction(action, cb) + local transform = self:GetTransform() + local startPosX = action.StartPosition.PositionX + local startPosY = action.StartPosition.PositionY + local endPosX = action.EndPosition.PositionX + local endPosY = action.EndPosition.PositionY + + local startCube = self:GetCubeObj(startPosY, startPosX) + local endCube = self:GetCubeObj(endPosY, endPosX) + local startCubePosition = startCube:GetGameObjUpCenterPosition() + local endCubePosition = endCube:GetGameObjUpCenterPosition() + local cubeDistance = CS.UnityEngine.Vector3.Distance(startCubePosition, endCubePosition) + local playActionTime = cubeDistance / MoveSpeed + + --计算播放音效的位置 + local distance = math.sqrt(XTool.MathPow((endPosY-startPosY), 2) + XTool.MathPow((endPosX - startPosX), 2)) + local playMoveSoundSpacePosition = distance > 0 and (endCubePosition - startCubePosition) / distance or Vector3(0, 0, 0) + local currPlayMoveSoundPosition = startCubePosition + playMoveSoundSpacePosition + + self:SetGameObjectPosition(startCubePosition) + + local moveX = endCubePosition.x - startCubePosition.x + local moveZ = endCubePosition.z - startCubePosition.z + + local gameObjPositionY = transform.position.y + + self:ChangeDirectionAction(action) + + local modelName = self:GetModelName() + local runAnima = XRpgMakerGameConfigs.GetRpgMakerGameRunAnimaName(modelName) + self:PlayAnima(runAnima) + + local movePositionX + local movePositionZ + local currPlayMoveSoundPositionX + local currPlayMoveSoundPositionZ + local tempCount = 1 + self.PlayMoveActionTimer = XUiHelper.Tween(playActionTime, function(f) + if XTool.UObjIsNil(transform) then + return + end + + movePositionX = startCubePosition.x + moveX * f + movePositionZ = startCubePosition.z + moveZ * f + self:SetGameObjectPosition(Vector3(movePositionX, gameObjPositionY, movePositionZ)) + + --保留2位小数 + movePositionX = movePositionX - movePositionX % 0.01 + movePositionZ = movePositionZ - movePositionZ % 0.01 + currPlayMoveSoundPositionX = currPlayMoveSoundPosition.x - currPlayMoveSoundPosition.x % 0.01 + currPlayMoveSoundPositionZ = currPlayMoveSoundPosition.z - currPlayMoveSoundPosition.z % 0.01 + --每移动一个格子播放一次音效 + if ((playMoveSoundSpacePosition.x > 0 or playMoveSoundSpacePosition.z > 0) and movePositionX >= currPlayMoveSoundPositionX and movePositionZ >= currPlayMoveSoundPositionZ) + or ((playMoveSoundSpacePosition.x < 0 or playMoveSoundSpacePosition.z < 0) and movePositionX <= currPlayMoveSoundPositionX and movePositionZ <= currPlayMoveSoundPositionZ) then + XSoundManager.PlaySoundByType(XSoundManager.UiBasicsMusic.RpgMakerGame_Move, XSoundManager.SoundType.Sound) + currPlayMoveSoundPosition = currPlayMoveSoundPosition + playMoveSoundSpacePosition + end + end, function () + self:StopPlayMoveActionTimer() + self:PlayStandAnima(function() + if cb then + cb() + end + end) + end) +end + +--isEnforceSetObjPos:是否强制设置场景对象的位置 +function XRpgMakerGameObject:StopPlayMoveActionTimer(isEnforceSetObjPos) + if isEnforceSetObjPos and self.PlayMoveActionTimer then + CSXScheduleManagerUnSchedule(self.PlayMoveActionTimer) + self.PlayMoveActionTimer = nil + end + + if isEnforceSetObjPos then + local x = self:GetPositionX() + local y = self:GetPositionY() + local transform = self:GetTransform() + local cube = self:GetCubeObj(y, x) + local cubePosition = cube:GetGameObjUpCenterPosition() + local gameObjPositionY = transform.position.y + self:SetGameObjectPosition(Vector3(cubePosition.x, gameObjPositionY, cubePosition.z)) + end +end + +--改变方向 +function XRpgMakerGameObject:ChangeDirectionAction(action, cb) + local transform = self:GetTransform() + if XTool.UObjIsNil(transform) then + return + end + + self:SetGameObjectLookRotation(action.Direction) + + if cb then + cb() + end +end + +--获得对应方向的坐标 +function XRpgMakerGameObject:GetDirectionPos(direction) + local transform = self:GetTransform() + if XTool.UObjIsNil(transform) then + return + end + + local objPosition = transform.position + local directionPos + if direction == XRpgMakerGameConfigs.RpgMakerGameMoveDirection.MoveLeft then + directionPos = objPosition + Vector3.left + elseif direction == XRpgMakerGameConfigs.RpgMakerGameMoveDirection.MoveRight then + directionPos = objPosition + Vector3.right + elseif direction == XRpgMakerGameConfigs.RpgMakerGameMoveDirection.MoveUp then + directionPos = objPosition + Vector3.forward + elseif direction == XRpgMakerGameConfigs.RpgMakerGameMoveDirection.MoveDown then + directionPos = objPosition + Vector3.back + end + return directionPos +end + +--加载模型 +function XRpgMakerGameObject:LoadModel(modelPath, root, modelName) + --记录旧模型位置 + local oldPos = self:GetGameObjPosition() + + self:Dispose() + + if not modelPath then + return + end + + self.ModelPath = modelPath + self.ModelRoot = root + self.ModelName = modelName + + local resource = self:ResourceManagerLoad(modelPath) + if not resource then + return + end + self.ModelResource = resource + + local model = CS.UnityEngine.Object.Instantiate(resource.Asset) + self:BindToRoot(model, root) + self:SetModel(model) + + if oldPos then + self:SetGameObjectPosition(oldPos) + end + + local meshFilter = model.transform:GetComponent("MeshFilter") + if not XTool.UObjIsNil(meshFilter) and meshFilter.mesh then + local mesh = meshFilter.mesh + --实例化出来的模型会静态合批,延迟重新设置(预制体tag改成Dynamic就好,等活动结束再删了这代码) + XScheduleManager.ScheduleOnce(function() + self:SetGameObjMesh(mesh) + end, 1) + end +end + +--加载特效 +function XRpgMakerGameObject:LoadEffect(asset, position, rootTransform) + local transform = rootTransform or self:GetTransform() + if XTool.UObjIsNil(transform) then + return + end + local model = CS.UnityEngine.Object.Instantiate(asset) + self:BindToRoot(model, transform) + + if position then + model.transform.position = position + end + + return model +end + +--设置动画控制器 +function XRpgMakerGameObject:SetAnimator(modelName, uiName) + local gameObject = self:GetGameObject() + if XTool.UObjIsNil(gameObject) then + return + end + + --加载controller + local controllerPath = XModelManager.GetUiControllerPath(modelName) + local runtimeController = CS.LoadHelper.LoadUiController(controllerPath, uiName) + self.Animator = gameObject.transform:GetComponent("Animator") + self.Animator.runtimeAnimatorController = runtimeController +end + +--播放动画 +--animaName:动画名 +--callBack:播放成功回调 +--finishCallBack:播放动画结束后或播放失败回调 +function XRpgMakerGameObject:PlayAnima(animaName, callBack, finishCallBack) + local animator = self:GetAnimator() + local gameObj = self:GetGameObject() + XModelManager.PlayAnima(gameObj, animator, animaName, nil, callBack, finishCallBack, finishCallBack) +end + +function XRpgMakerGameObject:BindToRoot(model, root) + model.transform:SetParent(root) + model.transform.localPosition = CS.UnityEngine.Vector3.zero + model.transform.localEulerAngles = CS.UnityEngine.Vector3.zero + model.transform.localScale = CS.UnityEngine.Vector3.one +end + +function XRpgMakerGameObject:SetModel(go) + self.GameObject = go + self.Transform = go.transform + + self:OnLoadComplete() +end + +function XRpgMakerGameObject:GetGameObject() + return self.GameObject +end + +function XRpgMakerGameObject:GetTransform() + return self.Transform +end + +function XRpgMakerGameObject:GetAnimator() + return self.Animator +end + +function XRpgMakerGameObject:GetModelName() + return self.ModelName or "" +end + +--设置场景对象位置 +function XRpgMakerGameObject:SetGameObjectPosition(position) + local transform = self:GetTransform() + if XTool.UObjIsNil(transform) then + return + end + + if not position then + XLog.Error("XRpgMakerGameObject:SetGameObjectPosition设置场景对象位置错误,position为nil") + return + end + + local xOffset = 0 + local yOffset = 0 + local zOffset = 0 + local modelName = self:GetModelName() + if not string.IsNilOrEmpty(modelName) then + xOffset = XRpgMakerGameConfigs.GetRpgMakerGameXOffSet(modelName) + yOffset = XRpgMakerGameConfigs.GetRpgMakerGameYOffSet(modelName) + zOffset = XRpgMakerGameConfigs.GetRpgMakerGameZOffSet(modelName) + end + + transform.position = position + Vector3(xOffset, yOffset, zOffset) +end + +function XRpgMakerGameObject:GetGameObjPosition() + local transform = self:GetTransform() + if XTool.UObjIsNil(transform) then + return + end + + return transform.position +end + +--获得模型所在的根节点 +function XRpgMakerGameObject:GetGameObjModelRoot() + return self.ModelRoot +end + +--设置场景对象朝向 +function XRpgMakerGameObject:SetGameObjectLookRotation(direction) + local transform = self:GetTransform() + if XTool.UObjIsNil(transform) then + return + end + + local objPos = self:GetGameObjPosition() + local directionPos = self:GetDirectionPos(direction) + if not objPos or not directionPos then + return + end + + local lookRotation = LookRotation(directionPos - objPos) + self:SetGameObjectRotation(lookRotation) +end + +--设置场景对象角度 +function XRpgMakerGameObject:SetGameObjectRotation(rotation) + local transform = self:GetTransform() + if XTool.UObjIsNil(transform) then + return + end + transform.rotation = rotation +end + +--获得场景对象大小 +function XRpgMakerGameObject:GetGameObjSize() + local gameObject = self:GetGameObject() + if XTool.UObjIsNil(gameObject) then + return {} + end + + local meshFilter = gameObject:GetComponent("MeshFilter") + return meshFilter and meshFilter.mesh.bounds.size or {} +end + +function XRpgMakerGameObject:OnLoadComplete() + -- body +end + +--播放攻击动画 +function XRpgMakerGameObject:PlayAtkAction(cb) + local modelName = self:GetModelName() + local atkAnima = XRpgMakerGameConfigs.GetRpgMakerGameAtkAnimaName(modelName) + self:PlayAnima(atkAnima, nil, function() + self:PlayStandAnima() + if cb then + cb() + end + end) +end + +--播放被攻击特效和音效 +function XRpgMakerGameObject:PlayBeAtkAction(cb) + local modelName = self:GetModelName() + local effectPath = XRpgMakerGameConfigs.GetRpgMakerGameBeAtkEffectPath(modelName) + local effectRootName = XRpgMakerGameConfigs.GetRpgMakerGameEffectRoot(modelName) + local effectRoot + --被攻击特效 + if not string.IsNilOrEmpty(effectPath) and not string.IsNilOrEmpty(effectRootName) then + local transform = self:GetTransform() + effectRoot = transform:FindTransform(effectRootName) + + if not self.BeAtkResource then + self.BeAtkResource = self:ResourceManagerLoad(effectPath) + end + + if XTool.UObjIsNil(effectRoot) then + XLog.Error(string.format("XRpgMakerGameObject:PlayBeAtkAction error: 被攻击特效父节点找不到, effectRootName: %s", effectRootName)) + else + if not self.BeAtkEffect then + self.BeAtkEffect = self:LoadEffect(self.BeAtkResource.Asset, effectRoot.transform.position, effectRoot) + end + if not XTool.UObjIsNil(self.BeAtkEffect) then + self.BeAtkEffect.gameObject:SetActiveEx(false) + self.BeAtkEffect.gameObject:SetActiveEx(true) + end + end + end + + XSoundManager.PlaySoundByType(XSoundManager.UiBasicsMusic.RpgMakerGame_Death, XSoundManager.SoundType.Sound) + + local delay = XRpgMakerGameConfigs.BeAtkEffectDelayCallbackTime + XScheduleManager.ScheduleOnce(function() + if not XTool.UObjIsNil(self.BeAtkEffect) then + self.BeAtkEffect.gameObject:SetActiveEx(false) + end + self:SetActive(false) + if cb then + cb() + end + end, delay) +end + +--播放站立动画 +function XRpgMakerGameObject:PlayStandAnima(cb) + local modelName = self:GetModelName() + local standAnima = XRpgMakerGameConfigs.GetRpgMakerGameStandAnimaName(modelName) + self:PlayAnima(standAnima, cb) +end + +function XRpgMakerGameObject:SetActive(isActive) + local gameObject = self:GetGameObject() + if XTool.UObjIsNil(gameObject) then + return + end + gameObject:SetActiveEx(isActive) +end + +function XRpgMakerGameObject:SetGameObjScale(scale) + local transform = self:GetTransform() + if not transform then + return + end + + transform.localScale = scale +end + +function XRpgMakerGameObject:SetGameObjMesh(mesh) + local transform = self:GetTransform() + if not transform then + return + end + + local meshFilter = transform:GetComponent("MeshFilter") + if XTool.UObjIsNil(meshFilter) or XTool.UObjIsNil(meshFilter.mesh) then + return + end + + meshFilter.mesh = mesh +end + +function XRpgMakerGameObject:GetGameObjMesh() + local transform = self:GetTransform() + if not transform then + return + end + + return transform:GetComponent("MeshFilter").mesh +end + +function XRpgMakerGameObject:GetCubeObj(row, col) + return XDataCenter.RpgMakerGameManager.GetSceneCubeObj(row, col) +end + +function XRpgMakerGameObject:GetCubeUpCenterPosition(row, col) + return XDataCenter.RpgMakerGameManager.GetSceneCubeUpCenterPosition(row, col) +end + +function XRpgMakerGameObject:GetCubeTransform(row, col) + return XDataCenter.RpgMakerGameManager.GetSceneCubeTransform(row, col) +end + +function XRpgMakerGameObject:ResourceManagerLoad(path) + local resource = CSXResourceManagerLoad(path) + if resource == nil or not resource.Asset then + XLog.Error(string.format("XRpgMakerGameObject:ResourceManagerLoad加载资源,路径:%s", path)) + return + end + + return resource +end +--------------场景对象相关 end------------------ + +return XRpgMakerGameObject \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XRpgMakerGame/Object/XRpgMakerGamePlayer.lua b/Resources/Scripts/XEntity/XRpgMakerGame/Object/XRpgMakerGamePlayer.lua new file mode 100644 index 00000000..3c68c55a --- /dev/null +++ b/Resources/Scripts/XEntity/XRpgMakerGame/Object/XRpgMakerGamePlayer.lua @@ -0,0 +1,149 @@ +local XRpgMakerGameObject = require("XEntity/XRpgMakerGame/Object/XRpgMakerGameObject") + +local type = type +local pairs = pairs +local CSXResourceManagerLoad = CS.XResourceManager.Load + +local DefaultHp = 100 + +local Default = { + _CurrentHp = 100, --当前血量 + _FaceDirection = 0, --朝向 +} + +--玩家对象 +local XRpgMakerGamePlayer = XClass(XRpgMakerGameObject, "XRpgMakerGamePlayer") + +function XRpgMakerGamePlayer:Ctor(id) + for key, value in pairs(Default) do + if type(value) == "table" then + self[key] = {} + else + self[key] = value + end + end +end + +function XRpgMakerGamePlayer:Dispose() + self:DisposeMoveDirectionEffectObj() + + XRpgMakerGamePlayer.Super.Dispose(self) +end + +function XRpgMakerGamePlayer:DisposeMoveDirectionEffectObj() + if self.MoveDirectionEffectObj and self.MoveDirectionEffectObj:Exist() then + CS.UnityEngine.GameObject.Destroy(self.MoveDirectionEffectObj) + self.MoveDirectionEffectObj = nil + end +end + +function XRpgMakerGamePlayer:InitData(mapId, roleId) + local startPointId = XRpgMakerGameConfigs.GetRpgMakerGameStartPointId(mapId) + local pointX = XRpgMakerGameConfigs.GetRpgMakerGameStartPointX(startPointId) + local pointY = XRpgMakerGameConfigs.GetRpgMakerGameStartPointY(startPointId) + local direction = XRpgMakerGameConfigs.GetRpgMakerGameStartPointDirection(startPointId) + self:SetId(roleId) + self:SetFaceDirection(direction) + self:SetCurrentHp(DefaultHp) + self:UpdatePosition({PositionX = pointX, PositionY = pointY}) +end + +function XRpgMakerGamePlayer:UpdateData(data) + self._CurrentHp = data.CurrentHp + self._FaceDirection = data.FaceDirection + self:UpdatePosition(data) +end + +function XRpgMakerGamePlayer:SetCurrentHp(hp) + self._CurrentHp = hp +end + +function XRpgMakerGamePlayer:SetFaceDirection(faceDirection) + self._FaceDirection = faceDirection +end + +function XRpgMakerGamePlayer:GetFaceDirection() + return self._FaceDirection +end + +function XRpgMakerGamePlayer:GetCurrentHp() + return self._CurrentHp +end + +function XRpgMakerGamePlayer:Die() + self:SetCurrentHp(0) +end + +function XRpgMakerGamePlayer:IsAlive() + return self._CurrentHp > 0 +end + +function XRpgMakerGamePlayer:UpdateObjPosAndDirection() + local transform = self:GetTransform() + if XTool.UObjIsNil(transform) then + return + end + + local x = self:GetPositionX() + local y = self:GetPositionY() + local direction = self:GetFaceDirection() + local cubePosition = self:GetCubeUpCenterPosition(y, x) + cubePosition.y = transform.position.y + self:SetGameObjectPosition(cubePosition) + self:ChangeDirectionAction({Direction = direction}) +end + +--杀死怪物 +function XRpgMakerGamePlayer:PlayKillMonsterAction(action, cb) + local monsterId = action.MonsterId + local cb = cb + local monsterObj = XDataCenter.RpgMakerGameManager.GetMonsterObj(monsterId) + self:PlayAtkAction(function() + monsterObj:PlayBeAtkAction(cb) + monsterObj:RemovePatrolLineObjs() + monsterObj:RemoveViewAreaModels() + end) +end + +--检查是否死亡 +function XRpgMakerGamePlayer:CheckIsDeath() + local currentHp = self:GetCurrentHp() + local isDeath = currentHp <= 0 + self:SetActive(not isDeath) +end + +--加载即将移动方向的特效 +function XRpgMakerGamePlayer:LoadMoveDirectionEffect() + self:DisposeMoveDirectionEffectObj() + + local direction = self:GetFaceDirection() + if not direction then + return + end + + local moveDirectionEffectPath = XRpgMakerGameConfigs.GetRpgMakerGameModelPath("RoleMoveArrow") + local resource = CSXResourceManagerLoad(moveDirectionEffectPath) + if resource == nil or not resource.Asset then + XLog.Error(string.format("XRpgMakerGamePlayer:LoadMoveDirectionEffect加载即将移动方向的特效:%s失败", moveDirectionEffectPath)) + return + end + + local cubeUpCenterPos = self:GetDirectionPos(direction) + if not cubeUpCenterPos then + return + end + + self.MoveDirectionEffectObj = self:LoadEffect(resource.Asset, cubeUpCenterPos) +end + +function XRpgMakerGamePlayer:SetMoveDirectionEffectActive(isActive) + if XTool.UObjIsNil(self.MoveDirectionEffectObj) then + return + end + + if self.MoveDirectionEffectObj.gameObject.activeSelf ~= isActive then + self.MoveDirectionEffectObj.gameObject:SetActiveEx(isActive) + end +end + +return XRpgMakerGamePlayer \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XRpgMakerGame/Object/XRpgMakerGameTriggerData.lua b/Resources/Scripts/XEntity/XRpgMakerGame/Object/XRpgMakerGameTriggerData.lua new file mode 100644 index 00000000..1b807afc --- /dev/null +++ b/Resources/Scripts/XEntity/XRpgMakerGame/Object/XRpgMakerGameTriggerData.lua @@ -0,0 +1,202 @@ +local XRpgMakerGameObject = require("XEntity/XRpgMakerGame/Object/XRpgMakerGameObject") + +local type = type +local pairs = pairs +local Vector3 = CS.UnityEngine.Vector3 +local Vec3Lerp = CS.UnityEngine.Vector3.Lerp + +local Default = { + _TriggerStatus = 0, --状态,1阻挡,0不阻挡 +} + +local TriggerType1OpenOffSetY = -0.22 --类型1开关开启时的位置偏移 +local TriggerType2OpenOffSetY = -0.46 --类型2开关开启时的位置偏移 +local ModelDefaultScale = Vector3(1, 1, 1) --模型默认大小 +local TriggerType2OpenScale = Vector3(0.9, 0.9, 0.9) --类型2开关开启时的模型大小 +local TriggerType2PlayTime = 0.5 --类型2开关开启或关闭播放动画的时间(单位:秒) + +--开关对象 +local XRpgMakerGameTriggerData = XClass(XRpgMakerGameObject, "XRpgMakerGameTriggerData") + +function XRpgMakerGameTriggerData:Ctor(id) + for key, value in pairs(Default) do + if type(value) == "table" then + self[key] = {} + else + self[key] = value + end + end + self:InitData() +end + +function XRpgMakerGameTriggerData:InitData() + self.StatusIsChange = false --新的机关状态是否和旧的不同 + local triggerId = self:GetId() + local pointX = XRpgMakerGameConfigs.GetRpgMakerGameTriggerX(triggerId) + local pointY = XRpgMakerGameConfigs.GetRpgMakerGameTriggerY(triggerId) + local defaultBlock = XRpgMakerGameConfigs.GetRpgMakerGameTriggerDefaultBlock(triggerId) + self:UpdatePosition({PositionX = pointX, PositionY = pointY}) + self:SetTriggerStatus(defaultBlock) +end + +function XRpgMakerGameTriggerData:UpdateData(data) + local status = data.TriggerStatus or data.BlockStatus + self:SetStatusIsChange(self._TriggerStatus ~= status) + self._TriggerStatus = status +end + +function XRpgMakerGameTriggerData:SetTriggerStatus(status) + self:SetStatusIsChange(self._TriggerStatus ~= status) + self._TriggerStatus = status +end + +function XRpgMakerGameTriggerData:SetStatusIsChange(isChange) + self.StatusIsChange = isChange +end + +function XRpgMakerGameTriggerData:IsBlock(status) + local triggerStatus = status or self._TriggerStatus + return triggerStatus == XRpgMakerGameConfigs.XRpgMakerGameBlockStatus.Block +end + +function XRpgMakerGameTriggerData:UpdateObjTriggerStatus(isNotPlaySound) + self:PlayTriggerStatusChangeAction({TriggerStatus = self._TriggerStatus}, nil, isNotPlaySound) +end + +--播放开关状态切换动画 +function XRpgMakerGameTriggerData:PlayTriggerStatusChangeAction(action, cb, isNotPlaySound) + local transform = self:GetTransform() + local gameObjPosition = self:GetGameObjPosition() + if not transform or not gameObjPosition then + return + end + + local triggerId = self:GetId() + local triggerType = XRpgMakerGameConfigs.GetRpgMakerGameTriggerType(triggerId) + local triggerStatus = action.TriggerStatus or action.BlockStatus + local isBlock = self:IsBlock(triggerStatus) + local positionX = gameObjPosition.x + local positionZ = gameObjPosition.z + local originScale = transform.localScale + local pointX = XRpgMakerGameConfigs.GetRpgMakerGameTriggerX(triggerId) + local pointY = XRpgMakerGameConfigs.GetRpgMakerGameTriggerY(triggerId) + local cubeUpCenterPosition = self:GetCubeUpCenterPosition(pointY, pointX) + local cubeUpCenterPositionY = cubeUpCenterPosition.y + + if triggerType == XRpgMakerGameConfigs.XRpgMakerGameTriggerType.Trigger2 then + self:CheckTriggerType1Touch(isBlock) + local objSize = self:GetGameObjSize() + local offSetY = objSize and -objSize.y + 0.1 or TriggerType2OpenOffSetY + + local easeMethod = function(f) + return XUiHelper.Evaluate(XUiHelper.EaseType.Increase, f) + end + local onRefresh = function(f) + if XTool.UObjIsNil(transform) then + return + end + + local offsetY = cubeUpCenterPositionY + offSetY + local position = isBlock and Vec3Lerp(gameObjPosition, Vector3(positionX, cubeUpCenterPositionY, positionZ), f) + or Vec3Lerp(gameObjPosition, Vector3(positionX, offsetY, positionZ), f) + self:SetGameObjectPosition(position) + + local scale = isBlock and Vec3Lerp(originScale, ModelDefaultScale, f) + or Vec3Lerp(originScale, TriggerType2OpenScale, f) + self:SetGameObjScale(scale) + end + self.TriggerType2PlayTimer = XUiHelper.Tween(TriggerType2PlayTime, onRefresh, nil, easeMethod) + + if not isNotPlaySound and self.StatusIsChange then + XSoundManager.PlaySoundByType(XSoundManager.UiBasicsMusic.RpgMakerGame_TriggerType2, XSoundManager.SoundType.Sound) + end + + elseif triggerType == XRpgMakerGameConfigs.XRpgMakerGameTriggerType.Trigger3 then + local trigger = XUiHelper.TryGetComponent(transform, "ScenePuzzle01_02Dici") + if trigger then + trigger.gameObject:SetActiveEx(isBlock) + self:SetActive(true) + else + self:SetActive(isBlock) + end + + if isBlock and not isNotPlaySound and self.StatusIsChange then + XSoundManager.PlaySoundByType(XSoundManager.UiBasicsMusic.RpgMakerGame_TriggerType3, XSoundManager.SoundType.Sound) + end + end + + if cb then + cb() + end +end + +--检查是否触发了类型1的机关(有怪物或玩家在机关上) +function XRpgMakerGameTriggerData:CheckTriggerType1Touch(isBlock) + local currentScene = XDataCenter.RpgMakerGameManager.GetCurrentScene() + local mapId = currentScene:GetMapId() + local triggerIdList = XRpgMakerGameConfigs.GetRpgMakerGameMapIdToTriggerIdList(mapId) + local playerObj = XDataCenter.RpgMakerGameManager.GetPlayerObj() + local positionX + local positionY + local triggerType + local pointX + local pointY + local monsterIdList + local monsterObj + + for _, triggerId in ipairs(triggerIdList) do + triggerType = XRpgMakerGameConfigs.GetRpgMakerGameTriggerType(triggerId) + if triggerType == XRpgMakerGameConfigs.XRpgMakerGameTriggerType.Trigger1 then + pointX = XRpgMakerGameConfigs.GetRpgMakerGameTriggerX(triggerId) + pointY = XRpgMakerGameConfigs.GetRpgMakerGameTriggerY(triggerId) + positionX = playerObj:GetPositionX() + positionY = playerObj:GetPositionY() + if pointX == positionX and pointY == positionY then + self:PlayTriggerType1Action(triggerId, isBlock) + goto continue + end + + monsterIdList = XRpgMakerGameConfigs.GetRpgMakerGameMapIdToMonsterIdList(mapId) + for _, monsterId in ipairs(monsterIdList) do + monsterObj = XDataCenter.RpgMakerGameManager.GetMonsterObj(monsterId) + positionX = monsterObj:GetPositionX() + positionY = monsterObj:GetPositionY() + if pointX == positionX and pointY == positionY then + self:PlayTriggerType1Action(triggerId, isBlock) + goto continue + end + end + + --没怪物或玩家在机关上还原成默认的状态 + self:PlayTriggerType1Action(triggerId, true) + end + + ::continue:: + end +end + +function XRpgMakerGameTriggerData:PlayTriggerType1Action(triggerId, isBlock) + local triggerObj = XDataCenter.RpgMakerGameManager.GetTriggerObj(triggerId) + if not triggerObj then + return + end + + local gameObjPosition = triggerObj:GetGameObjPosition() + if not gameObjPosition then + return + end + + local pointX = XRpgMakerGameConfigs.GetRpgMakerGameTriggerX(triggerId) + local pointY = XRpgMakerGameConfigs.GetRpgMakerGameTriggerY(triggerId) + local cubeUpCenterPosition = self:GetCubeUpCenterPosition(pointY, pointX) + local cubeUpCenterPositionY = cubeUpCenterPosition.y + local positionX = gameObjPosition.x + local positionZ = gameObjPosition.z + local offsetY = cubeUpCenterPositionY + TriggerType1OpenOffSetY + local position = isBlock and Vector3(positionX, cubeUpCenterPositionY, positionZ) + or Vector3(positionX, offsetY, positionZ) + + triggerObj:SetGameObjectPosition(position) +end + +return XRpgMakerGameTriggerData \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XRpgMakerGame/XRpgMakerActivityStageDb.lua b/Resources/Scripts/XEntity/XRpgMakerGame/XRpgMakerActivityStageDb.lua new file mode 100644 index 00000000..b13a81ef --- /dev/null +++ b/Resources/Scripts/XEntity/XRpgMakerGame/XRpgMakerActivityStageDb.lua @@ -0,0 +1,72 @@ +local type = type +local pairs = pairs + +local Default = { + _StageCfgId = 0, --关卡id + _RoleId = 0, --最后使用通过的角色 + _StepCount = 0, --通关时候的步数 + _StarCondition = {}, --通关获得的星星id列表 +} + +--关卡数据 +local XRpgMakerActivityStageDb = XClass(nil, "XRpgMakerActivityStageDb") + +function XRpgMakerActivityStageDb:Ctor(day) + for key, value in pairs(Default) do + if type(value) == "table" then + self[key] = {} + else + self[key] = value + end + end +end + +function XRpgMakerActivityStageDb:UpdateData(data) + self._StageCfgId = data.StageCfgId + self._RoleId = data.RoleId + self._StepCount = data.StepCount + self._StarCondition = data.StarCondition +end + +function XRpgMakerActivityStageDb:SetRoleId(roleId) + self._RoleId = roleId +end + +function XRpgMakerActivityStageDb:SetStepCount(stepCount) + self._StepCount = stepCount +end + +function XRpgMakerActivityStageDb:SetStarCondition(starCondition) + self._StarCondition = starCondition +end + +function XRpgMakerActivityStageDb:GetStarCount() + return self._StarCondition and #self._StarCondition or 0 +end + +function XRpgMakerActivityStageDb:IsStarConditionClear(starConditionId) + for _, starCondition in ipairs(self._StarCondition or {}) do + if starCondition == starConditionId then + return true + end + end + return false +end + +function XRpgMakerActivityStageDb:GetStageCfgId() + return self._StageCfgId +end + +function XRpgMakerActivityStageDb:GetRoleId() + return self._RoleId +end + +function XRpgMakerActivityStageDb:GetStepCount() + return self._StepCount +end + +function XRpgMakerActivityStageDb:GetStar() + return self._Star +end + +return XRpgMakerActivityStageDb \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XRpgMakerGame/XRpgMakerGameActivityDb.lua b/Resources/Scripts/XEntity/XRpgMakerGame/XRpgMakerGameActivityDb.lua new file mode 100644 index 00000000..d80bcbfd --- /dev/null +++ b/Resources/Scripts/XEntity/XRpgMakerGame/XRpgMakerGameActivityDb.lua @@ -0,0 +1,63 @@ +local XRpgMakerActivityStageDb = require("XEntity/XRpgMakerGame/XRpgMakerActivityStageDb") + +local type = type +local pairs = pairs +local tableInsert = table.insert + +local Default = { + _StageDbs = {}, --所有已通关的关卡数据 + _UnlockRoleId = {}, --已解锁的角色id列表 +} + +--活动数据 +local XRpgMakerGameActivityDb = XClass(nil, "XRpgMakerGameActivityDb") + +function XRpgMakerGameActivityDb:Ctor(day) + for key, value in pairs(Default) do + if type(value) == "table" then + self[key] = {} + else + self[key] = value + end + end +end + +function XRpgMakerGameActivityDb:UpdateData(data) + self._StageDbs = {} + local stageDb + for i, v in ipairs(data.StageDbs) do + stageDb = XRpgMakerActivityStageDb.New() + stageDb:UpdateData(v) + tableInsert(self._StageDbs, stageDb) + end + self._UnlockRoleId = data.UnlockRoleId +end + +function XRpgMakerGameActivityDb:UpdateStageDb(data) + local stageDb = XRpgMakerActivityStageDb.New() + stageDb:UpdateData(data) + tableInsert(self._StageDbs, stageDb) +end + +function XRpgMakerGameActivityDb:UpdateUnlockRoleId(unlockRoleId) + for _, roleId in ipairs(self._UnlockRoleId) do + if roleId == unlockRoleId then + return + end + end + tableInsert(self._UnlockRoleId, unlockRoleId) +end + +function XRpgMakerGameActivityDb:GetUnlockRoleIdList() + return self._UnlockRoleId +end + +function XRpgMakerGameActivityDb:GetStageDb(stageCfgId) + for _, stageDb in ipairs(self._StageDbs) do + if stageDb:GetStageCfgId() == stageCfgId then + return stageDb + end + end +end + +return XRpgMakerGameActivityDb \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XRpgMakerGame/XRpgMakerGameEnterStageDb.lua b/Resources/Scripts/XEntity/XRpgMakerGame/XRpgMakerGameEnterStageDb.lua new file mode 100644 index 00000000..364b3d75 --- /dev/null +++ b/Resources/Scripts/XEntity/XRpgMakerGame/XRpgMakerGameEnterStageDb.lua @@ -0,0 +1,42 @@ +local type = type +local pairs = pairs +local tableInsert = table.insert + +local Default = { + _StageId = 0, --关卡ID + _MapId = 0, --地图ID + _SelectRoleId = 0 --选用角色 +} + +--当前进入的关卡数据 +local XRpgMakerGameEnterStageDb = XClass(nil, "XRpgMakerGameEnterStageDb") + +function XRpgMakerGameEnterStageDb:Ctor(day) + for key, value in pairs(Default) do + if type(value) == "table" then + self[key] = {} + else + self[key] = value + end + end +end + +function XRpgMakerGameEnterStageDb:UpdateData(data) + self._StageId = data.StageId + self._MapId = data.MapId + self._SelectRoleId = data.SelectRoleId +end + +function XRpgMakerGameEnterStageDb:GetStageId() + return self._StageId +end + +function XRpgMakerGameEnterStageDb:GetMapId() + return self._MapId +end + +function XRpgMakerGameEnterStageDb:GetSelectRoleId() + return self._SelectRoleId +end + +return XRpgMakerGameEnterStageDb \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XRpgMakerGame/XRpgMakerGamePosition.lua b/Resources/Scripts/XEntity/XRpgMakerGame/XRpgMakerGamePosition.lua new file mode 100644 index 00000000..5dfbcb47 --- /dev/null +++ b/Resources/Scripts/XEntity/XRpgMakerGame/XRpgMakerGamePosition.lua @@ -0,0 +1,42 @@ +local type = type +local pairs = pairs + +local Default = { + _PositionX = 0, + _PositionY = 0, +} + +--二维坐标点,非场景对象的坐标 +local XRpgMakerGamePosition = XClass(nil, "XRpgMakerGamePosition") + +function XRpgMakerGamePosition:Ctor() + for key, value in pairs(Default) do + if type(value) == "table" then + self[key] = {} + else + self[key] = value + end + end +end + +function XRpgMakerGamePosition:UpdatePosition(data) + if not data then + return + end + if data.PositionX then + self._PositionX = data.PositionX + end + if data.PositionY then + self._PositionY = data.PositionY + end +end + +function XRpgMakerGamePosition:GetPositionX() + return self._PositionX +end + +function XRpgMakerGamePosition:GetPositionY() + return self._PositionY +end + +return XRpgMakerGamePosition \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XRpgTower/XRpgTowerChapter.lua b/Resources/Scripts/XEntity/XRpgTower/XRpgTowerChapter.lua new file mode 100644 index 00000000..799b086b --- /dev/null +++ b/Resources/Scripts/XEntity/XRpgTower/XRpgTowerChapter.lua @@ -0,0 +1,105 @@ +--兵法蓝图章节对象(现阶段一个章节就是一个活动ID) +local XRpgTowerChapter = XClass(nil, "XRpgTowerChapter") +--================ +--构造函数,初始化活动数据 +--================ +function XRpgTowerChapter:Ctor(activityId) + if activityId then self:RefreshData(activityId) end +end +--================ +--重新初始化活动数据 +--================ +function XRpgTowerChapter:RefreshData(activityId) + self.ActivityId = activityId + self.LastPassIndex = 1 + self:RefreshStage() +end +--================ +--重新初始化关卡 +--================ +function XRpgTowerChapter:ResetStage() + local rStageList = XRpgTowerConfig.GetRStageListByActivityId(self.ActivityId) + for index = 1, #rStageList do + local rStage = XDataCenter.RpgTowerManager.GetRStageByStageId(rStageList[index].StageId) + if rStage then rStage:Reset() end + end +end +--================ +--刷新关卡数据 +--================ +function XRpgTowerChapter:RefreshStage() + local rStageList = XRpgTowerConfig.GetRStageListByActivityId(self.ActivityId) + self.AllClear = true + for index = self.LastPassIndex > 0 and self.LastPassIndex or 1, #rStageList do + local rStage = XDataCenter.RpgTowerManager.GetRStageByStageId(rStageList[index].StageId) + if index == 1 and (not rStage:GetIsPass()) then + self.LastPassIndex = 0 + elseif rStage:GetIsPass() then + self.LastPassIndex = index + else + self.AllClear = false + end + end + self.TotalStageNum = #rStageList + -- 获取当前关卡进度 + self.CurrentIndex = (self.LastPassIndex < self.TotalStageNum and (self.LastPassIndex + 1)) or self.TotalStageNum + local rStage = XDataCenter.RpgTowerManager.GetRStageByStageId(rStageList[self.CurrentIndex].StageId) + self.CurrentRStage = rStage +end +--================ +--获取章节配置ID +--================ +function XRpgTowerChapter:GetChapterId() + return self.ActivityId or -1 +end +--================ +--获取章节是否全部通关 +--================ +function XRpgTowerChapter:GetIsClear() + return self.AllClear +end +--================ +--获取最后通关的关卡序号 +--================ +function XRpgTowerChapter:GetLassPassIndex() + return self.LastPassIndex +end +--================ +--获取当前关卡序号(若全通关则显示最后一关) +--================ +function XRpgTowerChapter:GetCurrentIndex() + return self.CurrentIndex +end +--================ +--获取当前关卡的RStage对象 +--================ +function XRpgTowerChapter:GetCurrentRStage() + return self.CurrentRStage +end +--================ +--获取当前章节通关进度字符串 +--================ +function XRpgTowerChapter:GetPassProgressStr() + return CS.XTextManager.GetText("RpgTowerChapterProgressStr", self.LastPassIndex, self.TotalStageNum) +end +--================ +--获取关卡动态列表的内容,根据通关情况把可显示的关卡列表传出 +--================ +function XRpgTowerChapter:GetDynamicRStageList(canShowGridNum, showFurtherNum) + --先刷新关卡状态 + self:RefreshStage() + local listLength = self.CurrentIndex + showFurtherNum + if listLength >= self.TotalStageNum or self.TotalStageNum <= canShowGridNum then + listLength = self.TotalStageNum + elseif listLength <= canShowGridNum then + listLength = canShowGridNum + end + local rStageList = XRpgTowerConfig.GetRStageListByActivityId(self.ActivityId) + local showStageList = {} + for orderId = 1, listLength do + showStageList[orderId] = rStageList[orderId] + end + return showStageList +end + +return XRpgTowerChapter \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XRpgTower/XRpgTowerCharacter.lua b/Resources/Scripts/XEntity/XRpgTower/XRpgTowerCharacter.lua new file mode 100644 index 00000000..018c4287 --- /dev/null +++ b/Resources/Scripts/XEntity/XRpgTower/XRpgTowerCharacter.lua @@ -0,0 +1,431 @@ +--兵法蓝图角色模型类 +local XRpgTowerCharacter = XClass(nil, "XRpgTowerCharacter") +local XRpgTowerTalent = require("XEntity/XRpgTower/XRpgTowerTalent") +local XRpgTowerItem = require("XEntity/XRpgTower/XRpgTowerItem") +--[[ +*********属性说明 +RCharaCfg 兵法蓝图角色配置 +TalentIds 已激活的天赋ID列表 +TalentPoints 剩余的天赋点 +Order 在队伍列表中的位置 +]] + +--[[ +================ +构造函数 +================ +]] +function XRpgTowerCharacter:Ctor(characterId, teamOrder) + self.RCharaCfg = XRpgTowerConfig.GetRCharacterCfgByCharacterIdAndLevel(characterId, 1) + self.RBaseCharaCfg = XRpgTowerConfig.GetRBaseCharaCfgByCharacterId(characterId) + self.RobotId = self.RCharaCfg.RobotId + self.Order = teamOrder + self.TalentIds = {} +end +--[[ +================ +刷新角色数据(刷新角色数据时使用) +@param XRpgCharacterData: 通信用角色数据模型数据 +================ +]] +function XRpgTowerCharacter:RefreshCharacterData(XRpgCharacterData) + self.RCharaCfg = XRpgTowerConfig.GetRCharacterCfgByCharacterIdAndLevel(XRpgCharacterData.CharacterId, XDataCenter.RpgTowerManager.GetCurrentLevel()) + self.RBaseCharaCfg = XRpgTowerConfig.GetRBaseCharaCfgByCharacterId(XRpgCharacterData.CharacterId) + self.TalentPoint = XRpgTowerItem.New(XDataCenter.RpgTowerManager.GetTalentItemId()) + self.RobotId = self.RCharaCfg.RobotId + self.TalentIds = self:InitTalentIds(XRpgCharacterData.TalentIds) + self.TalentPoint:SetNum(XRpgCharacterData.TalentPoints) + self:ResetInfo() + self:InitTalents() +end +function XRpgTowerCharacter:ResetInfo() + self:InitSkillInfo() + self:InitAbility() +end +--[[ +================ +清空角色技能信息 +================ +]] +function XRpgTowerCharacter:InitSkillInfo() + self.RoleListSkill = nil +end +--[[ +================ +清空角色战力信息 +================ +]] +function XRpgTowerCharacter:InitAbility() + self.Ability = nil +end +--[[ +================ +初始化天赋开启数据 +================ +]] +function XRpgTowerCharacter:InitTalentIds(activeTalentIds) + local talentActiveDic = {} + for _, activeTalentId in pairs(activeTalentIds) do + talentActiveDic[activeTalentId] = true + end + return talentActiveDic +end +--[[ +================ +初始化角色天赋信息 +================ +]] +function XRpgTowerCharacter:InitTalents() + local talents = XRpgTowerConfig.GetTalentCfgsByCharacterId(self:GetCharacterId()) + self.Talents = {} + for layerId, talentLayer in pairs(talents) do + if not self.Talents[layerId] then self.Talents[layerId] = {} end + for index, talentCfg in pairs(talentLayer) do + table.insert(self.Talents[layerId], XRpgTowerTalent.New(talentCfg.TalentId, self.TalentIds[talentCfg.TalentId], self)) + end + table.sort(self.Talents[layerId], function(rTalent1, rTalent2) + return rTalent1:GetId() < rTalent2:GetId() + end) + end +end +--[[ +================ +获取角色ID +================ +]] +function XRpgTowerCharacter:GetCharacterId() + return self.RCharaCfg and self.RCharaCfg.CharacterId +end +--[[ +================ +获取机器人ID +================ +]] +function XRpgTowerCharacter:GetRobotId() + return self.RobotId +end +--[[ +================ +获取机器人配置 +================ +]] +function XRpgTowerCharacter:GetRobotCfg() + return XRobotManager.GetRobotTemplate(self:GetRobotId()) +end +--[[ +================ +获取角色在队伍中的排序 +================ +]] +function XRpgTowerCharacter:GetOrder() + return self.Order +end +--[[ +================ +获取角色要展示的基础属性类型组数据 +================ +]] +function XRpgTowerCharacter:GetDisplayAttrTypeData() + local attrData = {} + for i in pairs(self.RBaseCharaCfg.DisplayAttriName) do + local attr = { + Name = self.RBaseCharaCfg.DisplayAttriName[i], + Type = self.RBaseCharaCfg.DisplayAttriType[i] + } + table.insert(attrData, attr) + end + return attrData +end +--[[ +================ +获取角色战力 +================ +]] +function XRpgTowerCharacter:GetAbility() + if self.Ability then return self.Ability end + --二期简化了技能树类型,可以直接读取机器人表的ShowAbility + self.Ability = XRobotManager.GetRobotAbility(self:GetRobotId()) + --[[ + self.Ability = 0 + --这里的角色属性已包含装备 + local robotAttrib = self:GetCharaAttributes() + local attribAbility = XAttribManager.GetAttribAbility(robotAttrib) + --构建机器人技能数据 + local skillData = XRobotManager.GetRobotSkillLevelDic(self.RobotId) + ]] + if self.Talents then + for _, talentLayer in pairs(self.Talents) do + for index, talent in pairs(talentLayer) do + if talent:GetIsUnLock() then + self.Ability = self.Ability + talent:GetSpecialAbility() + --[[ + local skillInfo = talent:GetSkillPlus() + if skillInfo then + for skillId, addLevel in pairs(skillInfo) do + skillData[skillId] = skillData[skillId] + addLevel + end + end + ]] + end + end + end + end + --local skillAbility = XDataCenter.CharacterManager.GetSkillAbility(skillData) + --self.Ability = self.Ability + attribAbility + skillAbility + return self.Ability +end +--[[ +================ +获取角色四围属性值 +================ +]] +function XRpgTowerCharacter:GetCharaAttributes() + local extraAttribIds = {} + for _, talentLayer in pairs(self.Talents) do + for index, talent in pairs(talentLayer) do + if talent:GetIsUnLock() then + local attribId = talent:GetAttribPlus() + if attribId then + table.insert(extraAttribIds, attribId) + end + end + end + end + return XRobotManager.GetRobotAttribWithExtraAttrib(self.RobotId, extraAttribIds) +end +--[[ +================ +获取角色天赋属性加值 +================ +]] +function XRpgTowerCharacter:GetCharaTalentPlusAttr() + local extraAttr + for _, talentLayer in pairs(self.Talents) do + for index, talent in pairs(talentLayer) do + if talent:GetIsUnLock() then + local attribId = talent:GetAttribPlus() + if not extraAttr and attribId then + extraAttr = XTool.Clone(XAttribManager.GetAttribByAttribId(attribId)) + elseif attribId then + XAttribManager.DoAddAttribsByAttrAndAddId(extraAttr, attribId) + end + end + end + end + return extraAttr +end +--[[ +================ +获取角色名称 +================ +]] +function XRpgTowerCharacter:GetCharaName() + return XCharacterConfigs.GetCharacterName(self.RCharaCfg.CharacterId) +end +--[[ +================ +获取角色名称+型号全称 +================ +]] +function XRpgTowerCharacter:GetFullName() + return XCharacterConfigs.GetCharacterFullNameStr(self.RCharaCfg.CharacterId) +end +--[[ +================ +获取角色型号名 +================ +]] +function XRpgTowerCharacter:GetModelName() + return XCharacterConfigs.GetCharacterTradeName(self.RCharaCfg.CharacterId) +end +--[[ +================ +获取角色详细界面的技能列表 +================ +]] +function XRpgTowerCharacter:GetRoleListSkill() + if self.RoleListSkill then return self.RoleListSkill end + local skillData = XRobotManager.GetRobotSkillLevelDic(self:GetRobotId(), true) + self.RoleListSkill = {} + local removeNo = { + [22] = true, + [24] = true, + [25] = true, + [26] = true, + [27] = true + } -- 队长技,SS,SSS,SSS+与终阶解放技能不展示 + --增加角色天赋里面的技能增益 + local plusSkillData = self:GetSkillPlusData() + for skillId, skillLevel in pairs(plusSkillData) do + skillData[skillId] = skillData[skillId] + skillLevel + end + --按SkillId排序 + local tempList = {} + for skillId, skillLevel in pairs(skillData) do + local skillNo = skillId % 100 + if not removeNo[skillNo] then + local skillInfo = XCharacterConfigs.GetSkillGradeDesConfig(skillId, skillLevel) + local tempData = { Order = skillId, Info = skillInfo} + table.insert(tempList, tempData) + end + end + table.sort(tempList, function(a,b) return a.Order < b.Order end) + for i = 1, #tempList do + table.insert(self.RoleListSkill, tempList[i].Info) + end + return self.RoleListSkill +end +--[[ +================ +获取角色技能天赋增加部分数据 +================ +]] +function XRpgTowerCharacter:GetSkillPlusData() + local plusSkillData = {} + if not self.Talents then return plusSkillData end + --统计每个激活天赋增加的技能 + for _, talentLayer in pairs(self.Talents) do + for index, talent in pairs(talentLayer) do + if talent:GetIsUnLock() then + local skillInfo = talent:GetSkillPlus() + if skillInfo then + for skillId, addLevel in pairs(skillInfo) do + if not plusSkillData[skillId] then plusSkillData[skillId] = 0 end + plusSkillData[skillId] = plusSkillData[skillId] + addLevel + end + end + end + end + end + return plusSkillData +end +--[[ +================ +获取角色小头像 +================ +]] +function XRpgTowerCharacter:GetSmallHeadIcon() + local fashionId = XCharacterConfigs.GetCharacterTemplate(self.RCharaCfg.CharacterId).DefaultNpcFashtionId + return XDataCenter.FashionManager.GetFashionSmallHeadIcon(fashionId) +end +--[[ +================ +获取角色大头像 +================ +]] +function XRpgTowerCharacter:GetBigHeadIcon() + local fashionId = XCharacterConfigs.GetCharacterTemplate(self.RCharaCfg.CharacterId).DefaultNpcFashtionId + return XDataCenter.FashionManager.GetFashionBigHeadIcon(fashionId) +end +--[[ +================ +获取角色职介图标 +================ +]] +function XRpgTowerCharacter:GetJobTypeIcon() + local jobType = XRobotManager.GetRobotJobType(self.RobotId) + return XCharacterConfigs.GetNpcTypeIcon(jobType) +end +--[[ +================ +是否已经满级 +================ +]] +function XRpgTowerCharacter:GetIsMaxLevel() + return self.RCharaCfg and (self:GetLevel() >= XDataCenter.RpgTowerManager.GetMaxLevel()) +end +--[[ +================ +获取角色的天赋点 +================ +]] +function XRpgTowerCharacter:GetTalentPoints() + return self.TalentPoint:GetNum() +end +--[[ +================ +获取角色的天赋对象列表 +================ +]] +function XRpgTowerCharacter:GetTalents() + return self.Talents +end +--================ +--根据等级获取角色的天赋对象列表 +--================ +function XRpgTowerCharacter:GetTalentsByLayer(layer) + return self.Talents[layer] +end +--[[ +================ +获取角色是否在出战队伍中 +================ +]] +function XRpgTowerCharacter:GetIsInTeam() + return XDataCenter.RpgTowerManager.GetCharacterIsInTeam(self:GetCharacterId()) +end +--[[ +================ +获取角色元素属性列表 +================ +]] +function XRpgTowerCharacter:GetElements() + local detailElementsList = XCharacterConfigs.GetCharDetailTemplate(self:GetCharacterId()) + local elements = {} + if detailElementsList then + for i = 1, #detailElementsList.ObtainElementList do + local elementConfig = XCharacterConfigs.GetCharElement(detailElementsList.ObtainElementList[i]) + elements[i] = elementConfig + end + end + return elements +end +--[[ +================ +角色激活天赋 +@param rTalent:天赋位置Id +================ +]] +function XRpgTowerCharacter:TalentActive(rTalent, talentPoints) + self.TalentPoint:SetNum(talentPoints) + rTalent:UnLock() + self:ResetInfo() +end +--[[ +================ +角色重置天赋 +@param talentPoints:重置后的天赋点 +================ +]] +function XRpgTowerCharacter:CharacterReset(talentPoints) + self.TalentPoint:SetNum(talentPoints) + for _, talentLayer in pairs(self.Talents) do + for index, talent in pairs(talentLayer) do + talent:Lock() + end + end + self:ResetInfo() +end +--[[ +================ +获取角色天赋道具 +================ +]] +function XRpgTowerCharacter:GetTalentItem() + return self.TalentPoint +end +--[[ +================ +检查角色是否有能激活的天赋 +================ +]] +function XRpgTowerCharacter:CheckCanActiveTalent() + if not self.Talents then return false end + for _, talentLayer in pairs(self.Talents) do + for index, talent in pairs(talentLayer) do + if not talent:GetIsUnLock() and talent:GetCanUnLock() then return true end + end + end + return false +end +return XRpgTowerCharacter \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XRpgTower/XRpgTowerItem.lua b/Resources/Scripts/XEntity/XRpgTower/XRpgTowerItem.lua new file mode 100644 index 00000000..ddf04906 --- /dev/null +++ b/Resources/Scripts/XEntity/XRpgTower/XRpgTowerItem.lua @@ -0,0 +1,64 @@ +-- 兵法蓝图玩法道具 +local XRpgTowerItem = XClass(nil, "XRpgTowerItem") + +function XRpgTowerItem:Ctor(rItemId) + self.ItemCfg = XRpgTowerConfig.GetRItemConfigByRItemId(rItemId) + self.Count = 0 +end +--=============== +--增加物品数量 +--@param addNum:增加的数量 +--=============== +function XRpgTowerItem:AddNum(addNum) + self.Count = self.Count + addNum +end +--=============== +--减少物品数量 +--@param minusNum:减少的数量 +--=============== +function XRpgTowerItem:MinusNum(minusNum) + self.Count = self.Count - minusNum + if self.Count < 0 then self.Count = 0 end +end +--=============== +--设置物品数量 +--@param num:设置数量 +--=============== +function XRpgTowerItem:SetNum(num) + self.Count = num +end +--=============== +--检查是否有足够物品数量 +--@param checkNum:检查的数量 +--=============== +function XRpgTowerItem:IsEnoughNum(checkNum) + return self.Count >= checkNum +end +--=============== +--获取当前物品数量 +--=============== +function XRpgTowerItem:GetNum() + return self.Count +end +--=============== +--获取图标地址 +--=============== +function XRpgTowerItem:GetIcon() + return self.ItemCfg.Icon +end +--=============== +--获取物品的临时展示信息(用于XUiTip) +--=============== +function XRpgTowerItem:GetTempItemData() + local tempItemData = { + IsTempItemData = true, + Name = self.ItemCfg.Name, + Count = self:GetNum(), + Icon = self.ItemCfg.Icon, + Quality = self.ItemCfg.Quality > 0 and self.ItemCfg.Quality or 1, + WorldDesc = self.ItemCfg.WorldDesc, + Description = self.ItemCfg.Description + } + return tempItemData +end +return XRpgTowerItem \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XRpgTower/XRpgTowerStage.lua b/Resources/Scripts/XEntity/XRpgTower/XRpgTowerStage.lua new file mode 100644 index 00000000..305ac92d --- /dev/null +++ b/Resources/Scripts/XEntity/XRpgTower/XRpgTowerStage.lua @@ -0,0 +1,129 @@ +-- 兵法蓝图关卡对象 +local XRpgTowerStage = XClass(nil, "XRpgTowerStage") +--================ +--定义StageInfo +--================ +local InitStageInfo = function(stageInfo) + stageInfo.Type = XDataCenter.FubenManager.StageType.RpgTower +end +--================ +--构造函数 +--================ +function XRpgTowerStage:Ctor(rStageId) + self.RStageCfg = XRpgTowerConfig.GetRStageCfgById(rStageId) + self.StageCfg = XDataCenter.FubenManager.GetStageCfg(self.RStageCfg.StageId) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(self.RStageCfg.StageId) + InitStageInfo(stageInfo) +end +--================ +--获取关卡基础配置 +--================ +function XRpgTowerStage:GetStageCfg() + return self.StageCfg +end +--================ +--获取关卡名称 +--================ +function XRpgTowerStage:GetStageName() + return self.StageCfg.Name +end +--================ +--获取关卡Id +--================ +function XRpgTowerStage:GetStageId() + return self.StageCfg.StageId +end +--================ +--获取关卡词缀 +--================ +function XRpgTowerStage:GetStageEvents() + local events = {} + local stageFightEvent = self.RStageCfg.NpcAffixId + if stageFightEvent then + for i, eventId in pairs(stageFightEvent) do + events[i] = XFubenConfigs.GetStageFightEventDetailsByStageFightEventId(eventId) + end + end + return events +end +--================ +--获取怪物模型ID +--================ +function XRpgTowerStage:GetMonsters() + return self.RStageCfg.MonsterId +end +--================ +--获取关卡难易度 +--================ +function XRpgTowerStage:GetDifficulty() + return self.RStageCfg.Difficulty +end +--================ +--获取关卡所属活动ID +--================ +function XRpgTowerStage:GetActivityId() + return self.RStageCfg.ActivityId +end +--================ +--获取关卡的环境描述 +--================ +function XRpgTowerStage:GetStageBuffDesc() + return self.RStageCfg.StageBuffDesc +end +--================ +--获取关卡序号 +--================ +function XRpgTowerStage:GetOrderId() + return self.RStageCfg.OrderId +end +--================ +--获取关卡名称 +--================ +function XRpgTowerStage:GetOrderName() + return self.RStageCfg.OrderName +end +--================ +--获取关卡推荐等级 +--================ +function XRpgTowerStage:GetRecommendLevel() + return self.RStageCfg.RecommendLevel +end +--================ +--获取关卡警告类型 +--================ +function XRpgTowerStage:GetStageWarningType() + if self:GetRecommendLevel() > XDataCenter.RpgTowerManager.GetCurrentLevel() then + return XDataCenter.RpgTowerManager.STAGE_WARNING_LEVEL.Danger + else + return XDataCenter.RpgTowerManager.STAGE_WARNING_LEVEL.NoWarning + end +end +--================ +--获取关卡是否通过 +--================ +function XRpgTowerStage:GetIsPass() + local stageInfo = XDataCenter.FubenManager.GetStageInfo(self.RStageCfg.StageId) + return stageInfo.Passed +end +--================ +--获取关卡是否解锁 +--================ +function XRpgTowerStage:GetIsUnlock() + local stageInfo = XDataCenter.FubenManager.GetStageInfo(self.RStageCfg.StageId) + return stageInfo.Unlock +end +--================ +--获取关卡奖励ID +--================ +function XRpgTowerStage:GetStageRewardId() + return self.StageCfg.FirstRewardId +end +--================ +--重置关卡通过状态 +--================ +function XRpgTowerStage:Reset() + local stageInfo = XDataCenter.FubenManager.GetStageInfo(self.RStageCfg.StageId) + if self:GetOrderId() ~= 1 then stageInfo.Unlock = false end + stageInfo.Passed = false +end +return XRpgTowerStage \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XRpgTower/XRpgTowerTalent.lua b/Resources/Scripts/XEntity/XRpgTower/XRpgTowerTalent.lua new file mode 100644 index 00000000..c332fea7 --- /dev/null +++ b/Resources/Scripts/XEntity/XRpgTower/XRpgTowerTalent.lua @@ -0,0 +1,175 @@ +-- 兵法蓝图天赋对象 +local XRpgTowerTalent = XClass(nil, "XRpgTowerTalent") + +function XRpgTowerTalent:Ctor(talentId, isUnLock, rChara) + self.TalentCfg = XRpgTowerConfig.GetTalentCfgById(talentId) + self.RCharacter = rChara + if isUnLock then + self:UnLock() + else + self:Lock() + end +end +--================ +--获取天赋ID +--================ +function XRpgTowerTalent:GetId() + return self.TalentCfg.TalentId +end +--================ +--获取天赋是否解锁 +--================ +function XRpgTowerTalent:GetIsUnLock() + return self.IsUnLock +end +--================ +--获取天赋解锁所需天赋点 +--================ +function XRpgTowerTalent:GetTalentConsume() + return self.TalentCfg.ConsumeCount +end +--================ +--获取天赋名称 +--================ +function XRpgTowerTalent:GetTalentName() + return self.TalentCfg.Name +end +--================ +--获取天赋图标路径 +--================ +function XRpgTowerTalent:GetIconPath() + return self.TalentCfg.Icon +end +--================ +--获取天赋所属角色Id +--================ +function XRpgTowerTalent:GetCharacterId() + return self.TalentCfg.CharacterId +end +--================ +--获取天赋技能描述 +--================ +function XRpgTowerTalent:GetDescription() + return self.TalentCfg.Description +end +--================ +--获取天赋属性加成Id +--================ +function XRpgTowerTalent:GetAttribPlus() + if not self.TalentCfg.AttribPoolGroupId then return nil end + local groupAttrCfg = XAttribConfigs.GetAttribGroupCfgById(self.TalentCfg.AttribPoolGroupId) + return groupAttrCfg and groupAttrCfg.AttribId +end +--================ +--获取天赋技能加成 +--skillInfo = { [skillId] = skillLevel ...} +--================ +function XRpgTowerTalent:GetSkillPlus() + if not self.TalentCfg.SkillIds then return {} end + local skillInfo = {} + for i = 1, #self.TalentCfg.SkillIds do + skillInfo[self.TalentCfg.SkillIds[i]] = self.TalentCfg.SkillLevels[i] + end + return skillInfo +end +--================ +--获取天赋特殊效果战力加成 +--================ +function XRpgTowerTalent:GetSpecialAbility() + return self.TalentCfg.SpecialAbility or 0 +end +--================ +--获取天赋所属等级层 +--================ +function XRpgTowerTalent:GetLayer() + return self.TalentCfg.LayerId +end +--================ +--获取解锁天赋需要的等级 +--================ +function XRpgTowerTalent:GetNeedTeamLevel() + if self.NeedTeamLevel then return self.NeedTeamLevel end + local layer = self:GetLayer() + local layerCfg = XRpgTowerConfig.GetTalentLayerCfgByLayerId(layer) + self.NeedTeamLevel = layerCfg.NeedTeamLevel + return self.NeedTeamLevel +end +--================ +--获取天赋消耗点 +--================ +function XRpgTowerTalent:GetCost() + return self.TalentCfg.ConsumeCount +end +--================ +--获取天赋消耗字符串 +--================ +function XRpgTowerTalent:GetCostStr() + local total = XDataCenter.RpgTowerManager.GetTeamMemberTalentPointsByCharacterId(self:GetCharacterId()) + local cost = self:GetCost() + local str + if total >= cost then + str = CS.XTextManager.GetText("RpgTowerLevelUpCostStr", total, cost) + else + str = CS.XTextManager.GetText("RpgTowerLevelUpCostNotEnoughStr", total, cost) + end + return str +end +--================ +--获取技能是否能解锁 +--================ +function XRpgTowerTalent:GetCanUnLock() + if self.CanActive then + return self.CanActive and (self:GetCost() <= XDataCenter.RpgTowerManager.GetTeamMemberTalentPointsByCharacterId(self:GetCharacterId())) + end + local layer = self:GetLayer() + if layer > 1 then + local preTalents = self.RCharacter:GetTalentsByLayer(layer - 1) + local preActive = false + for _, talent in pairs(preTalents) do + if talent:GetIsUnLock() then + preActive = true + break + end + end + local layerCfg = XRpgTowerConfig.GetTalentLayerCfgByLayerId(layer) + local canActive = XDataCenter.RpgTowerManager.GetCurrentLevel() >= layerCfg.NeedTeamLevel and preActive + self.CanActive = canActive + else + local layerCfg = XRpgTowerConfig.GetTalentLayerCfgByLayerId(layer) + local canActive = XDataCenter.RpgTowerManager.GetCurrentLevel() >= layerCfg.NeedTeamLevel + self.CanActive = canActive + end + return self.CanActive and (self:GetCost() <= XDataCenter.RpgTowerManager.GetTeamMemberTalentPointsByCharacterId(self:GetCharacterId())) +end +--================ +--检查角色是否足够改造点开启天赋 +--================ +function XRpgTowerTalent:CheckCostEnough() + local talentPoints = XDataCenter.RpgTowerManager.GetTeamMemberTalentPointsByCharacterId(self:GetCharacterId()) + return self:GetCost() <= talentPoints +end +--================ +--获取天赋是否已经到达要求队伍等级 +--================ +function XRpgTowerTalent:CheckNeedTeamLevel() + local layerCfg = XRpgTowerConfig.GetTalentLayerCfgByLayerId(self:GetLayer()) + return XDataCenter.RpgTowerManager.GetCurrentLevel() >= layerCfg.NeedTeamLevel +end +--================ +--解锁本天赋 +--================ +function XRpgTowerTalent:UnLock() + self.IsUnLock = true + if self.TalentCfg.ReplaceRobotId and self.TalentCfg.ReplaceRobotId > 0 then + self.RCharacter:ReplaceRobot(self.TalentCfg.ReplaceRobotId) + end + XEventManager.DispatchEvent(XEventId.EVENT_RPGTOWER_ON_TALENT_UNLOCK, self) +end +--================ +--锁上天赋(天赋重置时调用) +--================ +function XRpgTowerTalent:Lock() + self.IsUnLock = false + self.CanActive = false +end +return XRpgTowerTalent \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XScratchTicket/XScratchTicketActivityController.lua b/Resources/Scripts/XEntity/XScratchTicket/XScratchTicketActivityController.lua new file mode 100644 index 00000000..7cbd40b0 --- /dev/null +++ b/Resources/Scripts/XEntity/XScratchTicket/XScratchTicketActivityController.lua @@ -0,0 +1,187 @@ +-- 刮刮乐活动控制器 +local XScratchTicketActivityController = XClass(nil, "XScratchTicketActivityController") + +function XScratchTicketActivityController:Ctor(activityId) + self.ActivityCfg = XScratchTicketConfig.GetActivityConfigById(activityId) +end +--================ +--刷新活动数据 +--[[ +public class ScratchTicketActivityDb +{ +public int Id; --对应Activity表Id + +//已经开放的Grid +public List OpenGrid = new List(); + +//缓存配置表 +public int LuckNumber { get; set; } + +//选择哪一个开奖列 +public int SelectOpen { get; set; } + +public int GridCfgIndex { get; set; }--ScratchTicket表GridIds的序号,对应Grid表 + +public int CfgIndex { get; set; }--Activity表ScratchTicket数组的序号,对应ScratchTicket的Id +} + +public class ScratchTicketActivityOpenGridDb +{ +public int Index; +public int Num; +} +]] +--================ +function XScratchTicketActivityController:UpdateData(activityData) + if activityData.CfgIndex and activityData.CfgIndex >= 0 then + local ticketId = self:GetScratchTicketByIndex(activityData.CfgIndex + 1) --后端数组从0起,这里要+1 + if (not self.Ticket) and ticketId then + local ticketScript = require("XEntity/XScratchTicket/XScratchTicketStage") + self.Ticket = ticketScript.New(ticketId, self) + elseif self.Ticket and ticketId then + self.Ticket:UpdateTicket(ticketId) + end + if activityData.GridCfgIndex then + self.Ticket:UpdateGrid(activityData.GridCfgIndex + 1, activityData.LuckNumber) --后端数组从0起,这里要+1 + self.Ticket:RefreshGrid(activityData.OpenGrid, activityData.SelectOpen) + self.Ticket:RefreshResult(activityData.CorrectChose, activityData.Num) + end + end + self.TicketIndex = activityData.CfgIndex + 1 + self.IsWin = activityData.IsWin + self.ResetCount = activityData.ResetCount + self.ResetStatus = not self.IsWin and activityData.SelectOpen ~= nil +end +--============== +--预览九宫格格子 +--============== +function XScratchTicketActivityController:OpenGrid(gridIndex, gridNum) + self.Ticket:OpenGrid(gridIndex, gridNum) +end +--============== +--结束刮刮卡游戏 +--============== +function XScratchTicketActivityController:EndGame() + self.Ticket:EndGame() +end +--============== +--获取活动Id (Activity表Id) +--============== +function XScratchTicketActivityController:GetId() + return self.ActivityCfg and self.ActivityCfg.Id +end +--============== +--根据数组序号获取ScratchTicket数组对应序号的值 +--@param index:数组序号 +--============== +function XScratchTicketActivityController:GetScratchTicketByIndex(index) + return self.ActivityCfg and self.ActivityCfg.ScratchTicket[index] +end +--============== +--获取活动名称 +--============== +function XScratchTicketActivityController:GetName() + return self.ActivityCfg and self.ActivityCfg.Name +end +--============== +--获取活动TimeId +--============== +function XScratchTicketActivityController:GetTimeId() + return self.ActivityCfg and self.ActivityCfg.OpenTimeId +end +--============== +--获取活动门票道具Id +--============== +function XScratchTicketActivityController:GetSpendItemId() + return self.ActivityCfg and self.ActivityCfg.SpendItemId +end +--============== +--获取活动门票道具消耗数量 +--============== +function XScratchTicketActivityController:GetSpendItemNum() + return self.ActivityCfg and self.ActivityCfg.SpendItemCount +end +--============== +--获取活动门票道具Icon +--============== +function XScratchTicketActivityController:GetSpendItemIcon() + if self.SpendItemIcon then return self.SpendItemIcon end + self.SpendItemIcon = XDataCenter.ItemManager.GetItemIcon(self:GetSpendItemId()) + return self.SpendItemIcon +end +--============== +--获取能否重置(区分刮刮类型,true为黄金刮刮,false为普通刮刮) +--============== +function XScratchTicketActivityController:GetIsCanReset() + return self.ActivityCfg and self.ActivityCfg.IsCanReset +end +--============== +--获取可预览的次数 +--============== +function XScratchTicketActivityController:GetPreviewCount() + return self.ActivityCfg and self.ActivityCfg.PreviewCount +end + +function XScratchTicketActivityController:CheckPreviewFinish() + return self:GetPreviewCount() <= (self.Ticket and self.Ticket:GetOpenGridNum() or 0) +end +--============== +--获取当前活动是否已经获胜(仅黄金九宫有效) +--============== +function XScratchTicketActivityController:GetIsWin() + return self.IsWin +end + +function XScratchTicketActivityController:GetScratchTicket() + return self.ActivityCfg and self.ActivityCfg.ScratchTicket or {} +end + +function XScratchTicketActivityController:CheckIsLastTicket() + return self.TicketIndex and self.TicketIndex >= #self:GetScratchTicket() or false +end + +function XScratchTicketActivityController:GetGoldRewardItemId() + return self.ActivityCfg and self.ActivityCfg.GoldRewardItemId +end + +function XScratchTicketActivityController:GetGoldRewardItemNum() + return self.ActivityCfg and self.ActivityCfg.GoldRewardItemNum +end + +function XScratchTicketActivityController:GetGoldRewardItemIcon() + local itemId = self:GetGoldRewardItemId() + if not itemId then return nil end + return XDataCenter.ItemManager.GetItemIcon(itemId) +end +--============== +--获取当前刮刮卡对象 +--============== +function XScratchTicketActivityController:GetResetCount() + return self.ResetCount or 0 +end +--============== +--获取当前刮刮卡对象 +--============== +function XScratchTicketActivityController:GetTicket() + return self.Ticket +end +--============== +--获取活动开始时间戳 +--============== +function XScratchTicketActivityController:GetStartTime() + return XFunctionManager.GetStartTimeByTimeId(self:GetTimeId()) +end +--============== +--获取活动结束时间戳 +--============== +function XScratchTicketActivityController:GetEndTime() + return XFunctionManager.GetEndTimeByTimeId(self:GetTimeId()) +end +--============== +--获取黄金刮刮是否是重置状态 +--============== +function XScratchTicketActivityController:GetResetStatus() + return self.ResetStatus +end + +return XScratchTicketActivityController \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XScratchTicket/XScratchTicketStage.lua b/Resources/Scripts/XEntity/XScratchTicket/XScratchTicketStage.lua new file mode 100644 index 00000000..7ca159ae --- /dev/null +++ b/Resources/Scripts/XEntity/XScratchTicket/XScratchTicketStage.lua @@ -0,0 +1,176 @@ +-- 刮刮乐活动关卡 +local XScratchTicketStage = XClass(nil, "XScratchTicketStage") + +-- 关卡状态枚举 +XScratchTicketStage.PlayStatus = { + NotStart = 1, --未开始游戏 + Playing = 2, --正在游玩 + } + +function XScratchTicketStage:Ctor(id, activityController) + self.TicketCfg = XScratchTicketConfig.GetStageConfigById(id) + self.ActivityController = activityController + self.Status = XDataCenter.ScratchTicketManager.PlayStatus.NotStart +end + +function XScratchTicketStage:Reset() + self.GridCfg = nil + self.Status = XDataCenter.ScratchTicketManager.PlayStatus.NotStart + self.OpenGrids = {} + self.OpenNum = 0 + self.SelectChoseId = nil + self.ChoseCfg = nil + self.CorrectChose = nil +end +--=================== +--刷新刮刮配置 +--@param ticketId:刮刮配置ID +--=================== +function XScratchTicketStage:UpdateTicket(ticketId) + self.TicketCfg = XScratchTicketConfig.GetStageConfigById(ticketId) +end +--=================== +--刷新新的九宫格 +--@param gridId:九宫格表配置ID +--=================== +function XScratchTicketStage:UpdateGrid(gridId, luckNumber) + if not gridId then + self.GridCfg = nil + self.Status = XDataCenter.ScratchTicketManager.PlayStatus.NotStart + return + end + --self.GridCfg = XScratchTicketConfig.GetGridConfigById(self.TicketCfg.GridIds[gridId]) + self.LuckyNum = luckNumber +end +--=================== +--更新九宫格状态 +--@param openGrids:List +-- public int Index +-- public int Num +--@param selectChoseId:被选择的开奖列配置ID +--=================== +function XScratchTicketStage:RefreshGrid(openGrids, selectChoseId) + --更新预览格子状态 + self.OpenGrids = {} + self.OpenNum = 0 + if openGrids then + for index, grid in pairs(openGrids) do + self:OpenGrid(grid.Index + 1, grid.Num) + end + end + --更新开奖状态 + self.SelectChoseId = selectChoseId + if self.SelectChoseId and self.SelectChoseId > 0 then + self.ChoseCfg = XScratchTicketConfig.GetChoseConfigById(self.SelectChoseId) + self.Status = XDataCenter.ScratchTicketManager.PlayStatus.NotStart + else + self.ChoseCfg = nil + self.Status = XDataCenter.ScratchTicketManager.PlayStatus.Playing + end +end + +function XScratchTicketStage:RefreshResult(correctChose, gridNum) + --更新预览格子状态 + if gridNum and #gridNum > 0 then + self.OpenNum = 0 + for index, num in pairs(gridNum) do + self:OpenGrid(index, num) + end + end + self.CorrectChose = correctChose +end + +function XScratchTicketStage:OpenGrid(gridIndex, gridNum) + if not self.OpenGrids then self.OpenGrids = {} end + self.OpenGrids[gridIndex] = gridNum + self.OpenNum = self.OpenNum + 1 +end + +function XScratchTicketStage:EndGame() + self:Reset() +end + +function XScratchTicketStage:GetLuckyNum() + return self.LuckyNum +end + +function XScratchTicketStage:GetWinRewardItemId() + return self.TicketCfg and self.TicketCfg.WinRewardItemId +end + +function XScratchTicketStage:GetWinRewardItemIcon() + local itemId = self:GetWinRewardItemId() + if not itemId then return nil end + return XDataCenter.ItemManager.GetItemIcon(itemId) +end + +function XScratchTicketStage:GetWinRewardItemNum() + return self.TicketCfg and self.TicketCfg.WinRewardItemNum +end + +function XScratchTicketStage:GetLoseRewardItemId() + return self.TicketCfg and self.TicketCfg.LoseRewardItemId +end + +function XScratchTicketStage:GetLoseRewardItemNum() + return self.TicketCfg and self.TicketCfg.LoseRewardItemNum +end + +function XScratchTicketStage:GetLoseRewardItemIcon() + local itemId = self:GetLoseRewardItemId() + if not itemId then return nil end + return XDataCenter.ItemManager.GetItemIcon(itemId) +end + +function XScratchTicketStage:GetPlayStatus() + return self.Status +end + +function XScratchTicketStage:GetSelectChoseId() + return self.SelectChoseId +end + +function XScratchTicketStage:GetCorrectChose() + return self.CorrectChose or {} +end + +function XScratchTicketStage:CheckIsSelectCorrent() + local selectId = self:GetSelectChoseId() + for _, correct in pairs(self:GetCorrectChose()) do + if selectId == correct then + return true + end + end + return false +end +--================= +--根据九宫格序号获取九宫格数字 +--================= +function XScratchTicketStage:GetGridNumByGridIndex(gridIndex) + return self.OpenGrids and self.OpenGrids[gridIndex] or 0 +end +--================= +--检查对应序号九宫格是否被预览 +--================= +function XScratchTicketStage:CheckGridIsOpenByGridIndex(gridIndex) + return self.OpenGrids and (self.OpenGrids[gridIndex] ~= nil) or false +end +--================= +--获取九宫格已经预览的格子数 +--================= +function XScratchTicketStage:GetOpenGridNum() + return self.OpenNum or 0 +end +--================= +--获取幸运奖励ID +--================= +function XScratchTicketStage:GetWinRewardId() + return self.TicketCfg and self.TicketCfg.WinRewardId +end +--================= +--获取安慰奖励ID +--================= +function XScratchTicketStage:GetLoseRewardId() + return self.TicketCfg and self.TicketCfg.LoseRewardId +end +return XScratchTicketStage \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XSpringFestival/XSpringFestivalBoxGift.lua b/Resources/Scripts/XEntity/XSpringFestival/XSpringFestivalBoxGift.lua new file mode 100644 index 00000000..1ba1a2db --- /dev/null +++ b/Resources/Scripts/XEntity/XSpringFestival/XSpringFestivalBoxGift.lua @@ -0,0 +1,96 @@ +local XSpringFestivalBoxGift = XClass(nil, "XSpringFestivalBoxGift") + +local Default = { + SenderId = 0, + WordId = 0, + FromType = 0, + IsRecv = false, + Time = 0, + Name = "", + Level = 0, + HeadPortraitId = 0, + HeadFrameId = 0, +} + +function XSpringFestivalBoxGift:Ctor(data) + local temp = data or Default + + for k, v in pairs(temp) do + self[k] = v + end + + self.DefaultFriendInfo = XFriend.New(0, 0) +end + +function XSpringFestivalBoxGift:Update(data) + for k, v in pairs(data) do + self[k] = v + end +end + +function XSpringFestivalBoxGift:GetSenderId() + return self.SenderId or 0 +end + +function XSpringFestivalBoxGift:GetWordId() + return self.WordId or 0 +end + +function XSpringFestivalBoxGift:GetFromType() + return self.FromType or XSpringFestivalActivityConfigs.WordsGiftFromType.None +end + +function XSpringFestivalBoxGift:SetReceive(isReceive) + self.IsRecv = isReceive +end + +function XSpringFestivalBoxGift:IsReceive() + return self.IsRecv or false +end + +function XSpringFestivalBoxGift:GetTime() + return self.Time +end + +function XSpringFestivalBoxGift:GetFormatTime() + return XUiHelper.GetTime(self.Time, XUiHelper.TimeFormatType.MAIN) +end + +function XSpringFestivalBoxGift:GetFriendInfo() + return XDataCenter.SocialManager.GetFriendInfo(self.SenderId) or self.DefaultFriendInfo +end + +function XSpringFestivalBoxGift:GetFriendInfoFromGuild() + local memberList = XDataCenter.GuildManager.GetMemberList() + return memberList[self:GetSenderId()] +end + +function XSpringFestivalBoxGift:GetSenderName() + return self.Name +end + +function XSpringFestivalBoxGift:IsFriendOnline() + return true +end + +function XSpringFestivalBoxGift:GetFriendLastLoginTime() + return 0 +end + +function XSpringFestivalBoxGift:GetFriendLevel() + return self.Level +end + +function XSpringFestivalBoxGift:GetFriendIcon() + return self.HeadPortraitId +end + +function XSpringFestivalBoxGift:GetFriendHeadFrameId() + return self.HeadFrameId +end + +function XSpringFestivalBoxGift:GetFriendRemark() + return "" +end + +return XSpringFestivalBoxGift \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XSpringFestival/XSpringFestivalFriendRequestInfo.lua b/Resources/Scripts/XEntity/XSpringFestival/XSpringFestivalFriendRequestInfo.lua new file mode 100644 index 00000000..9546ed55 --- /dev/null +++ b/Resources/Scripts/XEntity/XSpringFestival/XSpringFestivalFriendRequestInfo.lua @@ -0,0 +1,76 @@ +local XSpringFestivalFriendRequestInfo = XClass(nil, "XSpringFestivalFriendRequestInfo") + +local Default = { + RequesterId = 0, + WordId = 0, + RequestTime = 0, + ExpireTime = 0, + FromType = 0, + HeadPortraitId = 0, + HeadFrameId = 0, + Level = 0, + Name = "", +} + +function XSpringFestivalFriendRequestInfo:Ctor(data) + local temp = data or Default + for k, v in pairs(temp) do + self[k] = v + end +end + +function XSpringFestivalFriendRequestInfo:UpdateData(data) + if not data then + return + end + for k, v in pairs(data) do + self[k] = v + end +end + +function XSpringFestivalFriendRequestInfo:GetRequesterId() + return self.RequesterId +end + +function XSpringFestivalFriendRequestInfo:GetWordId() + return self.WordId +end + +function XSpringFestivalFriendRequestInfo:GetRequestTime() + return self.RequestTime +end + +function XSpringFestivalFriendRequestInfo:GetExpireTime() + return self.ExpireTime +end + +function XSpringFestivalFriendRequestInfo:GetFromType() + return self.FromType +end + +function XSpringFestivalFriendRequestInfo:GetFriendIcon() + return self.HeadPortraitId +end + +function XSpringFestivalFriendRequestInfo:GetFriendHeadFrameId() + return self.HeadFrameId +end + +function XSpringFestivalFriendRequestInfo:IsExpire() + local now = XTime.GetServerNowTimestamp() + return now > self.ExpireTime +end + +function XSpringFestivalFriendRequestInfo:IsOnline() + return true +end + +function XSpringFestivalFriendRequestInfo:GetRequesterName() + return self.Name +end + +function XSpringFestivalFriendRequestInfo:GetLastLoginTime() + return 0 +end + +return XSpringFestivalFriendRequestInfo \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XStronghold/XStrongholdAssistantRecord.lua b/Resources/Scripts/XEntity/XStronghold/XStrongholdAssistantRecord.lua new file mode 100644 index 00000000..d21e9bbb --- /dev/null +++ b/Resources/Scripts/XEntity/XStronghold/XStrongholdAssistantRecord.lua @@ -0,0 +1,85 @@ +local type = type +local pairs = pairs +local mathCeil = math.ceil +local CsXTextManagerGetText = CS.XTextManager.GetText + +local Default = { + _Day = 0, --天数 + _LendCount = 0, --借出次数 + _LendDuration = 0, --借出时长(分钟) + _IsPause = false, --当天是否暂停结算 + _LendRewardValue = 0, --借用奖励数量 + _SetTimeRewardValue = 0, --设置时间奖励数量 +} + +local XStrongholdAssistantRecord = XClass(nil, "XStrongholdAssistantRecord") + +function XStrongholdAssistantRecord:Ctor(day) + for key, value in pairs(Default) do + if type(value) == "table" then + self[key] = {} + else + self[key] = value + end + end + + self._Day = day +end + +function XStrongholdAssistantRecord:UpdateData(recordInfo) + if XTool.IsTableEmpty(recordInfo) then return end + + self._LendCount = recordInfo.LendCount or self._LendCount + self._LendDuration = recordInfo.SetTime and mathCeil(recordInfo.SetTime / 60) or self._LendDuration--(s) + self._IsPause = recordInfo.IsStay and true or false + self._LendRewardValue = recordInfo.LendRewardValue or self._LendRewardValue + self._SetTimeRewardValue = recordInfo.SetTimeRewardValue or self._SetTimeRewardValue +end + +function XStrongholdAssistantRecord:GetDay() + return self._Day +end + +function XStrongholdAssistantRecord:IsPause() + return self._IsPause and true or false +end + +function XStrongholdAssistantRecord:GetLendCount() + return self._LendCount +end + +function XStrongholdAssistantRecord:GetLendRewardItemInfo() + local itemId = XStrongholdConfigs.GetCommonConfig("LendCharacterRewardItem") + return itemId, mathCeil(self._LendRewardValue) +end + +function XStrongholdAssistantRecord:GetLendRewardRecordString() + local itemId, itemCount = self:GetLendRewardItemInfo() + if itemCount == 0 then return "" end + + local itemName = XItemConfigs.GetItemNameById(itemId) + return XUiHelper.ConvertLineBreakSymbol(CsXTextManagerGetText("StrongholdSetAssistRecordLendCount", self._Day, self._LendCount, itemName, itemCount)) +end + +function XStrongholdAssistantRecord:GetLendDuration() + return self._LendDuration +end + +function XStrongholdAssistantRecord:GetDurationRewardItemInfo() + local itemId = XStrongholdConfigs.GetCommonConfig("SetAssistCharacterRewardItem") + return itemId, mathCeil(self._SetTimeRewardValue) +end + +function XStrongholdAssistantRecord:GetDurationRewardRecordString() + local itemId, itemCount = self:GetDurationRewardItemInfo() + if itemCount == 0 then return "" end + + local itemName = XItemConfigs.GetItemNameById(itemId) + return XUiHelper.ConvertLineBreakSymbol(CsXTextManagerGetText("StrongholdSetAssistRecordDuration", self._Day, self._LendDuration, itemName, itemCount)) +end + +function XStrongholdAssistantRecord:GetDelayRecordString() + return XUiHelper.ConvertLineBreakSymbol(CsXTextManagerGetText("StrongholdSetAssistRecordDelay", self._Day)) +end + +return XStrongholdAssistantRecord \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XStronghold/XStrongholdGroupInfo.lua b/Resources/Scripts/XEntity/XStronghold/XStrongholdGroupInfo.lua new file mode 100644 index 00000000..98d50f6d --- /dev/null +++ b/Resources/Scripts/XEntity/XStronghold/XStrongholdGroupInfo.lua @@ -0,0 +1,131 @@ +local XStrongholdStageData = require("XEntity/XStronghold/XStrongholdStageData") + +local type = type +local pairs = pairs +local ipairs = ipairs +local isNumberValid = XTool.IsNumberValid +local tableInsert = table.insert +local clone = XTool.Clone + +local Default = { + _Id = 0, --据点Id + _SupportId = 0, --支援方案Id + _StageIds = {}, --关卡Id列表 + _StageDatas = {}, --关卡数据 +} + +local XStrongholdGroupInfo = XClass(nil, "XStrongholdGroupInfo") + +function XStrongholdGroupInfo:Ctor(id) + for key, value in pairs(Default) do + if type(value) == "table" then + self[key] = {} + else + self[key] = value + end + end + + self._Id = id +end + +function XStrongholdGroupInfo:GetStageId(stageIndex) + return self._StageIds[stageIndex] or 0 +end + +function XStrongholdGroupInfo:GetStageDataByIndex(stageIndex) + local stageId = self:GetStageId(stageIndex) + return self:GetStageData(stageId) +end + +function XStrongholdGroupInfo:GetStageData(stageId) + if not isNumberValid(stageId) then + XLog.Error("XStrongholdGroupInfo:GetStageData error: stageId illegal, stageId is: ", stageId) + return + end + + local stageData = self._StageDatas[stageId] + if not stageData then + stageData = XStrongholdStageData.New(stageId) + self._StageDatas[stageId] = stageData + end + return stageData +end + +function XStrongholdGroupInfo:InitStageData(stageIds, stageBuffIdDic, supportId) + self._StageIds = {} + + for _, stageId in ipairs(stageIds or {}) do + local stageData = self:GetStageData(stageId) + tableInsert(self._StageIds, stageId) + + local buffId = stageBuffIdDic[stageId] + if isNumberValid(buffId) then + stageData:SetBuff(buffId) + end + end + + self._SupportId = supportId or 0 +end + +function XStrongholdGroupInfo:UpdateFinishStages(finishStageIds) + for _, stageId in pairs(finishStageIds or {}) do + local stageData = self:GetStageData(stageId) + stageData:SetFinished(true) + end +end + +function XStrongholdGroupInfo:ResetFinishStages() + for _, stageData in pairs(self._StageDatas) do + stageData:SetFinished(false) + end +end + +function XStrongholdGroupInfo:ResetFinishStage(stageId) + local stageData = self:GetStageData(stageId) + if stageData then + stageData:SetFinished(false) + end +end + +function XStrongholdGroupInfo:GetStageIds() + return clone(self._StageIds) +end + +function XStrongholdGroupInfo:GetSupportId() + return self._SupportId +end + +function XStrongholdGroupInfo:GetRequireTeamNum() + return #self._StageIds +end + +function XStrongholdGroupInfo:GetStageBuffId(stageIndex) + local stageData = self:GetStageDataByIndex(stageIndex) + return stageData and stageData:GetBuffId() or 0 +end + +function XStrongholdGroupInfo:IsStageFinished(stageIndex) + local stageData = self:GetStageDataByIndex(stageIndex) + return stageData and stageData:IsFinished() or false +end + +function XStrongholdGroupInfo:CheckHasStageFinished() + for _, stageData in pairs(self._StageDatas) do + if stageData:IsFinished() then + return true + end + end + return false +end + +function XStrongholdGroupInfo:GetNextFightStageIndex() + for stageIndex, stageId in ipairs(self._StageIds) do + local stageData = self:GetStageData(stageId) + if not stageData:IsFinished() then + return stageIndex + end + end + return 0 +end + +return XStrongholdGroupInfo \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XStronghold/XStrongholdMineRecord.lua b/Resources/Scripts/XEntity/XStronghold/XStrongholdMineRecord.lua new file mode 100644 index 00000000..0daea7f3 --- /dev/null +++ b/Resources/Scripts/XEntity/XStronghold/XStrongholdMineRecord.lua @@ -0,0 +1,47 @@ +local type = type +local pairs = pairs + +local Default = { + _Day = 0, --天数 + _MinerCount = 0, --矿工数量 + _MineralCount = 0, --矿石数量 + _TotalMineralCount = 0, --总产出矿石数量 +} + +local XStrongholdMineRecord = XClass(nil, "XStrongholdMineRecord") + +function XStrongholdMineRecord:Ctor(day) + for key, value in pairs(Default) do + if type(value) == "table" then + self[key] = {} + else + self[key] = value + end + end + + self._Day = day +end + +function XStrongholdMineRecord:UpdateData(minerCount, mineralCount, totalMineralCount) + self._MinerCount = minerCount or self._MinerCount + self._MineralCount = mineralCount or self._MineralCount + self._TotalMineralCount = totalMineralCount or self._TotalMineralCount +end + +function XStrongholdMineRecord:GetDay() + return self._Day +end + +function XStrongholdMineRecord:GetMinerCount() + return self._MinerCount +end + +function XStrongholdMineRecord:GetMineralCount() + return self._MineralCount +end + +function XStrongholdMineRecord:GetTotalMineralCount() + return self._TotalMineralCount +end + +return XStrongholdMineRecord \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XStronghold/XStrongholdPlugin.lua b/Resources/Scripts/XEntity/XStronghold/XStrongholdPlugin.lua new file mode 100644 index 00000000..af60ccc2 --- /dev/null +++ b/Resources/Scripts/XEntity/XStronghold/XStrongholdPlugin.lua @@ -0,0 +1,81 @@ +local type = type +local pairs = pairs +local ipairs = ipairs +local isNumberValid = XTool.IsNumberValid +local tableInsert = table.insert +local clone = XTool.Clone + +local Default = { + _Id = 0, --插件Id + _Count = 0, --已使用数量 + _CostElectric = 0, --总消耗电能 +} + +local XStrongholdPlugin = XClass(nil, "XStrongholdPlugin") + +function XStrongholdPlugin:Ctor(id) + for key, value in pairs(Default) do + if type(value) == "table" then + self[key] = {} + else + self[key] = value + end + end + + self._Id = id +end + +function XStrongholdPlugin:GetCostElectric() + return self._CostElectric +end + +function XStrongholdPlugin:GetCostElectricSingle() + return XStrongholdConfigs.GetPluginUseElectric(self._Id) +end + +function XStrongholdPlugin:GetAddAbility() + return self._Count * XStrongholdConfigs.GetPluginAddAbility(self._Id) +end + +function XStrongholdPlugin:SetCount(count) + self._Count = count or self._Count + + self._CostElectric = self._Count * self:GetCostElectricSingle() +end + +function XStrongholdPlugin:GetCount() + return self._Count +end + +function XStrongholdPlugin:GetCountLimit() + return XStrongholdConfigs.GetPluginCountLimit(self._Id) +end + +function XStrongholdPlugin:IsEmpty() + return not isNumberValid(self._Count) +end + +function XStrongholdPlugin:GetId() + return self._Id +end + +function XStrongholdPlugin:GetIcon() + return XStrongholdConfigs.GetPluginIcon(self._Id) +end + +function XStrongholdPlugin:GetName() + return XStrongholdConfigs.GetPluginName(self._Id) +end + +function XStrongholdPlugin:GetDesc() + return XStrongholdConfigs.GetPluginDesc(self._Id) +end + +function XStrongholdPlugin:Compare(cPlugin) + if not cPlugin then return false end + + return self._Id == cPlugin:GetId() + and self._Count == cPlugin:GetCount() +end + +return XStrongholdPlugin \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XStronghold/XStrongholdStageData.lua b/Resources/Scripts/XEntity/XStronghold/XStrongholdStageData.lua new file mode 100644 index 00000000..5c44cf77 --- /dev/null +++ b/Resources/Scripts/XEntity/XStronghold/XStrongholdStageData.lua @@ -0,0 +1,42 @@ +local type = type +local pairs = pairs +local isNumberValid = XTool.IsNumberValid + +local Default = { + _Id = 0, --关卡Id + _BuffId = 0, --环境BuffId + _IsFinished = false, --是否完成 +} + +local XStrongholdStageData = XClass(nil, "XStrongholdStageData") + +function XStrongholdStageData:Ctor(id) + for key, value in pairs(Default) do + if type(value) == "table" then + self[key] = {} + else + self[key] = value + end + end + + self._Id = id +end + +function XStrongholdStageData:SetBuff(buffId) + if not isNumberValid(buffId) then return end + self._BuffId = buffId +end + +function XStrongholdStageData:GetBuffId() + return self._BuffId +end + +function XStrongholdStageData:SetFinished(value) + self._IsFinished = value and true or false +end + +function XStrongholdStageData:IsFinished() + return self._IsFinished +end + +return XStrongholdStageData \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XStronghold/XStrongholdTeam.lua b/Resources/Scripts/XEntity/XStronghold/XStrongholdTeam.lua new file mode 100644 index 00000000..4a30fc55 --- /dev/null +++ b/Resources/Scripts/XEntity/XStronghold/XStrongholdTeam.lua @@ -0,0 +1,465 @@ +local XStrongholdTeamMember = require("XEntity/XStronghold/XStrongholdTeamMember") +local XStrongholdPlugin = require("XEntity/XStronghold/XStrongholdPlugin") + +local type = type +local pairs = pairs +local ipairs = ipairs +local IsNumberValid = XTool.IsNumberValid +local tableInsert = table.insert +local clone = XTool.Clone + +local Default = { + _Id = 0, --队伍Id + _CaptainPos = 1, --队长位 + _FirstPos = 1, --首发位 + _RuneId = 0, --符文Id + _SubRuneId = 0, --子符文Id + _TeamMemberDic = {}, --上阵成员信息 + _PluginDic = {}, --插件信息 +} + +local XStrongholdTeam = XClass(nil, "XStrongholdTeam") + +function XStrongholdTeam:Ctor(id) + self:Init(id) +end + +function XStrongholdTeam:Init(id) + for key, value in pairs(Default) do + if type(value) == "table" then + self[key] = {} + else + self[key] = value + end + end + + self._Id = id + self:InitPlugins() +end + +function XStrongholdTeam:GetId() + return self._Id +end + +function XStrongholdTeam:SetCaptainPos(captainPos) + self._CaptainPos = captainPos or self._CaptainPos +end + +function XStrongholdTeam:GetCaptainPos() + return self._CaptainPos +end + +function XStrongholdTeam:SetFirstPos(firstPos) + self._FirstPos = firstPos or self._FirstPos +end + +function XStrongholdTeam:GetFirstPos() + return self._FirstPos +end + +function XStrongholdTeam:CheckHasCaptain() + return not self:CheckPosEmpty(self._CaptainPos) +end + +function XStrongholdTeam:CheckHasFirstPos() + return not self:CheckPosEmpty(self._FirstPos) +end + +function XStrongholdTeam:GetCaptainSkillDesc() + if not self:CheckHasCaptain() then return "" end + local captainMember = self:GetMember(self._CaptainPos) + return captainMember and captainMember:GetCaptainSkillDesc() or "" +end + +function XStrongholdTeam:SetMemberForce(pos, member) + if not IsNumberValid(pos) then return end + member:SetPos(pos) + self._TeamMemberDic[pos] = member +end + +function XStrongholdTeam:GetMember(pos) + if not IsNumberValid(pos) then return end + local member = self._TeamMemberDic[pos] + if not member then + member = XStrongholdTeamMember.New(pos) + self._TeamMemberDic[pos] = member + end + return member +end + +function XStrongholdTeam:GetAllMembers() + local members = {} + for _, member in pairs(self._TeamMemberDic) do + tableInsert(members, member) + end + return members +end + +function XStrongholdTeam:GetInTeamMemberCount() + local count = 0 + for _, member in pairs(self._TeamMemberDic) do + if not member:IsEmpty() then + count = count + 1 + end + end + return count +end + +function XStrongholdTeam:GetShowCharacterIds() + local characterIds = {} + for pos, member in pairs(self._TeamMemberDic) do + local showCharacterId = member:GetShowCharacterId() + if IsNumberValid(showCharacterId) then + tableInsert(characterIds, showCharacterId) + end + end + return characterIds +end + +--是否已上阵相同型号角色 +function XStrongholdTeam:GetSameCharacterPos(characterId) + if not IsNumberValid(characterId) then return false end + characterId = XRobotManager.GetCharacterId(characterId) + + for pos, member in pairs(self._TeamMemberDic) do + local showCharacterId = member:GetShowCharacterId() + if showCharacterId == characterId then + return pos + end + end +end + +--是否已上阵支援角色 +function XStrongholdTeam:CheckExistAssitantCharacter() + for _, member in pairs(self._TeamMemberDic) do + if member:IsAssitant() then + return true + end + end + + return false +end + +function XStrongholdTeam:CheckInTeam(characterId, playerId) + if not IsNumberValid(characterId) then return false end + for _, member in pairs(self._TeamMemberDic) do + if member:IsInTeam(characterId, playerId) then + return true, member:GetPos() + end + end + return false, 0 +end + +function XStrongholdTeam:GetInTeamMemberByCharacterId(characterId, playerId) + if not IsNumberValid(characterId) then return end + for _, member in pairs(self._TeamMemberDic) do + if member:IsInTeam(characterId, playerId) then + return member + end + end +end + +function XStrongholdTeam:GetInTeamMemberIndex(characterId, playerId) + if not IsNumberValid(characterId) then return end + for memberIndex, member in pairs(self._TeamMemberDic) do + if member:IsInTeam(characterId, playerId) then + return memberIndex + end + end +end + +function XStrongholdTeam:GenarateTeamCharacterList(requireMemberNum) + local characterIdList = { 0, 0, 0 } + local characterIdToIsIsAssitantDic = {} + requireMemberNum = requireMemberNum or #characterIdList + for pos in pairs(characterIdList) do + if pos <= requireMemberNum then + local member = self:GetMember(pos) + local inTeamCharacterId = member and member:GetInTeamCharacterId() or 0 + characterIdList[pos] = inTeamCharacterId + characterIdToIsIsAssitantDic[inTeamCharacterId] = member:IsAssitant() + end + end + return characterIdList, characterIdToIsIsAssitantDic +end + +function XStrongholdTeam:SetMember(pos, characterId, playerId, robotId, ability) + if not IsNumberValid(pos) then return end + + local member = self:GetMember(pos) + if IsNumberValid(robotId) then + member:SetRobotId(robotId) + else + member:SetCharacterId(characterId, playerId)--服务端他非要发kt. + end + member:SetAbility(ability) +end + +--检查队伍中是否已经存在其他类型的角色(构造体/授格者) +function XStrongholdTeam:ExistDifferentCharacterType(characterType) + for _, member in pairs(self._TeamMemberDic) do + if not member:IsEmpty() then + local inCharacterType = member:GetCharacterType() + if inCharacterType and characterType and inCharacterType ~= characterType then + return true + end + end + end + return false +end + +function XStrongholdTeam:InitPlugins() + self._PluginDic = {} + local pluginIds = XStrongholdConfigs.GetPluginIds() + for _, pluginId in ipairs(pluginIds) do + self._PluginDic[pluginId] = XStrongholdPlugin.New(pluginId) + end +end + +function XStrongholdTeam:GetAllPlugins() + local plugins = {} + for _, plugin in pairs(self._PluginDic) do + tableInsert(plugins, plugin) + end + return plugins +end + +function XStrongholdTeam:GetPlugin(pluginId) + local plugin = self._PluginDic[pluginId] + if not plugin then + XLog.Error("XStrongholdTeam:GetPlugin error: 插件Id与服务端不同步, pluginId is: ", pluginId, self._PluginDic) + return + end + return plugin +end + +function XStrongholdTeam:SetPlugin(pluginId, count) + local plugin = self:GetPlugin(pluginId) + plugin:SetCount(count) +end + +function XStrongholdTeam:IsAllPluginEmpty() + for _, plugin in pairs(self._PluginDic) do + if not plugin:IsEmpty() then + return false + end + end + return true +end + +function XStrongholdTeam:GetUseElectricEnergy() + local useElectric = 0 + for _, plugin in pairs(self._PluginDic) do + useElectric = useElectric + plugin:GetCostElectric() + end + return useElectric +end + +--获取已上阵成员总战力 +function XStrongholdTeam:GetTeamAbility() + local addAbility = 0 + for pos in pairs(self._TeamMemberDic) do + addAbility = addAbility + self:GetTeamMemberAbility(pos) + end + return addAbility +end + +--获取已激活插件额外增加战力 +function XStrongholdTeam:GetPluginAddAbility() + local addAbility = 0 + for _, plugin in pairs(self._PluginDic) do + addAbility = addAbility + plugin:GetAddAbility() + end + return addAbility +end + +--队伍内成员战力 = 成员战力 + 已激活插件额外增加战力 +function XStrongholdTeam:GetTeamMemberAbility(pos) + local extraAbility = self:GetPluginAddAbility() + local member = self:GetMember(pos) + return extraAbility + member:GetAbility() +end + +function XStrongholdTeam:CheckPosEmpty(pos) + local member = self:GetMember(pos) + return member:IsEmpty() +end + +function XStrongholdTeam:CheckTeamEveryMemberAbility(requireAbility, requireTeamMemberNum) + requireTeamMemberNum = requireTeamMemberNum or 0 + for pos = 1, requireTeamMemberNum do + local ability = self:GetTeamMemberAbility(pos) + if ability < requireAbility then + return false + end + end + return true +end + +--按照队伍要求人数裁剪多余的队员 +function XStrongholdTeam:ClipMembers(requireTeamMember) + local inTeamCount = 0 + local tmpMembers = {} + for pos, member in pairs(self._TeamMemberDic) do + if not member:IsEmpty() then + inTeamCount = inTeamCount + 1 + end + + if pos > requireTeamMember then + -- if inTeamCount > requireTeamMember then + --队伍人数超出上限,直接裁员 + self._TeamMemberDic[pos] = nil + -- else + --队伍人数未超出上限,记录下来并移动到前面空的位置 + -- tableInsert(tmpMembers, member) + -- self._TeamMemberDic[pos] = nil + -- end + end + + end + + --将未超出上限但位置不对的队员移动到前面空的位置 + -- local nextEmptyPos = 0 + -- for pos = 1, requireTeamMember do + -- local member = self._TeamMemberDic[pos] + -- if not member or member:IsEmpty() then + -- nextEmptyPos = pos + -- break + -- end + -- end + -- if IsNumberValid(pos) then + -- for _, member in pairs(tmpMembers) do + -- self._TeamMemberDic[nextEmptyPos] = member + -- member:SetPos(nextEmptyPos) + -- nextEmptyPos = nextEmptyPos + 1 + -- end + -- end + --如队长/首发位为空,默认设置为1号位 + -- if self:CheckPosEmpty(self._CaptainPos) then + -- self._CaptainPos = 1 + -- end + -- if self:CheckPosEmpty(self._FirstPos) then + -- self._FirstPos = 1 + -- end +end + +--剔除不属于自己拥有角色的队员 +function XStrongholdTeam:KickOutOtherMembers() + for _, member in pairs(self._TeamMemberDic) do + if not member:IsOwn() then + member:ResetCharacters() + end + end +end + +--剔除已经失效的援助角色 +function XStrongholdTeam:KickOutInvalidMembers() + for _, member in pairs(self._TeamMemberDic) do + if not member:CheckValid() then + member:ResetCharacters() + end + end +end + +--清空队伍 +function XStrongholdTeam:Clear() + for _, member in pairs(self._TeamMemberDic) do + member:ResetCharacters() + end +end + +function XStrongholdTeam:Reset() + local oldId = self._Id + self:Init(oldId) +end + +function XStrongholdTeam:Compare(cTeam) + if not cTeam then return false end + + if self:GetCaptainPos() ~= cTeam:GetCaptainPos() then + return false + end + + if self:GetFirstPos() ~= cTeam:GetFirstPos() then + return false + end + + local runeId, subRuneId = self:GetRune() + local cRuneId, cSubRuneId = cTeam:GetRune() + if runeId ~= cRuneId + or subRuneId ~= cSubRuneId + then + return false + end + + for pos, member in pairs(self._TeamMemberDic) do + local cMember = cTeam:GetMember(pos) + if not member:Compare(cMember) then + return false + end + end + + for pluginId, plugin in pairs(self._PluginDic) do + local cPlugin = cTeam:GetPlugin(pluginId) + if not plugin:Compare(cPlugin) then + return false + end + end + + return true +end + +--设置符文 +function XStrongholdTeam:SetRune(runeId, subRuneId) + local oldRuneId, oldSubRuneId = 0, 0 + if XTool.IsNumberValid(runeId) then + oldRuneId = self._RuneId + self._RuneId = runeId + end + if XTool.IsNumberValid(subRuneId) then + oldSubRuneId = self._SubRuneId + self._SubRuneId = subRuneId + end + XDataCenter.StrongholdManager.TakeOffRune(oldRuneId, oldSubRuneId) + XDataCenter.StrongholdManager.UseRune(runeId, subRuneId, self._Id) +end + +--清空符文 +function XStrongholdTeam:ClearRune() + XDataCenter.StrongholdManager.TakeOffRune(self._RuneId, self._SubRuneId) + self._RuneId = 0 + self._SubRuneId = 0 +end + +--获取符文 +function XStrongholdTeam:GetRune() + return self._RuneId, self._SubRuneId +end + +--是否装备符文 +function XStrongholdTeam:HasRune() + return XTool.IsNumberValid(self._RuneId) + and XTool.IsNumberValid(self._SubRuneId) +end + +--是否装备该符文大类 +function XStrongholdTeam:IsRuneUsing(runeId) + return XTool.IsNumberValid(self._RuneId) + and self._RuneId == runeId +end + +--获取符文描述 +function XStrongholdTeam:GetRuneDesc() + local runeId = self._RuneId + if not XTool.IsNumberValid(runeId) then return "" end + return XStrongholdConfigs.GetRuneBrief(runeId) +end + +--获取符文颜色 +function XStrongholdTeam:GetRuneColor() + local runeId = self._RuneId + if not XTool.IsNumberValid(runeId) then return "" end + return XStrongholdConfigs.GetRuneColor(runeId) +end + +return XStrongholdTeam \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XStronghold/XStrongholdTeamMember.lua b/Resources/Scripts/XEntity/XStronghold/XStrongholdTeamMember.lua new file mode 100644 index 00000000..a62f5aa9 --- /dev/null +++ b/Resources/Scripts/XEntity/XStronghold/XStrongholdTeamMember.lua @@ -0,0 +1,254 @@ +local type = type +local pairs = pairs +local ipairs = ipairs +local tableInsert = table.insert +local IsNumberValid = XTool.IsNumberValid +local clone = XTool.Clone + +local Default = { + _Pos = 0, --队伍中的位置 + _CharacterId = 0, --角色Id + _RobotId = 0, --机器人Id + _PlayerId = 0, --玩家Id(援助角色) + _OthersAbility = 0, --角色战力(援助角色) +} + +local XStrongholdTeamMember = XClass(nil, "XStrongholdTeamMember") + +function XStrongholdTeamMember:Ctor(pos) + for key, value in pairs(Default) do + if type(value) == "table" then + self[key] = {} + else + self[key] = value + end + end + + self._Pos = pos +end + +function XStrongholdTeamMember:GetPos() + return self._Pos +end + +function XStrongholdTeamMember:SetPos(pos) + if not IsNumberValid(pos) then return end + self._Pos = pos +end + +function XStrongholdTeamMember:GetCharacterId() + return self._CharacterId +end + +function XStrongholdTeamMember:GetRobotId() + return self._RobotId +end + +function XStrongholdTeamMember:GetPlayerId() + return self._PlayerId +end + +function XStrongholdTeamMember:GetOthersPlayerId() + if self._PlayerId == XPlayer.Id then return 0 end + return self:GetPlayerId() +end + +function XStrongholdTeamMember:GetCaptainSkillDesc() + if self:IsEmpty() then return "" end + + if self:IsAssitant() then + return XDataCenter.CharacterManager.GetCaptainSkillDesc(self._CharacterId, true) + elseif self:IsRobot() then + return XRobotManager.GetRobotCaptainSkillDesc(self._RobotId) + else + return XDataCenter.CharacterManager.GetCaptainSkillDesc(self._CharacterId) + end +end + +--获取队伍中实际上阵的CharacterId/RobotId +function XStrongholdTeamMember:GetInTeamCharacterId() + if self:IsAssitant() then + return self:GetCharacterId() + elseif self:IsRobot() then + return self:GetRobotId() + else + return self:GetCharacterId() + end +end + +--获取展示用的CharacterId(RobotId自转换) +function XStrongholdTeamMember:GetShowCharacterId() + if self:IsAssitant() then + return self:GetCharacterId() + elseif self:IsRobot() then + return XRobotManager.GetCharacterId(self:GetRobotId()) + else + return self:GetCharacterId() + end +end + +function XStrongholdTeamMember:GetCharacterType() + local showCharacterId = self:GetShowCharacterId() + if not IsNumberValid(showCharacterId) then return end + return XCharacterConfigs.GetCharacterType(showCharacterId) +end + +--上阵 +function XStrongholdTeamMember:SetInTeam(characterId, playerId) + if XRobotManager.CheckIsRobotId(characterId) then + self:SetRobotId(characterId) + else + self:SetCharacterId(characterId, playerId) + end +end + +--下阵 +function XStrongholdTeamMember:KickOutTeam() + self:ResetCharacters() +end + +function XStrongholdTeamMember:SetCharacterId(characterId, playerId) + if not characterId then return end + + --清空其他角色信息 + self:ResetCharacters() + + self._CharacterId = characterId or 0 + self._PlayerId = playerId or XPlayer.Id + + if playerId ~= XPlayer.Id then + self._OthersAbility = XDataCenter.StrongholdManager.GetAssistantPlayerAbiility(playerId) + end +end + +function XStrongholdTeamMember:SetRobotId(robotId) + if not robotId then return end + + --清空其他角色信息 + self:ResetCharacters() + + self._RobotId = robotId +end + +function XStrongholdTeamMember:SetAbility(ability) + self._OthersAbility = ability or self._OthersAbility +end + +function XStrongholdTeamMember:GetAbility() + if self:IsEmpty() then return 0 end + + local ability = 0 + if self:IsAssitant() then + ability = self._OthersAbility + elseif self:IsRobot() then + ability = XRobotManager.GetRobotAbility(self._RobotId) + else + ability = XDataCenter.CharacterManager.GetCharacterAbilityById(self._CharacterId) + end + + return math.ceil(ability) +end + +--是否为援助角色 +function XStrongholdTeamMember:IsAssitant() + if self:IsEmpty() then return false end + return self._PlayerId ~= 0 and self._PlayerId ~= XPlayer.Id +end + +--是否为试玩角色 +function XStrongholdTeamMember:IsRobot() + if self:IsEmpty() then return false end + return self._RobotId ~= 0 +end + +--是否为自己拥有的角色 +function XStrongholdTeamMember:IsOwn() + if self:IsEmpty() then return false end + return not self:IsRobot() and not self:IsAssitant() +end + +--是否为授格者 +function XStrongholdTeamMember:IsIsomer() + if self:IsEmpty() then return false end + + if self:IsAssitant() then + return false + elseif self:IsRobot() then + return XRobotManager.IsIsomer(self._RobotId) + else + return XCharacterConfigs.IsIsomer(self._CharacterId) + end +end + +--援助角色是否有效 +function XStrongholdTeamMember:CheckAssitantValid() + if not self:IsAssitant() then return true end + return XDataCenter.StrongholdManager.CheckAssitantValid(self._PlayerId, self._CharacterId) +end + +--角色是否有效 +function XStrongholdTeamMember:CheckValid() + if self:IsAssitant() then + return self:CheckAssitantValid() + end + return true +end + +--是否为空 +function XStrongholdTeamMember:IsEmpty() + return self._CharacterId == 0 and self._RobotId == 0 +end + +function XStrongholdTeamMember:IsInTeam(characterId, playerId) + if not IsNumberValid(characterId) then return false end + if not self:CheckPlayerId(playerId) then return false end + return self:GetInTeamCharacterId() == characterId +end + +function XStrongholdTeamMember:CheckPlayerId(playerId) + if self:IsRobot() then return true end + playerId = IsNumberValid(playerId) and playerId or XPlayer.Id + return self._PlayerId == playerId +end + +function XStrongholdTeamMember:ResetCharacters() + self._CharacterId = 0 + self._RobotId = 0 + self._PlayerId = 0 +end + +function XStrongholdTeamMember:GetSmallHeadIcon() + if self:IsEmpty() then return "" end + + if self:IsAssitant() then + return XDataCenter.CharacterManager.GetCharSmallHeadIcon(self._CharacterId) + elseif self:IsRobot() then + return XRobotManager.GetRobotSmallHeadIcon(self._RobotId) + else + return XDataCenter.CharacterManager.GetCharSmallHeadIcon(self._CharacterId) + end +end + +function XStrongholdTeamMember:GetCharacterName() + if self:IsEmpty() then return "" end + + if self:IsAssitant() then + return XCharacterConfigs.GetCharacterName(self._CharacterId) + elseif self:IsRobot() then + local characterId = XRobotManager.GetCharacterId(self._RobotId) + return XCharacterConfigs.GetCharacterName(characterId) + else + return XCharacterConfigs.GetCharacterName(self._CharacterId) + end +end + +function XStrongholdTeamMember:Compare(cMember) + if not cMember then return false end + + return self._CharacterId == cMember:GetCharacterId() + and self._RobotId == cMember:GetRobotId() + and self._PlayerId == cMember:GetPlayerId() + and self._Pos == cMember:GetPos() +end + +return XStrongholdTeamMember \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XSuperTower/Function/XSuperTowerFunction.lua b/Resources/Scripts/XEntity/XSuperTower/Function/XSuperTowerFunction.lua new file mode 100644 index 00000000..123be763 --- /dev/null +++ b/Resources/Scripts/XEntity/XSuperTower/Function/XSuperTowerFunction.lua @@ -0,0 +1,88 @@ +--=========================== +--超级爬塔 特权 对象 +--模块负责:吕天元 +--=========================== +local XSuperTowerFunction = XClass(nil, "XSuperTowerFunction") + +function XSuperTowerFunction:Ctor(funcCfg, manager) + self.FuncManager = manager + self.FuncCfg = funcCfg +end +--================= +--获取特权键值 +--================= +function XSuperTowerFunction:GetKey() + return self.FuncCfg and self.FuncCfg.Key +end +--================= +--获取特权名称 +--================= +function XSuperTowerFunction:GetName() + return self.FuncCfg and self.FuncCfg.Name +end +--================= +--获取特权解锁的条件ID +--================= +function XSuperTowerFunction:GetConditionId() + return XSuperTowerConfigs.GetBaseConfigByKey(self:GetKey()) or 0 +end +--================= +--检查特权是否解锁 +--================= +function XSuperTowerFunction:CheckIsUnlock() + return XConditionManager.CheckCondition(self:GetConditionId()) +end +--================= +--获取特权图标 +--================= +function XSuperTowerFunction:GetIcon() + return self.FuncCfg and self.FuncCfg.Icon +end +--================= +--获取特权解锁条件的文字叙述 +--================= +function XSuperTowerFunction:GetUnLockDescription() + return self.FuncCfg and self.FuncCfg.UnLockDescription +end +--================= +--获取特权的序号 +--================= +function XSuperTowerFunction:GetOrder() + return self.FuncCfg and self.FuncCfg.Order +end +--================= +--获取特权所在的主题周 +--================= +function XSuperTowerFunction:GetThemeWeek() + return self.FuncCfg and self.FuncCfg.ThemeWeek +end +--================= +--获取解锁特权的道具ID +--================= +function XSuperTowerFunction:GetItemId() + return self.FuncCfg and self.FuncCfg.ItemId +end +--================= +--获取特权解锁的提示叙述 +--================= +function XSuperTowerFunction:GetLockTips() + return self.FuncCfg and self.FuncCfg.LockTips +end +--================= +--设置特权解锁事件 +--================= +function XSuperTowerFunction:SetUnLockEvent() + self.UnLockOnStart = self:CheckIsUnlock() +end +--================= +--解锁时 +--@return 是否是新解锁 +--================= +function XSuperTowerFunction:CheckNewUnlock() + if self.UnLockOnStart then return false end + local result = self:CheckIsUnlock() + if result then self.UnLockOnStart = true end + return result +end + +return XSuperTowerFunction \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XSuperTower/Function/XSuperTowerFunctionManager.lua b/Resources/Scripts/XEntity/XSuperTower/Function/XSuperTowerFunctionManager.lua new file mode 100644 index 00000000..81ffa7c6 --- /dev/null +++ b/Resources/Scripts/XEntity/XSuperTower/Function/XSuperTowerFunctionManager.lua @@ -0,0 +1,96 @@ +--=========================== +--超级爬塔 特权 管理器 +--模块负责:吕天元 +--=========================== +local XSuperTowerFunctionManager = XClass(nil, "XSuperTowerFunctionManager") + +function XSuperTowerFunctionManager:Ctor(rootManager) + self.ActivityManager = rootManager + self.UnlockList = {} + self:Init() +end +--================= +--初始化 +--================= +function XSuperTowerFunctionManager:Init() + local funcDic = XSuperTowerConfigs.GetAllFunctionCfgs() + local script = require("XEntity/XSuperTower/Function/XSuperTowerFunction") + self.Functions = {} --使用键值的特权字典 + self.FunctionByOrder = {} --使用序号的特权列表 + for key, cfg in pairs(funcDic) do + local func = script.New(cfg, self) + self.Functions[key] = func + local order = cfg.Order + self.FunctionByOrder[order] = func + end +end +--================= +--初始化最新特权的序号 +--================= +function XSuperTowerFunctionManager:InitFunctionNewIndex() + self.NewIndex = -1 + for order, func in pairs(self.FunctionByOrder) do + --若最新未解锁序号未赋值或大于检查中的未解锁特权序号,则赋值 + if not func:CheckIsUnlock() and ((self.NewIndex == -1) or (self.NewIndex > order)) then + self.NewIndex = order + end + end +end +--================= +--设置特权道具数量变化监听 +--================= +function XSuperTowerFunctionManager:SetUnLockEvent() + for _, func in pairs(self.Functions) do + func:SetUnLockEvent() + end +end + +function XSuperTowerFunctionManager:CheckUnLock() + for _, func in pairs(self.Functions) do + if func:CheckNewUnlock() then + self:AddUnlockFunction(func) + end + end + self:InitFunctionNewIndex() +end +--================= +--根据特权Key获取特权对象 +--@param key:特权键值 XSuperTowerManager.FunctionName +--================= +function XSuperTowerFunctionManager:GetFunctionByKey(key) + return self.Functions[key] +end +--================= +--根据特权Key检查特权是否解锁 +--@param key:特权键值 XSuperTowerManager.FunctionName +--================= +function XSuperTowerFunctionManager:CheckFunctionUnlockByKey(key) + if not self.Functions[key] then + return false + else + return self.Functions[key]:CheckIsUnlock() + end +end +--================= +--获取最新未解锁的特权对象 +--================= +function XSuperTowerFunctionManager:GetTheNewFunction() + if not self.NewIndex then self:InitFunctionNewIndex() end + if self.NewIndex == -1 then return nil end --全解锁的情况或初始化失败的情况 + return self.FunctionByOrder[self.NewIndex] +end +--================= +--把解锁特权对象入队解锁队列 +--================= +function XSuperTowerFunctionManager:AddUnlockFunction(func) + table.insert(self.UnlockList, func) +end +--================= +--获取解锁队列中的第一个特权对象 +--================= +function XSuperTowerFunctionManager:GetUnlockList() + local list = self.UnlockList + self.UnlockList = {} + return list +end +return XSuperTowerFunctionManager \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XSuperTower/Plugin/XSuperTowerPlugin.lua b/Resources/Scripts/XEntity/XSuperTower/Plugin/XSuperTowerPlugin.lua new file mode 100644 index 00000000..c0696c58 --- /dev/null +++ b/Resources/Scripts/XEntity/XSuperTower/Plugin/XSuperTowerPlugin.lua @@ -0,0 +1,84 @@ +local XSuperTowerPlugin = XClass(nil, "XSuperTowerPlugin") + +function XSuperTowerPlugin:Ctor(id) + self.Config = XSuperTowerConfigs.GetPluginCfgById(id) + self.Count = 0 +end + +function XSuperTowerPlugin:InitWithServerData(data) + self:UpdateCount(data.Count) +end + +function XSuperTowerPlugin:UpdateWithServerData(data) + self:UpdateCount(data.Count) +end + +function XSuperTowerPlugin:GetCount() + return self.Count +end + +function XSuperTowerPlugin:UpdateCount(value) + self.Count = value +end + +function XSuperTowerPlugin:GetId() + return self.Config.Id +end + +function XSuperTowerPlugin:GetName() + return self.Config.Name +end + +function XSuperTowerPlugin:GetDesc() + return self.Config.Description +end + +function XSuperTowerPlugin:GetQualityIcon() + return XSuperTowerConfigs.GetStarIconByQuality(self.Config.Quality) +end + +function XSuperTowerPlugin:GetQualityBg() + return XSuperTowerConfigs.GetStarBgByQuality(self.Config.Quality) +end + +function XSuperTowerPlugin:GetIcon() + return self.Config.Icon +end + +function XSuperTowerPlugin:GetFightEventId() + return self.Config.FightEventId +end + +function XSuperTowerPlugin:GetCharacterId() + return self.Config.CharacterId +end + +function XSuperTowerPlugin:GetCapacity() + return self.Config.Capacity * self.Count +end + +function XSuperTowerPlugin:GetStar() + return self.Config.Quality +end + +function XSuperTowerPlugin:GetQuality() + return self.Config.Quality +end + +function XSuperTowerPlugin:GetResolveId() + return self.Config.ResolveId +end + +function XSuperTowerPlugin:GetResolveCount() + return self.Config.ResolveCount +end + +function XSuperTowerPlugin:GetExp() + return self.Config.Exp +end + +function XSuperTowerPlugin:GetPriority() + return self.Config.Priority +end + +return XSuperTowerPlugin \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XSuperTower/Role/XSuperTowerRole.lua b/Resources/Scripts/XEntity/XSuperTower/Role/XSuperTowerRole.lua new file mode 100644 index 00000000..e79c3668 --- /dev/null +++ b/Resources/Scripts/XEntity/XSuperTower/Role/XSuperTowerRole.lua @@ -0,0 +1,173 @@ +local XSuperTowerPlugin = require("XEntity/XSuperTower/Plugin/XSuperTowerPlugin") +local XSuperTowerRole = XClass(nil, "XSuperTowerRole") + +-- rawData : XCharacter | XRobot +function XSuperTowerRole:Ctor(rawData) + -- XCharacter | XRobot + self.RawData = rawData + -- 超限解锁插件 + self.TransfinitePlugin = nil + self.Id = self.RawData.Id +end + +function XSuperTowerRole:GetId() + return self.RawData.Id +end + +-- 获取超级爬塔生命百分比(0-100) +function XSuperTowerRole:GetHpLeft() + return XDataCenter.SuperTowerManager.GetRoleManager():GetTierRoleHpLeft(self:GetCharacterId()) +end + +-- 获取超限等级 +function XSuperTowerRole:GetSuperLevel() + return XDataCenter.SuperTowerManager.GetRoleManager():GetTransfiniteLevel(self:GetCharacterId()) +end + +function XSuperTowerRole:GetIsRobot() + return XRobotManager.CheckIsRobotId(self.RawData.Id) +end + +function XSuperTowerRole:GetCurrentExp() + return XDataCenter.SuperTowerManager.GetRoleManager():GetTransfiniteExp(self:GetCharacterId()) +end + +function XSuperTowerRole:GetMaxExp(level) + if level == nil then level = self:GetSuperLevel() end + if level <= 0 then return 1 end + local levelConfig = XSuperTowerConfigs.GetCharacterLevelConfig(self:GetCharacterId() + , math.min(level + 1, self:GetMaxSuperLevel())) + if levelConfig then + return levelConfig.UpExp + end + levelConfig = XSuperTowerConfigs.GetCharacterLevelConfig(self:GetCharacterId(), level) + return levelConfig.UpExp +end + +-- 获取是否为特典中 +function XSuperTowerRole:GetIsInDult() + local superTowerManager = XDataCenter.SuperTowerManager + -- 特典权限没开启不需要处理 + if not superTowerManager.CheckFunctionUnlockByKey(superTowerManager.FunctionName.BonusChara) then + return false + end + local result, _ = superTowerManager.GetRoleManager():GetCharacterIsInDultAndConfig(self:GetCharacterId()) + return result +end + +function XSuperTowerRole:GetTransfinitePlugin() + if self.TransfinitePlugin == nil then + local pluginConfig = XSuperTowerConfigs.GetCharacterPluginConfig(self:GetCharacterId()) + if not pluginConfig then return end + self.TransfinitePlugin = XSuperTowerPlugin.New(pluginConfig.ActivatePlugin) + end + return self.TransfinitePlugin +end + +function XSuperTowerRole:GetTransfinitePluginName() + local pluginConfig = XSuperTowerConfigs.GetCharacterPluginConfig(self:GetCharacterId()) + if not pluginConfig then return "" end + return pluginConfig.Name +end + +function XSuperTowerRole:GetTransfinitePluginId() + local pluginConfig = XSuperTowerConfigs.GetCharacterPluginConfig(self:GetCharacterId()) + if not pluginConfig then return -1 end + return pluginConfig.ActivatePlugin +end + +function XSuperTowerRole:GetTransfinitePluginDesc() + local pluginConfig = XSuperTowerConfigs.GetCharacterPluginConfig(self:GetCharacterId()) + if not pluginConfig then return "" end + return pluginConfig.Desc +end + +function XSuperTowerRole:GetTransfinitePluginIsActive() + local pluginId = XDataCenter.SuperTowerManager.GetRoleManager():GetTransfinitePluginId(self:GetCharacterId()) + return pluginId ~= nil +end + +function XSuperTowerRole:GetCharacterViewModel() + return self.RawData:GetCharacterViewModel() +end + +function XSuperTowerRole:GetCharacterType() + return self.RawData:GetCharacterViewModel():GetCharacterType() +end + +function XSuperTowerRole:GetCharacterId() + if XRobotManager.CheckIsRobotId(self.RawData.Id) then + local robotConfig = XRobotManager.GetRobotTemplate(self.RawData.Id) + return robotConfig.CharacterId + else + return self.RawData.Id + end +end + +function XSuperTowerRole:GetAbility(level) + local superTowerManager = XDataCenter.SuperTowerManager + if level == nil then level = self:GetSuperLevel() end + local ablity = 0 + -- 要求超限权限开启才会显示这部分战力 + if level > 0 + and superTowerManager.CheckFunctionUnlockByKey(superTowerManager.FunctionName.Transfinite) then + local levelConfig = XSuperTowerConfigs.GetCharacterLevelConfig(self:GetCharacterId(), level) + ablity = levelConfig.Ability + end + return ablity + self:GetCharacterViewModel():GetAbility() +end + +function XSuperTowerRole:GetMaxSuperLevel() + return XSuperTowerConfigs.GetCharacterMaxLevel(self:GetCharacterId()) +end + +-- attributeType : XNpcAttribType +function XSuperTowerRole:GetAttributeValue(attributeType, level) + if level == nil then level = self:GetSuperLevel() end + if level <= 0 then + return 0 + end + local levelConfig = XSuperTowerConfigs.GetCharacterLevelConfig(self:GetCharacterId(), level) + for i, attributeId in ipairs(levelConfig.AttributeId) do + if attributeId == attributeType then + return levelConfig.AttributeValue[i] + end + end + return 0 +end + +function XSuperTowerRole:GetSmallHeadIcon() + if self:GetIsRobot() then + return XRobotManager.GetRobotSmallHeadIcon(self.RawData.Id) + else + return XDataCenter.CharacterManager.GetCharSmallHeadIcon(self.RawData.Id) + end +end + +function XSuperTowerRole:GetCaptainSkillDesc() + if self:GetIsRobot() then + return XRobotManager.GetRobotCaptainSkillDesc(self.RawData.Id) + else + return XDataCenter.CharacterManager.GetCaptainSkillDesc(self.RawData.Id) + end +end + +function XSuperTowerRole:GetPartner() + local result + if XRobotManager.CheckIsRobotId(self.RawData.Id) then + result = self.RawData:GetPartner() + else + result = XDataCenter.PartnerManager.GetCarryPartnerEntityByCarrierId(self.RawData.Id) + end + return result +end + +function XSuperTowerRole:GetEquipViewModels() + local result = {} + if XRobotManager.CheckIsRobotId(self.RawData.Id) then + result = self.RawData:GetEquipViewModels() + end + return result +end + +return XSuperTowerRole diff --git a/Resources/Scripts/XEntity/XSuperTower/Role/XSuperTowerRoleManager.lua b/Resources/Scripts/XEntity/XSuperTower/Role/XSuperTowerRoleManager.lua new file mode 100644 index 00000000..ae17ebc7 --- /dev/null +++ b/Resources/Scripts/XEntity/XSuperTower/Role/XSuperTowerRoleManager.lua @@ -0,0 +1,491 @@ +local XRobot = require("XEntity/XRobot/XRobot") +local XSuperTowerRole = require("XEntity/XSuperTower/Role/XSuperTowerRole") +local XSuperTowerRoleManager = XClass(nil, "XSuperTowerRoleManager") + +-- groupId : XRoomCharFilterTipsConfigs.EnumFilterTagGroup +-- tagValue : XCharacterConfigs.GetCharDetailTemplate(char.Id) +local FilterJudge = function(groupId, tagValue, superTowerRole) + local characterViewModel = superTowerRole:GetCharacterViewModel() + -- 职业筛选 + if groupId == XRoomCharFilterTipsConfigs.EnumFilterTagGroup.Career then + if tagValue == characterViewModel:GetCareer() then + return true + end + -- 能量元素筛选 + elseif groupId == XRoomCharFilterTipsConfigs.EnumFilterTagGroup.Element then + local obtainElementList = characterViewModel:GetObtainElements() + for _, element in pairs(obtainElementList) do + if element == tagValue then + return true + end + end + else + XLog.Error(string.format("XUiRoomCharacter:Filter函数错误,没有处理排序组:%s的逻辑", groupId)) + return false + end +end + +function XSuperTowerRoleManager:Ctor() + -- XSuperTowerRole + self.RoleDic = {} + -- XSuperTowerRole + self.Roles = {} + -- 超限角色服务器数据(Id & Level & Exp & PluginId) + self.TransfiniteRoleDataDic = {} + -- 角色/机器人爬塔数据 + self.TierRoleHpLeftDic = {} + -- 缓存已发放的机器人数据 + self.GrantedRobotDic = {} + -- 排序方法 + self.IsAscendOrder = true + self.SortFunctionDic = { + [XRoomCharFilterTipsConfigs.EnumSortTag.SuperLevel] = function(roleA, roleB) + local characterViewModelA = roleA:GetCharacterViewModel() + local characterViewModelB = roleB:GetCharacterViewModel() + local dultWeightA = roleA:GetIsInDult() and 10000 or 0 + local dultWeightB = roleB:GetIsInDult() and 10000 or 0 + if self.IsAscendOrder then + dultWeightA = dultWeightA * -1 + dultWeightB = dultWeightB * -1 + end + local aWeight = characterViewModelA:GetId() / 10000000 + roleA:GetSuperLevel() * 100 + dultWeightA + local bWeight = characterViewModelB:GetId() / 10000000 + roleB:GetSuperLevel() * 100 + dultWeightB + if self.IsAscendOrder then + return aWeight < bWeight + else + return aWeight > bWeight + end + end, + [XRoomCharFilterTipsConfigs.EnumSortTag.Quality] = function(roleA, roleB) + local characterViewModelA = roleA:GetCharacterViewModel() + local characterViewModelB = roleB:GetCharacterViewModel() + local dultWeightA = roleA:GetIsInDult() and 10000 or 0 + local dultWeightB = roleB:GetIsInDult() and 10000 or 0 + if self.IsAscendOrder then + dultWeightA = dultWeightA * -1 + dultWeightB = dultWeightB * -1 + end + local aWeight = characterViewModelA:GetId() / 10000000 + characterViewModelA:GetQuality() * 100 + dultWeightA + local bWeight = characterViewModelB:GetId() / 10000000 + characterViewModelB:GetQuality() * 100 + dultWeightB + if self.IsAscendOrder then + return aWeight < bWeight + else + return aWeight > bWeight + end + end, + [XRoomCharFilterTipsConfigs.EnumSortTag.Ability] = function(roleA, roleB) + local dultWeightA = roleA:GetIsInDult() and 1000000 or 0 + local dultWeightB = roleB:GetIsInDult() and 1000000 or 0 + if self.IsAscendOrder then + dultWeightA = dultWeightA * -1 + dultWeightB = dultWeightB * -1 + end + local aWeight = roleA:GetCharacterId() / 10000000 + roleA:GetAbility() * 10 + dultWeightA + local bWeight = roleB:GetCharacterId() / 10000000 + roleB:GetAbility() * 10 + dultWeightB + if self.IsAscendOrder then + return aWeight < bWeight + else + return aWeight > bWeight + end + end, + } + self:RegisterEvents() +end + +-- data : List(Id & Level & Exp & PluginId) +function XSuperTowerRoleManager:InitWithServerData(data) + for _, transfiniteCharacterInfo in ipairs(data) do + self.TransfiniteRoleDataDic[transfiniteCharacterInfo.Id] = transfiniteCharacterInfo + end +end + +-- 更新爬塔角色声明数据 +-- tierCharacterInfos : StTierCharacterInfo array +function XSuperTowerRoleManager:UpdateTierRoleHpLeftData(tierCharacterInfos) + if tierCharacterInfos == nil then return end + for _, tierCharacterInfo in ipairs(tierCharacterInfos) do + if tierCharacterInfo.Id > 0 then + self.TierRoleHpLeftDic[tierCharacterInfo.Id] = tierCharacterInfo.HpLeft + elseif tierCharacterInfo.RobotId > 0 then + self.TierRoleHpLeftDic[tierCharacterInfo.RobotId] = tierCharacterInfo.HpLeft + end + end +end + +function XSuperTowerRoleManager:UpdateCharacterLevel(characterId, level) + self.TransfiniteRoleDataDic[characterId] = self.TransfiniteRoleDataDic[characterId] or {} + self.TransfiniteRoleDataDic[characterId].Level = level +end + +function XSuperTowerRoleManager:UpdateCharacterPlugin(characterId, pluginId) + self.TransfiniteRoleDataDic[characterId] = self.TransfiniteRoleDataDic[characterId] or {} + self.TransfiniteRoleDataDic[characterId].PluginId = pluginId +end + +function XSuperTowerRoleManager:UpdateCharacterExp(characterId, exp) + self.TransfiniteRoleDataDic[characterId] = self.TransfiniteRoleDataDic[characterId] or {} + self.TransfiniteRoleDataDic[characterId].Exp = exp +end + +-- 获取当前激活的特典角色配置信息 +function XSuperTowerRoleManager:GetCurrentInDultConfig() + local configs = XSuperTowerConfigs.GetAllCharacterInDultConfigs() + for _, config in pairs(configs) do + if XFunctionManager.CheckInTimeByTimeId(config.TimeId) then + return config + end + end + return nil +end + +-- 获取能够参战的角色数据 +-- return : XSuperTowerRole array +-- characterType : XCharacterConfigs.CharacterType +function XSuperTowerRoleManager:GetCanFightRoles(characterType) + if self:CheckHasNewRobotGrant() or XTool.IsTableEmpty(self.Roles) then + self:GenerateRoleData() + end + if characterType == nil then + return self.Roles + end + local result = {} + for _, role in ipairs(self.Roles) do + if role:GetCharacterType() == characterType then + table.insert(result, role) + end + end + return result +end + +-- id : XCharacter | XRobot +-- return : XSuperTowerRole +function XSuperTowerRoleManager:GetRole(id) + if self:CheckHasNewRobotGrant() or XTool.IsTableEmpty(self.RoleDic) then + self:GenerateRoleData() + end + return self.RoleDic[id] +end + +function XSuperTowerRoleManager:GetTransfiniteLevel(characterId) + local data = self.TransfiniteRoleDataDic[characterId] + if not data then return 1 end + return data.Level or 1 +end + +function XSuperTowerRoleManager:GetTransfiniteExp(characterId) + local data = self.TransfiniteRoleDataDic[characterId] + if not data then return 0 end + return data.Exp or 0 +end + +function XSuperTowerRoleManager:GetTransfinitePluginId(characterId) + local data = self.TransfiniteRoleDataDic[characterId] + if not data then return nil end + if data.PluginId == nil or data.PluginId <= 0 then return nil end + return data.PluginId +end + +-- 获取超级爬塔角色生命百分比 +function XSuperTowerRoleManager:GetTierRoleHpLeft(roleId) + return self.TierRoleHpLeftDic[roleId] or 100 +end + +-- 获取角色是否属于特典中 +function XSuperTowerRoleManager:GetCharacterIsInDultAndConfig(id) + local configs = XSuperTowerConfigs.GetCharacterInDultConfigs(id) + if not configs then return false end + for _, config in ipairs(configs) do + if XFunctionManager.CheckInTimeByTimeId(config.TimeId) then + return true, config + end + end + return false, nil +end + +-- 角色请求镶嵌插件 +function XSuperTowerRoleManager:RequestMountPlugin(characterId, pluginId, callback) + local requestData = { + CharacterId = characterId, + PluginId = pluginId + } + -- res : StMountPluginResponse(PluginCount) + XNetwork.Call("StMountPluginRequest", requestData, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + self:UpdateCharacterPlugin(characterId, pluginId) + if callback then callback() end + end) +end + +function XSuperTowerRoleManager:RequestUpgradeCharacter(characterId, pluginDic, callback) + local requestData = { + CharacterId = characterId, + PluginDic = pluginDic + } + XMessagePack.MarkAsTable(requestData.PluginDic) + -- res : StUpgradeCharacterResponse(Level, Exp) + XNetwork.Call("StUpgradeCharacterRequest", requestData, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + -- 更新角色等级和经验 + self:UpdateCharacterLevel(characterId, res.Level) + self:UpdateCharacterExp(characterId, res.Exp) + if callback then + callback() + end + end) +end + +function XSuperTowerRoleManager:RefreshTierRoleData(tierCharacterInfos) + self:UpdateTierRoleHpLeftData(tierCharacterInfos) +end + +function XSuperTowerRoleManager:ResetTierRoleData() + self.TierRoleHpLeftDic = {} +end + +-- sortTagType : XRoomCharFilterTipsConfigs.EnumSortTag +function XSuperTowerRoleManager:SortRoles(roles, sortTagType, isAscendOrder) + if isAscendOrder == nil then isAscendOrder = self.IsAscendOrder end + self.IsAscendOrder = not isAscendOrder + if sortTagType == XRoomCharFilterTipsConfigs.EnumSortTag.Default then + sortTagType = XRoomCharFilterTipsConfigs.EnumSortTag.Ability + end + local characterRoles = {} + local characterIdDic = {} + local robotRoles = {} + for _, role in ipairs(roles) do + if XEntityHelper.GetIsRobot(role:GetId()) then + table.insert(robotRoles, role) + else + table.insert(characterRoles, role) + characterIdDic[role:GetId()] = role + end + end + table.sort(characterRoles, self.SortFunctionDic[sortTagType]) + table.sort(robotRoles, self.SortFunctionDic[sortTagType]) + local robotRole, sameCharacterRole + for i = #robotRoles, 1, -1 do + robotRole = robotRoles[i] + sameCharacterRole = characterIdDic[robotRole:GetCharacterId()] + -- 存在相同本地角色 + if sameCharacterRole ~= nil then + -- 对比排序值,升序放在前面,降序放在后面 + if self:GetRoleSortValue(robotRole, sortTagType) >= self:GetRoleSortValue(sameCharacterRole, sortTagType) then + local index = table.indexof(characterRoles, sameCharacterRole) + table.insert(characterRoles, index, robotRole) + table.remove(robotRoles, i) + end + end + end + return appendArray(characterRoles, robotRoles) +end + +function XSuperTowerRoleManager:GetFilterJudge() + return FilterJudge +end + +--######################## 红点检查 ######################## + +function XSuperTowerRoleManager:CheckRoleShowRedDot(roleId) + return self:CheckRolesSuperLevelUpShowRedDot(roleId) + or self:CheckRolePluginShowRedDot(roleId) +end + +function XSuperTowerRoleManager:CheckRolesSuperLevelUpShowRedDot(roleId) + local superTowerManager = XDataCenter.SuperTowerManager + -- 活动没开启不处理 + if superTowerManager.GetIsEnd() then return false end + -- 超限特权没开放,不需要显示 + if not superTowerManager.CheckFunctionUnlockByKey(superTowerManager.FunctionName.Transfinite) then + return false + end + local roles + if roleId == nil then + roles = self:GetCanFightRoles() + else + roles = { self:GetRole(roleId) } + end + local bagManager = superTowerManager.GetBagManager() + local star = XSuperTowerConfigs.GetClientBaseConfigByKey("RoleTransfiniteRedDotPluginStarLevel") or 0 + for _, role in ipairs(roles) do + -- 未满级并有指定的插件材料,给红点提示 + if role:GetSuperLevel() < role:GetMaxSuperLevel() + and bagManager:CheckHasPluginWithStarFilter(star) then + return true + end + end + return false +end + +function XSuperTowerRoleManager:CheckRolePluginShowRedDot(roleId) + local superTowerManager = XDataCenter.SuperTowerManager + -- 活动没开启不处理 + if superTowerManager.GetIsEnd() then return false end + -- 专属槽权限没开启不需要处理 + if not superTowerManager.CheckFunctionUnlockByKey(superTowerManager.FunctionName.Exclusive) then + return false + end + local roles + if roleId == nil then + roles = self:GetCanFightRoles() + else + roles = { self:GetRole(roleId) } + end + local bagManager = superTowerManager.GetBagManager() + for _, role in ipairs(roles) do + if not role:GetTransfinitePluginIsActive() and bagManager:GetIsHaveData(role:GetTransfinitePluginId()) then + return true + end + end + return false +end + +function XSuperTowerRoleManager:CheckRoleInDultShowRedDot() + local superTowerManager = XDataCenter.SuperTowerManager + -- 活动没开启不处理 + if superTowerManager.GetIsEnd() then return false end + -- 特典权限没开启不需要处理 + if not superTowerManager.CheckFunctionUnlockByKey(superTowerManager.FunctionName.BonusChara) then + return false + end + local currentConfig = self.GetCurrentInDultConfig() + -- 没有任何一个特典在开放时间内,不显示 + if currentConfig == nil then return false end + local inDultHistoryId = self:GetInDultHistoryId() + -- 没有记录说明没打开过,显示 + if inDultHistoryId == nil then return true end + -- 历史打开的记录与最新开放的记录不相同,显示,相同则不显示 + return inDultHistoryId ~= currentConfig.Id +end + +function XSuperTowerRoleManager:GetInDultHistoryId() + if self.InDultHistoryId == nil then + local superTowerManager = XDataCenter.SuperTowerManager + self.InDultHistoryId = + XSaveTool.GetData("XSuperTowerRoleManager.InDultHistoryId" .. XPlayer.Id .. superTowerManager.GetActivityId()) + end + return self.InDultHistoryId +end + +function XSuperTowerRoleManager:SetInDultHistoryId(id) + if id == nil then + local currentConfig = self.GetCurrentInDultConfig() + if currentConfig == nil then return end + id = currentConfig.Id + end + self.InDultHistoryId = id + XSaveTool.SaveData("XSuperTowerRoleManager.InDultHistoryId" + .. XPlayer.Id .. XDataCenter.SuperTowerManager.GetActivityId(), self.InDultHistoryId) +end + +--######################## 私有方法 ######################## + +-- sortTagType : XRoomCharFilterTipsConfigs.EnumSortTag +function XSuperTowerRoleManager:GetRoleSortValue(role, sortTagType) + if sortTagType == XRoomCharFilterTipsConfigs.EnumSortTag.Default then + sortTagType = XRoomCharFilterTipsConfigs.EnumSortTag.Ability + end + if sortTagType == XRoomCharFilterTipsConfigs.EnumSortTag.Ability then + return role:GetAbility() + elseif sortTagType == XRoomCharFilterTipsConfigs.EnumSortTag.SuperLevel then + return role:GetSuperLevel() + elseif sortTagType == XRoomCharFilterTipsConfigs.EnumSortTag.Quality then + return role:GetCharacterViewModel():GetQuality() + end +end + +function XSuperTowerRoleManager:GenerateRoleData() + local characters = XDataCenter.CharacterManager.GetOwnCharacterList() + for _, character in ipairs(characters) do + self:AddNewRole(character) + end + for _, robot in ipairs(self:GetCanFightRobots()) do + self:AddNewRole(robot) + end +end + +-- roleData : XCharacter | XRobot +function XSuperTowerRoleManager:AddNewRole(roleData) + -- 如果已经存在,直接不处理 + if self.RoleDic[roleData.Id] then return end + local role = XSuperTowerRole.New(roleData) + table.insert(self.Roles, role) + self.RoleDic[role:GetId()] = role +end + +function XSuperTowerRoleManager:GetCanFightRobots() + local result = {} + local config + for id, v in pairs(self.GrantedRobotDic) do + config = XSuperTowerConfigs.GetGrantRobotConfig(id) + for _, robotId in ipairs(config.RobotId) do + table.insert(result, XRobot.New(robotId)) + end + end + return result +end + +function XSuperTowerRoleManager:CheckHasNewRobotGrant() + local generateRobots = false + local robotConfigs = XSuperTowerConfigs.GetGrantRobotConfigs() + local nowTime = XTime.GetServerNowTimestamp() + local startTime = 0 + local activityStartTime = XDataCenter.SuperTowerManager.GetActivityStartTime() + local newGrantedRobotDic = {} + local tmpGrantedRobotDic = {} + -- 获取能够发送的配置表id + for id, config in pairs(robotConfigs) do + startTime = XUiHelper.GetTimeOfDelay(activityStartTime, config.OpenHour, XUiHelper.DelayType.Hour) + if nowTime >= startTime then + newGrantedRobotDic[id] = true + tmpGrantedRobotDic[id] = true + end + end + local newTableIsEmpty = XTool.IsTableEmpty(newGrantedRobotDic) + local oldTableIsEmpty = XTool.IsTableEmpty(self.GrantedRobotDic) + -- 都不为空,要对比一下数据是否有变化 + if not newTableIsEmpty and not oldTableIsEmpty then + for id, _ in pairs(self.GrantedRobotDic) do + if newGrantedRobotDic[id] then + newGrantedRobotDic[id] = nil + self.GrantedRobotDic[id] = nil + end + end + -- 都是空表,说明一致,不需要重新生成 + if XTool.IsTableEmpty(newGrantedRobotDic) and XTool.IsTableEmpty(self.GrantedRobotDic) then + generateRobots = false + else + generateRobots = true + end + else + -- 如果都是空表,说明没有任何一个是可以发送的 + if oldTableIsEmpty and newTableIsEmpty then + generateRobots = false + -- 有新的发送 + elseif oldTableIsEmpty and not newTableIsEmpty then + generateRobots = true + -- 旧的发送都过期了 + elseif not oldTableIsEmpty and newTableIsEmpty then + generateRobots = true + end + end + self.GrantedRobotDic = tmpGrantedRobotDic + return generateRobots +end + +function XSuperTowerRoleManager:RegisterEvents() + XEventManager.AddEventListener(XEventId.EVENT_CHARACTER_ADD_SYNC, self.OnCharacterAdd, self) +end + +function XSuperTowerRoleManager:OnCharacterAdd(character) + if character == nil then return end + if self.RoleDic[character.Id] then return end + self:AddNewRole(character) +end + +return XSuperTowerRoleManager \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XSuperTower/Shop/XSuperTowerShopManager.lua b/Resources/Scripts/XEntity/XSuperTower/Shop/XSuperTowerShopManager.lua new file mode 100644 index 00000000..042248a6 --- /dev/null +++ b/Resources/Scripts/XEntity/XSuperTower/Shop/XSuperTowerShopManager.lua @@ -0,0 +1,128 @@ +---@class XSuperTowerShopManager +local XSuperTowerShopManager = XClass(nil, "XSuperTowerShopManager") + +function XSuperTowerShopManager:Ctor() + self.RefreshCd = 0 + self.RefreshCount = 0 + self.ManualRefreshCount = 0 + self.MallId = 101 + self.BuyList = {} + -- self:RegisterNotify() +end + +function XSuperTowerShopManager:UpdateShopData(data) + if not data then + return + end + self.MallId = data.MallId --商店id + self.RefreshCd = data.MallRefreshCd --刷新cd + self.RefreshCount = data.MallRefreshCount --免费刷新次数 + self.ManualRefreshCount = data.ManualRefreshCount --手动刷新次数 + self.BuyList = data.BuyList --商品列表 + CS.XGameEventManager.Instance:Notify(XEventId.EVENT_ST_SHOP_REFRESH) +end + +function XSuperTowerShopManager:GetRefreshCount() + return self.RefreshCount +end + +function XSuperTowerShopManager:GetRefreshCd() + return self.RefreshCd +end + +function XSuperTowerShopManager:GetManualRefreshCount() + return self.ManualRefreshCount +end + +function XSuperTowerShopManager:GetBuyList() + return self.BuyList +end + +function XSuperTowerShopManager:GetMallId() + return self.MallId +end + +function XSuperTowerShopManager:GetSpendItemCountInfo() + local spendCount = self:GetRefreshInfo(self.ManualRefreshCount) + local mallConfig = XSuperTowerConfigs.GetMallConfig(self.MallId) + local itemCount = XDataCenter.ItemManager.GetCount(mallConfig.ManualRefreshSpendItemId) + return spendCount,itemCount +end + +function XSuperTowerShopManager:GetRefreshInfo(refreshCount) + local mallConfig = XSuperTowerConfigs.GetMallConfig(self.MallId) + if not mallConfig then + XLog.Error("XSuperTowerShopManager:GetRefreshInfo 配置不存在 shopId:", self.MallId) + return + end + refreshCount = refreshCount + 1 + local manualRefreshCountList = mallConfig.ManualRefreshSpendItemCount + refreshCount = XMath.Clamp(refreshCount, 1, #manualRefreshCountList) + return manualRefreshCountList[refreshCount] +end + +function XSuperTowerShopManager:GetMallItemInfo(id) + local config + for i = 1, #self.BuyList do + if self.BuyList[i].Id == id then + config = self.BuyList[i] + end + end + return config +end + +function XSuperTowerShopManager:RequestBugPlugin(listIndex, count, cb) + local req = { + Index = listIndex, + Count = count + } + + XNetwork.Call("StBuyPluginRequest", req, function(rsp) + if rsp.Code ~= XCode.Success then + XUiManager.TipCode(rsp.Code) + return + end + if cb then + cb() + end + end) +end + +function XSuperTowerShopManager:RequestRefreshMall(cb) + XNetwork.Call("StRefreshMallRequest", nil, function(rsp) + if rsp.Code ~= XCode.Success then + XUiManager.TipCode(rsp.Code) + return + end + self.RefreshCd = rsp.MallRefreshCd --刷新cd + self.RefreshCount = rsp.FreeRefreshCount --免费刷新次数 + self.ManualRefreshCount = rsp.ManualRefreshCount --手动刷新次数 + self.BuyList = rsp.PluginId --商品列表 + if cb then + cb() + end + end) +end + +-- function XSuperTowerShopManager:RegisterNotify() +-- XRpc.NotifySuperTowerMallRefreshData = function(data) +-- self.RefreshCd = data.MallRefreshCd +-- self.RefreshCount = data.MallRefreshCount +-- self.ManualRefreshCount = data.ManualRefreshCount +-- CS.XGameEventManager.Instance:Notify(XEventId.EVENT_ST_SHOP_REFRESH) +-- end + +-- XRpc.NotifySuperTowerMallData = function(data) +-- self:UpdateShopData(data.MallInfo) +-- end +-- end + +function XSuperTowerShopManager:OnrMallRefreshData(data) + self.RefreshCd = data.MallRefreshCd + self.RefreshCount = data.MallRefreshCount + self.ManualRefreshCount = data.ManualRefreshCount + CS.XGameEventManager.Instance:Notify(XEventId.EVENT_ST_SHOP_REFRESH) +end + +return XSuperTowerShopManager + diff --git a/Resources/Scripts/XEntity/XSuperTower/Stages/XSuperTowerStageManager.lua b/Resources/Scripts/XEntity/XSuperTower/Stages/XSuperTowerStageManager.lua new file mode 100644 index 00000000..fba57a81 --- /dev/null +++ b/Resources/Scripts/XEntity/XSuperTower/Stages/XSuperTowerStageManager.lua @@ -0,0 +1,278 @@ +--=========================== +--超级爬塔 关卡 管理器 +--模块负责:吕天元 +--=========================== +local XSuperTowerStageManager = XClass(nil, "XSuperTowerStageManager") + +function XSuperTowerStageManager:Ctor(rootManager) + self.ActivityManager = rootManager + self:Init() +end +--================= +--初始化 +--================= +function XSuperTowerStageManager:Init() + self:InitThemes() + -- self:InitRpc() +end +--================= +--初始化主题 +--================= +function XSuperTowerStageManager:InitThemes() + self.MaxStageCount = 0 + self.Themes = {} + self.ThemesOrderByIndex ={} + local themeIds = self.ActivityManager.GetThemeIds() + local themeScript = require("XEntity/XSuperTower/Stages/XSuperTowerTheme") + for index, id in pairs(themeIds) do + local theme = themeScript.New(self, id, index) + self.ThemesOrderByIndex[index] = theme --以排序做的字典 + self.Themes[id] = theme --以主题Id做的字典 + if theme:GetMaxStageCount() > self.MaxStageCount then + self.MaxStageCount = theme:GetMaxStageCount() + end + end +end + +-- function XSuperTowerStageManager:InitRpc() +-- XRpc.NotifyStMapTierData = function(data) +-- self:RefreshStMapTierData(data) +-- end +-- XRpc.NotifyStMapTargetData = function(data) +-- self:RefreshStMapTargetData(data) +-- end +-- XRpc.NotifyTargetStageFightResult = function(data) +-- self:SetTempProgress(data) +-- end +-- end +--// 更新爬塔数据 +-- // 地图id +-- public int Id; +-- // 改变类型,1更新,2结束重置 +-- public int ChangeType; +-- // 爬塔数据 +-- public StTierInfo TierInfo; +--} +function XSuperTowerStageManager:RefreshStMapTierData(data) + --XLog.Debug("================更新爬塔关卡数据:Data:", data) + if not data then return end + local theme = self.Themes[data.Id] + if theme then + theme:RefreshNotifyTierInfo(data.TierInfo, data.ChangeType == 2) + end +end + +function XSuperTowerStageManager:RefreshStMapTargetData(data) + local targetInfo = data.TargetInfo + for _, theme in pairs(self.Themes) do + if theme:CheckStStageIdIsInTheme(targetInfo.Id) then + return theme:GetTargetStageByStStageId(targetInfo.Id):RefreshProgress(targetInfo.Progress, true) + end + end +end + +function XSuperTowerStageManager:InitStageInfo() + for _, theme in pairs(self.Themes) do + theme:InitStageInfo() + end +end +--================= +--设置本次通关后的临时进度(如果取消则不会被正式记录) +--@param data +--data:{ +--目标关卡ID int TargetId, +--临时进度 int Progress, +--} +--================= +function XSuperTowerStageManager:SetTempProgress(data) + if not data then return end + self.TargetStageTempProgress = {} + self.TargetStageTempProgress[data.TargetId] = data.Progress + self.TempProgressMark = true +end +--================= +--获取临时进度 +--@param 临时进度 int targetId +--================= +function XSuperTowerStageManager:GetTempProgressByTargetId(targetId) + return self.TargetStageTempProgress and self.TargetStageTempProgress[targetId] or 0 +end +--================= +--判断临时进度是否已设置 +--================= +function XSuperTowerStageManager:IsSetTempProgress() + return self.TempProgressMark +end +--================= +--重置临时进度已设置标记 +--================= +function XSuperTowerStageManager:ClearTempProgressMark() + self.TempProgressMark = nil +end +--================= +--重置临时进度 +--================= +function XSuperTowerStageManager:ResetTempProgress() + self.TargetStageTempProgress = nil +end +--================= +--刷新推送数据 +--@param data(List) +--StMapInfo:{ +--地图id int Id, +--爬塔数据 StTierInfo TierInfo, +--目标信息列表 List TargetInfos +--} +--================= +function XSuperTowerStageManager:RefreshNotifyMapInfo(data) + for _, mapInfo in pairs(data or {}) do + if self.Themes[mapInfo.Id] then + self.Themes[mapInfo.Id]:RefreshNotifyInfo(mapInfo) + end + end +end +--================= +--获取所有主题 +--================= +function XSuperTowerStageManager:GetAllThemes() + return self.Themes +end +--================= +--获取所有主题列表 +--================= +function XSuperTowerStageManager:GetAllThemeList() + return self.ThemesOrderByIndex +end +--================= +--根据ID获取主题 +--@param id:主题ID +--================= +function XSuperTowerStageManager:GetThemeById(id) + return self.Themes[id] +end +--================= +--根据序号获取主题 +--@param themeIndex:主题序号 +--================= +function XSuperTowerStageManager:GetThemeByIndex(themeIndex) + return self.ThemesOrderByIndex[themeIndex] +end +--================= +--根据关卡Id获取所属主题对象 +--@param stageId:Stage表Id +--================= +function XSuperTowerStageManager:GetThemeByStageId(stageId) + for _, theme in pairs(self.Themes) do + if theme:CheckStageIdIsInTheme(stageId) then + return theme + end + end +end +--================= +--获取所有章节中的最大子关卡数 +--================= +function XSuperTowerStageManager:GetMaxStageCount() + return self.MaxStageCount +end +--================= +--根据关卡Id获取目标关卡Id +--@param stageId:Stage表Id +--================= +function XSuperTowerStageManager:GetTargetStageIdByStageId(stageId) + for _, theme in pairs(self.Themes) do + if theme:CheckStageIdIsInTheme(stageId) then + return theme:GetTargetStageIdByStageId(stageId) + end + end +end +--================= +--根据完成进度获取当前正在进行的主题对象 +--================= +function XSuperTowerStageManager:GetThemeByClearProgress() + local curIndex = 1 + --按顺序检测主题 + for index, theme in pairs(self.ThemesOrderByIndex) do + --若主题未开放,跳出循环 + if not theme:CheckIsOpen() then + break + end + --如果已经检测到最后一个主题,返回该主题 + if index == #self.ThemesOrderByIndex then + return theme + end + curIndex = index + --若主题未全部通关,则为当前进度的主题 + if not theme:CheckIsAllClear() then + break + end + + end + return self.ThemesOrderByIndex[curIndex] +end +--================= +--根据关卡Id获取目标关卡 +--@param stageId:Stage表Id +--================= +function XSuperTowerStageManager:GetTargetStageByStageId(stageId) + for _, theme in pairs(self.Themes) do + if theme:CheckStageIdIsInTheme(stageId) then + return theme:GetTargetStageByStageId(stageId) + end + end +end +--================= +--根据关卡Id获取关卡类型 +--@param stageId:Stage表Id +--================= +function XSuperTowerStageManager:GetStageTypeByStageId(stageId) + for _, theme in pairs(self.Themes) do + if theme:CheckStageIdIsInTheme(stageId) then + return theme:GetStageTypeByStageId(stageId) + end + end + return XDataCenter.SuperTowerManager.StageType.None +end +--================= +--根据目标关卡Id获取目标关卡对象 +--@param stStageId:TargetStage表Id +--================= +function XSuperTowerStageManager:GetTargetStageByStStageId(stStageId) + for _, theme in pairs(self.Themes) do + if theme:CheckStStageIdIsInTheme(stStageId) then + return theme:GetTargetStageByStStageId(stStageId) + end + end +end +--================= +--根据关卡Id获取目标关卡中该关卡的Index +--@param stageId:Stage表Id +--================= +function XSuperTowerStageManager:GetStageIndexByStageId(stageId) + for _, theme in pairs(self.Themes) do + if theme:CheckStageIdIsInTheme(stageId) then + return theme:GetStageIndexByStageId(stageId) + end + end + return 0 +end +--================= +--检查所有主题的重置标记 +--================= +function XSuperTowerStageManager:CheckReset() + for _, theme in pairs(self.Themes) do + theme:CheckReset() + end +end +--================= +--获取正在进行的爬塔主题ID,若都没有在进行,返回0 +--================= +function XSuperTowerStageManager:GetPlayingTierId() + for index, theme in pairs(self.Themes) do + if theme:CheckTierIsPlaying() then + return index + end + end + return 0 +end + +return XSuperTowerStageManager \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XSuperTower/Stages/XSuperTowerTargetStage.lua b/Resources/Scripts/XEntity/XSuperTower/Stages/XSuperTowerTargetStage.lua new file mode 100644 index 00000000..e7e18171 --- /dev/null +++ b/Resources/Scripts/XEntity/XSuperTower/Stages/XSuperTowerTargetStage.lua @@ -0,0 +1,309 @@ +--=========================== +--超级爬塔 目标关卡(普通关卡) 实体 +--模块负责:吕天元 +--=========================== +local XSuperTowerTargetStage = XClass(nil, "XSuperTowerTargetStage") + +function XSuperTowerTargetStage:Ctor(theme, cfg) + self.Theme = theme + self.StStageCfg = cfg + self:Init() +end +--================= +--初始化 +--================= +function XSuperTowerTargetStage:Init() + +end + +function XSuperTowerTargetStage:InitStageInfo() + local stageIds = self:GetStageId() + for _, stageId in pairs(stageIds) do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + if stageInfo then + stageInfo.Type = XDataCenter.FubenManager.StageType.SuperTower + end + end +end +--================= +--获取活动关卡Id +--================= +function XSuperTowerTargetStage:GetId() + return self.StStageCfg and self.StStageCfg.Id +end +--================= +--获取关卡配置 +--================= +function XSuperTowerTargetStage:GetStageCfg(id) + return XDataCenter.FubenManager.GetStageCfg(id or self:GetFirstStageId()) +end + +--================= +--刷新关卡进度 +--================= +function XSuperTowerTargetStage:RefreshProgress(progress, checkFunc) + self.CurrentProgress = progress or 0 + if checkFunc then + XDataCenter.SuperTowerManager.GetFunctionManager():CheckUnLock() + end +end +--================= +--获取活动关卡对应的StageId组 +--================= +function XSuperTowerTargetStage:GetStageId() + return self.StStageCfg and self.StStageCfg.StageId or {} +end +--================= +--根据stageId获取关卡对应的Index +--================= +function XSuperTowerTargetStage:GetStageIndexByStageId(stageId) + for index,id in pairs(self:GetStageId()) do + if id == stageId then + return index + end + end + return 0 +end +--================= +--获取活动关卡对应的第一个关卡表ID +--================= +function XSuperTowerTargetStage:GetFirstStageId() + return self.StStageCfg and self.StStageCfg.StageId and self.StStageCfg.StageId[1] or 0 +end +--================= +--获取活动关卡对应的RewardId组 +--================= +function XSuperTowerTargetStage:GetRewardId() + return self.StStageCfg and self.StStageCfg.RewardId or {} +end +--================= +--获取活动关卡对应的RewardId组 +--================= +function XSuperTowerTargetStage:GetRewardIdByProgress(curProgress) + return self.StStageCfg and self.StStageCfg.RewardId and self.StStageCfg.RewardId[curProgress] or 0 +end +--================= +--获取关卡名称 +--================= +function XSuperTowerTargetStage:GetStageName(id) + return self:GetStageCfg(id) and self:GetStageCfg(id).Name +end +--================= +--获取关卡序号缩略名称 +--================= +function XSuperTowerTargetStage:GetSimpleName() + return self.StStageCfg and self.StStageCfg.SimpleName +end +--================= +--获取完整的关卡名称(关卡序号名称 + 关卡名称) +--================= +function XSuperTowerTargetStage:GetFullStageName() + return self:GetStageName() .. self:GetSimpleName() +end +--================= +--获取关卡描述 +--================= +function XSuperTowerTargetStage:GetStageDescription(id) + return self:GetStageCfg(id) and self:GetStageCfg(id).Description +end +--================= +--获取现在通过的波数(单波关卡波数为1) +--================= +function XSuperTowerTargetStage:GetCurrentProgress() + return self.CurrentProgress or 0 +end +--================= +--获取关卡总波数(单波关卡波数为1) +--================= +function XSuperTowerTargetStage:GetProgress() + return self.StStageCfg and self.StStageCfg.Progress or 1 +end + +--================= +--获取当前关卡进度显示 +--================= +function XSuperTowerTargetStage:GetProgressStr() + return self:GetCurrentProgress() .."/".. self:GetProgress() +end +--================= +--检查关卡进度是否达标 +--@param progress:目标进度 +--================= +function XSuperTowerTargetStage:CheckProgress(progress) + return progress <= self:GetCurrentProgress() +end +--================= +--检查是否已通关 +--================= +function XSuperTowerTargetStage:CheckIsClear() + return self:GetProgress() <= self:GetCurrentProgress() +end +--================= +--获取活动关卡类型(XSuperTowerManager.StageType) +--================= +function XSuperTowerTargetStage:GetStageType() + return self.StStageCfg and self.StStageCfg.Type +end +--================= +--获取前置解锁条件要求关卡 +--================= +function XSuperTowerTargetStage:GetPreStageId() + return self.StStageCfg and self.StStageCfg.PreId +end +--================= +--获取前置解锁条件要求波数 +--================= +function XSuperTowerTargetStage:GetPreStageProgress() + return self.StStageCfg and self.StStageCfg.PreProgress +end +--================= +--根据关卡序号获取关卡推荐战力 +--================= +function XSuperTowerTargetStage:GetStageAbilityByIndex(index) + return self.StStageCfg and self.StStageCfg.StageAbility and self.StStageCfg.StageAbility[index] or 0 +end +--================= +--根据关卡序号获取登场成员数 +--================= +function XSuperTowerTargetStage:GetMemberCountByIndex(index) + return self.StStageCfg and self.StStageCfg.MemberCount and self.StStageCfg.MemberCount[index] or 0 +end +--================= +--根据关卡序号获取关卡ID +--================= +function XSuperTowerTargetStage:GetStageIdByIndex(index) + return self.StStageCfg and self.StStageCfg.StageId and self.StStageCfg.StageId[index] +end +--================= +--获取活动关卡对应的队伍数 +--================= +function XSuperTowerTargetStage:GetTeamCount() + return self.StStageCfg and self.StStageCfg.StageId and #self.StStageCfg.StageId or 0 +end +--================= +--获取前置解锁条件要求关卡的SimpleName +--================= +function XSuperTowerTargetStage:GetPreStageSimpleName() + local preStageId = self:GetPreStageId() + if preStageId == 0 then return "" end --没有前置关卡返空字符串 + local preStage = self:GetPreStStage() + if preStage then + return preStage:GetSimpleName() + else + return ""--没有前置关卡返回空字符串 + end +end +--================= +--获取前置解锁条件要求关卡的类型 +--================= +function XSuperTowerTargetStage:GetPreStageType() + local preStageId = self:GetPreStageId() + if preStageId == 0 then return nil end + local preStage = self:GetPreStStage() + if preStage then + return preStage:GetStageType() + else + return nil + end +end +--================= +--检查前置关卡解锁条件(前置关卡的开放与进度) +--================= +function XSuperTowerTargetStage:CheckStagePreCondition() + local preStageId = self:GetPreStageId() + if preStageId == 0 then return true end --没有前置关卡表示没有前置关卡类条件 + local preStage = self:GetPreStStage() + if preStage then + --检查前置关卡有没开放,之后检查前置关卡进度是否达到前置条件 + return preStage:CheckStageIsOpen() and preStage:CheckProgress(self:GetPreStageProgress()) + else + return false + end +end +--================= +--获取所属主题ID +--================= +function XSuperTowerTargetStage:GetThemeId() + return self.StStageCfg and self.StStageCfg.MapId +end +--================= +--获取关卡的开放延时时间(小时 +--================= +function XSuperTowerTargetStage:GetOpenTimeDelay() + return self.StStageCfg and self.StStageCfg.OpenHour +end +--================= +--获取关卡的背景图 +--================= +function XSuperTowerTargetStage:GetStageBg() + return self.StStageCfg and self.StStageCfg.Bg +end +--================= +--获取关卡开放的时间戳(使用主题开放时间+开放延时时间) +--================= +function XSuperTowerTargetStage:GetStartTime() + return XUiHelper.GetTimeOfDelay(self.Theme:GetStartTime(), self:GetOpenTimeDelay(), XUiHelper.DelayType.Hour) +end +--================= +--获取关卡结束的时间戳(使用主题的结束时间) +--================= +function XSuperTowerTargetStage:GetEndTime() + return self.Theme:GetEndTime() +end +--================= +--获取关卡开放的本地时间日期字符串 +--@param isFullDate:是否显示全部时间显示格式。true显示年月日时分秒,false显示月日 +--================= +function XSuperTowerTargetStage:GetStartTimeStr(isFullDate) + return XTime.TimestampToLocalDateTimeString(self:GetStartTime(), isFullDate and "yyyy-MM-dd HH:mm:ss" or "MM-dd") +end + +function XSuperTowerTargetStage:GetPreStStage() + return self.Theme.StageManager:GetTargetStageByStStageId(self:GetPreStageId()) +end +--================= +--检查关卡是否在开放时间内 +--================= +function XSuperTowerTargetStage:CheckIsInTime() + local now = XTime.GetServerNowTimestamp() + return (now >= self:GetStartTime()) and (now < self:GetEndTime()) +end +--================= +--检查关卡是否已开放 +--================= +function XSuperTowerTargetStage:CheckStageIsOpen() + --先检查开放时间,再检查关卡开放前置条件 + return self:CheckIsInTime() and self:CheckStagePreCondition() +end +--================= +--检查关卡是否是多波关卡 +--================= +function XSuperTowerTargetStage:CheckIsMultiWave() + return self:CheckIsSingleTeamMultiWave() or self:CheckIsMultiTeamMultiWave() +end +--================= +--检查关卡是否是单队多波关卡 +--================= +function XSuperTowerTargetStage:CheckIsSingleTeamMultiWave() + return self:GetStageType() == XDataCenter.SuperTowerManager.StageType.SingleTeamMultiWave +end +--================= +--检查关卡是否是多队多波关卡 +--================= +function XSuperTowerTargetStage:CheckIsMultiTeamMultiWave() + return self:GetStageType() == XDataCenter.SuperTowerManager.StageType.MultiTeamMultiWave +end +--================= +--检查关卡是否是单队单波 +--================= +function XSuperTowerTargetStage:CheckIsSingleTeamOneWave() + return self:GetStageType() == XDataCenter.SuperTowerManager.StageType.SingleTeamOneWave +end +--================= +--检查关卡是否是爬塔 +--================= +function XSuperTowerTargetStage:CheckIsLllimitedTower() + return self:GetStageType() == XDataCenter.SuperTowerManager.StageType.LllimitedTower +end + +return XSuperTowerTargetStage \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XSuperTower/Stages/XSuperTowerTheme.lua b/Resources/Scripts/XEntity/XSuperTower/Stages/XSuperTowerTheme.lua new file mode 100644 index 00000000..ff023a58 --- /dev/null +++ b/Resources/Scripts/XEntity/XSuperTower/Stages/XSuperTowerTheme.lua @@ -0,0 +1,600 @@ +--=========================== +--超级爬塔主题实体 +--模块负责:吕天元 +--=========================== +local XSuperTowerTheme = XClass(nil, "XSuperTowerTheme") + +function XSuperTowerTheme:Ctor(stageManager, themeId, themeIndex) + self.StageManager = stageManager + self.ActivityManager = stageManager.ActivityManager + self:InitTheme(themeId) + self.ThemeIndex = themeIndex + self.StageId2StageType = {} + self.StageId2Stage = {} + self.StageId2Index = {} -- 获取关卡<->目标关卡的序号 + self.MaxStageCount = 0 + self:InitTargetStages() -- 普通关卡 + self:InitTierStage() -- 爬塔 +end +--================= +--初始化主题 +--@param themeId:主题Id +--================= +function XSuperTowerTheme:InitTheme(themeId) + self.ThemeCfg = XSuperTowerConfigs.GetThemeById(themeId) + self.EnhancerAndPluginsDropCfg = XSuperTowerConfigs.GetEnDConfigByThemeId(themeId) + self.ThemeMapEffectCfg = XSuperTowerConfigs.GetMapEffectCfgByKey(themeId) +end +--================= +--初始化目标关卡 +--================= +function XSuperTowerTheme:InitTargetStages() + local script = require("XEntity/XSuperTower/Stages/XSuperTowerTargetStage") + local stageList = XSuperTowerConfigs.GetTargetStagesByThemeId(self:GetId()) + self.TargetStageDic = {} + self.TargetStageList = {} + for orderIndex, targetStage in pairs(stageList) do + local stage = script.New(self, targetStage) + self.TargetStageDic[targetStage.Id] = stage + self.TargetStageList[orderIndex] = stage + local stageIds = stage:GetStageId() + for index, stageId in pairs(stageIds) do + self.StageId2StageType[stageId] = stage:GetStageType() + self.StageId2Stage[stageId] = stage + self.StageId2Index[stageId] = index + if index > self.MaxStageCount then + self.MaxStageCount = index + end + end + end +end +--================= +--初始化爬塔关卡管理器 +--================= +function XSuperTowerTheme:InitTierStage() + local script = require("XEntity/XSuperTower/Stages/XSuperTowerTierManager") + self.TierManager = script.New(self) +end +--================= +--刷新推送数据 +--@param data(StMapInfo):{ +--地图id int Id, +--爬塔数据 StTierInfo TierInfo, +--目标信息列表 List TargetInfos +--} +--================= +function XSuperTowerTheme:RefreshNotifyInfo(data) + self:RefreshNotifyTierInfo(data.TierInfo) + self:RefreshTargetStageByNotifyInfo(data.TargetInfos) +end +--================= +--刷新爬塔推送数据 +--@param StTierInfo TierInfo +--================= +function XSuperTowerTheme:RefreshNotifyTierInfo(data, needReset) + self.TierManager:RefreshNotifyData(data, needReset) +end +--================= +--检查爬塔数据的重置标记 +--================= +function XSuperTowerTheme:CheckReset() + self.TierManager:CheckReset() +end +--================= +--获取爬塔数据的重置标记 +--================= +function XSuperTowerTheme:GetResetFlag() + return self.TierManager:GetResetFlag() +end +--================= +--刷新推送数据 +--@param data(List) +--StMapTargetInfo:{ +--目标id int Id, +--进度 int Progress +--} +--================= +function XSuperTowerTheme:RefreshTargetStageByNotifyInfo(targetInfos) + for _, info in pairs(targetInfos) do + if self.TargetStageDic[info.Id] then + self.TargetStageDic[info.Id]:RefreshProgress(info.Progress) + end + end + self.CurrentTargetIndex = 1 + for orderIndex, stage in pairs(self.TargetStageList) do + if stage:CheckStageIsOpen() then + self.CurrentTargetIndex = orderIndex + end + end +end + +function XSuperTowerTheme:InitStageInfo() + self.TierManager:InitStageInfo() + for _, targetStage in pairs(self.TargetStageList) do + targetStage:InitStageInfo() + end +end +--================= +--重置爬塔关卡 +--================= +function XSuperTowerTheme:ResetTierStage() + self.TierManager:Reset() +end +--================= +--放弃爬塔进度,结算 +--================= +function XSuperTowerTheme:RequestReset(callBack) + XNetwork.Call("StResetTierRequest", { MapId = self:GetId() }, function(reply) + if reply.Code ~= XCode.Success then + XUiManager.TipCode(reply.Code) + return + end + if callBack then callBack() end + self.StageManager:RefreshStMapTierData(reply.Operation) + self.TierManager:SetResetFlag(true) + XLuaUiManager.Open("UiSuperTowerInfiniteSettleWin", nil, self) + end) +end +--================= +--获取主题配置表Id +--================= +function XSuperTowerTheme:GetId() + return self.ThemeCfg and self.ThemeCfg.Id +end +--================= +--获取主题序号 +--================= +function XSuperTowerTheme:GetIndex() + return self.ThemeIndex +end +--================= +--获取主题名称 +--================= +function XSuperTowerTheme:GetName() + return self.ThemeCfg and self.ThemeCfg.Name or "" +end +--================= +--获取主题对应爬塔名称 +--================= +function XSuperTowerTheme:GetTierName() + return self.ThemeCfg and self.ThemeCfg.TierName or "" +end +--================= +--获取主题开放的TimeId +--================= +function XSuperTowerTheme:GetTimeId() + return self.ThemeCfg and self.ThemeCfg.TimeId or 0 +end +--================= +--获取主题通常地图特效 +--================= +function XSuperTowerTheme:GetMapNormalEffect() + return self.ThemeMapEffectCfg and self.ThemeMapEffectCfg.MapNormalEffect +end +--================= +--获取主题上锁地图特效 +--================= +function XSuperTowerTheme:GetMapLockEffect() + return self.ThemeMapEffectCfg and self.ThemeMapEffectCfg.MapLockEffect +end +--================= +--获取主题当前地图特效 +--================= +function XSuperTowerTheme:GetMapCurrentEffect() + return self.ThemeMapEffectCfg and self.ThemeMapEffectCfg.MapCurrentEffect +end +--================= +--获取主题地形地图特效 +--================= +function XSuperTowerTheme:GetMapTerrainEffect() + return self.ThemeMapEffectCfg and self.ThemeMapEffectCfg.MapTerrainEffect +end +--================= +--获取主题关卡上锁特效 +--================= +function XSuperTowerTheme:GetStageLockEffect(IsSp) + return self.ThemeMapEffectCfg and (IsSp and + self.ThemeMapEffectCfg.SpStageLockEffect or + self.ThemeMapEffectCfg.NorStageLockEffect) +end +--================= +--获取主题关卡特效 +--================= +function XSuperTowerTheme:GetStageUnLockEffect(IsSp) + return self.ThemeMapEffectCfg and (IsSp and + self.ThemeMapEffectCfg.SpStageUnLockEffect or + self.ThemeMapEffectCfg.NorStageUnLockEffect) +end +--================= +--获取主题关卡当前关卡特效 +--================= +function XSuperTowerTheme:GetStageCurrentEffect(IsSp) + return self.ThemeMapEffectCfg and (IsSp and + self.ThemeMapEffectCfg.SpStageCurrentEffect or + self.ThemeMapEffectCfg.NorStageCurrentEffect) +end +--================= +--获取主题关卡选中关卡特效 +--================= +function XSuperTowerTheme:GetStageSelectEffect(IsSp) + return self.ThemeMapEffectCfg and (IsSp and + self.ThemeMapEffectCfg.SpStageSelectEffect or + self.ThemeMapEffectCfg.NorStageSelectEffect) +end +--================= +--获取主题开放的时间戳 +--================= +function XSuperTowerTheme:GetStartTime() + return XFunctionManager.GetStartTimeByTimeId(self:GetTimeId()) +end +--================= +--获取主题结束的时间戳 +--================= +function XSuperTowerTheme:GetEndTime() + return XFunctionManager.GetEndTimeByTimeId(self:GetTimeId()) +end +--================= +--获取主题开放的本地时间日期字符串 +--@param isFullDate:是否显示全部时间显示格式。true显示年月日时分秒,false显示月日 +--================= +function XSuperTowerTheme:GetStartTimeStr(isFullDate) + return XTime.TimestampToLocalDateTimeString(self:GetStartTime(), isFullDate and "yyyy-MM-dd HH:mm:ss" or "MM-dd") +end +--================= +--获取主题爬塔现在积分显示 +--================= +function XSuperTowerTheme:GetTierScore() + return self.TierManager and self.TierManager:GetScoreStr() or "0/0" +end +--================= +--获取主题爬塔现在层数进度显示 +--================= +function XSuperTowerTheme:GetTierStr() + return self.TierManager and self.TierManager:GetTierStr() or "0/0" +end +--================= +--获取主题爬塔现在积分 +--================= +function XSuperTowerTheme:GetCurrentTierScore() + return self.TierManager and self.TierManager:GetCurrentScore() +end +--================= +--获取主题爬塔现在层数 +--================= +function XSuperTowerTheme:GetCurrentTier() + return self.TierManager and self.TierManager:GetCurrentTier() or 1 +end +--================= +--获取主题爬塔历史最高分 +--================= +function XSuperTowerTheme:GetHistoryTierScore() + return self.TierManager and self.TierManager:GetHistoryHighestScore() +end +--================= +--获取主题爬塔最大层数 +--================= +function XSuperTowerTheme:GetMaxTier() + return self.TierManager and self.TierManager:GetMaxTier() or 1 +end +--================= +--获取主题爬塔本周进度纪录字符串 +--================= +function XSuperTowerTheme:GetHistoryTierStr() + return self.TierManager and self.TierManager:GetHistoryTierStr() or "0/0" +end +--================= +--获取主题爬塔本周进度纪录 +--================= +function XSuperTowerTheme:GetHistoryHighestTier() + return self.TierManager and self.TierManager:GetHistoryHighestTier() +end +--================= +--获取主题爬塔可获得的分数上限 +--================= +function XSuperTowerTheme:GetTierMaxScore() + return self.TierManager and self.TierManager:GetMaxScore() or 0 +end +--================= +--获取主题爬塔是否刷新层数纪录 +--================= +function XSuperTowerTheme:CheckIsNewTierRecord() + return self.TierManager and self.TierManager:CheckIsNewTierRecord() +end +--================= +--获取主题爬塔是否刷新分数纪录 +--================= +function XSuperTowerTheme:CheckIsNewScoreRecord() + return self.TierManager and self.TierManager:CheckIsNewScoreRecord() +end +--================= +--根据层数获取爬塔关卡对象 +--@param tier:层数 +--================= +function XSuperTowerTheme:GetTierStageByTier(tier) + return self.TierManager:GetTierStageByTier(tier) +end +--================= +--获取当前爬塔关卡ID +--================= +function XSuperTowerTheme:GetCurrentTierStageId() + local tierStage = self:GetTierStageByTier(self:GetCurrentTier() + 1) + return tierStage:GetStageId() +end +--================= +--根据活动关卡ID获取目标关卡对象 +--@param stStageId:活动关卡ID +--================= +function XSuperTowerTheme:GetTargetStageByStStageId(stStageId) + return self.TargetStageDic[stStageId] +end +--================= +--根据关卡ID获取目标关卡对象 +--@param stStageId:关卡ID +--================= +function XSuperTowerTheme:GetTargetStageByStageId(stageId) + return self.StageId2Stage[stageId] +end +--================= +--获取目标关卡最大子关卡数 +--================= +function XSuperTowerTheme:GetMaxStageCount() + return self.MaxStageCount +end +--================= +--获取目标关卡列表 +--================= +function XSuperTowerTheme:GetTargetStageList() + return self.TargetStageList +end +--================= +--获取主题爬塔收益预览层名称 +--================= +function XSuperTowerTheme:GetPluginsPreviewName() + return self.EnhancerAndPluginsDropCfg and + self.EnhancerAndPluginsDropCfg.PluginsPreviewName +end +--================= +--获取主题爬塔收益预览插件配置ID +--================= +function XSuperTowerTheme:GetPluginsPreviewId() + return self.EnhancerAndPluginsDropCfg and + self.EnhancerAndPluginsDropCfg.PluginsPreviewId +end +--================= +--获取插件掉落预览数据 +--================= +function XSuperTowerTheme:GetPluginsDropPreview() + local previewName = self:GetPluginsPreviewName() + local previewPluginsPreviewId = self:GetPluginsPreviewId() + local previewData = {} + for index, name in pairs(previewName) do + local newData = { + Name = name, + PluginId = previewPluginsPreviewId[index] + } + previewData[index] = newData + end + return previewData +end +--================= +--检查现在该主题是否正在爬塔 +--================= +function XSuperTowerTheme:CheckTierIsPlaying() + return self.TierManager:CheckIsPlaying() +end +--================= +--检查主题是否目标关卡是否全部Clear +--================= +function XSuperTowerTheme:CheckIsAllClear() + if self.IsClear then return true end + for _, stage in pairs(self.TargetStageList) do + if not stage:CheckIsClear() then + return false + end + end + self.IsClear = true + return true +end +--================= +--检查主题是否目标关卡是否全部Clear +--================= +function XSuperTowerTheme:GetStageClearStr() + local clearCount = 0 + local maxCount = #self.TargetStageList + for _, stage in pairs(self.TargetStageList) do + if stage:CheckIsClear() then + clearCount = clearCount + 1 + end + end + return string.format("%d/%d", clearCount, maxCount) +end +--================= +--获取爬塔现在已获得的增益列表 +--================= +function XSuperTowerTheme:GetTierEnhanceIds() + return self.TierManager:GetEnhanceIds() or {} +end +--================= +--获取爬塔现在已获得的插件列表 +--================= +function XSuperTowerTheme:GetTierPluginInfos() + return self.TierManager:GetPluginInfos() or {} +end +--================= +--根据活动关卡ID检查关卡是否在该主题中 +--================= +function XSuperTowerTheme:CheckStStageIdIsInTheme(stStageId) + return self.TargetStageDic[stStageId] ~= nil +end +--================= +--根据关卡ID检查关卡是否在该主题中 +--================= +function XSuperTowerTheme:CheckStageIdIsInTheme(stageId) + return self.StageId2StageType[stageId] ~= nil +end +--================= +--根据关卡ID获取关卡类型 +--================= +function XSuperTowerTheme:GetStageTypeByStageId(stageId) + return self.StageId2StageType[stageId] +end +--================= +--根据关卡ID获取关卡序号 +--================= +function XSuperTowerTheme:GetStageIndexByStageId(stageId) + return self.StageId2Index[stageId] +end +--================= +--根据关卡ID获取目标活动关卡ID +--================= +function XSuperTowerTheme:GetTargetStageIdByStageId(stageId) + return self.StageId2Stage[stageId]:GetId() +end +--================= +--检查主题是否开放 +--================= +function XSuperTowerTheme:CheckIsOpen() + local startTime = self:GetStartTime() + local endTime = self:GetEndTime() + local nowTime = XTime.GetServerNowTimestamp() + return nowTime >= startTime and nowTime < endTime +end +--================= +--获取爬塔是否已经到达顶层 +--================= +function XSuperTowerTheme:CheckTierIsFinish() + return self.TierManager:GetCurrentTier() >= self.TierManager:GetMaxTier() +end + +function XSuperTowerTheme:GetTierScoreCountByScoreType(scoreType) + return self.TierManager:GetTierScoreCountByScoreType(scoreType) +end +--================= +--获取爬塔掉落页面增益掉落用列表 +--@param showAll:展示所有增益,否则会根据队伍成员展示掉落 +--================= +function XSuperTowerTheme:GetTierEnhanceDropShowList(showAll) + local resultList = {} + local dropGroupId = self.EnhancerAndPluginsDropCfg.EnhancerDropGroupId + local allEnhanceIds = XSuperTowerConfigs.GetEnhanceIdListByGroupId(dropGroupId) + if allEnhanceIds then + local characterIdDic = {} + if not showAll then + local team = XDataCenter.SuperTowerManager.GetTeamByStageType(XDataCenter.SuperTowerManager.StageType.LllimitedTower) + for i = 1, 3 do + local id = team:GetEntityIdByTeamPos(i) + if id and id > 0 then + local role = XDataCenter.SuperTowerManager.GetRoleManager():GetRole(id) + characterIdDic[role:GetCharacterId()] = true + end + end + end + local getDic = {} + local getEnhanceIds = self:GetTierEnhanceIds() + for _, enhanceId in pairs(getEnhanceIds) do + local enhanceCfg = XSuperTowerConfigs.GetEnhanceCfgById(enhanceId) + local data = { + EnhanceId = enhanceId, + IsExist = true, + Priority = enhanceCfg.Priority + } + table.insert(resultList, data) + end + for _, id in pairs(getEnhanceIds) do + getDic[id] = true + end + + for _, enhanceId in pairs(allEnhanceIds) do + local enhanceCfg = XSuperTowerConfigs.GetEnhanceCfgById(enhanceId) + if not getDic[enhanceId] and (showAll or enhanceCfg.CharacterId == 0 or + (enhanceCfg.CharacterId > 0 and characterIdDic[enhanceCfg.CharacterId])) then + local data = { + EnhanceId = enhanceId, + IsExist = false, + Priority = enhanceCfg.Priority + } + table.insert(resultList, data) + end + end + table.sort(resultList, function(data1, data2) + if data1.IsExist and not data2.IsExist then + return true + end + if not data1.IsExist and data2.IsExist then + return false + end + return data1.Priority < data2.Priority + end) + end + return resultList +end +--================= +--获取爬塔掉落页面插件掉落用列表 +--@param showAll:展示所有插件,否则会根据队伍成员展示掉落 +--================= +function XSuperTowerTheme:GetTierPluginDropShowList(showAll) + local resultList = {} + local dropLevels = self.EnhancerAndPluginsDropCfg.PluginsDropLevel + local dropGroupIds = self.EnhancerAndPluginsDropCfg.PluginsDropGroupId + local pluginInfos = self:GetTierPluginInfos() + local getDic = {} + for _, pluginInfo in pairs(pluginInfos) do + getDic[pluginInfo.Id] = true + end + for _, pluginInfo in pairs(pluginInfos) do + for i = 1, pluginInfo.Count do + local pluginCfg = XSuperTowerConfigs.GetPluginCfgById(pluginInfo.Id) + local data = { + PluginId = pluginCfg.Id, + IsExist = true, + Level = 1, + Priority = pluginCfg.Priority + } + table.insert(resultList, data) + end + end + local characterIdDic = {} + if not showAll then + local team = XDataCenter.SuperTowerManager.GetTeamByStageType(XDataCenter.SuperTowerManager.StageType.LllimitedTower) + for i = 1, 3 do + local id = team:GetEntityIdByTeamPos(i) + if id > 0 then + local role = XDataCenter.SuperTowerManager.GetRoleManager():GetRole(id) + characterIdDic[role:GetCharacterId()] = true + end + end + end + for index, level in pairs(dropLevels) do + local pluginList = XSuperTowerConfigs.GetPluginIdListByGroupId(dropGroupIds[index]) + if pluginList then + for _, pluginId in pairs(pluginList) do + local pluginCfg = XSuperTowerConfigs.GetPluginCfgById(pluginId) + if not getDic[pluginCfg.Id] and (showAll or pluginCfg.CharacterId == 0 or + (pluginCfg.CharacterId > 0 and characterIdDic[pluginCfg.CharacterId])) then + local data = { + PluginId = pluginId, + IsExist = false, + Level = level, + Priority = pluginCfg.Priority + } + table.insert(resultList, data) + end + end + end + end + table.sort(resultList, function(data1, data2) + if data1.IsExist and not data2.IsExist then + return true + end + if not data1.IsExist and data2.IsExist then + return false + end + if not data1.IsExist and data1.Level ~= data2.Level then + return data1.Level < data2.Level + end + return data1.Priority < data2.Priority + end) + return resultList +end + +return XSuperTowerTheme \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XSuperTower/Stages/XSuperTowerTierManager.lua b/Resources/Scripts/XEntity/XSuperTower/Stages/XSuperTowerTierManager.lua new file mode 100644 index 00000000..af791623 --- /dev/null +++ b/Resources/Scripts/XEntity/XSuperTower/Stages/XSuperTowerTierManager.lua @@ -0,0 +1,275 @@ +--=========================== +--超级爬塔 爬塔关卡 管理器 +--模块负责:吕天元 +--=========================== +local XSuperTowerTierManager = XClass(nil, "XSuperTowerTierManager") +local StageType = { + None = 0, -- 缺省类型,表示空值(用于查询时) + SingleTeamOneWave = 1, -- 单队伍单波 + SingleTeamMultiWave = 2, -- 单队伍多波 + MultiTeamMultiWave = 3, -- 多队伍多波 + LllimitedTower = 4, -- 无限爬塔 +} +function XSuperTowerTierManager:Ctor(theme) + self.Theme = theme + self:Init() +end +--================= +--初始化管理器 +--================= +function XSuperTowerTierManager:Init() + self:InitTierStages() +end +--================= +--初始化爬塔关卡 +--================= +function XSuperTowerTierManager:InitTierStages() + local stageList = XSuperTowerConfigs.GetTierStagesByThemeId(self.Theme:GetId()) + local script = require("XEntity/XSuperTower/Stages/XSuperTowerTierStage") + self.TierStages = {} + self.MaxScore = 0 + self.MaxTier = #stageList + for tier, tierStage in pairs(stageList) do + self.TierStages[tier] = script.New(self, tierStage) + self.MaxScore = self.MaxScore + self.TierStages[tier]:GetMaxScore() + local stageId = self.TierStages[tier]:GetStageId() + if not self.Theme.StageId2StageType[stageId] then + self.Theme.StageId2StageType[stageId] = StageType.LllimitedTower + self.Theme.StageId2Index[stageId] = 1 + end + end +end + +function XSuperTowerTierManager:InitStageInfo() + for _, tierStage in pairs(self.TierStages) do + tierStage:InitStageInfo() + end +end +--================= +--爬塔状态重置 +--================= +function XSuperTowerTierManager:Reset() + --重置时,若是新的层纪录,则刷新历史记录 + if self.IsNewTierRecord then + self.HistoryHighestTier = self.CurrentTier + end + --重置时,若是新的层纪录,则刷新历史记录 + if self.IsNewScoreRecord then + self.HistoryHighestScore = self.CurrentScore + end + self.CurrentTier = 0 + self.IsNewTierRecord = false + self.CurrentScore = 0 + self.IsNewScoreRecord = false + self.EnhancerIds = nil + self.PluginInfos = nil + self:ResetTierChara() +end +--================= +--刷新推送数据 +--@param data(StTierInfo):{ +--当前层 int Tier, +--历史最高层 int MaxTier, +--当前积分 int Score, +--历史最高积分 int MaxScore, +--增益列表 List EnhancerIds, +--插件列表 List PluginInfos, +--出战角色列表 List CharacterInfos +--} +--================= +function XSuperTowerTierManager:RefreshNotifyData(data, needReset) + --if not needReset then + self.CurrentTier = data.Tier + self.CurrentScore = data.Score + self.EnhancerIds = data.EnhancerIds + self.PluginInfos = data.PluginInfos + if self:CheckIsPlaying() then + self:RefreshTierChara(data.TeamInfo) + end + --end + self.IsNewTierRecord = self.CurrentTier > self:GetHistoryHighestTier() + self.IsNewScoreRecord = self.CurrentScore > self:GetHistoryHighestScore() + if not needReset then + self.HistoryHighestTier = data.MaxTier + self.HistoryHighestScore = data.MaxScore + end + self:SetResetFlag(needReset or false) +end +--================= +--通知角色管理器爬塔状态重置 +--================= +function XSuperTowerTierManager:ResetTierChara() + XDataCenter.SuperTowerManager.GetRoleManager():ResetTierRoleData() +end +--================= +--刷新推送爬塔角色数据 +--@param data(List)StTierCharacterInfo:{ +--角色id int Id, +--血量剩余百分比 int HpLeft, +--机器人id int RobotId,(当角色是机器人时才会有值) +--} +--================= +function XSuperTowerTierManager:RefreshTierChara(infos) + local team = XDataCenter.SuperTowerManager.GetTeamByStageType(XDataCenter.SuperTowerManager.StageType.LllimitedTower) + team:UpdateFirstFightPos(infos.FirstPos) + team:UpdateCaptianPos(infos.CaptainPos) + -- 更新队伍实体位置 + local characterInfo + for pos = 1, XEntityHelper.TEAM_MAX_ROLE_COUNT do + characterInfo = infos.CharacterInfos[pos] + if characterInfo then + if characterInfo.RobotId and characterInfo.RobotId > 0 then + team:UpdateEntityTeamPos(characterInfo.RobotId, pos, true) + elseif characterInfo.Id and characterInfo.Id > 0 then + team:UpdateEntityTeamPos(characterInfo.Id, pos, true) + else + team:UpdateEntityTeamPos(0, pos, true) + end + else + team:UpdateEntityTeamPos(0, pos, true) + end + end + XDataCenter.SuperTowerManager.GetRoleManager():RefreshTierRoleData(infos.CharacterInfos) +end +--================= +--根据层数获取爬塔关卡对象 +--@param tier:层数 +--================= +function XSuperTowerTierManager:GetTierStageByTier(tier) + return self.TierStages[tier] +end +--================= +--获取爬塔角色数据 +--================= +function XSuperTowerTierManager:GetTeam() + return self.TeamInfos or {} +end +--================= +--获取爬塔玩家现在积分 +--================= +function XSuperTowerTierManager:GetCurrentScore() + return self.CurrentScore or 0 +end +--================= +--获取爬塔玩家历史最高积分 +--================= +function XSuperTowerTierManager:GetHistoryHighestScore() + return self.HistoryHighestScore or 0 +end +--================= +--获取爬塔关卡最大可获得的积分 +--================= +function XSuperTowerTierManager:GetMaxScore() + return self.MaxScore or 0 +end +--================= +--获取爬塔关卡现在积分显示 +--格式: 历史荣誉分/最大可获得荣誉分 +--================= +function XSuperTowerTierManager:GetScoreStr() + return XUiHelper.GetText("STTierScoreStr", self:GetHistoryHighestScore(), self:GetMaxScore()) +end +--================= +--获取爬塔玩家现在层数 +--================= +function XSuperTowerTierManager:GetCurrentTier() + return self.CurrentTier or 0 +end +--================= +--获取爬塔玩家历史通过最高层 +--================= +function XSuperTowerTierManager:GetHistoryHighestTier() + return self.HistoryHighestTier or 0 +end +--================= +--获取爬塔关卡总层数 +--================= +function XSuperTowerTierManager:GetMaxTier() + return self.MaxTier or 0 +end +--================= +--获取爬塔关卡现在层数进度显示 +--================= +function XSuperTowerTierManager:GetTierStr() + return self:GetCurrentTier() .. "/" .. self:GetMaxTier() +end +--================= +--获取爬塔关卡利时最大层数进度显示 +--================= +function XSuperTowerTierManager:GetHistoryTierStr() + return self:GetHistoryHighestTier() .. "/" .. self:GetMaxTier() +end +--================= +--获取已获得的爬塔增益ID列表 +--================= +function XSuperTowerTierManager:GetEnhanceIds() + return self.EnhancerIds or {} +end +--================= +--获取已获得的插件信息 +--================= +function XSuperTowerTierManager:GetPluginInfos() + return self.PluginInfos or {} +end +--================= +--获取爬塔分数上限值 +--================= +function XSuperTowerTierManager:GetMaxScore() + return self.MaxScore +end +--================= +--检查现在是否正在爬塔 +--================= +function XSuperTowerTierManager:CheckIsPlaying() + return self:GetCurrentTier() > 0 +end +--================= +--检查最新的更新是否刷新了新层数纪录 +--================= +function XSuperTowerTierManager:CheckIsNewTierRecord() + return self.IsNewTierRecord +end +--================= +--检查最新的更新是否刷新了分数纪录 +--================= +function XSuperTowerTierManager:CheckIsNewScoreRecord() + return self.IsNewScoreRecord +end +--================= +--检查重置标记,若需重置则重置爬塔 +--================= +function XSuperTowerTierManager:CheckReset() + if not self.ResetFlag then return end + self.ResetFlag = false + self:Reset() +end +--================= +--获取当前重置标记状态 +--================= +function XSuperTowerTierManager:GetResetFlag() + return self.ResetFlag +end +--================= +--设置当前重置标记状态 +--================= +function XSuperTowerTierManager:SetResetFlag(value) + self.ResetFlag = value +end +--================= +--根据分数类型获取爬塔分数计数 +--@param scoreType:分数类型 XSuperTowerManager.ScoreType +--================= +function XSuperTowerTierManager:GetTierScoreCountByScoreType(scoreType) + local count = 0 + local score = 0 + for i = 1, self:GetCurrentTier() do + local num = self.TierStages[i]:GetScoreByIndex(scoreType) + if num > 0 then + count = count + 1 + score = score + num + end + end + return count, score +end + +return XSuperTowerTierManager \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XSuperTower/Stages/XSuperTowerTierStage.lua b/Resources/Scripts/XEntity/XSuperTower/Stages/XSuperTowerTierStage.lua new file mode 100644 index 00000000..1016bb36 --- /dev/null +++ b/Resources/Scripts/XEntity/XSuperTower/Stages/XSuperTowerTierStage.lua @@ -0,0 +1,73 @@ +--=========================== +--超级爬塔 爬塔关卡 实体 +--模块负责:吕天元 +--=========================== +local XSuperTowerTierStage = XClass(nil, "XSuperTowerTierStage") + +function XSuperTowerTierStage:Ctor(tierManager, cfg) + self.TierManager = tierManager + self.TierCfg = cfg +end + +function XSuperTowerTierStage:InitStageInfo() + local stageId = self:GetStageId() + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + if stageInfo then + stageInfo.Type = XDataCenter.FubenManager.StageType.SuperTower + end +end +--================= +--获取配置表ID +--================= +function XSuperTowerTierStage:GetId() + return self.TierCfg and self.TierCfg.Id +end +--================= +--获取关卡ID +--================= +function XSuperTowerTierStage:GetStageId() + return self.TierCfg and self.TierCfg.StageId +end +--================= +--获取层数 +--================= +function XSuperTowerTierStage:GetTier() + return self.TierCfg and self.TierCfg.Tier +end +--================= +--获取对应主题ID +--================= +function XSuperTowerTierStage:GetMapId() + return self.TierCfg and self.TierCfg.MapId +end +--================= +--获取插件掉落ID +--================= +function XSuperTowerTierStage:GetPluginDropId() + return self.TierCfg and self.TierCfg.PluginDropId +end +--================= +--获取分数 +--================= +function XSuperTowerTierStage:GetScore() + return self.TierCfg and self.TierCfg.Score +end +--================= +--获取积分类型 +--================= +function XSuperTowerTierStage:GetScoreByIndex(index) + local score = self:GetScore() + return score and score[index] +end + +function XSuperTowerTierStage:GetMaxScore() + if not self.MaxScore then + self.MaxScore = 0 + local score = self:GetScore() + for _, point in pairs(score) do + self.MaxScore = self.MaxScore + point + end + end + return self.MaxScore +end +return XSuperTowerTierStage \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XSuperTower/XCollectionManager.lua b/Resources/Scripts/XEntity/XSuperTower/XCollectionManager.lua new file mode 100644 index 00000000..bf7f6233 --- /dev/null +++ b/Resources/Scripts/XEntity/XSuperTower/XCollectionManager.lua @@ -0,0 +1,84 @@ +local XCollectionManager = XClass(nil, "XCollectionManager") + +function XCollectionManager:Ctor() + self.Datas = {} + self.CurrentCapacity = 0 + self.MaxCapacity = 0 +end + +function XCollectionManager:InitDatas(datas) + self.Datas = datas +end + +function XCollectionManager:UpdateCurrentCapacity(value) + self.CurrentCapacity = value +end + +function XCollectionManager:UpdateMaxCapacity(value) + self.MaxCapacity = value +end + +function XCollectionManager:GetMaxCapacity() + return self.MaxCapacity +end + +function XCollectionManager:GetCurrentCapacity() + return self.CurrentCapacity +end + +function XCollectionManager:AddData(data) + table.insert(self.Datas, data) +end + +function XCollectionManager:DeleteData(id) + local data + for i = #self.Datas, 1, -1 do + data = self.Datas[i] + if self:GetDataIsEqual(data, id) then + table.remove(self.Datas, i) + break + end + end +end + +function XCollectionManager:GetIsHaveData(id) + local data = self:GetData(id) + if not data then return false end + return data:GetCount() > 0 +end + +function XCollectionManager:GetData(id) + local data + for i = #self.Datas, 1, -1 do + data = self.Datas[i] + if self:GetDataIsEqual(data, id) then + return data + end + end + return nil +end + +function XCollectionManager:GetDatas() + return self.Datas +end + +function XCollectionManager:UpdateData(id, data) + local data + for i = #self.Datas, 1, -1 do + data = self.Datas[i] + if self:GetDataIsEqual(data, id) then + self.Datas[i] = data + break + end + end +end + +--######################## 私有方法 ######################## + +function XCollectionManager:GetDataIsEqual(data, id) + -- 兼容直接id的写法与获取id的写法 + return (data.Id and data.Id == id) + or (data.GetId and type(data.GetId) == "function" and data:GetId() == id) +end + +return XCollectionManager \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XSuperTower/XSuperTowerBagManager.lua b/Resources/Scripts/XEntity/XSuperTower/XSuperTowerBagManager.lua new file mode 100644 index 00000000..73a1028f --- /dev/null +++ b/Resources/Scripts/XEntity/XSuperTower/XSuperTowerBagManager.lua @@ -0,0 +1,316 @@ +local XCollectionManager = require("XEntity/XSuperTower/XCollectionManager") +local XSuperTowerPlugin = require("XEntity/XSuperTower/Plugin/XSuperTowerPlugin") +local XSuperTowerBagManager = XClass(XCollectionManager, "XSuperTowerBagManager") + +local SortByPriority = function(pluginA, pluginB) + return pluginA:GetPriority() < pluginB:GetPriority() +end + +function XSuperTowerBagManager:Ctor() + -- 图鉴数据 + self.PokedexPluginDic = {} + self.PluginSynthesisQueue = XQueue.New() + self.BagMaxCapacityUpdate = false + -- self:InitServerApi() +end + +-- data : StBagInfo +function XSuperTowerBagManager:InitWithServerData(data) + -- 更新背包容量 + self:UpdateMaxCapacity(data.Capacity) + -- 更新背包插件 + -- pluginInfo : StPluginInfo + for _, pluginInfo in ipairs(data.PluginInfos) do + self:AddPlugin(pluginInfo) + end +end + +-- data : StPluginInfo +function XSuperTowerBagManager:AddPlugin(data) + -- 增加图鉴标志 + self.PokedexPluginDic[data.Id] = true + if data.Count > 0 then + local plugin = XSuperTowerPlugin.New(data.Id) + plugin:InitWithServerData(data) + self:AddData(plugin) + end +end + +function XSuperTowerBagManager:DeletePlugin(id, count) + local plugin = self:GetPlugin(id) + plugin:UpdateCount(plugin:GetCount() - count) + if plugin:GetCount() <= 0 then + self:DeleteData(id) + end +end + +function XSuperTowerBagManager:GetPlugins(isAscendOrder) + local pluginsNotSplit = self:GetDatas() + local result = {} + local tmpPlugin = nil + for _, plugin in ipairs(pluginsNotSplit) do + for i = 1, plugin:GetCount() do + tmpPlugin = XSuperTowerPlugin.New(plugin:GetId()) + tmpPlugin:UpdateCount(1) + table.insert(result, tmpPlugin) + end + end + if isAscendOrder ~= nil then + local ascendWeight = -1 + if isAscendOrder then + ascendWeight = 1 + end + table.sort(result, function(pluginA, pluginB) + local sortWeigthA = ascendWeight * (pluginA:GetId() + pluginA:GetQuality() * 100000000) + local sortWeigthB = ascendWeight * (pluginB:GetId() + pluginB:GetQuality() * 100000000) + return sortWeigthA > sortWeigthB + end) + end + return result +end + +function XSuperTowerBagManager:GetPluginsByPrior() + local pluginsNotSplit = self:GetDatas() + local result = {} + local tmpPlugin = nil + for _, plugin in ipairs(pluginsNotSplit) do + for i = 1, plugin:GetCount() do + tmpPlugin = XSuperTowerPlugin.New(plugin:GetId()) + tmpPlugin:UpdateCount(1) + table.insert(result, tmpPlugin) + end + end + table.sort(result, SortByPriority) + return result +end + +function XSuperTowerBagManager:GetPlugin(id) + return self:GetData(id) +end + + +-- 根据插件id来更新数量 +function XSuperTowerBagManager:UpdatePluginCount(pluginId, count) + local plugin = self:GetData(pluginId) + plugin:UpdateCount(count) + if plugin:GetCount() <= 0 then + self:DeleteData(plugin:GetId()) + end +end + +function XSuperTowerBagManager:UpdatePluginDic(pluginDic) + for pluginId, count in pairs(pluginDic) do + self:UpdatePluginCount(pluginId, count) + end +end + +function XSuperTowerBagManager:UpdateMaxCapacity(value) + if self.MaxCapacity > 0 then + if not self.LastMaxCapacity then + self.LastMaxCapacity = self.MaxCapacity + end + self.BagMaxCapacityUpdate = true + end + self.MaxCapacity = value +end + +function XSuperTowerBagManager:CheckMaxCapacityUpdate() + if self.BagMaxCapacityUpdate then + self.BagMaxCapacityUpdate = false + local last = self.LastMaxCapacity + self.LastMaxCapacity = nil + return true, last, self:GetMaxCapacity() + end + return false +end + +function XSuperTowerBagManager:GetCurrentCapacity() + local allPlugins = self:GetPlugins() + local result = 0 + for _, plugin in pairs(allPlugins) do + result = result + plugin:GetCapacity() + end + return result +end + +function XSuperTowerBagManager:PluginSynEnqueue(oldList, newList) + local data = { + Old = oldList, + New = newList, + } + self.PluginSynthesisQueue:Enqueue(data) +end + +function XSuperTowerBagManager:GetPluginSyn() + if self.PluginSynthesisQueue:IsEmpty() then + return nil + end + local data = self.PluginSynthesisQueue:Dequeue() + return data and data.Old or nil, data and data.New or nil +end + +-- starGroup : { [star] = true, ... } +function XSuperTowerBagManager:GetPluginsWithStarFilter(starGroup, isAscendOrder) + local plugins = self:GetPlugins(isAscendOrder) + local result = {} + for _, plugin in ipairs(plugins) do + if starGroup[plugin:GetStar()] then + table.insert(result, plugin) + end + end + return result +end + +function XSuperTowerBagManager:CheckHasPluginWithStarFilter(star) + local plugins = self:GetPlugins() + for _, plugin in ipairs(plugins) do + if plugin:GetStar() <= star then + return true + end + end + return false +end + +function XSuperTowerBagManager:GetCapacityPercentsByStar(star) + local plugins = self:GetDatas() + local starTotalCapacity = 0 + -- local totalCapacity = 0 + for _, plugin in ipairs(plugins) do + -- totalCapacity = totalCapacity + plugin:GetCapacity() + if plugin:GetStar() == star then + starTotalCapacity = starTotalCapacity + plugin:GetCapacity() + end + end + -- if totalCapacity == 0 then return totalCapacity end + return getRoundingValue(starTotalCapacity / self:GetMaxCapacity(), 3) +end + +-- 获取图鉴插件数组 +-- return 1 : 已获得的图鉴插件 +-- return 2 : 未获得的图鉴插件 +function XSuperTowerBagManager:GetIllusPluginList(filter) + --[[local pluginConfigs = XSuperTowerConfigs.GetAllPluginCfgs() + local result1 = {} -- 已获得的图鉴插件 + local result2 = {} -- 未获得的图鉴插件 + local plugin + for _, config in pairs(pluginConfigs) do + plugin = XSuperTowerPlugin.New(config.Id) + if self.PokedexPluginDic[plugin:GetId()] then + table.insert(result1, plugin) + else + table.insert(result2, plugin) + end + end + return result1, result2]] --注释掉需要区分历史有无获得过的条件 + local pluginConfigs = XSuperTowerConfigs.GetAllPluginCfgs() + local result = {} + local noFilter = true + if filter and next(filter) then noFilter = false end + for _, config in pairs(pluginConfigs) do + if config.IsShowInLibrary and config.IsShowInLibrary > 0 then + if not noFilter and filter[config.Quality] then + local plugin = XSuperTowerPlugin.New(config.Id) + table.insert(result, plugin) + elseif noFilter then + local plugin = XSuperTowerPlugin.New(config.Id) + table.insert(result, plugin) + end + end + end + table.sort(result, SortByPriority) + return result +end + +function XSuperTowerBagManager:RequestResolvePlugin(resolveDic) + local requestData = { + ResolveDic = resolveDic, + } + XMessagePack.MarkAsTable(requestData.ResolveDic) + -- res : StResolvePluginResponse(RewardGoodsList) + XNetwork.Call("StResolvePluginRequest", requestData, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XUiManager.OpenUiObtain(res.RewardGoodsList) + end) +end + +--######################## 私有方法 ######################## + +-- function XSuperTowerBagManager:InitServerApi() +-- -- 背包最大容量 +-- XRpc.NotifyStBagCapacity = function(data) +-- self:UpdateMaxCapacity(data.Capacity) +-- end +-- -- 背包插件更新 +-- XRpc.NotifyStBagPluginChange = function(data) +-- self:OnBagPluginChange(data) +-- end +-- -- 通知背包插件合成数据 +-- -- data : List +-- XRpc.NotifyStBagPluginSynthesisData = function(pluginSynthesisInfos) +-- self:OnBagPluginSynthesisData(pluginSynthesisInfos) +-- end +-- end + +function XSuperTowerBagManager:OnBagPluginChange(data) + -- List Id && Count + local changePluginInfos = data.ChangePluginInfos + local plugin + for _, pluginInfo in ipairs(changePluginInfos) do + -- 删除变化 + if pluginInfo.Count <= 0 then + self:DeleteData(pluginInfo.Id) + else + plugin = self:GetData(pluginInfo.Id) + -- 更新变化 + if plugin then + plugin:UpdateWithServerData(pluginInfo) + else -- 增加变化 + self:AddPlugin(pluginInfo) + end + end + end + XEventManager.DispatchEvent(XEventId.EVENT_ST_PLUGIN_REFRESH) +end + +function XSuperTowerBagManager:OnBagPluginSynthesisData(pluginSynthesisInfos) + local result1 = {} -- 旧的插件数据 + local result2 = {} -- 新的插件数据 + --对比旧列表和新列表中重复的ID数量插件,去掉(此为多次合成的中途插件,最终不显示) + local oldPluginDic = {} + for _, pluginSynthesisInfo in pairs(pluginSynthesisInfos.SynthesisInfos) do + if pluginSynthesisInfo.Id and pluginSynthesisInfo.Id > 0 and not oldPluginDic[pluginSynthesisInfo.Id] then + oldPluginDic[pluginSynthesisInfo.Id] = pluginSynthesisInfo + end + end + for _, pluginSynthesisInfo in pairs(pluginSynthesisInfos.SynthesisInfos) do + if pluginSynthesisInfo.NewId and pluginSynthesisInfo.NewId > 0 and oldPluginDic[pluginSynthesisInfo.NewId] then + for i = 1, pluginSynthesisInfo.NewCount do + oldPluginDic[pluginSynthesisInfo.NewId].Count = oldPluginDic[pluginSynthesisInfo.NewId].Count - 1 + end + pluginSynthesisInfo.NewCount = 0 + end + end + --记录处理后的新旧合成列表 + local tmpPlugin + for _, pluginSynthesisInfo in ipairs(pluginSynthesisInfos.SynthesisInfos) do + -- 旧插件数据 + for i = 1, pluginSynthesisInfo.Count do + tmpPlugin = XSuperTowerPlugin.New(pluginSynthesisInfo.Id) + tmpPlugin:UpdateCount(1) + table.insert(result1, tmpPlugin) + end + -- 新插件数据 + for i = 1, pluginSynthesisInfo.NewCount do + tmpPlugin = XSuperTowerPlugin.New(pluginSynthesisInfo.NewId) + tmpPlugin:UpdateCount(1) + table.insert(result2, tmpPlugin) + end + end + + XDataCenter.SuperTowerManager.GetBagManager():PluginSynEnqueue(result1, result2) +end + +return XSuperTowerBagManager \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XSuperTower/XSuperTowerPluginSlotManager.lua b/Resources/Scripts/XEntity/XSuperTower/XSuperTowerPluginSlotManager.lua new file mode 100644 index 00000000..9da6b972 --- /dev/null +++ b/Resources/Scripts/XEntity/XSuperTower/XSuperTowerPluginSlotManager.lua @@ -0,0 +1,158 @@ +local XSuperTowerPlugin = require("XEntity/XSuperTower/Plugin/XSuperTowerPlugin") +local XSuperTowerPluginSlotManager = XClass(nil, "XSuperTowerPluginSlotManager") + +function XSuperTowerPluginSlotManager:Ctor() + self.PluginSlots = {} + self.MaxCapacity = XSuperTowerConfigs.GetBaseConfigByKey("MaxTeamPluginCount") + self.CurrentCapacity = 0 + self.StageId = nil +end + +function XSuperTowerPluginSlotManager:SetStageId(value) + self.StageId = value +end + +function XSuperTowerPluginSlotManager:SetMaxCapacity(value) + self.MaxCapacity = value +end + +function XSuperTowerPluginSlotManager:GetStageId() + return self.StageId +end +--=========================== +--把另一个Slot的内容添加入此Slot +--=========================== +function XSuperTowerPluginSlotManager:AddSlot(pluginSlot) + local addPluginList = pluginSlot:GetPluginsNotSplit() + if addPluginList and #addPluginList == 0 then return end + local originPluginList = self:GetPluginsNotSplit() + local originDic = {} + for _, originPlugin in pairs(originPluginList) do + originDic[originPlugin:GetId()] = originPlugin + end + self:Clear() + for _, plugin in pairs(addPluginList) do + local originPlugin = originDic[plugin:GetId()] + if originPlugin then + originPlugin:UpdateCount(originPlugin:GetCount() + plugin:GetCount()) + else + originDic[plugin:GetId()] = plugin + end + end + for _, newPlugin in pairs(originDic) do + self:AddPluginById(newPlugin:GetId(), newPlugin:GetCount()) + end +end + +function XSuperTowerPluginSlotManager:AddPluginById(pluginId, count) + if not pluginId then return end + for i = 1, count do + local plugin = XSuperTowerPlugin.New(pluginId) + plugin:UpdateCount(1) + self:AddPlugin(plugin) + end +end + +-- plugin : XSuperTowerPlugin +function XSuperTowerPluginSlotManager:AddPlugin(plugin, slot) + if not plugin then return end + if slot ~= nil then + if self.PluginSlots[slot] == 0 or self.PluginSlots[slot] == nil then + self.CurrentCapacity = self.CurrentCapacity + 1 + end + self.PluginSlots[slot] = plugin + else + for i = 1, self.MaxCapacity do + if self.PluginSlots[i] == 0 or self.PluginSlots[i] == nil then + self.PluginSlots[i] = plugin + self.CurrentCapacity = self.CurrentCapacity + 1 + return i + end + end + end + return slot +end + +function XSuperTowerPluginSlotManager:DeletePlugin(slot) + if slot == nil then return end + local plugin = self.PluginSlots[slot] + if plugin then + self.CurrentCapacity = self.CurrentCapacity - 1 + end + self.PluginSlots[slot] = 0 +end + +-- return : { plugin, plugin, 0, plugin } +-- PS: 0是数组的占位符,通过0判断该槽位为nil,直接设置为nil的话到导致数组遍历连续 +function XSuperTowerPluginSlotManager:GetPlugins(isCheckBag) + if isCheckBag then + local result = XTool.Clone(self.PluginSlots) + local bagManager = XDataCenter.SuperTowerManager.GetBagManager() + for i, plugin in ipairs(self.PluginSlots) do + if type(plugin) == "table" and not bagManager:GetIsHaveData(plugin:GetId()) then + result[i] = 0 + end + end + return result + end + return self.PluginSlots +end + +function XSuperTowerPluginSlotManager:GetPluginsSplit() + local result = {} + for _, plugin in pairs(self.PluginSlots) do + if type(plugin) == "table" then + table.insert(result, plugin) + end + end + return result +end + +function XSuperTowerPluginSlotManager:GetPluginsNotSplit() + local result = {} + local pluginCountDic = {} + local pluginId + for _, plugin in pairs(self.PluginSlots) do + if type(plugin) == "table" then + pluginId = plugin:GetId() + pluginCountDic[pluginId] = pluginCountDic[pluginId] or 0 + pluginCountDic[pluginId] = pluginCountDic[pluginId] + plugin:GetCount() + end + end + local plugin + for pluginId, count in pairs(pluginCountDic) do + if count > 0 then + plugin = XSuperTowerPlugin.New(pluginId) + plugin:UpdateCount(count) + table.insert(result, plugin) + end + end + return result +end + +function XSuperTowerPluginSlotManager:Clear() + self.PluginSlots = {} + self.StageId = nil + self.CurrentCapacity = 0 +end + +function XSuperTowerPluginSlotManager:GetIsEmpty() + return self.CurrentCapacity <= 0 + -- if #self.PluginSlots <= 0 then return true end + -- for _, plugin in ipairs(self.PluginSlots) do + -- if type(plugin) == "table" then + -- return false + -- end + -- end + -- return true +end + +function XSuperTowerPluginSlotManager:GetCurrentCapacity() + return self.CurrentCapacity +end + +function XSuperTowerPluginSlotManager:GetMaxCapacity() + return self.MaxCapacity +end + +return XSuperTowerPluginSlotManager \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XSuperTower/XSuperTowerTeamManager.lua b/Resources/Scripts/XEntity/XSuperTower/XSuperTowerTeamManager.lua new file mode 100644 index 00000000..cf56ec13 --- /dev/null +++ b/Resources/Scripts/XEntity/XSuperTower/XSuperTowerTeamManager.lua @@ -0,0 +1,231 @@ +local XSuperTowerPluginSlotManager = require("XEntity/XSuperTower/XSuperTowerPluginSlotManager") +local XTeam = require("XEntity/XTeam/XTeam") +local XSuperTowerTeamManager = XClass(nil, "XSuperTowerTeamManager") + +function XSuperTowerTeamManager:Ctor() + -- key : id, value : XTeam + self.TeamDic = nil + self.TeamDic = {} +end + +local CreateRealTeamId = function(teamId, index) + return string.format("%sSuperTower%s_%s_%s",XPlayer.Id, XDataCenter.SuperTowerManager.GetActivityId(), teamId, index or 1) +end + +function XSuperTowerTeamManager:GetTeamById(teamId, index)--单队伍类型时不需要设置关卡序号(有且仅有1),默认为1 + local teamId = CreateRealTeamId(teamId, index) + local result = self.TeamDic[teamId] + if not result then + result = XTeam.New(teamId) + result:UpdateExtraData(XSuperTowerPluginSlotManager.New()) + --result:UpdateSaveCallback(function(team) + --self:HandleTeamSaveCallback(team) + --end) + self.TeamDic[teamId] = result + end + return result +end + +function XSuperTowerTeamManager:ClearTeam(teamId, index)--单队伍类型时不需要设置关卡序号(有且仅有1),默认为1 + local teamId = CreateRealTeamId(teamId, index) + local team = self.TeamDic[teamId] + if team then + team:Clear() + end +end +--[[ + teamId:队伍类型ID(XSuperTowerManager.TeamId) + teamCount:本关队伍数量 + entityId:成员ID + 检查某个成员是否在队伍/其他队伍中,返回队伍编号,如果没有在任何队伍则返回0 +]] +function XSuperTowerTeamManager:CheckMemberIsInTeam(teamId, teamCount, entityId) + for index = 1, teamCount do + local teamId = CreateRealTeamId(teamId, index) + if teamId then + local team = self.TeamDic[teamId] + local entityList = team and team:GetEntityIds() or {} + for _,id in pairs(entityList) do + if id == entityId then + return index, team + end + end + end + end + return 0 +end + +function XSuperTowerTeamManager:GetTeamsByIdAndCount(teamId, teamCount) + local result = {} + for index = 1, teamCount do + local teamId = CreateRealTeamId(teamId, index) + if teamId then + local team = self.TeamDic[teamId] + if team then + table.insert(result, team) + end + end + end + return result +end + +--[[ + 没有任何插件,给提示 + 有插件,但不是合适的插件,并且当前是空状态,给提示 + 有插件,但不是合适的插件,不是空状态,不给提示 +]] +-- return : 是否一键上阵了插件,true为有上阵,false为无上阵 +function XSuperTowerTeamManager:AutoSelectPlugins2Teams(teams) + local plugins = XDataCenter.SuperTowerManager.GetBagManager():GetPlugins() + if not plugins or not next(plugins) then + XUiManager.TipText("STNoPlugin") + return false + end + -- 所有队伍的插件状态是否都是空的 + local isEmptyStatus = true + -- 队伍已经使用的插件 + local usedPluginDic = {} + local teamPlugins, pluginId + -- 将队伍正在使用的插件拿出来 + for _, team in ipairs(teams) do + teamPlugins = team:GetExtraData():GetPlugins(true) + for _, plugin in ipairs(teamPlugins) do + if plugin ~= 0 then + pluginId = plugin:GetId() + usedPluginDic[pluginId] = usedPluginDic[pluginId] or 0 + usedPluginDic[pluginId] = usedPluginDic[pluginId] + 1 + isEmptyStatus = false + end + end + end + local plugin + -- 和背包作比较,拿剩下的做自动选择 + for i = #plugins, 1, -1 do + plugin = plugins[i] + pluginId = plugin:GetId() + if usedPluginDic[pluginId] ~= nil and usedPluginDic[pluginId] > 0 then + table.remove(plugins, i) + usedPluginDic[pluginId] = usedPluginDic[pluginId] - 1 + end + end + local oldCount = #plugins + if oldCount <= 0 then return false end + for _, team in ipairs(teams) do + plugins = self:AutoSelectPlugins2Team(team, plugins) + end + if isEmptyStatus and oldCount == #plugins then + XUiManager.TipText("STNoPlugin") + return false + end + return true +end + +--######################## 私有方法 ######################## + +-- team : XTeam +function XSuperTowerTeamManager:SetTargetFightTeam(teamList, stageId, callback) + local teamInfos = {} + for teamIndex,team in pairs(teamList or {}) do + local pluginSlotManager = team:GetExtraData() + + -- 消耗的插件数据 + local pluginInfos = {} + for _, plugin in pairs(pluginSlotManager:GetPluginsNotSplit()) do + table.insert(pluginInfos, { + Id = plugin:GetId(), + Count = plugin:GetCount() + }) + end + -- 成员数据 + local characterInfos = {} + for index, entityId in ipairs(team:GetEntityIds()) do + characterInfos[index] = {} + local roleManager = XDataCenter.SuperTowerManager.GetRoleManager() + local role = roleManager:GetRole(entityId) + if not role then + characterInfos[index].Id = 0 + characterInfos[index].RobotId = 0 + elseif role:GetIsRobot() then + characterInfos[index].Id = role:GetCharacterId() + characterInfos[index].RobotId = entityId + else + characterInfos[index].Id = entityId + characterInfos[index].RobotId = 0 + end + end + + teamInfos[teamIndex] = {} + teamInfos[teamIndex].Id = teamIndex + teamInfos[teamIndex].CaptainPos = team:GetCaptainPos() + teamInfos[teamIndex].FirstPos = team:GetFirstFightPos() + teamInfos[teamIndex].PluginInfos = pluginInfos + teamInfos[teamIndex].CharacterInfos = characterInfos + end + + self:RequestSetTargetFightTeam(stageId, teamInfos, callback) +end + +-- StTargetFightTeamInfo array +-- { Id, CaptainPos, FirstPos } +function XSuperTowerTeamManager:RequestSetTargetFightTeam(stageId, teamInfos, callback) + if not stageId then return end + local requestData = { + TargetId = XDataCenter.SuperTowerManager.GetTargetStageIdByStageId(stageId), + TeamInfos = teamInfos + } + + XNetwork.Call("StSetTargetFightTeamRequest", requestData, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + if callback then callback() end + end) +end + +-- team : XTeam +function XSuperTowerTeamManager:AutoSelectPlugins2Team(team, plugins) + if plugins == nil then plugins = XDataCenter.SuperTowerManager.GetBagManager():GetPlugins() end + local characterContainValueDic = {} + local entityIds = team:GetEntityIds() + local characterId + local teamCharacterIdDic = {} + for pos, entityId in ipairs(entityIds) do + if entityId ~= 0 then + characterId = XEntityHelper.GetCharacterIdByEntityId(entityId) + -- 位置越前权重越大 + characterContainValueDic[characterId] = 10 - pos + teamCharacterIdDic[characterId] = true + end + end + table.sort(plugins, function(pluginA, pluginB) + local containValueA = characterContainValueDic[pluginA:GetCharacterId()] + local containValueB = characterContainValueDic[pluginB:GetCharacterId()] + -- 根据位置设置插件权重 + local characterWeightA = containValueA and containValueA * 1000000000 or 0 + local characterWeightB = containValueB and containValueB * 1000000000 or 0 + local sortWeightA = pluginA:GetId() + pluginA:GetQuality() * 100000000 + characterWeightA + pluginA:GetPriority() + local sortWeightB = pluginB:GetId() + pluginB:GetQuality() * 100000000 + characterWeightB + pluginB:GetPriority() + return sortWeightA < sortWeightB + end) + local pluginSlotManager = team:GetExtraData() + local maxCapacity = pluginSlotManager:GetMaxCapacity() + local plugin, pluginCharacterId + for i = #plugins, 1, -1 do + plugin = plugins[i] + -- 如果插件是角色专属插件,同时又是不属于本队伍角色,一律不上 + pluginCharacterId = plugin:GetCharacterId() + -- 属于通用插件、插件专属角色id是否在队伍里和排除掉所有角色专属槽插件 + if not XSuperTowerConfigs.GetPluginIdIsCharacterSlot(plugin:GetId()) + and (pluginCharacterId <= 0 or teamCharacterIdDic[pluginCharacterId]) then + pluginSlotManager:AddPlugin(plugin) + table.remove(plugins, i) + if pluginSlotManager:GetCurrentCapacity() >= maxCapacity then + break + end + end + end + return plugins +end + +return XSuperTowerTeamManager \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XTRPG/XTRPGBaseInfo.lua b/Resources/Scripts/XEntity/XTRPG/XTRPGBaseInfo.lua new file mode 100644 index 00000000..e692d68b --- /dev/null +++ b/Resources/Scripts/XEntity/XTRPG/XTRPGBaseInfo.lua @@ -0,0 +1,96 @@ +local type = type + +local XTRPGBaseInfo = XClass(nil, "XTRPGBaseInfo") + +local Default = { + __Level = 1, --探索等级 + __Exp = 0, --探索经验 + __Endurance = 0, --当前耐力 + __MaxEndurance = 0, --耐力上限 +} + +function XTRPGBaseInfo:Ctor(data) + for key, value in pairs(Default) do + if type(value) == "table" then + self[key] = {} + else + self[key] = value + end + end + + self.__MaxEndurance = CS.XGame.Config:GetInt("TrpgMaxEndurance") +end + +function XTRPGBaseInfo:UpdateData(data) + if XTool.IsTableEmpty(data) then return end + self.__Level = data.Level + self.__Exp = data.Exp + self.__Endurance = data.Endurance + + self:CheckLevelUpTips() + self:InitRedPointLevel() + XEventManager.DispatchEvent(XEventId.EVENT_TRPG_BASE_INFO_CHANGE) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_TRPG_BASE_INFO_CHANGE) +end + +function XTRPGBaseInfo:UpdateEndurance(endurance) + self.__Endurance = endurance + XEventManager.DispatchEvent(XEventId.EVENT_TRPG_BASE_INFO_CHANGE) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_TRPG_BASE_INFO_CHANGE) +end + +function XTRPGBaseInfo:GetLevel() + return self.__Level +end + +function XTRPGBaseInfo:GetExp() + return self.__Exp +end + +function XTRPGBaseInfo:GetMaxExp() + return XTRPGConfigs.GetMaxExp(self.__Level) +end + +function XTRPGBaseInfo:GetEndurance() + return self.__Endurance +end + +function XTRPGBaseInfo:GetMaxEndurance() + return self.__MaxEndurance +end + +function XTRPGBaseInfo:GetMaxTalentPoint() + return XTRPGConfigs.GetMaxTalentPoint(self.__Level) +end + +function XTRPGBaseInfo:CheckLevelUpTips() + local level = self:GetLevel() + if not self.OldLevel then + self.OldLevel = level + return + end + if self.OldLevel ~= level then + self.OldLevel = level + local text = CS.XTextManager.GetText("TRPGLevelUpTips") + XUiManager.TipMsgEnqueue(text) + end +end + +function XTRPGBaseInfo:InitRedPointLevel() + if not self.RedPointLevel then + local redPointLevel = XDataCenter.TRPGManager.GetExploreRedPointLevel() + if redPointLevel then + self.RedPointLevel = redPointLevel + else + local level = self:GetLevel() + self.RedPointLevel = level + XDataCenter.TRPGManager.SaveExploreRedPointLevel(level) + end + end +end + +function XTRPGBaseInfo:GetRedPointLevel() + return self.RedPointLevel +end + +return XTRPGBaseInfo \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XTRPG/XTRPGBossInfo.lua b/Resources/Scripts/XEntity/XTRPG/XTRPGBossInfo.lua new file mode 100644 index 00000000..4ee21fdd --- /dev/null +++ b/Resources/Scripts/XEntity/XTRPG/XTRPGBossInfo.lua @@ -0,0 +1,66 @@ +local type = type + +local XTRPGBossInfo = XClass(nil, "XTRPGBossInfo") + +local Default = { + __Id = 0, + __LoseHp = 0, --丢失血量 + __TotalHp = 0, --总血量 + __ChallengeCount = 0, --已挑战的次数 + __PhasesRewardList = {}, --奖励列表(保存已领取的奖励id) +} + +function XTRPGBossInfo:Ctor() + for key, value in pairs(Default) do + if type(value) == "table" then + self[key] = {} + else + self[key] = value + end + end +end + +function XTRPGBossInfo:UpdateBaseData(data) + if not data then return end + self.__Id = data.Id + self.__ChallengeCount = data.ChallengeCount + self:UpdatePhasesRewardList(data.PhasesRewardList) +end + +function XTRPGBossInfo:UpdateHpData(data) + self.__LoseHp = data.LoseHp + self.__TotalHp = data.TotalHp +end + +function XTRPGBossInfo:UpdatePhasesRewardList(phasesRewardList) + if not phasesRewardList then return end + for _, id in pairs(phasesRewardList) do + self.__PhasesRewardList[id] = 1 + end +end + +function XTRPGBossInfo:UpdateWorldBossChallengeCount(count) + self.__ChallengeCount = count +end + +function XTRPGBossInfo:GetId() + return self.__Id +end + +function XTRPGBossInfo:GetLoseHp() + return self.__LoseHp +end + +function XTRPGBossInfo:GetTotalHp() + return self.__TotalHp +end + +function XTRPGBossInfo:IsReceiveReward(id) + return self.__PhasesRewardList[id] +end + +function XTRPGBossInfo:GetChallengeCount() + return self.__ChallengeCount +end + +return XTRPGBossInfo \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XTRPG/XTRPGClientShopInfo.lua b/Resources/Scripts/XEntity/XTRPG/XTRPGClientShopInfo.lua new file mode 100644 index 00000000..18d21c42 --- /dev/null +++ b/Resources/Scripts/XEntity/XTRPG/XTRPGClientShopInfo.lua @@ -0,0 +1,41 @@ +local XTRPGShopInfo = require("XEntity/XTRPG/XTRPGShopInfo") + +local type = type + +local XTRPGClientShopInfo = XClass(XTRPGShopInfo, "XTRPGShopInfo") + +local DefaultMain = { + __DisCount = 100, --打折 + __AddBuyCount = 0, --增加购买上限 +} + +function XTRPGClientShopInfo:Ctor() + for key, value in pairs(DefaultMain) do + if type(value) == "table" then + self[key] = {} + else + self[key] = value + end + end +end + +function XTRPGClientShopInfo:UpdateData(data) + if not data then return end + if data.DisCount then + self.__DisCount = data.DisCount + end + if data.AddBuyCount then + self.__AddBuyCount = data.AddBuyCount + end + self:UpdateDataItemInfo(data) +end + +function XTRPGClientShopInfo:GetDisCount() + return self.__DisCount +end + +function XTRPGClientShopInfo:GetAddBuyCount() + return self.__AddBuyCount +end + +return XTRPGClientShopInfo \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XTRPG/XTRPGExamine.lua b/Resources/Scripts/XEntity/XTRPG/XTRPGExamine.lua new file mode 100644 index 00000000..572be35f --- /dev/null +++ b/Resources/Scripts/XEntity/XTRPG/XTRPGExamine.lua @@ -0,0 +1,182 @@ +local type = type +local pairs = pairs +local EXAMINE_STATUS = XTRPGConfigs.ExmaineStatus + +local Default = { + __Id = 0, + __ActionId = 0, + __PunishId = 0, + __Round = 0, + __MaxRound = 0, + __TotalScore = 0, + __ReqScore = 0, + __RoleScoreDic = {}, + __Status = EXAMINE_STATUS.Dead, + __MovieId = "", +} + +--不同结果对应剧情结局 +local MOVIEINDEX = { + [EXAMINE_STATUS.Suc] = 1, + [EXAMINE_STATUS.Fail] = 2, +} + +local XTRPGExamine = XClass(nil, "XTRPGExamine") + +function XTRPGExamine:Ctor() + for key, value in pairs(Default) do + if type(value) == "table" then + self[key] = {} + else + self[key] = value + end + end +end + +function XTRPGExamine:Start(examineId, actionId) + if not self:CheckStatus(EXAMINE_STATUS.Dead) then + XLog.Error("XTRPGExamine:Start error:跑团玩法尚有未处理完的检定数据, examineId: " .. self.__Id .. ", examineStatus: " .. self.__Status) + end + + self:Clear() + + self.__Id = examineId + self.__ActionId = actionId + self.__Round = 1 + self.__MaxRound = XTRPGConfigs.GetExamineActionRound(actionId) + + if XTRPGConfigs.CheckExamineActionType(actionId, XTRPGConfigs.TRPGExamineActionType.ConsumeItem) then + --道具检定直接通过 + self.__Status = EXAMINE_STATUS.Suc + else + self.__Status = EXAMINE_STATUS.Normal + end + + local roleIds = XDataCenter.TRPGManager.GetOwnRoleIds() + for _, roleId in pairs(roleIds) do + self.__RoleScoreDic[roleId] = 0 + end + self.__TotalScore = 0 + self.__ReqScore = XTRPGConfigs.GetExamineActionNeedValue(actionId) + self.__MovieId = XTRPGConfigs.GetExamineStartMovieId(examineId) +end + +function XTRPGExamine:Clear() + --恢复被挂起的剧情 + local movieId = self.__MovieId + if not string.IsNilOrEmpty(movieId) then + if XDataCenter.MovieManager.IsMovieYield() then + local index = MOVIEINDEX[self.__Status] + XDataCenter.MovieManager.ResumeMovie(index) + end + end + + self.__Status = EXAMINE_STATUS.Dead + self.__PunishId = 0 + self.__Round = 0 + self.__RoleScoreDic = {} + self.__TotalScore = 0 + self.__ReqScore = 0 + self.__MovieId = "" +end + +function XTRPGExamine:EnterPunish() + local punishId = self.__PunishId + if punishId == 0 then return end + + if XTRPGConfigs.CheckPunishType(punishId, XTRPGConfigs.PunishType.Fight) then + local params = XTRPGConfigs.GetPunishParams(punishId) + local stageId = params[1] + XLuaUiManager.Open("UiNewRoomSingle", stageId) + elseif XTRPGConfigs.CheckPunishType(punishId, XTRPGConfigs.PunishType.GoToOrigin) then + XDataCenter.TRPGManager.ReqMazeRestart() + end + + self.__PunishId = 0 +end + +function XTRPGExamine:EnterNextRound() + self.__Round = self.__Round + 1 + for roleId in pairs(self.__RoleScoreDic) do + self.__RoleScoreDic[roleId] = 0 + end +end + +function XTRPGExamine:UpdateResult(data) + if XTool.IsTableEmpty(data) then return end + + self.__Id = data.Id + self.__Status = data.Success and EXAMINE_STATUS.Suc or EXAMINE_STATUS.Fail + self.__PunishId = data.PunishId or 0 +end + +function XTRPGExamine:UpdateScore(data) + if XTool.IsTableEmpty(data) then return end + + local roleId = data.RoleId + local score = data.Score + local oldScore = self.__RoleScoreDic[roleId] + if oldScore then + self.__RoleScoreDic[roleId] = score + else + XLog.Error("XTRPGExamine:UpdateScore error:跑团玩法检定角色不存在, examineId: " .. self.__Id .. ", data: " .. data) + end + + self.__TotalScore = self.__TotalScore + score - oldScore +end + +function XTRPGExamine:IsCanEnternNextRound() + for _, score in pairs(self.__RoleScoreDic) do + if score == 0 then + return false + end + end + return true +end + +function XTRPGExamine:IsRoleAlreadyRolled(roleId) + local score = self:GetRoleScore(roleId) + return score ~= 0 +end + +function XTRPGExamine:IsLastRound() + return self.__Round == self.__MaxRound +end + +function XTRPGExamine:GetId() + return self.__Id +end + +function XTRPGExamine:GetActionId() + return self.__ActionId +end + +function XTRPGExamine:GetPunishId() + return self.__PunishId +end + +function XTRPGExamine:GetRoleScore(roleId) + return self.__RoleScoreDic[roleId] or 0 +end + +function XTRPGExamine:GetTotalScore() + return self.__TotalScore +end + +function XTRPGExamine:GetCurRound() + return self.__Round +end + +function XTRPGExamine:GetScores() + return self.__TotalScore, self.__ReqScore +end + +function XTRPGExamine:IsPassed() + return self.__TotalScore >= self.__ReqScore +end + +function XTRPGExamine:CheckStatus(examineStatus) + return self.__Status == examineStatus +end + +return XTRPGExamine \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XTRPG/XTRPGMaze.lua b/Resources/Scripts/XEntity/XTRPG/XTRPGMaze.lua new file mode 100644 index 00000000..9cac49a1 --- /dev/null +++ b/Resources/Scripts/XEntity/XTRPG/XTRPGMaze.lua @@ -0,0 +1,262 @@ +local XTRPGMazeLayer = require("XEntity/XTRPG/XTRPGMazeLayer") + +local type = type +local pairs = pairs +local tableInsert = table.insert + +local Default = { + __Id = 0, + __CurrentLayerId = 0, + __Layers = {}, + __LayerIdList = {}, + __RecordCardInfoList = {}, --计算进度使用的卡牌组 +} + +local XTRPGMaze = XClass(nil, "XTRPGMaze") + +function XTRPGMaze:Ctor(id) + for key, value in pairs(Default) do + if type(value) == "table" then + self[key] = {} + else + self[key] = value + end + end + + self.__Id = id + self:InitMaze() +end + +function XTRPGMaze:InitMaze() + local layerIds = XTRPGConfigs.GetMazeLayerIds(self.__Id) + for _, layerId in ipairs(layerIds) do + local layer = XTRPGMazeLayer.New(layerId) + self.__Layers[layerId] = layer + tableInsert(self.__LayerIdList, layerId) + + local cardIds = layer:GetCardIds() + for cardId in pairs(cardIds) do + local cardRecordGroupId = XTRPGConfigs.GetMazeCardRecordGroupId(cardId) + if cardRecordGroupId and cardRecordGroupId > 0 then + local group = self.__RecordCardInfoList[cardRecordGroupId] + if not group then + group = {} + self.__RecordCardInfoList[cardRecordGroupId] = group + end + + group[cardId] = false + end + end + end +end + +function XTRPGMaze:UpdateData(data) + if not data then return end + self:UpdateLayers(data.LayerInfos) + self:UpdateRecordCards(data.RecordCardIds) +end + +function XTRPGMaze:UpdateLayers(datas) + if not datas then return end + + for _, data in pairs(datas) do + local layer = self:GetLayer(data.Id) + layer:UpdateData(data.FinishCardId) + end +end + +function XTRPGMaze:UpdateRecordCards(datas) + if not datas then return end + + for _, cardId in pairs(datas) do + local cardRecordGroupId = XTRPGConfigs.GetMazeCardRecordGroupId(cardId) + local group = self.__RecordCardInfoList[cardRecordGroupId] + if group and group[cardId] ~= nil then + group[cardId] = true + else + XLog.Error("XTRPGMaze:UpdateRecordCards Error: 服务端下发的记录卡牌Id与配置不对应, cardId is: " .. cardId, self.__RecordCardInfoList) + end + end + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_TRPG_MAZE_RECORD_CARD) +end + +function XTRPGMaze:GetLayer(layerId) + local layer = self.__Layers[tonumber(layerId)] + if not layer then + XLog.Error("XTRPGMaze:GetLayer Error: layer not exist, layerId is: " .. layerId, self.__Layers) + return + end + return layer +end + +function XTRPGMaze:GetLayerIdList() + return self.__LayerIdList +end + +function XTRPGMaze:GetCurrentLayerId() + return self.__CurrentLayerId +end + +function XTRPGMaze:GetCurrentNodeId() + local layer = self:GetLayer(self.__CurrentLayerId) + return layer:GetCurrentNodeId() +end + +function XTRPGMaze:GetCurrentStandNodeIndex(layerId) + local layer = self:GetLayer(layerId) + return layer:GetCurrentStandNodeIndex() +end + +function XTRPGMaze:GetRecordGroupCardCount(cardRecordGroupId) + local finishCount, totalCount = 0, 0 + + local group = self.__RecordCardInfoList[cardRecordGroupId] + if not group then return finishCount, totalCount end + + for cardId, isFinished in pairs(group) do + if isFinished then + finishCount = finishCount + 1 + end + + totalCount = totalCount + 1 + end + + return finishCount, totalCount +end + +function XTRPGMaze:GetProgress() + local totalfinishCount, totalTotalCount = 0, 0 + + for groupId in pairs(self.__RecordCardInfoList) do + local finishCount, totalCount = self:GetRecordGroupCardCount(groupId) + totalfinishCount = totalfinishCount + finishCount + totalTotalCount = totalTotalCount + totalCount + end + + if totalTotalCount == 0 then return 1 end + return totalfinishCount / totalTotalCount +end + +function XTRPGMaze:GetLayerNodeIdList(layerId, notSort) + local layer = self:GetLayer(layerId) + return layer:GetSortedNodeIdList(notSort) +end + +function XTRPGMaze:GetLayerCardBeginEndPos(layerId, nodeId) + local layer = self:GetLayer(layerId) + return layer:GetNodeCardBeginEndPos(nodeId) +end + +function XTRPGMaze:GetLayerCardNum(layerId, nodeId) + local layer = self:GetLayer(layerId) + return layer:GetNodeCardNum(nodeId) +end + +function XTRPGMaze:GetLayerCardId(layerId, nodeId, cardIndex) + local layer = self:GetLayer(layerId) + return layer:GetNodeCardId(nodeId, cardIndex) +end + +function XTRPGMaze:IsLayerReachable(layerId) + return layerId == self.__CurrentLayerId +end + +function XTRPGMaze:IsNodeReachable(layerId, nodeId) + if not self:IsLayerReachable(layerId) then return false end + + local layer = self:GetLayer(layerId) + return layer:IsNodeReachable(nodeId) +end + +function XTRPGMaze:IsCardReachable(layerId, nodeId, cardIndex) + if not self:IsLayerReachable(layerId) then return false end + + local layer = self:GetLayer(layerId) + return layer:IsCardReachable(nodeId, cardIndex) +end + +function XTRPGMaze:IsCardAfterCurrentStand(layerId, nodeId, cardIndex) + if not self:IsLayerReachable(layerId) then return false end + + local layer = self:GetLayer(layerId) + return layer:IsCardAfterCurrentStand(nodeId, cardIndex) +end + +function XTRPGMaze:IsCardCurrentStand(layerId, nodeId, cardIndex) + if not self:IsLayerReachable(layerId) then return false end + + local layer = self:GetLayer(layerId) + return layer:IsCardCurrentStand(nodeId, cardIndex) +end + +function XTRPGMaze:GetMoveDelta(cardIndex) + local layerId = self.__CurrentLayerId + local layer = self:GetLayer(layerId) + return layer:GetMoveDelta(cardIndex) +end + +function XTRPGMaze:GetCardFinishedId(layerId, nodeId, cardIndex) + local layer = self:GetLayer(layerId) + return layer:GetCardFinishedId(nodeId, cardIndex) +end + +function XTRPGMaze:CheckCardCurrentType(layerId, nodeId, cardId, cardType) + local layer = self:GetLayer(layerId) + return layer:CheckCardCurrentType(nodeId, cardId, cardType) +end + +function XTRPGMaze:IsCardFinished(layerId, cardId) + local layer = self:GetLayer(layerId) + return layer:IsCardFinished(cardId) +end + +function XTRPGMaze:IsCardDisposeableForeverFinished(layerId, cardId) + local layer = self:GetLayer(layerId) + return layer:IsCardDisposeableForeverFinished(cardId) +end + +function XTRPGMaze:SelectCard(cardIndex) + local layerId = self.__CurrentLayerId + local layer = self:GetLayer(layerId) + layer:SelectCard(cardIndex) +end + +function XTRPGMaze:OnCardResult(cardIndex, resultData) + local layerId = self.__CurrentLayerId + local layer = self:GetLayer(layerId) + layer:OnCardResult(cardIndex, resultData) +end + +function XTRPGMaze:Enter() + self.__CurrentLayerId = XTRPGConfigs.GetMazeStartLayerId(self.__Id) + local layer = self:GetLayer(self.__CurrentLayerId) + layer:Enter() + + self:Reset() +end + +function XTRPGMaze:Reset() + for _, layer in pairs(self.__Layers) do + layer:Reset() + end +end + +function XTRPGMaze:RestartCurrentLayer() + local layer = self:GetLayer(self.__CurrentLayerId) + layer:Enter() +end + +function XTRPGMaze:MoveNext(cardIndex) + local layerId = self.__CurrentLayerId + local layer = self:GetLayer(layerId) + layer:MoveNext(cardIndex) +end + +function XTRPGMaze:MoveTo(layerId, nodeId, cardIndex) + self.__CurrentLayerId = layerId + local layer = self:GetLayer(layerId) + layer:MoveTo(nodeId, cardIndex) +end + +return XTRPGMaze \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XTRPG/XTRPGMazeCard.lua b/Resources/Scripts/XEntity/XTRPG/XTRPGMazeCard.lua new file mode 100644 index 00000000..3cf736ff --- /dev/null +++ b/Resources/Scripts/XEntity/XTRPG/XTRPGMazeCard.lua @@ -0,0 +1,234 @@ +local type = type +local tonumber = tonumber +local CardType = XTRPGConfigs.CardType + +local XTRPGMazeCard = XClass(nil, "XTRPGMazeCard") + +local Default = { + __Id = 0, + __ReplaceId = 0, + __Type = CardType.Default, + __IsDisposeableSingle = false, --是否一次性使用 + __IsDisposeable = false, --是否一次性使用(服务端记录,永久一次性触发) + __IsFinished = false, --是否触发过 +} + +function XTRPGMazeCard:Ctor(cardId) + for key, value in pairs(Default) do + if type(value) == "table" then + self[key] = {} + else + self[key] = value + end + end + + self.__Id = cardId + self.__Type = XTRPGConfigs.GetMazeCardType(cardId) + self.__IsDisposeableSingle = XTRPGConfigs.IsMazeCardSingleDisposeable(cardId) + self.__IsDisposeable = XTRPGConfigs.IsMazeCardDisposeable(cardId) +end + +function XTRPGMazeCard:Reset() + if self:IsDisposeableForever() then + return + end + + self.__ReplaceId = 0 + self.__IsFinished = false +end + +function XTRPGMazeCard:GetId() + return self.__Id +end + +function XTRPGMazeCard:GetEffectId() + if self.__ReplaceId ~= 0 then + return self.__ReplaceId + end + + return self.__Id +end + +function XTRPGMazeCard:CheckType(cardType) + if self.__ReplaceId ~= 0 then + local replaceCardType = XTRPGConfigs.GetMazeCardType(self.__ReplaceId) + return replaceCardType == cardType + end + + return self.__Type == cardType +end + +function XTRPGMazeCard:OnSelect(cardIndex, doNotSyn) + + if self:CheckType(CardType.Block) then + return + end + + if not doNotSyn then + self:ReplaceCard(nil)--手动点击选择要用卡牌原始类型处理 + XDataCenter.TRPGManager.TRPGMazeSelectCardRequest(cardIndex) + end + + --已完成过的卡牌直接通行 + if self:IsFinished() then + return + end + + if self:CheckType(CardType.Fight) then + + local cardId = self:GetEffectId() + local params = XTRPGConfigs.GetMazeCardParam(cardId) + local challengeLevel = tonumber(params[1]) + local stageId = tonumber(params[2]) + local qucikRewardId = tonumber(params[3]) + XLuaUiManager.Open("UiTRPGFightTips", cardId, cardIndex, stageId, challengeLevel, qucikRewardId) + + elseif self:CheckType(CardType.FightWin) then + + local cardId = self:GetEffectId() + local params = XTRPGConfigs.GetMazeCardParam(cardId) + local stageId = tonumber(params[1]) + XLuaUiManager.Open("UiTRPGFightTips", cardId, cardIndex, stageId) + + elseif self:CheckType(CardType.Examine) then + + local cardId = self:GetEffectId() + local params = XTRPGConfigs.GetMazeCardParam(cardId) + local examineId = tonumber(params[1]) + XDataCenter.TRPGManager.EnterExamine(examineId) + + end +end + +function XTRPGMazeCard:OnResult(cardIndex, resultData) + if not resultData then return end + + if not resultData.Success then + + if self:CheckType(CardType.Random) then--随机牌需要转换为真实类型后尝试进行新一轮操作 + + --优先处理随机牌类型替换逻辑 + local replaceCardId = resultData.ReplaceId + self:ReplaceCard(replaceCardId) + + local doNotSyn = true + self:OnSelect(cardIndex, doNotSyn) + + end + + return + + end + + coroutine.wrap(function() + local co = coroutine.running() + local callBack = function() coroutine.resume(co) end + + --奖励相关 + local rewardList = resultData.RewardList + if not XTool.IsTableEmpty(rewardList) then + XDataCenter.TRPGManager.OnGetReward(rewardList, callBack) + coroutine.yield() + end + + --已完成过的卡牌直接通行 + if self:IsFinished() then + XDataCenter.TRPGManager.ReqMazeMoveNext(cardIndex) + return + end + + --优先处理随机牌类型替换逻辑 + if self:CheckType(CardType.Random) then + local replaceCardId = resultData.ReplaceId + self:ReplaceCard(replaceCardId) + end + + --迷宫位置更新 + if self:CheckType(CardType.Block) + or self:CheckType(CardType.Random) then --随机牌替换为其他类型处理 + return + elseif self:CheckType(CardType.Pass) + or self:CheckType(CardType.Fight) + or self:CheckType(CardType.Examine) + or self:CheckType(CardType.Reward) + then + + XDataCenter.TRPGManager.ReqMazeMoveNext(cardIndex) + + elseif self:CheckType(CardType.FightWin) then + + local movieId = XTRPGConfigs.GetMazeCardMovieId(self.__Id) + XDataCenter.TRPGManager.ReqMazeMoveNext(cardIndex, movieId) + + elseif self:CheckType(CardType.Story) then + + local params = XTRPGConfigs.GetMazeCardParam(self.__Id) + local movieId = params[1] + local cb = function() + XDataCenter.TRPGManager.ReqMazeMoveNext(cardIndex) + XDataCenter.TRPGManager.CheckOpenNewMazeTips() + end + XDataCenter.MovieManager.PlayMovie(movieId, cb) + + elseif self:CheckType(CardType.Skip) then + + local params = XTRPGConfigs.GetMazeCardParam(self.__Id) + local skipLayerId = tonumber(params[1]) + local skipNodeId = tonumber(params[2]) + local skipCardIndex = tonumber(params[3]) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_TRPG_MAZE_MOVE_TO, skipLayerId, skipNodeId, skipCardIndex) + + elseif self:CheckType(CardType.Over) then + + XDataCenter.TRPGManager.QuitMaze() + + end + + --还原随机牌类型 + self:RevertCard() + + --标记已完成 + self:SetFinished() + end)() + +end + +function XTRPGMazeCard:IsDisposeable() + return self.__IsDisposeableSingle or self.__IsDisposeable +end + +function XTRPGMazeCard:IsDisposeableForever() + return self.__IsDisposeable +end + +function XTRPGMazeCard:IsFinished() + return self.__IsFinished +end + +function XTRPGMazeCard:GetFinishedId() + if not self:IsFinished() then + return + end + return XTRPGConfigs.GetMazeCardConvertCardId(self.__Id) +end + +function XTRPGMazeCard:SetFinished() + if not self:IsDisposeable() then + return + end + self.__IsFinished = true +end + +function XTRPGMazeCard:ReplaceCard(replaceCardId) + self.__ReplaceId = replaceCardId or 0 +end + +function XTRPGMazeCard:RevertCard() + --一次性卡牌触发完随机之后不再复原 + if self:IsDisposeable() then + return + end + self.__ReplaceId = 0 +end + +return XTRPGMazeCard \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XTRPG/XTRPGMazeLayer.lua b/Resources/Scripts/XEntity/XTRPG/XTRPGMazeLayer.lua new file mode 100644 index 00000000..b6e70149 --- /dev/null +++ b/Resources/Scripts/XEntity/XTRPG/XTRPGMazeLayer.lua @@ -0,0 +1,284 @@ +local XTRPGMazeNode = require("XEntity/XTRPG/XTRPGMazeNode") + +local type = type +local tableInsert = table.insert +local Default = { + __Id = 0, + __CurrentNodeIndex = 0, + __Map = {}, + __NodeNum = 0, + __NodeIdList = {}, + __CardIdToNodeIdDic = {}, +} + +local XTRPGMazeLayer = XClass(nil, "XTRPGMazeLayerLayer") + +function XTRPGMazeLayer:Ctor(id) + for key, value in pairs(Default) do + if type(value) == "table" then + self[key] = {} + else + self[key] = value + end + end + + self.__Id = id + self:InitMap() +end + +function XTRPGMazeLayer:InitMap() + local configs = XTRPGConfigs.GetMazeMapConfigs(self.__Id) + for nodeId, config in pairs(configs) do + local cardIds = config.CardId + + local node = XTRPGMazeNode.New(nodeId) + node:InitCards(cardIds) + + self.__Map[nodeId] = node + tableInsert(self.__NodeIdList, nodeId) + + for _, cardId in pairs(cardIds) do + self.__CardIdToNodeIdDic[cardId] = nodeId + end + end + + self.__NodeNum = #self.__NodeIdList +end + +function XTRPGMazeLayer:UpdateData(finishCardIds) + if not finishCardIds then return end + + for _, cardId in pairs(finishCardIds) do + local node = self:GetNodeByCardId(cardId) + if node then + node:SetCardFinished(cardId) + end + end +end + +function XTRPGMazeLayer:GetCardIds() + return self.__CardIdToNodeIdDic +end + +function XTRPGMazeLayer:GetNodeIdByCardId(cardId) + local nodeId = self.__CardIdToNodeIdDic[cardId] + if not nodeId then + XLog.Error("XTRPGMaze:GetNodeIdByCardId Error: nodeId not exist, cardId is: " .. cardId, self.__CardIdToNodeIdDic) + return + end + return nodeId +end + +function XTRPGMazeLayer:GetNodeId(nodeIndex) + local nodeId = self.__NodeIdList[nodeIndex] + if not nodeId then + XLog.Error("XTRPGMaze:GetNodeId Error: nodeId not exist, nodeIndex is: " .. nodeIndex, self.__NodeIdList) + return + end + return nodeId +end + +function XTRPGMazeLayer:GetNodeIndex(paramNodeId) + for nodeIndex, nodeId in pairs(self.__NodeIdList) do + if nodeId == paramNodeId then + return nodeIndex + end + end + return 0 +end + +function XTRPGMazeLayer:GetLastNodeIndex(nodeIndex) + local nextIndex = nodeIndex - 1 + if nextIndex < 1 then + nextIndex = self:GetNodeNum() + end + return nextIndex +end + +function XTRPGMazeLayer:GetNextNodeIndex(nodeIndex) + local nextIndex = nodeIndex + 1 + if nextIndex > self:GetNodeNum() then + nextIndex = 1 + end + return nextIndex +end + +function XTRPGMazeLayer:GetNodeNum() + return self.__NodeNum +end + +function XTRPGMazeLayer:GetNextNodeId() + local nextNodeIndex = self:GetNextNodeIndex(self.__CurrentNodeIndex) + return self:GetNodeId(nextNodeIndex) +end + +function XTRPGMazeLayer:GetNode(nodeId) + if not nodeId then + XLog.Error("XTRPGMaze:GetNode Error: nodeId is nil") + return + end + + local node = self.__Map[nodeId] + if not node then + XLog.Error("XTRPGMaze:GetNode Error: node not exist, nodeId is: " .. nodeId, self.__Map) + return + end + return node +end + +function XTRPGMazeLayer:GetNodeByCardId(cardId) + local nodeId = self:GetNodeIdByCardId(cardId) + return self:GetNode(nodeId) +end + +function XTRPGMazeLayer:GetSortedNodeIdList(notSort) + local list = {} + + local nodeNum = self:GetNodeNum() + local nodeIndex = notSort and 1 or self.__CurrentNodeIndex + for i = 1, nodeNum do + tableInsert(list, self:GetNodeId(nodeIndex)) + nodeIndex = self:GetNextNodeIndex(nodeIndex) + end + + return list +end + +function XTRPGMazeLayer:GetNodeCardBeginEndPos(nodeId) + local node = self:GetNode(nodeId) + return node:GetStartPos(), node:GetEndPos() +end + +function XTRPGMazeLayer:GetNodeCardNum(nodeId) + local node = self:GetNode(nodeId) + return node:GetCardNum() +end + +function XTRPGMazeLayer:GetNodeCardId(nodeId, cardIndex) + local node = self:GetNode(nodeId) + return node:GetCardId(cardIndex) +end + +function XTRPGMazeLayer:GetCurrentStandNodeIndex() + return self:GetLastNodeIndex(self.__CurrentNodeIndex) +end + +function XTRPGMazeLayer:GetCurrentNodeId() + return self:GetNodeId(self.__CurrentNodeIndex) +end + +function XTRPGMazeLayer:IsNodeReachable(nodeId) + local curNodeId = self:GetCurrentNodeId() + return nodeId == curNodeId +end + +function XTRPGMazeLayer:IsCardReachable(nodeId, cardIndex) + if not self:IsNodeReachable(nodeId) then return false end + + local node = self:GetNode(nodeId) + return node:IsCardReachable(cardIndex) +end + +function XTRPGMazeLayer:IsCardFinished(cardId) + local node = self:GetNodeByCardId(cardId) + if not node then return false end + + return node:IsCardFinished(cardId) +end + +function XTRPGMazeLayer:IsCardDisposeableForeverFinished(cardId) + local node = self:GetNodeByCardId(cardId) + if not node then return false end + + return node:IsCardDisposeableForeverFinished(cardId) +end + +--当前所在卡牌的正前方卡牌位置判断 +function XTRPGMazeLayer:IsCardAfterCurrentStand(nodeId, cardIndex) + --站立位置正前方是可选择的 + local curNodeId = self:GetCurrentNodeId() + if nodeId ~= curNodeId then return false end + + --卡牌位置为上次选择作为中轴的卡牌 + local node = self:GetNode(nodeId) + if not node:IsCardCurrentStand(cardIndex) then return false end + + return true +end + +--当前所在卡牌判断 +function XTRPGMazeLayer:IsCardCurrentStand(nodeId, cardIndex) + --站在可选择的节点前面一行 + local lastNodeIndex = self:GetLastNodeIndex(self.__CurrentNodeIndex) + local lastNodeId = self:GetNodeId(lastNodeIndex) + if nodeId ~= lastNodeId then return false end + + --卡牌位置为上次选择作为中轴的卡牌 + local node = self:GetNode(nodeId) + if not node:IsCardCurrentStand(cardIndex) then return false end + + return true +end + +function XTRPGMazeLayer:GetMoveDelta(cardIndex) + local nodeId = self:GetCurrentNodeId() + local node = self:GetNode(nodeId) + return node:GetMoveDelta(cardIndex) +end + +function XTRPGMazeLayer:GetCardFinishedId(nodeId, cardIndex) + local node = self:GetNode(nodeId) + return node:GetCardFinishedId(cardIndex) +end + +function XTRPGMazeLayer:CheckCardCurrentType(nodeId, cardId, cardType) + local node = self:GetNode(nodeId) + return node:CheckCardCurrentType(cardId, cardType) +end + +function XTRPGMazeLayer:Enter() + self.__CurrentNodeIndex = XTRPGConfigs.GetMazeLayerStartNodeId(self.__Id) + self.__CurrentNodeIndex = self:GetNextNodeIndex(self.__CurrentNodeIndex) --实际配置的是站立节点位置,当前可选择卡牌节点应前进一位 + + local startCardIndex = XTRPGConfigs.GetMazeLayerStartCardIndex(self.__Id) + for _, node in pairs(self.__Map) do + node:Enter(startCardIndex) + end +end + +function XTRPGMazeLayer:Reset() + for _, node in pairs(self.__Map) do + node:Reset() + end +end + +function XTRPGMazeLayer:SelectCard(cardIndex) + local nodeId = self:GetCurrentNodeId() + local node = self:GetNode(nodeId) + node:SelectCard(cardIndex) +end + +function XTRPGMazeLayer:OnCardResult(cardIndex, resultData) + local nodeId = self:GetCurrentNodeId() + local node = self:GetNode(nodeId) + node:OnCardResult(cardIndex, resultData) +end + +function XTRPGMazeLayer:MoveNext(cardIndex) + for _, node in pairs(self.__Map) do + node:MoveNext(cardIndex) + end + + self.__CurrentNodeIndex = self:GetNextNodeIndex(self.__CurrentNodeIndex) +end + +function XTRPGMazeLayer:MoveTo(nodeId, cardIndex) + for _, node in pairs(self.__Map) do + node:MoveTo(cardIndex) + end + + self.__CurrentNodeIndex = self:GetNodeIndex(nodeId) + self.__CurrentNodeIndex = self:GetNextNodeIndex(self.__CurrentNodeIndex) --实际配置的是站立节点位置,当前可选择卡牌节点应前进一位 +end + +return XTRPGMazeLayer \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XTRPG/XTRPGMazeNode.lua b/Resources/Scripts/XEntity/XTRPG/XTRPGMazeNode.lua new file mode 100644 index 00000000..03536581 --- /dev/null +++ b/Resources/Scripts/XEntity/XTRPG/XTRPGMazeNode.lua @@ -0,0 +1,173 @@ +local XTRPGMazeCard = require("XEntity/XTRPG/XTRPGMazeCard") + +local type = type +local pairs = pairs +local mathCeil = math.ceil +local mathFloor = math.floor +local tableInsert = table.insert + +local MAX_CARD_NUM = 9 --每个节点最大卡牌数量 +local MAX_POS = mathFloor(MAX_CARD_NUM / 2) * 2 + MAX_CARD_NUM --17:左右移动至中心轴后预留出一半位置用于界面展示 +local MID_PIVOT_POS = mathCeil(MAX_POS / 2) + +local Default = { + __Id = 0, + __StartPos = 0, + __Cards = {}, +} + +local XTRPGMazeNode = XClass(nil, "XTRPGMazeLayerLayer") + +function XTRPGMazeNode:Ctor(id) + for key, value in pairs(Default) do + if type(value) == "table" then + self[key] = {} + else + self[key] = value + end + end + + self.__Id = id +end + +function XTRPGMazeNode:InitCards(cardIds) + for _, cardId in ipairs(cardIds) do + local card = XTRPGMazeCard.New(cardId) + tableInsert(self.__Cards, card) + end + + if self:GetCardNum() > MAX_CARD_NUM then + XLog.Error("XTRPGMazeNode:InitCards Error: 迷宫节点初始化卡牌错误, 超过单节点最大卡牌数量上限: " .. MAX_CARD_NUM) + return + end +end + +function XTRPGMazeNode:GetCardNum() + return #self.__Cards +end + +function XTRPGMazeNode:GetStartPos() + return self.__StartPos +end + +function XTRPGMazeNode:GetEndPos() + return self.__StartPos + self:GetCardNum() - 1 +end + +function XTRPGMazeNode:GetCard(cardIndex) + local card = self.__Cards[cardIndex] + if not card then + XLog.Error("XTRPGMazeNode:GetCard Error: card not exist, cardIndex is: " .. cardIndex, self.__Cards) + return + end + return card +end + +function XTRPGMazeNode:GetCardId(cardIndex) + local card = self:GetCard(cardIndex) + return card:GetId() +end + +function XTRPGMazeNode:GetCardFinishedId(cardIndex) + local card = self:GetCard(cardIndex) + return card:GetFinishedId() +end + +function XTRPGMazeNode:CheckCardCurrentType(cardId, cardType) + local card = self:GetCardByCardId(cardId) + return card:CheckType(cardType) +end + +function XTRPGMazeNode:GetCardByCardId(cardId) + for _, card in pairs(self.__Cards) do + if card:GetId() == cardId then + return card + end + end + XLog.Error("XTRPGMazeNode:GetCardByCardId Error: card not exist, cardId is: " .. cardId, self.__Cards) +end + +function XTRPGMazeNode:CalcCardPos(cardIndex) + return self.__StartPos + cardIndex - 1 +end + +function XTRPGMazeNode:IsCardReachable(cardIndex) + if not cardIndex or cardIndex == 0 then return false end + local cardPos = self:CalcCardPos(cardIndex) + return cardPos >= MID_PIVOT_POS - 1 and cardPos <= MID_PIVOT_POS + 1 +end + +function XTRPGMazeNode:IsCardCurrentStand(cardIndex) + if not cardIndex or cardIndex == 0 then return false end + local cardPos = self:CalcCardPos(cardIndex) + return cardPos == MID_PIVOT_POS +end + +function XTRPGMazeNode:Enter(startCardIndex) + self:ResetStartPos(startCardIndex) +end + +function XTRPGMazeNode:Reset() + for _, card in pairs(self.__Cards) do + card:Reset() + end +end + +function XTRPGMazeNode:ResetStartPos(startCardIndex) + local delta = mathCeil(self:GetCardNum() / 2) - startCardIndex + self.__StartPos = MID_PIVOT_POS - mathFloor(self:GetCardNum() / 2) + delta +end + +function XTRPGMazeNode:SelectCard(cardIndex) + if not self:IsCardReachable(cardIndex) then + XLog.Error("XTRPGMazeNode:SelectCard Error: 当前卡牌位置不可选择, cardIndex: " .. cardIndex) + return + end + + local card = self:GetCard(cardIndex) + card:OnSelect(cardIndex) +end + +function XTRPGMazeNode:OnCardResult(cardIndex, resultData) + local card = self:GetCard(cardIndex) + card:OnResult(cardIndex, resultData) +end + +function XTRPGMazeNode:SetCardFinished(cardId) + local card = self:GetCardByCardId(cardId) + card:SetFinished() +end + +function XTRPGMazeNode:IsCardFinished(cardId) + local card = self:GetCardByCardId(cardId) + return card:IsFinished() +end + +function XTRPGMazeNode:IsCardDisposeableForeverFinished(cardId) + local card = self:GetCardByCardId(cardId) + return card:IsFinished() and card:IsDisposeableForever() +end + +function XTRPGMazeNode:GetMoveDelta(cardIndex) + local cardPos = self:CalcCardPos(cardIndex) + return MID_PIVOT_POS - cardPos +end + +function XTRPGMazeNode:MoveNext(cardIndex) + if not self:IsCardReachable(cardIndex) then + XLog.Error("XTRPGMazeNode:MoveNext Error: 当前卡牌位置不可到达, cardIndex: " .. cardIndex) + return + end + + local targetMidPos = self:CalcCardPos(cardIndex) + local deltaPos = -(targetMidPos - MID_PIVOT_POS) + self.__StartPos = self.__StartPos + deltaPos +end + +function XTRPGMazeNode:MoveTo(cardIndex) + local targetMidPos = self:CalcCardPos(cardIndex) + local deltaPos = -(targetMidPos - MID_PIVOT_POS) + self.__StartPos = self.__StartPos + deltaPos +end + +return XTRPGMazeNode \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XTRPG/XTRPGRole.lua b/Resources/Scripts/XEntity/XTRPG/XTRPGRole.lua new file mode 100644 index 00000000..e51223cd --- /dev/null +++ b/Resources/Scripts/XEntity/XTRPG/XTRPGRole.lua @@ -0,0 +1,215 @@ +local XTRPGRoleTalent = require("XEntity/XTRPG/XTRPGRoleTalent") +local XTRPGRoleAttribute = require("XEntity/XTRPG/XTRPGRoleAttribute") + +local type = type +local tableInsert = table.insert +local RoleAttributeType = XTRPGConfigs.RoleAttributeType + +local Default = { + __Id = 0, + __Attributes = {}, + __Talents = {}, + __UsedTalentPoint = 0, + __BuffIds = {}, +} + +local XTRPGRole = XClass(nil, "XTRPGRole") + +function XTRPGRole:Ctor(characterId) + for key, value in pairs(Default) do + if type(value) == "table" then + self[key] = {} + else + self[key] = value + end + end + + self.__Id = characterId + self:InitAttributes() + self:InitTalents() +end + +function XTRPGRole:UpdateData(data) + if not data then return end + + self.__BuffIds = data.BuffIds or {} + self:UpdateAtrributes(data.Attributes) + self:UpdateTalent(data.TalentIds) +end + +----------------------------------------------属性相关 begin-------------------------------- +function XTRPGRole:InitAttributes() + for _, attributeType in pairs(RoleAttributeType) do + local initValue = XTRPGConfigs.GetRoleInitAttribute(self.__Id, attributeType) + self.__Attributes[attributeType] = XTRPGRoleAttribute.New(attributeType, initValue) + end +end + +function XTRPGRole:UpdateAtrributes(datas) + if XTool.IsTableEmpty(datas) then return end + for _, data in pairs(datas) do + local attributeType = data.Id + local attribute = self:GetAttribute(attributeType) + attribute:UpdateData(data) + end +end + +function XTRPGRole:GetAttribute(attributeType) + local attribute = self.__Attributes[attributeType] + if not attribute then + XLog.Error("XTRPGRole:GetAttribute Error: 获取角色属性错误, attributeType: " .. attributeType) + return + end + return attribute +end + +function XTRPGRole:GetAttributeMinRollValue(attributeType) + local attribute = self:GetAttribute(attributeType) + return attribute:GetMinRollValue() +end + +function XTRPGRole:GetAttributeMaxRollValue(attributeType) + local attribute = self:GetAttribute(attributeType) + return attribute:GetMaxRollValue() +end + +function XTRPGRole:GetAttributes() + local attributes = {} + for attrType, attribute in pairs(self.__Attributes) do + local attribute = { + Type = attrType, + Value = attribute:GetValue(), + } + tableInsert(attributes, attribute) + end + return attributes +end +----------------------------------------------属性相关 end-------------------------------- +----------------------------------------------天赋相关 begin-------------------------------- +function XTRPGRole:InitTalents() + local roleId = self.__Id + local configs = XTRPGConfigs.GetRoleTalentGroupConfig(roleId) + + for talentId in pairs(configs) do + local talent = XTRPGRoleTalent.New(talentId) + talent:Init(roleId) + self.__Talents[talentId] = talent + end +end + +function XTRPGRole:UpdateTalent(talentIds) + if not talentIds then return end + + self.__UsedTalentPoint = 0 + for _, talent in pairs(self.__Talents) do + talent:SetActive(false) + end + + for _, talentId in pairs(talentIds) do + self:ActiveTalent(talentId) + end +end + +function XTRPGRole:GetTalent(talentId) + local talent = self.__Talents[talentId] + if not talent then + XLog.Error("XTRPGRole:GetTalent Error:: 获取角色天赋错误, talentId: " .. talentId) + return + end + return talent +end + +function XTRPGRole:GetTalentIds() + local talentIds = {} + for talentId in pairs(self.__Talents) do + tableInsert(talentIds, talentId) + end + return talentIds +end + +function XTRPGRole:GetCommonTalentIds() + local talentIds = {} + for talentId in pairs(self.__Talents) do + if XTRPGConfigs.IsRoleTalentCommonForShow(self.__Id, talentId) + and self:IsTalentActive(talentId) + then + tableInsert(talentIds, talentId) + end + end + return talentIds +end + +function XTRPGRole:CanActiveTalent(talentId) + local preId = XTRPGConfigs.GetRoleTalentPreId(self.__Id, talentId) + if not preId or preId == 0 then return true end + return self:IsTalentActive(preId) +end + +function XTRPGRole:CanActiveAnyTalent() + for talentId in pairs(self.__Talents) do + if self:CanActiveTalent(talentId) + and not self:IsTalentActive(talentId) + and XDataCenter.TRPGManager.IsActiveTalentCostEnough(self.__Id, talentId) + then + return true + end + end + return false +end + +function XTRPGRole:ActiveTalent(talentId) + local talent = self:GetTalent(talentId) + talent:SetActive(true) + + local costPoint = talent:GetCostPoint() + self.__UsedTalentPoint = self.__UsedTalentPoint + costPoint +end + +function XTRPGRole:IsTalentActive(talentId) + local talent = self:GetTalent(talentId) + return talent:IsActive() +end + +function XTRPGRole:IsAnyTalentActive() + for _, talent in pairs(self.__Talents) do + if talent:IsActive() then + return true + end + end + return false +end + +function XTRPGRole:GetTalentCostPoint(talentId) + local talent = self:GetTalent(talentId) + return talent:GetCostPoint() +end + +function XTRPGRole:GetUsedTalentPoint() + return self.__UsedTalentPoint +end +----------------------------------------------天赋相关 end-------------------------------- +----------------------------------------------Buff相关 begin-------------------------------- +function XTRPGRole:IsHaveBuffUp() + if self:IsHaveBuffDown() then return false end + for _, buffId in pairs(self.__BuffIds) do + if XTRPGConfigs.IsBuffUp(buffId) then + return true + end + end + return false +end + +function XTRPGRole:IsHaveBuffDown() + for _, buffId in pairs(self.__BuffIds) do + if XTRPGConfigs.IsBuffDown(buffId) then + return true + end + end + return false +end + +function XTRPGRole:GetBuffIds() + return XTool.Clone(self.__BuffIds) +end +----------------------------------------------Buff相关 end-------------------------------- +return XTRPGRole \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XTRPG/XTRPGRoleAttribute.lua b/Resources/Scripts/XEntity/XTRPG/XTRPGRoleAttribute.lua new file mode 100644 index 00000000..5e5ccf58 --- /dev/null +++ b/Resources/Scripts/XEntity/XTRPG/XTRPGRoleAttribute.lua @@ -0,0 +1,45 @@ +local type = type + +local Default = { + __Type = 0, + __Value = 0, + __MinRollValue = 0, + __MaxRollValue = 0, +} + +local XTRPGRoleAttribute = XClass(nil, "XTRPGRoleAttribute") + +function XTRPGRoleAttribute:Ctor(attributeType, initValue) + for key, value in pairs(Default) do + if type(value) == "table" then + self[key] = {} + else + self[key] = value + end + end + + self.__Type = attributeType + self.__Value = initValue +end + +function XTRPGRoleAttribute:UpdateData(data) + if XTool.IsTableEmpty(data) then return end + + self.__Value = data.Value or self.__Value + self.__MinRollValue = data.MinRollValue or self.__MinRollValue + self.__MaxRollValue = data.MaxRollValue or self.__MaxRollValue +end + +function XTRPGRoleAttribute:GetValue() + return self.__Value +end + +function XTRPGRoleAttribute:GetMinRollValue() + return self.__MinRollValue +end + +function XTRPGRoleAttribute:GetMaxRollValue() + return self.__MaxRollValue +end + +return XTRPGRoleAttribute \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XTRPG/XTRPGRoleTalent.lua b/Resources/Scripts/XEntity/XTRPG/XTRPGRoleTalent.lua new file mode 100644 index 00000000..6d547bf7 --- /dev/null +++ b/Resources/Scripts/XEntity/XTRPG/XTRPGRoleTalent.lua @@ -0,0 +1,39 @@ +local type = type + +local Default = { + __Id = 0, + __IsActive = false, + __CostPoint = 0, +} + +local XTRPGRoleTalent = XClass(nil, "XTRPGRoleTalent") + +function XTRPGRoleTalent:Ctor(id) + for key, value in pairs(Default) do + if type(value) == "table" then + self[key] = {} + else + self[key] = value + end + end + + self.__Id = id +end + +function XTRPGRoleTalent:Init(roleId) + self.__CostPoint = XTRPGConfigs.GetRoleTalentCostPoint(roleId, self.__Id) +end + +function XTRPGRoleTalent:IsActive() + return self.__IsActive or false +end + +function XTRPGRoleTalent:SetActive(value) + self.__IsActive = value and true or false +end + +function XTRPGRoleTalent:GetCostPoint() + return self.__CostPoint +end + +return XTRPGRoleTalent \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XTRPG/XTRPGShopInfo.lua b/Resources/Scripts/XEntity/XTRPG/XTRPGShopInfo.lua new file mode 100644 index 00000000..03496fea --- /dev/null +++ b/Resources/Scripts/XEntity/XTRPG/XTRPGShopInfo.lua @@ -0,0 +1,55 @@ +local XTRPGShopItemInfo = require("XEntity/XTRPG/XTRPGShopItemInfo") + +local type = type + +local XTRPGShopInfo = XClass(nil, "XTRPGShopInfo") + +local Default = { + __Id = 0, --商店Id + __ItemInfos = {} +} + +function XTRPGShopInfo:Ctor() + for key, value in pairs(Default) do + if type(value) == "table" then + self[key] = {} + else + self[key] = value + end + end +end + +function XTRPGShopInfo:UpdateDataItemInfo(data) + if not data then return end + self.__Id = data.Id + for _, v in pairs(data.ItemInfos or {}) do + if not self.__ItemInfos[v.Id] then + self.__ItemInfos[v.Id] = XTRPGShopItemInfo.New() + end + self.__ItemInfos[v.Id]:UpdateData(v) + end +end + +function XTRPGShopInfo:GetId() + return self.__Id +end + +function XTRPGShopInfo:GetItemInfos() + return self.__ItemInfos +end + +function XTRPGShopInfo:AddItemBuyCount(itemId, count) + if not self.__ItemInfos[itemId] then + local data = {Id = itemId, Count = count} + self.__ItemInfos[itemId] = XTRPGShopItemInfo.New() + self.__ItemInfos[itemId]:UpdateData(data) + else + self.__ItemInfos[itemId]:AddCount(count) + end +end + +function XTRPGShopInfo:GetItemCount(id) + return self.__ItemInfos[id] and self.__ItemInfos[id]:GetCount() or 0 +end + +return XTRPGShopInfo \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XTRPG/XTRPGShopItemInfo.lua b/Resources/Scripts/XEntity/XTRPG/XTRPGShopItemInfo.lua new file mode 100644 index 00000000..a760b09a --- /dev/null +++ b/Resources/Scripts/XEntity/XTRPG/XTRPGShopItemInfo.lua @@ -0,0 +1,38 @@ +local type = type + +local XTRPGShopItemInfo = XClass(nil, "XTRPGShopItemInfo") + +local Default = { + __Id = 0, --道具Id + __Count = 0, --已购买的数量 +} + +function XTRPGShopItemInfo:Ctor(data) + for key, value in pairs(Default) do + if type(value) == "table" then + self[key] = {} + else + self[key] = value + end + end +end + +function XTRPGShopItemInfo:UpdateData(data) + if not data then return end + self.__Id = data.Id + self.__Count = data.Count +end + +function XTRPGShopItemInfo:GetId() + return self.__Id +end + +function XTRPGShopItemInfo:AddCount(count) + self.__Count = self.__Count + count +end + +function XTRPGShopItemInfo:GetCount() + return self.__Count +end + +return XTRPGShopItemInfo \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XTRPG/XTRPGThirdAreaInfo.lua b/Resources/Scripts/XEntity/XTRPG/XTRPGThirdAreaInfo.lua new file mode 100644 index 00000000..37fed1bb --- /dev/null +++ b/Resources/Scripts/XEntity/XTRPG/XTRPGThirdAreaInfo.lua @@ -0,0 +1,42 @@ +local type = type +local pairs = pairs + +local XTRPGThirdAreaInfo = XClass(nil, "XTRPGThirdAreaInfo") + +local Default = { + __Id = 0, + __FinshedFunctionIdDic = {}, +} + +function XTRPGThirdAreaInfo:Ctor(data) + for key, value in pairs(Default) do + if type(value) == "table" then + self[key] = {} + else + self[key] = value + end + end +end + +function XTRPGThirdAreaInfo:UpdateData(data) + if not data then return end + + self.__Id = data.Id + for _, functionId in pairs(data) do + self.__FinshedFunctionIdDic[functionId] = functionId + end +end + +function XTRPGThirdAreaInfo:GetId() + return self.__Id +end + +function XTRPGThirdAreaInfo:IsFunctionFinished(functionId) + return self.__FinshedFunctionIdDic[functionId] and true or false +end + +function XTRPGThirdAreaInfo:SetFunctionFinished(functionId) + self.__FinshedFunctionIdDic[functionId] = functionId +end + +return XTRPGThirdAreaInfo \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XTeam/XTeam.lua b/Resources/Scripts/XEntity/XTeam/XTeam.lua new file mode 100644 index 00000000..c877cc83 --- /dev/null +++ b/Resources/Scripts/XEntity/XTeam/XTeam.lua @@ -0,0 +1,247 @@ +--[[ + 正常数据 + 消耗插件 + 爬塔增益 + 插件掉落 + 输入: + 队伍成员上下阵 + + 队伍额外携带的数据(消耗的插件) +]] +local XTeam = XClass(nil, "XTeam") + +function XTeam:Ctor(id) + self.Id = id or -1 + -- CharacterId | RobotId + self.EntitiyIds = {0, 0, 0} + self.FirstFightPos = 1 + self.CaptainPos = 1 + -- 队伍额外携带的自定义数据 + self.ExtraData = nil + self.AutoSave = id ~= nil + -- 保存回调 + self.SaveCallback = nil + -- 默认不限制 + self.CharacterLimitType = XFubenConfigs.CharacterLimitType.All + self:LoadTeamData() +end + +function XTeam:LoadTeamData() + local initData = XSaveTool.GetData(self:GetSaveKey()) + if not initData then return end + for key, value in pairs(initData) do + self[key] = value + end +end + +function XTeam:UpdateSaveCallback(callback) + self.SaveCallback = callback +end + +function XTeam:UpdateEntityTeamPos(entityId, teamPos, isJoin) + if isJoin then + self.EntitiyIds[teamPos] = entityId or 0 + else + for pos, id in ipairs(self.EntitiyIds) do + if id == entityId then + self.EntitiyIds[pos] = 0 + break + end + end + end + self:Save() +end + +-- teamData : 旧系统的队伍数据 +function XTeam:UpdateFromTeamData(teamData) + self.FirstFightPos = teamData.FirstFightPos + self.CaptainPos = teamData.CaptainPos + for pos, characterId in ipairs(teamData.TeamData) do + self.EntitiyIds[pos] = characterId + end + self:Save() +end + +function XTeam:UpdateFirstFightPos(value) + self.FirstFightPos = value + self:Save() +end + +function XTeam:UpdateCaptianPos(value) + self.CaptainPos = value + self:Save() +end + +function XTeam:UpdateExtraData(data) + self.ExtraData = data +end + +function XTeam:SwitchEntityPos(posA, posB) + local entityIdA = self.EntitiyIds[posA] + local entityIdB = self.EntitiyIds[posB] + self.EntitiyIds[posB] = entityIdA + self.EntitiyIds[posA] = entityIdB + self:Save() +end + +function XTeam:GetId() + return self.Id +end + +-- 获取当前队伍的角色类型 +function XTeam:GetCharacterType() + local entityId = nil + for _, value in pairs(self.EntitiyIds) do + if value > 0 then + entityId = value + break + end + end + if entityId == nil then return XCharacterConfigs.CharacterType.Normal end + local characterId = nil + if XRobotManager.CheckIsRobotId(entityId) then + local robotConfig = XRobotManager.GetRobotTemplate(entityId) + characterId = robotConfig.CharacterId + else + characterId = entityId + end + return XCharacterConfigs.GetCharacterType(characterId) +end + +-- 获取队伍限制角色类型 +function XTeam:GetCharacterLimitType() + return self.CharacterLimitType +end + +function XTeam:GetSaveKey() + return self.Id .. XPlayer.Id +end + +function XTeam:GetEntityIds() + return self.EntitiyIds +end + +function XTeam:GetEntityIdByTeamPos(pos) + return self.EntitiyIds[pos] or 0 +end + +function XTeam:GetEntityIdIsInTeam(entityId) + for pos, v in ipairs(self.EntitiyIds) do + if v == entityId then + return true, pos + end + end + return false, -1 +end + +function XTeam:GetEntityIdPos(entityId) + for pos, v in ipairs(self.EntitiyIds) do + if v == entityId then + return pos + end + end + return -1 +end + +function XTeam:CheckHasSameCharacterId(entityId) + local checkCharacterId = XEntityHelper.GetCharacterIdByEntityId(entityId) + for pos, entityId in pairs(self:GetEntityIds()) do + if XEntityHelper.GetCharacterIdByEntityId(entityId) == checkCharacterId then + return true, pos + end + end + return false, -1 +end + +function XTeam:GetFirstFightPos() + return self.FirstFightPos > 0 and self.FirstFightPos or 1 +end + +function XTeam:GetCaptainPos() + return self.CaptainPos > 0 and self.CaptainPos or 1 +end + +function XTeam:GetCaptainPosEntityId() + return self.EntitiyIds[self:GetCaptainPos()] +end + +function XTeam:GetFirstFightPosEntityId() + return self.EntitiyIds[self:GetFirstFightPos()] +end + +function XTeam:GetIsEmpty() + for _, v in ipairs(self.EntitiyIds) do + if v ~= 0 then + return false + end + end + return true +end + +function XTeam:GetIsFullMember() + for _, v in ipairs(self.EntitiyIds) do + if v == 0 then + return false + end + end + return true +end + +function XTeam:GetExtraData() + return self.ExtraData +end + +function XTeam:Clear() + self.EntitiyIds = {0, 0, 0} + self.FirstFightPos = 1 + self.CaptainPos = 1 + self:Save() +end + +function XTeam:ClearEntityIds() + self.EntitiyIds = {0, 0, 0} + self:Save() +end + +function XTeam:CopyData(OutTeam) + for i=1, #self.EntitiyIds do + self:UpdateEntityTeamPos(OutTeam:GetEntityIdByTeamPos(i), i, true) + end + self:UpdateFirstFightPos(OutTeam:GetFirstFightPos()) + self:UpdateCaptianPos(OutTeam:GetCaptainPos()) + self:Save() +end + +function XTeam:Save() + if not self.AutoSave then return end + -- 默认本地缓存,后面可扩展使用原本的服务器保存方式 + XSaveTool.SaveData(self:GetSaveKey(), { + Id = self.Id, + EntitiyIds = self.EntitiyIds, + FirstFightPos = self.FirstFightPos, + CaptainPos = self.CaptainPos, + }) + if self.SaveCallback then + self.SaveCallback(self) + end +end + +function XTeam:GetIsShowRoleDetailInfo() + local key = self:GetRoleDetailSaveKey() + if not CS.UnityEngine.PlayerPrefs.HasKey(key) then + return false + end + return CS.UnityEngine.PlayerPrefs.GetInt(key) == 1 +end + +function XTeam:SaveIsShowRoleDetailInfo(value) + CS.UnityEngine.PlayerPrefs.SetInt(self:GetRoleDetailSaveKey(), value) +end + +function XTeam:GetRoleDetailSaveKey() + -- 和之前的通用界面保持统一的key + if self.RoleDetailSaveKey == nil then + self.RoleDetailSaveKey = "NewRoomShowInfoToggle" .. tostring(XPlayer.Id) + end + return self.RoleDetailSaveKey +end + +return XTeam \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XWorldBoss/XAttributeAreaEntity.lua b/Resources/Scripts/XEntity/XWorldBoss/XAttributeAreaEntity.lua new file mode 100644 index 00000000..2631c81c --- /dev/null +++ b/Resources/Scripts/XEntity/XWorldBoss/XAttributeAreaEntity.lua @@ -0,0 +1,192 @@ +local XAttributeAreaEntity = XClass(nil, "XAttributeAreaEntity") +local XAttributeStageEntity = require("XEntity/XWorldBoss/XAttributeStageEntity") +local CSTextManagerGetText = CS.XTextManager.GetText +function XAttributeAreaEntity:Ctor(id) + self.Id = id + self.PrivateData = {} + self.GlobalData = {} + + self.ChallengeCount = 0 + self.AreaRewardFlag = false + self.Score = 0 + self.CharacterDatas = {} + + self.StageEntityDic = {} + for _, stageId in pairs(self:GetStageIds() or {}) do + self.StageEntityDic[stageId] = XAttributeStageEntity.New(stageId) + end + self.BossBuffList = {} + self.GetedBossBuffList = {} + self.GetedRobotList = {} + self.FinishStageCount = 0 +end + +function XAttributeAreaEntity:UpdateData(Data) + for key, value in pairs(Data) do + self[key] = value + end +end + +function XAttributeAreaEntity:UpdateStageEntityDic() + self.BossBuffList = {} + self.GetedBossBuffList = {} + self.GetedRobotList = {} + self.FinishStageCount = 0 + + for _, stageData in pairs(self:GetPrivateAttributeStageDatas()) do + self.StageEntityDic[stageData.Id]:UpdateData({ RewardFlag = stageData.RewardFlag }) + end + + for _, stageData in pairs(self:GetGlobalAttributeStageDatas()) do + if self.StageEntityDic[stageData.Id] then + self.StageEntityDic[stageData.Id]:UpdateData({ FinishCount = stageData.FinishCount }) + end + end + + for _, stageEntity in pairs(self.StageEntityDic) do + local isUnLock = true + local lockDesc = "" + if stageEntity:GetIsFinish() then + for _, buffId in pairs(stageEntity:GetBuffIds() or {}) do + local buffCfg = XWorldBossConfigs.GetBuffTemplatesById(buffId) + if buffCfg.Type == XWorldBossConfigs.BuffType.Buff then + table.insert(self.GetedBossBuffList, buffId) + elseif buffCfg.Type == XWorldBossConfigs.BuffType.Robot then + table.insert(self.GetedRobotList, buffId) + end + end + self.FinishStageCount = self.FinishStageCount + 1 + else + local name + for _, stageId in pairs(stageEntity:GetPreStageId() or {}) do + if stageId == 0 then + break + end + if not self.StageEntityDic[stageId]:GetIsFinish() then + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + name = not name and stageCfg.Name or string.format("%s,%s", name, stageCfg.Name) + isUnLock = false + end + end + lockDesc = name and CSTextManagerGetText("WorldBossStageLockText", name) or "" + end + + for _, buffId in pairs(stageEntity:GetBuffIds() or {}) do + local buffCfg = XWorldBossConfigs.GetBuffTemplatesById(buffId) + if buffCfg.Type == XWorldBossConfigs.BuffType.Buff then + table.insert(self.BossBuffList, buffId) + end + end + local tmpData = {} + tmpData.IsLock = not isUnLock + tmpData.LockDesc = lockDesc + stageEntity:UpdateData(tmpData) + end + +end + +function XAttributeAreaEntity:GetCfg() + return XWorldBossConfigs.GetAttributeAreaTemplatesById(self.Id) +end + +function XAttributeAreaEntity:GetId() + return self.Id +end + +function XAttributeAreaEntity:GetChallengeCount()--区域挑战次数 + return self.ChallengeCount +end + +function XAttributeAreaEntity:GetScore()--区域积分 + return self.Score +end + +function XAttributeAreaEntity:GetIsRewardGeted()--区域奖励是否领取 + return self.AreaRewardFlag +end + +function XAttributeAreaEntity:GetCharacterDatas()--本区域的上一次的出战队列 + return self.CharacterDatas +end + +function XAttributeAreaEntity:GetStageEntityDic()--该区域下所有关卡 + return self.StageEntityDic +end + +function XAttributeAreaEntity:GetBossBuffList()--获得本区域所有biffId数组 + return self.BossBuffList +end + +function XAttributeAreaEntity:GetGetedBossBuffList()--获得本区域已经获得的biffId数组 + return self.GetedBossBuffList +end + +function XAttributeAreaEntity:GetGetedRobotList()--获得本区域已经获得的机器人数组 + return self.GetedRobotList +end + +function XAttributeAreaEntity:GetFinishStageCount()--获得本区域已探索完成关卡数 + return self.FinishStageCount +end + +function XAttributeAreaEntity:GetIsAreaFinish()--获得本区域已探索完成关卡数 + return self.FinishStageCount >= #self:GetStageIds() +end + + +function XAttributeAreaEntity:GetPrivateAttributeStageDatas()--获得私人属性关卡数据 + return self.PrivateData or {} +end + +function XAttributeAreaEntity:GetGlobalAttributeStageDatas()--获得公共属性关卡数据 + return self.GlobalData or {} +end + +function XAttributeAreaEntity:GetStageEntityById(id)--该区域某个关卡 + if not self.StageEntityDic[id] then + XLog.Error("AttributeArea Id:" .. self.Id .. " Is Not Have Stage id:" .. id) + end + return self.StageEntityDic[id] +end + +function XAttributeAreaEntity:GetName() + return self:GetCfg().Name +end + +function XAttributeAreaEntity:GetEnglishName() + return self:GetCfg().EnglishName +end + +function XAttributeAreaEntity:GetMaxChallengeCount() + return self:GetCfg().MaxChallengeCount +end + +function XAttributeAreaEntity:GetFinishReward() + return self:GetCfg().FinishReward +end + +function XAttributeAreaEntity:GetBuffIds() + return self:GetCfg().BuffId +end + +function XAttributeAreaEntity:GetStageIds() + return self:GetCfg().StageId +end + +function XAttributeAreaEntity:GetStartStoryId() + return self:GetCfg().StartStoryId +end + +function XAttributeAreaEntity:GetAreaImg() + return self:GetCfg().AreaImg +end + +function XAttributeAreaEntity:GetAreaDesc() + return self:GetCfg().AreaDesc +end + +function XAttributeAreaEntity:GetPrefabName() + return self:GetCfg().PrefabName +end + +return XAttributeAreaEntity \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XWorldBoss/XAttributeStageEntity.lua b/Resources/Scripts/XEntity/XWorldBoss/XAttributeStageEntity.lua new file mode 100644 index 00000000..c7c98d6c --- /dev/null +++ b/Resources/Scripts/XEntity/XWorldBoss/XAttributeStageEntity.lua @@ -0,0 +1,81 @@ +local XAttributeStageEntity = XClass(nil, "XAttributeStageEntity") + +function XAttributeStageEntity:Ctor(id) + self.Id = id + self.RewardFlag = false + self.FinishCount = 0 + self.IsLock = true + self.LockDesc = "" +end + +function XAttributeStageEntity:UpdateData(Data) + for key, value in pairs(Data) do + self[key] = value + end +end + +function XAttributeStageEntity:GetCfg() + return XWorldBossConfigs.GetAttributeStageTemplatesById(self.Id) +end + +function XAttributeStageEntity:GetStageCfg() + return XDataCenter.FubenManager.GetStageCfg(self.Id) +end + +function XAttributeStageEntity:GetId() + return self.Id +end + +function XAttributeStageEntity:GetIsRewardGeted()--区域关卡奖励是否领取 + return self.RewardFlag +end + +function XAttributeStageEntity:GetFinishCount()--区域关卡全局完成次数 + return self.FinishCount +end + +function XAttributeStageEntity:GetIsLock()--区域关卡是否未开启 + return self.IsLock +end + +function XAttributeStageEntity:GetLockDesc()--区域关卡上锁提示 + return self.LockDesc +end + +function XAttributeStageEntity:GetTotalFinishCount() + return self:GetCfg().TotalFinishCount +end + +function XAttributeStageEntity:GetPreStageId() + return self:GetCfg().PreStageId +end + +function XAttributeStageEntity:GetFinishReward() + return self:GetCfg().FinishReward +end + +function XAttributeStageEntity:GetBuffIds() + return self:GetCfg().BuffId +end + +function XAttributeStageEntity:GetConsumeId() + return self:GetCfg().ConsumeId +end + +function XAttributeStageEntity:GetConsumeCount() + return self:GetCfg().ConsumeCount +end + +function XAttributeStageEntity:GetStartStoryId() + return self:GetCfg().StartStoryId +end + +function XAttributeStageEntity:GetIsFinish()--区域关卡是否完成 + return self.FinishCount >= self:GetTotalFinishCount() +end + +function XAttributeStageEntity:GetFinishPercent()--区域关卡是否完成 + return math.min(1, self.FinishCount / self:GetTotalFinishCount()) +end + +return XAttributeStageEntity \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XWorldBoss/XBossAreaEntity.lua b/Resources/Scripts/XEntity/XWorldBoss/XBossAreaEntity.lua new file mode 100644 index 00000000..d506f481 --- /dev/null +++ b/Resources/Scripts/XEntity/XWorldBoss/XBossAreaEntity.lua @@ -0,0 +1,145 @@ +local XBossAreaEntity = XClass(nil, "XBossAreaEntity") +local XPhasesRewardEntity = require("XEntity/XWorldBoss/XPhasesRewardEntity") +function XBossAreaEntity:Ctor(id) + self.Id = id + self.LoseHp = 0 + self.MaxHp = 1 + self.ChallengeCount = 0 + self.HpRecord = 0 + self.IsLock = true-----------------------还差解锁更新检查 + self.CharacterDatas = {} + self.GetedPhasesRewardIds = {} + --------------------------------------------------------- + self.PhasesRewardEntityDic = {} + for _,phasesRewardId in pairs(self:GetPhasesRewardIds()) do + self.PhasesRewardEntityDic[phasesRewardId] = XPhasesRewardEntity.New(phasesRewardId) + end +end + +function XBossAreaEntity:UpdateData(playerData) + for key, value in pairs(playerData) do + self[key] = value + end +end + +function XBossAreaEntity:UpdatePhasesReward() + for _,rewardEntity in pairs(self.PhasesRewardEntityDic) do + local isCanGet = self:GetBossHp() <= (rewardEntity:GetHpPercent() * 0.01 * self:GetTotalHp()) + local isGeted = self:GetIsGetedRewardById(rewardEntity:GetId()) + rewardEntity:UpdateData({IsCanGet = isCanGet,IsGeted = isGeted}) + end +end + +function XBossAreaEntity:GetCfg() + return XWorldBossConfigs.GetBossAreaTemplatesById(self.Id) +end + +function XBossAreaEntity:GetId() + return self.Id +end + +function XBossAreaEntity:GetBossHp() + return self:GetTotalHp() - self.LoseHp +end + +function XBossAreaEntity:GetIsFinish() + return self:GetBossHp() <= 0 +end + +function XBossAreaEntity:GetChallengeCount() + return self.ChallengeCount +end + +function XBossAreaEntity:GetHpRecord() + return self.HpRecord +end + +function XBossAreaEntity:GetIsLock() + return self.IsLock +end + +function XBossAreaEntity:GetTotalHp() + return self.MaxHp ~= 0 and self.MaxHp or 1 +end + +function XBossAreaEntity:GetGetedPhasesRewardIds() + return self.GetedPhasesRewardIds +end + +function XBossAreaEntity:GetPhasesRewardEntityDic()--该区域下所有阶段奖励 + return self.PhasesRewardEntityDic +end + +function XBossAreaEntity:GetCharacterDatas() + return self.CharacterDatas +end + +function XBossAreaEntity:GetIsGetedRewardById(id) + for _,rewardId in pairs(self.GetedPhasesRewardIds) do + if rewardId == id then + return true + end + end + return false +end + +function XBossAreaEntity:GetRewardEntityById(id)--该区域某个阶段奖励 + if not self.PhasesRewardEntityDic[id] then + XLog.Error("BossArea Id:"..self.Id.." Is Not Have PhasesReward id:"..id) + end + return self.PhasesRewardEntityDic[id] +end + +function XBossAreaEntity:GetName() + return self:GetCfg().Name +end + +function XBossAreaEntity:GetOpenCount() + return self:GetCfg().UnlockNeedStageCount +end + +function XBossAreaEntity:GetMaxChallengeCount() + return self:GetCfg().MaxChallengeCount +end + +function XBossAreaEntity:GetStageId() + return self:GetCfg().StageId +end + +function XBossAreaEntity:GetPhasesRewardIds() + return self:GetCfg().PhasesRewardId +end + +function XBossAreaEntity:GetStartStoryId() + return self:GetCfg().StartStoryId +end + +function XBossAreaEntity:GetFinishStoryId() + return self:GetCfg().FinishStoryId +end + +function XBossAreaEntity:GetAreaImg() + return self:GetCfg().AreaImg +end + +function XBossAreaEntity:GetAreaLockImg() + return self:GetCfg().AreaLockImg +end + +function XBossAreaEntity:GetAreaDesc() + return self:GetCfg().AreaDesc +end + +function XBossAreaEntity:GetModelId() + return self:GetCfg().ModelId +end + +function XBossAreaEntity:GetBossTaskIds() + return self:GetCfg().BossTaskId +end + +function XBossAreaEntity:GetHpPercent() + return self:GetBossHp() / self:GetTotalHp() +end + +return XBossAreaEntity \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XWorldBoss/XBuffEntity.lua b/Resources/Scripts/XEntity/XWorldBoss/XBuffEntity.lua new file mode 100644 index 00000000..3ef56241 --- /dev/null +++ b/Resources/Scripts/XEntity/XWorldBoss/XBuffEntity.lua @@ -0,0 +1,89 @@ +local XBuffEntity = XClass(nil, "XBuffEntity") +local CSXGameClientConfig = CS.XGame.ClientConfig +function XBuffEntity:Ctor(id) + self.Id = id + self.IsLock = true + self.LockDesc = self:GetInfoConditionText() + self.LockDescColor = CSXGameClientConfig:GetString("WorldBossBuffLockColor") + self.InfoTextColor = CSXGameClientConfig:GetString("WorldBossLockInfoColor") +end + +function XBuffEntity:UpdateData(playerData) + for key, value in pairs(playerData) do + self[key] = value + end +end + +function XBuffEntity:GetCfg() + return XWorldBossConfigs.GetBuffTemplatesById(self.Id) +end + +function XBuffEntity:GetId() + return self.Id +end + +function XBuffEntity:GetIsLock() + return self.IsLock +end + +function XBuffEntity:GetLockDesc() + return self.LockDesc +end + +function XBuffEntity:GetLockDescColor() + return self.LockDescColor +end + +function XBuffEntity:GetInfoTextColor() + return self.InfoTextColor +end + +function XBuffEntity:GetType() + return self:GetCfg().Type +end + +function XBuffEntity:GetPriority() + return self:GetCfg().Priority +end + +function XBuffEntity:GetGroupId() + return self:GetCfg().GroupId +end + +function XBuffEntity:GetName() + return self:GetCfg().Name +end + +function XBuffEntity:GetLevel() + return self:GetCfg().Level +end + +function XBuffEntity:GetCustomizeId() + return self:GetCfg().CustomizeId +end + +function XBuffEntity:GetInfoTitle() + return self:GetCfg().InfoTitle +end + +function XBuffEntity:GetInfoText() + return self:GetCfg().InfoText +end + +function XBuffEntity:GetInfoConditionText() + return self:GetCfg().InfoConditionText +end + +function XBuffEntity:GetHintText() + return self:GetCfg().HintText +end + +function XBuffEntity:GetIcon() + return self:GetCfg().Icon +end + +function XBuffEntity:GetIsNotShow() + return self:GetCfg().IsNotShow +end + +return XBuffEntity \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XWorldBoss/XPhasesRewardEntity.lua b/Resources/Scripts/XEntity/XWorldBoss/XPhasesRewardEntity.lua new file mode 100644 index 00000000..77ef6942 --- /dev/null +++ b/Resources/Scripts/XEntity/XWorldBoss/XPhasesRewardEntity.lua @@ -0,0 +1,39 @@ +local XPhasesRewardEntity = XClass(nil, "XPhasesRewardEntity") + +function XPhasesRewardEntity:Ctor(id) + self.Id = id + self.IsCanGet = false + self.IsGeted = false +end + +function XPhasesRewardEntity:UpdateData(playerData) + for key, value in pairs(playerData) do + self[key] = value + end +end + +function XPhasesRewardEntity:GetCfg() + return XWorldBossConfigs.GetPhasesRewardemplatesById(self.Id) +end + +function XPhasesRewardEntity:GetId() + return self.Id +end + +function XPhasesRewardEntity:GetIsCanGet() + return self.IsCanGet +end + +function XPhasesRewardEntity:GetIsGeted() + return self.IsGeted +end + +function XPhasesRewardEntity:GetHpPercent() + return self:GetCfg().HpPercent +end + +function XPhasesRewardEntity:GetRewardId() + return self:GetCfg().RewardId +end + +return XPhasesRewardEntity \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XWorldBoss/XSpecialSaleEntity.lua b/Resources/Scripts/XEntity/XWorldBoss/XSpecialSaleEntity.lua new file mode 100644 index 00000000..b8c0b8fa --- /dev/null +++ b/Resources/Scripts/XEntity/XWorldBoss/XSpecialSaleEntity.lua @@ -0,0 +1,77 @@ +local XSpecialSaleEntity = XClass(nil, "XSpecialSaleEntity") + +function XSpecialSaleEntity:Ctor(id) + self.Id = id + self.IsPurchased = false + + self.DiscountDic = {} + for _,discountId in pairs(self:GetDiscountIds() or {}) do + self.DiscountDic[discountId] = self:GetDiscountCfgById(discountId) + end + + self.MinConsumeCount = 0 + self.MinDiscountText = "" +end + +function XSpecialSaleEntity:UpdateData(playerData) + for key, value in pairs(playerData) do + self[key] = value + end +end + +function XSpecialSaleEntity:GetCfg() + return XWorldBossConfigs.GetBossShopTemplatesById(self.Id) +end + +function XSpecialSaleEntity:GetDiscountCfgById(id) + return XWorldBossConfigs.GetBossShopDiscountTemplatesById(id) +end + +function XSpecialSaleEntity:GetId() + return self.Id +end + +function XSpecialSaleEntity:GetDiscountDic()--打折数据字典 + return self.DiscountDic +end + +function XSpecialSaleEntity:GetRewardId() + return self:GetCfg().RewardId +end + +function XSpecialSaleEntity:GetConsumeId() + return self:GetCfg().ConsumeId +end + +function XSpecialSaleEntity:GetConsumeCount() + return self:GetCfg().ConsumeCount +end + +function XSpecialSaleEntity:GetMinConsumeCount() + return self.MinConsumeCount +end + +function XSpecialSaleEntity:GetMinDiscountText() + return self.MinDiscountText +end + +function XSpecialSaleEntity:GetDiscountIds() + return self:GetCfg().DiscountId +end + +function XSpecialSaleEntity:GetShopImg() + return self:GetCfg().ShopImg +end + +function XSpecialSaleEntity:GetDiscountDic() + return self.DiscountDic +end + +function XSpecialSaleEntity:GetDiscountById(id) + if not self.DiscountDic[id] then + XLog.Error("SpecialSale Id:"..self.Id.." Is Not Have Discount id:"..id) + end + return self.DiscountDic[id] +end + +return XSpecialSaleEntity \ No newline at end of file diff --git a/Resources/Scripts/XEntity/XWorldBoss/XWorldBossActivityEntity.lua b/Resources/Scripts/XEntity/XWorldBoss/XWorldBossActivityEntity.lua new file mode 100644 index 00000000..afd50830 --- /dev/null +++ b/Resources/Scripts/XEntity/XWorldBoss/XWorldBossActivityEntity.lua @@ -0,0 +1,254 @@ +local XWorldBossActivityEntity = XClass(nil, "XWorldBossActivityEntity") +local XSpecialSaleEntity = require("XEntity/XWorldBoss/XSpecialSaleEntity") +local XBossAreaEntity = require("XEntity/XWorldBoss/XBossAreaEntity") +local XAttributeAreaEntity = require("XEntity/XWorldBoss/XAttributeAreaEntity") +local CSTextManagerGetText = CS.XTextManager.GetText +function XWorldBossActivityEntity:Ctor(id) + self.Id = id + self.GlobalData = {} + self.PrivateData = {} + + self.AttributeAreaEntityDic = {} + for _, areaId in pairs(self:GetAttributeAreaIds() or {}) do + self.AttributeAreaEntityDic[areaId] = XAttributeAreaEntity.New(areaId) + end + + self.BossAreaEntityDic = {} + for _, areaId in pairs(self:GetBossAreaIds() or {}) do + self.BossAreaEntityDic[areaId] = XBossAreaEntity.New(areaId) + end + + self.SpecialSaleEntityDic = {} + for _, shopId in pairs(self:GetSpecialSaleIds() or {}) do + self.SpecialSaleEntityDic[shopId] = XSpecialSaleEntity.New(shopId) + end + + self.BossBuffList = {} + self.GetedBossBuffList = {} + self.GetedRobotIdList = {} + self.FinishStageCount = 0 +end + +function XWorldBossActivityEntity:UpdateData(playerData) + for key, value in pairs(playerData) do + self[key] = value + end +end + +function XWorldBossActivityEntity:UpdateEntityDic()--此处顺序不能改变 + self:UpdateAttributeAreaEntityDic() + self:UpdateBossAreaEntityDic() + self:UpdateSpecialSaleEntityDic() +end + +function XWorldBossActivityEntity:UpdateAttributeAreaEntityDic()--更新属性区域实体字典 + self.BossBuffList = {} + self.GetedBossBuffList = {} + self.GetedRobotIdList = {} + self.FinishStageCount = 0 + + for _, attributeArea in pairs(self:GetPrivateAttributeAreaDatas()) do + local tmpData = {} + tmpData.ChallengeCount = attributeArea.ChallengeCount + tmpData.AreaRewardFlag = attributeArea.RewardFlag + tmpData.Score = attributeArea.Score + tmpData.CharacterDatas = attributeArea.CharacterDatas + tmpData.PrivateData = attributeArea.AttributeStageDatas + self.AttributeAreaEntityDic[attributeArea.Id]:UpdateData(tmpData) + end + + for _, attributeArea in pairs(self:GetGlobalAttributeAreaDatas()) do + self.AttributeAreaEntityDic[attributeArea.Id]:UpdateData({ GlobalData = attributeArea.AttributeStageDatas }) + end + + for _, attributeAreaEntity in pairs(self.AttributeAreaEntityDic) do + attributeAreaEntity:UpdateStageEntityDic() + self.FinishStageCount = self.FinishStageCount + attributeAreaEntity:GetFinishStageCount() + + for _, bossBuffId in pairs(attributeAreaEntity:GetBossBuffList()) do + table.insert(self.BossBuffList, bossBuffId) + end + + for _, bossBuffId in pairs(attributeAreaEntity:GetGetedBossBuffList()) do + table.insert(self.GetedBossBuffList, bossBuffId) + end + + for _, robotId in pairs(attributeAreaEntity:GetGetedRobotList()) do + table.insert(self.GetedRobotIdList, robotId) + end + end + + XDataCenter.WorldBossManager.UpdateGetedBossBuff(self.GetedBossBuffList) + XDataCenter.WorldBossManager.UpdateGetedBossBuff(self.GetedRobotIdList) +end + +function XWorldBossActivityEntity:UpdateBossAreaEntityDic()--更新boss区域实体字典 + for _, BossArea in pairs(self:GetPrivateBossAreaDatas()) do + local tmpData = {} + tmpData.ChallengeCount = BossArea.ChallengeCount + tmpData.HpRecord = BossArea.HpRecord + tmpData.GetedPhasesRewardIds = BossArea.PhasesRewardIds + tmpData.CharacterDatas = BossArea.CharacterDatas + self.BossAreaEntityDic[BossArea.Id]:UpdateData(tmpData) + end + + for _, BossArea in pairs(self:GetGlobalBossAreaDatas()) do + local tmpData = {} + tmpData.LoseHp = BossArea.LoseHp + tmpData.MaxHp = BossArea.MaxHp + self.BossAreaEntityDic[BossArea.Id]:UpdateData(tmpData) + end + + for _, bossAreaEntity in pairs(self.BossAreaEntityDic) do + local IsUnLock = self.FinishStageCount >= bossAreaEntity:GetOpenCount() + bossAreaEntity:UpdateData({ IsLock = not IsUnLock }) + bossAreaEntity:UpdatePhasesReward() + end +end + +function XWorldBossActivityEntity:UpdateSpecialSaleEntityDic()--更新特卖实体字典 + for _, specialSaleId in pairs(self:GetPurchasedSaleIds()) do + self.SpecialSaleEntityDic[specialSaleId]:UpdateData({ IsPurchased = true }) + end + + for _, specialSaleEntity in pairs(self.SpecialSaleEntityDic) do + local curDiscountText = "" + local curConsumeCount = specialSaleEntity:GetConsumeCount() + local maxConsumeCount = specialSaleEntity:GetConsumeCount() + for _, discount in pairs(specialSaleEntity:GetDiscountDic()) do + local bossArea = self.BossAreaEntityDic[discount.BossId] + local IsDiscount = bossArea and bossArea:GetBossHp() <= (discount.HpPercent * 0.01 * bossArea:GetTotalHp()) + if IsDiscount and curConsumeCount > discount.Discount * maxConsumeCount then + curConsumeCount = discount.Discount * maxConsumeCount + curDiscountText = discount.DiscountText + end + end + local tmpData = {} + tmpData.MinDiscountText = curDiscountText + tmpData.MinConsumeCount = curConsumeCount + specialSaleEntity:UpdateData(tmpData) + end +end + +function XWorldBossActivityEntity:GetCfg() + return XWorldBossConfigs.GetActivityTemplatesById(self.Id) +end + +function XWorldBossActivityEntity:GetId() + return self.Id +end + +function XWorldBossActivityEntity:GetFinishStageCount() + return self.FinishStageCount +end + +function XWorldBossActivityEntity:GetGetedBossBuffList() + return self.GetedBossBuffList +end + +function XWorldBossActivityEntity:GetBossBuffList() + return self.BossBuffList +end + +function XWorldBossActivityEntity:GetGetedRobotIdList() + return self.GetedRobotIdList +end + +function XWorldBossActivityEntity:GetPrivateAttributeAreaDatas()--获取私有属性区域数据 + return self.PrivateData.AttributeAreaDatas or {} +end + +function XWorldBossActivityEntity:GetGlobalAttributeAreaDatas()--获取公共属性区域数据 + return self.GlobalData.AttributeAreaDatas or {} +end + +function XWorldBossActivityEntity:GetPrivateBossAreaDatas()--获取私有boss区域数据 + return self.PrivateData.BossAreaDatas or {} +end + +function XWorldBossActivityEntity:GetGlobalBossAreaDatas()--获取公共boss区域数据 + return self.GlobalData.BossAreaDatas or {} +end + +function XWorldBossActivityEntity:GetPurchasedSaleIds()--获取特卖已购买列表 + return self.PrivateData.ShopIds or {} +end + +function XWorldBossActivityEntity:GetName() + return self:GetCfg().Name +end + +function XWorldBossActivityEntity:GetBeginTime() + return XFunctionManager.GetStartTimeByTimeId(self:GetCfg().TimeId) or 0 +end + +function XWorldBossActivityEntity:GetEndTime() + return XFunctionManager.GetEndTimeByTimeId(self:GetCfg().TimeId) or 0 +end + +function XWorldBossActivityEntity:GetAttributeAreaIds() + return self:GetCfg().AttributeAreaId +end + +function XWorldBossActivityEntity:GetBossAreaIds() + return self:GetCfg().BossAreaId +end + +function XWorldBossActivityEntity:GetSpecialSaleIds() + return self:GetCfg().SpecialSaleId +end + +function XWorldBossActivityEntity:GetActionPointId() + return self:GetCfg().ActionPointId +end + +function XWorldBossActivityEntity:GetMaxActionPoint() + return self:GetCfg().MaxActionPoint +end + +function XWorldBossActivityEntity:GetShopCurrencyId() + return self:GetCfg().ShopCurrencyId +end + +function XWorldBossActivityEntity:GetStartStoryId() + return self:GetCfg().StartStoryId +end + +function XWorldBossActivityEntity:GetBg() + return self:GetCfg().Bg +end + +function XWorldBossActivityEntity:GetAttributeAreaEntityDic() + return self.AttributeAreaEntityDic +end + +function XWorldBossActivityEntity:GetBossAreaEntityDic() + return self.BossAreaEntityDic +end + +function XWorldBossActivityEntity:GetSpecialSaleEntityDic() + return self.SpecialSaleEntityDic +end + +function XWorldBossActivityEntity:GetAttributeAreaEntityById(id)--获取某个属性区域实体 + if not self.AttributeAreaEntityDic[id] then + XLog.Error("WorldBossActivity Id:" .. self.Id .. " Is Not Have AttributeArea id:" .. id) + end + return self.AttributeAreaEntityDic[id] +end + +function XWorldBossActivityEntity:GetBossAreaEntityById(id)--获取某个boss区域实体 + if not self.BossAreaEntityDic[id] then + XLog.Error("WorldBossActivity Id:" .. self.Id .. " Is Not Have BossArea id:" .. id) + end + return self.BossAreaEntityDic[id] +end + +function XWorldBossActivityEntity:GetSpecialSaleEntityById(id)--获取某个特卖实体 + if not self.SpecialSaleEntityDic[id] then + XLog.Error("WorldBossActivity Id:" .. self.Id .. " Is Not Have SpecialSale id:" .. id) + end + return self.SpecialSaleEntityDic[id] +end + +return XWorldBossActivityEntity \ No newline at end of file diff --git a/Resources/Scripts/XFormula/XArithmetic.lua b/Resources/Scripts/XFormula/XArithmetic.lua new file mode 100644 index 00000000..bc9b220e --- /dev/null +++ b/Resources/Scripts/XFormula/XArithmetic.lua @@ -0,0 +1,254 @@ +-- require("XCommon/XClass") +-- require("XCommon/XGlobalFunc") + +local function split(input, delimiter) + input = tostring(input) + delimiter = tostring(delimiter) + if (delimiter=='') then return false end + local pos,arr = 0, {} + for st,sp in function() return string.find(input, delimiter, pos, true) end do + table.insert(arr, string.sub(input, pos, st - 1)) + pos = sp + 1 + end + table.insert(arr, string.sub(input, pos)) + return arr +end + +--------------------------------------------------------------- +-- @class module +-- @name Stack +-- @author liqiang +local Stack = XClass(nil, "Stack") + +--[[-- +得到栈内元素数量 +@treturn number size 元素个数 +]] +function Stack:size() + return #self +end + +--[[-- +栈是否为空 +@treturn boolean b true为空,否则为不空 +]] +function Stack:empty() + return (self:size() == 0) +end + +--[[-- +出栈 +@treturn void value 返回删除的元素,空返回nil +]] +function Stack:pop() + local tmp = self:top() + table.remove(self) + return tmp +end + +--[[-- +入栈 +@tparam void value 入栈的元素 +@treturn number size 入栈后元素个数 +]] +function Stack:push(value) + table.insert(self, value) + return self:size() +end + +--[[-- +得到栈顶元素 +@treturn void value 栈顶元素,空返回nil +]] +function Stack:top() + local size = self:size() + if size == 0 then + return nil + end + return self[size] +end + +local XArithmetic = XClass(nil, "XArithmetic") + +local defaultOperatorLevel = { + ["+"] = 0, + ["-"] = 0, + ["("] = 10, + ["*"] = 1, + ["/"] = 1, + [")"] = 0, + ["<"] = 1, + [">"] = 1, + ["^"] = 2, +} + +local defaultOperatorPattern = { + ["%+"] = "+", + ["%-"] = "-", + ["%("] = "(", + ["%*"] = "*", + ["/"] = "/", + ["%)"] = ")", + ["<"] = "<", + [">"] = ">", + ["%^"] = "^", +} + +local charsReg = "^%a+%d*$" + +function XArithmetic:Ctor() + self.OperatorLevel = defaultOperatorLevel + self.OperatorPattern = defaultOperatorPattern + self.GetVariableDelegate = nil +end + +function XArithmetic:SetTextValueHandler(handle) + self.GetVariableDelegate = handle +end + +function XArithmetic:Calculate(expression) + local rpnExperssion = self:ConvertToRPN(self:InsertBlank(expression)) + return self:GetResultByExperssion(rpnExperssion) +end + +function XArithmetic:GetValue(left, right, operator) + if "+" == operator then + return left + right + elseif "-" == operator then + return left - right + elseif "*" == operator then + return left * right + elseif "/" == operator then + return left / right + elseif "<" == operator then + return math.min(left, right) + elseif ">" == operator then + return math.max(left, right) + elseif "^" == operator then + return math.pow(left, right) + end + XLog.Warning("XArithmetic:GetValue error! operator: %s", operator) + return 0 +end + +function XArithmetic:GetResultByExperssion(source) + local operatorLevel = self.OperatorLevel + local stack = Stack.New() + local list = split(source, " ") + for i, current in ipairs(list) do + if tonumber(current) then + stack:push(tonumber(current)) + elseif string.match(current, charsReg) then + stack:push(current) + elseif operatorLevel[current] then + local right = self:GetValueByText(stack:pop()) + local left = self:GetValueByText(stack:pop()) + stack:push(self:GetValue(left, right, string.sub(current, 1, 1))) + end + end + return stack:pop(), #stack +end + +function XArithmetic:GetValueByText(text) + if self.GetVariableDelegate then + return self.GetVariableDelegate(text) + end + if tonumber(text) then + return tonumber(text) + end + XLog.Warning("XArithmetic.GetVariableDelegate == nil") + return 1 +end + +function XArithmetic:ConvertToRPN(source) + local operatorLevel = self.OperatorLevel + local result = "" + local stack = Stack.New() + local list = split(source, " ") + for i, current in ipairs(list) do + -- log("current %s", current) + if tonumber(current) then + result = result..current.." " + elseif string.match(current, charsReg) then + result = result..current.." " + elseif operatorLevel[current] then + if #stack > 0 then + local prev = stack:top() + -- log("prev %s", prev) + if prev == "(" then + stack:push(current) + elseif current == "(" then + stack:push(current) + elseif current == ")" then + while #stack > 0 and stack:top() ~= "(" do + result = result..stack:pop().." " + end + --Pop the "(" + if #stack > 0 and stack:top() == "(" then + stack:pop() + end + elseif operatorLevel[current] <= operatorLevel[prev] then + while #stack > 0 do + local top = stack:pop() + if top ~= "(" and top ~= ")" and operatorLevel[current] <= operatorLevel[top] then + result = result..top.." " + else + -- break + stack:push(top) + break + end + end + stack:push(current) + else + stack:push(current) + end + else + stack:push(current) + end + end + + local text = "" + local i = 1 + while stack[i] ~= nil do + text = text.." "..stack[i] + i = i + 1 + end + -- log(" "..text) + end + if #stack > 0 then + while #stack > 0 do + local top = stack:pop() + if top ~= "(" and top ~= ")" then + result = result..top.." " + end + end + end + -- log(result) + return result +end + +function XArithmetic:InsertBlank(source) + for p, v in pairs(self.OperatorPattern) do + source = string.gsub(source, p, " "..v.." ") + end + return source +end + +return XArithmetic + +-- local function Test(expression, result) +-- local realyResult = XArithmetic:Calculate(expression); +-- XLog.Warning(realyResult, result) +-- if realyResult ~= result then +-- XLog.Warning("Formula.Calculate(\"%s\") != %d, realy result = %d", expression, result, realyResult) +-- else +-- XLog.Debug("XArithmetic test ok") +-- end +-- end + +-- XLog.Warning("===========asdasd") +-- Test("4-2-1+3", 4) +-- Test("1+1*(2+1)-3.8/2 + 1 * (2+1)", 5.1) +-- Test("1000+0+0+0+0-0-0-0+0-100-0-0-0", 900) +-- Test("1000-0-100", 900) +-- Test("0-2*(3+4*6/5)", -15.6) \ No newline at end of file diff --git a/Resources/Scripts/XFormula/XConditionFormula.lua b/Resources/Scripts/XFormula/XConditionFormula.lua new file mode 100644 index 00000000..fc600763 --- /dev/null +++ b/Resources/Scripts/XFormula/XConditionFormula.lua @@ -0,0 +1,106 @@ +local XArithmetic = require("XFormula/XArithmetic") +local XFormula = require("XFormula/XFormula") + +--######################## XConditionArithmetic ######################## +local XConditionArithmetic = XClass(XArithmetic, "XConditionArithmetic") + +function XConditionArithmetic:Ctor() + self.OperatorLevel["&"] = 0 + self.OperatorLevel["|"] = 0 + self.OperatorPattern["%&"] = "&" + self.OperatorPattern["%|"] = "|" + self.ConditionArgs = nil + self.Desc = nil + -- XTableCondition + self.Config = nil +end + +function XConditionArithmetic:GetValue(left, right, operator) + if "&" == operator then + return self:CheckCondition(left) and self:CheckCondition(right) + elseif "|" == operator then + return self:CheckCondition(left) or self:CheckCondition(right) + else + return XConditionArithmetic.Super.GetValue(self, left, right, operator) + end +end + +function XConditionArithmetic:SetConfig(config) + self.Config = config +end + +function XConditionArithmetic:SetConditionArgs(value) + self.ConditionArgs = value +end + +function XConditionArithmetic:ClearDesc() + self.Desc = nil +end + +function XConditionArithmetic:GetDesc() + return self.Desc +end + +function XConditionArithmetic:CheckCondition(id) + if type(id) == "boolean" then + return id + end + local result, desc = XConditionManager.CheckCondition(id, table.unpack(self.ConditionArgs or {})) + -- 记录首次条件不通过的描述 + if result == false and self.Desc == nil then + self.Desc = desc + end + return result +end + +function XConditionArithmetic:Calculate(expression) + local result, size = XConditionArithmetic.Super.Calculate(self, expression) + if size > 0 then + XLog.Error(string.format("请检查condition配置表id%s公式%s是否配置错误" + , self.Config.Id, self.Config.Formula)) + end + -- 特殊处理只有一个条件的情况下 + if type(result) == "number" then + return self:CheckCondition(result) + end + return result +end + +--######################## XConditionFormula ######################## +local XConditionFormula = XClass(XFormula, "XConditionFormula") + +function XConditionFormula:Ctor() + -- XTableCondition + self.Config = nil + self.Arithmetic = XConditionArithmetic.New() + self.Arithmetic:SetTextValueHandler(handler(self, self.GetValueByName)) +end + +function XConditionFormula:SetConfig(config) + self.Config = config + self.Arithmetic:SetConfig(config) +end + +function XConditionFormula:GetValueByName(name) + if type(name) == "boolean" then + return name + end + if tonumber(name) then + return tonumber(name) + end + XLog.Error(string.format("无法识别的值%s,请检查condition配置表id%s公式%s是否配置错误" + , name, self.Config.Id, self.Config.Formula)) + return false +end + +function XConditionFormula:GetResult(formula, conditionArgs) + self.Arithmetic:ClearDesc() + self.Arithmetic:SetConditionArgs(conditionArgs) + local result = self.Arithmetic:Calculate(formula) + local desc = self.Arithmetic:GetDesc() + self.Config = nil + self.Arithmetic:SetConfig(nil) + return result, desc +end + +return XConditionFormula \ No newline at end of file diff --git a/Resources/Scripts/XFormula/XFormula.lua b/Resources/Scripts/XFormula/XFormula.lua new file mode 100644 index 00000000..6bfe7118 --- /dev/null +++ b/Resources/Scripts/XFormula/XFormula.lua @@ -0,0 +1,16 @@ +local XArithmetic = require("XFormula/XArithmetic") + +local XFormula = XClass(nil, "XFormula") + +function XFormula:Ctor() + self.arithmetic = nil +end + +function XFormula:GetResult(text) + if self.arithmetic == nil then + self.arithmetic = XArithmetic.New() + end + return self.arithmetic:Calculate(text) +end + +return XFormula \ No newline at end of file diff --git a/Resources/Scripts/XGame.lua b/Resources/Scripts/XGame.lua new file mode 100644 index 00000000..8b4fb01c --- /dev/null +++ b/Resources/Scripts/XGame.lua @@ -0,0 +1,156 @@ +XGame = XGame or {} + +local UI_LOGIN = "UiLogin" + +XGame.Profiler = CS.XGame.Profiler:CreateChild("XGame") + +XGame.Start1 = function() + XGame.Profiler:Start() + + XConfigCenter.Init() + --打点 + CS.XRecord.Record("23009", "LuaXGameStart") + CS.XApplication.SetProgress(0.86) +end + +XGame.Start2 = function() + XLoginManager.Init() + + XDataCenter.Init() + + CS.XApplication.SetProgress(0.88) +end + +XGame.Start3 = function() + local playerProfiler = XGame.Profiler:CreateChild("XPlayerManager") + playerProfiler:Start() + XPlayerManager.Init() + playerProfiler:Stop() + + local userProfiler = XGame.Profiler:CreateChild("XUserManager") + userProfiler:Start() + XUserManager.Init() + userProfiler:Stop() + + local functionProfiler = XGame.Profiler:CreateChild("XFunctionManager") + functionProfiler:Start() + XFunctionManager.Init() + functionProfiler:Stop() + + local resetProfiler = XGame.Profiler:CreateChild("XResetManager") + resetProfiler:Start() + XResetManager.Init() + resetProfiler:Stop() + CS.XApplication.SetProgress(0.89) +end + +XGame.Start4 = function() + XAttribManager.Init() + CS.XApplication.SetProgress(0.95) +end + +XGame.Start5 = function() + local magicProfiler = XGame.Profiler:CreateChild("XMagicSkillManager") + magicProfiler:Start() + XMagicSkillManager.Init() + magicProfiler:Stop() + + local fightCharacterProfiler = XGame.Profiler:CreateChild("XFightCharacterManager") + fightCharacterProfiler:Start() + XFightCharacterManager.Init() + fightCharacterProfiler:Stop() + + local fightEquipProfiler = XGame.Profiler:CreateChild("XFightEquipManager") + fightEquipProfiler:Start() + XFightEquipManager.Init() + fightEquipProfiler:Stop() + + local fightPartnerProfiler = XGame.Profiler:CreateChild("XFightPartnerManager") + fightPartnerProfiler:Start() + XFightPartnerManager.Init() + fightPartnerProfiler:Stop() + + local modelProfiler = XGame.Profiler:CreateChild("XModelManager") + modelProfiler:Start() + XModelManager.Init() + modelProfiler:Stop() + + local conditionProfiler = XGame.Profiler:CreateChild("XConditionManager") + conditionProfiler:Start() + XConditionManager.Init() + conditionProfiler:Stop() + + local newRoleShowProfiler = XGame.Profiler:CreateChild("XNewRoleShowManager") + newRoleShowProfiler:Start() + XNewRoleShowManager.Init() + newRoleShowProfiler:Stop() + + local rewardProfiler = XGame.Profiler:CreateChild("XRewardManager") + rewardProfiler:Start() + XRewardManager.Init() + rewardProfiler:Stop() + + local roomSingleProfiler = XGame.Profiler:CreateChild("XRoomSingleManager") + roomSingleProfiler:Start() + XRoomSingleManager.Init() + roomSingleProfiler:Stop() + + local robotProfiler = XGame.Profiler:CreateChild("XRobotManager") + robotProfiler:Start() + XRobotManager.Init() + robotProfiler:Stop() + + local tipProfiler = XGame.Profiler:CreateChild("XTipManager") + tipProfiler:Start() + XTipManager.Init() + tipProfiler:Stop() + + local redPointProfiler = XGame.Profiler:CreateChild("XRedPointManager") + redPointProfiler:Start() + XRedPointManager.Init() + redPointProfiler:Stop() + + --local hudProfiler = XGame.Profiler:CreateChild("XHudManager") + --hudProfiler:Start() + --XHudManager.Init() + --hudProfiler:Stop() + + local permissionProfiler = XGame.Profiler:CreateChild("XPermissionManager") + permissionProfiler:Start() + XPermissionManager.Init() + permissionProfiler:Stop() + + CS.XApplication.SetProgress(1, true) +end + +XGame.Start6 = function() + local serverProfiler = XGame.Profiler:CreateChild("XServerManager") + serverProfiler:Start() + XServerManager.Init(function() + CsXUiManager.Instance:PopAllThenOpen(UI_LOGIN) + end) + serverProfiler:Stop() + XGame.Profiler:Stop() + --打点 + CS.XRecord.Record("23014", "LuaXGameStartFinish") + LuaGC() +end + +local BreakPointTimerId = nil +local BreakSocketHandle = nil +XGame.InitBreakPointTimer = function() + if CS.UnityEngine.Application.platform ~= CS.UnityEngine.RuntimePlatform.WindowsEditor then + return + end + + if BreakPointTimerId then + XScheduleManager.UnSchedule(BreakPointTimerId) + BreakPointTimerId = nil + end + if not BreakSocketHandle then + local debugXpCall + BreakSocketHandle, debugXpCall = require("XDebug/LuaDebug")("localhost", 7003) + end + BreakPointTimerId = XScheduleManager.ScheduleForever(BreakSocketHandle, 0) +end +XGame.InitBreakPointTimer() \ No newline at end of file diff --git a/Resources/Scripts/XGuide/Agent/XGuideAgent.lua b/Resources/Scripts/XGuide/Agent/XGuideAgent.lua new file mode 100644 index 00000000..abd7ea87 --- /dev/null +++ b/Resources/Scripts/XGuide/Agent/XGuideAgent.lua @@ -0,0 +1,190 @@ +local XGuideAgent = XLuaBehaviorManager.RegisterAgent(XLuaBehaviorAgent, "Guide") + +function XGuideAgent:OnAwake() + self.UiGuide = nil +end + +--获取Ui +function XGuideAgent:GetUi(uiName) + local isUiShow = CsXUiManager.Instance:IsUiShow(uiName) + if not isUiShow then + XLog.Error(uiName .. " is not showing") + return + end + + local ui = CsXUiManager.Instance:FindTopUi(uiName) + if not ui then + XLog.Error(uiName .. " is not on Top") + return + end + + local proxy = ui.UiProxy.UiLuaTable + return proxy +end + +--获取UiGuide +function XGuideAgent:GetUiGuide() + if self.UiGuide and self.UiGuide.Transform and self.UiGuide.Transform:Exist() then + return self.UiGuide + end + + local isUiGuideShow = CsXUiManager.Instance:IsUiShow("UiGuide") + if not isUiGuideShow then + XLuaUiManager.Open("UiGuide") + end + + local uiGuide = CsXUiManager.Instance:FindTopUi("UiGuide") + local proxy = nil + if uiGuide then + proxy = uiGuide.UiProxy.UiLuaTable + end + + self.UiGuide = proxy + + return proxy +end + + +--UI是否显示中 +function XGuideAgent:IsUiShowAndOnTop(uiName, needOnTop) + local isUiShow = CsXUiManager.Instance:IsUiShow(uiName) + if not isUiShow then + return false + end + + if not needOnTop then + return true + end + + local ui = CsXUiManager.Instance:FindTopUi(uiName) + if not ui then + return false + end + + return true +end + +---显示对话头像 +function XGuideAgent:ShowDialog(image, name, content, pos) + local uiGuide = self:GetUiGuide() + uiGuide:ShowDialog(image, name, content, pos) +end + +---隐藏对话头像 +function XGuideAgent:HideDialog() + local uiGuide = self:GetUiGuide() + uiGuide:HideDialog() +end + +---显示遮罩 +function XGuideAgent:ShowMask(isShowMask, isBlockRaycast) + local uiGuide = self:GetUiGuide() + uiGuide:ShowMark(isShowMask, isBlockRaycast) +end + +--ui是否显示中 +function XGuideAgent:IsUiActive(uiName, panel) + local target = self:FindTransformInUi(uiName, panel) + + if not target then + return false + end + + return target.gameObject.activeSelf +end + +--聚焦UI +function XGuideAgent:FocusOn(uiName, panel, eulerAngles, passEvent) + local target = self:FindTransformInUi(uiName, panel) + local uiGuide = self:GetUiGuide() + uiGuide:FocuOnPanel(target, eulerAngles, passEvent) +end + +--索引动态列表 +function XGuideAgent:IndexDynamicTable(uiName, dynamicName, indexKey, indexValue, focusTransform, passEvent) + local target = self:FindTransformInUi(uiName, dynamicName) + + local dynamicTable = target:GetComponent(typeof(CS.XDynamicTableNormal)) + if not dynamicTable then + XLog.Error(string.format("DynamicTable is null uiName:%s dynamicName:%s", uiName, dynamicName)) + return + end + + + local gridIndex = dynamicTable.LuaTableDelegate:GuideGetDynamicTableIndex(indexKey, indexValue) + dynamicTable:ReloadDataSync(gridIndex) + if gridIndex == -1 then + XLog.Error("找不到该动态节点,请检查ID参数是否正确 KEY:" .. tostring(indexKey) .. " ID:" .. tostring(indexValue)) + return nil + end + + local grid = dynamicTable:GetGridByIndex(gridIndex) + if not grid then + XLog.Error("找不到该动态节点,请检查ID参数是否正确 KEY:" .. tostring(indexKey) .. " ID:" .. tostring(indexValue) .. " Index:" .. tostring(gridIndex)) + return nil + end + + if focusTransform == nil or focusTransform == "" or focusTransform == "@" then + self.UiGuide:FocuOnPanel(grid.transform, nil, passEvent) + else + local tmpTarget = grid.transform:FindTransformWithSplit(focusTransform) + self.UiGuide:FocuOnPanel(tmpTarget, nil, passEvent) + end +end + +--寻找Ui +function XGuideAgent:FindTransformInUi(uiName, panel) + local ui = self:GetUi(uiName) + if ui == nil then + XLog.Error("错误!!引导未能找到 Ui:" .. uiName .. " 请检查引导流程") + return + end + + local target = ui.Transform:FindTransformWithSplit(panel) + if not target then + XLog.Error(uiName .. " 未能找到该节点:" .. panel) + return + end + + return target +end + +--跳转关卡 +function XGuideAgent:FubenJumpToStage(stageId) + + local uiFubenMainLineChapter = CsXUiManager.Instance:FindTopUi("UiFubenMainLineChapter") + local proxy = nil + if uiFubenMainLineChapter then + proxy = uiFubenMainLineChapter.UiProxy.UiLuaTable + end + + if proxy then + proxy:GoToStage(stageId) + end + +end + +--ScrollRect滑动到节点 +function XGuideAgent:FocuOnScrollRect(uiName, scroll, target) + + local targetScroll = self:FindTransformInUi(uiName, scroll) + + local scrollRect = targetScroll:GetComponent(typeof(CS.UnityEngine.UI.ScrollRect)) + if not scrollRect then + XLog.Error(string.format("scrollRect 不存在 uiName:%s dynamicName:%s", uiName, scroll)) + return false + end + + + local targetTrans = self:FindTransformInUi(uiName, target) + + if not targetTrans then + XLog.Error(string.format("节点不存在 uiName:%s dynamicName:%s", uiName, target)) + return false + end + + CS.XUiHelper.ScrollItemToView(targetScroll, scrollRect.viewport, scrollRect.content, targetTrans, nil) + + return true + +end \ No newline at end of file diff --git a/Resources/Scripts/XGuide/Node/XGuideCharacterEquipQualityCompareNode.lua b/Resources/Scripts/XGuide/Node/XGuideCharacterEquipQualityCompareNode.lua new file mode 100644 index 00000000..5c538f61 --- /dev/null +++ b/Resources/Scripts/XGuide/Node/XGuideCharacterEquipQualityCompareNode.lua @@ -0,0 +1,45 @@ +local XGuideCharacterEquipQualityCompareNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "CharacterEquipQualityCompare", CsBehaviorNodeType.Action, true, false) +--索引动态列表 +function XGuideCharacterEquipQualityCompareNode:OnAwake() + if self.Fields == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + if self.Fields["CharacterId"] == nil or self.Fields["CompareEquipId"] == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + self.CharacterId = self.Fields["CharacterId"] + self.CompareEquipId = self.Fields["CompareEquipId"] +end + +function XGuideCharacterEquipQualityCompareNode:OnEnter() + if not XDataCenter.CharacterManager.IsOwnCharacter(self.CharacterId) then + self.Node.Status = CsNodeStatus.FAILED + return + end + + local temp = XEquipConfig.GetEquipCfg(self.CompareEquipId) + if not temp then + self.Node.Status = CsNodeStatus.FAILED + return + end + + + local equipId = XDataCenter.EquipManager.GetCharacterWearingWeaponId(self.CharacterId) --初始为角色身上的装备 + local equip = XDataCenter.EquipManager.GetEquip(equipId) + if not equipId or not equip then + self.Node.Status = CsNodeStatus.FAILED + return + end + + local wearEquip = XEquipConfig.GetEquipCfg(equip.TemplateId) + if wearEquip.Star <= temp.Star then + self.Node.Status = CsNodeStatus.FAILED + return + end + + self.Node.Status = CsNodeStatus.SUCCESS +end \ No newline at end of file diff --git a/Resources/Scripts/XGuide/Node/XGuideCharacterEquipWithPosExistNode.lua b/Resources/Scripts/XGuide/Node/XGuideCharacterEquipWithPosExistNode.lua new file mode 100644 index 00000000..10eef766 --- /dev/null +++ b/Resources/Scripts/XGuide/Node/XGuideCharacterEquipWithPosExistNode.lua @@ -0,0 +1,26 @@ +local XGuideCharacterEquipWithPosExistNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "CheckCharacterEquipWithSiteExist", CsBehaviorNodeType.Action, true, false) + +--查找部位意识 +function XGuideCharacterEquipWithPosExistNode:OnAwake() + if self.Fields == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + if self.Fields["CharacterId"] == nil or self.Fields["Site"] == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + self.CharacterId = self.Fields["CharacterId"] + self.Site = self.Fields["Site"] +end + +function XGuideCharacterEquipWithPosExistNode:OnEnter() + local equipId = XDataCenter.EquipManager.GetWearingEquipIdBySite(self.CharacterId, self.Site) + if not equipId then + self.Node.Status = CsNodeStatus.FAILED + else + self.Node.Status = CsNodeStatus.SUCCESS + end +end \ No newline at end of file diff --git a/Resources/Scripts/XGuide/Node/XGuideDynamicIndexNode.lua b/Resources/Scripts/XGuide/Node/XGuideDynamicIndexNode.lua new file mode 100644 index 00000000..29c1d84f --- /dev/null +++ b/Resources/Scripts/XGuide/Node/XGuideDynamicIndexNode.lua @@ -0,0 +1,36 @@ +local XGuideDynamicIndexNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "GuideDynamicIndex", CsBehaviorNodeType.Action, true, false) +--索引动态列表 +function XGuideDynamicIndexNode:OnAwake() + if self.Fields == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + if self.Fields["UiName"] == nil or self.Fields["DynamicName"] == nil or self.Fields["IndexValue"] == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + self.UiName = self.Fields["UiName"] + self.DynamicName = self.Fields["DynamicName"] + self.IndexValue = self.Fields["IndexValue"] + self.IndexKey = self.Fields["IndexKey"] + self.FocusTransform = self.Fields["FocusTransform"] + self.PassEvent = self.Fields["PassEvent"] +end + +function XGuideDynamicIndexNode:OnEnter() + self.AgentProxy:IndexDynamicTable(self.UiName, self.DynamicName, self.IndexKey, self.IndexValue, self.FocusTransform, self.PassEvent) +end + +function XGuideDynamicIndexNode:OnGetEvents() + return { CS.XEventId.EVENT_GUIDE_CLICK_BTNPASS } +end + +function XGuideDynamicIndexNode:OnNotify(evt) + + if evt == CS.XEventId.EVENT_GUIDE_CLICK_BTNPASS then + self.Node.Status = CsNodeStatus.SUCCESS + end + +end \ No newline at end of file diff --git a/Resources/Scripts/XGuide/Node/XGuideEndNode.lua b/Resources/Scripts/XGuide/Node/XGuideEndNode.lua new file mode 100644 index 00000000..ee88d1ca --- /dev/null +++ b/Resources/Scripts/XGuide/Node/XGuideEndNode.lua @@ -0,0 +1,11 @@ +local XGuideEndNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "GuideEnd",CsBehaviorNodeType.Action,true,false) + +function XGuideEndNode:OnStart() + self.GuideId = self.BehaviorTree:GetLocalField("GuideId").Value +end + +function XGuideEndNode:OnEnter() + self.Node.Status = CsNodeStatus.SUCCESS + CsXGameEventManager.Instance:Notify(XEventId.EVENT_GUIDE_END, self.GuideId) +end + diff --git a/Resources/Scripts/XGuide/Node/XGuideFocusOnPanelNode.lua b/Resources/Scripts/XGuide/Node/XGuideFocusOnPanelNode.lua new file mode 100644 index 00000000..cbe723f7 --- /dev/null +++ b/Resources/Scripts/XGuide/Node/XGuideFocusOnPanelNode.lua @@ -0,0 +1,64 @@ +local XGuideFocusOnPanelNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "GuideFocusOn", CsBehaviorNodeType.Action, true, false) + +--初始化数据 +function XGuideFocusOnPanelNode:InitNodeData() + + if not self.Node.Fields then + self.Fields = nil + return + end + + self.Fields = {} + + local fields = self.Node.Fields.Fields + + for _, v in pairs(fields) do + if (v.FieldName == "EulerAngles") then + self.Fields[v.FieldName] = v + else + self.Fields[v.FieldName] = v.Value + end + end +end + + +--聚焦Ui +function XGuideFocusOnPanelNode:OnAwake() + if self.Fields == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + if self.Fields["UiName"] == nil or self.Fields["Transform"] == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + self.UiName = self.Fields["UiName"] + self.Transform = self.Fields["Transform"] + self.AnyClick = self.Fields["AnyClick"] + + + local eulerAngles = self.Fields["EulerAngles"] + self.EulerAngles = CS.UnityEngine.Vector3(eulerAngles.X, eulerAngles.Y, eulerAngles.Z) + self.PassEvent = self.Fields["PassEvent"] +end + +function XGuideFocusOnPanelNode:OnEnter() + self.AgentProxy:FocusOn(self.UiName, self.Transform, self.EulerAngles, self.PassEvent) + +end + +function XGuideFocusOnPanelNode:OnGetEvents() + return { CS.XEventId.EVENT_GUIDE_CLICK_BTNPASS, CS.XEventId.EVENT_GUIDE_ANYCLICK } +end + +function XGuideFocusOnPanelNode:OnNotify(evt) + + if evt == CS.XEventId.EVENT_GUIDE_CLICK_BTNPASS then + self.Node.Status = CsNodeStatus.SUCCESS + elseif self.AnyClick and evt == CS.XEventId.EVENT_GUIDE_ANYCLICK then + self.Node.Status = CsNodeStatus.SUCCESS + end + +end \ No newline at end of file diff --git a/Resources/Scripts/XGuide/Node/XGuideFocusOnScrollRectNode.lua b/Resources/Scripts/XGuide/Node/XGuideFocusOnScrollRectNode.lua new file mode 100644 index 00000000..91924048 --- /dev/null +++ b/Resources/Scripts/XGuide/Node/XGuideFocusOnScrollRectNode.lua @@ -0,0 +1,22 @@ +local XGuideFocusOnScrollRectNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "GuideFocusOnScrollRect", CsBehaviorNodeType.Action, true, false) + + +--聚焦Ui +function XGuideFocusOnScrollRectNode:OnAwake() + if self.Fields == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + self.UiName = self.Fields["UiName"] + self.TargetName = self.Fields["TargetName"] + self.ScrollRect = self.Fields["ScrollRect"] +end + +function XGuideFocusOnScrollRectNode:OnEnter() + if self.AgentProxy:FocuOnScrollRect(self.UiName, self.ScrollRect, self.TargetName) then + self.Node.Status = CsNodeStatus.SUCCESS + else + self.Node.Status = CsNodeStatus.FAILED + end +end \ No newline at end of file diff --git a/Resources/Scripts/XGuide/Node/XGuideFocusSetActive.lua b/Resources/Scripts/XGuide/Node/XGuideFocusSetActive.lua new file mode 100644 index 00000000..cc363095 --- /dev/null +++ b/Resources/Scripts/XGuide/Node/XGuideFocusSetActive.lua @@ -0,0 +1,20 @@ +local XGuideFocusSetActive = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "SetActive", CsBehaviorNodeType.Action, true, false) + +--节点显隐的条件 +function XGuideFocusSetActive:OnAwake() + if self.Fields == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + self.UiName = self.Fields["UiName"] + self.GameObject = self.Fields["GameObject"] + self.Active = self.Fields["Active"] +end + +function XGuideFocusSetActive:OnEnter() + local ts = self.AgentProxy:FindTransformInUi(self.UiName, self.GameObject) + ts.gameObject:SetActiveEx(self.Active) + + self.Node.Status = CsNodeStatus.SUCCESS +end diff --git a/Resources/Scripts/XGuide/Node/XGuideForceStepNode.lua b/Resources/Scripts/XGuide/Node/XGuideForceStepNode.lua new file mode 100644 index 00000000..7fa26b34 --- /dev/null +++ b/Resources/Scripts/XGuide/Node/XGuideForceStepNode.lua @@ -0,0 +1,225 @@ +local GuideForceStepNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "GuideForceStep", CsBehaviorNodeType.Action, true, false) +local GuideForceStepType = { + RunMain = 100, --返回主界面 + OpenUi = 200, --打开不带参数的UI(Par1:Ui名字) + OpenFubenUi = 201, --打开副本页面(Par1:难度ID) + ClickMainLineBanner = 300, --点击主线副本章节(Par1:主章节ID) + ClickFubenStage = 301, --点击关卡(Par1:关卡ID) + ClickStartFight = 302, --点击作战开始进入战前准备(Par1:关卡ID) + ClickEnterFight = 303, --点击开始战斗进入关卡(Par1:关卡ID) + GetTaskReward = 400, --领取任务奖励(Par1:奖励ID) + SetUpEquip = 500, --装备意识 + OpenAwarenessReplace = 600, --打开意识装备界面(Par1:位置) + OpenAwarenessDetail = 700, --打开意识详情界面(Par1:意识ID) + ClickAwarenessPos = 800, --选择意识装备栏(Par1:位置) + GetLiFu = 900, --领取丽芙 + OpenCharacterUi = 901, --打开角色培养界面 + SelectCharacterList = 1000, --选取角色养成列表(Par1:角色ID) + ClickButtonLevelUp = 1100, --点击培养按钮 + ClickButtonLevel = 1200, --点击升级按钮 + ClickLevelUpItem = 1300, --点击经验物品 + LevelUp = 1400, --升级 + ClickTaskJump = 1500, --点击任务跳转(BtnSkip) + ClickNewRoomChar1 = 1600, --点击出战页面第一个角色槽位 + ClickSelectChar = 1700, --点击选择一个角色 + ConformSelectChar = 1800, --确认选人 + SelectSkillLevelTab = 1900, --养成界面选择技能tab + SelectSkillBall = 2000, --养成界面选择技能tab后选择技能球 + SelectSkillBallLevelUp = 2100, --养成界面选择技能tab后选择技能球后点升级 +} +--引导开启节点 +function GuideForceStepNode:OnStart() + -- self.GuideId = self.BehaviorTree:GetLocalField("GuideId").Value +end + +function GuideForceStepNode:OnEnter() + local type = self.Fields["Type"] + if type == GuideForceStepType.RunMain then + + if not XLuaUiManager.IsUiShow("UiMain") then + CsXUiManager.Instance:RunMain() + end + + elseif type == GuideForceStepType.OpenUi then + + local cb = function(ui) + self.Agent:SetVarDicByKey(self.Fields["Par1"], ui) + end + XLuaUiManager.OpenWithCallback(self.Fields["Par1"], cb) + + elseif type == GuideForceStepType.OpenFubenUi then + + XLuaUiManager.Open("UiFuben") + + elseif type == GuideForceStepType.ClickMainLineBanner then + + local chapter = XDataCenter.FubenMainLineManager.GetChapterCfgByChapterMain(tonumber(self.Fields["Par1"]), CS.XGame.Config:GetInt("FubenDifficultNormal")) + local cb = function(ui) + self.Agent:SetVarDicByKey("UiFubenMainLineChapter", ui) + end + XLuaUiManager.OpenWithCallback("UiFubenMainLineChapter", cb, chapter) + + elseif type == GuideForceStepType.ClickFubenStage then + + local stage = XDataCenter.FubenManager.GetStageCfg(tonumber(self.Fields["Par1"])) + local ui = self.Agent:GetVarDicByKey("UiFubenMainLineChapter") + if ui then + ui:OpenOneChildUi("UiFubenMainLineDetail", ui) + end + + elseif type == GuideForceStepType.ClickStartFight then + + local stage = XDataCenter.FubenManager.GetStageCfg(tonumber(self.Fields["Par1"])) + local cb = function(ui) + self.Agent:SetVarDicByKey("UiNewRoomSingle", ui) + end + XLuaUiManager.OpenWithCallback("UiNewRoomSingle", cb, stage.StageId) + + elseif type == GuideForceStepType.ClickEnterFight then + + local stage = XDataCenter.FubenManager.GetStageCfg(tonumber(self.Fields["Par1"])) + local teamId = CS.XGame.Config:GetInt("TypeIdMainLine") + XDataCenter.FubenManager.EnterFight(stage, XDataCenter.TeamManager.GetPlayerTeam(teamId).TeamId, false) + + elseif type == GuideForceStepType.GetTaskReward then + + XDataCenter.TaskManager.FinishTask(tonumber(self.Fields["Par1"]), function(rewardGoodsList) + XUiManager.OpenUiObtain(rewardGoodsList) + end) + + elseif type == GuideForceStepType.SetUpEquip then + + XDataCenter.EquipManager.PutOn(self.Agent:GetVarDicByKey("UiEquipCharacterId"), self.Agent:GetVarDicByKey("UiEquipSelectEquipId")) + + elseif type == GuideForceStepType.OpenAwarenessReplace then + + local cb = function(ui) + ui.UiProxy.UiLuaTable.CharacterId = tonumber(self.Fields["Par1"]) + self.Agent:SetVarDicByKey("UiEquipAwarenessReplace", ui) + self.Agent:SetVarDicByKey("UiEquipCharacterId", tonumber(self.Fields["Par1"])) + end + XLuaUiManager.OpenWithCallback("UiEquipAwarenessReplace", cb, tonumber(self.Fields["Par1"]), tonumber(self.Fields["Par2"])) + + elseif type == GuideForceStepType.OpenAwarenessDetail then + + local ui = self.Agent:GetVarDicByKey("UiEquipAwarenessReplace") + if ui then + local templateId = tonumber(self.Fields["Par1"]) + ui.UiProxy.UiLuaTable.SelectEquipId = XDataCenter.EquipManager.GetFirstEquip(templateId).Id + XLuaUiManager.Open("UiEquipAwarenessPopup", ui.UiProxy.UiLuaTable, false) + self.Agent:SetVarDicByKey("UiEquipSelectEquipId", ui.UiProxy.UiLuaTable.SelectEquipId) + end + + elseif type == GuideForceStepType.ClickAwarenessPos then + + local ui = self.Agent:GetVarDicByKey("UiEquipAwarenessReplace") + if ui then + ui.UiProxy.UiLuaTable:SelectEquipSite(tonumber(self.Fields["Par1"])) + end + + elseif type == GuideForceStepType.GetLiFu then + + XDataCenter.TaskManager.GetCourseReward(tonumber(self.Fields["Par1"])) + + elseif type == GuideForceStepType.OpenCharacterUi then + + local cb = function(ui) + self.Agent:SetVarDicByKey("UiCharacter", ui) + end + XLuaUiManager.OpenWithCallback("UiCharacter", cb) + + elseif type == GuideForceStepType.SelectCharacterList then + + local ui = self.Agent:GetVarDicByKey("UiCharacter") + if ui then + local characterId = tonumber(self.Fields["Par1"]) + ui.UiProxy.UiLuaTable:UpdateCharacterList(characterId) + end + + elseif type == GuideForceStepType.ClickButtonLevelUp then + + local ui = self.Agent:GetVarDicByKey("UiCharacter") + if ui then + ui.UiProxy.UiLuaTable:FindChildUiObj("UiCharacterOwnedInfo"):OnBtnLevelUpClick() + end + + elseif type == GuideForceStepType.ClickButtonLevel then + + local ui = self.Agent:GetVarDicByKey("UiCharacter") + if ui then + ui.UiProxy.UiLuaTable:FindChildUiObj("UiPanelCharProperty").PanelsMap[1]:OnBtnLevelUpButtonClick() + end + + elseif type == GuideForceStepType.ClickLevelUpItem then + + local ui = self.Agent:GetVarDicByKey("UiCharacter") + if ui then + ui.UiProxy.UiLuaTable:FindChildUiObj("UiPanelCharProperty").PanelsMap[1].SelectLevelItems:DealSelectItem(1, 1) + end + + elseif type == GuideForceStepType.LevelUp then + + local ui = self.Agent:GetVarDicByKey("UiCharacter") + if ui then + ui.UiProxy.UiLuaTable:FindChildUiObj("UiPanelCharProperty").PanelsMap[1].SelectLevelItems:SendLevelExpItems() + end + + elseif type == GuideForceStepType.ClickTaskJump then + + local taskId = tonumber(self.Fields["Par1"]) + local skipId = XDataCenter.TaskManager.GetTaskTemplate(taskId).SkipId + XFunctionManager.SkipInterface(skipId) + + elseif type == GuideForceStepType.ClickNewRoomChar1 then + + local ui = self.Agent:GetVarDicByKey("UiNewRoomSingle") + if ui then + ui.UiProxy.UiLuaTable:OnBtnChar1Click() + end + + elseif type == GuideForceStepType.ClickSelectChar then + + local ui = self.AgentProxy:GetUi("UiRoomCharacter") + if ui then + ui:SelectCharacter(tonumber(self.Fields["Par1"])) + end + + elseif type == GuideForceStepType.ConformSelectChar then + + local ui = self.AgentProxy:GetUi("UiRoomCharacter") + if ui then + ui:OnBtnJoinTeamClick() + end + + elseif type == GuideForceStepType.SelectSkillLevelTab then + + local ui = self.Agent:GetVarDicByKey("UiCharacter") + if ui then + ui.UiProxy.UiLuaTable:FindChildUiObj("UiPanelCharProperty"):OnClickTabCallBack(4) + end + + elseif type == GuideForceStepType.SelectSkillBall then + + local ui = self.Agent:GetVarDicByKey("UiCharacter") + if ui then + ui.UiProxy.UiLuaTable:FindChildUiObj("UiPanelCharProperty").PanelsMap[4]:OnSelectSkill(1) + end + + elseif type == GuideForceStepType.SelectSkillBallLevelUp then + + local cb = function() + XEventManager.DispatchEvent(XEventId.EVENT_CHARACTER_INCREASE_TIP, CS.XTextManager.GetText("CharacterUngradeSkillComplete")) + local ui = self.AgentProxy:GetUi("UiPanelCharProperty") + if ui then + ui:RefreshData() + ui:Refresh() + end + end + XDataCenter.CharacterManager.UpgradeSubSkillLevel(tonumber(self.Fields["Par1"]), tonumber(self.Fields["Par2"]), cb) + + end + + + + self.Node.Status = CsNodeStatus.SUCCESS +end \ No newline at end of file diff --git a/Resources/Scripts/XGuide/Node/XGuideFubenJumpToStageNode.lua b/Resources/Scripts/XGuide/Node/XGuideFubenJumpToStageNode.lua new file mode 100644 index 00000000..857127d6 --- /dev/null +++ b/Resources/Scripts/XGuide/Node/XGuideFubenJumpToStageNode.lua @@ -0,0 +1,23 @@ +local XGuideFubenJumpToStageNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "GuideFubenJumpToStage", CsBehaviorNodeType.Action, true, false) + + + +--聚焦Ui +function XGuideFubenJumpToStageNode:OnAwake() + if self.Fields == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + if self.Fields["StageId"] == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + self.StageId = self.Fields["StageId"] +end + +function XGuideFubenJumpToStageNode:OnEnter() + self.AgentProxy:FubenJumpToStage(self.StageId) + self.Node.Status = CsNodeStatus.SUCCESS +end \ No newline at end of file diff --git a/Resources/Scripts/XGuide/Node/XGuideHideDialogNode.lua b/Resources/Scripts/XGuide/Node/XGuideHideDialogNode.lua new file mode 100644 index 00000000..76d6a59b --- /dev/null +++ b/Resources/Scripts/XGuide/Node/XGuideHideDialogNode.lua @@ -0,0 +1,7 @@ +local XGuideHideDialogNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "GuideHideDialog",CsBehaviorNodeType.Action,true,false) +--隐藏对话头像 +function XGuideHideDialogNode:OnEnter() + self.AgentProxy:HideDialog() + self.Node.Status = CsNodeStatus.SUCCESS +end + diff --git a/Resources/Scripts/XGuide/Node/XGuideIsAnyClickNode.lua b/Resources/Scripts/XGuide/Node/XGuideIsAnyClickNode.lua new file mode 100644 index 00000000..fb6a60e1 --- /dev/null +++ b/Resources/Scripts/XGuide/Node/XGuideIsAnyClickNode.lua @@ -0,0 +1,14 @@ +local XGuideIsAnyClickNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "GuideIsAnyClick", CsBehaviorNodeType.Condition, true, false) +--点击任意位置 +function XGuideIsAnyClickNode:OnGetEvents() + return { CS.XEventId.EVENT_GUIDE_ANYCLICK } +end + +function XGuideIsAnyClickNode:OnNotify(evt) + + if evt == CS.XEventId.EVENT_GUIDE_ANYCLICK then + self.Node.Status = CsNodeStatus.SUCCESS + end + +end + diff --git a/Resources/Scripts/XGuide/Node/XGuideIsCharacterInTeamNode.lua b/Resources/Scripts/XGuide/Node/XGuideIsCharacterInTeamNode.lua new file mode 100644 index 00000000..41b4be75 --- /dev/null +++ b/Resources/Scripts/XGuide/Node/XGuideIsCharacterInTeamNode.lua @@ -0,0 +1,23 @@ +local XGuideIsCharacterInTeamNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "IsCharacterInTeam", CsBehaviorNodeType.Condition, true, false) + +function XGuideIsCharacterInTeamNode:OnAwake() + if self.Fields == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + if self.Fields["CharacterId"] == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + self.CharacterId = self.Fields["CharacterId"] +end + +function XGuideIsCharacterInTeamNode:OnEnter() + if XDataCenter.TeamManager.CheckInTeam(self.CharacterId) then + self.Node.Status = CsNodeStatus.SUCCESS + else + self.Node.Status = CsNodeStatus.FAILED + end +end diff --git a/Resources/Scripts/XGuide/Node/XGuideIsGameObjectActiveNode.lua b/Resources/Scripts/XGuide/Node/XGuideIsGameObjectActiveNode.lua new file mode 100644 index 00000000..f27f8a9b --- /dev/null +++ b/Resources/Scripts/XGuide/Node/XGuideIsGameObjectActiveNode.lua @@ -0,0 +1,24 @@ +local XGuideIsUiOpenNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "IsGameObjectActive", CsBehaviorNodeType.Condition, true, false) + +function XGuideIsUiOpenNode:OnAwake() + if self.Fields == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + if self.Fields["UiName"] == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + self.UiName = self.Fields["UiName"] + self.GameObject = self.Fields["GameObject"] +end + +function XGuideIsUiOpenNode:OnEnter() + if self.AgentProxy:IsUiActive(self.UiName, self.GameObject) then + self.Node.Status = CsNodeStatus.SUCCESS + else + self.Node.Status = CsNodeStatus.FAILED + end +end diff --git a/Resources/Scripts/XGuide/Node/XGuideIsJoinGuildNode.lua b/Resources/Scripts/XGuide/Node/XGuideIsJoinGuildNode.lua new file mode 100644 index 00000000..a4c0dda6 --- /dev/null +++ b/Resources/Scripts/XGuide/Node/XGuideIsJoinGuildNode.lua @@ -0,0 +1,9 @@ +local XGuideIsJoinGuildNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "IsJoinGuild", CsBehaviorNodeType.Condition, true, false) + +function XGuideIsJoinGuildNode:OnEnter() + if XDataCenter.GuildManager.IsJoinGuild() then + self.Node.Status = CsNodeStatus.SUCCESS + else + self.Node.Status = CsNodeStatus.FAILED + end +end \ No newline at end of file diff --git a/Resources/Scripts/XGuide/Node/XGuideIsUiOpenNode.lua b/Resources/Scripts/XGuide/Node/XGuideIsUiOpenNode.lua new file mode 100644 index 00000000..e4b7be5d --- /dev/null +++ b/Resources/Scripts/XGuide/Node/XGuideIsUiOpenNode.lua @@ -0,0 +1,24 @@ +local XGuideIsUiOpenNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "IsUiOpen", CsBehaviorNodeType.Condition, true, false) + +function XGuideIsUiOpenNode:OnAwake() + if self.Fields == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + if self.Fields["UiName"] == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + self.UiName = self.Fields["UiName"] + self.RequireOnTop = self.Fields["RequireOnTop"] +end + +function XGuideIsUiOpenNode:OnEnter() + if self.AgentProxy:IsUiShowAndOnTop(self.UiName, self.RequireOnTop) then + self.Node.Status = CsNodeStatus.SUCCESS + else + self.Node.Status = CsNodeStatus.FAILED + end +end diff --git a/Resources/Scripts/XGuide/Node/XGuideOpenDormitoryNode.lua b/Resources/Scripts/XGuide/Node/XGuideOpenDormitoryNode.lua new file mode 100644 index 00000000..099d8774 --- /dev/null +++ b/Resources/Scripts/XGuide/Node/XGuideOpenDormitoryNode.lua @@ -0,0 +1,21 @@ +local XGuideOpenDormitoryNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "OpenDormitory", CsBehaviorNodeType.Action, true, false) + +function XGuideOpenDormitoryNode:OnAwake() + if self.Fields == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + if self.Fields["DormId"] == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + self.DormId = self.Fields["DormId"] +end + +function XGuideOpenDormitoryNode:OnEnter() + XLuaUiManager.Open("UiDormSecond", XDormConfig.VisitDisplaySetType.MySelf, self.DormId) + XHomeDormManager.SetSelectedRoom(self.DormId, true) + self.Node.Status = CsNodeStatus.SUCCESS +end diff --git a/Resources/Scripts/XGuide/Node/XGuideRecordNode.lua b/Resources/Scripts/XGuide/Node/XGuideRecordNode.lua new file mode 100644 index 00000000..fd1902a8 --- /dev/null +++ b/Resources/Scripts/XGuide/Node/XGuideRecordNode.lua @@ -0,0 +1,33 @@ +local XGuideRecordNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "GuideRecord", CsBehaviorNodeType.Action, true, false) +--显示对话头像 +function XGuideRecordNode:OnStart() + self.GuideId = self.BehaviorTree:GetLocalField("GuideId").Value +end + +function XGuideRecordNode:OnGetEvents() + return { XEventId.EVENT_GUIDE_COMPLETED_SUCCESS } +end + +function XGuideRecordNode:OnEnter() + + if XDataCenter.GuideManager.CheckIsGuide(self.GuideId) then + self.Node.Status = CsNodeStatus.SUCCESS + return + end + + local guideGroup = XGuideConfig.GetGuideGroupTemplatesById(self.GuideId) + local config = XGuideConfig.GetGuideCompleteTemplatesById(guideGroup.CompleteId) + + if config.Param[1] == 1 then + XDataCenter.GuideManager.ReqGuideComplete(self.GuideId) + end +end + +function XGuideRecordNode:OnNotify(evt, ...) + + local args = { ... } + + if evt == XEventId.EVENT_GUIDE_COMPLETED_SUCCESS and args[1] == self.GuideId then + self.Node.Status = CsNodeStatus.SUCCESS + end +end \ No newline at end of file diff --git a/Resources/Scripts/XGuide/Node/XGuideShowDialogNode.lua b/Resources/Scripts/XGuide/Node/XGuideShowDialogNode.lua new file mode 100644 index 00000000..d01b5c7e --- /dev/null +++ b/Resources/Scripts/XGuide/Node/XGuideShowDialogNode.lua @@ -0,0 +1,23 @@ +local XGuideShowDialogNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "GuideShowDialog", CsBehaviorNodeType.Action, true, false) +--显示对话头像 +function XGuideShowDialogNode:OnAwake() + if self.Fields == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + if self.Fields["Image"] == nil or self.Fields["Name"] == nil or self.Fields["Content"] == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + self.ImageString = self.Fields["Image"] + self.RoleName = self.Fields["Name"] + self.Content = self.Fields["Content"] + self.Pos = self.Fields["Pos"] +end + +function XGuideShowDialogNode:OnEnter() + self.AgentProxy:ShowDialog(self.ImageString, self.RoleName, self.Content, self.Pos) + self.Node.Status = CsNodeStatus.SUCCESS +end \ No newline at end of file diff --git a/Resources/Scripts/XGuide/Node/XGuideShowMaskNode.lua b/Resources/Scripts/XGuide/Node/XGuideShowMaskNode.lua new file mode 100644 index 00000000..77ff928e --- /dev/null +++ b/Resources/Scripts/XGuide/Node/XGuideShowMaskNode.lua @@ -0,0 +1,26 @@ +local XGuideShowMaskNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "GuideShowMask",CsBehaviorNodeType.Action,true,false) +--显示对话头像 +function XGuideShowMaskNode:OnAwake() + + + if self.Fields == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + + if self.Fields["IsShowMask"] == nil or self.Fields["IsBlockRayCast"] == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + self.IsShowMask = self.Fields["IsShowMask"] + self.IsBlockRayCast = self.Fields["IsBlockRayCast"] +end + +function XGuideShowMaskNode:OnEnter() + + self.AgentProxy:ShowMask(self.IsShowMask,self.IsBlockRayCast) + self.Node.Status = CsNodeStatus.SUCCESS +end + diff --git a/Resources/Scripts/XGuide/Node/XGuideStartNode.lua b/Resources/Scripts/XGuide/Node/XGuideStartNode.lua new file mode 100644 index 00000000..1b088e74 --- /dev/null +++ b/Resources/Scripts/XGuide/Node/XGuideStartNode.lua @@ -0,0 +1,16 @@ +local XGuideStartNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "GuideStart",CsBehaviorNodeType.Action,true,false) +--引导开启节点 +function XGuideStartNode:OnStart() + self.GuideId = self.BehaviorTree:GetLocalField("GuideId").Value +end + +function XGuideStartNode:OnEnter() + self.AgentProxy:ShowMask(false,true) + XDataCenter.GuideManager.ReqGuideOpen(self.GuideId,function() + self.Node.Status = CsNodeStatus.SUCCESS + CS.XGuideEventPass.IsFightGuide = false + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_GUIDE_START) + end) +end + diff --git a/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeBehaviorState.lua b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeBehaviorState.lua new file mode 100644 index 00000000..5d521ce9 --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeBehaviorState.lua @@ -0,0 +1,33 @@ +XHomeBehaviorStatus = { + IDLE = "IDLE", --正常 + SLEEP = "SLEEP", --睡觉 + + TIRED = "TIRED", --想上床躺着 + ANNOY = "ANNOY", --想上沙发 + BORING = "BORING", --无聊,想聊天 + WANTTOUCH = "WANTTOUCH", --想要抚摸 + LAZY = "LAZY", --想翻柜子 + LOVE = "LOVE", --相思 + + REWAWRD = "REWAWRD", --奖励 + GRAB_UP = "GRAB_UP", --抓起 + FONDLE = "FONDLE", --爱抚 + SELECTED = "SELECTED", --选中 + WAIT = "WAIT", --按下 + + CLICK = "CLICK", --选中 + CHNGEPOS = "CHNGEPOS", -- 改变位置 + RELATIOM = "RELATIOM", --与家具交互 +} + +--爱抚类型 +XHomeCharFondleType = { + NORMAL = 0, + TOUCH = 1, + PUSH = 2, + PLAY = 3, + TOUCH_COMPLETE = 4, + PUSH_COMPLETE = 5, + PLAY_COMPLETE = 6, + REFUSE = 7, +} \ No newline at end of file diff --git a/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharAgent.lua b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharAgent.lua new file mode 100644 index 00000000..4b1e4732 --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharAgent.lua @@ -0,0 +1,164 @@ +local XHomeCharAgent = XLuaBehaviorManager.RegisterAgent(XLuaBehaviorAgent, "HomeCharacter") + +function XHomeCharAgent:OnAwake() + self.Path = {} +end + +function XHomeCharAgent:SetHomeCharObj(homeCharObj) + self.HomeCharObj = homeCharObj +end + +--状态改变 +function XHomeCharAgent:ChangeStatus(state) + self.HomeCharObj:ChangeStatus(state) +end + +--状态机改变 +function XHomeCharAgent:ChangeStateMachine(state) + self.HomeCharObj:ChangeStateMachine(state) +end + +--获取属性 例如心情值 +function XHomeCharAgent:GetAtrributeValue(attributeKey) + return self.HomeCharObj:GetAtrributeValue(attributeKey) +end + +--播放动作 +function XHomeCharAgent:DoAction(actionId, needFadeCross, crossDuration) + self.HomeCharObj:DoAction(actionId, needFadeCross, crossDuration) +end + +--显示特定气泡 +function XHomeCharAgent:ShowBubble(id, callback) + self.HomeCharObj:ShowBubble(id, callback) +end + +--显示随机气泡 +function XHomeCharAgent:ShowRandomBubble(callback) + self.HomeCharObj:ShowRandomBubble(callback) +end + +--隐藏气泡 +function XHomeCharAgent:HideBubble() + self.HomeCharObj:HideBubble() +end + +--寻路 +function XHomeCharAgent:DoPathFind(minDistance, maxDistance) + self.HomeCharObj:DoPathFind(minDistance, maxDistance) + return true +end + +--显示特效 +function XHomeCharAgent:PlayEffect(effectId, bindWorldPos) + self.HomeCharObj:PlayEffect(effectId, bindWorldPos) +end + +--隐藏特效 +function XHomeCharAgent:HideEffect() + self.HomeCharObj:HideEffect() +end + +--检测交互 +function XHomeCharAgent:CheckFurnitureInteract() + return self.HomeCharObj:CheckFurnitureInteract() +end + +--检测事件完成 +function XHomeCharAgent:CheckEventCompleted(completeType, callback) + return self.HomeCharObj:CheckEventCompleted(completeType, callback) +end + +--家具交互 +function XHomeCharAgent:InteractFurniture() + return self.HomeCharObj:InteractFurniture() +end + +--家具交互动画 +function XHomeCharAgent:PlayInteractFurnitureAnimation() + return self.HomeCharObj:PlayInteractFurnitureAnimation() +end + +--检测人物交互 +function XHomeCharAgent:CheckCharacterInteracter() + return self.HomeCharObj:CheckCharacterInteracter() +end + +--获取爱抚类型 +function XHomeCharAgent:GetFondleType() + return self.HomeCharObj:GetFondleType() +end + +--出列爱抚类型 +function XHomeCharAgent:DequeueFondleType() + return self.HomeCharObj:DequeueFondleType() +end + +--到达家具交互 +function XHomeCharAgent:ReachFurniture() + self.HomeCharObj:ReachFurniture() +end + +--检测能否取消家具交互 +function XHomeCharAgent:CheckDisInteractFurniture() + return self.HomeCharObj:CheckDisInteractFurniture() +end + +--显示奖励 +function XHomeCharAgent:ShowEventReward() + self.HomeCharObj:ShowEventReward() +end + +--检测是否在家具上方 +function XHomeCharAgent:CheckRayCastFurnitureNode() + return self.HomeCharObj:CheckRayCastFurnitureNode() +end + +--获取状态 +function XHomeCharAgent:GetState() + return self.HomeCharObj:GetState() +end + +--检测事件存在 +function XHomeCharAgent:CheckEventExist(eventId) + return self.HomeCharObj:CheckEventExist(eventId) +end + +--检测是否正在播放指定动画 +function XHomeCharAgent:CheckIsPlayingAnimation(animationName) + return self.HomeCharObj:CheckIsPlayingAnimation(animationName) +end + +--设置是否阻挡 +function XHomeCharAgent:SetObstackeEnable(obstackeEnable) + self.HomeCharObj:SetObstackeEnable(obstackeEnable) +end + +--爱抚结束 +function XHomeCharAgent:DequeueFondleType() + self.HomeCharObj:DequeueFondleType() +end + +--朝向交互家具 +function XHomeCharAgent:SetForwardToFurniture(forward) + return self.HomeCharObj:SetForwardToFurniture(forward) +end + +--获取ID +function XHomeCharAgent:GetId() + return self.HomeCharObj.Id +end + +-- --设置停留点偏移 +-- function XHomeCharAgent:SetStayOffset() +-- return self.HomeCharObj:SetStayPosOffest() +-- end +--设置构造体交互开关 +function XHomeCharAgent:SetCharInteractTrigger(isOn) + return self.HomeCharObj:SetCharInteractTrigger(isOn) +end + +-- 检测构造体是否在坐标索引上 +function XHomeCharAgent:CheckCharInteractPosByIndex(index) + return self.HomeCharObj:CheckCharInteractPosByIndex(index) +end \ No newline at end of file diff --git a/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharFSMFactory.lua b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharFSMFactory.lua new file mode 100644 index 00000000..47a6e310 --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharFSMFactory.lua @@ -0,0 +1,36 @@ +--状态 +XHomeCharFSMType = { + EMPTY = "EMPTY", --空状态 + IDLE = "IDLE", --游荡状态 + MOOD = "MOOD", --心情状态 + INTERACT = "INTERACT", --交互状态 + CONTROL = "CONTROL", --控制状态 +} + +--状态工厂 +XHomeCharFSMFactory = {} +--注册表 +local Registry = {} + +--注册状态机 +function XHomeCharFSMFactory.RegisterFSM(name, state) + local machine = XClass(XHomeCharFSM, name) + Registry[state] = machine + machine.name = state + return machine +end + +--新建状态 +function XHomeCharFSMFactory.New(state, agent) + if not Registry[state] then + XLog.Error("状态机未注册!!!StateMachine :" .. tostring(state)) + return nil + end + + return Registry[state].New(agent) +end + +--清空注册表 +function XHomeCharFSMFactory.ClearRegistry() + Registry = {} +end \ No newline at end of file diff --git a/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharBubbleNode.lua b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharBubbleNode.lua new file mode 100644 index 00000000..f57f8439 --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharBubbleNode.lua @@ -0,0 +1,22 @@ +local XHomeCharBubbleNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "HomeCharBubble", CsBehaviorNodeType.Action, true, false) + +function XHomeCharBubbleNode:OnAwake() + if self.Fields == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + if self.Fields["Content"] == nil or self.Fields["EffectId"] == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + self.Content = self.Fields["Content"] + self.EffectId = self.Fields["EffectId"] +end + + +function XHomeCharBubbleNode:OnEnter() + self.AgentProxy:ShowBubble(self.Content, self.EffectId) + self.Node.Status = CsNodeStatus.SUCCESS +end \ No newline at end of file diff --git a/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharChangeStateMachineNode.lua b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharChangeStateMachineNode.lua new file mode 100644 index 00000000..fc828dbe --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharChangeStateMachineNode.lua @@ -0,0 +1,21 @@ +local XHomeCharChangeStateMachineNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "HomeCharChangeStateMachine",CsBehaviorNodeType.Action,true,false) + +function XHomeCharChangeStateMachineNode:OnAwake() + if self.Fields == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + if self.Fields["StateMachine"] == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + self.StateMachine = self.Fields["StateMachine"] +end + +function XHomeCharChangeStateMachineNode:OnEnter() + self.AgentProxy:ChangeStateMachine(self.StateMachine) + self.Node.Status = CsNodeStatus.SUCCESS +end + diff --git a/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharCheckClick.lua b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharCheckClick.lua new file mode 100644 index 00000000..a1851fb9 --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharCheckClick.lua @@ -0,0 +1,19 @@ +local XHomeCharCheckClick = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "HomeCharCheckClick", CsBehaviorNodeType.Condition, true, false) + + +function XHomeCharCheckClick:OnGetEvents() + return { XEventId.EVENT_DORM_CHARACTER_CLICK_SUCCESS } +end + +function XHomeCharCheckClick:OnEnter() + self.Id = self.AgentProxy:GetId() +end + +function XHomeCharCheckClick:OnNotify(evt, ...) + + local args = { ... } + + if evt == XEventId.EVENT_DORM_CHARACTER_CLICK_SUCCESS and args[1] == self.Id then + self.Node.Status = CsNodeStatus.SUCCESS + end +end \ No newline at end of file diff --git a/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharCheckDisInteractFurnitureNode.lua b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharCheckDisInteractFurnitureNode.lua new file mode 100644 index 00000000..e42b7ac4 --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharCheckDisInteractFurnitureNode.lua @@ -0,0 +1,9 @@ +local XHomeCharCheckDisInteractFurnitureNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "HomeCHarCheckCanDisInteractFurniture", CsBehaviorNodeType.Action, true, false) +function XHomeCharCheckDisInteractFurnitureNode:OnEnter() + if self.AgentProxy:CheckDisInteractFurniture() then + self.Node.Status = CsNodeStatus.SUCCESS + else + self.Node.Status = CsNodeStatus.FAILED + end +end + diff --git a/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharCheckDisgustedNode.lua b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharCheckDisgustedNode.lua new file mode 100644 index 00000000..332d1cae --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharCheckDisgustedNode.lua @@ -0,0 +1,5 @@ +local XHomeCharCheckDisgustedNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "HomeCharCheckDisgusted", CsBehaviorNodeType.Action, true, false) +function XHomeCharCheckDisgustedNode:OnEnter() + self.Node.Status = CsNodeStatus.FAILED +end + diff --git a/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharCheckEventExistNode.lua b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharCheckEventExistNode.lua new file mode 100644 index 00000000..d858ccb0 --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharCheckEventExistNode.lua @@ -0,0 +1,26 @@ +local XHomeCharCheckEventExistNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "HomeCharCheckEventExist", CsBehaviorNodeType.Condition, true, false) + +function XHomeCharCheckEventExistNode:OnAwake() + if self.Fields == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + if self.Fields["EventId"] == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + self.EventId = self.Fields["EventId"] +end + + +function XHomeCharCheckEventExistNode:OnEnter() + local result = self.AgentProxy:CheckEventExist(self.EventId) + + if result then + self.Node.Status = CsNodeStatus.SUCCESS + else + self.Node.Status = CsNodeStatus.FAILED + end +end \ No newline at end of file diff --git a/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharCheckFriendNode.lua b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharCheckFriendNode.lua new file mode 100644 index 00000000..e0fd6e97 --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharCheckFriendNode.lua @@ -0,0 +1,5 @@ +local XHomeCharCheckFriendNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "HomeCharCheckFriend", CsBehaviorNodeType.Condition, true, false) +function XHomeCharCheckFriendNode:OnEnter() + self.Node.Status = CsNodeStatus.FAILED +end + diff --git a/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharCheckInteractNode.lua b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharCheckInteractNode.lua new file mode 100644 index 00000000..7101aa65 --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharCheckInteractNode.lua @@ -0,0 +1,8 @@ +local XHomeCharCheckInteractNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "HomeCharCheckInteract", CsBehaviorNodeType.Condition, true, false) +function XHomeCharCheckInteractNode:OnEnter() + if self.AgentProxy:CheckFurnitureInteract() then + self.Node.Status = CsNodeStatus.SUCCESS + else + self.Node.Status = CsNodeStatus.FAILED + end +end diff --git a/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharCheckPlayAnimationNode.lua b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharCheckPlayAnimationNode.lua new file mode 100644 index 00000000..1c304ed3 --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharCheckPlayAnimationNode.lua @@ -0,0 +1,34 @@ +local XHomeCharCheckPlayAnimationNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "HomeCharCheckPlayAnimation", CsBehaviorNodeType.Condition, true, false) + +function XHomeCharCheckPlayAnimationNode:OnAwake() + if self.Fields == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + if self.Fields["AnimationName"] == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + local list = self.Fields["AnimationName"] + + self.AnimationName = {} + + local count = list.Count + for i = 0, count - 1 do + local v = list[i] + table.insert(self.AnimationName, v) + end +end + + +function XHomeCharCheckPlayAnimationNode:OnEnter() + local result = self.AgentProxy:CheckIsPlayingAnimation(self.AnimationName) + + if result then + self.Node.Status = CsNodeStatus.SUCCESS + else + self.Node.Status = CsNodeStatus.FAILED + end +end \ No newline at end of file diff --git a/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharCheckPointerUpNode.lua b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharCheckPointerUpNode.lua new file mode 100644 index 00000000..fec74789 --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharCheckPointerUpNode.lua @@ -0,0 +1,17 @@ +local XHomeCharCheckPointerUpNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "HomeCharCheckPointerUp", CsBehaviorNodeType.Condition, true, false) + +function XHomeCharCheckPointerUpNode:OnGetEvents() + return { XEventId.EVENT_DORM_CHARACTER_POINTER_UP_SUCCESS } +end + +function XHomeCharCheckPointerUpNode:OnEnter() + self.Id = self.AgentProxy:GetId() +end + +function XHomeCharCheckPointerUpNode:OnNotify(evt, ...) + local args = { ... } + + if evt == XEventId.EVENT_DORM_CHARACTER_POINTER_UP_SUCCESS and args[1] == self.Id then + self.Node.Status = CsNodeStatus.SUCCESS + end +end \ No newline at end of file diff --git a/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharCheckRayCastFurnitureNode.lua b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharCheckRayCastFurnitureNode.lua new file mode 100644 index 00000000..4d994183 --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharCheckRayCastFurnitureNode.lua @@ -0,0 +1,14 @@ +local XHomeCharCheckRayCastFurnitureNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "HomeCharCheckRayCastFurniture", CsBehaviorNodeType.Decorator, true, true) + +function XHomeCharCheckRayCastFurnitureNode:OnUpdate(dt) + local result = self.AgentProxy:CheckRayCastFurnitureNode() + + if not result then + self.Node.ChildNode:OnReset() + self.Node.Status = CsNodeStatus.FAILED + return + end + + self.Node.ChildNode:OnUpdate(dt); + self.Node.Status = self.Node.ChildNode.Status +end \ No newline at end of file diff --git a/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharCheckRelationNode.lua b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharCheckRelationNode.lua new file mode 100644 index 00000000..2e98fd53 --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharCheckRelationNode.lua @@ -0,0 +1,8 @@ +local XHomeCharCheckRelationNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "HomeCharCheckRelation", CsBehaviorNodeType.Condition, true, false) +function XHomeCharCheckRelationNode:OnEnter() + if self.AgentProxy:CheckCharacterInteracter() then + self.Node.Status = CsNodeStatus.SUCCESS + else + self.Node.Status = CsNodeStatus.FAILED + end +end \ No newline at end of file diff --git a/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharCompletedFondleNode.lua b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharCompletedFondleNode.lua new file mode 100644 index 00000000..120cdf12 --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharCompletedFondleNode.lua @@ -0,0 +1,6 @@ +local XHomeCharCompletedFondleNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "HomeCharCompletedFondle", CsBehaviorNodeType.Action, true, false) + +function XHomeCharCompletedFondleNode:OnEnter() + self.AgentProxy:DequeueFondleType() + self.Node.Status = CsNodeStatus.SUCCESS +end diff --git a/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharDialogNode.lua b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharDialogNode.lua new file mode 100644 index 00000000..8063ee1a --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharDialogNode.lua @@ -0,0 +1,21 @@ +local XHomeCharDialogNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "HomeCharDialog", CsBehaviorNodeType.Action, true, false) + +function XHomeCharDialogNode:OnAwake() + if self.Fields == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + if self.Fields["DialogId"] == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + self.DialogId = self.Fields["DialogId"] +end + +function XHomeCharDialogNode:OnEnter() + self.AgentProxy:ShowBubble(self.DialogId, function() + self.Node.Status = CsNodeStatus.SUCCESS + end) +end diff --git a/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharDoEffectNode.lua b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharDoEffectNode.lua new file mode 100644 index 00000000..5cdb950f --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharDoEffectNode.lua @@ -0,0 +1,25 @@ +local XHomeCharDoEffectNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "HomeCharDoEffect",CsBehaviorNodeType.Action,true,false) + +function XHomeCharDoEffectNode:OnAwake() + if self.Fields == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + if self.Fields["EffectId"] == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + self.EffectId = self.Fields["EffectId"] +end + + +function XHomeCharDoEffectNode:OnEnter() + local bindWorldPos = self.Agent:GetVarDicByKey("BindWorldPos") + self.Agent:SetVarDicByKey("BindWorldPos", nil) + + self.AgentProxy:PlayEffect(self.EffectId, bindWorldPos) + self.Node.Status = CsNodeStatus.SUCCESS +end + diff --git a/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharDoRoleActionOnlyNode.lua b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharDoRoleActionOnlyNode.lua new file mode 100644 index 00000000..fce2e6cc --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharDoRoleActionOnlyNode.lua @@ -0,0 +1,22 @@ +local XHomeCharDoRoleActionOnlyNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "HomeCharDoRoleActionOnly", CsBehaviorNodeType.Action, true, false) + +function XHomeCharDoRoleActionOnlyNode:OnAwake() + if self.Fields == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + if self.Fields["ActionId"] == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + self.ActionId = self.Fields["ActionId"] + self.CrossDuration = self.Fields["CrossDuration"] + self.NeedFadeCross = self.Fields["NeedFadeCross"] +end + +function XHomeCharDoRoleActionOnlyNode:OnEnter() + self.AgentProxy:DoAction(self.ActionId, self.NeedFadeCross, self.CrossDuration) + self.Node.Status = CsNodeStatus.SUCCESS +end diff --git a/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharEventRewardNode.lua b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharEventRewardNode.lua new file mode 100644 index 00000000..3d4ea6dd --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharEventRewardNode.lua @@ -0,0 +1,6 @@ +local XHomeCharEventRewardNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "HomeCharEventReward", CsBehaviorNodeType.Action, true, false) + +function XHomeCharEventRewardNode:OnEnter() + self.AgentProxy:ShowEventReward() + self.Node.Status = CsNodeStatus.SUCCESS +end \ No newline at end of file diff --git a/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharEventTypeCompareNode.lua b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharEventTypeCompareNode.lua new file mode 100644 index 00000000..ca88c097 --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharEventTypeCompareNode.lua @@ -0,0 +1,26 @@ +local XHomeCharEventTypeCompareNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "HomeCharEventTypeCompare", CsBehaviorNodeType.Condition, true, false) + +function XHomeCharEventTypeCompareNode:OnAwake() + if self.Fields == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + if self.Fields["EventType"] == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + self.EventType = self.Fields["EventType"] +end + + +function XHomeCharEventTypeCompareNode:OnEnter() + local result = self.AgentProxy:CheckEventCompleted(self.EventType, function() + self.Node.Status = CsNodeStatus.SUCCESS + end) + + if not result then + self.Node.Status = CsNodeStatus.FAILED + end +end \ No newline at end of file diff --git a/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharFaceLockNode.lua b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharFaceLockNode.lua new file mode 100644 index 00000000..7df02878 --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharFaceLockNode.lua @@ -0,0 +1,22 @@ +local XHomeCharFaceLockNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "HomeCharFaceLock",CsBehaviorNodeType.Action,true,false) + +function XHomeCharFaceLockNode:OnAwake() + if self.Fields == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + if self.Fields["FaceId"] == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + self.FaceId = self.Fields["FaceId"] +end + + +function XHomeCharFaceLockNode:OnEnter() + self.AgentProxy:PlayFace(self.FaceId) + self.Node.Status = CsNodeStatus.SUCCESS +end + diff --git a/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharFondleTypeJudgeNode.lua b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharFondleTypeJudgeNode.lua new file mode 100644 index 00000000..b7fe95cf --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharFondleTypeJudgeNode.lua @@ -0,0 +1,29 @@ +local XHomeCharFondleTypeJudgeNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "HomeCharFondleTypeJudge", CsBehaviorNodeType.Decorator, true, true) + +function XHomeCharFondleTypeJudgeNode:OnAwake() + if self.Fields == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + if self.Fields["FondleType"] == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + self.FondleType = self.Fields["FondleType"] +end + +function XHomeCharFondleTypeJudgeNode:OnUpdate(dt) + local fondleType = self.AgentProxy:GetFondleType() + + if fondleType ~= self.FondleType then + self.Node.ChildNode:OnReset() + self.Node.Status = CsNodeStatus.FAILED + return + end + + --self.AgentProxy:DequeueFondleType() + self.Node.ChildNode:OnUpdate(dt); + self.Node.Status = self.Node.ChildNode.Status +end \ No newline at end of file diff --git a/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharForwardToFurnitureNode.lua b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharForwardToFurnitureNode.lua new file mode 100644 index 00000000..483a4bc6 --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharForwardToFurnitureNode.lua @@ -0,0 +1,21 @@ +local XHomeCharForwardToFurnitureNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "HomeCharForwardToFurniture", CsBehaviorNodeType.Action, true, false) + +function XHomeCharForwardToFurnitureNode:OnAwake() + if self.Fields == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + if self.Fields["Direction"] == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + self.Direction = self.Fields["Direction"] +end + +function XHomeCharForwardToFurnitureNode:OnEnter() + if self.AgentProxy:SetForwardToFurniture(self.Direction) then + self.Node.Status = CsNodeStatus.SUCCESS + end +end \ No newline at end of file diff --git a/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharHideBubbleNode.lua b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharHideBubbleNode.lua new file mode 100644 index 00000000..d5c7b983 --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharHideBubbleNode.lua @@ -0,0 +1,6 @@ +local XHomeCharHideBubbleNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "HomeCharHideBubble", CsBehaviorNodeType.Action, true, false) + +function XHomeCharHideBubbleNode:OnEnter() + self.AgentProxy:HideBubble() + self.Node.Status = CsNodeStatus.SUCCESS +end \ No newline at end of file diff --git a/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharHideEffectNode.lua b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharHideEffectNode.lua new file mode 100644 index 00000000..be41220e --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharHideEffectNode.lua @@ -0,0 +1,6 @@ +local XHomeCharHideEffectNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "HomeCharHideEffect", CsBehaviorNodeType.Action, true, false) + +function XHomeCharHideEffectNode:OnEnter() + self.AgentProxy:HideEffect() + self.Node.Status = CsNodeStatus.SUCCESS +end \ No newline at end of file diff --git a/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharInteractFunitureActionNode.lua b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharInteractFunitureActionNode.lua new file mode 100644 index 00000000..20df31fd --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharInteractFunitureActionNode.lua @@ -0,0 +1,9 @@ +local XHomeCharInteractFunitureActionNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "HomeCharInteractFunitureAction", CsBehaviorNodeType.Action, true, false) + +function XHomeCharInteractFunitureActionNode:OnEnter() + if self.AgentProxy:PlayInteractFurnitureAnimation() then + self.Node.Status = CsNodeStatus.SUCCESS + else + self.Node.Status = CsNodeStatus.FAILED + end +end \ No newline at end of file diff --git a/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharInteractNode.lua b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharInteractNode.lua new file mode 100644 index 00000000..4bd441b9 --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharInteractNode.lua @@ -0,0 +1,9 @@ +local XHomeCharInteractNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "HomeCharInteract", CsBehaviorNodeType.Action, true, false) + +function XHomeCharInteractNode:OnEnter() + if self.AgentProxy:InteractFurniture() then + self.Node.Status = CsNodeStatus.SUCCESS + else + self.Node.Status = CsNodeStatus.FAILED + end +end \ No newline at end of file diff --git a/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharInteractTypeCompareNode.lua b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharInteractTypeCompareNode.lua new file mode 100644 index 00000000..6cdd48dc --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharInteractTypeCompareNode.lua @@ -0,0 +1,25 @@ +local XHomeCharInteractTypeCompareNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "HomeCharInteractTypeCompare", CsBehaviorNodeType.Condition, true, false) + +function XHomeCharInteractTypeCompareNode:OnAwake() + if self.Fields == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + if self.Fields["TypeId"] == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + self.TypeId = self.Fields["TypeId"] +end + +function XHomeCharInteractTypeCompareNode:OnEnter() + local fondleType = self.AgentProxy:GetFondleType() + if fondleType == self.TypeId then + + self.Node.Status = CsNodeStatus.SUCCESS + else + self.Node.Status = CsNodeStatus.FAILED + end +end \ No newline at end of file diff --git a/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharJudgeAttributeNode.lua b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharJudgeAttributeNode.lua new file mode 100644 index 00000000..ae75d860 --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharJudgeAttributeNode.lua @@ -0,0 +1,59 @@ +local XHomeCharJudgeAttrIntNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "HomeCharJudgeAttrInt", CsBehaviorNodeType.Action, true, false) + +local CompareSymbol = { + Less = 1, --小于 < + Greater = 2, --/大于 > + LEqual = 3, --小于等于 <= + GEqual = 4, --大于等于 >= + Equal = 5, --大于等于 == + NotEqual = 6, --不等于 != +} + + +function XHomeCharJudgeAttrIntNode:OnAwake() + if self.Fields == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + if self.Fields["AttributeKey"] == nil or self.Fields["CompareSymbol"] == nil or self.Fields["CompareValue"] == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + self.AttributeKey = self.Fields["AttributeKey"] + self.CompareSymbol = self.Fields["CompareSymbol"] + self.AttributeValue = self.Fields["CompareValue"] + +end + +function XHomeCharJudgeAttrIntNode:OnStart() + self.Attribute = self.AgentProxy:GetAtrributeValue(self.AttributeKey) + +end + +function XHomeCharJudgeAttrIntNode:OnEnter() + + local result = false + if self.CompareSymbol == CompareSymbol.Less then + result = self.Attribute < self.AttributeValue + elseif self.CompareSymbol == CompareSymbol.Equal then + result = self.Attribute == self.AttributeValue + elseif self.CompareSymbol == CompareSymbol.NotEqual then + result = self.Attribute ~= self.AttributeValue + elseif self.CompareSymbol == CompareSymbol.GEqual then + result = self.Attribute >= self.AttributeValue + elseif self.CompareSymbol == CompareSymbol.LEqual then + result = self.Attribute <= self.AttributeValue + elseif self.CompareSymbol == CompareSymbol.Greater then + result = self.Attribute >= self.AttributeValue + end + + + if result then + self.Node.Status = CsNodeStatus.SUCCESS + else + self.Node.Status = CsNodeStatus.FAILED + end + +end \ No newline at end of file diff --git a/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharJudgeInteractPosNode.lua b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharJudgeInteractPosNode.lua new file mode 100644 index 00000000..a5879e11 --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharJudgeInteractPosNode.lua @@ -0,0 +1,26 @@ +local XHomeCharJudgeInteractPosNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "HomeCharJudgeInteractPos",CsBehaviorNodeType.Action,true,false) + + +function XHomeCharJudgeInteractPosNode:OnAwake() + if self.Fields == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + if self.Fields["PositionIndex"] == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + self.PositionIndex = self.Fields["PositionIndex"] +end + +function XHomeCharJudgeInteractPosNode:OnEnter() + local result = self.AgentProxy:CheckCharInteractPosByIndex(self.PositionIndex) + if result then + self.Node.Status = CsNodeStatus.SUCCESS + else + self.Node.Status = CsNodeStatus.FAILED + end +end + diff --git a/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharObstacleEnableNode.lua b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharObstacleEnableNode.lua new file mode 100644 index 00000000..07258dc6 --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharObstacleEnableNode.lua @@ -0,0 +1,22 @@ +local XHomeCharObstacleEnableNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "HomeCharObstacleEnable",CsBehaviorNodeType.Action,true,false) + + +function XHomeCharObstacleEnableNode:OnAwake() + if self.Fields == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + if self.Fields["ObstackeEnable"] == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + self.ObstackeEnable = self.Fields["ObstackeEnable"] +end + +function XHomeCharObstacleEnableNode:OnEnter() + self.AgentProxy:SetObstackeEnable(self.ObstackeEnable) + self.Node.Status = CsNodeStatus.SUCCESS +end + diff --git a/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharPathFindNode.lua b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharPathFindNode.lua new file mode 100644 index 00000000..ebe1d485 --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharPathFindNode.lua @@ -0,0 +1,25 @@ +local XHomeCharPathFindNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "HomeCharPathFind", CsBehaviorNodeType.Action, true, false) + + +function XHomeCharPathFindNode:OnAwake() + if self.Fields == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + if self.Fields["MinDistance"] == nil or self.Fields["MaxDistance"] == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + self.MinDistance = self.Fields["MinDistance"] + self.MaxDistance = self.Fields["MaxDistance"] +end + +function XHomeCharPathFindNode:OnEnter() + if self.AgentProxy:DoPathFind(self.MinDistance, self.MaxDistance) then + self.Node.Status = CsNodeStatus.SUCCESS + else + self.Node.Status = CsNodeStatus.FAILED + end +end diff --git a/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharRandomDialogNode.lua b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharRandomDialogNode.lua new file mode 100644 index 00000000..88f41d0f --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharRandomDialogNode.lua @@ -0,0 +1,7 @@ +local XHomeCharRandomDialogNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "HomeCharRandomDialog", CsBehaviorNodeType.Action, true, false) +function XHomeCharRandomDialogNode:OnEnter() + self.AgentProxy:ShowRandomBubble(function() + self.Node.Status = CsNodeStatus.SUCCESS + end) +end + diff --git a/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharReachFurniture.lua b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharReachFurniture.lua new file mode 100644 index 00000000..eb6027de --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharReachFurniture.lua @@ -0,0 +1,6 @@ +local XHomeCharReachFurniture = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "HomeCharReachFurniture", CsBehaviorNodeType.Action, true, false) +function XHomeCharReachFurniture:OnEnter() + self.Node.Status = CsNodeStatus.SUCCESS + self.AgentProxy:ReachFurniture() +end + diff --git a/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharSetCharInteractTriggerNode.lua b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharSetCharInteractTriggerNode.lua new file mode 100644 index 00000000..43b89069 --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharSetCharInteractTriggerNode.lua @@ -0,0 +1,20 @@ +local XHomeCharSetCharInteractTriggerNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "HomeCharSetCharInteractTrigger", CsBehaviorNodeType.Action, true, false) + +function XHomeCharSetCharInteractTriggerNode:OnAwake() + if self.Fields == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + if self.Fields["Trigger"] == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + self.Trigger = self.Fields["Trigger"] +end + +function XHomeCharSetCharInteractTriggerNode:OnEnter() + self.Node.Status = CsNodeStatus.SUCCESS + self.AgentProxy:SetCharInteractTrigger(self.Trigger) +end diff --git a/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharSetInteractOffsetNode.lua b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharSetInteractOffsetNode.lua new file mode 100644 index 00000000..7f705623 --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharSetInteractOffsetNode.lua @@ -0,0 +1,6 @@ +local XHomeCharSetInteractOffsetNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "HomeCharSetInteractOffset", CsBehaviorNodeType.Action, true, false) +function XHomeCharSetInteractOffsetNode:OnEnter() + if self.AgentProxy:SetInteraterPosOffest() then + self.Node.Status = CsNodeStatus.SUCCESS + end +end \ No newline at end of file diff --git a/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharSetStayOffsetNode.lua b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharSetStayOffsetNode.lua new file mode 100644 index 00000000..055f3b06 --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharSetStayOffsetNode.lua @@ -0,0 +1,7 @@ +local XHomeCharSetStayOffsetNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "HomeCharSetStayOffest", CsBehaviorNodeType.Action, true, false) +function XHomeCharSetStayOffsetNode:OnEnter() + if self.AgentProxy:SetStayOffset() then + self.Node.Status = CsNodeStatus.SUCCESS + end +end + diff --git a/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharStateChangeNode.lua b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharStateChangeNode.lua new file mode 100644 index 00000000..6b3b8ae9 --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharStateChangeNode.lua @@ -0,0 +1,22 @@ +local XHomeCharStateChangeNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "HomeCharStateChange",CsBehaviorNodeType.Action,true,false) + +function XHomeCharStateChangeNode:OnAwake() + if self.Fields == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + if self.Fields["State"] == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + self.State = self.Fields["State"] +end + + +function XHomeCharStateChangeNode:OnEnter() + self.AgentProxy:ChangeStatus(self.State) + self.Node.Status = CsNodeStatus.SUCCESS +end + diff --git a/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharStateCompareNode.lua b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharStateCompareNode.lua new file mode 100644 index 00000000..6d41d35d --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeCharNode/XHomeCharStateCompareNode.lua @@ -0,0 +1,26 @@ +local XHomeCharStateCompareNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "HomeCharStateCompare",CsBehaviorNodeType.Action,true,false) + +function XHomeCharStateCompareNode:OnAwake() + if self.Fields == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + if self.Fields["State"] == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + self.State = self.Fields["State"] +end + + +function XHomeCharStateCompareNode:OnEnter() + local result = self.AgentProxy:GetState() + if result then + self.Node.Status = CsNodeStatus.SUCCESS + else + self.Node.Status = CsNodeStatus.FAILED + end +end + diff --git a/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeFSM/XHomeCharFSM.lua b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeFSM/XHomeCharFSM.lua new file mode 100644 index 00000000..58b45e44 --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeFSM/XHomeCharFSM.lua @@ -0,0 +1,29 @@ + +XHomeCharFSM = XClass(nil, "XHomeCharFSM") + +function XHomeCharFSM:Ctor(agent) + self.Agent = agent +end + +function XHomeCharFSM:Enter() + self:OnEnter() +end + +function XHomeCharFSM:OnEnter() + +end + +function XHomeCharFSM:Execute() + +end + + +function XHomeCharFSM:Exit() + self:OnExit() +end + +function XHomeCharFSM:OnExit() + +end + + diff --git a/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeFSM/XHomeCharFSMControl.lua b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeFSM/XHomeCharFSMControl.lua new file mode 100644 index 00000000..b1cba60d --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeFSM/XHomeCharFSMControl.lua @@ -0,0 +1,13 @@ +local XHomeCharFSMControl = XHomeCharFSMFactory.RegisterFSM("XHomeCharFSMControl", XHomeCharFSMType.CONTROL) + +function XHomeCharFSMControl:OnEnter() + +end + +function XHomeCharFSMControl:Execute() + --ToDo +end + +function XHomeCharFSMControl:OnExit() + +end \ No newline at end of file diff --git a/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeFSM/XHomeCharFSMEmpty.lua b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeFSM/XHomeCharFSMEmpty.lua new file mode 100644 index 00000000..0afdfc21 --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeFSM/XHomeCharFSMEmpty.lua @@ -0,0 +1,15 @@ +local XHomeCharFSMEmpty = XHomeCharFSMFactory.RegisterFSM("XHomeCharFSMEmpty",XHomeCharFSMType.EMPTY) + +function XHomeCharFSMEmpty:OnEnter() + +end + +function XHomeCharFSMEmpty:Execute() + --ToDo +end + +function XHomeCharFSMEmpty:OnExit() + +end + +return XHomeCharFSMEmpty \ No newline at end of file diff --git a/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeFSM/XHomeCharFSMIdle.lua b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeFSM/XHomeCharFSMIdle.lua new file mode 100644 index 00000000..284f3cd7 --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeFSM/XHomeCharFSMIdle.lua @@ -0,0 +1,15 @@ +local XHomeCharFSMIdle = XHomeCharFSMFactory.RegisterFSM("XHomeCharFSMIdle", XHomeCharFSMType.IDLE) + +function XHomeCharFSMIdle:OnEnter() + +end + +function XHomeCharFSMIdle:Execute() + +end + +function XHomeCharFSMIdle:OnExit() + +end + +return XHomeCharFSMIdle \ No newline at end of file diff --git a/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeFSM/XHomeCharFSMInteract.lua b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeFSM/XHomeCharFSMInteract.lua new file mode 100644 index 00000000..b2e5b72e --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeFSM/XHomeCharFSMInteract.lua @@ -0,0 +1,21 @@ +local XHomeCharFSMInteract = XHomeCharFSMFactory.RegisterFSM("XHomeCharFSMInteract",XHomeCharFSMType.INTERACT) + +function XHomeCharFSMInteract:OnEnter() + +end + +function XHomeCharFSMInteract:Execute() + --ToDo +end + +function XHomeCharFSMInteract:OnExit() + + --如果有家具交互 + if self.Agent.Furniture then + self.Agent:DisInteractFurniture() + end + + self.Agent.NavMeshAgent.IsObstacle = true +end + +return XHomeCharFSMInteract \ No newline at end of file diff --git a/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeFSM/XHomeCharFSMMood.lua b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeFSM/XHomeCharFSMMood.lua new file mode 100644 index 00000000..bd1b8be3 --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeChar/XHomeFSM/XHomeCharFSMMood.lua @@ -0,0 +1,15 @@ +local XHomeCharFSMMood = XHomeCharFSMFactory.RegisterFSM("XHomeCharFSMMood",XHomeCharFSMType.MOOD) + +function XHomeCharFSMMood:OnEnter() + +end + +function XHomeCharFSMMood:Execute() + --ToDo +end + +function XHomeCharFSMMood:OnExit() + +end + +return XHomeCharFSMMood \ No newline at end of file diff --git a/Resources/Scripts/XHome/XDorm/XHomeCharManager.lua b/Resources/Scripts/XHome/XDorm/XHomeCharManager.lua new file mode 100644 index 00000000..4c3cf05a --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeCharManager.lua @@ -0,0 +1,432 @@ +XHomeCharManager = XHomeCharManager or {} + +local XHomeCharObj = require("XHome/XDorm/XHomeCharObj") + +local ActiveCharacter = {} +local CurrentSelected = {} + +local EventRewards = {} + +local FURNITURE_INTERACT_CD = CS.XGame.ClientConfig:GetInt("DormFurnitureInteractCD") +local FURNITURE_INTERACT_DISTANCE = CS.XGame.ClientConfig:GetInt("DormFurnitureInteractDistance") + +local CHARACTER_INTERACT_CD = CS.XGame.ClientConfig:GetInt("DormCharacterInteractCD") + +local FurnitureLastInteractTime = {} +local CharacterLastInteractTime = {} + +--初始化 +function XHomeCharManager.Init() + XEventManager.AddEventListener(XEventId.EVENT_CHARACTER_ADD_EVENT_NOTIFY, function(...) + XHomeCharManager.OnEvent(XEventId.EVENT_CHARACTER_ADD_EVENT_NOTIFY, ...) + end) + + --爱抚 + XEventManager.AddEventListener(XEventId.EVENT_DORM_TOUCH_ENTER, function(...) + XHomeCharManager.OnEvent(XEventId.EVENT_DORM_TOUCH_ENTER, ...) + end) + + --进入爱抚 + XEventManager.AddEventListener(XEventId.EVENT_DORM_TOUCH_SHOW, XHomeCharManager.OnFondle) + --爱抚结束 + XEventManager.AddEventListener(XEventId.EVENT_DORM_TOUCH_HIDE, XHomeCharManager.OnFondleEnd) + + CsXGameEventManager.Instance:RegisterEvent(XEventId.EVENT_HOME_CHARACTER_STATUS_CHANGE, function() + + end) + + XEventManager.AddEventListener(XEventId.EVENT_USER_LOGOUT, XHomeCharManager.HandleSignOut) + +end + +--事件 +function XHomeCharManager.OnEvent(evt, ...) + + if CurrentSelected == nil then + return + end + + if evt == XEventId.EVENT_DORM_TOUCH_ENTER then + XHomeCharManager.HideAllCharacterBut(CurrentSelected.Id) + CurrentSelected:ChangeStatus(XHomeBehaviorStatus.FONDLE) + elseif evt == XEventId.EVENT_CHARACTER_ADD_EVENT_NOTIFY then + local charId = ... + local charObj = XHomeCharManager.GetActiveCharacter(charId) + if not charObj or not charObj.IsSelf then + return + end + + local event = XHomeCharManager.GetCharacterEvent(charId, true) + if event == nil then + XLog.Error("找不到事件", charId) + return + end + local temp = XDormConfig.GetCharacterEventById(event.EventId) + charObj:OnEventChange(temp) + end +end + + +function XHomeCharManager.HandleSignOut() + ActiveCharacter = {} + CurrentSelected = {} + + EventRewards = {} +end + +--爱抚结束 +function XHomeCharManager.OnFondleEnd() + XHomeCharManager.ShowAllCharacter() + if CurrentSelected then + CurrentSelected:SetFondleType(-1) + CurrentSelected:UnSelected() + CurrentSelected = nil + end +end + +--爱抚中 +function XHomeCharManager.OnFondle(fondleType, charId) + if CurrentSelected == nil or CurrentSelected.Id ~= charId then + return + end + + CurrentSelected:SetFondleType(fondleType) + XHomeCharManager.HideAllCharacterBut(CurrentSelected.Id) +end + + +--监听角色改变状态 +function XHomeCharManager.OnHomeCharChangeStatus() + +end + +--设置当前选中角色 +function XHomeCharManager.SetSelectCharacter(homeChar) + CurrentSelected = homeChar +end + +--获取当前选中角色 +function XHomeCharManager.GetSelectCharacter() + return CurrentSelected +end + +--预加载构造体 +function XHomeCharManager.PreLoadHomeCharacterById() + -- XHomeCharManager.CreateHomeCharacter(charId) +end + +--创建构造体 +function XHomeCharManager.CreateHomeCharacter(charId, root) + local charStyleConfig = XDormConfig.GetCharacterStyleConfigById(charId) + + local homeChar = XHomeCharObj.New() + homeChar:LoadModel(charStyleConfig.Model, root) + homeChar.GameObject:SetActive(false) + return homeChar +end + +--从池里面获取构造体模型 +function XHomeCharManager.SpawnHomeCharacter(charId, root) + local charObj = XHomeCharManager.CreateHomeCharacter(charId, root) + ActiveCharacter[charId] = charObj + + return charObj +end + +--回池 +function XHomeCharManager.DespawnHomeCharacter(charId, charObj) + if ActiveCharacter[charId] then + ActiveCharacter[charId]:Dispose() + end + charObj:Dispose() + ActiveCharacter[charId] = nil +end + +--获取活跃中的角色 +function XHomeCharManager.GetActiveCharacter(charId) + if not ActiveCharacter[charId] then + XLog.Warning("ActiveCharacter not exist ", charId) + return + end + + return ActiveCharacter[charId] +end + +--获取事件 +function XHomeCharManager.GetCharacterEvent(charId, isSelf) + local charData + if isSelf then + charData = XDataCenter.DormManager.GetCharacterDataByCharId(charId) + else + charData = XDataCenter.DormManager.GetTargetCharacterDataByCharId(charId) + end + + if not charData or not charData.EventList or #charData.EventList <= 0 then + return + end + + local curTime = XTime.GetServerNowTimestamp() + local EventTemp + for _, v in ipairs(charData.EventList) do + if not v.EndTime or v.EndTime > curTime or v.EndTime <= 0 then + local eventId = v.EventId + local temp = XDormConfig.GetCharacterEventById(eventId) + if not EventTemp or temp.Weight > EventTemp.Weight then + if temp and temp.BehaviorId then + EventTemp = temp + end + end + end + end + + return EventTemp +end + +---检测事件是否存在 +function XHomeCharManager.CheckCharacterEventExist(charId, eventId, isSelf) + local charData + + if isSelf then + charData = XDataCenter.DormManager.GetCharacterDataByCharId(charId) + else + charData = XDataCenter.DormManager.GetTargetCharacterDataByCharId(charId) + end + + if not charData.EventList or #charData.EventList <= 0 then + return false + end + + local curTime = XTime.GetServerNowTimestamp() + + for _, v in ipairs(charData.EventList) do + if not v.EndTime or v.EndTime > curTime or v.EndTime <= 0 then + if v.EventId == eventId then + return true + end + end + end + + return false +end + +---检测事件是否能完成 +function XHomeCharManager.CheckCharacterEventCompleted(charId, completeType, isSelf) + local charData + + if isSelf then + charData = XDataCenter.DormManager.GetCharacterDataByCharId(charId) + else + charData = XDataCenter.DormManager.GetTargetCharacterDataByCharId(charId) + end + + if not charData.EventList or #charData.EventList <= 0 then + return + end + local curTime = XTime.GetServerNowTimestamp() + local EventTemp + + for _, v in ipairs(charData.EventList) do + if not v.EndTime or v.EndTime > curTime or v.EndTime <= 0 then + local eventId = v.EventId + local temp = XDormConfig.GetCharacterEventById(eventId, true) + local completeTypes = temp.CompletedType + for _, var in ipairs(completeTypes) do + if var == completeType then + EventTemp = temp + break + end + end + end + end + + return EventTemp +end + + + +--检测人物交互 +function XHomeCharManager.CheckCharacterInteracter(charId) + local charObj = XHomeCharManager.GetActiveCharacter(charId) + if not charObj then + return false + end + + if XTool.UObjIsNil(charObj.GameObject) then + return false + end + + if XTool.UObjIsNil(charObj.Transform) then + return false + end + + local time = XTime.GetServerNowTimestamp() + local lastTime = CharacterLastInteractTime[charId] + if lastTime and lastTime + CHARACTER_INTERACT_CD > time then + return + end + + for _, v in pairs(ActiveCharacter) do + if v and not XTool.UObjIsNil(v.GameObject) and not XTool.UObjIsNil(v.Transform) and v.Id ~= charId and v.CharInteractTrigger then + local distance = CS.UnityEngine.Vector3.Distance(charObj.Transform.position, v.Transform.position) + + lastTime = CharacterLastInteractTime[v.Id] + local bInteract = lastTime and lastTime + CHARACTER_INTERACT_CD > time + if not bInteract then + local result, temp, state1, state2 = XDormConfig.GetCharacterInteractiveIndex(v.Id, charObj.Id) + if result then + local minDis = XHomeDormManager.GetCeilSize() * temp.MinDis + local maxDis = XHomeDormManager.GetCeilSize() * temp.MaxDis + if distance > minDis and distance < maxDis then + charObj.InteractiveCharacter = v + v.InteractiveCharacter = charObj + + charObj:InteractWith(v) + v:InteractWith(charObj) + + charObj:ChangeStatus(state1) + v:ChangeStatus(state2) + + CharacterLastInteractTime[charObj.Id] = time + CharacterLastInteractTime[v.Id] = time + + return true + end + end + end + end + end + + return false +end + + +--检测家具交互 +function XHomeCharManager.CheckFurnitureInteract(charId) + local charObj = XHomeCharManager.GetActiveCharacter(charId) + if not charObj then + return false + end + + local time = XTime.GetServerNowTimestamp() + local lastTime = FurnitureLastInteractTime[charId] + if lastTime and lastTime + FURNITURE_INTERACT_CD > time then + return + end + + local interactFurniture = nil + local interactPos = nil + local lastDistance = 0 + + local interactList = charObj.Room.InteractList + for _, v in ipairs(interactList) do + if v.Furniture:CheckCanInteract(v.GridPos.x, v.GridPos.y, charId) then + local pos = XHomeDormManager.GetLocalPosByGrid(v.GridPos.x, v.GridPos.y, CS.XHomePlatType.Ground, 0) + pos = charObj.Room.Transform.localToWorldMatrix:MultiplyPoint(pos) + local distance = CS.UnityEngine.Vector3.Distance(charObj.Transform.position, pos) + + local tempInteracPos = v.InteractPosGo.transform.position + + if distance < XHomeDormManager.GetCeilSize() * FURNITURE_INTERACT_DISTANCE and (lastDistance <= 0 or distance < lastDistance) and CS.XNavMeshUtility.CheckCanReachNavMeshSamplePosition(tempInteracPos, CS.XHomeMapManager.Inst.CeilSize * 0.5) then + interactFurniture = v + lastDistance = distance + interactPos = v.InteractPosGo.transform.position + end + end + end + + if interactFurniture then + return true, interactPos, interactFurniture + end + + return false +end + +--显示奖励 +function XHomeCharManager.ShowEventReward(charId) + if not EventRewards or not EventRewards[charId] then + return + end + + local rewards = EventRewards[charId] + XUiManager.OpenUiObtain(rewards) + EventRewards[charId] = nil +end + + +--设置奖励 +function XHomeCharManager.SetEventReward(charId, rewards) + EventRewards[charId] = rewards +end + +--隐藏所有 +function XHomeCharManager.HideAllCharacter() + if not ActiveCharacter then + return + end + + for _, v in pairs(ActiveCharacter) do + if not XTool.UObjIsNil(v.GameObject) then + v.GameObject:SetActive(false) + v:OnHide() + end + end +end + + +--隐藏所有 +function XHomeCharManager.ShowAllCharacter(isResetPosition) + if not ActiveCharacter then + return + end + + for _, v in pairs(ActiveCharacter) do + if not XTool.UObjIsNil(v.GameObject) then + v.GameObject:SetActive(true) + v:OnShow(isResetPosition) + end + end +end + + +--隐藏所有除了 +function XHomeCharManager.HideAllCharacterBut(charId) + if not ActiveCharacter then + return + end + + for i, v in pairs(ActiveCharacter) do + if not XTool.UObjIsNil(v.GameObject) and i ~= charId then + v.GameObject:SetActive(false) + v:OnHide() + + end + end +end + + +--显示 +function XHomeCharManager.ShowCharacter(charId) + if not ActiveCharacter then + return + end + + local character = ActiveCharacter[charId] + if character and not XTool.UObjIsNil(character.GameObject) then + character.GameObject:SetActive(true) + character:OnShow() + end +end + +--设置上次家具交互时间 +function XHomeCharManager.SetFurnitureInteractTime(charId) + local time = XTime.GetServerNowTimestamp() + FurnitureLastInteractTime[charId] = time +end + + +--设置上任务交互时间 +function XHomeCharManager.SetCharacterInteractTime(charId1, charId2) + local time = XTime.GetServerNowTimestamp() + CharacterLastInteractTime[charId1] = time + CharacterLastInteractTime[charId2] = time +end \ No newline at end of file diff --git a/Resources/Scripts/XHome/XDorm/XHomeCharObj.lua b/Resources/Scripts/XHome/XDorm/XHomeCharObj.lua new file mode 100644 index 00000000..0a477bc0 --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeCharObj.lua @@ -0,0 +1,897 @@ +--- 角色对象 +local XSceneObject = require("XHome/XSceneObject") + +local XHomeCharObj = XClass(XSceneObject, "XHomeCharObj") + +--设置数据 +function XHomeCharObj:SetData(data, isSelf) + self.CharData = data + self.IsSelf = isSelf + self.Id = data.CharacterId + self.CeilSize = XHomeDormManager.GetCeilSize() + +end + +--进入房间设置出生点 +function XHomeCharObj:Born(map, room) + self.Map = map + self.Room = room + + self:ReSetPosition() + self.Agent:SetVarDicByKey("DormitoryId", self.CharData.DormitoryId) + + self.NavMeshAgent.IsObstacle = true + self:ChangeStatus(XHomeBehaviorStatus.IDLE) + + self:ChangeStateMachine(XHomeCharFSMType.IDLE) + + self.GameObject:SetActive(true) + self.Visible = true +end + +--事件改变 +function XHomeCharObj:OnEventChange(event) + if XHomeBehaviorStatus.IDLE ~= self.Status then + return + end + + self:ChangeStatus(event.BehaviorId) +end + +--退出房间 +function XHomeCharObj:ExitRoom() + self:DisInteractFurniture() + self:DisPreInteractFurniture() + XHomeCharManager.DespawnHomeCharacter(self.Id, self) +end + +function XHomeCharObj:Recycle() + XHomeCharManager.DespawnHomeCharacter(self.CharData.CharacterId, self) +end + +--加载完成 +function XHomeCharObj:OnLoadComplete() + --行为代理 + self.Agent = self.GameObject:GetComponent(typeof(CS.BehaviorTree.XAgent)) + if XTool.UObjIsNil(self.Agent) then + self.Agent = self.GameObject:AddComponent(typeof(CS.BehaviorTree.XAgent)) + self.Agent.ProxyType = "HomeCharacter" + self.Agent:InitProxy() + end + + self.Agent.Proxy.LuaAgentProxy:SetHomeCharObj(self) + + + self.Animator = self.GameObject:GetComponent(typeof(CS.UnityEngine.Animator)) + self.DormPutOnAnimaTime = CS.XGame.ClientConfig:GetFloat("DormPutOnAnimaTime") + self.IsPressing = false + self.FondleType = 0 + + --寻路组件 + -- self.NavMeshAgent = CS.XNavMeshUtility.AddNavMeshAgent(self.GameObject) + -- self.NavMeshAgent.radius = 0.35 + self.NavMeshAgent = CS.XNavMeshUtility.AddMoveAgent(self.GameObject) + self.NavMeshAgent.Radius = 0.35 + self.NavMeshAgent.IsObstacle = true + self.GoInputHandler = self.GameObject:GetComponent(typeof(CS.XGoInputHandler)) + if XTool.UObjIsNil(self.GoInputHandler) then + self.GoInputHandler = self.GameObject:AddComponent(typeof(CS.XGoInputHandler)) + end + + --层级 + self.GameObject:SetLayerRecursively(CS.UnityEngine.LayerMask.NameToLayer(HomeSceneLayerMask.HomeCharacter)) + --阴影 + CS.XMaterialContainerHelper.ProcessCharacterShadowVolume(self.GameObject) + + if not XTool.UObjIsNil(self.GoInputHandler) then + self.GoInputHandler:AddPointerClickListener(function(eventData) self:OnClick(eventData) end) + self.GoInputHandler:AddDragListener(function(eventData) self:OnDrag(eventData) end) + self.GoInputHandler:AddPointerDownListener(function(eventData) self:OnPointerDown(eventData) end) + self.GoInputHandler:AddPressListener(function(pressTime) self:OnPress(pressTime) end) + self.GoInputHandler:AddPointerUpListener(function(eventData) self:OnPointerUp(eventData) end) + self.GoInputHandler:AddPointerExitListener(function(eventData) self:OnPointerExit(eventData) end) + end +end + +----------------------------------------------------------- +--获取属性 +function XHomeCharObj:GetAtrributeValue(attributeKey) + return self.CharData[attributeKey] +end + +--播放动作 +function XHomeCharObj:DoAction(actionId, needFadeCross, crossDuration) + + if (needFadeCross) then + self.Animator:CrossFade(actionId, crossDuration, -1, 0) + else + self.Animator:Play(actionId, -1, 0) + end +end + +--显示气泡 +function XHomeCharObj:ShowBubble(id, callBack) + XEventManager.DispatchEvent(XEventId.EVENT_CHARACTER_SHOW_DIALOBOX, self.Id, id, self.Transform, function() + if callBack then + callBack() + end + end) +end + +--显示气泡 +function XHomeCharObj:ShowRandomBubble(callBack) + local config = XDormConfig.GetCharacterDialog(self.CharData, self.Status) + + if not config then + if callBack then + callBack() + end + + return + end + + XEventManager.DispatchEvent(XEventId.EVENT_CHARACTER_SHOW_DIALOBOX, self.Id, config.Id, self.Transform, function() + if callBack then + callBack() + end + end) +end + +--隐藏气泡 +function XHomeCharObj:HideBubble() + XEventManager.DispatchEvent(XEventId.EVENT_CHARACTER_HIDE_DIALOBOX, self.Id) +end + +--随机寻路 +function XHomeCharObj:DoPathFind(minDistance, maxDistance) + local findPath = false + local x = self.Pos.x + local y = self.Pos.y + local distance + + self.Pos = XHomeDormManager.WorldPosToGroundGridPos(self.Transform.position, self.Room.Transform) + local findCount = 0 + while (not findPath) do + math.randomseed(os.time()) + distance = math.random(minDistance, maxDistance) + local vec = CS.UnityEngine.Random.insideUnitCircle + x = math.floor(0.5 + distance * vec.x + self.Pos.x) + y = math.floor(0.5 + distance * vec.y + self.Pos.y) + + if x > 1 and x < CS.XHomeMapManager.Inst.MapSize.x - 2 and y > 1 and y < CS.XHomeMapManager.Inst.MapSize.y - 2 then + local gridInfo = self.Map:GetGridInfo(x, y) + --local gridMask = CS.XRoomMapInfo.GetMapGridMask(gridInfo, CS.XRoomBlockType.Blocked, CS.XRoomBlockType.Furniture, CS.XRoomBlockType.Interaction) + if gridInfo <= 0 then + findPath = true + end + end + findCount = findCount + 1 + if findCount >= 10000 then return self.Agent:SetVarDicByKey("Destination", XHomeDormManager.GetLocalPosByGrid(self.Pos.x, self.Pos.y, CS.XHomePlatType.Ground, 0)) end + end + + self.Pos.x = x + self.Pos.y = y + + local pos = XHomeDormManager.GetLocalPosByGrid(x, y, CS.XHomePlatType.Ground, 0) + pos = self.Room.Transform.localToWorldMatrix:MultiplyPoint(pos) + self.Agent:SetVarDicByKey("Destination", pos) +end + + +--改变状态机 +function XHomeCharObj:ChangeStateMachine(stateM) + if self.StateMachine and self.StateMachine.name == stateM then + return + end + + if self.StateMachine then + self.StateMachine:Exit() + end + + self.StateMachine = XHomeCharFSMFactory.New(stateM, self) + self.StateMachine:Enter() + + self.StateMachine:Execute() +end + + +--改变状态 +function XHomeCharObj:ChangeStatus(state) + if self.Status == state and self.Status ~= XHomeBehaviorStatus.IDLE then + return + end + + self.FondleTypeList = {} + + --隐藏特效 + self:HideEffect() + --隐藏气泡 + self:HideBubble() + + --检测事件 + local event = XHomeCharManager.GetCharacterEvent(self.CharData.CharacterId, self.IsSelf) + if event and XHomeBehaviorStatus.IDLE == state then + state = event.BehaviorId + end + + self.Status = state + local temp = XDormConfig.GetCharacterBehavior(self.Id, state) + if not temp then + XLog.Error("获取角色行为树失败,角色id=".. tostring(self.Id) .. ", state=" .. tostring(state)) + return + end + local behaviorTreeId = temp.BehaviorId + self.CanClick = temp.CanClick == 1 + --切换状态机 + self:ChangeStateMachine(temp.StateMachine) + + XLuaBehaviorManager.PlayId(behaviorTreeId, self.Agent) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_HOME_CHARACTER_STATUS_CHANGE, self.Id) +end + +--播放特效 +function XHomeCharObj:PlayEffect(effectId, bindWorldPos) + XEventManager.DispatchEvent(XEventId.EVENT_CHARACTER_SHOW_3DIOBJ, self.Id, effectId, self.Transform, bindWorldPos) +end + +--隐藏特效 +function XHomeCharObj:HideEffect() + XEventManager.DispatchEvent(XEventId.EVENT_CHARACTER_HIDE_3DIOBJ, self.Id) +end + +--设置是否阻挡 +function XHomeCharObj:SetObstackeEnable(obstackeEnable) + self.NavMeshAgent.IsObstacle = obstackeEnable +end + + +--播放事件奖励 +function XHomeCharObj:ShowEventReward() + XHomeCharManager.ShowEventReward(self.Id) +end + +--获取状态 +function XHomeCharObj:GetState() + return self.Status +end + +--检测附近的人物交互 +function XHomeCharObj:CheckCharacterInteracter() + local result = XHomeCharManager.CheckCharacterInteracter(self.Id) + return result +end + +--检测附近的家具交互点 +function XHomeCharObj:CheckFurnitureInteract() + local result, dest, interact = XHomeCharManager.CheckFurnitureInteract(self.Id) + if result then + self.Agent:SetVarDicByKey("Destination", dest) + self.Furniture = interact.Furniture + self.InteractInfo = interact + + for _, v in ipairs(self.Furniture.InteractInfoList) do + if v.GridPos.x == self.InteractInfo.GridPos.x and v.GridPos.y == self.InteractInfo.GridPos.y then + local haveBehavior = false + local relation = XDormConfig.GetDormF2CBehaviorRelative(self.Furniture.Cfg.Id, self.Id, v.PosIndex) + if relation then + haveBehavior = true + else + local state = XDormConfig.GetCharacterBehavior(self.Id, v.AttractBehaviorType) + haveBehavior = state ~= nil + end + if haveBehavior then + local state = self:GetInteractInfoAttractBehavior(v) + v.UsedType = v.UsedType | XFurnitureInteractUsedType.Character + v.CharacterId = self.Id + self:ChangeStatus(state) + end + break + end + end + end + + return result +end + +--检测任务完成 +function XHomeCharObj:CheckEventCompleted(completeType, callBack) + local temp = XHomeCharManager.CheckCharacterEventCompleted(self.Id, completeType, self.IsSelf) + if not temp then + return false + end + + XDataCenter.DormManager.RequestDormitoryCharacterOperate(self.Id, self.CharData.DormitoryId, temp.EventId, 1, callBack) + return true +end + + +--检测任务存在 +function XHomeCharObj:CheckEventExist(eventId) + return XHomeCharManager.CheckCharacterEventExist(self.Id, eventId, self.IsSelf) +end + +--检测是否正在播放指定动画 +function XHomeCharObj:CheckIsPlayingAnimation(animationName) + if not animationName or #animationName <= 0 then + return false + end + + local curStateInfo = self.Animator:GetCurrentAnimatorStateInfo(0) + local nextStateInfo = self.Animator:GetNextAnimatorStateInfo(0) + + for _, v in ipairs(animationName) do + local newHash = CS.UnityEngine.Animator.StringToHash(v) + + if (curStateInfo.shortNameHash == newHash or nextStateInfo.shortNameHash == newHash) then + return true + end + end + + return false +end + +--侧身摄像机 +function XHomeCharObj:SidewaysSceneCamera() + local currentCamera = XHomeSceneManager.GetSceneCamera() + local direction = currentCamera.transform.position - self.Transform.position + local Direct = CS.UnityEngine.Vector3(direction.z, 0, -direction.x); + self.Transform.rotation = CS.UnityEngine.Quaternion.LookRotation(Direct, CS.UnityEngine.Vector3.up); +end + +--面向摄像机 +function XHomeCharObj:FaceToSceneCamera() + local currentCamera = XHomeSceneManager.GetSceneCamera() + local direction = currentCamera.transform.position - self.Transform.position + local Direct = CS.UnityEngine.Vector3(direction.x, 0, direction.z); + self.Transform.rotation = CS.UnityEngine.Quaternion.LookRotation(Direct, CS.UnityEngine.Vector3.up); +end + +function XHomeCharObj:Dispose() + + if not XTool.UObjIsNil(self.GoInputHandler) then + self.GoInputHandler:RemoveAllListeners() + end + self.GoInputHandler = nil + + self:HideBubble() + self:HideEffect() + + XHomeCharObj.Super.Dispose(self) +end + +function XHomeCharObj:OnDrag(eventData) + if not self.IsSelf then + return + end + + if self.Status ~= XHomeBehaviorStatus.GRAB_UP then + return + end + + -- 托起 + local currentCamera = XHomeSceneManager.GetSceneCamera() + local direction = self.Transform.position - currentCamera.transform.position + local z = CS.UnityEngine.Vector3.Dot(direction, currentCamera.transform.forward); + local screenPos = CS.UnityEngine.Vector3(eventData.position.x, eventData.position.y, z) + local pos = currentCamera:ScreenToWorldPoint(screenPos) + local gridPos = XHomeDormManager.WorldPosToGroundGridPos(pos, self.Room.Transform) + --判断拖拽越界 + if gridPos.x <= 0 or gridPos.y <= 0 or gridPos.x >= XHomeDormManager.GetMapWidth() - 1 or gridPos.y >= XHomeDormManager.GetMapHeight() - 1 then + return + end + + self.Transform.position = CS.UnityEngine.Vector3(pos.x, self.OrignalPosition.y + 0.5, pos.z) + + --判断射线碰到家私 + local layerMask = CS.UnityEngine.LayerMask.GetMask("Device") + if layerMask then + + local hit = self.Transform:PhysicsRayCast(CS.UnityEngine.Vector3.up * 100, CS.UnityEngine.Vector3.down, layerMask) + + if not XTool.UObjIsNil(hit) then + local obj = XSceneEntityManager.GetEntity(hit.gameObject) + + if self.PreInteractFurniture ~= nil and (obj == nil or obj.Data.Id ~= self.PreInteractFurniture.Data.Id) then + self.PreInteractFurniture:RayCastSelected(false) + self.IsRayCastFurniture = false + end + + if obj then + local interactInfo = obj:GetAvailableInteract(self.CharData.CharacterId) + if interactInfo then + self.PreInteractFurniture = obj + self.PreInteractFurniture:RayCastSelected(true) + self.IsRayCastFurniture = true + else + if self.PreInteractFurniture then + self.PreInteractFurniture:RayCastSelected(false) + end + self.IsRayCastFurniture = false + self.PreInteractFurniture = nil + end + end + else + if self.PreInteractFurniture ~= nil then + self.PreInteractFurniture:RayCastSelected(false) + self.PreInteractFurniture = nil + self.IsRayCastFurniture = false + + end + end + end +end + +--长按 +function XHomeCharObj:OnPress(pressTime) + if not self.IsSelf then + return + end + + if self.Status ~= XHomeBehaviorStatus.GRAB_UP then + if not self.IsPressing then + XEventManager.DispatchEvent(XEventId.EVENT_CHARACTER_PUT_ON, self.Id, self.Transform, true) + self.IsPressing = true + elseif pressTime >= self.DormPutOnAnimaTime then + self:SidewaysSceneCamera() + self.OrignalPosition = self.Transform.position + + self.Transform.position = CS.UnityEngine.Vector3(self.OrignalPosition.x, self.OrignalPosition.y + 0.5, self.OrignalPosition.z) + + self:ChangeStatus(XHomeBehaviorStatus.GRAB_UP) + self:HideBubble() + XEventManager.DispatchEvent(XEventId.EVENT_CHARACTER_CATCH) + self.NavMeshAgent.IsObstacle = false + self.IsPressing = false + end + end + +end + +--点击:会直接被外部调用,不会传eventData +function XHomeCharObj:OnClick(eventData) + if not self.IsSelf then + return + end + + if eventData then + self.Agent:SetVarDicByKey("BindWorldPos", eventData.pointerCurrentRaycast.worldPosition) + end + + if self.CanClick then + local currentCamera = XHomeSceneManager.GetSceneCamera() + local direction = currentCamera.transform.position - self.Transform.position + direction.y = 0 + local eulerAngle = CS.UnityEngine.Quaternion.LookRotation(direction).eulerAngles + self.Agent:SetVarDicByKey("TurnTo", eulerAngle) + XHomeCharManager.SetSelectCharacter(self) + + self:ChangeStatus(XHomeBehaviorStatus.SELECTED) + self:HideBubble() + XEventManager.DispatchEvent(XEventId.EVENT_DORM_EXP_DETAIL_SHOW, self.Id, self.Transform) + end + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_DORM_CHARACTER_CLICK_SUCCESS, self.Id) +end + +--手指压下 +function XHomeCharObj:OnPointerDown() + if not self.IsSelf then + return + end + + if self.CanClick then + self:HideBubble() + local currentCamera = XHomeSceneManager.GetSceneCamera() + local direction = currentCamera.transform.position - self.Transform.position + direction.y = 0 + local eulerAngle = CS.UnityEngine.Quaternion.LookRotation(direction).eulerAngles + self.Agent:SetVarDicByKey("TurnTo", eulerAngle) + self:ChangeStatus(XHomeBehaviorStatus.WAIT) + end +end + +--手指松开 +function XHomeCharObj:OnPointerUp() + if not self.IsSelf then + return + end + + if self.Status == XHomeBehaviorStatus.GRAB_UP or self.IsPressing then + XEventManager.DispatchEvent(XEventId.EVENT_CHARACTER_PUT_DOWN) + end + + if self.Status == XHomeBehaviorStatus.GRAB_UP then + + self:FaceToSceneCamera() + if not self.PreInteractFurniture then + self.NavMeshAgent.IsObstacle = true + CsXGameEventManager.Instance:Notify(XEventId.EVENT_DORM_CHARACTER_POINTER_UP_SUCCESS, self.Id) + else + self.NavMeshAgent.IsObstacle = false + + local interactInfo = self.PreInteractFurniture:GetNearAvailableInteract(self.Transform.position, self.CharData.CharacterId) + if not interactInfo then + self.PreInteractFurniture:RayCastSelected(false) + self.IsRayCastFurniture = false + self.PreInteractFurniture = nil + self.NavMeshAgent.IsObstacle = true + CsXGameEventManager.Instance:Notify(XEventId.EVENT_DORM_CHARACTER_POINTER_UP_SUCCESS, self.Id) + return + end + + self.PreInteractFurniture:RayCastSelected(false) + self.IsRayCastFurniture = false + + self.Transform.eulerAngles = interactInfo.StayPos.transform.eulerAngles + + self.Furniture = self.PreInteractFurniture + self.InteractInfo = interactInfo + + local state = self:GetInteractInfoBehavior(interactInfo) + self.Transform.position = CS.UnityEngine.Vector3(interactInfo.StayPos.transform.position.x, self.OrignalPosition.y, interactInfo.StayPos.transform.position.z) + self:ChangeStatus(state) + end + end + self.PreInteractFurniture = nil + + if self.IsPressing then + self.IsPressing = false + end +end + +function XHomeCharObj:GetInteractInfoBehavior(info) + local relation = XDormConfig.GetDormF2CBehaviorRelative(self.Furniture.Cfg.Id, self.Id, info.PosIndex) + if relation and relation.BehaviorWeight then + local totalweight = 0 + for _, weight in pairs(relation.BehaviorWeight) do + totalweight = totalweight + weight + end + math.randomseed(os.time()) + local random = math.random(0, totalweight) + local countWeight = 0 + for index, weight in pairs(relation.BehaviorWeight) do + countWeight = countWeight + weight + if random <= countWeight then + return relation.Behavior[index] + end + end + end + return info.BehaviorType +end + +function XHomeCharObj:GetInteractInfoAttractBehavior(info) + local relation = XDormConfig.GetDormF2CBehaviorRelative(self.Furniture.Cfg.Id, self.Id, info.PosIndex) + if relation and relation.AttractBehaviorWeight then + local totalweight = 0 + for _, weight in pairs(relation.AttractBehaviorWeight) do + totalweight = totalweight + weight + end + math.randomseed(os.time()) + local random = math.random(0, totalweight) + local countWeight = 0 + for index, weight in pairs(relation.AttractBehaviorWeight) do + countWeight = countWeight + weight + if random <= countWeight then + return relation.AttractBehavior[index] + end + end + end + return info.AttractBehaviorType +end + +--手指退出 +function XHomeCharObj:OnPointerExit() + if not self.IsSelf then + return + end + + if self.IsPressing then + XEventManager.DispatchEvent(XEventId.EVENT_CHARACTER_EXIT) + self.IsPressing = false + end +end + +--关联家具 +function XHomeCharObj:InteractFurniture() + if self.Furniture == nil or not self.InteractInfo then + return false + end + + for _, v in ipairs(self.Furniture.InteractInfoList) do + if v.GridPos.x == self.InteractInfo.GridPos.x and v.GridPos.y == self.InteractInfo.GridPos.y then + v.UsedType = v.UsedType | XFurnitureInteractUsedType.Character + v.CharacterId = self.Id + break + end + end + + return true +end + +-- 播放关联家具动画 +function XHomeCharObj:PlayInteractFurnitureAnimation() + if self.Furniture == nil or not self.InteractInfo then + return false + end + + self.Furniture:PlayInteractAnimation(self.Id) + return true +end + +--到达家具交互 +function XHomeCharObj:ReachFurniture() + if self.Furniture == nil then + self:ChangeStatus(XHomeBehaviorStatus.IDLE) + return false + end + for _, v in ipairs(self.Furniture.InteractInfoList) do + local state = self:GetInteractInfoBehavior(v) + if XDormConfig.GetCharacterBehavior(self.Id, state) then + self:ChangeStatus(state) + return true + end + end + + return false +end + +--取消家具预关联 +function XHomeCharObj:DisPreInteractFurniture() + if self.PreInteractFurniture == nil then + return false + end + + for _, v in ipairs(self.PreInteractFurniture.InteractInfoList) do + if v.CharacterId == self.Id and (v.UsedType & XFurnitureInteractUsedType.Character) > 0 then + XHomeCharManager.SetFurnitureInteractTime(self.Id) + v.UsedType = v.UsedType - XFurnitureInteractUsedType.Character + v.CharacterId = nil + break + end + end + + return true +end + +--取消家具关联 +function XHomeCharObj:DisInteractFurniture() + if self.Furniture == nil then + return false + end + + for _, v in ipairs(self.Furniture.InteractInfoList) do + if v.CharacterId == self.Id and (v.UsedType & XFurnitureInteractUsedType.Character) > 0 then + XHomeCharManager.SetFurnitureInteractTime(self.Id) + v.UsedType = v.UsedType - XFurnitureInteractUsedType.Character + v.CharacterId = nil + break + end + end + + self.Furniture = nil + self.InteractInfo = nil + return true +end + + +--检测是否可以取消家具关联 +function XHomeCharObj:CheckDisInteractFurniture() + if self.Furniture == nil then + return false + end + + for _, v in ipairs(self.Furniture.InteractInfoList) do + if v.CharacterId == self.Id and (v.UsedType & XFurnitureInteractUsedType.Character) > 0 then + local canReach = CS.XNavMeshUtility.CheckCanReachNavMeshSamplePosition(v.InteractPos.transform.position, CS.XHomeMapManager.Inst.CeilSize * 0.75) + if (v.UsedType & XFurnitureInteractUsedType.Block) > 0 or not canReach then + return false + else + return true + end + end + end + + return true +end + +--取消选择 +function XHomeCharObj:UnSelected() + XHomeCharManager.SetSelectCharacter(nil) + self:ChangeStatus(XHomeBehaviorStatus.IDLE) +end + +--设置爱抚类型 +function XHomeCharObj:SetFondleType(fondleType) + self.FondleTypeList = self.FondleTypeList or {} + local length = #self.FondleTypeList + if self.FondleType == fondleType then + return + end + + if length < 2 then + table.insert(self.FondleTypeList, fondleType) + return + end + + if fondleType == XHomeCharFondleType.REFUSE then + return + elseif self.FondleTypeList[length] <= XHomeCharFondleType.PLAY then + self.FondleTypeList[length] = fondleType + end + +end + +--出列 +function XHomeCharObj:DequeueFondleType() + if self.FondleTypeList and #self.FondleTypeList > 0 then + self.FondleType = table.remove(self.FondleTypeList, 1) + end + + if not self.FondleType then + self.FondleType = 0 + end +end + + +--获取爱抚类型 +function XHomeCharObj:GetFondleType() + if self.FondleTypeList and #self.FondleTypeList > 0 then + self.FondleType = self.FondleTypeList[1] + else + self.FondleType = 0 + end + + return self.FondleType +end + +-- 重新出生点 +function XHomeCharObj:ReBorn() + self.GameObject:SetActive(true) + self.NavMeshAgent.IsObstacle = true + self:ChangeStatus(XHomeBehaviorStatus.IDLE) +end + +-- 刷新位置 +function XHomeCharObj:ReSetPosition() + if self.LastInteractInfoPos then + self.LastInteractInfoPos = nil + end + + local canReachList = self.Room:GetCanReachList() + local isBornPos = false + local targetPos = CS.UnityEngine.Vector2.one + local x = 0 + local y = 0 + + + --最大的随机次数 + local limit = 30 + --设置随机数种子 + math.randomseed(os.time() + self.Id) + while (not isBornPos and limit >= 0) do + local index = math.random(1, #canReachList) + x = canReachList[index].x + y = canReachList[index].y + local pos = XHomeDormManager.GetLocalPosByGrid(x, y, CS.XHomePlatType.Ground, 0) + pos = self.Room.Transform.localToWorldMatrix:MultiplyPoint(pos) + isBornPos, targetPos = CS.XNavMeshUtility.NavMeshSamplePositionByWalkable(pos) + if not isBornPos then + targetPos = pos + end + + limit = limit - 1 + end + + self.Transform.position = targetPos + self.OrignalPosition = self.Transform.position + + self.Pos = { + ["x"] = x, + ["y"] = y + } + + self.Agent:SetVarDicByKey("x", x) + self.Agent:SetVarDicByKey("y", y) +end + +-- 检查是否在交互,如果在与家具交互,构造体重置到家具交互位置 +function XHomeCharObj:CheckInteractFurniture() + if self.LastInteractInfoPos then + self.Transform.position = CS.UnityEngine.Vector3(self.LastInteractInfoPos.x, self.LastInteractInfoPos.y, self.LastInteractInfoPos.z) + self.LastInteractInfoPos = nil + end +end + +function XHomeCharObj:OnShow(isResetPosition) + if self.Visible then + return + end + + if isResetPosition then + self:ReSetPosition() + else + self:CheckInteractFurniture() + end + + self.Visible = true + self:ReBorn() +end + + +function XHomeCharObj:OnHide() + if not self.Visible then + return + end + + -- 保存家具交互点信息 + if self.Furniture then + local info = self.Furniture:GetInteractById(self.Id) + self.LastInteractInfoPos = { + x = info.InteractPos.transform.position.x, + y = info.InteractPos.transform.position.y, + z = info.InteractPos.transform.position.z + } + end + + self:ChangeStateMachine(XHomeCharFSMType.EMPTY) + self:HideBubble() + + self.Visible = false +end + +--检测是否在家具上方 +function XHomeCharObj:CheckRayCastFurnitureNode() + return self.IsRayCastFurniture +end + + +--面向交互的构造体 +function XHomeCharObj:InteractWith(charObj) + local direction = charObj.Transform.position - self.Transform.position + direction.y = 0 + local eulerAngle = CS.UnityEngine.Quaternion.LookRotation(direction).eulerAngles + self.Agent:SetVarDicByKey("TurnTo", eulerAngle) +end + + +--交互家具面向方向调整 +function XHomeCharObj:SetForwardToFurniture(forward) + + local furniture = self.Furniture + local info = self.InteractInfo + if not furniture or not info then + return false + end + + + local interact = furniture:GetInteract(info.GridPos.x, info.GridPos.y) + local eulerAngle = interact.InteractPos.transform.eulerAngles + if forward < 0 then + eulerAngle = eulerAngle + CS.UnityEngine.Vector3(0, 180, 0) + end + self.Agent:SetVarDicByKey("TurnTo", eulerAngle) + return true +end + + +--设置构造体交互开关 +function XHomeCharObj:SetCharInteractTrigger(isOn) + self.CharInteractTrigger = isOn +end + +--检测构造体是否在坐标索引上 +function XHomeCharObj:CheckCharInteractPosByIndex(index) + if not self.Furniture or not self.Furniture.InteractInfoList then + return false + end + + for _, v in ipairs(self.Furniture.InteractInfoList) do + if v.CharacterId == self.Id and (v.UsedType & XFurnitureInteractUsedType.Character) > 0 then + return v.Index == index + end + end + + return false +end + +return XHomeCharObj \ No newline at end of file diff --git a/Resources/Scripts/XHome/XDorm/XHomeDormManager.lua b/Resources/Scripts/XHome/XDorm/XHomeDormManager.lua new file mode 100644 index 00000000..cb16f767 --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeDormManager.lua @@ -0,0 +1,1095 @@ +--- +--- 宿舍管理器 +--- 管理场景上对象 +--- +XHomeDormManager = XHomeDormManager or {} + +local XHomeRoomObj = require("XHome/XDorm/XHomeRoomObj") +local XHomeFurnitureObj = require("XHome/XDorm/XHomeFurnitureObj") + +-- 格子颜色了类型 +GridColorType = { + Default = 1, + Green = 2, + Red = 3, + Interact = 4, + Blue = 5, +} + +local GRID_COLOR_PATH = { + Default = CS.XGame.ClientConfig:GetString("HomeGridColorDefaultAssetUrl"), + Green = CS.XGame.ClientConfig:GetString("HomeGridColorGreenAssetUrl"), + Red = CS.XGame.ClientConfig:GetString("HomeGridColorRedAssetUrl"), + Interact = CS.XGame.ClientConfig:GetString("HomeGridColorInteractAssetUrl"), + Blue = CS.XGame.ClientConfig:GetString("HomeGridColorBlueAssetUrl") +} + +-- local IsSelf = false +local InDormitoryScene = false + +local GridColorSoDic = {} +local ResourceCacheDic = {} + +local MapResource = nil +local MapTransform = nil +local GroundRoot = nil +local WallRoot = nil +local HomeMapManager = nil --房间地图配置管理器 + +local RoomFacade = nil --房间外墙模板 +local RoomRoot = nil +local RoomTemplateGrid = nil +local RoomDic = {} + +local TallBuilding = nil + +local CurSelectedRoom = nil + +local IsSelectedFurniture = false +local ClickFurnitureCallback = nil + +XHomeDormManager.DormBgm = {} +XHomeDormManager.FurnitureShowAttrType = -1 + +local FurnitureMiniorType = { + Ground = 1, + Wall = 2, + Ceiling = 3, + BigFurniture = 4, + SmallFurniture = 5, + DecorateFurniture = 6, + PetFurniture = 7, +} + +local RecordRoomPutup = {} +-- 初始化场景 +local function InitScene(go, datas, dormDataType, onFinishLoadScene, isenterroom) + CS.XGridManager.Instance:Init() + + --场景全局光照 + XHomeSceneManager.SetGlobalIllumSO(CS.XGame.ClientConfig:GetString("HomeSceneSoAssetUrl")) + + --格子颜色信息资源 + for key, path in pairs(GRID_COLOR_PATH) do + local resource = CS.XResourceManager.Load(path) + if resource then + GridColorSoDic[GridColorType[key]] = resource + end + end + + TallBuilding = go.transform:Find("GroupBase/@TallBuilding") + RoomFacade = go.transform:Find("@RoomFacade") + RoomRoot = go.transform:Find("@Room") + RoomTemplateGrid = go.transform:Find("@Room/@Room_Template") + if not XTool.UObjIsNil(RoomTemplateGrid) then + RoomTemplateGrid.gameObject:SetActiveEx(false) + end + + if not XTool.UObjIsNil(RoomRoot) then + XHomeDormManager.LoadRooms(datas, dormDataType) + end + XDataCenter.DormManager.LoacdCollectTxture() + + local camera = XHomeSceneManager.GetSceneCamera() + HomeMapManager:SetCamera(camera) + + if dormDataType == XDormConfig.DormDataType.Self then + XLuaUiManager.OpenWithCallback("UiDormMain", function() + XLuaUiManager.Open("UiDormComponent") + + if onFinishLoadScene then + onFinishLoadScene() + end + if isenterroom then + XLuaUiManager.Open("UiDormSecond", XDormConfig.VisitDisplaySetType.MySelf, XHomeDormManager.DormitoryId) + end + end) + else + if not XLuaUiManager.IsUiLoad("UiDormSecond") then + local visit = XDormConfig.VisitDisplaySetType.Stranger + if XDataCenter.SocialManager.CheckIsFriend(XHomeDormManager.TargetId) then + visit = XDormConfig.VisitDisplaySetType.MyFriend + end + XLuaUiManager.OpenWithCallback("UiDormSecond", function() + XLuaUiManager.Close("UiLoading") + end, visit, XHomeDormManager.DormitoryId) + end + end + + XHomeCharManager.Init() + InDormitoryScene = true +end + +-- 移除场景 +local function RemoveScene() + InDormitoryScene = false + CS.XGridManager.Instance:Clear() + for _, v in pairs(GridColorSoDic) do + if v then + v:Release() + end + end + GridColorSoDic = {} + + XLuaUiManager.Close("UiDormComponent") + + RoomFacade = nil + RoomRoot = nil + RoomTemplateGrid = nil + for _, room in pairs(RoomDic) do + room:Dispose() + end + RoomDic = {} + CurSelectedRoom = nil + + HomeMapManager = nil + GroundRoot = nil + WallRoot = nil + if not XTool.UObjIsNil(MapTransform) then + CS.UnityEngine.GameObject.Destroy(MapTransform.gameObject) + end + MapTransform = nil + if MapResource then + MapResource:Release() + end + MapResource = nil + + for _, v in pairs(ResourceCacheDic) do + CS.XResourceManager.Unload(v) + end + ResourceCacheDic = {} +end + +-- 初始化地表地图 +local function InitSurfaceMap(model) + MapTransform = model.transform + GroundRoot = MapTransform:Find("@GroundRoot") + WallRoot = MapTransform:Find("@WallRoot") + MapTransform:SetParent(nil) + MapTransform.gameObject:SetActiveEx(false) + HomeMapManager = model:GetComponent("XHomeMapManager") + HomeMapManager:Init() +end + +-- 进入宿舍 +function XHomeDormManager.EnterDorm(targetId, dormitoryId, isSele, onFinishLoadScene, onFinishEnterRoom) + local isSelf = true + local dormDataType = XDormConfig.DormDataType.Self + XHomeDormManager.TargetId = targetId + XHomeDormManager.DormitoryId = dormitoryId + + if targetId and targetId ~= XPlayer.Id then + isSelf = false + dormDataType = XDormConfig.DormDataType.Target + end + + local cb = function() + -- IsSelf = isSelf + local datas = XDataCenter.DormManager.GetDormitoryData(dormDataType) + + local onLoadCompleteCb = function(go) + go.gameObject:SetActiveEx(true) + InitScene(go, datas, dormDataType, onFinishLoadScene, isSele) + + if dormitoryId and isSele then + XHomeDormManager.SetSelectedRoom(dormitoryId, true, nil, onFinishEnterRoom) + end + end + + XDataCenter.DormManager.RequestDormitoryDormEnter() + + MapResource = CS.XResourceManager.Load(CS.XGame.ClientConfig:GetString("HomeMapAssetUrl")) + local model = CS.UnityEngine.Object.Instantiate(MapResource.Asset) + InitSurfaceMap(model) + CS.XGlobalIllumination.SetSceneType(CS.XSceneType.Dormitory) + XHomeSceneManager.EnterScene("sushe003", CS.XGame.ClientConfig:GetString("SuShe003"), onLoadCompleteCb, RemoveScene) + + end + + if isSelf then + cb() + else + local charId = XDataCenter.DormManager.GetVisitorDormitoryCharacterId() + XDataCenter.DormManager.RequestDormitoryVisit(targetId, dormitoryId, charId, cb) + end +end + +--获取房间信息 +function XHomeDormManager.GetRoom(roomId) + if not RoomDic then + return nil + end + + return RoomDic[roomId] +end + +--设置房间交互信息GameObject +function XHomeDormManager.SetRoomInteractInfo(roomId) + local room = XHomeDormManager.GetRoom(roomId) + if room then + room:SetInteractInfoGo() + end +end + +--隐藏房间交互信息GameObject +function XHomeDormManager.HideRoomInteractInfo(roomId) + local room = XHomeDormManager.GetRoom(roomId) + if room then + room:HideInteractInfoGo() + end +end + +-- 加载模板以及收藏宿舍 +local function LoadTemplateRooms(datas, loadtype, isNotChangeView) + for _, data in pairs(datas) do + local room = RoomDic[data.Id] + if not room then + if not XTool.UObjIsNil(RoomTemplateGrid) then + room = XHomeRoomObj.New(data) + RoomDic[data.Id] = room + room:SetModel(RoomTemplateGrid.gameObject, loadtype) + RoomTemplateGrid.gameObject:SetActiveEx(true) + end + else + room:SetData(data, loadtype) + end + end + if not isNotChangeView then + XHomeSceneManager.ChangeView(HomeSceneViewType.OverView) + end +end + +-- 加载宿舍房间 +function XHomeDormManager.LoadRooms(datas, loadtype, isNotChangeView) + if datas == nil then + return + end + + if XDormConfig.IsTemplateRoom(loadtype) then + LoadTemplateRooms(datas, loadtype, isNotChangeView) + return + end + + for _, data in pairs(datas) do + local room = RoomDic[data.Id] + if not room then + local room_trans = RoomRoot:Find("@Room_" .. data.Id) + local room_trans_Putup = room_trans:Find("@Hud") + if not XTool.UObjIsNil(room_trans) then + room = XHomeRoomObj.New(data, RoomFacade) + RoomDic[data.Id] = room + room:SetModel(room_trans.gameObject, loadtype) + RecordRoomPutup[data.Id] = room_trans_Putup + end + else + room:SetData(data, loadtype) + end + end + + if not isNotChangeView then + XHomeSceneManager.ChangeView(HomeSceneViewType.OverView) + end +end + +function XHomeDormManager.GetRoomsPutup(dormId) + return RecordRoomPutup[dormId] +end + +-- 将地图网格挂到指定房间根节点 +function XHomeDormManager.AttachSurfaceToRoom(roomId) + if not roomId then + MapTransform.gameObject:SetActiveEx(false) + end + + local room = RoomDic[roomId] + if room and not XTool.UObjIsNil(room.Transform) then + local groundSurface = GroundRoot:GetComponentInChildren(typeof(CS.XHomeSurface)) + if not XTool.UObjIsNil(groundSurface) then + groundSurface.ConfigId = room.Ground.Data.CfgId + end + + -- 4个 + local wallSurface = WallRoot:GetComponentInChildren(typeof(CS.XHomeSurface)) + if not XTool.UObjIsNil(wallSurface) then + if room.Wall == nil then + XLog.Error("缺少墙的数据....(迷惑)") + else + wallSurface.ConfigId = room.Wall.Data.CfgId + end + end + + MapTransform:SetParent(room.Transform, false) + MapTransform.localPosition = CS.UnityEngine.Vector3.zero; + MapTransform.localRotation = CS.UnityEngine.Quaternion.identity + MapTransform.localScale = CS.UnityEngine.Vector3.one + + MapTransform.gameObject:SetActiveEx(true) + end +end + +--锁定墙体碰撞盒 +function XHomeDormManager.LockCollider(rotate) + if XTool.UObjIsNil(HomeMapManager) then + return + end + HomeMapManager:LockCollider(rotate) +end + + +function XHomeDormManager.OnShowBlockGrids(platType, gridOffset, rotate) + if XTool.UObjIsNil(HomeMapManager) then + return + end + + local so = XHomeDormManager.GetGridColorSO(GridColorType.Red) + HomeMapManager:OnShowBlockGrids(platType, gridOffset, so.Asset, rotate) +end + +function XHomeDormManager.OnHideBlockGrids(platType, rotate) + if XTool.UObjIsNil(HomeMapManager) then + return + end + + HomeMapManager:OnHideBlockGrids(platType, rotate) +end + +--解锁墙体碰撞盒 +function XHomeDormManager.UnlockCollider() + if XTool.UObjIsNil(HomeMapManager) then + return + end + HomeMapManager:UnlockCollider() +end + +--获取家具交互点格子坐标 +function XHomeDormManager.GetInteractGridPos(furnitureX, furnitureY, width, height, x, y, rotate) + if XTool.UObjIsNil(HomeMapManager) then + return + end + + -- 返回(格子坐标;该坐标是否在房间地图内) + return HomeMapManager:GetInteractGridPos(furnitureX, furnitureY, width, height, x, y, rotate) +end + +-- 获取地图格子边长 +function XHomeDormManager.GetCeilSize() + if XTool.UObjIsNil(HomeMapManager) then + return 0 + end + return HomeMapManager.CeilSize +end + +-- 获取地图宽 +function XHomeDormManager.GetMapWidth() + if XTool.UObjIsNil(HomeMapManager) then + return 0 + end + return HomeMapManager.MapSize.x +end + +-- 获取地图高 +function XHomeDormManager.GetMapHeight() + if XTool.UObjIsNil(HomeMapManager) then + return 0 + end + return HomeMapManager.MapSize.y +end + +-- 获取地图墙高 +function XHomeDormManager.GetMapTall() + if XTool.UObjIsNil(HomeMapManager) then + return 0 + end + return HomeMapManager.MapSize.z +end + +-- 获取格子颜色SO +function XHomeDormManager.GetGridColorSO(gridColorType) + return GridColorSoDic[gridColorType] +end + +-- 显示地表网格 +function XHomeDormManager.ShowSurface(type) + if XTool.UObjIsNil(MapTransform) then + return + end + + if type == CS.XHomePlatType.Ground then + GroundRoot.gameObject:SetActiveEx(true) + WallRoot.gameObject:SetActiveEx(false) + elseif type == CS.XHomePlatType.Wall then + GroundRoot.gameObject:SetActiveEx(false) + WallRoot.gameObject:SetActiveEx(true) + end +end + +function XHomeDormManager.ReformRoom(roomId, isBegin) + local room = RoomDic[roomId] + if not room then + return + end + + room:Reform(isBegin) +end + +-- 收起房间全部家具 +function XHomeDormManager.CleanRoom(roomId) + local room = RoomDic[roomId] + if not room then + return + end + + room:CleanRoom() +end + +-- 重置房间 +function XHomeDormManager.RevertRoom(roomId) + local room = RoomDic[roomId] + if not room then + return + end + + room:RevertRoom() +end + +function XHomeDormManager.RevertOnWall(roomId) + local room = RoomDic[roomId] + if not room then + return + end + + room:CleanWallFurniture() +end + +-- 重置当前宿舍光照 +function XHomeDormManager.SetIllumination() + if CurSelectedRoom then + CurSelectedRoom:SetIllumination() + end +end + +-- 保存房间摆设 +function XHomeDormManager.SaveRoomModification(roomId, isBehavior, cb) + local room = RoomDic[roomId] + if not room then + return + end + + XDataCenter.DormManager.RequestDecorationRoom(roomId, room, isBehavior, cb) +end + +-- 创建家具 +function XHomeDormManager.CreateFurniture(roomId, furnitureData, gridPos, rotate) + if not furnitureData then + return + end + + local room = RoomDic[roomId] + if not room then + return nil + end + + local isTemplateRoom = XDormConfig.IsTemplateRoom(room.CurLoadType) + local id = furnitureData.Id or 0 + if isTemplateRoom and id == 0 then + id = XGlobalVar.GetIncId() + end + + local data = {} + data.Id = id + data.CfgId = furnitureData.ConfigId + data.GridX = gridPos.x + data.GridY = gridPos.y + data.RotateAngle = rotate + + local furniture = XHomeFurnitureObj.New(data, room) + local root + if furniture.Cfg.LocateType == XFurnitureConfigs.HomeLocateType.Replace then + root = room.SurfaceRoot + else + root = room.FurnitureRoot + end + + furniture:LoadModel(furniture.Cfg.Model, root) + if isTemplateRoom then + return furniture + end + + if room.Data:IsSelfData() then + XHomeDormManager.ReplaceFurnitureMaterial(furniture, furnitureData.Id, XDormConfig.DormDataType.Self) + XHomeDormManager.ReplaceFurnitureFx(furniture, furnitureData.Id, XDormConfig.DormDataType.Self) + else + XHomeDormManager.ReplaceFurnitureMaterial(furniture, furnitureData.Id, XDormConfig.DormDataType.Target) + XHomeDormManager.ReplaceFurnitureFx(furniture, furnitureData.Id, XDormConfig.DormDataType.Target) + end + + return furniture +end + +function XHomeDormManager.ReplaceFurnitureMaterial(furniture, furnitureId, dormDataType) + local materialPath = XDataCenter.FurnitureManager.GetFurnitureMaterial(furnitureId, dormDataType) + if not materialPath then + return + end + local targetMaterial = ResourceCacheDic[materialPath] + if not targetMaterial then + targetMaterial = CS.XResourceManager.Load(materialPath) + ResourceCacheDic[materialPath] = targetMaterial + end + CS.XMaterialContainerHelper.ReplaceDormMat(furniture.GameObject, targetMaterial.Asset) +end + +function XHomeDormManager.ReplaceFurnitureFx(furniture, furnitureId, dormDataType) + local fxPath = XDataCenter.FurnitureManager.GetFurnitureFx(furnitureId, dormDataType) + if not fxPath then + return + end + + local effect = furniture.Transform:Find("Effect") + if not effect then return end + effect.gameObject:LoadPrefab(fxPath) +end + +-- 更换基础装修 +function XHomeDormManager.ReplaceSurface(roomId, furniture) + local room = RoomDic[roomId] + if not room then + return nil + end + + room:ReplaceSurface(furniture) +end + +-- 检测房间中家具类型数量限制 +function XHomeDormManager.CheckFurnitureCountReachLimit(roomId, furniture) + local room = RoomDic[roomId] + if not room then + return true + end + return room:CheckFurnitureCountReachLimit(furniture) +end + +-- 检测房间中家具类型数量限制 +function XHomeDormManager.CheckFurnitureCountReachLimitByPutNumType(roomId, putNumType) + local room = RoomDic[roomId] + if not room then + return true + end + return room:CheckFurnitureCountReachLimitByPutNumType(putNumType) +end + +-- 往房间中加入家具 +function XHomeDormManager.AddFurniture(roomId, furniture) + local room = RoomDic[roomId] + if not room then + return nil + end + room:AddFurniture(furniture) +end + +-- 从房间中移除家具 +function XHomeDormManager.RemoveFurniture(roomId, furniture) + local room = RoomDic[roomId] + if not room then + return nil + end + + room:RemoveFurniture(furniture) +end + +-- 选中指定房间 +function XHomeDormManager.SetSelectedRoom(roomId, isSelected, isvistor, onFinishEnterRoom) + CS.XMirrorManager.Instance:SetDormLayer(isSelected, CS.UnityEngine.LayerMask.GetMask(HomeSceneLayerMask.Device)) + local room = RoomDic[roomId] + if not room then + return nil + end + + if CurSelectedRoom then + if CurSelectedRoom.Data.Id == room.Data.Id then + CurSelectedRoom:SetCharacterExit() + CurSelectedRoom:SetSelected(isSelected, true, onFinishEnterRoom) + if isvistor then + CurSelectedRoom = nil + end + if not isSelected then + XHomeSceneManager.SetGlobalIllumSO(CS.XGame.ClientConfig:GetString("HomeSceneSoAssetUrl")) + end + return + end + + CurSelectedRoom:SetSelected(false, nil, onFinishEnterRoom) + end + + room:SetSelected(isSelected, true, onFinishEnterRoom) + if isSelected then + CurSelectedRoom = room + end +end + +function XHomeDormManager.CharacterExit(roomId) + local room = RoomDic[roomId] + if not room then + return + end + room:SetCharacterExit() +end + +-- 显示或隐藏指定房间的外部景物 +function XHomeDormManager.ShowOrHideOutsideRoom(baseRoomId, isShowOutside) + -- 场景上高楼 + if not XTool.UObjIsNil(TallBuilding) then + TallBuilding.gameObject:SetActiveEx(isShowOutside) + end + + -- 其他房间 + for id, room in pairs(RoomDic) do + local isTemplateRoom = XDormConfig.IsTemplateRoom(room.CurLoadType) + if id ~= baseRoomId and not isTemplateRoom then + room.GameObject:SetActiveEx(isShowOutside) + end + end +end + +-- 显示构造体详情时 显示隐藏指定房间的外部景物 +function XHomeDormManager.ShowOrHideBuilding(isShowOutside) + -- 场景上高楼 + if not XTool.UObjIsNil(TallBuilding) then + TallBuilding.gameObject:SetActiveEx(isShowOutside) + end +end + +-- 设置选中家具 +function XHomeDormManager.SetSelectedFurniture(selected) + IsSelectedFurniture = selected +end + +-- 检测当前是否选中家具 +function XHomeDormManager.CheckSelectedFurniture() + return IsSelectedFurniture +end + +-- 设置点击家具回调 +function XHomeDormManager.SetClickFurnitureCallback(cb) + ClickFurnitureCallback = cb +end + +-- 调用点击家具回调 +function XHomeDormManager.FireClickFurnitureCallback(furniture) + if ClickFurnitureCallback then + ClickFurnitureCallback(furniture) + end +end + +-- 检测家具是否被阻挡 +function XHomeDormManager.CheckRoomFurnitureBlock(roomId, furnitureId, x, y, width, height, type, rotate) + local room = RoomDic[roomId] + if room then + return room:CheckFurnitureBlock(furnitureId, x, y, width, height, type, rotate) + end + + return true, CS.UnityEngine.Vector3.zero +end + +-- 检测家具碰撞 +function XHomeDormManager.CheckRoomFurnitureCollider(furniture, roomId) + local room = RoomDic[roomId] + return room:CheckFurnituresCollider(furniture) or false +end + +-- 获取本地坐标 +function XHomeDormManager.GetLocalPosByGrid(x, y, type, rotate) + if not XTool.UObjIsNil(HomeMapManager) then + return HomeMapManager:GetLocalPosByGrid(x, y, type, rotate) + end +end + +-- 检测地图是否有阻挡 +function XHomeDormManager.CheckMultiBlock(blockCfgId, x, y, width, height, type, rotate) + if not XTool.UObjIsNil(HomeMapManager) then + return HomeMapManager:CheckMultiBlock(blockCfgId, x, y, width, height, type, rotate) + end +end + +-- 世界坐标转地板格子坐标 +function XHomeDormManager.WorldPosToGroundGridPos(worldPos, roomTransform) + if XTool.UObjIsNil(HomeMapManager) then + return CS.UnityEngine.Vector2.zero, 0 + end + + local localPos = roomTransform.worldToLocalMatrix:MultiplyPoint(worldPos) + local gridPos = HomeMapManager:GetGridPosByLocal(localPos, CS.XHomePlatType.Ground, 0, 1, 1) + + return gridPos +end + +-- 检测世界坐标是否在地图边界 +function XHomeDormManager.WorldPosCheckIsInBound(worldPos, roomTransform) + if XTool.UObjIsNil(HomeMapManager) then + return false + end + + local localPos = roomTransform.worldToLocalMatrix:MultiplyPoint(worldPos) + local gridPos = HomeMapManager:GetGridPosByLocal(localPos, CS.XHomePlatType.Ground, 0) + local valid = HomeMapManager:CheckIsInBound(CS.XHomePlatType.Ground, gridPos.x, gridPos.y, 0) + return valid +end + +-- 获取格子坐标 +function XHomeDormManager.GetGridPosByWorldPos(worldPos, transform, width, height) + if XTool.UObjIsNil(HomeMapManager) then + return CS.UnityEngine.Vector3.zero, 0 + end + + local type, rotate + local name = transform.name + + if name == "@Wall01" then + type = CS.XHomePlatType.Wall + rotate = 0 + elseif name == "@Wall02" then + type = CS.XHomePlatType.Wall + rotate = 1 + elseif name == "@Wall03" then + type = CS.XHomePlatType.Wall + rotate = 2 + elseif name == "@Wall04" then + type = CS.XHomePlatType.Wall + rotate = 3 + else + type = CS.XHomePlatType.Ground + rotate = 0 + end + + local localPos = HomeMapManager.transform.worldToLocalMatrix:MultiplyPoint(worldPos) + local gridPos = HomeMapManager:GetGridPosByLocal(localPos, type, rotate, width, height) + + return gridPos, rotate +end + +-- 获取某个宿舍,某类型家具的数量 +function XHomeDormManager.GetFurnitureNumsByRoomAndMinor(roomId, minorType) + + local room = RoomDic[roomId] + if not room then + return 0 + end + + local roomData = room:GetData() + + if minorType == FurnitureMiniorType.Ground then + return 1 + elseif minorType == FurnitureMiniorType.Wall then + return 1 + elseif minorType == FurnitureMiniorType.Ceiling then + return 1 + end + + local furnitureList = roomData:GetFurnitureDic() + local totalNum = 0 + for _, v in pairs(furnitureList) do + local furnitureTemplate = XFurnitureConfigs.GetFurnitureTemplateById(v.ConfigId) + local furnitureMinorType = XFurnitureConfigs.GetFurnitureTypeById(furnitureTemplate.TypeId) + if minorType == furnitureMinorType.MinorType then + totalNum = totalNum + 1 + end + end + return totalNum +end + +-- 获取某个宿舍,某类型家具的容量 +function XHomeDormManager.GetFurnitureCapacityByRoomANdMinor(roomId, minorType, roomType) + local roomTemplate + if XDormConfig.IsTemplateRoom(roomType) then + roomTemplate = XDormConfig.GetDefaultDormitory() + else + roomTemplate = XDormConfig.GetDormitoryCfgById(roomId) + end + + if minorType == FurnitureMiniorType.Ground or minorType == FurnitureMiniorType.Wall or minorType == FurnitureMiniorType.Ceiling then + return 1 + elseif minorType == FurnitureMiniorType.BigFurniture then + return roomTemplate.BigFurnitureCapacity or 0 + elseif minorType == FurnitureMiniorType.SmallFurniture then + return roomTemplate.SmallFurnitureCapacity or 0 + elseif minorType == FurnitureMiniorType.DecorateFurniture then + return roomTemplate.DecorateCapacity or 0 + elseif minorType == FurnitureMiniorType.PetFurniture then + return roomTemplate.PetCapacity or 0 + else + return 0 + end +end + +function XHomeDormManager.GetFurnitureScoresByRoomData(roomData, dormDataType) + local furnitureIdList = {} + local totalScore = 0 + local attrList = { + [1] = 0, + [2] = 0, + [3] = 0, + } + + if not roomData then + return totalScore, attrList + end + + local furnitureList = roomData:GetFurnitureDic() + for _, v in pairs(furnitureList) do + table.insert(furnitureIdList, { + furnitureId = v.Id + }) + + end + local curdormDataType = XDormConfig.DormDataType.Target + if not dormDataType then + curdormDataType = XDormConfig.DormDataType.Self + end + for _, v in pairs(furnitureIdList) do + local redScore = XDataCenter.FurnitureManager.GetFurnitureRedScore(v.furnitureId, curdormDataType) + local yellowScore = XDataCenter.FurnitureManager.GetFurnitureYellowScore(v.furnitureId, curdormDataType) + local blueScore = XDataCenter.FurnitureManager.GetFurnitureBlueScore(v.furnitureId, curdormDataType) + totalScore = totalScore + XDataCenter.FurnitureManager.GetFurnitureScore(v.furnitureId, curdormDataType) + --totalScore = totalScore + redScore + yellowScore + blueScore + attrList[1] = attrList[1] + redScore + attrList[2] = attrList[2] + yellowScore + attrList[3] = attrList[3] + blueScore + end + + return { + TotalScore = totalScore, + AttrList = attrList + } +end + +function XHomeDormManager.GetFurnitureScoresByUnsaveRoom(roomId) + local room = RoomDic[roomId] + local totalScore = 0 + local attrList = { + [1] = 0, + [2] = 0, + [3] = 0, + } + if not room then + return { + TotalScore = totalScore, + AttrList = attrList + } + end + + local roomData = XDataCenter.DormManager.GetRoomDataByRoomId(roomId) + + return XHomeDormManager.GetFurnitureScoresByRoomData(roomData) +end + +-- 获取 +function XHomeDormManager.GetFurnitureScoresByRoomId(roomId) + local room = RoomDic[roomId] + local totalScore = 0 + local attrList = { + [1] = 0, + [2] = 0, + [3] = 0, + } + if not room then + return { + TotalScore = totalScore, + AttrList = attrList + } + end + + local roomData = room:GetData() + + return XHomeDormManager.GetFurnitureScoresByRoomData(roomData) +end + +-- 获取宿舍内3D坐标 对应2D坐标 +function XHomeDormManager.GetWorldToViewPoint(roomId, pos) + local room = RoomDic[roomId] + local camera = XHomeSceneManager.GetSceneCamera() + + if not room or not camera then + XLog.Error("XHomeDormManager.GetWorldToViewPoint error room is null, id is " .. roomId) + return CS.UnityEngine.Vector3.zero + end + + local screenPos = camera:WorldToViewportPoint(pos) + screenPos.x = screenPos.x * CsXUiManager.RealScreenWidth + screenPos.y = screenPos.y * CsXUiManager.RealScreenHeight + + return screenPos +end + +function XHomeDormManager.GetFurnitureFromList(id, furntiureList) + if not furntiureList then + return nil + end + for _, v in pairs(furntiureList) do + if v.Id == id then + return v + end + end + return nil +end + + +-- 是否需要保存宿舍, 宿舍任何物品稍微有改动则需要提示玩家保存 +function XHomeDormManager.IsNeedSave(roomId, roomDataType) + local room = RoomDic[roomId] + if not room then + return false + end + + local lastSaveData = XDataCenter.DormManager.GetRoomDataByRoomId(roomId, roomDataType) + local currentData = room:GetData() + + -- 家具(数量不一致,或者位置、角度不一致,提示保存) + local lastFurnitureList = lastSaveData:GetFurnitureDic() + local currentFurnitureList = currentData:GetFurnitureDic() + local isMyRoom = roomDataType == XDormConfig.DormDataType.Self + + local lastFurnitureNum = XHomeDormManager.GetFurnitureNumsByDic(lastFurnitureList) + local currentFurnitureNum = XHomeDormManager.GetFurnitureNumsByDic(currentFurnitureList) + if lastFurnitureNum ~= currentFurnitureNum then + return true + end + + for _, v in pairs(lastFurnitureList) do + local currentFurniture = currentFurnitureList[v.Id] + if currentFurniture == nil then + return true + end + + if isMyRoom then + -- 地板,天花板,墙 + if XDataCenter.FurnitureManager.IsFurnitureMatchType(v.Id, XFurnitureConfigs.HomeSurfaceBaseType.Ground) then + if v.Id ~= room.Ground.Data.Id then + return true + end + elseif XDataCenter.FurnitureManager.IsFurnitureMatchType(v.Id, XFurnitureConfigs.HomeSurfaceBaseType.Ceiling) then + if v.Id ~= room.Ceiling.Data.Id then + return true + end + elseif XDataCenter.FurnitureManager.IsFurnitureMatchType(v.Id, XFurnitureConfigs.HomeSurfaceBaseType.Wall) then + if v.Id ~= room.Wall.Data.Id then + return true + end + else + if v.ConfigId ~= currentFurniture.ConfigId or v.GridX ~= currentFurniture.GridX or + v.GridY ~= currentFurniture.GridY or v.RotateAngle ~= currentFurniture.RotateAngle then + return true + end + end + else + -- 地板,天花板,墙 + if XFurnitureConfigs.IsFurnitureMatchTypeByConfigId(v.ConfigId, XFurnitureConfigs.HomeSurfaceBaseType.Ground) then + if v.ConfigId ~= room.Ground.Data.CfgId then + return true + end + elseif XFurnitureConfigs.IsFurnitureMatchTypeByConfigId(v.ConfigId, XFurnitureConfigs.HomeSurfaceBaseType.Ceiling) then + if v.ConfigId ~= room.Ceiling.Data.CfgId then + return true + end + elseif XFurnitureConfigs.IsFurnitureMatchTypeByConfigId(v.ConfigId, XFurnitureConfigs.HomeSurfaceBaseType.Wall) then + if v.ConfigId ~= room.Wall.Data.CfgId then + return true + end + else + if v.ConfigId ~= currentFurniture.ConfigId or v.GridX ~= currentFurniture.GridX or + v.GridY ~= currentFurniture.GridY or v.RotateAngle ~= currentFurniture.RotateAngle then + return true + end + end + end + end + + return false +end + +function XHomeDormManager.GetFurnitureNumsByDic(furnitureDic) + local totalNum = 0 + if not furnitureDic then + return totalNum + end + for _, _ in pairs(furnitureDic) do + totalNum = totalNum + 1 + end + return totalNum +end + +-- 获取单个房间 +function XHomeDormManager.GetSingleDormByRoomId(roomId) + local room = RoomDic[roomId] + return room +end + +function XHomeDormManager.DormistoryGetFarestWall(dormitoryId) + local room = XHomeDormManager.GetSingleDormByRoomId(dormitoryId) + local totalWallNums = 4 + local wallPositions = {} + + for i = 1, totalWallNums do + wallPositions[i] = room.Transform:Find(string.format("HomeMapManager(Clone)/@WallRoot/@Wall0%d", i)).position + end + + local camera = XHomeSceneManager.GetSceneCamera() + if not camera then + return 1 + end + + local cameraPosition = camera.transform.position + local maxWallIndex = 1 + local maxWallDistance = 0 + + for k, wallPos in pairs(wallPositions) do + local distance = CS.UnityEngine.Vector3.Distance(cameraPosition, wallPos) + if distance > maxWallDistance then + maxWallIndex = k + maxWallDistance = distance + end + end + + return maxWallIndex +end + +-- 是否在宿舍场景里 +function XHomeDormManager.InDormScene() + return InDormitoryScene +end + +-- 是否在宿舍某个房间里 +function XHomeDormManager.InAnyRoom() + return CurSelectedRoom ~= nil and CurSelectedRoom.IsSelected +end + +-- 获取当前在宿舍某个房间的id +function XHomeDormManager.GetCurrentRoomId() + if CurSelectedRoom and CurSelectedRoom.IsSelected then + return CurSelectedRoom.Data.Id + end + return nil +end + +-- 获取当前在宿舍某个房间家具数据 +function XHomeDormManager.GetCurrentRoomFurnitures() + if CurSelectedRoom and CurSelectedRoom.IsSelected then + return CurSelectedRoom.Data:GetFurnitureDic() + end + return nil +end + +-- 是否在宿舍某个房间里(房间id为roomId) +function XHomeDormManager.IsInRoom(roomId) + if CurSelectedRoom == nil then return false end + if roomId and CurSelectedRoom.Data and CurSelectedRoom.Data.Id == roomId then + return CurSelectedRoom.IsSelected + end + return false +end + +--将网格的坐标显示到UI上 仅用于编辑器模式 +function XHomeDormManager.ShowGridPosInUi(type) + if not XTool.UObjIsNil(HomeMapManager) then + return HomeMapManager:ShowGridPosInUi(type) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XHome/XDorm/XHomeFurniture/XHomeFurnitureAgent.lua b/Resources/Scripts/XHome/XDorm/XHomeFurniture/XHomeFurnitureAgent.lua new file mode 100644 index 00000000..e1fe3753 --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeFurniture/XHomeFurnitureAgent.lua @@ -0,0 +1,55 @@ +local XHomeFurnitureAgent = XLuaBehaviorManager.RegisterAgent(XLuaBehaviorAgent, "HomeFurniture") + +function XHomeFurnitureAgent:OnAwake() + self.Path = {} +end + +-- 设置家具数据 +function XHomeFurnitureAgent:SetHomeFrunitureObj(homeFurnitureObj) + self.HomeFurnitureObj = homeFurnitureObj +end + +-- 状态改变 +function XHomeFurnitureAgent:ChangeStatus(state) + self.HomeFurnitureObj:ChangeStatus(state) +end + +-- 检测是否在家具上方 +function XHomeFurnitureAgent:CheckRayCastFurnitureNode() + return self.HomeFurnitureObj:CheckRayCastFurnitureNode() +end + +-- 还原家具位置 +function XHomeFurnitureAgent:ResetFurnituePistionNode() + return self.HomeFurnitureObj:ResetFurnituePistionNode() +end + + -- 播放家具动画 +function XHomeFurnitureAgent:DoActionNode(actionId,needFadeCross,crossDuration) + return self.HomeFurnitureObj:DoActionNode(actionId,needFadeCross,crossDuration) +end + + -- 播放家具特效 +function XHomeFurnitureAgent:DoEffectNode(effectId) + return self.HomeFurnitureObj:DoEffectNode(effectId) +end + + -- 隐藏家具 +function XHomeFurnitureAgent:HideFurnitureNode() + return self.HomeFurnitureObj:HideFurnitureNode() +end + + -- 改变家具位置 +function XHomeFurnitureAgent:ChangeFurnituePositionNode() + return self.HomeFurnitureObj:ChangeFurnituePositionNode() +end + +-- 保存家具变更所在房间 +function XHomeFurnitureAgent:SaveFurnitureInRoomNode() + self.HomeFurnitureObj:SaveFurnitureInRoomNode() +end + +-- 获取ID +function XHomeFurnitureAgent:GetId() + return self.HomeFurnitureObj.Data.Id +end diff --git a/Resources/Scripts/XHome/XDorm/XHomeFurniture/XHomeFurnitureNode/XHomeFurnitureChangeFurniturePositionNode.lua b/Resources/Scripts/XHome/XDorm/XHomeFurniture/XHomeFurnitureNode/XHomeFurnitureChangeFurniturePositionNode.lua new file mode 100644 index 00000000..c3cbf83b --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeFurniture/XHomeFurnitureNode/XHomeFurnitureChangeFurniturePositionNode.lua @@ -0,0 +1,9 @@ +local XHomeFurnitureChangeFurniturePositionNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "HomeFurnitureChangeFurniturePosition", CsBehaviorNodeType.Action, true, false) + +function XHomeFurnitureChangeFurniturePositionNode:OnEnter() + if self.AgentProxy:ChangeFurnituePositionNode() then + self.Node.Status = CsNodeStatus.SUCCESS + else + self.Node.Status = CsNodeStatus.FAILED + end +end \ No newline at end of file diff --git a/Resources/Scripts/XHome/XDorm/XHomeFurniture/XHomeFurnitureNode/XHomeFurnitureCheckPointerUpNode.lua b/Resources/Scripts/XHome/XDorm/XHomeFurniture/XHomeFurnitureNode/XHomeFurnitureCheckPointerUpNode.lua new file mode 100644 index 00000000..20db7eef --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeFurniture/XHomeFurnitureNode/XHomeFurnitureCheckPointerUpNode.lua @@ -0,0 +1,17 @@ +local XHomeFurnitureCheckPointerUpNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "HomeFurnitureCheckPointerUp", CsBehaviorNodeType.Condition, true, false) + +function XHomeFurnitureCheckPointerUpNode:OnGetEvents() + return { XEventId.EVENT_DORM_FURNITURE_POINTER_UP_SUCCESS } +end + +function XHomeFurnitureCheckPointerUpNode:OnEnter() + self.Id = self.AgentProxy:GetId() +end + +function XHomeFurnitureCheckPointerUpNode:OnNotify(evt, ...) + local args = { ... } + + if evt == XEventId.EVENT_DORM_FURNITURE_POINTER_UP_SUCCESS and args[1] == self.Id then + self.Node.Status = CsNodeStatus.SUCCESS + end +end \ No newline at end of file diff --git a/Resources/Scripts/XHome/XDorm/XHomeFurniture/XHomeFurnitureNode/XHomeFurnitureCheckRayCastFunitureNode.lua b/Resources/Scripts/XHome/XDorm/XHomeFurniture/XHomeFurnitureNode/XHomeFurnitureCheckRayCastFunitureNode.lua new file mode 100644 index 00000000..d90fa9a9 --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeFurniture/XHomeFurnitureNode/XHomeFurnitureCheckRayCastFunitureNode.lua @@ -0,0 +1,14 @@ +local XHomeFurnitureCheckRayCastFunitureNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "HomeFurnitureCheckRayCastFuniture", CsBehaviorNodeType.Decorator, true, true) + +function XHomeFurnitureCheckRayCastFunitureNode:OnUpdate(dt) + local result = self.AgentProxy:CheckRayCastFurnitureNode() + + if not result then + self.Node.ChildNode:OnReset() + self.Node.Status = CsNodeStatus.FAILED + return + end + + self.Node.ChildNode:OnUpdate(dt) + self.Node.Status = self.Node.ChildNode.Status +end \ No newline at end of file diff --git a/Resources/Scripts/XHome/XDorm/XHomeFurniture/XHomeFurnitureNode/XHomeFurnitureDoActionOnlyNode.lua b/Resources/Scripts/XHome/XDorm/XHomeFurniture/XHomeFurnitureNode/XHomeFurnitureDoActionOnlyNode.lua new file mode 100644 index 00000000..3b26880d --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeFurniture/XHomeFurnitureNode/XHomeFurnitureDoActionOnlyNode.lua @@ -0,0 +1,22 @@ +local XHomeFurnitureDoActionOnlyNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "HomeFurnitureDoActionOnly",CsBehaviorNodeType.Action,true,false) + +function XHomeFurnitureDoActionOnlyNode:OnAwake() + if self.Fields == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + if self.Fields["ActionId"] == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + self.ActionId = self.Fields["ActionId"] + self.CrossDuration = self.Fields["CrossDuration"] + self.NeedFadeCross = self.Fields["NeedFadeCross"] +end + +function XHomeFurnitureDoActionOnlyNode:OnEnter() + self.AgentProxy:DoActionNode(self.ActionId,self.NeedFadeCross,self.CrossDuration) + self.Node.Status = CsNodeStatus.SUCCESS +end \ No newline at end of file diff --git a/Resources/Scripts/XHome/XDorm/XHomeFurniture/XHomeFurnitureNode/XHomeFurnitureDoEffectNode.lua b/Resources/Scripts/XHome/XDorm/XHomeFurniture/XHomeFurnitureNode/XHomeFurnitureDoEffectNode.lua new file mode 100644 index 00000000..b940c393 --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeFurniture/XHomeFurnitureNode/XHomeFurnitureDoEffectNode.lua @@ -0,0 +1,20 @@ +local XHomeFurnitureDoEffectNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "HomeFurnitureDoEffect",CsBehaviorNodeType.Action,true,false) + +function XHomeFurnitureDoEffectNode:OnAwake() + if self.Fields == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + if self.Fields["EffectId"] == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + self.EffectId = self.Fields["EffectId"] +end + +function XHomeFurnitureDoEffectNode:OnEnter() + self.AgentProxy:DoEffectNode(self.EffectId) + self.Node.Status = CsNodeStatus.SUCCESS +end \ No newline at end of file diff --git a/Resources/Scripts/XHome/XDorm/XHomeFurniture/XHomeFurnitureNode/XHomeFurnitureHideNode.lua b/Resources/Scripts/XHome/XDorm/XHomeFurniture/XHomeFurnitureNode/XHomeFurnitureHideNode.lua new file mode 100644 index 00000000..74f90590 --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeFurniture/XHomeFurnitureNode/XHomeFurnitureHideNode.lua @@ -0,0 +1,6 @@ +local XHomeFurnitureHideNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "HomeFurnitureHide", CsBehaviorNodeType.Action, true, false) + +function XHomeFurnitureHideNode:OnEnter() + self.AgentProxy:HideFurnitureNode() + self.Node.Status = CsNodeStatus.SUCCESS +end \ No newline at end of file diff --git a/Resources/Scripts/XHome/XDorm/XHomeFurniture/XHomeFurnitureNode/XHomeFurnitureResetFurniturePositionNode.lua b/Resources/Scripts/XHome/XDorm/XHomeFurniture/XHomeFurnitureNode/XHomeFurnitureResetFurniturePositionNode.lua new file mode 100644 index 00000000..c93c3473 --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeFurniture/XHomeFurnitureNode/XHomeFurnitureResetFurniturePositionNode.lua @@ -0,0 +1,6 @@ +local XHomeFurnitureResetFurniturePositionNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "HomeFurnitureResetFurniturePosition", CsBehaviorNodeType.Action, true, false) + +function XHomeFurnitureResetFurniturePositionNode:OnEnter() + self.AgentProxy:ResetFurnituePistionNode() + self.Node.Status = CsNodeStatus.SUCCESS +end \ No newline at end of file diff --git a/Resources/Scripts/XHome/XDorm/XHomeFurniture/XHomeFurnitureNode/XHomeFurnitureSaveFurnitureInRoomNode.lua b/Resources/Scripts/XHome/XDorm/XHomeFurniture/XHomeFurnitureNode/XHomeFurnitureSaveFurnitureInRoomNode.lua new file mode 100644 index 00000000..578457fa --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeFurniture/XHomeFurnitureNode/XHomeFurnitureSaveFurnitureInRoomNode.lua @@ -0,0 +1,6 @@ +local XHomeFurnitureSaveFurnitureInRoomNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "HomeFurnitureSaveFurnitureInRoom", CsBehaviorNodeType.Action, true, false) + +function XHomeFurnitureSaveFurnitureInRoomNode:OnEnter() + self.AgentProxy:SaveFurnitureInRoomNode() + self.Node.Status = CsNodeStatus.SUCCESS +end \ No newline at end of file diff --git a/Resources/Scripts/XHome/XDorm/XHomeFurniture/XHomeFurnitureNode/XHomeFurnitureSaveSuccessNode.lua b/Resources/Scripts/XHome/XDorm/XHomeFurniture/XHomeFurnitureNode/XHomeFurnitureSaveSuccessNode.lua new file mode 100644 index 00000000..4add0163 --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeFurniture/XHomeFurnitureNode/XHomeFurnitureSaveSuccessNode.lua @@ -0,0 +1,21 @@ +local XHomeFurnitureSaveSuccessNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "HomeFurnitureSaveSuccess", CsBehaviorNodeType.Condition, true, false) + +function XHomeFurnitureSaveSuccessNode:OnGetEvents() + return { XEventId.EVENT_DORM_FURNITURE_PUT_SUCCESS } + end + + function XHomeFurnitureSaveSuccessNode:OnEnter() + self.Id = self.AgentProxy:GetId() + end + + function XHomeFurnitureSaveSuccessNode:OnNotify(evt,...) + local args = {...} + + if evt == XEventId.EVENT_DORM_FURNITURE_PUT_SUCCESS and args[1] == self.Id then + if args[2] then + self.Node.Status = CsNodeStatus.SUCCESS + else + self.Node.Status = CsNodeStatus.FAILED + end + end + end \ No newline at end of file diff --git a/Resources/Scripts/XHome/XDorm/XHomeFurniture/XHomeFurnitureNode/XHomeFurnitureStateChangeNode.lua b/Resources/Scripts/XHome/XDorm/XHomeFurniture/XHomeFurnitureNode/XHomeFurnitureStateChangeNode.lua new file mode 100644 index 00000000..8710a351 --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeFurniture/XHomeFurnitureNode/XHomeFurnitureStateChangeNode.lua @@ -0,0 +1,22 @@ +local XHomeFurnitureStateChangeNode = XLuaBehaviorManager.RegisterNode(XLuaBehaviorNode, "HomeFurnitureStateChange",CsBehaviorNodeType.Action,true,false) + +function XHomeFurnitureStateChangeNode:OnAwake() + if self.Fields == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + if self.Fields["State"] == nil then + self.Node.Status = CsNodeStatus.ERROR + return + end + + self.State = self.Fields["State"] +end + + +function XHomeFurnitureStateChangeNode:OnEnter() + self.AgentProxy:ChangeStatus(self.State) + self.Node.Status = CsNodeStatus.SUCCESS +end + diff --git a/Resources/Scripts/XHome/XDorm/XHomeFurnitureObj.lua b/Resources/Scripts/XHome/XDorm/XHomeFurnitureObj.lua new file mode 100644 index 00000000..414a7d75 --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeFurnitureObj.lua @@ -0,0 +1,1392 @@ +--- +--- 宿舍家具对象 +--- +local TEST_FURNITURE_NAME = "Furniture003" --Test +local XSceneObject = require("XHome/XSceneObject") + +local XHomeFurnitureObj = XClass(XSceneObject, "XHomeFurnitureObj") +local Vector3 = CS.UnityEngine.Vector3 +local WallNum = 4 +local PutOnOffeY = 0.75 + +function XHomeFurnitureObj:Ctor(data, room) + self.Data = data + self.Room = room + self.ConfirmGridX = self.Data.GridX + self.ConfirmGridY = self.Data.GridY + self.ConfirmRotate = self.Data.RotateAngle + self.CfgId = self.Data.CfgId + self.GridOffset = CS.XGame.ClientConfig:GetFloat("DormGroundGridMeshHighOffset") + + self.OnWallFixGridPos = {} + self.OnWallFixGridPos[0] = Vector3(0, 0.5 * XHomeDormManager.GetMapTall() * XHomeDormManager.GetCeilSize(), 0.5 * XHomeDormManager.GetMapHeight() * XHomeDormManager.GetCeilSize() - self.GridOffset) + self.OnWallFixGridPos[1] = Vector3(0.5 * XHomeDormManager.GetMapWidth() * XHomeDormManager.GetCeilSize() - self.GridOffset, 0.5 * XHomeDormManager.GetMapTall() * XHomeDormManager.GetCeilSize(), 0) + self.OnWallFixGridPos[2] = Vector3(0, 0.5 * XHomeDormManager.GetMapTall() * XHomeDormManager.GetCeilSize(), -0.5 * XHomeDormManager.GetMapHeight() * XHomeDormManager.GetCeilSize() + self.GridOffset) + self.OnWallFixGridPos[3] = Vector3(-0.5 * XHomeDormManager.GetMapWidth() * XHomeDormManager.GetCeilSize() + self.GridOffset, 0.5 * XHomeDormManager.GetMapTall() * XHomeDormManager.GetCeilSize(), 0) + + self.InteractInfoList = {} + self.InterGos = {} + self.Cfg = XFurnitureConfigs.GetFurnitureTemplateById(self.Data.CfgId) + if self.Cfg then + self.PlaceType = XFurnitureConfigs.GetFurniturePlaceType(self.Cfg.TypeId) + end + + self.HomePlatType = nil + if self.PlaceType == XFurniturePlaceType.OnGround then + self.HomePlatType = XFurnitureConfigs.HomePlatType.Ground + elseif self.PlaceType == XFurniturePlaceType.OnWall then + self.HomePlatType = XFurnitureConfigs.HomePlatType.Wall + end + self:SetPos(self.ConfirmGridX, self.ConfirmGridY, self.ConfirmRotate) + + self.IsSelected = false + self.IsMapBlock = false + self.IsFurnitureBlock = false + self.IsColliderBlock = false + + self.IsShowGlow = false + self.IsAddDragComponent = false + self.AninationIndex = 0 + self.RippleWater = nil +end + +function XHomeFurnitureObj:Dispose() + XHomeFurnitureObj.Super.Dispose(self) + + self:HideAttrTag() + + + if not XTool.UObjIsNil(self.GridComponent) then + CS.XGridManager.Instance:FreeGrid(self.GridComponent) + end + self.GridComponent = nil + + if not XTool.UObjIsNil(self.GoInputHandler) then + self.GoInputHandler:RemoveAllListeners() + end + self.GoInputHandler = nil + + if self.NavMeshSurface and self.NavMeshSurface:Exist() then + self.NavMeshSurface:RemoveData() + end + + self.CanChange = false + self.ChangeFurnitureData = nil + self.RippleWater = nil +end + +function XHomeFurnitureObj:GetWallEffectsByRot(rot) + return self.WallEffects and self.WallEffects[rot] or nil +end + +function XHomeFurnitureObj:GetFurntiureEffect() + return self.EffectComp +end + +function XHomeFurnitureObj:OnLoadComplete() + self.Colliders = {} + local list = self.GameObject:GetComponentsInChildren(typeof(CS.UnityEngine.Collider)) + for i = 0, list.Length - 1 do + table.insert(self.Colliders, list[i]) + end + + self.Effect = self.Transform:Find("Effect") + if not XTool.UObjIsNil(self.Effect) then + self.EffectComp = self.Effect:GetComponent(typeof(CS.XPrefabLoader)) + end + + self.RippleWater = self.Transform:GetComponentInChildren(typeof(CS.XRippleWater)) + + -- 行为代理 + if self.Cfg.HasBehavior then + self.Agent = self.GameObject:GetComponent(typeof(CS.BehaviorTree.XAgent)) + if XTool.UObjIsNil(self.Agent) then + self.Agent = self.GameObject:AddComponent(typeof(CS.BehaviorTree.XAgent)) + self.Agent.ProxyType = "HomeFurniture" + self.Agent:InitProxy() + end + + self.Agent.Proxy.LuaAgentProxy:SetHomeFrunitureObj(self) + end + self.DormPutOnAnimaTime = CS.XGame.ClientConfig:GetFloat("DormPutOnAnimaTime") + self.IsPressing = false + self.CanChange = false + self.ChangeFurnitureData = nil + + -- 监听点击 + self.GoInputHandler = self.Transform:GetComponent(typeof(CS.XGoInputHandler)) + if XTool.UObjIsNil(self.GoInputHandler) then + self.GoInputHandler = self.GameObject:AddComponent(typeof(CS.XGoInputHandler)) + end + if not XTool.UObjIsNil(self.GoInputHandler) then + self.GoInputHandler:AddPointerClickListener(function(eventData) self:OnClick(eventData) end) + if self.Cfg.HasBehavior then + self.GoInputHandler:AddDragListener(function(eventData) self:OnDrag(eventData) end) + end + self.GoInputHandler:AddPressListener(function(pressTime) self:OnPress(pressTime) end) + self.GoInputHandler:AddPointerExitListener(function(eventData) self:OnPointerExit(eventData) end) + self.GoInputHandler:AddPointerUpListener(function(eventData) self:OnPointerUp(eventData) end) + end + + self.WallEffects = {} + for i = 1, WallNum do + local wallIndex = tostring(i - 1) + local wallEffect = self.Transform:Find(string.format("WallEffect%s", wallIndex)) + if wallEffect then + self.WallEffects[wallIndex] = {} + + local effectIndex = 1 + local subEffect = self.Transform:Find(string.format("WallEffect%s/Effect%d", wallIndex, effectIndex)) + if not XTool.UObjIsNil(subEffect) then + self.SubEffectComp = subEffect:GetComponent(typeof(CS.XPrefabLoader)) + end + while (self.SubEffectComp) + do + table.insert(self.WallEffects[wallIndex], effectIndex, self.SubEffectComp) + effectIndex = effectIndex + 1 + subEffect = self.Transform:Find(string.format("WallEffect%s/Effect%d", wallIndex, effectIndex)) + if not XTool.UObjIsNil(subEffect) then + self.SubEffectComp = subEffect:GetComponent(typeof(CS.XPrefabLoader)) + else + self.SubEffectComp = nil + end + end + end + end + + if self.PlaceType == XFurniturePlaceType.Ceiling then + self.GameObject:SetLayerRecursively(CS.UnityEngine.LayerMask.NameToLayer(HomeSceneLayerMask.Block)) + else + self.GameObject:SetLayerRecursively(CS.UnityEngine.LayerMask.NameToLayer(HomeSceneLayerMask.Device)) + end + + self:SetData(self.Data) + if self.PlaceType == XFurniturePlaceType.Ground then + self.NavMeshSurface = CS.XNavMeshUtility.SetNavMeshSurfaceAndBuild(self.GameObject) --self.GameObject:AddComponent(typeof(CS.UnityEngine.AI.NavMeshSurface)) + elseif self.Cfg.IsObstacle == 1 then + CS.XNavMeshUtility.AddNavMeshObstacle(self.GameObject) + end + + self.Animator = self.GameObject:GetComponent(typeof(CS.UnityEngine.Animator)) + self:ChangeStatus(XHomeBehaviorStatus.IDLE, true) +end + +function XHomeFurnitureObj:SetData(data) + self.Data = data + self.ConfirmGridX = self.Data.GridX + self.ConfirmGridY = self.Data.GridY + self.ConfirmRotate = self.Data.RotateAngle + + self:SetPos(self.ConfirmGridX, self.ConfirmGridY, self.ConfirmRotate) +end + +function XHomeFurnitureObj:GetData() + return self.ConfirmGridX, self.ConfirmGridY, self.ConfirmRotate +end + +function XHomeFurnitureObj:GetXHomePlatType() + if self.Cfg == nil then + return + end + + if self.Cfg.LocateType ~= XFurnitureConfigs.HomeLocateType.Replace then + if self.Cfg.Model == TEST_FURNITURE_NAME then + -- Test + local scale = self.Transform.localScale + self.Transform.localScale = Vector3(self.Cfg.Width, scale.y, self.Cfg.Height) + end + end + + return XFurnitureConfigs.LocateTypeToXHomePlatType(self.Cfg.LocateType) +end + +function XHomeFurnitureObj:GetSize() + if self.Cfg == nil then + return 0, 0 + end + + return self.Cfg.Width, self.Cfg.Height +end + +function XHomeFurnitureObj:RippleAddChar(charTrans) + if self.RippleWater then + self.RippleWater:AddTriggerRippleObject_Unique(charTrans) + end +end + +function XHomeFurnitureObj:RippleRemoveChar(charTrans) + if self.RippleWater then + self.RippleWater:RemoveTriggerRippleObject(charTrans) + end +end + +function XHomeFurnitureObj:RippleClearChar() + if self.RippleWater then + self.RippleWater:ClearTriggerRippleObject() + end +end + +-- 检测是否可在该位置摆放 +function XHomeFurnitureObj:CheckCanLocate() + return not self.IsMapBlock and not self.IsFurnitureBlock and not self.IsColliderBlock +end + +-- 设置家具位置 +function XHomeFurnitureObj:SetPos(x, y, rotate) + self.GridX = x + self.GridY = y + self.RotateAngle = rotate + + if XTool.UObjIsNil(self.Transform) then + return + end + if self.Cfg == nil then + return + end + + if self.PlaceType == XFurniturePlaceType.Ground or + self.PlaceType == XFurniturePlaceType.Wall or + self.PlaceType == XFurniturePlaceType.Ceiling then + --地板、墙、天花板为固定 + self.GridX = 0 + self.GridY = 0 + self.RotateAngle = 0 + elseif self.PlaceType == XFurniturePlaceType.OnWall then + -- 摆放在墙上的家具 + local platCfgId = self.Room:GetPlatId(CS.XHomePlatType.Wall) + + -- 检测是否有家具阻挡 + self.IsFurnitureBlock = XHomeDormManager.CheckRoomFurnitureBlock(self.Room.Data.Id, self.Data.Id, self.GridX, self.GridY, self.Cfg.Width, self.Cfg.Height, CS.XHomePlatType.Wall, self.RotateAngle) + -- 检测地表是否有障碍阻挡 + local isBlock, pos = XHomeDormManager.CheckMultiBlock(platCfgId, self.GridX, self.GridY, self.Cfg.Width, self.Cfg.Height, CS.XHomePlatType.Wall, self.RotateAngle) + + -- 合并两种阻挡 + self.IsMapBlock = isBlock + + pos = self.Room.Transform.localToWorldMatrix:MultiplyPoint(pos) + self.Transform.position = pos + self.Transform.localEulerAngles = Vector3(0, self.RotateAngle * 90, 0) + + elseif self.PlaceType == XFurniturePlaceType.OnGround then + --摆放在地板上家具 + if self.Cfg.LocateType ~= XFurnitureConfigs.HomeLocateType.Replace then + if self.Cfg.Model == TEST_FURNITURE_NAME then + -- Test + local scale = self.Transform.localScale + self.Transform.localScale = Vector3(self.Cfg.Width, scale.y, self.Cfg.Height) + end + end + + local platCfgId = self.Room:GetPlatId(CS.XHomePlatType.Ground) + + -- 检测是否有家具阻挡 + self.IsFurnitureBlock = XHomeDormManager.CheckRoomFurnitureBlock(self.Room.Data.Id, self.Data.Id, self.GridX, self.GridY, self.Cfg.Width, self.Cfg.Height, CS.XHomePlatType.Ground, self.RotateAngle) + -- 检测地表是否有障碍阻挡 + local isBlock, pos = XHomeDormManager.CheckMultiBlock(platCfgId, self.GridX, self.GridY, self.Cfg.Width, self.Cfg.Height, CS.XHomePlatType.Ground, self.RotateAngle) + -- 合并两种阻挡 + self.IsMapBlock = isBlock + + pos = self.Room.Transform.localToWorldMatrix:MultiplyPoint(pos) + self.Transform.position = pos + self.Transform.localEulerAngles = Vector3(0, self.RotateAngle * 90, 0) + + end + + self.IsColliderBlock = XHomeDormManager.CheckRoomFurnitureCollider(self, self.Room.Data.Id) + + self:ShowSelectGrid() +end + +-- 生成家具交互信息 +function XHomeFurnitureObj:GenerateInteractInfo(roomMap) + if not roomMap then + return + end + + self.InteractInfoList = {} + local sumIndex = self.Cfg.InteractPos or 0 + for k=1, sumIndex do + local stayPoint = self.GameObject:FindGameObject("StayPos" .. tostring(k)) + local interactPoint = self.GameObject:FindGameObject("Interactpos" .. tostring(k)) + if interactPoint == nil then + if XMain.IsEditorDebug then + XLog.Error(string.format("%s 缺少交互点%s号", self.Cfg.Name, k)) + end + break + end + local gridPos, isValid = self:GetInteractGridPos(interactPoint.transform) + local block = roomMap:GetGridInfo(gridPos.x, gridPos.y) + local blockMask = CS.XRoomMapInfo.GetMapGridMask(block, CS.XRoomBlockType.Blocked, CS.XRoomBlockType.Furniture) + + local info = {} + info.Index = k + info.GridPos = gridPos + if isValid and (blockMask <= 0) then + info.UsedType = XFurnitureInteractUsedType.None + else + info.UsedType = XFurnitureInteractUsedType.Block + if XMain.IsEditorDebug then + -- XLog.Error(string.format("家具(%s)的%s号交互点被遮挡,网格坐标:%s,%s (仅作提示不卡流程)", self.Cfg.Name, k, gridPos.x, gridPos.y)) + end + end + + if not XTool.UObjIsNil(stayPoint) then + local stayPos = stayPoint.transform.position + local stayIsInBound = XHomeDormManager.WorldPosCheckIsInBound(stayPos, self.Room.Transform) + if stayIsInBound then + info.StayType = XFurnitureInteractUsedType.None + else + info.StayType = XFurnitureInteractUsedType.Block + end + end + info.StayPos = stayPoint + info.InteractPos = interactPoint + info.PosIndex = k + info.BehaviorType = self.Cfg.BehaviorType[k] or self.Cfg.BehaviorType[1]-- 标记互动点序号以分别不同角色在不同点的互动 + info.AttractBehaviorType = self.Cfg.AttractBehaviorType[k] or self.Cfg.AttractBehaviorType[1]-- 标记互动点序号以分别不同角色在不同点的互动 + table.insert(self.InteractInfoList, info) + end + + return self.InteractInfoList +end + +function XHomeFurnitureObj:GetInteractGridPos(transform) + local isValid = true + local gridPos = XHomeDormManager.GetGridPosByWorldPos(transform.position, transform, 0, 0) + + if gridPos.x > XHomeDormManager.GetMapWidth() or gridPos.y > XHomeDormManager.GetMapHeight() or gridPos.x < 0 or gridPos.y < 0 then + isValid = false + XLog.Error("交互位置信息无效,不在地图绑定范围内") + end + + return gridPos, isValid +end + +-- 获取家具交互点信息 +function XHomeFurnitureObj:GetInteractInfoList() + if not self.InteractInfoList or _G.next(self.InteractInfoList) == nil then + local roomMap = CS.XRoomMapInfo.GenerateMap(self.CfgId) + self:GenerateInteractInfo(roomMap) + end + + return self.InteractInfoList +end + +-- 设置家具交互点信息 +function XHomeFurnitureObj:SetInteractInfoGo() + if self.IsSetInterGo then + if _G.next(self.InterGos) then + for _, v in pairs(self.InterGos) do + if v then + v.gameObject:SetActive(true) + end + end + return + end + end + + local intergo = self.Room.FurnitureRoot.gameObject:FindGameObject("InterPosIcon") + if not intergo then + return + end + local infos = self:GetInteractInfoList() + for k, v in pairs(infos) do + local itemobj = CS.UnityEngine.Object.Instantiate(intergo, v.InteractPos.transform) + itemobj.transform.localPosition = Vector3(0, 0.1, 0) + itemobj.transform.localRotation = CS.UnityEngine.Quaternion.Euler(90, 0, 0) + itemobj.gameObject:SetActive(true) + self.InterGos[k] = itemobj + end + self.IsSetInterGo = true +end + +function XHomeFurnitureObj:HideInteractInfoGo() + if self.IsSetInterGo and self.InterGos then + for _, v in pairs(self.InterGos) do + if v then + v.gameObject:SetActive(false) + end + end + end +end + +function XHomeFurnitureObj:GetInteractInfoGo() + return self.InterGos +end + +-- 获取最近家具交互点信息 +function XHomeFurnitureObj:GetNearAvailableInteract(position, characterId) + local interactInfo = nil + local lastDistance = 0 + + for _, info in ipairs(self.InteractInfoList) do + local haveBehavior = false + local relation = XDormConfig.GetDormF2CBehaviorRelative(self.Cfg.Id, characterId, info.PosIndex) + if relation then + haveBehavior = true + else + if info.UsedType == XFurnitureInteractUsedType.None or info.UsedType == XFurnitureInteractUsedType.Block and + XDormConfig.GetCharacterBehavior(characterId, info.AttractBehaviorType) then + haveBehavior = true + end + end + if haveBehavior then + local distance = Vector3.Distance(position, info.StayPos.transform.position) + if lastDistance <= 0 or distance < lastDistance then + interactInfo = info + lastDistance = distance + end + end + end + + return interactInfo +end + +-- 获取家具交互点信息 +function XHomeFurnitureObj:GetAvailableInteract(characterId) + for _, info in ipairs(self.InteractInfoList) do + local relation = XDormConfig.GetDormF2CBehaviorRelative(self.Cfg.Id, characterId, info.PosIndex) + if relation then return info end + if info.UsedType == XFurnitureInteractUsedType.None or info.UsedType == XFurnitureInteractUsedType.Block then + if info.StayType and info.StayType ~= XFurnitureInteractUsedType.Block + and XDormConfig.GetCharacterBehavior(characterId, info.BehaviorType) then + return info + end + end + end + + return nil +end + +-- 通过构造体ID获取交互中的家具交互点信息 +function XHomeFurnitureObj:GetInteractById(characterId) + if not self.InteractInfoList then + return nil + end + + for _, v in ipairs(self.InteractInfoList) do + if (v.UsedType & XFurnitureInteractUsedType.Character) > 0 and characterId == v.CharacterId then + return v + end + end + + return nil +end +--=================== +-- 检测交互点是否能交互 +-- @param gridX:要检测的网格位置X坐标 +-- @param gridY:要检测的网格位置Y坐标 +-- @param charId:角色ID +--=================== +function XHomeFurnitureObj:CheckCanInteract(gridX, gridY, charId) + for _, info in ipairs(self.InteractInfoList) do + local haveBehavior = false + local relation = XDormConfig.GetDormF2CBehaviorRelative(self.Cfg.Id, charId, info.PosIndex) + if relation then + haveBehavior = true + else + local state = XDormConfig.GetCharacterBehavior(charId, info.BehaviorType) + haveBehavior = state ~= nil + end + if haveBehavior and info.GridPos.x == gridX and info.GridPos.y == gridY then + return info.UsedType == XFurnitureInteractUsedType.None + end + end + + return false +end + +-- 获取交互点 +function XHomeFurnitureObj:GetInteract(gridX, gridY) + for _, info in ipairs(self.InteractInfoList) do + if info.GridPos.x == gridX and info.GridPos.y == gridY then + return info + end + end + + return nil +end + +-- 显示占位网格 +function XHomeFurnitureObj:ShowFixGrid(isShow, rotate) + if not isShow then + if not XTool.UObjIsNil(self.WallFixGridComponents) then + self.WallFixGridComponents.gameObject:SetActive(false) + end + + if not XTool.UObjIsNil(self.GroundFixGridComponent) then + self.GroundFixGridComponent.gameObject:SetActive(false) + end + return + end + + if not self.PlaceType or self.PlaceType == XFurniturePlaceType.Ceiling or + self.PlaceType == XFurniturePlaceType.OnGround or + self.PlaceType == XFurniturePlaceType.OnWall then + return + end + + if self.PlaceType == XFurniturePlaceType.Ground then + local w = XHomeDormManager.GetMapWidth() + local h = XHomeDormManager.GetMapHeight() + + if XTool.UObjIsNil(self.GroundFixGridComponent) then + self.GroundFixGridComponent = CS.XGridManager.Instance:GetGrid(h, w, false, XHomeDormManager.GetCeilSize()) + local fixtransform = self.GroundFixGridComponent.transform + fixtransform.eulerAngles = self.Transform.eulerAngles + + fixtransform.position = self.Transform.position + Vector3(0, self.GridOffset, 0) + end + + self.GroundFixGridComponent.gameObject:SetActive(true) + + local so = XHomeDormManager.GetGridColorSO(GridColorType.Default) + self.GroundFixGridComponent:SetGridColorInfo(so.Asset) + elseif self.PlaceType == XFurniturePlaceType.Wall then + if not rotate then + return + end + + local mapWidth, mapHeight + local rot = rotate % 2 + if rot == 0 then + mapWidth = XHomeDormManager.GetMapWidth() + mapHeight = XHomeDormManager.GetMapTall() + else + mapWidth = XHomeDormManager.GetMapHeight() + mapHeight = XHomeDormManager.GetMapTall() + end + + if XTool.UObjIsNil(self.WallFixGridComponents) then + self.WallFixGridComponents = CS.XGridManager.Instance:GetGrid(mapHeight, mapWidth, true, XHomeDormManager.GetCeilSize()) + end + + local fixtransform = self.WallFixGridComponents.transform + local offset = self.OnWallFixGridPos[rotate] + fixtransform.position = self.Transform.position + offset + fixtransform.eulerAngles = self.Transform.eulerAngles + Vector3(0, 90 * rotate, 0) + + self.WallFixGridComponents.gameObject:SetActive(true) + + local so = XHomeDormManager.GetGridColorSO(GridColorType.Default) + self.WallFixGridComponents:SetGridColorInfo(so.Asset) + end +end + +-- 显示选中网格 +function XHomeFurnitureObj:ShowSelectGrid() + if self.IsSelected and not self.IsAddDragComponent then + if not self.Cfg.HasBehavior then + self.GoInputHandler:AddDragListener(function(eventData) self:OnDrag(eventData) end) + end + self.IsAddDragComponent = true + end + if not self.IsSelected and self.IsAddDragComponent then + if not self.Cfg.HasBehavior then + self.GoInputHandler:RemoveDragListener() + end + self.IsAddDragComponent = false + end + + local isBlock = not self:CheckCanLocate() + if not self.IsSelected then + if not XTool.UObjIsNil(self.GridComponent) then + self.GridComponent.gameObject:SetActive(false) + end + if not XTool.UObjIsNil(self.FurniturePlaceHolder) then + self.FurniturePlaceHolder.gameObject:SetActive(false) + end + return + end + + if not self.PlaceType then + return + end + + if self.PlaceType == XFurniturePlaceType.OnGround then + local rot = self.RotateAngle % 2 + local w, h + if rot == 0 then + w = self.Cfg.Width + h = self.Cfg.Height + else + w = self.Cfg.Height + h = self.Cfg.Width + end + + local left = self.GridX + local right = XHomeDormManager.GetMapWidth() - self.GridX - w + local up = XHomeDormManager.GetMapHeight() - self.GridY - h + local down = self.GridY + + if left < 0 then + left = 0 + end + if right < 0 then + right = 0 + end + if up < 0 then + up = 0 + end + if down < 0 then + down = 0 + end + + if XTool.UObjIsNil(self.GridComponent) then + self.GridComponent = CS.XGridManager.Instance:GetCrossGrid(h, w, left, right, + up, down, false, XHomeDormManager.GetCeilSize()) + self.GridComponent.gameObject.name = "GridComponent" + self.GridComponent.transform.localEulerAngles = Vector3.zero + self.GridComponent.transform.localScale = Vector3.one + else + self.GridComponent.gameObject:SetActive(true) + self.GridComponent:GenerateCrossGrid(h, w, left, right, up, down, false, XHomeDormManager.GetCeilSize()) + end + + local so + if isBlock then + so = XHomeDormManager.GetGridColorSO(GridColorType.Red) + else + so = XHomeDormManager.GetGridColorSO(GridColorType.Blue) + end + self.GridComponent:SetGridColorInfo(so.Asset) + self.GridComponent.transform.position = self.Transform.position + Vector3(0, self.GridOffset, 0) + elseif self.PlaceType == XFurniturePlaceType.OnWall then + local w = self.Cfg.Width + local h = self.Cfg.Height + + local mapWidth, mapHeight + local rot = self.RotateAngle % 2 + if rot == 0 then + mapWidth = XHomeDormManager.GetMapWidth() + mapHeight = XHomeDormManager.GetMapTall() + else + mapWidth = XHomeDormManager.GetMapHeight() + mapHeight = XHomeDormManager.GetMapTall() + end + + local left = self.GridX + local right = mapWidth - self.GridX - w + local up = mapHeight - self.GridY - h + local down = self.GridY + + if left < 0 then + left = 0 + end + if right < 0 then + right = 0 + end + if up < 0 then + up = 0 + end + if down < 0 then + down = 0 + end + + if XTool.UObjIsNil(self.GridComponent) then + self.GridComponent = CS.XGridManager.Instance:GetCrossGrid(h, w, left, right, + up, down, true, XHomeDormManager.GetCeilSize()) + self.GridComponent.gameObject.name = "GridComponent" + self.GridComponent.transform.localEulerAngles = Vector3.zero + self.GridComponent.transform.localScale = Vector3.one + else + self.GridComponent.gameObject:SetActive(true) + self.GridComponent:GenerateCrossGrid(h, w, left, right, + up, down, true, XHomeDormManager.GetCeilSize()) + end + + local offset + if self.RotateAngle == 0 then + offset = Vector3(0, 0, -0.01 - self.GridOffset) + elseif self.RotateAngle == 1 then + offset = Vector3(-0.01 - self.GridOffset, 0, 0) + elseif self.RotateAngle == 2 then + offset = Vector3(0, 0, 0.01 + self.GridOffset) + elseif self.RotateAngle == 3 then + offset = Vector3(0.01 + self.GridOffset, 0, 0) + end + self.GridComponent.transform.position = self.Transform.position + Vector3(0, 0.5 * h * XHomeDormManager.GetCeilSize(), 0) + offset + self.GridComponent.transform.eulerAngles = self.Transform.eulerAngles + + local so + if isBlock then + so = XHomeDormManager.GetGridColorSO(GridColorType.Red) + else + so = XHomeDormManager.GetGridColorSO(GridColorType.Blue) + end + self.GridComponent:SetGridColorInfo(so.Asset) + end +end + +-- 获取家具位置 +function XHomeFurnitureObj:GetPos() + return self.GridX, self.GridY, self.RotateAngle +end + +-- 恢复家具位置 +function XHomeFurnitureObj:RevertPosition() + self.IsSelected = false + self:SetPos(self.ConfirmGridX, self.ConfirmGridY, self.ConfirmRotate) +end + +-- 收纳家具 +function XHomeFurnitureObj:Storage(isMulti) + self.IsSelected = false + self.InteractInfoList = {} + self:RippleClearChar() + self.GameObject:SetActive(false) + if not XTool.UObjIsNil(self.GridComponent) then + CS.XGridManager.Instance:FreeGrid(self.GridComponent) + end + self.GridComponent = nil + + if not isMulti then + XHomeDormManager.RemoveFurniture(self.Room.Data.Id, self) + end + CsXGameEventManager.Instance:Notify(XEventId.EVENT_FURNITURE_ONDRAGITEM_CHANGED, true, self.Data.Id) + + self:Dispose() + self:HideInteractInfoGo() +end + +-- 检测类型数量限制 +function XHomeFurnitureObj:CheckPutTypeCountReachLimit() + return XHomeDormManager.CheckFurnitureCountReachLimit(self.Room.Data.Id, self) +end + +-- 确定放置家具 +function XHomeFurnitureObj:LocateFurniture() + self.ConfirmGridX = self.GridX + self.ConfirmGridY = self.GridY + self.ConfirmRotate = self.RotateAngle + + self.IsSelected = false + self:ShowSelectGrid() + + XHomeDormManager.AddFurniture(self.Room.Data.Id, self) + + self:ShowAttrTag() + CsXGameEventManager.Instance:Notify(XEventId.EVENT_FURNITURE_ONDRAGITEM_CHANGED, false, self.Data.Id) +end + +function XHomeFurnitureObj:CancelSelect() + --TODO + self:ShowSelectGrid() +end + +-- 点击家具 +function XHomeFurnitureObj:OnClick(eventData) + if self.PlaceType == XFurniturePlaceType.Ground or + self.PlaceType == XFurniturePlaceType.Wall or + self.PlaceType == XFurniturePlaceType.Ceiling then + return + end + + if self.IsDrag then + self.IsDrag = false + return + end + + if XHomeDormManager.CheckSelectedFurniture() then + return + end + + if not XDataCenter.FurnitureManager.GetInRefeform() then + if not self:CheckCanBehavior() then + self:PlayClickAnimation() + else + self:OnBehaviorClick(eventData) + end + end + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_CLICKFURNITURE_ONROOM, self.Data.Id) + XHomeDormManager.FireClickFurnitureCallback(self) + self:ShowSelectGrid() +end + +-- 拖动家具 +function XHomeFurnitureObj:OnDrag(eventData) + if self.PlaceType == XFurniturePlaceType.Ground or + self.PlaceType == XFurniturePlaceType.Wall or + self.PlaceType == XFurniturePlaceType.Ceiling then + return + end + + if not XDataCenter.FurnitureManager.GetInRefeform() then + self:OnBehaviorDrag(eventData) + return false + end + + if not self.IsSelected then + return false + end + + self.IsDrag = true + + local pos = eventData.position + return self:AdjustPosition(pos) +end + +function XHomeFurnitureObj:GetCenterPosition() + if self.CenterObj then + return self.CenterObj.position + else + self.CenterObj = self.Transform:Find("CenterPos") + if self.CenterObj then + return self.CenterObj.position + else + return self.Transform.position + end + end +end + +-- 调整家具位置 +function XHomeFurnitureObj:AdjustPosition(screenPos) + if self.Cfg == nil then + return false + end + + local camera = XHomeSceneManager.GetSceneCamera() + if XTool.UObjIsNil(camera) then + return false + end + + local ray = camera:ScreenPointToRay(Vector3(screenPos.x, screenPos.y, 0)) + local layerMask = CS.UnityEngine.LayerMask.GetMask("HomeSurface") + if (layerMask) then + local ret, hit = ray:RayCast(layerMask) + if ret then + local width = self.Cfg.Width + local height = self.Cfg.Height + if self.PlaceType == XFurniturePlaceType.OnGround then + local rot = self.RotateAngle % 2 + if rot == 1 then + width = self.Cfg.Height + height = self.Cfg.Width + end + end + + local gridPos = XHomeDormManager.GetGridPosByWorldPos(hit.point, hit.transform, width, height) + self:SetPos(gridPos.x, gridPos.y, self.RotateAngle) + end + end + self:SetInteractInfoGo() + + return true +end + +-- 播放家具交互动画 +function XHomeFurnitureObj:PlayInteractAnimation(characterId) + if not characterId then + return + end + + local animationName = XFurnitureConfigs.GetDormFurnitureAnimationByCharId(self.Data.CfgId, characterId) + if not animationName then + return + end + + self.Animator:Play(animationName) +end + +-- 播放家具点击动画 +function XHomeFurnitureObj:PlayClickAnimation() + local animationType = XFurnitureConfigs.GetOnceAnimationType(self.Data.CfgId) + if animationType == XFurnitureConfigs.FurnitureAnimationType.None then + return + end + + local animationName = XFurnitureConfigs.GetOnceAnimationName(self.Data.CfgId) + if not animationName then + return + end + + -- 判断是否在和构造体交互 + for _, v in ipairs(self.InteractInfoList) do + if (v.UsedType & XFurnitureInteractUsedType.Character) > 0 then + return + end + end + + if animationType == XFurnitureConfigs.FurnitureAnimationType.Once then + self.Animator:Play(animationName) + elseif animationType == XFurnitureConfigs.FurnitureAnimationType.Repeat then + if self.AninationIndex >= #animationName then + self.AninationIndex = 0 + end + + self.AninationIndex = self.AninationIndex + 1 + self.Animator:Play(animationName[self.AninationIndex]) + end +end + +-- 检测家具碰撞 +function XHomeFurnitureObj:CheckFurnitureCollision(x, y, width, height, type, rotate) + local homePlatType = XFurnitureConfigs.LocateTypeToXHomePlatType(self.Cfg.LocateType) + + -- 1.不同地表的物体,永不相交 + if homePlatType ~= type then + return false + end + + -- 2.墙上 + if type == CS.XHomePlatType.Wall then + if rotate ~= self.ConfirmRotate then + -- 2.1不在同一面墙,永不相交 + return false + end + + -- 2.2检测两个正矩形碰撞 + local deltaX = x - self.ConfirmGridX + local deltaY = y - self.ConfirmGridY + + if (deltaX > 0 and deltaX >= self.Cfg.Width) or (deltaX < 0 and deltaX <= -width) or + (deltaY > 0 and deltaY >= self.Cfg.Height) or (deltaY < 0 and deltaY <= -height) then + return false + end + end + + -- 3.地板上 + if type == CS.XHomePlatType.Ground then + local deltaX = x - self.ConfirmGridX + local deltaY = y - self.ConfirmGridY + + local rot1 = self.ConfirmRotate % 2 + local w1, h1 + if rot1 == 0 then + w1 = self.Cfg.Width + h1 = self.Cfg.Height + else + w1 = self.Cfg.Height + h1 = self.Cfg.Width + end + + local rot2 = rotate % 2 + local w2, h2 + if rot2 == 0 then + w2 = width + h2 = height + else + w2 = height + h2 = width + end + + -- 3.1旋转后,检测正矩形碰撞 + if (deltaX > 0 and deltaX >= w1) or (deltaX < 0 and deltaX <= -w2) or + (deltaY > 0 and deltaY >= h1) or (deltaY < 0 and deltaY <= -h2) then + return false + end + end + + return true +end + +function XHomeFurnitureObj:RayCastSelected(isSelect) + if self.IsShowGlow == isSelect then + return + end + + if isSelect then + CS.XMaterialContainerHelper.AddRoomRim(self.GameObject) + else + CS.XMaterialContainerHelper.RemoveRoomRim(self.GameObject) + end + + self.IsShowGlow = isSelect +end + +function XHomeFurnitureObj:ShowAttrTag(attrIndex) + if not attrIndex then + attrIndex = XHomeDormManager.FurnitureShowAttrType + end + + + if attrIndex > 0 then + local furnitureData = XDataCenter.FurnitureManager.GetFurnitureById(self.Data.Id) + local furnitureType = XDataCenter.FurnitureManager.GetFurnitureConfigByUniqueId(self.Data.Id).TypeId + + local attrValue + local quality + local max + if attrIndex == XFurnitureConfigs.AttrType.AttrAll then + attrValue = furnitureData:GetScore() + quality, max = XFurnitureConfigs.GetFurnitureTotalAttrLevel(furnitureType, attrValue) + else + attrValue = furnitureData:GeAttrtScore(attrIndex, furnitureData.AttrList[attrIndex]) + quality, max = XFurnitureConfigs.GetFurnitureSingleAttrLevel(furnitureType, attrIndex, attrValue) + end + + local offset = self.Cfg.AttrTagY + local color = XFurnitureConfigs.FurnitureAttrTagColor[quality] or XFurnitureConfigs.FurnitureAttrTagColor[1] + local level = XFurnitureConfigs.FurnitureAttrLevel[quality] or XFurnitureConfigs.FurnitureAttrLevel[1] + local desc = string.format("%s%d", color, level, attrValue) + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_DORM_FURNITURE_ATTR_TAG_DETAIL, self.Room.Data.Id, self.Data.Id, self.Transform, desc, attrValue / max, color, offset) + else + CsXGameEventManager.Instance:Notify(XEventId.EVENT_DORM_FURNITURE_HIDE_ATTR_TAG_DETAIL, self.Data.Id) + end + +end + + +function XHomeFurnitureObj:HideAttrTag() + CsXGameEventManager.Instance:Notify(XEventId.EVENT_DORM_FURNITURE_HIDE_ATTR_TAG_DETAIL, self.Data.Id) +end + +function XHomeFurnitureObj:OnStateChange(state) + if state == "Enter" then + self:ShowAttrTag() + self:ShowFurnitureEffect() + self:EnableBoxColliders() + else + self:HideAttrTag() + self:HideFurnitureEffect() + self:DisableBoxColliders() + end +end + +function XHomeFurnitureObj:ShowFurnitureEffect() + if self.EffectComp and self.EffectComp.GameObject then + self.EffectComp.GameObject:SetActiveEx(true) + end +end + +function XHomeFurnitureObj:HideFurnitureEffect() + if self.EffectComp and self.EffectComp.GameObject then + self.EffectComp.GameObject:SetActiveEx(false) + end +end + +function XHomeFurnitureObj:EnableBoxColliders() + for _, v in pairs(self.Colliders or {}) do + v.enabled = true + end +end + +function XHomeFurnitureObj:DisableBoxColliders() + for _, v in pairs(self.Colliders or {}) do + v.enabled = false + end +end + +-------------------------------家具行为树相关(Start)---------------------------- +-- 家具变换位置 +function XHomeFurnitureObj:ChangeFurnituePositionNode() + if not self.CanChange then + return false + end + + -- 处理直接收纳逻辑 + if not self.ChangeFurnitureData then + self.GameObject.transform.localScale = Vector3.one + self:Storage() + self.CanChange = false + return true + end + + local x = self.ChangeFurnitureData.X + local y = self.ChangeFurnitureData.Y + local rotate = self.ChangeFurnitureData.R + self:SetPos(x, y, rotate) + + self.ConfirmGridX = x + self.ConfirmGridY = y + self.ConfirmRotate = rotate + self.GameObject.transform.localScale = Vector3.one + self.ChangeFurnitureData = nil + self.CanChange = false + return true +end + +-- 播放动作 +function XHomeFurnitureObj:DoActionNode(actionId, needFadeCross, crossDuration) + if (needFadeCross) then + self.Animator:CrossFade(actionId, crossDuration, -1, 0) + else + self.Animator:Play(actionId, -1, 0) + end +end + +-- 播放特效 +function XHomeFurnitureObj:DoEffectNode(effectId) + local effectConfig = XDormConfig.GetMoodEffectConfig(effectId) + self.EffectObj = self.Transform:LoadPrefab(effectConfig.Path, false) + self.EffectObj.transform:SetParent(self.Transform, false) + local position = CS.UnityEngine.Vector3(0, effectConfig.Hight, 0) + self.EffectObj.transform.localPosition = position +end + +-- 隐藏家具 +function XHomeFurnitureObj:HideFurnitureNode() + self.GameObject.transform.localScale = Vector3.zero +end + +-- 还原家具位置 +function XHomeFurnitureObj:ResetFurnituePistionNode() + self:SetPos(self.ConfirmGridX, self.ConfirmGridY, self.ConfirmRotate) +end + +-- 检测是否在家具上方 +function XHomeFurnitureObj:CheckRayCastFurnitureNode() + return self.IsRayCastFurniture +end + +-- 保存家具变更所在房间 +function XHomeFurnitureObj:SaveFurnitureInRoomNode() + local isBehavior = true + XHomeDormManager.SaveRoomModification(self.Room.Data.Id, isBehavior, function(isSuccess) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_DORM_FURNITURE_PUT_SUCCESS, self.Data.Id, isSuccess) + end) +end + +-- 设置位置交换数据 +function XHomeFurnitureObj:SetChangeFurnitureData(furniture) + if not furniture then + self.ChangeFurnitureData = nil + return + end + self.ChangeFurnitureData = {} + self.ChangeFurnitureData.X = furniture.ConfirmGridX + self.ChangeFurnitureData.Y = furniture.ConfirmGridY + self.ChangeFurnitureData.R = furniture.ConfirmRotate +end + +-- 隐藏特效 +function XHomeFurnitureObj:HideEffect() + if not self.EffectObj then + return + end + + self.EffectObj:SetActiveEx(false) +end + +--改变状态 +function XHomeFurnitureObj:ChangeStatus(state, ignoreReform) + if not self:CheckCanBehavior(ignoreReform) then + return + end + + if self.Status == state and self.Status ~= XHomeBehaviorStatus.IDLE then + return + end + + self:HideEffect() + self.Status = state + local temp = XFurnitureConfigs.GetFurnitureBehavior(self.Data.CfgId, state) + local behaviorTreeId = temp.BehaviorId + XLuaBehaviorManager.PlayId(behaviorTreeId, self.Agent) +end + +function XHomeFurnitureObj:CheckCanBehavior(ignoreReform) + if XDataCenter.FurnitureManager.GetInRefeform() and not ignoreReform then + return + end + + if self.Room.Data.RoomDataType ~= XDormConfig.DormDataType.Self then + return false + end + + if not self.Cfg.HasBehavior then + return false + end + + return true +end + +-- 家具侧面面对相机 +function XHomeFurnitureObj:SidewaysSceneCamera() + local currentCamera = XHomeSceneManager.GetSceneCamera() + local direction = currentCamera.transform.position - self.Transform.position + local Direct = CS.UnityEngine.Vector3(direction.z, 0, -direction.x); + self.Transform.rotation = CS.UnityEngine.Quaternion.LookRotation(Direct, CS.UnityEngine.Vector3.up); +end + +--长按 +function XHomeFurnitureObj:OnPress(pressTime) + if not self:CheckCanBehavior() then + return + end + + if self.Status ~= XHomeBehaviorStatus.GRAB_UP then + if not self.IsPressing then + XEventManager.DispatchEvent(XEventId.EVENT_CHARACTER_PUT_ON, self.Data.CfgId, self.Transform, false) + self.IsPressing = true + elseif pressTime >= self.DormPutOnAnimaTime then + self.GameObject:SetLayerRecursively(CS.UnityEngine.LayerMask.NameToLayer(HomeSceneLayerMask.HomeCharacter)) + self:SidewaysSceneCamera() + self.OrignalPosition = self.Transform.position + self.Transform.position = CS.UnityEngine.Vector3(self.OrignalPosition.x, self.OrignalPosition.y + PutOnOffeY, self.OrignalPosition.z) + self:ChangeStatus(XHomeBehaviorStatus.GRAB_UP) + XEventManager.DispatchEvent(XEventId.EVENT_CHARACTER_CATCH) + self.IsPressing = false + end + end +end + +--手指退出 +function XHomeFurnitureObj:OnPointerExit() + if not self:CheckCanBehavior() then + return + end + + if self.IsPressing then + XEventManager.DispatchEvent(XEventId.EVENT_CHARACTER_EXIT) + self.IsPressing = false + end +end + +--点击 +function XHomeFurnitureObj:OnBehaviorClick() + -- 家具行为点击预留接口 +end + +function XHomeFurnitureObj:OnBehaviorDrag(eventData) + if not self:CheckCanBehavior() then + return + end + + if self.Status ~= XHomeBehaviorStatus.GRAB_UP then + return + end + + -- 托起 + local currentCamera = XHomeSceneManager.GetSceneCamera() + local direction = self.Transform.position - currentCamera.transform.position + local z = CS.UnityEngine.Vector3.Dot(direction, currentCamera.transform.forward) + local screenPos = CS.UnityEngine.Vector3(eventData.position.x, eventData.position.y, z) + local pos = currentCamera:ScreenToWorldPoint(screenPos) + local gridPos = XHomeDormManager.WorldPosToGroundGridPos(pos, self.Room.Transform) + + --判断拖拽越界 + if gridPos.x <= 0 or gridPos.y <= 0 or gridPos.x >= XHomeDormManager.GetMapWidth() - 1 or gridPos.y >= XHomeDormManager.GetMapHeight() - 1 then + return + end + self.Transform.position = CS.UnityEngine.Vector3(pos.x, self.OrignalPosition.y + PutOnOffeY, pos.z) + --判断射线碰到家私 + local layerMask = CS.UnityEngine.LayerMask.GetMask("Device") + if layerMask then + local hit = self.Transform:PhysicsRayCast(CS.UnityEngine.Vector3.up * 100, CS.UnityEngine.Vector3.down, layerMask) + if not XTool.UObjIsNil(hit) then + local obj = XSceneEntityManager.GetEntity(hit.gameObject) + if obj.Data.Id == self.Data.Id then + return + end + + if self.PreInteractFurniture ~= nil and (obj == nil or obj.Data.Id ~= self.PreInteractFurniture.Data.Id) then + self.PreInteractFurniture:RayCastSelected(false) + self.IsRayCastFurniture = false + end + + if obj then + local selfPosChangeType = self.Cfg.PosChangeType + local targetPosChangeType = obj.Cfg.PosChangeType + local typeNoe = XFurnitureConfigs.PosChangeType.None + local canChange = targetPosChangeType ~= typeNoe and selfPosChangeType ~= typeNoe + + if canChange then + self.PreInteractFurniture = obj + self.PreInteractFurniture:RayCastSelected(true) + self.IsRayCastFurniture = true + else + if self.PreInteractFurniture then + self.PreInteractFurniture:RayCastSelected(false) + end + self.IsRayCastFurniture = false + self.PreInteractFurniture = nil + end + end + else + if self.PreInteractFurniture ~= nil then + self.PreInteractFurniture:RayCastSelected(false) + self.PreInteractFurniture = nil + self.IsRayCastFurniture = false + end + end + end +end + +--手指松开 +function XHomeFurnitureObj:OnPointerUp(eventData) + if not self:CheckCanBehavior() then + return + end + + if self.Status == XHomeBehaviorStatus.GRAB_UP or self.IsPressing then + self.GameObject:SetLayerRecursively(CS.UnityEngine.LayerMask.NameToLayer(HomeSceneLayerMask.Device)) + XEventManager.DispatchEvent(XEventId.EVENT_CHARACTER_PUT_DOWN) + end + + if self.Status == XHomeBehaviorStatus.GRAB_UP then + if not self.PreInteractFurniture then + local canChange, x, y, r = self:CheckCanPudownLocate(eventData) + if canChange then + self.CanChange = true + self.ChangeFurnitureData = {} + self.ChangeFurnitureData.X = x + self.ChangeFurnitureData.Y = y + self.ChangeFurnitureData.R = r + self:ChangeStatus(XHomeBehaviorStatus.CHNGEPOS) + end + CsXGameEventManager.Instance:Notify(XEventId.EVENT_DORM_FURNITURE_POINTER_UP_SUCCESS, self.Data.Id) + else + self.PreInteractFurniture:RayCastSelected(false) + self.IsRayCastFurniture = false + self.CanChange = true + self.PreInteractFurniture.CanChange = true + + local selfPosChangeType = self.Cfg.PosChangeType + local targetPosChangeType = self.PreInteractFurniture.Cfg.PosChangeType + if selfPosChangeType == targetPosChangeType then + self.PreInteractFurniture:SetChangeFurnitureData(self) + self:SetChangeFurnitureData(self.PreInteractFurniture) + else + self.PreInteractFurniture:SetChangeFurnitureData(nil) + self:SetChangeFurnitureData(self.PreInteractFurniture) + end + + local state = self.PreInteractFurniture.Cfg.FunitureBehaviorType + self:ChangeStatus(state) + self.PreInteractFurniture:ChangeStatus(state) + end + end + + self.PreInteractFurniture = nil + if self.IsPressing then + self.IsPressing = false + end +end + +-- 处理家具放到空位置 +function XHomeFurnitureObj:CheckCanPudownLocate(eventData) + local currentCamera = XHomeSceneManager.GetSceneCamera() + local direction = self.Transform.position - currentCamera.transform.position + local z = CS.UnityEngine.Vector3.Dot(direction, currentCamera.transform.forward) + local screenPos = CS.UnityEngine.Vector3(eventData.position.x, eventData.position.y, z) + local pos = currentCamera:ScreenToWorldPoint(screenPos) + local gridPos = XHomeDormManager.WorldPosToGroundGridPos(pos, self.Room.Transform) + local x = gridPos.x + local y = gridPos.y + local r = self.RotateAngle + local canChange + local isMapBlock = false + local isFurnitureBlock = false + local isColliderBlock + + if self.PlaceType == XFurniturePlaceType.OnWall then + local platCfgId = self.Room:GetPlatId(CS.XHomePlatType.Wall) + isFurnitureBlock = XHomeDormManager.CheckRoomFurnitureBlock(self.Room.Data.Id, self.Data.Id, x, y, self.Cfg.Width, self.Cfg.Height, CS.XHomePlatType.Wall, r) + local isBlock = XHomeDormManager.CheckMultiBlock(platCfgId, x, y, self.Cfg.Width, self.Cfg.Height, CS.XHomePlatType.Wall, r) + isMapBlock = isBlock + elseif self.PlaceType == XFurniturePlaceType.OnGround then + local platCfgId = self.Room:GetPlatId(CS.XHomePlatType.Ground) + isFurnitureBlock = XHomeDormManager.CheckRoomFurnitureBlock(self.Room.Data.Id, self.Data.Id, x, y, self.Cfg.Width, self.Cfg.Height, CS.XHomePlatType.Ground, r) + local isBlock = XHomeDormManager.CheckMultiBlock(platCfgId, x, y, self.Cfg.Width, self.Cfg.Height, CS.XHomePlatType.Ground, r) + isMapBlock = isBlock + end + + isColliderBlock = XHomeDormManager.CheckRoomFurnitureCollider(self, self.Room.Data.Id) + canChange = not isMapBlock and not isFurnitureBlock and not isColliderBlock + return canChange, x, y, r +end +-------------------------------家具行为树相关(End)---------------------------- +return XHomeFurnitureObj \ No newline at end of file diff --git a/Resources/Scripts/XHome/XDorm/XHomeRoomObj.lua b/Resources/Scripts/XHome/XDorm/XHomeRoomObj.lua new file mode 100644 index 00000000..a56c6e57 --- /dev/null +++ b/Resources/Scripts/XHome/XDorm/XHomeRoomObj.lua @@ -0,0 +1,1070 @@ +--- +--- 宿舍房间对象 +--- +local XSceneObject = require("XHome/XSceneObject") + +local XHomeRoomObj = XClass(XSceneObject, "XHomeRoomObj") + +local ROOM_DEFAULT_SO_PATH = CS.XGame.ClientConfig:GetString("RoomDefaultSoPath") +local DisplaySetType +local WallNum = 4 +local ROOM_FAR_CLIP_PLANE = 25 +local Bounds = CS.UnityEngine.Bounds + +function XHomeRoomObj:Ctor(data, facadeGo) + DisplaySetType = XDormConfig.VisitDisplaySetType + + self.Data = data + + if not XTool.UObjIsNil(facadeGo) then + self.FacadeGo = CS.UnityEngine.GameObject.Instantiate(facadeGo) + if not XTool.UObjIsNil(self.FacadeGo) then + self.RoomUnlockGo = self.FacadeGo:Find("@Unlock").gameObject + self.RoomLockGo = self.FacadeGo:Find("@Lock").gameObject + end + end + + self.IsSelected = false + self.IsCanSave = true + + self.SurfaceRoot = nil + self.CharacterRoot = nil + self.FurnitureRoot = nil + + self.Ground = nil + self.Wall = nil + self.Ceiling = nil + self.CanReachList = {} -- 构造体可行走区域列表 + + self.WallFurnitureList = {} + self.GroundFurnitureList = {} + self.WallDithers = {} + self.CharacterList = {} +end + +function XHomeRoomObj:Dispose() + self:RemoveLastWallEffectDither(self.Wall) + XHomeRoomObj.Super.Dispose(self) + + if self.WallFurnitureList then + for k, v in pairs(self.WallFurnitureList) do + for _, furniture in pairs(v) do + furniture:Dispose() + end + end + end + + if self.GroundFurnitureList then + for k, furniture in pairs(self.GroundFurnitureList) do + furniture:Dispose() + end + end + + if self.Ceiling then + self.Ceiling:Dispose() + end + + if self.Wall then + self.Wall:Dispose() + end + + + if self.Ground then + self.Ground:Dispose() + end + + + self.Ground = nil + self.Wall = nil + self.Ceiling = nil + self.WallFurnitureList = nil + self.GroundFurnitureList = nil + + + if not XTool.UObjIsNil(self.GoInputHandler) then + self.GoInputHandler:RemoveAllListeners() + end + self.GoInputHandler = nil + self.RoomMap = nil + self.InteractList = nil +end + +function XHomeRoomObj:OnLoadComplete(loadtype) + if not XTool.UObjIsNil(self.FacadeGo) then + self.FacadeGo:SetParent(self.Transform, false) + self.FacadeGo.localPosition = CS.UnityEngine.Vector3.zero + self.FacadeGo.localEulerAngles = CS.UnityEngine.Vector3.zero + self.FacadeGo.localScale = CS.UnityEngine.Vector3.one + end + + self.SurfaceRoot = self.Transform:Find("@Surface") + self.CharacterRoot = self.Transform:Find("@Character") + self.FurnitureRoot = self.Transform:Find("@Furniture") + + self.SurfaceRoot.gameObject:SetActiveEx(false) + self.FurnitureRoot.gameObject:SetActiveEx(false) + self.CharacterRoot.gameObject:SetActiveEx(false) + + self.GoInputHandler = self.Transform:GetComponent(typeof(CS.XGoInputHandler)) + if not XTool.UObjIsNil(self.GoInputHandler) then + self.GoInputHandler:AddPointerClickListener(function() self:OnClick() end) + end + + self:SetData(self.Data, loadtype) +end + +--显示属性标签 +function XHomeRoomObj:OnShowFurnitureAttr(evt, args) + local room = XHomeDormManager.GetRoom(self.Data.Id) + if room and XHomeDormManager.IsInRoom(self.Data.Id) then + for _, v in pairs(room.GroundFurnitureList) do + v:ShowAttrTag(args[0]) + end + + for _, v in pairs(room.WallFurnitureList) do + for _, furniture in pairs(v) do + furniture:ShowAttrTag(args[0]) + end + end + end +end + +--隐藏属性标签 +function XHomeRoomObj:OnHideFurnitureAttr() + if self.GroundFurnitureList then + for _, v in pairs(self.GroundFurnitureList) do + v:HideAttrTag() + end + end +end + +-- 设置房间数据 +function XHomeRoomObj:SetData(data, loadtype) + self.Data = data + self.CurLoadType = loadtype + + local isUnlock = self.Data:WhetherRoomUnlock() + if not XTool.UObjIsNil(self.RoomLockGo) then + local v3 = XDormConfig.GetDormSenceVector(data.Id) + self.RoomLockGo:SetActiveEx(not isUnlock) + self.RoomLockGo.transform.localRotation = CS.UnityEngine.Quaternion.Euler(v3.x, v3.y, v3.z) + end + if not XTool.UObjIsNil(self.RoomUnlockGo) then + local v3 = XDormConfig.GetDormSenceVector(data.Id) + self.RoomUnlockGo:SetActiveEx(isUnlock) + self.RoomUnlockGo.transform.localRotation = CS.UnityEngine.Quaternion.Euler(v3.x, v3.y, v3.z) + end + + self:CleanRoom() + self:CleanCharacter() + self:LoadFurniture() + self:LoadCharacter() + + self:GenerateRoomMap() +end + +-- 获取房间数据 +function XHomeRoomObj:GetData() + local roomData = XHomeRoomData.New(self.Data.Id) + local roomType = self.Data:GetRoomDataType() + local isTemplate = XDormConfig.IsTemplateRoom(roomType) + + roomData:SetPlayerId(self.Data:GetPlayerId()) + roomData:SetRoomUnlock(self.Data:WhetherRoomUnlock()) + roomData:SetRoomName(self.Data:GetRoomName()) + roomData:SetRoomDataType(roomType) + + if self.Wall then + if isTemplate then + roomData:AddFurniture(self.Wall.Data.Id, self.Wall.Data.CfgId, 0, 0, 0) + else + roomData:AddFurniture(self.Wall.Data.Id, self.Wall.Data.CfgId) + end + end + + if self.Ground then + if isTemplate then + roomData:AddFurniture(self.Ground.Data.Id, self.Ground.Data.CfgId, 0, 0, 0) + else + roomData:AddFurniture(self.Ground.Data.Id, self.Ground.Data.CfgId) + end + end + + if self.Ceiling then + if isTemplate then + roomData:AddFurniture(self.Ceiling.Data.Id, self.Ceiling.Data.CfgId, 0, 0, 0) + else + roomData:AddFurniture(self.Ceiling.Data.Id, self.Ceiling.Data.CfgId) + end + end + + for _, furniture in pairs(self.GroundFurnitureList) do + local x, y, rotate = furniture:GetData() + roomData:AddFurniture(furniture.Data.Id, furniture.Data.CfgId, x, y, rotate) + end + + for _, v in pairs(self.WallFurnitureList) do + for _, furniture in pairs(v) do + local x, y, rotate = furniture:GetData() + roomData:AddFurniture(furniture.Data.Id, furniture.Data.CfgId, x, y, rotate) + end + end + + return roomData +end + +-- 设置房间光照信息 +function XHomeRoomObj:SetIllumination() + if not self.Ceiling then + return + end + + if not self.Ceiling.Cfg then + return + end + + local soPath = self.Ceiling.Cfg.IlluminationSO + if not self.Ceiling.Cfg.IlluminationSO or string.len(self.Ceiling.Cfg.IlluminationSO) <= 0 then + soPath = ROOM_DEFAULT_SO_PATH + end + XHomeSceneManager.SetGlobalIllumSO(soPath) +end + +-- 重置房间摆设,增加参数,重置完再刷数据 +function XHomeRoomObj:RevertRoom() + self:CleanRoom() + self:LoadFurniture() + self:SetIllumination() + self:GenerateRoomMap() +end + +-- 收起房间家具,增加参数,收起完再刷数据,如果有构造体需要回收利用。 +function XHomeRoomObj:CleanRoom() + self:CleanGroudFurinture() + self:CleanWallFurniture() + CsXGameEventManager.Instance:Notify(XEventId.EVENT_FURNITURE_CLEANROOM) +end + + +function XHomeRoomObj:CleanWallFurniture() + if self.WallFurnitureList then + for _, v in pairs(self.WallFurnitureList) do + for _, furniture in pairs(v) do + furniture:Storage(false) + end + end + end + self.WallFurnitureList = {} +end + +function XHomeRoomObj:CleanGroudFurinture() + if self.GroundFurnitureList then + for _, furniture in pairs(self.GroundFurnitureList) do + furniture:Storage(false) + end + end + self.GroundFurnitureList = {} +end + +function XHomeRoomObj:CleanCharacter() + self:SetCharacterExit() +end + +-- 加载家具 +function XHomeRoomObj:LoadFurniture() + self:RemoveWallDither() + local furnitureList = self.Data:GetFurnitureDic() + for _, data in pairs(furnitureList) do + local furnitureCfg = XFurnitureConfigs.GetFurnitureTemplateById(data.ConfigId) + if furnitureCfg then + local furnitureData + if XDormConfig.IsTemplateRoom(self.CurLoadType) then + furnitureData = { + Id = data.Id, + ConfigId = data.ConfigId + } + else + furnitureData = XDataCenter.FurnitureManager.GetFurnitureById(data.Id, self.CurLoadType) + end + local furniture = XHomeDormManager.CreateFurniture(self.Data.Id, furnitureData, { x = data.GridX, y = data.GridY }, data.RotateAngle) + + if furniture then + if furniture.PlaceType == XFurniturePlaceType.Wall then + --墙体 + self:UpdateWallDither(self.Wall, furniture) + if self.Wall then + self.Wall:Storage() + end + self.Wall = furniture + elseif furniture.PlaceType == XFurniturePlaceType.Ground then + --地板 + if self.Ground then + self.Ground:Storage() + end + + self.Ground = furniture + elseif furniture.PlaceType == XFurniturePlaceType.Ceiling then + --天花板 + if self.Ceiling then + self.Ceiling:Storage() + end + self.Ceiling = furniture + elseif furniture.PlaceType == XFurniturePlaceType.OnWall then + --墙上家具 + local dic = self.WallFurnitureList[tostring(data.RotateAngle)] + if not dic then + dic = {} + self.WallFurnitureList[tostring(data.RotateAngle)] = dic + end + dic[furniture.Data.Id] = furniture + else + --地上家具 + self.GroundFurnitureList[furniture.Data.Id] = furniture + end + CsXGameEventManager.Instance:Notify(XEventId.EVENT_FURNITURE_ONDRAGITEM_CHANGED, false, furniture.Data.Id) + end + end + end + + self:UpdateWallListRender() +end + + +--获取所有家具 +function XHomeRoomObj:GetAllFurnitureConfig() + local configs = {} + --天花板 + if self.Ceiling and self.Ceiling.Cfg then + table.insert(configs, self.Ceiling.Cfg) + end + + --地板 + if self.Ground and self.Ground.Cfg then + table.insert(configs, self.Ground.Cfg) + end + + --墙 + if self.Wall and self.Wall.Cfg then + table.insert(configs, self.Wall.Cfg) + end + + --地上家具 + for _, v in pairs(self.GroundFurnitureList) do + table.insert(configs, v.Cfg) + end + + --挂饰 + for _, v in pairs(self.WallFurnitureList) do + for _, furniture in pairs(v) do + table.insert(configs, furniture.Cfg) + end + end + + return configs +end + +-- 设置家具交互点Go +function XHomeRoomObj:SetInteractInfoGo() + for _, v in pairs(self.GroundFurnitureList) do + if v then + v:SetInteractInfoGo() + end + end +end + +-- 隐藏家具交互点Go +function XHomeRoomObj:HideInteractInfoGo() + for _, v in pairs(self.GroundFurnitureList) do + if v then + v:HideInteractInfoGo() + end + end +end + +-- 获取地表配置id +function XHomeRoomObj:GetPlatId(homePlatType) + if (homePlatType == CS.XHomePlatType.Ground and not self.Ground) or + (homePlatType == CS.XHomePlatType.Wall and not self.Wall) then + return XDataCenter.DormManager.GetRoomPlatId(self.Data.Id, homePlatType) + elseif homePlatType == CS.XHomePlatType.Ground then + return self.Ground.CfgId + elseif homePlatType == CS.XHomePlatType.Wall then + return self.Wall.CfgId + else + return 0 + end +end + +-- 加载构造体 +function XHomeRoomObj:LoadCharacter() + local characterList = self.Data:GetCharacter() + + for _, data in ipairs(characterList) do + XHomeCharManager.PreLoadHomeCharacterById(data.CharacterId) + end +end + +-- 更换基础装修 +function XHomeRoomObj:ReplaceSurface(furniture) + if furniture.PlaceType == XFurniturePlaceType.Wall then + self:RemoveWallDither() + if self.Wall then + self.Wall:Storage() + end + self:UpdateWallDither(self.Wall, furniture) + self.Wall = furniture + self:GenerateRoomMap() + + for _, v in pairs(self.WallFurnitureList) do + for _, data in pairs(v) do + local cfg = XFurnitureConfigs.GetFurnitureTemplateById(data.Data.CfgId) + if cfg then + local homePlatType = XFurnitureConfigs.LocateTypeToXHomePlatType(cfg.LocateType) + if homePlatType == nil then + return + end + + -- 检测是否有家具阻挡 + local x, y, rot = data:GetData() + if self:CheckFurnitureBlock(data.Data.Id, x, y, cfg.Width, cfg.Height, homePlatType, rot) then + data:Storage() + end + end + end + end + + self:UpdateWallListRender() + + elseif furniture.PlaceType == XFurniturePlaceType.Ground then + if self.Ground then + self.Ground:Storage() + end + self.Ground = furniture + self:GenerateRoomMap() + for _, data in pairs(self.GroundFurnitureList) do + local cfg = XFurnitureConfigs.GetFurnitureTemplateById(data.Data.CfgId) + if cfg then + local homePlatType = XFurnitureConfigs.LocateTypeToXHomePlatType(cfg.LocateType) + if homePlatType == nil then + return + end + + -- 检测是否有家具阻挡 + local x, y, rot = data:GetData() + if self:CheckFurnitureBlock(data.Data.Id, x, y, cfg.Width, cfg.Height, homePlatType, rot) then + --self.IsCanSave = false + data:Storage() + break + end + end + end + elseif furniture.PlaceType == XFurniturePlaceType.Ceiling then + if self.Ceiling then + self.Ceiling:Storage() + end + self.Ceiling = furniture + self:SetIllumination() + end + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_FURNITURE_ONDRAGITEM_CHANGED, false, furniture.Data.Id) +end + +-- 检测类型数量限制 +function XHomeRoomObj:CheckFurnitureCountReachLimit(furniture) + if furniture.Cfg.PutNumType <= 0 then + -- 无类型,不限制 + return false + end + local PutNumCfg = XFurnitureConfigs.GetFurniturePutNumCfg(furniture.Cfg.PutNumType) + if PutNumCfg.PutCount <= 0 then + -- 不限制数量 + return false + end + + local count = 0 + for _, v in pairs(self.GroundFurnitureList) do + if v.Cfg.PutNumType == furniture.Cfg.PutNumType then + count = count + 1 + end + end + + if count < PutNumCfg.PutCount then + -- 未达到限制数量 + return false + end + + return true +end + +-- 检测类型数量限制 +function XHomeRoomObj:CheckFurnitureCountReachLimitByPutNumType(putNumType) + if putNumType <= 0 then + -- 无类型,不限制 + return false + end + local PutNumCfg = XFurnitureConfigs.GetFurniturePutNumCfg(putNumType) + if PutNumCfg.PutCount <= 0 then + -- 不限制数量 + return false + end + + local count = 0 + for _, v in pairs(self.GroundFurnitureList) do + if v.Cfg.PutNumType == putNumType then + count = count + 1 + end + end + + if count < PutNumCfg.PutCount then + -- 未达到限制数量 + return false + end + + return true +end + +-- 添加家具 +function XHomeRoomObj:AddFurniture(furniture) + local old + if furniture.PlaceType == XFurniturePlaceType.OnGround then + old = self.GroundFurnitureList[furniture.Data.Id] + if not old then + self.GroundFurnitureList[furniture.Data.Id] = furniture + end + elseif furniture.PlaceType == XFurniturePlaceType.OnWall then + for _, v in pairs(self.WallFurnitureList) do + old = v[furniture.Data.Id] + if old then + local _, _, rot = old:GetData() + self.WallDithers[tostring(rot)]:AddRenderer(furniture.GameObject) + self.WallDithers[tostring(rot)]:AddStateChangeListener(furniture.GameObject, handler(furniture, furniture.OnStateChange)) + break + end + end + + if not old then + local _, _, rot = furniture:GetData() + local temp = self.WallFurnitureList[tostring(rot)] + if not temp then + temp = {} + self.WallFurnitureList[tostring(rot)] = temp + end + + temp[furniture.Data.Id] = furniture + self.WallDithers[tostring(rot)]:AddRenderer(furniture.GameObject) + self.WallDithers[tostring(rot)]:AddStateChangeListener(furniture.GameObject, handler(furniture, furniture.OnStateChange)) + end + end +end + +-- 移除家具 +function XHomeRoomObj:RemoveFurniture(furniture) + if furniture.PlaceType == XFurniturePlaceType.OnGround then + self.GroundFurnitureList[furniture.Data.Id] = nil + elseif furniture.PlaceType == XFurniturePlaceType.OnWall then + local _, _, rot = furniture:GetData() + local temp = self.WallFurnitureList[tostring(rot)] + if temp then + if temp[furniture.Data.Id] then + self.WallDithers[tostring(rot)]:RemoveRenderer(temp[furniture.Data.Id].GameObject) + self.WallDithers[tostring(rot)]:RemoveStateChangeListener(temp[furniture.Data.Id].GameObject) + + end + temp[furniture.Data.Id] = nil + end + end +end + +-- 选中房间 +function XHomeRoomObj:SetSelected(isSelected, shouldProcessOutside, onFinishEnterRoom) + self.IsSelected = isSelected + if isSelected then + self.GameObject:SetActiveEx(true) + end + local cb = function() + if XTool.UObjIsNil(self.GameObject) then + return + end + + local roomType = self.Data:GetRoomDataType() + local isTemplate = XDormConfig.IsTemplateRoom(roomType) + self.SurfaceRoot.gameObject:SetActiveEx(isSelected or isTemplate) + self.FurnitureRoot.gameObject:SetActiveEx(isSelected or isTemplate) + self.CharacterRoot.gameObject:SetActiveEx(isSelected or isTemplate) + + if not XTool.UObjIsNil(self.FacadeGo) then + self.FacadeGo.gameObject:SetActiveEx(not isSelected) + end + + if shouldProcessOutside then + XHomeDormManager.ShowOrHideOutsideRoom(self.Data.Id, not isSelected) + end + + if onFinishEnterRoom then + onFinishEnterRoom() + end + end + + if isSelected then + self:SetIllumination() + local func = function() + cb() + XScheduleManager.ScheduleOnce(function() + self:SetCharacterBorn() + end, 1) + XHomeSceneManager.ChangeView(HomeSceneViewType.RoomView) + end + + XLuaUiManager.Open("UiBlackScreen", self.Transform, true, "Room", func) + local camera = XHomeSceneManager.GetSceneCamera() + if not XTool.UObjIsNil(camera) then + camera.farClipPlane = ROOM_FAR_CLIP_PLANE + end + XEventManager.DispatchEvent(XEventId.EVENT_DORM_ROOM, self.Data.Id) + CsXGameEventManager.Instance:RegisterEvent(XEventId.EVENT_DORM_FURNITURE_ATTR_TAG, handler(self, self.OnShowFurnitureAttr)) + + else + XScheduleManager.ScheduleOnce(function() + cb() + end, 150) + self:SetCharacterExit() + + CsXGameEventManager.Instance:RemoveEvent(XEventId.EVENT_DORM_FURNITURE_ATTR_TAG, handler(self, self.OnShowFurnitureAttr)) + + self:OnHideFurnitureAttr() + self:StorageTemplateFurnitrue() + end +end + +-- 收纳模板宿舍中的家具 +function XHomeRoomObj:StorageTemplateFurnitrue() + if not XDormConfig.IsTemplateRoom(self.CurLoadType) then + return + end + + if self.Ceiling then + self.Ceiling:Storage() + self.Ceiling = nil + end + + if self.Ground then + self.Ground:Storage() + self.Ground = nil + end + + if self.Wall then + self.Wall:Storage() + self.Wall = nil + end + + for _, furniture in pairs(self.GroundFurnitureList) do + furniture:Storage() + end + self.GroundFurnitureList = {} + + for _, v in pairs(self.WallFurnitureList) do + for _, furniture in pairs(v) do + furniture:Storage() + end + end + self.WallFurnitureList = {} +end + +--进入房间角色出生 +function XHomeRoomObj:SetCharacterBorn() + if not self.IsSelected then + return + end + + self:ResetCharacterList() +end + +function XHomeRoomObj:ResetCharacterList() + self:CleanCharacter() + local characterList = self.Data:GetCharacter() + if characterList == nil then + return + end + + for _, data in ipairs(characterList) do + if data and data.CharacterId then + if (not self.Data:IsSelfData()) or (not XDataCenter.DormManager.IsWorking(data.CharacterId)) then + local charObj = XHomeCharManager.SpawnHomeCharacter(data.CharacterId, self.CharacterRoot) + charObj:SetData(data, self.Data:IsSelfData()) + charObj:Born(self.RoomMap, self) + table.insert(self.CharacterList, charObj) + end + end + end + + for _, furniture in pairs(self.GroundFurnitureList) do + for _, char in ipairs(self.CharacterList) do + furniture:RippleAddChar(char.Transform) + end + end +end + +--退出房间 +function XHomeRoomObj:SetCharacterExit() + if self.CharacterList == nil then + return + end + + for _, v in ipairs(self.CharacterList) do + v:ExitRoom() + end + + self.CharacterList = {} + for _, furniture in pairs(self.GroundFurnitureList) do + furniture:RippleClearChar() + end +end + +--添加构造体 +function XHomeRoomObj:AddCharacter(dormtoryId, characterId) + if dormtoryId ~= self.Data.Id then + return + end + + local data = self.Data:GetCharacterById(characterId) + if (not self.Data:IsSelfData()) or (not XDataCenter.DormManager.IsWorking(data.CharacterId)) then + local charObj = XHomeCharManager.SpawnHomeCharacter(characterId, self.CharacterRoot) + charObj:SetData(data, self.Data:IsSelfData()) + + if self.IsSelected then + table.insert(self.CharacterList, charObj) + charObj:Born(self.RoomMap, self) + end + + for _, furniture in pairs(self.GroundFurnitureList) do + furniture:RippleAddChar(charObj.Transform) + end + end +end + +--移除构造体 +function XHomeRoomObj:RemoveCharacter(dormtoryId, characterId) + if dormtoryId ~= self.Data.Id then + return + end + + if not self.IsSelected then + return + end + + local charObj = nil + local index = -1 + for k, v in ipairs(self.CharacterList) do + + if v.Id == characterId then + charObj = v + index = k + break + end + end + + if not charObj then + return + end + + for _, furniture in pairs(self.GroundFurnitureList) do + furniture:RippleRemoveChar(charObj.Transform) + end + + charObj:ExitRoom() + table.remove(self.CharacterList, index) +end + +function XHomeRoomObj:Reform(isBegin) + for _, furniture in pairs(self.GroundFurnitureList) do + if isBegin then + furniture:RippleClearChar() + else + for _, char in ipairs(self.CharacterList) do + furniture:RippleAddChar(char.Transform) + end + end + end +end + +-- 点击房间 +function XHomeRoomObj:OnClick() + if not self.Data:WhetherRoomUnlock() then + --未解锁,先激活 + local cfg = XDormConfig.GetDormitoryCfgById(self.Data.Id) + local name = XDataCenter.ItemManager.GetItemName(cfg.ConsumeItemId) + local title = CS.XTextManager.GetText("TipTitle") + local count = cfg.ConsumeItemCount + local des = CS.XTextManager.GetText("DormActiveTips", count, name) + XUiManager.DialogTip(title, des, XUiManager.DialogType.Normal, nil, function() XDataCenter.DormManager.RequestDormitoryActive(self.Data.Id) end) + return + end + + -- 已激活,进入房间 + if XLuaUiManager.IsUiShow("UiDormSecond") then + return + end + XLuaUiManager.Open("UiDormSecond", DisplaySetType.MySelf, self.Data.Id) + XHomeDormManager.SetSelectedRoom(self.Data.Id, true) +end + +-- 设置可行走区域列表 +function XHomeRoomObj:SetCanReachList() + if not self.RoomMap then + return + end + + self.CanReachList = {} + for x = 0, CS.XHomeMapManager.Inst.MapSize.x - 1 do + for y = 0, CS.XHomeMapManager.Inst.MapSize.y - 1 do + local gridInfo = self.RoomMap:GetGridInfo(x, y) + local gridMask = CS.XRoomMapInfo.GetMapGridMask(gridInfo, CS.XRoomBlockType.Furniture) + if gridMask <= 0 then + local info = { x = x, y = y } + table.insert(self.CanReachList, info) + end + end + end + + if #self.CanReachList <= 0 then + XLog.Error("XHomeRoomObj SetCanReachList Error, Can reach patch is zero!") + end +end + +-- 获取可行走区域列表 +function XHomeRoomObj:GetCanReachList() + return self.CanReachList +end + +-- 生成地图信息及家具交互点信息 +function XHomeRoomObj:GenerateRoomMap() + if not self.Ground then + return + end + + --房间动态地图信息 + self.RoomMap = CS.XRoomMapInfo.GenerateMap(self.Ground.Data.CfgId) + --先将HomeDormManager节点转到对应房间里再计算网格点里的数据,不然会有误差 + XHomeDormManager.AttachSurfaceToRoom(self.Data.Id) + + if self.GroundFurnitureList then + for _, furniture in pairs(self.GroundFurnitureList) do + if furniture.Cfg then + local x, y, rotate = furniture:GetData() + -- 家具 + self.RoomMap:SetFurnitureInfo(x, y, furniture.Cfg.Width, furniture.Cfg.Height, rotate) + end + end + end + self:SetCanReachList() + + --有效交互点列表 + self.InteractList = {} + if self.GroundFurnitureList then + for _, furniture in pairs(self.GroundFurnitureList) do + if furniture.Cfg then + local list = furniture:GenerateInteractInfo(self.RoomMap) + for _, info in ipairs(list) do + if (info.UsedType & XFurnitureInteractUsedType.Block) <= 0 then + local interactInfo = {} + interactInfo.GridPos = info.GridPos + interactInfo.StayPosGo = info.StayPos + interactInfo.InteractPosGo = info.InteractPos + interactInfo.Furniture = furniture + table.insert(self.InteractList, interactInfo) + end + + -- 交互点 + if info.GridPos then + --从格子坐标转换回以前配置表的坐标,为了兼容以前的写法,避免去改C# + local x, y, rotate = furniture:GetData() + local configX = info.GridPos.x - x + local configY = info.GridPos.y - y + self.RoomMap:SetFurnitureInteractionInfo(x, y, furniture.Cfg.Width, furniture.Cfg.Height, configX, configY, rotate) + end + end + end + end + end + + --等上面处理完后重新隐藏 + XHomeDormManager.AttachSurfaceToRoom() +end + +-- 检测家具阻挡 +function XHomeRoomObj:CheckFurnitureBlock(furnitureId, x, y, width, height, type, rotate) + local isBlock = false + + for _, furniture in pairs(self.GroundFurnitureList) do + if furnitureId ~= furniture.Data.Id and furniture:CheckCanLocate() and + furniture:CheckFurnitureCollision(x, y, width, height, type, rotate) then + isBlock = true + break + end + end + + if not isBlock then + for _, v in pairs(self.WallFurnitureList) do + for _, furniture in pairs(v) do + if furnitureId ~= furniture.Data.Id and furniture:CheckCanLocate() and + furniture:CheckFurnitureCollision(x, y, width, height, type, rotate) then + isBlock = true + break + end + end + + if isBlock then + break + end + end + end + + local blockCfgId = 0 + if type == CS.XHomePlatType.Ground and self.Ground then + blockCfgId = self.Ground.Data.CfgId + elseif type == CS.XHomePlatType.Wall and self.Wall then + blockCfgId = self.Wall.Data.CfgId + end + + local block, pos = XHomeDormManager.CheckMultiBlock(blockCfgId, x, y, width, height, type, rotate) + if not isBlock then + isBlock = block + end + + return isBlock, pos +end + +-- 移除所有墙饰的dither +function XHomeRoomObj:RemoveWallDither() + if self.Wall and self.WallDithers then + for rotate, v in pairs(self.WallFurnitureList) do + local wallDitherIndex = tostring(rotate) + for _, furniture in pairs(v) do + if self.WallDithers[wallDitherIndex] then + self.WallDithers[wallDitherIndex]:RemoveRenderer(furniture.GameObject) + self.WallDithers[wallDitherIndex]:RemoveStateChangeListener(furniture.GameObject) + end + end + end + end +end + +-- 更新dither +function XHomeRoomObj:UpdateWallDither(lastWall, curWall) + + self:RemoveLastWallEffectDither(lastWall) + if curWall then + for i = 1, WallNum do + local ditherKey = tostring(i - 1) + self.WallDithers[ditherKey] = curWall.Transform:Find(ditherKey):GetComponent(typeof(CS.XRoomWallDither)) + + local wallEffects = curWall:GetWallEffectsByRot(ditherKey) + if wallEffects then + for j = 1, #wallEffects do + local wallEffectObj = wallEffects[j].gameObject + if not XTool.UObjIsNil(wallEffectObj) then + self.WallDithers[ditherKey]:AddStateChangeListener(wallEffectObj, function(state) + self:OnWallEffectDitherChange(state, wallEffectObj) + end) + end + end + end + end + end +end + +function XHomeRoomObj:RemoveLastWallEffectDither(wall) + if not wall then return end + for i = 1, WallNum do + local ditherKey = tostring(i - 1) + + if self.WallDithers[ditherKey] then + local wallEffects = wall:GetWallEffectsByRot(ditherKey) + if wallEffects then + for j = 1, #wallEffects do + local wallEffectObj = wallEffects[j].gameObject + if not XTool.UObjIsNil(wallEffectObj) then + self.WallDithers[ditherKey]:RemoveStateChangeListener(wallEffectObj) + end + end + end + end + end +end + +-- 墙特效 +function XHomeRoomObj:OnWallEffectDitherChange(state, effectObj) + if state == "Enter" then + effectObj:SetActiveEx(true) + else + effectObj:SetActiveEx(false) + end +end + +-- 给所有墙饰添加render,换墙操作 +function XHomeRoomObj:UpdateWallListRender() + if self.WallFurnitureList then + for rotate, v in pairs(self.WallFurnitureList) do + local wallDitherIndex = tostring(rotate) + for _, furniture in pairs(v) do + if self.WallDithers[wallDitherIndex] then + self.WallDithers[wallDitherIndex]:AddStateChangeListener(furniture.GameObject, handler(furniture, furniture.OnStateChange)) + self.WallDithers[wallDitherIndex]:AddRenderer(furniture.GameObject) + end + end + end + end +end + +-- 家具碰撞检测 +function XHomeRoomObj:CheckFurnituresCollider(checkFurniture) + if not checkFurniture then + return false + end + + for _, collider in pairs(checkFurniture.Colliders) do + if not XTool.UObjIsNil(collider) then + for _, furniture in pairs(self.GroundFurnitureList or {}) do + if furniture ~= checkFurniture then + for _, furnitureCollider in pairs(furniture.Colliders or {}) do + if collider ~= furnitureCollider and collider.bounds:Intersects(furnitureCollider.bounds) then + return true + end + end + end + end + + for _, furnitureList in pairs(self.WallFurnitureList or {}) do + for _, furniture in pairs(furnitureList) do + if furniture ~= checkFurniture then + for _, furnitureCollider in pairs(furniture.Colliders or {}) do + if collider ~= furnitureCollider and collider.bounds:Intersects(furnitureCollider.bounds) then + return true + end + end + end + end + end + + if self.Ceiling then + if checkFurniture ~= self.Ceiling then + for _, furnitureCollider in pairs(self.Ceiling.Colliders or {}) do + if collider ~= furnitureCollider and collider.bounds:Intersects(furnitureCollider.bounds) then + return true + end + end + end + end + end + end + + return false +end + +function XHomeRoomObj:CheckColliderIntersectByBounds(colliderSrc, colliderDsc) + local boundSrc = Bounds(colliderSrc.center + colliderSrc.transform.position, colliderSrc.size) + local boundDsc = Bounds(colliderDsc.center + colliderDsc.transform.position, colliderDsc.size) + return boundSrc:Intersects(boundDsc) +end + +return XHomeRoomObj \ No newline at end of file diff --git a/Resources/Scripts/XHome/XHomeScene.lua b/Resources/Scripts/XHome/XHomeScene.lua new file mode 100644 index 00000000..9fc7a448 --- /dev/null +++ b/Resources/Scripts/XHome/XHomeScene.lua @@ -0,0 +1,172 @@ +XHomeScene = XClass(nil, "XHomeScene") + +local SCENE_FAR_CLIP_PLANE = 350 + +function XHomeScene:Ctor(senceNane, sceneAssetUrl, onLoadCompleteCb, onLeaveCb) + self.OnLoadCompleteCb = onLoadCompleteCb + self.OnLeaveCb = onLeaveCb + + self.NameOne = "sushe003_1" + self.NameTow = "sushe003_2" + self.CurName = self.NameOne + self.Name = senceNane + self.SceneAssetUrl = sceneAssetUrl + self.Resource = nil + self.GameObject = nil + + self.CameraFollowTarget1 = nil + self.CameraFollowTarget2 = nil + self.CurCameraFollowTarget = nil + self.Camera = nil + self.CameraController = nil + self.PhysicsRaycaster = nil + + -- 光照信息相关变量 + self.CurrentGlobalIllumSoPath = nil + self.GlobalIllumSOResourceMap = {} + self.CurrentPointLightPath = nil + self.CurrentPintLightParent = nil + self.GlobalPointLightMap = {} +end + +function XHomeScene:OnEnterScene() + --XSceneResourceManager.InitPool() + self.Resource = CS.XResourceManager.LoadAsync(self.SceneAssetUrl) + CS.XTool.WaitCoroutine(self.Resource, function() + if not self.Resource.Asset then + XLog.Error("XHomeScene LoadScene error, instantiate error, name: " .. self.SceneAssetUrl) + return + end + + self.GameObject = CS.UnityEngine.Object.Instantiate(self.Resource.Asset) + self:OnLoadComplete() + end) +end + +function XHomeScene:OnLeaveScene() + if self.OnLeaveCb then + self.OnLeaveCb() + end + + CS.UnityEngine.GameObject.Destroy(self.GameObject) + self.GameObject = nil + + self.CurrentGlobalIllumSoPath = nil + for _, v in pairs(self.GlobalIllumSOResourceMap) do + if v then + v:Release() + end + end + self.GlobalIllumSOResourceMap = nil + + self.CurrentPointLightPath = nil + self.CurrentPintLightParent = nil + for _, v in pairs(self.GlobalPointLightMap) do + if v.Resource then + v.Resource:Release() + end + + if not XTool.UObjIsNil(v.SoTrans) then + CS.UnityEngine.GameObject.Destroy(v.SoTrans.gameObject) + end + end + self.GlobalPointLightMap = nil + + CS.XGlobalIllumination.SetSceneType(CS.XSceneType.Ui) + + if self.Resource then + self.Resource:Release() + end +end + +function XHomeScene:OnLoadComplete() + self:InitCamera() + + if self.OnLoadCompleteCb then + self.OnLoadCompleteCb(self.GameObject) + end +end + +function XHomeScene:InitCamera() + self.Camera = self.GameObject.transform:Find("Camera"):GetComponent("Camera") + self.PhysicsRaycaster = self.Camera.gameObject:AddComponent(typeof(CS.UnityEngine.EventSystems.PhysicsRaycaster)) + + CS.XGraphicManager.BindCamera(self.Camera) + local target1 = CS.UnityEngine.GameObject.Find("@Target_1") + local target2 = CS.UnityEngine.GameObject.Find("@Target_2") + if not XTool.UObjIsNil(target1) then + self.CameraFollowTarget1 = target1.transform + self.CurCameraFollowTarget = target1.transform + end + if not XTool.UObjIsNil(target2) then + self.CameraFollowTarget2 = target2.transform + end + + self.CameraController = self.Camera.gameObject:GetComponent(typeof(CS.XCameraController)) + + self.CameraController:SetParam(self.CurName) + XCameraHelper.SetCameraTarget(self.CameraController, self.CurCameraFollowTarget) + self.DefaultCameraDistance = self.CameraController.Distance +end + +function XHomeScene:ChangeCameraToScene(cb) + XLuaUiManager.Open("UiBlackScreen", self.CurCameraFollowTarget, false, self.CurName, cb) + local camera = self:GetCamera() + if not XTool.UObjIsNil(camera) then + camera.farClipPlane = SCENE_FAR_CLIP_PLANE + end +end + +function XHomeScene:ChangeCameraToSceneById(senceId, cb) + if senceId == XDormConfig.SenceType.Tow then + self.CurCameraFollowTarget = self.CameraFollowTarget2 + self.CurName = self.NameTow + elseif senceId == XDormConfig.SenceType.One then + self.CurCameraFollowTarget = self.CameraFollowTarget1 + self.CurName = self.NameOne + end + + XLuaUiManager.Open("UiBlackScreen", self.CurCameraFollowTarget, false, self.CurName, function() + XCameraHelper.SetCameraTarget(self.CameraController, self.CurCameraFollowTarget) + if cb then cb() end + end) +end + +function XHomeScene:GetCamera() + return self.Camera +end + +function XHomeScene:GetCameraController() + return self.CameraController +end + +function XHomeScene:SetRaycasterMask(mask) + self.PhysicsRaycaster:SetEventMask(mask) +end + +----------------------------光照信息接口 start----------------------------- +-- 设置全局光照 +function XHomeScene:SetGlobalIllumSO(soPath) + if not soPath or string.len(soPath) <= 0 then + return + end + + self.CurrentGlobalIllumSoPath = soPath + + local resource = self.GlobalIllumSOResourceMap[soPath] + if not resource then + resource = CS.XResourceManager.Load(soPath) + self.GlobalIllumSOResourceMap[soPath] = resource + end + + CS.XGlobalIllumination.SetGlobalIllumSO(resource.Asset) +end + +-- 重置为当前场景全局光 +function XHomeScene:ResetToCurrentGlobalIllumination() + local resource = self.GlobalIllumSOResourceMap[self.CurrentGlobalIllumSoPath] + if resource then + CS.XGlobalIllumination.SetGlobalIllumSO(resource.Asset) + end +end +----------------------------光照信息接口 end----------------------------- \ No newline at end of file diff --git a/Resources/Scripts/XHome/XHomeSceneManager.lua b/Resources/Scripts/XHome/XHomeSceneManager.lua new file mode 100644 index 00000000..e401d3f0 --- /dev/null +++ b/Resources/Scripts/XHome/XHomeSceneManager.lua @@ -0,0 +1,212 @@ +XHomeSceneManager = XHomeSceneManager or {} + +HomeSceneViewType = { + OverView = 0, --总览 + RoomView = 1, --房间视角 + DeviceView = 2, --设备视角 +} + +HomeSceneLayerMask = { + Room = "Room", + Device = "Device", + HomeSurface = "HomeSurface", + Block = "Block", + HomeCharacter = "HomeCharacter", +} + +local CurrentScene = nil +local CurrentView = HomeSceneViewType.OverView + +function XHomeSceneManager.Init() + --TODO +end + +function XHomeSceneManager.EnterScene(sceneName, sceneAssetUrl,onLoadCompleteCb, onLeaveCb) + if CurrentScene and CurrentScene.Name == sceneName then + return + end + + local scene = XHomeScene.New(sceneName, sceneAssetUrl, onLoadCompleteCb, onLeaveCb) + + XLuaUiManager.Open("UiLoading", LoadingType.Dormitory) + CS.UnityEngine.Resources.UnloadUnusedAssets() + XHomeSceneManager.LeaveScene() + CurrentScene = scene + CurrentScene:OnEnterScene() + CurrentView = HomeSceneViewType.OverView +end + +function XHomeSceneManager.LeaveScene() + if CurrentScene then + CurrentScene:OnLeaveScene() + -- 清除宿舍本地图片缓存 + XDataCenter.DormManager.ClearLocalCaptureCache() + CurrentScene = nil + end +end + +function XHomeSceneManager.GetCurrentScene() + return CurrentScene +end + +function XHomeSceneManager.GetSceneCamera() + if CurrentScene then + return CurrentScene:GetCamera() + end + return nil +end + +function XHomeSceneManager.GetSceneCameraController() + if CurrentScene then + return CurrentScene:GetCameraController() + end + return nil +end + +function XHomeSceneManager.ChangeAngleYAndYAxis(angleY, isAllowYAxis) + local cameraController = XHomeSceneManager.GetSceneCameraController() + if not XTool.UObjIsNil(cameraController) then + if angleY > 0 then + cameraController.TargetAngleY = angleY + end + cameraController.AllowYAxis = isAllowYAxis + end +end + +function XHomeSceneManager.EnterShare(homeRoomData) + if not homeRoomData then + return + end + + local cameraController = XHomeSceneManager.GetSceneCameraController() + if not XTool.UObjIsNil(cameraController) then + local imgName = tostring(XPlayer.Id) .. tostring(homeRoomData:GetShareId()) .. XDormConfig.ShareName + local texture = cameraController:CaptureCamera(imgName, true) + XDataCenter.DormManager.SetLocalCaptureCache(imgName, texture) + XLuaUiManager.Open("UiDormTemplateShare", homeRoomData, texture) + end +end + +function XHomeSceneManager.CaptureCamera(imgName, isBig) + if not imgName then + return nil + end + + local texture = nil + local cameraController = XHomeSceneManager.GetSceneCameraController() + if not XTool.UObjIsNil(cameraController) then + local captrueAngleX = XDormConfig.CaptureAngleX + local captrueAngleY = XDormConfig.CaptureAngleY + local captrueDistance = XDormConfig.CaptureDistance + + local oldIsTweenCamera = cameraController.IsTweenCamera + local oldTargetAngleX = cameraController.TargetAngleX + local oldTargetAngleY = cameraController.TargetAngleY + local oldDistance = cameraController.Distance + + local minDistance = cameraController.MinDistance + local maxDistance = cameraController.MaxDistance + + -- 设置摄像机参数 + cameraController.IsTweenCamera = false + if captrueDistance > maxDistance then + cameraController.MaxDistance = captrueDistance + end + if captrueDistance < minDistance then + cameraController.MinDistance = captrueDistance + end + cameraController.TargetAngleX = captrueAngleX + cameraController.TargetAngleY = captrueAngleY + cameraController.Distance = captrueDistance + + -- 截屏 + texture = cameraController:CaptureCamera(imgName, isBig) + XDataCenter.DormManager.SetLocalCaptureCache(imgName, texture) + + XScheduleManager.ScheduleOnce(function() + --还原摄像机参数 + cameraController.MaxDistance = maxDistance + cameraController.MinDistance = minDistance + cameraController.TargetAngleX = oldTargetAngleX + cameraController.TargetAngleY = oldTargetAngleY + cameraController.Distance = oldDistance + cameraController.IsTweenCamera = oldIsTweenCamera + end, 500) + + return texture + end + + return texture +end + +function XHomeSceneManager.ChangeView(viewType) + CurrentView = viewType + local mask = XHomeSceneManager.GetLayerMask() + if CurrentScene then + CurrentScene:SetRaycasterMask(mask) + end +end + +function XHomeSceneManager.GetCurrentView() + return CurrentView +end + +function XHomeSceneManager.GetLayerMask() + if (CurrentView == HomeSceneViewType.OverView) then + return CS.UnityEngine.LayerMask.GetMask(HomeSceneLayerMask.Room) + elseif (CurrentView == HomeSceneViewType.RoomView) then + return CS.UnityEngine.LayerMask.GetMask(HomeSceneLayerMask.Device) | CS.UnityEngine.LayerMask.GetMask(HomeSceneLayerMask.HomeCharacter) + else + return nil + end +end + +function XHomeSceneManager.ChangeBackToOverView() + if CurrentView == HomeSceneViewType.OverView then + return false + end + CurrentScene:ChangeCameraToScene(function() + XHomeSceneManager.ChangeView(HomeSceneViewType.OverView) + end) + return true +end + +function XHomeSceneManager.ChangeSceneView(sceneId, cb) + CurrentScene:ChangeCameraToSceneById(sceneId, cb) + XHomeSceneManager.SetGlobalIllumSO(CS.XGame.ClientConfig:GetString("HomeSceneSoAssetUrl")) +end + +function XHomeSceneManager.IsInHomeScene() + return CurrentScene ~= nil +end + +----------------------------光照信息接口 start----------------------------- +-- 设置场景光照信息 +--function XHomeSceneManager.SetSceneType(sceneType) +-- XLog.Error(sceneType) +-- if CurrentScene then +-- CurrentScene:SetSceneType(sceneType) +-- end +--end +-- +-- 重置为当前光照场景类型 +--function XHomeSceneManager.ResetToCurrentSceneType() +-- if CurrentScene then +-- CurrentScene:ResetToCurrentSceneType() +-- end +--end + +-- 设置全局光照 +function XHomeSceneManager.SetGlobalIllumSO(soPath) + if CurrentScene then + CurrentScene:SetGlobalIllumSO(soPath) + end +end + +-- 重置为当前场景全局光 +function XHomeSceneManager.ResetToCurrentGlobalIllumination() + if CurrentScene then + CurrentScene:ResetToCurrentGlobalIllumination() + end +end +----------------------------光照信息接口 end----------------------------- \ No newline at end of file diff --git a/Resources/Scripts/XHome/XInfrastructure/XDeviceObject.lua b/Resources/Scripts/XHome/XInfrastructure/XDeviceObject.lua new file mode 100644 index 00000000..880347ae --- /dev/null +++ b/Resources/Scripts/XHome/XInfrastructure/XDeviceObject.lua @@ -0,0 +1,200 @@ +XDeviceObject = XClass(nil, "XDeviceObject") + +DeviceCategory = { + Device = 1, + Slot = 2, +} + +function XDeviceObject:Ctor(go, xRoomObj, cfg) + self.GameObject = go + self.Transform = go.transform + self.Parent = xRoomObj + + self.DeviceCfg = cfg + self.DeviceType = cfg.Id + self.OpenUI = cfg.OpenUI + + if self.DeviceType > XDataCenter.HostelManager.FunctionDeviceType.Unknown and + self.DeviceType < XDataCenter.HostelManager.FunctionDeviceType.FucEnd then + self.Category = DeviceCategory.Device + self.DeviceData = XDataCenter.HostelManager.GetFunctionDeviceData(self.DeviceType) + else + self.Category = DeviceCategory.Slot + self.DeviceData = XDataCenter.HostelManager.GetWorkCharBySlot(self.DeviceType) + end + + XSceneEntityManager.AddEntity(self.GameObject, self) + + self.GoInputHandler = self.Transform:GetComponent(typeof(CS.XGoInputHandler)) + if not XTool.UObjIsNil(self.GoInputHandler) then + self.GoInputHandler:AddPointerClickListener(function() self:OnClick() end) + end +end + +function XDeviceObject:Dispose() + XSceneEntityManager.RemoveEntity(self.GameObject) + + if not XTool.UObjIsNil(self.GoInputHandler) then + self.GoInputHandler:RemoveAllListeners() + end + self.GoInputHandler = nil + + if self.HudId then + local hud = XHudManager.GetDisplayHudByInstId(self.HudId) + if hud then + hud:Hide() + end + end + self.HudId = nil + + self.GameObject = nil + self.Parent = nil + self.DeviceCfg = nil + self.OpenUI = nil + + self.Category = nil + self.DeviceData = nil +end + +function XDeviceObject:OnClick() + if self.Category == DeviceCategory.Slot then + local state = XDataCenter.HostelManager.GetWorkSlotState(self.DeviceType) + if state == XDataCenter.HostelManager.WorkSlotState.Lock then + XUiManager.TipText("HostelWorkSlotLock") + return + end + end + if XDataCenter.HostelManager.IsInVisitFriendHostel() then + self:ChangeViewToCurDevice() + return + else + local fCloseCallBack = function() + self.Parent:ChangeViewCurRoomView() + end + if self.DeviceType == XDataCenter.HostelManager.FunctionDeviceType.PowerStation then + local curVlue = XDataCenter.HostelManager.GetPowerStationSaveElectric() + if curVlue > 0 then + XDataCenter.HostelManager.ReqCollectPowerStationElectric(function() + local rewards = {} + table.insert(rewards, { TemplateId = XDataCenter.ItemManager.ItemId.HostelElectric, Count = curVlue }) + + XUiManager.OpenUiObtain(rewards, nil, function() + + --使用新UI打开 + XLuaUiManager.Open(self.OpenUI, self.DeviceType, self, fCloseCallBack) + + self:ChangeViewToCurDevice() + + end) + end) + return + else + --使用新UI打开 + XLuaUiManager.Open(self.OpenUI, self.DeviceType, self, fCloseCallBack) + end + + else + + --使用新UI打开 + XLuaUiManager.Open(self.OpenUI, fCloseCallBack) + + end + end + self:ChangeViewToCurDevice() +end + +function XDeviceObject:ChangeViewToCurDevice() + local cameraCtrl = XHomeSceneManager.GetSceneCameraController() + if cameraCtrl then + XCameraHelper.SetCameraTarget(cameraCtrl, self.GameObject.transform, 3) + cameraCtrl:SetWorldOffset(CS.UnityEngine.Vector2.zero) + cameraCtrl.AllowDrag = false + end + + XHomeSceneManager.ChangeView(HomeSceneViewType.DeviceView) +end + +function XDeviceObject:OnBeginDrag() + -- +end + +function XDeviceObject:OnEndDrag() + -- +end + +function XDeviceObject:OnDrag() + -- +end + +function XDeviceObject:CheckShowHud() + if self.Category == DeviceCategory.Device then + if not XDataCenter.HostelManager.IsInVisitFriendHostel() then + if self.DeviceType == XDataCenter.HostelManager.FunctionDeviceType.PowerStation then + self:ShowHud(UiHudType.DeviceState, { Type = self.DeviceType }) + end + end + --TODO + elseif self.Category == DeviceCategory.Slot then + if XDataCenter.HostelManager.IsInVisitFriendHostel() then + return + end + local state, time = XDataCenter.HostelManager.GetWorkSlotState(self.DeviceType) + if time and time > 0 then + self:ShowHud(UiHudType.CoolTime, { Time = time, CallBack = function() + self:CheckShowHud() + end }) + else + self:ShowHud(UiHudType.WorkSlotState, { State = state, Slot = self.DeviceType, fClickComplete = function() + XDataCenter.HostelManager.ReqCollectSlotProduct(self.DeviceType, function(charId, rewards) + self:CheckShowHud() + --CS.XUiManager.DialogManager:Push("UiHostelMissionComplete", false, false, charId, rewards) + XLuaUiManager.Open("UiHostelMissionComplete", charId, rewards) + end) + end, + fClickAdd = function() + self:OnClick() + end }) + end + end +end + +function XDeviceObject:ShowHud(hudType, data) + local hud = nil + if self.HudId then + local oldHud = XHudManager.GetDisplayHudByInstId(self.HudId) + if oldHud then + if oldHud.HudType == hudType then + hud = oldHud + else + oldHud:Hide() + end + end + end + + if not hud then + hud = XHudManager.GetHud(hudType) + self.HudId = hud.InstId + end + data.Cfg = XDataCenter.HostelManager.GetHudTemplate(hudType, self.DeviceType) + hud:SetMetaData(data) + local camera = XHomeSceneManager.GetSceneCamera() + hud:SetFollowTarget(self.Transform, camera) +end + +function XDeviceObject:GetDisplayHud() + if self.HudId then + return XHudManager.GetDisplayHudByInstId(self.HudId) + else + return nil + end +end + +function XDeviceObject:HideHud() + if self.HudId then + local hud = XHudManager.GetDisplayHudByInstId(self.HudId) + if hud then + hud:Hide() + end + end + self.HudId = nil +end \ No newline at end of file diff --git a/Resources/Scripts/XHome/XInfrastructure/XHomeInfrastructureManager.lua b/Resources/Scripts/XHome/XInfrastructure/XHomeInfrastructureManager.lua new file mode 100644 index 00000000..bc09a408 --- /dev/null +++ b/Resources/Scripts/XHome/XInfrastructure/XHomeInfrastructureManager.lua @@ -0,0 +1,57 @@ +--- +--- 基建管理器 +---(管理基建场景对象) +--- +XHomeInfrastructureManager = XHomeInfrastructureManager or {} + +-- local RoomType = { +-- Dormitory = 4, --基地装备 +-- } + +-- local RoomRoot = nil +local RoomList = {} + +-- 初始化场景 +-- local function InitScene(sceneRootGo) +-- XLuaUiManager.Open("UiHomeMain", XDataCenter.HostelManager.SceneType.Function) + +-- RoomRoot = sceneRootGo.transform:Find("GroupTerrain") +-- local room_map = XDataCenter.HostelManager.GetSceneRoomNodeMap("RoomDomitory") +-- for _, cfg in pairs(room_map) do +-- local go = sceneRootGo.transform:Find(cfg.Path).gameObject +-- local room = XRoomObject.New(go, RoomRoot, cfg) +-- if cfg.Id == RoomType.Dormitory then +-- local baseEquipRedPoint = sceneRootGo.transform:Find(cfg.Path .. "/redPoint") +-- if not XTool.UObjIsNil(baseEquipRedPoint) then +-- baseEquipRedPoint.gameObject:SetActive(XDataCenter.BaseEquipManager.CheckBaseEquipHint()) +-- end +-- room:OnClick()--临时屏蔽其它模块 +-- end +-- table.insert(RoomList, room) +-- end +-- end + +-- -- 移除场景 +-- local function RemoveScene() +-- for _, room in ipairs(RoomList) do +-- room:Dispose() +-- end +-- RoomList = {} + +-- if not XTool.UObjIsNil(RoomRoot) then +-- CS.UnityEngine.GameObject.Destroy(RoomRoot.gameObject) +-- end +-- RoomRoot = nil +-- end + +-- 进入基建 +function XHomeInfrastructureManager.EnterInfrastructure() + --XHomeSceneManager.EnterScene("RoomDomitory", CS.XGame.ClientConfig:GetString("RoomDomitoryAssetUrl"), InitScene, RemoveScene) +end + +function XHomeInfrastructureManager.ChangeCameraToScene() + for _, room in ipairs(RoomList) do + room:HideDeviceHud() + room:CheckShowHud() + end +end \ No newline at end of file diff --git a/Resources/Scripts/XHome/XInfrastructure/XRoomObject.lua b/Resources/Scripts/XHome/XInfrastructure/XRoomObject.lua new file mode 100644 index 00000000..ec958e7c --- /dev/null +++ b/Resources/Scripts/XHome/XInfrastructure/XRoomObject.lua @@ -0,0 +1,142 @@ +XRoomObject = XClass(nil, "XRoomObject") + +function XRoomObject:Ctor(go, parent, cfg) + self.GameObject = go + self.Transform = go.transform + self.Parent = parent + + self.RoomType = cfg.Id + self.DeviceList = {} + + local curScene = XHomeSceneManager.GetCurrentScene() + local device_map = XDataCenter.HostelManager.GetSceneDeviceNodeMap(cfg.Scene, cfg.Id) + if device_map ~= nil then + for _, device_cfg in pairs(device_map) do + if not string.IsNilOrEmpty(device_cfg.Path) then + local deviceGo = curScene.GameObject.transform:Find(device_cfg.Path).gameObject + local device = XDeviceObject.New(deviceGo, self, device_cfg) + --local uiWidget = deviceGo.gameObject:AddComponent(typeof(CS.XUiWidget)) + --uiWidget:AddPointerClickListener(XSceneEventHandler.OnSceneObjectClick) + --uiWidget:AddBeginDragListener(XSceneEventHandler.OnBeginDrag) + --uiWidget:AddEndDragListener(XSceneEventHandler.OnEndDrag) + table.insert(self.DeviceList, device) + end + end + end + + XSceneEntityManager.AddEntity(self.GameObject, self) + self:CheckShowHud() +end + +function XRoomObject:Dispose() + XSceneEntityManager.RemoveEntity(self.GameObject) + for _, device in ipairs(self.DeviceList) do + device:Dispose() + end + self:HideRoomCurHud() + self.DeviceList = nil + + self.GameObject = nil + self.Parent = nil +end + +function XRoomObject:CheckShowHud() + local state = XDataCenter.HostelManager.GetFuncDeviceUpgradeState(self.RoomType) + if state == XDataCenter.HostelManager.DeviceUpgradeState.Upgrading or state == XDataCenter.HostelManager.DeviceUpgradeState.Complete then + self:ShowHud(UiHudType.RoomUpgrade, { Type = self.RoomType }) + end +end + +function XRoomObject:OnClick() + self:ChangeViewCurRoomView() + XLuaUiManager.Open("UiHostelRoom") + local state = XDataCenter.HostelManager.GetFuncDeviceUpgradeState(self.RoomType) + if state == XDataCenter.HostelManager.DeviceUpgradeState.Complete then + self:HideRoomCurHud() + XDataCenter.HostelManager.ComfirmFuncDeviceUpgrade(self.RoomType, function() + CS.XUiManager.DialogManager:Push("UiHostelDeviceUpgradeResult", false, false, self.RoomType) + end) + end +end + +function XRoomObject:ChangeViewCurRoomView() + if XDataCenter.HostelManager.IsInVisitFriendHostel() then + return + else + local state = XDataCenter.HostelManager.GetFuncDeviceUpgradeState(self.RoomType) + if state == XDataCenter.HostelManager.DeviceUpgradeState.Upgrading then + return + end + end + local cameraCtrl = XHomeSceneManager.GetSceneCameraController() + if cameraCtrl then + XCameraHelper.SetCameraTarget(cameraCtrl, self.GameObject.transform, 8) + cameraCtrl:SetWorldOffset(CS.UnityEngine.Vector2.zero) + cameraCtrl.AllowDrag = false + end + + XHomeSceneManager.ChangeView(HomeSceneViewType.RoomView) + + for _, device in ipairs(self.DeviceList) do + device:CheckShowHud() + end +end + +function XRoomObject:OnBeginDrag() + -- +end + +function XRoomObject:OnEndDrag() + -- +end + +function XRoomObject:OnDrag() + -- +end + +function XRoomObject:ShowHud(hudType, data) + local hud = nil + if self.HudId then + local oldHud = XHudManager.GetDisplayHudByInstId(self.HudId) + if oldHud then + if oldHud.HudType == hudType then + hud = oldHud + else + oldHud:Hide() + end + end + end + + if not hud then + hud = XHudManager.GetHud(hudType) + self.HudId = hud.InstId + end + data.Cfg = XDataCenter.HostelManager.GetHudTemplate(hudType, self.RoomType) + hud:SetMetaData(data) + local camera = XHomeSceneManager.GetSceneCamera() + hud:SetFollowTarget(self.Transform, camera) +end + +function XRoomObject:HideRoomCurHud() + if self.HudId then + local hud = XHudManager.GetDisplayHudByInstId(self.HudId) + if hud then + hud:Hide() + end + self.HudId = nil + end +end + +function XRoomObject:GetDisplayHud() + if self.HudId then + return XHudManager.GetDisplayHudByInstId(self.HudId) + else + return nil + end +end + +function XRoomObject:HideDeviceHud() + for _, device in ipairs(self.DeviceList) do + device:HideHud() + end +end \ No newline at end of file diff --git a/Resources/Scripts/XHome/XSceneEntityManager.lua b/Resources/Scripts/XHome/XSceneEntityManager.lua new file mode 100644 index 00000000..44dad9db --- /dev/null +++ b/Resources/Scripts/XHome/XSceneEntityManager.lua @@ -0,0 +1,47 @@ +XSceneEntityManager = XSceneEntityManager or {} + +local EntityMap = {} +local ChildToKeyGoMap = {} + +function XSceneEntityManager.AddEntity(go, entity) + local list = go:GetComponentsInChildren(typeof(CS.UnityEngine.Collider)) + local keyList = {} + for i = 0, list.Length - 1 do + local key = list[i].gameObject + ChildToKeyGoMap[key] = go + table.insert(keyList, key) + end + + if entity and not XTool.UObjIsNil(go) then + EntityMap[go] = entity + end +end + +function XSceneEntityManager.RemoveEntity(go) + local key = ChildToKeyGoMap[go] + + if key == nil then + key = go + end + + if not XTool.UObjIsNil(key) then + EntityMap[key] = nil + end +end + +function XSceneEntityManager.ClearEntities() + EntityMap = {} + ChildToKeyGoMap = {} +end + +function XSceneEntityManager.GetEntity(go) + local key = ChildToKeyGoMap[go] + if not key then + key = go + end + + if XTool.UObjIsNil(key) then + return nil + end + return EntityMap[key] +end \ No newline at end of file diff --git a/Resources/Scripts/XHome/XSceneObject.lua b/Resources/Scripts/XHome/XSceneObject.lua new file mode 100644 index 00000000..0db7bb6b --- /dev/null +++ b/Resources/Scripts/XHome/XSceneObject.lua @@ -0,0 +1,66 @@ +--- +--- 场景基类对象 +--- +local XSceneObject = XClass(nil, "XSceneObject") + +function XSceneObject:Ctor() + -- +end + +function XSceneObject:Dispose() + XSceneEntityManager.RemoveEntity(self.GameObject) + + if self.GameObject and self.GameObject:Exist() then + CS.UnityEngine.GameObject.Destroy(self.GameObject) + self.GameObject = nil + self.Transform = nil + end + + if self.Resource then + self.Resource:Release() + self.Resource = nil + end + + --if self.ModelPath then + --XSceneResourceManager.ReturnGoToPool(self.ModelPath, self.GameObject) + --end + self.ModelPath = nil +end + +function XSceneObject:SetModel(go, loadtype) + self.GameObject = go + self.Transform = go.transform + + XSceneEntityManager.AddEntity(self.GameObject, self) + self:OnLoadComplete(loadtype) +end + +function XSceneObject:LoadModel(modelPath, root) + self.ModelPath = modelPath + --local model = XSceneResourceManager.GetGoFromPool(modelPath) + local resource = CS.XResourceManager.Load(modelPath) + + if resource == nil or not resource.Asset then + XLog.Error(string.format("加载宿舍SceneObject:%s失败", modelPath)) + return + end + + self.Resource = resource + + local model = CS.UnityEngine.Object.Instantiate(resource.Asset) + self:BindToRoot(model, root) + self:SetModel(model) +end + +function XSceneObject:BindToRoot(model, root) + model.transform:SetParent(root) + model.transform.localPosition = CS.UnityEngine.Vector3.zero + model.transform.localEulerAngles = CS.UnityEngine.Vector3.zero + model.transform.localScale = CS.UnityEngine.Vector3.one +end + +function XSceneObject:OnLoadComplete() + -- body +end + +return XSceneObject \ No newline at end of file diff --git a/Resources/Scripts/XHome/XSceneResourceManager.lua b/Resources/Scripts/XHome/XSceneResourceManager.lua new file mode 100644 index 00000000..0a7d06e6 --- /dev/null +++ b/Resources/Scripts/XHome/XSceneResourceManager.lua @@ -0,0 +1,100 @@ +XSceneResourceManager = XSceneResourceManager or {} + +local ScenePoolRoot = nil +local ResourceMap = nil + +-- 初始化 +function XSceneResourceManager.InitPool() + if XTool.UObjIsNil(ScenePoolRoot) then + ScenePoolRoot = CS.UnityEngine.GameObject("ScenePoolRoot") + ScenePoolRoot:SetActive(false) + CS.UnityEngine.Object.DontDestroyOnLoad(ScenePoolRoot) + end + + XSceneResourceManager.ClearPool() + ResourceMap = {} +end + +-- 出池 +function XSceneResourceManager.GetGoFromPool(path) + if not ResourceMap then + ResourceMap = {} + end + + local temp = ResourceMap[path] + if not temp then + temp = {} + temp.Gos = {} + ResourceMap[path] = temp + end + + if not temp.Resource then + temp.Resource = CS.XResourceManager.Load(path) + end + + local go + + while (#temp.Gos > 0) do + go = table.remove(temp.Gos, #temp.Gos) + if not XTool.UObjIsNil(go) then + go:SetActive(true) + break + end + end + + if XTool.UObjIsNil(go) then + go = CS.UnityEngine.Object.Instantiate(temp.Resource.Asset) + end + + return go +end + +-- 回池 +function XSceneResourceManager.ReturnGoToPool(path, go) + if XTool.UObjIsNil(go) then + return + end + + if not ResourceMap then + ResourceMap = {} + end + + local temp = ResourceMap[path] + if not temp then + temp = {} + temp.Gos = {} + ResourceMap[path] = temp + end + + if not temp.Resource then + CS.UnityEngine.GameObject.Destroy(go) + return + end + + go.transform:SetParent(ScenePoolRoot.transform, false) + table.insert(temp.Gos, go) +end + +-- 清池 +function XSceneResourceManager.ClearPool() + if ResourceMap then + for _, v in pairs(ResourceMap) do + -- 销毁GameObject + if v.Gos then + for _, go in ipairs(v.Gos) do + if not XTool.UObjIsNil(go) then + CS.UnityEngine.GameObject.Destroy(go) + end + end + end + v.Gos = nil + + -- 释放资源 + if v.Resource then + v.Resource:Release() + end + end + end + + ResourceMap = nil +end \ No newline at end of file diff --git a/Resources/Scripts/XHotReload.lua b/Resources/Scripts/XHotReload.lua new file mode 100644 index 00000000..3a4f0d31 --- /dev/null +++ b/Resources/Scripts/XHotReload.lua @@ -0,0 +1,131 @@ +-- 用于运行时热重载LUA逻辑,热键F3,在XDataCenter中初始化的相关Manager文件中涉及数据的改动需要重登或断线重连后生效(仅editor + debug模式下生效) +XHotReload = XHotReload or {} + +local function updateFunc(newFunc, oldFunc) + assert("function" == type(newFunc)) + assert("function" == type(oldFunc)) + + local newUpvalueDic = {} + for i = 1, math.huge do + local name, newValue = debug.getupvalue(newFunc, i) + if not name then break end + newUpvalueDic[name] = newValue + end + + for i = 1, math.huge do + local name = debug.getupvalue(oldFunc, i) + if not name then break end + local newValue = newUpvalueDic[name] + if newValue then + debug.setupvalue(oldFunc, i, newValue) + end + end +end + +local updateTable +function updateTable(newTable, oldTable) + if "table" ~= type(oldTable) then return end + if "table" ~= type(newTable) then return end + + for key, newValue in pairs(newTable) do + local oldValue = oldTable[key] + local typeValue = type(newValue) + + if typeValue == "table" then + updateTable(newValue, oldValue) + elseif typeValue == "function" then + updateFunc(newValue, oldValue) + end + oldTable[key] = newValue--此处未处理newTable中值数量少于oldTable的情况 + end + + local oldMeta = debug.getmetatable(oldTable) + local newMeta = debug.getmetatable(newTable) + if type(oldMeta) == "table" and type(newMeta) == "table" then + updateTable(newMeta, oldMeta) + end +end + +local function TryRunInitConfig(fileName) + local _, endPos = string.find(fileName, "XConfig/") + if not endPos or endPos < 0 then return end + + local className = string.sub(fileName, endPos + 1) + local class = rawget(_G, className) + if not class then return end + + if class.Init then class.Init() end +end + +local function TryReplaceManager(filePath) + local _, endPos = string.find(filePath, "XManager/") + if not endPos or endPos < 0 then return end + local name = string.sub(filePath, endPos + 1) + + local creatorName = string.format("%sCreator", name) + local managerVar = rawget(_G, creatorName) or rawget(_G, name) + if type(managerVar) == "function" then + local newManager = managerVar() + updateTable(newManager, XDataCenter[name]) + elseif type(managerVar) == "table" and managerVar.Init then + managerVar.Init() + XLog.Debug(string.format("已重新运行%s的Init", name)) + end +end + +function XHotReload.Reload(fileName) + if not XMain.IsEditorDebug then return end + + --local info = debug.getinfo(2) + if not package.loaded[fileName] then + XLog.Error("XHotReload.Reload reload file error: file never loaded, fileName is: ", fileName) + return + end + + local oldModule = package.loaded[fileName] + package.loaded[fileName] = nil + + local ok, err = pcall(require, fileName) + if not ok then + package.loaded[fileName] = oldModule + XLog.Error("XHotReload.Reload reload file error: ", err) + return + end + + local newModule = package.loaded[fileName] + if "table" ~= type(newModule) then + TryRunInitConfig(fileName)--全局函数中只处理Config文件 + end + updateTable(newModule, oldModule) + UpdateClassType(newModule, oldModule) + + if "boolean" == type(newModule) then + TryReplaceManager(fileName) --改变XDataCenter所指向的Manager + end + + package.loaded[fileName] = oldModule + XLog.Debug("kkkttt XHotReload.Reload suc, fileName is: ", fileName) +end + +-- 部分表在Manager里读取 +function XHotReload.InitMgrTab() + if not XMain.IsDebug then return end + XReadOnlyTable.HotLoad = true + --XNewRoleShowManager.Init() + --XTipManager.Init() + XConditionManager.Init() + XFightUiManager.Init() + XLoginManager.Init() + XPlayerManager.Init() + XResetManager.Init() + XRobotManager.Init() + XRoomSingleManager.Init() + + XFunctionManager.Init() + XModelManager.Init() + XRewardManager.Init() + XReadOnlyTable.HotLoad = false + + CS.XGame.ClientConfig:Init("Client/Config/ClientConfig.tab") + CS.XGame.Config:Init("Share/Config/Config.tab") +end \ No newline at end of file diff --git a/Resources/Scripts/XMain.lua b/Resources/Scripts/XMain.lua new file mode 100644 index 00000000..d473c517 --- /dev/null +++ b/Resources/Scripts/XMain.lua @@ -0,0 +1,212 @@ +XMain = XMain or {} + +XMain.IsWindowsEditor = CS.UnityEngine.Application.platform == CS.UnityEngine.RuntimePlatform.WindowsEditor +local IsWindowsPlayer = CS.UnityEngine.Application.platform == CS.UnityEngine.RuntimePlatform.WindowsPlayer + +XMain.IsDebug = CS.XRemoteConfig.Debug +XMain.IsEditorDebug = (XMain.IsWindowsEditor or IsWindowsPlayer) and XMain.IsDebug + +local lockGMeta = { + __newindex = function(t, k) + XLog.Error("can't assign " .. k .." in _G") + end, + __index = function(t, k) + XLog.Error("can't index " .. k .." in _G, which is nil") + end +} + +function LuaLockG() + setmetatable(_G, lockGMeta) +end + +local import = CS.XLuaEngine.Import + +import("XCommon/XLog.lua") + +XMain.Step1 = function() + --打点 + CS.XRecord.Record("23000", "LuaXMainStart") + + if XMain.IsEditorDebug then + require("XHotReload") + end + + require("XCommon/XRpc") + import("XCommon") + import("XConfig") + import("XOverseas/XConfig") -- 海外定制化目录 + require("XGame") + import("XEntity") + import("XOverseas/XEntity") -- 海外定制化目录 + import("XUi/XUiBase") + import("XUi/XUiCommon/XScrollView") + import("XBehavior") + import("XGuide") + require("XMovieActions/XMovieActionBase") + CS.XApplication.SetProgress(0.52) +end + + +XMain.Step2 = function() + import("XManager") + import("XOverseas/XManager") -- 海外定制化目录 + import("XNotify") + CS.XApplication.SetProgress(0.54) +end + +XMain.Step3 = function() + import("XUi/XUiArena") + import("XUi/XUiArenaActivityResult") + import("XUi/XUiArenaFightResult") + import("XUi/XUiArenaLevelDetail") + import("XUi/XUiArenaStage") + import("XUi/XUiArenaTask") + import("XUi/XUiArenaTeam") + import("XUi/XUiArenaTeamRank") + import("XUi/XUiArenaWarZone") + import("XUi/XUiNewAutoFightDialog") + import("XUi/XUiAutoFightList") + import("XUi/XUiAutoFightReward") + import("XUi/XUiAutoFightTip") + import("XUi/XUiAwarenessTf") + import("XUi/XUiBag") + import("XUi/XUiBaseEquip") + import("XUi/XUiBfrt") + import("XUi/XUiBuyAsset") + import("XUi/XUiCharacter") + import("XUi/XUiCharacterDetail") + import("XUi/XUiChatServe") + import("XUi/XUiComeAcross") + import("XUi/XUiCommon") + import("XUi/XUiDialog") + import("XUi/XUiDorm") + import("XUi/XUiDraw") + CS.XApplication.SetProgress(0.56) +end + +XMain.Step4 = function() + import("XUi/XUiEquip") + import("XUi/XUiEquipAwarenessReplace") + import("XUi/XUiEquipBreakThrough") + import("XUi/XUiEquipDetail") + import("XUi/XUiEquipReplace") + import("XUi/XUiEquipReplaceNew") + import("XUi/XUiEquipResonanceSelect") + import("XUi/XUiEquipResonanceSkill") + import("XUi/XUiEquipStrengthen") + import("XUi/XUiFashion") + import("XUi/XUiFavorability") + import("XUi/XUiFightLoading") + import("XUi/XUiFirstGetPopUp") + import("XUi/XUiFuben") + import("XUi/XUiFubenActivityBanner") + import("XUi/XUiFubenActivityChapter") + import("XUi/XUiFubenActivitySection") + import("XUi/XUiFubenChallengeBanner") + import("XUi/XUiFubenChallengeChapter") + CS.XApplication.SetProgress(0.58) +end + +XMain.Step5 = function() + import("XUi/XUiFubenChallengeEMEX") + import("XUi/XUiFubenChallengeHSJYQZ") + import("XUi/XUiFubenChallengeMap") + import("XUi/XUiFubenBossSingle") + import("XUi/XUiFubenChallengeMapEmex") + import("XUi/XUiFubenChallengeSection") + import("XUi/XUiFubenChallengeUrgent") + import("XUi/XUiFubenChallengeYSHTX") + import("XUi/XUiFubenCoinSkill") + import("XUi/XUiFubenDailyBanner") + import("XUi/XUiFubenDailyChapter") + import("XUi/XUiFubenDialog") + import("XUi/XUiFubenFlopReward") + import("XUi/XUiFubenMainLineBanner") + import("XUi/XUiFubenMainLineChapter") + import("XUi/XUiFubenMainLineChapterBanner") + import("XUi/XUiFubenMainLineDetail") + import("XUi/XUiFubenResourceDetail") + import("XUi/XUiFubenStageDetail") + import("XUi/XUiFubenStory") + CS.XApplication.SetProgress(0.60) +end + +XMain.Step6 = function() + import("XUi/XUiFubenUrgentEventTip") + import("XUi/XUiFunctionalOpen") + import("XUi/XUiGameNotice") + import("XUi/XUiGuide") + import("XUi/XUiHomeMain") + import("XUi/XUiHostelCharacterWork") + import("XUi/XUiHostelDelegate") + import("XUi/XUiHostelDelegateReporter") + import("XUi/XUiHostelDeviceDetail") + import("XUi/XUiHostelDeviceUpgradeResult") + import("XUi/XUiHostelDeviceUpgrading") + import("XUi/XUiHostelMissionComplete") + import("XUi/XUiHostelQte") + import("XUi/XUiHostelRest") + import("XUi/XUiHostelRoom") + import("XUi/XUiHud") + import("XUi/XUiLogin") + import("XUi/XUiLoginNotice") + import("XUi/XUiMail") + import("XUi/XUiMain") + CS.XApplication.SetProgress(0.62) +end + +XMain.Step7 = function() + import("XUi/XUiMission") + import("XUi/XUiMoneyReward") + import("XUi/XUiMoneyRewardFightTipFind") + import("XUi/XUiNewPlayerTask") + import("XUi/XUiNewRoleShow") + import("XUi/XUiNewRoomSingle") + import("XUi/XUiNoticeTips") + import("XUi/XUiObtain") + import("XUi/XUiOnlineBoss") + import("XUi/XUiOnlineBossResult") + import("XUi/XUiOnLineTranscript") + import("XUi/XUiOnLineTranscriptRoom") + import("XUi/XUiPersonalInfo") + import("XUi/XUiPlayer") + import("XUi/XUiPlayerUp") + import("XUi/XUiPrequel") + import("XUi/XUiPrequelLineDetail") + import("XUi/XUiRegister") + import("XUi/XUiRoomCharacter") + import("XUi/XUiRoomMul") + CS.XApplication.SetProgress(0.65) +end + +XMain.Step8 = function() + import("XUi/XUiRoomTeamPrefab") + import("XUi/XUiSet") + import("XUi/XUiSettleLose") + import("XUi/XUiSettleUrgentEvent") + import("XUi/XUiSettleWin") + import("XUi/XUiSettleWinMainLine") + import("XUi/XUiSettleWinSingleBoss") + import("XUi/XUiShop") + import("XUi/XUiSkip") + import("XUi/XUiSocial") + import("XUi/XUiStory") + import("XUi/XUiTask") + import("XUi/XUiTest") + import("XUi/XUiTip") + import("XUi/XUiTipReward") + import("XUi/XUiTower") + import("XUi/XUiTrial") + import("XHome") + import("XScene") + import("XUi") + import("XOverseas/XUi") -- 海外定制化目录 + import("XMerge") + CS.XApplication.SetProgress(0.68) +end + +XMain.Step9 = function() + LuaLockG() + --打点 + CS.XRecord.Record("23008", "LuaXMainStartFinish") +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XActivityBriefManager.lua b/Resources/Scripts/XManager/XActivityBriefManager.lua new file mode 100644 index 00000000..420106da --- /dev/null +++ b/Resources/Scripts/XManager/XActivityBriefManager.lua @@ -0,0 +1,293 @@ +XActivityBriefManagerCreator = function() + local MethodName = { + FinishBrirfStory = "FinishBriefStoryRequest" + } + + local PlayedStoryDic = {} + local OldSpecialActivityTemplates = {} + + local SpecialActivityMaxEndTime = 0 + local pairs = pairs + local ParseToTimestamp = XTime.ParseToTimestamp + local CSUnityEnginePlayerPrefs = CS.UnityEngine.PlayerPrefs + + local ActivityConfig = XActivityBriefConfigs.GetActivityConfig() + local FirstOpenUi = nil + local FirstConditionalOpenUi = nil + local COOKIE_FIRSTOPENUI_KEY = "IsFirstOpen" + local COOKIE_FIRSTCONDITIONALOPENUI_KEY = "IsFirstConditionalOpen" + local XActivityBriefManager = {} + local MAX_MODEL_NUMBER + local ModelRankIndex + + local CheckIsNewSpecialActivityTemplates = function(nowSpecialActivityTemplates) + if #OldSpecialActivityTemplates ~= #nowSpecialActivityTemplates then + OldSpecialActivityTemplates = nowSpecialActivityTemplates + return true + end + return false + end + + local function Init() + for _, v in pairs(XActivityBriefConfigs.GetAllActivityEntryConfig()) do + local endTime = XFunctionManager.GetEndTimeByTimeId(v.TimeId) + if SpecialActivityMaxEndTime < endTime then + SpecialActivityMaxEndTime = endTime + end + end + --游戏一开始随机获取其中一个数,用于活动界面随机显示一个模型 + -- local models = XActivityBriefConfigs.GetActivityModels() + -- MAX_MODEL_NUMBER = #models == 0 and 1 or #models + -- math.randomseed(os.time()) + -- ModelRankIndex = math.random(MAX_MODEL_NUMBER) + end + + function XActivityBriefManager.GetSpecialActivityMaxEndTime() + return SpecialActivityMaxEndTime + end + + function XActivityBriefManager.GetEntryBtnName(activityGroupId) + local config = XActivityBriefConfigs.GetActivityGroupConfig(activityGroupId) + return config.BtnName + end + + function XActivityBriefManager.GetActivityStoryConfig() + local storyConfig = XActivityBriefConfigs.GetActivityStoryConfig() + return storyConfig + end + + function XActivityBriefManager.InitPlayedStoryTemplates(ids) + XActivityBriefConfigs.InitPlayedStoryTemplates(ids) + end + + function XActivityBriefManager.AddPlayedStoryId(id) + XActivityBriefConfigs.AddPlayedStoryId(id) + end + + function XActivityBriefManager.GetActivityConditionDescById(id) + local desc = XActivityBriefConfigs.GetActivityConditionDescById(id) + return desc + end + + function XActivityBriefManager.GetActivityShopIds() + local shopIds = {} + + local shopInfoIds = ActivityConfig.ShopInfoId + for index, shopInfoId in ipairs(shopInfoIds) do + shopIds[index] = XActivityBriefConfigs.GetActivityShopByInfoId(shopInfoId).ShopId + end + + return shopIds + end + + function XActivityBriefManager.GetActivityShopNameByShopId(shopId) + return XShopManager.GetShopName(shopId) + end + + function XActivityBriefManager.GetActivityShopIdByIndex(index) + return XActivityBriefConfigs.GetActivityShopByInfoId(ActivityConfig.ShopInfoId[index]).ShopId + end + + function XActivityBriefManager.GetActivityShopConditionByShopId(shopId) + return XShopManager.GetShopConditionIdList(shopId) + end + + function XActivityBriefManager.GetActivityShopItemBgByIndex(index) + return XActivityBriefConfigs.GetActivityShopByInfoId(ActivityConfig.ShopInfoId[index]).ShopItemBg + end + + function XActivityBriefManager.GetActivityShopBgByIndex(index) + return XActivityBriefConfigs.GetActivityShopByInfoId(ActivityConfig.ShopInfoId[index]).ShopBg + end + + function XActivityBriefManager.GetActivityShopIconByIndex(index) + return XActivityBriefConfigs.GetActivityShopByInfoId(ActivityConfig.ShopInfoId[index]).ShopIcon + end + + function XActivityBriefManager.GetActivityMain3DBg() + return ActivityConfig.Main3DBg + end + + function XActivityBriefManager.GetActivityTaskBg() + return XActivityBriefConfigs.GetActivityTaskByInfoId(ActivityConfig.TaskInfoId).TaskBg + end + + function XActivityBriefManager.GetActivityTaskGotBg() + return XActivityBriefConfigs.GetActivityTaskByInfoId(ActivityConfig.TaskInfoId).TaskGotBg + end + + function XActivityBriefManager.GetActivityTaskVipBg() + return XActivityBriefConfigs.GetActivityTaskByInfoId(ActivityConfig.TaskInfoId).TaskVipBg + end + + function XActivityBriefManager.GetActivityTaskVipGotBg() + return XActivityBriefConfigs.GetActivityTaskByInfoId(ActivityConfig.TaskInfoId).TaskVipGotBg + end + + function XActivityBriefManager.GetActivityActivityPointId() + return XActivityBriefConfigs.GetActivityTaskByInfoId(ActivityConfig.TaskInfoId).ActivityPointId + end + + function XActivityBriefManager.CheckTaskIsInMark(Id) + local MaskTaskIds = XActivityBriefConfigs.GetActivityTaskByInfoId(ActivityConfig.TaskInfoId).MarkTaskId + for _, v in pairs(MaskTaskIds or {}) do + if v == Id then + return true + end + end + return false + end + + function XActivityBriefManager.GetActivityShopGoodsByShopIndex(index) + local shopId = XActivityBriefManager.GetActivityShopIdByIndex(index) + local goods = XShopManager.GetShopGoodsList(shopId) + return goods + end + + function XActivityBriefManager.GetActivityTaskTime() + local taskGroupId = XActivityBriefConfigs.GetActivityTaskByInfoId(ActivityConfig.TaskInfoId).TaskGroupId + if taskGroupId == 0 then return end + return XTaskConfig.GetTimeLimitTaskTime(taskGroupId) + end + + function XActivityBriefManager.IsActivityTaskInTime() + local taskGroupId = XActivityBriefConfigs.GetActivityTaskByInfoId(ActivityConfig.TaskInfoId).TaskGroupId + if taskGroupId == 0 then return false end + return XTaskConfig.IsTimeLimitTaskInTime(taskGroupId) + end + + function XActivityBriefManager.GetActivityTaskDatas() + local taskGroupId = XActivityBriefConfigs.GetActivityTaskByInfoId(ActivityConfig.TaskInfoId).TaskGroupId + if taskGroupId == 0 then return {} end + return XDataCenter.TaskManager.GetTimeLimitTaskListByGroupId(taskGroupId) + end + + function XActivityBriefManager.CheckAnyTaskFinished() + local taskDatas = XActivityBriefManager.GetActivityTaskDatas() + + local achieved = XDataCenter.TaskManager.TaskState.Achieved + for _, taskData in pairs(taskDatas) do + if taskData.State == achieved then + return true + end + end + + return false + end + + function XActivityBriefManager.GetNowActivityEntryConfig() + local nowSpecialActivityTemplates = {} + for _,v in pairs(XActivityBriefConfigs.GetAllActivityEntryConfig()) do + if XFunctionManager.CheckInTimeByTimeId(v.TimeId) and + (v.Condition == 0 or XConditionManager.CheckCondition(v.Condition)) then + table.insert(nowSpecialActivityTemplates, v) + end + end + + local isNewActivity = CheckIsNewSpecialActivityTemplates(nowSpecialActivityTemplates) + return nowSpecialActivityTemplates, isNewActivity + end + + function XActivityBriefManager.CheckActivityBriefOpen() + if not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.ActivityBrief) then + return false + end + + local nowTime = XTime.GetServerNowTimestamp() + return XFunctionManager.CheckInTimeByTimeId(ActivityConfig.TimeId) + end + + function XActivityBriefManager.IsFirstOpen() + if FirstOpenUi == nil then + FirstOpenUi = not XActivityBriefManager.ReadCookie(COOKIE_FIRSTOPENUI_KEY) + end + return FirstOpenUi + end + + function XActivityBriefManager.SetNotFirstOpen() + FirstOpenUi = false + CSUnityEnginePlayerPrefs.SetInt(XActivityBriefManager.GetCookieKeyStr(COOKIE_FIRSTOPENUI_KEY), 1) + CSUnityEnginePlayerPrefs.Save() + end + + function XActivityBriefManager.IsAnimConditionPassed() + local conditionId = ActivityConfig.AnimConditionId + if conditionId == 0 or conditionId == nil then + return false + end + return XConditionManager.CheckCondition(conditionId) + end + + function XActivityBriefManager.IsFirstConditionalOpen() + if FirstConditionalOpenUi == nil then + FirstConditionalOpenUi = not XActivityBriefManager.ReadCookie(COOKIE_FIRSTCONDITIONALOPENUI_KEY) + end + return FirstConditionalOpenUi + end + + function XActivityBriefManager.SetNotFirstConditionalOpen() + FirstConditionalOpenUi = false + CSUnityEnginePlayerPrefs.SetInt(XActivityBriefManager.GetCookieKeyStr(COOKIE_FIRSTCONDITIONALOPENUI_KEY), 1) + CSUnityEnginePlayerPrefs.Save() + end + + function XActivityBriefManager.GetCookieKeyStr(key) + return string.format("%s%s%s", ActivityConfig.EndTimeStr, XPlayer.Id, key) + end + + function XActivityBriefManager.ReadCookie(key) + return CSUnityEnginePlayerPrefs.HasKey(XActivityBriefManager.GetCookieKeyStr(key)) + end + + + function XActivityBriefManager.InitPlayedStoryDic(ids) + for key, value in pairs(ids) do + for id, playedStoryId in pairs(value) do + PlayedStoryDic[playedStoryId] = true + end + end + end + + function XActivityBriefManager.AddPlayedStoryId(id) + PlayedStoryDic[id] = true + end + + function XActivityBriefManager.GetPlayedStoryDic() + return PlayedStoryDic + end + + function XActivityBriefManager.SendStoryId(storyId) + XNetwork.Call(MethodName.FinishBrirfStory, { Id = storyId }, function(response) + if response.Code ~= XCode.Success then + XUiManager.TipCode(response.Code) + return + end + XActivityBriefManager.AddPlayedStoryId(storyId) + end) + end + + function XActivityBriefManager.QueryStatistics(storyId) + local playeds = XActivityBriefManager.GetPlayedStoryDic() + if playeds[storyId] == true then + return + end + XActivityBriefManager.SendStoryId(storyId) + end + --@endregion + + function XActivityBriefManager.GetModelRankIndex() + ModelRankIndex = ModelRankIndex + 1 + if ModelRankIndex > MAX_MODEL_NUMBER then + ModelRankIndex = 1 + end + + return ModelRankIndex + end + + XEventManager.AddEventListener(XEventId.EVENT_LOGIN_SUCCESS, Init) + return XActivityBriefManager +end + +XRpc.NotifyBriefStoryData = function(storyData) + XDataCenter.ActivityBriefManager.InitPlayedStoryDic(storyData) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XActivityManager.lua b/Resources/Scripts/XManager/XActivityManager.lua new file mode 100644 index 00000000..d08c2601 --- /dev/null +++ b/Resources/Scripts/XManager/XActivityManager.lua @@ -0,0 +1,417 @@ +XActivityManagerCreator = function() + local pairs = pairs + local ipairs = ipairs + local tostring = tostring + local tonumber = tonumber + local tableSort = table.sort + local tableInsert = table.insert + local stringSplit = string.Split + local ParseToTimestamp = XTime.ParseToTimestamp + local CSUnityEnginePlayerPrefs = CS.UnityEngine.PlayerPrefs + local CSXTextManagerGetText = CS.XTextManager.GetText + + local SortedActivityGroupInfos = {} + local HaveReadActivityIds = {} + local SavedTimeDataDic = {} + + local METHOD_NAME = { + LinkTaskFinished = "DoClientTaskEventRequest" + } + + local XActivityManager = {} + function XActivityManager.Init() + XEventManager.AddEventListener(XEventId.EVENT_LOGIN_SUCCESS, XActivityManager.ReadCookie) + XEventManager.AddEventListener(XEventId.EVENT_REGRESSION_TASK_SCHEDULE_UPDATE, XActivityManager.ReadCookie) + XEventManager.AddEventListener(XEventId.EVENT_LOGIN_SUCCESS, XActivityManager.ReadTime) + -- XEventManager.AddEventListener(XEventId.EVENT_TASK_SYNC, XActivityManager.OnTaskDataChanged) + XActivityManager.InitSortedActivityGroupInfos() + end + + --构建活动组-活动配置索引表并分别根据SortId排序 + function XActivityManager.InitSortedActivityGroupInfos() + local sortFunc = function(l, r) + return l.SortId < r.SortId + end + + local activityGroupTemplates = XActivityConfigs.GetActivityGroupTemplates() + for groupId, template in pairs(activityGroupTemplates) do + SortedActivityGroupInfos[groupId] = { + SortId = template.SortId, + ActivityGroupCfg = template, + ActivityCfgs = {} + } + end + + local activityTemplates = XActivityConfigs.GetActivityTemplates() + for _, template in pairs(activityTemplates) do + local groupId = template.GroupId + local activityGroupCfg = SortedActivityGroupInfos[groupId] + if not activityGroupCfg then + XLog.ErrorTableDataNotFound("XActivityManager.InitSortedActivityGroupInfos", + "activityGroupCfg", "Client/Activity/ActivityGroup.tab", "GroupId", tostring(groupId)) + return + end + local activityCfgs = activityGroupCfg.ActivityCfgs + tableInsert(activityCfgs, template) + end + + for _, activityGroupInfo in pairs(SortedActivityGroupInfos) do + tableSort(activityGroupInfo.ActivityCfgs, sortFunc) + end + + tableSort(SortedActivityGroupInfos, sortFunc) + end + + function XActivityManager.PuzzleActIdToActId(subId) + local activityTemplates = XActivityConfigs.GetActivityTemplates() + for _, activityCfg in pairs(activityTemplates) do + if activityCfg.ActivityType == XActivityConfigs.ActivityType.JigsawPuzzle and activityCfg.Params[1] == subId then + return activityCfg.Id + end + end + return + end + + function XActivityManager.IsActivityOpen(activityId) + if not activityId then return false end + local activityCfg = XActivityConfigs.GetActivityTemplate(activityId) + if not activityCfg then return false end + + if activityCfg.ConditionId ~= 0 then + local result, _ = XConditionManager.CheckCondition(activityCfg.ConditionId) + if not result then + return false + end + end + + local now = XTime.GetServerNowTimestamp() + local activityType = activityCfg.ActivityType + if activityType == XActivityConfigs.ActivityType.Task then + local taskGroupId = activityCfg.Params[1] + return XTaskConfig.IsTimeLimitTaskInTime(taskGroupId) + elseif activityType == XActivityConfigs.ActivityType.SendInvitation or activityType == XActivityConfigs.ActivityType.AcceptInvitation then + if XDataCenter.RegressionManager.IsActivityOpenInUiActivityBase(activityType) then + local regressionId = activityCfg.Params[1] + if XDataCenter.RegressionManager.GetInvitationActivityId() == regressionId then + return true + end + end + return false + elseif activityType == XActivityConfigs.ActivityType.Link then + local openTime = XDataCenter.TaskManager.GetLinkTimeTaskOpenTime(activityCfg.Params[2]) + if not openTime then + return false + end + local timeLimitCfg = XTaskConfig.GetTimeLimitTaskCfg(activityCfg.Params[2]) + local durationTime = timeLimitCfg.Duration + local tempTime = openTime + durationTime + local endTime = tempTime + local nowTime = XTime.GetServerNowTimestamp() + if nowTime > openTime and nowTime < endTime then + return true + end + return false + end + + return XFunctionManager.CheckInTimeByTimeId(activityCfg.TimeId) + end + + function XActivityManager.GetActivityGroupInfos() + local groupInfos = {} + + for _, activityGroupInfo in ipairs(SortedActivityGroupInfos) do + local groupInfo = {} + + for _, activityCfg in ipairs(activityGroupInfo.ActivityCfgs) do + if XActivityManager.IsActivityOpen(activityCfg.Id) then + groupInfo.ActivityGroupCfg = groupInfo.ActivityGroupCfg or activityGroupInfo.ActivityGroupCfg + groupInfo.ActivityCfgs = groupInfo.ActivityCfgs or {} + tableInsert(groupInfo.ActivityCfgs, activityCfg) + end + end + + if next(groupInfo) then + tableInsert(groupInfos, groupInfo) + end + end + + return groupInfos + end + + function XActivityManager.GetActivityTaskData(activityId) + local activityCfg = XActivityConfigs.GetActivityTemplate(activityId) + if activityCfg.ActivityType ~= XActivityConfigs.ActivityType.Task and activityCfg.ActivityType ~= XActivityConfigs.ActivityType.ConsumeReward then + return {} + end + + local taskGroupId = activityCfg.Params[1] + return XDataCenter.TaskManager.GetTimeLimitTaskListByGroupId(taskGroupId) + end + + function XActivityManager.CheckRedPoint() + local activityTemplates = XActivityConfigs.GetActivityTemplates() + for activityId in pairs(activityTemplates) do + if XActivityManager.CheckRedPointByActivityId(activityId) then + return true + end + end + return false + end + + function XActivityManager.CheckRedPointByActivityId(activityId) + if not XActivityManager.IsActivityOpen(activityId) then + return false + end + + --任务类型特殊加入已完成小红点逻辑 + local activityCfg = XActivityConfigs.GetActivityTemplate(activityId) + if activityCfg.ActivityType == XActivityConfigs.ActivityType.Task or activityCfg.ActivityType == XActivityConfigs.ActivityType.ConsumeReward then -- 累计消费活动使用task类型红点判断 + local achieved = XDataCenter.TaskManager.TaskState.Achieved + local taskDatas = XActivityManager.GetActivityTaskData(activityId) + for _, taskData in pairs(taskDatas) do + if taskData.State == achieved then + return true + end + end + if activityCfg.Params[2] and activityCfg.Params[2] ~= 0 then -- 存在可跳转的任务面板 + return XActivityManager.CheckTaskSkipRedPoint(activityCfg.Params[2]) + end + -- 拼图活动有自己的红点判断 + elseif activityCfg.ActivityType == XActivityConfigs.ActivityType.JigsawPuzzle then + -- Params[1] 为拼图活动ID + local id = XActivityConfigs.GetActivityTemplate(activityId).Params[1] + return XDataCenter.PuzzleActivityManager.IsHaveRedPointById(id) + --发送邀请活动有自己的红点判断 + elseif activityCfg.ActivityType == XActivityConfigs.ActivityType.SendInvitation then + return XDataCenter.RegressionManager.IsSendInvitationHaveRedPoint() + --接受邀请活动有自己的红点判断 + elseif activityCfg.ActivityType == XActivityConfigs.ActivityType.AcceptInvitation then + return XDataCenter.RegressionManager.IsAcceptInvitationHaveRedPoint() + elseif activityCfg.ActivityType == XActivityConfigs.ActivityType.Link then + --取得链接公告对应的链接内容 + local linkCfg = XActivityConfigs.GetActivityLinkCfg(activityCfg.Params[1]) + --如果已经领取过了,那么就不会再显示红点了 + local TaskData = XDataCenter.TaskManager.GetTimeLimitTaskListByGroupId(activityCfg.Params[2]) + if not TaskData or not TaskData[1] then + return false + end + if TaskData[1].State == XDataCenter.TaskManager.TaskState.Achieved then + return true + end + if XDataCenter.TaskManager.IsTaskFinished(TaskData[1].Id) then + return false + end + if linkCfg.RedPointType == 1 then + return not HaveReadActivityIds[activityId] + end + if linkCfg.RedPointType == 2 then + if SavedTimeDataDic[activityId] == 0 then + return true + end + + local currentTime = XTime.GetSeverTodayFreshTime() + return currentTime ~= SavedTimeDataDic[activityId] + end + -- 跳转活动需要特殊红点显示时 + elseif activityCfg.ActivityType == XActivityConfigs.ActivityType.Skip then + local redPointCondition = XActivityBriefConfigs.GetRedPointConditionsBySkipId(activityCfg.Params[1]) + if redPointCondition then + for _, red in pairs(redPointCondition) do + if XRedPointConditions[red]:Check() then + return true + end + end + end + end + --当活动类型(ActivityType)为Shop或Skip时,红点通过本地记录来判断是否显示 + return not HaveReadActivityIds[activityId] + end + + function XActivityManager.GetCookieKeyStr() + return string.format("%s%s", tostring(XPlayer.Id), "_ActivityReadInfoCookieKey") + end + + function XActivityManager.GetTodayTimeKeyStr() + return string.format("%s%s", tostring(XPlayer.Id), "_TodayFrieTime") + end + + function XActivityManager.ReadCookie() + if not CSUnityEnginePlayerPrefs.HasKey(XActivityManager.GetCookieKeyStr()) then + return + end + + local dataStr = CSUnityEnginePlayerPrefs.GetString(XActivityManager.GetCookieKeyStr()) + local msgTab = stringSplit(dataStr, '\t') + if not msgTab or #msgTab <= 0 then + return + end + + for _, activityIdStr in ipairs(msgTab) do + local activityId = tonumber(activityIdStr) + if activityId then + local activityCfg = XActivityConfigs.GetActivityTemplate(activityId) + if XActivityManager.IsActivityOpen(activityId) or (activityCfg and activityCfg.ActivityType == XActivityConfigs.ActivityType.Link) then + HaveReadActivityIds[activityId] = true + else + HaveReadActivityIds[activityId] = nil + end + end + end + end + + --读取注册表保存的内容 + function XActivityManager.ReadTime() + if not CSUnityEnginePlayerPrefs.HasKey(XActivityManager.GetTodayTimeKeyStr()) then + return + end + + local dataStr = CSUnityEnginePlayerPrefs.GetString(XActivityManager.GetTodayTimeKeyStr()) + local msgTab = stringSplit(dataStr, '\t') + if not msgTab or #msgTab <= 0 then + return + end + + for _, timeStr in ipairs(msgTab) do + local timeCfg = stringSplit(timeStr, '|') + local activityId = tonumber(timeCfg[1]) + local time = tonumber(timeCfg[2]) + if activityId then + SavedTimeDataDic[activityId] = time + end + end + end + + function XActivityManager.OnTaskDataChanged() + if XLuaUiManager.IsUiShow("UiDialog") then + return + end + + if not XLuaUiManager.IsUiShow("UiShop") and not XLuaUiManager.IsUiShow("UiPurchase") then + return + end + + if XDataCenter.TaskManager.CheckConsumeTaskHaveReward() then + XUiManager.DialogTip(CSXTextManagerGetText("ActivityConsumeRewardDialogTipTitle"), CSXTextManagerGetText("ActivityConsumeRewardDialogTipContent"), XUiManager.DialogType.OnlySure) + end + end + + function XActivityManager.SaveInGameNoticeReadList(activityId) + if not XActivityManager.IsActivityOpen(activityId) then return end + HaveReadActivityIds[activityId] = true + + local saveContent = "" + for id in pairs(HaveReadActivityIds) do + saveContent = saveContent .. id .. '\t' + end + + CSUnityEnginePlayerPrefs.SetString(XActivityManager.GetCookieKeyStr(), saveContent) + CSUnityEnginePlayerPrefs.Save() + + XEventManager.DispatchEvent(XEventId.EVENT_ACTIVITY_ACTIVITIES_READ_CHANGE) + end + + function XActivityManager.CheckTaskSkipRedPoint(skipType) + if not XFunctionManager.IsCanSkip(skipType) then + return false + end + + if skipType == XActivityConfigs.TaskPanelSkipType.CanZhangHeMing_Qu + or skipType == XActivityConfigs.TaskPanelSkipType.CanZhangHeMing_LuNa + or skipType == XActivityConfigs.TaskPanelSkipType.CanZhangHeMing_SP + then + return XRedPointConditionFuBenDragPuzzleGameRed.Check() + elseif skipType == XActivityConfigs.TaskPanelSkipType.ChrismasTree_Dress then + return XRedPointConditionChristmasTree.Check() + elseif skipType == XActivityConfigs.TaskPanelSkipType.Couplet_Game then + return XRedPointConditionCoupletGameRed.Check() + elseif skipType == XActivityConfigs.TaskPanelSkipType.InvertCard_Game then + return XRedPointConditionInvertCardGameRed.Check() + end + end + + --链接类型的公告红点需要特殊处理 存在两种类型1.只显示一次的类型 2.每天都显示一次的类型 + function XActivityManager.HandleLinkActivityRedPoint(activityId) + if not XActivityManager.IsActivityOpen(activityId) then + return + end + + local activityCfg = XActivityConfigs.GetActivityTemplate(activityId) + local linkCfg = XActivityConfigs.GetActivityLinkCfg(activityCfg.Params[1]) + --只显示一次的类型,按照以前的方式处理 + if linkCfg.RedPointType == 1 then + HaveReadActivityIds[activityId] = true + local saveContent = "" + for id in pairs(HaveReadActivityIds) do + saveContent = saveContent .. id .. '\t' + end + + CSUnityEnginePlayerPrefs.SetString(XActivityManager.GetCookieKeyStr(), saveContent) + CSUnityEnginePlayerPrefs.Save() + XEventManager.DispatchEvent(XEventId.EVENT_ACTIVITY_ACTIVITIES_READ_CHANGE) + end + --每天都显示一次的类型,保存每天5点的时间戳,然后用这个做比较 + if linkCfg.RedPointType == 2 then + local todayTime = XTime.GetSeverTodayFreshTime() + SavedTimeDataDic[activityId] = todayTime + local saveContent = "" + for id, time in pairs(SavedTimeDataDic) do + saveContent = string.format("%s%d%s%d%s", saveContent, id, '|', time, '\t') + end + CSUnityEnginePlayerPrefs.SetString(XActivityManager.GetTodayTimeKeyStr(), saveContent) + CSUnityEnginePlayerPrefs.Save() + XEventManager.DispatchEvent(XEventId.EVENT_ACTIVITY_ACTIVITIES_READ_CHANGE) + end + end + + --点击链接的时候通知后端任务已经完成 + function XActivityManager.TellFinishLinkTask(taskId, cb) + local req = { ClientTaskType = taskId } + XNetwork.Call(METHOD_NAME.LinkTaskFinished, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + if cb then + cb() + end + end) + end + + -- [ 海外新增(Rooot活动) + XActivityManager.RoootData = { + Token = nil, + StartTime = nil, + ExchangeEndTime = nil, + } + function XActivityManager.OpenRoootUrl(hostUrl) + if not hostUrl or hostUrl == "" then + XUiManager.TipText("RoootActivityUrlError") + return + end + if XActivityManager.RoootData.Token and XActivityManager.RoootData.StartTime and XActivityManager.RoootData.ExchangeEndTime then + local nowTime = XTime.GetServerNowTimestamp() + if nowTime < XActivityManager.RoootData.StartTime or nowTime > XActivityManager.RoootData.ExchangeEndTime then + XUiManager.TipText("RoootActivityNotInTime") + end + local fullUrl = hostUrl.."?associate_token="..XActivityManager.RoootData.Token + CS.UnityEngine.Application.OpenURL(fullUrl) + else + XNetwork.Call("RoootAuthRequest", {}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XActivityManager.RoootData.Token = res.Token + XActivityManager.RoootData.StartTime = res.StartTime + XActivityManager.RoootData.ExchangeEndTime = res.ExchangeEndTime + local fullUrl = hostUrl.."?associate_token="..XActivityManager.RoootData.Token + CS.UnityEngine.Application.OpenURL(fullUrl) + end) + end + end + -- ] + + XActivityManager.Init() + + return XActivityManager +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XAgreementManager.lua b/Resources/Scripts/XManager/XAgreementManager.lua new file mode 100644 index 00000000..b02ab648 --- /dev/null +++ b/Resources/Scripts/XManager/XAgreementManager.lua @@ -0,0 +1,99 @@ +--- +--- Generated by EmmyLua(https://github.com/EmmyLua) +--- Created by admin. +--- DateTime: 2020/10/15 18:05 +--- + +XAgreementManager = XAgreementManager or {} + +XAgreementManager.UserAgreeLicence = nil + +XAgreementManager.CurAgree = "" +XAgreementManager.CurPriva = "" + +local USER_AGREEMENT_URL = "https://kurogame.net/download/termsofservice.txt" +local USER_PRIVACY_URL = "https://kurogame.net/download/privacypolicy.txt" + +local LOCAL_SAVE_AGREE = "LOCAL_SAVE_AGREE" +local LOCAL_SAVE_PRIVE = "LOCAL_SAVE_PRIVE" + +function XAgreementManager.SetUserAgreeLicence(agree) + XAgreementManager.UserAgreeLicence = agree +end + +function XAgreementManager.GetUserAgreeLicence() + return XAgreementManager.UserAgreeLicence +end + +function XAgreementManager.SetDelegate(delegate) + XAgreementManager.CheckDelegate = delegate +end + +function XAgreementManager.CheckNeedShow() + local saveAgree = XSaveTool.GetData(LOCAL_SAVE_AGREE) + local savePrive = XSaveTool.GetData(LOCAL_SAVE_PRIVE) + + if saveAgree == nil or savePrive == nil then + XAgreementManager.SetUserAgreeLicence(false) + return true + end + + if XAgreementManager.CurAgree == "" or XAgreementManager.CurPriva == "" then + XAgreementManager.CurAgree = saveAgree + XAgreementManager.CurPriva = savePrive + XAgreementManager.SetUserAgreeLicence(true) + return false + end + + if XAgreementManager.CurAgree ~= saveAgree or XAgreementManager.CurPriva ~= savePrive then + XAgreementManager.SetUserAgreeLicence(false) + return true + end + + XAgreementManager.SetUserAgreeLicence(true) + return false +end + +function XAgreementManager.LoadAgreeInfo() + XLuaUiManager.SetAnimationMask("LoadAgree", true) + XAgreementManager.NeedLoadCount = 2 + local agreementRequest = CS.UnityEngine.Networking.UnityWebRequest.Get(USER_AGREEMENT_URL) + CS.XTool.WaitNativeCoroutine(agreementRequest:SendWebRequest(), function() + if agreementRequest.isNetworkError or agreementRequest.isHttpError or agreementRequest.isError then + XLuaUiManager.SetAnimationMask("LoadAgree", false) + return + end + XAgreementManager.CurAgree = agreementRequest.downloadHandler.text or "" + agreementRequest:Dispose() + XAgreementManager.NeedLoadCount = XAgreementManager.NeedLoadCount - 1 + if XAgreementManager.NeedLoadCount == 0 then + XLuaUiManager.SetAnimationMask("LoadAgree",false) + XEventManager.DispatchEvent(XEventId.EVENT_AGREEMENT_LOAD_FINISH) + end + end) + local privacyRequest = CS.UnityEngine.Networking.UnityWebRequest.Get(USER_PRIVACY_URL) + CS.XTool.WaitNativeCoroutine(privacyRequest:SendWebRequest(), function() + if privacyRequest.isNetworkError or privacyRequest.isHttpError or privacyRequest.isError then + XLuaUiManager.SetAnimationMask("LoadAgree",false) + return + end + XAgreementManager.CurPriva = privacyRequest.downloadHandler.text or "" + privacyRequest:Dispose() + XAgreementManager.NeedLoadCount = XAgreementManager.NeedLoadCount - 1 + if XAgreementManager.NeedLoadCount == 0 then + XLuaUiManager.SetAnimationMask("LoadAgree",false) + XEventManager.DispatchEvent(XEventId.EVENT_AGREEMENT_LOAD_FINISH) + end + end) +end + +function XAgreementManager.SplitLongText(str) + local len = #str + local half = math.floor(len / 2) + local _, e = string.find(str, '\r\n', half, true) + if e ~= nil then + return string.sub(str, 1, e), string.sub(str, e + 1, len) + else + return str, "" + end +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XAntiAddictionManager.lua b/Resources/Scripts/XManager/XAntiAddictionManager.lua new file mode 100644 index 00000000..9210d5f4 --- /dev/null +++ b/Resources/Scripts/XManager/XAntiAddictionManager.lua @@ -0,0 +1,88 @@ +-- 防沉迷系统 +XAntiAddictionManagerCreator = function() + local XAntiAddictionManager = {} + + local NeedToKickOff = false + local KickMsg = nil + + local IsDrawingCard = false + local IsPaying = false + + -- 踢下线 + local KickOffAction = function() + if not NeedToKickOff then + return + end + + if KickMsg == nil or KickMsg == "" then + -- 无消息踢人,直接退出 + XUserManager.Logout(function(result) + if result then + CS.XHeroSdkAgent.NotifyKickResult(result) + end + end) + return + end + + -- 有消息,弹窗提醒 + XUiManager.SystemDialogTip(CS.XTextManager.GetText("TipTitle"), KickMsg, XUiManager.DialogType.OnlySure, nil, function() + XUserManager.Logout(function(result) + if result then + CS.XHeroSdkAgent.NotifyKickResult(result) + end + end) + end) + end + + -- 防沉迷踢人 + function XAntiAddictionManager.Kick(msg) + NeedToKickOff = true + KickMsg = msg + + if CS.XFight.Instance ~= nil then + -- 战斗中 + return + end + + if IsPaying then + -- 充值中 + return + end + + if IsDrawingCard then + -- 抽卡中 + return + end + + KickOffAction() + end + + -- 开始抽卡行为 + function XAntiAddictionManager.BeginDrawCardAction() + IsDrawingCard = true + end + + -- 结束抽卡行为 + function XAntiAddictionManager.EndDrawCardAction() + IsDrawingCard = false + KickOffAction() + end + + -- 开始充值行为 + function XAntiAddictionManager.BeginPayAction() + IsPaying = true + end + + -- 结束充值行为 + function XAntiAddictionManager.EndPayAction() + IsPaying = false + KickOffAction() + end + + -- 结束战斗行为 + function XAntiAddictionManager.EndFightAction() + KickOffAction() + end + + return XAntiAddictionManager +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XAppEventManager.lua b/Resources/Scripts/XManager/XAppEventManager.lua new file mode 100644 index 00000000..72c1e62e --- /dev/null +++ b/Resources/Scripts/XManager/XAppEventManager.lua @@ -0,0 +1,170 @@ +local Json = require("XCommon/Json") +XAppEventManager = XAppEventManager or {} + +XAppEventManager.CommonEventNameConfig = { + ["Game_Privacy"] = "Game_Privacy", + ["Change_account"] = "Change_account", + ["SDK_Initialize"] = "SDK_Initialize", + ["SDK_Login"] = "SDK_Login", + ["Completed_Registration"] = "Completed_Registration", + ["Anime_Start"] = "Anime_Start", + ["First_Battle_Finish"] = "First_Battle_Finish", + ["Second_Battle_End"] = "Second_Battle_End", + ["Third_Battle_End"] = "Third_Battle_End", + ["Newbee_Mission_End"] = "Newbee_Mission_End", + ["Purchased"] = "Purchased", + ["First_buy"] = "First_buy", + ["draws_role_10"]="10draws_role", + ["draws_weapon_10"] = "10draws_weapon", + ["draws_limit_10"] = "10draws_limit", + ["Daily_Task"] = "Daily_Task", + ["Monthly_Card"] = "Monthly_Card" +} + +local AccumulateEventConfig = { + [1] = "Total_Purchase_1", + [2] = "Total_Purchase_2", + [3] = "Total_Purchase_3", + [4] = "Total_Purchase_4", + [5] = "Total_Purchase_5", + [6] = "Total_Purchase_6", + [7] = "Total_Purchase_7", + [8] = "Total_Purchase_8", + [9] = "Total_Purchase_9", + [10] = "Total_Purchase_10", +} + +local PurchaseConfig = { + [1001] = "Redeemed_0.99", + [1002] = "Redeemed_4.99", + [1003] = "Redeemed_5.99", + [1004] = "Redeemed_9.99", + [1005] = "Redeemed_11.99", + [1006] = "Redeemed_19.99", + [1007] = "Redeemed_49.99", + [1008] = "Redeemed_99.99", +} + +local HKPurchaseConfig = { + [83028] = "Monthly_Card1", + [83029] = "Monthly_Card2", +} + +local TaskStoryHKEventConfig = { + [100] = "Newbee_Mission_End", + [320] = "Complete_C1", + [321] = "Complete_C2", + [322] = "Complete_C3", + [323] = "Complete_C4", + [324] = "Complete_C5", + [325] = "Complete_C6", + [326] = "Complete_C7", + [327] = "Complete_C8", + [3130] = "SS_1", + [3131] = "SS_3", + [3134] = "SS_9", + [3140] = "SSS_1", + [3141] = "SSS_3", + [3144] = "SSS_9", + [3150] = "TotalSkin_2", + [3151] = "TotalSkin_5", + [3152] = "TotalSkin_10" + +} + +local LevelEventConfig = { + [10] = "Level_10", + [15] = "Level_15", + [20] = "Level_20", + [25] = "Level_25", + [30] = "Level_30", + [35] = "Level_35", + [40] = "Level_40", + [45] = "Level_45", + [50] = "Level_50", + [60] = "Level_60", + [70] = "Level_70", + [80] = "Level_80", +} + +local WeeklyRewardConfig = { + [30003] = "PainGage_3", + [30006] = "PainGage_6", + [30015] = "War_3", + [30018] = "War_6" +} + +local MedalConfig = { + [1] = "Badge_Ace", + [2] = "Badge_Pioneer", + [3] = "Badge_Million", + [4] = "Badge_Beacon", + [5] = "Badge_Leader" +} + +--通用打点 +function XAppEventManager.AppLogEvent(eventName) + CS.XAppEventManager.LogAppEvent(eventName) +end + +function XAppEventManager.AppLogEventWithParameter(eventName, eventValue) + CS.XAppEventManager.LogAppEventWithParameter(eventName, eventValue) +end + +-- 领取累计充值打点 +function XAppEventManager.AccumulatePayAppLogEvent(id) + if not id or not AccumulateEventConfig[id] then + return + end + XAppEventManager.AppLogEvent(AccumulateEventConfig[id]) +end + +-- 购买黑卡打点 +function XAppEventManager.PurchasePayAppLogEvent(id) + if not id or not PurchaseConfig[id] then + return + end + XAppEventManager.AppLogEvent(PurchaseConfig[id]) +end + +-- 虹卡购买打点 +function XAppEventManager.HKPurchasePayAppLogEvent(id) + if not id or not HKPurchaseConfig[id] then + return + end + XAppEventManager.AppLogEvent(HKPurchaseConfig[id]) +end + +-- 充值 +function XAppEventManager.PayAppLogEvent(amount) + local orderStr = Json.encode({["af_revenue"] = amount, ["af_currency"] = "USD"}) + XAppEventManager.AppLogEventWithParameter(XAppEventManager.CommonEventNameConfig.Purchased, orderStr) +end + +--任务 +function XAppEventManager.TaskAppLogEvent(taskId, status) + if TaskStoryHKEventConfig[taskId] and (status == XDataCenter.TaskManager.TaskState.Achieved) then + XAppEventManager.AppLogEvent(TaskStoryHKEventConfig[taskId]) + end +end + +--等级 +function XAppEventManager.LevelAppLogEvent(level) + if LevelEventConfig[level] then + XAppEventManager.AppLogEvent(LevelEventConfig[level]) + end +end + +--周任务领奖 +function XAppEventManager.WeeklyRewardAppLogEvent(taskId) + if WeeklyRewardConfig[taskId] ~= nil then + XAppEventManager.AppLogEvent(WeeklyRewardConfig[taskId]) + end +end + +--勋章 +function XAppEventManager.MedalAppLogEvent(medalId) + if MedalConfig[medalId] ~= nil then + XAppEventManager.AppLogEvent(MedalConfig[medalId]) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XArchiveManager.lua b/Resources/Scripts/XManager/XArchiveManager.lua new file mode 100644 index 00000000..f8f79836 --- /dev/null +++ b/Resources/Scripts/XManager/XArchiveManager.lua @@ -0,0 +1,2442 @@ + +-- +-- Author: zhanghsuang、wujie +-- Note: 图鉴数据管理 + +XArchiveManagerCreator = function() + local EntityType = { + Info = 1, + Setting = 2, + Skill = 3, + } + + local tableInsert = table.insert + local XArchiveMonsterDetailEntity = require("XEntity/XArchive/XArchiveMonsterDetailEntity") + local XArchiveMonsterEntity = require("XEntity/XArchive/XArchiveMonsterEntity") + local XArchiveStoryChapterEntity = require("XEntity/XArchive/XArchiveStoryChapterEntity") + local XArchiveStoryDetailEntity = require("XEntity/XArchive/XArchiveStoryDetailEntity") + + local XArchiveCGEntity = require("XEntity/XArchive/XArchiveCGEntity") + local XArchiveCommunicationEntity = require("XEntity/XArchive/XArchiveCommunicationEntity") + local XArchiveMailEntity = require("XEntity/XArchive/XArchiveMailEntity") + local XArchiveNpcDetailEntity = require("XEntity/XArchive/XArchiveNpcDetailEntity") + local XArchiveNpcEntity = require("XEntity/XArchive/XArchiveNpcEntity") + local XArchivePartnerEntity = require("XEntity/XArchive/XArchivePartnerEntity") + local XArchivePartnerSettingEntity = require("XEntity/XArchive/XArchivePartnerSettingEntity") + + local XArchiveManager ={} + local ArchiveCfg = {} + local ArchiveMonsterCfg = {} + local ArchiveMonsterInfoCfg = {} + local ArchiveMonsterSkillCfg = {} + local ArchiveMonsterSettingCfg = {} + + -- local AwarenessSettingCfg = {} + -- local WeaponSettingCfg = {} + + -- local ArchiveWeaponGroupCfg = {} + local ArchiveWeaponTemplateIdToSettingListDic = {} + local ArchiveAwarenessGroupCfg = {} + + local ArchiveStoryChapterCfg = {} + local ArchiveStoryDetailCfg = {} + + local ArchiveStoryNpcCfg = {} + local ArchiveStoryNpcSettingCfg = {} + + local ArchiveCGGroupCfg = {} + local ArchiveCGDetailCfg = {} + + local ArchiveMailCfg = {} + local ArchiveCommunicationCfg = {} + local EventDateGroupCfg = {} + + local ArchiveAwarenessShowedStatusDic = {} + local ArchiveShowedMonsterList = {} + + local ArchiveTagList = {} + local ArchiveMonsterList = {} + local ArchiveMonsterInfoList = {} + local ArchiveMonsterSkillList = {} + local ArchiveMonsterSettingList = {} + + local MonsterRedPointDic = {} + + local ArchiveNpcToMonster = {} + local ArchiveMonsterData = {} + + local ArchiveStoryGroupList = {} + local ArchiveStoryChapterList = {} + local ArchiveStoryDetailList = {} + + local ArchiveStoryNpcList = {} + local ArchiveStoryNpcSettingList = {} + + local ArchiveCGDetailList = {} + local ArchiveShowedCGList = {} + local ArchiveCGDetailData = {} + + local ArchiveMailList = {} + local ArchiveCommunicationList = {} + + local ArchivePartnerList = {} + local ArchivePartnerSettingList = {} + local PartnerUnLockDic = {} + local PartnerUnLockSettingDic = {} + + local ArchiveMonsterUnlockIdsList = {} + local ArchiveMonsterInfoUnlockIdsList = {} + local ArchiveMonsterSkillUnlockIdsList = {} + local ArchiveMonsterSettingUnlockIdsList = {} + + local ArchiveMonsterEvaluateList = {} + local ArchiveMonsterMySelfEvaluateList = {} + local ArchiveStoryEvaluateList = {} + local ArchiveStoryMySelfEvaluateList = {} + + local LastSyncMonsterEvaluateTimes = {} + local LastSyncStoryEvaluateTimes = {} + -- 记录服务端武器数据,以TemplateId为键 + local ArchiveWeaponServerData = {} + -- 记录服务端意识数据,以TemplateId为键 + local ArchiveAwarenessServerData = {} + -- 记录suitId对应获得的数量 + local ArchiveAwarenessSuitToAwarenessCountDic = {} + -- 记录解锁的武器是否已读(解锁)(已读则无相关红点) + local ArchiveWeaponUnlockServerData = {} + -- 记录解锁的意识套装是否已读(解锁) + local ArchiveAwarenessSuitUnlockServerData = {} + -- 记录服务端武器设定已读(解锁)数据,以SettingId为键 + local ArchiveWeaponSettingUnlockServerData = {} + -- 记录服务端意识设定已读(解锁)数据,以SettingId为键 + local ArchiveAwarenessSettingUnlockServerData = {} + + -->>>红点相关 + local ArchiveWeaponRedPointCountDic = {} --每个武器类型拥有的红点数量 + local ArchiveWeaponTotalRedPointCount = 0 --武器图鉴拥有的红点数量 + + local ArchiveAwarenessSuitRedPointCountDic = {} --每个意识获取类型下对应套装拥有的红点数量 + local ArchiveAwarenessSuitTotalRedPointCount = 0 --意识图鉴拥有的红点数量 + + local ArchiveWeaponSettingCanUnlockDic = {} --武器设定可以解锁的 + local ArchiveNewWeaponSettingIdsDic = {} --武器id对应的新的武器设定ids + local ArchiveWeaponSettingRedPointCountDic = {} --每个武器类型下对应设定拥有的红点数量 + local ArchiveWeaponSettingTotalRedPointCount = 0 --武器设定拥有的总红点数量 + + local ArchiveAwarenessSettingCanUnlockDic = {} --意识设定可以解锁的 + local ArchiveNewAwarenessSettingIdsDic = {} --意识suitId对应的新的设定ids + local ArchiveAwarenessSettingRedPointCountDic = {} --每个意识获取类型下对应设定拥有的红点数量 + local ArchiveAwarenessSettingTotalRedPointCount = 0 --意识设定拥有的总红点数量 + --<<<红点相关 + + XArchiveManager.EquipInfoChildUiType = { + Details = 1, + Setting = 2, + } + + XArchiveManager.MonsterRedPointType = { + Monster = 1, + MonsterInfo = 2, + MonsterSkill = 3, + MonsterSetting = 4, + } + + local SYNC_EVALUATE_SECOND = 5 + + local METHOD_NAME = { + GetEvaluateRequest = "GetEvaluateRequest", + GetStoryEvaluateRequest = "GetStoryEvaluateRequest", + ArchiveEvaluateRequest = "ArchiveEvaluateRequest", + ArchiveGiveLikeRequest = "ArchiveGiveLikeRequest", + UnlockMonsterSettingRequest = "UnlockMonsterSettingRequest", + UnlockArchiveMonsterRequest = "UnlockArchiveMonsterRequest", + UnlockMonsterInfoRequest = "UnlockMonsterInfoRequest", + UnlockMonsterSkillRequest = "UnlockMonsterSkillRequest", + + UnlockArchiveWeaponRequest = "UnlockArchiveWeaponRequest", + UnlockArchiveAwarenessRequest = "UnlockArchiveAwarenessRequest", + UnlockWeaponSettingRequest = "UnlockWeaponSettingRequest", + UnlockAwarenessSettingRequest = "UnlockAwarenessSettingRequest", + } + + function XArchiveManager.Init() + PartnerUnLockSettingDic = {} + PartnerUnLockDic = {} + + ArchiveCfg = XArchiveConfigs.GetArchiveConfigs()--图鉴入口 + -- AwarenessSettingCfg = XArchiveConfigs.GetAwarenessSettings()--意识设定 + -- WeaponSettingCfg = XArchiveConfigs.GetWeaponSettings()--武器设定 + + ArchiveMonsterCfg = XArchiveConfigs.GetArchiveMonsterConfigs()--图鉴怪物 + ArchiveTagList = XArchiveConfigs.GetArchiveTagAllList()--图鉴标签 + ArchiveMonsterInfoCfg = XArchiveConfigs.GetArchiveMonsterInfoConfigs()--图鉴怪物信息 + ArchiveMonsterSkillCfg = XArchiveConfigs.GetArchiveMonsterSkillConfigs()--图鉴怪物技能 + ArchiveMonsterSettingCfg = XArchiveConfigs.GetArchiveMonsterSettingConfigs()--图鉴怪物设定 + + -- ArchiveWeaponGroupCfg = XArchiveConfigs.GetWeaponGroup() + ArchiveWeaponTemplateIdToSettingListDic = XArchiveConfigs.GetWeaponTemplateIdToSettingListDic() + ArchiveAwarenessGroupCfg = XArchiveConfigs.GetAwarenessGroup() + ArchiveAwarenessShowedStatusDic = XArchiveConfigs.GetAwarenessShowedStatusDic() + + ArchiveStoryGroupList = XArchiveConfigs.GetArchiveStoryGroupAllList() + ArchiveStoryChapterCfg = XArchiveConfigs.GetArchiveStoryChapterConfigs() + ArchiveStoryDetailCfg = XArchiveConfigs.GetArchiveStoryDetailConfigs() + + ArchiveStoryNpcCfg = XArchiveConfigs.GetArchiveStoryNpcConfigs()--图鉴NPC + ArchiveStoryNpcSettingCfg = XArchiveConfigs.GetArchiveStoryNpcSettingConfigs()--图鉴NPC设定 + + ArchiveCGGroupCfg = XArchiveConfigs.GetArchiveCGGroupConfigs()--图鉴CG组信息 + ArchiveCGDetailCfg = XArchiveConfigs.GetArchiveCGDetailConfigs()--图鉴CG详情 + + ArchiveMailCfg = XArchiveConfigs.GetArchiveMailsConfigs() + ArchiveCommunicationCfg = XArchiveConfigs.GetArchiveCommunicationsConfigs() + EventDateGroupCfg = XArchiveConfigs.GetEventDateGroupsConfigs() + + XArchiveManager.InitArchiveMonsterList() + XArchiveManager.InitArchiveMonsterDetail(EntityType.Info,ArchiveMonsterInfoCfg,ArchiveMonsterInfoList,true) + XArchiveManager.InitArchiveMonsterDetail(EntityType.Skill,ArchiveMonsterSkillCfg,ArchiveMonsterSkillList,false) + XArchiveManager.InitArchiveMonsterDetail(EntityType.Setting,ArchiveMonsterSettingCfg,ArchiveMonsterSettingList,true) + + XArchiveManager.InitArchiveStoryChapterList() + XArchiveManager.InitArchiveStoryDetailAllList() + + XArchiveManager.InitArchiveStoryNpcAllList() + XArchiveManager.InitArchiveStoryNpcSettingAllList() + + XArchiveManager.InitArchiveCGAllList() + + XArchiveManager.InitArchiveMailList() + XArchiveManager.InitArchiveCommunicationList() + + XArchiveManager.InitArchivePartnerSetting() + XArchiveManager.InitArchivePartnerList() + end + --------------------------------怪物图鉴,数据初始化------------------------------------------>>> + function XArchiveManager.InitArchiveMonsterList() + ArchiveMonsterList = {} + ArchiveNpcToMonster = {} + ArchiveMonsterData = {} + for _, monster in pairs(ArchiveMonsterCfg or {}) do + if not ArchiveMonsterList[monster.Type] then + ArchiveMonsterList[monster.Type] = {} + end + local tmp = XArchiveMonsterEntity.New(monster.Id) + for _,id in pairs(monster.NpcId or {})do + ArchiveNpcToMonster[id] = monster.Id + end + tableInsert(ArchiveMonsterList[monster.Type], tmp) + end + for _,list in pairs(ArchiveMonsterList)do + XArchiveConfigs.SortByOrder(list) + for _,monster in pairs(list) do + ArchiveMonsterData[monster:GetId()] = monster + end + end + end + + function XArchiveManager.InitArchiveMonsterDetail(entityType,detailCfg,allList,IsHavetype) + for _, detail in pairs(detailCfg or {}) do + + if not allList[detail.GroupId] then + allList[detail.GroupId] = {} + end + + if IsHavetype and not allList[detail.GroupId][detail.Type] then + allList[detail.GroupId][detail.Type] = {} + end + + local tmp = XArchiveMonsterDetailEntity.New(entityType,detail.Id) + + if IsHavetype then + table.insert(allList[detail.GroupId][detail.Type], tmp) + else + table.insert(allList[detail.GroupId], tmp) + end + end + for _,group in pairs(allList) do + if IsHavetype then + for _,type in pairs(group) do + XArchiveConfigs.SortByOrder(type) + end + else + XArchiveConfigs.SortByOrder(group) + end + end + end + --------------------------------怪物图鉴,数据初始化------------------------------------------<<< + --------------------------------怪物图鉴,数据获取相关------------------------------------------>>> + + function XArchiveManager.GetArchiveMonsterEvaluate(npcId) + return ArchiveMonsterEvaluateList[npcId] or {} + end + + function XArchiveManager.GetArchiveMonsterMySelfEvaluate(npcId) + return ArchiveMonsterMySelfEvaluateList[npcId] or {} + end + + function XArchiveManager.GetArchiveMonsterEvaluateList() + return ArchiveMonsterEvaluateList + end + + function XArchiveManager.GetArchiveMonsterMySelfEvaluateList() + return ArchiveMonsterMySelfEvaluateList + end + + function XArchiveManager.GetArchiveMonsterUnlockIdsList() + return ArchiveMonsterUnlockIdsList + end + + function XArchiveManager.GetArchiveMonsterInfoUnlockIdsList() + return ArchiveMonsterInfoUnlockIdsList + end + + function XArchiveManager.GetArchiveMonsterSkillUnlockIdsList() + return ArchiveMonsterSkillUnlockIdsList + end + + function XArchiveManager.GetArchiveMonsterSettingUnlockIdsList() + return ArchiveMonsterSettingUnlockIdsList + end + + function XArchiveManager.GetArchiveMonsterEntityByNpcId(npcId) + local monsterId = XArchiveManager.GetMonsterIdByNpcId(npcId) + if monsterId == nil then + XLog.Error(string.format("npcId:%s没有在Share/Archive/Monster.tab或SameNpcGroup.tab配置", npcId)) + return nil + end + return ArchiveMonsterData[monsterId] + end + + function XArchiveManager.GetArchiveMonsterType(monsterId) + return ArchiveMonsterData[monsterId] and ArchiveMonsterData[monsterId]:GetType() or nil + end + + function XArchiveManager.GetArchives()------------------------------------修改技能设定等的条件判定 + local list = {} + for _, v in pairs(ArchiveCfg) do + local SkipFunctional = XFunctionConfig.GetSkipList(v.SkipId) + if SkipFunctional and not XFunctionManager.CheckFunctionFitter(SkipFunctional.FunctionalId) then + table.insert(list, v) + end + end + --return XArchiveConfigs.SortByOrder(list) + return list + end + + function XArchiveManager.GetMonsterKillCount(npcId) + local sameNpcId = XArchiveConfigs.GetSameNpcId(npcId) + local monsterId = ArchiveNpcToMonster[sameNpcId] + if not monsterId then return 0 end + local killCount = ArchiveMonsterData[monsterId].Kill[sameNpcId] + return killCount and killCount or 0 + end + + function XArchiveManager.GetMonsterArchiveName(monster) + if monster:GetName() then + return monster:GetName() + end + if monster:GetNpcId(1) then + return XArchiveConfigs.GetMonsterRealName(monster:GetNpcId(1)) + end + return "NULL" + end + + function XArchiveManager.GetArchiveTagList(group) + return ArchiveTagList[group] + end + + function XArchiveManager.GetArchiveMonsterList(type)--type为空时不作为判断条件,获取相应类型的图鉴怪物列表 + if type then + return ArchiveMonsterList[type] or {} + end + local list = {} + for _,tmpType in pairs(ArchiveMonsterList) do + for _,monster in pairs(tmpType) do + tableInsert(list,monster) + end + end + return XArchiveConfigs.SortByOrder(list) + end + + function XArchiveManager.GetArchiveMonsterInfoList(groupId,type)--type为空时不作为判断条件,获取相应类型的图鉴怪物信息列表 + if type then + return ArchiveMonsterInfoList[groupId] and ArchiveMonsterInfoList[groupId][type] or {} + end + local list = {} + for _,tmpType in pairs(ArchiveMonsterInfoList[groupId]) do + for _,monster in pairs(tmpType) do + tableInsert(list,monster) + end + end + return XArchiveConfigs.SortByOrder(list) + end + + function XArchiveManager.GetArchiveMonsterSkillList(groupId)--groupId为空时不作为判断条件,获取相应类型的图鉴怪物技能列表 + if groupId then + return ArchiveMonsterSkillList[groupId] or {} + end + local list = {} + for _,group in pairs(ArchiveMonsterSkillList) do + for _,monster in pairs(group) do + tableInsert(list,monster) + end + end + return XArchiveConfigs.SortByOrder(list) + end + + function XArchiveManager.GetArchiveMonsterSettingList(groupId,type)--type为空时不作为判断条件,获取相应类型的图鉴怪物设定列表 + if type then + return ArchiveMonsterSettingList[groupId] and ArchiveMonsterSettingList[groupId][type] or {} + end + local list = {} + for _,tmpType in pairs(ArchiveMonsterSettingList[groupId]) do + for _,monster in pairs(tmpType) do + tableInsert(list,monster) + end + end + return XArchiveConfigs.SortByOrder(list) + end + + function XArchiveManager.GetMonsterCompletionRate(type) + local monsterList = XArchiveManager.GetArchiveMonsterList(type) + if #monsterList < 1 then + return 0 + end + local unlockCount = 0 + for _,v in pairs(monsterList or {}) do + if not v.IsLockMain then + unlockCount = unlockCount + 1 + end + end + return math.floor((unlockCount/#monsterList)*100) + end + + function XArchiveManager.IsMonsterHaveRedPointByAll() + local IsHaveRedPoint = false + for type,_ in pairs(MonsterRedPointDic or {}) do + if XArchiveManager.IsMonsterHaveRedPointByType(type) then + IsHaveRedPoint = true + break + end + if XArchiveManager.IsMonsterHaveNewTagByType(type) then + IsHaveRedPoint = true + break + end + end + return IsHaveRedPoint + end + + function XArchiveManager.IsMonsterHaveNewTagByType(type) + local IsHaveNewTag = false + for monsterId,_ in pairs(MonsterRedPointDic[type] or {}) do + if XArchiveManager.IsMonsterHaveNewTagById(monsterId) then + IsHaveNewTag = true + break + end + end + return IsHaveNewTag + end + + function XArchiveManager.IsMonsterHaveRedPointByType(type) + local IsHaveRedPoint = false + for monsterId,_ in pairs(MonsterRedPointDic[type] or {}) do + if XArchiveManager.IsMonsterHaveRedPointById(monsterId) then + IsHaveRedPoint = true + break + end + end + return IsHaveRedPoint + end + + function XArchiveManager.IsMonsterHaveNewTagById(monsterId) + local monsterType = XArchiveManager.GetArchiveMonsterType(monsterId) + return monsterType and MonsterRedPointDic[monsterType] and + MonsterRedPointDic[monsterType][monsterId] and + MonsterRedPointDic[monsterType][monsterId].IsNewMonster or false + end + + function XArchiveManager.IsMonsterHaveRedPointById(monsterId) + return XArchiveManager.IsHaveNewMonsterInfoByNpcId(monsterId) or + XArchiveManager.IsHaveNewMonsterSkillByNpcId(monsterId) or + XArchiveManager.IsHaveNewMonsterSettingByNpcId(monsterId) + end + + function XArchiveManager.IsHaveNewMonsterInfoByNpcId(monsterId) + local monsterType = XArchiveManager.GetArchiveMonsterType(monsterId) + return monsterType and MonsterRedPointDic[monsterType] and + MonsterRedPointDic[monsterType][monsterId] and + MonsterRedPointDic[monsterType][monsterId].IsNewInfo or false + end + + function XArchiveManager.IsHaveNewMonsterSkillByNpcId(monsterId) + local monsterType = XArchiveManager.GetArchiveMonsterType(monsterId) + return monsterType and MonsterRedPointDic[monsterType] and + MonsterRedPointDic[monsterType][monsterId] and + MonsterRedPointDic[monsterType][monsterId].IsNewSkill or false + end + + function XArchiveManager.IsHaveNewMonsterSettingByNpcId(monsterId) + local monsterType = XArchiveManager.GetArchiveMonsterType(monsterId) + return monsterType and MonsterRedPointDic[monsterType] and + MonsterRedPointDic[monsterType][monsterId] and + MonsterRedPointDic[monsterType][monsterId].IsNewSetting or false + end + --------------------------------怪物图鉴,数据获取相关------------------------------------------<<< + + --------------------------------怪物图鉴,数据更新相关------------------------------------------>>> + function XArchiveManager.UpdateMonsterData() + MonsterRedPointDic = {} + XArchiveManager.UpdateMonsterList() + XArchiveManager.UpdateMonsterInfoList() + XArchiveManager.UpdateMonsterSettingList() + XArchiveManager.UpdateMonsterSkillList() + XEventManager.DispatchEvent(XEventId.EVNET_ARCHIVE_MONSTER_KILLCOUNTCHANGE) + end + + function XArchiveManager.UpdateMonsterList() --更新图鉴怪物列表数据 + local killCount = {} + local tmpData = {} + for _,showedMonster in pairs(ArchiveShowedMonsterList or {}) do + local sameNpcId = XArchiveConfigs.GetSameNpcId(showedMonster.Id) + local monsterId = ArchiveNpcToMonster[sameNpcId] + local monsterData = ArchiveMonsterData[monsterId] + if monsterId and monsterData then + tmpData.IsLockMain = false + if not killCount[sameNpcId] then killCount[sameNpcId] = 0 end + killCount[sameNpcId] = killCount[sameNpcId] + showedMonster.Killed + tmpData.Kill = tmpData.Kill or {} + tmpData.Kill[sameNpcId] = killCount[sameNpcId] + monsterData:UpdateData(tmpData) + XArchiveManager.SetMonsterRedPointDic(monsterId,XArchiveManager.MonsterRedPointType.Monster,nil) + end + end + end + + function XArchiveManager.UpdateMonsterInfoList()--更新图鉴怪物信息列表数据 + for _,showedMonster in pairs(ArchiveShowedMonsterList or {}) do + local sameNpcId = XArchiveConfigs.GetSameNpcId(showedMonster.Id) + local monsterId = ArchiveNpcToMonster[sameNpcId] + local monsterData = ArchiveMonsterData[monsterId] + if monsterId and monsterData then + for _,npcId in pairs(monsterData:GetNpcId() or {}) do + for _,type in pairs(ArchiveMonsterInfoList[npcId] or {}) do + for _,monsterInfo in pairs(type) do + local IsUnLock = false + local lockDes = "" + if monsterInfo:GetCondition() == 0 then + IsUnLock =true + else + IsUnLock,lockDes = XConditionManager.CheckCondition(monsterInfo:GetCondition(),monsterInfo:GetGroupId()) + end + local tmpData = {} + tmpData.IsLock = not IsUnLock + tmpData.LockDesc = lockDes + monsterInfo:UpdateData(tmpData) + if IsUnLock then + XArchiveManager.SetMonsterRedPointDic(monsterId,XArchiveManager.MonsterRedPointType.MonsterInfo,monsterInfo:GetId()) + end + end + end + end + end + end + end + + + + function XArchiveManager.UpdateMonsterSkillList()--更新图鉴怪物技能列表数据 + for _,showedMonster in pairs(ArchiveShowedMonsterList or {}) do + local sameNpcId = XArchiveConfigs.GetSameNpcId(showedMonster.Id) + local monsterId = ArchiveNpcToMonster[sameNpcId] + local monsterData = ArchiveMonsterData[monsterId] + if monsterId and monsterData then + for _,npcId in pairs(monsterData:GetNpcId() or {}) do + for _,monsterSkill in pairs(ArchiveMonsterSkillList[npcId] or {}) do + local IsUnLock = false + local lockDes = "" + if monsterSkill:GetCondition() == 0 then + IsUnLock =true + else + IsUnLock,lockDes = XConditionManager.CheckCondition(monsterSkill:GetCondition(),monsterSkill:GetGroupId()) + end + local tmpData = {} + tmpData.IsLock = not IsUnLock + tmpData.LockDesc = lockDes + monsterSkill:UpdateData(tmpData) + if IsUnLock then + XArchiveManager.SetMonsterRedPointDic(monsterId,XArchiveManager.MonsterRedPointType.MonsterSkill,monsterSkill:GetId()) + end + end + end + end + end + end + + function XArchiveManager.UpdateMonsterSettingList()--更新图鉴怪物设定列表数据 + for _,showedMonster in pairs(ArchiveShowedMonsterList or {}) do + local sameNpcId = XArchiveConfigs.GetSameNpcId(showedMonster.Id) + local monsterId = ArchiveNpcToMonster[sameNpcId] + local monsterData = ArchiveMonsterData[monsterId] + if monsterId and monsterData then + for _,npcId in pairs(monsterData:GetNpcId() or {}) do + for _,type in pairs(ArchiveMonsterSettingList[npcId] or {}) do + for _,monsterStting in pairs(type) do + local IsUnLock = false + local lockDes = "" + if monsterStting:GetCondition() == 0 then + IsUnLock =true + else + IsUnLock,lockDes = XConditionManager.CheckCondition(monsterStting:GetCondition(),monsterStting:GetGroupId()) + end + local tmpData = {} + tmpData.IsLock = not IsUnLock + tmpData.LockDesc = lockDes + monsterStting:UpdateData(tmpData) + if IsUnLock then + XArchiveManager.SetMonsterRedPointDic(monsterId,XArchiveManager.MonsterRedPointType.MonsterSetting,monsterStting:GetId()) + end + end + end + end + end + end + end + + function XArchiveManager.SetMonsterRedPointDic(monsterId,type,id) + local monsterType = XArchiveManager.GetArchiveMonsterType(monsterId) + if not monsterType then return end + if not MonsterRedPointDic[monsterType] then + MonsterRedPointDic[monsterType] = {} + end + if not MonsterRedPointDic[monsterType][monsterId] then + MonsterRedPointDic[monsterType][monsterId] = {} + end + if type == XArchiveManager.MonsterRedPointType.Monster then + if not ArchiveMonsterUnlockIdsList[monsterId] then + MonsterRedPointDic[monsterType][monsterId].IsNewMonster = true + end + elseif type == XArchiveManager.MonsterRedPointType.MonsterInfo then + if not ArchiveMonsterInfoUnlockIdsList[id] then + MonsterRedPointDic[monsterType][monsterId].IsNewInfo = true + end + elseif type == XArchiveManager.MonsterRedPointType.MonsterSkill then + if not ArchiveMonsterSkillUnlockIdsList[id] then + MonsterRedPointDic[monsterType][monsterId].IsNewSkill = true + end + elseif type == XArchiveManager.MonsterRedPointType.MonsterSetting then + if not ArchiveMonsterSettingUnlockIdsList[id] then + MonsterRedPointDic[monsterType][monsterId].IsNewSetting = true + end + end + + end + + function XArchiveManager.ClearMonsterRedPointDic(monsterId,type) + local monsterType = XArchiveManager.GetArchiveMonsterType(monsterId) + if not monsterType then return end + if not MonsterRedPointDic[monsterType] then return end + if not MonsterRedPointDic[monsterType][monsterId] then return end + if type == XArchiveManager.MonsterRedPointType.Monster then + MonsterRedPointDic[monsterType][monsterId].IsNewMonster = false + elseif type == XArchiveManager.MonsterRedPointType.MonsterInfo then + MonsterRedPointDic[monsterType][monsterId].IsNewInfo = false + elseif type == XArchiveManager.MonsterRedPointType.MonsterSkill then + MonsterRedPointDic[monsterType][monsterId].IsNewSkill = false + elseif type == XArchiveManager.MonsterRedPointType.MonsterSetting then + MonsterRedPointDic[monsterType][monsterId].IsNewSetting = false + end + if not MonsterRedPointDic[monsterType][monsterId].IsNewMonster and + not MonsterRedPointDic[monsterType][monsterId].IsNewInfo and + not MonsterRedPointDic[monsterType][monsterId].IsNewSkill and + not MonsterRedPointDic[monsterType][monsterId].IsNewSetting then + + MonsterRedPointDic[monsterType][monsterId] = nil + end + end + + function XArchiveManager.SetArchiveShowedMonsterList(list) + for _,monster in pairs(list or {}) do + ArchiveShowedMonsterList[monster.Id] = monster + end + end + + function XArchiveManager.AddArchiveShowedMonsterList(list) + for _,monster in pairs(list or {}) do + if not ArchiveShowedMonsterList[monster] then + ArchiveShowedMonsterList[monster.Id] = monster + else + ArchiveShowedMonsterList[monster.Id].Killed = monster.Killed + end + end + end + + function XArchiveManager.SetArchiveMonsterEvaluate(evaluates) + for _,evaluate in pairs(evaluates or {}) do + if evaluate and evaluate.Id then + ArchiveMonsterEvaluateList[evaluate.Id] = evaluate + for index,tag in pairs(ArchiveMonsterEvaluateList[evaluate.Id].Tags) do + local tagCfg = XArchiveConfigs.GetArchiveTagCfgById(tag.Id) + if tagCfg and tagCfg.IsNotShow == 1 then + ArchiveMonsterEvaluateList[evaluate.Id].Tags[index] = nil + end + end + end + end + end + + function XArchiveManager.SetArchiveMonsterMySelfEvaluate(mySelfEvaluates) + for _,mySelfEvaluate in pairs(mySelfEvaluates or {}) do + if mySelfEvaluate and mySelfEvaluate.Id then + ArchiveMonsterMySelfEvaluateList[mySelfEvaluate.Id] = mySelfEvaluate + for index,tag in pairs(ArchiveMonsterMySelfEvaluateList[mySelfEvaluate.Id].Tags) do + local tagCfg = XArchiveConfigs.GetArchiveTagCfgById(tag) + if tagCfg and tagCfg.IsNotShow == 1 then + ArchiveMonsterMySelfEvaluateList[mySelfEvaluate.Id].Tags[index] = nil + end + end + end + end + end + + function XArchiveManager.SetArchiveMonsterMySelfEvaluateLikeStatus(npcId,likeState) + if not ArchiveMonsterMySelfEvaluateList[npcId] then + ArchiveMonsterMySelfEvaluateList[npcId] ={} + end + ArchiveMonsterMySelfEvaluateList[npcId].LikeStatus = likeState + end + + function XArchiveManager.SetArchiveMonsterMySelfEvaluateDifficulty(npcId,score,difficulty,tags) + if not ArchiveMonsterMySelfEvaluateList[npcId] then + ArchiveMonsterMySelfEvaluateList[npcId] ={} + end + ArchiveMonsterMySelfEvaluateList[npcId].Score = score + ArchiveMonsterMySelfEvaluateList[npcId].Difficulty = difficulty + ArchiveMonsterMySelfEvaluateList[npcId].Tags = tags + end + + function XArchiveManager.SetArchiveMonsterUnlockIdsList(list) + for _,id in pairs(list) do + ArchiveMonsterUnlockIdsList[id] = true + end + end + + function XArchiveManager.SetArchiveMonsterInfoUnlockIdsList(list) + for _,id in pairs(list) do + ArchiveMonsterInfoUnlockIdsList[id] = true + end + end + + function XArchiveManager.SetArchiveMonsterSkillUnlockIdsList(list) + for _,id in pairs(list) do + ArchiveMonsterSkillUnlockIdsList[id] = true + end + end + + function XArchiveManager.SetArchiveMonsterSettingUnlockIdsList(list) + for _,id in pairs(list) do + ArchiveMonsterSettingUnlockIdsList[id] = true + end + end + + function XArchiveManager.ClearMonsterNewTag(datas) + local idList = {} + + if not datas then + return + end + + local IsHasNew = false + for _,data in pairs(datas) do + if XArchiveManager.IsMonsterHaveNewTagById(data.Id) then + IsHasNew = true + break + end + end + if not IsHasNew then return end + + for _,data in pairs(datas) do + if not data.IsLockMain then + tableInsert(idList,data.Id) + end + end + + if #idList < 1 then + return + end + + XDataCenter.ArchiveManager.UnlockArchiveMonster(idList,function () + for _,id in pairs(idList) do + XDataCenter.ArchiveManager.ClearMonsterRedPointDic(id,XDataCenter.ArchiveManager.MonsterRedPointType.Monster) + end + XDataCenter.ArchiveManager.SetArchiveMonsterUnlockIdsList(idList) + XEventManager.DispatchEvent(XEventId.EVNET_ARCHIVE_MONSTER_UNLOCKMONSTER) + end) + end + + function XArchiveManager.ClearDetailRedPoint(type,datas) + local idList = {} + if not datas then + return + end + --------------------检测各类型是否有新增记录------------------ + if type == XArchiveConfigs.MonsterDetailType.Info then + local IsHasNew = false + for _,data in pairs(datas) do + if XArchiveManager.IsHaveNewMonsterInfoByNpcId(data:GetId()) then + IsHasNew = true + break + end + end + if not IsHasNew then return end + elseif type == XArchiveConfigs.MonsterDetailType.Setting then + local IsHasNew = false + for _,data in pairs(datas) do + if XArchiveManager.IsHaveNewMonsterSettingByNpcId(data:GetId()) then + IsHasNew = true + break + end + end + if not IsHasNew then return end + elseif type == XArchiveConfigs.MonsterDetailType.Skill then + local IsHasNew = false + for _,data in pairs(datas) do + if XArchiveManager.IsHaveNewMonsterSkillByNpcId(data:GetId()) then + IsHasNew = true + break + end + end + if not IsHasNew then return end + end + --------------------将各类型新增记录的ID放入一个List------------------ + for _,data in pairs(datas) do + for _,npcId in pairs(data:GetNpcId() or {}) do + if type == XArchiveConfigs.MonsterDetailType.Info then + local list = XArchiveManager.GetArchiveMonsterInfoList(npcId,nil) + for _,info in pairs(list or {}) do + if not info:GetIsLock() then + tableInsert(idList,info:GetId()) + end + end + elseif type == XArchiveConfigs.MonsterDetailType.Setting then + local list = XArchiveManager.GetArchiveMonsterSettingList(npcId,nil) + for _,setting in pairs(list or {}) do + if not setting:GetIsLock() then + tableInsert(idList,setting:GetId()) + end + end + elseif type == XArchiveConfigs.MonsterDetailType.Skill then + local list = XArchiveManager.GetArchiveMonsterSkillList(npcId) + for _,skill in pairs(list or {}) do + if not skill:GetIsLock() then + tableInsert(idList,skill:GetId()) + end + end + end + end + end + + if #idList < 1 then + return + end + --------------------将各类型新增记录的红点取消通知服务器------------------ + if type == XArchiveConfigs.MonsterDetailType.Info then + XArchiveManager.UnlockMonsterInfo(idList,function () + for _,data in pairs(datas) do + XArchiveManager.ClearMonsterRedPointDic(data:GetId(),XArchiveManager.MonsterRedPointType.MonsterInfo) + end + XArchiveManager.SetArchiveMonsterInfoUnlockIdsList(idList) + XEventManager.DispatchEvent(XEventId.EVNET_ARCHIVE_MONSTER_UNLOCKMONSTERINFO) + end) + elseif type == XArchiveConfigs.MonsterDetailType.Setting then + XArchiveManager.UnlockMonsterSetting(idList,function () + for _,data in pairs(datas) do + XArchiveManager.ClearMonsterRedPointDic(data:GetId(),XArchiveManager.MonsterRedPointType.MonsterSetting) + end + XArchiveManager.SetArchiveMonsterSettingUnlockIdsList(idList) + XEventManager.DispatchEvent(XEventId.EVNET_ARCHIVE_MONSTER_UNLOCKMONSTERSETTING) + end) + elseif type == XArchiveConfigs.MonsterDetailType.Skill then + XArchiveManager.UnlockMonsterSkill(idList,function () + for _,data in pairs(datas) do + XArchiveManager.ClearMonsterRedPointDic(data:GetId(),XArchiveManager.MonsterRedPointType.MonsterSkill) + end + XArchiveManager.SetArchiveMonsterSkillUnlockIdsList(idList) + XEventManager.DispatchEvent(XEventId.EVNET_ARCHIVE_MONSTER_UNLOCKMONSTERSKILL) + end) + end + end + + function XArchiveManager.GetMonsterEvaluateFromSever(NpcIds, cb) + local now = XTime.GetServerNowTimestamp() + local monsterId = ArchiveNpcToMonster[NpcIds[1]] + local syscTime = LastSyncMonsterEvaluateTimes[monsterId] + + if syscTime and now - syscTime < SYNC_EVALUATE_SECOND then + if cb then + cb() + return + end + end + + XNetwork.Call(METHOD_NAME.GetEvaluateRequest, {Ids = NpcIds}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XArchiveManager.SetArchiveMonsterEvaluate(res.Evaluates) + XArchiveManager.SetArchiveMonsterMySelfEvaluate(res.PersonalEvaluates) + LastSyncMonsterEvaluateTimes[monsterId] = XTime.GetServerNowTimestamp() + if cb then cb() end + end) + end + + function XArchiveManager.MonsterGiveEvaluate(npcId ,score ,difficulty ,tags ,cbBeFore ,cbAfter) + local type = XArchiveConfigs.SubSystemType.Monster + local tb = {Id = npcId ,Type = type ,Score = score ,Difficulty = difficulty ,Tags = tags} + XNetwork.Call(METHOD_NAME.ArchiveEvaluateRequest, tb, function(res) + if cbBeFore then cbBeFore() end + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XArchiveManager.SetArchiveMonsterMySelfEvaluateDifficulty(npcId,score,difficulty,tags) + if cbAfter then cbAfter() end + end) + end + + function XArchiveManager.MonsterGiveLike(likeList ,cb) + local type = XArchiveConfigs.SubSystemType.Monster + XNetwork.Call(METHOD_NAME.ArchiveGiveLikeRequest, {LikeList = likeList ,Type = type}, function(res) + if cb then cb() end + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + for _,id in pairs(res.SuccessIds or {}) do + for _,like in pairs(likeList or {}) do + if id == like.Id then + XArchiveManager.SetArchiveMonsterMySelfEvaluateLikeStatus(id,like.LikeStatus) + end + end + end + end) + end + + function XArchiveManager.UnlockArchiveMonster(ids,cb) + local list = {} + for _,id in pairs(ids or {}) do + if not ArchiveMonsterUnlockIdsList[id] then + tableInsert(list,id) + end + end + if #list == 0 then + return + end + XNetwork.Call(METHOD_NAME.UnlockArchiveMonsterRequest, {Ids = list}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + if cb then cb() end + end) + end + + function XArchiveManager.UnlockMonsterInfo(ids,cb) + local list = {} + for _,id in pairs(ids or {}) do + if not ArchiveMonsterInfoUnlockIdsList[id] then + tableInsert(list,id) + end + end + if #list == 0 then + return + end + XNetwork.Call(METHOD_NAME.UnlockMonsterInfoRequest, {Ids = ids}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + if cb then cb() end + end) + end + + function XArchiveManager.UnlockMonsterSkill(ids,cb) + local list = {} + for _,id in pairs(ids or {}) do + if not ArchiveMonsterSkillUnlockIdsList[id] then + tableInsert(list,id) + end + end + if #list == 0 then + return + end + XNetwork.Call(METHOD_NAME.UnlockMonsterSkillRequest, {Ids = ids}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + if cb then cb() end + end) + end + + function XArchiveManager.UnlockMonsterSetting(ids,cb) + local list = {} + for _,id in pairs(ids or {}) do + if not ArchiveMonsterSettingUnlockIdsList[id] then + tableInsert(list,id) + end + end + if #list == 0 then + return + end + XNetwork.Call(METHOD_NAME.UnlockMonsterSettingRequest, {Ids = ids}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + if cb then cb() end + end) + end + --------------------------------怪物图鉴,数据更新相关------------------------------------------<<< + --检查怪物的开放列表以及怪物的从属信息列表,检查是否有关于某个怪的新增,关于某个怪的信息开放 + --------------------------------怪物图鉴,数据检查相关------------------------------------------>>> + --------------------------------怪物图鉴,数据检查相关------------------------------------------<<< + + -- 武器、意识部分------------------->>> + + -- 武器相关 + function XArchiveManager.IsWeaponGet(templateId) + return ArchiveWeaponServerData[templateId] ~= nil + end + + function XArchiveManager.GetWeaponCollectRate() + local sumNum = XArchiveConfigs.GetWeaponSumCollectNum() + if sumNum == 0 then + return 0 + end + local haveNum = 0 + for _, _ in pairs(ArchiveWeaponServerData) do + haveNum = haveNum + 1 + end + return math.floor(haveNum * 100 / sumNum) + end + + -- 武器new标签 + function XArchiveManager.IsNewWeapon(templateId) + local isNew = false + if not ArchiveWeaponUnlockServerData[templateId] and ArchiveWeaponServerData[templateId] then + isNew = true + end + + return isNew + end + + -- 某个武器类型下是否有new标签 + function XArchiveManager.IsHaveNewWeaponByWeaponType(type) + return ArchiveWeaponRedPointCountDic[type] > 0 + end + + -- 武器图鉴是否有new标签 + function XArchiveManager.IsHaveNewWeapon() + return ArchiveWeaponTotalRedPointCount > 0 + end + + -- 武器图鉴是否有红点 + function XArchiveManager.IsNewWeaponSetting(templateId) + local newSettingList = ArchiveNewWeaponSettingIdsDic[templateId] + if newSettingList and #newSettingList > 0 then + return true + end + return false + end + + function XArchiveManager.IsWeaponSettingOpen(settingId) + return ArchiveWeaponSettingUnlockServerData[settingId] or ArchiveWeaponSettingCanUnlockDic[settingId] == true + end + + -- 武器设定有红点的列表,列表可能为空 + function XArchiveManager.GetNewWeaponSettingIdList(templateId) + return ArchiveNewWeaponSettingIdsDic[templateId] + end + + -- 某个武器类型下是否有红点 + function XArchiveManager.IsHaveNewWeaponSettingByWeaponType(type) + return ArchiveWeaponSettingRedPointCountDic[type] > 0 + end + + -- 武器图鉴是否有红点 + function XArchiveManager.IsHaveNewWeaponSetting() + return ArchiveWeaponSettingTotalRedPointCount > 0 + end + + -- 意识相关 + function XArchiveManager.IsAwarenessGet(templateId) + return ArchiveAwarenessServerData[templateId] ~= nil + end + + function XArchiveManager.GetAwarenessCollectRate() + local sumNum = XArchiveConfigs.GetAwarenessSumCollectNum() + if sumNum == 0 then + return 0 + end + local haveNum = 0 + for _, _ in pairs(ArchiveAwarenessServerData) do + haveNum = haveNum + 1 + end + return math.floor(haveNum * 100 / sumNum) + end + + -- 意识new标签 + function XArchiveManager.IsNewAwarenessSuit(suitId) + local isNew = false + if not ArchiveAwarenessSuitUnlockServerData[suitId] and ArchiveAwarenessSuitToAwarenessCountDic[suitId] then + isNew = true + end + return isNew + end + + -- 某个意识的获得类型下是否有new标签 + function XArchiveManager.IsHaveNewAwarenessSuitByGetType(type) + return ArchiveAwarenessSuitRedPointCountDic[type] > 0 + end + + -- 意识图鉴是否有new标签 + function XArchiveManager.IsHaveNewAwarenessSuit() + return ArchiveAwarenessSuitTotalRedPointCount > 0 + end + + -- 意识设定是否有红点 + function XArchiveManager.IsNewAwarenessSetting(suitId) + local newSettingList = ArchiveNewAwarenessSettingIdsDic[suitId] + if newSettingList and #newSettingList > 0 then + return true + end + return false + end + + function XArchiveManager.IsAwarenessSettingOpen(settingId) + return ArchiveAwarenessSettingUnlockServerData[settingId] or ArchiveAwarenessSettingCanUnlockDic[settingId] == true + end + + -- 有红点的意识列表 + function XArchiveManager.GetNewAwarenessSettingIdList(suitId) + return ArchiveNewAwarenessSettingIdsDic[suitId] + end + + -- 意识图鉴是否有红点 + function XArchiveManager.IsHaveNewAwarenessSetting() + return ArchiveAwarenessSettingTotalRedPointCount > 0 + end + + -- 意识的获得类型下是否有红点 + function XArchiveManager.IsHaveNewAwarenessSettingByGetType(type) + return ArchiveAwarenessSettingRedPointCountDic[type] > 0 + end + + function XArchiveManager.GetAwarenessCountBySuitId(suitId) + return ArchiveAwarenessSuitToAwarenessCountDic[suitId] or 0 + end + + function XArchiveManager.IsEquipGet(templateId) + return XArchiveManager.IsWeaponGet(templateId) or XArchiveManager.IsAwarenessGet(templateId) + end + + function XArchiveManager.GetEquipLv(templateId) + local data = ArchiveWeaponServerData[templateId] or ArchiveAwarenessServerData[templateId] + return data and data.Level or 0 + end + + function XArchiveManager.GetEquipBreakThroughTimes(templateId) + local data = ArchiveWeaponServerData[templateId] or ArchiveAwarenessServerData[templateId] + return data and data.Breakthrough or 0 + end + + + -- 从服务端获取武器和意识相关数据 + function XArchiveManager.SetEquipServerData(equipData) + local templateId + local suitId + --只有在配置表中出现id才会记录在本地的serverData + for _, data in ipairs(equipData) do + templateId = data.Id + if XDataCenter.EquipManager.IsWeaponByTemplateId(templateId) and ArchiveWeaponTemplateIdToSettingListDic[templateId] then + ArchiveWeaponServerData[templateId] = data + elseif XDataCenter.EquipManager.IsAwarenessByTemplateId(templateId) and ArchiveAwarenessShowedStatusDic[templateId] then + ArchiveAwarenessServerData[templateId] = data + suitId = XDataCenter.EquipManager.GetSuitIdByTemplateId(templateId) + ArchiveAwarenessSuitToAwarenessCountDic[suitId] = ArchiveAwarenessSuitToAwarenessCountDic[suitId] or 0 + ArchiveAwarenessSuitToAwarenessCountDic[suitId] = ArchiveAwarenessSuitToAwarenessCountDic[suitId] + 1 + end + end + end + + -- 从服务端获取武器和意识相关数据,并判断是否有新的武器或者意识 + function XArchiveManager.UpdateEquipServerData(equipData) + local templateId + --只有在配置表中出现id才会记录在本地的serverData + local isNewWeaponSetting = false + local isNewAwarenessSetting = false + local weaponIdList + local awarenessSuitIdList + local suitId + local weaponType + local awarenessSuitGetType + local settingDataList + local settingId + local conditionId + local updateSuitIdDic + for _, data in ipairs(equipData) do + templateId = data.Id + if XDataCenter.EquipManager.IsWeaponByTemplateId(templateId) and ArchiveWeaponTemplateIdToSettingListDic[templateId] then + weaponType = XDataCenter.EquipManager.GetEquipTypeByTemplateId(templateId) + if not ArchiveWeaponUnlockServerData[templateId] then + weaponIdList = weaponIdList or {} + tableInsert(weaponIdList, templateId) + if not ArchiveWeaponServerData[templateId] then + ArchiveWeaponRedPointCountDic[weaponType] = ArchiveWeaponRedPointCountDic[weaponType] + 1 + ArchiveWeaponTotalRedPointCount = ArchiveWeaponTotalRedPointCount + 1 + end + end + ArchiveWeaponServerData[templateId] = data + settingDataList = XArchiveConfigs.GetWeaponSettingList(templateId) + for _, settingData in ipairs(settingDataList) do + settingId = settingData.Id + conditionId = settingData.Condition + if not ArchiveWeaponSettingUnlockServerData[settingId] then + if not ArchiveWeaponSettingCanUnlockDic[settingId] and XConditionManager.CheckCondition(conditionId, templateId) then + isNewWeaponSetting = true + ArchiveWeaponSettingCanUnlockDic[settingId] = true + ArchiveNewWeaponSettingIdsDic[templateId] = ArchiveNewWeaponSettingIdsDic[templateId] or {} + table.insert(ArchiveNewWeaponSettingIdsDic[templateId], settingId) + ArchiveWeaponSettingRedPointCountDic[weaponType] = ArchiveWeaponSettingRedPointCountDic[weaponType] + 1 + ArchiveWeaponSettingTotalRedPointCount = ArchiveWeaponSettingTotalRedPointCount + 1 + end + end + end + + elseif XDataCenter.EquipManager.IsAwarenessByTemplateId(templateId) and ArchiveAwarenessShowedStatusDic[templateId] then + suitId = XDataCenter.EquipManager.GetSuitIdByTemplateId(templateId) + updateSuitIdDic = updateSuitIdDic or {} + updateSuitIdDic[suitId] = true + if not ArchiveAwarenessServerData[templateId] then + if not ArchiveAwarenessSuitToAwarenessCountDic[suitId] then + awarenessSuitIdList = awarenessSuitIdList or {} + tableInsert(awarenessSuitIdList, suitId) + awarenessSuitGetType = XArchiveConfigs.GetAwarenessSuitInfoGetType(suitId) + ArchiveAwarenessSuitRedPointCountDic[awarenessSuitGetType] = ArchiveAwarenessSuitRedPointCountDic[awarenessSuitGetType] + 1 + ArchiveAwarenessSuitTotalRedPointCount = ArchiveAwarenessSuitTotalRedPointCount + 1 + end + ArchiveAwarenessSuitToAwarenessCountDic[suitId] = ArchiveAwarenessSuitToAwarenessCountDic[suitId] or 0 + ArchiveAwarenessSuitToAwarenessCountDic[suitId] = ArchiveAwarenessSuitToAwarenessCountDic[suitId] + 1 + end + + ArchiveAwarenessServerData[templateId] = data + end + end + + if updateSuitIdDic then + for tmpSuitId, _ in pairs(updateSuitIdDic) do + settingDataList = XArchiveConfigs.GetAwarenessSettingList(tmpSuitId) + for _, settingData in ipairs(settingDataList) do + settingId = settingData.Id + conditionId = settingData.Condition + + if not ArchiveAwarenessSettingUnlockServerData[settingId] and + not ArchiveAwarenessSettingCanUnlockDic[settingId] and + XConditionManager.CheckCondition(conditionId, tmpSuitId) then + + isNewAwarenessSetting = true + ArchiveAwarenessSettingCanUnlockDic[settingId] = true + ArchiveNewAwarenessSettingIdsDic[tmpSuitId] = ArchiveNewAwarenessSettingIdsDic[tmpSuitId] or {} + table.insert(ArchiveNewAwarenessSettingIdsDic[tmpSuitId], settingId) + + awarenessSuitGetType = XArchiveConfigs.GetAwarenessSuitInfoGetType(tmpSuitId) + ArchiveAwarenessSettingRedPointCountDic[awarenessSuitGetType] = ArchiveAwarenessSettingRedPointCountDic[awarenessSuitGetType] + 1 + ArchiveAwarenessSettingTotalRedPointCount = ArchiveAwarenessSettingTotalRedPointCount + 1 + end + end + end + end + + if weaponIdList then + XEventManager.DispatchEvent(XEventId.EVENET_ARCHIVE_NEW_WEAPON, weaponIdList) + end + if isNewWeaponSetting then + XEventManager.DispatchEvent(XEventId.EVENET_ARCHIVE_UNLOCK_WEAPON_SETTING) + end + + if awarenessSuitIdList then + XEventManager.DispatchEvent(XEventId.EVENET_ARCHIVE_NEW_AWARENESS_SUIT, awarenessSuitIdList) + end + if isNewAwarenessSetting then + XEventManager.DispatchEvent(XEventId.EVENET_ARCHIVE_UNLOCK_AWARENESS_SETTING) + end + end + + function XArchiveManager.UpdateWeaponUnlockServerData(idList) + for _, id in ipairs(idList) do + ArchiveWeaponUnlockServerData[id] = true + end + end + + function XArchiveManager.UpdateAwarenessSuitUnlockServerData(idList) + for _, id in ipairs(idList) do + ArchiveAwarenessSuitUnlockServerData[id] = true + end + end + + function XArchiveManager.UpdateWeaponSettingUnlockServerData(idList) + for _, id in ipairs(idList) do + ArchiveWeaponSettingUnlockServerData[id] = true + end + end + + function XArchiveManager.UpdateAwarenessSettingUnlockServerData(idList) + for _, id in ipairs(idList) do + ArchiveAwarenessSettingUnlockServerData[id] = true + end + end + + function XArchiveManager.CreateRedPointCountDic() + local weaponTypeList = XArchiveConfigs.GetShowedWeaponTypeList() + local groupTypeList = XArchiveConfigs.GetAwarenessGroupTypes() + + for _,type in ipairs(weaponTypeList) do + ArchiveWeaponRedPointCountDic[type] = 0 + ArchiveWeaponSettingRedPointCountDic[type] = 0 + end + + for _, type in pairs(groupTypeList) do + ArchiveAwarenessSuitRedPointCountDic[type.GroupId] = 0 + ArchiveAwarenessSettingRedPointCountDic[type.GroupId] = 0 + end + + local weaponType + for id, _ in pairs(ArchiveWeaponServerData) do + if not ArchiveWeaponUnlockServerData[id] then + weaponType = XDataCenter.EquipManager.GetEquipTypeByTemplateId(id) + if weaponType then + ArchiveWeaponRedPointCountDic[weaponType] = ArchiveWeaponRedPointCountDic[weaponType] + 1 + ArchiveWeaponTotalRedPointCount = ArchiveWeaponTotalRedPointCount + 1 + end + end + end + + local awarenessGetType + for id, _ in pairs(ArchiveAwarenessSuitToAwarenessCountDic) do + if not ArchiveAwarenessSuitUnlockServerData[id] then + awarenessGetType = XArchiveConfigs.GetAwarenessSuitInfoGetType(id) + if ArchiveAwarenessSuitRedPointCountDic[awarenessGetType] then + ArchiveAwarenessSuitRedPointCountDic[awarenessGetType] = ArchiveAwarenessSuitRedPointCountDic[awarenessGetType] + 1 + ArchiveAwarenessSuitTotalRedPointCount = ArchiveAwarenessSuitTotalRedPointCount + 1 + end + end + end + + + local settingDataList + local settingId + for weaponId, _ in pairs(ArchiveWeaponTemplateIdToSettingListDic) do + settingDataList = XArchiveConfigs.GetWeaponSettingList(weaponId) + for _, settingData in ipairs(settingDataList) do + settingId = settingData.Id + if not ArchiveWeaponSettingUnlockServerData[settingId] and XConditionManager.CheckCondition(settingData.Condition, weaponId) then + ArchiveWeaponSettingCanUnlockDic[settingId] = true + weaponType = XDataCenter.EquipManager.GetEquipTypeByTemplateId(weaponId) + ArchiveNewWeaponSettingIdsDic[weaponId] = ArchiveNewWeaponSettingIdsDic[weaponId] or {} + table.insert(ArchiveNewWeaponSettingIdsDic[weaponId],settingId) + ArchiveWeaponSettingRedPointCountDic[weaponType] = ArchiveWeaponSettingRedPointCountDic[weaponType] + 1 + ArchiveWeaponSettingTotalRedPointCount = ArchiveWeaponSettingTotalRedPointCount + 1 + end + end + end + + local getType + for suitId, _ in pairs(ArchiveAwarenessGroupCfg) do + settingDataList = XArchiveConfigs.GetAwarenessSettingList(suitId) + for _, settingData in ipairs(settingDataList) do + settingId = settingData.Id + if not ArchiveAwarenessSettingUnlockServerData[settingId] and XConditionManager.CheckCondition(settingData.Condition, suitId) then + ArchiveAwarenessSettingCanUnlockDic[settingId] = true + getType = XArchiveConfigs.GetAwarenessSuitInfoGetType(suitId) + ArchiveNewAwarenessSettingIdsDic[suitId] = ArchiveNewAwarenessSettingIdsDic[suitId] or {} + table.insert(ArchiveNewAwarenessSettingIdsDic[suitId], settingId) + ArchiveAwarenessSettingRedPointCountDic[getType] = ArchiveAwarenessSettingRedPointCountDic[getType] + 1 + ArchiveAwarenessSettingTotalRedPointCount = ArchiveAwarenessSettingTotalRedPointCount + 1 + end + end + end + end + + function XArchiveManager.RequestUnlockWeapon(idList) + XNetwork.Call(METHOD_NAME.UnlockArchiveWeaponRequest, {Ids = idList}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + end + + local successIdList = res.SuccessIds + if successIdList then + local weaponType + for _, id in ipairs(successIdList) do + ArchiveWeaponUnlockServerData[id] = true + weaponType = XDataCenter.EquipManager.GetEquipTypeByTemplateId(id) + ArchiveWeaponRedPointCountDic[weaponType] = ArchiveWeaponRedPointCountDic[weaponType] - 1 + end + ArchiveWeaponTotalRedPointCount = ArchiveWeaponTotalRedPointCount - #successIdList + + XEventManager.DispatchEvent(XEventId.EVENET_ARCHIVE_UNLOCK_WEAPON) + end + end) + end + + function XArchiveManager.HandleCanUnlockWeapon() + local isHaveNew = XArchiveManager.IsHaveNewWeapon() + if isHaveNew then + local idList = {} + for id, _ in pairs(ArchiveWeaponServerData) do + if XArchiveManager.IsNewWeapon(id) then + table.insert(idList, id) + end + end + XArchiveManager.RequestUnlockWeapon(idList) + end + end + + function XArchiveManager.HandleCanUnlockWeaponByWeaponType(type) + local isHaveNew = XArchiveManager.IsHaveNewWeaponByWeaponType(type) + if isHaveNew then + local idList = {} + local needCheckIdList = XArchiveConfigs.GetWeaponTemplateIdListByType(type) + if needCheckIdList then + for _, id in ipairs(needCheckIdList) do + if XArchiveManager.IsNewWeapon(id) then + table.insert(idList, id) + end + end + XArchiveManager.RequestUnlockWeapon(idList) + end + end + end + + function XArchiveManager.RequestUnlockAwarenessSuit(idList) + XNetwork.Call(METHOD_NAME.UnlockArchiveAwarenessRequest, {Ids = idList}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + end + + local successIdList = res.SuccessIds + if successIdList then + local awarenessGetType + for _, id in ipairs(successIdList) do + ArchiveAwarenessSuitUnlockServerData[id] = true + awarenessGetType = XArchiveConfigs.GetAwarenessSuitInfoGetType(id) + ArchiveAwarenessSuitRedPointCountDic[awarenessGetType] = ArchiveAwarenessSuitRedPointCountDic[awarenessGetType] - 1 + end + ArchiveAwarenessSuitTotalRedPointCount = ArchiveAwarenessSuitTotalRedPointCount - #successIdList + + XEventManager.DispatchEvent(XEventId.EVENET_ARCHIVE_UNLOCK_AWARENESS_SUIT) + end + end) + end + + function XArchiveManager.HandleCanUnlockAwarenessSuit() + local isHaveNew = XArchiveManager.IsHaveNewAwarenessSuit() + if isHaveNew then + local idList = {} + for id, _ in pairs(ArchiveAwarenessSuitToAwarenessCountDic) do + if XArchiveManager.IsNewAwarenessSuit(id) then + table.insert(idList, id) + end + end + XArchiveManager.RequestUnlockAwarenessSuit(idList) + end + end + + function XArchiveManager.HandleCanUnlockAwarenessSuitByGetType(type) + local isHaveNew = XArchiveManager.IsHaveNewAwarenessSuitByGetType(type) + if isHaveNew then + local typeToGroupDatasDic = XArchiveConfigs.GetAwarenessTypeToGroupDatasDic() + local groupDataList = typeToGroupDatasDic[type] + if groupDataList then + local newSettingId + local requestIdList = {} + for _, groupData in ipairs(groupDataList) do + newSettingId = groupData.Id + if XArchiveManager.IsNewAwarenessSuit(newSettingId) then + tableInsert(requestIdList, newSettingId) + end + end + XArchiveManager.RequestUnlockAwarenessSuit(requestIdList) + end + end + end + + function XArchiveManager.CheckWeaponsCollectionLevelUp(type,curLevel) + local oldlevel = XSaveTool.GetData(string.format("%d%s%d", XPlayer.Id, "ArchiveWeaponsCollection",type)) + if not oldlevel then + XSaveTool.SaveData(string.format("%d%s%d", XPlayer.Id, "ArchiveWeaponsCollection",type), curLevel) + return false + else + if curLevel > oldlevel then + XSaveTool.SaveData(string.format("%d%s%d", XPlayer.Id, "ArchiveWeaponsCollection",type), curLevel) + return true, oldlevel + else + return false + end + end + end + + function XArchiveManager.SaveWeaponsCollectionDefaultData(type,level) + local oldlevel = XSaveTool.GetData(string.format("%d%s%d", XPlayer.Id, "ArchiveWeaponsCollection",type)) + if not oldlevel then + XSaveTool.SaveData(string.format("%d%s%d", XPlayer.Id, "ArchiveWeaponsCollection",type), level) + end + end + + function XArchiveManager.RequestUnlockWeaponSetting(settingIdList) + XNetwork.Call(METHOD_NAME.UnlockWeaponSettingRequest, {Ids = settingIdList}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + end + + local successIdList = res.SuccessIds + if successIdList then + local templateId + local weaponType + local newWeaponSettingIdList + for _, id in ipairs(successIdList) do + ArchiveWeaponSettingUnlockServerData[id] = true + ArchiveWeaponSettingCanUnlockDic[id] = nil + templateId = XArchiveConfigs.GetWeaponTemplateIdBySettingId(id) + weaponType = XDataCenter.EquipManager.GetEquipTypeByTemplateId(templateId) + ArchiveWeaponSettingRedPointCountDic[weaponType] = ArchiveWeaponSettingRedPointCountDic[weaponType] - 1 + newWeaponSettingIdList = ArchiveNewWeaponSettingIdsDic[templateId] + if newWeaponSettingIdList then + for index, settingId in ipairs(newWeaponSettingIdList) do + if id == settingId then + table.remove(newWeaponSettingIdList, index) + break + end + end + if #newWeaponSettingIdList == 0 then + ArchiveNewWeaponSettingIdsDic[templateId] = nil + end + end + end + ArchiveWeaponSettingTotalRedPointCount = ArchiveWeaponSettingTotalRedPointCount - #successIdList + + XEventManager.DispatchEvent(XEventId.EVENET_ARCHIVE_UNLOCK_WEAPON_SETTING) + end + end) + end + + function XArchiveManager.HandleCanUnlockWeaponSetting() + local isHaveNew = XArchiveManager.IsHaveNewWeaponSetting() + if isHaveNew then + local idList = {} + for id, _ in pairs(ArchiveWeaponSettingCanUnlockDic) do + tableInsert(idList, id) + end + XArchiveManager.RequestUnlockWeaponSetting(idList) + end + end + + function XArchiveManager.HandleCanUnlockWeaponSettingByWeaponType(type) + local isHaveNew = XArchiveManager.IsHaveNewWeaponSettingByWeaponType(type) + if not isHaveNew then return end + local idList = {} + local needCheckIdList = XArchiveConfigs.GetWeaponTemplateIdListByType(type) + for _, templateId in ipairs(needCheckIdList) do + if ArchiveNewWeaponSettingIdsDic[templateId] then + for _, id in ipairs(ArchiveNewWeaponSettingIdsDic[templateId]) do + tableInsert(idList, id) + end + end + end + XArchiveManager.RequestUnlockWeaponSetting(idList) + end + + function XArchiveManager.RequestUnlockAwarenessSetting(settingIdList) + XNetwork.Call(METHOD_NAME.UnlockAwarenessSettingRequest, {Ids = settingIdList}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + end + + local successIdList = res.SuccessIds + if successIdList then + local suitId + local getType + local newAwarenessSettingIdList + for _, id in ipairs(successIdList) do + ArchiveAwarenessSettingUnlockServerData[id] = true + ArchiveAwarenessSettingCanUnlockDic[id] = nil + suitId = XArchiveConfigs.GetAwarenessSuitIdBySettingId(id) + getType = XArchiveConfigs.GetAwarenessSuitInfoGetType(suitId) + ArchiveAwarenessSettingRedPointCountDic[getType] = ArchiveAwarenessSettingRedPointCountDic[getType] - 1 + newAwarenessSettingIdList = ArchiveNewAwarenessSettingIdsDic[suitId] + if newAwarenessSettingIdList then + for index, settingId in ipairs(newAwarenessSettingIdList) do + if id == settingId then + table.remove(newAwarenessSettingIdList, index) + break + end + end + if #newAwarenessSettingIdList == 0 then + ArchiveNewAwarenessSettingIdsDic[suitId] = nil + end + end + end + ArchiveAwarenessSettingTotalRedPointCount = ArchiveAwarenessSettingTotalRedPointCount - #successIdList + XEventManager.DispatchEvent(XEventId.EVENET_ARCHIVE_UNLOCK_AWARENESS_SETTING) + end + end) + end + + function XArchiveManager.HandleCanUnlockAwarenessSetting() + local isHaveNew = XArchiveManager.IsHaveNewAwarenessSetting() + if isHaveNew then + local idList = {} + for id, _ in pairs(ArchiveAwarenessSettingCanUnlockDic) do + tableInsert(idList, id) + end + XArchiveManager.RequestUnlockAwarenessSetting(idList) + end + end + + function XArchiveManager.HandleCanUnlockAwarenessSettingByGetType(type) + local isHaveNew = XArchiveManager.IsHaveNewAwarenessSettingByGetType(type) + if not isHaveNew then return end + local typeToGroupDatasDic = XArchiveConfigs.GetAwarenessTypeToGroupDatasDic() + local groupDataList = typeToGroupDatasDic[type] + if groupDataList then + local newSettingIdList + local requestIdList = {} + for _, groupData in ipairs(groupDataList) do + newSettingIdList = ArchiveNewAwarenessSettingIdsDic[groupData.Id] + if newSettingIdList then + for _, id in ipairs(newSettingIdList) do + tableInsert(requestIdList, id) + end + end + end + XArchiveManager.RequestUnlockAwarenessSetting(requestIdList) + end + end + + -- 武器、意识部分-------------------<<< + + -- 剧情相关------------->>> + + function XArchiveManager.InitArchiveStoryChapterList() + for _, chapter in pairs(ArchiveStoryChapterCfg or {}) do + + if not ArchiveStoryChapterList[chapter.GroupId] then + ArchiveStoryChapterList[chapter.GroupId] = {} + end + + local tmp = XArchiveStoryChapterEntity.New(chapter.Id) + table.insert(ArchiveStoryChapterList[chapter.GroupId], tmp) + end + for _,group in pairs(ArchiveStoryChapterList) do + XArchiveConfigs.SortByOrder(group) + end + end + + function XArchiveManager.InitArchiveStoryDetailAllList() + for _, detail in pairs(ArchiveStoryDetailCfg or {}) do + + if not ArchiveStoryDetailList[detail.ChapterId] then + ArchiveStoryDetailList[detail.ChapterId] = {} + end + + local tmp = XArchiveStoryDetailEntity.New(detail.Id) + table.insert(ArchiveStoryDetailList[detail.ChapterId], tmp) + end + for _,group in pairs(ArchiveStoryDetailList) do + XArchiveConfigs.SortByOrder(group) + end + end + + function XArchiveManager.GetArchiveStoryGroupList() + return ArchiveStoryGroupList + end + + function XArchiveManager.GetArchiveStoryEvaluate(id) + return ArchiveStoryEvaluateList[id] or {} + end + + function XArchiveManager.GetArchiveStoryMySelfEvaluate(id) + return ArchiveStoryMySelfEvaluateList[id] or {} + end + + function XArchiveManager.GetArchiveStoryEvaluateList() + return ArchiveStoryEvaluateList + end + + function XArchiveManager.GetArchiveStoryMySelfEvaluateList() + return ArchiveStoryMySelfEvaluateList + end + + function XArchiveManager.GetStoryCollectRate() + local storyDetailList = XArchiveManager.GetArchiveStoryDetailList() + if #storyDetailList < 1 then + return 0 + end + local unlockCount = 0 + for _,v in pairs(storyDetailList or {}) do + if not v:GetIsLock() then + unlockCount = unlockCount + 1 + end + end + return math.floor((unlockCount/#storyDetailList)*100) + end + + function XArchiveManager.GetArchiveStoryChapterList(groupId)--groupId为空时不作为判断条件 + if groupId then + return ArchiveStoryChapterList[groupId] or {} + end + local list = {} + for _,group in pairs(ArchiveStoryChapterList or {}) do + for _,chapter in pairs(group) do + tableInsert(list,chapter) + end + end + return XArchiveConfigs.SortByOrder(list) + end + + function XArchiveManager.GetArchiveStoryDetailList(chapterId)--chapterId为空时不作为判断条件 + if chapterId then + return ArchiveStoryDetailList[chapterId] or {} + end + local list = {} + for _,group in pairs(ArchiveStoryDetailList or {}) do + for _,detail in pairs(group) do + tableInsert(list,detail) + end + end + return XArchiveConfigs.SortByOrder(list) + end + + function XArchiveManager.GetArchiveStoryDetailIdList(chapterId) + + local list = {} + for _,detail in pairs(ArchiveStoryDetailList[chapterId] or {}) do + tableInsert(list,detail:GetId()) + end + return list + end + + function XArchiveManager.SetArchiveStoryEvaluate(likes) + for _,like in pairs(likes or {}) do + if like and like.Id then + ArchiveStoryEvaluateList[like.Id] = like + end + end + end + + function XArchiveManager.SetArchiveStoryMySelfEvaluate(mySelfLikes) + for _,myLike in pairs(mySelfLikes or {}) do + if myLike and myLike.Id then + ArchiveStoryMySelfEvaluateList[myLike.Id] = myLike + end + end + end + + function XArchiveManager.SetArchiveStoryMySelfEvaluateLikeStatus(id,likeState) + if not ArchiveStoryMySelfEvaluateList[id] then + ArchiveStoryMySelfEvaluateList[id] ={} + end + ArchiveStoryMySelfEvaluateList[id].LikeStatus = likeState + end + + function XArchiveManager.UpdateStoryData() + XArchiveManager.UpdateStoryDetailList() + XArchiveManager.UpdateStoryChapterList() + end + + function XArchiveManager.UpdateStoryChapterList()--更新图鉴剧情关卡列表数据 + for _,chapterList in pairs(ArchiveStoryChapterList or {}) do + for _,chapter in pairs(chapterList or {}) do + local IsUnLock = false + local lockDes = CS.XTextManager.GetText("StoryArchiveErrorHint") + local storyDetailList = XArchiveManager.GetArchiveStoryDetailList(chapter:GetId()) + for _,detail in pairs(storyDetailList or {}) do + IsUnLock = IsUnLock or (not detail:GetIsLock()) + if IsUnLock then + break + end + end + local tmpData = {} + tmpData.IsLock = not IsUnLock + local FirstIndex = 1 + local storyDetail = storyDetailList[FirstIndex] + if storyDetail and storyDetail:GetLockDesc() then + tmpData.LockDesc = storyDetail:GetLockDesc() + else + tmpData.LockDesc = lockDes + XLog.Error("detail is nil or LockDesc is nil by chapterId:" .. chapter:GetId()) + end + chapter:UpdateData(tmpData) + end + end + end + + function XArchiveManager.UpdateStoryDetailList()--更新图鉴剧情详细列表数据 + for _,detailList in pairs(ArchiveStoryDetailList or {}) do + for _,detail in pairs(detailList or {}) do + local IsUnLock = false + local lockDes = "" + local nowTime = XTime.GetServerNowTimestamp() + local unLockTime = detail:GetUnLockTime() and XTime.ParseToTimestamp(detail:GetUnLockTime()) or 0 + local IsPassCondition = (unLockTime ~= 0) and (nowTime > unLockTime) + if detail:GetCondition() == 0 or IsPassCondition then + IsUnLock = true + else + IsUnLock, lockDes = XConditionManager.CheckCondition(detail:GetCondition()) + end + local tmpData = {} + tmpData.IsLock = not IsUnLock + tmpData.LockDesc = lockDes + detail:UpdateData(tmpData) + end + end + end + + function XArchiveManager.GetStoryEvaluateFromSever(chapterId,Ids, cb) + local now = XTime.GetServerNowTimestamp() + local syscTime = LastSyncStoryEvaluateTimes[chapterId] + + if syscTime and now - syscTime < SYNC_EVALUATE_SECOND then + if cb then + cb() + return + end + end + + XNetwork.Call(METHOD_NAME.GetStoryEvaluateRequest, {Ids = Ids}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XArchiveManager.SetArchiveStoryEvaluate(res.Likes) + XArchiveManager.SetArchiveStoryMySelfEvaluate(res.PersonalLikes) + LastSyncStoryEvaluateTimes[chapterId] = XTime.GetServerNowTimestamp() + if cb then cb() end + end) + end + + function XArchiveManager.StoryGiveLike(likeList ,cb) + local type = XArchiveConfigs.SubSystemType.Story + XNetwork.Call(METHOD_NAME.ArchiveGiveLikeRequest, {LikeList = likeList ,Type = type}, function(res) + if cb then cb() end + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + for _,id in pairs(res.SuccessIds or {}) do + for _,like in pairs(likeList or {}) do + if id == like.Id then + XArchiveManager.SetArchiveStoryMySelfEvaluateLikeStatus(id,like.LikeStatus) + end + end + end + end) + end + -- 剧情相关-------------<<< + + -- Npc相关------------->>> + function XArchiveManager.InitArchiveStoryNpcAllList()--创建图鉴Npc数据 + for _, npcCfg in pairs(ArchiveStoryNpcCfg or {}) do + + local tmp = XArchiveNpcEntity.New(npcCfg.Id) + table.insert(ArchiveStoryNpcList, tmp) + end + XArchiveConfigs.SortByOrder(ArchiveStoryNpcList) + end + + function XArchiveManager.InitArchiveStoryNpcSettingAllList()--创建图鉴NpcSetting数据 + for _, settingCfg in pairs(ArchiveStoryNpcSettingCfg or {}) do + + if not ArchiveStoryNpcSettingList[settingCfg.GroupId] then + ArchiveStoryNpcSettingList[settingCfg.GroupId] = {} + end + + if not ArchiveStoryNpcSettingList[settingCfg.GroupId][settingCfg.Type] then + ArchiveStoryNpcSettingList[settingCfg.GroupId][settingCfg.Type] = {} + end + + local tmp = XArchiveNpcDetailEntity.New(settingCfg.Id) + table.insert(ArchiveStoryNpcSettingList[settingCfg.GroupId][settingCfg.Type], tmp) + end + for _,group in pairs(ArchiveStoryNpcSettingList) do + for _,type in pairs(group) do + XArchiveConfigs.SortByOrder(type) + end + end + end + + function XArchiveManager.UpdateStoryNpcList()--更新图鉴Npc数据 + for _,npc in pairs(ArchiveStoryNpcList or {}) do + local IsUnLock = false + local lockDes = "" + local nowTime = XTime.GetServerNowTimestamp() + local unLockTime = npc:GetUnLockTime() and XTime.ParseToTimestamp(npc:GetUnLockTime()) or 0 + local IsPassCondition = (unLockTime ~= 0) and (nowTime > unLockTime) + if npc:GetCondition() == 0 or IsPassCondition then + IsUnLock = true + else + IsUnLock, lockDes = XConditionManager.CheckCondition(npc:GetCondition()) + end + local tmpData = {} + tmpData.IsLock = not IsUnLock + tmpData.LockDesc = lockDes + npc:UpdateData(tmpData) + end + end + + function XArchiveManager.UpdateStoryNpcSettingList()--更新图鉴NpcSetting数据 + for _,settingGroupList in pairs(ArchiveStoryNpcSettingList or {}) do + for _,settingList in pairs(settingGroupList or {}) do + for _,setting in pairs(settingList or {}) do + local IsUnLock + local lockDes = "" + local nowTime = XTime.GetServerNowTimestamp() + local unLockTime = setting:GetUnLockTime() and XTime.ParseToTimestamp(setting:GetUnLockTime()) or 0 + local IsPassCondition = (unLockTime ~= 0) and (nowTime > unLockTime) + if setting:GetCondition() == 0 or IsPassCondition then + IsUnLock = true + else + IsUnLock, lockDes = XConditionManager.CheckCondition(setting:GetCondition()) + end + local tmpData = {} + tmpData.IsLock = not IsUnLock + tmpData.LockDesc = lockDes + setting:UpdateData(tmpData) + end + end + end + end + + function XArchiveManager.UpdateStoryNpcData() + XArchiveManager.UpdateStoryNpcList() + XArchiveManager.UpdateStoryNpcSettingList() + end + + function XArchiveManager.GetArchiveStoryNpcList() + return ArchiveStoryNpcList or {} + end + + function XArchiveManager.GetArchiveStoryNpcSettingList(group,type)--type为空时不作为判断条件,获取相应类型的图鉴Npc设定列表 + if type then + return ArchiveStoryNpcSettingList[group] and ArchiveStoryNpcSettingList[group][type] or {} + end + local list = {} + for _,settingList in pairs(ArchiveStoryNpcSettingList[group]) do + for _,setting in pairs(settingList) do + tableInsert(list,setting) + end + end + return XArchiveConfigs.SortByOrder(list) + end + + function XArchiveManager.GetNPCCompletionRate() + local npcList = XArchiveManager.GetArchiveStoryNpcList() + if #npcList < 1 then + return 0 + end + local unlockCount = 0 + for _,v in pairs(npcList or {}) do + if not v:GetIsLock() then + unlockCount = unlockCount + 1 + end + end + return math.floor((unlockCount/#npcList)*100) + end + -- Npc相关-------------<<< + + -- CG相关------------->>> + function XArchiveManager.InitArchiveCGAllList()--创建图鉴NpcSetting数据 + for _, CGDetailCfg in pairs(ArchiveCGDetailCfg or {}) do + + if not ArchiveCGDetailList[CGDetailCfg.GroupId] then + ArchiveCGDetailList[CGDetailCfg.GroupId] = {} + end + + local tmp = XArchiveCGEntity.New(CGDetailCfg.Id) + table.insert(ArchiveCGDetailList[CGDetailCfg.GroupId], tmp) + ArchiveCGDetailData[CGDetailCfg.Id] = tmp + end + for _,group in pairs(ArchiveCGDetailList) do + XArchiveConfigs.SortByOrder(group) + end + end + + function XArchiveManager.SetArchiveShowedCGList(idList) + for _,id in pairs(idList or {}) do + ArchiveShowedCGList[id] = id + end + end + + function XArchiveManager.UpdateCGAllList()--更新图鉴Npc数据 + for _,group in pairs(ArchiveCGDetailList or {}) do + for _,CGDetail in pairs(group) do + local lockDes = "" + local IsUnLock = "" + if ArchiveShowedCGList[CGDetail:GetId()] then + IsUnLock = true + else + if CGDetail:GetCondition() ~= 0 then + _,lockDes = XConditionManager.CheckCondition(CGDetail:GetCondition()) + end + IsUnLock = false + end + local tmpData = {} + tmpData.IsLock = not IsUnLock + tmpData.LockDesc = lockDes + CGDetail:UpdateData(tmpData) + end + end + end + + function XArchiveManager.GetArchiveCGGroupList() + local list = {} + for _,group in pairs(ArchiveCGGroupCfg) do + tableInsert(list,group) + end + return XArchiveConfigs.SortByOrder(list) + end + + function XArchiveManager.GetArchiveCGDetailList(group)--group为空时不作为判断条件,获取相应类型的图鉴CG列表 + if group then + return ArchiveCGDetailList[group] and ArchiveCGDetailList[group] or {} + end + local list = {} + for _,CGDetailGroup in pairs(ArchiveCGDetailList) do + for _,CGDetail in pairs(CGDetailGroup) do + tableInsert(list,CGDetail) + end + end + return XArchiveConfigs.SortByOrder(list) + end + + function XArchiveManager.GetCGCompletionRate(type) + local CGList = XArchiveManager.GetArchiveCGDetailList(type) + if #CGList < 1 then + return 0 + end + local unlockCount = 0 + for _,v in pairs(CGList or {}) do + if not v:GetIsLock() then + unlockCount = unlockCount + 1 + end + end + return math.floor((unlockCount/#CGList)*100) + end + + function XArchiveManager.CheckCGRedPointByGroup(groupId) + local list = XArchiveManager.GetArchiveCGDetailList(groupId) + for _,cgDetail in pairs(list) do + if XArchiveManager.CheckCGRedPoint(cgDetail:GetId()) then + return true + end + end + return false + end + + function XArchiveManager.ClearCGRedPointByGroup(groupId) + local list = XArchiveManager.GetArchiveCGDetailList(groupId) + for _,cgDetail in pairs(list) do + XArchiveManager.ClearCGRedPoint(cgDetail:GetId()) + end + XEventManager.DispatchEvent(XEventId.EVENET_ARCHIVE_MARK_CG) + end + + function XArchiveManager.ClearCGRedPointById(id) + XArchiveManager.ClearCGRedPoint(id) + XEventManager.DispatchEvent(XEventId.EVENET_ARCHIVE_MARK_CG) + end + + function XArchiveManager.CheckCGRedPoint(id) + if XSaveTool.GetData(string.format("%d%s%d", XPlayer.Id, "ArchiveCG",id)) then + return true + else + return false + end + end + + function XArchiveManager.AddNewCGRedPoint(idList) + for _,id in pairs(idList) do + if ArchiveCGDetailData[id] and ArchiveCGDetailData[id]:GetIsShowRedPoint() == 1 then + + if not XSaveTool.GetData(string.format("%d%s%d", XPlayer.Id, "ArchiveCG",id)) then + XSaveTool.SaveData(string.format("%d%s%d", XPlayer.Id, "ArchiveCG",id), id) + end + end + end + end + + function XArchiveManager.ClearCGRedPoint(id) + if XSaveTool.GetData(string.format("%d%s%d", XPlayer.Id, "ArchiveCG",id)) then + XSaveTool.RemoveData(string.format("%d%s%d", XPlayer.Id, "ArchiveCG",id)) + end + end + -- CG相关-------------<<< + + -- 邮件通讯相关------------->>> + + function XArchiveManager.InitArchiveMailList()--创建图鉴邮件数据 + for _, mailCfg in pairs(ArchiveMailCfg or {}) do + if not ArchiveMailList[mailCfg.GroupId] then + ArchiveMailList[mailCfg.GroupId] = {} + end + local tmp = XArchiveMailEntity.New(mailCfg.Id) + table.insert(ArchiveMailList[mailCfg.GroupId], tmp) + end + for _,group in pairs(ArchiveMailList) do + XArchiveConfigs.SortByOrder(group) + end + end + + function XArchiveManager.InitArchiveCommunicationList()--创建图鉴通讯数据 + for _, communicationCfg in pairs(ArchiveCommunicationCfg or {}) do + + if not ArchiveCommunicationList[communicationCfg.GroupId] then + ArchiveCommunicationList[communicationCfg.GroupId] = {} + end + + local tmp = XArchiveCommunicationEntity.New(communicationCfg.Id) + table.insert(ArchiveCommunicationList[communicationCfg.GroupId], tmp) + end + for _,group in pairs(ArchiveCommunicationList) do + XArchiveConfigs.SortByOrder(group) + end + end + + function XArchiveManager.UpdateMailList()--更新邮件数据 + for _,group in pairs(ArchiveMailList or {}) do + for _,mail in pairs(group) do + local IsUnLock = false + local lockDes = "" + local nowTime = XTime.GetServerNowTimestamp() + local unLockTime = mail:GetUnLockTime() and XTime.ParseToTimestamp(mail:GetUnLockTime()) or 0 + local IsInUnLockTime = (unLockTime == 0) or (nowTime > unLockTime) + if not IsInUnLockTime then + lockDes = CS.XTextManager.GetText("ArchiveNotUnLockTime") + IsUnLock = false + else + if mail:GetCondition() == 0 then + IsUnLock = true + else + IsUnLock, lockDes = XConditionManager.CheckCondition(mail:GetCondition()) + end + end + local tmpData = {} + tmpData.IsLock = not IsUnLock + tmpData.LockDesc = lockDes + mail:UpdateData(tmpData) + end + end + end + + function XArchiveManager.UpdateCommunicationList()--更新通讯数据 + for _,group in pairs(ArchiveCommunicationList or {}) do + for _,communication in pairs(group) do + local IsUnLock = false + local lockDes = "" + local nowTime = XTime.GetServerNowTimestamp() + local unLockTime = communication:GetUnLockTime() and XTime.ParseToTimestamp(communication:GetUnLockTime()) or 0 + local IsPassCondition = (unLockTime ~= 0) and (nowTime > unLockTime) + + if communication:GetCondition() == 0 or IsPassCondition then + IsUnLock = XPlayer.IsCommunicationMark(communication:GetCommunicationId()) + else + IsUnLock, lockDes = XConditionManager.CheckCondition(communication:GetCondition()) + end + + local tmpData = {} + tmpData.IsLock = not IsUnLock + tmpData.LockDesc = lockDes + communication:UpdateData(tmpData) + end + end + end + + function XArchiveManager.UpdateMailAndCommunicationData() + XArchiveManager.UpdateMailList() + XArchiveManager.UpdateCommunicationList() + end + + function XArchiveManager.GetArchiveCommunicationList(group)--group为空时不作为判断条件 + local list = {} + if group then + if ArchiveCommunicationList and ArchiveCommunicationList[group] then + for _,communication in pairs(ArchiveCommunicationList[group]) do + if not communication:GetIsLock() then + tableInsert(list,communication) + end + end + end + return XArchiveConfigs.SortByOrder(list) + end + + for _,communicationList in pairs(ArchiveCommunicationList) do + for _,communication in pairs(communicationList) do + if not communication:GetIsLock() then + tableInsert(list,communication) + end + end + end + return XArchiveConfigs.SortByOrder(list) + end + + function XArchiveManager.GetArchiveMailList(group)--group为空时不作为判断条件 + local list = {} + if group then + if ArchiveMailList and ArchiveMailList[group] then + for _,mail in pairs(ArchiveMailList[group]) do + if not mail:GetIsLock() then + tableInsert(list,mail) + end + end + end + return XArchiveConfigs.SortByOrder(list) + end + + for _,mailList in pairs(ArchiveMailList) do + for _,mail in pairs(mailList) do + if not mail:GetIsLock() then + tableInsert(list,mail) + end + end + end + return XArchiveConfigs.SortByOrder(list) + end + function XArchiveManager.GetEventDateGroupList() + local list = {} + for _,group in pairs(EventDateGroupCfg) do + list[group.GroupType] = list[group.GroupType] or {} + tableInsert(list[group.GroupType],group) + end + + for _,group in pairs(list)do + XArchiveConfigs.SortByOrder(group) + end + + return list + end + -- 邮件通讯相关-------------<<< + + --------------------------------伙伴图鉴相关------------------------------------------>>> + function XArchiveManager.InitArchivePartnerSetting() + ArchivePartnerSettingList = {} + local detailCfg = XArchiveConfigs.GetPartnerSettingConfigs() + for _, detail in pairs(detailCfg or {}) do + + if not ArchivePartnerSettingList[detail.GroupId] then + ArchivePartnerSettingList[detail.GroupId] = {} + end + + if not ArchivePartnerSettingList[detail.GroupId][detail.Type] then + ArchivePartnerSettingList[detail.GroupId][detail.Type] = {} + end + + local tmp = XArchivePartnerSettingEntity.New(detail.Id) + table.insert(ArchivePartnerSettingList[detail.GroupId][detail.Type], tmp) + end + for _,group in pairs(ArchivePartnerSettingList) do + for _,type in pairs(group) do + XArchiveConfigs.SortByOrder(type) + end + end + end + + function XArchiveManager.InitArchivePartnerList()--生成图鉴伙伴数据 + ArchivePartnerList = {} + local templateList = XArchiveConfigs.GetPartnerConfigs() + for _,template in pairs(templateList or {}) do + if not ArchivePartnerList[template.GroupId] then + ArchivePartnerList[template.GroupId] = {} + end + local entity = XArchivePartnerEntity.New(template.Id, + XArchiveManager.GetArchivePartnerSetting(template.Id,XArchiveConfigs.PartnerSettingType.Story), + XArchiveManager.GetArchivePartnerSetting(template.Id,XArchiveConfigs.PartnerSettingType.Setting)) + table.insert(ArchivePartnerList[template.GroupId],entity) + end + for _,group in pairs(ArchivePartnerList) do + XArchiveConfigs.SortByOrder(group) + end + end + + function XArchiveManager.UpdateArchivePartnerList()--更新图鉴伙伴数据 + for _,group in pairs(ArchivePartnerList or {}) do + for _,partner in pairs(group) do + local IsUnLock = false + if PartnerUnLockDic[partner:GetTemplateId()] then + IsUnLock = true + end + partner:UpdateData({IsArchiveLock = not IsUnLock}) + end + end + end + + function XArchiveManager.UpdateArchivePartnerSettingList()--更新图鉴伙伴设定数据 + for _,group in pairs(ArchivePartnerList or {}) do + for _,partner in pairs(group) do + partner:UpdateStoryAndSettingEntity(PartnerUnLockSettingDic) + end + end + end + + function XArchiveManager.UpdateUnLockPartnerDic(dataList) + for _,data in pairs(dataList) do + if not PartnerUnLockDic[data] then + PartnerUnLockDic[data] = data + end + end + end + + function XArchiveManager.UpdateUnLockPartnerSettingDic(dataList) + for _,data in pairs(dataList) do + if not PartnerUnLockSettingDic[data] then + PartnerUnLockSettingDic[data] = data + end + end + end + + function XArchiveManager.GetPartnerUnLockDic() + return PartnerUnLockDic + end + + function XArchiveManager.GetPartnerUnLockById(templateId) + return PartnerUnLockDic[templateId] + end + + function XArchiveManager.GetPartnerSettingUnLockDic() + return PartnerUnLockSettingDic + end + + function XArchiveManager.GetPartnerGroupList() + local list = {} + local groupConfigs = XArchiveConfigs.GetPartnerGroupConfigs() + for groupId,_ in pairs(ArchivePartnerList) do + if groupConfigs[groupId] then + table.insert(list,groupConfigs[groupId]) + end + end + XArchiveConfigs.SortByOrder(list) + return list + end + + function XArchiveManager.GetArchivePartnerList(group) + if group then + return ArchivePartnerList[group] and ArchivePartnerList[group] or {} + end + local list = {} + for _,partnerGroup in pairs(ArchivePartnerList) do + for _,partner in pairs(partnerGroup) do + tableInsert(list,partner) + end + end + return XArchiveConfigs.SortByOrder(list) + end + + function XArchiveManager.GetArchivePartnerSetting(partnerTemplateId,type) + local settingList = ArchivePartnerSettingList[partnerTemplateId] + if not settingList then + XLog.Error("Id is not exist in Share/Archive/PartnerSetting.tab".." id = " .. partnerTemplateId) + return + end + local setting = settingList[type] + if not setting then + return + end + return XArchiveConfigs.SortByOrder(setting) + end + + function XArchiveManager.GetPartnerCompletionRate(type) + local partnerList = XArchiveManager.GetArchivePartnerList(type) + if #partnerList < 1 then + return 0 + end + local unlockCount = 0 + for _,v in pairs(partnerList or {}) do + if not v:GetIsArchiveLock() then + unlockCount = unlockCount + 1 + end + end + return math.floor((unlockCount/#partnerList)*100) + end + + -- 根据npcId获取monsterId + -- PS:XArchiveConfigs.GetSameNpcId该方法关联配置的Npc的会计入图鉴击杀计算内 + -- PS:这里两张表的配置其实是强关联,详细配法最好问图鉴相关负责人 + -- PS:以后根据NpcId获取MonsterId时不要直接走ArchiveNpcToMonster变量 + function XArchiveManager.GetMonsterIdByNpcId(npcId) + local sameNpcId = XArchiveConfigs.GetSameNpcId(npcId) + return ArchiveNpcToMonster[sameNpcId] + end + + --------------------------------伙伴图鉴相关------------------------------------------<<< + + XArchiveManager.Init() + return XArchiveManager +end + + +XRpc.NotifyArchiveLoginData = function(data) + XDataCenter.ArchiveManager.SetArchiveShowedMonsterList(data.Monsters) + XDataCenter.ArchiveManager.SetArchiveMonsterSettingUnlockIdsList(data.MonsterSettings) + XDataCenter.ArchiveManager.SetArchiveMonsterUnlockIdsList(data.MonsterUnlockIds) + XDataCenter.ArchiveManager.SetArchiveMonsterInfoUnlockIdsList(data.MonsterInfos) + XDataCenter.ArchiveManager.SetArchiveMonsterSkillUnlockIdsList(data.MonsterSkills) + XDataCenter.ArchiveManager.SetEquipServerData(data.Equips) + XDataCenter.ArchiveManager.SetArchiveShowedCGList(data.UnlockCgs) + + + XDataCenter.ArchiveManager.UpdateWeaponUnlockServerData(data.WeaponUnlockIds) + XDataCenter.ArchiveManager.UpdateAwarenessSuitUnlockServerData(data.AwarenessUnlockIds) + XDataCenter.ArchiveManager.UpdateWeaponSettingUnlockServerData(data.WeaponSettings) + XDataCenter.ArchiveManager.UpdateAwarenessSettingUnlockServerData(data.AwarenessSettings) + XDataCenter.ArchiveManager.UpdateUnLockPartnerSettingDic(data.PartnerSettings) + XDataCenter.ArchiveManager.UpdateUnLockPartnerDic(data.PartnerUnlockIds) + + XDataCenter.ArchiveManager.UpdateMonsterData() + XDataCenter.ArchiveManager.UpdateCGAllList() + XDataCenter.ArchiveManager.CreateRedPointCountDic() + + XDataCenter.PartnerManager.UpdateAllPartnerStory() + XDataCenter.ArchiveManager.UpdateArchivePartnerList() + XDataCenter.ArchiveManager.UpdateArchivePartnerSettingList() +end + +XRpc.NotifyArchiveMonsterRecord = function(data) + XDataCenter.ArchiveManager.AddArchiveShowedMonsterList(data.Monsters) + XDataCenter.ArchiveManager.UpdateMonsterData() +end + +XRpc.NotifyArchiveCgs = function(data) + XDataCenter.ArchiveManager.SetArchiveShowedCGList(data.UnlockCgs) + XDataCenter.ArchiveManager.UpdateCGAllList() + XDataCenter.ArchiveManager.AddNewCGRedPoint(data.UnlockCgs) + XEventManager.DispatchEvent(XEventId.EVENET_ARCHIVE_NEW_CG) +end +-----------------武器、意识相关------------------->>> +XRpc.NotifyArchiveEquip = function(data) + XDataCenter.ArchiveManager.UpdateEquipServerData(data.Equips) +end + +-----------------武器、意识相关-------------------<<< + +-----------------伙伴相关------------------->>> + +XRpc.NotifyArchivePartners = function(data) + XDataCenter.ArchiveManager.UpdateUnLockPartnerDic(data.PartnerUnlockIds) + XDataCenter.ArchiveManager.UpdateArchivePartnerList() +end + +XRpc.NotifyPartnerSettings = function(data) + XDataCenter.ArchiveManager.UpdateUnLockPartnerSettingDic(data.PartnerSettings) + XDataCenter.ArchiveManager.UpdateArchivePartnerSettingList() + XDataCenter.PartnerManager.UpdateAllPartnerStory() +end +-----------------伙伴相关-------------------<<< \ No newline at end of file diff --git a/Resources/Scripts/XManager/XArenaManager.lua b/Resources/Scripts/XManager/XArenaManager.lua new file mode 100644 index 00000000..26b1deaf --- /dev/null +++ b/Resources/Scripts/XManager/XArenaManager.lua @@ -0,0 +1,1578 @@ +--- +--- 竞技副本管理器 +--- + +XArenaManagerCreator = function() + local XArenaManager = {} + + local SYNC_RANK_LIST_SECOND = 60 --获取排行榜List请求保护时间 + local SYNC_HALL_SECOND = 5 --获取其他请求保护时间 + local SYNC_OTHER_SECOND = 15 --获取其他请求保护时间 + local SYNC_GOURP_MEMBER_SECOND = 10 --请求小队排行保护时间 + + local LastSyncRankListTime = 0 --排行榜List最后刷新时间 + local LastHallTeamListTime = 0 --大厅队伍列表最后刷新时间 + local LastHallPlayerListTime = 0 --大厅个人玩家列表最后刷新时间 + local LastFriendPlayerTime = 0 --请求好友竞技信息最后刷新时间 + local LasGroupMemberTime = 0 --请求小队排信息最后刷新时间 + + --队伍数据 + local HallTeamMap = {} --大厅队伍 + local HallPlayerMap = {} --大厅玩家 + local FriendMap = {} --好友列表 + local TeamInfo = nil --队伍信息 + local ApplyMap = {} --申请列表 + local InviteMap = {} --邀请列表 + local HaveToRequestApplyData = -1 + + local APPLY_TYPE = { + TEAM = 1, --自己有队伍 + SINGLE = 2, --自己无队伍 + } + + --竞技全局数据 + local ActivityNo = 0 -- 活动编号 + local LastActivityNo = 0 -- 上一期活动编号 + local ActivityStatus = XArenaActivityStatus.Default --当前活动状态 + local CountDownTime = 0 -- 进入下一阶段倒计时 + local TeamStartTime = 0 -- 组队期开始时间 + local FightStartTime = 0 -- 战斗期开始时间 + local ResultStartTime = 0 -- 结算期开始时间 + local WaveRate = 0 -- 波动指数 + local WaveLastRate = 0 -- 上一期波动指数 + + --竞技排行数据 + local PlayerResultRankList = {} -- 该段位玩家排行 + local PlayerLoaclResultRanlList = nil -- 该段位玩家排行(本地数据) + local PlayerLastResultRanlList = nil -- 该段位上一期玩家排行 + local TeamRankChallengeId = 0 -- 队伍排行榜的挑战ID + local TeamRankData = {} -- 队伍排行 + local TeamResultList = {} -- 该段位队员成绩 + local TeamLastResultList = nil -- 该段位队员上一期成绩 + -- local AreaIdToStageDetailList = {} -- 各战区玩家通关详情 + local LastDataRespone = nil + + --竞技个人数据 + local ChallengeId = 0 -- 挑战Id(根据玩家等级与竞技段位决定) + local ContributeScore = 0 -- 当前战区贡献总分 + local LastChallengeId = 0 -- 上一期挑战Id(根据玩家等级与竞技段位决定) + local ArenaLevel = 0 -- 竞技段位 + local LastArenaLevel = 0 -- 上一期竞技段位 + local LastContributeScore = 0 --上一期战区贡献分 + local IsJoinActivity = false -- 是否已报名 + local UnlockCount = 0 -- 剩余解锁次数 + local TotalPoint = 0 -- 总分数 + local AreaDatas = {} -- 战区信息列表 + + local ArenaActivityResultData = nil --竞技奖励缓存数据 + local ArenaStatusInFightChangeCache = false -- 竞技状态改变是否在战斗中缓存 + + local EnterAreaStageInfo = {} -- 进入战斗的区域信息 + + local MaxPointStageDic = {} -- 已经通关的满分列表 + + local ArenaRequest = { + RequestMyTeamInfo = "MyTeamRequest", -- 获取我的队伍信息 + RequestHallTeamList = "HallTeamRequest", -- 获取大厅队伍列表 + RequestHallPlayerList = "HallPlayerRequest", -- 获取大厅个人玩家列表 + RequestApplyData = "ApplyDataRequest", -- 获取邀请申请信息列表 + RequestFriendArenaInfo = "FriendPlayerRequest", -- 请求好友竞技信息 + RequestCreateTeam = "CreateTeamRequest", -- 请求创建队伍 + RequestApplyTeam = "ApplyTeamRequest", -- 申请入队 + RequestRefuseApply = "RefuseApplyRequest", -- 拒绝申请 + RequestAcceptApply = "AcceptApplyRequest", -- 接受申请 + RequestLeaveTeam = "LeaveTeamRequest", -- 请求离队 + RequestKickTeam = "KickTeamRequest", -- 请求踢人 + RequestInvitePlayer = "InvitePlayerRequest", -- 邀请玩家 + RequestRefuseInvite = "PersonalRefuseRequest", -- 拒绝邀请 + RequestAcceptInvite = "PersonalAcceptRequest", -- 接受邀请 + + RequestSignUpArena = "JoinActivityRequest", -- 报名参加竞技活动 + + RequestGroupMember = "GroupMemberRequest", -- 请求主页面成员信息 + RequestAreaData = "AreaDataRequest", -- 请求区域信息 + RequestStagePassDetail = "StagePassDetailRequest", -- 请求通关详情 + RequestUnlockArea = "UnlockAreaRequest", -- 请求解锁战区 + + RequestTeamRankData = "TeamRankDataRequest", -- 请求队伍排行 + ScoreQueryReq = "ScoreQueryRequest", -- 请求上一期主页面成员信息 + AreaAutoFightRequest = "AreaAutoFightRequest", + } + + ----------------------------Team start-------------------------- + + --监听UI界面打开事件 + --function XArenaManager.Init() + -- CsXGameEventManager.Instance:RegisterEvent(CS.XEventId.EVENT_UI_ENABLE, function(_, ui) + -- XArenaManager.OpenArenaActivityResult(ui[0].UiData.UiName) + -- end) + --end + + -- 打开竞技奖励界面 + function XArenaManager.OpenArenaActivityResult() + if ArenaActivityResultData == nil then + return + end + + XLuaUiManager.Open("UiArenaActivityResult", ArenaActivityResultData, function() + ArenaActivityResultData = nil + end) + end + + -- 检测竞技奖励界面 + function XArenaManager.CheckOpenArenaActivityResult() + if ArenaActivityResultData == nil then + return false + end + + XLuaUiManager.Open("UiArenaActivityResult", ArenaActivityResultData, function() + ArenaActivityResultData = nil + end, function() + XEventManager.DispatchEvent(XEventId.EVENT_ARENA_RESULT_CLOSE) + end) + + return true + end + + -- 处理竞技活动结果 + function XArenaManager.HandleArenaActivityResult(data) + ArenaLevel = data.NewArenaLevel + ContributeScore = data.ContributeScore + ArenaActivityResultData = data + end + + -- 获取我队队伍Id + function XArenaManager.GetTeamId() + if not TeamInfo then + return 0 + end + + return TeamInfo.TeamId or 0 + end + + -- 检测指定玩家是否是我队队长 + function XArenaManager.CheckPlayerIsCaptain(Id) + if not Id then + return false + end + + if Id == 0 then + return false + end + + if not TeamInfo then + return false + end + + local captain = TeamInfo.Captain or 0 + return captain == Id + end + + -- 检测自己是否是我队队长 + function XArenaManager.CheckSelfIsCaptain() + return XArenaManager.CheckPlayerIsCaptain(XPlayer.Id) + end + + -- 获取我的队伍成员列表 + function XArenaManager.GetMyTeamMemberList() + if not TeamInfo then + return {} + end + + return TeamInfo.ShowList + end + + -- 获取大厅玩家列表 + function XArenaManager.GetHallPlayerList() + local list = {} + + if HallPlayerMap then + for _, v in pairs(HallPlayerMap) do + table.insert(list, v) + end + end + + return list + end + + -- 获取大厅队伍列表 + function XArenaManager.GetHallTeamList() + local list = {} + + if HallTeamMap then + for _, v in pairs(HallTeamMap) do + table.insert(list, v) + end + end + + return list + end + + -- 获取申请数据列表 + function XArenaManager.GetApplyDataList() + local teamId = XArenaManager.GetTeamId() + local list = {} + if teamId > 0 then + if XArenaManager.CheckSelfIsCaptain() then + for _, v in pairs(ApplyMap) do + table.insert(list, v) + end + return list + else + return list + end + else + for _, v in pairs(InviteMap) do + table.insert(list, v) + end + return list + end + end + + -- 检测是否有申请数据 + function XArenaManager.CheckHaveApplyData() + local list = XArenaManager.GetApplyDataList() + return #list > 0 or HaveToRequestApplyData > 0 + end + + -- 获取竞技好友列表 + function XArenaManager.GetArenaFriendList() + local list = {} + + if FriendMap then + for _, v in pairs(FriendMap) do + table.insert(list, v) + end + end + + table.sort(list, function(a, b) + local isSameIdA = ChallengeId == a.ChallengeId + local isSameIdB = ChallengeId == b.ChallengeId + if isSameIdA ~= isSameIdB then + return isSameIdA + end + + local isEnterFightA = a.ChallengeId > 0 + local isEnterFightB = b.ChallengeId > 0 + if isEnterFightA ~= isEnterFightB then + return isEnterFightB + end + + return a.Info.Id > b.Info.Id + end) + + return list + end + + -- 处理被队长踢出队伍 + function XArenaManager.HandleIsKickedByCaptain() + TeamInfo = {} + XEventManager.DispatchEvent(XEventId.EVENT_ARENA_TEAM_CHANGE) + end + + -- 收到新申请信息 + function XArenaManager.HandleNewApplyData() + HaveToRequestApplyData = 1 + XEventManager.DispatchEvent(XEventId.EVENT_ARENA_TEAM_NEW_APPLY_ENTER) + end + + -- 处理队伍信息 + function XArenaManager.HandleTeamInfo(info) + if (not TeamInfo or not TeamInfo.TeamId) and info.TeamId > 0 and HaveToRequestApplyData > 0 then + HaveToRequestApplyData = 0 + end + + TeamInfo = info + + XEventManager.DispatchEvent(XEventId.EVENT_ARENA_TEAM_CHANGE) + end + + -- 处理大厅队伍列表 + function XArenaManager.HandleHallTeamList(data) + HallTeamMap = {} + for _, v in ipairs(data.TeamList) do + HallTeamMap[v.Info.TeamId] = v + end + end + + -- 处理大厅玩家列表 + function XArenaManager.HandleHallPlayerList(data) + HallPlayerMap = {} + for _, v in ipairs(data.PlayerList) do + HallPlayerMap[v.Info.Id] = v + end + end + + -- 处理好友列表 + function XArenaManager.HandleFriendList(data) + FriendMap = {} + if data and data.FriendPlayerList then + for _, v in ipairs(data.FriendPlayerList) do + --TODO 筛选相同段位的 + FriendMap[v.Info.Id] = v + end + end + end + + -- 处理邀请申请信息列表 + function XArenaManager.HandleApplyData(data) + if not data then + return + end + + ApplyMap = {} + InviteMap = {} + + local map = {} + for _, v in ipairs(data.ApplyList) do + map[v.Id] = v + end + + if data.ApplyType == APPLY_TYPE.SINGLE then + --队伍邀请信息列表 + InviteMap = map + elseif data.ApplyType == APPLY_TYPE.TEAM then + --玩家请求消息列表 + ApplyMap = map + end + + XEventManager.DispatchEvent(XEventId.EVENT_ARENA_TEAM_RECEIVE_APPLY_DATA) + end + + -- 检查是否在组队期状态 + function XArenaManager.CheckInTeamState() + return ActivityStatus == XArenaActivityStatus.Rest + end + + -- 检查是否在战斗期状态 + function XArenaManager.CheckInFightState() + return ActivityStatus == XArenaActivityStatus.Fight + end + + -- 检查玩家是否可以打纷争战区副本 + function XArenaManager.IsPlayerCanEnterFight() + local isOpen = XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.FubenArena) + return isOpen and XArenaManager.CheckInFightState() + end + + -- 获取我的队伍信息 + function XArenaManager.RequestMyTeamInfo(cb) + if ActivityStatus ~= XArenaActivityStatus.Rest then + XUiManager.TipText("ArenaActivityStatusWrong") + return + end + + if TeamInfo then + if cb then + cb() + end + return + end + + XNetwork.Call(ArenaRequest.RequestMyTeamInfo, nil, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + XArenaManager.HandleTeamInfo(res.MyTeam) + + if cb then + cb() + end + end) + end + + -- 请求大厅队伍列表 + function XArenaManager.RequestHallTeamList(cb) + if ActivityStatus ~= XArenaActivityStatus.Rest then + XUiManager.TipText("ArenaActivityStatusWrong") + return + end + + -- 请求间隔保护 + local now = XTime.GetServerNowTimestamp() + if LastHallTeamListTime + SYNC_HALL_SECOND >= now then + if cb then + cb() + end + return + end + LastHallTeamListTime = now + + --TODO 受刷新时间限制 + XNetwork.Call(ArenaRequest.RequestHallTeamList, nil, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + XArenaManager.HandleHallTeamList(res.HallTeamData) + + if cb then + cb() + end + end) + end + + -- 请求大厅玩家列表 + function XArenaManager.RequestHallPlayerList(cb) + if ActivityStatus ~= XArenaActivityStatus.Rest then + XUiManager.TipText("ArenaActivityStatusWrong") + return + end + + -- 请求间隔保护 + local now = XTime.GetServerNowTimestamp() + if LastHallPlayerListTime + SYNC_HALL_SECOND >= now then + if cb then + cb() + end + return + end + LastHallPlayerListTime = now + + --TODO 受刷新时间限制 + XNetwork.Call(ArenaRequest.RequestHallPlayerList, nil, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + XArenaManager.HandleHallPlayerList(res.HallPlayerData) + + if cb then + cb() + end + end) + end + + -- 获取邀请申请信息列表 + function XArenaManager.RequestApplyData(cb) + if ActivityStatus ~= XArenaActivityStatus.Rest then + XUiManager.TipText("ArenaActivityStatusWrong") + return + end + + --TODO 受刷新时间限制 + XNetwork.Call(ArenaRequest.RequestApplyData, nil, function(res) + HaveToRequestApplyData = 0 + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + XArenaManager.HandleApplyData(res.ApplyData) + + if cb then + cb() + end + end) + end + + -- 获取所有好友竞技信息 + function XArenaManager.RequestFriendArenaInfo(cb) + if ActivityStatus ~= XArenaActivityStatus.Rest then + XUiManager.TipText("ArenaActivityStatusWrong") + return + end + + -- 请求间隔保护 + local now = XTime.GetServerNowTimestamp() + if LastFriendPlayerTime + SYNC_OTHER_SECOND >= now then + if cb then + cb() + end + return + end + LastFriendPlayerTime = now + + XNetwork.Call(ArenaRequest.RequestFriendArenaInfo, nil, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + XArenaManager.HandleFriendList(res.FriendPlayerData) + + if cb then + cb() + end + end) + end + + -- 请求创建队伍 + function XArenaManager.RequestCreateTeam(cb) + if ActivityStatus ~= XArenaActivityStatus.Rest then + XUiManager.TipText("ArenaActivityStatusWrong") + return + end + + XNetwork.Call(ArenaRequest.RequestCreateTeam, nil, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + if cb then + cb() + end + end) + end + + -- 申请入队 + function XArenaManager.RequestApplyTeam(teamId, cb) + if ActivityStatus ~= XArenaActivityStatus.Rest then + XUiManager.TipText("ArenaActivityStatusWrong") + return + end + + XNetwork.Call(ArenaRequest.RequestApplyTeam, { TeamId = teamId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local info = HallTeamMap[teamId] + if info then + info.Apply = 1 + end + + if cb then + cb() + end + end) + end + + -- 拒绝申请 + function XArenaManager.RequestRefuseApply(targetId, cb) + if ActivityStatus ~= XArenaActivityStatus.Rest then + XUiManager.TipText("ArenaActivityStatusWrong") + return + end + + XNetwork.Call(ArenaRequest.RequestRefuseApply, { TargetId = targetId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + ApplyMap[targetId] = nil + XEventManager.DispatchEvent(XEventId.EVENT_ARENA_TEAM_APPLY_CHANGE) + + if cb then + cb() + end + end) + end + + -- 接受申请 + function XArenaManager.RequestAcceptApply(targetId, cb) + if ActivityStatus ~= XArenaActivityStatus.Rest then + XUiManager.TipText("ArenaActivityStatusWrong") + return + end + + XNetwork.Call(ArenaRequest.RequestAcceptApply, { TargetId = targetId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + ApplyMap[targetId] = nil + XEventManager.DispatchEvent(XEventId.EVENT_ARENA_TEAM_APPLY_CHANGE) + + if cb then + cb() + end + end) + end + + -- 请求离队 + function XArenaManager.RequestLeaveTeam(cb) + if ActivityStatus ~= XArenaActivityStatus.Rest then + XUiManager.TipText("ArenaActivityStatusWrong") + return + end + + XNetwork.Call(ArenaRequest.RequestLeaveTeam, nil, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + TeamInfo = {} + if HaveToRequestApplyData > 0 then + HaveToRequestApplyData = 0 + end + + XEventManager.DispatchEvent(XEventId.EVENT_ARENA_TEAM_INITIATIVE_LEAVE) + + if cb then + cb() + end + end) + end + + -- 踢除队员 + function XArenaManager.RequestKickTeam(targetId, cb) + if ActivityStatus ~= XArenaActivityStatus.Rest then + XUiManager.TipText("ArenaActivityStatusWrong") + return + end + + XNetwork.Call(ArenaRequest.RequestKickTeam, { TargetId = targetId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + if cb then + cb() + end + end) + end + + -- 邀请玩家入队 + function XArenaManager.RequestInvitePlayer(targetId, cb) + if ActivityStatus ~= XArenaActivityStatus.Rest then + XUiManager.TipText("ArenaActivityStatusWrong") + return + end + + XNetwork.Call(ArenaRequest.RequestInvitePlayer, { TargetId = targetId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local info = HallPlayerMap[targetId] + if info then + info.Invite = 1 + end + + local friend = FriendMap[targetId] + if friend then + friend.Invite = 1 + end + + if cb then + cb() + end + end) + end + + -- 拒绝邀请 + function XArenaManager.RequestRefuseInvite(targetId, cb) + if ActivityStatus ~= XArenaActivityStatus.Rest then + XUiManager.TipText("ArenaActivityStatusWrong") + return + end + + XNetwork.Call(ArenaRequest.RequestRefuseInvite, { TargetId = targetId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + InviteMap[targetId] = nil + XEventManager.DispatchEvent(XEventId.EVENT_ARENA_TEAM_APPLY_CHANGE) + + if cb then + cb() + end + end) + end + + -- 接受邀请 + function XArenaManager.RequestAcceptInvite(targetId, cb) + if ActivityStatus ~= XArenaActivityStatus.Rest then + XUiManager.TipText("ArenaActivityStatusWrong") + return + end + + XNetwork.Call(ArenaRequest.RequestAcceptInvite, { TargetId = targetId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + InviteMap[targetId] = nil + XEventManager.DispatchEvent(XEventId.EVENT_ARENA_TEAM_APPLY_CHANGE) + + if cb then + cb() + end + end) + end + + -- 保存排名到本地 + function XArenaManager.SaveResultToLocal() + if ActivityNo <= 0 then return end + + local key = XPrefs.ArenaTeamResult .. tostring(XPlayer.Id) + local value = tostring(ActivityNo) .. "|" + for i, info in ipairs(PlayerResultRankList) do + value = value .. tostring(info.Id) + if i < #PlayerResultRankList then + value = value .. "|" + end + end + + CS.UnityEngine.PlayerPrefs.SetString(key, value) + CS.UnityEngine.PlayerPrefs.Save() + end + + -- 获取本地排名数据 + function XArenaManager.GetResultFormLocal(playerId) + PlayerLoaclResultRanlList = {} + + local key = XPrefs.ArenaTeamResult .. tostring(XPlayer.Id) + if not CS.UnityEngine.PlayerPrefs.HasKey(key) then + return nil + end + + local value = CS.UnityEngine.PlayerPrefs.GetString(key) + local strs = string.Split(value) + if not strs or #strs < 2 then + return nil + end + + if tonumber(strs[1]) ~= LastActivityNo then + return nil + end + + for i=2, #strs do + PlayerLoaclResultRanlList[tonumber(strs[i])] = i - 1 + end + + return PlayerLoaclResultRanlList[playerId] or nil + end + ----------------------------Team end-------------------------- + + ----------------------------Arena start-------------------------- + -- 获取活动状态 + function XArenaManager.GetArenaActivityStatus() + return ActivityStatus + end + + -- 获取进入下一阶段时间戳 + function XArenaManager.GetEnterNextStatusTime() + return CountDownTime + end + + -- 获取功能开启时间 + local GetTimeStr = function(time) + if not time or time <= 0 then + return "" + end + local str = XTime.TimestampToGameDateTimeString(time, "yy/MM/dd HH:mm") + return str + end + + -- 获取组队期开始时间 + function XArenaManager.GetTeamStartTime() + return GetTimeStr(TeamStartTime) + end + + -- 获取战斗期开始时间 + function XArenaManager.GetFightStartTime() + return GetTimeStr(FightStartTime) + end + + -- 获取结算期开始时间 + function XArenaManager.GetResultStartTime() + return GetTimeStr(ResultStartTime) + end + + -- 获取当前的竞技段位 + function XArenaManager.GetCurArenaLevel() + return ArenaLevel + end + + -- 获取上一期的竞技段位 + function XArenaManager.GetLastArenaLevel() + return LastArenaLevel + end + + -- 获取上一期战区贡献分 + function XArenaManager.GetLastContributeScore() + return LastContributeScore + end + + -- 获取波动指数 + function XArenaManager.GetWaveRate() + return WaveRate + end + + -- 获取上一期波动指数 + function XArenaManager.GetWaveLastRate() + return WaveLastRate + end + + -- 获取当前挑战id + function XArenaManager.GetCurChallengeId() + return ChallengeId + end + + -- 获取当前战区贡献总分 + function XArenaManager.GetContributeScore() + return ContributeScore + end + + -- 获取当前挑战配置 + function XArenaManager.GetCurChallengeCfg() + return XArenaConfigs.GetChallengeArenaCfgById(ChallengeId) + end + + -- 获取上一期挑战配置 + function XArenaManager.GetLastChallengeCfg() + return XArenaConfigs.GetChallengeArenaCfgById(LastChallengeId) + end + + -- 获取竞技挑战最高等级 + function XArenaManager.IsMaxArenaLevel(level) + return level >= XArenaConfigs.GetChallengeMaxArenaLevel(ChallengeId) + end + + -- 获取玩家竞技信息 + function XArenaManager.GetPlayerArenaInfo() + for _, info in ipairs(TeamResultList) do + if info.Id == XPlayer.Id then + return info + end + end + end + + -- 获取玩家上一期竞技信息 + function XArenaManager.GetPlayerLastArenaInfo() + for _, info in ipairs(TeamLastResultList) do + if info.Id == XPlayer.Id then + return info + end + end + end + + -- 获取玩家竞技个人排名 + function XArenaManager.GetPlayerArenaRankAndRegion() + local rank = 0 + local point = 0 + local region = XArenaPlayerRankRegion.DownRegion + + for i, info in ipairs(PlayerResultRankList) do + if info.Id == XPlayer.Id then + rank = i + point = info.Point + end + end + + if point == 0 then + if ArenaLevel <= 1 then + region = XArenaPlayerRankRegion.KeepRegion + end + return rank, region + end + + local challengeCfg = XArenaConfigs.GetChallengeArenaCfgById(ChallengeId) + if challengeCfg then + if rank <= challengeCfg.DanUpRank then + region = XArenaPlayerRankRegion.UpRegion + elseif rank > challengeCfg.DanUpRank and rank <= challengeCfg.DanKeepRank then + region = XArenaPlayerRankRegion.KeepRegion + end + end + + return rank, region + end + + -- 获取玩家上一期竞技个人排名 + function XArenaManager.GetLastPlayerArenaRankAndRegion() + local rank = 0 + local point = 0 + local region = XArenaPlayerRankRegion.DownRegion + + for i, info in ipairs(PlayerLastResultRanlList) do + if info.Id == XPlayer.Id then + rank = i + point = info.Point + end + end + + if point == 0 then + if ArenaLevel <= 1 then + region = XArenaPlayerRankRegion.KeepRegion + end + return rank, region + end + + local challengeCfg = XArenaConfigs.GetChallengeArenaCfgById(LastChallengeId) + if challengeCfg then + if rank <= challengeCfg.DanUpRank then + region = XArenaPlayerRankRegion.UpRegion + elseif rank > challengeCfg.DanUpRank and rank <= challengeCfg.DanKeepRank then + region = XArenaPlayerRankRegion.KeepRegion + end + end + + return rank, region + end + + -- 获取队员竞技信息列表 + function XArenaManager.GetPlayerArenaTeamMemberInfo() + local list = {} + for _, info in ipairs(TeamResultList) do + if info.Id ~= XPlayer.Id then + table.insert(list, info) + end + end + + return list + end + + -- 获取队员上一期竞技信息列表 + function XArenaManager.GetPlayerLastArenaTeamMemberInfo() + local list = {} + for _, info in ipairs(TeamLastResultList) do + if info.Id ~= XPlayer.Id then + table.insert(list, info) + end + end + + return list + end + + -- 获取队伍竞技总分 + function XArenaManager.GetArenaTeamTotalPoint() + local point = 0 + for _, info in ipairs(TeamResultList) do + point = point + info.Point + end + + return point + end + + -- 获取队伍上一期竞技总分 + function XArenaManager.GetLastArenaTeamTotalPoint() + local point = 0 + for _, info in ipairs(TeamLastResultList) do + point = point + info.Point + end + + return point + end + + + -- 获取玩家竞技排行数据 + function XArenaManager.GetPlayerArenaRankList() + local challengeCfg = XArenaConfigs.GetChallengeArenaCfgById(ChallengeId) + if not challengeCfg then + return nil + end + + local rankData = {} + rankData.UpList = {} + rankData.KeepList = {} + rankData.DownList = {} + + for i, info in ipairs(PlayerResultRankList) do + if info.Point > 0 then + if (i - challengeCfg.DanUpRank <= 0) then + table.insert(rankData.UpList, info) + elseif (i - challengeCfg.DanKeepRank <= 0) then + table.insert(rankData.KeepList, info) + else + table.insert(rankData.DownList, info) + end + else + if challengeCfg.ArenaLv <= 1 then + table.insert(rankData.KeepList, info) + else + table.insert(rankData.DownList, info) + end + end + end + + return rankData + end + + -- 获取玩家上一期竞技排行数据 + function XArenaManager.GetLastPlayerArenaRankList() + local challengeCfg = XArenaConfigs.GetChallengeArenaCfgById(LastChallengeId) + if not challengeCfg then + return nil + end + + local rankData = {} + rankData.UpList = {} + rankData.KeepList = {} + rankData.DownList = {} + + for i, info in ipairs(PlayerLastResultRanlList) do + if info.Point > 0 then + if (i - challengeCfg.DanUpRank <= 0) then + table.insert(rankData.UpList, info) + elseif (i - challengeCfg.DanKeepRank <= 0) then + table.insert(rankData.KeepList, info) + else + table.insert(rankData.DownList, info) + end + else + if challengeCfg.ArenaLv <= 1 then + table.insert(rankData.KeepList, info) + else + table.insert(rankData.DownList, info) + end + end + end + + return rankData + end + + -- 获取队伍排行榜的挑战配置 + function XArenaManager.GetTeamRankChallengeCfg() + if TeamRankChallengeId <= 0 then + return nil + end + + return XArenaConfigs.GetChallengeArenaCfgById(TeamRankChallengeId) + end + + -- 获取队伍排行统计时间 + function XArenaManager.GetArenaTeamRankTime() + if not TeamRankData.BeginTime or not TeamRankData.BeginTime then + return "" + end + + local begin_time = XTime.TimestampToGameDateTimeString(TeamRankData.BeginTime, "yy.MM.dd") + local end_time = XTime.TimestampToGameDateTimeString(TeamRankData.EndTime, "yy.MM.dd") + local desc = CS.XTextManager.GetText("ArenaRankDesc") + return begin_time .. "-" .. end_time .. desc + end + + -- 获取竞技队伍排行列表 + function XArenaManager.GetTeamRankList() + return TeamRankData.TeamRowList + end + + -- 获取自己队伍排行百分比 + function XArenaManager.GetMyTeamRankRate() + local rankRate = TeamRankData.RankRate or 0 + return rankRate / 10000 + end + + -- 获取竞技我的队伍排行及数据 + function XArenaManager.GetMyTeamRankAndData() + return TeamRankData.MyRank, TeamRankData.TotalRank, TeamRankData.MyTeamInfo + end + + -- 获取剩余解锁战区次数 + function XArenaManager.GetUnlockArenaAreaCount() + return UnlockCount + end + + -- 获取玩家战区总分 + function XArenaManager.GetArenaAreaTotalPoint() + return TotalPoint + end + + -- 通过战区Id获取战区信息 + function XArenaManager.GetArenaAreaDataByAreaId(areaId) + return AreaDatas[areaId] + end + + -- 通过战区Id获取战区当前关卡进度 + function XArenaManager.GetCurStageIndexByAreaId(areaId) + local stageInfos = AreaDatas[areaId].StageInfos + if not stageInfos then + return 1 + end + + if #stageInfos >= XArenaConfigs.GetTheMaxStageCountOfArenaArea() then + return #stageInfos + else + return #stageInfos + 1 + end + end + + -- 通过战区Id、关卡Id获取关卡积分 + function XArenaManager.GetArenaStageScore(areaId, stageId) + local stageInfos = AreaDatas[areaId].StageInfos + if not stageInfos then + return 0 + end + + for _, v in ipairs(stageInfos) do + if v.StageId == stageId then + return v.Point + end + end + return 0 + end + + -- 通过战区Id、关卡Id修改关卡积分 + function XArenaManager.ChangeArenaStageScore(areaId, stageId, score) + local stageInfos = AreaDatas[areaId].StageInfos + if not stageInfos then + return + end + + for _, v in ipairs(stageInfos) do + if v.StageId == stageId then + v.Point = score + end + end + end + + -- 设置正在战斗的竞技区域 + function XArenaManager.SetEnterAreaStageInfo(areaId, index) + EnterAreaStageInfo = {} + EnterAreaStageInfo.AreaId = areaId + EnterAreaStageInfo.StageIndex = index + + local stageId = XArenaConfigs.GetArenaAreaStageCfgByAreaId(areaId).StageId[index] + + local chaperName, stageName = XArenaConfigs.GetChapterAndStageName(areaId, stageId) + EnterAreaStageInfo.ChapterName = chaperName + EnterAreaStageInfo.StageName = stageName + end + + -- 获取竞技结算分数配置 + function XArenaManager.GetMarkCfg() + if not EnterAreaStageInfo.AreaId or not EnterAreaStageInfo.StageIndex then + return nil + end + + local stageCfg = XArenaConfigs.GetArenaAreaStageCfgByAreaId(EnterAreaStageInfo.AreaId) + if not stageCfg then + return nil + end + + local markCfg = XArenaConfigs.GetMarkCfgById(stageCfg.MarkId[EnterAreaStageInfo.StageIndex]) + return markCfg + end + + -- 状态改变直接回到主界面 + local JudgeGotoMain = function() + if not XLuaUiManager.IsUiLoad("UiArena") then + return + end + + if ActivityStatus == XArenaActivityStatus.Loading or ActivityStatus == XArenaActivityStatus.Default then + return + end + + -- 如果玩家在竞技战斗中 先做缓存 + if CS.XFight.IsRunning or XLuaUiManager.IsUiLoad("UiLoading") then + ArenaStatusInFightChangeCache = true + return + end + + -- 如果玩家在好友宿舍中 退出宿舍 + if XLuaUiManager.IsUiLoad("UiDormSecond") then + XHomeSceneManager.LeaveScene() + XEventManager.DispatchEvent(XEventId.EVENT_DORM_CLOSE_COMPONET) + end + + XUiManager.TipText("ArenaActivityStatusChange") + XLuaUiManager.RunMain() + end + + -- 竞技战斗结束后判断是否跳到主界面 + function XArenaManager.JudgeGotoMainWhenFightOver() + if not XLuaUiManager.IsUiLoad("UiArena") then + return false + end + + if not ArenaStatusInFightChangeCache then + return false + end + + ArenaStatusInFightChangeCache = false + XUiManager.TipText("ArenaActivityStatusChange") + XLuaUiManager.RunMain() + + return true + end + + -- 是否战斗中改变了状态 + function XArenaManager.IsChangeStatusInFight() + return ArenaStatusInFightChangeCache + end + + -- 处理竞技活动相关数据 + function XArenaManager.HandleArenaActivity(data) + -- 清空数据 + HallTeamMap = {} + HallPlayerMap = {} + FriendMap = {} + TeamInfo = nil + ApplyMap = {} + InviteMap = {} + MaxPointStageDic = {} + HaveToRequestApplyData = -1 + + ActivityNo = 0 + ActivityStatus = XArenaActivityStatus.Default + CountDownTime = 0 + TeamStartTime = 0 + FightStartTime = 0 + ResultStartTime = 0 + WaveRate = 0 + PlayerResultRankList = {} + TeamRankChallengeId = 0 + TeamRankData = {} + TeamResultList = {} + -- AreaIdToStageDetailList = {} + ChallengeId = 0 + ArenaLevel = 0 + UnlockCount = 0 + TotalPoint = 0 + AreaDatas = {} + EnterAreaStageInfo = {} + + -- 请求保护时间清0 + LastSyncRankListTime = 0 + LastHallTeamListTime = 0 + LastHallPlayerListTime = 0 + LastFriendPlayerTime = 0 + LasGroupMemberTime = 0 + + -- 重设数据 + ActivityNo = data.ActivityNo + ChallengeId = data.ChallengeId + ActivityStatus = data.Status + CountDownTime = data.NextStatusTime + TeamStartTime = data.TeamTime + FightStartTime = data.FightTime + ResultStartTime = data.ResultTime + ArenaLevel = data.ArenaLevel + IsJoinActivity = data.JoinActivity == 1 -- 是否参加过当前活动 + UnlockCount = data.UnlockCount + ContributeScore = data.ContributeScore + + for _, v in pairs(data.MaxPointStageList) do + MaxPointStageDic[v] = true + end + + if ActivityStatus == XArenaActivityStatus.Over then + IsJoinActivity = false + WaveLastRate = nil + PlayerLastResultRanlList = nil + TeamLastResultList = nil + LastChallengeId = nil + LastActivityNo = nil + LastArenaLevel = nil + LastDataRespone = nil + LastContributeScore = nil + end + + local remainTime = CountDownTime - XTime.GetServerNowTimestamp() + XCountDown.CreateTimer(XArenaConfigs.ArenaTimerName, remainTime) + + JudgeGotoMain() + XEventManager.DispatchEvent(XEventId.EVENT_TASK_SYNC) + end + + -- 获取正在战斗的竞技区域 + function XArenaManager.GetEnterAreaStageInfo() + return EnterAreaStageInfo + end + + -- 获取是否参加过当前活动 + function XArenaManager.GetIsJoinActivity() + return IsJoinActivity + end + + -- 报名参加竞技活动 + function XArenaManager.RequestSignUpArena(cb) + if ActivityStatus == XArenaActivityStatus.Over then + if cb then + cb() + end + return + end + + if IsJoinActivity then + if cb then + cb() + end + return + end + + XNetwork.Call(ArenaRequest.RequestSignUpArena, nil, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + IsJoinActivity = true + if res.ChallengeId then + ChallengeId = res.ChallengeId + end + + if cb then + cb() + end + end) + end + + -- 请求主页面成员信息 + function XArenaManager.RequestGroupMember(cb) + if ActivityStatus ~= XArenaActivityStatus.Fight then + XUiManager.TipText("ArenaActivityStatusWrong") + return + end + + -- 请求间隔保护 + local now = XTime.GetServerNowTimestamp() + if LasGroupMemberTime + SYNC_GOURP_MEMBER_SECOND >= now then + XEventManager.DispatchEvent(XEventId.EVENT_ARENA_MAIN_INFO) + if cb then + cb() + end + return + end + LasGroupMemberTime = now + + XNetwork.Call(ArenaRequest.RequestGroupMember, nil, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + WaveRate = res.WaveRate + PlayerResultRankList = res.GroupPlayerList + TeamResultList = res.TeamPlayerList + XArenaManager.SaveResultToLocal() + XEventManager.DispatchEvent(XEventId.EVENT_ARENA_MAIN_INFO) + if cb then + cb() + end + end) + end + + -- 请求上一期主界面信息 + function XArenaManager.ScoreQueryReq(cb) + -- -- TODO:::等待服务器完成功能 + -- if true then + -- XUiManager.TipMsg(CS.XTextManager.GetText("ComingSoon"), XUiManager.UiTipType.Tip) + -- return + -- end + if LastDataRespone and LastDataRespone.Code ~= XCode.Success then + XUiManager.TipCode(LastDataRespone.Code) + return + end + + if TeamLastResultList ~= nil then + if cb then + cb() + end + return + end + + XNetwork.Call(ArenaRequest.ScoreQueryReq, nil, function(res) + LastDataRespone = res + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + WaveLastRate = res.WaveRate + PlayerLastResultRanlList = res.GroupPlayerList + TeamLastResultList = res.TeamPlayerList + LastChallengeId = res.ChallengeId + LastActivityNo = res.ActivityNo + LastArenaLevel = res.ArenaLevel + LastContributeScore = res.ContributeScore + + if cb then cb() end + end) + end + + -- 请求区域信息 + function XArenaManager.RequestAreaData(cb) + if ActivityStatus ~= XArenaActivityStatus.Fight then + XUiManager.TipText("ArenaActivityStatusWrong") + return + end + + XNetwork.Call(ArenaRequest.RequestAreaData, nil, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + TotalPoint = res.TotalPoint + for _, areaShowData in ipairs(res.AreaList) do + AreaDatas[areaShowData.AreaId] = areaShowData + end + XEventManager.DispatchEvent(XEventId.EVENT_ARENA_REFRESH_AREA_INFO) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_ARENA_REFRESH_AREA_INFO) + + if cb then + cb() + end + end) + end + + -- 请求通关详情 + function XArenaManager.RequestStagePassDetail(areaId, cb) + if ActivityStatus ~= XArenaActivityStatus.Fight then + XUiManager.TipText("ArenaActivityStatusWrong") + return + end + + XNetwork.Call(ArenaRequest.RequestStagePassDetail, { AreaId = areaId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local detailMap = {} + for _, data in ipairs(res.StageDetailList) do + detailMap[data.StageId] = data + end + -- AreaIdToStageDetailList[areaId] = detailMap + + if cb then + cb(detailMap) + end + end) + end + + -- 请求解锁战区 + function XArenaManager.RequestUnlockArea(areaId, cb) + if ActivityStatus ~= XArenaActivityStatus.Fight then + XUiManager.TipText("ArenaActivityStatusWrong") + return + end + + if UnlockCount <= 0 then + XUiManager.TipError(CS.XTextManager.GetText("ArenaActivityUnlockCountNotEnough")) + return + end + + XNetwork.Call(ArenaRequest.RequestUnlockArea, { AreaId = areaId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + UnlockCount = UnlockCount - 1 + local data = AreaDatas[areaId] + data.Lock = 0 + + XEventManager.DispatchEvent(XEventId.EVENT_ARENA_UNLOCK_AREA) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_ARENA_UNLOCK_AREA) + + if cb then + cb() + end + end) + end + + -- 请求队伍排行 + function XArenaManager.RequestTeamRankData(cb) + -- 请求间隔保护 + local now = XTime.GetServerNowTimestamp() + if LastSyncRankListTime + SYNC_RANK_LIST_SECOND >= now and TeamRankChallengeId > 0 then + if cb then + cb() + end + return + end + LastSyncRankListTime = now + + XNetwork.Call(ArenaRequest.RequestTeamRankData, nil, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + TeamRankChallengeId = res.ChallengeId + TeamRankData = res.RankData + + XEventManager.DispatchEvent(XEventId.EVENT_ARENA_REFRESH_TEAM_RANK_INFO) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_ARENA_REFRESH_TEAM_RANK_INFO) + + if cb then + cb() + end + end) + end + + --记录满分通关的关卡列表 + function XArenaManager.NotifyMaxPointList(data) + MaxPointStageDic = {} + for _, v in pairs(data.MaxPointStageList) do + MaxPointStageDic[v] = true + end + end + + function XArenaManager.IsCanAutoFightByStageId(stageId) + return MaxPointStageDic[stageId] == true + end + + function XArenaManager.RequestAutoFight(areaId, stageId) + XNetwork.Call(ArenaRequest.AreaAutoFightRequest, { AreaId = areaId, StageId = stageId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + XArenaManager.RequestAreaData(function() + CsXGameEventManager.Instance:Notify(XEventId.EVENT_ARENA_RESULT_AUTOFIGHT) + XUiManager.TipText("ArenaAutoFightSuccess") + end) + end) + end + + function XArenaManager.InitStageInfo() + local arenaStageInfo = XArenaConfigs.GetArenaStageCfg() + for _, stageList in ipairs(arenaStageInfo) do + for _, v in ipairs(stageList.StageId) do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(v) + stageInfo.Type = XDataCenter.FubenManager.StageType.Arena + end + end + end + + --计算竞技场贡献分(需要根据战区积分判断) + function XArenaManager.GetContributeScoreByCfg(index, challengeCfg, point) + if point > 0 then + return challengeCfg.ContributeScore[index] or 0 + else + return 0 + end + end + + --XArenaManager.Init() + ----------------------------Arena start-------------------------- + + return XArenaManager +end + +XRpc.NotifyArenaActivity = function(data) + XDataCenter.ArenaManager.HandleArenaActivity(data) +end + +XRpc.NotifyMyTeam = function(data) + XDataCenter.ArenaManager.HandleTeamInfo(data.MyTeam) +end + +XRpc.NotifyPlayerKick = function() + XDataCenter.ArenaManager.HandleIsKickedByCaptain() +end + +XRpc.NotifyNewApply = function(data) + XDataCenter.ArenaManager.HandleNewApplyData(data) +end + +XRpc.ActivityResultNotify = function(data) + XDataCenter.ArenaManager.HandleArenaActivityResult(data) +end + +--已经满分通关的关卡列表(用于自动作战) +XRpc.NotifyMaxPointList = function(data) + XDataCenter.ArenaManager.NotifyMaxPointList(data) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XArenaOnlineManager.lua b/Resources/Scripts/XManager/XArenaOnlineManager.lua new file mode 100644 index 00000000..8ab58083 --- /dev/null +++ b/Resources/Scripts/XManager/XArenaOnlineManager.lua @@ -0,0 +1,876 @@ +XArenaOnlineManagerCreator = function() + local XArenaOnlineManager = {} + + local AreaChanged = false --区域是否改变 + local NextRefreshTime = 0 -- 下一次副本刷新时间 + local AssistCount = 0 -- 助战总次数 + local StagePassCount = {} -- 通关次数 + local ScetionData = {} -- 小节数据 + local StageInfodData = {} -- 关卡数据 + local CurCapterId = 0 -- 当前章节ID + local CurSectionId = 0 -- 当前小节ID + local CurChallengeId = 0 -- 单机模式下当前挑战ID + local FubenStageStrs = {} -- 副本星数 + local CharEndurances = {} -- 角色耐力 + local FirstPassCount = 0 -- 首通总次数 + local FirstPassList = {} -- 首通关卡 + local PlayerTeamData = {} + local TypeId = CS.XGame.Config:GetInt("TypeIdArenaOnline") + local DefaultTeam = { + CaptainPos = 1, + FirstFightPos = 1, + TeamData = { 0, 0, 0 }, + } + + local InFightChangeCache = false -- 是否在战斗中缓存 + + local sec_of_refresh_time = 7 * 60 * 60 + + local SetAreasInfo = function(areas) + ScetionData = {} + StageInfodData = {} + for _, v in ipairs(areas) do + if not ScetionData[v.Id] then + ScetionData[v.Id] = {} + ScetionData[v.Id].Id = v.Id + ScetionData[v.Id].OpenDays = {} + ScetionData[v.Id].Stages = {} + ScetionData[v.Id].GroupId = v.GroupId + end + + local section = XArenaOnlineConfigs.GetSectionById(v.Id) + for _, day in ipairs(section.OpenDays) do + local weekOfSun = 7 + local weekOfDeflautSun = 0 + if day == weekOfDeflautSun then + table.insert(ScetionData[v.Id].OpenDays, weekOfSun) + else + table.insert(ScetionData[v.Id].OpenDays, day) + end + end + + local group = XArenaOnlineConfigs.GetStageGroupById(v.GroupId) + for _, stageId in ipairs(group.StageIds) do + table.insert(ScetionData[v.Id].Stages, stageId) + if not StageInfodData[stageId] then + StageInfodData[stageId] = {} + local stageCfg = XArenaOnlineConfigs.GetStageById(stageId) + StageInfodData[stageId].BuffIds = stageCfg.EventId + end + end + + table.sort(ScetionData[v.Id].OpenDays, function(a, b) + return a < b + end) + + table.sort(ScetionData[v.Id].Stages, function(a, b) + local sortA = XArenaOnlineConfigs.GetStageSortByStageId(a) + local sortB = XArenaOnlineConfigs.GetStageSortByStageId(b) + return sortA < sortB + end) + end + end + + -- 初始化副本info + function XArenaOnlineManager.InitStageInfo() + local arenaOnlineCfgs = XArenaOnlineConfigs.GetStages() + local arenaOnlineType = XDataCenter.FubenManager.StageType.ArenaOnline + for _, cfg in pairs(arenaOnlineCfgs) do + for _, id in pairs(cfg.Difficulty) do + local levelControl = XFubenConfigs.GetStageMultiplayerLevelControlCfgById(id) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(levelControl.StageId) + if stageInfo then + if stageInfo.Type and stageInfo.Type ~= arenaOnlineType then + XLog.Error(string.format("%s已设置了Type",levelControl.StageId)) + end + stageInfo.Type = arenaOnlineType + end + end + for _, id in pairs(cfg.SingleDiff) do + local levelControl = XFubenConfigs.GetStageMultiplayerLevelControlCfgById(id) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(levelControl.StageId) + if stageInfo then + if stageInfo.Type and stageInfo.Type ~= arenaOnlineType then + XLog.Error(string.format("%s已设置了Type",levelControl.StageId)) + end + stageInfo.Type = arenaOnlineType + end + end + end + end + + --重置stageInfo数据 + function XArenaOnlineManager.ResetStageInfo() + local arenaOnlineCfgs = XArenaOnlineConfigs.GetStages() + for _, cfg in pairs(arenaOnlineCfgs) do + for _, id in pairs(cfg.Difficulty) do + local levelControl = XFubenConfigs.GetStageMultiplayerLevelControlCfgById(id) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(levelControl.StageId) + if stageInfo then + stageInfo.Passed = false + end + end + for _, id in pairs(cfg.SingleDiff) do + local levelControl = XFubenConfigs.GetStageMultiplayerLevelControlCfgById(id) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(levelControl.StageId) + if stageInfo then + stageInfo.Passed = false + end + end + end + end + + function XArenaOnlineManager.OpenFightLoading(stageId) + local roomData = XDataCenter.RoomManager.RoomData + if roomData then + XLuaUiManager.Open("UiOnLineLoading") + else + XDataCenter.FubenManager.OpenFightLoading(stageId) + end + end + + function XArenaOnlineManager.CloseFightLoading() + local roomData = XDataCenter.RoomManager.RoomData + if roomData then + XLuaUiManager.Remove("UiOnLineLoading") + else + XDataCenter.FubenManager.CloseFightLoading() + end + end + + -- 处理成为客户端需要的联机数据 + function XArenaOnlineManager.HandlerLoginData(data) + NextRefreshTime = data.NextRefreshTime + AreaChanged = false + AssistCount = data.AssistCount + FirstPassCount = data.FirstPassCount + SetAreasInfo(data.Areas) + FubenStageStrs = {} + + if data.Stars and #data.Stars > 0 then + for _, v in ipairs(data.Stars) do + local count = (v.StarsMark & 1) + (v.StarsMark & 2 > 0 and 1 or 0) + (v.StarsMark & 4 > 0 and 1 or 0) + local map = {(v.StarsMark & 1) > 0, (v.StarsMark & 2) > 0, (v.StarsMark & 4) > 0 } + FubenStageStrs[v.StageId] = {} + FubenStageStrs[v.StageId].Count = count + FubenStageStrs[v.StageId].StarsMap = map + end + end + + CharEndurances = {} + if data.EnduranceList and #data.EnduranceList > 0 then + for _, v in ipairs(data.EnduranceList) do + CharEndurances[v.CharacterId] = v.EnduranceCount + end + end + + StagePassCount = {} + if data.Bottoms and #data.Bottoms > 0 then + for _, v in ipairs(data.Bottoms) do + local key = tostring(v.DropId) .. tostring(v.BottomId) + StagePassCount[key] = v.CurLevel + end + end + + FirstPassList = {} + if data.FirstPassList and #data.FirstPassList > 0 then + for _, v in ipairs(data.FirstPassList) do + XArenaOnlineManager.HandlerStagePass(v) + end + end + + XArenaOnlineManager.InitStageInfo() + end + + -- 获取开启章节 + function XArenaOnlineManager.GetArenaOnlineChapters() + local list = {} + local defualtList = {} + local level = XPlayer.Level + local chapters = XArenaOnlineConfigs.GetChapters() + local defaultChapterId = XArenaOnlineConfigs.DEFAULT_CHAPTERID + for _, v in pairs(chapters) do + if v.Id == defaultChapterId then + table.insert(defualtList, v) + end + + if level >= v.MinLevel and level <= v.MaxLevel then + table.insert(list, v) + end + end + table.sort(list, function(a, b) + return a.Id < b.Id + end) + + return #list > 0 and list or defualtList + end + + -- 获取小节数据 + function XArenaOnlineManager.GetSectionData() + local list = {} + local chapter = XArenaOnlineManager.GetCurChapterCfg() + if not chapter then return list end + + for _, sectionId in ipairs(chapter.SectionId) do + if ScetionData[sectionId] then + table.insert(list, ScetionData[sectionId]) + end + end + return list + end + + -- 获取角色耐力值 + function XArenaOnlineManager.GetCharEndurance(characterId) + return CharEndurances[characterId] or 0 + end + + -- 获取当前单个小节 + function XArenaOnlineManager.GetCurSectionData() + local data = ScetionData[CurSectionId] + if not data then + return nil + end + + return data + end + + -- 获取当前单个小节Prefab + function XArenaOnlineManager.GetCurSectionPrefabPath() + local data = ScetionData[CurSectionId] + if not data or not data.GroupId then + return nil + end + return XArenaOnlineConfigs.GetStageGroupPrefabPathById(data.GroupId) + end + -- 获取当前单个小节Icon + function XArenaOnlineManager.GetCurSectionIcon(sectionid) + local data = ScetionData[sectionid] + if not data or not data.GroupId then + return nil + end + return XArenaOnlineConfigs.GetStageGroupIconById(data.GroupId) + end + -- 获取下次刷新时间 + function XArenaOnlineManager.GetNextRefreshTime() + return NextRefreshTime + end + + -- 获取首通总次数 + function XArenaOnlineManager.GetFirstPassCount() + return FirstPassCount + end + + -- 获取通关总次数 + function XArenaOnlineManager.GetStageTotalCount(stageId) + return XArenaOnlineConfigs.GetStageBottomCountByStageId(stageId) + end + + -- 获取当前通关次数 + function XArenaOnlineManager.GetStagePassCount(stageId) + local key = XArenaOnlineConfigs.GetStageDropKeyByStageId(stageId) + return StagePassCount[key] or 0 + end + + -- 获取上一次助战次数 + function XArenaOnlineManager.GetLastAssistCount() + return AssistCount - 1 > 0 and AssistCount - 1 or 0 + end + + -- 获取助战次数 + function XArenaOnlineManager.GetAssistCount() + return AssistCount or 0 + end + + -- 通过副本StageId获取联机关卡Config + function XArenaOnlineManager.GetArenaOnlineStageCfgStageId(stageId) + return XArenaOnlineConfigs.GetStageById(stageId) + end + + -- 通过副本StageId获取联机关卡同调Config + function XArenaOnlineManager.GetActiveBuffCfgByStageId(stageId) + local stageCfg = XArenaOnlineConfigs.GetStageById(stageId) + local activeBuffId = stageCfg.ActiveBuffId + return XArenaOnlineConfigs.GetActiveBuffById(activeBuffId) + end + + -- 通过联机StageId获取副本Info + function XArenaOnlineManager.GetStageInfo(stageId) + local id = XArenaOnlineManager.GetStageId(stageId) + if id then + -- XLog.Warning(stageId,id,XDataCenter.FubenManager.GetStageInfo(id)) + return XDataCenter.FubenManager.GetStageInfo(id) + end + return XDataCenter.FubenManager.GetStageInfo(stageId) + end + + function XArenaOnlineManager.GetLevelControl(id) + local data = XDataCenter.RoomManager.RoomData + local level = 1 + if data and data.ChallengeLevel then + level = data.ChallengeLevel + end + local stageInfo + local cfg = XArenaOnlineConfigs.GetStageById(id) + if cfg and cfg.Difficulty[level] then + local id = cfg.Difficulty[level] + return XFubenConfigs.GetStageMultiplayerLevelControlCfgById(id) + end + end + + function XArenaOnlineManager.GetStageIdByIdAndLevel(id, level) + local stageInfo + local cfg = XArenaOnlineConfigs.GetStageById(id) + if cfg and cfg.Difficulty[level] then + local id = cfg.Difficulty[level] + local levelControl = XFubenConfigs.GetStageMultiplayerLevelControlCfgById(id) + return levelControl.StageId + end + end + + function XArenaOnlineManager.GetStageId(id) + local levelControl = XArenaOnlineManager.GetLevelControl(id) + if levelControl then + return levelControl.StageId + end + end + + -- 通过副本ChallengeId获取副本星数 + function XArenaOnlineManager.GetStageStarsByChallengeId(challengeId) + return FubenStageStrs[challengeId] and FubenStageStrs[challengeId].Count or 0 + end + + -- 通过ChallengeId获取副本星数Map + function XArenaOnlineManager.GetStageStarsMapByChallengeId(challengeId) + if not FubenStageStrs[challengeId] then + return {false, false, false} + else + return FubenStageStrs[challengeId].StarsMap + end + end + + -- 检查当前构造体是否满足同调 + function XArenaOnlineManager.CheckActiveBuffOnByCharId(charId) + local challengeId = XArenaOnlineManager.GetCurChallengeId() + local buffCfg = XArenaOnlineManager.GetActiveBuffCfgByStageId(challengeId) + local minQulity = XCharacterConfigs.GetCharMinQuality(charId) + return minQulity <= buffCfg.Quality + end + + -- 检查关卡是否通关 + function XArenaOnlineManager.CheckStagePass(challengeId) + if not challengeId then return false end + local cfg = XArenaOnlineConfigs.GetStageById(challengeId) + if cfg then + --三种难度只要一种通过即为通过 + for _,levelControlId in ipairs(cfg.Difficulty) do + local levelControlCfg = XFubenConfigs.GetStageMultiplayerLevelControlCfgById(levelControlId) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(levelControlCfg.StageId) + if stageInfo.Passed then + return true + end + end + for _,levelControlId in ipairs(cfg.SingleDiff) do + local levelControlCfg = XFubenConfigs.GetStageMultiplayerLevelControlCfgById(levelControlId) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(levelControlCfg.StageId) + if stageInfo.Passed then + return true + end + end + end + return false + + -- local cfg = XArenaOnlineManager.GetArenaOnlineStageCfgStageId(challengeId) + -- local levelControl = XFubenConfigs.GetStageMultiplayerLevelControlCfgById(cfg.SingleDiff[1]) + -- local stageId = levelControl.StageId + -- local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + -- return stageInfo.Passed + end + + -- 判断是否符合当前模式 + function XArenaOnlineManager.CheckStageIsArenaOnline(stageId) + local info = XDataCenter.FubenManager.GetStageInfo(stageId) + return info and info.Type == XDataCenter.FubenManager.StageType.ArenaOnline + end + + -- 获取单人模式对应的难度等级,同时保存挑战Id + function XArenaOnlineManager.GetSingleModeDifficulty(challengeId, isSave) + local cfg = XDataCenter.ArenaOnlineManager.GetArenaOnlineStageCfgStageId(challengeId) + local levelControlCfg = XFubenConfigs.GetStageMultiplayerLevelControlCfgById(cfg.SingleDiff[1]) + if isSave then + CurChallengeId = challengeId + end + return levelControlCfg.Difficulty + end + + -- 判断当前是否为单机模式 + function XArenaOnlineManager.CheckSingleMode() + return XDataCenter.RoomManager.RoomData == nil + end + + -- 获取当前挑战id + function XArenaOnlineManager.GetCurChallengeId() + if XDataCenter.RoomManager.RoomData then + return XDataCenter.RoomManager.RoomData.ChallengeId + else + return CurChallengeId + end + end + + -- 获取所有关卡进度 + function XArenaOnlineManager.GetStageSchedule() + local passCount = 0 + local allCount = 0 + local list = XArenaOnlineManager.GetArenaOnlineChapters() + if not list or #list <= 0 then + return passCount, allCount + end + CurCapterId = list[1].Id + + local sectionList = {} + local chapter = XArenaOnlineManager.GetCurChapterCfg() + if not chapter then + return passCount, allCount + end + + for _, sectionId in ipairs(chapter.SectionId) do + if ScetionData[sectionId] then + sectionList[sectionId] = ScetionData[sectionId] + end + end + + for _, v in pairs(sectionList) do + for _, challengeId in ipairs(v.Stages) do + allCount = allCount + 1 + if XArenaOnlineManager.CheckStagePass(challengeId) then + passCount = passCount + 1 + end + end + end + return passCount, allCount + end + + -- 获取小节关卡进度 + function XArenaOnlineManager.GetStageScheduleByScetionId(sectionId) + local passCount = 0 + local allCount = 0 + local scetion = ScetionData[sectionId] + if not scetion then + return passCount, allCount + end + + for _, challengeId in ipairs(scetion.Stages) do + allCount = allCount + 1 + if XArenaOnlineManager.CheckStagePass(challengeId) then + passCount = passCount + 1 + end + end + return passCount, allCount + end + + -- 判断小节是否开启 + function XArenaOnlineManager.CheckSectionLeftTime(sectionId) + local scetion = ScetionData[sectionId] + if not scetion then + return -1 + end + + local freshNow = XTime.GetServerNowTimestamp() - sec_of_refresh_time + local severDay = XTime.GetWeekDay(freshNow, true) + local nextOpenDay = scetion.OpenDays[1] + for _, day in ipairs(scetion.OpenDays) do + if day == severDay then + return 0 + elseif day > severDay then + nextOpenDay = day + break + end + end + + return XTime.GetNextWeekOfDayStartWithMon(nextOpenDay, sec_of_refresh_time) + end + + -- 获取通关条件数量 + function XArenaOnlineManager.GetStarInfoBySectionid(sectionId) + local stars = 0 + local allStars = 0 + local scetion = ScetionData[sectionId] + if not scetion then + return stars, allStars + end + + allStars = XArenaOnlineConfigs.GetStageGroupRequireStar(scetion.GroupId) + for _, challengeId in ipairs(scetion.Stages) do + stars = stars + XArenaOnlineManager.GetStageStarsByChallengeId(challengeId) + end + + return stars, allStars + end + + -- 获取关卡信息 + function XArenaOnlineManager.GetArenaOnlineStageInfo(stageId) + local data = StageInfodData[stageId] + if not data then + XLog.Error("XArenaOnlineManager.GetArenaOnlineStageInfo not found by id : " .. tostring(stageId)) + return nil + end + return data + end + + -- 获取当前联机关卡耐力消耗 + function XArenaOnlineManager.GetStageEndurance(challengeId) + if not XDataCenter.RoomManager.RoomData and not challengeId then + return 0 + end + + local stageId = challengeId or XDataCenter.RoomManager.RoomData.ChallengeId + return XArenaOnlineConfigs.GetStageEnduranceCostByStageId(stageId) + end + + -- 检查是否更新 + function XArenaOnlineManager.CheckTimeOut() + if NextRefreshTime == nil then + return false + end + local curTime = XTime.GetServerNowTimestamp() + local offset = NextRefreshTime - curTime + return offset <= 0 + end + + -- 设置当前章节ID + function XArenaOnlineManager.SetCurChapterId() + if CurCapterId > 0 then return end + + local list = XArenaOnlineManager.GetArenaOnlineChapters() + if not list or #list <= 0 then return end + CurCapterId = list[1].Id + end + + -- 获取当前章节配置表 + function XArenaOnlineManager.GetCurChapterCfg() + if CurCapterId <= 0 then + return nil + end + + return XArenaOnlineConfigs.GetChapterById(CurCapterId) + end + + -- 获取当前小节配置表 + function XArenaOnlineManager.GetCurSectionCfg() + if CurSectionId <= 0 then + return nil + end + + return XArenaOnlineConfigs.GetSectionById(CurSectionId) + end + + -- 检查当前小节是否需要日刷新 + function XArenaOnlineManager.CheckCurSectionDayRefrsh() + if CurSectionId <= 0 then + return true + end + + local section = ScetionData[CurSectionId] + if not section then + return true + end + + local freshNow = XTime.GetServerNowTimestamp() + local severDay = XTime.GetWeekDay(freshNow, true) + for _, day in ipairs(section.OpenDays) do + if day == severDay then + return false + end + end + + return true + end + + -- 打开区域联机详情 + function XArenaOnlineManager.OpenArenaOnlineChapter(chapterId) + CurCapterId = chapterId + XLuaUiManager.Open("UiArenaOnlineChapter") + end + + -- 打开区域联机小节详情 + function XArenaOnlineManager.OpenArenaOnlineSection(sectionId) + CurSectionId = sectionId + XLuaUiManager.Open("UiArenaOnlineSection") + end + + -- 判斷好友邀請是否提示 + function XArenaOnlineManager.CheckInviteTipShow() + -- local key = XPrefs.ArenaOnlineInvit.. tostring(XPlayer.Id) + -- local isShow = true + -- if CS.UnityEngine.PlayerPrefs.HasKey(key) then + -- local time = CS.UnityEngine.PlayerPrefs.GetInt(key) + -- local now = XTime.GetServerNowTimestamp() + -- isShow = now > time + -- end + + -- return isShow + return XDataCenter.SetManager.InviteButton == 1 + end + + -- 处理今日不在提示逻辑 + function XArenaOnlineManager.SetInviteTip() + local key = XPrefs.ArenaOnlineInvit.. tostring(XPlayer.Id) + local time = XTime.GetSeverTomorrowFreshTime() + CS.UnityEngine.PlayerPrefs.SetInt(key, time) + CS.UnityEngine.PlayerPrefs.Save() + end + + -- 判断是否第一次打开 + function XArenaOnlineManager.CheckFirstOpen() + local cfg = XArenaOnlineManager.GetCurChapterCfg() + local key = XPrefs.ArenaOnlineFirstOpen .. tostring(XPlayer.Id) .. tostring(cfg.StoryId) + + return not CS.UnityEngine.PlayerPrefs.HasKey(key) + end + + -- 设置第一次打开 + function XArenaOnlineManager.SetFirstOpen() + local cfg = XArenaOnlineManager.GetCurChapterCfg() + local key = XPrefs.ArenaOnlineFirstOpen .. tostring(XPlayer.Id) .. tostring(cfg.StoryId) + local time = XTime.GetSeverTomorrowFreshTime() + CS.UnityEngine.PlayerPrefs.SetInt(key, time) + CS.UnityEngine.PlayerPrefs.Save() + end + + function XArenaOnlineManager.ShowReward(winData) + if XDataCenter.FubenManager.CheckHasFlopReward(winData, true) then + XLuaUiManager.Open("UiFubenFlopReward", function() + XArenaOnlineManager.OpenSettleUi(winData) + end, winData) + else + XArenaOnlineManager.OpenSettleUi(winData) + end + end + + function XArenaOnlineManager.OpenSettleUi(winData) + if XDataCenter.RoomManager.RoomData then + XLuaUiManager.PopThenOpen("UiMultiplayerFightGrade", function () + XLuaUiManager.PopThenOpen("UiSettleWinMainLine", winData) + end) + else + XLuaUiManager.PopThenOpen("UiSettleWinMainLine", winData) + end + end + + -- 处理战斗结算数据 + function XArenaOnlineManager.HandlerFightEndData(data) + AssistCount = data.AssistCount + FirstPassCount = data.FirstPassCount + + local t = data.Star + local count = (t.StarsMark & 1) + (t.StarsMark & 2 > 0 and 1 or 0) + (t.StarsMark & 4 > 0 and 1 or 0) + local map = {(t.StarsMark & 1) > 0, (t.StarsMark & 2) > 0, (t.StarsMark & 4) > 0 } + if not FubenStageStrs[t.StageId] then + FubenStageStrs[t.StageId] = {} + end + FubenStageStrs[t.StageId].Count = count + FubenStageStrs[t.StageId].StarsMap = map + + for k, v in ipairs(data.EnduranceList) do + CharEndurances[v.CharacterId] = v.EnduranceCount + end + -- CharEndurances[data.Endurance.CharacterId] = data.Endurance.EnduranceCount + + if data.Bottom then + local key = tostring(data.Bottom.DropId) .. tostring(data.Bottom.BottomId) + StagePassCount[key] = data.Bottom.CurLevel + end + XArenaOnlineManager.HandlerStagePass(data.PassInfo) + end + + -- 处理已通关卡 + function XArenaOnlineManager.HandlerStagePass(data) + if data then + FirstPassList[data.StageId] = data + local stageInfo = XDataCenter.ArenaOnlineManager.GetStageInfo(data.StageId) + if stageInfo then + stageInfo.Passed = true + end + if next(data.SingleCharacterIds) then + local teamData = {} + teamData.TeamData = data.SingleCharacterIds + + for k,v in ipairs(data.SingleCharacterIds) do + if v == data.CaptainId then + teamData.CaptainPos = k + end + if v == data.FirstFightId then + teamData.FirstFightPos = k + end + end + PlayerTeamData[data.StageId] = teamData + end + end + end + + function XArenaOnlineManager.GetPlayerTeam(challengeId) + local teamId = XDataCenter.TeamManager.GetTeamId(TypeId) + + if PlayerTeamData[challengeId] then + PlayerTeamData[challengeId].TeamId = teamId + return XTool.Clone(PlayerTeamData[challengeId]) + else + DefaultTeam.TeamId = teamId + return XTool.Clone(DefaultTeam) + end + end + + -- 处理周更新 + function XArenaOnlineManager.HandlerWeekRefresh(data) + NextRefreshTime = data.NextRefreshTime + AreaChanged = true + SetAreasInfo(data.Areas) + FubenStageStrs = {} + CharEndurances = {} + FirstPassList = {} + XArenaOnlineManager.ResetStageInfo() + XEventManager.DispatchEvent(XEventId.EVENT_ARENAONLINE_WEEK_REFRESH) + end + + --区域是否变更 + function XArenaOnlineManager.IsAreaChanged() + return AreaChanged + end + + --设置区域变更标记 + function XArenaOnlineManager.SetAreaChanged(value) + AreaChanged = value + end + + -- 区域联机更新回主界面处理 + function XArenaOnlineManager.RunMain() + if InFightChangeCache then + return + end + + if CS.XFight.IsRunning or XLuaUiManager.IsUiLoad("UiLoading") then + InFightChangeCache = true + return + end + local notDialogTip = true + XLuaUiManager.RunMain(notDialogTip) + XUiManager.TipMsg(CS.XTextManager.GetText("ArenaOnlineTimeOut")) + end + + -- 处理日更新 + function XArenaOnlineManager.HandlerDayRefresh() + XEventManager.DispatchEvent(XEventId.EVENT_ARENAONLINE_DAY_REFRESH) + end + + -- 战斗结束后判断是否跳到主界面 + function XArenaOnlineManager.JudgeGotoMainWhenFightOver(stageId) + local stageInfos = XDataCenter.FubenManager.GetStageInfo(stageId) + if not stageInfos or stageInfos.Type ~= XDataCenter.FubenManager.StageType.ArenaOnline then + return false + end + + if not InFightChangeCache then + return false + end + + InFightChangeCache = false + local notDialogTip = true + XUiManager.TipText("ArenaOnlineTimeOut") + XLuaUiManager.RunMain(notDialogTip) + + return true + end + + function XArenaOnlineManager.OpenPrivateChat(chatData) + if not XDataCenter.ArenaOnlineManager.CheckInviteTipShow() then + return + end + + if chatData.MsgType ~= ChatMsgType.RoomMsg then + return + end + + local contentData = XChatData.DecodeRoomMsg(chatData.Content) + if not contentData then + return + end + + if chatData.SenderId == XPlayer.Id then + return + end + + XArenaOnlineManager.RecordPrivateChatData(chatData) + if XArenaOnlineManager.IsShowMaskUI() or XDataCenter.MovieManager.IsPlayingMovie() then + return + end + + if XLuaUiManager.IsUiShow("UiArenaOnlineInvitation")then + return + end + + XLuaUiManager.Open("UiArenaOnlineInvitation") + end + + function XArenaOnlineManager.RecordPrivateChatData(chatData) + if not XArenaOnlineManager.ChatDatas then + XArenaOnlineManager.ChatDatas = {} + end + + table.insert(XArenaOnlineManager.ChatDatas, chatData) + end + + function XArenaOnlineManager.ClearPrivateChatData() + XArenaOnlineManager.ChatDatas = {} + end + + function XArenaOnlineManager.GetPrivateChatData() + return XArenaOnlineManager.ChatDatas + end + + function XArenaOnlineManager.RemovePrivateChatData(senderId) + if not XArenaOnlineManager.ChatDatas then + return + end + + local chatData + for i = #XArenaOnlineManager.ChatDatas, 1, -1 do + chatData = XArenaOnlineManager.ChatDatas[i] + if chatData and chatData.SenderId == senderId then + table.remove(XArenaOnlineManager.ChatDatas, i) + end + end + end + + function XArenaOnlineManager.IsShowMaskUI() + for _,uiname in pairs(XArenaOnlineConfigs.MaskArenOnlineUIName)do + if XLuaUiManager.IsUiShow(uiname)then + return true + end + end + + return false + end + + function XArenaOnlineManager.Init() + XEventManager.AddEventListener(XEventId.EVENT_CHAT_RECEIVE_PRIVATECHAT, XArenaOnlineManager.OpenPrivateChat) + end + + XArenaOnlineManager.Init() + return XArenaOnlineManager +end + +-- 关闭合众战局功能 +XRpc.NotifyArenaOnlineLoginData = function(data) + --XDataCenter.ArenaOnlineManager.HandlerLoginData(data) +end + +XRpc.NotifyArenaOnlineFightEnd = function(data) + --XDataCenter.ArenaOnlineManager.HandlerFightEndData(data) +end + +XRpc.NotifyArenaOnlineInfo = function(data) + --XDataCenter.ArenaOnlineManager.HandlerWeekRefresh(data) +end + +XRpc.NotifyArenaOnlineDayRefresh = function() + --XDataCenter.ArenaOnlineManager.HandlerDayRefresh() +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XAssistManager.lua b/Resources/Scripts/XManager/XAssistManager.lua new file mode 100644 index 00000000..4bee378c --- /dev/null +++ b/Resources/Scripts/XManager/XAssistManager.lua @@ -0,0 +1,50 @@ +XAssistManagerCreator = function() + local XAssistManager = {} + + XAssistManager.AssistType = { + Friend = 1, + Legion = 2, + Passer = 3, + Robot = 4 + } + + local METHOD_NAME = { + GetPasser = "GetPasser", + ChangeAssistCharacterId = "ChangeAssistCharIdRequest", + } + + local AssistPlayerData = {} + + function XAssistManager.NotifyAssistData(data) + XAssistManager.InitAssistData(data.AssistData) + end + + function XAssistManager.InitAssistData(assistData) + if assistData == nil then + return + end + AssistPlayerData = assistData + end + + function XAssistManager.GetAssistCharacterId() + return AssistPlayerData.AssistCharacterId + end + + function XAssistManager.ChangeAssistCharacterId(id, cb) + XNetwork.Call(METHOD_NAME.ChangeAssistCharacterId, { AssistCharId = id }, + function(response) + if response.Code == XCode.Success then + AssistPlayerData.AssistCharacterId = id + cb(response.Code) + else + XUiManager.TipCode(response.Code) + end + end) + end + + return XAssistManager +end + +XRpc.NotifyAssistData = function(data) + XDataCenter.AssistManager.NotifyAssistData(data) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XAttribManager.lua b/Resources/Scripts/XManager/XAttribManager.lua new file mode 100644 index 00000000..bc6855ca --- /dev/null +++ b/Resources/Scripts/XManager/XAttribManager.lua @@ -0,0 +1,943 @@ +local pairs = pairs +local type = type + +local table = table +local tableInsert = table.insert + +XAttribManager = XAttribManager or {} + +-- 属性id获取接口 +local AddNumericIdInterfaces = {} +local AddPromotedIdInterfaces = {} +local AddGrowRateIdInterfaces = {} + +local FPS = CS.XFightConfig.FPS +local FPS_FIX = fix(FPS) +local FPS_RECIPROCAL_FIX = CS.XFightConfig.FpsReciprocal +local RADIAN_PER_ANGLE_FIX = fix.deg2rad + +local AttribCount = XNpcAttribType.End +local RunSpeedIndex = XNpcAttribType.RunSpeed +local WalkSpeedIndex = XNpcAttribType.WalkSpeed +local SquatSpeedIndex = XNpcAttribType.SquatSpeed +local SprintSpeedIndex = XNpcAttribType.SprintSpeed +local TurnRoundSpeedIndex = XNpcAttribType.TurnRoundSpeed +local BallIntervalIndex = XNpcAttribType.BallInterval +local DodgeEnergyAutoRecoveryIndex = XNpcAttribType.DodgeEnergyAutoRecovery + +local DEFAULT_VALUE = 0 +local AttribTemplates = {} +local AttribPromotedTemplates = {} +local AttribGrowRateTemplates = {} +local AttribReviseTemplates = {} +local AttribGroupTemplates = {} +local AttribAbilityTemplate = {} + +--属性名字配置表 +local AttribDescTemplates = {} +-- local NpcTemplates = {} +---属性id接口注册 +---@param inter function +function XAttribManager.RegisterGrowRateIdInterface(inter) + tableInsert(AddGrowRateIdInterfaces, inter) +end + +---@param inter function +function XAttribManager.RegisterNumericIdInterface(inter) + tableInsert(AddNumericIdInterfaces, inter) +end + +---@param inter function +function XAttribManager.RegisterPromotedIdInterface(inter) + tableInsert(AddPromotedIdInterfaces, inter) +end + +---属性计算 +local function CreateAttribArray() + local array = {} + -- 初始化时不申请全部内存,改用字典 + -- for _ = 1, AttribCount - 1 do + -- tableInsert(array, fix.zero) + -- end + return array +end + +---将配置转换成fix数组 +---@param template table 属性配置 +---@return fix[] fix数组 +local function GetAttribArray(template) + local attribs = CreateAttribArray() + + for k, v in pairs(XNpcAttribType) do + if template[k] and template[k] ~= DEFAULT_VALUE then + attribs[v] = template[k] + end + end + + return attribs +end + +---初始化属性配置 +---@param template table 原有配置 +---@return fix[] 属性配置fix只读数组 +local function InitAttribTemplates(template) + local attribTemplates = {} + for k, v in pairs(template) do + attribTemplates[k] = GetAttribArray(v) + end + return XReadOnlyTable.Create(attribTemplates) +end + +---加载属性配置 +local function LoadAttribConfig() + AttribGroupTemplates = XAttribConfigs.GetAttribGroupTemplates() + AttribReviseTemplates = XAttribConfigs.GetAttribReviseTemplates() + -- NpcTemplates = XAttribConfigs.GetNpcTemplates() + AttribDescTemplates = XAttribConfigs.GetAttribDescTemplates() + AttribAbilityTemplate = XAttribConfigs.GetAttribAbilityTemplate() + + AttribTemplates = InitAttribTemplates(XAttribConfigs.GetAttribTemplates()) + AttribPromotedTemplates = InitAttribTemplates(XAttribConfigs.GetAttribPromotedTemplates()) + AttribGrowRateTemplates = InitAttribTemplates(XAttribConfigs.GetAttribGrowRateTemplates()) +end + +local function GetAttribTemplate(attribId) + local attribs = AttribTemplates[attribId] + if not attribs then + XLog.Error("XAttribManager GetAttribTemplate Error: can not found attrib template, Id is " .. attribId, AttribTemplates) + return XCode.AttribManagerGetAttribTemplateNotFound, nil + end + + return XCode.Success, attribs +end + +local function GetAttribPromotedTemplate(attribId) + local attribs = AttribPromotedTemplates[attribId] + if not attribs then + XLog.Error("XAttribManager GetAttribPromotedTemplate Error: can not found attrib template, Id is " .. attribId) + return XCode.AttribManagerGetPromotedAttribTemplateNotFound, nil + end + + return XCode.Success, attribs +end + +local function GetAttribGrowRateTemplate(attribId) + local attribs = AttribGrowRateTemplates[attribId] + if not attribs then + XLog.Error("XAttribManager GetAttribGrowRateTemplate Error: can not found attrib template, Id is " .. attribId) + return XCode.AttribManagerGetGrowRateAttribTemplateNotFound, nil + end + + return XCode.Success, attribs +end + +local function GetAttribGroupTemplate(id) + local attribGroup = AttribGroupTemplates[id] + if not attribGroup then + XLog.Error("XAttribManager GetAttribGroupTemplate Error: can not found attrib group template, Id is " .. id) + return XCode.AttribGroupNotFound, nil + end + + return XCode.Success, attribGroup +end + +---属性计算 +---属性加法 +---@param attribs1 fix[] 原属性数组 +---@param attribs2 fix[] 增加属性数组 +local function DoAddAttribs(attribs1, attribs2) + for k, v in pairs(attribs2) do + if attribs1[k] then + attribs1[k] = attribs1[k] + attribs2[k] + else + attribs1[k] = attribs2[k] + end + end +end + +---属性成长(原属性 + 成长属性 * 培养等级) +---@param attribs1 fix[] 原属性数组 +---@param attribs2 fix[] 成长属性数组 +---@param trainedLevel number 培养等级 +local function DoPromotedAttribs(attribs1, attribs2, trainedLevel) + if trainedLevel <= 0 then + return + end + + trainedLevel = fix(trainedLevel) + + for k, v in pairs(attribs2) do + if attribs1[k] then + attribs1[k] = attribs1[k] + attribs2[k] * trainedLevel + else + attribs1[k] = attribs2[k] * trainedLevel + end + end +end + +---属性加成(原属性 + 原属性 * 加成属性) +---@param attribs1 fix[] 原属性数组 +---@param attribs2 fix[] 加成属性数组 +local function DoGrowRateAttribs(attribs1, attribs2) + for k, v in pairs(attribs2) do + if attribs1[k] then + attribs1[k] = attribs1[k] + attribs1[k] * attribs2[k] + else + attribs1[k] = attribs1[k] * attribs2[k] + end + end +end + +---属性修正(原属性 * (1 + 修正系数)) +---@param attrib fix 原属性 +---@param factor fix 修正系数 +---@return fix 修正后属性 +local function DoReviseAttrib(attrib, factor) + if not attrib then + attrib = DEFAULT_VALUE + end + return attrib * (fix.one + factor); +end + +---获取总加成属性 +---@param attribIds table 属性加成id列表 +---@return XCode,fix[] 状态码和属性数组 +local function GetTotalGrowRateAttribs(attribIds) + local attribs = CreateAttribArray() + + for _, id in pairs(attribIds) do + local code, readAttribs = GetAttribGrowRateTemplate(id) + if code ~= XCode.Success then + return code, nil + end + + DoAddAttribs(attribs, readAttribs) + end + + return XCode.Success, attribs +end + +---获取总属性数值叠加 +---@param attribIds table 叠加属性id列表 +---@return XCode,fix[] 状态码和属性数组 +local function GetTotalNumericAttribs(attribIds) + local attribs = CreateAttribArray() + + for _, id in pairs(attribIds) do + local code, readAttribs = GetAttribTemplate(id) + if code ~= XCode.Success then + return code, nil + end + + DoAddAttribs(attribs, readAttribs) + end + + return XCode.Success, attribs +end + +---获取总成长属性 +---@param attribIds table 成长属性id列表 +---@param trainedLevels table 培养等级列表 +---@return XCode, fix[] 状态码和属性数组 +local function GetTotalPromotedAttribs(attribIds, trainedLevels) + local attribs = CreateAttribArray() + if #trainedLevels ~= #attribIds then + XLog.Error("XAttribManager GetTotalPromotedAttribs Error: trainedLevels array length is not equal to template id array length") + return XCode.AttribManagerGetTotalPromotedAttribsParamArrayError, nil + end + + local length = #trainedLevels + for i = 1, length do + local level = trainedLevels[i] + if level <= 0 then + XLog.Error("XAttribManager GetTotalPromotedAttribs Error: level is smaller than 1, level is " .. level) + return XCode.AttribManagerGetTotalPromotedAttribsLevelError, nil + end + + local code, readAttribs = GetAttribPromotedTemplate(attribIds[i]) + if code ~= XCode.Success then + return code, nil + end + + DoPromotedAttribs(attribs, readAttribs, level) + end + + return XCode.Success, attribs +end + +---属性数组修正 +---@param attribs fix[] 属性数组 +---@param reviseId number 修正id +---@return XCode 状态码 +local function ReviseAttribs(attribs, reviseId) + local template = AttribReviseTemplates[reviseId] + if not template then + XLog.Error("XAttribManager.ReviseAttribs error: can not found template, reviseId is " .. reviseId); + return XCode.AttribReviseTemplateNotFound + end + + for i = 1, #template.AttribTypes do + local attribIndex = template.AttribTypes[i] + attribs[attribIndex] = DoReviseAttrib(attribs[attribIndex], template.Values[i]); + end + + return XCode.Success +end + +---将属性数组从fix转换成XAttrib +---@param attribs fix[] fix属性数组 +---@return XAttrib[] XAttrib属性数组 +local function Fix2XAttrib(attribs) + local xAttribs = {} + for attribIndex = 1, AttribCount - 1 do + local xAttrib + if attribs[attribIndex] then + xAttrib = CS.XAttrib.Ctor(FixToInt(attribs[attribIndex])) + else + xAttrib = CS.XAttrib() + end + tableInsert(xAttribs, xAttrib) + end + + --- 特殊处理 + xAttribs[RunSpeedIndex]:SetBase(FixToInt(attribs[RunSpeedIndex] * fix.thousand / FPS_FIX)) + xAttribs[WalkSpeedIndex]:SetBase(FixToInt(attribs[WalkSpeedIndex] * fix.thousand / FPS_FIX)) + xAttribs[SquatSpeedIndex]:SetBase(FixToInt(attribs[SquatSpeedIndex] * fix.thousand / FPS_FIX)) + xAttribs[SprintSpeedIndex]:SetBase(FixToInt(attribs[SprintSpeedIndex] * fix.thousand / FPS_FIX)) + xAttribs[TurnRoundSpeedIndex]:SetBase(FixToInt(attribs[TurnRoundSpeedIndex] * FPS_RECIPROCAL_FIX * RADIAN_PER_ANGLE_FIX * fix.thousand)) + xAttribs[BallIntervalIndex]:SetBase(FixToInt(attribs[BallIntervalIndex] * FPS_FIX)) + xAttribs[DodgeEnergyAutoRecoveryIndex]:SetBase(FixToInt(attribs[DodgeEnergyAutoRecoveryIndex] * FPS_RECIPROCAL_FIX)) + + --- CS数组下标从0开始,补一位 + tableInsert(xAttribs, 1, CS.XAttrib()) + + return xAttribs +end + +---获取npc基础属性 +---@param npcTemplate table npc配置 +---@param level number 等级 +---@return XCode,fix[] 状态码和属性数组 +local function GetNpcBaseAttribs(npcTemplate, level) + local code, baseAttribs = GetAttribTemplate(npcTemplate.AttribId) + if code ~= XCode.Success then + return code, nil + end + + local attribs = CreateAttribArray() + DoAddAttribs(attribs, baseAttribs) + + --- 出生等级为1,培养等级=等级 - 1 + local trainedLevel = level - 1 + + if npcTemplate.PromotedId and npcTemplate.PromotedId > 0 and trainedLevel > 0 then + local promotedAttribs + code, promotedAttribs = GetAttribPromotedTemplate(npcTemplate.PromotedId) + if code ~= XCode.Success then + return code, nil + end + + DoPromotedAttribs(attribs, promotedAttribs, trainedLevel) + end + + return XCode.Success, attribs +end + +---获取npc基础属性 +---@param npcTemplate table npc配置 +---@param level number 等级 +---@param reviseId number 修正系数id +---@return XCode,fix[] 状态码和属性数组 +local function GetNpcBaseAttribsWithReviseId(npcTemplate, level, reviseId) + local code, attribs = GetNpcBaseAttribs(npcTemplate, level) + if code ~= XCode.Success then + return code, nil + end + + if reviseId and reviseId > 0 then + code = ReviseAttribs(attribs, reviseId) + if code ~= XCode.Success then + return code, nil + end + end + + return XCode.Success, attribs +end + +---获取npc基础属性 +---@param npcTemplateId number npc配置id +---@param level number 等级 +---@return XCode,fix[] 状态码和属性数组 +local function GetNpcBaseAttribsByNpcId(npcTemplateId, level) + local npcTemplate = CS.XNpcManager.GetNpcTemplate(npcTemplateId) + if not npcTemplate then + XLog.Error("XAttribManager GetNpcBaseAttribsByNpcId Error: can not found npc template, npc Id is " .. npcTemplateId) + return XCode.AttribManagerGetNpcAttribNpcNotFound, nil + end + + return GetNpcBaseAttribs(npcTemplate, level) +end + +---获取npc基础属性 +---@param npcTemplateId number npc配置id +---@param level number 等级 +---@param reviseId number 修正系数id +---@return XCode,fix[] 状态码和属性数组 +local function GetNpcBaseAttribsByNpcIdWithReviseId(npcTemplateId, level, reviseId) + local npcTemplate = CS.XNpcManager.GetNpcTemplate(npcTemplateId) + if not npcTemplate then + XLog.Error("XAttribManager GetNpcBaseAttribsByNpcIdWithReviseId Error: can not found npc template, npc Id is " .. npcTemplateId) + return XCode.AttribManagerGetNpcAttribNpcNotFound, nil + end + + return GetNpcBaseAttribsWithReviseId(npcTemplate, level, reviseId) +end + +---获取属性加成id列表 +---@param npcData userdata npc数据 +---@return XCode,table 状态码和属性id列表 +local function GetGrowRateAttribIds(npcData) + local attribIds = {} + for _, inter in pairs(AddGrowRateIdInterfaces) do + local code = inter(npcData, attribIds) + if code ~= XCode.Success then + return code, nil + end + end + + if npcData.AttribGroupList then + local attribGroupList = npcData.AttribGroupList + if type(attribGroupList) == "userdata" then + attribGroupList = XTool.CsList2LuaTable(attribGroupList) + end + + if #attribGroupList > 0 then + for _, id in pairs(attribGroupList) do + local code, group = GetAttribGroupTemplate(id) + if code ~= XCode.Success then + return code, nil + end + + if group.AttribGrowRateId > 0 then + tableInsert(attribIds, group.AttribGrowRateId) + end + end + end + end + + return XCode.Success, attribIds +end + +---获取属性叠加id列表 +---@param npcData userdata npc数据 +---@return XCode,table 状态码和属性id列表 +local function GetNumericAttribIds(npcData) + local attribIds = {} + for _, inter in pairs(AddNumericIdInterfaces) do + local code = inter(npcData, attribIds) + if code ~= XCode.Success then + return code, nil + end + end + + if npcData.AttribGroupList then + local attribGroupList = npcData.AttribGroupList + if type(attribGroupList) == "userdata" then + attribGroupList = XTool.CsList2LuaTable(attribGroupList) + end + + if #attribGroupList > 0 then + for _, id in pairs(attribGroupList) do + local code, group = GetAttribGroupTemplate(id) + if code ~= XCode.Success then + return code, nil + end + + if group.AttribId > 0 then + tableInsert(attribIds, group.AttribId) + end + end + end + end + + return XCode.Success, attribIds +end + +---获取属性成长id列表和培养等级列表 +---@param npcData userdata npc数据 +---@return XCode,table,table 状态码和属性id列表、培养等级列表 +local function GetPromotedAttribIds(npcData) + local attribIds = {} + local levels = {} + + for _, inter in pairs(AddPromotedIdInterfaces) do + local code = inter(npcData, attribIds, levels) + if code ~= XCode.Success then + return code, nil, nil + end + end + + return XCode.Success, attribIds, levels +end + +---属性加成计算 +---@param npcData userdata npc数据 +---@param attribs fix[] 属性数组 +---@return XCode 状态码 +local function DoAddGrowRateAttribs(npcData, attribs) + local code, attribIds = GetGrowRateAttribIds(npcData) + if code ~= XCode.Success then + return code + end + + local growRateAttribs + code, growRateAttribs = GetTotalGrowRateAttribs(attribIds) + if code ~= XCode.Success then + return code + end + + DoGrowRateAttribs(attribs, growRateAttribs) + + return XCode.Success +end + +---属性叠加计算 +---@param npcData userdata npc数据 +---@param attribs fix[] 属性数组 +---@return XCode 状态码 +local function DoAddNumericAttribs(npcData, attribs) + local code, attribIds = GetNumericAttribIds(npcData) + if code ~= XCode.Success then + return code + end + + local numericAttribs + code, numericAttribs = GetTotalNumericAttribs(attribIds) + if code ~= XCode.Success then + return code + end + + DoAddAttribs(attribs, numericAttribs) + + return XCode.Success +end + +---属性成长计算 +---@param npcData userdata npc数据 +---@param attribs fix[] 属性数组 +---@return XCode 状态码 +local function DoAddPromotedAttribs(npcData, attribs) + local code, attribIds, levels = GetPromotedAttribIds(npcData) + if code ~= XCode.Success then + return code + end + + local promotedAttribs + code, promotedAttribs = GetTotalPromotedAttribs(attribIds, levels) + if code ~= XCode.Success then + return code + end + + DoAddAttribs(attribs, promotedAttribs) + + return XCode.Success +end + +---获取npc属性 +---@param npcData userdata npc数据 +---@return XCode,fix[] 状态码和属性数组 +local function GetNpcAttribs(npcData) + local attribs + local characterData = npcData.Character + + local code, npcId = XFightCharacterManager.GetNpcId(characterData) + if code ~= XCode.Success then + return code, nil + end + + code, attribs = GetNpcBaseAttribsByNpcId(npcId, characterData.Level) + if code ~= XCode.Success then + return code, nil + end + + --- 属性加成只针对基础属性,需要第一个计算 + code = DoAddGrowRateAttribs(npcData, attribs) + if code ~= XCode.Success then + return code, nil + end + + code = DoAddNumericAttribs(npcData, attribs) + if code ~= XCode.Success then + return code, nil + end + + code = DoAddPromotedAttribs(npcData, attribs) + if code ~= XCode.Success then + return code, nil + end + + if npcData.AttribReviseId and npcData.AttribReviseId > 0 then + code = ReviseAttribs(attribs, npcData.AttribReviseId) + if code ~= XCode.Success then + return code, nil + end + end + + return XCode.Success, attribs +end + +local function TryGetNpcBaseAttribs(npcTemplateId, level, reviseId) + local code, attribs = GetNpcBaseAttribsByNpcIdWithReviseId(npcTemplateId, level, reviseId) + if code ~= XCode.Success then + XLog.Error("TryGetNpcBaseAttribs error: code is ", code) + return nil + end + + return Fix2XAttrib(attribs) +end + +local function TryGetNpcAttribs(npcData) + local code, attribs = GetNpcAttribs(npcData) + if code ~= XCode.Success then + XLog.Error("TryGetNpcAttribs error: code is ", code) + return nil + end + + return Fix2XAttrib(attribs) +end + +------------------------------------------------------------------------------------------- +XAttribManager.GetAttribAbility = function(attribs) + if not attribs then + return + end + + local ability = fix.zero + for k, attr in pairs(attribs) do + local attribKey = XAttribManager.GetAttribKeyByIndex(k) + local template = AttribAbilityTemplate[attribKey] + if template and template.Ability > fix.zero then + ability = ability + attr * template.Ability + end + end + + return FixToInt(ability) +end + +XAttribManager.GetPartnerAttribAbility = function(attribs) + if not attribs then + return + end + + local ability = fix.zero + for k, attr in pairs(attribs) do + local attribKey = XAttribManager.GetAttribKeyByIndex(k) + local template = AttribAbilityTemplate[attribKey] + if template and template.PartnerAbility > fix.zero then + ability = ability + attr * template.PartnerAbility + end + end + + return FixToInt(ability) +end + +XAttribManager.GetAttribGroupTemplate = GetAttribGroupTemplate + +---------------------------------------客户端特有方法--------------------------------------- +---获取合并属性数组(fix结构) +---@param numericIds table 数值加成id列表 +---@param promotedIds table 等级提升id列表 +---@param trainedLevels table 等级列表 +---@return fix[] fix数组 +function XAttribManager.GetMergeAttribs(numericIds, promotedIds, trainedLevels) + local attribs = CreateAttribArray() + if #numericIds > 0 then + local code, numericAttribs = GetTotalNumericAttribs(numericIds) + if code ~= XCode.Success then + return + end + + DoAddAttribs(attribs, numericAttribs) + end + + if (trainedLevels and promotedIds) and (#promotedIds > 0 and #trainedLevels > 0) then + local code, promotedAttribs = GetTotalPromotedAttribs(promotedIds, trainedLevels) + if code ~= XCode.Success then + return + end + + DoAddAttribs(attribs, promotedAttribs) + end + + return attribs +end + +---获取基础属性数组 +---@param attribId number|table 属性id或者属性id列表 +---@return fix[] 属性fix数组 +function XAttribManager.GetBaseAttribs(attribId) + local attribIdList = {} + + if type(attribId) ~= "table" then + tableInsert(attribIdList, attribId) + else + attribIdList = attribId + end + + local code, attribs = GetTotalNumericAttribs(attribIdList) + if code ~= XCode.Success then + return nil + end + + return attribs +end + +---获取等级提升属性数组 +---@param attribId number|table 属性id或者属性id列表 +---@param level number|table 等级或者等级列表 +---@return fix[] 属性fix数组 +function XAttribManager.GetPromotedAttribs(attribId, level) + local attribIds = {} + local levels = {} + + if type(attribId) ~= "table" then + tableInsert(attribIds, attribId) + else + attribIds = attribId + end + + if not level then + for _ = 1, #attribIds do + tableInsert(levels, 1) + end + elseif type(level) ~= "table" then + tableInsert(levels, level) + else + levels = level + end + + local code, attribs = GetTotalPromotedAttribs(attribIds, levels) + if code ~= XCode.Success then + return nil + end + + return attribs +end + +---获取提升比例属性数组 +---@param attribId number|table 属性id或者属性id列表 +---@return fix[] 属性fix数组 +function XAttribManager.GetGrowRateAttribs(attribId) + local attribIdList = {} + + if type(attribId) ~= "table" then + tableInsert(attribIdList, attribId) + else + attribIdList = attribId + end + + local code, attribs = GetTotalGrowRateAttribs(attribIdList) + if code ~= XCode.Success then + return nil + end + + return attribs +end + +function XAttribManager.GetAttribNameByIndex(index) + local template = AttribDescTemplates[index] + if not template then + return + end + return template.Name +end + +function XAttribManager.GetAttribKeyByIndex(index) + local template = AttribDescTemplates[index] + if not template then + return + end + return template.Attrib +end + +---获取npc属性 +---@param npcData table npc数据 +---@return table fix属性数组 +XAttribManager.GetNpcAttribs = function(npcData) + local code, attribs = GetNpcAttribs(npcData) + if code ~= XCode.Success then + return nil + end + + return attribs +end + +--============ +--属性加值 +--============ +XAttribManager.DoAddAttribsByAttrAndAddId = function(attr, attrId) + local attr1 = XAttribManager.GetAttribByAttribId(attrId) + DoAddAttribs(attr, attr1) +end + +XAttribManager.GetAttribByAttribId = function(attribId) + local code, baseAttribs = GetAttribTemplate(attribId) + if code then return baseAttribs end + return nil +end + +XAttribManager.TryGetAttribGroupTemplate = function(id) + local code, template = GetAttribGroupTemplate(id) + if code ~= XCode.Success then + XLog.Error("XAttribManager.GetAttribGroupTemplate error: code is ", code) + return nil + end + + return template +end + +---获取npc基础属性 +XAttribManager.GetNpcBaseAttribsByNpcIdWithReviseId = function(npcTemplateId, level, reviseId) + local code, attribs = GetNpcBaseAttribsByNpcIdWithReviseId(npcTemplateId, level, reviseId) + if code ~= XCode.Success then + return nil + end + + return attribs +end + +-------------------------------------Partner相关---------------------------------------------------- +-- 伙伴属性id获取接口 +local AddPartnerNumericIdInterfaces = {} +local AddPartnerPromotedIdInterfaces = {} + +function XAttribManager.RegisterPartnerNumericIdInterface(inter) + tableInsert(AddPartnerNumericIdInterfaces, inter) +end + +function XAttribManager.RegisterPartnerPromotedIdInterface(inter) + tableInsert(AddPartnerPromotedIdInterfaces, inter) +end + +---获取Partner基础属性 +local function GetPartnerBaseAttribs(partnerData, attribs) + local partnerEntity = XDataCenter.PartnerManager.CreatePartnerEntityByPartnerData(partnerData) + + if partnerEntity then + return XCode.PartnerTemplateNotFound + end + local code, baseAttribs = GetAttribTemplate(partnerEntity:GetBaseAttribId()) + if code ~= XCode.Success then + return code, nil + end + DoAddAttribs(attribs, baseAttribs) + return XCode.Success +end + +---获取属性叠加id列表 +local function GetPartnerNumericAttribIds(partnerData) + local attribIds = {} + for _, inter in pairs(AddPartnerNumericIdInterfaces) do + local code = inter(partnerData, attribIds) + if code ~= XCode.Success then + return code, nil + end + end + + return XCode.Success, attribIds +end + +---获取属性成长id列表和培养等级列表 +local function GetPartnerPromotedAttribIds(partnerData) + local attribIds = {} + local levels = {} + + for _, inter in pairs(AddPartnerPromotedIdInterfaces) do + local code = inter(partnerData, attribIds, levels) + if code ~= XCode.Success then + return code, nil, nil + end + end + + return XCode.Success, attribIds, levels +end + +---属性叠加计算 +local function DoAddPartnerNumericAttribs(partnerData, attribs) + local code, attribIds = GetPartnerNumericAttribIds(partnerData) + if code ~= XCode.Success then + return code + end + + local numericAttribs + code, numericAttribs = GetTotalNumericAttribs(attribIds) + if code ~= XCode.Success then + return code + end + + DoAddAttribs(attribs, numericAttribs) + + return XCode.Success +end + +---属性成长计算 +local function DoAddPartnerPromotedAttribs(partnerData, attribs) + local code, attribIds, levels = GetPartnerPromotedAttribIds(partnerData) + if code ~= XCode.Success then + return code + end + + local promotedAttribs + code, promotedAttribs = GetTotalPromotedAttribs(attribIds, levels) + if code ~= XCode.Success then + return code + end + + DoAddAttribs(attribs, promotedAttribs) + return XCode.Success +end + +---获取Partner属性 +local function GetPartnerAttribs(partnerData) + local attribs = CreateAttribArray() + + local code = DoAddPartnerNumericAttribs(partnerData, attribs) + if code ~= XCode.Success then + return code, nil + end + + code = DoAddPartnerPromotedAttribs(partnerData, attribs) + if code ~= XCode.Success then + return code, nil + end + + return XCode.Success, attribs +end + +local function TryGetPartnerAttribs(partnerData) + local code, attribs = GetPartnerAttribs(partnerData) + if code ~= XCode.Success then + XLog.Error("TryGetPartnerAttribs error: code is ", code) + return nil + end + + return Fix2XAttrib(attribs) +end + +------------------------------------------------------------------------------------------ +---------------------------------------客户端特有方法--------------------------------------- +local _IsInited + +function XAttribManager.Init() + CS.XFightDelegate.GetNpcBaseAttrib = TryGetNpcBaseAttribs + CS.XFightDelegate.GetNpcAttrib = TryGetNpcAttribs + CS.XFightDelegate.GetPartnerAttrib = TryGetPartnerAttribs + LoadAttribConfig() + + _IsInited = true + XEventManager.DispatchEvent(XEventId.EVENT_ATTRIBUTE_MANAGER_INIT) +end + +function XAttribManager.IsInited() + return _IsInited +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XAutoFightManager.lua b/Resources/Scripts/XManager/XAutoFightManager.lua new file mode 100644 index 00000000..79bf115b --- /dev/null +++ b/Resources/Scripts/XManager/XAutoFightManager.lua @@ -0,0 +1,227 @@ +XAutoFightManagerCreator = function() + local tableremove = table.remove + local tableinsert = table.insert + + local AutoFightManager = {} + + + local METHOD_NAME = { + StartAutoFight = "StartAutoFightRequest", + ObtainAutoFightRewards = "ObtainAutoFightRewardsRequest", + StartNewAutoFight = "SweepRequest", + } + + AutoFightManager.State = { + None = 0, + Fighting = 1, + Complete = 2 + } + + local Records = {} + local RecordLookup + + --local timer + --local updateInterval = XScheduleManager.SECOND + + local BeginData + + + function AutoFightManager.GetRecordCount() + return #Records + end + + -- local function CreateTimer() + -- timer = XScheduleManager.ScheduleForever(function() + -- local now = XTime.GetServerNowTimestamp() + -- local cnt = 0 + -- for _, v in pairs(Records) do + -- if now >= v.CompleteTime then + -- cnt = cnt + 1 + -- end + -- end + -- XEventManager.DispatchEvent(XEventId.EVENT_AUTO_FIGHT_CHANGE, cnt) + -- end, updateInterval) + -- end + + -- local RemoveTimer + -- RemoveTimer = function() + -- if timer then + -- XScheduleManager.UnSchedule(timer) + -- end + -- XEventManager.RemoveEventListener(XEventId.EVENT_USER_LOGOUT, RemoveTimer) + -- XEventManager.RemoveEventListener(XEventId.EVENT_NETWORK_DISCONNECT, RemoveTimer) + -- end + + local function UpdateRecords(records) + Records = records + RecordLookup = {} + for _, v in pairs(Records) do + RecordLookup[v.StageId] = v + end + end + + --(records) --NotifyLogin + function AutoFightManager.InitAutoFightData(records) + UpdateRecords(records) + -- CreateTimer() + -- XEventManager.AddEventListener(XEventId.EVENT_USER_LOGOUT, RemoveTimer) + -- XEventManager.AddEventListener(XEventId.EVENT_NETWORK_DISCONNECT, RemoveTimer) + end + + function AutoFightManager.CheckAutoFightAvailable(stageId) + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + if not stageCfg or stageCfg.AutoFightId <= 0 then + return XCode.FubenManagerAutoFightStageInvalid + end + + local stageData = XDataCenter.FubenManager.GetStageData(stageId) + if not stageData then + return XCode.FubenManagerAutoFightStageInvalid + end + + return XCode.Success + end + + --(stageId, times, cb(res = {Code, Record})) + function AutoFightManager.StartAutoFight(stageId, times, cb) + XNetwork.Call(METHOD_NAME.StartAutoFight, { StageId = stageId, Times = times }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + tableinsert(Records, res.Record) + RecordLookup[res.Record.StageId] = res.Record + XEventManager.DispatchEvent(XEventId.EVENT_AUTO_FIGHT_START, stageId) + + if cb then + cb(res) + end + end) + end + + function AutoFightManager.StartNewAutoFight(stageId, count, cb) + XNetwork.Call(METHOD_NAME.StartNewAutoFight, { StageId = stageId, Count = count }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + XEventManager.DispatchEvent(XEventId.EVENT_AUTO_FIGHT_START, stageId) + + if cb then + cb(res) + end + end) + end + + function AutoFightManager.GetRecords() + return Records + end + + --(index, cb(res = {Code, TeamExp, CharacterExp, Rewards})) + function AutoFightManager.ObtainRewards(index, cb) + local record = Records[index] + if not record then + XUiManager.TipCode(XCode.FubenManagerAutoFightIndexInvalid) + return + end + + local stageId = record.StageId + + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + local cardIds = record.CardIds + local hasRobot = false + if stageCfg.RobotId and #stageCfg.RobotId > 0 then + hasRobot = true + cardIds = {} + for _, v in pairs(stageCfg.RobotId) do + local charId = XRobotManager.GetCharacterId(v) + tableinsert(cardIds, charId) + end + end + + XNetwork.Call(METHOD_NAME.ObtainAutoFightRewards, { Index = index - 1, StageId = stageId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + tableremove(Records, index) + RecordLookup[stageId] = nil + + XEventManager.DispatchEvent(XEventId.EVENT_AUTO_FIGHT_REMOVE, stageId) + + if hasRobot then + res.CharacterExp = 0 + end + + if cb then + cb(res) + end + + XLuaUiManager.Open("UiAutoFightReward", cardIds, res) + end) + end + + function AutoFightManager.GetRecordByStageId(stageId) + return RecordLookup and RecordLookup[stageId] + end + + function AutoFightManager.GetIndexByStageId(stageId) + for k, v in pairs(Records) do + if v.StageId == stageId then + return k + end + end + return 0 + end + + function AutoFightManager.GetAutoFightBeginData() + return BeginData + end + + function AutoFightManager.RecordFightBeginData(stageId, times, cardIds) + BeginData = { + CharExp = {}, + RoleLevel = XPlayer.Level, + RoleExp = XPlayer.Exp, + StageId = stageId, + Times = times, + } + + for _, charId in pairs(cardIds) do + local char = XDataCenter.CharacterManager.GetCharacter(charId) + if char ~= nil then + table.insert(BeginData.CharExp, { Id = charId, Quality = char.Quality, Exp = char.Exp, Level = char.Level }) + end + end + end + + function AutoFightManager.CheckOpenDialog(stageId, stage) + local maxChallengeNum = XDataCenter.FubenManager.GetStageMaxChallengeNums(stageId) + local stageData = XDataCenter.FubenManager.GetStageData(stageId) + if maxChallengeNum > 0 then + local chanllengedNum = 0 + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + if stageInfo.Type == XDataCenter.FubenManager.StageType.Prequel then + local info = XDataCenter.PrequelManager.GetUnlockChallengeStagesByStageId(stageId) + if info then + chanllengedNum = info.Count + end + else + chanllengedNum = stageData and stageData.PassTimesToday or 0 + end + + maxChallengeNum = maxChallengeNum - chanllengedNum + if maxChallengeNum <= 0 then + local msg = CS.XTextManager.GetText("FubenChallengeCountNotEnough") + XUiManager.TipMsg(msg) + return + end + end + XLuaUiManager.Open("UiAutoFightEnter", stageId, stage) + end + + return AutoFightManager +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XAutoWindowManager.lua b/Resources/Scripts/XManager/XAutoWindowManager.lua new file mode 100644 index 00000000..f1eaccb3 --- /dev/null +++ b/Resources/Scripts/XManager/XAutoWindowManager.lua @@ -0,0 +1,212 @@ +XAutoWindowManagerCreator = function() + local XAutoWindowManager = {} + + local AutoWindowList = {} -- 当前自动弹窗列表 + local AutoWindowIndex = 0 -- 当前自动弹出索引 + local IsFirstOpenAutoWindow = true -- 是否第一次打开自动弹窗 + + local SetPlayerPrefs = function(key, count) + local needSave = false + if CS.UnityEngine.PlayerPrefs.HasKey(key) then + local showCount = CS.UnityEngine.PlayerPrefs.GetInt(key) + if showCount < count then + needSave = true + CS.UnityEngine.PlayerPrefs.SetInt(key, showCount + 1) + end + else + needSave = true + CS.UnityEngine.PlayerPrefs.SetInt(key, 1) + end + return needSave + end + + -- 检查周期内是否弹窗 + local CheckAutoType = function(autoType, count, configId, openTime) + local needSave = false + + local now = XTime.GetServerNowTimestamp() + local dateTime = CS.XDateUtil.GetGameDateTime(now) + + if autoType == XAutoWindowConfigs.AutoType.EachTime then + return true + elseif autoType == XAutoWindowConfigs.AutoType.EachDay then + local dayZero = dateTime.Date:ToTimestamp() + local key = XPrefs.AutoWindowEach .. tostring(XPlayer.Id) .. dayZero .. configId + needSave = SetPlayerPrefs(key, count) + elseif autoType == XAutoWindowConfigs.AutoType.EachWeek then + local weekZero = CS.XDateUtil.GetFirstDayOfThisWeek(dateTime):ToTimestamp() + local key = XPrefs.AutoWindowEach .. tostring(XPlayer.Id) .. weekZero .. configId + needSave = SetPlayerPrefs(key, count) + elseif autoType == XAutoWindowConfigs.AutoType.EachMonth then + local monthZero = CS.XDateUtil.GetFirstDayOfThisMonth(dateTime):ToTimestamp() + local key = XPrefs.AutoWindowEach .. tostring(XPlayer.Id) .. monthZero .. configId + needSave = SetPlayerPrefs(key, count) + elseif autoType == XAutoWindowConfigs.AutoType.Period then + local key = XPrefs.AutoWindowPeriod .. tostring(XPlayer.Id) .. openTime .. configId + needSave = SetPlayerPrefs(key, count) + elseif autoType == XAutoWindowConfigs.AutoType.EachDayOffset then + local key = "" + local dayZero = dateTime.Date:ToTimestamp() + if dateTime.Hour < 7 then + key = XPrefs.AutoWindowEach .. tostring(XPlayer.Id) .. (dayZero - 86400) .. configId + else + key = XPrefs.AutoWindowEach .. tostring(XPlayer.Id) .. (dayZero) .. configId + end + needSave = SetPlayerPrefs(key, count) + return needSave + end + + if needSave then + CS.UnityEngine.PlayerPrefs.Save() + end + + return needSave + end + + -- 开始自动弹窗 + function XAutoWindowManager.StartAutoWindow(justSignIn) + if AutoWindowIndex <= 0 then + AutoWindowList = {} + elseif AutoWindowIndex > 0 and not justSignIn then + AutoWindowIndex = AutoWindowIndex - 1 + XAutoWindowManager.NextAutoWindow() + return true + end + + AutoWindowIndex = 0 + local autoWindowControllerConfig = XAutoWindowConfigs.GetAutoWindowControllerConfig() + for _, v in pairs(autoWindowControllerConfig) do + for _, k in pairs(AutoWindowList) do + if k.Id == v.Id then + goto continue + end + end + + if justSignIn and v.FunctionType ~= XAutoWindowConfigs.AutoFunctionType.Sign then + goto continue + end + + -- 对回归活动特殊处理,是否打脸不走配置表,而是根据外部接口来判断 + if v.FunctionType == XAutoWindowConfigs.AutoFunctionType.Regression then + if XDataCenter.RegressionManager.CheckNeedAutoWindow() then + table.insert(AutoWindowList, v) + end + goto continue + end + + local openTime = XFunctionManager.GetStartTimeByTimeId(v.TimeId) + if not XFunctionManager.CheckInTimeByTimeId(v.TimeId) then + goto continue + end + + if v.ConditionId > 0 and not XConditionManager.CheckCondition(v.ConditionId) then + goto continue + end + + if v.FunctionType == XAutoWindowConfigs.AutoFunctionType.Sign then + local paramId = XFunctionConfig.GetParamId(v.SkipId) + local subConfigId = XSignInConfigs.GetWelfareConfig(paramId).SubConfigId + if not XDataCenter.SignInManager.IsShowSignIn(subConfigId) + or XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.SignIn) then + goto continue + end + XDataCenter.SignInManager.SetNotifySign(false) + end + + if not CheckAutoType(v.AutoType, v.AutoCount, v.Id, openTime) then + goto continue + end + + if v.FunctionType == XAutoWindowConfigs.AutoFunctionType.NewYearZhanBu then + if XDataCenter.SignInManager.GetTodayDiviningState() then + goto continue + end + end + if v.FunctionType == XAutoWindowConfigs.AutoFunctionType.Fireworks then + if not XDataCenter.FireworksManager.HasAvailableFireTimes() then + goto continue + end + end + table.insert(AutoWindowList, v) + :: continue :: + end + + if #AutoWindowList <= 0 then + return false + end + + table.sort(AutoWindowList, function(a, b) + return a.Pre > b.Pre + end) + + XAutoWindowManager.NextAutoWindow() + return true + end + + -- 下一个动弹窗 + function XAutoWindowManager.NextAutoWindow() + AutoWindowIndex = AutoWindowIndex + 1 + if AutoWindowIndex > #AutoWindowList then + XAutoWindowManager.ClearAutoWindow() + XEventManager.DispatchEvent(XEventId.EVENT_AUTO_WINDOW_END) + return + end + + XFunctionManager.SkipInterface(AutoWindowList[AutoWindowIndex].SkipId) + end + + -- 结束自动弹窗 + function XAutoWindowManager.StopAutoWindow() + XEventManager.DispatchEvent(XEventId.EVENT_AUTO_WINDOW_STOP) + + if AutoWindowIndex <= 0 then + AutoWindowList = {} + return + end + + -- 判断是否需要继续弹窗 + if AutoWindowList[AutoWindowIndex].ContinueOpen then + return + end + + XAutoWindowManager.ClearAutoWindow() + end + + -- 清除自动弹窗 + function XAutoWindowManager.ClearAutoWindow() + AutoWindowList = {} + AutoWindowIndex = 0 + XEventManager.DispatchEvent(XEventId.EVENT_AUTO_WINDOW_STOP) + end + + function XAutoWindowManager.CheckAutoWindow() + if XUiManager.IsHideFunc then return false end + if IsFirstOpenAutoWindow then + IsFirstOpenAutoWindow = false + return XAutoWindowManager.StartAutoWindow() + end + + return XAutoWindowManager.CheckContinueAutoWindow() + end + + -- 检查是否继续自动弹窗 + function XAutoWindowManager.CheckContinueAutoWindow() + -- 检查是否有推送签到 + local isNotifySignIn = XDataCenter.SignInManager.CheckNotifySign() + local isContinueAuto = AutoWindowIndex > 0 + + if not isNotifySignIn and not isContinueAuto then -- 没有推送签到,没有继续弹窗 + return false + elseif not isNotifySignIn and isContinueAuto then -- 没有推送签到,有继续弹窗 + return XAutoWindowManager.StartAutoWindow() + elseif isNotifySignIn and not isContinueAuto then -- 有推送签到,没有继续弹窗 + return XAutoWindowManager.StartAutoWindow(true) + elseif isNotifySignIn and isContinueAuto then -- 有推送签到,有继续弹窗 + return XAutoWindowManager.StartAutoWindow(true) + end + + return false + end + + return XAutoWindowManager +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XBaseEquipManager.lua b/Resources/Scripts/XManager/XBaseEquipManager.lua new file mode 100644 index 00000000..e1a47cd1 --- /dev/null +++ b/Resources/Scripts/XManager/XBaseEquipManager.lua @@ -0,0 +1,702 @@ +XBaseEquipManagerCreator = function() + + local pairs = pairs + + local table = table + local tableInsert = table.insert + local tableSort = table.sort + local string = string + local stringFormat = string.format + + local XBaseEquipManager = {} + + + local METHOD_NAME = { + Evaluate = "BaseEquipEvaluateRequest", + PutOn = "BaseEquipPutOnRequest", + Recycle = "BaseEquipRecycleRequest" + } + + XBaseEquipManager.XATTRIB_CHANGE = { + NoChange = 0, + Up = 1, + Down = 2 + } + + local BaseEquipTemplates = {} -- 基地装备配置 + + local BaseEquipDatas = {} -- 基地装备数据 + local BaseEquipInfo = {} -- 已装备的基地装备信息 + local EvaluatedAttribInfoDict = {} -- 基地装备属性信息 + + function XBaseEquipManager.Init() + BaseEquipTemplates = XBaseEquipConfigs.GetBaseEquipTemplates() + end + + function XBaseEquipManager.IsBaseEquipEvaluated(baseEquip) + return baseEquip.AttribGroupIdList and #baseEquip.AttribGroupIdList > 0 + end + + function XBaseEquipManager.IsBaseEquipPutOn(baseEquipId) + for _, id in pairs(BaseEquipInfo) do + if id == baseEquipId then + return true + end + end + + return false + end + + local function PutOnBaseEquip(part, baseEquipId) + BaseEquipInfo[part] = baseEquipId + end + + local function DeleteBaseEquips(idList) + for _, id in pairs(idList) do + BaseEquipDatas[id] = nil + end + end + + local function GetAttribInfo(groupId) + local template = XAttribManager.TryGetAttribGroupTemplate(groupId) + if not template then + return + end + + local numericalList = {} + if template.AttribId > 0 then + local attrib = XAttribManager.GetBaseAttribs(template.AttribId) + for k, v in pairs(attrib) do + if k ~= "Id" and v > fix.zero then + tableInsert(numericalList, { + Name = XAttribManager.GetAttribNameByIndex(k), + Key = k, + Value = v + }) + end + end + end + + local growRateList = {} + if template.AttribGrowRateId > 0 then + local attrib = XAttribManager.GetGrowRateAttribs(template.AttribGrowRateId) + for k, v in pairs(attrib) do + if k ~= "Id" and v > fix.zero then + tableInsert(growRateList, { + Name = XAttribManager.GetAttribNameByIndex(k), + Key = k, + Value = v + }) + end + end + end + + return numericalList, growRateList + end + + local function GetMaxAttribDesc(groupId) + local template = XAttribManager.TryGetAttribGroupTemplate(groupId) + if not template then + return + end + + return template.MaxAttribDesc + end + + local function AddEvaluatedAttribInfo(baseEquipData) + if not baseEquipData then + return + end + + local attribPoolIdList = baseEquipData.AttribGroupIdList + if not attribPoolIdList or #attribPoolIdList <= 0 then + return + end + + local numericalList = {} + local growRateList = {} + + for _, id in pairs(attribPoolIdList) do + local list1, list2 = GetAttribInfo(id) + + for _, info in pairs(list1) do + tableInsert(numericalList, info) + end + + for _, info in pairs(list2) do + tableInsert(growRateList, info) + end + end + + EvaluatedAttribInfoDict[baseEquipData.Id] = { + NumericalList = numericalList, + GrowRateList = growRateList, + } + end + + function XBaseEquipManager.GetBaseEquipTemplate(templateId) + local template = BaseEquipTemplates[templateId] + if not template then + XLog.ErrorTableDataNotFound("XBaseEquipManager.GetBaseEquipTemplate", + "template", "Share/BaseEquip/BaseEquip.tab", "templateId", tostring(templateId)) + return + end + + return template + end + + local function SortBaseEquipFunc(a, b) + local isEvaluated1 = XBaseEquipManager.IsBaseEquipEvaluated(a) + local isEvaluated2 = XBaseEquipManager.IsBaseEquipEvaluated(b) + + if isEvaluated1 ~= isEvaluated2 then + return isEvaluated2 + end + + local template1 = XBaseEquipManager.GetBaseEquipTemplate(a.TemplateId) + local template2 = XBaseEquipManager.GetBaseEquipTemplate(b.TemplateId) + + if template1.Star ~= template2.Star then + return template1.Star > template2.Star + end + + if template1.Quality ~= template2.Quality then + return template1.Quality > template2.Quality + end + + return template1.Priority > template2.Priority + end + + function XBaseEquipManager.GetBaseEquipListByPart(part) + part = part and part or 0 + local list = {} + for _, baseEquip in pairs(BaseEquipDatas) do + local template = XBaseEquipManager.GetBaseEquipTemplate(baseEquip.TemplateId) + if template.Part == part or part == 0 then + tableInsert(list, baseEquip) + end + end + + tableSort(list, SortBaseEquipFunc) + + return list + end + + function XBaseEquipManager.GetBaseEquipNotPutOnListByPart(part) + part = part and part or 0 + local list = {} + for _, baseEquip in pairs(BaseEquipDatas) do + if not XBaseEquipManager.IsBaseEquipPutOn(baseEquip.Id) then + local template = XBaseEquipManager.GetBaseEquipTemplate(baseEquip.TemplateId) + if template.Part == part or part == 0 then + tableInsert(list, baseEquip) + end + end + end + + tableSort(list, SortBaseEquipFunc) + + return list + end + + --==============================-- + --desc: 获取属性信息 + --@id: 基地装备id + --@return 属性信息 + --==============================-- + function XBaseEquipManager:GetEvaluatedAttribInfo(id) + return EvaluatedAttribInfoDict[id] + end + + --==============================-- + --desc: 获取属性展示信息 + --@pooId: 基地装备id + --@return 属性展示信息 + --==============================-- + function XBaseEquipManager.GetEvaluatedAttribShowInfo(id) + local info = EvaluatedAttribInfoDict[id] + if not info then + return + end + + local attriDescList = {} + if info.NumericalList and #info.NumericalList > 0 then + for _, v in pairs(info.NumericalList) do + tableInsert(attriDescList, { + Name = v.Name, + Key = v.Key, + Value = "+" .. FixToInt(v.Value) + }) + end + end + + if info.GrowRateList and #info.GrowRateList > 0 then + for _, v in pairs(info.GrowRateList) do + tableInsert(attriDescList, { + Name = v.Name, + Key = v.Key, + Value = "+" .. stringFormat("%.2f", (v.Value * fix.hundred):ToString()) .. "%" + }) + end + end + + return { + AttriDescList = attriDescList, + } + end + + function XBaseEquipManager.GetEvaluatedMaxAttribShowInfo(id) + local data = BaseEquipDatas[id] + if not data then + return + end + + local maxAttribDescList = {} + for _, pooId in pairs(data.AttribGroupIdList) do + tableInsert(maxAttribDescList, GetMaxAttribDesc(pooId)) + end + + return maxAttribDescList + end + + function XBaseEquipManager.GetBaseEquipPart(templateId) + local template = BaseEquipTemplates[templateId] + if not template then + XLog.ErrorTableDataNotFound("XBaseEquipManager.GetBaseEquipPart", + "template", "Share/BaseEquip/BaseEquip.tab", "templateId", tostring(templateId)) + return + end + + return template.Part + end + + function XBaseEquipManager.GetBaseEquipName(templateId) + local template = BaseEquipTemplates[templateId] + if not template then + XLog.ErrorTableDataNotFound("XBaseEquipManager.GetBaseEquipName", + "template", "Share/BaseEquip/BaseEquip.tab", "templateId", tostring(templateId)) + return + end + + return template.Name + end + + function XBaseEquipManager.GetBaseEquipQuality(templateId) + local template = BaseEquipTemplates[templateId] + if not template then + XLog.ErrorTableDataNotFound("XBaseEquipManager.GetBaseEquipQuality", + "template", "Share/BaseEquip/BaseEquip.tab", "templateId", tostring(templateId)) + return + end + + return template.Quality + end + + function XBaseEquipManager.GetBaseEquipIcon(templateId) + local template = BaseEquipTemplates[templateId] + if not template then + XLog.ErrorTableDataNotFound("XBaseEquipManager.GetBaseEquipIcon", + "template", "Share/BaseEquip/BaseEquip.tab", "templateId", tostring(templateId)) + return + end + + return template.Icon + end + + function XBaseEquipManager.GetBaseEquipBigIcon(templateId) + local template = BaseEquipTemplates[templateId] + if not template then + XLog.ErrorTableDataNotFound("XBaseEquipManager.GetBaseEquipBigIcon", + "template", "Share/BaseEquip/BaseEquip.tab", "templateId", tostring(templateId)) + return + end + + return template.BigIcon + end + + function XBaseEquipManager.GetBaseEquipDesc(templateId) + local template = BaseEquipTemplates[templateId] + if not template then + XLog.ErrorTableDataNotFound("XBaseEquipManager.GetBaseEquipDesc", + "template", "Share/BaseEquip/BaseEquip.tab", "templateId", tostring(templateId)) + return + end + + return template.Description + end + + function XBaseEquipManager.GetBaseEquipNotEvaluatedDesc(templateId) + local template = BaseEquipTemplates[templateId] + if not template then + XLog.ErrorTableDataNotFound("XBaseEquipManager.GetBaseEquipNotEvaluatedDesc", + "template", "Share/BaseEquip/BaseEquip.tab", "templateId", tostring(templateId)) + return + end + + return template.NotEvaluatedDesc + end + + function XBaseEquipManager.GetBaseEquipRecoveryRewardId(templateId) + local template = BaseEquipTemplates[templateId] + if not template then + XLog.ErrorTableDataNotFound("XBaseEquipManager.GetBaseEquipRecoveryRewardId", + "template", "Share/BaseEquip/BaseEquip.tab", "templateId", tostring(templateId)) + return + end + + return template.RecoveryRewardId + end + + function XBaseEquipManager.GetBaseEquipRecoveryRewardList(templateIdList) + if not templateIdList or #templateIdList <= 0 then + return + end + + local rewardGoodsList = {} + for _, templateId in pairs(templateIdList) do + local rewardId = XBaseEquipManager.GetBaseEquipRecoveryRewardId(templateId) + if rewardId then + local rewardList = XRewardManager.GetRewardList(rewardId) + for _, reward in pairs(rewardList) do + tableInsert(rewardGoodsList, reward) + end + end + end + + return XRewardManager.MergeAndSortRewardGoodsList(rewardGoodsList) + end + + function XBaseEquipManager.GetBaseEquipStar(templateId) + local template = XBaseEquipManager.GetBaseEquipTemplate(templateId) + return template.Star + end + + function XBaseEquipManager.GetBaseEquipInfo() + local baseEquipDict = {} + for k, v in pairs(BaseEquipInfo) do + local baseEquip = BaseEquipDatas[v] + baseEquipDict[k] = baseEquip + end + return baseEquipDict + end + + function XBaseEquipManager.GetBaseEquipById(id) + return BaseEquipDatas[id] + end + + function XBaseEquipManager.GetBaseEquipByPart(part) + local id = BaseEquipInfo[part] + if not id then + return + end + + return BaseEquipDatas[id] + end + + --==============================-- + --desc: 比较属性变化 + --@newId: 基地装备Id + --@oldId: 基地装备Id + --@return 比较结果 + --==============================-- + function XBaseEquipManager.CompareAttrib(newId, oldId) + if not newId then + return + end + + local newInfo = XBaseEquipManager:GetEvaluatedAttribInfo(newId) + local oldInfo + + if oldId then + oldInfo = XBaseEquipManager:GetEvaluatedAttribInfo(oldId) + end + + local resultList = {} + + local compareFunc = function(curInfo, infoList) + local result = XBaseEquipManager.XATTRIB_CHANGE.Up + + if not infoList or #infoList <= 0 then + return result + end + + for _, info in pairs(infoList) do + if info.Key == curInfo.Key then + if info.Value > curInfo.Value then + result = XBaseEquipManager.XATTRIB_CHANGE.Down + elseif info.Value < curInfo.Value then + result = XBaseEquipManager.XATTRIB_CHANGE.Up + else + result = XBaseEquipManager.XATTRIB_CHANGE.NoChange + end + break + end + end + + return result + end + + if newInfo.NumericalList and #newInfo.NumericalList > 0 then + for _, info in pairs(newInfo.NumericalList) do + tableInsert(resultList, compareFunc(info, oldInfo and oldInfo.NumericalList or nil)) + end + end + + if newInfo.GrowRateList and #newInfo.GrowRateList > 0 then + for _, info in pairs(newInfo.GrowRateList) do + tableInsert(resultList, compareFunc(info, oldInfo and oldInfo.GrowRateList or nil)) + end + end + + return resultList + end + + function XBaseEquipManager.HasBaseEquipUnEvaluated() + for _, baseEquip in pairs(BaseEquipDatas) do + if not XBaseEquipManager.IsBaseEquipEvaluated(baseEquip) then + return true + end + end + + return false + end + + function XBaseEquipManager.GetBaseEquipCount(templateId) + local count = 0 + for _, baseEquip in pairs(BaseEquipDatas) do + if baseEquip.TemplateId == templateId then + count = count + 1 + end + end + return count + end + + function XBaseEquipManager.GetAttribGroupIdListByType(type) + local groupIdList = {} + + for _, id in pairs(BaseEquipInfo) do + local baseEquip = BaseEquipDatas[id] + if baseEquip then + local template = XBaseEquipManager.GetBaseEquipTemplate(baseEquip.TemplateId) + if template and template.Type == type then + for _, groupId in pairs(baseEquip.AttribGroupIdList) do + tableInsert(groupIdList, groupId) + end + end + end + end + + return groupIdList + end + + ----------------------服务端协议begin---------------------- + function XBaseEquipManager.Evaluate(id, cb) + local baseEquipData = BaseEquipDatas[id] + if not baseEquipData then + XUiManager.TipCode(XCode.BaseEquipNotFound) + return + end + + if XBaseEquipManager.IsBaseEquipEvaluated(baseEquipData) then + XUiManager.TipCode(XCode.BaseEquipEvaluated) + return + end + + XNetwork.Call(METHOD_NAME.Evaluate, { Id = id }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + if cb then + cb(BaseEquipDatas[id]) + end + end) + end + + function XBaseEquipManager.PutOn(id, cb) + local baseEquipData = BaseEquipDatas[id] + if not baseEquipData then + XUiManager.TipCode(XCode.BaseEquipNotFound) + return + end + + local template = BaseEquipTemplates[baseEquipData.TemplateId] + if not template then + XUiManager.TipCode(XCode.BaseEquipTemplateNoFound) + return + end + + + if XBaseEquipManager.IsBaseEquipPutOn(id) then + XUiManager.TipCode(XCode.BaseEquipWasPutOn) + return + end + + XNetwork.Call(METHOD_NAME.PutOn, { Id = id }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + PutOnBaseEquip(template.Part, id) + + if cb then + cb() + end + + XEventManager.DispatchEvent(XEventId.EVENT_BASE_EQUIP_DATA_CHANGE_NOTIFY, id) + end) + end + + -- 本地管理的红点 -> 移除 + function XBaseEquipManager.DeleteNewHint(id) + local key = XPrefs.BaseEquip .. tostring(XPlayer.Id) .. id + if CS.UnityEngine.PlayerPrefs.HasKey(key) then + CS.UnityEngine.PlayerPrefs.DeleteKey(key) + end + end + + -- 本地管理的红点 -> 增加Id 表示此红点不再出现! + function XBaseEquipManager.AddNewHint(id) + local key = XPrefs.BaseEquip .. tostring(XPlayer.Id) .. id + if not CS.UnityEngine.PlayerPrefs.HasKey(key) then + CS.UnityEngine.PlayerPrefs.SetString(key, key) + end + end + + -- 本地管理的红点 -> 检查是否需要显示红点 + -- 如果本地有存储 说明不需要显示 + function XBaseEquipManager.CheckNewHint(id) + local key = XPrefs.BaseEquip .. tostring(XPlayer.Id) .. id + return not CS.UnityEngine.PlayerPrefs.HasKey(key) + end + + function XBaseEquipManager.CheckNewHintByPart(part) + local isNew = false + local baseEquipList = XBaseEquipManager.GetBaseEquipListByPart(part) + for _, baseEquip in pairs(baseEquipList) do + local key = XPrefs.BaseEquip .. tostring(XPlayer.Id) .. baseEquip.Id + if not CS.UnityEngine.PlayerPrefs.HasKey(key) then + isNew = true + end + end + return isNew + end + + function XBaseEquipManager.CheckBaseEquipHint() + local isNew = false + for part = 1, 6 do + if XBaseEquipManager.CheckNewHintByPart(part) then + isNew = true + break + end + end + return isNew + end + + function XBaseEquipManager.Recycle(idList, cb) + if #idList == 0 then + XUiManager.TipText("BaseEquipRecycleNotSelected") + return + end + local highQuality = false + + for _, id in pairs(idList) do + local data = BaseEquipDatas[id] + if not data then + XUiManager.TipCode(XCode.BaseEquipNotFound) + return + end + + if XBaseEquipManager.IsBaseEquipPutOn(id) then + XUiManager.TipCode(XCode.BaseEquipWasPutOn) + return + end + + XBaseEquipManager.DeleteNewHint(id) + + local quality = XBaseEquipManager.GetBaseEquipQuality(data.TemplateId) + + if quality >= XGoodsCommonManager.QualityType.Gold then + highQuality = true + end + end + + local requestFunc = function() + XNetwork.Call(METHOD_NAME.Recycle, { IdList = idList }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + if res.RewardGoodsList and #res.RewardGoodsList > 0 then + XUiManager.OpenUiObtain(res.RewardGoodsList) + end + + DeleteBaseEquips(idList) + + if cb then + cb() + end + end) + end + + if highQuality then + XUiManager.DialogTip("", CS.XTextManager.GetText("DecomposeConfirmTip"), XUiManager.DialogType.Normal, nil, requestFunc) + return + end + + requestFunc() + end + + local function UpdateBaseEquipDatas(baseEquipList) + if not baseEquipList or #baseEquipList <= 0 then + return + end + + for _, baseEquip in pairs(baseEquipList) do + BaseEquipDatas[baseEquip.Id] = baseEquip + AddEvaluatedAttribInfo(baseEquip) + end + + XEventManager.DispatchEvent(XEventId.EVENT_BASE_EQUIP_DATA_REFRESH) + end + + function XBaseEquipManager.NotifyBaseEquipDataList(data) + if not data then return end + UpdateBaseEquipDatas(data.BaseEquipDataList) + end + + function XBaseEquipManager.NotifyBaseEquipInfo(data) + if not data then return end + BaseEquipInfo = data.BaseEquipInfo + end + + local function UpdateBaseEquipInfo(dressedList) + if not dressedList or #dressedList <= 0 then + return + end + + for _, info in pairs(dressedList) do + BaseEquipInfo[info.Part] = info.BaseEquipId + end + end + + ----------------------服务端协议end---------------------- + function XBaseEquipManager.InitLoginData(data) + if not data then + return + end + + UpdateBaseEquipDatas(data.BaseEquipList) + UpdateBaseEquipInfo(data.DressedList) + end + + XBaseEquipManager.Init() + return XBaseEquipManager +end + +XRpc.NotifyBaseEquipDataList = function(data) + XDataCenter.BaseEquipManager.NotifyBaseEquipDataList(data) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XBfrtManager.lua b/Resources/Scripts/XManager/XBfrtManager.lua new file mode 100644 index 00000000..6cd6266f --- /dev/null +++ b/Resources/Scripts/XManager/XBfrtManager.lua @@ -0,0 +1,935 @@ +XBfrtManagerCreator = function() + + local pairs = pairs + local ipairs = ipairs + local string = string + local table = table + local tableInsert = table.insert + local tableRemove = table.remove + local tableSort = table.sort + local ParseToTimestamp = XTime.ParseToTimestamp + local FightCb + local CloseLoadingCb + + -- 据点战管理器 + local XBfrtManager = {} + + --据点战梯队类型 + XBfrtManager.EchelonType = { + Fight = 0, --作战梯队 + Logistics = 1, --后勤梯队 + } + + local METHOD_NAME = { + GetBfrtDataRequest = "GetBfrtDataRequest", + BfrtTeamSetRequest = "BfrtTeamSetRequest" + } + + local BfrtChapterTemplates = {} + local BfrtGroupTemplates = {} + local EchelonInfoTemplates = {} + + local BfrtFollowGroupDic = {} + local ChapterInfos = {} + local GroupInfos = {} + local ChapterDic = {} + local GroupIdToOrderIdDic = {} + local StageDic = {} + local TaskIdToOrderIdDic = {} + local GroupIdToChapterIdDic = {} + local EchlonTeamPosDic = {} + local EchlonFirstFightDic = {} + + --面板上显示的位置 = 队伍中实际中的位置 + local TEAM_POS_DIC = { + [1] = 2, + [2] = 1, + [3] = 3, + } + + local BfrtData = {} + local FightTeams = {} + local LogisticsTeams = {} + + local function IsGroupPassed(groupId) + local records = BfrtData.BfrtGroupRecords + if not records then + return false + end + + for _, record in pairs(records) do + if record.Id == groupId then + return true + end + end + + return false + end + + function XBfrtManager.GetChapterInfo(chapterId) + return ChapterInfos[chapterId] + end + + local function GetGroupInfo(groupId) + return GroupInfos[groupId] + end + + function XBfrtManager.GetChapterCfg(chapterId) + local chapterCfg = BfrtChapterTemplates[chapterId] + if not chapterCfg then + XLog.ErrorTableDataNotFound("XBfrtManager.GetChapterCfg", "chapterCfg", + "Share/Fuben/Bfrt/BfrtChapter.tab", "chapterId", tostring(chapterId)) + return + end + return chapterCfg + end + + local function GetGroupCfg(groupId) + local groupCfg = BfrtGroupTemplates[groupId] + if not groupCfg then + XLog.ErrorTableDataNotFound("GetGroupCfg", "groupCfg", "Share/Fuben/Bfrt/BfrtGroup.tab", "groupId", tostring(groupId)) + return + end + return groupCfg + end + + function XBfrtManager.GetStageIdList(groupId) + local stageIdList = {} + + local groupCfg = GetGroupCfg(groupId) + local seqList = string.ToIntArray(groupCfg.TeamFightSeq, '|') + local originList = groupCfg.StageId + for index, seq in ipairs(seqList) do + stageIdList[index] = originList[seq] + end + + return stageIdList + end + + function XBfrtManager.GetFightInfoIdList(groupId) + local fightInfoIdList = {} + + local groupCfg = GetGroupCfg(groupId) + local seqList = string.ToIntArray(groupCfg.TeamFightSeq, '|') + local originList = groupCfg.FightInfoId + for index, seq in ipairs(seqList) do + fightInfoIdList[index] = originList[seq] + end + + return fightInfoIdList + end + + function XBfrtManager.GetLogisticsInfoIdList(groupId) + local groupCfg = GetGroupCfg(groupId) + return groupCfg.LogisticsInfoId + end + + local function GetEchelonInfo(echelonId) + local echelon = EchelonInfoTemplates[echelonId] + if not echelon then + XLog.ErrorTableDataNotFound("GetEchelonInfo", "echelon", "Share/Fuben/Bfrt/EchelonInfo.tab", "echelonId", tostring(echelonId)) + return + end + + return echelon + end + + function XBfrtManager.GetGroupList(chapterId) + local chapter = BfrtChapterTemplates[chapterId] + if not chapter then + XLog.ErrorTableDataNotFound("XBfrtManager.GetGroupList", "chapter", "Share/Fuben/Bfrt/BfrtChapter.tab", "chapterId", tostring(chapterId)) + return + end + + return chapter.GroupId + end + + function XBfrtManager.GetChapterName(chapterId) + local chapter = BfrtChapterTemplates[chapterId] + if not chapter then + XLog.ErrorTableDataNotFound("XBfrtManager.GetChapterName", "chapter", "Share/Fuben/Bfrt/BfrtChapter.tab", "chapterId", tostring(chapterId)) + return + end + + return chapter.ChapterName + end + + function XBfrtManager.TeamPosConvert(index) + return TEAM_POS_DIC[index] + end + + function XBfrtManager.MemberIndexConvert(pos) + for index, dicPos in pairs(TEAM_POS_DIC) do + if pos == dicPos then + return index + end + end + end + + local function CheckTeamLimit(echelonId, team) + local needNum = XBfrtManager.GetEchelonNeedCharacterNum(echelonId) + for i = 1, needNum do + local characterId = team[i] + if not characterId or characterId == 0 then + return false + end + end + + return true + end + + --获取各梯队需求人数 + function XBfrtManager.GetEchelonNeedCharacterNum(echelonId) + local echelon = GetEchelonInfo(echelonId) + return echelon and echelon.NeedCharacter + end + + function XBfrtManager.InitStageInfo() + for groupId, groupCfg in pairs(BfrtGroupTemplates) do + local groupInfo = GroupInfos[groupId] + for _, v in pairs(groupCfg.StageId) do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(v) + if not stageInfo then + local tmpStr = "XBfrtManager InitStageInfo错误, 无法根据 Share/Fuben/Bfrt/BfrtGroup.tab 表里面的stageId" + XLog.Error(tmpStr .. v .. " 找到Share/Fuben/Stage.tab 表中的表项") + break + end + + stageInfo.IsOpen = true + stageInfo.Type = XDataCenter.FubenManager.StageType.Bfrt + stageInfo.Unlock = groupInfo and groupInfo.Unlock or false + stageInfo.ChapterId = groupInfo and groupInfo.ChapterId + + end + + local baseStageInfo = XDataCenter.FubenManager.GetStageInfo(groupCfg.BaseStage) + baseStageInfo.IsOpen = true + baseStageInfo.Type = XDataCenter.FubenManager.StageType.Bfrt + baseStageInfo.Unlock = groupInfo and groupInfo.Unlock or false + baseStageInfo.ChapterId = groupInfo and groupInfo.ChapterId + end + end + + local function InitGroupInfo() + GroupInfos = {} + for groupId, groupCfg in pairs(BfrtGroupTemplates) do + local info = {} + GroupInfos[groupId] = info + GroupIdToOrderIdDic[groupId] = groupCfg.GroupOrderId + + info.Unlock = true + local preGroupId = groupCfg.PreGroupId + if preGroupId and preGroupId > 0 then + info.Unlock = false + for _, record in pairs(BfrtData.BfrtGroupRecords) do + if record.Id == preGroupId then + info.Unlock = true + break + end + end + end + + StageDic[groupCfg.BaseStage] = { + GroupId = groupId, + IsLastStage = false, + } + + local count = #groupCfg.StageId + for k, v in pairs(groupCfg.StageId) do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(v) + if stageInfo then + stageInfo.Unlock = info.Unlock + + StageDic[v] = { + GroupId = groupId, + IsLastStage = (k == count) + } + else + local tmpStr = "XBfrtManager.InitGroupInfo错误, 无法根据 Share/Fuben/Bfrt/BfrtGroup.tab 表里面的stageId" + XLog.Error(tmpStr .. v .. " 找到Share/Fuben/Stage.tab 表中的表项") + end + end + info.Passed = IsGroupPassed(groupId) + end + end + + local function InitChapterInfo() + ChapterInfos = {} + for chapterId, chapterCfg in pairs(BfrtChapterTemplates) do + ChapterDic[chapterCfg.OrderId] = chapterId + local info = {} + ChapterInfos[chapterId] = info + info.ChapterId = chapterId + if #chapterCfg.GroupId > 0 then + local groupId = chapterCfg.GroupId[1] + local groupInfo = GroupInfos[groupId] + if groupInfo then + info.Unlock = groupInfo.Unlock + end + end + + local allPassed = true + for k, v in pairs(chapterCfg.GroupId) do + GroupIdToChapterIdDic[v] = chapterId + + local groupInfo = GroupInfos[v] + groupInfo.OrderId = k + groupInfo.ChapterId = chapterId + + local groupCfg = BfrtGroupTemplates[v] + for _, v2 in pairs(groupCfg.StageId) do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(v2) + stageInfo.ChapterId = chapterId + end + + if not groupInfo.Passed then + allPassed = false + end + end + info.Passed = allPassed + + for orderId, taskId in ipairs(chapterCfg.TaskId) do + TaskIdToOrderIdDic[taskId] = orderId + end + end + end + + local function GetChapterTaskIdList(chapterId) + local chapterCfg = XBfrtManager.GetChapterCfg(chapterId) + local taskIdList = chapterCfg.TaskId + if not taskIdList then + XLog.ErrorTableDataNotFound("XBfrtManager.GetChapterTaskIdList", + "TaskId", "Share/Fuben/Bfrt/BfrtChapter.tab", "chapterId", tostring(chapterId)) + end + return taskIdList + end + + local function InitFollowGroup() + for k, v in pairs(BfrtGroupTemplates) do + if v.PreGroupId > 0 then + local list = BfrtFollowGroupDic[v.PreGroupId] + if not list then + list = {} + end + + tableInsert(list, k) + BfrtFollowGroupDic[v.PreGroupId] = list + end + end + end + + local function InitTeamRecords() + local teamInfos = BfrtData.BfrtTeamInfos + if not teamInfos then return end + + for _, teamInfo in pairs(teamInfos) do + if teamInfo then + local groupId = teamInfo.Id + FightTeams[groupId] = teamInfo.FightTeamList + LogisticsTeams[groupId] = teamInfo.LogisticsTeamList + + local captainList = teamInfo.CaptainPosList + local firstFightList = teamInfo.FirstFightPosList + + if captainList then + local fightInfoIdList = XBfrtManager.GetFightInfoIdList(groupId) + for index, echelonId in ipairs(fightInfoIdList) do + XBfrtManager.SetTeamCaptainPos(echelonId, captainList[index]) + end + end + + if firstFightList then + local fightInfoIdList = XBfrtManager.GetFightInfoIdList(groupId) + for index, echelonId in ipairs(fightInfoIdList) do + XBfrtManager.SetTeamFirstFightPos(echelonId, firstFightList[index]) + end + end + end + end + end + + local function UnlockFollowGroup(groupId) + local list = BfrtFollowGroupDic[groupId] + if not list then + return + end + + for _, id in pairs(list) do + GroupInfos[id].Unlock = true + + local groupCfg = BfrtGroupTemplates[id] + for _, v in pairs(groupCfg.StageId) do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(v) + stageInfo.Unlock = true + end + + local baseStageInfo = XDataCenter.FubenManager.GetStageInfo(groupCfg.BaseStage) + baseStageInfo.Unlock = true + + local chapterId = XBfrtManager.GetChapterIdByGroupId(id) + local chapterInfo = XBfrtManager.GetChapterInfo(chapterId) + chapterInfo.Unlock = true + end + end + + function XBfrtManager.CheckActivityCondition(chapterId) + local chapterCfg = XBfrtManager.GetChapterCfg(chapterId) + local conditionId = chapterCfg.ActivityCondition + if conditionId ~= 0 and not XConditionManager.CheckCondition(conditionId) then + return false + end + return true + end + + function XBfrtManager.CheckAnyTaskRewardCanGet(chapterId) + if not chapterId then + return + end + local taskId = XBfrtManager.GetBfrtTaskId(chapterId) + local taskData = XDataCenter.TaskManager.GetTaskDataById(taskId) + return taskData and taskData.State == XDataCenter.TaskManager.TaskState.Achieved + end + + function XBfrtManager.GetTaskOrderId(taskId) + return TaskIdToOrderIdDic[taskId] + end + + function XBfrtManager.GetGroupIdByStageId(stageId) + if not StageDic[stageId] then + XLog.Error("XBfrtManager GetGroupIdByStageId 无法从StageDic中找到groupId,检查 Share/Fuben/Bfrt/BfrtGroup.tab 表, stageId 是" .. stageId) + return + end + return StageDic[stageId].GroupId + end + + function XBfrtManager.GetGroupIdByBaseStage(baseStage) + return XBfrtManager.GetGroupIdByStageId(baseStage) + end + + function XBfrtManager.Init() + BfrtChapterTemplates = XBfrtConfigs.GetBfrtChapterTemplates() + BfrtGroupTemplates = XBfrtConfigs.GetBfrtGroupTemplates() + EchelonInfoTemplates = XBfrtConfigs.GetEchelonInfoTemplates() + end + + function XBfrtManager.IsChapterInTime(chapterId) + local chapterCfg = XBfrtManager.GetChapterCfg(chapterId) + local startTime = ParseToTimestamp(chapterCfg.OpenTimeStr) + if not startTime or startTime <= 0 then + return true + end + + local nowTime = XTime.GetServerNowTimestamp() + return startTime <= nowTime + end + + function XBfrtManager.GetChapterList() + local list = {} + + for _, chapterId in pairs(ChapterDic) do + if XBfrtManager.IsChapterInTime(chapterId) then + tableInsert(list, chapterId) + end + end + + return list + end + + function XBfrtManager.GetChapterInfoForOrder(orderId) + local chapterId = ChapterDic[orderId] + return ChapterInfos[chapterId] + end + + function XBfrtManager.GetGroupRequireCharacterNum(groupId) + local groupRequireCharacterNum = 0 + + local fightInfoList = XBfrtManager.GetFightInfoIdList(groupId) + for _, echelonId in pairs(fightInfoList) do + groupRequireCharacterNum = groupRequireCharacterNum + XBfrtManager.GetEchelonNeedCharacterNum(echelonId) + end + + local logisticsInfoList = XBfrtManager.GetLogisticsInfoIdList(groupId) + for _, echelonId in pairs(logisticsInfoList) do + groupRequireCharacterNum = groupRequireCharacterNum + XBfrtManager.GetEchelonNeedCharacterNum(echelonId) + end + + return groupRequireCharacterNum + end + + function XBfrtManager.CheckChapterNew(chapterId) + local chapterInfo = XBfrtManager.GetChapterInfo(chapterId) + return chapterInfo.Unlock and not chapterInfo.Passed + end + + --获取当前最新解锁的Chapter + function XBfrtManager.GetActiveChapterId() + local activeChapterId = 1 + + local chapterIdList = XBfrtManager.GetChapterList() + for _, chapterId in ipairs(chapterIdList) do + local chapterInfo = XBfrtManager.GetChapterInfo(chapterId) + if chapterInfo.Unlock then + activeChapterId = chapterId + end + end + + return activeChapterId + end + + function XBfrtManager.GetChapterOrderId(chapterId) + local chapterCfg = XBfrtManager.GetChapterCfg(chapterId) + return chapterCfg.OrderId + end + + function XBfrtManager.GetGroupOrderId(groupId) + local groupInfo = GetGroupInfo(groupId) + return groupInfo.OrderId + end + + --获取Chapter中所有Group用于展示的BaseStage的List + function XBfrtManager.GetBaseStageList(chapterId) + local baseStageList = {} + + local groupList = XBfrtManager.GetGroupList(chapterId) + for _, groupId in ipairs(groupList) do + local groupCfg = GetGroupCfg(groupId) + table.insert(baseStageList, groupCfg.BaseStage) + end + + return baseStageList + end + + function XBfrtManager.GetBaseStage(groupId) + local groupCfg = GetGroupCfg(groupId) + return groupCfg.BaseStage + end + + function XBfrtManager.CheckBaseStageUnlock(baseStage) + local groupId = XBfrtManager.GetGroupIdByBaseStage(baseStage) + local groupInfo = GetGroupInfo(groupId) + return groupInfo.Unlock + end + + function XBfrtManager.IsGroupPassedByStageId(stageId) + local groupId = XDataCenter.BfrtManager.GetGroupIdByStageId(stageId) + local groupInfo = GetGroupInfo(groupId) + return groupInfo.Passed + end + + function XBfrtManager.GetLogisticSkillDes(echelonId) + local echelon = GetEchelonInfo(echelonId) + if not echelon.BuffId or echelon.BuffId == 0 then + XLog.ErrorTableDataNotFound("XBfrtManager.GetLogisticSkillDes", "BuffId", + "Share/Fuben/Bfrt/EchelonInfo.tab", "echelonId", tostring(echelonId)) + return + end + + local fightEventCfg = CS.XNpcManager.GetFightEventTemplate(echelon.BuffId) + return fightEventCfg and fightEventCfg.Description + end + + function XBfrtManager.GetEchelonRequireAbility(echelonId) + local echelon = GetEchelonInfo(echelonId) + return echelon.RequireAbility + end + + function XBfrtManager.GetEchelonConditionId(echelonId) + local echelon = GetEchelonInfo(echelonId) + return echelon.Condition + end + + function XBfrtManager.CheckStageTypeIsBfrt(stageId) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + if stageInfo and stageInfo.Type == XDataCenter.FubenManager.StageType.Bfrt then + return true + end + return false + end + + function XBfrtManager.GetFightTeamList(groupId) + local team = FightTeams[groupId] or {} + return XTool.Clone(team) + end + + function XBfrtManager.GetLogisticsTeamList(groupId) + local team = LogisticsTeams[groupId] or {} + return XTool.Clone(team) + end + + function XBfrtManager.GetTotalTaskNum(chapterId) + local taskIdList = GetChapterTaskIdList(chapterId) + return #taskIdList + end + + function XBfrtManager.GetCurFinishTaskNum(chapterId) + local finishTaskNum = 0 + local taskIdList = GetChapterTaskIdList(chapterId) + for _, taskId in pairs(taskIdList) do + local taskData = XDataCenter.TaskManager.GetTaskDataById(taskId) + if taskData then + if taskData.State == XDataCenter.TaskManager.TaskState.Achieved or taskData.State == XDataCenter.TaskManager.TaskState.Finish then + finishTaskNum = finishTaskNum + 1 + end + end + end + return finishTaskNum + end + + function XBfrtManager.CheckAllTaskRewardHasGot(chapterId) + local taskId = XBfrtManager.GetBfrtTaskId(chapterId) + local taskData = XDataCenter.TaskManager.GetTaskDataById(taskId) + return taskData and taskData.State == XDataCenter.TaskManager.TaskState.Finish + end + + function XBfrtManager.GetBfrtTaskId(chapterId) + local taskIdList = GetChapterTaskIdList(chapterId) + return taskIdList[1] + end + + function XBfrtManager.CheckAllChapterReward() + if not ChapterDic then return false end + for _, chapterId in pairs(ChapterDic) do + if XBfrtManager.CheckAnyTaskRewardCanGet(chapterId) then + return true + end + end + return false + end + + function XBfrtManager.FinishStage(stageId) + local stage = StageDic[stageId] + if not stage or not stage.IsLastStage then + return + end + + local groupId = stage.GroupId + GroupInfos[groupId].Passed = true + + local findRecord = false + for _, record in pairs(BfrtData.BfrtGroupRecords) do + if record.Id == groupId then + record.Count = record.Count + 1 + findRecord = true + break + end + end + + if not findRecord then + local record = { + Id = groupId, + Count = 1, + } + tableInsert(BfrtData.BfrtGroupRecords, record) + end + + UnlockFollowGroup(groupId) + end + + function XBfrtManager.GetGroupFinishCount(baseStage) + local records = BfrtData.BfrtGroupRecords + if not records then + return 0 + end + + local groupId = XBfrtManager.GetGroupIdByBaseStage(baseStage) + for _, record in pairs(records) do + if record.Id == groupId then + return record.Count + end + end + + return 0 + end + + function XBfrtManager.IsBfrtChapter(id) + return BfrtChapterTemplates[id] ~= nil + end + + function XBfrtManager.GetGroupMaxChallengeNum(baseStage) + local groupId = XBfrtManager.GetGroupIdByBaseStage(baseStage) + local groupCfg = GetGroupCfg(groupId) + return groupCfg.ChallengeNum + end + + function XBfrtManager.GetChapterIdByGroupId(groupId) + return GroupIdToChapterIdDic[groupId] + end + + function XBfrtManager.GetEchelonNameTxt(echelonType, echelonIndex) + local echelonNameTxt + if echelonType == XBfrtManager.EchelonType.Fight then + echelonNameTxt = CS.XTextManager.GetText("BfrtFightEchelonTitle", echelonIndex) + elseif echelonType == XBfrtManager.EchelonType.Logistics then + echelonNameTxt = CS.XTextManager.GetText("BfrtLogisticEchelonTitle", echelonIndex) + end + + return echelonNameTxt + end + + function XBfrtManager.OpenFightLoading() + return + end + + function XBfrtManager.CloseFightLoading(stage) + if CloseLoadingCb then + CloseLoadingCb() + end + + local groupId = XBfrtManager.GetGroupIdByStageId(stage) + local logisticsInfoIdList = XBfrtManager.GetLogisticsInfoIdList(groupId) + local totalShowTimes = #logisticsInfoIdList + if totalShowTimes > 0 then + XLuaUiManager.Open("UiTipBfrtLogisticSkill", groupId) + end + end + + function XBfrtManager.FinishFight(settle) + XDataCenter.FubenManager.FinishFight(settle) + if FightCb then + FightCb(settle.IsWin) + end + end + + function XBfrtManager.ShowReward(winData) + if XBfrtManager.CheckIsGroupLastStage(winData.StageId) then + XLuaUiManager.Open("UiBfrtPostWarCount", winData) + end + end + + function XBfrtManager.SetCloseLoadingCb(cb) + CloseLoadingCb = cb + end + + function XBfrtManager.SetFightCb(cb) + FightCb = cb + end + + function XBfrtManager.CheckIsGroupLastStage(stageId) + local groupId = XBfrtManager.GetGroupIdByStageId(stageId) + local stageIdList = XBfrtManager.GetStageIdList(groupId) + return stageIdList[#stageIdList] == stageId + end + + function XBfrtManager.GetGroupOrderIdByStageId(stageId) + local groupId = XBfrtManager.GetGroupIdByStageId(stageId) + return GroupIdToOrderIdDic[groupId] + end + + function XBfrtManager.CheckPreGroupUnlock(groupId) + local groupInfo = GetGroupInfo(groupId) + local groupCfg = GetGroupCfg(groupId) + return groupInfo.Unlock, groupCfg.PreGroupId + end + + ----------------------服务端协议begin---------------------- + local function CheckFightTeamCondition(groupId, teamList) + local infoList = XBfrtManager.GetFightInfoIdList(groupId) + + for k, echelonId in pairs(infoList) do + local team = teamList[k] + if not team then + return false + end + + if not CheckTeamLimit(echelonId, team) then + return false + end + end + + return true + end + + local function CheckLogisticsTeamCondition(groupId, teamList) + local infoList = XBfrtManager.GetLogisticsInfoIdList(groupId) + + if not infoList or not next(infoList) then + return true + end + + for k, echelonId in pairs(infoList) do + local team = teamList[k] + if not team or not CheckTeamLimit(echelonId, team) then + return false + end + end + + return true + end + + function XBfrtManager.CheckTeam(groupId, fightTeamList, logisticsTeamList, cb) + if not CheckFightTeamCondition(groupId, fightTeamList) then + XUiManager.TipText("FightTeamConditionLimit") + return + end + + if not CheckLogisticsTeamCondition(groupId, logisticsTeamList) then + XUiManager.TipText("LogisticsTeamConditionLimit") + return + end + + local captainList = {} + local firstFightPosList = {} + local fightInfoIdList = XBfrtManager.GetFightInfoIdList(groupId) + for _, echelonId in ipairs(fightInfoIdList) do + local captainPos = XBfrtManager.GetTeamCaptainPos(echelonId) + tableInsert(captainList, captainPos) + + local firstFightPos = XBfrtManager.GetTeamFirstFightPos(echelonId) + tableInsert(firstFightPosList, firstFightPos) + end + + XNetwork.Call(METHOD_NAME.BfrtTeamSetRequest, { + BfrtGroupId = groupId, + FightTeam = fightTeamList, --List /*characterId list*/> + LogisticsTeam = logisticsTeamList, --List /*characterId list*/> + CaptainPosList = captainList, + FirstFightPosList = firstFightPosList, + }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + FightTeams[groupId] = fightTeamList + LogisticsTeams[groupId] = logisticsTeamList + + if cb then + cb() + end + end) + end + + function XBfrtManager.AutoTeam(groupId) + local anyMemberInTeam = false + local fightTeamList = {} + local logisticsTeamList = {} + local sortTeamInfoList = {} + local fightInfoIdList = XBfrtManager.GetFightInfoIdList(groupId) + local stageIds = XBfrtManager.GetStageIdList(groupId) + for i, echelonId in ipairs(fightInfoIdList) do + local fightTeam = { 0, 0, 0 } + tableInsert(fightTeamList, fightTeam) + + local echelonCfg = GetEchelonInfo(echelonId) + local teamInfo = { + Index = i, + RequireAbility = echelonCfg.RequireAbility, + NeedCharacter = echelonCfg.NeedCharacter, + Team = fightTeam, + StageId = stageIds[i], + } + tableInsert(sortTeamInfoList, teamInfo) + end + + local logisticsInfoIdList = XBfrtManager.GetLogisticsInfoIdList(groupId) + for i, echelonId in ipairs(logisticsInfoIdList) do + local logisticsTeam = { 0, 0, 0 } + tableInsert(logisticsTeamList, logisticsTeam) + + local echelonCfg = GetEchelonInfo(echelonId) + local teamInfo = { + Index = i, + RequireAbility = echelonCfg.RequireAbility, + NeedCharacter = echelonCfg.NeedCharacter, + Team = logisticsTeam, + StageId = stageIds[i], + } + tableInsert(sortTeamInfoList, teamInfo) + end + + tableSort(sortTeamInfoList, function(a, b) + if a.RequireAbility ~= b.RequireAbility then + return a.RequireAbility > b.RequireAbility + end + return a.Index < b.Index + end) + + local ownCharacters = XDataCenter.CharacterManager.GetOwnCharacterList() + tableSort(ownCharacters, function(a, b) + return a.Ability > b.Ability + end) + + for _, teamInfo in pairs(sortTeamInfoList) do + if not next(ownCharacters) then break end + + local characterLimitType = XFubenConfigs.GetStageCharacterLimitType(teamInfo.StageId) + local defaultCharacterType = XDataCenter.FubenManager.GetDefaultCharacterTypeByCharacterLimitType(characterLimitType) + for memberIndex = 1, teamInfo.NeedCharacter do + for index, character in ipairs(ownCharacters) do + -- if character.Ability >= teamInfo.RequireAbility then + local charType = XCharacterConfigs.GetCharacterType(character.Id) + if defaultCharacterType ~= XFubenConfigs.CharacterLimitType.All and defaultCharacterType ~= charType then + goto SELECT_CONTINUE + end + teamInfo.Team[memberIndex] = character.Id + tableRemove(ownCharacters, index) + anyMemberInTeam = true + break + -- end + :: SELECT_CONTINUE :: + end + end + end + + + return fightTeamList, logisticsTeamList, anyMemberInTeam + end + + function XBfrtManager.GetChapterPassCount(chapterId) + local passCount = 0 + + local groupList = XBfrtManager.GetGroupList(chapterId) + for _, groupId in ipairs(groupList) do + if GroupInfos[groupId].Passed then + passCount = passCount + 1 + end + end + + return passCount + end + + function XBfrtManager.GetGroupCount(chapterId) + local groupList = XBfrtManager.GetGroupList(chapterId) + return #groupList + end + + function XBfrtManager.GetTeamCaptainPos(echelonId) + return EchlonTeamPosDic[echelonId] or XBfrtConfigs.CAPTIAN_MEMBER_INDEX + end + + function XBfrtManager.SetTeamCaptainPos(echelonId, captainPos) + EchlonTeamPosDic[echelonId] = captainPos + end + + ---========================================== + --- 得到队伍首发位 + --- 当首发位不为空时,直接返回首发位 + --- 不然查看队长位是否为空,不为空则返回队长位 + ---(因为服务器在之前只有队长位,后面区分了队长位与首发位,存在有队长位数据,没有首发位数据的情况) + --- 如果队长位也为空,则返回默认首发位 + ---@return number + ---========================================== + function XBfrtManager.GetTeamFirstFightPos(echelonId) + return EchlonFirstFightDic[echelonId] or EchlonTeamPosDic[echelonId] or XBfrtConfigs.FIRST_FIGHT_MEMBER_INDEX + end + + function XBfrtManager.SetTeamFirstFightPos(echelonId, firstFightPos) + EchlonFirstFightDic[echelonId] = firstFightPos + end + + function XBfrtManager.NotifyBfrtData(data) + BfrtData = data.BfrtData + + InitGroupInfo() + InitChapterInfo() + InitFollowGroup() + InitTeamRecords() + end + ----------------------服务端协议end---------------------- + XBfrtManager.Init() + return XBfrtManager +end + +XRpc.NotifyBfrtData = function(data) + XDataCenter.BfrtManager.NotifyBfrtData(data) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XBountyTaskManager.lua b/Resources/Scripts/XManager/XBountyTaskManager.lua new file mode 100644 index 00000000..6a6ce2b9 --- /dev/null +++ b/Resources/Scripts/XManager/XBountyTaskManager.lua @@ -0,0 +1,573 @@ +XBountyTaskManagerCreator = function() + + local XBountyTaskManager = {} + XBountyTaskManager.BountyTaskStatus = { + ["Normal"] = 0, + ["DifficultStageWin"] = 1, + ["Complete"] = 2, + ["AcceptReward"] = 3, + } + + --最大任务数 + XBountyTaskManager.MAX_BOUNTY_TASK_COUNT = CS.XGame.Config:GetInt("BountyTaskCount") + --最大刷新次數 + XBountyTaskManager.MAX_BOUNTY_TASK_REFRESH_COUNT = CS.XGame.Config:GetInt("BountyTaskRefreshCount") + + + --赏金任务数据 + local BountyTaskInfo = nil + local BountyTaskPreFightData = nil + local BountyTaskFightData = nil + --表数据 + local BountyTaskConfig = {} + local BountyTaskRankConfig = {} + local BountyTaskRandomEventConfig = {} + local BountyTaskDifficultStageConfig = {} + + local FakeBountyTaskOrder = {} + local SelectIndex = -1; + local MaxRankLevel = 0 + + local RefreshTime = -1 + + --协议 + local BountyTaskRequest = { + AcceptBountyTaskRequest = "AcceptBountyTaskRequest", + AcceptBountyTaskRewardRequest = "AcceptBountyTaskRewardRequest", + RefreshBountyTaskPoolRequest = "RefreshBountyTaskPoolRequest", + } + + function XBountyTaskManager.Init() + XBountyTaskManager.InitConfig() + end + + --初始化表 + function XBountyTaskManager.InitConfig() + BountyTaskConfig = XBountyTaskConfigs.GetBountyTaskConfig() + BountyTaskRankConfig = XBountyTaskConfigs.GetBountyTaskRankConfig() + BountyTaskRandomEventConfig = XBountyTaskConfigs.GetBountyTaskRandomEventConfig() + BountyTaskDifficultStageConfig = XBountyTaskConfigs.GetBountyTaskDifficultStageConfig() + + --获取最高等级 + MaxRankLevel = XBountyTaskConfigs.MaxRankLevel + end + + --登录下发 + function XBountyTaskManager.InitData(taskInfo) + BountyTaskInfo = taskInfo + end + + ---外部接口------------------------------------------------------ + ---获取任务数据 + function XBountyTaskManager.GetBountyTaskInfo() + return BountyTaskInfo + end + + --获取等级 + function XBountyTaskManager.GetBountyTaskInfoRankLevel() + if not BountyTaskInfo then + return 0 + end + + return BountyTaskInfo.RankLevel + end + + + --获取最大等级 + function XBountyTaskManager.GetMaxBountyTaskInfoRankLevel() + return MaxRankLevel + end + + --获取任务完成数量 + function XBountyTaskManager.GetBountyTaskCompletedCount() + if not BountyTaskInfo then + return 0 + end + + local taskCount = #BountyTaskInfo.TaskCards + + local completeCount = 0 + + for index = 1, taskCount do + if BountyTaskInfo.TaskCards[index].Status == XBountyTaskManager.BountyTaskStatus.Complete or + BountyTaskInfo.TaskCards[index].Status == XBountyTaskManager.BountyTaskStatus.AcceptReward then + completeCount = completeCount + 1 + end + end + + return completeCount + end + + + --是否有可以领奖的任务 + function XBountyTaskManager.CheckBountyTaskCanReward() + if not BountyTaskInfo then + return false + end + + local taskCount = #BountyTaskInfo.TaskCards + + for index = 1, taskCount do + if BountyTaskInfo.TaskCards[index].Status == XBountyTaskManager.BountyTaskStatus.Complete then + return true + end + end + + return false + end + + --获取任务完成并且领奖的数量 + function XBountyTaskManager.GetBountyTaskCompletedAndAcceptRewardCount() + if not BountyTaskInfo then + return 0 + end + + local taskCount = #BountyTaskInfo.TaskCards + + local completeCount = 0 + + for index = 1, taskCount do + if BountyTaskInfo.TaskCards[index].Status == XBountyTaskManager.BountyTaskStatus.AcceptReward then + completeCount = completeCount + 1 + end + end + + return completeCount + end + + --获取排行奖励表格 + function XBountyTaskManager.GetBountyTaskRankTable() + if not BountyTaskRankConfig then + return nil + end + + local config = {} + for _, value in pairs(BountyTaskRankConfig) do + table.insert(config, value) + end + + table.sort(config, function(a, b) + return b.RankLevel < a.RankLevel + end) + + return config + end + + --获取本地数据 + function XBountyTaskManager.GetBountyTaskConfig(id) + if not BountyTaskConfig then + return + end + + if not BountyTaskConfig[id] then + local tempStr = XBountyTaskConfigs.GetBountyTaskPath() + XLog.ErrorTableDataNotFound("XBountyTaskManager.GetBountyTaskConfig", "LevelUpTemplates", tempStr, "id", tostring(id)) + return + end + + return BountyTaskConfig[id] + end + + --获取随机事件数据 + function XBountyTaskManager.GetBountyTaskRandomEventConfig(eventId) + if not BountyTaskRandomEventConfig then + return + end + + + if not BountyTaskRandomEventConfig[eventId] then + XLog:Debug("Get BountyTaskRandomEventConfig err,eventId not exist " .. tostring(eventId)) + return + end + + return BountyTaskRandomEventConfig[eventId] + end + + + --获取等级数据 + function XBountyTaskManager.GetBountyTaskRankConfig(rankLevel) + if not BountyTaskRankConfig then + return + end + + + if not BountyTaskRankConfig[rankLevel] then + XLog:Debug("Get BountyTaskRankConfig err,rankLevel not exist " .. tostring(rankLevel)) + return + end + + + return BountyTaskRankConfig[rankLevel] + end + + + --获取困难关卡数据 + function XBountyTaskManager.GetBountyTaskDifficultStageConfig(id) + if not BountyTaskDifficultStageConfig then + return + end + + if not BountyTaskDifficultStageConfig[id] then + XLog:Debug("Get BountyTaskDifficultStageConfig err,Id not exist " .. tostring(id)) + return + end + + return BountyTaskDifficultStageConfig[id] + end + + --设置选中索引 + function XBountyTaskManager.SetSelectIndex(index) + SelectIndex = index + end + + --获取选中索引 + function XBountyTaskManager.GetSelectIndex() + return SelectIndex + end + + --获取一个假的任务顺序 + function XBountyTaskManager.GetFakeTaskOrder() + return FakeBountyTaskOrder + end + + --是否是赏金任务完成 + function XBountyTaskManager.CheckBountyTaskHasReward() + if not BountyTaskInfo or not BountyTaskInfo.TaskCards then + return false + end + + for _, task in ipairs(BountyTaskInfo.TaskCards) do + if task.Status == XBountyTaskManager.BountyTaskStatus.Complete then + return true + end + end + + return false + end + + --是否本周第一次进入赏金 + function XBountyTaskManager.IsFirstTimeLoginInWeek() + local lastRefreshTime = XBountyTaskManager.GetBountyTaskLastRefreshTime() + local refreshTime = XBountyTaskManager.GetRefreshTime() + + if lastRefreshTime ~= refreshTime then + return true + end + + return false + end + + + + --是否是赏金前置困难副本 + function XBountyTaskManager.CheckBountyTaskPreFight(stageId) + if not BountyTaskInfo or not BountyTaskInfo.TaskCards then + return false + end + + for _, var in ipairs(BountyTaskInfo.TaskCards) do + if var.DifficultStageId == stageId then + return true, var + end + end + + return false + end + + --是否是赏金前置困难副本,判断状态 + function XBountyTaskManager.CheckBountyTaskPreFightWithStatus(stageId) + local isPreFight, task = XBountyTaskManager.CheckBountyTaskPreFight(stageId) + if task and (task.Status == XBountyTaskManager.BountyTaskStatus.Complete + or task.Status == XBountyTaskManager.BountyTaskStatus.AcceptReward) then + return false + end + return isPreFight, task + end + + --是否是前置关卡 + function XBountyTaskManager.IsBountyPreFight() + return BountyTaskPreFightData ~= nil + end + + --是否是赏金关卡 + function XBountyTaskManager.IsBountyTaskFight() + return BountyTaskFightData ~= nil + end + + --获取赏金关卡数据 + function XBountyTaskManager.GetBountyTaskFightData() + return BountyTaskFightData + end + + --获取赏金刷新时间 + function XBountyTaskManager.GetRefreshTime() + return RefreshTime + end + + --设置上次进入赏金的时间 + function XBountyTaskManager.SetBountyTaskLastLoginTime() + local key = tostring(XPlayer.Id) .. "_LastBountyTaskTime" + CS.UnityEngine.PlayerPrefs.SetInt(key, XTime.GetServerNowTimestamp()) + end + + --获取上次进入赏金的时间 + function XBountyTaskManager.GetBountyTaskLastLoginTime() + local key = tostring(XPlayer.Id) .. "_LastBountyTaskTime" + local lastLoginTime = CS.UnityEngine.PlayerPrefs.GetInt(key, -1) + return lastLoginTime + end + + + --设置上次刷新赏金的时间 + function XBountyTaskManager.SetBountyTaskLastRefreshTime() + local lastRefreshTime = XBountyTaskManager.GetBountyTaskLastRefreshTime() + + if lastRefreshTime == RefreshTime then + return + end + + local key = tostring(XPlayer.Id) .. "_BountyTaskLastRefreshTime" + CS.UnityEngine.PlayerPrefs.SetInt(key, RefreshTime) + + + XEventManager.DispatchEvent(XEventId.EVENT_BOUNTYTASK_INFO_CHANGE_NOTIFY) + + end + + --获取上次刷新赏金的时间 + function XBountyTaskManager.GetBountyTaskLastRefreshTime() + local key = tostring(XPlayer.Id) .. "_BountyTaskLastRefreshTime" + local lastLoginTime = CS.UnityEngine.PlayerPrefs.GetInt(key, -1) + return lastLoginTime + end + + --记录前置关卡战斗 + function XBountyTaskManager.RecordPreFightData(taskId, teamId, isHasAssist, assisPId, assistType) + local bountyTask = XBountyTaskManager.GetBountyTaskConfig(taskId) + if not bountyTask then + return + end + + BountyTaskPreFightData = {} + BountyTaskPreFightData.taskId = taskId + BountyTaskPreFightData.stageId = bountyTask.StageId + BountyTaskPreFightData.teamId = teamId + BountyTaskPreFightData.isHasAssist = isHasAssist + BountyTaskPreFightData.assisPId = assisPId + BountyTaskPreFightData.assistType = assistType + end + + --进入战斗 + function XBountyTaskManager.EnterFight(result) + if not BountyTaskPreFightData then + return + end + + local stage = XDataCenter.FubenManager.GetStageCfg(BountyTaskPreFightData.stageId) + XDataCenter.FubenManager.EnterFight(stage, BountyTaskPreFightData.teamId) + BountyTaskPreFightData = nil + BountyTaskFightData = {} + BountyTaskFightData.PreFightResult = result + end + + --重置战斗数据 + function XBountyTaskManager.ResetFightData() + BountyTaskFightData = nil + BountyTaskPreFightData = nil + end + -------------------------------------------------------------- + --从池中抽取任务 + function XBountyTaskManager.GetTaskCardFromTaskPool(taskId) + if not BountyTaskInfo or not BountyTaskInfo.TaskPool then + return + end + + local index = -1 + local taskCard = nil + for i, var in ipairs(BountyTaskInfo.TaskPool) do + if var.Id == taskId then + taskCard = var + index = i + break + end + end + + if index == -1 or taskCard == nil then + return + end + + return taskCard + end + + --完成任务 + function XBountyTaskManager.FinshedTask(taskId) + if not BountyTaskInfo then + return + end + + for _, var in ipairs(BountyTaskInfo.TaskCards) do + if var.Id == taskId then + var.Status = XBountyTaskManager.BountyTaskStatus.Complete + break + end + end + end + + + --领取奖励 + function XBountyTaskManager.GetBountyTaskReward(resp) + if not BountyTaskInfo then + return + end + + local taskId = resp.TaskId + + for _, var in ipairs(BountyTaskInfo.TaskCards) do + if var.Id == taskId then + var.Status = XBountyTaskManager.BountyTaskStatus.AcceptReward + break + end + end + + if BountyTaskInfo.RankLevel < resp.RankLevel then + BountyTaskInfo.RankLevel = resp.RankLevel + end + + --升级 + XUiManager.OpenUiObtain(resp.RewardGoodsList, CS.XTextManager.GetText("BountyTaskRewardTipTitle"), function() + XEventManager.DispatchEvent(XEventId.EVENT_BOUNTYTASK_ACCEPT_TASK_REWARD) + end) + end + + ----协议---------------------------------------------------------------------- + --请求接受任务 + function XBountyTaskManager.AcceptBountyTask(taskId, cb) + XNetwork.Call(BountyTaskRequest.AcceptBountyTaskRequest, { TaskId = taskId }, function(resp) + if resp.Code ~= XCode.Success then + XUiManager.TipCode(resp.Code) + return + end + + if not BountyTaskInfo then + return + end + + if SelectIndex > 0 then + FakeBountyTaskOrder[taskId] = SelectIndex; + end + + local taskCard = XBountyTaskManager.GetTaskCardFromTaskPool(taskId) + if taskCard then + table.insert(BountyTaskInfo.TaskCards, taskCard) + end + + BountyTaskInfo.TaskPool = resp.TaskPool + -- XUiManager.TipMsg(CS.XTextManager.GetText("BountyTaskAccetpTaskSuccess")) + if cb then + cb() + end + + XEventManager.DispatchEvent(XEventId.EVENT_BOUNTYTASK_ACCEPT_TASK) + end) + end + + --请求领取奖励 + function XBountyTaskManager.AcceptBountyTaskReward(taskId, cb) + XNetwork.Call(BountyTaskRequest.AcceptBountyTaskRewardRequest, { TaskId = taskId }, function(resp) + if resp.Code ~= XCode.Success then + XUiManager.TipCode(resp.Code) + return + end + + if not BountyTaskInfo then + return + end + + XBountyTaskManager.GetBountyTaskReward(resp) + + if cb then + cb() + end + + end) + end + + --刷新任务池 + function XBountyTaskManager.RefreshBountyTaskPool(cb) + XNetwork.Call(BountyTaskRequest.RefreshBountyTaskPoolRequest, nil, function(resp) + if resp.Code ~= XCode.Success then + XUiManager.TipCode(resp.Code) + return + end + + if not BountyTaskInfo then + return + end + + BountyTaskInfo.TaskPoolRefreshCount = resp.TaskPoolRefreshCount + BountyTaskInfo.TaskPool = resp.TaskPool + + if cb then + cb() + end + + XEventManager.DispatchEvent(XEventId.EVENT_BOUNTYTASK_TASK_REFRESH) + end) + end + + --通知任务信息改变 + function XBountyTaskManager.NotifyBountyTaskInfo(data) + BountyTaskInfo = data.TaskInfo + RefreshTime = data.RefreshTime + FakeBountyTaskOrder = {} + SelectIndex = -1 + XEventManager.DispatchEvent(XEventId.EVENT_BOUNTYTASK_INFO_CHANGE_NOTIFY) + end + + --推送任务完成 + function XBountyTaskManager.NotifyBountyTaskComplete(data) + XBountyTaskManager.FinshedTask(data.TaskId) + XEventManager.DispatchEvent(XEventId.EVENT_BOUNTYTASK_TASK_COMPLETE_NOTIFY) + end + -------------------------------------------------------------------------- + function XBountyTaskManager.CheckReadyToFight() + return not XBountyTaskManager.IsBountyTaskFight() + end + + function XBountyTaskManager.FinishFight() + local preSettle = XBountyTaskManager.GetBountyTaskFightData().PreFightResult + XDataCenter.FubenManager.ChallengeWin(preSettle) + XBountyTaskManager.ResetFightData() + end + + --打开加载界面 + function XBountyTaskManager.OpenFightLoading(stageId) + XLuaUiManager.Remove("UiMoneyRewardFightTipFind") + + XLuaUiManager.Open("UiMoneyRewardFightTips", stageId) + end + + function XBountyTaskManager.CloseFightLoading() + XLuaUiManager.Remove("UiMoneyRewardFightTips") + end + + --初始化关卡数据 + function XBountyTaskManager.InitStageInfo() + for id, v in pairs(BountyTaskConfig) do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(v.StageId) + stageInfo.BountyId = id + stageInfo.Type = XDataCenter.FubenManager.StageType.BountyTask + end + end + + XBountyTaskManager.Init() + return XBountyTaskManager +end + +XRpc.NotifyBountyTaskInfo = function(data) + XDataCenter.BountyTaskManager.NotifyBountyTaskInfo(data) +end + +XRpc.NotifyBountyTaskComplete = function(data) + XDataCenter.BountyTaskManager.NotifyBountyTaskComplete(data) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XCdKeyManager.lua b/Resources/Scripts/XManager/XCdKeyManager.lua new file mode 100644 index 00000000..79dbfb05 --- /dev/null +++ b/Resources/Scripts/XManager/XCdKeyManager.lua @@ -0,0 +1,25 @@ +XCdKeyManagerCreator = function() + local XCdKeyManager = {} + + local XCdKeyRequest = { + UseCdKeyRequest = "UseCdKeyRequest" + } + + function XCdKeyManager.UseCdKeyRequest(id) + if not id or id == "" then + XUiManager.TipText("CdKeyIsEmpty") + return + end + + XNetwork.Call(XCdKeyRequest.UseCdKeyRequest, {Id = id}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + XUiManager.OpenUiObtain(res.RewardGoods) + end) + end + + return XCdKeyManager +end diff --git a/Resources/Scripts/XManager/XCharacterManager.lua b/Resources/Scripts/XManager/XCharacterManager.lua new file mode 100644 index 00000000..859904ec --- /dev/null +++ b/Resources/Scripts/XManager/XCharacterManager.lua @@ -0,0 +1,1650 @@ +XCharacterManagerCreator = function() + + local type = type + local pairs = pairs + + local table = table + local tableSort = table.sort + local tableInsert = table.insert + local mathMin = math.min + local mathMax = math.max + local stringFormat = string.format + local CsXTextManagerGetText = CsXTextManagerGetText + + local XCharacterManager = {} + + -- service config begin -- + local METHOD_NAME = { + LevelUp = "CharacterLevelUpRequest", + ActivateStar = "CharacterActivateStarRequest", + PromoteQuality = "CharacterPromoteQualityRequest", + PromoteGrade = "CharacterPromoteGradeRequest", + ExchangeCharacter = "CharacterExchangeRequest", + UnlockSubSkill = "CharacterUnlockSkillGroupRequest", + UpgradeSubSkill = "CharacterUpgradeSkillGroupRequest", + SwitchSkill = "CharacterSwitchSkillRequest", + } + -- service config end -- + local OwnCharacters = {} -- 已拥有角色数据 + setmetatable(OwnCharacters, { + __index = function(_, k, v) + if XCharacterConfigs.IsCharacterInShowTime(k) then + return v + end + end, + + __pairs = function(t) + return function(t, k) + local nk, nv = next(t, k) + if nk then + if XCharacterConfigs.IsCharacterInShowTime(nk) then + return nk, nv + else + return nk, nil + end + end + end, t, nil + end + }) + + function XCharacterManager.NewCharacter(character) + if character == nil or character.Id == nil then + XLog.Error("XCharacterManager.NewCharacter函数参数不能为空或者参数的Id字段不能为空") + return + end + return XCharacter.New(character) + end + + function XCharacterManager.InitCharacters(characters) + for _, character in pairs(characters) do + OwnCharacters[character.Id] = XCharacterManager.NewCharacter(character) + end + end + + function XCharacterManager.GetCharacter(id) + return OwnCharacters[id] + end + + function XCharacterManager.IsOwnCharacter(characterId) + return OwnCharacters[characterId] ~= nil + end + + local DefaultSort = function(a, b) + if a.Level ~= b.Level then + return a.Level > b.Level + end + + if a.Quality ~= b.Quality then + return a.Quality > b.Quality + end + + local priorityA = XCharacterConfigs.GetCharacterPriority(a.Id) + local priorityB = XCharacterConfigs.GetCharacterPriority(b.Id) + + if priorityA ~= priorityB then + return priorityA < priorityB + end + + return a.Id > b.Id + end + + --==============================-- + --desc: 获取卡牌列表(获得) + --@return 卡牌列表 + --==============================-- + function XCharacterManager.GetCharacterList(characterType, isUseTempSelectTag, isAscendOrder, isUseNewSort) + local characterList = {} + + local isNeedIsomer + if characterType then + if characterType == XCharacterConfigs.CharacterType.Normal then + isNeedIsomer = false + elseif characterType == XCharacterConfigs.CharacterType.Isomer then + isNeedIsomer = true + end + end + + local unOwnCharList = {} + for k, v in pairs(XCharacterConfigs.GetCharacterTemplates()) do + if not isUseNewSort or XDataCenter.RoomCharFilterTipsManager.IsFilterSelectTag(k, characterType, isUseTempSelectTag) then + if OwnCharacters[k] then + if isNeedIsomer == nil then + tableInsert(characterList, OwnCharacters[k]) + elseif isNeedIsomer and XCharacterConfigs.IsIsomer(k) then + tableInsert(characterList, OwnCharacters[k]) + elseif isNeedIsomer == false and not XCharacterConfigs.IsIsomer(k) then + tableInsert(characterList, OwnCharacters[k]) + end + else + if isNeedIsomer == nil then + tableInsert(unOwnCharList, v) + elseif isNeedIsomer and XCharacterConfigs.IsIsomer(k) then + tableInsert(unOwnCharList, v) + elseif isNeedIsomer == false and not XCharacterConfigs.IsIsomer(k) then + tableInsert(unOwnCharList, v) + end + end + end + end + + tableSort(characterList, function(a, b) + local isInteamA = XDataCenter.TeamManager.CheckInTeam(a.Id) + local isInteamB = XDataCenter.TeamManager.CheckInTeam(b.Id) + + if isInteamA ~= isInteamB then + return isInteamA + end + + if isUseNewSort then + return XDataCenter.RoomCharFilterTipsManager.GetSort(a.Id, b.Id, characterType, isAscendOrder) + end + return DefaultSort(a, b) + end) + + tableSort(unOwnCharList, function(a, b) + if isUseNewSort then + return XDataCenter.RoomCharFilterTipsManager.GetSort(a.Id, b.Id, characterType, isAscendOrder) + end + return DefaultSort(a, b) + end) + + -- 合并列表 + for _, char in pairs(unOwnCharList) do + tableInsert(characterList, char) + end + + return characterList + end + + function XCharacterManager.GetOwnCharacterList(characterType, isUseNewSort) + local characterList = {} + + local isNeedIsomer + if characterType then + if characterType == XCharacterConfigs.CharacterType.Normal then + isNeedIsomer = false + elseif characterType == XCharacterConfigs.CharacterType.Isomer then + isNeedIsomer = true + end + end + + for characterId, v in pairs(OwnCharacters) do + if not isUseNewSort or XDataCenter.RoomCharFilterTipsManager.IsFilterSelectTag(characterId, characterType) then + if isNeedIsomer == nil then + tableInsert(characterList, v) + elseif isNeedIsomer and XCharacterConfigs.IsIsomer(characterId) then + tableInsert(characterList, v) + elseif isNeedIsomer == false and not XCharacterConfigs.IsIsomer(characterId) then + tableInsert(characterList, v) + end + end + end + + tableSort(characterList, function(a, b) + if isUseNewSort then + return XDataCenter.RoomCharFilterTipsManager.GetSort(a.Id, b.Id, characterType) + end + return DefaultSort(a, b) + end) + + return characterList + end + + function XCharacterManager.GetCharacterCountByAbility(ability) + local count = 0 + for _, v in pairs(OwnCharacters) do + local curAbility = XCharacterManager.GetCharacterAbility(v) + if curAbility and curAbility >= ability then + count = count + 1 + end + end + + return count + end + + + --队伍预设列表排序特殊处理 + function XCharacterManager.GetSpecilOwnCharacterList() + local characterList = {} + for _, v in pairs(OwnCharacters) do + tableInsert(characterList, v) + end + + tableSort(characterList, function(a, b) + return DefaultSort(a, b) + end) + + local specilList = {} + + for k, v in pairs(characterList) do + if k % 2 ~= 0 then + tableInsert(specilList, v) + end + end + + for k, v in pairs(characterList) do + if k % 2 == 0 then + tableInsert(specilList, v) + end + end + + return specilList + end + + function XCharacterManager.GetCharacterListInTeam(characterType) + local characterList = XCharacterManager.GetOwnCharacterList(characterType) + + tableSort(characterList, function(a, b) + local isInteamA = XDataCenter.TeamManager.CheckInTeam(a.Id) + local isInteamB = XDataCenter.TeamManager.CheckInTeam(b.Id) + + if isInteamA ~= isInteamB then + return isInteamA + end + + return DefaultSort(a, b) + end) + + return characterList + end + + function XCharacterManager.GetCharacterIdListInTeam(characterType) + local characterList = XCharacterManager.GetOwnCharacterList(characterType) + local idList = {} + tableSort(characterList, function(a, b) + local isInteamA = XDataCenter.TeamManager.CheckInTeam(a.Id) + local isInteamB = XDataCenter.TeamManager.CheckInTeam(b.Id) + + if isInteamA ~= isInteamB then + return isInteamA + end + + return DefaultSort(a, b) + end) + + for _, char in pairs(characterList) do + table.insert(idList, char.Id) + end + return idList + end + + function XCharacterManager.GetAssignCharacterListInTeam(characterType, tmpTeamIdDic) + local characterList = XCharacterManager.GetOwnCharacterList(characterType) + + tableSort(characterList, function(a, b) + local isInteamA = tmpTeamIdDic[a.Id] + local isInteamB = tmpTeamIdDic[b.Id] + + if isInteamA ~= isInteamB then + return isInteamB + end + return DefaultSort(a, b) + end) + return characterList + end + + function XCharacterManager.GetRobotAndCharacterIdList(robotIdList, characterType) + local characterList = XCharacterManager.GetOwnCharacterList(characterType) + local idList = XRobotManager.GetRobotIdFilterListByCharacterType(robotIdList, characterType) + for _, char in pairs(characterList) do + table.insert(idList, char.Id) + end + return idList + end + + function XCharacterManager.GetRobotCorrespondCharacterIdList(robotIdList) + local ownCharacterIdList = {} + local charId + for _, robotId in ipairs(robotIdList) do + charId = XRobotManager.GetCharacterId(robotId) + if XCharacterManager.IsOwnCharacter(charId) then + table.insert(ownCharacterIdList, charId) + end + end + return ownCharacterIdList + end + + function XCharacterManager.GetRobotAndCorrespondCharacterIdList(robotIdList, characterType) + robotIdList = XRobotManager.GetRobotIdFilterListByCharacterType(robotIdList, characterType) + local characterList = XCharacterManager.GetRobotCorrespondCharacterIdList(robotIdList) + local idList = XRobotManager.GetRobotIdFilterListByCharacterType(robotIdList, characterType) + for _, charId in pairs(characterList) do + table.insert(idList, charId) + end + return idList + end + + function XCharacterManager.IsUseItemEnough(itemIds, itemCounts) + if not itemIds then + return true + end + + if type(itemIds) == "number" then + if type(itemCounts) == "table" then + itemCounts = itemCounts[1] + end + + return XDataCenter.ItemManager.CheckItemCountById(itemIds, itemCounts) + end + + itemCounts = itemCounts or {} + for i = 1, #itemIds do + local key = itemIds[i] + local count = itemCounts[i] or 0 + + if not XDataCenter.ItemManager.CheckItemCountById(key, count) then + return false + end + end + + return true + end + + function XCharacterManager.AddCharacter(charData) + local character = XCharacterManager.NewCharacter(charData) + OwnCharacters[character.Id] = character + XEventManager.DispatchEvent(XEventId.EVENT_CHARACTER_ADD_SYNC, character) + return character + end + + local function GetAttribGroupIdList(character) + local npcTemplate = XCharacterConfigs.GetNpcTemplate(character.NpcId) + if not npcTemplate then + return + end + + return XDataCenter.BaseEquipManager.GetAttribGroupIdListByType(npcTemplate.Type) + end + + function XCharacterManager.GetSkillPlus(character) + local list = XDataCenter.FubenAssignManager.GetSkillPlusIdList() + + if not list then + return + end + + local skillPlus = {} + for _, plusId in pairs(list) do + local plusList = XCharacterConfigs.GetSkillPlusList(character.Id, character.Type, plusId) + if plusList then + for _, skillId in pairs(plusList) do + local level = character:GetSkillLevelBySkillId(skillId) + if level and level > 0 then + if skillPlus[skillId] then + skillPlus[skillId] = skillPlus[skillId] + 1 + else + skillPlus[skillId] = 1 + end + end + end + end + end + + return skillPlus + end + + function XCharacterManager.GetSkillPlusOther(character, assignChapterRecords) + local list = XDataCenter.FubenAssignManager.GetSkillPlusIdListOther(assignChapterRecords) + if not list then + return + end + local skillPlus = {} + for _, plusId in pairs(list) do + local plusList = XCharacterConfigs.GetSkillPlusList(character.Id, character.Type, plusId) + if plusList then + for _, skillId in pairs(plusList) do + local level = character:GetSkillLevelBySkillId(skillId) + if level and level > 0 then + if skillPlus[skillId] then + skillPlus[skillId] = skillPlus[skillId] + 1 + else + skillPlus[skillId] = 1 + end + end + end + end + end + + return skillPlus + end + + function XCharacterManager.GetFightNpcData(characterId) + local character = characterId + + if type(characterId) == "number" then + character = XCharacterManager.GetCharacter(characterId) + if not character then + return + end + end + + local equipDataList = XDataCenter.EquipManager.GetCharacterWearingEquips(character.Id) + if not equipDataList then + return + end + + local groupIdList = GetAttribGroupIdList(character) + if not groupIdList then + return + end + + return { + Character = character, + Equips = equipDataList, + AttribGroupList = groupIdList, --基地装备用(已废弃) + CharacterSkillPlus = XCharacterManager.GetSkillPlus(character) + } + end + + function XCharacterManager.GetFightNpcDataOther(character, equipList, assignChapterRecords) + local equipDataList = equipList + if not equipDataList then + return + end + + local groupIdList = GetAttribGroupIdList(character) + if not groupIdList then + return + end + + return { + Character = character, + Equips = equipDataList, + AttribGroupList = groupIdList, + CharacterSkillPlus = XCharacterManager.GetSkillPlusOther(character, assignChapterRecords) + } + end + + + function XCharacterManager.GetCharacterAttribs(character) + local npcData = XCharacterManager.GetFightNpcData(character) + if not npcData then + return + end + + return XAttribManager.GetNpcAttribs(npcData) + end + + function XCharacterManager.GetCharacterAttribsOther(character, equipList, assignChapterRecords) + local npcData = XCharacterManager.GetFightNpcDataOther(character, equipList, assignChapterRecords) + if not npcData then + return + end + + return XAttribManager.GetNpcAttribs(npcData) + end + + local function GetSkillAbility(skillList) + local ability = 0 + for id, level in pairs(skillList) do + ability = ability + XCharacterConfigs.GetSubSkillAbility(id, level) + end + return ability + end + + local function GetResonanceSkillAbility(skillList, useSkillMap) + if not skillList then + return 0 + end + + if not useSkillMap then + return 0 + end + + local ability = 0 + for id, level in pairs(skillList) do + if useSkillMap[id] then + ability = ability + XCharacterConfigs.GetResonanceSkillAbility(id, level) + end + end + return ability + end + XCharacterManager.GetResonanceSkillAbility = GetResonanceSkillAbility + + local function GetPlusSkillAbility(skillList, useSkillMap) + if not skillList then + return 0 + end + + if not useSkillMap then + return 0 + end + + local ability = 0 + for id, level in pairs(skillList) do + if useSkillMap[id] then + ability = ability + XCharacterConfigs.GetPlusSkillAbility(id, level) + end + end + + return ability + end + + function XCharacterManager.GetCharacterAbility(character) + local npcData = XCharacterManager.GetFightNpcData(character) + if not npcData then + return 0 + end + + --属性战力 + local baseAbility = XAttribManager.GetAttribAbility(character.Attribs) or 0 + + --技能战力 + local skillLevel = XFightCharacterManager.GetCharSkillLevelMap(npcData) + local skillAbility = GetSkillAbility(skillLevel) + + --装备共鸣战力 + local resonanceSkillLevel = XFightCharacterManager.GetResonanceSkillLevelMap(npcData) + local resonanceSkillAbility = GetResonanceSkillAbility(resonanceSkillLevel, skillLevel) + + --边界公约驻守增加技能等级战力 + local plusSkillAbility = GetPlusSkillAbility(npcData.CharacterSkillPlus, skillLevel) + + --装备技能战力 + local equipAbility = XDataCenter.EquipManager.GetEquipSkillAbility(character.Id) or 0 + + --伙伴战力 + local partnerAbility = XDataCenter.PartnerManager.GetCarryPartnerAbilityByCarrierId(character.Id) + + return baseAbility + skillAbility + resonanceSkillAbility + plusSkillAbility + equipAbility + partnerAbility + end + + -- partner : XPartner + function XCharacterManager.GetCharacterAbilityOther(character, equipList, assignChapterRecords, partner) + local npcData = XCharacterManager.GetFightNpcDataOther(character, equipList, assignChapterRecords) + if not npcData then + return + end + + local attribs = XCharacterManager.GetCharacterAttribsOther(character, equipList, assignChapterRecords) + local baseAbility = XAttribManager.GetAttribAbility(attribs) + if not baseAbility then + return + end + + local skillLevel = XFightCharacterManager.GetCharSkillLevelMap(npcData) + local skillAbility = GetSkillAbility(skillLevel) + + local resonanceSkillLevel = XFightCharacterManager.GetResonanceSkillLevelMap(npcData) + local resonanceSkillAbility = GetResonanceSkillAbility(resonanceSkillLevel, skillLevel) + + local plusSkillAbility = GetPlusSkillAbility(npcData.CharacterSkillPlus, skillLevel) + + local equipAbility = XDataCenter.EquipManager.GetEquipSkillAbilityOther(character, equipList) + if not equipAbility then + return + end + -- 宠物战力 + local partnerAbility = XDataCenter.PartnerManager.GetCarryPartnerAbility(partner) + return baseAbility + skillAbility + resonanceSkillAbility + plusSkillAbility + equipAbility + partnerAbility + end + + -- 根据id获得身上角色战力 + function XCharacterManager.GetCharacterAbilityById(characterId) + local character = OwnCharacters[characterId] + return character and XCharacterManager.GetCharacterAbility(character) or 0 + end + + function XCharacterManager.GetMaxOwnCharacterAbility() + local maxAbility = 0 + + for _, character in pairs(OwnCharacters) do + local ability = XCharacterManager.GetCharacterAbility(character) + maxAbility = mathMax(ability, maxAbility) + end + + return maxAbility + end + + function XCharacterManager.GetNpcBaseAttrib(npcId) + local npcTemplate = CS.XNpcManager.GetNpcTemplate(npcId) + if not npcTemplate then + XLog.ErrorTableDataNotFound("XCharacterManager.GetNpcBaseAttrib", "npcTemplate", "Client/Fight/Npc/Npc.tab", "npcId", tostring(npcId)) + return + end + return XAttribManager.GetBaseAttribs(npcTemplate.AttribId) + end + + -- 升级相关begin -- + function XCharacterManager.IsOverLevel(templateId) + local curLevel = XPlayer.Level + local char = XCharacterManager.GetCharacter(templateId) + return char and char.Level >= curLevel + end + + function XCharacterManager.IsMaxLevel(templateId) + local char = XCharacterManager.GetCharacter(templateId) + local maxLevel = XCharacterConfigs.GetCharMaxLevel(templateId) + return char and char.Level >= maxLevel + end + + function XCharacterManager.CalLevelAndExp(character, exp) + local teamLevel = XPlayer.Level + local id = character.Id + local curExp = character.Exp + exp + local curLevel = character.Level + + local maxLevel = XCharacterConfigs.GetCharMaxLevel(id) + + while curLevel do + local nextLevelExp = XCharacterConfigs.GetNextLevelExp(id, curLevel) + if ((curExp >= nextLevelExp) and (curLevel < teamLevel)) then + if curLevel == maxLevel then + curExp = nextLevelExp + break + else + curExp = curExp - nextLevelExp + curLevel = curLevel + 1 + if (curLevel >= teamLevel) then + break + end + end + else + break + end + end + return curLevel, curExp + end + + function XCharacterManager.GetMaxAvailableLevel(templateId) + if not templateId then + return + end + + local charMaxLevel = XCharacterConfigs.GetCharMaxLevel(templateId) + local playerMaxLevel = XPlayer.Level + + return mathMin(charMaxLevel, playerMaxLevel) + end + + function XCharacterManager.GetMaxLevelNeedExp(character) + local id = character.Id + local levelUpTemplateId = XCharacterConfigs.GetCharacterTemplate(id).LevelUpTemplateId + local levelUpTemplate = XCharacterConfigs.GetLevelUpTemplate(levelUpTemplateId) + local maxLevel = XCharacterConfigs.GetCharMaxLevel(id) + local totalExp = 0 + for i = character.Level, maxLevel - 1 do + totalExp = totalExp + levelUpTemplate[i].Exp + end + + return totalExp - character.Exp + end + -- 升级相关end -- + -- 品质相关begin -- + function XCharacterManager.IsMaxQuality(character) + if not character then + XLog.Error("XCharacterManager.IsMaxQuality函数参数character不能为空") + return + end + + return character.Quality >= XCharacterConfigs.GetCharMaxQuality(character.Id) + end + + function XCharacterManager.IsMaxQualityById(characterId) + if not characterId then + return + end + + local character = XCharacterManager.GetCharacter(characterId) + return character and character.Quality >= XCharacterConfigs.GetCharMaxQuality(character.Id) + end + + function XCharacterManager.IsCanActivateStar(character) + if not character then + XLog.Error("XCharacterManager.IsCanActivateStar函数参数character不能为空") + return + end + + if character.Quality >= XCharacterConfigs.GetCharMaxQuality(character.Id) then + return false + end + + if character.Star >= XCharacterConfigs.MAX_QUALITY_STAR then + return false + end + + return true + end + + function XCharacterManager.IsActivateStarUseItemEnough(templateId, quality, star) + if not templateId or not quality or not star then + local tmpStr = "XCharacterManager.IsCharQualityStarUseItemEnough函数参数错误:, 参数templateId是" + XLog.Error(tmpStr .. templateId .. " 参数quality是" .. quality .. " 参数star是" .. star) + return + end + + local template = XCharacterConfigs.GetCharacterTemplate(templateId) + if not template then + XLog.ErrorTableDataNotFound("XCharacterManager.IsCharQualityStarUseItemEnough", + "template", "Share/Character/Character.tab", "templateId", tostring(templateId)) + return + end + + if quality < 1 then + XLog.Error("XCharacterManager.IsCharQualityStarUseItemEnough错误: 参数quality不能小于1, 参数quality是: " .. quality) + return + end + + if star < 1 or star > XCharacterConfigs.MAX_QUALITY_STAR then + local tmpStr = "XCharacterManager.IsCharQualityStarUseItemEnough函数错误: 参数star不能小于1或者大于" + XLog.Error(tmpStr .. XCharacterConfigs.MAX_QUALITY_STAR .. ", 参数star是: " .. star) + return + end + + local itemKey = template.ItemId + local characterType = XCharacterConfigs.GetCharacterType(templateId) + local itemCount = XCharacterConfigs.GetStarUseCount(characterType, quality, star) + + return XCharacterManager.IsUseItemEnough(itemKey, itemCount) + end + + function XCharacterManager.IsCanPromoted(characterId) + local character = XCharacterManager.GetCharacter(characterId) + local hasCoin = XDataCenter.ItemManager.GetCoinsNum() + local characterType = XCharacterConfigs.GetCharacterType(characterId) + local useCoin = XCharacterConfigs.GetPromoteUseCoin(characterType, character.Quality) + + return hasCoin >= useCoin + end + + --得到角色需要展示的 fashionId + function XCharacterManager.GetShowFashionId(templateId, isNotSelf) + -- 默认优先拿自己的数据 + if isNotSelf == nil then isNotSelf = false end + -- 不属于自身数据的直接获取本地即可 + if isNotSelf then + return XCharacterConfigs.GetCharacterTemplate(templateId).DefaultNpcFashtionId + end + if XCharacterManager.IsOwnCharacter(templateId) == true then + return OwnCharacters[templateId].FashionId + else + return XCharacterConfigs.GetCharacterTemplate(templateId).DefaultNpcFashtionId + end + end + + function XCharacterManager.GetCharHalfBodyBigImage(templateId) --获得角色半身像(剧情用) + local fashionId = XCharacterManager.GetShowFashionId(templateId) + + if fashionId == nil then + XLog.ErrorTableDataNotFound("XCharacterManager.GetCharHalfBodyBigImage", + "DefaultNpcFashtionId", "Share/Character/Character.tab", "templateId", tostring(templateId)) + return + end + + return XDataCenter.FashionManager.GetFashionHalfBodyImage(fashionId) + end + + function XCharacterManager.GetCharHalfBodyImage(templateId) --获得角色半身像(通用) + local fashionId = XCharacterManager.GetShowFashionId(templateId) + + if fashionId == nil then + XLog.ErrorTableDataNotFound("XCharacterManager.GetCharHalfBodyImage", + "DefaultNpcFashtionId", "Share/Character/Character.tab", "templateId", tostring(templateId)) + return + end + + return XDataCenter.FashionManager.GetRoleCharacterBigImage(fashionId) + end + + function XCharacterManager.GetCharSmallHeadIcon(templateId, liberateLv, IsNotSelf, customFashionId) --获得角色小头像列表 + local fashionId = customFashionId or XCharacterManager.GetShowFashionId(templateId, IsNotSelf) + + if fashionId == nil then + XLog.ErrorTableDataNotFound("XCharacterManager.GetShowFashionId", + "DefaultNpcFashtionId", "Share/Character/Character.tab", "templateId", tostring(templateId)) + return + end + + local isAchieveMaxLiberation = not liberateLv and + XDataCenter.ExhibitionManager.IsAchieveMaxLiberation(templateId, IsNotSelf) or + XDataCenter.ExhibitionManager.IsMaxLiberationLevel(liberateLv) + + local result = isAchieveMaxLiberation and XDataCenter.FashionManager.GetFashionSmallHeadIconLiberation(fashionId) or + XDataCenter.FashionManager.GetFashionSmallHeadIcon(fashionId) + + return result + end + + -- 获取角色初始时装的初始头像 + function XCharacterManager.GetDefaultCharSmallHeadIcon(templateId) + local fashionId = XCharacterConfigs.GetCharacterTemplate(templateId).DefaultNpcFashtionId + + if fashionId == nil then + XLog.Error("XCharacterManager.GetDefaultCharSmallHeadIcon函数错误,fashionId为空") + return + end + + return XDataCenter.FashionManager.GetFashionSmallHeadIcon(fashionId) + end + + function XCharacterManager.GetCharSmallHeadIconByCharacter(character) + local fashionId = character.FashionId + local isAchieveMaxLiberation = XDataCenter.ExhibitionManager.IsMaxLiberationLevel(character.LiberateLv) + if isAchieveMaxLiberation then + return XDataCenter.FashionManager.GetFashionSmallHeadIconLiberation(fashionId) + else + return XDataCenter.FashionManager.GetFashionSmallHeadIcon(fashionId) + end + end + + function XCharacterManager.GetCharBigHeadIcon(templateId, liberateLv, isNotSelf, customFashionId) --获得角色大头像 + local fashionId = customFashionId or XCharacterManager.GetShowFashionId(templateId, isNotSelf) + + if fashionId == nil then + XLog.ErrorTableDataNotFound("XCharacterManager.GetCharBigHeadIcon", + "DefaultNpcFashtionId", "Share/Character/Character.tab", "templateId", tostring(templateId)) + return + end + + local isAchieveMaxLiberation = not liberateLv and + XDataCenter.ExhibitionManager.IsAchieveMaxLiberation(templateId, isNotSelf) or + XDataCenter.ExhibitionManager.IsMaxLiberationLevel(liberateLv) + + local result = isAchieveMaxLiberation and XDataCenter.FashionManager.GetFashionBigHeadIconLiberation(fashionId) or + XDataCenter.FashionManager.GetFashionBigHeadIcon(fashionId) + + return result + end + + function XCharacterManager.GetCharRoundnessHeadIcon(templateId) --获得角色圆头像 + local fashionId = XCharacterManager.GetShowFashionId(templateId) + + if fashionId == nil then + XLog.ErrorTableDataNotFound("XCharacterManager.GetCharRoundnessHeadIcon", + "DefaultNpcFashtionId", "Share/Character/Character.tab", "templateId", tostring(templateId)) + return + end + + return XDataCenter.FashionManager.GetFashionRoundnessHeadIcon(fashionId) + end + + function XCharacterManager.GetCharBigRoundnessHeadIcon(templateId) --获得角色大圆头像 + local fashionId = XCharacterManager.GetShowFashionId(templateId) + + if fashionId == nil then + XLog.ErrorTableDataNotFound("XCharacterManager.GetCharBigRoundnessHeadIcon", + "DefaultNpcFashtionId", "Share/Character/Character.tab", "templateId", tostring(templateId)) + return + end + + return XDataCenter.FashionManager.GetFashionBigRoundnessHeadIcon(fashionId) + end + + function XCharacterManager.GetCharBigRoundnessNotItemHeadIcon(templateId, liberateLv) --获得角色圆头像(非物品使用) + local fashionId = XCharacterManager.GetShowFashionId(templateId) + + if fashionId == nil then + XLog.ErrorTableDataNotFound("XCharacterManager.GetCharBigRoundnessNotItemHeadIcon", + "DefaultNpcFashtionId", "Share/Character/Character.tab", "templateId", tostring(templateId)) + return + end + + local isAchieveMaxLiberation = not liberateLv and XDataCenter.ExhibitionManager.IsAchieveMaxLiberation(templateId) or + XDataCenter.ExhibitionManager.IsMaxLiberationLevel(liberateLv) + local result = isAchieveMaxLiberation and XDataCenter.FashionManager.GetFashionRoundnessNotItemHeadIconLiberation(fashionId) or + XDataCenter.FashionManager.GetFashionRoundnessNotItemHeadIcon(fashionId) + return result + end + + function XCharacterManager.GetFightCharHeadIcon(character) --获得战斗角色头像 + local fashionId = character.FashionId + local isAchieveMaxLiberation = XDataCenter.ExhibitionManager.IsMaxLiberationLevel(character.LiberateLv) + if isAchieveMaxLiberation then + return XDataCenter.FashionManager.GetFashionRoundnessNotItemHeadIconLiberation(fashionId) + else + return XDataCenter.FashionManager.GetFashionRoundnessNotItemHeadIcon(fashionId) + end + end + + function XCharacterManager.GetCharUnlockFragment(templateId) + if not templateId then + XLog.Error("XCharacterManager.GetCharUnlockFragment函数参数错误, 参数templateId不能为空") + return + end + + local curCharItemId = XCharacterConfigs.GetCharacterTemplate(templateId).ItemId + if not curCharItemId then + XLog.ErrorTableDataNotFound("XCharacterManager.GetCharUnlockFragment", + "curCharItemId", "Share/Character/Character.tab", "templateId", tostring(templateId)) + return + end + + local item = XDataCenter.ItemManager.GetItem(curCharItemId) + + if not item then + return 0 + end + + return item.Count + end + + function XCharacterManager.GetCharShowFashionSceneUrl(templateId) --获取角色需要显示时装所关联的场景路径 + if not templateId then + XLog.Error("XCharacterManager.GetCharShowFashionSceneUrl函数参数错误, 参数templateId不能为空") + return + end + + local fashionId = XCharacterManager.GetShowFashionId(templateId) + if not fashionId then + XLog.Error("XCharacterManager.GetCharShowFashionSceneUrl函数参数错误, 获取fashionId失败") + return + end + + local sceneUrl = XDataCenter.FashionManager.GetFashionSceneUrl(fashionId) + return sceneUrl + end + + -- 品质相关end -- + -- 改造相关begin -- + function XCharacterManager.IsMaxCharGrade(character) + return character.Grade >= XCharacterConfigs.GetCharMaxGrade(character.Id) + end + + function XCharacterManager.IsPromoteGradeUseItemEnough(templateId, grade) + if not templateId or not grade then + XLog.Error("XCharacterManager.IsPromoteGradeUseItemEnough参数不能为空: 参数templateId是 " .. templateId .. " 参数grade是" .. grade) + return + end + + local gradeConfig = XCharacterConfigs.GetGradeTemplates(templateId, grade) + if not gradeConfig then + XLog.ErrorTableDataNotFound("XCharacterManager.IsPromoteGradeUseItemEnough", + "gradeConfig", "Share/Character/Grade/CharacterGrade.tab", "grade", tostring(grade)) + return + end + + local itemKey, itemCount = gradeConfig.UseItemKey, gradeConfig.UseItemCount + if not itemKey then + return true + end + + return XCharacterManager.IsUseItemEnough(itemKey, itemCount) + end + + function XCharacterManager.CheckCanUpdateSkill(charId, subSkillId, subSkillLevel) + local char = XCharacterManager.GetCharacter(charId) + if (char == nil) then + return false + end + + local min_max = XCharacterConfigs.GetSubSkillMinMaxLevel(subSkillId) + if (subSkillLevel >= min_max.Max) then + return false + end + + local gradeConfig = XCharacterConfigs.GetSkillGradeConfig(subSkillId, subSkillLevel) + if not gradeConfig then return false end + + if gradeConfig.ConditionId then + for _, v in pairs(gradeConfig.ConditionId) do + if not XConditionManager.CheckCondition(v, charId) then + return false + end + end + end + + if (not XCharacterManager.IsUseItemEnough(XDataCenter.ItemManager.ItemId.SkillPoint, gradeConfig.UseSkillPoint)) then + return false + end + + if (not XCharacterManager.IsUseItemEnough(XDataCenter.ItemManager.ItemId.Coin, gradeConfig.UseCoin)) then + return false + end + + return true + end + + --得到人物技能共鸣等级 + function XCharacterManager.GetResonanceSkillLevel(characterId, skillId) + if not characterId or characterId == 0 then return 0 end + if not XCharacterManager.IsOwnCharacter(characterId) then return 0 end + local npcData = {} + npcData.Character = XCharacterManager.GetCharacter(characterId) + npcData.Equips = XDataCenter.EquipManager.GetCharacterWearingEquips(characterId) + local resonanceSkillLevelMap = XMagicSkillManager.GetResonanceSkillLevelMap(npcData) + return resonanceSkillLevelMap[skillId] or 0 + end + + --得到人物技能驻守等级 + function XCharacterManager.GetAssignSkillLevel(characterId, skillId) + if not characterId or characterId == 0 then return 0 end + if not XCharacterManager.IsOwnCharacter(characterId) then return 0 end + return XDataCenter.FubenAssignManager.GetSkillLevel(characterId, skillId) + end + + --得到人物技能总加成等级 + function XCharacterManager.GetSkillPlusLevel(characterId, skillId) + return XCharacterManager.GetResonanceSkillLevel(characterId, skillId) + XCharacterManager.GetAssignSkillLevel(characterId, skillId) + end + + --==============================-- + --desc: 获取队长技能描述 + --@characterId: 卡牌数据 + --@return 技能Data + --==============================-- + function XCharacterManager.GetCaptainSkillInfo(characterId) + local captianSkillId = XCharacterConfigs.GetCharacterCaptainSkill(characterId) + local skillLevel = XCharacterManager.GetSkillLevel(captianSkillId) + return XCharacterConfigs.GetCaptainSkillInfo(characterId, skillLevel) + end + + --==============================-- + --desc: 获取队长技能描述 + --@characterId: 卡牌数据 + --@isOnlyShowIntro: 是否只显示技能描述 + --==============================-- + function XCharacterManager.GetCaptainSkillDesc(characterId, isOnlyShowIntro) + local captianSkillInfo = XCharacterManager.GetCaptainSkillInfo(characterId) + return (captianSkillInfo and captianSkillInfo.Level > 0 or isOnlyShowIntro) and captianSkillInfo.Intro or stringFormat("%s%s", captianSkillInfo.Intro, CsXTextManagerGetText("CaptainSkillLock")) + end + + function XCharacterManager.GetSkillLevel(skillId) + local characterId = XCharacterConfigs.GetCharacterIdBySkillId(skillId) + local character = XCharacterManager.GetCharacter(characterId) + return character and character:GetSkillLevelBySkillId(skillId) or 0 + end + + function XCharacterManager.GetSpecialWeaponSkillDes(skillId) + local skillLevel = XCharacterManager.GetSkillLevel(skillId) + + local characterId = XCharacterConfigs.GetCharacterIdBySkillId(skillId) + local addLevel = XCharacterManager.GetSkillPlusLevel(characterId, skillId) + + skillLevel = skillLevel + addLevel + skillLevel = skillLevel == 0 and 1 or skillLevel + + return XCharacterConfigs.GetSkillGradeDesConfigWeaponSkillDes(skillId, skillLevel) + end + + --解锁角色终阶解放技能 + function XCharacterManager.UnlockMaxLiberationSkill(characterId) + local skillGroupId = XCharacterConfigs.GetCharMaxLiberationSkillGroupId(characterId) + local character = OwnCharacters[characterId] + if character then + local skillLevel = character:GetSkillLevel(skillGroupId) + if not skillLevel or skillLevel <= 0 then + XCharacterManager.UnlockSubSkill(nil, characterId, nil, skillGroupId) + end + end + end + + -- 技能相关end -- + -- 服务端相关begin-- + function XCharacterManager.ExchangeCharacter(templateId, cb) + if XCharacterManager.IsOwnCharacter(templateId) then + XUiManager.TipCode(XCode.CharacterManagerExchangeCharacterAlreadyOwn) + return + end + + local char = XCharacterConfigs.GetCharacterTemplate(templateId) + if not char then + XUiManager.TipCode(XCode.CharacterManagerGetCharacterTemplateNotFound) + return + end + + local itemId = char.ItemId + local bornQulity = XCharacterConfigs.GetCharMinQuality(templateId) + local characterType = XCharacterConfigs.GetCharacterType(templateId) + local itemCount = XCharacterConfigs.GetComposeCount(characterType, bornQulity) + + if not XCharacterManager.IsUseItemEnough(itemId, itemCount) then + XUiManager.TipText("CharacterManagerItemNotEnough") + return + end + + XNetwork.Call(METHOD_NAME.ExchangeCharacter, { TemplateId = templateId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_CHARACTER_SYN, templateId) + + if cb then + cb() + end + end) + end + + function XCharacterManager.OnSyncCharacter(protoData) + if not OwnCharacters[protoData.Id] then + XCharacterManager.AddCharacter(protoData) + + local templateId = protoData.Id + if XCharacterConfigs.GetCharacterNeedFirstShow(templateId) ~= 0 then + XUiHelper.PushInFirstGetIdList(templateId, XArrangeConfigs.Types.Character) + end + + XEventManager.DispatchEvent(XEventId.EVENT_CHARACTER_FIRST_GET, templateId) + + return + end + + OwnCharacters[protoData.Id]:Sync(protoData) + end + + function XCharacterManager.OnSyncCharacterVitality(characterId, vitality) + local character = OwnCharacters[characterId] + if not character then return end + character.Vitality = vitality + end + + function XCharacterManager.AddExp(character, itemDict, cb) + if type(character) == "number" then + character = OwnCharacters[character] + end + + cb = cb and cb or function() end + + XMessagePack.MarkAsTable(itemDict) + + local oldLevel = character.Level + XNetwork.Call(METHOD_NAME.LevelUp, { TemplateId = character.Id, UseItems = itemDict }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local exp = 0 + for k, v in pairs(itemDict) do + exp = exp + XDataCenter.ItemManager.GetCharExp(k, character.Type) * v + end + + local useStr = CS.XTextManager.GetText("CharacterExpItemsUse") + local addStr = CS.XTextManager.GetText("ExpAdd", exp) + XEventManager.DispatchEvent(XEventId.EVENT_CHARACTER_INCREASE_TIP, useStr, addStr, oldLevel) + XEventManager.DispatchEvent(XEventId.EVENT_CHARACTER_LEVEL_UP, character.Id) + + cb() + end) + end + + function XCharacterManager.ActivateStar(character, cb) + if type(character) == "number" then + character = OwnCharacters[character] + end + + cb = cb or function() end + + if XCharacterManager.IsMaxQuality(character) then + XUiManager.TipCode(XCode.CharacterManagerMaxQuality) + return + end + + if character.Star >= XCharacterConfigs.MAX_QUALITY_STAR then + XUiManager.TipCode(XCode.CharacterManagerActivateStarMaxStar) + return + end + + local star = character.Star + 1 + + if not XCharacterManager.IsActivateStarUseItemEnough(character.Id, character.Quality, star) then + XUiManager.TipText("CharacterManagerItemNotEnough") + return + end + + local oldAttribs = XCharacterConfigs.GetCharStarAttribs(character.Id, character.Quality, character.Star) + + XNetwork.Call(METHOD_NAME.ActivateStar, { TemplateId = character.Id }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local attrText = "" + for k, v in pairs(oldAttribs) do + local value = FixToDouble(v) + if value > 0 then + attrText = XAttribManager.GetAttribNameByIndex(k) .. "+" .. stringFormat("%.2f", value) + break + end + end + + XEventManager.DispatchEvent(XEventId.EVENT_CHARACTER_QUALITY_STAR_PROMOTE, character.Id) + XEventManager.DispatchEvent(XEventId.EVENT_CHARACTER_INCREASE_TIP, CS.XTextManager.GetText("CharacterActivation"), attrText) + + if cb then + cb() + end + end) + end + + function XCharacterManager.PromoteQuality(character, cb) + if type(character) == "number" then + character = OwnCharacters[character] + end + + if XCharacterManager.IsMaxQuality(character) then + XUiManager.TipCode(XCode.CharacterManagerMaxQuality) + return + end + + if character.Star < XCharacterConfigs.MAX_QUALITY_STAR then + XUiManager.TipCode(XCode.CharacterManagerPromoteQualityStarNotEnough) + return + end + + local characterType = XCharacterConfigs.GetCharacterType(character.Id) + if not XDataCenter.ItemManager.DoNotEnoughBuyAsset(XDataCenter.ItemManager.ItemId.Coin, + XCharacterConfigs.GetPromoteUseCoin(characterType, character.Quality), + 1, + function() + XCharacterManager.PromoteQuality(character, cb) + end, + "CharacterManagerItemNotEnough") then + return + end + + XNetwork.Call(METHOD_NAME.PromoteQuality, { TemplateId = character.Id }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + XEventManager.DispatchEvent(XEventId.EVENT_CHARACTER_QUALITY_PROMOTE, character.Id) + + if cb then + cb() + end + end) + end + + -------------------------------------------------------------------------- + function XCharacterManager.PromoteGrade(character, cb) + if type(character) == "number" then + character = OwnCharacters[character] + end + + if XCharacterManager.IsMaxCharGrade(character) then + XUiManager.TipCode(XCode.CharacterManagerMaxGrade) + return + end + + if not XCharacterManager.IsPromoteGradeUseItemEnough(character.Id, character.Grade) then + XUiManager.TipText("CharacterManagerCoinNotEnough") + return + end + + cb = cb or function() end + + local oldGrade = character.Grade + XNetwork.Call(METHOD_NAME.PromoteGrade, { TemplateId = character.Id }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + XEventManager.DispatchEvent(XEventId.EVENT_CHARACTER_GRADE, character.Id) + + cb(oldGrade) + end) + end + + function XCharacterManager.UnlockSubSkill(skillId, characterId, cb, skillGroupId) + skillGroupId = skillGroupId or XCharacterConfigs.GetSkillGroupIdAndIndex(skillId) + local req = { SkillGroupId = skillGroupId } + + XNetwork.Call(METHOD_NAME.UnlockSubSkill, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + XEventManager.DispatchEvent(XEventId.EVENT_CHARACTER_SKILL_UNLOCK, characterId) + + if cb then + cb() + end + end) + end + + function XCharacterManager.UpgradeSubSkillLevel(characterId, skillId, cb) + local skillGroupId = XCharacterConfigs.GetSkillGroupIdAndIndex(skillId) + local req = { SkillGroupId = skillGroupId } + + XNetwork.Call(METHOD_NAME.UpgradeSubSkill, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + XEventManager.DispatchEvent(XEventId.EVENT_CHARACTER_SKILL_UP, characterId) + + if cb then + cb() + end + end) + end + + function XCharacterManager.IsSkillUsing(skillId) + local characterId = XCharacterConfigs.GetCharacterIdBySkillId(skillId) + local character = XCharacterManager.GetCharacter(characterId) + return character and character:IsSkillUsing(skillId) or false + end + + function XCharacterManager.ReqSwitchSkill(skillId, cb) + local req = { SkillId = skillId } + + XNetwork.Call(METHOD_NAME.SwitchSkill, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local characterId = XCharacterConfigs.GetCharacterIdBySkillId(skillId) + local character = XCharacterManager.GetCharacter(characterId) + character:SwithSkill(skillId) + + if cb then + cb() + end + end) + end + + -- 服务端相关end-- + function XCharacterManager.GetCharModel(templateId, quality) + if not templateId then + XLog.Error("XCharacterManager.GetCharModel函数参数错误: 参数templateId不能为空") + return + end + + if not quality then + quality = XCharacterConfigs.GetCharMinQuality(templateId) + end + + local npcId = XCharacterConfigs.GetCharNpcId(templateId, quality) + + if npcId == nil then + return + end + + local npcTemplate = CS.XNpcManager.GetNpcTemplate(npcId) + + if npcTemplate == nil then + XLog.ErrorTableDataNotFound("XCharacterManager.GetCharModel", "npcTemplate", " Client/Fight/Npc/Npc.tab", "npcId", tostring(npcId)) + return + end + + return npcTemplate.ModelId + end + + function XCharacterManager.GetCharResModel(resId) + if not resId then + XLog.Error("XCharacterManager.GetCharResModel函数参数错误: 参数resId不能为空") + return + end + + local npcTemplate = CS.XNpcManager.GetNpcResTemplate(resId) + + if npcTemplate == nil then + XLog.ErrorTableDataNotFound("XCharacterManager.GetCharResModel", "npcTemplate", "Share/Fight/Npc/NpcRes.tab", "resId", tostring(resId)) + return + end + + return npcTemplate.ModelId + end + + --获取角色解放等级到对应的ModelId + function XCharacterManager.GetCharLiberationLevelModelId(characterId, growUpLevel) + if not characterId then + XLog.Error("XCharacterManager.GetCharLiberationLevelModel函数参数错误: 参数characterId不能为空") + return + end + growUpLevel = growUpLevel or XCharacterConfigs.GrowUpLevel.New + + local modelId = XCharacterConfigs.GetCharLiberationLevelModelId(characterId, growUpLevel) + if not modelId then + local character = XDataCenter.CharacterManager.GetCharacter(characterId) + return XCharacterManager.GetCharModel(characterId, character.Quality) + end + + return modelId + end + + --获取角色解放等级到对应的解放特效名称和模型挂点名 + function XCharacterManager.GetCharLiberationLevelEffectRootAndPath(characterId, growUpLevel) + if not characterId then + XLog.Error("XCharacterManager.GetCharLiberationLevelModel函数参数错误: 参数characterId不能为空") + return + end + growUpLevel = growUpLevel or XDataCenter.ExhibitionManager.GetCharacterGrowUpLevel(characterId) + + return XCharacterConfigs.GetCharLiberationLevelEffectRootAndPath(characterId, growUpLevel) + end + + --获取已解放角色时装到对应的解放特效名称和模型挂点名(传入growUpLevel为预览,否则为自己的角色) + function XCharacterManager.GetCharFashionLiberationEffectRootAndPath(characterId, growUpLevel, fashionId) + if not characterId then + XLog.Error("XCharacterManager.GetCharLiberationLevelModel函数参数错误: 参数characterId不能为空") + return + end + + --自己的角色 + if not growUpLevel then + --拥有该角色 + if not XCharacterManager.IsOwnCharacter(characterId) then + return + end + + growUpLevel = XDataCenter.ExhibitionManager.GetCharacterGrowUpLevel(characterId) + end + + --解放等级达到满级 + local isAchieveMaxLiberation = XDataCenter.ExhibitionManager.IsMaxLiberationLevel(growUpLevel) + if not isAchieveMaxLiberation then + return + end + + fashionId = fashionId or XDataCenter.FashionManager.GetFashionIdByCharId(characterId) + return XDataCenter.FashionManager.GetFashionLiberationEffectRootAndPath(fashionId) + end + + function XCharacterManager.GetCharResIcon(resId) + if not resId then + XLog.Error("XCharacterManager.GetCharResModel函数参数错误: 参数resId不能为空") + return + end + + local npcTemplate = CS.XNpcManager.GetNpcResTemplate(resId) + + if npcTemplate == nil then + XLog.ErrorTableDataNotFound("XCharacterManager.GetCharResIcon", "npcTemplate", "Share/Fight/Npc/NpcRes.tab", "resId", tostring(resId)) + return + end + + return npcTemplate.HeadImageName + end + + --红点相关----------------------------- + function XCharacterManager.CanLevelUp(characterId) + if not characterId then + return false + end + + if not XCharacterManager.IsOwnCharacter(characterId) then + return false + end + + local character = XCharacterManager.GetCharacter(characterId) + if not character then return false end + + if XCharacterManager.IsOverLevel(characterId) or XCharacterManager.IsMaxLevel(characterId) then + return false + end + + local expItemsInfo = XDataCenter.ItemManager.GetCardExpItems() + return next(expItemsInfo) + end + + --检测是否可以提升品质 + function XCharacterManager.CanPromoteQuality(characterId) + + if not characterId then + return false + end + + if not XCharacterManager.IsOwnCharacter(characterId) then + return false + end + + local character = XCharacterManager.GetCharacter(characterId) + + if XCharacterManager.IsMaxQuality(character) then + return false + end + + --最大星级时可以进化到下一阶 + if character.Star == XCharacterConfigs.MAX_QUALITY_STAR then + return XCharacterManager.IsCanPromoted(character.Id) + end + + local star = character.Star + 1 + if not XCharacterManager.IsActivateStarUseItemEnough(character.Id, character.Quality, star) then + return false + end + + return true + end + + --检测是否可以晋升 + function XCharacterManager.CanPromoteGrade(characterId) + + if not characterId then + return false + end + + if not XCharacterManager.IsOwnCharacter(characterId) then + return false + end + + local character = XCharacterManager.GetCharacter(characterId) + + if XCharacterManager.IsMaxCharGrade(character) then + return false + end + + if not XCharacterManager.CheckCanPromoteGradePrecondition(characterId, character.Id, character.Grade) then + return false + end + + if not XCharacterManager.IsPromoteGradeUseItemEnough(character.Id, character.Grade) then + return false + end + + return true + end + + function XCharacterManager.CheckCanPromoteGradePrecondition(characterId, templateId, grade) + local gradeTemplate = XCharacterConfigs.GetGradeTemplates(templateId, grade) + if not gradeTemplate then + return + end + + if #gradeTemplate.ConditionId > 0 then + for i = 1, #gradeTemplate.ConditionId do + local coditionId = gradeTemplate.ConditionId[i] + if not XConditionManager.CheckCondition(coditionId, characterId) then + return false + end + end + + return true + else + return true + end + end + + --是否有技能红点 + function XCharacterManager.CanPromoteSkill(characterId) + if not characterId then + return false + end + + local character = OwnCharacters[characterId] + if not character then + return false + end + + local canUpdate = false + local skills = XCharacterConfigs.GetCharacterSkills(characterId) + for _, skill in pairs(skills) do + for _, subSkill in ipairs(skill.subSkills) do + if (XCharacterManager.CheckCanUpdateSkill(characterId, subSkill.SubSkillId, subSkill.Level)) then + canUpdate = true + break + end + end + end + + return canUpdate + end + + --判断是否能解锁 + function XCharacterManager:CanCharacterUnlock(characterId) + if not characterId then + return false + end + + if XCharacterManager.IsOwnCharacter(characterId) then + return false + end + + local character = XCharacterConfigs.GetCharacterTemplate(characterId) + + local itemId = character.ItemId + local bornQulity = XCharacterConfigs.GetCharMinQuality(characterId) + local characterType = XCharacterConfigs.GetCharacterType(characterId) + local itemCount = XCharacterConfigs.GetComposeCount(characterType, bornQulity) + + if not XCharacterManager.IsUseItemEnough(itemId, itemCount) then + return false + end + + return true + end + + function XCharacterManager.NotifyCharacterDataList(data) + local characterList = data.CharacterDataList + if not characterList then + return + end + + for _, character in pairs(characterList) do + XCharacterManager.OnSyncCharacter(character) + end + end + + function XCharacterManager.GetCharacterLevel(characterId) + if XRobotManager.CheckIsRobotId(characterId) then + return XRobotManager.GetRobotCharacterLevel(characterId) + end + local ownCharacter = XCharacterManager.GetCharacter(characterId) + return ownCharacter and ownCharacter.Level or 0 + end + + function XCharacterManager.GetCharacterQuality(characterId) + if XRobotManager.CheckIsRobotId(characterId) then + return XRobotManager.GetRobotCharacterQuality(characterId) + end + local ownCharacter = XCharacterManager.GetCharacter(characterId) + if ownCharacter then + return ownCharacter.Quality or 0 + end + return XCharacterConfigs.GetCharacterQualityCfg(characterId) + end + + function XCharacterManager.GetCharacterHaveRobotAbilityById(characterId) + if XRobotManager.CheckIsRobotId(characterId) then + return XRobotManager.GetRobotAbility(characterId) + end + local ownCharacter = XCharacterManager.GetCharacter(characterId) + return ownCharacter and ownCharacter.Ability or 0 + end + + XCharacterManager.GetSkillAbility = GetSkillAbility + return XCharacterManager +end + +XRpc.NotifyCharacterDataList = function(data) + XDataCenter.CharacterManager.NotifyCharacterDataList(data) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XChatManager.lua b/Resources/Scripts/XManager/XChatManager.lua new file mode 100644 index 00000000..5aa5bf0f --- /dev/null +++ b/Resources/Scripts/XManager/XChatManager.lua @@ -0,0 +1,1369 @@ +local tableInsert = table.insert +local ipairs = ipairs +local ChatChannelType = ChatChannelType + +XChatManagerCreator = function() + local XChatManager = {} + + local CLIENT_WORLD_CHAT_MAX_SIZE = 0 + local CLIENT_ROOM_CHAT_MAX_SIZE = 0 + local REMOVE_CHAT_RECORD_OF_DAY = 0 + local CHAT_INTERVAL_TIME = 0 + local TodayResetTime = 0 + local WORLD_CHAT_MAX_COUNT = 0 + local MENTOR_CHAT_MAX_COUNT = 0 + -- 一天的秒数 + local ONE_DAY_SECONDS = 60 * 60 * 24 + + local WorldChatList = {} --保存世界聊天记录 + local PrivateChatMap = {} --保存私聊的聊天纪录 + local GuildChatList = {} --保存公会聊天纪录 + local RoomChatList = {} --保存房间聊天记录 + local MentorChatList = {} --师徒聊天记录 + local ChatList = {} --各类聊天记录 + local EmojiDatasDic = {} + local EffectInfo = {} -- 关键字屏幕特效 + local EffectTriggerType = { + Me = 1, + Other = 2, + All = 3, + } + local LastChatCoolTime = 0 + local LastEffectCoolTime = 0 + + local MessageId = -1 --离线消息 + local OfflineMessageTag = "OfflineRecordMessage_" + + local LastRequestChannelTime = 0 + local CurrentChatChannelId = 0 + local LastReadChatTime = {} + local ChatChannelInfos + local GuildChatContent = "" + local GuildSaveCount = 0 + local MentorChatContent = "" + local MentorSaveCount = 0 + + --协议处理 + local MethodName = { + SendChat = "SendChatRequest", + GetGift = "GetGiftsRequest", + GetAllGiftsRequest = "GetAllGiftsRequest", + GetOfflineMessageRequest = "OfflineMessageRequest", + SelectChatChannelRequest = "SelectChatChannelRequest", + EnterWorldChatRequest = "EnterWorldChatRequest", + GetWorldChannelInfoRequest = "GetWorldChannelInfoRequest", + } + + function XChatManager.Init() + REMOVE_CHAT_RECORD_OF_DAY = CS.XGame.ClientConfig:GetInt("RemoveChatRecordOfDay") + CLIENT_WORLD_CHAT_MAX_SIZE = CS.XGame.ClientConfig:GetInt("WorldChatMaxSize") + CLIENT_ROOM_CHAT_MAX_SIZE = CS.XGame.ClientConfig:GetInt("RoomChatMaxSize") + CHAT_INTERVAL_TIME = CS.XGame.Config:GetInt("ChatIntervalTime") + WORLD_CHAT_MAX_COUNT = CS.XGame.Config:GetInt("WorldChatMaxCount") + MENTOR_CHAT_MAX_COUNT = XMentorSystemConfigs.GetMentorSystemData("MentorChatMaxCount") + + ChatList[ChatChannelType.World] = WorldChatList + ChatList[ChatChannelType.Guild] = GuildChatList + ChatList[ChatChannelType.Room] = RoomChatList + ChatList[ChatChannelType.Mentor] = MentorChatList + + for _, type in pairs(ChatChannelType) do + local key = string.format("%s%d" ,XChatConfigs.KEY_LAST_READ_CHAT_TIME, type) + LastReadChatTime[type] = XSaveTool.GetData(key) or XMath.IntMax() + end + + XEventManager.AddEventListener(XEventId.EVENT_ROOM_LEAVE_ROOM, function() + RoomChatList = {} + ChatList[ChatChannelType.Room] = RoomChatList + end) + XEventManager.AddEventListener(XEventId.EVENT_LOGIN_DATA_LOAD_COMPLETE, function() + XChatManager.InitChatChannel() + -- 登录完成后直接获取所有频道信息 + XChatManager.GetWorldChannelInfos() + end) + + -- 聊天播放特效功能 + local effectTemplates = XChatConfigs.GetEffectTemplates() + local nowTime = XTime.GetServerNowTimestamp() + for _, template in pairs(effectTemplates) do + local endTime = XTime.ParseToTimestamp(template.EndTimeStr) + if nowTime < endTime then + local data = XTool.Clone(template) + data.BeginTime = XTime.ParseToTimestamp(data.BeginTimeStr) + data.EndTime = endTime + tableInsert(EffectInfo, data) + end + end + end + + function XChatManager.GetLastRequestChannelTime() + return LastRequestChannelTime + end + + function XChatManager.SetLastRequestChannelTime(time) + LastRequestChannelTime = time + end + + function XChatManager.GetWorldChatMaxCount() + return WORLD_CHAT_MAX_COUNT + end + + function XChatManager.GetMentorChatMaxCount() + return MENTOR_CHAT_MAX_COUNT + end + + -- 初始化世界聊天数据 + function XChatManager.InitWorldChatData(worldChatDataList) + WorldChatList = {} + ChatList[ChatChannelType.World] = WorldChatList + local WorldChatLoop = function(item) + if item ~= nil then + XChatManager.ProcessExtraContent(item) + tableInsert(WorldChatList, 1, item) + end + end + XTool.LoopCollection(worldChatDataList, WorldChatLoop) + end + + --加载私聊信息 + function XChatManager.InitFriendPrivateChatData() + PrivateChatMap = {} + local cb = function() + for _, friendId in pairs(XDataCenter.SocialManager.GetFriendIds()) do + XChatManager.ReadSpecifyFriendsChatContent(friendId) + end + XChatManager.GetOfflineMessageRequest(XChatManager.GetLocalOfflineRecord()) + end + XDataCenter.SocialManager.GetFriendsInfo(cb) + end + + --处理系统消息 + local function HandleSystemChat() + --TODO Handle System Chat + end + + --处理世界消息 + local function HandleWorldChat(chatData, isNotify) + --黑名单的聊天数据不加入 + if XDataCenter.SocialManager.GetBlackData(chatData.SenderId) then + return + end + + if #WorldChatList >= CLIENT_WORLD_CHAT_MAX_SIZE then + table.remove(WorldChatList, #WorldChatList) + end + tableInsert(WorldChatList, 1, chatData) + + if isNotify then + XEventManager.DispatchEvent(XEventId.EVENT_CHAT_RECEIVE_WORLD_MSG, chatData) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_CHAT_RECEIVE_WORLD_MSG, chatData) + end + end + + --处理公会消息 + local function HandleGuildChat(chatData, isNotify) + if XDataCenter.SocialManager.GetBlackData(chatData.SenderId) then + return + end + + tableInsert(GuildChatList, 1, chatData) + if isNotify then + XEventManager.DispatchEvent(XEventId.EVENT_GUILD_RECEIVE_CHAT, chatData) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_GUILD_RECEIVE_CHAT, chatData) + end + end + + --处理师徒消息 + local function HandleMentorChat(chatData, isNotify) + if XDataCenter.SocialManager.GetBlackData(chatData.SenderId) then + return + end + + if #MentorChatList >= MENTOR_CHAT_MAX_COUNT then + table.remove(MentorChatList, #MentorChatList) + end + tableInsert(MentorChatList, 1, chatData) + + if isNotify then + XEventManager.DispatchEvent(XEventId.EVENT_CHAT_RECEIVE_MENTOR_MSG, chatData) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_CHAT_RECEIVE_MENTOR_MSG, chatData) + end + end + + --处理私聊消息 + local function HandlePrivateChat(chatData, ignoreNotify) + if XDataCenter.SocialManager.GetBlackData(chatData.SenderId) then + return + end + + if (not chatData) then + return + end + if chatData.SenderId == XPlayer.Id or + chatData.MsgType == ChatMsgType.Gift or + chatData.MsgType == ChatMsgType.Tips then + chatData.IsRead = true + end + if chatData.SenderId ~= XPlayer.Id then + XChatManager.UpdateLocalOfflineRecord(chatData.MessageId or 0) + end + local targetId = chatData:GetChatTargetId() + + XChatManager.AddPrivateChatData(targetId, chatData, false, ignoreNotify) + + --保存消息 + XChatManager.SaveSpecifyFriendsChatContent(targetId) + end + + --处理房间消息 + local function HandleRoomChat(chatData) + if XDataCenter.SocialManager.GetBlackData(chatData.SenderId) then + return + end + + if #RoomChatList >= CLIENT_ROOM_CHAT_MAX_SIZE then + table.remove(RoomChatList, #RoomChatList) + end + tableInsert(RoomChatList, 1, chatData) + + XEventManager.DispatchEvent(XEventId.EVENT_CHAT_RECEIVE_ROOM_MSG, chatData) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_CHAT_RECEIVE_ROOM_MSG, chatData) + end + + -- 清除房间聊天 + function XChatManager.ResetRoomChat() + RoomChatList = {} + ChatList[ChatChannelType.Room] = RoomChatList + end + + function XChatManager.OnSynChat(chatMsg, ignoreNotify) + local chatData = XChatData.New(chatMsg) + if chatMsg.ChannelType == ChatChannelType.System then + HandleSystemChat(chatData) + elseif chatMsg.ChannelType == ChatChannelType.World then + HandleWorldChat(chatData, true) + elseif chatMsg.ChannelType == ChatChannelType.Private then + HandlePrivateChat(chatData, ignoreNotify) + elseif chatMsg.ChannelType == ChatChannelType.Room then + HandleRoomChat(chatData) + elseif chatMsg.ChannelType == ChatChannelType.Guild then + HandleGuildChat(chatData, true) + XChatManager.SaveGuildChatContent() + elseif chatMsg.ChannelType == ChatChannelType.Mentor then + HandleMentorChat(chatData, true) + end + + --接收到礼物时增加一条tip提示 + if chatMsg.MsgType == ChatMsgType.Gift then + chatMsg.MsgType = ChatMsgType.Tips + chatMsg.CreateTime = chatMsg.CreateTime + chatMsg.GiftId = chatMsg.GiftId + XChatManager.OnSynChat(chatMsg, true) + end + end + + + + ---------------------------------public function----------------------------------- + function XChatManager.GetRemoveChatRecordOfDays() + return REMOVE_CHAT_RECORD_OF_DAY + end + + function XChatManager.GetWorldChatMaxSize() + return CLIENT_WORLD_CHAT_MAX_SIZE + end + + --=== Emoji === + function XChatManager.GetEmojiIcon(emojiId) + return XChatConfigs.GetEmojiIcon(emojiId) + end + + function XChatManager.GetEmojiQuality() + return XChatConfigs.GetEmojiQuality() + end + + function XChatManager.GetEmojiName(emojiId) + return XChatConfigs.GetEmojiName(emojiId) + end + + function XChatManager.GetEmojiDescription(emojiId) + return XChatConfigs.GetEmojiDescription(emojiId) + end + + function XChatManager.GetEmojiWorldDesc(emojiId) + return XChatConfigs.GetEmojiWorldDesc(emojiId) + end + + function XChatManager.GetEmojiBigIcon(emojiId) + return XChatConfigs.GetEmojiBigIcon(emojiId) + end + + function XChatManager.GetEmojiTemplates() + local templates = {} + + for _, emojiData in pairs(EmojiDatasDic) do + tableInsert(templates, emojiData) + end + table.sort(templates, function(l, r) return l:GetEmojiOrder() < r:GetEmojiOrder() end) + return templates + end + + function XChatManager.GetEmojiDatasDic() + return EmojiDatasDic + end + + function XChatManager.IsEmojiValid(emojiId) + for _, v in pairs(EmojiDatasDic) do + if v:IsEmojiValid(emojiId) then + return true + end + end + + return false + end + + --=== Any Chat === + function XChatManager.GetChatList(type) + return ChatList[type] + end + + --=== World Chat === + function XChatManager.GetWorldChatList() + return WorldChatList + end + + --=== Guild Chat === + function XChatManager.GetGuildChatList() + return GuildChatList + end + + --=== Mentor Chat === + function XChatManager.GetMentorChatList() + return MentorChatList + end + + --=== Room Chat === + function XChatManager.GetRoomChatList() + table.sort(RoomChatList, function(a, b) + if a.CreateTime ~= b.CreateTime then + return a.CreateTime > b.CreateTime + end + end) + return RoomChatList + end + + --=== Private Chat === + -- 获取私聊聊天数据 + function XChatManager.GetPrivateDynamicList(friendId) + local msgData = XChatManager.GetPrivateChatsByFriendId(friendId) + local sortFunc = function(a, b) + if a.CreateTime ~= b.CreateTime then + return a.CreateTime > b.CreateTime + else + if a.MsgType == ChatMsgType.Tips then + if b.MsgType == ChatMsgType.Tips then + return a.GiftStatus > b.GiftStatus + end + return true + end + end + end + table.sort(msgData, sortFunc) + return msgData + end + + -- 获取私聊好友id列表 + function XChatManager.GetPrivateChatGroupData(nowID) + --初始化数据 + local chatFriendIdList = XChatManager.GetHaveChatDataFriendIds() + local targetInList = false + for _, id in ipairs(chatFriendIdList) do + if id == nowID then + targetInList = true + break + end + end + if not targetInList then + tableInsert(chatFriendIdList, 1, nowID) + end + + local dynamicListData = {} + for _, v in ipairs(chatFriendIdList) do + local friendInfo = XDataCenter.SocialManager.GetFriendInfo(v) + tableInsert(dynamicListData, friendInfo) + end + return dynamicListData + end + + + --新增私聊消息 + function XChatManager.AddPrivateChatData(friendId, chatData, isInit, ignoreNotify) + if XDataCenter.SocialManager.GetBlackData(friendId) then + return + end + + --好友聊天数据结构 + local friendChats = PrivateChatMap[friendId] + if not friendChats then + friendChats = {} + friendChats.ChatMap = {} + friendChats.LastChat = nil + PrivateChatMap[friendId] = friendChats + end + + friendChats.LastChat = chatData + + friendChats.ChatMap = friendChats.ChatMap or {} + tableInsert(friendChats.ChatMap, chatData) + + if not isInit or not chatData.IsRead then + if not ignoreNotify then + XEventManager.DispatchEvent(XEventId.EVENT_CHAT_RECEIVE_PRIVATECHAT, chatData) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_CHAT_RECEIVE_PRIVATECHAT, chatData) + end + end + end + + --获取已聊天过的好友id列表 + function XChatManager.GetHaveChatDataFriendIds() + local list = {} + + for friendId, chatInfo in pairs(PrivateChatMap) do + if chatInfo and chatInfo.ChatMap then + for _, _ in pairs(chatInfo.ChatMap) do + tableInsert(list, friendId) + break + end + end + end + + if #list >= 2 then + local sortByCreateTime = function(l, r) + local lchat = XChatManager.GetLastPrivateChatByFriendId(l) + local rchat = XChatManager.GetLastPrivateChatByFriendId(r) + if lchat.CreateTime > rchat.CreateTime then + return true + else + return false + end + end + table.sort(list, sortByCreateTime) + end + + return list + end + + --更新礼物信息 + function XChatManager.UpdateGiftData(friendId, giftId, status, giftCount) + local friendChats = PrivateChatMap[friendId] + if not friendChats or not friendChats.ChatMap then + return + end + + for _, v in pairs(friendChats.ChatMap) do + if (v.MsgType == ChatMsgType.Gift or v.MsgType == ChatMsgType.Tips) and v.GiftId == giftId and v.SenderId == friendId then + friendChats.LastChat = v + v.GiftStatus = status + if giftCount and giftCount > 0 then + v.GiftCount = giftCount + end + end + end + --保存消息 + XChatManager.SaveSpecifyFriendsChatContent(friendId) + end + + --获取指定好友聊天列表 + function XChatManager.GetPrivateChatsByFriendId(friendId) + local list = {} + if (PrivateChatMap[friendId] and PrivateChatMap[friendId].ChatMap) then + for _, chat in pairs(PrivateChatMap[friendId].ChatMap) do + tableInsert(list, chat) + end + end + return list + end + + --获取好友最后一条聊天 + function XChatManager.GetLastPrivateChatByFriendId(friendId) + local lastChat = nil + local info = PrivateChatMap[friendId] + if (info) then + lastChat = info.LastChat + end + return lastChat + end + + --获取好友未读聊天数量 + function XChatManager.GetPrivateUnreadChatCountByFriendId(friendId) + local count = 0 + local info = PrivateChatMap[friendId] + if (info and info.ChatMap) then + for _, chat in pairs(info.ChatMap) do + if (not chat.IsRead) then + count = count + 1 + end + end + end + return count + end + + --设置指定好友全部聊天为已读 + function XChatManager.SetPrivateChatReadByFriendId(friendId) + local friendChat = PrivateChatMap[friendId] + local count = 0 + if friendChat and friendChat.ChatMap then + for _, chat in pairs(friendChat.ChatMap) do + if not chat.IsRead then + chat.IsRead = true + count = count + 1 + end + end + end + + --保存消息 + XChatManager.SaveSpecifyFriendsChatContent(friendId) + + if count > 0 then + XEventManager.DispatchEvent(XEventId.EVENT_FRIEND_READ_PRIVATE_MSG) + end + end + + --检测好友是否有自己可以领取的礼物 + function XChatManager.CheckDoesHaveGiftByFriendId(friendId) + local friendChats = PrivateChatMap[friendId] + if not friendChats or not friendChats.ChatMap then + return false + end + for _, v in pairs(friendChats.ChatMap) do + if v:CheckHaveGift() then + return true + end + end + return false + end + + ---------------------------------Chat Record----------------------------------- + local ChatRecordTag = "ChatRecord_%d_%d" --标识 + 好友id + 自己id + + --读取指定好友的聊天内容 + function XChatManager.ReadSpecifyFriendsChatContent(friendId) + local key = string.format(ChatRecordTag, friendId, XPlayer.Id) + if CS.UnityEngine.PlayerPrefs.HasKey(key) then + local chatRecord = CS.UnityEngine.PlayerPrefs.GetString(key) + local msgTab = string.Split(chatRecord, '\n') + if msgTab ~= nil and #msgTab > 0 then + for index = 1, #msgTab do + local content = msgTab[index] + if (not string.IsNilOrEmpty(content)) then + local tab = string.Split(content, '\t') + if tab ~= nil then + if XChatManager.CheckIsRemove(tonumber(tab[3])) then + local chatData = XChatData.New() + chatData.ChannelType = ChatChannelType.Private + + chatData.SenderId = tonumber(tab[1]) + chatData.TargetId = tonumber(tab[2]) + chatData.CreateTime = tonumber(tab[3]) + chatData.Content = tab[4] + chatData.MsgType = tonumber(tab[5]) + chatData.GiftId = tonumber(tab[6]) + chatData.GiftCount = tonumber(tab[7]) + chatData.GiftStatus = tonumber(tab[8]) + chatData.IsRead = tonumber(tab[9]) == 1 + chatData.CustomContent = tab[10] + + if XPlayer.Id == chatData.SenderId then + chatData.Icon = XPlayer.CurrHeadPortraitId + chatData.NickName = XPlayer.Name + chatData.HeadFrameId = XPlayer.CurrHeadFrameId + else + local friendInfo = XDataCenter.SocialManager.GetFriendInfo(friendId) + if friendInfo then + chatData.Icon = friendInfo.Icon + chatData.NickName = friendInfo.NickName + chatData.HeadFrameId = friendInfo.HeadFrameId + end + end + XChatManager.ProcessExtraContent(chatData) + XChatManager.AddPrivateChatData(friendId, chatData, true) + end + end + end + end + end + end + end + + --检测该消息是否是七天前的 + function XChatManager.CheckIsRemove(time) + if time == nil then + return false + end + local curTime = XTime.GetServerNowTimestamp() + return curTime - time <= REMOVE_CHAT_RECORD_OF_DAY * 24 * 60 * 60 + end + + function XChatManager.DeleteGuildChat(guildId) + GuildChatList = {} + ChatList[ChatChannelType.Guild] = GuildChatList + local key = XDataCenter.GuildManager.GetGuildChannelKey(guildId) + if CS.UnityEngine.PlayerPrefs.HasKey(key) then + CS.UnityEngine.PlayerPrefs.DeleteKey(key) + CS.UnityEngine.PlayerPrefs.Save() + end + end + + -- 登录初始化公会聊天内容 + function XChatManager.InitLocalCacheGuildChatContent() + if not XDataCenter.GuildManager.IsJoinGuild() then return end + local guildId = XDataCenter.GuildManager.GetGuildId() + local key = XDataCenter.GuildManager.GetGuildChannelKey(guildId) + if CS.UnityEngine.PlayerPrefs.HasKey(key) then + GuildChatList = {} + ChatList[ChatChannelType.Guild] = GuildChatList + local chatRecord = CS.UnityEngine.PlayerPrefs.GetString(key) + local allLines = string.Split(chatRecord, '\n') + if allLines ~= nil and #allLines > 0 then + for i = 1, #allLines do + local content = allLines[i] + if (not string.IsNilOrEmpty(content)) then + local tab = string.Split(content, '\t') + if tab ~= nil then + local chatData = XChatData.New() + chatData.SenderId = tonumber(tab[1]) + chatData.TargetId = tonumber(tab[2]) + chatData.CreateTime = tonumber(tab[3]) + chatData.Content = tab[4] + chatData.MsgType = tonumber(tab[5]) + chatData.IsRead = tonumber(tab[6]) + chatData.MessageId = tonumber(tab[7]) + chatData.Icon = tonumber(tab[8]) + chatData.CustomContent = tab[9] + chatData.NickName = tab[10] + chatData.GuildRankLevel = tonumber(tab[11]) + chatData.ChannelType = tonumber(tab[12]) + chatData.HeadFrameId = tonumber(tab[13]) + chatData.CollectWordId = tonumber(tab[14]) + chatData.NameplateId = tonumber(tab[15]) or 0 + tableInsert(GuildChatList, chatData) + end + end + end + end + end + end + + -- 合并客户端,服务端公会聊天 + function XChatManager.MergeClientAndServerGuildChat(serverChat) + + if #serverChat <= 0 then return end + if #GuildChatList <= 0 then + if #serverChat > 0 then + for _, chatData in pairs(serverChat) do + tableInsert(GuildChatList, chatData) + end + return + end + end + + local clientTailIndex = 1 + local clientTailCreateTime = GuildChatList[clientTailIndex].CreateTime + + local serverTailIndex = #serverChat + local serverTailCreateTime = serverChat[serverTailIndex].CreateTime + + local serverHeadIndex = 1 + local serverHeadCreateTime = serverChat[serverHeadIndex].CreateTime + + -- 服务端缓存与客户端缓存完全重叠 + if clientTailCreateTime > serverHeadCreateTime then + return + end + + -- 服务端缓存与客户端缓存部分重叠 + local beginIndex = 0 + if serverTailCreateTime <= clientTailCreateTime and clientTailCreateTime <= serverHeadCreateTime then + local clientHeadChat = GuildChatList[clientTailIndex] + for i = #serverChat, 1, -1 do + local curServerChat = serverChat[i] + + if clientHeadChat.CreateTime == curServerChat.CreateTime and + clientHeadChat.SenderId == curServerChat.SenderId and + clientHeadChat.Content == curServerChat.Content then + + beginIndex = i - 1 + break + end + + if clientHeadChat.CreateTime < curServerChat.CreateTime then + beginIndex = i + break + end + end + + if beginIndex > 0 and beginIndex <= #serverChat then + for i = beginIndex, 1, -1 do + tableInsert(GuildChatList, 1, serverChat[i]) + end + end + XChatManager.SaveGuildChatContent() + return + end + + -- 服务端缓存与客户端缓存完成不重叠 + if clientTailCreateTime < serverTailCreateTime then + for i = #serverChat, 1, -1 do + tableInsert(GuildChatList, 1, serverChat[i]) + end + end + XChatManager.SaveGuildChatContent() + end + + -- 存储公会聊天内容 + function XChatManager.SaveGuildChatContent() + if not XDataCenter.GuildManager.IsJoinGuild() then return end + local splitMark = "\n" + for i = #GuildChatList-GuildSaveCount, 1, -1 do + local chat = GuildChatList[i] + local list = {} + if chat ~= nil and type(chat) == 'table' and i <= XGuildConfig.GuildChatCacheCount then + tableInsert(list, chat.SenderId) + tableInsert(list, chat.TargetId) + tableInsert(list, chat.CreateTime) + tableInsert(list, chat.Content) + tableInsert(list, chat.MsgType) + tableInsert(list, (chat.IsRead and "1" or "0")) + tableInsert(list, chat.MessageId) + tableInsert(list, chat.Icon) + tableInsert(list, (chat.CustomContent or "")) + tableInsert(list, (chat.NickName or "")) + tableInsert(list, (chat.GuildRankLevel or "0")) + tableInsert(list, (chat.ChannelType or "0")) + tableInsert(list, (chat.HeadFrameId or "0")) + tableInsert(list, (chat.CollectWordId or "0")) + tableInsert(list, (chat.NameplateId or "0")) + end + GuildSaveCount = GuildSaveCount + 1 + local chatStr = table.concat(list, "\t") + GuildChatContent = string.format("%s%s%s", chatStr, splitMark, GuildChatContent) + end + if GuildChatContent ~= nil and GuildChatContent ~= '' then + local guildId = XDataCenter.GuildManager.GetGuildId() + local key = XDataCenter.GuildManager.GetGuildChannelKey(guildId) + CS.UnityEngine.PlayerPrefs.SetString(key, GuildChatContent) + CS.UnityEngine.PlayerPrefs.Save() + end + end + + -- 关键字匹配 + function XChatManager.KeywordMatch(channelType, chatData) + local nowTime = XTime.GetServerNowTimestamp() + local firstMatchIndex = nil + local minMatchPos = XMath.IntMax() + for index, info in ipairs(EffectInfo) do + local isMatch = true + isMatch = isMatch and nowTime > info.BeginTime and nowTime < info.EndTime + isMatch = isMatch and nowTime > LastEffectCoolTime + info.CoolTime + isMatch = isMatch and chatData.MsgType == ChatMsgType.Normal or chatData.MsgType == ChatMsgType.RoomMsg + if not isMatch then goto CONTINUE end + + if info.TriggerType == EffectTriggerType.Me then + isMatch = isMatch and chatData.SenderId == XPlayer.Id + elseif info.TriggerType == EffectTriggerType.Other then + isMatch = isMatch and chatData.SenderId ~= XPlayer.Id + end + + if info.Channel and next(info.Channel) then + local isPartMatch = false + for _,channel in ipairs(info.Channel) do + isPartMatch = isPartMatch or channel == channelType + end + isMatch = isMatch and isPartMatch + end + + if not isMatch then goto CONTINUE end + + -- 开始匹配具体内容 + if info.Keyword and next(info.Keyword) then + for _,pattern in ipairs(info.Keyword) do + local matchPos = string.find(chatData.Content, pattern) + if matchPos and matchPos < minMatchPos then + firstMatchIndex = index + minMatchPos = matchPos + end + end + + end + :: CONTINUE :: + end + if firstMatchIndex then + CsXGameEventManager.Instance:Notify(XEventId.EVENT_CHAT_MATCH_EFFECT, EffectInfo[firstMatchIndex]) + return + end + end + + -- 权重随机算法(输入:权重数组 输出:加权后的随机index) + function XChatManager.WeightRandomSelect(weights) + local sum = 0 + for i = 1, #weights do + sum = sum + weights[i] + end + math.randomseed(os.time()) + local compareWeight = math.random(1, sum) + local weightIndex = 1 + while sum > 0 do + sum = sum - weights[weightIndex] + if sum < compareWeight then + return weightIndex + end + weightIndex = weightIndex + 1 + end + XLog.Error("compare error, return nil") + return nil + end + + -- 设置特效播放完毕的时间 + function XChatManager.SetEffectEnd(time) + LastEffectCoolTime = time or XTime.GetServerNowTimestamp() + end + + -- 设置最后一次读消息的时间 + function XChatManager.SetChatRead(type) + local key = string.format("%s%d" ,XChatConfigs.KEY_LAST_READ_CHAT_TIME, type) + if next(ChatList[type]) then + LastReadChatTime[type] = ChatList[type][1].CreateTime + else + local nowTime = XTime.GetServerNowTimestamp() + LastReadChatTime[type] = nowTime + -- XLog.Warning("nowTime",XTime.TimestampToLocalDateTimeString(nowTime),type) + end + XSaveTool.SaveData(key, LastReadChatTime[type]) + end + + -- 获取未读信息数量 + function XChatManager.GetUnreadChatCount(type) + local count = 0 + local chatList = XChatManager.GetChatList(type) + if not (chatList and next(chatList)) then + return count + end + for i = 1, #chatList do + local chat = chatList[i] + if chat.CreateTime > LastReadChatTime[type] then + count = count + 1 + end + end + return count + end + + function XChatManager.CheckRedPointByType(type) + -- return XChatManager.GetUnreadChatCount(type) > 0 + local chatList = XChatManager.GetChatList(type) + if not (chatList and next(chatList)) then + return false + end + -- 除了好友消息,其他类型都是将最新消息插入到表头 + -- XLog.Warning(chatList) + -- XLog.Warning(type, chatList[1].CreateTime > LastReadChatTime[type], chatList[1].CreateTime, XTime.TimestampToLocalDateTimeString(LastReadChatTime[type]),XTime.TimestampToLocalDateTimeString(chatList[1].CreateTime)) + return chatList[1].CreateTime > LastReadChatTime[type] + end + + function XChatManager.GetLatestChatData(type) + if type then + return ChatList[type][1] + else + -- 默认返回最后一次公会或者世界聊天内容 + local worldMsg = ChatList[ChatChannelType.World][1] + local guildMsg = ChatList[ChatChannelType.Guild][1] + local latestMsg + local latestTime = 0 + if guildMsg then + latestMsg = guildMsg + latestTime = guildMsg.CreateTime + end + if worldMsg and worldMsg.CreateTime > latestTime then + latestMsg = worldMsg + latestTime = worldMsg.CreateTime + end + return latestMsg + end + end + + -- 删除上一个公会的聊天缓存 + function XChatManager.DeleteLastGuildChatContent(lastGuildId) + if XDataCenter.GuideManager.IsJoinGuild() then + local guildId = XDataCenter.GuildManager.GetGuildId() + if guildId == lastGuildId then return end + end + local lastGuildKey = XDataCenter.GuildManager.GetGuildChannelKey(lastGuildId) + if CS.UnityEngine.PlayerPrefs.HasKey(lastGuildKey) then + CS.UnityEngine.PlayerPrefs.DeleteKey(lastGuildKey) + CS.UnityEngine.PlayerPrefs.Save() + end + end + + --存储指定好友的聊天内容 + function XChatManager.SaveSpecifyFriendsChatContent(friendId) + local chatList = XChatManager.GetPrivateDynamicList(friendId) + if chatList == nil or #chatList == 0 then + return + end + local saveContent = '' + for index = 1, #chatList do + local chat = chatList[index] + if chat ~= nil and type(chat) == 'table' then + saveContent = saveContent .. chat.SenderId .. '\t' + saveContent = saveContent .. chat.TargetId .. '\t' + saveContent = saveContent .. chat.CreateTime .. '\t' + saveContent = saveContent .. chat.Content .. '\t' + saveContent = saveContent .. chat.MsgType .. "\t" + saveContent = saveContent .. tostring(chat.GiftId) .. "\t" + saveContent = saveContent .. tostring(chat.GiftCount) .. "\t" + saveContent = saveContent .. tostring(chat.GiftStatus) .. "\t" + saveContent = saveContent .. (chat.IsRead and "1" or "0") .. "\t" + saveContent = saveContent .. (chat.CustomContent or "") .. "\n" + end + end + if saveContent ~= nil and saveContent ~= '' then + local key = string.format(ChatRecordTag, friendId, XPlayer.Id) + CS.UnityEngine.PlayerPrefs.SetString(key, saveContent) + CS.UnityEngine.PlayerPrefs.Save() + end + end + + --清除指定好友的聊天内容 + function XChatManager.ClearFriendChatContent(friendId) + local key = string.format(ChatRecordTag, friendId, XPlayer.Id) + PrivateChatMap[friendId] = nil + if CS.UnityEngine.PlayerPrefs.HasKey(key) then + CS.UnityEngine.PlayerPrefs.DeleteKey(key) + CS.UnityEngine.PlayerPrefs.Save() + end + end + + --获取所有私聊信息 + function XChatManager.GetAllPrivateChatMsgCount() + + if not PrivateChatMap then + return 0 + end + local count = 0 + for _, v in pairs(PrivateChatMap) do + local info = v + if (info and info.ChatMap) then + for _, chat in pairs(info.ChatMap) do + if (not chat.IsRead) then + count = count + 1 + end + end + end + end + return count + end + + function XChatManager.CheckCd() + if LastChatCoolTime > 0 and LastChatCoolTime + CHAT_INTERVAL_TIME > XTime.GetServerNowTimestamp() then + XUiManager.TipCode(XCode.ChatManagerRefreshTimeCooling) + return false + end + + return true + end + + --发送聊天 + function XChatManager.SendChat(chatData, cb) + XNetwork.Call(MethodName.SendChat, { ChatData = chatData, TargetIdList = chatData.TargetIds }, function(response) + LastChatCoolTime = response.RefreshTime + if response.Code ~= XCode.Success then + XUiManager.TipCode(response.Code) + + if chatData.ChannelType == ChatChannelType.World then + if cb then + cb(CHAT_INTERVAL_TIME + LastChatCoolTime - XTime.GetServerNowTimestamp(), response.ChatData) + end + end + return + end + + if cb then + cb(CHAT_INTERVAL_TIME + LastChatCoolTime - XTime.GetServerNowTimestamp(), response.ChatData) + end + end) + end + + --收取单个礼物 + function XChatManager.GetGift(giftId, callback) + callback = callback or function() end + + XNetwork.Call(MethodName.GetGift, { GiftId = giftId or 0 }, function(response) + if response.Code ~= XCode.Success then + XUiManager.TipCode(response.Code) + return + end + callback(response.RewardGoodsList) + end) + end + + --群收礼物 + function XChatManager.GetAllGiftsRequest(callback) + if not XChatManager.CheckHasGift() then + XUiManager.TipError(CS.XTextManager.GetText("ChatManagerGetGiftNotGift")) + return + end + XNetwork.Call(MethodName.GetAllGiftsRequest, nil, function(response) + if response.Code ~= XCode.Success then + XUiManager.TipCode(response.Code) + return + end + if #response.RewardGoodsList <= 0 then + XUiManager.TipError(CS.XTextManager.GetText("ChatManagerGetGiftNotGift")) + return + end + if callback then + callback(response.GiftInfoList, response.RewardGoodsList) + end + end) + end + + -- 离线消息 + function XChatManager.GetOfflineMessageRequest(msgId, cb) + XNetwork.Call(MethodName.GetOfflineMessageRequest, { MessageId = msgId }, function(response) + if response.Code ~= XCode.Success then + XUiManager.TipCode(response.Code) + return + end + -- 处理离线的消息 + XChatManager.HandleOfflineMessage(response.Messages) + if cb then + cb() + end + end) + end + + function XChatManager.HandleOfflineMessage(offlineMessages) + if not offlineMessages then return end + + local lastChatData = nil + local earliestChatTime = XMath.IntMax() + for _, chatData in pairs(offlineMessages) do + XChatManager.ProcessExtraContent(chatData) + XChatManager.OnSynChat(chatData, true) + if earliestChatTime < chatData.CreateTime then + earliestChatTime = chatData.CreateTime + end + lastChatData = chatData + end + + for _, type in ipairs(ChatChannelType) do + if earliestChatTime < LastReadChatTime[type] then + LastReadChatTime[type] = earliestChatTime + local key = string.format("%s%d" ,XChatConfigs.KEY_LAST_READ_CHAT_TIME, type) + XSaveTool.SaveData(key, LastReadChatTime[type]) + end + end + + -- 只在最后检查一次红点 + if lastChatData then + local data = XChatData.New(lastChatData) + XEventManager.DispatchEvent(XEventId.EVENT_CHAT_RECEIVE_PRIVATECHAT, data) + end + end + + function XChatManager.UpdateLocalOfflineRecord(messageId) + if messageId > MessageId then + MessageId = messageId + local key = string.format("%s%s", OfflineMessageTag, tostring(XPlayer.Id)) + CS.UnityEngine.PlayerPrefs.SetInt(key, MessageId) + CS.UnityEngine.PlayerPrefs.Save() + end + + end + + function XChatManager.GetLocalOfflineRecord() + local key = string.format("%s%s", OfflineMessageTag, tostring(XPlayer.Id)) + if CS.UnityEngine.PlayerPrefs.HasKey(key) then + MessageId = CS.UnityEngine.PlayerPrefs.GetInt(key, MessageId) + end + return MessageId + end + + -- 【聊天分频道】 + function XChatManager.GetCurrentChatChannelId() + return CurrentChatChannelId + end + + -- 切换聊天频道 + function XChatManager.SelectChatChannel(channelId, succeedCb, failedCb) + if channelId == CurrentChatChannelId then return end + + XNetwork.Call(MethodName.SelectChatChannelRequest, { ChannelId = channelId - 1 }, function(response) + if response.Code ~= XCode.Success then + XUiManager.TipCode(response.Code) + if failedCb then + failedCb() + end + return + end + CurrentChatChannelId = channelId + CsXGameEventManager.Instance:Notify(XEventId.EVENT_CHAT_CHANNEL_CHANGED) + if succeedCb then + succeedCb() + end + end) + end + + -- 登录初始化聊天频道 + function XChatManager.InitChatChannel() + XNetwork.Call(MethodName.EnterWorldChatRequest, {}, function(response) + if response.Code ~= XCode.Success then + XUiManager.TipCode(response.Code) + return + end + CurrentChatChannelId = response.ChannelId + 1 + CsXGameEventManager.Instance:Notify(XEventId.EVENT_CHAT_CHANNEL_CHANGED) + end) + end + local RecruitChannelId = -1 + -- 获取频道消息 + function XChatManager.GetWorldChannelInfos(cb) + XNetwork.Call(MethodName.GetWorldChannelInfoRequest, {}, function(response) + if response.Code ~= XCode.Success then + XUiManager.TipCode(response.Code) + return + end + + ChatChannelInfos = response.ChannelInfos + local lastIndex = #ChatChannelInfos + for index, v in pairs(ChatChannelInfos) do + v.ChannelId = v.ChannelId + 1 + if index == lastIndex then v.IsRecruitChannel = true end + end + RecruitChannelId = lastIndex + if cb then + cb(ChatChannelInfos) + end + end) + end + + function XChatManager.GetRecruitChannelId() + return RecruitChannelId + end + + function XChatManager.GetAllChannelInfos() + return ChatChannelInfos + end + + function XChatManager.OnChatChannelChanged(notifyData) + if not notifyData then return end + local notifyChannelId = notifyData.ChannelId + 1 + if CurrentChatChannelId ~= notifyChannelId then + CurrentChatChannelId = notifyChannelId + CsXGameEventManager.Instance:Notify(XEventId.EVENT_CHAT_SERVER_CHANNEL_CHANGED, notifyChannelId) + end + end + + function XChatManager.UpdateGiftResetTime(resetTime) + TodayResetTime = resetTime + end + + function XChatManager.CheckHasGift() + for _, chatInfo in pairs(PrivateChatMap) do + for _, chat in pairs(chatInfo.ChatMap) do + if chat.MsgType == ChatMsgType.Gift and chat.GiftStatus == ChatGiftState.WaitReceive and chat.SenderId ~= XPlayer.Id then + return true + end + end + end + + return false + end + + function XChatManager.UpdateGiftStatus() + for _, chatInfo in pairs(PrivateChatMap) do + for _, chat in pairs(chatInfo.ChatMap) do + if TodayResetTime > 0 + and chat.MsgType == ChatMsgType.Gift + and chat.GiftStatus == ChatGiftState.WaitReceive + and chat.CreateTime < (TodayResetTime - ONE_DAY_SECONDS) then + chat.GiftStatus = ChatGiftState.Fetched + end + end + end + end + + -- 创建礼物文本 + function XChatManager.CreateGiftTips(chatData) + if not chatData then + return "" + end + + -- 发礼物提示 + if chatData.GiftStatus == ChatGiftState.WaitReceive then + if chatData.SenderId == XPlayer.Id then + local friend = XDataCenter.SocialManager.GetFriendInfo(chatData.TargetId) + if friend then + local name = XDataCenter.SocialManager.GetPlayerRemark(chatData.TargetId, chatData.NickName) + return CS.XTextManager.GetText("GiftMoneySendNotReceive", name, chatData.GiftCount) + end + else + local name = XDataCenter.SocialManager.GetPlayerRemark(chatData.SenderId, chatData.NickName) + return CS.XTextManager.GetText("GiftMoneyReceiveNotReceive", name, chatData.GiftCount) + end + -- 领礼物提示 + elseif chatData.GiftStatus == ChatGiftState.Received then + -- 自己领礼物 + if chatData.SenderId ~= XPlayer.Id then + local friend = XDataCenter.SocialManager.GetFriendInfo(chatData.SenderId) + local name = XDataCenter.SocialManager.GetPlayerRemark(chatData.SenderId, chatData.NickName) + if friend then + return CS.XTextManager.GetText("GiftMoneyReceiveHaveReceive", name, chatData.GiftCount) + else + return CS.XTextManager.GetText("GiftMoneyReceiveHaveReceive", "", chatData.GiftCount) + end + else + -- 别人领礼物 + local friend = XDataCenter.SocialManager.GetFriendInfo(chatData.TargetId) + local name = XDataCenter.SocialManager.GetPlayerRemark(chatData.TargetId, chatData.NickName) + if friend then + return CS.XTextManager.GetText("GiftMoneySendHaveReceive", name, chatData.GiftCount) + end + end + end + return "" + end + + function XChatManager.ProcessExtraContent(chatData) + if not chatData then + return + end + + local customContent = XMessagePack.Decode(chatData.CustomContent) + if not customContent then + return + end + + if string.find(chatData.Content, "room") then + chatData.Content = string.gsub(chatData.Content, "room", customContent) + end + end + + function XChatManager.NotifyChatMessage(chatData) + XChatManager.ProcessExtraContent(chatData) + XChatManager.OnSynChat(chatData) + + XEventManager.DispatchEvent(XEventId.EVENT_CHAT_MSG_SYNC) + end + + function XChatManager.NotifyPrivateChat(chatData) + if not chatData or not chatData.ChatMessages then + return + end + + if XDataCenter.SocialManager.GetBlackData(chatData.SenderId) then + return + end + + local lastChatMsg + for _, chatMsg in ipairs(chatData.ChatMessages) do + lastChatMsg = XChatData.New(chatMsg) + XChatManager.ProcessExtraContent(chatMsg) + XChatManager.OnSynChat(chatMsg, true) + end + XEventManager.DispatchEvent(XEventId.EVENT_CHAT_MSG_SYNC) + + if lastChatMsg then + XEventManager.DispatchEvent(XEventId.EVENT_CHAT_RECEIVE_PRIVATECHAT, lastChatMsg) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_CHAT_RECEIVE_PRIVATECHAT, lastChatMsg) + end + end + + function XChatManager.NotifyWorldChat(chatData) + if not chatData or not chatData.ChatMessages then + return + end + local lastChatMsg + for _, chatMsg in ipairs(chatData.ChatMessages) do + if not XDataCenter.SocialManager.GetBlackData(chatMsg.SenderId) then + XChatManager.ProcessExtraContent(chatMsg) + lastChatMsg = XChatData.New(chatMsg) + HandleWorldChat(lastChatMsg) + end + end + + if lastChatMsg then + XEventManager.DispatchEvent(XEventId.EVENT_CHAT_RECEIVE_WORLD_MSG, lastChatMsg) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_CHAT_RECEIVE_WORLD_MSG, lastChatMsg) + end + end + + function XChatManager.NotifyMentorChat(chatData) + if not chatData or not chatData.ChatMessages then + return + end + local lastChatMsg + for _, chatMsg in ipairs(chatData.ChatMessages) do + XChatManager.ProcessExtraContent(chatMsg) + lastChatMsg = XChatData.New(chatMsg) + HandleMentorChat(lastChatMsg) + end + + if lastChatMsg then + XEventManager.DispatchEvent(XEventId.EVENT_CHAT_RECEIVE_MENTOR_MSG, lastChatMsg) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_CHAT_RECEIVE_MENTOR_MSG, lastChatMsg) + end + end + + function XChatManager.NotifyChatEmoji(emojiData) + if not emojiData.Emoji then + return + end + + EmojiDatasDic[emojiData.Emoji.Id] = XChatEmoji.New(emojiData.Emoji) + end + + function XChatManager.NotifyChatLoginData(loginData) + TodayResetTime = loginData.RefreshTime + + for __, v in pairs(loginData.UnlockEmojis) do + EmojiDatasDic[v.Id] = XChatEmoji.New(v) + end + end + + XChatManager.Init() + return XChatManager +end + +--同步聊天 +XRpc.NotifyChatMessage = function(chatData) + XDataCenter.ChatManager.NotifyChatMessage(chatData) +end + +XRpc.NotifyPrivateChat = function(chatData) + XDataCenter.ChatManager.NotifyPrivateChat(chatData) +end + +XRpc.NotifyTodayGiftResetTime = function(notifyData) + XDataCenter.ChatManager.UpdateGiftResetTime(notifyData.ResetTime) +end + +XRpc.NotifyWorldChat = function(chatData) + XDataCenter.ChatManager.NotifyWorldChat(chatData) +end + +XRpc.NotifyMentorChat = function(chatData) + XDataCenter.ChatManager.NotifyMentorChat(chatData) +end + +-- 聊天频道切换 +XRpc.NotifyChatChannelChange = function(notifyData) + XDataCenter.ChatManager.OnChatChannelChanged(notifyData) +end + +XRpc.NotifyChatLoginData = function(loginData) + XDataCenter.ChatManager.NotifyChatLoginData(loginData) +end + +XRpc.NotifyChatEmoji = function(emojiData) + XDataCenter.ChatManager.NotifyChatEmoji(emojiData) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XChessPursuitManager.lua b/Resources/Scripts/XManager/XChessPursuitManager.lua new file mode 100644 index 00000000..82bebec2 --- /dev/null +++ b/Resources/Scripts/XManager/XChessPursuitManager.lua @@ -0,0 +1,1045 @@ +local XChessPursuitMapDb = require("XUi/XUiChessPursuit/XData/XChessPursuitMapDb") +local XChessPursuitMapBoss = require("XUi/XUiChessPursuit/XData/XChessPursuitMapBoss") +local XChessPursuitSyncActionQueue = require("XUi/XUiChessPursuit/XData/XChessPursuitSyncActionQueue") +local XChessPursuitRank = require("XUi/XUiChessPursuit/XData/XChessPursuitRank") +local XChessPursuitRankPlayer = require("XUi/XUiChessPursuit/XData/XChessPursuitRankPlayer") +local XChessPursuitRankGrid = require("XUi/XUiChessPursuit/XData/XChessPursuitRankGrid") +local XChessPursuitSyncAction = require("XUi/XUiChessPursuit/XData/XChessPursuitSyncAction") +local CSXTextManagerGetText = CS.XTextManager.GetText +local tableSort = table.sort + +XChessPursuitManagerCreator = function() + local XChessPursuitManager = {} + + local ChessPursuitRequest = { + ChessPursuitEnterMapRequest = "ChessPursuitEnterMapRequest", -- 进入图请求 + ChessPursuitSetGridTeamRequest = "ChessPursuitSetGridTeamRequest", -- 布阵请求 + ChessPursuitBuyCardRequest = "ChessPursuitBuyCardRequest", -- 购买卡牌请求 + ChessPursuitEndRoundRequest = "ChessPursuitEndRoundRequest", -- 结束回合请求 + ChessPursuitAutoFightRequest = "ChessPursuitAutoFightRequest", -- 自动战斗请求 + ChessPursuitResetMapRequest = "ChessPursuitResetMapRequest", -- 重置地图 + ChessPursuitAutoClearRequest = "ChessPursuitAutoClearRequest", -- 扫荡 + ChessPursuitEndBattleRequest = "ChessPursuitEndBattleRequest", -- 确认战斗结果 + ChessPursuitGetRankRequest = "ChessPursuitGetRankRequest", -- 请求排行榜数据 + ChessPursuitGetRankPlayerDetailRequest = "ChessPursuitGetRankPlayerDetailRequest", --请求排行榜上单个玩家的详细数据 + ChessPursuitChangeTeamRequest = "ChessPursuitChangeTeamRequest", --战斗前改变队伍 + } + + --面板上显示的位置 = 队伍中实际中的位置 + local TEAM_POS_DIC = { + [1] = 2, + [2] = 1, + [3] = 3, + } + + local ChessPursuitMapBossList = {} + local ChessPursuitMapDbList = {} + local ChessPursuitSyncActionQueue = XChessPursuitSyncActionQueue.New() + local ChessPursuitTempTeamDic = {} --缓存地图所有布阵格的队伍数据 + local CurrentMapId + local CurrentEndTime + local ChessPursuitRankDataList = {} + local ChessPursuitMyRank = -1 -- 服务端下发的主角排名,表示有多少人排名在我的前面 + local ChessPursuitAllRank = -1 -- 所有玩家的排名数量 + local ChessPursuitMyScore = 0 + local ChessPursuitRankGridList = {} --排行榜单个玩家详情的布阵格列表 + local ChessPursuitStartStoryId = CS.XGame.ClientConfig:GetString("ChessPursuitStartStoryId") + local ChessPursuitCoinItemData = {} + local PlayerTeamTempData --当前编队中的所有队伍缓存(只在编队界面中确定保存了,才会影响到ChessPursuitTempTeamDic) + local IsRegisterEditBattleProxy = false + local ChessPursuitRankDetailBossId = 0 + + local mathMax = math.max + local stringFormat = string.format + + XChessPursuitManager.ChessPursuitSyncActionType = { + None = 0, + --触发了卡牌效果 + CardEffect = 1, + --更新卡牌有效性计数 + KeepCount = 2, + --开始战斗 + BeginBattle = 3, + --结束战斗 + EndBattle = 4, + --确认结束,战斗对Boss造成伤害 + EndBattleHurt = 5, + --结束回合 + EndRound = 6, + --处于停顿移动 + StopMove = 7, + --移动到新位置 + Move = 8, + } + + local DefaultTeam = { + CaptainPos = 1, + FirstFightPos = 1, + TeamData = { 0, 0, 0 }, + } + + -------本地接口 begin-------- + local function InitPlayerTeamTempData(teamGridIndex) + if nil == PlayerTeamTempData then + local mapId = CurrentMapId or -1 + PlayerTeamTempData = XTool.Clone(ChessPursuitTempTeamDic[mapId] or {}) + end + + if (teamGridIndex) and (not PlayerTeamTempData[teamGridIndex]) then + PlayerTeamTempData[teamGridIndex] = XTool.Clone(DefaultTeam) + end + end + + local function GetPlayerTeamTempDataCharacterId(teamGridId, teamDataIndex) + InitPlayerTeamTempData() + local characterId = PlayerTeamTempData[teamGridId] and PlayerTeamTempData[teamGridId].TeamData and PlayerTeamTempData[teamGridId].TeamData[teamDataIndex] + return characterId or 0 + end + + local function GetPlayerTeamTempDataByTeamGridId(teamGridId) + InitPlayerTeamTempData() + return PlayerTeamTempData[teamGridId] and PlayerTeamTempData[teamGridId].TeamData + end + + local function GetPlayerTeamFirstFightPosByTeamGridId(teamGridId) + InitPlayerTeamTempData() + return PlayerTeamTempData[teamGridId] and PlayerTeamTempData[teamGridId].FirstFightPos + end + + local function GetPlayerTeamCaptainPosByTeamGridId(teamGridId) + InitPlayerTeamTempData() + return PlayerTeamTempData[teamGridId] and PlayerTeamTempData[teamGridId].CaptainPos + end + + --进入地图ChessPursuitTempTeamDic[mapId]为空 和 重置前缓存服务端的队伍数据 + local function BeforeResetSaveTeamTemp(mapId) + local chessPursuitMapDb = ChessPursuitMapDbList[mapId] + if not chessPursuitMapDb then + XLog.Error("重置前缓存服务端的队伍数据失败", mapId, ChessPursuitMapDbList) + return + end + + local gridTeamDb = chessPursuitMapDb:GetGridTeamDb() + if not ChessPursuitTempTeamDic[mapId] then + ChessPursuitTempTeamDic[mapId] = {} + end + + local teamDataClone + for teamGridIndex, teamData in ipairs(gridTeamDb) do + teamDataClone = XTool.Clone(DefaultTeam) + teamDataClone.TeamData = chessPursuitMapDb:GetTeamCharacterIds(teamGridIndex, true) + teamDataClone.CaptainPos = teamData.CaptainPos + teamDataClone.FirstFightPos = teamData.FirstFightPos + ChessPursuitTempTeamDic[mapId][teamGridIndex] = teamDataClone + end + end + -------本地接口 end-------- + + -- 退出追击玩法界面时要清理的数据 + function XChessPursuitManager.Clear() + ChessPursuitSyncActionQueue = XChessPursuitSyncActionQueue.New() + CurrentMapId = nil + CurrentEndTime = nil + XChessPursuitManager.ClearTempTeam() + end + + function XChessPursuitManager.InitMapData(res, isReset) + XChessPursuitManager.Clear(isReset) + + CurrentMapId = res.MapDb.Id + CurrentEndTime = XChessPursuitConfig.GetActivityEndTime() + + local chessPursuitMapBoss = XChessPursuitMapBoss.New(res.MapBoss) + local chessPursuitMapDb = XChessPursuitMapDb.New(res.MapDb) + + ChessPursuitMapDbList[chessPursuitMapDb:GetMapId()] = chessPursuitMapDb + ChessPursuitMapBossList[chessPursuitMapBoss:GetId()] = chessPursuitMapBoss + + ChessPursuitSyncActionQueue = XChessPursuitSyncActionQueue.New() + ChessPursuitSyncActionQueue:Push(res.Actions) + + XEventManager.DispatchEvent(XEventId.EVENT_CHESSPURSUIT_MAP_UPDATE) + end + + function XChessPursuitManager.RegisterEditBattleProxy() + if IsRegisterEditBattleProxy then return end + IsRegisterEditBattleProxy = true + XUiNewRoomSingleProxy.RegisterProxy(XDataCenter.FubenManager.StageType.ChessPursuit, + require("XUi/XUiChessPursuit/XUi/XUiChessPursuitNewRoomSingle")) + end + + function XChessPursuitManager.GetChessPursuitMapBoss(bossId) + return bossId and ChessPursuitMapBossList[bossId] + end + + function XChessPursuitManager.GetChessPursuitSyncActionQueue() + return ChessPursuitSyncActionQueue + end + + function XChessPursuitManager.GetChessPursuitMapDb(mapId) + if not mapId then + return + end + if not ChessPursuitMapDbList[mapId] then + ChessPursuitMapDbList[mapId] = XChessPursuitMapDb.New(mapId) + end + return ChessPursuitMapDbList[mapId] + end + + function XChessPursuitManager.RequestChessPursuitEnterMapData(mapId, cb) + XNetwork.Call(ChessPursuitRequest.ChessPursuitEnterMapRequest, { + MapId = mapId, + }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + XLog.Error("进入追击地图失败,mapId:,", mapId) + return + end + + XChessPursuitManager.InitMapData(res) + + if XTool.IsTableEmpty(ChessPursuitTempTeamDic[mapId]) then + BeforeResetSaveTeamTemp(mapId) + end + + if cb then + cb() + end + end) + end + + function XChessPursuitManager.RequestChessPursuitSetGridTeamData(mapId, cb) + local teamSet = {} + if ChessPursuitTempTeamDic[mapId] then + local config = XChessPursuitConfig.GetChessPursuitMapTemplate(mapId) + for teamGridId, cubeIndex in ipairs(config.TeamGrid) do + local curTeam = ChessPursuitTempTeamDic[mapId][teamGridId] + if not curTeam then + return false, CSXTextManagerGetText("ChessPursuitBuZhenEnterFailed") + elseif not XChessPursuitManager.IsCaptainCharacterIdInTempTeamData(mapId, teamGridId) then + return false, CSXTextManagerGetText("ChessPursuitNoCaptain", teamGridId) + elseif not XChessPursuitManager.IsFirstFightCharacterIdInTempTeamData(mapId, teamGridId) then + return false, CSXTextManagerGetText("ChessPursuitNoFirst", teamGridId) + else + local preFight = {} + preFight.CardIds = {} + preFight.CaptainPos = curTeam.CaptainPos + preFight.FirstFightPos = curTeam.FirstFightPos + preFight.RobotIds = {} + preFight.Id = config.TeamGrid[teamGridId] + preFight.HurtBoss = 0 + for _, v in pairs(curTeam.TeamData or {}) do + if not XRobotManager.CheckIsRobotId(v) then + table.insert(preFight.CardIds, v) + table.insert(preFight.RobotIds, 0) + else + table.insert(preFight.CardIds, 0) + table.insert(preFight.RobotIds, v) + end + end + table.insert(teamSet, preFight) + end + end + else + return false, CSXTextManagerGetText("ChessPursuitBuZhenEnterFailed") + end + + XMessagePack.MarkAsTable(teamSet) + XNetwork.Call(ChessPursuitRequest.ChessPursuitSetGridTeamRequest, { + TeamSet = teamSet + }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local chessPursuitMapDb = XDataCenter.ChessPursuitManager.GetChessPursuitMapDb(mapId) + if chessPursuitMapDb then + chessPursuitMapDb:SetGridTeamDb(res.TeamSet) + end + + if cb then + cb() + end + end) + + return true + end + + function XChessPursuitManager.RequestChessPursuitEndBattleRequest(cb) + XNetwork.Call(ChessPursuitRequest.ChessPursuitEndBattleRequest, nil, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + ChessPursuitSyncActionQueue:Push(res.Actions) + + if cb then + cb() + end + end) + end + + function XChessPursuitManager.RequestChessPursuitBuyCardData(cardCfgIds, cb) + XNetwork.Call(ChessPursuitRequest.ChessPursuitBuyCardRequest, {CardCfgIds = cardCfgIds}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + XUiManager.TipText("ChessPursuitShopBuyCompleteTips") + + local chessPursuitMapDb = XChessPursuitManager.GetChessPursuitMapDb(CurrentMapId) + chessPursuitMapDb:AddBuyedCards(res.CardIds) + chessPursuitMapDb:AddBuyedCardId(res.CardIds) + chessPursuitMapDb:SubCoin(res.SubCoin) + + XEventManager.DispatchEvent(XEventId.EVENT_CHESSPURSUIT_BUY_CARD) + + if cb then + cb() + end + end) + end + + function XChessPursuitManager.RequestChessPursuitEndRoundData(usedToGrid, usedToBoss, cb) + local params = { + UsedToGrid = usedToGrid or {}, + UsedToBoss = usedToBoss or {}, + } + XMessagePack.MarkAsTable(params.UsedToGrid) + XNetwork.Call(ChessPursuitRequest.ChessPursuitEndRoundRequest, params, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local chessPursuitMapDb = ChessPursuitMapDbList[CurrentMapId] + chessPursuitMapDb:RemoveCardsByUsedToGrid(res.UsedToGrid) + chessPursuitMapDb:RemoveCardsByUesdToBoss(res.UesdToBoss) + + chessPursuitMapDb:AddGridCardDb(res.UsedToGrid) + chessPursuitMapDb:AddBossCardDb(res.UesdToBoss) + ChessPursuitSyncActionQueue:Push(res.Actions) + + if cb then + cb(res.BossRandomStep) + end + end) + end + + function XChessPursuitManager.RequestChessPursuitAutoFightData(cb) + XNetwork.Call(ChessPursuitRequest.ChessPursuitAutoFightRequest, nil, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + ChessPursuitSyncActionQueue:Push(res.Actions) + + if cb then + cb() + end + end) + end + + function XChessPursuitManager.RequestChessPursuitResetMapData(cb, mapId) + BeforeResetSaveTeamTemp(mapId) + + XNetwork.Call(ChessPursuitRequest.ChessPursuitResetMapRequest, nil, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + XChessPursuitManager.InitMapData(res, true) + + if cb then + cb() + end + end) + end + + function XChessPursuitManager.RequestChessPursuitAutoClearData(cb) + XNetwork.Call(ChessPursuitRequest.ChessPursuitAutoClearRequest, nil, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + local chessPursuitMapDb = ChessPursuitMapDbList[CurrentMapId] + chessPursuitMapDb:AddBossBattleCount(res.AddBattleCount) + chessPursuitMapDb:SubBossHp(res.SubHp) + ChessPursuitSyncActionQueue:Push(res.Actions) + + if cb then + cb() + end + end) + end + + function XChessPursuitManager.RequestChessPursuitChangeTeam(gridIndex) + local teamTeamData = GetPlayerTeamTempDataByTeamGridId(gridIndex) + local firstFightPos = GetPlayerTeamFirstFightPosByTeamGridId(gridIndex) + local captainPos = GetPlayerTeamCaptainPosByTeamGridId(gridIndex) + local cardIds, robotIds = XChessPursuitManager.ClientTeamDataChangeServer(teamTeamData) + local params = { + FirstFightPos = firstFightPos, + CaptainPos = captainPos, + CardIds = cardIds, + RobotIds = robotIds + } + + XNetwork.Call(ChessPursuitRequest.ChessPursuitChangeTeamRequest, params, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local chessPursuitMapDb = ChessPursuitMapDbList[CurrentMapId] + chessPursuitMapDb:ChangeGridTeamDb(res) + XEventManager.DispatchEvent(XEventId.EVENT_CHESSPURSUIT_SAVETEAM) + end) + end + + function XChessPursuitManager.ClientTeamDataChangeServer(teamData) + local cardIds = {} + local robotIds = {} + for _, v in pairs(teamData or {}) do + if not XRobotManager.CheckIsRobotId(v) then + table.insert(cardIds, v) + table.insert(robotIds, 0) + else + table.insert(cardIds, 0) + table.insert(robotIds, v) + end + end + return cardIds, robotIds + end + + function XChessPursuitManager.ServerTeamDataChangeClient(cardIds, robotIds, isNotConverRobotId) + local teamData = {} + + for i, characterId in ipairs(cardIds or {}) do + -- 0即可能没有上阵或在RobotIds + if characterId ~= 0 then + teamData[i] = characterId + else + local robotId = robotIds and robotIds[i] or 0 + teamData[i] = isNotConverRobotId and robotId or XRobotManager.GetCharacterId(robotId) + end + end + + return teamData + end + + function XChessPursuitManager.NotifyChessPursuitBossAction(data) + ChessPursuitSyncActionQueue:Push(data.Actions) + end + + function XChessPursuitManager.RefreshDataByAction(action) + local chessPursuitMapDb = ChessPursuitMapDbList[CurrentMapId] + if not chessPursuitMapDb then + return + end + + if action:GetType() == XChessPursuitManager.ChessPursuitSyncActionType.CardEffect then + chessPursuitMapDb:SetBossMoveDirection(action:GetBossMoveDirection()) + chessPursuitMapDb:SetBossPos(action:GetBoosPos()) + chessPursuitMapDb:SetBossHp(action:GetBossHp()) + chessPursuitMapDb:AddBossCardDb(action:GetAddBossCard()) + elseif action:GetType() == XChessPursuitManager.ChessPursuitSyncActionType.KeepCount then + chessPursuitMapDb:RefreshKeepCount(action:GetCardId(), action:GetKeepCount()) + chessPursuitMapDb:SetBossMoveDirection(action:GetBossMoveDirection()) + elseif action:GetType() == XChessPursuitManager.ChessPursuitSyncActionType.EndBattle then + + elseif action:GetType() == XChessPursuitManager.ChessPursuitSyncActionType.EndBattleHurt then + local teamGridIndex = XChessPursuitConfig.GetTeamGridIndexByPos(CurrentMapId, action:GetBoosPos()) + chessPursuitMapDb:SetGridTeamDbHurtBoss(teamGridIndex, action:GetHurtBoss()) + chessPursuitMapDb:AddBossBattleCount(1) + chessPursuitMapDb:SetBossHp(action:GetBossHp()) + elseif action:GetType() == XChessPursuitManager.ChessPursuitSyncActionType.Move then + chessPursuitMapDb:SetBossPos(action:GetBoosPos()) + chessPursuitMapDb:SetBossMoveDirection(action:GetBossMoveDirection()) + elseif action:GetType() == XChessPursuitManager.ChessPursuitSyncActionType.EndRound then + chessPursuitMapDb:SetCoin(action:GetCoin()) + end + end + + function XChessPursuitManager.NotifyChessPursuitGroupInfo(data) + for i,mapDb in ipairs(data.MapDBList) do + local chessPursuitMapDb = XChessPursuitMapDb.New(mapDb) + ChessPursuitMapDbList[chessPursuitMapDb:GetMapId()] = chessPursuitMapDb + end + + + for i,mapBoss in ipairs(data.MapBossList) do + local chessPursuitMapBoss = XChessPursuitMapBoss.New(mapBoss) + ChessPursuitMapBossList[chessPursuitMapBoss:GetId()] = chessPursuitMapBoss + end + + XChessPursuitManager.RegisterEditBattleProxy() + XEventManager.DispatchEvent(XEventId.EVENT_CHESSPURSUIT_MAP_UPDATE) + end + + -- 从编队界面保存临时的队伍数据 + function XChessPursuitManager.SaveTempTeamData(mapId) + InitPlayerTeamTempData() + if not ChessPursuitTempTeamDic[mapId] then + ChessPursuitTempTeamDic[mapId] = {} + end + + local newTeamTemp = {} + for teamGridIndex, team in pairs(PlayerTeamTempData) do + newTeamTemp[teamGridIndex] = team + end + + ChessPursuitTempTeamDic[mapId] = newTeamTemp + XEventManager.DispatchEvent(XEventId.EVENT_CHESSPURSUIT_SAVETEAM) + XChessPursuitManager.ClearTempTeam() + end + + function XChessPursuitManager.GetSaveTempTeamData(mapId, teamGridIndex) + if ChessPursuitTempTeamDic[mapId] then + return XTool.Clone(ChessPursuitTempTeamDic[mapId][teamGridIndex]) + end + end + + function XChessPursuitManager.GetCaptainPosInTempTeamData(mapId, teamGridIndex) + local tempTeamData = XChessPursuitManager.GetSaveTempTeamData(mapId, teamGridIndex) + return tempTeamData and tempTeamData.CaptainPos or 1 + end + + function XChessPursuitManager.GetFirstFightPosInTempTeamData(mapId, teamGridIndex) + local tempTeamData = XChessPursuitManager.GetSaveTempTeamData(mapId, teamGridIndex) + return tempTeamData and tempTeamData.FirstFightPos or 1 + end + + function XChessPursuitManager.GetCharacterIdInTempTeamData(mapId, teamGridIndex, pos) + local tempTeamData = XChessPursuitManager.GetSaveTempTeamData(mapId, teamGridIndex) + return tempTeamData and tempTeamData.TeamData[pos] + end + + function XChessPursuitManager.IsCaptainCharacterIdInTempTeamData(mapId, teamGridIndex) + local tempTeamData = XChessPursuitManager.GetSaveTempTeamData(mapId, teamGridIndex) + return tempTeamData and tempTeamData.TeamData and tempTeamData.TeamData[tempTeamData.CaptainPos] and 0 ~= tempTeamData.TeamData[tempTeamData.CaptainPos] + end + + function XChessPursuitManager.IsFirstFightCharacterIdInTempTeamData(mapId, teamGridIndex) + local tempTeamData = XChessPursuitManager.GetSaveTempTeamData(mapId, teamGridIndex) + return tempTeamData and tempTeamData.TeamData and tempTeamData.TeamData[tempTeamData.FirstFightPos] and 0 ~= tempTeamData.TeamData[tempTeamData.FirstFightPos] + end + + function XChessPursuitManager.TeamPosConvert(index) + return TEAM_POS_DIC[index] + end + + --缓存正在编队中的临时队伍 + function XChessPursuitManager.SetPlayerTeamData(curTeam, mapId, teamGridId, isUsePrefab) + InitPlayerTeamTempData() + --检查其他位置有没一样的角色;使用队伍预设空掉其他位置一样的角色,否则交换角色位置 + for i, characterId in ipairs(curTeam.TeamData) do + local isInOtherTeam, teamGridIndex, teamDataIndex = XChessPursuitManager.CheckIsInChessPursuit(mapId, characterId, teamGridId) + if isInOtherTeam and PlayerTeamTempData[teamGridIndex] and PlayerTeamTempData[teamGridIndex].TeamData then + local oldCharacterId = isUsePrefab and 0 or GetPlayerTeamTempDataCharacterId(teamGridId, i) + PlayerTeamTempData[teamGridIndex].TeamData[teamDataIndex] = oldCharacterId + end + end + + PlayerTeamTempData[teamGridId] = XTool.Clone(curTeam) + end + + --快速编队界面,缓存的正在编队中的临时队伍 + function XChessPursuitManager.QuickDeploySetPlayerTeamData(teamDataList) + PlayerTeamTempData = XTool.Clone(teamDataList) + end + + function XChessPursuitManager.SetPlayerTeamDataFirstFightPos(firstFightPos, teamGridIndex) + InitPlayerTeamTempData(teamGridIndex) + if PlayerTeamTempData[teamGridIndex] then + PlayerTeamTempData[teamGridIndex].FirstFightPos = firstFightPos + end + end + + function XChessPursuitManager.SetPlayerTeamDataCaptainPos(captainPos, teamGridIndex) + InitPlayerTeamTempData(teamGridIndex) + if PlayerTeamTempData[teamGridIndex] then + PlayerTeamTempData[teamGridIndex].CaptainPos = captainPos + end + end + + --关闭编队界面时清理 + function XChessPursuitManager.ClearTempTeam() + PlayerTeamTempData = nil + end + + --检查角色是否在其他队伍中 + function XChessPursuitManager.CheckIsInChessPursuit(mapId, characterId, currTeamGridId) + if 0 == characterId then + return false + end + InitPlayerTeamTempData(mapId) + + if XTool.IsTableEmpty(PlayerTeamTempData) then + return false + end + for teamGridIndex, v in pairs(PlayerTeamTempData) do + if teamGridIndex ~= currTeamGridId then + for i, cId in ipairs(v.TeamData) do + if cId == characterId then + return true, teamGridIndex, i + end + end + end + end + return false + end + + --检查能否互相交换队伍中的角色 + function XChessPursuitManager.CheckIsSwapTeamPos(teamGridIdA, teamDataIndexA, teamGridIdB, teamDataIndexB) + if teamGridIdA == teamGridIdB then + return true + end + + local teamDataA = GetPlayerTeamTempDataByTeamGridId(teamGridIdA) + if not teamDataA then + return true + end + + local teamDataB = GetPlayerTeamTempDataByTeamGridId(teamGridIdB) + if not teamDataB then + return true + end + + local characterIdA = GetPlayerTeamTempDataCharacterId(teamGridIdA, teamDataIndexA) + characterIdA = XRobotManager.CheckIdToCharacterId(characterIdA) + if 0 ~= characterIdA then + for i, characterId in ipairs(teamDataB) do + if i ~= teamDataIndexB then + characterId = XRobotManager.CheckIdToCharacterId(characterId) + if characterIdA == characterId then + return false + end + end + end + end + + local characterIdB = GetPlayerTeamTempDataCharacterId(teamGridIdB, teamDataIndexB) + characterIdB = XRobotManager.CheckIdToCharacterId(characterIdB) + if 0 ~= characterIdB then + for i, characterId in ipairs(teamDataA) do + if i ~= teamDataIndexA then + characterId = XRobotManager.CheckIdToCharacterId(characterId) + if characterIdB == characterId then + return false + end + end + end + end + + return true + end + + function XChessPursuitManager.GetActivityChapters() + local chapters = {} + local config = XChessPursuitConfig.GetChessPursuitInTimeMapGroup() + + if config then + local tempChapter = { + Type = XDataCenter.FubenManager.ChapterType.ChessPursuit, + Id = config.Id, + } + + chapters = {tempChapter} + end + return chapters + end + + --@region FubenManager的引用函数(战斗) + + function XChessPursuitManager.InitStageInfo() + for i,v in ipairs(XChessPursuitConfig.GetAllChessPursuitBossTemplate()) do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(v.StageId) + stageInfo.Type = XDataCenter.FubenManager.StageType.ChessPursuit + stageInfo.ChapterName = v.Name + end + end + + function XChessPursuitManager.PushAction() + local res = XDataCenter.FubenManager.FubenSettleResult + if not res or not res.Settle then + return + end + + if res.Settle.ChessPursuitResult then + ChessPursuitSyncActionQueue:Push(res.Settle.ChessPursuitResult) + end + end + XEventManager.AddEventListener(XEventId.EVENT_FUBEN_SETTLE_REWARD, XChessPursuitManager.PushAction, XChessPursuitManager) + + function XChessPursuitManager.FinishFight(settle) + --当期活动已经结束 + local nowTime = XTime.GetServerNowTimestamp() + if (nowTime and CurrentEndTime and nowTime >= CurrentEndTime) or not settle.ChessPursuitResult[1] then + XDataCenter.FubenManager.ChallengeLose() + return + end + + local chessPursuitSyncAction = XChessPursuitSyncAction.New(settle.ChessPursuitResult[1]) + if chessPursuitSyncAction:GetIsForceExit() then + XDataCenter.FubenManager.ChallengeLose() + else + local chessPursuitMapTemplate = XChessPursuitConfig.GetChessPursuitMapTemplate(CurrentMapId) + local chessPursuitMapDb = XDataCenter.ChessPursuitManager.GetChessPursuitMapDb(CurrentMapId) + local bossPos = chessPursuitMapDb:GetBossPos() + local teamGridIndex = XChessPursuitConfig.GetTeamGridIndexByPos(CurrentMapId, bossPos) + + XLuaUiManager.Open("UiChessPursuitFightResult", { + MapId = CurrentMapId, + ChessPursuitSyncAction = chessPursuitSyncAction, + BossId = chessPursuitMapTemplate.BossId, + TeamGridIndex = teamGridIndex, + }) + end + end + + --@endregion + + function XChessPursuitManager.GetCoinCount(chessPursuitMapId) + local mapId = chessPursuitMapId or CurrentMapId + if not mapId then + return 0 + end + local chessPursuitMapDb = XChessPursuitManager.GetChessPursuitMapDb(mapId) + return chessPursuitMapDb:GetCoin() + end + + --@region 排行榜 + local function UpdatePlayerRankList(playerRankList) + ChessPursuitRankDataList = {} + for i, v in ipairs(playerRankList) do + if not ChessPursuitRankDataList[i] then + ChessPursuitRankDataList[i] = XChessPursuitRankPlayer.New() + end + ChessPursuitRankDataList[i]:UpdateData(v) + end + end + + function XChessPursuitManager.ChessPursuitGetRankRequest(cb) + local groupId = XChessPursuitConfig.GetCurrentGroupId() + XNetwork.Call(ChessPursuitRequest.ChessPursuitGetRankRequest, {GroupId = groupId}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + UpdatePlayerRankList(res.PlayerRank) + ChessPursuitMyRank = res.My --表示有多少人排名在我的前面,不等于我当前排第几名 + ChessPursuitAllRank = res.All + ChessPursuitMyScore = res.MyScore + if cb then + cb(groupId) + end + end) + end + + function XChessPursuitManager.GetRankDataList() + return ChessPursuitRankDataList + end + + function XChessPursuitManager.IsHasMyRank() + if ChessPursuitMyRank <= -1 then + return false + end + return true + end + + function XChessPursuitManager.GetChessPursuitMyRank() + local playerId = XPlayer.Id + local myRank = XChessPursuitManager.GetPursuitRankIndex(playerId) + return myRank + end + + function XChessPursuitManager.GetChessPursuitMyRankPercent() + if 0 == ChessPursuitAllRank or not XChessPursuitManager.IsHasMyRank() then + return 0 + end + --无人排在自己的前面返回1% + if 0 == ChessPursuitMyRank then + return 1 + end + return math.floor(ChessPursuitMyRank / ChessPursuitAllRank * 100) + end + + function XChessPursuitManager.GetChessPursuitAllRank() + return ChessPursuitAllRank + end + + function XChessPursuitManager.GetChessPursuitMyScore() + return mathMax(ChessPursuitMyScore, 0) + end + + function XChessPursuitManager.GetPursuitRankData(playerId) + for _, chessPursuitRankPlayer in ipairs(ChessPursuitRankDataList) do + if chessPursuitRankPlayer:IsCurPlayer(playerId) then + return chessPursuitRankPlayer + end + end + end + + function XChessPursuitManager.GetPursuitRankIndex(playerId) + for index, chessPursuitRankPlayer in ipairs(ChessPursuitRankDataList) do + if chessPursuitRankPlayer:IsCurPlayer(playerId) then + return index + end + end + end + + local function UpdateChessPursuitRankGridList(chessPursuitRankGridList) + ChessPursuitRankGridList = {} + for i, chessPursuitRankGridData in ipairs(chessPursuitRankGridList) do + if not ChessPursuitRankGridList[i] then + ChessPursuitRankGridList[i] = XChessPursuitRankGrid.New(chessPursuitRankGridData) + end + end + end + + local function UpdateChessPursuitRankDetailBossId(bossId) + if not bossId then return end + ChessPursuitRankDetailBossId = bossId + end + + function XChessPursuitManager.ChessPursuitGetRankPlayerDetailRequest(playerId, groupId) + XNetwork.Call(ChessPursuitRequest.ChessPursuitGetRankPlayerDetailRequest, {PlayerId = playerId, GroupId = groupId}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + UpdateChessPursuitRankGridList(res.Grids) + UpdateChessPursuitRankDetailBossId(res.BossId) + XLuaUiManager.Open("UiChessPursuitRankLineup", playerId, ChessPursuitRankGridList) + end) + end + + function XChessPursuitManager.GetChessPursuitRankDetailBossHp() + local chessPursuitMapBoss = XChessPursuitManager.GetChessPursuitMapBoss(ChessPursuitRankDetailBossId) + return chessPursuitMapBoss and chessPursuitMapBoss:GetInitHp() or 0 + end + + -- gridTeamIndex:第几号布阵格 + function XChessPursuitManager.IsRankCaptain(gridTeamIndex, characterId, playerId) + local chessPursuitRankPlayer = XChessPursuitManager.GetPursuitRankData(playerId) + if not chessPursuitRankPlayer then + return false + end + if chessPursuitRankPlayer:IsCaptain(gridTeamIndex, characterId) then + return true + end + return false + end + + function XChessPursuitManager.GetRankDetailCharacterLiberateLv(index, characterId) + local chessPursuitRankGrid = ChessPursuitRankGridList[index] + if chessPursuitRankGrid then + return chessPursuitRankGrid:GetCharacterLiberateLv(characterId) + end + return 0 + end + --@endregion + + --@region 商店 + function XChessPursuitManager.GetShopCardIdList(chessPursuitMapId) + local shopId = XChessPursuitConfig.GetChessPursuitMapShopCardId(chessPursuitMapId) + local shopCardIdList = XChessPursuitConfig.GetShopCardIdList(shopId) + local chessPursuitMapDb = XChessPursuitManager.GetChessPursuitMapDb(chessPursuitMapId) + tableSort(shopCardIdList, function(cardIdA, cardIdB) + local isBuyedCardA = chessPursuitMapDb:IsBuyedCard(cardIdA) + local isBuyedCardB = chessPursuitMapDb:IsBuyedCard(cardIdB) + if isBuyedCardA ~= isBuyedCardB then + return isBuyedCardB + end + + local cardQualityA = XChessPursuitConfig.GetCardQuality(cardIdA) + local cardQualityB = XChessPursuitConfig.GetCardQuality(cardIdB) + if cardQualityA ~= cardQualityB then + return cardQualityA > cardQualityB + end + + return cardIdA < cardIdB + end) + return shopCardIdList + end + + function XChessPursuitManager.IsBuyedCard(chessPursuitMapId, cardId) + local chessPursuitMapDb = XChessPursuitManager.GetChessPursuitMapDb(chessPursuitMapId) + return chessPursuitMapDb:IsBuyedCard(cardId) + end + --@endregion + + function XChessPursuitManager.GetSumCoinCount() + local groupId = XChessPursuitConfig.GetCurrentGroupId() + if not groupId then + return 0 + end + + local sum = 0 + local addCoinFunc = function(mapId) + local mapDb = XChessPursuitManager.GetChessPursuitMapDb(mapId) + if mapDb:IsKill() then + return XChessPursuitConfig.GetChessPursuitMapFinishAddCoin(mapId) + end + return 0 + end + + local mapIdList = XChessPursuitConfig.GetMapIdListByGroupId(groupId) + if XChessPursuitConfig.GetStageTypeByGroupId(groupId) == XChessPursuitCtrl.MAIN_UI_TYPE.STABLE then + for _, mapId in ipairs(mapIdList) do + sum = sum + addCoinFunc(mapId) + end + else + if mapIdList[1] then + local initFunc = XChessPursuitConfig.GetChessPursuitMapInitFuncList(mapIdList[1]) + local mapId + for _, funcId in ipairs(initFunc) do + if funcId > 0 and XChessPursuitConfig.IsMapInitFuncAddCoinType(funcId) then + mapId = XChessPursuitConfig.GetMapInitFuncMapId(funcId) + sum = sum + addCoinFunc(mapId) + end + end + end + end + return sum + end + + function XChessPursuitManager.IsCanTakeReward() + local groupId = XChessPursuitConfig.GetCurrentGroupId() + local mapsCfg = XChessPursuitConfig.GetChessPursuitMapsByGroupId(groupId) + + for _,cfg in ipairs(mapsCfg) do + if ChessPursuitMapDbList[cfg.Id] then + if ChessPursuitMapDbList[cfg.Id]:IsCanTakeReward() then + return true + end + end + end + end + + function XChessPursuitManager.CheckIsAutoPlayStory() + if not XSaveTool.GetData(stringFormat("%d%s%s", XPlayer.Id, "ChessPursuitIsAutoPlayStory", ChessPursuitStartStoryId)) then + XSaveTool.SaveData(stringFormat("%d%s%s", XPlayer.Id, "ChessPursuitIsAutoPlayStory", ChessPursuitStartStoryId), true) + XDataCenter.MovieManager.PlayMovie(ChessPursuitStartStoryId, XChessPursuitManager.CheckIsAutoShowHelp) + else + XChessPursuitManager.CheckIsAutoShowHelp() + end + end + + function XChessPursuitManager.CheckIsAutoShowHelp() + local config = XHelpCourseConfig.GetHelpCourseTemplateByFunction("ChessPursuit") + if not config then return end + + local id = config.Id + if not XSaveTool.GetData(stringFormat("%d%s%s", XPlayer.Id, "ChessPursuitIsAutoShowHelp", id)) then + XSaveTool.SaveData(stringFormat("%d%s%s", XPlayer.Id, "ChessPursuitIsAutoShowHelp", id), true) + XChessPursuitManager.OpenHelpTip() + end + end + + function XChessPursuitManager.OpenHelpTip() + local csXChessPursuitCtrlCom = XChessPursuitCtrl.GetCSXChessPursuitCtrlCom() + if not csXChessPursuitCtrlCom then + return + end + local chessPursuitDrawCamera = csXChessPursuitCtrlCom:GetChessPursuitDrawCamera() + local currCameraState = chessPursuitDrawCamera:GetChessPursuitCameraState() + chessPursuitDrawCamera:SwitchChessPursuitCameraState(CS.XChessPursuitCameraState.None) + XUiManager.ShowHelpTip("ChessPursuit", function() + chessPursuitDrawCamera:SwitchChessPursuitCameraState(currCameraState) + end) + end + + --活动简介界面的可挑战提醒 + function XChessPursuitManager.CheckIsCanFightTips() + local groupId = XChessPursuitConfig.GetCurrentGroupId() + local mapsCfg = XChessPursuitConfig.GetChessPursuitMapsByGroupId(groupId) + + for _,cfg in ipairs(mapsCfg) do + if XChessPursuitConfig.CheckChessPursuitMapIsOpen(cfg.Id) then + local chessPursuitMapDb = XDataCenter.ChessPursuitManager.GetChessPursuitMapDb(cfg.Id) + if not chessPursuitMapDb:IsKill() then + return true + end + end + end + end + + function XChessPursuitManager.GetBossHurMax(mapId, teamGridIndex) + local chessPursuitMapDb = XDataCenter.ChessPursuitManager.GetChessPursuitMapDb(mapId) + local hurtBoss = chessPursuitMapDb:GetHurtBossByGridId(teamGridIndex) + if hurtBoss and hurtBoss > 0 then + local chessPursuitMapTemplate = XChessPursuitConfig.GetChessPursuitMapTemplate(mapId) + local chessPursuitMapBoss = XDataCenter.ChessPursuitManager.GetChessPursuitMapBoss(chessPursuitMapTemplate.BossId) + local ration = hurtBoss / chessPursuitMapBoss:GetInitHp() + + return ration + else + return 0 + end + end + + function XChessPursuitManager.OpenCoinTip() + XLuaUiManager.Open("UiTip", ChessPursuitCoinItemData) + end + + -- 是否开放斗争期炼狱模式 + function XChessPursuitManager.IsOpenFightHeard() + local cfg = XChessPursuitConfig.GetChessPursuitMapByUiType(XChessPursuitCtrl.MAIN_UI_TYPE.FIGHT_HARD) + return XChessPursuitConfig.CheckChessPursuitMapIsOpen(cfg.Id) + end + + function XChessPursuitManager.SaveSaoDangIsAlreadyAutoOpen(mapId) + local key = string.format("ChessPursuitSaoDangIsAlreadyAutoOpen_%s_%s", mapId, XPlayer.Id) + XSaveTool.SaveData(key, true) + end + + function XChessPursuitManager.IsSaoDangAlreadyAutoOpen(mapId) + local key = string.format("ChessPursuitSaoDangIsAlreadyAutoOpen_%s_%s", mapId, XPlayer.Id) + if XSaveTool.GetData(key) then + return true + end + return false + end + + function XChessPursuitManager.RemoveSaoDangIsAlreadyAutoOpen(mapId) + local key = string.format("ChessPursuitSaoDangIsAlreadyAutoOpen_%s_%s", mapId, XPlayer.Id) + if XSaveTool.GetData(key) then + XSaveTool.RemoveData(key) + end + end + + local function InitChessPursuitCoinItemData() + local itemId = XChessPursuitConfig.SHOP_COIN_ITEM_ID + ChessPursuitCoinItemData = { + TemplateId = itemId, + IsTempItemData = true, + Name = XDataCenter.ItemManager.GetItemName(itemId), + Icon = XDataCenter.ItemManager.GetItemIcon(itemId), + Description = XDataCenter.ItemManager.GetItemDescription(itemId), + WorldDesc = XDataCenter.ItemManager.GetItemWorldDesc(itemId) + } + end + + local function Init() + InitChessPursuitCoinItemData() + end + Init() + + return XChessPursuitManager +end + +XRpc.NotifyChessPursuitBossAction = function(data) + XDataCenter.ChessPursuitManager.NotifyChessPursuitBossAction(data) +end + +XRpc.NotifyChessPursuitGroupInfo = function(data) + XDataCenter.ChessPursuitManager.NotifyChessPursuitGroupInfo(data) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XChristmasTreeManager.lua b/Resources/Scripts/XManager/XChristmasTreeManager.lua new file mode 100644 index 00000000..9a286e58 --- /dev/null +++ b/Resources/Scripts/XManager/XChristmasTreeManager.lua @@ -0,0 +1,528 @@ +local tableInsert = table.insert +local tableSort = table.sort + +XChristmasTreeManagerCreator = function () + local XChristmasTreeManager = {} + local ActivityInfo = nil + local OrnamentsPos = {} + local TempOrnamentsPos = {} + local PosChangeList = {} + local OrnamentsInfo = {} + local OrnamentsReadList = {} + local OrnamentsReadKey = "ChristmasTreeOrnamentRead" + local OpenKey = "ChristmasTreeOpen" + + local ACTIVITY_PROTO = { + ChristmasTreeActivityDataRequest = "ChristmasTreeActivityDataRequest", + ActiveOrnamentsRequest = "ActiveOrnamentsRequest", + ChangeOrnamentsRequest = "ChangeOrnamentsRequest", + } + + local function GetKey(keyword) + if not ActivityInfo then return end + return string.format("%d_%s_%d", XPlayer.Id, keyword, ActivityInfo.Id) + end + + function XChristmasTreeManager.Init() + local activityTemplates = XChristmasTreeConfig.GetActivityTemplates() + local nowTime = XTime.GetServerNowTimestamp() + for _, template in pairs(activityTemplates) do + local TimeId = template.TimeId + local startTime, endTime = XFunctionManager.GetTimeByTimeId(TimeId) + if nowTime > startTime and nowTime < endTime then + if not ActivityInfo then + ActivityInfo = XChristmasTreeConfig.GetActivityTemplateById(template.Id) + end + end + end + + if ActivityInfo then + XChristmasTreeManager.RequestData() + for _,ornament in pairs(XChristmasTreeConfig.GetOrnamentCfg()) do + XEventManager.AddEventListener(XEventId.EVENT_ITEM_COUNT_UPDATE_PREFIX .. ornament.SubItemId, XChristmasTreeManager.OnSubItemCountChange) + end + OrnamentsReadList = XSaveTool.GetData(GetKey(OrnamentsReadKey)) or OrnamentsReadList + end + end + + function XChristmasTreeManager.RequestData() + XNetwork.Call(ACTIVITY_PROTO.ChristmasTreeActivityDataRequest, {ActId = ActivityInfo.Id}, function (res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + XChristmasTreeManager.HandleData(res) + end) + end + + function XChristmasTreeManager.Reset(actId) + if actId then + ActivityInfo = XChristmasTreeConfig.GetActivityTemplateById(actId) + end + XChristmasTreeManager.ResetChange() + return ActivityInfo + end + + function XChristmasTreeManager.HandleData(data) + if data == nil then return end + + OrnamentsPos = data.Tree + for _, id in pairs(OrnamentsPos) do + if id and id ~= 0 then + OrnamentsReadList[id] = true + end + end + XChristmasTreeManager.SetOrnamentRead() + + OrnamentsInfo = {} + for _,id in ipairs(data.Ornaments) do + OrnamentsInfo[id] = true + end + end + + -- 获得临时布局位置(刚进入时获得已保存的位置) + function XChristmasTreeManager.GetCurrentOrnamentPos() + if not next(PosChangeList) then + return OrnamentsPos + end + + if not next(TempOrnamentsPos) then + TempOrnamentsPos = XTool.Clone(OrnamentsPos) + end + for partId, ornamentId in pairs(PosChangeList) do + TempOrnamentsPos[partId] = ornamentId + end + + return TempOrnamentsPos + end + + function XChristmasTreeManager.PutOrnament(partId ,ornamentId) + local isValid = false + for _, v in ipairs(XChristmasTreeConfig.GetOrnamentById(ornamentId).PartId) do + if v == partId then + isValid = true + break; + end + end + if isValid then + PosChangeList[partId] = ornamentId + XChristmasTreeManager.SetOrnamentRead(ornamentId) + return true + end + return false + end + + function XChristmasTreeManager.SwapOrnamentPos(partId1 ,partId2) + if XChristmasTreeConfig.GetGrpIdByTreePart(partId1) == XChristmasTreeConfig.GetGrpIdByTreePart(partId2) then + local tempPos = XChristmasTreeManager.GetCurrentOrnamentPos() + PosChangeList[partId1] = tempPos[partId2] or 0 + PosChangeList[partId2] = tempPos[partId1] or 0 + return true + end + return false + end + + function XChristmasTreeManager.RemoveOrnament(partId) + XChristmasTreeManager.SetOrnamentRead(PosChangeList[partId]) + PosChangeList[partId] = 0 + return true + end + + function XChristmasTreeManager.RemoveOrnamentGrp(grpId) + local partCount, partGrpCount = XChristmasTreeConfig.GetTreePartCount() + if not grpId or grpId > partGrpCount then + for partId = 1, partCount do + + PosChangeList[partId] = 0 + end + else + local partGrp = XChristmasTreeConfig.GetTreePartByGroup(grpId) + for _, part in ipairs(partGrp) do + PosChangeList[part.Id] = 0 + end + end + return true + end + + function XChristmasTreeManager.CheckPartGrpEmpty(grpId) + local _, partGrpCount = XChristmasTreeConfig.GetTreePartCount() + local tempPos = XChristmasTreeManager.GetCurrentOrnamentPos() + if not grpId or grpId > partGrpCount then + for _, v in pairs(tempPos) do + if v and v ~= 0 then + return false + end + end + else + local partGrp = XChristmasTreeConfig.GetTreePartByGroup(grpId) + for _, part in ipairs(partGrp) do + if tempPos[part.Id] and tempPos[part.Id] ~= 0 then + return false + end + end + end + return true + end + + function XChristmasTreeManager.CheckOrnamentGrpUnread(grpId) + if not ActivityInfo then return end + + local _, partGrpCount = XChristmasTreeConfig.GetTreePartCount() + if not grpId or grpId > partGrpCount then + for _, ornament in pairs(XChristmasTreeConfig.GetOrnamentCfg()) do + local id = ornament.Id + if XChristmasTreeManager.CheckOrnamentOwn(id) and not OrnamentsReadList[id] then + return true + end + end + else + --XLog.Warning("CheckOrnamentGrpUnread",OrnamentsInfo,grpId, OrnamentsReadList) + for _, ornament in pairs(XChristmasTreeConfig.GetOrnamentByGroup(grpId)) do + local id = ornament.Id + if XChristmasTreeManager.CheckOrnamentOwn(id) and not OrnamentsReadList[id] then + -- XLog.Warning(" true" .. grpId .. "") + return true + end + --XLog.Warning("single",grpId, XChristmasTreeManager.CheckOrnamentOwn(id), OrnamentsReadList[id]) + end + end + --XLog.Warning(" false" .. grpId .. "") + return false + end + + function XChristmasTreeManager.CheckOrnamentUnread(id) + return XChristmasTreeManager.CheckOrnamentOwn(id) and not OrnamentsReadList[id] + end + + function XChristmasTreeManager.SetOrnamentRead(id) + if id then + if OrnamentsReadList[id] or not OrnamentsInfo[id] then return end + OrnamentsReadList[id] = true + end + XSaveTool.SaveData(GetKey(OrnamentsReadKey), OrnamentsReadList) + XEventManager.DispatchEvent(XEventId.EVENT_CHRISTMAS_TREE_ORNAMENT_READ) + end + + function XChristmasTreeManager.CheckChange() + return next(PosChangeList) ~= nil + end + + function XChristmasTreeManager.SubmitChange(cb) + if not PosChangeList or not next(PosChangeList) then + XUiManager.TipMsg("変更なし") + return + end + local tempOrnamentsPos = XChristmasTreeManager.GetCurrentOrnamentPos() + XMessagePack.MarkAsTable(tempOrnamentsPos) + XNetwork.Call(ACTIVITY_PROTO.ChangeOrnamentsRequest, {Changes = tempOrnamentsPos}, function (res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + if res.Changes and next(res.Changes) then + XChristmasTreeManager.ApplyChange(res.Changes) + XChristmasTreeManager.ResetChange() + XEventManager.DispatchEvent(EVENT_CHRISTMAS_TREE_GOT_REWARD) + end + if cb then + cb() + end + end) + end + + function XChristmasTreeManager.ApplyChange(changes) + for partId, ornamentId in pairs(changes) do + OrnamentsPos[partId] = ornamentId + OrnamentsReadList[ornamentId] = true + end + XChristmasTreeManager.SetOrnamentRead() + end + + function XChristmasTreeManager.ResetChange() + PosChangeList = {} + TempOrnamentsPos = {} + end + + function XChristmasTreeManager.GetAttrName(index) + if ActivityInfo then + if index then + return ActivityInfo.AttrName[index] + else + return ActivityInfo.AttrName + end + end + return {} + end + + function XChristmasTreeManager.GetAttrDeltaValue() + local delta = {} + for i in ipairs(XChristmasTreeManager.GetAttrName()) do + delta[i] = 0 + end + + for partId, ornamentId in pairs(PosChangeList) do + local oldItem = XChristmasTreeConfig.GetOrnamentById(OrnamentsPos[partId]) + local newItem = XChristmasTreeConfig.GetOrnamentById(ornamentId) + if oldItem then + for i, v in ipairs(oldItem.Attr) do + delta[i] = delta[i] - v + end + end + if newItem then + for i, v in ipairs(newItem.Attr) do + delta[i] = delta[i] + v + end + end + end + + return delta + end + + function XChristmasTreeManager.GetAttrValue() + local value = {} + local countIndex = #ActivityInfo.AttrName + 1 + for i = 1, countIndex do + value[i] = 0 + end + for _, ornamentId in pairs(OrnamentsPos) do + local item = XChristmasTreeConfig.GetOrnamentById(ornamentId) + if item then + for i, v in ipairs(item.Attr) do + value[i] = value[i] + v + value[countIndex] = value[countIndex] + v + end + end + end + return value + end + + function XChristmasTreeManager.GetTempItemData(id) + local ornamentData = XChristmasTreeConfig.GetOrnamentById(id) + local itemId = ornamentData.ItemId + + -- 获取属性总分文本 + local attrHead = CS.XTextManager.GetText("ChristmasTreeOrnamentDescHead", + "\t\t\t\t", " ", XChristmasTreeConfig.GetAttrCount(ornamentData.Id)) + local list = {attrHead} + -- 获取单项属性文本 + for i, name in ipairs(XChristmasTreeManager.GetAttrName()) do + local attrInfo = string.format("%s %d", name, ornamentData.Attr[i]) + tableInsert(list, attrInfo) + end + -- 合并各属性文本 + local attrFull = table.concat(list, "\n\t\t\t\t\t") + + local data = XTool.Clone(XGoodsCommonManager.GetGoodsShowParamsByTemplateId(itemId)) + data.IsTempItemData = true + data.Count = XChristmasTreeManager.CheckOrnamentOwn(id) and "1" or "0" + data.Description = XGoodsCommonManager.GetGoodsDescription(itemId) + -- attrFull = string.gsub(attrFull, "\\t", "\t") + -- 合并世界观描述与属性描述文本 + data.WorldDesc = string.format("%s\n%s", XGoodsCommonManager.GetGoodsWorldDesc(itemId), attrFull) + return data + end + + + --排序 + local getSortFunc = function (sortType) + if not sortType or sortType == 0 then + return function(a, b) + return a.Id < b.Id + end + else + return function(a, b) + if a.Attr[sortType] ~= b.Attr[sortType] then + -- 按属性从大到小排序 + return a.Attr[sortType] > b.Attr[sortType] + else + -- 其次按 Id 从小到大排序 + return a.Id < b.Id + end + end + end + end + + function XChristmasTreeManager.GetAvailableOrnaments(grpId, sortType) + local list = {} + local rawData = nil + --if not grpId or grpId > PartGrpCount then + -- rawData = XChristmasTreeConfig.GetOrnamentCfg() + --else + rawData = XChristmasTreeConfig.GetOrnamentByGroup(grpId) or {} + --end + + for _, item in pairs(rawData) do + -- XChristmasTreeManager.CheckOrnamentOwn(item.Id) and + if XChristmasTreeManager.GetOrnamentAvailability(item.Id) then + tableInsert(list, item) + end + end + + if next(list) then + tableSort(list ,getSortFunc(sortType)) + end + + --XLog.Warning(grpId, sortType, list, OrnamentsInfo) + return list + end + + function XChristmasTreeManager.CheckOrnamentOwn(id) + return OrnamentsInfo[id] + end + + function XChristmasTreeManager.GetOrnamentAvailability(id) + for _, v in pairs(XChristmasTreeManager.GetCurrentOrnamentPos()) do + if v == id then + return false + end + end + return true + end + + function XChristmasTreeManager.GetActivityInfo() + return ActivityInfo + end + + function XChristmasTreeManager.CheckCanGetOrnament() + if not ActivityInfo then return false end + local minItemCount = XMath.IntMax() + local minItemId = nil + local isFull = true + for _, ornament in pairs(XChristmasTreeConfig.GetOrnamentCfg()) do + if not OrnamentsInfo[ornament.Id] then + if XDataCenter.ItemManager.CheckItemCountById(ornament.SubItemId, ornament.SubItemCount) then + return true, ornament.SubItemId, ornament.SubItemCount + elseif ornament.SubItemCount < minItemCount then + minItemCount = ornament.SubItemCount + minItemId = ornament.SubItemId + isFull = false + end + end + end + if isFull then + return false, XChristmasTreeConfig.GetOrnamentById(1).SubItemId, 0 + end + return false, minItemId, minItemCount + end + + function XChristmasTreeManager.OnSubItemCountChange() + XEventManager.DispatchEvent(XEventId.EVENT_CHRISTMAS_TREE_ORNAMENT_ACTIVE) + end + + function XChristmasTreeManager.CheckOrnamentFull() + for _,ornament in pairs(XChristmasTreeConfig.GetOrnamentCfg()) do + if not OrnamentsInfo[ornament.Id] then + return false + end + end + return true + end + + function XChristmasTreeManager.GetOrnamentCount() + local own, count = 0, 0 + for _,ornament in pairs(XChristmasTreeConfig.GetOrnamentCfg()) do + count = count + 1 + if OrnamentsInfo[ornament.Id] then + own = own + 1 + end + end + return own, count + end + + function XChristmasTreeManager.ActiveOrnament(id, cb) + XNetwork.Call(ACTIVITY_PROTO.ActiveOrnamentsRequest, {OrnamentId = id}, function (res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + -- 本地构造 + local rewardGoodsList = {{TemplateId = XChristmasTreeConfig.GetOrnamentById(res.OrnamentId).ItemId , RewardType = XRewardManager.XRewardType.Item, Count = 1}} + XUiManager.OpenUiObtain(rewardGoodsList) + OrnamentsInfo[res.OrnamentId] = true + XEventManager.DispatchEvent(XEventId.EVENT_CHRISTMAS_TREE_ORNAMENT_READ) + if cb then + cb() + end + end) + end + + --- 获取完成的挑战任务数与总数 + function XChristmasTreeManager.GetTaskProgress() + local taskIds = ActivityInfo.TaskId + local totalTaskNum = #taskIds + local finishNum = 0 + + if taskIds == nil or next(taskIds) == nil then + return + end + + for _, id in pairs(taskIds) do + if XDataCenter.TaskManager.CheckTaskFinished(id) then + finishNum = finishNum + 1 + end + end + + return finishNum, totalTaskNum + end + + --- 检查任务是否全部领取奖励 + function XChristmasTreeManager.CheckTaskAllFinish() + local taskIds = ActivityInfo.TaskId + + if taskIds == nil or next(taskIds) == nil then + return + end + + for _, id in pairs(taskIds) do + if not XDataCenter.TaskManager.CheckTaskFinished(id) then + return false + end + end + + return true + end + + --- 检查是否有奖励可以领取 + function XChristmasTreeManager.HasTaskReward() + if not ActivityInfo then return end + local taskIds = ActivityInfo.TaskId + + if taskIds == nil or next(taskIds) == nil then + return false + end + + for _, id in pairs(taskIds) do + -- XLog.Warning("HasTaskReward", id, XDataCenter.TaskManager.GetTaskDataById(id)) + if XDataCenter.TaskManager.CheckTaskAchieved(id) then + return true + end + end + + return false + end + + -- 判断是否为指定时间点后第一次打开 + function XChristmasTreeManager.CheckFirstOpen() + if not ActivityInfo then return end + local nowTime = XTime.GetServerNowTimestamp() + local lastOpen = XSaveTool.GetData(GetKey(OpenKey)) or 0 + local currentOpen = lastOpen + 1 + if lastOpen < #ActivityInfo.Time and nowTime > XTime.ParseToTimestamp(ActivityInfo.Time[currentOpen]) then + return true, currentOpen, ActivityInfo.StoryId[currentOpen] + else + return false + end + end + + -- 设置第一次打开 + function XChristmasTreeManager.SetOpen(currentOpen) + XSaveTool.SaveData(GetKey(OpenKey), tonumber(currentOpen)) + end + + XEventManager.AddEventListener(XEventId.EVENT_LOGIN_DATA_LOAD_COMPLETE, function() + XChristmasTreeManager.Init() + end) + + return XChristmasTreeManager +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XClickClearGameManager.lua b/Resources/Scripts/XManager/XClickClearGameManager.lua new file mode 100644 index 00000000..9e30917c --- /dev/null +++ b/Resources/Scripts/XManager/XClickClearGameManager.lua @@ -0,0 +1,510 @@ +local XClickClearGameRewardData = require("XEntity/XClickClearGame/XClickClearGameRewardData") + +XClickClearGameManagerCreator = function() + local tableInsert = table.insert + + local XClickClearGameManager = {} + + XClickClearGameManager.GeneralPanelStates = { + Default = 1, + Clearance = 2, + Failure = 3, + } + + XClickClearGameManager.GameState = { + Default = 1, -- 默认 + InitComplete = 2, -- 初始化完成 + Playing = 3, -- 游戏中 + Pause = 4, -- 暂停 + Account = 5 -- 结算 + } + + XClickClearGameManager.GameDifficultys = { + Simple = 1, + Complex = 2, + Difficult = 3, + Hell = 4, + } + + local GameInfo = { + CurGameState = XClickClearGameManager.GameState.Default, -- 游戏当前状态 + HeadNormalType = 0, -- 普通头像类型 + HeadNormalTargetCount = 0, -- 普通头像目标数量 + HeadNormalCurCount = 0, -- 普通头像当前找到数量 + HeadNormalDesc = "", -- 普通头像条件文字 + HeadSpecialType = 0, -- 特殊头像类型 + HeadSpecialTargetCount = 0, -- 特殊头像目标数量 + HeadSpecialCurCount = 0, -- 特殊头像当前找到数量 + HeadSpecialDesc = "", -- 特殊头像条件文字 + LimitTime = 0, -- 本关时间限制 + RemainTime = 0, -- 游戏剩余时间 + WrongCostTime = 0, -- 点错扣除的时间 + HeadInfoPageList = {}, -- 头像页信息列表 + HeadInfoPageCount = 0, -- 头像页页数 + CurrentHeadPageIndex = 0, -- 当前头像页序号 + CurrentHeadRealPageIndex = 1, -- 当前头像页真实列表序号(数组下标) + UseTime = 0, -- 结算用时 + IsNewRecord = false -- 是否是新记录 + } + + local PassTimeRecords = {} -- 保存的通关时间记录 + local ActivityData = {} + local ActivityId = 0 + local StartTime = 0 + local TakedRewardIds = {} + local RewardDataList = {} -- 奖励数据列表 + local IsTakeDifficultyBtnRedPointTable = {} -- 难度按钮红点是否被点击表 + + local CurrentGameDifficulty = XClickClearGameManager.GameDifficultys.Simple -- 当前难度 + + local CLICKCLEARGAME_PROTO = { + ClickClearGameStageRecordRequest = "ClickClearGameStageRecordRequest", + ClickClearGameStageGetRewardRequest = "ClickClearGameStageGetRewardRequest", + } + + function XClickClearGameManager.Init() + XClickClearGameManager.InitRewardDataList() + end + + function XClickClearGameManager.HandlerClickClearData(data) + local ActivityDatas = data.Activities + ActivityData = ActivityDatas[1] + if not ActivityData then + return + end + + ActivityId = ActivityData.Id + StartTime = ActivityData.StartTime + PassTimeRecords = ActivityData.BestRecords + TakedRewardIds = ActivityData.RewardIds + for _,v in pairs(RewardDataList) do + local gameStageId = v:GetGameStageId() + if TakedRewardIds[gameStageId] then + v:SetIsTaked(true) + else + v:SetIsTaked(false) + end + + if PassTimeRecords[gameStageId] and PassTimeRecords[gameStageId] > 0 then + v:SetCanTake(true) + else + v:SetCanTake(false) + end + end + end + + function XClickClearGameManager.GetRemainDaysStr() + local gameTemplates = XClickClearGameConfigs.GetGameTemplates() + if not gameTemplates or #gameTemplates <= 0 then + return false + end + + local gameTemplate = gameTemplates[1] + local nowTimeStamp = XTime.GetServerNowTimestamp() + local startTimeStamp = XTime.ParseToTimestamp(gameTemplate.StartTimeStr) + local endTimeStamp = XTime.ParseToTimestamp(gameTemplate.EndTimeStr) + if nowTimeStamp < startTimeStamp or nowTimeStamp > endTimeStamp then + return false + end + + local differenceTimeStamp = endTimeStamp - nowTimeStamp + local remainDaysStr = XUiHelper.GetTime(differenceTimeStamp, XUiHelper.TimeFormatType.ACTIVITY) + return true, remainDaysStr + end + + function XClickClearGameManager.CheckTabBtnByIndex(index) + local gameStageTemplate = XClickClearGameConfigs.GetGameStageTemplateById(index) + if not gameStageTemplate.UnlockCondition or gameStageTemplate.UnlockCondition == 0 then + return true + end + + return XConditionManager.CheckCondition(gameStageTemplate.UnlockCondition) + end + + function XClickClearGameManager.CheckTabBtnByLastDifficult(index) + if index == 1 then + return true + end + + local lastIndex = index - 1 + if PassTimeRecords[lastIndex] and PassTimeRecords[lastIndex] > 0 then + return true + end + + return false + end + + function XClickClearGameManager.GetCondetionDeseByIndex(index) + local gameStageTemplate = XClickClearGameConfigs.GetGameStageTemplateById(index) + if not gameStageTemplate.UnlockCondition or gameStageTemplate.UnlockCondition == 0 then + return "" + end + + return XConditionManager.GetConditionDescById(gameStageTemplate.UnlockCondition) + end + + function XClickClearGameManager.CheckPass(difficulty) + if PassTimeRecords[difficulty] and PassTimeRecords[difficulty] ~= 0 then + return true, PassTimeRecords[difficulty]/1000 + end + + return false + end + + function XClickClearGameManager.GetStageTagNameAndNameEnById(id) + local gameStageTemplate = XClickClearGameConfigs.GetGameStageTemplateById(id) + if not gameStageTemplate then + return nil + end + + return gameStageTemplate.Name, gameStageTemplate.NameEn + end + + function XClickClearGameManager.GetGameInfo() -- 获取游戏信息 + return GameInfo + end + + function XClickClearGameManager.GetHelpId() + local gameTemplates = XClickClearGameConfigs.GetGameTemplates() + if not gameTemplates or #gameTemplates <= 0 then + return 0 + end + + local gameTemplate = gameTemplates[1] + return gameTemplate.HelpId + end + + function XClickClearGameManager.GetCurGameDifficulty() + return CurrentGameDifficulty + end + + function XClickClearGameManager.SetCurGameDifficulty(difficulty) + CurrentGameDifficulty = difficulty + end + + function XClickClearGameManager.ResetGame() + XClickClearGameManager.ResetData() + CsXGameEventManager.Instance:Notify(XEventId.EVENT_CLICKCLEARGAME_GAME_RESET) + end + + function XClickClearGameManager.ResetData() + GameInfo = { + CurGameState = XClickClearGameManager.GameState.Default, + HeadNormalType = 0, + HeadNormalTargetCount = 0, + HeadNormalCurCount = 0, + HeadNormalDesc = "", + HeadSpecialType = 0, + HeadSpecialTargetCount = 0, + HeadSpecialCurCount = 0, + HeadSpecialDesc = "", + LimitTime = 0, + RemainTime = 0, + WrongCostTime = 0, + HeadInfoPageList = {}, + HeadInfoPageCount = 0, + CurrentHeadPageIndex = 0, + CurrentHeadRealPageIndex = 1, + IsNewRecord = false, + } + end + + function XClickClearGameManager.StartGame() + if not XClickClearGameManager.GetRemainDaysStr() then -- 活动结束 不可再开始游戏 + XUiManager.TipError(CS.XTextManager.GetText("ClickClearGameOver")) + return + end + + if not XClickClearGameManager.InitGame() then + return + end + + GameInfo.CurGameState = XClickClearGameManager.GameState.InitComplete + CsXGameEventManager.Instance:Notify(XEventId.EVENT_CLICKCLEARGAME_INIT_COMPLETE) + end + + function XClickClearGameManager.InitGame() + if not CurrentGameDifficulty then + return false + end + + local gameStage = XClickClearGameConfigs.GetGameStageTemplateById(CurrentGameDifficulty) + GameInfo.IsNewRecord = false + GameInfo.HeadNormalType = gameStage.HeadNormalType + GameInfo.HeadNormalTargetCount = gameStage.HeadNormalCount + GameInfo.HeadNormalDesc = gameStage.NormalTypeDesc + GameInfo.HeadNormalCurCount = 0 + GameInfo.HeadSpecialType = gameStage.HeadSpecialType + GameInfo.HeadSpecialTargetCount = gameStage.HeadSpecialCount + GameInfo.HeadSpecialDesc = gameStage.SpecialTypeDesc + GameInfo.HeadSpecialCurCount = 0 + GameInfo.LimitTime = gameStage.TimeLimit + GameInfo.RemainTime = gameStage.TimeLimit + GameInfo.WrongCostTime = gameStage.WrongCostTime + GameInfo.HeadInfoPageList = {} + + local pageListIdStr = gameStage.PageList + for _,v in pairs(pageListIdStr) do + local pageIdList = string.ToIntArray(v) + local randomPageIndex = math.random(1, #pageIdList) + local pageId = pageIdList[randomPageIndex] + local headInfoList = {} + + local pageTemplate = XClickClearGameConfigs.GetPageTemplateById(pageId) + local rowNumberList = pageTemplate.RowNumber + for _,v in pairs(rowNumberList) do + local rowNumberIdList = string.ToIntArray(v) + local randomRowIndex = math.random(1, #rowNumberIdList) + local rowId = rowNumberIdList[randomRowIndex] + + local rowTemplate = XClickClearGameConfigs.GetRowTemplateById(rowId) + local headIdList = rowTemplate.HeadId + for _,v in pairs(headIdList) do + local headTypeList = XClickClearGameConfigs.GetHeadTypeListByType(v) + local headIndex = math.random(1, #headTypeList) + local headTemplate = XClickClearGameConfigs.GetHeadTemplateById(headTypeList[headIndex]) + local headInfo = {} + headInfo.Type = headTemplate.Type + headInfo.Url = headTemplate.Url + headInfo.IsBeCatched = false + + tableInsert(headInfoList, headInfo) + end + end + + tableInsert(GameInfo.HeadInfoPageList, headInfoList) + end + + GameInfo.HeadInfoPageCount = #GameInfo.HeadInfoPageList + + return true + end + + function XClickClearGameManager.CalcRealIndex(index) + if index > 0 then + return math.fmod(index, GameInfo.HeadInfoPageCount) + 1 + elseif index == 0 then + return 1 + elseif index < 0 then + local abs = math.abs(index) + local fmodVal = math.fmod(abs, GameInfo.HeadInfoPageCount) + if fmodVal == 0 then + return 1 + else + return GameInfo.HeadInfoPageCount - fmodVal + 1 + end + end + end + + function XClickClearGameManager.GetNextPageIndex() + GameInfo.CurrentHeadPageIndex = GameInfo.CurrentHeadPageIndex + 1 + GameInfo.CurrentHeadRealPageIndex = XClickClearGameManager.CalcRealIndex(GameInfo.CurrentHeadPageIndex) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_CLICKCLEARGAME_GAME_PAGE_CHANGED) + return GameInfo.CurrentHeadPageIndex + end + + function XClickClearGameManager.GetLastPageIndex() + GameInfo.CurrentHeadPageIndex = GameInfo.CurrentHeadPageIndex - 1 + GameInfo.CurrentHeadRealPageIndex = XClickClearGameManager.CalcRealIndex(GameInfo.CurrentHeadPageIndex) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_CLICKCLEARGAME_GAME_PAGE_CHANGED) + return GameInfo.CurrentHeadPageIndex + end + + function XClickClearGameManager.OnTouchedHead(index, grid) + if GameInfo.CurGameState ~= XClickClearGameManager.GameState.Playing then + return + end + + local headInfo = GameInfo.HeadInfoPageList[GameInfo.CurrentHeadRealPageIndex][index] + if headInfo.IsBeCatched then + return + end + + if headInfo.Type ~= GameInfo.HeadNormalType and headInfo.Type ~= GameInfo.HeadSpecialType then + GameInfo.RemainTime = GameInfo.RemainTime - GameInfo.WrongCostTime + CsXGameEventManager.Instance:Notify(XEventId.EVENT_CLICKCLEARGAME_GAME_PAUSE, true) + return + end + + if headInfo.Type == GameInfo.HeadNormalType then + GameInfo.HeadNormalCurCount = GameInfo.HeadNormalCurCount + 1 + elseif headInfo.Type == GameInfo.HeadSpecialType then + GameInfo.HeadSpecialCurCount = GameInfo.HeadSpecialCurCount + 1 + end + + headInfo.IsBeCatched = true + grid.DisableAnimation.gameObject:PlayTimelineAnimation(function(state) + grid.HeadIcon.gameObject:SetActiveEx(false) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_CLICKCLEARGAME_HEAD_COUNT_CHANGED) + XClickClearGameManager.CheckWin() + end, nil) + + end + + function XClickClearGameManager.SetGameStatePlaying() + GameInfo.CurGameState = XClickClearGameManager.GameState.Playing + CsXGameEventManager.Instance:Notify(XEventId.EVENT_CLICKCLEARGAME_GAME_PLAYING) + end + + function XClickClearGameManager.SetGameStatePause() + GameInfo.CurGameState = XClickClearGameManager.GameState.Pause + CsXGameEventManager.Instance:Notify(XEventId.EVENT_CLICKCLEARGAME_GAME_PAUSE) + end + + function XClickClearGameManager.SetGameStateAccount(isWin) + GameInfo.CurGameState = XClickClearGameManager.GameState.Account + if isWin then + GameInfo.UseTime = GameInfo.LimitTime - GameInfo.RemainTime + if not PassTimeRecords[CurrentGameDifficulty] or GameInfo.UseTime < PassTimeRecords[CurrentGameDifficulty]/1000 then + PassTimeRecords[CurrentGameDifficulty] = GameInfo.UseTime * 1000 + local gameStageId = CurrentGameDifficulty + local bestRecord = math.ceil(PassTimeRecords[CurrentGameDifficulty]) + XNetwork.Call( CLICKCLEARGAME_PROTO.ClickClearGameStageRecordRequest, { GameStageId = gameStageId, BestRecord = bestRecord }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + end) + GameInfo.IsNewRecord = true + end + RewardDataList[CurrentGameDifficulty]:SetCanTake(true) + XEventManager.DispatchEvent(XEventId.EVENT_CLICKCLEARGAME_FINISHED_GAME) + end + CsXGameEventManager.Instance:Notify(XEventId.EVENT_CLICKCLEARGAME_GAME_PAUSE) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_CLICKCLEARGAME_GAME_ACCOUNT, isWin) + end + + function XClickClearGameManager.SetRemainTime(remainTime) + if remainTime < 0 then + remainTime = 0 + end + + GameInfo.RemainTime = remainTime + end + + function XClickClearGameManager.CheckHeadIsCatch(pageIndex, headIndex) + return GameInfo.HeadInfoPageList[pageIndex][headIndex].IsBeCatched + end + + function XClickClearGameManager.CheckWin() + if GameInfo.HeadNormalCurCount >= GameInfo.HeadNormalTargetCount and GameInfo.HeadSpecialCurCount >= GameInfo.HeadSpecialTargetCount then + XClickClearGameManager.SetGameStateAccount(true) + end + end + + function XClickClearGameManager.GetRewardList() + return RewardDataList + end + + function XClickClearGameManager.GetSortRewardList() + local isTakedRewardList = {} + local notTakedRewardList = {} + for _,v in pairs(RewardDataList) do + if v:CheckIsTaked() then + tableInsert(isTakedRewardList, v) + else + tableInsert(notTakedRewardList, v) + end + end + + for _,v in pairs(isTakedRewardList) do + tableInsert(notTakedRewardList, v) + end + + return notTakedRewardList + end + + function XClickClearGameManager.GetRewardData(gameStageId) + return RewardDataList[gameStageId] + end + + function XClickClearGameManager.InitRewardDataList() + RewardDataList = {} + local gameStageTemplates = XClickClearGameConfigs.GetGameStageTemplates() + for gameStageId,template in pairs(gameStageTemplates) do + local rewardId = template.RewardId + local rewardConditionDesc = template.RewardConditionDesc + local rewardData = XClickClearGameRewardData.New(gameStageId, rewardId, rewardConditionDesc) + if rewardData then + tableInsert(RewardDataList, rewardData) + end + end + end + + function XClickClearGameManager.GetRewardRequest(gameStageId, cb) + XNetwork.Call(CLICKCLEARGAME_PROTO.ClickClearGameStageGetRewardRequest, { GameStageId = gameStageId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + RewardDataList[gameStageId]:SetIsTaked(true) + XEventManager.DispatchEvent(XEventId.EVENT_CLICKCLEARGAME_TAKED_REWARD) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_CLICKCLEARGAME_TAKED_REWARD) + if cb then + cb(res.RewardGoodsList) + end + end) + end + + function XClickClearGameManager.GetRewardCount() + return #RewardDataList + end + + function XClickClearGameManager.GetRewardTakedCount() + local count = 0 + for _,v in pairs(RewardDataList) do + if v:CheckIsTaked() then + count = count + 1 + end + end + return count + end + + function XClickClearGameManager.GetRewardCanTakeCount() + local count = 0 + for _,v in pairs(RewardDataList) do + if v:CheckCanTake() then + count = count + 1 + end + end + return count + end + + function XClickClearGameManager.CheckDifficultyRedPoint(difficulty) + local isUnLock = XClickClearGameManager.CheckTabBtnByLastDifficult(difficulty) + local passTime = PassTimeRecords[difficulty] + if isUnLock and not IsTakeDifficultyBtnRedPointTable[difficulty] then + if not passTime or passTime == 0 then + return true + end + end + return false + end + + function XClickClearGameManager.CheckRewardRedPoint() + for _,v in pairs(RewardDataList) do + if v:CheckCanTake() and not v:CheckIsTaked() then + return true + end + end + + return false + end + + function XClickClearGameManager.SetTakeDifficultyBtnRedPoint(index, bool) + IsTakeDifficultyBtnRedPointTable[index] = bool + end + + function XClickClearGameManager.GetTakeDifficultyBtnRedPoint(index) + return IsTakeDifficultyBtnRedPointTable[index] + end + + XClickClearGameManager:Init() + + return XClickClearGameManager +end + +XRpc.NotifyClickClearData = function (data) + XDataCenter.XClickClearGameManager.HandlerClickClearData(data) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XCollectionWallManager.lua b/Resources/Scripts/XManager/XCollectionWallManager.lua new file mode 100644 index 00000000..7963e89c --- /dev/null +++ b/Resources/Scripts/XManager/XCollectionWallManager.lua @@ -0,0 +1,489 @@ +local XCollectionWall = require("XEntity/XCollectionWall/XCollectionWall") + +XCollectionWallManagerCreator = function() + local XCollectionWallManager = {} + + local METHOD_NAME = { + RequestEditCollectionWall = "EditCollectionWallRequest", -- 保存墙编辑 + RequestEditCollectionWallIsShow = "EditCollectionWallIsShowRequest", -- 保存展示设置 + } + + local WallEntity = {} -- 所有收藏品墙的数据,Id做索引 + local BackgroundIsUnLock = {} -- 墙面是否解锁,Id做索引 + local PedestalIsUnLock = {} -- 底座是否解锁,Id做索引 + + local LocalCaptureCache = {} -- 本地截图缓存 + + function XCollectionWallManager.Init() + -- 构建WallEntity + local collectionWallIdList = XCollectionWallConfigs.GetCollectionWallIdList() + for _, id in ipairs(collectionWallIdList) do + local collectionWall = XCollectionWall.New(id) + WallEntity[id] = collectionWall + end + + + -- 获取配置表数据,按种类来初始化饰品数据 + local backgroundDecorationList = XCollectionWallConfigs.GetColDecCfgListByType(XCollectionWallConfigs.EnumDecorationType.Background) + local pedestalDecorationList = XCollectionWallConfigs.GetColDecCfgListByType(XCollectionWallConfigs.EnumDecorationType.Pedestal) + + -- 全部初始化为未解锁 + for _, data in ipairs(backgroundDecorationList) do + BackgroundIsUnLock[data.Id] = false + end + for _, data in ipairs(pedestalDecorationList) do + PedestalIsUnLock[data.Id] = false + end + end + + --- + --- 使用服务器下发的数据来更新收藏品墙 + function XCollectionWallManager.SyncWallEntityData(dataList) + if dataList == nil then + XLog.Error("XCollectionWallManager.SyncWallEntityData函数错误,参数dataList为 nil") + return + end + + for _, data in pairs(dataList) do + -- 更新收藏品墙的状态 + XCollectionWallManager.UpdateWallEntityList(data.Id, data) + end + end + + --- + --- 使用服务器下发的数据来更新装饰品 + function XCollectionWallManager.SyncDecorationData(decorationsList) + if decorationsList == nil then + XLog.Error("XCollectionWallManager.SyncDecorationData函数错误,参数decorationsList为 nil") + return + end + + for _, id in pairs(decorationsList) do + local type = XCollectionWallConfigs.GetColDecType(id) + if type == XCollectionWallConfigs.EnumDecorationType.Background then + BackgroundIsUnLock[id] = true + elseif type == XCollectionWallConfigs.EnumDecorationType.Pedestal then + PedestalIsUnLock[id] = true + else + XLog.Error("XCollectionWallManager.SyncDecorationData函数错误,type不是XCollectionWallConfigs.EnumDecorationType类型的值") + end + end + end + + --- + --- 根据'data'的key来更新'wallId'收藏品墙数据实体(XCollectionWall)对应的属性 + --- 需要注意的是两者的key名称需要保持一致 + --- @param data table + function XCollectionWallManager.UpdateWallEntityList(wallId, data) + if WallEntity[wallId] == nil then + XLog.Error(string.format("XCollectionWallManager.GetWallEntityData函数错误,没有Id:%的收藏品实体数据", wallId)) + return + end + + if data == nil then + XLog.Error("XCollectionWallManager.GetWallEntityData函数错误,参数data为 nil") + return + end + WallEntity[wallId]:UpdateDate(data) + + if data.CollectionSetInfos then + local state + if next(data.CollectionSetInfos) == nil then + state = XCollectionWallConfigs.EnumWallState.None + else + state = XCollectionWallConfigs.EnumWallState.Normal + end + WallEntity[wallId]:UpdateDate({ State = state }) + end + end + + --- + --- 按Rank值排序'data',存放的值是XCollectionWall数据实体 + ---@param data table + function XCollectionWallManager.SortWallEntityByRank(data) + table.sort(data, function(a, b) + return a:GetRank() < b:GetRank() + end) + end + + --- + --- 获取所有收藏品墙的数据数组 + --- 按配置表Rank值排序 + ---@return table + function XCollectionWallManager.GetWallEntityList() + local result = {} + + if WallEntity == nil then + XLog.Error("XCollectionWallManager:GetWallEntityList函数错误:WallEntity为 nil") + return result + end + + for _, v in pairs(WallEntity) do + table.insert(result, v) + end + + XCollectionWallManager.SortWallEntityByRank(result) + return result + end + + --- + --- 获取已解锁并摆放了收藏品的收藏品墙数据数组 + --- 按配置表Rank值排序 + ---@return table + function XCollectionWallManager.GetNormalWallEntityList() + local result = {} + + if WallEntity == nil then + XLog.Error("XCollectionWallManager:GetNormalWallEntityList函数错误:WallEntity为 nil") + return result + end + + for _, v in pairs(WallEntity) do + if v.State == XCollectionWallConfigs.EnumWallState.Normal then + table.insert(result, v) + end + end + + XCollectionWallManager.SortWallEntityByRank(result) + return result + end + + --- + --- 获取'wallId'收藏品墙数据实体 + --- @param wallId number + function XCollectionWallManager.GetWallEntityData(wallId) + if WallEntity[wallId] == nil then + XLog.Error(string.format("XCollectionWallManager.GetWallEntityData函数错误,没有Id:%的收藏品实体数据", wallId)) + return nil + end + return WallEntity[wallId] + end + + --- + --- 根据'data'上的数据来获取对应的‘selectType’的数据数组 + ---'data'是当前墙上数据来生成的 + --- + --- 收藏品不显示正在使用与未解锁的,装饰品有使用与未解锁的状态 + --- 装饰品返回的结构:{ index = { Id, IsUnlock } } + --- 收藏品返回的是Id数组 + ---@param data table + ---@param selectType number + ---@return table + function XCollectionWallManager.GetItemList(data, selectType) + local result = {} + local isDecoration + if selectType == XCollectionWallConfigs.EnumSelectType.BACKGROUND then + isDecoration = true + for id,isUnlock in pairs(BackgroundIsUnLock) do + local temp = {} + temp.Id = id + temp.IsUnlock = isUnlock + table.insert(result, temp) + end + elseif selectType == XCollectionWallConfigs.EnumSelectType.PEDESTAL then + isDecoration = true + for id,isUnlock in pairs(PedestalIsUnLock) do + local temp = {} + temp.Id = id + temp.IsUnlock = isUnlock + table.insert(result, temp) + end + elseif selectType == XCollectionWallConfigs.EnumSelectType.BIG then + -- 质量为6的收藏品 + isDecoration = false + local list = XDataCenter.MedalManager.GetScoreTitleByQuality(6) + result = XCollectionWallManager.FilterUseCollection(data.CollectionSetInfos,list) + elseif selectType == XCollectionWallConfigs.EnumSelectType.MIDDLE then + -- 质量为5的收藏品 + isDecoration = false + local list = XDataCenter.MedalManager.GetScoreTitleByQuality(5) + result = XCollectionWallManager.FilterUseCollection(data.CollectionSetInfos,list) + elseif selectType == XCollectionWallConfigs.EnumSelectType.LITTL then + -- 质量为2、3、4的收藏品 + isDecoration = false + local list = XDataCenter.MedalManager.GetScoreTitleByQuality(2,4) + result = XCollectionWallManager.FilterUseCollection(data.CollectionSetInfos,list) + end + + if isDecoration then + table.sort(result, function(a, b) + local aRank = XCollectionWallConfigs.GetColDecRank(a.Id) + local bRank = XCollectionWallConfigs.GetColDecRank(b.Id) + if aRank == bRank then + return a.Id < b.Id + else + return aRank < bRank + end + end) + else + -- 过滤掉其他收藏品墙正在使用的收藏品 + result = XCollectionWallManager.FilterOtherUseCollection(data.Id, result) + + table.sort(result, function(a, b) + local aPriority = XMedalConfigs.GetCollectionPriorityById(a) + local bPriority = XMedalConfigs.GetCollectionPriorityById(b) + + if aPriority == bPriority then + return a < b + else + return aPriority < bPriority + end + end) + end + + return result + end + + --- + --- 过滤掉'collectionSetInfo'中使用的收藏品 + ---@param collectionSetInfo table + ---@param filterList table + ---@return table + function XCollectionWallManager.FilterUseCollection(collectionSetInfo, filterList) + local result = {} + + local useDic = {} -- id字典 + local useGroup = {} -- 组id字典,同一个组的收藏品视为同一个收藏品 + + for _, data in pairs(collectionSetInfo) do + useDic[data.Id] = true + local groupId = XMedalConfigs.GetCollectionGroupById(data.Id) + if groupId ~= 0 and not useGroup[groupId] then + useGroup[groupId] = data.Id + end + end + + -- 过滤掉使用着的收藏品 + for _, filter in pairs(filterList) do + if not useDic[filter.Id] then + local groupId = XMedalConfigs.GetCollectionGroupById(filter.Id) + if not useGroup[groupId] then + table.insert(result, filter.Id) + end + end + end + + return result + end + + --- + --- 过滤掉其他收藏品墙正在使用的收藏品 + --- 'filterList'为等待过滤的列表 + ---@param curWallDataId table + ---@param filterList table + ---@return table + function XCollectionWallManager.FilterOtherUseCollection(curWallDataId, filterList) + local result = {} + + local useDic = {} -- id字典 + local useGroup = {} -- 组id字典,同一个组的收藏品视为同一个收藏品 + + for _, wallData in pairs(WallEntity) do + if wallData:GetId() ~= curWallDataId then + local collectionInfo = wallData:GetCollectionSetInfos() + for _, info in pairs(collectionInfo) do + if useDic[info.Id] then + XLog.Error(string.format("XCollectionWallManager.FilterOtherUseCollection函数错误,有相同Id的收藏品被多个墙重复使用,ID:%s", info.Id)) + end + useDic[info.Id] = info + + local groupId = XMedalConfigs.GetCollectionGroupById(info.Id) + if groupId ~= 0 and not useGroup[groupId] then + useGroup[groupId] = info.Id + end + end + end + end + + -- 过滤掉使用着的收藏品 + for _, id in pairs(filterList) do + if not useDic[id] then + local groupId = XMedalConfigs.GetCollectionGroupById(id) + if not useGroup[groupId] then + table.insert(result, id) + end + end + end + + return result + end + + --- + --- 通过中心本地坐标获取左下角格子坐标 + --- GridPos = (CenterLocalPos - ItemSize/2) / GridSize + function XCollectionWallManager.GetGridPosByLocalPos(localPos, gridSize) + -- 利用中心本地坐标算出左下角本地坐标 + local leftBottomLocalPos = CS.UnityEngine.Vector2(localPos.x - gridSize / 2, localPos.y - gridSize / 2) + + -- 0.5是格子大小一半的偏移,使坐标的计算区域称向中心区域(超出这个区域,gridPos就换成其他坐标) + local gridPos = CS.UnityEngine.Vector2Int(math.floor((leftBottomLocalPos.x) / XCollectionWallConfigs.CellSize + 0.5), + math.floor(leftBottomLocalPos.y / XCollectionWallConfigs.CellSize + 0.5)); + return gridPos + end + + --- + --- 通过左下角格子坐标获取中心本地坐标 + --- CenterLocalPos = GirdPos * GridSize + ItemSize/2 + function XCollectionWallManager.GetLocalPosByGridPos(gridPos, gridSize) + local localPos + + -- 左下角本地坐标为格子坐标*格子长度 + local leftBottomLocalPos = CS.UnityEngine.Vector2(gridPos.x * XCollectionWallConfigs.CellSize, gridPos.y * XCollectionWallConfigs.CellSize) + + -- 中心本地坐标相对左下角本地坐标的偏移为物体尺寸的一半 + localPos = CS.UnityEngine.Vector2(leftBottomLocalPos.x + gridSize / 2, leftBottomLocalPos.y + gridSize / 2) + + return localPos + end + + function XCollectionWallManager.IsNeedSave(wallDataId, curWallData) + local wallData = XCollectionWallManager.GetWallEntityData(wallDataId) + local lastCollectionSetInfo = wallData:GetCollectionSetInfos() + + if #curWallData.CollectionSetInfos ~= #lastCollectionSetInfo then + return true + end + + -- 墙面与底面 + if curWallData.BackgroundId ~= wallData:GetBackgroundId() + or curWallData.PedestalId ~= wallData:GetPedestalId() then + return true + end + + -- 摆放的收藏品 + local curCollectionSetInfoDic = {} + for _, v in pairs(curWallData.CollectionSetInfos) do + curCollectionSetInfoDic[v.Id] = v + end + for _, v in pairs(lastCollectionSetInfo) do + local curCollection = curCollectionSetInfoDic[v.Id] + if curCollection == nil then + return true + end + + if v.X ~= curCollection.X or v.Y ~= curCollection.Y or v.SizeId ~= curCollection.SizeId then + return true + end + end + + return false + end + + function XCollectionWallManager.GetCaptureImgName(wallDataId) + return string.format("%s%s", tostring(XPlayer.Id), tostring(wallDataId)) + end + + function XCollectionWallManager.GetLocalCaptureCache(id) + local texture = LocalCaptureCache[id] + return texture or nil + end + + function XCollectionWallManager.SetLocalCaptureCache(id, texture) + LocalCaptureCache[id] = texture + end + + function XCollectionWallManager.ClearLocalCaptureCache() + for _, texture in pairs(LocalCaptureCache) do + if not XTool.UObjIsNil(texture) then + CS.UnityEngine.Object.Destroy(texture) + end + end + LocalCaptureCache = {} + end + + function XCollectionWallManager.CaptureCamera(imgName, cb) + if not imgName then + return nil + end + + CS.XScreenCapture.ScreenCaptureWithCallBack(CS.XUiManager.Instance.UiCamera,function(texture) + CS.XTool.SaveCaptureImg(imgName, texture); + XCollectionWallManager.SetLocalCaptureCache(imgName, texture) + if cb then + cb() + end + end) + end + + function XCollectionWallManager.GetShowWallList() + local result = {} + for _, wallData in pairs(WallEntity) do + if wallData:GetIsShow() then + local collectionInfo = wallData:GetCollectionSetInfos() + + if next(collectionInfo) then + table.insert(result, wallData) + end + end + end + return result + end + + ------------------------------------------------------------------ 请求协议 ------------------------------------------------------- + + --- + --- 请求保存收藏品墙的展示设置 + --- 'isShowInfos' = { Id, IsShow } + ---@param isShowInfos table + ---@param cb function + function XCollectionWallManager.RequestEditCollectionWallIsShow(isShowInfos, cb) + XNetwork.Call(METHOD_NAME.RequestEditCollectionWallIsShow, { CollectionWallIsShowInfos = isShowInfos }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + for _, showInfo in pairs(isShowInfos) do + XCollectionWallManager.UpdateWallEntityList(showInfo.Id, { IsShow = showInfo.IsShow }) + end + + if cb then + cb() + end + end) + end + + --- + --- 请求编辑收藏品墙,'wallId'是收藏品墙Id,'pedestalId'是底座Id,'backgroundId'是背景Id + --- 'setInfo'是收藏品信息,结构为{ Id, X, Y, SizeId } + ---@param wallId number + ---@param pedestalId number + ---@param backgroundId number + ---@param setInfo table + ---@param cb function + function XCollectionWallManager.RequestEditCollectionWall(wallId, pedestalId, backgroundId, setInfo, cb) + local req = { Id = wallId, PedestalId = pedestalId, BackgroundId = backgroundId, CollectionSetInfos = setInfo } + + local state + if next(setInfo) == nil then + state = XCollectionWallConfigs.EnumWallState.None + else + state = XCollectionWallConfigs.EnumWallState.Normal + end + + XNetwork.Call(METHOD_NAME.RequestEditCollectionWall, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XCollectionWallManager.UpdateWallEntityList(wallId, + { PedestalId = pedestalId, BackgroundId = backgroundId, State = state, CollectionSetInfos = setInfo }) + if cb then + cb() + end + end) + end + + XCollectionWallManager.Init() + return XCollectionWallManager +end + +-- 解锁底座或背景时推送(数据包括之前解锁的饰品) +XRpc.NotifyWallDecoration = function(data) + XDataCenter.CollectionWallManager.SyncDecorationData(data.UnlockedDecorationIds) +end + +-- 解锁收藏品墙时推送(数据只有新解锁的墙) +XRpc.NotifyWallInfo = function(data) + XDataCenter.CollectionWallManager.SyncWallEntityData(data.Walls) +end + diff --git a/Resources/Scripts/XManager/XComeAcrossManager.lua b/Resources/Scripts/XManager/XComeAcrossManager.lua new file mode 100644 index 00000000..d0071edf --- /dev/null +++ b/Resources/Scripts/XManager/XComeAcrossManager.lua @@ -0,0 +1,127 @@ + +XComeAcrossManagerCreator = function() + local XComeAcrossManager = {} + --更新冷却 + local GAME_REFRESH_TIME = 3600 + local GRID_COUNT_LIMIT = 5 -- 最多五个关卡 + + --上次更新的时间 + local LastRefreshTime = -1 + local LastReuslt = nil + local CurComeAcrossGames = nil + local PlayCount = 0 + local COMEACROSS_PROTO ={ + TrustGamePlayRequest = "TrustGamePlayRequest", + TrustGameResultRequest = "TrustGameResultRequest" + } + + --获取偶遇小游戏列表 + function XComeAcrossManager.GetComeAcrossGames() + if CurComeAcrossGames == nil or XTime.GetServerNowTimestamp() > LastRefreshTime + GAME_REFRESH_TIME then + + local ownsCharacter = XDataCenter.CharacterManager.GetOwnCharacterList() + if not ownsCharacter then + return false + end + + local charaterData = XComeAcrossManager.RandowGetOwnCharacter(ownsCharacter) + if not charaterData then + return false + end + + local count = #charaterData + CurComeAcrossGames = XComeAcrossConfig.RandomNumberGetGameConfig(count) + if CurComeAcrossGames then + for i,v in ipairs(CurComeAcrossGames) do + v.Character = charaterData[i] + end + end + + LastRefreshTime = XTime.GetServerNowTimestamp() + end + + return CurComeAcrossGames + end + + + --随机获取拥有的角色 + function XComeAcrossManager.RandowGetOwnCharacter(characters) + if not characters then + return + end + + if #characters <= GRID_COUNT_LIMIT then + return characters + end + + local chars = {} + for _ = 1, GRID_COUNT_LIMIT,1 do + local length = #characters + local rand = math.random(1,length) + local char = table.remove(characters, rand) + table.insert(chars, char) + end + + return chars + end + + --获取游戏次数 + function XComeAcrossManager.GetPlayCount() + return PlayCount + end + + --获取最近一次结算 + function XComeAcrossManager.GetLastResult() + return LastReuslt + end + + ------------------------------------------------ + --数据下发 + function XComeAcrossManager.NotifyTrustGameData(data) + if not data then + return + end + + PlayCount = data.TrustData.PlayCount + end + + --请求游戏开始 + function XComeAcrossManager.ReqTrustGamePlayRequest(cb) + XNetwork.Call(COMEACROSS_PROTO.TrustGamePlayRequest,nil, function(res) + if res.code ~= XCode.Success then + XUiManager.TipCode(res.code) + return + end + + if cb then + cb() + end + + PlayCount = PlayCount + 1 + XEventManager.DispatchEvent(XEventId.EVENT_COMEACROSS_PLAY) + end) + end + + --请求游戏结算 + function XComeAcrossManager.ReqTrustGameResultRequest(characterId,gameId,finishNum,cb) + XNetwork.Call(COMEACROSS_PROTO.TrustGameResultRequest,{CharacterId = characterId, GameId = gameId,FinishNum = finishNum }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + if cb then + cb(res) + end + + LastReuslt = res + XEventManager.DispatchEvent(XEventId.EVENT_COMEACROSS_PLAYRESULT) + end) + end + + return XComeAcrossManager +end + +XRpc.NotifyTrustGameData = function(data) + XDataCenter.ComeAcrossManager.NotifyTrustGameData(data) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XComposeGameManager.lua b/Resources/Scripts/XManager/XComposeGameManager.lua new file mode 100644 index 00000000..fa800dd8 --- /dev/null +++ b/Resources/Scripts/XManager/XComposeGameManager.lua @@ -0,0 +1,303 @@ +-- 组合小游戏管理器 +XComposeGameManagerCreator = function() + local XComposeGameManager = {} + --======================================== + --[[ + *********搜索以下关键字快速到达该类方法模块********* + =========协议数据结构 + =========成员变量 + =========字典 + =========初始化管理器,基础对象,对象刷新方法 + =========请求协议方法 + =========外部接口方法 + =========XRpc通知协议 + ]]-- + + --=============协议数据结构================ + + --======活动信息ComposeGameDataDb============= + -- 活动Id + -- int ActId + -- 当前进度 + -- int Schedule + -- 刷新次数 + -- int RefreshCount + -- 增加刷新次数时间戳(为 0 表示已达上限) + -- int RefreshTime + -- 商品列表 + -- List GoodsList + -- 商店列表 + -- List ShopInfos + -- 已领取奖励列表 + -- List RecvRewards + --============================================= + + --==========商品信息ComposeShopInfo============= + -- 标志Id + -- int Id + -- 商品Id + -- int Goods + -- 是否已出售 + -- bool IsSell + --============================================= + + --==========刷新商店数据ComposeRefreshData===== + -- 活动Id + -- int ActId + -- 今日刷新次数 + -- int RefreshCount + -- 增加刷新次数时间戳(为 0 表示已达上限) + -- int RefreshTime + --============================================== + + --==========背包物品列表信息ComposeGoodsInfo===== + -- 活动Id + -- int ActId + -- 背包物品列表 + -- List GoodsList + --============================================== + --============= END ================ + + --============成员变量============== + --================ + --是否从服务器接收了活动通知 + --================ + local ReceiveNotify = false + --================ + --活动对象集合 + --================ + local Games = {} + --============= END ================ + + --==============字典================ + --================ + --请求协议名称 + --================ + local REQUEST_NAMES = { --请求名称 + BuyShopGoods = "ComposeBuyShopGoodsRequest", -- 购买商店物品 + RefreshShopList = "ComposeFlushShopRequest", -- 刷新商店商品 + GetReward = "ComposeScheduleRewardRequest", -- 领取合成进度奖励 + } + --============= END ================ + + --==============玩法常量================ + --================ + --是否DEBUG模式(调试模式输出打印,取本地时间等) + --================ + XComposeGameManager.DEBUG_MODE = false + --================ + --背包格子数量 + --================ + XComposeGameManager.BAG_GRIDS_NUM = 8 + --============= END ================ + + --===================================== + --==============初始化管理器,活动对象处理方法================ + + --================ + --管理器初始化方法 + --================ + function XComposeGameManager.Init() + local config = XComposeGameConfig.GetDefaultConfig() + if config then + XComposeGameManager.DEBUG_MODE = config.DebugMode and config.DebugMode == 1 + end + end + --================ + --接收活动通知 + --================ + function XComposeGameManager.OnNotifyComposeActivityInfo(ComposeGameDataDb) + local game = Games[ComposeGameDataDb.ActId] + if not game then + XComposeGameManager.DebugLog( + "组合小游戏接收协议:NotifyComposeActivityInfo, 接收到新活动通知, 准备新增活动对象:", + ComposeGameDataDb + ) + XComposeGameManager.AddGame(ComposeGameDataDb) + else + XComposeGameManager.DebugLog( + "组合小游戏接收协议:NotifyComposeActivityInfo, 接收到活动刷新通知, 准备刷新活动对象:", + ComposeGameDataDb + ) + game:RefreshComposeGameData(ComposeGameDataDb) + end + end + --================ + --接收商店刷新数据ComposeRefreshData + --================ + function XComposeGameManager.OnNotifyComposeRefreshData(ComposeRefreshData) + local game = Games[ComposeRefreshData.ActId] + if not game then + XComposeGameManager.DebugLog("OnNotifyComposeFlushShopInfo错误,原因:找不到对应活动ID的活动对象。 ActId:" .. tostring(ComposeRefreshData.ActId)) + return + end + game:SetRefreshStatus(ComposeRefreshData) + end + --================ + --接收背包刷新数据ComposeGoodsInfo + --================ + function XComposeGameManager.OnNotifyComposeGoodsInfo(ComposeGoodsInfo) + local game = Games[ComposeGoodsInfo.ActId] + if not game then + XComposeGameManager.DebugLog("OnNotifyComposeGoodsInfo错误,原因:找不到对应活动ID的活动对象。 ActId:" .. tostring(ComposeGoodsInfo.ActId)) + return + end + game:SetRefreshStatus(ComposeGoodsInfo) + end + --================ + --添加一个新活动 + --================ + function XComposeGameManager.AddGame(ComposeGameDataDb) + local XComposeGame = require("XEntity/XMiniGame/ComposeFactory/XComposeGame") + if XComposeGame then + Games[ComposeGameDataDb.ActId] = XComposeGame.New(ComposeGameDataDb) + end + end + --================ + --Debug方法 + --================ + function XComposeGameManager.DebugLog(...) + if not XComposeGameManager.DEBUG_MODE then return end + XLog.Debug(...) + end + --============= END ================ + --==============外部接口方法================ + + --=============== + --根据活动ID获取活动对象 + --@param gameId:活动ID + --=============== + function XComposeGameManager.GetGameById(gameId) + local game = Games[gameId] + if not game then + XComposeGameManager.DebugLog("XComposeGameManager.GetGameById获取组合小游戏活动对象失败,GameId:", gameId) + return nil + end + XComposeGameManager.DebugLog("获取组合小游戏活动对象成功,GameId:", gameId) + return game + end + --================ + --判断是否第一次进入玩法(本地存储纪录) + --@param gameId:活动ID + --================ + function XComposeGameManager.GetIsFirstIn(gameId) + if not gameId then return false end + local localData = XSaveTool.GetData("ComposeGameFirstIn" .. XPlayer.Id .. tostring(gameId)) + if localData == nil then + XSaveTool.SaveData("ComposeGameFirstIn".. XPlayer.Id .. tostring(gameId), true) + return true + end + return false + end + --================ + --判断是否新获得道具 + --@param gameId:活动ID + --================ + function XComposeGameManager.GetItemIsNew(gameId, itemId) + local game = Games[gameId] + if not game then + XComposeGameManager.DebugLog("XComposeGameManager.GetGameById获取组合小游戏活动对象失败,GameId:", gameId) + return nil + end + XComposeGameManager.DebugLog("获取组合小游戏活动对象成功,GameId:", gameId) + return game:GetItemIsNew(itemId) + end + --=============== + --跳转到组合小游戏 + --@param gameId:活动ID + --=============== + function XComposeGameManager.JumpTo(gameId) + local game = XComposeGameManager.GetGameById(gameId) + if not game then return end + local canGoTo, notStart = game:CheckIsOpenTime() + if canGoTo then + XLuaUiManager.Open("UiComposeGame", gameId) + elseif notStart then + XUiManager.TipMsg(CS.XTextManager.GetText("ComposeGameNotStart")) + else + XUiManager.TipMsg(CS.XTextManager.GetText("ComposeGameNotInTime")) + end + end + + function XComposeGameManager.BuyItem(shopGrid) + local item = shopGrid:GetItem() + local game = Games[item:GetGameId()] + if not game then + XComposeGameManager.DebugLog("XComposeGameManager.BuyItem获取组合小游戏活动对象失败,GameId:", gameId) + return nil + end + local canBuy, desc = game:CheckCanBuyItem(item) + if canBuy then + XNetwork.Call(REQUEST_NAMES.BuyShopGoods, { ShopId = shopGrid:GetBuyId() }, function(reply) + if reply.Code ~= XCode.Success then + XUiManager.TipCode(reply.Code) + return + end + game:BuyItem(item:GetId()) + shopGrid:Buy() + CsXGameEventManager.Instance:Notify(XEventId.EVENT_COMPOSEGAME_BAGITEM_REFRESH) + end) + else + XUiManager.TipMsg(desc) + end + end + + function XComposeGameManager.RefreshShop(gameId) + local game = XComposeGameManager.GetGameById(gameId) + if not game then return end + local canRefresh = game:CheckCanRefresh() + if canRefresh then + XNetwork.Call(REQUEST_NAMES.RefreshShopList, {}, function(reply) + if reply.Code ~= XCode.Success then + XUiManager.TipCode(reply.Code) + return + end + game:RefreshShopInfoList(reply.ShopInfo) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_COMPOSEGAME_SHOP_ITEM_REFRESH) + end) + end + end + + function XComposeGameManager.GetReward(gameId, box) + XNetwork.Call(REQUEST_NAMES.GetReward, { Schedule = box:GetSchedule() }, function(reply) + if reply.Code ~= XCode.Success then + XUiManager.TipCode(reply.Code) + return + end + box:SetIsReceive(true) + XUiManager.OpenUiObtain(reply.RewardGoodsList) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_COMPOSEGAME_TREASURE_GET) + end) + end + --============= END ================ + XComposeGameManager.Init() + return XComposeGameManager +end +--======================================== +--=============XRpc通知协议================ +--====数据结构参照本文件的"协议数据结构"===== +--============== +--通知合成活动数据 +--@param ComposeGameDataDb:活动信息 +--============== +XRpc.NotifyComposeActivityData = function(ComposeGameDataDb) + XDataCenter.ComposeGameManager.DebugLog("接受到NotifyComposeActivityInfo数据,数据:", ComposeGameDataDb) + XDataCenter.ComposeGameManager.OnNotifyComposeActivityInfo(ComposeGameDataDb) +end +--============== +--通知刷新商店数据 +--@param ComposeFlushShopInfo:刷新商店数据 +--============== +XRpc.NotifyComposeRefreshData = function(ComposeRefreshData) + XDataCenter.ComposeGameManager.DebugLog("接受到NotifyComposeRefreshData数据,数据:", ComposeRefreshData) + XDataCenter.ComposeGameManager.OnNotifyComposeRefreshData(ComposeRefreshData) +end +--============== +--通知背包物品列表 +--@param composeGoodsInfo:背包物品列表 +--============== +XRpc.NotifyComposeGoodsData = function(ComposeGoodsInfo) + XDataCenter.ComposeGameManager.DebugLog("接受到NotifyComposeGoodsInfo数据,数据:", ComposeGoodsInfo) + --XDataCenter.ComposeGameManager.OnNotifyComposeGoodsInfo(ComposeGoodsInfo) +end +--============= END ================ \ No newline at end of file diff --git a/Resources/Scripts/XManager/XConditionManager.lua b/Resources/Scripts/XManager/XConditionManager.lua new file mode 100644 index 00000000..00461a22 --- /dev/null +++ b/Resources/Scripts/XManager/XConditionManager.lua @@ -0,0 +1,1332 @@ +local tableUnpack = table.unpack + +XConditionManager = XConditionManager or {} + +local TABLE_CONDITION_PATH = "Share/Condition/Condition.tab" +local ConditionTemplate = {} + +local DefaultRet = true + +XConditionManager.ConditionType = { + Unknown = 0, + Player = 1, + Character = 13, + Team = 18, + Kill = 30, + Equip = 31, + Activity = 40, + Formula = 41,--国服代码提前搬迁 +} + +local PlayerCondition +PlayerCondition = { + [10101] = function(condition) -- 查询玩家等级是否达标 + return XPlayer.Level >= condition.Params[1], condition.Desc + end, + [10102] = function(condition) -- 查询玩家是否拥有指定角色 + return XDataCenter.CharacterManager.IsOwnCharacter(condition.Params[1]), condition.Desc + end, + [10103] = function(condition) -- 查询玩家是否拥有指定数量的角色 + return #XDataCenter.CharacterManager.GetOwnCharacterList() >= condition.Params[1], condition.Desc + end, + [10104] = function(condition) -- 查询玩家背包是否有容量 + local ret, desc = PlayerCondition[12101](condition) + if not ret then + return ret, desc + end + + return PlayerCondition[12102](condition) + end, + [10105] = function(condition) -- 查询玩家是否通过指定得关卡 + local stageId = condition.Params[1] + -- local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + -- if stageInfo then + -- return stageInfo.Passed, condition.Desc + -- else + -- return true, condition.Desc + -- end + local flag = XDataCenter.FubenManager.CheckStageIsPass(stageId) + return flag, condition.Desc + end, + [10106] = function(condition)--至少拥有其中一个角色 + if condition.Params and #condition.Params > 0 then + for i = 1, #condition.Params do + local isOwnCharacter = XDataCenter.CharacterManager.IsOwnCharacter(condition.Params[i]) + if isOwnCharacter then + return true, condition.Desc + end + end + end + return false, condition.Desc + end, + [10107] = function(condition) -- 查询玩家等级是否小于等于n + return XPlayer.Level <= condition.Params[1], condition.Desc + end, + [10108] = function(condition) -- 查询玩家是否通过指定得关卡 + local stageId = condition.Params[1] + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + if stageInfo then + return (not stageInfo.Passed), condition.Desc + else + return false, condition.Desc + end + end, + [10109] = function(condition) --查询玩家是否拥有战力X的角色数量 + local needCount = condition.Params[1] + local needAbility = condition.Params[2] + local curCount = XDataCenter.CharacterManager.GetCharacterCountByAbility(needAbility) + if (curCount >= needCount) then + return true, condition.Desc + else + return false, condition.Desc + end + end, + [10110] = function(condition) -- 查询玩家是否有某个勋章 + return XPlayer.IsMedalUnlock(condition.Params[1]), condition.Desc + end, + [10111] = function(condition) -- 查询玩家是否完成过某个任务 + local task = XDataCenter.TaskManager.GetTaskDataById(condition.Params[1]) + return task and task.State == XDataCenter.TaskManager.TaskState.Finish or false, condition.Desc + end, + [10112] = function(condition) -- 单挑Boss奖励是否领取,活动是否开启 + local isCurActivity = XDataCenter.FubenActivityBossSingleManager.GetCurActivityId() == condition.Params[1] + local isFinish = XDataCenter.FubenActivityBossSingleManager.CheckRewardIsFinish(condition.Params[2]) + if XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.FubenActivitySingleBoss) and isFinish and isCurActivity then + return true, condition.Desc + end + return false, condition.Desc + end, + [10114] = function(condition) -- 世界boss属性关完成数量 + local worldBossActivity = XDataCenter.WorldBossManager.GetCurWorldBossActivity() + if worldBossActivity then + local finishStageCount = worldBossActivity:GetFinishStageCount() + if finishStageCount >= condition.Params[1] then + return true, condition.Desc + end + end + return false, condition.Desc + end, + [10115] = function(condition) -- 世界boss血量低于xx(百分比) + local bossArea = XDataCenter.WorldBossManager.GetBossAreaById(condition.Params[1]) + if bossArea then + local hpPercent = bossArea:GetHpPercent() + if hpPercent * 100 <= condition.Params[2] then + return true, condition.Desc + end + end + return false, condition.Desc + end, + [10118] = function(condition) -- 判断玩家是否完成预热关拼图 + local puzzleId = condition.Params[1] + if XDataCenter.FubenActivityPuzzleManager.GetPuzzleStateById(puzzleId) == XFubenActivityPuzzleConfigs.PuzzleState.Complete then + return true, condition.Desc + end + return false, condition.Desc + end, + [10119] = function(condition) -- 判断是否完成跑团(TRPG)某个目标 + local targetId = condition.Params[1] + if XDataCenter.TRPGManager.IsTargetFinish(targetId) then + return true, condition.Desc + end + return false, condition.Desc + end, + [10120] = function(condition) -- 判断尼尔角色等级是否达标 + local characterId = condition.Params[1] + local nieRCharacter = XDataCenter.NieRManager.GetNieRCharacterByCharacterId(characterId) + if nieRCharacter and (nieRCharacter:GetNieRCharacterLevel() >= condition.Params[2]) then + return true, condition.Desc + end + return false, condition.Desc + end, + [10121] = function(condition) -- 判断尼尔辅助机等级是否达标 + local targetLevel = condition.Params[1] + local nieRPOd = XDataCenter.NieRManager.GetNieRPODData() + if nieRPOd and (nieRPOd:GetNieRPODLevel() >= targetLevel) then + return true, condition.Desc + end + return false, condition.Desc + end, + [10122] = function(condition) -- 判断尼尔辅助机技能等级是否达标 + local skillId = condition.Params[1] + local skillLevel = condition.Params[2] + local nieRPOd = XDataCenter.NieRManager.GetNieRPODData() + if nieRPOd and (nieRPOd:GetNieRPODSkillLevelById(skillId) >= skillLevel) then + return true, condition.Desc + end + return false, condition.Desc + end, + + [10123] = function(condition) + local result = XDataCenter.RegressionManager.IsRegressionActivityOpen(XRegressionConfigs.ActivityType.Task) + return result, condition.Desc + end, + [10126] = function(condition)--玩家是否完成跑团(TRPG)某迷宫卡牌 + local mazeId = condition.Params[1] + local layerId = condition.Params[2] + local cardId = condition.Params[3] + if XDataCenter.TRPGManager.IsMazeCardFinished(mazeId, layerId, cardId) then + return true, condition.Desc + end + return false, condition.Desc + end, + [10127] = function(condition)--判断玩家合成小游戏活动进度是否达标 + local schedule = condition.Params[1] + local gameId = condition.Params[2] + local game = XDataCenter.ComposeGameManager.GetGameById(gameId) + if game then + local currentSchedule = game:GetCurrentSchedule() + return currentSchedule >= schedule, condition.Desc + end + return false, condition.Desc + end, + [10128] = function(condition)--超级据点拥有矿工数量 + local requireCount = condition.Params[1] or 0 + local haveCount = XDataCenter.StrongholdManager.GetMinerCount() + return haveCount >= requireCount, condition.Desc, haveCount, requireCount + end, + [10129] = function(condition)--超级据点拥有矿石数量 + local requireCount = condition.Params[1] + local haveCount = XDataCenter.StrongholdManager.GetTotalMineralCount() + return haveCount >= requireCount, condition.Desc, haveCount, requireCount + end, + [10130] = function(condition)--超级据点完成据点数量 + local requireCount = condition.Params[1] + local haveCount = XDataCenter.StrongholdManager.GetFinishGroupCount() + return haveCount >= requireCount, condition.Desc, haveCount, requireCount + end, + [10131] = function(condition)--超级据点完成某个据点 + local groupId = condition.Params[1] + local isfinished = XDataCenter.StrongholdManager.IsGroupFinished(groupId) + return isfinished, condition.Desc + end, + [10132] = function(condition)--超级据点矿石预计产出 + local requireCount = condition.Params[1] + local haveCount = XDataCenter.StrongholdManager.GetPredictTotalMineralCount() + return haveCount >= requireCount, condition.Desc, haveCount, requireCount + end, + [10133] = function(condition, ...)--超级据点队伍是否满员 + local args = { ... } + local teamList = args and args[1] + local isfinished = XDataCenter.StrongholdManager.CheckCurGroupTeamFull(teamList) + return isfinished, condition.Desc + end, + [10134] = function(condition, ...)--超级据点队伍列表平均战力是否符合要求 + local requireCount = condition.Params[1] + local args = { ... } + local teamList = args and args[1] + local isfinished, averageAbility = XDataCenter.StrongholdManager.CheckTeamListAverageAbility(requireCount, teamList) + return isfinished, condition.Desc .. "/" .. math.floor(averageAbility) + end, + [10135] = function(condition)--超级据点未完成某个据点 + local groupId = condition.Params[1] + local isfinished = XDataCenter.StrongholdManager.IsGroupFinished(groupId) + return not isfinished, condition.Desc + end, + [10139] = function(condition)--玩家是否未完成跑团(TRPG)某迷宫卡牌 + local mazeId = condition.Params[1] + local layerId = condition.Params[2] + local cardId = condition.Params[3] + if XDataCenter.TRPGManager.IsMazeCardFinished(mazeId, layerId, cardId) then + return false, condition.Desc + end + return true, condition.Desc + end, + [10140] = function(condition)--超级据点当前活动阶段是否满足任一参数(1, --开启中2, --战斗开启3, --战斗结束4, --已结束) + local isfinished = false + for _, status in pairs(condition.Params) do + if status > 0 and XDataCenter.StrongholdManager.CheckActivityStatus(status) then + isfinished = true + break + end + end + return isfinished, condition.Desc + end, + [10141] = function(condition)--Rpg爬塔玩法是否当前队伍等级高于参照值 + local needLevel = condition.Params[1] + local reachLevel = XDataCenter.RpgTowerManager.GetCurrentLevel() >= needLevel + return reachLevel, condition.Desc + end, + [10142] = function(condition)--是否拥有某个伙伴 + local templateId = condition.Params[1] + local IsUnLock = XDataCenter.ArchiveManager.GetPartnerUnLockById(templateId) + return IsUnLock, condition.Desc + end, + [10143] = function(condition)--是否完成翻牌小游戏某个关卡 + local activityId = condition.Params[1] + local stageId = condition.Params[2] + return XDataCenter.InvertCardGameManager.CheckActivityStageFinished(activityId, stageId), condition.Desc + end, + [10144] = function(condition) -- 判断杀戮无双难度星数 + local diff = condition.Params[1] + local star = condition.Params[2] + local curStar = XDataCenter.KillZoneManager.GetTotalStageStarByDiff(diff) + return curStar >= star, condition.Desc + end, + [10145] = function(condition) -- 判断超级爬塔通关目标关卡进度 + local targetStageId = condition.Params[1] + local progress = condition.Params[2] + local stageManager = XDataCenter.SuperTowerManager.GetStageManager() + if not stageManager then return false end + local stStage = stageManager:GetTargetStageByStStageId(targetStageId) + if not stStage then return false end + return stStage:GetCurrentProgress() >= progress, condition.Desc + end, + + [10146] = function(condition,...) -- 或条件判断通过,特定13章探索模型XX节点或通关指定id副本 + local tempCondition1 = {Params = {[1] = condition.Params[1]}} + local tempCondition2 = {Params = {[1] = condition.Params[2]}} + local ret1 = PlayerCondition[10105](tempCondition1) + local ret2 = PlayerCondition[10119](tempCondition2) + local ret = ret1 or ret2 + return ret, condition.Desc + end, + + [11101] = function(condition) -- 查询指定道具数量是否达标 + return XDataCenter.ItemManager.CheckItemCountById(condition.Params[1], condition.Params[2]), condition.Desc + end, + [11102] = function(condition)--查询玩家角色解放阶段是否达到 + return XDataCenter.ExhibitionManager.IsAchieveLiberation(condition.Params[1], condition.Params[2]), condition.Desc + end, + [11103] = function(condition) -- 查询玩家是否领取首充奖励 + return XDataCenter.PayManager.GetFirstRechargeReward(), condition.Desc + end, + [11104] = function(condition) -- 查询玩家是否拥有某个时装 + return XDataCenter.FashionManager.CheckHasFashion(condition.Params[1]), condition.Desc + end, + [11105] = function(condition) -- 查询玩家是否不拥有某个时装 + return not XDataCenter.FashionManager.CheckHasFashion(condition.Params[1]), condition.Desc + end, + [11106] = function(condition) -- 查询玩家是否通过某个试验区关卡(填试验区ID) + return XDataCenter.FubenExperimentManager.CheckExperimentIsFinish(condition.Params[1]), condition.Desc + end, + [11108] = function(condition) -- 查询玩家复刷关等级是否达到 + return XDataCenter.FubenRepeatChallengeManager.IsLevelReach(condition.Params[1]), condition.Desc + end, + [11109] = function(condition) -- 查询玩家在指定时间内通过某个关卡 + if not condition.Params or #condition.Params < 2 then + return false, condition.Desc + end + + local stageId = condition.Params[1] + local stageData = XDataCenter.FubenManager.GetStageData(stageId) + if not stageData then + return false, condition.Desc + end + + if stageData.BestRecordTime <= 0 or stageData.BestRecordTime > condition.Params[2] then + return false, condition.Desc + end + + return true, condition.Desc + end, + [11110] = function(condition) -- 查询玩家在本期巴别塔活动中的分数是否超过某个值 + + local count = condition.Params[1] + local _, maxLevel = XDataCenter.FubenBabelTowerManager.GetCurrentActivityScores() + + if maxLevel >= count then + return true, condition.Desc + end + return false, condition.Desc + end, + [11111] = function(condition) --查询当前爬塔达到的最高层数 + local curMaxTier = XDataCenter.FubenRogueLikeManager.GetHistoryMaxTier() + if condition and condition.Params[1] then + return curMaxTier >= condition.Params[1], condition.Desc + end + return false, condition.Desc + end, + [11112] = function(condition) --查询玩家是否拥有某个永久武器时装 + local id = condition.Params[1] + local ret = XDataCenter.WeaponFashionManager.CheckHasFashion(id) + and not XDataCenter.WeaponFashionManager.IsFashionTimeLimit(id) + return ret, condition.Desc + end, + [11113] = function(condition) --查询玩家是否不拥有某个永久武器时装 + local id = condition.Params[1] + local ret = not XDataCenter.WeaponFashionManager.CheckHasFashion(id) + or XDataCenter.WeaponFashionManager.IsFashionTimeLimit(id) + return ret, condition.Desc + end, + [11114] = function(condition)--查询玩家是否拥有一堆时装中的某一个 + local ret = false + for _, fashionId in pairs(condition.Params) do + ret = XDataCenter.WeaponFashionManager.CheckHasFashion(fashionId) + and not XDataCenter.WeaponFashionManager.IsFashionTimeLimit(fashionId) + if ret then + break + end + end + return ret, condition.Desc + end, + [11117] = function(condition)--查询玩家是否拥指定ID的场景 + local ret = false + ret = XDataCenter.PhotographManager.CheckSceneIsHaveById(condition.Params[1]) + return ret, condition.Desc + end, + [12101] = function(condition) -- 查询武器库是否有容量 + return XDataCenter.EquipManager.CheckMaxCount(XEquipConfig.Classify.Weapon), condition.Desc + end, + [12102] = function(condition) -- 查询意识库是否有容量 + return XDataCenter.EquipManager.CheckMaxCount(XEquipConfig.Classify.Awareness), condition.Desc + end, + [21101] = function(condition) -- 查询玩家是否购买月卡 + local isGot = true + local uiType = condition.Params[1] + local id = condition.Params[2] + if XDataCenter.PurchaseManager.IsYkBuyed(uiType, id) then + local data = XDataCenter.PurchaseManager.GetYKInfoData(uiType, id) + if data then + isGot = data.IsDailyRewardGet + end + end + return not isGot, condition.Desc + end, + [21102] = function(condition) -- 查询玩家是否未领取首充奖励 + return not XDataCenter.PayManager.GetFirstRechargeReward(), condition.Desc + end, + [22001] = function(condition) -- 红包活动ID下指定NPC累计获得的物品数量 + local count = condition.Params[1] + local itemId = condition.Params[2] + local activityId = condition.Params[3] + local npcId = condition.Params[4] + local total = XDataCenter.ItemManager.GetRedEnvelopeCertainNpcItemCount(activityId, npcId, itemId) + return total >= count, condition.Desc + end, + [23001] = function(condition) -- 判断服务器时间是否达到某个开始时间 + local timeId = condition.Params[1] + return XFunctionManager.CheckInTimeByTimeId(timeId), condition.Desc + end, + [15101] = function(condition) + local nodeId = condition.Params[1] + local cfg = XFubenExploreConfigs.GetLevel(nodeId) + if not cfg then + return false, condition.Desc + end + return XDataCenter.FubenExploreManager.IsNodeFinish(cfg.ChapterId, nodeId), condition.Desc + end, + [15102] = function(condition) + local chapterId = condition.Params[1] + local chapterData = XDataCenter.FubenAssignManager.GetChapterDataById(chapterId) + return (chapterData and chapterData:IsPass()), condition.Desc + end, + [15106] = function(condition) + local count = condition.Params[1] + local myCount = XDataCenter.ArenaOnlineManager.GetFirstPassCount() + return myCount >= count, condition.Desc + end, + [15110] = function(condition) --查询纷争战区是否开启 + return XDataCenter.ArenaManager.IsPlayerCanEnterFight(), condition.Desc + end, + [15111] = function(condition) --幻痛囚笼是否开启 + return XDataCenter.FubenBossSingleManager.IsBossSingleOpen(), condition.Desc + end, + + [15200] = function(condition) -- 主线普通与隐藏模式的收集进度是否均达到100% + local chapterMainId = condition.Params[1] + local chapterMain = XDataCenter.FubenMainLineManager.GetChapterMainTemplate(chapterMainId) + local NorProgress = XDataCenter.FubenMainLineManager.GetProgressByChapterId(chapterMain.ChapterId[1]) + local DiffProgress = XDataCenter.FubenMainLineManager.GetProgressByChapterId(chapterMain.ChapterId[2]) + + if NorProgress >= condition.Params[2] and DiffProgress >= condition.Params[2] then + return true, condition.Desc + end + return false, condition.Desc + end, + + [15201] = function(condition) -- 外篇普通与隐藏模式的收集进度是否均达到100% + local chapterMainId = condition.Params[1] + local chapterMain = XDataCenter.ExtraChapterManager.GetChapterCfg(chapterMainId) + local NorProgress = XDataCenter.ExtraChapterManager.GetProgressByChapterId(chapterMain.ChapterId[1]) + local DiffProgress = XDataCenter.ExtraChapterManager.GetProgressByChapterId(chapterMain.ChapterId[2]) + + if NorProgress >= condition.Params[2] and DiffProgress >= condition.Params[2] then + return true, condition.Desc + end + return false, condition.Desc + end, + + [15202] = function(condition) -- 是否通关周目章节 + local lastStage = XFubenZhouMuConfigs.GetZhouMuChapterLastStage(condition.Params[1]) + local flag = XDataCenter.FubenManager.CheckStageIsPass(lastStage) + return flag, condition.Desc + end, + + [16100] = function(condition) --查询公会等级是否达到(服务端未实现) + if not XDataCenter.GuildManager.IsJoinGuild() then return false, condition.Desc end + local guildLevel = XDataCenter.GuildManager.GetGuildLevel() + if condition.Params and condition.Params[1] > 0 and guildLevel >= condition.Params[1] then + return true, condition.Desc + end + return false, condition.Desc + end, + + [22002] = function(condition) --查询公会职务是否与参数中任一值匹配 + if not XDataCenter.GuildManager.IsJoinGuild() then return false, condition.Desc end + local rankLevel = XDataCenter.GuildManager.GetCurRankLevel() + for i = 1, #condition.Params do + if rankLevel == condition.Params[i] then + return true, condition.Desc + end + end + return false, condition.Desc + end, + + [10117] = function(condition) -- 查询玩家荣耀勋阶是否达标 + return XPlayer.GetHonorLevel() >= condition.Params[1], condition.Desc + end, + [10124] = function(condition) + local wave = XDataCenter.ExpeditionManager.GetWave() + return wave and wave >= condition.Params[1] + end, + [10125] = function(condition) + local recruitLevel = XDataCenter.ExpeditionManager.GetRecruitLevel() + return recruitLevel and recruitLevel >= condition.Params[1] + end, + + [15301] = function(condition) --追击玩法 + local mapId = condition.Params[1] + local mapDb = XDataCenter.ChessPursuitManager.GetChessPursuitMapDb(mapId) + if mapDb and mapDb:IsKill() then + return true + else + return false, condition.Desc + end + end, + [15302] = function(condition) --追击玩法 + local mapId = condition.Params[1] + local killBossCount = condition.Params[2] + local mapDb = XDataCenter.ChessPursuitManager.GetChessPursuitMapDb(mapId) + if mapDb and mapDb:IsKill() then + return mapDb:GetWinForBattleCount() <= killBossCount + else + return false, condition.Desc + end + end, + [15303] = function(condition) --追击玩法:是否布过阵 + for i, mapId in ipairs(condition.Params) do + local mapDb = XDataCenter.ChessPursuitManager.GetChessPursuitMapDb(mapId) + if mapDb and not mapDb:NeedBuZhen() then + return true + end + end + end, + [15304] = function(condition) --骇入玩法:查询研发等级是否达到 + if XDataCenter.FubenHackManager.GetIsActivityEnd() then return false end + return condition.Params[1] >= XDataCenter.FubenHackManager.GetLevel() + end, +} + +local CharacterCondition = { + [13101] = function(condition, characterId) -- 查询角色性别是否符合 + if type(characterId) ~= "number" then + characterId = characterId.Id + end + local characterTemplate = XCharacterConfigs.GetCharacterTemplate(characterId) + return characterTemplate.Sex == condition.Params[1], condition.Desc + end, + [13102] = function(condition, characterId) -- 查询角色类型是否符合 + local character = characterId + if type(characterId) == "number" then + character = XDataCenter.CharacterManager.GetCharacter(characterId) + end + local npcId = XCharacterConfigs.GetCharNpcId(character.Id, character.Quality) + local npcTemplate = CS.XNpcManager.GetNpcTemplate(npcId) + for i = 1, #condition.Params do + if npcTemplate.Type == condition.Params[i] then + return true + end + end + return false, condition.Desc + end, + + [13103] = function(condition, characterId) -- 查询角色是否符合等级 + local character = XDataCenter.CharacterManager.GetCharacter(characterId) + return character.Level >= condition.Params[1], condition.Desc + end, + + [13104] = function(condition, characterId) -- 查询单个角色类型是否符合 + local character = characterId + if type(characterId) == "number" then + character = XDataCenter.CharacterManager.GetCharacter(characterId) + end + local npcId = XCharacterConfigs.GetCharNpcId(character.Id, character.Quality) + local npcTemplate = CS.XNpcManager.GetNpcTemplate(npcId) + if npcTemplate.Type == condition.Params[1] then + return true + end + return false, condition.Desc + end, + [13105] = function(condition, characterId) -- 查询单个角色品质是否符合 + local character = characterId + if type(characterId) == "number" then + character = XDataCenter.CharacterManager.GetCharacter(characterId) + end + + if character.Quality >= condition.Params[1] then + return true + end + + return false, condition.Desc + end, + + + [13106] = function(condition, characterId) -- 查询拥有构造体 + if characterId == condition.Params[1] then + return true + end + + return false, condition.Desc + end, + + [13107] = function(condition, characterId) --查询角色是否符合Grade等级要求 + local character = nil + if type(characterId) == "number" then + character = XDataCenter.CharacterManager.GetCharacter(characterId) + end + + if not character then + return false, condition.Desc + end + + if character.Grade >= condition.Params[1] then + return true + end + return false, condition.Desc + end, + + [13108] = function(condition, characterId) --查询角色战力是否满足 + local character = XDataCenter.CharacterManager.GetCharacter(characterId) + if character.Ability >= condition.Params[1] then + return true, condition.Desc + end + return false, condition.Desc + end, + + [13109] = function(condition, characterId) --查询角色是否佩戴共鸣技能 + local starLimit = condition.Params[1] + local limitSkillNum = condition.Params[2] + local allSkillNum = 0 + + local weaponData = XDataCenter.EquipManager.GetCharacterWearingWeaponId(characterId) + local equipInfo = XDataCenter.EquipManager.GetEquip(weaponData) + local star = XDataCenter.EquipManager.GetEquipStar(equipInfo.TemplateId) + if star >= starLimit then + if equipInfo.ResonanceInfo ~= nil then + for _, info in pairs(equipInfo.ResonanceInfo) do + if info.CharacterId == characterId then + allSkillNum = allSkillNum + 1 + end + end + end + end + + local awarenessData = XDataCenter.EquipManager.GetCharacterWearingAwarenessIds(characterId) + for _, equipId in pairs(awarenessData) do + local equipInfo2 = XDataCenter.EquipManager.GetEquip(equipId) + local star2 = XDataCenter.EquipManager.GetEquipStar(equipInfo2.TemplateId) + if star2 >= starLimit then + if equipInfo2.ResonanceInfo ~= nil then + for _, info in pairs(equipInfo2.ResonanceInfo) do + if info.CharacterId == characterId then + allSkillNum = allSkillNum + 1 + end + end + end + end + end + + if allSkillNum >= limitSkillNum then + return true, condition.Desc + end + + return false, condition.Desc + end, + + [13110] = function(condition, characterId) --角色武器共鸣技能数 + if not condition.Params or #condition.Params ~= 2 then + return false, condition.Desc + end + local resonanceCount = 0 + local weaponData = XDataCenter.EquipManager.GetCharacterWearingWeaponId(characterId) + local equipInfo = XDataCenter.EquipManager.GetEquip(weaponData) + if equipInfo.ResonanceInfo ~= nil then + for _, info in pairs(equipInfo.ResonanceInfo) do + local quality = XDataCenter.EquipManager.GetEquipQuality(equipInfo.TemplateId) + if info.CharacterId == characterId and quality >= condition.Params[1] then + resonanceCount = resonanceCount + 1 + end + if resonanceCount > condition.Params[2] then + return true, condition.Desc + end + end + end + return false, condition.Desc + end, + + [13111] = function(condition, characterId) --角色意识共鸣技能数 + if not condition.Params or #condition.Params ~= 2 then + return false, condition.Desc + end + local weaponData = XDataCenter.EquipManager.GetCharacterWearingAwarenessIds(characterId) + local resonanceCount = 0 + for _, equipId in pairs(weaponData) do + local equipInfo = XDataCenter.EquipManager.GetEquip(equipId) + if equipInfo.ResonanceInfo ~= nil then + for _, info in pairs(equipInfo.ResonanceInfo) do + local quality = XDataCenter.EquipManager.GetEquipQuality(equipInfo.TemplateId) + if info.CharacterId == characterId and quality >= condition.Params[1] then + resonanceCount = resonanceCount + 1 + end + if resonanceCount > condition.Params[2] then + return true, condition.Desc + end + end + end + end + return false, condition.Desc + end, + + [13112] = function(condition, characterId) --角色指定id武器共鸣技能数 + if not condition.Params or #condition.Params ~= 2 then + return false, condition.Desc + end + local weaponData = XDataCenter.EquipManager.GetCanUseWeaponIds(characterId) + local resonanceCount = 0 + local equipInfo = nil + for _, equipId in pairs(weaponData) do + if equipId == condition.Params[1] then + equipInfo = XDataCenter.EquipManager.GetEquip(equipId) + end + + if equipInfo then + if equipInfo.ResonanceInfo ~= nil then + for _, info in pairs(equipInfo.ResonanceInfo) do + if info.CharacterId == characterId then + resonanceCount = resonanceCount + 1 + end + if resonanceCount > condition.Params[2] then + return true, condition.Desc + end + end + end + end + end + return false, condition.Desc + end, + + [13113] = function(condition) --判断是否是好感度最高的构造体 + if not condition.Params or #condition.Params < 1 then + return false, condition.Desc + end + + local id = XDataCenter.FavorabilityManager.GetHighestTrustExpCharacter() + + for _, roleId in pairs(condition.Params) do + if id == roleId then + return true + end + end + + return false, condition.Desc + end, + + [13114] = function(condition, characterId) -- 构造体是否终解 + local character = XDataCenter.CharacterManager.GetCharacter(characterId) + if not character then + return false, condition.Desc + end + local growUpLevel = XDataCenter.ExhibitionManager.GetCharacterGrowUpLevel(character.Id) + return (XDataCenter.ExhibitionManager.IsMaxLiberationLevel(growUpLevel)), condition.Desc + end, + + + + [13115] = function(condition, characterId) -- 构造体是否类型相符(构造体,感染体) + local character = characterId + if type(characterId) == "number" then + character = XDataCenter.CharacterManager.GetCharacter(characterId) + end + local charType = XCharacterConfigs.GetCharacterType(character.Id) + if charType == condition.Params[1] then + return true + end + return false, condition.Desc + end, + [59001] = function(condition) --查询猜拳小游戏对应关卡是否通关 + local stageId = condition.Params[1] + local stage = XDataCenter.FingerGuessingManager.GetStageByStageId(stageId) + if stage then + return stage:GetIsClear(), condition.Desc + end + return false, condition.Desc + end, +} + +local TeamCondition = { + [18101] = function(condition, characterIds) -- 查询队伍角色性别是否符合 + local ret, desc = true, nil + if type(characterIds) == "table" then + for _, id in pairs(characterIds) do + if id > 0 then + ret, desc = CharacterCondition[13101](condition, id) + if not ret then + break + end + end + end + else + XTool.LoopCollection(characterIds, function(id) + if id > 0 then + if ret then + ret, desc = CharacterCondition[13101](condition, id) + end + end + end) + end + + return ret, desc + end, + [18102] = function(condition, characterIds) -- 查询队伍角色类型是否符合 + local ret, desc = true, nil + if type(characterIds) == "table" then + for _, id in pairs(characterIds) do + if id > 0 then + ret, desc = CharacterCondition[13102](condition, id) + if not ret then + break + end + end + end + else + XTool.LoopCollection(characterIds, function(id) + if id > 0 then + ret, desc = CharacterCondition[13102](condition, id) + if ret then + ret, desc = CharacterCondition[13101](condition, id) + end + end + end) + end + + return ret, desc + end, + [18103] = function(condition, characterIds) -- 查询队伍是否拥有指定角色数量 + local chechCount = condition.Params[1] or 1 + local total = 0 + if type(characterIds) == "table" then + for i = 2, #condition.Params do + for _, id in pairs(characterIds) do + if id > 0 then + if id == condition.Params[i] then + total = total + 1 + break + end + end + end + + if total >= chechCount then + break + end + end + else + for i = 2, #condition.Params do + XTool.LoopCollection(characterIds, function(id) + if id > 0 then + if id == condition.Params[i] then + total = total + 1 + end + end + end) + + if total >= chechCount then + break + end + end + end + + return total >= chechCount, condition.Desc + end, + [18104] = function(condition, characterIds) -- 查询队伍是否已拥有指定角色数量 + if type(characterIds) == "table" then + for i = 1, #condition.Params do + for _, id in pairs(characterIds) do + if id > 0 then + if id == condition.Params[i] then + return false, condition.Desc + end + end + end + end + else + for i = 2, #condition.Params do + XTool.LoopCollection(characterIds, function(id) + if id > 0 then + if id == condition.Params[i] then + return false, condition.Desc + end + end + end) + end + end + + return true, condition.Desc + end, + [18105] = function(condition, characterIds) -- 派遣中拥有指定数量指定兵种构造 + local ret = true + local chechCount = condition.Params[2] or 1 + local total = 0 + if type(characterIds) == "table" then + for _, id in pairs(characterIds) do + if id > 0 then + ret = CharacterCondition[13104](condition, id) + if ret then + total = total + 1 + end + end + + if total >= chechCount then + break + end + end + else + XTool.LoopCollection(characterIds, function(id) + if id > 0 then + ret = CharacterCondition[13104](condition, id) + if ret then + total = total + 1 + end + end + + if total >= chechCount then + return + end + end) + end + + return total >= chechCount, condition.Desc + end, + [18106] = function(condition, characterIds) -- 派遣中拥有指定数量达到指定战斗力的构造体 + local chechCount = condition.Params[2] or 1 + local total = 0 + + if type(characterIds) == "table" then + for _, id in pairs(characterIds) do + local character = XDataCenter.CharacterManager.GetCharacter(id) + if character.Ability >= condition.Params[1] then + total = total + 1 + end + end + end + + return total >= chechCount, condition.Desc + end, + + [18107] = function(condition, characterIds) -- 派遣中拥有指定数量达到指定品质的构造体 + local ret = true + local chechCount = condition.Params[2] or 1 + local total = 0 + if type(characterIds) == "table" then + for _, id in pairs(characterIds) do + if id > 0 then + ret = CharacterCondition[13105](condition, id) + if ret then + total = total + 1 + end + end + + if total >= chechCount then + break + end + end + else + XTool.LoopCollection(characterIds, function(id) + if id > 0 then + ret = CharacterCondition[13105](condition, id) + if ret then + total = total + 1 + end + end + + if total >= chechCount then + return + end + end) + end + + return total >= chechCount, condition.Desc + end, + [18108] = function(condition, characterIds) -- 派遣中拥有指定数量达到指定等级的构造体 + local ret = true + local chechCount = condition.Params[2] or 1 + local total = 0 + if type(characterIds) == "table" then + for _, id in pairs(characterIds) do + if id > 0 then + ret = CharacterCondition[13103](condition, id) + if ret then + total = total + 1 + end + end + + if total >= chechCount then + break + end + end + else + XTool.LoopCollection(characterIds, function(id) + if id > 0 then + ret = CharacterCondition[13103](condition, id) + if ret then + total = total + 1 + end + end + + if total >= chechCount then + return + end + end) + end + + return total >= chechCount, condition.Desc + end, + [18109] = function(condition, characterIds) -- 派遣中拥有指定数量指定性别的构造体 + local ret = true + local chechCount = condition.Params[2] or 1 + local total = 0 + if type(characterIds) == "table" then + for _, id in pairs(characterIds) do + if id > 0 then + ret = CharacterCondition[13101](condition, id) + if ret then + total = total + 1 + end + end + + if total >= chechCount then + break + end + + end + else + XTool.LoopCollection(characterIds, function(id) + if id > 0 then + ret = CharacterCondition[13101](condition, id) + if ret then + total = total + 1 + end + end + + if total >= chechCount then + return + end + end) + end + + return total >= chechCount, condition.Desc + end, + [18110] = function(condition, characterIds) -- 派遣中拥有构造体 + local ret = true + local chechCount = condition.Params[2] or 1 + local total = 0 + if type(characterIds) == "table" then + for _, id in pairs(characterIds) do + if id > 0 then + ret = CharacterCondition[13106](condition, id) + if ret then + total = total + 1 + end + end + + if total >= chechCount then + break + end + end + else + XTool.LoopCollection(characterIds, function(id) + if id > 0 then + ret = CharacterCondition[13106](condition, id) + if ret then + total = total + 1 + end + end + + if total >= chechCount then + return + end + end) + end + + return total >= chechCount, condition.Desc + end, + [18111] = function(condition, characterIds) -- 仅可上阵N个人 + local count = condition.Params[1] + local compareType = condition.Params[2] + local total = 0 + for _, v in pairs(characterIds) do + if v > 0 then + total = total + 1 + end + end + if compareType == XUiCompareType.Equal then--等于 + return total == count, condition.Desc + end + if compareType == XUiCompareType.NoLess then--大于等于 + return total >= count, condition.Desc + end + return false, condition.Desc + end, + + [18112] = function(condition, characterIds) -- 要求队伍中有N个类型构造体 + local ret = true + local chechCount = condition.Params[2] or 1 + local total = 0 + if type(characterIds) == "table" then + for _, id in pairs(characterIds) do + if id > 0 then + ret = CharacterCondition[13115](condition, id) + if ret then + total = total + 1 + end + end + + if total >= chechCount then + break + end + end + else + XTool.LoopCollection(characterIds, function(id) + if id > 0 then + ret = CharacterCondition[13115](condition, id) + if ret then + total = total + 1 + end + end + + if total >= chechCount then + return + end + end) + end + + return total >= chechCount, condition.Desc + end, +} + +local KillCondition = { + [30101] = function(condition, npcId) -- 查询怪物击杀数是否达到 + return XDataCenter.ArchiveManager.GetMonsterKillCount(npcId) >= condition.Params[1], condition.Desc + end, +} + +local EquipCondition = { + [31101] = function(condition, equipId) -- 是否拥有某个装备 + return XDataCenter.ArchiveManager.IsEquipGet(equipId), condition.Desc + end, + + [31102] = function(condition, equipId) -- 装备是否达到目标等级 + return XDataCenter.ArchiveManager.GetEquipLv(equipId) >= condition.Params[1], condition.Desc + end, + + [31103] = function(condition, equipId) -- 武器的突破次数是否达到目标次数 + return XDataCenter.ArchiveManager.GetEquipBreakThroughTimes(equipId) >= condition.Params[1], condition.Desc + end, + + [31104] = function(condition, suitId) -- 套装中某一个意识的等级是否达到目标等级 + local idList = XEquipConfig.GetEquipTemplateIdsBySuitId(suitId) + local targetNum = condition.Params[1] + local isOpen = false + for _, id in ipairs(idList) do + if XDataCenter.ArchiveManager.GetEquipLv(id) >= targetNum then + isOpen = true + break + end + end + return isOpen, condition.Desc + end, + + [31105] = function(condition, suitId) -- 套装中某一个意识的突破次数是否达到目标次数 + local idList = XEquipConfig.GetEquipTemplateIdsBySuitId(suitId) + local targetNum = condition.Params[1] + local isOpen = false + for _, id in ipairs(idList) do + if XDataCenter.ArchiveManager.GetEquipBreakThroughTimes(id) >= targetNum then + isOpen = true + break + end + end + return isOpen, condition.Desc + end, + + [31106] = function(condition, suitId) -- 套装中不同的意识的数量达到目标数量 + return XDataCenter.ArchiveManager.GetAwarenessCountBySuitId(suitId) >= condition.Params[1], condition.Desc + end, +} + +function XConditionManager.GetConditionType(id) + local template = ConditionTemplate[id] + if not template then + XLog.Error("XConditionManager.GetConditionType error: can not found template, id is " .. id) + return XConditionManager.ConditionType.Unknown + end + + -- 0代表公式专用,没有范围设置,主要是要与服务器逻辑同步 + if template.Type == 0 then + return XConditionManager.ConditionType.Formula + elseif template.Type >= 13000 and template.Type < 14000 then + return XConditionManager.ConditionType.Character + elseif template.Type >= 18000 and template.Type < 19000 then + return XConditionManager.ConditionType.Team + elseif template.Type >= 30000 and template.Type < 31000 then + return XConditionManager.ConditionType.Kill + elseif template.Type >= 31000 and template.Type < 32000 then + return XConditionManager.ConditionType.Equip + else + return XConditionManager.ConditionType.Player + end +end + +function XConditionManager.Init() + ConditionTemplate = XTableManager.ReadByIntKey(TABLE_CONDITION_PATH, XTable.XTableCondition, "Id") +end + +function XConditionManager.GetConditionTemplate(id) + if not ConditionTemplate[id] then + XLog.Error("XConditionManager.GetConditionTemplate config is null " .. id) + return + end + return ConditionTemplate[id] +end + +function XConditionManager.CheckCharacterCondition(id, characterId) + local template = ConditionTemplate[id] + if not template then + XLog.Error("XConditionManager.CheckCharacterCondition error: can not found template, id is " .. id) + return DefaultRet + end + + local func = CharacterCondition[template.Type] + if not func then + XLog.Error("XConditionManager.CheckCharacterCondition error: can not found condition, id is " .. id .. " type is " .. template.Type) + return DefaultRet + end + + return func(template, characterId) +end + +function XConditionManager.CheckPlayerCondition(id, ...) + local template = ConditionTemplate[id] + if not template then + XLog.Error("XConditionManager.CheckPlayerCondition error: can not found template, id is " .. id) + return DefaultRet + end + + local func = PlayerCondition[template.Type] + if not func then + XLog.Error("XConditionManager.CheckPlayerCondition error: can not found condition, id is " .. id .. " type is " .. template.Type) + return DefaultRet + end + + return func(template, ...) +end + +function XConditionManager.CheckTeamCondition(id, characterIds) + local template = ConditionTemplate[id] + if not template then + XLog.Error("XConditionManager.CheckTeamCondition error: can not found template, id is " .. id) + return DefaultRet + end + + local func = TeamCondition[template.Type] + if not func then + XLog.Error("XConditionManager.CheckTeamCondition error: can not found condition, id is " .. id .. " type is " .. template.Type) + return DefaultRet + end + + return func(template, characterIds) +end + +function XConditionManager.CheckKillCondition(id, NpcId) + local template = ConditionTemplate[id] + if not template then + XLog.Error("XConditionManager.CheckKillCondition error: can not found template, id is " .. id) + return DefaultRet + end + + local func = KillCondition[template.Type] + if not func then + XLog.Error("XConditionManager.CheckKillCondition error: can not found condition, id is " .. id .. " type is " .. template.Type) + return DefaultRet + end + + return func(template, NpcId) +end + +-- checkedId can be suitId or equipId +function XConditionManager.CheckEquipCondition(conditionId, checkedId) + local template = ConditionTemplate[conditionId] + if not template then + XLog.Error("XConditionManager.CheckEquipCondition error: can not found template, id is " .. conditionId) + return DefaultRet + end + local func = EquipCondition[template.Type] + if not func then + XLog.Error("XConditionManager.CheckEquipCondition error: can not found condition, id is " .. conditionId .. " type is " .. template.Type) + return DefaultRet + end + + return func(template, checkedId) +end + +function XConditionManager.CheckCondition(id, ...) + local type = XConditionManager.GetConditionType(id) + if type == XConditionManager.ConditionType.Character then + return XConditionManager.CheckCharacterCondition(id, ...) + elseif type == XConditionManager.ConditionType.Team then + return XConditionManager.CheckTeamCondition(id, ...) + elseif type == XConditionManager.ConditionType.Kill then + return XConditionManager.CheckKillCondition(id, ...) + elseif type == XConditionManager.ConditionType.Equip then + return XConditionManager.CheckEquipCondition(id, ...) + elseif type == XConditionManager.ConditionType.Formula then + return XConditionManager.CheckComplexCondition(id, ...) + else + return XConditionManager.CheckPlayerCondition(id, ...) + end +end + +--[[ + 目前条件组合支持这三种情况 & | () 符号任意组合 + 1.1001 & (1002 | 1003) —— 都是无参数 + 2.1001 & 1002 | 1003 —— 都是需要指定参数(比如指定角色id),比如判断某个角色是否满足等级大于20级同时战力高于1000 + 3.1001 & 1002 | 1003 —— 1001无参数 1002需要传角色id,比如满足指挥官等级是否大于50级和某个角色是否大于20级 +]] +function XConditionManager.CheckComplexCondition(id, ...) + local args = { ... } + local conditionFormula = XConditionManager.ConditionFormula + if conditionFormula == nil then + local XConditionFormula = require("XFormula/XConditionFormula") + conditionFormula = XConditionFormula.New() + XConditionManager.ConditionFormula = conditionFormula + end + local config = XConditionManager.GetConditionTemplate(id) + -- 便于在内部提示配置错误 + conditionFormula:SetConfig(config) + local result, desc = conditionFormula:GetResult(config.Formula, args) + if config.Desc then + desc = config.Desc + end + return result, desc +end + +function XConditionManager.GetConditionDescById(id) + if (ConditionTemplate[id] or {}).Desc then + return ConditionTemplate[id].Desc + end +end + +function XConditionManager.GetConditionParams(id) + if (ConditionTemplate[id] or {}).Params then + return tableUnpack(ConditionTemplate[id].Params) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XCoupletGameManager.lua b/Resources/Scripts/XManager/XCoupletGameManager.lua new file mode 100644 index 00000000..bcdc7c2c --- /dev/null +++ b/Resources/Scripts/XManager/XCoupletGameManager.lua @@ -0,0 +1,389 @@ +local tableInsert = table.insert +local tableSort = table.sort + +XCoupletGameManagerCreator = function() + local XCoupletGameManager = {} + local ActivityInfo = nil + local CurrentCoupletId = 0 + local CurrentCoupletIndex = 0 + local CoupletsDataByServer = {} -- 服务器下发的数据 + + local ACTIVITY_COUPLET_PROTO = { + CoupletOpenWordRequest = "CoupletOpenWordRequest", -- 翻字 + CoupletCompleteSentenceRequest = "CoupletCompleteSentenceRequest", -- 校验对联 + } + + function XCoupletGameManager.Init() + + end + + function XCoupletGameManager.HandleCoupletData(data) + local activityId = data.ActivityId + ActivityInfo = XCoupletGameConfigs.GetCoupletBaseActivityById(activityId) + CoupletsDataByServer = {} + for _, coupletData in ipairs(data.WordList) do + CoupletsDataByServer[coupletData.CoupletId] = coupletData + end + CurrentCoupletId = CoupletsDataByServer[#CoupletsDataByServer].CoupletId + + CurrentCoupletIndex = XCoupletGameManager.GetCoupletIndexById(CurrentCoupletId) + end + + function XCoupletGameManager.CheckHasServerData() + return CoupletsDataByServer and next(CoupletsDataByServer) + end + + function XCoupletGameManager.GetCoupletWord(index, cb) + -- 自校验 + local consumeItemId = ActivityInfo.ConsumeItemId + local needCount = XCoupletGameConfigs.GetCoupletTemplateById(CurrentCoupletId).ItemConsumeCount + if not XDataCenter.ItemManager.CheckItemCountById(consumeItemId, needCount) then + XUiManager.TipMsg(CS.XTextManager.GetText("CoupletGameItemNotEnough")) + return + end + + XNetwork.Call(ACTIVITY_COUPLET_PROTO.CoupletOpenWordRequest, {WordIndex = index}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + CoupletsDataByServer[CurrentCoupletId].Words[index] = res.WordId + + if cb then cb() end + end) + end + + function XCoupletGameManager.ChangeWord(takeIndex, putIndex) + if not CurrentCoupletId or not CoupletsDataByServer[CurrentCoupletId] then + return + end + + if XCoupletGameManager.GetCoupletGameStatus() == XCoupletGameConfigs.CouPletStatus.Complete then + return + end + + if not CoupletsDataByServer[CurrentCoupletId].Words[takeIndex] or not CoupletsDataByServer[CurrentCoupletId].Words[takeIndex] then + return + end + + local takeWordId = CoupletsDataByServer[CurrentCoupletId].Words[takeIndex] + CoupletsDataByServer[CurrentCoupletId].Words[takeIndex] = CoupletsDataByServer[CurrentCoupletId].Words[putIndex] + CoupletsDataByServer[CurrentCoupletId].Words[putIndex] = takeWordId + -- XLog.Debug(CoupletsDataByServer[CurrentCoupletId].Words) + -- 抛出事件 刷新UI + CsXGameEventManager.Instance:Notify(XEventId.EVENT_COUPLET_GAME_CHANGE_WORD) + end + + function XCoupletGameManager.CompleteCoupletSentence() + if not XCoupletGameManager.CheckCoupletIsCheckComplete(CurrentCoupletId) then -- 没有全部翻开 + return + end + + XNetwork.Call(ACTIVITY_COUPLET_PROTO.CoupletCompleteSentenceRequest, { Words = CoupletsDataByServer[CurrentCoupletId].Words }, function (res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_COUPLET_GAME_SENTENCE_ERROR) + return + end + -- 成功出对 更新当前对联数据状态 + CoupletsDataByServer[CurrentCoupletId].Status = XCoupletGameConfigs.CouPletStatus.Complete + -- 开放下一个数据 + XCoupletGameManager.InitializeNextCoupletData() + -- 抛出事件 刷新UI + CsXGameEventManager.Instance:Notify(XEventId.EVENT_COUPLET_GAME_COMPLETE) + XEventManager.DispatchEvent(XEventId.EVENT_COUPLET_GAME_COMPLETE) + end) + end + + function XCoupletGameManager.GetCoupletGameStatus(coupletId) + if not CurrentCoupletId or not CoupletsDataByServer[coupletId] then + return XCoupletGameConfigs.CouPletStatus.Incomplete + end + + return CoupletsDataByServer[coupletId].Status + end + + function XCoupletGameManager.GetCoupletIndexById(coupletId) + if not coupletId or coupletId == 0 then + return + end + + local coupletTemplates = XCoupletGameManager.GetCoupletTemplates() + for index, template in ipairs(coupletTemplates) do + if template.Id == coupletId then + return index + end + end + + return nil + end + + function XCoupletGameManager.CheckCoupletIsOpen(index) + local coupletTemplates = XCoupletGameManager.GetCoupletTemplates() + if index == 1 then + return true + else + if CoupletsDataByServer[coupletTemplates[index].Id] then + return true + else + local lastData = CoupletsDataByServer[coupletTemplates[index-1].Id] + if not lastData then -- 上一关没数据这关一定未解锁 + return false + end + if lastData.Status == XCoupletGameConfigs.CouPletStatus.Complete then + return true + end + end + end + + return false + end + + function XCoupletGameManager.InitializeNextCoupletData() + local coupletTemplates = XCoupletGameManager.GetCoupletTemplates() + if CurrentCoupletIndex >= #coupletTemplates then -- 已经是最后一个 + return + end + + CurrentCoupletIndex = CurrentCoupletIndex + 1 + local coupletTemplate = coupletTemplates[CurrentCoupletIndex] + CurrentCoupletId = coupletTemplate.Id + local words = {} + for i = 1, #coupletTemplate.DownWordId, 1 do + tableInsert(words, 0) + end + CoupletsDataByServer[coupletTemplate.Id] = { + CoupletId = coupletTemplate.Id, + Words = words, + Status = XCoupletGameConfigs.CouPletStatus.Incomplete, + } + + local coupletName = XCoupletGameConfigs.GetCoupletTemplateById(CurrentCoupletId).TitleName + XUiManager.TipMsg(CS.XTextManager.GetText("CoupletGameCoupletUnlock", coupletName)) + end + + function XCoupletGameManager.GetHelpId() + if not ActivityInfo then + return + end + + return ActivityInfo.HelpId + end + + function XCoupletGameManager.GetConsumeItemId() + if not ActivityInfo then + return + end + + return ActivityInfo.ConsumeItemId + end + + function XCoupletGameManager.GetActivityTimeId() + if not ActivityInfo then + return + end + + return ActivityInfo.TimeId + end + + function XCoupletGameManager.GetCoupletTemplates() + if not ActivityInfo then + return + end + + if not ActivityInfo.Id then + return + end + + return XCoupletGameConfigs.GetCoupletTemplatesByActId(ActivityInfo.Id) + end + + function XCoupletGameManager.GetActivityTitle() + if not ActivityInfo then + return + end + + return ActivityInfo.Title, ActivityInfo.TitleEn + end + + function XCoupletGameManager.GetEffectOpenDelay() + if not ActivityInfo then + return + end + + return ActivityInfo.EffectDelay + end + + function XCoupletGameManager.GetHitFaceStoryId() + if not ActivityInfo then + return + end + + return ActivityInfo.StoryId + end + + function XCoupletGameManager.GetCoupletTemplateByIndex(index) + local coupletTemplates = XCoupletGameManager.GetCoupletTemplates() + if not coupletTemplates then + return + end + + return coupletTemplates[index] + end + + function XCoupletGameManager.GetLastCoupletName(index) + if not index then + return + end + + local lastIndex = index-1 + if lastIndex < 1 then + return + else + local coupletTemplate = XCoupletGameManager.GetCoupletTemplateByIndex(lastIndex) + return coupletTemplate.TitleName + end + end + + function XCoupletGameManager.FindDefaultSelectTabIndex() + return #CoupletsDataByServer + end + + function XCoupletGameManager.CheckCoupletIsCheckComplete(coupletId) -- 检查对联是否将文字全部翻开了 + if not CoupletsDataByServer[coupletId] then + return false + end + + if CoupletsDataByServer[coupletId].Status == XCoupletGameConfigs.CouPletStatus.Complete then + return false + end + + for _, wordId in pairs(CoupletsDataByServer[coupletId].Words) do + if wordId == 0 then + return false + end + end + + return true + end + + function XCoupletGameManager.GetDownWordsDataById(coupletId) + if not CoupletsDataByServer[coupletId] then + return + end + + return CoupletsDataByServer[coupletId].Words + end + + function XCoupletGameManager.GetRewardTaskDatas() + local taskDataList = XDataCenter.TaskManager.GetCoupletTaskList() + + tableSort(taskDataList, function (a, b) + if a.State == b.State then + return a.Id < b.Id + else + if a.State == XDataCenter.TaskManager.TaskState.Achieved then + return true + elseif a.State == XDataCenter.TaskManager.TaskState.Active and b.State == XDataCenter.TaskManager.TaskState.Finish then + return true + else + return false + end + end + end) + + return taskDataList + end + + function XCoupletGameManager.FinishTask(taskId) + XDataCenter.TaskManager.FinishTask(taskId, function(rewardGoodsList) + XUiManager.OpenUiObtain(rewardGoodsList) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_COUPLET_GAME_FINISH_TASK) + XEventManager.DispatchEvent(XEventId.EVENT_COUPLET_GAME_FINISH_TASK) + end) + end + + function XCoupletGameManager.GetRewardProcess() + local taskDataList = XDataCenter.TaskManager.GetCoupletTaskList() + local takeNum = 0 + local Count = #taskDataList + for _, taskData in pairs(taskDataList) do + if taskData.State == XDataCenter.TaskManager.TaskState.Finish then + takeNum = takeNum + 1 + end + end + return takeNum, Count + end + + function XCoupletGameManager.CheckRewardTaskRedPoint() + return XDataCenter.TaskManager.GetIsRewardForEx(XDataCenter.TaskManager.TaskType.Couplet) + end + + function XCoupletGameManager.CheckPlayVideoRedPoint(coupletId) + if not CoupletsDataByServer[coupletId] then + return false + end + + if CoupletsDataByServer[coupletId].Status == XCoupletGameConfigs.CouPletStatus.Incomplete then + return false + end + + local isPlayedVideo = XSaveTool.GetData(string.format("%s%s%s", XCoupletGameConfigs.PLAY_VIDEO_STATE_KEY, XPlayer.Id, coupletId)) + if not isPlayedVideo or isPlayedVideo == XCoupletGameConfigs.PlayVideoState.UnPlay then + return true + else + return false + end + end + + function XCoupletGameManager.CheckHasNoPlayVideo() + for _, data in pairs(CoupletsDataByServer) do + if XCoupletGameManager.CheckPlayVideoRedPoint(data.CoupletId) then + return true + end + end + + return false + end + + function XCoupletGameManager.CheckCanExchangeWord() + if not CoupletsDataByServer[CurrentCoupletId] then + return false + end + + if CoupletsDataByServer[CurrentCoupletId].Status == XCoupletGameConfigs.CouPletStatus.Complete then + return false + end + + if XCoupletGameManager.CheckCoupletIsCheckComplete(CurrentCoupletId) then + return false + end + + local consumeItemId = ActivityInfo.ConsumeItemId + local needCount = XCoupletGameConfigs.GetCoupletTemplateById(CurrentCoupletId).ItemConsumeCount + return XDataCenter.ItemManager.CheckItemCountById(consumeItemId, needCount) + end + + function XCoupletGameManager.CheckWordIsCorrect(coupletId, index, id) + local downWordIdArr = XCoupletGameConfigs.GetCoupletDownIdArr(coupletId, index) + if not downWordIdArr then + return false + end + + for _, downWordId in pairs(downWordIdArr) do + if downWordId == id then + return true + end + end + + return false + end + + XCoupletGameManager.Init() + return XCoupletGameManager +end + +XRpc.NotifyCoupletData = function (data) + XDataCenter.CoupletGameManager.HandleCoupletData(data) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XDataCenter.lua b/Resources/Scripts/XManager/XDataCenter.lua new file mode 100644 index 00000000..2ed00b5b --- /dev/null +++ b/Resources/Scripts/XManager/XDataCenter.lua @@ -0,0 +1,201 @@ +XDataCenter = XDataCenter or {} + +local IsWindowsEditor = XMain.IsWindowsEditor +local DataCenterProfiler = nil + +-- 使用XDataCenter.[key]访问 +local function InitManager(key, creator) + if IsWindowsEditor then + local profiler = DataCenterProfiler:CreateChild(key) + profiler:Start() + -- XPerformance.RecordLuaMemData(key, function() + XDataCenter[key] = creator() + -- end) + profiler:Stop() + else + XDataCenter[key] = creator() + end +end + +function XDataCenter.Init() + if XMain.IsEditorDebug then + CS.XLuaEngine.Reload() + end + + DataCenterProfiler = XGame.Profiler:CreateChild("XDataCenter") + DataCenterProfiler:Start() + + XScheduleManager.UnScheduleAll() + XGame.InitBreakPointTimer() + XPerformance.StartLuaMenCollect() + XEventManager.RemoveAllListener() + CsXGameEventManager.Instance:Clear() + CS.XLuaMethodManager.ClearAll() + + XAnalyticsEvent.Init() + + InitManager("UploadLogManager", XUploadLogManagerCreator) + InitManager("AntiAddictionManager", XAntiAddictionManagerCreator) + InitManager("GuideManager", XGuideManagerCreator) + InitManager("MovieManager", XMovieManagerCreator) + + InitManager("LoadingManager", XLoadingManagerCreator) + InitManager("CharacterManager", XCharacterManagerCreator) + InitManager("ItemManager", XItemManagerCreator) + + --fuben + InitManager("FubenMainLineManager", XFubenMainLineManagerCreator) + InitManager("FubenDailyManager", XFubenDailyManagerCreator) + InitManager("FubenResourceManager", XFubenResourceManagerCreator) + InitManager("PracticeManager", XPracticeManagerCreator) + InitManager("FubenFestivalActivityManager", XFubenFestivalActivityManagerCreator) + InitManager("FubenUnionKillManager", XFubenUnionKillManagerCreator) + InitManager("FubenUnionKillRoomManager", XFubenUnionKillRoomManagerCreator) + InitManager("FubenUrgentEventManager", XFubenUrgentEventManagerCreator) + InitManager("FubenBossSingleManager", XFubenBossSingleManagerCreator) + InitManager("FubenBossOnlineManager", XFubenBossOnlineManagerCreator) + InitManager("ArenaOnlineManager", XArenaOnlineManagerCreator) + InitManager("FubenActivityBranchManager", XFubenActivityBranchManagerCreator) + InitManager("FubenHackManager", XFubenHackManagerCreator) + InitManager("FubenCoupleCombatManager", XFubenCoupleCombatManagerCreator) + + InitManager("FubenActivityBossSingleManager", XFubenActivityBossSingleManagerCreator) + + InitManager("FubenRepeatChallengeManager", XFubenRepeatChallengeManagerCreator) + + InitManager("TeamManager", XTeamManagerCreator) + InitManager("EquipManager", XEquipManagerCreator) + InitManager("FurnitureManager", XFurnitureManagerCreator) + InitManager("HeadPortraitManager", XHeadPortraitManagerCreator) + InitManager("DormManager", XDormManagerCreator) + InitManager("BaseEquipManager", XBaseEquipManagerCreator) + InitManager("PersonalInfoManager", XPersonalInfoManagerCreator) + InitManager("DisplayManager", XDisplayManagerCreator) + InitManager("StoryManager", XStoryManagerCreator) + InitManager("AssistManager", XAssistManagerCreator) + InitManager("TaskManager", XTaskManagerCreator) + InitManager("FashionManager", XFashionManagerCreator) + InitManager("WeaponFashionManager", XWeaponFashionManagerCreator) + + InitManager("DrawManager", XDrawManagerCreator) + InitManager("GachaManager", XGachaManagerCreator) + InitManager("MailManager", XMailManagerCreator) + InitManager("SocialManager", XSocialManagerCreator) + InitManager("ChatManager", XChatManagerCreator) + + --不再使用 + --InitManager("HostelManager", XHostelManagerCreator) + --InitManager("HostelDelegateManager", XHostelDelegateManagerCreator) + + InitManager("BountyTaskManager", XBountyTaskManagerCreator) + InitManager("TaskForceManager", XTaskForceManagerCreator) + InitManager("BfrtManager", XBfrtManagerCreator) + InitManager("PrequelManager", XPrequelManagerCreator) + InitManager("FubenBabelTowerManager", XFubenBabelTowerManagerCreator) + InitManager("FubenRogueLikeManager", XFubenRogueLikeManagerCreator) + InitManager("TrialManager", XTrialManagerCreator) + InitManager("ArenaManager", XArenaManagerCreator) + InitManager("FubenExploreManager", XFubenExploreManagerCreator) + --特训关 + InitManager("FubenSpecialTrainManager", XFubenSpecialTrainManagerCreator) + --消除小游戏 + InitManager("EliminateGameManager", XEliminateGameManagerCreator) + InitManager("FubenAssignManager", XFubenAssignManagerCreator) + InitManager("ExtraChapterManager", XFubenExtraChapterCreator) + InitManager("FubenInfestorExploreManager", XFubenInfestorExploreManagerCreator) + InitManager("TRPGManager", XTRPGManagerCreator) + InitManager("PokemonManager", XPokemonManagerCreator) + InitManager("SpringFestivalActivityManager", XSpringFestivalActivityManagerCreator) + + InitManager("GuildBossManager", XGuildBossManagerCreator) + InitManager("ExpeditionManager", XExpeditionManagerCreator) + InitManager("WorldBossManager", XWorldBossManagerCreator) + InitManager("RpgTowerManager", XRpgTowerManagerCreator) + InitManager("MaintainerActionManager", XMaintainerActionManagerCreator) + InitManager("NieRManager", XNieRManagerCreator) + InitManager("FubenZhouMuManager", XFubenZhouMuManagerCreator) + InitManager("FubenExperimentManager", XFubenExperimentManagerCreator) + InitManager("FubenNewCharActivityManager", XFubenNewCharActivityManagerCreator) + InitManager("ChessPursuitManager", XChessPursuitManagerCreator) + InitManager("WhiteValentineManager", XWhiteValentineManagerCreator) + InitManager("FingerGuessingManager", XFingerGuessingManagerCreator) + InitManager("FubenSimulatedCombatManager", XFubenSimulatedCombatManagerCreator) + + InitManager("StrongholdManager", XStrongholdManagerCreator) + InitManager("KillZoneManager", XKillZoneManagerCreator) + + InitManager("ReformActivityManager", XReformActivityManagerCreator) + InitManager("PartnerTeachingManager", XPartnerTeachingManagerCreator) + InitManager("FashionStoryManager", XFashionStoryManagerCreator) + InitManager("SuperTowerManager", XSuperTowerManagerCreator) + InitManager("FubenManager", XFubenManagerCreator) + InitManager("MoeWarManager", XMoeWarManagerCreator) + InitManager("PokerGuessingManager", XPokerGuessingMangerCreator) + + InitManager("RpgMakerGameManager", XRpgMakerGameManagerCreator) + InitManager("PassportManager", XPassportManagerCreator) + + InitManager("SignBoardManager", XSignBoardManagerCreator) + InitManager("VoteManager", XVoteManagerCreator) + InitManager("FavorabilityManager", XFavorabilityManagerCreator) + InitManager("ComeAcrossManager", XComeAcrossManagerCreator) + InitManager("AutoFightManager", XAutoFightManagerCreator) + InitManager("NoticeManager", XNoticeManagerCreator) + InitManager("RoomManager", XRoomManagerCreator) + InitManager("CommunicationManager", XFunctionCommunicationManagerCreator) + InitManager("FunctionEventManager", XFunctionEventManagerCreator) + + XTypeManager.Init() + + InitManager("ExhibitionManager", XExhibitionManagerCreator) + InitManager("AutoWindowManager", XAutoWindowManagerCreator) + InitManager("PlayerInfoManager", XPlayerInfoManagerCreator) + InitManager("SignInManager", XSignInManagerCreator) + InitManager("MedalManager", XMedalManagerCreator) + InitManager("ArchiveManager", XArchiveManagerCreator) + InitManager("PurchaseManager", XPurchaseManagerCreator) + InitManager("PayManager", XPayManagerCreator) + + InitManager("ReportManager", XReportManagerCreater) + + InitManager("CdKeyManager", XCdKeyManagerCreator) + InitManager("FunctionalSkipManager", XFunctionalSkipManagerCreator) + InitManager("GuildManager", XGuildManagerCreator) + InitManager("MarketingActivityManager", XMarketingActivityManagerCreator) + InitManager("ActivityManager", XActivityManagerCreator) + InitManager("PuzzleActivityManager", XPuzzleActivityManagerCreator) + InitManager("ActivityBriefManager", XActivityBriefManagerCreator) + InitManager("ChristmasTreeManager", XChristmasTreeManagerCreator) + InitManager("VideoManager", XVideoManagerCreator) + + InitManager("SetManager", XSetManagerCreator) + + InitManager("RegressionManager", XRegressionManagerCreator) + InitManager("FightWordsManager", XFightWordsManagerCreator) + InitManager("FightInfestorExploreManager", XFightInfestorExploreManagerCreator) + InitManager("MusicPlayerManager", XMusicPlayerManagerCreator) + InitManager("XClickClearGameManager", XClickClearGameManagerCreator) + InitManager("PhotographManager", XPhotographManagerCreator) + InitManager("FubenActivityPuzzleManager", XFubenActivityPuzzleManagerCreator) + InitManager("MentorSystemManager", XMentorSystemManagerCreator) + InitManager("CollectionWallManager", XCollectionWallManagerCreator) + InitManager("RoomCharFilterTipsManager", XRoomCharFilterTipsManagerCreator) + InitManager("ComposeGameManager", XComposeGameManagerCreator) + InitManager("LottoManager", XLottoManagerCreator) + InitManager("PartnerManager", XPartnerManagerCreator) + InitManager("GuardCampManager", XGuardCampManagerCreator) + + InitManager("CoupletGameManager", XCoupletGameManagerCreator) + InitManager("SpecialShopManager", XSpecialShopManagerCreator) + InitManager("ScratchTicketManager", XScratchTicketManagerCreator) + InitManager("InvertCardGameManager", XInvertCardGameManagerCreator) + InitManager("MovieAssembleManager", XMovieAssembleManagerCreator) + InitManager("MineSweepingManager", XMineSweepingManagerCreator) + InitManager("SlotMachineManager", XSlotMachineManagerCreator) + InitManager("FireworksManager", XFireworksManagerCreator) + InitManager("UiPcManager", XUiPcManagerCreator); + + CS.XLuaMethodManager.RefreshAll() + DataCenterProfiler:Stop() + -- XLog.Debug(DataCenterProfiler) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XDisplayManager.lua b/Resources/Scripts/XManager/XDisplayManager.lua new file mode 100644 index 00000000..cb69652d --- /dev/null +++ b/Resources/Scripts/XManager/XDisplayManager.lua @@ -0,0 +1,219 @@ +XDisplayManagerCreator = function() + + local XDisplayManager = {} + + local DisplayTable = nil + local ContentTable = nil + local Groups = {} + local CharDict = {} + local CurDisplayChar + local LoadStates = {} + + function XDisplayManager.Init() + DisplayTable = XDisplayConfigs.GetDisplayTable() + ContentTable = XDisplayConfigs.GetContentTable() + Groups = XDisplayConfigs.GetGroups() + end + + function XDisplayManager.InitDisplayCharId(id) + XDisplayManager.GetCharDict() + CurDisplayChar = CharDict[id] + end + + function XDisplayManager.GetDisplayTable(id) + local tab = DisplayTable[id] + if not tab then + XLog.ErrorTableDataNotFound("XDisplayManager.GetDisplayTable", "tab", "Client/Display/Display.tab", "id", tostring(id)) + end + return tab + end + + function XDisplayManager.GetDisplayContentTable(id) + local tab = ContentTable[id] + if not tab then + XLog.ErrorTableDataNotFound("XDisplayManager.GetDisplayTable", "tab", "Client/Display/DisplayContent.tab", "id", tostring(id)) + end + return tab + end + + function XDisplayManager.RandBehavior(modelName) + local group = Groups[modelName] + if not group then + if not modelName then + XLog.Error("XDisplayManager.RandContent 错误: 参数modelName不能为空") + else + XLog.ErrorTableDataNotFound("XDisplayManager.GetDisplayTable", + "modelName", "Client/Display/Display.tab", "modelName", tostring(modelName)) + end + return + end + local index = XMath.RandByWeights(group.Weights) + local id = group.Ids[index] + if not id then + local tempStr = "XDisplayManager.GetDisplayTable错误:Client/Display/Display.tab 表中modelName: " + XLog.Error(tempStr .. tostring(modelName) .. "对应配置项的index: " .. index .. "内容为空,检查index或者配置表") + return + end + local displayTable = XDisplayManager.GetDisplayTable(id) + local contentTable = XDisplayManager.GetDisplayContentTable(displayTable.ContentId) + local result = { + Action = displayTable.Action, + Sound = contentTable.Sound, + Text = contentTable.Text, + Duration = contentTable.Duration, + } + return result + end + + function XDisplayManager.SetDisplayCharById(id, callback) + if id == XPlayer.DisplayCharId then + return + end + + local newChar = XDataCenter.CharacterManager.GetCharacter(id) + if not newChar then + return + end + + XNetwork.Call("ChangePlayerDisplayCharIdRequest", { CharId = id }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + XDataCenter.SignBoardManager.ChangeDisplayCharacter(id) + + CurDisplayChar = newChar + XPlayer.SetDisplayCharId(id) + callback(id) + end) + end + + function XDisplayManager.GetCharDict() + CharDict = {} + local list = XDataCenter.CharacterManager.GetOwnCharacterList() + for _, char in ipairs(list) do + CharDict[char.Id] = char + end + return CharDict + end + + -- 根据角色ID设置看板展示角色 + function XDisplayManager.SetDisplayCharByCharacterId(charId) + if not charId then + return + end + + local newChar = XDataCenter.CharacterManager.GetCharacter(charId) + if not newChar then + return + end + + CurDisplayChar = newChar + end + + function XDisplayManager.GetDisplayChar() + if not CurDisplayChar then + local charId = XPlayer.DisplayCharId + CurDisplayChar = XDataCenter.CharacterManager.GetCharacter(charId) + end + return CurDisplayChar + end + + function XDisplayManager.GetModelName(id) + local character = XDataCenter.CharacterManager.GetCharacter(id) + local quality + if character then + quality = character.Quality + else + quality = XCharacterConfigs.GetCharMinQuality(id) + end + return XDataCenter.CharacterManager.GetCharModel(id, quality) + end + + -- 更换模型和加载展示状态机,完成后调用回调。 + function XDisplayManager.UpdateRoleModel(panelRoleModel, id, cb, fashionId) + + local state = {} + + -- 初始化信息 + LoadStates[panelRoleModel] = state + state.Panel = panelRoleModel + state.Id = id + state.Callback = cb + state.IsLoading = true + state.ModelName = XDisplayManager.GetModelName(id) + + state.RerollData = function() + state.RollData = XDisplayManager.RandBehavior(state.ModelName) + end + + --获取时装ModelName + local resourcesId + if fashionId then + resourcesId = XDataCenter.FashionManager.GetResourcesId(fashionId) + else + resourcesId = XDataCenter.FashionManager.GetFashionResourceIdByCharId(id) + end + + local fashionModelName + + if resourcesId then + fashionModelName = XDataCenter.CharacterManager.GetCharResModel(resourcesId) + else + fashionModelName = XDisplayManager.GetModelName(id) + end + + --获取Controller名字 + state.RuntimeControllerName = XModelManager.GetUiDisplayControllerPath(fashionModelName) + + -- 更换模型 + local callback = function(model) + state.Model = model + state.Animator = state.Model:GetComponent("Animator") + XDisplayManager.OnAssetLoaded(state) + end + panelRoleModel:UpdateCharacterModel(id, nil, XModelManager.MODEL_UINAME.XUiMain, callback, nil, fashionId) + + -- 加载animationController + local runtimeController = CS.LoadHelper.LoadUiController(state.RuntimeControllerName, panelRoleModel.RefName) + + if runtimeController == nil or not runtimeController:Exist() then + XLog.Error("XUiPanelDisplay RefreshSelf 错误: 展示角色的动画状态机加载失败: 状态机名称 " .. state.RuntimeControllerName .. " Ui名称:" .. panelRoleModel.RefName) + return + end + state.RunTimeController = runtimeController + if not state.Model then + return + end + XDisplayManager.OnAssetLoaded(state) + + -- 两个都OK的时候触发回调 + return state + end + + function XDisplayManager.OnAssetLoaded(state) + if XTool.UObjIsNil(state.Model) or XTool.UObjIsNil(state.RunTimeController) then + return + end + state.Animator.runtimeAnimatorController = state.RunTimeController + state.IsLoading = false + if not state.Model.activeSelf then + return + end + if state.Callback then + state.Callback(state.Model) + end + end + + function XDisplayManager.PlayAnimation(panelRoleModel, animation) + local state = LoadStates[panelRoleModel] + if state.IsLoading or not state.Animator or not state.Model.activeSelf then + return + end + state.Animator:SetTrigger(animation) + end + + XDisplayManager.Init() + return XDisplayManager +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XDormManager.lua b/Resources/Scripts/XManager/XDormManager.lua new file mode 100644 index 00000000..3e6e2344 --- /dev/null +++ b/Resources/Scripts/XManager/XDormManager.lua @@ -0,0 +1,2462 @@ +--- +--- 宿舍业务管理器 +--- +XDormManagerCreator = function() + local XDormManager = {} + + local CharacterData = {} -- 构造体数据 + local DormitoryData = {} -- 宿舍数据 + -- local VisitorData = {} -- 宿舍访客数据 + local WorkListData = {} --打工数据(正在打工或者打完工但是奖励没有领) + local WorkRefreshTime = -1 --打工刷新时间 + local RecommVisData = {} --推荐访问数据 + local RecommVisIds = {} + local RecommVisFriendData = {} + + local LastSyncServerTime = 0 -- 爱抚水枪上一次请求时间 + local DormShowEventList = {} -- 构造体客户端展示事件效果列表 + local IsPlayingShowEvent = false -- 现在是否在播放展示事件 + local IsInTouch = false -- 是否再爱抚中 + local SYNC_PUTFURNITURE_SECOND = 5 --摆放家具保护护时间 + local LastPutFurnitureTime = 0 --大厅个人玩家列表最后刷新时间 + + local TargetDormitoryData = {} --别人宿舍数据 + local TargetCharacterData = {} -- 构造体数据(访问其他人时) + -- local TargetVisitorData = {} -- 宿舍访问数据(访问其他人时) + + local TempDormitoryData = {} -- 模板宿舍数据(包括收藏宿舍) + local ProvisionalDormData = {} -- 导入的宿舍数据 + local LocalCaptureCache = {} -- 本地截图缓存 + local DormRedTimer + + local SnapshotTimes = 0 -- 已使用的分享次数 + local LastShareTime = 0 -- 上一次分享的时间 + + local DormitoryRequest = { + DormitoryDataReq = "DormitoryDataRequest", -- 宿舍总数据请求 + ActiveDormItemReq = "ActiveDormItemRequest", --激活宿舍 + DormRenameReq = "DormRenameRequest", --房间改名 + PutFurnitureReq = "PutFurnitureRequest", --摆放家具请求 + DormSnapshotLayoutReq = "DormSnapshotLayoutRequest", --请求宿舍分享ID + + DormEnterReq = "DormEnterRequest", --进入宿舍通知 + DormExitReq = "DormOutRequest", --退出宿舍通知 + + DormCharacterOperateReq = "DormCharacterOperateRequest", --构造体处理事件反馈 + DormRemoveCharacterReq = "DormRemoveCharacterRequest", --拿走构造体 + DormPutCharacterReq = "DormPutCharacterRequest", --放置构造体 + CheckCreateFurnitureReq = "CheckCreateFurnitureRequest", --请求刷新家具建造列表 + DormRecommendReq = "DormRecommendRequest", --推荐访问 + DormDetailsReq = "DormDetailsRequest", --宿舍访问时的详细信息 + DormVisitReq = "DormVisitRequest", --访问宿舍 + DormWorkReq = "DormWorkRequest", --宿舍打工 + DormWorkRewardReq = "DormWorkRewardRequest", --宿舍打工领取奖励 + + FondleDataReq = "GetFondleDataRequest", -- 爱抚信息查询 + FondleReq = "DormDoFondleRequest", -- 爱抚请求 + + DormWordDoneReq = "DormWordDoneRequest", -- 代工请求 + DormGetPlayerLayoutReq = "DormGetPlayerLayoutRequest", -- 通过ID导入他人宿舍模板 + DormBindLayoutReq = "DormBindLayoutRequest", -- 模板绑定宿舍 + DormUnBindLayoutReq = "DormUnBindLayoutRequest", -- 解除模板绑定宿舍 + DormCollectLayoutReq = "DormCollectLayoutRequest", -- 收藏宿舍请求 + } + + function XDormManager.InitOnlyOnce() + if XDormManager.IsFirstInit then + return + end + XDormManager.IsFirstInit = true + + DormitoryData = {} + local dormitoryTemplates = XDormConfig.GetTotalDormitoryCfg() + -- 宿舍布局数据 + for id, _ in pairs(dormitoryTemplates) do + DormitoryData[id] = XHomeRoomData.New(id) + DormitoryData[id]:SetPlayerId(XPlayer.Id) + end + + local templateData = XDormConfig.GetDormTemplateData() + for k, v in pairs(templateData) do + TempDormitoryData[k] = v + end + + IsPlayingShowEvent = false + end + + -- 初始化宿舍小屋数据 + function XDormManager.InitDormitoryData(dormitoryList) + if not dormitoryList or not next(dormitoryList) then + return + end + for _, data in pairs(dormitoryList) do + local roomData = DormitoryData[data.DormitoryId] + if not roomData then + local path = XDormConfig.GetDormitoryTablePath() + XLog.Error("XDormManager.InitDormitoryData 错误:" .. path .. " 表中不存在DormitoryId: " .. data.DormitoryId .."检查配置表或者参数dormitoryList") + else + roomData:SetRoomUnlock(true) + roomData:SetRoomName(data.DormitoryName) + end + end + end + + -- 初始化宿舍小人数据 + function XDormManager.InitCharacterData(characterList) + if not characterList or not next(characterList) then + return + end + for _, data in ipairs(characterList) do + CharacterData[data.CharacterId] = data + if data.DormitoryId and data.DormitoryId > 0 then + local roomData = DormitoryData[data.DormitoryId] + if roomData then + roomData:AddCharacter(data) + end + end + end + end + + -- 初始化宿舍内部家具数据 + function XDormManager.InitFurnitureData(furnitureList) + if not furnitureList or not next(furnitureList) then + return + end + for _, data in pairs(furnitureList) do + local roomData = DormitoryData[data.DormitoryId] + if roomData then + roomData:SetRoomUnlock(true) + roomData:AddFurniture(data.Id, data.ConfigId, data.X, data.Y, data.Angle) + end + end + end + + function XDormManager.InitdormCollectData(dormCollectList) + if dormCollectList and next(dormCollectList) then + for _, v in ipairs(dormCollectList) do + TempDormitoryData[v.LayoutId] = XHomeRoomData.New(v.LayoutId) + TempDormitoryData[v.LayoutId]:SetPlayerId(v.PlayerId) + TempDormitoryData[v.LayoutId]:SetRoomName(v.Name) + TempDormitoryData[v.LayoutId]:SetRoomUnlock(true) + TempDormitoryData[v.LayoutId]:SetRoomDataType(XDormConfig.DormDataType.Collect) + TempDormitoryData[v.LayoutId]:SetRoomCreateTime(v.CreateTime) + + for _, furniture in ipairs(v.FurnitureList) do + local id = XGlobalVar.GetIncId() + TempDormitoryData[v.LayoutId]:AddFurniture(id, furniture.ConfigId, furniture.X, furniture.Y, furniture.Angle) + end + end + end + end + + function XDormManager.InitbindRelationData(bindRelations) + if bindRelations and next(bindRelations) then + for _, bindRelation in ipairs(bindRelations) do + if TempDormitoryData[bindRelation.LayoutId] then + TempDormitoryData[bindRelation.LayoutId]:SetConnectDormId(bindRelation.DormitoryId) + end + + if DormitoryData[bindRelation.DormitoryId] then + DormitoryData[bindRelation.DormitoryId]:SetConnectDormId(bindRelation.LayoutId) + end + end + end + end + + -- 设置导入宿舍数据 + function XDormManager.SetDormProvisionalData(shareId, furnitureList) + if not shareId or not furnitureList or #furnitureList <= 0 then + return + end + + if #ProvisionalDormData == XDormConfig.ProvisionalMaXCount then + table.remove(ProvisionalDormData, 1) + end + + local data = XHomeRoomData.New(shareId) + data:SetRoomDataType(XDormConfig.DormDataType.Provisional) + + for _, furniture in ipairs(furnitureList) do + local id = XGlobalVar.GetIncId() + data:AddFurniture(id, furniture.ConfigId, furniture.X, furniture.Y, furniture.Angle) + end + + table.insert(ProvisionalDormData, data) + end + + -- 获取上一个导入宿舍数据 + function XDormManager.GetLastDormProvisionalData() + if #ProvisionalDormData > 0 then + table.remove(ProvisionalDormData, #ProvisionalDormData) + if #ProvisionalDormData > 0 then + return ProvisionalDormData[#ProvisionalDormData] + end + end + + return nil + end + + -- 获取入宿舍数据 + function XDormManager.GetDormProvisionalData(roomId) + for _, v in ipairs(ProvisionalDormData) do + if v:GetRoomId() == roomId then + return v + end + end + + return nil + end + + -- 加载收藏宿舍的入口图片 + function XDormManager.LoacdCollectTxture() + local datas = XDormManager.GetTemplateDormitoryData(XDormConfig.DormDataType.Collect) + for _, v in ipairs(datas) do + v:GetRoomPicture() + end + end + + -- 获取模板宿舍数据 + function XDormManager.GetTemplateDormitoryData(dormDataType, idList) + if dormDataType == XDormConfig.DormDataType.Collect then + local datas = {} + + for _, v in pairs(TempDormitoryData) do + if v:GetRoomDataType() == XDormConfig.DormDataType.Collect then + table.insert(datas, v) + end + end + + table.sort(datas, function(a, b) + return a:GetRoomCreateTime() < b:GetRoomCreateTime() + end) + + return datas + end + + if dormDataType == XDormConfig.DormDataType.Template then + local datas = {} + if idList and #idList > 0 then + for _, id in ipairs(idList) do + local data = TempDormitoryData[id] + local isShow = XDormConfig.GetDormTemplateIsSwhoById(data:GetRoomId()) + if isShow then + table.insert(datas, data) + end + end + else + for _, v in pairs(TempDormitoryData) do + if v:GetRoomDataType() == XDormConfig.DormDataType.Template then + local isShow = XDormConfig.GetDormTemplateIsSwhoById(v:GetRoomId()) + if isShow then + table.insert(datas, v) + end + end + end + end + + table.sort(datas, function(a, b) + return a:GetRoomOrder() < b:GetRoomOrder() + end) + + return datas + end + + return nil + end + + --获取所有宿舍数据 + function XDormManager.GetDormitoryData(dormDataType, senceId) + if dormDataType == XDormConfig.DormDataType.Target then + return TargetDormitoryData + end + + if senceId then + local data = {} + for id, room in pairs(DormitoryData) do + local cfgId = XDormConfig.GetDormitorySenceById(id) + if cfgId == senceId then + data[id] = room + end + end + return data + end + + return DormitoryData + end + + -- 获取指定宿舍数据 + function XDormManager.GetRoomDataByRoomId(roomId, dormDataType) + local data, roomData + if dormDataType == XDormConfig.DormDataType.Target then + data = TargetDormitoryData + elseif dormDataType == XDormConfig.DormDataType.Template or dormDataType == XDormConfig.DormDataType.Collect then + data = TempDormitoryData + elseif dormDataType == XDormConfig.DormDataType.Provisional then + roomData = XDormManager.GetDormProvisionalData(roomId) + else + data = DormitoryData + end + + if not roomData then + roomData = data[roomId] + end + + if not roomData then + local tempStr = "XDormManager.GetRoomDataByRoomId无法根据roomId获得宿舍数据, 检查参数roomId : " + XLog.Error(tempStr .. tostring(roomId) .. " 参数dormDataType:" .. dormDataType) + return + end + + return roomData + end + + -- 入住排序方法 + local CharacterCheckInSortFunc = function(a, b) + if a.DormitoryId < 0 or b.DormitoryId < 0 then + return a.DormitoryId < b.DormitoryId + elseif a.DormitoryId > 0 or b.DormitoryId > 0 then + return a.CharacterId < b.CharacterId + end + + return false + end + + -- 取回入住人数据 + function XDormManager.GetCharactersSortedCheckInByDormId(dormId) + if not CharacterData or not next(CharacterData) then + return nil + end + + local data = {} + local d = {} + + for _, v in pairs(CharacterData) do + if v.DormitoryId == dormId then + table.insert(data, { CharacterId = v.CharacterId, DormitoryId = v.DormitoryId }) + else + table.insert(d, { CharacterId = v.CharacterId, DormitoryId = v.DormitoryId }) + end + end + + table.sort(d, CharacterCheckInSortFunc) + for _, v in pairs(d) do + table.insert(data, v) + end + return data + end + + ---------------------start data--------------------- + -- + function XDormManager.GetCharacterDataByCharId(id) + -- 没有数据下 直接返回nil + if not CharacterData or not next(CharacterData) then + return nil + end + local t = CharacterData[id] + if not t then + XLog.Error("XDormManager.GetCharacterDataByCharId 函数错误: 无法从服务端发回的数据characterList根据id找到对应的内容, Id = " .. tostring(id)) + return nil + end + + return t + end + + function XDormManager.CheckHaveDormCharacterByRewardId(id) + local characterId = XDormConfig.GetDormCharacterRewardData(id).CharacterId + return (CharacterData and CharacterData[characterId]) + end + + function XDormManager.GetTargetCharacterDataByCharId(id) + -- 没有数据下 直接返回nil + if not TargetCharacterData or not next(TargetCharacterData) then + return nil + end + + local t = TargetCharacterData[id] + if not t then + XLog.Error("XDormManager.GetTargetCharacterDataByCharId 函数错误: 无法从服务端发回的数据characterList根据id找到对应的内容, Id = " .. tostring(id)) + return nil + end + + return t + end + + -- 根据宿舍人员id---->CharacterId,获得角色大头像 + function XDormManager.GetCharBigHeadIcon(id) + return XDataCenter.CharacterManager.GetCharBigHeadIcon(id) + end + + -- 根据宿舍人员id---->CharacterId,获得角色小头像 + function XDormManager.GetCharSmallHeadIcon(id) + return XDataCenter.CharacterManager.GetCharSmallHeadIcon(id) + end + + -- 根据宿舍人员id---->CharacterId和类型,取回角色喜好Icon + function XDormManager.GetCharacterLikeIconById(id, lt) + if not id or not lt then + return + end + + local charStyleConfig = XDormConfig.GetCharacterStyleConfigById(id) + + if not charStyleConfig then + return + end + + local d = charStyleConfig[lt] + if not d then + return + end + + local likeTypeConfig = XFurnitureConfigs.GetDormFurnitureType(d) + return likeTypeConfig.TypeIcon + end + + -- 根据宿舍人员id---->CharacterId和类型,取回角色喜好Name + function XDormManager.GetCharacterLikeNameById(id, lt) + if not id or not lt then + return + end + + local charStyleConfig = XDormConfig.GetCharacterStyleConfigById(id) + if not charStyleConfig then + return + end + local d = charStyleConfig[lt] + if not d then + return + end + + local likeTypeConfig = XFurnitureConfigs.GetDormFurnitureType(d) + return likeTypeConfig.TypeName + end + + -- 根据宿舍人员id---->CharacterId,取回角色体力 + function XDormManager.GetVitalityById(id) + local d = XDormManager.GetCharacterDataByCharId(id) + if not d then + return 0 + end + + return d.Vitality + end + + -- 根据宿舍人员id---->CharacterId,取回角色心情值 + function XDormManager.GetMoodById(id) + local d = XDormManager.GetCharacterDataByCharId(id) + if not d then + return 0 + end + + return d.Mood + end + + -- 根据宿舍id--->DormitoryId,取回宿舍人员角色Icon圆头像 + function XDormManager.GetDormCharactersIcons(id, dormDataType) + local icons = {} + local d = XDormManager.GetRoomDataByRoomId(id, dormDataType) + if not d then + return icons + end + + local characterList = d:GetCharacter() + for k, v in pairs(characterList) do + --获得角色圆头像 + local icon = XDataCenter.CharacterManager.GetCharRoundnessHeadIcon(v.CharacterId) + icons[k] = icon + end + return icons + end + + -- 根据宿舍id--->DormitoryId,取回宿舍人员Ids + function XDormManager.GetDormCharactersIds(roomId, dormDataType) + local ids = {} + local d = XDormManager.GetRoomDataByRoomId(roomId, dormDataType) + if not d then + return ids + end + + local list = d:GetCharacter() + for _, v in pairs(list) do + ids[v.CharacterId] = v.CharacterId + end + return ids + end + + -- 根据宿舍id--->DormitoryId,取回宿舍人员中是否有事件 + function XDormManager.IsHaveDormCharactersEvent(roomId) + local d = XDormManager.GetRoomDataByRoomId(roomId) + local list = d:GetCharacter() + for _, v in pairs(list) do + local eventtemp = XHomeCharManager.GetCharacterEvent(v.CharacterId, true) + if eventtemp then + return true + end + end + return false + end + + -- 根据宿舍id--->DormitoryId,取回宿舍名字 + function XDormManager.GetDormName(id, dormDataType) + local d = XDormManager.GetRoomDataByRoomId(id, dormDataType) + if not d then + return + end + + return d:GetRoomName() or "" + end + + -- 根据宿舍id--->DormitoryId,取回宿舍总评分 + function XDormManager.GetDormTotalScore(id, dormDataType) + local totalScore = 0 + local d = XDormManager.GetRoomDataByRoomId(id, dormDataType) + if d then + local furnitureIdList = {} + local dic = d:GetFurnitureDic() + for furnitureId, _ in pairs(dic) do + table.insert(furnitureIdList, furnitureId) + end + + if furnitureIdList then + for _, furnitureId in pairs(furnitureIdList) do + totalScore = totalScore + XDataCenter.FurnitureManager.GetFurnitureScore(furnitureId, dormDataType) + end + end + end + + return XFurnitureConfigs.GetFurnitureTotalAttrLevelDescription(1, totalScore) + end + + -- 获取房间地表实例Id + function XDormManager.GetRoomPlatId(roomId, homePlatType, dormDataType) + if homePlatType == nil then + return nil + end + + local dic + if dormDataType == XDormConfig.DormDataType.Target then + dic = TargetDormitoryData + else + dic = DormitoryData + end + + local roomData = dic[roomId] + if roomData == nil then + return nil + end + + local list = roomData:GetFurnitureDic() + for _, v in pairs(list) do + local cfg = XFurnitureConfigs.GetFurnitureTemplateById(v.ConfigId) + if cfg then + local typeCfg = XFurnitureConfigs.GetFurnitureTypeById(cfg.TypeId) + if typeCfg then + if homePlatType == CS.XHomePlatType.Ground and typeCfg.MajorType == 1 and typeCfg.MinorType == 1 then + return v + end + + if homePlatType == CS.XHomePlatType.Wall and typeCfg.MajorType == 1 and typeCfg.MinorType == 2 then + return v + end + end + end + end + + return nil + end + + function XDormManager.GetAllCharacterIds() + local characterIds = {} + if CharacterData and next(CharacterData) then + for _, v in pairs(CharacterData) do + local t = XDormConfig.GetCharacterStyleConfigById(v.CharacterId) + if t then + table.insert(characterIds, v.CharacterId) + end + end + else + local characters = XDataCenter.CharacterManager.GetOwnCharacterList() + for _, v in pairs(characters) do + table.insert(characterIds, v.Id) + end + end + return characterIds + end + + function XDormManager.GetDormCharacterIds(...) + local charactersIds = {} + if CharacterData == nil then + return charactersIds + end + + local conditions = {...} + for _, v in pairs(CharacterData) do + local t = XDormConfig.GetCharacterStyleConfigById(v.CharacterId) + if t then + for _, charType in ipairs(conditions) do + if t.Type == charType then + table.insert(charactersIds, v.CharacterId) + goto GET_CHAR_IDS_BREAK + end + end + ::GET_CHAR_IDS_BREAK:: + end + end + + return charactersIds + end + + -- 构造体所在宿舍号 + function XDormManager.GetCharacterRoomNumber(charId) + local t = XDormManager.GetCharacterDataByCharId(charId) + if not t then + return 0 + end + + if t.DormitoryId > 0 then + return t.DormitoryId + end + + return 0 + end + + -- 构造体是否在宿舍中 + function XDormManager.CheckCharInDorm(charId) + local t = XDormManager.GetCharacterDataByCharId(charId) + if not t then + return false + end + return t.DormitoryId > 0 + end + + -- 获取构造体当前回复等级 + function XDormManager.GetCharRecoveryCurLevel(charId) + local curLevelConfig = nil + local curIndex = 0 + local charData = XDormManager.GetCharacterDataByCharId(charId) + if not charData then + return curLevelConfig, curIndex + end + local scoreA, scoreB, scoreC = XDormManager.GetDormitoryScore(charData.DormitoryId) + local indexA = XFurnitureConfigs.AttrType.AttrA - 1 + local indexB = XFurnitureConfigs.AttrType.AttrB - 1 + local indexC = XFurnitureConfigs.AttrType.AttrC - 1 + + local allFurnitureAttrs = XHomeDormManager.GetFurnitureScoresByUnsaveRoom(charData.DormitoryId) + local allScores = allFurnitureAttrs.TotalScore + + local recoveryConfigs = XDormConfig.GetCharRecoveryConfig(charId) + for index, recoveryConfig in pairs(recoveryConfigs) do + if recoveryConfig.CompareType == XDormConfig.CompareType.Less then + if scoreA <= (recoveryConfig.AttrCondition[indexA] or 0) and + scoreB <= (recoveryConfig.AttrCondition[indexB] or 0) and + scoreC <= (recoveryConfig.AttrCondition[indexC] or 0) and + allScores <= recoveryConfig.AttrTotal then + curLevelConfig = recoveryConfig + curIndex = index + end + elseif recoveryConfig.CompareType == XDormConfig.CompareType.Equal then + if scoreA == (recoveryConfig.AttrCondition[indexA] or 0) and + scoreB == (recoveryConfig.AttrCondition[indexB] or 0) and + scoreC == (recoveryConfig.AttrCondition[indexC] or 0) and + allScores == recoveryConfig.AttrTotal then + curLevelConfig = recoveryConfig + curIndex = index + end + elseif recoveryConfig.CompareType == XDormConfig.CompareType.Greater then + if scoreA >= (recoveryConfig.AttrCondition[indexA] or 0) and + scoreB >= (recoveryConfig.AttrCondition[indexB] or 0) and + scoreC >= (recoveryConfig.AttrCondition[indexC] or 0) and + allScores >= recoveryConfig.AttrTotal then + curLevelConfig = recoveryConfig + curIndex = index + end + end + end + + return curLevelConfig, curIndex + end + + -- 获取构造体当前 下一个回复等级Config + function XDormManager.GetCharRecoveryConfigs(charId) + local curRecoveryConfig, curConfigIndex = XDormManager.GetCharRecoveryCurLevel(charId) + local nextRecoveryConfig + + if curRecoveryConfig == nil then + return nil, nil + end + + local recoveryConfigs = XDormConfig.GetCharRecoveryConfig(charId) + + -- 当前已经是最大值 直接把当前作为Next返回 当前为nil + if curConfigIndex >= #recoveryConfigs then + return nil, curRecoveryConfig + end + + nextRecoveryConfig = recoveryConfigs[curConfigIndex + 1] + return curRecoveryConfig, nextRecoveryConfig + end + + -- 获取某个宿舍的家具三个总分(attrA, attrB, attrC) + function XDormManager.GetDormitoryScore(dormitoryId, dormDataType) + local dic + if dormDataType == XDormConfig.DormDataType.Target then + dic = TargetDormitoryData + else + dic = DormitoryData + end + + local data = dic[dormitoryId] + if not data then + return 0, 0, 0 + end + + local kv = data:GetFurnitureDic() + local furnitureIds = {} + for id, _ in pairs(kv) do + table.insert(furnitureIds, id) + end + local scoreA, scoreB, scoreC = XDataCenter.FurnitureManager.GetFurniturePartScore(furnitureIds, dormDataType) + return scoreA, scoreB, scoreC + end + + local getScoreNamesSort = function(a, b) + return a[2] > b[2] + end + + -- 获取某个宿舍的家具三个总分对应名字 + function XDormManager.GetDormitoryScoreNames() + local attrType = XFurnitureConfigs.AttrType + local indexA = attrType.AttrA + local indexB = attrType.AttrB + local indexC = attrType.AttrC + local a = XFurnitureConfigs.GetDormFurnitureTypeName(indexA) + local b = XFurnitureConfigs.GetDormFurnitureTypeName(indexB) + local c = XFurnitureConfigs.GetDormFurnitureTypeName(indexC) + return a, b, c + end + + -- 获取某个宿舍的家具三个总分(attrA, attrB, attrC)以及对应Icon + function XDormManager.GetDormitoryScoreIcons(dormitoryId, dormDataType) + local scoreA, scoreB, scoreC = XDormManager.GetDormitoryScore(dormitoryId, dormDataType) + local data = {} + local attrType = XFurnitureConfigs.AttrType + local indexA = attrType.AttrA + local indexB = attrType.AttrB + local indexC = attrType.AttrC + data[1] = { XFurnitureConfigs.GetDormFurnitureTypeIcon(indexA), scoreA, indexA } + data[2] = { XFurnitureConfigs.GetDormFurnitureTypeIcon(indexB), scoreB, indexB } + data[3] = { XFurnitureConfigs.GetDormFurnitureTypeIcon(indexC), scoreC, indexC } + table.sort(data, getScoreNamesSort) + return data + end + + function XDormManager.GetDormitoryScoreLevelDes(dormitoryId, dormDataType) + local scoreA, scoreB, scoreC = XDormManager.GetDormitoryScore(dormitoryId, dormDataType) + local attrType = XFurnitureConfigs.AttrType + local indexA = attrType.AttrA + local indexB = attrType.AttrB + local indexC = attrType.AttrC + local a = XFurnitureConfigs.GetFurnitureAttrLevelDescription(1, indexA, scoreA) + local b = XFurnitureConfigs.GetFurnitureAttrLevelDescription(1, indexB, scoreB) + local c = XFurnitureConfigs.GetFurnitureAttrLevelDescription(1, indexC, scoreC) + return a, b, c + end + + -- 获得玩家访问其他宿舍时的角色id(暂时做成随机,二期做成可设置) + function XDormManager.GetVisitorDormitoryCharacterId() + local d = XDormManager.GetAllCharacterIds() + if _G.next(d) == nil then + return 0 + end + + local index = math.random(1, #d) + return d[index] + end + + -- 改名完成修正数据 + function XDormManager.RenameSuccess(dormitoryId, newName) + local roomData = DormitoryData[dormitoryId] + if roomData then + roomData:SetRoomName(newName) + end + end + + -- 通知有人进入房间 + function XDormManager.NotifyDormVisitEnter() + end + + -- 通知打工刷新时间 + function XDormManager.NotifyDormWorkRefreshTime(data) + if WorkRefreshTime > 0 then + XDormManager.NotifyDormWorkRefreshFlag = true + end + WorkRefreshTime = data.NextRefreshTime or -1 + --XDormManager.NotifyDormWorkRefreshFlag = true + XEventManager.DispatchEvent(XEventId.EVENT_DORM_WORK_RESET) + end + + function XDormManager.GetDormWorkRefreshTime() + return WorkRefreshTime + end + + -- 批量通知构造体心情值和体力值改变 + function XDormManager.NotifyCharacterAttr(data) + for _, v in pairs(data.AttrList) do + XDormManager.NotifyCharacterMood(v) + XDormManager.NotifyCharacterVitality(v) + end + end + + -- 通知构造体心情值改变 + function XDormManager.NotifyCharacterMood(data) + local t = XDormManager.GetCharacterDataByCharId(data.CharacterId) + if not t then + return + end + + local changeValue = data.Mood - t.Mood + t.Mood = data.Mood + XEventManager.DispatchEvent(XEventId.EVENT_CHARACTER_MOOD_CHANGED, data.CharacterId, changeValue) + end + + -- 通知构造体体力值改变 + function XDormManager.NotifyCharacterVitality(data) + local t = XDormManager.GetCharacterDataByCharId(data.CharacterId) + if not t then + return + end + + t.Vitality = data.Vitality + XEventManager.DispatchEvent(XEventId.EVENT_CHARACTER_VITALITY_CHANGED, data.CharacterId) + end + + -- 通知构造体体力/心情恢复速度改变 + function XDormManager.NotifyCharacterSpeedChange(data) + for _, v in ipairs(data.Recoveries) do + local t = XDormManager.GetCharacterDataByCharId(v.CharacterId) + if not t then + return + end + + local moodChangeValue = v.MoodSpeed - t.MoodSpeed + local vitalityChangeValue = v.VitalitySpeed - t.VitalitySpeed + t.MoodSpeed = v.MoodSpeed + t.VitalitySpeed = v.VitalitySpeed + + if data.ChangeType == XDormConfig.RecoveryType.PutFurniture then + + local moodEventId = moodChangeValue > 0 and XDormConfig.ShowEventId.MoodSpeedAdd or XDormConfig.ShowEventId.MoodSpeedCut + local vitalityEventId = vitalityChangeValue > 0 and XDormConfig.ShowEventId.VitalitySpeedAdd + or XDormConfig.ShowEventId.VitalitySpeedCut + + if moodChangeValue ~= 0 then + XDormManager.DormShowEventShowAdd(v.CharacterId, moodChangeValue, moodEventId) + end + + if vitalityChangeValue ~= 0 then + XDormManager.DormShowEventShowAdd(v.CharacterId, vitalityChangeValue, vitalityEventId) + end + end + end + end + + -- 设置是否再爱抚中 + function XDormManager.SetInTouch(isInTouch) + IsInTouch = isInTouch + end + + -- 是否再爱抚中 + function XDormManager.CheckInTouch() + return IsInTouch + end + + function XDormManager.DormShowEventShowAdd(charId, changeValue, eventId) + local dormShowEvent = {} + dormShowEvent.CharacterId = charId + dormShowEvent.ChangeValue = changeValue + dormShowEvent.EventId = eventId + table.insert(DormShowEventList, dormShowEvent) + + if not XLuaUiManager.IsUiShow("UiDormSecond") then + return + end + + if IsInTouch then + return + end + + if IsPlayingShowEvent then + return + end + + XDormManager.GetNextShowEvent() + end + + function XDormManager.GetNextShowEvent() + if #DormShowEventList <= 0 then + IsPlayingShowEvent = false + return + end + + if not XLuaUiManager.IsUiShow("UiDormSecond") then + return + end + + if IsInTouch then + return + end + + IsPlayingShowEvent = true + local firstData = table.remove(DormShowEventList, 1) + XEventManager.DispatchEvent(XEventId.EVENT_DORM_SHOW_EVENT_CHANGE, firstData) + end + + -- 通知构造有事件变更 + function XDormManager.NotifyDormCharacterAddEvent(data) + if not data or not data.EventList then + return + end + + for _, v in ipairs(data.EventList) do + local t = XDormManager.GetCharacterDataByCharId(v.CharacterId) + if not t then + return + end + + t.EventList = t.EventList or {} + for _, v2 in ipairs(v.EventList) do + table.insert(t.EventList, v2) + end + XEventManager.DispatchEvent(XEventId.EVENT_CHARACTER_DORMMAIN_EVENT_NOTIFY, t.DormitoryId) + XEventManager.DispatchEvent(XEventId.EVENT_CHARACTER_ADD_EVENT_NOTIFY, v.CharacterId) + end + end + + -- 通知构造有事件变更 + function XDormManager.NotifyDormCharacterSubEvent(data) + + if not data or not data.EventList then + return + end + + for _, v in ipairs(data.EventList) do + + local t = XDormManager.GetCharacterDataByCharId(v.CharacterId) + if not t then + return + end + local idx = -1 + t.EventList = t.EventList or {} + for index, var in ipairs(t.EventList) do + if var.EventId == v.EventId then + idx = index + end + end + + if idx > 0 then + table.remove(t.EventList, idx) + end + + XEventManager.DispatchEvent(XEventId.EVENT_CHARACTER_SUB_EVENT_NOTIFY, data.CharacterId) + end + + end + + -- 取回玩家宿舍打工数据(正在打工或者奖励没有领) + -- 保证工位小的在前面 + local DormWorkDataSort = function(a, b) + return a.WorkPos < b.WorkPos + end + + function XDormManager.GetDormWorkData() + local listData = {} + local d = WorkListData or {} + for _, v in pairs(d) do + if v then + table.insert(listData, v) + end + end + + table.sort(listData, DormWorkDataSort) + return listData + end + + -- 取回玩家宿舍打工数据(能打工的) + function XDormManager.GetDormNotWorkData() + local listData = {} + local ids = XDormManager.GetAllCharacterIds() + for _, id in pairs(ids) do + if XDormManager.CheckCharInDorm(id) and not XDormManager.IsWorking(id) then + table.insert(listData, id) + end + end + table.sort(listData, function(a, b) + local vitalityA = XDormManager.GetVitalityById(a) + local vitalityB = XDormManager.GetVitalityById(b) + + if vitalityA ~= vitalityB then + return vitalityA > vitalityB + end + + return a < b + end) + + return listData + end + + -- 是否在打工中 + function XDormManager.IsWorking(charId) + local d = WorkListData or {} + for _, v in pairs(d) do + if v.CharacterId == charId then + local f = v.WorkEndTime - XTime.GetServerNowTimestamp() > 0 + if f then + return true + end + end + end + + return false + end + + -- 取回玩家宿舍已经占了的工位 + function XDormManager.GetDormWorkPosData() + local posList = {} + local d = WorkListData or {} + for _, v in pairs(d) do + posList[v.WorkPos] = v.WorkPos + end + return posList + end + + -- 当前拥有的宿舍 + function XDormManager.GetDormitoryCount() + local count = 0 + for _, room in pairs(DormitoryData) do + if room:WhetherRoomUnlock() then + count = count + 1 + end + end + return count + end + + -- 检查某个宿舍是否激活 + function XDormManager.IsDormitoryActive(dormitoryId) + local room = DormitoryData[dormitoryId] + if not room then return false end + return room:WhetherRoomUnlock() + end + + -- 当前已经激活的房间ID + function XDormManager.GetDormitoryActiveIds() + local ids = {} + for dormitoryId, room in pairs(DormitoryData) do + if room:WhetherRoomUnlock() then + table.insert(ids, dormitoryId) + end + end + return ids + end + + -- + function XDormManager.GetDormitoryCount() + local count = 0 + for _, room in pairs(DormitoryData) do + if room:WhetherRoomUnlock() then + count = count + 1 + end + end + return count + end + + -- 如果拥有的数量超过配置的最大数量,就取最大数量。 + function XDormManager.GetWorkCfg(dormCount) + local cfgWork = XDormConfig.GetDormCharacterWorkData() or {} + local count = XDormManager.GetDormitoryCount() + if dormCount then + count = dormCount + end + + local index = count + local temple = #cfgWork + + if count > temple then + index = temple + end + + local data = XDormConfig.GetDormCharacterWorkById(index) + return data + end + + -- 获取宿舍与模板宿舍之间的达成百分比 + function XDormManager.GetDormTemplatePercent(tmeplateDormId, dormId) + local templateData = TempDormitoryData[tmeplateDormId] + local dormData = DormitoryData[dormId] + + if not templateData or not dormData then + return 0 + end + + local dormFurnitureCount = 0 + local dormFurnitureConfigDic = dormData:GetFurnitureConfigDic() + + local templateFurnitureCount = 0 + local templateFurnitureConfigDic = templateData:GetFurnitureConfigDic() + + -- 模板宿舍家具数量 + for _, v in pairs(templateFurnitureConfigDic) do + templateFurnitureCount = templateFurnitureCount + #v + end + + -- 自己宿舍加家具达成数量 + for k, v in pairs(dormFurnitureConfigDic) do + if templateFurnitureConfigDic[k] then + if #v >= #templateFurnitureConfigDic[k] then + dormFurnitureCount = dormFurnitureCount + #templateFurnitureConfigDic[k] + else + dormFurnitureCount = dormFurnitureCount + #v + end + end + end + + if templateFurnitureCount <= 0 then + return 0 + end + + return math.floor((dormFurnitureCount / templateFurnitureCount) * 100) + end + + --==============================-- + --desc: 获取宿舍某个家具数量 + --@roomId: 房间ID + --@dormDataType: 房间类型 + --@isIncludeUnUse: 是否加上背包未使用的家具 + --@return 数量 + --==============================-- + function XDormManager.GetFunritureCountInDorm(roomId, dormDataType, configId, isIncludeUnUse) + local roomData = XDormManager.GetRoomDataByRoomId(roomId, dormDataType) + local furnitureCount = #roomData:GetFurnitureConfigByConfigId(configId) + if isIncludeUnUse then + local unUseCount = #XDataCenter.FurnitureManager.GetUnuseFurnitueById(configId) + furnitureCount = furnitureCount + unUseCount + end + + return furnitureCount + end + + function XDormManager.GetLocalCaptureCache(id) + local texture = LocalCaptureCache[id] + return texture or nil + end + + function XDormManager.SetLocalCaptureCache(id, texture) + LocalCaptureCache[id] = texture + end + + function XDormManager.ClearLocalCaptureCache() + for _, texture in pairs(LocalCaptureCache) do + if not XTool.UObjIsNil(texture) then + CS.UnityEngine.Object.Destroy(texture) + end + end + LocalCaptureCache = {} + end + + ---------------------end data--------------------- + ---------------------start net--------------------- + function XDormManager.UpdateDormData(roomId, roomData) + local newRoomData = XHomeRoomData.New(roomId) + newRoomData:SetPlayerId(XPlayer.Id) + local furnitureList = roomData:GetFurnitureDic() + for _, furniture in pairs(furnitureList) do + local furnitureData = XDataCenter.FurnitureManager.GetFurnitureById(furniture.Id) + if furnitureData then + newRoomData:AddFurniture(furnitureData.Id, furnitureData.ConfigId, furnitureData.X, furnitureData.Y, furnitureData.Angle) + end + end + + DormitoryData[roomId] = newRoomData + end + + function XDormManager.SetRoomDataDormitoryId(roomData, roomId) + local furnitureList = roomData:GetFurnitureDic() + + for _, furniture in pairs(furnitureList) do + XDataCenter.FurnitureManager.SetFurnitureState(furniture.Id, roomId) + end + end + + -- 房间家具摆放 + function XDormManager.RequestDecorationRoom(roomId, room, isBehavior, cb) + if isBehavior then + local now = XTime.GetServerNowTimestamp() + if LastPutFurnitureTime + SYNC_PUTFURNITURE_SECOND >= now then + if cb then + cb(true) + end + return + end + LastPutFurnitureTime = now + end + + if not room then return end + local roomData = room:GetData() + if not roomData then return end + + local furnitureList = {} + local furnitures = roomData:GetFurnitureDic() + local roomDataType = roomData:GetRoomDataType() + local roomUnsaveData = XDormManager.GetRoomDataByRoomId(roomId, roomDataType) + local successCb = function(isSuccess) + room:GenerateRoomMap() + -- 提示成功 + if not isBehavior then + XUiManager.TipMsg(CS.XTextManager.GetText("FurnitureSaveSuccess")) + end + + if roomDataType == XDormConfig.DormDataType.Self then + -- 修改保存之前的家具为不属于这个房间 + XDormManager.SetRoomDataDormitoryId(roomUnsaveData, 0) + -- 修改保存之后的家具为属于这个房间 + XDormManager.SetRoomDataDormitoryId(roomData, roomId) + -- 将修改保存起来(直接替换旧数据) + DormitoryData[roomId]:SetFurnitureDic(roomData:GetFurnitureDic()) + elseif roomDataType == XDormConfig.DormDataType.Collect then + TempDormitoryData[roomId]:SetFurnitureDic(roomData:GetFurnitureDic()) + local imgName = tostring(XPlayer.Id) .. tostring(roomId) + local texture = XHomeSceneManager.CaptureCamera(imgName, false) + XDormManager.SetLocalCaptureCache(imgName, texture) + elseif roomDataType == XDormConfig.DormDataType.Provisional then + local provisionalRoom = XDormManager.GetDormProvisionalData(roomId) + provisionalRoom:SetFurnitureDic(roomData:GetFurnitureDic()) + elseif roomDataType == XDormConfig.DormDataType.Template then + TempDormitoryData[roomId]:SetFurnitureDic(roomData:GetFurnitureDic()) + end + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_FURNITURE_REFRESH) + if cb then + cb(isSuccess) + end + end + + for _, v in pairs(furnitures) do + local data = {} + if roomDataType == XDormConfig.DormDataType.Self then + data.Id = v.Id + else + data.ConfigId = v.ConfigId + end + + data.X = v.GridX + data.Y = v.GridY + data.Angle = v.RotateAngle + table.insert(furnitureList, data) + end + + if roomDataType == XDormConfig.DormDataType.Self then + XDataCenter.FurnitureManager.PutFurniture(roomId, furnitureList, isBehavior, successCb) + elseif roomDataType == XDormConfig.DormDataType.Collect then + local name = roomData:GetRoomName() + XDormManager.CollectPutFunitrue(roomId, name, furnitureList, successCb) + else + successCb(true) + end + end + + -- 请求宿舍分享ID + function XDormManager.RequestDormSnapshotLayout(furnitureList, cb) + if SnapshotTimes <= XDormConfig.MAX_SHARE_COUNT then + local now = XTime.GetServerNowTimestamp() + + if LastShareTime + XDormConfig.GET_SHARE_ID_INTERVAL > now then + -- 需要等待的时间比现在还晚 + local waitTime = (LastShareTime + XDormConfig.GET_SHARE_ID_INTERVAL) - now + local tip = CS.XTextManager.GetText("DormShareWaitTime", waitTime) + XUiManager.TipMsg(tip) + return + end + LastShareTime = now + + table.sort(furnitureList, function(item1, item2) + if item1.ConfigId ~= item2.ConfigId then + return item1.ConfigId < item2.ConfigId + end + + if item1.X == nil or item2.X == nil then + return false + elseif item1.X ~= item2.X then + return item1.X < item2.X + end + + if item1.Y == nil or item2.Y == nil then + return false + elseif item1.Y ~= item2.Y then + return item1.Y < item2.Y + end + + if item1.Angle == nil or item2.Angle ==nil then + return false + else + return item1.Angle < item2.Angle + end + end) + + local req = { FurnitureList = furnitureList} + XNetwork.Call(DormitoryRequest.DormSnapshotLayoutReq, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + -- 更新分享次数 + SnapshotTimes = res.SnapshotTimes + + if cb then + cb(res.ShareId) + end + end) + else + XUiManager.TipText("DormShareCountNotEnough") + end + end + + -- 获取构造体回复速度 + function XDormManager.GetDormitoryRecoverSpeed(charId, cb) + local t = XDormManager.GetCharacterDataByCharId(charId) + if not t then + return nil + end + + local moodSpeed = string.format("%.1f", t.MoodSpeed / 100) + local vitalitySpeed = string.format("%.1f", t.VitalitySpeed / 100) + + if moodSpeed * 10 % 10 == 0 then + moodSpeed = string.format("%d", moodSpeed) + end + + if vitalitySpeed * 10 % 10 == 0 then + vitalitySpeed = string.format("%d", vitalitySpeed) + end + + + if cb then + cb(moodSpeed, vitalitySpeed, t) + end + end + + -- 激活宿舍 + function XDormManager.RequestDormitoryActive(dormitoryId, cb) + XNetwork.Call(DormitoryRequest.ActiveDormItemReq, { DormitoryId = dormitoryId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + XDormManager.ReqDormitoryActiveSuccess(res.DormitoryId, res.DormitoryName, res.FurnitureList) + if cb then + cb() + end + + XUiManager.TipText("DormActiveSuccessTips") + XEventManager.DispatchEvent(XEventId.EVENT_DORM_ROOM_ACTIVE_SUCCESS) + end) + end + + -- 激活宿舍成功修正数据 + function XDormManager.ReqDormitoryActiveSuccess(dormitoryId, dormitoryName, furnitureList) + for _, v in pairs(furnitureList) do + XDataCenter.FurnitureManager.AddFurniture(v) + end + local roomData = DormitoryData[dormitoryId] + + if roomData then + roomData:SetRoomName(dormitoryName) + roomData:SetRoomUnlock(true) + for _, data in pairs(furnitureList) do + roomData:AddFurniture(data.Id, data.ConfigId, data.X, data.Y, data.Angle) + end + end + + local room = XHomeDormManager.GetSingleDormByRoomId(dormitoryId) + room:SetData(roomData) + end + + -- 访问宿舍(包括自己和他人的) + function XDormManager.VisitDormitory(displayState, dormitoryId) + local f = displayState == XDormConfig.VisitDisplaySetType.MySelf + local isvistor = false + local ids = XDormManager.GetDormitoryActiveIds() + for _, dormId in pairs(ids) do + XHomeDormManager.RevertOnWall(dormId) + end + + if f then + local data = XDataCenter.DormManager.GetDormitoryData() + XHomeDormManager.LoadRooms(data, XDormConfig.DormDataType.Self) + else + local data = XDataCenter.DormManager.GetDormitoryData(XDormConfig.DormDataType.Target) + XHomeDormManager.LoadRooms(data, XDormConfig.DormDataType.Target) + isvistor = true + end + + XHomeDormManager.SetSelectedRoom(dormitoryId, true, isvistor) + end + + -- 进入模板宿舍(包括临时模板) + function XDormManager.EnterTeamplateDormitory(dormitoryId, roomDataType) + local roomType = roomDataType + local isCollectNone = roomType == XDormConfig.DormDataType.CollectNone + if isCollectNone then + roomType = XDormConfig.DormDataType.Template + end + + local data = XDormManager.GetRoomDataByRoomId(dormitoryId, roomType) + if isCollectNone then + local defluatFurnitrue = XDataCenter.FurnitureManager.GetCollectNoneFurnitrue(dormitoryId) + if defluatFurnitrue then + data:SetFurnitureDic(defluatFurnitrue) + end + end + + local datas = { data } + XHomeDormManager.LoadRooms(datas, roomType) + XLuaUiManager.Open("UiDormTemplateScene", dormitoryId, roomDataType) + XHomeDormManager.SetSelectedRoom(dormitoryId, true) + end + + -- 房间改名 + function XDormManager.RequestDormitoryRename(dormitoryId, newName, cb) + XNetwork.Call(DormitoryRequest.DormRenameReq, { DormitoryId = dormitoryId, NewName = newName }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + if cb then + XDormManager.RenameSuccess(dormitoryId, newName) + cb() + end + end) + end + + -- 摆放家具请求 + function XDormManager.RequestDormitoryPutFurniture(dormitoryId, furnitureList, cb) + XNetwork.Call(DormitoryRequest.PutFurnitureReq, { DormitoryId = dormitoryId, FurnitureList = furnitureList }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + if cb then + cb() + end + end) + end + + -- 退出宿舍请求 + function XDormManager.RequestDormitoryExit() + XNetwork.Send(DormitoryRequest.DormExitReq) + end + + -- 进入宿舍通知 + function XDormManager.RequestDormitoryDormEnter(cb) + XNetwork.Call(DormitoryRequest.DormEnterReq, nil, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local data = res.CharacterEvents + if data then + for _, v in pairs(data) do + + local t = XDormManager.GetCharacterDataByCharId(v.CharacterId) + if not t then + return + end + + t.EventList = v.EventList + end + end + + if cb then + cb() + end + + end) + end + + -- 构造体处理事件反馈 + function XDormManager.RequestDormitoryCharacterOperate(charId, dormitoryId, eventId, operateType, cb) + XNetwork.Call(DormitoryRequest.DormCharacterOperateReq, { CharacterId = charId, EventId = eventId, OperateType = operateType }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local character = XDormManager.GetCharacterDataByCharId(charId) + if not character.EventList then + return + end + + local index = -1 + for i, v in ipairs(character.EventList) do + if v.EventId == eventId then + index = i + end + end + + if index > 0 then + table.remove(character.EventList, index) + end + + XHomeCharManager.SetEventReward(charId, res.RewardGoods) + + -- 处理回复弹条 + local changeValue = math.floor(res.MoodValue / 100) + if character.Mood + changeValue > XDormConfig.DORM_MOOD_MAX_VALUE then + changeValue = XDormConfig.DORM_MOOD_MAX_VALUE - character.Mood + end + + character.Mood = character.Mood + changeValue + local showEventId = changeValue > 0 and XDormConfig.ShowEventId.MoodAdd or XDormConfig.ShowEventId.MoodCut + XDormManager.DormShowEventShowAdd(charId, changeValue, showEventId) + + XEventManager.DispatchEvent(XEventId.EVENT_CHARACTER_MOOD_CHANGED, charId, changeValue) + + if cb then + cb() + end + end) + end + + -- 放置构造体 + function XDormManager.RequestDormitoryPutCharacter(dormitoryId, characterIds, cb) + XNetwork.Call(DormitoryRequest.DormPutCharacterReq, { DormitoryId = dormitoryId, CharacterIds = characterIds }, function(res) + XDormManager.PutCharacterSuccess(dormitoryId, res.SuccessIds) + if cb then + cb() + end + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + XEventManager.DispatchEvent(XEventId.EVENT_CHARACTER_CHANGE_ROOM_CHARACTER, characterIds) + end) + end + + -- 放置构造体成功修正数据 + function XDormManager.PutCharacterSuccess(dormitoryId, characterIds) + if not dormitoryId or not characterIds then + return + end + + for _, id in pairs(characterIds) do + local d = CharacterData[id] + if d then + d.DormitoryId = dormitoryId + end + + local roomData = DormitoryData[dormitoryId] + roomData:AddCharacter(d) + local room = XHomeDormManager.GetRoom(dormitoryId) + if room and room.IsSelected then + room.Data.Character = roomData.Character + room:AddCharacter(dormitoryId, id) + end + end + end + + -- 重新放置构造体 + function XDormManager.ResetPutCharacter(dormitoryId, characterIds) + if not dormitoryId or not characterIds or #characterIds <= 0 then + return + end + + for _, id in pairs(characterIds) do + local room = XHomeDormManager.GetRoom(dormitoryId) + if room and room.IsSelected then + room:AddCharacter(dormitoryId, id) + end + end + end + + -- 移走构造体 + function XDormManager.RequestDormitoryRemoveCharacter(characterIds, cb) + XNetwork.Call(DormitoryRequest.DormRemoveCharacterReq, { CharacterIds = characterIds }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + XDormManager.RemoveCharacterSuccess(res.SuccessList) + if cb then + cb() + end + + XEventManager.DispatchEvent(XEventId.EVENT_CHARACTER_CHANGE_ROOM_CHARACTER, characterIds) + end) + end + + -- 移走构造体成功修正数据 + function XDormManager.RemoveCharacterSuccess(successList) + if not successList then + return + end + + for _, v in pairs(successList) do + local roomData = DormitoryData[v.DormitoryId] + if roomData then + roomData:RemoveCharacter(v.CharacterId) + + local room = XHomeDormManager.GetRoom(v.DormitoryId) + if room then + room:RemoveCharacter(v.DormitoryId, v.CharacterId) + end + end + + local id = v.CharacterId + local d = CharacterData[id] + if d then + d.DormitoryId = -1 + end + end + end + + -- 请求刷新家具建造列表 + function XDormManager.RequestDormitoryCheckCreateFurniture(cb) + XNetwork.Call(DormitoryRequest.CheckCreateFurnitureReq, nil, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + if cb then + cb(res.FurnitureList) + end + end) + end + + -- 访问具体宿舍 + function XDormManager.RequestDormitoryVisit(targetId, dormitoryId, characterId, cb) + XNetwork.Call(DormitoryRequest.DormVisitReq, { TargetId = targetId, DormitoryId = dormitoryId, CharacterId = characterId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + XDormManager.DormitoryVisitData(res.VisitorList, res.CharacterList, res.DormitoryList, res.FurnitureList, res.PlayerName, targetId) + + if cb then + cb() + end + end) + end + + -- 访问具体宿舍数据记录 + function XDormManager.DormitoryVisitData(visitorList, characterList, dormitoryList, furnitureList, playername, targetId) + local dormitoryCfgs = XDormConfig.GetTotalDormitoryCfg() + + -- 宿舍布局数据 + for id, _ in pairs(dormitoryCfgs) do + TargetDormitoryData[id] = XHomeRoomData.New(id) + TargetDormitoryData[id]:SetPlayerId(targetId) + TargetDormitoryData[id]:SetRoomDataType(XDormConfig.DormDataType.Target) + TargetDormitoryData[id].PlayerName = playername + end + + if dormitoryList then + for _, data in pairs(dormitoryList) do + local roomData = TargetDormitoryData[data.DormitoryId] + if not roomData then + XLog.Error("XDormManager.DormitoryVisitData错误: dormitory id is not exist, id = " .. tostring(data.DormitoryId)) + else + roomData:SetRoomUnlock(true) + roomData:SetRoomName(data.DormitoryName) + end + end + end + + -- 宿舍家具 + XDataCenter.FurnitureManager.RemoveFurnitureOther() + if furnitureList then + for _, data in pairs(furnitureList) do + local roomData = TargetDormitoryData[data.DormitoryId] + if roomData then + roomData:SetRoomUnlock(true) + roomData:AddFurniture(data.Id, data.ConfigId, data.X, data.Y, data.Angle) + XDataCenter.FurnitureManager.AddFurniture(data, XDormConfig.DormDataType.Target) + end + end + end + + -- 构造体数据 + if characterList then + for _, data in ipairs(characterList) do + TargetCharacterData[data.CharacterId] = data + if data.DormitoryId and data.DormitoryId > 0 then + local roomData = TargetDormitoryData[data.DormitoryId] + if roomData then + roomData:AddCharacter(data) + end + end + end + end + + -- 正在访问宿舍数据 + -- if visitorList then + -- for _, data in pairs(visitorList) do + -- TargetVisitorData[data.CharacterId] = data + -- end + -- end + end + + -- 推荐访问 + function XDormManager.RequestDormitoryRecommend(cb) + XNetwork.Call(DormitoryRequest.DormRecommendReq, nil, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + XDormManager.RecordDormitoryRecommend(res) + if cb then + cb(res) + end + end) + end + + -- 记录推荐访问数据 + function XDormManager.RecordDormitoryRecommend(data) + RecommVisData = {} + local d = data.Details or {} + for _, v in pairs(d) do + RecommVisIds[v.DormitoryId] = v.DormitoryId + RecommVisData[v.PlayerId] = v + end + end + + -- 取总的推荐访问数据 + function XDormManager.GetDormitoryRecommendTotalData() + return RecommVisData + end + + -- 取总的推荐访问数据 + function XDormManager.GetDormitoryRecommendScore(id) + if not id then + return + end + + return RecommVisData[id] + end + + function XDormManager.GetDormitoryTargetScore(roomId) + local roomData = XDormManager.GetRoomDataByRoomId(roomId, XDormConfig.DormDataType.Target) + if not roomData then + return + end + return XHomeDormManager.GetFurnitureScoresByRoomData(roomData, XDormConfig.DormDataType.Target) + end + + -- 取推荐访问id和是否是最后一个(当前dormId的下一个id,最后一个直接返回dormId和true) + function XDormManager.GetDormitoryRecommendDataForNext(dormId) + local data = XDormManager.GetDormitoryRecommendTotalDormId() + local len = #data + local f = false + + for i = 1, len do + if f then + return data[i], len == i + end + + if data[i] == dormId then + f = true + end + end + + return dormId, true + end + + -- 取推荐访问id和是否是前一个(当前dormId的上一个id,第一个直接返回dormId和true) + function XDormManager.GetDormitoryRecommendDataForPre(dormId) + local data = XDormManager.GetDormitoryRecommendTotalDormId() + local f = false + + for i, v in pairs(data) do + if f then + return v, i == 1 + end + + if v == dormId then + f = true + end + end + + return dormId, true + end + + -- 取所有推荐访问DormId + function XDormManager.GetDormitoryRecommendTotalDormId() + local d = {} + for _, v in pairs(RecommVisIds) do + table.insert(d, v) + end + return d + end + + function XDormManager.HandleVisFriendData(data) + if data then + for _, v in pairs(data) do + if v.DormitoryId ~= 0 then + v.DataTime = XTime.GetServerNowTimestamp() + RecommVisFriendData[v.PlayerId] = v + end + end + end + return RecommVisFriendData + end + + function XDormManager.GetVisFriendData() + return RecommVisFriendData + end + + function XDormManager.GetVisFriendById(playerid) + if not playerid then + return + end + + if RecommVisFriendData and RecommVisFriendData[playerid] then + return RecommVisFriendData[playerid] + end + end + -- 访问具体数据 + function XDormManager.RequestDormitoryDetails(players, cb) + XNetwork.Call(DormitoryRequest.DormDetailsReq, { Players = players }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + XDormManager.HandleVisFriendData(res.Details) + if cb then + cb() + end + end) + end + + -- 宿舍打工 + function XDormManager.RequestDormitoryWork(works, cb) + XNetwork.Call(DormitoryRequest.DormWorkReq, { Works = works }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + XDormManager.DormWorkRespHandle(res.WorkList) + if cb then + cb(res) + end + end) + end + + -- 打工成功修正数据 + function XDormManager.DormWorkRespHandle(workList) + if not workList then + return + end + + for _, data in pairs(workList) do + WorkListData[data.WorkPos] = data + local dormitoryId = XDormManager.GetCharacterRoomNumber(data.CharacterId) + if dormitoryId then + local room = XHomeDormManager.GetRoom(dormitoryId) + if room then + room:RemoveCharacter(dormitoryId, data.CharacterId) + end + end + end + end + + -- 宿舍打工领取奖励 + function XDormManager.RequestDormitoryWorkReward(posList, cb) + XNetwork.Call(DormitoryRequest.DormWorkRewardReq, { PosList = posList }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + XDormManager.DormWorkRewardGet(res.WorkRewards) + if cb then + cb() + end + end) + end + + -- 领取奖励成功修正数据 + function XDormManager.DormWorkRewardGet(workRewards) + if not workRewards or _G.next(workRewards) == nil then + return + end + + local rewards = {} + local workPos = {} + for _, v0 in pairs(workRewards) do + for _, v1 in pairs(WorkListData) do + if v1.WorkPos == v0.WorkPos then + if v0.ResetCount == 0 then + v1.WorkEndTime = 0 + else + workPos[v1.WorkPos] = v1.WorkPos + end + end + end + table.insert(rewards, { TemplateId = v0.ItemId, Count = v0.ItemNum, RewardType = v0.RewardType or XRewardManager.XRewardType.Item }) + end + + for pos, _ in pairs(workPos) do + for index, item in pairs(WorkListData) do + if item and item.WorkPos == pos then + WorkListData[index] = nil + end + end + end + + XUiManager.OpenUiObtain(rewards) + end + + -- 爱抚信息查询 + function XDormManager.GetDormFondleData(characterId, cb) + if not characterId then + return + end + + XNetwork.Call(DormitoryRequest.FondleDataReq, { CharacterId = characterId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local fondle = { LastRecoveryTime = res.LastRecoveryTime, LeftCount = res.FondleCount } + if cb then + cb(fondle) + end + end) + end + + -- 爱抚请求 + function XDormManager.DoFondleReq(characterId, fondleType, cb) + if not characterId or not fondleType then + return + end + + local now = XTime.GetServerNowTimestamp() + if fondleType == XDormConfig.TouchState.WaterGun then + if LastSyncServerTime + XDormConfig.WATERGUN_TIME >= now then + return + end + end + LastSyncServerTime = now + + local req = { CharacterId = characterId, FondleType = fondleType } + XNetwork.Call(DormitoryRequest.FondleReq, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + if cb then + cb() + end + end) + end + + -- 代工请求 + function XDormManager.DormWordDoneReq(workposList, cb) + if not workposList then + return + end + + local req = { WorkPos = workposList } + XNetwork.Call(DormitoryRequest.DormWordDoneReq, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XDormManager.DormCharacterRewardGet(res.WorkRewards, res.ExtraRewards, workposList) + XEventManager.DispatchEvent(XEventId.EVENT_DORM_DAI_GONE_REWARD) + if cb then + cb() + end + end) + end + --一键代工后回调(因为点返回不会重新读取小人状态,临时把角色小人加回宿舍) + function XDormManager.QuickDormDoneCallBack(workposList) + for _, pos in pairs(workposList) do + local data = WorkListData[pos] + if data then + local dormitoryId = XDormManager.GetCharacterRoomNumber(data.CharacterId) + if dormitoryId then + local room = XHomeDormManager.GetRoom(dormitoryId) + if room then + room:ResetCharacterList() + end + end + end + end + end + function XDormManager.DormCharacterRewardGet(workRewards, extraRewards) + if (not workRewards or _G.next(workRewards) == nil) and (not extraRewards or _G.next(extraRewards) == nil) then + return + end + + local rewards = {} + local workPos = {} + for _, v0 in pairs(workRewards) do + for _, v1 in pairs(WorkListData) do + if v1.WorkPos == v0.WorkPos then + if v0.ResetCount == 0 then + v1.WorkEndTime = 0 + else + workPos[v1.WorkPos] = v1.WorkPos + end + end + end + table.insert(rewards, { TemplateId = v0.ItemId, Count = v0.ItemNum, RewardType = v0.RewardType or XRewardManager.XRewardType.Item }) + end + + for _, v in pairs(extraRewards) do + table.insert(rewards, { TemplateId = v.TemplateId, Count = v.Count, RewardType = v.RewardType or XRewardManager.XRewardType.Item }) + end + + for pos, _ in pairs(workPos) do + for index, item in pairs(WorkListData) do + if item and item.WorkPos == pos then + WorkListData[index] = nil + end + end + end + + XUiManager.OpenUiObtain(rewards) + end + + function XDormManager.NotifyFurnitureUnLock(data) + XDormManager.FurnitureUnlockList = {} + if data and data.FurnitureUnlockList then + for _, v in pairs(data.FurnitureUnlockList) do + XDormManager.FurnitureUnlockList[v] = v + end + end + end + + function XDormManager.IdFurnitureUnLock(id) + return XDormManager.FurnitureUnlockList[id] ~= nil or XDataCenter.FurnitureManager.IsFieldGuideHave(id) + end + + -- 已使用的分享次数 + function XDormManager.NotifySnapshotTimes(data) + SnapshotTimes = data.SnapshotTimes + end + + function XDormManager.GetSnapshotTimes() + return SnapshotTimes + end + + -- 打工数据 + function XDormManager.NotifyDormWork(data) + if data and data.WorkList then + for _, tmpData in pairs(data.WorkList) do + WorkListData[tmpData.WorkPos] = tmpData + end + end + end + + function XDormManager.GetDormWorkByPos(pos) + return WorkListData[pos] + end + + function XDormManager.GetDormWorkRewCounrByPos(pos) + if WorkListData[pos] and WorkListData[pos].RewardNum then + return WorkListData[pos].RewardNum + end + + return 0 + end + + -- 打工Red + function XDormManager.DormWorkRedFun() + if _G.next(WorkListData) ~= nil then + for _, data in pairs(WorkListData) do + if data.WorkEndTime > 0 and data.WorkEndTime < XTime.GetServerNowTimestamp() then + return true + end + end + end + return false + end + + -- 重置打工工位 + function XDormManager.ResetDormWorkPos() + local workdata = {} + if _G.next(WorkListData) ~= nil then + for _, data in pairs(WorkListData) do + if data.WorkEndTime ~= 0 then + workdata[data.WorkPos] = data + end + end + end + WorkListData = workdata + end + + -- 启动 + function XDormManager.StartDormRedTimer() + if DormRedTimer then + return + end + + DormRedTimer = XScheduleManager.ScheduleForever(XDormManager.UpdateDormRed, 2000) + end + + -- 停止 + function XDormManager.StopDormRedTimer() + if not DormRedTimer then + return + end + + XScheduleManager.UnSchedule(DormRedTimer) + DormRedTimer = nil + end + + function XDormManager.UpdateDormRed() + XEventManager.DispatchEvent(XEventId.EVENT_DORM_WORK_REDARD) + XEventManager.DispatchEvent(XEventId.EVENT_FURNITURE_CREATE_CHANGED) + end + + -- 宿舍性别 + --function XDormManager.GetDormSex(characterId) + -- return XDormConfig.GetCharacterStyleConfigSexById(characterId) + --end + + function XDormManager.NotifyAddDormCharacter(data) + if data then + for _, v in pairs(data) do + CharacterData[v.CharacterId] = v + if v.DormitoryId and v.DormitoryId > 0 then + local roomData = DormitoryData[v.DormitoryId] + if roomData then + roomData:AddCharacter(v) + end + end + end + end + end + + -- 获取他人宿舍模板请求 + function XDormManager.DormGetPlayerLayoutReq(shareId, cb) + if not shareId then + return + end + + local req = { ShareId = shareId } + XNetwork.Call(DormitoryRequest.DormGetPlayerLayoutReq, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + + XDormManager.SetDormProvisionalData(shareId, res.FurnitureList) + if cb then + cb() + end + end) + end + + -- 绑定模板宿舍 + function XDormManager.DormBindLayoutReq(dormId, templateId, cb) + if not dormId or not templateId then + return + end + + local req = { DormitoryId = dormId, LayoutId = templateId } + XNetwork.Call(DormitoryRequest.DormBindLayoutReq, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + if cb then + cb() + end + end) + end + + -- 解除绑定模板宿舍 + function XDormManager.DormUnBindLayoutReq(templateId, cb) + if not templateId then + return + end + + local req = { LayoutId = templateId } + XNetwork.Call(DormitoryRequest.DormUnBindLayoutReq, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + if cb then + cb() + end + end) + end + + -- 收藏宿舍模板 + function XDormManager.DormCollectLayoutReq(id, name, furnitureList, cb) + if not id or not name or not furnitureList then + return + end + + local req = { LayoutId = id, LayoutName = name, FurnitureList = furnitureList } + XNetwork.Call(DormitoryRequest.DormCollectLayoutReq, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local collectDorm = TempDormitoryData[id] + if not collectDorm then -- 普通存储 + local newId = res.NewLayoutId + TempDormitoryData[newId] = XHomeRoomData.New(newId) + TempDormitoryData[newId]:SetPlayerId(XPlayer.Id) + TempDormitoryData[newId]:SetRoomName(name) + TempDormitoryData[newId]:SetRoomUnlock(true) + TempDormitoryData[newId]:SetRoomDataType(XDormConfig.DormDataType.Collect) + TempDormitoryData[newId]:SetRoomCreateTime(res.CreateTime) + + for _, furniture in ipairs(furnitureList) do + local incId = XGlobalVar.GetIncId() + TempDormitoryData[newId]:AddFurniture(incId, furniture.ConfigId, furniture.X, furniture.Y, furniture.Angle) + end + else -- 覆盖存储 + collectDorm:SetRoomName(name) + collectDorm:ClearFruniture() + for i, furniture in ipairs(furnitureList) do + collectDorm:AddFurniture(i, furniture.ConfigId, furniture.X, furniture.Y, furniture.Angle) + end + end + + local roomId = collectDorm and id or res.NewLayoutId + if cb then + cb(roomId) + end + end) + end + + -- 收藏宿舍摆放家具 + function XDormManager.CollectPutFunitrue(id, name, furnitureList, cb) + if not id or not name or not furnitureList then + return + end + + local req = { LayoutId = id, LayoutName = name, FurnitureList = furnitureList } + XNetwork.Call(DormitoryRequest.DormCollectLayoutReq, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + if cb then + cb() + end + end) + end + + -- 一键摆放模板宿舍 + function XDormManager.CopyTemplateDorm(roomId, templateDormId, roomType, cb) + local room = XDataCenter.DormManager.GetRoomDataByRoomId(roomId, XDormConfig.DormDataType.Self) + local templateRoom = XDataCenter.DormManager.GetRoomDataByRoomId(templateDormId, roomType) + if not room or not templateRoom then + return + end + + local roomFurnitureConfigs = room:GetFurnitureConfigDic() + local templateFurnitures = templateRoom:GetFurnitureDic() + + -- 未使用背包家具 + local caheBagConfigs = XTool.Clone(XDataCenter.FurnitureManager.GetUnuseFurnitue()) + -- 临时缓存宿舍数据 + local cacheRoom = XHomeRoomData.New(roomId) + + for _, v in pairs(templateFurnitures) do + local notFurniture = true + -- 检查当前宿舍中是否有此家具 + local furnitureIds = roomFurnitureConfigs[v.ConfigId] + if furnitureIds and #furnitureIds > 0 then + local id = furnitureIds[1] + notFurniture = false + cacheRoom:AddFurniture(id, v.ConfigId, v.GridX, v.GridY, v.RotateAngle) + table.remove(furnitureIds, 1) + else + -- 检查背包中是否有此家具 + local bagFurnitureIds = caheBagConfigs[v.ConfigId] + if bagFurnitureIds and #bagFurnitureIds > 0 then + local id = bagFurnitureIds[1] + notFurniture = false + cacheRoom:AddFurniture(id, v.ConfigId, v.GridX, v.GridY, v.RotateAngle) + table.remove(bagFurnitureIds, 1) + end + end + + -- 保留地板,天花板,墙 + local baseType = XFurnitureConfigs.HomeSurfaceBaseType + local tempF = nil + if XFurnitureConfigs.IsFurnitureMatchTypeByConfigId(v.ConfigId, baseType.Ground) and notFurniture then + tempF = room:GetGroundFurniture() + elseif XFurnitureConfigs.IsFurnitureMatchTypeByConfigId(v.ConfigId, baseType.Ceiling) and notFurniture then + tempF = room:GetCeillingFurniture() + elseif XFurnitureConfigs.IsFurnitureMatchTypeByConfigId(v.ConfigId, baseType.Wall) and notFurniture then + tempF = room:GetWallFurniture() + end + + if notFurniture and tempF then + cacheRoom:AddFurniture(tempF.Id, tempF.ConfigId, tempF.GridX, tempF.GridY, tempF.RotateAngle) + end + end + + local furnitures = cacheRoom:GetFurnitureDic() + local furnitureList = {} + for _, v in pairs(furnitures) do + local data = {} + data.Id = v.Id + data.X = v.GridX + data.Y = v.GridY + data.Angle = v.RotateAngle + table.insert(furnitureList, data) + end + + if #furnitureList <= 0 then + XUiManager.TipText("DormTemplateOneKeyNone", XUiManager.UiTipType.Tip) + return + end + + XDataCenter.FurnitureManager.PutFurniture(roomId, furnitureList, false, function() + XDormManager.SetRoomDataDormitoryId(room, 0) + XDormManager.SetRoomDataDormitoryId(cacheRoom, roomId) + + room:SetFurnitureDic(furnitures) + local datas = { room } + local isNotChangeView = true + XHomeDormManager.LoadRooms(datas, XDormConfig.DormDataType.Self, isNotChangeView) + if cb then + cb() + end + end) + end + --================ + --推送宿舍名变更 + --@param data:{ int DormId, string DormName} + --================ + function XDormManager.NotifyDormName(data) + local dorm = DormitoryData[data.DormId] + if dorm then dorm:SetRoomName(data.DormName) end + end + ---------------------end net--------------------- + + --- + --- 是否有权限访问其他玩家宿舍 + ---@param playerId number + ---@param appearanceShowType number 类型为XUiAppearanceShowType枚举 + ---@return boolean + function XDormManager.HasDormPermission(playerId, appearanceShowType) + if playerId == XPlayer.Id then + return true + else + if appearanceShowType then + if appearanceShowType == XUiAppearanceShowType.ToAll then + return true + elseif appearanceShowType == XUiAppearanceShowType.ToSelf then + return false + elseif appearanceShowType == XUiAppearanceShowType.ToFriend then + return XDataCenter.SocialManager.CheckIsFriend(playerId) + else + XLog.Error("XDormManager.HasDormPermission函数错误,展示设置不属于XUiAppearanceShowType类型") + return false + end + else + XLog.Error("XDormManager.HasDormPermission函数错误,没有玩家宿舍展示设置数据") + return false + end + end + end + + return XDormManager +end + +XRpc.NotifyDormVisitEnter = function(data) + XDataCenter.DormManager.NotifyDormVisitEnter(data) +end +--================ +--通知宿舍名称改变 +--@param data:{ int DormId, string DormName} +--================ +XRpc.NotifyDormName = function(data) + XDataCenter.DormManager.NotifyDormName(data) +end + +XRpc.NotifyWorkNextRefreshTime = function(data) + XDataCenter.DormManager.NotifyDormWorkRefreshTime(data) +end + +XRpc.NotifyCharacterAttr = function(data) + XDataCenter.DormManager.NotifyCharacterAttr(data) +end + +XRpc.NotifyCharacterMood = function(data) + XDataCenter.DormManager.NotifyCharacterMood(data) +end + +XRpc.NotifyCharacterVitality = function(data) + XDataCenter.DormManager.NotifyCharacterVitality(data) +end + +XRpc.NotifyDormCharacterRecovery = function(data) + XDataCenter.DormManager.NotifyCharacterSpeedChange(data) +end + +XRpc.NotifyDormCharacterAddEvent = function(data) + XDataCenter.DormManager.NotifyDormCharacterAddEvent(data) +end + +XRpc.NotifyDormCharacterSubEvent = function(data) + XDataCenter.DormManager.NotifyDormCharacterSubEvent(data) +end + +XRpc.NotifyDormitoryData = function(data) + -- 初始化默认一次的数据 + XDataCenter.DormManager.InitOnlyOnce() + -- 之前旧协议原有字段 + XDataCenter.DormManager.NotifyDormWork(data) + XDataCenter.DormManager.NotifySnapshotTimes(data) + XDataCenter.DormManager.NotifyFurnitureUnLock(data) + XDataCenter.FurnitureManager.InitFurnitureCreateList(data) + -- from DormitoryDataRequest + XDataCenter.DormManager.InitDormitoryData(data.DormitoryList) + XDataCenter.DormManager.InitFurnitureData(data.FurnitureList) + XDataCenter.DormManager.InitCharacterData(data.CharacterList) + XDataCenter.DormManager.InitdormCollectData(data.Layouts) + XDataCenter.DormManager.InitbindRelationData(data.BindRelations) + XDataCenter.FurnitureManager.InitData(data.FurnitureList) +end + +XRpc.NotifyAddDormCharacter = function(data) + XDataCenter.DormManager.NotifyAddDormCharacter(data) +end + +XRpc.NotifyDormExceptionItem = function(data) + XUiManager.TipMsg(CS.XTextManager.GetText("DormExceptionItemConvert")) +end + +XRpc.NotifyDormDailyReset = function (data) + XDataCenter.DormManager.NotifySnapshotTimes(data) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XDrawManager.lua b/Resources/Scripts/XManager/XDrawManager.lua new file mode 100644 index 00000000..7971f754 --- /dev/null +++ b/Resources/Scripts/XManager/XDrawManager.lua @@ -0,0 +1,497 @@ +XDrawManagerCreator = function() + + local XDrawManager = {} + + local tableInsert = table.insert + local tableSort = table.sort + + local GET_DRAW_DATA_INTERVAL = 15 + + local DrawGroupInfos = {} + local DrawInfos = {} + local LastGetGroupInfoTime = 0 + local LastGetDropInfoTimes = {} + + local DrawPreviews = {} + local DrawCombinations = {} + local DrawProbs = {} + local DrawGroupRule = {} + local DrawShow = {} + local DrawNewYearShow = {} + local DrawShowCharacter = {} + local DrawCamera = {} + local DrawTabs = {} + local ActivityDrawList = {} + local ActivityDrawListByTag = {} + local DrawActivityCount = 0 + local IsHasNewActivityDraw = false + local CurSelectTabInfo = nil + local LostSelectDrawGroupId = 0 + local LostSelectDrawType = 0 + + XDrawManager.DrawEventType = { Normal = 0, NewHand = 1, Activity = 2, OldActivity = 3 } + + function XDrawManager.Init() + DrawCombinations = XDrawConfigs.GetDrawCombinations() + DrawGroupRule = XDrawConfigs.GetDrawGroupRule() + DrawShow = XDrawConfigs.GetDrawShow() + DrawNewYearShow = XDrawConfigs.GetDrawNewYearShow() + DrawShowCharacter = XDrawConfigs.GetDrawShowCharacter() + DrawCamera = XDrawConfigs.GetDrawCamera() + DrawTabs = XDrawConfigs.GetDrawTabs() + DrawPreviews = XDrawConfigs.GetDrawPreviews() + DrawProbs = XDrawConfigs.GetDrawProbs() + end + + function XDrawManager.GetDrawPreview(drawId) + return DrawPreviews[drawId] + end + + function XDrawManager.GetDrawCombination(drawId) + return DrawCombinations[drawId] + end + + function XDrawManager.GetDrawProb(drawId) + local cfgs = DrawProbs[drawId] or {} + table.sort(cfgs, function(a, b) + return a.Sort < b.Sort + end) + return cfgs + end + + function XDrawManager.GetDrawGroupRule(groupId) + return DrawGroupRule[groupId] + end + + function XDrawManager.GetDrawShow(type) + return DrawShow[type - 1] + end + + function XDrawManager.GetDrawNewYearShow(type) + return DrawNewYearShow[type - 1] + end + + function XDrawManager.GetDrawCamera(id) + return DrawCamera[id] + end + + function XDrawManager.GetDrawInfo(drawId) + return DrawInfos[drawId] + end + + function XDrawManager.GetDrawShowCharacter(id) + return DrawShowCharacter[id] + end + + function XDrawManager.GetLostSelectDrawGroupId() + return LostSelectDrawGroupId + end + + function XDrawManager.SetLostSelectDrawGroupId(groupId) + LostSelectDrawGroupId = groupId + end + + function XDrawManager.GetLostSelectDrawType() + return LostSelectDrawType + end + + function XDrawManager.SetLostSelectDrawType(type) + LostSelectDrawType = type + end + + function XDrawManager.GetDrawInfoListByGroupId(groupId) + local list = {} + local drawAimProbability = XDrawConfigs.GetDrawAimProbability() + + for _, info in pairs(DrawInfos) do + if info.GroupId == groupId then + tableInsert(list, info) + end + end + + tableSort(list, function(a, b) + local PriorityA = drawAimProbability[a.Id] and drawAimProbability[a.Id].Priority or 0 + local PriorityB = drawAimProbability[b.Id] and drawAimProbability[b.Id].Priority or 0 + + if PriorityA == PriorityB then + return a.Id < b.Id + else + return PriorityA > PriorityB + end + end) + + return list + end + + function XDrawManager.GetUseDrawInfoByGroupId(groupId) + local groupInfo = DrawGroupInfos[groupId] + local UseDrawInfo = groupInfo.UseDrawId > 0 and XDrawManager.GetDrawInfo(groupInfo.UseDrawId) or nil + + if UseDrawInfo then + return UseDrawInfo + else + local list = XDrawManager.GetDrawInfoListByGroupId(groupId) + return list[1] + end + end + + function XDrawManager.GetDrawGroupInfoByGroupId(groupId) + return DrawGroupInfos[groupId] + end + + function XDrawManager.CheckDrawIsTimeOver(drawId) + if not DrawInfos[drawId] then + return true + end + if DrawInfos[drawId].EndTime == 0 then + return false + end + local nowTime = XTime.GetServerNowTimestamp() + return DrawInfos[drawId].EndTime - nowTime <= 0 + end + + -- 查询相关begin -- + function XDrawManager.GetDrawGroupInfos() + local list = {} + + for _, v in pairs(DrawGroupInfos) do + tableInsert(list, v) + end + + tableSort(list, function(a, b) + return a.Priority > b.Priority + end) + --检测如果有过期的,下次请求跳过时间间隔检测 + for _, v in pairs(list) do + if v.EndTime > 0 and v.EndTime - XTime.GetServerNowTimestamp() <= 0 then + LastGetGroupInfoTime = 0 + CurSelectTabInfo = nil + end + end + return list + end + + function XDrawManager.UpdateDrawGroupInfos(groupInfoList) + DrawGroupInfos = {} + + local isExpired = true + + for _, info in pairs(groupInfoList) do + DrawGroupInfos[info.Id] = info + DrawGroupInfos[info.Id].BottomTimes = DrawGroupInfos[info.Id].MaxBottomTimes - DrawGroupInfos[info.Id].BottomTimes + if CurSelectTabInfo then + if info.Id == CurSelectTabInfo.Id then + isExpired = false + end + end + end + + if isExpired then + CurSelectTabInfo = nil + end + end + + function XDrawManager.UpdateDrawInfos(drawInfoList) + --每次更新一组info之前清空之前相同GroupId的信息 + local deleteKey = {} + for k, v in pairs(DrawInfos) do + if v.GroupId == drawInfoList[1].GroupId then + deleteKey[k] = true + end + end + for k, _ in pairs(deleteKey) do + DrawInfos[k] = nil + end + + for _, info in pairs(drawInfoList) do + XDrawManager.UpdateDrawInfo(info) + end + end + + function XDrawManager.UpdateDrawInfo(drawInfo) + DrawInfos[drawInfo.Id] = XTool.Clone(drawInfo) + DrawInfos[drawInfo.Id].BottomTimes = DrawInfos[drawInfo.Id].MaxBottomTimes - DrawInfos[drawInfo.Id].BottomTimes + end + -- 查询相关end -- + -- 消息相关begin -- + function XDrawManager.GetDrawInfoList(groupId, cb, IsNotDoCoolDown) + local now = XTime.GetServerNowTimestamp() + if LastGetDropInfoTimes[groupId] and now - LastGetDropInfoTimes[groupId] <= GET_DRAW_DATA_INTERVAL and not IsNotDoCoolDown then + if cb then cb() end + return + end + XNetwork.Call("DrawGetDrawInfoListRequest", { GroupId = groupId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XDrawManager.UpdateDrawInfos(res.DrawInfoList) + LastGetDropInfoTimes[groupId] = now + if cb then cb() end + end) + end + + function XDrawManager.GetDrawGroupList(cb) + local now = XTime.GetServerNowTimestamp() + if now - LastGetGroupInfoTime <= GET_DRAW_DATA_INTERVAL then + if cb then cb() end + return + end + XNetwork.Call("DrawGetDrawGroupListRequest", nil, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XDrawManager.UpdateDrawGroupInfos(res.DrawGroupInfoList) + LastGetGroupInfoTime = now + if cb then cb() end + end) + end + + --==============================-- + --desc: 打乱奖励顺序,防止因规则造成顺序可循 + --@rewardGoodsList: 奖励列表 + --@return 处理后奖励列表 + --==============================-- + -- local function UpsetRewardGoodsList(rewardGoodsList) + -- local list = {} + + -- local len = #rewardGoodsList + -- if len <= 1 then + -- return rewardGoodsList + -- end + + -- for i = 1, len do + -- local index = math.random(1, len) + -- if index ~= i then + -- local tmp = rewardGoodsList[i] + -- rewardGoodsList[i] = rewardGoodsList[index] + -- rewardGoodsList[index] = tmp + -- end + -- end + + -- return rewardGoodsList + -- end + + function XDrawManager.DrawCard(drawId, count, cb, failCb) + XNetwork.Call("DrawDrawCardRequest", { DrawId = drawId, Count = count }, function(res) + if res.Code ~= XCode.Success then + if failCb then + failCb() + end + XUiManager.TipCode(res.Code) + return + end + XDrawManager.UpdateDrawInfo(res.ClientDrawInfo) + XDrawManager.UpdateDrawGroupByInfo(res.ClientDrawInfo) + local drawInfo = XDrawManager.GetDrawInfo(res.ClientDrawInfo.Id) + if cb then cb(drawInfo, res.RewardGoodsList, res.ExtraRewardList) end + end) + end + function XDrawManager.SaveDrawAimId(drawId, groupId, cb)--保存狙击目标 + XNetwork.Call("DrawSetUseDrawIdRequest", { DrawId = drawId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XDrawManager.GetDrawGroupInfoByGroupId(groupId).UseDrawId = drawId + XDrawManager.GetDrawGroupInfoByGroupId(groupId).SwitchDrawIdCount = res.SwitchDrawIdCount + if cb then cb() end + end) + end + -- 消息相关end -- + -- Wind -- + function XDrawManager.GetDrawTab(tabID) + for _, tab in pairs(DrawTabs) do + if tab.Id == tabID then + return tab + end + end + + XLog.Error("XDrawManager.GetDrawTab : Client/Draw/DrawTabs.tab 表中不存在 tabID:" .. tabID .. "检查参数或者配置表项") + return nil + end + + function XDrawManager.GetCurSelectTabInfo() + return CurSelectTabInfo + end + + function XDrawManager.SetCurSelectTabInfo(info) + CurSelectTabInfo = info + end + + function XDrawManager.UpdateDrawGroupByInfo(clientDrawInfo) + for _, v in pairs(DrawGroupInfos) do + if v.UseDrawId == clientDrawInfo.Id then + v.BottomTimes = clientDrawInfo.MaxBottomTimes - clientDrawInfo.BottomTimes + end + end + end + + function XDrawManager.GetActivityDrawMarkId(Id)--获取当前卡池ID的卡池在记录队列中的位置ID + local countMax = XSaveTool.GetData(string.format("%d%s", XPlayer.Id, "ActivityDrawCountMax")) + if countMax then + for i = 1, countMax do + local drawId = XSaveTool.GetData(string.format("%d%s%d", XPlayer.Id, "NewActivityDraw", i)) + if drawId then + if drawId == Id then + return i + end + end + end + end + return nil + end + + function XDrawManager.MarkActivityDraw()--记录当前开放的活动卡池 + for _, Id in pairs(ActivityDrawList or {}) do + if not XDrawManager.GetActivityDrawMarkId(Id) then + local count = 1 + while true do + if not XSaveTool.GetData(string.format("%d%s%d", XPlayer.Id, "NewActivityDraw", count)) then + XSaveTool.SaveData(string.format("%d%s%d", XPlayer.Id, "NewActivityDraw", count), Id) + local countMax = XSaveTool.GetData(string.format("%d%s", XPlayer.Id, "ActivityDrawCountMax")) + if (not countMax) or (countMax and countMax < count) then + XSaveTool.SaveData(string.format("%d%s", XPlayer.Id, "ActivityDrawCountMax"), count) + end + break + end + count = count + 1 + end + end + end + IsHasNewActivityDraw = false + end + + function XDrawManager.UnMarkOldActivityDraw(list)--消除已关闭卡池的记录 + local countMax = XSaveTool.GetData(string.format("%d%s", XPlayer.Id, "ActivityDrawCountMax")) + if countMax then + for i = 1, countMax do + local drawId = XSaveTool.GetData(string.format("%d%s%d", XPlayer.Id, "NewActivityDraw", i)) + if drawId then + local IsInList = false + for _, v in pairs(list or {}) do + if drawId == v then + IsInList = true + end + end + if not IsInList then + XSaveTool.RemoveData(string.format("%d%s%d", XPlayer.Id, "NewActivityDraw", i)) + end + end + end + end + end + + function XDrawManager.SetNewActivityDraw(list)--记录是否有新卡池开启 + IsHasNewActivityDraw = false + for _, v in pairs(list or {}) do + IsHasNewActivityDraw = IsHasNewActivityDraw or (not XDrawManager.GetActivityDrawMarkId(v)) + end + end + + function XDrawManager.CheckNewActivityDraw()--检查是否有新卡池开启 + if not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.DrawCard) then + return false + end + return IsHasNewActivityDraw + end + + function XDrawManager.UpdateDrawActivityCount(count) + DrawActivityCount = count + end + + function XDrawManager.UpdateActivityDrawList(list) + ActivityDrawList = list + end + + function XDrawManager.UpdateActivityDrawListByTag(lnfoList) + for _, v in pairs(lnfoList) do + if not ActivityDrawListByTag[v.Tag] then + ActivityDrawListByTag[v.Tag] = {} + end + local drawInfo = XDataCenter.DrawManager.GetUseDrawInfoByGroupId(v.Id) + table.insert(ActivityDrawListByTag[v.Tag], drawInfo.Id) + end + end + + function XDrawManager.CheckDrawActivityCount() + return DrawActivityCount > 0 + end + + function XDrawManager.IsCanAutoOpenAimGroupSelect(time, groupId) --判断time时间以内是否可以自动打开狙击池组合选择界面 + local data = XSaveTool.GetData(string.format("%d%s%d", XPlayer.Id, "AimAutoOpenState", groupId)) + if data then + if time > data then + XSaveTool.SaveData(string.format("%d%s%d", XPlayer.Id, "AimAutoOpenState", groupId), time) + return true + else + return false + end + else + XSaveTool.SaveData(string.format("%d%s%d", XPlayer.Id, "AimAutoOpenState", groupId), time) + return true + end + end + + function XDrawManager.IsShowNewTag(time, ruleType, groupId) --判断time时间以内是否显示新标签 + local data = XSaveTool.GetData(string.format("%d%s%d%d", XPlayer.Id, "DrawShowNewTag", ruleType, groupId)) + if data then + if time > data then + return true + else + return false + end + else + return true + end + end + + function XDrawManager.MarkNewTag(time, ruleType, groupId) --标记新标签 + local data = XSaveTool.GetData(string.format("%d%s%d%d", XPlayer.Id, "DrawShowNewTag", ruleType, groupId)) + if data then + if time > data then + XSaveTool.SaveData(string.format("%d%s%d%d", XPlayer.Id, "DrawShowNewTag", ruleType, groupId), time) + end + else + XSaveTool.SaveData(string.format("%d%s%d%d", XPlayer.Id, "DrawShowNewTag", ruleType, groupId), time) + end + end + + function XDrawManager.GetDrawPurchase(drawId) + local drawInfo = XDataCenter.DrawManager.GetDrawInfo(drawId) + if not drawInfo then + return {} + end + + local purchaseIds = drawInfo.PurchaseId + local drawPurchase = {} + if purchaseIds and next(purchaseIds) and drawInfo.PurchaseUiType then + for _, purchaseId in ipairs(purchaseIds) do + local purchaseData = XDataCenter.PurchaseManager.GetPurchaseData(drawInfo.PurchaseUiType, purchaseId) + if purchaseData then + tableInsert(drawPurchase, purchaseData) + end + end + end + + return drawPurchase + end + + -- WindEnd -- + XDrawManager.Init() + return XDrawManager +end + + +XRpc.NotifyActivityDrawGroupCount = function(data) + XDataCenter.DrawManager.UpdateDrawActivityCount(data.Count) + XEventManager.DispatchEvent(XEventId.EVENT_DRAW_ACTIVITYCOUNT_CHANGE) +end + +XRpc.NotifyActivityDrawList = function(data) + XDataCenter.DrawManager.UpdateActivityDrawList(data.DrawIdList) + XDataCenter.DrawManager.SetNewActivityDraw(data.DrawIdList) + XDataCenter.DrawManager.UnMarkOldActivityDraw(data.DrawIdList) + XEventManager.DispatchEvent(XEventId.EVENT_DRAW_ACTIVITYDRAW_CHANGE) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XEliminateGameManager.lua b/Resources/Scripts/XManager/XEliminateGameManager.lua new file mode 100644 index 00000000..cf68837c --- /dev/null +++ b/Resources/Scripts/XManager/XEliminateGameManager.lua @@ -0,0 +1,465 @@ +XEliminateGameManagerCreator = function() + + local XEliminateGameManager = {} + + + local Proto = { + RequestEliminateGameData = "EliminateGameDataRequest", --请求数据 + RequestEliminateGameFlip = "EliminateGameFlipRequest", --翻牌 + RequestEliminateGameMove = "EliminateGameMoveRequest", --移动 + RequestEliminateGameReset = "EliminateGameResetRequest", --重置 + RequestEliminateGameGetReward = "EliminateGameGetRewardRequest", --奖励 + } + + + XEliminateGameManager.EliminateGameSpecialType = { + Obstacle = 0, --障碍 + Space = 1001, --空 + } + + XEliminateGameManager.EliminateGameState = { + Close = 0, --关闭 + Flip = 1, --翻牌 + Move = 2 --移动 + } + + + XEliminateGameManager.EliminateGridState = { + Cover = 0, --盖住 + Normal = 1, --正常 + Reward = 2 --已经消除 + } + + + local EliminateGameData = {} + + function XEliminateGameManager.Init() + + end + + --获取 + function XEliminateGameManager.GetEliminateGameData(id) + return EliminateGameData[id] + end + + --尝试获取 + function XEliminateGameManager.TryGetEliminateGameData(id, cb) + if not EliminateGameData or not EliminateGameData[id] then + XEliminateGameManager.RequestEliminateGameData(id, cb) + else + if cb then + cb() + end + end + end + + --初始化游戏数据 + function XEliminateGameManager.InitEliminateGameData(id, res) + local data = EliminateGameData[id] or {} + data.State = res.State + data.CurGrids = res.CurGrids + data.RewardIds = res.RewardIds + data.MoveCost = res.MoveCost + local gameConfig = XEliminateGameConfig.GetEliminateGame(id) + if not gameConfig then + return + end + + data.Config = gameConfig + local gridInfo = {} + local eliminateInfo = {} + + local isEliminateAll = true + + for k, v in pairs(data.CurGrids) do + local grid = v + gridInfo[grid.X] = gridInfo[grid.X] or {} + gridInfo[grid.X][grid.Y] = grid + + local gridCfg = XEliminateGameConfig.GetEliminateGameGrid(grid.Id) + if grid.State == XEliminateGameManager.EliminateGridState.Reward then + local count = eliminateInfo[gridCfg.Type] or 0 + eliminateInfo[gridCfg.Type] = count + 1 + end + + if grid.State == XEliminateGameManager.EliminateGridState.Normal and gridCfg.Type ~= XEliminateGameManager.EliminateGameSpecialType.Space and gridCfg.Type ~= XEliminateGameManager.EliminateGameSpecialType.Obstacle then + isEliminateAll = false + end + + end + data.IsEliminateAll = isEliminateAll + data.EliminateInfo = eliminateInfo + data.GridInfo = gridInfo + data.Rewards = XEliminateGameConfig.GetEliminateGameRewardByGameId(id) + + EliminateGameData[id] = data + end + + + + --判断是否领奖 + function XEliminateGameManager.IsRewarded(id, rewardId) + local gameData = EliminateGameData[id] + + if not gameData then + return false + end + + if not gameData.RewardIds then + return false + end + + for i, v in ipairs(gameData.RewardIds) do + if v == rewardId then + return true + end + end + + return false + end + + + --判断是否完成 + function XEliminateGameManager.IsRewardFinish(rewardCfg) + local gameData = EliminateGameData[rewardCfg.GameId] + + if not gameData then + return false + end + + if not gameData.EliminateInfo then + return false + end + + local count = gameData.EliminateInfo[rewardCfg.GridType] + if not count then + return false + end + + if count >= rewardCfg.GridCount then + return true + end + + return false + end + + --检测是否有奖励 + function XEliminateGameManager.CheckGameHasReward(gameId) + if XEliminateGameManager.CheckTimeOut(gameId, true) then + return + end + + local gameData = EliminateGameData[gameId] + if not gameData then + return + end + + local rewardList = gameData.Rewards + for _, v in ipairs(rewardList) do + local isRewarded = XEliminateGameManager.IsRewarded(v.GameId, v.Id) + local isFinish = XEliminateGameManager.IsRewardFinish(v) + if not isRewarded and isFinish then + return true + end + end + + return false + end + + --检测过期 + function XEliminateGameManager.CheckTimeOut(id, isShowTip) + if id <= 0 then + return true + end + + local curTime = XTime.GetServerNowTimestamp() + local config = XEliminateGameConfig.GetEliminateGame(id) + local startTime, endTime = XFunctionManager.GetTimeByTimeId(config.TimeId) + if curTime < startTime then + if isShowTip then + XUiManager.TipMsg(CS.XTextManager.GetText("EliminateNotOpen")) + end + return true + end + + if curTime > endTime then + if isShowTip then + XUiManager.TipMsg(CS.XTextManager.GetText("EliminateTimeOut")) + end + return true + end + + return false + end + + + function XEliminateGameManager.CheckCanFlipGrid(gameId) + if XEliminateGameManager.CheckTimeOut(gameId, true) then + return + end + + local gameData = EliminateGameData[gameId] + if not gameData then + return + end + + local flipCostItem = gameData.Config.FlipItemId + local count = XDataCenter.ItemManager.GetCount(flipCostItem) + local name = XDataCenter.ItemManager.GetItemName(flipCostItem) + if count <= 0 or count < gameData.Config.FlipItemCount then + XUiManager.TipMsg(string.format(CS.XTextManager.GetText("EliminateFlipItemLack"), gameData.Config.FlipItemCount, name)) + return false + end + + return true + end + + + function XEliminateGameManager.CheckCanExchangeGrid(gameId, isTip) + if XEliminateGameManager.CheckTimeOut(gameId, true) then + return + end + + local gameData = EliminateGameData[gameId] + if not gameData then + return + end + + local costItem = gameData.Config.MoveItemId + local count = XDataCenter.ItemManager.GetCount(costItem) + local name = XDataCenter.ItemManager.GetItemName(costItem) + if count <= 0 or count < gameData.Config.MoveItemCount then + if isTip then + XUiManager.TipMsg(string.format(CS.XTextManager.GetText("EliminateExchangeItemLack"), gameData.Config.MoveItemCount, name)) + end + return false + end + + return true + end + + + + --翻牌处理 + function XEliminateGameManager.OnFlip(gameId, x, y, result) + local gameData = EliminateGameData[gameId] + if not gameData then + return + end + + if result.State and gameData.State ~= result.State then + XUiManager.TipText("EliminateFlipEnd", XUiManager.UiTipType.Tip) + gameData.State = result.State + end + + local eliminateInfo = {} + for k, v in pairs(gameData.CurGrids) do + --被翻开 + if v.X == x and v.Y == y then + v.State = XEliminateGameManager.EliminateGridState.Normal + end + + --检测消除 + if result.EliminateGrids then + for _, var in ipairs(result.EliminateGrids) do + if v.X == var.X and v.Y == var.Y then + v.State = var.State + end + end + end + + local grid = v + local gridCfg = XEliminateGameConfig.GetEliminateGameGrid(grid.Id) + if grid.State == XEliminateGameManager.EliminateGridState.Reward then + local count = eliminateInfo[gridCfg.Type] or 0 + eliminateInfo[gridCfg.Type] = count + 1 + end + end + + gameData.EliminateInfo = eliminateInfo + end + + --格子交换 + function XEliminateGameManager.OnExchangeGrid(gameId, x, y, dstX, dstY, result) + local gameData = EliminateGameData[gameId] + if not gameData then + return + end + + gameData.MoveCost = result.MoveCost + + --交换ID + local lineCount = gameData.Config.LineCount + local indexA = x + (y - 1) * lineCount + local indexB = dstX + (dstY - 1) * lineCount + + local gridA, gridB + for k, v in ipairs(gameData.CurGrids) do + if v.X == x and v.Y == y then + gridA = v + end + + if v.X == dstX and v.Y == dstY then + gridB = v + end + end + + gridA.X = dstX + gridA.Y = dstY + gridB.X = x + gridB.Y = y + + local isEliminateAll = true + local eliminateInfo = {} + for k, v in ipairs(gameData.CurGrids) do + + --检测消除 + if result.EliminateGrids then + for _, var in ipairs(result.EliminateGrids) do + if v.X == var.X and v.Y == var.Y then + v.State = var.State + end + end + end + + + local grid = v + local gridCfg = XEliminateGameConfig.GetEliminateGameGrid(grid.Id) + if grid.State == XEliminateGameManager.EliminateGridState.Reward then + local count = eliminateInfo[gridCfg.Type] or 0 + eliminateInfo[gridCfg.Type] = count + 1 + end + + if grid.State == XEliminateGameManager.EliminateGridState.Normal and gridCfg.Type ~= XEliminateGameManager.EliminateGameSpecialType.Space and gridCfg.Type ~= XEliminateGameManager.EliminateGameSpecialType.Obstacle then + isEliminateAll = false + end + end + + gameData.EliminateInfo = eliminateInfo + gameData.IsEliminateAll = isEliminateAll + + end + + -- 保存本地数据 + function XEliminateGameManager.SaveEliminateGamePrefs(value, id) + if XPlayer.Id and id then + local key = string.format("EliminateGame_%s_%s", tostring(XPlayer.Id), id) + CS.UnityEngine.PlayerPrefs.SetInt(key, value) + CS.UnityEngine.PlayerPrefs.Save() + end + end + + function XEliminateGameManager.GetEliminateGamePrefs(id) + if XPlayer.Id and id then + local key = string.format("EliminateGame_%s_%s", tostring(XPlayer.Id), id) + if CS.UnityEngine.PlayerPrefs.HasKey(key) then + local value = CS.UnityEngine.PlayerPrefs.GetInt(key, 0) + return value + end + end + + return 0 + end + + ---------------------------------------------------------------------------------- + --请求游戏数据 + function XEliminateGameManager.RequestEliminateGameData(id, cb) + XNetwork.Call(Proto.RequestEliminateGameData, { Id = id }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + XEliminateGameManager.InitEliminateGameData(id, res) + + if cb then + cb() + end + + end) + end + + + --请求游戏翻牌 + function XEliminateGameManager.RequestEliminateGameFlip(id, x, y, cb) + XNetwork.Call(Proto.RequestEliminateGameFlip, { Id = id, X = x, Y = y }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + XEliminateGameManager.OnFlip(id, x, y, res) + + if cb then + cb(res.EliminateGrids) + end + + end) + end + + --请求交换位置 + function XEliminateGameManager.RequestEliminateGameMove(id, srcX, srcY, desX, desY, cb) + XNetwork.Call(Proto.RequestEliminateGameMove, { Id = id, SrcX = srcX, SrcY = srcY, DesX = desX, DesY = desY }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + XEliminateGameManager.OnExchangeGrid(id, srcX, srcY, desX, desY, res) + + if cb then + cb(res.EliminateGrids) + end + + end) + end + + --请求重置 + function XEliminateGameManager.RequestEliminateGameReset(id, cb) + XNetwork.Call(Proto.RequestEliminateGameReset, { Id = id }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local gameData = EliminateGameData[id] + + if gameData then + gameData.MoveCost = res.MoveCost + gameData.CurGrids = res.CurGrids + end + + if cb then + cb() + end + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_ELIMINATEGAME_RESET) + + end) + end + + + --请求奖励 + function XEliminateGameManager.RequestEliminateGameGetReward(gameId, id) + XNetwork.Call(Proto.RequestEliminateGameGetReward, { Id = id }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local gameData = EliminateGameData[gameId] + if gameData then + table.insert(gameData.RewardIds, id) + end + + if res.RewardGoods then + XUiManager.OpenUiObtain(res.RewardGoods, CS.XTextManager.GetText("Award")) + end + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_ELIMINATEGAME_GET_REWARD) + end) + end + + ----------------------------------------------------------------------------------- + return XEliminateGameManager +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XEquipManager.lua b/Resources/Scripts/XManager/XEquipManager.lua new file mode 100644 index 00000000..aa3e4368 --- /dev/null +++ b/Resources/Scripts/XManager/XEquipManager.lua @@ -0,0 +1,3249 @@ +XEquipManagerCreator = function() + local pairs = pairs + local type = type + local table = table + local next = next + local tableInsert = table.insert + local tableRemove = table.remove + local tableSort = table.sort + local mathMin = math.min + local mathFloor = math.floor + local CSXTextManagerGetText = CS.XTextManager.GetText + + local XEquipManager = {} + local Equips = {} -- 装备数据 + local WeaponTypeCheckDic = {} + local AwarenessTypeCheckDic = {} + local OverLimitTexts = {} + local AwarenessSuitPrefabInfoList = {} --意识组合预设 + local AwakeItemTypeDic = {} + + local EQUIP_FIRST_GET_KEY = "EquipFirstGetTemplateIds" + local EQUIP_DECOMPOSE_RETURN_RATE = CS.XGame.Config:GetInt("EquipDecomposeReturnRate") / 10000 + local EQUIP_SUIT_PREFAB_MAX_NUM = CS.XGame.Config:GetInt("EquipSuitPrefabMaxNum") + local EQUIP_SUIT_CHARACTER_PREFAB_MAX_NUM = CS.XGame.Config:GetInt("EquipSuitCharacterPrefabMaxNum") + + local XEquip = require("XEntity/XEquip/XEquip") + local XEquipSuitPrefab = require("XEntity/XEquip/XEquipSuitPrefab") + local XSkillInfoObj = require("XEntity/XEquip/XSkillInfoObj") + -----------------------------------------Privite Begin------------------------------------ + local function GetEquipTemplateId(equipId) + local equip = XEquipManager.GetEquip(equipId) + return equip.TemplateId + end + + local function GetEquipCfg(equipId) + local templateId = GetEquipTemplateId(equipId) + return XEquipConfig.GetEquipCfg(templateId) + end + + local function CheckEquipExist(equipId) + return Equips[equipId] + end + + local function GetEquipBorderCfg(equipId) + local templateId = GetEquipTemplateId(equipId) + return XEquipConfig.GetEquipBorderCfg(templateId) + end + + local function GetSuitPresentEquipTemplateId(suitId) + local templateIds = XEquipConfig.GetEquipTemplateIdsBySuitId(suitId) + return templateIds and templateIds[1] + end + + local function GetEquipBreakthroughCfg(equipId) + local equip = XEquipManager.GetEquip(equipId) + return XEquipConfig.GetEquipBreakthroughCfg(equip.TemplateId, equip.Breakthrough) + end + + local function GetEquipBreakthroughCfgNext(equipId) + local equip = XEquipManager.GetEquip(equipId) + return XEquipConfig.GetEquipBreakthroughCfg(equip.TemplateId, equip.Breakthrough + 1) + end + + local function InitEquipTypeCheckDic() + WeaponTypeCheckDic[XEquipConfig.EquipSite.Weapon] = XEquipConfig.Classify.Weapon + for _, site in pairs(XEquipConfig.EquipSite.Awareness) do + AwarenessTypeCheckDic[site] = XEquipConfig.Classify.Awareness + end + end + + local function GetSuitPrefabInfoList() + return AwarenessSuitPrefabInfoList + end + + local function GetEquipAwakeCfg(equipId) + local equip = XEquipManager.GetEquip(equipId) + return XEquipConfig.GetEquipAwakeCfg(equip.TemplateId) + end + + local function InitAwakeItemTypeDic() + local equipAwakeCfgs = XEquipConfig.GetEquipAwakeCfgs() + for _, equipAwakeCfg in pairs(equipAwakeCfgs) do + local itemIds = equipAwakeCfg.ItemId + if itemIds then + for _, itemId in pairs(itemIds) do + local awakeItemType = AwakeItemTypeDic[itemId] + if not awakeItemType then + awakeItemType = {} + AwakeItemTypeDic[itemId] = awakeItemType + end + local equipCfg = XEquipConfig.GetEquipCfg(equipAwakeCfg.Id) + if not awakeItemType[equipCfg.SuitId] then + awakeItemType[equipCfg.SuitId] = equipCfg.SuitId + end + end + end + end + end + + InitEquipTypeCheckDic() + InitAwakeItemTypeDic() + -----------------------------------------Privite End------------------------------------ + function XEquipManager.InitEquipData(equipsData) + for _, equip in pairs(equipsData) do + Equips[equip.Id] = XEquipManager.NewEquip(equip) + end + + XEventManager.DispatchEvent(XEventId.EVENT_EQUIP_DATA_INIT_NOTIFY) + end + + function XEquipManager.NewEquip(protoData) + return XEquip.New(protoData) + end + + function XEquipManager.NotifyEquipDataList(data) + local syncList = data.EquipDataList + if not syncList then + return + end + + for _, equip in pairs(syncList) do + XEquipManager.OnSyncEquip(equip) + end + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_EQUIP_DATA_LIST_UPDATE_NOTYFY) + end + + function XEquipManager.NotifyEquipChipGroupList(data) + AwarenessSuitPrefabInfoList = {} + local chipGroupDataList = data.ChipGroupDataList + for _, chipGroupData in ipairs(chipGroupDataList) do + tableInsert(AwarenessSuitPrefabInfoList, XEquipSuitPrefab.New(chipGroupData)) + end + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_EQUIP_SUIT_PREFAB_DATA_UPDATE_NOTIFY) + end + + function XEquipManager.OnSyncEquip(protoData) + local equip = Equips[protoData.Id] + if not equip then + equip = XEquipManager.NewEquip(protoData) + Equips[protoData.Id] = equip + + -- local templateId = protoData.TemplateId + -- if XEquipManager.CheckFirstGet(templateId) then + -- XUiHelper.PushInFirstGetIdList(templateId, XArrangeConfigs.Types.Weapon) + -- end + else + equip:SyncData(protoData) + end + + XEventManager.DispatchEvent(XEventId.EVENT_EQUIP_DATA_CHANGE_NOTIFY, equip) + end + + function XEquipManager.DeleteEquip(equipProtoId) + Equips[equipProtoId] = nil + end + + function XEquipManager.GetEquip(equipId) + local equip = Equips[equipId] + if not equip then + XLog.Error("XEquipManager.GetEquip错误, 无法根据equipId: " .. equipId .. "从服务端返回的装备列表中获得数据") + return + end + return equip + end + + --desc: 获取所有武器equipId + function XEquipManager.GetWeaponIds() + local weaponIds = {} + for k, v in pairs(Equips) do + if XEquipManager.IsClassifyEqual(v.Id, XEquipConfig.Classify.Weapon) then + tableInsert(weaponIds, k) + end + end + return weaponIds + end + + function XEquipManager.GetWeaponCount() + local weaponIds = XEquipManager.GetWeaponIds() + return weaponIds and #weaponIds or 0 + end + + function XEquipManager.GetAwarenessCount(characterType) + local awarenessIds = XEquipManager.GetAwarenessIds(characterType) + return awarenessIds and #awarenessIds or 0 + end + + function XEquipManager.GetSuitIdsByStars(starCheckList) + local suitIds = {} + + local doNotRepeatSuitIds = {} + local equipIds = XEquipManager.GetAwarenessIds() + for _, equipId in pairs(equipIds) do + local templateId = GetEquipTemplateId(equipId) + local star = XEquipManager.GetEquipStar(templateId) + + if starCheckList[star] then + local suitId = XEquipManager.GetSuitId(equipId) + if suitId > 0 then + doNotRepeatSuitIds[suitId] = true + end + end + end + + for suitId in pairs(doNotRepeatSuitIds) do + tableInsert(suitIds, suitId) + end + + --展示排序:构造体〉感染体〉通用 + local UserTypeSortPriority = { + [XEquipConfig.UserType.All] = 1, + [XEquipConfig.UserType.Isomer] = 2, + [XEquipConfig.UserType.Normal] = 3, + } + tableSort(suitIds, function(lSuitID, rSuitID) + local lStar = XEquipManager.GetSuitStar(lSuitID) + local rStar = XEquipManager.GetSuitStar(rSuitID) + if lStar ~= rStar then + return lStar > rStar + end + + local aCharacterType = XEquipManager.GetSuitCharacterType(lSuitID) + local bCharacterType = XEquipManager.GetSuitCharacterType(rSuitID) + if aCharacterType ~= bCharacterType then + return UserTypeSortPriority[aCharacterType] > UserTypeSortPriority[bCharacterType] + end + end) + + tableInsert(suitIds, 1, XEquipConfig.DEFAULT_SUIT_ID.Normal) + tableInsert(suitIds, 2, XEquipConfig.DEFAULT_SUIT_ID.Isomer) + + return suitIds + end + + function XEquipManager.GetDecomposeRewardEquipCount(equipId) + local weaponCount, awarenessCount = 0, 0 + + local rewards = XEquipManager.GetDecomposeRewards({ equipId }) + for _, v in pairs(rewards) do + if XArrangeConfigs.GetType(v.TemplateId) == XArrangeConfigs.Types.Weapon then + weaponCount = weaponCount + v.Count + elseif XArrangeConfigs.GetType(v.TemplateId) == XArrangeConfigs.Types.Wafer then + awarenessCount = awarenessCount + v.Count + end + end + + return weaponCount, awarenessCount + end + + function XEquipManager.GetDecomposeRewards(equipIds) + local itemInfoList = {} + + local rewards = {} + local coinId = XDataCenter.ItemManager.ItemId.Coin + XTool.LoopCollection(equipIds, function(equipId) + local equip = XEquipManager.GetEquip(equipId) + local decomposeconfig = XEquipConfig.GetEquipDecomposeCfg(equip.TemplateId, equip.Breakthrough) + local levelUpCfg = XEquipConfig.GetLevelUpCfg(equip.TemplateId, equip.Breakthrough, equip.Level) + local equipBreakthroughCfg = GetEquipBreakthroughCfg(equipId) + local exp = (equip.Exp + levelUpCfg.AllExp + equipBreakthroughCfg.Exp) + + local expToCoin = mathFloor(exp / decomposeconfig.ExpToOneCoin) + if expToCoin > 0 then + local coinReward = rewards[coinId] + if coinReward then + coinReward.Count = coinReward.Count + expToCoin + else + rewards[coinId] = XRewardManager.CreateRewardGoods(coinId, expToCoin) + end + end + + local ratedExp = exp * EQUIP_DECOMPOSE_RETURN_RATE + local expToFoodId = decomposeconfig.ExpToItemId + local singleExp = XDataCenter.ItemManager.GetItemsAddEquipExp(expToFoodId) + local expToFoodCount = mathFloor(ratedExp / (singleExp)) + if expToFoodCount > 0 then + local foodReward = rewards[expToFoodId] + if foodReward then + foodReward.Count = foodReward.Count + expToFoodCount + else + rewards[expToFoodId] = XRewardManager.CreateRewardGoods(expToFoodId, expToFoodCount) + end + end + + if decomposeconfig.RewardId > 0 then + local rewardList = XRewardManager.GetRewardList(decomposeconfig.RewardId) + for _, item in pairs(rewardList) do + if rewards[item.TemplateId] then + rewards[item.TemplateId].Count = rewards[item.TemplateId].Count + item.Count + else + rewards[item.TemplateId] = XRewardManager.CreateRewardGoodsByTemplate(item) + end + end + end + end) + + for _, reward in pairs(rewards) do + tableInsert(itemInfoList, reward) + end + itemInfoList = XRewardManager.SortRewardGoodsList(itemInfoList) + + return itemInfoList + end + + function XEquipManager.GetSuitPrefabNum() + return #AwarenessSuitPrefabInfoList + end + + function XEquipManager.GetSuitPrefabNumMax() + return EQUIP_SUIT_PREFAB_MAX_NUM + end + + function XEquipManager.GetEquipSuitCharacterPrefabMaxNum() + return EQUIP_SUIT_CHARACTER_PREFAB_MAX_NUM + end + + function XEquipManager.GetSuitPrefabIndexList(characterType) + local prefabIndexList = {} + + for index, suitPrefab in pairs(AwarenessSuitPrefabInfoList) do + if not characterType or suitPrefab:GetCharacterType() == characterType then + tableInsert(prefabIndexList, index) + end + end + + return prefabIndexList + end + + function XEquipManager.GetSuitPrefabInfo(index) + return index and AwarenessSuitPrefabInfoList[index] + end + + function XEquipManager.SaveSuitPrefabInfo(equipGroupData) + tableInsert(AwarenessSuitPrefabInfoList, XEquipSuitPrefab.New(equipGroupData)) + end + + function XEquipManager.DeleteSuitPrefabInfo(index) + if not index then return end + tableRemove(AwarenessSuitPrefabInfoList, index) + end + + function XEquipManager.GetUnSavedSuitPrefabInfo(characterId) + local equipGroupData = { + Name = "", + ChipIdList = XEquipManager.GetCharacterWearingAwarenessIds(characterId), + } + return XEquipSuitPrefab.New(equipGroupData) + end + -----------------------------------------Function Begin------------------------------------ + local DefaultSort = function(a, b, exclude) + if not exclude or exclude ~= XEquipConfig.PriorSortType.Star then + local aStar = XEquipManager.GetEquipStar(a.TemplateId) + local bStar = XEquipManager.GetEquipStar(b.TemplateId) + if aStar ~= bStar then + return aStar > bStar + end + end + + if not exclude or exclude ~= XEquipConfig.PriorSortType.Breakthrough then + if a.Breakthrough ~= b.Breakthrough then + return a.Breakthrough > b.Breakthrough + end + end + + if not exclude or exclude ~= XEquipConfig.PriorSortType.Level then + if a.Level ~= b.Level then + return a.Level > b.Level + end + end + + if a.IsRecycle ~= b.IsRecycle then + return a.IsRecycle == false + end + + return XEquipManager.GetEquipPriority(a.TemplateId) > XEquipManager.GetEquipPriority(b.TemplateId) + end + + function XEquipManager.SortEquipIdListByPriorType(equipIdList, priorSortType) + local sortFunc + + if priorSortType == XEquipConfig.PriorSortType.Level then + sortFunc = function(aId, bId) + local a = XEquipManager.GetEquip(aId) + local b = XEquipManager.GetEquip(bId) + if a.Level ~= b.Level then + return a.Level > b.Level + end + return DefaultSort(a, b, priorSortType) + end + elseif priorSortType == XEquipConfig.PriorSortType.Breakthrough then + sortFunc = function(aId, bId) + local a = XEquipManager.GetEquip(aId) + local b = XEquipManager.GetEquip(bId) + if a.Breakthrough ~= b.Breakthrough then + return a.Breakthrough > b.Breakthrough + end + return DefaultSort(a, b, priorSortType) + end + elseif priorSortType == XEquipConfig.PriorSortType.Star then + sortFunc = function(aId, bId) + local a = XEquipManager.GetEquip(aId) + local b = XEquipManager.GetEquip(bId) + local aStar = XEquipManager.GetEquipStar(a.TemplateId) + local bStar = XEquipManager.GetEquipStar(b.TemplateId) + if aStar ~= bStar then + return aStar > bStar + end + return DefaultSort(a, b, priorSortType) + end + elseif priorSortType == XEquipConfig.PriorSortType.Proceed then + sortFunc = function(aId, bId) + local a = XEquipManager.GetEquip(aId) + local b = XEquipManager.GetEquip(bId) + if a.CreateTime ~= b.CreateTime then + return a.CreateTime < b.CreateTime + end + return DefaultSort(a, b, priorSortType) + end + else + sortFunc = function(aId, bId) + local a = XEquipManager.GetEquip(aId) + local b = XEquipManager.GetEquip(bId) + return DefaultSort(a, b) + end + end + + tableSort(equipIdList, function(aId, bId) + --强制优先插入装备中排序 + local aWearing = XEquipManager.IsWearing(aId) and 1 or 0 + local bWearing = XEquipManager.IsWearing(bId) and 1 or 0 + if aWearing ~= bWearing then + return aWearing < bWearing + end + + return sortFunc(aId, bId) + end) + end + + function XEquipManager.ConstructAwarenessStarToSiteToSuitIdsDic(characterType, IsGift) + local starToSuitIdsDic = {} + + local doNotRepeatSuitIds = {} + local equipIds = XEquipManager.GetAwarenessIds(characterType) + for _, equipId in pairs(equipIds) do + local templateId = GetEquipTemplateId(equipId) + + local star = XEquipManager.GetEquipStar(templateId) + doNotRepeatSuitIds[star] = doNotRepeatSuitIds[star] or {} + + local site = XEquipManager.GetEquipSite(equipId) + doNotRepeatSuitIds[star][site] = doNotRepeatSuitIds[star][site] or {} + doNotRepeatSuitIds[star].Total = doNotRepeatSuitIds[star].Total or {} + + local suitId = XEquipManager.GetSuitId(equipId) + if suitId > 0 then + local IsCanBeGift = XEquipManager.IsCanBeGift(equipId) + if not IsGift or IsCanBeGift then + doNotRepeatSuitIds[star][site][suitId] = true + doNotRepeatSuitIds[star]["Total"][suitId] = true + end + end + end + + for star = 1, XEquipConfig.MAX_STAR_COUNT do + starToSuitIdsDic[star] = {} + + for _, site in pairs(XEquipConfig.EquipSite.Awareness) do + starToSuitIdsDic[star][site] = {} + + if doNotRepeatSuitIds[star] and doNotRepeatSuitIds[star][site] then + for suitId in pairs(doNotRepeatSuitIds[star][site]) do + tableInsert(starToSuitIdsDic[star][site], suitId) + end + end + end + + starToSuitIdsDic[star].Total = {} + if doNotRepeatSuitIds[star] then + for suitId in pairs(doNotRepeatSuitIds[star]["Total"]) do + tableInsert(starToSuitIdsDic[star]["Total"], suitId) + end + end + end + + return starToSuitIdsDic + end + + function XEquipManager.ConstructAwarenessSiteToEquipIdsDic(characterType, IsGift) + local siteToEquipIdsDic = {} + + for _, site in pairs(XEquipConfig.EquipSite.Awareness) do + siteToEquipIdsDic[site] = {} + end + + local equipIds = XEquipManager.GetAwarenessIds(characterType) + for _, equipId in pairs(equipIds) do + local IsCanBeGift = XEquipManager.IsCanBeGift(equipId) + if not IsGift or IsCanBeGift then + local site = XEquipManager.GetEquipSite(equipId) + tableInsert(siteToEquipIdsDic[site], equipId) + end + end + + return siteToEquipIdsDic + end + + function XEquipManager.ConstructAwarenessSuitIdToEquipIdsDic(characterType, IsGift) + local suitIdToEquipIdsDic = {} + + local equipIds = XEquipManager.GetAwarenessIds(characterType) + for _, equipId in pairs(equipIds) do + local suitId = XEquipManager.GetSuitId(equipId) + suitIdToEquipIdsDic[suitId] = suitIdToEquipIdsDic[suitId] or {} + + if suitId > 0 then + local site = XEquipManager.GetEquipSite(equipId) + suitIdToEquipIdsDic[suitId]["Total"] = suitIdToEquipIdsDic[suitId]["Total"] or {} + suitIdToEquipIdsDic[suitId][site] = suitIdToEquipIdsDic[suitId][site] or {} + + local IsCanBeGift = XEquipManager.IsCanBeGift(equipId) + if not IsGift or IsCanBeGift then + tableInsert(suitIdToEquipIdsDic[suitId][site], equipId) + tableInsert(suitIdToEquipIdsDic[suitId]["Total"], equipId) + end + end + end + + return suitIdToEquipIdsDic + end + + function XEquipManager.ConstructAwarenessResonanceTypeToEquipIdsDic(characterId) + local ResonanceType = { + CurCharacter = 1, --当前角色共鸣 + Others = 2, --其他角色共鸣 + None = 3, --无共鸣 + } + local resonanceTypeToEquipIdsDic = { + [ResonanceType.CurCharacter] = {}, + [ResonanceType.Others] = {}, + [ResonanceType.None] = {}, + } + + local characterType = XCharacterConfigs.GetCharacterType(characterId) + local equipIds = XEquipManager.GetAwarenessIds(characterType) + for _, equipId in pairs(equipIds) do + local resonanceType = ResonanceType.None + + local isFive = XEquipManager.IsFiveStar(equipId) + local equip = XEquipManager.GetEquip(equipId) + + local resonanceInfo = equip.ResonanceInfo + if resonanceInfo then + for _, data in pairs(resonanceInfo) do + --五星共鸣过的意识属于【当前角色共鸣】分类中 + if isFive then + resonanceType = ResonanceType.CurCharacter + break + end + + if data.CharacterId == characterId then + resonanceType = ResonanceType.CurCharacter + break + end + + resonanceType = ResonanceType.Others + end + end + + tableInsert(resonanceTypeToEquipIdsDic[resonanceType], equipId) + end + + + return resonanceTypeToEquipIdsDic + end + + function XEquipManager.TipEquipOperation(equipId, changeTxt, closeCb, setMask) + local uiName = "UiEquipCanBreakthroughTip" + if XLuaUiManager.IsUiShow(uiName) then + XLuaUiManager.Remove(uiName) + end + XLuaUiManager.Open(uiName, equipId, changeTxt, closeCb, setMask) + end + -----------------------------------------Function End------------------------------------ + -----------------------------------------Protocol Begin------------------------------------ + function XEquipManager.PutOn(characterId, equipId) + if not XDataCenter.CharacterManager.IsOwnCharacter(characterId) then + XUiManager.TipText("EquipPutOnNotChar") + return + end + + local equipSpecialCharacterId = XEquipManager.GetEquipSpecialCharacterId(equipId) + if equipSpecialCharacterId and equipSpecialCharacterId ~= characterId then + local char = XDataCenter.CharacterManager.GetCharacter(equipSpecialCharacterId) + if char then + local characterName = XCharacterConfigs.GetCharacterName(equipSpecialCharacterId) + local gradeName = XCharacterConfigs.GetCharGradeName(equipSpecialCharacterId, char.Grade) + XUiManager.TipMsg(CSXTextManagerGetText("EquipPutOnSpecialCharacterIdNotEqual", characterName, gradeName)) + end + return + end + + local characterEquipType = XCharacterConfigs.GetCharacterEquipType(characterId) + if not XEquipManager.IsTypeEqual(equipId, characterEquipType) then + XUiManager.TipText("EquipPutOnEquipTypeError") + return + end + + local req = { CharacterId = characterId, Site = XEquipManager.GetEquipSite(equipId), EquipId = equipId } + XNetwork.Call("EquipPutOnRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local equipSite = XEquipManager.GetEquipSite(equipId) + local oldEquipId = XEquipManager.GetWearingEquipIdBySite(characterId, equipSite) + if oldEquipId and oldEquipId ~= 0 then + local oldEquip = XEquipManager.GetEquip(oldEquipId) + if XEquipManager.IsWeapon(oldEquipId) then + local switchCharacterId = XEquipManager.GetEquipWearingCharacterId(equipId) + oldEquip:PutOn(switchCharacterId) + else + oldEquip:TakeOff() + end + end + + local equip = XEquipManager.GetEquip(equipId) + equip:PutOn(characterId) + + XEquipManager.TipEquipOperation(nil, CSXTextManagerGetText("EquipPutOnSuc")) + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_EQUIP_PUTON_NOTYFY, equipId) + XEventManager.DispatchEvent(XEventId.EVENT_EQUIP_PUTON_NOTYFY, equipId) + + if XEquipManager.IsClassifyEqual(equipId, XEquipConfig.Classify.Weapon) then + XEventManager.DispatchEvent(XEventId.EVENT_EQUIP_PUTON_WEAPON_NOTYFY, characterId, equipId) + end + end) + end + + function XEquipManager.TakeOff(equipIds) + if not equipIds or not next(equipIds) then + XLog.Error("XEquipManager.TakeOff错误, 参数equipIds不能为为空") + return + end + + for _, equipId in pairs(equipIds) do + if not XEquipManager.IsWearing(equipId) then + XUiManager.TipText("EquipTakeOffNotChar") + return + end + end + + local req = { EquipIds = equipIds } + XNetwork.Call("EquipTakeOffRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + XEquipManager.TipEquipOperation(nil, CSXTextManagerGetText("EquipTakeOffSuc")) + + for _, equipId in pairs(equipIds) do + local equip = XEquipManager.GetEquip(equipId) + equip:TakeOff() + XEventManager.DispatchEvent(XEventId.EVENT_EQUIP_TAKEOFF_NOTYFY, equipId) + end + + XEventManager.DispatchEvent(XEventId.EVENT_EQUIPLIST_TAKEOFF_NOTYFY, equipIds) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_EQUIPLIST_TAKEOFF_NOTYFY, equipIds) + end) + end + + function XEquipManager.SetLock(equipId, isLock) + if not equipId then + XLog.Error("XEquipManager.SetLock错误: 参数equipId不能为空") + return + end + + local req = { EquipId = equipId, IsLock = isLock } + XNetwork.Call("EquipUpdateLockRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local equip = XEquipManager.GetEquip(equipId) + equip:SetLock(isLock) + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_EQUIP_LOCK_STATUS_CHANGE_NOTYFY, equipId, isLock) + XEventManager.DispatchEvent(XEventId.EVENT_EQUIP_LOCK_STATUS_CHANGE_NOTYFY, equipId, isLock) + end) + end + + function XEquipManager.LevelUp(equipId, equipIdCheckList, useItemDic, callBackBeforeEvent) + if not equipId then + XLog.Error("XEquipManager.LevelUp错误: 参数equipId不能为空") + return + end + + if XEquipManager.IsMaxLevel(equipId) then + XUiManager.TipText("EquipLevelUpMaxLevel") + return + end + + local costEmpty = true + local costMoney = 0 + if equipIdCheckList and next(equipIdCheckList) then + costEmpty = nil + costMoney = costMoney + XEquipManager.GetEatEquipsCostMoney(equipIdCheckList) + end + + if useItemDic and next(useItemDic) then + costEmpty = nil + costMoney = costMoney + XEquipManager.GetEatItemsCostMoney(useItemDic) + XMessagePack.MarkAsTable(useItemDic) + end + + if costEmpty then + XUiManager.TipText("EquipLevelUpItemEmpty") + return + end + + if not XDataCenter.ItemManager.DoNotEnoughBuyAsset(XDataCenter.ItemManager.ItemId.Coin, costMoney, 1, function() + XEquipManager.LevelUp(equipId, equipIdCheckList, useItemDic, callBackBeforeEvent) + end, "EquipBreakCoinNotEnough") then + return + end + + local useEquipIdList = {} + local containPrecious = false + local canNotAutoEatStar = XEquipConfig.CAN_NOT_AUTO_EAT_STAR + for tmpEquipId in pairs(equipIdCheckList) do + containPrecious = containPrecious or XEquipManager.GetEquipStar(GetEquipTemplateId(tmpEquipId)) >= canNotAutoEatStar + tableInsert(useEquipIdList, tmpEquipId) + end + + local req = { EquipId = equipId, UseEquipIdList = useEquipIdList, UseItems = useItemDic } + local callFunc = function() + XNetwork.Call("EquipLevelUpRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + for _, id in pairs(useEquipIdList) do + XEquipManager.DeleteEquip(id) + end + + local equip = XEquipManager.GetEquip(equipId) + equip:SetLevel(res.Level) + equip:SetExp(res.Exp) + + local closeCb + if XEquipManager.CanBreakThrough(equipId) then + closeCb = function() + XEquipManager.TipEquipOperation(equipId, nil, nil, true) + end + end + XEquipManager.TipEquipOperation(nil, CSXTextManagerGetText("EquipStrengthenSuc"), closeCb, true) + + if callBackBeforeEvent then callBackBeforeEvent() end + CsXGameEventManager.Instance:Notify(XEventId.EVENT_EQUIP_STRENGTHEN_NOTYFY, equipId) + XEventManager.DispatchEvent(XEventId.EVENT_EQUIP_STRENGTHEN_NOTYFY, equipId) + end) + end + + if containPrecious then + local title = CSXTextManagerGetText("EquipStrengthenPreciousTipTitle") + local content = CSXTextManagerGetText("EquipStrengthenPreciousTipContent") + XUiManager.DialogTip(title, content, XUiManager.DialogType.Normal, nil, callFunc) + else + callFunc() + end + end + + function XEquipManager.Breakthrough(equipId) + if not equipId then + XLog.Error("XEquipManager.Breakthrough错误: 参数equipId不能为空") + return + end + + if XEquipManager.IsMaxBreakthrough(equipId) then + XUiManager.TipText("EquipBreakMax") + return + end + + if not XEquipManager.IsReachBreakthroughLevel(equipId) then + XUiManager.TipText("EquipBreakMinLevel") + return + end + + local consumeItems = XEquipManager.GetBreakthroughConsumeItems(equipId) + if not XDataCenter.ItemManager.CheckItemsCount(consumeItems) then + XUiManager.TipText("EquipBreakItemNotEnough") + return + end + + if not XDataCenter.ItemManager.DoNotEnoughBuyAsset(XEquipManager.GetBreakthroughUseItemId(equipId), + XEquipManager.GetBreakthroughUseMoney(equipId), + 1, + function() + XEquipManager.Breakthrough(equipId) + end, + "EquipBreakCoinNotEnough") then + return + end + + local title = CSXTextManagerGetText("EquipBreakthroughConfirmTiltle") + local content = CSXTextManagerGetText("EquipBreakthroughConfirmContent") + XUiManager.DialogTip(title, content, XUiManager.DialogType.Normal, nil, function() + XNetwork.Call("EquipBreakthroughRequest", { EquipId = equipId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local equip = XEquipManager.GetEquip(equipId) + equip:BreakthroughOneTime() + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_EQUIP_BREAKTHROUGH_NOTYFY, equipId) + XEventManager.DispatchEvent(XEventId.EVENT_EQUIP_BREAKTHROUGH_NOTYFY, equipId) + end) + end) + end + + function XEquipManager.AwarenessTransform(suitId, site, usedIdList, cb) + if not suitId then + XLog.Error("XEquipManager.SetLock错误: 参数suitId不能为空") + return + end + + local req = { SuitId = suitId, Site = site, UseIdList = usedIdList } + XNetwork.Call("EquipTransformChipRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + for _, id in pairs(usedIdList) do + XEquipManager.DeleteEquip(id) + end + + if cb then + cb(res.EquipData) + end + end) + end + + -- 服务端接口begin + function XEquipManager.Resonance(equipId, slot, characterId, useEquipId, useItemId, selectSkillId, equipResonanceType) + if useEquipId and XEquipManager.IsLock(useEquipId) then + XUiManager.TipText("EquipIsLock") + return + end + + if characterId and not XDataCenter.CharacterManager.IsOwnCharacter(characterId) then + XUiManager.TipText("EquipResonanceNotOwnCharacter") + return + end + + local callFunc = function() + local req = { + EquipId = equipId, + Slot = slot, + CharacterId = characterId, + UseEquipId = useEquipId, + UseItemId = useItemId, + SelectSkillId = selectSkillId, + SelectType = equipResonanceType, + } + XNetwork.Call("EquipResonanceRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + if useEquipId then + XEquipManager.DeleteEquip(useEquipId) + end + + local equip = XEquipManager.GetEquip(equipId) + if XDataCenter.EquipManager.IsClassifyEqual(equipId, XEquipConfig.Classify.Weapon) then + equip:Resonance(res.ResonanceData, selectSkillId ~= nil) + else + equip:Resonance(res.ResonanceData) + end + + --5星及以上的装备(包括武器、意识)共鸣操作成功之后,将该装备自动上锁 + if XEquipManager.CanResonance(equipId) then + equip:SetLock(true) + end + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_EQUIP_RESONANCE_NOTYFY, equipId, slot) + XEventManager.DispatchEvent(XEventId.EVENT_EQUIP_RESONANCE_NOTYFY, equipId) + end) + end + + local containPreciousConfirmFunc = function() + local containPrecious = useEquipId and XEquipManager.GetEquipStar(GetEquipTemplateId(useEquipId)) >= XEquipConfig.CAN_NOT_AUTO_EAT_STAR + if containPrecious then + local title = CSXTextManagerGetText("EquipResonancePreciousTipTitle") + local content = CSXTextManagerGetText("EquipResonancePreciousTipContent") + XUiManager.DialogTip(title, content, XUiManager.DialogType.Normal, nil, callFunc) + else + callFunc() + end + end + + containPreciousConfirmFunc() + end + + function XEquipManager.ResonanceConfirm(equipId, slot, isUse) + local req = { EquipId = equipId, Slot = slot, IsUse = isUse } + XNetwork.Call("EquipResonanceConfirmRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local equip = XEquipManager.GetEquip(equipId) + equip:ResonanceConfirm(slot, isUse) + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_EQUIP_RESONANCE_ACK_NOTYFY, equipId, slot) + XEventManager.DispatchEvent(XEventId.EVENT_EQUIP_RESONANCE_ACK_NOTYFY, equipId) + end) + end + + function XEquipManager.Awake(equipId, slot, costType) + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.EquipAwake) then + return + end + + XNetwork.Call("EquipAwakeRequest", + { + EquipId = equipId, + Slot = slot, + CostType = costType, + }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local equip = XEquipManager.GetEquip(equipId) + equip:SetAwake(slot) + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_EQUIP_AWAKE_NOTYFY, equipId, slot) + XEventManager.DispatchEvent(XEventId.EVENT_EQUIP_AWAKE_NOTYFY, equipId) + end) + end + + function XEquipManager.EquipDecompose(equipIds, cb) + local req = { EquipIds = equipIds } + XNetwork.Call("EquipDecomposeRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local rewardGoodsList = res.RewardGoodsList + for _, id in pairs(equipIds) do + XEquipManager.DeleteEquip(id) + end + + if cb then cb(rewardGoodsList) end + end) + end + + --characterId:专属组合角色Id,通用组合为0 + function XEquipManager.EquipSuitPrefabSave(suitPrefabInfo, characterId) + if not suitPrefabInfo then return end + + local name = suitPrefabInfo:GetName() + if not name or name == "" then + XUiManager.TipText("EquipSuitPrefabSaveNotName") + return + end + + local chipIds = suitPrefabInfo:GetEquipIds() + if not next(chipIds) then + XUiManager.TipText("EquipSuitPrefabSaveNotEquipIds") + return + end + + local req = { + Name = name, + ChipIds = chipIds, + CharacterId = characterId, + } + XNetwork.Call("EquipAddChipGroupRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + XEquipManager.SaveSuitPrefabInfo(res.ChipGroupData) + XUiManager.TipText("EquipSuitPrefabSaveSuc") + CsXGameEventManager.Instance:Notify(XEventId.EVENT_EQUIP_SUIT_PREFAB_DATA_UPDATE_NOTIFY) + end) + end + + function XEquipManager.EquipSuitPrefabEquip(prefabIndex, characterId, afterCheckCb) + if not characterId then return end + local suitPrefabInfo = XEquipManager.GetSuitPrefabInfo(prefabIndex) + if not suitPrefabInfo then return end + + local oldEquipSiteToIdDic = {} + local oldEquipIds = XEquipManager.GetCharacterWearingAwarenessIds(characterId) + for _, equipId in pairs(oldEquipIds) do + local equipSite = XEquipManager.GetEquipSite(equipId) + oldEquipSiteToIdDic[equipSite] = equipId + end + + local isDifferent = false + local newEquipSiteToIdDic = {} + local newEquipIds = suitPrefabInfo:GetEquipIds() + local newEquipIdDic = {} + for _, equipId in pairs(newEquipIds) do + local equipSpecialCharacterId = XEquipManager.GetEquipSpecialCharacterId(equipId) + if equipSpecialCharacterId and equipSpecialCharacterId ~= characterId then + local char = XDataCenter.CharacterManager.GetCharacter(equipSpecialCharacterId) + local characterName = XCharacterConfigs.GetCharacterName(equipSpecialCharacterId) + local gradeName = XCharacterConfigs.GetCharGradeName(equipSpecialCharacterId, char.Grade) + XUiManager.TipMsg(CSXTextManagerGetText("EquipPutOnSpecialCharacterIdNotEqual", characterName, gradeName)) + return + end + + local equipSite = XEquipManager.GetEquipSite(equipId) + newEquipSiteToIdDic[equipSite] = equipId + newEquipIdDic[equipId] = true + if oldEquipSiteToIdDic[equipSite] ~= equipId then + isDifferent = true + end + end + + for _, oldequipId in pairs(oldEquipIds) do + if not newEquipIdDic[oldequipId] then + isDifferent = true + end + end + + if not isDifferent then + XUiManager.TipText("EquipSuitPrefabEquipSame") + return + end + + local req = { CharacterId = characterId, GroupId = suitPrefabInfo:GetGroupId() } + XNetwork.Call("EquipPutOnChipGroupRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + for _, equipId in pairs(oldEquipIds) do + local equip = XEquipManager.GetEquip(equipId) + equip:TakeOff() + end + + for _, equipId in pairs(newEquipIds) do + local equip = XEquipManager.GetEquip(equipId) + equip:PutOn(characterId) + end + + local equipIds = {} + for _, equipSite in pairs(XEquipConfig.EquipSite.Awareness) do + local equipId = oldEquipSiteToIdDic[equipSite] or newEquipSiteToIdDic[equipSite] + if equipId then + tableInsert(equipIds, equipId) + end + end + + XUiManager.TipText("EquipSuitPrefabEquipSuc") + if afterCheckCb then afterCheckCb() end + CsXGameEventManager.Instance:Notify(XEventId.EVENT_EQUIPLIST_TAKEOFF_NOTYFY, equipIds) + XEventManager.DispatchEvent(XEventId.EVENT_EQUIPLIST_TAKEOFF_NOTYFY, equipIds) + end) + end + + function XEquipManager.EquipSuitPrefabDelete(prefabIndex) + local suitPrefabInfo = XEquipManager.GetSuitPrefabInfo(prefabIndex) + if not suitPrefabInfo then return end + + local req = { GroupId = suitPrefabInfo:GetGroupId() } + XNetwork.Call("EquipDeleteChipGroupRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + XEquipManager.DeleteSuitPrefabInfo(prefabIndex) + XUiManager.TipText("EquipSuitPrefabDeleteSuc") + CsXGameEventManager.Instance:Notify(XEventId.EVENT_EQUIP_SUIT_PREFAB_DATA_UPDATE_NOTIFY) + end) + end + + function XEquipManager.EquipSuitPrefabRename(prefabIndex, newName) + local suitPrefabInfo = XEquipManager.GetSuitPrefabInfo(prefabIndex) + if not suitPrefabInfo then return end + + local equipGroupData = { + GroupId = suitPrefabInfo:GetGroupId(), + Name = newName, + ChipIdList = suitPrefabInfo:GetEquipIds(), + CharacterId = suitPrefabInfo:GetCharacterId(), + } + local req = { GroupData = equipGroupData } + + XNetwork.Call("EquipUpdateChipGroupRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + suitPrefabInfo:UpdateData(equipGroupData) + XUiManager.TipText("EquipSuitPrefabRenameSuc") + CsXGameEventManager.Instance:Notify(XEventId.EVENT_EQUIP_SUIT_PREFAB_DATA_UPDATE_NOTIFY) + end) + end + -----------------------------------------Protocol End------------------------------------ + -----------------------------------------Checker Begin----------------------------------- + function XEquipManager.CheckMaxCount(equipType, count) + if equipType == XEquipConfig.Classify.Weapon then + local maxWeaponCount = XEquipConfig.GetMaxWeaponCount() + if count and count > 0 then + return XEquipManager.GetWeaponCount() + count > maxWeaponCount + else + return XEquipManager.GetWeaponCount() >= maxWeaponCount + end + elseif equipType == XEquipConfig.Classify.Awareness then + local maxAwarenessCount = XEquipConfig.GetMaxAwarenessCount() + if count and count > 0 then + return XEquipManager.GetAwarenessCount() + count > maxAwarenessCount + else + return XEquipManager.GetAwarenessCount() >= maxAwarenessCount + end + end + end + + function XEquipManager.CheckBagCount(count, equipType) + if XEquipManager.CheckMaxCount(equipType, count) then + local messageTips + if equipType == XEquipConfig.Classify.Weapon then + messageTips = CSXTextManagerGetText("WeaponBagFull") + elseif equipType == XEquipConfig.Classify.Awareness then + messageTips = CSXTextManagerGetText("ChipBagFull") + end + + XUiManager.TipMsg(messageTips, XUiManager.UiTipType.Tip) + return false + end + + return true + end + + function XEquipManager.IsWeapon(equipId) + return XEquipManager.IsClassifyEqual(equipId, XEquipConfig.Classify.Weapon) + end + + function XEquipManager.IsWeaponByTemplateId(templateId) + return XEquipManager.IsClassifyEqualByTemplateId(templateId, XEquipConfig.Classify.Weapon) + end + + function XEquipManager.IsAwareness(equipId) + return XEquipManager.IsClassifyEqual(equipId, XEquipConfig.Classify.Awareness) + end + + function XEquipManager.IsAwarenessByTemplateId(templateId) + return XEquipManager.IsClassifyEqualByTemplateId(templateId, XEquipConfig.Classify.Awareness) + end + + function XEquipManager.IsFood(equipId) + local equipCfg = GetEquipCfg(equipId) + return equipCfg.Type == XEquipConfig.EquipType.Food + end + + function XEquipManager.IsClassifyEqual(equipId, classify) + local templateId = GetEquipTemplateId(equipId) + return XEquipManager.IsClassifyEqualByTemplateId(templateId, classify) + end + + function XEquipManager.IsCharacterTypeFit(equipId, characterType) + local templateId = GetEquipTemplateId(equipId) + return XEquipManager.IsCharacterTypeFitByTemplateId(templateId, characterType) + end + + function XEquipManager.IsCharacterTypeFitByTemplateId(templateId, characterType) + local configCharacterType = XEquipConfig.GetEquipCharacterType(templateId) + return configCharacterType == XEquipConfig.UserType.All or configCharacterType == characterType + end + + function XEquipManager.IsClassifyEqualByTemplateId(templateId, classify) + local equipClassify = XEquipManager.GetEquipClassifyByTemplateId(templateId) + return classify and equipClassify and classify == equipClassify + end + + function XEquipManager.IsTypeEqual(equipId, equipType) + local equipCfg = GetEquipCfg(equipId) + return equipCfg.Type == XEquipConfig.EquipType.Universal or equipType and equipType == equipCfg.Type + end + + function XEquipManager.IsWearing(equipId) + if not equipId then return false end + local equip = XEquipManager.GetEquip(equipId) + return equip and equip.CharacterId and equip.CharacterId > 0 + end + + function XEquipManager.IsInSuitPrefab(equipId) + if not equipId then return false end + local suitPrefabList = GetSuitPrefabInfoList() + for _, suitPrefabInfo in pairs(suitPrefabList) do + if suitPrefabInfo:IsEquipIn(equipId) then + return true + end + end + return false + end + + function XEquipManager.IsLock(equipId) + if not equipId then return false end + local equip = XEquipManager.GetEquip(equipId) + return equip and equip.IsLock + end + + function XEquipManager.IsMaxLevel(equipId) + local equip = XEquipManager.GetEquip(equipId) + return equip.Level >= XEquipManager.GetBreakthroughLevelLimit(equipId) + end + + function XEquipManager.IsMaxLevelByTemplateId(templateId, breakThrough, level) + return level >= XEquipManager.GetBreakthroughLevelLimitByTemplateId(templateId, breakThrough) + end + + function XEquipManager.IsMaxBreakthrough(equipId) + local equip = XEquipManager.GetEquip(equipId) + local equipBorderCfg = GetEquipBorderCfg(equipId) + return equip.Breakthrough >= equipBorderCfg.MaxBreakthrough + end + + function XEquipManager.IsReachBreakthroughLevel(equipId) + local equip = XEquipManager.GetEquip(equipId) + return equip.Level >= XEquipManager.GetBreakthroughLevelLimit(equipId) + end + + function XEquipManager.IsCanBeGift(equipId)--是否能作为师徒系统的礼物 + local IsNotWearing = not XEquipManager.IsWearing(equipId) + local IsNotInSuit = not XEquipManager.IsInSuitPrefab(equipId) + local IsUnLock = not XEquipManager.IsLock(equipId) + local templateId = GetEquipTemplateId(equipId) + local IsCanGive = not XMentorSystemConfigs.IsCanNotGiveWafer(templateId) + local equip = XEquipManager.GetEquip(equipId) + local resonanCecount = XEquipManager.GetResonanceCount(equipId) + local breakthrough = equip and equip.Breakthrough or 0 + local level = equip and equip.Level or 1 + + return IsNotWearing and IsNotInSuit and IsUnLock and IsCanGive and resonanCecount == 0 and level == 1 and breakthrough == 0 + end + + function XEquipManager.CanBreakThrough(equipId) + return not XEquipManager.IsMaxBreakthrough(equipId) and XEquipManager.IsReachBreakthroughLevel(equipId) + end + + function XEquipManager.CanBreakThroughByEquipData(equip) + local equipBorderCfg = XEquipConfig.GetEquipBorderCfg(equip.TemplateId) + local isMaxBreakthrough = equip.Breakthrough >= equipBorderCfg.MaxBreakthrough + local isReachBreakthroughLevel = equip.Level >= XEquipManager.GetBreakthroughLevelLimitByEquipData(equip) + return not isMaxBreakthrough and isReachBreakthroughLevel + end + + function XEquipManager.CanBreakThroughByTemplateId(templateId, breakThrough, level) + local equipBorderCfg = XEquipConfig.GetEquipBorderCfg(templateId) + local isMaxBreakthrough = breakThrough >= equipBorderCfg.MaxBreakthrough + local isReachBreakthroughLevel = level >= XEquipManager.GetBreakthroughLevelLimitByTemplateId(templateId, breakThrough) + return not isMaxBreakthrough and isReachBreakthroughLevel + end + + function XEquipManager.IsFiveStar(equipId) + local templateId = XDataCenter.EquipManager.GetEquipTemplateId(equipId) + local quality = XDataCenter.EquipManager.GetEquipQuality(templateId) + return quality == XEquipConfig.MIN_RESONANCE_EQUIP_STAR_COUNT + end + + function XEquipManager.CanResonance(equipId) + local templateId = GetEquipTemplateId(equipId) + local star = XEquipManager.GetEquipStar(templateId) + return star >= XEquipConfig.MIN_RESONANCE_EQUIP_STAR_COUNT + end + + function XEquipManager.CanResonanceByTemplateId(templateId) + local resonanceSkillNum = XEquipManager.GetResonanceSkillNumByTemplateId(templateId) + return resonanceSkillNum > 0 + end + + function XEquipManager.CanResonanceBindCharacter(equipId) + local templateId = GetEquipTemplateId(equipId) + local star = XEquipManager.GetEquipStar(templateId) + return star >= XEquipConfig.GetMinResonanceBindStar() + end + + function XEquipManager.CheckResonanceConsumeItemEnough(equipId) + local itemIds = {} + local consumeItemId = XEquipManager.GetResonanceConsumeItemId(equipId) + local haveCount = XDataCenter.ItemManager.GetCount(consumeItemId) + local consumeCount = XEquipManager.GetResonanceConsumeItemCount(equipId) + + local consumeSelectSkillItemId = XEquipManager.GetResonanceConsumeSelectSkillItemId(equipId) + local haveSelectCount = XDataCenter.ItemManager.GetCount(consumeSelectSkillItemId) + local consumeSelectSkillItemCount = XEquipManager.GetResonanceConsumeSelectSkillItemCount(equipId) + + local isEnough = false + if consumeItemId and haveCount >= consumeCount then + table.insert(itemIds, consumeItemId) + isEnough = true + end + + if consumeSelectSkillItemId and haveSelectCount >= consumeSelectSkillItemCount then + table.insert(itemIds, consumeSelectSkillItemId) + isEnough = true + end + + return isEnough, itemIds + end + + function XEquipManager.CheckEquipPosResonanced(equipId, pos) + local equip = XEquipManager.GetEquip(equipId) + return equip.ResonanceInfo and equip.ResonanceInfo[pos] + end + + --装备是否共鸣过 + function XEquipManager.IsEquipResonanced(equipId) + local equip = XEquipManager.GetEquip(equipId) + return equip and not XTool.IsTableEmpty(equip.ResonanceInfo) or not XTool.IsTableEmpty(equip.UnconfirmedResonanceInfo) + end + + function XEquipManager.CheckEquipStarCanAwake(equipId) + local templateId = GetEquipTemplateId(equipId) + local star = XEquipManager.GetEquipStar(templateId) + if star < XEquipConfig.GetMinAwakeStar() then + return false + end + return true + end + + function XEquipManager.CheckEquipCanAwake(equipId) + if not XEquipManager.CheckEquipStarCanAwake(equipId) then + return false + end + + local templateId = GetEquipTemplateId(equipId) + local maxLevel = XEquipManager.GetEquipMaxLevel(templateId) + local equip = XEquipManager.GetEquip(equipId) + if equip.Level ~= maxLevel then + return false + end + + return true + end + + function XEquipManager.IsEquipAwaken(equipId) + for pos = 1, XEquipConfig.MAX_RESONANCE_SKILL_COUNT do + if XEquipManager.IsEquipPosAwaken(equipId, pos) then + return true + end + end + return false + end + + function XEquipManager.IsEquipPosAwaken(equipId, pos) + local equip = XEquipManager.GetEquip(equipId) + return equip:IsEquipPosAwaken(pos) + end + + function XEquipManager.CheckEquipPosUnconfirmedResonanced(equipId, pos) + local equip = XEquipManager.GetEquip(equipId) + return equip.UnconfirmedResonanceInfo and equip.UnconfirmedResonanceInfo[pos] + end + + function XEquipManager.CheckFirstGet(templateId) + local needFirstShow = XEquipConfig.GetNeedFirstShow(templateId) + if not needFirstShow or needFirstShow == 0 then return false end + + local firstGetTemplateIds = XSaveTool.GetData(XPlayer.Id .. EQUIP_FIRST_GET_KEY) or {} + if firstGetTemplateIds[templateId] then + return false + else + firstGetTemplateIds[templateId] = true + XSaveTool.SaveData(XPlayer.Id .. EQUIP_FIRST_GET_KEY, firstGetTemplateIds) + return true + end + end + + --狗粮 + function XEquipManager.IsEquipRecomendedToBeEat(strengthenEquipId, equipId) + if not equipId then return false end + local equip = XEquipManager.GetEquip(equipId) + local canNotAutoEatStar = XEquipConfig.CAN_NOT_AUTO_EAT_STAR + local equipClassify = XEquipManager.GetEquipClassify(strengthenEquipId) + + if XEquipManager.GetEquipClassify(equipId) == equipClassify --武器吃武器,意识吃意识 + and not XEquipManager.IsWearing(equipId) --不能吃穿戴中 + and not XEquipManager.IsInSuitPrefab(equipId) --不能吃预设中 + and not XEquipManager.IsLock(equipId) --不能吃上锁中 + and XEquipManager.GetEquipStar(equip.TemplateId) < canNotAutoEatStar --不自动吃大于该星级的装备 + and equip.Breakthrough == 0 --不吃突破过的 + and equip.Level == 1 and equip.Exp == 0 --不吃强化过的 + and not equip.ResonanceInfo and not equip.UnconfirmedResonanceInfo --不吃共鸣过的 + then + return true + end + + return false + end + + --强化默认使用装备条件,不满足则使用道具 + function XEquipManager.IsStrengthenDefaultUseEquip(StrenthenEquipId) + local equipIdList = XDataCenter.EquipManager.GetCanEatEquipIds(StrenthenEquipId) + for _, equipId in pairs(equipIdList) do + if XEquipManager.IsEquipRecomendedToBeEat(StrenthenEquipId, equipId) then + return true + end + end + + local itemIdList = XDataCenter.EquipManager.GetCanEatItemIds(StrenthenEquipId) + if next(itemIdList) then + return false + end + + return true + end + -----------------------------------------Checker End------------------------------------ + -----------------------------------------Getter Begin------------------------------------ + local function ConstructEquipAttrMap(attrs, isIncludeZero, remainDigitTwo) + local equipAttrMap = {} + + for _, attrIndex in ipairs(XEquipConfig.AttrSortType) do + local value = attrs and attrs[attrIndex] + + --默认保留两位小数 + if not remainDigitTwo then + value = value and FixToInt(value) + else + value = value and tonumber(string.format("%0.2f", FixToDouble(value))) + end + + if isIncludeZero or value and value > 0 then + tableInsert(equipAttrMap, { + AttrIndex = attrIndex, + Name = XAttribManager.GetAttribNameByIndex(attrIndex), + Value = value or 0, + }) + end + end + + return equipAttrMap + end + + function XEquipManager.GetEquipAttrMap(equipId, preLevel) + local attrMap = {} + + if not equipId then + return attrMap + end + local equip = XEquipManager.GetEquip(equipId) + local attrs = XFightEquipManager.GetEquipAttribs(equip, preLevel) + attrMap = ConstructEquipAttrMap(attrs) + + return attrMap + end + + function XEquipManager.GetEquipAttrMapByEquipData(equip) + local attrMap = {} + if not equip then + return attrMap + end + local attrs = XFightEquipManager.GetEquipAttribs(equip) + attrMap = ConstructEquipAttrMap(attrs) + + return attrMap + end + + function XEquipManager.GetTemplateEquipAttrMap(templateId, preLevel) + local equipData = { + TemplateId = templateId, + Breakthrough = 0, + Level = 1, + } + local attrs = XFightEquipManager.GetEquipAttribs(equipData, preLevel) + return ConstructEquipAttrMap(attrs) + end + + function XEquipManager.ConstructTemplateEquipAttrMap(templateId, breakthroughTimes, level) + local equipData = { + TemplateId = templateId, + Breakthrough = breakthroughTimes, + Level = level, + } + local attrs = XFightEquipManager.GetEquipAttribs(equipData) + return ConstructEquipAttrMap(attrs) + end + + function XEquipManager.GetWearingAwarenessMergeAttrMap(characterId) + local wearingAwarenessIds = XEquipManager.GetCharacterWearingAwarenessIds(characterId) + return XEquipManager.GetAwarenessMergeAttrMap(wearingAwarenessIds) + end + + function XEquipManager.GetAwarenessMergeAttrMap(equipIds) + local equipList = {} + for _, equipId in pairs(equipIds) do + tableInsert(equipList, XEquipManager.GetEquip(equipId)) + end + local attrs = XFightEquipManager.GetEquipListAttribs(equipList) + return ConstructEquipAttrMap(attrs, true) + end + + function XEquipManager.GetBreakthroughPromotedAttrMap(equipId, preBreakthrough) + local equipBreakthroughCfg + + if preBreakthrough then + equipBreakthroughCfg = GetEquipBreakthroughCfgNext(equipId) + else + equipBreakthroughCfg = GetEquipBreakthroughCfg(equipId) + end + + local map = XAttribManager.GetPromotedAttribs(equipBreakthroughCfg.AttribPromotedId) + return ConstructEquipAttrMap(map, false, true) + end + + function XEquipManager.GetCharacterWearingEquips(characterId) + local equips = {} + + for _, equip in pairs(Equips) do + if characterId > 0 and equip.CharacterId == characterId then + tableInsert(equips, equip) + end + end + + return equips + end + + function XEquipManager.GetCharacterWearingWeaponId(characterId) + for _, equip in pairs(Equips) do + if equip.CharacterId == characterId and + XEquipManager.IsWearing(equip.Id) and + XEquipManager.IsClassifyEqual(equip.Id, XEquipConfig.Classify.Weapon) then + return equip.Id + end + end + end + + function XEquipManager.GetWearingEquipIdBySite(characterId, site) + for _, equip in pairs(Equips) do + if equip.CharacterId == characterId and XEquipManager.GetEquipSite(equip.Id) == site then + return equip.Id + end + end + end + + function XEquipManager.GetCharacterWearingAwarenessIds(characterId) + local awarenessIds = {} + local equips = XEquipManager.GetCharacterWearingEquips(characterId) + for _, equip in pairs(equips) do + if XEquipManager.IsClassifyEqual(equip.Id, XEquipConfig.Classify.Awareness) then + tableInsert(awarenessIds, equip.Id) + end + end + return awarenessIds + end + + --desc: 获取符合当前角色使用类型的所有武器equipId + function XEquipManager.GetCanUseWeaponIds(characterId) + local weaponIds = {} + local requireEquipType = XCharacterConfigs.GetCharacterEquipType(characterId) + for k, v in pairs(Equips) do + if XEquipManager.IsClassifyEqual(v.Id, XEquipConfig.Classify.Weapon) and XEquipManager.IsTypeEqual(v.Id, requireEquipType) then + tableInsert(weaponIds, k) + end + end + return weaponIds + end + + --desc: 获取符合当前角色使用类型的所有武器templateId + function XEquipManager.GetCanUseWeaponTemplateIds(characterId) + local weaponTemplateIds = {} + local requireEquipType = XCharacterConfigs.GetCharacterEquipType(characterId) + local equipTemplates = XEquipConfig.GetEquipTemplates() + for _, v in pairs(equipTemplates) do + if XEquipManager.IsClassifyEqualByTemplateId(v.Id, XEquipConfig.Classify.Weapon) and v.Type == requireEquipType then + tableInsert(weaponTemplateIds, v.Id) + end + end + return weaponTemplateIds + end + + --desc: 获取符合当前武器使用角色的所有templateId + function XEquipManager.GetWeaponUserTemplateIds(weaponTemplateIds) + local characters = XCharacterConfigs.GetCharacterTemplates() + local canUesCharacters = {} + for _, character in pairs(characters) do + local weaponIds = XEquipManager.GetCanUseWeaponTemplateIds(character.Id) + for _, weaponId in pairs(weaponIds) do + if weaponTemplateIds == weaponId then + tableInsert(canUesCharacters, character) + end + end + end + return canUesCharacters + end + + --desc: 获取所有意识 + function XEquipManager.GetAwarenessIds(characterType) + local awarenessIds = {} + for k, v in pairs(Equips) do + local equipId = v.Id + if XEquipManager.IsClassifyEqual(equipId, XEquipConfig.Classify.Awareness) + and (not characterType or XEquipManager.IsCharacterTypeFit(equipId, characterType)) then + tableInsert(awarenessIds, k) + end + end + return awarenessIds + end + + local CanEatEquipSort = function(lEquipId, rEquipId) + local ltemplateId = GetEquipTemplateId(lEquipId) + local rtemplateId = GetEquipTemplateId(rEquipId) + local lEquip = XEquipManager.GetEquip(lEquipId) + local rEquip = XEquipManager.GetEquip(rEquipId) + + local lStar = XEquipManager.GetEquipStar(ltemplateId) + local rStar = XEquipManager.GetEquipStar(rtemplateId) + if lStar ~= rStar then + return lStar < rStar + end + + local lIsFood = XEquipManager.IsFood(lEquipId) + local rIsFood = XEquipManager.IsFood(rEquipId) + if lIsFood ~= rIsFood then + return lIsFood + end + + if lEquip.Breakthrough ~= rEquip.Breakthrough then + return lEquip.Breakthrough < rEquip.Breakthrough + end + + if lEquip.Level ~= rEquip.Level then + return lEquip.Level < rEquip.Level + end + + return XEquipManager.GetEquipPriority(ltemplateId) < XEquipManager.GetEquipPriority(rtemplateId) + end + + local function GetCanEatWeaponIds(equipId) + local weaponIds = {} + for k, v in pairs(Equips) do + if v.Id ~= equipId and XEquipManager.IsClassifyEqual(v.Id, XEquipConfig.Classify.Weapon) + and not XEquipManager.IsWearing(v.Id) and not XEquipManager.IsLock(v.Id) then + tableInsert(weaponIds, k) + end + end + tableSort(weaponIds, CanEatEquipSort) + return weaponIds + end + + local function GetCanEatAwarenessIds(equipId) + local awarenessIds = {} + for k, v in pairs(Equips) do + if v.Id ~= equipId and XEquipManager.IsClassifyEqual(v.Id, XEquipConfig.Classify.Awareness) + and not XEquipManager.IsWearing(v.Id) and not XEquipManager.IsInSuitPrefab(v.Id) and not XEquipManager.IsLock(v.Id) then + tableInsert(awarenessIds, k) + end + end + tableSort(awarenessIds, CanEatEquipSort) + return awarenessIds + end + + function XEquipManager.GetCanEatEquipIds(equipId) + local equipIds = {} + if XEquipManager.IsAwareness(equipId) then + equipIds = GetCanEatAwarenessIds(equipId) + elseif XEquipManager.IsWeapon(equipId) then + equipIds = GetCanEatWeaponIds(equipId) + end + return equipIds + end + + function XEquipManager.GetCanEatItemIds(equipId) + local itemIds = {} + + local equipClassify = XEquipManager.GetEquipClassify(equipId) + local items = XDataCenter.ItemManager.GetEquipExpItems(equipClassify) + for _, item in pairs(items) do + tableInsert(itemIds, item.Id) + end + + return itemIds + end + + function XEquipManager.GetRecomendEatEquipIds(equipId) + local equipIds = {} + + for _, v in pairs(Equips) do + local tmpEquipId = v.Id + if tmpEquipId ~= equipId --不能吃自己 + and XEquipManager.IsEquipRecomendedToBeEat(equipId, tmpEquipId) + then + tableInsert(equipIds, tmpEquipId) + end + end + tableSort(equipIds, CanEatEquipSort) + + return equipIds + end + + function XEquipManager.GetCanDecomposeWeaponIds() + local weaponIds = {} + for k, v in pairs(Equips) do + if XEquipManager.IsClassifyEqual(v.Id, XEquipConfig.Classify.Weapon) + and not XEquipManager.IsWearing(v.Id) and not XEquipManager.IsLock(v.Id) then + tableInsert(weaponIds, k) + end + end + return weaponIds + end + + function XEquipManager.GetCanDecomposeAwarenessIdsBySuitId(suitId) + local awarenessIds = {} + + local equipIds = XEquipManager.GetEquipIdsBySuitId(suitId) + for _, v in pairs(equipIds) do + if XEquipManager.IsClassifyEqual(v, XEquipConfig.Classify.Awareness) + and not XEquipManager.IsWearing(v) and not XEquipManager.IsInSuitPrefab(v) and not XEquipManager.IsLock(v) then + tableInsert(awarenessIds, v) + end + end + + return awarenessIds + end + + function XEquipManager.GetEquipSite(equipId) + local equipCfg = GetEquipCfg(equipId) + return equipCfg.Site + end + + function XEquipManager.GetEquipSiteByEquipData(equip) + local equipCfg = XEquipConfig.GetEquipCfg(equip.TemplateId) + return equipCfg.Site + end + + function XEquipManager.GetEquipType(equipId) + local equipCfg = GetEquipCfg(equipId) + return equipCfg.Type + end + + function XEquipManager.GetEquipSiteByTemplateId(templateId) + local equipCfg = XEquipConfig.GetEquipCfg(templateId) + return equipCfg.Site + end + + function XEquipManager.GetEquipTypeByTemplateId(templateId) + local equipCfg = XEquipConfig.GetEquipCfg(templateId) + return equipCfg.Type + end + + function XEquipManager.GetEquipWearingCharacterId(equipId) + local equip = XEquipManager.GetEquip(equipId) + return equip.CharacterId > 0 and equip.CharacterId or nil + end + + --专属角色Id + function XEquipManager.GetEquipSpecialCharacterId(equipId) + local equipCfg = GetEquipCfg(equipId) + if equipCfg.CharacterId > 0 then + return equipCfg.CharacterId + end + end + + function XEquipManager.GetEquipSpecialCharacterIdByTemplateId(templateId) + local equipCfg = XEquipConfig.GetEquipCfg(templateId) + if equipCfg.CharacterId > 0 then + return equipCfg.CharacterId + end + end + + function XEquipManager.GetEquipClassify(equipId) + local site = XEquipManager.GetEquipSite(equipId) + if site == XEquipConfig.EquipSite.Weapon then + return XEquipConfig.Classify.Weapon + end + + return XEquipConfig.Classify.Awareness + end + + function XEquipManager.GetEquipClassifyByTemplateId(templateId) + if not XEquipConfig.CheckTemplateIdIsEquip(templateId) then return end + local equipSite = XEquipManager.GetEquipSiteByTemplateId(templateId) + return WeaponTypeCheckDic[equipSite] or AwarenessTypeCheckDic[equipSite] + end + + function XEquipManager.GetSuitId(equipId) + local equipCfg = GetEquipCfg(equipId) + return equipCfg.SuitId + end + + function XEquipManager.GetSuitIdByTemplateId(templateId) + local equipCfg = XEquipConfig.GetEquipCfg(templateId) + return equipCfg.SuitId + end + + function XEquipManager.GetEquipTemplateIdsBySuitId(suitId) + local equipTemplateIds = XEquipConfig.GetEquipTemplateIdsBySuitId(suitId) + return equipTemplateIds + end + + function XEquipManager.GetWeaponTypeIconPath(equipId) + local templateId = GetEquipTemplateId(equipId) + if XEquipManager.IsClassifyEqualByTemplateId(templateId, XEquipConfig.Classify.Weapon) then + return XEquipConfig.GetWeaponTypeIconPath(templateId) + end + end + + function XEquipManager.GetEquipBreakThroughIcon(equipId) + local equip = XEquipManager.GetEquip(equipId) + return XEquipConfig.GetEquipBreakThroughIcon(equip.Breakthrough) + end + + function XEquipManager.GetEquipBreakThroughIconByBreakThrough(breakthrough) + return XEquipConfig.GetEquipBreakThroughIcon(breakthrough) + end + + function XEquipManager.GetEquipBreakThroughSmallIcon(equipId) + local equip = XEquipManager.GetEquip(equipId) + if equip.Breakthrough == 0 then return end + return XEquipConfig.GetEquipBreakThroughSmallIcon(equip.Breakthrough) + end + + function XEquipManager.GetEquipBreakThroughBigIcon(equipId, preBreakthrough) + local equip = XEquipManager.GetEquip(equipId) + local breakthrough = equip.Breakthrough + if preBreakthrough then + breakthrough = breakthrough + preBreakthrough + end + return XEquipConfig.GetEquipBreakThroughBigIcon(breakthrough) + end + + function XEquipManager.GetEquipIdsBySuitId(suitId, site) + if suitId == XEquipConfig.DEFAULT_SUIT_ID.Normal then + return XEquipManager.GetAwarenessIds(XCharacterConfigs.CharacterType.Normal) + elseif suitId == XEquipConfig.DEFAULT_SUIT_ID.Isomer then + return XEquipManager.GetAwarenessIds(XCharacterConfigs.CharacterType.Isomer) + end + + local equipIds = {} + + for _, equip in pairs(Equips) do + local equipId = equip.Id + if suitId == XEquipManager.GetSuitId(equipId) then + if type(site) ~= "number" or XEquipManager.GetEquipSite(equipId) == site then + tableInsert(equipIds, equipId) + end + end + end + + return equipIds + end + + function XEquipManager.GetSuitName(suitId) + if XEquipConfig.IsDefaultSuitId(suitId) then return "" end + local suitCfg = XEquipConfig.GetEquipSuitCfg(suitId) + return suitCfg.Name + end + + function XEquipManager.GetSuitDescription(suitId) + if XEquipConfig.IsDefaultSuitId(suitId) then return "" end + local suitCfg = XEquipConfig.GetEquipSuitCfg(suitId) + return suitCfg.Description + end + + function XEquipManager.GetSuitSites(templateId) + local suitId = XEquipManager.GetSuitIdByTemplateId(templateId) + return XEquipConfig.GetSuitSites(suitId) + end + + function XEquipManager.GetSuitCharacterType(suitId) + if suitId == XEquipConfig.DEFAULT_SUIT_ID.Normal then + return XEquipConfig.UserType.Normal + elseif suitId == XEquipConfig.DEFAULT_SUIT_ID.Isomer then + return XEquipConfig.UserType.Isomer + end + + local templateId = GetSuitPresentEquipTemplateId(suitId) + return XEquipConfig.GetEquipCharacterType(templateId) + end + + function XEquipManager.GetSuitStar(suitId) + if XEquipConfig.IsDefaultSuitId(suitId) then return 0 end + local templateId = GetSuitPresentEquipTemplateId(suitId) + return XEquipManager.GetEquipStar(templateId) + end + + function XEquipManager.GetSuitQualityIcon(suitId) + if XEquipConfig.IsDefaultSuitId(suitId) then return end + local templateId = GetSuitPresentEquipTemplateId(suitId) + return XEquipManager.GetEquipBgPath(templateId) + end + + function XEquipManager.GetCharacterWearingSuitMergeActiveSkillDesInfoList(characterId) + local wearingAwarenessIds = XEquipManager.GetCharacterWearingAwarenessIds(characterId) + return XEquipManager.GetSuitMergeActiveSkillDesInfoList(wearingAwarenessIds) + end + + function XEquipManager.GetSuitMergeActiveSkillDesInfoList(wearingAwarenessIds) + local skillDesInfoList = {} + + local suitIdSet = {} + for _, equipId in pairs(wearingAwarenessIds) do + local suitId = XEquipManager.GetSuitId(equipId) + if suitId > 0 then + local count = suitIdSet[suitId] + suitIdSet[suitId] = count and count + 1 or 1 + end + end + + for suitId, count in pairs(suitIdSet) do + local activeskillDesList = XEquipManager.GetSuitActiveSkillDesList(suitId, count) + for _, info in pairs(activeskillDesList) do + if info.IsActive then + tableInsert(skillDesInfoList, info) + end + end + end + + return skillDesInfoList + end + + function XEquipManager.GetActiveSuitEquipsCount(characterId, suitId) + local count = 0 + local siteCheckDic = {} + + local wearingAwarenessIds = XEquipManager.GetCharacterWearingAwarenessIds(characterId) + for _, equipId in pairs(wearingAwarenessIds) do + local wearingSuitId = XEquipManager.GetSuitId(equipId) + if suitId > 0 and suitId == wearingSuitId then + count = count + 1 + local site = XEquipManager.GetEquipSite(equipId) + siteCheckDic[site] = true + end + end + + return count, siteCheckDic + end + + function XEquipManager.GetSuitActiveSkillDesList(suitId, count) + local activeskillDesList = {} + + local skillDesList = XEquipManager.GetSuitSkillDesList(suitId) + if skillDesList[2] then + tableInsert(activeskillDesList, { + SkillDes = skillDesList[2] or "", + PosDes = CSXTextManagerGetText("EquipSuitSkillPrefix2"), + IsActive = count and count >= 2 + }) + end + if skillDesList[4] then + tableInsert(activeskillDesList, { + SkillDes = skillDesList[4] or "", + PosDes = CSXTextManagerGetText("EquipSuitSkillPrefix4"), + IsActive = count and count >= 4 + }) + end + if skillDesList[6] then + tableInsert(activeskillDesList, { + SkillDes = skillDesList[6] or "", + PosDes = CSXTextManagerGetText("EquipSuitSkillPrefix6"), + IsActive = count and count >= 6 + }) + end + + return activeskillDesList + end + + function XEquipManager.GetSuitSkillDesList(suitId) + if not suitId or suitId == 0 or XEquipConfig.IsDefaultSuitId(suitId) then + return {} + end + local suitCfg = XEquipConfig.GetEquipSuitCfg(suitId) + return suitCfg and suitCfg.SkillDescription or {} + end + + function XEquipManager.GetEquipCountInSuit(suitId, site) + return #XEquipManager.GetEquipIdsBySuitId(suitId, site) + end + + function XEquipManager.GetMaxSuitCount() + return XEquipConfig.GetMaxSuitCount() + end + + function XEquipManager.GetWeaponModelCfgByEquipId(equipId, uiName) + local templateId = GetEquipTemplateId(equipId) + local breakthroughTimes = XEquipManager.GetBreakthroughTimes(equipId) + local resonanceCount = XEquipManager.GetResonanceCount(equipId) + return XEquipManager.GetWeaponModelCfg(templateId, uiName, breakthroughTimes, resonanceCount) + end + + function XEquipManager.GetBreakthroughTimes(equipId) + local breakthroughTimes = 0 + + if CheckEquipExist(equipId) then + local equip = XEquipManager.GetEquip(equipId) + breakthroughTimes = equip.Breakthrough + end + + return breakthroughTimes + end + + function XEquipManager.GetResonanceCount(equipId) + local resonanceCount = 0 + if CheckEquipExist(equipId) then + local equip = XEquipManager.GetEquip(equipId) + resonanceCount = equip.ResonanceInfo and (equip.ResonanceInfo.Count or XTool.GetTableCount(equip.ResonanceInfo)) or 0 + end + return resonanceCount + end + + --desc: 获取装备模型配置列表 + function XEquipManager.GetWeaponModelCfg(templateId, uiName, breakthroughTimes, resonanceCount) + local modelCfg = {} + + if not templateId then + XLog.Error("XEquipManager.GetWeaponModelCfg错误: 参数templateId不能为空") + return modelCfg + end + + local template = XEquipConfig.GetEquipResCfg(templateId, breakthroughTimes) + local modelId = XEquipConfig.GetWeaponResonanceModelId(XEquipConfig.WeaponCase.Case1, template.Id, resonanceCount) + modelCfg.ModelId = modelId + modelCfg.TransformConfig = XEquipConfig.GetEquipModelTransformCfg(templateId, uiName, resonanceCount) + return modelCfg + end + + -- 获取装备模型id列表 + function XEquipManager.GetEquipModelIdListByEquipData(equip, weaponFashionId) + local idList = {} + local template = XEquipConfig.GetEquipResCfg(equip.TemplateId, equip.Breakthrough) + local resonanceCount = equip and equip.ResonanceInfo and (equip.ResonanceInfo.Count or XTool.GetTableCount(equip.ResonanceInfo)) or 0 + local isWeaponFashion = weaponFashionId and not XWeaponFashionConfigs.IsDefaultId(weaponFashionId) + + for case, modelTransId in pairs(template.ModelTransId) do + if XTool.IsNumberValid(modelTransId) then + local modelId = isWeaponFashion and XWeaponFashionConfigs.GetWeaponResonanceModelId(case, weaponFashionId, resonanceCount) + or XEquipConfig.GetWeaponResonanceModelId(case, equip.TemplateId, resonanceCount) + idList[case] = modelId + end + end + return idList + end + + --desc: 获取武器模型名字列表(战斗用) + function XEquipManager.GetWeaponModelNameList(templateId) + local nameList = {} + + local usage = XEquipConfig.WeaponUsage.Battle + local template = XEquipConfig.GetEquipResCfg(templateId) + for _, modelId in pairs(template.ModelTransId) do + local modelName = XEquipConfig.GetEquipModelName(modelId, usage) + tableInsert(nameList, modelName) + end + return nameList + end + + --desc: 获取武器模型名字列表(战斗用) + function XEquipManager.GetWeaponModelNameListByFight(fightNpcData) + local nameList = {} + + local characterId = fightNpcData.Character.Id + local weaponFashionId = fightNpcData.WeaponFashionId or XDataCenter.WeaponFashionManager.GetCharacterWearingWeaponFashionId(characterId) + local usage = XEquipConfig.WeaponUsage.Battle + for _, equip in pairs(fightNpcData.Equips) do + if XEquipManager.IsWeaponByTemplateId(equip.TemplateId) then + local idList = XEquipManager.GetEquipModelIdListByEquipData(equip, weaponFashionId) + for _, modelId in ipairs(idList) do + tableInsert(nameList, XEquipConfig.GetEquipModelName(modelId, usage)) + end + break + end + end + + return nameList or {} + end + + --desc: 获取武器动画controller(战斗用) + function XEquipManager.GetWeaponControllerList(templateId) + local controllerList = {} + local usage = XEquipConfig.WeaponUsage.Battle + local template = XEquipConfig.GetEquipResCfg(templateId) + for _, modelId in pairs(template.ModelTransId) do + local controller = XEquipConfig.GetEquipAnimController(modelId, usage) + tableInsert(controllerList, controller or "") + end + return controllerList + end + + --desc: 获取武器模动画controller(战斗用) + function XEquipManager.GetWeaponControllerListByFight(fightNpcData) + local controllerList = {} + local characterId = fightNpcData.Character.Id + local weaponFashionId = fightNpcData.WeaponFashionId or XDataCenter.WeaponFashionManager.GetCharacterWearingWeaponFashionId(characterId) + local usage = XEquipConfig.WeaponUsage.Battle + for _, equip in pairs(fightNpcData.Equips) do + if XEquipManager.IsWeaponByTemplateId(equip.TemplateId) then + local idList = XEquipManager.GetEquipModelIdListByEquipData(equip, weaponFashionId) + for _, modelId in ipairs(idList) do + tableInsert(controllerList, XEquipConfig.GetEquipAnimController(modelId, usage)) + end + break + end + end + return controllerList + end + + --desc: 获取武器模型id列表 + function XEquipManager.GetEquipModelIdListByFight(fightNpcData) + local idList = {} + local characterId = fightNpcData.Character.Id + local weaponFashionId = fightNpcData.WeaponFashionId or XDataCenter.WeaponFashionManager.GetCharacterWearingWeaponFashionId(characterId) + for _, equip in pairs(fightNpcData.Equips) do + if XEquipManager.IsWeaponByTemplateId(equip.TemplateId) then + idList = XEquipManager.GetEquipModelIdListByEquipData(equip, weaponFashionId) + break + end + end + return idList + end + + --desc: 通过角色id获取武器模型名字列表 + function XEquipManager.GetEquipModelIdListByCharacterId(characterId, isDefault, weaponFashionId) + local isOwnCharacter = XDataCenter.CharacterManager.IsOwnCharacter(characterId) + + -- 武器时装预览 + if weaponFashionId then + if isOwnCharacter then + local equipId = XEquipManager.GetCharacterWearingWeaponId(characterId) + local equip = XEquipManager.GetEquip(equipId) + return XEquipManager.GetEquipModelIdListByEquipData(equip, weaponFashionId) + else + local templateId = XCharacterConfigs.GetCharacterDefaultEquipId(characterId) + local equip = { TemplateId = templateId } + return XEquipManager.GetEquipModelIdListByEquipData(equip, weaponFashionId) + end + end + + -- 默认武器预览 + if isDefault or not isOwnCharacter then + local idList = {} + local templateId = XCharacterConfigs.GetCharacterDefaultEquipId(characterId) + local template = XEquipConfig.GetEquipResCfg(templateId) + for _, id in pairs(template.ModelTransId) do + tableInsert(idList, id) + end + return idList + end + + -- 主角获取武器逻辑 + local equipId = XEquipManager.GetCharacterWearingWeaponId(characterId) + local equip = XEquipManager.GetEquip(equipId) + weaponFashionId = XDataCenter.WeaponFashionManager.GetCharacterWearingWeaponFashionId(characterId) + return XEquipManager.GetEquipModelIdListByEquipData(equip, weaponFashionId) + end + + -- 获取武器共鸣成功的特效显示时间 + function XEquipManager.GetWeaponResonanceEffectDelay(equipId, resonanceCount) + if not equipId then return end + local equip = XEquipManager.GetEquip(equipId) + local modelId = XEquipConfig.GetWeaponResonanceModelId(XEquipConfig.WeaponCase.Case1, equip.TemplateId, resonanceCount) + return XEquipConfig.GetWeaponResonanceEffectDelay(modelId) + end + + -- 获取角色武器共鸣特效(战斗用) + function XEquipManager.GetWeaponResonanceEffectPathByFight(fightNpcData) + local equip + + for _, v in pairs(fightNpcData.Equips) do + local equipTemplate = XEquipConfig.GetEquipCfg(v.TemplateId) + if equipTemplate.Site == XEquipConfig.EquipSite.Weapon then + equip = v + break + end + end + + if not equip then + XLog.Error("XEquipManager.GetWeaponResonanceEffectPathByFight错误, 参数fightNpcData:" .. tostring(fightNpcData) .. "中不包含武器") + return + end + + local resonanceCount = equip.ResonanceInfo and (equip.ResonanceInfo.Count or XTool.GetTableCount(equip.ResonanceInfo)) or 0 + local modelId = XEquipConfig.GetWeaponResonanceModelId(XEquipConfig.WeaponCase.Case1, equip.TemplateId, resonanceCount) + return XEquipConfig.GetEquipModelEffectPath(modelId) + end + + function XEquipManager.GetEquipCount(templateId) + local count = 0 + for _, v in pairs(Equips) do + if v.TemplateId == templateId then + count = count + 1 + end + end + return count + end + + function XEquipManager.GetFirstEquip(templateId) + for _, v in pairs(Equips) do + if v.TemplateId == templateId then + return v + end + end + end + + --desc: 获取装备大图标路径 + function XEquipManager.GetEquipBigIconPath(templateId) + if not templateId then + XLog.Error("XEquipManager.GetEquipBigIconPath错误, 参数templateId不能为空") + return + end + + local equipResCfg = XEquipConfig.GetEquipResCfg(templateId) + return equipResCfg.BigIconPath + end + + --desc: 获取装备图标路径 + function XEquipManager.GetEquipIconPath(templateId) + if not templateId then + XLog.Error("XEquipManager.GetEquipIconPath错误: 参数templateId不能为空") + return + end + + local equipResCfg = XEquipConfig.GetEquipResCfg(templateId) + return equipResCfg.IconPath + end + + --desc: 获取装备在背包中显示图标路径 + function XEquipManager.GetEquipIconBagPath(templateId, breakthroughTimes) + local equipResCfg = XEquipConfig.GetEquipResCfg(templateId, breakthroughTimes) + return equipResCfg.IconPath + end + + --desc: 获取套装在背包中显示图标路径 + function XEquipManager.GetSuitIconBagPath(suitId) + local suitCfg = XEquipConfig.GetEquipSuitCfg(suitId) + return suitCfg.IconPath + end + + --desc: 获取套装在背包中显示大图标路径 + function XEquipManager.GetSuitBigIconBagPath(suitId) + local suitCfg = XEquipConfig.GetEquipSuitCfg(suitId) + if not suitCfg then + local path = XEquipConfig.GetEquipSuitPath() + XLog.ErrorTableDataNotFound("XEquipManager.GetSuitBigIconBagPath", "suitCfg", path, "suitId", tostring(suitId)) + return + end + return suitCfg.BigIconPath + end + + --desc: 获取意识立绘路径 + function XEquipManager.GetEquipLiHuiPath(templateId, breakthroughTimes) + if not templateId then + XLog.Error("XEquipManager.GetEquipLiHuiPath 错误: 参数templateId不能为空") + return + end + + local equipResCfg = XEquipConfig.GetEquipResCfg(templateId, breakthroughTimes) + return equipResCfg.LiHuiPath + end + + function XEquipManager.GetEquipPainterName(templateId, breakthroughTimes) + local equipResCfg = XEquipConfig.GetEquipResCfg(templateId, breakthroughTimes) + return equipResCfg.PainterName + end + + function XEquipManager.GetEquipBgPath(templateId) + return XEquipConfig.GetEquipBgPath(templateId) + end + + function XEquipManager.GetEquipQualityPath(templateId) + return XEquipConfig.GetEquipQualityPath(templateId) + end + + function XEquipManager.GetEquipQuality(templateId) + local equipCfg = XEquipConfig.GetEquipCfg(templateId) + return equipCfg.Quality + end + + function XEquipManager.GetEquipPriority(templateId) + local equipCfg = XEquipConfig.GetEquipCfg(templateId) + return equipCfg.Priority + end + + function XEquipManager.GetEquipStar(templateId) + local equipCfg = XEquipConfig.GetEquipCfg(templateId) + return equipCfg.Star + end + + function XEquipManager.GetEquipName(templateId) + local equipCfg = XEquipConfig.GetEquipCfg(templateId) + return equipCfg.Name or "" + end + + function XEquipManager.GetEquipDescription(templateId) + local equipCfg = XEquipConfig.GetEquipCfg(templateId) + return equipCfg.Description or "" + end + + function XEquipManager.GetOriginWeaponSkillInfo(templateId) + local equipCfg = XEquipConfig.GetEquipCfg(templateId) + + local weaponSkillId = equipCfg.WeaponSkillId + if not weaponSkillId then + local path = XEquipConfig.GetEquipPath() + XLog.ErrorTableDataNotFound("XEquipManager.GetOriginWeaponSkillInfo", "weaponSkillId", path, "templateId", tostring(templateId)) + return + end + + return XSkillInfoObj.New(XEquipConfig.EquipResonanceType.WeaponSkill, weaponSkillId) + end + + function XEquipManager.GetEquipMinLevel(templateId) + local equipBorderCfg = XEquipConfig.GetEquipBorderCfg(templateId) + return equipBorderCfg.MinLevel + end + + function XEquipManager.GetEquipMaxLevel(templateId) + local equipBorderCfg = XEquipConfig.GetEquipBorderCfg(templateId) + return equipBorderCfg.MaxLevel + end + + function XEquipManager.GetEquipMinBreakthrough(templateId) + local equipBorderCfg = XEquipConfig.GetEquipBorderCfg(templateId) + return equipBorderCfg.MinBreakthrough + end + + function XEquipManager.GetEquipMaxBreakthrough(templateId) + local equipBorderCfg = XEquipConfig.GetEquipBorderCfg(templateId) + return equipBorderCfg.MaxBreakthrough + end + + function XEquipManager.GetNextLevelExp(equipId, level) + local equip = XDataCenter.EquipManager.GetEquip(equipId) + level = level or equip.Level + local levelUpCfg = XEquipConfig.GetLevelUpCfg(equip.TemplateId, equip.Breakthrough, level) + return levelUpCfg.Exp + end + + function XEquipManager.GetEquipAddExp(equipId, count) + count = count or 1 + local exp + + local equip = XEquipManager.GetEquip(equipId) + local levelUpCfg = XEquipConfig.GetLevelUpCfg(equip.TemplateId, equip.Breakthrough, equip.Level) + local offerExp = XEquipManager.GetEquipOfferExp(equipId) + + --- 获得经验 = 装备已培养经验 * 继承比例 + 突破提供的经验 + exp = equip.Exp + levelUpCfg.AllExp + exp = exp * XEquipConfig.GetEquipExpInheritPercent() / 100 + exp = exp + offerExp + + return exp * count + end + + function XEquipManager.GetEquipLevelTotalNeedExp(equipId, targetLevel) + local totalExp = 0 + + local equip = XEquipManager.GetEquip(equipId) + for level = equip.Level, targetLevel - 1 do + totalExp = totalExp + XEquipManager.GetNextLevelExp(equipId, level) + end + totalExp = totalExp - equip.Exp + + return totalExp + end + + function XEquipManager.GetEatEquipsCostMoney(equipIdKeys) + local costMoney = 0 + + for equipId in pairs(equipIdKeys) do + local equipCfg = GetEquipCfg(equipId) + costMoney = costMoney + XEquipConfig.GetEatEquipCostMoney(equipCfg.Site, equipCfg.Star) + end + + return costMoney + end + + function XEquipManager.GetEatItemsCostMoney(itemIdDic) + local costMoney = 0 + + for itemId, count in pairs(itemIdDic) do + costMoney = costMoney + XDataCenter.ItemManager.GetItemsAddEquipCost(itemId, count) + end + + return costMoney + end + + function XEquipManager.GetBreakthroughLevelLimitByTemplateId(templateId, times) + local equipBreakthroughCfg = XEquipConfig.GetEquipBreakthroughCfg(templateId, times or 0) + return equipBreakthroughCfg.LevelLimit + end + + function XEquipManager.GetBreakthroughLevelLimit(equipId) + local equipBreakthroughCfg = GetEquipBreakthroughCfg(equipId) + return equipBreakthroughCfg.LevelLimit + end + + function XEquipManager.GetBreakthroughLevelLimitByEquipData(equip) + local equipBreakthroughCfg = XEquipConfig.GetEquipBreakthroughCfg(equip.TemplateId, equip.Breakthrough) + return equipBreakthroughCfg.LevelLimit + end + + function XEquipManager.GetBreakthroughLevelLimitNext(equipId) + local equipBreakthroughCfg = GetEquipBreakthroughCfgNext(equipId) + return equipBreakthroughCfg.LevelLimit + end + + function XEquipManager.GetBreakthroughCondition(equipId) + local equipBreakthroughCfg = GetEquipBreakthroughCfg(equipId) + return equipBreakthroughCfg.ConditionId + end + + function XEquipManager.GetBreakthroughUseMoney(equipId) + local equipBreakthroughCfg = GetEquipBreakthroughCfg(equipId) + return equipBreakthroughCfg.UseMoney + end + + function XEquipManager.GetBreakthroughUseItemId(equipId) + local equipBreakthroughCfg = GetEquipBreakthroughCfg(equipId) + return equipBreakthroughCfg.UseItemId + end + + function XEquipManager.GetBreakthroughConsumeItems(equipId) + local consumeItems = {} + + local equipBreakthroughCfg = GetEquipBreakthroughCfg(equipId) + for i = 1, #equipBreakthroughCfg.ItemId do + tableInsert(consumeItems, { + Id = equipBreakthroughCfg.ItemId[i], + Count = equipBreakthroughCfg.ItemCount[i], + }) + end + + return consumeItems + end + + function XEquipManager.GetAwakeConsumeCoin(equipId) + local consumeCoin = 0 + + local coinId = XDataCenter.ItemManager.ItemId.Coin + local config = GetEquipAwakeCfg(equipId) + for i = 1, #config.ItemId do + local itemId = config.ItemId[i] + if itemId == coinId then + consumeCoin = config.ItemCount[i] + break + end + end + + return consumeCoin + end + + function XEquipManager.GetAwakeConsumeItemList(equipId) + local consumeItems = {} + + local coinId = XDataCenter.ItemManager.ItemId.Coin + local config = GetEquipAwakeCfg(equipId) + for i = 1, #config.ItemId do + local itemId = config.ItemId[i] + if itemId ~= coinId then + tableInsert(consumeItems, { + ItemId = itemId, + Count = config.ItemCount[i], + }) + end + end + + return consumeItems + end + + function XEquipManager.GetAwakeConsumeItemCrystalList(equipId) + local consumeItems = {} + + local coinId = XDataCenter.ItemManager.ItemId.Coin + local config = GetEquipAwakeCfg(equipId) + for i = 1, #config.ItemCrystalId do + local itemId = config.ItemCrystalId[i] + if itemId ~= coinId then + tableInsert(consumeItems, { + ItemId = itemId, + Count = config.ItemCrystalCount[i], + }) + end + end + + return consumeItems + end + + function XEquipManager.GetAwakeConsumeCrystalCoin(equipId) + local consumeCoin = 0 + + local coinId = XDataCenter.ItemManager.ItemId.Coin + local config = GetEquipAwakeCfg(equipId) + for i = 1, #config.ItemCrystalId do + local itemId = config.ItemCrystalId[i] + if itemId == coinId then + consumeCoin = config.ItemCrystalCount[i] + break + end + end + + return consumeCoin + end + + function XEquipManager.GetAwakeSkillDesList(equipId, pos) + local templateId = GetEquipTemplateId(equipId) + return XEquipConfig.GetEquipAwakeSkillDesList(templateId, pos) + end + + function XEquipManager.GetAwakeSkillDesListByEquipData(equip, pos) + local templateId = equip.TemplateId + return XEquipConfig.GetEquipAwakeSkillDesList(templateId, pos) + end + + function XEquipManager.GetEquipOfferExp(equipId) + local equipBreakthroughCfg = GetEquipBreakthroughCfg(equipId) + return equipBreakthroughCfg.Exp + end + + function XEquipManager.GetResonanceSkillNum(equipId) + local templateId = GetEquipTemplateId(equipId) + return XEquipManager.GetResonanceSkillNumByTemplateId(templateId) + end + + function XEquipManager.GetResonanceSkillNumByTemplateId(templateId) + local count = 0 + + local equipResonanceCfg = XEquipConfig.GetEquipResonanceCfg(templateId) + if not equipResonanceCfg then return count end + + for pos = 1, XEquipConfig.MAX_RESONANCE_SKILL_COUNT do + if equipResonanceCfg.WeaponSkillPoolId and equipResonanceCfg.WeaponSkillPoolId[pos] and equipResonanceCfg.WeaponSkillPoolId[pos] > 0 then + count = count + 1 + elseif equipResonanceCfg.AttribPoolId and equipResonanceCfg.AttribPoolId[pos] and equipResonanceCfg.AttribPoolId[pos] > 0 then + count = count + 1 + elseif equipResonanceCfg.CharacterSkillPoolId and equipResonanceCfg.CharacterSkillPoolId[pos] + and equipResonanceCfg.CharacterSkillPoolId[pos] > 0 then + count = count + 1 + end + end + + return count + end + + function XEquipManager.GetResonancePreSkillInfoList(equipId, characterId, slot) + local preSkillInfoList = {} + local templateId = GetEquipTemplateId(equipId) + local equipResonanceCfg = XEquipConfig.GetEquipResonanceCfg(templateId) + + if XEquipManager.IsClassifyEqual(equipId, XEquipConfig.Classify.Weapon) then + local poolId = equipResonanceCfg.WeaponSkillPoolId[slot] + local skillIds = XEquipConfig.GetWeaponSkillPoolSkillIds(poolId, characterId) + + for _, skillId in ipairs(skillIds) do + tableInsert(preSkillInfoList, XSkillInfoObj.New(XEquipConfig.EquipResonanceType.WeaponSkill, skillId)) + end + else + local skillPoolId = equipResonanceCfg.CharacterSkillPoolId[slot] + local skillInfos = XCharacterConfigs.GetCharacterSkillPoolSkillInfos(skillPoolId, characterId) + local attrPoolId = equipResonanceCfg.AttribPoolId[slot] + local attrInfos = XAttribConfigs.GetAttribGroupTemplateByPoolId(attrPoolId) + + for i, v in ipairs(skillInfos) do + tableInsert(preSkillInfoList, XSkillInfoObj.New(XEquipConfig.EquipResonanceType.CharacterSkill, v.SkillId)) + end + + for i, v in ipairs(attrInfos) do + tableInsert(preSkillInfoList, XSkillInfoObj.New(XEquipConfig.EquipResonanceType.Attrib, v.Id)) + end + end + + return preSkillInfoList + end + + function XEquipManager.GetResonanceSkillInfo(equipId, pos) + local skillInfo = {} + + local equip = XEquipManager.GetEquip(equipId) + if equip.ResonanceInfo and equip.ResonanceInfo[pos] then + skillInfo = XSkillInfoObj.New(equip.ResonanceInfo[pos].Type, equip.ResonanceInfo[pos].TemplateId) + end + + return skillInfo + end + + function XEquipManager.GetResonanceSkillInfoByEquipData(equip, pos) + local skillInfo = {} + + if equip.ResonanceInfo and equip.ResonanceInfo[pos] then + skillInfo = XSkillInfoObj.New(equip.ResonanceInfo[pos].Type, equip.ResonanceInfo[pos].TemplateId) + end + + return skillInfo + end + + function XEquipManager.GetUnconfirmedResonanceSkillInfo(equipId, pos) + local skillInfo = {} + + local equip = XEquipManager.GetEquip(equipId) + if equip.UnconfirmedResonanceInfo and equip.UnconfirmedResonanceInfo[pos] then + skillInfo = XSkillInfoObj.New(equip.UnconfirmedResonanceInfo[pos].Type, equip.UnconfirmedResonanceInfo[pos].TemplateId) + end + + return skillInfo + end + + function XEquipManager.GetResonanceBindCharacterId(equipId, pos) + local equip = XEquipManager.GetEquip(equipId) + return equip.ResonanceInfo and equip.ResonanceInfo[pos] and equip.ResonanceInfo[pos].CharacterId or 0 + end + + function XEquipManager.GetResonanceBindCharacterIdByEquipData(equip, pos) + return equip.ResonanceInfo and equip.ResonanceInfo[pos] and equip.ResonanceInfo[pos].CharacterId or 0 + end + + function XEquipManager.GetUnconfirmedResonanceBindCharacterId(equipId, pos) + local equip = XEquipManager.GetEquip(equipId) + return equip.UnconfirmedResonanceInfo and equip.UnconfirmedResonanceInfo[pos] and equip.UnconfirmedResonanceInfo[pos].CharacterId + end + + function XEquipManager.GetResonanceConsumeItemId(equipId) + local templateId = GetEquipTemplateId(equipId) + local equipResonanceItemCfg = XEquipConfig.GetEquipResonanceConsumeItemCfg(templateId) + return equipResonanceItemCfg.ItemId[1] + end + + function XEquipManager.GetResonanceConsumeItemCount(equipId) + local templateId = GetEquipTemplateId(equipId) + local equipResonanceItemCfg = XEquipConfig.GetEquipResonanceConsumeItemCfg(templateId) + local count = equipResonanceItemCfg.ItemCount[1] + + return count + end + + function XEquipManager.GetResonanceConsumeSelectSkillItemId(equipId) + local templateId = GetEquipTemplateId(equipId) + local equipResonanceItemCfg = XEquipConfig.GetEquipResonanceConsumeItemCfg(templateId) + return equipResonanceItemCfg.SelectSkillItemId[1] + end + + function XEquipManager.GetResonanceConsumeSelectSkillItemCount(equipId) + local templateId = GetEquipTemplateId(equipId) + local equipResonanceItemCfg = XEquipConfig.GetEquipResonanceConsumeItemCfg(templateId) + local count = equipResonanceItemCfg.SelectSkillItemCount[1] + + return count + end + + function XEquipManager.GetResonanceCanEatEquipIds(equipId) + local equipIds = {} + + if XEquipManager.IsClassifyEqual(equipId, XEquipConfig.Classify.Weapon) then + --武器消耗同星级 + local resonanceEquip = XEquipManager.GetEquip(equipId) + local star = XEquipManager.GetEquipStar(resonanceEquip.TemplateId) + + for _, equip in pairs(Equips) do + if equip.Id ~= equipId and star == XEquipManager.GetEquipStar(equip.TemplateId) + and XEquipManager.IsClassifyEqual(equip.Id, XEquipConfig.Classify.Weapon) + and not XEquipManager.IsWearing(equip.Id) and not XEquipManager.IsLock(equip.Id) then + tableInsert(equipIds, equip.Id) + end + end + else + --意识消耗同套装 + local resonanceSuitId = XEquipManager.GetSuitId(equipId) + + for _, equip in pairs(Equips) do + if equip.Id ~= equipId and resonanceSuitId == XEquipManager.GetSuitId(equip.Id) + and XEquipManager.IsClassifyEqual(equip.Id, XEquipConfig.Classify.Awareness) + and not XEquipManager.IsWearing(equip.Id) and not XEquipManager.IsInSuitPrefab(equip.Id) and not XEquipManager.IsLock(equip.Id) then + tableInsert(equipIds, equip.Id) + end + end + end + + --加个默认排序 + XEquipManager.SortEquipIdListByPriorType(equipIds) + + return equipIds + end + + function XEquipManager.GetCanResonanceCharacterList(equipId) + local canResonanceCharacterList = {} + + local wearingCharacterId = XEquipManager.GetEquipWearingCharacterId(equipId) + if wearingCharacterId then + tableInsert(canResonanceCharacterList, XDataCenter.CharacterManager.GetCharacter(wearingCharacterId)) + end + + local templateId = GetEquipTemplateId(equipId) + local characterType = XEquipConfig.GetEquipCharacterType(templateId) + local ownCharacterList = XDataCenter.CharacterManager.GetOwnCharacterList(characterType) + for _, character in pairs(ownCharacterList) do + local characterId = character.Id + if characterId ~= wearingCharacterId then + local characterEquipType = XCharacterConfigs.GetCharacterEquipType(characterId) + if XEquipManager.IsTypeEqual(equipId, characterEquipType) then + tableInsert(canResonanceCharacterList, character) + end + end + end + + return canResonanceCharacterList + end + + --获取某TemplateID的装备的数量 + function XEquipManager.GetEquipCountByTemplateID(templateId) + local count = 0 + for _, v in pairs(Equips) do + if v.TemplateId == templateId then + count = count + 1 + end + end + return count + end + + local function GetWeaponSkillAbility(equip, characterId) + local template = XEquipConfig.GetEquipCfg(equip.TemplateId) + if not template then + return + end + + if template.Site ~= XEquipConfig.EquipSite.Weapon then + XLog.Error("GetWeaponSkillAbility 错误: 参数equip不是武器, equip的Site是: " .. template.site) + return + end + + local ability = 0 + + if template.WeaponSkillId > 0 then + local weaponAbility = XEquipConfig.GetWeaponSkillAbility(template.WeaponSkillId) + if not weaponAbility then + local path = XEquipConfig.GetWeaponSkillPath() + XLog.ErrorTableDataNotFound("XEquipManager.GetWeaponSkillAbility", + "weaponAbility", path, "WeaponSkillId", tostring(template.WeaponSkillId)) + return + end + + ability = ability + weaponAbility + end + + if equip.ResonanceInfo then + for _, resonanceData in pairs(equip.ResonanceInfo) do + if resonanceData.Type == XEquipConfig.EquipResonanceType.WeaponSkill then + if resonanceData.CharacterId == 0 or resonanceData.CharacterId == characterId then + local weaponAbility = XEquipConfig.GetWeaponSkillAbility(resonanceData.TemplateId) + if not weaponAbility then + local path = XEquipConfig.GetWeaponSkillPath() + XLog.ErrorTableDataNotFound("XEquipManager.GetWeaponSkillAbility", + "weaponAbility", path, "WeaponSkillId", tostring(resonanceData.TemplateId)) + return + end + + ability = ability + weaponAbility + end + end + end + end + + return ability + end + + local function GetEquipSkillAbility(equipList, characterId) + local suitCount = {} + local ability = 0 + + for _, equip in pairs(equipList) do + local template = XEquipConfig.GetEquipCfg(equip.TemplateId) + if not template then + return 0 + end + + if template.Site == XEquipConfig.EquipSite.Weapon then + local weaponAbility = GetWeaponSkillAbility(equip, characterId) + if not weaponAbility then + return 0 + end + + ability = ability + weaponAbility + end + + if template.SuitId > 0 then + if not suitCount[template.SuitId] then + suitCount[template.SuitId] = 1 + else + suitCount[template.SuitId] = suitCount[template.SuitId] + 1 + end + end + end + + for suitId, count in pairs(suitCount) do + local template = XEquipConfig.GetEquipSuitCfg(suitId) + if not template then + return 0 + end + + for i = 1, mathMin(count, XEquipConfig.MAX_SUIT_COUNT) do + local effectId = template.SkillEffect[i] + if effectId and effectId > 0 then + local effectTemplate = XEquipConfig.GetEquipSuitEffectCfg(effectId) + if not effectTemplate then + return 0 + end + + ability = ability + effectTemplate.Ability + end + end + end + + return ability + end + + function XEquipManager.GetEquipSkillAbility(characterId) + local equipList = XEquipManager.GetCharacterWearingEquips(characterId) + if not equipList or #equipList <= 0 then + return 0 + end + + return GetEquipSkillAbility(equipList, characterId) + end + + function XEquipManager.GetEquipSkillAbilityOther(character, equipList) + if not equipList or #equipList <= 0 then + return 0 + end + return GetEquipSkillAbility(equipList, character.Id) + end + + --- 计算装备战斗力(不包含角色共鸣相关) + function XEquipManager.GetEquipAbility(characterId) + local equipList = XEquipManager.GetCharacterWearingEquips(characterId) + if not equipList or #equipList <= 0 then + return 0 + end + + local skillAbility = GetEquipSkillAbility(equipList, 0) + local equipListAttribs = XFightEquipManager.GetEquipListAttribs(equipList) + local equipListAbility = XAttribManager.GetAttribAbility(equipListAttribs) + + return equipListAbility + skillAbility + end + + function XEquipManager.GetEquipSkipIds(eatType, equipId) + local site = XEquipManager.GetEquipSite(equipId) + local template = XEquipConfig.GetEquipSkipIdTemplate(eatType, site) + return template.SkipIdParams + end + + function XEquipManager.CheckBoxOverLimitOfDraw()--武器意识拦截检测 + OverLimitTexts["Weapon"] = nil + OverLimitTexts["Wafer"] = nil + + local max = XEquipConfig.GetMaxWeaponCount() + local cur = XEquipManager.GetWeaponCount() + if (max - cur) < 1 then + OverLimitTexts["Weapon"] = CS.XTextManager.GetText("WeaponBoxIsFull") + end + + max = XEquipConfig.GetMaxAwarenessCount() + cur = XEquipManager.GetAwarenessCount() + if (max - cur) < 1 then + OverLimitTexts["Wafer"] = CS.XTextManager.GetText("WaferBoxIsFull") + end + + max = CS.XGame.Config:GetInt("MailCountLimit") + cur = #XDataCenter.MailManager.GetMailList() + if (max - cur) < 1 then + XUiManager.TipMsg(CS.XTextManager.GetText("MailBoxIsFull")) + return true + end + + if OverLimitTexts["Weapon"] then + XUiManager.TipMsg(OverLimitTexts["Weapon"]) + return true + end + if OverLimitTexts["Wafer"] then + XUiManager.TipMsg(OverLimitTexts["Wafer"]) + return true + end + return false + end + + function XEquipManager.CheckBoxOverLimitOfGetAwareness()--意识拦截检测 + OverLimitTexts["Wafer"] = nil + + local max = XEquipConfig.GetMaxAwarenessCount() + local cur = XEquipManager.GetAwarenessCount() + if (max - cur) < 1 then + OverLimitTexts["Wafer"] = CS.XTextManager.GetText("WaferBoxIsFull") + end + + max = CS.XGame.Config:GetInt("MailCountLimit") + cur = #XDataCenter.MailManager.GetMailList() + if (max - cur) < 1 then + XUiManager.TipMsg(CS.XTextManager.GetText("MailBoxIsFull")) + return true + end + + if OverLimitTexts["Wafer"] then + XUiManager.TipMsg(OverLimitTexts["Wafer"]) + return true + end + return false + end + + function XEquipManager.GetMaxCountOfBoxOverLimit(EquipId, MaxCount, Count)--武器意识拦截检测 + local maxCount = MaxCount + OverLimitTexts["Weapon"] = nil + OverLimitTexts["Wafer"] = nil + OverLimitTexts["Item"] = nil + + if XArrangeConfigs.GetType(EquipId) == XArrangeConfigs.Types.Weapon then + local max = XEquipConfig.GetMaxWeaponCount() + local cur = XEquipManager.GetWeaponCount() + if (max - cur) // Count < maxCount then + maxCount = math.max(0, (max - cur) // Count) + OverLimitTexts["Weapon"] = CS.XTextManager.GetText("WeaponBoxWillBeFull") + end + elseif XArrangeConfigs.GetType(EquipId) == XArrangeConfigs.Types.Wafer then + local max = XEquipConfig.GetMaxAwarenessCount() + local cur = XEquipManager.GetAwarenessCount() + if (max - cur) // Count < maxCount then + maxCount = math.max(0, (max - cur) // Count) + OverLimitTexts["Wafer"] = CS.XTextManager.GetText("WaferBoxWillBeFull") + end + elseif XArrangeConfigs.GetType(EquipId) == XArrangeConfigs.Types.Item then + local item = XDataCenter.ItemManager.GetItem(EquipId) + local max = item.Template.MaxCount + local cur = item:GetCount() + if max > 0 then + if (max - cur) // Count < maxCount then + maxCount = math.max(0, (max - cur) // Count) + OverLimitTexts["Item"] = CS.XTextManager.GetText("ItemBoxWillBeFull") + end + end + end + + return maxCount + end + + function XEquipManager.ShowBoxOverLimitText()--武器意识拦截检测 + if OverLimitTexts["Weapon"] then + XUiManager.TipMsg(OverLimitTexts["Weapon"]) + return true + end + if OverLimitTexts["Wafer"] then + XUiManager.TipMsg(OverLimitTexts["Wafer"]) + return true + end + if OverLimitTexts["Item"] then + XUiManager.TipMsg(OverLimitTexts["Item"]) + return true + end + return false + end + + function XEquipManager.GetAwakeItemApplicationScope(itemId)--获取觉醒道具能够生效的意识列表 + if not AwakeItemTypeDic then + XLog.Error("EquipAwake.tab Is None or EquipAwakeItem Is None") + return nil + end + return AwakeItemTypeDic[itemId] + end + + --装备回收相关 begin + --意识回收设置 + local AwarenessRecycleInfo = { + --设置的回收星级(默认选中1-4星) + StarCheckDic = { + [1] = true, + [2] = true, + [3] = true, + [4] = true, + }, + Days = 0, --设置回收天数, 0为不回收 + } + + local function UpdateAwarenessRecycleInfo(recycleInfo) + if XTool.IsTableEmpty(recycleInfo) then return end + + local starDic = {} + for _, star in pairs(recycleInfo.RecycleStar or {}) do + starDic[star] = true + end + AwarenessRecycleInfo.StarCheckDic = starDic + + AwarenessRecycleInfo.Days = recycleInfo.Days or 0 + end + + function XEquipManager.IsEquipCanRecycle(equipId) + if not equipId then return false end + local equip = XEquipManager.GetEquip(equipId) + if not equip then return false end + + local equipId = equip.Id + return + XEquipManager.IsClassifyEqual(equipId, XEquipConfig.Classify.Awareness) --是意识(后续开放武器回收) + and XEquipManager.GetEquipStar(equip.TemplateId) <= XEquipConfig.CAN_NOT_AUTO_EAT_STAR --星级≤5 + and equip.Breakthrough == 0 --无突破 + and equip.Level == 1 and equip.Exp == 0 --无强化 + and not equip.ResonanceInfo and not equip.UnconfirmedResonanceInfo --无共鸣 + and not XEquipManager.IsEquipAwaken(equipId) --无觉醒 + and not XEquipManager.IsWearing(equipId) --未被穿戴 + and not XEquipManager.IsInSuitPrefab(equipId) --未被预设在意识组合中 + and not XEquipManager.IsLock(equipId) --未上锁 + end + + --是否待回收 + function XEquipManager.IsRecycle(equipId) + if not equipId then return false end + local equip = XEquipManager.GetEquip(equipId) + if not equip then return false end + + return equip.IsRecycle + end + + function XEquipManager.GetCanRecycleWeaponIds() + local weaponIds = {} + for k, v in pairs(Equips) do + local equipId = v.Id + + if XEquipManager.IsClassifyEqual(equipId, XEquipConfig.Classify.Weapon) + and XEquipManager.IsEquipCanRecycle(equipId) + then + tableInsert(weaponIds, k) + end + end + return weaponIds + end + + function XEquipManager.GetCanRecycleAwarenessIdsBySuitId(suitId) + local awarenessIds = {} + + local equipIds = XEquipManager.GetEquipIdsBySuitId(suitId) + for _, equipId in pairs(equipIds) do + if XEquipManager.IsClassifyEqual(equipId, XEquipConfig.Classify.Awareness) + and XEquipManager.IsEquipCanRecycle(equipId) + then + tableInsert(awarenessIds, equipId) + end + end + + return awarenessIds + end + + function XEquipManager.GetEquipRecycleItemCount(equipId, count) + count = count or 1 + return precent * XEquipManager.GetEquipAddExp(equipId, count) + end + + function XEquipManager.GetRecycleRewards(equipIds) + local itemInfoList = {} + + local totalExp = 0 + for _, equipId in pairs(equipIds) do + local addExp = XEquipManager.GetEquipAddExp(equipId) + totalExp = totalExp + addExp + end + if totalExp == 0 then return itemInfoList end + + local precent = XEquipConfig.GetEquipRecycleItemPercent() + local itemInfo = { + TemplateId = XEquipConfig.GetEquipRecycleItemId(), + Count = mathFloor(precent * totalExp), + } + tableInsert(itemInfoList, itemInfo) + + return itemInfoList + end + + function XEquipManager.GetRecycleStarCheckDic() + return XTool.Clone(AwarenessRecycleInfo.StarCheckDic) + end + + function XEquipManager.GetRecycleSettingDays() + return AwarenessRecycleInfo.Days or 0 + end + + function XEquipManager.CheckRecycleInfoDifferent(starCheckDic, days) + if days ~= AwarenessRecycleInfo.Days then + return true + end + + for star, value in pairs(starCheckDic) do + if value and not AwarenessRecycleInfo.StarCheckDic[star] then + return true + end + end + + for star, value in pairs(AwarenessRecycleInfo.StarCheckDic) do + if value and not starCheckDic[star] then + return true + end + end + + return false + end + + --装备意识回收请求 + function XEquipManager.EquipChipRecycleRequest(equipIds, cb) + local req = { ChipIds = equipIds } + XNetwork.Call("EquipChipRecycleRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local rewardGoodsList = res.RewardGoodsList + for _, id in pairs(equipIds) do + XEquipManager.DeleteEquip(id) + end + + if cb then cb(rewardGoodsList) end + end) + end + + --装备意识设置自动回收请求 + function XEquipManager.EquipChipSiteAutoRecycleRequest(starList, days, cb) + local req = { StarList = starList, Days = days } + XNetwork.Call("EquipChipSiteAutoRecycleRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + UpdateAwarenessRecycleInfo({ + RecycleStar = starList, + Days = days, + }) + + if cb then cb() end + end) + end + + function XEquipManager.IsSetRecycleNeedConfirm(equipId) + if XEquipManager.IsHaveRecycleCookie() then return false end + local equip = XEquipManager.GetEquip(equipId) + return equip and XEquipManager.GetEquipStar(equip.TemplateId) == XEquipConfig.CAN_NOT_AUTO_EAT_STAR + end + + function XEquipManager.GetRecycleCookieKey() + return XPlayer.Id .. "IsHaveRecycleCookie" + end + + function XEquipManager.IsHaveRecycleCookie() + local key = XEquipManager.GetRecycleCookieKey() + local updateTime = XSaveTool.GetData(key) + if not updateTime then + return false + end + return XTime.GetServerNowTimestamp() < updateTime + end + + function XEquipManager.SetRecycleCookie(isSelect) + local key = XEquipManager.GetRecycleCookieKey() + if not isSelect then + XSaveTool.RemoveData(key) + else + if XEquipManager.IsHaveRecycleCookie() then return end + local updateTime = XTime.GetSeverTomorrowFreshTime() + XSaveTool.SaveData(key, updateTime) + end + end + + --装备更新回收标志请求 + function XEquipManager.EquipUpdateRecycleRequest(equipId, isRecycle, cb) + isRecycle = isRecycle and true or false + + local callFunc = function() + local req = { EquipId = equipId, IsRecycle = isRecycle } + XNetwork.Call("EquipUpdateRecycleRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local equip = XEquipManager.GetEquip(equipId) + equip:SetRecycle(isRecycle) + + if cb then cb() end + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_EQUIP_RECYCLE_STATUS_CHANGE_NOTYFY, equipId, isRecycle) + XEventManager.DispatchEvent(XEventId.EVENT_EQUIP_RECYCLE_STATUS_CHANGE_NOTYFY, equipId, isRecycle) + end) + end + + if isRecycle and XEquipManager.IsSetRecycleNeedConfirm(equipId) then + local title = CSXTextManagerGetText("EquipSetRecycleConfirmTitle") + local content = CSXTextManagerGetText("EquipSetRecycleConfirmContent") + local days = XEquipManager.GetRecycleSettingDays() + local content2 = days > 0 and CSXTextManagerGetText("EquipSetRecycleConfirmContentExtra", days) or CSXTextManagerGetText("EquipSetRecycleConfirmContentExtraNegative") + local hintInfo = { + SetHintCb = XEquipManager.SetRecycleCookie, + Status = XEquipManager.IsHaveRecycleCookie, + } + XUiManager.DialogHintTip(title, content, content2, nil, callFunc, hintInfo) + else + callFunc() + end + end + + function XEquipManager.NotifyEquipChipAutoRecycleSite(data) + UpdateAwarenessRecycleInfo(data.ChipRecycleSite) + end + + function XEquipManager.NotifyEquipAutoRecycleChipList(data) + local equipIds = data.ChipIds + if XTool.IsTableEmpty(equipIds) then return end + + for _, equipId in pairs(equipIds) do + XEquipManager.DeleteEquip(equipId) + end + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_EQUIP_RECYCLE_NOTIFY, equipIds) + end + --装备回收相关 end + -----------------------------------------Getter End------------------------------------ + XEquipManager.GetEquipTemplateId = GetEquipTemplateId + + return XEquipManager +end + +XRpc.NotifyEquipDataList = function(data) + XDataCenter.EquipManager.NotifyEquipDataList(data) +end + +XRpc.NotifyEquipChipGroupList = function(data) + XDataCenter.EquipManager.NotifyEquipChipGroupList(data) +end + +XRpc.NotifyEquipChipAutoRecycleSite = function(data) + XDataCenter.EquipManager.NotifyEquipChipAutoRecycleSite(data) +end + +XRpc.NotifyEquipAutoRecycleChipList = function(data) + XDataCenter.EquipManager.NotifyEquipAutoRecycleChipList(data) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XEventManager.lua b/Resources/Scripts/XManager/XEventManager.lua new file mode 100644 index 00000000..8c6e5a8c --- /dev/null +++ b/Resources/Scripts/XManager/XEventManager.lua @@ -0,0 +1,142 @@ +XEventManager = XEventManager or {} + +local ListenersMap = {} +local DelayRemoveMap = {} +local IsRunning = false + +function XEventManager.AddEventListener(eventId, func, obj) + local listenerList = ListenersMap[eventId] + if (not listenerList) then + listenerList = {} + end + + local funcList = listenerList[func] + if (obj) then + if (not funcList) then + funcList = {} + end + funcList[obj] = obj + listenerList[func] = funcList + else + listenerList[func] = func + end + + ListenersMap[eventId] = listenerList + return { eventId, func, obj } +end + +function XEventManager.RemoveEventListener(eventId, func, obj) + if IsRunning then + DelayRemoveMap[eventId] = DelayRemoveMap[eventId] or {} + DelayRemoveMap[eventId][func] = DelayRemoveMap[eventId][func] or {} + if obj then + DelayRemoveMap[eventId][func][obj] = true + else + DelayRemoveMap[eventId][func][func] = true + end + return + end + local listenerList = ListenersMap[eventId] + if (not listenerList) then + return + end + + local funcList = listenerList[func] + if (obj) then + if (not funcList) then + return + end + funcList[obj] = nil + listenerList[func] = funcList + else + listenerList[func] = nil + end + + ListenersMap[eventId] = listenerList +end + +function XEventManager.RemoveAllListener() + ListenersMap = {} +end + +function XEventManager.DispatchEvent(eventId, ...) + local listenerList = ListenersMap[eventId] + if (not listenerList) then + return + end + IsRunning = true + for f, listener in pairs(listenerList) do + if (type(listener) == "table") then + for _, obj in pairs(listener) do + if not DelayRemoveMap[eventId] or not DelayRemoveMap[eventId][f] or not DelayRemoveMap[eventId][f][obj] + or not DelayRemoveMap[eventId][f][f] then + f(obj, ...) + end + end + else + if not DelayRemoveMap[eventId] or not DelayRemoveMap[eventId][f] or not DelayRemoveMap[eventId][f][f] then + f(...) + end + end + end + IsRunning = false + if next(DelayRemoveMap) then + for rmId, rmEventList in pairs(DelayRemoveMap) do + for rmF, rmFunclist in pairs(rmEventList) do + for obj, _ in pairs(rmFunclist) do + if obj == rmF then + XEventManager.RemoveEventListener(rmId, rmF) + else + XEventManager.RemoveEventListener(rmId, rmF, obj) + end + end + end + end + DelayRemoveMap = {} + end +end + +------ 添加节点的绑定 -------- +local NodeEventBindRecord = {} + +function XEventManager.BindEvent(node, eventId, func, obj) + if not NodeEventBindRecord[node] then + NodeEventBindRecord[node] = {} + end + local checkExist + if node.Exist then + checkExist = function() return node:Exist() end + else + local gameObject = node.GameObject or node.gameObject or node.Transform or node.transform + if gameObject and gameObject.Exist then + checkExist = function() return gameObject:Exist() end + end + end + local handler + if checkExist then + handler = XEventManager.AddEventListener(eventId, function(...) + if not checkExist() then + XEventManager.UnBindEvent(node) + else + if obj then + func(obj, ...) + else + func(...) + end + end + end) + else + handler = XEventManager.AddEventListener(eventId, func, obj) + end + table.insert(NodeEventBindRecord[node], handler) + return handler +end + +function XEventManager.UnBindEvent(node) + if NodeEventBindRecord[node] then + for _, v in ipairs(NodeEventBindRecord[node]) do + XEventManager.RemoveEventListener(table.unpack(v)) + end + NodeEventBindRecord[node] = nil + end +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XExhibitionManager.lua b/Resources/Scripts/XManager/XExhibitionManager.lua new file mode 100644 index 00000000..07a7becc --- /dev/null +++ b/Resources/Scripts/XManager/XExhibitionManager.lua @@ -0,0 +1,301 @@ +XExhibitionManagerCreator = function() + local XExhibitionManager = {} + local METHOD_NAME = { + GatherRewardListRequest = "GatherRewardListRequest", + GetGatherReward = "GatherRewardRequest", + } + + local TotalCharacterNum = {} + local CharacterTaskFinished = {} + --临时存放要查看的人的数据 + local CharacterInfo = nil + local SelfGatherRewards = {} + XExhibitionManager.ExhibitionType = { + STRUCT = XCharacterConfigs.CharacterType.Normal, -- 构造体 + PUNISHER = XCharacterConfigs.CharacterType.Isomer, -- 授格者 + Linkage = 3, -- 联动角色 + } + function XExhibitionManager.HandleExhibitionInfo(data) + for _, v in pairs(data.GatherRewards) do + CharacterTaskFinished[v] = true + end + SelfGatherRewards = data.GatherRewards + XEventManager.DispatchEvent(XEventId.EVENT_CHARACTER_EXHIBITION_REFRESH) + end + --获得新的角色 + function XExhibitionManager.GetNewCharacter(Id) + if not CharacterTaskFinished[Id] then + CharacterTaskFinished[Id] = true + table.insert(SelfGatherRewards, Id) + end + end + --存放希望查看的玩家所持有图鉴数据 + function XExhibitionManager.SetCharacterInfo(info) + CharacterInfo = info + end + + function XExhibitionManager.ClearCharacterInfo() + CharacterInfo = nil + end + --存放自己的所持有图鉴数据 + function XExhibitionManager.GetSelfGatherRewards() + return SelfGatherRewards + end + + function XExhibitionManager.CheckTempCharacterTaskFinish(id, IsNotSelf) + local info = IsNotSelf and CharacterInfo or SelfGatherRewards + for _, v in pairs(info) do + if v == id then + return true + end + end + return false + end + + function XExhibitionManager.GetCharacterGrowUpLevel(characterId, IsNotSelf) + local curLevel = XCharacterConfigs.GrowUpLevel.New + local characterTasks = XExhibitionConfigs.GetCharacterGrowUpTasks(characterId) + if XTool.IsTableEmpty(characterTasks) then + return curLevel + end + for _, task in pairs(characterTasks) do + if task.LevelId > curLevel and XExhibitionManager.CheckTempCharacterTaskFinish(task.Id, IsNotSelf) then + curLevel = task.LevelId + end + end + return curLevel + end + + function XExhibitionManager.IsAchieveMaxLiberation(characterId, IsNotSelf) + return XExhibitionManager.IsAchieveLiberation(characterId, XCharacterConfigs.GrowUpLevel.End, IsNotSelf) + end + + function XExhibitionManager.IsAchieveLiberation(characterId, level, IsNotSelf) + return level and XExhibitionManager.GetCharacterGrowUpLevel(characterId, IsNotSelf) == level + end + + function XExhibitionManager.IsMaxLiberationLevel(level) + return level == XCharacterConfigs.GrowUpLevel.End + end + + function XExhibitionManager.CheckIsOwnCharacter(characterId, IsNotSelf) + local growUpTasksConfig = XExhibitionConfigs.GetGrowUpTasksConfig() + local info = IsNotSelf and CharacterInfo or SelfGatherRewards + for _, v in pairs(info) do + if growUpTasksConfig[v].CharacterId == characterId then + return true + end + end + return false + end + + function XExhibitionManager.CheckNewCharacterReward(characterId) + local isNew = false + + if characterId then + return XExhibitionManager.CheckNewRewardByCharacterId(characterId) + end + + local tasksConfig = XExhibitionConfigs.GetCharacterGrowUpTasksConfig() + if XDataCenter.ExhibitionManager.CheckRedPointIsCanSee() then + for tmpCharacterId, taskConfig in pairs(tasksConfig) do + if XDataCenter.CharacterManager.IsOwnCharacter(tmpCharacterId) then + for taskId, config in pairs(taskConfig) do + local canGetReward = true + for index = 1, #config.ConditionIds do + local ret, _ = XConditionManager.CheckCondition(config.ConditionIds[index], tmpCharacterId) + if not ret then + canGetReward = false + end + end + if canGetReward and not XExhibitionManager.CheckGrowUpTaskFinish(taskId) then + isNew = true + end + end + end + end + end + return isNew + end + + function XExhibitionManager.CheckRedPointIsCanSee() + return XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.CharacterExhibition) + end + + function XExhibitionManager.CheckNewRewardByCharacterId(characterId) + if not XDataCenter.CharacterManager.IsOwnCharacter(characterId) then + return false + end + + local taskConfig = XExhibitionConfigs.GetCharacterGrowUpTasks(characterId) + if XTool.IsTableEmpty(taskConfig) then + return false + end + + for taskId, config in pairs(taskConfig) do + local canGetReward = true + for index = 1, #config.ConditionIds do + local ret, _ = XConditionManager.CheckCondition(config.ConditionIds[index], characterId) + if not ret then + canGetReward = false + end + end + if canGetReward and not XExhibitionManager.CheckGrowUpTaskFinish(taskId) then + return true + end + end + end + + function XExhibitionManager.GetCollectionTotalNum(exhibitionType) + if not TotalCharacterNum[exhibitionType] or TotalCharacterNum[exhibitionType] <= 0 then + TotalCharacterNum[exhibitionType] = 0 + local characterExhibitionInfo = XExhibitionConfigs.GetExhibitionPortConfigByType(exhibitionType) + for _, v in pairs(characterExhibitionInfo) do + if v.CharacterId ~= 0 then + TotalCharacterNum[exhibitionType] = TotalCharacterNum[exhibitionType] + 1 + end + end + end + return TotalCharacterNum[exhibitionType] + end + + function XExhibitionManager.GetCollectionRate(IsNotSelf, exhibitionType) + local totalTaskNum = XExhibitionConfigs.GetGrowUpLevelMax() * XExhibitionManager.GetTotalCharacterNum(exhibitionType) + if totalTaskNum == 0 then return 1 end + local curTaskNum = 0 + local tempData = {} + local tempConfigData = XExhibitionConfigs.GetGrowUpTasksConfigByType(exhibitionType) + local tempExhibitionConfigs = XExhibitionConfigs.GetExhibitionLevelPoints() + local info = IsNotSelf and CharacterInfo or SelfGatherRewards + for _, v in pairs(info) do + if tempConfigData[v] then + if tempData[tempConfigData[v].CharacterId] then + if tempExhibitionConfigs[tempConfigData[v].LevelId] then + tempData[tempConfigData[v].CharacterId] = tempData[tempConfigData[v].CharacterId] + + tempExhibitionConfigs[tempConfigData[v].LevelId] + else + tempData[tempConfigData[v].CharacterId] = tempData[tempConfigData[v].CharacterId] + 1 + end + else + if tempExhibitionConfigs[tempConfigData[v].LevelId] then + tempData[tempConfigData[v].CharacterId] = tempExhibitionConfigs[tempConfigData[v].LevelId] + else + tempData[tempConfigData[v].CharacterId] = 1 + end + end + end + end + for _, v in pairs(tempData) do + curTaskNum = curTaskNum + v + end + return curTaskNum / totalTaskNum + end + + function XExhibitionManager.GetTaskFinishNum(IsNotSelf, exhibitionType) + local taskFinishNum = {} + local growUpTasksConfig = XExhibitionConfigs.GetGrowUpTasksConfigByType(exhibitionType) or {} + local info = IsNotSelf and CharacterInfo or SelfGatherRewards + for index = XCharacterConfigs.GrowUpLevel.End, 1, -1 do + taskFinishNum[index] = 0 + for _, v in pairs(info) do + if growUpTasksConfig[v] and growUpTasksConfig[v].LevelId == index then + taskFinishNum[index] = taskFinishNum[index] + 1 + end + end + end + return taskFinishNum + end + + function XExhibitionManager.GetTotalCharacterNum(exhibitionType) + local totalCharacterNum = 0 + local characterExhibitionInfo = XExhibitionConfigs.GetExhibitionPortConfigByType(exhibitionType) or {} + for _, v in pairs(characterExhibitionInfo) do + if v.CharacterId ~= 0 then + totalCharacterNum = totalCharacterNum + 1 + end + end + return totalCharacterNum + end + + function XExhibitionManager.CheckGrowUpTaskFinish(taskId) + return CharacterTaskFinished[taskId] ~= nil + end + + function XExhibitionManager.CheckCharacterGraduation(characterId, IsNotSelf) + local count = 0 + local growUpTasksConfig = XExhibitionConfigs.GetGrowUpTasksConfig() + local info = IsNotSelf and CharacterInfo or SelfGatherRewards + for _, v in pairs(info) do + if growUpTasksConfig[v].CharacterId == characterId then + if growUpTasksConfig[v].LevelId > count then + count = growUpTasksConfig[v].LevelId + end + end + end + return count >= XCharacterConfigs.GrowUpLevel.End + end + --区分是否是查看自己的信息 + function XExhibitionManager.GetCharHeadPortrait(characterId, IsNotSelf) + if characterId == nil or characterId == 0 then + return XExhibitionConfigs.GetDefaultPortraitImagePath() + elseif XExhibitionManager.CheckCharacterGraduation(characterId, IsNotSelf) then + return XExhibitionConfigs.GetCharacterGraduationPortrait(characterId) + else + return XExhibitionConfigs.GetCharacterHeadPortrait(characterId) + end + end + + -- --服务端交互 + -- function XExhibitionManager.RefreshGatherReward(cb) + -- XNetwork.Call(METHOD_NAME.GatherRewardListRequest, nil, + -- function(response) + -- if response.Code ~= XCode.Success then + -- XUiManager.TipCode(response.Code) + -- return + -- end + -- for _, v in pairs(response.GatherRewards) do + -- CharacterTaskFinished[v] = true + -- end + -- if cb then + -- cb() + -- end + -- end) + -- end + function XExhibitionManager.GetGatherReward(characterId, curSelectLevel, cb) + local taskConfig = XExhibitionConfigs.GetCharacterGrowUpTask(characterId, curSelectLevel) + local id = taskConfig.Id + XNetwork.Call(METHOD_NAME.GetGatherReward, { Id = id }, + function(response) + if response.Code ~= XCode.Success then + XUiManager.TipCode(response.Code) + return + end + + XExhibitionManager.GetNewCharacter(id) + XEventManager.DispatchEvent(XEventId.EVENT_CHARACTER_EXHIBITION_REFRESH) + if cb then cb() end + + XUiManager.OpenUiObtain(response.RewardGoods, nil, function() + local levelId = taskConfig.LevelId + local levelName = XExhibitionConfigs.GetExhibitionLevelNameByLevel(levelId) + XLuaUiManager.Open("UiEquipLevelUpTips", CS.XTextManager.GetText("CharacterLiberateSuccess", levelName)) + end) + + --终阶解放自动解放技能 + local growUpLevel = XExhibitionManager.GetCharacterGrowUpLevel(characterId) + if growUpLevel == XCharacterConfigs.GrowUpLevel.End then + XDataCenter.CharacterManager.UnlockMaxLiberationSkill(characterId) + end + end) + end + + return XExhibitionManager +end + +XRpc.NotifyGatherRewardList = function(data) + XDataCenter.ExhibitionManager.HandleExhibitionInfo(data) +end + +XRpc.NotifyGatherReward = function(data) + XDataCenter.ExhibitionManager.GetNewCharacter(data.Id) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XExpeditionManager.lua b/Resources/Scripts/XManager/XExpeditionManager.lua new file mode 100644 index 00000000..cb87650e --- /dev/null +++ b/Resources/Scripts/XManager/XExpeditionManager.lua @@ -0,0 +1,789 @@ +--虚像地平线玩法管理器 +XExpeditionManagerCreator = function() + local ExpeditionConfig = XExpeditionConfig + local RankMap = {} + local ExpeditionManager = {} + local ExpeditionChapterConfigs = {} --虚像地平线章节配置 + local InitialComplete = false + local CheckIfRunMain = false + local EStages = {} + local XTeam = require("XEntity/XExpedition/XExpeditionTeam") + local XComboList = require("XEntity/XExpedition/XExpeditionComboList") + local XStage = require("XEntity/XExpedition/XExpeditionStage") + local XActivity = require("XEntity/XExpedition/XExpeditionActivity") + -- sealed class NotifyExpeditionData + -- int ActivityId; + -- long ResetTime; + -- int ChapterId; + -- Dictionary> Rewards; + -- int CanRefreshTimes; + -- int ExtraRefreshTimes; + -- int BuyRefreshTimes; + -- long RefreshTimesRecoveryTime; + -- int DailyLikeCount; + -- int RefreshTimes; + -- int RecruitLevel; + -- int NpcGroup; + -- List PickedCharacters; + -- List AlternativeCharacters + local ActivityId = 0 --现在的活动ID + local RecruitTime = 0 --现在可用的抽卡次数 + local ResetTime = 0 --本轮章节重置时间 + local NextRecruitAddTime = 0 --下次增加抽卡次数时间 + local BuyRecruitTime = 0 --螺母累计购买抽卡次数 + local ExtraRecruitTime = 0 --额外追加的抽卡次数 + local CurrentChapterId = 0 --现在使用的章节 + local EActivity --活动管理对象 + local RewardsTable -- 获取章节奖励字典 + local DailyLikeCount = 0 --今日点赞次数 + local IsActivityEnd = true + local ChapterInfos = {} + local MyTeam + local ComboList + local IsRegisterEditBattleProxy = false + + local SortByRankFunc = function(a, b) + return a.Rank > b.Rank + end + + ExpeditionManager.StageType = { + [1] = "Story", -- 1 剧情关 + [2] = "Battle", -- 2 战斗关 + [3] = "Infinity", -- 3 无尽关 + } + --===================== + --关卡难度枚举 + --===================== + ExpeditionManager.StageDifficulty = { + Normal = 1, --普通难度 + NightMare = 2, --噩梦难度 + } + --===================== + --关卡难度提示枚举 + --===================== + ExpeditionManager.StageWarning = { + NoWarning = 1, -- 无警告 + Warning = 2, -- 黄色等级差警告 + Danger = 3, -- 红色等级差警告 + } + ExpeditionManager.ComboBtnType = { + BaseComboType = 1, + ChildComboType = 2 + } + + ExpeditionManager.ComboConditionType = { + MemberNum = 1, -- 检查合计数量 + TotalRank = 2, -- 检查合计等级 + TargetMember = 3, -- 检查对应角色等级 + TargetTypeAndRank = 4 -- 检查指定特征的高于指定等级的人 + } + + ExpeditionManager.BuffTipsType = { + GlobalBuff = 1, + StageBuff = 2, + Skill = 3, + } + + local METHOD_NAME = { + RecruitRefresh = "ExpeditionRefreshAlternativeRequest", --刷新招募商店 + RecruitMember = "ExpeditionRecruitRequest", --招募一个队员 + FireMember = "ExpeditionFireRequest", --解雇一个队员 + SendComment = "ExpeditionSendCommentRequest", --发送留言 + GetCommentInfo = "ExpeditionGetCommentInfoRequest", --取得留言列表 + CommentDoLike = "ExpeditionLikeCommentRequest", --点赞 + GetChapterReward = "ExpeditionGetChapterRewardRequest", --获取当前章节通关奖励 + GetRankingData = "ExpeditionRankRequest", --获取排行数据 + GetMyRanking = "ExpeditionRankNumRequest", --获取玩家自身排行数据 + } + --=================== + --客户端启动初始化管理器 + --=================== + function ExpeditionManager.Init() + ExpeditionChapterConfigs = ExpeditionConfig.GetLastestExpeditionConfig() + ExpeditionManager.InitObjects() + XEventManager.AddEventListener(XEventId.EVENT_FUBEN_STAGE_SYNC, ExpeditionManager.OnSyncStageData) + end + --=================== + --客户端启动初始化对象 + --=================== + function ExpeditionManager.InitObjects() + EActivity = XActivity.New() + MyTeam = XTeam.New() + end + + function ExpeditionManager.OnSyncStageData(stageId) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + if stageInfo.Type ~= XDataCenter.FubenManager.StageType.Expedition then return end + end + + function ExpeditionManager.GetChapterReward(difficulty) + if ExpeditionManager.GetIsReceivedReward(difficulty) then + return false + end + XNetwork.Call(METHOD_NAME.GetChapterReward, { Difficulty = difficulty }, function(reply) + if reply.Code ~= XCode.Success then + XUiManager.TipCode(reply.Code) + return + end + if not RewardsTable[CurrentChapterId] then RewardsTable[CurrentChapterId] = {} end + table.insert(RewardsTable[CurrentChapterId], difficulty) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_EXPEDITION_ON_GET_CHAPTER_REWARD, reply.RewardGoodsList) + end) + end + --*******************************待招募成员相关方法***************************** + local RecruitMembers + function ExpeditionManager.InitRecruitInfos() + local RecruitMembersObj = require("XEntity/XExpedition/XExpeditionRecruitMembers") + RecruitMembers = RecruitMembersObj.New(ExpeditionManager:GetRecruitDrawNum()) + end + + function ExpeditionManager.RefreshRecruitInfos(recruitMembers) + RecruitMembers:Reset() + if recruitMembers and #recruitMembers > 0 then + for i = 1, ExpeditionManager:GetRecruitDrawNum() do + RecruitMembers:ResetCharaData(i, recruitMembers[i].ECharacterId) + if recruitMembers[i].IsPicked then + RecruitMembers:SetRecruitPos(i) + end + end + end + CsXGameEventManager.Instance:Notify(XEventId.EVENT_EXPEDITION_RECRUIT_REFRESH, true) + end + --=================== + --招募角色请求 + --@param characterIndex: 要招募的角色在招募列表中的Index + --=================== + function ExpeditionManager.RecruitMember(characterIndex) + local chara = RecruitMembers:GetCharaByPos(characterIndex) + if not chara then return end + if RecruitMembers:GetRecruitPos() == characterIndex then + XUiManager.TipMsg(CS.XTextManager.GetText("ExpeditionCharaRecruited")) + return + end + if RecruitMembers:GetIsPicked() then + XUiManager.TipMsg(CS.XTextManager.GetText("ExpeditionIsPicked")) + return + end + local team = ExpeditionManager.GetTeam() + if (not team:CheckHaveNewPos() and not team:CheckInTeamByEBaseId(chara:GetBaseId())) then + XUiManager.TipMsg(CS.XTextManager.GetText("ExpeditionFullMember")) + return + end + if chara:GetIsMaxLevel() then + XUiManager.TipMsg(CS.XTextManager.GetText("ExpeditionMaxLevel")) + return + end + XNetwork.Call(METHOD_NAME.RecruitMember, { CharacterIndex = characterIndex - 1 }, function(reply) + if reply.Code ~= XCode.Success then + XUiManager.TipCode(reply.Code) + return + end + ExpeditionManager.RecruitPick(characterIndex) + end) + end + + function ExpeditionManager.RecruitPick(index) + RecruitMembers:SetRecruitPos(index) + local addMember = RecruitMembers:GetCharaByPos(index) + MyTeam:AddMemberByEChara(addMember) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_EXPEDITION_RECRUIT_REFRESH, false) + end + + function ExpeditionManager.RefreshRecruit() + XNetwork.Call(METHOD_NAME.RecruitRefresh, nil, function(reply) + if reply.Code ~= XCode.Success then + XUiManager.TipCode(reply.Code) + return + end + ExpeditionManager.RefreshRecruitInfos(reply.AlternativeCharacters) + end) + end + + function ExpeditionManager.SetRecruitInfoHadCommented(eCharId) + --for _, info in pairs(RecruitInfos) do + -- if info.Cfg.Id == eCharId then + -- info.HadCommented = true + -- return + -- end + --end + end + + function ExpeditionManager.GetCanRecruit() + return EActivity and EActivity:GetCanRecruit() + end + + function ExpeditionManager.GetCanBuyDraw() + return EActivity and EActivity:GetCanBuyDraw() + end + --*******************************待招募成员相关方法结束************************** + --*******************************成员队伍相关方法***************************** + function ExpeditionManager.GetCharaDisplayIndex(eBaseId) + return MyTeam:GetCharaDisplayIndexByBaseId(eBaseId) + end + + function ExpeditionManager.GetCharaByEBaseId(eBaseId) + return MyTeam:GetCharaByEBaseId(eBaseId) + end + + function ExpeditionManager.GetECharaByDisplayIndex(index) + return MyTeam:GetECharaByDisplayIndex(index) + end + + function ExpeditionManager.IsMemberActive(baseId) + return MyTeam:CheckInTeamByEBaseId(baseId) + end + + function ExpeditionManager.InitMemberData(members) + MyTeam:Reset() + local memberList = {} + for _, data in pairs(members) do + table.insert(memberList, data.ECharacterId) + end + MyTeam:AddMemberListByECharaIds(memberList) + end + --=================== + --解雇一个角色 + --@param characterId: 要解雇的角色Id + --=================== + function ExpeditionManager.FireMember(eBaseId, eCharacterId) + local tipTitle = CS.XTextManager.GetText("ExpeditionFireConfirmTitle") + local content = CS.XTextManager.GetText("ExpeditionFireConfirmContent") + local confirmCb = function() + XNetwork.Call(METHOD_NAME.FireMember, {ECharacterId = eCharacterId}, function(reply) + if reply.Code ~= XCode.Success then + XUiManager.TipCode(reply.Code) + return + end + MyTeam:RemoveMember(eBaseId) + end) + end + CsXUiManager.Instance:Open("UiDialog", tipTitle, content, XUiManager.DialogType.Normal, nil, confirmCb) + end + + function ExpeditionManager.CheckHaveMember() + return MyTeam and MyTeam:GetTeamNum() > 0 + end + --*******************************成员队伍相关方法结束************************** + --****************************战斗相关方法 开始**************************** + --=================== + --获取出战队伍数据 + --=================== + function ExpeditionManager.GetExpeditionTeam() + local teamInfos = XDataCenter.TeamManager.GetPlayerTeam(CS.XGame.Config:GetInt("TypeIdExpedition")) + for index, baseId in pairs(teamInfos.TeamData) do + if baseId > 0 then + local isActive = ExpeditionManager.IsMemberActive(baseId) + if not isActive then + teamInfos.TeamData[index] = 0 + end + end + end + return teamInfos + end + + function ExpeditionManager.CheckStageIsExpedition(stageId) + local info = XDataCenter.FubenManager.GetStageInfo(stageId) + return info and info.Type == XDataCenter.FubenManager.StageType.Expedition + end + --****************************战斗相关方法 结束**************************** + --****************************Get方法 开始**************************** + function ExpeditionManager.GetCharacterIsInTeam(baseId) + local teamInfos = XDataCenter.TeamManager.GetPlayerTeam(CS.XGame.Config:GetInt("TypeIdExpedition")) + if not teamInfos or not baseId then return false end + for _, v in pairs(teamInfos.TeamData) do + if v == baseId then + return true + end + end + return false + end + --=================== + --获取招募一次刷新数目 + --=================== + function ExpeditionManager.GetRecruitDrawNum() + return EActivity:GetRecruitDrawNum() + end + --=================== + --获取招募刷新次数字符串 + --=================== + function ExpeditionManager.GetRecruitNumInfoString() + return EActivity:GetRecruitTimesStr() + end + --=================== + --获取自然招募次数是否已到最大值 + --=================== + function ExpeditionManager.GetRecruitTimeFull() + return EActivity:GetRecruitTimeFull() + end + --=================== + --获取活动配置简表 + --=================== + function ExpeditionManager.GetActivityChapters() + if ExpeditionManager.GetIsActivityEnd() then return {} end + local chapters = {} + local expeditionConfig = XExpeditionConfig.GetExpeditionConfig() + if expeditionConfig then + for _, v in pairs(expeditionConfig) do + local startTime = XFunctionManager.GetStartTimeByTimeId(v.TimeId) + local endTime = XFunctionManager.GetEndTimeByTimeId(v.TimeId) + local timeNow = XTime.GetServerNowTimestamp() + if timeNow >= startTime and timeNow < endTime then + local tempChapter = {} + tempChapter.Type = XDataCenter.FubenManager.ChapterType.Expedition + tempChapter.Id = v.Id + table.insert(chapters, tempChapter) + end + end + end + return chapters + end + + function ExpeditionManager.GetIsChapterClear(difficulty) + return ExpeditionManager.GetCurrentChapter():GetIsClearByDifficulty(difficulty) + end + --=================== + --获取关卡重置时间字符串 + --=================== + function ExpeditionManager.GetResetTime() + return EActivity:GetResetTime() + end + --=================== + --获取下次招募自然恢复刷新时间 + --=================== + function ExpeditionManager.GetNextRecruitAddTime() + return EActivity:GetNextRecruitAddTime() + end + + function ExpeditionManager.GetEActivity() + return EActivity + end + --================ + --获取当前章节对象 + --================ + function ExpeditionManager.GetCurrentChapter() + return EActivity:GetCurrentChapter() + end + --================ + --根据难度获取当前章节奖励 + --@param difficulty:难度 + --================ + function ExpeditionManager.GetChapterRewardIdByDifficulty(difficulty) + return ExpeditionManager.GetCurrentChapter():GetChapterReward(difficulty) + end + --================ + --获取当前招募等级 + --================ + function ExpeditionManager.GetRecruitLevel() + return EActivity:GetRecruitLevel() + end + --================ + --获取当前招募等级 + --================ + function ExpeditionManager.GetRecruitNum() + return EActivity:GetRecruitNum() + end + + function ExpeditionManager.GetBuyRecruitTimes() + return EActivity:GetBuyRecruitTimes() + end + function ExpeditionManager.GetBuyDrawInfo() + local price = ExpeditionConfig.GetDrawPriceByCount(ExpeditionManager:GetBuyRecruitTimes() + 1) + return price + end + + function ExpeditionManager.GetCurrentChapterGlobalCombos() + return ExpeditionConfig.GetChapterCfgById(CurrentChapterId).ComboIds + end + + function ExpeditionManager.GetStartTime() + if not EActivity then return 0 end + return XFunctionManager.GetStartTimeByTimeId(EActivity:GetTimeId()) or 0 + end + + function ExpeditionManager.GetEndTime() + if not EActivity then return 0 end + return XFunctionManager.GetEndTimeByTimeId(EActivity:GetTimeId()) or 0 + end + + function ExpeditionManager.GetResetTime() + return EActivity and EActivity:GetResetTime() + end + + function ExpeditionManager.GetStageCompleteStr(difficulty) + return ExpeditionManager.GetCurrentChapter():GetStageCompleteStr(difficulty) + end + + function ExpeditionManager.GetStageCompletePercent(difficulty) + return ExpeditionManager.GetCurrentChapter():GetStageCompletePercent(difficulty) + end + + function ExpeditionManager.GetIsReceivedReward(difficulty) + if not RewardsTable then return false end + for chapterId, v in pairs(RewardsTable) do + if chapterId == CurrentChapterId then + for _, diff in pairs(v) do + if diff == difficulty then return true end + end + end + end + return false + end + + function ExpeditionManager.GetIsActivityEnd() + local timeNow = XTime.GetServerNowTimestamp() + local isEnd = timeNow >= ExpeditionManager.GetEndTime() + local isStart = timeNow >= ExpeditionManager.GetStartTime() + local inActivity = (not isEnd) and (isStart) + return IsActivityEnd or not inActivity, timeNow < ExpeditionManager.GetStartTime() + end + + function ExpeditionManager.GetRankStr(rank) + if rank >= 27 then return "MAX" end + return rank + end + + function ExpeditionManager.GetIfBackMain() + return CheckIfRunMain or ExpeditionManager.GetIsActivityEnd() + end + + function ExpeditionManager.SetIfBackMain(ifBackMain) + CheckIfRunMain = ifBackMain + end + --================= + --使用玩法关卡Id获取关卡对象 + --@param eStageId:玩法关卡Id + --================= + function ExpeditionManager.GetEStageByEStageId(eStageId) + return EStages[eStageId] + end + --================= + --使用关卡Id获取关卡对象 + --@param stageId:关卡Id + --================= + function ExpeditionManager.GetEStageByStageId(stageId) + local eStageId = XExpeditionConfig.GetEStageIdByStageId(stageId) + return eStageId and EStages[eStageId] + end + --****************************Get方法 结束**************************** + --****************************FubenManager方法 开始**************************** + --=================== + --初始化关卡信息 + --=================== + function ExpeditionManager.InitStageInfo(checkNewUnlock) + EStages = {} + local eStageList = ExpeditionConfig.GetStageList() + for eStageId, eStageCfg in pairs(eStageList) do + EStages[eStageCfg.Id] = XStage.New(eStageCfg.Id) + end + if EActivity then EActivity:RefreshChapter() end + end + --=================== + --调用结算界面 + --=================== + function ExpeditionManager.ShowReward(winData) + local eStage = ExpeditionManager.GetEStageByStageId(winData.StageId) + if eStage:GetIsInfinity() then + XLuaUiManager.Open("UiExpeditionInfinityWin", winData) + else + XLuaUiManager.Open("UiExpeditionSettleWin", winData) + end + end + --****************************FubenManager方法 结束**************************** + --****************************玩法入口方法 开始**************************** + --=================== + --获取玩法入口红点状况 + --=================== + function ExpeditionManager.CheckRecruitRedPoint() + local isInActivity = not ExpeditionManager.GetIsActivityEnd() + local isOpen = XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.Expedition) + return isInActivity and isOpen and ((EActivity:GetRecruitTimes() + EActivity:GetExtraRecruitTimes()) > 0) + end + --****************************玩法入口方法 结束**************************** + --****************************留言板方法 开始**************************** + local MAX_COMMENT_PAGE = 5 + --=================== + --发送评论 + --=================== + function ExpeditionManager.SendComment(eCharId, content) + if string.IsNilOrEmpty(content) then XUiManager.TipMsg(CS.XTextManager.GetText("ExpeditionNoContentComment")) return end + XNetwork.Call(METHOD_NAME.SendComment, { ECharacterId = eCharId, Content = content }, function(reply) + if reply.Code ~= XCode.Success then + XUiManager.TipCode(reply.Code) + return + end + XEventManager.DispatchEvent(XEventId.EVENT_EXPEDITION_COMMENTS_SEND, reply.CommentId, reply.Content) + end) + end + + function ExpeditionManager.GetComment(baseId, pageNo) + XNetwork.Call(METHOD_NAME.GetCommentInfo, { BaseId = baseId, PageNo = pageNo }, function(reply) + if reply.Code ~= XCode.Success then + XUiManager.TipCode(reply.Code) + return + end + ExpeditionManager.ReceiveComment(reply) + end) + end + + function ExpeditionManager.CommentDoLike(baseId, commentId) + if DailyLikeCount >= EActivity:GetDailyLikeMaxNum() then + XUiManager.TipMsg(CS.XTextManager.GetText("ExpeditionDoLikeOverTime")) + return + end + XNetwork.Call(METHOD_NAME.CommentDoLike, { BaseId = baseId, CommentId = commentId }, function(reply) + if reply.Code ~= XCode.Success then + XUiManager.TipCode(reply.Code) + return + end + DailyLikeCount = DailyLikeCount + 1 + XEventManager.DispatchEvent(XEventId.EVENT_EXPEDITION_COMMENTS_DOLIKE, commentId) + end) + end + + function ExpeditionManager.ReceiveComment(commentData) + XEventManager.DispatchEvent(XEventId.EVENT_EXPEDITION_COMMENTS_RECEIVE, commentData.Comments, commentData.PageNo) + end + --****************************留言板方法 结束**************************** + --****************************功能开放与跳转界面******************************* + function ExpeditionManager.JumpToExpedition() + if XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.Expedition) then + local canGoTo, notStart = ExpeditionManager.CheckCanGoTo() + if canGoTo then + XLuaUiManager.Open("UiExpeditionMain", CurrentChapterId) + elseif notStart then + XUiManager.TipMsg(CS.XTextManager.GetText("ExpeditionActivityNotStart")) + else + XUiManager.TipMsg(CS.XTextManager.GetText("ExpeditionActivityEnd")) + end + end + end + + function ExpeditionManager.CheckCanGoTo() + local isActivityEnd, notStart = ExpeditionManager.GetIsActivityEnd() + return not isActivityEnd, notStart + end + --****************************功能开放与跳转*结束*************************** + --****************************网络协议 开始**************************** + --=================== + --接受服务端推送,初始化数据 + --@服务端推送XRpc.InitExpeditionData + --=================== + function ExpeditionManager.InitData(data) + if EActivity then EActivity:SetActivityId(data.ActivityId) end + if data.ChapterId == 0 then ExpeditionManager.ActivityEnd() return end + ExpeditionManager.SetCurrentChapter(data.ChapterId) + if EActivity then EActivity:RefreshActivity(data) end + ExpeditionManager.InitMemberData(data.PickedCharacters) + ExpeditionManager.InitRecruitInfos() + ExpeditionManager.RefreshRecruitInfos(data.AlternativeCharacters) + ExpeditionManager.SetWave(data.NpcGroup) + ExpeditionManager.RegisterEditBattleProxy() + RewardsTable = data.Rewards or {} + IsActivityEnd = false + if not InitialComplete then InitialComplete = true end + end + + --[[ + ================ + 注册出战界面代理 + ================ + ]] + function ExpeditionManager.RegisterEditBattleProxy() + if IsRegisterEditBattleProxy then return end + IsRegisterEditBattleProxy = true + XUiNewRoomSingleProxy.RegisterProxy(XDataCenter.FubenManager.StageType.Expedition, + require("XUi/XUiExpedition/Battle/XUiExpeditionNewRoomSingle")) + end + + function ExpeditionManager.ActivityEnd() + IsActivityEnd = true + CsXGameEventManager.Instance:Notify(XEventId.EVENT_ACTIVITY_ON_RESET, XDataCenter.FubenManager.StageType.Expedition) + if InitialComplete then + CheckIfRunMain = true + end + end + + function ExpeditionManager.SetCurrentChapter(chapter) + local isNewChapter = CurrentChapterId ~= chapter + if not isNewChapter and CurrentChapterId ~= 0 then return end + CurrentChapterId = chapter > 0 and chapter or 1 + if EActivity then EActivity:SetChapterOrderId(CurrentChapterId) end + CsXGameEventManager.Instance:Notify(XEventId.EVENT_ACTIVITY_ON_RESET, XDataCenter.FubenManager.StageType.Expedition) + if InitialComplete then + CheckIfRunMain = true + end + end + + function ExpeditionManager.UpdateRecruitTimes(data) + if EActivity then EActivity:UpdateRecruitTimes(data, true) end + end + --****************************网络协议 结束**************************** + --**************************** + --二期工程:新对象处理方法 + --**************************** + --================ + --获取队伍对象 + --================ + function ExpeditionManager.GetTeam() + return MyTeam + end + --================ + --获取指定位置的队员 + --@param pos:位置序号 + --================ + function ExpeditionManager.GetTeamCharaByPos(pos) + if not pos then return nil end + local team = ExpeditionManager.GetTeam() + return team and team:GetCharaByDisplayPos(pos) + end + --================ + --获取队伍位置对象 + --================ + function ExpeditionManager.GetTeamPosDisplayList() + return MyTeam:GetTeamPosDisplayList() + end + --================ + --根据位置获取成员对象 + --@param index:展示序号 + --================ + function ExpeditionManager.GetCharaByDisplayIndex(index) + return MyTeam:GetCharaByDisplayPos(index) + end + --================ + --获取队伍平均星级 + --================ + function ExpeditionManager.GetTeamAverageStar() + return MyTeam:GetAverageStar() + end + --================ + --检查成员展示列表中是否含有指定序号的成员 + --@param index:展示序号 + --================ + function ExpeditionManager.CheckCharaIsInDisplayByIndex(index) + return MyTeam:CheckCharaInDisplayListByPos(index) + end + --================ + --根据玩法角色ID获取角色 + --================ + function ExpeditionManager.GetECharaByEBaseId(eBaseId) + return MyTeam:GetCharaByEBaseId(eBaseId) + end + --================ + --获取组合一览列表 + --================ + function ExpeditionManager.GetComboList() + return MyTeam:GetComboList() + end + --================ + --根据组合ID获取组合 + --================ + function ExpeditionManager.GetComboByChildComboId(childComboId) + return ExpeditionManager.GetComboList():GetComboByComboId(childComboId) + end + --================ + --获取招募商店角色 + --================ + function ExpeditionManager.GetRecruitMembers() + return RecruitMembers + end + --================ + --获取无尽关卡通过波数 + --================ + function ExpeditionManager.GetWave() + return EActivity:GetWave() + end + --================ + --设置当前章节无尽关卡波数 + --@param wave:波数 + --================ + function ExpeditionManager.SetWave(wave) + return EActivity:SetWave(wave) + end + --================ + --根据商店位置获取招募商店角色 + --================ + function ExpeditionManager.GetRecruitMemberByPos(pos) + return RecruitMembers:GetCharaByPos(pos) + end + --================ + --根据商店位置获取招募商店角色 + --================ + function ExpeditionManager.GetIsNormalClear() + return ExpeditionManager.GetCurrentChapter():GetIsNormalClear() + end + --================ + --获取自己排行数 + --================ + function ExpeditionManager.GetSelfRank() + return EActivity:GetSelfRank() + end + --================ + --获取自己排行数字符串 + --================ + function ExpeditionManager.GetSelfRankStr() + return EActivity:GetSelfRankStr() + end + --================ + --获取前百排行榜数据 + --================ + function ExpeditionManager.GetRankingList() + return EActivity:GetRankingList() + end + --================ + --获取排位图片 + --================ + function ExpeditionManager.GetRankSpecialIcon(ranking) + return EActivity:GetRankSpecialIcon(ranking) + end + --================ + --获取排位信息 + --================ + function ExpeditionManager.GetRankingData() + XNetwork.Call(METHOD_NAME.GetRankingData, nil, function(reply) + if reply.Code ~= XCode.Success then + XUiManager.TipCode(reply.Code) + return + end + if EActivity then EActivity:UpdateRankingData(reply) end + CsXGameEventManager.Instance:Notify(XEventId.EVENT_EXPEDITION_RANKING_REFRESH) + end) + end + --================ + --获取玩家自身排位信息 + --================ + function ExpeditionManager.GetMyRankingData() + XNetwork.Call(METHOD_NAME.GetMyRanking, nil, function(reply) + if reply.Code ~= XCode.Success then + XUiManager.TipCode(reply.Code) + return + end + if EActivity then EActivity:UpdateMyRankingData(reply) end + CsXGameEventManager.Instance:Notify(XEventId.EVENT_EXPEDITION_RANKING_REFRESH) + end) + end + + --用于活动简介界面的红点检测 + function ExpeditionManager.CheckActivityRedPoint() + --返回true就是有未用的刷新次数 false就是没有刷新次数 + local canRecruit = ExpeditionManager.GetCanRecruit() + -- 返回true就是全部关卡通过了 + local isAllPass = ExpeditionManager.GetIsChapterClear(ExpeditionManager.StageDifficulty.NightMare) + + return canRecruit and not isAllPass + end + + ExpeditionManager.Init() + return ExpeditionManager +end +--================ +--刷新玩法信息 +--================ +XRpc.NotifyExpeditionData = function(data) + XDataCenter.ExpeditionManager.InitData(data) +end +--================ +--刷新招募相关信息 +--================ +XRpc.NotifyExpeditionRefreshTimes = function(data) + XDataCenter.ExpeditionManager.UpdateRecruitTimes(data) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XFashionManager.lua b/Resources/Scripts/XManager/XFashionManager.lua new file mode 100644 index 00000000..3b253fc2 --- /dev/null +++ b/Resources/Scripts/XManager/XFashionManager.lua @@ -0,0 +1,732 @@ +local pairs = pairs +local table = table +local tableInsert = table.insert +local tableSort = table.sort + +XFashionManagerCreator = function() + local XFashionManager = {} + + XFashionManager.FashionStatus = { + -- 未拥有 + UnOwned = 0, + -- 未解锁 + Lock = 1, + -- 已解锁 + UnLock = 2, + -- 已穿戴 + Dressed = 3 + } + + local TABLE_FASHION_PATH = "Share/Fashion/Fashion.tab" + -- local TABLE_FASHION_QUALITY_PATH = "Share/Fashion/FashionQuality.tab" + local METHOD_NAME = { + Use = "FashionUseRequest", + Unlock = "FashionUnLockRequest", + } + + local FashionTemplates = {} -- 时装配置 + -- local FashionQuality = {} -- 时装品质相关信息 + local OwnFashionStatus = {} -- 已拥有的时装 + local CharFashions = {} -- 角色对应时装列表 + local ResToFashionTab = {} -- 资源Id对应时装表 + + --==============================-- + --desc: 获取时装配置 + --@id: 时装Id + --@return: 时装配置 + --==============================-- + function XFashionManager.GetFashionTemplate(id) + local tab = FashionTemplates[id] + if tab == nil then + XLog.ErrorTableDataNotFound("XFashionManager.GetFashionTemplate", "tab", TABLE_FASHION_PATH, "id", tostring(id)) + end + return tab + end + + --==============================-- + --desc: 获取整个时装配置 + --@return: 时装配置 + --==============================-- + function XFashionManager.GetAllFashionTemplate() + return XTool.Clone(FashionTemplates) + end + + --==============================-- + --desc: 获取在显示时间内的整个时装配置 + --@return: 时装配置 + --==============================-- + function XFashionManager.GetAllFashionTemplateInTime() + local allFashionTemplates = XTool.Clone(FashionTemplates) + local fashionTemplateDic = {} + local timeStamp = XTime.GetServerNowTimestamp() + for _, fashionTemplate in pairs(allFashionTemplates) do + local showTimeStr = fashionTemplate.ShowTimeStr + if showTimeStr then + if (timeStamp >= XTime.ParseToTimestamp(showTimeStr)) then + fashionTemplateDic[fashionTemplate.Id] = fashionTemplate + end + else + fashionTemplateDic[fashionTemplate.Id] = fashionTemplate + end + end + + return fashionTemplateDic + end + + --==============================-- + --desc: 获取拥有时装配置 + --@return: 已拥有时装 + --==============================-- + function XFashionManager.GetOwnFashionStatus() + return XTool.Clone(OwnFashionStatus) + end + + --==============================-- + --desc: 是否拥有时装 + --@id: 时装id + --@return 拥有为true,否则false + --==============================-- + -- local function CheckOwnFashion(id) + -- return OwnFashionStatus[id] ~= nil + -- end + --==============================-- + --desc: 时装是否已穿戴 + --@id: 时装id + --@return 穿戴为true,否则false + --==============================-- + local function IsFashionDressed(id) + local template = XFashionManager.GetFashionTemplate(id) + + if not template then + return false + end + + local char = XDataCenter.CharacterManager.GetCharacter(template.CharacterId) + if not char then + return false + end + + return char.FashionId == id + end + + --==============================-- + --desc: 获取时装状态 + --@id: 时装id + --@return 状态 + --==============================-- + function XFashionManager.GetFashionStatus(id) + local status = OwnFashionStatus[id] + + if status == nil then + return XFashionManager.FashionStatus.UnOwned + end + + if IsFashionDressed(id) then + return XFashionManager.FashionStatus.Dressed + end + + return status and XFashionManager.FashionStatus.Lock or XFashionManager.FashionStatus.UnLock + end + + function XFashionManager.Init() + FashionTemplates = XTableManager.ReadByIntKey(TABLE_FASHION_PATH, XTable.XTableFashion, "Id") + -- FashionQuality = XTableManager.ReadByIntKey(TABLE_FASHION_QUALITY_PATH, XTable.XTableFashionQuality, "Id") + for id, template in pairs(FashionTemplates) do + local list = CharFashions[template.CharacterId] + if not list then + list = {} + end + + tableInsert(list, id) + CharFashions[template.CharacterId] = list + --初始化资源ID对应时装Id + ResToFashionTab[template.ResourcesId] = id + end + end + + function XFashionManager.InitFashions(fashions) + local fashionDic = {} + for _, data in ipairs(fashions) do + fashionDic[data.Id] = data.IsLock + end + + OwnFashionStatus = fashionDic + end + + --==============================-- + --desc: 检查角色是否有时装 + --@id: 时装Id + --@return: 是否有时装 + --==============================-- + function XFashionManager.CheckHasFashion(id) + return OwnFashionStatus[id] ~= nil + end + + --==============================-- + --desc: 服务器获得时装推送 + --protoData:时装数据 + --==============================-- + function XFashionManager.NotifyFashionDict(data) + local fashions = data.FashionList + if not fashions then + return + end + + for _, tmpData in ipairs(fashions) do + OwnFashionStatus[tmpData.Id] = tmpData.IsLock + end + end + + --==============================-- + --desc: 获取时装图标 + --@fashionId: 时装id + --@return 时装对应的人物角色小图像图标 + --==============================-- + function XFashionManager.GetFashionSmallHeadIcon(fashionId) + local tab = FashionTemplates[fashionId] + if tab == nil then + XLog.ErrorTableDataNotFound("XFashionManager.GetFashionSmallHeadIcon", "tab", TABLE_FASHION_PATH, "fashionId", tostring(fashionId)) + return + end + return tab.SmallHeadIcon + end + + --==============================-- + --desc: 获取时装图标 + --@fashionId: 时装id + --@return 时装对应的人物角色小图像图标【三阶解放版】 + --==============================-- + function XFashionManager.GetFashionSmallHeadIconLiberation(fashionId) + local tab = FashionTemplates[fashionId] + if tab == nil then + XLog.ErrorTableDataNotFound("XFashionManager.GetFashionSmallHeadIconLiberation", + "tab", TABLE_FASHION_PATH, "fashionId", tostring(fashionId)) + return + end + return tab.SmallHeadIconLiberation + end + + --==============================-- + --desc: 获取时装图标 + --@fashionId: 时装id + --@return 时装对应的人物角色大图像图标 + --==============================-- + function XFashionManager.GetFashionBigHeadIcon(fashionId) + local tab = FashionTemplates[fashionId] + if tab == nil then + XLog.ErrorTableDataNotFound("XFashionManager.GetFashionBigHeadIcon", "tab", TABLE_FASHION_PATH, "fashionId", tostring(fashionId)) + return + end + return tab.BigHeadIcon + end + + --==============================-- + --desc: 获取时装图标 + --@fashionId: 时装id + --@return 时装对应的人物角色大图像图标 + --==============================-- + function XFashionManager.GetFashionBigHeadIconLiberation(fashionId) + local tab = FashionTemplates[fashionId] + if tab == nil then + XLog.ErrorTableDataNotFound("XFashionManager.GetFashionBigHeadIconLiberation", + "tab", TABLE_FASHION_PATH, "fashionId", tostring(fashionId)) + return + end + return tab.BigHeadIconLiberation + end + + --==============================-- + --desc: 获取时装图标 + --@fashionId: 时装id + --@return 时装对应的人物角色小圆形图像图标 + --==============================-- + function XFashionManager.GetFashionRoundnessHeadIcon(fashionId) + local tab = FashionTemplates[fashionId] + if tab == nil then + XLog.ErrorTableDataNotFound("XFashionManager.GetFashionRoundnessHeadIcon", "tab", TABLE_FASHION_PATH, "fashionId", tostring(fashionId)) + return + end + return tab.RoundnessHeadIcon + end + + --==============================-- + --desc: 获取时装图标 + --@fashionId: 时装id + --@return 时装对应的人物角色大圆形图像图标 + --==============================-- + function XFashionManager.GetFashionBigRoundnessHeadIcon(fashionId) + local tab = FashionTemplates[fashionId] + if tab == nil then + XLog.ErrorTableDataNotFound("XFashionManager.GetFashionBigRoundnessHeadIcon", "tab", TABLE_FASHION_PATH, "fashionId", tostring(fashionId)) + return + end + return tab.BigRoundnessHeadIcon + end + + --==============================-- + --desc: 获取时装图标 + --@fashionId: 时装id + --@return 时装对应的人物角色圆形图像图标(非物品使用) + --==============================-- + function XFashionManager.GetFashionRoundnessNotItemHeadIcon(fashionId) + local tab = FashionTemplates[fashionId] + if tab == nil then + XLog.ErrorTableDataNotFound("XFashionManager.GetFashionRoundnessNotItemHeadIcon", + "tab", TABLE_FASHION_PATH, "fashionId", tostring(fashionId)) + return + end + return tab.RoundnessNotItemHeadIcon + end + + --==============================-- + --desc: 获取时装图标 + --@fashionId: 时装id + --@return 时装对应的人物角色圆形图像图标(非物品使用)【三阶解放版】 + --==============================-- + function XFashionManager.GetFashionRoundnessNotItemHeadIconLiberation(fashionId) + local tab = FashionTemplates[fashionId] + if tab == nil then + XLog.ErrorTableDataNotFound("XFashionManager.GetFashionRoundnessNotItemHeadIconLiberation", + "tab", TABLE_FASHION_PATH, "fashionId", tostring(fashionId)) + return + end + return tab.RoundnessNotItemHeadIconLiberation + end + + --==============================-- + --desc: 获取时装图标 + --@fashionId: 时装id + --@return 时装对应的人物角色半身像(剧情用) + --==============================-- + function XFashionManager.GetFashionHalfBodyImage(fashionId) + local tab = FashionTemplates[fashionId] + if tab == nil then + XLog.ErrorTableDataNotFound("XFashionManager.GetFashionHalfBodyImage", "tab", TABLE_FASHION_PATH, "fashionId", tostring(fashionId)) + return + end + return tab.HalfBodyImage + end + + --==============================-- + --desc: 获取时装图标 + --@fashionId: 时装id + --@return 时装对应的人物角色半身像(通用) + --==============================-- + function XFashionManager.GetRoleCharacterBigImage(fashionId) + local tab = FashionTemplates[fashionId] + if tab == nil then + XLog.ErrorTableDataNotFound("XFashionManager.GetRoleCharacterBigImage", "tab", TABLE_FASHION_PATH, "fashionId", tostring(fashionId)) + return + end + return tab.RoleCharacterBigImage + end + + --==============================-- + --desc: 获取时装图标 + --@id: 时装id + --@return 时装图标 + --==============================-- + function XFashionManager.GetFashionIcon(id) + local tab = FashionTemplates[id] + if tab == nil then + XLog.ErrorTableDataNotFound("XFashionManager.GetFashionIcon", "tab", TABLE_FASHION_PATH, "id", tostring(id)) + end + return tab.Icon + end + + --==============================-- + --desc: 根据ResourcesId获取FashionId + --@id: 资源id + --@return FashionId + --==============================-- + function XFashionManager.GetFashionIdByResId(resId) + local id = ResToFashionTab[resId] + if id == nil then + XLog.ErrorTableDataNotFound("XFashionManager.GetFashionIdByResId", "时装Id", TABLE_FASHION_PATH, "ResourceId", tostring(resId)) + end + return id + end + --==============================-- + --desc: 获取ResourcesId + --@id: 时装id + --@return ResourcesId + --==============================-- + function XFashionManager.GetResourcesId(id) + local tab = FashionTemplates[id] + if tab == nil then + XLog.ErrorTableDataNotFound("XFashionManager.GetResourcesId", "tab", TABLE_FASHION_PATH, "id", tostring(id)) + end + return tab.ResourcesId + end + --==============================-- + --desc: 获取CharacterId + --@id: 时装id + --@return CharacterId + --==============================-- + function XFashionManager.GetCharacterId(id) + local tab = FashionTemplates[id] + if tab == nil then + XLog.ErrorTableDataNotFound("XFashionManager.GetCharacterId", "tab", TABLE_FASHION_PATH, "id", tostring(id)) + end + return tab.CharacterId + end + --==============================-- + --desc: 获取时装大图标 + --@id: 时装id + --@return 时装大图标 + --==============================-- + function XFashionManager.GetFashionBigIcon(id) + local tab = FashionTemplates[id] + if tab == nil then + XLog.ErrorTableDataNotFound("XFashionManager.GetFashionBigIcon", "tab", TABLE_FASHION_PATH, "id", tostring(id)) + end + return tab.BigIcon + end + --==============================-- + --desc: 获取时装立绘图标 + --@id: 时装id + --@return 时装图标 + --==============================-- + function XFashionManager.GetFashionCharacterIcon(id) + local tab = FashionTemplates[id] + if tab == nil then + XLog.ErrorTableDataNotFound("XFashionManager.CharacterIcon", "tab", TABLE_FASHION_PATH, "id", tostring(id)) + end + return tab.CharacterIcon + end + --==============================-- + --desc: 拿取时装名字 + --@id: 时装Id + --@return: 时装名字 + --==============================-- + function XFashionManager.GetFashionName(id) + local tab = FashionTemplates[id] + if tab == nil then + XLog.ErrorTableDataNotFound("XFashionManager.GetFashionName", "tab", TABLE_FASHION_PATH, "id", tostring(id)) + end + return tab.Name + end + + --==============================-- + --desc: 拿取时装品质 + --@id: 时装Id + --@return: 时装品质 + --==============================-- + function XFashionManager.GetFashionQuality(id) + local tab = FashionTemplates[id] + if tab == nil then + XLog.ErrorTableDataNotFound("XFashionManager.GetFashionQuality", "tab", TABLE_FASHION_PATH, "id", tostring(id)) + end + return tab.Quality + end + + --==============================-- + --desc: 拿取时装系列 + --@id: 时装Id + --@return: 时装系列Id + --==============================-- + function XFashionManager.GetFashionSeries(id) + local tab = FashionTemplates[id] + if tab == nil then + XLog.ErrorTableDataNotFound("XFashionManager.GetFashionSeries", "tab", TABLE_FASHION_PATH, "id", tostring(id)) + end + return tab.Series + end + + --==============================-- + --desc: 拿取时装简介1 + --@id: 时装Id + --@return: 时装简介 + --==============================-- + function XFashionManager.GetFashionDesc(id) + local tab = FashionTemplates[id] + if tab == nil then + XLog.ErrorTableDataNotFound("XFashionManager.GetFashionDesc", "tab", TABLE_FASHION_PATH, "id", tostring(id)) + end + return tab.Description + end + + --==============================-- + --desc: 拿取时装简介2 + --@id: 时装Id + --@return: 时装简介 + --==============================-- + function XFashionManager.GetFashionWorldDescription(id) + local tab = FashionTemplates[id] + if tab == nil then + XLog.ErrorTableDataNotFound("XFashionManager.GetFashionWorldDescription", "tab", TABLE_FASHION_PATH, "id", tostring(id)) + end + return tab.WorldDescription + end + + + --==============================-- + --desc: 拿取时装跳转列表 + --@id: 时装Id + --@return: 时装列表 + --==============================-- + function XFashionManager.GetFashionSkipIdParams(id) + local tab = FashionTemplates[id] + if tab == nil then + XLog.ErrorTableDataNotFound("XFashionManager.GetFashionSkipIdParams", "tab", TABLE_FASHION_PATH, "id", tostring(id)) + end + return tab.SkipIdParams + end + + + local SortStatusPriority = { + [XFashionManager.FashionStatus.UnOwned] = 1, + [XFashionManager.FashionStatus.UnLock] = 2, + [XFashionManager.FashionStatus.Lock] = 3, + [XFashionManager.FashionStatus.Dressed] = 4 + } + + --==============================-- + --desc: 通过角色ID获取角色所有时装信息 + --@charId: 角色ID + --@return: 时装List + --==============================-- + function XFashionManager.GetFashionByCharId(charId) + local fashions = CharFashions[charId] + if not fashions then + XLog.Error("XFashionManager.GetFashionByCharId 错误: 无法根据参数charId " .. charId .. "获取" .. TABLE_FASHION_PATH .. "表中的时装信息, 检查charId获取这配置表") + return + end + + local fashionIdList = {} + for _, id in pairs(fashions) do + tableInsert(fashionIdList, id) + end + + tableSort(fashionIdList, function(a, b) + local status1, status2 = XFashionManager.GetFashionStatus(a), XFashionManager.GetFashionStatus(b) + + if status1 ~= status2 then + return SortStatusPriority[status1] > SortStatusPriority[status2] + end + + return XFashionManager.GetFashionPriority(a) > XFashionManager.GetFashionPriority(b) + end) + + return fashionIdList + end + + --==============================-- + --desc: 通过角色ID获取角色当前时间可以显示的所有时装信息 + --@charId: 角色ID + --@return: 时装List + --==============================-- + function XFashionManager.GetCurrentTimeFashionByCharId(charId) + local fashions = CharFashions[charId] + if not fashions then + XLog.Error("XFashionManager.GetFashionByCharId 错误: 无法根据参数charId " .. charId .. "获取" .. TABLE_FASHION_PATH .. "表中的时装信息, 检查charId获取这配置表") + return + end + + local fashionIdList = {} + local timeStamp = XTime.GetServerNowTimestamp() + for _, id in pairs(fashions) do + local fashionTemplate = XFashionManager.GetFashionTemplate(id) + if fashionTemplate then + local showTimeStr = fashionTemplate.ShowTimeStr + if showTimeStr then + local showTimeStamp = XTime.ParseToTimestamp(showTimeStr) + if (timeStamp >= showTimeStamp) then + tableInsert(fashionIdList, id) + end + else + tableInsert(fashionIdList, id) + end + end + end + + if #fashionIdList > 0 then + tableSort(fashionIdList, function(a, b) + local status1, status2 = XFashionManager.GetFashionStatus(a), XFashionManager.GetFashionStatus(b) + + if status1 ~= status2 then + return SortStatusPriority[status1] > SortStatusPriority[status2] + end + + return XFashionManager.GetFashionPriority(a) > XFashionManager.GetFashionPriority(b) + end) + end + + return fashionIdList + end + + --==============================-- + --desc: 通过角色ID获取角色当前使用时装信息 + --@charId: 角色ID + --@return: 当前使用的时装信息 + --==============================-- + function XFashionManager.GetFashionResourceIdByCharId(charId) + local char = XDataCenter.CharacterManager.GetCharacter(charId) + local fashionId = char and char.FashionId or XDataCenter.CharacterManager.GetShowFashionId(charId) + local template = XFashionManager.GetFashionTemplate(fashionId) + if template then + return template.ResourcesId + end + end + + --==============================-- + --desc: 通过角色ID获取角色当前使用时装ID + --@charId: 角色ID + --@return: 当前使用的时装信息 + --==============================-- + function XFashionManager.GetFashionIdByCharId(charId) + local char = XDataCenter.CharacterManager.GetCharacter(charId) + local fashionId = char and char.FashionId or XDataCenter.CharacterManager.GetShowFashionId(charId) + local template = XFashionManager.GetFashionTemplate(fashionId) + if template then + return template.Id + end + end + + --==============================-- + --desc: 通过XFightNpcData返回资源 + --@fightNpcData: 角色数据 + --@return: 角色模型名称 + --==============================-- + function XFashionManager.GetCharacterModelName(fightNpcData) + if not fightNpcData then + XLog.Error("XFashionManager.GetCharacterModelName 错误: 参数fightNpcData不能为空") + return + end + + local fashionId = fightNpcData.Character.FashionId + if fashionId <= 0 then + local charId = fightNpcData.Character.Id + fashionId = XCharacterConfigs.GetCharacterTemplate(charId).DefaultNpcFashtionId + end + local resId = XFashionManager.GetFashionTemplate(fashionId).ResourcesId + + return XDataCenter.CharacterManager.GetCharResModel(resId) + end + + --==============================-- + --desc: 通过fashionId拿取头像信息 + --@fightNpcData: fashionId + --@return: 头像Icon + --==============================-- + function XFashionManager.GetCharacterModelIcon(fashionId, charId) + if not fashionId then + XLog.Error("XFashionManager.GetCharacterModelIcon 错误: 参数fashionId不能为空") + return + end + + if fashionId <= 0 then + fashionId = XCharacterConfigs.GetCharacterTemplate(charId).DefaultNpcFashtionId + end + + local resId = XFashionManager.GetFashionTemplate(fashionId).ResourcesId + return XDataCenter.CharacterManager.GetCharResIcon(resId) + end + + --==============================-- + --desc: 获取时装显示优先级 + --@templateId: 时装配置表id + --@return 显示优先级 + --==============================-- + function XFashionManager.GetFashionPriority(templateId) + local tab = FashionTemplates[templateId] + if tab == nil then + XLog.ErrorTableDataNotFound("XFashionManager.GetFashionPriority", "tab", TABLE_FASHION_PATH, "templateId", tostring(templateId)) + end + return tab.Priority + end + + --==============================-- + --desc: 获取时装对应场景路径 + --@templateId: 时装配置表id + --@return 场景路径SceneUrl + --==============================-- + function XFashionManager.GetFashionSceneUrl(templateId) + local tab = FashionTemplates[templateId] + if tab == nil then + XLog.ErrorTableDataNotFound("XFashionManager.GetFashionSceneUrl", "tab", TABLE_FASHION_PATH, "templateId", tostring(templateId)) + return + end + + if not tab.SceneModelId or tab.SceneModelId == 0 then + return + end + + local sceneUrl, _ = XSceneModelConfigs.GetSceneAndModelPathById(tab.SceneModelId) + if not sceneUrl then + return + end + + return sceneUrl + end + + --==============================-- + --desc: 获取时装对应解放特效配置 + --@templateId: 时装配置表id + --@return EffectRootName, EffectPath + --==============================-- + function XFashionManager.GetFashionLiberationEffectRootAndPath(templateId) + local tab = FashionTemplates[templateId] + if tab == nil then + XLog.ErrorTableDataNotFound("XFashionManager.GetFashionLiberationEffectRootAndPath", "tab", TABLE_FASHION_PATH, "templateId", tostring(templateId)) + end + + local rootName, fxPath = tab.EffectRootName, tab.EffectPath + if not rootName or not fxPath then + XLog.ErrorTableDataNotFound("XFashionManager.GetFashionLiberationEffectRootAndPath", "EffectRootName/EffectPath", TABLE_FASHION_PATH, "templateId", tostring(templateId)) + end + + return rootName, fxPath + end + + -- service config begin -- + function XFashionManager.UseFashion(id, cb, errorCb, skipJudge) + if not skipJudge then + local temp = XFashionManager.GetFashionTemplate(id) + if temp and not XDataCenter.CharacterManager.IsOwnCharacter(temp.CharacterId) then + XUiManager.TipText("CharacterLock") + return + end + end + + XNetwork.Call(METHOD_NAME.Use, { FashionId = id }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + if errorCb then + errorCb() + end + return + end + + if cb then cb() end + end) + end + + function XFashionManager.UnlockFashion(id, cb) + local status = XFashionManager.GetFashionStatus(id) + if status == XFashionManager.FashionStatus.UnOwned then + XUiManager.TipCode(XCode.FashionIsUnOwned) + return + end + + if status ~= XFashionManager.FashionStatus.Lock then + XUiManager.TipCode(XCode.FashionIsUnLock) + return + end + + XNetwork.Call(METHOD_NAME.Unlock, { FashionId = id }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + end + + if cb then cb() end + end) + end + -- service config end -- + XFashionManager.Init() + return XFashionManager +end + +XRpc.FashionSyncNotify = function(data) + XDataCenter.FashionManager.NotifyFashionDict(data) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XFashionStoryManager.lua b/Resources/Scripts/XManager/XFashionStoryManager.lua new file mode 100644 index 00000000..a7afc115 --- /dev/null +++ b/Resources/Scripts/XManager/XFashionStoryManager.lua @@ -0,0 +1,223 @@ +XFashionStoryManagerCreator = function() + local XFashionStoryManager = {} + local PassedStage = {} + + + -------------------------------------------------------副本相关------------------------------------------------------ + + function XFashionStoryManager.InitStageInfo() + local allFashionStoryId = XFashionStoryConfigs.GetAllFashionStoryId() + for _, chapterId in pairs(allFashionStoryId) do + local stageIdList = XFashionStoryConfigs.GetAllStageId(chapterId) + for i, stageId in ipairs(stageIdList) do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + stageInfo.Type = XDataCenter.FubenManager.StageType.FashionStory + stageInfo.OrderId = i + end + end + XFashionStoryManager.RefreshStageInfo() + end + + function XFashionStoryManager.ShowReward(winData) + if not winData then + return + end + XFashionStoryManager.RefreshStagePassedBySettleData(winData.SettleData) + + XLuaUiManager.Open("UiSettleWin", winData) + end + -------------------------------------------------------------------------------------------------------------------- + + + --- + --- 获取'id'系列涂装剧情活动的开始时间戳与结束时间戳 + ---@return number 开始时间戳|结束时间戳 + function XFashionStoryManager.GetActivityTime(id) + local timeId = XFashionStoryConfigs.GetActivityTimeId(id) + return XFunctionManager.GetTimeByTimeId(timeId) + end + + --- + --- 获取系列涂装剧情活动 + function XFashionStoryManager.GetActivityChapters(noNeedInTime) + local chapter = {} + local allFashionStoryId = XFashionStoryConfigs.GetAllFashionStoryId() + for _, id in pairs(allFashionStoryId) do + if noNeedInTime or XFashionStoryManager.IsActivityInTime(id) then + table.insert(chapter, { + Id = id, + Type = XDataCenter.FubenManager.ChapterType.FashionStory, + Name = XFashionStoryConfigs.GetName(id), + Icon = XFashionStoryConfigs.GetActivityBannerIcon(id) + }) + end + end + return chapter + end + + --- + --- 获取'id'活动中处于开放时间的试玩关 + function XFashionStoryManager.GetActiveTrialStage(id) + local result = {} + local trialStageList = XFashionStoryConfigs.GetTrialStagesList(id) + if trialStageList then + for _, trialStage in ipairs(trialStageList) do + if XFashionStoryManager.IsTrialStageInTime(trialStage) then + table.insert(result, trialStage) + end + end + end + return result + end + + --- + --- 获取活动的类型 + function XFashionStoryManager.GetType(id) + local chapterStageList = XFashionStoryConfigs.GetChapterStagesList(id) + local trialStageList = XFashionStoryConfigs.GetTrialStagesList(id) + if XTool.IsTableEmpty(chapterStageList) then + return XFashionStoryConfigs.Type.OnlyTrial + elseif XTool.IsTableEmpty(trialStageList) then + return XFashionStoryConfigs.Type.OnlyChapter + else + return XFashionStoryConfigs.Type.Both + end + end + + --- + --- 获取活动章节关的关卡进度 + function XFashionStoryManager.GetChapterProgress(id) + local stageIdList = XFashionStoryConfigs.GetChapterStagesList(id) + local passNum = 0 + local totalNum = #stageIdList + + for _, stageId in ipairs(stageIdList) do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + if stageInfo.Passed then + passNum = passNum + 1 + end + end + return passNum, totalNum + end + + --- + --- 获取活动的剩余时间戳 + function XFashionStoryManager.GetLeftTimeStamp(id) + local _, endTime = XFashionStoryManager.GetActivityTime(id) + return endTime > 0 and endTime - XTime.GetServerNowTimestamp() or 0 + end + + --- + --- 获取试玩关关卡剩余时间戳 + function XFashionStoryManager.GetTrialStageLeftTimeStamp(stageId) + local timeId = XFashionStoryConfigs.GetStageTimeId(stageId) + local endTime = XFunctionManager.GetEndTimeByTimeId(timeId) + return endTime > 0 and endTime - XTime.GetServerNowTimestamp() or 0 + end + + --- + --- 获取剧情关入口的剩余时间戳 + function XFashionStoryManager.GetStoryTimeStamp(id) + local timeId = XFashionStoryConfigs.GetStoryTimeId(id) + local endTime = XFunctionManager.GetEndTimeByTimeId(timeId) + return endTime > 0 and endTime - XTime.GetServerNowTimestamp() or 0 + end + + --- + --- 判断试玩关关卡是否处于开放时间,无时间配置默认不开放 + function XFashionStoryManager.IsTrialStageInTime(stageId) + local stageTimeId = XFashionStoryConfigs.GetStageTimeId(stageId) + return XFunctionManager.CheckInTimeByTimeId(stageTimeId, false) + end + + --- + --- 打开活动主界面 + function XFashionStoryManager.OpenFashionStoryMain(activityId) + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.FashionStory) then + return + end + if XFashionStoryManager.IsActivityInTime(activityId) then + XLuaUiManager.Open("UiFubenFashionStory", activityId) + else + XUiManager.TipMsg(CSXTextManagerGetText("FashionStoryActivityEnd")) + end + end + + --- + --- 'activityId'是否处于开启时间 + function XFashionStoryManager.IsActivityInTime(activityId) + local timeId = XFashionStoryConfigs.GetActivityTimeId(activityId) + return XFunctionManager.CheckInTimeByTimeId(timeId, false) + end + + --- + --- 剧情模式入口是否处于开启时间 + function XFashionStoryManager.IsStoryInTime(activityId) + local timeId = XFashionStoryConfigs.GetStoryTimeId(activityId) + return XFunctionManager.CheckInTimeByTimeId(timeId, false) + end + + --- + --- 刷新关卡通关信息 + function XFashionStoryManager.RefreshStagePassedBySettleData(settleData) + if not settleData then + return + end + PassedStage[settleData.StageId] = true + XFashionStoryManager.RefreshStageInfo() + end + + --- + --- 刷新StageInfo数据 + function XFashionStoryManager.RefreshStageInfo() + local allFashionStoryId = XFashionStoryConfigs.GetAllFashionStoryId() + for _, chapterId in pairs(allFashionStoryId) do + local allStageId = XFashionStoryConfigs.GetAllStageId(chapterId) + for _, stageId in pairs(allStageId) do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + if stageInfo then + stageInfo.Passed = PassedStage[stageId] or false + stageInfo.Unlock = true + stageInfo.IsOpen = true + if stageCfg.RequireLevel > 0 and XPlayer.Level < stageCfg.RequireLevel then + stageInfo.Unlock = false + stageInfo.IsOpen = false + end + for _, preStageId in pairs(stageCfg.PreStageId or {}) do + if preStageId > 0 then + if not PassedStage[preStageId] then + stageInfo.Unlock = false + stageInfo.IsOpen = false + break + end + end + end + end + end + end + end + + + ----------------------------------------------同步服务器推送数据-------------------------------------------------------- + + --- + --- 同步关卡通关数据 + function XFashionStoryManager.SyncStageData(stageData) + if not stageData then + return + end + for _, stageId in pairs(stageData or {}) do + PassedStage[stageId] = true + end + XFashionStoryManager.RefreshStageInfo(stageData) + end + -------------------------------------------------------------------------------------------------------------------- + + + return XFashionStoryManager +end + +XRpc.NotifyFashionStoryData = function(data) + XDataCenter.FashionStoryManager.SyncStageData(data.FinishStageList) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XFavorabilityManager.lua b/Resources/Scripts/XManager/XFavorabilityManager.lua new file mode 100644 index 00000000..5da8d54b --- /dev/null +++ b/Resources/Scripts/XManager/XFavorabilityManager.lua @@ -0,0 +1,734 @@ +XFavorabilityManagerCreator = function() + local XFavorabilityManager = {} + local ClientConfig = CS.XGame.ClientConfig + + local CharacterFavorabilityDatas = {} + + local UnlockRewardFunc = {} + + local GivenItemCharacterIdList = {} + + -- 播放语音结束进行回调时,是否调用StopCvContent,语音正常播放结束时调用,查看动作打断语音时不调用 + local DontStopCvContent + + -- [战斗参数达到target, 后端还不能正确计算出战斗参数,暂时返回false] + UnlockRewardFunc[XFavorabilityConfigs.RewardUnlockType.FightAbility] = function() + -- local characterData = XDataCenter.CharacterManager.GetCharacter(characterId) + -- local curCharacterAbility = characterData.Ability or 0 + return false + -- return math.ceil(curCharacterAbility) >= target + end + -- [信赖度达到target] + UnlockRewardFunc[XFavorabilityConfigs.RewardUnlockType.TrustLv] = function(characterId, target) + local characterData = XDataCenter.CharacterManager.GetCharacter(characterId) + local trustLv = characterData.TrustLv or 1 + return trustLv >= target + end + -- [角色等级达到target] + UnlockRewardFunc[XFavorabilityConfigs.RewardUnlockType.CharacterLv] = function(characterId, target) + local characterData = XDataCenter.CharacterManager.GetCharacter(characterId) + local characterLevel = characterData.Level or 1 + return characterLevel >= target + end + -- [进化至target] + UnlockRewardFunc[XFavorabilityConfigs.RewardUnlockType.Quality] = function(characterId, target) + local characterData = XDataCenter.CharacterManager.GetCharacter(characterId) + local characterQuality = characterData.Quality or 1 + return characterQuality >= target + end + + local UnlockStrangeNewsFunc = {} + UnlockStrangeNewsFunc[XFavorabilityConfigs.StrangeNewsUnlockType.TrustLv] = function(characterId, target) + local characterData = XDataCenter.CharacterManager.GetCharacter(characterId) + if not characterData then + return false + end + + local trustLv = characterData.TrustLv or 1 + return trustLv >= target + end + + -- [宿舍事件:等宿舍完工补上] + UnlockStrangeNewsFunc[XFavorabilityConfigs.StrangeNewsUnlockType.DormEvent] = function() + return false + end + + + function XFavorabilityManager.Init() + + CharacterFavorabilityDatas = {} + --默认打开已解锁的信息 + local allInfo = XFavorabilityConfigs.GetCharacterInformation() + for id, v in pairs(allInfo) do + local trustLv = XFavorabilityManager.GetCurrCharacterFavorabilityLevel(id) + for _, var in ipairs(v) do + if var.UnlockLv <= trustLv then + XFavorabilityManager.OnUnlockCharacterInfomatin(id, var.Id) + end + end + + end + + --异闻 + local allRumors = XFavorabilityConfigs.GetCharacterRumors() + for id, v in pairs(allRumors) do + + for _, var in ipairs(v) do + local canUnlock = XFavorabilityManager.CanRumorsUnlock(id, var.UnlockType, var.UnlockPara) + if canUnlock then + XFavorabilityManager.OnUnlockCharacterRumor(id, var.Id) + end + end + end + + --剧情 + local allStory = XFavorabilityConfigs.GetCharacterStory() + for id, v in pairs(allStory) do + local trustLv = XFavorabilityManager.GetCurrCharacterFavorabilityLevel(id) + for _, var in ipairs(v) do + if var.UnlockLv <= trustLv then + XFavorabilityManager.OnUnlockCharacterStory(id, var.Id) + end + end + end + + --CV + local allVoice = XFavorabilityConfigs.GetCharacterVoice() + for id, v in pairs(allVoice) do + local trustLv = XFavorabilityManager.GetCurrCharacterFavorabilityLevel(id) + for _, var in ipairs(v) do + if var.UnlockLv <= trustLv then + XFavorabilityManager.OnUnlockCharacterVoice(id, var.Id) + end + end + end + + --动作 + local allAction = XFavorabilityConfigs.GetCharacterAction() + for id, v in pairs(allAction) do + local trustLv = XFavorabilityManager.GetCurrCharacterFavorabilityLevel(id) + for _, var in ipairs(v) do + if var.UnlockLv <= trustLv then + XFavorabilityManager.OnUnlockCharacterAction(id, var.Id) + end + end + end + + --XFavorabilityManager.InitEventListener() + end + + + function XFavorabilityManager.InitEventListener() + XEventManager.AddEventListener(XEventId.EVENT_CHARACTER_FIRST_GET, function(characterId) + XDataCenter.FavorabilityManager.PlayCvByType(characterId, XFavorabilityConfigs.SoundEventType.FirstTimeObtain) + end) + + XEventManager.AddEventListener(XEventId.EVENT_CHARACTER_LEVEL_UP, function(characterId) + XDataCenter.FavorabilityManager.PlayCvByType(characterId, XFavorabilityConfigs.SoundEventType.LevelUp) + end) + + XEventManager.AddEventListener(XEventId.EVENT_CHARACTER_QUALITY_PROMOTE, function(characterId) + XDataCenter.FavorabilityManager.PlayCvByType(characterId, XFavorabilityConfigs.SoundEventType.Evolve) + end) + + XEventManager.AddEventListener(XEventId.EVENT_CHARACTER_GRADE, function(characterId) + XDataCenter.FavorabilityManager.PlayCvByType(characterId, XFavorabilityConfigs.SoundEventType.GradeUp) + end) + + XEventManager.AddEventListener(XEventId.EVENT_CHARACTER_SKILL_UP, function(characterId) + XDataCenter.FavorabilityManager.PlayCvByType(characterId, XFavorabilityConfigs.SoundEventType.SkillUp) + end) + + XEventManager.AddEventListener(XEventId.EVENT_EQUIP_PUTON_WEAPON_NOTYFY, function(characterId) + XDataCenter.FavorabilityManager.PlayCvByType(characterId, XFavorabilityConfigs.SoundEventType.WearWeapon) + end) + + XEventManager.AddEventListener(XEventId.EVENT_LOGIN_DATA_LOAD_COMPLETE, function(characterId) + XFavorabilityManager.Init() + -- XDataCenter.FavorabilityManager.PlayCvByType(characterId, XFavorabilityConfigs.SoundEventType.WearWeapon) + end) + + XEventManager.AddEventListener(XEventId.EVENT_TEAM_MEMBER_CHANGE, function(curTeamId, characterId, isCaptain) + if characterId == 0 then return end + local soundEventType = isCaptain and XFavorabilityConfigs.SoundEventType.CaptainJoinTeam + or XFavorabilityConfigs.SoundEventType.MemberJoinTeam + XDataCenter.FavorabilityManager.PlayCvByType(characterId, soundEventType) + end) + end + + function XFavorabilityManager.GetFavorabilityColorWorld(trustLv, name) + return XFavorabilityConfigs.GetWordsWithColor(trustLv, name) + end + + -- [获得好感度面板信息] + function XFavorabilityManager.GetNameWithTitleById(characterId) -- (海外定制)看板角色信息不显示title后缀,国服修改提前 + local currCharacterName = XCharacterConfigs.GetCharacterName(characterId) + --local currCharacterTitle = XCharacterConfigs.GetCharacterTradeName(characterId) + --return XFavorabilityConfigs.GetCharacterNameWithTitle(currCharacterName, currCharacterTitle) + return currCharacterName + end + + + function XFavorabilityManager.GetCurrCharacterFavorabilityLevel(characterId) + if characterId == nil then + return 1 + end + + local currCharacterData = XDataCenter.CharacterManager.GetCharacter(characterId) + if currCharacterData == nil then + return 1 + end + + return currCharacterData.TrustLv or 1 + end + + function XFavorabilityManager.GetCurrCharacterExp(characterId) + if characterId == nil then + return 0 + end + + local currCharacterData = XDataCenter.CharacterManager.GetCharacter(characterId) + + if currCharacterData == nil then + return 0 + end + return currCharacterData.TrustExp or 0 + end + + function XFavorabilityManager.GetCharacterTrustExpById(characterId) + local currCharacterData = XDataCenter.CharacterManager.GetCharacter(characterId) + + if currCharacterData == nil then + return 0 + end + return currCharacterData.TrustExp or 0 + end + + --获取好感度最高的角色Id + function XFavorabilityManager.GetHighestTrustExpCharacter() + local characters = XDataCenter.CharacterManager.GetOwnCharacterList() + local char = nil + local highestExp = -1 + for _, v in pairs(characters) do + -- local exp = XFavorabilityManager.GetCharacterTrustExpById(v.Id) + local level = XFavorabilityManager.GetCurrCharacterFavorabilityLevel(v.Id) + -- local num = exp + level * 100000 --权重 + if char and level == highestExp then + if char.Level == v.Level then + + if char.CreateTime == v.CreateTime then + if char.Id > v.Id then + highestExp = level + char = v + end + elseif char.CreateTime > v.CreateTime then + highestExp = level + char = v + end + + elseif char.Level < v.Level then + highestExp = level + char = v + end + + elseif level > highestExp then + char = v + highestExp = level + end + end + + return char.Id + end + -- [获取好感度等级经验表数据] + function XFavorabilityManager.GetFavorabilityTableData(characterId) + local curTrustExp = XFavorabilityConfigs.GetTrustExpById(characterId) + if curTrustExp == nil then + return + end + local currLevel = XFavorabilityManager.GetCurrCharacterFavorabilityLevel(characterId) + return curTrustExp[currLevel] + end + + -- [资料是否已经解锁] + function XFavorabilityManager.IsInformationUnlock(characterId, infoId) + local favorabilityDatas = XFavorabilityManager.GetCharacterFavorabilityDatasById(characterId) + if favorabilityDatas == nil or favorabilityDatas.UnlockInformation == nil then return false end + return favorabilityDatas.UnlockInformation[infoId] + end + + -- [资料是否可以解锁] + function XFavorabilityManager.CanInformationUnlock(characterId, infoId) + local characterData = XDataCenter.CharacterManager.GetCharacter(characterId) + if characterData == nil then return false end + local trustLv = characterData.TrustLv or 1 + local characterUnlockLvs = XFavorabilityConfigs.GetCharacterInformationUnlockLvById(characterId) + if characterUnlockLvs and characterUnlockLvs[infoId] then + return trustLv >= characterUnlockLvs[infoId] + end + return false + end + + -- [异闻是否解锁] + function XFavorabilityManager.IsRumorUnlock(characterId, rumorId) + local favorabilityDatas = XFavorabilityManager.GetCharacterFavorabilityDatasById(characterId) + if favorabilityDatas == nil or favorabilityDatas.UnlockStrangeNews == nil then return false end + return favorabilityDatas.UnlockStrangeNews[rumorId] + end + -- [异闻是否可以解锁] + function XFavorabilityManager.CanRumorsUnlock(characterId, unlockType, unlockParam) + if UnlockStrangeNewsFunc[unlockType] then + return UnlockStrangeNewsFunc[unlockType](characterId, unlockParam) + end + return false + end + + -- [语音是否解锁] + function XFavorabilityManager.IsVoiceUnlock(characterId, Id) + local favorabilityDatas = XFavorabilityManager.GetCharacterFavorabilityDatasById(characterId) + if favorabilityDatas == nil or favorabilityDatas.UnlockVoice == nil then return false end + return favorabilityDatas.UnlockVoice[Id] + end + + -- [语音是否可以解锁] + function XFavorabilityManager.CanVoiceUnlock(characterId, Id) + local characterData = XDataCenter.CharacterManager.GetCharacter(characterId) + if characterData == nil then return false end + local trustLv = characterData.TrustLv or 1 + local voiceUnlockLvs = XFavorabilityConfigs.GetCharacterVoiceUnlockLvsById(characterId) + if voiceUnlockLvs and voiceUnlockLvs[Id] then + return trustLv >= voiceUnlockLvs[Id] + end + return false + end + + -- [动作是否解锁] + function XFavorabilityManager.IsActionUnlock(characterId, Id) + local favorabilityDatas = XFavorabilityManager.GetCharacterFavorabilityDatasById(characterId) + if favorabilityDatas == nil or favorabilityDatas.UnlockAction == nil then return false end + return favorabilityDatas.UnlockAction[Id] + end + + -- [动作是否可以解锁] + function XFavorabilityManager.CanActionUnlock(characterId, Id) + local characterData = XDataCenter.CharacterManager.GetCharacter(characterId) + if characterData == nil then return false end + local trustLv = characterData.TrustLv or 1 + local actionUnlockLvs = XFavorabilityConfigs.GetCharacterActionUnlockLvsById(characterId) + if actionUnlockLvs and actionUnlockLvs[Id] then + return trustLv >= actionUnlockLvs[Id] + end + return false + end + + -- 【档案end】 + -- 【剧情begin】 + -- [剧情是否已经解锁] + function XFavorabilityManager.IsStoryUnlock(characterId, Id) + local favorabilityDatas = XFavorabilityManager.GetCharacterFavorabilityDatasById(characterId) + if favorabilityDatas == nil or favorabilityDatas.UnlockStory == nil then return false end + return favorabilityDatas.UnlockStory[Id] + end + + -- [剧情剧情是否可以解锁] + function XFavorabilityManager.CanStoryUnlock(characterId, Id) + local characterData = XDataCenter.CharacterManager.GetCharacter(characterId) + if characterData == nil then return false end + local storys = XFavorabilityConfigs.GetCharacterStoryUnlockLvsById(characterId) + if storys == nil then return false end + local storyUnlockLv = storys[Id] or 1 + local trustLv = characterData.TrustLv or 1 + return trustLv >= storyUnlockLv + end + + -- 【剧情end】 + -- 【礼物begin】 + function XFavorabilityManager.SortTrustItems(itemA, itemB) + local itemAPriority = XDataCenter.ItemManager.GetItemPriority(itemA.Id) or 0 + local itemBPriority = XDataCenter.ItemManager.GetItemPriority(itemB.Id) or 0 + + if itemA.IsFavourWeight == itemB.IsFavourWeight then + if itemA.TrustItemQuality == itemB.TrustItemQuality then + if itemAPriority == itemBPriority then + return itemA.Id > itemB.Id + end + return itemAPriority > itemBPriority + end + return itemA.TrustItemQuality > itemB.TrustItemQuality + end + return itemA.IsFavourWeight > itemB.IsFavourWeight + end + + -- 可领取>未解锁>已领取>id排序,权重1,2,3 + local sortTrustItemReward = function(rewardA, rewardB) + local aWeight = rewardA.Weight or 3 + local bWeight = rewardB.Weight or 3 + if aWeight == bWeight then + return rewardA.Id < rewardB.Id + else + return aWeight < bWeight + end + end + + -- [获取奖励道具的列表:排序] + function XFavorabilityManager.GetTrustItemRewardById(characterId) + local currRewardDatas = XFavorabilityConfigs.GetCharacterGiftRewardById(characterId) + for _, v in pairs(currRewardDatas) do + if XFavorabilityManager.IsRewardCollected(characterId, v.Id) then + v.Weight = 3 + else + if XFavorabilityManager.CanRewardUnlock(characterId, v.UnlockType, v.UnlockPara) then--可领取 + v.Weight = 1 + else + v.Weight = 2 + end + end + end + table.sort(currRewardDatas, sortTrustItemReward) + return currRewardDatas + end + + -- [角色奖励是否已经领取] + function XFavorabilityManager.IsRewardCollected(characterId, rewardId) + local favorabilityDatas = XFavorabilityManager.GetCharacterFavorabilityDatasById(characterId) + if favorabilityDatas == nil or favorabilityDatas.UnlockReward == nil then return false end + return favorabilityDatas.UnlockReward[rewardId] + end + + -- [奖励是否可以解锁] + function XFavorabilityManager.CanRewardUnlock(characterId, unlockType, unlockParam) + if UnlockRewardFunc[unlockType] then + return UnlockRewardFunc[unlockType](characterId, unlockParam) + end + return false + end + + -- [添加ID至已经给过特殊礼物的构造体名单] + function XFavorabilityManager.AddGivenItemCharacterId(characterId) + GivenItemCharacterIdList[characterId] = true + end + + -- [添加ID至已经给过特殊礼物的构造体名单] + function XFavorabilityManager.SetGivenItemCharacterId(characterIds) + if not characterIds then return end + for _, id in pairs(characterIds) do + GivenItemCharacterIdList[id] = true + end + end + + -- [检查目标ID是否存在于一给过特殊礼物的构造体名单中] + function XFavorabilityManager.IsInGivenItemCharacterIdList(characterId) + local IsIn = GivenItemCharacterIdList[characterId] + return IsIn and IsIn or false + end + -- 【礼物begin】 + -- 【Rpc相关】 + -- [领取角色奖励] + function XFavorabilityManager.OnCollectCharacterReward(templateId, rewardId, cb) + XNetwork.Call("CharacterUnlockRewardRequest", { TemplateId = templateId, Id = rewardId }, function(res) + cb = cb or function() end + if res.Code == XCode.Success then + local characterFavorabilityDatas = XFavorabilityManager.GetCharacterFavorabilityDatasById(templateId) + if characterFavorabilityDatas and characterFavorabilityDatas.UnlockReward then + characterFavorabilityDatas.UnlockReward[rewardId] = true + end + + cb() + XEventManager.DispatchEvent(XEventId.EVENT_FAVORABILITY_COLLECTGIFT) + local rewards = XFavorabilityConfigs.GetLikeRewardById(rewardId) + if rewards then + local list = {} + table.insert(list, XRewardManager.CreateRewardGoodsByTemplate({ TemplateId = rewards.ItemId, Count = rewards.ItemCount })) + XUiManager.OpenUiObtain(list) + end + + else + XUiManager.TipCode(res.Code) + end + end) + end + + -- [解锁剧情]解锁成功,返回0,重新登陆数据会绑定再character上,不重新登陆也会有最新的数据绑到character + function XFavorabilityManager.OnUnlockCharacterStory(templateId, storyId) + local characterFavorabilityDatas = XFavorabilityManager.GetCharacterFavorabilityDatasById(templateId) + if characterFavorabilityDatas and characterFavorabilityDatas.UnlockStory then + characterFavorabilityDatas.UnlockStory[storyId] = true + end + end + + -- [解锁数据] + function XFavorabilityManager.OnUnlockCharacterInfomatin(templateId, infoId) + local characterFavorabilityDatas = XFavorabilityManager.GetCharacterFavorabilityDatasById(templateId) + if characterFavorabilityDatas and characterFavorabilityDatas.UnlockInformation then + characterFavorabilityDatas.UnlockInformation[infoId] = true + end + end + + -- [解锁异闻] + function XFavorabilityManager.OnUnlockCharacterRumor(templateId, rumorId) + local characterFavorabilityDatas = XFavorabilityManager.GetCharacterFavorabilityDatasById(templateId) + if characterFavorabilityDatas and characterFavorabilityDatas.UnlockStrangeNews then + characterFavorabilityDatas.UnlockStrangeNews[rumorId] = true + end + end + + -- [解锁语音] + function XFavorabilityManager.OnUnlockCharacterVoice(templateId, cvId) + local characterFavorabilityDatas = XFavorabilityManager.GetCharacterFavorabilityDatasById(templateId) + if characterFavorabilityDatas and characterFavorabilityDatas.UnlockVoice then + characterFavorabilityDatas.UnlockVoice[cvId] = true + end + end + + -- [解锁动作] + function XFavorabilityManager.OnUnlockCharacterAction(templateId, actionId) + local characterFavorabilityDatas = XFavorabilityManager.GetCharacterFavorabilityDatasById(templateId) + if characterFavorabilityDatas and characterFavorabilityDatas.UnlockAction then + characterFavorabilityDatas.UnlockAction[actionId] = true + end + end + + -- [发送礼物] + function XFavorabilityManager.OnSendCharacterGift(args, cb) + local gitfs = {} + + for k, v in pairs(args.GiftItems) do + gitfs[k] = v + end + + XMessagePack.MarkAsTable(gitfs) + XNetwork.Call("CharacterSendGiftRequest", { TemplateId = args.CharacterId, GiftItems = gitfs }, function(res) + cb = cb or function() end + if res.Code == XCode.Success then + cb(res) + XEventManager.DispatchEvent(XEventId.EVENT_FAVORABILITY_GIFT, args.CharacterId) + else + XUiManager.TipCode(res.Code) + end + end) + end + + -- [通知更新角色信赖度等级和经验] + function XFavorabilityManager.OnCharacterTrustInfoUpdate(response) + local characterData = XDataCenter.CharacterManager.GetCharacter(response.TemplateId) + if characterData then + -- 等级变化 + local trustLvHasChanged = characterData.TrustLv ~= response.TrustLv + characterData.TrustLv = response.TrustLv + characterData.TrustExp = response.TrustExp + if trustLvHasChanged then + CsXGameEventManager.Instance:Notify(XEventId.EVENT_FAVORABILITY_LEVELCHANGED, response.TrustLv) + XEventManager.DispatchEvent(XEventId.EVENT_FAVORABILITY_LEVELCHANGED) + end + CsXGameEventManager.Instance:Notify(XEventId.EVENT_FAVORABILITY_MAIN_REFRESH) + end + end + + -- [看板交互] + function XFavorabilityManager.BoardMutualRequest() + XNetwork.Send("BoardMutualRequest", {}) + end + + function XFavorabilityManager.IsMaxFavorabilityLevel(characterId) + local trustLv = XFavorabilityManager.GetCurrCharacterFavorabilityLevel(characterId) + local maxLv = XFavorabilityConfigs.GetMaxFavorabilityLevel(characterId) + return trustLv == maxLv + end + + -- 【红点相关】 + -- [某个角色是否有资料可以解锁] + function XFavorabilityManager.HasDataToBeUnlock(characterId) + local characterData = XDataCenter.CharacterManager.GetCharacter(characterId) + if characterData == nil then return false end + local characterTrustLv = characterData.TrustLv or 1 + + local informationDatas = XFavorabilityConfigs.GetCharacterInformationById(characterId) + if informationDatas == nil then return false end + + local favorabilityDatas = XFavorabilityManager.GetCharacterFavorabilityDatasById(characterId) + if favorabilityDatas == nil or favorabilityDatas.UnlockInformation == nil then return false end + + for _, info in pairs(informationDatas) do + local isUnlock = favorabilityDatas.UnlockInformation[info.Id] + local canUnlock = characterTrustLv >= info.UnlockLv + if (not isUnlock) and canUnlock then + return true + end + end + return false + end + + -- [某个角色是否有异闻可以解锁] + function XFavorabilityManager.HasRumorsToBeUnlock(characterId) + local characterData = XDataCenter.CharacterManager.GetCharacter(characterId) + + if characterData == nil then return false end + local rumors = XFavorabilityConfigs.GetCharacterRumorsById(characterId) + if rumors == nil then return false end + + for _, news in pairs(rumors) do + local isNewsUnlock = XFavorabilityManager.IsRumorUnlock(characterId, news.Id) + local canNewsUnlock = XFavorabilityManager.CanRumorsUnlock(characterId, news.UnlockType, news.UnlockPara) + if (not isNewsUnlock) and canNewsUnlock then + return true + end + end + return false + end + -- [某个角色是否有语音可以解锁] + function XFavorabilityManager.HasAudioToBeUnlock(characterId) + local characterData = XDataCenter.CharacterManager.GetCharacter(characterId) + if characterData == nil then return false end + local trustLv = characterData.TrustLv or 1 + + local voices = XFavorabilityConfigs.GetCharacterVoiceById(characterId) + if voices == nil then return false end + + local favorabilityDatas = XFavorabilityManager.GetCharacterFavorabilityDatasById(characterId) + if favorabilityDatas == nil or favorabilityDatas.UnlockVoice == nil then return false end + + for _, voice in pairs(voices) do + local isVoiceUnlock = favorabilityDatas.UnlockVoice[voice.Id] + local canVoiceUnlock = trustLv >= voice.UnlockLv + if (not isVoiceUnlock) and canVoiceUnlock then + return true + end + end + return false + end + -- [某个角色是否有动作可以解锁] + function XFavorabilityManager.HasActionToBeUnlock(characterId) + local characterData = XDataCenter.CharacterManager.GetCharacter(characterId) + if characterData == nil then return false end + local trustLv = characterData.TrustLv or 1 + + local actions = XFavorabilityConfigs.GetCharacterActionById(characterId) + if actions == nil then return false end + + local favorabilityDatas = XFavorabilityManager.GetCharacterFavorabilityDatasById(characterId) + if favorabilityDatas == nil or favorabilityDatas.UnlockAction == nil then return false end + + for _, action in pairs(actions) do + local isActionUnlock = favorabilityDatas.UnlockAction[action.Id] + local canVoiceUnlock = trustLv >= action.UnlockLv + if (not isActionUnlock) and canVoiceUnlock then + return true + end + end + return false + end + -- [某个/当前角色是否有剧情可以解锁] + function XFavorabilityManager.HasStroyToBeUnlock(characterId) + local storys = XFavorabilityConfigs.GetCharacterStoryById(characterId) + if storys == nil then return false end + + local characterData = XDataCenter.CharacterManager.GetCharacter(characterId) + if characterData == nil then return false end + local characterTrustLv = characterData.TrustLv or 1 + + local favorabilityDatas = XFavorabilityManager.GetCharacterFavorabilityDatasById(characterId) + if favorabilityDatas == nil or favorabilityDatas.UnlockStory == nil then return false end + + for _, story in pairs(storys) do + local isStoryUnlock = favorabilityDatas.UnlockStory[story.Id] + local canStoryUnlock = characterTrustLv >= story.UnlockLv + if (not isStoryUnlock) and canStoryUnlock then + return true + end + end + return false + end + + -- [剧情是否可以解锁] + function XFavorabilityManager.CanStoryUnlock(characterId, Id) + local characterData = XDataCenter.CharacterManager.GetCharacter(characterId) + if characterData == nil then return false end + local characterLv = characterData.TrustLv or 1 + + local storys = XFavorabilityConfigs.GetCharacterStoryUnlockLvsById(characterId) + if storys == nil then return false end + local storyLv = storys[Id] or 1 + + return characterLv >= storyLv + end + + -- [播放特殊事件音效] + local PlayingCvId = nil + local PlayingCvInfo = nil + function XFavorabilityManager.PlayCvByType(characterId, soundType) + if not characterId or characterId == 0 then return end + + local voices = XFavorabilityConfigs.GetCharacterVoiceById(characterId) + for _, voice in pairs(voices) do + if voice.SoundType == soundType then + local cvId = voice.CvId + + if PlayingCvId and PlayingCvId == cvId then return end + PlayingCvId = cvId + + PlayingCvInfo = CS.XAudioManager.PlayCv(voice.CvId, function() + PlayingCvId = nil + end) + + return + end + end + end + + function XFavorabilityManager.StopCv() + if not PlayingCvInfo or not PlayingCvInfo.Playing then return end + PlayingCvInfo:Stop() + PlayingCvId = nil + PlayingCvInfo = nil + end + + function XFavorabilityManager.GetCharacterFavorabilityDatasById(characterId) + + local datas = CharacterFavorabilityDatas[characterId] + if not datas then + datas = {} + datas.UnlockInformation = {} + datas.UnlockStory = {} + datas.UnlockReward = {} + datas.UnlockVoice = {} + datas.UnlockStrangeNews = {} + datas.UnlockAction = {} + CharacterFavorabilityDatas[characterId] = datas + end + + return CharacterFavorabilityDatas[characterId] + end + + function XFavorabilityManager.GetFavorabilitySkipIds() + local skip_size = ClientConfig:GetInt("FavorabilitySkipSize") + local skipIds = {} + for i = 1, skip_size do + table.insert(skipIds, ClientConfig:GetInt(string.format("FavorabilitySkip%d", i))) + end + + return skipIds + end + + function XFavorabilityManager.SetDontStopCvContent(value) + DontStopCvContent = value + end + + function XFavorabilityManager.GetDontStopCvContent() + return DontStopCvContent + end + + XFavorabilityManager.InitEventListener() + + return XFavorabilityManager +end +-- [更新好感度等级,经验] +XRpc.NotifyCharacterTrustInfo = function(response) + XDataCenter.FavorabilityManager.OnCharacterTrustInfoUpdate(response) +end + +XRpc.NotifyCharacterExtraData = function(response) + --XDataCenter.FavorabilityManager.OnCharacterFavorabilityDatasAsync(response) +end + +XRpc.NotifyFiveTwentyRecord = function(response) + XDataCenter.FavorabilityManager.SetGivenItemCharacterId(response.CharacterIds) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XFightCharacterManager.lua b/Resources/Scripts/XManager/XFightCharacterManager.lua new file mode 100644 index 00000000..aca29be8 --- /dev/null +++ b/Resources/Scripts/XManager/XFightCharacterManager.lua @@ -0,0 +1,273 @@ +local pairs = pairs +local table = table +local tableInsert = table.insert + +XFightCharacterManager = XFightCharacterManager or {} + +local function Awake() +end + +local function GetQualityTemplate(templateId, quality) + local qualityTemplate = XCharacterConfigs.GetQualityTemplate(templateId, quality) + + if not qualityTemplate then + return XCode.CharacterManagerGetQualityTemplateNotFound, nil + end + + return XCode.Success, qualityTemplate +end + +local function GetGradeTemplates(templateId, grade) + local gradeTemplate = XCharacterConfigs.GetGradeTemplates(templateId, grade) + if not gradeTemplate then + return XCode.CharacterManagerGetGradeTemplateNotFound, nil + end + + return XCode.Success, gradeTemplate +end + +local function GetCharSkillLevelEffectTemplate(skillId, level) + local levelConfig = XCharacterConfigs.GetSkillLevelEffectTemplate(skillId, level) + if not levelConfig then + return XCode.CharacterSkillLevelEffectTemplateNotFound, nil + end + + return XCode.Success, levelConfig +end + +-----------------------------------------Attribs Begin--------------------------------------- +---添加角色星数属性id +---当前品质,从1星累加到当前星 +---@param characterData userdata 角色数据 +---@param attribIds table 属性id列表 +---@return XCode 状态码 +local function DoAddStarAttribId(characterData, attribIds) + if characterData.Star <= 0 then + return XCode.Success + end + + local code, template = GetQualityTemplate(characterData.Id, characterData.Quality) + if code ~= XCode.Success then + return code + end + + local maxStar = #template.AttrId + + for i = 1, characterData.Star do + if i > maxStar then + break + end + + local attribId = template.AttrId[i] + if attribId > 0 then + tableInsert(attribIds, attribId) + end + end + + return XCode.Success +end + +---添加角色晋升属性id +---@param characterData userdata 角色数据 +---@param attribIds table 属性id列表 +---@return XCode 状态码 +local function DoAddGradeAttribId(characterData, attribIds) + local code, template = GetGradeTemplates(characterData.Id, characterData.Grade) + if code ~= XCode.Success then + return code + end + + if template.AttrId > 0 then + tableInsert(attribIds, template.AttrId) + end + + return XCode.Success +end + +--- 属性计算 +--- 1、星星提供属性 +--- 2、晋升提供属性 +local function AddNumericAttribId(npcData, attribIds) + if not npcData.Character then + return XCode.Success + end + + local code = DoAddStarAttribId(npcData.Character, attribIds) + if code ~= XCode.Success then + return code + end + + code = DoAddGradeAttribId(npcData.Character, attribIds) + if code ~= XCode.Success then + return code + end + + return XCode.Success +end +-----------------------------------------Attribs End----------------------------------------- +local function GetResonanceSkillLevelMap(npcData) + local levelMap = {} + + local equips = npcData.Equips + if not equips then + return levelMap + end + + XTool.LoopCollection(equips, function(equipData) + if equipData.ResonanceInfo then + XTool.LoopCollection(equipData.ResonanceInfo, function(resonance) + if resonance.Type == CS.EquipResonanceType.CharacterSkill or resonance.Type == XEquipConfig.EquipResonanceType.CharacterSkill then + if resonance.CharacterId == npcData.Character.Id then + local skillId = resonance.TemplateId + local groupSkillIds = XCharacterConfigs.GetGroupSkillIds(skillId) + + for _, groupSkillId in pairs(groupSkillIds) do + if levelMap[groupSkillId] then + levelMap[groupSkillId] = levelMap[groupSkillId] + 1 + else + levelMap[groupSkillId] = 1 + end + end + end + end + end) + end + end) + + return levelMap +end + +---获取角色技能等级集合 +---@param npcData userdata npc数据 +---@return table 技能等级集合 +local function GetCharSkillLevelMap(npcData) + local levelMap = {} + XTool.LoopCollection(npcData.Character.SkillList, function(skill) + local skillId = skill.Id + local skillLevel = skill.Level + levelMap[skillId] = skillLevel + end) + + local resLevelMap = GetResonanceSkillLevelMap(npcData) + for skillId, level in pairs(resLevelMap) do + if levelMap[skillId] then + levelMap[skillId] = levelMap[skillId] + level + end + end + + if npcData.CharacterSkillPlus then + XTool.LoopMap(npcData.CharacterSkillPlus, function(skillId, level) + if levelMap[skillId] then + levelMap[skillId] = levelMap[skillId] + level + end + end) + end + + return levelMap +end + +--- 技能等级 +--- 1、角色技能加成 +--- 2、共鸣提供加成 +local function GetSkillLevel(npcData, levelMap) + if not npcData.Character then + return XCode.Success + end + + local charLevelMap = GetCharSkillLevelMap(npcData) + + for skillId, level in pairs(charLevelMap) do + local code, template = GetCharSkillLevelEffectTemplate(skillId, level) + if code ~= XCode.Success then + return code + end + + for _, subSkillId in pairs(template.SubSkillId) do + local curLevel = levelMap[subSkillId] + if not curLevel or curLevel < level then + levelMap[subSkillId] = level + end + end + end + + return XCode.Success +end + +--- 魔法等级 +--- 1、角色技能加成 +local function GetMagicLevel(npcData, levelMap) + if not npcData.Character then + return XCode.Success + end + + local charLevelMap = GetCharSkillLevelMap(npcData) + + for skillId, level in pairs(charLevelMap) do + local code, template = GetCharSkillLevelEffectTemplate(skillId, level) + if code ~= XCode.Success then + return code + end + + for _, subMagicId in pairs(template.SubMagicId) do + local curLevel = levelMap[subMagicId] + if not curLevel or curLevel < level then + levelMap[subMagicId] = level + end + end + end + + return XCode.Success +end + +--- 出生魔法属性等级 +--- 1、角色技能加成 +--- 2、共鸣提供加成 +local function GetBornMagicLevel(npcData, levelMap) + if not npcData.Character then + return XCode.Success + end + + local charLevelMap = GetCharSkillLevelMap(npcData) + + for skillId, level in pairs(charLevelMap) do + local code, template = GetCharSkillLevelEffectTemplate(skillId, level) + if code ~= XCode.Success then + return code + end + + for _, magic in pairs(template.BornMagic) do + local curLevel = levelMap[magic] + if not curLevel or curLevel < level then + levelMap[magic] = level + end + end + end + + return XCode.Success +end + +function XFightCharacterManager.GetNpcId(characterData) + local code, qualityTemplate = GetQualityTemplate(characterData.Id, characterData.Quality) + if code ~= XCode.Success then + return code, 0 + end + + return XCode.Success, qualityTemplate.NpcId +end + +local function RegisterInterfaces() + XAttribManager.RegisterNumericIdInterface(AddNumericAttribId) + + XMagicSkillManager.RegisterResonanceSkillLevelInterface(GetResonanceSkillLevelMap) + XMagicSkillManager.RegisterSkillLevelInterface(GetSkillLevel) + XMagicSkillManager.RegisterMagicLevelInterface(GetMagicLevel) + XMagicSkillManager.RegisterBornMagicLevelInterface(GetBornMagicLevel) +end + +function XFightCharacterManager.Init() + Awake() + RegisterInterfaces() +end + +XFightCharacterManager.GetCharSkillLevelMap = GetCharSkillLevelMap +XFightCharacterManager.GetResonanceSkillLevelMap = GetResonanceSkillLevelMap \ No newline at end of file diff --git a/Resources/Scripts/XManager/XFightEquipManager.lua b/Resources/Scripts/XManager/XFightEquipManager.lua new file mode 100644 index 00000000..2e8cf07d --- /dev/null +++ b/Resources/Scripts/XManager/XFightEquipManager.lua @@ -0,0 +1,702 @@ +local pairs = pairs +local type = type + +local table = table +local tableInsert = table.insert + +local mathMin = math.min + +XFightEquipManager = XFightEquipManager or {} + +local function Awake() +end + +local function GetEquipTemplate(equipTemplateId) + local template = XEquipConfig.GetEquipCfg(equipTemplateId) + if not template then + return XCode.EquipTemplateNotFound, nil + end + + return XCode.Success, template +end + +local function GetBreakthroughTemplate(equipTemplateId, times) + local template = XEquipConfig.GetEquipBreakthroughCfg(equipTemplateId, times) + if not template then + return XCode.EquipBreakthroughTemplateNotFound, nil + end + + return XCode.Success, template +end + +local function GetWeaponSkillTemplate(templateId) + local template = XEquipConfig.GetWeaponSkillTemplate(templateId) + if not template then + return XCode.EquipWeaponSkillTemplateNotFound, nil + end + + return XCode.Success, template +end + +local function GetSuitTemplate(suitId) + local template = XEquipConfig.GetEquipSuitCfg(suitId) + if not template then + return XCode.EquipSuitTemplateNotFound, nil + end + + return XCode.Success, template +end + +local function GetSuitEffectTemplate(templateId) + local template = XEquipConfig.GetEquipSuitEffectCfg(templateId) + if not template then + return XCode.EquipSuitEffectTemplateNotFound, nil + end + + return XCode.Success, template +end + +local function GetEquipAwakeTemplate(templateId) + local template = XEquipConfig.GetEquipAwakeCfg(templateId) + if not template then + return XCode.EquipAwakeTemplateNotFound, nil + end + + return XCode.Success, template +end +-----------------------------------------Attribs Begin--------------------------------------- +---突破属性成长加成 +---@param equipData userdata 装备数据 +---@param attribIds table 属性id列表 +---@param trainedLevels table 培养等级列表 +---@return XCode 状态码 +local function DoAddBreakthroughPromotedAttribId(equipData, attribIds, trainedLevels) + local code, template = GetBreakthroughTemplate(equipData.TemplateId, equipData.Breakthrough) + if code ~= XCode.Success then + return code + end + + local trainedLevel = equipData.Level - 1 + if trainedLevel > 0 and template.AttribPromotedId > 0 then + tableInsert(attribIds, template.AttribPromotedId) + tableInsert(trainedLevels, trainedLevel) + end + + return XCode.Success +end + +---共鸣属性叠加id +local function DoAddResonanceAttribId(equipData, characterId, attribIds) + local resonanceInfo = equipData.ResonanceInfo + + if type(resonanceInfo) == "userdata" then + resonanceInfo = XTool.CsList2LuaTable(resonanceInfo) + end + + for _, resonanceData in pairs(resonanceInfo) do + if resonanceData.Type == XEquipConfig.EquipResonanceType.Attrib or + resonanceData.Type == CS.EquipResonanceType.Attrib then + if resonanceData.CharacterId == 0 or resonanceData.CharacterId == characterId then + local code, template = XAttribManager.GetAttribGroupTemplate(resonanceData.TemplateId) + if code ~= XCode.Success then + return code + end + + if template.AttribId > 0 then + tableInsert(attribIds, template.AttribId) + end + end + end + end + + return XCode.Success +end + +---共鸣属性加成id +local function DoAddResonanceGrowRateAttribId(equipData, characterId, attribIds) + local resonanceInfo = equipData.ResonanceInfo + + if type(resonanceInfo) == "userdata" then + resonanceInfo = XTool.CsList2LuaTable(resonanceInfo) + end + + for _, resonanceData in pairs(resonanceInfo) do + if resonanceData.Type == XEquipConfig.EquipResonanceType.Attrib or + resonanceData.Type == CS.EquipResonanceType.Attrib then + if resonanceData.CharacterId == 0 or resonanceData.CharacterId == characterId then + local code, template = XAttribManager.GetAttribGroupTemplate(resonanceData.TemplateId) + if code ~= XCode.Success then + return code + end + + if template.AttribGrowRateId > 0 then + tableInsert(attribIds, template.AttribGrowRateId) + end + end + end + end + + return XCode.Success +end + +--- 觉醒属性叠加id +local function DoAddAwakeAttribId(equipData, characterId, attribIds) + local awakeSlotList = equipData.AwakeSlotList + + if type(awakeSlotList) == "userdata" then + awakeSlotList = XTool.CsList2LuaTable(awakeSlotList) + end + + if not awakeSlotList or not next(awakeSlotList) then + return XCode.Success + end + + local code, template = GetEquipAwakeTemplate(equipData.TemplateId) + if code ~= XCode.Success then + return code + end + + local resonanceInfo = equipData.ResonanceInfo + + if type(resonanceInfo) == "userdata" then + resonanceInfo = XTool.CsList2LuaTable(resonanceInfo) + end + + for _, slot in pairs(awakeSlotList) do + for _, resonanceData in pairs(resonanceInfo) do + if resonanceData.Slot == slot then + if resonanceData.CharacterId == 0 or resonanceData.CharacterId == characterId then + local attribId = template.AttribId[slot] + + if not attribId then + return XCode.EquipAwakeSlotAttribConfigNotFound + end + + tableInsert(attribIds, attribId) + end + end + end + end + + return XCode.Success +end + +--- 属性计算 +--- 1、突破提供基础属性 +--- 2、共鸣属性计算 +--- 3、觉醒提供属性 +local function AddNumericAttribId(npcData, attribIds) + local equips = npcData.Equips + if not equips then + return XCode.Success + end + + if type(equips) == "userdata" then + equips = XTool.CsList2LuaTable(equips) + end + + if #equips <= 0 then + return XCode.Success + end + + for _, equipData in pairs(equips) do + local code, template = GetBreakthroughTemplate(equipData.TemplateId, equipData.Breakthrough) + if code ~= XCode.Success then + return code + end + + if template.AttribId > 0 then + tableInsert(attribIds, template.AttribId) + end + + if equipData.ResonanceInfo then + code = DoAddResonanceAttribId(equipData, npcData.Character.Id, attribIds) + if code ~= XCode.Success then + return code + end + end + + if equipData.AwakeSlotList then + code = DoAddAwakeAttribId(equipData, npcData.Character.Id, attribIds) + if code ~= XCode.Success then + return code + end + end + end + + return XCode.Success +end + +--- 属性百分比加成 +--- 1、共鸣提供加成 +local function AddGrowRateAttribId(npcData, attribIds) + local equips = npcData.Equips + if not equips then + return XCode.Success + end + + if type(equips) == "userdata" then + equips = XTool.CsList2LuaTable(equips) + end + + if #equips < 0 then + return XCode.Success + end + + for _, equipData in pairs(equips) do + if equipData.ResonanceInfo then + local code = DoAddResonanceGrowRateAttribId(equipData, npcData.Character.Id, attribIds) + if code ~= XCode.Success then + return code + end + end + end + + return XCode.Success +end + +--- 属性成长加成 +--- 1、突破提供加成 +local function AddPromotedAttribId(npcData, attribIds, trainedLevels) + local equips = npcData.Equips + if not equips then + return XCode.Success + end + + if type(equips) == "userdata" then + equips = XTool.CsList2LuaTable(equips) + end + + if #equips <= 0 then + return XCode.Success + end + + for _, equipData in pairs(equips) do + local code = DoAddBreakthroughPromotedAttribId(equipData, attribIds, trainedLevels) + if code ~= XCode.Success then + return code + end + end + + return XCode.Success +end +-----------------------------------------Attribs End----------------------------------------- +-----------------------------------------Skill Begin----------------------------------------- +---武器技能等级集合 +---武器技能都为1级 +---@param equipData userdata 装备数据 +---@param levelMap table 技能等级集合 +---@return XCode 状态码 +local function DoGetWeaponSkillLevel(equipData, levelMap) + local code, template = GetEquipTemplate(equipData.TemplateId) + if code ~= XCode.Success then + return code + end + + if template.Site ~= XEquipConfig.EquipSite.Weapon then + return XCode.Success + end + + if template.WeaponSkillId <= 0 then + return XCode.Success + end + + local skillTemplate + code, skillTemplate = GetWeaponSkillTemplate(template.WeaponSkillId) + if code ~= XCode.Success then + return code + end + + for _, subSkillId in pairs(skillTemplate.SubSkillId) do + levelMap[subSkillId] = 1 + end + + return XCode.Success +end + +---武器共鸣技能集合 +---共鸣技能等级都为1级 +---@param equipData userdata 装备数据 +---@param characterId number 角色id +---@param levelMap table 技能等级集合 +---@return XCode 状态码 +local function DoGetResonanceSkillLevel(equipData, characterId, levelMap) + local resonanceInfo = equipData.ResonanceInfo + + if type(resonanceInfo) == "userdata" then + resonanceInfo = XTool.CsList2LuaTable(resonanceInfo) + end + + for _, resonanceData in pairs(resonanceInfo) do + if resonanceData.Type == CS.EquipResonanceType.WeaponSkill then + if resonanceData.CharacterId == 0 or resonanceData.CharacterId == characterId then + local code, skillTemplate = GetWeaponSkillTemplate(resonanceData.TemplateId) + if code ~= XCode.Success then + return code + end + + for _, subSkillId in pairs(skillTemplate.SubSkillId) do + levelMap[subSkillId] = 1 + end + end + end + end + + return XCode.Success +end + +---套装技能等级集合 +---套装技能等级都为1级 +---@param equips userdata 装备数据 +---@param levelMap table 技能等级集合 +---@return XCode 状态码 +local function DoGetSuitSkillLevel(equips, levelMap) + local suitCount = {} + + if type(equips) == "userdata" then + equips = XTool.CsList2LuaTable(equips) + end + + for _, equip in pairs(equips) do + local code, template = GetEquipTemplate(equip.TemplateId) + if code ~= XCode.Success then + return code + end + + if template.SuitId > 0 then + if not suitCount[template.SuitId] then + suitCount[template.SuitId] = 1 + else + suitCount[template.SuitId] = suitCount[template.SuitId] + 1 + end + end + end + + for suitId, count in pairs(suitCount) do + local code, template = GetSuitTemplate(suitId) + if code ~= XCode.Success then + return code + end + + for i = 1, mathMin(count, XEquipConfig.MAX_SUIT_COUNT) do + local effectId = template.SkillEffect[i] + if effectId and effectId > 0 then + local effectTemplate + code, effectTemplate = GetSuitEffectTemplate(effectId) + if code ~= XCode.Success then + return code + end + + if #effectTemplate.SkillId > 0 then + for _, skillId in pairs(effectTemplate.SkillId) do + levelMap[skillId] = 1 + end + end + end + end + end + + return XCode.Success +end + +---武器额外技能加成 +---额外技能等级都为1级 +---@param plusSkillList userdata 额外加成技能列表 +---@param levelMap table 技能等级集合 +---@return XCode 状态码 +local function DoGetPlusSkillLevel(plusSkillList, levelMap) + if not plusSkillList then + return XCode.Success + end + + if type(plusSkillList) == "userdata" then + plusSkillList = XTool.CsList2LuaTable(plusSkillList) + end + + for _, skillId in pairs(plusSkillList) do + local code, skillTemplate = GetWeaponSkillTemplate(skillId) + if code ~= XCode.Success then + return code + end + + for _, subSkillId in pairs(skillTemplate.SubSkillId) do + levelMap[subSkillId] = 1 + end + end + + return XCode.Success +end + +--- 技能等级 +--- 1、武器技能加成 +--- 2、共鸣提供加成 +--- 3、套装技能加成 +--- 4、武器额外技能加成 +local function GetSkillLevel(npcData, levelMap) + local code + local equips = npcData.Equips + + if type(equips) == "userdata" then + equips = XTool.CsList2LuaTable(equips) + end + + for _, equipData in pairs(equips) do + code = DoGetWeaponSkillLevel(equipData, levelMap) + if code ~= XCode.Success then + return code + end + + code = DoGetResonanceSkillLevel(equipData, npcData.Character.Id, levelMap) + if code ~= XCode.Success then + return code + end + end + + code = DoGetSuitSkillLevel(equips, levelMap) + if code ~= XCode.Success then + return code + end + + code = DoGetPlusSkillLevel(npcData.EquipSkillPlus, levelMap) + if code ~= XCode.Success then + return code + end + + return XCode.Success +end +-----------------------------------------Skill End----------------------------------------- +-----------------------------------------Magic Begin----------------------------------------- +---武器出生魔法等级集合 +---武器出生魔法等级都为1级 +---@param equipData userdata 装备数据 +---@param levelMap table 出生魔法等级集合 +---@return XCode 状态码 +local function DoGetWeaponBornMagicLevel(equipData, levelMap) + local code, template = GetEquipTemplate(equipData.TemplateId) + if code ~= XCode.Success then + return code + end + + if template.Site ~= XEquipConfig.EquipSite.Weapon then + return XCode.Success + end + + if template.WeaponSkillId <= 0 then + return XCode.Success + end + + local skillTemplate + code, skillTemplate = GetWeaponSkillTemplate(template.WeaponSkillId) + if code ~= XCode.Success then + return code + end + + for _, magic in pairs(skillTemplate.BornMagic) do + levelMap[magic] = 1 + end + + return XCode.Success +end + +---武器共鸣出生魔法等级集合 +---共鸣出生魔法等级都为1级 +---@param equipData userdata 装备数据 +---@param characterId number 角色id +---@param levelMap table 技能等级集合 +---@return XCode 状态码 +local function DoGetResonanceBornMagicLevel(equipData, characterId, levelMap) + local resonanceInfo = equipData.ResonanceInfo + + if type(resonanceInfo) == "userdata" then + resonanceInfo = XTool.CsList2LuaTable(resonanceInfo) + end + + for _, resonanceData in pairs(resonanceInfo) do + if resonanceData.Type == CS.EquipResonanceType.WeaponSkill then + if resonanceData.CharacterId == 0 or resonanceData.CharacterId == characterId then + local code, skillTemplate = GetWeaponSkillTemplate(resonanceData.TemplateId) + if code ~= XCode.Success then + return code + end + + for _, magic in pairs(skillTemplate.BornMagic) do + levelMap[magic] = 1 + end + end + end + end + + return XCode.Success +end + +---套装出生魔法等级集合 +---套装出生魔法等级都为1级 +---@param equips userdata 装备数据 +---@param levelMap table 出生魔法等级集合 +---@return XCode 状态码 +local function DoGetSuitBornMagicLevel(equips, levelMap) + local suitCount = {} + + if type(equips) == "userdata" then + equips = XTool.CsList2LuaTable(equips) + end + + for _, equip in pairs(equips) do + local code, template = GetEquipTemplate(equip.TemplateId) + if code ~= XCode.Success then + return code + end + + if template.SuitId > 0 then + if not suitCount[template.SuitId] then + suitCount[template.SuitId] = 1 + else + suitCount[template.SuitId] = suitCount[template.SuitId] + 1 + end + end + end + + for suitId, count in pairs(suitCount) do + local code, template = GetSuitTemplate(suitId) + if code ~= XCode.Success then + return code + end + + for i = 1, mathMin(count, XEquipConfig.MAX_SUIT_COUNT) do + local effectId = template.SkillEffect[i] + if effectId and effectId > 0 then + local effectTemplate + code, effectTemplate = GetSuitEffectTemplate(effectId) + if code ~= XCode.Success then + return code + end + + if #effectTemplate.BornMagic > 0 then + for _, bornMagic in pairs(effectTemplate.BornMagic) do + levelMap[bornMagic] = 1 + end + end + end + end + end + + return XCode.Success +end + +---武器额外出生魔法等级加成 +---额外出生魔法等级都为1级 +---@param plusSkillList userdata 额外加成技能列表 +---@param levelMap table 出生魔法等级集合 +---@return XCode 状态码 +local function DoGetPlusBornMagicLevel(plusSkillList, levelMap) + if not plusSkillList then + return XCode.Success + end + + if type(plusSkillList) == "userdata" then + plusSkillList = XTool.CsList2LuaTable(plusSkillList) + end + + for _, skillId in pairs(plusSkillList) do + local code, skillTemplate = GetWeaponSkillTemplate(skillId) + if code ~= XCode.Success then + return code + end + + for _, magic in pairs(skillTemplate.BornMagic) do + levelMap[magic] = 1 + end + end + + return XCode.Success +end + +--- 出生魔法属性等级 +--- 1、武器技能加成 +--- 2、共鸣提供加成 +--- 3、套装技能加成 +--- 4、武器额外技能加成 +local function GetBornMagicLevel(npcData, levelMap) + local code + local equips = npcData.Equips + + if type(equips) == "userdata" then + equips = XTool.CsList2LuaTable(equips) + end + + for _, equipData in pairs(equips) do + code = DoGetWeaponBornMagicLevel(equipData, levelMap) + if code ~= XCode.Success then + return code + end + + code = DoGetResonanceBornMagicLevel(equipData, npcData.Character.Id, levelMap) + if code ~= XCode.Success then + return code + end + end + + code = DoGetSuitBornMagicLevel(npcData.Equips, levelMap) + if code ~= XCode.Success then + return code + end + + code = DoGetPlusBornMagicLevel(npcData.EquipSkillPlus, levelMap) + if code ~= XCode.Success then + return code + end + + return XCode.Success +end +-----------------------------------------Magic End----------------------------------------- +local function RegisterInterfaces() + XAttribManager.RegisterGrowRateIdInterface(AddGrowRateAttribId) + XAttribManager.RegisterNumericIdInterface(AddNumericAttribId) + XAttribManager.RegisterPromotedIdInterface(AddPromotedAttribId) + + XMagicSkillManager.RegisterSkillLevelInterface(GetSkillLevel) + XMagicSkillManager.RegisterBornMagicLevelInterface(GetBornMagicLevel) +end + +function XFightEquipManager.Init() + Awake() + RegisterInterfaces() +end + +---------------------------------------客户端特有方法--------------------------------------- +local function DoGetEquipAttribIds(equipData, numericIds, promotedIds, trainedLevels) + local code, template = GetBreakthroughTemplate(equipData.TemplateId, equipData.Breakthrough) + if code ~= XCode.Success then + return + end + + tableInsert(numericIds, template.AttribId) + DoAddBreakthroughPromotedAttribId(equipData, promotedIds, trainedLevels) +end + +function XFightEquipManager.GetEquipAttribs(equipData, preLevel) + local numericIds = {} + local trainedLevels = {} + local promotedIds = {} + local equipLevel = preLevel or equipData.Level + + DoGetEquipAttribIds({ + TemplateId = equipData.TemplateId, + Breakthrough = equipData.Breakthrough, + Level = equipLevel + }, numericIds, promotedIds, trainedLevels) + + return XAttribManager.GetMergeAttribs(numericIds, promotedIds, trainedLevels) +end + +function XFightEquipManager.GetEquipListAttribs(equipDatas) + local numericIds = {} + local trainedLevels = {} + local promotedIds = {} + + XTool.LoopCollection(equipDatas, function(equipData) + DoGetEquipAttribIds(equipData, numericIds, promotedIds, trainedLevels) + end) + + return XAttribManager.GetMergeAttribs(numericIds, promotedIds, trainedLevels) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XFightInfestorExploreManager.lua b/Resources/Scripts/XManager/XFightInfestorExploreManager.lua new file mode 100644 index 00000000..28f064ad --- /dev/null +++ b/Resources/Scripts/XManager/XFightInfestorExploreManager.lua @@ -0,0 +1,188 @@ +XFightInfestorExploreManagerCreator = function() + local XFightInfestorExploreManager = {} + + local math = math + local RULER_PAGE_NUM = CS.XGame.ClientConfig:GetInt("FightInfestorScoreRulerMinCount") + local SCORE_GAP = CS.XGame.ClientConfig:GetFloat("FightInfestorPanelScoreGap") + local PLAYER_SCORE_LIMIT = CS.XGame.ClientConfig:GetFloat("FightInfestorPlayerScoreLimit") + + local MyScore = 0 + local BaseScore = 0 + local StageId = 0 + local ScoreRule = nil + local DamageMaxScore = nil + local HpMaxScore = nil + local UseTimeMaxScore = nil + local TotalMaxScore = nil + + XFightInfestorExploreManager.COLLECT_SCORE_TIME = 1000 -- 列表刷新时间(ms) + + function XFightInfestorExploreManager.Init() + CsXGameEventManager.Instance:RegisterEvent(XEventId.EVENT_FIGHT_EXIT, XFightInfestorExploreManager.OnFightExit) + end + + function XFightInfestorExploreManager.OnFightExit() + XLuaUiManager.Remove("UiFightInfestorExplore") + end + + -- CS CALL + function XFightInfestorExploreManager.ShowPanel(active, stageId) + if active then + if XFightInfestorExploreManager.InitData(stageId) then + XLuaUiManager.Open("UiFightInfestorExplore") + end + else + XLuaUiManager.Close("UiFightInfestorExplore") + end + end + + function XFightInfestorExploreManager.InitData(stageId) + if not CS.XFight.Instance then + XLog.Error("不在战斗中,无法打开UiFightInfestorExplore" ) + return false + end + StageId = stageId or CS.XFight.Instance.FightData.StageId + ScoreRule = XFubenInfestorExploreConfigs.GetScoreRuleConfig(StageId) + if not ScoreRule then + return false + end + DamageMaxScore = ScoreRule.DamageMaxScore > 0 and ScoreRule.DamageMaxScore or XMath.IntMax() + HpMaxScore = ScoreRule.HpMaxScore > 0 and ScoreRule.HpMaxScore or XMath.IntMax() + UseTimeMaxScore = ScoreRule.UseTimeMaxScore > 0 and ScoreRule.UseTimeMaxScore or XMath.IntMax() + TotalMaxScore = ScoreRule.TotalMaxScore > 0 and ScoreRule.TotalMaxScore or XMath.IntMax() + + SCORE_GAP = XDataCenter.FubenInfestorExploreManager.GetDiffShowScoreGap() + PLAYER_SCORE_LIMIT = XDataCenter.FubenInfestorExploreManager.GetDiffShowScoreLimit() + + local myTotalScore = XDataCenter.FubenInfestorExploreManager.GetPlayerScore(XPlayer.Id) + local stageScore = XDataCenter.FubenInfestorExploreManager.GetChapter2StageScore(StageId) + BaseScore = myTotalScore - stageScore + MyScore = BaseScore + if BaseScore < 0 then + XLog.Error("初始化分数<0 stageId:" .. StageId .. ", stageScore:" .. tostring(stageScore)) + end + return true + end + + function XFightInfestorExploreManager.GetScore() + return MyScore + end + + function XFightInfestorExploreManager.SetScore(score) + MyScore = score + end + + function XFightInfestorExploreManager.CalcScore(score) + local fightInstance = CS.XFight.Instance + if not fightInstance then + score = score + 1000 + else + local totalDamage = fightInstance.Result:CollectTotalDamage() + local leftHpRate = fightInstance.Result:CollectLeftHpRate() + local usedTime = fightInstance.Result:CollectUsedTime() + + local damageScore = math.min(totalDamage * ScoreRule.DamageFactor, DamageMaxScore) + local hpScore = math.min(leftHpRate * ScoreRule.HpFactor, HpMaxScore) + local useTimeScore = math.min(usedTime * ScoreRule.UseTimeFactor, UseTimeMaxScore) + score = BaseScore + math.min(math.ceil(damageScore + hpScore + useTimeScore), TotalMaxScore) + -- XLog.Debug(" scoreData = " .. score, {leftHpRate, totalDamage, usedTime, damageScore, hpScore, useTimeScore}) + end + return score + end + + function XFightInfestorExploreManager.GetScoreGap() + return SCORE_GAP + end + + function XFightInfestorExploreManager.GetScoreFloor(score) + score = score or XFightInfestorExploreManager.GetScore() + local leftScore = score % SCORE_GAP + return score - leftScore + end + + function XFightInfestorExploreManager.GetScoreStr(score) + score = score or XFightInfestorExploreManager.GetScore() + return CS.XTextManager.GetText("InfestorFightScoreName") .. XFightInfestorExploreManager.NomalizeScoreStr(score) -- "当前讨伐值:" + end + + function XFightInfestorExploreManager.NomalizeScoreStr(score) + if score >= 10000 then + return CS.XTextManager.GetText("ShowLargeIntNumText", math.floor(score / 1000) / 10) --因为W仅仅是中国境内约定俗成的万,老外看不懂 所以要同步!!!! + end + return score + end + + function XFightInfestorExploreManager.GetRulerList(playerList) + local rulerList = {} + local scoreFloor = XFightInfestorExploreManager.GetScoreFloor() + local maxScore = 0 + for _, data in ipairs(playerList) do + if data:GetScore() > maxScore then + maxScore = data:GetScore() + end + end + local rulerNum = math.ceil((maxScore -scoreFloor) / SCORE_GAP) + 1 + rulerNum = math.max(rulerNum, RULER_PAGE_NUM) + for i = rulerNum, 1, -1 do + local score = scoreFloor + SCORE_GAP * i + local scoreStr = XFightInfestorExploreManager.NomalizeScoreStr(score) + table.insert(rulerList, scoreStr) + end + return rulerList + end + + ----------- 玩家数据 begin----------- + local PlayerData = XClass(nil, "PlayerData") + + function PlayerData:Ctor(index, infestorExplorePlayer) + self.index = index + self.name = infestorExplorePlayer:GetName() + local shortName = string.Utf8Sub(self.name, 1, 4) + if self.name ~= shortName then + self.name = shortName .. "..." + end + self.score = infestorExplorePlayer:GetScore() + self.Icon = infestorExplorePlayer:GetHeadIcon() + self.posRate = 0 -- 刻度倍数(以最小刻度开始) + end + function PlayerData:GetName() return self.name end + function PlayerData:GetScore() return self.score end + function PlayerData:GetScoreStr() return XFightInfestorExploreManager.NomalizeScoreStr(self.score) end + function PlayerData:GetPosRate() return self.posRate end + function PlayerData:SetPosRate(rate) self.posRate = rate end + function PlayerData:GetIcon() return self.Icon end + + function XFightInfestorExploreManager.GetPlayerList() + local playerList = {} + local indexList = XDataCenter.FubenInfestorExploreManager.GetPlayerRankIndexList() + local list = {} + local playerId = XPlayer.Id + for _, index in ipairs(indexList) do + local infestorExplorePlayer = XDataCenter.FubenInfestorExploreManager.GetPlayerRankData(index) + if infestorExplorePlayer then + if infestorExplorePlayer:GetPlayerId() ~= playerId and + infestorExplorePlayer:GetScore() >= PLAYER_SCORE_LIMIT then + table.insert(list, infestorExplorePlayer) + end + end + end + + for _, infestorExplorePlayer in ipairs(list) do + table.insert(playerList, PlayerData.New(index, infestorExplorePlayer)) + end + -- 计算位置数据 + local score = XFightInfestorExploreManager.GetScore() + local scoreFloor = XFightInfestorExploreManager.GetScoreFloor() + for _, data in ipairs(playerList) do + if data:GetScore() > score then + local posRate = (data:GetScore() - scoreFloor) / SCORE_GAP + data:SetPosRate(posRate) + end + end + return playerList + end + ----------- 玩家数据 end + + XFightInfestorExploreManager.Init() + return XFightInfestorExploreManager +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XFightPartnerManager.lua b/Resources/Scripts/XManager/XFightPartnerManager.lua new file mode 100644 index 00000000..b54de921 --- /dev/null +++ b/Resources/Scripts/XManager/XFightPartnerManager.lua @@ -0,0 +1,363 @@ +local tableInsert = table.insert + +XFightPartnerManager = XFightPartnerManager or {} + +local function Awake() +end + +-----------------------------------------Attribs Begin--------------------------------------- +---突破属性成长加成 +local function DoAddBreakthroughPromotedAttribId(partnerData, attribIds, trainedLevels) + local partnerEntity = XDataCenter.PartnerManager.CreatePartnerEntityByPartnerData(partnerData) + + if not partnerEntity then + return XCode.PartnerTemplateNotFound + end + + local trainedLevel = (partnerData.PreLevel or partnerEntity:GetLevel()) - 1 + local attribPromotedId = partnerEntity:GetBreakthroughAttribPromotedId() + if trainedLevel > 0 and attribPromotedId > 0 then + tableInsert(attribIds, attribPromotedId) + tableInsert(trainedLevels, trainedLevel) + end + + return XCode.Success +end + +---突破基础属性加成 +local function DoAddBreakthroughAttribId(partnerData, attribIds) + local partnerEntity = XDataCenter.PartnerManager.CreatePartnerEntityByPartnerData(partnerData) + + if not partnerEntity then + return XCode.PartnerTemplateNotFound + end + + local attribId = partnerEntity:GetBreakthroughAttribId() + if attribId > 0 then + tableInsert(attribIds, attribId) + end + + return XCode.Success +end + +---添加角色星数属性id +---当前品质,从1星累加到当前星 +local function DoAddStarAttribId(partnerData, attribIds) + local partnerEntity = XDataCenter.PartnerManager.CreatePartnerEntityByPartnerData(partnerData) + + if not partnerEntity then + return XCode.PartnerTemplateNotFound + end + + for quality = partnerEntity:GetInitQuality(), partnerEntity:GetQuality() do + local starAttrIds = partnerEntity:GetQualityStarAttribId(quality) + local maxStar = #starAttrIds + + if quality == partnerEntity:GetQuality() then + maxStar = partnerEntity:GetCanActivateStarCount() + end + + for i = 1, maxStar do + local attribId = starAttrIds[i] + if attribId > 0 then + tableInsert(attribIds, attribId) + end + end + end + + return XCode.Success +end + +---添加角色进化属性id +local function DoAddEvolutionAttribId(partnerData, attribIds) + local partnerEntity = XDataCenter.PartnerManager.CreatePartnerEntityByPartnerData(partnerData) + + if not partnerEntity then + return XCode.PartnerTemplateNotFound + end + + local attribId = partnerEntity:GetQualityEvolutionAttribId() + if attribId > 0 then + tableInsert(attribIds, attribId) + end + + return XCode.Success +end + +--- 属性计算 +--- 1、突破提供基础属性 +--- 2、升星提供属性 +--- 3、进化提供属性 +local function GetNumericAttribId(partnerData, attribIds) + local code + + code = DoAddBreakthroughAttribId(partnerData, attribIds) + if code ~= XCode.Success then + return code + end + + code = DoAddStarAttribId(partnerData, attribIds) + if code ~= XCode.Success then + return code + end + + code = DoAddEvolutionAttribId(partnerData, attribIds) + if code ~= XCode.Success then + return code + end + + return XCode.Success +end + +--- 属性计算 +--- 1、只要突破提供基础属性 +local function GetBreakthroughNumericAttribId(partnerData, attribIds) + local code + + code = DoAddBreakthroughAttribId(partnerData, attribIds) + if code ~= XCode.Success then + return code + end + return XCode.Success +end + +--- 属性成长加成 +--- 1、突破提供加成 +local function GetPromotedAttribId(partnerData, attribIds, trainedLevels) + local code = DoAddBreakthroughPromotedAttribId(partnerData, attribIds, trainedLevels) + if code ~= XCode.Success then + return code + end + + return XCode.Success +end + +-----------------------------------------Attribs End----------------------------------------- +-----------------------------------------Skill Begin----------------------------------------- +---伙伴主动技能集合 +local function SetPartnerMainSkillLevel(partnerData, levelMap) + local partnerEntity = XDataCenter.PartnerManager.CreatePartnerEntityByPartnerData(partnerData) + if not partnerEntity then + return XCode.PartnerTemplateNotFound + end + + local mainSkillGroupEntityDic = partnerEntity:GetMainSkillGroupEntityDic() + for _, groupEntity in pairs(mainSkillGroupEntityDic or {}) do + if groupEntity:GetIsCarry() then + local skillLevel = groupEntity:GetLevel() + local subSkillIds = groupEntity:GetActiveSkillSubSkillId() + for _,subSkillId in pairs(subSkillIds or {}) do + if not levelMap[subSkillId] or levelMap[subSkillId] < skillLevel then + levelMap[subSkillId] = skillLevel + end + end + end + end + + return XCode.Success +end + +---伙伴被动技能集合 +local function SetPartnerPassiveSkillLevel(partnerData, levelMap) + local partnerEntity = XDataCenter.PartnerManager.CreatePartnerEntityByPartnerData(partnerData) + if not partnerEntity then + return XCode.PartnerTemplateNotFound + end + + local passiveSkillGroupEntityDic = partnerEntity:GetPassiveSkillGroupEntityDic() + for _, groupEntity in pairs(passiveSkillGroupEntityDic or {}) do + if groupEntity:GetIsCarry() then + local skillLevel = groupEntity:GetLevel() + local subSkillIds = groupEntity:GetActiveSkillSubSkillId() + for _,subSkillId in pairs(subSkillIds or {}) do + if not levelMap[subSkillId] or levelMap[subSkillId] < skillLevel then + levelMap[subSkillId] = skillLevel + end + end + end + end + + return XCode.Success +end + +--- 技能等级 +--- 1、伙伴主动技能加成 +--- 2、伙伴被动技能加成 +local function GetSkillLevel(partnerData, levelMap) + local code + + code = SetPartnerMainSkillLevel(partnerData, levelMap) + if code ~= XCode.Success then + return code + end + + code = SetPartnerPassiveSkillLevel(partnerData, levelMap) + if code ~= XCode.Success then + return code + end + + return XCode.Success +end +-----------------------------------------Skill End----------------------------------------- +-----------------------------------------Magic Begin----------------------------------------- +---伙伴主动魔法集合 +local function SetPartnerMainMagicLevel(partnerData, levelMap) + local partnerEntity = XDataCenter.PartnerManager.CreatePartnerEntityByPartnerData(partnerData) + if not partnerEntity then + return XCode.PartnerTemplateNotFound + end + + local mainSkillGroupEntityDic = partnerEntity:GetMainSkillGroupEntityDic() + for _, groupEntity in pairs(mainSkillGroupEntityDic or {}) do + if groupEntity:GetIsCarry() then + local skillLevel = groupEntity:GetLevel() + local subMagicIds = groupEntity:GetActiveSkillSubMagicId() + for _,subMagicId in pairs(subMagicIds or {}) do + if not levelMap[subMagicId] or levelMap[subMagicId] < skillLevel then + levelMap[subMagicId] = skillLevel + end + end + end + end + + return XCode.Success +end + +---伙伴被动魔法集合 +local function SetPartnerPassiveMagicLevel(partnerData, levelMap) + local partnerEntity = XDataCenter.PartnerManager.CreatePartnerEntityByPartnerData(partnerData) + if not partnerEntity then + return XCode.PartnerTemplateNotFound + end + + local passiveSkillGroupEntityDic = partnerEntity:GetPassiveSkillGroupEntityDic() + for _, groupEntity in pairs(passiveSkillGroupEntityDic or {}) do + if groupEntity:GetIsCarry() then + local skillLevel = groupEntity:GetLevel() + local subMagicIds = groupEntity:GetActiveSkillSubMagicId() + for _,subMagicId in pairs(subMagicIds or {}) do + if not levelMap[subMagicId] or levelMap[subMagicId] < skillLevel then + levelMap[subMagicId] = skillLevel + end + end + end + end + + return XCode.Success +end + +--- 魔法等级 +--- 1、伙伴主动魔法加成 +--- 2、伙伴被动魔法加成 +local function GetMagicLevel(partnerData, levelMap) + local code + + code = SetPartnerMainMagicLevel(partnerData, levelMap) + if code ~= XCode.Success then + return code + end + + code = SetPartnerPassiveMagicLevel(partnerData, levelMap) + if code ~= XCode.Success then + return code + end + + return XCode.Success +end +-----------------------------------------Magic End----------------------------------------- +-----------------------------------------BornMagic Begin----------------------------------------- +---伙伴主动出生魔法集合 +local function SetPartnerMainBornMagicLevel(partnerData, levelMap) + local partnerEntity = XDataCenter.PartnerManager.CreatePartnerEntityByPartnerData(partnerData) + if not partnerEntity then + return XCode.PartnerTemplateNotFound + end + + local mainSkillGroupEntityDic = partnerEntity:GetMainSkillGroupEntityDic() + for _, groupEntity in pairs(mainSkillGroupEntityDic or {}) do + if groupEntity:GetIsCarry() then + local skillLevel = groupEntity:GetLevel() + local bornMagicIds = groupEntity:GetActiveSkillBornMagic() + for _,bornMagicId in pairs(bornMagicIds or {}) do + if not levelMap[bornMagicId] or levelMap[bornMagicId] < skillLevel then + levelMap[bornMagicId] = skillLevel + end + end + end + end + + return XCode.Success +end + +---伙伴被动出生魔法集合 +local function SetPartnerPassiveBornMagicLevel(partnerData, levelMap) + local partnerEntity = XDataCenter.PartnerManager.CreatePartnerEntityByPartnerData(partnerData) + if not partnerEntity then + return XCode.PartnerTemplateNotFound + end + + local passiveSkillGroupEntityDic = partnerEntity:GetPassiveSkillGroupEntityDic() + for _, groupEntity in pairs(passiveSkillGroupEntityDic or {}) do + if groupEntity:GetIsCarry() then + local skillLevel = groupEntity:GetLevel() + local bornMagicIds = groupEntity:GetActiveSkillBornMagic() + for _,bornMagicId in pairs(bornMagicIds or {}) do + if not levelMap[bornMagicId] or levelMap[bornMagicId] < skillLevel then + levelMap[bornMagicId] = skillLevel + end + end + end + end + + return XCode.Success +end + +--- 魔法等级 +--- 1、伙伴主动出生魔法加成 +--- 2、伙伴被动出生魔法加成 +local function GetBornMagicLevel(partnerData, levelMap) + local code + + code = SetPartnerMainBornMagicLevel(partnerData, levelMap) + if code ~= XCode.Success then + return code + end + + code = SetPartnerPassiveBornMagicLevel(partnerData, levelMap) + if code ~= XCode.Success then + return code + end + + return XCode.Success +end + +-----------------------------------------BornMagic End----------------------------------------- +local function RegisterInterfaces() + XAttribManager.RegisterPartnerNumericIdInterface(GetNumericAttribId) + XAttribManager.RegisterPartnerPromotedIdInterface(GetPromotedAttribId) + + XMagicSkillManager.RegisterPartnerSkillLevelInterface(GetSkillLevel) + XMagicSkillManager.RegisterPartnerMagicLevelInterface(GetMagicLevel) + XMagicSkillManager.RegisterPartnerBornMagicLevelInterface(GetBornMagicLevel) +end + +function XFightPartnerManager.Init() + Awake() + RegisterInterfaces() +end + +---------------------------------------客户端特有方法--------------------------------------- +local function DoGetPartnerAttribIds(partnerData, numericIds, promotedIds, trainedLevels) + GetNumericAttribId(partnerData, numericIds) + GetPromotedAttribId(partnerData, promotedIds, trainedLevels) +end + +function XFightPartnerManager.GetPartnerAttribs(partnerData, preLevel) + local numericIds = {} + local trainedLevels = {} + local promotedIds = {} + local data = XTool.Clone(partnerData) + data.Level = preLevel and preLevel or data.Level + DoGetPartnerAttribIds(data, numericIds, promotedIds, trainedLevels) + return XAttribManager.GetMergeAttribs(numericIds, promotedIds, trainedLevels) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XFightUiManager.lua b/Resources/Scripts/XManager/XFightUiManager.lua new file mode 100644 index 00000000..59d111ad --- /dev/null +++ b/Resources/Scripts/XManager/XFightUiManager.lua @@ -0,0 +1,47 @@ +local FunctionParams +local FunctionDictionary +local FunctionParamPath = "Client/Fight/LuaFunctionParams/LuaFunctionParams.tab"; + +--if not CS.XFight.Instance then +--CS.XFight.Instance.InputControl.OnOperationClick +--CS.XNpcOperationClickKey +--CS.XNpcOperationClickType +XFightUiManager = XFightUiManager or {} + +function XFightUiManager.Init() + FunctionParams = XTableManager.ReadByIntKey(FunctionParamPath, XTable.XTableLuaFunctionParams, "Id") +end +--CSharpCallLua +function XFightUiManager.DoLuaFunctionWithValue(id,value) + if not FunctionParams then + XFightUiManager.Init() + end + local funcName = FunctionParams[id].FunctionName + FunctionDictionary[funcName](id,value) +end +--CSharpCallLua +function XFightUiManager.DoLuaFunction(id) + if not FunctionParams then + XFightUiManager.Init() + end + local funcName = FunctionParams[id].FunctionName + FunctionDictionary[funcName](id) +end + +FunctionDictionary = { + ["DoNieRoleDeath"] = function(id,value) + XLog.Debug("DoNieRoleDeath", id, tostring(value)) + if XLuaUiManager.IsUiShow("UiNieREasterEgg") then + XLog.Error("界面处于展示状态,请检查行为树节点!!!") + return + end + --FunctionParams[id].Params + if value < 3 then + local isFirstDeath = value == 1 + XLuaUiManager.Open("UiNieREasterEgg", false , isFirstDeath) + else + local lastName, nowName = XDataCenter.NieRManager.GetNieREasrerEggPlayerName() + XLuaUiManager.Open("UiFightNieRTips",lastName, nowName) + end + end +} \ No newline at end of file diff --git a/Resources/Scripts/XManager/XFightWordsManager.lua b/Resources/Scripts/XManager/XFightWordsManager.lua new file mode 100644 index 00000000..b84319dd --- /dev/null +++ b/Resources/Scripts/XManager/XFightWordsManager.lua @@ -0,0 +1,147 @@ +XFightWordsManagerCreator = function() + local XFightWordsManager = {} + + local CSXScheduleManagerScheduleOnce = XScheduleManager.ScheduleOnce + local CSXScheduleManagerUnSchedule = XScheduleManager.UnSchedule + local XEventId = XEventId + local CsXGameEventManager = CS.XGameEventManager + + local TemplateId = nil + local CurrentTemplate = nil + local CurrentId = nil + local MaxId = nil + local ScheduleId = nil + local CurAudioInfo = nil + local NextTime + local PauseTime + + function XFightWordsManager.Init() + CsXGameEventManager.Instance:RegisterEvent(CS.XEventId.EVENT_FIGHT_PRE_CLEAR_UI, XFightWordsManager.OnFightExit) + end + + function XFightWordsManager.OnFightExit() + XFightWordsManager.Stop(true) + end + + function XFightWordsManager.InitData() + CurrentId = 0 + MaxId = #CurrentTemplate + end + + local PlayNextWordFunc = function() + XFightWordsManager.PlayNext() + end + + function XFightWordsManager.Run(wordsId) + if TemplateId then + XFightWordsManager.Stop(true) + end + TemplateId = wordsId + CurrentTemplate = XFightWordsConfigs.GetMovieCfg(wordsId) + if not CurrentTemplate then + XLog.Error("找不到wordsId,请检查 "..tostring(wordsId)) + return + end + XLuaUiManager.Open("UiFightWords") + XFightWordsManager.InitData() + XFightWordsManager.PlayNext() + end + + function XFightWordsManager.UnSchedule() + if ScheduleId then + CSXScheduleManagerUnSchedule(ScheduleId) + ScheduleId = nil + end + end + + function XFightWordsManager.Stop(isForce) + if TemplateId then + TemplateId = nil + CurrentTemplate = nil + CurrentId = nil + PauseTime = nil + NextTime = nil + XFightWordsManager.UnSchedule() + if isForce then + XLuaUiManager.Remove("UiFightWords") + else + XLuaUiManager.Close("UiFightWords") + end + + if CurAudioInfo then + CurAudioInfo:Stop() + CurAudioInfo = nil + end + end + end + + function XFightWordsManager.Pause() + if TemplateId then + PauseTime = CS.UnityEngine.Time.time + XFightWordsManager.UnSchedule() + + if CurAudioInfo then + CurAudioInfo:Pause() + end + end + end + + function XFightWordsManager.Resume() + if TemplateId and PauseTime and NextTime then + local duration = NextTime - PauseTime + if (duration > 0) then + duration = math.floor(duration * 1000) + ScheduleId = CSXScheduleManagerScheduleOnce(PlayNextWordFunc, duration) + end + PauseTime = nil + NextTime = nil + + if CurAudioInfo then + CurAudioInfo:Resume() + end + end + end + + -- local GetTotalDuration = function(tab) + -- local duration = 0 + -- for _, t in ipairs(tab) do + -- duration = duration + t + -- end + -- return duration + -- end + + function XFightWordsManager.PlayNext() + if not TemplateId and not CurrentTemplate then + XLog.Warning("No Runnig Fight Words") + return + end + CurrentId = CurrentId + 1 + if CurrentId > MaxId then + XFightWordsManager.Stop() + return + end + + local Template = CurrentTemplate[CurrentId] + local text = Template.Text + local duration = Template.Duration * 1000 + NextTime = CS.UnityEngine.Time.time + Template.Duration + XEventManager.DispatchEvent(XEventId.EVENT_FIGHT_WORDS_NEXT, text) + + -- 音效 + local cueId = Template.CueId + if cueId and cueId ~= 0 then + if CurAudioInfo then + CurAudioInfo:Stop() + end + CurAudioInfo = CS.XAudioManager.PlaySound(cueId) + else + CurAudioInfo = nil + end + + XFightWordsManager.UnSchedule() + ScheduleId = CSXScheduleManagerScheduleOnce(PlayNextWordFunc, duration) + end + + XFightWordsManager.Init() + return XFightWordsManager +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XFingerGuessingManager.lua b/Resources/Scripts/XManager/XFingerGuessingManager.lua new file mode 100644 index 00000000..2f8f2942 --- /dev/null +++ b/Resources/Scripts/XManager/XFingerGuessingManager.lua @@ -0,0 +1,153 @@ +--猜拳小游戏管理器 +XFingerGuessingManagerCreator = function() + local FingerGuessingManager = {} + -- 出拳种类 + FingerGuessingManager.FINGER_TYPE = { + Rock = 0, -- 石头 + Paper = 1, -- 布 + Scissors = 2, -- 剪刀 + } + -- 对局结果枚举 + FingerGuessingManager.DUEL_RESULT = { + Win = 0, -- 胜利 + Draw = 1, -- 平局 + Lose = 2, -- 失败 + } + --================ + --请求协议名称 + --================ + local REQUEST_NAMES = { --请求名称 + StartGame = "FingerGuessingGameStartStageRequest", -- 进入关卡 + OpenEyes = "FingerGuessingGameChangeCheatStatusRequest", -- 开启天眼 + FingerPlay = "FingerGuessingGamePlayerActionRequest", -- 出拳 + } + local GameControl + function FingerGuessingManager.Init() + local XGame = require("XEntity/XMiniGame/FingerGuessing/XFingerGuessingGameController") + GameControl = XGame.New() + end + --======================= + --刷新活动数据 + --@param data: { + -- int ActivityId //当前活动Id + -- List FingerGuessingStageData //已开启的关卡信息 + -- FingerGuessingCurrentStageInfo CurrentStageData //当前关卡信息 + --} + --======================= + function FingerGuessingManager.RefreshActivityData(data) + GameControl:RefreshActivityData(data) + end + --======================= + --请求出拳 + --======================= + function FingerGuessingManager.PlayFinger(fingerId) + XNetwork.Call(REQUEST_NAMES.FingerPlay, { PlayerTrick = fingerId }, function(reply) + if reply.Code ~= XCode.Success then + XUiManager.TipCode(reply.Code) + return + end + GameControl:RefreshCurrentStage(reply.CurrentStageInfo) + GameControl:RefreshStageData(reply.StageChangeData) + XEventManager.DispatchEvent(XEventId.EVENT_FINGER_GUESS_PLAY_FINGER, fingerId, reply.IsRoundWin, reply.IsStageEnd) + if reply.IsStageEnd then GameControl:SetIsGaming(false) end + end) + end + --================ + --请求开启天眼 + --================ + function FingerGuessingManager.OpenEyes(stage) + XNetwork.Call(REQUEST_NAMES.OpenEyes, { Status = not GameControl:GetIsOpenEye() }, function(reply) + if reply.Code ~= XCode.Success then + XUiManager.TipCode(reply.Code) + return + end + GameControl:SetIsOpenEye(not GameControl:GetIsOpenEye()) + XEventManager.DispatchEvent(XEventId.EVENT_FINGER_GUESS_OPEN_EYE, stage:GetId()) + end) + end + --================ + --请求开始游戏 + --================ + function FingerGuessingManager.StartGame(stage) + if stage:CheckIsFirstEntry() and not GameControl:CheckCoinEnough(stage:GetCostItemCount()) then + XUiManager.TipMsg(CS.XTextManager.GetText("FingerGuessCoinNotEnough")) + return + end + XNetwork.Call(REQUEST_NAMES.StartGame, { StageId = stage:GetStageId()}, function(reply) + if reply.Code ~= XCode.Success then + XUiManager.TipCode(reply.Code) + return + end + GameControl:RefreshCurrentStage(reply.CurrentStageData) + XEventManager.DispatchEvent(XEventId.EVENT_FINGER_GUESS_GAME_START, stage) + end) + end + --================ + --跳转到玩法 + --================ + function FingerGuessingManager.JumpTo() + if XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.FingerGuessing) then + local canGoTo, notStart = FingerGuessingManager.CheckCanGoTo() + if canGoTo then + if GameControl:GetIsGaming() then + XLuaUiManager.Open("UiFingerGuessingGame", GameControl:GetCurrentStage()) + else + XLuaUiManager.Open("UiFingerGuessingSelectStage") + end + elseif notStart then + XUiManager.TipMsg(CS.XTextManager.GetText("CommonActivityNotStart")) + else + XUiManager.TipMsg(CS.XTextManager.GetText("CommonActivityEnd")) + end + end + end + --================ + --检查是否能进入玩法 + --@return param1:是否在活动时间内(true为在活动时间内) + --@return param2:是否未开始活动(true为未开始活动) + --================ + function FingerGuessingManager.CheckCanGoTo() + local endTime = GameControl:GetActivityEndTime() + local startTime = GameControl:GetActivityStartTime() + local nowTime = XTime.GetServerNowTimestamp() + local isActivityEnd = (nowTime >= endTime) and (nowTime > startTime) + local notStart = nowTime < startTime + return not isActivityEnd, notStart + end + --================ + --获取游戏控制器 + --================ + function FingerGuessingManager.GetGameController() + return GameControl + end + --================ + --获取游戏控制器 + --================ + function FingerGuessingManager.GetStageByStageId(stageId) + GameControl:GetStageByStageId() + end + --================ + --判断是否第一次进入玩法(本地存储纪录) + --================ + function FingerGuessingManager.GetIsFirstIn() + local localData = XSaveTool.GetData("FingerGuessFirstIn" .. XPlayer.Id) + if localData == nil then + XSaveTool.SaveData("FingerGuessFirstIn".. XPlayer.Id, true) + return true + end + return false + end + FingerGuessingManager.Init() + return FingerGuessingManager +end +--======================= +--登陆通知活动数据 +--@param data: { +-- int ActivityId //当前活动Id +-- List FingerGuessingStageData //已开启的关卡信息 +-- FingerGuessingCurrentStageInfo CurrentStageData //当前关卡信息 +--} +--======================= +XRpc.NotifyFingerGuessingGameData = function(data) + XDataCenter.FingerGuessingManager.RefreshActivityData(data) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XFuBenActivityPuzzleManager.lua b/Resources/Scripts/XManager/XFuBenActivityPuzzleManager.lua new file mode 100644 index 00000000..b84b7a3e --- /dev/null +++ b/Resources/Scripts/XManager/XFuBenActivityPuzzleManager.lua @@ -0,0 +1,658 @@ +local tableInsert = table.insert +local tableSort = table.sort +local tableRemove = table.remove + +XFubenActivityPuzzleManagerCreator = function () + local XFubenActivityPuzzleManager = {} + local ActivityInfo = nil + local PuzzleTemplates = {} + local PuzzleInfos = {} + local PieceTables = {} -- 碎片表{puzzleId = {}} + local PuzzlePieceTables = {} -- 拼图方块表 {puzzleId = {}} + local GotRewardIdxTables = {} -- 获取的区域奖励Idx表 {puzzleId={}} + local GotCompleteStateTables = {} -- 全部拼图完成奖励获取表 {puzzleId = 0 or 1 or nil} + local PuzzleCompleteStateTable = {} -- 拼图完成表 + local SwitchRedPointDic = {} -- 转化按钮红点字典(0:无红点,1:有红点) + local DecryptionPasswordData = {} -- 解密密码表 + + local ACTIVITY_PUZZLE_PROTO = { + DragPuzzleActivityDataRequest = "DragPuzzleActivityDataRequest", + DragPuzzleActivityExchangePieceRequest = "DragPuzzleActivityExchangePieceRequest", + DragPuzzleActivityMovePieceRequest = "DragPuzzleActivityMovePieceRequest", + DragPuzzleActivityGetRewardRequest = "DragPuzzleActivityGetRewardRequest", + DragPuzzleActivityExchangePasswordRequest = "DragPuzzleActivityExchangePasswordRequest", + } + + function XFubenActivityPuzzleManager.Init() + XEventManager.AddEventListener(XEventId.EVENT_LOGIN_DATA_LOAD_COMPLETE, function() + local activityTemplates = XFubenActivityPuzzleConfigs.GetActivityTemplates() + local nowTime = XTime.GetServerNowTimestamp() + for _, template in ipairs(activityTemplates) do + local TimeId = template.TimeId + local startTime, endTime = XFunctionManager.GetTimeByTimeId(TimeId) + if nowTime > startTime and nowTime < endTime then + if not ActivityInfo then + ActivityInfo = XFubenActivityPuzzleConfigs.GetActivityTemplateById(template.Id) + end + if not PuzzleTemplates or #PuzzleTemplates <= 0 then + PuzzleTemplates = XFubenActivityPuzzleConfigs.GetPuzzleTemplatesByActId(template.Id) + end + if not PuzzleInfos or not next(PuzzleInfos) then + XNetwork.Call(ACTIVITY_PUZZLE_PROTO.DragPuzzleActivityDataRequest, {ActId = template.Id}, function (res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XFubenActivityPuzzleManager.HandlePuzzles(res.Puzzles) + end) + end + break + end + end + end) + end + + function XFubenActivityPuzzleManager.OpenPuzzleGame(actId) + if not ActivityInfo then + ActivityInfo = XFubenActivityPuzzleConfigs.GetActivityTemplateById(actId) + end + + if not PuzzleTemplates or #PuzzleTemplates <= 0 then + PuzzleTemplates = XFubenActivityPuzzleConfigs.GetPuzzleTemplatesByActId(actId) + end + + if not DecryptionPasswordData or not next(DecryptionPasswordData) then + XFubenActivityPuzzleManager.InitDecryptionPasswordData() + end + + XLuaUiManager.Open("UiFubenActivityPuzzle") + end + + function XFubenActivityPuzzleManager.HandlePuzzles(puzzles) + XFubenActivityPuzzleManager.InitDecryptionPasswordData() -- 根据配置初始化密码默认数据 + for _, puzzleInfo in pairs(puzzles) do + PuzzleInfos[puzzleInfo.Id] = puzzleInfo + + if not puzzleInfo.GotRewardIdxs then + GotRewardIdxTables[puzzleInfo.Id] = {} + else + GotRewardIdxTables[puzzleInfo.Id] = puzzleInfo.GotRewardIdxs + end + + PuzzleCompleteStateTable[puzzleInfo.Id] = puzzleInfo.State + GotCompleteStateTables[puzzleInfo.Id] = puzzleInfo.CompleteRewardState + + PieceTables[puzzleInfo.Id] = {} + PuzzlePieceTables[puzzleInfo.Id] = {} + + local pieces = puzzleInfo.Pieces + for _, pieceInfo in pairs(pieces) do + if pieceInfo.Idx > 0 then -- 大于0是已经拼上的碎片 + PuzzlePieceTables[puzzleInfo.Id][pieceInfo.Idx] = pieceInfo.Id + else -- 小于等于零是已经兑换没有拼的碎片 + tableInsert(PieceTables[puzzleInfo.Id], pieceInfo) + end + end + + tableSort(PieceTables[puzzleInfo.Id], function(pieceA, pieceB) + return pieceA.Idx > pieceB.Idx + end) + + -- DecryptionPasswordData[puzzleInfo.Id] = nil + if puzzleInfo.CurrentPassword and next(puzzleInfo.CurrentPassword) then -- 初始化密码数据 + DecryptionPasswordData[puzzleInfo.Id] = puzzleInfo.CurrentPassword + end + end + end + + function XFubenActivityPuzzleManager.InitDecryptionPasswordData() + local puzzleTemplates = XFubenActivityPuzzleManager.GetPuzzleTemplates() + if puzzleTemplates and next(puzzleTemplates) then + DecryptionPasswordData = {} + for _, puzzleTemplate in pairs(puzzleTemplates) do + if puzzleTemplate.PuzzleType == XFubenActivityPuzzleConfigs.PuzzleType.Decryption then + local passwordLength = XFubenActivityPuzzleConfigs.GetPuzzlePasswordLengthById(puzzleTemplate.Id) + DecryptionPasswordData[puzzleTemplate.Id] = {} + for i = 1, passwordLength do + tableInsert(DecryptionPasswordData[puzzleTemplate.Id], 0) + end + end + end + end + end + + function XFubenActivityPuzzleManager.GetPuzzleTemplates() + return PuzzleTemplates + end + + function XFubenActivityPuzzleManager.GetPuzzleTemplateByIndex(index) -- index 代表当前活动的第index个拼图 + if not PuzzleTemplates then + return nil + end + + return PuzzleTemplates[index] + end + + function XFubenActivityPuzzleManager.GetPuzzleInfos() + return PuzzleInfos + end + + function XFubenActivityPuzzleManager.GetPuzzleInfoById(id) + if not PuzzleInfos then + return {} + end + + return PuzzleInfos[id] + end + + function XFubenActivityPuzzleManager.GetActivityInfo() + return ActivityInfo + end + + function XFubenActivityPuzzleManager.GetPieceTabelById(puzzleId) + if not PieceTables[puzzleId] then + PieceTables[puzzleId] = {} + end + + return PieceTables[puzzleId] + end + + function XFubenActivityPuzzleManager.GetPuzzlePieceTabelById(puzzleId) + if not PuzzlePieceTables[puzzleId] then + PuzzlePieceTables[puzzleId] = {} + end + + return PuzzlePieceTables[puzzleId] + end + + function XFubenActivityPuzzleManager.GetGotRewardIdxTableById(puzzleId) + if not GotRewardIdxTables[puzzleId] then + GotRewardIdxTables[puzzleId] = {} + end + + return GotRewardIdxTables[puzzleId] + end + + function XFubenActivityPuzzleManager.GetPuzzleStateById(puzzleId) + if not PuzzleCompleteStateTable[puzzleId] then + return XFubenActivityPuzzleConfigs.PuzzleState.Incomplete + end + + return PuzzleCompleteStateTable[puzzleId] + end + + function XFubenActivityPuzzleManager.CheckCompleteRewardIsGot(puzzleId) + if not GotCompleteStateTables[puzzleId] then + return XFubenActivityPuzzleConfigs.CompleteRewardState.Unrewarded + end + + return GotCompleteStateTables[puzzleId] + end + + function XFubenActivityPuzzleManager.GetPuzzlePieceByIndex(puzzleId, index) + local puzzlePieceTable = XFubenActivityPuzzleManager.GetPuzzlePieceTabelById(puzzleId) + return puzzlePieceTable[index] + end + + function XFubenActivityPuzzleManager.ExchangePiece(puzzleId) + if not ActivityInfo then + return + end + + local puzzleTemplate = XFubenActivityPuzzleConfigs.GetPuzzleTemplateById(puzzleId) + if not puzzleTemplate then + return + end + + if XFubenActivityPuzzleManager.CheckIsSwitchOutPiece(puzzleTemplate) then -- 检查是否已经把全部碎片换完了 + XUiManager.TipText("DragPuzzleActivityAllPieceTaked") + return + end + + local itemId = ActivityInfo.ItemId + if not XDataCenter.ItemManager.CheckItemCountById(itemId, puzzleTemplate.PieceItemCount) then -- 检查兑换碎片的道具是否充足 + XUiManager.TipText("DragPuzzleActivityItemNotEnough") + return + end + + XNetwork.Call(ACTIVITY_PUZZLE_PROTO.DragPuzzleActivityExchangePieceRequest, {PuzzleId = puzzleTemplate.Id}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + if not PieceTables[res.PuzzleId] then + PieceTables[res.PuzzleId] = {} + end + + if PieceTables[res.PuzzleId] then -- 校验是否发送了相同碎片 + for _, pieceInfo in pairs(PieceTables[res.PuzzleId]) do + if pieceInfo.Id == res.NewPiece.Id then + XLog.Error("CurrentPieceTable:", PieceTables[res.PuzzleId], "ServerResponse:", res) + XUiManager.TipError(CS.XTextManager.GetText("DragPuzzleActivityExchangePieceError")) + return + end + end + end + + tableInsert(PieceTables[res.PuzzleId], res.NewPiece) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_DRAG_PUZZLE_GAME_GET_PIECE, res.PuzzleId) + XEventManager.DispatchEvent(XEventId.EVENT_DRAG_PUZZLE_GAME_GET_PIECE) + end) + end + + function XFubenActivityPuzzleManager.CheckIsSwitchOutPiece(puzzleTemplate) + if PieceTables[puzzleTemplate.Id] and PuzzlePieceTables[puzzleTemplate.Id] then + local pieceCount = XTool.GetTableCount(PieceTables[puzzleTemplate.Id]) + local puzzlePieceCount = XTool.GetTableCount(PuzzlePieceTables[puzzleTemplate.Id]) + if (pieceCount + puzzlePieceCount) >= (puzzleTemplate.RowSize * puzzleTemplate.ColSize) then -- 检查是否已经把全部碎片换完了 + return true + end + end + end + + function XFubenActivityPuzzleManager.CheckAreaRewardCanTake(puzzleId, index) -- 奖励的index + local needBlockStr = XFubenActivityPuzzleConfigs.GetPuzzleTemplateById(puzzleId).RewardPiecesStr[index] + local needBlockArr = string.ToIntArray(needBlockStr) + for _, pieceIndex in pairs(needBlockArr) do + if not XFubenActivityPuzzleManager.CheckPieceIsCorrect(puzzleId, pieceIndex) then + return false + end + end + + return true + end + + function XFubenActivityPuzzleManager.CheckPieceIsCorrect(puzzleId, index) -- 位置的index 1-15 + local puzzlePieceTable = XFubenActivityPuzzleManager.GetPuzzlePieceTabelById(puzzleId) + local curIndexPieceId = puzzlePieceTable[index] + if not curIndexPieceId then + return false + else + local correctIdx = XFubenActivityPuzzleConfigs.GetPieceCorrectIdxById(curIndexPieceId) + if correctIdx ~= index then + return false + else + return true + end + end + end + + function XFubenActivityPuzzleManager.GetPuzzlePieceSuccessCount(puzzleId) + local puzzlePieceTable = XFubenActivityPuzzleManager.GetPuzzlePieceTabelById(puzzleId) + local count = 0 + for index, info in pairs(puzzlePieceTable) do + if XFubenActivityPuzzleManager.CheckPieceIsCorrect(puzzleId, index) then + count = count + 1 + end + end + return count + end + + function XFubenActivityPuzzleManager.CheckPuzzleIsOpen(index) + if not PuzzleInfos or not next(PuzzleInfos) then + return index == 1 + else + if index == 1 then + return true + else + local lastPuzzleState = XFubenActivityPuzzleManager.GetPuzzleStateById(PuzzleTemplates[index-1].Id) + return (lastPuzzleState == XFubenActivityPuzzleConfigs.PuzzleState.Complete) + end + end + end + + function XFubenActivityPuzzleManager.MovePiece(puzzleId, pieceId, targetIndex, cb) + XNetwork.Call(ACTIVITY_PUZZLE_PROTO.DragPuzzleActivityMovePieceRequest,{PuzzleId = puzzleId, PieceId = pieceId, TargetIdx = targetIndex}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_DRAG_PUZZLE_GAME_PUZZLE_CHANGED, puzzleId) -- 报错根据数据还原界面 + return + end + + if cb then + cb(res) + end + end) + end + + function XFubenActivityPuzzleManager.GetFirstPiece(puzzleId) + if not PieceTables[puzzleId] or #PieceTables[puzzleId] <= 0 then + return false, nil + end + + return true, PieceTables[puzzleId][#PieceTables[puzzleId]] + end + + function XFubenActivityPuzzleManager.MovePieceFormPieceTable(puzzleId, targetIndex) + if not PieceTables[puzzleId] or #PieceTables[puzzleId] <= 0 then -- 检查待拼的碎片列表是否有碎片 + return + end + + if not PuzzlePieceTables[puzzleId] then + PuzzlePieceTables[puzzleId] = {} + return + end + + if PuzzlePieceTables[puzzleId][targetIndex] then -- 检查即将下落的拼图格子是否有碎片(从碎片列表拿出的只能放在空格子) + XUiManager.TipText("DragPuzzleActivityTheBlockHasPiece") + return + end + + local pieceInfo = PieceTables[puzzleId][#PieceTables[puzzleId]] + + XFubenActivityPuzzleManager.MovePiece(puzzleId, pieceInfo.Id, targetIndex, function(res) + local changedPieces = res.ChangedPieces + for _, pieceInfo in pairs(changedPieces) do + PuzzlePieceTables[res.PuzzleId][pieceInfo.Idx] = pieceInfo.Id + end + tableRemove(PieceTables[res.PuzzleId]) + if not PuzzleInfos[res.PuzzleId] then + PuzzleInfos[res.PuzzleId] = {} + end + PuzzleCompleteStateTable[res.PuzzleId] = res.PuzzleState + CsXGameEventManager.Instance:Notify(XEventId.EVENT_DRAG_PUZZLE_GAME_PUZZLE_CHANGED, res.PuzzleId, targetIndex) + XEventManager.DispatchEvent(XEventId.EVENT_DRAG_PUZZLE_GAME_PUZZLE_CHANGED) + if res.PuzzleState == XFubenActivityPuzzleConfigs.PuzzleState.Complete then + CsXGameEventManager.Instance:Notify(XEventId.EVENT_DRAG_PUZZLE_GAME_PUZZLE_COMPLETE, res.PuzzleId) + XEventManager.DispatchEvent(XEventId.EVENT_DRAG_PUZZLE_GAME_PUZZLE_COMPLETE) + elseif res.PuzzleState == XFubenActivityPuzzleConfigs.PuzzleState.PuzzleCompleteButNotDecryption then + CsXGameEventManager.Instance:Notify(XEventId.EVENT_DRAG_PUZZLE_GAME_PUZZLE_DECRYPTION, res.PuzzleId) + end + end) + end + + function XFubenActivityPuzzleManager.MovePieceFormPuzzle(puzzleId, pieceId, pieceIndex, targetIndex) + if pieceIndex == targetIndex then -- 放入的位置是原来的位置 + return + CsXGameEventManager.Instance:Notify(XEventId.EVENT_DRAG_PUZZLE_GAME_PUZZLE_CHANGED, puzzleId, targetIndex) + end + + if XFubenActivityPuzzleManager.CheckPieceIsCorrect(puzzleId, targetIndex) then -- 检查该碎片是否是正确的(正确的不能被拿起) + return + end + + if PuzzlePieceTables[puzzleId][targetIndex] and XFubenActivityPuzzleManager.CheckPieceIsCorrect(puzzleId, targetIndex) then -- 检查交换的位置是否已经放入正确的碎片 + XUiManager.TipText("DragPuzzleActivityTheBlockHasCorrectPiece") + return + end + + XFubenActivityPuzzleManager.MovePiece(puzzleId, pieceId, targetIndex, function(res) + local changedPieces = res.ChangedPieces + PuzzlePieceTables[res.PuzzleId][pieceIndex] = nil + for _, pieceInfo in pairs(changedPieces) do + PuzzlePieceTables[res.PuzzleId][pieceInfo.Idx] = pieceInfo.Id + end + + if not PuzzleInfos[res.PuzzleId] then + PuzzleInfos[res.PuzzleId] = {} + end + PuzzleCompleteStateTable[res.PuzzleId] = res.PuzzleState + CsXGameEventManager.Instance:Notify(XEventId.EVENT_DRAG_PUZZLE_GAME_PUZZLE_CHANGED, res.PuzzleId, targetIndex) + XEventManager.DispatchEvent(XEventId.EVENT_DRAG_PUZZLE_GAME_PUZZLE_CHANGED) + if res.PuzzleState == XFubenActivityPuzzleConfigs.PuzzleState.Complete then + CsXGameEventManager.Instance:Notify(XEventId.EVENT_DRAG_PUZZLE_GAME_PUZZLE_COMPLETE, res.PuzzleId) + XEventManager.DispatchEvent(XEventId.EVENT_DRAG_PUZZLE_GAME_PUZZLE_COMPLETE) + elseif res.PuzzleState == XFubenActivityPuzzleConfigs.PuzzleState.PuzzleCompleteButNotDecryption then + CsXGameEventManager.Instance:Notify(XEventId.EVENT_DRAG_PUZZLE_GAME_PUZZLE_DECRYPTION, res.PuzzleId) + end + end) + end + + function XFubenActivityPuzzleManager.GetReward(puzzleId, index) + if not XFubenActivityPuzzleManager.CheckAreaRewardCanTake(puzzleId ,index) then + XUiManager.TipText("DragPuzzleActivityCanTakeReward") + return + end + + if XFubenActivityPuzzleManager.IsRewardHasTaked(puzzleId, index) then + return + end + + XNetwork.Call(ACTIVITY_PUZZLE_PROTO.DragPuzzleActivityGetRewardRequest,{PuzzleId = puzzleId, RewardIdx = index}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local gotRewardIdxs = res.GotRewardIdxs + for _, rewardIdx in pairs(gotRewardIdxs) do + tableInsert(GotRewardIdxTables[res.PuzzleId], rewardIdx) + end + + GotCompleteStateTables[res.PuzzleId] = res.CompleteRewardState + + local rewardGoods = res.RewardGoods + XUiManager.OpenUiObtain(rewardGoods, CS.XTextManager.GetText("Award")) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_DRAG_PUZZLE_GAME_GOT_REWARD, res.PuzzleId) + end) + end + + function XFubenActivityPuzzleManager.IsRewardHasTaked(puzzleId, index) + local gotRewardIdxTable = XFubenActivityPuzzleManager.GetGotRewardIdxTableById(puzzleId) + for _, idx in pairs(gotRewardIdxTable) do + if idx == index then + return true + end + end + + return false + end + + function XFubenActivityPuzzleManager.FindDefaultSelectTabIndex() + for index, template in ipairs(PuzzleTemplates) do + if not GotCompleteStateTables[template.Id] or GotCompleteStateTables[template.Id] == XFubenActivityPuzzleConfigs.CompleteRewardState.Unrewarded then + return index + end + end + + return #PuzzleTemplates + end + + function XFubenActivityPuzzleManager.CheckSwitchRedPoint() + local hasRed = false + SwitchRedPointDic = {} + for index, template in pairs(PuzzleTemplates) do + if XFubenActivityPuzzleManager.CheckPuzzleIsOpen(index) + and XFubenActivityPuzzleManager.GetPuzzleStateById(template.Id) == XFubenActivityPuzzleConfigs.PuzzleState.Incomplete + and not XFubenActivityPuzzleManager.CheckIsSwitchOutPiece(template) + and XDataCenter.ItemManager.CheckItemCountById(ActivityInfo.ItemId, template.PieceItemCount) then + SwitchRedPointDic[template.Id] = 1 + hasRed = true + else + SwitchRedPointDic[template.Id] = 0 + end + end + return hasRed + end + + function XFubenActivityPuzzleManager.CheckHasSwitchRedPointById(puzzleId) + local puzzleTemplate = XFubenActivityPuzzleConfigs.GetPuzzleTemplateById(puzzleId) + if not puzzleTemplate then + return false + end + + if not XFubenActivityPuzzleManager.CheckIsSwitchOutPiece(puzzleTemplate) and + XDataCenter.ItemManager.CheckItemCountById(ActivityInfo.ItemId, puzzleTemplate.PieceItemCount) then + return true + end + + return false + end + + function XFubenActivityPuzzleManager.CheckAwardRedPoint() + for index, template in pairs(PuzzleTemplates) do + if XFubenActivityPuzzleManager.CheckPuzzleIsOpen(index) then + if XFubenActivityPuzzleManager.GetPuzzleStateById(template.Id) == XFubenActivityPuzzleConfigs.PuzzleState.Incomplete then + local rewardIds = template.RewardId + for index, _ in ipairs(rewardIds) do + if XFubenActivityPuzzleManager.CheckAreaRewardCanTake(template.Id, index) and not XFubenActivityPuzzleManager.IsRewardHasTaked(template.Id, index) then + return true + end + end + elseif XFubenActivityPuzzleManager.GetPuzzleStateById(template.Id) == XFubenActivityPuzzleConfigs.PuzzleState.Complete then + if XFubenActivityPuzzleManager.CheckCompleteRewardIsGot(template.Id) == XPuzzleActivityConfigs.PuzzleRewardState.Unrewarded then + return true + end + end + end + end + end + + function XFubenActivityPuzzleManager.CheckTabRedPointByIndex(index) + local puzzleTmp = XFubenActivityPuzzleManager.GetPuzzleTemplateByIndex(index) + if not XFubenActivityPuzzleManager.CheckPuzzleIsOpen(index) then + return false + end + + if XFubenActivityPuzzleManager.GetPuzzleStateById(puzzleTmp.Id) == XFubenActivityPuzzleConfigs.PuzzleState.Incomplete then -- 检测奖励 + local rewardIds = puzzleTmp.RewardId + for index, _ in ipairs(rewardIds) do + if XFubenActivityPuzzleManager.CheckAreaRewardCanTake(puzzleTmp.Id, index) and not XFubenActivityPuzzleManager.IsRewardHasTaked(puzzleTmp.Id, index) then + return true + end + end + elseif XFubenActivityPuzzleManager.GetPuzzleStateById(puzzleTmp.Id) == XFubenActivityPuzzleConfigs.PuzzleState.Complete then + if XFubenActivityPuzzleManager.CheckCompleteRewardIsGot(puzzleTmp.Id) == XPuzzleActivityConfigs.PuzzleRewardState.Unrewarded then + return true + end + end + + if XFubenActivityPuzzleManager.CheckHasSwitchRedPointById(puzzleTmp.Id) then -- 检测兑换按钮 + return true + end + + if XFubenActivityPuzzleManager.CheckVideoRedPoint(puzzleTmp.Id) then -- 检测剧情 + return true + end + + if XFubenActivityPuzzleManager.CheckDecryptionRedPoint(puzzleTmp.Id) then -- 检测是否可以解密 + return true + end + + return false + end + + function XFubenActivityPuzzleManager.CheckVideoRedPoint(puzzleId) + local puzzleTemplate = XFubenActivityPuzzleConfigs.GetPuzzleTemplateById(puzzleId) + if not puzzleTemplate.CompleteStoryId or puzzleTemplate.CompleteStoryId == "" then + return false + end + + if XFubenActivityPuzzleManager.CheckCompleteRewardIsGot(puzzleId) == XPuzzleActivityConfigs.PuzzleRewardState.Unrewarded then + return false + end + + local isPlayedVideo = XSaveTool.GetData(string.format("%s%s%s", XPlayer.Id, XFubenActivityPuzzleConfigs.PLAY_VIDEO_STATE_KEY ,puzzleId)) + if isPlayedVideo and isPlayedVideo == XFubenActivityPuzzleConfigs.PlayVideoState.Played then + return false + end + + return true + end + + function XFubenActivityPuzzleManager.CheckAllVideoRedPoint() + for _, template in pairs(PuzzleTemplates) do + if XFubenActivityPuzzleManager.CheckVideoRedPoint(template.Id) then + return true + end + end + + return false + end + + function XFubenActivityPuzzleManager.CheckDecryptionRedPoint(puzzleId) + if not puzzleId then + return false + end + + if XFubenActivityPuzzleManager.GetPuzzleStateById(puzzleId) == XFubenActivityPuzzleConfigs.PuzzleState.PuzzleCompleteButNotDecryption then + return true + end + + return false + end + + function XFubenActivityPuzzleManager.CheckAllPuzzleDecryptionRedPoint() + for _, template in pairs(PuzzleTemplates) do + if XFubenActivityPuzzleManager.CheckDecryptionRedPoint(template.Id) then + return true + end + end + + return false + end + + function XFubenActivityPuzzleManager.GetPasswordByPuzzleId(puzzleId) + if not puzzleId then + XLog.Error("PuzzleId or Index Can't Be Nil") + return nil + end + + if not DecryptionPasswordData[puzzleId] then + XLog.Error("Can't Find Data DecryptionPasswordData By PuzzleId:"..puzzleId) + return nil + end + + return DecryptionPasswordData[puzzleId] + end + + function XFubenActivityPuzzleManager.SetPasswordByPuzzleId(puzzleId, password) + if not puzzleId then + XLog.Error("PuzzleId Can't Be Nil") + return + end + + if not DecryptionPasswordData[puzzleId] then + XLog.Error("Can't Find Data DecryptionPasswordData By PuzzleId:"..puzzleId) + return + end + + DecryptionPasswordData[puzzleId] = password + end + + function XFubenActivityPuzzleManager.ExchangePassword(puzzleId, password) + if not puzzleId then + XLog.Error("PuzzleId Can't Be nil") + return + end + + if not password or not next(password) then + XLog.Error("Password is Nil or Empty Table") + return + end + XNetwork.Call(ACTIVITY_PUZZLE_PROTO.DragPuzzleActivityExchangePasswordRequest, {PuzzleId = puzzleId, Password = password}, function (res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + XFubenActivityPuzzleManager.SetPasswordByPuzzleId(puzzleId, password) + PuzzleCompleteStateTable[puzzleId] = res.PuzzleState + + if PuzzleCompleteStateTable[puzzleId] == XFubenActivityPuzzleConfigs.PuzzleState.PuzzleCompleteButNotDecryption then + CsXGameEventManager.Instance:Notify(XEventId.EVENT_DRAG_PUZZLE_GAME_PUZZLE_CHECK_WORD_ERROR, puzzleId) + elseif PuzzleCompleteStateTable[puzzleId] == XFubenActivityPuzzleConfigs.PuzzleState.Complete then + CsXGameEventManager.Instance:Notify(XEventId.EVENT_DRAG_PUZZLE_GAME_PUZZLE_COMPLETE, puzzleId) + XEventManager.DispatchEvent(XEventId.EVENT_DRAG_PUZZLE_GAME_PUZZLE_COMPLETE) + end + end) + end + + function XFubenActivityPuzzleManager.HitPasswordMessage(puzzleId) + local hitCount = XSaveTool.GetData(string.format("%s%s%s", XFubenActivityPuzzleConfigs.PASSWORD_HIT_MESSAGE_COUNT, XPlayer.Id, puzzleId)) or 0 + hitCount = hitCount + 1 + local messageList = XFubenActivityBossSingleConfigs.GetPuzzlePasswordHintMessage(puzzleId) + if messageList and next(messageList) then + if messageList[hitCount] then + XUiManager.TipError(messageList[hitCount]) + else + XUiManager.TipError(messageList[#messageList]) + end + XSaveTool.SaveData(string.format("%s%s%s", XFubenActivityPuzzleConfigs.PASSWORD_HIT_MESSAGE_COUNT, XPlayer.Id, puzzleId), hitCount) + end + end + + XFubenActivityPuzzleManager.Init() + return XFubenActivityPuzzleManager +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XFubenActivityBossSingleManager.lua b/Resources/Scripts/XManager/XFubenActivityBossSingleManager.lua new file mode 100644 index 00000000..968ec0e1 --- /dev/null +++ b/Resources/Scripts/XManager/XFubenActivityBossSingleManager.lua @@ -0,0 +1,252 @@ +XFubenActivityBossSingleManagerCreator = function() + local pairs = pairs + local tableInsert = table.insert + local ParseToTimestamp = XTime.ParseToTimestamp + + local CurActivityId = 0 --当前活动Id + local SectionId = 0 --根据等极段开放的活动章节 + local Schedule = 0 --通关进度 + local StarRewardIds = {} --已经领取的列表,游戏刚进来的时候初始化 + local StageInfos = {} + + local XFubenActivityBossSingleManager = {} + + local METHOD_NAME = { + ReceiveTreasureReward = "BossActivityStarRewardRequest", + } + + function XFubenActivityBossSingleManager.GetActivitySections() + local sections = {} + + if XFubenActivityBossSingleManager.IsOpen() then + local section = { + Type = XDataCenter.FubenManager.ChapterType.ActivityBossSingle, + Id = SectionId + } + tableInsert(sections, section) + end + + return sections + end + + function XFubenActivityBossSingleManager.InitStageInfo() + local sectionCfgs = XFubenActivityBossSingleConfigs.GetSectionCfgs() + for _, sectionCfg in pairs(sectionCfgs) do + for _, challengeId in pairs(sectionCfg.ChallengeId) do + local stageId = XFubenActivityBossSingleConfigs.GetStageId(challengeId) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + stageInfo.Type = XDataCenter.FubenManager.StageType.ActivityBossSingle + end + end + end + + function XFubenActivityBossSingleManager.GetSectionStageIdList(sectionId) + local stageIdList = {} + + local sectionCfg = XFubenActivityBossSingleConfigs.GetSectionCfg(sectionId) + for index, challengeId in pairs(sectionCfg.ChallengeId) do + local stageId = XFubenActivityBossSingleConfigs.GetStageId(challengeId) + stageIdList[index] = stageId + end + + return stageIdList + end + + --刷新通关记录 + function XFubenActivityBossSingleManager.IsChallengeUnlock(challengeId) + local orderId = XFubenActivityBossSingleConfigs.GetChallengeOrderId(challengeId) + return orderId <= Schedule + 1 + end + + function XFubenActivityBossSingleManager.IsChallengeUnlockByStageId(stageId) + local challengeId = XFubenActivityBossSingleConfigs.GetChanllengeIdByStageId(stageId) + return XFubenActivityBossSingleManager.IsChallengeUnlock(challengeId) + end + + function XFubenActivityBossSingleManager.IsChallengePassed(challengeId) + local orderId = XFubenActivityBossSingleConfigs.GetChallengeOrderId(challengeId) + return orderId <= Schedule + end + + function XFubenActivityBossSingleManager.IsChallengePassedByStageId(stageId) + local challengeId = XFubenActivityBossSingleConfigs.GetChanllengeIdByStageId(stageId) + return XFubenActivityBossSingleManager.IsChallengePassed(challengeId) + end + + function XFubenActivityBossSingleManager.GetPreChallengeId(sectionId, challengeId) + local sectionCfg = XFubenActivityBossSingleConfigs.GetSectionCfg(sectionId) + local orderId = XFubenActivityBossSingleConfigs.GetChallengeOrderId(challengeId) + return sectionCfg.ChallengeId[orderId - 1] + end + + function XFubenActivityBossSingleManager.GetCurSectionId() + return SectionId + end + + function XFubenActivityBossSingleManager.GetFinishCount() + return Schedule + end + + function XFubenActivityBossSingleManager.GetActivityBeginTime() + return XFubenActivityBossSingleConfigs.GetActivityBeginTime(CurActivityId) + end + + function XFubenActivityBossSingleManager.GetFightEndTime() + return XFubenActivityBossSingleConfigs.GetFightEndTime(CurActivityId) + end + + function XFubenActivityBossSingleManager.GetActivityEndTime() + return XFubenActivityBossSingleConfigs.GetActivityEndTime(CurActivityId) + end + + function XFubenActivityBossSingleManager.IsOpen() + local nowTime = XTime.GetServerNowTimestamp() + local beginTime = XFubenActivityBossSingleManager.GetActivityBeginTime() + local endTime = XFubenActivityBossSingleManager.GetActivityEndTime() + return beginTime <= nowTime and nowTime < endTime and SectionId ~= 0 + end + + function XFubenActivityBossSingleManager.IsStatusEqualFightEnd() + local now = XTime.GetServerNowTimestamp() + local fightEndTime = XFubenActivityBossSingleManager.GetFightEndTime() + local endTime = XFubenActivityBossSingleManager.GetActivityEndTime() + return fightEndTime <= now and now < endTime + end + + function XFubenActivityBossSingleManager.OnActivityEnd() + if CS.XFight.IsRunning or XLuaUiManager.IsUiLoad("UiLoading") then + return + end + XUiManager.TipText("ActivityBossSingleOver") + XLuaUiManager.RunMain() + end + + --获取当前活动Id + function XFubenActivityBossSingleManager.GetCurActivityId() + return CurActivityId + end + + --根据关卡个数获得总星数 + function XFubenActivityBossSingleManager.GetAllStarsCount() + return 3 * XFubenActivityBossSingleConfigs.GetChallengeCount(SectionId) + end + + --获取当前星数 + function XFubenActivityBossSingleManager.GetCurStarsCount() + local curStatsCount = 0 + + local stageIds = XDataCenter.FubenActivityBossSingleManager.GetSectionStageIdList(SectionId) + for i = 1, #stageIds do + curStatsCount = curStatsCount + StageInfos[stageIds[i]].Stars + end + + return curStatsCount + end + + --获取每个副本的星星信息 + function XFubenActivityBossSingleManager.GetStageStarMap(stageId) + return StageInfos[stageId].StarsMap + end + + --判断当前红点 + function XFubenActivityBossSingleManager.CheckRedPoint() + local curStarCount = XFubenActivityBossSingleManager.GetCurStarsCount() + local starRewardTemplates = XFubenActivityBossSingleConfigs.GetStarRewardTemplates() + local bossSectionRewardIds = XFubenActivityBossSingleConfigs.GetBossSectionRewardIds(SectionId) + for _, RewardId in pairs(bossSectionRewardIds) do + if StarRewardIds[RewardId] == nil then + if curStarCount >= starRewardTemplates[RewardId].RequireStar then + return true + end + end + end + return false + end + + --判断是不是已经全部领取了 + function XFubenActivityBossSingleManager.CheckIsAllFinish() + local bossSectionRewardIds = XFubenActivityBossSingleConfigs.GetBossSectionRewardIds(SectionId) + for _, v in pairs(bossSectionRewardIds) do + if not StarRewardIds[v] then + return false + end + end + return true + end + + function XFubenActivityBossSingleManager.CheckRewardIsFinish(Id) + if StarRewardIds[Id] == nil then + return false + end + return true + end + + --解析星星数 + local GetStarsCount = function(starsMark) + local count = (starsMark & 1) + (starsMark & 2 > 0 and 1 or 0) + (starsMark & 4 > 0 and 1 or 0) + local map = {(starsMark & 1) > 0, (starsMark & 2) > 0, (starsMark & 4) > 0 } + return count, map + end + + function XFubenActivityBossSingleManager.NotifyBossActivityData(data) + CurActivityId = data.ActivityId + SectionId = data.SectionId + Schedule = data.Schedule + for _, v in pairs(data.StarRewardIds) do + if StarRewardIds[v] == nil then + StarRewardIds[v] = v + end + end + + local stageIds = XDataCenter.FubenActivityBossSingleManager.GetSectionStageIdList(SectionId) + for i = 1, #stageIds do + local starsMark + if data.StageStarInfos[i] and data.StageStarInfos[i].StarsMark then + starsMark = data.StageStarInfos[i].StarsMark + else + starsMark = 0 + end + local stageInfoTab = {} + stageInfoTab.Stars, stageInfoTab.StarsMap = GetStarsCount(starsMark) + StageInfos[stageIds[i]] = stageInfoTab + end + end + + function XFubenActivityBossSingleManager.NotifyBossStageStarData(data) + local stageInfoTab = {} + stageInfoTab.Stars, stageInfoTab.StarsMap = GetStarsCount(data.StarInfo.StarsMark) + StageInfos[data.StarInfo.StageId] = stageInfoTab + end + + --领奖 + function XFubenActivityBossSingleManager.ReceiveTreasureReward(Id, cb) + local req = { Id = Id } + XNetwork.Call(METHOD_NAME.ReceiveTreasureReward, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XFubenActivityBossSingleManager.SyncTreasureStage(Id) + if cb then + cb(res.RewardGoodsList) + end + end) + end + + --同步领奖状态 + function XFubenActivityBossSingleManager.SyncTreasureStage(Id) + if StarRewardIds[Id] == nil then + StarRewardIds[Id] = Id + end + end + + return XFubenActivityBossSingleManager +end + +XRpc.NotifyBossActivityData = function(data) + XDataCenter.FubenActivityBossSingleManager.NotifyBossActivityData(data) +end + +XRpc.NotifyBossStageStarData = function(data) + XDataCenter.FubenActivityBossSingleManager.NotifyBossStageStarData(data) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XFubenActivityBranchManager.lua b/Resources/Scripts/XManager/XFubenActivityBranchManager.lua new file mode 100644 index 00000000..10fe1ddb --- /dev/null +++ b/Resources/Scripts/XManager/XFubenActivityBranchManager.lua @@ -0,0 +1,186 @@ +XFubenActivityBranchManagerCreator = function() + local pairs = pairs + local tableInsert = table.insert + local ParseToTimestamp = XTime.ParseToTimestamp + + local CurActivityId = XFubenActivityBranchConfigs.GetDefaultActivityId() + + local SectionId = 0 + local ScheduleDic = {} --章节Id-通关进度Dic + local SelectDifficult = false --记录上次是否选中挑战难度 + + local XFubenActivityBranchManager = {} + + XFubenActivityBranchManager.BranchType = { + Normal = 1, + Difficult = 2 + } + + function XFubenActivityBranchManager.Init() + XEventManager.AddEventListener(XEventId.EVENT_FUBEN_REFRESH_STAGE_DATA, XFubenActivityBranchManager.HandlerFightResult) + end + + function XFubenActivityBranchManager.HandlerFightResult() + XFubenActivityBranchManager.RefreshStagePassed() + end + + function XFubenActivityBranchManager.GetActivitySections() + local sections = {} + + if XFubenActivityBranchManager.IsOpen() then + local section = { + Type = XDataCenter.FubenManager.ChapterType.ActivtityBranch, + Id = SectionId + } + tableInsert(sections, section) + end + + return sections + end + + function XFubenActivityBranchManager.InitStageInfo() + local sectionCfgs = XFubenActivityBranchConfigs.GetSectionCfgs() + + for _, sectionCfg in pairs(sectionCfgs) do + local normalChapterCfg = XFubenActivityBranchConfigs.GetChapterCfg(sectionCfg.NormalId) + for _, stageId in pairs(normalChapterCfg.StageId) do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + stageInfo.Type = XDataCenter.FubenManager.StageType.ActivtityBranch + end + + local difficultChapterCfg = XFubenActivityBranchConfigs.GetChapterCfg(sectionCfg.DifficultyId) + for _, stageId in pairs(difficultChapterCfg.StageId) do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + stageInfo.Type = XDataCenter.FubenManager.StageType.ActivtityBranch + end + end + end + + --刷新通关记录 + function XFubenActivityBranchManager.RefreshStagePassed() + for chapterId, schedule in pairs(ScheduleDic) do + local chapterCfg = XFubenActivityBranchConfigs.GetChapterCfg(chapterId) + for index, stageId in pairs(chapterCfg.StageId) do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + if index <= schedule then + stageInfo.Passed = true + else + stageInfo.Passed = false + end + + if index <= schedule + 1 then + stageInfo.Unlock = true + stageInfo.IsOpen = true + else + stageInfo.IsOpen = false + end + end + end + end + + function XFubenActivityBranchManager.SelectDifficult(selectDifficult) + SelectDifficult = selectDifficult + end + + function XFubenActivityBranchManager.IsSelectDifficult() + return SelectDifficult + end + + function XFubenActivityBranchManager.GetCurSectionId() + return SectionId + end + + function XFubenActivityBranchManager.GetCurChapterId(sectionId) + local sectionCfg = XFubenActivityBranchConfigs.GetSectionCfg(sectionId) + return XFubenActivityBranchManager.IsSelectDifficult() and sectionCfg.DifficultyId or sectionCfg.NormalId + end + + function XFubenActivityBranchManager.GetChapterFinishCount(chapterId) + return ScheduleDic[chapterId] + end + + function XFubenActivityBranchManager.GetChapterMoveStageIndex(chapterId) + if not chapterId then return end + local chapterCfg = XFubenActivityBranchConfigs.GetChapterCfg(chapterId) + return chapterCfg and chapterCfg.MoveStageIndex + end + + function XFubenActivityBranchManager.GetChapterDatumLinePrecent(chapterId) + if not chapterId then return end + local chapterCfg = XFubenActivityBranchConfigs.GetChapterCfg(chapterId) + return chapterCfg and chapterCfg.DatumLinePrecent + end + + function XFubenActivityBranchManager.GetActivityBeginTime() + return XFubenActivityBranchConfigs.GetActivityBeginTime(CurActivityId) + end + + function XFubenActivityBranchManager.GetActivityChallengeBeginTime() + return XFubenActivityBranchConfigs.GetChallengeBeginTime(CurActivityId) + end + + function XFubenActivityBranchManager.GetFightEndTime() + return XFubenActivityBranchConfigs.GetFightEndTime(CurActivityId) + end + + function XFubenActivityBranchManager.GetActivityEndTime() + return XFubenActivityBranchConfigs.GetActivityEndTime(CurActivityId) + end + + function XFubenActivityBranchManager.IsStatusEqualFightEnd() + local now = XTime.GetServerNowTimestamp() + local fightEndTime = XFubenActivityBranchManager.GetFightEndTime() + local endTime = XFubenActivityBranchManager.GetActivityEndTime() + return fightEndTime <= now and now < endTime + end + + function XFubenActivityBranchManager.IsStatusEqualChallengeBegin() + local now = XTime.GetServerNowTimestamp() + local challengeBeginTime = XFubenActivityBranchManager.GetActivityChallengeBeginTime() + local endTime = XFubenActivityBranchManager.GetActivityEndTime() + return challengeBeginTime <= now and now < endTime + end + + function XFubenActivityBranchManager.IsOpen() + local nowTime = XTime.GetServerNowTimestamp() + local beginTime = XFubenActivityBranchManager.GetActivityBeginTime() + local endTime = XFubenActivityBranchManager.GetActivityEndTime() + return beginTime <= nowTime and nowTime < endTime and SectionId ~= 0 + end + + function XFubenActivityBranchManager.OnActivityEnd() + if CS.XFight.IsRunning or XLuaUiManager.IsUiLoad("UiLoading") then + return + end + XUiManager.TipText("ActivityBranchOver") + XLuaUiManager.RunMain() + end + + function XFubenActivityBranchManager.NotifyBranchData(data) + CurActivityId = data.ActivityId + SectionId = data.SectionId + + for _, branchChallengeInfo in pairs(data.ChallengeInfos) do + ScheduleDic[branchChallengeInfo.Id] = branchChallengeInfo.Schedule + end + + XFubenActivityBranchManager.RefreshStagePassed() + end + + function XFubenActivityBranchManager.CheckActivityCondition(sectionId) + local sectionCfg = XFubenActivityBranchConfigs.GetSectionCfg(sectionId) + local chapterCfg = XFubenActivityBranchConfigs.GetChapterCfg(sectionCfg.DifficultyId) + local conditionId = chapterCfg.OpenCondition + if conditionId ~= 0 then + return XConditionManager.CheckCondition(conditionId) + end + return true + end + + XFubenActivityBranchManager.Init() + return XFubenActivityBranchManager +end + +XRpc.NotifyBranchData = function(data) + XDataCenter.FubenActivityBranchManager.NotifyBranchData(data) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XFubenAssignManager.lua b/Resources/Scripts/XManager/XFubenAssignManager.lua new file mode 100644 index 00000000..a7f5ce5d --- /dev/null +++ b/Resources/Scripts/XManager/XFubenAssignManager.lua @@ -0,0 +1,1222 @@ +--- 占领副本管理器 +XFubenAssignManagerCreator = function() + local XFubenAssignManager = {} + + -- 协议 + local METHOD_NAME = { + AssignGetDataRequest = "AssignGetDataRequest", + AssignSetTeamRequest = "AssignSetTeamRequest", + AssignSetCharacterRequest = "AssignSetCharacterRequest", + AssignGetRewardRequest = "AssignGetRewardRequest", + } + + -- 常量 + XFubenAssignManager.MaxSelectConditionNum = 4 + XFubenAssignManager.SelectConditionColor = {[true] = CS.UnityEngine.Color.black, [false] = CS.UnityEngine.Color.gray } + XFubenAssignManager.MemberColor = { + "FF1111FF", -- red + "4F99FFFF", -- blue + "F9CB35FF", -- yellow + } + XFubenAssignManager.FomationAnimFinishDelay = 400 -- 特效显示时间 + XFubenAssignManager.FormationState = { Effect = 1, Reset = 2 } + local CHARACTERTYPE_ALL = 0 + local SKILLTYPE_BITS = 1000 + local KeyAccountEnterAssign = "Assign" + + -- ui操作所缓存的数据 + XFubenAssignManager.SelectChapterId = nil + XFubenAssignManager.SelectGroupId = nil + XFubenAssignManager.SelectCharacterId = nil + XFubenAssignManager.OccupyFirstSelectTeamId = nil + XFubenAssignManager.OccupyFirstSelectOrder = nil + XFubenAssignManager.OccupySecondSelectTeamId = nil + XFubenAssignManager.OccupySecondSelectOrder = nil + + XFubenAssignManager.CAPTIAN_MEMBER_INDEX = 1 -- 队长位置 + XFubenAssignManager.FIRSTFIGHT_MEMBER_INDEX = 1 -- 首发位置 + local MEMBER_MAX_COUNT = 3 -- 队伍最大成员数 + + local ChapterIdList = nil + local ChapterDataDict = nil -- 章节 + local GroupDataDict = nil -- 关卡组 + local TeamDataDict = nil -- 队伍 + + ------ 战斗接口用的数据 + local FinishFightCb = nil + local CloseLoadingCb = nil + -- local MEMBER_INDEX_BY_ORDER = {[1] = 2, [2] = 1, [3] = 3} -- 面板上显示的位置(order) = 队伍中实际中的位置(index) + local MEMBER_ORDER_BY_INDEX = {[1] = 2, [2] = 1, [3] = 3 } -- 队伍中实际中的位置(index) = 面板上显示的位置(order) + local GroupIdByStageId = nil -- {[stageId] = groupId, ...} + local FollowGroupDict = nil -- {[前置组id] = {后置组id, ...}, ...} + + + function XFubenAssignManager.Init() + end + + function XFubenAssignManager.ClearData() + XFubenAssignManager.SelectChapterId = nil + XFubenAssignManager.SelectGroupId = nil + XFubenAssignManager.SelectCharacterId = nil + XFubenAssignManager.OccupyFirstSelectTeamId = nil + XFubenAssignManager.OccupyFirstSelectOrder = nil + XFubenAssignManager.OccupySecondSelectTeamId = nil + XFubenAssignManager.OccupySecondSelectOrder = nil + + ChapterIdList = nil + ChapterDataDict = nil -- 章节 + GroupDataDict = nil -- 关卡组 + TeamDataDict = nil -- 队伍 + FollowGroupDict = nil + end + + ----------- 章节数据 begin----------- + local ChapterData = XClass(nil, "ChapterData") + function ChapterData:Ctor(id) + self.Id = id + self.CharacterId = nil -- 驻守角色 + self.Rewarded = false -- 已领奖 + self.IsPassByServer = nil -- 服务器已通关标记 + end + function ChapterData:GetCfg() + return XFubenAssignConfigs.GetChapterTemplateById(self.Id) + end + function ChapterData:GetId() return self.Id end + function ChapterData:GetName() return self:GetCfg().ChapterName end + function ChapterData:GetDesc() return self:GetCfg().ChapterEn end + function ChapterData:GetOrderId() return self:GetCfg().OrderId end + function ChapterData:GetIcon() return self:GetCfg().Cover end + function ChapterData:GetSkillPlusId() return self:GetCfg().SkillPlusId end + function ChapterData:GetAssignCondition() return self:GetCfg().AssignCondition end + function ChapterData:GetSelectCharCondition() return self:GetCfg().SelectCharCondition end + function ChapterData:GetRewardId() return self:GetCfg().RewardId end + function ChapterData:GetGroupId() return self:GetCfg().GroupId end + + -- 获得所有加成效果的key + function ChapterData:GetBuffKeys() + if not self.BuffKeys then + self.BuffKeys = {} + local buffConfigId = self:GetSkillPlusId() + if buffConfigId and buffConfigId ~= 0 then + local plusConfig = XCharacterConfigs.GetSkillTypePlusTemplate(buffConfigId) + if plusConfig then + local key + + local isAllMember = (#plusConfig.CharacterType == #XCharacterConfigs.GetAllCharacterCareerIds()) + if isAllMember then + local characterType = CHARACTERTYPE_ALL + for _, skillType in ipairs(plusConfig.SkillType) do + key = characterType * SKILLTYPE_BITS + skillType + table.insert(self.BuffKeys, key) + end + else + for _, characterType in ipairs(plusConfig.CharacterType) do + for _, skillType in ipairs(plusConfig.SkillType) do + key = characterType * SKILLTYPE_BITS + skillType + table.insert(self.BuffKeys, key) + end + end + end + end + end + self.BuffKeys = XFubenAssignManager.SortKeys(self.BuffKeys) + end + return self.BuffKeys + end + + function ChapterData:GetBuffDescList() + return XFubenAssignManager.GetBuffDescListByKeys(self:GetBuffKeys()) + end + + function ChapterData:IsCharConditionMatch(characterId) + local isMatch = true + local conditions = self:GetSelectCharCondition() + for _, conditionId in ipairs(conditions) do + if not (XConditionManager.CheckCondition(conditionId, characterId)) then + isMatch = false + break + end + end + return isMatch + end + + function ChapterData:GetProgressStr() + local groupNum = #self:GetGroupId() + return math.floor((self:GetPassNum() / groupNum) * 100) .. "%" + end + + function ChapterData:GetCharacterBodyIcon() + return XDataCenter.CharacterManager.GetCharHalfBodyImage(self.CharacterId) + end + + function ChapterData:IsRewarded() + return self.Rewarded + end + + function ChapterData:CanReward() + return (self:IsPass() and not self:IsRewarded()) + end + + function ChapterData:IsUnlock() + for _, groupId in ipairs(self:GetGroupId()) do + local groupData = XFubenAssignManager.GetGroupDataById(groupId) + if groupData and groupData:IsUnlock() then + return true + end + end + return false + end + + function ChapterData:CanAssign() + return self:IsPass() and self:IsMatchAssignCondition() + end + + -- server api + function ChapterData:SetRewarded(state) + self.Rewarded = state + end + + function ChapterData:GetPassNum() + local passNum = 0 + for _, groupId in ipairs(self:GetGroupId()) do + local groupData = XFubenAssignManager.GetGroupDataById(groupId) + if groupData and groupData:IsPass() then + passNum = passNum + 1 + end + end + return passNum + end + + function ChapterData:SetIsPassByServer(value) + self.IsPassByServer = value + end + + function ChapterData:IsPass() + if self.IsPassByServer then + return true + end + local groupNum = #self:GetGroupId() + return (self:GetPassNum() >= groupNum) + end + + function ChapterData:IsMatchAssignCondition() + for _, conditionId in ipairs(self:GetAssignCondition()) do + if not (XConditionManager.CheckCondition(conditionId)) then + return false + end + end + return true + end + + function ChapterData:SetCharacterId(characterId) + self.CharacterId = characterId + end + + function ChapterData:IsOccupy() + return (self.CharacterId and self.CharacterId ~= 0) + end + + function ChapterData:GetCharacterId() + return self.CharacterId + end + + function ChapterData:GetOccupyCharacterIcon() + return XDataCenter.CharacterManager.GetCharBigRoundnessNotItemHeadIcon(self:GetCharacterId()) + end + + function ChapterData:GetOccupyCharacterName() + return XCharacterConfigs.GetCharacterFullNameStr(self:GetCharacterId()) + end + + -- 是否当前进度章节 + function XFubenAssignManager.IsCurrentChapter(chapterId) + local passNum = XFubenAssignManager.GetAllChapterPassNum() + local targetIndex = 0 + for i, id in ipairs(XFubenAssignManager.GetChapterIdList()) do + if chapterId == id then + targetIndex = i + break + end + end + if targetIndex == 0 then + XLog.Debug("XFubenAssignManager.IsCurrentChapter参数传入了无效的chapterId: " .. tostring(chapterId)) + end + return (targetIndex == passNum + 1) + end + + function XFubenAssignManager.GetAllChapterPassNum() + local passNum = 0 + for _, chapterId in ipairs(XFubenAssignManager.GetChapterIdList()) do + local chapterData = XFubenAssignManager.GetChapterDataById(chapterId) + if chapterData:IsPass() then + passNum = passNum + 1 + end + end + return passNum + end + + function XFubenAssignManager.GetCharacterOccupyChapterId(characterId) + if characterId and characterId ~= 0 then + for _, chapterId in ipairs(XFubenAssignManager.GetChapterIdList()) do + local chapterData = XFubenAssignManager.GetChapterDataById(chapterId) + if chapterData:GetCharacterId() == characterId then + return chapterId + end + end + end + return nil + end + + function XFubenAssignManager.GetChapterIdList() + if not ChapterIdList then + ChapterIdList = {} + for id, _ in pairs(XFubenAssignConfigs.GetChapterTemplates()) do + table.insert(ChapterIdList, id) + end + table.sort(ChapterIdList, function(a, b) return a < b end) + end + return ChapterIdList + end + + function XFubenAssignManager.GetUnlockChapterIdList() + local idList = {} + local data + for _, id in ipairs(XFubenAssignManager.GetChapterIdList()) do + data = XFubenAssignManager.GetChapterDataById(id) + if data:IsUnlock() then + table.insert(idList, id) + end + end + return idList + end + + -- 角色是否已在占领 + function XFubenAssignManager.CheckCharacterInOccupy(characterId) + local chapterData + for _, id in ipairs(XFubenAssignManager.GetChapterIdList()) do + chapterData = XFubenAssignManager.GetChapterDataById(id) + if chapterData:GetCharacterId() == characterId then + return true + end + end + return false + end + + function XFubenAssignManager.GetChapterDataById(id) + if not id then + XLog.Error("XFubenAssignManager.GetChapterDataById函数参数id不能为空" .. tostring(id)) + return + end + if not ChapterDataDict then + ChapterDataDict = {} + end + if not ChapterDataDict[id] then + ChapterDataDict[id] = ChapterData.New(id) + end + return ChapterDataDict[id] + end + + function XFubenAssignManager.GetCurrentChapterData() + local idList = XFubenAssignManager.GetChapterIdList() + for _, chapterId in ipairs(idList) do + local chapterData = XFubenAssignManager.GetChapterDataById(chapterId) + if not chapterData:IsPass() then + return chapterData + end + end + return XFubenAssignManager.GetChapterDataById(idList[#idList]) + end + + function XFubenAssignManager.GetChapterProgressTxt() + local chapterData = XFubenAssignManager.GetCurrentChapterData() + return CS.XTextManager.GetText("AssignChapterProgressTxt", chapterData:GetDesc()) + end + ----------- 章节数据 end----------- + ----------- 关卡组数据 begin----------- + local GroupData = XClass(nil, "GroupData") + function GroupData:Ctor(id) + self.Id = id + self.FightCount = 0 + self.GroupRebootCount = 0 + self.IsPerfect = false + end + function GroupData:GetCfg() + return XFubenAssignConfigs.GetGroupTemplateById(self.Id) + end + function GroupData:GetId() return self.Id end + function GroupData:GetPreGroupId() return self:GetCfg().PreGroupId end + -- function GroupData:GetMaxFightCount() return self:GetCfg().ChallengeNum end + function GroupData:GetTeamInfoId() return self:GetCfg().TeamInfoId end + function GroupData:GetBaseStageId() return self:GetCfg().BaseStage end + function GroupData:GetStageId() return self:GetCfg().StageId end + function GroupData:GetName() return self:GetCfg().Name end + function GroupData:GetIcon() return self:GetCfg().Icon end + + function GroupData:IsUnlock() + if self:GetFightCount() > 0 then + return true + end + local preGroupId = self:GetPreGroupId() + return ((not preGroupId or preGroupId == 0) or XFubenAssignManager.GetGroupDataById(preGroupId):IsPass()) + end + + -- 刷新关卡解锁信息 + function GroupData:SyncStageInfo(isPass) + local isUnlock = self:IsUnlock() + for _, stageId in ipairs(self:GetStageId()) do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + stageInfo.Unlock = isUnlock + if isPass ~= nil then + stageInfo.Passed = isPass + end + end + local baseStageId = self:GetBaseStageId() + local baseStageInfo = XDataCenter.FubenManager.GetStageInfo(baseStageId) + baseStageInfo.Unlock = isUnlock + if isPass ~= nil then + baseStageInfo.Passed = isPass + end + + if isUnlock then + XFubenAssignManager.UnlockFollowGroupStage(self:GetId()) + end + end + + -- server api + function GroupData:SetFightCount(count) + count = count or 0 + local oldCount = self.FightCount + self.FightCount = count + if (not oldCount or oldCount == 0) and (count > 0) then -- 新解锁 + self:SyncStageInfo(true) + end + end + + function GroupData:GetFightCount() + -- do return 1 end -- for testing + return self.FightCount + end + function GroupData:SetIsPerfect(isPerfect) + self.IsPerfect = isPerfect + end + function GroupData:GetIsPerfect() + return self.IsPerfect + end + function GroupData:SetGroupRebootCountAdd( rebootCount ) + self.GroupRebootCount = self.GroupRebootCount + rebootCount + end + function GroupData:GetGroupRebootCount() + return self.GroupRebootCount + end + function GroupData:ResetGroupRebootCount() + self.GroupRebootCount = 0 + end + function GroupData:IsPass() + if self:GetFightCount() > 0 then + return true + end + return false + -- -- 根据StageInfo来 来源于XFubenManager.InitFubenData + -- local stageInfo = XDataCenter.FubenManager.GetStageInfo(self:GetBaseStageId()) + -- return (stageInfo and stageInfo.Passed) + end + + function XFubenAssignManager.GetGroupDataById(id) + if not GroupDataDict then + GroupDataDict = {} + end + if not GroupDataDict[id] then + GroupDataDict[id] = GroupData.New(id) + end + return GroupDataDict[id] + end + ----------- 关卡组数据 end----------- + ----------- 队伍数据 begin----------- + ------- 队员数据 + local MemberData = XClass(nil, "MemberData") + function MemberData:Ctor(index) + self.Index = index -- 队伍位置 + self.CharacterId = nil + end + function MemberData:GetIndex() return self.Index end + function MemberData:GetCharacterId() return self.CharacterId end + function MemberData:HasCharacter() return (self.CharacterId and self.CharacterId ~= 0) end + + function MemberData:SetCharacterId(characterId) + self.CharacterId = characterId + end + + function MemberData:GetCharacterAbility() + return self:HasCharacter() and XDataCenter.CharacterManager.GetCharacterAbilityById(self.CharacterId) or 0 + end + + function MemberData:GetCharacterSkillInfo() + return self:HasCharacter() and XDataCenter.CharacterManager.GetCaptainSkillInfo(self.CharacterId) or nil + end + + function MemberData:GetCharacterType() + return self:HasCharacter() and XCharacterConfigs.GetCharacterType(self.CharacterId) + end + + -------队伍数据 + local TeamData = XClass(nil, "TeamData") + function TeamData:Ctor(id) + self.Id = id + self.MemberList = nil + self.LeaderIndex = nil + self.FirstFightIndex = nil + end + function TeamData:GetCfg() + return XFubenAssignConfigs.GetTeamInfoTemplateById(self.Id) + end + function TeamData:GetId() return self.Id end + function TeamData:GetBuffId() return self:GetCfg().BuffId end + function TeamData:GetNeedCharacter() return self:GetCfg().NeedCharacter end + function TeamData:GetRequireAbility() return self:GetCfg().RequireAbility end + function TeamData:GetCondition() return self:GetCfg().Condition end + function TeamData:GetDesc() return self:GetCfg().Desc end + + function TeamData:GetMemberList() + if not self.MemberList then + self.MemberList = {} + local count = self:GetNeedCharacter() + for i = 1, count do + self.MemberList[i] = MemberData.New(i) -- 队伍位置 + end + if count > 1 then -- 若是多人队伍则队长居中, 即队员索引为{2, 1, 3} + self.MemberList[1], self.MemberList[2] = self.MemberList[2], self.MemberList[1] + end + end + return self.MemberList + end + + function TeamData:ClearMemberList() + if not self.MemberList then return end + for _, memberData in pairs(self.MemberList) do + memberData:SetCharacterId(0) + end + end + + function TeamData:GetCharacterType() + if not self.MemberList then return end + for _, memberData in pairs(self.MemberList) do + if memberData:HasCharacter() then + return memberData:GetCharacterType() + end + end + end + + function TeamData:GetMember(index) + for _, member in ipairs(self:GetMemberList()) do + if member:GetIndex() == index then + return member + end + end + XLog.Error("TeamData:GetMember函数无效参数index: " .. tostring(index)) + return nil + end + + function TeamData:SetLeaderIndex(index) + self.LeaderIndex = index + end + + function TeamData:GetLeaderIndex() + return self.LeaderIndex or XFubenAssignManager.CAPTIAN_MEMBER_INDEX + end + + function TeamData:SetFirstFightIndex(index) + self.FirstFightIndex = index + end + + ---========================================== + --- 得到队伍首发位 + --- 当首发位不为空时,直接返回首发位 + --- 不然查看队长位是否为空,不为空则返回队长位 + ---(因为服务器在之前只有队长位,后面区分了队长位与首发位,存在有队长位数据,没有首发位数据的情况) + --- 如果队长位也为空,则返回默认首发位 + ---@return number + ---========================================== + function TeamData:GetFirstFightIndex() + return self.FirstFightIndex or self.LeaderIndex or XFubenAssignManager.FIRSTFIGHT_MEMBER_INDEX + end + + function TeamData:GetLeaderSkillDesc() + local memberData = self:GetMember(self:GetLeaderIndex()) + if memberData then + local captianSkillInfo = memberData:GetCharacterSkillInfo() + if captianSkillInfo then + return captianSkillInfo.Level > 0 and captianSkillInfo.Intro or string.format("%s%s", captianSkillInfo.Intro, CS.XTextManager.GetText("CaptainSkillLock")) + end + end + return "" + end + + function TeamData:IsEnoughAbility() + local memberList = self:GetMemberList() + local need = self:GetRequireAbility() + for _, member in pairs(memberList) do + if member:GetCharacterAbility() > need then + return true + end + end + return false + end + + function TeamData:SetMember(order, characterId) + self:GetMemberList()[order]:SetCharacterId(characterId) + end + + -- 获得角色在队伍中的排序 + function TeamData:GetCharacterOrder(characterId) + for order, v in pairs(self:GetMemberList()) do + if v:GetCharacterId() == characterId then + return order + end + end + return nil + end + + -- server api + function TeamData:SetMemberList(characterIdList) + if characterIdList then + local memberList = self:GetMemberList() + local memberCount = #memberList + for index, v in pairs(memberList) do + local order = XFubenAssignManager.GetMemberOrderByIndex(index, memberCount) + v:SetCharacterId(characterIdList[order]) + end + else + for _, v in pairs(self:GetMemberList()) do + v:SetCharacterId(nil) + end + end + end + + -- 角色是否已在队伍中 + function XFubenAssignManager.CheckCharacterInTeam(characterId) + for _, teamData in pairs(TeamDataDict) do + if teamData:GetCharacterOrder(characterId) ~= nil then + return true + end + end + return false + end + + -- 获取其他队伍的角色 + function XFubenAssignManager.GetOtherTeamCharacters(groupId, srcTeamId) + local otherTeamCharacters = {} + for _, teamId in pairs(GroupDataDict[groupId]:GetTeamInfoId()) do + if teamId ~= srcTeamId and TeamDataDict[teamId] then + for i, member in ipairs(TeamDataDict[teamId]:GetMemberList()) do + local characterId = member:GetCharacterId() + if characterId and characterId ~= 0 then + table.insert(otherTeamCharacters, { teamId, i, characterId }) + end + end + end + end + return otherTeamCharacters + end + + -- 获取某组里 角色对应的队伍编号 + function XFubenAssignManager.GetCharacterTeamOderMapByGroup(groupId) + local teamOrderMap = {} + local teamIdMap = {} + for i, teamId in pairs(GroupDataDict[groupId]:GetTeamInfoId()) do + local teamData = XFubenAssignManager.GetTeamDataById(teamId) + for _, memberData in ipairs(teamData:GetMemberList()) do + if memberData:HasCharacter() then + teamIdMap[memberData:GetCharacterId()] = teamId + teamOrderMap[memberData:GetCharacterId()] = i + end + end + end + return teamIdMap, teamOrderMap + end + + + function XFubenAssignManager.SetTeamMember(teamId, targetOrder, characterId) + local targetTeamData = XFubenAssignManager.GetTeamDataById(teamId) + -- -- 检查所有队伍并清除该characterId + -- local order = nil + -- for k, teamData in pairs(TeamDataDict) do + -- order = teamData:GetCharacterOrder(characterId) + -- if order ~= nil then + -- teamData:SetMember(order, nil) + -- break + -- end + -- end + targetTeamData:SetMember(targetOrder, characterId) + end + + function XFubenAssignManager.GetTeamDataById(id) + if not TeamDataDict then + TeamDataDict = {} + end + if not TeamDataDict[id] then + TeamDataDict[id] = TeamData.New(id) + end + return TeamDataDict[id] + end + + function XFubenAssignManager.GetTeamCharacterType(teamId) + local teamData = XFubenAssignManager.GetTeamDataById(teamId) + return teamData:GetCharacterType() + end + + function XFubenAssignManager.IsCharacterInTeamById(teamId, characterId) + local teamData = XFubenAssignManager.GetTeamDataById(teamId) + return teamData:GetCharacterOrder(characterId) ~= nil + end + + function XFubenAssignManager.GetGroupMemberCount(groupId) + local count = 0 + for _, teamId in pairs(GroupDataDict[groupId]:GetTeamInfoId()) do + for _, member in ipairs(XFubenAssignManager.GetTeamDataById(teamId):GetMemberList()) do + if member:HasCharacter() then + count = count + 1 + end + end + end + return count + end + + -- 一键上阵 + function XFubenAssignManager.AutoTeam(groupId) + local ownCharacters = XDataCenter.CharacterManager.GetOwnCharacterList() + table.sort(ownCharacters, function(a, b) + return a.Ability > b.Ability + end) + -- 保留当前角色 + -- local curCharacters = XFubenAssignManager.GetOtherTeamCharacters(groupId, nil) + local count = 1 + local maxCount = #ownCharacters + for _, teamId in pairs(GroupDataDict[groupId]:GetTeamInfoId()) do + if count > maxCount then + break + end + local teamData = XFubenAssignManager.GetTeamDataById(teamId) + local needCount = teamData:GetNeedCharacter() + for index = 1, needCount do + local order = XFubenAssignManager.GetMemberOrderByIndex(index, needCount) + local targetTeamData = XFubenAssignManager.GetTeamDataById(teamId) + + local stageId = teamId + local characterLimitType = XFubenConfigs.GetStageCharacterLimitType(teamId) + local defaultCharacterType = XDataCenter.FubenManager.GetDefaultCharacterTypeByCharacterLimitType(characterLimitType) + + local i + for charIndex, char in ipairs(ownCharacters) do + local charType = XCharacterConfigs.GetCharacterType(char.Id) + if defaultCharacterType ~= XFubenConfigs.CharacterLimitType.All and defaultCharacterType ~= charType then + goto CONTINUE + end + XFubenAssignManager.SetTeamMember(teamId, order, char.Id) + i = charIndex + break + :: CONTINUE :: + end + if i then + table.remove(ownCharacters, i) + end + end + end + end + + -- 是否满足关卡所需战力 + function XFubenAssignManager.IsAbilityMatch(targetStageId, charIdList) + local groupId = XFubenAssignManager.GetGroupIdByStageId(targetStageId) + local groupData = XFubenAssignManager.GetGroupDataById(groupId) + local isMatch = false + local teamIdList = groupData:GetTeamInfoId() + for i, stageId in pairs(groupData:GetStageId()) do + if stageId == targetStageId then + isMatch = true + local teamId = teamIdList[i] + local teamData = XFubenAssignManager.GetTeamDataById(teamId) + for order = 1, teamData:GetNeedCharacter() do + local characterId = charIdList[order] + local character = XDataCenter.CharacterManager.GetCharacter(characterId) + if character.Ability < teamData:GetRequireAbility() then + isMatch = false + break + end + end + break + end + end + return isMatch + end + ----------- 队伍数据 end----------- + ----------- 战斗接口 begin----------- + function XFubenAssignManager.SetCloseLoadingCb(cb) + CloseLoadingCb = cb + end + + function XFubenAssignManager.SetFinishFightCb(cb) + FinishFightCb = cb + end + + -- function XFubenAssignManager.GetMemberIndexByOrder(order) + -- return MEMBER_INDEX_BY_ORDER[order] + -- end + function XFubenAssignManager.GetMemberOrderByIndex(index, maxCount) + return maxCount > 1 and MEMBER_ORDER_BY_INDEX[index] or index + end + + function XFubenAssignManager.GetGroupIdByStageId(stageId) + if not GroupIdByStageId then + GroupIdByStageId = {} + local GroupTemplates = XFubenAssignConfigs.GetGroupTemplates() + local groupData + for groupId, _ in pairs(GroupTemplates) do + groupData = XFubenAssignManager.GetGroupDataById(groupId) + for _, id in ipairs(groupData:GetStageId()) do + GroupIdByStageId[id] = groupId + end + end + end + return GroupIdByStageId[stageId] + end + + function XFubenAssignManager.CheckIsGroupLastStage(stageId) + local groupId = XFubenAssignManager.GetGroupIdByStageId(stageId) + local groupData = XFubenAssignManager.GetGroupDataById(groupId) + local stageIdList = groupData:GetStageId() + return (stageIdList[#stageIdList] == stageId) + end + + ------ 以下是在FubenManager注册的函数 + function XFubenAssignManager.InitStageInfo() + local stageType = XDataCenter.FubenManager.StageType.Assign + local chapterData + local groupData + for _, chapterid in pairs(XFubenAssignManager.GetChapterIdList()) do + chapterData = XFubenAssignManager.GetChapterDataById(chapterid) + for _, groupId in pairs(chapterData:GetGroupId()) do + groupData = XFubenAssignManager.GetGroupDataById(groupId) + + local isUnlock = groupData:IsUnlock() + for _, stageId in ipairs(groupData:GetStageId()) do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + stageInfo.IsOpen = true + stageInfo.Type = stageType + stageInfo.Unlock = isUnlock + stageInfo.ChapterId = chapterid + end + + local baseStageInfo = XDataCenter.FubenManager.GetStageInfo(groupData:GetBaseStageId()) + baseStageInfo.IsOpen = true + baseStageInfo.Type = stageType + baseStageInfo.Unlock = isUnlock + baseStageInfo.ChapterId = chapterid + end + end + end + + function XFubenAssignManager.FinishFight(settle) + + local groupId = XFubenAssignManager.GetGroupIdByStageId(settle.StageId) + local groupData = XFubenAssignManager.GetGroupDataById(groupId) + if not groupData:GetIsPerfect() then + if settle.IsWin then + groupData:SetGroupRebootCountAdd(CS.XFight.Instance.FightReboot.RebootCount) + else + groupData:ResetGroupRebootCount() + end + end + + XDataCenter.FubenManager.FinishFight(settle) + + if FinishFightCb then + FinishFightCb(settle.IsWin) + end + end + + function XFubenAssignManager.OpenFightLoading() + return + end + + function XFubenAssignManager.CloseFightLoading() + if CloseLoadingCb then + CloseLoadingCb() + end + end + + function XFubenAssignManager.ShowReward(winData) + if XFubenAssignManager.CheckIsGroupLastStage(winData.StageId) then + -- 本地挑战次数自增 + local groupId = XFubenAssignManager.GetGroupIdByStageId(winData.StageId) + local groupData = XFubenAssignManager.GetGroupDataById(groupId) + groupData:SetFightCount(groupData:GetFightCount() + 1) + if not groupData:GetIsPerfect() then + if groupData:GetGroupRebootCount() <= 0 then + groupData:SetIsPerfect(true) + end + groupData:ResetGroupRebootCount() + end + XEventManager.DispatchEvent(XEventId.EVENET_ASSIGN_CAN_REWARD) -- 刷新红点 + XLuaUiManager.Open("UiAssignPostWarCount", winData) + end + end + ----------- 战斗接口 end----------- + -- 某角色某技能加成 + function XFubenAssignManager.GetSkillLevel(characterId, skillId) + local character = XDataCenter.CharacterManager.GetCharacter(characterId) + if not character then return 0 end + + local keys, levels = XFubenAssignManager.GetBuffKeysAndLevels() + local npcTemplate = XCharacterConfigs.GetNpcTemplate(character.NpcId) + local tragetCharacterType = npcTemplate.Type + local targetSkilType = XCharacterConfigs.GetSkillType(skillId) + local level = nil + for _, key in pairs(keys) do + local skillType = key % SKILLTYPE_BITS + local characterType = (key - skillType) / SKILLTYPE_BITS + if (characterType == tragetCharacterType or characterType == CHARACTERTYPE_ALL) and skillType == targetSkilType then + level = levels[key] + end + end + return level or 0 + end + + function XFubenAssignManager.GetSkillLevelByCharacterData(character, skillId, assignChapterRecords) + local keys = {} + local levels = {} + for _, v in ipairs(assignChapterRecords) do + local chapterData = ChapterData.New(v.ChapterId) + chapterData:SetCharacterId(v.CharacterId) + + if chapterData:IsOccupy() then + for _, key in ipairs(chapterData:GetBuffKeys()) do + if not levels[key] then + levels[key] = 1 + table.insert(keys, key) + else + levels[key] = levels[key] + 1 + end + end + end + end + local npcTemplate = XCharacterConfigs.GetNpcTemplate(character.NpcId) + local tragetCharacterType = npcTemplate.Type + local targetSkilType = XCharacterConfigs.GetSkillType(skillId) + local level = nil + for _, key in pairs(keys) do + local skillType = key % SKILLTYPE_BITS + local characterType = (key - skillType) / SKILLTYPE_BITS + if (characterType == tragetCharacterType or characterType == CHARACTERTYPE_ALL) and skillType == targetSkilType then + level = levels[key] + end + end + return level or 0 + end + + -- 参数keys: {角色类型*1000+技能类型, ...} + -- 参数levels: {[key] = level, ...} + function XFubenAssignManager.GetBuffDescListByKeys(keys, levels) + local descList = {} + local GetCareerName = XCharacterConfigs.GetCareerName + local GetSkillTypeName = XCharacterConfigs.GetSkillTypeName + local GetText = CS.XTextManager.GetText + for _, key in ipairs(keys) do + local skillType = key % SKILLTYPE_BITS + local characterType = (key - skillType) / SKILLTYPE_BITS + local level = levels and levels[key] or 1 + local memberTypeName = characterType == CHARACTERTYPE_ALL and "" or GetCareerName(characterType) + local str = GetText("AssignSkillPlus", memberTypeName, GetSkillTypeName(skillType), level) -- 全体{0}成员{1}等级+{2} + table.insert(descList, str) + end + return descList + end + + function XFubenAssignManager.GetBuffKeysAndLevels() + local keys = {} + local levels = {} + for _, id in ipairs(XFubenAssignManager.GetChapterIdList()) do + local chapterData = XFubenAssignManager.GetChapterDataById(id) + if chapterData:IsOccupy() then + for _, key in ipairs(chapterData:GetBuffKeys()) do + if not levels[key] then + levels[key] = 1 + table.insert(keys, key) + else + levels[key] = levels[key] + 1 + end + end + end + end + return keys, levels + end + + function XFubenAssignManager.SortKeys(keys) + table.sort(keys, function(a, b) + local skillTypeA = a % SKILLTYPE_BITS + local characterTypeA = (a - skillTypeA) / SKILLTYPE_BITS + local skillTypeB = b % SKILLTYPE_BITS + local characterTypeB = (b - skillTypeB) / SKILLTYPE_BITS + if skillTypeA ~= skillTypeB then + return skillTypeA < skillTypeB + end + return characterTypeA < characterTypeB + end) + return keys + end + + function XFubenAssignManager.GetAllBuffList() + local keys, levels = XFubenAssignManager.GetBuffKeysAndLevels() + keys = XFubenAssignManager.SortKeys(keys) + return XFubenAssignManager.GetBuffDescListByKeys(keys, levels) + end + + function XFubenAssignManager.TryGetFightTeamCharList(groupId) + local groupData = XFubenAssignManager.GetGroupDataById(groupId) + local teamList = {} + local captainPosList = {} + local firstFightPosList = {} + local teamIdList = groupData:GetTeamInfoId() + local allTeamHasMember = (#teamIdList > 0) + for i, teamId in ipairs(teamIdList) do + teamList[i] = {} + local count = 0 + local teamData = XFubenAssignManager.GetTeamDataById(teamId) + captainPosList[i] = teamData:GetLeaderIndex() + firstFightPosList[i] = teamData:GetFirstFightIndex() + local memberList = teamData:GetMemberList() + for _, memberData in ipairs(memberList) do + local characterId = memberData:GetCharacterId() or 0 + teamList[i][memberData:GetIndex()] = characterId + if characterId ~= 0 then + count = count + 1 + end + end + if count < #memberList then + allTeamHasMember = false + end + end + return allTeamHasMember, teamList, captainPosList, firstFightPosList + end + + -- 刷新后面关卡的解锁信息 + function XFubenAssignManager.UnlockFollowGroupStage(preGroupId) + local followGroupIdList = XFubenAssignManager.GetFollowGroupIdList(preGroupId) + if not followGroupIdList then + -- XLog.Debug(" 没有后置关卡id列表:" .. tostring(preGroupId)) + return + end + for _, followGroupId in ipairs(followGroupIdList) do + local followGroupData = XFubenAssignManager.GetGroupDataById(followGroupId) + followGroupData:SyncStageInfo() + end + end + + -- 获得后置关卡组 + function XFubenAssignManager.GetFollowGroupIdList(preGroupId) + if not FollowGroupDict then + XFubenAssignManager.InitFollowGroupDict() + end + local ids = FollowGroupDict[preGroupId] + -- if not ids then + -- XLog.Debug("前置关卡id无效:" .. tostring(preGroupId)) + -- end + return ids + end + + -- 初始化关卡组后置数据 + function XFubenAssignManager.InitFollowGroupDict() + if not FollowGroupDict then + FollowGroupDict = {} + local GroupTemplates = XFubenAssignConfigs.GetGroupTemplates() + local groupData + for groupId, _ in pairs(GroupTemplates) do + groupData = XFubenAssignManager.GetGroupDataById(groupId) + local preGroupId = groupData:GetPreGroupId() + if not FollowGroupDict[preGroupId] then + FollowGroupDict[preGroupId] = {} + end + table.insert(FollowGroupDict[preGroupId], groupId) + end + end + end + + -- Login登录后端初始化数据接口 + function XFubenAssignManager.InitServerData(chapterRecords) + XFubenAssignManager.UpdateChapterRecords(chapterRecords) + XFubenAssignManager.InitFollowGroupDict() + + -- 有数据代表已经通关 + local chapterData + for _, v in pairs(chapterRecords) do + chapterData = XFubenAssignManager.GetChapterDataById(v.ChapterId) + chapterData:SetIsPassByServer(true) + end + XEventManager.DispatchEvent(XEventId.EVENET_ASSIGN_CAN_REWARD) -- 刷新红点 + end + + function XFubenAssignManager.UpdateChapterRecords(chapterRecords) + if not chapterRecords then + return + end + for _, v in pairs(chapterRecords) do + local chapterData = XFubenAssignManager.GetChapterDataById(v.ChapterId) + chapterData:SetCharacterId(v.CharacterId) + chapterData:SetRewarded(v.IsGetReward) + end + end + + function XFubenAssignManager.IsRedPoint() + for _, chapterId in ipairs(XFubenAssignManager.GetChapterIdList()) do + local chapterData = XFubenAssignManager.GetChapterDataById(chapterId) + if chapterData:CanReward() then + return true + end + end + return false + end + + function XFubenAssignManager.GetCharacterListInTeam(inTeamIdMap, charType) + local ownCharacters = XDataCenter.CharacterManager.GetOwnCharacterList(charType) + -- 排序 未编队>已编队 等级>品质>优先级 + local weights = {} -- 编队[1位] + 等级[3位] + 品质[1位] + 优先级[5位] + local GetCharacterPriority = XCharacterConfigs.GetCharacterPriority + for _, character in ipairs(ownCharacters) do + local teamOrder = inTeamIdMap[character.Id] + local stateOrder = teamOrder and (9 - teamOrder) or 9 + local priority = GetCharacterPriority(character.Id) + local weightOrder = stateOrder * 1000000000 + local weightLevel = character.Level * 1000000 + local weightQuality = character.Quality * 100000 + local weightPriority = priority + weights[character.Id] = weightOrder + weightLevel + weightQuality + weightPriority + end + table.sort(ownCharacters, function(a, b) + return weights[a.Id] > weights[b.Id] + end) + return ownCharacters + end + + -- 是否满足关卡所需战力 + function XFubenAssignManager.IsStagePass(stageId) + local groupId = XFubenAssignManager.GetGroupIdByStageId(stageId) + local groupData = XFubenAssignManager.GetGroupDataById(groupId) + return groupData:IsPass() + end + + function XFubenAssignManager.GetAccountEnterKey() + return KeyAccountEnterAssign .. XPlayer.Id + end + + + -----------------协议---------- + function XFubenAssignManager.AssignGetDataRequest(cb) + -- if cb then cb() return end -- for testing + XNetwork.Call(METHOD_NAME.AssignGetDataRequest, nil, function(res) + local info = res.AssignInfo + local chapterRecords = info.ChapterRecords -- 章节占领角色 + XFubenAssignManager.UpdateChapterRecords(chapterRecords) + + local groupRecords = info.GroupRecords -- 关卡组挑战次数 + for _, v in ipairs(groupRecords) do + local groupData = XFubenAssignManager.GetGroupDataById(v.GroupId) + groupData:SetFightCount(v.Count) + groupData:SetIsPerfect(v.IsPerfect) + end + XEventManager.DispatchEvent(XEventId.EVENET_ASSIGN_CAN_REWARD) -- 刷新红点 + + local groupTeamRecords = info.GroupTeamRecords -- 编队记录 + for _, v in ipairs(groupTeamRecords) do + local groupData = XFubenAssignManager.GetGroupDataById(v.GroupId) + local teamCount = #v.TeamInfoList + local posCount = v.CaptainPosList and #v.CaptainPosList or 0 + local firstFightCount = v.FirstFightPosList and #v.FirstFightPosList or 0 + + for i, teamId in ipairs(groupData:GetTeamInfoId()) do + local teamData = XFubenAssignManager.GetTeamDataById(teamId) + local charaterIds = (i <= teamCount) and v.TeamInfoList[i] or nil + local captainPos = (i <= posCount) and v.CaptainPosList[i] or XFubenAssignManager.CAPTIAN_MEMBER_INDEX + local firstFightPos = (i <= firstFightCount) and v.FirstFightPosList[i] or XFubenAssignManager.FIRSTFIGHT_MEMBER_INDEX + teamData:SetMemberList(charaterIds) + teamData:SetLeaderIndex(captainPos) + teamData:SetFirstFightIndex(firstFightPos) + end + end + + if cb then + cb() + end + end) + end + + function XFubenAssignManager.AssignSetTeamRequest(GroupId, TeamList, captainPosList, firstFightPosList, cb) + -- if cb then cb() return end -- for testing + XNetwork.Call(METHOD_NAME.AssignSetTeamRequest, { GroupId = GroupId, TeamList = TeamList, CaptainPosList = captainPosList, FirstFightPosList = firstFightPosList }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + if cb then + cb() + end + end) + end + + function XFubenAssignManager.AssignSetCharacterRequest(ChapterId, CharacterId, cb) + -- if cb then cb() return end -- for testing + XNetwork.Call(METHOD_NAME.AssignSetCharacterRequest, { ChapterId = ChapterId, CharacterId = CharacterId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XEventManager.DispatchEvent(XEventId.EVENT_REFRESH_CHRACTER_ABLIITY) -- 重新计算角色战力 + if cb then + cb() + end + end) + end + function XFubenAssignManager.AssignGetRewardRequest(ChapterId, cb) + -- if cb then cb() return end -- for testing + XNetwork.Call(METHOD_NAME.AssignGetRewardRequest, { ChapterId = ChapterId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + local chapterData = XFubenAssignManager.GetChapterDataById(ChapterId) + chapterData:SetRewarded(true) + XUiManager.OpenUiObtain(res.RewardList or {}) + if cb then + cb() + end + end) + end + + function XFubenAssignManager.GetSkillPlusIdList() + local list = {} + for _, chapterId in ipairs(XFubenAssignManager.GetChapterIdList()) do + local chapterData = XFubenAssignManager.GetChapterDataById(chapterId) + if chapterData:IsOccupy() then + table.insert(list, chapterData:GetSkillPlusId()) + end + end + return list + end + + function XFubenAssignManager.GetSkillPlusIdListOther(assignChapterRecords) + local list = {} + if assignChapterRecords == nil then + return list + end + for _, v in ipairs(assignChapterRecords) do + local chapterData = ChapterData.New(v.ChapterId) + chapterData:SetCharacterId(v.CharacterId) + + if chapterData:IsOccupy() then + table.insert(list, chapterData:GetSkillPlusId()) + end + end + return list + end + + ------------------------------- + XFubenAssignManager.Init() + return XFubenAssignManager +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XFubenBabelTowerManager.lua b/Resources/Scripts/XManager/XFubenBabelTowerManager.lua new file mode 100644 index 00000000..e302a440 --- /dev/null +++ b/Resources/Scripts/XManager/XFubenBabelTowerManager.lua @@ -0,0 +1,812 @@ +local XBabelTowerStageData = require("XEntity/XBabelTower/XBabelTowerStageData") + +XFubenBabelTowerManagerCreator = function() + local XFubenBabelTowerManager = {} + + local RequestRpc = { + BabelTowerSelect = "BabelTowerSelectRequest", --关卡选择请求 + BabelTowerStageReset = "BabelTowerStageResetRequest", --关卡重置请求 + BabelTowerStageWipeOut = "BabelTowerStageWipeOutRequest", --关卡扫荡请求 + BabelTowerGetRank = "BabelTowerGetRankRequest", --获取排名 + } + + local CurrentActivityNo = nil --当前活动id + local CurrentActivityMaxScore = 0 --当前活动最高等级 + local CurrentRankLevel = 0 --当前排行榜等级 + local BabelActivityStatus = {} --{活动id = 活动状态} + local BabelActivityStages = {} --{活动id = 活动Stage列表} + local Stage2ActivityMap = {} --{stageId = activityId} + + local StageSupportDefaultBuffList = {} + + local CurStageId = nil -- 当前通关的副本 + local CurTeamId = nil -- 当前通关的副本 + local CurStageGuideId = nil -- 当前通关的副本阶段 + local CurTeamList = nil -- 当前组队信息 + local CurCaptainPos = nil + local CurFirstFightPos = nil + local CurStageLevel = nil + local ChallengeBuffList = nil -- 当前选择的挑战信息 + local SupportBuffList = nil -- 当前选择的支援信息 + local CurTeamScore = nil + local CurActivityMaxScore = nil + + -- 获取排名 + local CurScore = 0 + local CurRank = 0 + local TotalRank = 0 + local RankInfos = {} + + local LastOpenStageId = nil + + local function GetStageDatas() + local stageDatas = BabelActivityStages[CurrentActivityNo] + if not stageDatas then + return {} + end + return stageDatas + end + + local function GetStageData(stageId) + local stageDatas = GetStageDatas() + local stageData = stageDatas and stageDatas[stageId] + if not stageData then + return + end + return stageData + end + + local function GetTeamData(stageId, teamId) + local stageData = GetStageData(stageId) + local teamData = stageData and stageData:GetTeamData(teamId) + if not teamData then + return + end + return teamData + end + + function XFubenBabelTowerManager.InitStageInfo() + local allBabelActivityTemplates = XFubenBabelTowerConfigs.GetAllBabelTowerActivityTemplate() + if allBabelActivityTemplates then + for _, activityTemplate in pairs(allBabelActivityTemplates) do + for _, stageId in pairs(activityTemplate.StageId or {}) do + Stage2ActivityMap[stageId] = activityTemplate.Id + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + if stageInfo then + stageInfo.Type = XDataCenter.FubenManager.StageType.BabelTower + end + end + end + XFubenBabelTowerManager.RefreshStagePassed() + end + end + + function XFubenBabelTowerManager.OpenFightLoading(stageId) + XDataCenter.FubenManager.OpenFightLoading(stageId) + end + + function XFubenBabelTowerManager.CloseFightLoading(stageId) + XDataCenter.FubenManager.CloseFightLoading(stageId) + + XLuaUiManager.Open("UiFightBabelTower", stageId, XFubenBabelTowerConfigs.BattleReady) + end + + function XFubenBabelTowerManager.ShowReward(winData) + if not winData or not winData.SettleData then + XLuaUiManager.Open("UiSettleWin", winData) + return + end + + XFubenBabelTowerManager.RefreshStagePassed() + XLuaUiManager.Open("UiFightBabelTower", winData.SettleData.StageId, XFubenBabelTowerConfigs.BattleEnd) + end + + function XFubenBabelTowerManager.FinishFight(settle) + XFubenBabelTowerManager.SetNeedShowUiDifficult(true) + XDataCenter.FubenManager.FinishFight(settle) + end + + local __IsNeedShowUiDifficult = false + function XFubenBabelTowerManager.IsNeedShowUiDifficult() + return __IsNeedShowUiDifficult + end + + function XFubenBabelTowerManager.SetNeedShowUiDifficult(value) + __IsNeedShowUiDifficult = value and true or false + end + + -- stageInfo刷新 + -- 选中的关卡临时数据 + function XFubenBabelTowerManager.SaveCurStageInfo(stageId, teamId, guideId, teamList, challengeBuffs, supportBuffs, captainPos, stageLevel, firstFightPos) + CurStageId = stageId + CurTeamId = teamId + CurStageGuideId = guideId + CurTeamList = teamList + ChallengeBuffList = challengeBuffs + SupportBuffList = supportBuffs + CurCaptainPos = captainPos + CurStageLevel = stageLevel + CurFirstFightPos = firstFightPos + CurTeamScore = XDataCenter.FubenBabelTowerManager.GetTeamMaxScore(stageId, teamId) + CurActivityMaxScore = XFubenBabelTowerManager.GetCurrentActivityMaxScore() + end + + function XFubenBabelTowerManager.GetCurStageInfo() + return CurStageId, CurTeamId, CurStageGuideId, CurTeamList, ChallengeBuffList, SupportBuffList + , CurCaptainPos, CurStageLevel, CurFirstFightPos, CurTeamScore, CurActivityMaxScore + end + + function XFubenBabelTowerManager.ClearCurStageInfo() + CurStageId = nil + CurTeamId = nil + CurStageGuideId = nil + CurTeamList = nil + ChallengeBuffList = nil + SupportBuffList = nil + CurCaptainPos = nil + CurFirstFightPos = nil + CurStageLevel = nil + CurTeamScore = nil + CurActivityMaxScore = nil + end + + -- 保存红点 babelenvironment_playerId_activityId_stageId = (1代表打开过、0或者nil代表没有打开过) + function XFubenBabelTowerManager.UpdateBabalPrefsByKey(key, value) + if key then + CS.UnityEngine.PlayerPrefs.SetInt(key, value) + CS.UnityEngine.PlayerPrefs.Save() + end + end + + function XFubenBabelTowerManager.GetBabelPrefsByKey(key, defaultValue) + if key then + if CS.UnityEngine.PlayerPrefs.HasKey(key) then + local babelTowerPref = CS.UnityEngine.PlayerPrefs.GetInt(key) + return (babelTowerPref == nil) and defaultValue or babelTowerPref + end + end + return defaultValue + end + + -- 保存本地数据 + function XFubenBabelTowerManager.SaveBabelTowerPrefs(key, value) + if XPlayer.Id and CurrentActivityNo then + key = string.format("%s_%s_%s", key, tostring(XPlayer.Id), tostring(CurrentActivityNo)) + CS.UnityEngine.PlayerPrefs.SetInt(key, value) + CS.UnityEngine.PlayerPrefs.Save() + end + end + + function XFubenBabelTowerManager.GetBabelTowerPrefs(key, defaultValue) + if XPlayer.Id and CurrentActivityNo then + key = string.format("%s_%s_%s", key, tostring(XPlayer.Id), tostring(CurrentActivityNo)) + if CS.UnityEngine.PlayerPrefs.HasKey(key) then + local babelTowerPref = CS.UnityEngine.PlayerPrefs.GetInt(key) + return (babelTowerPref == nil or babelTowerPref == 0) and defaultValue or babelTowerPref + end + end + return defaultValue + end + + -- 是否为自选战略 + function XFubenBabelTowerManager.IsStageGuideAuto(guideId) + local stageGuideTemplate = XFubenBabelTowerConfigs.GetBabelTowerStageGuideTemplate(guideId) + return #stageGuideTemplate.BuffGroup <= 0 and #stageGuideTemplate.BuffId <= 0 + end + + function XFubenBabelTowerManager.IsStagePassed(stageId) + local stageData = GetStageData(stageId) + return stageData:IsSyned() + end + + function XFubenBabelTowerManager.IsStageTeamHasRecord(stageId, teamId) + if not XFubenBabelTowerManager.IsStagePassed(stageId) then return false end + local teamData = GetTeamData(stageId, teamId) + return teamData:IsSyned() + end + + function XFubenBabelTowerManager.GetStageTotalScore(stageId) + local stageData = GetStageData(stageId) + return stageData and stageData:GetTotalScore() or 0 + end + + function XFubenBabelTowerManager.GetStageGuideId(stageId) + local stageData = GetStageData(stageId) + return stageData and stageData:GetGudieId() or 0 + end + + function XFubenBabelTowerManager.GetStageTeamIdList(stageId) + local stageData = GetStageData(stageId) + return stageData and stageData:GetTeamIdList() or {} + end + + function XFubenBabelTowerManager.GetStageUnlockTeamNum() + local unlockTeamNum + + local stageDatas = GetStageDatas() + for _, stageData in pairs(stageDatas) do + local stageTeamNum = stageData:GetSynTeamNum() + unlockTeamNum = unlockTeamNum or stageTeamNum + if stageTeamNum < unlockTeamNum then + unlockTeamNum = stageTeamNum + end + end + + return unlockTeamNum or 0 + end + + function XFubenBabelTowerManager.WipeOutBlackList(paramStageId, paramTeamId) + local blackList = {} + + local stageDatas = GetStageDatas() + for stageId, stageData in pairs(stageDatas) do + if stageId ~= paramStageId then + local totalCharacterIds = stageData:GetTotalUsedCharacterIds(paramTeamId) + for characterId in pairs(totalCharacterIds) do + blackList[characterId] = true + end + end + end + + return blackList + end + + function XFubenBabelTowerManager.GetActivityBeginTime(activityNo) + if not activityNo then + return nil + end + local activityTemplate = XFubenBabelTowerConfigs.GetBabelTowerActivityTemplateById(activityNo) + return XFunctionManager.GetStartTimeByTimeId(activityTemplate.ActivityTimeId) + end + + function XFubenBabelTowerManager.GetFightEndTime(activityNo) + if not activityNo then + return nil + end + local activityTemplate = XFubenBabelTowerConfigs.GetBabelTowerActivityTemplateById(activityNo) + return XFunctionManager.GetEndTimeByTimeId(activityTemplate.FightTimeId) + end + + function XFubenBabelTowerManager.GetActivityEndTime(activityNo) + if not activityNo then + return nil + end + local activityTemplate = XFubenBabelTowerConfigs.GetBabelTowerActivityTemplateById(activityNo) + return XFunctionManager.GetEndTimeByTimeId(activityTemplate.ActivityTimeId) + end + + function XFubenBabelTowerManager.GetBanCharacterIdsByBuff(challengeBuffList) + local banCharacterIds = {} + + if challengeBuffList then + for _, buffDatas in pairs(challengeBuffList) do + local buffTemplate = XFubenBabelTowerConfigs.GetBabelTowerBuffTemplate(buffDatas.SelectBuffId) + for _, banChar in pairs(buffTemplate.BanCharacterId) do + banCharacterIds[banChar] = true + end + end + end + + return banCharacterIds + end + + -- 当前角色是否被锁定 + function XFubenBabelTowerManager.IsCharacterLockByStageId(cid, curStageId, curTeamId) + local stageDatas = GetStageDatas() + for stageId, stageData in pairs(stageDatas) do + if stageId == curStageId then + local totalCharacterIds = stageData:GetTotalUsedCharacterIds(curTeamId) + if totalCharacterIds[cid] then return true end + else + local totalCharacterIds = stageData:GetTotalUsedCharacterIds() + if totalCharacterIds[cid] then return true end + end + end + return false + end + + -- 获取被禁用的角色 + -- function XFubenBabelTowerManager.GetBanCharactersByBuffs(challengeBuffList) + -- -- 排除选中buff的禁用角色--可以放出来 + -- local banCharList = {} + -- if challengeBuffList then + -- for _, buffDatas in pairs(challengeBuffList) do + -- local buffTemplate = XFubenBabelTowerConfigs.GetBabelTowerBuffTemplate(buffDatas.SelectBuffId) + -- for _, banChar in pairs(buffTemplate.BanCharacterId) do + -- banCharList[banChar] = true + -- end + -- end + -- end + -- return banCharList + -- end + function XFubenBabelTowerManager.GetCurrentActivityNo() + return CurrentActivityNo + end + + function XFubenBabelTowerManager.GetNewActivityNo() + local activityTemplateList = XFubenBabelTowerConfigs.GetAllBabelTowerActivityTemplate() + local newActivityId + for _, v in pairs(activityTemplateList) do + newActivityId = v.Id + end + return newActivityId + end + + function XFubenBabelTowerManager.GetCurrentActivityMaxScore() + return CurrentActivityMaxScore + end + + function XFubenBabelTowerManager.GetCurrentActivityScores() + local curScore = 0 + + local stageDatas = GetStageDatas() + for _, stageData in pairs(stageDatas) do + curScore = curScore + stageData:GetTotalScore() + end + + local maxScore = CurrentActivityMaxScore + return curScore, maxScore + end + + -- stageId的引导关是否开启 + function XFubenBabelTowerManager.IsBabelStageGuideUnlock(stageId, guideId) + local isStageUnlock = XFubenBabelTowerManager.IsBabelStageUnlock(stageId) + if not isStageUnlock then + return false + end + + -- 上一关是否开启 + local stageTemplate = XFubenBabelTowerConfigs.GetBabelTowerStageTemplate(stageId) + local serverGuideId = XFubenBabelTowerManager.GetStageGuideId(stageId) + if serverGuideId == 0 then + return stageTemplate.StageGuideId[1] == guideId + else + local stageGuideMap = {} + for i = 1, #stageTemplate.StageGuideId do + local curGuideId = stageTemplate.StageGuideId[i] + stageGuideMap[curGuideId] = i + end + local maxIndex = (stageGuideMap[serverGuideId] or 0) + 1 + return maxIndex >= stageGuideMap[guideId] or false + end + end + + -- stageId是否开启 + function XFubenBabelTowerManager.IsBabelStageUnlock(stageId) + -- 未到开启时间 + local activityNo = Stage2ActivityMap[stageId] + if not XFubenBabelTowerManager.IsInActivityFightTime(activityNo) then + return false, CS.XTextManager.GetText("BabelTowerNoneFight") + end + + -- stage开启时间 + local stageTemplate = XFubenBabelTowerConfigs.GetBabelTowerStageTemplate(stageId) + local now = XTime.GetServerNowTimestamp() + local beginTime, endTime = XFunctionManager.GetTimeByTimeId(stageTemplate.TimeId) + if not beginTime or not endTime then + return false, "" + end + if now < beginTime or now > endTime then + return false, CS.XTextManager.GetText("BabelTowerNoneOpen") + end + + -- 上一个stage是否开启 + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + + local desc = "" + for _, prestageId in pairs(stageCfg.PreStageId or {}) do + if prestageId > 0 then + local preStageConfigs = XFubenBabelTowerConfigs.GetBabelStageConfigs(prestageId) + desc = CS.XTextManager.GetText("BabelTowerNotEnoughScore", preStageConfigs.Name, stageTemplate.PreStageScore) + end + end + return stageInfo.Unlock, desc + end + + -- 是否处于活动战斗时间 + function XFubenBabelTowerManager.IsInActivityFightTime(activityNo) + if not activityNo then return false end + local activityTemplate = XFubenBabelTowerConfigs.GetBabelTowerActivityTemplateById(activityNo) + if not activityTemplate then return false end + local serverStatus = BabelActivityStatus[activityNo] + if serverStatus ~= XFubenBabelTowerConfigs.BabelTowerStatus.Open then return false end + local now = XTime.GetServerNowTimestamp() + local beginTime = XFunctionManager.GetStartTimeByTimeId(activityTemplate.ActivityTimeId) + local fightEndTime = XFunctionManager.GetEndTimeByTimeId(activityTemplate.FightTimeId) + if not beginTime or not fightEndTime then + return false + end + return now >= beginTime and now <= fightEndTime + end + + -- 是否处于活动时间 + function XFubenBabelTowerManager.IsInActivityTime(activityNo) + if not activityNo then return false end + local activityTemplate = XFubenBabelTowerConfigs.GetBabelTowerActivityTemplateById(activityNo) + if not activityTemplate then + return false + end + local serverStatus = BabelActivityStatus[activityNo] + if serverStatus ~= XFubenBabelTowerConfigs.BabelTowerStatus.Open and serverStatus ~= XFubenBabelTowerConfigs.BabelTowerStatus.FightEnd then + return false + end + local now = XTime.GetServerNowTimestamp() + local beginTime, endTime = XFunctionManager.GetTimeByTimeId(activityTemplate.ActivityTimeId) + if not beginTime or not endTime then return false end + return now >= beginTime and now <= endTime + end + + -- StageInfo相关 + -- 刷新通过的StageInfo + -- 登录同步数据之后,刷新setWinDatas之后,InitStageInfo之后 + function XFubenBabelTowerManager.RefreshStagePassed() + local allBabelActivityTemplates = XFubenBabelTowerConfigs.GetAllBabelTowerActivityTemplate() + if allBabelActivityTemplates then + for _, activityTemplate in pairs(allBabelActivityTemplates) do + local activityStageList = BabelActivityStages[activityTemplate.Id] + if not activityStageList then + return + end + for _, stageId in pairs(activityTemplate.StageId or {}) do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + if stageInfo then + stageInfo.Passed = activityStageList[stageId] ~= nil + stageInfo.Unlock = true + stageInfo.IsOpen = true + + if stageCfg.RequireLevel > 0 and XPlayer.Level < stageCfg.RequireLevel then + stageInfo.Unlock = false + stageInfo.IsOpen = false + end + + for _, prestageId in pairs(stageCfg.PreStageId or {}) do + if prestageId > 0 then + local needScore = XFubenBabelTowerConfigs.GetBabelTowerStageTemplate(stageId).PreStageScore or 0 + local preScore = (activityStageList[prestageId] ~= nil) and activityStageList[prestageId].MaxScore or 0 + if needScore > preScore then + stageInfo.Unlock = false + stageInfo.IsOpen = false + break + end + end + end + end + end + end + end + end + + -- 是否在显示等级的时间段 + function XFubenBabelTowerManager.IsBabelTowerInShowTime() + local activityNo = XFubenBabelTowerManager.GetCurrentActivityNo() + if not activityNo then return false end + local activityTemplate = XFubenBabelTowerConfigs.GetBabelTowerActivityTemplateById(activityNo) + if not activityTemplate then return false end + local now = XTime.GetServerNowTimestamp() + local beginTime = XFunctionManager.GetStartTimeByTimeId(activityTemplate.ActivityTimeId) + local shwoEndTime = XFunctionManager.GetEndTimeByTimeId(activityTemplate.ShowTimeId) + if not beginTime or not shwoEndTime then return false end + return now >= beginTime and now <= shwoEndTime + end + + -- RPC + -- 选择关卡 + function XFubenBabelTowerManager.SelectBabelTowerStage(stageId, guideId, teamList, challengeBuffInfos, supportBuffInfos, func, stageLevel, teamId) + local req = { + StageId = stageId, + GuideId = guideId, + TeamList = teamList, + ChallengeBuffInfos = challengeBuffInfos, + SupportBuffInfos = supportBuffInfos, + StageLevel = stageLevel, + TeamId = teamId, + } + + XNetwork.Call(RequestRpc.BabelTowerSelect, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + if func then + func() + end + end) + end + + -- 重置关卡 + function XFubenBabelTowerManager.ResetBabelTowerStage(stageId, teamId, func) + XNetwork.Call(RequestRpc.BabelTowerStageReset, { StageId = stageId, TeamId = teamId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local teamData = GetTeamData(stageId, teamId) + teamData:Reset() + + XEventManager.DispatchEvent(XEventId.EVENT_BABEL_RESET_STATUES_CHANGED) + + if func then + func() + end + end) + end + + -- 扫荡关卡 + function XFubenBabelTowerManager.WipeOutBabelTowerStage(stageId, teamId, func) + XNetwork.Call(RequestRpc.BabelTowerStageWipeOut, { StageId = stageId, TeamId = teamId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local teamData = GetTeamData(stageId, teamId) + teamData:Recover() + + XEventManager.DispatchEvent(XEventId.EVENT_BABEL_RESET_STATUES_CHANGED) + + if func then + func() + end + end) + end + + + function XFubenBabelTowerManager.GetRank(func) + XNetwork.Call(RequestRpc.BabelTowerGetRank, {}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + CurScore = res.Score + CurRank = res.Rank + TotalRank = res.TotalRank + RankInfos = res.RankInfos + + if func then + func() + end + end) + end + + -- 获取排名信息 + function XFubenBabelTowerManager.GetScoreInfos() + return CurScore, CurRank, TotalRank + end + + -- 获取排名信息 + function XFubenBabelTowerManager.GetRankInfos() + return RankInfos + end + + --战斗失败返回 + -- 获取当前排行等级 + function XFubenBabelTowerManager.GetRankLevel() + return CurrentRankLevel + end + + function XFubenBabelTowerManager.SetTeamChace(stageId, teamId, team, captainPos, firstFightPos) + local teamData = GetTeamData(stageId, teamId) + if teamData:IsSyned() then return end --如果该关卡下已经有通关记录,那么不进行队伍配置缓存 + teamData:UpdateCharacterIds(team) + teamData:SetCaptainPos(captainPos) + teamData:SetFirstFightPos(firstFightPos) + end + + function XFubenBabelTowerManager.ClearTeamChace(stageId) + local teamIdList = XFubenBabelTowerManager.GetStageTeamIdList(stageId) + for _, teamId in pairs(teamIdList) do + local teamData = GetTeamData(stageId, teamId) + if not teamData:IsSyned() then + teamData:ClearCharacterIds() + end + end + end + + -- 支援缓存相关 + function XFubenBabelTowerManager.GetSupportBuffListCacheByStageId(stageId, teamId) + local teamData = GetTeamData(stageId, teamId) + return teamData:GetSupportBuffDic() + end + + function XFubenBabelTowerManager.UpdateSupportBuffListCache(stageId, supportBuffList, teamId) + local teamData = GetTeamData(stageId, teamId) + teamData:UpdateSupportBuffDic(supportBuffList) + end + + -- 挑战缓存相关 + function XFubenBabelTowerManager.GetBuffListCacheByStageId(stageId, teamId) + local teamData = GetTeamData(stageId, teamId) + return teamData:GetChallengeBuffDic() + end + + function XFubenBabelTowerManager.UpdateBuffListCache(stageId, challengeBuffList, teamId) + local teamData = GetTeamData(stageId, teamId) + teamData:UpdateChallengeBuffDic(challengeBuffList) + end + + function XFubenBabelTowerManager.IsTeamReseted(stageId, teamId) + local teamData = GetTeamData(stageId, teamId) + return teamData:IsReseted() + end + + function XFubenBabelTowerManager.GetTeamCharacterIds(stageId, teamId, includeReset) + local teamData = GetTeamData(stageId, teamId) + return teamData:GetCharacterIds(includeReset) + end + + function XFubenBabelTowerManager.GetTeamMaxScore(stageId, teamId) + local teamData = GetTeamData(stageId, teamId) + return teamData and teamData:GetMaxScore() or 0 + end + + function XFubenBabelTowerManager.GetTeamCaptainPos(stageId, teamId) + local teamData = GetTeamData(stageId, teamId) + return teamData:GetCaptainPos() + end + + function XFubenBabelTowerManager.GetTeamFirstFightPos(stageId, teamId) + local teamData = GetTeamData(stageId, teamId) + return teamData:GetFirstFightPos() + end + + function XFubenBabelTowerManager.CheckTeamHasCaptain(stageId, teamId) + local teamData = GetTeamData(stageId, teamId) + return teamData:HasCaptain() + end + + function XFubenBabelTowerManager.GetCacheTeam(stageId, teamId, characterIds, captainPos, firstFightPos) + local curTeam = { + TeamData = characterIds or XFubenBabelTowerManager.GetTeamCharacterIds(stageId, teamId), + CaptainPos = captainPos or XFubenBabelTowerManager.GetTeamCaptainPos(stageId, teamId), + FirstFightPos = firstFightPos or XFubenBabelTowerManager.GetTeamFirstFightPos(stageId, teamId), + } + return curTeam + end + + function XFubenBabelTowerManager.GetTeamCurScore(stageId, teamId, ignoreReset) + local teamData = GetTeamData(stageId, teamId) + return teamData:GetScore(ignoreReset) + end + + function XFubenBabelTowerManager.GetTeamSelectDifficult(stageId, teamId) + local teamData = GetTeamData(stageId, teamId) + return teamData:GetSelectDiffcult() + end + + function XFubenBabelTowerManager.UpdateTeamSelectDifficult(stageId, teamId, difficult) + local teamData = GetTeamData(stageId, teamId) + teamData:SelectDiffcult(difficult) + end + + -- 打开巴贝塔之前检查是否需要播剧情 + function XFubenBabelTowerManager.OpenBabelTowerCheckStory() + local value = XFubenBabelTowerManager.GetBabelTowerPrefs(XFubenBabelTowerConfigs.HAS_PLAY_BEGINSTORY, 0) + local activityNo = XFubenBabelTowerManager.GetCurrentActivityNo() + local hasPlay = value == 1 + if not hasPlay and activityNo then + local storyId = XFubenBabelTowerConfigs.GetActivityBeginStory(activityNo) + -- 播放剧情 + if storyId then + XDataCenter.MovieManager.PlayMovie(storyId, function() + XLuaUiManager.Open("UiBabelTowerMainNew") + end) + else + XLuaUiManager.Open("UiBabelTowerMainNew") + end + -- XDataCenter.FubenBabelTowerManager.SaveBabelTowerPrefs(XFubenBabelTowerConfigs.HAS_PLAY_BEGINSTORY, 1) + else + XLuaUiManager.Open("UiBabelTowerMainNew") + end + end + + local function UpdateBabelActivityStages(activityNo, stageDatas) + if not activityNo then return end + + local clientStageDatas = BabelActivityStages[activityNo] + if not clientStageDatas then + clientStageDatas = {} + local config = XFubenBabelTowerConfigs.GetBabelTowerActivityTemplateById(activityNo) + for _, stageId in pairs(config.StageId) do + if stageId > 0 then + local clientStageData = XBabelTowerStageData.New(stageId) + clientStageDatas[stageId] = clientStageData + end + end + BabelActivityStages[activityNo] = clientStageDatas + end + + if not stageDatas then return end + for _, stageData in pairs(stageDatas) do + local stageId = stageData.Id + local clientStageData = clientStageDatas[stageId] + clientStageData:UpdateData(stageData) + end + + XEventManager.DispatchEvent(XEventId.EVENT_BABEL_ACTIVITY_STATUS_CHANGED) + end + + -- 登录同步 + function XFubenBabelTowerManager.AsyncBabelTowerData(notifyData) + if not notifyData then return end + CurrentActivityNo = notifyData.ActivityNo + CurrentActivityMaxScore = notifyData.MaxScore + CurrentRankLevel = notifyData.RankLevel + + UpdateBabelActivityStages(CurrentActivityNo, notifyData.StageDatas) + + XFubenBabelTowerManager.RefreshStagePassed() + end + + -- 同步活动状态 + function XFubenBabelTowerManager.AsyncActivityStatus(notifyData) + if not notifyData then return end + + BabelActivityStatus[notifyData.ActivityNo] = notifyData.Status + XEventManager.DispatchEvent(XEventId.EVENT_BABEL_ACTIVITY_STATUS_CHANGED) + end + + -- 同步单个关卡数据 + function XFubenBabelTowerManager.AsyncActivityStageInfo(notifyData) + if not notifyData then return end + + CurrentActivityMaxScore = notifyData.MaxScore + + local stageId = notifyData.StageId + local clientStageData = GetStageData(stageId) + clientStageData:Syn() + + local teamData = notifyData.TeamData + local clientTeamData = GetTeamData(stageId, teamData.Id) + clientTeamData:UpdateData(teamData) + + XFubenBabelTowerManager.RefreshStagePassed() + + XEventManager.DispatchEvent(XEventId.EVENT_BABEL_STAGE_INFO_ASYNC) + end + + function XFubenBabelTowerManager.GetBabelTowerSection() + local sections = {} + + if XFubenBabelTowerManager.IsInActivityTime(CurrentActivityNo) then + local section = { + Id = CurrentActivityNo, + Type = XDataCenter.FubenManager.ChapterType.ActivityBabelTower, + BannerBg = CS.XGame.ClientConfig:GetString("FubenBabelTowerBannerBg"), + } + + table.insert(sections, section) + end + + return sections + end + + -- 设置最后打开的关卡id + function XFubenBabelTowerManager.SetLastOpenStageId(value) + LastOpenStageId = value + end + + function XFubenBabelTowerManager.GetLastOpenStageId() + return LastOpenStageId + end + + return XFubenBabelTowerManager +end + +--登录,或者开启通知玩法数据,活动未开启不下发 +XRpc.NotifyBabelTowerData = function(notifyData) + XDataCenter.FubenBabelTowerManager.AsyncBabelTowerData(notifyData) +end + +--通知活动状态,先下发这条协议,后下发NotifyBabelTowerData +XRpc.NotifyBabelTowerActivityStatus = function(notifyData) + XDataCenter.FubenBabelTowerManager.AsyncActivityStatus(notifyData) +end + +--更新单个关卡数据 +XRpc.NotifyBabelTowerTeamData = function(notifyData) + XDataCenter.FubenBabelTowerManager.AsyncActivityStageInfo(notifyData) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XFubenBossOnlineManager.lua b/Resources/Scripts/XManager/XFubenBossOnlineManager.lua new file mode 100644 index 00000000..00a7d4f1 --- /dev/null +++ b/Resources/Scripts/XManager/XFubenBossOnlineManager.lua @@ -0,0 +1,393 @@ +XFubenBossOnlineManagerCreator = function() + + local XFubenBossOnlineManager = {} + + XFubenBossOnlineManager.OnlineBossDifficultLevel = { + SIMPLE = 1, + NORMAL = 2, + HARD = 3, + HELL = 4, + NightMare = 5, + } + + local NORMAL_BOSS_COUNT = 4 + local ACTIVITY_BOSS_COUNT = 5 + + local METHOD_NAME = { + GetActivityBossDataRequest = "GetActivityBossDataRequest" + } + + local CsXTextManager = CS.XTextManager + local TABLE_FUBEN_ONLINE_OPEN_TIME = "Share/Fuben/BossOnline/BossOnlineOpenTime.tab" + local OnlineBossNormalOpenTimeTemplates = {} --联机boss常规开放时间限制 + local OnlineBossNormalOpenTimeList = {} + local IsActivity + local BossDataList + local OnlineLelfTime --联机Boss刷新时间 + local OnlineBeginTime + local OnlineBossSectionTemplates = {} + local OnlineBossChapterTemplates = {} + local NormalChapterId = CS.XGame.Config:GetInt("OnlineBossNormalChapterId") + local ActivityChapterId = CS.XGame.Config:GetInt("OnlineBossActivityChapterId") + local LastRequestTime = 0 + local RequestInterval = 30 + + function XFubenBossOnlineManager.Init() + OnlineBossSectionTemplates = XFubenBossOnlineConfig.GetSectionTemplates() + OnlineBossChapterTemplates = XFubenBossOnlineConfig.GetChapterTemplates() + OnlineBossNormalOpenTimeTemplates = XTableManager.ReadByIntKey(TABLE_FUBEN_ONLINE_OPEN_TIME, XTable.XTableActivityBossOnlineOpenTime, "Id") + for _, openTimeCfg in pairs(OnlineBossNormalOpenTimeTemplates) do + table.insert(OnlineBossNormalOpenTimeList, openTimeCfg) + end + end + + function XFubenBossOnlineManager.GetBossOnlineChapters() + if not BossDataList then + return {} + end + local list = {} + local chapterId = IsActivity and ActivityChapterId or NormalChapterId + for k, v in pairs(OnlineBossChapterTemplates) do + if k == chapterId then + table.insert(list, v) + end + end + table.sort(list, function(a, b) + return a.Id < b.Id + end) + return list + end + + function XFubenBossOnlineManager.UpdateStageUnlock(stageId, diff) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + stageInfo.Unlock = false + stageInfo.IsOpen = false + if stageCfg.RequireLevel > 0 and XPlayer.Level < stageCfg.RequireLevel then + return + end + + if diff > 1 then + for _, v in pairs(OnlineBossSectionTemplates) do + if v.DifficultType == diff - 1 then + local preStageInfo = XDataCenter.FubenManager.GetStageInfo(v.StageId) + if preStageInfo.Passed then + stageInfo.Unlock = true + stageInfo.IsOpen = true + return + end + end + end + else + stageInfo.Unlock = true + stageInfo.IsOpen = true + end + end + + function XFubenBossOnlineManager.InitStageInfo() + for _, sectionCfg in pairs(OnlineBossSectionTemplates) do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(sectionCfg.StageId) + stageInfo.BossSectionId = sectionCfg.Id + stageInfo.Type = XDataCenter.FubenManager.StageType.BossOnline + stageInfo.Difficult = sectionCfg.DifficultType + XFubenBossOnlineManager.UpdateStageUnlock(sectionCfg.StageId, sectionCfg.DifficultType) + end + end + + function XFubenBossOnlineManager.CheckAutoExitFight(stageId) + return true + end + + function XFubenBossOnlineManager.OpenFightLoading(stageId) + XLuaUiManager.Open("UiOnLineLoading") + end + + function XFubenBossOnlineManager.CloseFightLoading() + XLuaUiManager.Remove("UiOnLineLoading") + end + + function XFubenBossOnlineManager.ShowReward(winData) + -- XEventManager.DispatchEvent(XEventId.EVENT_FUBEN_SHOW_REWARD, winData) + -- XLuaUiManager.Open("UiSettleWin", winData) + if XDataCenter.FubenManager.CheckHasFlopReward(winData) then + XLuaUiManager.Open("UiFubenFlopReward", function() + XLuaUiManager.PopThenOpen("UiMultiplayerFightGrade", function() + XLuaUiManager.PopThenOpen("UiSettleWin", winData) + end) + end, winData) + if XDataCenter.FubenManager.CheckHasFlopReward(winData, true) and not XDataCenter.FubenManager.CheckCanFlop(winData.StageId) then + XUiManager.TipText("BossOnlineConsumeFinish", XUiManager.UiTipType.Success) + end + else + XLuaUiManager.Open("UiMultiplayerFightGrade", function() + XLuaUiManager.PopThenOpen("UiSettleWin", winData) + end) + end + end + + function XFubenBossOnlineManager.CheckIsInvade() + local key = "OnlineBossBeginTime_" .. XPlayer.Id + local time = XSaveTool.GetData(key) + return OnlineBeginTime == time + end + + function XFubenBossOnlineManager.RecordInvade() + local key = "OnlineBossBeginTime_" .. XPlayer.Id + XSaveTool.SaveData(key, OnlineBeginTime) + end + + function XFubenBossOnlineManager.GetActOnlineBossSectionForDiff(difficult) + if not BossDataList then + return + end + + for _, v in pairs(BossDataList) do + if v.DifficultyType == difficult then + return v + end + end + end + + function XFubenBossOnlineManager.GetStageIdByDiff(difficult) + for _, v in pairs(OnlineBossSectionTemplates) do + if v.DifficultType == difficult then + return v.StageId + end + end + return 0 + end + + function XFubenBossOnlineManager.GetActOnlineBossSectionById(secitonId, useLastTemplate) + if useLastTemplate then + local tmp = OnlineBossSectionTemplates[secitonId] + return OnlineBossSectionTemplates[tmp.LastSectionId] + end + return OnlineBossSectionTemplates[secitonId] + end + + function XFubenBossOnlineManager.GetBossOnlineNormalOpenTimeList() + return OnlineBossNormalOpenTimeList + end + + --获取不在指定时间段提示 + function XFubenBossOnlineManager.GetNotInTimeTip() + local tipStr + + local timeQuantum = {} + for _, openTimeCfg in pairs(OnlineBossNormalOpenTimeList) do + local str = openTimeCfg.BeginTime .. "-" .. openTimeCfg.EndTime + table.insert(timeQuantum, str) + end + tipStr = CsXTextManager.GetText("BossOnlineOpenTimeTip", timeQuantum[1], timeQuantum[2]) + + return tipStr or "" + end + + --判断常规BossOnLine是不是在指定时间内 + function XFubenBossOnlineManager.CheckNormalBossOnlineInTime() + for _, openTimeCfg in pairs(OnlineBossNormalOpenTimeList) do + local beginTimes = string.Split(openTimeCfg.BeginTime, ":") + local endTimes = string.Split(openTimeCfg.EndTime, ":") + local beginTime = XTime.GeyServerTime(beginTimes[1], beginTimes[2], 0) + local endTime = XTime.GeyServerTime(endTimes[1], endTimes[2], 0) + local nowTime = XTime.GetServerNowTimestamp() + if nowTime >= beginTime and nowTime <= endTime then + return true + end + end + return false + end + + function XFubenBossOnlineManager.GetBossDataList() + return BossDataList + end + + function XFubenBossOnlineManager.GetIsActivity() + return IsActivity + end + + function XFubenBossOnlineManager.CheckBossDataCorrect() + if not BossDataList then + XLog.Error("XFubenBossOnlineManager.CheckBossDataCorrect 错误, 联网获取的Boss信息列表为空") + return false + end + + local count = IsActivity and ACTIVITY_BOSS_COUNT or NORMAL_BOSS_COUNT + for diff = 1, count, 1 do + local correct = false + for _, bossInfo in pairs(BossDataList) do + if bossInfo.DifficultyType == diff then + correct = true + break + end + end + if not correct then + XLog.Error("XFubenBossOnlineManager.CheckBossDataCorrect错误, Boss无法根据DifficultyType找到 DifficultyType:" .. diff) + return false + end + end + + for _, v in pairs(BossDataList) do + if not OnlineBossSectionTemplates[v.BossId] then + XLog.Error("XFubenBossOnlineManager.CheckBossDataCorrect错误, 无法根据BossId:" .. v.BossId .. "在" .. TABLE_FUBEN_ONLINEBOSS_SECTION .. "表中找到数据") + return false + end + end + return true + end + + function XFubenBossOnlineManager.OnRefreshBossData(data) + local oldBeginTime = OnlineBeginTime + IsActivity = data.Activity == 1 + OnlineBeginTime = data.BeginTime + OnlineLelfTime = data.LeftTime + XTime.GetServerNowTimestamp() + BossDataList = data.BossDataList + if oldBeginTime == OnlineBeginTime then + XEventManager.DispatchEvent(XEventId.EVENT_ONLINEBOSS_UPDATE) + else + XEventManager.DispatchEvent(XEventId.EVENT_ONLINEBOSS_REFRESH) + end + end + + -- 获取联机BOSS信息 + function XFubenBossOnlineManager.RequsetGetBossDataList(cb) + LastRequestTime = XTime.GetServerNowTimestamp() + XNetwork.Call(METHOD_NAME.GetActivityBossDataRequest, nil, function(reply) + if reply.Code ~= XCode.Success then + XUiManager.TipCode(reply.Code) + return + end + XFubenBossOnlineManager.OnRefreshBossData(reply) + if cb then + cb() + end + end) + end + + function XFubenBossOnlineManager.RefreshBossData(cb) + if not XFubenBossOnlineManager.BossDataList or + XFubenBossOnlineManager.CheckOnlineBossTimeOut() or + XTime.GetServerNowTimestamp() - LastRequestTime > RequestInterval then + XFubenBossOnlineManager.RequsetGetBossDataList(cb) + else + if cb then + cb() + end + end + end + + function XFubenBossOnlineManager.GetOnlineBossUpdateTime() + return OnlineLelfTime + end + + --检测boss是否已经更新 + function XFubenBossOnlineManager.CheckOnlineBossTimeOut() + if OnlineLelfTime == nil then + return false + end + local curTime = XTime.GetServerNowTimestamp() + local offset = OnlineLelfTime - curTime + return offset <= 0 + end + + --检测前置条件 + function XFubenBossOnlineManager.CheckOnlineBossUnlock(diffcult, needTips) + if not BossDataList then + return false + end + + local bossData = XFubenBossOnlineManager.GetActOnlineBossSectionForDiff(diffcult) + if not bossData then + return false + end + + local boSection = XFubenBossOnlineManager.GetActOnlineBossSectionById(bossData.BossId) + if not boSection then + return false + end + + local stageCfg = XDataCenter.FubenManager.GetStageCfg(boSection.StageId) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageCfg.StageId) + + if needTips then + if not stageInfo.Unlock then + XUiManager.TipMsg(XDataCenter.FubenManager.GetFubenOpenTips(stageCfg.StageId, CS.XTextManager.GetText("BossOnlineNotUnlock"))) + end + end + + return stageInfo.Unlock + end + + function XFubenBossOnlineManager.GetFlopConsumeItemCount() + local template + for _, v in pairs(OnlineBossSectionTemplates) do + template = v + break + end + if not template then + return 0 + end + local itemId = XDataCenter.FubenManager.GetFlopConsumeItemId(template.StageId) + local item = XDataCenter.ItemManager.GetItem(itemId) + return item and item:GetCount() or 0 + end + + function XFubenBossOnlineManager.OpenBossOnlineUi(selectIdx) + XFubenBossOnlineManager.RefreshBossData(function() + if not XDataCenter.FubenBossOnlineManager.CheckBossDataCorrect() then + CsXUiManager.Instance:RunMain() + return + end + local isActivity = XFubenBossOnlineManager.GetIsActivity() + if isActivity and XFubenBossOnlineManager.CheckIsInvade() then + XLuaUiManager.Open("UiOnlineBossActivity", selectIdx) + else + XLuaUiManager.Open("UiOnlineBoss", selectIdx) + end + end) + end + + function XFubenBossOnlineManager.OpenBossOnlineUiWithoutCheck(selectIdx) + local isActivity = XFubenBossOnlineManager.GetIsActivity() + if isActivity and XFubenBossOnlineManager.CheckIsInvade() then + XLuaUiManager.Open("UiOnlineBossActivity", selectIdx) + else + XLuaUiManager.Open("UiOnlineBoss", selectIdx) + end + end + + function XFubenBossOnlineManager.PopOverTips() + if XFubenBossOnlineManager.GetIsActivity() then + XUiManager.TipText("ActivityBossOnlineOver") + else + XUiManager.TipText("BossOnlineOver") + end + end + + function XFubenBossOnlineManager.OnActivityEnd() + BossDataList = nil + XFubenBossOnlineManager.RequsetGetBossDataList() + XEventManager.DispatchEvent(XEventId.EVENT_ONLINE_BOSS_REFRESH) + if CS.XFight.IsRunning or XLuaUiManager.IsUiLoad("UiLoading") then + return + end + if XFubenBossOnlineManager.TryPopOverTips() then + XLuaUiManager.RunMain() + end + end + + function XFubenBossOnlineManager.TryPopOverTips() + if XLuaUiManager.IsUiShow("UiOnlineBoss") or XLuaUiManager.IsUiShow("UiOnlineBossActivity") then + XFubenBossOnlineManager.PopOverTips() + return true + end + return false + end + + XFubenBossOnlineManager.Init() + return XFubenBossOnlineManager +end + +XRpc.NotifyBossOnlineActivityStatus = function(data) + XDataCenter.FubenBossOnlineManager.OnRefreshBossData(data) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XFubenBossSingleManager.lua b/Resources/Scripts/XManager/XFubenBossSingleManager.lua new file mode 100644 index 00000000..98e35d4e --- /dev/null +++ b/Resources/Scripts/XManager/XFubenBossSingleManager.lua @@ -0,0 +1,706 @@ +XFubenBossSingleManagerCreator = function() + + local XFubenBossSingleManager = {} + + -- 重置倒计时 + local RESET_COUNT_DOWN_NAME = "SingleBossReset" + + -- templates + local BossSingleGradeCfg = {} + local RankRewardCfg = {} -- key = levelType, value = {cfg} + local ScoreRewardCfg = {} -- key = levelType, value = {cfg} + local BossSectionCfg = {} + local BossChapterTemplates = {} + local BossStageCfg = {} + local BossSectionInfo = {} + + local FubenBossSingleData = {} + local SelfRankData = {} + local BossList = {} + + local LastSyncServerTimes = {} + local RankData = {} + local RankRole = {} + + local NeedResetFlag = false + + local METHOD_NAME = { + GetSelfRank = "BossSingleRankInfoRequest", + GetRankData = "BossSingleGetRankRequest", + GetReward = "BossSingleGetRewardRequest", + AutoFight = "BossSingleAutoFightRequest", + SaveScore = "BossSingleSaveScoreRequest", + ChooseLevelType = "BossSingleSelectLevelTypeRequest", + } + + local SYNC_SERVER_BOSS_SECOND = 20 + XFubenBossSingleManager.MAX_RANK_COUNT = CS.XGame.ClientConfig:GetInt("BossSingleMaxRanCount") + + function XFubenBossSingleManager.Init() + BossSingleGradeCfg = XFubenBossSingleConfigs.GetBossSingleGradeCfg() + BossSectionCfg = XFubenBossSingleConfigs.GetBossSectionCfg() + BossSectionInfo = XFubenBossSingleConfigs.GetBossSectionInfo() + BossStageCfg = XFubenBossSingleConfigs.GetBossStageCfg() + RankRole = XFubenBossSingleConfigs.GetRankRole() + ScoreRewardCfg = XFubenBossSingleConfigs.GetScoreRewardCfg() + RankRewardCfg = XFubenBossSingleConfigs.GetRankRewardCfg() + end + + function XFubenBossSingleManager.InitStageInfo() + for _, sectionCfg in pairs(BossSectionCfg) do + for i = 1, #sectionCfg.StageId do + local bossStageCfg = BossStageCfg[sectionCfg.StageId[i]] + local stageInfo = XDataCenter.FubenManager.GetStageInfo(bossStageCfg.StageId) + stageInfo.BossSectionId = sectionCfg.Id + stageInfo.Type = XDataCenter.FubenManager.StageType.BossSingle + end + end + end + + function XFubenBossSingleManager.GetResetCountDownName() + return RESET_COUNT_DOWN_NAME + end + + -- function XFubenBossSingleManager.FinishFight(settle) + -- XDataCenter.FubenManager.ChallengeWin(settle) + -- end + function XFubenBossSingleManager.GetBossSingleTemplates() + return BossChapterTemplates + end + + function XFubenBossSingleManager.GetRankLevelCfg() + local cfgs = {} + for _, cfg in ipairs(BossSingleGradeCfg) do + table.insert(cfgs, cfg) + end + + table.sort(cfgs, function(a, b) + return a.LevelType < b.LevelType + end) + + return cfgs + end + + function XFubenBossSingleManager.GetRankLevelCfgByType(type) + return BossSingleGradeCfg[type] + end + + function XFubenBossSingleManager.GetRankLevelCfgs() + return BossSingleGradeCfg + end + + function XFubenBossSingleManager.GetRankRewardCfg(levelType) + return RankRewardCfg[levelType] + end + + function XFubenBossSingleManager.GetScoreRewardCfg(levelType) + return ScoreRewardCfg[levelType] + end + + function XFubenBossSingleManager.GetBossSectionCfg(bossId) + return BossSectionCfg[bossId] + end + + function XFubenBossSingleManager.GetBossSectionInfo(bossId) + return BossSectionInfo[bossId] + end + + function XFubenBossSingleManager.GetBossStageCfg(bossStageId) + return BossStageCfg[bossStageId] + end + + function XFubenBossSingleManager.RefreshBossSingleData(bossSingleData) + if not bossSingleData then return end + + local oldActivityId = FubenBossSingleData.ActivityNo + FubenBossSingleData = bossSingleData + BossList = bossSingleData.BossList + XCountDown.CreateTimer(RESET_COUNT_DOWN_NAME, FubenBossSingleData.RemainTime) + + local newActivityId = bossSingleData.ActivityNo + if oldActivityId and newActivityId and oldActivityId ~= newActivityId then + XFubenBossSingleManager.SetNeedReset(true) + XEventManager.DispatchEvent(XEventId.EVENT_FUBEN_SINGLE_BOSS_RESET) + end + end + + function XFubenBossSingleManager.GetCharacterChallengeCount(charId) + return FubenBossSingleData.CharacterPoints[charId] or 0 + end + + function XFubenBossSingleManager.GetBoosSingleData() + return FubenBossSingleData + end + + function XFubenBossSingleManager.GetProposedLevel(stageId) + local levelType = FubenBossSingleData.LevelType + local bossSingleGradeCfg = BossSingleGradeCfg[levelType] + return XDataCenter.FubenManager.GetStageProposedLevel(stageId, bossSingleGradeCfg.MaxPlayerLevel) + end + + function XFubenBossSingleManager.GetPreFullScore(stageId) + local levelType = FubenBossSingleData.LevelType + local cfg = BossStageCfg[stageId] + if not cfg then + return 0 + end + + local fullScore = cfg.PreFullScore[levelType] + if not fullScore then + return 0 + end + + return fullScore + end + + function XFubenBossSingleManager.GetNpcScores(stageId, bossLeftHp, bossMaxHp) + local levelType = FubenBossSingleData.LevelType + local cfg = RankRole[stageId] + if not cfg then + XLog.ErrorTableDataNotFound("XFubenBossSingleManager.GetNpcScores", + "cfg", "Share/Fuben/BossSingle/BossSingleScoreRule.tab", "stageId", tostring(stageId)) + return 0 + end + local bossLoseHpScore = 0 + if bossMaxHp > 0 then + bossLoseHpScore = math.floor((bossMaxHp - bossLeftHp) / bossMaxHp / cfg.BossLoseHp[levelType] * cfg.BossLoseHpScore[levelType]) + end + return bossLoseHpScore + end + + -- 检查奖励是否领取 + function XFubenBossSingleManager.CheckRewardGet(rewardId) + local rewardIds = FubenBossSingleData.RewardIds + for _, id in pairs(rewardIds) do + if rewardId == id then + return true + end + end + return false + end + + -- 检查奖励是否还有奖励需要领取 + function XFubenBossSingleManager.CheckRewardRedHint() + local index = FubenBossSingleData.LevelType + local cfgs = XFubenBossSingleManager.GetScoreRewardCfg(index) + + if not cfgs then return -1 end + + local totalScore = FubenBossSingleData.TotalScore + local rewardIds = FubenBossSingleData.RewardIds + + for _, v in pairs(cfgs) do + local canGet = totalScore >= v.Score + local got = false + if canGet then + for _, id in pairs(rewardIds) do + if id == v.Id then + got = true + break + end + end + + if not got then + return 1 + end + end + end + + return -1 + end + + -- 检查自动战斗保存 + function XFubenBossSingleManager.CheckAtuoFight(stageId) + for _, v in pairs(FubenBossSingleData.HistoryList) do + if v.StageId == stageId then + return v + end + end + + return nil + end + + function XFubenBossSingleManager.CheckStagePassed(sectionId, index) + local sectionInfo = XFubenBossSingleManager.GetBossSectionInfo(sectionId) + local stageId = sectionInfo[index].StageId + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + return stageInfo.Unlock + end + + function XFubenBossSingleManager.GetCurScoreRewardCfg() + local curScore = FubenBossSingleData.TotalScore + local levelType = FubenBossSingleData.LevelType + + for i = 1, #ScoreRewardCfg[levelType] do + if curScore < ScoreRewardCfg[levelType][i].Score then + return ScoreRewardCfg[levelType][i] + end + end + end + + function XFubenBossSingleManager.GetMaxStamina() + local levelType = FubenBossSingleData.LevelType + local levelTypeCfg = XFubenBossSingleManager.GetRankLevelCfgByType(levelType) + if not levelTypeCfg then + XLog.ErrorTableDataNotFound("XFubenBossSingleManager.GetMaxStamina", + "levelTypeCfg", "Share/Fuben/BossSingle/BossSingleGrade.tab", "levelType", tostring(levelType)) + return 0 + end + + return levelTypeCfg.StaminaCount + end + + function XFubenBossSingleManager.GetChallengeCount() + local levelType = FubenBossSingleData.LevelType + local levelTypeCfg = XFubenBossSingleManager.GetRankLevelCfgByType(levelType) + if not levelTypeCfg then + XLog.ErrorTableDataNotFound("XFubenBossSingleManager.GetChallengeCount", + "levelTypeCfg", "Share/Fuben/BossSingle/BossSingleGrade.tab", "levelType", tostring(levelType)) + return 0 + end + + if XTime.CheckWeekend() then + return levelTypeCfg.WeekChallengeCount + else + return levelTypeCfg.ChallengeCount + end + end + + function XFubenBossSingleManager.GetCurBossIndex(bossId) + local sectionInfo = XFubenBossSingleManager.GetBossSectionInfo(bossId) + local hasHideBoss = XDataCenter.FubenBossSingleManager.CheckLevelHasHideBoss() + local count = hasHideBoss and #sectionInfo or #sectionInfo - 1 + + for i = 1, count do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(sectionInfo[i].StageId) + if not stageInfo.Passed then + count = sectionInfo[i].DifficultyType + break + end + end + + -- 打到隐藏Boss 但是没有达到开启条件处理 + if sectionInfo[count].DifficultyType == XFubenBossSingleConfigs.DifficultyType.Hide then + local hideBossOpen, _ = XFubenBossSingleManager.CheckHideBossOpen(sectionInfo[count]) + if not hideBossOpen then + count = sectionInfo[#sectionInfo - 1].DifficultyType + end + end + + return count + end + + function XFubenBossSingleManager.CheckBossAllPassed(bossId) + local sectionInfo = XFubenBossSingleManager.GetBossSectionInfo(bossId) + for i = 1, #sectionInfo do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(sectionInfo[i].StageId) + if not stageInfo.Passed then + return false + end + end + return true + end + + function XFubenBossSingleManager.GetBossCurDifficultyInfo(bossId, index) + local sectionInfo = XFubenBossSingleManager.GetBossSectionInfo(bossId) + local sectionCfg = XFubenBossSingleManager.GetBossSectionCfg(bossId) + local hasHideBoss = XDataCenter.FubenBossSingleManager.CheckLevelHasHideBoss() + local count = hasHideBoss and #sectionInfo or #sectionInfo - 1 + local curBossCfg = sectionInfo[count] + for i = 1, count do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(sectionInfo[i].StageId) + if not stageInfo.Passed then + curBossCfg = sectionInfo[i] + break + end + end + + local now = XTime.GetServerNowTimestamp() + local tagTmepIcon = nil + for i = 1, #sectionCfg.ActivityTimeId do + local startTime, endTime = XFunctionManager.GetTimeByTimeId(sectionCfg.ActivityTimeId[i]) + if startTime and endTime and now >= startTime and now < endTime then + tagTmepIcon = sectionCfg.ActivityTag[i] + break + end + end + + local groupTempId = nil + local groupTempName = nil + local groupTempIcon = nil + local hideBossOpen = false + + local levelTypeCfg = XFubenBossSingleManager.GetRankLevelCfgByType(FubenBossSingleData.LevelType) + if levelTypeCfg and levelTypeCfg.GroupId[index] then + groupTempId = levelTypeCfg.GroupId[index] + local groupInfo = XFubenBossSingleConfigs.GetBossSingleGroupById(groupTempId) + groupTempName = groupInfo.GroupName + groupTempIcon = groupInfo.GroupIcon + hideBossOpen = levelTypeCfg.HideBossOpen + end + + if hideBossOpen then + hideBossOpen = XFubenBossSingleManager.CheckHideBossOpen(curBossCfg) + end + + -- 打到隐藏Boss 但是没有达到开启条件处理 + if not hideBossOpen and curBossCfg.DifficultyType == XFubenBossSingleConfigs.DifficultyType.Hide then + curBossCfg = sectionInfo[#sectionInfo - 1] + end + + local info = { + bossName = curBossCfg.BossName, + bossIcon = sectionCfg.BossHeadIcon, + bossDiffiName = curBossCfg.DifficultyDesc, + tagIcon = tagTmepIcon, + groupId = groupTempId, + groupName = groupTempName, + groupIcon = groupTempIcon, + isHideBoss = hideBossOpen + } + return info + end + + function XFubenBossSingleManager.CheckLevelHasHideBoss() + local levelTypeCfg = XFubenBossSingleManager.GetRankLevelCfgByType(FubenBossSingleData.LevelType) + if levelTypeCfg then + return levelTypeCfg.HideBossOpen + end + + return false + end + + function XFubenBossSingleManager.CheckHideBossOpenByBossId(bossId) + local sectionInfo = XFubenBossSingleManager.GetBossSectionInfo(bossId) + local hideBossCfg = nil + local closeDesc = "" + + for i = 1, #sectionInfo do + if sectionInfo[i].DifficultyType == XFubenBossSingleConfigs.DifficultyType.Hide then + hideBossCfg = sectionInfo[i] + break + end + end + + if hideBossCfg == nil then + return false, closeDesc + end + + return XFubenBossSingleManager.CheckHideBossOpen(hideBossCfg) + end + + function XFubenBossSingleManager.CheckHideBossOpen(bossStageCfg) + if bossStageCfg.DifficultyType ~= XFubenBossSingleConfigs.DifficultyType.Hide then + return false, nil + end + + local isOpen, desc = XFubenBossSingleManager.CheckBossOpen(bossStageCfg) + return isOpen, desc + end + + function XFubenBossSingleManager.CheckBossOpen(bossStageCfg) + local isOpen = true + local desc = "" + + for i = 1, #bossStageCfg.OpenCondition do + if bossStageCfg.OpenCondition[i] and bossStageCfg.OpenCondition[i] > 0 then + isOpen, desc = XConditionManager.CheckCondition(bossStageCfg.OpenCondition[i]) + end + + if not isOpen then + break + end + end + + return isOpen, desc + end + + function XFubenBossSingleManager.GetBossNameInfo(bossId, stageId) + local stageName = "" + local chapterName = "" + local sectionInfo = XFubenBossSingleManager.GetBossSectionInfo(bossId) + for i = 1, #sectionInfo do + if sectionInfo[i].StageId == stageId then + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + local curBossStageCfg = XFubenBossSingleManager.GetBossStageCfg(sectionInfo[i].StageId) + stageName = stageCfg.Name + chapterName = curBossStageCfg.BossName + end + end + return chapterName, stageName + end + + function XFubenBossSingleManager.GetBossStageInfo(stageId) + local bossId = XDataCenter.FubenManager.GetStageInfo(stageId).BossSectionId + local sectionInfo = XFubenBossSingleManager.GetBossSectionInfo(bossId) + for i = 1, #sectionInfo do + if sectionInfo[i].StageId == stageId then + return sectionInfo[i] + end + end + return nil + end + + function XFubenBossSingleManager.GetBossDifficultName(stageId) + local name = "" + local bossId = XDataCenter.FubenManager.GetStageInfo(stageId).BossSectionId + local sectionInfo = XFubenBossSingleManager.GetBossSectionInfo(bossId) + for i = 1, #sectionInfo do + if sectionInfo[i].StageId == stageId then + name = sectionInfo[i].DifficultyDesc + end + end + return name + end + + function XFubenBossSingleManager.GetRankSpecialIcon(num, levelType) + if not levelType then + levelType = FubenBossSingleData.LevelType + end + + local cfgs = XFubenBossSingleManager.GetRankRewardCfg(levelType) + return cfgs[num].RankIcon + end + + --超频区选择 + function XFubenBossSingleManager.CheckNeedChooseLevelType() + return FubenBossSingleData.LevelType == XFubenBossSingleConfigs.LevelType.Chooseable + end + + function XFubenBossSingleManager.IsInLevelTypeHigh() + return FubenBossSingleData.LevelType == XFubenBossSingleConfigs.LevelType.High + end + + function XFubenBossSingleManager.IsInLevelTypeExtreme() + return FubenBossSingleData.LevelType == XFubenBossSingleConfigs.LevelType.Extreme + end + + function XFubenBossSingleManager.IsChooseLevelTypeConditionOk() + if not XFubenBossSingleManager.IsInLevelTypeHigh() then return false end + + local needScore = XFubenBossSingleManager.GetChooseLevelTypeNeedScore() + if needScore > 0 and FubenBossSingleData.MaxScore >= needScore then return true end + + return XPlayer.IsMedalUnlock(XMedalConfigs.MedalId.BossSingle) + end + + function XFubenBossSingleManager.GetChooseLevelTypeNeedScore() + local levelType = FubenBossSingleData.LevelType + 1 + local bossSingleGradeCfg = BossSingleGradeCfg[levelType] + return bossSingleGradeCfg and bossSingleGradeCfg.NeedScore or 0 + end + + function XFubenBossSingleManager.OpenBossSingleView() + local func = function() + XLuaUiManager.Open("UiFubenBossSingle", FubenBossSingleData, BossList) + end + XFubenBossSingleManager.RequestSelfRank(func) + end + + function XFubenBossSingleManager.ReqChooseLevelType(levelType) + if not levelType then return end + + local req = { LevelId = levelType } + XNetwork.Call(METHOD_NAME.ChooseLevelType, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + XDataCenter.FubenBossSingleManager.RefreshBossSingleData(res.FubenBossSingleData) + XFubenBossSingleManager.OpenBossSingleView() + end) + end + + function XFubenBossSingleManager.RefreshSelfRank(rank, totalRank) + SelfRankData.Rank = rank + SelfRankData.TotalRank = totalRank + end + + function XFubenBossSingleManager.GetSelfRank() + return SelfRankData.Rank or 0 + end + + function XFubenBossSingleManager.GetSelfTotalRank() + return SelfRankData.TotalRank or 0 + end + + function XFubenBossSingleManager.RefreshChallengeCount(challengeCount) + FubenBossSingleData.ChallengeCount = challengeCount + end + + function XFubenBossSingleManager.RequestSelfRank(cb) + XNetwork.Call(METHOD_NAME.GetSelfRank, nil, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + XFubenBossSingleManager.RefreshSelfRank(res.Rank, res.TotalRank) + + if cb then + cb() + end + end) + end + + function XFubenBossSingleManager.GetRankData(cb, levelType) + local now = XTime.GetServerNowTimestamp() + if LastSyncServerTimes[levelType] + and LastSyncServerTimes[levelType] + SYNC_SERVER_BOSS_SECOND >= now then + if cb then + cb(RankData[levelType]) + end + return + end + + local req = { Level = levelType } + XNetwork.Call(METHOD_NAME.GetRankData, req, + function(response) + if response.Code ~= XCode.Success then + XUiManager.TipCode(response.Code) + return + end + LastSyncServerTimes[levelType] = now + + local luaRankData = {} + luaRankData.MineRankNum = response.RankNum + luaRankData.HistoryMaxRankNum = response.HistoryNum + luaRankData.LeftTime = response.LeftTime + luaRankData.TotalCount = response.TotalCount + luaRankData.rankData = {} + + if response.RankList and #response.RankList > 0 then + XTool.LoopCollection(response.RankList, function(data) + local luaRankMetaData = {} + luaRankMetaData.PlayerId = data.Id + luaRankMetaData.RankNum = data.RankNum + luaRankMetaData.HeadPortraitId = data.HeadPortraitId + luaRankMetaData.HeadFrameId = data.HeadFrameId + luaRankMetaData.Name = data.Name + luaRankMetaData.Score = data.Score + luaRankMetaData.CharacterHeadData = data.CharacterList or {} + table.insert(luaRankData.rankData, luaRankMetaData) + end) + end + + RankData[levelType] = luaRankData + if cb then + cb(RankData[levelType]) + end + end) + end + + function XFubenBossSingleManager.GetRankRewardReq(rewardId, cb) + local req = { Id = rewardId } + XNetwork.Call(METHOD_NAME.GetReward, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + table.insert(FubenBossSingleData.RewardIds, rewardId) + + if cb then + cb(res.RewardGoodsList) + end + end) + end + + -- 自动战斗 + function XFubenBossSingleManager.AutoFight(stagedId, cb) + local req = { StageId = stagedId } + XNetwork.Call(METHOD_NAME.AutoFight, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + if cb then + cb(res.Supply > 0) + end + end) + end + + -- 保存战斗数据 + function XFubenBossSingleManager.SaveScore(stagedId, cb) + local req = { StageId = stagedId } + XNetwork.Call(METHOD_NAME.SaveScore, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + if cb then + cb(res.Supply > 0) + end + end) + end + + function XFubenBossSingleManager.CheckPreFight() + local curCount = XFubenBossSingleManager.GetBoosSingleData().ChallengeCount + local allCount = XFubenBossSingleManager.GetChallengeCount() + if allCount - curCount <= 0 then + local msg = CS.XTextManager.GetText("FubenChallengeCountNotEnough") + XUiManager.TipMsg(msg) + return false + end + return true + end + + -- 胜利 & 奖励界面 + function XFubenBossSingleManager.ShowReward(winData) + if XDataCenter.FubenManager.CheckHasFlopReward(winData) then + XLuaUiManager.Open("UiFubenFlopReward", function() + XLuaUiManager.PopThenOpen("UiSettleWinSingleBoss", winData) + end, winData) + else + XLuaUiManager.Open("UiSettleWinSingleBoss", winData) + end + end + + function XFubenBossSingleManager.IsBossSingleOpen() + local isOpen = XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.FubenChallengeBossSingle) + return isOpen + end + + function XFubenBossSingleManager.SetNeedReset(value) + NeedResetFlag = value and true + end + + function XFubenBossSingleManager.IsNeedReset() + return NeedResetFlag + end + + function XFubenBossSingleManager.OnActivityEnd() + if not XFubenBossSingleManager.IsNeedReset() then + return + end + + if CS.XFight.IsRunning or XLuaUiManager.IsUiLoad("UiLoading") then + return + end + + XUiManager.TipText("BossOnlineOver") + XLuaUiManager.RunMain() + + XFubenBossSingleManager.SetNeedReset(false) + end + + XFubenBossSingleManager.Init() + return XFubenBossSingleManager +end + +XRpc.NotifyFubenBossSingleData = function(data) + XDataCenter.FubenBossSingleManager.RefreshBossSingleData(data.FubenBossSingleData) + XEventManager.DispatchEvent(XEventId.EVENT_FUBEN_SINGLE_BOSS_SYNC) +end + +XRpc.NotifyBossSingleRankInfo = function(data) + XDataCenter.FubenBossSingleManager.RefreshSelfRank(data.Rank, data.TotalRank) + XEventManager.DispatchEvent(XEventId.EVENT_FUBEN_SINGLE_BOSS_RANK_SYNC) +end + +XRpc.NotifyBossSingleChallengeCount = function(data) + XDataCenter.FubenBossSingleManager.RefreshChallengeCount(data.ChallengeCount) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XFubenCoupleCombatManager.lua b/Resources/Scripts/XManager/XFubenCoupleCombatManager.lua new file mode 100644 index 00000000..dc67e713 --- /dev/null +++ b/Resources/Scripts/XManager/XFubenCoupleCombatManager.lua @@ -0,0 +1,407 @@ +local tableInsert = table.insert +local ipairs = ipairs +local pairs = pairs +local KEY_STAGE = "NewStage" + +XFubenCoupleCombatManagerCreator = function() + local XFubenCoupleCombatManager = {} + local ActivityInfo = nil + local ActivityDay = 0 + local DefaultActivityInfo = nil + + local StageRecordDic = {} + local RobotRecordDic = {} + local StageChapterDic = {} + local NewStageReadDic = {} + local IsRegisterEditBattleProxy = false + + -------- local function begin ---------- + local function Init() + if ActivityInfo then + DefaultActivityInfo = ActivityInfo + else + local activityTemplates = XFubenCoupleCombatConfig.GetActTemplates() + for _, template in pairs(activityTemplates) do + DefaultActivityInfo = XFubenCoupleCombatConfig.GetActivityTemplateById(template.Id) + if XFunctionManager.CheckInTimeByTimeId(DefaultActivityInfo.TimeId) then + ActivityInfo = DefaultActivityInfo + end + end + end + XFubenCoupleCombatManager.RegisterEditBattleProxy() + end + + local function GetKey(key) + return string.format("%s_FubenCoupleCombat_%d_%s", tostring(XPlayer.Id), ActivityInfo.Id, key) + end + + -------- local function end ---------- + local FUBEN_COUPLE_COMBAT_PROTO = { + ResetStageMemberRequest = "CoupleCombatResetStageMemberRequest", + } + + function XFubenCoupleCombatManager.GetCurrentActTemplate() + return ActivityInfo + end + + function XFubenCoupleCombatManager.GetChapterTemplate(type) + if not ActivityInfo then return {} end + local id = ActivityInfo.ChapterIds[type] + return XFubenCoupleCombatConfig.GetChapterTemplate(id) or {} + end + + function XFubenCoupleCombatManager.OnActivityEnd() + XLuaUiManager.RunMain() + if XFubenCoupleCombatManager.GetIsActivityEnd() then + XUiManager.TipText("ActivityMainLineEnd", XUiManager.UiTipType.Wrong) + else + XUiManager.TipText("ArenaOnlineTimeOut", XUiManager.UiTipType.Wrong, true) + end + end + + -- 检测是否开启模式 + function XFubenCoupleCombatManager.CheckModeOpen(type) + if not type then return end + if XFubenCoupleCombatManager.GetIsActivityEnd() then + XUiManager.TipText("RougeLikeNotInActivityTime") + return false, CS.XTextManager.GetText("RougeLikeNotInActivityTime") + end + + local chapter = XFubenCoupleCombatManager.GetChapterTemplate(type) + if not chapter then return true end + if not XFubenCoupleCombatManager.CheckStageOpen(chapter.StageIds[1]) then + return XFubenCoupleCombatManager.CheckStageOpen(chapter.StageIds[1], true) + end + + if type == XFubenCoupleCombatConfig.StageType.Hard then + chapter = XFubenCoupleCombatManager.GetChapterTemplate(XFubenCoupleCombatConfig.StageType.Normal) + local stageId = chapter.StageIds[#chapter.StageIds] + if not StageRecordDic[stageId] then + return false, CS.XTextManager.GetText("CoupleCombatHardModeNotOpen") + end + end + + return true + end + + -- 检测关卡是否处于开放状态 + function XFubenCoupleCombatManager.CheckStageOpen(stageId, isGetTime) + local stageInterInfo = XFubenCoupleCombatConfig.GetStageInfo(stageId) + if not stageInterInfo then return end + if ActivityDay >= stageInterInfo.OpenDay then + return true + elseif isGetTime then + local nowTime = XTime.GetServerNowTimestamp() + local refreshTime = XTime.GetSeverNextRefreshTime() + local remainTime = XUiHelper.GetTime((stageInterInfo.OpenDay - ActivityDay - 1) * 60 * 60 * 24 + refreshTime - nowTime, XUiHelper.TimeFormatType.MOE_WAR) + return false, CS.XTextManager.GetText("ScheOpenCountdown", remainTime) + else + return false + end + end + + -- 红点逻辑:有新关卡时重置 + function XFubenCoupleCombatManager.CheckNewStage(type) + if not XFubenCoupleCombatManager.CheckModeOpen(type) then return false end + + local chapter = XFubenCoupleCombatManager.GetChapterTemplate(type) + for _, v in ipairs(chapter.StageIds) do + if XFubenCoupleCombatManager.CheckStageOpen(v) and not NewStageReadDic[v] then + return true + end + end + + return false + end + + function XFubenCoupleCombatManager.SetReadNewStageMark(type) + if not XFubenCoupleCombatManager.CheckModeOpen(type) then return end + local needSave = false + local chapter = XFubenCoupleCombatManager.GetChapterTemplate(type) + for _, v in ipairs(chapter.StageIds) do + if XFubenCoupleCombatManager.CheckStageOpen(v) and not NewStageReadDic[v] then + NewStageReadDic[v] = true + needSave = true + end + end + + if needSave then + XSaveTool.SaveData(GetKey(KEY_STAGE), NewStageReadDic) + end + end + + -- 获取所有关卡进度 + function XFubenCoupleCombatManager.GetStageSchedule(stageType) + local passCount = 0 + local allCount = 0 + for _, type in pairs(XFubenCoupleCombatConfig.StageType) do + if stageType and type ~= stageType then + goto CONTINUE + end + local chapter = XFubenCoupleCombatManager.GetChapterTemplate(type) + if XFubenCoupleCombatManager.CheckStageOpen(chapter.StageIds[1]) then + allCount = allCount + #chapter.StageIds + for _, stageId in ipairs(chapter.StageIds) do + if StageRecordDic[stageId] and next(StageRecordDic[stageId]) then + passCount = passCount + 1 + end + end + end + ::CONTINUE:: + end + + return passCount, allCount + end + + function XFubenCoupleCombatManager.GetFeatureMatch(stageId, teamData) + local matchDic = {} + local featureList = {} + local stageInterInfo = XFubenCoupleCombatConfig.GetStageInfo(stageId) + if not stageInterInfo then return matchDic end + featureList[0] = stageInterInfo.Feature + for _, v in ipairs(stageInterInfo.Feature) do + matchDic[v] = 0 + end + for i, id in ipairs(teamData) do + local memberInfo = XFubenCoupleCombatConfig.GetRobotInfo(id) + if memberInfo then + featureList[i] = memberInfo.Feature + for _, v in ipairs(memberInfo.Feature) do + if matchDic[v] then + matchDic[v] = matchDic[v] + 1 + end + end + end + end + return matchDic, featureList + end + + -- 检测机器人是否已使用状态 + function XFubenCoupleCombatManager.CheckRobotUsed(stageId, robotId) + if not StageChapterDic[stageId] then return end + local chapterId = StageChapterDic[stageId].Id + if not RobotRecordDic[chapterId] then + return + end + return RobotRecordDic[chapterId][robotId] + end + + function XFubenCoupleCombatManager.GetStageUsedRobot(stageId) + return StageRecordDic[stageId] or {} + end + + function XFubenCoupleCombatManager.GetRobotByStage(stageId) + return StageChapterDic[stageId] and StageChapterDic[stageId].RobotIds + end + + -- [初始化数据] + function XFubenCoupleCombatManager.InitStageInfo() + for _, chapter in pairs(XFubenCoupleCombatConfig.GetChapterTemplates()) do + for _, stageId in ipairs(chapter.StageIds) do + StageChapterDic[stageId] = chapter + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + if stageInfo then + stageInfo.Type = XDataCenter.FubenManager.StageType.CoupleCombat + end + end + end + + -- 通关后会执行InitStage 所以需要刷新 + XFubenCoupleCombatManager.RefreshStagePassed() + end + + function XFubenCoupleCombatManager.RefreshStagePassed() + for _, chapter in pairs(XFubenCoupleCombatConfig.GetChapterTemplates()) do + for _, stageId in ipairs(chapter.StageIds) do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + if stageInfo then + stageInfo.Passed = StageRecordDic[stageId] or false + --stageInfo.StarsMap = XFubenCoupleCombatManager.GetStarMap(stageId) + stageInfo.Unlock = XFubenCoupleCombatManager.CheckStageOpen(stageId) + stageInfo.IsOpen = true + + if stageCfg.RequireLevel > 0 and XPlayer.Level < stageCfg.RequireLevel then + stageInfo.Unlock = false + end + + for _, preStageId in pairs(stageCfg.PreStageId or {}) do + if preStageId > 0 then + if not StageRecordDic[preStageId] then + stageInfo.Unlock = false + stageInfo.IsOpen = false + break + end + end + end + end + end + end + end + + function XFubenCoupleCombatManager.PreFight(stage, teamId) + local preFight = {} + --preFight.CardIds = {} + preFight.RobotIds = {} + preFight.StageId = stage.StageId + local teamData = XDataCenter.TeamManager.GetTeamData(teamId) + for i, v in pairs(teamData) do + local isRobot = XRobotManager.CheckIsRobotId(v) + preFight.RobotIds[i] = isRobot and v or 0 + end + + preFight.CaptainPos = XDataCenter.TeamManager.GetTeamCaptainPos(teamId) + preFight.FirstFightPos = XDataCenter.TeamManager.GetTeamFirstFightPos(teamId) + + return preFight + end + + function XFubenCoupleCombatManager.GetAvailableActs() + local act = ActivityInfo or DefaultActivityInfo + local activityList = {} + if act and + not XFubenCoupleCombatManager.GetIsActivityEnd() and + not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.FubenCoupleCombat) then + tableInsert(activityList, { + Id = act.Id, + Type = XDataCenter.FubenManager.ChapterType.CoupleCombat, + Name = act.Name, + Icon = act.BannerBg, + }) + end + return activityList + end + + --判断活动是否开启 + function XFubenCoupleCombatManager.GetIsActivityEnd() + local timeNow = XTime.GetServerNowTimestamp() + local isEnd = timeNow >= XFubenCoupleCombatManager.GetEndTime() + local isStart = timeNow >= XFubenCoupleCombatManager.GetStartTime() + local inActivity = (not isEnd) and (isStart) + return not inActivity, timeNow < XFubenCoupleCombatManager.GetStartTime() + end + + --获取活动开始时间 + function XFubenCoupleCombatManager.GetStartTime() + if DefaultActivityInfo then + return XFunctionManager.GetStartTimeByTimeId(DefaultActivityInfo.TimeId) or 0 + end + return 0 + end + + --获取活动结束时间 + function XFubenCoupleCombatManager.GetEndTime() + if DefaultActivityInfo then + return XFunctionManager.GetEndTimeByTimeId(DefaultActivityInfo.TimeId) or 0 + end + return 0 + end + + -- 主题活动页面是否可挑战接口 + function XFubenCoupleCombatManager.IsChallengeable() + if not ActivityInfo then return false end + for _, type in pairs(XFubenCoupleCombatConfig.StageType) do + if XFubenCoupleCombatManager.CheckNewStage(type) then + return true + end + end + + return false + end + + -- 注册出战界面代理 + function XFubenCoupleCombatManager.RegisterEditBattleProxy() + if IsRegisterEditBattleProxy then return end + IsRegisterEditBattleProxy = true + XUiNewRoomSingleProxy.RegisterProxy(XDataCenter.FubenManager.StageType.CoupleCombat, + require("XUi/XUiFubenCoupleCombat/Proxy/XUiCoupleCombatNewRoomSingle")) + XUiRoomCharacterProxy.RegisterProxy(XDataCenter.FubenManager.StageType.CoupleCombat, + require("XUi/XUiFubenCoupleCombat/Proxy/XUiCoupleCombatRoomCharacter")) + end + + function XFubenCoupleCombatManager.ResetStage(stageId, cb) + if not StageRecordDic[stageId] then return end + XNetwork.Call(FUBEN_COUPLE_COMBAT_PROTO.ResetStageMemberRequest, { StageId = stageId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + for _, robotId in pairs(StageRecordDic[stageId]) do + local chapterId = StageChapterDic[stageId].Id + RobotRecordDic[chapterId][robotId] = nil + end + + StageRecordDic[stageId] = {} + if cb then cb() end + CsXGameEventManager.Instance:Notify(XEventId.EVENT_FUBEN_COUPLECOMBAT_UPDATE) + end) + end + + --登录/活动开始/跨周时下发 + function XFubenCoupleCombatManager.NotifyData(data) + ActivityInfo = XFubenCoupleCombatConfig.GetActivityTemplateById(data.Data.ActivityId) + if not ActivityInfo then + CsXGameEventManager.Instance:Notify(XEventId.EVENT_ACTIVITY_ON_RESET, XDataCenter.FubenManager.StageType.CoupleCombat) + return + end + ActivityDay = data.ActivityDay + Init() + StageRecordDic = {} + RobotRecordDic = {} + for _, v in ipairs(data.Data.Stages) do + StageRecordDic[v.StageId] = v.RobotIds + local chapterId = StageChapterDic[v.StageId].Id + if not RobotRecordDic[chapterId] then + RobotRecordDic[chapterId] = {} + end + for _, robotId in pairs(v.RobotIds) do + RobotRecordDic[chapterId][robotId] = true + end + end + + XFubenCoupleCombatManager.RefreshStagePassed() + + NewStageReadDic = XSaveTool.GetData(GetKey(KEY_STAGE)) or {} + end + + -- 下发关卡数据(通关星数) + function XFubenCoupleCombatManager.NotifyStageData(stageInfo) + StageRecordDic[stageInfo.StageId] = stageInfo.RobotIds + + local chapterId = StageChapterDic[stageInfo.StageId].Id + if not RobotRecordDic[chapterId] then + RobotRecordDic[chapterId] = {} + end + for _, robotId in pairs(stageInfo.RobotIds) do + RobotRecordDic[chapterId][robotId] = true + end + + XFubenCoupleCombatManager.RefreshStagePassed() + CsXGameEventManager.Instance:Notify(XEventId.EVENT_FUBEN_COUPLECOMBAT_UPDATE) + end + + -- 下发活动天数 + function XFubenCoupleCombatManager.NotifyDailyData(data) + ActivityDay = data.ActivityDay + XFubenCoupleCombatManager.RefreshStagePassed() + CsXGameEventManager.Instance:Notify(XEventId.EVENT_FUBEN_COUPLECOMBAT_UPDATE) + end + + XEventManager.AddEventListener(XEventId.EVENT_LOGIN_DATA_LOAD_COMPLETE, function() + Init() + end) + return XFubenCoupleCombatManager +end + +XRpc.NotifyCoupleCombatData = function(data) + XDataCenter.FubenCoupleCombatManager.NotifyData(data) +end + +XRpc.NotifyCoupleCombatStageData = function(data) + XDataCenter.FubenCoupleCombatManager.NotifyStageData(data.StageData) +end + +XRpc.NotifyCoupleCombatDailyData = function(data) + XDataCenter.FubenCoupleCombatManager.NotifyDailyData(data) +end diff --git a/Resources/Scripts/XManager/XFubenDailyManager.lua b/Resources/Scripts/XManager/XFubenDailyManager.lua new file mode 100644 index 00000000..ddbb2711 --- /dev/null +++ b/Resources/Scripts/XManager/XFubenDailyManager.lua @@ -0,0 +1,297 @@ +XFubenDailyManagerCreator = function() + local XFubenDailyManager = {} + + local METHOD_NAME = { + ReceiveDailyReward = "ReceiveDailyRewardRequest", + } + + local ConditionType = { + LeverCondition = 1, + EventCondition = 2, + } + + local WEEK = 7 + local RefreshTime = 0 + + local DailySectionData = {} + local DailyRecord = {} + + function XFubenDailyManager.Init() + end + + function XFubenDailyManager.OpenFightLoading(stageId) + XEventManager.DispatchEvent(XEventId.EVENT_FIGHT_LOADINGFINISHED) + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + + if stageCfg and stageCfg.LoadingType then + XLuaUiManager.Open("UiLoading", stageCfg.LoadingType) + else + XLuaUiManager.Open("UiLoading", LoadingType.Fight) + end + end + + function XFubenDailyManager.CloseFightLoading(stageId) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + if stageInfo.DailyType == XDataCenter.FubenManager.ChapterType.EMEX then + -- XLuaUiManager.Remove("UiOnLineLoading") + XLuaUiManager.Remove("UiLoading") + else + XLuaUiManager.Remove("UiLoading") + end + end + + -- function XFubenDailyManager.ShowReward(winData) + -- local stageInfo = XDataCenter.FubenManager.GetStageInfo(winData.StageId) + -- if stageInfo.DailyType == XDataCenter.FubenManager.ChapterType.EMEX then + -- XEventManager.DispatchEvent(XEventId.EVENT_FUBEN_SHOW_REWARD, winData) + -- else + -- XLuaUiManager.Open("UiSettleWin", winData) + -- end + -- end + -- 需要显示多重挑战则需要加ShowReward + function XFubenDailyManager.ShowReward(winData) + if not winData then return end + XLuaUiManager.Open("UiRepeatChallengeSettleWin", winData) + end + + function XFubenDailyManager.InitFubenDailyData() + -- if fubenDailyData.DailySectionData then + -- for k, v in pairs(fubenDailyData.DailySectionData) do + -- DailySectionData[k] = v + -- end + -- end + end + + function XFubenDailyManager.GetDailySectionData(sectionId) + return DailySectionData[sectionId] + end + + + function XFubenDailyManager.SyncDailyReward(sectionId) + DailySectionData[sectionId].ReceiveReward = true + end + + function XFubenDailyManager.IsDayLock(Id) + + for k, v in pairs(XDailyDungeonConfigs.GetDailyDungeonDayOfWeek(Id)) do + if v > 0 and k == XFubenDailyManager.GetNowDayOfWeekByRefreshTime() then + return false + end + end + return true + end + + function XFubenDailyManager.GetConditionData(Id) + local functionNameId = {} + local data = {} + local dungeonRule = XDailyDungeonConfigs.GetDailyDungeonRulesById(Id) + if dungeonRule.Type == XDataCenter.FubenManager.ChapterType.GZTX then--日常構造體特訓 + functionNameId = XFunctionManager.FunctionName.FubenDailyGZTX + elseif dungeonRule.Type == XDataCenter.FubenManager.ChapterType.XYZB then--日常稀有裝備 + functionNameId = XFunctionManager.FunctionName.FubenDailyXYZB + elseif dungeonRule.Type == XDataCenter.FubenManager.ChapterType.TPCL then--日常突破材料 + functionNameId = XFunctionManager.FunctionName.FubenDailyTPCL + elseif dungeonRule.Type == XDataCenter.FubenManager.ChapterType.ZBJY then--日常裝備經驗 + functionNameId = XFunctionManager.FunctionName.FubenDailyZBJY + elseif dungeonRule.Type == XDataCenter.FubenManager.ChapterType.LMDZ then--日常螺母大戰 + functionNameId = XFunctionManager.FunctionName.FubenDailyLMDZ + elseif dungeonRule.Type == XDataCenter.FubenManager.ChapterType.JNQH then--日常技能强化 + functionNameId = XFunctionManager.FunctionName.FubenDailyJNQH + elseif dungeonRule.Type == XDataCenter.FubenManager.ChapterType.FZJQH then--日常辅助机强化 + functionNameId = XFunctionManager.FunctionName.FubenDailyFZJQH + elseif dungeonRule.Type == XDataCenter.FubenManager.ChapterType.Assign then--边界公约 + functionNameId = XFunctionManager.FunctionName.FubenAssign + end + data.IsLock = not XFunctionManager.JudgeCanOpen(functionNameId) + data.functionNameId = functionNameId + return data + end + function XFubenDailyManager.GetOpenDayString(rule) + --開放日顯示 + local tmpNum = { "One", "Two", "Three", "Four", "Five", "Six", "Diary" } + local dayStr = "" + local dayCount = 0 + local IsAllDay = false + for i = 1, WEEK do + if rule.OpenDayOfWeek[i] ~= 0 then + dayStr = dayStr .. CS.XTextManager.GetText(tmpNum[i]) + dayCount = dayCount + 1 + end + end + + if dayCount == WEEK then + dayStr = CS.XTextManager.GetText("FubenDailyAllDayOpen") + IsAllDay = true + end + + return dayStr, IsAllDay + end + + function XFubenDailyManager.GetMainLineFubenOrderId(stageId) + local chapterCfg = XFubenMainLineConfigs.GetChapterCfg() + for _, v1 in pairs(chapterCfg) do + for _, v2 in pairs(v1.StageId) do + if stageId == v2 then + return v1.OrderId .. "-" .. XDataCenter.FubenManager.GetStageCfg(v2).OrderId + end + end + end + return "" + end + + function XFubenDailyManager.GetEventOpen(Id) + local eventOpenData = {} + local eventText = "" + local dungeonRule = XDailyDungeonConfigs.GetDailyDungeonRulesById(Id) + local specialCondition = XDailyDungeonConfigs.GetDailySpecialConditionList() + local eventOpen = false + local nowTime = XTime.GetServerNowTimestamp() + local stratTime + local endTime + for _, v in pairs(dungeonRule.SpecialConditionId) do + if v ~= 0 then + if specialCondition[v].Type == ConditionType.LeverCondition then + + local tmpCon = XConditionManager.CheckPlayerCondition(specialCondition[v].IntParam[1]) + eventOpen = eventOpen or tmpCon + if tmpCon and eventText == "" then eventText = specialCondition[v].Text end + + elseif specialCondition[v].Type == ConditionType.EventCondition then + stratTime = XTime.ParseToTimestamp(specialCondition[v].StringParam[1]) + endTime = XTime.ParseToTimestamp(specialCondition[v].StringParam[2]) + if stratTime and endTime then + local tmpCon = nowTime > stratTime and nowTime < endTime + eventOpen = eventOpen or tmpCon + if tmpCon and eventText == "" then eventText = specialCondition[v].Text end + end + end + else + eventOpen = eventOpen or false + end + end + eventOpenData.IsOpen = eventOpen + eventOpenData.Text = eventText + return eventOpenData + end + + function XFubenDailyManager.GetDropDataList(Id, dayOfWeek)--根据日期获得掉落的物品组 + local RandomDrop = {} + local FixedDrop = {} + local DropGroupDatas = {} + for _, v in pairs(XDailyDungeonConfigs.GetDailyDropGroupList()) do + if v.DungeonId == Id then + table.insert(DropGroupDatas, v) + end + end + + for _, v in pairs(DropGroupDatas) do + if v.OpenDayOfWeek == dayOfWeek then + RandomDrop = XRewardManager.GetRewardList(v.RandomRewardId) + + FixedDrop = XRewardManager.GetRewardList(v.FixedRewardId) + + end + end + return RandomDrop, FixedDrop + end + + function XFubenDailyManager.GetNowDayOfWeekByRefreshTime() + local nowTime = XTime.GetServerNowTimestamp() + local toDay = XTime.GetWeekDay(nowTime, true) + local tmpTime + RefreshTime = RefreshTime or 0 + + if RefreshTime - XTime.GetTodayTime(0, 0, 0) >= CS.XDateUtil.ONE_DAY_SECOND then + tmpTime = RefreshTime - CS.XDateUtil.ONE_DAY_SECOND + else + tmpTime = RefreshTime + end + + if nowTime < tmpTime then + toDay = toDay - 1 + end + + if toDay <= 0 then + toDay = toDay + 7 + end + return toDay + end + + function XFubenDailyManager.InitStageInfo() + local DungeonDataList = XDailyDungeonConfigs.GetDailyDungeonDataList() + for _, chapter in pairs(DungeonDataList) do + for _, stageId in pairs(chapter.StageId) do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + if stageInfo then + stageInfo.Type = XDataCenter.FubenManager.StageType.Daily + stageInfo.mode = XDataCenter.FubenManager.ModeType.SINGLE + stageInfo.stageDataName = chapter.Name + end + end + end + end + + + -- 领取挑战奖励 + function XFubenDailyManager.ReceiveDailyReward(cb, dailySectionId) + local req = { DailySectionId = dailySectionId } + XNetwork.Call(METHOD_NAME.ReceiveDailyReward, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XFubenDailyManager.SyncDailyReward(dailySectionId) + if cb then + cb(res.RewardGoodsList) + end + end) + end + + function XFubenDailyManager.GetRemainCount() + + end + + function XFubenDailyManager.NotifyFubenDailyData(req) + XTool.LoopMap(req.FubenDailyData.DailySectionData, function(k, v) + DailySectionData[k] = v + XEventManager.DispatchEvent(XEventId.EVENT_FUBEN_DAILY_REFRESH) + end) + end + + function XFubenDailyManager.NotifyDailyFubenRefreshTime(req) + RefreshTime = req.RefreshTime + end + + function XFubenDailyManager.NotifyDailyFubenLoginData(req) + RefreshTime = req.RefreshTime + for _, v in pairs(req.Records) do + DailyRecord[v.ChapterId] = v.StageId + end + end + + function XFubenDailyManager.GetLastStageId(dailyDungeonId) + return DailyRecord[dailyDungeonId] + end + + function XFubenDailyManager.SetFubenDailyRecord(stageId) + local dailyDungeonId = XDailyDungeonConfigs.GetDailyDungeonIdByStageId(stageId) + if dailyDungeonId and DailyRecord then + DailyRecord[dailyDungeonId] = stageId + end + end + + XFubenDailyManager.Init() + return XFubenDailyManager +end + +XRpc.NotifyFubenDailyData = function(req) + XDataCenter.FubenDailyManager.NotifyFubenDailyData(req) +end + +XRpc.NotifyDailyFuBenRefreshTime = function(req) + XDataCenter.FubenDailyManager.NotifyDailyFubenRefreshTime(req) +end + +XRpc.NotifyDailyFubenLoginData = function(req) + XDataCenter.FubenDailyManager.NotifyDailyFubenLoginData(req) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XFubenExperimentManager.lua b/Resources/Scripts/XManager/XFubenExperimentManager.lua new file mode 100644 index 00000000..8a736a19 --- /dev/null +++ b/Resources/Scripts/XManager/XFubenExperimentManager.lua @@ -0,0 +1,414 @@ +local CSXTextManagerGetText = CS.XTextManager.GetText +local tableInsert = table.insert +local tableSort = table.sort +local CSGameEventManager = CS.XGameEventManager.Instance + +XFubenExperimentManagerCreator = function() + local XFubenExperimentManager = {} + + local TrialGroup = {} + local TrialLevel = {} + local TrialLevelDic = {} + local ShowTrialGroup = {} + -- local BattleTrial = {} + local FinishExperimentIds = {} + local ExperimentInfos = {} -- 关卡完成信息字典(k:关卡Id,v:信息) + --服务器获取的副本结束时间信息 + local CurStageId + XFubenExperimentManager.TrialLevelType = { + Signle = 1, + Mult = 2, + Switch = 3, + SkinTrial = 5, + } + + XFubenExperimentManager.TabGroupId = { + SkinTrial = 18 --涂装试玩 + } + + local FUBEN_EXPERIMENT_PROTO = { + ExperimentStarRewardRequest = "ExperimentStarRewardRequest", + } + local function InitLevelDic() + for i, v in ipairs(TrialLevel) do + if not TrialLevelDic[v.GroupID] then + TrialLevelDic[v.GroupID] = {v} + else + tableInsert(TrialLevelDic[v.GroupID],v) + end + end + end + + function XFubenExperimentManager.Init() + TrialGroup = XFubenExperimentConfigs.GetTrialGroupCfg() + TrialLevel = XFubenExperimentConfigs.GetTrialLevelCfg() + InitLevelDic() + -- BattleTrial = XFubenExperimentConfigs.GetBattleTrialCfg() + end + + local GetStarsCount = function(starsMark) + local count = (starsMark & 1) + (starsMark & 2 > 0 and 1 or 0) + (starsMark & 4 > 0 and 1 or 0) + local map = {(starsMark & 1) > 0, (starsMark & 2) > 0, (starsMark & 4) > 0 } + return count, map + end + + function XFubenExperimentManager.GetTrialGroup() + return TrialGroup + end + + function XFubenExperimentManager.GetSkinTrialTime() + local levels = TrialLevelDic[XFubenExperimentManager.TabGroupId.SkinTrial] + if #levels == 0 then return end + local startTime = math.huge + local endTime = 0 + for i = 1, #levels do + local timeId = levels[i].TimeId + if timeId and timeId ~= 0 and XFunctionManager.IsEffectiveTimeId(timeId) then + local levelStartTime,levelEndTime = XFunctionManager.GetTimeByTimeId(timeId) + if startTime > levelStartTime then startTime = levelStartTime end + if endTime < levelEndTime then endTime = levelEndTime end + end + end + return startTime,endTime + end + + function XFubenExperimentManager.GetTrialLevelByGroupID(groupID) + local levels = TrialLevelDic[groupID] or {} + local temps = {} + for _, v in ipairs(levels) do + if v.TimeId and v.TimeId ~= 0 then + if XFunctionManager.CheckInTimeByTimeId(v.TimeId) then + tableInsert(temps,v) + end + else + tableInsert(temps,v) + end + end + return temps + end + + function XFubenExperimentManager.CheckGroupHasInTimeTask(groupId) + local levels = XFubenExperimentManager.GetTrialLevelByGroupID(groupId) + return #levels > 0 + end + + function XFubenExperimentManager.GetShowTrialGroup(func) + ShowTrialGroup = {} + for k, v in pairs(TrialGroup) do + if v.SubIndex == 0 and v.TimeId == 0 then + tableInsert(ShowTrialGroup,v) + elseif XFubenExperimentManager.CheckGroupHasInTimeTask(v.Id) then + tableInsert(ShowTrialGroup,v) + end + end + if func then + tableSort(ShowTrialGroup,func) + end + return ShowTrialGroup + end + + + function XFubenExperimentManager.GetEndTime(id) + if ShowTrialGroup[id] then + local timeId = ShowTrialGroup[id].TimeId + return XFunctionManager.GetEndTimeByTimeId(timeId) + end + return nil + end + + function XFubenExperimentManager.GetStartTime(id) + if ShowTrialGroup[id] then + local timeId = ShowTrialGroup[id].TimeId + return XFunctionManager.GetStartTimeByTimeId(timeId) + end + return nil + end + + function XFubenExperimentManager.GetStageCondition(id) + return TrialLevel[id].ConditionId + end + + function XFubenExperimentManager.GetStageShowPass(id) + return TrialLevel[id].ShowPass + end + + function XFubenExperimentManager.GetCurExperimentLevelId() + return CurStageId + end + + function XFubenExperimentManager.SetCurExperimentLevelId(id) + CurStageId = id + end + + function XFubenExperimentManager.GetCurExperiment() + return XFubenExperimentConfigs.GetTrialLevelCfgById(CurStageId) + end + + function XFubenExperimentManager.GetFinishExperimentIds() + return FinishExperimentIds + end + + function XFubenExperimentManager.SetFinishExperimentIds(list) + FinishExperimentIds = list + end + + function XFubenExperimentManager.UpdateFinishExperimentId(id) + table.insert(FinishExperimentIds, id) + end + + function XFubenExperimentManager.CheckExperimentIsFinish(Id) + for _, v in pairs(FinishExperimentIds) do + if v == Id then + return true + end + end + return false + end + + function XFubenExperimentManager.SetExperimentInfo(experimentInfo) + ExperimentInfos[experimentInfo.Id] = experimentInfo + end + + function XFubenExperimentManager.GetExperimentInfo(id) + if not ExperimentInfos[id] then + return nil + end + + return ExperimentInfos[id] + end + + function XFubenExperimentManager.HandleExperimentData(data) + XFubenExperimentManager.SetFinishExperimentIds(data.FinishIds) + if data.ExperimentInfos then + for _, experimentInfo in ipairs(data.ExperimentInfos) do + XFubenExperimentManager.SetExperimentInfo(experimentInfo) + end + end + end + + function XFubenExperimentManager.SetStarReward(id, starNum) + if not ExperimentInfos[id] then + return + end + + if not ExperimentInfos[id].StarList then + ExperimentInfos[id].StarList = {} + end + + tableInsert(ExperimentInfos[id].StarList, starNum) + end + + function XFubenExperimentManager.GetStarReward(levelId, rewardIndex) + -- TODO 本地校验 + if XFubenExperimentManager.CheckExperimentRewardIsTaked(levelId, rewardIndex) then + XUiManager.TipError(CSXTextManagerGetText("FuBenExperimentRewardIsTaked")) + return + end + + if not XFubenExperimentManager.CheckExperimentRewardIsCanTake(levelId, rewardIndex) then + XUiManager.TipError(CSXTextManagerGetText("FuBenExperimentTakeRewardFaild")) + return + end + + local starNum = XFubenExperimentManager.GetStardRewardNeedStarNum(levelId, rewardIndex) + + XNetwork.Call(FUBEN_EXPERIMENT_PROTO.ExperimentStarRewardRequest, {Id = levelId, StarNum = starNum},function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + XFubenExperimentManager.SetStarReward(levelId, starNum) + XUiManager.OpenUiObtain(res.RewardList) + CSGameEventManager:Notify(XEventId.EVENT_EXPERIMENT_GET_STAR_REWARD) + XEventManager.DispatchEvent(XEventId.EVENT_EXPERIMENT_GET_STAR_REWARD) + end) + end + + function XFubenExperimentManager.GetExperimentStarProgressById(id) + local levelCfg = XFubenExperimentConfigs.GetTrialLevelCfgById(id) + if not levelCfg then + return + end + + local starRewardCfg = XFubenExperimentConfigs.GetTrialStarRewardCfgById(levelCfg.StarReward) + if not starRewardCfg then + return + end + + local curStarNum = 0 + local experimentInfo = XFubenExperimentManager.GetExperimentInfo(id) + if experimentInfo then + if experimentInfo.StarsMark then + curStarNum = GetStarsCount(experimentInfo.StarsMark) + end + end + + local maxStarNum = 0 + for _, starNum in pairs(starRewardCfg.StarNum) do + if starNum > maxStarNum then + maxStarNum = starNum + end + end + + return curStarNum, maxStarNum + end + + function XFubenExperimentManager.CheckTargetComplete(id, targetIndex) + local experimentInfo = ExperimentInfos[id] + if not experimentInfo then + return false + end + + local starsMark = experimentInfo.StarsMark + local starCount, starMap = GetStarsCount(experimentInfo.StarsMark) + if starMap[targetIndex] then + return true + end + + return false + end + + function XFubenExperimentManager.CheckExperimentRewardIsTaked(id, rewardIndex) + local experimentInfo = XFubenExperimentManager.GetExperimentInfo(id) + if not experimentInfo then + return false + end + + local starNum = XFubenExperimentManager.GetStardRewardNeedStarNum(id, rewardIndex) + if not starNum then + return false + end + + if not experimentInfo.StarList then + return false + end + + for _, isTakedStarNum in pairs(experimentInfo.StarList) do + if starNum == isTakedStarNum then + return true + end + end + + return false + end + + -- 判断可领取该星级奖励(不判断是否已经领取,已经领取用CheckExperimentRewardIsTaked判断) + function XFubenExperimentManager.CheckExperimentRewardIsCanTake(id, rewardIndex) + local experimentInfo = ExperimentInfos[id] + if not experimentInfo then + return false + end + + local starCount = GetStarsCount(experimentInfo.StarsMark) + local starNum = XFubenExperimentManager.GetStardRewardNeedStarNum(id, rewardIndex) + if not starNum then + return false + end + + if starCount < starNum then + return false + end + + return true + end + + function XFubenExperimentManager.GetStardRewardNeedStarNum(id, rewardIndex) + local trainedLevelCfg = XFubenExperimentConfigs.GetTrialLevelCfgById(id) + local trialRewardCfg = XFubenExperimentConfigs.GetTrialStarRewardCfgById(trainedLevelCfg.StarReward) + local starNumList = trialRewardCfg.StarNum + + if not starNumList[rewardIndex] then + return nil + end + + return starNumList[rewardIndex] + end + + function XFubenExperimentManager.CheckBannerRedPoint(trialLevelInfo) -- 检查红点 + local isShowRed = false + if trialLevelInfo.StarReward and trialLevelInfo.StarReward > 0 then -- 带有奖励的试玩关 + local starRewardId = trialLevelInfo.StarReward + local rewardList = XFubenExperimentConfigs.GetTrialStarRewardCfgById(starRewardId).StarNum + if not rewardList then + return false + end + for index, _ in ipairs(rewardList) do + if XFubenExperimentManager.CheckExperimentRewardIsCanTake(trialLevelInfo.Id, index) and not XFubenExperimentManager.CheckExperimentRewardIsTaked(trialLevelInfo.Id, index) then + isShowRed = true + break + end + end + elseif trialLevelInfo.Type == XFubenExperimentManager.TrialLevelType.SkinTrial then + if not XFubenExperimentManager.CheckExperimentIsFinish(trialLevelInfo.Id) then + isShowRed = true + end + end + + return isShowRed + end + + function XFubenExperimentManager.CheckExperimentGroupHaveRedPoint(groupId) + local levelTamplates = XFubenExperimentManager.GetTrialLevelByGroupID(groupId) + for _, trialLevelInfo in ipairs(levelTamplates) do + if XFubenExperimentManager.CheckBannerRedPoint(trialLevelInfo) then + return true + end + end + end + + function XFubenExperimentManager.CheckSkinTrialRedPoint() + return XFubenExperimentManager.CheckExperimentGroupHaveRedPoint(XFubenExperimentManager.TabGroupId.SkinTrial) + end + + function XFubenExperimentManager.InitStageInfo() + for k, v in ipairs(TrialLevel) do + if v.SingStageId and v.SingStageId ~= 0 then + local stageInfo = XDataCenter.FubenManager.GetStageInfo(v.SingStageId) + stageInfo.Type = XDataCenter.FubenManager.StageType.Experiment + if v.StarReward and v.StarReward ~= 0 then stageInfo.HasReward = true end + end + if v.MultStageId and v.MultStageId ~= 0 then + local stageInfo = XDataCenter.FubenManager.GetStageInfo(v.MultStageId) + stageInfo.Type = XDataCenter.FubenManager.StageType.Experiment + if v.StarReward and v.StarReward ~= 0 then stageInfo.HasReward = true end + end + end + end + + function XFubenExperimentManager.ShowReward(winData) + local stageId = winData.StageId + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + if next(stageCfg.StarDesc) then + XLuaUiManager.Open("UiSettleWinMainLine", winData) + else + XLuaUiManager.Open("UiSettleWin", winData) + end + end + + function XFubenExperimentManager.CheckExperimentRedPoint() + local experimentGroups = XFubenExperimentManager.GetShowTrialGroup() + for _, groupTemplate in ipairs(experimentGroups) do + if XFubenExperimentManager.CheckExperimentGroupHaveRedPoint(groupTemplate.Id) then + return true + end + end + + return false + end + + XFubenExperimentManager.Init() + return XFubenExperimentManager +end + +XRpc.NotifyUpdateExperimentId = function(data) + XDataCenter.FubenExperimentManager.UpdateFinishExperimentId(data.Id) + if data.Info then + XDataCenter.FubenExperimentManager.SetExperimentInfo(data.Info) + end + XEventManager.DispatchEvent(XEventId.EVENT_UPDATE_EXPERIMENT) +end + +XRpc.NotifyExperimentData = function(data) + XDataCenter.FubenExperimentManager.HandleExperimentData(data) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XFubenExploreManager.lua b/Resources/Scripts/XManager/XFubenExploreManager.lua new file mode 100644 index 00000000..5fd7c0bb --- /dev/null +++ b/Resources/Scripts/XManager/XFubenExploreManager.lua @@ -0,0 +1,374 @@ +XFubenExploreManagerCreator = function() + local XFubenExploreManager = {} + --服务器数据 + local ExploreChapterData = {} + --处理后的关卡数据 + local ExploreNodeData = {} + --保存战斗关卡使用的角色,胜利后扣除体力 + local CurTeam = {} + + local CurSelectChapterId = 1 + local CurNodeId = 1 + + function XFubenExploreManager.Init() + XEventManager.AddEventListener(XEventId.EVENT_FUBEN_SETTLE_REWARD, XFubenExploreManager.HandlerFightResult) + end + + function XFubenExploreManager.InitNodeData() + ExploreNodeData = {} + local nodeData = XFubenExploreConfigs.GetExploreNodeCfg() + for k, v in pairs(nodeData) do + ExploreNodeData[k] = { tableData = v } + end + for _, v in pairs(ExploreNodeData) do + XFubenExploreManager.UpdateNodeData(v) + end + XEventManager.DispatchEvent(XEventId.EVENT_FUBEN_EXPLORE_UPDATE) + end + + function XFubenExploreManager.UpdateNodeData(nodeData) + if XFubenExploreManager.IsNodeFinish(nodeData.tableData.ChapterId, nodeData.tableData.Id) then + nodeData.State = XFubenExploreConfigs.NodeStateEnum.Complete + else + nodeData.State = XFubenExploreConfigs.NodeStateEnum.Visivle + for j = 1, #nodeData.tableData.PreShowId do + if #nodeData.tableData.PreShowId > 0 then + if XFubenExploreManager.IsNodeFinish(nodeData.tableData.ChapterId, nodeData.tableData.PreShowId[j]) == false then + nodeData.State = XFubenExploreConfigs.NodeStateEnum.Invisivle + break + end + end + end + + if nodeData.State == XFubenExploreConfigs.NodeStateEnum.Visivle then + nodeData.State = XFubenExploreConfigs.NodeStateEnum.Availavle + for j = 1, #nodeData.tableData.PreOpenId do + if XFubenExploreManager.IsNodeFinish(nodeData.tableData.ChapterId, nodeData.tableData.PreOpenId[j]) == false then + nodeData.State = XFubenExploreConfigs.NodeStateEnum.Visivle + break + end + end + end + end + end + + function XFubenExploreManager.InitStageInfo() + local battleIdList = {} + local allNodeData = XFubenExploreConfigs.GetExploreNodeCfg() + for _, v in pairs(allNodeData) do + if v.Type == XFubenExploreConfigs.NodeTypeEnum.Stage then + table.insert(battleIdList, tonumber(v.TypeValue)) + end + end + for _, v in pairs(battleIdList) do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(v) + stageInfo.Type = XDataCenter.FubenManager.StageType.Explore + end + end + + + --Get + --根据原型ID获取对应角色在某一章的已使用的耐力值 + function XFubenExploreManager.GetEndurance(chapterId, characterId) + local chapterData = XFubenExploreManager.GetChapterData(chapterId) + for i = 1, #chapterData.EnduranceInfos do + if chapterData.EnduranceInfos[i].Id == characterId then + return chapterData.EnduranceInfos[i].Use + end + end + --找不到,说明体力还是满的,已使用0 + return 0 + end + --获取某一章里的最大耐力(每个角色都一样) + function XFubenExploreManager.GetMaxEndurance(chapterId) + local chapterData = XFubenExploreConfigs.GetChapterData(chapterId) + return chapterData.Endurance + end + + --获取某一章的数据 + function XFubenExploreManager.GetChapterData(chapterId) + for i = 1, #ExploreChapterData do + if ExploreChapterData[i].Id == chapterId then + return ExploreChapterData[i] + end + end + + local tempChapterData = { + EnduranceInfos = {}, + RewardStatus = 0, + Id = chapterId, + FinishNodes = {}, + UnlockEvents = {}, + } + table.insert(ExploreChapterData, tempChapterData) + return tempChapterData + end + + --获取某一章所有节点的数据(处理后) + function XFubenExploreManager.GetAllNodeData(chapterId) + local tempList = {} + for _, v in pairs(ExploreNodeData) do + if v.tableData.ChapterId == chapterId then + table.insert(tempList, v) + end + end + return tempList + end + + --获取某一关的数据(处理后) + function XFubenExploreManager.GetNodeData(nodeId) + return ExploreNodeData[nodeId] + end + + --获取某一章探索率 + function XFubenExploreManager.GetExploreProgress(chapterId) + local allLevelData = XFubenExploreConfigs.GetAllLevel(chapterId) + local allPassLevelData = XFubenExploreManager.GetChapterData(chapterId) + if allPassLevelData == nil then + return 0 + else + return #allPassLevelData.FinishNodes / #allLevelData + end + end + + --获取某一章的已打开的记录 + function XFubenExploreManager.GetChapterStoryText(chapterId) + local allStoryText = XFubenExploreConfigs.GetChapterStoryText(chapterId) + local tempList = {} + for i = 1, #allStoryText do + if allStoryText[i].UnlockNodeId == 0 or XFubenExploreManager.IsNodeFinish(chapterId, allStoryText[i].UnlockNodeId) then + table.insert(tempList, allStoryText[i]) + end + end + return tempList + end + --获取当前选中的章节ID + function XFubenExploreManager.GetCurChapterId() + return CurSelectChapterId + end + + --获取当前能打的最新章节ID + function XFubenExploreManager.GetNewestChapterId() + local allChapterData = XFubenExploreConfigs.GetExploreChapterCfg() + for i = 1, #allChapterData do + if XFubenExploreManager.GetExploreProgress(allChapterData[i].Id) ~= 1 then + return allChapterData[i].Id + end + end + return nil + end + + --获取当前进入的关卡节点ID + function XFubenExploreManager.GetCurNodeId() + return CurNodeId + end + + --获取当前进入的关卡消耗体力值 + function XFubenExploreManager:GetCurNodeEndurance() + return XFubenExploreConfigs.GetLevel(XFubenExploreManager.GetCurNodeId()).CostEndurance + end + + --获取当前进度的章节名 + function XFubenExploreManager.GetCurProgressName() + local allChapterData = XFubenExploreConfigs.GetExploreChapterCfg() + for i = 1, #allChapterData do + if XFubenExploreManager.GetExploreProgress(allChapterData[i].Id) ~= 1 then + return allChapterData[i].Name + end + end + return nil + end + + --某个buff的解锁进度 + function XFubenExploreManager.GetBuffUnlockProgress(buffInfo) + local unlockNum = 0 + for _, v in pairs(buffInfo.UnlockEvent) do + if XFubenExploreManager.IsBuffUnlockEvent(buffInfo, v) then + unlockNum = unlockNum + 1 + end + end + return unlockNum / #buffInfo.UnlockEvent + end + + --Get end + --Set + function XFubenExploreManager.SetNodeFinish(chapterId, nodeId) + if XFubenExploreManager.IsNodeFinish(chapterId, nodeId) then + return + end + local chapterData = XFubenExploreManager.GetChapterData(chapterId) + local curNode = XFubenExploreManager.GetNodeData(nodeId) + if chapterData ~= nil then + table.insert(chapterData.FinishNodes, nodeId) + else + local tempChapterData = { + EnduranceInfos = {}, + RewardStatus = 0, + Id = chapterId, + FinishNodes = {}, + UnlockEvents = {}, + } + table.insert(tempChapterData.FinishNodes, chapterId, nodeId) + table.insert(ExploreChapterData, tempChapterData) + end + + chapterData = XFubenExploreManager.GetChapterData(chapterId) + if curNode.tableData.CostEndurance > 0 then + for i = 1, #CurTeam.TeamData do + local hasId = false + for j = 1, #chapterData.EnduranceInfos do + if chapterData.EnduranceInfos[j].Id == CurTeam.TeamData[i] then + chapterData.EnduranceInfos[j].Use = chapterData.EnduranceInfos[j].Use + curNode.tableData.CostEndurance + hasId = true + end + end + if not hasId then + table.insert(chapterData.EnduranceInfos, { Id = CurTeam.TeamData[i], Use = curNode.tableData.CostEndurance }) + end + end + end + XFubenExploreManager.InitNodeData() + end + + function XFubenExploreManager.SetCurChapterId(id) + CurSelectChapterId = id + end + + function XFubenExploreManager.SetCurNodeId(id) + CurNodeId = id + end + + function XFubenExploreManager.SetCurTeam(team) + CurTeam = team + end + --Set end + --Is + --某一关是否完成 + function XFubenExploreManager.IsNodeFinish(chapterId, nodeId) + local chapterData = XFubenExploreManager.GetChapterData(chapterId) + if chapterData ~= nil then + for i = 1, #chapterData.FinishNodes do + if chapterData.FinishNodes[i] == nodeId then + return true + end + end + end + --找不到,说明没完成 + return false + end + + --检测是否有东西没领 + function XFubenExploreManager.IsRedPoint() + for i = 1, #ExploreChapterData do + if ExploreChapterData[i].RewardStatus == 0 and XFubenExploreManager.GetExploreProgress(ExploreChapterData[i].Id) == 1 then + return true + end + end + return false + end + + --某章是否有奖励没领 + function XFubenExploreManager.IsChapterRedPoint(chapterId) + local chapterData = XFubenExploreManager.GetChapterData(chapterId) + if chapterData then + return chapterData.RewardStatus == 0 and XFubenExploreManager.GetExploreProgress(chapterId) == 1 + else + return false + end + end + + --某个buff是否解锁 + function XFubenExploreManager.IsBuffUnlock(buffInfo) + local isUnlock = true + for _, v in pairs(buffInfo.UnlockEvent) do + if not XFubenExploreManager.IsBuffUnlockEvent(buffInfo, v) then + isUnlock = false + end + end + return isUnlock + end + + --某个buff的某个条件是否满足 + function XFubenExploreManager.IsBuffUnlockEvent(buffInfo, eventId) + local isUnlock = false + local chapterData = XFubenExploreManager.GetChapterData(buffInfo.ChapterId) + for _, v in pairs(chapterData.UnlockEvents) do + if v == eventId then + isUnlock = true + break + end + end + return isUnlock + end + --是否完成全部章节 + function XFubenExploreManager.IsFinishAll() + if not XFubenExploreManager.IsRedPoint() and XFubenExploreManager.GetCurProgressName() == nil then + return true + end + return false + end + --Is end + -- Network + -- 完成剧情关卡请求 + function XFubenExploreManager.FinishNode(chapterId, nodeId, cb) + XNetwork.Call("ExploreFinishNodeRequest", { Id = nodeId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + XFubenExploreManager.SetNodeFinish(chapterId, nodeId) + cb() + end) + end + + -- 领取章节奖励 + function XFubenExploreManager.GetChapterReward(chapterId, cb) + XNetwork.Call("ExploreGetRewardRequest", { Id = chapterId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + XFubenExploreManager.GetChapterData(chapterId).RewardStatus = 1 + if res.RewardGoodsList and #res.RewardGoodsList > 0 then + XUiManager.OpenUiObtain(res.RewardGoodsList, nil, cb) + end + end) + end + --Network end + --Handle + function XFubenExploreManager.HandleExploreData(data) + --清空数据 + ExploreChapterData = {} + --赋值 + ExploreChapterData = data.ChapterDatas + XFubenExploreManager.InitNodeData() + end + + function XFubenExploreManager.HandlerFightResult(evt) + if evt ~= nil and evt.IsWin then + local stage = XDataCenter.FubenManager.GetStageInfo(evt.StageId) + if stage.Type == XDataCenter.FubenManager.StageType.Explore then + XFubenExploreManager.SetNodeFinish(XFubenExploreManager.GetCurChapterId(), XFubenExploreManager.GetCurNodeId()) + end + end + end + + function XFubenExploreManager.HandleExploreUnlockEvent(evt) + local chapterData = XFubenExploreManager.GetChapterData(evt.Id) + chapterData.UnlockEvents = evt.UnlockEvents + XEventManager.DispatchEvent(XEventId.EVENT_FUBEN_EXPLORE_UPDATEBUFF) + end + + --Handle end + XFubenExploreManager.Init() + return XFubenExploreManager +end + +XRpc.NotifyExploreData = function(data) + XDataCenter.FubenExploreManager.HandleExploreData(data) +end +XRpc.NotifyExploreUnlockEvent = function(data) + XDataCenter.FubenExploreManager.HandleExploreUnlockEvent(data) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XFubenExtraChapterManager.lua b/Resources/Scripts/XManager/XFubenExtraChapterManager.lua new file mode 100644 index 00000000..85e50203 --- /dev/null +++ b/Resources/Scripts/XManager/XFubenExtraChapterManager.lua @@ -0,0 +1,787 @@ +XFubenExtraChapterCreator = function() + local ExtraChapterManager = {} + local ChapterInfos = {} -- info {FirstStage, ActiveStage, Stars, Unlock, Passed} + local LastPassStage = {} -- index:章节数chapterId 内容:通关关卡passStageId + local ChapterExtraCfgs = {} + local ChapterExtraDetailsCfgs = {} + local StarTreasureCfgs = {} + local ActivityChapters = {} --活动抢先体验ChapterId列表 + local ActivityEndTime = 0 --活动抢先体验结束时间 + local ActivityChallengeBeginTime = 0 --活动抢先体验结束时间(隐藏模式) + local ActivityTimer + local ExploreEventStateList = {} + local ExploreGroupInfos = {} + local ExploreItemInfos = {} + local PlayerTreasureData = {} + local CurrentClearData = {} + --排序 + local orderIdSortFunc = function(a, b) + return a.OrderId < b.OrderId + end + + local SortById = function(a, b) + return a.Id < b.Id + end + local ExItemRedPointState = { + Off = 0, + On = 1, + } + + local DifficultType = { + Normal = CS.XGame.Config:GetInt("FubenDifficultNormal"), + Hard = CS.XGame.Config:GetInt("FubenDifficultHard") + } + + function ExtraChapterManager.Init() + ChapterExtraCfgs = XFubenExtraChapterConfigs.GetExtraChapterCfgs() + ChapterExtraDetailsCfgs = XFubenExtraChapterConfigs.GetExtraChapterDetailsCfgs() + StarTreasureCfgs = XFubenExtraChapterConfigs.GetExtraChapterStarTreasuresCfgs() + ExtraChapterManager.InitExploreGroup() + ExtraChapterManager.InitExploreItem() + ExtraChapterManager.UiGridChapterMoveMinX = CS.XGame.ClientConfig:GetInt("UiGridChapterMoveMinX") + ExtraChapterManager.UiGridChapterMoveMaxX = CS.XGame.ClientConfig:GetInt("UiGridChapterMoveMaxX") + ExtraChapterManager.UiGridChapterMoveTargetX = CS.XGame.ClientConfig:GetInt("UiGridChapterMoveTargetX") + ExtraChapterManager.UiGridChapterMoveDuration = CS.XGame.ClientConfig:GetFloat("UiGridChapterMoveDuration") + end + + function ExtraChapterManager.InitExtraInfos(infoDatas) + if not infoDatas then return end + if infoDatas.TreasureData then + for i = 1, #infoDatas.TreasureData do + PlayerTreasureData[infoDatas.TreasureData[i]] = true + end + end + if infoDatas.LastPassStage then + for k, v in pairs(infoDatas.LastPassStage) do + LastPassStage[k] = v + end + end + if infoDatas.ChapterEventInfos then + ExtraChapterManager.SetChapterEventState(infoDatas.ChapterEventInfos) + end + XEventManager.AddEventListener(XEventId.EVENT_FUBEN_STAGE_SYNC, ExtraChapterManager.OnSyncStageData) + XEventManager.AddEventListener(XEventId.EVENT_CHARACTER_LEVEL_UP, ExtraChapterManager.InitStageInfoEx) + end + + function ExtraChapterManager.InitStageInfoEx() + ExtraChapterManager.InitStageInfo(false) + end + + function ExtraChapterManager.InitStageInfo(checkNewUnlock) + ExtraChapterManager.InitChapterData(checkNewUnlock) + ExtraChapterManager.ExtraActivityStart() + end + + local function InitChapterInfo(chapterMain, chapter) + local info = {} + if #chapter.StageId > 0 then + info.ChapterMainId = chapterMain.Id + info.FirstStage = chapter.StageId[1] + local firstStageInfo = XDataCenter.FubenManager.GetStageInfo(info.FirstStage) + + -- 如果章节处于活动时间内,根据时间判断是否可以解锁 + local firstUnlock = firstStageInfo.Unlock + local firstPassed = firstStageInfo.Passed + info.Unlock = firstUnlock + info.IsOpen = firstStageInfo.IsOpen + if not firstPassed and firstUnlock and ExtraChapterManager.CheckDiffHasAcitivity(chapter) then + if not ExtraChapterManager.CheckActivityCondition(chapter.ChapterId) then + info.Unlock = false + info.IsOpen = false + end + elseif (not ExtraChapterManager.IsExtraActivityOpen() and ExtraChapterManager.CheckDiffHasAcitivity(chapter)) or not ExtraChapterManager.CheckDiffHasAcitivity(chapter) then + local isOpen, desc = ExtraChapterManager.CheckOpenCondition(chapter.ChapterId) + if not isOpen then + info.Unlock = false + info.IsOpen = false + end + end + local passStageNum = 0 + local stars = 0 + local allPassed = true + for _, v in ipairs(chapter.StageId) do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(v) + if stageInfo.Unlock then + info.ActiveStage = v + info.LastStageOrder = XDataCenter.FubenManager.GetStageOrderId(v) + end + if not stageInfo.Passed then + allPassed = false + else + passStageNum = passStageNum + 1 + end + stars = stars + stageInfo.Stars + end + + local treasureCfg = XDataCenter.ExtraChapterManager.GetTreasureCfg(chapter.TreasureId[#chapter.TreasureId]) + info.TotalStars = treasureCfg.RequireStar + info.Stars = stars > info.TotalStars and info.TotalStars or stars + info.Passed = allPassed + info.PassStageNum = passStageNum + end + return info + end + + function ExtraChapterManager.InitChapterData(checkNewUnlock) + local oldChapterInfos = ChapterInfos + ChapterInfos = {} + local SortChapterExtraCfgs = {} + for _, chapterMain in pairs(ChapterExtraCfgs) do + table.insert(SortChapterExtraCfgs, chapterMain) + end + table.sort(SortChapterExtraCfgs, SortById) + CurrentClearData.ChapterTotalNum = 0 + CurrentClearData.AllChapterClear = true + for _, chapterMain in pairs(SortChapterExtraCfgs) do + for difficult, chapterId in pairs(chapterMain.ChapterId) do + local chapter = ChapterExtraDetailsCfgs[chapterId] + ChapterInfos[chapterId] = InitChapterInfo(chapterMain, chapter) + for k, v in ipairs(chapter.StageId) do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(v) + stageInfo.Type = XDataCenter.FubenManager.StageType.ExtraChapter + stageInfo.OrderId = k + stageInfo.ChapterId = chapter.ChapterId + stageInfo.Difficult = difficult + end + local info = ChapterInfos[chapterId] + if difficult == DifficultType.Normal then + CurrentClearData.ChapterTotalNum = CurrentClearData.ChapterTotalNum + 1 + if CurrentClearData.AllChapterClear and info.Unlock then + CurrentClearData.ChapterId = info.ChapterMainId + CurrentClearData.StageTitle = chapter.StageTitle + CurrentClearData.StageId = info.ActiveStage + CurrentClearData.LastStageOrder = info.LastStageOrder + CurrentClearData.IsClear = info.Passed + CurrentClearData.PassStageNum = info.PassStageNum + end + if not info.Passed then CurrentClearData.AllChapterClear = false end + end + end + end + if checkNewUnlock then + for k, v in pairs(ChapterInfos) do + if v.Unlock and not oldChapterInfos[k].Unlock then + XEventManager.DispatchEvent(XEventId.EVENT_FUBEN_NEW_EXTRA_CHAPTER, k) + end + end + end + end + + function ExtraChapterManager.OnSyncStageData(stageId) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + if stageInfo.Type ~= XDataCenter.FubenManager.StageType.ExtraChapter then return end + LastPassStage[stageInfo.ChapterId] = stageId + end + + function ExtraChapterManager.IsTreasureGet(treasureId) + return PlayerTreasureData[treasureId] + end + + function ExtraChapterManager.SyncTreasureStage(treasureId) + PlayerTreasureData[treasureId] = true + end + + function ExtraChapterManager.GetChapterExtraCfgs(difficult) + local list = {} + local activityList = {} + + for _, v in pairs(ChapterExtraCfgs) do + local chapterId + local chapterInfo + + chapterId = v.ChapterId[difficult] + chapterInfo = ExtraChapterManager.GetChapterInfo(chapterId) + + if chapterInfo then + if chapterInfo.IsActivity then + table.insert(activityList, v) + else + table.insert(list, v) + end + end + end + + if next(list) then + table.sort(list, orderIdSortFunc) + end + + if next(activityList) then + table.sort(activityList, orderIdSortFunc) + + local allUnlock = true + for order, template in pairs(list) do + local chapterId + local chapterInfo + + chapterId = template.ChapterId[difficult] + chapterInfo = ExtraChapterManager.GetChapterInfo(chapterId) + + if not chapterInfo.Unlock then + local index = order + for _, v in pairs(activityList) do + table.insert(list, index, v) + index = index + 1 + end + + allUnlock = false + break + end + end + + if allUnlock then + for _, v in pairs(activityList) do + table.insert(list, v) + end + end + end + + return list + end + -- 获取篇章星数 + function ExtraChapterManager.GetChapterStars(chapterId) + local info = ChapterInfos[chapterId] + return info and info.Stars or 0, info and info.TotalStars or 0 + end + + function ExtraChapterManager.GetChapterList(difficult) + local list = {} + for _, v in pairs(ChapterExtraCfgs) do + list[v.OrderId] = v.ChapterId[difficult] + end + return list + end + + function ExtraChapterManager.GetChapterCfg(chapterId) + return ChapterExtraCfgs[chapterId] + end + + function ExtraChapterManager.GetChapterInfo(chapterId) + return ChapterInfos[chapterId] + end + + function ExtraChapterManager.GetChapterByChapterDetailsId(chapterId) + return ChapterInfos[chapterId].ChapterMainId + end + + function ExtraChapterManager.GetChapterDetailsCfg(chapterId) + return ChapterExtraDetailsCfgs[chapterId] + end + + function ExtraChapterManager.GetChapterDetailsCfgByChapterIdAndDifficult(chapterId, difficult) + local cfg = ExtraChapterManager.GetChapterCfg(chapterId) + if not cfg then return nil end + return ExtraChapterManager.GetChapterDetailsCfg(cfg.ChapterId[difficult]) + end + + function ExtraChapterManager.GetChapterDetailsStageTitle(chapterId) + if chapterId == nil then return end + local cfg = ExtraChapterManager.GetChapterDetailsCfg(chapterId) + return cfg.StageTitle + end + + function ExtraChapterManager.CheckChapterNew(chapterId) + local chapterInfo = ExtraChapterManager.GetChapterInfo(chapterId) + return chapterInfo.Unlock and not chapterInfo.Passed + end + + function ExtraChapterManager.GetLastPassStage(chapterId) + return LastPassStage[chapterId] + end + + function ExtraChapterManager.GetStageList(chapterId) + return ChapterExtraDetailsCfgs[chapterId].StageId + end + + function ExtraChapterManager.GetAutoChangeBgDatumLinePrecent(chapterId) + return ChapterExtraDetailsCfgs[chapterId].DatumLinePrecent or 0 + end + + function ExtraChapterManager.GetAutoChangeBgStageIndex(chapterId) + return ChapterExtraDetailsCfgs[chapterId].MoveStageIndex or 0 + end + + function ExtraChapterManager.GetTreasureCfg(treasureId) + if StarTreasureCfgs[treasureId] then + return StarTreasureCfgs[treasureId] + end + end + + ---检测章节内是否有收集进度奖励 + function ExtraChapterManager.CheckTreasureReward(chapterId) + local chapterInfo = ExtraChapterManager.GetChapterInfo(chapterId) + if chapterInfo and not chapterInfo.Unlock then + return false + end + + local chapter = ExtraChapterManager.GetChapterDetailsCfg(chapterId) + if not chapter then return false end + + local hasReward = false + local targetList = chapter.TreasureId + if not targetList then return false end + for _, var in ipairs(targetList) do + local treasureCfg = ExtraChapterManager.GetTreasureCfg(var) + if treasureCfg then + local requireStars = treasureCfg.RequireStar + local starCount = 0 + local stageList = ExtraChapterManager.GetStageList(chapterId) + + for i = 1, #stageList do + local stage = XDataCenter.FubenManager.GetStageCfg(stageList[i]) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stage.StageId) + starCount = starCount + stageInfo.Stars + end + + if requireStars > 0 and requireStars <= starCount then + local isGet = ExtraChapterManager.IsTreasureGet(treasureCfg.TreasureId) + if not isGet then + hasReward = true + break + end + end + end + end + + return hasReward + end + + function ExtraChapterManager.GetProgressByChapterId(chapterId) + local chapterInfo = ExtraChapterManager.GetChapterInfo(chapterId) + return math.ceil(100 * chapterInfo.Stars / chapterInfo.TotalStars) + end + + function ExtraChapterManager.GetChapterInfoForOrderId(difficult, orderId) + for _, v in pairs(ChapterExtraCfgs) do + if v.OrderId == orderId then + local chapterId = v.ChapterId[difficult] + return ExtraChapterManager.GetChapterInfo(chapterId) + end + end + end + + function ExtraChapterManager.GetChapterIdByChapterExtraId(chapterExtraId, difficult) + if difficult == DifficultType.Normal then + return ChapterExtraCfgs[chapterExtraId].ChapterId[1] + elseif difficult == DifficultType.Hard then + return ChapterExtraCfgs[chapterExtraId].ChapterId[2] + end + local tempStr = "ExtraChapterManager.GetChapterIdByChapterExtraId函数参数difficult应该是," + XLog.Error(tempStr .. "config表:Share/Config/Config.tab, 中字段FubenDifficultNormal、FubenDifficultHard对应的值中的一个") + end + + function ExtraChapterManager.GetCurDiffcult() + return ExtraChapterManager.CurDifficult or DifficultType.Normal + end + + function ExtraChapterManager.SetCurDifficult(difficult) + ExtraChapterManager.CurDifficult = difficult + XEventManager.DispatchEvent(XEventId.EVENT_FUBEN_CHANGE_EXTRA_CHAPTER_DIFFICULT, difficult) + end + + --检测所有章节进度是否有奖励 + function ExtraChapterManager.CheckAllChapterReward() + for _, v in pairs(ChapterExtraCfgs) do + for _, chapterId in pairs(v.ChapterId) do + if ExtraChapterManager.CheckTreasureReward(chapterId) then + return true + end + end + end + return false + end + --获取通关进度 + function ExtraChapterManager.GetChapterClearData() + return CurrentClearData + end + --跳转到外章Banner页面 + function ExtraChapterManager.JumpToExtraBanner() + XLuaUiManager.Open("UiFuben", XDataCenter.FubenManager.StageType.Mainline, nil, 4) + end + --跳转到外章章节关卡 + function ExtraChapterManager.JumpToExtraStage(chapterId, stageId) + local chapter = ExtraChapterManager.GetChapterDetailsCfg(chapterId) + if chapter then + local checkResult, checkDesription = ExtraChapterManager.CheckCanGoTo(chapterId, stageId) + if not checkResult then + XUiManager.TipMsg(checkDesription) + return + end + XLuaUiManager.Open("UiFubenMainLineChapterFw", chapter, stageId, false) + else + ExtraChapterManager.JumpToExtraBanner() + XLog.Error("跳转到特定外章章节关卡失败,没有在chapterDetails表中找到章节信息。 chpaterId : " .. tostring(chapterId)) + end + end + -- 检查番外章节是否可以跳转 + function ExtraChapterManager.CheckCanGoTo(chapterId, stageId, specialTip) + specialTip = specialTip or "获取章节数据失败" + + if not chapterId then return false, specialTip end + local chapterInfo = ExtraChapterManager.GetChapterInfo(chapterId) + if not chapterInfo then return false, specialTip end + if chapterInfo.IsActivity then + if not ExtraChapterManager.IsExtraActivityOpen() then + return false, CS.XTextManager.GetText("FubenExtraNotOpen") + end + local checkResult, checkDesription = ExtraChapterManager.CheckActivityCondition(chapterId) + if not checkResult then + return false, checkDesription + end + end + if not chapterInfo.Unlock then return false, XDataCenter.FubenManager.GetFubenOpenTips(chapterInfo.FirstStage) end + if stageId then + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + if not stageInfo then return false, "获取关卡数据失败" end + if not stageInfo.Unlock then return false, XDataCenter.FubenManager.GetFubenOpenTips(stageId) end + end + return true + end + ------------------------------------------------------------------抢先体验部分 + function ExtraChapterManager.NotifyExtraActivity(data) + local now = XTime.GetServerNowTimestamp() + ActivityEndTime = data.EndTime or 0 + ActivityChallengeBeginTime = data.HideChapterBeginTime or 0 + if now < ActivityEndTime then + --清理上次活动状态 + if next(ActivityChapters) then + ExtraChapterManager.ExtraActivityEnd() + end + + ActivityChapters = { + MainLineIds = data.Chapters, + } + + ExtraChapterManager.ExtraActivityStart() + else + --活动关闭 + ExtraChapterManager.ExtraActivityEnd() + end + end + + function ExtraChapterManager.IsExtraActivityOpen() + return ActivityEndTime and ActivityEndTime > XTime.GetServerNowTimestamp() + end + + function ExtraChapterManager.IsExtraActivityChallengeBegin() + return ActivityChallengeBeginTime and XTime.GetServerNowTimestamp() >= ActivityChallengeBeginTime + end + + function ExtraChapterManager.ExtraActivityStart() + if not ExtraChapterManager.IsExtraActivityOpen() then return end + --定时器 + if ActivityTimer then + XScheduleManager.UnSchedule(ActivityTimer) + ActivityTimer = nil + end + local time = XTime.GetServerNowTimestamp() + local challengeWaitUnlock = true + ActivityTimer = XScheduleManager.ScheduleForever(function() + time = time + 1 + if time >= ActivityChallengeBeginTime then + if challengeWaitUnlock then + ExtraChapterManager.UnlockActivityChapters() + challengeWaitUnlock = nil + end + end + if time >= ActivityEndTime then + ExtraChapterManager.ExtraActivityEnd() + end + end, XScheduleManager.SECOND, 0) + ExtraChapterManager.UnlockActivityChapters() + end + + function ExtraChapterManager.UnlockActivityChapters() + if not next(ActivityChapters) then return end + for _, chapterId in pairs(ActivityChapters.MainLineIds) do + if chapterId ~= 0 then + ExtraChapterManager.UnlockChapterViaActivity(chapterId) + end + end + CsXGameEventManager.Instance:Notify(XEventId.EVENT_ACTIVITY_EXTRACHAPTER_STATE_CHANGE) + end + + function ExtraChapterManager.ExtraActivityEnd() + if ActivityTimer then + XScheduleManager.UnSchedule(ActivityTimer) + ActivityTimer = nil + end + --活动结束处理 + local chapterIds = ActivityChapters.MainLineIds + if chapterIds then + for _, chapterId in pairs(chapterIds) do + if chapterId ~= 0 then + local chapterInfo = ExtraChapterManager.GetChapterInfo(chapterId) + chapterInfo.IsActivity = false + end + end + end + XDataCenter.FubenManager.InitData(true) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_ACTIVITY_EXTRACHAPTER_STATE_CHANGE) + end + + function ExtraChapterManager.GetActivityEndTime() + return ActivityEndTime + end + + function ExtraChapterManager.CheckDiffHasAcitivity(chapter) + if not next(ActivityChapters) then return false end + for _, chapterId in pairs(ActivityChapters.MainLineIds) do + if chapterId == chapter.ChapterId then + return true + end + end + return false + end + + function ExtraChapterManager.UnlockChapterViaActivity(chapterId) + --开启章节,标识活动状态 + local chapterInfo = ExtraChapterManager.GetChapterInfo(chapterId) + if not chapterInfo then return end + chapterInfo.IsActivity = true + + if not ExtraChapterManager.CheckActivityCondition(chapterId) then + chapterInfo.Unlock = false + chapterInfo.IsOpen = false + return + end + + chapterInfo.Unlock = true + chapterInfo.IsOpen = true + + local chapterCfg = ExtraChapterManager.GetChapterDetailsCfg(chapterId) + for index, stageId in ipairs(chapterCfg.StageId) do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + stageInfo.Unlock = true + stageInfo.IsOpen = true + + --章节第一关无视前置条件 + if index ~= 1 then + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + + --其余关卡只检测前置条件组 + for _, prestageId in pairs(stageCfg.PreStageId or {}) do + if prestageId > 0 then + local stageData = XDataCenter.FubenManager.GetStageData(prestageId) + + if not stageData or not stageData.Passed then + stageInfo.Unlock = false + stageInfo.IsOpen = false + break + end + end + end + end + end + end + + function ExtraChapterManager.CheckActivityCondition(chapterId) + local chapterCfg = ExtraChapterManager.GetChapterDetailsCfg(chapterId) + if not chapterCfg then return false, CS.XTextManager.GetText("ExtraChapterFindNoChapterData") end + if chapterCfg.Difficult == DifficultType.Hard and + not ExtraChapterManager.IsExtraActivityChallengeBegin() then + local time = XTime.GetServerNowTimestamp() + local timeStr = XUiHelper.GetTime(ActivityChallengeBeginTime - time, XUiHelper.TimeFormatType.ACTIVITY) + local msg = CS.XTextManager.GetText("FuBenExtraChapterActivityNotReachChallengeTime", timeStr) + return false, msg + elseif chapterCfg.Difficult == DifficultType.Hard and + not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.FubenDifficulty) then + return false, XFunctionManager.GetFunctionOpenCondition(XFunctionManager.FunctionName.FubenDifficulty) + end + + local conditionId = chapterCfg.ActivityCondition + if conditionId and conditionId ~= 0 then + return XConditionManager.CheckCondition(conditionId) + end + + return true, "" + end + + function ExtraChapterManager.OnActivityEnd() + if CS.XFight.IsRunning or XLuaUiManager.IsUiLoad("UiLoading") then + return + end + XUiManager.TipText("ActivityExtraChapterEnd") + XLuaUiManager.RunMain() + end + + function ExtraChapterManager.IfChapterIsExtraChapter(chapterId) + return ChapterExtraDetailsCfgs[chapterId] ~= nil + end + ------------------------------------------------------------------ 活动番外副本抢先体验 end ------------------------------------------------------- + ------------------------------------------------------------------ 活动番外副本探索玩法 begin ------------------------------------------------------- + function ExtraChapterManager.InitExploreGroup() + local exploreGroupList = XFubenExtraChapterConfigs.GetExploreGroupCfg() + for _, exploreGroup in pairs(exploreGroupList) do + if not ExploreGroupInfos[exploreGroup.GroupId] then + ExploreGroupInfos[exploreGroup.GroupId] = {} + end + ExploreGroupInfos[exploreGroup.GroupId][exploreGroup.StageIndex] = exploreGroup + end + end + + function ExtraChapterManager.InitExploreItem() + local exploreItemList = XFubenExtraChapterConfigs.GetExploreItemCfg() + for _, exploreItem in pairs(exploreItemList) do + if not ExploreItemInfos[exploreItem.MainChapterId] then + ExploreItemInfos[exploreItem.MainChapterId] = {} + end + table.insert(ExploreItemInfos[exploreItem.MainChapterId], exploreItem) + end + end + + function ExtraChapterManager.GetExploreGroupInfoByGroupId(id) + if not ExploreGroupInfos[id] then + XLog.ErrorTableDataNotFound("ExtraChapterManager.GetExploreGroupInfoByGroupId", + "ExploreGroupInfos", " Client/Fuben/ExtraChapter/ExtraExploreGroup.tab", "id", tostring(id)) + return {} + end + return ExploreGroupInfos[id] + end + + function ExtraChapterManager.GetChapterOrderIdByStageId(stageId) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + local chapter = ChapterExtraDetailsCfgs[stageInfo.ChapterId] + return chapter.OrderId + end + + function ExtraChapterManager.CheckChapterTypeIsExplore(chapter) + return chapter.ExploreGroupId and chapter.ExploreGroupId > 0 + end + + function ExtraChapterManager.CheckHaveNewExploreItemByChapterId(chapterId) + if not ExploreItemInfos[chapterId] then + return false + end + for _, info in pairs(ExploreItemInfos[chapterId]) do + if ExtraChapterManager.CheckHaveNewExploreItemByItemId(info.Id) then + return true + end + end + return false + end + + function ExtraChapterManager.CheckHaveNewExploreItemByItemId(itemId) + local data = XSaveTool.GetData(string.format("%d%s%d", XPlayer.Id, "ExtraChapterExploreItem", itemId)) + return data == ExItemRedPointState.On + end + + function ExtraChapterManager.SetChapterEventState(chapterEventDatas) + for _, data in pairs(chapterEventDatas) do + local eventIds = data.EventIds or {} + for _, id in pairs(eventIds) do + ExploreEventStateList[id] = true + end + end + end + + function ExtraChapterManager.AddChapterEventState(chapterEventData) + local eventIds = chapterEventData and chapterEventData.EventIds or {} + for _, id in pairs(eventIds) do + ExploreEventStateList[id] = true + end + end + + function ExtraChapterManager.GetChapterExploreItemList(chapterId) + local list = {} + if ExploreItemInfos[chapterId] then + for _, info in pairs(ExploreItemInfos[chapterId]) do + if ExploreEventStateList[info.Id] then + table.insert(list, info) + end + end + end + return list + end + + function ExtraChapterManager.GetChapterExploreItemMaxCount(chapterId) + return ExploreItemInfos[chapterId] and #ExploreItemInfos[chapterId] or 0 + end + + function ExtraChapterManager.SaveNewExploreItemRedPoint(chapterEventData) + local eventIds = chapterEventData and chapterEventData.EventIds or {} + local exploreItemList = XFubenMainLineConfigs.GetExploreItemCfg() + for _, id in pairs(eventIds) do + if exploreItemList[id] then + if not XSaveTool.GetData(string.format("%d%s%d", XPlayer.Id, "ExtraChapterExploreItem", id)) then + XSaveTool.SaveData(string.format("%d%s%d", XPlayer.Id, "ExtraChapterExploreItem", id), ExItemRedPointState.On) + end + else + XLog.ErrorTableDataNotFound("ExtraChapterManager.SaveNewExploreItemRedPoint", + "exploreItem", "Client/Fuben/ExtraChapter/ExtraExploreItem.tab", "id", tostring(id)) + end + end + end + + function ExtraChapterManager.MarkNewExploreItemRedPointByItemId(itemId) + local data = XSaveTool.GetData(string.format("%d%s%d", XPlayer.Id, "ExtraChapterExploreItem", itemId)) + if data and data == ExItemRedPointState.On then + XSaveTool.SaveData(string.format("%d%s%d", XPlayer.Id, "ExtraChapterExploreItem", itemId), ExItemRedPointState.Off) + XEventManager.DispatchEvent(XEventId.EVENT_MAINLINE_EXPLORE_ITEMBOX_CLOSE) + end + end + + function ExtraChapterManager.CheckHaveNewJumpStageButtonByStageId(stageId) + local data = XSaveTool.GetData(string.format("%d%s%d", XPlayer.Id, "ExtraChapterJumpStageButton", stageId)) + if data then + return data == ExItemRedPointState.On + end + return false + end + + function ExtraChapterManager.SaveNewJumpStageButtonEffect(stageId) + if not XSaveTool.GetData(string.format("%d%s%d", XPlayer.Id, "ExtraChapterJumpStageButton", stageId)) then + XSaveTool.SaveData(string.format("%d%s%d", XPlayer.Id, "ExtraChapterJumpStageButton", stageId), ExItemRedPointState.On) + end + end + + function ExtraChapterManager.MarkNewJumpStageButtonEffectByStageId(stageId) + local data = XSaveTool.GetData(string.format("%d%s%d", XPlayer.Id, "ExtraChapterJumpStageButton", stageId)) + if data and data == ExItemRedPointState.On then + XSaveTool.SaveData(string.format("%d%s%d", XPlayer.Id, "ExtraChapterJumpStageButton", stageId), ExItemRedPointState.Off) + end + end + -- 胜利 & 奖励界面 + function ExtraChapterManager.ShowReward(winData) + XLuaUiManager.Open("UiSettleWinMainLine", winData) + end + ------------------------------------------------------------------ 活动主线副本探索玩法 end ------------------------------------------------------- + --新增章节开启条件 + function ExtraChapterManager.CheckOpenCondition(chapterId) + local chapterCfg = ExtraChapterManager.GetChapterDetailsCfg(chapterId) + if not chapterCfg then return false, CS.XTextManager.GetText("ExtraChapterFindNoChapterData") end + local conditionId = chapterCfg.OpenCondition + if conditionId and conditionId ~= 0 then + return XConditionManager.CheckCondition(conditionId) + end + + return true, "" + end + + -- 领取宝箱奖励 + function ExtraChapterManager.ReceiveTreasureReward(cb, treasureId) + local req = { TreasureId = treasureId } + XNetwork.Call("ChapterExtraTreasureRewardRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + ExtraChapterManager.SyncTreasureStage(treasureId) + if cb then + cb(res.RewardGoods) + end + XEventManager.DispatchEvent(XEventId.EVENT_FUBEN_EXTRACHAPTER_REWARD) + end) + end + ExtraChapterManager.Init() + return ExtraChapterManager +end + +XRpc.NotifyChapterExtraActivity = function(data) + XDataCenter.ExtraChapterManager.NotifyExtraActivity(data) +end + +XRpc.NotifyChapterExtraEventData = function(data) + XDataCenter.ExtraChapterManager.AddChapterEventState(data.ChapterEventData) + XDataCenter.ExtraChapterManager.SaveNewExploreItemRedPoint(data.ChapterEventData) + XEventManager.DispatchEvent(XEventId.EVENT_EXTRACHAPTER_EXPLORE_ITEM_GET) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XFubenFestivalActivityManager.lua b/Resources/Scripts/XManager/XFubenFestivalActivityManager.lua new file mode 100644 index 00000000..b373246f --- /dev/null +++ b/Resources/Scripts/XManager/XFubenFestivalActivityManager.lua @@ -0,0 +1,180 @@ +XFubenFestivalActivityManagerCreator = function() + local XFestivalChapter = require("XEntity/XFestival/XFestivalChapter") + local XFubenFestivalActivityManager = {} + local FestivalChapters = {} + XFubenFestivalActivityManager.StageFuben = 1 --战斗 + XFubenFestivalActivityManager.StageStory = 2 --剧情 + local StageId2ChapterIdDic = {} + + function XFubenFestivalActivityManager.Init() + XEventManager.AddEventListener(XEventId.EVENT_PLAYER_LEVEL_CHANGE, XFubenFestivalActivityManager.RefreshChapterStages) + end + + -- [初始化数据] + function XFubenFestivalActivityManager.InitStageInfo() + XFubenFestivalActivityManager.InitAllEntities() + end + + function XFubenFestivalActivityManager.InitAllEntities() + local festivalTemplates = XFestivalActivityConfig.GetFestivalsTemplates() + for _, festivalTemplate in pairs(festivalTemplates or {}) do + if not FestivalChapters[festivalTemplate.Id] then + FestivalChapters[festivalTemplate.Id] = XFestivalChapter.New(festivalTemplate.Id) + else + FestivalChapters[festivalTemplate.Id]:RefreshStages() + end + end + end + + function XFubenFestivalActivityManager.AddStageId2ChapterId(stageId, chapterId) + StageId2ChapterIdDic[stageId] = chapterId + end + + function XFubenFestivalActivityManager.GetChapterIdByStageId(stageId) + return StageId2ChapterIdDic[stageId] or 0 + end + + -- [胜利] + function XFubenFestivalActivityManager.ShowReward(winData) + if not winData then return end + XFubenFestivalActivityManager.RefreshStagePassedBySettleDatas(winData.SettleData) + XLuaUiManager.Open("UiSettleWin", winData) + end + --==================== + --根据通关数据刷新章节关卡 + --==================== + function XFubenFestivalActivityManager.RefreshStagePassedBySettleDatas(settleData) + if not settleData then return end + for _, chapter in pairs(FestivalChapters) do + local stage = chapter:GetStageByStageId(settleData.StageId) + if stage then + stage:SetIsPass(true) + stage:AddPassCount(1) + chapter:RefreshChapterStageInfos() + XEventManager.DispatchEvent(XEventId.EVENT_ON_FESTIVAL_CHANGED) + break + end + end + end + --==================== + --刷新章节关卡,用于外部条件变更时刷新章节关卡状态 + --==================== + function XFubenFestivalActivityManager.RefreshChapterStages() + for _, chapter in pairs(FestivalChapters) do + if chapter:GetIsOpen() then + chapter:RefreshChapterStageInfos() + end + end + end + --==================== + --同步通关数据 + --@param response:服务器传来的通关数据 + --==================== + function XFubenFestivalActivityManager.RefreshStagePassed(response) + for _, info in pairs(response.FestivalInfos or {}) do + local chapter = FestivalChapters[info.Id] + if chapter then + for _, stageInfos in pairs(info.StageInfos or {}) do + local stage = chapter:GetStageByStageId(stageInfos.Id) + if stage then + stage:SetIsPass(true) + stage:SetPassCount(stageInfos.ChallengeCount) + end + end + chapter:RefreshChapterStageInfos() + end + end + end + --==================== + --根据节日ID获取节日活动的通关数据 + --@return1 通关总数 + --@return2 关卡总数 + --==================== + function XFubenFestivalActivityManager.GetFestivalProgress(festivalId) + local chapter = FestivalChapters[festivalId] + if not chapter then return 0, 0 end + return chapter:GetStagePassCount(), chapter:GetStageTotalCount() + end + --==================== + --根据节日ID获取节日活动是否在开放时间内 + --@param festivalId:节日配置Id + --==================== + function XFubenFestivalActivityManager.GetAvailableFestivals() + local activityList = {} + for _, chapter in pairs(FestivalChapters) do + if chapter:GetIsOpen() then + table.insert(activityList, { + Id = chapter:GetChapterId(), + Type = chapter:GetChapterType(), + Name = chapter:GetName(), + Icon = chapter:GetBannerBg(), + }) + end + end + return activityList + end + --==================== + --根据节日ID获取节日活动是否在开放时间内 + --@param festivalId:节日配置Id + --==================== + function XFubenFestivalActivityManager.IsFestivalInActivity(festivalId) + local chapter = FestivalChapters[festivalId] + if chapter then + return chapter:GetIsInTime() + end + return false + end + --==================== + --根据节日ID和关卡ID获取节日关卡对象 + --@param festivalId:节日配置Id + --@param stageId:关卡表Id + --==================== + function XFubenFestivalActivityManager.GetFestivalStageByFestivalIdAndStageId(festivalId, stageId) + local chapter = FestivalChapters[festivalId] + if not chapter then return end + return chapter:GetStageByStageId(stageId) + end + --==================== + --根据节日ID和关卡ID获取节日章节对象 + --@param festivalId:节日配置Id + --==================== + function XFubenFestivalActivityManager.GetFestivalChapterById(festivalId) + return FestivalChapters[festivalId] + end + --==================== + --根据关卡ID获取关卡是否开放 + --@param stageId:关卡ID + --==================== + function XFubenFestivalActivityManager.CheckPassedByStageId(stageId) + for _, chapter in pairs(FestivalChapters) do + local stage = chapter:GetStageByStageId(stageId) + if stage then + return stage:GetIsPass() + end + end + return false + end + -- [播放剧情] + function XFubenFestivalActivityManager.FinishStoryRequest(stageId, cb) + XNetwork.Call("EnterStoryRequest", { StageId = stageId }, function(res) + cb = cb or function() end + if res.Code == XCode.Success then + cb(res) + else + XUiManager.TipCode(res.Code) + end + end) + end + + function XFubenFestivalActivityManager.OnAsyncFestivalStages(response) + if not response then return end + XFubenFestivalActivityManager.RefreshStagePassed(response) + end + + XFubenFestivalActivityManager.Init() + return XFubenFestivalActivityManager +end + +XRpc.NotifyFestivalData = function(response) + XDataCenter.FubenFestivalActivityManager.OnAsyncFestivalStages(response) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XFubenHackManager.lua b/Resources/Scripts/XManager/XFubenHackManager.lua new file mode 100644 index 00000000..ec87f7d8 --- /dev/null +++ b/Resources/Scripts/XManager/XFubenHackManager.lua @@ -0,0 +1,687 @@ +local tableInsert = table.insert +local ipairs = ipairs +local pairs = pairs +local CsPlayerPrefs = CS.UnityEngine.PlayerPrefs +local KEY_LAST_LEVEL = "LastLevel" +local KEY_LAST_EXP = "LastExp" +local KEY_AFFIX_UNLOCK = "AffixUnlock" +local KEY_STAGE_DETAIL = "StageDetail" +local KEY_TEAM = "Team" + +XFubenHackManagerCreator = function() + local MAX_STAGE_STAR_COUNT = 3 + local XFubenHackManager = {} + local ActivityInfo = nil + local DefaultActivityInfo = nil + + local LevelInfo = { + Level = 0, + TotalExp = 0, + Exp = 0, + LastLevel = nil, + LastExp = nil, + } + local CurChapterId = 1 + local IsTicketGet = false + local BuffBarList = {} + + local StageStarRecordDic = {} + local AffixUnlockMap = {} -- 已解锁buff表 + local RewardDic = {} --已经领取的星级奖励 + local LevelExpDic = {} -- 每一级所需要的总经验 + local BuffLevelDic = {} -- BuffId对应的等级 + local StageDetailReadDic = {} -- 关卡详情已读标记 + local BuffPosLevelDic = {} -- Buff栏开放表 + local IsRegisterEditBattleProxy = false + + -------- local function begin ---------- + local function Init() + local activityTemplates = XFubenHackConfig.GetActTemplates() + for _, template in pairs(activityTemplates) do + DefaultActivityInfo = ActivityInfo or XFubenHackConfig.GetActivityTemplateById(template.Id) + end + + XFubenHackManager.RegisterEditBattleProxy() + end + + local function GetKey(key) + return string.format("%s_FubenHack_%d_%d_%s", tostring(XPlayer.Id), ActivityInfo.Id, CurChapterId, key) + end + + --最后一次保存的等级 + local function GetLastLevel() + return LevelInfo.LastLevel or CsPlayerPrefs.GetInt(GetKey(KEY_LAST_LEVEL), -1) + end + + local function GetLastExp() + return LevelInfo.LastExp or CsPlayerPrefs.GetInt(GetKey(KEY_LAST_EXP), -1) + end + + -- 保存当前等级 + local function SaveLevel(level) + local curLevel = level or XFubenHackManager.GetLevel() + CsPlayerPrefs.SetInt(KEY_LAST_LEVEL, curLevel) + CsPlayerPrefs.Save() + LevelInfo.LastLevel = curLevel + end + + local function SaveExp(exp) + local curExp = exp or XFubenHackManager.GetTotalExp() + CsPlayerPrefs.SetInt(KEY_LAST_EXP, curExp) + LevelInfo.LastExp = curExp + end + + local function GetLevelByExp(exp) + for i = XFubenHackManager.GetMaxLevel(), 1, -1 do + if exp >= LevelExpDic[i] then + return i + end + end + end + + local GetStarsCount = function(starsMark) + local count = (starsMark & 1) + (starsMark & 2 > 0 and 1 or 0) + (starsMark & 4 > 0 and 1 or 0) + local starMap = {(starsMark & 1) > 0, (starsMark & 2) > 0, (starsMark & 4) > 0 } + return count, starMap + end + + -------- local function end ---------- + local FUBEN_HACK_PROTO = { + GetHackRewardRequest = "GetHackRewardRequest", + SetHackBuffRequest = "SetHackBuffRequest", + GetHackDailyTicketRequest = "GetHackDailyTicketRequest", + } + + function XFubenHackManager.GetCurrentActTemplate() + return ActivityInfo + end + + function XFubenHackManager.OnActivityEnd() + XLuaUiManager.RunMain() + if XFubenHackManager.GetIsActivityEnd() then + XUiManager.TipText("ActivityMainLineEnd", XUiManager.UiTipType.Wrong) + else + XUiManager.TipText("ArenaOnlineTimeOut", XUiManager.UiTipType.Wrong, true) + end + end + + -- 判断等级是否提升 + function XFubenHackManager.CheckLevelUp() + local curLevel = XFubenHackManager.GetLevel() + local lastLevel = GetLastLevel() + -- -1 表示未保存过 + if lastLevel == -1 then + SaveLevel() + return false + end + if lastLevel < curLevel then + XLuaUiManager.Open("UiHackLevelUpTips",lastLevel, curLevel) + SaveLevel(curLevel) + return true + end + return false + end + + -- 判断经验是否提升 + function XFubenHackManager.CheckExpAdd() + local curExp = XFubenHackManager.GetTotalExp() + local lastExp = GetLastExp() + -- -1 表示未保存过 + if lastExp == -1 then + SaveExp() + CsPlayerPrefs.Save() + return false + end + + if lastExp < curExp then + local AnimTempLevel = GetLevelByExp(lastExp) + local lastLevelExp = lastExp - LevelExpDic[AnimTempLevel] + local lvCfg = XFubenHackManager.GetLevelCfg(AnimTempLevel) + if LevelInfo.Level > AnimTempLevel then + AnimTempLevel = AnimTempLevel + 1 + LevelInfo.LastExp = LevelExpDic[AnimTempLevel] + return true, true, AnimTempLevel - 1, lastLevelExp, lvCfg.UpExp, lvCfg.UpExp + else + SaveExp(LevelInfo.TotalExp) + return true, false, AnimTempLevel, lastLevelExp, XFubenHackManager.GetCurExp(), lvCfg.UpExp + end + end + return false, false + end + + -- 等级 + function XFubenHackManager.GetLevel() + return LevelInfo.Level + end + + function XFubenHackManager.GetTotalExp() + return LevelInfo.TotalExp + end + + function XFubenHackManager.GetCurExp() + return LevelInfo.CurExp + end + + function XFubenHackManager.GetNextUpExp() + local lvCfg = XFubenHackManager.GetLevelCfg(LevelInfo.Level) + if not lvCfg then + return 0 + end + return lvCfg.UpExp + end + + function XFubenHackManager.GetReadDetailMark(stageId) + return StageDetailReadDic[stageId] + end + + function XFubenHackManager.SetReadDetailMark(stageId) + StageDetailReadDic[stageId] = true + XSaveTool.SaveData(GetKey(KEY_STAGE_DETAIL), StageDetailReadDic) + end + + function XFubenHackManager.GetBuffBarList() + return BuffBarList + end + + function XFubenHackManager.GetBuffAbilityBonus() + local bonus = 0 + for _, v in ipairs(BuffBarList) do + if v ~= 0 then + bonus = bonus + XFubenHackConfig.GetBuffById(v).AbilityBonus + end + end + return bonus + end + + function XFubenHackManager.CheckAffixEquip(buffId) + for _, v in ipairs(BuffBarList) do + if v == buffId then + return true + end + end + return false + end + + function XFubenHackManager.GetLevelByBuffId(buffId) + return BuffLevelDic[buffId] + end + + function XFubenHackManager.CheckAffixRedPoint() + for i = 1, LevelInfo.Level do + if not AffixUnlockMap[i] then + return true + end + end + + local count = 0 + local buffBarCount = 0 + for i = XFubenHackConfig.BuffBarCapacity, 0, -1 do + if XFubenHackManager.IsBuffPosUnlock(i) then + buffBarCount = i + break + end + end + + for i = 1, buffBarCount do + if BuffBarList[i] == 0 then + if LevelInfo.Level >= buffBarCount then + return true + end + else + count = count + 1 + end + end + + if count < LevelInfo.Level and count < buffBarCount then + return true + end + + return false + end + + function XFubenHackManager.GetBuffListShowIndex() + for i = 1, LevelInfo.Level do + if not AffixUnlockMap[i+1] then + return i + end + end + return LevelInfo.Level + end + + function XFubenHackManager.IsAffixUnlock(level) + return LevelInfo.Level >= level and AffixUnlockMap[level] + end + + function XFubenHackManager.UnlockAffix(level) + if LevelInfo.Level < level then + local desc = CS.XTextManager.GetText("FubenHackUnlockBuffFail") + return false, desc + else + AffixUnlockMap[level] = true + XSaveTool.SaveData(GetKey(KEY_AFFIX_UNLOCK), AffixUnlockMap) + local desc = CS.XTextManager.GetText("FubenHackUnlockBuffSucc") + return true, desc + end + end + + function XFubenHackManager.IsBuffPosUnlock(index) + return BuffPosLevelDic[index] and LevelInfo.Level >= BuffPosLevelDic[index], BuffPosLevelDic[index] or -1 + end + + function XFubenHackManager.GetLevelCfg(level) + return XFubenHackConfig.GetLevelCfg(CurChapterId, level) + end + + function XFubenHackManager.GetMaxLevel() + local cfgs = XFubenHackConfig.GetLevelCfgs(CurChapterId) + return cfgs and #cfgs or 0 + end + + -- 保存编队信息 + function XFubenHackManager.SaveTeamLocal(curTeam) + XSaveTool.SaveData(GetKey(KEY_TEAM), curTeam) + end + + -- 读取本地编队信息 + function XFubenHackManager.LoadTeamLocal() + local team = XSaveTool.GetData(GetKey(KEY_TEAM)) or XDataCenter.TeamManager.EmptyTeam + return team + end + + --获取奖励 + function XFubenHackManager.GetStarRewardList() + local ownStars = XFubenHackManager.GetStarProgress() + local canGet = false + local startIndex = 1 + local leastGap = XMath.IntMax() + local starReward = {} + for i, v in ipairs(XFubenHackManager.GetCurChapterTemplate().RewardId) do + local cfg = XFubenHackConfig.GetRewardById(v) + if cfg then + local data = {} + data.Id = cfg.Id + data.RequireStar = cfg.NeedStars + data.RewardId = cfg.RewardId + data.IsFinish = ownStars >= cfg.NeedStars + data.IsReward = XFubenHackManager.CheckStarRewardGet(v) + starReward[i] = data + if canGet then goto CONTINUE end + if data.IsFinish and not data.IsReward then + startIndex = i + canGet = true + elseif not data.IsFinish then + local gap = cfg.NeedStars - ownStars + if leastGap > gap then + leastGap = gap + startIndex = i + end + end + end + ::CONTINUE:: + end + + return starReward, canGet, startIndex + end + + --判断是否已经领奖 + function XFubenHackManager.CheckStarRewardGet(rewardId) + if not rewardId then + return + end + + return RewardDic and RewardDic[rewardId] + end + + function XFubenHackManager.GetStarReward(id, cb) + XNetwork.Call(FUBEN_HACK_PROTO.GetHackRewardRequest, { Id = id }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + RewardDic[id] = true + if cb then + cb(res.RewardGoodsList) + end + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_FUBEN_HACK_UPDATE) + end) + end + + -- [初始化数据] + function XFubenHackManager.InitStageInfo() + local stages = XFubenHackConfig.GetStages() + for _, v in pairs(stages) do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(v.Id) + if stageInfo then + stageInfo.Type = XDataCenter.FubenManager.StageType.Hack + end + end + + -- 通关后需要会执行InitStage 所以需要刷新 + XFubenHackManager.RefreshStagePassed() + end + + function XFubenHackManager.RefreshStagePassed() + if CurChapterId == 0 then return end + local chapter = XFubenHackManager.GetCurChapterTemplate() + for _, stageId in ipairs(chapter.StageId) do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + if stageInfo then + stageInfo.Passed = StageStarRecordDic[stageId] or false + stageInfo.StarsMap = XFubenHackManager.GetStarMap(stageId) + stageInfo.Unlock = true + stageInfo.IsOpen = true + + if stageCfg.RequireLevel > 0 and XPlayer.Level < stageCfg.RequireLevel then + stageInfo.Unlock = false + end + + for _, preStageId in pairs(stageCfg.PreStageId or {}) do + if preStageId > 0 then + if not StageStarRecordDic[preStageId] then + stageInfo.Unlock = false + stageInfo.IsOpen = false + break + end + end + end + end + end + end + + function XFubenHackManager.CheckPreFight(stage) + if not StageStarRecordDic[stage.StageId] then + local consume = XFubenHackConfig.GetStageInfo(stage.StageId).ConsumeTicket + local count = XDataCenter.ItemManager.GetCount(ActivityInfo.TicketId) + if consume > count then + local msg = CS.XTextManager.GetText("FubenHackTicketNotEnough") + XUiManager.TipMsg(msg) + return false + end + end + return true + end + + function XFubenHackManager.PreFight(stage, teamId) + local preFight = {} + preFight.CardIds = {} + preFight.RobotIds = {} + preFight.StageId = stage.StageId + + if not stage.RobotId or #stage.RobotId <= 0 then + local teamData = XDataCenter.TeamManager.GetTeamData(teamId) + for i, v in pairs(teamData) do + local isRobot = XRobotManager.CheckIsRobotId(v) + --preFight.RobotIds[i] = isRobot and v or 0 + if isRobot then tableInsert(preFight.RobotIds, v) end + preFight.CardIds[i] = XRobotManager.CheckIdToCharacterId(v) + end + preFight.CaptainPos = XDataCenter.TeamManager.GetTeamCaptainPos(teamId) + preFight.FirstFightPos = XDataCenter.TeamManager.GetTeamFirstFightPos(teamId) + end + + return preFight + end + + -- [胜利] + function XFubenHackManager.ShowReward(winData) + if not winData then return end + + XLuaUiManager.Open("UiSettleWinMainLine", winData) + end + + function XFubenHackManager.SetBuff(index, buffId, cb) + if index == 0 then + for pos, v in ipairs(BuffBarList) do + if v == 0 and XFubenHackManager.IsBuffPosUnlock(pos) then + index = pos + break + end + end + end + + if index ~= 0 then + XNetwork.Call(FUBEN_HACK_PROTO.SetHackBuffRequest, {Index = index, BuffId = buffId},function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return false + end + + BuffBarList[index] = buffId + CsXGameEventManager.Instance:Notify(XEventId.EVENT_FUBEN_HACK_UPDATE) + + cb(true) + end) + else + cb(false, CS.XTextManager.GetText("FubenHackEquipBuffFail")) + end + end + + function XFubenHackManager.GetHackDailyTicket() + if IsTicketGet then return false end + XNetwork.Call(FUBEN_HACK_PROTO.GetHackDailyTicketRequest, {},function(res) + if res.Code ~= XCode.Success then + -- XUiManager.TipCode(res.Code) + return false + end + + IsTicketGet = true + local rewards = {{ TemplateId = res.TicketId , Count = res.TicketCount }} + XUiManager.OpenUiObtain(rewards, CS.XTextManager.GetText("FubenHackDailyTicket")) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_FUBEN_HACK_UPDATE) + return true + end) + end + + function XFubenHackManager.GetCurChapterTemplate() + return XFubenHackConfig.GetChapterTemplate(CurChapterId) or {} + end + + function XFubenHackManager.GetStarMap(stageId) + local starsMark = StageStarRecordDic[stageId] or 0 + local count, starMap = GetStarsCount(starsMark) + return starMap, count + end + + -- 获取所有关卡进度 + function XFubenHackManager.GetStageSchedule() + local chapter = XFubenHackManager.GetCurChapterTemplate() + local passCount = 0 + local allCount = #chapter.StageId + + for _, stageId in ipairs(chapter.StageId) do + if StageStarRecordDic[stageId] then + passCount = passCount + 1 + end + end + + return passCount, allCount + end + + -- 主题活动页面是否可挑战接口 + function XFubenHackManager.IsChallengeable() + if not ActivityInfo then return false end + + if not IsTicketGet or XDataCenter.ItemManager.GetCount(ActivityInfo.TicketId) > 0 then + local passCount, allCount = XFubenHackManager.GetStageSchedule() + if passCount < allCount then + return true + end + end + + return false + end + + -- 获取篇章星数 + function XFubenHackManager.GetStarProgress() + local templates = XFubenHackManager.GetCurChapterTemplate() + local totalStars = #templates.StageId * MAX_STAGE_STAR_COUNT + local ownStars = 0 + for _, v in ipairs(templates.StageId) do + local _, starCount = XFubenHackManager.GetStarMap(v) + ownStars = ownStars + starCount + end + return ownStars, totalStars + end + + function XFubenHackManager.GetAvailableActs() + local act = XFubenHackManager.GetCurrentActTemplate() + local activityList = {} + if act and + not XFubenHackManager.GetIsActivityEnd() and + not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.FubenHack) then + tableInsert(activityList, { + Id = act.Id, + Type = XDataCenter.FubenManager.ChapterType.Hack, + Name = act.Name, + Icon = act.BannerBg, + }) + end + return activityList + end + + --判断活动是否开启 + function XFubenHackManager.GetIsActivityEnd() + if not ActivityInfo then + return true, true + end + local timeNow = XTime.GetServerNowTimestamp() + local isEnd = timeNow >= XFubenHackManager.GetEndTime() + local isStart = timeNow >= XFubenHackManager.GetStartTime() + local inActivity = (not isEnd) and (isStart) + return not inActivity, timeNow < XFubenHackManager.GetStartTime() + end + + --获取活动开始时间 + function XFubenHackManager.GetStartTime() + if DefaultActivityInfo then + return XFunctionManager.GetStartTimeByTimeId(DefaultActivityInfo.TimeId) or 0 + end + return 0 + end + + --获取活动结束时间 + function XFubenHackManager.GetEndTime() + if DefaultActivityInfo then + return XFunctionManager.GetEndTimeByTimeId(DefaultActivityInfo.TimeId) or 0 + end + return 0 + end + + --获取本轮结束时间 + function XFubenHackManager.GetCurChapterEndTime() + local chapter = XFubenHackManager.GetCurChapterTemplate() + if DefaultActivityInfo then + return XFunctionManager.GetEndTimeByTimeId(chapter.TimeId) or 0 + end + return 0 + end + + -- 注册出战界面代理 + function XFubenHackManager.RegisterEditBattleProxy() + if IsRegisterEditBattleProxy then return end + IsRegisterEditBattleProxy = true + XUiNewRoomSingleProxy.RegisterProxy(XDataCenter.FubenManager.StageType.Hack, + require("XUi/XUiFubenHack/Proxy/XUiHackNewRoomSingle")) + XUiRoomCharacterProxy.RegisterProxy(XDataCenter.FubenManager.StageType.Hack, + require("XUi/XUiFubenHack/Proxy/XUiHackRoomCharacter")) + end + + --登录/活动开始/跨周时下发 + function XFubenHackManager.NotifyData(data) + ActivityInfo = XFubenHackConfig.GetActivityTemplateById(data.Id) + CurChapterId = data.ChapterId + + if CurChapterId ~= 0 then + LevelExpDic = {[1] = 0} + BuffPosLevelDic = {} + local maxLv = XFubenHackManager.GetMaxLevel() + for i = 1, maxLv do + local levelCfg = XFubenHackManager.GetLevelCfg(i) + LevelExpDic[i + 1] = LevelExpDic[i] + levelCfg.UpExp + BuffLevelDic[levelCfg.BuffId] = i + + for pos = 1, levelCfg.UnlockBuffPos do + if not BuffPosLevelDic[pos] then + BuffPosLevelDic[pos] = i + end + end + end + --BuffLevelDic[XFubenHackManager.GetLevelCfg(maxLv).BuffId] = maxLv + + LevelInfo.Level = data.Level + LevelInfo.TotalExp = data.TotalExp + LevelInfo.CurExp = data.TotalExp - LevelExpDic[data.Level] or 0 + IsTicketGet = data.IsTicketGet + BuffBarList = data.LevelBuffIds + + RewardDic = {} + for _, rewardId in ipairs(data.RewardIds) do + RewardDic[rewardId] = true + end + + StageStarRecordDic = {} + for _, stageInfo in ipairs(data.StageInfos) do + StageStarRecordDic[stageInfo.Id] = stageInfo.Star + end + XFubenHackManager.RefreshStagePassed() + + AffixUnlockMap = XSaveTool.GetData(GetKey(KEY_AFFIX_UNLOCK)) + if not AffixUnlockMap then + AffixUnlockMap = {} + for i = 1, LevelInfo.Level do + AffixUnlockMap[i] = true + end + XSaveTool.SaveData(GetKey(KEY_AFFIX_UNLOCK), AffixUnlockMap) + end + StageDetailReadDic = XSaveTool.GetData(GetKey(KEY_STAGE_DETAIL)) or {} + end + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_ACTIVITY_ON_RESET, XDataCenter.FubenManager.StageType.Hack) + end + + -- 下发等级数据 + function XFubenHackManager.NotifyHackLevelData(data) + LevelInfo.Level = data.Level + LevelInfo.TotalExp = data.TotalExp + LevelInfo.CurExp = data.TotalExp - LevelExpDic[data.Level] + -- 派发更新通知 + CsXGameEventManager.Instance:Notify(XEventId.EVENT_FUBEN_HACK_UPDATE) + end + + -- 下发关卡数据(通关星数) + function XFubenHackManager.NotifyStageData(stageInfo) + StageStarRecordDic[stageInfo.Id] = stageInfo.Star + XFubenHackManager.RefreshStagePassed() + end + + -- 下发门票领取状态 + function XFubenHackManager.NotifyHackTicketGetState(data) + IsTicketGet = data.IsTicketGet + -- 派发更新通知 + CsXGameEventManager.Instance:Notify(XEventId.EVENT_FUBEN_HACK_UPDATE) + end + + XEventManager.AddEventListener(XEventId.EVENT_LOGIN_DATA_LOAD_COMPLETE, function() + Init() + end) + return XFubenHackManager +end + +XRpc.NotifyHackLoginData = function(data) + XDataCenter.FubenHackManager.NotifyData(data) +end + +XRpc.NotifyHackLevelData = function(data) + XDataCenter.FubenHackManager.NotifyHackLevelData(data) +end + +XRpc.NotifyHackStageInfoChange = function(data) + XDataCenter.FubenHackManager.NotifyStageData(data.StageInfo) +end + +XRpc.NotifyHackTicketGetState = function(data) + XDataCenter.FubenHackManager.NotifyHackTicketGetState(data) +end diff --git a/Resources/Scripts/XManager/XFubenInfestorExploreManager.lua b/Resources/Scripts/XManager/XFubenInfestorExploreManager.lua new file mode 100644 index 00000000..81ec5535 --- /dev/null +++ b/Resources/Scripts/XManager/XFubenInfestorExploreManager.lua @@ -0,0 +1,2270 @@ +-- -------------------(引用外部模块)begin--------------------- +local XInfestorExploreMapNode = require("XEntity/XInfestorExplore/XInfestorExploreMapNode") +local XInfestorExplorePlayer = require("XEntity/XInfestorExplore/XInfestorExplorePlayer") +local XInfestorExploreCharacter = require("XEntity/XInfestorExplore/XInfestorExploreCharacter") +local XInfestorExploreCore = require("XEntity/XInfestorExplore/XInfestorExploreCore") +local XInfestorExploreTeam = require("XEntity/XInfestorExplore/XInfestorExploreTeam") +-- -------------------(引用外部模块)end--------------------- +-- -------------------(lua api c#函数 api)begin------------------ +local pairs = pairs +local tableInsert = table.insert +local tableRemove = table.remove +local tableSort = table.sort +local CSXTextManagerGetText = CS.XTextManager.GetText +-- -------------------(lua api c#函数 api)end------------------ +local REQUEST_SYNC_INFO_CD = CS.XGame.Config:GetInt("InfestorSyncPlayerInfoInterval") +local REQUEST_LEAVE_CHAPTER_MSG_CD = CS.XGame.Config:GetInt("InfestorChapterLeaveMsgInterval") +local REQUEST_GET_LEAVE_CHAPTER_MSG_CD = CS.XGame.Config:GetInt("InfestorChapterLeaveMsgInterval") +local MAX_CHAPTER_MESSAGE_COUNT = CS.XGame.Config:GetInt("InfestorChapterLeaveMsgMaxCount") +local SectionType = { + Init = 0, --初始化 + RESET = 1, --结算期 + StageExplore = 2, --关卡探索 + BossFight = 3, --boss战 +} + + + +-- -------------------(数据)begin------------------ +XFubenInfestorExploreManagerCreator = function() + local SectionStatus = SectionType.Init --当前处于的阶段 + local CurChapterId = 0 --当前的章节 + local CurNodeId = 0 --当前的节点 + local DelayMoveNodeId + local LastFinishNodeId = 0 + local CurGroupId = 0 + local CurDiff = 0 + local LastSyncInfoTime = 0 + local LastLeaveChapterMsgTime = 0 + local LastGetLeaveChapterMsgTime = 0 + local Maps = {} --存储五个地图的配置 + local PlayerDataDic = {} + local PlayerRankDataList = {} + local CharacterDataDic = {} + local BuffIds = {} + local CoreDic = {} + local CoreIdList = {} + local CoreUseIdDic = {} + local ChapterIdToShopDic = {} + local SelectRewardInfoDic = {} + local ContractEventIdDic = {} + local FightRewardBuyDic = {} + local ChapterMsgDic = {} + local FightEventId = 0 + local ActivityId = 0 + local Chapter2ScoreDic = {} + local ActivityNo = 0 + local OldActivityNo = 0 + local LastDiff = 0 + local AfterFightNeedShowReward + local NewChapterNeedShowAnim + local Team = { + [XFubenConfigs.CharacterLimitType.All] = XInfestorExploreTeam.New(XFubenConfigs.CharacterLimitType.All), + [XFubenConfigs.CharacterLimitType.Normal] = XInfestorExploreTeam.New(XFubenConfigs.CharacterLimitType.Normal), + [XFubenConfigs.CharacterLimitType.Isomer] = XInfestorExploreTeam.New(XFubenConfigs.CharacterLimitType.Isomer), + [XFubenConfigs.CharacterLimitType.IsomerDebuff] = XInfestorExploreTeam.New(XFubenConfigs.CharacterLimitType.IsomerDebuff), + [XFubenConfigs.CharacterLimitType.NormalDebuff] = XInfestorExploreTeam.New(XFubenConfigs.CharacterLimitType.NormalDebuff), + } + local TeamChanged = nil + + local OldMoneyCount = 0 + local NewMoneyCount = 0 + + local OpenInfestorExploreCoreDelay = 0 + local OpenInfestorExploreCoreScheduleId = nil + local OpenInfestorExploreCoreCbTemp = nil + -- -------------------(数据)end------------------ + -- -------------------(本地接口)begin------------------ + local function GetCookieKey() + return XPlayer.Id .. "NEW_DIFF" + end + + local function GetMap(chapterId) + local map = Maps[chapterId] + if not map then + XLog.Error("XFubenInfestorExploreManager GetMap Error: 获取地图失败,章节不存在地图配置,chapterId: " .. chapterId) + return + end + return map + end + + local function GetStageNode(chapterId, nodeId) + local map = GetMap(chapterId) + local stageNode = map and map[nodeId] + if not stageNode then + XLog.Error("XFubenInfestorExploreManager GetStageNode Error: 获取地图节点失败,章节不存在地图配置,chapterId: " .. chapterId .. ", nodeId: " .. nodeId .. ", map: ", map) + return + end + return stageNode + end + + local function GetNodeOutPostStory(chapterId, nodeId) + local node = GetStageNode(chapterId, nodeId) + return node:GetOutPostStory() + end + + local function GetCharacterData(characterId) + local characterData = CharacterDataDic[characterId] + if not characterData then + characterData = XInfestorExploreCharacter.New() + CharacterDataDic[characterId] = characterData + end + return characterData + end + + local function GetTeam(teamType) + return Team[teamType] + end + + local function GetChapterTeam(chapterId) + local teamType = XFubenInfestorExploreConfigs.GetChapterCharacterLimitType(chapterId) + return GetTeam(teamType) + end + + local function GetCore(coreId) + return CoreDic[coreId] + end + + local function AddCore(coreData) + local core = XInfestorExploreCore.New() + core:UpdateData(coreData) + + local coreId = core:GetId() + CoreDic[coreId] = core + tableInsert(CoreIdList, coreId) + end + + local function DeleteCore(coreId) + CoreDic[coreId] = nil + + for index, paramCoreId in pairs(CoreIdList) do + if coreId == paramCoreId then + tableRemove(CoreIdList, index) + break + end + end + + for pos, paramCoreId in pairs(CoreUseIdDic) do + if coreId == paramCoreId then + CoreUseIdDic[pos] = 0 + break + end + end + end + + local function IsHaveCore(coreId) + if not coreId then return false end + local core = GetCore(coreId) + return core and true or false + end + + local function TakeOffCore(pos) + local coreId = CoreUseIdDic[pos] + if coreId and coreId > 0 then + local core = GetCore(coreId) + if core then + core:TakeOff() + end + CoreUseIdDic[pos] = 0 + end + end + + local function PutOnCore(coreId, pos) + --在装备一个Buff之前先把对应位置上的buff TakeOff + TakeOffCore(pos) + + local core = GetCore(coreId) + core:PutOn(pos) + CoreUseIdDic[pos] = coreId + end + + local function AddBuff(buffId) + for _, existBuffId in pairs(BuffIds) do + if existBuffId == buffId then + return + end + end + tableInsert(BuffIds, buffId) + end + + local function RemoveBuff(buffId) + if not buffId or buffId == 0 then return end + for index, existBuffId in pairs(BuffIds) do + if existBuffId == buffId then + tableRemove(BuffIds, index) + return + end + end + end + + local function CheckBuffExsit(buffId) + if not buffId or buffId == 0 then return false end + for index, existBuffId in pairs(BuffIds) do + if existBuffId == buffId then + return true + end + end + return false + end + + local function GetShop() + return ChapterIdToShopDic[CurChapterId] + end + + local function GetSelectRewardInfo(chapterId, nodeId) + return SelectRewardInfoDic[chapterId] and SelectRewardInfoDic[chapterId][nodeId] + end + + local function GetPlayerData(playerId) + return PlayerDataDic[playerId] + end + + local function GetSelectRewardPlayerData(chapterId, nodeId) + local selectRewardInfo = GetSelectRewardInfo(chapterId, nodeId) + if not selectRewardInfo then + return + end + + local playerId = selectRewardInfo.PlayerId + if not playerId then + return + end + + return GetPlayerData(playerId) + end + + local function OnGetMapStartNodeId(chapterId) + local map = GetMap(chapterId) + for _, node in pairs(map) do + if node:IsStart() then + return node:GetNodeId() + end + end + end + + local function InitMaps() + local chapterConfigs = XFubenInfestorExploreConfigs.GetChapterConfigs() + for chapterId in pairs(chapterConfigs) do + local tree = {} + + local mapConfig = XFubenInfestorExploreConfigs.GetMapConfig(chapterId) + for nodeId, nodeConfig in pairs(mapConfig) do + local node = tree[nodeId] + if not node then + node = XInfestorExploreMapNode.New(nodeId) + tree[nodeId] = node + end + + local parentIds = nodeConfig.FrontId + for _, parentId in pairs(parentIds) do + if parentId ~= 0 then + node:SetParentId(parentId) + + local parentNode = tree[parentId] + if not parentNode then + parentNode = XInfestorExploreMapNode.New(parentId) + tree[parentId] = parentNode + end + + parentNode:SetChildId(nodeId) + end + end + end + + Maps[chapterId] = tree + + end + end + + local function UpdateFinishedNodesStatus(finishedGridDic) + if finishedGridDic then + for chapterId, finishedNodeIds in pairs(finishedGridDic) do + if next(finishedNodeIds) then + for _, nodeId in pairs(finishedNodeIds) do + local node = GetStageNode(chapterId, nodeId) + node:SetStatusPassed() + + --已走过的路径驱散子节点迷雾 + local childIds = node:GetChildIds() + for childId in pairs(childIds) do + local childNode = GetStageNode(chapterId, childId) + childNode:SetStatusUnReach() + end + end + end + end + end + + local chapterId = CurChapterId + local currentNode = GetStageNode(chapterId, CurNodeId) + currentNode:SetStatusCurrent() + + --最后一章判最后一关通关 + local nextChapterId = XFubenInfestorExploreConfigs.GetNextChapterId(chapterId) + if nextChapterId == 0 then + if currentNode:IsEnd() then + currentNode:SetStatusPassed() + end + end + + local childIds = currentNode:GetChildIds() + for childId in pairs(childIds) do + local childNode = GetStageNode(chapterId, childId) + childNode:SetStatusReach() + end + end + + local function OnGetMoneyTip(moneyCount, closeCallback) + if not moneyCount or moneyCount <= 0 then return end + local rewardGoodsList = {} + tableInsert(rewardGoodsList, XRewardManager.CreateRewardGoods(XDataCenter.ItemManager.ItemId.InfestorMoney, moneyCount)) + XUiManager.OpenUiObtain(rewardGoodsList, nil, closeCallback) + end + + local function OnGetNewCore(coreId, coreLevel, finishCb) + local core = GetCore(coreId) + local finishCbTemp = finishCb + if not core then + local coreData = { Id = coreId, Level = coreLevel } + AddCore(coreData) + XDataCenter.FubenInfestorExploreManager.OpenGetNewCoreUi(function() + XLuaUiManager.Open("UiInfestorExploreCoreObtain", coreId, coreLevel, finishCbTemp) + end) + else + if core:IsMaxLevel() then + local title = CSXTextManagerGetText("InfestorExploreCoreAutoDecomposeTitle") + local coreName = core:GetName() + local decomposeMoney = XFubenInfestorExploreConfigs.GetCoreDecomposeMoney(coreId, coreLevel) + local content = CSXTextManagerGetText("InfestorExploreCoreAutoDecomposeContent", coreName, decomposeMoney) + local sureCallBack = function() + OnGetMoneyTip(decomposeMoney, finishCbTemp) + end + local closeCallback = sureCallBack + XDataCenter.FubenInfestorExploreManager.OpenGetNewCoreUi(function() + XUiManager.DialogTip(title, content, XUiManager.DialogType.OnlySure, closeCallback, sureCallBack) + end) + else + local oldLevel = core:GetLevel() + local maxLevel = core:GetMaxLevel() + local newLevel = coreLevel + oldLevel + local coreIdTemp = coreId + newLevel = newLevel > maxLevel and maxLevel or newLevel + core:SetLevel(newLevel) + XDataCenter.FubenInfestorExploreManager.OpenGetNewCoreUi(function() + XLuaUiManager.Open("UiInfestorExploreCoreLevelUp", coreIdTemp, oldLevel, newLevel, finishCbTemp) + end) + end + end + XDataCenter.FubenInfestorExploreManager.AutoWearingOnceCore(coreId) + end + + local function OnNewEventTips(eventType, eventArgs) + if eventType == XFubenInfestorExploreConfigs.EventType.AddCore then + if not eventArgs then return end + local coreId = eventArgs[1] + local coreLevel = eventArgs[2] + OnGetNewCore(coreId, coreLevel) + else + if eventType == XFubenInfestorExploreConfigs.EventType.AddBuff then + if not eventArgs then return end + local buffId = eventArgs[1] + AddBuff(buffId) + elseif eventType == XFubenInfestorExploreConfigs.EventType.RemoveBuff then + local buffIds = eventArgs + if buffIds then + for _, buffId in pairs(buffIds) do + RemoveBuff(buffId) + end + end + elseif eventType == XFubenInfestorExploreConfigs.EventType.LostCore then + local coreId = eventArgs and eventArgs[1] + if IsHaveCore(coreId) then + DeleteCore(coreId) + end + elseif eventType == XFubenInfestorExploreConfigs.EventType.LevelUpCore then + local coreId = eventArgs and eventArgs[1] + local core = GetCore(coreId) + if core then + OnGetNewCore(coreId, 1) + end + end + end + end + + local function GetEventTipsContent(eventType, eventArgs) + return XFubenInfestorExploreConfigs.GetEventTypeTipContent(eventType, eventArgs) + end + + local function OnNotAddCoreEventTips(content) + if content and "" ~= content then + local title = CSXTextManagerGetText("InfestorExploreEventTypeTipTitle") + XUiManager.DialogTip(title, content, XUiManager.DialogType.OnlySure) + end + end + + local function MoveToNextChapter() + local curNode = GetStageNode(CurChapterId, CurNodeId) + if not curNode:IsEnd() then return end + curNode:SetStatusPassed() + + local nextChapterId = XFubenInfestorExploreConfigs.GetNextChapterId(CurChapterId) + if nextChapterId > 0 then + CurChapterId = nextChapterId + CurNodeId = OnGetMapStartNodeId(CurChapterId) + end + + UpdateFinishedNodesStatus() + + NewChapterNeedShowAnim = true + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_INFESTOREXPLORE_CHAPTER_FINISH) + end + + local function MoveToNextNode(oldNodeId, newNodeId) + local chapterId = CurChapterId + local playerId = XPlayer.Id + + local oldNode = GetStageNode(chapterId, CurNodeId) + oldNode:SetStatusPassed() + oldNode:ClearOccupiedPlayerId(playerId) + + local childIds = oldNode:GetChildIds() + for childId in pairs(childIds) do + local childNode = GetStageNode(chapterId, childId) + childNode:SetStatusUnReach() + end + + local newNode = GetStageNode(chapterId, newNodeId) + newNode:SetStatusCurrent() + newNode:SetOccupiedPlayerId(playerId) + + local childIds = newNode:GetChildIds() + for childId in pairs(childIds) do + local childNode = GetStageNode(chapterId, childId) + childNode:SetStatusReach() + end + + CurNodeId = newNodeId + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_INFESTOREXPLORE_MOVE_TO_NEXT_NODE) + + MoveToNextChapter() + end + + local function SetLastFinishNodeId(nodeId) + if not nodeId then return end + LastFinishNodeId = nodeId + end + + local function InsertChapterMessage(chapterId, playerMsgInfo) + local msgs = ChapterMsgDic[chapterId] or {} + ChapterMsgDic[chapterId] = msgs + + + local playerId = playerMsgInfo.Id + local player = GetPlayerData(playerId) + if not player then + player = XInfestorExplorePlayer.New() + PlayerDataDic[playerId] = player + end + player:UpdateData(playerMsgInfo) + + tableInsert(msgs, 1, playerMsgInfo) + + local msgNum = #msgs + if msgNum > MAX_CHAPTER_MESSAGE_COUNT then + tableRemove(msgs, msgNum) + end + end + -- -------------------(本地接口)end------------------ + -- -------------------(对外开放接口)begin------------------ + local XFubenInfestorExploreManager = {} + + function XFubenInfestorExploreManager.GetCurSectionName() + return XFubenInfestorExploreConfigs.GetSectionName(SectionStatus) + end + + function XFubenInfestorExploreManager.Reset() + XLuaUiManager.RunMain() + XUiManager.TipText("InfestorExploreReset") + end + + function XFubenInfestorExploreManager.IsOpen() + return SectionStatus ~= SectionType.Init + end + + function XFubenInfestorExploreManager.IsInSectionOne() + return SectionStatus == SectionType.StageExplore + end + + function XFubenInfestorExploreManager.IsInSectionTwo() + return SectionStatus == SectionType.BossFight + end + + function XFubenInfestorExploreManager.IsInSectionEnd() + return SectionStatus == SectionType.RESET + end + + function XFubenInfestorExploreManager.GetCurDiff() + return CurDiff + end + + function XFubenInfestorExploreManager.CheckNewDiff() + + if OldActivityNo and OldActivityNo == ActivityNo then + return + end + + --每期段位弹出一次并记录Cookie + XLuaUiManager.Open("UiInfestorExploreActivityResult", LastDiff, CurDiff) + OldActivityNo = ActivityNo + XSaveTool.SaveData(GetCookieKey(), ActivityNo) + end + + function XFubenInfestorExploreManager.GetDiffIcon(diff) + diff = diff or CurDiff + return XFubenInfestorExploreConfigs.GetDiffIcon(CurGroupId, diff) + end + + function XFubenInfestorExploreManager.GetDiffName(diff) + diff = diff or CurDiff + return XFubenInfestorExploreConfigs.GetDiffName(CurGroupId, diff) + end + + function XFubenInfestorExploreManager.GetDiffUpNum() + return XFubenInfestorExploreConfigs.GetDiffUpNum(CurGroupId, CurDiff) + end + + function XFubenInfestorExploreManager.GetDiffKeepNum() + return XFubenInfestorExploreConfigs.GetDiffKeepNum(CurGroupId, CurDiff) + end + + function XFubenInfestorExploreManager.GetDiffDownNum() + return XFubenInfestorExploreConfigs.GetDiffDownNum(CurGroupId, CurDiff) + end + + function XFubenInfestorExploreManager.GetDiffShowScoreGap() + return XFubenInfestorExploreConfigs.GetDiffShowScoreGap(CurGroupId, CurDiff) + end + + function XFubenInfestorExploreManager.GetDiffShowScoreLimit() + return XFubenInfestorExploreConfigs.GetDiffShowScoreLimit(CurGroupId, CurDiff) + end + + function XFubenInfestorExploreManager.IsChapterPassed(chapterId) + local nextChapterId = XFubenInfestorExploreConfigs.GetNextChapterId(chapterId) + if nextChapterId == 0 then + --最后一章判最后一关通关 + local nodeId = CurNodeId + return XFubenInfestorExploreManager.IsNodeEnd(chapterId, nodeId) and XFubenInfestorExploreManager.IsNodePassed(chapterId, nodeId) + end + return CurChapterId > chapterId + end + + function XFubenInfestorExploreManager.IsChapterUnlock(chapterId) + local preChapterId = XFubenInfestorExploreConfigs.GetPreChapterId(chapterId) + return not preChapterId or preChapterId == 0 or XFubenInfestorExploreManager.IsChapterPassed(preChapterId) + end + + function XFubenInfestorExploreManager.IsChapterRequireIsomer(chapterId) + local characterLimitType = XFubenInfestorExploreConfigs.GetChapterCharacterLimitType(chapterId) + local characterType = XDataCenter.FubenManager.GetDefaultCharacterTypeByCharacterLimitType(characterLimitType) + return characterType == XCharacterConfigs.CharacterType.Isomer + end + + function XFubenInfestorExploreManager.GetBuffDes() + local buffId + if XFubenInfestorExploreManager.IsInSectionOne() then + buffId = XFubenInfestorExploreConfigs.GetBuffId(FightEventId) + elseif XFubenInfestorExploreManager.IsInSectionTwo() then + buffId = XFubenInfestorExploreConfigs.GetBuffIdTwo(FightEventId) + end + local fightEventCfg = buffId and buffId ~= 0 and CS.XNpcManager.GetFightEventTemplate(buffId) + return fightEventCfg and fightEventCfg.Description or "" + end + + function XFubenInfestorExploreManager.GetActionPoint() + local itemId = XDataCenter.ItemManager.ItemId.InfestorActionPoint + return XDataCenter.ItemManager.GetCount(itemId) + end + + function XFubenInfestorExploreManager.CheckActionPointEnough(count) + local haveCount = XFubenInfestorExploreManager.GetActionPoint() + return haveCount >= count + end + + function XFubenInfestorExploreManager.IsActionPointEmpty() + local haveCount = XFubenInfestorExploreManager.GetActionPoint() + return haveCount <= 0 + end + + function XFubenInfestorExploreManager.GetCurGroupLevelBorder() + return XFubenInfestorExploreConfigs.GetGroupLevelBorder(CurGroupId) + end + + function XFubenInfestorExploreManager.GetCurGroupDiffConfigs() + return XFubenInfestorExploreConfigs.GetGroupDiffConfigs(CurGroupId) + end + + function XFubenInfestorExploreManager.GetCurGroupRankRegionDescText(diff, region) + return XFubenInfestorExploreConfigs.GetRankRegionDescText(CurGroupId, diff, region) + end + + function XFubenInfestorExploreManager.GetCurGroupRankRegionRewardList(diff, region) + diff = diff or CurDiff + local mailId = XFubenInfestorExploreConfigs.GetRankRegionMailId(CurGroupId, diff, region) + if not mailId or mailId == 0 then + return {} + end + return XDataCenter.MailManager.GetRewardList(mailId) + end + + function XFubenInfestorExploreManager.GetPlayerRankIndexList() --返回序号 + local indexList = {} + for index in pairs(PlayerRankDataList) do + indexList[index] = index + end + return indexList + end + + function XFubenInfestorExploreManager.GetPlayerRankData(rankIndex) --通过上面返回的序号,拿到对应的来拿取数据 + return PlayerRankDataList[rankIndex] + end + + function XFubenInfestorExploreManager.GetRankPlayerId(rankIndex) + local rankPlayerData = XFubenInfestorExploreManager.GetPlayerRankData(rankIndex) + return rankPlayerData and rankPlayerData:GetPlayerId() + end + + function XFubenInfestorExploreManager.IsChapterTeamEmpty(chapterId) + local team = GetChapterTeam(chapterId) + return team:IsEmpty() + end + + function XFubenInfestorExploreManager.IsChapterTeamNoCaptain(chapterId) + local team = GetChapterTeam(chapterId) + return not team:IsCaptainExist() + end + + function XFubenInfestorExploreManager.IsChapterTeamExist(chapterId) + -- local team = GetChapterTeam(chapterId) + -- return not team:IsEmpty() and team:IsSyned() + -- 起点类型任意编队 + return not XFubenInfestorExploreManager.IsNodeStart(chapterId, CurNodeId) + end + + function XFubenInfestorExploreManager.GetChapterTeamCharacterIds(chapterId) + local team = GetChapterTeam(chapterId) + return team:GetCharacterIds() + end + + function XFubenInfestorExploreManager.GetChapterTeamCaptainPos(chapterId) + local team = GetChapterTeam(chapterId) + return team:GetCaptainPos() + end + + function XFubenInfestorExploreManager.GetChapterTeamFirstFightPos(chapterId) + local team = GetChapterTeam(chapterId) + return team:GetFirstFightPos() + end + + function XFubenInfestorExploreManager.SaveChapterTeam(chapterId, characterIds, captainPos, firstFightPos) + local team = GetChapterTeam(chapterId) + + local oldCharacterIds = team:GetCharacterIds() + for _, characterId in pairs(oldCharacterIds) do + if characterId > 0 then + local characterData = GetCharacterData(characterId) + characterData:ClearTeamInfo() + end + end + + team:SetCharacterIds(characterIds) + team:SetCaptainPos(captainPos) + team:SetFirstFightPos(firstFightPos) + + local newCharacterIds = team:GetCharacterIds() + for teamPos, characterId in pairs(newCharacterIds) do + if characterId > 0 then + local characterData = GetCharacterData(characterId) + local isCaptain = captainPos == teamPos + local firstFight = firstFightPos == teamPos + characterData:SetTeamInfo(teamPos, isCaptain, firstFight) + end + end + end + + function XFubenInfestorExploreManager:SetTeamChangedFlag() + TeamChanged = true + end + + function XFubenInfestorExploreManager:IsTeamChanged() + return TeamChanged + end + + function XFubenInfestorExploreManager:ClearTeamChangedFlag() + TeamChanged = nil + end + + function XFubenInfestorExploreManager.GetCharacterHpPrecent(characterId) + local characterData = GetCharacterData(characterId) + return characterData:GetHpPercent() + end + + function XFubenInfestorExploreManager.RefreshCacheMoneyCount(newMoneyCount, oldMoneyCount) + OldMoneyCount = oldMoneyCount or NewMoneyCount + NewMoneyCount = newMoneyCount + end + + function XFubenInfestorExploreManager.GetOldMoneyCount() + return OldMoneyCount + end + + function XFubenInfestorExploreManager.GetMoneyIcon() + return XDataCenter.ItemManager.GetItemIcon(XDataCenter.ItemManager.ItemId.InfestorMoney) + end + + function XFubenInfestorExploreManager.GetMoneyCount() + return XDataCenter.ItemManager.GetCount(XDataCenter.ItemManager.ItemId.InfestorMoney) + end + + function XFubenInfestorExploreManager.GetMoneyName() + return XDataCenter.ItemManager.GetItemName(XDataCenter.ItemManager.ItemId.InfestorMoney) + end + + function XFubenInfestorExploreManager.CheckMoneyEnough(count) + local haveCount = XFubenInfestorExploreManager.GetMoneyCount() + return haveCount >= count + end + + function XFubenInfestorExploreManager.IsMoneyEmpty() + local haveCount = XFubenInfestorExploreManager.GetMoneyCount() + return haveCount <= 0 + end + + function XFubenInfestorExploreManager.GetMapNodeIds(chapterId) + return GetMap(chapterId) + end + + function XFubenInfestorExploreManager.GetNodePrefabPath(chapterId, nodeId) + local node = GetStageNode(chapterId, nodeId) + return node:GetPrefabPath() + end + + function XFubenInfestorExploreManager.GetNodeStageBg(chapterId, nodeId) + local node = GetStageNode(chapterId, nodeId) + return node:GetStageBg() + end + + function XFubenInfestorExploreManager.GetNodeTypeIcon(chapterId, nodeId) + local node = GetStageNode(chapterId, nodeId) + return node:GetTypeIcon() + end + + function XFubenInfestorExploreManager.GetNodeTypeDetailUiName(chapterId, nodeId) + local node = GetStageNode(chapterId, nodeId) + return node:GetNodeTypeUiName() + end + + function XFubenInfestorExploreManager.GetNodeEventPoolId(chapterId, nodeId) + local node = GetStageNode(chapterId, nodeId) + return node:GetEventPoolId() + end + + function XFubenInfestorExploreManager.GetNodeFightStageId(chapterId, nodeId) + local node = GetStageNode(chapterId, nodeId) + return node:GetFightStageId() + end + + function XFubenInfestorExploreManager.GetNodeShowRewardId(chapterId, nodeId) + local node = GetStageNode(chapterId, nodeId) + return node:GetShowRewardId() + end + + function XFubenInfestorExploreManager.GetSupplyNodeDesList(chapterId, nodeId) + local node = GetStageNode(chapterId, nodeId) + return node:GetSupplyDesList() + end + + function XFubenInfestorExploreManager.IsNodeCurrentShop(chapterId, nodeId) + local node = GetStageNode(chapterId, nodeId) + return node:IsShop() and node:IsCurrent() + end + + function XFubenInfestorExploreManager.IsNodeSelectEvent(chapterId, nodeId) + local node = GetStageNode(chapterId, nodeId) + return node:IsSelectEvent() + end + + function XFubenInfestorExploreManager.IsNodeAutoEvent(chapterId, nodeId) + local node = GetStageNode(chapterId, nodeId) + return node:IsAutoEvent() + end + + function XFubenInfestorExploreManager.IsNodeCurrent(chapterId, nodeId) + local node = GetStageNode(chapterId, nodeId) + return node:IsCurrent() + end + + function XFubenInfestorExploreManager.IsNodeFinished(nodeId) + return LastFinishNodeId == nodeId + end + + function XFubenInfestorExploreManager.IsNodeCurrentFinished(chapterId, nodeId) + return XFubenInfestorExploreManager.IsNodeCurrent(chapterId, nodeId) and XFubenInfestorExploreManager.IsNodeFinished(nodeId) + end + + function XFubenInfestorExploreManager.IsNodeReach(chapterId, nodeId) + local node = GetStageNode(chapterId, nodeId) + return node:IsReach() + end + + function XFubenInfestorExploreManager.IsNodeUnReach(chapterId, nodeId) + local node = GetStageNode(chapterId, nodeId) + return node:IsUnReach() + end + + function XFubenInfestorExploreManager.IsNodePassed(chapterId, nodeId) + local node = GetStageNode(chapterId, nodeId) + return node:IsPassed() + end + + function XFubenInfestorExploreManager.IsNodeFog(chapterId, nodeId) + local node = GetStageNode(chapterId, nodeId) + return node:IsFog() + end + + function XFubenInfestorExploreManager.IsNodeCurrent(chapterId, nodeId) + local node = GetStageNode(chapterId, nodeId) + return node:IsCurrent() + end + + function XFubenInfestorExploreManager.IsNodeStart(chapterId, nodeId) + local node = GetStageNode(chapterId, nodeId) + return node:IsStart() + end + + function XFubenInfestorExploreManager.IsNodeEnd(chapterId, nodeId) + local node = GetStageNode(chapterId, nodeId) + return node:IsEnd() + end + + --如果同一个节点有多个玩家,只显示一个(优先显示自己) + function XFubenInfestorExploreManager.GetNodeShowOccupiedPlayerId(chapterId, nodeId) + local showPlayerId = 0 + + local node = GetStageNode(chapterId, nodeId) + local playerIds = node:GetOccupiedPlayerIds() + for _, playerId in pairs(playerIds) do + showPlayerId = playerId + if playerId == XPlayer.Id then + break + end + end + + return showPlayerId + end + + function XFubenInfestorExploreManager.CheckActionPoint(chapterId, nodeId) + local node = GetStageNode(chapterId, nodeId) + local useActionPoint = node:GetUseActionPoint() + return XFubenInfestorExploreManager.CheckActionPointEnough(useActionPoint) + end + + function XFubenInfestorExploreManager.GetBuffIds() + return BuffIds + end + + local Default_Core_Sort = function(aId, bId) + local aQuality = XFubenInfestorExploreConfigs.GetCoreQuality(aId) + local bQuality = XFubenInfestorExploreConfigs.GetCoreQuality(bId) + if aQuality ~= bQuality then + return aQuality > bQuality + end + + local aLevel = XFubenInfestorExploreManager.GetCoreLevel(aId) + local bLevel = XFubenInfestorExploreManager.GetCoreLevel(bId) + if aLevel ~= bLevel then + return aLevel > bLevel + end + end + + function XFubenInfestorExploreManager.GetCoreIds() + local coreIds = {} + + for _, coreId in pairs(CoreIdList) do + if not XFubenInfestorExploreManager.IsCoreWearing(coreId) then + tableInsert(coreIds, coreId) + end + end + tableSort(coreIds, Default_Core_Sort) + + return coreIds + end + + function XFubenInfestorExploreManager.IsHaveOnceCore() + return next(CoreIdList) and true or false + end + + function XFubenInfestorExploreManager.GetWearingCoreIdDic() + return XTool.Clone(CoreUseIdDic) + end + + function XFubenInfestorExploreManager.GetWearingCoreId(pos) + return CoreUseIdDic[pos] or 0 + end + + function XFubenInfestorExploreManager.GetOnceNotWearingPos() + for pos = 1, XFubenInfestorExploreConfigs.MaxWearingCoreNum do + if XFubenInfestorExploreManager.GetWearingCoreId(pos) == 0 then + return pos + end + end + return 0 + end + + function XFubenInfestorExploreManager.AutoWearingOnceCore(coreId) + if XFubenInfestorExploreManager.IsCoreWearing(coreId) then return end + + local pos = XFubenInfestorExploreManager.GetOnceNotWearingPos() + if pos > 0 then + XDataCenter.FubenInfestorExploreManager.RequestInfestorExplorePutOnCore(coreId, pos) + end + end + + function XFubenInfestorExploreManager.IsCoreWearing(coreId) + local core = GetCore(coreId) + return core:IsWearing() + end + + function XFubenInfestorExploreManager.GetCoreLevel(coreId) + local core = GetCore(coreId) + return core:GetLevel() + end + + function XFubenInfestorExploreManager.GetCoreDecomposeMoney(coreIds) + local totalMoney = 0 + + for _, coreId in pairs(coreIds) do + local core = GetCore(coreId) + totalMoney = totalMoney + core:GetDecomposeMoney() + end + + return totalMoney + end + + function XFubenInfestorExploreManager.GetRandomSupplyRewardDesList(num) + local desList = {} + + num = num or 0 + local retNum = 0 + local retCheckDic = {} + local totalDesNum = XFubenInfestorExploreConfigs.GetSupplyRewardDesTotalNum() + math.randomseed(os.time()) + + while true do + if retNum >= num then + break + end + + local ret = math.random(totalDesNum) + if not retCheckDic[ret] then + retCheckDic[ret] = ret + retNum = retNum + 1 + tableInsert(desList, XFubenInfestorExploreConfigs.GetSupplyRewardDes(ret)) + end + end + + return desList + end + + function XFubenInfestorExploreManager.GetOutPostNodeStartDes(chapterId, nodeId) + local outPostStory = GetNodeOutPostStory(chapterId, nodeId) + return outPostStory:GetStartDes() + end + + function XFubenInfestorExploreManager.GetOutPostOption1Txt(chapterId, nodeId) + local outPostStory = GetNodeOutPostStory(chapterId, nodeId) + return outPostStory:GetOption1Txt() + end + + function XFubenInfestorExploreManager.GetOutPostOption2Txt(chapterId, nodeId) + local outPostStory = GetNodeOutPostStory(chapterId, nodeId) + return outPostStory:GetOption2Txt() + end + + function XFubenInfestorExploreManager.GetOutPostNodeMyTurnDes(chapterId, nodeId, option, characterName) + local outPostStory = GetNodeOutPostStory(chapterId, nodeId) + return outPostStory:GetMyTurnDes(option, characterName) + end + + function XFubenInfestorExploreManager.GetOutPostNodeHisTurnDes(chapterId, nodeId, option, isHurt, characterName, hp) + local outPostStory = GetNodeOutPostStory(chapterId, nodeId) + return outPostStory:GetHisTurnDes(option, isHurt, characterName, hp) + end + + function XFubenInfestorExploreManager.GetOutPostNodeEndDes(chapterId, nodeId, characterName, hp) + local outPostStory = GetNodeOutPostStory(chapterId, nodeId) + return outPostStory:GetEndDes(characterName, hp) + end + + function XFubenInfestorExploreManager.CheckShopExist() + -- local shop = GetShop() + -- return shop and next(shop) and true or false + return false + end + + function XFubenInfestorExploreManager.CheckNewChapterNeedShowAnim() + return NewChapterNeedShowAnim + end + + function XFubenInfestorExploreManager.ClearNewChapterNeedShowAnim() + NewChapterNeedShowAnim = nil + end + + function XFubenInfestorExploreManager.GetGoodsIds() + local goodsIds = {} + local goodsRecordDic = GetShop().GoodsRecordDic + for goodsId in pairs(goodsRecordDic) do + tableInsert(goodsIds, goodsId) + end + return goodsIds + end + + function XFubenInfestorExploreManager.GetShopRefreshCost() + local shopId = GetShop().ShopId + return XFubenInfestorExploreConfigs.GetShopRefreshCost(shopId) + end + + function XFubenInfestorExploreManager.IsGoodsSellOut(goodsId) + local limitCount = XFubenInfestorExploreConfigs.GetGoodsLimitCount(goodsId) + + + if limitCount == 0 then + return false + end + + local goodsRecordDic = GetShop().GoodsRecordDic + local buyCount = goodsRecordDic[goodsId] + return buyCount and buyCount >= limitCount + end + + local DEFAULT_PLAYER_NAME = CSXTextManagerGetText("InfestorExploreRewardNodeDefaultPlayerName") + function XFubenInfestorExploreManager.GetSelectRewardPlayerName(chapterId, nodeId) + local player = GetSelectRewardPlayerData(chapterId, nodeId) + if not player then + return DEFAULT_PLAYER_NAME + end + return player:GetName() + end + + local DEFAULT_MESSAGE = CSXTextManagerGetText("InfestorExploreRewardNodeDefaultMessage") + function XFubenInfestorExploreManager.GetSelectRewardMessage(chapterId, nodeId) + local selectRewardInfo = GetSelectRewardInfo(chapterId, nodeId) + if not selectRewardInfo then + return DEFAULT_MESSAGE + end + + local player = GetSelectRewardPlayerData(chapterId, nodeId) + local msg = selectRewardInfo.Message + if string.IsNilOrEmpty(msg) then + return player:GetSign() + end + + return msg + end + + function XFubenInfestorExploreManager.GetSelectRewardPlayerHeadId(chapterId, nodeId) + local player = GetSelectRewardPlayerData(chapterId, nodeId) + if not player then + return + end + return player:GetHeadPortraitId() + end + + function XFubenInfestorExploreManager.GetSelectRewardPlayerHeadFrameId(chapterId, nodeId) + local player = GetSelectRewardPlayerData(chapterId, nodeId) + if not player then + return + end + return player:GetHeadFrameId() + end + + function XFubenInfestorExploreManager.GetSelectRewardPlayerHeadIcon(chapterId, nodeId) + local player = GetSelectRewardPlayerData(chapterId, nodeId) + if not player then + return + end + return player:GetHeadIcon() + end + + function XFubenInfestorExploreManager.GetSelectRewardPlayerHeadEffectPath(chapterId, nodeId) + local player = GetSelectRewardPlayerData(chapterId, nodeId) + if not player then + return + end + return player:GetHeadEffectPath() + end + + function XFubenInfestorExploreManager.GetSelectRewardPlayerHeadFrame(chapterId, nodeId) + local player = GetSelectRewardPlayerData(chapterId, nodeId) + if not player then + return + end + return player:GetHeadFrame() + end + + function XFubenInfestorExploreManager.GetSelectRewardPlayerHeadFrameEffectPath(chapterId, nodeId) + local player = GetSelectRewardPlayerData(chapterId, nodeId) + if not player then + return + end + return player:GetHeadFrameEffectPath() + end + + function XFubenInfestorExploreManager.IsLastPlayerSelectReward(chapterId, nodeId, rewardId) + local selectRewardInfo = GetSelectRewardInfo(chapterId, nodeId) + if not selectRewardInfo then + return false + end + return selectRewardInfo.RewardId == rewardId + end + + function XFubenInfestorExploreManager.GetShopEventIds() + local shopEventIds = {} + + for eventId in pairs(ContractEventIdDic) do + tableInsert(shopEventIds, eventId) + end + + return shopEventIds + end + + function XFubenInfestorExploreManager.IsShopEventSellOut() + for _, value in pairs(ContractEventIdDic) do + if value == true then + return true + end + end + return false + end + + function XFubenInfestorExploreManager.ClearFightRewards() + FightRewardBuyDic = {} + AfterFightNeedShowReward = nil + + --最后一关BOSS打完之后未翻牌,重登翻牌之后需要手动检查是否通关章节 + MoveToNextChapter() + end + + function XFubenInfestorExploreManager.IsFightRewadsExist() + + return next(FightRewardBuyDic) and true or false + end + + function XFubenInfestorExploreManager.GetFightRewardIds() + local rewardIds = {} + for rewardId, isBuy in pairs(FightRewardBuyDic) do + tableInsert(rewardIds, rewardId) + end + return rewardIds + end + + function XFubenInfestorExploreManager.IsFightRewadBuy(rewardId) + return FightRewardBuyDic[rewardId] + end + + function XFubenInfestorExploreManager.GetFightRewadBuyTimes() + local times = 0 + for rewardId, isBuy in pairs(FightRewardBuyDic) do + if isBuy then + times = times + 1 + end + end + return times + end + + function XFubenInfestorExploreManager.GetAllChapterMsgs(chapterId) + return ChapterMsgDic[chapterId] or {} + end + + function XFubenInfestorExploreManager.GetChapterPlayerMsg(chapterId, msgId) + local msgs = ChapterMsgDic[chapterId] + return msgs and msgs[msgId] or "" + end + + function XFubenInfestorExploreManager.GetPlayerScore(playerId) + local player = GetPlayerData(playerId) + if not player then + return 0 + end + return player:GetScore() + end + + function XFubenInfestorExploreManager.GetPlayerHeadIcon(playerId) + local player = GetPlayerData(playerId) + if not player then + return + end + return player:GetHeadIcon() + end + + function XFubenInfestorExploreManager.GetPlayerHeadEffectPath(playerId) + local player = GetPlayerData(playerId) + if not player then + return + end + return player:GetHeadEffectPath() + end + + function XFubenInfestorExploreManager.GetPlayerHeadFrame(playerId) + local player = GetPlayerData(playerId) + if not player then + return + end + return player:GetHeadFrame() + end + + function XFubenInfestorExploreManager.GetPlayerHeadFrameEffectPath(playerId) + local player = GetPlayerData(playerId) + if not player then + return + end + return player:GetHeadFrameEffectPath() + end + + function XFubenInfestorExploreManager.GetPlayerName(playerId) + local player = GetPlayerData(playerId) + if not player then + return + end + return player:GetName() + end + + function XFubenInfestorExploreManager.GetPlayerLevel(playerId) + local player = GetPlayerData(playerId) + if not player then + return + end + return player:GetLevel() + end + + function XFubenInfestorExploreManager.GetPlayerDiffName(playerId) + local player = GetPlayerData(playerId) + if not player then + return + end + return player:GetDiffName() + end + + function XFubenInfestorExploreManager.GetPlayerDiffIcon(playerId) + local player = GetPlayerData(playerId) + if not player then + return + end + return player:GetDiffIcon() + end + + function XFubenInfestorExploreManager.GetPlayerHeadId(playerId) + local player = GetPlayerData(playerId) + if not player then + return + end + return player:GetHeadPortraitId() + end + + function XFubenInfestorExploreManager.GetPlayerHeadFrameId(playerId) + local player = GetPlayerData(playerId) + if not player then + return + end + return player:GetHeadFrameId() + end + + function XFubenInfestorExploreManager.GetChapter2StageScore(stageId) + return Chapter2ScoreDic[stageId] or 0 + end + + function XFubenInfestorExploreManager.GetChapter2TotalScore() + local totalScore = 0 + if Chapter2ScoreDic then + for _, score in pairs(Chapter2ScoreDic) do + totalScore = totalScore + score + end + end + return totalScore + end + + function XFubenInfestorExploreManager.GetChapter2StageIds() + return XFubenInfestorExploreConfigs.GetChapter2StageIds(ActivityId) + end + + function XFubenInfestorExploreManager.SetOpenInfestorExploreCoreDelay(openInfestorExploreCoreDelay) + OpenInfestorExploreCoreDelay = openInfestorExploreCoreDelay + end + + function XFubenInfestorExploreManager.GetOpenInfestorExploreCoreDelay() + return OpenInfestorExploreCoreDelay + end + + function XFubenInfestorExploreManager.OpenGetNewCoreUi(cb) + if not cb and not OpenInfestorExploreCoreCbTemp then return end + + if OpenInfestorExploreCoreScheduleId then + XScheduleManager.UnSchedule(OpenInfestorExploreCoreScheduleId) + end + + if cb then + OpenInfestorExploreCoreCbTemp = cb + end + local openInfestorExploreCoreCb = cb or OpenInfestorExploreCoreCbTemp + local scheduleCallback = function() + openInfestorExploreCoreCb() + XDataCenter.FubenInfestorExploreManager.SetOpenInfestorExploreCoreDelay(0) + OpenInfestorExploreCoreCbTemp = nil + OpenInfestorExploreCoreScheduleId = nil + end + local delayTime = XDataCenter.FubenInfestorExploreManager.GetOpenInfestorExploreCoreDelay() + OpenInfestorExploreCoreScheduleId = XScheduleManager.ScheduleOnce(scheduleCallback, delayTime) + end + + + local function UpdateSectionData(status, nextResetTime) --更新现在出于什么时间段,更新这个时间段的的剩余时间 + SectionStatus = status + local leftTime = nextResetTime - XTime.GetServerNowTimestamp() + + XCountDown.CreateTimer(XCountDown.GTimerName.FubenInfestorExplore, leftTime) + end + + local function CreateCenterFog(chapterId, centerNodeId, fogDepth) + local centerNode = GetStageNode(chapterId, centerNodeId) + centerNode:SetStatusFog() + + if fogDepth == 0 then + return + end + + fogDepth = fogDepth - 1 + + local childIds = centerNode:GetChildIds() + for childId in pairs(childIds) do + CreateCenterFog(chapterId, childId, fogDepth) + end + + local parentIds = centerNode:GetParentIds() + for parentId in pairs(parentIds) do + CreateCenterFog(chapterId, parentId, fogDepth) + end + end + + local FogCenterNodeIds = {} + local function UpdateStagesInfo(mapList) + if not mapList then return end + + InitMaps() + + for _, map in pairs(mapList) do + local chapterId = map.ChapterId + local stageDataList = map.GridList + for _, stageData in pairs(stageDataList) do + local nodeId = stageData.Id + local node = GetStageNode(chapterId, nodeId) + if not node then + local mapId = XFubenInfestorExploreConfigs.GetMapId(chapterId) + XLog.Error("XFubenInfestorExploreManager UpdateStagesInfo error:关卡地图中不存在节点, chapterId: " .. chapterId .. ", nodeId: " .. nodeId .. ", mapId: " .. mapId) + end + + local stageId = stageData.NodeId + node:SetStageId(stageId) + end + + --必须等待所有节点更新完毕后再生成迷雾 + for _, stageData in pairs(stageDataList) do + local nodeId = stageData.Id + local stageId = stageData.NodeId + local nodeResType = XFubenInfestorExploreConfigs.GetNodeResType(stageId) + local fogDepth = XFubenInfestorExploreConfigs.GetFogDepth(nodeResType) + + if fogDepth ~= 0 then + CreateCenterFog(chapterId, nodeId, fogDepth) + tableInsert(FogCenterNodeIds, nodeId) + end + end + + --迷雾全部生成完毕后还原各中心点初始状态 + for _, centerNodeId in pairs(FogCenterNodeIds) do + local centerNode = GetStageNode(chapterId, centerNodeId) + centerNode:SetStatusUnReach() + end + FogCenterNodeIds = {} + end + end + + local function ResetData() + FightRewardBuyDic = {} + CharacterDataDic = {} + LastSyncInfoTime = 0 + LastLeaveChapterMsgTime = 0 + LastGetLeaveChapterMsgTime = 0 + ChapterMsgDic = {} + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_INFESTOREXPLORE_RESET) + end + + local function UpdateChapterData(data) + CurChapterId = data.CurrentChapterId + CurNodeId = data.CurrentGridId + CurGroupId = data.GroupId + FightEventId = data.FightEventId + ActivityId = data.ActivityId + end + + local function UpdateDiff(data) + CurDiff = data.Diff + LastDiff = data.LastDiff + ActivityNo = data.ActivityNo + OldActivityNo = XSaveTool.GetData(GetCookieKey()) + end + + local function UpdateChapter2Data(bossFightScoreInfoList) + if not bossFightScoreInfoList then return end + Chapter2ScoreDic = {} + + for _, info in pairs(bossFightScoreInfoList) do + local stageId = info.StageId + local score = info.Score + Chapter2ScoreDic[stageId] = score + end + end + + local function UpdateBuffData(buffList) + BuffIds = buffList + end + + local function UpdateCharacterData(characterInfoList) + if not characterInfoList then return end + + for _, info in pairs(characterInfoList) do + local characterId = info.CharacterId + local characterData = GetCharacterData(characterId) + characterData:UpdateData(info) + CharacterDataDic[characterId] = characterData + end + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_INFESTOREXPLORE_CHARACTER_HP_CHANGE) + end + + local function UpdateCoreData(coreInfo) + if not coreInfo then return end + + CoreDic = {} + CoreIdList = {} + CoreUseIdDic = {} + local coreDataList = coreInfo.CoreList + for _, coreData in pairs(coreDataList) do + AddCore(coreData) + end + + local useDic = coreInfo.UseList + for pos = 1, XFubenInfestorExploreConfigs.MaxWearingCoreNum do + local coreId = useDic[pos] + if coreId and coreId > 0 then + local core = GetCore(coreId) + if not core then + XLog.Error("XFubenInfestorExploreManager UpdateCoreData Error:穿戴中的核心未拥有, coreId: " .. coreId) + else + PutOnCore(coreId, pos) + end + else + TakeOffCore(pos) + end + end + end + + local function UpdateShopData(shopData) + if not shopData then return end + + local shop = {} + shop.ShopId = shopData.Id + + local goodsRecordDic = {} + local shopInfoList = shopData.GoodsList + for _, shopInfo in pairs(shopInfoList) do + local id = shopInfo.Id + local buyCount = shopInfo.BuyCount + goodsRecordDic[id] = buyCount + end + shop.GoodsRecordDic = goodsRecordDic + + ChapterIdToShopDic[CurChapterId] = shop + end + + local function UpdateTeamData(teamType, teamdata) + if not teamdata then return end + + local captainPos = 1 + local firstFightPos + + local characterIds = { 0, 0, 0 } + for _, characterId in pairs(teamdata) do + local characterData = GetCharacterData(characterId) + local teamPos = characterData:GetTeamPos() + characterIds[teamPos] = characterId + if characterData:IsMeCaptain() then + captainPos = teamPos + end + if characterData:IsMeFirstFight() then + firstFightPos = teamPos + end + end + + -- 服务器没有首发位数据就和队长位一致 + if firstFightPos == nil then + firstFightPos = captainPos + end + + local team = GetTeam(teamType) + team:SetCaptainPos(captainPos) + team:SetFirstFightPos(firstFightPos) + team:SetCharacterIds(characterIds) + if not team:IsEmpty() then + team:Syn() + end + end + + local function UpdateTeamInfoList(teamInfoList) + if not teamInfoList then return end + + for _, teamInfo in pairs(teamInfoList) do + local teamType = teamInfo.CharacterLimitType + local teamData = teamInfo.CharacterList + UpdateTeamData(teamType, teamData) + end + end + + local PLAYER_RANK_SORT = function(aPlayer, bPlayer) + local aScore = aPlayer:GetScore() + local bScore = bPlayer:GetScore() + if aScore ~= bScore then + return aScore > bScore + end + + local aChapterId = aPlayer:GetChapterId() + local bChapterId = bPlayer:GetChapterId() + if aChapterId ~= bChapterId then + return aChapterId > bChapterId + end + + local aGridId = aPlayer:GetGridId() + local bGridId = bPlayer:GetGridId() + if aGridId ~= bGridId then + return aGridId > bGridId + end + end + + local function UpdatePlayerRank(infestorPlayerList) + PlayerRankDataList = {} + + for index, playerData in pairs(infestorPlayerList) do + local playerId = playerData.Id + + local player = GetPlayerData(playerId) + if player then + --清除小队成员之前所在的格子位置 + local chapterId = player:GetChapterId() + local nodeId = player:GetGridId() + if chapterId > 0 and nodeId > 0 then + local node = GetStageNode(chapterId, nodeId) + node:ClearOccupiedPlayerId(playerId) + end + else + player = XInfestorExplorePlayer.New() + end + + player:UpdateData(playerData) + PlayerDataDic[playerId] = player + PlayerRankDataList[index] = player + + --记录小队成员所在的格子位置 + local chapterId = player:GetChapterId() + local nodeId = player:GetGridId() + if chapterId > 0 and nodeId > 0 then + local node = GetStageNode(chapterId, nodeId) + node:SetOccupiedPlayerId(playerId) + end + end + tableSort(PlayerRankDataList, PLAYER_RANK_SORT) + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_INFESTOREXPLORE_REFRESH_PALYER_RANK) + end + + local function UpdateSelectRewardInfoList(selectRewardInfoList) + if not selectRewardInfoList then return end + + SelectRewardInfoDic = {} + for _, rewardInfo in pairs(selectRewardInfoList) do + local chapterId = rewardInfo.ChapterId + local chapterDic = SelectRewardInfoDic[chapterId] or {} + SelectRewardInfoDic[chapterId] = chapterDic + + local nodeId = rewardInfo.GridId + local nodeDic = chapterDic[nodeId] or {} + chapterDic[nodeId] = nodeDic + + nodeDic.RewardId = rewardInfo.RewardId + nodeDic.PlayerId = rewardInfo.PlayerId + nodeDic.Message = rewardInfo.Msg + end + end + + local function UpdateContractInfo(contractInfo, nextResetTime) + if not contractInfo then return end + ContractEventIdDic = {} + + local goodsIdList = contractInfo.GoodsIdList + if goodsIdList then + for _, eventId in pairs(goodsIdList) do + ContractEventIdDic[eventId] = false + end + end + + local buyGoodsId = contractInfo.BuyGoodsId + if buyGoodsId and buyGoodsId > 0 then + if ContractEventIdDic[buyGoodsId] == false then + ContractEventIdDic[buyGoodsId] = true + end + end + + nextResetTime = nextResetTime or XTime.GetSeverNextRefreshTime() + local nowTime = XTime.GetServerNowTimestamp() + local leftTime = nextResetTime - nowTime + + + XCountDown.CreateTimer(XCountDown.GTimerName.FubenInfestorExploreDaily, leftTime) + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_INFESTOREXPLORE_CONTRACT_DAILY_RESET) + end + + local function UpdateFightRewards(fightRewardInfoList) + if not fightRewardInfoList then return end + FightRewardBuyDic = {} + + for _, fightRewardInfo in pairs(fightRewardInfoList) do + local rewardId = fightRewardInfo.RewardId + local isBuy = fightRewardInfo.IsBuy + FightRewardBuyDic[rewardId] = isBuy + end + end + + local function UpdateChapterLeaveMsg(chapterId, msgList) + if not chapterId or not msgList then return end + ChapterMsgDic[chapterId] = {} + + for _, playerMsgInfo in pairs(msgList) do + InsertChapterMessage(chapterId, playerMsgInfo) + end + end + + function XFubenInfestorExploreManager.OpenEntranceUi(openCb) + local now = XTime.GetServerNowTimestamp() + if LastSyncInfoTime + REQUEST_SYNC_INFO_CD >= now then + openCb() + else + XDataCenter.FubenInfestorExploreManager.RequestInfo(function() + openCb() + end) + end + end + + function XFubenInfestorExploreManager.RequestInfo(callBack) + local now = XTime.GetServerNowTimestamp() + if LastSyncInfoTime + REQUEST_SYNC_INFO_CD >= now then + return + end + LastSyncInfoTime = now + + XNetwork.Call("InfestorExploreGetInfoRequest", nil, function(res) + + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local data = res.InfestorInfo + UpdateCharacterData(data.CharacterList) + UpdateTeamInfoList(data.TeamInfoList) + UpdateChapterData(data) + UpdateDiff(data) + UpdateChapter2Data(data.BossFightScoreInfoList) + UpdateFinishedNodesStatus(data.FinishGridDict) + UpdateBuffData(data.BuffList) + UpdateCoreData(data.CoreInfo) + UpdatePlayerRank(data.InfestorPlayerList) + UpdateSelectRewardInfoList(data.SelectRewardInfoList) + UpdateContractInfo(data.EventShopInfo) + SetLastFinishNodeId(data.LastFinishGridId) + + if callBack then callBack() end + end) + end + + function XFubenInfestorExploreManager.RequestShopInfo(nodeId, callBack) + if XFubenInfestorExploreManager.CheckShopExist() then + return + end + + local req = { GridId = nodeId } + XNetwork.Call("InfestorExploreGetShopRequest", req, function(res) + + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local shop = res.Shop + UpdateShopData(shop) + + MoveToNextNode(CurNodeId, nodeId) + + if callBack then callBack() end + end) + end + + function XFubenInfestorExploreManager.RequestBuyGoods(goodsId, callBack) + local req = { GoodsId = goodsId } + XNetwork.Call("InfestorExploreBuyGoodsRequest", req, function(res) + + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local coreData = res.Core + if coreData and coreData.Id then + OnGetNewCore(coreData.Id, coreData.Level) + end + + local goodsRecordDic = GetShop().GoodsRecordDic + local buyCount = goodsRecordDic[goodsId] + goodsRecordDic[goodsId] = buyCount + 1 + + if callBack then callBack() end + end) + end + + function XFubenInfestorExploreManager.RequestRefreshShop(callBack) + XNetwork.Call("InfestorExploreRefreshShopRequest", nil, function(res) + + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local shop = res.Shop + UpdateShopData(shop) + + if callBack then callBack() end + end) + end + + function XFubenInfestorExploreManager.RequestGetSelectReward(nodeId, rewardCallBack) + local req = { GridId = nodeId } + XNetwork.Call("InfestorExploreGetSelectRewardRequest", req, function(res) + + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local selectRewardFunc = function() + local selectRewardIdList = res.SelectRewardIdList + if selectRewardIdList and next(selectRewardIdList) then + rewardCallBack(selectRewardIdList) + end + end + + local rewardCore = res.RewardCore + if rewardCore and rewardCore.Id then + OnGetNewCore(rewardCore.Id, rewardCore.Level, selectRewardFunc) + else + selectRewardFunc() + end + + MoveToNextNode(CurNodeId, nodeId) + end) + end + + function XFubenInfestorExploreManager.RequestSetSelectReward(rewardId, msg, callBack) + local req = { RewardId = rewardId, Msg = msg } + XNetwork.Call("InfestorExploreSetSelectRewardRequest", req, function(res) + + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + SetLastFinishNodeId(CurNodeId) + + if callBack then callBack() end + end) + end + + function XFubenInfestorExploreManager.RequestSupply(chapterId, nodeId, callBack) + local req = { ChapterId = chapterId, GridId = nodeId } + + XNetwork.Call("InfestorExploreSupplyRequest", req, function(res) + + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local coreList = res.CoreRewardList + local index = 1 + local finishCb + finishCb = function() + index = index + 1 + local nextCoreData = coreList[index] + if not nextCoreData then return end + OnGetNewCore(nextCoreData.CoreId, nextCoreData.CoreLevel, finishCb) + end + local coreData = coreList[index] + OnGetNewCore(coreData.CoreId, coreData.CoreLevel, finishCb) + + MoveToNextNode(CurNodeId, nodeId) + SetLastFinishNodeId(CurNodeId) + + if callBack then callBack() end + end) + end + + function XFubenInfestorExploreManager.RequestUpdateTeam(chapterId, callBack) + local req = {} + local team = GetChapterTeam(chapterId) + req.Team = team:GetCharacterIds() + req.CaptainPos = team:GetCaptainPos() + req.FirstFightPos = team:GetFirstFightPos() + + XNetwork.Call("InfestorExploreUpdateTeamRequest", req, function(res) + + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + team:Syn() + + if callBack then callBack() end + end) + end + + function XFubenInfestorExploreManager.RequestRest(chapterId, nodeId, callBack) + local req = {} + req.ChapterId = chapterId + req.GridId = nodeId + local team = GetChapterTeam(chapterId) + req.Team = team:GetCharacterIds() + req.CaptainPos = team:GetCaptainPos() + req.FirstFightPos = team:GetFirstFightPos() + + XNetwork.Call("InfestorExploreRestRequest", req, function(res) + + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + MoveToNextNode(CurNodeId, nodeId) + SetLastFinishNodeId(CurNodeId) + + if callBack then callBack() end + end) + end + + function XFubenInfestorExploreManager.RequestBuyEventGoods(goodsId, callBack) + local req = { GoodsId = goodsId } + XNetwork.Call("InfestorBuyEventGoodsRequest", req, function(res) + + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local eventType = res.EventType + local eventArgs = res.EventArgs + if eventType ~= XFubenInfestorExploreConfigs.EventType.AddCore then + local content = GetEventTipsContent(eventType, eventArgs) + OnNotAddCoreEventTips(content) + end + OnNewEventTips(eventType, eventArgs) + + ContractEventIdDic[goodsId] = true + + if callBack then callBack() end + end) + end + + function XFubenInfestorExploreManager.RequestInfestorExploreBuyFightReward(rewardId, callBack) + local req = { RewardId = rewardId } + XNetwork.Call("InfestorExploreBuyFlopRewardRequest", req, function(res) + + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + FightRewardBuyDic[rewardId] = true + + local coreId = XFubenInfestorExploreConfigs.GetRewardCoreId(rewardId) + local coreLevel = XFubenInfestorExploreConfigs.GetRewardCoreLevel(rewardId) + OnGetNewCore(coreId, coreLevel) + + if callBack then callBack() end + end) + end + + function XFubenInfestorExploreManager.RequestFinishAction(callBack) + XNetwork.Call("InfestorExploreFinishActionRequest", nil, function(res) + + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + SetLastFinishNodeId(CurNodeId) + + if callBack then callBack() end + end) + end + + function XFubenInfestorExploreManager.RequestInfestorExplorePutOnCore(coreId, pos, callBack) + local req = { CoreId = coreId, Index = pos } + + XNetwork.Call("InfestorExploreUseCoreRequest", req, function(res) + + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + PutOnCore(coreId, pos) + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_INFESTOREXPLORE_CORE_PUTON, pos) + + if callBack then callBack() end + end) + end + + function XFubenInfestorExploreManager.RequestInfestorExploreTakeOffCore(pos, callBack) + local req = { Index = pos } + + XNetwork.Call("InfestorExploreTakeOffCoreRequest", req, function(res) + + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + TakeOffCore(pos) + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_INFESTOREXPLORE_CORE_TAKEOFF) + + if callBack then callBack() end + end) + end + + function XFubenInfestorExploreManager.RequestInfestorExploreDecomposeCore(coreIds, callBack) + local req = { CoreList = coreIds } + + XNetwork.Call("InfestorExploreDecomposeCoreRequest", req, function(res) + + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local moneyCount = XFubenInfestorExploreManager.GetCoreDecomposeMoney(coreIds) + OnGetMoneyTip(moneyCount) + + for _, coreId in pairs(coreIds) do + DeleteCore(coreId) + end + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_INFESTOREXPLORE_CORE_DECOMPOESE) + + if callBack then callBack() end + end) + end + + function XFubenInfestorExploreManager.RequestInfestorExploreSelectEvent(nodeId, eventIds, callBack) + local req = { GridId = nodeId, EventIdList = eventIds } + + + XNetwork.Call("InfestorExploreSelectEventRequest", req, function(res) + + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local eventResultList = res.EventResultList + local tipsContent = "" + for _, eventResult in pairs(eventResultList) do + local eventType = eventResult.EventType + local eventArgs = eventResult.Args + if eventType ~= XFubenInfestorExploreConfigs.EventType.AddCore then + local content = GetEventTipsContent(eventType, eventArgs) + tipsContent = tipsContent .. content .. "\n" + end + OnNewEventTips(eventType, eventArgs) + end + OnNotAddCoreEventTips(tipsContent) + + MoveToNextNode(CurNodeId, nodeId) + SetLastFinishNodeId(CurNodeId) + + if callBack then callBack() end + end) + end + + function XFubenInfestorExploreManager.RequestInfestorExploreAutoEvent(nodeId, callBack) + local req = { GridId = nodeId } + + XNetwork.Call("InfestorExploreAutoEventRequest", req, function(res) + + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local eventResult = res.EventResult + local eventType = eventResult.EventType + local eventArgs = eventResult.Args + if eventType ~= XFubenInfestorExploreConfigs.EventType.AddCore then + local content = GetEventTipsContent(eventType, eventArgs) + OnNotAddCoreEventTips(content) + end + OnNewEventTips(eventType, eventArgs) + + MoveToNextNode(CurNodeId, nodeId) + SetLastFinishNodeId(CurNodeId) + + if callBack then callBack() end + end) + end + + function XFubenInfestorExploreManager.OpenGuestBook(chapterId) + local now = XTime.GetServerNowTimestamp() + if LastGetLeaveChapterMsgTime + REQUEST_GET_LEAVE_CHAPTER_MSG_CD >= now then + XLuaUiManager.Open("UiInfestorExploreGuestbook", chapterId) + return + end + + local callBack = function() + XLuaUiManager.Open("UiInfestorExploreGuestbook", chapterId) + end + XFubenInfestorExploreManager.RequestGetChapterLeaveMsg(chapterId, callBack) + end + + function XFubenInfestorExploreManager.RequestGetChapterLeaveMsg(chapterId, callBack) + local now = XTime.GetServerNowTimestamp() + if LastGetLeaveChapterMsgTime + REQUEST_GET_LEAVE_CHAPTER_MSG_CD >= now then + return + end + LastGetLeaveChapterMsgTime = now + + local req = { ChapterId = chapterId } + XNetwork.Call("InfestorGetChapterLeaveMsgRequest", req, function(res) + + local msgList = res.MsgList + if msgList then + UpdateChapterLeaveMsg(chapterId, msgList) + end + + if callBack then callBack() end + end) + end + + function XFubenInfestorExploreManager.RequestChapterLeaveMsg(chapterId, msg, callBack) + local now = XTime.GetServerNowTimestamp() + if LastLeaveChapterMsgTime + REQUEST_LEAVE_CHAPTER_MSG_CD >= now then + local tip = CSXTextManagerGetText("InfestorExploreRequestChapterLeaveMsgInCD", REQUEST_LEAVE_CHAPTER_MSG_CD) + XUiManager.TipMsg(tip) + return + end + + local req = { ChapterId = chapterId, Msg = msg } + XNetwork.Call("InfestorChapterLeaveMsgRequest", req, function(res) + + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + LastLeaveChapterMsgTime = now + + local playerMsgInfo = { + Msg = msg, + Id = XPlayer.Id, + GroupId = CurGroupId, + Diff = CurDiff, + } + InsertChapterMessage(chapterId, playerMsgInfo) + + if callBack then callBack() end + end) + end + + function XFubenInfestorExploreManager.RequestOutPostSend(nodeId, characterId, callBack) + local req = { GridId = nodeId, CharacterId = characterId } + XNetwork.Call("InfestorExploreBfrtRequest", req, function(res) + + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + MoveToNextNode(CurNodeId, nodeId) + + local rewardMoney = res.RewardMoney + local subHpList = res.SubHpList + + if callBack then callBack(rewardMoney, subHpList) end + end) + end + + function XFubenInfestorExploreManager.RequestEnterFight(chapterId, nodeId) + local stageId = XFubenInfestorExploreManager.GetNodeFightStageId(chapterId, nodeId) + local team = XFubenInfestorExploreManager.GetChapterTeamCharacterIds(chapterId) + local captainPos = XDataCenter.FubenInfestorExploreManager.GetChapterTeamCaptainPos(chapterId) + local firstFightPos = XDataCenter.FubenInfestorExploreManager.GetChapterTeamFirstFightPos(chapterId) + XDataCenter.FubenManager.EnterInfestorExploreFight(stageId, team, captainPos, nodeId, firstFightPos) + + DelayMoveNodeId = nodeId + end + + + function XFubenInfestorExploreManager.NotifyInfestorStatus(data) + + if data.IsReset then + ResetData() + end + UpdateSectionData(data.Status, data.NextResetTime) + UpdateStagesInfo(data.MapList) + end + + function XFubenInfestorExploreManager.NotifyInfestorDailyReset(data) + + UpdateContractInfo(data.EventShopInfo, data.NextResetTime) + end + + function XFubenInfestorExploreManager.NotifyInfestorCharacterList(data) + + UpdateCharacterData(data.CharacterList) + end + + function XFubenInfestorExploreManager.NotifyFlopRewardInfoList(data) + + UpdateFightRewards(data.FlopRewardInfoList) + + if AfterFightNeedShowReward then + AfterFightNeedShowReward = nil + if XFubenInfestorExploreManager.IsFightRewadsExist() then + XLuaUiManager.Open("UiInfestorExploreChoose") + end + end + end + + function XFubenInfestorExploreManager.NotifyInfestorPlayerInfoList(data) + + local infestorPlayerList = data.PlayerInfoList + if not infestorPlayerList then return end + UpdatePlayerRank(infestorPlayerList) + end + + --FubenManager相关 + function XFubenInfestorExploreManager.InitStageInfo() + local configs = XFubenInfestorExploreConfigs.GetStageConfigs() + for _, config in pairs(configs) do + local stageId = config.FightStageId + if stageId > 0 then + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + if stageInfo then + stageInfo.Type = XDataCenter.FubenManager.StageType.InfestorExplore + end + end + end + + local activityConfigs = XFubenInfestorExploreConfigs.GetActivityConfigs() + for _, config in pairs(activityConfigs) do + for _, stageId in pairs(config.BossStageId) do + if stageId > 0 then + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + if stageInfo then + stageInfo.Type = XDataCenter.FubenManager.StageType.InfestorExplore + end + end + end + end + end + + --战斗结算翻牌走副本之外独立协议通知 + function XFubenInfestorExploreManager.FinishFight(settle) + + local infestorBossFightResult = settle.InfestorBossFightResult + if infestorBossFightResult and next(infestorBossFightResult) then + local stageId = settle.StageId + + local newScore = infestorBossFightResult.TotalScore + local oldScore = XFubenInfestorExploreManager.GetChapter2StageScore(stageId) + local isNewScore = newScore > oldScore + if isNewScore then + Chapter2ScoreDic[stageId] = newScore + end + + local totalScore = XFubenInfestorExploreManager.GetChapter2TotalScore() + local player = GetPlayerData(XPlayer.Id) + player:SetScore(totalScore) + + XLuaUiManager.Open("UiInfestorExploreFightResult", stageId, infestorBossFightResult, isNewScore) + else + XDataCenter.FubenManager.FinishFight(settle) + if settle.IsWin then + if DelayMoveNodeId then + MoveToNextNode(CurNodeId, DelayMoveNodeId) + DelayMoveNodeId = nil + end + + AfterFightNeedShowReward = true + end + end + end + + XFubenInfestorExploreManager.OnGetMoneyTip = OnGetMoneyTip + XFubenInfestorExploreManager.IsHaveCore = IsHaveCore + XFubenInfestorExploreManager.CheckBuffExsit = CheckBuffExsit + return XFubenInfestorExploreManager + -- -------------------(对外开放接口)end------------------ +end + +-- -------------------(服务器推送)begin------------------ +XRpc.NotifyInfestorStatus = function(data) + XDataCenter.FubenInfestorExploreManager.NotifyInfestorStatus(data) +end + +XRpc.NotifyInfestorDailyReset = function(data) + XDataCenter.FubenInfestorExploreManager.NotifyInfestorDailyReset(data) +end + +XRpc.NotifyInfestorCharacterList = function(data) + XDataCenter.FubenInfestorExploreManager.NotifyInfestorCharacterList(data) +end + +XRpc.NotifyFlopRewardInfoList = function(data) + XDataCenter.FubenInfestorExploreManager.NotifyFlopRewardInfoList(data) +end + +XRpc.NotifyInfestorPlayerInfoList = function(data) + XDataCenter.FubenInfestorExploreManager.NotifyInfestorPlayerInfoList(data) +end +-- -------------------(服务器推送)end------------------ \ No newline at end of file diff --git a/Resources/Scripts/XManager/XFubenMainLineManager.lua b/Resources/Scripts/XManager/XFubenMainLineManager.lua new file mode 100644 index 00000000..846c8a28 --- /dev/null +++ b/Resources/Scripts/XManager/XFubenMainLineManager.lua @@ -0,0 +1,1005 @@ +local tableInsert = table.insert +local tableSort = table.sort + +XFubenMainLineManagerCreator = function() + + local XFubenMainLineManager = {} + + local METHOD_NAME = { + ReceiveTreasureReward = "ReceiveTreasureRewardRequest", + BuyMainLineChallengeCount = "BuyMainLineChallengeCountRequest", + } + + local ChapterMainTemplates = {} + local ChapterCfg = {} + local TreasureCfg = {} + local NewChaperId = -1 + + local StageDifficultMap = {} + local PlayerTreasureData = {} + local ExploreGroupInfos = {} + local ExploreItemInfos = {} + local ChapterInfos = {} -- info {FirstStage, ActiveStage, Stars, Unlock, Passed} + local CurDifficult + local LastFightStage = {} + local ActivityChapters = {} --活动抢先体验ChapterId列表 + local ActivityEndTime = 0 --活动抢先体验结束时间 + local ActivityChallengeBeginTime = 0 --活动抢先体验结束时间(隐藏模式) + local ActivityTimer + local ExploreEventStateList = {} + + local LastPassStage = {} --key:chapterId value:stageId + + local ExItemRedPointState = { + Off = 0, + On = 1, + } + + function XFubenMainLineManager.Init() + ChapterMainTemplates = XFubenMainLineConfigs.GetChapterMainTemplates() + ChapterCfg = XFubenMainLineConfigs.GetChapterCfg() + TreasureCfg = XFubenMainLineConfigs.GetTreasureCfg() + XFubenMainLineManager.InitStageDifficultMap() + XFubenMainLineManager.InitExploreGroup() + XFubenMainLineManager.InitExploreItem() + + XFubenMainLineManager.DifficultNormal = CS.XGame.Config:GetInt("FubenDifficultNormal") + XFubenMainLineManager.DifficultHard = CS.XGame.Config:GetInt("FubenDifficultHard") + XFubenMainLineManager.DifficultNightmare = CS.XGame.Config:GetInt("FubenDifficultNightmare") + + XFubenMainLineManager.UiGridChapterMoveMinX = CS.XGame.ClientConfig:GetInt("UiGridChapterMoveMinX") + XFubenMainLineManager.UiGridChapterMoveMaxX = CS.XGame.ClientConfig:GetInt("UiGridChapterMoveMaxX") + XFubenMainLineManager.UiGridChapterMoveTargetX = CS.XGame.ClientConfig:GetInt("UiGridChapterMoveTargetX") + XFubenMainLineManager.UiGridChapterMoveDuration = CS.XGame.ClientConfig:GetFloat("UiGridChapterMoveDuration") + + XFubenMainLineManager.TRPGChapterId = CS.XGame.ClientConfig:GetInt("TRPGChapterId") + + CurDifficult = XFubenMainLineManager.DifficultNormal + end + + function XFubenMainLineManager.InitStageInfoEx() + XFubenMainLineManager.InitStageInfo(false) + end + + function XFubenMainLineManager.InitStageInfo(checkNewUnlock) + XFubenMainLineManager.InitChapterData(checkNewUnlock) + XFubenMainLineManager.MainLineActivityStart() + end + + function XFubenMainLineManager.InitStageDifficultMap() + for _, chapter in pairs(ChapterCfg) do + for _, stageId in ipairs(chapter.StageId) do + StageDifficultMap[stageId] = chapter.Difficult + end + end + end + + function XFubenMainLineManager.CheckOpenCondition(chapterId) + local chapterCfg = XFubenMainLineManager.GetChapterCfg(chapterId) + local conditionId = chapterCfg.OpenCondition + if conditionId ~= 0 then + return XConditionManager.CheckCondition(conditionId) + end + + return true, "" + end + + local function InitChapterInfo(chapterMain, chapter) + local info = {} + if #chapter.StageId > 0 then + info.ChapterMainId = chapterMain.Id + info.FirstStage = chapter.StageId[1] + local firstStageInfo = XDataCenter.FubenManager.GetStageInfo(info.FirstStage) + + -- 如果章节处于活动时间内,根据时间判断是否可以解锁 + local firstUnlock = firstStageInfo.Unlock + local firstPassed = firstStageInfo.Passed + info.Unlock = firstUnlock + info.IsOpen = firstStageInfo.IsOpen + if not firstPassed and firstUnlock and XFubenMainLineManager.CheckDiffHasAcitivity(chapter) then + if not XFubenMainLineManager.CheckActivityCondition(chapter.ChapterId) then + info.Unlock = false + info.IsOpen = false + end + elseif (not XFubenMainLineManager.IsMainLineActivityOpen() and XFubenMainLineManager.CheckDiffHasAcitivity(chapter)) + or not XFubenMainLineManager.CheckDiffHasAcitivity(chapter) then + if not XFubenMainLineManager.CheckOpenCondition(chapter.ChapterId) then + info.Unlock = false + info.IsOpen = false + end + end + + local passStageNum = 0 + local stars = 0 + local allPassed = true + + for _, v in ipairs(chapter.StageId) do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(v) + if stageInfo.Unlock then + info.ActiveStage = v + end + if not stageInfo.Passed then + allPassed = false + else + passStageNum = passStageNum + 1 + end + stars = stars + stageInfo.Stars + end + + local treasureCfg = XDataCenter.FubenMainLineManager.GetTreasureCfg(chapter.TreasureId[#chapter.TreasureId]) + info.TotalStars = treasureCfg.RequireStar + info.Stars = stars > info.TotalStars and info.TotalStars or stars + info.Passed = allPassed + info.PassStageNum = passStageNum + elseif chapterMain.Id == XFubenMainLineManager.TRPGChapterId then + local isOpen = XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.MainLineTRPG) + info.ChapterMainId = chapterMain.Id + info.Unlock = isOpen + info.IsOpen = isOpen + info.Passed = true + end + return info + end + + function XFubenMainLineManager.InitChapterData(checkNewUnlock) + local oldChapterInfos = ChapterInfos + ChapterInfos = {} + for _, chapterMain in pairs(ChapterMainTemplates) do + for difficult, chapterId in pairs(chapterMain.ChapterId) do + if chapterId > 0 then + local chapter = ChapterCfg[chapterId] + ChapterInfos[chapterId] = InitChapterInfo(chapterMain, chapter) + for k, v in ipairs(chapter.StageId) do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(v) + stageInfo.Type = XDataCenter.FubenManager.StageType.Mainline + stageInfo.OrderId = k + stageInfo.ChapterId = chapter.ChapterId + stageInfo.Difficult = difficult + end + end + end + end + + NewChaperId = -1 + if checkNewUnlock then + for k, v in pairs(ChapterInfos) do + if v.Unlock and not oldChapterInfos[k].Unlock then + NewChaperId = k + XEventManager.DispatchEvent(XEventId.EVENT_FUBEN_NEW_MAIN_LINE_CHAPTER, k) + end + end + end + end + + + + function XFubenMainLineManager.GetLastPassStage(chapterId) + return LastPassStage[chapterId] + end + + function XFubenMainLineManager.GetCurDifficult() + return CurDifficult + end + + function XFubenMainLineManager.SetCurDifficult(difficult) + if difficult == XFubenMainLineManager.DifficultNightmare then return end + CurDifficult = difficult + XEventManager.DispatchEvent(XEventId.EVENT_FUBEN_CHANGE_MAIN_LINE_DIFFICULT, difficult) + end + + function XFubenMainLineManager.RecordLastStage(chapterId, stageId) + LastFightStage[chapterId] = stageId + end + + function XFubenMainLineManager.GetLastStage(chapterId) + return LastFightStage[chapterId] + end + + function XFubenMainLineManager.GetNextChapterId(chapterId) + local curChapterCfg = ChapterCfg[chapterId] + if not curChapterCfg then return end + + local orerdId = curChapterCfg.OrderId + 1 + local difficult = curChapterCfg.Difficult + for _, v in pairs(ChapterCfg) do + if v.OrderId == orerdId and v.Difficult == difficult then + if XFubenMainLineManager.IsStageIdTableEmpty(v.ChapterId) then + orerdId = orerdId + 1 + else + return v.ChapterId + end + end + end + end + + function XFubenMainLineManager.IsStageIdTableEmpty(chapterId) + local curchapterCfg = ChapterCfg[chapterId] + local StageIdList = curchapterCfg and curchapterCfg.StageId + return XTool.IsTableEmpty(StageIdList) + end + + function XFubenMainLineManager.GetLastStageId(chapterId) + if XFubenMainLineManager.IsStageIdTableEmpty(chapterId) then + return + end + + local curChapterCfg = ChapterCfg[chapterId] + return curChapterCfg.StageId[#curChapterCfg.StageId] + end + + function XFubenMainLineManager.CheckChapterNew(chapterId) + local chapterInfo = XFubenMainLineManager.GetChapterInfo(chapterId) + return chapterInfo.Unlock and not chapterInfo.Passed + end + + -- 改章节是否可以跳转 + function XFubenMainLineManager.CheckChapterCanGoTo(chapterId) + if not chapterId then return true end + local chapterInfo = XFubenMainLineManager.GetChapterInfo(chapterId) + if not chapterInfo then return true end + + if chapterInfo.IsActivity then + if not XFubenMainLineManager.IsMainLineActivityOpen() or not XFubenMainLineManager.CheckActivityCondition(chapterId) then + return false + end + end + + return chapterInfo.Unlock + end + + function XFubenMainLineManager.CheckNewChapter() + local chapterList = XDataCenter.FubenMainLineManager.GetChapterList(XDataCenter.FubenManager.DifficultNormal) + for _, v in ipairs(chapterList) do + local chapterInfo = XDataCenter.FubenMainLineManager.GetChapterInfo(v) + if chapterInfo.Unlock then + local activeStageId = chapterInfo.ActiveStage + if not activeStageId then break end + local stageInfo = XDataCenter.FubenManager.GetStageInfo(activeStageId) + local nextStageInfo = XDataCenter.FubenManager.GetStageInfo(stageInfo.NextStageId) + if nextStageInfo and nextStageInfo.Unlock or stageInfo.Passed then + return false + else + return true + end + end + + if not chapterInfo.Passed then + break + end + end + + return false + end + + + + -- 获取篇章进度、上次所选篇章 + function XFubenMainLineManager.GetChapterInfo(chapterId) + return ChapterInfos[chapterId] + end + + function XFubenMainLineManager.GetChapterInfoForOrderId(difficult, orderId) + if difficult ~= XFubenMainLineManager.DifficultNightmare then + for _, v in pairs(ChapterMainTemplates) do + if v.OrderId == orderId then + local chapterId = v.ChapterId[difficult] + return XFubenMainLineManager.GetChapterInfo(chapterId) + end + end + end + end + + -- 获取篇章星数 + function XFubenMainLineManager.GetChapterStars(chapterId) + local info = ChapterInfos[chapterId] + return info and info.Stars or 0, info and info.TotalStars or 0 + end + + function XFubenMainLineManager.GetChapterList(difficult) + if difficult ~= XFubenMainLineManager.DifficultNightmare then + local list = {} + for _, v in pairs(ChapterMainTemplates) do + list[v.OrderId] = v.ChapterId[difficult] + end + return list + end + end + + local orderIdSortFunc = function(a, b) + return a.OrderId < b.OrderId + end + + function XFubenMainLineManager.GetChapterMainTemplates(difficult) + local list = {} + local activityList = {} + + for _, v in pairs(ChapterMainTemplates) do + local chapterId + local chapterInfo + + if difficult == XDataCenter.FubenManager.DifficultNightmare then + chapterId = v.BfrtId + if chapterId and chapterId > 0 then + chapterInfo = XDataCenter.BfrtManager.GetChapterInfo(chapterId) + end + else + chapterId = v.ChapterId[difficult] + if chapterId and chapterId > 0 then + chapterInfo = XFubenMainLineManager.GetChapterInfo(chapterId) + end + end + + if chapterInfo then + if chapterInfo.IsActivity then + tableInsert(activityList, v) + else + tableInsert(list, v) + end + end + end + + if next(list) then + tableSort(list, orderIdSortFunc) + end + + if next(activityList) then + tableSort(activityList, orderIdSortFunc) + + local allUnlock = true + for order, template in pairs(list) do + local chapterId + local chapterInfo + + if difficult == XDataCenter.FubenManager.DifficultNightmare then + chapterId = template.BfrtId + if chapterId and chapterId > 0 then + chapterInfo = XDataCenter.BfrtManager.GetChapterInfo(chapterId) + end + else + chapterId = template.ChapterId[difficult] + if chapterId and chapterId > 0 then + chapterInfo = XFubenMainLineManager.GetChapterInfo(chapterId) + end + end + + if (chapterInfo) and (not chapterInfo.Unlock) then + local index = order + for _, v in pairs(activityList) do + tableInsert(list, index, v) + index = index + 1 + end + + allUnlock = false + break + end + end + + if allUnlock then + for _, v in pairs(activityList) do + tableInsert(list, v) + end + end + end + + return list + end + + function XFubenMainLineManager.GetChapterMainTemplate(chapterMainId) + return ChapterMainTemplates[chapterMainId] + end + + function XFubenMainLineManager.GetChapterCfg(chapterId) + return ChapterCfg[chapterId] + end + + function XFubenMainLineManager.GetChapterIdByChapterMain(chapterMainId, difficult) + if difficult == XFubenMainLineManager.DifficultNormal then + return ChapterMainTemplates[chapterMainId].ChapterId[1] + elseif difficult == XFubenMainLineManager.DifficultHard then + return ChapterMainTemplates[chapterMainId].ChapterId[2] + elseif difficult == XFubenMainLineManager.DifficultNightmare then + return ChapterMainTemplates[chapterMainId].BfrtId + end + local tempStr = "XFubenMainLineManager.GetChapterIdByChapterMain函数参数difficult应该是," + XLog.Error(tempStr .. "config表:Share/Config/Config.tab, 中字段FubenDifficultNormal、FubenDifficultHard、FubenDifficultNightmare对应的值中的一个") + end + + function XFubenMainLineManager.GetChapterCfgByChapterMain(chapterMainId, difficult) + if difficult == XFubenMainLineManager.DifficultNormal then + return ChapterCfg[ChapterMainTemplates[chapterMainId].ChapterId[1]] + elseif difficult == XFubenMainLineManager.DifficultHard then + return ChapterCfg[ChapterMainTemplates[chapterMainId].ChapterId[2]] + elseif difficult == XFubenMainLineManager.DifficultNightmare then + return XDataCenter.BfrtManager.GetChapterCfg(ChapterMainTemplates[chapterMainId].BfrtId) + end + local tempStr = "XFubenMainLineManager.GetChapterIdByChapterMain函数参数difficult应该是," + XLog.Error(tempStr .. "config表:Share/Config/Config.tab, 中字段FubenDifficultNormal、FubenDifficultHard、FubenDifficultNightmare对应的值中的一个") + end + + function XFubenMainLineManager.GetChapterInfoByChapterMain(chapterMainId, difficult) + if difficult == XFubenMainLineManager.DifficultNormal then + return ChapterInfos[ChapterMainTemplates[chapterMainId].ChapterId[1]] + elseif difficult == XFubenMainLineManager.DifficultHard then + return ChapterInfos[ChapterMainTemplates[chapterMainId].ChapterId[2]] + elseif difficult == XFubenMainLineManager.DifficultNightmare then + return XDataCenter.BfrtManager.GetChapterInfo(ChapterMainTemplates[chapterMainId].BfrtId) + end + local tempStr = "XFubenMainLineManager.GetChapterIdByChapterMain函数参数difficult应该是," + XLog.Error(tempStr .. "config表:Share/Config/Config.tab, 中字段FubenDifficultNormal、FubenDifficultHard、FubenDifficultNightmare对应的值中的一个") + end + + function XFubenMainLineManager.GetStageDifficult(stageId) + local difficult = StageDifficultMap[stageId] or 0 + return difficult + end + + function XFubenMainLineManager.GetStageList(chapterId) + return ChapterCfg[chapterId].StageId + end + + function XFubenMainLineManager.GetTreasureCfg(treasureId) + if TreasureCfg[treasureId] then + return TreasureCfg[treasureId] + end + end + + function XFubenMainLineManager.GetProgressByChapterId(chapterId) + if chapterId == XDataCenter.FubenMainLineManager.TRPGChapterId then + local progress = XDataCenter.TRPGManager.GetProgress() + return progress + end + + local chapterInfo = XFubenMainLineManager.GetChapterInfo(chapterId) + if not chapterInfo.Stars or not chapterInfo.TotalStars then + return 0 + end + return math.ceil(100 * chapterInfo.Stars / chapterInfo.TotalStars) + end + + function XFubenMainLineManager.GetChapterOrderIdByStageId(stageId) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + local chapter = ChapterCfg[stageInfo.ChapterId] + return chapter.OrderId + end + + function XFubenMainLineManager.InitFubenMainLineData(fubenMainLineData) + if fubenMainLineData.TreasureData then + for i = 1, #fubenMainLineData.TreasureData do + PlayerTreasureData[fubenMainLineData.TreasureData[i]] = true + end + end + + if fubenMainLineData.LastPassStage then + for k, v in pairs(fubenMainLineData.LastPassStage) do + LastPassStage[k] = v + end + end + + if fubenMainLineData.MainChapterEventInfos then + XFubenMainLineManager.SetChapterEventState(fubenMainLineData.MainChapterEventInfos) + end + + XEventManager.AddEventListener(XEventId.EVENT_FUBEN_STAGE_SYNC, XFubenMainLineManager.OnSyncStageData) + XEventManager.AddEventListener(XEventId.EVENT_CHARACTER_LEVEL_UP, XFubenMainLineManager.InitStageInfoEx) + end + + function XFubenMainLineManager.OnSyncStageData(stageId) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + if stageInfo and stageInfo.Type == XDataCenter.FubenManager.StageType.Mainline and stageInfo.ChapterId then + LastPassStage[stageInfo.ChapterId] = stageId + end + end + + function XFubenMainLineManager.IsTreasureGet(treasureId) + return PlayerTreasureData[treasureId] + end + + function XFubenMainLineManager.SyncTreasureStage(treasureId) + PlayerTreasureData[treasureId] = true + end + + -- 领取宝箱奖励 + function XFubenMainLineManager.ReceiveTreasureReward(cb, treasureId) + local req = { TreasureId = treasureId } + XNetwork.Call(METHOD_NAME.ReceiveTreasureReward, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XFubenMainLineManager.SyncTreasureStage(treasureId) + if cb then + cb(res.RewardGoodsList) + end + XEventManager.DispatchEvent(XEventId.EVENT_FUBEN_CHAPTER_REWARD) + end) + end + + --检测所有章节进度是否有奖励 + function XFubenMainLineManager.CheckAllChapterReward() + for _, v in pairs(ChapterMainTemplates) do + for _, chapterId in pairs(v.ChapterId) do + if XFubenMainLineManager.CheckTreasureReward(chapterId) then + return true + end + end + end + return false + end + + ---检测章节内是否有收集进度奖励 + function XFubenMainLineManager.CheckTreasureReward(chapterId) + local chapterInfo = XFubenMainLineManager.GetChapterInfo(chapterId) + if not chapterInfo.Unlock then + return false + end + + local hasReward = false + local chapter = XFubenMainLineManager.GetChapterCfg(chapterId) + local targetList = chapter.TreasureId + + for _, var in ipairs(targetList) do + local treasureCfg = XFubenMainLineManager.GetTreasureCfg(var) + if treasureCfg then + local requireStars = treasureCfg.RequireStar + local starCount = 0 + local stageList = XFubenMainLineManager.GetStageList(chapterId) + + for i = 1, #stageList do + local stage = XDataCenter.FubenManager.GetStageCfg(stageList[i]) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stage.StageId) + starCount = starCount + stageInfo.Stars + end + + if requireStars > 0 and requireStars <= starCount then + local isGet = XFubenMainLineManager.IsTreasureGet(treasureCfg.TreasureId) + if not isGet then + hasReward = true + break + end + end + end + end + + return hasReward + end + + function XFubenMainLineManager.BuyMainLineChallengeCount(cb, stageId) + local difficult = XFubenMainLineManager.GetStageDifficult(stageId) + local challengeData = XFubenMainLineManager.GetStageBuyChallengeData(stageId) + local req = { StageId = stageId } + XNetwork.Call(METHOD_NAME.BuyMainLineChallengeCount, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + CS.XAnalyticsManager.OnPurchaseItemByGem("BuyChallengeCount-" .. difficult .. " x" .. 1, 1, challengeData.BuyChallengeCost) + if cb then + cb() + end + end) + end + + function XFubenMainLineManager.GetStageBuyChallengeData(stageId) + local challengeCountData = {} + local stageData = XDataCenter.FubenManager.GetStageData(stageId) + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + challengeCountData.BuyCount = 0 + challengeCountData.PassTimesToday = 0 + if stageData then + challengeCountData.BuyCount = stageData.BuyCount + challengeCountData.PassTimesToday = stageData.PassTimesToday + end + challengeCountData.BuyChallengeCount = stageCfg.BuyChallengeCount + challengeCountData.MaxChallengeNums = stageCfg.MaxChallengeNums + challengeCountData.BuyChallengeCost = stageCfg.BuyChallengeCost + challengeCountData.StageId = stageId + return challengeCountData + end + + function XFubenMainLineManager.CheckPreFight(stage) + local stageId = stage.StageId + local stageData = XDataCenter.FubenManager.GetStageData(stageId) + if stageData ~= nil and stage.MaxChallengeNums > 0 and stageData.PassTimesToday >= stage.MaxChallengeNums then + local msg = CS.XTextManager.GetText("FubenChallengeCountNotEnough") + XUiManager.TipMsg(msg) + return false + end + return true + end + + function XFubenMainLineManager.FinishFight(settle) + if settle.IsWin then + if XDataCenter.BountyTaskManager.CheckBountyTaskPreFightWithStatus(settle.StageId) and XDataCenter.BountyTaskManager.IsBountyPreFight() then + --检查是否是赏金任务前置 + XDataCenter.BountyTaskManager.EnterFight(settle) + else + XDataCenter.FubenManager.ChallengeWin(settle) + end + else + XDataCenter.FubenManager.ChallengeLose(settle) + end + end + + function XFubenMainLineManager.ShowSummary(stageId) + if XDataCenter.FubenManager.CurFightResult and XDataCenter.FubenManager.CurFightResult.IsWin then + if XDataCenter.BountyTaskManager.CheckBountyTaskPreFightWithStatus(stageId) and XDataCenter.BountyTaskManager.IsBountyPreFight() then + XLuaUiManager.Open("UiMoneyRewardFightTipFind") + end + else + XDataCenter.FubenManager.ExitFight() + end + end + + function XFubenMainLineManager.GetActiveChapterCfg(difficult) + local activeChapterCfg + local chapterList = XFubenMainLineManager.GetChapterList(difficult) + for i = #chapterList, 1, -1 do + local chapterId = chapterList[i] + local chapterInfo = XFubenMainLineManager.GetChapterInfo(chapterId) + if chapterInfo.Unlock then + activeChapterCfg = XFubenMainLineManager.GetChapterCfg(chapterId) + break + end + end + return activeChapterCfg + end + + function XFubenMainLineManager.CheckAutoExitFight(stageId) + if XDataCenter.BountyTaskManager.CheckBountyTaskPreFightWithStatus(stageId) and XDataCenter.BountyTaskManager.IsBountyPreFight() then + return false + end + return true + end + + -- 胜利 & 奖励界面 + function XFubenMainLineManager.ShowReward(winData) + XLuaUiManager.Open("UiSettleWinMainLine", winData) + end + + function XFubenMainLineManager.GetNewChapterId() + return NewChaperId + end + + ------------------------------------------------------------------ 活动主线副本抢先体验 begin ------------------------------------------------------- + function XFubenMainLineManager.NotifyMainLineActivity(data) + local now = XTime.GetServerNowTimestamp() + ActivityEndTime = data.EndTime or 0 + ActivityChallengeBeginTime = data.HideChapterBeginTime or 0 + if now < ActivityEndTime then + --清理上次活动状态 + if next(ActivityChapters) then + XFubenMainLineManager.MainLineActivityEnd() + end + + ActivityChapters = { + MainLineIds = data.Chapters, + BfrtId = data.BfrtChapter, + } + + XFubenMainLineManager.MainLineActivityStart() + else + --活动关闭 + XFubenMainLineManager.MainLineActivityEnd() + end + end + + function XFubenMainLineManager.IsMainLineActivityOpen() + return ActivityEndTime and ActivityEndTime > XTime.GetServerNowTimestamp() + end + + function XFubenMainLineManager.IsMainLineActivityChallengeBegin() + return ActivityChallengeBeginTime and XTime.GetServerNowTimestamp() >= ActivityChallengeBeginTime + end + + function XFubenMainLineManager.MainLineActivityStart() + if not XFubenMainLineManager.IsMainLineActivityOpen() then return end + + --定时器 + if ActivityTimer then + XScheduleManager.UnSchedule(ActivityTimer) + ActivityTimer = nil + end + + local time = XTime.GetServerNowTimestamp() + local challengeWaitUnlock = true + ActivityTimer = XScheduleManager.ScheduleForever(function() + time = time + 1 + if time >= ActivityChallengeBeginTime then + if challengeWaitUnlock then + XFubenMainLineManager.UnlockActivityChapters() + challengeWaitUnlock = nil + end + end + + if time >= ActivityEndTime then + XFubenMainLineManager.MainLineActivityEnd() + end + end, XScheduleManager.SECOND, 0) + + XFubenMainLineManager.UnlockActivityChapters() + end + + function XFubenMainLineManager.UnlockActivityChapters() + if not next(ActivityChapters) then return end + + --主线章节普通和困难 + for _, chapterId in pairs(ActivityChapters.MainLineIds) do + if chapterId ~= 0 then + XFubenMainLineManager.UnlockChapterViaActivity(chapterId) + end + end + + --据点战章节 + local bfrtId = ActivityChapters.BfrtId + if bfrtId and bfrtId ~= 0 then + XDataCenter.BfrtManager.UnlockChapterViaActivity(bfrtId) + end + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_ACTIVITY_MAINLINE_STATE_CHANGE) + end + + function XFubenMainLineManager.MainLineActivityEnd() + if ActivityTimer then + XScheduleManager.UnSchedule(ActivityTimer) + ActivityTimer = nil + end + + --活动结束处理 + local chapterIds = ActivityChapters.MainLineIds + if chapterIds then + for _, chapterId in pairs(chapterIds) do + if chapterId ~= 0 then + local chapterInfo = XFubenMainLineManager.GetChapterInfo(chapterId) + chapterInfo.IsActivity = false + end + end + end + + local bfrtId = ActivityChapters.BfrtId + if bfrtId and bfrtId ~= 0 then + local chapterInfo = XDataCenter.BfrtManager.GetChapterInfo(bfrtId) + chapterInfo.IsActivity = false + end + + XDataCenter.FubenManager.InitData(true) + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_ACTIVITY_MAINLINE_STATE_CHANGE, chapterIds) + end + + function XFubenMainLineManager.GetActivityEndTime() + return ActivityEndTime + end + + function XFubenMainLineManager.CheckDiffHasAcitivity(chapter) + if not next(ActivityChapters) then return false end + if chapter.Difficult == XFubenMainLineManager.DifficultNightmare then + return chapter.ChapterId == ActivityChapters.BfrtId + else + for _, chapterId in pairs(ActivityChapters.MainLineIds) do + if chapterId == chapter.ChapterId then + return true + end + end + end + return false + end + + + + function XFubenMainLineManager.UnlockChapterViaActivity(chapterId) + --开启章节,标识活动状态 + local chapterInfo = XFubenMainLineManager.GetChapterInfo(chapterId) + chapterInfo.IsActivity = true + + if not XFubenMainLineManager.CheckActivityCondition(chapterId) then + chapterInfo.Unlock = false + chapterInfo.IsOpen = false + return + end + + if chapterId == XDataCenter.FubenMainLineManager.TRPGChapterId then + chapterInfo.Unlock = true + chapterInfo.IsOpen = true + return + end + + chapterInfo.Unlock = true + chapterInfo.IsOpen = true + + local chapterCfg = XFubenMainLineManager.GetChapterCfg(chapterId) + for index, stageId in ipairs(chapterCfg.StageId) do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + stageInfo.Unlock = true + stageInfo.IsOpen = true + + --章节第一关无视前置条件 + if index ~= 1 then + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + + --其余关卡只检测前置条件组 + for _, prestageId in pairs(stageCfg.PreStageId or {}) do + if prestageId > 0 then + local stageData = XDataCenter.FubenManager.GetStageData(prestageId) + + if not stageData or not stageData.Passed then + stageInfo.Unlock = false + stageInfo.IsOpen = false + break + end + end + end + end + end + end + + function XFubenMainLineManager.CheckActivityCondition(chapterId) + local chapterCfg = XFubenMainLineManager.GetChapterCfg(chapterId) + + if chapterCfg.Difficult == XFubenMainLineManager.DifficultHard and + not XFubenMainLineManager.IsMainLineActivityChallengeBegin() then + local time = XTime.GetServerNowTimestamp() + local timeStr = XUiHelper.GetTime(ActivityChallengeBeginTime - time, XUiHelper.TimeFormatType.ACTIVITY) + local msg = CS.XTextManager.GetText("FuBenMainlineActivityNotReachChallengeTime", timeStr) + return false, msg + elseif chapterCfg.Difficult == XFubenMainLineManager.DifficultHard and + not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.FubenDifficulty) then + return false, XFunctionManager.GetFunctionOpenCondition(XFunctionManager.FunctionName.FubenDifficulty) + end + + local conditionId = chapterCfg.ActivityCondition + if conditionId ~= 0 then + return XConditionManager.CheckCondition(conditionId) + end + + return true, "" + end + + function XFubenMainLineManager.OnActivityEnd() + if CS.XFight.IsRunning or XLuaUiManager.IsUiLoad("UiLoading") then + return + end + XUiManager.TipText("ActivityMainLineEnd") + XLuaUiManager.RunMain() + end + ------------------------------------------------------------------ 活动主线副本抢先体验 end ------------------------------------------------------- + ------------------------------------------------------------------ 活动主线副本探索玩法 begin ------------------------------------------------------- + function XFubenMainLineManager.InitExploreGroup() + local exploreGroupList = XFubenMainLineConfigs.GetExploreGroupCfg() + for _, exploreGroup in pairs(exploreGroupList) do + if not ExploreGroupInfos[exploreGroup.GroupId] then + ExploreGroupInfos[exploreGroup.GroupId] = {} + end + ExploreGroupInfos[exploreGroup.GroupId][exploreGroup.StageIndex] = exploreGroup + end + end + + function XFubenMainLineManager.InitExploreItem() + local exploreItemList = XFubenMainLineConfigs.GetExploreItemCfg() + for _, exploreItem in pairs(exploreItemList) do + if not ExploreItemInfos[exploreItem.MainChapterId] then + ExploreItemInfos[exploreItem.MainChapterId] = {} + end + tableInsert(ExploreItemInfos[exploreItem.MainChapterId], exploreItem) + end + end + + function XFubenMainLineManager.GetExploreGroupInfoByGroupId(id) + if not ExploreGroupInfos[id] then + XLog.ErrorTableDataNotFound("XFubenMainLineManager.GetExploreGroupInfoByGroupId", + "ExploreGroupInfos", " Client/Fuben/MainLine/ExploreGroup.tab", "id", tostring(id)) + return {} + end + return ExploreGroupInfos[id] + end + + function XFubenMainLineManager.CheckChapterTypeIsExplore(chapter) + return chapter.ExploreGroupId and chapter.ExploreGroupId > 0 + end + + function XFubenMainLineManager.CheckHaveNewExploreItemByChapterId(mainChapterId) + if not ExploreItemInfos[mainChapterId] then + return false + end + for _, info in pairs(ExploreItemInfos[mainChapterId]) do + if XFubenMainLineManager.CheckHaveNewExploreItemByItemId(info.Id) then + return true + end + end + return false + end + + function XFubenMainLineManager.CheckHaveNewExploreItemByItemId(itemId) + local data = XSaveTool.GetData(string.format("%d%s%d", XPlayer.Id, "MainLineExploreItem", itemId)) + return data == ExItemRedPointState.On + end + + function XFubenMainLineManager.SetChapterEventState(chapterEventDatas) + for _, data in pairs(chapterEventDatas) do + local eventIds = data.EventIds or {} + for _, id in pairs(eventIds) do + ExploreEventStateList[id] = true + end + end + end + + function XFubenMainLineManager.AddChapterEventState(chapterEventData) + local eventIds = chapterEventData and chapterEventData.EventIds or {} + for _, id in pairs(eventIds) do + ExploreEventStateList[id] = true + end + end + + function XFubenMainLineManager.GetChapterExploreItemList(mainChapterId) + local list = {} + if ExploreItemInfos[mainChapterId] then + for _, info in pairs(ExploreItemInfos[mainChapterId]) do + if ExploreEventStateList[info.Id] then + tableInsert(list, info) + end + end + end + return list + end + + function XFubenMainLineManager.GetChapterExploreItemMaxCount(mainChapterId) + return ExploreItemInfos[mainChapterId] and #ExploreItemInfos[mainChapterId] or 0 + end + + function XFubenMainLineManager.SaveNewExploreItemRedPoint(chapterEventData) + local eventIds = chapterEventData and chapterEventData.EventIds or {} + local exploreItemList = XFubenMainLineConfigs.GetExploreItemCfg() + for _, id in pairs(eventIds) do + if exploreItemList[id] then + if not XSaveTool.GetData(string.format("%d%s%d", XPlayer.Id, "MainLineExploreItem", id)) then + XSaveTool.SaveData(string.format("%d%s%d", XPlayer.Id, "MainLineExploreItem", id), ExItemRedPointState.On) + end + else + XLog.ErrorTableDataNotFound("XFubenMainLineManager.SaveNewExploreItemRedPoint", + "exploreItem", "Client/Fuben/MainLine/ExploreItem.tab", "id", tostring(id)) + end + end + end + + function XFubenMainLineManager.MarkNewExploreItemRedPointByItemId(itemId) + local data = XSaveTool.GetData(string.format("%d%s%d", XPlayer.Id, "MainLineExploreItem", itemId)) + if data and data == ExItemRedPointState.On then + XSaveTool.SaveData(string.format("%d%s%d", XPlayer.Id, "MainLineExploreItem", itemId), ExItemRedPointState.Off) + XEventManager.DispatchEvent(XEventId.EVENT_MAINLINE_EXPLORE_ITEMBOX_CLOSE) + end + end + + function XFubenMainLineManager.CheckHaveNewJumpStageButtonByStageId(stageId) + local data = XSaveTool.GetData(string.format("%d%s%d", XPlayer.Id, "MainLineJumpStageButton", stageId)) + if data then + return data == ExItemRedPointState.On + end + return false + end + + function XFubenMainLineManager.SaveNewJumpStageButtonEffect(stageId) + if not XSaveTool.GetData(string.format("%d%s%d", XPlayer.Id, "MainLineJumpStageButton", stageId)) then + XSaveTool.SaveData(string.format("%d%s%d", XPlayer.Id, "MainLineJumpStageButton", stageId), ExItemRedPointState.On) + end + end + + function XFubenMainLineManager.MarkNewJumpStageButtonEffectByStageId(stageId) + local data = XSaveTool.GetData(string.format("%d%s%d", XPlayer.Id, "MainLineJumpStageButton", stageId)) + if data and data == ExItemRedPointState.On then + XSaveTool.SaveData(string.format("%d%s%d", XPlayer.Id, "MainLineJumpStageButton", stageId), ExItemRedPointState.Off) + end + end + + ------------------------------------------------------------------ 活动主线副本探索玩法 end ------------------------------------------------------- + XFubenMainLineManager.Init() + return XFubenMainLineManager +end + +XRpc.NotifyMainLineActivity = function(data) + XDataCenter.FubenMainLineManager.NotifyMainLineActivity(data) +end + +XRpc.NotifyMainChapterEventData = function(data) + XDataCenter.FubenMainLineManager.AddChapterEventState(data.ChapterEventData) + XDataCenter.FubenMainLineManager.SaveNewExploreItemRedPoint(data.ChapterEventData) + XEventManager.DispatchEvent(XEventId.EVENT_MAINLINE_EXPLORE_ITEM_GET) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XFubenManager.lua b/Resources/Scripts/XManager/XFubenManager.lua new file mode 100644 index 00000000..2198a94a --- /dev/null +++ b/Resources/Scripts/XManager/XFubenManager.lua @@ -0,0 +1,3096 @@ +XFubenManagerCreator = function() + local XFubenManager = {} + local CSTextManagerGetText = CS.XTextManager.GetText + XFubenManager.StageType = { + Mainline = 1, + Daily = 2, + Tower = 3, + Urgent = 4, + BossSingle = 5, + BossOnline = 6, + Bfrt = 7, + Resource = 8, + BountyTask = 9, + Trial = 10, + Prequel = 11, + Arena = 12, + Experiment = 13, --试验区 + Explore = 14, --探索玩法关卡 + ActivtityBranch = 15, --活动支线副本 + ActivityBossSingle = 16, --活动单挑BOSS + Practice = 17, --教学关卡 + Festival = 18, --节日副本 + BabelTower = 19, -- 巴别塔计划 + RepeatChallenge = 20, --复刷本 + RogueLike = 21, --爬塔玩法 + Assign = 22, -- 边界公约 + UnionKill = 23, --列阵 + ArenaOnline = 24, --合众战局 + ExtraChapter = 25, --番外关卡 + SpecialTrain = 26, --特训关 + InfestorExplore = 27, --感染体玩法 + GuildBoss = 28, --工会boss + Expedition = 29, --虚像地平线 + WorldBoss = 30, --世界Boss + RpgTower = 31, --兵法蓝图 + MaintainerAction = 32, --大富翁 + TRPG = 33, --跑团玩法 + NieR = 34, --尼尔玩法 + ZhouMu = 35, --多周目 + NewCharAct = 36, -- 新角色教学 + Pokemon = 37, --口袋妖怪 + ChessPursuit = 38, --追击玩法 + Stronghold = 39, --超级据点 + SimulatedCombat = 40, --模拟作战 + Hack = 41, --骇入玩法 + PartnerTeaching = 43, --宠物教学 + Reform = 44, --改造关卡 + KillZone = 45, --杀戮无双 + FashionStory = 46, --涂装剧情活动 + CoupleCombat = 47, --双人下场玩法 + SuperTower = 48, --超级爬塔 + } + + XFubenManager.ChapterType = { + TOWER = 1, + YSHTX = 2, + EMEX = 3, + DJHGZD = 4, + BossSingle = 5, + Urgent = 6, + BossOnline = 7, + Resource = 8, + Trial = 9, + ARENA = 10, + Explore = 11, --探索 + ActivtityBranch = 12, --活动支线副本 + ActivityBossSingle = 13, --活动单挑BOSS + Practice = 14, --教学关卡 + GZTX = 15, --日常構造體特訓 + XYZB = 16, --日常稀有裝備 + TPCL = 17, --日常突破材料 + ZBJY = 18, --日常裝備經驗 + LMDZ = 19, --日常螺母大戰 + JNQH = 20, --日常技能强化 + Christmas = 21, --节日活动-圣诞节 + BriefDarkStream = 22, --活动-极地暗流 + ActivityBabelTower = 23, --巴别塔计划 + FestivalNewYear = 24, --新年活动 + RepeatChallenge = 25, --复刷本 + RogueLike = 26, --爬塔 + FoolsDay = 27, --愚人节活动 + Assign = 28, -- 边界公约 + ChinaBoatPreheat = 29, --中国船预热 + ArenaOnline = 30, -- 合众战局 + UnionKill = 31, --列阵 + SpecialTrain = 32, --特训关 + InfestorExplore = 33, -- 感染体玩法 + Expedition = 34, -- 虚像地平线 + WorldBoss = 35, --世界Boss + RpgTower = 36, --兵法蓝图 + MaintainerAction = 37, --大富翁 + NewCharAct = 38, -- 新角色教学 + Pokemon = 39, --口袋战双 + NieR = 40, --尼尔玩法 + ChessPursuit = 41, --追击玩法 + SpringFestivalActivity = 42, --春节活动 + SimulatedCombat = 43, --模拟作战 + Stronghold = 44, --超级据点 + MoeWar = 45, --萌战 + Reform = 46, --改造玩法 + PartnerTeaching = 47, --宠物教学 + FZJQH = 48, --日常辅助机强化 + PokerGuessing = 49, --翻牌猜大小 + Hack = 50, --骇入玩法 + FashionStory = 51, --涂装剧情活动 + KillZone = 52, --杀戮无双 + SuperTower = 53, --超级爬塔 + CoupleCombat = 54, --双人下场玩法玩法 + } + + XFubenManager.ModeType = { + SINGLE = 1, + MULTI = 2, + } + + XFubenManager.ChapterFunctionName = { + [XFubenManager.ChapterType.Trial] = XFunctionManager.FunctionName.FubenChallengeTrial, + [XFubenManager.ChapterType.Explore] = XFunctionManager.FunctionName.FubenExplore, + [XFubenManager.ChapterType.Practice] = XFunctionManager.FunctionName.Practice, + [XFubenManager.ChapterType.ARENA] = XFunctionManager.FunctionName.FubenArena, + [XFubenManager.ChapterType.BossSingle] = XFunctionManager.FunctionName.FubenChallengeBossSingle, + [XFubenManager.ChapterType.Assign] = XFunctionManager.FunctionName.FubenAssign, + [XFubenManager.ChapterType.InfestorExplore] = XFunctionManager.FunctionName.FubenInfesotorExplore, + [XFubenManager.ChapterType.MaintainerAction] = XFunctionManager.FunctionName.MaintainerAction, + [XFubenManager.ChapterType.Stronghold] = XFunctionManager.FunctionName.Stronghold, + [XFubenManager.ChapterType.PartnerTeaching] = XFunctionManager.FunctionName.PartnerTeaching, + } + + local StageCfg = {} + local StageTransformCfg = {} + local StageLevelControlCfg = {} + local FlopRewardTemplates = {} + local StageLevelMap = {} + local StageMultiplayerLevelMap = {} + local MultiChallengeConfigs = {} + + local NotRobotId = 1000000 + -- local RefreshTime = 0 + local PlayerStageData = {} + local AssistSuccess = false + local NeedCheckUiConflict = false + local UnlockHideStages = {} + local NewHideStageId = nil --存储新开启的隐藏关卡的ID + local EnterFightStartTime = 0 + -- CheckPreFight function + local InitStageInfoHandler = {} + local CheckPreFightHandler = {} + local PreFightHandler = {} + local OpenFightLoadingHandler = {} + local CloseFightLoadingHandler = {} + local SettleFightHandler = {} + local ShowSummaryHandler = {} + local FinishFightHandler = {} + local CallFinishFightHandler = {} + local ShowRewardHandler = {} + local CheckReadyToFightHandler = {} + local CheckAutoExitFightHandler = {} + local CheckStageIsPassHandler = {} + local StageInfos = {} + + local METHOD_NAME = { + PreFight = "PreFightRequest", + FightSettle = "FightSettleRequest", + FightWin = "FightWinRequest", + FightLose = "FightLoseRequest", + BuyActionPoint = "BuyActionPointRequest", + RefreshFubenList = "RefreshFubenListRequest", + EnterChallenge = "EnterChallengeRequest", + CheckChallengeCanEnter = "CheckChallengeCanEnterRequest", + GetTowerInfo = "GetTowerInfoRequest", + GetTowerRecommendedList = "GetTowerRecommendedListRequest", + GetTowerChapterReward = "GetTowerChapterRewardRequest", + CheckResetTower = "CheckResetTowerRequest", + GuideComplete = "GuideCompleteRequest", + GetFightData = "GetFightDataRequest", + BOGetBossDataRequest = "BOGetBossDataRequest", + FightReboot = "FightRebootRequest", + FightRestart = "FightRestartRequest" + } + + function XFubenManager.Init() + StageCfg = XFubenConfigs.GetStageCfgs() + StageLevelControlCfg = XFubenConfigs.GetStageLevelControlCfg() + StageTransformCfg = XFubenConfigs.GetStageTransformCfg() + FlopRewardTemplates = XFubenConfigs.GetFlopRewardTemplates() + MultiChallengeConfigs = XFubenConfigs.GetMultiChallengeStageConfigs() + + XFubenManager.DifficultNormal = CS.XGame.Config:GetInt("FubenDifficultNormal") + XFubenManager.DifficultHard = CS.XGame.Config:GetInt("FubenDifficultHard") + XFubenManager.DifficultNightmare = CS.XGame.Config:GetInt("FubenDifficultNightmare") + XFubenManager.StageStarNum = CS.XGame.Config:GetInt("FubenStageStarNum") + XFubenManager.NotGetTreasure = CS.XGame.Config:GetInt("FubenNotGetTreasure") + XFubenManager.GetTreasure = CS.XGame.Config:GetInt("FubenGetTreasure") + XFubenManager.FubenFlopCount = CS.XGame.Config:GetInt("FubenFlopCount") + + XFubenManager.SettleRewardAnimationDelay = CS.XGame.ClientConfig:GetInt("SettleRewardAnimationDelay") + XFubenManager.SettleRewardAnimationInterval = CS.XGame.ClientConfig:GetInt("SettleRewardAnimationInterval") + + XEventManager.AddEventListener(XEventId.EVENT_PLAYER_LEVEL_CHANGE, XFubenManager.InitData) + + XFubenManager.RegisterFubenManager(XFubenManager.StageType.Mainline, XDataCenter.FubenMainLineManager) + XFubenManager.RegisterFubenManager(XFubenManager.StageType.Daily, XDataCenter.FubenDailyManager) + XFubenManager.RegisterFubenManager(XFubenManager.StageType.BossSingle, XDataCenter.FubenBossSingleManager) + XFubenManager.RegisterFubenManager(XFubenManager.StageType.Urgent, XDataCenter.FubenUrgentEventManager) + XFubenManager.RegisterFubenManager(XFubenManager.StageType.Resource, XDataCenter.FubenResourceManager) + XFubenManager.RegisterFubenManager(XFubenManager.StageType.Bfrt, XDataCenter.BfrtManager) + XFubenManager.RegisterFubenManager(XFubenManager.StageType.BountyTask, XDataCenter.BountyTaskManager) + XFubenManager.RegisterFubenManager(XFubenManager.StageType.BossOnline, XDataCenter.FubenBossOnlineManager) + XFubenManager.RegisterFubenManager(XFubenManager.StageType.Prequel, XDataCenter.PrequelManager) + XFubenManager.RegisterFubenManager(XFubenManager.StageType.Trial, XDataCenter.TrialManager) + XFubenManager.RegisterFubenManager(XFubenManager.StageType.Arena, XDataCenter.ArenaManager) + XFubenManager.RegisterFubenManager(XFubenManager.StageType.Explore, XDataCenter.FubenExploreManager) + XFubenManager.RegisterFubenManager(XFubenManager.StageType.ActivtityBranch, XDataCenter.FubenActivityBranchManager) + XFubenManager.RegisterFubenManager(XFubenManager.StageType.ActivityBossSingle, XDataCenter.FubenActivityBossSingleManager) + XFubenManager.RegisterFubenManager(XFubenManager.StageType.Practice, XDataCenter.PracticeManager) + XFubenManager.RegisterFubenManager(XFubenManager.StageType.Festival, XDataCenter.FubenFestivalActivityManager) + XFubenManager.RegisterFubenManager(XFubenManager.StageType.BabelTower, XDataCenter.FubenBabelTowerManager) + XFubenManager.RegisterFubenManager(XFubenManager.StageType.RepeatChallenge, XDataCenter.FubenRepeatChallengeManager) + XFubenManager.RegisterFubenManager(XFubenManager.StageType.RogueLike, XDataCenter.FubenRogueLikeManager) + XFubenManager.RegisterFubenManager(XFubenManager.StageType.Assign, XDataCenter.FubenAssignManager) + XFubenManager.RegisterFubenManager(XFubenManager.StageType.ArenaOnline, XDataCenter.ArenaOnlineManager) + XFubenManager.RegisterFubenManager(XFubenManager.StageType.UnionKill, XDataCenter.FubenUnionKillManager) + XFubenManager.RegisterFubenManager(XFubenManager.StageType.ExtraChapter, XDataCenter.ExtraChapterManager) + XFubenManager.RegisterFubenManager(XFubenManager.StageType.SpecialTrain, XDataCenter.FubenSpecialTrainManager) + XFubenManager.RegisterFubenManager(XFubenManager.StageType.InfestorExplore, XDataCenter.FubenInfestorExploreManager) + XFubenManager.RegisterFubenManager(XFubenManager.StageType.GuildBoss, XDataCenter.GuildBossManager) + XFubenManager.RegisterFubenManager(XFubenManager.StageType.Expedition, XDataCenter.ExpeditionManager) + XFubenManager.RegisterFubenManager(XFubenManager.StageType.WorldBoss, XDataCenter.WorldBossManager) + XFubenManager.RegisterFubenManager(XFubenManager.StageType.RpgTower, XDataCenter.RpgTowerManager) + XFubenManager.RegisterFubenManager(XFubenManager.StageType.MaintainerAction, XDataCenter.MaintainerActionManager) + XFubenManager.RegisterFubenManager(XFubenManager.StageType.TRPG, XDataCenter.TRPGManager) + XFubenManager.RegisterFubenManager(XFubenManager.StageType.NieR, XDataCenter.NieRManager) + XFubenManager.RegisterFubenManager(XFubenManager.StageType.ZhouMu, XDataCenter.FubenZhouMuManager) + XFubenManager.RegisterFubenManager(XFubenManager.StageType.Experiment, XDataCenter.FubenExperimentManager) + XFubenManager.RegisterFubenManager(XFubenManager.StageType.NewCharAct, XDataCenter.FubenNewCharActivityManager) + XFubenManager.RegisterFubenManager(XFubenManager.StageType.Pokemon, XDataCenter.PokemonManager) + XFubenManager.RegisterFubenManager(XFubenManager.StageType.ChessPursuit, XDataCenter.ChessPursuitManager) + XFubenManager.RegisterFubenManager(XFubenManager.StageType.SimulatedCombat, XDataCenter.FubenSimulatedCombatManager) + XFubenManager.RegisterFubenManager(XFubenManager.StageType.Stronghold, XDataCenter.StrongholdManager) + XFubenManager.RegisterFubenManager(XFubenManager.StageType.Reform, XDataCenter.ReformActivityManager) + XFubenManager.RegisterFubenManager(XFubenManager.StageType.PartnerTeaching, XDataCenter.PartnerTeachingManager) + XFubenManager.RegisterFubenManager(XFubenManager.StageType.Hack, XDataCenter.FubenHackManager) + XFubenManager.RegisterFubenManager(XFubenManager.StageType.CoupleCombat, XDataCenter.FubenCoupleCombatManager) + XFubenManager.RegisterFubenManager(XFubenManager.StageType.KillZone, XDataCenter.KillZoneManager) + XFubenManager.RegisterFubenManager(XFubenManager.StageType.FashionStory, XDataCenter.FashionStoryManager) + XFubenManager.RegisterFubenManager(XFubenManager.StageType.SuperTower, XDataCenter.SuperTowerManager) + + XFubenManager.InitStageLevelMap() + XFubenManager.InitStageMultiplayerLevelMap() + end + + function XFubenManager.RegisterFubenManager(type, manager) + if manager.InitStageInfo then + InitStageInfoHandler[type] = manager.InitStageInfo + end + if manager.CheckPreFight then + CheckPreFightHandler[type] = manager.CheckPreFight + end + + if manager.PreFight then + PreFightHandler[type] = manager.PreFight + end + if manager.FinishFight then + FinishFightHandler[type] = manager.FinishFight + end + if manager.CallFinishFight then + CallFinishFightHandler[type] = manager.CallFinishFight + end + if manager.OpenFightLoading then + OpenFightLoadingHandler[type] = manager.OpenFightLoading + end + if manager.CloseFightLoading then + CloseFightLoadingHandler[type] = manager.CloseFightLoading + end + if manager.ShowSummary then + ShowSummaryHandler[type] = manager.ShowSummary + end + if manager.SettleFight then + SettleFightHandler[type] = manager.SettleFight + end + if manager.CheckReadyToFight then + CheckReadyToFightHandler[type] = manager.CheckReadyToFight + end + if manager.CheckAutoExitFight then + CheckAutoExitFightHandler[type] = manager.CheckAutoExitFight + end + + if manager.ShowReward then + ShowRewardHandler[type] = manager.ShowReward + end + + if manager.CheckPassedByStageId then + CheckStageIsPassHandler[type] = manager.CheckPassedByStageId + end + end + + function XFubenManager.InitStageLevelMap() + StageLevelMap = {} + local tmpDict = {} + + XTool.LoopMap(StageLevelControlCfg, function(key, v) + if not tmpDict[v.StageId] then + tmpDict[v.StageId] = {} + end + table.insert(tmpDict[v.StageId], v) + end) + + for k, list in pairs(tmpDict) do + table.sort(list, function(a, b) + return a.MaxLevel < b.MaxLevel + end) + local tmpByLevel = {} + local index = 1 + for i = 1, XPlayerManager.PlayerMaxLevel do + if i > list[index].MaxLevel then + index = index + 1 + if index > #list then + break + end + end + tmpByLevel[i] = list[index] + end + StageLevelMap[k] = tmpByLevel + end + end + + function XFubenManager.InitStageMultiplayerLevelMap() + local config = XFubenConfigs.GetStageMultiplayerLevelControlCfg() + StageMultiplayerLevelMap = {} + for _, v in pairs(config) do + if not StageMultiplayerLevelMap[v.StageId] then + StageMultiplayerLevelMap[v.StageId] = {} + end + StageMultiplayerLevelMap[v.StageId][v.Difficulty] = v + end + end + + function XFubenManager.GetStageCfg(stageId) + if not StageCfg[stageId] then + XLog.ErrorTableDataNotFound("XFubenManager.GetStageCfg", "StageCfg", "Share/Fuben/Stage.tab", "stageId", tostring(stageId)) + return + end + return StageCfg[stageId] + end + + function XFubenManager.GetStageOrderId(stageId) + local cfg = XFubenManager.GetStageCfg(stageId) + if not cfg then return end + return cfg.OrderId + end + function XFubenManager.GetStageRebootId(stageId) + if not StageCfg[stageId] then + return 0 + end + return StageCfg[stageId].RebootId + end + + -- 战斗cs调用 + function XFubenManager.GetStageOnlineMsgId(stageId) + if not StageCfg[stageId] then + return 0 + end + return StageCfg[stageId].OnlineMsgId + end + + -- CS CALL + function XFubenManager.GetStageForceAllyEffect(stageId) + if not StageCfg[stageId] then + return false + end + return StageCfg[stageId].ForceAllyEffect + end + + function XFubenManager.GetStageName(stageId) + local config = XFubenManager.GetStageCfg(stageId) + return config.Name + end + + function XFubenManager.GetStageIcon(stageId) + local config = XFubenManager.GetStageCfg(stageId) + return config.Icon + end + + function XFubenManager.GetStageDes(stageId) + local config = XFubenManager.GetStageCfg(stageId) + return config.Description + end + + function XFubenManager.GetStageResetHpCounts(stageId) + if not StageCfg[stageId] then + return {} + end + if #StageCfg[stageId].ResetHpCount == 1 or #StageCfg[stageId].ResetHpCount == 2 then + XLog.Error("XFubenManager 修改怪物血条数量数组长度异常!stageId " .. tostring(stageId)) + end + local resetHpCount = {} + for i = 1, #StageCfg[stageId].ResetHpCount do + resetHpCount[i] = StageCfg[stageId].ResetHpCount[i] + end + return resetHpCount + end + + function XFubenManager.GetStageTransformCfg(stageId) + if not StageTransformCfg[stageId] then + XLog.ErrorTableDataNotFound("XFubenManager.GetStageTransformCfg", + "StageTransformCfg", "Share/Fuben/StageTransform.tab", "stageId", tostring(stageId)) + return + end + return StageTransformCfg[stageId] + end + + function XFubenManager.GetStageBgmId(stageId) + if not StageCfg[stageId] then + return 0 + end + return StageCfg[stageId].BgmId + end + + function XFubenManager.GetStageAmbientSound(stageId) + if not StageCfg[stageId] then + return 0 + end + return StageCfg[stageId].AmbientSound + end + + function XFubenManager.GetStageMaxChallengeNums(stageId) + return StageCfg[stageId] and StageCfg[stageId].MaxChallengeNums or 0 + end + + function XFubenManager.GetStageBuyChallengeCount(stageId) + return StageCfg[stageId] and StageCfg[stageId].BuyChallengeCount or 0 + end + + function XFubenManager.GetConditonByMapId(stageId) + local suggestedConditionIds, forceConditionIds = {}, {} + if StageCfg[stageId] then + suggestedConditionIds = StageCfg[stageId].SuggestedConditionId + forceConditionIds = StageCfg[stageId].ForceConditionId + end + return suggestedConditionIds, forceConditionIds + end + + local GetStarsCount = function(starsMark) + local count = (starsMark & 1) + (starsMark & 2 > 0 and 1 or 0) + (starsMark & 4 > 0 and 1 or 0) + local map = {(starsMark & 1) > 0, (starsMark & 2) > 0, (starsMark & 4) > 0 } + return count, map + end + + function XFubenManager.InitFubenData(fubenData) + -- 玩家数据 + if fubenData then + if fubenData.StageData then + for key, value in pairs(fubenData.StageData) do + PlayerStageData[key] = value + -- XEventManager.DispatchEvent(XEventId.EVENT_FUBEN_STAGE_SYNC, key) + end + end + -- if fubenData.FubenBaseData and fubenData.FubenBaseData.RefreshTime > 0 then + -- RefreshTime = fubenData.FubenBaseData.RefreshTime + -- end + if fubenData.UnlockHideStages then + for _, v in pairs(fubenData.UnlockHideStages) do + UnlockHideStages[v] = true + end + end + end + XFubenManager.InitData() + end + + function XFubenManager.InitData(checkNewUnlock) + local oldStageInfos = StageInfos + + XFubenManager.InitStageInfo() + for _, v in pairs(InitStageInfoHandler) do + v(checkNewUnlock) + end + XFubenManager.InitStageInfoNextStageId() + -- 发送关卡刷新事件 + XEventManager.DispatchEvent(XEventId.EVENT_FUBEN_REFRESH_STAGE_DATA) + + -- 检查新关卡事件 + if checkNewUnlock then + for k, v in pairs(StageInfos) do + if v.Unlock and not oldStageInfos[k].Unlock then + XEventManager.DispatchEvent(XEventId.EVENT_FUBEN_NEW_STAGE, k) + end + end + end + end + + function XFubenManager.InitStageInfo() + -- stage + StageInfos = {} + for stageId, stageCfg in pairs(StageCfg) do + local info = {} + StageInfos[stageId] = info + info.HaveAssist = stageCfg.HaveAssist + info.IsMultiplayer = stageCfg.IsMultiplayer + if PlayerStageData[stageId] then + info.Passed = PlayerStageData[stageId].Passed + info.Stars, info.StarsMap = GetStarsCount(PlayerStageData[stageId].StarsMark) + else + info.Passed = false + info.Stars = 0 + info.StarsMap = {false, false, false } + end + info.Unlock = true + info.IsOpen = true + info.Type = stageCfg.StageType ~= 0 and stageCfg.StageType or nil + if stageCfg.RequireLevel > 0 and XPlayer.Level < stageCfg.RequireLevel then + info.Unlock = false + end + for _, preStageId in pairs(stageCfg.PreStageId or {}) do + if preStageId > 0 then + if not PlayerStageData[preStageId] or not PlayerStageData[preStageId].Passed then + info.Unlock = false + info.IsOpen = false + break + end + end + end + info.TotalStars = 3 + end + end + + function XFubenManager.InitStageInfoNextStageId() + for _, v in pairs(StageCfg) do + for _, preStageId in pairs(v.PreStageId) do + local preStageInfo = XFubenManager.GetStageInfo(preStageId) + if preStageInfo then + if not (v.StageType == XFubenConfigs.STAGETYPE_STORYEGG or v.StageType == XFubenConfigs.STAGETYPE_FIGHTEGG) then + preStageInfo.NextStageId = v.StageId + end + else + XLog.Error("XFubenManager.InitStageInfoNextStageId error:初始化前置关卡信息失败, 请检查Stage.tab, preStageId: " .. preStageId) + end + end + end + end + + function XFubenManager.IsPreStageIdContains(preStageId, stageId) + for _, v in pairs(preStageId or {}) do + if v == stageId then return true end + end + return false + end + + -- 获取每个关卡的星星、次数等数据 + function XFubenManager.GetStageInfo(stageId) + return StageInfos[stageId] + end + + function XFubenManager.GetStageInfos() + return StageInfos + end + + function XFubenManager.UpdateStageStarsInfo(data) + if data == nil or type(data) ~= "table" then + return + end + for _, v in pairs(data) do + StageInfos[v.StageId].Stars, StageInfos[v.StageId].StarsMap = GetStarsCount(v.StarsMark) + end + end + + function XFubenManager.GetStageData(stageId) + return PlayerStageData[stageId] + end + + function XFubenManager.GetStageName(stageId) + local cfg = StageCfg[stageId] + return cfg and cfg.Name + end + + function XFubenManager.GetStageNameLevel(stageId) + local curStageOrderId + local curChapterOrderId + local stageInfo + stageInfo = XFubenManager.GetStageInfo(stageId) + if stageInfo and stageInfo.ChapterId then + local chapter = XDataCenter.FubenMainLineManager.GetChapterCfg(stageInfo.ChapterId) + curStageOrderId = stageInfo.OrderId + curChapterOrderId = chapter.OrderId + if curStageOrderId and curChapterOrderId then + return "【" .. curChapterOrderId .. "-" .. curStageOrderId .. "】" .. XFubenManager.GetStageName(stageId) + end + end + return XFubenManager.GetStageName(stageId) + end + + function XFubenManager.GetActivityChaptersBySort() + local chapters = XTool.MergeArray( + XDataCenter.FubenBossOnlineManager.GetBossOnlineChapters()--联机boss + , XDataCenter.FubenActivityBranchManager.GetActivitySections()--副本支线活动 + , XDataCenter.FubenActivityBossSingleManager.GetActivitySections()--单挑BOSS活动 + , XDataCenter.FubenFestivalActivityManager.GetAvailableFestivals()--节日活动副本 + , XDataCenter.FubenBabelTowerManager.GetBabelTowerSection()--巴别塔计划 + , XDataCenter.FubenRepeatChallengeManager.GetActivitySections()--复刷本 + , XDataCenter.FubenRogueLikeManager.GetRogueLikeSection()--爬塔系统 + -- , XDataCenter.ArenaOnlineManager.GetArenaOnlineChapters() -- 删除合众战局玩法 + , XDataCenter.FubenUnionKillManager.GetUnionKillActivity()--狙击战 + , XDataCenter.FubenSpecialTrainManager.GetSpecialTrainAcitity()--特训关 + , XDataCenter.ExpeditionManager.GetActivityChapters()--虚像地平线 + , XDataCenter.WorldBossManager.GetWorldBossSection()--世界Boss + , XDataCenter.RpgTowerManager.GetActivityChapters()--兵法蓝图 + , XDataCenter.NieRManager.GetActivityChapters()--尼尔玩法 + , XDataCenter.FubenNewCharActivityManager.GetAvailableActs()-- 新角色预热活动 + , XDataCenter.FubenSimulatedCombatManager.GetAvailableActs()-- 模拟作战 + , XDataCenter.FubenHackManager.GetAvailableActs()-- 骇入玩法 + , XDataCenter.PokemonManager.GetActivityChapters()--口袋战双 + , XDataCenter.ChessPursuitManager.GetActivityChapters()--追击玩法 + , XDataCenter.MoeWarManager.GetActivityChapter() -- 萌战玩法 + , XDataCenter.ReformActivityManager.GetAvailableChapters() -- 改造玩法 + , XDataCenter.PokerGuessingManager.GetChapters() --翻牌猜大小 + , XDataCenter.KillZoneManager.GetActivityChapters() --杀戮无双 + , XDataCenter.FashionStoryManager.GetActivityChapters() -- 系列涂装剧情活动 + , XDataCenter.SuperTowerManager.GetActivityChapters() --超级爬塔活动 + , XDataCenter.FubenCoupleCombatManager.GetAvailableActs()-- 骇入玩法 + ) + table.sort(chapters, function(a, b) + local priority1 = XFubenConfigs.GetActivityPriorityByActivityIdAndType(a.Id, a.Type) + local priority2 = XFubenConfigs.GetActivityPriorityByActivityIdAndType(b.Id, b.Type) + return priority1 > priority2 + end) + + return chapters + end + + function XFubenManager.GetChallengeChapters() + local list = {} + local isTrialFinish = false + local isExploreFinishAll = false + local exploreChapters = nil + local arenaChapters + local bossSingleChapters + local practiceChapters + local trialChapters + local assignChapter + local isOpen + --如果完成了全部探索需要把探索拍到最后 + isOpen = not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.FubenExplore) + if isOpen then + exploreChapters = XFubenConfigs.GetChapterBannerByType(XFubenManager.ChapterType.Explore) + if exploreChapters.IsOpen and exploreChapters.IsOpen == 1 then + if not XDataCenter.FubenExploreManager.IsFinishAll() then + table.insert(list, exploreChapters) + else + isExploreFinishAll = true + end + end + end + + isOpen = not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.FubenArena) + if isOpen then + arenaChapters = XFubenConfigs.GetChapterBannerByType(XFubenManager.ChapterType.ARENA) + if arenaChapters.IsOpen and arenaChapters.IsOpen == 1 then + table.insert(list, arenaChapters) + end + end + + isOpen = not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.FubenChallengeBossSingle) + if isOpen then + bossSingleChapters = XFubenConfigs.GetChapterBannerByType(XFubenManager.ChapterType.BossSingle) + if bossSingleChapters.IsOpen and bossSingleChapters.IsOpen == 1 then + table.insert(list, bossSingleChapters) + end + end + + isOpen = not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.Practice) + if isOpen then + practiceChapters = XFubenConfigs.GetChapterBannerByType(XFubenManager.ChapterType.Practice) + if practiceChapters.IsOpen and practiceChapters.IsOpen == 1 then + table.insert(list, practiceChapters) + end + end + + isOpen = not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.FubenChallengeTrial) + if isOpen then + trialChapters = XFubenConfigs.GetChapterBannerByType(XFubenManager.ChapterType.Trial) + if trialChapters and trialChapters.IsOpen and trialChapters.IsOpen == 1 then + if XDataCenter.TrialManager.EntranceOpen() then + table.insert(list, trialChapters) + else + isTrialFinish = true + end + end + end + + isOpen = not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.FubenAssign) + if isOpen then + assignChapter = XFubenConfigs.GetChapterBannerByType(XFubenManager.ChapterType.Assign) + if assignChapter and assignChapter.IsOpen == 1 then + table.insert(list, assignChapter) + end + end + + isOpen = not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.FubenInfesotorExplore) + and XDataCenter.FubenInfestorExploreManager.IsOpen() + if isOpen then + local chapter = XFubenConfigs.GetChapterBannerByType(XFubenManager.ChapterType.InfestorExplore) + if chapter and chapter.IsOpen == 1 then + table.insert(list, chapter) + end + end + + isOpen = not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.MaintainerAction) + if isOpen then--要时间控制 + local IsStart = XDataCenter.MaintainerActionManager.IsStart() + local chapter = XFubenConfigs.GetChapterBannerByType(XFubenManager.ChapterType.MaintainerAction) + if IsStart and chapter and chapter.IsOpen == 1 then + table.insert(list, chapter) + end + end + + isOpen = not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.Stronghold) + and XDataCenter.StrongholdManager.IsOpen() + if isOpen then + local chapter = XFubenConfigs.GetChapterBannerByType(XFubenManager.ChapterType.Stronghold) + if chapter and chapter.IsOpen == 1 then + table.insert(list, chapter) + end + end + + isOpen = not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.PartnerTeaching) + if isOpen then + local chapter = XFubenConfigs.GetChapterBannerByType(XFubenManager.ChapterType.PartnerTeaching) + if chapter and chapter.IsOpen == 1 then + table.insert(list, chapter) + end + end + + table.sort(list, function(chapterA, chapterB) + local weightA = XFunctionManager.JudgeCanOpen(XFubenManager.ChapterFunctionName[chapterA.Type]) and 1 or 0 + local weightB = XFunctionManager.JudgeCanOpen(XFubenManager.ChapterFunctionName[chapterB.Type]) and 1 or 0 + if weightA == weightB then + return chapterA.Priority < chapterB.Priority + end + return weightA > weightB + end) + + if isTrialFinish then + table.insert(list, trialChapters) + end + + --如果完成了全部探索需要把探索排到最后 + if isExploreFinishAll then + table.insert(list, exploreChapters) + end + return list + end + + + function XFubenManager.GetDailyDungeonRules() + local dailyDungeonRules = XDailyDungeonConfigs.GetDailyDungeonRulesList() + + local tmpDataList = {} + + for _, v in pairs(dailyDungeonRules) do + local tmpData = {} + local tmpDay = XDataCenter.FubenDailyManager.IsDayLock(v.Id) + local tmpCon = XDataCenter.FubenDailyManager.GetConditionData(v.Id).IsLock + local tmpOpen = XDataCenter.FubenDailyManager.GetEventOpen(v.Id).IsOpen + tmpData.Lock = tmpCon or (tmpDay and not tmpOpen) + tmpData.Rule = v + tmpData.Open = tmpOpen and not tmpCon + if not XFunctionManager.CheckFunctionFitter(XDataCenter.FubenDailyManager.GetConditionData(v.Id).functionNameId) then + table.insert(tmpDataList, tmpData) + end + end + + table.sort(tmpDataList, function(a, b) + if not a.Lock and not b.Lock then + if (a.Open and b.Open) or (not a.Open and not b.Open) then + return a.Rule.Priority < b.Rule.Priority + else + return a.Open and not b.Open + end + elseif a.Lock and b.Lock then + return a.Rule.Priority < b.Rule.Priority + else + return not a.Lock and b.Lock + end + end) + + + dailyDungeonRules = {} + for _, v in pairs(tmpDataList) do + table.insert(dailyDungeonRules, v.Rule) + end + + return dailyDungeonRules + end + + function XFubenManager.GetDailyDungeonRule(Id) + local dailyDungeonRules = XDailyDungeonConfigs.GetDailyDungeonRulesList() + return dailyDungeonRules[Id] + end + + function XFubenManager.CheckFightCondition(conditionIds, teamId) + if #conditionIds <= 0 then + return true + end + + local teamData = nil + if teamId then + teamData = XDataCenter.TeamManager.GetTeamData(teamId) + end + + for _, id in pairs(conditionIds) do + local ret, desc = XConditionManager.CheckCondition(id, teamData) + if not ret then + XUiManager.TipError(desc) + return false + end + end + return true + end + + function XFubenManager.CheckFightConditionByTeamData(conditionIds, teamData) + if #conditionIds <= 0 then + return true + end + + for _, id in pairs(conditionIds) do + local ret, desc = XConditionManager.CheckCondition(id, teamData) + if not ret then + XUiManager.TipError(desc) + return false + end + end + return true + end + + function XFubenManager.CheckPreFightBase(stage, challengeCount) + challengeCount = challengeCount or 1 + + -- 检测前置副本 + local stageId = stage.StageId + local stageInfo = XFubenManager.GetStageInfo(stageId) + if not stageInfo.Unlock then + XUiManager.TipMsg(XFubenManager.GetFubenOpenTips(stageId)) + return false + end + + -- 翻牌额外体力 + local flopRewardId = stage.FlopRewardId + local flopRewardTemplate = FlopRewardTemplates[flopRewardId] + if flopRewardTemplate and XDataCenter.ItemManager.CheckItemCountById(flopRewardTemplate.ConsumeItemId, flopRewardTemplate.ConsumeItemCount) then + if flopRewardTemplate.ExtraActionPoint > 0 then + local cost = challengeCount * (stage.RequireActionPoint + flopRewardTemplate.ExtraActionPoint) + if not XDataCenter.ItemManager.DoNotEnoughBuyAsset(XDataCenter.ItemManager.ItemId.ActionPoint, + cost, + 1, + function() XFubenManager.CheckPreFightBase(stage) end, + "FubenActionPointNotEnough") then + return false + end + end + end + + -- 检测体力 + if stage.RequireActionPoint > 0 then + local cost = challengeCount * stage.RequireActionPoint + if not XDataCenter.ItemManager.DoNotEnoughBuyAsset(XDataCenter.ItemManager.ItemId.ActionPoint, + cost, + 1, + function() XFubenManager.CheckPreFightBase(stage) end, + "FubenActionPointNotEnough") then + return false + end + end + + return true + end + + function XFubenManager.CheckCanFlop(stageId) + local stage = XFubenManager.GetStageCfg(stageId) + local flopRewardId = stage.FlopRewardId + local flopRewardTemplate = FlopRewardTemplates[flopRewardId] + if not flopRewardTemplate then + return false + end + + if flopRewardTemplate.ConsumeItemId > 0 then + if not XDataCenter.ItemManager.CheckItemCountById(flopRewardTemplate.ConsumeItemId, flopRewardTemplate.ConsumeItemCount) then + return false + end + end + + return true + end + + function XFubenManager.GetStageActionPointConsume(stageId) + local stage = XFubenManager.GetStageCfg(stageId) + local flopRewardId = stage.FlopRewardId + local flopRewardTemplate = FlopRewardTemplates[flopRewardId] + + -- 没配翻牌 + if not flopRewardTemplate then + return stage.RequireActionPoint + end + + -- 翻牌道具不足 + if not XFubenManager.CheckCanFlop(stageId) then + return stage.RequireActionPoint + end + + return stage.RequireActionPoint + flopRewardTemplate.ExtraActionPoint + end + + function XFubenManager.GetFlopShowId(stageId) + local stage = XFubenManager.GetStageCfg(stageId) + local flopRewardId = stage.FlopRewardId + local flopRewardTemplate = FlopRewardTemplates[flopRewardId] + return flopRewardTemplate and flopRewardTemplate.ShowRewardId or 0 + end + + function XFubenManager.GetFlopConsumeItemId(stageId) + local stage = XFubenManager.GetStageCfg(stageId) + local flopRewardId = stage.FlopRewardId + local flopRewardTemplate = FlopRewardTemplates[flopRewardId] + return flopRewardTemplate and flopRewardTemplate.ConsumeItemId or 0 + end + + function XFubenManager.CheckPreFight(stage, challengeCount, autoFight) + -- 当自动作战时,无需检测自定义按键冲突 + if not autoFight and XFubenManager.CheckCustomUiConflict() then return end + challengeCount = challengeCount or 1 + if not XFubenManager.CheckPreFightBase(stage, challengeCount) then + return false + end + + local stageId = stage.StageId + local stageInfo = XFubenManager.GetStageInfo(stageId) + if CheckPreFightHandler[stageInfo.Type] then + return CheckPreFightHandler[stageInfo.Type](stage, challengeCount) + end + return true + end + + -- 在进入战斗前,构建PreFightData请求XFightData + function XFubenManager.PreFight(stage, teamId, isAssist, challengeCount, challengeId) + local preFight = {} + preFight.CardIds = {} + preFight.StageId = stage.StageId + preFight.IsHasAssist = isAssist and true or false + preFight.ChallengeCount = challengeCount or 1 + local isExpedition = XDataCenter.ExpeditionManager.CheckStageIsExpedition(stage.StageId) + local isArenaOnline = XDataCenter.ArenaOnlineManager.CheckStageIsArenaOnline(stage.StageId) + local isSimulatedCombat = XDataCenter.FubenSimulatedCombatManager.CheckStageIsSimulatedCombat(stage.StageId) + -- 如果有试玩角色,则不读取玩家队伍信息 + if not stage.RobotId or #stage.RobotId <= 0 and not isExpedition then + local teamData = XDataCenter.TeamManager.GetTeamData(teamId) + for _, v in pairs(teamData) do + table.insert(preFight.CardIds, v) + end + preFight.CaptainPos = XDataCenter.TeamManager.GetTeamCaptainPos(teamId) + preFight.FirstFightPos = XDataCenter.TeamManager.GetTeamFirstFightPos(teamId) + elseif isExpedition then + preFight.RobotIds = {} + local teamData = XDataCenter.TeamManager.GetTeamData(teamId) + for i in pairs(teamData) do + local eChara = XDataCenter.ExpeditionManager.GetCharaByEBaseId(teamData[i]) + preFight.RobotIds[i] = eChara and eChara:GetRobotId() or 0 + end + preFight.CaptainPos = XDataCenter.TeamManager.GetTeamCaptainPos(teamId) + preFight.FirstFightPos = XDataCenter.TeamManager.GetTeamFirstFightPos(teamId) + end + if isArenaOnline then + preFight.StageLevel = XDataCenter.ArenaOnlineManager.GetSingleModeDifficulty(challengeId, true) + end + if isSimulatedCombat then + preFight.RobotIds = {} + for i, v in ipairs(preFight.CardIds) do + local data = XDataCenter.FubenSimulatedCombatManager.GetCurStageMemberDataByCharId(v) + if data then + preFight.RobotIds[i] = data.RobotId + else + preFight.RobotIds[i] = 0 + end + end + preFight.CardIds = nil + end + + return preFight + end + + function XFubenManager.EnterFight(stage, teamId, isAssist, challengeCount, challengeId) + if not XFubenManager.CheckPreFight(stage, challengeCount) then + return + end + --检测是否赏金前置战斗 + local isBountyTaskFight, task = XDataCenter.BountyTaskManager.CheckBountyTaskPreFightWithStatus(stage.StageId) + if isBountyTaskFight then + XDataCenter.BountyTaskManager.RecordPreFightData(task.Id, teamId) + end + local stageInfo = XFubenManager.GetStageInfo(stage.StageId) + local preFight + if PreFightHandler[stageInfo.Type] then + preFight = PreFightHandler[stageInfo.Type](stage, teamId, isAssist, challengeCount, challengeId) + else + preFight = XFubenManager.PreFight(stage, teamId, isAssist, challengeCount, challengeId) + end + XNetwork.Call(METHOD_NAME.PreFight, { PreFightData = preFight }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local fightData = res.FightData + local stageInfo = XFubenManager.GetStageInfo(fightData.StageId) + local isKeepPlayingStory = stage and XFubenConfigs.IsKeepPlayingStory(stage.StageId) and (stage.BeginStoryId) + local isNotPass = stage and stage.BeginStoryId and (not stageInfo or not stageInfo.Passed) + if isKeepPlayingStory or isNotPass then + -- 播放剧情,进入战斗 + XEventManager.DispatchEvent(XEventId.EVENT_FIGHT_BEGIN_PLAYMOVIE) + + XDataCenter.MovieManager.PlayMovie(stage.BeginStoryId, function() + XFubenManager.EnterRealFight(preFight, fightData) + end) + + else + -- 直接进入战斗 + XFubenManager.EnterRealFight(preFight, fightData) + end + end) + end + + -- 狙击战战斗 + function XFubenManager.EnterUnionKillFight(stage, curTeam, teamCache, func) + if not XFubenManager.CheckPreFight(stage) then + return + end + + -- 队长检查 + local caption = curTeam.CaptainPos + local captionId = curTeam.TeamData[caption] + if captionId == nil or captionId <= 0 then + XUiManager.TipText("TeamManagerCheckCaptainNil") + return + end + + local preFight = {} + preFight.CardIds = {} + preFight.StageId = stage.StageId + preFight.CaptainPos = curTeam.CaptainPos + for _, v in pairs(curTeam.TeamData or {}) do + table.insert(preFight.CardIds, v) + end + preFight.ShareCardInfos = {} + for _, teamItem in pairs(teamCache or {}) do + table.insert(preFight.ShareCardInfos, { + CardId = teamItem.CharacterId, + PlayerId = teamItem.PlayerId + }) + end + + local req = { PreFightData = preFight } + XNetwork.Call(METHOD_NAME.PreFight, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + if func then + func() + end + + local fightData = res.FightData + local stageInfo = XFubenManager.GetStageInfo(fightData.StageId) + local isKeepPlayingStory = stage and XFubenConfigs.IsKeepPlayingStory(stage.StageId) and (stage.BeginStoryId) + local isNotPass = stage and stage.BeginStoryId and (not stageInfo or not stageInfo.Passed) + if isKeepPlayingStory or isNotPass then + XEventManager.DispatchEvent(XEventId.EVENT_FIGHT_BEGIN_PLAYMOVIE) + XDataCenter.MovieManager.PlayMovie(stage.BeginStoryId, function() + XFubenManager.EnterRealFight(preFight, fightData) + end) + else + XFubenManager.EnterRealFight(preFight, fightData) + end + XDataCenter.FubenUnionKillManager.UpdateChallengeStageById(stage.StageId) + end) + + end + + -- 追击玩法 + function XFubenManager.EnterChessPursuitFight(stage, preFight, callBack) + XNetwork.Call(METHOD_NAME.PreFight, { PreFightData = preFight }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local fightData = res.FightData + local stageInfo = XFubenManager.GetStageInfo(fightData.StageId) + local isKeepPlayingStory = stage and XFubenConfigs.IsKeepPlayingStory(stage.StageId) and (stage.BeginStoryId) + local isNotPass = stage and stage.BeginStoryId and (not stageInfo or not stageInfo.Passed) + if isKeepPlayingStory or isNotPass then + -- 播放剧情,进入战斗 + XEventManager.DispatchEvent(XEventId.EVENT_FIGHT_BEGIN_PLAYMOVIE) + + XDataCenter.MovieManager.PlayMovie(stage.BeginStoryId, function() + if callBack then + callBack() + end + XFubenManager.EnterRealFight(preFight, fightData) + end) + else + if callBack then + callBack() + end + -- 直接进入战斗 + XFubenManager.EnterRealFight(preFight, fightData, true) + end + end) + end + + -- 世界boss + function XFubenManager.EnterWorldBossFight(stage, curTeam, stageLevel) + local preFight = {} + preFight.CardIds = {} + preFight.StageId = stage.StageId + preFight.CaptainPos = curTeam.CaptainPos + preFight.FirstFightPos = curTeam.FirstFightPos + preFight.RobotIds = {} + preFight.StageLevel = stageLevel + for _, v in pairs(curTeam.TeamData or {}) do-----------zhangshuang + if not XRobotManager.CheckIsRobotId(v) then + table.insert(preFight.CardIds, v) + table.insert(preFight.RobotIds, 0) + else + local cardId = XRobotManager.GetCharacterId(v) + table.insert(preFight.CardIds, cardId) + table.insert(preFight.RobotIds, v) + end + end + + XNetwork.Call(METHOD_NAME.PreFight, { PreFightData = preFight }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local fightData = res.FightData + local stageInfo = XFubenManager.GetStageInfo(fightData.StageId) + local isKeepPlayingStory = stage and XFubenConfigs.IsKeepPlayingStory(stage.StageId) and (stage.BeginStoryId) + local isNotPass = stage and stage.BeginStoryId and (not stageInfo or not stageInfo.Passed) + if isKeepPlayingStory or isNotPass then + -- 播放剧情,进入战斗 + XEventManager.DispatchEvent(XEventId.EVENT_FIGHT_BEGIN_PLAYMOVIE) + + XDataCenter.MovieManager.PlayMovie(stage.BeginStoryId, function() + XFubenManager.EnterRealFight(preFight, fightData) + end) + + else + -- 直接进入战斗 + XFubenManager.EnterRealFight(preFight, fightData) + end + end) + end + + -- 跑团世界boss + function XFubenManager.EnterTRPGWorldBossFight(stage, curTeam) + if not XFubenManager.CheckPreFight(stage) then + return + end + local preFight = {} + preFight.CardIds = {} + preFight.StageId = stage.StageId + preFight.CaptainPos = curTeam.CaptainPos + preFight.FirstFightPos = curTeam.FirstFightPos + preFight.RobotIds = {} + for _, v in pairs(curTeam.TeamData or {}) do + if v > NotRobotId then + table.insert(preFight.CardIds, v) + table.insert(preFight.RobotIds, 0) + else + local cardId = XRobotManager.GetCharacterId(v) + table.insert(preFight.CardIds, cardId) + table.insert(preFight.RobotIds, v) + end + end + + XNetwork.Call(METHOD_NAME.PreFight, { PreFightData = preFight }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local fightData = res.FightData + local stageInfo = XFubenManager.GetStageInfo(fightData.StageId) + XFubenManager.EnterRealFight(preFight, fightData) + end) + end + + -- 爬塔战斗 + function XFubenManager.EnterRogueLikeFight(stage, curTeam, isAssist, nodeId, func) + if not XFubenManager.CheckPreFight(stage) then + return + end + + local preFight = {} + preFight.CardIds = {} + preFight.StageId = stage.StageId + preFight.RogueLikeNodeId = nodeId + preFight.IsHasAssist = false + preFight.AssistType = isAssist + preFight.CaptainPos = curTeam.CaptainPos + preFight.FirstFightPos = curTeam.FirstFightPos + for _, v in pairs(curTeam.TeamData or {}) do + table.insert(preFight.CardIds, v) + end + + -- 助战机器人、调换队长位置 + if isAssist == 1 then + local captainPos = curTeam.CaptainPos + if captainPos ~= nil and captainPos > 0 then + local tempCardIds = preFight.CardIds[captainPos] + preFight.CardIds[captainPos] = preFight.CardIds[1] + preFight.CardIds[1] = tempCardIds + end + end + + local req = { PreFightData = preFight } + XNetwork.Call(METHOD_NAME.PreFight, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + if func then + func() + end + + local fightData = res.FightData + local stageInfo = XFubenManager.GetStageInfo(fightData.StageId) + local isKeepPlayingStory = stage and XFubenConfigs.IsKeepPlayingStory(stage.StageId) and (stage.BeginStoryId) + local isNotPass = stage and stage.BeginStoryId and (not stageInfo or not stageInfo.Passed) + if isKeepPlayingStory or isNotPass then + XEventManager.DispatchEvent(XEventId.EVENT_FIGHT_BEGIN_PLAYMOVIE) + XDataCenter.MovieManager.PlayMovie(stage.BeginStoryId, function() + XFubenManager.EnterRealFight(preFight, fightData) + end) + else + XFubenManager.EnterRealFight(preFight, fightData) + end + end) + end + + -- 巴别塔战斗 + function XFubenManager.EnterBabelTowerFight(stageId, team, cb, captainPos, firstFightPos) + local stage = XFubenManager.GetStageCfg(stageId) + if not XFubenManager.CheckPreFight(stage) then + return + end + + local preFight = {} + preFight.CardIds = {} + preFight.StageId = stageId + preFight.CaptainPos = captainPos + preFight.FirstFightPos = firstFightPos + + for _, v in pairs(team) do + table.insert(preFight.CardIds, v) + end + + local rep = { PreFightData = preFight } + XNetwork.Call(METHOD_NAME.PreFight, rep, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + local fightData = res.FightData + local stageInfo = XFubenManager.GetStageInfo(fightData.StageId) + if stage and stage.BeginStoryId and (not stageInfo or not stageInfo.Passed) then + XDataCenter.MovieManager.PlayMovie(stage.BeginStoryId, function() + XFubenManager.EnterRealFight(preFight, fightData) + if cb then + cb() + end + end) + else + XFubenManager.EnterRealFight(preFight, fightData) + if cb then + cb() + end + end + end) + + end + + -- 据点战斗 + function XFubenManager.EnterBfrtFight(stageId, team, captainPos, firstFightPos) + local stage = XFubenManager.GetStageCfg(stageId) + if not XFubenManager.CheckPreFight(stage) then + return + end + + local preFight = {} + preFight.CardIds = {} + preFight.StageId = stage.StageId + preFight.CaptainPos = captainPos + preFight.FirstFightPos = firstFightPos + + for _, v in pairs(team) do + table.insert(preFight.CardIds, v) + end + local req = { PreFightData = preFight } + XNetwork.Call(METHOD_NAME.PreFight, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + local fightData = res.FightData + local stageInfo = XFubenManager.GetStageInfo(fightData.StageId) + if stage and stage.BeginStoryId and (not stageInfo or not stageInfo.Passed) then + -- 播放剧情,进入战斗 + XDataCenter.MovieManager.PlayMovie(stage.BeginStoryId, function() + XFubenManager.EnterRealFight(preFight, fightData) + end) + else + -- 直接进入战斗 + XFubenManager.EnterRealFight(preFight, fightData) + end + end) + end + + -- 超级据点战斗 + function XFubenManager.EnterStrongholdFight(stageId, characterIds, captainPos, firstFightPos) + local stage = XFubenManager.GetStageCfg(stageId) + if not XFubenManager.CheckPreFight(stage) then + return + end + + local preFight = {} + preFight.CardIds = characterIds + preFight.StageId = stage.StageId + preFight.CaptainPos = captainPos + preFight.FirstFightPos = firstFightPos + + local req = { PreFightData = preFight } + XNetwork.Call(METHOD_NAME.PreFight, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + local fightData = res.FightData + local stageInfo = XFubenManager.GetStageInfo(fightData.StageId) + if stage and stage.BeginStoryId and (not stageInfo or not stageInfo.Passed) then + -- 播放剧情,进入战斗 + XDataCenter.MovieManager.PlayMovie(stage.BeginStoryId, function() + XFubenManager.EnterRealFight(preFight, fightData) + end) + else + -- 直接进入战斗 + XFubenManager.EnterRealFight(preFight, fightData) + end + end) + end + + -- 异聚迷宫战斗 + function XFubenManager.EnterInfestorExploreFight(stageId, team, captainPos, infestorGridId, firstFightPos) + local stage = XFubenManager.GetStageCfg(stageId) + if not XFubenManager.CheckPreFight(stage) then + return + end + + local preFight = {} + preFight.CardIds = {} + preFight.StageId = stage.StageId + preFight.CaptainPos = captainPos + preFight.InfestorGridId = infestorGridId + preFight.FirstFightPos = firstFightPos + + for _, v in pairs(team) do + table.insert(preFight.CardIds, v) + end + local req = { PreFightData = preFight } + XNetwork.Call(METHOD_NAME.PreFight, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + local fightData = res.FightData + local stageInfo = XFubenManager.GetStageInfo(fightData.StageId) + if stage and stage.BeginStoryId and (not stageInfo or not stageInfo.Passed) then + -- 播放剧情,进入战斗 + XDataCenter.MovieManager.PlayMovie(stage.BeginStoryId, function() + XFubenManager.EnterRealFight(preFight, fightData) + end) + else + -- 直接进入战斗 + XFubenManager.EnterRealFight(preFight, fightData) + end + end) + end + + -- 边界公约战斗 + function XFubenManager.EnterAssignFight(stageId, charIdList, captainPos, startCb, errorCb, firstFightPos) + local stage = XFubenManager.GetStageCfg(stageId) + local preFight = {} + preFight.CardIds = {} + preFight.StageId = stage.StageId + preFight.CaptainPos = captainPos or XDataCenter.FubenAssignManager.CAPTIAN_MEMBER_INDEX + preFight.FirstFightPos = firstFightPos or XDataCenter.FubenAssignManager.FIRSTFIGHT_MEMBER_INDEX + + for _, charId in ipairs(charIdList) do + if charId ~= 0 then + table.insert(preFight.CardIds, charId) + end + end + local req = { PreFightData = preFight } + XNetwork.Call(METHOD_NAME.PreFight, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + if errorCb then + errorCb() + end + return + end + local fightData = res.FightData + -- -- 战力不足 不能复活 (改为服务器处理,读取FightReboot.tab字段RebootCondition) + -- if not XDataCenter.FubenAssignManager.IsAbilityMatch(stageId, charIdList) then + -- fightData.RebootId = 0 + -- end + local stageInfo = XFubenManager.GetStageInfo(fightData.StageId) + if stage and stage.BeginStoryId and (not stageInfo or not stageInfo.Passed) then + -- 播放剧情,进入战斗 + XDataCenter.MovieManager.PlayMovie(stage.BeginStoryId, function() + startCb() + XFubenManager.EnterRealFight(preFight, fightData) + end) + else + -- 直接进入战斗 + startCb() + XFubenManager.EnterRealFight(preFight, fightData) + end + end) + end + + -- 尼尔玩法 + function XFubenManager.EnterNieRFight(stage, curTeam) + if not XFubenManager.CheckPreFight(stage) then + return + end + local preFight = {} + preFight.CardIds = {} + preFight.StageId = stage.StageId + preFight.CaptainPos = curTeam.CaptainPos + preFight.FirstFightPos = curTeam.FirstFightPos + preFight.RobotIds = {} + for _, v in pairs(curTeam.TeamData or {}) do + table.insert(preFight.RobotIds, v) + end + XNetwork.Call(METHOD_NAME.PreFight, { PreFightData = preFight }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local fightData = res.FightData + local stageInfo = XFubenManager.GetStageInfo(fightData.StageId) + local isKeepPlayingStory = stage and XFubenConfigs.IsKeepPlayingStory(stage.StageId) and (stage.BeginStoryId) + local isNotPass = stage and stage.BeginStoryId and (not stageInfo or not stageInfo.Passed) + if isKeepPlayingStory or isNotPass then + -- 播放剧情,进入战斗 + XEventManager.DispatchEvent(XEventId.EVENT_FIGHT_BEGIN_PLAYMOVIE) + + XDataCenter.MovieManager.PlayMovie(stage.BeginStoryId, function() + XFubenManager.EnterRealFight(preFight, fightData) + end) + + else + -- 直接进入战斗 + XFubenManager.EnterRealFight(preFight, fightData) + end + end) + end + + -- 口袋妖怪战斗 + function XFubenManager.EnterPokemonFight(stageId) + local stage = XFubenManager.GetStageCfg(stageId) + if not XFubenManager.CheckPreFight(stage) then + return + end + + local preFight = {} + preFight.StageId = stage.StageId + + local req = { PreFightData = preFight } + XNetwork.Call(METHOD_NAME.PreFight, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local fightData = res.FightData + local stageInfo = XFubenManager.GetStageInfo(fightData.StageId) + if stage and stage.BeginStoryId and (not stageInfo or not stageInfo.Passed) then + -- 播放剧情,进入战斗 + XDataCenter.MovieManager.PlayMovie(stage.BeginStoryId, function() + XFubenManager.EnterRealFight(preFight, fightData) + end) + else + -- 直接进入战斗 + XFubenManager.EnterRealFight(preFight, fightData) + end + end) + end + + -- 萌战战斗 + function XFubenManager.EnterMoeWarFight(stage, curTeam) + if not XFubenManager.CheckPreFight(stage) then + return + end + local preFight = {} + preFight.CardIds = {} + preFight.StageId = stage.StageId + preFight.CaptainPos = curTeam.CaptainPos + preFight.FirstFightPos = curTeam.FirstFightPos + preFight.RobotIds = {} + + local charId = curTeam.TeamData[1] + if XRobotManager.CheckIsRobotId(charId) then + table.insert(preFight.RobotIds, charId) + else + table.insert(preFight.CardIds, charId) + end + + XNetwork.Call(METHOD_NAME.PreFight, { PreFightData = preFight }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local fightData = res.FightData + local stageInfo = XFubenManager.GetStageInfo(fightData.StageId) + local isKeepPlayingStory = stage and XFubenConfigs.IsKeepPlayingStory(stage.StageId) and (stage.BeginStoryId) + local isNotPass = stage and stage.BeginStoryId and (not stageInfo or not stageInfo.Passed) + if isKeepPlayingStory or isNotPass then + -- 播放剧情,进入战斗 + XEventManager.DispatchEvent(XEventId.EVENT_FIGHT_BEGIN_PLAYMOVIE) + + XDataCenter.MovieManager.PlayMovie(stage.BeginStoryId, function() + XFubenManager.EnterRealFight(preFight, fightData) + end) + + else + -- 直接进入战斗 + XFubenManager.EnterRealFight(preFight, fightData) + end + end) + end + + --杀戮无双 + function XFubenManager.EnterKillZoneFight(stage, curTeam) + if not XFubenManager.CheckPreFight(stage) then + return + end + local preFight = {} + preFight.CardIds = {} + preFight.StageId = stage.StageId + preFight.CaptainPos = curTeam.CaptainPos + preFight.FirstFightPos = curTeam.FirstFightPos + preFight.RobotIds = {} + for _, v in pairs(curTeam.TeamData or {}) do + if not XRobotManager.CheckIsRobotId(v) then + table.insert(preFight.CardIds, v) + table.insert(preFight.RobotIds, 0) + else + table.insert(preFight.CardIds, 0) + table.insert(preFight.RobotIds, v) + end + end + + XNetwork.Call(METHOD_NAME.PreFight, { PreFightData = preFight }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local fightData = res.FightData + local stageInfo = XFubenManager.GetStageInfo(fightData.StageId) + XFubenManager.EnterRealFight(preFight, fightData) + end) + end + + + function XFubenManager.ReconnectFight() + -- 获取fightData + XNetwork.Call(METHOD_NAME.GetFightData, nil, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + -- 构造preFightData + local fightData = res.FightData + local preFightData = {} + preFightData.CardIds = {} + preFightData.StageId = fightData.StageId + for i = 1, #fightData.RoleData do + local role = fightData.RoleData[i] + if role.Id == XPlayer.Id then + for j = 1, #role.NpcData do + local npc = role.NpcData[j] + table.insert(preFightData.CardIds, npc.Character.Id) + end + break + end + end + + XFubenManager.EnterRealFight(preFightData, fightData, true) + end) + end + + --==============================-- + --desc: 进入新手战斗,构造战斗数据 + --time:2018-06-19 04:11:30 + --@stageId: + --@charId: + --@return + --==============================-- + function XFubenManager.EnterGuideFight(guiId, stageId, chars, weapons) + local fightData = {} + fightData.RoleData = {} + fightData.FightId = 1 + fightData.Online = false + fightData.Seed = 1 + fightData.StageId = stageId + + local roleData = {} + roleData.NpcData = {} + table.insert(fightData.RoleData, roleData) + roleData.Id = XPlayer.Id + roleData.Name = CSTextManagerGetText("Aha") + roleData.Camp = 1 + + local npcData = {} + npcData.Equips = {} + roleData.NpcData[0] = npcData + + for _, v in pairs(chars) do + local character = {} + npcData.Character = character + character.Id = v + character.Level = 1 + character.Quality = 1 + character.Star = 1 + end + + for _, v in pairs(weapons) do + local equipData = {} + table.insert(npcData.Equips, equipData) + equipData.Id = 1 + equipData.TemplateId = v + equipData.Level = 1 + equipData.Star = 0 + equipData.Breakthrough = 0 + end + + local stage = XFubenManager.GetStageCfg(stageId) + fightData.RebootId = stage.RebootId + fightData.DisableJoystick = stage.DisableJoystick + fightData.DisableDeadEffect = stage.DisableDeadEffect + local endFightCb = function() + if stage.EndStoryId then + XDataCenter.MovieManager.PlayMovie(stage.EndStoryId, function() + local guideFight = XDataCenter.GuideManager.GetNextGuideFight() + if guideFight then + XDataCenter.FubenManager.EnterGuideFight(guideFight.Id, guideFight.StageId, guideFight.NpcId, guideFight.Weapon) + else + XLoginManager.SetFirstOpenMainUi(true) + XLuaUiManager.RunMain() + end + end) + else + local guideFight = XDataCenter.GuideManager.GetNextGuideFight() + if guideFight then + XDataCenter.FubenManager.EnterGuideFight(guideFight.Id, guideFight.StageId, guideFight.NpcId, guideFight.Weapon) + else + XLoginManager.SetFirstOpenMainUi(true) + XLuaUiManager.RunMain() + end + end + end + + local enterFightFunc = function() + XFubenManager.CallOpenFightLoading(stageId) + + if guiId == 100002 then + --CheckPoint: APPEVENT_FIRST_BATTLE_FINISH + XAppEventManager.AppLogEvent(XAppEventManager.CommonEventNameConfig.First_Battle_Finish) + elseif guiId == 100003 then + --CheckPoint: APPEVENT_SECOND_BATTLE_END + XAppEventManager.AppLogEvent(XAppEventManager.CommonEventNameConfig.Second_Battle_End); + end + + local args = CS.XFightClientArgs() + args.HideCloseButton = true + args.RoleId = XPlayer.Id + args.CloseLoadingCb = function() + XFubenManager.CallCloseFightLoading(stageId) + end + args.FinishCbAfterClear = function() + local req = { GuideGroupId = guiId } + XNetwork.Call(METHOD_NAME.GuideComplete, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + endFightCb() + end) + end + args.ClientOnly = true + + -- CS.XUiManager.Instance:ReleaseUiScene("UiActivityBriefBase") + CS.XFight.Enter(fightData, args) + end + + if stage.BeginStoryId then + XDataCenter.MovieManager.PlayMovie(stage.BeginStoryId, enterFightFunc) + else + enterFightFunc() + end + end + + --进入技能教学战斗,构造战斗数据 + function XFubenManager.EnterSkillTeachFight(characterId) + local stageId = XCharacterConfigs.GetCharTeachStageIdById(characterId) + + local fightData = {} + fightData.RoleData = {} + fightData.FightId = 1 + fightData.Online = false + fightData.Seed = 1 + fightData.StageId = stageId + + local roleData = {} + roleData.NpcData = {} + table.insert(fightData.RoleData, roleData) + roleData.Id = XPlayer.Id + roleData.Name = CSTextManagerGetText("Aha") + roleData.Camp = 1 + + local npcData = {} + roleData.NpcData[0] = npcData + + npcData.Character = XDataCenter.CharacterManager.GetCharacter(characterId) + npcData.Equips = XDataCenter.EquipManager.GetCharacterWearingEquips(characterId) + npcData.WeaponFashionId = XDataCenter.WeaponFashionManager.GetCharacterWearingWeaponFashionId(characterId) + + local stage = XFubenManager.GetStageCfg(stageId) + fightData.RebootId = stage.RebootId + local endFightCb = function() + if stage.EndStoryId then + XDataCenter.MovieManager.PlayMovie(stage.EndStoryId) + end + end + + local enterFightFunc = function() + XFubenManager.CallOpenFightLoading(stageId) + local args = CS.XFightClientArgs() + args.RoleId = XPlayer.Id + args.CloseLoadingCb = function() + XFubenManager.CallCloseFightLoading(stageId) + end + args.FinishCbAfterClear = function() + endFightCb() + end + args.ClientOnly = true + + -- CS.XUiManager.Instance:ReleaseUiScene("UiActivityBriefBase") + CS.XFight.Enter(fightData, args) + end + + if stage.BeginStoryId then + XDataCenter.MovieManager.PlayMovie(stage.BeginStoryId, enterFightFunc) + else + enterFightFunc() + end + end + + function XFubenManager.PlayStory(storyId, callback) + XDataCenter.MovieManager.PlayMovie(storyId, function() + if callback then + callback() + end + end) + end + + function XFubenManager.CheckCustomUiConflict() + if NeedCheckUiConflict then + CS.XCustomUi.Instance:GetData() + NeedCheckUiConflict = false + end + if CS.XRLFightSettings.UiConflict then + NeedCheckUiConflict = true + -- 在新手引导时不提示冲突 + if XDataCenter.GuideManager.CheckIsInGuide() then return end + local title = CSTextManagerGetText("TipTitle") + local content = CSTextManagerGetText("FightUiCustomConflict") + local extraData = { sureText = CSTextManagerGetText("TaskStateSkip") } + local sureCallback = function() + XLuaUiManager.Open("UiFightCustom", CS.XFight.Instance) + end + XUiManager.DialogTip(title, content, XUiManager.DialogType.OnlySure, nil, sureCallback, extraData) + return true + end + return false + end + + --异步进入战斗 + function XFubenManager.EnterRealFightAsync(preFightData, fightData, isNotReleaseAll) + if XFubenManager.CheckCustomUiConflict() then return end + local stageId = fightData.StageId + XFubenManager.CallOpenFightLoading(stageId) + + coroutine.yield() + + local assistInfo + + if preFightData.IsHasAssist then + for i = 1, #fightData.RoleData do + local role = fightData.RoleData[i] + if role.Id == XPlayer.Id then + assistInfo = role.AssistNpcData + break + end + end + end + + local roleData = {} + for i = 1, #fightData.RoleData do + local role = fightData.RoleData[i] + roleData[i] = role.Id + end + + local charList = {} + local charDic = {} --已在charList中的Robot对应的CharId + for _, cardId in ipairs(preFightData.RobotIds or {}) do + table.insert(charList, cardId) + + local charId = XRobotManager.GetCharacterId(cardId) + charDic[charId] = true + end + for _, cardId in ipairs(preFightData.CardIds or {}) do + if not charDic[cardId] then + table.insert(charList, cardId) + end + end + + XFubenManager.RecordFightBeginData(stageId, charList, preFightData.IsHasAssist, assistInfo, preFightData.ChallengeCount, roleData) + + -- 提示加锁 + XTipManager.Suspend() + + -- 功能开启&新手加锁 + XDataCenter.FunctionEventManager.LockFunctionEvent() + + XFubenManager.FubenSettleResult = nil + + local args = XFubenManager.CtorFightArgs(fightData.StageId, fightData.RoleData) + --CS.XUiManager.Instance:ReleaseUiScene("UiActivityBriefBase") + XEventManager.DispatchEvent(XEventId.EVENT_PRE_ENTER_FIGHT) + if not isNotReleaseAll then + CS.XUiManager.Instance:ReleaseAll(CsXUiType.Normal, nil) + XTableManager.ReleaseTableCache() + collectgarbage("collect") + end + CS.XFight.Enter(fightData, args) + EnterFightStartTime = CS.UnityEngine.Time.time + XEventManager.DispatchEvent(XEventId.EVENT_ENTER_FIGHT) + + end + + + -- 组织战斗需要用的数据 + function XFubenManager.EnterRealFight(preFightData, fightData, isNotReleaseAll) + --增加异步加载,第一时间先把load图加载进来 + local co = coroutine.create(function() + XFubenManager.EnterRealFightAsync(preFightData, fightData, isNotReleaseAll) + end) + + coroutine.resume(co) + XScheduleManager.ScheduleOnce(function() + coroutine.resume(co) + end, 500) + end + + + function XFubenManager.CtorFightArgs(stageId, roleData) + local stageInfo = XFubenManager.GetStageInfo(stageId) + local stageCfg = XFubenManager.GetStageCfg(stageId) + local args = CS.XFightClientArgs() + + args.IsReconnect = false + args.RoleId = XPlayer.Id + args.FinishCb = CallFinishFightHandler[stageInfo.Type] or XFubenManager.CallFinishFight + args.ProcessCb = function(progress) + XDataCenter.RoomManager.UpdateLoadProcess(progress) + end + + local roleNum = 0 + args.CloseLoadingCb = function() + XFubenManager.CallCloseFightLoading(stageId) + local loadingTime = CS.UnityEngine.Time.time - EnterFightStartTime + local roleIdStr = "" + if roleData[1] then + for i = 0, #roleData[1].NpcData do + if roleData[1].NpcData[i] then + roleIdStr = roleIdStr .. roleData[1].NpcData[i].Character.Id .. "," + roleNum = roleNum + 1 + end + end + end + local msgtab = {} + msgtab.stageId = stageId + msgtab.loadingTime = loadingTime + msgtab.roleIdStr = roleIdStr + msgtab.roleNum = roleNum + CS.XRecord.Record(msgtab, "24034", "BdcEnterFightLoadingTime") + CS.XHeroBdcAgent.BdcEnterFightLoadingTime(stageId, loadingTime, roleIdStr) + end + local list = CS.System.Collections.Generic.List(CS.System.String)() + for _, v in pairs(stageCfg.StarDesc) do + list:Add(v) + end + args.StarTips = list + args.Stars = stageInfo.Stars + if ShowSummaryHandler[stageInfo.Type] then + args.ShowSummaryCb = function() + ShowSummaryHandler[stageInfo.Type](stageId) + end + end + + if CheckAutoExitFightHandler[stageInfo.Type] then + args.AutoExitFight = CheckAutoExitFightHandler[stageInfo.Type](stageId) + end + + if SettleFightHandler[stageInfo.Type] then + args.SettleCb = SettleFightHandler[stageInfo.Type] + else + args.SettleCb = XFubenManager.SettleFight + end + + if CheckReadyToFightHandler[stageInfo.Type] then + args.IsReadyToFight = CheckReadyToFightHandler[stageInfo.Type](stageId) + end + return args + end + + -- 联机副本进入战斗 + function XFubenManager.OnEnterFight(fightData) + -- 进入战斗前关闭所有弹出框 + XLuaUiManager.Remove("UiDialog") + + local role + for i = 1, #fightData.RoleData do + if fightData.RoleData[i].Id == XPlayer.Id then + role = fightData.RoleData[i] + break + end + end + + if not role then + XLog.Error("XFubenManager.OnEnterFight函数出错, 联机副本RoleData列表中没有找到自身数据") + return + end + + local preFightData = {} + preFightData.StageId = fightData.StageId + preFightData.CardIds = {} + for _, v in pairs(role.NpcData) do + table.insert(preFightData.CardIds, v.Character.Id) + end + XFubenManager.EnterRealFight(preFightData, fightData) + end + + -- 战斗开始前数据记录,便于结算时的 UI 数据显示 + local BeginData + --返回战前数据 + function XFubenManager.GetFightBeginData() + return BeginData + end + + function XFubenManager.RecordFightBeginData(stageId, charList, isHasAssist, assistPlayerData, challengeCount, roleData) + BeginData = { + CharExp = {}, + RoleExp = 0, + RoleCoins = 0, + LastPassed = false, + AssistPlayerData = nil, + IsHasAssist = false, + CharList = charList, + StageId = stageId, + ChallengeCount = challengeCount, -- 记录挑战次数 + RoleData = roleData + } + + for _, charId in pairs(charList) do + local isRobot = XRobotManager.CheckIsRobotId(charId) + local char = isRobot and XRobotManager.GetRobotTemplate(charId) or XDataCenter.CharacterManager.GetCharacter(charId) + if char ~= nil then + if isRobot then + table.insert(BeginData.CharExp, { Id = charId, Quality = char.CharacterQuality, Exp = 0, Level = char.CharacterLevel }) + else + table.insert(BeginData.CharExp, { Id = charId, Quality = char.Quality, Exp = char.Exp, Level = char.Level }) + end + end + end + + -- local stage = XFubenManager.GetStageCfg(stageId) + BeginData.RoleLevel = XPlayer.GetLevelOrHonorLevel() + BeginData.RoleExp = XPlayer.Exp + BeginData.RoleCoins = XDataCenter.ItemManager.GetCoinsNum() + local stageInfo = XFubenManager.GetStageInfo(stageId) + BeginData.LastPassed = stageInfo.Passed + BeginData.AssistPlayerData = assistPlayerData + BeginData.IsHasAssist = isHasAssist + + -- 联机相关 + local roomData = XDataCenter.RoomManager.RoomData + if roomData then + BeginData.PlayerList = {} + for _, v in pairs(roomData.PlayerDataList) do + local playerData = { + Id = v.Id, + Name = v.Name, + Character = v.FightNpcData.Character, + CharacterId = v.FightNpcData.Character.Id, + MedalId = v.MedalId, + HeadPortraitId = v.HeadPortraitId, + HeadFrameId = v.HeadFrameId + } + if stageInfo.Type == XDataCenter.FubenManager.StageType.ArenaOnline then + playerData.StageType = XDataCenter.FubenManager.StageType.ArenaOnline + playerData.IsFirstPass = v.IsFirstPass + end + BeginData.PlayerList[v.Id] = playerData + end + end + end + + function XFubenManager.GetFightChallengeCount() + return BeginData and BeginData.ChallengeCount or 1 + end + + function XFubenManager.RequestRestart(fightId, cb) + XNetwork.Call(METHOD_NAME.FightRestart, { FightId = fightId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + end + cb(res.Seed) + end) + end + + function XFubenManager.RequestReboot(fightId, rebootCount, cb) + XNetwork.Call(METHOD_NAME.FightReboot, { FightId = fightId, RebootCount = rebootCount }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + end + cb(res.Code == XCode.Success) + end) + end + + --战斗结算统计 + function XFubenManager.StatisticsFightResultDps(result) + -- 初始化Dps数据 + local dpsTable = {} + + --Dps数据 + if result.NpcDpsTable and result.NpcDpsTable.Count > 0 then + local damageTotalMvp = -1 + local hurtMvp = -1 + local cureMvp = -1 + local breakEndureMvp = -1 + + local damageTotalMvpValue = -1 + local hurtMvpValue = -1 + local cureMvpValue = -1 + local breakEndureValue = -1 + + XTool.LoopMap(result.NpcDpsTable, function(_, v) + dpsTable[v.RoleId] = {} + dpsTable[v.RoleId].DamageTotal = v.DamageTotal + dpsTable[v.RoleId].Hurt = v.Hurt + dpsTable[v.RoleId].Cure = v.Cure + dpsTable[v.RoleId].BreakEndure = v.BreakEndure + dpsTable[v.RoleId].RoleId = v.RoleId + + if damageTotalMvpValue == -1 or v.DamageTotal > damageTotalMvpValue then + damageTotalMvpValue = v.DamageTotal + damageTotalMvp = v.RoleId + end + + if cureMvpValue == -1 or v.Cure > cureMvpValue then + cureMvpValue = v.Cure + cureMvp = v.RoleId + end + + if hurtMvpValue == -1 or v.Hurt > hurtMvpValue then + hurtMvpValue = v.Hurt + hurtMvp = v.RoleId + end + + if breakEndureValue == -1 or v.BreakEndure > breakEndureValue then + breakEndureValue = v.BreakEndure + breakEndureMvp = v.RoleId + end + end) + + if damageTotalMvp ~= -1 and dpsTable[damageTotalMvp] then + dpsTable[damageTotalMvp].IsDamageTotalMvp = true + end + + if cureMvp ~= -1 and dpsTable[cureMvp] then + dpsTable[cureMvp].IsCureMvp = true + end + + if hurtMvp ~= -1 and dpsTable[hurtMvp] then + dpsTable[hurtMvp].IsHurtMvp = true + end + + if breakEndureMvp ~= -1 and dpsTable[breakEndureMvp] then + dpsTable[breakEndureMvp].IsBreakEndureMvp = true + end + XFubenManager.LastDpsTable = dpsTable + end + --夏活拍照关数据 + if result.EpisodeFightResults and result.EpisodeFightResults.Count > 0 then + local photoMvp = -1 + local mischiefMvp = -1 + local photoValue = -1 + local mischiefValue = -1 + local resultTable = {} + XTool.LoopMap(result.EpisodeFightResults, function(roleId, v) + resultTable[roleId] = {} + resultTable[roleId].ScorePhoto = v.ScoreByTakePhoto + resultTable[roleId].ScoreByMischief = v.ScoreByMischief + resultTable[roleId].RoleId = roleId + if v.ScoreByTakePhoto > photoValue then + photoValue = v.ScoreByTakePhoto + photoMvp = roleId + end + if v.ScoreByMischief > mischiefValue then + mischiefValue = v.ScoreByMischief + mischiefMvp = roleId + end + end) + + if mischiefMvp ~= -1 and resultTable[mischiefMvp] then + resultTable[mischiefMvp].IsMischiefMvp = true + end + + if photoMvp ~= -1 and resultTable[photoMvp] then + resultTable[photoMvp].IsPhotoMvp = true + end + + XFubenManager.SummerEpisodeDpsTable = resultTable + end + end + + function XFubenManager.CallFinishFight() + local res = XFubenManager.FubenSettleResult + XFubenManager.FubenSettling = false + XFubenManager.FubenSettleResult = nil + + --通知战斗结束,关闭战斗设置页面 + CS.XGameEventManager.Instance:Notify(XEventId.EVENT_FIGHT_FINISH) + + if not res then + -- 强退 + XFubenManager.ChallengeLose() + return + end + + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + XFubenManager.ChallengeLose() + CS.XGameEventManager.Instance:Notify(XEventId.EVENT_FUBEN_SETTLE_FAIL, res.Code) + return + end + + local stageId = res.Settle.StageId + local stageInfo = XFubenManager.GetStageInfo(stageId) + --local stageCfg = XFubenManager.GetStageCfg(stageId) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_FIGHT_RESULT, res.Settle) + + if FinishFightHandler[stageInfo.Type] then + FinishFightHandler[stageInfo.Type](res.Settle) + else + XFubenManager.FinishFight(res.Settle) + end + end + + function XFubenManager.FinishFight(settle) + if settle.IsWin then + XFubenManager.ChallengeWin(settle) + else + XFubenManager.ChallengeLose(settle) + end + end + + function XFubenManager.GetChallengeWinData(beginData, settleData) + local stageData = PlayerStageData[settleData.StageId] + + local starsMap = {} + local starsMark = stageData and stageData.StarsMark or settleData.StarsMark + if starsMark then + local _, tmpStarsMap = GetStarsCount(starsMark) + starsMap = tmpStarsMap + end + + return { + SettleData = settleData, + StageId = settleData.StageId, + RewardGoodsList = settleData.RewardGoodsList, + CharExp = beginData.CharExp, + RoleExp = beginData.RoleExp, + RoleLevel = beginData.RoleLevel, + RoleCoins = beginData.RoleCoins, + StarsMap = starsMap, + UrgentId = settleData.UrgentEnventId, + ClientAssistInfo = AssistSuccess and beginData.AssistPlayerData or nil, + FlopRewardList = settleData.FlopRewardList, + PlayerList = beginData.PlayerList, + } + end + + function XFubenManager.ChallengeWin(settleData) + -- 据点战关卡处理 + local stageInfo = StageInfos[settleData.StageId] + if stageInfo.Type == XFubenManager.StageType.Bfrt then + XDataCenter.BfrtManager.FinishStage(settleData.StageId) + end + local winData = XFubenManager.GetChallengeWinData(BeginData, settleData) + local stage = XFubenManager.GetStageCfg(settleData.StageId) + local isKeepPlayingStory = stage and XFubenConfigs.IsKeepPlayingStory(stage.StageId) and (stage.EndStoryId) + local isNotPass = stage and stage.EndStoryId and not BeginData.LastPassed + if isKeepPlayingStory or isNotPass then + -- 播放剧情,弹出结算 + XDataCenter.MovieManager.PlayMovie(stage.EndStoryId, function() + XFubenManager.CallShowReward(winData) + end) + else + -- 弹出结算 + XFubenManager.CallShowReward(winData) + end + + -- XDataCenter.GuideManager.CompleteEvent(XDataCenter.GuideManager.GuideEventType.PassStage, settleData.StageId) + XEventManager.DispatchEvent(XEventId.EVENT_FIGHT_RESULT_WIN) + end + + function XFubenManager.CheckHasFlopReward(winData, needMySelf) + for _, v in pairs(winData.FlopRewardList) do + if v.PlayerId ~= 0 then + if not needMySelf or v.PlayerId == XPlayer.Id then + return true + end + end + end + return false + end + + function XFubenManager.CallShowReward(winData) + if not winData then + XLog.Warning("XFubenManager.CallShowReward warning, winData is nil") + return + end + --CS.XAudioManager.PlayMusic(CS.XAudioManager.BATTLE_WIN_BGM) + --CS.XAudioManager.RemoveCueSheet(CS.XAudioManager.NORMAL_MUSIC_CUE_SHEET_ID) + local stageInfo = XFubenManager.GetStageInfo(winData.StageId) + + if ShowRewardHandler[stageInfo.Type] then + ShowRewardHandler[stageInfo.Type](winData) + else + XFubenManager.ShowReward(winData) + end + end + + -- 胜利 & 奖励界面 + function XFubenManager.ShowReward(winData) + if winData.SettleData.ArenaResult then + XLuaUiManager.Open("UiArenaFightResult", winData) + return + end + if XFubenManager.CheckHasFlopReward(winData) then + XLuaUiManager.Open("UiFubenFlopReward", function() + XLuaUiManager.PopThenOpen("UiSettleWin", winData) + end, winData) + else + XLuaUiManager.Open("UiSettleWin", winData) + end + end + + -- 失败界面 + function XFubenManager.ChallengeLose(settleData) + XLuaUiManager.Open("UiSettleLose", settleData) + --CS.XAudioManager.RemoveCueSheet(CS.XAudioManager.NORMAL_MUSIC_CUE_SHEET_ID) + --CS.XAudioManager.PlayMusic(CS.XAudioManager.BATTLE_LOSE_BGM) + end + + -- 购买体力,作为测试的暂时工具 + function XFubenManager.BuyActionPoint(cb) + XNetwork.Call(METHOD_NAME.BuyActionPoint, nil, function() + local val = XDataCenter.ItemManager.GetActionPointsNum() + cb(val) + end) + end + + -- 挑战进入前检查是否结算中 + function XFubenManager.CheckChallengeCanEnter(cb, challengeId) + local req = { ChallengeId = challengeId } + XNetwork.Call(METHOD_NAME.CheckChallengeCanEnter, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + if cb then + cb() + end + end) + end + + function XFubenManager.GoToFuben(param) + if param == XFubenManager.StageType.Mainline or param == XFubenManager.StageType.Daily then + if param == XFubenManager.StageType.Daily then + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.FubenChallenge) then + return + end + end + XFubenManager.OpenFuben(param) + else + XFubenManager.OpenFubenByStageId(param) + end + end + + function XFubenManager.OpenFuben(type, stageId) + -- if os.date("%x") ~= os.date("%x", RefreshTime) then + -- XNetwork.Call(METHOD_NAME.RefreshFubenList, nil, function(res) + -- if res.Code ~= XCode.Success then + -- XUiManager.TipCode(res.Code) + -- return + -- end + -- CS.XUiManager.ViewManager:Push("UiFuben", false, false, type, stageId) + -- end) + -- else + -- CS.XUiManager.ViewManager:Push("UiFuben", false, false, type, stageId) + -- end + XLuaUiManager.Open("UiFuben", type, stageId) + end + + function XFubenManager.OpenFubenByStageId(stageId) + local stageInfo = XFubenManager.GetStageInfo(stageId) + if not stageInfo then + XLog.ErrorTableDataNotFound("XFubenManager.OpenFubenByStageId", "stageInfo", "Share/Fuben/Stage.tab", "stageId", tostring(stageId)) + return + end + if not stageInfo.Unlock then + XUiManager.TipMsg(XFubenManager.GetFubenOpenTips(stageId)) + return + end + + if stageInfo.Type == XFubenManager.StageType.Mainline then + if stageInfo.Difficult == XFubenManager.DifficultHard and (not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.FubenDifficulty)) then + local openTips = XFunctionManager.GetFunctionOpenCondition(XFunctionManager.FunctionName.FubenDifficulty) + XUiManager.TipMsg(openTips) + return + end + local chapter = XDataCenter.FubenMainLineManager.GetChapterCfg(stageInfo.ChapterId) + if not XDataCenter.FubenMainLineManager.CheckChapterCanGoTo(chapter.ChapterId) then + XUiManager.TipMsg(CSTextManagerGetText("FubenMainLineNoneOpen")) + return + end + CsXUiManager.Instance:Open("UiFubenMainLineChapter", chapter, stageId) + elseif stageInfo.Type == XFubenManager.StageType.Bfrt then + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.FubenNightmare) then + return + end + + local chapter = XDataCenter.BfrtManager.GetChapterCfg(stageInfo.ChapterId) + CsXUiManager.Instance:Open("UiFubenMainLineChapter", chapter, stageId) + elseif stageInfo.Type == XFubenManager.StageType.ActivtityBranch then + if not XDataCenter.FubenActivityBranchManager.IsOpen() then + XUiManager.TipText("ActivityBranchNotOpen") + return + end + + local sectionId = XDataCenter.FubenActivityBranchManager.GetCurSectionId() + XLuaUiManager.Open("UiActivityBranch", sectionId) + elseif stageInfo.Type == XFubenManager.StageType.ActivityBossSingle then + if not XDataCenter.FubenActivityBossSingleManager.IsOpen() then + XUiManager.TipText("ActivityBossSingleNotOpen") + return + end + + local sectionId = XDataCenter.FubenActivityBossSingleManager.GetCurSectionId() + XLuaUiManager.Open("UiActivityBossSingle", sectionId) + elseif stageInfo.Type == XFubenManager.StageType.Assign then + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.FubenAssign) then + XLog.Debug("Assign Stage not open ", stageId) + return + end + XLuaUiManager.Open("UiPanelAssignMain", stageId) + end + end + + function XFubenManager.GoToCurrentMainLine(stageId) + if not XFubenManager.UiFubenMainLineChapterInst then + XLog.Error("XFubenManager.GoToCurrentMainLine : UiFubenMainLineChapterInst为空") + return + end + local stageInfo = XFubenManager.GetStageInfo(stageId) + if not stageInfo then + XLog.ErrorTableDataNotFound("XFubenManager.GoToCurrentMainLine", "stageInfo", "Share/Fuben/Stage.tab", "stageId", tostring(stageId)) + return + end + if not stageInfo.Unlock then + XUiManager.TipMsg(XFubenManager.GetFubenOpenTips(stageId)) + return + end + + XFubenManager.UiFubenMainLineChapterInst:OpenStage(stageId, true) + end + + function XFubenManager.OpenRoomSingle(stage, data) + if XFubenManager.CheckPreFight(stage) then + XLuaUiManager.Open("UiNewRoomSingle", stage.StageId, data) + return true + end + return false + end + + function XFubenManager.RequestCreateRoom(stage, cb) + if XFubenManager.CheckPreFight(stage) then + XDataCenter.RoomManager.CreateRoom(stage.StageId, cb) + end + end + + function XFubenManager.RequestArenaOnlineCreateRoom(stageinfo, stageid, cb) + if XFubenManager.CheckPreFight(stageinfo) then + XDataCenter.RoomManager.ArenaOnlineCreateRoom(stageid, cb) + end + end + + function XFubenManager.RequestMatchRoom(stage, cb) + if XFubenManager.CheckPreFight(stage) then + XDataCenter.RoomManager.Match(stage.StageId, cb) + end + end + + -- 区域联机匹配 + function XFubenManager.RequestAreanaOnlineMatchRoom(stage, stageId, cb) + if XFubenManager.CheckPreFight(stage) then + XDataCenter.RoomManager.AreanaOnlineMatch(stageId, cb) + end + end + + function XFubenManager.GetFubenTitle(stageId) + local stageInfo = XFubenManager.GetStageInfo(stageId) + local stageCfg = XFubenManager.GetStageCfg(stageId) + local res + if stageInfo and stageInfo.Type == XFubenManager.StageType.Mainline then + local diffMsg = "" + local chapterCfg = XDataCenter.FubenMainLineManager.GetChapterCfg(stageInfo.ChapterId) + if stageInfo.Difficult == XFubenManager.DifficultNormal then + diffMsg = CSTextManagerGetText("FubenDifficultyNormal", chapterCfg.OrderId, stageCfg.OrderId) + elseif stageInfo.Difficult == XFubenManager.DifficultHard then + diffMsg = CSTextManagerGetText("FubenDifficultyHard", chapterCfg.OrderId, stageCfg.OrderId) + end + res = diffMsg + elseif stageInfo and stageInfo.Type == XFubenManager.StageType.ExtraChapter then + local diffMsg = "" + local chapterCfg = XDataCenter.ExtraChapterManager.GetChapterDetailsCfg(stageInfo.ChapterId) + if stageInfo.Difficult == XFubenManager.DifficultNormal then + diffMsg = CSTextManagerGetText("FubenDifficultyNormal", chapterCfg.StageTitle, stageCfg.OrderId) + elseif stageInfo.Difficult == XFubenManager.DifficultHard then + diffMsg = CSTextManagerGetText("FubenDifficultyHard", chapterCfg.StageTitle, stageCfg.OrderId) + end + res = diffMsg + elseif stageInfo and stageInfo.Type == XFubenManager.StageType.Bfrt then + local chapterCfg = XDataCenter.FubenMainLineManager.GetChapterCfg(stageInfo.ChapterId) + res = CSTextManagerGetText("FubenDifficultyNightmare", chapterCfg.OrderId, stageCfg.OrderId) + else + res = stageCfg.Name + end + return res + end + + function XFubenManager.GetDifficultIcon(stageId) + local stageInfo = XFubenManager.GetStageInfo(stageId) + if stageInfo then + if stageInfo.Type == XFubenManager.StageType.Mainline then + if stageInfo.Difficult == XFubenManager.DifficultNormal then + return CS.XGame.Config:GetString("StageNomraIcon") + elseif stageInfo.Difficult == XFubenManager.DifficultHard then + return CS.XGame.Config:GetString("StageHardIcon") + end + elseif stageInfo.Type == XFubenManager.StageType.Bfrt then + return CS.XGame.Config:GetString("StageFortress") + elseif stageInfo.Type == XFubenManager.StageType.Resource then + return CS.XGame.Config:GetString("StageResourceIcon") + elseif stageInfo.Type == XFubenManager.StageType.Daily then + return CS.XGame.Config:GetString("StageDailyIcon") + end + end + return CS.XGame.Config:GetString("StageNomraIcon") + end + + function XFubenManager.GetFubenOpenTips(stageId, default) + local curStageCfg = XFubenManager.GetStageCfg(stageId) + + local preStageIds = curStageCfg.PreStageId + if #preStageIds > 0 then + for _, preStageId in pairs(preStageIds) do + local stageInfo = XFubenManager.GetStageInfo(preStageId) + if not stageInfo.Passed then + if stageInfo.Type == XFubenManager.StageType.Mainline then + local title = XFubenManager.GetFubenTitle(preStageId) + return CSTextManagerGetText("FubenPreMainLineStage", title) + elseif stageInfo.Type == XFubenManager.StageType.ExtraChapter then + local title = XFubenManager.GetFubenTitle(preStageId) + return CSTextManagerGetText("FubenPreExtraChapterStage", title) + elseif stageInfo.Type == XFubenManager.StageType.ZhouMu then + local title = XFubenManager.GetFubenTitle(preStageId) + return CSTextManagerGetText("AssignStageUnlock", title) + elseif stageInfo.Type == XFubenManager.StageType.NieR then + local title = XFubenManager.GetFubenTitle(preStageId) + return CSTextManagerGetText("NieRStageUnLockByPer", title) + end + end + end + end + + if XDataCenter.BfrtManager.CheckStageTypeIsBfrt(stageId) then + local groupId = XDataCenter.BfrtManager.GetGroupIdByBaseStage(stageId) + local preGroupUnlock, preGroupId = XDataCenter.BfrtManager.CheckPreGroupUnlock(groupId) + if not preGroupUnlock then + local preStageId = XDataCenter.BfrtManager.GetBaseStage(preGroupId) + local title = XFubenManager.GetFubenTitle(preStageId) + return CSTextManagerGetText("FubenPreStage", title) + end + end + + if XPlayer.Level < curStageCfg.RequireLevel then + return CSTextManagerGetText("FubenNeedLevel", curStageCfg.RequireLevel) + end + + if default then + return default + end + return CSTextManagerGetText("NotUnlock") + end + + function XFubenManager.GetAssistTemplateInfo() + local info = { + IsHasAssist = false + } + + if BeginData and BeginData.IsHasAssist then + info.IsHasAssist = BeginData.IsHasAssist + if BeginData.AssistPlayerData == nil then + info.FailAssist = CSTextManagerGetText("GetAssistFail") + end + end + + if BeginData and BeginData.AssistPlayerData then + local template = XAssistConfig.GetAssistRuleTemplate(BeginData.AssistPlayerData.RuleTemplateId) + if template then + info.Title = template.Title + if BeginData.AssistPlayerData.NpcData and BeginData.AssistPlayerData.Id > 0 then + info.Sign = BeginData.AssistPlayerData.Sign + info.Name = XDataCenter.SocialManager.GetPlayerRemark(BeginData.AssistPlayerData.Id, BeginData.AssistPlayerData.Name) + + local headPortraitInfo = XPlayerManager.GetHeadPortraitInfoById(BeginData.AssistPlayerData.HeadPortraitId) + if (headPortraitInfo ~= nil) then + info.Image = headPortraitInfo.ImgSrc + end + local headFrameInfo = XPlayerManager.GetHeadPortraitInfoById(BeginData.AssistPlayerData.HeadFrameId) + if (headFrameInfo ~= nil) then + info.HeadFrameImage = headFrameInfo.ImgSrc + end + AssistSuccess = true + end + if info.Sign == "" or info.Sign == nil then + info.Sign = CSTextManagerGetText("CharacterSignTip") + end + end + end + + return info + end + + function XFubenManager.EnterChallenge(cb) + XNetwork.Call(METHOD_NAME.EnterChallenge, nil, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + if cb then + cb() + end + end) + end + + --是否开放显示指定关卡 + function XFubenManager.CheckStageOpen(stageId) + local stageInfo = XFubenManager.GetStageInfo(stageId) + if stageInfo then + return stageInfo.IsOpen + else + return false + end + end + + function XFubenManager.CheckStageIsPass(stageId) + local stageInfo = XFubenManager.GetStageInfo(stageId) + if not stageInfo then + return false + end + + if stageInfo.Type == XFubenManager.StageType.Bfrt then + return XDataCenter.BfrtManager.IsGroupPassedByStageId(stageId) + elseif stageInfo.Type == XFubenManager.StageType.Assign then + return XDataCenter.FubenAssignManager.IsStagePass(stageId) + elseif stageInfo.Type == XFubenManager.StageType.TRPG then + return XDataCenter.TRPGManager.IsStagePass(stageId) + elseif stageInfo.Type == XFubenManager.StageType.Pokemon then + return XDataCenter.PokemonManager.CheckStageIsPassed(stageId) + elseif CheckStageIsPassHandler[stageInfo.Type] then + return CheckStageIsPassHandler[stageInfo.Type](stageId) + end + return stageInfo.Passed + end + + function XFubenManager.CheckStageIsUnlock(stageId) + local stageInfo = XFubenManager.GetStageInfo(stageId) + if not stageInfo then + return false + end + return stageInfo.Unlock or false + end + + function XFubenManager.GetStageLevelControl(stageId, playerLevel) + playerLevel = playerLevel or XPlayer.Level + return StageLevelMap[stageId] and StageLevelMap[stageId][playerLevel] + end + + function XFubenManager.GetStageProposedLevel(stageId, level) + local template = StageLevelMap[stageId] and StageLevelMap[stageId][level] + return template and template.RecommendationLevel or 1 + end + + function XFubenManager.GetStageMultiplayerLevelControl(stageId, difficulty) + return StageMultiplayerLevelMap[stageId] and StageMultiplayerLevelMap[stageId][difficulty] + end + + function XFubenManager.CheckMultiplayerLevelControl(stageId) + return StageMultiplayerLevelMap[stageId] + end + + function XFubenManager.CtorPreFight(stage, teamId) + local preFight = {} + preFight.CardIds = {} + preFight.StageId = stage.StageId + if not stage.RobotId or #stage.RobotId <= 0 then + local teamData = XDataCenter.TeamManager.GetTeamData(teamId) + for _, v in pairs(teamData) do + table.insert(preFight.CardIds, v) + end + end + return preFight + end + + function XFubenManager.CallOpenFightLoading(stageId) + local stageInfo = XFubenManager.GetStageInfo(stageId) + if OpenFightLoadingHandler[stageInfo.Type] then + OpenFightLoadingHandler[stageInfo.Type](stageId) + else + XFubenManager.OpenFightLoading(stageId) + end + + end + + function XFubenManager.OpenFightLoading(stageId) + XEventManager.DispatchEvent(XEventId.EVENT_FIGHT_LOADINGFINISHED) + + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + + if stageCfg and stageCfg.LoadingType then + XLuaUiManager.Open("UiLoading", stageCfg.LoadingType) + else + XLuaUiManager.Open("UiLoading", LoadingType.Fight) + end + end + + function XFubenManager.CallCloseFightLoading(stageId) + local stageInfo = XFubenManager.GetStageInfo(stageId) + if CloseFightLoadingHandler[stageInfo.Type] then + CloseFightLoadingHandler[stageInfo.Type](stageId) + else + XFubenManager.CloseFightLoading(stageId) + end + end + + function XFubenManager.CloseFightLoading() + XLuaUiManager.Remove("UiLoading") + end + + -- 通用结算 + function XFubenManager.SettleFight(result) + if XFubenManager.FubenSettling then + XLog.Warning("XFubenManager.SettleFight Warning, fuben is settling!") + return + end + + XFubenManager.StatisticsFightResultDps(result) + XFubenManager.FubenSettling = true + local fightResult = XFubenManager.CtorFightResult(result) + XFubenManager.CurFightResult = fightResult + + if result.FightData.Online then + if not result.IsForceExit then + if XFubenManager.FubenSettleResult then + XLuaUiManager.SetMask(true) + XFubenManager.IsWaitingResult = true + end + end + else + XNetwork.Call(METHOD_NAME.FightSettle, { Result = fightResult }, function(res) + --战斗结算清除数据的判断依据 + XFubenManager.FubenSettleResult = res + XEventManager.DispatchEvent(XEventId.EVENT_FUBEN_SETTLE_REWARD, res.Settle) + end) + end + end + + function XFubenManager.FinishStoryRequest(stageId, cb) + XNetwork.Call("EnterStoryRequest", { StageId = stageId }, function(res) + cb = cb or function() end + if res.Code == XCode.Success then + cb(res) + else + XUiManager.TipCode(res.Code) + end + end) + end + + function XFubenManager.CheckSettleFight() + return XFubenManager.FubenSettleResult ~= nil + end + + function XFubenManager.ExitFight() + if XFubenManager.FubenSettleResult then + CS.XFight.ExitForClient(false) + return true + end + return false + end + + function XFubenManager.ReadyToFight() + CS.XFight.ReadyToFight() + end + + function XFubenManager.CtorFightResult(result) + local bytes = result:GetFightsResultsBytes() + local fightResult = XMessagePack.Decode(bytes) + + -- 初始化数据结构 + XMessagePack.MarkAsTable(fightResult.IntToIntRecord) + XMessagePack.MarkAsTable(fightResult.StringToIntRecord) + XMessagePack.MarkAsTable(fightResult.NpcHpInfo) + XMessagePack.MarkAsTable(fightResult.NpcDpsTable) + XMessagePack.MarkAsTable(fightResult.Operations) + XMessagePack.MarkAsTable(fightResult.DeathRecord) + XMessagePack.MarkAsTable(fightResult.EpisodeFightResults) + return fightResult + end + + function XFubenManager.GetFubenNames(stageId) + local stage = XDataCenter.FubenManager.GetStageCfg(stageId) + local stageInfo = XFubenManager.GetStageInfo(stageId) + local chapterName, stageName + local curStageType = stageInfo.Type + + if curStageType == XDataCenter.FubenManager.StageType.Mainline then + local tmpStage = XDataCenter.FubenManager.GetStageCfg(stageId) + local chapterInfo = XDataCenter.FubenMainLineManager.GetChapterInfo(stageInfo.ChapterId) + local chapterMain = XDataCenter.FubenMainLineManager.GetChapterMainTemplate(chapterInfo.ChapterMainId) + chapterName = chapterMain.ChapterName + stageName = tmpStage.Name + elseif curStageType == XDataCenter.FubenManager.StageType.Urgent then + chapterName = "" + stageName = stage.Name + elseif curStageType == XDataCenter.FubenManager.StageType.Daily then + local tmpStageInfo = XDataCenter.FubenManager.GetStageCfg(stageId) + chapterName = tmpStageInfo.stageDataName + stageName = stage.Name + elseif curStageType == XDataCenter.FubenManager.StageType.BossSingle then + chapterName, stageName = XDataCenter.FubenBossSingleManager.GetBossNameInfo(stageInfo.BossSectionId, stageId) + elseif curStageType == XDataCenter.FubenManager.StageType.Arena then + local areaStageInfo = XDataCenter.ArenaManager.GetEnterAreaStageInfo() + chapterName = areaStageInfo.ChapterName + stageName = areaStageInfo.StageName + elseif curStageType == XDataCenter.FubenManager.StageType.ArenaOnline then + stageName = stage.Name + local arenaOnlineCfg = XDataCenter.ArenaOnlineManager.GetCurChapterCfg() + chapterName = arenaOnlineCfg and arenaOnlineCfg.Name or "" + elseif curStageType == XDataCenter.FubenManager.StageType.ExtraChapter then + local tmpStage = XDataCenter.FubenManager.GetStageCfg(stageId) + local chapterId = XDataCenter.ExtraChapterManager.GetChapterByChapterDetailsId(stageInfo.ChapterId) + local chapterDetail = XDataCenter.ExtraChapterManager.GetChapterCfg(chapterId) + chapterName = chapterDetail.ChapterName + stageName = tmpStage.Name + elseif curStageType == XDataCenter.FubenManager.StageType.WorldBoss then + chapterName = stage.ChapterName + stageName = stage.Name + elseif curStageType == XDataCenter.FubenManager.StageType.TRPG then + chapterName = stage.ChapterName + stageName = stage.Name + elseif curStageType == XDataCenter.FubenManager.StageType.Stronghold then + chapterName = stage.ChapterName + stageName = stage.Name + elseif curStageType == XDataCenter.FubenManager.StageType.KillZone then + chapterName = "" + stageName = XKillZoneConfigs.GetStageName(stageId) + end + + return chapterName, stageName + end + + function XFubenManager.GetUnlockHideStageById(stageId) + return UnlockHideStages[stageId] + end + + function XFubenManager.EnterPrequelFight(stageId) + local stageCfg = XFubenManager.GetStageCfg(stageId) + local stageInfo = XFubenManager.GetStageInfo(stageId) + if stageCfg and stageInfo then + if stageInfo.Unlock then + if stageCfg.RequireActionPoint > 0 then + if not XDataCenter.ItemManager.DoNotEnoughBuyAsset(XDataCenter.ItemManager.ItemId.ActionPoint, + stageCfg.RequireActionPoint, + 1, + function() XFubenManager.EnterPrequelFight(stageId) end, + "FubenActionPointNotEnough") then + return + end + end + -- + for _, conditionId in pairs(stageCfg.ForceConditionId or {}) do + local ret, desc = XConditionManager.CheckCondition(conditionId) + if not ret then + XUiManager.TipError(desc) + return + end + end + XDataCenter.PrequelManager.UpdateShowChapter(stageId) + XFubenManager.EnterFight(stageCfg, nil, false) + else + XUiManager.TipMsg(XFubenManager.GetFubenOpenTips(stageId)) + end + end + end + + -- 多重挑战相关 + function XFubenManager.GetMultiChallengeStageConfig(stageId) + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + local multiChallengeId = stageCfg.MultiChallengeId + if not multiChallengeId then + XLog.ErrorTableDataNotFound("XFubenManager.GetMultiChallengeStageConfig", + "multiChallengeId", "Share/Fuben/Stage.tab", "stageId", tostring(stageId)) + return + end + + local activityCfg = MultiChallengeConfigs[multiChallengeId] + if not activityCfg then + XLog.ErrorTableDataNotFound("XFubenManager.GetMultiChallengeStageConfig", + "activityCfg", "Share/Fuben/MultiChallengeStage.tab", "multiChallengeId", tostring(multiChallengeId)) + return + end + return activityCfg + end + + function XFubenManager.CheckChallengeCount(stageId, count) + local stageExCfg = XFubenManager.GetMultiChallengeStageConfig(stageId) + return stageExCfg.MultiChallengeMin <= count and count <= stageExCfg.MultiChallengeMax + end + + function XFubenManager.GetStageExCost(stageId) + local stageExCfg = XFubenManager.GetMultiChallengeStageConfig(stageId) + local itemId = stageExCfg.ConsumeId and stageExCfg.ConsumeId[1] or 0 + local itemNum = stageExCfg.ConsumeNum and stageExCfg.ConsumeNum[1] or 0 + return itemId, itemNum + end + + function XFubenManager.GetStageMaxChallengeCount(stageId) + local stageExCfg = XFubenManager.GetMultiChallengeStageConfig(stageId) + local maxTimes = stageExCfg.MultiChallengeMax + + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + local requirePoint = stageCfg.RequireActionPoint + local ownActionPoint = XDataCenter.ItemManager.GetCount(XDataCenter.ItemManager.ItemId.ActionPoint) + local times1 = requirePoint ~= 0 and math.floor(ownActionPoint / requirePoint) or maxTimes + + local exItemId, exItemCount = XFubenManager.GetStageExCost(stageId) + local ownExItemCount = exItemId ~= 0 and XDataCenter.ItemManager.GetCount(exItemId) or 0 + local times2 = exItemCount ~= 0 and math.floor(ownExItemCount / exItemCount) or maxTimes + + return math.min(times1, math.min(times2, maxTimes)) + end + + -- Rpc相关 + function XFubenManager.OnSyncStageData(stageList) + for _, v in pairs(stageList) do + PlayerStageData[v.StageId] = v + XEventManager.DispatchEvent(XEventId.EVENT_FUBEN_STAGE_SYNC, v.StageId) + end + XFubenManager.InitData(true) + end + + function XFubenManager.OnSyncUnlockHideStage(unlockHideStage) + UnlockHideStages[unlockHideStage] = true + end + + function XFubenManager.OnFightSettleNotify(response) + if XFubenManager.IsWaitingResult then + XLuaUiManager.SetMask(false) + end + XFubenManager.IsWaitingResult = false + XFubenManager.FubenSettleResult = response + XEventManager.DispatchEvent(XEventId.EVENT_FUBEN_SETTLE_REWARD, response.Settle) + end + + function XFubenManager.NewHideStage(Id) --记录新的隐藏关卡 + XFubenManager.NewHideStageId = Id + end + + function XFubenManager.CheckHasNewHideStage()--检查是否有新的隐藏关卡 + if XFubenManager.NewHideStageId then + local cfg = XDataCenter.FubenManager.GetStageCfg(XFubenManager.NewHideStageId) + local msg = CSTextManagerGetText("HideStageIsOpen", cfg.Name) + XUiManager.TipMsg(msg, XUiManager.UiTipType.Success, function() + XFubenManager.ClearNewHideStage() + XEventManager.DispatchEvent(XEventId.EVENT_FUNCTION_EVENT_COMPLETE) + end) + return true + end + return false + end + + function XFubenManager.ClearNewHideStage()--消除新的隐藏关卡记录 + XFubenManager.NewHideStageId = nil + end + + function XFubenManager.InitNewChallengeRedPointTable() -- 读取本地存储数据初始化新挑战红点纪录 + if XFubenManager.NewChallengeInit then return end + XFubenManager.NewChallengeInit = true + XFubenManager.NewChallengeRedPointTable = {} + local localData = XSaveTool.GetData(XPlayer.Id .. "NewChallengeRedPoint") + if not localData or type(localData) ~= "table" then return end + for i in pairs(localData) do + -- 若还没到新的开始时间,不采用之前的纪录 + if XFubenConfigs.IsNewChallengeStartById(localData[i].Id) and + localData[i].EndTime and localData[i].EndTime > XTime.GetServerNowTimestamp() then + XFubenManager.NewChallengeRedPointTable[localData[i].Id] = localData[i] + end + end + end + + function XFubenManager.RefreshNewChallengeRedPoint() -- 点击挑战页签时刷新新挑战红点状态 + local challengeLength = XFubenConfigs.GetNewChallengeConfigsLength() + if not challengeLength or challengeLength == 0 then return end + local needSave = false + for i = 1, challengeLength do + if XFunctionManager.JudgeCanOpen(XFubenConfigs.GetNewChallengeFunctionId(i)) + and XFubenConfigs.IsNewChallengeStartByIndex(i) then -- 若时间还未到达开始时间,不纪录 + local id = XFubenConfigs.GetNewChallengeId(i) + if not XFubenManager.NewChallengeRedPointTable[id] then + local newMessage = { + Id = id, + IsClicked = true, + EndTime = XFubenConfigs.GetNewChallengeEndTimeStamp(i), + } + XFubenManager.NewChallengeRedPointTable[id] = newMessage + needSave = true + elseif not XFubenManager.NewChallengeRedPointTable[id].IsClicked then + XFubenManager.NewChallengeRedPointTable[id].IsClicked = true + XFubenManager.NewChallengeRedPointTable[id].EndTime = XFubenConfigs.GetNewChallengeEndTimeStamp(i) + needSave = true + end + end + end + if needSave then XFubenManager.SaveNewChallengeRedPoint() end + end + + function XFubenManager.SaveNewChallengeRedPoint() -- 保存新挑战红点状态到本地 + XSaveTool.SaveData(XPlayer.Id .. "NewChallengeRedPoint", XFubenManager.NewChallengeRedPointTable) + XEventManager.DispatchEvent(XEventId.EVENT_FUBEN_NEW_CHALLEGE) + end + + function XFubenManager.IsNewChallengeRedPoint() -- 检查挑战页签的新玩法红点 + local challengeLength = XFubenConfigs.GetNewChallengeConfigsLength() + if not challengeLength or challengeLength <= 0 then return false end + for i = 1, challengeLength do + if XFunctionManager.JudgeCanOpen(XFubenConfigs.GetNewChallengeFunctionId(i)) + and XFubenConfigs.IsNewChallengeStartByIndex(i) then -- 检测是否新挑战已经开始 + local temp = XFubenManager.NewChallengeRedPointTable[XFubenConfigs.GetNewChallengeId(i)] + if temp == nil then return true + elseif temp ~= nil and not temp.IsClicked then return true end + end + end + return false + end + + local DefaultCharacterTypeConvert = { + [XFubenConfigs.CharacterLimitType.All] = XCharacterConfigs.CharacterType.Normal, + [XFubenConfigs.CharacterLimitType.Normal] = XCharacterConfigs.CharacterType.Normal, + [XFubenConfigs.CharacterLimitType.Isomer] = XCharacterConfigs.CharacterType.Isomer, + [XFubenConfigs.CharacterLimitType.IsomerDebuff] = XCharacterConfigs.CharacterType.Normal, + [XFubenConfigs.CharacterLimitType.NormalDebuff] = XCharacterConfigs.CharacterType.Isomer, + } + -- 获取编队类型限制对应的默认角色类型 + function XFubenManager.GetDefaultCharacterTypeByCharacterLimitType(characterLimitType) + return DefaultCharacterTypeConvert[characterLimitType] + end + -- 获取编队类型限制对应的强制角色类型 + function XFubenManager.GetForceCharacterTypeByCharacterLimitType(characterLimitType) + if characterLimitType == XFubenConfigs.CharacterLimitType.All + or characterLimitType == XFubenConfigs.CharacterLimitType.IsomerDebuff + or characterLimitType == XFubenConfigs.CharacterLimitType.NormalDebuff then return end + return DefaultCharacterTypeConvert[characterLimitType] + end + + function XFubenManager.ResetStagePassedStatus(stageIds) + for _, stageId in pairs(stageIds) do + local stageInfo = XFubenManager.GetStageInfo(stageId) + if PlayerStageData[stageId] then + PlayerStageData[stageId].Passed = false + end + stageInfo.Passed = false + end + for _, stageId in pairs(stageIds) do + local stageCfg = XFubenManager.GetStageCfg(stageId) + local stageInfo = XFubenManager.GetStageInfo(stageId) + stageInfo.Unlock = true + stageInfo.IsOpen = true + stageInfo.Passed = false + stageInfo.Stars = 0 + stageInfo.StarsMap = {false, false, false } + if stageCfg.RequireLevel > 0 and XPlayer.Level < stageCfg.RequireLevel then + stageInfo.Unlock = false + end + for _, preStageId in pairs(stageCfg.PreStageId or {}) do + if preStageId > 0 then + if not PlayerStageData[preStageId] or not PlayerStageData[preStageId].Passed then + stageInfo.Unlock = false + stageInfo.IsOpen = false + break + end + end + end + end + end + XFubenManager.Init() + + return XFubenManager +end + + +XRpc.NotifyStageData = function(data) + XDataCenter.FubenManager.OnSyncStageData(data.StageList) +end + +XRpc.OnEnterFight = function(data) + -- 进入战斗前关闭所有弹出框 + XDataCenter.FubenManager.OnEnterFight(data.FightData) +end + +XRpc.NotifyUnlockHideStage = function(data) + if not data then return end + XDataCenter.FubenManager.OnSyncUnlockHideStage(data.UnlockHideStage) + XDataCenter.FubenManager.NewHideStage(data.UnlockHideStage) +end + +XRpc.FightSettleNotify = function(response) + XLog.Debug("FightSettleNotify") + XLog.Debug(response) + XDataCenter.FubenManager.OnFightSettleNotify(response) +end + +XRpc.NotifyRemoveStageData = function(data) + XDataCenter.FubenManager.ResetStagePassedStatus(data.StageIds) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XFubenNewCharActivityManager.lua b/Resources/Scripts/XManager/XFubenNewCharActivityManager.lua new file mode 100644 index 00000000..ab9ecf16 --- /dev/null +++ b/Resources/Scripts/XManager/XFubenNewCharActivityManager.lua @@ -0,0 +1,396 @@ +XFubenNewCharActivityManagerCreator = function() + local XFubenNewCharActivityManager = {} + local TreasureRecord = {} + local StarRecords = {} + local KoroLastOpenPanel + + -- 注册出战界面代理 + local function RegisterEditBattleProxy() + XUiNewRoomSingleProxy.RegisterProxy(XDataCenter.FubenManager.StageType.NewCharAct, require("XUi/XUiNewChar/XUiNewCharNewRoomSingle")) + end + + local function Init() + RegisterEditBattleProxy() + -- 登录时服务端推送任务完成情况 + end + + local FUBEN_NEWCHAR_PROTO = { + TeachingTreasureRewardRequest = "TeachingTreasureRewardRequest", + } + + local GetStarsCount = function(starsMark) + local count = (starsMark & 1) + (starsMark & 2 > 0 and 1 or 0) + (starsMark & 4 > 0 and 1 or 0) + local starMap = {(starsMark & 1) > 0, (starsMark & 2) > 0, (starsMark & 4) > 0 } + return count, starMap + end + + -- [初始化数据] + function XFubenNewCharActivityManager.InitStageInfo() + local actTemplates = XFubenNewCharConfig.GetActTemplates() + for _, actTemplate in pairs(actTemplates or {}) do + for _, stageId in pairs(actTemplate.StageId) do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + if stageInfo then + stageInfo.Type = XDataCenter.FubenManager.StageType.NewCharAct + end + end + + for _, stageId in pairs(actTemplate.ChallengeStage) do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + if stageInfo then + stageInfo.Type = XDataCenter.FubenManager.StageType.NewCharAct + end + end + end + + -- 通关后需要会执行InitStage 所以需要刷新 + XFubenNewCharActivityManager.RefreshStagePassed() + end + + function XFubenNewCharActivityManager.RefreshStagePassed() + local actTemplates = XFubenNewCharConfig.GetActTemplates() + for _, actTemplate in pairs(actTemplates) do + for _, stageId in pairs(actTemplate.StageId) do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + if stageInfo then + stageInfo.Passed = StarRecords[stageId] or false + stageInfo.StarsMap = XFubenNewCharActivityManager.GetStarMap(stageId) + stageInfo.Unlock = true + stageInfo.IsOpen = true + + if stageCfg.RequireLevel > 0 and XPlayer.Level < stageCfg.RequireLevel then + stageInfo.Unlock = false + stageInfo.IsOpen = false + end + for _, preStageId in pairs(stageCfg.PreStageId or {}) do + if preStageId > 0 then + if not StarRecords[preStageId] then + stageInfo.Unlock = false + stageInfo.IsOpen = false + break + end + end + end + + end + end + + for _, stageId in pairs(actTemplate.ChallengeStage) do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + if stageInfo then + stageInfo.Passed = StarRecords[stageId] or false + stageInfo.StarsMap = XFubenNewCharActivityManager.GetStarMap(stageId) + stageInfo.Unlock = true + stageInfo.IsOpen = true + + if stageCfg.RequireLevel > 0 and XPlayer.Level < stageCfg.RequireLevel then + stageInfo.Unlock = false + stageInfo.IsOpen = false + end + for _, preStageId in pairs(stageCfg.PreStageId or {}) do + if preStageId > 0 then + if not StarRecords[preStageId] then + stageInfo.Unlock = false + stageInfo.IsOpen = false + break + end + end + end + + end + end + end + end + + -- 在进入战斗前,构建PreFightData请求XFightData + function XFubenNewCharActivityManager.PreFight(stage, teamId) + local preFight = {} + preFight.CardIds = {} + preFight.RobotIds = {} + preFight.StageId = stage.StageId + + if not stage.RobotId or #stage.RobotId <= 0 then + local teamData = XDataCenter.TeamManager.GetTeamData(teamId) + for i, v in pairs(teamData) do + local isRobot = XRobotManager.CheckIsRobotId(v) + preFight.RobotIds[i] = isRobot and v or 0 + preFight.CardIds[i] = isRobot and 0 or v + end + preFight.CaptainPos = XDataCenter.TeamManager.GetTeamCaptainPos(teamId) + preFight.FirstFightPos = XDataCenter.TeamManager.GetTeamFirstFightPos(teamId) + end + + return preFight + end + + function XFubenNewCharActivityManager.CheckStagePass(stageId) + return StarRecords[stageId] and true or false + end + + -- 获取所有关卡进度 + function XFubenNewCharActivityManager.GetStageSchedule(actId) + local template = XFubenNewCharConfig.GetDataById(actId) + + local passCount = 0 + local allCount = #template.StageId + + for _, stageId in ipairs(template.StageId) do + if StarRecords[stageId] then + passCount = passCount + 1 + end + end + + return passCount, allCount + end + + -- 获取篇章星数 + function XFubenNewCharActivityManager.GetStarProgressById(actId) + local template = XFubenNewCharConfig.GetDataById(actId) + local totalStars = template.TotalStars + local ownStars = 0 + for _,v in ipairs(template.StageId) do + local starsMark = StarRecords[v] + local starCount = starsMark and GetStarsCount(starsMark) or 0 + ownStars = ownStars + starCount + end + return ownStars, totalStars or 0 + end + + --库洛姆版本篇章星数获取 + function XFubenNewCharActivityManager.GetKoroStarProgressById(actId) + local template = XFubenNewCharConfig.GetDataById(actId) + local totalStars = template.TotalStars + local ownStars = 0 + for _,v in ipairs(template.ChallengeStage) do + local starsMark = StarRecords[v] + local starCount = starsMark and GetStarsCount(starsMark) or 0 + ownStars = ownStars + starCount + end + return ownStars, totalStars or 0 + end + + function XFubenNewCharActivityManager.GetAvailableActs() + local acts = XFubenNewCharConfig.GetActTemplates() + local activityList = {} + local now = XTime.GetServerNowTimestamp() + for _, v in pairs(acts) do + local beginTimeSecond, endTimeSecond = XFubenNewCharConfig.GetActivityTime(v.Id) + if beginTimeSecond and endTimeSecond then + if (not XFunctionManager.CheckFunctionFitter(v.FunctionOpenId)) and now > beginTimeSecond and endTimeSecond > now then + table.insert(activityList, { + Id = v.Id, + Type = XDataCenter.FubenManager.ChapterType.NewCharAct, + Name = v.Name, + Icon = v.BannerBg, + }) + end + end + end + return activityList + end + + + function XFubenNewCharActivityManager.HandleNewCharActData(data) + for _, info in ipairs(data.ActivityInfo) do + for _, v in ipairs(info.TreasureRecord) do + TreasureRecord[v] = true + end + + for _, v in ipairs(info.StarRecords) do + XFubenNewCharActivityManager.HandleNewStageStarRecord(v) + end + end + XFubenNewCharActivityManager.RefreshStagePassed() + end + + function XFubenNewCharActivityManager.HandleNewStageStarRecord(data) + -- Id 是指StageId(关卡Id) + StarRecords[data.Id] = data.StarsMark + XFubenNewCharActivityManager.RefreshStagePassed() + XEventManager.DispatchEvent(XEventId.EVENT_KORO_CHAR_ACTIVITY_REDPOINTEVENT) + end + + function XFubenNewCharActivityManager.GetStarMap(stageId) + local starsMark = StarRecords[stageId] or 0 + local count, starMap = GetStarsCount(starsMark) + return starMap, count + end + + function XFubenNewCharActivityManager.GetStarReward(treasureId, cb) + XNetwork.Call(FUBEN_NEWCHAR_PROTO.TeachingTreasureRewardRequest, {TreasureId = treasureId},function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + -- 设置已领取 + TreasureRecord[treasureId] = true + if cb then + cb(res.RewardGoodsList) + end + XEventManager.DispatchEvent(XEventId.EVENT_FUBEN_NEWCHARACT_REWARD) + end) + end + + -- [胜利] + function XFubenNewCharActivityManager.ShowReward(winData) + if not winData then return end + + XFubenNewCharActivityManager.RefreshStagePassed() + XLuaUiManager.Open("UiSettleWinMainLine", winData) + end + + function XFubenNewCharActivityManager.IsTreasureGet(treasureId) + return TreasureRecord[treasureId] + end + + function XFubenNewCharActivityManager.IsOpen(actId) + local nowTime = XTime.GetServerNowTimestamp() + if not actId then + for _, v in pairs(XFubenNewCharConfig.GetActTemplates()) do + actId = v.Id + if XFunctionManager.CheckInTimeByTimeId(v.TimeId) then + return true + end + end + end + local beginTime, endTime = XFubenNewCharConfig.GetActivityTime(actId) + return beginTime <= nowTime and nowTime < endTime, beginTime, endTime + end + + function XFubenNewCharActivityManager.IsChallengeable(actId) + local koroCfg = XFubenNewCharConfig.GetDataById(actId) + if not koroCfg then + return false + end + + local challengeStageIds = koroCfg.StageId + if challengeStageIds then + for _, v in pairs(challengeStageIds) do + if not XFubenNewCharActivityManager.CheckStagePass(v) then + return true + end + end + end + + challengeStageIds = koroCfg.ChallengeStage + if challengeStageIds then + for _, v in pairs(challengeStageIds) do + if not XFubenNewCharActivityManager.CheckStagePass(v) then + return true + end + end + end + + return false + + --if not XFubenNewCharActivityManager.IsOpen(actId) then return false end + --local ActStageIds = XFubenNewCharConfig.GetDataById(actId).StageId + --for _,stageId in ipairs(ActStageIds) do + -- if not XFubenNewCharActivityManager.CheckStagePass(stageId) then + -- return true + -- end + --end + --return false + end + + function XFubenNewCharActivityManager.CheckTreasureReward(actId) + local hasReward = false + local template = XFubenNewCharConfig.GetDataById(actId) + local targetList = template.TreasureId + + for _, var in ipairs(targetList) do + local treasureCfg = XFubenNewCharConfig.GetTreasureCfg(var) + if treasureCfg then + local requireStars = treasureCfg.RequireStar + local starCount = 0 + local stageList = template.ChallengeStage or template.StageId + + + for _, stageId in ipairs(stageList) do + local _, star = XFubenNewCharActivityManager.GetStarMap(stageId) + starCount = starCount + star + end + + if requireStars > 0 and requireStars <= starCount then + local isGet = XFubenNewCharActivityManager.IsTreasureGet(treasureCfg.TreasureId) + if not isGet then + hasReward = true + break + end + end + end + end + + return hasReward + end + + function XFubenNewCharActivityManager.GetStardRewardNeedStarNum(id, rewardIndex) + local trainedLevelCfg = XFubenExperimentConfigs.GetTrialLevelCfgById(id) + local trialRewardCfg = XFubenExperimentConfigs.GetTrialStarRewardCfgById(trainedLevelCfg.StarReward) + local starNumList = trialRewardCfg.StarNum + + if not starNumList[rewardIndex] then + return nil + end + + return starNumList[rewardIndex] + end + + --库洛姆人物活动 + function XFubenNewCharActivityManager.CheckChallengeRedPoint() + local koroCfg = XFubenNewCharConfig.GetNewCharKoroCfg() + if not koroCfg then + return false + end + + return XDataCenter.FubenNewCharActivityManager.CheckTreasureReward(koroCfg.Id) + end + + function XFubenNewCharActivityManager.CheckTeachingRedPoint() + local koroCfg = XFubenNewCharConfig.GetNewCharKoroCfg() + if not koroCfg then + return false + end + local nowTime = XTime.GetServerNowTimestamp() + local beginTime,endTime = XFunctionManager.GetTimeByTimeId(koroCfg.TimeId) + if nowTime < beginTime or nowTime > endTime then + return false + end + local challengeStageIds = koroCfg.StageId + if challengeStageIds then + for _, v in pairs(challengeStageIds) do + if not XFubenNewCharActivityManager.CheckStagePass(v) then + return true + end + end + end + + return false + end + + function XFubenNewCharActivityManager.SetKoroLastOpenPanel(panelStage) + KoroLastOpenPanel = panelStage + end + + function XFubenNewCharActivityManager.GetKoroLastOpenPanel() + return KoroLastOpenPanel + end + + function XFubenNewCharActivityManager.GetCharacterList(id) + return XFubenNewCharConfig:GetTryCharacterIds(id) + end + + XEventManager.AddEventListener(XEventId.EVENT_LOGIN_DATA_LOAD_COMPLETE, Init) + return XFubenNewCharActivityManager +end + +XRpc.NotifyTeachingActivityInfo = function(data) + XDataCenter.FubenNewCharActivityManager.HandleNewCharActData(data) +end + +XRpc.NotifyTeachingUpdateStageInfo = function(data) + XDataCenter.FubenNewCharActivityManager.HandleNewStageStarRecord(data.Info) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XFubenRepeatChallengeManager.lua b/Resources/Scripts/XManager/XFubenRepeatChallengeManager.lua new file mode 100644 index 00000000..f05afcfb --- /dev/null +++ b/Resources/Scripts/XManager/XFubenRepeatChallengeManager.lua @@ -0,0 +1,466 @@ +XFubenRepeatChallengeManagerCreator = function() + local pairs = pairs + local tableInsert = table.insert + local stringGsub = string.gsub + + local CurActivityId = XFubenRepeatChallengeConfigs.GetDefaultActivityId() + local SelectDifficult = false --记录上次是否选中挑战难度 + local ChapterIdToPassedStageIdDic = {} --章节Id-通关进度Dic + local GotRewardIdCheckDic = {} -- 已领取奖励Id记录 + local NewChapterTipInfo = {} -- 新章节开启提示 + local StageIdToChapterId = {} + local AddLevelTip -- 权限等级增加提示 + -- 活动等级信息 + local LevelInfo = { + Level = 0, + Exp = 0, + DayExp = 0, + } + + local XFubenRepeatChallengeManager = {} + + XFubenRepeatChallengeManager.ExCostItemId = CS.XGame.ClientConfig:GetInt("FubenRepeatChallengeExCostItemId") --复刷关门票Id(展示用) + XFubenRepeatChallengeManager.DifficultType = { + Normal = 1, + Difficult = 2, + } + + function XFubenRepeatChallengeManager.Init() + XEventManager.AddEventListener(XEventId.EVENT_FUBEN_REFRESH_STAGE_DATA, XFubenRepeatChallengeManager.RefreshStagePassed) + end + + function XFubenRepeatChallengeManager.InitStageInfo() + local config = XFubenRepeatChallengeManager.GetActivityConfig() + + for _, chapterId in pairs(config.NormalChapter) do + local chapterCfg = XFubenRepeatChallengeConfigs.GetChapterCfg(chapterId) + for _, stageId in pairs(chapterCfg.StageId) do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + stageInfo.Type = XDataCenter.FubenManager.StageType.RepeatChallenge + StageIdToChapterId[stageId] = chapterId + end + end + + for _, chapterId in pairs(config.HiddenChapter) do + local chapterCfg = XFubenRepeatChallengeConfigs.GetChapterCfg(chapterId) + for _, stageId in pairs(chapterCfg.StageId) do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + stageInfo.Type = XDataCenter.FubenManager.StageType.RepeatChallenge + StageIdToChapterId[stageId] = chapterId + end + end + end + + function XFubenRepeatChallengeManager.GetChapterIdByStageId(stageId) + return StageIdToChapterId[stageId] + end + + function XFubenRepeatChallengeManager.ResetNewChapterTipInfo() + NewChapterTipInfo = {} + end + + function XFubenRepeatChallengeManager.GetNewChapterTipInfo() + return NewChapterTipInfo + end + + function XFubenRepeatChallengeManager.UpdateChapterGotRewardIds(rewardIds) + GotRewardIdCheckDic = {} + if not rewardIds then return end + for _, rewardId in pairs(rewardIds) do + GotRewardIdCheckDic[rewardId] = true + end + end + + function XFubenRepeatChallengeManager.UpdateChapterIdToPassedStageIdDic(chapterInfos) + ChapterIdToPassedStageIdDic = {} + + if not chapterInfos then return end + for _, chapterInfo in pairs(chapterInfos) do + ChapterIdToPassedStageIdDic[chapterInfo.Id] = chapterInfo.FinishStages + end + + XFubenRepeatChallengeManager.RefreshStagePassed() + end + + local function RefreshStagePassedByChapterIds(chapterIds) + for _, chapterId in pairs(chapterIds) do + local passedStageIds = ChapterIdToPassedStageIdDic[chapterId] + local schedule = passedStageIds and #passedStageIds or 0 + local chapterCfg = XFubenRepeatChallengeConfigs.GetChapterCfg(chapterId) + for index, stageId in pairs(chapterCfg.StageId) do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + if index <= schedule then + stageInfo.Passed = true + else + stageInfo.Passed = false + end + + if index <= schedule + 1 then + stageInfo.Unlock = true + stageInfo.IsOpen = true + else + stageInfo.IsOpen = false + end + end + end + end + + function XFubenRepeatChallengeManager.RefreshStagePassed() + local config = XFubenRepeatChallengeManager.GetActivityConfig() + RefreshStagePassedByChapterIds(config.NormalChapter) + RefreshStagePassedByChapterIds(config.HiddenChapter) + end + + function XFubenRepeatChallengeManager.PassStage(stageId) + local chapterId = XFubenRepeatChallengeConfigs.GetChapterIdByStageId(stageId) + local chapterStagePassedInfo = ChapterIdToPassedStageIdDic[chapterId] or {} + for _, existStageId in pairs(chapterStagePassedInfo) do + if existStageId == stageId then + return + end + end + + tableInsert(chapterStagePassedInfo, stageId) + ChapterIdToPassedStageIdDic[chapterId] = chapterStagePassedInfo + XFubenRepeatChallengeManager.RefreshStagePassed() + end + + function XFubenRepeatChallengeManager.GetActivitySections() + local sections = {} + + if XFubenRepeatChallengeManager.IsOpen() then + local curId = XFubenRepeatChallengeManager.GetCurChapterId(XFubenRepeatChallengeManager.DifficultType.Normal) + if not curId then + XLog.Error("XFubenRepeatChallengeManager.GetActivitySections Error: 复刷关时间配置错误, 活动开启中但没有可用作战章节时间, 配置路径:" .. XFubenRepeatChallengeConfigs.GetChapterCfgPath()) + return sections + end + + local section = { + Id = curId, + Type = XDataCenter.FubenManager.ChapterType.RepeatChallenge, + } + tableInsert(sections, section) + end + + return sections + end + + function XFubenRepeatChallengeManager.GetChapterId(difficultType, index) + local chapterIds = XFubenRepeatChallengeManager.GetChapterIds(difficultType) + return chapterIds[index] + end + + function XFubenRepeatChallengeManager.GetChapterNum(difficultType) + local chapterIds = XDataCenter.FubenRepeatChallengeManager.GetChapterIds(difficultType) + return chapterIds and #chapterIds or 0 + end + + function XFubenRepeatChallengeManager.GetAllChapterIds() + local allChapterIds = {} + for _, difficultType in pairs(XFubenRepeatChallengeManager.DifficultType) do + local chapterIds = XFubenRepeatChallengeManager.GetChapterIds(difficultType) + for _, chapterId in pairs(chapterIds) do + if chapterId ~= 0 then + tableInsert(allChapterIds, chapterId) + end + end + end + return allChapterIds + end + + function XFubenRepeatChallengeManager.GetChapterIds(difficultType) + local config = XFubenRepeatChallengeManager.GetActivityConfig() + return difficultType == XFubenRepeatChallengeManager.DifficultType.Difficult and config.HiddenChapter or config.NormalChapter + end + + function XFubenRepeatChallengeManager.GetCurChapterIndex(difficultType) + local curChapterIndex + + local chapterIds = XFubenRepeatChallengeManager.GetChapterIds(difficultType) + if XFubenRepeatChallengeManager.IsStatusEqualFightEnd() then + curChapterIndex = #chapterIds + else + for index, chapterId in ipairs(chapterIds) do + curChapterIndex = XFubenRepeatChallengeManager.IsChapterUnlock(chapterId) and index or curChapterIndex + end + end + + return curChapterIndex + end + + function XFubenRepeatChallengeManager.GetCurChapterId(difficultType) + local curChapterIndex = XFubenRepeatChallengeManager.GetCurChapterIndex(difficultType) + local chapterIds = XFubenRepeatChallengeManager.GetChapterIds(difficultType) + return chapterIds[curChapterIndex] + end + + function XFubenRepeatChallengeManager.GetChapterFinishCount(chapterId) + local chapterPassedInfo = ChapterIdToPassedStageIdDic[chapterId] + return chapterPassedInfo and #chapterPassedInfo or 0 + end + + function XFubenRepeatChallengeManager.GetActivityBeginTime() + local config = XFubenRepeatChallengeManager.GetActivityConfig() + return XFunctionManager.GetStartTimeByTimeId(config.ActivityTimeId) + end + + function XFubenRepeatChallengeManager.GetActivityChallengeBeginTime() + local config = XFubenRepeatChallengeManager.GetActivityConfig() + return XFunctionManager.GetStartTimeByTimeId(config.ChallengeTimeId) + end + + function XFubenRepeatChallengeManager.GetFightEndTime() + local config = XFubenRepeatChallengeManager.GetActivityConfig() + return XFunctionManager.GetEndTimeByTimeId(config.FightTimeId) + end + + function XFubenRepeatChallengeManager.GetActivityEndTime() + local config = XFubenRepeatChallengeManager.GetActivityConfig() + return XFunctionManager.GetEndTimeByTimeId(config.ActivityTimeId) + end + + function XFubenRepeatChallengeManager.GetActDescription() + local config = XFubenRepeatChallengeManager.GetActivityConfig() + return stringGsub(config.ActDescription, "\\n", "\n") + end + + function XFubenRepeatChallengeManager.GetSelectDifficult() + return SelectDifficult + end + + function XFubenRepeatChallengeManager.SelectDifficult(selectDifficult) + SelectDifficult = selectDifficult + end + + function XFubenRepeatChallengeManager.GetLevel() + return LevelInfo.Level + end + + function XFubenRepeatChallengeManager.GetNextShowLevel() + for i = LevelInfo.Level + 1, XFubenRepeatChallengeConfigs.GetMaxLevel() do + local levelConfig = XFubenRepeatChallengeConfigs.GetLevelConfig(i) + if levelConfig.NeedShow then return i end + end + end + + function XFubenRepeatChallengeManager.GetOriginExp() + return LevelInfo.Exp + end + + function XFubenRepeatChallengeManager.GetExp() + local totalExp = LevelInfo.Exp + local level = XFubenRepeatChallengeManager.GetLevel() + for lv = 1, level - 1 do + local levelConfig = XFubenRepeatChallengeConfigs.GetLevelConfig(lv) + totalExp = totalExp - levelConfig.UpExp + end + return totalExp + end + + function XFubenRepeatChallengeManager.GetDayExp() + return LevelInfo.DayExp + end + + function XFubenRepeatChallengeManager.GetSelectDifficult() + return SelectDifficult + end + + function XFubenRepeatChallengeManager.GetActivityConfig() + return XFubenRepeatChallengeConfigs.GetActivityConfig(CurActivityId) + end + + function XFubenRepeatChallengeManager.GetChapterRewardId(chapterId) + local rewardConfig = XFubenRepeatChallengeConfigs.GetChapterRewardConfig(chapterId) + return rewardConfig.RewardId + end + + function XFubenRepeatChallengeManager.GetChapterBeginTime(chapterId) + local chapterConfig = XFubenRepeatChallengeConfigs.GetChapterCfg(chapterId) + return XFunctionManager.GetStartTimeByTimeId(chapterConfig.TimeId) + end + + function XFubenRepeatChallengeManager.GetChapterEndTime(chapterId) + local chapterConfig = XFubenRepeatChallengeConfigs.GetChapterCfg(chapterId) + return XFunctionManager.GetEndTimeByTimeId(chapterConfig.TimeId) + end + + function XFubenRepeatChallengeManager.GetBuffDes(buffId) + local fightEventCfg = buffId and buffId ~= 0 and CS.XNpcManager.GetFightEventTemplate(buffId) + return fightEventCfg and fightEventCfg.Description + end + + function XFubenRepeatChallengeManager.IsLevelReach(checkLevel) + local level = XFubenRepeatChallengeManager.GetLevel() + return level >= checkLevel + end + + function XFubenRepeatChallengeManager.IsBeforeChapterTime(chapterId) + local chapterConfig = XFubenRepeatChallengeConfigs.GetChapterCfg(chapterId) + local now = XTime.GetServerNowTimestamp() + local beginTime = XFunctionManager.GetStartTimeByTimeId(chapterConfig.TimeId) + return now < beginTime + end + + function XFubenRepeatChallengeManager.IsChapterUnlock(chapterId) + local chapterConfig = XFubenRepeatChallengeConfigs.GetChapterCfg(chapterId) + local now = XTime.GetServerNowTimestamp() + local beginTime = XFunctionManager.GetStartTimeByTimeId(chapterConfig.TimeId) + local endTime = XFunctionManager.GetEndTimeByTimeId(chapterConfig.TimeId) + return beginTime <= now and now < endTime + end + + function XFubenRepeatChallengeManager.IsStageFinished(stageId) + return XFubenRepeatChallengeManager.IsChapterFinished(StageIdToChapterId[stageId]) + end + + function XFubenRepeatChallengeManager.IsChapterFinished(chapterId) + local chapterConfig = XFubenRepeatChallengeConfigs.GetChapterCfg(chapterId) + local now = XTime.GetServerNowTimestamp() + local endTime = XFunctionManager.GetEndTimeByTimeId(chapterConfig.TimeId) + return now > endTime + end + + function XFubenRepeatChallengeManager.IsStatusEqualFightEnd() + local now = XTime.GetServerNowTimestamp() + local fightEndTime = XFubenRepeatChallengeManager.GetFightEndTime() + local endTime = XFubenRepeatChallengeManager.GetActivityEndTime() + return fightEndTime <= now and now < endTime + end + + function XFubenRepeatChallengeManager.IsStatusEqualChallengeBegin() + local now = XTime.GetServerNowTimestamp() + local challengeBeginTime = XFubenRepeatChallengeManager.GetActivityChallengeBeginTime() + local endTime = XFubenRepeatChallengeManager.GetActivityEndTime() + return challengeBeginTime <= now and now < endTime + end + + function XFubenRepeatChallengeManager.IsOpen() + local nowTime = XTime.GetServerNowTimestamp() + local beginTime = XFubenRepeatChallengeManager.GetActivityBeginTime() + local endTime = XFubenRepeatChallengeManager.GetActivityEndTime() + return beginTime <= nowTime and nowTime < endTime + end + + function XFubenRepeatChallengeManager.IsDifficultModeOpen() + local config = XFubenRepeatChallengeManager.GetActivityConfig() + local conditionId = config.HideChapterConditionId + if conditionId ~= 0 then + return XConditionManager.CheckCondition(conditionId) + end + return true + end + + function XFubenRepeatChallengeManager.CheckPreFight(stage, challengeCount) + if not XDataCenter.FubenRepeatChallengeManager.IsOpen() then + XUiManager.TipText("ActivityRepeatChallengeOver") + return false + end + + if XDataCenter.FubenRepeatChallengeManager.IsStatusEqualFightEnd() then + XUiManager.TipText("ActivityRepeatChallengeOver") + return false + end + + local itemId, itemNum = XDataCenter.FubenManager.GetStageExCost(stage.StageId) + if XDataCenter.ItemManager.GetCount(itemId) < itemNum * challengeCount then + XUiManager.TipText("ActivityRepeatChallengeCostNotEnough") + return false + end + + return true + end + + function XFubenRepeatChallengeManager.CheckChapterRewardCanGetReal(chapterId) + if not XFubenRepeatChallengeManager.IsOpen() then return false end + if XFubenRepeatChallengeManager.IsBeforeChapterTime(chapterId) then return false end + + local canGet = XFubenRepeatChallengeManager.CheckChapterRewardCanGet(chapterId) + local hasGot = XFubenRepeatChallengeManager.CheckChapterRewardGot(chapterId) + return canGet and not hasGot + end + + function XFubenRepeatChallengeManager.CheckChapterRewardGot(chapterId) + return GotRewardIdCheckDic[chapterId] + end + + function XFubenRepeatChallengeManager.CheckChapterRewardCanGet(chapterId) + local rewardConfig = XFubenRepeatChallengeConfigs.GetChapterRewardConfig(chapterId) + local conditionId = rewardConfig.Condition + if conditionId ~= 0 then + return XConditionManager.CheckCondition(conditionId) + end + end + + function XFubenRepeatChallengeManager.OnActivityEnd() + if CS.XFight.IsRunning or XLuaUiManager.IsUiLoad("UiLoading") then + return + end + XUiManager.TipText("ActivityRepeatChallengeOver") + XLuaUiManager.RunMain() + end + + function XFubenRepeatChallengeManager.ShowReward(winData) + if not winData then return end + XFubenRepeatChallengeManager.PassStage(winData.StageId) + XLuaUiManager.Open("UiRepeatChallengeSettleWin", winData, AddLevelTip) + end + + function XFubenRepeatChallengeManager.NotifyRepeatChallengeData(data) + CurActivityId = data.Id + LevelInfo = data.ExpInfo + XFubenRepeatChallengeManager.UpdateChapterGotRewardIds(data.RewardIds) + XFubenRepeatChallengeManager.UpdateChapterIdToPassedStageIdDic(data.RcChapters) + end + + function XFubenRepeatChallengeManager.UpdateLevelInfo(data) + local oldExp = XFubenRepeatChallengeManager.GetOriginExp() + local oldCurNormalChapterIndex = XFubenRepeatChallengeManager.GetCurChapterIndex(XFubenRepeatChallengeManager.DifficultType.Normal) + local oldCurDifficultChapterIndex = XFubenRepeatChallengeManager.GetCurChapterIndex(XFubenRepeatChallengeManager.DifficultType.Difficult) + LevelInfo = data.ExpInfo + local newExp = XFubenRepeatChallengeManager.GetOriginExp() + local newCurNormalChapterIndex = XFubenRepeatChallengeManager.GetCurChapterIndex(XFubenRepeatChallengeManager.DifficultType.Normal) + local newCurDifficultChapterIndex = XFubenRepeatChallengeManager.GetCurChapterIndex(XFubenRepeatChallengeManager.DifficultType.Difficult) + + if oldCurNormalChapterIndex ~= newCurNormalChapterIndex then + NewChapterTipInfo.OldIndex = oldCurNormalChapterIndex + NewChapterTipInfo.NewIndex = newCurNormalChapterIndex + elseif oldCurDifficultChapterIndex ~= newCurDifficultChapterIndex then + NewChapterTipInfo.OldIndex = oldCurDifficultChapterIndex + NewChapterTipInfo.NewIndex = newCurDifficultChapterIndex + end + + local addExp = newExp - oldExp + if addExp > 0 then + AddLevelTip = addExp + end + end + + function XFubenRepeatChallengeManager.ClearAddLevelTip() + AddLevelTip = nil + end + + function XFubenRepeatChallengeManager.RequesetGetReward(chapterId, cb) + if not chapterId or chapterId == 0 then return end + XNetwork.Call("RepeatChallengeRewardRequest", { Id = chapterId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + GotRewardIdCheckDic[chapterId] = true + + if cb then cb(res.RewardGoodsList) end + end) + end + + XFubenRepeatChallengeManager.Init() + return XFubenRepeatChallengeManager +end + +XRpc.NotifyRepeatChallengeData = function(data) + XDataCenter.FubenRepeatChallengeManager.NotifyRepeatChallengeData(data) +end + +XRpc.NotifyRcExpChange = function(data) + XDataCenter.FubenRepeatChallengeManager.UpdateLevelInfo(data) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XFubenResourceManager.lua b/Resources/Scripts/XManager/XFubenResourceManager.lua new file mode 100644 index 00000000..77dc54a2 --- /dev/null +++ b/Resources/Scripts/XManager/XFubenResourceManager.lua @@ -0,0 +1,199 @@ +XFubenResourceManagerCreator = function() + + local XFubenResourceManager = {} + + local PREFS_LEVEL_KEY = "FunbenResourceLastLevel" + -- local PREFS_REWARD_KEY = "FunbenResourceLastReward" + -- local TABLE_LEVEL_SECTION = "Share/Fuben/FubenResource/FubenResourceLevelSection.tab" + -- local TABLE_RESOURCE_CHAPTER = "Share/Fuben/FubenResource/FubenResourceChapter.tab" + --资源副本配置表 + -- local LevelSectionCfg = {} + --挑战副本入口表的子表 + local FubenResourceChapter = {} + --当天副本数据 + local CurrentSectionData = nil + local NextRefreshTime = nil + local LastPlayerLevel = nil + local TopRewardList = nil + local TempTopRewardList = nil + + local ResourceType = { + Coin = 1, + Skill = 2, + } + + --读取玩家本地缓存 + local function InitPrefs() + local lastLevel = XSaveTool.GetData(XPlayer.Id .. PREFS_LEVEL_KEY) + if lastLevel then + LastPlayerLevel = lastLevel + else + LastPlayerLevel = XPlayer.Level + XSaveTool.SaveData(XPlayer.Id .. PREFS_LEVEL_KEY, LastPlayerLevel) + end + end + + function XFubenResourceManager.Init() + -- LevelSectionCfg = XTableManager.ReadByIntKey(TABLE_LEVEL_SECTION, XTable.XTableFubenResourceLevelSection, "Id") + -- FubenResourceChapter = XTableManager.ReadByIntKey(TABLE_RESOURCE_CHAPTER, XTable.XFubenResourceChapter, "Id") + end + + function XFubenResourceManager.InitStageInfo() + -- for sectionId, sectionCfg in pairs(LevelSectionCfg) do + -- for _, stageId in pairs(sectionCfg.StageList) do + -- local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + -- stageInfo.ResourceType = sectionCfg.Type + -- stageInfo.Type = XDataCenter.FubenManager.StageType.Resource + -- end + -- end + end + + --从服务器获取相关数据 + function XFubenResourceManager.InitFubenResourceData() + -- CurrentSectionData = {} + -- for _, data in pairs(stageMaps) do + -- local cfg = LevelSectionCfg[data.ConfigId] + -- local index = data.Index + 1 + -- local typeId = cfg.Type + -- local localTable = { + -- Type = typeId, + -- Difficulty = cfg.DifficultyList[index], + -- ColorChallenge = cfg.ColorChallengeList[index], + -- ColorReward = cfg.ColorRewardList[index], + -- StageId = cfg.StageList[index], + -- LeftCount = data.LeftCount, + -- MaxCount = cfg.DaliyCount, + -- } + -- CurrentSectionData[typeId] = localTable + -- end + end + + function XFubenResourceManager.CheckPreFight(stage) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stage.StageId) + local resourceData = XFubenResourceManager.GetSectionDataByTypeId(stageInfo.ResourceType) + if resourceData.LeftCount <= 0 then + local msg = CS.XTextManager.GetText("FubenChallengeCountNotEnough") + XUiManager.TipMsg(msg) + return false + end + return true + end + + --更新资源副本剩余挑战次数 + function XFubenResourceManager.FubenLeftCountUpdate(data) + CurrentSectionData[data.Type].LeftCount = data.LeftCount + end + + --更新资源副本通关收益 + function XFubenResourceManager.FubenRewardUpdate(data) + local maxRewards = { + [ResourceType.Coin] = data.CoinRewardNum, + [ResourceType.Skill] = data.SkillRewardNum, + } + if not TopRewardList then + TopRewardList = maxRewards + return + end + TempTopRewardList = maxRewards + end + + --检查最高奖励是否有变化 + function XFubenResourceManager.CheckRewradChange(typeId) + if not TempTopRewardList or not TempTopRewardList[typeId] then + return false + end + + if not TopRewardList then + TopRewardList = {} + end + + return TempTopRewardList[typeId] > (TopRewardList[typeId] or 0) + end + + --将缓存数据更换到实际记录数据 + function XFubenResourceManager.UpdateRewardFromTemp() + if TempTopRewardList then + TopRewardList = TempTopRewardList + end + TempTopRewardList = nil + end + + --获取玩家上次的等级和当前的等级 + function XFubenResourceManager.GetPlayerLevelInfo() + if not LastPlayerLevel then + InitPrefs() + end + local nowLevel = XPlayer.Level + local lastLevel = nil + if XPlayer.Level ~= LastPlayerLevel then + if XPlayer.Level > LastPlayerLevel then + lastLevel = LastPlayerLevel + else + XLog.Error("XFubenResourceManager.LastPlayerLevel is Wrong!") + end + LastPlayerLevel = XPlayer.Level + XSaveTool.SaveData(XPlayer.Id .. PREFS_LEVEL_KEY, LastPlayerLevel) + end + return nowLevel, lastLevel + end + + function XFubenResourceManager.GetTopRewardByTypeId(typeId) + if TempTopRewardList and TempTopRewardList[typeId] then + return TempTopRewardList[typeId] + else + return TopRewardList[typeId] or 0 + end + end + + function XFubenResourceManager.GetResourceChapters() + return FubenResourceChapter + end + + --获取资源副本数据 + function XFubenResourceManager.GetSectionDatas() + return CurrentSectionData + end + + --根据资源副本类型ID获取资源副本Cfg + function XFubenResourceManager.GetSectionDataByTypeId(typeId) + return CurrentSectionData[typeId] + end + + function XFubenResourceManager.GetRemainingTime() + local timeNow = XTime.GetServerNowTimestamp() + if NextRefreshTime < timeNow then + return 0 + end + return (NextRefreshTime - timeNow) + end + + --服务端协议 + function XFubenResourceManager.GetCurrentSectionData() + -- XNetwork.Call("ResourceStageDataRequest", nil, function(res) + -- if res.Code ~= XCode.Success then + -- XUiManager.TipCode(res.Code) + -- return + -- end + -- NextRefreshTime = res.NextRefreshTime + -- local stageMaps = { + -- [ResourceType.Coin] = res.CoinStageData; + -- [ResourceType.Skill] = res.SkillStageData; + -- } + -- XFubenResourceManager.InitFubenResourceData(stageMaps) + -- if callback then + -- callback(CurrentSectionData) + -- end + -- end) + end + + XFubenResourceManager.Init() + return XFubenResourceManager +end + +XRpc.NotifyResourceStageSingleData = function(data) + XDataCenter.FubenResourceManager.FubenLeftCountUpdate(data) +end + +XRpc.NotifyResourceStageRewardIds = function(data) + XDataCenter.FubenResourceManager.FubenRewardUpdate(data) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XFubenRogueLikeManager.lua b/Resources/Scripts/XManager/XFubenRogueLikeManager.lua new file mode 100644 index 00000000..df7355e0 --- /dev/null +++ b/Resources/Scripts/XManager/XFubenRogueLikeManager.lua @@ -0,0 +1,1193 @@ +XFubenRogueLikeManagerCreator = function() + + local XFubenRogueLikeManager = {} + + local RogueLikeRpc = { + GetBlackShopData = "GetBlackShopDataRequest", --获取黑市商店数据 + BuyBlackShopItem = "BuyBlackShopItemRequest", --黑市商店购买 + FinishNode = "FinishNodeRequest", --完成节点 + OpenBox = "OpenBoxRequest", --打开宝箱 + Recover = "RecoverRequest", --休息点回复行动力 + IntensifyBuff = "IntensifyBuffRequest", --增强buff + SelectNode = "SelectNodeRequest", --选择节点 + NodeBuy = "NodeBuyRequest", --节点商店购买 + SelectSpecialEvent = "SelectSpecialEventRequest", --选择特殊事件 + SupportCall = "SupportCallRequest", --支援请求 + SelectSpecialEventGroup = "SelectSpecialEventGroupRequest", --选择特殊事件组 + TeamSet = "RogueLikeTeamSetRequest", --设置队伍 + ResetHardNode = "ResetHardNodeRequest",--重置副本次数 + OpenTrialPoint = "OpenTrialPointRequest",--刷新试炼积分信息 + } + local CheckUiName = { + [1] = "UiRogueLikeMain", + [2] = "UiRogueLikeHelpRole", + [3] = "UiRogueLikeIllegalShop", + [4] = "UiRogueLikeObtainBuff", + [5] = "UiRogueLikeRoomCharacter", + [6] = "UiRogueLikeShop", + [7] = "UiRogueLikeStoryResult", + [8] = "UiRogueLikeThemeTips", + [9] = "UiRogueLikeTask", + [10] = "UiRogueLikeFightTips", + } + + -- 活动信息 + local ActivityId -- 活动id + local CurSectionId = 0 -- 当前章节 + local ActionPoint = 0 + local SectionInfo = {} -- 选择的节点信息//TierSectionInfo + local AssistRobots = {} -- 助战机器人//int + local BuffIds = {} -- 获得的buff//int + local CharacterInfos = {} -- 参战列表//RLCharacterInfo + local NodeShopInfos = {} -- 节点商店信息//RLNodeShopInfo + -- local DayBuffIds = {} -- 每日buff//int + local TeamEffectId = 0 -- 队伍效果id + local DayRefreshTime = 0 -- 每日刷新时间 + local WeekRefreshTime = 0 -- 每周刷新时间 + local SupportInfos = {} -- 支援终端 + local NewBuffIds = {} -- 最新获得的buff,用来显示 + local NewRobots = {} -- 最新获得的支援角色,显示用 + local ShowSelectNodeInfo = {} -- 选择过的节点//[nodeId = nodeInfo] + local IsFinal = false -- 是否为最后的层级 + local HistoryMaxTier = 0 -- 历史达到最高层数 + + local Id2SectionMap = {} -- SecionId对应SectionInfo + local RogueLikeStageRobots = {} -- 助战阵容{stageId = {IsAssis=,RobotId}} + + local RogueLikeTrialPoint = 0 --试炼模式积分 + local RogueLikeResetNum = 0 --重置试炼次数 + local NeedShowTrialTips = false --是否需要显示试炼开启 + local TrialPointDatas = {} + local NeedShowTrialPointView = false --是否需要显示积分页面 + local RogueLikeTrialPointLast = -1 + local RogueLikeTrialPointShowByTween = 0 + + function XFubenRogueLikeManager.InitStageInfo() + local allNodes = XFubenRogueLikeConfig.GetAllNodes() + for _, nodeDatas in pairs(allNodes) do + if nodeDatas.Type == XFubenRogueLikeConfig.XRLNodeType.Fight then + local stageId = nodeDatas.Param[1] + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + if stageInfo then + stageInfo.Type = XDataCenter.FubenManager.StageType.RogueLike + end + local stageDiffcultId = nodeDatas.Param[2] + if stageDiffcultId and stageDiffcultId > 0 then + local stageDiffcultInfo = XDataCenter.FubenManager.GetStageInfo(stageDiffcultId) + if stageDiffcultInfo then + stageDiffcultInfo.Type = XDataCenter.FubenManager.StageType.RogueLike + end + end + end + end + end + + -- [胜利] + function XFubenRogueLikeManager.ShowReward(winData) + if not winData then return end + XLuaUiManager.Open("UiSettleWin", winData) + end + + function XFubenRogueLikeManager.AsyncRogueLikeInfo(notifyData) + if not notifyData then return end + ActivityId = notifyData.Id + CurSectionId = notifyData.CurSectionId + ActionPoint = notifyData.ActionPoint + SectionInfo = notifyData.SectionInfo + AssistRobots = notifyData.AssistRobots + RogueLikeTrialPoint = notifyData.TrialPoint + RogueLikeResetNum = notifyData.HardNodeResetCount + + if RogueLikeTrialPointLast > -1 and RogueLikeTrialPointLast < RogueLikeTrialPoint then + RogueLikeTrialPointShowByTween = RogueLikeTrialPointLast + end + RogueLikeTrialPointLast = RogueLikeTrialPoint + + if not next(AssistRobots) then + XFubenRogueLikeManager.ResetNewRobots() + end + BuffIds = notifyData.BuffIds + if not next(BuffIds) then + XFubenRogueLikeManager.ResetNewBuffs() + end + CharacterInfos = notifyData.CharacterInfos + HistoryMaxTier = notifyData.MaxTier + + NodeShopInfos = {} + for i = 1, #notifyData.ShopInfos do + local shopInfo = notifyData.ShopInfos[i] + NodeShopInfos[shopInfo.Id] = shopInfo + end + + TeamEffectId = notifyData.TeamEffectId + DayRefreshTime = math.floor(notifyData.DayRefreshTime) + WeekRefreshTime = math.floor(notifyData.WeekRefreshTime) + + SupportInfos = {} + for _, v in pairs(notifyData.SupportInfos or {}) do + SupportInfos[v.Id] = v.Count + end + + for k, v in pairs(SectionInfo) do + Id2SectionMap[v.Id] = {} + Id2SectionMap[v.Id].Index = k + Id2SectionMap[v.Id].Id = v.Id + Id2SectionMap[v.Id].Group = v.Group + + Id2SectionMap[v.Id].FinishNode = {} + for _, node in pairs(v.FinishNode or {}) do + Id2SectionMap[v.Id].FinishNode[node] = true + end + + Id2SectionMap[v.Id].SelectNodeInfo = {} + for _, nodeInfo in pairs(v.SelectNodeInfos or {}) do + Id2SectionMap[v.Id].SelectNodeInfo[nodeInfo.SelectId] = nodeInfo + end + end + + -- 日重置、 周重置刷新界面 + XEventManager.DispatchEvent(XEventId.EVENT_ROGUELIKE_REFRESH_ALLNODES) + XEventManager.DispatchEvent(XEventId.EVENT_ROGUELIKE_ACTIONPOINT_CHARACTER_CHANGED) + XEventManager.DispatchEvent(XEventId.EVENT_ROGUELIKE_ASSISTROBOT_CHANGED) + XEventManager.DispatchEvent(XEventId.EVENT_ROGUELIKE_BUFFIDS_CHANGES) + XEventManager.DispatchEvent(XEventId.EVENT_ROGUELIKE_TEAMEFFECT_CHANGES) + XEventManager.DispatchEvent(XEventId.EVENT_ROGUELIKE_TASK_RESET) + + XEventManager.DispatchEvent(XEventId.EVENT_ROGUELIKE_ILLEGAL_SHOP_RESET) + -- 检查是否需要重置角色 + XFubenRogueLikeManager.CheckCharacterReset() + end + + function XFubenRogueLikeManager.AsyncBuffData(notifyData) + if not notifyData then return end + BuffIds = notifyData.BuffIds + if notifyData.NewId > 0 then + NewBuffIds[notifyData.NewId] = true + end + XEventManager.DispatchEvent(XEventId.EVENT_ROGUELIKE_BUFFIDS_CHANGES) + end + + function XFubenRogueLikeManager.ResetDataByInPurgatory() + NeedShowTrialTips = true + BuffIds = {} + XFubenRogueLikeManager.ResetNewBuffs() + XEventManager.DispatchEvent(XEventId.EVENT_ROGUELIKE_BUFFIDS_CHANGES) + XEventManager.DispatchEvent(XEventId.EVENT_ROGUELIKE_SECTIONTYPE_CHANGE) + end + + -- 章节选择同步 + function XFubenRogueLikeManager.AsyncSectionInfoChange(notifyData) + if not notifyData then return end + local lastSectionType = XFubenRogueLikeConfig.GetTierSectionTierTypeById(CurSectionId) or 0 + CurSectionId = notifyData.CurSectionId + local curSectionType = XFubenRogueLikeConfig.GetTierSectionTierTypeById(CurSectionId) + if lastSectionType == XFubenRogueLikeConfig.TierType.Normal and curSectionType == XFubenRogueLikeConfig.TierType.Purgatory then + XFubenRogueLikeManager.ResetDataByInPurgatory() + end + + for k, v in pairs(SectionInfo) do + if v.Id == notifyData.SectionInfo.Id then + SectionInfo[k] = notifyData.SectionInfo + end + end + + local sectionId = notifyData.SectionInfo.Id + Id2SectionMap[sectionId].FinishNode = {} + for _, node in pairs(notifyData.SectionInfo.FinishNode or {}) do + Id2SectionMap[sectionId].FinishNode[node] = true + end + + Id2SectionMap[sectionId].SelectNodeInfo = {} + for _, nodeInfo in pairs(notifyData.SectionInfo.SelectNodeInfos or {}) do + Id2SectionMap[sectionId].SelectNodeInfo[nodeInfo.SelectId] = nodeInfo + end + XEventManager.DispatchEvent(XEventId.EVENT_ROGUELIKE_REFRESH_ALLNODES) + IsFinal = XFubenRogueLikeManager.GetRogueLikeLevel() == XFubenRogueLikeManager.GetMaxTier() + + local currTier = XFubenRogueLikeManager.GetRogueLikeLevel() + if currTier > HistoryMaxTier then + HistoryMaxTier = currTier + end + end + + function XFubenRogueLikeManager.AsyncNodeShopInfo(notifyData) + if not notifyData then return end + local shopId = notifyData.ShopInfo.Id + NodeShopInfos[shopId] = notifyData.ShopInfo + + end + + -- 通知助战机器人改变 + function XFubenRogueLikeManager.AsyncAssistRobot(notifyData) + if not notifyData then return end + + local new_assisRobots = {} + for _, robotId in pairs(notifyData.AssistRobots) do + new_assisRobots[robotId] = true + end + for _, robotId in pairs(AssistRobots) do + new_assisRobots[robotId] = nil + end + local receiveNewRobot = false + local robot_names = "" + for robotId, _ in pairs(new_assisRobots) do + receiveNewRobot = true + NewRobots[robotId] = true + local characterId = XRobotManager.GetCharacterId(robotId) + local fullName = XCharacterConfigs.GetCharacterFullNameStr(characterId) + if robot_names == "" then + robot_names = fullName + else + robot_names = string.format("%s %s", robot_names, fullName) + end + end + if receiveNewRobot and robot_names ~= "" then + XUiManager.TipMsg(CS.XTextManager.GetText("RogueLikeGetAssistRobot", robot_names)) + end + + AssistRobots = notifyData.AssistRobots + XEventManager.DispatchEvent(XEventId.EVENT_ROGUELIKE_ASSISTROBOT_CHANGED) + end + + -- 刷新行动点和角色信息 + function XFubenRogueLikeManager.AsyncActionPointAndCharacterInfo(notifyData) + if not notifyData then return end + local newActionPoint = notifyData.ActionPoint + local isAdd = newActionPoint > ActionPoint + ActionPoint = notifyData.ActionPoint + + RogueLikeTrialPoint = notifyData.TrialPoint + + if RogueLikeTrialPointLast > -1 and RogueLikeTrialPointLast < RogueLikeTrialPoint then + RogueLikeTrialPointShowByTween = RogueLikeTrialPointLast + end + RogueLikeTrialPointLast = RogueLikeTrialPoint + + local newCharacterInfos = notifyData.CharacterInfos + for i = 1, #newCharacterInfos do + if newCharacterInfos[i] and CharacterInfos[i] then + if newCharacterInfos[i].HpLeft ~= CharacterInfos[i].HpLeft then + newCharacterInfos[i].EffectUp = true + end + end + end + CharacterInfos = notifyData.CharacterInfos + + XEventManager.DispatchEvent(XEventId.EVENT_ROGUELIKE_ACTIONPOINT_CHARACTER_CHANGED, isAdd) + end + + -- 刷新队伍效果 + function XFubenRogueLikeManager.AsyncTeamEffect(notifyData) + if not notifyData then return end + TeamEffectId = notifyData.TeamEffectId + + XEventManager.DispatchEvent(XEventId.EVENT_ROGUELIKE_TEAMEFFECT_CHANGES) + end + + --刷新获得积分数据 + function XFubenRogueLikeManager.AsyncTrialPoint(notifyData) + TrialPointDatas = notifyData.pointInfo or {} + table.sort(TrialPointDatas,function(a,b) + return a.PointType < b.PointType + end) + NeedShowTrialPointView = true + XEventManager.DispatchEvent(XEventId.EVENT_ROGUELIKE_TRIALPOINT_CHANGE) + end + + --刷新获得积分数据(回调) + function XFubenRogueLikeManager.AsyncTrialPointRequest(pointInfo) + TrialPointDatas = pointInfo + table.sort(TrialPointDatas,function(a,b) + return a.PointType < b.PointType + end) + end + + -- 活动id + function XFubenRogueLikeManager.GetRogueLikeActivityId() + return ActivityId + end + + -- 行动点 + function XFubenRogueLikeManager.GetRogueLikeActionPoint() + return ActionPoint + end + + -- 日常buff + function XFubenRogueLikeManager.GetRogueLikeDayBuffs() + return XFubenRogueLikeManager.GetDayBuffByTeamEffect(TeamEffectId, CharacterInfos) + end + + -- 锁定的出站角色 + function XFubenRogueLikeManager.GetCharacterInfos() + return CharacterInfos + end + + -- 如果有出站人数为3则视为已经锁定 + function XFubenRogueLikeManager.IsRogueLikeCharacterLock() + return XFubenRogueLikeManager.GetTeamMemberCount() == #CharacterInfos + end + + -- 助战机器人 + function XFubenRogueLikeManager.GetAssistRobots(characterType) + local robots = {} + + for _, v in pairs(AssistRobots or {}) do + local characterId = XRobotManager.GetCharacterId(v) + local charType = XCharacterConfigs.GetCharacterType(characterId) + if not characterType or charType == characterType then + table.insert(robots, { Id = v }) + end + end + + return robots + end + + -- 助战角色达到3人则视为可以切换助战 + function XFubenRogueLikeManager.CanSwitch2Assist() + return #AssistRobots >= XFubenRogueLikeManager.GetTeamMemberCount() + end + + -- 获得助战人数,默认3 + function XFubenRogueLikeManager.GetTeamMemberCount() + local activityId = XFubenRogueLikeManager.GetRogueLikeActivityId() + if not activityId then return XFubenRogueLikeConfig.TEAM_NUMBER end + + local activityTemplate = XFubenRogueLikeConfig.GetRougueLikeTemplateById(activityId) + if not activityTemplate then return XFubenRogueLikeConfig.TEAM_NUMBER end + + return activityTemplate.TeamMemberCount or XFubenRogueLikeConfig.TEAM_NUMBER + end + + -- 当前章节 + function XFubenRogueLikeManager.GetCurSectionInfo() + return Id2SectionMap[CurSectionId] + end + + -- 获取当前活动最大层数 + function XFubenRogueLikeManager.GetMaxTier() + local maxTier = 0 + local maxTierNormal = 0 + local maxTierPurgatory = 0 + local curSectionType = XFubenRogueLikeConfig.GetTierSectionTierTypeById(CurSectionId) + + for _, v in pairs(SectionInfo) do + local tierSectionTemplate = XFubenRogueLikeConfig.GetTierSectionTemplateById(v.Id) + if tierSectionTemplate.MaxTier > maxTier then + if XFubenRogueLikeConfig.GetTierSectionTierTypeById(v.Id) == XFubenRogueLikeConfig.TierType.Normal then + maxTierNormal = tierSectionTemplate.MaxTier + else + maxTierPurgatory = tierSectionTemplate.MaxTier + end + --maxTier = tierSectionTemplate.MaxTier + end + end + maxTierPurgatory = maxTierPurgatory - maxTierNormal + if XFubenRogueLikeManager.IsSectionPurgatory() then + return maxTierPurgatory + else + return maxTierNormal + end + return maxTier + end + + function XFubenRogueLikeManager.GetRogueLikeLevel() + if not SectionInfo then return 0 end + + local rogueLikeLevel = 0 + local curSectionType = XFubenRogueLikeConfig.GetTierSectionTierTypeById(CurSectionId) + for i = 1, #SectionInfo do + local section = SectionInfo[i] + if section and section.Id then + local sectionType = XFubenRogueLikeConfig.GetTierSectionTierTypeById(section.Id) + for _, v in pairs(section.FinishNode) do + local finishNode = Id2SectionMap[section.Id].FinishNode or {} + if finishNode[v] and curSectionType == sectionType then + rogueLikeLevel = rogueLikeLevel + 1 + end + end + end + end + return rogueLikeLevel + end + + -- 获取我的buffs//排序规则:新获得的(20) > 正面的(10) > 负面的(5) + function XFubenRogueLikeManager.GetMyBuffs() + local myBuffs = {} + for _, v in pairs(BuffIds) do + local buffConfig = XFubenRogueLikeConfig.GetBuffConfigById(v) + + local weight = 5 + if XFubenRogueLikeConfig.BuffType.PositiveBuff == buffConfig.BuffType then + weight = 10 + end + weight = XFubenRogueLikeManager.IsBuffNew(v) and 20 or weight + table.insert(myBuffs, { + BuffId = v, + IsSelect = false, + BuffType = buffConfig.BuffType, + Priority = buffConfig.Priority, + SortWeight = weight, + }) + end + table.sort(myBuffs, function(a, b) + return a.BuffId < b.BuffId + end) + return myBuffs + end + + -- 获得节点商店数据 + function XFubenRogueLikeManager.GetNodeShopInfoById(shopId) + return NodeShopInfos[shopId] + end + + -- 队伍效果id + function XFubenRogueLikeManager.GetTeamEffectId() + return TeamEffectId + end + + -- 是否为队伍效果id中配置的角色 + function XFubenRogueLikeManager.IsTeamEffectCharacter(cid) + local teamEffectId = XFubenRogueLikeManager.GetTeamEffectId() + if XFubenRogueLikeManager.IsSectionPurgatory() then return false end + if teamEffectId <= 0 then return false end + + local teamEffectTemplate = XFubenRogueLikeConfig.GetTeamEffectTemplateById(teamEffectId) + if not teamEffectTemplate then + return false + end + for _, characterId in pairs(teamEffectTemplate.CharacterId) do + if characterId == cid then + return true + end + end + return false + end + + -- 日刷新时间 + function XFubenRogueLikeManager.GetDayRefreshTime() + return DayRefreshTime + end + + -- 周刷新时间 + function XFubenRogueLikeManager.GetWeekRefreshTime() + return WeekRefreshTime + end + + -- 获取支援终端的东西 + function XFubenRogueLikeManager.GetSupportInfos() + return SupportInfos + end + + -- 是否有新的buffId + function XFubenRogueLikeManager.HasNewBuffs() + local newBuffCount = 0 + for _, _ in pairs(NewBuffIds) do + newBuffCount = newBuffCount + 1 + end + return newBuffCount + end + + -- 重置新效果 + function XFubenRogueLikeManager.ResetNewBuffs() + NewBuffIds = {} + end + + -- 是否为新获得的buff + function XFubenRogueLikeManager.IsBuffNew(buffId) + return NewBuffIds[buffId] + end + + -- 是否有新获得的支援角色 + function XFubenRogueLikeManager.HasNewRobots() + local newRobotCount = 0 + for _, _ in pairs(NewRobots) do + newRobotCount = newRobotCount + 1 + end + return newRobotCount > 0 + end + + function XFubenRogueLikeManager.ResetNewRobots() + NewRobots = {} + end + + function XFubenRogueLikeManager.UpdateNewRobots(robotId) + NewRobots[robotId] = nil + end + + function XFubenRogueLikeManager.IsRobotNew(robotId) + return NewRobots[robotId] + end + + -- 获取是否选择过节点 + function XFubenRogueLikeManager.GetShowSelectNodeById(nodeId) + return ShowSelectNodeInfo[nodeId] + end + + -- 获得主题buff + function XFubenRogueLikeManager.GetDayBuffByTeamEffect(id, characterInfos) + local day_buffs = {} + local teamEffectTemplate = XFubenRogueLikeConfig.GetTeamEffectTemplateById(id) + if not teamEffectTemplate then + return day_buffs + end + + local lock_character = {} + for _, characterInfo in pairs(characterInfos or {}) do + lock_character[characterInfo.Id] = true + end + + local buff_count = 0 + + for _, characterId in pairs(teamEffectTemplate.CharacterId) do + if lock_character[characterId] then + buff_count = buff_count + 1 + end + end + + for i, buffId in pairs(teamEffectTemplate.BuffId) do + table.insert(day_buffs, { + BuffId = buffId, + IsActive = i <= buff_count + }) + end + + return day_buffs + end + + -- 获得折扣:队伍buff/系统buff + function XFubenRogueLikeManager.GetNodeShopDiscount() + -- 默认100,没有打折 + local discount = 100 + local curSectionType = XFubenRogueLikeConfig.GetTierSectionTierTypeById(CurSectionId) + if curSectionType == XFubenRogueLikeConfig.TierType.Purgatory then + return discount + end + for _, buffId in pairs(BuffIds) do + local buffTemplate = XFubenRogueLikeConfig.GetBuffTemplateById(buffId) + if buffTemplate then + if buffTemplate.Discount > 0 and buffTemplate.Discount < discount then + discount = buffTemplate.Discount + end + end + end + + local day_Buff = XFubenRogueLikeManager.GetDayBuffByTeamEffect(TeamEffectId, CharacterInfos) + for _, buffInfo in pairs(day_Buff) do + local buffTemplate = XFubenRogueLikeConfig.GetBuffTemplateById(buffInfo.BuffId) + if buffTemplate and buffInfo.IsActive then + if buffTemplate.Discount > 0 and buffTemplate.Discount < discount then + discount = buffTemplate.Discount + end + end + end + + return discount + end + + -- 是否在显示等级的时间段 + function XFubenRogueLikeManager.IsInActivity() + local activityId = XFubenRogueLikeManager.GetRogueLikeActivityId() + if not activityId then return false end + local activityTemplate = XFubenRogueLikeConfig.GetRougueLikeTemplateById(activityId) + if not activityTemplate then return false end + local now = XTime.GetServerNowTimestamp() + local beginTime, endTime = XFunctionManager.GetTimeByTimeId(activityTemplate.ActivityTimeId) + if not beginTime or not endTime then return false end + return now >= beginTime and now <= endTime + end + + -- 是否在挑战时间 + function XFubenRogueLikeManager.IsInFight() + local activityId = XFubenRogueLikeManager.GetRogueLikeActivityId() + if not activityId then return false end + local activityTemplate = XFubenRogueLikeConfig.GetRougueLikeTemplateById(activityId) + if not activityTemplate then return false end + local now = XTime.GetServerNowTimestamp() + local beginTime = XFunctionManager.GetStartTimeByTimeId(activityTemplate.ActivityTimeId) + local endTime = XFunctionManager.GetEndTimeByTimeId(activityTemplate.FightTimeId) + if not beginTime or not endTime then return false end + return now >= beginTime and now <= endTime + end + + -- 获取入口数据 + function XFubenRogueLikeManager.GetRogueLikeSection() + local sections = {} + local activityId = XFubenRogueLikeManager.GetRogueLikeActivityId() + if activityId and XFubenRogueLikeManager.IsInActivity() then + local section = { + Id = activityId, + Type = XDataCenter.FubenManager.ChapterType.RogueLike, + BannerBg = CS.XGame.ClientConfig:GetString("FubenRogueLikeBannerBg"), + } + + table.insert(sections, section) + end + + return sections + end + + -- 选择特殊节点 + function XFubenRogueLikeManager.SelectSpecialEvent(nodeId, eventId, func) + XNetwork.Call(RogueLikeRpc.SelectSpecialEvent, { + NodeId = nodeId, + EventId = eventId + }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + if func then + func() + end + -- response + -- public XCode Code; + end) + end + + -- 神秘商店购买 + function XFubenRogueLikeManager.NodeBuy(nodeId, itemId, itemCount, func) + XNetwork.Call(RogueLikeRpc.NodeBuy, { + NodeId = nodeId, + ItemId = itemId, + Count = itemCount + }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + if func then + func() + end + + -- 奖励通知 + local shopItemTemplate = XFubenRogueLikeConfig.GetShopItemTemplateById(itemId) + if not shopItemTemplate then return end + + if shopItemTemplate.Type == XFubenRogueLikeConfig.XRLShopItemType.Item then + local list = {} + table.insert(list, XRewardManager.CreateRewardGoodsByTemplate({ TemplateId = shopItemTemplate.Param[1], Count = shopItemTemplate.Param[2] or 1 })) + XUiManager.OpenUiObtain(list) + elseif shopItemTemplate.Type == XFubenRogueLikeConfig.XRLShopItemType.Buff then + local buffIds = {} + table.insert(buffIds, { + Id = shopItemTemplate.Param[1] + }) + XLuaUiManager.Open("UiRogueLikeObtainBuff", buffIds) + end + + end) + end + + -- 选择节点 + function XFubenRogueLikeManager.SelectNode(nodeId, func) + XNetwork.Call(RogueLikeRpc.SelectNode, { + NodeId = nodeId + }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + -- 记下选择过的节点{Id,SelectId, Value, SubValue} + if res.SelectInfo then + ShowSelectNodeInfo[res.SelectInfo.SelectId] = res.SelectInfo + end + + if func then + func() + end + -- response + -- public XCode Code; + end) + end + + -- 增强buff + function XFubenRogueLikeManager.IntensifyBuff(nodeId, buffId, func) + XNetwork.Call(RogueLikeRpc.IntensifyBuff, { + NodeId = nodeId, + BuffId = buffId + }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local buffTemplate = XFubenRogueLikeConfig.GetBuffTemplateById(buffId) + local update_buffs = {} + for _, v in pairs(BuffIds or {}) do + if v ~= buffId and v ~= buffTemplate.IntensifyId then + table.insert(update_buffs, v) + end + end + if buffTemplate.IntensifyId > 0 then + table.insert(update_buffs, buffTemplate.IntensifyId) + end + BuffIds = update_buffs + XEventManager.DispatchEvent(XEventId.EVENT_ROGUELIKE_BUFFIDS_CHANGES) + + if func then + func() + end + -- response + -- public XCode Code; + end) + end + + -- 休息点回复行动力 + function XFubenRogueLikeManager.Recover(nodeId, func) + XNetwork.Call(RogueLikeRpc.Recover, { + NodeId = nodeId, + }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + if func then + func() + end + -- response + -- public XCode Code; + end) + end + + -- 打开宝箱 + function XFubenRogueLikeManager.OpenBox(nodeId, eventNode, func) + XNetwork.Call(RogueLikeRpc.OpenBox, { + NodeId = nodeId, + }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + -- 判断宝箱类型 + local nodeTemplate = XFubenRogueLikeConfig.GetNodeTemplateById(eventNode.Id) + for i = 1, #nodeTemplate.Param do + local boxId = nodeTemplate.Param[i] + local boxTemplate = XFubenRogueLikeConfig.GetBoxTemplateById(boxId) + if boxTemplate.Type == XFubenRogueLikeConfig.XRLBoxType.Item then + if func then + func() + end + XUiManager.OpenUiObtain(res.RewardGoodsList or {}) + elseif boxTemplate.Type == XFubenRogueLikeConfig.XRLBoxType.Buff then + local buffIds = {} + for i2 = 1, #boxTemplate.Param do + table.insert(buffIds, { + Id = boxTemplate.Param[i2] + }) + end + XLuaUiManager.Open("UiRogueLikeObtainBuff", buffIds) + if func then + func() + end + end + break + end + + -- response + -- public XCode Code; + -- public List RewardGoodsList; + end) + end + + -- 完成节点:离开 + function XFubenRogueLikeManager.FinishNode(nodeId, func) + XNetwork.Call(RogueLikeRpc.FinishNode, { + NodeId = nodeId, + }, function(res) + + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + if func then + func(res) + end + -- response + -- public XCode Code; + end) + end + + -- 黑市商店购买 + function XFubenRogueLikeManager.BuyBlackShopItem() + end + + -- 支援请求 + function XFubenRogueLikeManager.RequestSupportCall(id, count, func) + XNetwork.Call(RogueLikeRpc.SupportCall, { + Id = id, + Count = count + }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + SupportInfos[id] = (SupportInfos[id] or 0) + 1 + local supportTemplate = XFubenRogueLikeConfig.GetSupportStationTemplateById(id) + local specialEventTemplate = XFubenRogueLikeConfig.GetSpecialEventTemplateById(supportTemplate.SpecialEvent) + if XFubenRogueLikeConfig.XRLOtherEventType.AddRobot ~= specialEventTemplate.Type then + XLuaUiManager.Open("UiRogueLikeStoryResult", supportTemplate.SpecialEvent, XFubenRogueLikeConfig.SpecialResultType.SingleEvent) + end + + if func then + func() + end + + end) + end + + -- 选择特殊事件组 + function XFubenRogueLikeManager.SelectSpecialEventGroup(nodeId, groupId, func) + XNetwork.Call(RogueLikeRpc.SelectSpecialEventGroup, + { + NodeId = nodeId, + GroupId = groupId + }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + if func then + func() + end + + if #res.ResultInfos > 0 then + XLuaUiManager.Open("UiRogueLikeStoryResult", res.ResultInfos, XFubenRogueLikeConfig.SpecialResultType.MultipleEvent) + end + end) + end + + -- 当天第一次进入时,保存今日队伍 + function XFubenRogueLikeManager.RogueLikeSetTeam(characterList, func) + XNetwork.Call(RogueLikeRpc.TeamSet, + { + CharacterList = characterList + }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + for i = 1, #characterList do + CharacterInfos[i] = {} + CharacterInfos[i].Id = characterList[i] + CharacterInfos[i].HpLeft = 100 + CharacterInfos[i].TeamPos = i + CharacterInfos[i].Captain = 0 + CharacterInfos[i].FirstFight = 0 + end + + XEventManager.DispatchEvent(XEventId.EVENT_ROGUELIKE_ACTIONPOINT_CHARACTER_CHANGED) + + if func then + func() + end + end) + end + + + function XFubenRogueLikeManager.UpdateRogueLikeStageRobots(stageId, isAssis, robotId) + RogueLikeStageRobots[stageId] = {} + RogueLikeStageRobots[stageId].IsAssis = isAssis == 1 + local robots = (isAssis == 1) and robotId or {} + RogueLikeStageRobots[stageId].RobotId = robots + end + + function XFubenRogueLikeManager.GetRogueLikeStageRobots(stageId) + return RogueLikeStageRobots[stageId] + end + + + function XFubenRogueLikeManager.GetActivityBeginTime() + local activityTemplate = XFubenRogueLikeConfig.GetLastRogueLikeConfig() + return XFunctionManager.GetStartTimeByTimeId(activityTemplate.ActivityTimeId) + end + + function XFubenRogueLikeManager.GetFightEndTime() + local activityTemplate = XFubenRogueLikeConfig.GetLastRogueLikeConfig() + return XFunctionManager.GetEndTimeByTimeId(activityTemplate.FightTimeId) + end + + function XFubenRogueLikeManager.GetActivityEndTime() + local activityTemplate = XFubenRogueLikeConfig.GetLastRogueLikeConfig() + return XFunctionManager.GetEndTimeByTimeId(activityTemplate.ActivityTimeId) + end + + function XFubenRogueLikeManager.GetFunctionalOpenId() + local activityConfig = XFubenRogueLikeConfig.GetRogueLikeConfigById(ActivityId) + return activityConfig.FunctionalOpenId + end + + function XFubenRogueLikeManager.ShowRogueLikeTipsOnce() + local value = XFubenRogueLikeManager.GetRogueLikePrefs(XFubenRogueLikeConfig.KEY_SHOW_TIPS, 0) + local hasShow = value == 1 + if not hasShow then + XUiManager.ShowHelpTip("RogueLike") + XFubenRogueLikeManager.SaveRogueLikePrefs(XFubenRogueLikeConfig.KEY_SHOW_TIPS, 1) + end + end + + -- 打开爬塔之前检查是否需要播剧情 + function XFubenRogueLikeManager.OpenRogueLikeCheckStory() + local value = XFubenRogueLikeManager.GetRogueLikePrefs(XFubenRogueLikeConfig.KEY_PLAY_STORY, 0) + local activityId = XFubenRogueLikeManager.GetRogueLikeActivityId() + local hasPlay = value == 1 + if not hasPlay and activityId then + local activityConfig = XFubenRogueLikeConfig.GetRogueLikeConfigById(activityId) + -- -- 播放剧情 + if activityConfig and activityConfig.BeginStoryId then + XDataCenter.MovieManager.PlayMovie(activityConfig.BeginStoryId, function() + XLuaUiManager.Open("UiRogueLikeMain") + end) + else + XLuaUiManager.Open("UiRogueLikeMain") + end + XFubenRogueLikeManager.SaveRogueLikePrefs(XFubenRogueLikeConfig.KEY_PLAY_STORY, 1) + else + XLuaUiManager.Open("UiRogueLikeMain") + end + end + + -- 保存本地数据 + function XFubenRogueLikeManager.SaveRogueLikePrefs(key, value) + local activityId = XFubenRogueLikeManager.GetRogueLikeActivityId() + if XPlayer.Id and activityId then + key = string.format("%s_%s_%s", key, tostring(XPlayer.Id), tostring(activityId)) + CS.UnityEngine.PlayerPrefs.SetInt(key, value) + CS.UnityEngine.PlayerPrefs.Save() + end + end + + function XFubenRogueLikeManager.GetRogueLikePrefs(key, defaultValue) + local activityId = XFubenRogueLikeManager.GetRogueLikeActivityId() + if XPlayer.Id and activityId then + key = string.format("%s_%s_%s", key, tostring(XPlayer.Id), tostring(activityId)) + if CS.UnityEngine.PlayerPrefs.HasKey(key) then + local rogueLikePref = CS.UnityEngine.PlayerPrefs.GetInt(key) + return (rogueLikePref == nil or rogueLikePref == 0) and defaultValue or rogueLikePref + end + end + return defaultValue + end + + -- 检查活动结束 + function XFubenRogueLikeManager.CheckRogueLikeActivityEndOnUi(uiName) + if not XFubenRogueLikeManager.IsInActivity() and XLuaUiManager.IsUiShow(uiName) then + XUiManager.TipMsg(CS.XTextManager.GetText("RougeLikeNotInActivityTime")) + XLuaUiManager.RunMain() + end + end + + -- 检查天重置-修改为活动过期提示 + function XFubenRogueLikeManager.CheckRogueLikeDayResetOnUi(uiName) + if CS.XFight.IsRunning or XLuaUiManager.IsUiLoad("UiLoading") then + return + end + if XLuaUiManager.IsUiShow(uiName) then + local notChars = #CharacterInfos <= 0 + local notInActivity = not XFubenRogueLikeManager.IsInActivity() + if notChars or notInActivity then + if notChars then + XUiManager.TipMsg(CS.XTextManager.GetText("RogueLikeDayReset")) + elseif notInActivity then + XUiManager.TipMsg(CS.XTextManager.GetText("RougeLikeNotInActivityTime")) + end + XScheduleManager.ScheduleOnce(function() + XLuaUiManager.RunMain() + end, 1000) + end + end + end + + function XFubenRogueLikeManager.CheckCharacterReset() + -- 战斗模式 + if CS.XFight.IsRunning or XLuaUiManager.IsUiLoad("UiLoading") then + return + end + + if XFubenRogueLikeManager.IsTargetUiShow() and not XFubenRogueLikeManager.IsSectionPurgatory() then + local notChars = #CharacterInfos <= 0 + local notInActivity = not XFubenRogueLikeManager.IsInActivity() + if notChars or notInActivity then + if notInActivity then + XUiManager.TipMsg(CS.XTextManager.GetText("RougeLikeNotInActivityTime")) + elseif notChars then + XUiManager.TipMsg(CS.XTextManager.GetText("RogueLikeDayReset")) + end + XScheduleManager.ScheduleOnce(function() + XLuaUiManager.RunMain() + end, 1000) + end + end + + end + + function XFubenRogueLikeManager.IsTargetUiShow() + for _, uiName in pairs(CheckUiName) do + if XLuaUiManager.IsUiShow(uiName) then + return true + end + end + return false + end + + function XFubenRogueLikeManager.IsFinalTier() + return IsFinal + end + + -- 获取历史最高层级 + function XFubenRogueLikeManager.GetHistoryMaxTier() + return HistoryMaxTier + end + + function XFubenRogueLikeManager.ResetIsFinalTier() + IsFinal = false + end + + -- 最多获得机器人数量 + function XFubenRogueLikeManager.GetMaxRobotCount() + local activityId = XFubenRogueLikeManager.GetRogueLikeActivityId() + if not activityId then return 3 end + local activityTemplate = XFubenRogueLikeConfig.GetRougueLikeTemplateById(activityId) + if not activityTemplate then return 3 end + return activityTemplate.RobotMax or 3 + end + + -- 机器人是否已经到达最大值 + function XFubenRogueLikeManager.IsAssistRobotFull() + local ownCount = #AssistRobots + local needCount = XFubenRogueLikeManager.GetMaxRobotCount() + return ownCount >= needCount + end + + + --试炼模式尽量放在这里 + --试炼模式重置数据 + function XFubenRogueLikeManager.ResetHardNode(resetType, func) + XNetwork.Call(RogueLikeRpc.ResetHardNode, { + Type = resetType, + }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + XDataCenter.FubenRogueLikeManager.AsyncRogueLikeInfo(res.Data) + XEventManager.DispatchEvent(XEventId.EVENT_ROGUELIKE_SECTION_REFRESH) + if func then + func() + end + end) + end + + function XFubenRogueLikeManager.OpenTrialPoint(func) + XNetwork.Call(RogueLikeRpc.OpenTrialPoint, { + CurSectionId = CurSectionId + }, function(res) + + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + XDataCenter.FubenRogueLikeManager.AsyncTrialPointRequest(res.PointInfo) + if func then + func() + end + end) + end + + function XFubenRogueLikeManager.GetRogueLikeTrialPoint() + return RogueLikeTrialPoint + end + + function XFubenRogueLikeManager.SetRogueLikeTrialPointShowByTween(value) + RogueLikeTrialPointShowByTween = value + end + + function XFubenRogueLikeManager.GetRogueLikeTrialPointShowByTween() + return RogueLikeTrialPointShowByTween + end + + function XFubenRogueLikeManager.IsSectionPurgatory() + local CurSectionTierType = XFubenRogueLikeConfig.GetTierSectionTierTypeById(CurSectionId) + return CurSectionTierType == XFubenRogueLikeConfig.TierType.Purgatory + end + + function XFubenRogueLikeManager.GetNeedShowTrialTips() + return NeedShowTrialTips + end + + --是否需要显示试炼开启页面 + function XFubenRogueLikeManager.SetNeedShowTrialTips(value) + NeedShowTrialTips = value + end + + function XFubenRogueLikeManager.GetRogueLikeResetNum() + return RogueLikeResetNum + end + + --获取最终得分的数据 + function XFubenRogueLikeManager.GetRogueLikeTrialPointDatas() + return TrialPointDatas + end + + --是否需要显示最终得分页面 + function XFubenRogueLikeManager.SetNeedShowTrialPointView(value) + NeedShowTrialPointView = value + end + + function XFubenRogueLikeManager.GetNeedShowTrialPointView() + return NeedShowTrialPointView + end + + function XFubenRogueLikeManager.Init() + end + + XFubenRogueLikeManager.Init() + return XFubenRogueLikeManager +end + +-- 通知玩法数据 +XRpc.NotifyRogueLikeData = function(notifyData) + XDataCenter.FubenRogueLikeManager.AsyncRogueLikeInfo(notifyData) +end + +-- 通知buff +XRpc.NotifyBuffData = function(notifyData) + XDataCenter.FubenRogueLikeManager.AsyncBuffData(notifyData) +end + +-- 更新章节数据 +XRpc.NotifySectionInfoChange = function(notifyData) + XDataCenter.FubenRogueLikeManager.AsyncSectionInfoChange(notifyData) +end + + +XRpc.NotifyNodeShopInfo = function(notifyData) + XDataCenter.FubenRogueLikeManager.AsyncNodeShopInfo(notifyData) +end + +-- 通知助战机器人改变 +XRpc.NotifyAssistRobot = function(notifyData) + XDataCenter.FubenRogueLikeManager.AsyncAssistRobot(notifyData) +end + +-- 刷新行动点和角色信息 +XRpc.NotifyActionPointAndCharacterInfo = function(notifyData) + XDataCenter.FubenRogueLikeManager.AsyncActionPointAndCharacterInfo(notifyData) +end + +-- 刷新队伍效果 +XRpc.NotifyTeamEffect = function(notifyData) + XDataCenter.FubenRogueLikeManager.AsyncTeamEffect(notifyData) +end + +--通关显示试炼积分 +XRpc.NotifyTrialPoint = function(notifyData) + XDataCenter.FubenRogueLikeManager.AsyncTrialPoint(notifyData) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XFubenSimulatedCombatManager.lua b/Resources/Scripts/XManager/XFubenSimulatedCombatManager.lua new file mode 100644 index 00000000..83d399f9 --- /dev/null +++ b/Resources/Scripts/XManager/XFubenSimulatedCombatManager.lua @@ -0,0 +1,881 @@ +local tableInsert = table.insert +local ipairs = ipairs +local pairs = pairs + +XFubenSimulatedCombatManagerCreator = function() + local MAX_CHAR_COUNT = 3 + local MAX_STAGE_STAR_COUNT = 3 + local XFubenSimulatedCombatManager = {} + local ActivityInfo = nil + local DefaultActivityInfo = nil + local StageInterInfo = nil + local ChallengeMapKey = "SIMULATED_COMBAT_CHALLENGE_MAP_" + local ShopMapKey = "SIMULATED_COMBAT_SHOP_MAP_" + + local MemberList = {} + local AdditionList = {} + local LocalCurrency = {} + local CurrencyNoToId = {} + local CurrencyIdToNo = {} + local ChallengeMap = {} + local CurrentTeam = {} + local CharIdToMemberId = {} + local ConsumeLimitList = {} + local LastShopMap = {} + + local DailyStageStarRewardCount = 0 --每日关卡星级奖励领取次数 + local StageStarRecordDic = {} + local StarRewardDic = {} --已经领取的星级奖励 + local PointRewardDic = {} --已经领取的积分奖励 + local ResMemberSelectCount = 0 -- 已选择成员数 + local IsRegisterEditBattleProxy = false + + function XFubenSimulatedCombatManager.Init() + DailyStageStarRewardCount = 0 + local activityTemplates = XFubenSimulatedCombatConfig.GetActTemplates() + local nowTime = XTime.GetServerNowTimestamp() + for _, template in pairs(activityTemplates) do + DefaultActivityInfo = XFubenSimulatedCombatConfig.GetActivityTemplateById(template.Id) + local TimeId = template.TimeId + local startTime, endTime = XFunctionManager.GetTimeByTimeId(TimeId) + if nowTime > startTime and nowTime < endTime then + if not ActivityInfo then + ActivityInfo = XFubenSimulatedCombatConfig.GetActivityTemplateById(template.Id) + end + break + end + end + + if ActivityInfo then + for i, v in ipairs(ActivityInfo.ConsumeIds) do + XEventManager.AddEventListener(XEventId.EVENT_ITEM_COUNT_UPDATE_PREFIX .. v, XFubenSimulatedCombatManager.OnCurrencyChange) + CurrencyNoToId[i] = v + CurrencyIdToNo[v] = i + if ActivityInfo.ConsumeCountLimit[i] > 0 then + ConsumeLimitList[v] = true + end + end + XFubenSimulatedCombatManager.OnCurrencyChange() + end + + XFubenSimulatedCombatManager.ResetChange() + XFubenSimulatedCombatManager.RegisterEditBattleProxy() + end + + local FUBEN_SIMUCOMBAT_PROTO = { + SimulatedCombatGetStageRewardRequest = "SimulatedCombatGetStageRewardRequest", + SimulatedCombatPreFightRequest = "SimulatedCombatPreFightRequest", + SimulatedCombatPointRewardRequest = "SimulatedCombatPointRewardRequest", + SimulatedCombatGetStarRewardRequest = "SimulatedCombatGetStarRewardRequest", + } + + function XFubenSimulatedCombatManager.GetCurrentActTemplate() + return ActivityInfo + end + + function XFubenSimulatedCombatManager.GetCurrencyIdByNo(no) + return CurrencyNoToId[no] + end + + function XFubenSimulatedCombatManager.CheckChange() + return false + end + + function XFubenSimulatedCombatManager.OnActivityEnd() + XLuaUiManager.RunMain() + XUiManager.TipText("ActivityMainLineEnd", XUiManager.UiTipType.Wrong, true) + end + + function XFubenSimulatedCombatManager.ResetChange() + if not ActivityInfo then return end + + XFubenSimulatedCombatManager.SaveShopMap() + StageInterInfo = nil + MemberList = {} + AdditionList = {} + ChallengeMap = {} + CharIdToMemberId = {} + ResMemberSelectCount = 0 + XFubenSimulatedCombatManager.OnCurrencyChange() + end + + function XFubenSimulatedCombatManager.GetCurrencyByItem(item) + if ConsumeLimitList[item.Id] then + return string.format("%d/%d", LocalCurrency[item.Id], item:GetCount()) + else + return LocalCurrency[item.Id] + end + end + + function XFubenSimulatedCombatManager.GetCurrencyByNo(no) + if not ActivityInfo then return end + return LocalCurrency[ActivityInfo.ConsumeIds[no]] + end + + function XFubenSimulatedCombatManager.GetCurrencyIcon(no) + if not no or not ActivityInfo then return end + local index = tonumber(no) + return XDataCenter.ItemManager.GetItemIcon(ActivityInfo.ConsumeIds[index]) + end + + function XFubenSimulatedCombatManager.OnCurrencyChange() + if not ActivityInfo then return end + -- 计算本地货币数量 + for _, consumeId in ipairs(ActivityInfo.ConsumeIds) do + LocalCurrency[consumeId] = XDataCenter.ItemManager.GetCount(consumeId) + end + + if StageInterInfo then + local priceCount = XFubenSimulatedCombatManager.CalcBuyCount() + for consumeId, price in pairs(priceCount) do + LocalCurrency[consumeId] = LocalCurrency[consumeId] - price + end + end + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_FUBEN_SIMUCOMBAT_UPDATE, false) + end + + function XFubenSimulatedCombatManager.GetResCfg(data) + if data.Type == XFubenSimulatedCombatConfig.ResType.Member then + return XFubenSimulatedCombatConfig.GetMemberById(data.Id) + elseif data.Type == XFubenSimulatedCombatConfig.ResType.Addition then + return XFubenSimulatedCombatConfig.GetAdditionById(data.Id) + end + end + + function XFubenSimulatedCombatManager.CalcPriceCount(calcSelectType) + if not StageInterInfo then return end + local price = {} + -- calcSelectType 计算特定类别选中商品的价格 + for _, consumeId in ipairs(ActivityInfo.ConsumeIds) do + price[consumeId] = 0 + end + + if XFubenSimulatedCombatManager.CheckCurrencyFree() then + return price + end + + local list = XFubenSimulatedCombatManager.GetCurrentResList(calcSelectType) + for _, item in ipairs(list) do + if item.IsSelect then + for i, v in ipairs(XFubenSimulatedCombatManager.GetResCfg(item).ConsumeCounts) do + local consume = CurrencyNoToId[i] + price[consume] = price[consume] + v + end + end + end + + return price + end + + function XFubenSimulatedCombatManager.CalcBuyCount() + if not ActivityInfo then return end + -- 计算已购买商品的价格 + local price = {} + for _, consumeId in ipairs(ActivityInfo.ConsumeIds) do + price[consumeId] = 0 + end + + if XFubenSimulatedCombatManager.CheckCurrencyFree() then + return price + end + + local list = XTool.MergeArray(MemberList, AdditionList) + for _, item in ipairs(list) do + local unitPrice = XFubenSimulatedCombatManager.GetResCfg(item).ConsumeCounts + if item.BuyMethod then + local consume = CurrencyNoToId[item.BuyMethod] + price[consume] = price[consume] + unitPrice[item.BuyMethod] + end + end + + return price + end + function XFubenSimulatedCombatManager.CheckCurrencyFree() + if not ActivityInfo or not StageInterInfo then return end + if XDataCenter.FubenManager.CheckStageIsPass(StageInterInfo.StageId) and + StageInterInfo.Type == XFubenSimulatedCombatConfig.StageType.Normal then + return true + else + return false + end + end + + function XFubenSimulatedCombatManager.GetCurStageMember(memberId) + local memberCfgList = {} + -- 后续考虑根据是否已选择、已购买排序 + for _,v in ipairs(MemberList) do + local data = XFubenSimulatedCombatConfig.GetMemberById(v.Id) + if memberId ~= v.Id then + tableInsert(memberCfgList, data) + else + tableInsert(memberCfgList, 1, data) + end + end + return memberCfgList + end + + function XFubenSimulatedCombatManager.GetCurStageMemberDataByCharId(charId) + -- XLog.Warning("GetCurStageMemberDataByCharId", charId, CharIdToMemberId[charId], CharIdToMemberId) + local memberId = CharIdToMemberId[charId] or 0 + return XFubenSimulatedCombatConfig.GetMemberById(memberId) + end + + function XFubenSimulatedCombatManager.SelectStageInter(Id) + StageInterInfo = XFubenSimulatedCombatConfig.GetStageInterData(Id) + if not StageInterInfo then return end + + LastShopMap = XFubenSimulatedCombatManager.GetShopMapCache() + MemberList = {} + ResMemberSelectCount = 0 + for _,v in ipairs(StageInterInfo.MemberIds) do + local type = XFubenSimulatedCombatConfig.ResType.Member + local data = {Id = v, Type = type} + local subMap = LastShopMap[type] + if subMap then + data.BuyMethod = subMap[v] + end + if data.BuyMethod then + ResMemberSelectCount = ResMemberSelectCount + 1 + end + tableInsert(MemberList, data) + end + AdditionList = {} + for _,v in ipairs(StageInterInfo.Additions) do + local type = XFubenSimulatedCombatConfig.ResType.Addition + local data = {Id = v, Type = type} + local subMap = LastShopMap[type] + if subMap then + data.BuyMethod = subMap[v] + end + tableInsert(AdditionList, data) + end + XFubenSimulatedCombatManager.OnCurrencyChange() + end + + function XFubenSimulatedCombatManager.GetCurrentResList(type) + if type == XFubenSimulatedCombatConfig.ResType.Member then + return MemberList + elseif type == XFubenSimulatedCombatConfig.ResType.Addition then + return AdditionList + end + return {} + end + + function XFubenSimulatedCombatManager.SelectGridRes(data) + if data.Type == XFubenSimulatedCombatConfig.ResType.Member then + if not data.BuyMethod then + if not data.IsSelect then + if ResMemberSelectCount >= MAX_CHAR_COUNT then + return false, CsXTextManagerGetText("SimulatedCombatOverMaxChar") + end + ResMemberSelectCount = ResMemberSelectCount + 1 + else + ResMemberSelectCount = ResMemberSelectCount - 1 + end + end + end + + data.IsSelect = not data.IsSelect + CsXGameEventManager.Instance:Notify(XEventId.EVENT_FUBEN_SIMUCOMBAT_UPDATE, false) + return true + end + + function XFubenSimulatedCombatManager.GetMemberCount() + local count = 0 + for _, item in ipairs(MemberList) do + if item.BuyMethod then + count = count + 1 + end + end + return count, MAX_CHAR_COUNT + end + + function XFubenSimulatedCombatManager.CancelBuyGridRes(data) + data.BuyMethod = false + if data.Type == XFubenSimulatedCombatConfig.ResType.Member then + ResMemberSelectCount = ResMemberSelectCount - 1 + end + XFubenSimulatedCombatManager.OnCurrencyChange() + end + + function XFubenSimulatedCombatManager.CheckBuyRes(type) + local selectCount, buyCount = 0, 0 + local list = XFubenSimulatedCombatManager.GetCurrentResList(type) + for _, item in ipairs(list) do + if item.IsSelect then + selectCount = selectCount + 1 + elseif item.BuyMethod then + buyCount = buyCount + 1 + end + end + if type == XFubenSimulatedCombatConfig.ResType.Member and buyCount >= MAX_CHAR_COUNT then + return false, CsXTextManagerGetText("SimulatedCombatOverMaxCharUnableBuy") + elseif selectCount > 0 then + return true + else + return false, CsXTextManagerGetText("SimulatedCombatBuyNothing") + end + end + + function XFubenSimulatedCombatManager.BuySelectedGridRes(type, payMethod) + local result, desc = XFubenSimulatedCombatManager.CheckBuyRes(type) + if not result then + return result, desc + end + + local bill = XFubenSimulatedCombatManager.CalcPriceCount(type) + local consume = CurrencyNoToId[payMethod] + if LocalCurrency[consume] < bill[consume] then + return false, CsXTextManagerGetText("SimulatedCombatBuyFail") + end + + local list = XFubenSimulatedCombatManager.GetCurrentResList(type) + for _, item in ipairs(list) do + if item.IsSelect then + item.BuyMethod = payMethod + item.IsSelect = false + end + end + XFubenSimulatedCombatManager.OnCurrencyChange() + CsXGameEventManager.Instance:Notify(XEventId.EVENT_FUBEN_SIMUCOMBAT_UPDATE, true) + return true + end + + function XFubenSimulatedCombatManager.CheckEnterRoom() + if not StageInterInfo then return end + + local memberCount = 0 + for _,v in ipairs(MemberList) do + if v.BuyMethod then + memberCount = memberCount + 1 + end + end + + if StageInterInfo.Type == XFubenSimulatedCombatConfig.StageType.Normal then + return memberCount == MAX_CHAR_COUNT + elseif StageInterInfo.Type == XFubenSimulatedCombatConfig.StageType.Challenge then + return memberCount > 0 and memberCount <= MAX_CHAR_COUNT + end + end + + --获取奖励 + function XFubenSimulatedCombatManager.GetStarRewardList() + local ownStars = XFubenSimulatedCombatManager.GetStarProgress() + local canGet = false + local startIndex = 1 + local leastGap = XMath.IntMax() + local starReward = {} + for i in ipairs(XFubenSimulatedCombatConfig.GetStarReward()) do + local cfg = XFubenSimulatedCombatConfig.GetStarRewardById(i) + if cfg then + local data = {} + data.Id = cfg.Id + data.RequireStar = cfg.RequireStar + data.RewardId = cfg.RewardId + data.IsFinish = ownStars >= cfg.RequireStar + data.IsReward = XFubenSimulatedCombatManager.CheckStarRewardGet(cfg.Id) + starReward[i] = data + if canGet then goto CONTINUE end + if data.IsFinish and not data.IsReward then + startIndex = i + canGet = true + elseif not data.IsFinish then + local gap = cfg.RequireStar - ownStars + if leastGap > gap then + leastGap = gap + startIndex = i + end + end + end + ::CONTINUE:: + end + + return starReward, canGet, startIndex + end + + function XFubenSimulatedCombatManager.GetStardRewardNeedStarNum(rewardIndex) + if not rewardCfg[rewardIndex] then + return nil + end + + return rewardCfg[rewardIndex].RequireStar + end + + --判断是否已经领奖 + function XFubenSimulatedCombatManager.CheckStarRewardGet(rewardId) + if not rewardId then + return + end + + return StarRewardDic and StarRewardDic[rewardId] + end + + --返回每日领奖次数及上限 + function XFubenSimulatedCombatManager.GetDailyRewardRemainCount() + if not ActivityInfo then return 0 end + return ActivityInfo.MaxDailyStageStarRewardCount - DailyStageStarRewardCount + end + + --读取获得奖励的状态 + function XFubenSimulatedCombatManager.CheckPointRewardGet(rewardId) + if not rewardId then + return + end + + return PointRewardDic and PointRewardDic[rewardId] + end + + -- 检测是否开启模式 + function XFubenSimulatedCombatManager.CheckModeOpen(type) + if XFubenSimulatedCombatManager.GetIsActivityEnd() then + XUiManager.TipText("RougeLikeNotInActivityTime") + return false, CS.XTextManager.GetText("RougeLikeNotInActivityTime") + end + + if type == XFubenSimulatedCombatConfig.StageType.Challenge then + local isOpen, desc = XConditionManager.CheckCondition(ActivityInfo.HardConditionId) + return isOpen, desc + end + + return true + end + + function XFubenSimulatedCombatManager.GetPointReward(id, funCb) + XNetwork.Call(FUBEN_SIMUCOMBAT_PROTO.SimulatedCombatPointRewardRequest, { Id = id }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + PointRewardDic[id] = true + if funCb then + funCb(res.Goods) + end + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_FUBEN_SIMUCOMBAT_REWARD) + end) + end + + function XFubenSimulatedCombatManager.GetStarReward(treasureId, cb) + XNetwork.Call(FUBEN_SIMUCOMBAT_PROTO.SimulatedCombatGetStarRewardRequest, {Id = treasureId},function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + -- 设置已领取 + StarRewardDic[treasureId] = true + if cb then + cb(res.Goods) + end + CsXGameEventManager.Instance:Notify(XEventId.EVENT_FUBEN_SIMUCOMBAT_UPDATE) + XEventManager.DispatchEvent(XEventId.EVENT_FUBEN_SIMUCOMBAT_UPDATE) + end) + end + + -- [初始化数据] + function XFubenSimulatedCombatManager.InitStageInfo() + for _, stageType in pairs(XFubenSimulatedCombatConfig.StageType or {}) do + local stages = XFubenSimulatedCombatConfig.GetStageInterDataByType(stageType) + for _, v in ipairs(stages) do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(v.StageId) + if stageInfo then + stageInfo.Type = XDataCenter.FubenManager.StageType.SimulatedCombat + end + end + end + + -- 通关后需要会执行InitStage 所以需要刷新 + XFubenSimulatedCombatManager.RefreshStagePassed() + end + + function XFubenSimulatedCombatManager.RefreshStagePassed() + local mapStages = XFubenSimulatedCombatConfig.GetStageInterDataByType(XFubenSimulatedCombatConfig.StageType.Normal) + local stages = XFubenSimulatedCombatConfig.GetStageInterDataByType(XFubenSimulatedCombatConfig.StageType.Challenge) + for i, v in ipairs(stages) do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(v.StageId) + local mapStageInfo = XDataCenter.FubenManager.GetStageInfo(mapStages[i].StageId) + local stageCfg = XDataCenter.FubenManager.GetStageCfg(v.StageId) + if stageInfo then + stageInfo.Unlock = mapStageInfo.Passed + stageInfo.IsOpen = mapStageInfo.Passed + + for _, preStageId in pairs(stageCfg.PreStageId or {}) do + if preStageId > 0 then + if not XDataCenter.FubenManager.CheckStageIsPass(preStageId) then + stageInfo.Unlock = false + break + end + end + end + end + end + end + + function XFubenSimulatedCombatManager.GetCharacterAndRobotId(memberId) + local data = XFubenSimulatedCombatConfig.GetMemberById(memberId) + return XRobotManager.GetCharacterId(data.RobotId), data.RobotId + end + + function XFubenSimulatedCombatManager.SendPreFightRequest(cb) + if not StageInterInfo then return end + local members = {} + local additions = {} + + CurrentTeam = XTool.Clone(XFubenSimulatedCombatConfig.TeamTemplate) + CurrentTeam.TeamId = XDataCenter.TeamManager.GetTeamId(CS.XGame.Config:GetInt("TypeIdSimulatedCombat")) + + for _, item in ipairs(MemberList) do + if item.BuyMethod then + tableInsert(members, {Id = item.Id, ConsumeType = item.BuyMethod}) + local charId = XFubenSimulatedCombatManager.GetCharacterAndRobotId(item.Id) + --XLog.Warning("name", XCharacterConfigs.GetCharacterFullNameStr(charId)) + tableInsert(CurrentTeam.TeamData, charId) + CharIdToMemberId[charId] = item.Id + end + end + + for _, item in ipairs(AdditionList) do + if item.BuyMethod then + tableInsert(additions, {Id = item.Id, ConsumeType = item.BuyMethod}) + end + end + + for i = #CurrentTeam.TeamData + 1, MAX_CHAR_COUNT do + CurrentTeam.TeamData[i] = 0 + end + + local challengeIds = {} + for i, v in ipairs(ChallengeMap) do + if v then + tableInsert(challengeIds, StageInterInfo.ChallengeIds[i]) + end + end + + XNetwork.Call(FUBEN_SIMUCOMBAT_PROTO.SimulatedCombatPreFightRequest, + { StageId = StageInterInfo.StageId, Members = members, Additions = additions, ChallengeIds = challengeIds}, + function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + if cb then + cb() + end + end) + end + + function XFubenSimulatedCombatManager.GetTeam() + if not StageInterInfo then return end + local curMapStr = XSaveTool.Stringify(XFubenSimulatedCombatManager.GetShopMap()) + local preMapStr = XSaveTool.Stringify(LastShopMap) + + if curMapStr == preMapStr then + local team = XDataCenter.TeamManager.LoadTeamLocal(StageInterInfo.StageId) + if team then + --CurrentTeam = team + --XLog.Warning("curMapStr == preMapStr", XFubenSimulatedCombatManager.GetShopMap(), LastShopMap) + return team + end + end + + --XLog.Warning("curMapStr != preMapStr", XFubenSimulatedCombatManager.GetShopMap(), LastShopMap) + return XTool.Clone(CurrentTeam) + end + + function XFubenSimulatedCombatManager.GetRoomMemberList() + local memberList = {} + for _, v in ipairs(CurrentTeam.TeamData) do + if v and v ~= 0 then + tableInsert(memberList, v) + end + end + return memberList + end + + function XFubenSimulatedCombatManager.FinishFight(settleData) + XLuaUiManager.Remove("UiSimulatedCombatResAllo") + if settleData.IsWin then + local beginData = XDataCenter.FubenManager.GetFightBeginData() + + local winData = { + SettleData = settleData, + StageId = settleData.StageId, + RewardGoodsList = settleData.RewardGoodsList, + UrgentId = settleData.UrgentEnventId, + NpcInfo = settleData.NpcHpInfo, + CharExp = beginData.CharExp, + RoleExp = beginData.RoleExp, + RoleLevel = beginData.RoleLevel, + RoleCoins = beginData.RoleCoins, + PlayerList = beginData.PlayerList, + } + if StageInterInfo.Type == XFubenSimulatedCombatConfig.StageType.Challenge then + local count = 0 + for _, v in ipairs(ChallengeMap) do + if v then + count = count + 1 + end + end + local rewardId = StageInterInfo.StarRewardIds[count] + if rewardId and rewardId ~= 0 then + winData.RewardGoodsList = XRewardManager.GetRewardList(rewardId) or XRewardManager.GetRewardListNotCount(rewardId) + end + winData.StarsMap = ChallengeMap + end + + XFubenSimulatedCombatManager.ShowReward(winData) + else + XUiManager.TipText("SimulatedCombatFailTips", XUiManager.UiTipType.Tip, true) + XDataCenter.FubenManager.ChallengeLose(settleData) + end + end + + -- [胜利] + function XFubenSimulatedCombatManager.ShowReward(winData) + if not winData or not StageInterInfo then return end + + XFubenSimulatedCombatManager.RefreshStagePassed() + XLuaUiManager.Open("UiSimulatedCombatSettleWin", winData, StageInterInfo) + end + + function XFubenSimulatedCombatManager.GetStageReward(cb) + XNetwork.Call(FUBEN_SIMUCOMBAT_PROTO.SimulatedCombatGetStageRewardRequest, {},function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + DailyStageStarRewardCount = DailyStageStarRewardCount + 1 + if cb then + cb() + end + CsXGameEventManager.Instance:Notify(XEventId.EVENT_FUBEN_SIMUCOMBAT_UPDATE, false) + end) + end + + function XFubenSimulatedCombatManager.GetStageStar(stageId) + return StageStarRecordDic[stageId] + end + + function XFubenSimulatedCombatManager.CheckStageIsSimulatedCombat(stageId) + local info = XDataCenter.FubenManager.GetStageInfo(stageId) + return info and info.Type == XDataCenter.FubenManager.StageType.SimulatedCombat + end + + -- 获取所有关卡进度 + function XFubenSimulatedCombatManager.GetStageSchedule(stageType) + local templates = {} + if stageType == XFubenSimulatedCombatConfig.StageType.Challenge then + templates = XFubenSimulatedCombatConfig.GetStageInterDataByType(stageType) + else + templates = XFubenSimulatedCombatConfig.GetStageInterDataByType(XFubenSimulatedCombatConfig.StageType.Normal) + end + + local passCount = 0 + local allCount = #templates + + for _, v in ipairs(templates) do + if XDataCenter.FubenManager.CheckStageIsPass(v.StageId) then + passCount = passCount + 1 + end + end + + return passCount, allCount + end + + -- 主题活动页面是否可挑战接口 + function XFubenSimulatedCombatManager.IsChallengeable() + if not ActivityInfo then return false end + + local passCount, allCount = XFubenSimulatedCombatManager.GetStageSchedule(XFubenSimulatedCombatConfig.StageType.Normal) + if passCount < allCount then + return true + end + + passCount, allCount = XFubenSimulatedCombatManager.GetStageSchedule(XFubenSimulatedCombatConfig.StageType.Challenge) + if passCount < allCount then + return true + end + + return false + end + + -- 获取篇章星数 + function XFubenSimulatedCombatManager.GetStarProgress() + local templates = XFubenSimulatedCombatConfig.GetStageInterDataByType(XFubenSimulatedCombatConfig.StageType.Challenge) + local totalStars = #templates * MAX_STAGE_STAR_COUNT + local ownStars = 0 + for _,v in ipairs(templates) do + local starCount = StageStarRecordDic[v.StageId] or 0 + ownStars = ownStars + starCount + end + return ownStars, totalStars + end + + function XFubenSimulatedCombatManager.GetAvailableActs() + local act = XFubenSimulatedCombatManager.GetCurrentActTemplate() + local activityList = {} + if act and + not XFubenSimulatedCombatManager.GetIsActivityEnd() and + not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.FubenSimulatedCombat) then + tableInsert(activityList, { + Id = act.Id, + Type = XDataCenter.FubenManager.ChapterType.SimulatedCombat, + Name = act.Name, + Icon = act.BannerBg, + }) + end + return activityList + end + + --判断活动是否开启 + function XFubenSimulatedCombatManager.GetIsActivityEnd() + if not ActivityInfo then return true end + local timeNow = XTime.GetServerNowTimestamp() + local isEnd = timeNow >= XFubenSimulatedCombatManager.GetEndTime() + local isStart = timeNow >= XFubenSimulatedCombatManager.GetStartTime() + local inActivity = (not isEnd) and (isStart) + return not inActivity, timeNow < XFubenSimulatedCombatManager.GetStartTime() + end + + --获取本轮开始时间 + function XFubenSimulatedCombatManager.GetStartTime() + if DefaultActivityInfo then + return XFunctionManager.GetStartTimeByTimeId(DefaultActivityInfo.TimeId) or 0 + end + return 0 + end + + --获取本轮结束时间 + function XFubenSimulatedCombatManager.GetEndTime() + if DefaultActivityInfo then + return XFunctionManager.GetEndTimeByTimeId(DefaultActivityInfo.TimeId) or 0 + end + return 0 + end + + function XFubenSimulatedCombatManager.GetPlainStarMap(stageId) + local starsCount = StageStarRecordDic[stageId] or 0 + local starMap = {starsCount >= 1, starsCount >= 2, starsCount >= 3} + return starMap, starsCount + end + + local function GetShopMapKey() + return string.format("%s%s_%d_%s", ShopMapKey, tostring(XPlayer.Id), ActivityInfo.Id, StageInterInfo.StageId) + end + + function XFubenSimulatedCombatManager.GetShopMapCache() + if not StageInterInfo then return {} end + return XSaveTool.GetData(GetShopMapKey()) or {} + end + + function XFubenSimulatedCombatManager.GetShopMap() + if not StageInterInfo then return end + local shopMap = {} + local list = XTool.MergeArray(MemberList, AdditionList) + for _, item in ipairs(list) do + if not shopMap[item.Type] then + shopMap[item.Type] = {} + end + shopMap[item.Type][item.Id] = item.BuyMethod + end + return shopMap + end + + function XFubenSimulatedCombatManager.SaveShopMap() + if not StageInterInfo then return end + --XLog.Warning("SaveShopMap", XFubenSimulatedCombatManager.GetShopMap()) + XSaveTool.SaveData(GetShopMapKey(), XFubenSimulatedCombatManager.GetShopMap()) + end + + function XFubenSimulatedCombatManager.UpdateShopMapCache() + if not StageInterInfo then return end + LastShopMap = XFubenSimulatedCombatManager.GetShopMapCache() + end + + local function GetClgMapKey(stageId) + return string.format("%s%s_%d_%s", ChallengeMapKey, tostring(XPlayer.Id), ActivityInfo.Id, stageId) + end + + function XFubenSimulatedCombatManager.GetClgMap(stageId) + local clgMap = XSaveTool.GetData(GetClgMapKey(stageId)) or {false, false, false} + local count = 0 + for _, v in ipairs(clgMap) do + if v then + count = count + 1 + end + end + return clgMap, count + end + + function XFubenSimulatedCombatManager.SaveClgMap(stageId, clgMap) + ChallengeMap = clgMap or {false, false, false} + XSaveTool.SaveData(GetClgMapKey(stageId), clgMap) + end + + -- 注册出战界面代理 + function XFubenSimulatedCombatManager.RegisterEditBattleProxy() + if IsRegisterEditBattleProxy then return end + IsRegisterEditBattleProxy = true + XUiNewRoomSingleProxy.RegisterProxy(XDataCenter.FubenManager.StageType.SimulatedCombat, + require("XUi/XUiFubenSimulatedCombat/XUiSimulatedCombatNewRoomSingle")) + end + + --活动登录下发 + function XFubenSimulatedCombatManager.NotifyData(data) + if data.ActivityId == 0 then + if CS.XFight.Instance ~= nil then + XLuaUiManager.Remove("UiSimulatedCombatMain") + XLuaUiManager.Remove("UiSimulatedCombatResAllo") + else + CsXGameEventManager.Instance:Notify(XEventId.EVENT_ACTIVITY_ON_RESET, XDataCenter.FubenManager.StageType.SimulatedCombat) + end + ActivityInfo = nil + return + end + + if not ActivityInfo or ActivityInfo.Id ~= data.ActivityId then + ActivityInfo = XFubenSimulatedCombatConfig.GetActivityTemplateById(data.ActivityId) + XFubenSimulatedCombatManager.Init() + end + + DailyStageStarRewardCount = data.DailyStageStarRewardCount + for _, starRewardId in ipairs(data.StarRewards) do + StarRewardDic[starRewardId] = true + end + for _, pointRewardId in ipairs(data.PointRewards) do + PointRewardDic[pointRewardId] = true + end + for _, stageData in ipairs(data.StageDataList) do + StageStarRecordDic[stageData.StageId] = stageData.FinishStar + end + end + + -- 下发奖励领取次数 + function XFubenSimulatedCombatManager.NotifyDailyReset(data) + DailyStageStarRewardCount = data.DailyStageStarRewardCount + CsXGameEventManager.Instance:Notify(XEventId.EVENT_FUBEN_SIMUCOMBAT_UPDATE, false) + end + + -- 下发关卡数据(通关星数) + function XFubenSimulatedCombatManager.NotifyStageData(stageData) + StageStarRecordDic[stageData.StageId] = stageData.FinishStar + end + + XEventManager.AddEventListener(XEventId.EVENT_LOGIN_DATA_LOAD_COMPLETE, function() + XFubenSimulatedCombatManager.Init() + end) + return XFubenSimulatedCombatManager +end + +XRpc.NotifySimulatedCombatData = function(data) + XDataCenter.FubenSimulatedCombatManager.NotifyData(data.Data) +end + +XRpc.NotifySimulatedCombatDailyReset = function(data) + XDataCenter.FubenSimulatedCombatManager.NotifyDailyReset(data) +end + +XRpc.NotifySimulatedCombatStageData = function(data) + XDataCenter.FubenSimulatedCombatManager.NotifyStageData(data.SimulatedCombatStageData) +end diff --git a/Resources/Scripts/XManager/XFubenSpecialTrainManager.lua b/Resources/Scripts/XManager/XFubenSpecialTrainManager.lua new file mode 100644 index 00000000..d563272f --- /dev/null +++ b/Resources/Scripts/XManager/XFubenSpecialTrainManager.lua @@ -0,0 +1,479 @@ +XFubenSpecialTrainManagerCreator = function() + + local XFubenSpecialTrainManager = {} + local ActivityId --开启的活动 + local WeeklyRewardIds --每周已经领取的奖励 + local RewardIds --已经领取的奖励 + local WeeklyStars --本周星级 + local PointRewardDic = {} --积分奖励 + + local Proto = { + SpecialTrainGetRewardRequest = "SpecialTrainGetRewardRequest", --领奖 + SpecialTrainGetWeeklyRewardRequest = "SpecialTrainGetWeeklyRewardRequest", --领奖 + SpecialTrainPointRewardRequest = "SpecialTrainPointRewardRequest", --领奖 + } + + --活动类型 + XFubenSpecialTrainManager.RewardType = { + Task = 1, + StarReward = 2 + } + + --当前活动Id + XFubenSpecialTrainManager.CurActiveId = -1 + + function XFubenSpecialTrainManager.Init() + + end + + + --检查过期 + function XFubenSpecialTrainManager.CheckActivityTimeout(id, isShowTip) + if id <= 0 then + return true + end + + local curTime = XTime.GetServerNowTimestamp() + + local config = XFubenSpecialTrainConfig.GetActivityConfigById(id) + local startTime, endTime = XFunctionManager.GetTimeByTimeId(config.TimeId) + if curTime < startTime then + if isShowTip then + XUiManager.TipMsg(CS.XTextManager.GetText("SpecialTrainNotOpen")) + end + return true + end + + if curTime > endTime then + if isShowTip then + XUiManager.TipMsg(CS.XTextManager.GetText("SpecialTrainTimeOut")) + end + return true + end + + return false + end + + + --返回当前活动 + function XFubenSpecialTrainManager.GetSpecialTrainAcitity() + if not ActivityId then + return + end + + local specialData = {} + local curTime = XTime.GetServerNowTimestamp() + + local config = XFubenSpecialTrainConfig.GetActivityConfigById(ActivityId) + local startTime, endTime = XFunctionManager.GetTimeByTimeId(config.TimeId) + + if curTime >= startTime and curTime < endTime then + local data = {} + data.Id = ActivityId + data.Type = XDataCenter.FubenManager.ChapterType.SpecialTrain + data.Config = config + table.insert(specialData, data) + end + return specialData + end + + function XFubenSpecialTrainManager.GetCurActivityId() + if not ActivityId then + return + end + + return ActivityId + end + + --获取章节的星星数 + function XFubenSpecialTrainManager.GetSpecialTrainNormalChapterStar(id) + + local chapterCfg = XFubenSpecialTrainConfig.GetChapterConfigById(id) + if not chapterCfg then + return 0 + end + + if chapterCfg.RewardType ~= XFubenSpecialTrainManager.RewardType.StarReward then + return 0 + end + + local totalStar = 0 + for i = 1, #chapterCfg.StageIds do + local stageId = chapterCfg.StageIds[i] + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + if not stageCfg.IsMultiplayer then + totalStar = totalStar + stageInfo.Stars + end + end + + return totalStar + end + + + --获取奖励 + function XFubenSpecialTrainManager.GetSpecialTrainNormalChapterReward(id) + local chapterCfg = XFubenSpecialTrainConfig.GetChapterConfigById(id) + + if not chapterCfg then + return + end + + if chapterCfg.RewardType ~= XFubenSpecialTrainManager.RewardType.StarReward then + return + end + + local totalStar = 0 + for i = 1, #chapterCfg.StageIds do + local stageId = chapterCfg.StageIds[i] + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + + if not stageCfg.IsMultiplayer then + totalStar = totalStar + stageInfo.Stars + end + end + + local specialStarReward = {} + + for i, v in ipairs(chapterCfg.RewardParams) do + local cfg = XFubenSpecialTrainConfig.GetStarRewardConfigById(v) + if cfg then + local data = {} + data.Id = cfg.Id + data.RequireStar = cfg.RequireStar + data.RewardId = cfg.RewardId + data.IsFinish = totalStar >= cfg.RequireStar + data.IsReward = XFubenSpecialTrainManager.IsReward(cfg.Id) + specialStarReward[i] = data + end + end + + return specialStarReward + end + + + --获取任务 + function XFubenSpecialTrainManager.GetSpecialTrainChapterTask(id) + local chapterCfg = XFubenSpecialTrainConfig.GetChapterConfigById(id) + + if not chapterCfg then + return + end + + if chapterCfg.RewardType ~= XFubenSpecialTrainManager.RewardType.Task then + return + end + + local specialStarReward = {} + + for i, v in ipairs(chapterCfg.RewardParams) do + specialStarReward[i] = v + end + + return specialStarReward + end + + --夏活特训关关卡获得 + function XFubenSpecialTrainManager.GetPhotoStages() + local stages = {} + local activityConfig = XFubenSpecialTrainConfig.GetActivityConfigById(XFubenSpecialTrainManager.GetCurActivityId()) + if not activityConfig then return end + for i = 1,#activityConfig.ChapterIds do + local chapterConfig = XFubenSpecialTrainConfig.GetChapterConfigById(activityConfig.ChapterIds[i]) + for j = 1, #chapterConfig.StageIds do + table.insert(stages, chapterConfig.StageIds[j]) + end + end + return stages + end + + function XFubenSpecialTrainManager.IsPhotoStage(stageId) + local activityConfig = XFubenSpecialTrainConfig.GetActivityConfigById(XFubenSpecialTrainManager.GetCurActivityId()) + if not activityConfig then return end + for i = 1,#activityConfig.ChapterIds do + local chapterConfig = XFubenSpecialTrainConfig.GetChapterConfigById(activityConfig.ChapterIds[i]) + for j = 1, #chapterConfig.StageIds do + if chapterConfig.StageIds[j] == stageId then + return true + end + end + end + return false + end + + --判断是否已经领奖 + function XFubenSpecialTrainManager.IsReward(rewardId) + if not rewardId then + return + end + + if not RewardIds then + return false + end + + for i, v in ipairs(RewardIds) do + if v == rewardId then + return true + end + end + + return false + end + + --读取获得奖励的状态 + function XFubenSpecialTrainManager.CheckPointRewardGet(id) + return PointRewardDic[id] or false + end + + --检查是不是有新的关卡可以挑战 + function XFubenSpecialTrainManager.CheckNotPassStage() + local config = XFubenSpecialTrainConfig.GetActivityConfigById(ActivityId) + local chapterIds = config.ChapterIds + + for _, chapterId in ipairs(chapterIds) do + local chapterCfg = XFubenSpecialTrainConfig.GetChapterConfigById(chapterId) + for i = 1, #chapterCfg.StageIds do + local stageId = chapterCfg.StageIds[i] + if not XDataCenter.FubenManager.CheckStageIsPass(stageId) then + return true + end + end + end + return false + end + + function XFubenSpecialTrainManager.CheckConditionSpecialTrainRedPoint() + if not XFubenSpecialTrainManager.GetCurActivityId() or XFubenSpecialTrainManager.CheckActivityTimeout(XFubenSpecialTrainManager.GetCurActivityId(), false) then + return false + end + local config = XFubenSpecialTrainConfig.GetActivityConfigById(ActivityId) + local chapterIds = config.ChapterIds + + for _, chapterId in ipairs(chapterIds) do + local chapeter = XFubenSpecialTrainConfig.GetChapterConfigById(chapterId) + if chapeter.RewardType == XFubenSpecialTrainManager.RewardType.StarReward then + local starRewardList = XFubenSpecialTrainManager.GetSpecialTrainNormalChapterReward(chapeter.Id) + for _, v in ipairs(starRewardList) do + if v.IsFinish and not v.IsReward then + return true + end + end + elseif chapeter.RewardType == XFubenSpecialTrainManager.RewardType.Task then + local tasks = XFubenSpecialTrainManager.GetSpecialTrainChapterTask(chapeter.Id) + for _, taskId in ipairs(tasks) do + local task = XDataCenter.TaskManager.GetTaskDataById(taskId) + if task and task.State == XDataCenter.TaskManager.TaskState.Achieved then + return true + end + end + end + end + + return false + end + + function XFubenSpecialTrainManager.CheckConditionSpecialTrainPointRedPoint() + if not XFubenSpecialTrainManager.GetCurActivityId() or XFubenSpecialTrainManager.CheckActivityTimeout(XFubenSpecialTrainManager.GetCurActivityId(), false) then + return false + end + local config = XFubenSpecialTrainConfig.GetActivityConfigById(ActivityId) + local nowTime = XTime.GetServerNowTimestamp() -- 海外修改,在检查红点的时候先判断活动开启时间 + if nowTime >= XFunctionManager.GetEndTimeByTimeId(config.TimeId) or nowTime <= XFunctionManager.GetStartTimeByTimeId(config.TimeId) then + return false + end + if config.PointItemId == 0 then + else + local pointCount = XDataCenter.ItemManager.GetCount(config.PointItemId) + for _, pointId in ipairs(config.PointRewardId) do + local tmpPointCfg = XFubenSpecialTrainConfig.GetSpecialPointRewardConfig(pointId) + if pointCount >= tmpPointCfg.NeedPoint and not XFubenSpecialTrainManager.CheckPointRewardGet(pointId) then + return true + end + end + end + return false + end + + function XFubenSpecialTrainManager.GetSpecialTrainPointItemId() + local itemId = XFubenSpecialTrainConfig.GetActivityConfigById(ActivityId).PointItemId + return itemId ~= 0 and itemId or -1 + end + + --领取奖励 + function XFubenSpecialTrainManager.SpecialTrainGetRewardRequest(id, cb) + + XNetwork.Call("SpecialTrainGetRewardRequest", { Id = id }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + table.insert(RewardIds, id) + + if cb then + cb(res.Goods) + end + + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_FUBEN_SPECIAL_TRAIN_REWARD, id) + end) + end + + function XFubenSpecialTrainManager.SpecialTrainPointRewardRequest(id, funCb) + XNetwork.Call("SpecialTrainPointRewardRequest", { Id = id }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + PointRewardDic[id] = true + if funCb then + funCb(res.Goods) + end + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_FUBEN_SPECIAL_TRAIN_REWARD, id) + end) + end + + -- 保存本地数据 + function XFubenSpecialTrainManager.SaveSpecialTrainPrefs(value, activityId, chapterId) + if XPlayer.Id and activityId and chapterId then + local key = string.format("SpecialTrain_%s_%s_%s", tostring(XPlayer.Id), activityId, chapterId) + CS.UnityEngine.PlayerPrefs.SetInt(key, value) + CS.UnityEngine.PlayerPrefs.Save() + end + end + + function XFubenSpecialTrainManager.GetSpecialTrainPrefs(activityId, chapterId) + if XPlayer.Id and activityId and chapterId then + local key = string.format("SpecialTrain_%s_%s_%s", tostring(XPlayer.Id), activityId, chapterId) + if CS.UnityEngine.PlayerPrefs.HasKey(key) then + local value = CS.UnityEngine.PlayerPrefs.GetInt(key, 0) + return value + end + end + + return 0 + end + + + --活动登录下发 + function XFubenSpecialTrainManager.NotifySpecialTrainLoginData(data) + RewardIds = data.RewardIds or {} + ActivityId = data.Id + for _, pointRewardId in ipairs(data.PointRewards) do + PointRewardDic[pointRewardId] = true + end + end + + --------------副本相关------------------- + --设置关卡类型 + function XFubenSpecialTrainManager.InitStageInfo() + local chapterCfg = XFubenSpecialTrainConfig.GetChapterConfig() + for _, chapter in pairs(chapterCfg) do + for _, v in ipairs(chapter.StageIds) do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(v) + stageInfo.Type = XDataCenter.FubenManager.StageType.SpecialTrain + end + end + end + + function XFubenSpecialTrainManager.OpenFightLoading(stageId) + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + if stageCfg.IsMultiplayer then + XLuaUiManager.Open("UiOnLineLoading") + else + XDataCenter.FubenManager.OpenFightLoading(stageId) + end + end + + function XFubenSpecialTrainManager.CloseFightLoading(stageId) + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + if stageCfg.IsMultiplayer then + XLuaUiManager.Remove("UiOnLineLoading") + else + XDataCenter.FubenManager.CloseFightLoading(stageId) + end + end + + --显示奖励结算 + function XFubenSpecialTrainManager.ShowReward(winData) + local stageCfg = XDataCenter.FubenManager.GetStageCfg(winData.StageId) + if stageCfg.IsMultiplayer then + + if XDataCenter.FubenManager.CheckHasFlopReward(winData, true) then + XLuaUiManager.Open("UiFubenFlopReward", function() + XFubenSpecialTrainManager.OpenSettleUi(winData) + end, winData) + else + XFubenSpecialTrainManager.OpenSettleUi(winData) + --XLuaUiManager.Open("UiSummerRank", function() + -- XLuaUiManager.PopThenOpen("UiSettleWin", winData) + --end, winData) + end + else + XLuaUiManager.Open("UiSettleWinMainLine", winData) + end + + end + + function XFubenSpecialTrainManager.OpenSettleUi(winData) + if XDataCenter.RoomManager.RoomData then + XLuaUiManager.PopThenOpen("UiSummerEpisodeSettle",function() + XDataCenter.FubenManager.FubenSettling = false + XDataCenter.FubenManager.FubenSettleResult = nil + end) + else + XLuaUiManager.PopThenOpen("UiSettleWinMainLine", winData) + end + end + + function XFubenSpecialTrainManager.CallFinishFight() + XDataCenter.FubenManager.FubenSettling = false + XDataCenter.FubenManager.FubenSettleResult = nil + CS.XGameEventManager.Instance:Notify(XEventId.EVENT_FIGHT_FINISH) + end + + function XFubenSpecialTrainManager.SettleFight(result) + if XDataCenter.FubenManager.FubenSettling then + XLog.Warning("XFubenManager.SettleFight Warning, fuben is settling!") + return + end + + XDataCenter.FubenManager.StatisticsFightResultDps(result) + XDataCenter.FubenManager.FubenSettling = true + local fightResult = XDataCenter.FubenManager.CtorFightResult(result) + XDataCenter.FubenManager.CurFightResult = fightResult + XNetwork.Call("FightSettleRequest", { Result = fightResult }, function(res) + XEventManager.DispatchEvent(XEventId.EVENT_FUBEN_SETTLE_REWARD, fightResult.Settle) + XDataCenter.FubenManager.FubenSettleResult = res + if res.Settle.IsWin then + XFubenSpecialTrainManager.ShowReward(res.Settle) + end + end) + end + + function XFubenSpecialTrainManager.GetSavePhotoKey() + return string.format("%s_%s", "SummerEpisodePhoto", XPlayer.Id) + end + + function XFubenSpecialTrainManager.SetSavePhotoValue(value) + local isSave = value == true and 1 or 0 + XSaveTool.SaveData(XFubenSpecialTrainManager.GetSavePhotoKey(),isSave) + end + + function XFubenSpecialTrainManager.GetSavePhotoValue() + return XSaveTool.GetData(XFubenSpecialTrainManager.GetSavePhotoKey()) == 1 + end + + XFubenSpecialTrainManager.Init() + + return XFubenSpecialTrainManager +end + +-- 登录活动数据下发 +XRpc.NotifySpecialTrainLoginData = function(notifyData) + XDataCenter.FubenSpecialTrainManager.NotifySpecialTrainLoginData(notifyData) +end + diff --git a/Resources/Scripts/XManager/XFubenUnionKillManager.lua b/Resources/Scripts/XManager/XFubenUnionKillManager.lua new file mode 100644 index 00000000..6bfdd22d --- /dev/null +++ b/Resources/Scripts/XManager/XFubenUnionKillManager.lua @@ -0,0 +1,675 @@ +XFubenUnionKillManagerCreator = function() + + local XFubenUnionKillManager = {} + + local UnionKillRpc = { + GetBoxReward = "GetBoxRewardRequest", -- 领取宝箱 + GetUnionKillRankData = "GetUnionKillRankDataRequest", -- 获取歼敌排行榜 + GetUnionPraiseRankData = "GetUnionPraiseRankDataRequest", -- 获取点赞排行榜 + PraisePlayer = "UnionKillPraiseRequest", -- 点赞请求 + LeaveFightRoom = "UnionKillLeaveFightRoomRequest", -- 离开战斗房间 + } + + --------------------------------------------------------排行数据 + local UnionRankData = XClass(nil, "UnionRankData") + + function UnionRankData:Ctor(rankDatas) + self.LastModify = 0 + if not rankDatas then return end + self:UpdateUnionRankData(rankDatas) + end + + function UnionRankData:UpdateUnionRankData(rankDatas) + self.Score = rankDatas.Score or 0 + self.Rank = rankDatas.Rank or 0 + self.TotalRank = rankDatas.TotalRank or 0 + self.HistoryRank = rankDatas.HistoryRank or 0 + self.PlayerList = rankDatas.UnionKillRowRankInfos or rankDatas.UnionPraiseRowRankInfos or {} + self:SetModifyTime() + end + + function UnionRankData:SetModifyTime() + self.LastModify = XTime.GetServerNowTimestamp() + end + --------------------------------------------------------提示数据 + local UnionTipMessage = XClass(nil, "UnionTipMessage") + + function UnionTipMessage:Ctor(msg, chatData) + self.IsChatMsg = false + if msg then + self.TipsType = msg.TipsType + self.PlayerId = msg.PlayerId + self.CharacterId = msg.CharacterId + self.ShareCharacterInfos = msg.ShareCharacterInfos + end + if chatData then + self.PlayerId = chatData.SenderId + self.ChatData = chatData + self.IsChatMsg = true + end + end + + function UnionTipMessage:IsChatTip() + return self.IsChatMsg + end + + local UnionKillData = {} + local UnionKillFightRoomData = nil + local PraiseRankDatas = UnionRankData.New() + local KillRankDatas = {} + local SectionKillBossCount = {} + local TipQueue = {} + local CacheTeam = {} + local Max_Team_Count = 3 + -- 判断结算用 + local EventStageIds = {} + local BossStageIds = {} + local TrialStageIds = {} + + function XFubenUnionKillManager.InitStageInfo() + -- 初始化全部 + if UnionKillData and UnionKillData.Id and UnionKillData.Id > 0 then + EventStageIds = {} + BossStageIds = {} + TrialStageIds = {} + local unionKillTemplate = XFubenUnionKillConfigs.GetUnionActivityById(UnionKillData.Id) + if unionKillTemplate then + for i = 1, #unionKillTemplate.SectionId do + local sectionId = unionKillTemplate.SectionId[i] + local sectionTemplate = XFubenUnionKillConfigs.GetUnionSectionById(sectionId) + if sectionTemplate then + XFubenUnionKillManager.SetStageInfoType(sectionTemplate.BossStage) + BossStageIds[sectionTemplate.BossStage] = true + + XFubenUnionKillManager.SetStageInfoType(sectionTemplate.TrialStage) + TrialStageIds[sectionTemplate.TrialStage] = true + + for _, stageId in pairs(sectionTemplate.EventStageId) do + XFubenUnionKillManager.SetStageInfoType(stageId) + EventStageIds[stageId] = true + end + end + end + end + end + end + + function XFubenUnionKillManager.SetStageInfoType(stageId) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + if stageInfo then + stageInfo.Type = XDataCenter.FubenManager.StageType.UnionKill + end + end + + function XFubenUnionKillManager.ShowReward(winData) + if not winData then return end + -- 有共享角色、先弹出点赞界面 + local unionKillResult = winData.SettleData.UnionKillResult + if unionKillResult then + local shareResults = unionKillResult.ShareResultInfos + if shareResults and #shareResults > 0 then + XLuaUiManager.Open("UiUnionKillGrade", winData) + return + end + end + + local stageId = winData.SettleData.StageId + -- 没有贡献角色、走通用 + -- 事件关卡 + if XFubenUnionKillManager.IsEventStage(stageId) then + XLuaUiManager.Open("UiSettleWin", winData) + return + end + -- boss、试炼关卡 + if XFubenUnionKillManager.IsBossStage(stageId) or XFubenUnionKillManager.IsTrialStage(stageId) then + if winData.SettleData.UnionKillResult then + XLuaUiManager.Open("UiArenaFightResult", winData) + return + end + end + + -- by default + XLuaUiManager.Open("UiSettleWin", winData) + end + + -- 离开战斗房间 + function XFubenUnionKillManager.LeaveFightRoom(func) + XNetwork.Call(UnionKillRpc.LeaveFightRoom, {}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + if func then + func() + end + end) + end + + -- 点赞请求 + function XFubenUnionKillManager.PraisePlayerCharacters(playerId, characterId, func) + XNetwork.Call(UnionKillRpc.PraisePlayer, { + PlayerId = playerId, CharacterId = characterId + }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + if func then + func() + end + end) + end + + -- 获取点赞排行榜 + function XFubenUnionKillManager.GetPraiseRankData(func) + XNetwork.Call(UnionKillRpc.GetUnionPraiseRankData, {}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + PraiseRankDatas:UpdateUnionRankData(res) + + if func then + func() + end + end) + end + + -- 获取歼敌排行榜 + function XFubenUnionKillManager.GetUnionKillRankData(levelId, func) + XNetwork.Call(UnionKillRpc.GetUnionKillRankData, { LevelId = levelId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + if not KillRankDatas[levelId] then + KillRankDatas[levelId] = UnionRankData.New(res) + else + KillRankDatas[levelId]:UpdateUnionRankData(res) + end + + if func then + func() + end + end) + end + + -- 领取宝箱 + function XFubenUnionKillManager.GetUnionBoxReward(id, func) + XNetwork.Call(UnionKillRpc.GetBoxReward, { Id = id }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + XUiManager.OpenUiObtain(res.RewardGoodsList or {}) + if func then + func() + end + end) + end + + -- 活动登录信息通知 + function XFubenUnionKillManager.SyncUnionKillLoginData(notifyData) + if not notifyData then return end + UnionKillData.Id = notifyData.Id + UnionKillData.CurSectionId = notifyData.CurSectionId + UnionKillData.WeatherId = notifyData.WeatherId + UnionKillData.SectionInfos = {} + for _, sectionInfo in pairs(notifyData.SectionInfos) do + UnionKillData.SectionInfos[sectionInfo.Id] = sectionInfo + end + + local activityTemplate = XFubenUnionKillConfigs.GetUnionActivityById(UnionKillData.Id) + if activityTemplate and UnionKillData.CurSectionId == 0 then + local length = #activityTemplate.SectionId + UnionKillData.CurSectionId = activityTemplate.SectionId[length] + end + + XFubenUnionKillManager.InitStageInfo() + end + + -- 活动信息变化:切章节界面 + function XFubenUnionKillManager.SyncUnionKillActivityData(notifyData) + if not notifyData then return end + UnionKillData.Id = notifyData.Id + UnionKillData.CurSectionId = notifyData.CurSectionId + UnionKillData.WeatherId = notifyData.WeatherId + + local activityTemplate = XFubenUnionKillConfigs.GetUnionActivityById(UnionKillData.Id) + if activityTemplate and UnionKillData.CurSectionId == 0 then + local length = #activityTemplate.SectionId + UnionKillData.CurSectionId = activityTemplate.SectionId[length] + end + + XEventManager.DispatchEvent(XEventId.EVENT_UNIONKILL_ACTIVITYINFO) + end + + -- 通知战斗房间数据:进入关卡界面 + function XFubenUnionKillManager.SyncUnionKillFightRoomData(notifyData) + if not notifyData then return end + UnionKillFightRoomData = {} + UnionKillFightRoomData.EndTime = notifyData.EndTime + UnionKillFightRoomData.BossHpLeft = notifyData.BossHpLeft + UnionKillFightRoomData.UnionKillPlayerInfos = {} + for index, playerInfo in pairs(notifyData.UnionKillPlayerInfos or {}) do + playerInfo.Position = index + UnionKillFightRoomData.UnionKillPlayerInfos[playerInfo.Id] = playerInfo + end + + UnionKillFightRoomData.UnionKillStageInfos = {} + for _, stageInfo in pairs(notifyData.UnionKillStageInfos or {}) do + UnionKillFightRoomData.UnionKillStageInfos[stageInfo.Id] = stageInfo + end + UnionKillFightRoomData.ChallengeStage = {} + + XDataCenter.FubenUnionKillRoomManager.SetPlayersFightState() + + -- 新关卡,重置队伍 + CacheTeam = {} + XEventManager.DispatchEvent(XEventId.EVENT_UNIONKILL_ROOMDATANOTIFY) + end + + -- 通知boss血量 + function XFubenUnionKillManager.SyncUnionKillBossHp(notifyData) + if not notifyData then return end + if not UnionKillFightRoomData then return end + + if notifyData.BossHpLeft <= 0 then + UnionKillFightRoomData.FirstKillBoss = true + end + + UnionKillFightRoomData.BossHpLeft = notifyData.BossHpLeft + + XEventManager.DispatchEvent(XEventId.EVENT_UNIONKILL_BOSSHPCHANGE) + end + + -- 通知玩家状态 + function XFubenUnionKillManager.SyncUnionKillPlayerInfo(notifyData) + if not notifyData then return end + if not UnionKillFightRoomData then return end + + local changePlayerInfo = notifyData.PlayerInfo + local oldPlayerInfo = UnionKillFightRoomData.UnionKillPlayerInfos[changePlayerInfo.Id] + local position = oldPlayerInfo.Position + changePlayerInfo.Position = position + UnionKillFightRoomData.UnionKillPlayerInfos[changePlayerInfo.Id] = changePlayerInfo + + XEventManager.DispatchEvent(XEventId.EVENT_UNIONKILL_PLAYERINFOCHANGE) + end + + -- 通知关卡信息 + function XFubenUnionKillManager.SyncUnionKillStageInfo(notifyData) + if not notifyData then return end + if not UnionKillFightRoomData then return end + + local changeStageInfo = notifyData.StageInfo + UnionKillFightRoomData.UnionKillStageInfos[changeStageInfo.Id] = changeStageInfo + + XEventManager.DispatchEvent(XEventId.EVENT_UNIONKILL_STAGEINFOCHANGE) + end + + -- 通知击杀boss + function XFubenUnionKillManager.SyncUnionKillBossCount(notifyData) + if not notifyData then return end + SectionKillBossCount[notifyData.Section] = notifyData.KillCount + + XEventManager.DispatchEvent(XEventId.EVENT_UNIONKILL_BOSSCOUNTCHANGE) + end + + -- tips通知 + function XFubenUnionKillManager.SyncUnionKillTipsMessage(notifyData) + if not notifyData then return end + + if not TipQueue["All"] then + TipQueue["All"] = {} + end + + if notifyData.TipsType == XFubenUnionKillConfigs.TipsMessageType.Praise then + table.insert(TipQueue["All"], UnionTipMessage.New(notifyData, nil)) + elseif notifyData.TipsType == XFubenUnionKillConfigs.TipsMessageType.FightBrrow then + local playerId = notifyData.PlayerId + + if notifyData.ShareCharacterInfos then + for i = 1, #notifyData.ShareCharacterInfos do + local shareInfo = notifyData.ShareCharacterInfos[i] + local args = {} + args.TipsType = XFubenUnionKillConfigs.TipsMessageType.FightBrrow + args.PlayerId = notifyData.PlayerId + args.CharacterId = notifyData.CharacterId--这种类型用不到 + args.ShareCharacterInfos = {} + args.ShareCharacterInfos.CharacterId = shareInfo.CharacterId + args.ShareCharacterInfos.PlayerId = shareInfo.PlayerId + + XFubenUnionKillManager.Add2TipQueue(false, playerId, args) + end + end + + local stageId = notifyData.StageId + XEventManager.DispatchEvent(XEventId.EVENT_UNIONKILL_FIGHTSTATUS, playerId, stageId) + + elseif notifyData.TipsType == XFubenUnionKillConfigs.TipsMessageType.ResultBorrow then + table.insert(TipQueue["All"], UnionTipMessage.New(notifyData, nil)) + elseif notifyData.TipsType == XFubenUnionKillConfigs.TipsMessageType.LeaveStage then + local playerId = notifyData.PlayerId + XEventManager.DispatchEvent(XEventId.EVENT_UNIONKILL_FIGHTSTATUS, playerId) + end + + XEventManager.DispatchEvent(XEventId.EVENT_UNIONKILL_TIPSMESSAGE) + end + + + -- 是否是事件关卡 + function XFubenUnionKillManager.IsEventStage(stageId) + return EventStageIds[stageId] + end + + -- 是否是boss关卡 + function XFubenUnionKillManager.IsBossStage(stageId) + return BossStageIds[stageId] + end + + -- 是否是试炼关 + function XFubenUnionKillManager.IsTrialStage(stageId) + return TrialStageIds[stageId] + end + + -- 判断我是否通关某关卡 + function XFubenUnionKillManager.IsMeFinish(stageInfo) + if not stageInfo then return false end + for _, playerId in pairs(stageInfo.PlayerIds or {}) do + if playerId == XPlayer.Id then + return true + end + end + return false + end + + -- 判读其他玩家是否通关某关卡 + function XFubenUnionKillManager.IsOthersFinish(stageInfo) + if not stageInfo then return false end + for _, playerId in pairs(stageInfo.PlayerIds or {}) do + if playerId ~= XPlayer.Id then + return true + end + end + return false + end + + + -- 通知玩家离开房间 + function XFubenUnionKillManager.SyncUnionKillLeaveRoom(notifyData) + if not notifyData then return end + + -- 离开队伍 + if UnionKillFightRoomData then + UnionKillFightRoomData.LeaveReson = notifyData.Reason + end + + XEventManager.DispatchEvent(XEventId.EVENT_UNIONKILL_LEAVEROOM, notifyData.Reason) + end + + -- 提示玩家离开的理由 + function XFubenUnionKillManager.TipsPlayerleaveReson(leaveReason) + if XFubenUnionKillConfigs.LeaveReason.LeaveTeam == leaveReason then + XUiManager.TipMsg(CS.XTextManager.GetText("UnionLeaveMiddle")) + elseif XFubenUnionKillConfigs.LeaveReason.LeaveFight == leaveReason then + XUiManager.TipMsg(CS.XTextManager.GetText("UnionLeaveMiddle")) + elseif XFubenUnionKillConfigs.LeaveReason.TimeOver == leaveReason then + XUiManager.TipMsg(CS.XTextManager.GetText("UnionLeaveTimeOver")) + elseif XFubenUnionKillConfigs.LeaveReason.KickOut == leaveReason then + XUiManager.TipMsg(CS.XTextManager.GetText("UnionLeaveKickOut")) + elseif XFubenUnionKillConfigs.LeaveReason.Offline == leaveReason then + XUiManager.TipMsg(CS.XTextManager.GetText("UnionLeaveOffline")) + else + XUiManager.TipMsg(CS.XTextManager.GetText("UnionLeaveMiddle")) + end + + end + + -- 同步章节信息 + function XFubenUnionKillManager.SyncUnionKillSectionData(notifyData) + if not notifyData then return end + + local id = notifyData.SectionInfo.Id + UnionKillData.SectionInfos[id] = notifyData.SectionInfo + + end + + -- 获取阵容缓存 + function XFubenUnionKillManager.GetCacheTeam() + return CacheTeam + end + + -- 更新阵容缓存,这里保存的东西结算的时候可用,玩家数据被清空也可以用 + function XFubenUnionKillManager.UpdateCacheTeam(curTeam) + if not curTeam then return end + for i = 1, Max_Team_Count do + local curItem = curTeam[i] + if curItem then + if not CacheTeam[i] then + CacheTeam[i] = {} + end + CacheTeam[i].CharacterId = curItem.CharacterId + CacheTeam[i].IsShare = curItem.IsShare + CacheTeam[i].PlayerId = curItem.PlayerId + CacheTeam[i].IsTeamLeader = curItem.IsTeamLeader + else + CacheTeam[i] = nil + end + end + end + + function XFubenUnionKillManager.GetAllTip() + return TipQueue + end + + -- 获取特殊tipmessage + function XFubenUnionKillManager.GetTipQueueAll() + if not TipQueue["All"] then return nil end + if #TipQueue["All"] >= 1 then + local tip_msg = table.remove(TipQueue["All"], 1) + return tip_msg + end + return nil + end + + -- 根据玩家id获取提示 + function XFubenUnionKillManager.GetTipQueueById(playerId) + if not TipQueue[playerId] then return nil end + if #TipQueue[playerId] >= 1 then + local tip_msg = table.remove(TipQueue[playerId], 1) + return tip_msg + end + return nil + end + + -- 更新tipmessage + function XFubenUnionKillManager.Add2TipQueue(isMsgChat, playerId, tipData) + if not TipQueue[playerId] then + TipQueue[playerId] = {} + end + if isMsgChat then + table.insert(TipQueue[playerId], UnionTipMessage.New(nil, tipData)) + else + table.insert(TipQueue[playerId], UnionTipMessage.New(tipData, nil)) + end + end + + -- 获取房间数据:为空则没有房间 + function XFubenUnionKillManager.GetCurRoomData() + return UnionKillFightRoomData + end + + -- 当前房间内打过的关卡 + function XFubenUnionKillManager.UpdateChallengeStageById(stageId) + if UnionKillFightRoomData and UnionKillFightRoomData.ChallengeStage then + UnionKillFightRoomData.ChallengeStage[stageId] = true + end + end + + -- 获取boss击杀数 + function XFubenUnionKillManager.GetBossKillCount(id) + return SectionKillBossCount[id] or 0 + end + + -- 试炼关是否可以使用共享角色 + function XFubenUnionKillManager.GetTrialUseShare() + local unionKillInfo = XFubenUnionKillManager.GetUnionKillInfo() + if unionKillInfo == nil then return true end + + if unionKillInfo.Id == nil or unionKillInfo.Id == 0 then return true end + + local curSectionId = unionKillInfo.CurSectionId + local curSectionTemplate = XFubenUnionKillConfigs.GetUnionSectionById(curSectionId) + if not curSectionTemplate then return true end + + return curSectionTemplate.TrialUseShare == 1 + end + + -- 是否为试炼关 + function XFubenUnionKillManager.CurIsTrialBoss() + local roomFightData = XFubenUnionKillManager.GetCurRoomData() + if not roomFightData then return false end + return roomFightData.BossHpLeft <= 0 + end + + -- 获取章节信息 + function XFubenUnionKillManager.GetSectionInfoById(id) + + if not id then return nil end + return UnionKillData.SectionInfos[id] + end + + -- 获取合众歼敌信息 + function XFubenUnionKillManager.GetUnionKillInfo() + return UnionKillData + end + + -- 获取点赞排名数据 + function XFubenUnionKillManager.GetPraiseRankInfos() + return PraiseRankDatas + end + + -- 获取歼敌排名数据 + function XFubenUnionKillManager.GetKillRankInfosByLevel(level) + return KillRankDatas[level] + end + + -- 获取活动入口 + function XFubenUnionKillManager.GetUnionKillActivity() + local sections = {} + local activityId = UnionKillData and UnionKillData.Id + + if activityId and activityId > 0 and XFubenUnionKillConfigs.UnionKillInActivity(activityId) then + local activityConfig = XFubenUnionKillConfigs.GetUnionActivityConfigById(activityId) + local section = { + Id = activityId, + Type = XDataCenter.FubenManager.ChapterType.UnionKill, + BannerBg = activityConfig.Icon + } + + table.insert(sections, section) + end + + return sections + end + + local function GetActivityId() + local activityId = XFubenUnionKillConfigs.GetUnionDefaultActivityId() + + local unionInfo = XDataCenter.FubenUnionKillManager.GetUnionKillInfo() + if unionInfo and unionInfo.Id and unionInfo.Id > 0 then + activityId = unionInfo.Id + end + + return activityId + end + + -- 获取活动入口时间 + function XFubenUnionKillManager.GetUnionActivityTimes() + local activityId = GetActivityId() + return XFubenUnionKillConfigs.GetUnionActivityTimes(activityId) + end + + -- 保存本地数据 + function XFubenUnionKillManager.SaveUnionKillStringPrefs(key, value) + if XPlayer.Id then + key = string.format("%s_%s", key, tostring(XPlayer.Id)) + CS.UnityEngine.PlayerPrefs.SetString(key, value) + CS.UnityEngine.PlayerPrefs.Save() + end + end + + function XFubenUnionKillManager.GetUnionKillStringPrefs(key, defaultValue) + if XPlayer.Id then + key = string.format("%s_%s", key, tostring(XPlayer.Id)) + if CS.UnityEngine.PlayerPrefs.HasKey(key) then + local unionPref = CS.UnityEngine.PlayerPrefs.GetString(key) + return (unionPref == nil or unionPref == "") and defaultValue or unionPref + end + end + return defaultValue + end + + function XFubenUnionKillManager.Init() + end + + XFubenUnionKillManager.Init() + return XFubenUnionKillManager +end + +-- 同步登陆数据 +XRpc.NotifyUnionKillLoginData = function(notifyData) + XDataCenter.FubenUnionKillManager.SyncUnionKillLoginData(notifyData) +end + +-- 同步活动数据 +XRpc.NotifyUnionKillActivityData = function(notifyData) + XDataCenter.FubenUnionKillManager.SyncUnionKillActivityData(notifyData) +end + +-- 同步房间内数据 +XRpc.NotifyUnionKillFightRoomData = function(notifyData) + XDataCenter.FubenUnionKillManager.SyncUnionKillFightRoomData(notifyData) +end + +-- 同步boss血量 +XRpc.NotifyUnionKillBossHp = function(notifyData) + XDataCenter.FubenUnionKillManager.SyncUnionKillBossHp(notifyData) +end + +-- 通知玩家状态 +XRpc.NotifyUnionKillPlayerInfo = function(notifyData) + XDataCenter.FubenUnionKillManager.SyncUnionKillPlayerInfo(notifyData) +end + +-- 通知关卡信息 +XRpc.NotifyUnionKillStageInfo = function(notifyData) + + XDataCenter.FubenUnionKillManager.SyncUnionKillStageInfo(notifyData) +end + +-- 通知击杀boss +XRpc.NotifyUnionKillBossCount = function(notifyData) + XDataCenter.FubenUnionKillManager.SyncUnionKillBossCount(notifyData) +end + +-- tips通知 +XRpc.NotifyUnionKillTipsMessage = function(notifyData) + XDataCenter.FubenUnionKillManager.SyncUnionKillTipsMessage(notifyData) +end + +-- 通知玩家离开战斗房间 +XRpc.NotifyUnionKillLeaveRoom = function(notifyData) + XDataCenter.FubenUnionKillManager.SyncUnionKillLeaveRoom(notifyData) +end + +-- 通知章节信息 +XRpc.NotifyUnionKillSectionData = function(notifyData) + + XDataCenter.FubenUnionKillManager.SyncUnionKillSectionData(notifyData) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XFubenUnionKillRoomManager.lua b/Resources/Scripts/XManager/XFubenUnionKillRoomManager.lua new file mode 100644 index 00000000..4e980f0a --- /dev/null +++ b/Resources/Scripts/XManager/XFubenUnionKillRoomManager.lua @@ -0,0 +1,497 @@ +XFubenUnionKillRoomManagerCreator = function() + + local XFubenUnionKillRoomManager = {} + local UnionRoomRpc = { + CreateUnionKillRoom = "CreateUnionKillRoomRequest", -- 创建房间 + UnionKillMatchRoom = "UnionKillMatchRoomRequest", -- 匹配 + UnionKillCancelMatch = "UnionKillCancelMatchRequest", -- 取消匹配 + UnionKillEnterFight = "UnionKillEnterFightRequest", -- 进入战斗 + UnionKillChangePlayerState = "UnionKillChangePlayerStateRequest", -- 更改玩家状态 + UnionKillChangeLeader = "UnionKillChangeLeaderRequest", -- 更改队长 + UnionKillKickOut = "UnionKillKickOutRequest", -- 踢出队伍 + UnionKillSelect = "UnionKillSelectRequest", -- 选择角色 + UnionKillEnterTargetRoom = "UnionKillEnterTargetRoomRequest", -- 进入房间 + UnionKillLeaveTeamRoom = "UnionKillLeaveTeamRoomRequest", -- 离开组队界面 + UnionKillSetAutoMatch = "UnionKillSetAutoMatchRequest", -- 切换快速匹配 + } + + local UnionRoomData = {} + local IsUnionMatching = false + + + -- 快速匹配:结果返回 + function XFubenUnionKillRoomManager.SyncMatchData(notifyData) + if not notifyData then return end + + if notifyData.Code ~= XCode.Success then + IsUnionMatching = false + XEventManager.DispatchEvent(XEventId.EVENT_UNIONKILLROOM_MATCHRESULT) + return + end + + XDataCenter.ChatManager.ResetRoomChat() + UnionRoomData.Id = notifyData.RoomData.Id + UnionRoomData.AutoMatch = notifyData.RoomData.AutoMatch + UnionRoomData.State = notifyData.RoomData.State + local playerDataList = notifyData.RoomData.PlayerDataList + UnionRoomData.PlayerDataList = {} + for _, playerData in pairs(playerDataList or {}) do + UnionRoomData.PlayerDataList[playerData.Id] = playerData + end + + if XLuaUiManager.IsUiShow("UiDialog") then + XLuaUiManager.Close("UiDialog") + end + + IsUnionMatching = false + XLuaUiManager.Open("UiUnionKillRoom") + XEventManager.DispatchEvent(XEventId.EVENT_UNIONKILLROOM_MATCHRESULT) + end + + -- 被踢出队伍 + function XFubenUnionKillRoomManager.SyncKickOutData(notifyData) + if not notifyData then return end + + if notifyData.Code == XCode.Success then + local playerData = UnionRoomData.PlayerDataList[XPlayer.Id] + if playerData and playerData.Leader then + XUiManager.TipMsg(CS.XTextManager.GetText("UnionLeaderStayTooLong")) + else + XUiManager.TipMsg(CS.XTextManager.GetText("UnionMemberKickOut")) + end + else + XUiManager.TipCode(notifyData.Code) + end + UnionRoomData = {} + + XEventManager.DispatchEvent(XEventId.EVENT_UNIONKILLROOM_KICKOUT) + end + + -- 同步队长信息 + function XFubenUnionKillRoomManager.SyncRoomLeaderData(notifyData) + if not notifyData then return end + if UnionRoomData then + for id, playerData in pairs(UnionRoomData.PlayerDataList or {}) do + playerData.Leader = notifyData.LeaderId == id + end + end + + XEventManager.DispatchEvent(XEventId.EVENT_UNIONKILLROOM_LEADER_CHANGED) + end + + -- 同步玩家状态 + function XFubenUnionKillRoomManager.SyncPlayerStatusData(notifyData) + if not notifyData then return end + local lastState = XFubenUnionKillConfigs.UnionRoomPlayerState.Normal + if UnionRoomData then + for id, playerData in pairs(UnionRoomData.PlayerDataList or {}) do + if id == notifyData.PlayerId then + lastState = playerData.State + playerData.State = notifyData.State + end + end + end + + XEventManager.DispatchEvent(XEventId.EVENT_UNIONKILLROOM_PLAYERSTATE_CHANGED, notifyData.PlayerId, lastState) + end + + -- 同步玩家共享角色信息 + function XFubenUnionKillRoomManager.SyncPlayerFightNpcData(notifyData) + if not notifyData then return end + if UnionRoomData then + for id, playerData in pairs(UnionRoomData.PlayerDataList or {}) do + if id == notifyData.PlayerId then + playerData.FightNpcData = notifyData.FightNpcData + end + end + end + + XEventManager.DispatchEvent(XEventId.EVENT_UNIONKILLROOM_FIGHTNPC_CHANGED, notifyData.PlayerId) + end + + -- 有其他玩家加入我所在的房间 + function XFubenUnionKillRoomManager.SyncPlayerEnterData(notifyData) + if not notifyData then return end + if UnionRoomData and UnionRoomData.PlayerDataList then + local playerData = notifyData.PlayerData + UnionRoomData.PlayerDataList[playerData.Id] = playerData + end + + XEventManager.DispatchEvent(XEventId.EVENT_UNIONKILLROOM_PLAYERENTER) + end + + -- 有玩家离开当前房间 + function XFubenUnionKillRoomManager.SyncPlayerLeaveData(notifyData) + if not notifyData then return end + + if notifyData.PlayerId == XPlayer.Id then + if not CS.XFight.IsRunning then + XUiManager.TipMsg(CS.XTextManager.GetText("UnionNetworkFluctuation")) + end + UnionRoomData = {} + XEventManager.DispatchEvent(XEventId.EVENT_UNIONKILLROOM_KICKOUT) + return + end + if UnionRoomData and UnionRoomData.PlayerDataList then + UnionRoomData.PlayerDataList[notifyData.PlayerId] = nil + if notifyData.NewLeaderId and notifyData.NewLeaderId ~= 0 then + for id, playerData in pairs(UnionRoomData.PlayerDataList or {}) do + playerData.Leader = id == notifyData.NewLeaderId + end + end + end + + XEventManager.DispatchEvent(XEventId.EVENT_UNIONKILLROOM_PLAYERLEAVE) + end + + -- 快速匹配同步 + function XFubenUnionKillRoomManager.SyncAutoMatchData(notifyData) + if not notifyData then return end + + if UnionRoomData then + UnionRoomData.AutoMatch = notifyData.AutoMatch + end + + XEventManager.DispatchEvent(XEventId.EVENT_UNIONKILLROOM_AUTOMATCHCHANGE) + + end + + -- 玩家主动离开队伍 + function XFubenUnionKillRoomManager.LeaveUnionTeamRoom(func) + XNetwork.Call(UnionRoomRpc.UnionKillLeaveTeamRoom, {}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + if func then + func() + end + + -- 清理房间数据 + UnionRoomData = {} + end) + + end + + -- 进入房间:点击链接 + function XFubenUnionKillRoomManager.EnterTargetUnionRoom(roomId, func) + XNetwork.Call(UnionRoomRpc.UnionKillEnterTargetRoom, { + RoomId = roomId + }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XDataCenter.ChatManager.ResetRoomChat() + UnionRoomData.Id = res.RoomData.Id + UnionRoomData.AutoMatch = res.RoomData.AutoMatch + UnionRoomData.State = res.RoomData.State + local playerDataList = res.RoomData.PlayerDataList + UnionRoomData.PlayerDataList = {} + for _, playerData in pairs(playerDataList or {}) do + UnionRoomData.PlayerDataList[playerData.Id] = playerData + end + + if func then + func() + end + + end) + end + + -- 玩家点击链接 + function XFubenUnionKillRoomManager.ClickEnterRoomHref(roomId, createTime) + + -- 检查玩法开启 + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.FubenUnionKill) then + return + end + + -- 链接超时检查 + if XTime.GetServerNowTimestamp() > createTime + CS.XGame.Config:GetInt("RoomHrefDisableTime") then + XUiManager.TipText("RoomHrefDisabled") + return + end + + XFubenUnionKillRoomManager.EnterTargetUnionRoom(roomId, function() + XLuaUiManager.Open("UiUnionKillRoom") + end) + end + + -- 切换快速匹配 + function XFubenUnionKillRoomManager.SetUnionQuickMatch(autoMatch, func) + if UnionRoomData and UnionRoomData.AutoMatch == autoMatch then return end + + XNetwork.Call(UnionRoomRpc.UnionKillSetAutoMatch, { AutoMatch = autoMatch }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + UnionRoomData.AutoMatch = autoMatch + if func then + func() + end + end) + end + + -- 选择角色-不涉及房间数据的管理 + function XFubenUnionKillRoomManager.SelectUnionRole(characterId, func) + XNetwork.Call(UnionRoomRpc.UnionKillSelect, { CharacterId = characterId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + if UnionRoomData and UnionRoomData.PlayerDataList then + local playerData = UnionRoomData.PlayerDataList[XPlayer.Id] + playerData.FightNpcData = res.FightNpcData + end + + if func then + func() + end + + end) + end + + -- 踢出队伍 + function XFubenUnionKillRoomManager.KickOutUnionTeam(playerId, func) + XNetwork.Call(UnionRoomRpc.UnionKillKickOut, { PlayerId = playerId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + if UnionRoomData then + UnionRoomData.PlayerDataList[playerId] = nil + end + + if func then + func() + end + end) + end + + -- 更换队长 + function XFubenUnionKillRoomManager.ChangeUnionLeader(playerId, func) + XNetwork.Call(UnionRoomRpc.UnionKillChangeLeader, { PlayerId = playerId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + if UnionRoomData then + for id, playerData in pairs(UnionRoomData.PlayerDataList or {}) do + playerData.Leader = id == playerId + end + end + + if func then + func() + end + end) + end + + -- 更改玩家状态-不涉及房间数据的管理 + function XFubenUnionKillRoomManager.ChangePlayerState(state, func) + local req = { State = state } + XNetwork.Call(UnionRoomRpc.UnionKillChangePlayerState, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + if func then + func() + end + end) + end + + -- 进入战斗:成功进入UnionKillStage界面-不涉及房间数据的管理 + function XFubenUnionKillRoomManager.EnterUnionRoomFihgt(func) + XNetwork.Call(UnionRoomRpc.UnionKillEnterFight, {}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + if func then + func() + end + end) + + end + + -- 取消匹配:取消匹配,成功匹配界面才能关闭-不涉及房间数据的管理 + function XFubenUnionKillRoomManager.CancelUnionMatch(func) + if not IsUnionMatching then + if func then + func() + end + return + end + XNetwork.Call(UnionRoomRpc.UnionKillCancelMatch, {}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + IsUnionMatching = false + + if func then + func() + end + end) + end + + -- 匹配:发起匹配,成功限时匹配的view-不涉及房间数据的管理 + function XFubenUnionKillRoomManager.MatchUnionRoom(func) + if IsUnionMatching then + return + end + XNetwork.Call(UnionRoomRpc.UnionKillMatchRoom, {}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + IsUnionMatching = true + + if func then + func() + end + end) + end + + -- 创建 + function XFubenUnionKillRoomManager.CreateUnionRoom(autoMatch, func) + XNetwork.Call(UnionRoomRpc.CreateUnionKillRoom, { AutoMatch = autoMatch }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XDataCenter.ChatManager.ResetRoomChat() + -- 创建房间数据 + UnionRoomData.Id = res.RoomData.Id + UnionRoomData.AutoMatch = res.RoomData.AutoMatch + UnionRoomData.State = res.RoomData.State + local playerDataList = res.RoomData.PlayerDataList + UnionRoomData.PlayerDataList = {} + for _, playerData in pairs(playerDataList or {}) do + UnionRoomData.PlayerDataList[playerData.Id] = playerData + end + + if func then + func() + end + + end) + end + + function XFubenUnionKillRoomManager.SetPlayersFightState() + if UnionRoomData then + for id, playerData in pairs(UnionRoomData.PlayerDataList or {}) do + playerData.State = XFubenUnionKillConfigs.UnionRoomPlayerState.Fight + XEventManager.DispatchEvent(XEventId.EVENT_UNIONKILLROOM_PLAYERSTATE_CHANGED, id) + end + end + end + + -- 是否是队长 + function XFubenUnionKillRoomManager.IsLeader(playerId) + if UnionRoomData and UnionRoomData.PlayerDataList then + local playerData = UnionRoomData.PlayerDataList[playerId] + if not playerData then return false end + return playerData.Leader + end + return false + end + + -- 获取队员状态 + function XFubenUnionKillRoomManager.GetPlayerState(playerId) + if UnionRoomData and UnionRoomData.PlayerDataList then + for id, playerData in pairs(UnionRoomData.PlayerDataList) do + if id == playerId then + return playerData.State + end + end + end + return XFubenUnionKillConfigs.UnionRoomPlayerState.Normal + end + + -- 全员已经准备好了:不需要考虑队长 + function XFubenUnionKillRoomManager.IsAllMemberReady() + local isAllReady = true + local hasFight = false + if UnionRoomData and UnionRoomData.PlayerDataList then + for _, playerData in pairs(UnionRoomData.PlayerDataList) do + if playerData.State ~= XFubenUnionKillConfigs.UnionRoomPlayerState.Ready and + not playerData.Leader then + isAllReady = false + end + if playerData.State == XFubenUnionKillConfigs.UnionRoomPlayerState.Fight then + hasFight = true + end + end + end + if hasFight then + isAllReady = false + end + return isAllReady + end + + function XFubenUnionKillRoomManager.IsMatching() + return IsUnionMatching + end + + -- 获取组队数据 + function XFubenUnionKillRoomManager.GetUnionRoomData() + return UnionRoomData + end + + function XFubenUnionKillRoomManager.Init() + IsUnionMatching = false + end + + XFubenUnionKillRoomManager.Init() + return XFubenUnionKillRoomManager +end + +-- 匹配成功:队长队员处理:收下收到的数据 +XRpc.UnionKillMatchNotify = function(notifyData) + XDataCenter.FubenUnionKillRoomManager.SyncMatchData(notifyData) +end + +-- 踢出队伍:一般只有队员能收到,队长变为队员也能收到 +XRpc.UnionKillKickOutNotify = function(notifyData) + XDataCenter.FubenUnionKillRoomManager.SyncKickOutData(notifyData) +end + +-- 同步玩家数据变化:队长?状态?角色?拆分成3条,减少数据同步量 +XRpc.UnionKillTeamLeaderChangeNotify = function(notifyData) + XDataCenter.FubenUnionKillRoomManager.SyncRoomLeaderData(notifyData) +end + +XRpc.UnionKillTeamPlayerStatusChangeNotify = function(notifyData) + XDataCenter.FubenUnionKillRoomManager.SyncPlayerStatusData(notifyData) +end + +XRpc.UnionKillTeamPlayerFightNpcChangeNotify = function(notifyData) + XDataCenter.FubenUnionKillRoomManager.SyncPlayerFightNpcData(notifyData) +end + +-- 玩家加入:队长队员的处理:新增加入队员的数据->刷新界面 +XRpc.UnionKillPlayerEnterNotify = function(notifyData) + XDataCenter.FubenUnionKillRoomManager.SyncPlayerEnterData(notifyData) +end + +-- 玩家离队:队长队员的处理:清除离队队员的数据->刷新界面 +XRpc.UnionKillPlayerLeaveNotify = function(notifyData) + XDataCenter.FubenUnionKillRoomManager.SyncPlayerLeaveData(notifyData) +end + +-- 快速匹配数据同步 +XRpc.UnionKillAutoMatchChangeNotify = function(notifyData) + XDataCenter.FubenUnionKillRoomManager.SyncAutoMatchData(notifyData) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XFubenUrgentEventManager.lua b/Resources/Scripts/XManager/XFubenUrgentEventManager.lua new file mode 100644 index 00000000..cc5f64c9 --- /dev/null +++ b/Resources/Scripts/XManager/XFubenUrgentEventManager.lua @@ -0,0 +1,93 @@ +XFubenUrgentEventManagerCreator = function() + + local XFubenUrgentEventManager = {} + + local UrgentEventData = {} + + local CheckUrgentEventTime = function() + if next(UrgentEventData) then + for _, v in pairs(UrgentEventData) do + local now = XTime.GetServerNowTimestamp() + local passedTime = now - v.Time + local urgentCfg = XFubenUrgentEventConfig.GetUrgentEventCfgById(v.UrgentId) + local remainTime = urgentCfg.Time - passedTime + XCountDown.CreateTimer(tostring(v.UrgentId), remainTime, now) + end + else + XCountDown.CreateTimer(XCountDown.GTimerName.UrgentEvent, 0) + end + end + + function XFubenUrgentEventManager.Init() + end + + + + function XFubenUrgentEventManager.InitStageInfo() + for urgentId, urgentCfg in pairs(XFubenUrgentEventConfig.GetUrgentEventCfg()) do + for _, stageId in ipairs(urgentCfg.StageId) do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + stageInfo.SectionId = urgentId + stageInfo.StageId = stageId + stageInfo.Type = XDataCenter.FubenManager.StageType.Urgent + end + end + end + + function XFubenUrgentEventManager.InitData(fubenUrgentEventData) + XTool.LoopMap(fubenUrgentEventData.UrgentEventData, function(k, v) + UrgentEventData[k] = v + end) + CheckUrgentEventTime() + end + + function XFubenUrgentEventManager.GetMapIdByUrgentId(urgentId) + return UrgentEventData[urgentId].StageId + end + + function XFubenUrgentEventManager.GetUrgentList() + local list = {} + for urgentId, v in pairs(UrgentEventData) do + if v.Activated then + local urgentEventTemp = { + UrgentCfg = XFubenUrgentEventConfig.GetUrgentEventCfgById(urgentId), + UrgentInfo = v, + IsClose = false, + IsUrgentEvent = true, + Id = urgentId, + Type = XDataCenter.FubenManager.ChapterType.Urgent + } + table.insert(list, urgentEventTemp) + end + end + return list + end + + function XFubenUrgentEventManager.NotifyUrgentData(req) + XTool.LoopMap(req.FubenUrgentEventData.UrgentEventData, function(k, v) + UrgentEventData[k] = v + end) + CheckUrgentEventTime() + XEventManager.DispatchEvent(XEventId.EVENT_URGENTEVENT_SYNC) + end + + function XFubenUrgentEventManager.CheckPreFight(stage) + local stageId = stage.StageId + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + local urgentId = stageInfo.SectionId + if stageId ~= XFubenUrgentEventManager.GetMapIdByUrgentId(urgentId) or XCountDown.GetRemainTime(tostring(urgentId)) <= 0 then + local msg = CS.XTextManager.GetText("FubenNotTime") + XUiManager.TipMsg(msg) + CS.XUiManager.ViewManager:Pop() + return false + end + return true + end + + XFubenUrgentEventManager.Init() + return XFubenUrgentEventManager +end + +XRpc.NotifyUrgentData = function(req) + XDataCenter.FubenUrgentEventManager.NotifyUrgentData(req) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XFubenZhouMuManager.lua b/Resources/Scripts/XManager/XFubenZhouMuManager.lua new file mode 100644 index 00000000..5157c94f --- /dev/null +++ b/Resources/Scripts/XManager/XFubenZhouMuManager.lua @@ -0,0 +1,231 @@ +--- 一个主线或外篇章节对应一个周目(ZhouMuId),把周目(ZhouMuId)当成一个模式,第几周目对应周目的第几个周目章节(ZhouMuChapterId) + +XFubenZhouMuManagerCreator = function() + local XFubenZhouMuManager = {} + + --- + --- 实现FubenManager中的接口,初始化StageInfo + function XFubenZhouMuManager.InitStageInfo() + local zhouMuChapterCfg = XFubenZhouMuConfigs.GetAllZhouMuChapterCfg() + for _, data in pairs(zhouMuChapterCfg) do + for i,stageId in ipairs(data.StageId) do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + stageInfo.Type = XDataCenter.FubenManager.StageType.ZhouMu + stageInfo.OrderId = i + end + end + end + + --- + --- 根据'zhouMuId'检查当前章节处于第几周目 + --- 如果没有解锁或没有配置周目挑战则返回 0 + ---@param zhouMuId number + ---@return number + function XFubenZhouMuManager.GetZhouMuNumber(zhouMuId) + if zhouMuId == 0 or zhouMuId == nil then + return 0 + end + + local zhouMuChapters = XFubenZhouMuConfigs.GetZhouMuChapters(zhouMuId) + + for i = #zhouMuChapters, 1, -1 do + local onThis = true -- 默认处于当前周目,有任何一个条件不满足时改为false + + -- 检查解锁条件 + local conditions = XFubenZhouMuConfigs.GetZhouMuChapterCondition(zhouMuChapters[i]) + for _, v in pairs(conditions) do + if not XConditionManager.CheckCondition(v) then + onThis = false + end + end + + if onThis then + return i + end + end + + return 0 + end + + --- + --- 获取‘zhouMuId’周目完成的挑战任务数与总数 + ---@param zhouMuId number + ---@return number + ---@return number + function XFubenZhouMuManager.GetZhouMuTaskProgress(zhouMuId) + local taskIds = XFubenZhouMuConfigs.GetZhouMuTasks(zhouMuId) + local totalTaskNum = #taskIds + local zhouMuNum = 0 + + local taskList = XDataCenter.TaskManager.GetZhouMuFullTaskList(XDataCenter.TaskManager.TaskType.ZhouMu) + if taskList == nil or next(taskList) == nil then + return zhouMuNum, totalTaskNum + end + + local taskDic = {} + for _,v in pairs(taskList) do + taskDic[v.Id] = v + end + + for _, id in pairs(taskIds) do + if taskDic[id].State == XDataCenter.TaskManager.TaskState.Achieved + or taskDic[id].State == XDataCenter.TaskManager.TaskState.Finish then + zhouMuNum = zhouMuNum + 1 + end + end + + return zhouMuNum, totalTaskNum + end + + --- + --- 检查‘zhouMuId’周目的挑战任务是否全部领取奖励 + ---@param zhouMuId number + ---@return boolean + function XFubenZhouMuManager.ZhouMuTaskIsAllFinish(zhouMuId) + local result = true + local taskIds = XFubenZhouMuConfigs.GetZhouMuTasks(zhouMuId) + + local taskList = XDataCenter.TaskManager.GetZhouMuFullTaskList(XDataCenter.TaskManager.TaskType.ZhouMu) + if taskList == nil or next(taskList) == nil then + result = false + return result + end + + local taskDic = {} + for _,v in pairs(taskList) do + taskDic[v.Id] = v + end + + for _, id in pairs(taskIds) do + if taskDic[id].State ~= XDataCenter.TaskManager.TaskState.Finish then + result = false + end + end + + return result + end + + --- + --- 检查'zhouMuId'周目是否有奖励可以领取 + ---@param zhouMuId number + ---@return boolean + function XFubenZhouMuManager.HasTaskReward(zhouMuId) + local haveTask = false + if zhouMuId == nil then + return haveTask + end + + local taskIds = XFubenZhouMuConfigs.GetZhouMuTasks(zhouMuId) + local taskList = XDataCenter.TaskManager.GetZhouMuFullTaskList(XDataCenter.TaskManager.TaskType.ZhouMu) + if taskList == nil or next(taskList) == nil then + return haveTask + end + + local taskDic = {} + for _,v in pairs(taskList) do + taskDic[v.Id] = v + end + + for _, id in pairs(taskIds) do + if taskDic[id].State == XDataCenter.TaskManager.TaskState.Achieved then + haveTask = true + end + end + + return haveTask + end + + --- + --- 根据'zhouMuId'获取周目的当前周目章节Id + ---@param zhouMuId number + ---@return number + function XFubenZhouMuManager.GetZhouMuChapterIdByZhouMuId(zhouMuId) + -- 当前周目所在的周目章节数 + local zhouMuNumber = XFubenZhouMuManager.GetZhouMuNumber(zhouMuId) + if zhouMuNumber == 0 then + return {} + end + + -- 用周目Id得到所有周目章节Id + local zhouMuChapters = XFubenZhouMuConfigs.GetZhouMuChapters(zhouMuId) + + return zhouMuChapters[zhouMuNumber] + end + + --- + --- 根据'ChapterMainId'获取周目的当前周目章节数据 + --- 'isExtra'true为外篇,false为主线 + ---@param ChapterMainId number + ---@param isExtra boolean + ---@return table + function XFubenZhouMuManager.GetZhouMuChapterData(chapterMainId, isExtra) + -- 得到该章节的周目Id + local zhouMuId + if isExtra then + zhouMuId = XFubenExtraChapterConfigs.GetZhouMuId(chapterMainId) + else + zhouMuId = XFubenMainLineConfigs.GetZhouMuId(chapterMainId) + end + + -- 当前周目所在的周目章节数 + local zhouMuNumber = XFubenZhouMuManager.GetZhouMuNumber(zhouMuId) + if zhouMuNumber == 0 then + return {} + end + + -- 用周目Id得到所有周目章节Id + local zhouMuChapters = XFubenZhouMuConfigs.GetZhouMuChapters(zhouMuId) + + -- 用当前周目章节的Id得到章节数据 + local config = XFubenZhouMuConfigs.GetZhouMuChapterCfg(zhouMuChapters[zhouMuNumber]) + + return config + end + + --- + --- 判断是否需要播放弹窗动画,以及要播放怎样的弹窗动画 + --- 'zhouMuId'为当前的周目Id + --- 'zhouMuChapterId'为当前的周目章节Id + --- 'oriLastStageIsPass'是一开始保存的当前章节最后一关是否通关的标志 + --- 如果在开启界面的时候对比发现最后一关的通关状态与'oriLastStageIsPass'不同,则说明第一次通关了最后一关 + ---@param zhouMuId number + ---@param zhouMuChapterId number + ---@param oriLastStageIsPass boolean + ---@return number + function XFubenZhouMuManager.CheckPlayTipAnima(zhouMuId, zhouMuChapterId, oriLastStageIsPass) + if oriLastStageIsPass then + -- 之前通关过当前周目章节的最后一关,不播放动画 + return XFubenZhouMuConfigs.EnumZhouMuTipAnima.None + else + local zhouMuHadIn = XSaveTool.GetData(string.format("%s%s", "ZhouMuHadIn", XPlayer.Id)) + if not zhouMuHadIn then + -- 第一次进入周目模式 + XSaveTool.SaveData(string.format("%s%s", "ZhouMuHadIn", XPlayer.Id), true) + return XFubenZhouMuConfigs.EnumZhouMuTipAnima.PlayStart + end + + local lastStage = XFubenZhouMuConfigs.GetZhouMuChapterLastStage(zhouMuChapterId) + local isPassLastStage = XDataCenter.FubenManager.CheckStageIsPass(lastStage) + + if isPassLastStage then + -- 通关了最后一关 + local isLastZhouMuChapter + local lastZhouMuChapter = XFubenZhouMuConfigs.GetZhouMuLastChapter(zhouMuId) + isLastZhouMuChapter = (lastZhouMuChapter == zhouMuChapterId) + + if isLastZhouMuChapter then + -- 最后一个周目章节,只播放结束动画 + return XFubenZhouMuConfigs.EnumZhouMuTipAnima.PlayEnd + else + -- 不是最后的周目章节,先播放结束动画,然后播放开启新周目章节的动画 + return XFubenZhouMuConfigs.EnumZhouMuTipAnima.PlayEndStart + end + else + return XFubenZhouMuConfigs.EnumZhouMuTipAnima.None + end + end + end + + return XFubenZhouMuManager + +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XFunctionCommunicationManager.lua b/Resources/Scripts/XManager/XFunctionCommunicationManager.lua new file mode 100644 index 00000000..bdc2cbe4 --- /dev/null +++ b/Resources/Scripts/XManager/XFunctionCommunicationManager.lua @@ -0,0 +1,214 @@ +XFunctionCommunicationManagerCreator = function() + local XFunctionCommunicationManager = {} + + local CommunicationQueen = {} + local CommunicationActiveList = {} + local IsCommunicating = false + local DisableFunction = false --功能屏蔽标记(调试模式时使用) + local FestivalCommunication = {} + XFunctionCommunicationManager.Type = { Normal = 1, Medal = 2 } + XFunctionCommunicationManager.FestivalType = { Love = 1, SixOne = 2 } + XFunctionCommunicationManager.InitiativeType = { GiveItem = 1,GameStory = 2} + function XFunctionCommunicationManager.Init() + DisableFunction = XMain.IsDebug and XFunctionCommunicationManager.CheckFuncDisable() + end + + --处理战斗结算 + function XFunctionCommunicationManager.HandleFunctionEvent() + + local result = XFunctionCommunicationManager.CheckCommunication(XFunctionCommunicationManager.Type.Normal) + -- if result then + -- if not IsCommunicating then + -- IsCommunicating = true + -- XFunctionCommunicationManager.ShowNextCommunication() + -- end + -- end + return result + end + + --检查开启的通讯 + function XFunctionCommunicationManager.SetCommunication() + local FunctionCommunicationConfig = XCommunicationConfig.GetFunctionCommunicationConfig() + + if FunctionCommunicationConfig then + for k, v in pairs(FunctionCommunicationConfig) do + if not XPlayer.IsCommunicationMark(v.Id) and (not CommunicationActiveList[v.Id]) then + + local isOpen = true + for _, condition in ipairs(v.ConditionIds) do + if not XConditionManager.CheckCondition(condition) then + isOpen = false + break + end + end + + if isOpen then + if not CommunicationQueen[v.Type] then CommunicationQueen[v.Type] = {} end + CommunicationActiveList[v.Id] = true + table.insert(CommunicationQueen[v.Type], v) + CommunicationQueen[v.Type].Type = v.Type + end + end + end + + for _, v in pairs(CommunicationQueen) do + table.sort(v, function(a, b) + return a.Priority < b.Priority + end) + end + + end + end + + function XFunctionCommunicationManager.SetFestivalCommunication() + local FunctionFestivalCommunicationConfig = XCommunicationConfig.GetFunctionFestivalCommunicationConfig() + + if FunctionFestivalCommunicationConfig then + for _, v in pairs(FunctionFestivalCommunicationConfig) do + local curTime = XTime.GetServerNowTimestamp() + local startStr = XTime.ParseToTimestamp(v.StartTimeStr) + local endStr = XTime.ParseToTimestamp(v.EndTimeStr) + local isOpen = true + + for _, condition in ipairs(v.ConditionIds) do + if not XConditionManager.CheckCondition(condition) then + isOpen = false + break + end + end + + if curTime < startStr or curTime > endStr then + isOpen = false + end + + if isOpen then + if not FestivalCommunication[v.Type] then + FestivalCommunication[v.Type] = v + end + end + end + end + end + + function XFunctionCommunicationManager.CheckCommunication(type) + if #CommunicationQueen[type] <= 0 then + return false + end + return true + end + + --显示 + function XFunctionCommunicationManager.ShowNextCommunication(type) + if DisableFunction then return false end + if not CommunicationQueen[type] or #CommunicationQueen[type] <= 0 then + return false + end + + local communicationData = XFunctionCommunicationManager.GetNextCommunication(type) + + XLuaUiManager.Open("UiFunctionalOpen", communicationData, type ~= XFunctionCommunicationManager.Type.Medal, true) + + return true + end + + + function XFunctionCommunicationManager.ShowFestivalCommunication() + if DisableFunction then return false end + for _, festival in pairs(FestivalCommunication) do + if festival then + local festivalCommunication = XCommunicationConfig.GetFunctionFestivalCommunicationDicByType(festival.Type) + local IsMark = false + for _,communication in pairs(festivalCommunication) do + if XPlayer.IsCommunicationMark(communication.Id) then + IsMark = true + break + end + end + + if not IsMark then + XFunctionCommunicationManager.ReqMarkCommunication(festival.Id) + XLuaUiManager.Open("UiFunctionalOpen", festival, true, false) + return true + end + end + end + + return false + end + + + function XFunctionCommunicationManager.ShowItemCommunication(CharacterId) + local initiativeConfig = XCommunicationConfig.GetFunctionInitiativeCommunicationConfig() + local firstIndex = 1 + for _, initiative in pairs(initiativeConfig) do + if initiative.Type == XFunctionCommunicationManager.InitiativeType.GiveItem then + local ret, _ = XConditionManager.CheckCondition(initiative.ConditionIds[firstIndex]) + local template = XConditionManager.GetConditionTemplate(initiative.ConditionIds[firstIndex]) + if ret and template.Params[firstIndex] and template.Params[firstIndex] == CharacterId then + XFunctionCommunicationManager.ReqMarkCommunication(initiative.Id) + XLuaUiManager.Open("UiFunctionalOpen", initiative, true, false) + end + end + end + end + + function XFunctionCommunicationManager.ShowGameStoryCommunication(CommuId, callback) + if not CommuId then return end + local config = XCommunicationConfig.GetFunctionInitiativeCommunicationConfigById(CommuId) + if not config then return end + XFunctionCommunicationManager.ReqMarkCommunication(config.Id) + XLuaUiManager.Open("UiFunctionalOpen", config, true, false, callback) + end + + function XFunctionCommunicationManager.SetFestivalCommunicationTrigger(type) + local key = string.format("%s%s%d", tostring(XPlayer.Id), "_FestivalCommunicationTrigger_", type) + CS.UnityEngine.PlayerPrefs.SetInt(key, 1) + end + + function XFunctionCommunicationManager.GetFestivalCommunicationTrigger(type) + local key = string.format("%s%s%d", tostring(XPlayer.Id), "_FestivalCommunicationTrigger_", type) + local result = CS.UnityEngine.PlayerPrefs.GetInt(key, 0) + return result + end + + + --获取下一个 + function XFunctionCommunicationManager.GetNextCommunication(type) + if not CommunicationQueen[type] or #CommunicationQueen[type] <= 0 then + return nil + end + + local communication = table.remove(CommunicationQueen[type], 1) + XFunctionCommunicationManager.ReqMarkCommunication(communication.Id) + + return communication + end + + + function XFunctionCommunicationManager.IsCommunicating() + return IsCommunicating + end + + + function XFunctionCommunicationManager.SetCommunicating(isCommunicating) + IsCommunicating = isCommunicating + end + + --请求记录 + function XFunctionCommunicationManager.ReqMarkCommunication(id) + XPlayer.ChangeCommunicationMarks(id) + end + + --检测功能开关 + function XFunctionCommunicationManager.CheckFuncDisable() + return XSaveTool.GetData(XPrefs.CommunicationTrigger) + end + + function XFunctionCommunicationManager.ChangeFuncDisable(state) + DisableFunction = state + XSaveTool.SaveData(XPrefs.CommunicationTrigger, DisableFunction) + end + + XFunctionCommunicationManager.Init() + return XFunctionCommunicationManager +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XFunctionEventManager.lua b/Resources/Scripts/XManager/XFunctionEventManager.lua new file mode 100644 index 00000000..b3ee886c --- /dev/null +++ b/Resources/Scripts/XManager/XFunctionEventManager.lua @@ -0,0 +1,211 @@ +XFunctionEventManagerCreator = function() + local InMainUi = false + local FunctionEvenState = { + IDLE = 1, + PLAYING = 2, + LOCK = 3 + } + local DisableFunction = false --功能屏蔽标记(调试模式时使用) + local FunctionState = FunctionEvenState.IDLE + + local XFunctionEventManager = {} + + function XFunctionEventManager.Init() + XEventManager.AddEventListener(XEventId.EVENT_LOGIN_SUCCESS, function() + XEventManager.AddEventListener(XEventId.EVENT_PLAYER_LEVEL_CHANGE, XFunctionEventManager.HandlerPlayerLevelChange) + XEventManager.AddEventListener(XEventId.EVENT_FIGHT_RESULT_WIN, XFunctionEventManager.HandlerFightResult) + XEventManager.AddEventListener(XEventId.EVENT_FUNCTION_EVENT_START, XFunctionEventManager.OnFunctionEventStart) + XEventManager.AddEventListener(XEventId.EVENT_MEDAL_TIPSOVER, XFunctionEventManager.OnMedalTipsCompleted) + XEventManager.AddEventListener(XEventId.EVENT_FUNCTION_EVENT_COMPLETE, XFunctionEventManager.OnFunctionEventCompleted) + XEventManager.AddEventListener(XEventId.EVENT_PLAYER_LEVEL_UP_ANIMATION_END, XFunctionEventManager.OnLevelUpAnimationEnd) + XEventManager.AddEventListener(XEventId.EVENT_TASKFORCE_TIP_MISSION_END, XFunctionEventManager.OnTipMissionEnd) + XEventManager.AddEventListener(XEventId.EVENT_AUTO_WINDOW_STOP, XFunctionEventManager.OnFunctionEventBreak) + XEventManager.AddEventListener(XEventId.EVENT_MAINUI_ENABLE, XFunctionEventManager.OnBackToMain) + XEventManager.AddEventListener(XEventId.EVENT_ARENA_RESULT_CLOSE, XFunctionEventManager.UnLockFunctionEvent) + XEventManager.AddEventListener(XEventId.EVENT_SCORETITLE_NEW, XFunctionEventManager.GetNewCollection) + XEventManager.AddEventListener(XEventId.EVENT_AUTO_WINDOW_END, XFunctionEventManager.OnHitFaceEnd) + XEventManager.AddEventListener(XEventId.EVENT_MENTOR_AUTO_GRADUATE, XFunctionEventManager.HandlerAutoGraduate) + end) + DisableFunction = XFunctionEventManager.CheckFuncDisable() + end + + --处理战斗结算 + function XFunctionEventManager.HandlerFightResult() + XFunctionEventManager.OnFunctionEventValueChange() + end + function XFunctionEventManager.TryDoDeepLinkInfo() + local afdeeplink = CS.XAppsflyerEvent.GetDeepLinkValue() + if afdeeplink and afdeeplink ~= "" then + XLog.Debug("afdeeplink:"..tostring(afdeeplink)) + end + local NewGuidePass = CS.XGame.ClientConfig:GetInt("DeepLinkCondition") + if CS.XRemoteConfig.DeepLinkEnabled and not string.IsNilOrEmpty(afdeeplink) and XConditionManager.CheckCondition(NewGuidePass) then + local endValuePos = afdeeplink:find("?af_qr=true", 1) or 0 + if endValuePos-1 > 1 then + afdeeplink = afdeeplink:sub(1,endValuePos-1) + end + local afdeepInfo = string.Split(afdeeplink, "_") + XLog.Debug("afdeepInfo:", afdeepInfo); + CS.XAppsflyerEvent.ResetDeepLinkValue() + if afdeepInfo[1] == "i" then + local skipId = tonumber(afdeepInfo[2]) + if XFunctionManager.IsAFDeepLinkCanSkipByShowTips(skipId) then + XFunctionManager.SkipInterface(skipId) + return true + end + end + elseif not XConditionManager.CheckCondition(NewGuidePass) then + CS.XAppsflyerEvent.ResetDeepLinkValue() + end + return false + end + --处理等级提升 + function XFunctionEventManager.HandlerPlayerLevelChange() + XFunctionEventManager.OnFunctionEventValueChange() + end + + --处理自动毕业 + function XFunctionEventManager.HandlerAutoGraduate() + XFunctionEventManager.OnFunctionEventValueChange() + end + + function XFunctionEventManager.OnFunctionEventValueChange() + --第一次进入主界面并播放完成首次进入动画后在响应对应的方法 + if not XLoginManager.IsStartGuide() then + return + end + + XFunctionManager.CheckOpen() + + if FunctionState ~= FunctionEvenState.IDLE or DisableFunction then + return + end + + XDataCenter.CommunicationManager.SetCommunication() + XDataCenter.CommunicationManager.SetFestivalCommunication() + -- 当前是否在主界面 + InMainUi = XLuaUiManager.IsUiShow("UiMain") + if InMainUi and CS.XRemoteConfig.DeepLinkEnabled and XFunctionEventManager.TryDoDeepLinkInfo() then + FunctionState = FunctionEvenState.PLAYING + elseif XLoginManager.CheckLimitLogin() then --登录限制(答题) + FunctionState = FunctionEvenState.PLAYING + elseif XPlayer.HandlerPlayLevelUpAnimation() then --玩家等级提升 + FunctionState = FunctionEvenState.PLAYING + elseif XDataCenter.MentorSystemManager.CheckHaveGraduateReward() then --学员毕业 + FunctionState = FunctionEvenState.PLAYING + elseif XDataCenter.FubenManager.CheckHasNewHideStage() then --隐藏关卡开启 + FunctionState = FunctionEvenState.PLAYING + elseif XDataCenter.TaskForceManager.HandlerPlayTipMission() then --任务提示 + FunctionState = FunctionEvenState.PLAYING + elseif XDataCenter.ArenaManager.CheckOpenArenaActivityResult() then -- 竞技结算 + FunctionState = FunctionEvenState.PLAYING + elseif XDataCenter.MedalManager.ShowUnlockTips() then --勋章飘窗 + FunctionState = FunctionEvenState.PLAYING + elseif InMainUi and XDataCenter.GuildBossManager.CheckShowTip() then -- 公会boss击败 + FunctionState = FunctionEvenState.PLAYING + elseif InMainUi and XDataCenter.GuildManager.CheckGuildLevelUp() then -- 公会等级提升 + FunctionState = FunctionEvenState.PLAYING + elseif XDataCenter.CommunicationManager.ShowNextCommunication(XDataCenter.CommunicationManager.Type.Medal) then --勋章通讯 + FunctionState = FunctionEvenState.PLAYING + elseif XDataCenter.CommunicationManager.ShowNextCommunication(XDataCenter.CommunicationManager.Type.Normal) then --通常通讯 + FunctionState = FunctionEvenState.PLAYING + elseif XFunctionManager.ShowOpenHint() then --系统开放 + FunctionState = FunctionEvenState.PLAYING + elseif XDataCenter.GuideManager.CheckGuideOpen() then -- 引导 + FunctionState = FunctionEvenState.PLAYING + elseif InMainUi and XDataCenter.CommunicationManager.ShowFestivalCommunication() then --节日通讯 + FunctionState = FunctionEvenState.PLAYING + elseif InMainUi and XDataCenter.AutoWindowManager.CheckAutoWindow() then -- 打脸 + FunctionState = FunctionEvenState.PLAYING + elseif XDataCenter.MedalManager.CheckCanGetNewCollection() then -- 获得收藏品 + FunctionState = FunctionEvenState.PLAYING + end + + if FunctionState ~= FunctionEvenState.PLAYING then + XEventManager.DispatchEvent(XEventId.EVENT_FUNCTION_EVENT_END) + end + end + + -- 交互开始 + function XFunctionEventManager.OnFunctionEventStart() + FunctionState = FunctionEvenState.PLAYING + end + + -- 交互完成 + function XFunctionEventManager.OnFunctionEventCompleted() + FunctionState = FunctionEvenState.IDLE + XFunctionEventManager.OnFunctionEventValueChange() + end + + --回到主界面 + function XFunctionEventManager.OnBackToMain() + FunctionState = FunctionEvenState.IDLE + XFunctionEventManager.OnFunctionEventValueChange() + end + + --飘窗结束 + function XFunctionEventManager.OnMedalTipsCompleted() + FunctionState = FunctionEvenState.IDLE + XFunctionEventManager.OnFunctionEventValueChange() + end + + -- 打脸中断 + function XFunctionEventManager.OnFunctionEventBreak() + FunctionState = FunctionEvenState.IDLE + end + + -- 打脸结束 + function XFunctionEventManager.OnHitFaceEnd() + FunctionState = FunctionEvenState.IDLE + -- if XDataCenter.GuideManager.CheckGuideOpen() then + -- FunctionState = FunctionEvenState.PLAYING + -- end + XFunctionEventManager.OnFunctionEventValueChange() + end + + --完成 + function XFunctionEventManager.OnLevelUpAnimationEnd() + FunctionState = FunctionEvenState.IDLE + XFunctionEventManager.OnFunctionEventValueChange() + end + + -- 派遣队伍提升 + function XFunctionEventManager.OnTipMissionEnd() + FunctionState = FunctionEvenState.IDLE + XFunctionEventManager.OnFunctionEventValueChange() + end + + --锁 + function XFunctionEventManager.LockFunctionEvent() + FunctionState = FunctionEvenState.LOCK + end + + --解锁 + function XFunctionEventManager.UnLockFunctionEvent() + FunctionState = FunctionEvenState.IDLE + XFunctionEventManager.OnFunctionEventValueChange() + end + + --获得收藏品 + function XFunctionEventManager.GetNewCollection() + --FunctionState = FunctionEvenState.IDLE + XFunctionEventManager.OnFunctionEventValueChange() + end + + function XFunctionEventManager.IsPlaying() + return FunctionState == FunctionEvenState.PLAYING + end + + --检测功能开关 + function XFunctionEventManager.CheckFuncDisable() + return XMain.IsDebug and XSaveTool.GetData(XPrefs.FunctionEventTrigger) + end + + function XFunctionEventManager.ChangeFuncDisable(state) + DisableFunction = state + XSaveTool.SaveData(XPrefs.FunctionEventTrigger, DisableFunction) + end + + XFunctionEventManager.Init() + return XFunctionEventManager +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XFunctionManager.lua b/Resources/Scripts/XManager/XFunctionManager.lua new file mode 100644 index 00000000..aaa2cd7a --- /dev/null +++ b/Resources/Scripts/XManager/XFunctionManager.lua @@ -0,0 +1,664 @@ +local XFunctionTime = require("XEntity/XFunctional/XFunctionTime") +local tableSort = table.sort +local tableInsert = table.insert + +local TABLE_SECONDARY_FUNCTIONAL_PATH = "Client/Functional/SecondaryFunctional.tab" +local TABLE_SKIP_FUNCTIONAL_PATH = "Client/Functional/SkipFunctional.tab" +local TABLE_FUNCTIONAL_OPEN = "Share/Functional/FunctionalOpen.tab" +--local TABLE_MAIN_AD = "Client/Functional/MainAd.tab" +local TABLE_MAIN_ACTIVITY_SKIP_PATH = "Client/Functional/MainActivitySkip.tab" +local SecondaryFunctionalTemplates = {} --二级功能配置 +local SkipFunctionalTemplates = {} --跳转功能表 +local FunctionalOpenTemplates = {} --功能开启表 +-- local MainAdTemplates = {} --广告栏 +local MainActivitySkipTemplates = {} --活动便捷入口 +local ShieldFuncDic = {} -- 功能过滤 +local ShieldUiNameDic = {} -- 功能对应的界面过滤 +local FunctionTimeData = {} --功能开启时间 + +XFunctionManager = XFunctionManager or {} + +XFunctionManager.SkipOrigin = { + System = 1, -- 系统来源 + SonSystem = 2, -- 子系统来源 + Section = 3, -- 副本来源 + Main = 4, -- 主界面 + Webpage = 5, -- 网页 + SystemWithArgs = 6, -- 跳转特定标签页的系统 + Custom = 7, -- 跳转自定义系统(大部分副本) + Dormitory = 8, -- 跳转宿舍 +} +XFunctionManager.OpenCondition = { + Default = 0, -- 默认 + TeamLevel = 1, -- 战队等级 + FinishSection = 2, -- 通关副本 + FinishTask = 3, -- 完成任务 + FinishNoob = 4, -- 完成新手 + Main = 5, -- 掉线返回主界面 +} +-- XFunctionManager.OpenHint = { +-- TeamLevelToOpen, +-- CopyToOpen, +-- FinishToOpen +-- } + +--这个枚举由服务端制定 +XFunctionManager.FunctionName = { + Target = 1, --目标 + SkipObligate = 2, --预留 + Deposit = 3, --充值 + Setting = 4, --设置 + SignIn = 5, --签到 + Feedback = 6, --反馈 + Welfare = 7, --福利 + ExchangeCode = 8, --兑换码 + + Character = 101, --构造体 + CharacterGrade = 102, --构造体晋升 + CharacterQuality = 103, --构造体进化 + CharacterSkill = 104, --构造体技能 + CharacterExhibition = 105, --构造体展示厅 + Isomer = 106, --感染体 + + Equip = 201, --装备 + EquipStrengthen = 202, --装备强化 + EquipResonance = 203, --装备共鸣 + EquipStrengthenAutoSelect = 204, --装备一键强化 + EquipAwake = 205, --装备觉醒 + + Bag = 301, --背包 + DrawCard = 401, --研发 + DrawCardEquip = 402, --研发装备 + ActivityDrawCard = 403, --活动研发 + Task = 501, --任务 + TaskDay = 503, --任务每日 + TaskActivity = 504, --任务活动 + TaskWeekly = 505, --任务每周 + Player = 601, --战队 + PlayerBrand = 602, --战队烙印 + PlayerAchievement = 603, --战斗成就 + Mail = 701, --邮件 + SocialFriend = 801, --好友 + SocialChat = 802, --聊天 + Domitory = 901, --基建(弃用) + Dorm = 902, --宿舍 + ShopCommon = 1001, --普通商店 + ShopActive = 1002, --活动商店 + Dispatch = 1201, --派遣 + BountyTask = 1301, --赏金 + MaintainerAction = 1302, --维持者行动(大富翁) + MentorSystem = 1303, --师徒系统 + MainLineTRPG = 1304, --主线跑团玩法(终焉福音) + NieR = 1305, --尼尔玩法 + Pokemon = 1306, --口袋战双 + ChessPursuitMain = 1307, -- 追击玩法 + SpringFestivalActivity = 1308, --春节集字活动 + WhiteValentineDay = 1309, -- 白色情人节约会活动 + MoeWar = 1310, -- 萌战 + FavorabilityMain = 1400, --好感度 + FavorabilityFile = 1401, --好感度-档案 + FavorabilityStory = 1402, --好感度-剧情 + FavorabilityGift = 1403, --好感度-礼物 + FavorabilityComeAcross = 1404, --好感度-偶遇 + + CustomUi = 1501, --自定义控件 + + FubenChallengeTrial = 1601, --试炼玩法 + Prequel = 1701, --断章 + Practice = 1800, --教学 + PartnerTeaching = 1801, -- 宠物教学 + + Guild = 1901, --指挥部 + GuildBoss = 1904, --工会boss + OtherHelp = 2001, --助战 + Collection = 2100, --收藏品 + Medal = 2101, --勋章 + Nameplate = 2102, --铭牌 + Archive = 2200, --图鉴系统 + SubMenu = 2300, -- 主界面二级菜单 + Photograph = 2400, -- 拍照模式 + PurchaseAdd = 3000, --累计充值 + + PicComposition = 4000, --看图作文 + WindowsInlay = 4001, --外站活动 + + Partner = 5001, --伙伴系统 + + InvitationCodeShare = 8001, -- 邀请码分享 + + FubenDifficulty = 10102, --副本困难 + FubenNightmare = 10103, --据点战 + FubenChallenge = 10201, --挑战副本 + FubenChallengeTower = 10202, --挑战爬塔 + FubenChallengeBossSingle = 10203, --挑战单机Boss + FubenArena = 10204, -- 竞技 + Stronghold = 10205, -- 超级据点 + + ActivityBrief = 10300, --活动简介 + FubenActivity = 10301, --活动副本 + FubenActivityOnlineBoss = 10302, --活动联机boss + FubenActivityBranch = 10303, --活动支线 + FubenActivitySingleBoss = 10304, --活动单挑boss + FubenActivityTrial = 10305, --试验区 + FestivalActivity = 10306, --节日活动 + FubenActivityFestival = 10306, --节日活动 + BabelTower = 10307, --巴别塔计划 + FubenActivityMainLine = 10308, --活动主线 + RepeatChallenge = 10309, --复刷本 + RogueLike = 10310, --爬塔 + FubenAssign = 10311, --占领玩法 + ArenaOnline = 10312, --区域联机玩法 + FubenUnionKill = 10313, --狙击战 + Extra = 10314, -- 外章 + FubenInfesotorExplore = 10315, --感染体玩法 + SpecialTrain = 10316, -- 特训关 + EliminateGame = 10317, -- 特训关小游戏 + Expedition = 10318, -- 虚像地平线 + ClickClearGame = 10319, -- 中元节点消小游戏 + WorldBoss = 10320, -- 世界boss + RpgTower = 10321, -- 兵法蓝图 + HonorLevel = 10322, -- 荣耀勋阶 + FubenZhongYuanFestival = 10323, -- 中元节副本 + DragPuzzleGame = 10324, -- 拼图小游戏 + NewCharAct = 10325, -- 新角色教学 + ChristmasTreeGame = 10326, -- 圣诞树装扮小游戏 + CoupletGame = 10328, -- 对联小游戏 + FingerGuessing = 10329, --猜拳小游戏 + FubenSimulatedCombat = 10330, -- 模拟作战 + InvertCardGame = 10331, -- 翻牌小游戏 + PokerGuessing = 10333, --翻牌猜大小 + MovieAssemble = 10334, -- 剧情合集 + MineSweeping = 10335, -- 扫雷 + FubenHack = 10336, -- 骇入玩法 + Reform = 10337, -- 改造玩法 + ScratchTicket = 10338, -- 刮刮卡 + KillZone = 10339, --杀戮空间 + SuperTower = 10340, -- 超级爬塔 + FashionStory = 10341, -- 涂装剧情活动 + Passport = 10342, --战斗通行证 + FubenCoupleCombat = 10343, -- 双人下场玩法 + RpgMakerActivity = 10345, --21年端午活动 + FubenDaily = 10401, --日常副本 + FubenDailyYSHTX = 10402, --日常意识海特训 + FubenDailyEMEX = 10403, --日常EMEX行动 + FubenDailyResource = 10404, --日常资源副本 + FubenExplore = 10405, --探索 + FubenDailyGZTX = 10406, --日常構造體特訓 + FubenDailyXYZB = 10407, --日常稀有裝備 + FubenDailyTPCL = 10408, --日常突破材料 + FubenDailyZBJY = 10409, --日常裝備經驗 + FubenDailyLMDZ = 10410, --日常螺母大戰 + FubenDailyJNQH = 10411, --日常技能强化 + FubenDailyFZJQH = 10412, --日常辅助机强化 + FubenDailyShop = 10450, --日常补给商店 +} + +XFunctionManager.FunctionType = { + System = 1, + Stage = 2, +} + +XFunctionManager.TimeState = { + Start = 1, + End = 2, +} + +function XFunctionManager.Init() + FunctionalOpenTemplates = {} + SecondaryFunctionalTemplates = XTableManager.ReadByIntKey(TABLE_SECONDARY_FUNCTIONAL_PATH, XTable.XTableSecondaryFunctional, "Id") + SkipFunctionalTemplates = XTableManager.ReadByIntKey(TABLE_SKIP_FUNCTIONAL_PATH, XTable.XTableSkipFunctional, "SkipId") + MainActivitySkipTemplates = XTableManager.ReadByIntKey(TABLE_MAIN_ACTIVITY_SKIP_PATH, XTable.XTableMainActivitySkip, "Id") + + --local mainAdTemplates = XTableManager.ReadByIntKey(TABLE_MAIN_AD, XTable.XTableMainAd, "Id") + --for _, v in pairs(mainAdTemplates) do + -- if not MainAdTemplates[v.ChannelId] then + -- MainAdTemplates[v.ChannelId] = {} + -- end + -- + -- tableInsert(MainAdTemplates[v.ChannelId], v) + --end + --MainAdTemplates = XReadOnlyTable.Create(MainAdTemplates) + local listOpenFunctional = XTableManager.ReadByIntKey(TABLE_FUNCTIONAL_OPEN, XTable.XTableFunctionalOpen, "Id") + for k, v in pairs(listOpenFunctional) do + local IsHasCondition = false + + for _, id in pairs(v.Condition) do + if id ~= 0 then + IsHasCondition = true + end + end + + if IsHasCondition then + FunctionalOpenTemplates[k] = v + end + end + + XFunctionManager.IsOpen = false +end + +function XFunctionManager.FilterUi(evt, args, ...) + local uiName = args[0].UiData.UiName + if ShieldUiNameDic[uiName] then + XUiManager.TipText("ShieldFunctionTip", nil, true) + XLuaUiManager.RunMain() +end +end + +function XFunctionManager.FilterUiFinish() + ShieldUiNameDic = {} + CsXGameEventManager.Instance:RemoveEvent(CS.XEventId.EVENT_UI_ALLOWOPERATE, XFunctionManager.FilterUi) + XEventManager.RemoveEventListener(XEventId.EVENT_MAINUI_ENABLE, XFunctionManager.FilterUiFinish) +end + +function XFunctionManager.InitShieldFuncData(shieldFuncList, inGameUpdate) + ShieldFuncDic = {} + ShieldUiNameDic = {} + local EnableFilterUi = true + for _, v in ipairs(shieldFuncList) do + ShieldFuncDic[v] = true + if inGameUpdate then + for _, uiName in ipairs(XFunctionConfig.GetShieldFuncUiName(v)) do + if CS.XFight.Instance and XLuaUiManager.IsUiShow(uiName) then + EnableFilterUi = false + XUiManager.TipText("ShieldFunctionTip", nil, true) + XLuaUiManager.RunMain() + ShieldUiNameDic = {} + end + ShieldUiNameDic[uiName] = true + end + end + end + + if inGameUpdate and EnableFilterUi then + CsXGameEventManager.Instance:RegisterEvent(CS.XEventId.EVENT_UI_ALLOWOPERATE, XFunctionManager.FilterUi) + XEventManager.AddEventListener(XEventId.EVENT_MAINUI_ENABLE, XFunctionManager.FilterUiFinish) +end + end + +--检测是否可以过滤该功能 +function XFunctionManager.CheckFunctionFitter(id) + return ShieldFuncDic[id] + end + +--界面跳转 +function XFunctionManager.SkipInterface(id) + if id == 0 then + return + end + + local list = XFunctionConfig.GetSkipFuncCfg(id) + if list == nil then + XLog.Error("XFunctionManager.SkipInterface error: can not found list, id = " .. tostring(id)) + return + end + + if list.FunctionalId ~= nil and list.FunctionalId ~= 0 then + -- 屏蔽功能 + if XFunctionManager.CheckFunctionFitter(list.FunctionalId) then + XUiManager.TipMsg(CS.XTextManager.GetText("FunctionalMaintain")) + return + end + + if not XFunctionManager.DetectionFunction(list.FunctionalId) then + return + end + + end + + -- 提审包屏蔽,跳转到主线页面 + if XUiManager.IsHideFunc and list.IsHideFunc then + XLuaUiManager.Open("UiFuben", XDataCenter.FubenManager.StageType.Mainline, nil, 1) + return + end + + if list.Origin == XFunctionManager.SkipOrigin.System then + if XLuaUiManager.IsUiShow(list.UiName) then + return + end + + XLuaUiManager.Open(list.UiName) + end + + if list.Origin == XFunctionManager.SkipOrigin.SonSystem then + if XLuaUiManager.IsUiShow(list.UiName) then + return + end + + if list.UiName == "UiCharacter" then + XLuaUiManager.Open(list.UiName, list.ParamId, nil, nil, nil, true) + elseif list.UiName == "UiActivityBase" then + XLuaUiManager.Open(list.UiName, list.ParamId, list.CustomParams[1], list.CustomParams[2]) + elseif list.UiName == "UiSet" then + XLuaUiManager.Open(list.UiName, false, list.ParamId or 4) + elseif list.UiName == "UiActivityBase" then + XLuaUiManager.Open(list.UiName, list.ParamId, list.CustomParams[1], list.CustomParams[2]) + else + XLuaUiManager.Open(list.UiName, list.ParamId) + end + end + + if list.Origin == XFunctionManager.SkipOrigin.Section then + XDataCenter.FubenManager.GoToFuben(list.ParamId) + end + + if list.Origin == XFunctionManager.SkipOrigin.Main then + if XLuaUiManager.IsUiShow("UiMain") then + return + end + + XLuaUiManager.RunMain() + end + + if list.Origin == XFunctionManager.SkipOrigin.SystemWithArgs then + XDataCenter.FunctionalSkipManager.SkipSystemWidthArgs(list) + return + end + + if list.Origin == XFunctionManager.SkipOrigin.Custom then + XDataCenter.FunctionalSkipManager.SkipCustom(list) + return + end + + if list.Origin == XFunctionManager.SkipOrigin.Dormitory then + XDataCenter.FunctionalSkipManager.SkipDormitory(list) + return + end + + -- if list.Origin == XFunctionManager.SkipOrigin.Webpage then + -- end +end + +function XFunctionManager.CheckSkipInDuration(id) + local cfg = XFunctionConfig.GetSkipFuncCfg(id) + if not cfg then + return false + end + + local timeId = cfg.TimeId + local startTimeStr = cfg.StartTime + local closeTimeStr = cfg.CloseTime + if timeId and timeId ~= 0 then + return XFunctionManager.CheckInTimeByTimeId(timeId) + else + local nowTimeStamp = XTime.GetServerNowTimestamp() + if startTimeStr and startTimeStr ~= "" and closeTimeStr and closeTimeStr ~= "" then + local startTime = XTime.ParseToTimestamp(startTimeStr) + local closeTime = XTime.ParseToTimestamp(closeTimeStr) + return (nowTimeStamp >= startTime and nowTimeStamp <= closeTime) + elseif startTimeStr and startTimeStr ~= "" then + local startTime = XTime.ParseToTimestamp(startTimeStr) + return nowTimeStamp >= startTime + elseif closeTimeStr and closeTimeStr ~= "" then + local closeTime = XTime.ParseToTimestamp(closeTimeStr) + return nowTimeStamp < closeTime + end + end + + return true +end + +function XFunctionManager.GetSkipList(id) + if SkipFunctionalTemplates[id] then + return SkipFunctionalTemplates[id] + end +end + + +function XFunctionManager.IsCanSkip(skipId) + local list = XFunctionConfig.GetSkipList(skipId) + if not list then return false end + return XFunctionManager.JudgeCanOpen(list.FunctionalId) +end + +function XFunctionManager.JudgeOpen(id) + --判断是否开启功能 + if not XFunctionConfig.GetFuncOpenCfg(id) then + return true + end + + return XPlayer.IsMark(id) +end + +function XFunctionManager.GetFunctionOpenCondition(id) + --获取开启条件说明 + local isOpen + local decs = "" + + if not XFunctionConfig.GetFuncOpenCfg(id) then + return decs + end + + if not XFunctionManager.IsDuringTime(id) then + return CS.XTextManager.GetText("FunctionNotDuringOpening") + end + + for _, v in pairs(XFunctionConfig.GetFuncOpenCfg(id).Condition) do + if v and v ~= 0 then + isOpen, decs = XConditionManager.CheckCondition(v) + if not isOpen then + break + end + end + end + + return decs +end + +function XFunctionManager.JudgeCanOpen(id) + if not XFunctionManager.IsDuringTime(id) then + return false + end + + -- 判断是否能开启 + local isOpen = true + + -- 如果没有配置应该返回true + if not XFunctionConfig.GetFuncOpenCfg(id) then + return true + end + + for _, v in pairs(XFunctionConfig.GetFuncOpenCfg(id).Condition) do + if v and v ~= 0 then + isOpen = XConditionManager.CheckCondition(v) + if not isOpen then + break + end + end + end + + return isOpen +end +--================ +--检测功能是否开放 +--@param functionNameId:FunctionManager.FunctionName 功能枚举ID +--@param needMark:是否需要通知后端标记功能开放 +--@param noTips:是否要弹出错误提示 +--================ +function XFunctionManager.DetectionFunction(functionNameId, needMark, noTips) + --判断能否进入功能按钮 + if not XFunctionManager.JudgeCanOpen(functionNameId) then + if not noTips then + XUiManager.TipError(XFunctionManager.GetFunctionOpenCondition(functionNameId)) + end + return false + end + --后端需要使用功能开放标记时另外特殊判断并添加标记 + if needMark then + if not XFunctionManager.JudgeOpen(functionNameId) then + XPlayer.ChangeMarks(functionNameId) + end + end + return true +end + +local CanOpenId = {} + +function XFunctionManager.CheckOpen() + --开启功能 + for _, id in ipairs(XFunctionConfig.GetOpenList()) do + if not XFunctionManager.JudgeOpen(id) then + if XFunctionManager.JudgeCanOpen(id) then + XPlayer.ChangeMarks(id) + if XFunctionConfig.GetOpenHint(id) == 1 then + tableInsert(CanOpenId, id) + end + end + end + end +end + + +--获取功能开启提醒方式 +function XFunctionManager.ShowOpenHint() + if not CanOpenId or #CanOpenId <= 0 then + return false + end + + for i = 1, #CanOpenId do + if XFunctionConfig.GetOpenHint(CanOpenId[i]) == 1 then + XLuaUiManager.Open("UiHintFunctional", CanOpenId) + CanOpenId = {} + return true + end + end + + return false +end + +--活动跳转相关 begin +function XFunctionManager.CheckSkipActivityOpen() + local template = XFunctionConfig.GetMainActSkipCfg(1) + local stageType = template.StageType + local stageTypes = XDataCenter.FubenManager.StageType + + if stageType == stageTypes.Mainline then + return XDataCenter.FubenMainLineManager.IsMainLineActivityOpen() + elseif stageType == stageTypes.ActivtityBranch then + return XDataCenter.FubenActivityBranchManager.IsOpen() + elseif stageType == stageTypes.ActivityBossSingle then + return XDataCenter.FubenActivityBossSingleManager.IsOpen() + end + + return false +end + +function XFunctionManager.SkipToActivity() + if not XFunctionManager.CheckSkipActivityOpen() then + return + end + + local skipId = XFunctionConfig.GetMainActSkipCfg(1).SkipId + if not skipId then + return + end + + XFunctionManager.SkipInterface(skipId) +end + +--活动跳转相关 end +--功能时间相关 begin +local function GetTimeData(timeId) + return FunctionTimeData[timeId] +end + +function XFunctionManager.IsEffectiveTimeId(timeId) + if not timeId then + return false + end + if FunctionTimeData[timeId] then + return true + else + return false + end +end + +function XFunctionManager.CheckInTimeByTimeId(timeId, defaultOpen) + --未配置timeId默认未开启 + if not XTool.IsNumberValid(timeId) then + return defaultOpen and true or false + end + + --timeId配置错误默认未开启 + local timeData = GetTimeData(timeId) + if not timeData then + return defaultOpen and true or false + end + + --startTime未配置默认无开启时间限制 + --endTime未配置默认无结束时间限制 + return timeData:IsInTime() +end + +function XFunctionManager.GetStartTimeByTimeId(timeId) + if not timeId then return end + local timeData = GetTimeData(timeId) + return timeData and timeData:GetStartTime() or 0 +end + +function XFunctionManager.GetEndTimeByTimeId(timeId) + if not timeId then return 0 end + local timeData = GetTimeData(timeId) + return timeData and timeData:GetEndTime() or 0 +end + +function XFunctionManager.GetTimeByTimeId(timeId) + return XFunctionManager.GetStartTimeByTimeId(timeId), XFunctionManager.GetEndTimeByTimeId(timeId) +end + +function XFunctionManager.IsDuringTime(functionId) + local timeId = XFunctionConfig.GetFuncOpenCfg(functionId) and XFunctionConfig.GetFuncOpenCfg(functionId).TimeId + --未配置timeId默认开启(功能开启特殊处理) + if not timeId or timeId == 0 then return true end + return XFunctionManager.CheckInTimeByTimeId(timeId) +end + +function XFunctionManager.BindTimeId(timeId) + if not timeId then return end + local timeData = GetTimeData(timeId) + if timeData then + timeData:CreateTimer() + end +end + +--AFDeepLink特定需求 +function XFunctionManager.IsAFDeepLinkCanSkipByShowTips(skipId) + local list = XFunctionManager.GetSkipList(skipId) + if not list then + return false + end + local isCanSkip = XFunctionManager.DetectionFunction(list.FunctionalId) + if isCanSkip and not XFunctionManager.CheckSkipInDuration(skipId) then + XUiManager.TipError(CS.XTextManager.GetText("AFDeepLinkNotTime")) + return false + end + return isCanSkip +end + +local function UpdateFunctionTimeData(dataList) + if not dataList then return end + for _, data in pairs(dataList) do + local timeId = data.Id + + local timeData = FunctionTimeData[timeId] + if not timeData then + timeData = XFunctionTime.New(timeId) + FunctionTimeData[timeId] = timeData + end + + timeData:UpdateData(data) + end +end + +function XFunctionManager.InitFuncOpenTime(data) + UpdateFunctionTimeData(data) +end + +XRpc.NotifyTimeLimitCtrlConfigList = function(data) + UpdateFunctionTimeData(data.TimeLimitCtrlConfigList) + XEventManager.DispatchEvent(XEventId.EVENT_ETCD_TIME_CHANGE) +end + +--功能时间相关 end +XRpc.NotifyClientShieldFunction = function(data) + XFunctionManager.InitShieldFuncData(data.ShieldFunctionIds, true) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XFunctionalSkipManager.lua b/Resources/Scripts/XManager/XFunctionalSkipManager.lua new file mode 100644 index 00000000..fbf73173 --- /dev/null +++ b/Resources/Scripts/XManager/XFunctionalSkipManager.lua @@ -0,0 +1,1000 @@ +XFunctionalSkipManagerCreator = function() + local XFunctionalSkipManager = {} + local DormDrawGroudId = CS.XGame.ClientConfig:GetInt("DormDrawGroudId") + + -- 跳转打开界面选择标签页类型6 + function XFunctionalSkipManager.SkipSystemWidthArgs(skipDatas) + if not skipDatas then return end + local param1 = (skipDatas.CustomParams[1] ~= 0) and skipDatas.CustomParams[1] or nil + local param2 = (skipDatas.CustomParams[2] ~= 0) and skipDatas.CustomParams[2] or nil + local param3 = (skipDatas.CustomParams[3] ~= 0) and skipDatas.CustomParams[3] or nil + + if skipDatas.UiName == "UiTask" and XLuaUiManager.IsUiShow("UiTask") then + XEventManager.DispatchEvent(XEventId.EVENT_TASK_TAB_CHANGE, param1) + elseif skipDatas.UiName == "UiActivityBriefBase" and XLuaUiManager.IsUiShow("UiActivityBriefBase") then + XEventManager.DispatchEvent(XEventId.EVENT_BRIEF_CHANGE_TAB, param1) + elseif skipDatas.UiName == "UiPuzzleActivity" then + XDataCenter.FubenActivityPuzzleManager.OpenPuzzleGame(param1) + else + XLuaUiManager.Open(skipDatas.UiName, param1, param2, param3) + end + end + + -- 跳转副本类型7 + function XFunctionalSkipManager.SkipCustom(skipDatas) + if not skipDatas then return end + + if XFunctionalSkipManager[skipDatas.UiName] then + XFunctionalSkipManager[skipDatas.UiName](skipDatas) + end + end + + -- 跳转宿舍类型8 + function XFunctionalSkipManager.SkipDormitory(skipDatas) + if not skipDatas or not XPlayer.Id then return end + + if XFunctionalSkipManager[skipDatas.UiName] then + XFunctionalSkipManager[skipDatas.UiName](skipDatas) + end + end + + -- 前往宿舍房间 + function XFunctionalSkipManager.SkipDormRoom(list) + local param1 = (list.CustomParams[1] ~= 0) and list.CustomParams[1] or nil + -- 该房间未激活 + if (param1 == nil) or (not XDataCenter.DormManager.IsDormitoryActive(param1)) then + if not XHomeDormManager.InDormScene() then + XHomeDormManager.EnterDorm(XPlayer.Id, nil, false) + end + return + end + + -- 房间已激活 + if XHomeDormManager.InDormScene() then + if XLuaUiManager.IsUiShow("UiDormTask") then + XLuaUiManager.Close("UiDormTask") + end + + if not XHomeDormManager.IsInRoom(param1) then + + if not XLuaUiManager.IsUiShow("UiDormSecond") then + XLuaUiManager.Open("UiDormSecond", XDormConfig.VisitDisplaySetType.MySelf, param1) + else + XEventManager.DispatchEvent(XEventId.EVENT_DORM_SKIP, param1) + end + + XHomeDormManager.SetSelectedRoom(param1, true) + end + else + XHomeDormManager.EnterDorm(XPlayer.Id, nil, false, function() + + if not XLuaUiManager.IsUiShow("UiDormSecond") then + XLuaUiManager.Open("UiDormSecond", XDormConfig.VisitDisplaySetType.MySelf, param1) + else + XEventManager.DispatchEvent(XEventId.EVENT_DORM_SKIP, param1) + end + + XHomeDormManager.SetSelectedRoom(param1, true) + + end) + end + end + + -- 前往宿舍主界面 + function XFunctionalSkipManager.SkipDormMain() + + if XLuaUiManager.IsUiLoad("UiDormTask") then + XLuaUiManager.Remove("UiDormTask") + end + + if not XHomeDormManager.InDormScene() then + XHomeDormManager.EnterDorm(XPlayer.Id, nil, false) + elseif XHomeDormManager.InAnyRoom() then + local roomId = XHomeDormManager.GetCurrentRoomId() + if roomId then + XHomeDormManager.SetSelectedRoom(roomId, false) + + if XLuaUiManager.IsUiLoad("UiDormSecond") then + XLuaUiManager.Remove("UiDormSecond") + end + + end + end + XLuaUiManager:ShowTopUi() + end + + -- 前往宿舍访问 + function XFunctionalSkipManager.SkipDormVisit(list) + local param1 = (list.CustomParams[1] ~= 0) and list.CustomParams[1] or 1 + if XHomeDormManager.InDormScene() then + XLuaUiManager.Open("UiDormVisit", nil, param1) + else + XHomeDormManager.EnterDorm(XPlayer.Id, nil, false, function() + XLuaUiManager.Open("UiDormVisit", nil, param1) + end) + end + end + + -- 前往宿舍任务 + function XFunctionalSkipManager.SkipDormTask(list) + local param1 = (list.CustomParams[1] ~= 0) and list.CustomParams[1] or 1 + if XHomeDormManager.InDormScene() then + XLuaUiManager.Open("UiDormTask", param1) + else + XHomeDormManager.EnterDorm(XPlayer.Id, nil, false, function() + XLuaUiManager.Open("UiDormTask", param1) + end) + end + end + + -- 前往宿舍仓库界面 + function XFunctionalSkipManager.SkipDormWarehouse(list) + local param1 = (list.CustomParams[1] ~= 0) and list.CustomParams[1] or 1 + if XHomeDormManager.InDormScene() then + XLuaUiManager.Open("UiDormBag", param1) + else + XHomeDormManager.EnterDorm(XPlayer.Id, nil, false, function() + XLuaUiManager.Open("UiDormBag", param1) + end) + end + end + + -- 前往宿舍成员界面 + function XFunctionalSkipManager.SkipDormMember() + if XHomeDormManager.InDormScene() then + XLuaUiManager.Open("UiDormPerson") + else + XHomeDormManager.EnterDorm(XPlayer.Id, nil, false, function() + XLuaUiManager.Open("UiDormPerson") + end) + end + end + + -- 前往宿舍打工界面 + function XFunctionalSkipManager.SkipDormWork() + if XHomeDormManager.InDormScene() then + if not XLuaUiManager.IsUiShow("UiDormWork") then + XLuaUiManager.Open("UiDormWork") + else + XEventManager.DispatchEvent(XEventId.EVENT_DORM_SKIP) + end + else + XHomeDormManager.EnterDorm(XPlayer.Id, nil, false, function() + XLuaUiManager.Open("UiDormWork") + end) + end + end + + -- 前往宿舍商店界面 + function XFunctionalSkipManager.SkipDormShop(list) + local param1 = (list.CustomParams[1] ~= 0) and list.CustomParams[1] + if XHomeDormManager.InDormScene() then + if XLuaUiManager.IsUiShow("UiShop") then return end + XLuaUiManager.Open("UiShop", XShopManager.ShopType.Dorm, nil, param1) + else + XHomeDormManager.EnterDorm(XPlayer.Id, nil, false, function() + if XLuaUiManager.IsUiShow("UiShop") then return end + XLuaUiManager.Open("UiShop", XShopManager.ShopType.Dorm, nil, param1) + end) + end + end + + -- 前往宿舍研发界面 + function XFunctionalSkipManager.SkipDormDraw() + if XHomeDormManager.InDormScene() then + XDataCenter.DrawManager.GetDrawGroupList( + function() + local info = XDataCenter.DrawManager.GetDrawGroupInfoByGroupId(DormDrawGroudId) + if not info then return end + XDataCenter.DrawManager.GetDrawInfoList(DormDrawGroudId, function() + XLuaUiManager.Open("UiDraw", DormDrawGroudId, function() + XHomeSceneManager.ResetToCurrentGlobalIllumination() + end, info.UiBackGround) + end) + end + ) + else + XHomeDormManager.EnterDorm(XPlayer.Id, nil, false, function() + XDataCenter.DrawManager.GetDrawGroupList( + function() + local info = XDataCenter.DrawManager.GetDrawGroupInfoByGroupId(DormDrawGroudId) + if not info then return end + XDataCenter.DrawManager.GetDrawInfoList(DormDrawGroudId, function() + XLuaUiManager.Open("UiDraw", DormDrawGroudId, function() + XHomeSceneManager.ResetToCurrentGlobalIllumination() + end, info.UiBackGround) + end) + end + ) + end) + end + end + + -- 前往宿舍建造界面 + function XFunctionalSkipManager.SkipDormFurnitureBuild(list) + local param1 = (list.CustomParams[1] ~= 0) and list.CustomParams[1] or 1 + if XHomeDormManager.InDormScene() then + XLuaUiManager.Open("UiFurnitureBuild", param1) + else + XHomeDormManager.EnterDorm(XPlayer.Id, nil, false, function() + XLuaUiManager.Open("UiFurnitureBuild", param1) + end) + end + end + + -- 前往巴别塔 + function XFunctionalSkipManager.OnOpenBabelTower() + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.BabelTower) then + return + end + + local currentActivityNo = XDataCenter.FubenBabelTowerManager.GetCurrentActivityNo() + if not currentActivityNo or not XDataCenter.FubenBabelTowerManager.IsInActivityTime(currentActivityNo) then + XUiManager.TipMsg(CS.XTextManager.GetText("RougeLikeNotInActivityTime")) + return + end + + XDataCenter.FubenBabelTowerManager.OpenBabelTowerCheckStory() + end + + -- 前往新角色教学活动 + function XFunctionalSkipManager.OnOpenNewCharActivity(list) + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.NewCharAct) then + return + end + + local actId = (list.CustomParams[1] ~= 0) and list.CustomParams[1] or 1 + -- 活动时间限制 + if not XDataCenter.FubenNewCharActivityManager.IsOpen(actId) then + XUiManager.TipText("RougeLikeNotInActivityTime") + return + end + + local newCharType = XFubenNewCharConfig.GetNewCharType(actId) + local uiName + if newCharType == XFubenNewCharConfig.NewCharType.YinMianZheGuang then + uiName = "UiNewCharActivity" + elseif newCharType == XFubenNewCharConfig.NewCharType.KoroChar then + uiName = "UiFunbenKoroTutorial" + elseif newCharType == XFubenNewCharConfig.NewCharType.WeiLa then + uiName = "UiFunbenWeiLaTutorial" + end + + XLuaUiManager.Open(uiName, actId) + end + + -- 前往赏金任务 + function XFunctionalSkipManager.OnOpenUiMoneyReward() + if XDataCenter.MaintainerActionManager.IsStart() then + XUiManager.TipText("MaintainerActionEventOver") + XDataCenter.FunctionalSkipManager.OnOpenMaintainerAction() + else + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.BountyTask) then + return + end + XDataCenter.BountyTaskManager.SetBountyTaskLastRefreshTime() + XLuaUiManager.Open("UiMoneyReward") + end + + end + + -- 前往协同作战 + function XFunctionalSkipManager.OnOpenUiOnlineBoss(list) + local param1 = (list.CustomParams[1] ~= 0) and list.CustomParams[1] or 1 + --开启时间限制 + if not XDataCenter.FubenBossOnlineManager.CheckNormalBossOnlineInTime() then + local tipText = XDataCenter.FubenBossOnlineManager.GetNotInTimeTip() + XUiManager.TipError(tipText) + return + end + XDataCenter.FubenBossOnlineManager.OpenBossOnlineUi(param1) + end + + -- 前往活动协同作战 + function XFunctionalSkipManager.OnOpenUiOnlineBossActivity(list) + local functionId = XFunctionManager.FunctionName.FubenActivityOnlineBoss + local isOpen = XFunctionManager.JudgeCanOpen(functionId) and XDataCenter.FubenBossOnlineManager.GetIsActivity() + + if not isOpen then + XUiManager.TipText("ActivityBossOnlineOver") + return + end + + local param1 = (list.CustomParams[1] ~= 0) and list.CustomParams[1] or 1 + XDataCenter.FubenBossOnlineManager.OpenBossOnlineUi(param1) + end + + + -- 前往特训关 + function XFunctionalSkipManager.OnOpenUiSpecialTrainActivity(list) + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.SpecialTrain) then + return + end + + if XLuaUiManager.IsUiShow("UiSummerTaskReward") then + return + end + + local param1 = (list.CustomParams[1] ~= 0) and list.CustomParams[1] or 1 + local param2 = (list.CustomParams[2] ~= 0) and list.CustomParams[2] or 1 + local param3 = (list.CustomParams[3] ~= 0) and list.CustomParams[3] or 0 + + if XDataCenter.FubenSpecialTrainManager.CheckActivityTimeout(param1, true) then + return + end + + XLuaUiManager.Open("UiSummerEpisodeNew", param1, param2, param3) + end + + -- 被感染的守林人 + function XFunctionalSkipManager.OnOpenUiActivityBranch(list) + + -- 开启时间限制 + if not XDataCenter.FubenActivityBranchManager.IsOpen() then + XUiManager.TipText("ActivityBranchNotOpen") + return + end + + local param1 = (list.CustomParams[1] ~= 0) and list.CustomParams[1] or 1 + local param2 = (list.CustomParams[2] ~= 0) and list.CustomParams[2] or nil + + if param1 == XDataCenter.FubenActivityBranchManager.BranchType.Difficult then + if not XDataCenter.FubenActivityBranchManager.IsStatusEqualChallengeBegin() then + XUiManager.TipText("ActivityBranchNotOpen") + return + end + end + + if XFunctionalSkipManager.IsStageLock(param2) then return end + + local sectionId = XDataCenter.FubenActivityBranchManager.GetCurSectionId() + XLuaUiManager.Open("UiActivityBranch", sectionId, param1, param2) + end + + -- 前往格式塔 + function XFunctionalSkipManager.OnOpenUiActivityBossSingle(list) + + local param1 = (list.CustomParams[1] ~= 0) and list.CustomParams[1] or nil + local sectionId = XDataCenter.FubenActivityBossSingleManager.GetCurSectionId() or 1 + -- 活动时间限制 + if not XDataCenter.FubenActivityBossSingleManager.IsOpen() then + XUiManager.TipText("RougeLikeNotInActivityTime") + return + end + + if (not param1) or (not XDataCenter.FubenActivityBossSingleManager.IsChallengeUnlock(param1)) then + XLuaUiManager.Open("UiActivityBossSingle", sectionId) + else + XLuaUiManager.Open("UiActivityBossSingleDetail", param1) + end + end + + -- 前往纷争战区 + function XFunctionalSkipManager.OnOpenUiArena() + local arenaChapters = XFubenConfigs.GetChapterBannerByType(XDataCenter.FubenManager.ChapterType.ARENA) + XDataCenter.ArenaManager.RequestSignUpArena(function() + XLuaUiManager.Open("UiArena", arenaChapters) + end) + end + + -- 前往幻痛囚笼 + function XFunctionalSkipManager.OnOpenUiFubenBossSingle() + if XDataCenter.FubenBossSingleManager.CheckNeedChooseLevelType() then + XLuaUiManager.Open("UiFubenBossSingleChooseLevelType") + return + end + + XDataCenter.FubenBossSingleManager.OpenBossSingleView() + end + + -- 前往资源副本 + function XFunctionalSkipManager.OnOpenUiFubenDaily(list) + local param1 = (list.CustomParams[1] ~= 0) and list.CustomParams[1] + local param2 = (list.CustomParams[2] ~= 0) and list.CustomParams[2] + if param1 == nil or param1 == 0 then + XLuaUiManager.Open("UiFuben", XDataCenter.FubenManager.StageType.Resource) + return + end + + XLuaUiManager.OpenWithCallback("UiFubenDaily", function() + CsXGameEventManager.Instance:Notify(XEventId.EVENT_FUBEN_RESOURCE_AUTOSELECT, param2) + end, XDailyDungeonConfigs.GetDailyDungeonRulesById(param1)) + end + + -- 前往前传 + function XFunctionalSkipManager.OnOpenUiPrequel(list) + local param1 = (list.CustomParams[1] ~= 0) and list.CustomParams[1] + local param2 = (list.CustomParams[2] ~= 0) and list.CustomParams[2] + local covers = XDataCenter.PrequelManager.GetListCovers() + if covers then + local index = 0 + for k, v in pairs(covers) do + if v.CoverId == param1 then + index = k + break + end + end + if covers[index] then + if covers[index].IsAllChapterLock and (not covers[index].IsActivity) then + XUiManager.TipMsg(XDataCenter.PrequelManager.GetChapterUnlockDescription(covers[index].ShowChapter)) + return + end + XLuaUiManager.Open("UiPrequel", covers[index], nil, param2) + end + end + -- XLuaUiManager.OpenWithCallback("UiFuben", function() + -- CsXGameEventManager.Instance:Notify(XEventId.EVENT_FUBEN_PREQUEL_AUTOSELECT, param1, param2) + -- end, 1) + end + -- 是否能前往前传 + function XFunctionalSkipManager.IsCanOpenUiPrequel(list) + local param1 = (list.CustomParams[1] ~= 0) and list.CustomParams[1] + local param2 = (list.CustomParams[2] ~= 0) and list.CustomParams[2] + local covers = XDataCenter.PrequelManager.GetListCovers() + if covers then + local index = 0 + for k, v in pairs(covers) do + if v.CoverId == param1 then + index = k + break + end + end + if covers[index] then + if covers[index].IsAllChapterLock and (not covers[index].IsActivity) then + return false + end + return true + end + end + return false + end + + -- 前往剧情简章主界面-- 前往据点战主界面 + function XFunctionalSkipManager.OnOpenMainlineSubtab(list) + local param1 = (list.CustomParams[1] ~= 0) and list.CustomParams[1] or 1 + XLuaUiManager.Open("UiFuben", 1, nil, param1) + end + + -- 前往隐藏关卡主界面 + function XFunctionalSkipManager.OnOpenMainlineWithDifficuty() + XLuaUiManager.OpenWithCallback("UiFuben", function() + CsXGameEventManager.Instance:Notify(XEventId.EVENT_FUBEN_MAINLINE_DIFFICUTY_SELECT) + end, 1) + end + + -- 前往展示厅,有参数时打开某个角色 + function XFunctionalSkipManager.OnOpenExhibition(list) + local param1 = (list.CustomParams[1] ~= 0) and list.CustomParams[1] or nil + XLuaUiManager.OpenWithCallback("UiExhibition", function() + CsXGameEventManager.Instance:Notify(XEventId.EVENT_CHARACTER_EXHIBITION_AUTOSELECT, param1) + end, true, list.CustomParams[2]) + end + + -- 前往具体的抽卡 + function XFunctionalSkipManager.OnOpenDrawDetail(list) + local param1 = (list.CustomParams[1] ~= 0) and list.CustomParams[1] or nil + XDataCenter.DrawManager.GetDrawGroupList(function() + local drawGroupInfos = XDataCenter.DrawManager.GetDrawGroupInfos() + for _, info in pairs(drawGroupInfos or {}) do + if param1 and info.Id == param1 then + XDataCenter.DrawManager.GetDrawInfoList(info.Id, function() + XLuaUiManager.Open(info.UiPrefab, info.Id, nil, info.UiBackGround) + end) + break + end + end + end) + end + + -- 跳转节日活动 + function XFunctionalSkipManager.OnOpenFestivalActivity(list) + local param1 = (list.CustomParams[1] ~= 0) and list.CustomParams[1] or nil + local param2 = (list.CustomParams[2] ~= 0) and list.CustomParams[2] or nil + if not XDataCenter.FubenFestivalActivityManager.IsFestivalInActivity(param1) then + XUiManager.TipText("FestivalActivityNotInActivityTime") + return + end + + if param2 then + if XFunctionalSkipManager.IsStageLock(param2) then return end + XLuaUiManager.Open("UiFubenChristmasMainLineChapter", param1, param2) + else + XLuaUiManager.Open("UiFubenChristmasMainLineChapter", param1) + end + end + + -- 复刷本 + function XFunctionalSkipManager.OnOpenRepeatChallengeActivity(list) + local param = (list.CustomParams[1] ~= 0) and list.CustomParams[1] or nil + if not XDataCenter.FubenRepeatChallengeManager.IsOpen() then + XUiManager.TipMsg(CS.XTextManager.GetText("FubenRepeatNotInActivityTime")) + return + end + + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.RepeatChallenge) then + return + end + + XLuaUiManager.Open("UiFubenRepeatchallenge", param) + end + + -- 爬塔活动 + function XFunctionalSkipManager.OnOpenRogueLikeActivity() + local activityId = XDataCenter.FubenRogueLikeManager.GetRogueLikeActivityId() + if activityId == nil or activityId <= 0 then + XUiManager.TipMsg(CS.XTextManager.GetText("RougeLikeNotInActivityTime")) + return + end + local activityConfig = XFubenRogueLikeConfig.GetRogueLikeConfigById(activityId) + + if not activityConfig then + return + end + if not XDataCenter.FubenRogueLikeManager.IsInActivity() then + XUiManager.TipMsg(CS.XTextManager.GetText("RougeLikeNotInActivityTime")) + return + end + + if activityConfig.FunctionalOpenId > 0 and (not XFunctionManager.DetectionFunction(activityConfig.FunctionalOpenId)) then + return + end + + XDataCenter.FubenRogueLikeManager.OpenRogueLikeCheckStory() + end + + -- 打开主线、隐藏线、据点战 + function XFunctionalSkipManager.OnOpenMainLineStage(list) + local stageId = (list.CustomParams[1] ~= 0) and list.CustomParams[1] or nil + local param2 = (list.CustomParams[2] ~= 0) and list.CustomParams[2] or nil + local openStageDetail = param2 == 1 + if not stageId then return end + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + if stageInfo.Difficult == XDataCenter.FubenManager.DifficultHard and (not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.FubenDifficulty)) then + local openTips = XFunctionManager.GetFunctionOpenCondition(XFunctionManager.FunctionName.FubenDifficulty) + XUiManager.TipMsg(openTips) + return + end + + if stageInfo.Type == XDataCenter.FubenManager.StageType.Bfrt then + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.FubenNightmare) then + return + end + end + + if XFunctionalSkipManager.IsStageLock(stageId) then return end + + local chapter = XDataCenter.FubenMainLineManager.GetChapterCfg(stageInfo.ChapterId) + if not XDataCenter.FubenMainLineManager.CheckChapterCanGoTo(chapter.ChapterId) then + XUiManager.TipMsg(CS.XTextManager.GetText("FubenMainLineNoneOpen")) + return + end + if openStageDetail then + CsXUiManager.Instance:Open("UiFubenMainLineChapter", chapter, stageId) + else + CsXUiManager.Instance:Open("UiFubenMainLineChapter", chapter) + end + end + + -- 狙击战跳转 + function XFunctionalSkipManager.OnOpenUnionKill() + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.FubenUnionKill) then + return + end + local unionInfo = XDataCenter.FubenUnionKillManager.GetUnionKillInfo() + if not unionInfo or not unionInfo.Id or unionInfo.Id <= 0 then + XUiManager.TipMsg(CS.XTextManager.GetText("UnionKillMainNotInActivity")) + return + end + + if not XFubenUnionKillConfigs.UnionKillInActivity(unionInfo.Id) then + XUiManager.TipMsg(CS.XTextManager.GetText("UnionKillMainNotInActivity")) + return + end + + XLuaUiManager.Open("UiUnionKillMain") + end + + -- 公会 + function XFunctionalSkipManager.OnOpenGuild() + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.Guild) then + return + end + + XDataCenter.GuildManager.EnterGuild() + end + + -- 跳转巴别塔勋章 + function XFunctionalSkipManager.OnOpenMedal(list) + local param1 = (list.CustomParams[1] ~= 0) and list.CustomParams[1] or nil + local selectIndex = 4 + XLuaUiManager.Open("UiPlayer", nil, selectIndex, nil, param1) + end + + -- 跳转图鉴 + function XFunctionalSkipManager.OnOpenArchive(list) + local param1 = (list.CustomParams[1] ~= 0) and list.CustomParams[1] or nil + if param1 == XArchiveConfigs.SubSystemType.Monster then + XLuaUiManager.Open("UiArchiveMonster") + elseif param1 == XArchiveConfigs.SubSystemType.Weapon then + XLuaUiManager.Open("UiArchiveWeapon") + elseif param1 == XArchiveConfigs.SubSystemType.Awareness then + XLuaUiManager.Open("UiArchiveAwareness") + elseif param1 == XArchiveConfigs.SubSystemType.Story then + XLuaUiManager.Open("UiArchiveStory") + elseif param1 == XArchiveConfigs.SubSystemType.CG then + XLuaUiManager.Open("UiArchiveCG") + elseif param1 == XArchiveConfigs.SubSystemType.NPC then + XLuaUiManager.Open("UiArchiveNpc") + elseif param1 == XArchiveConfigs.SubSystemType.Email then + XLuaUiManager.Open("UiArchiveEmail") + elseif param1 == XArchiveConfigs.SubSystemType.Partner then + XLuaUiManager.Open("UiArchivePartner") + end + end + + -- 跳转gacha + function XFunctionalSkipManager.OnOpenGacha(list) + local gachaId = (list.CustomParams[1] ~= 0) and list.CustomParams[1] or nil + local IsOpen = gachaId and XDataCenter.GachaManager.CheckGachaIsOpenById(gachaId, true) or false + if not IsOpen then + return + end + XDataCenter.GachaManager.GetGachaRewardInfoRequest(gachaId, function() + local gachaRule = XGachaConfigs.GetGachaRuleCfgById(gachaId) + XLuaUiManager.Open(gachaRule.UiName, gachaId) + end) + end + + -- 跳转gacha组 + function XFunctionalSkipManager.OnOpenGachaOrganize(list) + local organizeId = (list.CustomParams[1] ~= 0) and list.CustomParams[1] or nil + local IsOpen = organizeId and XDataCenter.GachaManager.CheckGachaOrganizeIsOpen(organizeId, true) or false + if not IsOpen then + return + end + + XDataCenter.GachaManager.GetGachaOrganizeInfoRequest(organizeId, function(gachaId) + local organizeRule = XGachaConfigs.GetOrganizeRuleCfg(organizeId) + if not organizeRule then + return + end + -- 'gachaId'为卡池组里最新解锁的卡池Id,由服务器下发,打开界面时默认选中 + XLuaUiManager.Open(organizeRule.UiName, organizeId, gachaId, organizeRule) + end) + end + + -- 跳转活动材料商店 + function XFunctionalSkipManager.OnOpenActivityBriefShop(list) + + local isOpen, desc = XActivityBrieIsOpen.Get(XActivityBriefConfigs.ActivityGroupId.ActivityBriefShop) + if isOpen then + XLuaUiManager.Open("UiActivityBriefShop", nil, nil) + else + XUiManager.TipMsg(desc) + end + end + + -- 跳转世界Boss + function XFunctionalSkipManager.OnOpenWorldBoss() + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.WorldBoss) then + return + end + if not XDataCenter.WorldBossManager.IsInActivity() then + XUiManager.TipMsg(CS.XTextManager.GetText("WorldBossNotInActivityTime")) + return + end + XDataCenter.WorldBossManager.OpenWorldMainWind() + end + + -- 跳转大富翁 + function XFunctionalSkipManager.OnOpenMaintainerAction() + local ret, msg = XDataCenter.MaintainerActionManager.CheckIsOpen() + if not ret then + XUiManager.TipMsg(msg) + return + end + + XDataCenter.MaintainerActionManager.OpenMaintainerActionWind() + end + + -- 跳转师徒系统 + function XFunctionalSkipManager.OnOpenMentorSystem() + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.MentorSystem) then + return + end + XLuaUiManager.Open("UiMentorMain") + end + + -- 区域联机 + function XFunctionalSkipManager.OnOpenAreanOnlineChapter() + XDataCenter.ArenaOnlineManager.SetCurChapterId() + XLuaUiManager.Open("UiArenaOnlineChapter") + end + + -- 检查stageId是否开启 + function XFunctionalSkipManager.IsStageLock(stageId) + if not stageId then return false end + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + if not stageInfo then + return false + end + if not stageInfo.Unlock then + XUiManager.TipMsg(XDataCenter.FubenManager.GetFubenOpenTips(stageId)) + return true + end + return false + end + -- 跳转到番外关卡 + function XFunctionalSkipManager.ExtraChapter(jumpData) + if not jumpData then return end + if XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.Extra) then + local extraManager = XDataCenter.ExtraChapterManager + if not jumpData.CustomParams then extraManager.JumpToExtraBanner() end + local chapterId = jumpData.CustomParams[1] + if chapterId then extraManager.JumpToExtraStage(chapterId, jumpData.CustomParams[2]) + else extraManager.JumpToExtraBanner() end + end + end + + function XFunctionalSkipManager.FubenInfesotorExplore() + if XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.FubenInfesotorExplore) then + if XDataCenter.FubenInfestorExploreManager.IsInSectionOne() + or XDataCenter.FubenInfestorExploreManager.IsInSectionTwo() then + local openCb = function() + XLuaUiManager.Open("UiInfestorExploreRank") + end + XDataCenter.FubenInfestorExploreManager.OpenEntranceUi(openCb) + elseif XDataCenter.FubenInfestorExploreManager.IsInSectionEnd() then + XUiManager.TipText("InfestorExploreEnterSectionEnd") + end + end + end + + --跳转到尼尔彩蛋界面 + function XFunctionalSkipManager.OnNieREasterEgg() + XDataCenter.NieRManager.OpenNieRDataSaveUi() + end + + --跳转到尼尔复刷界面 + function XFunctionalSkipManager.OnUiFubenNierRepeat(jumpData) + XLuaUiManager.Open("UiFubenNierRepeat", jumpData.ParamId) + end + + --跳转到尼尔任务界面 + function XFunctionalSkipManager.OnUiFubenNierTask(jumpData) + XLuaUiManager.Open("UiNierTask", jumpData.ParamId) + end + + --跳转到尼尔主界面 + function XFunctionalSkipManager.OnUiFubenNierEnter() + if XDataCenter.NieRManager.GetIsActivityEnd() then + XUiManager.TipText("NieREnd") + else + XLuaUiManager.Open("UiFubenNierEnter") + end + end + + function XFunctionalSkipManager.Expedition() + XDataCenter.ExpeditionManager.JumpToExpedition() + end + + function XFunctionalSkipManager.RpgTower() + XDataCenter.RpgTowerManager.JumpTo() + end + + function XFunctionalSkipManager.SuperTowerJumpTo() + XDataCenter.SuperTowerManager.JumpTo() + end + + function XFunctionalSkipManager.SkipTRPGMain() + XDataCenter.TRPGManager.SkipTRPGMain() + end + + --跳转到口袋战双主界面 + function XFunctionalSkipManager.SkipToPokemonMainUi() + XDataCenter.PokemonManager.OpenPokemonMainUi() + end + + --跳转到追击玩法主界面 + function XFunctionalSkipManager.SkipToPursuit() + if XChessPursuitConfig.GetChessPursuitInTimeMapGroup() then + XLuaUiManager.Open("UiChessPursuitMain") + else + XUiManager.TipText("ChessPursuitNotInTime") + end + end + + function XFunctionalSkipManager.SkipToSpringFestivalActivity() + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.SpringFestivalActivity) then + return + end + XDataCenter.SpringFestivalActivityManager.OpenActivityMain() + end + + function XFunctionalSkipManager.SkipToSpringFestivalActivityWithClose() + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.SpringFestivalActivity) then + return + end + XDataCenter.SpringFestivalActivityManager.OpenMainWithClose() + end + + function XFunctionalSkipManager.SkipToSpringFestivalSmashEggs() + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.SpringFestivalActivity) then + return + end + if XDataCenter.SpringFestivalActivityManager.IsOpen() then + XLuaUiManager.PopThenOpen("UiSpringFestivalSmashEggs") + end + end + + function XFunctionalSkipManager.SkipToSpringFestivalCollectWord() + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.SpringFestivalActivity) then + return + end + if XDataCenter.SpringFestivalActivityManager.IsOpen() then + XLuaUiManager.PopThenOpen("UiSpringFestivalCollectCard") + end + end + + --跳转至2021端午活动主界面 + function XFunctionalSkipManager.SkipToRpgMakerGameMain() + XDataCenter.RpgMakerGameManager.RequestRpgMakerGameEnter() + end + + --================ + --跳转到组合小游戏 + --================ + function XFunctionalSkipManager.JumpToComposeGame(skipDatas) + XDataCenter.ComposeGameManager.JumpTo(skipDatas.CustomParams[1]) + end + + --超级据点主界面 + function XFunctionalSkipManager.SkipToStrongholdMain() + XDataCenter.StrongholdManager.EnterUiMain() + end + + --================ + --跳转到白色情人节约会小游戏 + --================ + function XFunctionalSkipManager.JumpToWhiteValentineGame() + XDataCenter.WhiteValentineManager.JumpTo() + end + + -- 跳转到涂装返场商店 + function XFunctionalSkipManager.SkipToSpecialShop(skipData) + XShopManager.GetShopInfo(skipData.ParamId, function() + XLuaUiManager.Open("UiSpecialFashionShop", skipData.ParamId) + end) + end + --================ + --跳转到猜拳小游戏 + --================ + function XFunctionalSkipManager.JumpToFingerGuessing() + XDataCenter.FingerGuessingManager.JumpTo() + end + -- 跳转模拟作战 + function XFunctionalSkipManager.SkipToSimulatedCombat(list) + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.FubenSimulatedCombat) then + return + end + + local mode, childUiType = list.CustomParams[1], list.CustomParams[2] + local isOpen, desc = XDataCenter.FubenSimulatedCombatManager.CheckModeOpen(mode) + if not isOpen then + XUiManager.TipMsg(desc) + return + end + + XLuaUiManager.Remove("UiSimulatedCombatMain") + XLuaUiManager.Open("UiSimulatedCombatMain", mode, childUiType) + end + + function XFunctionalSkipManager.SkipToMoeWar() + XDataCenter.MoeWarManager.OnOpenMain() + end + + function XFunctionalSkipManager.SkipToFubenHack(list) + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.FubenHack) then + return + end + local isEnd, isNotOpen = XDataCenter.FubenHackManager.GetIsActivityEnd() + if isNotOpen then + XUiManager.TipText("CommonActivityNotStart") + elseif isEnd then + XUiManager.TipText("ActivityMainLineEnd") + else + XLuaUiManager.Open("UiFubenHack") + end + end + + function XFunctionalSkipManager.SkipToMineSweeping() + XDataCenter.MineSweepingManager.OpenMineSweeping() + end + + function XFunctionalSkipManager.SkipToFubenCoupleCombat(list) + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.FubenCoupleCombat) then + return + end + + if XDataCenter.FubenCoupleCombatManager.GetIsActivityEnd() then + XUiManager.TipText("ActivityMainLineEnd") + end + + local mode = list.CustomParams[1] + local isOpen, desc = XDataCenter.FubenCoupleCombatManager.CheckModeOpen(mode) + if not isOpen then + XUiManager.TipMsg(desc) + return + end + XLuaUiManager.Open("UiCoupleCombatMain", mode) + end + + function XFunctionalSkipManager.SkipToMovieAssemble(skipDatas) + XLuaUiManager.Open("UiMovieAssemble", skipDatas.CustomParams[1]) + end + + function XFunctionalSkipManager.SkipToPartnerTeachingChapter(skipData) + local isUnlock, lockTip = XDataCenter.PartnerTeachingManager.WhetherUnLockChapter(skipData.CustomParams[1]) + if isUnlock then + XLuaUiManager.Open("UiPartnerTeachingChapter", skipData.CustomParams[1]) + else + XUiManager.TipMsg(lockTip) + end + end + + function XFunctionalSkipManager.SkipToReformActivity() + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.Reform) then + return + end + if not XDataCenter.ReformActivityManager.GetIsOpen() then + XUiManager.TipError(CS.XTextManager.GetText("FunctionNotDuringOpening")) + return + end + XDataCenter.ReformActivityManager.EnterRequest(function() + XLuaUiManager.Open("UiReform") + end) + end + + function XFunctionalSkipManager.SkipToSuperTowerTier() + XDataCenter.SuperTowerManager.SkipToSuperTowerTier() + end + + function XFunctionalSkipManager.SkipToPokerGuessing() + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.PokerGuessing) and (not XDataCenter.PokerGuessingManager.IsOpen()) then + return + end + XDataCenter.PokerGuessingManager.OnOpenMain() + end + + function XFunctionalSkipManager.SkipToFashionStory(skipData) + XDataCenter.FashionStoryManager.OpenFashionStoryMain(skipData.CustomParams[1]) + end + function XFunctionalSkipManager.OnOpenSlotmachine(list) + local param1 = (list.CustomParams[1] ~= 0) and list.CustomParams[1] or nil + XDataCenter.SlotMachineManager.OpenSlotMachine(param1) + end + + function XFunctionalSkipManager.SkipToKillZone() + XDataCenter.KillZoneManager.EnterUiMain() + end + function XFunctionalSkipManager.UiDrawNewYear( skipData ) + local isOpen = true + local desc + if skipData.CustomParams[3] then + isOpen, desc = XConditionManager.CheckCondition(skipData.CustomParams[3]) + end + if not isOpen then + XUiManager.TipError(desc) + else + XDataCenter.GachaManager.GetGachaRewardInfoRequest(skipData.CustomParams[1], function() + XLuaUiManager.Open("UiDrawNewYear", skipData.CustomParams[1], skipData.CustomParams[2]) + end) + end + + end + function XFunctionalSkipManager.OnOpenSlotmachine(list) + local param1 = (list.CustomParams[1] ~= 0) and list.CustomParams[1] or nil + XDataCenter.SlotMachineManager.OpenSlotMachine(param1) + end + return XFunctionalSkipManager +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XFurnitureManager.lua b/Resources/Scripts/XManager/XFurnitureManager.lua new file mode 100644 index 00000000..0e8cd9a1 --- /dev/null +++ b/Resources/Scripts/XManager/XFurnitureManager.lua @@ -0,0 +1,1298 @@ +--- +--- 家具管理器 +--- +XFurnitureManagerCreator = function() + local XFurnitureManager = {} + + local FurnitureDatas = {} -- 家具数据 table = {id = XHomeFurnitureData} + local OtherFurnitureDatas = {} -- 家具数据(其他人的) table = {id = XHomeFurnitureData} + local FurnitureCategoryTypes = {} -- 家具类型 table = {FurnitureTypeId = {ids}} + local FurnitureSingleUnUse = {} -- ConfigId家具未使用列表 table = {FurnitureConfigId = {ids}} + local FurnitureCreateDatas = {} -- 家具创建列表 + local CollectNoneRoomFurnitrueList = {} -- 空收藏场景表 + local FurnitureDatasCount = 0 -- 擁有家具总数 + local IsInReforming = false -- 是否在家具摆放中 + + local FurnitureRequest = { + DecomposeFurniture = "DecomposeFurnitureRequest", -- 分解家具 + CreateFurniture = "CreateFurnitureRequest", --建造家具 + CheckCreateFurniture = "CheckCreateFurnitureRequest", --领取家具 + RemouldFurniture = "RemouldFurnitureRequest", --改造家具 + PutFurniture = "PutFurnitureRequest", --家具摆放 + FurnitureRemake = "FurnitureRemakeRequest", --重新建造家具 + SetFurnitureLock = "SetFurnitureOptLockRequest", --锁定或解锁家具 + } + + function XFurnitureManager.InitFurnitureCreateList(response) + if not response or not response.FurnitureCreateList then return end + FurnitureCreateDatas = response.FurnitureCreateList + end + + function XFurnitureManager.InitData(furnitureList) + if not furnitureList or not next(furnitureList) then + return + end + -- MinorType 加入全部类型 + FurnitureDatas = {} + FurnitureCategoryTypes = {} + FurnitureSingleUnUse = {} + + FurnitureCategoryTypes[XFurnitureConfigs.FURNITURE_CATEGORY_ALL_ID] = {} + + + local furnitureDatasCount = 0 + for _, data in pairs(furnitureList) do + if FurnitureDatas[data.Id] then + XLog.Error("XFurnitureManager.InitData error:id is repeated, id = " .. data.Id) + else + FurnitureDatas[data.Id] = XHomeFurnitureData.New(data) + end + + if data.DormitoryId <= 0 then + XFurnitureManager.AddFurnitureSingleUnUse(data.ConfigId, data.Id) + end + + local typeConfig = XFurnitureConfigs.GetFurnitureTypeCfgByConfigId(data.ConfigId) + if not FurnitureCategoryTypes[typeConfig.Id] then + FurnitureCategoryTypes[typeConfig.Id] = {} + end + + table.insert(FurnitureCategoryTypes[typeConfig.Id], data.Id) + table.insert(FurnitureCategoryTypes[XFurnitureConfigs.FURNITURE_CATEGORY_ALL_ID], data.Id) + furnitureDatasCount = furnitureDatasCount + 1 + end + + FurnitureDatasCount = furnitureDatasCount + end + + ---------------------start Data--------------------- + -- 本地管理的红点 -> 移除 + function XFurnitureManager.DeleteNewHint(ids) + local needSave = false + for _, id in ipairs(ids) do + local key = XPrefs.DormNewHint .. tostring(XPlayer.Id) .. id + if CS.UnityEngine.PlayerPrefs.HasKey(key) then + CS.UnityEngine.PlayerPrefs.DeleteKey(key) + needSave = true + end + end + + if needSave then + CS.UnityEngine.PlayerPrefs.Save() + end + end + + -- 本地管理的红点 -> 增加Id 表示此红点不再出现! + function XFurnitureManager.AddNewHint(ids) + local needSave = false + for _, id in ipairs(ids) do + local key = XPrefs.DormNewHint .. tostring(XPlayer.Id) .. id + if not CS.UnityEngine.PlayerPrefs.HasKey(key) then + CS.UnityEngine.PlayerPrefs.SetString(key, key) + needSave = true + end + end + + if needSave then + CS.UnityEngine.PlayerPrefs.Save() + end + end + + -- 本地管理的红点 -> 检查是否需要显示红点 + -- 如果本地有存储 说明不需要显示 + function XFurnitureManager.CheckNewHint(id) + local key = XPrefs.DormNewHint .. tostring(XPlayer.Id) .. id + return not CS.UnityEngine.PlayerPrefs.HasKey(key) + end + + -- 通过家具唯一Id 获取家具ConfigId + function XFurnitureManager.GetFurnitureConfigId(id, dormDataType) + local t = XFurnitureManager.GetFurnitureById(id, dormDataType) + return t.ConfigId + end + + -- 获取家具配置表By 唯一Id + function XFurnitureManager.GetFurnitureConfigByUniqueId(uniqueId, dormDataType) + local t = XFurnitureManager.GetFurnitureById(uniqueId, dormDataType) + return XFurnitureConfigs.GetFurnitureTemplateById(t.ConfigId) + end + + --获取所有家具数据 + function XFurnitureManager.GetFurnitureDatas() + return FurnitureDatas + end + + --获取所擁有家具总数 + function XFurnitureManager.GetAllFurnitureCount() + return FurnitureDatasCount + end + + -- 获取家具 + function XFurnitureManager.GetFurnitureById(ids, dormDataType) + local datas = FurnitureDatas + if dormDataType == XDormConfig.DormDataType.Target then + datas = OtherFurnitureDatas + end + + local func = function(id) + local t = datas[id] + if not t and t ~= nil then + XLog.Error("XFurnitureManager.GetFurnitureById error:id is not found, id = " .. id) + return nil + end + + return t + end + + if type(ids) == "table" then + local furnitureDatas = {} + for _, id in ipairs(ids) do + local furnitureData = func(id) + table.insert(furnitureDatas, furnitureData) + end + return furnitureDatas + else + local furnitureData = func(ids) + return furnitureData + end + end + + function XFurnitureManager.AddFurnitureSingleUnUse(configId, id) + if not FurnitureSingleUnUse[configId] then + FurnitureSingleUnUse[configId] = {} + end + + table.insert(FurnitureSingleUnUse[configId], id) + end + + function XFurnitureManager.RemoveFurnitureSingleUnUse(configId, id) + if not FurnitureSingleUnUse[configId] then + return + end + + local index + for i, v in ipairs(FurnitureSingleUnUse[configId]) do + if id == v then + index = i + break + end + end + + if index then + table.remove(FurnitureSingleUnUse[configId], index) + end + end + + --设置家具为使用状态 + function XFurnitureManager.SetFurnitureState(furnitureId, dormitoryId) + local furniture = XFurnitureManager.GetFurnitureById(furnitureId) + if furniture then + furniture:SetUsedDormitoryId(dormitoryId) + + if dormitoryId > 0 then + XFurnitureManager.RemoveFurnitureSingleUnUse(furniture.ConfigId, furniture.Id) + else + XFurnitureManager.AddFurnitureSingleUnUse(furniture.ConfigId, furniture.Id) + end + end + end + + --查看家具是否在使用中 + function XFurnitureManager.CheckFurnitureUsing(furnitureId, dormDataType) + local isUsing = false + if XDormConfig.IsTemplateRoom(dormDataType) then + return isUsing + end + + local furniture = XFurnitureManager.GetFurnitureById(furnitureId, dormDataType) + if furniture and furniture:CheckIsUsed() then + isUsing = true + end + + return isUsing + end + + -- 获取未使用的家具列表 + function XFurnitureManager.GetUnusedFurnitureList() + local list = {} + for _, furniture in pairs(FurnitureDatas) do + if furniture and furniture.DormitoryId > 0 then + table.insert(list, furniture) + end + end + + return list + end + + -- 获取CategoryType的家具的个数 + function XFurnitureManager.GetFurnitureCategoryCount(selectIds) + local count = 0 + for _, selectId in ipairs(selectIds) do + if FurnitureCategoryTypes[selectId] then + count = count + #FurnitureCategoryTypes[selectId] + end + end + + return count + end + + -- 获取不在使用中的家具通过ConfigId + function XFurnitureManager.GetUnuseFurnitueById(configId) + local list = FurnitureSingleUnUse[configId] + return list or {} + end + + function XFurnitureManager.GetUnuseFurnitue() + return FurnitureSingleUnUse or {} + end + + local CheckSuit = function(selectSuitIds, furinitureId) + if not selectSuitIds or #selectSuitIds <= 0 then + return true + end + + for _, suitId in ipairs(selectSuitIds) do + if suitId == XFurnitureConfigs.FURNITURE_SUIT_CATEGORY_ALL_ID then + return true + end + + local tempCfg = XFurnitureManager.GetFurnitureConfigByUniqueId(furinitureId) + if tempCfg.SuitId == suitId then + return true + end + end + + return false + end + + -- 获取FurnitureTypeId的家具唯一Ids + function XFurnitureManager.GetFurnitureCategoryIds(selectIds, selectSuitIds, isRemoveUsed, isAscending, isRemoveUnuse, isRemoveLock) + local ids = {} + for _, selectId in ipairs(selectIds) do + if FurnitureCategoryTypes[selectId] then + for _, id in ipairs(FurnitureCategoryTypes[selectId]) do + if isRemoveUsed and XFurnitureManager.CheckFurnitureUsing(id) then + goto continue + end + + if isRemoveUnuse and not XFurnitureManager.CheckFurnitureUsing(id) then + goto continue + end + + if isRemoveLock and XFurnitureManager.GetFurnitureIsLocked(id) then + goto continue + end + + if not CheckSuit(selectSuitIds, id) then + goto continue + end + + table.insert(ids, id) + :: continue :: + end + end + end + + table.sort(ids, function(a, b) + -- 是否使用 + local usingA = XFurnitureManager.CheckFurnitureUsing(a) + local usingB = XFurnitureManager.CheckFurnitureUsing(b) + if usingA ~= usingB then + return usingB + end + + -- 判断积分 + local scoreA = XFurnitureManager.GetFurnitureScore(a) + local scoreB = XFurnitureManager.GetFurnitureScore(b) + if scoreA ~= scoreB then + if isAscending then + return scoreA < scoreB + else + return scoreA > scoreB + end + end + + -- 判断类型 + local configIdA = XFurnitureManager.GetFurnitureConfigId(a) + local minorA = XFurnitureConfigs.GetFurnitureTypeCfgByConfigId(configIdA).MinorType + + local configIdB = XFurnitureManager.GetFurnitureConfigId(b) + local minorB = XFurnitureConfigs.GetFurnitureTypeCfgByConfigId(configIdB).MinorType + + if minorA ~= minorB then + return minorA < minorB + end + + return a < b + end) + + return ids + end + + -- 获取已拥有的家具配置id列表 + function XFurnitureManager.GetTotalFurnitureIds() + local configIds = {} + local furnitureIds = XFurnitureManager.GetFurnitureCategoryIds({ XFurnitureConfigs.FURNITURE_CATEGORY_ALL_ID }, + { XFurnitureConfigs.FURNITURE_SUIT_CATEGORY_ALL_ID }, false) + for _, id in pairs(furnitureIds) do + local furnitureData = XFurnitureManager.GetFurnitureConfigByUniqueId(id) + if furnitureData then + configIds[furnitureData.Id] = furnitureData.Id + end + end + + return configIds + end + + -- 判断是否已经有的该图鉴 + function XFurnitureManager.IsFieldGuideHave(id) + if not id then + return false + end + + local ids = XFurnitureManager.GetTotalFurnitureIds() or {} + return ids[id] ~= nil + end + + -- 获取家具得总积分 + function XFurnitureManager.GetFurnitureScore(furnitureId,dormDataType) + local t = XFurnitureManager.GetFurnitureById(furnitureId,dormDataType) + if not t then + return 0 + end + + return t:GetScore() + end + + function XFurnitureManager.GetFurnitureRedScore(furnitureId, dormDataType) + local t = XFurnitureManager.GetFurnitureById(furnitureId, dormDataType) + if t then + return t:GetRedScore() + end + + return 0 + end + + function XFurnitureManager.GetFurnitureYellowScore(furnitureId, dormDataType) + local t = XFurnitureManager.GetFurnitureById(furnitureId, dormDataType) + if t then + return t:GetYellowScore() + end + + return 0 + end + + function XFurnitureManager.GetFurnitureBlueScore(furnitureId, dormDataType) + local t = XFurnitureManager.GetFurnitureById(furnitureId, dormDataType) + if t then + return t:GetBlueScore() + end + + return 0 + end + --=================== + --获取家具是否上锁 + --@param furnitureId:家具ID + --=================== + function XFurnitureManager.GetFurnitureIsLocked(furnitureId) + local t = XFurnitureManager.GetFurnitureById(furnitureId) + if t then + return t:GetIsLocked() + end + + return false + end + -- 获取家具特殊效果描述 + function XFurnitureManager.GetFurnitureEffectDesc(furnitureId) + local t = XFurnitureManager.GetFurnitureById(furnitureId) + if t.Addition <= 0 then + return CS.XTextManager.GetText("DormFurnitureEffectDescNull") + end + + local addConfig = XFurnitureConfigs.GetAdditonAttrConfigById(t.Addition) + return addConfig.Introduce + end + + -- 分别获取家具三条属性总分(attrA, attrB, attrC) + function XFurnitureManager.GetFurniturePartScore(furnitureIds,dormDataType) + local attrA = 0 + local attrB = 0 + local attrC = 0 + + if furnitureIds then + for _, id in ipairs(furnitureIds) do + local t = XFurnitureManager.GetFurnitureById(id,dormDataType) + if t then + attrA = attrA + t:GetRedScore() + attrB = attrB + t:GetYellowScore() + attrC = attrC + t:GetBlueScore() + end + end + end + + return attrA, attrB, attrC + end + + -- 添加家具 + function XFurnitureManager.AddFurniture(furnitureData, dormDataType) + local datas + if not dormDataType then + dormDataType = XDormConfig.DormDataType.Self + end + if dormDataType == XDormConfig.DormDataType.Self then + datas = FurnitureDatas + else + datas = OtherFurnitureDatas + end + + + if datas[furnitureData.Id] then + XLog.Error("FurnitureDatas is already exist furniture id is" .. furnitureData.Id) + return + end + + if dormDataType == XDormConfig.DormDataType.Self then + XDataCenter.DormManager.FurnitureUnlockList[furnitureData.ConfigId] = furnitureData.ConfigId + end + datas[furnitureData.Id] = XHomeFurnitureData.New(furnitureData) + + if not dormDataType or dormDataType == XDormConfig.DormDataType.Self then + FurnitureDatasCount = FurnitureDatasCount + 1 + + -- FurnitureCategoryTypes同时添加 + local configId = furnitureData.ConfigId + local furnitureTypeId = XFurnitureConfigs.GetFurnitureTypeCfgByConfigId(configId).Id + if not FurnitureCategoryTypes[furnitureTypeId] then + FurnitureCategoryTypes[furnitureTypeId] = {} + end + + if not FurnitureCategoryTypes[XFurnitureConfigs.FURNITURE_CATEGORY_ALL_ID] then + FurnitureCategoryTypes[XFurnitureConfigs.FURNITURE_CATEGORY_ALL_ID] = {} + end + + table.insert(FurnitureCategoryTypes[furnitureTypeId], furnitureData.Id) + table.insert(FurnitureCategoryTypes[XFurnitureConfigs.FURNITURE_CATEGORY_ALL_ID], furnitureData.Id) + + -- 家具ConfigList同时添加 + XFurnitureManager.AddFurnitureSingleUnUse(furnitureData.ConfigId, furnitureData.Id) + end + end + + -- 移除家具(其他人的) + function XFurnitureManager.RemoveFurnitureOther() + OtherFurnitureDatas = {} + end + + -- 移除家具 + function XFurnitureManager.RemoveFurniture(furnitureId) + -- 先FurnitureCategoryTypes 同时移除 + local configId = XFurnitureManager.GetFurnitureConfigId(furnitureId) + local furnitureTypeId = XFurnitureConfigs.GetFurnitureTypeCfgByConfigId(configId).Id + XFurnitureManager.RemoveFurnitureSingleUnUse(configId, furnitureId) + + if FurnitureCategoryTypes[furnitureTypeId] then + local index + for i, v in ipairs(FurnitureCategoryTypes[furnitureTypeId]) do + if furnitureId == v then + index = i + break + end + end + + if index then + table.remove(FurnitureCategoryTypes[furnitureTypeId], index) + end + end + + if FurnitureCategoryTypes[XFurnitureConfigs.FURNITURE_CATEGORY_ALL_ID] then + local index + for i, v in ipairs(FurnitureCategoryTypes[XFurnitureConfigs.FURNITURE_CATEGORY_ALL_ID]) do + if furnitureId == v then + index = i + break + end + end + + if index then + table.remove(FurnitureCategoryTypes[XFurnitureConfigs.FURNITURE_CATEGORY_ALL_ID], index) + end + end + + if not FurnitureDatas[furnitureId] or FurnitureDatas[furnitureId] == nil then + XLog.Error("FurnitureDatas is not exist furniture id is" .. furnitureId) + return + end + if FurnitureDatasCount and FurnitureDatasCount > 0 then + FurnitureDatasCount = FurnitureDatasCount - 1 + end + + FurnitureDatas[furnitureId] = nil + end + + -- 服务器推送增加家具 + function XFurnitureManager.NotifyFurnitureOperate(data) + if data == nil or #data <= 0 then + return + end + + for _, v in pairs(data) do + if v.OperateType == XFurnitureConfigs.FurnitureOperate.Add then + XFurnitureManager.AddFurniture(v.ClientFurniture) + elseif v.OperateType == XFurnitureConfigs.FurnitureOperate.Delete then + XFurnitureManager.RemoveFurniture(v.ClientFurniture.Id) + end + end + end + + -- 获取家具等级奖励Id + function XFurnitureManager.GetLevelRewardId(furnitureId) + local allScore = XFurnitureManager.GetFurnitureScore(furnitureId) + local configId = XFurnitureManager.GetFurnitureConfigId(furnitureId) + local furnitureTypeId = XFurnitureConfigs.GetFurnitureTypeCfgByConfigId(configId).Id + local levelConfigs = XFurnitureConfigs.GetFurnitureLevelTemplate(furnitureTypeId) + local rewardId + + for _, levelConfig in pairs(levelConfigs) do + if allScore >= levelConfig.MinScore and allScore < levelConfig.MaxScore then + rewardId = levelConfig.ReturnId + break + end + end + + return rewardId + end + + -- 获取家具品质 + function XFurnitureManager.GetLevelRewardQuality(furnitureId) + local allScore = XFurnitureManager.GetFurnitureScore(furnitureId) + local configId = XFurnitureManager.GetFurnitureConfigId(furnitureId) + local furnitureTypeId = XFurnitureConfigs.GetFurnitureTypeCfgByConfigId(configId).Id + local levelConfigs = XFurnitureConfigs.GetFurnitureLevelTemplate(furnitureTypeId) + local quality + for _, levelConfig in pairs(levelConfigs) do + if allScore >= levelConfig.MinScore and allScore < levelConfig.MaxScore then + quality = levelConfig.Quality + break + end + end + + if not quality then + XLog.Error("XFurnitureManager.GetLevelRewardQuality Error allScore is " .. allScore) + return 1 + end + return quality + end + + -- 获得回收家具的奖励列表 + function XFurnitureManager.GetRecycleRewards(furnitureIds) + local rewards = {} + local rewardIds = {} + local recycleRewards = {} + + for _, furnitureId in ipairs(furnitureIds) do + local levelRewardId = XFurnitureManager.GetLevelRewardId(furnitureId) + + local configId = XFurnitureManager.GetFurnitureConfigId(furnitureId) + local normalRewardId = XFurnitureConfigs.GetFurnitureReturnId(configId) + + if levelRewardId then + table.insert(rewardIds, levelRewardId) + end + + if normalRewardId then + table.insert(rewardIds, normalRewardId) + end + end + + for _, rewardId in ipairs(rewardIds) do + local rewardList = XRewardManager.GetRewardList(rewardId) + for _, item in pairs(rewardList) do + if rewards[item.TemplateId] then + rewards[item.TemplateId].Count = rewards[item.TemplateId].Count + item.Count + else + rewards[item.TemplateId] = XRewardManager.CreateRewardGoodsByTemplate(item) + end + end + end + for _, reward in pairs(rewards) do + table.insert(recycleRewards, reward) + end + + if #recycleRewards > 0 then + recycleRewards = XRewardManager.SortRewardGoodsList(recycleRewards) + end + + return recycleRewards + end + + -- 分解家具 + function XFurnitureManager.DecomposeFurniture(furnitureIds, cb) + XNetwork.Call(FurnitureRequest.DecomposeFurniture, { FurnitureIds = furnitureIds }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + if cb then + cb(res.RewardGoods, res.SuccessIds) + end + + XEventManager.DispatchEvent(XEventId.EVENT_FURNITURE_ON_MODIFY) + end) + end + + function XFurnitureManager.GetRewardFurnitureAttr(extraAttrId) + local extraAttr = XFurnitureConfigs.GetFurnitureExtraAttrsById(extraAttrId) + local total = XFurnitureConfigs.GetFurnitureBaseAttrValueById(extraAttr.BaseAttrId) + + local totalPercent = extraAttr.AttrIds[XFurnitureConfigs.AttrType.AttrA] + + extraAttr.AttrIds[XFurnitureConfigs.AttrType.AttrB] + + extraAttr.AttrIds[XFurnitureConfigs.AttrType.AttrC] + + local attrA = math.floor(extraAttr.AttrIds[XFurnitureConfigs.AttrType.AttrA] / totalPercent * total or 0) + local attrB = math.floor(extraAttr.AttrIds[XFurnitureConfigs.AttrType.AttrB] / totalPercent * total or 0) + local attrC = total - attrA - attrB + + return attrA, attrB, attrC + end + + + -- 获取奖励家具特殊属性id + function XFurnitureManager.GetRewardFurnitureEffectId(furntiureRewardId) + local template = XFurnitureConfigs.GetFurnitureReward(furntiureRewardId) + if not template then + return 0 + end + + return template.AdditionId + end + + -- 获取奖励家具品质 + function XFurnitureManager.GetRewardFurnitureQuality(id) + local template = XFurnitureConfigs.GetFurnitureReward(id) + if not template then + return 0 + end + + local attrScore = XFurnitureConfigs.GetFurntiureExtraAttrTotalValue(template.ExtraAttrId) + local additionScore = XFurnitureConfigs.GetAdditionalAddScore(template.AdditionId) + + local allScore = attrScore + additionScore + local furnitureTypeId = XFurnitureConfigs.GetFurnitureTypeCfgByConfigId(template.FurnitureId).Id + local levelConfigs = XFurnitureConfigs.GetFurnitureLevelTemplate(furnitureTypeId) + + for _, levelConfig in ipairs(levelConfigs) do + if allScore >= levelConfig.MinScore and allScore < levelConfig.MaxScore then + return levelConfig.Quality + end + end + + return 0 + end + + -- 获取Extra家具总分 + function XFurnitureManager.GetRewardFurnitureScore(id) + local template = XFurnitureConfigs.GetFurnitureReward(id) + if not template then + return 0 + end + + local attrScore = XFurnitureConfigs.GetFurntiureExtraAttrTotalValue(template.ExtraAttrId) + local additionScore = XFurnitureConfigs.GetAdditionalAddScore(template.AdditionId) + + return attrScore + additionScore + end + + function XFurnitureManager.SetCollectNoneFurnitrue(roomId, furnitureList) + CollectNoneRoomFurnitrueList[roomId] = furnitureList + end + + function XFurnitureManager.GetCollectNoneFurnitrue(roomId) + return CollectNoneRoomFurnitrueList[roomId] + end + + function XFurnitureManager.CheckCollectNoneFurnitrue(roomId) + return CollectNoneRoomFurnitrueList[roomId] ~= nil + end + + function XFurnitureManager.IsFurnitureMatchType(id, targetType) + local furnitureDatas = XFurnitureManager.GetFurnitureById(id) + local furnitureTemplates = XFurnitureConfigs.GetFurnitureTemplateById(furnitureDatas.ConfigId) + if furnitureTemplates then + return furnitureTemplates.TypeId == targetType + end + return false + end + + function XFurnitureManager.UpdateFurnitureCreateList(pos, endTime, furniture, count) + for _, v in pairs(FurnitureCreateDatas) do + if v.Pos == pos then + v.EndTime = endTime + v.Furniture = furniture + v.Count = count + return + end + end + table.insert(FurnitureCreateDatas, { + Pos = pos, + EndTime = endTime, + Furniture = furniture, + Count = count, + }) + end + + function XFurnitureManager.GetFurnitureCreateItemByPos(pos) + if not FurnitureCreateDatas then + return nil + end + + for _, v in pairs(FurnitureCreateDatas) do + if v.Pos == pos then + return v + end + end + end + + function XFurnitureManager.RemoveFurnitureCreateListByPos(pos) + local key = nil + for k, v in pairs(FurnitureCreateDatas) do + if v.Pos == pos then + key = k + break + end + end + if key then + FurnitureCreateDatas[key] = nil + end + end + + function XFurnitureManager.HasCollectableFurniture() + if not FurnitureCreateDatas then + return false + end + local now = XTime.GetServerNowTimestamp() + local canCollect = false + for _, v in pairs(FurnitureCreateDatas) do + if v.EndTime <= now then + canCollect = true + break + end + end + return canCollect + end + + function XFurnitureManager.GetFurnitureCreateList() + return FurnitureCreateDatas + end + + + --判断坑位已满 + function XFurnitureManager.IsFurnitureCreatePosFull() + local maxCreateNum = CS.XGame.Config:GetInt("DormFurnitureCreateNum") + if not FurnitureCreateDatas then + return false + end + + local buildingNum = 0 + for _, _ in pairs(FurnitureCreateDatas) do + buildingNum = buildingNum + 1 + end + + if buildingNum == maxCreateNum then + return true + end + + return false + end + + + + -- 获取所有MinorType类型的家具数量,需要过滤风格参数 + function XFurnitureManager.GetFurnitureCountByMinorTypeAndSuitId(roomId, furnitureCache, suitId, minorType) + local totalDatas = furnitureCache or {} + local totalCount = 0 + + for _, v in pairs(totalDatas) do + local furnitureTemplate = XFurnitureConfigs.GetFurnitureTemplateById(v.ConfigId) + local currentTypeDatas = XFurnitureConfigs.GetFurnitureTypeById(furnitureTemplate.TypeId) + local currentBaseDatas = XFurnitureConfigs.GetFurnitureBaseTemplatesById(v.ConfigId) + local currentFurniture = XFurnitureManager.GetFurnitureById(v.Id) + local isUsing = currentFurniture:CheckIsUsed() and currentFurniture.DormitoryId ~= roomId--不计算其他宿舍的 + + if XFurnitureConfigs.IsAllSuit(suitId) then + --全部 + if (not isUsing) and currentTypeDatas.MinorType == minorType then + totalCount = totalCount + 1 + end + else + if (not isUsing) and currentTypeDatas.MinorType == minorType and currentBaseDatas.SuitId == suitId then + totalCount = totalCount + 1 + end + end + end + return totalCount + end + + function XFurnitureManager.GetFurnitureCountByMinorAndCategoryAndSuitId(roomId, furnitureCache, suitId, minor, category) + local totalDatas = furnitureCache or {} + local totalCount = 0 + category = category or 0 + + for _, v in pairs(totalDatas) do + local furnitureTemplate = XFurnitureConfigs.GetFurnitureTemplateById(v.ConfigId) + local currentTypeDatas = XFurnitureConfigs.GetFurnitureTypeById(furnitureTemplate.TypeId) + local currentBaseDatas = XFurnitureConfigs.GetFurnitureBaseTemplatesById(v.ConfigId) + local currentFurniture = XFurnitureManager.GetFurnitureById(v.Id) + local isUsing = currentFurniture:CheckIsUsed() and currentFurniture.DormitoryId ~= roomId--不计算其他宿舍的 + + if not isUsing then + if XFurnitureConfigs.IsAllSuit(suitId) then + if currentTypeDatas.MinorType == minor and currentTypeDatas.Category == category then + totalCount = totalCount + 1 + end + else + if suitId == currentBaseDatas.SuitId and currentTypeDatas.MinorType == minor and currentTypeDatas.Category == category then + totalCount = totalCount + 1 + end + end + end + end + + return totalCount + end + + -- 获取过滤的家具数据 + function XFurnitureManager.FilterDisplayFurnitures(roomId, suitId, minorType, categoryType) + local totalDatas = XDataCenter.FurnitureManager.GetFurnitureDatas() + local list = {} + -- 过滤 + for _, v in pairs(totalDatas) do + local furnitureTemplate = XFurnitureConfigs.GetFurnitureTemplateById(v.ConfigId) + local baseData = XFurnitureConfigs.GetFurnitureBaseTemplatesById(v.ConfigId) + local currentTypeDatas = XFurnitureConfigs.GetFurnitureTypeById(furnitureTemplate.TypeId) + local isUsing = XFurnitureManager.CheckFurnitureUsing(v.Id) + + if not isUsing then + if suitId and suitId ~= 1 then + --有套装id + if baseData.SuitId == suitId then + if categoryType ~= nil and categoryType ~= 0 then + --不为空 + if currentTypeDatas.MinorType == minorType and currentTypeDatas.Category == categoryType then + table.insert(list, v) + end + else + if currentTypeDatas.MinorType == minorType then + table.insert(list, v) + end + end + end + else + --没有套装id + if categoryType ~= nil and categoryType ~= 0 then + --不为空 + if currentTypeDatas.MinorType == minorType and currentTypeDatas.Category == categoryType then + table.insert(list, v) + end + else + if currentTypeDatas.MinorType == minorType then + table.insert(list, v) + end + end + end + end + end + return list + end + + -- 获取家具套装数量 + function XFurnitureManager.GetFurnitureCountBySuitId(roomId, cache, suitId) + + local typeList = XFurnitureConfigs.GetFurnitureTypeList() + + local totalCount = 0 + if XFurnitureConfigs.IsAllSuit(suitId) then + for _, typeDatas in pairs(typeList) do + local baseType = typeDatas.MinorType + local cacheBaseKey = XFurnitureManager.GenerateCacheKey(baseType, nil) + for _, _ in pairs(cache[cacheBaseKey]) do + totalCount = totalCount + 1 + end + end + else + for _, typeDatas in pairs(typeList) do + local baseType = typeDatas.MinorType + local cacheBaseKey = XFurnitureManager.GenerateCacheKey(baseType, nil) + for _, furniture in pairs(cache[cacheBaseKey]) do + + local baseData = XFurnitureConfigs.GetFurnitureBaseTemplatesById(furniture.ConfigId) + if baseData.SuitId == suitId then + totalCount = totalCount + 1 + end + + end + end + end + + return totalCount + end + + function XFurnitureManager.GenerateCacheKey(baseType, subType) + if not baseType then + return + end + + if subType == nil then + return string.format("%d_", baseType) + else + return string.format("%d_%d_", baseType, subType) + end + end + + -- 摆放家具 + function XFurnitureManager.PutFurniture(dormitoryId, furnitureList, isBehavior, func) + XNetwork.Call(FurnitureRequest.PutFurniture, { + DormitoryId = dormitoryId, + FurnitureList = furnitureList + }, function(res) + if res.Code ~= XCode.Success then + if isBehavior and func then + func(false) + end + XUiManager.TipCode(res.Code) + return + end + + if func then + func(true) + end + end) + end + + -- 改造家具 + function XFurnitureManager.RemouldFurniture(furnitureIds, draftId, func) + XNetwork.Call(FurnitureRequest.RemouldFurniture, { FurnitureIds = furnitureIds, ItemId = draftId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + -- 清除消耗的家具 + for _, furnitureId in ipairs(furnitureIds) do + XFurnitureManager.RemoveFurniture(furnitureId) + XFurnitureManager.DeleteNewHint({ [1] = furnitureId }) + end + + -- 添加新增的家具 + for _, furniture in ipairs(res.FurnitureList) do + XFurnitureManager.AddFurniture(furniture) + XFurnitureManager.DeleteNewHint({ [1] = furniture.Id }) + end + + if func then + func(res.FurnitureList) + end + end) + end + + -- 领取家具, + function XFurnitureManager.CheckCreateFurniture(pos, func) + XNetwork.Call(FurnitureRequest.CheckCreateFurniture, { Pos = pos }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + -- 清除FurnitureManager的创建家具列表数据 + XFurnitureManager.RemoveFurnitureCreateListByPos(pos) + -- 将家具添加到List列表 + for _, furniture in ipairs(res.FurnitureList) do + XFurnitureManager.AddFurniture(furniture) + end + + if func then + func(res.FurnitureList, res.Count) + end + + XEventManager.DispatchEvent(XEventId.EVENT_FURNITURE_Get_Furniture) + end) + end + + -- 建造家具 + function XFurnitureManager.CreateFurniture(pos, typeIds, count, costA, costB, costC, func) + XNetwork.Call(FurnitureRequest.CreateFurniture, { + Pos = pos, + TypeIds = typeIds, + Count = count, + CostA = costA, + CostB = costB, + CostC = costC + }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + -- 添加到FurnitureManager + XFurnitureManager.UpdateFurnitureCreateList(pos, res.EndTime, res.Furniture, res.Count) + if func then + -- 刷新界面 + func() + end + end) + end + + -- 重新建造家具 + function XFurnitureManager.FurnitureRemake(pos, furnitureList, func) + XNetwork.Call(FurnitureRequest.FurnitureRemake, { + Pos = pos, + FurnitureIds = furnitureList + }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + -- 将分解成功的家具从缓存中移除 + for _, id in ipairs(furnitureList) do + -- local configId = XDataCenter.FurnitureManager.GetFurnitureConfigId(id) + XDataCenter.FurnitureManager.RemoveFurniture(id) + end + + -- 删除红点 + XDataCenter.FurnitureManager.DeleteNewHint(furnitureList) + XRewardManager.MergeAndSortRewardGoodsList(res.RewardGoods) + XFurnitureManager.UpdateFurnitureCreateList(pos, res.EndTime, res.Furniture, res.Count) + + if func then + func() + end + end) + end + --===================== + --解锁/上锁家具 + --@param furnitureId:家具ID + --@param isLocked:是否上锁 + --@param callBack:成功回调 + --===================== + function XFurnitureManager.SetFurnitureLock(furnitureId, isLocked, callBack) + XNetwork.Call(FurnitureRequest.SetFurnitureLock, { + FurnitureId = furnitureId, + IsLocked = isLocked + }, function(reply) + -- reply = { + -- XCode Code, + -- int FurnitureId, + -- bool IsLocked} + if reply.Code ~= XCode.Success then + XUiManager.TipCode(reply.Code) + return + end + local furnitureData = XFurnitureManager.GetFurnitureById(reply.FurnitureId) + if furnitureData then + furnitureData:SetIsLocked(isLocked) + end + if callBack then callBack() end + end) + end + + -- 根据家具属性获得贴图 + function XFurnitureManager.GetFurnitureMaterial(furnitureId, dormDataType) + if not furnitureId then + return + end + + local furnitureData = XFurnitureManager.GetFurnitureById(furnitureId, dormDataType) + if not furnitureData then + return + end + + local furnitureColour = XFurnitureConfigs.GetFurnitureColour(furnitureData.ConfigId) + if not furnitureColour then + return + end + + if XDormConfig.IsTemplateRoom(dormDataType) then + return furnitureColour.DefaultMaterial + end + + local maxAttrKey = 0 + local maxAttrVal = 0 + -- local midAttrKey = 0 + local midAttrVal = 0 + + for k, v in pairs(furnitureData.AttrList) do + if v >= maxAttrVal then + -- midAttrKey = maxAttrKey + midAttrVal = maxAttrVal + + maxAttrKey = k + maxAttrVal = v + elseif v >= midAttrVal then + -- midAttrKey = k + midAttrVal = v + end + end + + -- 最高和第二高值一致,则返回默认 + if maxAttrVal == midAttrVal then + return furnitureColour.DefaultMaterial + end + if midAttrVal == 0 then + return furnitureColour.FurnitureMaterials[maxAttrKey] + end + + local attrOverRate = (maxAttrVal - midAttrVal) / midAttrVal * 100 + if furnitureColour and attrOverRate >= furnitureColour.AttrIds[maxAttrKey] then + return furnitureColour.FurnitureMaterials[maxAttrKey] + end + + return furnitureColour.DefaultMaterial + end + + -- 根据家具属性获得家具特效 + function XFurnitureManager.GetFurnitureFx(furnitureId, dormDataType) + if not furnitureId then + return + end + + local furnitureData = XFurnitureManager.GetFurnitureById(furnitureId, dormDataType) + if not furnitureData then + return + end + + local furnitureColour = XFurnitureConfigs.GetFurnitureColour(furnitureData.ConfigId) + if not furnitureColour then + return + end + + if XDormConfig.IsTemplateRoom(dormDataType) then + return furnitureColour.DefaultMaterial + end + + local maxAttrKey = 0 + local maxAttrVal = 0 + -- local midAttrKey = 0 + local midAttrVal = 0 + + for k, v in pairs(furnitureData.AttrList) do + if v >= maxAttrVal then + -- midAttrKey = maxAttrKey + midAttrVal = maxAttrVal + + maxAttrKey = k + maxAttrVal = v + elseif v >= midAttrVal then + -- midAttrKey = k + midAttrVal = v + end + end + + -- 最高和第二高值一致,则返回默认 + if maxAttrVal == midAttrVal then + return furnitureColour.DefaultFurnitureFx + end + if midAttrVal == 0 then + return furnitureColour.FurnitureFx[maxAttrKey] + end + + local attrOverRate = (maxAttrVal - midAttrVal) / midAttrVal * 100 + if furnitureColour and attrOverRate >= furnitureColour.AttrIds[maxAttrKey] then + return furnitureColour.FurnitureFx[maxAttrKey] + end + + return furnitureColour.DefaultFurnitureFx + end + + -- 读取家具表的Icon,不能获得家具的属性用这个接口 + function XFurnitureManager.GetFurnitureIconByConfigId(configId) + local furnitureTemplates = XFurnitureConfigs.GetFurnitureBaseTemplatesById(configId) + if not furnitureTemplates then + return "" + end + return furnitureTemplates.Icon + end + + -- 根据家具属性计算家具的Icon,能获得家具的属性用这个接口 + function XFurnitureManager.GetFurnitureIconById(furnitureId, dormDataType) + if not furnitureId then + return "" + end + + local furnitureData = XFurnitureManager.GetFurnitureById(furnitureId, dormDataType) + return XFurnitureManager.GetIconByFurniture(furnitureData) + end + + function XFurnitureManager.GetIconByFurniture(furniture) + if not furniture then + return "" + end + + local baseIcon = XFurnitureManager.GetFurnitureIconByConfigId(furniture.ConfigId) + + local furnitureColour = XFurnitureConfigs.GetFurnitureColour(furniture.ConfigId) + if not furnitureColour then + return baseIcon + end + + local maxAttrKey = 0 + local maxAttrVal = 0 + -- local midAttrKey = 0 + local midAttrVal = 0 + + for k, v in pairs(furniture.AttrList) do + if v >= maxAttrVal then + -- midAttrKey = maxAttrKey + midAttrVal = maxAttrVal + + maxAttrKey = k + maxAttrVal = v + elseif v >= midAttrVal then + -- midAttrKey = k + midAttrVal = v + end + end + + local defaultIcon = (furnitureColour.DefaultFurnitureIcon == "") and baseIcon or furnitureColour.DefaultFurnitureIcon + local chooseIcon = (furnitureColour.FurnitureIcons[maxAttrKey] == "") and defaultIcon or furnitureColour.FurnitureIcons[maxAttrKey] + + -- 最高和第二高值一致,则返回默认 + if maxAttrVal == midAttrVal then + return defaultIcon + end + if midAttrVal == 0 then + return chooseIcon + end + + local attrOverRate = (maxAttrVal - midAttrVal) / midAttrVal * 100 + if furnitureColour and attrOverRate >= furnitureColour.AttrIds[maxAttrKey] then + return chooseIcon + end + return defaultIcon + end + + function XFurnitureManager.GetTemplateCount(templateId) + local totalCount = 0 + for _, v in pairs(XFurnitureManager.GetFurnitureDatas()) do + local isUsing = XFurnitureManager.CheckFurnitureUsing(v.Id) + if (not isUsing) and v.ConfigId == templateId then + totalCount = totalCount + 1 + end + end + return totalCount + end + + function XFurnitureManager.SetInRefeform(isInReforming) + IsInReforming = isInReforming + end + + function XFurnitureManager.GetInRefeform() + return IsInReforming + end + + return XFurnitureManager +end + +XRpc.NotifyFurnitureOperate = function(data) + XDataCenter.FurnitureManager.NotifyFurnitureOperate(data.OperateList) +end diff --git a/Resources/Scripts/XManager/XGachaManager.lua b/Resources/Scripts/XManager/XGachaManager.lua new file mode 100644 index 00000000..a8bbfbd2 --- /dev/null +++ b/Resources/Scripts/XManager/XGachaManager.lua @@ -0,0 +1,415 @@ +XGachaManagerCreator = function() + local GET_GACHA_DATA_INTERVAL = 15 + local XGachaManager = {} + local GachaRewardInfos = {} + local GachaProbShows = {} + local GachaLogList = {} + local LastGetGachaRewardInfoTimes = {} + local CurCountOfAll = 0 + local MaxCountOfAll = 0 + local IsInfinite = false + local ParseToTimestamp = XTime.ParseToTimestamp + + -- 卡池组状态 + -- Key:number OrganizeId + -- Value:Table { gachaId = XGachaConfigs.OrganizeGachaStatus } + local GachaOrganizeStatus = {} + + local METHOD_NAME = { + GetGachaInfo = "GetGachaInfoRequest", + Gacha = "GachaRequest", + GetGachaOrganizeInfo = "GetGachaOrganizeInfoRequest", + } + + function XGachaManager.Init() + XGachaManager.SetGachaRewardInfo() + XGachaManager.SetGachaProbShowInfo() + end + + function XGachaManager.GetGachaRewardInfoById(gaChaId) + local gachaCfg = XGachaConfigs.GetGachas() + MaxCountOfAll = 0 + CurCountOfAll = 0 + IsInfinite = false + local groupIdList = {} + for _, groupId in pairs(gachaCfg[gaChaId].GroupId) do + table.insert(groupIdList, groupId) + end + + local list = {} + for _, v in pairs(GachaRewardInfos) do + for _, groupId in pairs(groupIdList) do + if v.GroupId == groupId then + table.insert(list, v) + break + end + end + + end + for _, v in pairs(list) do + if v.RewardType == XGachaConfigs.RewardType.NotCount then + IsInfinite = true + end + MaxCountOfAll = MaxCountOfAll + v.UsableTimes + CurCountOfAll = CurCountOfAll + (v.UsableTimes - v.CurCount) + end + + table.sort(list, function(a, b) + if a.Priority == b.Priority then + return a.Id < b.Id + else + return a.Priority > b.Priority + end + end) + return list + end + + function XGachaManager.GetGachaProbShowById(gaChaId) + local gachaProbShowInfo = GachaProbShows[gaChaId] + if gachaProbShowInfo then + table.sort(gachaProbShowInfo, function(a, b) + if a.IsRare == b.IsRare then + return a.Id < b.Id + else + return a.IsRare == XGachaConfigs.RareType.Rare + end + end) + else + XLog.Error("ProbShows's Data Is Null By GachaId :"..gaChaId) + end + + return gachaProbShowInfo + end + + function XGachaManager.GetCurCountOfAll() + return CurCountOfAll + end + + function XGachaManager.GetMaxCountOfAll() + return MaxCountOfAll + end + + function XGachaManager.GetIsInfinite() + return IsInfinite + end + + function XGachaManager.GetGachaLogById(gachaId) + return GachaLogList[gachaId] or {} + end + + --- + ---@param notCheckDraw boolean 是否检测活动研发功能开启,true:不检测,false:检测 + function XGachaManager.CheckGachaIsOpenById(id, IsShowText, notCheckDraw) + if IsShowText then + if not notCheckDraw and not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.ActivityDrawCard) then + return false + end + else + if not notCheckDraw and not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.ActivityDrawCard) then + return false + end + end + + local gachaCfg = XGachaConfigs.GetGachas() + + if not gachaCfg[id] then + XLog.Error("GachaId Is Not Exist :"..id) + return false + end + + local nowTime = XTime.GetServerNowTimestamp() + local startTime = ParseToTimestamp(gachaCfg[id].StartTimeStr) + local endTime = ParseToTimestamp(gachaCfg[id].EndTimeStr) + local IsClose = nowTime > endTime + local IsNotOpen = startTime > nowTime + if IsShowText and IsNotOpen then + local str = CS.XTextManager.GetText("GachaIsNotOpen", gachaCfg[id].StartTimeStr, gachaCfg[id].EndTimeStr) + XUiManager.TipMsg(str) + end + if IsShowText and IsClose then + XUiManager.TipText("GachaIsClose") + end + return (not IsClose) and (not IsNotOpen) + end + + --- + --- 检测扭蛋组是否开启 + function XGachaManager.CheckGachaOrganizeIsOpen(organizeId, isShowText) + local startTimeStr, endTimeStr = XGachaConfigs.GetOrganizeTime(organizeId) + if not startTimeStr or not endTimeStr then + return false + end + + local nowTime = XTime.GetServerNowTimestamp() + local startTime = ParseToTimestamp(startTimeStr) + local endTime = ParseToTimestamp(endTimeStr) + + local IsNotOpen = startTime > nowTime + if isShowText and IsNotOpen then + local str = CS.XTextManager.GetText("GachaIsNotOpen", startTimeStr, endTimeStr) + XUiManager.TipMsg(str) + end + + local IsClose = nowTime > endTime + if isShowText and IsClose then + XUiManager.TipText("GachaIsClose") + end + + return (not IsClose) and (not IsNotOpen) + end + + function XGachaManager.UpdateGachaRewardInfo(gridInfoList) + for _, v in pairs(gridInfoList or {}) do + if GachaRewardInfos[v.Id] then + GachaRewardInfos[v.Id].CurCount = GachaRewardInfos[v.Id].UsableTimes - v.Times + end + end + end + + function XGachaManager.UpdateGachaLog(gachaId, logList) + GachaLogList = GachaLogList or {} + GachaLogList[gachaId] = logList + end + + function XGachaManager.SetGachaRewardInfo() + local gachaRewardCfg = XGachaConfigs.GetGachaReward() + for id, reward in pairs(gachaRewardCfg) do + GachaRewardInfos[id] = {} + for k, v in pairs(reward) do + GachaRewardInfos[id][k] = v + end + GachaRewardInfos[id].CurCount = GachaRewardInfos[id].UsableTimes + end + end + + function XGachaManager.SetGachaProbShowInfo() + local gachaProbShowCfg = XGachaConfigs.GetGachaProbShows() + for _, probShow in pairs(gachaProbShowCfg) do + GachaProbShows[probShow.GachaId] = GachaProbShows[probShow.GachaId] or {} + table.insert(GachaProbShows[probShow.GachaId],probShow) + end + end + + function XGachaManager.GetGachaRewardInfoRequest(gaChaId, cb) + local now = XTime.GetServerNowTimestamp() + if LastGetGachaRewardInfoTimes[gaChaId] and now - LastGetGachaRewardInfoTimes[gaChaId] <= GET_GACHA_DATA_INTERVAL then + cb() + return + end + XNetwork.Call(METHOD_NAME.GetGachaInfo, { Id = gaChaId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XGachaManager.UpdateGachaRewardInfo(res.GridInfoList) + XGachaManager.UpdateGachaLog(gaChaId, res.GachaRecordList) + LastGetGachaRewardInfoTimes[gaChaId] = XTime.GetServerNowTimestamp() + cb() + end) + end + + + function XGachaManager.DoGacha(gaChaId, count, cb, errorCb, organizeId) + XNetwork.Call(METHOD_NAME.Gacha, { Id = gaChaId, Times = count }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + if errorCb then + errorCb() + end + return + end + XGachaManager.UpdateGachaRewardInfo(res.GridInfoList) + XGachaManager.UpdateGachaLog(gaChaId, res.GachaRecordList) + + local newUnlockGachaId + if organizeId then + newUnlockGachaId = XGachaManager.DrawUpdateOrganizeStatus(organizeId, gaChaId) + end + + if cb then + cb(res.RewardList, newUnlockGachaId) + end + end) + end + + --- + --- 在进入界面的时候请求'organizeId'卡池组里的已售罄池子,以及最新解锁的池子的奖励信息 + function XGachaManager.GetGachaOrganizeInfoRequest(organizeId, cb) + XNetwork.Call(METHOD_NAME.GetGachaOrganizeInfo, { OrganizeId = organizeId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + XGachaManager.UpdateGachaRewardInfo(res.GridInfoList) + XGachaManager.UpdateGachaLog(res.CurrentId, res.GachaRecordList) + XGachaManager.OpenUpdateOrganizeStatus(organizeId, res.CurrentId, res.OutOfStockIdList) + if cb then + cb(res.CurrentId) + end + end) + end + + + --------------------------------------------Organize卡池状态相关------------------------------------------------------ + + --- + --- 进入界面时更新卡池组的卡池状态 + --- + --- 'newestGachaId'为最新解锁的卡池Id,它前面的卡池状态为正常或售罄,后面的卡池状态为锁定 + --- 'outSoldList'为已售罄卡池Id数组,这样就不用发送所有卡池的奖励信息,就能知道所有卡池的状态 + function XGachaManager.OpenUpdateOrganizeStatus(organizeId, newestGachaId, outSoldList) + if not GachaOrganizeStatus[organizeId] then + GachaOrganizeStatus[organizeId] = {} + end + + -- 设置已售罄卡池 + for _, gachaId in ipairs(outSoldList) do + if not GachaOrganizeStatus[organizeId][gachaId] then + GachaOrganizeStatus[organizeId][gachaId] = XGachaConfigs.OrganizeGachaStatus.SoldOut + end + + -- 进入界面时,客户端缓存的售馨卡池与服务器下发的售罄卡池不同步 + if GachaOrganizeStatus[organizeId][gachaId] ~= XGachaConfigs.OrganizeGachaStatus.SoldOut then + XLog.Error(string.format("XGachaManager.UpdateOrganizeGachaStatus函数错误,服务器下发的最新卡池Id为%s,卡池组%s的卡池%s状态与服务器不同步,客户端的为未售罄状态", + tostring(newestGachaId), tostring(organizeId), tostring(gachaId))) + GachaOrganizeStatus[organizeId][gachaId] = XGachaConfigs.OrganizeGachaStatus.SoldOut + end + end + + local organizeGachaIdList = XGachaConfigs.GetOrganizeGahcaIdList(organizeId) -- organizeId组的所有gachaId数组,已根据Sort排序 + local newestGachaIndex = XGachaConfigs.GetOrganizeIndex(organizeId, newestGachaId) -- 最新解锁卡池在organizeGachaIdList数组里的序号 + if not newestGachaIndex then + return + end + -- 最新解锁卡池前面的卡池为已解锁或售罄,后面的为锁定 + for index, gachaId in ipairs(organizeGachaIdList) do + if index <= newestGachaIndex then + if not GachaOrganizeStatus[organizeId][gachaId] then + GachaOrganizeStatus[organizeId][gachaId] = XGachaConfigs.OrganizeGachaStatus.Normal + end + + -- 进入界面时,客户端缓存的 newestGachaId卡池前面的卡池的状态 为锁定,说明状态与服务器不同步 + if GachaOrganizeStatus[organizeId][gachaId] == XGachaConfigs.OrganizeGachaStatus.Lock then + XLog.Error(string.format("XGachaManager.UpdateOrganizeGachaStatus函数错误,服务器下发的最新卡池Id为%s,卡池组%s的卡池%s状态与服务器不同步,客户端的为上锁状态", + tostring(newestGachaId), tostring(organizeId), tostring(gachaId))) + GachaOrganizeStatus[organizeId][gachaId] = XGachaConfigs.OrganizeGachaStatus.Normal + end + else + if not GachaOrganizeStatus[organizeId][gachaId] then + GachaOrganizeStatus[organizeId][gachaId] = XGachaConfigs.OrganizeGachaStatus.Lock + end + + -- 进入界面时,客户端缓存的 newestGachaId卡池后面的卡池的状态为正常,说明状态与服务器不同步 + if GachaOrganizeStatus[organizeId][gachaId] == XGachaConfigs.OrganizeGachaStatus.Normal then + XLog.Error(string.format("XGachaManager.UpdateOrganizeGachaStatus函数错误,服务器下发的最新卡池Id为%s,卡池组%s的卡池%s状态与服务器不同步,客户端的为正常状态", + tostring(newestGachaId), tostring(organizeId), tostring(gachaId))) + GachaOrganizeStatus[organizeId][gachaId] = XGachaConfigs.OrganizeGachaStatus.Lock + end + end + end + end + + --- 抽卡后更新卡池组的卡池状态 + --- 如果解锁了新卡池则返回该卡池Id + ---@return number + function XGachaManager.DrawUpdateOrganizeStatus(organizeId, DrawingGachaId) + if not GachaOrganizeStatus[organizeId] then + XLog.Error(string.format("XGachaManager.DrawUpdateOrganizeStatus函数错误,卡池组%s的状态数据为空", + tostring(organizeId))) + GachaOrganizeStatus[organizeId] = {} + end + + local isSoldOutRare = true -- 特殊奖励是否售罄 + local isSoldOut = true -- 全部奖励是否售罄 + local groupIdList = {} + + -- 是否无限次数 + if IsInfinite then + isSoldOut = false + else + -- 找出DrawingGachaId的奖励 + local gachaCfg = XGachaConfigs.GetGachas() + for _, groupId in pairs(gachaCfg[DrawingGachaId].GroupId) do + table.insert(groupIdList, groupId) + end + + for _, v in pairs(GachaRewardInfos) do + -- 是否属于DrawingGachaId的奖励组 + for _, groupId in pairs(groupIdList) do + if v.GroupId == groupId and v.CurCount ~= 0 then + isSoldOut = false + if v.Rare then + isSoldOutRare = false + end + break + end + end + end + end + + if isSoldOut then + GachaOrganizeStatus[organizeId][DrawingGachaId] = XGachaConfigs.OrganizeGachaStatus.SoldOut + end + + local isUnlockNext + if isSoldOutRare then + -- 是否解锁了新的卡池62504 + local nextGachaStatus, nextGachaId = XGachaManager.GetOrganizeNextGachaStatus(organizeId, DrawingGachaId) + if nextGachaStatus and nextGachaId then + if nextGachaStatus == XGachaConfigs.OrganizeGachaStatus.Lock then + GachaOrganizeStatus[organizeId][nextGachaId] = XGachaConfigs.OrganizeGachaStatus.Normal + isUnlockNext = nextGachaId + end + end + end + return isUnlockNext + end + + --- + --- 获取''organizeId'卡池组内'gachaId'卡池的状态 + function XGachaManager.GetOrganizeGachaStatus(organizeId, gachaId) + if not gachaId or gachaId == 0 then + return + end + if GachaOrganizeStatus[organizeId] then + if GachaOrganizeStatus[organizeId][gachaId] then + return GachaOrganizeStatus[organizeId][gachaId] + else + XLog.Error(string.format("XGachaManager.GetOrganizeGachaStatus函数错误,卡池%s的状态数据为空", gachaId)) + end + else + XLog.Error(string.format("XGachaManager.GetOrganizeGachaStatus函数错误,卡池组%s的状态数据为空", organizeId)) + end + return XGachaConfigs.OrganizeGachaStatus.Lock + end + + --- + --- 获取''organizeId'卡池组内'gachaId'前一个卡池的状态与Id + --- + --- 如果'gachaId'是第一个卡池,则返回nil + function XGachaManager.GetOrganizePreGachaStatus(organizeId, gachaId) + local preGachaId = XGachaConfigs.GetOrganizePreGachaId(organizeId, gachaId) + local status = XGachaManager.GetOrganizeGachaStatus(organizeId, preGachaId) + if status then + return status, preGachaId + end + end + + --- + --- 获取''organizeId'卡池组内'gachaId'后一个卡池的状态与Id + --- + --- 如果'gachaId'是最后一个卡池,则返回nil + function XGachaManager.GetOrganizeNextGachaStatus(organizeId, gachaId) + local nextGachaId = XGachaConfigs.GetOrganizeNextGachaId(organizeId, gachaId) + local status = XGachaManager.GetOrganizeGachaStatus(organizeId, nextGachaId) + if status then + return status, nextGachaId + end + end + -------------------------------------------------------------------------------------------------------------------- + + + XGachaManager.Init() + return XGachaManager +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XGmTestManager.lua b/Resources/Scripts/XManager/XGmTestManager.lua new file mode 100644 index 00000000..b340cb7e --- /dev/null +++ b/Resources/Scripts/XManager/XGmTestManager.lua @@ -0,0 +1,532 @@ +XGmTestManager = XGmTestManager or {} +local Panel + +local function CheckLogin() + if not XLoginManager.IsLogin() then + XUiManager.TipError("请先登录") + return false + end + + return true +end + +local function Open(name, ...) + if not CheckLogin() then + return + end + + XLuaUiManager.Open(name, ...) +end + +local function OpenActivity() + XActivityBriefConfigs.TestOpenActivity() + XUiManager.SystemDialogTip("", "开启活动成功,重新登录生效", XUiManager.DialogType.OnlySure, nil, function() + XLoginManager.DoDisconnect() + end) +end + +-----------更新版本信息------------ +local TxtVersion +local function UpdateVersionInfo() + if not TxtVersion then return end + if CS.XInfo.Version == CS.XRemoteConfig.ApplicationVersion then + TxtVersion.text = string.format("客户端版本\n%s", CS.XRemoteConfig.ApplicationVersion) + else + TxtVersion.text = string.format("原版本%s\n现版本%s", CS.XInfo.Version, CS.XRemoteConfig.ApplicationVersion) + end +end +--------------------------------- + +local function AddMoeWar() + Panel:AddButton("萌战主页", function() + Open("UiMoeWarMain") + end) + + Panel:AddButton("萌战信息界面", function() + Open("UiMoeWarMessage") + end) + + Panel:AddButton("萌战排行榜", function() + Open("UiMoeWarRankingList") + end) + + Panel:AddButton("萌战赛程", function() + Open("UiMoeWarSchedule") + end) + + local playerId = 1 + local itemCount = 1 + local itemNo = 1 + + Panel:AddInput("投票Id", function(value) + playerId = tonumber(value) + end) + + Panel:AddInput("道具数量", function(value) + itemCount = tonumber(value) + end) + + Panel:AddInput("道具类型", function(value) + itemNo = tonumber(value) + end) + + Panel:AddButton("萌战投票", function() + XDataCenter.MoeWarManager.GetPlayer(playerId):RequestVote(itemNo, itemCount) + end) + + ---------萌战动画 begin------------ + local winnerIndex = 1 + local animGroupIds = {} + + Panel:AddInput("胜利跑道\nIndex(1/2/3)", function(value) + winnerIndex = tonumber(value) + end) + + for index = 1, 3 do + Panel:AddInput("动画组Id" .. index, function(value) + animGroupIds[index] = tonumber(value) + end) + end + + Panel:AddButton("萌战动画", function() + XMoeWarConfig.ReloadAnimationConfigs() + XLuaUiManager.Open("UiMoeWarAnimation", animGroupIds, winnerIndex) + end) + ---------萌战动画 end------------ +end + +local function AddSvnFunction() + local tool = CS.XExternalTool + local runSvn = tool.RunSvn + local asynRunTool = asynTask(tool.RunToolInNewThread) + local svnGuiTool = "TortoiseProc.exe" + local svnTool = tool.SvnPath + + local upCmd = "update --non-interactive " + local checkRevCmd = "info --show-item last-changed-revision " + local log = XUiManager.TipMsgEnqueue + local manualResolveTip = function() + log("如果弹窗有红色列表,请手动解决冲突。如无则请手动关闭") + end + + Panel:AddButton("更新资源包", function() + RunAsyn(function() + log("开始更新打包机已打包资源") + local oldRev = runSvn(checkRevCmd..tool.ProductPath.."File"); + asynRunTool(svnTool, "cleanup "..tool.ProductPath.."File", false) + asynRunTool(svnTool, upCmd..tool.ProductPath.."File", false) + + local newRev = runSvn(checkRevCmd..tool.ProductPath.."File"); + if oldRev ~= newRev then + manualResolveTip() + asynRunTool(svnGuiTool,"/command:resolve /path:"..tool.ProductPath.."File", true) + + XLuaUiManager.RunMain() + log("资源有更新,已自动重载并返回主界面") + else + log("资源无更新,版本号:"..tonumber(newRev)) + end + + local info = runSvn("log -l 1 --incremental "..tool.ProductPath.."File"); + XUiManager.UiFubenDialogTip("打包机最近打包时间", info) + end ) + end ) + + Panel:AddButton("更新Lua", function() + local oldRev = runSvn(checkRevCmd..tool.ProductPath.."Lua"); + runSvn("update --accept mf "..tool.ProductPath.."Lua") + local newRev = runSvn(checkRevCmd..tool.ProductPath.."Lua"); + if oldRev ~= newRev then + CS.XDebugManager.ReLogin() + log("Lua有更新,已自动热重载并重登") + else + log("Lua无更新,版本号:"..tonumber(newRev)) + end + end ) + + Panel:AddButton("更新配置表", function() + RunAsyn(function() + log("开始更新配置表") + local oldRev = runSvn(checkRevCmd..tool.ProductPath.."Table"); + asynRunTool(svnTool, "cleanup "..tool.ProductPath.."Table", false) + asynRunTool(svnTool, upCmd..tool.ProductPath.."Table", false) + + local newRev = runSvn(checkRevCmd..tool.ProductPath.."Table"); + if oldRev ~= newRev then + manualResolveTip() + asynRunTool(svnGuiTool,"/command:resolve /path:"..tool.ProductPath.."Table", true) + + CS.XDebugManager.ReloadLuaTable() + local info = runSvn("log -l 15 --incremental "..tool.ProductPath.."Table"); + + XUiManager.UiFubenDialogTip("更新记录", info) + log("配置表有更新,已自动热重载并重登,请查看近期更新记录") + else + log("配置表无更新,版本号:"..tonumber(newRev)) + end + end ) + end ) +end + +local function AddArchiveFunction() + Panel:AddSubMenu("SVN操作\n(beta)", AddSvnFunction) + Panel:AddSubMenu("萌战相关", AddMoeWar) + Panel:AddButton("开启活动", function() + OpenActivity() + end) + + Panel:AddButton("模拟Android", function() + XUserManager.Platform = XUserManager.PLATFORM.Android + end) + + Panel:AddButton("模拟iOS", function() + XUserManager.Platform = XUserManager.PLATFORM.IOS + end) + + Panel:AddButton("简单分享文字2", function() + CS.XHeroShareAgent.Share( + function(a) + XLog.Debug("share status is ") + XLog.Debug(a) + end, + isShowUi, + CS.ShareType.Text, + heroSharePlatform, + " ", + false, + nil, + nil, + nil, + "简单分享文字", + nil + ) + end) + + Panel:AddButton("分享文字", function() + XPlatformShareManager.ShareByPlatformShareId(platformType, function(a) XLog.Debug("share status is ", a) end, 1, isShowUi) + end) + + Panel:AddButton("分享链接", function() + XPlatformShareManager.ShareByPlatformShareId(platformType, function(a) XLog.Debug("share status is ", a) end, 2, isShowUi) + end) + + Panel:AddButton("分享图片", function() + local runningPlatform = XUserManager.Platform + local dirPath + if runningPlatform == XUserManager.PLATFORM.Android then + dirPath = CS.UnityEngine.Application.persistentDataPath .. "/../../../../DCIM/" + elseif runningPlatform == XUserManager.PLATFORM.IOS then + dirPath = CS.UnityEngine.Application.persistentDataPath .. "/" + elseif runningPlatform == XUserManager.PLATFORM.Win then + dirPath = CS.UnityEngine.Application.persistentDataPath .. "/" + end + if dirPath then + local testPicName = "test.png" + local fileFullPath = dirPath .. testPicName + XLog.Debug("fileFullPath = ", fileFullPath) + XPlatformShareManager.Share(XPlatformShareConfigs.ShareType.Image, platformType, function(a) + XLog.Debug("share status is ", a) + end, fileFullPath, nil, nil, nil, isShowUi) + else + XLog.Debug("dirPath is nil") + end + end) + + Panel:AddButton("打印平台", function() + XLog.Debug("AppPackageName = " .. CS.XAppPlatBridge.GetAppPackageName()) + end, 3) +end + +local function AddInfo() + Panel:AddText("当前服务器", function(TxtServer) + TxtServer.text = string.format("当前服务器\n%s", XServerManager.GetCurServerName()) + end) + TxtVersion = Panel:AddText("当前版本", UpdateVersionInfo) + Panel:AddText("已启动时间", function(TxtTime) + TxtTime.text = string.format("已启动时间\n%s", XUiHelper.GetTime(math.floor(CS.UnityEngine.Time.realtimeSinceStartup) ,XUiHelper.TimeFormatType.DAILY_TASK)) + end) + Panel:AddText("用户名", function(TxtUsername) + TxtUsername.text = string.format("用户名\n%s", XUserManager.UserName or "未登录") + end) +end + +local function AddServerFunction() + local version = 0 + Panel:AddInput("版本号数字", function(value) + version = tonumber(value) or 0 + end) + Panel:AddButton("改版本号", function() + local newVersion = string.format("1.%d.0", version) + CS.XRemoteConfig.SetVersion(newVersion) + UpdateVersionInfo() + if version == 0 then + XUiManager.TipMsgEnqueue("版本号被改为"..newVersion.."主干。如需切换到分支,输入单个数字即可,例如输入20表示\"1.20分支\"") + else + XUiManager.TipMsgEnqueue("版本号被改为"..newVersion.."分支。如需切换到主干,输入0即可") + end + end) + Panel:AddButton("重置版本号(远程配置)", function() + XUiManager.TipMsg("正在重置远程配置") + CS.XRemoteConfig.Reset() + XScheduleManager.ScheduleOnce(function() + XServerManager.Init() + XUiManager.TipMsgEnqueue("版本号被改为"..CS.XRemoteConfig.ApplicationVersion) + UpdateVersionInfo() + end, 2200) + end) + + local tool = CS.XExternalTool + local serverPath = tool.ProductPath.."Bin/NewServer/Bin/" + Panel:AddButton("开启/重启本地服",function() + tool.RunToolInNewThread(serverPath.."Start.bat",nil, true) + end) + + Panel:AddButton("关闭本地服",function() + tool.RunToolInNewThread(serverPath.."Stop.bat",nil, true) + end) + + Panel:AddButton("本地服清库",function() + XUiManager.SystemDialogTip(CS.XTextManager.GetText("TipTitle"), "是否确定进行清库操作?\n操作后将无法恢复!", XUiManager.DialogType.Normal, nil, function() + tool.RunToolInNewThread(serverPath.."ClearDb.bat",nil, true) + end) + end) +end + +local function AddDebugUse() + local uiName = "UiSet" + Panel:AddInput("界面名称", function(value) + uiName = value + end) + + Panel:AddButton("打开界面", function() + Open(uiName) + end) + + Panel:AddButton("重载Ui配置表", function() + CS.XUiManager.Instance:Reset() + CS.XDebugManager.ReLogin() + end) + ---------新增临时服 begin------------ + local ip + Panel:AddInput("临时服IP:", function(value) + ip = tostring(value) + end) + + Panel:AddButton("新增临时服", function() + local result, desc = XServerManager.InsertTempServer(ip) + if not result then + XUiManager.TipMsg(desc) + else + XUiManager.TipMsg("成功") + end + end) + ---------新增临时服 end------------ + + local keyWord + Panel:AddInput("协议关键字", function(value) + keyWord = value + end) + + Panel:AddButton("添加协议关键字", function() + if string.IsNilOrEmpty(keyWord) then + XUiManager.TipMsg("请输入网络协议关键字") + else + table.insert(XRpc.DebugKeyWords, keyWord) + XUiManager.TipMsg("添加成功,实用功能中开启网络调试日志即可查看") + end + + end) + + Panel:AddButton("清空协议关键字", function() + XRpc.DebugKeyWords = {} + end) + + Panel:AddButton("替换进战Loading界面", function() + XDataCenter.FubenManager.OpenFightLoading = function() + XEventManager.DispatchEvent(XEventId.EVENT_FIGHT_LOADINGFINISHED) + local XArchiveCGEntity = require("XEntity/XArchive/XArchiveCGEntity") + XLuaUiManager.Open("UiArchiveCGDetail", {XArchiveCGEntity.New(106013)}, 1) + end + + XDataCenter.FubenManager.CloseFightLoading = function() + XLuaUiManager.Remove("UiArchiveCGDetail") + end + + XUiManager.TipMsg("进战界面替换成spine动画成功,重登后恢复") + end) +end + +local function AddTestUse() + local guideId = 50102 + Panel:AddInput("引导Id", function(value) + guideId = tonumber(value) + end) + + Panel:AddButton("手动开启引导", function() + XDataCenter.GuideManager:PlayGuide(guideId) + end) + + Panel:AddButton("关闭新手引导", function() + XDataCenter.GuideManager.ResetGuide() + end) + + ---------UI遮罩测试 begin------------ + local maskTime = 0--遮罩计时 + local timeId = nil + + local txtMaskTime = Panel:AddText(string.format("距离上一次遮罩计时:%d秒", maskTime)) + + local updateTxt = function() + if XTool.UObjIsNil(txtMaskTime) then return end + txtMaskTime.text = string.format("距离上一次遮罩计时:%d秒", maskTime) + end + + local reset = function() + maskTime = 0 + if timeId then + XScheduleManager.UnSchedule(timeId) + timeId = nil + end + end + + local addTimer = function() + timeId = XScheduleManager.ScheduleForever(function() + if XTool.UObjIsNil(txt) then + reset() + return + end + maskTime = maskTime + 1 + updateTxt() + end, XScheduleManager.SECOND) + end + + Panel:AddButton("添加UI遮罩", function() + reset() + updateTxt() + addTimer() + XLuaUiManager.SetMask(true) + end) + + Panel:AddButton("取消UI遮罩", function() + updateTxt() + XLuaUiManager.SetMask(false) + end) + ---------UI遮罩测试 end------------ + ---------LUA内存 begin------------ + Panel:AddButton("开始记录LUA内存", function() + XLuaMemoryMonitor.StartRecordAlloc() + end) + + Panel:AddButton("结束记录LUA内存", function() + XLuaMemoryMonitor.StopRecordAlloc() + end) + ---------LUA内存 end------------ + ---------机器人配置调试 begin------------ + --[[ + 显示武器共鸣技能、意识共鸣技能、意识超频技能增加的生命/会心/防御/攻击数值 + 显示成员当前的战斗力 + 显示伙伴当前的战力、攻击力数值 + ]] + local robotId = 0 + Panel:AddInput("机器人Id", function(value) + robotId = tonumber(value) + end) + + Panel:AddButton("查看机器人数据", function() + if not XTool.IsNumberValid(robotId) then + XUiManager.TipMsg("请先输入robotId!") + return + end + + if not XRobotManager.CheckRobotExist(robotId) then + XUiManager.TipMsg("robotId不正确,找不到对应配置,robotId: " .. robotId .. ", 配置路径: " .. XRobotManager.GetConfigPath()) + return + end + + local partner = XRobotManager.GetRobotPartner(robotId) + local partnerAttr = not XTool.IsTableEmpty(partner) and partner:GetPartnerAttrMap(partner:GetLevel()) + local equipResonanceAttr = XRobotManager.GetRobotResonanceAbilityList(robotId) + local equipAwakenAttr = XRobotManager.GetRobotAwakenAbilityList(robotId) + + local content = string.format( + [[ + 机器人战力: %d\n + 机器人伙伴战力: %d\n + 机器人伙伴攻击力: %d\n + 武器/意识共鸣增加属性值: %s\n + 意识超频增加属性值: %s\n + ]] + , XRobotManager.GetRobotAbility(robotId) + , XRobotManager.GetRobotPartnerAbility(robotId) + , not XTool.IsTableEmpty(partnerAttr) and partnerAttr[1].Value or 0 + , not XTool.IsTableEmpty(equipResonanceAttr) and "详见LOG" or "空" + , not XTool.IsTableEmpty(equipAwakenAttr) and "详见LOG" or "空" + ) + XUiManager.UiFubenDialogTip("机器人数据", content) + if not XTool.IsTableEmpty(equipResonanceAttr) then + XLog.Debug("机器人Id: " .. robotId .. ", 武器/意识共鸣增加属性值: ", equipResonanceAttr) + end + if not XTool.IsTableEmpty(equipAwakenAttr) then + XLog.Debug("机器人Id: " .. robotId .. ", 意识超频增加属性值: ", equipAwakenAttr) + end + end) + + local XRobot = require("XEntity/XRobot/XRobot") + XRobot.New(1001) + ---------机器人配置调试 end------------ +end + + +local function AddPlannerUse() + local cueId + local typeId + Panel:AddInput("CueId", function(value) + cueId = tonumber(value) + end) + Panel:AddInput("音频类型", function(value) + typeId = tonumber(value) + end) + + local btnPlay = Panel:AddButton("播放音效", function() + if not cueId or not typeId then + XUiManager.TipMsg("请填写CueId和音频类型(1->BGM、2->音效、3->CV)后使用,例如填写1020、2将播放进入战斗音效") + return + end + CS.XAudioManager.StopAll() + XSoundManager.PlayFunc[typeId](cueId) + end) + + if btnPlay then + btnPlay.transform:GetComponent("XUguiPlaySound").enabled = false + end + + Panel:AddButton("关闭音效", function() + CS.XAudioManager.StopAll() + end) + + + local skipId + Panel:AddInput("Skip跳转Id", function(value) + skipId = tonumber(value) + end) + + Panel:AddButton("开始跳转", function() + if skipId then + XFunctionManager.SkipInterface(tonumber(skipId)) + else + XUiManager.TipMsg("请输入正确的SkipId后操作") + end + end) +end + +--------------Ui组件创建 begin---------------- +function XGmTestManager.Init() + Panel = CS.XDebugManager.DebuggerGm + Panel:AddSubMenu("当前信息", AddInfo, true) + Panel:AddSubMenu("服务器", AddServerFunction, true) + Panel:AddSubMenu("开发专用", AddDebugUse) + Panel:AddSubMenu("测试专用", AddTestUse) + Panel:AddSubMenu("策划专用", AddPlannerUse) + Panel:AddSubMenu("归档功能", AddArchiveFunction) +end +--------------Ui组件创建 end---------------- \ No newline at end of file diff --git a/Resources/Scripts/XManager/XGoodsCommonManager.lua b/Resources/Scripts/XManager/XGoodsCommonManager.lua new file mode 100644 index 00000000..89c8ea1d --- /dev/null +++ b/Resources/Scripts/XManager/XGoodsCommonManager.lua @@ -0,0 +1,676 @@ +XGoodsCommonManager = XGoodsCommonManager or {} + +XGoodsCommonManager.QualityType = { + White = 1, + Greed = 2, + Blue = 3, + Purple = 4, + Gold = 5, + Red = 6, + Red1 = 7 +} + + +local GoodsName = { + [XArrangeConfigs.Types.Item] = function(templateId) + return XDataCenter.ItemManager.GetItemName(templateId) + end, + + [XArrangeConfigs.Types.Character] = function(templateId) + return XCharacterConfigs.GetCharacterName(templateId) + end, + + [XArrangeConfigs.Types.Weapon] = function(templateId) + return XDataCenter.EquipManager.GetEquipName(templateId) + end, + + [XArrangeConfigs.Types.Wafer] = function(templateId) + return XDataCenter.EquipManager.GetEquipName(templateId) + end, + + [XArrangeConfigs.Types.Fashion] = function(templateId) + return XDataCenter.FashionManager.GetFashionName(templateId) + end, + + [XArrangeConfigs.Types.BaseEquip] = function(templateId) + return XDataCenter.BaseEquipManager.GetBaseEquipName(templateId) + end, + + [XArrangeConfigs.Types.Furniture] = function(templateId) + return XFurnitureConfigs.GetFurnitureNameById(templateId) + end, + + [XArrangeConfigs.Types.DormCharacter] = function(templateId) + return XDormConfig.GetDormCharacterRewardNameById(templateId) + end, + + [XArrangeConfigs.Types.ChatEmoji] = function(templateId) + return XDataCenter.ChatManager.GetEmojiName(templateId) + end, + + [XArrangeConfigs.Types.WeaponFashion] = function(templateId) + return XWeaponFashionConfigs.GetFashionName(templateId) + end, + + [XArrangeConfigs.Types.Collection] = function(templateId) + return XMedalConfigs.GetCollectionNameById(templateId) + end, + + [XArrangeConfigs.Types.Background] = function(templateId) + return XPhotographConfigs.GetBackgroundNameById(templateId) + end, + + [XArrangeConfigs.Types.Partner] = function(templateId) + return XPartnerConfigs.GetPartnerTemplateName(templateId) + end, + + [XArrangeConfigs.Types.Nameplate] = function(templateId) + return XMedalConfigs.GetNameplateName(templateId) + end, +} + +local GoodsQuality = { + [XArrangeConfigs.Types.Item] = function(templateId) + return XDataCenter.ItemManager.GetItemQuality(templateId) + end, + + [XArrangeConfigs.Types.Character] = function() + return XGoodsCommonManager.QualityType.Gold + end, + + [XArrangeConfigs.Types.Weapon] = function(templateId) + return XDataCenter.EquipManager.GetEquipQuality(templateId) + end, + + [XArrangeConfigs.Types.Wafer] = function(templateId) + return XDataCenter.EquipManager.GetEquipQuality(templateId) + end, + + [XArrangeConfigs.Types.Fashion] = function(templateId) + return XDataCenter.FashionManager.GetFashionQuality(templateId) + end, + + [XArrangeConfigs.Types.BaseEquip] = function(templateId) + return XDataCenter.BaseEquipManager.GetBaseEquipQuality(templateId) + end, + + [XArrangeConfigs.Types.DormCharacter] = function(templateId) + return XDormConfig.GetDormCharacterRewardQualityById(templateId) + end, + + [XArrangeConfigs.Types.WeaponFashion] = function(templateId) + return XWeaponFashionConfigs.GetFashionQuality(templateId) + end, + + [XArrangeConfigs.Types.Collection] = function(templateId) + return XMedalConfigs.GetCollectionDefaultQualityById(templateId) + end, + + [XArrangeConfigs.Types.Background] = function(templateId) + return XPhotographConfigs.GetBackgroundQualityById(templateId) + end, + + [XArrangeConfigs.Types.Partner] = function(templateId) + return XPartnerConfigs.GetPartnerTemplateQuality(templateId) + end, + + [XArrangeConfigs.Types.Nameplate] = function(templateId) + return XMedalConfigs.GetNameplateQuality(templateId) + end, +} + +local GoodsIcon = { + [XArrangeConfigs.Types.Item] = function(templateId) + return XDataCenter.ItemManager.GetItemIcon(templateId) + end, + + [XArrangeConfigs.Types.Character] = function(templateId) + return XDataCenter.CharacterManager.GetCharRoundnessHeadIcon(templateId) + end, + + [XArrangeConfigs.Types.Weapon] = function(templateId) + return XDataCenter.EquipManager.GetEquipIconPath(templateId) + end, + + [XArrangeConfigs.Types.Wafer] = function(templateId) + return XDataCenter.EquipManager.GetEquipIconPath(templateId) + end, + + [XArrangeConfigs.Types.Fashion] = function(templateId) + return XDataCenter.FashionManager.GetFashionIcon(templateId) + end, + + [XArrangeConfigs.Types.BaseEquip] = function(templateId) + return XDataCenter.BaseEquipManager.GetBaseEquipIcon(templateId) + end, + + [XArrangeConfigs.Types.Furniture] = function(templateId) + return XFurnitureConfigs.GetFurnitureIconById(templateId) + end, + [XArrangeConfigs.Types.DormCharacter] = function(templateId) + return XDormConfig.GetDormCharacterRewardIconById(templateId) + end, + + [XArrangeConfigs.Types.ChatEmoji] = function(templateId) + return XDataCenter.ChatManager.GetEmojiIcon(templateId) + end, + + [XArrangeConfigs.Types.WeaponFashion] = function(templateId) + return XWeaponFashionConfigs.GetFashionIcon(templateId) + end, + + [XArrangeConfigs.Types.Collection] = function(templateId) + return XMedalConfigs.GetCollectionIconById(templateId) + end, + + [XArrangeConfigs.Types.Background] = function(templateId) + return XPhotographConfigs.GetBackgroundBigIconById(templateId) + end, + + [XArrangeConfigs.Types.Partner] = function(templateId) + return XPartnerConfigs.GetPartnerTemplateIcon(templateId) + end, + + [XArrangeConfigs.Types.Nameplate] = function(templateId) + return XMedalConfigs.GetNameplateIcon(templateId) + end, +} + +local GoodsDescription = { + [XArrangeConfigs.Types.Item] = function(templateId) + return XDataCenter.ItemManager.GetItemDescription(templateId) + end, + + [XArrangeConfigs.Types.Character] = function(templateId) + return XCharacterConfigs.GetCharacterIntro(templateId) + end, + + [XArrangeConfigs.Types.Fashion] = function(templateId) + return XDataCenter.FashionManager.GetFashionDesc(templateId) + end, + + [XArrangeConfigs.Types.Weapon] = function(templateId) + return XDataCenter.EquipManager.GetEquipDescription(templateId) + end, + + [XArrangeConfigs.Types.Wafer] = function(templateId) + return XDataCenter.EquipManager.GetEquipDescription(templateId) + end, + + [XArrangeConfigs.Types.BaseEquip] = function(templateId) + return XDataCenter.BaseEquipManager.GetBaseEquipDesc(templateId) + end, + + [XArrangeConfigs.Types.Furniture] = function(templateId) + return XFurnitureConfigs.GetFurnitureDescriptionById(templateId) + end, + + [XArrangeConfigs.Types.HeadPortrait] = function(templateId) + return XDataCenter.HeadPortraitManager.GetHeadPortraitDescriptionById(templateId) + end, + + [XArrangeConfigs.Types.DormCharacter] = function(templateId) + return XDormConfig.GetDormDescriptionRewardCharIdById(templateId) + end, + + [XArrangeConfigs.Types.ChatEmoji] = function(templateId) + return XDataCenter.ChatManager.GetEmojiDescription(templateId) + end, + + [XArrangeConfigs.Types.WeaponFashion] = function(templateId) + return XWeaponFashionConfigs.GetFashionDesc(templateId) + end, + + [XArrangeConfigs.Types.Collection] = function(templateId) + return XMedalConfigs.GetCollectionDescById(templateId) + end, + + [XArrangeConfigs.Types.Background] = function(templateId) + return XPhotographConfigs.GetBackgroundDescriptionById(templateId) + end, + + [XArrangeConfigs.Types.Partner] = function(templateId) + return XPartnerConfigs.GetPartnerTemplateGoodsDesc(templateId) + end, + + [XArrangeConfigs.Types.Nameplate] = function(templateId) + return XMedalConfigs.GetNameplateDescription(templateId) + end, +} + +local GoodsWorldDesc = { + [XArrangeConfigs.Types.Item] = function(templateId) + return XDataCenter.ItemManager.GetItemWorldDesc(templateId) + end, + + [XArrangeConfigs.Types.Fashion] = function(templateId) + return XDataCenter.FashionManager.GetFashionWorldDescription(templateId) + end, + + [XArrangeConfigs.Types.HeadPortrait] = function(templateId) + return XDataCenter.HeadPortraitManager.GetHeadPortraitWorldDescById(templateId) + end, + + [XArrangeConfigs.Types.DormCharacter] = function(templateId) + return XDormConfig.GetDormWorldDescriptionRewardCharIdById(templateId) + end, + + [XArrangeConfigs.Types.ChatEmoji] = function(templateId) + return XDataCenter.ChatManager.GetEmojiWorldDesc(templateId) + end, + + [XArrangeConfigs.Types.WeaponFashion] = function(templateId) + return XWeaponFashionConfigs.GetFashionWorldDescription(templateId) + end, + + [XArrangeConfigs.Types.Collection] = function(templateId) + return XMedalConfigs.GetCollectionWorldDescById(templateId) + end, + + [XArrangeConfigs.Types.Background] = function(templateId) + return XPhotographConfigs.GetBackgroundWorldDescriptionById(templateId) + end, + + [XArrangeConfigs.Types.Partner] = function(templateId) + return XPartnerConfigs.GetPartnerTemplateGoodsWorldDesc(templateId) + end, + + -- [XArrangeConfigs.Types.Nameplate] = function(templateId) + -- return XMedalConfigs.GetNameplateDescription(templateId) + -- end, +} + +local GoodsSkipIdParams = { + [XArrangeConfigs.Types.Item] = function(templateId) + return XDataCenter.ItemManager.GetItemSkipIdParams(templateId) + end, + + [XArrangeConfigs.Types.Fashion] = function(templateId) + return XDataCenter.FashionManager.GetFashionSkipIdParams(templateId) + end, + + [XArrangeConfigs.Types.WeaponFashion] = function(templateId) + return XWeaponFashionConfigs.GetFashionSkipIdParams(templateId) + end, +} + +local GoodsCurrentCount = { + [XArrangeConfigs.Types.Item] = function(templateId) + return XDataCenter.ItemManager.GetCount(templateId) + end, + + [XArrangeConfigs.Types.Character] = function(templateId) + return XDataCenter.CharacterManager.IsOwnCharacter(templateId) and 1 or 0 + end, + + [XArrangeConfigs.Types.Weapon] = function(templateId) + return XDataCenter.EquipManager.GetEquipCount(templateId) + end, + + [XArrangeConfigs.Types.Wafer] = function(templateId) + return XDataCenter.EquipManager.GetEquipCount(templateId) + end, + + [XArrangeConfigs.Types.Fashion] = function(templateId) + return XDataCenter.FashionManager.CheckHasFashion(templateId) and 1 or 0 + end, + + [XArrangeConfigs.Types.BaseEquip] = function(templateId) + return XDataCenter.BaseEquipManager.GetBaseEquipCount(templateId) + end, + + [XArrangeConfigs.Types.Furniture] = function(templateId) + return XDataCenter.FurnitureManager.GetTemplateCount(templateId) + end, + + [XArrangeConfigs.Types.WeaponFashion] = function(templateId) + return XDataCenter.WeaponFashionManager.CheckHasFashion(templateId) and 1 or 0 + end, + + [XArrangeConfigs.Types.Collection] = function(templateId) + return XDataCenter.MedalManager.CheckScoreTitleIsHaveById(templateId) and 1 or 0 + end, + + [XArrangeConfigs.Types.Background] = function(templateId) + return XDataCenter.PhotographManager.CheckSceneIsHaveById(templateId) and 1 or 0 + end, + + [XArrangeConfigs.Types.HeadPortrait] = function(templateId) + return XDataCenter.HeadPortraitManager.CheckIsUnLockHead(templateId) and 1 or 0 + end, + + [XArrangeConfigs.Types.Partner] = function(templateId) + return XDataCenter.PartnerManager.GetPartnerCountByTemplateId(templateId) + end, + + [XArrangeConfigs.Types.Nameplate] = function(templateId) + return XDataCenter.MedalManager.CheckNameplateGroupUnluck(XMedalConfigs.GetNameplateGroup(templateId)) and 1 or 0 + end, +} + +--==============================-- +--desc: 通用物品名字获取 +--@templateId: 配置表id +--@return 物品名 +--==============================-- +function XGoodsCommonManager.GetGoodsName(templateId) + local arrangeType = XArrangeConfigs.GetType(templateId) + return GoodsName[arrangeType] and GoodsName[arrangeType](templateId) or nil +end + +--==============================-- +--desc: 通用物品默认品质 +--@templateId: 配置表id +--@return 物品品质 +--==============================-- +function XGoodsCommonManager.GetGoodsDefaultQuality(templateId) + local arrangeType = XArrangeConfigs.GetType(templateId) + return GoodsQuality[arrangeType] and GoodsQuality[arrangeType](templateId) or nil +end + +--==============================-- +--desc: 通用物品Icon +--@templateId: 配置表id +--@args: 额外参数 +--@return 物品Icon +--==============================-- +function XGoodsCommonManager.GetGoodsIcon(templateId) + local arrangeType = XArrangeConfigs.GetType(templateId) + return GoodsIcon[arrangeType] and GoodsIcon[arrangeType](templateId) or nil +end + +--==============================-- +--desc: 通用物品描述 +--@templateId: 配置表id +--@return 物品描述 +--==============================-- +function XGoodsCommonManager.GetGoodsDescription(templateId) + local arrangeType = XArrangeConfigs.GetType(templateId) + return GoodsDescription[arrangeType] and GoodsDescription[arrangeType](templateId) or nil +end + +--==============================-- +--desc: 通用物品世界观描述 +--@templateId: 配置表id +--@return 世界观描述 +--==============================-- +function XGoodsCommonManager.GetGoodsWorldDesc(templateId) + local arrangeType = XArrangeConfigs.GetType(templateId) + return GoodsWorldDesc[arrangeType] and GoodsWorldDesc[arrangeType](templateId) or nil +end + +--==============================-- +--desc: 通用物品跳转列表,不包括过期跳转 +--@templateId: 配置表id +--@return 跳转列表 +--==============================-- +function XGoodsCommonManager.GetGoodsSkipIdParams(templateId) + local arrangeType = XArrangeConfigs.GetType(templateId) + local goodsSkipIdParams = GoodsSkipIdParams[arrangeType] + if not goodsSkipIdParams then + return nil + end + + local skipIds = {} + local templateSkipIds = GoodsSkipIdParams[arrangeType](templateId) + for _, skipId in ipairs(templateSkipIds) do + if XFunctionManager.CheckSkipInDuration(skipId) then + table.insert(skipIds, skipId) + end + end + + return skipIds +end + +--==============================-- +--desc: 通用物品需要显示的跳转列表 +--包括 在持续时间内的跳转 或 过期但IsShowExplain字段为true 的跳转 +--需要在上层逻辑中判断跳转是否过期,然后执行相应操作 +--@templateId: 配置表id +--@return 跳转列表 +--==============================-- +function XGoodsCommonManager.GetGoodsShowSkipId(templateId) + local arrangeType = XArrangeConfigs.GetType(templateId) + local goodsSkipIdParams = GoodsSkipIdParams[arrangeType] + if not goodsSkipIdParams then + return nil + end + + local showSkipList = {} + local allSkipList = GoodsSkipIdParams[arrangeType](templateId) + for _, skipId in ipairs(allSkipList) do + if XFunctionManager.CheckSkipInDuration(skipId) or XFunctionConfig.GetIsShowExplain(skipId) then + table.insert(showSkipList, skipId) + end + end + + -- 在持续时间内的跳转排前面 + table.sort(showSkipList, function(a, b) + local aIsInDuration = XFunctionManager.CheckSkipInDuration(a) + local bIsInDuration = XFunctionManager.CheckSkipInDuration(b) + return aIsInDuration and not bIsInDuration + end) + + return showSkipList +end + +--==============================-- +--desc: 通用物品当前数量 +--@templateId: 配置表id +--@return 当前数量 +--==============================-- +function XGoodsCommonManager.GetGoodsCurrentCount(templateId) + --战区贡献道具不在背包,需要特殊处理 + if templateId == XArenaConfigs.CONTRIBUTESCORE_ID then + return XDataCenter.ArenaManager.GetContributeScore() + elseif templateId == XChessPursuitConfig.SHOP_COIN_ITEM_ID then + return XDataCenter.ChessPursuitManager.GetSumCoinCount() + elseif templateId == XDataCenter.StrongholdManager.GetBatteryItemId() then + return XDataCenter.StrongholdManager.GetTotalElectricEnergy() + elseif templateId == XDataCenter.ReformActivityManager.GetScoreItemId() then + return XDataCenter.ReformActivityManager.GetAllStageAccumulativeScore() + else + local arrangeType = XArrangeConfigs.GetType(templateId) + return GoodsCurrentCount[arrangeType] and GoodsCurrentCount[arrangeType](templateId) or 0 + end +end + +local GoodsShowParams = {} + +GoodsShowParams[XArrangeConfigs.Types.Item] = function(templateId) + return { + RewardType = XRewardManager.XRewardType.Item, + TemplateId = templateId, + Name = XDataCenter.ItemManager.GetItemName(templateId), + Quality = XDataCenter.ItemManager.GetItemQuality(templateId), + Icon = XDataCenter.ItemManager.GetItemIcon(templateId), + BigIcon = XDataCenter.ItemManager.GetItemBigIcon(templateId) + } +end + +GoodsShowParams[XArrangeConfigs.Types.Character] = function(templateId) + local quality = XCharacterConfigs.GetCharMinQuality(templateId) + + return { + RewardType = XRewardManager.XRewardType.Character, + TemplateId = templateId, + Name = XCharacterConfigs.GetCharacterName(templateId), + TradeName = XCharacterConfigs.GetCharacterTradeName(templateId), + Quality = quality, + QualityIcon = XCharacterConfigs.GetCharQualityIconGoods(quality), + Icon = XDataCenter.CharacterManager.GetCharRoundnessHeadIcon(templateId), + BigIcon = XDataCenter.CharacterManager.GetCharBigRoundnessHeadIcon(templateId), + + } +end + +GoodsShowParams[XArrangeConfigs.Types.Weapon] = function(templateId) + local quality = XDataCenter.EquipManager.GetEquipQuality(templateId) + + return { + RewardType = XRewardManager.XRewardType.Equip, + TemplateId = templateId, + Name = XDataCenter.EquipManager.GetEquipName(templateId), + Quality = quality, + QualityTag = quality > XGoodsCommonManager.QualityType.Gold, + Star = XDataCenter.EquipManager.GetEquipStar(templateId), + Site = XDataCenter.EquipManager.GetEquipSiteByTemplateId(templateId), + Icon = XDataCenter.EquipManager.GetEquipIconPath(templateId), + BigIcon = XDataCenter.EquipManager.GetEquipBigIconPath(templateId) + } +end + +GoodsShowParams[XArrangeConfigs.Types.Wafer] = GoodsShowParams[XArrangeConfigs.Types.Weapon] + +GoodsShowParams[XArrangeConfigs.Types.Fashion] = function(templateId) + return { + RewardType = XRewardManager.XRewardType.Fashion, + TemplateId = templateId, + Count = 1, + Name = XDataCenter.FashionManager.GetFashionName(templateId), + Quality = XDataCenter.FashionManager.GetFashionQuality(templateId), + Icon = XDataCenter.FashionManager.GetFashionIcon(templateId), + BigIcon = XDataCenter.FashionManager.GetFashionBigIcon(templateId), + CharacterIcon = XDataCenter.FashionManager.GetFashionCharacterIcon(templateId) + } +end + +GoodsShowParams[XArrangeConfigs.Types.BaseEquip] = function(templateId) + return { + RewardType = XRewardManager.XRewardType.BaseEquip, + TemplateId = templateId, + Name = XDataCenter.BaseEquipManager.GetBaseEquipName(templateId), + Quality = XDataCenter.BaseEquipManager.GetBaseEquipQuality(templateId), + Icon = XDataCenter.BaseEquipManager.GetBaseEquipIcon(templateId), + BigIcon = XDataCenter.BaseEquipManager.GetBaseEquipBigIcon(templateId) + } +end + +GoodsShowParams[XArrangeConfigs.Types.Furniture] = function(templateId) + local cfg = XFurnitureConfigs.GetFurnitureReward(templateId) + if cfg and cfg.FurnitureId then + return { + RewardType = XRewardManager.XRewardType.Furniture, + TemplateId = cfg.FurnitureId, + Name = XFurnitureConfigs.GetFurnitureNameById(cfg.FurnitureId), + Icon = XFurnitureConfigs.GetFurnitureIconById(cfg.FurnitureId), + BigIcon = XFurnitureConfigs.GetFurnitureBigIconById(cfg.FurnitureId), + } + end +end + +GoodsShowParams[XArrangeConfigs.Types.HeadPortrait] = function(templateId) + return { + RewardType = XRewardManager.XRewardType.HeadPortrait, + TemplateId = templateId, + Name = XDataCenter.HeadPortraitManager.GetHeadPortraitNameById(templateId), + Icon = XDataCenter.HeadPortraitManager.GetHeadPortraitImgSrcById(templateId), + BigIcon = XDataCenter.HeadPortraitManager.GetHeadPortraitImgSrcById(templateId), + Effect = XDataCenter.HeadPortraitManager.GetHeadPortraitEffectById(templateId), + Quality = XDataCenter.HeadPortraitManager.GetHeadPortraitQualityById(templateId), + } +end + +GoodsShowParams[XArrangeConfigs.Types.DormCharacter] = function(templateId) + return { + RewardType = XRewardManager.XRewardType.DormCharacter, + TemplateId = templateId, + Name = XDormConfig.GetDormCharacterRewardNameById(templateId), + Icon = XDormConfig.GetDormCharacterRewardSmallIconById(templateId), + BigIcon = XDormConfig.GetDormCharacterRewardIconById(templateId), + Quality = XDormConfig.GetDormCharacterRewardQualityById(templateId), + } +end + +GoodsShowParams[XArrangeConfigs.Types.ChatEmoji] = function(templateId) + return { + RewardType = XRewardManager.XRewardType.ChatEmoji, + TemplateId = templateId, + Name = XDataCenter.ChatManager.GetEmojiName(templateId), + Icon = XDataCenter.ChatManager.GetEmojiIcon(templateId), + BigIcon = XDataCenter.ChatManager.GetEmojiBigIcon(templateId), + } +end + +GoodsShowParams[XArrangeConfigs.Types.WeaponFashion] = function(templateId) + return { + RewardType = XRewardManager.XRewardType.WeaponFashion, + TemplateId = templateId, + Count = 1, + Name = XWeaponFashionConfigs.GetFashionName(templateId), + Quality = XWeaponFashionConfigs.GetFashionQuality(templateId), + Icon = XWeaponFashionConfigs.GetFashionIcon(templateId), + BigIcon = XWeaponFashionConfigs.GetFashionBigIcon(templateId), + ShopIcon = XWeaponFashionConfigs.GetFashionShopIcon(templateId) + } +end + +GoodsShowParams[XArrangeConfigs.Types.Collection] = function(templateId) + return { + RewardType = XRewardManager.XRewardType.Collection, + TemplateId = templateId, + Name = XMedalConfigs.GetCollectionNameById(templateId), + Quality = XMedalConfigs.GetCollectionDefaultQualityById(templateId), + Icon = XMedalConfigs.GetCollectionIconById(templateId), + BigIcon = XMedalConfigs.GetCollectionIconById(templateId), + LevelIcon = XMedalConfigs.GetCollectionDefaultLevelById(templateId) + } +end + +GoodsShowParams[XArrangeConfigs.Types.Background] = function(templateId) + return { + RewardType = XRewardManager.XRewardType.Background, + TemplateId = templateId, + Name = XPhotographConfigs.GetBackgroundNameById(templateId), + Quality = XPhotographConfigs.GetBackgroundQualityById(templateId), + Icon = XPhotographConfigs.GetBackgroundIconById(templateId), + BigIcon = XPhotographConfigs.GetBackgroundBigIconById(templateId), + } +end + +GoodsShowParams[XArrangeConfigs.Types.Pokemon] = function(templateId) + return { + RewardType = XRewardManager.XRewardType.Pokemon, + TemplateId = templateId, + Name = XPokemonConfigs.GetMonsterName(templateId), + Icon = XPokemonConfigs.GetMonsterHeadIcon(templateId), + } +end + +GoodsShowParams[XArrangeConfigs.Types.Partner] = function(templateId) + local quality = XPartnerConfigs.GetPartnerTemplateQuality(templateId) + return { + RewardType = XRewardManager.XRewardType.Partner, + TemplateId = templateId, + Name = XPartnerConfigs.GetPartnerTemplateName(templateId), + Icon = XPartnerConfigs.GetPartnerTemplateIcon(templateId), + Quality = quality, + QualityIcon = XCharacterConfigs.GetCharQualityIconGoods(quality), + } +end + +GoodsShowParams[XArrangeConfigs.Types.Nameplate] = function(templateId) + return { + RewardType = XRewardManager.XRewardType.Nameplate, + TemplateId = templateId, + Name = XMedalConfigs.GetNameplateName(templateId), + Icon = XMedalConfigs.GetNameplateIcon(templateId), + Quality = XMedalConfigs.GetNameplateQuality(templateId), + } +end +--==============================-- +--desc: 通用物品展示参数 +--@templateId: 配置表id +--@return 物品展示参数 +--==============================-- +function XGoodsCommonManager.GetGoodsShowParamsByTemplateId(templateId) + local arrangeType = XArrangeConfigs.GetType(templateId) + + if not GoodsShowParams[arrangeType] then + local str = "XGoodsCommonManager.GetGoodsShowParamsByTemplateId error: goods type is nonsupport, arrangeType is " + XLog.Error(str .. arrangeType .. " templateId is " .. templateId) + return + end + + return GoodsShowParams[arrangeType](templateId) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XGuardCampManager.lua b/Resources/Scripts/XManager/XGuardCampManager.lua new file mode 100644 index 00000000..0c8e60ac --- /dev/null +++ b/Resources/Scripts/XManager/XGuardCampManager.lua @@ -0,0 +1,390 @@ +local XGuardCampActivityInfo = require("XEntity/XGuardCamp/XGuardCampActivityInfo") +local XGuardActivityNotifyData = require("XEntity/XGuardCamp/XGuardActivityNotifyData") + +XGuardCampManagerCreator = function() + local CSTextManagerGetText = CS.XTextManager.GetText + local mathMax = math.max + local mathMin = math.min + + local GuardActivityInfos = {} + local GlobalData = {} + local LoginTime = -1 --登录时间 + local LastLoginTime = -1 --上次登录时间 + local ActivityOpenStateTimer + local CurrGetGuardCampGlobalDataRequestTimastame = 0 + local GetGuardCampGlobalDataRequestInterval = 10 --获取活动全局数据时间间隔 + local PercentPointList = { + 0.26, + 0.5, + 0.73, + 0.96, + 1 + } + + ---------------------本地接口 begin------------------ + local function UpdateCurrGetGuardCampGlobalDataRequestTimastame() + local serverTimestamp = XTime.GetServerNowTimestamp() + CurrGetGuardCampGlobalDataRequestTimastame = serverTimestamp + GetGuardCampGlobalDataRequestInterval + end + + local function UpdateGlobalData(data) + if not data then return end + if not GlobalData[data.Id] then + GlobalData[data.Id] = XGuardActivityNotifyData.New(data.Id) + end + GlobalData[data.Id]:UpdateData(data) + UpdateCurrGetGuardCampGlobalDataRequestTimastame() + end + + local function UpdateGuardActivityInfo(data) + if not GuardActivityInfos[data.Id] then + GuardActivityInfos[data.Id] = XGuardCampActivityInfo.New(data.Id) + end + GuardActivityInfos[data.Id]:UpdateData(data) + end + + local function UpdateGuardActivityInfos(data) + if not data then return end + for _, v in pairs(data) do + UpdateGuardActivityInfo(v) + end + end + + local function UpdateGuardActivityIsGetReward(activityId, isGetReward) + if GuardActivityInfos[activityId] then + GuardActivityInfos[activityId]:SetIsGetReward(isGetReward) + end + end + + local function StopActivityOpenTimer() + if ActivityOpenStateTimer then + XScheduleManager.UnSchedule(ActivityOpenStateTimer) + end + end + + local function CheckActivityOpenTimer() + StopActivityOpenTimer() + local activityId = XGuardCampConfig.GetActivityId() + local serverTimestamp = XTime.GetServerNowTimestamp() + local _, endActivityTime = XGuardCampConfig.GetActivityTime(activityId) + if endActivityTime > serverTimestamp then + ActivityOpenStateTimer = XScheduleManager.ScheduleForever(function() + serverTimestamp = XTime.GetServerNowTimestamp() + if serverTimestamp >= endActivityTime then + XEventManager.DispatchEvent(XEventId.EVENT_GUARD_CAMP_ACTIVITY_OPEN_STATE_CHANGE) + StopActivityOpenTimer() + end + end, XScheduleManager.SECOND, 0) + end + end + + local function GetFirstOpenActivityRedPointTimestamp() + return XSaveTool.GetData("GuardCampFirstOpenActivityRedPointTimestamp_" .. XPlayer.Id) or 0 + end + + local function CheckUpdateFirstOpenActivityRedPointTimestamp() + local firstOpenActivityRedPointTimestamp = GetFirstOpenActivityRedPointTimestamp() + local activityId = XGuardCampConfig.GetActivityId() + local _, endActivityTime = XGuardCampConfig.GetActivityTime(activityId) + if firstOpenActivityRedPointTimestamp < endActivityTime then + XSaveTool.SaveData("GuardCampFirstOpenActivityRedPointTimestamp_" .. XPlayer.Id, endActivityTime) + end + end + + local function GetSupportTomorrowRedPointTimestamp() + return XSaveTool.GetData("GuardCampSupportTomorrowRedPointTimeStamp_" .. XPlayer.Id) or 0 + end + + local function CheckUpdateSupportTomorrowRedPointTimestamp() + local activityId = XGuardCampConfig.GetActivityId() + local state = XDataCenter.GuardCampManager.GetActivityState(activityId) + if state ~= XGuardCampConfig.ActivityState.SupportOpen then return end + + local supportTomorrowRedPointTimeStamp = GetSupportTomorrowRedPointTimestamp() + local serverTimestamp = XTime.GetServerNowTimestamp() + if serverTimestamp > supportTomorrowRedPointTimeStamp then + XSaveTool.SaveData("GuardCampSupportTomorrowRedPointTimeStamp_" .. XPlayer.Id, XTime.GetSeverTomorrowFreshTime()) + end + end + + local function IsGetGuardCampGlobalDataRequest() + if XDataCenter.GuardCampManager.IsActivityClose() then + return false + end + local serverTimestamp = XTime.GetServerNowTimestamp() + if CurrGetGuardCampGlobalDataRequestTimastame < serverTimestamp then + return true + end + return false + end + ---------------------本地接口 end------------------ + + local XGuardCampManager = {} + + function XGuardCampManager.Init() + XEventManager.AddEventListener(XEventId.EVENT_LOGIN_SUCCESS, function() + if XDataCenter.GuardCampManager.IsActivityClose() then + return + end + local activityId = XGuardCampConfig.GetActivityId() + XGuardCampManager.RequestGetGuardCampGlobalDataSend(activityId, function() + XEventManager.DispatchEvent(XEventId.EVENT_GUARD_CAMP_ACTIVITY_OPEN_STATE_CHANGE) + end) + end) + + XEventManager.AddEventListener(XEventId.EVENT_USER_LOGOUT, function() + StopActivityOpenTimer() + end) + CheckActivityOpenTimer() + end + + function XGuardCampManager.GetSelectCampIdByActivityId(activityId) + local data = GuardActivityInfos[activityId] + return data and data:GetSelectCampId() or 0 + end + + function XGuardCampManager.GetSupportCount(activityId, campId) + local data = GuardActivityInfos[activityId] + return data and data:GetSupportCountByCampId(campId) or 0 + end + + function XGuardCampManager.IsGetReward(activityId) + local data = GuardActivityInfos[activityId] + return data and data:IsGetReward() or false + end + + function XGuardCampManager.GetMaxSupportCount(activityId) + local totalSupportCountCfg = XGuardCampConfig.GetActivityTotalSupportCount(activityId) + local campIdList = XGuardCampConfig.GetCampIdList() + local totalSupportCountInfo = 0 + local campSupportCount + for _, campId in ipairs(campIdList) do + campSupportCount = XGuardCampManager.GetSupportCount(activityId, campId) + totalSupportCountInfo = totalSupportCountInfo + campSupportCount + end + return mathMax(totalSupportCountCfg - totalSupportCountInfo, 0) + end + + function XGuardCampManager.GetPondCountByActivityId(activityId) + local data = GlobalData[activityId] + return data and data:GetPondCount() or 0 + end + + function XGuardCampManager.GetWinCampIdByActivityId(activityId) + local data = GlobalData[activityId] + return data and data:GetWinCampId() or 0 + end + + function XGuardCampManager.GetJoinTotalNum(activityId) + local data = GlobalData[activityId] + return data and data:GetJoinTotalNum() or 0 + end + + function XGuardCampManager.GetJoinPercent(activityId) + local joinTotalNum = XGuardCampManager.GetJoinTotalNum(activityId) + if joinTotalNum == 0 then + return 0 + end + + local joinNumList = XGuardCampConfig.GetActivityJoinNumList(activityId) + local totalJoinNum = #joinNumList + if totalJoinNum == 0 then + return 0 + end + + local supportIndex = #PercentPointList + local currjoinNumCfg = joinNumList[totalJoinNum] + for i = totalJoinNum, 1, -1 do + if joinTotalNum <= joinNumList[i] then + supportIndex = i + currjoinNumCfg = joinNumList[i] + else + break + end + end + + local curPercentPoint = PercentPointList[supportIndex] or 0 + if currjoinNumCfg == 0 then + return curPercentPoint + end + + local preJoinNumCfg = joinNumList[supportIndex - 1] or 0 + local prePercentPoint = PercentPointList[supportIndex - 1] or 0 + local adjacentPercentDiffer = curPercentPoint - prePercentPoint + local joinPercent = (joinTotalNum - preJoinNumCfg) / (currjoinNumCfg - preJoinNumCfg) * adjacentPercentDiffer + prePercentPoint + return joinTotalNum > 0 and mathMin(joinPercent, 1) or 0 + end + + function XGuardCampManager.GetSupportNum(activityId, campId) + local data = GlobalData[activityId] + if not data then + return 0 + end + return data:GetSupportNumByCampId(campId) + end + + function XGuardCampManager.GetJoinNum(activityId, campId) + local data = GlobalData[activityId] + if not data then + return 0 + end + return data:GetJoinNumByCampId(campId) + end + + function XGuardCampManager.CheckRedPoint() + local serverTimestamp = XTime.GetServerNowTimestamp() + if XGuardCampManager.IsFirstOpenView() then + return true + end + + local activityId = XGuardCampConfig.GetActivityId() + local selectCampId = XGuardCampManager.GetSelectCampIdByActivityId(activityId) + local state = XGuardCampManager.GetActivityState(activityId) + local supportTomorrowRedPointTimeStamp = GetSupportTomorrowRedPointTimestamp() + --开启投注期间没有选择阵营,每日红点提醒 + if selectCampId == 0 and state == XGuardCampConfig.ActivityState.SupportOpen and serverTimestamp > supportTomorrowRedPointTimeStamp then + return true + end + + if selectCampId > 0 then + local isGetReward = XGuardCampManager.IsGetReward(activityId) + if state == XGuardCampConfig.ActivityState.DrawLottery and not isGetReward then + return true + end + end + return false + end + + function XGuardCampManager.CheckUpdateRedPointTimeStamp() + CheckUpdateFirstOpenActivityRedPointTimestamp() + CheckUpdateSupportTomorrowRedPointTimestamp() + end + + function XGuardCampManager.IsFirstOpenView() + local serverTimestamp = XTime.GetServerNowTimestamp() + local firstOpenActivityRedPointTimestamp = GetFirstOpenActivityRedPointTimestamp() + return serverTimestamp > firstOpenActivityRedPointTimestamp + end + + --返回当前的开启状态,时间描述,标题,当前状态的时间戳 + function XGuardCampManager.GetActivityState(activityId) + local serverTimestamp = XTime.GetServerNowTimestamp() + local startActivityTime, endActivityTime = XGuardCampConfig.GetActivityTime(activityId) + local startSupporLastTime, endSupporLastTime = XGuardCampConfig.GetActivitySupportLastTime(activityId) + local winCampId = XGuardCampManager.GetWinCampIdByActivityId(activityId) + + local title + if startActivityTime > serverTimestamp or startSupporLastTime > serverTimestamp then + return XGuardCampConfig.ActivityState.UnOpen, XGuardCampConfig.GetSupportOpenTimeStr(activityId), CSTextManagerGetText("GuardCampUnOpenTitle"), startSupporLastTime + end + if startSupporLastTime <= serverTimestamp and endSupporLastTime > serverTimestamp then + return XGuardCampConfig.ActivityState.SupportOpen, "", CSTextManagerGetText("GuardCampSupportOpenTitle"), endSupporLastTime + end + if endSupporLastTime <= serverTimestamp and winCampId == 0 then + return XGuardCampConfig.ActivityState.SupportClose, XGuardCampConfig.GetActivityShowDrawLotteryTime(activityId), CSTextManagerGetText("GuardCampSupportCloseTitle"), endActivityTime + end + if winCampId ~= 0 and endActivityTime > serverTimestamp then + return XGuardCampConfig.ActivityState.DrawLottery, XGuardCampConfig.GetActivityCloseTimeStr(activityId), CSTextManagerGetText("GuardCampCloseTitle"), endActivityTime + end + + return XGuardCampConfig.ActivityState.Close, "", "", 0 + end + + function XGuardCampManager.IsActivityClose() + local activityId = XGuardCampConfig.GetActivityId() + local serverTimestamp = XTime.GetServerNowTimestamp() + local startActivityTime, endActivityTime = XGuardCampConfig.GetActivityTime(activityId) + return serverTimestamp < startActivityTime or serverTimestamp >= endActivityTime + end + + function XGuardCampManager.GetActivityPurchasePackageData(activityId) + local purchasePackageUiType, purchasePackageId = XGuardCampConfig.GetActivityJoinCampPurchasePackage(activityId) + local purchaseData = XDataCenter.PurchaseManager.GetPurchaseData(purchasePackageUiType, purchasePackageId) + if not purchaseData or purchaseData.IsSelloutHide then + purchasePackageUiType, purchasePackageId = XGuardCampConfig.GetActivitySupportCampPurchasePackage(activityId) + purchaseData = XDataCenter.PurchaseManager.GetPurchaseData(purchasePackageUiType, purchasePackageId) + end + return purchaseData + end + ---------------------protocol begin------------------ + --选择守护阵营 + function XGuardCampManager.RequestSelectGuardCampSend(id, campId) + local req = {Id = id, CampId = campId} + XNetwork.Call("SelectGuardCampRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XUiManager.TipText("GuardCampSelectCampSuccess") + end) + end + + --支援阵营 + function XGuardCampManager.RequestSupportGuardCampSend(id, campId, count) + local req = {Id = id, CampId = campId, Count = count} + XNetwork.Call("SupportGuardCampRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XUiManager.TipText("GuardCampSupportCampSuccess") + end) + end + + --领取奖励 + function XGuardCampManager.RequestGetGuardCampRewardSend(id, cb) + local req = {Id = id} + XNetwork.Call("GetGuardCampRewardRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XUiManager.OpenUiObtain(res.RewardList) + UpdateGuardActivityIsGetReward(id, true) + if cb then + cb() + end + end) + end + + --活动全局数据 + function XGuardCampManager.RequestGetGuardCampGlobalDataSend(id, cb) + if not IsGetGuardCampGlobalDataRequest() then return end + local req = {Id = id} + XNetwork.Call("GetGuardCampGlobalDataRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + UpdateGlobalData(res.GlobalData) + if cb then + cb() + end + end) + end + + function XGuardCampManager.NotifyGuardCampLoginData(data) + UpdateGuardActivityInfos(data.GuardActivityInfos) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_GUARD_CAMP_ACTIVITY_DATA_CHANGE) + end + + function XGuardCampManager.NotifyGuardCampActivityInfo(data) + UpdateGuardActivityInfo(data.ActivityInfo) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_GUARD_CAMP_ACTIVITY_DATA_CHANGE) + end + ---------------------protocol end------------------ + + XGuardCampManager.Init() + return XGuardCampManager +end + +---------------------(服务器推送)begin------------------ +XRpc.NotifyGuardCampLoginData = function(data) + XDataCenter.GuardCampManager.NotifyGuardCampLoginData(data) +end + +--选择阵营和应援时通知 +XRpc.NotifyGuardCampActivityInfo = function(data) + XDataCenter.GuardCampManager.NotifyGuardCampActivityInfo(data) +end +---------------------(服务器推送)end-------------------- \ No newline at end of file diff --git a/Resources/Scripts/XManager/XGuideManager.lua b/Resources/Scripts/XManager/XGuideManager.lua new file mode 100644 index 00000000..a54e6e43 --- /dev/null +++ b/Resources/Scripts/XManager/XGuideManager.lua @@ -0,0 +1,518 @@ +XGuideManagerCreator = function() + + local XGuideManager = {} + + -- 引导组记录状态 + XGuideManager.RecordState = { + None = 0, -- + RequestRecord = 1, --请求记录中 + Record = 2, --已记录 + } + + XGuideManager.GuideType = { + Default = 1, + Fight = 2, + } + + local PROTOCOL_REQUEST_NAME = { + ReqOpenGuide = "GuideOpenRequest", + ReqCompleteGuide = "GuideCompleteRequest", + ReqCompleteGuideGroup = "GuideGroupFinishRequest", + } + + -- 该事件类型包括了引导的触发、完成类型 + XGuideManager.GuideEventType = { + TeamLevel = 1, --战队等级:等级 + PassStage = 2, --副本相关:副本id, 是否通关 + CompleteTask = 3, --完成任务:任务id + FunctionOpen = 4, --功能开启:功能id + GainCharacter = 5, --获得角色:角色id + GainEquip = 6, --获得装备:装备id + GainItem = 7, --获得道具:道具id,数量 + CharacterUpgrade = 8, --角色培养:角色id,等级,改造阶段, 晋升等级 + CharacterUpgradeSkill = 9, --角色技能:角色id, 技能id, 等级 + EquipUpgrade = 10, --装备升级:装备id, 等级,突破次数,觉醒等级 + CompleteGuide = 11, --完成引导:引导组id + CompleteGuideStep = 12, --完成步骤:步骤id + OpenPanel = 13, --打开界面:Ui名 + ClosePanel = 14, --关闭界面:UI名 + ClickSpecify = 15, --点击指定区域 + } + + XGuideManager.GroupOpenType = { + FightTeamLevel = 1, --战队等级:等级 + PassStage = 2, --通过副本:副本id + FunctionOpen = 3, --功能开启:功能id + GainCharacter = 4, --获得角色:角色id + GainEquip = 5, --获得装备:装备id + GainItem = 6, --获得道具:道具id + CompleteGuide = 7, --完成引导:引导组id + CompleteTask = 8, --完成任务:任务id + } + + XGuideManager.GroupCompleteType = { + CompleteStep = 1, --步骤结束:步骤id + Stage = 2, --副本相关:副本id, 是否通关 + CompleteTask = 3, --完成任务:任务id + CharacterDevelop = 4, --角色培养:角色id,等级,改造阶段, 晋升等级 + CharacterSkill = 5, --角色技能:角色id, 技能id, 等级 + EquipUpgrade = 6, --装备升级:装备id, 等级,突破次数,觉醒等级 + GainItem = 7, --获得道具:道具id, 数量 + EquipPutOn = 8, --穿装备:装备id + UseItem = 9, --使用道具:道具id,数量 + PartUpgrade = 10, --部件升级:角色id,部件id,部件等级 + TeamChanged = 11, --战斗编队 + CompleteCourse = 12, --完成历程:副本id + GainReward = 13, --领取奖励 :奖励ID + } + + XGuideManager.StepOpenType = { + OpenPanel = 1, --打开界面:Ui名 + ClosePanel = 2, --关闭界面:UI名 + CompleteStep = 3, --完成步骤:步骤id + GainItem = 4, --获得道具:道具id + CompleteTask = 5, --完成任务:任务id + CustomEvent = 6, --自定义消息 :参数 + GainReward = 7, --领取奖励 :奖励ID + } + + XGuideManager.StepCompleteType = { + DefaultClick = 0, --默认:点击 + OpenPanel = 1, --打开界面:UI名 + ClosePanel = 2, --关闭界面:UI名 + GainItem = 3, --获得道具:道具id + CompleteTask = 4, --完成任务:任务id + CustomEvent = 5, --自定义消息 :参数 + GainReward = 6, --领取奖励 :奖励ID + } + + local GuideAgent = nil --引导Agent + + -- local WaitingGuide = nil --当前等激活的引导 + local ActiveGuide = nil --当前引导 + local GuideData = {} -- 玩家引导数据 + local DisableFunction = false --功能屏蔽标记(调试模式时使用) + local IsGuiding = false + + local WaitingGuideList = {} + + function XGuideManager.Init() + XEventManager.AddEventListener(XEventId.EVENT_USER_LOGOUT, XGuideManager.HandleSignOut) + + CsXGameEventManager.Instance:RegisterEvent(CS.XEventId.EVENT_UI_ALLOWOPERATE, function(evt, ui) + XGuideManager.HandleUiOpen(ui[0].UiData.UiName) + end) + + --引导开启 + CsXGameEventManager.Instance:RegisterEvent(XEventId.EVENT_GUIDE_START, XGuideManager.OnGuideStart) + --引导结束 + CsXGameEventManager.Instance:RegisterEvent(XEventId.EVENT_GUIDE_END, XGuideManager.OnGuideEnd) + end + + --初始化 + function XGuideManager.InitGuideData(datas) + ActiveGuide = nil -- 当前引导 + WaitingGuideList = {} + DisableFunction = XMain.IsDebug and XGuideManager.CheckFuncDisable() + for _, v in pairs(datas) do + GuideData[v] = v + end + end + + function XGuideManager.OnGuideStart() + IsGuiding = true + end + + function XGuideManager.OnGuideEnd() + IsGuiding = false + XGuideManager.ResetGuide() + + XEventManager.DispatchEvent(XEventId.EVENT_FUNCTION_EVENT_COMPLETE) + end + + --检测引导开启 + function XGuideManager.CheckGuideOpen() + if DisableFunction then + return false + end + + if ActiveGuide and IsGuiding then + return true + end + + XGuideManager.FindActiveGuide() + + local result = false + local removeIndex = -1 + for i, v in ipairs(WaitingGuideList) do + local waitingGuide = v + if (waitingGuide and waitingGuide.GuideType == XGuideManager.GuideType.Default) then + if XGuideManager.TryActiveGuide(waitingGuide) then + removeIndex = i + result = true + break + end + end + end + + if removeIndex > 0 then + table.remove(WaitingGuideList, removeIndex) + end + + return result + end + + --创建引导主体 + function XGuideManager:CreateGuideAgent() + local guideAgent = CS.UnityEngine.GameObject("GuideAgent") + + GuideAgent = guideAgent:AddComponent(typeof(CS.BehaviorTree.XAgent)) + GuideAgent.ProxyType = "Guide" + GuideAgent:InitProxy() + end + + --开始引导 + function XGuideManager:PlayGuide(id) + if not GuideAgent or not GuideAgent:Exist() then + XGuideManager:CreateGuideAgent() + end + + if id == 50000 then + --CheckPoint: APPEVENT_THIRD_BATTLE_END + XAppEventManager.AppLogEvent(XAppEventManager.CommonEventNameConfig.Third_Battle_End) + end + + GuideAgent.gameObject:SetActive(true) + XLuaBehaviorManager.PlayId(id, GuideAgent) + end + + --检测引导开关 + function XGuideManager.CheckFuncDisable() + return XSaveTool.GetData(XPrefs.GuideTrigger) + end + + function XGuideManager.ChangeFuncDisable(state) + DisableFunction = state + XSaveTool.SaveData(XPrefs.GuideTrigger, DisableFunction) + end + + --重置引导 + function XGuideManager.ResetGuide() + if GuideAgent and GuideAgent:Exist() then + GuideAgent.gameObject:SetActive(false) + + if GuideAgent.Proxy.LuaAgentProxy then + GuideAgent.Proxy.LuaAgentProxy.UiGuide = nil + end + end + + ActiveGuide = nil -- 当前引导 + XLuaUiManager.Close("UiGuide") + end + + function XGuideManager.HandleUiOpen(UiName) + if IsGuiding then + return + end + + local bActive = false + + local removeIndex = -1 + for i, v in ipairs(WaitingGuideList) do + local activeUis = string.Split(v.ActiveUi, '|') + for _, v2 in ipairs(activeUis) do + if v2 == UiName then + bActive = true + break + end + end + + if bActive then + if XGuideManager.TryActiveGuide(v) then + removeIndex = i + break + end + end + + bActive = false + end + + if removeIndex > 0 then + table.remove(WaitingGuideList, removeIndex) + end + end + + --尝试开启引导 + function XGuideManager.TryActiveGuide(guide) + if guide == nil then + return false + end + + -- 远程配置屏蔽引导,除了新手关1、2、3(可以移到CheckGuideOpen方法中) + if XUiManager.IsHideFunc then + return + end + + if not XLoginManager.IsStartGuide() then + return + end + + if guide.GuideType ~= XGuideManager.GuideType.Default then + return false + end + + local bActive = false + + local activeUis = string.Split(guide.ActiveUi, '|') + for _, v in ipairs(activeUis) do + if CsXUiManager.Instance:IsUiShow(v) and CsXUiManager.Instance:FindTopUi(v) then + bActive = true + break + end + end + + if not bActive then + return false + end + + ActiveGuide = guide + XGuideManager:PlayGuide(ActiveGuide.Id) + return true + end + + ---查找激活的引导 + function XGuideManager.FindActiveGuide() + local IsOpen = false + + WaitingGuideList = {} + local guideGroupTemplates = XGuideConfig.GetGuideGroupTemplates() + for _, temp in pairs(guideGroupTemplates) do + if not XGuideManager.CheckIsGuide(temp.Id) and temp.Ignore == 0 then + for _, v in pairs(temp.ConditionId) do + if v and v ~= 0 then + IsOpen = XConditionManager.CheckCondition(v) + if not IsOpen then + break + end + end + end + + if IsOpen then + XGuideManager.SetActiveGuide(temp) + IsOpen = false + end + end + end + end + + --激活引导 + function XGuideManager.SetActiveGuide(guide) + WaitingGuideList = WaitingGuideList or {} + local insetIndex = -1 + if #WaitingGuideList <= 0 then + insetIndex = 1 + end + + for i, v in ipairs(WaitingGuideList) do + if guide.Priority < v.Priority then + insetIndex = i + break + end + end + + if insetIndex <= 0 then + table.insert(WaitingGuideList, guide) + else + table.insert(WaitingGuideList, insetIndex, guide) + end + + -- if (WaitingGuide == nil) then + -- WaitingGuide = guide + -- else + -- if (guide.Priority < WaitingGuide.Priority) then + -- WaitingGuide = guide + -- end + -- end + end + + --完成引导 + -- function XGuideManager.CompleteGuide() + -- if not ActiveGuide then + -- return + -- end + + -- if (IsRecord == XGuideManager.RecordState.Record) then + -- local guideId = ActiveGuide.Id + -- ActiveGuide = nil + -- IsRecord = XGuideManager.RecordState.None + -- end + -- end + + -- 外部调用接口end -- + -- 查询相关begin -- + function XGuideManager.CheckIsGuide(guideId) + if not GuideData then + return false + end + + for _, value in pairs(GuideData) do + if value == guideId then + return true + end + end + + return false + end + + -- 查询相关end -- + -- 获取下一场新手战斗 + function XGuideManager.GetNextGuideFight() + if DisableFunction then + return false + end + if ActiveGuide and IsGuiding then + return false + end + + XGuideManager.FindActiveGuide() + + local result = nil + local removeIndex = -1 + for i, v in ipairs(WaitingGuideList) do + local waitingGuide = v + if (waitingGuide and waitingGuide.GuideType == XGuideManager.GuideType.Fight) then + local cfg = XGuideConfig.GetGuideFightTemplatesById(waitingGuide.Id) + if cfg then + removeIndex = i + result = cfg + break + end + end + end + + if removeIndex > 0 then + ActiveGuide = table.remove(WaitingGuideList, removeIndex) + end + + return result + end + + --是否是战斗引导 + function XGuideManager.CheckIsFightGuide() + if ActiveGuide and ActiveGuide.GuideType == XGuideManager.GuideType.Fight then + return true + end + + return false + end + + --是否正在引导 + function XGuideManager.CheckIsInGuide() + return IsGuiding + end + + --处理登出 + function XGuideManager.HandleSignOut() + XGuideManager.ResetGuide() + if GuideAgent and GuideAgent:Exist() then + CS.UnityEngine.GameObject.Destroy(GuideAgent.gameObject) + GuideAgent = nil + end + end + + -- 消息相关begin -- + function XGuideManager.ReqGuideOpen(guideId, cb) + XNetwork.Call(PROTOCOL_REQUEST_NAME.ReqOpenGuide, { GuideGroupId = guideId }, function(response) + if response.Code ~= XCode.Success then + XUiManager.TipCode(response.Code) + end + + if cb then + cb() + end + end) + end + + function XGuideManager.ReqGuideComplete(guideId, cb) + XNetwork.Call(PROTOCOL_REQUEST_NAME.ReqCompleteGuide, { GuideGroupId = guideId }, function(response) + if response.Code ~= XCode.Success then + XUiManager.TipCode(response.Code) + else + if response.RewardGoodsList then + XUiManager.OpenUiObtain(response.RewardGoodsList, nil) + end + + XGuideManager.OnSyncGuideData(guideId) + + end + + if cb then + cb() + end + end) + end + + function XGuideManager.ReqCompleteGuideGroup(cb) + if not ActiveGuide then + if cb then + cb() + end + return + end + + local groupId = XGuideConfig.GetGuideGroupTemplatesById(ActiveGuide.Id).GroupId + XNetwork.Call(PROTOCOL_REQUEST_NAME.ReqCompleteGuideGroup, { GroupId = groupId }, function(response) + if response.Code ~= XCode.Success then + XUiManager.TipCode(response.Code) + else + if response.RewardGoodsList then + XUiManager.OpenUiObtain(response.RewardGoodsList, nil) + end + XGuideManager.OnSyncGuideGroupData(groupId) + end + if cb then + cb() + end + end) + end + + function XGuideManager.OnSyncGuideGroupData(groupId) + local configData = XGuideConfig.GetGuideGroupTemplates() + for k, v in pairs(configData) do + if v.GroupId == groupId then + GuideData[k] = k + end + end + if ActiveGuide then + local guideType = ActiveGuide.GuideType + if guideType ~= XGuideManager.GuideType.Default then + XEventManager.DispatchEvent(XEventId.EVENT_FUNCTION_EVENT_COMPLETE) + end + end + CsXGameEventManager.Instance:Notify(XEventId.EVENT_GUIDE_COMPLETED_SUCCESS) + end + + function XGuideManager.OnSyncGuideData(guideId) + if DisableFunction then + return + end + + GuideData[guideId] = guideId + if ActiveGuide and (ActiveGuide.Id == guideId) then + local guideType = ActiveGuide.GuideType + if guideType ~= XGuideManager.GuideType.Default then + XEventManager.DispatchEvent(XEventId.EVENT_FUNCTION_EVENT_COMPLETE) + end + end + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_GUIDE_COMPLETED_SUCCESS, guideId) + end + -- 消息相关end -- + XGuideManager.Init() + + return XGuideManager +end + +XRpc.NotifyGuide = function(data) + XDataCenter.GuideManager.OnSyncGuideData(data.GuideGroupId) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XGuildBossManager.lua b/Resources/Scripts/XManager/XGuildBossManager.lua new file mode 100644 index 00000000..7f62ac93 --- /dev/null +++ b/Resources/Scripts/XManager/XGuildBossManager.lua @@ -0,0 +1,919 @@ +XGuildBossManagerCreator = function() + local XGuildBossManager = {} + --保存boss血量,活动时间,总分等相关信息 + local GuildBossInfoData = {} + --保存关卡信息 + local GuildBossLevelData = {} + --保存排行榜相关信息 + --local GuildBossRankData = {} + --boss死后所增加的分数 + local GuildBossDeathAddScore = CS.XGame.Config:GetInt("GuildBossDeathAddScore") + local GuildBossStageAddBuffPoint = CS.XGame.Config:GetInt("GuildBossStageAddBuffPoint")--激活安稳度所需要的次数 + --关卡数量(不包含boss) + local GuildBossStageCount = 7 + --是否需要刷新选关页面数据 + local NeedUpdateStageInfo = false + --本次战斗消减boss血量 + local CurFightBossHp = 0 + --本次战斗获得贡献值 + local CurFightContribute = 0 + --是否有Boss血量宝箱可以领 + local HasBossHpReward = false + --是否有积分宝箱可以领 + local HasScoreReward = false + --是否是从工会页面进入(用于判断是否要在本地记录boss血量) + local IsFirstEnter = false + --当前所选关卡的类型,用于选人页面保存不同的队伍 + local CurSelectStageType = nil + --周长任务刷新时间 + local GuildBossWeeklyTaskTime = nil + local GuildBossNewRewardTime = CS.XGame.Config:GetInt("GuildBossNewRewardDate") --新奖励切换显示时间 + --公会boss血量降为0 + local IsBossDead = nil + local BossDeadEndTime = nil -- 记录hp状态需要用活动结束时间一并记录,防止第二次boss被击败不弹出提示 + local NeedShowBossDeadTip = false + local KilledBossLv = 0 + local IsRegisterEditBattleProxy = false + + local GuildBossRpc = { + GuildBossInfoRequest = "GuildBossInfoRequest", --公会boss主界面信息请求 + GuildBossPlayerRankRequest = "GuildBossPlayerRankRequest", --公会boss成员排行 + GuildBossGuildRankRequest = "GuildBossGuildRankRequest", --公会boss全服排行 + GuildBossActivityRequest = "GuildBossActivityRequest", --活动挑战情况 + GuildBossStageRequest = "GuildBossStageRequest", --请求单个关卡的挑战情况 + GuildBossPlayerStageRankRequest = "GuildBossPlayerStageRankRequest", --请求单个关卡的排行榜 + GuildBossScoreBoxRequest = "GuildBossScoreBoxRequest", --领取积分奖励宝箱 + GuildBossHpBoxRequest = "GuildBossHpBoxRequest", --领取boss血量奖励 + GuildBossLevelRequest = "GuildBossLevelRequest", --设置下期的boss难度等级 + GuildBossSetOrderRequest = "GuildBossSetOrderRequest", --设置公会boss的战术指挥 + GuildBossUploadRequest = "GuildBossUploadRequest", --战斗结束确认上传分数 + } + + local LastSyncGuildRankListTime = 0 --工会总分排行榜List最后刷新时间 + local LastSyncRankListTime = 0 --内部排行榜List最后刷新时间 + local LastSyncStageInfoTime = 0 --关卡详细信息最后刷新时间 + + local SYNC_RANK_LIST_SECOND = 60 --获取排行榜List请求保护时间 + + ---- local function begin ----- + local function RegisterEditBattleProxy() + if IsRegisterEditBattleProxy then return end + IsRegisterEditBattleProxy = true + XUiNewRoomSingleProxy.RegisterProxy(XDataCenter.FubenManager.StageType.GuildBoss, + require("XUi/XUiGuildBoss/XUiGuildBossNewRoomSingle")) + end + + local function Init() + -- 初始化hp的持久化记录 + local hpStr = CS.UnityEngine.PlayerPrefs.GetString(XGuildBossManager.GetBossDeadTipKey(), "") + + if hpStr ~= "" then + local strs = string.Split(hpStr, "|") + local endTime = tonumber(strs[1]) or -1 + local oldHp = tonumber(strs[2]) or -1 + if oldHp ~= -1 then + IsBossDead = (oldHp <= 0) + if IsBossDead and endTime ~= -1 then + BossDeadEndTime = tonumber(endTime) + end + end + end + + RegisterEditBattleProxy() + end + ---- local function end ----- + --Get Begin + --获取boss血量上限 + function XGuildBossManager.GetMaxBossHp() + return GuildBossInfoData.HpMax + end + + --获取boss当前血量 + function XGuildBossManager.GetCurBossHp() + return GuildBossInfoData.HpLeft + end + + --获取挑战记录 + function XGuildBossManager.GetLogs() + return GuildBossInfoData.Logs + end + + --获取剩余时间 + function XGuildBossManager.GetEndTime() + return GuildBossInfoData.EndTime + end + + --获取工会总分数 + function XGuildBossManager.GetTotalScore() + return GuildBossInfoData.TotalScore + end + + --获取关卡信息 + function XGuildBossManager.GetLevelData() + return GuildBossLevelData + end + + --获取关卡信息 + function XGuildBossManager.GetLevelDataByStageId(stageId) + for i = 1, #GuildBossLevelData do + if GuildBossLevelData[i].StageId == stageId then + return GuildBossLevelData[i] + end + end + return nil + end + + --获取历史最高工会总分 + function XGuildBossManager.GetScoreSumBest() + return GuildBossInfoData.ScoreSumBest + end + + --获取当前工会boss等级 + function XGuildBossManager.GetCurBossLevel() + return GuildBossInfoData.BossLevel + end + + --获取下期工会boss等级 + function XGuildBossManager.GetNextBossLevel() + return GuildBossInfoData.BossLevelNext + end + + --获取低浓度区的关卡信息 + function XGuildBossManager.GetLowLevelInfo() + for i = 1, #GuildBossLevelData do + if GuildBossLevelData[i].Type == GuildBossLevelType.Low and GuildBossLevelData[i].Score > 0 then + return GuildBossLevelData[i] + end + end + return nil + end + + --获取高浓度区的关卡信息 + function XGuildBossManager.GetHighLevelInfo() + for i = 1, #GuildBossLevelData do + if GuildBossLevelData[i].Type == GuildBossLevelType.High and GuildBossLevelData[i].Score > 0 then + return GuildBossLevelData[i] + end + end + return nil + end + + --获取boss关卡信息 + function XGuildBossManager.GetBossLevelInfo() + for i = 1, #GuildBossLevelData do + if GuildBossLevelData[i].Type == GuildBossLevelType.Boss then + return GuildBossLevelData[i] + end + end + end + + --获取本期低浓度区分 + function XGuildBossManager.GetLowScore() + for i = 1, #GuildBossLevelData do + if GuildBossLevelData[i].Type == GuildBossLevelType.Low and GuildBossLevelData[i].Score > 0 then + return GuildBossLevelData[i].Score + end + end + return 0 + end + + --获取本期高浓度区分 + function XGuildBossManager.GetHighScore() + for i = 1, #GuildBossLevelData do + if GuildBossLevelData[i].Type == GuildBossLevelType.High and GuildBossLevelData[i].Score > 0 then + return GuildBossLevelData[i].Score + end + end + return 0 + end + + --获取本期boss分 + function XGuildBossManager.GetBossScore() + for i = 1, #GuildBossLevelData do + if GuildBossLevelData[i].Type == GuildBossLevelType.Boss and GuildBossLevelData[i].Score > 0 then + return GuildBossLevelData[i].Score + end + end + return 0 + end + + --获取本期我的总分 + function XGuildBossManager.GetMyTotalScore() + local sumScore = 0 + for i = 1, #GuildBossLevelData do + sumScore = sumScore + GuildBossLevelData[i].Score + end + if GuildBossInfoData.HpLeft == 0 and sumScore > 0 then + sumScore = sumScore + GuildBossDeathAddScore + end + return sumScore + end + + --获取斩杀boss的额外分数 + function XGuildBossManager.GetAdditionalScore() + return GuildBossDeathAddScore + end + + --获取满安稳值所需挑战次数 + function XGuildBossManager.GuildBossStageAddBuffPoint() + return GuildBossStageAddBuffPoint + end + + --获取已领取的积分宝箱id + function XGuildBossManager.GetScoreBoxGot() + return GuildBossInfoData.ScoreBoxGot + end + + --获取已领取的血量奖励id + function XGuildBossManager.GetHpBoxGot() + return GuildBossInfoData.HpBoxGot + end + + --获取当前关卡的战术布局顺序 + --function XGuildBossManager.GetOrderString() + -- local orderString = "" + -- for i = 1, GuildBossStageCount do + -- orderString = orderString .. tostring(GuildBossLevelData[i].Order) + -- end + -- return orderString + --end + + --获取关卡在数据中的位置 + function XGuildBossManager.GetStageDataPos(data) + for i = 1, GuildBossStageCount do + if GuildBossLevelData[i].StageId == data.StageId then + return i + end + end + return -1 + end + + function XGuildBossManager.GetStageCount() + return GuildBossStageCount + end + + --得到某一关限制使用的robotID + function XGuildBossManager.GetStageRobotTab(stageId) + for i = 1, #GuildBossLevelData do + if GuildBossLevelData[i].StageId == stageId then + for j = 1, #GuildBossInfoData.RobotList do + if GuildBossInfoData.RobotList[j].Type == GuildBossLevelData[i].Type then + return GuildBossInfoData.RobotList[j].RobotIds + end + end + end + end + return nil + end + + --获取工会前五 + --function XGuildBossManager.GetGuildBossTopFive() + -- return GuildBossInfoData.TopFive + --end + + --获取我的排名信息 + function XGuildBossManager.GetMyRankData() + return GuildBossInfoData.MyRank + end + + --获取我的排名名次信息 + function XGuildBossManager.GetMyRankNum() + return GuildBossInfoData.MyRankNum + end + + --获取工会的排名信息 + function XGuildBossManager.GetMyGuildRankData() + return GuildBossInfoData.MyGuildRankData + end + + --获取工会的排名名次信息 + function XGuildBossManager.GetMyGuildRankNum() + return GuildBossInfoData.MyGuildRankNum + end + + --获取工会排名 + function XGuildBossManager.GetAllGuildRankList() + return GuildBossInfoData.AllGuildRankList + end + + --获取工会内排名 + function XGuildBossManager.GetAllRankList() + return GuildBossInfoData.AllRankList + end + + --点击关卡的时候获取该关卡的详细信息 + function XGuildBossManager.GetDetailLevelData(stageId) + return GuildBossInfoData.DetailLevelData[stageId] + end + + --获取某关卡的排行榜 + function XGuildBossManager.GetDetailLevelRankData(stageId) + return GuildBossInfoData.DetailLevelRankData[stageId] + end + + --获取log版本号 + function XGuildBossManager.GetLogId() + local logId = 0 + if GuildBossInfoData.Logs ~= nil then + for i = 1, #GuildBossInfoData.Logs do + if GuildBossInfoData.Logs[i].LogId > logId then + logId = GuildBossInfoData.Logs[i].LogId + end + end + end + return logId + end + + --本次战斗消减boss血量 + function XGuildBossManager.GetCurFightBossHp() + return CurFightBossHp + end + + --本次战斗贡献值 + function XGuildBossManager.GetCurFightContribute() + return CurFightContribute + end + + --获取活动版本号 + function XGuildBossManager.GetActivityId() + return GuildBossInfoData.ActivityId + end + + --获取当前所选关卡类型 + function XGuildBossManager.GetCurSelectStageType() + return CurSelectStageType + end + + --获取周长任务刷新时间 + function XGuildBossManager.GetWeeklyTaskTime() + return GuildBossWeeklyTaskTime + end + --Get End + + --Set Begin + --设置优先顺序(GuildBossLevelData.Order) orderData = "1234123" + --function XGuildBossManager.SetOrderData(orderData) + -- --检查合法性 + -- if orderData == nil or string.len(orderData) ~= GuildBossStageCount then + -- for i = 1, GuildBossStageCount do + -- GuildBossLevelData[i].Order = 0 + -- end + -- return + -- end + -- for i = 1, GuildBossStageCount do + -- GuildBossLevelData[i].Order = tonumber(orderData[i]) + -- end + --end + + --是否需要刷新 + function XGuildBossManager.SetNeedUpdateStageInfo(isNeed) + NeedUpdateStageInfo = isNeed + end + + --本次战斗消减boss血量 + function XGuildBossManager.SetCurFightBossHp(hp) + CurFightBossHp = hp + end + + --设置是否有Boss血量宝箱可以领 + function XGuildBossManager.SetBossHpReward(val) + HasBossHpReward = val + end + + --设置是否有积分宝箱可以领 + function XGuildBossManager.SetScoreReward(val) + HasScoreReward = val + end + + --设置是否是从工会页面进入 + function XGuildBossManager.SetFirstEnterMark(val) + IsFirstEnter = val + end + + --设置当前所选关卡类型 + function XGuildBossManager.SetCurSelectStageType(type) + CurSelectStageType = type + end + + --设置周长任务刷新时间 + function XGuildBossManager.SetGuildBossWeeklyTaskTime(time) + GuildBossWeeklyTaskTime = time + end + --Set End + + --other + function XGuildBossManager.GetHpRewardId(id) + local hpRewardData = XGuildBossConfig.HpRewards() + local now = XTime.GetServerNowTimestamp() + return now > GuildBossNewRewardTime and hpRewardData[id].NewRewardId or hpRewardData[id].RewardId + end + + function XGuildBossManager.GetScoreRewardId(id) + local rewardData = XGuildBossConfig.ScoreRewards() + local now = XTime.GetServerNowTimestamp() + return now > GuildBossNewRewardTime and rewardData[id].NewRewardId or rewardData[id].RewardId + end + + --更新是否有奖励可领 + function XGuildBossManager.UpdateReward() + --bossHp宝箱 + local hpRewardData = XGuildBossConfig.HpRewards() + local curBossHpPercent = GuildBossInfoData.HpLeft / GuildBossInfoData.HpMax * 100 + if GuildBossInfoData.HpBoxGot >= #hpRewardData then + HasBossHpReward = false + else + if curBossHpPercent <= hpRewardData[GuildBossInfoData.HpBoxGot + 1].HpPercent then + HasBossHpReward = true + else + HasBossHpReward = false + end + end + --积分宝箱 + HasScoreReward = false + local myTotalScore = XGuildBossManager.GetMyTotalScore() + local scoreBoxGot = GuildBossInfoData.ScoreBoxGot + local rewardData = XGuildBossConfig.ScoreRewards() + for i = 1, #rewardData do + local isGet = false + for _,val in pairs(scoreBoxGot) do + if val == rewardData[i].Id then + isGet = true + break + end + end + if myTotalScore >= rewardData[i].Score and not isGet then + HasScoreReward = true + end + end + XEventManager.DispatchEvent(XEventId.EVENT_GUILDBOSS_HPBOX_CHANGED) + XEventManager.DispatchEvent(XEventId.EVENT_GUILDBOSS_SCOREBOX_CHANGED) + end + + --如果被踢了或者其他需要清除缓存日志的情况 + function XGuildBossManager.ClearLog() + GuildBossInfoData.Logs = nil + end + + --如果被踢了或者其他需要清除奖励信息 + function XGuildBossManager.ClearReward() + HasBossHpReward = false + HasScoreReward = false + XEventManager.DispatchEvent(XEventId.EVENT_GUILDBOSS_HPBOX_CHANGED) + XEventManager.DispatchEvent(XEventId.EVENT_GUILDBOSS_SCOREBOX_CHANGED) + end + + function XGuildBossManager.UpdateLog(newActivityId, logs) + --log + if GuildBossInfoData.ActivityId then + if GuildBossInfoData.ActivityId ~= newActivityId then + GuildBossInfoData.Logs = logs + else + if logs then + if GuildBossInfoData.Logs == nil then + GuildBossInfoData.Logs = logs + else + for i = 1, #logs do + table.insert(GuildBossInfoData.Logs, logs[i]) + end + end + end + end + else + GuildBossInfoData.Logs = logs + end + end + + --是否需要刷新 + function XGuildBossManager.IsNeedUpdateStageInfo() + return NeedUpdateStageInfo + end + + --是否有奖励可以领 + function XGuildBossManager.IsReward() + return HasBossHpReward or HasScoreReward + end + + --是否有Boss血量宝箱可以领 + function XGuildBossManager.IsBossHpReward() + return HasBossHpReward + end + + --是否有积分宝箱可以领 + function XGuildBossManager.IsScoreReward() + return HasScoreReward + end + + --本地记录当前BossHp,用于显示不在期间其他人造成的伤害 + function XGuildBossManager.LocalBossHpLog() + local curHp = GuildBossInfoData.HpLeft + local curActivity = GuildBossInfoData.ActivityId + local logHp = XSaveTool.GetData("GuildBossHp" .. XPlayer.Id) + local logActivity = XSaveTool.GetData("GuildBossActivity" .. XPlayer.Id) + if logHp and logActivity and logActivity == curActivity and tonumber(logHp) > curHp and IsFirstEnter then + XUiManager.TipMsg(CS.XTextManager.GetText("GuildBossHpNote", tonumber(logHp) - curHp)) + else + IsFirstEnter = false + end + XSaveTool.SaveData("GuildBossHp" .. XPlayer.Id, curHp) + XSaveTool.SaveData("GuildBossActivity" .. XPlayer.Id, curActivity) + end + + function XGuildBossManager.ParseRankName(rank) + if rank >= 1 then + return (math.modf(rank)) + elseif rank == 0 then + return "" + else + local rankNum = math.modf(rank * 100) + return rankNum .. "%" + end + return "" + end + --other end + + --boss hp tip + function XGuildBossManager.GetBossDeadTipKey() + return "BossDeadTip" .. XPlayer.Id + end + + function XGuildBossManager.UpdateGuildBossHp(hp, bossLv) + if NeedShowBossDeadTip then + return + end + local isDead = (hp <= 0) + + if IsBossDead == isDead then + return + end + + + local endTime = XDataCenter.GuildManager.GuildBossEndTime() + if not endTime then + XLog.Error("初始化[boss被击败]的本地信息失败 endTime = nil, 需确保NotifyGuildData下发时间早于该接口调用") + return + end + + if endTime == BossDeadEndTime then + return + end + + IsBossDead = isDead + + if isDead then + BossDeadEndTime = endTime + KilledBossLv = bossLv + else + BossDeadEndTime = false + end + local saveStr = endTime .. "|" .. (isDead and "0" or "1") + CS.UnityEngine.PlayerPrefs.SetString(XGuildBossManager.GetBossDeadTipKey(), saveStr) + + if isDead and not XLuaUiManager.IsUiShow("UiGuildBossStage") and not XLuaUiManager.IsUiShow("UiGuildBossHall") then + NeedShowBossDeadTip = true + -- XGuildBossManager.CheckShowTip() + end + end + + function XGuildBossManager.CheckShowTip() + if not NeedShowBossDeadTip then + return false + end + if CS.XFight.IsRunning then + return false + end + NeedShowBossDeadTip = false + XLuaUiManager.Open("UiGuildBossTip") + return true + end + + function XGuildBossManager.GetKilledBossLv() + return KilledBossLv or "??" + end + --boss hp tip end + + function XGuildBossManager.PreFight(stage, teamId) + local preFight = {} + local curTeam = XDataCenter.TeamManager.GetPlayerTeamData(teamId) + preFight.CardIds = {} + preFight.StageId = stage.StageId + preFight.CaptainPos = curTeam.CaptainPos + preFight.FirstFightPos = curTeam.FirstFightPos + preFight.RobotIds = {} + for _, v in pairs(curTeam.TeamData or {}) do + if not XRobotManager.CheckIsRobotId(v) then + table.insert(preFight.CardIds, v) + table.insert(preFight.RobotIds, 0) + else + table.insert(preFight.CardIds, 0) + table.insert(preFight.RobotIds, v) + end + end + return preFight + end + --Fight + function XGuildBossManager.FinishFight(settle) + if settle.IsWin then + XLuaUiManager.Open("UiGuildBossFightResult", settle) + else + XLuaUiManager.Open("UiSettleLose", settle) + end + end + --Fight End + + --Request Begin + --公会boss主界面信息请求 + function XGuildBossManager.GuildBossInfoRequest(cb) + XNetwork.Call(GuildBossRpc.GuildBossInfoRequest, {LogId = XGuildBossManager.GetLogId()}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + XGuildBossManager.UpdateLog(res.ActivityId, res.Logs) + GuildBossInfoData.ActivityId = res.ActivityId + GuildBossInfoData.HpMax = res.HpMax + GuildBossInfoData.HpLeft = res.HpLeft + XGuildBossManager.LocalBossHpLog() + GuildBossInfoData.EndTime = res.EndTime + XDataCenter.GuildManager.SetGuildBossEndTime(res.EndTime) --更新入口处的倒计时 + GuildBossInfoData.MyRank = res.MyRank + GuildBossInfoData.MyRankNum = res.MyRankNum + --GuildBossInfoData.TopFive = res.TopFive + GuildBossInfoData.TotalScore = res.TotalScore + + if GuildBossInfoData.MyRank.RankLevel == 0 then + GuildBossInfoData.MyRank.Name = XPlayer.Name + GuildBossInfoData.MyRank.Id = XPlayer.Id + GuildBossInfoData.MyRank.RankLevel = XDataCenter.GuildManager.GetCurRankLevel() + GuildBossInfoData.MyRank.HeadPortraitId = XPlayer.CurrHeadPortraitId + GuildBossInfoData.MyRank.HeadFrameId = XPlayer.CurrHeadFrameId + end + + if cb then + cb() + end + NeedShowBossDeadTip = false + end) + end + + function XGuildBossManager.ReqOpenGuildBossHall() + XDataCenter.GuildBossManager.GuildBossInfoRequest(function() XLuaUiManager.Open("UiGuildBossHall") end) + end + + -- 打开工会boss之前先请求服务端 不能直接通过UiManager打开 + function XGuildBossManager.OpenGuildBossHall() + if not XDataCenter.GuildManager.IsInitGuildData() then + XDataCenter.GuildManager.GetGuildDetails(0, XGuildBossManager.ReqOpenGuildBossHall) + else + XGuildBossManager.ReqOpenGuildBossHall() + end + end + + --Test Debug + function XGuildBossManager.GuildBossTestDamageRequest(stageId, score) + XNetwork.Call("GuildBossTestDamageRequest", {ActivityId = GuildBossInfoData.ActivityId, StageId = stageId, Score = score, CardIds = {1,2,3}}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + if cb then + cb() + end + end) + end + --Test End + + function XGuildBossManager.GuildBossActivityRequest(cb, isForce) + -- 请求间隔保护 + if not isForce then + local now = XTime.GetServerNowTimestamp() + if LastSyncStageInfoTime + SYNC_RANK_LIST_SECOND >= now then + if cb then + cb() + end + return + end + LastSyncStageInfoTime = now + end + XNetwork.Call(GuildBossRpc.GuildBossActivityRequest, {}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + GuildBossInfoData.ActivityId = res.ActivityId + GuildBossInfoData.ScoreSumBest = res.GuildScoreSumBest + GuildBossInfoData.HpMax = res.HpMax + GuildBossInfoData.HpLeft = res.HpLeft + XGuildBossManager.LocalBossHpLog() + GuildBossInfoData.TotalScore = res.GuildScoreSum + GuildBossInfoData.BossLevel = res.BossLevel + GuildBossInfoData.BossLevelNext = res.BossLevelNext + GuildBossInfoData.ScoreBoxGot = res.ScoreBoxGot + GuildBossInfoData.HpBoxGot = res.HpBoxGot --已领取的血量奖励id + GuildBossInfoData.RobotList = res.RobotList --每类关卡限制的robotId + GuildBossLevelData = res.BossList + for i = 1, #GuildBossLevelData do + if string.len(res.Order) < GuildBossStageCount then + GuildBossLevelData[i].Order = 0 + else + GuildBossLevelData[i].Order = tonumber(string.sub(res.Order, i, i)) + end + if GuildBossLevelData[i].Type == GuildBossLevelType.High then + GuildBossLevelData[i].NameOrder = i - 4 + else + GuildBossLevelData[i].NameOrder = i + end + end + XGuildBossManager.UpdateReward() + + if cb then + cb() + end + NeedShowBossDeadTip = false + end) + end + + + function XGuildBossManager.GuildBossLevelRequest(level, cb) + XNetwork.Call(GuildBossRpc.GuildBossLevelRequest, {BossLevelNext = level, ActivityId = GuildBossInfoData.ActivityId}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + GuildBossInfoData.BossLevelNext = level + XEventManager.DispatchEvent(XEventId.EVENT_GUILDBOSS_UPDATEDIFF) + + if cb then + cb() + end + end) + end + + function XGuildBossManager.GuildBossScoreBoxRequest(id, cb) + XNetwork.Call(GuildBossRpc.GuildBossScoreBoxRequest, {BoxId = id}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + XUiManager.OpenUiObtain(res.RewardGoods) + table.insert(GuildBossInfoData.ScoreBoxGot, id) + XGuildBossManager.UpdateReward() + + if cb then + cb() + end + end) + end + + function XGuildBossManager.GuildBossHpBoxRequest(id, cb) + XNetwork.Call(GuildBossRpc.GuildBossHpBoxRequest, {BoxId = id}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + XUiManager.OpenUiObtain(res.RewardGoods) + GuildBossInfoData.HpBoxGot = id + XGuildBossManager.UpdateReward() + + if cb then + cb() + end + end) + end + + function XGuildBossManager.GuildBossSetOrderRequest(data, cb) + XNetwork.Call(GuildBossRpc.GuildBossSetOrderRequest, {Order = data, ActivityId = GuildBossInfoData.ActivityId}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + for i = 1, #GuildBossLevelData do + GuildBossLevelData[i].Order = tonumber(string.sub(data, i, i)) + if GuildBossLevelData[i].Type == GuildBossLevelType.High then + GuildBossLevelData[i].NameOrder = i - 4 + else + GuildBossLevelData[i].NameOrder = i + end + end + XEventManager.DispatchEvent(XEventId.EVENT_GUILDBOSS_UPDATEORDER) + + if cb then + cb() + end + end) + end + + function XGuildBossManager.GuildBossUploadRequest(stageId, cb) + XNetwork.Call(GuildBossRpc.GuildBossUploadRequest, {StageId = stageId}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + CurFightBossHp = res.SubHp + CurFightContribute = res.Contribute + + if cb then + cb() + end + end) + end + + function XGuildBossManager.GuildBossGuildRankRequest(cb) + -- 请求间隔保护 + local now = XTime.GetServerNowTimestamp() + if LastSyncGuildRankListTime + SYNC_RANK_LIST_SECOND >= now then + if cb then + cb() + end + return false + end + LastSyncGuildRankListTime = now + XNetwork.Call(GuildBossRpc.GuildBossGuildRankRequest, {}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + GuildBossInfoData.AllGuildRankList = res.RankList + GuildBossInfoData.MyGuildRankData = res.MyRank + GuildBossInfoData.MyGuildRankNum = res.MyRankNum + + if cb then + cb() + end + end) + return true + end + + function XGuildBossManager.GuildBossPlayerRankRequest(cb, immediate) + -- 请求间隔保护 + local now = XTime.GetServerNowTimestamp() + if not immediate and LastSyncRankListTime + SYNC_RANK_LIST_SECOND >= now then + if cb then + cb() + end + return + end + LastSyncRankListTime = now + XNetwork.Call(GuildBossRpc.GuildBossPlayerRankRequest, {}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + GuildBossInfoData.AllRankList = res.RankList + + if cb then + cb() + end + end) + end + + function XGuildBossManager.GuildBossStageRequest(stageId, cb) + XNetwork.Call(GuildBossRpc.GuildBossStageRequest, {StageId = stageId , LogId = XGuildBossManager.GetLogId()}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + XGuildBossManager.UpdateLog(GuildBossInfoData.ActivityId, res.Logs) + if GuildBossInfoData.DetailLevelData == nil then + GuildBossInfoData.DetailLevelData = {} + end + GuildBossInfoData.DetailLevelData[stageId] = res + if cb then + cb() + end + end) + end + + function XGuildBossManager.GuildBossPlayerStageRankRequest(stageId, cb) + XNetwork.Call(GuildBossRpc.GuildBossPlayerStageRankRequest, {StageId = stageId}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + if GuildBossInfoData.DetailLevelRankData == nil then + GuildBossInfoData.DetailLevelRankData = {} + end + GuildBossInfoData.DetailLevelRankData[stageId] = res.RankList + + if cb then + cb() + end + end) + end + --Request End + + XEventManager.AddEventListener(XEventId.EVENT_LOGIN_SUCCESS, Init) + return XGuildBossManager +end + +return XGuildBossManagerCreator \ No newline at end of file diff --git a/Resources/Scripts/XManager/XGuildManager.lua b/Resources/Scripts/XManager/XGuildManager.lua new file mode 100644 index 00000000..97ad5024 --- /dev/null +++ b/Resources/Scripts/XManager/XGuildManager.lua @@ -0,0 +1,2298 @@ +XGuildManagerCreator = function() + local XGuildManager = {} + local Json = require("XCommon/Json") + + local GuildRpc = { + GuildCreate = "GuildCreateRequest", --创建公会请求 + GuildApply = "GuildApplyRequest", --申请加入公会 + GuildAckApply = "GuildAckApplyRequest", --审批加入公会 + GuildRecruit = "GuildRecruitRequest", --公会招募请求 + GuildListRecommend = "GuildListRecommendRequest", --获取公会推荐列表请求 + GuildListDetail = "GuildListDetailRequest", --获取公会详情 + GuildChangeIcon = "GuildChangeIconRequest", --更改公会头像 + GuildChangeName = "GuildChangeNameRequest", --更改公会名称 + GuildChangeDeclaration = "GuildChangeDeclarationRequest", --更换宣言 + GuildChangeNotice = "GuildChangeNoticeRequest", --更换内部通讯 + GuildChangeRankName = "GuildChangeRankNameRequest", --修改自定义职位 + GuildReleaseWish = "GuildReleaseWishRequest", --发布心愿 + GuildListWish = "GuildListWishRequest", --获取已发布心愿列表 + GuildWishContribute = "GuildWishContributeRequest", --心愿捐献 + GuildChangeRank = "GuildChangeRankRequest", --更换职位 + GuildQuit = "GuildQuitRequest", --退出公会 + GuildKickMember = "GuildKickMemberRequest", --公会踢人 + GuildListNews = "GuildListNewsRequest", --获取公会动态 + GuildGiveLike = "GuildGiveLikeRequest", --点赞 + GuildImpeach = "GuildImpeachRequest", --弹劾 + GuildChangeScript = "GuildChangeScriptRequest", --迎新语,检测屏蔽词 + --GuildListScript = "GuildListScriptRequest", --获取当前自定义话术 暂时弃用 + GuildRecruitRecommend = "GuildRecruitRecommendRequest", --获取招募推荐请求 + GuildListRecruit = "GuildListRecruitRequest", --玩家查询发给自己的招募请求 + GuildAckRecruit = "GuildAckRecruitRequest", --回应招募请求 + GuildTourist = "GuildTouristRequest", --游客模式加入公会 + GuildQuitTourist = "GuildQuitTouristRequest", --退出游客模式 + GuildListApply = "GuildListApplyRequest", --获取公会申请者列表 + GuildLevelUp = "GuildLevelUpRequest", --公会升级 + GuildPayMaintain = "GuildPayMaintainRequest", --公会缴纳维护费用 + GuildGetGift = "GuildGetGiftRequest", --公会获取活跃度礼包 + GuildListChat = "GuildListChatRequest", --服务器聊天缓存请求 + GuildChangeApplyOption = "GuildChangeApplyOptionRequest", --修改申请选项 + GuildGetContributeReward = "GuildGetContributeRewardRequest", --领取上周贡献奖励 + GuildMemberDetail = "GuildMemberDetailRequest", --获取公会成员信息 + GuildListRank = "GuildListRankRequest", --公会排行榜 + GuildFind = "GuildFindRequest", --公会搜索 + GuildListTalent = "GuildListTalentRequest", --公会天赋列表 + GuildUpgradeTalent = "GuildUpgradeTalentRequest", --公会天赋升级 + } + local DataType = { + Int = 1, + String = 2, + } + XGuildManager.GuildFunctional = { + Info = 1, + Member = 2, + Challenge = 3, + Welfare = 4, + } + + local GuildData = nil + + local GuildMemberCount = 0 + local GuildJoinCdEnd = 0 + local CanImpeach = false + local HasImpeach = false + local GuildLastRank = {} + local GuildCurRank = {} + local EnterGuildRightAway = false + local TalentLevelCount = 0 + + local LastReqServeChatTime = 0 + local TalentPoint = 0 + local TalentLevels = {} -- id = level + --发布心愿,请求多少次。 + local WishCount = 0 + --发布心愿,捐赠了多少次。 + local WishContributeCount = 0 + -- 是否可以领取贡献奖励 + local HasContributeReward = 0 + -- 公会推荐招募页数 + local RecommendPageNo = 0 + -- 公会推荐招募数据 + local RecommendPageData = {} + -- 发送过招募的玩家 + local RecommendedPlayers = {} + --推荐公会数据 + local GuildRecommendDatas = {} + --搜索公会数据 + local GuildFindDatas = {} + --自定义话术数据 + local GuildScriptListDatas = {} + local GuildScriptSelectedDatas = {} + --自定义话术 + local GuildScriptAutoChat = nil + local GuildWelcomeWordKey = "GuildWelcomeWordKey" + local GuildWelcomeSelectKey = "GuildWelcomeSelectKey" + local GuildWelcomeAutoChatKey = "GuildWelcomeAutoChatKey" + -- 自定义职位名 + local GuildCustomName = {} + --已发布心愿列表数据 + local GuildWishListDatas = {} + --公会申请者数据 + local GuildApplyListDatas = {} + local HasApplyMember = false + --玩家收到的招募数据 + local GuildRecruitDatas = {} + --未加入公会时公会信息 + local GuildVistorInfoDatas = {} + -- 排行榜 + local GuildRankListDatas = {} + -- 公会动态相关 + local GuildLogList = {} + local GuildLogMaxPage = {} + local GuildNewsCountPerPage = 0 + -- 未加入公会前的邀请 + local HasGuildRecruit = false + -- 公会免费改名机会(被强制改名后获得) + local FreeChangeGuildNameCount = 0 + + function XGuildManager.AsyncGuildData(notifyData) + if not notifyData then return end + HasContributeReward = notifyData.HasContributeReward + FreeChangeGuildNameCount = notifyData.FreeChangeGuildNameCount or 0 + GuildData.GuildId = notifyData.GuildId + GuildData.GuildName = notifyData.GuildName + GuildData.GuildLevel = notifyData.GuildLevel + GuildData.GuildIconId = notifyData.IconId + GuildData.GuildRankLevel = notifyData.GuildRankLevel + GuildData.BossEndTime = notifyData.BossEndTime --工会boss结束时间,用于工会主页面显示倒计时 + HasGuildRecruit = notifyData.HasRecruit + XEventManager.DispatchEvent(XEventId.EVENT_GUILD_RECRUIT_LIST_CHANGED) + if XGuildManager.IsJoinGuild() then + XGuildManager.GetGuildDetails(0) + if EnterGuildRightAway == notifyData.GuildId then + EnterGuildRightAway = nil + XGuildManager.CloseAllAndEnterGuild() + end + -- 获取服务端公会频道缓存 + XGuildManager.GuildListChat(function() + end) + + -- 申请列表 + if XGuildManager.IsGuildAdminister() then + XGuildManager.GetGuildListApply(function() + local applyList = XGuildManager.GetGuildApplyList() + if next(applyList) then + HasApplyMember = true + XEventManager.DispatchEvent(XEventId.EVENT_GUILD_APPLY_LIST_CHANGED) + end + end) + end + -- 获取成员 + local guildId = XGuildManager.GetGuildId() + XGuildManager.GetGuildMembers(guildId) + else + -- 未加入公会,清除自定义职位信息 + GuildData:UpdateAllRankNames() + end + XEventManager.DispatchEvent(XEventId.EVENT_GUILD_NOTICE) + end + + function XGuildManager.AsyncGuildRankName(notifyData) + if not notifyData then return end + GuildData:UpdateAllRankNames(notifyData.AllRankName) + XEventManager.DispatchEvent(XEventId.EVENT_GUILD_ALLRANKNAME_UPDATE) + end + + -- 紧急维护状态更新 + function XGuildManager.AsyncGuildMaintain(notifyData) + if not notifyData then return end + + GuildData.MaintainState = notifyData.MaintainState + GuildData.EmergenceTime = notifyData.EmergenceTime + + XEventManager.DispatchEvent(XEventId.EVENT_GUILD_MAINTAIN_STATE_CHANGED) + end + + -- 公会弹劾状态 + function XGuildManager.AsyncGuildImpeach(notifyData) + if not notifyData then return end + -- notifyData.State 0正常、1可弹劾 + CanImpeach = notifyData.State == 1 + XEventManager.DispatchEvent(XEventId.EVENT_GUILD_LEADER_DISSMISS) + end + + -- 公会建设度更新 + function XGuildManager.AsyncGuildEvent(notifyData) + if not notifyData then return end + local eventType = notifyData.Type + local eventValue = notifyData.Value + local eventValue2 = notifyData.Value2 + local eventStr = notifyData.Str1 + + if XGuildConfig.GuildEventType.Build == eventType then + GuildData.Build = eventValue + XEventManager.DispatchEvent(XEventId.EVENT_GUILD_BUILD_CHANGED) + elseif XGuildConfig.GuildEventType.Contribute == eventType then + GuildData.GuildContributeLeft = eventValue + XEventManager.DispatchEvent(XEventId.EVENT_GUILD_CONTRIBUTE_CHANGED) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_GUILD_CONTRIBUTE_CHANGED) + elseif XGuildConfig.GuildEventType.GiftContribute == eventType then + GuildData.GiftContribute = eventValue + XEventManager.DispatchEvent(XEventId.EVENT_GUILD_GIFT_CONTRIBUTE_CHANGED) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_GUILD_GIFT_CONTRIBUTE_CHANGED) + elseif XGuildConfig.GuildEventType.Level == eventType then + GuildData.GuildLevel = eventValue + local levelTemplate = XGuildConfig.GetGuildLevelDataBylevel(GuildData.GuildLevel) + GuildData.GuildMemberMaxCount = levelTemplate.Capacity + XEventManager.DispatchEvent(XEventId.EVENT_GUILD_LEVEL_CHANGED) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_GUILD_LEVEL_CHANGED) + elseif XGuildConfig.GuildEventType.ApplyChanged == eventType then + HasApplyMember = true + XEventManager.DispatchEvent(XEventId.EVENT_GUILD_APPLY_LIST_CHANGED) + + elseif XGuildConfig.GuildEventType.KickOut == eventType then + + XDataCenter.ChatManager.DeleteGuildChat(GuildData.GuildId) + XDataCenter.GuildBossManager.ClearLog() + XDataCenter.GuildBossManager.ClearReward() + + GuildData.GuildId = 0 + GuildData.GiftGuildLevel = 0 + + if XPlayer.Id == eventValue then return end + if XLuaUiManager.IsUiLoad("UiGuildMain") then + XUiManager.TipMsg(CS.XTextManager.GetText("GuildKickOutByAdministor")) + if CS.XFight.Instance ~= nil then + return + end + if XHomeSceneManager.GetCurrentScene() ~= nil then + XHomeSceneManager.LeaveScene() + end + XLuaUiManager.RunMain() + end + -- if XLuaUiManager.IsUiLoad("UiGuildMain") then + -- XUiManager.TipMsg(CS.XTextManager.GetText("GuildKickOutByAdministor")) + -- if XLuaUiManager.IsUiShow("UiGuildMain") then + -- XLuaUiManager.Close("UiGuildMain") + -- end + -- end + XEventManager.DispatchEvent(XEventId.EVENT_GUILD_GIFT_CONTRIBUTE_CHANGED) + elseif XGuildConfig.GuildEventType.ContributeReward == eventType then + HasContributeReward = eventValue + + XEventManager.DispatchEvent(XEventId.EVENT_GUILD_MEMBER_CONTRIBUTE_CONDITION) + + elseif XGuildConfig.GuildEventType.WeeklyReset == eventType then + -- 清空周贡献 + -- local allMember = XGuildManager.GetMemberList() + -- for _, member in pairs(allMember or {}) do + -- member.ContributeWeek = 0 + -- end + + if XGuildManager.IsJoinGuild() then + XGuildManager.GuildListChat(function() + CsXGameEventManager.Instance:Notify(XEventId.EVENT_GUILD_WEEKLY_RESET) + end) + end + + elseif XGuildConfig.GuildEventType.RankLevelChanged == eventType then + -- 重新请求最新消息,重现请求角色 + local oldRankLevel = GuildData.GuildRankLevel + local needReq = oldRankLevel == XGuildConfig.GuildRankLevel.Leader or eventValue == XGuildConfig.GuildRankLevel.Leader + GuildData.GuildRankLevel = eventValue + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_GUILD_RANKLEVEL_CHANGED) + XEventManager.DispatchEvent(XEventId.EVENT_GUILD_RANKLEVEL_CHANGED) + if XLuaUiManager.IsUiLoad("UiGuildMain") then + XUiManager.TipMsg(CS.XTextManager.GetText("GuildRankLevelChangeNotify", XGuildManager.GetRankNameByLevel(GuildData.GuildRankLevel))) + if XGuildManager.IsGuildAdminister() then + XGuildManager.GetGuildListApply(function() + local applyList = XGuildManager.GetGuildApplyList() + if next(applyList) then + HasApplyMember = true + XEventManager.DispatchEvent(XEventId.EVENT_GUILD_APPLY_LIST_CHANGED) + end + end) + else + HasApplyMember = false + XEventManager.DispatchEvent(XEventId.EVENT_GUILD_APPLY_LIST_CHANGED) + end + + if needReq then--更新 + XGuildManager.GetGuildDetails(0, function() + CsXGameEventManager.Instance:Notify(XEventId.EVNET_GUILD_LEADER_NAME_CHANGED) + end) + end + end + + -- 假如会长->会员,其他->会长,更新成员 + if XLuaUiManager.IsUiLoad("UiGuildRongyu") and needReq then + local guildId = XGuildManager.GetGuildId() + XGuildManager.GetGuildMembers(guildId, function() + XEventManager.DispatchEvent(XEventId.EVNET_GUILD_LEADER_CHANGED) + if XLuaUiManager.IsUiShow("UiPlayerInfo") then + XLuaUiManager.Close("UiPlayerInfo") + end + end) + end + + if XLuaUiManager.IsUiShow("UiPlayerInfo") then + XLuaUiManager.Close("UiPlayerInfo") + end + elseif XGuildConfig.GuildEventType.Talent == eventType then + TalentLevels[eventValue] = eventValue2 + CsXGameEventManager.Instance:Notify(XEventId.EVENT_GUILD_TALENT_ASYNC) + elseif XGuildConfig.GuildEventType.TalentPoint == eventType then + TalentPoint = eventValue + CsXGameEventManager.Instance:Notify(XEventId.EVENT_GUILD_TALENT_ASYNC) + elseif XGuildConfig.GuildEventType.MemberChanged == eventType then + GuildData.GuildMemberCount = eventValue + if XGuildManager.GetGuildScriptAutoChat() then + -- local username = eventStr + XGuildManager.SendGuildScript() + end + XEventManager.DispatchEvent(XEventId.EVENT_GUILD_MEMBERCOUNT_CHANGED) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_GUILD_MEMBERCOUNT_CHANGED) + elseif XGuildConfig.GuildEventType.Recruit == eventType then + HasGuildRecruit = true + XEventManager.DispatchEvent(XEventId.EVENT_GUILD_RECRUIT_LIST_CHANGED) + elseif XGuildConfig.GuildEventType.GuildBossHpBox == eventType then + XDataCenter.GuildBossManager.SetBossHpReward(true) + XEventManager.DispatchEvent(XEventId.EVENT_GUILDBOSS_HPBOX_CHANGED) + XDataCenter.GuildBossManager.UpdateGuildBossHp(eventValue, eventValue2) + elseif XGuildConfig.GuildEventType.GuildBossScoreBox == eventType then + XDataCenter.GuildBossManager.SetScoreReward(true) + XEventManager.DispatchEvent(XEventId.EVENT_GUILDBOSS_SCOREBOX_CHANGED) + elseif XGuildConfig.GuildEventType.GuildBossWeeklyTask == eventType then + XDataCenter.GuildBossManager.SetGuildBossWeeklyTaskTime(eventValue) + elseif XGuildConfig.GuildEventType.FreeChangeName == eventType then + FreeChangeGuildNameCount = FreeChangeGuildNameCount + 1 + end + end + + function XGuildManager.Init() + if not GuildData then + GuildData = XGuildData.New() + end + GuildNewsCountPerPage = CS.XGame.Config:GetInt("GuildNewsCountPerPage") + end + + function XGuildManager.IsInitGuildData() + return GuildData:IsInit() + end + + --所在公会的职务 + function XGuildManager.GetCurRankLevel() + return GuildData.GuildRankLevel + end + + --所在公会的职务是否是管理层 + function XGuildManager.IsGuildAdminister() + return GuildData:IsGuildAdministor() + end + + -- 是否为会长 + function XGuildManager.IsGuildLeader() + return GuildData:IsLeader() + end + + --是否已经加入公会 + function XGuildManager.IsJoinGuild() + return GuildData:IsJoinGuild() + end + + --当前公会职位人数 + function XGuildManager.GetMyGuildPosCount() + -- GetGuildPositionCurAmount + local data = GuildData:GetGuildMembers() + local level = XGuildManager.GetGuildLevel() + local amount = {} + for _, v in pairs(XGuildConfig.GuildRankLevel) do + amount[v] = amount[v] or 0 + end + for _, v in pairs(data) do + amount[v.RankLevel] = amount[v.RankLevel] + 1 + end + return amount + end + + --当前公会职位容量 + function XGuildManager.GetGuildPosCapacity(level, rank) + local rankLevel = XGuildConfig.GuildRankLevel + local guildLevelData = XGuildConfig.GetGuildLevelDataBylevel(level) + if not guildLevelData then + return + end + if rank == rankLevel.Leader then + return 1 + elseif rank == rankLevel.CoLeader then + return guildLevelData.PositionNum[1] + elseif rank == rankLevel.Elder then + return guildLevelData.PositionNum[2] + elseif rank == rankLevel.Member then + return guildLevelData.Capacity + elseif rank == rankLevel.Tourist then + return guildLevelData.PositionNum[3] + end + end + + -- 如果该玩家是在离线时被审批进入了公会,则重新上线前,Data.GuildDetail都不会更新信息,因此采用本地信息判断 + function XGuildManager.CheckMemberOperatePermission(targetId) + local memberList = XDataCenter.GuildManager.GetMemberList() + local isAdministor = XDataCenter.GuildManager.IsGuildAdminister() + local myRankLevel = XDataCenter.GuildManager.GetCurRankLevel() + if memberList[targetId] then + local targetRankLevel = memberList[targetId].RankLevel + return targetRankLevel ~= nil and targetRankLevel > 0 and isAdministor and myRankLevel < targetRankLevel + end + return false + end + + --当前心愿请求数 + function XGuildManager.GetCurWishReqCount() + return WishCount + end + + --累计当前心愿请求数 + function XGuildManager.AddCurWishReqCount() + WishCount = WishCount + 1 + end + + --获取所有公会 + function XGuildManager.GetCurGuildsInfo() + return {} + end + + --获取今天已经捐赠次数 + function XGuildManager.GetCurDonationCount() + return WishContributeCount + end + + --累加今天已经捐赠次数 + function XGuildManager.AddCurDonationCount() + WishContributeCount = WishContributeCount + 1 + end + + --获取总可捐赠次数 + function XGuildManager.GetTotalDonationCount(level) + return XGuildConfig.GetGuildWishContributeMaxCountByLevel(level) + end + + --判断此公会人数是否已经满 + function XGuildManager.IsFullGuild(guildId) + local data = XGuildManager.GetVistorGuildDetailsById(guildId) + if not data then + return true + end + + return data.GuildMemberMaxCount == data.GuildMemberCount + end + + --判断此公会游客数量是否已经满 + function XGuildManager.IsFullGuildVistor(guildId) + local data = XGuildManager.GetVistorGuildDetailsById(guildId) + if not data then + return true + end + + return data.GuildTouristMaxCount == data.GuildTouristCount + end + + --判断自己是不是游客 + function XGuildManager.IsGuildTourist() + return XGuildManager.GetCurRankLevel() == XGuildConfig.GuildRankLevel.Tourist + end + + --已经发布的心愿 + function XGuildManager.GetGuildWishList() + return GuildWishListDatas + end + --处理公会推荐列表数据 + -- int Id; + -- string Name; + -- int IconId; + -- int Level; + -- int MemberCount; + -- int MemberMaxCount; + -- int ContributeIn7Days; + function XGuildManager.HandleGuildRecommendDatas(pageNo, datas) + if datas ~= nil and next(datas) ~= nil then + GuildRecommendDatas[pageNo] = {} + for _, v in pairs(datas) do + if v and v.Id then + table.insert(GuildRecommendDatas[pageNo], v) + end + end + XGuildManager.RecordGuildRecommend(-1) + else + XGuildManager.RecordGuildRecommend(pageNo) + end + end + + function XGuildManager.HandleGuildFindDatas(guildname, datas) + if datas ~= nil and next(datas) ~= nil then + GuildFindDatas[guildname] = {} + for _, v in pairs(datas) do + if v and v.Id then + table.insert(GuildFindDatas[guildname], v) + end + end + end + end + + function XGuildManager.GetGuildFindDatas(guildname) + return GuildFindDatas[guildname] or {} + end + + function XGuildManager.RecordGuildRecommend(pageNo) + XGuildManager.EmptyPageNo = pageNo + end + + function XGuildManager.GetCurGuildRecommend() + return XGuildManager.EmptyPageNo + end + + function XGuildManager.GetGuildRecommendDatas(pageNo) + + local nextPageNo = pageNo + 1 + if GuildRecommendDatas[pageNo] and not GuildRecommendDatas[nextPageNo] then + XDataCenter.GuildManager.GuildListRecommendRequest(nextPageNo, function() + end) + end + + return GuildRecommendDatas[pageNo] or {} + end + + function XGuildManager.ResetGuildRecommendDatas() + GuildRecommendDatas = {} + end + + function XGuildManager.IsNeedRequestRecommendData() + if not next(GuildRecommendDatas) then + return true + end + if XTime.GetServerNowTimestamp() - XGuildManager.PreRequestRecommendTime > XGuildConfig.GuildRequestRecommandTime then + return true + end + + return false + end + + function XGuildManager.ResetPreRequestRecommendTime() + XGuildManager.PreRequestRecommendTime = 0 + end + + function XGuildManager.IsNeedRequestRank() + if not next(GuildRankListDatas) then + return true + end + + if XTime.GetServerNowTimestamp() - XGuildManager.PreRequestGuildListRankTime > XGuildConfig.GuildRequestRankTime then + return true + end + + return false + end + + -- 随机发送迎新语 + function XGuildManager.SendGuildScript() + math.randomseed(os.time()) + local chatData = {} + chatData.ChannelType = ChatChannelType.Guild + chatData.MsgType = ChatMsgType.Normal + chatData.TargetIds = {} + chatData.TargetIds[1] = XGuildManager.GetGuildId() + local welcome = XGuildManager.GetGuildScriptSelectedDatas() + if #welcome == 0 then return end + local content = welcome[math.random(#welcome)] + chatData.Content = content + XDataCenter.ChatManager.SendChat(chatData) + end + + --处理已发布心愿列表数据 + -- string Name; + -- int HeadPortraitId; + -- int RankLevel; + -- int ItemId; + -- int GotCount; + -- int MaxCount; + -- int Seq; + function XGuildManager.HandleListWishDatas(wishesData, wishCount, wishContributeCount) + GuildWishListDatas = {} + if wishesData ~= nil and next(wishesData) ~= nil then + for _, v in pairs(wishesData) do + if v and v.Id then + if XPlayer.Id ~= v.Id then + table.insert(GuildWishListDatas, v) + end + end + end + end + WishCount = wishCount + WishContributeCount = wishContributeCount + end + + function XGuildManager.HandleListRankDatas(type, tabledata, myRankNum) + GuildRankListDatas[type] = {} + local rankFromList = nil + if not (tabledata and next(tabledata)) then return end + for index, v in ipairs(tabledata) do + if v and v.GuildId then + if GuildData.GuildId == v.GuildId then + rankFromList = index + end + v.RankNum = index + v.Type = type + table.insert(GuildRankListDatas[type], v) + end + end + -- 如果榜单中有则优先用榜单的排名 + if rankFromList then + GuildData.GuildRank[type] = rankFromList + -- 如果服务端没有,则本地只能显示百分比 + elseif myRankNum > 0 and myRankNum < 1 then + GuildData.GuildRank[type] = (math.floor(myRankNum * 10000) / 10000) + else + GuildData.GuildRank[type] = 0 + end + end + + function XGuildManager.GetMyGuildRank(type) + return GuildData.GuildRank[type] or 0 + end + + function XGuildManager.GetMyGuildLastRank(type) + if not GuildLastRank[type] then + GuildLastRank[type] = XGuildManager.GetGuildPrefs(XGuildConfig.KEY_LAST_RANK..type, nil, DataType.String) + end + if not GuildLastRank[type] then + return 0 + end + local strTable = string.Split(GuildLastRank[type], '_') + local lastDate, lastRank = strTable[1], strTable[2] + return tonumber(lastRank) or 0 + end + + function XGuildManager.SaveMyGuildCurRank(type) + local date = os.date("%Y%m%d") + local oldCurRank = XGuildManager.GetGuildPrefs(XGuildConfig.KEY_CUR_RANK..type, nil, DataType.String) + local strTable = string.Split(oldCurRank, '_') + local lastDate = strTable[1] or date + -- 已经是旧数据了,需要赋给GuildLastRank + if next(strTable) and tonumber(lastDate) < tonumber(date) then + GuildLastRank[type] = oldCurRank + XGuildManager.SaveGuildPrefs(XGuildConfig.KEY_LAST_RANK..type, GuildLastRank[type], DataType.String) + end + GuildCurRank[type] = string.format( "%s_%.4f", date, XGuildManager.GetMyGuildRank(type)) + XGuildManager.SaveGuildPrefs(XGuildConfig.KEY_CUR_RANK..type, GuildCurRank[type], DataType.String) + end + + function XGuildManager.GetListRankDatas(order) + return GuildRankListDatas[order] + end + + function XGuildManager.EnterGuild() + if not XDataCenter.GuildManager.IsJoinGuild() then + if XGuildManager.IsNeedRequestRecommendData() then + XDataCenter.GuildManager.GuildListRecommendRequest(1, function() + XLuaUiManager.Open("UiGuildRecommendation") + end) + else + XLuaUiManager.Open("UiGuildRecommendation") + end + return + end + + if XGuildManager.IsGuildTourist() then + XDataCenter.GuildManager.GetVistorGuildDetailsReq(GuildData.GuildId, function() + XLuaUiManager.Open("UiGuildVistor") + end) + else + XDataCenter.GuildManager.GetGuildDetails(0, function() + XLuaUiManager.Open("UiGuildMain") + end) + end + end + + -- 用于在未进公会界面前获取公会数据,如已有数据则不再获取 + function XGuildManager.RequestGuildData() + if not XDataCenter.GuildManager.IsJoinGuild() then return end + if not XGuildManager.IsInitGuildData() then + XDataCenter.GuildManager.GetGuildDetails(0) + end + end + + function XGuildManager.CloseAllAndEnterGuild() + XDataCenter.GuildManager.GetGuildDetails(0, function() + XLuaUiManager.PopThenOpen("UiGuildMain") + XLuaUiManager.Remove("UiGuildRecommendation") + end) + end + + + function XGuildManager.EnterGuildTalent() + if XGuildManager.CheckAllTalentLevelMax() then + XDataCenter.GuildManager.GetGuildDetails(0, function() + XLuaUiManager.Open("UiGuildGloryLevel") + end) + else + XGuildManager.GuildTalentListReq(function() + XLuaUiManager.Open("UiGuildSkill") + end) + end + end + + function XGuildManager.HandleGuildListRecruitDatas(datas) + GuildRecruitDatas = {} + if datas ~= nil and next(datas) ~= nil then + for _, v in pairs(datas) do + if v.PlayerId and v.PlayerId ~= XPlayer.Id then + table.insert(GuildRecruitDatas, v) + end + end + end + end + + function XGuildManager.GetGuildListRecruitDatas() + return GuildRecruitDatas + end + + function XGuildManager.IsNeedRequestRecruitData() + if not next(GuildRecruitDatas) then + return true + end + + if XTime.GetServerNowTimestamp() - XGuildManager.PreRequestRecruitTime > XGuildConfig.GuildRequestRecruitTime then + return true + end + + return false + end + + --游客模式退出后,清掉。 + function XGuildManager.QuitVistorClean() + XGuildManager.ClearVistorGuildMembers(GuildData.GuildId) + GuildData.GuildId = 0 + end + + -- RPC + --获取招募推荐请求 + function XGuildManager.GuildRecruitRecommendRequest(pageNo, cb) + XNetwork.Call(GuildRpc.GuildRecruitRecommend, { PageNo = pageNo }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + for _, recruitInfo in pairs(res.RecommendData or {}) do + if not RecommendedPlayers[recruitInfo.PlayerId] then + RecommendPageData[recruitInfo.PlayerId] = recruitInfo + end + end + + if cb then + cb() + end + end) + end + + -- 随机出count个推荐招募,不在ownList中 + function XGuildManager.GetRandomRecommendPlayers() + + local randomRecommend = {} + local playerIdList = {} + local availableCount = 0 + local availableRecommend = {} + for id, recruitInfo in pairs(RecommendPageData) do + if not RecommendedPlayers[id] then + table.insert(playerIdList, id) + availableCount = availableCount + 1 + availableRecommend[id] = recruitInfo + end + end + + if availableCount <= XGuildConfig.RecommendCount then + return availableRecommend + end + -- 需要随机:随机次数尽量少 + math.randomseed(os.time()) + local randomCount = XGuildConfig.RecommendCount + local leftCount = availableCount - XGuildConfig.RecommendCount + local leftPlayers = {} + if leftCount <= XGuildConfig.RecommendCount then + while (leftCount > 0) + do + local index = math.random(1, availableCount) + local playerId = playerIdList[index] + if not leftPlayers[playerId] then + leftPlayers[playerId] = true + leftCount = leftCount - 1 + end + end + for id, recruitInfo in pairs(availableRecommend) do + if not leftPlayers[id] then + randomRecommend[id] = recruitInfo + end + end + return randomRecommend + else + while (randomCount > 0) + do + local randomLength = availableCount - (XGuildConfig.RecommendCount - randomCount) + local index = math.random(1, randomLength) + local playerId = playerIdList[index] + if not randomRecommend[playerId] then + randomRecommend[playerId] = availableRecommend[playerId] + randomCount = randomCount - 1 + -- 随机到的、跟最后一个调换位置 + local temp = playerIdList[randomLength] + playerIdList[index] = temp + playerIdList[randomLength] = playerId + end + end + return randomRecommend + end + end + + --玩家查询发给自己的招募请求 + function XGuildManager.GuildListRecruitRequest(cb) + if XGuildManager.IsNeedRequestRecruitData() then + XNetwork.Call(GuildRpc.GuildListRecruit, {}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XGuildManager.PreRequestRecruitTime = XTime.GetServerNowTimestamp() + XGuildManager.HandleGuildListRecruitDatas(res.Data) + if cb then + cb() + end + end) + else + if cb then + cb() + end + end + end + + --回应招募请求 + function XGuildManager.GuildAckRecruitRequest(guildId, isAgree, playerId, cb) + if not guildId or guildId <= 0 or isAgree == nil then + XLog.Error("XGuildManager.GuildAckRecruitRequest参数错误: 参数guildId是 " .. tostring(guildId) .. " 参数isAgree是" .. tostring(isAgree)) + return + end + + XNetwork.Call(GuildRpc.GuildAckRecruit, { GuildId = guildId, IsAgree = isAgree }, function(res) + local removeIndex = -1 + for k, v in pairs(GuildRecruitDatas or {}) do + if v.PlayerId == playerId and v.GuildId == guildId then + removeIndex = k + break + end + end + + if removeIndex ~= -1 then + table.remove(GuildRecruitDatas, removeIndex) + end + + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + if cb then + cb() + end + return + end + + if isAgree then + XGuildManager.CloseAllAndEnterGuild() + end + + if cb then + cb() + end + end) + end + + --游客模式加入公会 + function XGuildManager.GuildTouristRequest(guildId, cb) + if not guildId or guildId <= 0 then + XLog.Error("XGuildManager.GuildTouristRequest参数错误: 参数guildId是空或者guildId小于等于0, 参数guildId:" .. tostring(guildId)) + return + end + + XNetwork.Call(GuildRpc.GuildTourist, { GuildId = guildId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + GuildData.GuildId = guildId + if cb then + cb() + end + end) + end + + --退出游客模式 + function XGuildManager.GuildQuitTouristRequest(cb) + XNetwork.Call(GuildRpc.GuildQuitTourist, {}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + if cb then + cb() + end + end) + end + + --发布心愿 + function XGuildManager.PublishWishRequest(itemId, cb) + if not itemId then + XLog.Error("XGuildManager.PublishWishRequest参数错误: 参数itemId是空") + return + end + + XNetwork.Call(GuildRpc.GuildReleaseWish, { ItemId = itemId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + XGuildManager.AddCurWishReqCount() + if cb then + cb() + end + end) + end + + --捐赠 + function XGuildManager.DonateRequest(playerId, seq, itemId, cb) + XNetwork.Call(GuildRpc.GuildWishContribute, { PlayerId = playerId, Seq = seq, ItemId = itemId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + XGuildManager.AddCurDonationCount() + if cb then + cb() + end + end) + end + + --创建公会 + function XGuildManager.BuildGuildRequest(guildName, guildDeclaration, iconId, cb) + XNetwork.Call(GuildRpc.GuildCreate, { + GuildName = guildName, + GuildDeclaration = guildDeclaration, + IconId = iconId + }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + local needDispatch, name, declaration = false + if res.GuildName ~= nil and res.GuildName ~= "" then + name = res.GuildName + needDispatch = true + end + + if res.GuildDeclaration ~= nil and res.GuildDeclaration ~= "" then + declaration = res.GuildDeclaration + needDispatch = true + end + + if needDispatch then + name = name or guildName + declaration = declaration or guildDeclaration + CsXGameEventManager.Instance:Notify(XEventId.EVENT_GUILD_FILTER_FINISH, name, declaration) + end + return + end + + if cb then + cb() + end + end) + end + + -- 获取公会详情GuildId = 0表示本公会 + function XGuildManager.GetGuildDetails(guild, cb) + XNetwork.Call(GuildRpc.GuildListDetail, { GuildId = guild }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + GuildData:UpdateGuildData(res) + + if cb then + cb() + end + end) + end + + function XGuildManager.GetVistorGuildDetailsReq(guildId, cb) + XNetwork.Call(GuildRpc.GuildListDetail, { GuildId = guildId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + if not GuildVistorInfoDatas[res.GuildId] then + GuildVistorInfoDatas[res.GuildId] = XGuildVistorData.New() + end + + GuildVistorInfoDatas[res.GuildId]:UpdateGuildData(res) + if cb then + cb() + end + end) + end + + function XGuildManager.GetVistorGuildDetailsById(guildId) + return GuildVistorInfoDatas[guildId] + end + + function XGuildManager.GetVistorMemberList(guildId) + return GuildVistorInfoDatas[guildId]:GetMemberList() + end + + function XGuildManager.IsHaveVistorGuildDetailsById(guildId) + if not GuildVistorInfoDatas[guildId] then + return false + end + + return GuildVistorInfoDatas[guildId]:IsHaveVistorGuildDetailsById() + end + + -- 自定义职位 + function XGuildManager.ChangeRankName(allRankNames, cb) + XNetwork.Call(GuildRpc.GuildChangeRankName, { AllRankName = allRankNames }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + GuildData:UpdateAllRankNames(allRankNames) + + if cb then + cb() + end + end) + end + + -- 变更职位 + function XGuildManager.GuildChangeRank(playerId, rankId, cb) + XNetwork.Call(GuildRpc.GuildChangeRank, + { + PlayerId = playerId, + NewRank = rankId + }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local members = GuildData:GetGuildMembers() + if members and members[playerId] then + members[playerId].RankLevel = rankId + -- 通知刷新 + XEventManager.DispatchEvent(XEventId.EVENT_GUILD_UPDATE_MEMBER_INFO) + end + + if cb then + cb() + end + end) + end + + -- 退出公会 + function XGuildManager.QuitGuild(cb) + local lastGuildId = GuildData.GuildId + local tempLevel = XGuildManager.GetGuildLevel() + XGuildManager.SaveGuildLevel(-1) + XNetwork.Call(GuildRpc.GuildQuit, {}, function(res) + if res.Code ~= XCode.Success then + XGuildManager.SaveGuildLevel(tempLevel) + XUiManager.TipCode(res.Code) + return + end + XDataCenter.ChatManager.DeleteGuildChat(lastGuildId) + XDataCenter.GuildBossManager.ClearLog() + XDataCenter.GuildBossManager.ClearReward() + XGuildManager.ClearLog() + GuildData.GuildId = 0 + + if cb then + cb() + end + end) + end + + --修改公会头像 + function XGuildManager.GuildChangeIconRequest(iconid, cb) + XNetwork.Call(GuildRpc.GuildChangeIcon, { IconId = iconid }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + GuildData.GuildIconId = iconid + if cb then + cb() + end + end) + end + + -- 修改公会名称 + function XGuildManager.GuildChangeName(name, func) + XNetwork.Call(GuildRpc.GuildChangeName, { Name = name }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + if res.Name ~= nil and res.Name ~= "" then + CsXGameEventManager.Instance:Notify(XEventId.EVENT_GUILD_FILTER_FINISH, res.Name) + end + return + end + GuildData.GuildName = name + if func then + func() + end + end) + end + + -- 修改宣言 + function XGuildManager.GuildChangeDeclaration(delaration, func) + XNetwork.Call(GuildRpc.GuildChangeDeclaration, { Delaration = delaration }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + if res.Delaration ~= nil and res.Delaration ~= "" then + CsXGameEventManager.Instance:Notify(XEventId.EVENT_GUILD_FILTER_FINISH, res.Delaration) + end + return + end + GuildData.GuildDeclaration = delaration + if func then + func() + end + end) + end + + -- 修改内部通讯 + function XGuildManager.GuildChangeNotice(notice, func) + XNetwork.Call(GuildRpc.GuildChangeNotice, { Notice = notice }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + if res.Notice ~= nil and res.Notice ~= "" then + CsXGameEventManager.Instance:Notify(XEventId.EVENT_GUILD_FILTER_FINISH, res.Notice) + end + return + end + GuildData.GuildInterCom = notice + if func then + func() + end + end) + end + + + -- 获取公会成员信息 + function XGuildManager.GetGuildMembers(guildId, func) + XNetwork.Call(GuildRpc.GuildMemberDetail, { GuildId = guildId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + CanImpeach = res.CanImpeach + HasImpeach = res.HasImpeach + + local MemberCount = 0 + for _, _ in pairs(res.MembersData or {}) do + MemberCount = MemberCount + 1 + end + GuildData:UpdateGuildMembers(res.MembersData, MemberCount) + + -- 人数变化,相同界面使用这个事件 + if MemberCount > GuildMemberCount then + GuildMemberCount = MemberCount + XEventManager.DispatchEvent(XEventId.EVENT_GUILD_UPDATE_MEMBER_INFO) + end + -- 检查会长罢免 + XEventManager.DispatchEvent(XEventId.EVENT_GUILD_LEADER_DISSMISS) + -- 检查成员在线人数 + XEventManager.DispatchEvent(XEventId.EVENT_GUILD_MEMBERCOUNT_CHANGED) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_GUILD_MEMBERCOUNT_CHANGED) + if func then + func() + end + end) + + end + + -- 获取公会成员信息(游客) + function XGuildManager.GetVistorGuildMembers(guildId, func) + XNetwork.Call(GuildRpc.GuildMemberDetail, { GuildId = guildId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + if not GuildVistorInfoDatas[guildId] then + GuildVistorInfoDatas[guildId] = XGuildVistorData.New() + end + + GuildVistorInfoDatas[guildId]:UpdateGuildMembers(res.MembersData) + if func then + func() + end + end) + + end + -- 申请加入公会的列表 + function XGuildManager.GetGuildListApply(cb) + XNetwork.Call(GuildRpc.GuildListApply, {}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + GuildApplyListDatas = {} + for _, v in pairs(res.Data or {}) do + GuildApplyListDatas[v.PlayerId] = v + end + + if cb then + cb() + end + end) + end + + -- 点赞 + function XGuildManager.GuildGiveLike(playerId, itemId, itemCount, cb) + XNetwork.Call(GuildRpc.GuildGiveLike, + { + OtherId = playerId, + ItemId = itemId, + ItemCount = itemCount + }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + if cb then + cb() + end + end) + end + + -- 弹劾会长 + function XGuildManager.GuildImpeachLeader(cb) + XNetwork.Call(GuildRpc.GuildImpeach, {}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + if cb then + cb() + end + end) + end + + -- 公会升级 + function XGuildManager.GuildLevelUp(cb) + XNetwork.Call(GuildRpc.GuildLevelUp, {}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + if cb then + cb() + end + end) + end + + -- 缴纳维护费用 + function XGuildManager.GuildPayMaintain(cb) + XNetwork.Call(GuildRpc.GuildPayMaintain, {}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + GuildData.MaintainState = XGuildConfig.GuildMaintainState.Normal + + if cb then + cb() + end + end) + end + + function XGuildManager.GetGuildLogListByType(type) + if not GuildLogList[type] then + GuildLogList[type] = {} + end + return GuildLogList[type] + end + + function XGuildManager.GetGuildLogMaxPage(type) + return GuildLogMaxPage[type] or 0 + end + + function XGuildManager.ClearLog() + GuildLogList = {} + GuildLogMaxPage = {} + end + + -- 获取公会动态 + function XGuildManager.GetGuildListNews(newsType, pageNo, cb) + XNetwork.Call(GuildRpc.GuildListNews, + { + NewsType = newsType, + PageNo = pageNo + }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + -- 记录公会动态信息 + local logList = XGuildManager.GetGuildLogListByType(newsType) + if pageNo <= 0 then + pageNo = res.MaxPageNo + GuildLogMaxPage[newsType] = res.MaxPageNo + end + for k, v in ipairs(res.News or {}) do + -- 首先请求最后一页(pageNo为0),获得最大页数后循环-1获取列表 + local index = (pageNo - 1) * GuildNewsCountPerPage + k + logList[index] = v + end + + if cb then + cb() + end + end) + end + + -- 公会活跃度礼包 + function XGuildManager.GuildGetGift(giftLevel, cb) + XNetwork.Call(GuildRpc.GuildGetGift, { GiftLevel = giftLevel}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + GuildData.GiftLevelGot[giftLevel] = true + local giftGuildLevel = GuildData.GiftGuildLevel + local giftData = XGuildConfig.GetGuildGiftByGuildLevelAndGiftLevel(giftGuildLevel, giftLevel) + if giftData and giftData.GiftReward then + local rewardList = XRewardManager.GetRewardList(giftData.GiftReward) + if rewardList then + XUiManager.OpenUiObtain(rewardList) + end + end + if cb then + cb() + end + -- 触发更新 + XEventManager.DispatchEvent(XEventId.EVENT_GUILD_GIFT_CONTRIBUTE_CHANGED) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_GUILD_GIFT_CONTRIBUTE_CHANGED) + end) + end + + -- 修改申请设置 + function XGuildManager.GuildChangeApplyOption(option, minLevel, func) + XNetwork.Call(GuildRpc.GuildChangeApplyOption, + { Option = option, MinLevel = minLevel }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + GuildData.Option = option + GuildData.MinLevel = minLevel + + if func then + func() + end + + end) + end + + -- 领取上周贡献奖励 + function XGuildManager.GuildGetContributeReward(func) + XNetwork.Call(GuildRpc.GuildGetContributeReward, + {}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + HasContributeReward = 0 + XEventManager.DispatchEvent(XEventId.EVENT_GUILD_MEMBER_CONTRIBUTE_CONDITION) + + local list = {} + table.insert(list, XRewardManager.CreateRewardGoodsByTemplate({ TemplateId = XGuildConfig.GuildCoin, Count = res.AddGuildCoin })) + XUiManager.OpenUiObtain(list) + + if func then + func() + end + end) + end + + -- 获取服务器聊天缓存 + function XGuildManager.GuildListChat(cb) + -- 限制频繁操作 + local curTime = XTime.GetServerNowTimestamp() + if curTime - LastReqServeChatTime < 5 then + return + end + LastReqServeChatTime = curTime + + XNetwork.Call(GuildRpc.GuildListChat, {}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local chatCache = {} + for i = 1, #res.ChatList do + local chatJson = Json.decode(res.ChatList[i]) + local chatData = XChatData.New(chatJson) + -- local chatData = XChatData.New() + -- chatData.SenderId = chatJson.SenderId + -- chatData.TargetId = chatJson.TargetId + -- chatData.CreateTime = chatJson.CreateTime + -- chatData.Content = chatJson.Content + -- chatData.MsgType = chatJson.MsgType + -- chatData.MessageId = chatJson.MessageId + -- chatData.Icon = chatJson.Icon + -- chatData.CustomContent = chatJson.CustomContent + -- chatData.NickName = chatJson.NickName + table.insert(chatCache, 1, chatData) + end + -- 初始化客户端信息 + XDataCenter.ChatManager.InitLocalCacheGuildChatContent() + + -- 服务端,客户端消息合并 + XDataCenter.ChatManager.MergeClientAndServerGuildChat(chatCache) + + if cb then + cb() + end + end) + end + + -- 会长向玩家发出招募 + function XGuildManager.GuildRecruit(playerId, cb, notRecord) + XNetwork.Call(GuildRpc.GuildRecruit, { PlayId = playerId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + if not notRecord then + RecommendedPlayers[playerId] = true + end + -- 招募发出成功 + if cb then + cb() + end + return + end + XUiManager.TipMsg(CS.XTextManager.GetText("GuildHasSendRecruit")) + if not notRecord then + RecommendedPlayers[playerId] = true + end + -- 招募发出成功 + if cb then + cb() + end + end) + end + + --申请加入公会 + function XGuildManager.ApplyToJoinGuildRequest(guildId, cb) + XNetwork.Call(GuildRpc.GuildApply, { GuildId = guildId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + if cb then + cb() + end + if res.IsPass == true then + EnterGuildRightAway = guildId + if guildId == XGuildManager.GetGuildId() then + XGuildManager.CloseAllAndEnterGuild() + end + end + end) + end + + -- 拒绝成员加入公会 + function XGuildManager.RefuseGuildRequest(playId, cb) + XNetwork.Call(GuildRpc.GuildAckApply, { PlayId = playId, IsAgree = false }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + + GuildApplyListDatas[playId] = nil + if cb then + cb() + end + return + end + + GuildApplyListDatas[playId] = nil + + if cb then + cb() + end + end) + end + + --同意成员加入公会 + function XGuildManager.AcceptGuildRequest(playId, playerName, cb) + XNetwork.Call(GuildRpc.GuildAckApply, { PlayId = playId, IsAgree = true }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + GuildApplyListDatas[playId] = nil + + if cb then + cb() + end + return + end + + XUiManager.TipMsg(CS.XTextManager.GetText("GuildAcceptSucceed", playerName)) + GuildApplyListDatas[playId] = nil + if cb then + cb() + end + end) + end + + -- 公会踢人 + function XGuildManager.GuildKickMember(playerId, cb) + XNetwork.Call(GuildRpc.GuildKickMember, { OtherId = playerId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + GuildData:RemoveMember(playerId) + XEventManager.DispatchEvent(XEventId.EVENT_GUILD_UPDATE_MEMBER_INFO) + if cb then + cb() + end + end) + end + + --获取公会推荐列表请求 + function XGuildManager.GuildListRecommendRequest(pageNo, cb) + XNetwork.Call(GuildRpc.GuildListRecommend, { PageNo = pageNo }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XGuildManager.PreRequestRecommendTime = XTime.GetServerNowTimestamp() + XGuildManager.HandleGuildRecommendDatas(pageNo, res.Datas) + GuildJoinCdEnd = res.JoinCdEnd + if cb then + cb() + end + end) + end + + function XGuildManager.GetGuildJoinCdEnd() + return GuildJoinCdEnd + end + + -- 公会搜索 + function XGuildManager.GuildFind(guildname, cb) + XNetwork.Call(GuildRpc.GuildFind, { GuildName = guildname }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + XGuildManager.HandleGuildFindDatas(guildname, res.GuildList) + + if cb then + cb() + end + end) + end + + --迎新语,检测屏蔽词 + function XGuildManager.GuildChangeScriptRequest(scripts, selects, autoChat, cb) + XNetwork.Call(GuildRpc.GuildChangeScript, { Scripts = scripts }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + for i= 1, #scripts do + if res.Scripts and res.Scripts[i] ~= nil and res.Scripts[i] ~= "" then + scripts[i] = res.Scripts[i] + end + end + local scriptsData = {} + local exist = false + for index, data in pairs(scripts) do + scriptsData[index] = {} + scriptsData[index].WelcomeWord = data + scriptsData[index].Select = selects[index] + exist = exist or selects[index] + end + autoChat = autoChat and exist + XDataCenter.GuildManager.SetGuildScriptDatas(scriptsData, autoChat) + XUiManager.TipText("GuildWelcomeWordSuccessTips") + if cb then + cb() + end + end) + end + + --获取当前自定义话术 暂时弃用 + -- function XGuildManager.GuildListScriptRequest(cb) + -- XNetwork.Call(GuildRpc.GuildListScript, {}, function(res) + -- if res.Code ~= XCode.Success then + -- XUiManager.TipCode(res.Code) + -- return + -- end + + -- XGuildManager.HandleGuildScriptDatas(res.Scripts, res.AutoChat) + -- if cb then + -- cb() + -- end + -- end) + -- end + + --获取已发布心愿列表 + function XGuildManager.GuildListWishRequest(cb) + XNetwork.Call(GuildRpc.GuildListWish, {}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + XGuildManager.HandleListWishDatas(res.WishesData, res.WishCount, res.WishContributeCount) + if cb then + cb() + end + end) + end + + -- 公会天赋 + function XGuildManager.GuildTalentListReq(func) + XNetwork.Call(GuildRpc.GuildListTalent, {}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + TalentPoint = res.Point + TalentLevels = {} + local talentSumLevel = 0 + for id, level in pairs(res.Talents or {}) do + TalentLevels[id] = level + talentSumLevel = talentSumLevel + level + end + GuildData.TalentSumLevel = talentSumLevel + if func then + func() + end + end) + end + + -- 公会天赋升级 + function XGuildManager.GuildUpgradeTalent(talentId, func) + XNetwork.Call(GuildRpc.GuildUpgradeTalent, { Id = talentId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + GuildData.TalentSumLevel = GuildData.TalentSumLevel + 1 + TalentPoint = res.Point + -- if not TalentLevels[talentId] then + -- TalentLevels[talentId] = 0 + -- end + -- local oldLevel = TalentLevels[talentId] + -- TalentLevels[talentId] = oldLevel + 1 + + if func then + func() + end + end) + end + + function XGuildManager.GetTalentPoint() + return TalentPoint + end + + function XGuildManager.GetTalentLevel(id) + return TalentLevels[id] or 0 + end + + -- 是否解锁 + function XGuildManager.IsTalentUnlock(id) + local talentTemplate = XGuildConfig.GetGuildTalentById(id) + if not talentTemplate then return false end + local curGuildLevel = XGuildManager.GetGuildLevel() + return curGuildLevel >= talentTemplate.GuildLevel + end + + function XGuildManager.IsTalentMaxLevel(id) + local curLevel = XGuildManager.GetTalentLevel(id) + local talentTemplate = XGuildConfig.GetGuildTalentById(id) + if not talentTemplate then return false end + return talentTemplate.CostPoint[curLevel + 1] == nil + end + + function XGuildManager.CheckAllTalentLevelMax() + if XGuildManager.IsGuildLevelMax(XGuildManager.GetGuildLevel()) then --or + -- XGuildManager.GetTalentPointFromBuild() > 0 then + if TalentLevelCount == 0 then + local sum = 0 + local points = XGuildConfig.GetSortedTalentPoints() + for _, v in pairs(points) do + local talentTemplate = XGuildConfig.GetGuildTalentById(v.Id) + sum = sum + #talentTemplate.CostPoint + end + TalentLevelCount = sum + end + return GuildData.TalentSumLevel == TalentLevelCount + end + return false + end + + -- 能否升级:是否解锁、父节点、消耗,最高级 + function XGuildManager.CanTalentUpgrade(id) + if not XGuildManager.IsTalentUnlock(id) then return false end + local curLevel = XGuildManager.GetTalentLevel(id) + local talentTemplate = XGuildConfig.GetGuildTalentById(id) + if not talentTemplate then return false end + + if not XGuildManager.CheckParentTalent(id) then + return false + end + + local cost = talentTemplate.CostPoint[curLevel + 1] or 0 + return TalentPoint >= cost + end + + -- 前置条件检查 + function XGuildManager.CheckParentTalent(id) + local talentTemplate = XGuildConfig.GetGuildTalentById(id) + if not talentTemplate then return false end + + local preUnlock = false + local preAllZero = true + local curLevel = XGuildManager.GetTalentLevel(id) + for i = 1, #talentTemplate.Parent do + local preId = talentTemplate.Parent[i] + local preLevel = XGuildManager.GetTalentLevel(preId) + if preId > 0 then + preAllZero = false + if preLevel > curLevel then + preUnlock = true + break + end + end + end + + if not preAllZero then + return preUnlock + end + return true + end + + -- 父节点是否都为0 + function XGuildManager.IsTalentParentAllZero(id) + local talentTemplate = XGuildConfig.GetGuildTalentById(id) + if not talentTemplate then return false end + + local allZero = true + for i = 1, #talentTemplate.Parent do + if talentTemplate.Parent[i] > 0 then + allZero = false + break + end + end + return allZero + end + + -- 公会日常任务 + function XGuildManager.GetSortedGuildDailyTasks() + local tasks = XDataCenter.TaskManager.GetGuildDailyFullTaskList() + -- 是否需要排序 + for _, v in pairs(tasks or {}) do + v.SortWeight = 2 + if v.State == XDataCenter.TaskManager.TaskState.Achieved then + v.SortWeight = 1 + elseif v.State == XDataCenter.TaskManager.TaskState.Finish or v.State == XDataCenter.TaskManager.TaskState.Invalid then + v.SortWeight = 3 + end + end + + table.sort(tasks, function(taskA, taskB) + if taskA.SortWeight == taskB.SortWeight then + return taskA.Id < taskB.Id + end + return taskA.SortWeight < taskB.SortWeight + end) + return tasks + end + + -- 是否有购买的权限 + function XGuildManager.CheckShopBuyAccess(shopId) + if shopId == XGuildConfig.GuildPurchaseShop then + return XGuildManager.IsGuildAdminister() + end + return true + end + + -- 是否可以领取贡献奖励 + function XGuildManager.CanCollectContributeReward() + if XGuildManager.IsGuildTourist() then return false end + + return HasContributeReward == 1 + end + + -- 获取公会排名 + function XGuildManager.GuildListRankRequest(order, cb) + XNetwork.Call(GuildRpc.GuildListRank, { Order = order}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XGuildManager.HandleListRankDatas(order, res.RankList, res.MyRankNum) + if cb then + cb() + end + end) + end + -- 是否紧急维护状态 + function XGuildManager.IsUrgentMaintainState() + return GuildData.MaintainState == XGuildConfig.GuildMaintainState.Urgent + end + + -- 紧急状态开始时间 + function XGuildManager.GetEmergenceTime() + return GuildData.EmergenceTime + end + + -- 获取建设度 + function XGuildManager.GetBuild() + return GuildData.Build + end + + -- 获取申请设置 + function XGuildManager.GetApplyOption() + return GuildData.Option + end + + -- 获取最低等级 + function XGuildManager.GetMinLevelOption() + return GuildData.MinLevel + end + + -- 获取最高等级获得的天赋点 + function XGuildManager.GetTalentPointFromBuild() + return GuildData.TalentPointFromBuild or 0 + end + + -- 获取当前荣耀等级 + function XGuildManager.GetGloryLevel() + local level = math.modf( GuildData.TalentPointFromBuild / XGuildConfig.GloryPointsPerLevel) + return level > XGuildConfig.GuildGloryMaxLevel and XGuildConfig.GuildGloryMaxLevel or level + end + + -- 礼包是否可以领取 + function XGuildManager.CanCollectGift(giftLevel) + if XGuildManager.IsGuildTourist() then return false end + if not XGuildManager.IsJoinGuild() then return false end + + local lastGuildId = XGuildManager.GetGiftGuildGot() + local curGuildId = XGuildManager.GetGuildId() + if lastGuildId > 0 and lastGuildId ~= curGuildId then + return false + end + + local giftGuildLevel = XGuildManager.GetGiftGuildLevel() + local giftLevelGots = XGuildManager.GetGiftLevelGot() + if giftLevelGots[giftLevel] then return false end + + local giftData = XGuildConfig.GetGuildGiftByGuildLevelAndGiftLevel(giftGuildLevel, giftLevel) + if not giftData then return false end + + local giftContribute = XGuildManager.GetGiftContribute() + if giftContribute < giftData.GiftContribute then + return false + end + + return true + end + + -- 公会礼包贡献进度 + function XGuildManager.GetGiftContribute() + return GuildData.GiftContribute + end + + -- 礼包刷新时的公会等级 + function XGuildManager.GetGiftGuildLevel() + return GuildData.GiftGuildLevel + end + + -- 礼包当前等级 + function XGuildManager.GetGiftLevel() + return GuildData.GiftLevel + end + + -- 玩家已领取的礼包等级 + function XGuildManager.GetGiftLevelGot() + return GuildData.GiftLevelGot + end + + -- 玩家在哪个公会领过礼包 + function XGuildManager.GetGiftGuildGot() + return GuildData.GiftGuildGot + end + + -- 当前剩余的贡献值 + function XGuildManager.GetGuildContributeLeft() + return GuildData.GuildContributeLeft + end + + -- 公会id + function XGuildManager.GetGuildId() + return GuildData.GuildId + end + + -- 公会名字 + function XGuildManager.GetGuildName() + return GuildData.GuildName + end + + -- 公会等级 + function XGuildManager.GetGuildLevel() + return GuildData.GuildLevel + end + + function XGuildManager.GetGuildContributeIn7Days() + return GuildData.GuildContributeIn7Days + end + + -- 判断公会等级是否提升 + function XGuildManager.CheckGuildLevelUp() + if not XGuildManager.IsJoinGuild() then return false end + if XLuaUiManager.IsUiShow("UiGuildLevelUp") then return false end + local curLevel = XGuildManager.GetGuildLevel() + local lastLevel = XGuildManager.GetLastLevel() + -- -1 表示换了公会或未保存过 + if lastLevel == -1 then + XGuildManager.SaveGuildLevel() + return false + end + if lastLevel < curLevel then + GuildData.GuildLastLevel = lastLevel + XLuaUiManager.Open("UiGuildLevelUp",lastLevel, curLevel, function() + XGuildManager.SaveGuildLevel(curLevel) + end) + return true + end + return false + end + + --最后一次保存的等级 + function XGuildManager.GetLastLevel() + return GuildData.GuildLastLevel or XGuildManager.GetGuildPrefs(XGuildConfig.KEY_LAST_LEVEL, -1) + end + + -- 保存当前等级 + function XGuildManager.SaveGuildLevel(level) + local curLevel = level or XGuildManager.GetGuildLevel() + XGuildManager.SaveGuildPrefs(XGuildConfig.KEY_LAST_LEVEL, curLevel) + GuildData.GuildLastLevel = curLevel + end + + -- 公会等级是否达到最大(是否满级) + function XGuildManager.IsGuildLevelMax(level) + local isMax = false + local levelData = XGuildConfig.GetGuildLevelDataBylevel(level) + if not levelData then return isMax end + + local nextLevel = level + 1 + local nextLevelData = XGuildConfig.GetGuildLevelDataBylevel(nextLevel) + if not nextLevelData then + isMax = true + end + + return isMax + end + + -- 保存本地数据 + function XGuildManager.SaveGuildPrefs(key, value, type) + local guildId = XGuildManager.GetGuildId() + if XPlayer.Id and guildId then + key = string.format("%s_%s_%s", key, tostring(XPlayer.Id), tostring(guildId)) + if type == DataType.String then + CS.UnityEngine.PlayerPrefs.SetString(key, value) + else + CS.UnityEngine.PlayerPrefs.SetInt(key, value) + end + CS.UnityEngine.PlayerPrefs.Save() + end + end + + -- 获取本地数据 + function XGuildManager.GetGuildPrefs(key, defaultValue, type) + local guildId = XGuildManager.GetGuildId() + if XPlayer.Id and guildId then + key = string.format("%s_%s_%s", key, tostring(XPlayer.Id), tostring(guildId)) + if CS.UnityEngine.PlayerPrefs.HasKey(key) then + local guildPref = nil + if type == DataType.String then + guildPref = CS.UnityEngine.PlayerPrefs.GetString(key) + else + guildPref = CS.UnityEngine.PlayerPrefs.GetInt(key) + end + return (guildPref == nil or guildPref == 0) and defaultValue or guildPref + end + end + return defaultValue + end + + -- 公会宣言 + function XGuildManager.GetGuildDeclaration() + return GuildData.GuildDeclaration + end + + -- 公会内部通讯 + function XGuildManager.GetGuildInterCom() + return GuildData.GuildInterCom + end + + -- 公会图标 + function XGuildManager.GetGuildIconId() + local headPortrait = XGuildConfig.GetGuildHeadPortraitById(GuildData.GuildIconId) + if not headPortrait then return nil end + return headPortrait.Icon + end + + function XGuildManager.GetGuildHeadPortrait() + return GuildData.GuildIconId + end + + -- 会长名字 + function XGuildManager.GetGuildLeaderName() + return GuildData.GuildLeaderName + end + + -- 会员数量 + function XGuildManager.GetMemberCount() + return GuildData.GuildMemberCount + end + + -- 会员在线数量 + function XGuildManager.GetOnlineMemberCount() + local onlineCount = 0 + local allMembers = GuildData:GetGuildMembers() + for _, member in pairs(allMembers or {}) do + if member.OnlineFlag == 1 then + onlineCount = onlineCount + 1 + end + end + return onlineCount + end + + -- 会员最大数量 + function XGuildManager.GetMemberMaxCount() + return GuildData.GuildMemberMaxCount + end + + -- 是否可以弹劾会长 + function XGuildManager.CanImpeachLeader() + return CanImpeach + end + + -- 是否弹劾过会长 + function XGuildManager.HasImpeachLeader() + return HasImpeach + end + + -- 设置弹劾过会长 + function XGuildManager.SetImpeachLeader() + HasImpeach = true + end + + -- 获取成员 + function XGuildManager.GetMemberList() + return GuildData:GetGuildMembers() + end + + -- 获取成员(游客) + function XGuildManager.GetVistorMemberList(guildid) + return GuildVistorInfoDatas[guildid]:GetGuildMembers() + end + + -- 清掉获取成员 + function XGuildManager.ClearVistorGuildMembers(guildid) + if GuildVistorInfoDatas[guildid] then + GuildVistorInfoDatas[guildid]:ClearGuildMembers() + end + end + + -- 推荐页数 + function XGuildManager.GetRecommendPageNo() + RecommendPageNo = RecommendPageNo % 10 + 1 + return RecommendPageNo + end + + -- 自定义职位{Id = Name} + function XGuildManager.GetAllRankNames() + return GuildData.DecodeRankNames + end + + function XGuildManager.GetRankNameByLevel(level) + return GuildData:GetRankNameByLevel(level) + end + + -- 查看申请者列表 + function XGuildManager.GetGuildApplyList() + return GuildApplyListDatas + end + + -- 重置申请信息 + function XGuildManager.ResetApplyMemberList() + HasApplyMember = false + XEventManager.DispatchEvent(XEventId.EVENT_GUILD_APPLY_LIST_CHANGED) + end + + -- 是否有申请信息 + function XGuildManager.GetHasApplyMemberList() + if XGuildManager.IsGuildTourist() or not XGuildManager.IsGuildAdminister() then return false end + return HasApplyMember + end + + -- 获取保存公会聊天缓存的key + function XGuildManager.GetGuildChannelKey(guildId) + return string.format("GuildKey_%s_%s", tostring(XPlayer.Id), tostring(guildId)) + end + + -- 查看是否有招募 + function XGuildManager.HasGuildRecruitList() + return HasGuildRecruit + end + + -- 重置招募列表 + function XGuildManager.ResetGuildRecruit() + if HasGuildRecruit then + HasGuildRecruit = false + XEventManager.DispatchEvent(XEventId.EVENT_GUILD_RECRUIT_LIST_CHANGED) + end + end + + -- 查询免费改名机会 + function XGuildManager.GetFreeChangeGuildName() + return FreeChangeGuildNameCount > 0 + end + + -- 使用免费改名机会 + function XGuildManager.SetFreeChangeGuildNameCount() + if FreeChangeGuildNameCount > 0 then + FreeChangeGuildNameCount = FreeChangeGuildNameCount - 1 + end + end + + -- 获取工会boss结束时间 + function XGuildManager.GuildBossEndTime() + return GuildData.BossEndTime + end + + -- 更新工会boss结束时间 + function XGuildManager.SetGuildBossEndTime(val) + if val then + GuildData.BossEndTime = val + else + XLog.Warning("SetGuildBossEndTime(val) Failed") + end + end + + --获取当前迎新语 + function XGuildManager.GetGuildScriptDatas() + if not next(GuildScriptListDatas) then + GuildScriptListDatas = {} + for i = 1, XGuildConfig.GuildDefaultWelcomeWord do + local key = string.format("%s_%d_%d", GuildWelcomeWordKey, XPlayer.Id, i) + if not CS.UnityEngine.PlayerPrefs.HasKey(key) then + break + end + GuildScriptListDatas[i] = {} + GuildScriptListDatas[i].WelcomeWord = CS.UnityEngine.PlayerPrefs.GetString(key ,nil) + key = string.format("%s_%d_%d", GuildWelcomeSelectKey, XPlayer.Id, i) + GuildScriptListDatas[i].Select = (CS.UnityEngine.PlayerPrefs.GetInt(key, 0) == 1) + end + if not next(GuildScriptListDatas) then + GuildScriptListDatas = XGuildConfig.GetDefaultWelcomeWords() + end + end + return GuildScriptListDatas + end + + function XGuildManager.HandleGuildScriptSelectedDatas(scriptsData) + GuildScriptSelectedDatas = {} + for _, v in pairs(scriptsData) do + if v.Select then + table.insert(GuildScriptSelectedDatas, v.WelcomeWord) + end + end + end + + function XGuildManager.GetGuildScriptSelectedDatas() + if GuildScriptSelectedDatas == nil or next(GuildScriptSelectedDatas) == nil then + local scriptsData = XGuildManager.GetGuildScriptDatas() + XGuildManager.HandleGuildScriptSelectedDatas(scriptsData) + end + return GuildScriptSelectedDatas + end + + --处理迎新语数据(可以优化,用XSaveTool.SaveData方法) + function XGuildManager.SetGuildScriptDatas(scriptsData, autoChat) + GuildScriptListDatas = {} + if scriptsData and next(scriptsData) then + for k, v in pairs(scriptsData) do + if v then + table.insert(GuildScriptListDatas, v) + local key = string.format("%s_%d_%d", GuildWelcomeWordKey, XPlayer.Id, k) + CS.UnityEngine.PlayerPrefs.SetString(key, v.WelcomeWord) + key = string.format("%s_%d_%d", GuildWelcomeSelectKey, XPlayer.Id, k) + CS.UnityEngine.PlayerPrefs.SetInt(key, v.Select and 1 or 0) + end + end + XGuildManager.HandleGuildScriptSelectedDatas(scriptsData) + end + GuildScriptAutoChat = autoChat + local key = string.format("%s_%d", GuildWelcomeAutoChatKey, XPlayer.Id) + CS.UnityEngine.PlayerPrefs.SetInt(key, GuildScriptAutoChat and 1 or 0) + CS.UnityEngine.PlayerPrefs.Save() + end + + function XGuildManager.GetGuildScriptAutoChat() + if GuildScriptAutoChat == nil then + local key = string.format("%s_%d", GuildWelcomeAutoChatKey, XPlayer.Id) + -- 是否自动喊话,默认开启 + GuildScriptAutoChat = (CS.UnityEngine.PlayerPrefs.GetInt(key, 1) == 1) + end + return GuildScriptAutoChat + end + + function XGuildManager.InitGuildCustomNameTable() + GuildCustomName = {} + for _, v in pairs(XGuildConfig.GuildRankLevel) do + GuildCustomName[v] = {} + end + local templates = XTool.Clone(XGuildConfig.GetCustomNameTemplate()) + local list = {} + for index, template in pairs(templates) do + if template.Enable then + template.Id = index + table.insert(list, template) + end + end + table.sort(list, function(itemA, itemB) + return itemA.Id < itemB.Id + end) + for k, v in pairs(list) do + table.insert(GuildCustomName[v.RankLevel], v.Name) + end + end + + function XGuildManager.GetGuildCustomName() + if not next(GuildCustomName) then + XGuildManager.InitGuildCustomNameTable() + end + return GuildCustomName + end + + XGuildManager.Init() + return XGuildManager +end + +-- 上线时推送公会数据 +XRpc.NotifyGuildData = function(notifyData) + XDataCenter.GuildManager.AsyncGuildData(notifyData) +end + +-- 推送公会事件 +XRpc.NotifyGuildEvent = function(notifyData) + XDataCenter.GuildManager.AsyncGuildEvent(notifyData) +end + +XRpc.NotifyRankName = function(notifyData) + XDataCenter.GuildManager.AsyncGuildRankName(notifyData) +end + +XRpc.NotifyGuildMaintain = function(notifyData) + XDataCenter.GuildManager.AsyncGuildMaintain(notifyData) +end + +XRpc.NotifyGuildImpeach = function(notifyData) + XDataCenter.GuildManager.AsyncGuildImpeach(notifyData) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XHardwareManager.lua b/Resources/Scripts/XManager/XHardwareManager.lua new file mode 100644 index 00000000..bd59f808 --- /dev/null +++ b/Resources/Scripts/XManager/XHardwareManager.lua @@ -0,0 +1,540 @@ +XHardwareManager = XHardwareManager or {} + +local XQualityManager = CS.XQualityManager.Instance + + +local XRenderQuality = { + Lowest = 0, + Low = 1, + Middle = 2, + High = 3, + Highest = 4 +} + + +--ios默认高档配置,其他需要指定的在这里写 +local IOS_TABLE = { + + ["iPad11,1"] = XRenderQuality.Highest, + ["iPad11,2"] = XRenderQuality.Highest, + ["iPad11,3"] = XRenderQuality.Highest, + ["iPad11,4"] = XRenderQuality.Highest, + ["iPad8,1"] = XRenderQuality.Highest, + ["iPad8,2"] = XRenderQuality.Highest, + ["iPad8,3"] = XRenderQuality.Highest, + ["iPad8,4"] = XRenderQuality.Highest, + ["iPad8,5"] = XRenderQuality.Highest, + ["iPad8,6"] = XRenderQuality.Highest, + ["iPad8,7"] = XRenderQuality.Highest, + ["iPad8,8"] = XRenderQuality.Highest, + + ["iPad7,1"] = XRenderQuality.Highest, + ["iPad7,2"] = XRenderQuality.Highest, + ["iPad7,3"] = XRenderQuality.Highest, + ["iPad7,4"] = XRenderQuality.Highest, + ["iPad7,5"] = XRenderQuality.Middle, + ["iPad7,6"] = XRenderQuality.Middle, + ["iPad7,7"] = XRenderQuality.Highest, + + ["iPad6,11"] = XRenderQuality.Middle, + ["iPad6,12"] = XRenderQuality.Middle, + + ["iPad6,1"] = XRenderQuality.Highest, + ["iPad6,2"] = XRenderQuality.Highest, + ["iPad6,3"] = XRenderQuality.Middle, + ["iPad6,4"] = XRenderQuality.Middle, + ["iPad6,5"] = XRenderQuality.Highest, + ["iPad6,6"] = XRenderQuality.Highest, + ["iPad6,7"] = XRenderQuality.Highest, + + ["iPad5,1"] = XRenderQuality.Middle, + ["iPad5,2"] = XRenderQuality.Middle, + ["iPad5,3"] = XRenderQuality.Middle, + ["iPad5,4"] = XRenderQuality.Middle, + ["iPad5,5"] = XRenderQuality.Middle, + + ["iPad4,1"] = XRenderQuality.Highest, + ["iPad4,2"] = XRenderQuality.Highest, + ["iPad4,3"] = XRenderQuality.Highest, + ["iPad4,7"] = XRenderQuality.Highest, + ["iPad4,8"] = XRenderQuality.Highest, + ["iPad4,9"] = XRenderQuality.Highest, + + ["iPad3,1"] = XRenderQuality.Highest, + ["iPad3,2"] = XRenderQuality.Highest, + ["iPad3,3"] = XRenderQuality.Highest, + ["iPad3,4"] = XRenderQuality.Highest, + ["iPad3,5"] = XRenderQuality.Highest, + ["iPad3,6"] = XRenderQuality.Highest, + + + + + ["iPhone1,1"] = XRenderQuality.Low, + ["iPhone1,2"] = XRenderQuality.Low, + ["iPhone2,1"] = XRenderQuality.Low, + ["iPhone3,1"] = XRenderQuality.Low, + ["iPhone3,2"] = XRenderQuality.Low, + ["iPhone3,3"] = XRenderQuality.Low, + ["iPhone4,1"] = XRenderQuality.Low, + + ["iPhone5,1"] = XRenderQuality.Low, + ["iPhone5,2"] = XRenderQuality.Low, + ["iPhone5,3"] = XRenderQuality.Low, + ["iPhone5,4"] = XRenderQuality.Low, + + ["iPhone6,1"] = XRenderQuality.Low, + ["iPhone6,2"] = XRenderQuality.Low, + + ["iPhone7,2"] = XRenderQuality.Middle, + ["iPhone7,1"] = XRenderQuality.Middle, + + --iphone 6s + ["iPhone8,1"] = XRenderQuality.Middle, + ["iPhone8,2"] = XRenderQuality.Middle, + ["iPhone8,4"] = XRenderQuality.High, + + --iphone 7 + ["iPhone9,1"] = XRenderQuality.High, + ["iPhone9,2"] = XRenderQuality.High, + ["iPhone9,3"] = XRenderQuality.High, + ["iPhone9,4"] = XRenderQuality.High, + + --iphone 8 + ["iPhone10,1"] = XRenderQuality.High, + ["iPhone10,4"] = XRenderQuality.High, + + --iphone 8 plus + ["iPhone10,2"] = XRenderQuality.High, + ["iPhone10,5"] = XRenderQuality.High, + + --iphone x + ["iPhone10,3"] = XRenderQuality.High, + ["iPhone10,6"] = XRenderQuality.High, + + --iphone xr + ["iPhone11,8"] = XRenderQuality.Highest, + + --iphone xs + ["iPhone11,2"] = XRenderQuality.High, + + --iphone xs max + ["iPhone11,6"] = XRenderQuality.High, + + --??? + ["iPhone11,4"] = XRenderQuality.Highest, + ["iPhone11,1"] = XRenderQuality.Highest, + ["iPhone11,3"] = XRenderQuality.Highest, + ["iPhone11,5"] = XRenderQuality.Highest, + ["iPhone11,7"] = XRenderQuality.Highest, + ["iPhone11,9"] = XRenderQuality.Highest, + + ["iPhone12,1"] = XRenderQuality.Highest, + ["iPhone12,2"] = XRenderQuality.Highest, + ["iPhone12,3"] = XRenderQuality.Highest, + ["iPhone12,4"] = XRenderQuality.Highest, + ["iPhone12,5"] = XRenderQuality.Highest, + ["iPhone12,6"] = XRenderQuality.Highest, + ["iPhone12,7"] = XRenderQuality.Highest, + ["iPhone12,8"] = XRenderQuality.Highest, + ["iPhone12,9"] = XRenderQuality.Highest, + +} + +function XHardwareManager.CheckIOS() + local iosName = CS.UnityEngine.SystemInfo.deviceModel + XLog.Debug("IOS Model name:" .. tostring(iosName)) + + if not iosName or iosName == "" then + return XRenderQuality.High + end + + local quality = IOS_TABLE[iosName] + + if not quality then + return XRenderQuality.High + end + + return quality +end + +--设置硬件相关分辨率 +function XHardwareManager.SetHardwareResolution() + local model = CS.UnityEngine.SystemInfo.deviceModel + if not model then + XQualityManager:SetHardwareScale(1) + return + end + + if model then + + --iphone x 设置一个0.9分辨率进去 + if model == "iPhone10,3" or model == "iPhone10,6" or model == "iPhone11,6" then + XQualityManager:SetHardwareScale(0.9) + return + end + + end + + + XQualityManager:SetHardwareScale(1) +end + + +function XHardwareManager.CheckAndroid() + return XHardwareManager.CheckGpuAndroid(CS.UnityEngine.SystemInfo.graphicsDeviceName) +end + +function XHardwareManager.CheckGpuAdreno(tokens) + local seriesNum + for i = 1, #tokens do + seriesNum = tonumber(tokens[i]) + if seriesNum then + + if seriesNum == 540 then + --835 + return XRenderQuality.High + end + + if seriesNum == 618 then + --855+ + return XRenderQuality.High + end + + if seriesNum == 616 then + --710 + return XRenderQuality.High + end + + if seriesNum < 400 then + return XRenderQuality.Lowest + elseif seriesNum <= 509 then + return XRenderQuality.Lowest + elseif seriesNum < 510 then + return XRenderQuality.Low + elseif seriesNum < 600 then + return XRenderQuality.Middle + else + + if seriesNum >= 600 and seriesNum < 700 then + + if seriesNum <= 627 then + --616 + return XRenderQuality.Middle + else + if seriesNum >= 640 then + --640 + return XRenderQuality.Highest + else + --630 + return XRenderQuality.High + end + + end + + elseif seriesNum >= 700 and seriesNum < 800 then + --700系列都是高端 + return XRenderQuality.Middle + + else + --800 + if seriesNum <= 900 then + + if seriesNum <= 806 then + --800 ~ 806 + return XRenderQuality.Middle + else + + if seriesNum >= 820 then + --820以上为最高端 + return XRenderQuality.Middle + else + --806~820 + return XRenderQuality.Middle + end + + end + + else + --未知系列默认返回高端机 + return XRenderQuality.Middle + end + + --默认返回中端机 + -- return XRenderQuality.Middle + end + + end + end + end + + XLog.Warning("XHardwareManager.CheckGpuAdreno: Getting quality fail, unknow device.") + return XRenderQuality.Middle +end + +function XHardwareManager.CheckGpuPowerVR(tokens) + -- local tag = "XHardwareManager.CheckGpuPowerVR " + -- -- XLog.Debug(tag .. "Begin") + for i = 1, #tokens do + local token = tokens[i] + + if token == "sgx" then + -- XLog.Debug(tag .. "sgx") + return XRenderQuality.Lowest + end + + if token == "furian" then + -- XLog.Debug(tag .. "furian") + return XRenderQuality.Lowest + end + + local quality = XHardwareManager.GetQualityByPowerVRSeriesNum(token) + if quality then + return quality + end + end + XLog.Warning("XHardwareManager.CheckGpuAdreno: Getting quality fail, unknow device.") + return XRenderQuality.Lowest +end + +function XHardwareManager.GetQualityByPowerVRSeriesNum(token) + -- local tag = "XHardwareManager.GetQualityByPowerVRSeriesNum " + -- XLog.Debug(tag .. "token = " .. token) + -- Precheck + local char1 = string.byte(token, 1) + local gByte = string.byte('g', 1) + local isGSeries = char1 == gByte + if not isGSeries then + -- XLog.Debug(tag .. "isGSeries = false or nil, continue") + return XRenderQuality.Low + end + + -- Getting series number + local seriesNum + local char2 = string.byte(token, 2) + local isNumberStartAt2 = char2 >= string.byte('0', 1) and char2 <= string.byte('9', 1) + if isNumberStartAt2 then + seriesNum = tonumber(string.sub(token, 2)) + else + seriesNum = tonumber(string.sub(token, 1)) + end + + if not seriesNum then + -- XLog.Debug(tag .. "series number = nil") + return XRenderQuality.Low + end + -- XLog.Debug(tag .. "series number = " .. seriesNum) + -- Return by series number + if seriesNum > 0 then + if seriesNum >= 9400 then + -- XLog.Debug(tag .. "seriesNum >= 9400") + return XRenderQuality.Middle + elseif seriesNum >= 8300 then + -- XLog.Debug(tag .. "seriesNum >= 8300") + return XRenderQuality.Low + else -- redmi 6 GE8320 Huawei Y5 2018 GE8100 + -- XLog.Debug(tag .. "else") + return XRenderQuality.Lowest + end + end +end + +function XHardwareManager.GetMaliSeriesNumByToken(token, flag) + -- local tag = "XHardwareManager.GetMaliSeriesNumByToken" + -- XLog.Debug(tag .. "token = " .. token .. ", flag = " .. tostring(flag)) + local mpIndex = string.LastIndexOf(token, "mp") + if mpIndex > 1 then + -- XLog.Debug(tag .. "mpIndex > 1") + -- 't/g' + number + mp + local startIndex + if flag then + startIndex = 2 + else + startIndex = 1 + end + token = string.sub(token, startIndex, mpIndex - startIndex) + -- XLog.Debug(tag .. "token = " .. token) + else + -- 't/g' + number + if flag then + token = string.sub(token, 2) + end + -- XLog.Debug(tag .. "token = " .. token) + end + + local result = tonumber(token) + -- if result then + -- XLog.Debug(tag .. "tonumber(token) = " .. result) + -- else + -- XLog.Debug(tag .. "tonumber(token) = nil") + -- end + return result +end + +function XHardwareManager.GetQualityByMaliSeriesNum(seriesNum, gFlag, tFlag) + + -- local tag = "XHardwareManager.GetQualityByMaliSeriesNum : " + -- XLog.Debug("mali series number = " .. seriesNum) + if seriesNum <= 0 then + return XRenderQuality.Middle + end + + -- G series + if gFlag then + -- XLog.Debug("Mali G series " .. seriesNum) + if seriesNum >= 76 then + -- XLog.Debug("seriesNum >= 76") + return XRenderQuality.High + elseif seriesNum >= 72 then -- MP value + -- XLog.Debug("seriesNum >= 72") + --G72 + return XRenderQuality.Middle + elseif seriesNum >= 71 then -- MP value + return XRenderQuality.Middle + elseif seriesNum >= 52 then + --kirin 810 + return XRenderQuality.High + else -- huawei Lite G51 G71 + return XRenderQuality.Middle + end + end + + -- T series Opengl ES 3.1 + if tFlag then + -- XLog.Debug("Mali T series " .. seriesNum) + if seriesNum >= 780 then -- MTK MP NightMare + -- XLog.Debug("seriesNum >= 780") + return XRenderQuality.Middle + else -- 720 760 + return XRenderQuality.Low + end + end + + -- Other series + -- XLog.Debug(tag .. "Mali other series name: " .. seriesNum) + if seriesNum < 600 and seriesNum >= 200 then + -- XLog.Debug("seriesNum < 600 and seriesNum >= 200") + return XRenderQuality.Low + else + -- XLog.Debug(tag .. "else") + return XRenderQuality.Middle + end +end + +function XHardwareManager.CheckGpuMali(tokens) + -- local tag = "XHardwareManager.CheckGpuMali " + -- XLog.Debug("check gpu mali " .. tag .. " #tokens = " .. #tokens) + -- Format : arm mali 'g/t'number + for i = 2, #tokens do + local token = tokens[i] + + -- Getting flags + local firstCharByte = string.byte(token, 1) + local tByte = string.byte('t', 1) + local gByte = string.byte('g', 1) + local tFlag = firstCharByte == tByte + local gFlag = firstCharByte == gByte + local flag = tFlag or gFlag + + -- Getting series number + local seriesNum = XHardwareManager.GetMaliSeriesNumByToken(token, flag) + if not seriesNum then + goto continue + end + -- XLog.Debug(tag .. "seriesNum = " .. seriesNum) + -- Getting quality + local quality = XHardwareManager.GetQualityByMaliSeriesNum(seriesNum, gFlag, tFlag) + if quality then + -- XLog.Debug(tag .. "quality = " .. quality) + return quality + end + + ::continue:: + end + + XLog.Error("XHardwareManager.CheckGpuMali: Getting quality fail, unknow device.") + return XRenderQuality.Middle +end + +function XHardwareManager.CheckGpuTegra(tokens) + -- local tag = "XHardwareManager.CheckGpuTegra " + for i = 1, #tokens do + local text = tokens[i] + if text == "k1" then + -- XLog.Debug(tag .. "text == \"k1\"") + return XRenderQuality.Lowest + end + if text == "x1" then + -- XLog.Debug(tag .. "text == \"x1\"") + return XRenderQuality.Low + end + end + -- XLog.Debug(tag .. "else") + XLog.Error("XHardwareManager.CheckGpuTegra: Getting quality fail, unknow device.") + return XRenderQuality.Middle +end + +function XHardwareManager.CheckGpuAndroid(gpuName) + + XQualityManager.IsSimulator = false + + if not gpuName or gpuName == "" then + XLog.Error("XHardwareManager.CheckGpuAndroid: Getting quality fail, gpuName is nil.") + return XRenderQuality.Middle + end + + -- XLog.Debug("XHardwareManager.CheckGpuAndroid : " .. gpuName) + -- Pretreatment + gpuName = string.lower(gpuName) + local separators = { '\t', '\r', '\n', '+', '-', ':' } + for i = 1, #separators do + gpuName = string.gsub(gpuName, separators[i], ' ') + end + local tokens = string.Split(gpuName, ' ') + local tokenLength = #tokens + if not tokens or tokenLength == 0 then + XLog.Error("XHardwareManager.CheckGpuAndroid: Split gpu name fail.") + return XRenderQuality.Middle + end + + local token1 = tokens[1] + local token2 = nil + if tokenLength >= 2 then + token2 = tokens[2] + end + + local cpuName = string.lower(CS.UnityEngine.SystemInfo.processorType or "") + + -- XLog.Debug("XHardwareManager.CheckGpuAndroid : " .. cpuName) + local deviceModel = CS.UnityEngine.SystemInfo.deviceModel + + if deviceModel and deviceModel ~= "" then + deviceModel = string.lower(deviceModel) + end + + --检查模拟器 + if string.match(gpuName, "direct3d") or string.match(gpuName, "geforce") or string.match(gpuName, "gtx") + or string.match(cpuName, "intel") or string.match(cpuName, "amd") or string.match(cpuName, "intel") + or string.match(gpuName, "mumu") or string.match(gpuName, "nvidia") or string.match(deviceModel, "mumu") then + XLog.Debug("XHardwareManager.SetAndroidSimulator") + XQualityManager.IsSimulator = true + return XRenderQuality.Highest + end + + --检查手机 + if string.match(token1, "vivante") then + return XRenderQuality.Middle + elseif token1 == "adreno" then + return XHardwareManager.CheckGpuAdreno(tokens) + elseif token1 == "powervr" or token1 == "imagination" or token1 == "sgx" or token1 == "rogue" then + return XHardwareManager.CheckGpuPowerVR(tokens) + elseif token1 == "arm" or token1 == "mali" or (tokenLength > 1 and token2 and token2 == "mali") then + return XHardwareManager.CheckGpuMali(tokens) + elseif token1 == "tegra" then + return XHardwareManager.CheckGpuTegra(tokens) + end + + XLog.Error("XHardwareManager.CheckGpuAndroid: Getting quality fail, unknow device, gpu name = \"" .. gpuName .. "\"." .. " cpuName=" .. cpuName) + + return XRenderQuality.Middle +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XHaruUserManager.lua b/Resources/Scripts/XManager/XHaruUserManager.lua new file mode 100644 index 00000000..dabeba2f --- /dev/null +++ b/Resources/Scripts/XManager/XHaruUserManager.lua @@ -0,0 +1,76 @@ +XHaruUserManager = XHaruUserManager or {} + +local AccountList = {} +local AccountDict = {} +local IsLoadList = false + +function XHaruUserManager.IsNeedLogin() + return not XUserManager.UserId or #XUserManager.UserId == 0 +end + +function XHaruUserManager.Login(cb) + if XHaruUserManager.IsNeedLogin() then + CsXUiManager.Instance:Open("UiRegister", cb) + end +end + +function XHaruUserManager.Logout(cb) + if XHaruUserManager.IsNeedLogin() then + if cb then + cb() + end + + return + end + + if XDataCenter.FunctionEventManager.CheckFuncDisable() then + XUserManager.SignOut() + else + local title = CS.XTextManager.GetText("TipTitle") + local content = CS.XTextManager.GetText("LoginSignOut") + local dialogType = XUiManager.DialogType.Normal + local closeCallback = nil + local sureCallback = function() + XUserManager.SignOut() + end + + CsXUiManager.Instance:Open("UiDialog", title, content, dialogType, closeCallback, sureCallback); + end + + if cb then + cb() + end +end + +function XHaruUserManager.SignIn(userId, cb) + AccountDict[userId] = os.time() + IsLoadList = false + XSaveTool.SaveData(XPrefs.AccountHistory, AccountDict) + + XUserManager.SetUserId(userId) + XUserManager.SetUserName(userId) + if cb then + cb() + end +end + +function XHaruUserManager.GetAccountList() + if not next(AccountDict) then + AccountDict = XSaveTool.GetData(XPrefs.AccountHistory) or {} + end + if not IsLoadList then + AccountList = {} + for name, v in pairs(AccountDict) do + local account = { + Name = name, + Time = v, + } + table.insert(AccountList, account) + end + table.sort(AccountList, function(a, b) + return a.Time > b.Time + end) + IsLoadList = true + end + return AccountList +end diff --git a/Resources/Scripts/XManager/XHeadPortraitManager.lua b/Resources/Scripts/XManager/XHeadPortraitManager.lua new file mode 100644 index 00000000..363b1aa5 --- /dev/null +++ b/Resources/Scripts/XManager/XHeadPortraitManager.lua @@ -0,0 +1,389 @@ +local ParseToTimestamp = XTime.ParseToTimestamp + +XHeadPortraitManagerCreator = function() + + local XHeadPortraitManager = {} + local HeadPortraitQuality = CS.XGame.Config:GetInt("HeadPortraitQuality") + + local HeadPortraitsTemplates = {} + local UnlockHeadInfos = {} + + local SameGroupShowId = {} + local SameGroupInitId = {} + local METHOD_NAME = { + SetHeadPortraitRequest = "SetHeadPortraitRequest", + SetHeadFrameRequest = "SetHeadFrameRequest", + } + + function XHeadPortraitManager.Init() + HeadPortraitsTemplates = XHeadPortraitConfigs.GetHeadPortraitsCfg() + XHeadPortraitManager.InitSameGroupShowId() + end + + function XHeadPortraitManager.InitSameGroupShowId() + local oldPriority + for _, template in pairs(HeadPortraitsTemplates) do + if template.GroupId ~= 0 then + local sameGroupList = SameGroupShowId[template.Type] + local sameGroupInitList = SameGroupInitId[template.Type] + if not sameGroupList then + sameGroupList = {} + SameGroupShowId[template.Type] = sameGroupList + end + + if not sameGroupInitList then + sameGroupInitList = {} + SameGroupInitId[template.Type] = sameGroupInitList + end + + if oldPriority then + if oldPriority > template.Priority then + sameGroupList[template.GroupId] = template.Id + sameGroupInitList[template.GroupId] = template.Id + oldPriority = template.Priority + end + else + sameGroupList[template.GroupId] = template.Id + sameGroupInitList[template.GroupId] = template.Id + oldPriority = template.Priority + end + end + end + end + + function XHeadPortraitManager.UpdateSameGroupShowId(Id) + local templates = HeadPortraitsTemplates[Id] + local groupId = templates and templates.GroupId or 0 + + if groupId ~= 0 then + local type = templates.Type + local oldId = SameGroupShowId[type][groupId] + XHeadPortraitManager.SetHeadPortraitForOld(oldId) + XHeadPortraitManager.RemoveHeadPortraitInfo({ oldId }) + SameGroupShowId[type][groupId] = Id + + local currId = 0 + if type == XHeadPortraitConfigs.HeadType.HeadPortrait then + currId = XPlayer.CurrHeadPortraitId or 0 + elseif type == XHeadPortraitConfigs.HeadType.HeadFrame then + currId = XPlayer.CurrHeadFrameId or 0 + end + if currId ~= 0 then + local currTemplates = HeadPortraitsTemplates[currId] + if currTemplates.GroupId == groupId and currTemplates.Id ~= Id then + XDataCenter.HeadPortraitManager.ChangeHeadFrame(Id) + end + end + end + end + + function XHeadPortraitManager.RestSameGroupShowId(Ids) + for _, id in pairs(Ids) do + local templates = HeadPortraitsTemplates[id] + local groupId = templates and templates.GroupId or 0 + + if groupId ~= 0 then + local type = templates.Type + SameGroupShowId[type][groupId] = SameGroupInitId[type][groupId] + end + end + end + + function XHeadPortraitManager.CheckIsNewHeadPortrait(type) + local IsHaveNew = false + local HeadPortraitIds = XHeadPortraitManager.GetUnlockedHeadPortraitIds(type) + for _, v in pairs(HeadPortraitIds) do + if XHeadPortraitManager.CheckIsNewHeadPortraitById(v.Id) then + IsHaveNew = true + end + end + + return IsHaveNew + end + + function XHeadPortraitManager.CheckIsHideTime(id) + local template = HeadPortraitsTemplates[id] + if not template then + return false + end + + local showTime = ParseToTimestamp(template.ShowTimeStr) + if not showTime then + return false + end + return XTime.GetServerNowTimestamp() < showTime + end + + function XHeadPortraitManager.CheckIsNewHeadPortraitById(Id) + local IsHaveNew = false + + if XSaveTool.GetData(string.format("%d%s%d", XPlayer.Id, "NewHeadPortrait", Id)) then + IsHaveNew = true + end + + if not XHeadPortraitManager.IsHeadPortraitValid(Id) then + IsHaveNew = false + end + + return IsHaveNew + end + + function XHeadPortraitManager.SetHeadPortraitForOld(Id) + if XSaveTool.GetData(string.format("%d%s%d", XPlayer.Id, "NewHeadPortrait", Id)) then + XSaveTool.RemoveData(string.format("%d%s%d", XPlayer.Id, "NewHeadPortrait", Id)) + end + end + + function XHeadPortraitManager.AddNewHeadPortrait(Id) + if not XSaveTool.GetData(string.format("%d%s%d", XPlayer.Id, "NewHeadPortrait", Id)) then + XSaveTool.SaveData(string.format("%d%s%d", XPlayer.Id, "NewHeadPortrait", Id), Id) + end + end + + function XHeadPortraitManager.ChangeHeadPortrait(id, cb) + XNetwork.Call(METHOD_NAME.SetHeadPortraitRequest, { Id = id }, function(response) + if response.Code ~= XCode.Success then + XUiManager.TipCode(response.Code) + return + end + + XPlayer.SetHeadPortrait(id) + if cb then cb() end + end) + end + + function XHeadPortraitManager.ChangeHeadFrame(id, cb) + XNetwork.Call(METHOD_NAME.SetHeadFrameRequest, { Id = id }, function(response) + if response.Code ~= XCode.Success then + XUiManager.TipCode(response.Code) + return + end + + XPlayer.SetHeadFrame(id) + if cb then cb() end + end) + end + + function XHeadPortraitManager.GetUnlockedHeadPortraitIds(type) + local list = {} + for id, v in pairs(HeadPortraitsTemplates) do + if not XHeadPortraitManager.CheckIsHideTime(id) then + if not type or v.Type == type then + if v.GroupId == 0 then + table.insert(list, v) + else + if SameGroupShowId[v.Type][v.GroupId] == v.Id then + table.insert(list, v) + end + end + end + end + end + + table.sort(list, function(headA, headB) + local weightA = XHeadPortraitManager.IsHeadPortraitValid(headA.Id) and 1 or 0 + local weightB = XHeadPortraitManager.IsHeadPortraitValid(headB.Id) and 1 or 0 + if weightA == weightB then + return headA.Priority < headB.Priority + end + return weightA > weightB + end) + + return list + end + + function XHeadPortraitManager.IsHeadPortraitValid(headId) + local template = HeadPortraitsTemplates[headId] + if not template then + return false + end + + local headInfo = UnlockHeadInfos[headId] + if not headInfo then + return false + end + + if template.LimitType == XHeadPortraitConfigs.HeadTimeLimitType.Forever then + return true + elseif template.LimitType == XHeadPortraitConfigs.HeadTimeLimitType.Duration then + return XTime.GetServerNowTimestamp() - headInfo.BeginTime < headInfo.LeftCount * template.Duration + elseif template.LimitType == XHeadPortraitConfigs.HeadTimeLimitType.FixedTime then + return XTime.GetServerNowTimestamp() > XHeadPortraitManager.GetBeginTimestamp(headId) + and XTime.GetServerNowTimestamp() < XHeadPortraitManager.GetEndTimestamp(headId) + end + + return false + end + + function XHeadPortraitManager.AsyncHeadPortraitInfos(heads, IsAddNew) + if not UnlockHeadInfos then + UnlockHeadInfos = {} + end + + for _, v in pairs(heads or {}) do + XHeadPortraitManager.UpdateSameGroupShowId(v.Id) + UnlockHeadInfos[v.Id] = v + if IsAddNew then + XHeadPortraitManager.AddNewHeadPortrait(v.Id) + end + end + end + + function XHeadPortraitManager.CheckIsUnLockHead(headId) + return UnlockHeadInfos[headId] and true or false + end + + function XHeadPortraitManager.GetHeadPortraitData() + return HeadPortraitsTemplates + end + + function XHeadPortraitManager.GetHeadPortraitInfoById(id) + return id and HeadPortraitsTemplates[id] + end + + function XHeadPortraitManager.GetHeadPortraitNumById(id, type) + local num = 0 + local Ids = XHeadPortraitManager.GetUnlockedHeadPortraitIds(type) + local IsHave = false + for _, v in pairs(Ids) do + num = num + 1 + if v.Id == id then + IsHave = true + break + end + end + + return IsHave and num or 0 + end + + function XHeadPortraitManager.GetHeadPortraitQualityById(id) + local templates = HeadPortraitsTemplates[id] + return templates and templates.Quality or 1 + end + + function XHeadPortraitManager.GetHeadPortraitNameById(id) + if not HeadPortraitsTemplates[id] then + return "" + end + + return HeadPortraitsTemplates[id].Name + end + + function XHeadPortraitManager.GetHeadPortraitImgSrcById(id) + if not HeadPortraitsTemplates[id] then + return + end + + return HeadPortraitsTemplates[id].ImgSrc + end + + + function XHeadPortraitManager.GetHeadPortraitEffectById(id) + if not HeadPortraitsTemplates[id] then + return + end + + return HeadPortraitsTemplates[id].Effect + end + + function XHeadPortraitManager.GetHeadPortraitLockDescId(id) + if not HeadPortraitsTemplates[id] then + return "" + end + + return HeadPortraitsTemplates[id].LockDescId + end + + function XHeadPortraitManager.GetHeadPortraitDescriptionById(id) + if not HeadPortraitsTemplates[id] then + return "" + end + + return HeadPortraitsTemplates[id].Description + end + + function XHeadPortraitManager.GetHeadPortraitWorldDescById(id) + if not HeadPortraitsTemplates[id] then + return "" + end + + return HeadPortraitsTemplates[id].WorldDesc + end + + function XHeadPortraitManager.GetBeginTimestamp(id) + if not HeadPortraitsTemplates[id] then + return 0 + end + + return XFunctionManager.GetStartTimeByTimeId(HeadPortraitsTemplates[id].TimeId) or 0 + end + + function XHeadPortraitManager.GetEndTimestamp(id) + if not HeadPortraitsTemplates[id] then + return 0 + end + + return XFunctionManager.GetEndTimeByTimeId(HeadPortraitsTemplates[id].TimeId) or 0 + end + + function XHeadPortraitManager.GetHeadLeftTime(id) + local template = HeadPortraitsTemplates[id] + if not template then + return "" + end + + local headInfo = UnlockHeadInfos[id] + if not headInfo then + return "" + end + + local duration = template.Duration * headInfo.LeftCount + local leftTime = duration - (XTime.GetServerNowTimestamp() - headInfo.BeginTime) + + return CS.XTextManager.GetText("HeadLeftTimeText", XUiHelper.GetTime(leftTime, XUiHelper.TimeFormatType.HEADPORTRAIT)) + end + + function XHeadPortraitManager.GetHeadValidDuration(id) + local template = HeadPortraitsTemplates[id] + if not template then + return "" + end + + return CS.XTextManager.GetText("HeadValidTimeText", XUiHelper.GetTime(template.Duration, XUiHelper.TimeFormatType.HEADPORTRAIT)) + end + + function XHeadPortraitManager.RemoveHeadPortraitInfo(ids) + if not UnlockHeadInfos then + return + end + + for _, id in pairs(ids) do + UnlockHeadInfos[id] = nil + end + end + + XHeadPortraitManager.Init() + return XHeadPortraitManager +end + +XRpc.NotifyHeadPortraitInfos = function(data) + if not data then + return + end + + XDataCenter.HeadPortraitManager.AsyncHeadPortraitInfos(data.Heads, true) + XEventManager.DispatchEvent(XEventId.EVENT_HEAD_PORTRAIT_NOTIFY) +end + +XRpc.NotifyHeadTimeout = function(data) + XPlayer.SetHeadPortrait(data.CurrHeadPortraitId) + XPlayer.SetHeadFrame(data.CurrHeadFrameId) + + XDataCenter.HeadPortraitManager.SetHeadPortraitForOld(data.CurrHeadPortraitId) + XDataCenter.HeadPortraitManager.SetHeadPortraitForOld(data.CurrHeadFrameId) + + XDataCenter.HeadPortraitManager.RemoveHeadPortraitInfo(data.TimeoutIds) + XDataCenter.HeadPortraitManager.RestSameGroupShowId(data.TimeoutIds) + XEventManager.DispatchEvent(XEventId.EVENT_HEAD_PORTRAIT_NOTIFY) + XEventManager.DispatchEvent(XEventId.EVENT_HEAD_PORTRAIT_TIMEOUT) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XHeroSdkManager.lua b/Resources/Scripts/XManager/XHeroSdkManager.lua new file mode 100644 index 00000000..1bd60f3d --- /dev/null +++ b/Resources/Scripts/XManager/XHeroSdkManager.lua @@ -0,0 +1,291 @@ +XHeroSdkManager = XHeroSdkManager or {} + +local Json = require("XCommon/Json") + +local Application = CS.UnityEngine.Application +local Platform = Application.platform +local RuntimePlatform = CS.UnityEngine.RuntimePlatform + +local IsSdkLogined = false +local LogoutSccess = 0 +local LogoutFailed = 1 +local LogoutCb = nil +local LastTimeOfCallSdkLoginUi = 0 +local CallLoginUiCountDown = 2 +local HeroRoleInfo = CS.XHeroRoleInfo +local HeroOrderInfo = CS.XHeroOrderInfo +local PayCallbacks = {} -- android 充值回调 +local IOSPayCallback = nil -- iOS 充值回调 +local HasSdkLoginError = false -- sdk登陆存在错误 +--local CallbackUrl = "http://haru.free.idcfengye.com/api/XPay/HeroPayResult" +local CallbackUrl = CS.XRemoteConfig.PayCallbackUrl +local XRecordUserInfo = CS.XRecord.XRecordUserInfo + +local CleanPayCallbacks = function() + PayCallbacks = {} + IOSPayCallback = nil +end + +function XHeroSdkManager.IsNeedLogin() + return not (CS.XHeroSdkAgent.IsLogined() and IsSdkLogined) +end + +function XHeroSdkManager.HasLoginError() + return HasSdkLoginError +end + +function XHeroSdkManager.Login() + if not XHeroSdkManager.IsNeedLogin() then + CS.XRecord.Record("24035", "HeroSdkRepetitionLogin") + return + end + + local curTime = CS.UnityEngine.Time.realtimeSinceStartup + if curTime - LastTimeOfCallSdkLoginUi < CallLoginUiCountDown then + CS.XRecord.Record("24036", "HeroSdkShortTimeLogin") + return + end + LastTimeOfCallSdkLoginUi = curTime + + HasSdkLoginError = false + CS.XRecord.Record("24023", "HeroSdkLogin") + CS.XHeroSdkAgent.Login() +end + +function XHeroSdkManager.Logout(cb) + if XHeroSdkManager.IsNeedLogin() then + if cb then + cb(LogoutFailed) + end + return + end + + LogoutCb = cb + CS.XRecord.Record("24029", "HeroSdkLogout") + CS.XHeroSdkAgent.Logout() + + if Platform == RuntimePlatform.IPhonePlayer then + -- iOS 无回调,直接调用退出 + XHeroSdkManager.OnLogoutSuccess() + end +end + +function XHeroSdkManager.OnLoginSuccess(uid, username, token) + if IsSdkLogined and XUserManager.UserId ~= uid then + XLog.Error("重复的登陆成功回调 user_id1:" .. tostring(XUserManager.UserId) .. ", user_id2:" .. tostring(uid)) + HasSdkLoginError = true + end + IsSdkLogined = true + LastTimeOfCallSdkLoginUi = 0 + local info = XRecordUserInfo() + info.UserId = uid + info.UserName = username + CS.XRecord.Login(info) + CS.XRecord.Record("24024", "HeroSdkLoginSuccess") + CleanPayCallbacks() + XUserManager.SetUserId(uid) + XUserManager.SetUserName(username) + XUserManager.SetToken(token) +end + +function XHeroSdkManager.OnLoginFailed(msg) + XLog.Error("Hero sdk login failed. " .. msg) + IsSdkLogined = false + CS.XRecord.Record("24032", "HeroSdkLoginFailed") + + LastTimeOfCallSdkLoginUi = 0 + XUiManager.SystemDialogTip(CS.XTextManager.GetText("TipTitle"), CS.XTextManager.GetText("HeroSdkLoginFailed"), XUiManager.DialogType.OnlySure, nil, function() + XHeroSdkManager.Login() + end) +end + +function XHeroSdkManager.OnLoginCancel() + IsSdkLogined = false + LastTimeOfCallSdkLoginUi = 0 + -- CS.XRecord.Record("24032", "HeroSdkLoginFailed") +end + +function XHeroSdkManager.OnSwitchAccountSuccess(uid, username, token) + local info = XRecordUserInfo() + info.UserId = uid + info.UserName = username + CS.XRecord.Login(info) + CS.XRecord.Record("24025", "HeroSdkSwitchAccountSuccess") + CleanPayCallbacks() + XUserManager.OnSwitchAccountSuccess(uid, username, token) +end + +function XHeroSdkManager.OnSwitchAccountFailed(msg) + CS.XRecord.Record("24026", "HeroSdkSwitchAccountFailed") + XUiManager.SystemDialogTip(CS.XTextManager.GetText("TipTitle"), msg, XUiManager.DialogType.OnlySure, nil, nil) +end + +function XHeroSdkManager.OnSwitchAccountCancel() + --TODO +end + +function XHeroSdkManager.OnLogoutSuccess() + IsSdkLogined = false + CS.XRecord.Record("24027", "HeroSdkLogoutSuccess") + CS.XRecord.Logout() + CleanPayCallbacks() + XUserManager.SignOut() + + if LogoutCb then + LogoutCb(LogoutSccess) + LogoutCb = nil + end +end + +function XHeroSdkManager.OnLogoutFailed(msg) + IsSdkLogined = true + CS.XRecord.Record("24028", "HeroSdkLogoutFailed") + XUiManager.SystemDialogTip(CS.XTextManager.GetText("TipTitle"), msg, XUiManager.DialogType.OnlySure, nil, nil) + + if LogoutCb then + LogoutCb(LogoutFailed) + LogoutCb = nil + end +end + +function XHeroSdkManager.OnSdkKickOff(msg) + XLog.Debug("XHeroSdkManager.OnSdkKickOff() msg = " .. msg) + XDataCenter.AntiAddictionManager.Kick(msg) +end + +local GetRoleInfo = function() + local roleInfo = HeroRoleInfo() + roleInfo.Id = XPlayer.Id + roleInfo.ServerId = XServerManager.Id + roleInfo.ServerName = XServerManager.ServerName + roleInfo.Name = XPlayer.Name + roleInfo.Level = XPlayer.Level + roleInfo.CreateTime = XPlayer.CreateTime + roleInfo.PaidGem = XDataCenter.ItemManager.GetCount(XDataCenter.ItemManager.ItemId.PaidGem) + roleInfo.Coin = XDataCenter.ItemManager.GetCount(XDataCenter.ItemManager.ItemId.Coin) + roleInfo.SumPay = 0 + roleInfo.VipLevel = 0 + roleInfo.PartyName = nil + + return roleInfo +end + +function XHeroSdkManager.EnterGame() + if XUserManager.Channel ~= XUserManager.CHANNEL.HERO then + return + end + CS.XHeroSdkAgent.EnterGame(GetRoleInfo()) +end + +function XHeroSdkManager.CreateNewRole() + if XUserManager.Channel ~= XUserManager.CHANNEL.HERO then + return + end + CS.XHeroSdkAgent.CreateNewRole(GetRoleInfo()) +end + +function XHeroSdkManager.RoleLevelUp() + if XUserManager.Channel ~= XUserManager.CHANNEL.HERO then + return + end + CS.XHeroSdkAgent.RoleLevelUp(GetRoleInfo()) +end + +local GetOrderInfo = function(cpOrderId, goodsId, extraParams) + local orderInfo = HeroOrderInfo() + orderInfo.CpOrderId = cpOrderId + orderInfo.GoodsId = goodsId + + if extraParams and _G.next(extraParams) then + orderInfo.ExtraParams = Json.encode(extraParams) + end + + -- if productInfo.GoodsName and #productInfo.GoodsName > 0 then + -- orderInfo.GoodsName = productInfo.GoodsName + -- end + -- if productInfo.GoodsDesc and #productInfo.GoodsDesc > 0 then + -- orderInfo.GoodsDesc = productInfo.GoodsDesc + -- end + -- if productInfo.Amount and productInfo.Amount > 0 then + -- orderInfo.Amount = productInfo.Amount + -- end + -- if productInfo.Price and productInfo.Price > 0 then + -- orderInfo.Price = productInfo.Price + -- end + -- if productInfo.Count and productInfo.Count > 0 then + -- orderInfo.Count = productInfo.Count + -- end + if CallbackUrl then + orderInfo.CallbackUrl = CallbackUrl + end + + return orderInfo +end + +function XHeroSdkManager.Pay(productKey, cpOrderId, goodsId, cb) + -- local extraParams = { + -- PlayerId = XPlayer.Id, + -- ProductKey = productKey, + -- CpOrderId = cpOrderId, + -- ProductId = productInfo.ProductId + -- } + if Platform == RuntimePlatform.Android then + PayCallbacks[cpOrderId] = { + cb = cb, + info = { + ProductKey = productKey, + CpOrderId = cpOrderId, + GoodsId = goodsId, + PlayerId = XPlayer.Id + } + } + end + + local order = GetOrderInfo(cpOrderId, goodsId) + CS.XHeroSdkAgent.Pay(order, GetRoleInfo()) + XDataCenter.AntiAddictionManager.BeginPayAction() +end + +function XHeroSdkManager.OnPayAndSuccess(sdkOrderId, cpOrderId) + local cbInfo = PayCallbacks[cpOrderId] + if cbInfo and cbInfo.cb then + cbInfo.info.sdkOrderId = sdkOrderId + cbInfo.cb(nil, cbInfo.info) + end + + PayCallbacks[cpOrderId] = nil + XDataCenter.AntiAddictionManager.EndPayAction() +end + +function XHeroSdkManager.OnPayAndFailed(cpOrderId, msg) + local cbInfo = PayCallbacks[cpOrderId] + if cbInfo and cbInfo.cb then + cbInfo.cb(msg, cbInfo.info) + end + + PayCallbacks[cpOrderId] = nil + XDataCenter.AntiAddictionManager.EndPayAction() +end + +function XHeroSdkManager.OnPayAndCancel(cpOrderId) + PayCallbacks[cpOrderId] = nil + XDataCenter.AntiAddictionManager.EndPayAction() +end + +function XHeroSdkManager.OnPayIOSSuccess(orderId) + if IOSPayCallback then + IOSPayCallback(nil, orderId) + end + XDataCenter.AntiAddictionManager.EndPayAction() +end + +function XHeroSdkManager.OnPayIOSFailed(msg) + if IOSPayCallback then + IOSPayCallback(msg) + end + XDataCenter.AntiAddictionManager.EndPayAction() +end + +function XHeroSdkManager.RegisterIOSCallback(cb) + IOSPayCallback = cb +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XHgSdkManager.lua b/Resources/Scripts/XManager/XHgSdkManager.lua new file mode 100644 index 00000000..234ec3a4 --- /dev/null +++ b/Resources/Scripts/XManager/XHgSdkManager.lua @@ -0,0 +1,534 @@ +XHgSdkManager = XHgSdkManager or {} + +local Json = require("XCommon/Json") + +local Application = CS.UnityEngine.Application +local Platform = Application.platform +local RuntimePlatform = CS.UnityEngine.RuntimePlatform + +local IsSdkLogined = false + +local LastTimeOfCallSdkLoginUi = 0 +local CallLoginUiCountDown = 2 + +local HgOrderInfo = CS.XHgOrderInfo + +local PayCallbacks = {} -- android 充值回调 +local IOSPayCallback = nil -- iOS 充值回调 + +local CallbackUrl = CS.XRemoteConfig.PayCallbackUrl + +local XRecordUserInfo = CS.XRecord.XRecordUserInfo + +local CleanPayCallbacks = function() + PayCallbacks = {} + IOSPayCallback = nil +end + +XHgSdkManager.UserType = { + Quickly = 2333, -- 快速登录(没有默认游客,有账号就上次登录) + Vistor = 0, + FaceBook = 1, + Google = 2, + GameCenter = 3, + WeChat = 4, + Twitter = 5, + Line = 6, + Apple = 7, + Line = 8, + Suid = 9, + Huawei = 10, + Oppo = 11, +} + +--检测SDK是否已经登录 +local checkNeedLogin = function() + if not XHgSdkManager.IsNeedLogin() then + XLog.Debug("SDK不需要登录") + CS.XRecord.Record("24035", "HeroSdkRepetitionLogin") + return false + end + return true +end + +--检测登录间隔 +local checkLoginTimeTooFast = function() + local curTime = CS.UnityEngine.Time.realtimeSinceStartup + if curTime - LastTimeOfCallSdkLoginUi < CallLoginUiCountDown then + XLog.Debug("请求SDK登录时间过短") + CS.XRecord.Record("24036", "HeroSdkShortTimeLogin") + return false + end + LastTimeOfCallSdkLoginUi = curTime + return true +end + + +function XHgSdkManager.IsNeedLogin() + return not IsSdkLogined +end + +function XHgSdkManager.SetCallBackUrl(url) + CallbackUrl = url +end + +function XHgSdkManager.LoginQuickly() + XLog.Debug("SDK登录类型:快速登录"); + CS.XHgSdkAgent.LoginQuickly(); +end + +function XHgSdkManager.LoginVisitor() + XLog.Debug("SDK登录类型:游客登录"); + CS.XHgSdkAgent.SwitchAccount(XHgSdkManager.UserType.Vistor); +end + +function XHgSdkManager.LoginGoogle() + XLog.Debug("SDK登录类型:Google登录"); + CS.XHgSdkAgent.SwitchAccount(XHgSdkManager.UserType.Google); +end + +function XHgSdkManager.LoginFacebook() + XLog.Debug("SDK登录类型:Facebook登录"); + CS.XHgSdkAgent.SwitchAccount(XHgSdkManager.UserType.FaceBook); +end + +-- function XHgSdkManager.LoginTourist() +-- XLog.Debug("SDK登录类型:游客登录") +-- CS.XHgSdkAgent.LoginTourist() +-- end + +function XHgSdkManager.LoginTwitter() + XLog.Debug("SDK登录类型:Twitter登录") + -- CS.XHgSdkAgent.LoginTwitter() + CS.XHgSdkAgent.SwitchAccount(XHgSdkManager.UserType.Twitter); +end + +function XHgSdkManager.LoginLine() + XLog.Debug("SDK登录类型:Line登录") + -- CS.XHgSdkAgent.LoginLine() + CS.XHgSdkAgent.SwitchAccount(XHgSdkManager.UserType.Line); +end + +function XHgSdkManager.LoginApple() + XLog.Debug("SDK登录类型:Apple登录") + -- CS.XHgSdkAgent.LoginApple() + CS.XHgSdkAgent.SwitchAccount(XHgSdkManager.UserType.Apple); +end + +function XHgSdkManager.LoginHuawei() + XLog.Debug("SDK登录类型:华为登录"); + CS.XHgSdkAgent.SwitchAccount(XHgSdkManager.UserType.Huawei); +end + +function XHgSdkManager.LoginSid() + XLog.Debug("SDK登录类型:引继码登录") + CS.XHgSdkAgent.LoginSid() +end + +function XHgSdkManager.LoginOppo() + XLog.Debug("SDK登录类型:Oppo登录"); + CS.XHgSdkAgent.SwitchAccount(XHgSdkManager.UserType.Oppo); +end + +local loginMethods = { + [XHgSdkManager.UserType.Quickly] = XHgSdkManager.LoginQuickly, + [XHgSdkManager.UserType.Vistor] = XHgSdkManager.LoginVisitor, + [XHgSdkManager.UserType.Google] = XHgSdkManager.LoginGoogle, + [XHgSdkManager.UserType.FaceBook] = XHgSdkManager.LoginFacebook, + [XHgSdkManager.UserType.Apple] = XHgSdkManager.LoginApple, + [XHgSdkManager.UserType.Twitter] = XHgSdkManager.LoginTwitter, + [XHgSdkManager.UserType.Suid] = XHgSdkManager.LoginSid, + [XHgSdkManager.UserType.Huawei] = XHgSdkManager.LoginHuawei, + [XHgSdkManager.UserType.Oppo] = XHgSdkManager.LoginOppo, + [XHgSdkManager.UserType.Line] = XHgSdkManager.LoginLine, +} + +function XHgSdkManager.Login(userType) + --if not checkNeedLogin() then return end + if not checkLoginTimeTooFast() then return end + CS.XRecord.Record("24023", "HeroSdkLogin") + local loginMethod = loginMethods[userType] + if loginMethod == nil then + XLog.Error("登录类型未定义, userType=" .. userType) + return + end + if XUserManager.Channel ~= XUserManager.CHANNEL.KuroPC then + XLuaUiManager.SetAnimationMask("HgLogin", true) + end + loginMethod() +end + +function XHgSdkManager.LoginSuid(account, pass) + --if not checkNeedLogin() then return end + if not checkLoginTimeTooFast() then return end + CS.XRecord.Record("24023", "HeroSdkLogin") + XLog.Debug("SDK登录类型:引继码登录") + XLuaUiManager.SetAnimationMask("HgLogin", true) + CS.XHgSdkAgent.LoginSid(account, pass) +end + +function XHgSdkManager.BackToLogin() + CS.XRecord.Logout() + XUserManager.SignOut() + CleanPayCallbacks() +end + +function XHgSdkManager.Logout() + if XHgSdkManager.IsNeedLogin() then + XLog.Debug("SDK无需登出") + return + end + + XLog.Debug("登出成功") + CS.XHgSdkAgent.Logout() + IsSdkLogined = false + CS.XRecord.Record("24027", "HeroSdkLogoutSuccess") + CS.XRecord.Record("24029", "HeroSdkLogout") + CS.XRecord.Logout() + XUserManager.SignOut() + CleanPayCallbacks() +end + +function XHgSdkManager.OnLoginSuccess(jsondata) + XLog.Debug("SDK登录成功") + --CheckPoint: APPEVENT_SDK_INITIALIZE + XAppEventManager.AppLogEvent(XAppEventManager.CommonEventNameConfig.SDK_Initialize) + XLuaUiManager.SetAnimationMask("HgLogin", false) + IsSdkLogined = true + XLog.Debug("--------------jsondata---------------") + XLog.Debug(jsondata) + local data = Json.decode(jsondata) + + local info = XRecordUserInfo() + + local userId = data.uid + local userType = data.userType + local pwdStatus = data.pwdStatus + + if XUserManager.Channel == XUserManager.CHANNEL.IOS then + userId = data.suid + userType = tonumber(data.type) + pwdStatus = tonumber(data.pwdStatus) + end + + info.UserId = userId + CS.XRecord.Login(info) + CS.XRecord.Record("24024", "HeroSdkLoginSuccess") + CleanPayCallbacks() + XUserManager.SetUserId(userId) + XUserManager.SetToken(data.token) + XUserManager.SetUserType(userType) + XUserManager.SetPasswordStatus(pwdStatus) + XLoginManager.SetSDKAccountStatus(tonumber(data.logoutStatus)) + if XLoginManager.GetSDKAccountStatus() == XLoginManager.SDKAccountStatus.Cancellation then + XUiManager.DialogTip(CS.XGame.ClientConfig:GetString("AccountUnCancellationTitle"), CS.XGame.ClientConfig:GetString("AccountUnCancellationContent"), nil, function() end, function() + XHgSdkManager.AccountUnCancellation() + end) + end + XEventManager.DispatchEvent(XEventId.EVNET_HGSDKLOGIN_SUCCESS) +end + +function XHgSdkManager.OnLoginFailed(msg) + XLuaUiManager.SetAnimationMask("HgLogin", false) + XLog.Debug("SDK登录失败: " .. msg) + --IsSdkLogined = false + CS.XRecord.Record("24032", "HeroSdkLoginFailed") + LastTimeOfCallSdkLoginUi = 0 + if msg ~= nil and msg ~= "" then + XUiManager.SystemDialogTip(CS.XTextManager.GetText("TipTitle"), msg, XUiManager.DialogType.OnlySure, nil, function() + --XHgSdkManager.Login() + end) + end +end + +function XHgSdkManager.OnLoginCancel(msg) + XLuaUiManager.SetAnimationMask("HgLogin", false) + XLog.Debug("SDK用户取消登录") + --IsSdkLogined = false + LastTimeOfCallSdkLoginUi = 0 + if msg ~= nil and msg ~= "" then + XUiManager.SystemDialogTip(CS.XTextManager.GetText("TipTitle"), msg, XUiManager.DialogType.OnlySure, nil, function() + --XHgSdkManager.Login() + end) + end +end + +function XHgSdkManager.GetBindState() + CS.XHgSdkAgent.GetBindState() +end + +function XHgSdkManager.OnGetBindState(jsonStr) + --{"code":0,"msg":"成功","fbBind":0,"googleBind":0,"gcBind":0,"weChatBind":0,"twitterBind":0,"appleBind":0,"lineBind":0} + XEventManager.DispatchEvent(XEventId.EVENT_HGSDK_GET_BIND, jsonStr) +end + +function XHgSdkManager.StartBind(userType) + CS.XHgSdkAgent.StartBind(userType) +end + +function XHgSdkManager.OnBindSuccess() + XEventManager.DispatchEvent(XEventId.EVENT_HGSDK_BIND_RESULT, true) +end + +function XHgSdkManager.OnBindFailed(msg) + --{"code":2,"msg":"用户已经绑定其它帐号","userType":0} + XEventManager.DispatchEvent(XEventId.EVENT_HGSDK_BIND_RESULT, false, msg) +end + +function XHgSdkManager.SetSUidPass(pass) + CS.XHgSdkAgent.SetSUidPassword(pass) +end + +function XHgSdkManager.OnSetSUidPassSuccess() + XEventManager.DispatchEvent(XEventId.EVENT_HGSDK_SETPASS_RESULT, true) +end + +function XHgSdkManager.OnSetSUidPassFail() + XEventManager.DispatchEvent(XEventId.EVENT_HGSDK_SETPASS_RESULT, false) +end + +function XHgSdkManager.OnLoginUnRegister() + CS.XHgSdkAgent.ShowRegister() +end + +local GetOrderInfo = function(cpOrderId, goodsId, roleId) + local orderInfo = HgOrderInfo() + orderInfo.CpOrderId = cpOrderId + orderInfo.GoodsId = goodsId + orderInfo.RoleId = roleId + orderInfo.RoleName = XPlayer.Name + if CallbackUrl then + orderInfo.CallbackUrl = CallbackUrl + end + return orderInfo +end + +function XHgSdkManager.Pay(productKey, cpOrderId, goodsId, cb) + if Platform == RuntimePlatform.Android then + PayCallbacks[cpOrderId] = { + cb = cb, + info = { + ProductKey = productKey, + CpOrderId = cpOrderId, + GoodsId = goodsId, + PlayerId = XPlayer.Id + } + } + end + local order = GetOrderInfo(cpOrderId, goodsId, XPlayer.Id) + CS.XHgSdkAgent.Pay(order) +end + +function XHgSdkManager.OnPaySuccess(jsondata) + local data = Json.decode(jsondata) + local cpOrderId = data.cpOrderId + local cbInfo = PayCallbacks[cpOrderId] + if cbInfo and cbInfo.cb then + cbInfo.cb(nil, cbInfo.info) + else + --XLog.Debug("XHgSdkManager.OnPaySuccess is nil") + end + PayCallbacks[cpOrderId] = nil +end + +function XHgSdkManager.OnPayFailed(jsondata) + local data = Json.decode(jsondata) + local cpOrderId = data.cpOrderId + local msg = data.msg or "" + local cbInfo = PayCallbacks[cpOrderId] + if cbInfo and cbInfo.cb then + cbInfo.cb(msg, cbInfo.info) + else + --XLog.Debug("XHgSdkManager.OnPayFailed is nil") + end + PayCallbacks[cpOrderId] = nil + --支付失败的时候解锁 + XEventManager.DispatchEvent(XEventId.EVENT_PURCHASEBUY_PAYCANCELORFAIL) +end + +function XHgSdkManager.OnPayCancel(cpOrderId, msg) + --PayCallbacks[cpOrderId] = nil + local text = CS.XTextManager.GetText("PayFail") + XUiManager.DialogTip("", text, XUiManager.DialogType.OnlySure) + XEventManager.DispatchEvent(XEventId.EVENT_PURCHASEBUY_PAYCANCELORFAIL) +end + +function XHgSdkManager.OnPayPending(cpOrderId, msg) + --XLog.Debug("XHgSdkManager.OnPayPending") + --XLog.Debug(cpOrderId) + --XLog.Debug(msg) +end + +function XHgSdkManager.OnPayResultNull() + XEventManager.DispatchEvent(XEventId.EVENT_PURCHASEBUY_PAYCANCELORFAIL) +end + +function XHgSdkManager.OnPayIOSSuccess(jsondata) + local data = Json.decode(jsondata) + local cpOrderId = data.cpOrderId + if IOSPayCallback then + IOSPayCallback(nil, cpOrderId) + end +end + +function XHgSdkManager.OnPayIOSFailed(jsondata) + local data = Json.decode(jsondata) + local msg = data.msg or "" + if IOSPayCallback then + IOSPayCallback(msg) + end + --支付失败的时候解锁 + XEventManager.DispatchEvent(XEventId.EVENT_PURCHASEBUY_PAYCANCELORFAIL) +end + +function XHgSdkManager.RegisterIOSCallback(cb) + IOSPayCallback = cb +end + +function XHgSdkManager.OnRegisterAccountFailed(msg) + +end + +function XHgSdkManager.OnSwitchAccountResultNull() + +end + +function XHgSdkManager.OnSwitchAccountNoRegister(uid, token, pwdStatus, msg) + +end + +function XHgSdkManager.OnRegisterAccountResultNull(msg) + +end + +function XHgSdkManager.OnRegisterAccountSuccess(uid, token, userType) + +end + +function XHgSdkManager.OnRegisterAccountCancel() + +end + +function XHgSdkManager.OnStartBindResultSuccess() + +end + +function XHgSdkManager.OnStartBindResultNull() + +end + +function XHgSdkManager.OnStartBindResultCancel() + +end + +function XHgSdkManager.OnStartBindResultFailed() + +end + +function XHgSdkManager.OnBindTaskFinished() + local taskParam = XTaskConfig.GetTaskCondition(80001).Params[2] + XNetwork.Call("DoClientTaskEventRequest", {ClientTaskType = taskParam}, function(reply) + XLog.Error(reply.Code) + if reply.Code ~= XCode.Success then + return + end + XLog.Debug("引继码任务完成") + end) +end + +local BdcServerBean + +function XHgSdkManager.setServerBeanTmp(serverBean) + BdcServerBean = serverBean +end + +function XHgSdkManager.onServerBeanChangeHandle() + local jsonBdcServerBean = CS.XHeroBdcAgent.GetServerBean() + if jsonBdcServerBean and jsonBdcServerBean ~= "" then + if not BdcServerBean or jsonBdcServerBean ~= BdcServerBean then + BdcServerBean = jsonBdcServerBean + if XLoginManager.IsLogin() then + XLog.Warning("ServerBean数据同步") + XNetwork.Call("SetServerBeanRequest", {ServerBean = BdcServerBean}, function(reply) + if reply.Code ~= XCode.Success then + XLog.Error(reply.Code) + return + end + end) + end + end + end + XLog.Warning("ServerBean修改", jsonBdcServerBean) +end + +function XHgSdkManager.AccountCancellation() + XLog.Debug("Lua层调用注销账号") + if Platform == RuntimePlatform.IPhonePlayer then -- 目前只有ios存在账号注销功能 + CS.XHgSdkAgent.AccountCancellation() + end +end + +function XHgSdkManager.AccountUnCancellation() + XLog.Debug("Lua层调用取消注销账号") + if Platform == RuntimePlatform.IPhonePlayer then -- 目前只有ios存在该功能 + CS.XHgSdkAgent.AccountUnCancellation() + end +end + +function XHgSdkManager.SwitchAccount(userType) + XLog.Debug("SDK开始切换账户"); + CS.XHgSdkAgent.SwitchAccount(userType); +end + +-- 注销账号成功回调 +function XHgSdkManager.OnAccountCancellationSuccess() + XLog.Debug("Lua层注销账号成功回调") + XUserManager.Logout() -- 登出 +end + +-- 取消注销账号回调 +function XHgSdkManager.OnAccountUnCancellation(flag) + XLog.Debug("Lua层取消注销账号回调:"..tostring(flag)) + if flag == "success" then + XLoginManager.SetSDKAccountStatus(XLoginManager.SDKAccountStatus.Normal) + XUiManager.TipMsg(CS.XGame.ClientConfig:GetString("OnAccountUnCancellationSuccessTip")) + end +end + +function XHgSdkManager.OnBdcServerBeanChanged() + if not XLoginManager.IsLogin() then return end -- 如果没登入服务器,不检测bdcServerBean改变,登录时会重新向服务器发送 + local serverBean = CS.XHeroBdcAgent.GetServerBeanStr() + if serverBean and serverBean ~= "" then + XNetwork.Call("SetServerBeanRequest", {ServerBean = serverBean}, function(res) + if res.Code ~= XCode.Success then + XLog.Error("SetServerBeanRequest Error") + return + end + end) + else + XLog.Error("Lua OnBdcServerBeanChanged ServerBean is Nil") + end +end + +function XHgSdkManager.GetDeepLinkValue() + if not deepLinkValue or deepLinkValue == "" then + deepLinkValue = CS.XAppsflyerEvent.GetDeepLinkValue() + end + if deepLinkValue and deepLinkValue ~= "" then + XLog.Debug("DeepLinkValue:"..tostring(deepLinkValue)) + return deepLinkValue + end +end + +function XHgSdkManager.PushDeepLinkEvent() + local deepLinkValue = XHgSdkManager.GetDeepLinkValue() + if CS.XRemoteConfig.AFDeepLinkEnabled and not string.IsNilOrEmpty(deepLinkValue) then + if XLuaUiManager.IsUiShow("UiLogin") then -- 登录界面唤醒自动登录 + XEventManager.DispatchEvent(XEventId.EVENT_DEEPLINK_PUSH_TO_LOGIN) + elseif XLuaUiManager.IsUiShow("UiMain") then -- 主界面直接跳转 + XEventManager.DispatchEvent(XEventId.EVENT_MAINUI_ENABLE) + else + XHgSdkManager.ClearDeepLinkValue() + end + end +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XHostelDelegateManager.lua b/Resources/Scripts/XManager/XHostelDelegateManager.lua new file mode 100644 index 00000000..b3f1918c --- /dev/null +++ b/Resources/Scripts/XManager/XHostelDelegateManager.lua @@ -0,0 +1,191 @@ +XHostelDelegateManagerCreator = function() + + local XHostelDelegateManager = {} + XHostelDelegateManager.FunctionDeviceType = { + Unknown = -1, --未知类型 + Electric = 1, --电量 + } + + local TABLE_HOSTELDELEGATE_PATH = "Share/Hostel/HostelDelegate.tab" + + + local HostelDelegateTemplate = {} + local HostelDeviceDelegate = {} + -- local HostelDelegateAssitPlayer = 0 + -- local HostelDelegateAssitPerPlayerCount = 0 + + local table_insert = table.insert + + --玩家数据 + -- local AssistCountMap = {} + local DelegataList = {} + local DelegateReport = {} + local FriendDelegateData = {} --好友的数据 + + local PROTOCAL_REQUEST_NAME = { + PublishDelegateRequest = "PublishDelegateRequest", + FinishDelegateRequest = "FinishDelegateRequest", + FriendHostelDelegateRequest = "FriendHostelDelegateRequest" + } + + function XHostelDelegateManager.Init() + HostelDelegateTemplate = XTableManager.ReadByIntKey(TABLE_HOSTELDELEGATE_PATH, XTable.XTableHostelDelegate, "DelegateType") + for _, v in pairs(HostelDelegateTemplate) do + local slotConfig = XDataCenter.HostelManager.GetFuncDeviceSlotTemplate(v.SlotType) + if slotConfig then + local deviceType = slotConfig.BelongType + if not HostelDeviceDelegate[deviceType] then + HostelDeviceDelegate[deviceType] = {} + end + table_insert(HostelDeviceDelegate[deviceType], v.DelegateType) + end + end + + -- HostelDelegateAssitPlayer = CS.XGame.Config:GetInt("HostelDelegateAssitPlayer") + -- HostelDelegateAssitPerPlayerCount = CS.XGame.Config:GetInt("HostelDelegateAssitPerPlayerCount") + end + ----------------配置处理----------------------- + function XHostelDelegateManager.GetDelegateTemplateByType(delegateType) + return HostelDelegateTemplate[delegateType] + end + + function XHostelDelegateManager.GetDelegateListByDeviceType(deviceType) + return HostelDeviceDelegate[deviceType] + end + + ----------------模块逻辑----------------------- + function XHostelDelegateManager.InitHostelDelegateData(hostelDelegate) + if not hostelDelegate then + return + end + + -- XTool.LoopMap(hostelDelegate.AssistCountMap, function(key, value) + -- AssistCountMap[key] = value + -- end) + + XTool.LoopCollection(hostelDelegate.DelegataList, function(data) + table_insert(DelegataList, data) + end) + + XTool.LoopCollection(hostelDelegate.DelegateReport, function(data) + table_insert(DelegateReport, data) + end) + end + + function XHostelDelegateManager.GetHostelDelegateCount(delegateType) + local totalCount = 0 + local doneCount = 0 + for _, v in ipairs(DelegataList) do + if v.DelegateType == delegateType then + totalCount = totalCount + 1 + if v.IsDone then + doneCount = doneCount + 1 + end + end + end + return totalCount, doneCount + end + + function XHostelDelegateManager.SetDelegateDone(delegateType) + for _, v in ipairs(DelegataList) do + if v.DelegateType == delegateType and not v.IsDone then + v.IsDone = true + end + end + end + + function XHostelDelegateManager.GetDelegateReportList() + return DelegateReport + end + + -------------------消息通信-------------------------- + function XHostelDelegateManager.ReqPublishDelegate(delegateType, count, cb) + XNetwork.Call(PROTOCAL_REQUEST_NAME.PublishDelegateRequest, { DelegateType = delegateType, Count = count }, function(response) + if response.Code ~= XCode.Success then + XUiManager.TipCode(response.Code) + return + end + --TODO 直接保存个数 + -- XTool.LoopCollection(dataList.DelegataList, function(data) + -- table_insert(DelegataList, data) + -- end) + if cb then + cb() + end + end) + end + + function XHostelDelegateManager.ReqFinishDelegate(playerId, delegateType, completeType, cb) + XNetwork.Call(PROTOCAL_REQUEST_NAME.FinishDelegateRequest, { PlayerId = playerId, DelegateType = delegateType, CompleteType = completeType }, + function(response) + if response.Code ~= XCode.Success then + XUiManager.TipCode(response.Code) + return + end + if cb then + cb() + end + end) + end + + function XHostelDelegateManager.ReqFriendHostelDelegateData(playerId) + XNetwork.Call(PROTOCAL_REQUEST_NAME.FriendHostelDelegateRequest, { PlayerId = playerId }, function(response) + if response.Code ~= XCode.Success then + XUiManager.TipCode(response.Code) + return + end + + XHostelDelegateManager.OnSyncFriendHostelDelegateList(playerId, response.Datas) + -- if cb then + -- cb() + -- end + end) + end + + function XHostelDelegateManager.OnSyncDelegateReport(report) + table_insert(DelegateReport, report) + end + + function XHostelDelegateManager.OnSyncDelegateDateReset() + -- AssistCountMap = {} + DelegataList = {} + end + + function XHostelDelegateManager.OnSyncAssistCount() + -- AssistCountMap[playerId] = count + end + + function XHostelDelegateManager.OnSyncDelegateDone(delegateType) + XHostelDelegateManager.SetDelegateDone(delegateType) + end + + function XHostelDelegateManager.OnSyncFriendHostelDelegateList(playerId, dataList) + FriendDelegateData[playerId] = {} + XTool.LoopCollection(dataList.DelegataList, function(data) + table_insert(FriendDelegateData[playerId], data) + end) + end + + XHostelDelegateManager.Init() + return XHostelDelegateManager +end + +XRpc.NotifyDelegateReport = function(data) + XDataCenter.HostelDelegateManager.OnSyncDelegateReport(data.Report) +end + +XRpc.NotifyResetDelegateData = function() + XDataCenter.HostelDelegateManager.OnSyncDelegateDateReset() +end + +XRpc.NotifyAssistCount = function(data) + XDataCenter.HostelDelegateManager.OnSyncAssistCount(data.AssistData.TargetId, data.AssistData.Count) +end + +XRpc.NotifyDelegateDone = function(data) + XDataCenter.HostelDelegateManager.OnSyncDelegateDone(data.DelegateType) +end + +XRpc.NotifyFriendDelegateData = function(msg) + XDataCenter.HostelDelegateManager.OnSyncFriendHostelDelegateList(msg.FriendId, msg.Datas) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XHostelManager.lua b/Resources/Scripts/XManager/XHostelManager.lua new file mode 100644 index 00000000..d9df1837 --- /dev/null +++ b/Resources/Scripts/XManager/XHostelManager.lua @@ -0,0 +1,600 @@ +XHostelManagerCreator = function() + + local XHostelManager = {} + XHostelManager.FunctionDeviceType = { + Unknown = -1, --未知类型 + MainComputer = 1, --主电脑 + PowerStation = 2, --发电站 + Factory = 3, --工厂 + FucEnd = 4, + + PowerSlotA = 201, -- 发电站槽位A + PowerSlotB = 202, -- 发电站槽位B + PowerSlotC = 203, -- 发电站槽位C + + FactorySlotA = 301, + FactorySlotB = 302, + FactorySlotC = 303, + FactorySlotD = 304, + FactorySlotE = 305, + FactorySlotF = 306, + } + + XHostelManager.WorkSlotState = { + Unknown = -1, + Lock = 1, + Idle = 2, + Working = 3, + Complete = 4, + } + + XHostelManager.DeviceUpgradeState = { + Unknown = -1, + Normal = 1, + Upgrading = 2, + Complete = 3, + } + + XHostelManager.SceneType = { + Unknown = -1, + Function = 1, --功能放场景 + } + + + -- local TABLE_HOSTELROOM_PATH = "Share/Hostel/HostelRoom.tab" + -- local TABLE_HOSTEL_FUNCDEVICE_PATH = "Share/Hostel/FunctionDevice.tab" + -- local TABLE_HOSTEL_REST_PATH = "Share/Hostel/HostelRest.tab" + -- local TABLE_HOSTEL_ROOM_NODE_PATH = "Client/Hostel/HostelRoomNode.tab" + -- local TABLE_HOSTEL_DEVICE_NODE_PATH = "Client/Hostel/HostelDeviceNode.tab" + -- local TABLE_HOSTEL_HUD_PATH = "Client/Hostel/HostelHud.tab" + local SceneToHostelRoomNodeMap = {} + local SceneToHostelDeviceNodeMap = {} + local HostelRoomTemplate = {} + local HostelRoomFloorList = {} + local FunctionDeviceLvlTemplate = {} + local FunctionDeviceSubType = {} + local HostelRestTemplate = {} + local HostelHudTemplate = {} + local HostelMaxFloor = 0 + local MaxCharacterVitality = 0 -- + + local HostelFloorData = {} + local HostelFuncDeviceData = {} + local PowerStationData = {} + local WorkSlotDate = {} + + local PROTOCAL_REQUEST_NAME = { + RestCharacterRequest = "RestCharacterRequest", + UnrestCharacterRequest = "UnrestCharacterRequest", + UpgradeFunctionDeviceRequest = "UpgradeFunctionDeviceRequest", + ConfirmFunctionDeviceUpgradeRequest = "ConfirmFunctionDeviceUpgradeRequest", + CollectElectricRequest = "CollectElectricRequest", + CollectSlotProductRequest = "CollectSlotProductRequest", + WorkInFunctionDeviceRequest = "WorkInFunctionDeviceRequest", + } + + local table_insert = table.insert + + + function XHostelManager.Init() + SceneToHostelRoomNodeMap = XHostelConfigs.GetSceneToHostelRoomNodeMap() + SceneToHostelDeviceNodeMap = XHostelConfigs.GetSceneToHostelDeviceNodeMap() + HostelRoomTemplate = XHostelConfigs.GetHostelRoomTemplate() + HostelRoomFloorList = XHostelConfigs.GetHostelRoomFloorList() + FunctionDeviceLvlTemplate = XHostelConfigs.GetFunctionDeviceLvlTemplate() + FunctionDeviceSubType = XHostelConfigs.GetFunctionDeviceSubType() + HostelRestTemplate = XHostelConfigs.GetHostelRestTemplate() + HostelHudTemplate = XHostelConfigs.GetHostelHudTemplate() + + HostelMaxFloor = XHostelConfigs.HostelMaxFloor + MaxCharacterVitality = XHostelConfigs.MaxCharacterVitality + end + + ----------------配置处理----------------------- + function XHostelManager.GetHostelRoomTemplate(templateId) + return HostelRoomTemplate[templateId] + end + + function XHostelManager.GetHostelFloorRoomListTemplate(floor) + return HostelRoomFloorList[floor] + end + + function XHostelManager.GetSceneRoomNodeMap(scene) + return SceneToHostelRoomNodeMap[scene] + end + + function XHostelManager.GetSceneDeviceNodeMap(scene, id) + return SceneToHostelDeviceNodeMap[scene][id] + end + + function XHostelManager.GetHostelFunctionDeviceLevelTemplate(type, level) + if not FunctionDeviceLvlTemplate[type] then + return + end + return FunctionDeviceLvlTemplate[type][level] + end + + function XHostelManager.GetFuncDeviceSlotTemplate(slot) + return XHostelManager.GetHostelFunctionDeviceLevelTemplate(slot, 1) + end + + function XHostelManager.GetHostelRestTemplate(floor) + return HostelRestTemplate[floor] + end + + function XHostelManager.GetHostelFloorRestCount(floor) + return HostelRestTemplate[floor].RestCharCount + end + + function XHostelManager.GetHostelMaxFloor() + return HostelMaxFloor + end + + function XHostelManager.GetMaxCharacterVitality() + return MaxCharacterVitality + end + + function XHostelManager.GetFunctionDeviceSubTypeList(type) + return FunctionDeviceSubType[type] + end + + function XHostelManager.GetWorkSlotWorkTime(slot) + local slotCfg = XHostelManager.GetFuncDeviceSlotTemplate(slot) + if not slotCfg then + return 0 + end + if slotCfg.BelongType == XHostelManager.FunctionDeviceType.PowerStation then + return slotCfg.FunctionParam[1] * slotCfg.FunctionParam[3] + elseif slotCfg.BelongType == XHostelManager.FunctionDeviceType.Factory then + return slotCfg.FunctionParam[1] + end + end + + function XHostelManager.GetHudTemplate(hudType, deviceType) + if not HostelHudTemplate[hudType] then + return + end + return HostelHudTemplate[hudType][deviceType] + end + + ----------------模块逻辑----------------------- + function XHostelManager.InitHostelData(hostelData) + if not hostelData then + return + end + XTool.LoopMap(hostelData.FloorData, function(key, value) + HostelFloorData[key] = {} + HostelFloorData[key].RoomList = {} + HostelFloorData[key].RestCharList = {} + XTool.LoopCollection(value.RoomList, function(roomdata) + table_insert(HostelFloorData[key].RoomList, roomdata) + end) + XTool.LoopCollection(value.RestCharList, function(restdata) + table_insert(HostelFloorData[key].RestCharList, restdata) + end) + end) + + XTool.LoopMap(hostelData.FunctionDeviceData, function(key, value) + HostelFuncDeviceData[key] = value + end) + + PowerStationData.CurSaveElectric = hostelData.PowerStationData.CurSaveElectric + XTool.LoopMap(hostelData.WorkSlotDate, function(key, data) + WorkSlotDate[key] = data + end) + end + + function XHostelManager.ResetCharWorkData(XHostelCharWorkData) + XHostelCharWorkData.CharacterId = 0 + XHostelCharWorkData.BeginTime = 0 + XHostelCharWorkData.LastCalcTime = 0 + end + + function XHostelManager.GetFuncDeviceUpgradeTime(type) + if not HostelFuncDeviceData[type] then + return + end + return HostelFuncDeviceData[type].UpgradeBeginTime + end + + function XHostelManager.GetFunctionDeviceLevel(type) + if not HostelFuncDeviceData[type] then + return + end + return HostelFuncDeviceData[type].Level + end + + function XHostelManager.GetFunctionDeviceData(type) + return HostelFuncDeviceData[type] + end + + function XHostelManager.IsFuncDeviceUpgrading(type) + local data = HostelFuncDeviceData[type] + if not data then return false end + return data.UpgradeBeginTime ~= 0 + end + + function XHostelManager.GetFuncDeviceUpgradeState(type) + local deveice = XHostelManager.GetFunctionDeviceData(type) + if not deveice or deveice.UpgradeBeginTime == 0 then + return XHostelManager.DeviceUpgradeState.Normal + end + local nextConfig = XHostelManager.GetHostelFunctionDeviceLevelTemplate(type, deveice.Level + 1) + if not nextConfig then + return XHostelManager.DeviceUpgradeState.Unknown + end + local endUpgradTime = deveice.UpgradeBeginTime + nextConfig.CostTime + local curTime = XTime.GetServerNowTimestamp() + if curTime >= endUpgradTime then + return XHostelManager.DeviceUpgradeState.Complete + else + return XHostelManager.DeviceUpgradeState.Upgrading, endUpgradTime - curTime + end + end + + function XHostelManager.GetFuncDeviceCurLvlTemplate(type) + local level = XHostelManager.GetFunctionDeviceLevel(type) + if not level then return end + return XHostelManager.GetHostelFunctionDeviceLevelTemplate(type, level) + end + + function XHostelManager.IsHostelFloorOpen(floor) + if HostelFloorData[floor] then + return true + end + return false + end + + function XHostelManager.IsFloorBuildRoomFull(floor) + local configList = XHostelManager.GetHostelFloorRoomListTemplate(floor) + local roomList = XHostelManager.GetFloorRoomList(floor) + if not configList or not roomList then + return false + end + return #configList == #roomList + end + + function XHostelManager.GetFloorData(floor) + return HostelFloorData[floor] + end + + function XHostelManager.GetFloorRoomList(floor) + if not HostelFloorData[floor] then + return + end + return HostelFloorData[floor].RoomList + end + + function XHostelManager.GetFloorRestDataList(floor) + if not HostelFloorData[floor] then + return + end + return HostelFloorData[floor].RestCharList + end + + function XHostelManager.GetAllRestCharDataList() + local tCharList = {} + for _, data in pairs(HostelFloorData) do + for _, v in ipairs(data.RestCharList) do + table_insert(tCharList, v) + end + end + return tCharList + end + + function XHostelManager.IsCharacterInRest(charId) + for floor, floorData in pairs(HostelFloorData) do + for _, v in ipairs(floorData.RestCharList) do + if v.CharacterId == charId then + return true, floor + end + end + end + return false + end + + function XHostelManager.IsCharacterInWork(charId) + for _, v in pairs(WorkSlotDate) do + if v.CharacterId == charId then + return true + end + end + return false + end + + function XHostelManager.GetHostelRestData(floor, slot) + local restCharList = XHostelManager.GetFloorRestDataList(floor) + if not restCharList then return end + for _, v in ipairs(restCharList) do + if v.Slot == slot then + return v + end + end + end + + function XHostelManager.SetHostelRestData(floor, XRestCharData) + local floorData = XHostelManager.GetFloorData(floor) + if not floorData then return end + if not floorData.RestCharList then + floorData.RestCharList = {} + end + for i, v in ipairs(floorData.RestCharList) do + if v.Slot == XRestCharData.Slot then + floorData.RestCharList[i] = XRestCharData + return + end + end + table_insert(floorData.RestCharList, XRestCharData) + end + + function XHostelManager.ResetHostelRestData(floor, slot) + local floorData = XHostelManager.GetFloorData(floor) + if not floorData then return end + if not floorData.RestCharList then + floorData.RestCharList = {} + end + for _, v in ipairs(floorData.RestCharList) do + if v.Slot == slot then + XHostelManager.ResetCharWorkData(v) + return + end + end + end + + --------------------工作槽位----------------------- + function XHostelManager.CheckWorkSlotIsEmpty(slot) + local workChar = WorkSlotDate[slot] + if not workChar or workChar.CharacterId == 0 then + return true + end + return false + end + + function XHostelManager.CheckWorkSlotIsIdle(slot) + local workChar = WorkSlotDate[slot] + if workChar and workChar.BeginTime > 0 then + return false + end + return true + end + + function XHostelManager.GetWorkCharBySlot(slot) + return WorkSlotDate[slot] + end + + function XHostelManager.SetWorkSlotData(workChar) + WorkSlotDate[workChar.Slot] = workChar + end + + function XHostelManager.ResetWorkSlotData(slot) + local workChar = WorkSlotDate[slot] + if not workChar then + return + end + XHostelManager.ResetCharWorkData(workChar) + end + + function XHostelManager.GetDevieWorkSlotPruduct(slotType) + local slotCfg = XHostelManager.GetFuncDeviceSlotTemplate(slotType) + if not slotCfg then + return 0, 0 + end + + local deviceCfg = XHostelManager.GetFuncDeviceCurLvlTemplate(slotCfg.BelongType) + if not deviceCfg then + return 0, 0 + end + + local Id, count + if slotCfg.BelongType == XHostelManager.FunctionDeviceType.PowerStation then + Id = XDataCenter.ItemManager.ItemId.HostelElectric + count = (slotCfg.FunctionParam[1]) * (slotCfg.FunctionParam[4] + deviceCfg.FunctionParam[4]) + elseif slotCfg.BelongType == XHostelManager.FunctionDeviceType.Factory then + Id = slotCfg.FunctionParam[3] + count = deviceCfg.FunctionParam[1] + slotCfg.FunctionParam[4] + end + return Id, count + end + + function XHostelManager.GetWorkSlotState(slot) + local slotCfg = XHostelManager.GetFuncDeviceSlotTemplate(slot) + if not slotCfg then + return XHostelManager.WorkSlotState.Unknown + end + if slotCfg.ConditionId ~= 0 and not XConditionManager.CheckCondition(slotCfg.ConditionId) then + return XHostelManager.WorkSlotState.Lock + end + local workChar = WorkSlotDate[slot] + if not workChar or (workChar.CharacterId == 0 and workChar.BeginTime == 0) then + return XHostelManager.WorkSlotState.Idle + end + if workChar.BeginTime > 0 then + local curTime = XTime.GetServerNowTimestamp() + local workTime = workChar.BeginTime + XHostelManager.GetWorkSlotWorkTime(slot) + if workTime <= curTime then + if slotCfg.BelongType == XHostelManager.FunctionDeviceType.PowerStation then + return XHostelManager.WorkSlotState.Idle + else + return XHostelManager.WorkSlotState.Complete + end + else + return XHostelManager.WorkSlotState.Working, workTime - curTime + end + end + return XHostelManager.WorkSlotState.Unknown + end + + function XHostelManager.GetCurDeviceWorkSlot(deviceType) + local slotList = XHostelManager.GetFunctionDeviceSubTypeList(deviceType) + local slotOpenList = {} + for _, ty in ipairs(slotList) do + local slotConfig = XHostelManager.GetFuncDeviceSlotTemplate(ty) + if slotConfig then + if slotConfig.ConditionId == 0 or XConditionManager.CheckCondition(slotConfig.ConditionId) then + table_insert(slotOpenList, ty) + end + end + end + return slotOpenList + end + + function XHostelManager.CalcDeviceSlotLevel(deviceType, deviceLevel) + local slotList = XHostelManager.GetFunctionDeviceSubTypeList(deviceType) + local slotOpenList = {} + for _, ty in ipairs(slotList) do + local slotConfig = XHostelManager.GetFuncDeviceSlotTemplate(ty) + if slotConfig and deviceLevel then + local open = false + local condition = XConditionManager.GetConditionTemplate(slotConfig.ConditionId) + if not condition then + open = true + elseif condition.Type == 20101 and condition.Params[1] == deviceType and deviceLevel >= condition.Params[2] then + open = true + elseif XConditionManager.CheckCondition(slotConfig.ConditionId) then + open = true + end + if open then + table_insert(slotOpenList, ty) + end + end + end + return slotOpenList + end + + ---------------------发电站---------------------- + function XHostelManager.GetPowerStationSaveElectric() + return PowerStationData.CurSaveElectric + end + + --------------------访问他人宿舍-------------- + function XHostelManager.IsInVisitFriendHostel() + return false + end + + -------------------消息通讯-------------------------- + function XHostelManager.ReqRestCharacter(charId, floor, slot, cb) + XNetwork.Call(PROTOCAL_REQUEST_NAME.RestCharacterRequest, { CharacterId = charId, FloorId = floor, Slot = slot }, function(response) + if response.Code ~= XCode.Success then + XUiManager.TipCode(response.Code) + return + end + XHostelManager.SetHostelRestData(floor, response.RestChar) + if response.ChangeFloor and response.ChangeFloor > 0 then + XHostelManager.SetHostelRestData(response.ChangeFloor, response.ChangeData) + end + if cb then + cb() + end + end) + end + + function XHostelManager.ReqUnRestCharacter(floor, slot, cb) + XNetwork.Call(PROTOCAL_REQUEST_NAME.UnrestCharacterRequest, { FloorId = floor, Slot = slot }, function(response) + if response.Code ~= XCode.Success then + XUiManager.TipCode(response.Code) + return + end + XHostelManager.ResetHostelRestData(floor, slot) + if cb then + cb() + end + end) + end + + function XHostelManager.ReqFuncDeviceUpgrade(type, cb) + XNetwork.Call(PROTOCAL_REQUEST_NAME.UpgradeFunctionDeviceRequest, { Type = type }, function(response) + if response.Code ~= XCode.Success then + XUiManager.TipCode(response.Code) + return + end + HostelFuncDeviceData[response.DeviceData.Type] = response.DeviceData + if cb then + cb() + end + end) + end + + function XHostelManager.ComfirmFuncDeviceUpgrade(type, cb) + XNetwork.Call(PROTOCAL_REQUEST_NAME.ConfirmFunctionDeviceUpgradeRequest, { Type = type }, function(response) + if response.Code ~= XCode.Success then + XUiManager.TipCode(response.Code) + return + end + HostelFuncDeviceData[response.DeviceData.Type] = response.DeviceData + if cb then + cb() + end + end) + end + + function XHostelManager.ReqCollectPowerStationElectric(cb) + XNetwork.Call(PROTOCAL_REQUEST_NAME.CollectElectricRequest, nil, function(response) + if response.Code ~= XCode.Success then + XUiManager.TipCode(response.Code) + return + end + PowerStationData.CurSaveElectric = 0 + if cb then + cb() + end + end) + end + + function XHostelManager.ReqWorkInFunctionDevice(charId, slot, cb) + XNetwork.Call(PROTOCAL_REQUEST_NAME.WorkInFunctionDeviceRequest, { CharId = charId, Slot = slot }, function(response) + if response.Code ~= XCode.Success then + XUiManager.TipCode(response.Code) + return + end + local slotConfig = XHostelManager.GetFuncDeviceSlotTemplate(slot) + if not slotConfig then + return + end + XHostelManager.SetWorkSlotData(response.WorkChar) + if cb then + cb() + end + end) + end + + function XHostelManager.ReqCollectSlotProduct(slot, cb) + cb = cb or function() end + XNetwork.Call(PROTOCAL_REQUEST_NAME.CollectSlotProductRequest, { Slot = slot }, function(response) + if response.Code ~= XCode.Success then + XUiManager.TipCode(response.Code) + return + end + + local charId = XHostelManager.GetWorkCharBySlot(slot).CharacterId + XHostelManager.ResetWorkSlotData(slot) + cb(charId, response.Rewards) + end) + end + + function XHostelManager.OnSyncPowerStationSaveElectric(saveElectric) + PowerStationData.CurSaveElectric = saveElectric + end + + function XHostelManager.OnSyncCharacterWorkData(workChar) + WorkSlotDate[workChar.Slot] = workChar + end + + function XHostelManager.OnSyncFunctionDeviceData(XDeviceData) + HostelFuncDeviceData[XDeviceData.Type] = XDeviceData + end + + XHostelManager.Init() + return XHostelManager +end + +XRpc.NotifyPowerStationSaveElectric = function(data) + XDataCenter.HostelManager.OnSyncPowerStationSaveElectric(data.SaveElectric) +end + +XRpc.NotifyCharacterWorkData = function(data) + XDataCenter.HostelManager.OnSyncCharacterWorkData(data.WorkChar) +end + +XRpc.NotifyFunctionDeviceData = function(data) + XDataCenter.HostelManager.OnSyncFunctionDeviceData(data.DeviceData) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XHudManager.lua b/Resources/Scripts/XManager/XHudManager.lua new file mode 100644 index 00000000..b0ef0e95 --- /dev/null +++ b/Resources/Scripts/XManager/XHudManager.lua @@ -0,0 +1,71 @@ +XHudManager = XHudManager or {} + +UiHudType = { + CoolTime = 1, + DeviceState = 2, + WorkSlotState = 3, + RoomUpgrade = 4, +} + +local GetHudFunc = nil +local ReturnHudFunc = nil + +local DisplayHudMap = {} + +function XHudManager.Init() + --local ret = CS.XUiManager.HudManager:Push("UiHud", false, false) + + XLuaUiManager.Open("UiHud") + + -- Test + --CS.XTool.WaitCoroutine(ret, function() + -- local hud = XHudManager.GetHud(UiHudType.CoolTime) + -- hud:SetMetaData() + -- hud:Hide() + --end) +end + +---------------------------------------------HUD Pool start------------------------------------------- +function XHudManager.AddHudFunc(getFunc, returnFunc) + GetHudFunc = getFunc + ReturnHudFunc = returnFunc +end + +function XHudManager.RemoveHudFunc() + GetHudFunc = nil + ReturnHudFunc = nil +end + +function XHudManager.GetHud(hudType) + return GetHudFunc(hudType) +end + +function XHudManager.ReturnHud(hud) + ReturnHudFunc(hud) +end +---------------------------------------------HUD Pool end------------------------------------------- + +---------------------------------------------显示中的HUD start------------------------------------------- +function XHudManager.AddDisplayHud(hudId, hud) + DisplayHudMap[hudId] = hud +end + +function XHudManager.RemoveDisplayHud(hudId) + DisplayHudMap[hudId] = nil +end + +function XHudManager.ClearDisplayHud() + for _, hud in pairs(DisplayHudMap) do + hud:Hide() + end + DisplayHudMap = {} +end + +function XHudManager.GetDisplayHudMap() + return DisplayHudMap +end + +function XHudManager.GetDisplayHudByInstId(hudId) + return DisplayHudMap[hudId] +end +---------------------------------------------显示中的HUD end------------------------------------------- \ No newline at end of file diff --git a/Resources/Scripts/XManager/XInvertCardGameManager.lua b/Resources/Scripts/XManager/XInvertCardGameManager.lua new file mode 100644 index 00000000..531471d3 --- /dev/null +++ b/Resources/Scripts/XManager/XInvertCardGameManager.lua @@ -0,0 +1,359 @@ +local tableInsert = table.insert +local tableSort = table.sort +local XInvertCardStageEntity = require("XEntity/XInvertCardGame/XInvertCardStage") +XInvertCardGameManagerCreator = function() + local XInvertCardGameManager = {} + local ActId = 0 + local CurStageId = 0 + local StageEntityList = {} + + local INVERT_CARD_PROTO = { + InvertCardRequest = "InvertCardRequest", -- 翻牌请求 + InvertCardsRewardRequest = "InvertCardsRewardRequest", -- 领取关卡奖励请求 + } + + function XInvertCardGameManager.HandleInvertGameData(data) + ActId = data.ActivityId + CurStageId = data.CurActivityStageId + local stageInfoList = data.ActivityStageInfoList + -- 遍历数据 + if stageInfoList and next(stageInfoList) then + for _, stageData in ipairs(stageInfoList) do + if stageData.ActivityStageId then + local tmp = XInvertCardGameConfig.GetInvertCardStageTemplateById(stageData.ActivityStageId) + local stageEntity = XInvertCardStageEntity.New(tmp, stageData) + tableInsert(StageEntityList, stageEntity) + end + end + end + end + + function XInvertCardGameManager.Init() + + end + + function XInvertCardGameManager.GetStageEntityById(stageId) + for _, stageData in ipairs(StageEntityList) do + local id = stageData:GetId() + if id == stageId then + return stageData + end + end + + return nil + end + + function XInvertCardGameManager.InvertCardRequest(stageId, cardIdx) + if not ActId or ActId == 0 then + XLog.Error("Invert Card Game ActivityId Can't Be nil or 0") + return + end + + local cardState = XInvertCardGameManager.CheckCardState(stageId, cardIdx) + if cardState == XInvertCardGameConfig.InvertCardGameCardState.Back then + local stageData = XInvertCardGameManager.GetStageEntityById(stageId) + if not XInvertCardGameManager.CheckHasEnoughItem(stageData) then + XUiManager.TipText("InvertCardGameHaveNotEnoughItem") + return + end + XNetwork.Call(INVERT_CARD_PROTO.InvertCardRequest, {ActivityId = ActId, ActivityStageId = stageId, CardIdx = cardIdx}, function (res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + if stageData then + XInvertCardGameManager.InvertCard(stageData, stageId, cardIdx) + XInvertCardGameManager.ClearCardData(stageData, stageId, res.FinCardsIdxList) + XInvertCardGameManager.PunishCard(stageData, stageId, res.PunishCardsIdxList) + stageData:SetProgress(res.Progress) + stageData:AddTotalCounts() + stageData:SetStatus(res.ActivityStageStatus) + if res.ActivityStageStatus == XInvertCardGameConfig.InvertCardGameStageStatusType.Finish then + XInvertCardGameManager.CheckNextStageOpen() + end + + XEventManager.DispatchEvent(XEventId.EVENT_INVERT_CARD_GAME_CARD_CHANGED) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_INVERT_CARD_GAME_CARD_CHANGED, stageData, cardIdx, res.PunishCardsIdxList, res.FinCardsIdxList) + end + end) + end + end + + function XInvertCardGameManager.InvertCard(stageData, stageId, cardIdx) + if not stageData then + stageData = XInvertCardGameManager.GetStageEntityById(stageId) + end + if stageData then + stageData:SetCardInvert(cardIdx) + end + end + + function XInvertCardGameManager.ClearCardData(stageData, stageId, finishCardIdxs) + if not stageData then + stageData = XInvertCardGameManager.GetStageEntityById(stageId) + end + if stageData then + for _, finishIdx in ipairs(finishCardIdxs) do + stageData:SetCardFinish(finishIdx) + end + end + end + + function XInvertCardGameManager.PunishCard(stageData, stageId, punishCardIdxs) + if not stageData then + stageData = XInvertCardGameManager.GetStageEntityById(stageId) + end + if stageData then + for _, punishIdx in ipairs(punishCardIdxs) do + stageData:SetCardPunish(punishIdx) + end + end + end + + function XInvertCardGameManager.InvertCardsRewardRequest(stageId) + if not ActId or ActId == 0 then + XLog.Error("Invert Card Game ActivityId Can't Be nil or 0") + return + end + + XNetwork.Call(INVERT_CARD_PROTO.InvertCardsRewardRequest, {ActivityId = ActId, ActivityStageId = stageId}, function (res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local stageData = XInvertCardGameManager.GetStageEntityById(stageId) + if stageData then + stageData:SetRewardListIdx(res.RewardListIdx) + if res.RewardGoodsList and next(res.RewardGoodsList) then + XUiManager.OpenUiObtain(res.RewardGoodsList, CS.XTextManager.GetText("Award")) + end + end + + XEventManager.DispatchEvent(XEventId.EVENT_INVERT_CARD_GAME_GET_REWARD) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_INVERT_CARD_GAME_GET_REWARD, stageData) + end) + end + + function XInvertCardGameManager.CheckNextStageOpen() + local curOpenStageId = 0 + for index, stageData in ipairs(StageEntityList) do + if stageData:GetStatus() == XInvertCardGameConfig.InvertCardGameStageStatusType.Lock then + if StageEntityList[index-1] and StageEntityList[index-1]:GetStatus() == XInvertCardGameConfig.InvertCardGameStageStatusType.Finish then + stageData:SetStatus(XInvertCardGameConfig.InvertCardGameStageStatusType.Process) + CurStageId = stageData:GetId() + end + end + end + end + + function XInvertCardGameManager.GetHelpId() + if ActId and ActId ~= 0 then + return XInvertCardGameConfig.GetHelpId(ActId) + end + end + + function XInvertCardGameManager.GetConsumeItemId() + if ActId and ActId ~= 0 then + return XInvertCardGameConfig.GetConsumeItemId(ActId) + end + end + + function XInvertCardGameManager.CheckHasServerData() + if StageEntityList and next(StageEntityList) then + return true + end + + return false + end + + function XInvertCardGameManager.GetStorySkipId() + if ActId and ActId ~= 0 then + return XInvertCardGameConfig.GetStorySkipId(ActId) + end + end + + function XInvertCardGameManager.GetActivityTimeId() + if ActId and ActId ~= 0 then + return XInvertCardGameConfig.GetActivityTimeId(ActId) + end + end + + function XInvertCardGameManager.GetStageEntityList() + return StageEntityList + end + + function XInvertCardGameManager.CheckStageIsOpen(index) + if StageEntityList and StageEntityList[index] then + return StageEntityList[index]:GetStatus() ~= XInvertCardGameConfig.InvertCardGameStageStatusType.Lock + end + end + + function XInvertCardGameManager.FindDefaultSelectTabIndex() + if CurStageId then + for index, stageEntity in ipairs(StageEntityList) do + if stageEntity:GetId() == CurStageId then + return index + end + end + end + + return 1 + end + + function XInvertCardGameManager.GetCurStageEntity() + if CurStageId then + for index, stageEntity in ipairs(StageEntityList) do + if stageEntity:GetId() == CurStageId then + return stageEntity + end + end + end + end + + -- 根据关卡Id,奖励Id检查奖励状态 + function XInvertCardGameManager.CheckRewardState(stageId, rewardIdx) + if not stageId or not rewardIdx or stageId == 0 or rewardIdx == 0 then + return XInvertCardGameConfig.InvertCardGameRewardTookState.NotFinish + end + local stageEntity = XInvertCardGameManager.GetStageEntityById(stageId) + if stageEntity:GetRewardListIdx()[rewardIdx] == true then + return XInvertCardGameConfig.InvertCardGameRewardTookState.Took + else + local finishProgress = stageEntity:GetProgress() + local targetProgress = stageEntity:GetFinishProgress()[rewardIdx] + if finishProgress and targetProgress then + if finishProgress < targetProgress then + return XInvertCardGameConfig.InvertCardGameRewardTookState.NotFinish + else + return XInvertCardGameConfig.InvertCardGameRewardTookState.NotTook + end + else + return XInvertCardGameConfig.InvertCardGameRewardTookState.NotFinish + end + end + end + + -- 根据关卡Id,卡牌Id检查卡牌状态 + function XInvertCardGameManager.CheckCardState(stageId, cardIdx) + if not stageId or not cardIdx or stageId == 0 or cardIdx == 0 then + return XInvertCardGameConfig.InvertCardGameCardState.Finish + end + local stageEntity = XInvertCardGameManager.GetStageEntityById(stageId) + if stageEntity:GetStatus() == XInvertCardGameConfig.InvertCardGameStageStatusType.Finish then + return XInvertCardGameConfig.InvertCardGameCardState.Front + end + local cardList = stageEntity:GetRandomCardList() + if cardList[cardIdx] then + if cardList[cardIdx].IsFinish then + return XInvertCardGameConfig.InvertCardGameCardState.Finish + else + local invertList = stageEntity:GetInvertList() + for _, invertCardIdx in ipairs(invertList) do + if cardIdx == invertCardIdx then + return XInvertCardGameConfig.InvertCardGameCardState.Front + end + end + + return XInvertCardGameConfig.InvertCardGameCardState.Back + end + else + return XInvertCardGameConfig.InvertCardGameCardState.Finish + end + end + + function XInvertCardGameManager.GetStartStage(stageEntity) + if not stageEntity then + return XInvertCardGameConfig.InvertCardGameStartStage.Started + end + local stageId = stageEntity:GetId() + local startStateData = XSaveTool.GetData(string.format( "%s%s%s%s", XInvertCardGameConfig.INVERT_CARD_GAME_START_STATE_KEY, XPlayer.Id, XDataCenter.InvertCardGameManager.ActId, stageId)) + if not startStateData or startStateData == XInvertCardGameConfig.InvertCardGameStartStage.NotStart then + return XInvertCardGameConfig.InvertCardGameStartStage.NotStart + else + return XInvertCardGameConfig.InvertCardGameStartStage.Started + end + end + + function XInvertCardGameManager.SetStartStage(stageEntity) + if not stageEntity then + return + end + local stageId = stageEntity:GetId() + XSaveTool.SaveData(string.format( "%s%s%s%s", XInvertCardGameConfig.INVERT_CARD_GAME_START_STATE_KEY, XPlayer.Id, XDataCenter.InvertCardGameManager.ActId, stageId), XInvertCardGameConfig.InvertCardGameStartStage.Started) + end + + function XInvertCardGameManager.CheckTogRedPoint(index) + if StageEntityList[index] then + if StageEntityList[index]:GetStatus() == XInvertCardGameConfig.InvertCardGameStageStatusType.Process then + if StageEntityList[index]:GetTotalCounts() >= StageEntityList[index]:GetMaxCostNum() then -- 超过最大翻牌次数不消耗代币 + return true + end + if XInvertCardGameManager.CheckHasEnoughItem(StageEntityList[index]) then + return true + end + end + + local rewardList = StageEntityList[index]:GetRewards() + local stageId = StageEntityList[index]:GetId() + for index, _ in ipairs(rewardList) do + if XInvertCardGameManager.CheckRewardState(stageId, index) == XInvertCardGameConfig.InvertCardGameRewardTookState.NotTook then + return true + end + end + end + + return false + end + + function XInvertCardGameManager.CheckHasEnoughItem(stageEntity) + local consumeItemId = XInvertCardGameManager.GetConsumeItemId() + if not consumeItemId then + return false + end + + local consumeCount = stageEntity:GetCostCoinNum() + if not consumeCount then + return false + end + + if stageEntity:GetTotalCounts() >= stageEntity:GetMaxCostNum() then -- 超过最大翻牌次数不消耗代币 + return true + end + + return XDataCenter.ItemManager.CheckItemCountById(consumeItemId, consumeCount) + end + + function XInvertCardGameManager.CheckAllGameRedPoint() + if StageEntityList and next(StageEntityList) then + for index, _ in ipairs(StageEntityList) do + if XInvertCardGameManager.CheckTogRedPoint(index) then + return true + end + end + end + + return false + end + + function XInvertCardGameManager.CheckActivityStageFinished(activityId, stageId) + if not ActId or ActId == 0 or ActId ~= activityId then + return false + end + + local stageEntity = XInvertCardGameManager.GetStageEntityById(stageId) + if not stageEntity then + return false + end + + return stageEntity:GetStatus() == XInvertCardGameConfig.InvertCardGameStageStatusType.Finish + end + + XInvertCardGameManager.Init() + return XInvertCardGameManager +end + +XRpc.NotifyInvertCardGameData = function (data) + XDataCenter.InvertCardGameManager.HandleInvertGameData(data) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XItemManager.lua b/Resources/Scripts/XManager/XItemManager.lua new file mode 100644 index 00000000..064103e5 --- /dev/null +++ b/Resources/Scripts/XManager/XItemManager.lua @@ -0,0 +1,1564 @@ +XItemManagerCreator = function() + + local XItemManager = {} + + local tableInsert = table.insert + local tableRemove = table.remove + local tableSort = table.sort + local mathCeil = math.ceil + local mathMin = math.min + + local Items = {} -- 所有道具数据 + local RecItemIds = {} -- 恢复类道具 + local SuppliesItems = {} -- 补给类道具 + local BuyAssetTemplates = {} -- 购买资源配置表 + local BuyAssetDailyLimit = {} -- 购买资源每日限制 + local ItemTemplates = {} + local ItemFirstGetCheckTable = {} + local RedEnvelopeInfos = {} -- 红包道具使用记录 + + local BuyAssetCoinBase = 0 + local BuyAssetCoinMul = 0 + -- local BuyAssetCoinCritProb = 0 + -- local BuyAssetCoinCritMul = 0 + -- item 参数下表 + -- local PARAM_ACTIONPOINT_INTERVAL = 1 + -- local PARAM_ACTIONPOINT_NUM = 2 + local RecTimer + + XItemManager.ItemId = { + Coin = 1, + PaidGem = 2, + FreeGem = 3, + ActionPoint = 4, + HongKa = 5, + TeamExp = 7, + AndroidHongKa = 8, + IosHongKa = 10, + SkillPoint = 12, + DailyActiveness = 13, + WeeklyActiveness = 14, + HostelElectric = 15, + HostelMat = 16, + OnlineBossTicket = 17, + BountyTaskExp = 18, + DormCoin = 30, + FurnitureCoin = 31, + DormEnterIcon = 36, + BaseEquipCoin = 300, + InfestorActionPoint = 50, + InfestorMoney = 51, + PokemonLevelUpItem = 56, + PokemonStarUpItem = 57, + PokemonLowStarUpItem = 58, + PassportExp = 60, + TRPGTalen = 61000, + TRPGMoney = 61001, + TRPGEXP = 61002, + TRPGEndurance = 61003, + UniversalWord = 62309, + EquipRecycleItemId = CS.XGame.Config:GetInt("EquipRecycleItemId"), + MoeWarRespondItemId = 62501, --萌战应援票 + MoeWarPreparationItemId = 62505, --萌战筹备度 + MoeWarCommunicateItemId = 62506, --萌战通讯次数 + PokerGuessingItemId = 62711, --翻牌比大小活动物品 + SuperTowerBagItemId = 62801, --超级爬塔背包扩容道具Id + } + + --时效性道具初始时间计算方式 + XItemManager.TimelinessType = { + Invalid = 0, + FromConfig = 1, --通过配置 + AfterGet = 2, --获取后 + Batch = 3, --按时间分批次 + } + + --礼包类型 + XItemManager.GiftItemUseType = { + Reward = 1, + Drop = 2, + OptionalReward = 3, + RedEnvelope = 4, + } + + --特殊补给道具 + XItemManager.SuppliesItemType = { + Battery = 90000, + CoinPackage = 91000 + } + + XItemManager.SubType_1 = { + Reward = 1, + } + + XItemManager.SUBTYPE_EXP = 2 + + XItemManager.PageRecordCache = XItemConfigs.PageType.Equip -- 仓库默认选择标签 + + local METHOD_NAME = { + Sell = "ItemSellRequest", + Use = "ItemUseRequest", + BuyAsset = "ItemBuyAssetRequest", + MultiplyUse = "ItemUseMultipleRequest", + } + + local BAG_ITEM_SORT_FUNC = function(a, b) + local aItemId = a.Data.Id + local bItemId = b.Data.Id + + --优先级排序 + local aPriority = XItemManager.GetItemPriority(aItemId) + local bPriority = XItemManager.GetItemPriority(bItemId) + if aPriority ~= bPriority then + return aPriority > bPriority + end + + --溢出排序 + local aIsCanConvert = XItemManager.IsCanConvert(aItemId) + local bIsCanConvert = XItemManager.IsCanConvert(bItemId) + if aIsCanConvert ~= bIsCanConvert then + return aIsCanConvert + end + + --可使用排序 + local aIsUseable = XItemManager.IsUseable(aItemId) + local bIsUseable = XItemManager.IsUseable(bItemId) + if aIsUseable ~= bIsUseable then + return aIsUseable + end + + --时效性排序 + local aIsTimeLimit = XItemManager.IsTimeLimit(aItemId) + local bIsTimeLimit = XItemManager.IsTimeLimit(bItemId) + if aIsTimeLimit ~= bIsTimeLimit then + return aIsTimeLimit + elseif aIsTimeLimit then + --剩余时间排序 + local nowTime = XTime.GetServerNowTimestamp() + local aleftTime = a.RecycleBatch and a.RecycleBatch.RecycleTime - nowTime or XDataCenter.ItemManager.GetRecycleLeftTime(aItemId) + local bleftTime = b.RecycleBatch and b.RecycleBatch.RecycleTime - nowTime or XDataCenter.ItemManager.GetRecycleLeftTime(bItemId) + if aleftTime ~= bleftTime then + return aleftTime < bleftTime + end + end + + --品质排序 + local aQuality = XItemManager.GetItemQuality(aItemId) + local bQuality = XItemManager.GetItemQuality(bItemId) + if aQuality ~= bQuality then + return aQuality > bQuality + end + + --Id排序 + if aItemId ~= bItemId then + return aItemId < bItemId + end + + --数量排序 + if a.Count ~= b.Count then + return a.Count > b.Count + end + + return false + end + + local CONSUMABLES_ITEM_SORT_FUNC = function(a, b) + local aItemId = a.Data.Id + local bItemId = b.Data.Id + + --溢出排序 + local aIsCanConvert = XItemManager.IsCanConvert(aItemId) + local bIsCanConvert = XItemManager.IsCanConvert(bItemId) + if aIsCanConvert ~= bIsCanConvert then + return aIsCanConvert + end + + --可使用排序 + local aIsUseable = XItemManager.IsUseable(aItemId) + local bIsUseable = XItemManager.IsUseable(bItemId) + if aIsUseable ~= bIsUseable then + return aIsUseable + end + + --时效性排序 + local aIsTimeLimit = XItemManager.IsTimeLimit(aItemId) + local bIsTimeLimit = XItemManager.IsTimeLimit(bItemId) + if aIsTimeLimit ~= bIsTimeLimit then + return aIsTimeLimit + elseif aIsTimeLimit then + --剩余时间排序 + local nowTime = XTime.GetServerNowTimestamp() + local aleftTime = a.RecycleBatch and a.RecycleBatch.RecycleTime - nowTime or XDataCenter.ItemManager.GetRecycleLeftTime(aItemId) + local bleftTime = b.RecycleBatch and b.RecycleBatch.RecycleTime - nowTime or XDataCenter.ItemManager.GetRecycleLeftTime(bItemId) + if aleftTime ~= bleftTime then + return aleftTime < bleftTime + end + end + + --优先级排序 + local aPriority = XItemManager.GetItemPriority(aItemId) + local bPriority = XItemManager.GetItemPriority(bItemId) + if aPriority ~= bPriority then + return aPriority > bPriority + end + + --品质排序 + local aQuality = XItemManager.GetItemQuality(aItemId) + local bQuality = XItemManager.GetItemQuality(bItemId) + if aQuality ~= bQuality then + return aQuality > bQuality + end + + --Id排序 + if aItemId ~= bItemId then + return aItemId < bItemId + end + + --数量排序 + if a.Count ~= b.Count then + return a.Count > b.Count + end + + return false + end + + local EXP_ITEM_SORT_CMP = function(a, b) + if a.Template.Id ~= b.Template.Id then + if a.Template.Id == XDataCenter.ItemManager.ItemId.EquipRecycleItemId then + return true + end + if b.Template.Id == XDataCenter.ItemManager.ItemId.EquipRecycleItemId then + return false + end + end + + if a.Template.Quality ~= b.Template.Quality then + return a.Template.Quality < b.Template.Quality + end + + if a.Template.GetExp() ~= b.Template.GetExp() then + return a.Template.GetExp() < b.Template.GetExp() + end + + if a.Template.Priority ~= b.Template.Priority then + return a.Template.Priority > b.Template.Priority + end + + if a.Count ~= b.Count then + return a.Count > b.Count + end + + return false + end + + function XItemManager.Init() + ItemTemplates = XItemConfigs.GetItemTemplates() + BuyAssetDailyLimit = XItemConfigs.GetBuyAssetDailyLimit() + BuyAssetTemplates = XItemConfigs.GetBuyAssetTemplates() + BuyAssetCoinBase = CS.XGame.Config:GetInt("BuyAssetCoinBase") + BuyAssetCoinMul = CS.XGame.Config:GetInt("BuyAssetCoinMul") + -- BuyAssetCoinCritProb = CS.XGame.Config:GetInt("BuyAssetCoinCritProb") + -- BuyAssetCoinCritMul = CS.XGame.Config:GetInt("BuyAssetCoinCritMul") + + XItemManager.PageRecordCache = XItemConfigs.PageType.Equip + + XEventManager.AddEventListener(XEventId.EVENT_USER_LOGOUT, function() + if RecTimer then + XScheduleManager.UnSchedule(RecTimer) + end + end) + + XItemManager.InitAllItems() + end + + function XItemManager.InitAllItems() + Items = {} + for id, template in pairs(ItemTemplates) do + local item + if template.RecType == XResetManager.ResetType.NoNeed then + item = XItem.New(nil, template) + else + item = XRecItem.New(nil, template) + tableInsert(RecItemIds, id) + end + -- 存储补给包相关数据(电池、螺母包) + if template.SubTypeParams[1] == XItemManager.SubType_1.Reward then + local subType3 = template.SubTypeParams[3] + if subType3 == XItemManager.SuppliesItemType.Battery then + SuppliesItems[XItemManager.SuppliesItemType.Battery] = SuppliesItems[XItemManager.SuppliesItemType.Battery] or {} + tableInsert(SuppliesItems[XItemManager.SuppliesItemType.Battery], item.Id) + elseif subType3 == XItemManager.SuppliesItemType.CoinPackage then + SuppliesItems[XItemManager.SuppliesItemType.CoinPackage] = SuppliesItems[XItemManager.SuppliesItemType.CoinPackage] or {} + tableInsert(SuppliesItems[XItemManager.SuppliesItemType.CoinPackage], item.Id) + end + end + Items[item.Id] = item + end + end + + function XItemManager.AddItemListener() + RecTimer = XScheduleManager.ScheduleForever(function() + for _, id in pairs(RecItemIds) do + Items[id]:CheckCount() + end + end, XScheduleManager.SECOND, 0) + end + + function XItemManager.InitItemData(items) + for _, itemData in pairs(items) do + if Items[itemData.Id] then + Items[itemData.Id]:RefreshItem(itemData) + ItemFirstGetCheckTable[itemData.Id] = true + else + XLog.ErrorTableDataNotFound("XItemManager.InitItemData", "Item", " Share/Item/Item.tab", "Id", tostring(itemData.Id)) + end + end + + XItemManager.AddItemListener() + end + + function XItemManager.InitItemRecycle(list) + -- 回收道具时限表 + if not list then return end + for id, itemRecycleList in pairs(list) do + Items[id].ItemRecycleList = itemRecycleList + end + end + + function XItemManager.InitBatchItemRecycle(data) + if not data or not next(data) then return end + XItemManager.NotifyBatchItemRecycle(data) + end + + -- 获取数据 + function XItemManager.GetItemTemplate(id) + local tab = ItemTemplates[id] + if tab == nil then + XLog.ErrorTableDataNotFound("XItemManager.GetItemTemplate", "ItemTemplate", " Share/Item/Item.tab", "id", tostring(id)) + end + return tab + end + + function XItemManager.GetItemQuality(id) + local tab = ItemTemplates[id] + if tab == nil then + XLog.ErrorTableDataNotFound("XItemManager.GetItemQuality", "ItemTemplate", " Share/Item/Item.tab", "id", tostring(id)) + return + end + return tab.Quality + end + + function XItemManager.GetItemType(id) + local tab = ItemTemplates[id] + if tab == nil then + XLog.ErrorTableDataNotFound("XItemManager.GetItemType", "ItemTemplate", " Share/Item/Item.tab", "id", tostring(id)) + return + end + return tab.ItemType + end + + function XItemManager.GetItemPriority(id) + local tab = ItemTemplates[id] + if tab == nil then + XLog.ErrorTableDataNotFound("XItemManager.GetItemPriority", "ItemTemplate", " Share/Item/Item.tab", "id", tostring(id)) + return + end + return tab.Priority + end + + function XItemManager.GetItemBigIcon(id) + local tab = XItemManager.GetItemTemplate(id) + if tab == nil then + XLog.ErrorTableDataNotFound("XItemManager.GetItemBigIcon", "ItemTemplate", " Share/Item/Item.tab", "id", tostring(id)) + return + end + + return tab.BigIcon + end + + function XItemManager.GetItemIcon(id) + local tab = XItemManager.GetItemTemplate(id) + if tab == nil then + XLog.ErrorTableDataNotFound("XItemManager.GetItemIcon", "ItemTemplate", " Share/Item/Item.tab", "id", tostring(id)) + return nil + end + + return tab.Icon + end + + function XItemManager.GetItemDescription(id) + local tab = XItemManager.GetItemTemplate(id) + if tab == nil then + XLog.ErrorTableDataNotFound("XItemManager.GetItemDescription", "ItemTemplate", " Share/Item/Item.tab", "id", tostring(id)) + return + end + + return tab.Description + end + + function XItemManager.GetItemWorldDesc(id) + local tab = XItemManager.GetItemTemplate(id) + if tab == nil then + XLog.ErrorTableDataNotFound("XItemManager.GetItemWorldDesc", "ItemTemplate", " Share/Item/Item.tab", "id", tostring(id)) + return + end + + return tab.WorldDesc + end + + function XItemManager.GetItemSkipIdParams(id) + local tab = XItemManager.GetItemTemplate(id) + if tab == nil then + XLog.ErrorTableDataNotFound("XItemManager.GetItemSkipIdParams", "ItemTemplate", " Share/Item/Item.tab", "id", tostring(id)) + return + end + + return tab.SkipIdParams + end + + function XItemManager.GetBuyAssetTemplate(targetId, times, notTipError) + local template = BuyAssetTemplates[targetId] + + if template == nil then + if not notTipError then + XLog.ErrorTableDataNotFound("XItemManager.GetBuyAssetTemplate", "template", "Share/Item/BuyAsset.tab", "targetId", tostring(targetId)) + end + return + end + + local config = template[1] + for i = 1, #template do + if template[i].Times > times then + return config + end + config = template[i] + end + + return config + end + + function XItemManager.GetAllBuyAssetTemplate() + return BuyAssetTemplates + end + + function XItemManager.GetBuyAssetTemplateById(id) + if not BuyAssetTemplates then + return nil + end + + return BuyAssetTemplates[id] + end + + function XItemManager.GetRedEnvelopeCertainNpcItemCount(activityId, npcId, itemId) + local count = 0 + + local redEnvelope = RedEnvelopeInfos[activityId] + if not redEnvelope then + return count + end + + local reward = redEnvelope[npcId] + count = reward and reward[itemId] or count + + return count + end + + function XItemManager.GetItem(id) + if (id == XItemManager.ItemId.FreeGem or id == XItemManager.ItemId.PaidGem) then + local freeGem = Items[XItemManager.ItemId.FreeGem] + local paidGem = Items[XItemManager.ItemId.PaidGem] + + local mergeGem = XItem.New(nil, freeGem.Template) + mergeGem.Count = mergeGem.Count + freeGem.Count + paidGem.Count + + return mergeGem + else + return Items[id] + end + end + + function XItemManager.GetCount(id) + if (id == XItemManager.ItemId.FreeGem or id == XItemManager.ItemId.PaidGem) then + return Items[XItemManager.ItemId.FreeGem]:GetCount() + + Items[XItemManager.ItemId.PaidGem]:GetCount() + elseif id == XGuildConfig.GuildContributeCoin then + return XDataCenter.GuildManager.GetGuildContributeLeft() or 0 + elseif id == XItemManager.ItemId.TRPGEXP then + return XDataCenter.TRPGManager.GetExploreCurExp() + end + return Items[id] and Items[id]:GetCount() or 0 + end + + function XItemManager.GetFreeGemCount() + return Items[XItemManager.ItemId.FreeGem]:GetCount() + end + + function XItemManager.GetPaidGemCount() + return Items[XItemManager.ItemId.PaidGem]:GetCount() + end + + function XItemManager.GetMaxCount(id) + return Items[id] and Items[id]:GetMaxCount() or 0 + end + + function XItemManager.GetItemsByType(itemType) + local list = {} + + for _, item in pairs(Items) do + if item.Template.ItemType == itemType and item:GetCount() > 0 then + tableInsert(list, item) + end + end + + return list + end + + function XItemManager.GetItemsByTypeAndSuitId(itemType, suitId) + local list = {} + + for _, item in pairs(Items) do + local isSuit = suitId == nil + local cfg = XItemManager.GetItemTemplate(item.Id) + if not isSuit then + isSuit = suitId == XItemConfigs.SuitAllType.All or suitId == XItemConfigs.SuitAllType.DefaultAll or suitId == cfg.SuitId + end + + if cfg.ItemType == itemType and item:GetCount() > 0 and isSuit then + tableInsert(list, item) + end + end + + return list + end + + function XItemManager.GetCardExpItems() + local list = XItemManager.GetItemsByType(XItemConfigs.ItemType.CardExp) + tableSort(list, function(a, b) + return a.Template.Exp < b.Template.Exp + end) + return list + end + + function XItemManager.GetEquipExpItems(equipClassify) + local result = {} + + for _, item in pairs(Items) do + if (item.Template.ItemType == XItemConfigs.ItemType.EquipExp + or item.Template.ItemType == XItemConfigs.ItemType.EquipExpNotInBag) + and item.Template.Classify == equipClassify + and item:GetCount() > 0 + then + tableInsert(result, item) + end + end + tableSort(result, EXP_ITEM_SORT_CMP) + + return result + end + + function XItemManager.GetPartnerExpItems() + local list = XItemManager.GetItemsByType(XItemConfigs.ItemType.PartnerExp) + tableSort(list, function(a, b) + return a.Template.Exp < b.Template.Exp + end) + return list + end + + function XItemManager.GetCharExp(id, subType) + local template = XItemManager.GetItemTemplate(id) + return template.GetExp(subType) + end + + function XItemManager.GetItemsAddEquipExp(id, count) + count = count or 1 + local template = XItemManager.GetItemTemplate(id) + return template.GetExp() * count + end + + function XItemManager.GetItemsAddEquipCost(id, count) + count = count or 1 + local template = XItemManager.GetItemTemplate(id) + return template.GetCost() * count + end + + function XItemManager.GetTeamExp(id) + local PARAM_EXP = 1 + local template = XItemManager.GetItemTemplate(id) + return template.SubTypeParams[PARAM_EXP] + end + + function XItemManager.GetBuyAssetInfo(targetId) + if not targetId then + return + XLog.Error("XItemManager.GetBuyAssetInfo函数参数错误, 参数targetId不能为空") + end + + -- 获取购买次数 + local times = 0 + if Items[targetId] then + times = Items[targetId].BuyTimes or 0 + end + + -- 检查是否达到每日上限,读表 + local dayLimit = BuyAssetDailyLimit[targetId] + local template + if dayLimit and dayLimit > 0 and times >= dayLimit then + template = XItemManager.GetBuyAssetTemplate(targetId, dayLimit) + else + template = XItemManager.GetBuyAssetTemplate(targetId, times + 1) + end + + + local targetCount = template.GainCount + + -- 计算消耗量 + if targetId == XItemManager.ItemId.Coin then + targetCount = (BuyAssetCoinBase + XPlayer.Level * BuyAssetCoinMul) * targetCount + end + + -- 返回 + return { + LeftTimes = dayLimit > 0 and dayLimit - times or nil, + TargetId = targetId, + TargetCount = targetCount, + ConsumeId = template.ConsumeId, + ConsumeCount = template.ConsumeCount, + } + end + + function XItemManager.GetItemsByTypes(types, useConsumableSort) + local result = {} + for i = 1, #types do + local items = XItemManager.GetItemsByType(types[i]) + for i2 = 1, #items do + tableInsert(result, items[i2]) + end + end + + local bagItems = XDataCenter.ItemManager.ConvertToGridData(result) + local sortFunc = useConsumableSort and CONSUMABLES_ITEM_SORT_FUNC or BAG_ITEM_SORT_FUNC + tableSort(bagItems, sortFunc) + return bagItems + end + + function XItemManager.GetCanSellItemsByTypes(types, useConsumableSort) + local result = {} + for i = 1, #types do + local items = XItemManager.GetItemsByType(types[i]) + for i2 = 1, #items do + if XItemManager.IsCanSell(items[i2].Id) then + tableInsert(result, items[i2]) + end + end + end + + local bagItems = XDataCenter.ItemManager.ConvertToGridData(result) + local sortFunc = useConsumableSort and CONSUMABLES_ITEM_SORT_FUNC or BAG_ITEM_SORT_FUNC + tableSort(bagItems, sortFunc) + return bagItems + end + + function XItemManager.GetCanConvertItemsByTypes(types) + local result = {} + for i = 1, #types do + local items = XItemManager.GetItemsByType(types[i]) + for i2 = 1, #items do + if XItemManager.IsCanConvert(items[i2].Id) then + tableInsert(result, items[i2]) + end + end + end + + local bagItems = XDataCenter.ItemManager.ConvertToGridData(result) + tableSort(bagItems, BAG_ITEM_SORT_FUNC) + return bagItems + end + + --获得出售道具获得的奖励信息 + function XItemManager.GetSellReward(id, count) + local reward = {} + + if not id then return reward end + count = count or 1 + + local tab = XItemManager.GetItemTemplate(id) + local templateId = tab.SellForId + if templateId > 0 then + reward.TemplateId = templateId + reward.Count = tab.SellForCount * count + end + + return reward + end + + function XItemManager.GetSelectGiftRewardId(id) + local template = XItemManager.GetItemTemplate(id) + return template.RewardId + end + + function XItemManager.GetItemName(id) + local template = XItemManager.GetItemTemplate(id) + if not template then + return nil + end + return template.Name + end + + -- 战斗复活ui调用 + function XItemManager.GetCostItemText(id) + return CS.XTextManager.GetText("RebootCostText", XItemManager.GetItemName(id)) --"消耗{0}" + end + + -- 战斗复活ui调用 + function XItemManager.CanRebootBuyItem(id) + return (id ~= XItemManager.ItemId.Coin and id ~= XItemManager.ItemId.FreeGem and id ~= XItemManager.ItemId.PaidGem) + end + + function XItemManager.GetItemSuit(id) + local template = XItemManager.GetItemTemplate(id) + if not template then + return nil + end + return template.Suit + end + + function XItemManager.GetDailyActiveness() + return XItemManager.GetItem(XItemManager.ItemId.DailyActiveness) + end + + function XItemManager.GetWeeklyActiveness() + return XItemManager.GetItem(XItemManager.ItemId.WeeklyActiveness) + end + + function XItemManager.CheckItemTemplateExist(id) + return id and ItemTemplates[id] and true or false + end + + function XItemManager.IsCanSell(id) + if XItemManager.IsTimeLimitBatch(id) then return false end --时效批次性道具不可出售 + local template = XItemManager.GetItemTemplate(id) + return template.SellForId > 0 and template.SellForCount > 0 + end + + function XItemManager.IsUseable(id) + local template = XItemManager.GetItemTemplate(id) + return template.ItemType == XItemConfigs.ItemType.Gift + end + + function XItemManager.IsWeaponFashion(id) + if not XItemManager.CheckItemTemplateExist(id) then return false end + local template = XItemManager.GetItemTemplate(id) + return template.ItemType == XItemConfigs.ItemType.WeaponFashion + end + + function XItemManager.IsWeaponFashionTimeLimit(id) + if not XItemManager.IsWeaponFashion(id) then + return true + end + + local weaponFashionId = XItemManager.GetWeaponFashionId(id) + if XDataCenter.WeaponFashionManager.CheckFashionTimeLimit(weaponFashionId) then + return true + end + + local addTime = XItemManager.GetWeaponFashionAddTime(id) + if addTime and addTime > 0 then + return true + end + + return false + end + + function XItemManager.GetWeaponFashionId(id) + if not XItemManager.IsWeaponFashion(id) then return end + local template = XItemManager.GetItemTemplate(id) + return template.SubTypeParams[1] + end + + function XItemManager.GetWeaponFashionAddTime(id) + if not XItemManager.IsWeaponFashion(id) then return end + local template = XItemManager.GetItemTemplate(id) + return template.SubTypeParams[2] + end + + --- + --- 储存仓库页签选择 + function XItemManager.SetPageRecordCache(page) + XItemManager.PageRecordCache = page + end + + -- 是否溢出(碎片是否可转化) + function XItemManager.IsCanConvert(id) + local template = XItemManager.GetItemTemplate(id) + if template.ItemType ~= XItemConfigs.ItemType.Fragment then + return false + end + + --角色已经满级 + local characterId = XCharacterConfigs.GetCharcterIdByFragmentItemId(id) + local charcter = XDataCenter.CharacterManager.GetCharacter(characterId) + return charcter and XDataCenter.CharacterManager.IsMaxQuality(charcter) + end + + -- 背包材料 + function XItemManager.IsBagMaterial(id) + local template = XItemManager.GetItemTemplate(id) + local itemType = template.ItemType + for _, materialType in pairs(XItemConfigs.Materials) do + if itemType == materialType then return true end + end + return false + end + + -- 时效性道具 + function XItemManager.IsTimeLimit(id) + local template = XItemManager.GetItemTemplate(id) + return template.TimelinessType > XItemManager.TimelinessType.Invalid + end + + -- 时效分批次性道具 + function XItemManager.IsTimeLimitBatch(id) + local template = XItemManager.GetItemTemplate(id) + return template.TimelinessType == XItemManager.TimelinessType.Batch + end + + -- 可选礼包 + function XItemManager.IsSelectGift(id) + if not XItemManager.IsUseable(id) then return false end + local template = XItemManager.GetItemTemplate(id) + return template.GiftType == XItemManager.GiftItemUseType.OptionalReward + end + + -- 红包 + function XItemManager.IsRedEnvelope(id) + if not XItemManager.IsUseable(id) then return false end + local template = XItemManager.GetItemTemplate(id) + return template.GiftType == XItemManager.GiftItemUseType.RedEnvelope + end + + -- 检查数据 + function XItemManager.CheckItemCount(item, count) + return item and item:GetCount() >= count + end + + function XItemManager.CheckItemCountById(id, count) + local item = XItemManager.GetItem(id) + return XItemManager.CheckItemCount(item, count) + end + + function XItemManager.CheckItemsCount(items) + for _, item in pairs(items) do + if not XItemManager.CheckItemCountById(item.Id, item.Count) then + return false + end + end + return true + end + + function XItemManager.CheckItemsCountByTimes(items, times) + for _, item in pairs(items) do + if not XItemManager.CheckItemCountById(item.Id, item.Count * times) then + return false + end + end + return true + end + + function XItemManager.CheckItemType(item, type) + return item.Template.ItemType == type + end + + -- 修改数据 + function XItemManager.CreateItem(itemData) + local template = XItemManager.GetItemTemplate(itemData.Id) + if template == nil then + XLog.ErrorTableDataNotFound("XItemManager.CreateItem", "ItemTemplate", " Share/Item/Item.tab", "id", tostring(itemData.Id)) + end + + local item + if template.RecType == XResetManager.ResetType.NoNeed then + item = XItem.New(itemData, template) + else + item = XRecItem.New(itemData, template) + end + + Items[item.Id] = item + return item + end + + function XItemManager.SetItemCount(id, count, validTime) + local item = Items[id] + if not item then + item = XItemManager.CreateItem(id, count, validTime, 0) + end + item:SetCount(count) + return item + end + + function XItemManager.SetItemCountDelta(id, delta, validTime) + local item = Items[id] + if item then + XItemManager.SetItemCount(id, item.Count + delta, validTime) + else + XItemManager.SetItemCount(id, delta, validTime) + end + end + + -- 回收相关 + function XItemManager.GetRecycleLeftTime(id) + local leftTime = 0 + + local item = XItemManager.GetItem(id) + if not item then return leftTime end + + local startTime + if item.Template.TimelinessType == XItemManager.TimelinessType.FromConfig then + startTime = XTime.ParseToTimestamp(item.Template.StartTime) + elseif item.Template.TimelinessType == XItemManager.TimelinessType.AfterGet then + startTime = item.CreateTime + end + + if startTime then + local endTime = startTime + item.Template.Duration + leftTime = endTime - XTime.GetServerNowTimestamp() + end + + return leftTime + end + + -- 此接口只检测回收类型 XItemManager.TimelinessType.FromConfig/XItemManager.TimelinessType.AfterGet + -- XItemManager.TimelinessType.Batch类型回收时间列表需手动检查 + function XItemManager.IsTimeOver(id) + if XItemManager.IsTimeLimit(id) then + local leftTime = XItemManager.GetRecycleLeftTime(id) + if leftTime and leftTime <= 0 then + return true + end + end + + return false + end + + -- 服务端交互 + function XItemManager.PackItemList(items) + local rpcData = {} + for id, count in pairs(items) do + local data = {} + data.Id = id + data.Count = count + tableInsert(rpcData, data) + end + + return rpcData + end + + function XItemManager.Use(id, recycleTime, count, callback, rewardIds) + local req = { Id = id, RecycleTime = recycleTime, Count = count, SelectRewardIds = rewardIds } + + XNetwork.Call(METHOD_NAME.Use, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + if callback then + callback(res.RewardGoodsList) + end + + if XItemManager.IsTimeLimit(id) then + XEventManager.DispatchEvent(XEventId.EVENT_TIMELIMIT_ITEM_USE, id) + end + CsXGameEventManager.Instance:Notify(XEventId.EVENT_ITEM_USE, id) + end) + end + + function XItemManager.Sell(datas, callback) + XMessagePack.MarkAsTable(datas) + local req = { SellItems = datas } + XNetwork.Call(METHOD_NAME.Sell, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + else + if callback then + callback(res.ObtainItems) + end + end + end) + end + + function XItemManager.BuyAsset(targetId, callback, failCallback, times, consumeId) + local req = { ItemId = targetId, ConsumeId = consumeId, Times = times } + XNetwork.Call(METHOD_NAME.BuyAsset, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + if failCallback then + failCallback() + end + + return + end + + -- if res.IsCrit then + -- end + if callback then + callback(targetId, res.Count, res.IsCrit) + end + + XEventManager.DispatchEvent(XEventId.EVENT_ITEM_BUYASSET, targetId) + end) + end + + function XItemManager.MultiplyUse(useList, callback) + local req = { UseList = useList } + + XNetwork.Call(METHOD_NAME.MultiplyUse, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + if callback then + callback(res.RewardGoodsList) + end + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_ITEM_MULTIPLY_USE) + end) + end + + -- 角色需要的基础属性 + function XItemManager.GetCoinsNum() + return Items[XItemManager.ItemId.Coin]:GetCount() + end + + function XItemManager.GetTotalGemsNum() + return Items[XItemManager.ItemId.FreeGem]:GetCount() + Items[XItemManager.ItemId.PaidGem]:GetCount() + end + + function XItemManager.GetActionPointsNum() + return Items[XItemManager.ItemId.ActionPoint]:GetCount() + end + + function XItemManager.GetMaxActionPoints() + return XPlayerManager.GetMaxActionPoint(XPlayer.GetLevelOrHonorLevel(), XPlayer.IsHonorLevelOpen()) + end + + function XItemManager.GetActionPointsRefreshResidueSecond() + return Items[XItemManager.ItemId.ActionPoint]:GetRefreshResidueSecond() + end + + function XItemManager.GetSkillPointNum() + return Items[XItemManager.ItemId.SkillPoint]:GetCount() + end + + function XItemManager.GetBatterys() + local tmp = {} + for _, v in pairs(SuppliesItems[XItemManager.SuppliesItemType.Battery]) do + if Items[v] then + tableInsert(tmp, Items[v]) + end + end + return XItemManager.ConvertToGridData(tmp) + end + + function XItemManager.GetCoinPackages() + local result = {} + for _, v in pairs(SuppliesItems[XItemManager.SuppliesItemType.CoinPackage]) do + if Items[v] then + tableInsert(result, Items[v]) + end + end + return XItemManager.ConvertToGridData(result) + end + + function XItemManager.GetCurBatterys() + local CurBatterys = {} + + local nowTime = XTime.GetServerNowTimestamp() + for _, v in pairs(XItemManager.GetBatterys()) do + local item = v.Data + if item:GetCount() > 0 then + local recycleBatch = v.RecycleBatch + if recycleBatch then + if recycleBatch.RecycleTime > nowTime then + tableInsert(CurBatterys, v) + end + elseif not XItemManager.IsTimeOver(item.Id) then + tableInsert(CurBatterys, v) + end + end + end + + tableSort(CurBatterys, function(a, b) + local aTemplate = a.Data.Template + local bTemplate = b.Data.Template + + if aTemplate.TimelinessType == bTemplate.TimelinessType then + if a.RecycleBatch and b.RecycleBatch then + if a.RecycleBatch.RecycleTime == b.RecycleBatch.RecycleTime then + return aTemplate.Priority > bTemplate.Priority + else + return a.RecycleBatch.RecycleTime < b.RecycleBatch.RecycleTime + end + else + return aTemplate.Priority > bTemplate.Priority + end + else + return aTemplate.TimelinessType > bTemplate.TimelinessType + end + end) + + return CurBatterys + end + + function XItemManager.GetCurrentCoinPackages() + local result = {} + local nowTime = XTime.GetServerNowTimestamp() + for _, value in ipairs(XItemManager.GetCoinPackages()) do + local item = value.Data + if item:GetCount() > 0 then + -- RecycleBatch这个数据是服务器返回的,来源于InitItemRecycle + local recycleBatch = value.RecycleBatch + if recycleBatch then + if recycleBatch.RecycleTime > nowTime then + tableInsert(result, value) + end + elseif not XItemManager.IsTimeOver(item.Id) then + tableInsert(result, value) + end + end + end + tableSort(result, function(a, b) + local aItemConfig = a.Data.Template + local bItemConfig = b.Data.Template + if aItemConfig.Priority == bItemConfig.Priority then + return aItemConfig.Id > bItemConfig.Id + else + return aItemConfig.Priority > bItemConfig.Priority + end + end) + return result + end + + function XItemManager.GetBatteryMinLeftTime() + local minLeftTime = 0 + + local nowTime = XTime.GetServerNowTimestamp() + local batterys = XItemManager.GetBatterys() + for _, v in pairs(batterys) do + local itemId = v.Data.Id + if XItemManager.IsTimeLimit(itemId) then + local recycleBatch = v.RecycleBatch + if recycleBatch then + if recycleBatch.RecycleCount > 0 then + local leftTime = recycleBatch.RecycleTime - nowTime + leftTime = leftTime > 0 and leftTime or 0 + if minLeftTime == 0 or minLeftTime > leftTime then + minLeftTime = leftTime + end + end + else + if v.Data:GetCount() > 0 and not XItemManager.IsTimeOver(itemId) then + local leftTime = XItemManager.GetRecycleLeftTime(itemId) + if leftTime then + if minLeftTime == 0 or minLeftTime > leftTime then + minLeftTime = leftTime + end + end + end + end + end + end + + return minLeftTime + end + + function XItemManager.GetTimeLimitItemsMinLeftTime() + local minLeftTime = 0 + + local nowTime = XTime.GetServerNowTimestamp() + for _, v in pairs(Items) do + local itemId = v.Id + if XItemManager.IsTimeLimit(itemId) and v:GetCount() > 0 and XItemManager.IsBagMaterial(itemId) then + local itemRecycleList = v.ItemRecycleList + if itemRecycleList then + for _, recycleBatch in pairs(itemRecycleList) do + if recycleBatch.RecycleCount > 0 then + local leftTime = recycleBatch.RecycleTime - nowTime + leftTime = leftTime > 0 and leftTime or 0 + if minLeftTime == 0 or minLeftTime > leftTime then + minLeftTime = leftTime + end + end + end + else + if not XItemManager.IsTimeOver(itemId) then + local leftTime = XItemManager.GetRecycleLeftTime(itemId) + if leftTime then + if minLeftTime == 0 or minLeftTime > leftTime then + minLeftTime = leftTime + end + end + end + end + end + end + + return minLeftTime + end + + function XItemManager.GetBagItemListMinLeftTime(bagDatas) + local minLeftTime = 0 + + local nowTime = XTime.GetServerNowTimestamp() + for _, gridData in pairs(bagDatas) do + local itemId = gridData.Data.Id + if XItemManager.IsTimeLimit(itemId) and gridData.Count > 0 then + local leftTime = gridData.RecycleBatch and gridData.RecycleBatch.RecycleTime - nowTime or XDataCenter.ItemManager.GetRecycleLeftTime(itemId) + leftTime = leftTime > 0 and leftTime or 0 + if minLeftTime == 0 or minLeftTime > leftTime then + minLeftTime = leftTime + end + end + end + + return minLeftTime + end + + function XItemManager.CheckBatteryIsHave() + for _, v in pairs(XItemManager.GetBatterys()) do + if v.Data:GetCount() > 0 then + return true + end + end + return false + end + + function XItemManager.CheckCoinPackageIsHave() + for _, v in pairs(XItemManager.GetCoinPackages()) do + if v.Data:GetCount() > 0 then + return true + end + end + return false + end + + function XItemManager.CheckBatteryIsHaveByIdAndRecycleTime(id, recycleTime) + for _, v in pairs(XItemManager.GetBatterys()) do + if v.Data:GetCount() > 0 and v.Data.Id == id then + if (not recycleTime or v.RecycleBatch.RecycleTime == recycleTime) then + return true + end + end + end + return false + end + + function XItemManager.DoNotEnoughBuyAsset(useItemId, useItemCount, buyCount, callBack, errorTxt) + local ownItemCount = XDataCenter.ItemManager.GetCount(useItemId) + local lackItemCount = useItemCount * buyCount - ownItemCount + if lackItemCount > 0 then + local template = XDataCenter.ItemManager.GetBuyAssetTemplate(useItemId, 0, true) + if template ~= nil then + if BuyAssetTemplates[useItemId] and #BuyAssetTemplates[useItemId] > 1 then + XItemManager.SelectBuyAssetType(useItemId, callBack, nil, 1, true) + else + lackItemCount = mathCeil(lackItemCount / template.GainCount) + XItemManager.SelectBuyAssetType(useItemId, callBack, nil, lackItemCount, true) + end + else + XUiManager.TipError(CS.XTextManager.GetText(errorTxt)) + end + return false + end + return true + end + function XItemManager.SelectBuyAssetType(useItemId, callBack, challengeCountData, buyAmount, isAutoClose) + if useItemId == XDataCenter.ItemManager.ItemId.ActionPoint and + XDataCenter.ItemManager.CheckBatteryIsHave() then + XLuaUiManager.Open("UiUsePackage", useItemId, callBack, challengeCountData, buyAmount) + elseif useItemId == XDataCenter.ItemManager.ItemId.Coin + and XDataCenter.ItemManager.CheckCoinPackageIsHave() then + XLuaUiManager.Open("UiUseCoinPackage") + else + XLuaUiManager.Open("UiBuyAsset", useItemId, callBack, challengeCountData, buyAmount, isAutoClose) + end + end + function XItemManager.NotifyItemDataList(data) + local list = data.ItemDataList + if not list then + return + end + for _, tmpData in pairs(list) do + local id = tmpData.Id + + if not Items[id] then + Items[id] = XItemManager.CreateItem(tmpData) + else + Items[id]:RefreshItem(tmpData) + end + + + + if not ItemFirstGetCheckTable[id] then + ItemFirstGetCheckTable[id] = true + end + end + + -- 回收道具时限表 + XItemManager.InitItemRecycle(data.ItemRecycleDict) + end + + function XItemManager.GetMaxCount(id) + if id == XItemManager.ItemId.ActionPoint then + return XItemManager.GetMaxActionPoints() + else + local template = XItemManager.GetItemTemplate(id) + if template then + if template.MaxCount <= 0 then + return XMath.IntMax() -- int.MaxValue,和服务端相同 + else + return template.MaxCount + end + else + return -1 + end + end + end + + function XItemManager.ConvertToGridData(originDatas) + local bagDatas = {} + for i = 1, #originDatas do + local data = originDatas[i] + if data.Count > 0 then + -- 按限时道具到期时间拆分(优先) + if XItemManager.IsTimeLimitBatch(data.Id) then + local list = data.ItemRecycleList + if list then + for index, info in ipairs(list) do + if info.RecycleCount > 0 then + local gridData = {} + gridData.Data = data + gridData.GridIndex = index + gridData.RecycleBatch = info + gridData.Count = info.RecycleCount + tableInsert(bagDatas, gridData) + end + end + end + -- 按最大堆叠数拆分 + elseif data.Template.GridCount <= 0 then + local gridData = {} + gridData.Data = data + gridData.GridIndex = 1 + gridData.Count = data.Count + tableInsert(bagDatas, gridData) + else + local gridCount = data.Template.GridCount + local gridNum = mathCeil(data.Count / gridCount) + for j = 1, gridNum do + local gridData = {} + gridData.Data = data + gridData.GridIndex = j + gridData.Count = mathMin(data.Count - (j - 1) * gridCount, gridCount) + tableInsert(bagDatas, gridData) + end + end + end + end + return bagDatas + end + -------------------------道具事件相关------------------------- + --==============================-- + --desc: 道具数量变化监听 + --@ids: 道具id或者道具id列表 + --@func: 事件回调 + --@ui: ui节点 + --@obj: UI对象,可为空 + --==============================-- + function XItemManager.AddCountUpdateListener(ids, func, ui, obj) + if type(ids) == "number" then + if ids == XItemManager.ItemId.FreeGem or ids == XItemManager.ItemId.PaidGem then + ids = { XItemManager.ItemId.FreeGem, XItemManager.ItemId.PaidGem } + else + ids = { ids } + end + end + + + for _, id in pairs(ids) do + if not Items[id] then + XLog.ErrorTableDataNotFound("XItemManager.AddCountUpdateListener", "Items", "Share/Item/Item.tab", "Id", tostring(id)) + return + end + end + + if not ui then + XLog.Error("XItemManager.AddCountUpdateListener函数参数错误: 参数ui不能为空") + return + end + + for _, id in pairs(ids) do + XEventManager.BindEvent(ui, XEventId.EVENT_ITEM_COUNT_UPDATE_PREFIX .. id, func, obj) + end + end + + --==============================-- + --desc: 购买次数变化监听 + --@ids: 道具id或者道具id列表 + --@func: 事件回调 + --@ui: ui节点 + --@obj: UI对象,可为空 + --==============================-- + function XItemManager.AddBuyTimesUpdateListener(ids, func, ui, obj) + if type(ids) == "number" then + if ids == XItemManager.ItemId.FreeGem or ids == XItemManager.ItemId.PaidGem then + ids = { XItemManager.ItemId.FreeGem, XItemManager.ItemId.PaidGem } + else + ids = { ids } + end + end + + for _, id in pairs(ids) do + if not Items[id] then + XLog.ErrorTableDataNotFound("XItemManager.AddBuyTimesUpdateListener", "Items", "Share/Item/Item.tab", "Id", tostring(id)) + return + end + end + + if not ui then + XLog.Error("XItemManager.AddBuyTimesUpdateListener函数参数错误: 参数ui不能为空") + return + end + + for _, id in pairs(ids) do + XEventManager.BindEvent(ui, XEventId.EVENT_ITEM_BUYTIEMS_UPDATE_PREFIX .. id, func, obj) + end + end + + function XItemManager.GetCookieKeyStr() + return string.format("RecycleItemList_%s", XPlayer.Id) + end + + function XItemManager.IsFastTrading(id) + local fastTrading = XItemConfigs.GetFastTrading(id) + if not fastTrading or fastTrading == XItemConfigs.FastTrading.NotFastTrading then + return false + end + + return true + end + + function XItemManager.JudjeCanFastTrading(uiName) + local FastTradingUiList = XItemConfigs.GetUiBuyAsset() + for _, v in pairs(FastTradingUiList) do + if v.UiName == uiName then + return true + end + end + + return false + end + + function XItemManager.NotifyItemRecycle(data) + if not next(data.RecycleIds) then return end + + for _, id in pairs(data.RecycleIds) do + Items[id] = nil + end + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_ITEM_RECYCLE) + end + + function XItemManager.NotifyBatchItemRecycle(data) + if not next(data.ItemRecycleList) then return end + + for _, recycleInfo in pairs(data.ItemRecycleList) do + local id = recycleInfo.Id + + local item = Items[id] + local itemRecycleList = item and item.ItemRecycleList + if itemRecycleList then + for k, v in pairs(itemRecycleList) do + if v.RecycleTime == recycleInfo.RecycleTime then + tableRemove(itemRecycleList, k) + break + end + end + + if not next(itemRecycleList) then + Items[id] = nil + end + end + end + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_ITEM_RECYCLE) + end + + function XItemManager.NotifyAllRedEnvelope(data) + if not next(data.Envelopes) then return end + + RedEnvelopeInfos = {} + for _, envelope in pairs(data.Envelopes) do + local activityId = envelope.ActivityId + RedEnvelopeInfos[activityId] = RedEnvelopeInfos[activityId] or {} + + local npcId = envelope.NpcId + RedEnvelopeInfos[activityId][npcId] = RedEnvelopeInfos[activityId][npcId] or {} + + local rewards = envelope.Rewards + for _, reward in pairs(rewards) do + local itemId = reward.ItemId + local itemCount = reward.ItemCount + local oldCount = RedEnvelopeInfos[activityId][npcId][itemId] or 0 + RedEnvelopeInfos[activityId][npcId][itemId] = oldCount + itemCount + end + end + end + + function XItemManager.NotifyRedEnvelopeUse(data) + local envelopeId = data.EnvelopeId + if not envelopeId or not XItemManager.IsRedEnvelope(envelopeId) then return end + + local envelopes = data.Envelopes + if not next(envelopes) then return end + + for _, envelope in pairs(envelopes) do + local activityId = envelope.ActivityId + RedEnvelopeInfos[activityId] = RedEnvelopeInfos[activityId] or {} + + local npcId = envelope.NpcId + RedEnvelopeInfos[activityId][npcId] = RedEnvelopeInfos[activityId][npcId] or {} + + local itemId = envelope.ItemId + local itemCount = envelope.ItemCount + local oldCount = RedEnvelopeInfos[activityId][npcId][itemId] or 0 + RedEnvelopeInfos[activityId][npcId][itemId] = oldCount + itemCount + end + + XLuaUiManager.Open("UiRedEnvelope", envelopeId, envelopes) + end + -------------------------道具事件相关------------------------- + XItemManager.Init() + return XItemManager +end + +XRpc.NotifyItemDataList = function(data) + XDataCenter.ItemManager.NotifyItemDataList(data) +end + +XRpc.NotifyItemRecycle = function(data) + XDataCenter.ItemManager.NotifyItemRecycle(data) +end + +XRpc.NotifyBatchItemRecycle = function(data) + XDataCenter.ItemManager.NotifyBatchItemRecycle(data) +end + +XRpc.NotifyAllRedEnvelope = function(data) + XDataCenter.ItemManager.NotifyAllRedEnvelope(data) +end + +XRpc.NotifyRedEnvelopeUse = function(data) + XDataCenter.ItemManager.NotifyRedEnvelopeUse(data) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XKillZoneManager.lua b/Resources/Scripts/XManager/XKillZoneManager.lua new file mode 100644 index 00000000..d62ffbb0 --- /dev/null +++ b/Resources/Scripts/XManager/XKillZoneManager.lua @@ -0,0 +1,1105 @@ +XKillZoneManagerCreator = function() + local tableInsert = table.insert + local pairs = pairs + local tonumber = tonumber + local stringFormat = string.format + + local XKillZoneManager = {} + + -----------------活动入口 begin---------------- + local _ActivityId = XKillZoneConfigs.GetDefaultActivityId() --当前开放活动Id + local _ActivityEnd = false --活动是否结束 + + local function UpdateActivityId(activityId) + XCountDown.RemoveTimer(XCountDown.GTimerName.KillZone) + + if not XTool.IsNumberValid(activityId) then + _ActivityId = XKillZoneConfigs.GetDefaultActivityId() + return + end + + _ActivityId = activityId + + local nowTime = XTime.GetServerNowTimestamp() + local leftTime = XKillZoneManager.GetEndTime() - nowTime + if leftTime > 0 then + XCountDown.CreateTimer(XCountDown.GTimerName.KillZone, leftTime) + end + end + + function XKillZoneManager.GetActivityName() + return XKillZoneConfigs.GetActivityName(_ActivityId) + end + + function XKillZoneManager.GetActivityChapters() + if not XKillZoneManager.IsOpen() then return end + + local chapters = {} + tableInsert(chapters, { + Id = _ActivityId, + Type = XDataCenter.FubenManager.ChapterType.KillZone, + BannerBg = XKillZoneConfigs.GetActivityBg(_ActivityId), + Name = XKillZoneManager.GetActivityName(), + }) + return chapters + end + + function XKillZoneManager.IsOpen() + if not XTool.IsNumberValid(_ActivityId) then return false end + + local nowTime = XTime.GetServerNowTimestamp() + local beginTime = XKillZoneManager.GetStartTime() + local endTime = XKillZoneManager.GetEndTime() + return beginTime <= nowTime and nowTime < endTime + end + + function XKillZoneManager.GetStartTime() + return XKillZoneConfigs.GetActivityStartTime(_ActivityId) or 0 + end + + function XKillZoneManager.GetEndTime() + return XKillZoneConfigs.GetActivityEndTime(_ActivityId) or 0 + end + + function XKillZoneManager.GetCurrActivityTime() + return XKillZoneManager.GetStartTime(), XKillZoneManager.GetEndTime() + end + + function XKillZoneManager.SetActivityEnd() + _ActivityEnd = true + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_KILLZONE_ACTIVITY_END) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_ACTIVITY_ON_RESET, XDataCenter.FubenManager.StageType.KillZone) + end + + function XKillZoneManager.ClearActivityEnd() + _ActivityEnd = nil + end + + function XKillZoneManager.OnActivityEnd() + if not _ActivityEnd then return false end + + if CS.XFight.IsRunning + or XLuaUiManager.IsUiLoad("UiLoading") + or XLuaUiManager.IsUiLoad("UiSettleLose") + or XLuaUiManager.IsUiLoad("UiSettleWin") then + return false + end + + --延迟是为了防止打断UI动画 + XScheduleManager.ScheduleOnce(function() + XUiManager.TipText("KillZoneActivityEnd") + XLuaUiManager.RunMain() + end, 1000) + + XKillZoneManager.ClearActivityEnd() + + return true + end + + function XKillZoneManager.EnterUiMain(beforeOpenUiCb) + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.KillZone) then return end + + if not XKillZoneManager.IsOpen() then + XUiManager.TipText("KillZoneActivityNotOpen") + return + end + + if beforeOpenUiCb then + beforeOpenUiCb(function() + XLuaUiManager.Open("UiKillZoneMain") + end) + else + XLuaUiManager.Open("UiKillZoneMain") + end + end + -----------------活动入口 end------------------ + -----------------关卡相关 begin------------------ + local XKillZoneStage = require("XEntity/XKillZone/XKillZoneStage") + + local _FinishStageDic = {} --关卡通关记录 + + local function InitStageType(stageId) + stageId = tonumber(stageId) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + if stageInfo then + stageInfo.Type = XDataCenter.FubenManager.StageType.KillZone + end + end + + local function GetStageInfo(stageId) + return _FinishStageDic[stageId] + end + + local function UpdateStageInfo(data) + local stageId = data.Id + local stage = GetStageInfo(stageId) + if not stage then + stage = XKillZoneStage.New(stageId) + _FinishStageDic[stageId] = stage + + --新增已解锁关卡时删除新关卡Cookie + XKillZoneManager.ClearCookieNewStage(stageId) + end + stage:UpdateData(data) + end + + local function UpdateFinishedStages(data) + for _, info in pairs(data) do + UpdateStageInfo(info) + end + + XEventManager.DispatchEvent(XEventId.EVENT_KILLZONE_STAGE_CHANGE) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_KILLZONE_STAGE_CHANGE) + end + + function XKillZoneManager.InitStageType() + local stageIds = XKillZoneConfigs.GetAllStageIds() + for _, stageId in pairs(stageIds) do + InitStageType(stageId) + end + end + + --关卡是否解锁 + function XKillZoneManager.IsStageUnlock(stageId) + local preStageId = XKillZoneConfigs.GetStagePreStageId(stageId) + if XTool.IsNumberValid(preStageId) then + return XKillZoneManager.IsStageFinished(preStageId) + end + return true + end + + --关卡是否通关 + function XKillZoneManager.IsStageFinished(stageId) + local stage = GetStageInfo(stageId) + if XTool.IsTableEmpty(stage) then + return false + end + return stage:IsFinished() + end + + --关卡是否满星通关 + function XKillZoneManager.IsStageFinishedPerfect(stageId) + if not XKillZoneManager.IsStageFinished(stageId) then return false end + local stageInfo = GetStageInfo(stageId) + return stageInfo:IsFinishedPerfect() + end + + --获取关卡最高击杀数 + function XKillZoneManager.GetStageMaxKillNum(stageId) + local stageInfo = GetStageInfo(stageId) + return stageInfo and stageInfo:GetKillEnemyCount() or 0 + end + + --获取关卡星数(当前,最高) + function XKillZoneManager.GetStageStar(stageId) + local stageInfo = GetStageInfo(stageId) + if not stageInfo then return 0, XKillZoneConfigs.GetStageMaxStar(stageId) end + return stageInfo:GetStar(), stageInfo:GetMaxStar() + end + + --获取该难度下所有关卡星数(当前,最高) + function XKillZoneManager.GetTotalStageStarByDiff(diff) + local star, maxStar = 0, 0 + + local stageIds = XKillZoneManager.GetStageIdsByDiff(diff) + for _, stageId in pairs(stageIds) do + local tmpStar, tmpMaxStar = XKillZoneManager.GetStageStar(stageId) + star = star + tmpStar + maxStar = maxStar + tmpMaxStar + end + + return star, maxStar + end + + --获取该难度下所有章节Id + function XKillZoneManager.GetChapterIds(diff) + return XKillZoneConfigs.GetChapterIdsByDiff(_ActivityId, diff) + end + + --获取该难度下所有关卡Id + function XKillZoneManager.GetStageIdsByDiff(diff) + local stageIds = {} + + local chapterIds = XKillZoneManager.GetChapterIds(diff) + for _, chapterId in pairs(chapterIds) do + local chapterStageIds = XKillZoneConfigs.GetChapterStageIds(chapterId) + for _, stageId in pairs(chapterStageIds) do + tableInsert(stageIds, stageId) + end + end + + return stageIds + end + + --章节是否在开启时间内 + function XKillZoneManager.IsChapterUnlock(chapterId) + local timeId = XKillZoneConfigs.GetChapterTimeId(chapterId) + return XFunctionManager.CheckInTimeByTimeId(timeId, true) + end + + --章节是否完成(当前章节全关卡满星通关) + function XKillZoneManager.IsChpaterFinished(chapterId) + local stageIds = XKillZoneConfigs.GetChapterStageIds(chapterId) + for _, stageId in pairs(stageIds) do + if not XKillZoneManager.IsStageFinishedPerfect(stageId) then + return false + end + end + return true + end + + --获取章节开启剩余时间(超过结束时间会读到负数,策划说不处理) + function XKillZoneManager.GetChpaterOpenLeftTime(chapterId) + local timeId = XKillZoneConfigs.GetChapterTimeId(chapterId) + local startTime = XFunctionManager.GetStartTimeByTimeId(timeId) + local nowTime = XTime.GetServerNowTimestamp() + return startTime - nowTime + end + + local function GetCookieKeyDiffAndChapterId() + if not XTool.IsNumberValid(_ActivityId) then return end + return stringFormat("XKillZoneManager_CookieKeyDiffAndChapterId_%d_%d", XPlayer.Id, _ActivityId) + end + + --更新上次挑战难度/章节缓存 + function XKillZoneManager.SetCookieDiffAndChapterId(diff, chapterId) + local key = GetCookieKeyDiffAndChapterId() + local data = { + Diff = diff, + ChapterId = chapterId, + } + XSaveTool.SaveData(key, data) + end + + --获取上次挑战难度/章节缓存 + function XKillZoneManager.GetCookieDiffAndChapterId() + local key = GetCookieKeyDiffAndChapterId() + local data = XSaveTool.GetData(key) + if XTool.IsTableEmpty(data) then return end + return data.Diff, data.ChapterId + end + + --更新可挑战新关卡Cookie + local function UpdateNewStageCookie() + local newStageIds = {} + + local chapterIds = XKillZoneManager.GetChapterIds(XKillZoneConfigs.Difficult.Normal) + for _, chapterId in pairs(chapterIds) do + --章节已解锁 + if XKillZoneManager.IsChapterUnlock(chapterId) then + local stageIds = XKillZoneConfigs.GetChapterStageIds(chapterId) + for _, stageId in pairs(stageIds) do + --关卡未通关 + if not XKillZoneManager.IsStageFinished(stageId) then + newStageIds[stageId] = stageId + end + end + end + end + + XKillZoneManager.SetCookieNewStage(newStageIds) + end + + local function GetCookieKeyNewStage() + if not XTool.IsNumberValid(_ActivityId) then return end + local today5 = XTime.GetSeverTodayFreshTime() + return stringFormat("XKillZoneManager_CookieKeyNewStage_%d_%d_%d", XPlayer.Id, _ActivityId, today5) + end + + --全量设置新关卡标记缓存(每日重置) + function XKillZoneManager.SetCookieNewStage(newStageIds) + local key = GetCookieKeyNewStage() + local data = XSaveTool.GetData(key) + if XTool.IsTableEmpty(data) then + data = newStageIds + XSaveTool.SaveData(key, data) + end + + XEventManager.DispatchEvent(XEventId.EVENT_KILLZONE_NEW_CHAPTER_CHANGE) + end + + --检查新关卡标记缓存(每日重置) + function XKillZoneManager.CheckCookieNewStage(stageId) + local key = GetCookieKeyNewStage() + local data = XSaveTool.GetData(key) + return data and data[stageId] or false + end + + --清除新关卡标记缓存(挑战关卡后) + function XKillZoneManager.ClearCookieNewStage(stageId) + local key = GetCookieKeyNewStage() + local data = XSaveTool.GetData(key) + if not XTool.IsTableEmpty(data) then + data[stageId] = nil + XSaveTool.SaveData(key, data) + end + + XEventManager.DispatchEvent(XEventId.EVENT_KILLZONE_NEW_CHAPTER_CHANGE) + end + + local function GetCookieKeyNewChapterClicked(chapterId) + if not XTool.IsNumberValid(_ActivityId) then return end + return stringFormat("%d_%d_%d_XKillZoneManager_CookieKeyNewChapterClicked", XPlayer.Id, _ActivityId, chapterId) + end + + --设置新章节已点击标记缓存(点击新章节时) + function XKillZoneManager.SetCookieNewChapterClicked(chapterId) + local key = GetCookieKeyNewChapterClicked(chapterId) + XSaveTool.SaveData(key, true) + + XEventManager.DispatchEvent(XEventId.EVENT_KILLZONE_NEW_CHAPTER_CHANGE) + end + + --获取新章节已点击标记缓存 + function XKillZoneManager.GetCookieNewChapterClicked(chapterId) + local key = GetCookieKeyNewChapterClicked(chapterId) + return XSaveTool.GetData(key) + end + + --章节按钮可挑战红点(chapter解锁,(stages全部未解锁,未点击过) or (有关卡解锁,且未首通(每日判定))) + function XKillZoneManager.CheckNewChapterRedPoint(chapterId) + if not XKillZoneManager.IsChapterUnlock(chapterId) then return false end + + local allLock = true + local stageIds = XKillZoneConfigs.GetChapterStageIds(chapterId) + for _, stageId in pairs(stageIds) do + if XKillZoneManager.IsStageUnlock(stageId) then + allLock = false + + if not XKillZoneManager.IsStageFinished(stageId) + and XKillZoneManager.CheckCookieNewStage(stageId) then + return true + end + end + end + + if allLock then + return not XKillZoneManager.GetCookieNewChapterClicked(chapterId) + end + end + + local function GetCookieKeyNewDiffClicked() + if not XTool.IsNumberValid(_ActivityId) then return end + return stringFormat("%d_%d_XKillZoneManager_CookieKeyNewDiffClicked", XPlayer.Id, _ActivityId) + end + + --设置挑战模式已点击标记缓存(点击挑战模式按钮时) + function XKillZoneManager.SetCookieNewDiffClicked() + local key = GetCookieKeyNewDiffClicked() + XSaveTool.SaveData(key, true) + + XEventManager.DispatchEvent(XEventId.EVENT_KILLZONE_NEW_DIFF_CHANGE) + end + + --获取挑战模式已点击标记缓存 + function XKillZoneManager.GetCookieNewDiffClicked() + local key = GetCookieKeyNewDiffClicked() + return XSaveTool.GetData(key) + end + + --挑战模式是否开启 + function XKillZoneManager.IsDiffHardUnlock() + local chapterIds = XKillZoneManager.GetChapterIds(XKillZoneConfigs.Difficult.Hard) + for _, chapterId in pairs(chapterIds) do + local preStageId = XKillZoneConfigs.GetChapterPreStageId(chapterId) + if not XKillZoneManager.IsStageFinished(preStageId) then + return false, preStageId + end + end + return true, 0 + end + + --获取关卡总进度 + function XKillZoneManager.GetStageProcess() + local finishCount, totalCount = 0, 0 + + local totalStageIds = XKillZoneConfigs.GetTotalStageIdsByDiff(_ActivityId, XKillZoneConfigs.Difficult.Normal) + for _, stageId in pairs(totalStageIds) do + if XKillZoneManager.IsStageFinished(stageId) then + finishCount = finishCount + 1 + end + totalCount = totalCount + 1 + end + + return finishCount, totalCount + end + -----------------关卡相关 end------------------ + -----------------奖励相关 begin------------------ + local _FarmRewardObtainCount = 0 --复刷奖励已领取次数 + local _StarRewardObtainDic = {} --星级奖励领取记录 + local _DailyStarRewardIndex = 0 --每日星级奖励领取记录(对应配置表Id) + local _YesterdayStar = 0 --每日星级奖励档位 + + local function UpdateFarmRewardObtainCount(data) + _FarmRewardObtainCount = XTool.IsNumberValid(data) and data or 0 + + XEventManager.DispatchEvent(XEventId.EVENT_KILLZONE_FARM_REWARD_OBTAIN_COUNT_CHANGE) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_KILLZONE_FARM_REWARD_OBTAIN_COUNT_CHANGE) + end + + --获取复刷奖励剩余领取次数 + function XKillZoneManager.GetLeftFarmRewardObtainCount() + return XMath.Clamp(XKillZoneConfigs.MaxFarmRewardCount - _FarmRewardObtainCount, 0, XKillZoneConfigs.MaxFarmRewardCount) + end + + --是否有剩余复刷奖励领取次数 + function XKillZoneManager.CheckHasLeftFarmRewardObtainCount() + return XKillZoneManager.GetLeftFarmRewardObtainCount() > 0 + end + + local function UpdateStarRewardRecord(data) + if XTool.IsTableEmpty(data) then return end + + for _, starRewardId in pairs(data) do + _StarRewardObtainDic[starRewardId] = starRewardId + end + + XEventManager.DispatchEvent(XEventId.EVENT_KILLZONE_STAR_REWARD_OBTAIN_RECORD_CHANGE) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_KILLZONE_STAR_REWARD_OBTAIN_RECORD_CHANGE) + end + + --星级奖励是否可领取 + function XKillZoneManager.IsStarRewardCanGet(starRewardId) + local diff = XKillZoneConfigs.GetStarRewardDiff(starRewardId) + local requireStar = XKillZoneConfigs.GetStarRewardStar(starRewardId) + local star = XKillZoneManager.GetTotalStageStarByDiff(diff) + return star >= requireStar + end + + --所有难度下是否有星级奖励可领取 + function XKillZoneManager.IsAnyStarRewardCanGet() + if not XKillZoneManager.IsOpen() then return false end + + for _, diff in pairs(XKillZoneConfigs.Difficult) do + if XKillZoneManager.IsAnyStarRewardCanGetByDiff(diff) then return true end + end + return false + end + + --当前难度下是否有星级奖励可领取 + function XKillZoneManager.IsAnyStarRewardCanGetByDiff(diff) + if not XKillZoneManager.IsOpen() then return false end + + local rewardIds = XKillZoneConfigs.GetAllStarRewardIdsByDiff(diff) + for _, starRewardId in pairs(rewardIds) do + if not XKillZoneManager.IsStarRewardObtained(starRewardId) + and XKillZoneManager.IsStarRewardCanGet(starRewardId) + then + return true + end + end + return false + end + + --星级奖励是否已领取 + function XKillZoneManager.IsStarRewardObtained(starRewardId) + return _StarRewardObtainDic[starRewardId] and true or false + end + + --当前难度星级奖励是否全部已领取 + function XKillZoneManager.IsStarRewardObtainedByDiff(diff) + if not XKillZoneManager.IsOpen() then return false end + + local rewardIds = XKillZoneConfigs.GetAllStarRewardIdsByDiff(diff) + for _, starRewardId in pairs(rewardIds) do + if not XKillZoneManager.IsStarRewardObtained(starRewardId) then + return false + end + end + return true + end + + local function UpdateDailyStarRewardIndex(index, star) + _DailyStarRewardIndex = index or _DailyStarRewardIndex + _YesterdayStar = star or _YesterdayStar + + XEventManager.DispatchEvent(XEventId.EVENT_KILLZONE_DAILYSTARREWARDINDEX_CHANGE) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_KILLZONE_DAILYSTARREWARDINDEX_CHANGE) + end + + function XKillZoneManager.GetAllDailyStarRewardIds() + return XKillZoneConfigs.GetAllDailyStarRewardIds(_ActivityId) + end + + --获取昨日挑战总星级 + function XKillZoneManager.GetYesterdayStar() + return _YesterdayStar + end + + --每日星级奖励是否已领取 + function XKillZoneManager.IsDailyStarRewardObtained() + return XTool.IsNumberValid(_DailyStarRewardIndex) + end + + --请求领取星级奖励 + function XKillZoneManager.KillZoneTakeDiffStarRewardRequest(starRewardId, cb) + local req = { Id = starRewardId } + + XNetwork.Call("KillZoneTakeDiffStarRewardRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + UpdateStarRewardRecord({ starRewardId }) + + local rewardGoods = res.RewardGoodsList + if cb then cb(rewardGoods) end + end) + end + + --请求领取复刷奖励 + function XKillZoneManager.KillZoneTakeFarmRewardRequest(stageId, cb) + do return end--屏蔽 + + local req = { StageId = stageId } + XNetwork.Call("KillZoneTakeFarmRewardRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + UpdateFarmRewardObtainCount(res.TakeFarmRewardCount) + + if cb then cb(res.RewardGoodsList) end + end) + end + + --请求领取每日星级奖励 + function XKillZoneManager.KillZoneTakeDailyStarRewardRequest(cb) + XNetwork.Call("KillZoneTakeDailyStarRewardRequest", nil, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + UpdateDailyStarRewardIndex(res.Id) + + local rewardGoods = res.RewardGoodsList + if cb then cb(rewardGoods) end + end) + end + -----------------奖励相关 end------------------ + -----------------插件相关 begin------------------ + local XKillZonePlugin = require("XEntity/XKillZone/XKillZonePlugin") + + local _Plugins = {} --插件信息 + local _UnlockPluginSlotDic = {} --已解锁插件槽 + + local function InitPlugins() + _Plugins = {} + + local pluginIds = XKillZoneConfigs.GetAllPluginIds() + for _, pluginId in pairs(pluginIds) do + _Plugins[pluginId] = XKillZonePlugin.New(pluginId) + end + + XEventManager.DispatchEvent(XEventId.EVENT_KILLZONE_PLUGIN_CHANGE) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_KILLZONE_PLUGIN_CHANGE) + end + + local function GetPlugin(pluginId) + return _Plugins[pluginId] + end + + local function UpdatePlugins(data) + for _, info in pairs(data) do + local pluginId = info.Id + + local plugin = GetPlugin(pluginId) + if plugin then + plugin:UpdateData(info) + end + end + + XEventManager.DispatchEvent(XEventId.EVENT_KILLZONE_PLUGIN_CHANGE) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_KILLZONE_PLUGIN_CHANGE) + end + + local function PutOnPlugin(pluginId, slot) + if not XTool.IsNumberValid(pluginId) + or not XTool.IsNumberValid(slot) + then return end + + local plugin = GetPlugin(pluginId) + if plugin then + plugin:PutOn(slot) + end + _UnlockPluginSlotDic[slot] = pluginId + end + + local function TakeOffPlugin(pluginId) + if not XTool.IsNumberValid(pluginId) + then return end + + local plugin = GetPlugin(pluginId) + if plugin then + plugin:TakeOff() + end + + for slot, inPluginId in pairs(_UnlockPluginSlotDic) do + if inPluginId == pluginId then + _UnlockPluginSlotDic[slot] = 0 + end + end + end + + local function ResetPlugins(pluginIds) + for _, pluginId in pairs(pluginIds) do + local plugin = GetPlugin(pluginId) + if plugin then + plugin:Reset() + end + TakeOffPlugin(pluginId) + end + + XEventManager.DispatchEvent(XEventId.EVENT_KILLZONE_PLUGIN_CHANGE) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_KILLZONE_PLUGIN_CHANGE) + end + + local function UpdatePluginSlots(data) + _UnlockPluginSlotDic = {} + + local slot, pluginId + for _, info in pairs(data) do + slot = info.Id + pluginId = info.PluginId + + if XTool.IsNumberValid(slot) then + _UnlockPluginSlotDic[slot] = pluginId or 0 + PutOnPlugin(pluginId, slot) + end + end + + XEventManager.DispatchEvent(XEventId.EVENT_KILLZONE_PLUGIN_SLOT_CHANGE) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_KILLZONE_PLUGIN_SLOT_CHANGE) + end + + --插件槽是否解锁 + function XKillZoneManager.IsPluginSlotUnlock(slot) + local conditionId = XKillZoneConfigs.GetPluginSlotConditionId(slot) + if XTool.IsNumberValid(conditionId) then + return XConditionManager.CheckCondition(conditionId) + end + return true + end + + --插件槽是否为空(已解锁) + function XKillZoneManager.IsPluginSlotEmpty(slot) + if not XKillZoneManager.IsPluginSlotUnlock(slot) then return false end + return not XTool.IsNumberValid(XKillZoneManager.GetSlotWearingPluginId(slot)) + end + + function XKillZoneManager.GetSlotWearingPluginId(slot) + local pluginId = _UnlockPluginSlotDic[slot] + return XTool.IsNumberValid(pluginId) and pluginId or nil + end + + --获取下一个已解锁空插件槽,全满返回1 + function XKillZoneManager.GetNextEmptySlot() + for slot = 1, XKillZoneConfigs.GetMaxPluginSlotNum() do + if XKillZoneManager.IsPluginSlotEmpty(slot) then + return slot + end + end + return 1 + end + + --获取插件等级 + function XKillZoneManager.GetPluginLevel(pluginId) + local plugin = GetPlugin(pluginId) + return plugin and plugin:GetLevel() or 0 + end + + --获取插件展示等级(包含未解锁/未激活/正常/最大等级) + function XKillZoneManager.GetPluginShowLevelStr(pluginId) + local plugin = GetPlugin(pluginId) + return plugin and plugin:GetShowLevelStr() or "" + end + + --插件是否未解锁 + function XKillZoneManager.IsPluginLock(pluginId) + local plugin = GetPlugin(pluginId) + return plugin and plugin:IsLock() + end + + --插件是否可解锁(满足消耗) + function XKillZoneManager.IsPluginCanUnlock(pluginId) + if not XKillZoneManager.IsPluginLock(pluginId) then return false end + local itemId, itemCount = XKillZoneConfigs.GetPluginUnlockCost(pluginId) + if XTool.IsNumberValid(itemId) then + return XDataCenter.ItemManager.CheckItemCountById(itemId, itemCount) + end + return true + end + + --插件是否未激活 + function XKillZoneManager.IsPluginUnActive(pluginId) + local plugin = GetPlugin(pluginId) + return plugin and plugin:IsUnActive() + end + + --插件是否可激活(满足消耗) + function XKillZoneManager.IsPluginCanActive(pluginId) + if not XKillZoneManager.IsPluginUnActive(pluginId) then return false end + local itemId, itemCount = XKillZoneConfigs.GetPluginUnActiveCost(pluginId) + if XTool.IsNumberValid(itemId) then + return XDataCenter.ItemManager.CheckItemCountById(itemId, itemCount) + end + return true + end + + --插件是否可升级 + function XKillZoneManager.CheckPluginCanLevelUp(pluginId) + return not XKillZoneManager.IsPluginLock(pluginId) + and not XKillZoneManager.IsPluginUnActive(pluginId) + and not XKillZoneManager.IsPluginMaxLevel(pluginId) + end + + --插件是否达到最大等级 + function XKillZoneManager.IsPluginMaxLevel(pluginId) + local plugin = GetPlugin(pluginId) + return plugin and plugin:IsMaxLevel() + end + + --获取插件升级消耗 + function XKillZoneManager.GetPluginLevelUpCost(pluginId) + local plugin = GetPlugin(pluginId) + if plugin then + return plugin:GetLevelUpCost() + end + return 0, 0 + end + + --插件是否可升级(消耗足够) + function XKillZoneManager.IsPluginCanLevelUp(pluginId) + if not XKillZoneManager.CheckPluginCanLevelUp(pluginId) then return false end + local itemId, itemCount = XKillZoneManager.GetPluginLevelUpCost(pluginId) + if XTool.IsNumberValid(itemId) then + return XDataCenter.ItemManager.CheckItemCountById(itemId, itemCount) + end + return true + end + + --获取插件是否装备中位置 + function XKillZoneManager.GetPluginWearingSlot(pluginId) + if not XTool.IsNumberValid(pluginId) then return 0 end + for slot in pairs(_UnlockPluginSlotDic) do + if pluginId == XKillZoneManager.GetSlotWearingPluginId(slot) then + return slot + end + end + return 0 + end + + --插件是否装备中 + function XKillZoneManager.IsPluginWearing(pluginId) + return XTool.IsNumberValid(XKillZoneManager.GetPluginWearingSlot(pluginId)) + end + + --插件是否可重置 + function XKillZoneManager.IsPluginCanReset(pluginId) + return not XKillZoneManager.IsPluginLock(pluginId) + end + + --获取插件重置总消耗 + function XKillZoneManager.GetPluginsResetCost(pluginIds) + return XKillZoneConfigs.GetPluginsResetCost(pluginIds, _ActivityId) + end + + --获取插件重置总获得 + function XKillZoneManager.GetPluginsResetObtainList(pluginIds) + local itemList = {} + + local itemDic = {} + local itemId, itemCount + for _, pluginId in pairs(pluginIds) do + if not XKillZoneManager.IsPluginLock(pluginId) then + --计算激活+升级消耗 + local level = XKillZoneManager.GetPluginLevel(pluginId) + itemId, itemCount = XKillZoneConfigs.GetPluginLevelUpCostTotal(pluginId, 1, level) + itemDic[itemId] = itemDic[itemId] or 0 + itemDic[itemId] = itemDic[itemId] + itemCount + + --计算解锁消耗 + itemId, itemCount = XKillZoneConfigs.GetPluginUnlockCost(pluginId) + itemDic[itemId] = itemDic[itemId] or 0 + itemDic[itemId] = itemDic[itemId] + itemCount + end + end + + for itemId, itemCount in pairs(itemDic) do + tableInsert(itemList, { + Id = itemId, + Count = itemCount, + }) + end + + return itemList + end + + --获取所有可重置插件Id列表 + function XKillZoneManager.GetCanResetPluginIds() + local pluginIds = {} + for pluginId in pairs(_Plugins) do + if XKillZoneManager.IsPluginCanReset(pluginId) then + tableInsert(pluginIds, pluginId) + end + end + return pluginIds + end + + --是否有插件可解锁/激活/升级(满足消耗) + function XKillZoneManager.IsAnyPluginCanOperate() + for pluginId in pairs(_Plugins) do + if XKillZoneManager.IsPluginCanLevelUp(pluginId) + or XKillZoneManager.IsPluginCanActive(pluginId) + or XKillZoneManager.IsPluginCanUnlock(pluginId) + then + return true + end + end + return false + end + + local function GetCookieKeyPluginOperate() + if not XTool.IsNumberValid(_ActivityId) then return end + return stringFormat("XKillZoneManager_CookieKeyPluginOperate_%d_%d", XPlayer.Id, _ActivityId) + end + + --设置插件待操作缓存 + local function SetCookiePluginOperate() + local key = GetCookieKeyPluginOperate() + local value = XKillZoneManager.IsAnyPluginCanOperate() + XSaveTool.SaveData(key, value) + XEventManager.DispatchEvent(XEventId.EVENT_KILLZONE_PLUGIN_OPERATE_CHANGE) + end + + --检查插件待操作缓存 + function XKillZoneManager.CheckCookiePluginOperate() + local key = GetCookieKeyPluginOperate() + local data = XSaveTool.GetData(key) + return data and true or false + end + + --清除插件待操作缓存(进入插件界面后) + function XKillZoneManager.ClearCookiePluginOperate() + local key = GetCookieKeyPluginOperate() + XSaveTool.RemoveData(key) + XEventManager.DispatchEvent(XEventId.EVENT_KILLZONE_PLUGIN_OPERATE_CHANGE) + end + + local function GetCookieKeyPluginOperateChecked() + if not XTool.IsNumberValid(_ActivityId) then return end + local today5 = XTime.GetSeverTodayFreshTime() + return stringFormat("XKillZoneManager_CookieKeyPluginOperateChecked_%d_%d_%d", XPlayer.Id, _ActivityId, today5) + end + + --主动检查插件待检查Cookie(每日) + local function TryCheckPluginOperateCookie() + XEventManager.AddEventListener(XEventId.EVENT_ITEM_COUNT_UPDATE_PREFIX .. XKillZoneConfigs.ItemIdCoinA, SetCookiePluginOperate) + XEventManager.AddEventListener(XEventId.EVENT_ITEM_COUNT_UPDATE_PREFIX .. XKillZoneConfigs.ItemIdCoinB, SetCookiePluginOperate) + + if XKillZoneManager.CheckCookiePluginOperateChecked() then return end + --如果当日未检查过,主动检查一次,并记录cookie + SetCookiePluginOperate() + local key = GetCookieKeyPluginOperateChecked() + XSaveTool.SaveData(key, true) + end + + --插件待操作缓存是否被检查过(每日重置) + function XKillZoneManager.CheckCookiePluginOperateChecked() + local key = GetCookieKeyPluginOperateChecked() + return XSaveTool.GetData(key) + end + + --[[插件红点规则:(策划文档) + 若有任意1个插件满足解锁,激活,升级条件,则在插件的入口处添加蓝点提示 + 此蓝点提示在玩家进入插件界面后移除,且每次的提示逻辑只在玩家的A和B货币发生变动时做检测 + (也就是说,如果玩家满足激活某1插件,点进界面后没有操作退出后,蓝点提示也会消失) + 注意此判定,在每日5点后默认刷新1次:比如我有货币1可以激活插件,但白天点击,蓝点就取消了; + 到了第2天(由于蓝点判定重置)会在做1次判定,看我的货币是否符合条件 + ]] + function XKillZoneManager.CheckPluginsCanOperateRedPoint() + return XKillZoneManager.CheckCookiePluginOperate() + end + + --请求重置插件(pluginId为0时代表重置所有插件) + function XKillZoneManager.KillZoneResetRequest(pluginIds, cb) + local pluginId = #pluginIds > 1 and 0 or pluginIds[1] + local req = { PluginId = pluginId } + + XNetwork.Call("KillZoneResetRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + ResetPlugins(pluginIds) + + local rewardGoods = {} + tableInsert(rewardGoods, XRewardManager.CreateRewardGoods(XKillZoneConfigs.ItemIdCoinA, res.AddCoinA)) + tableInsert(rewardGoods, XRewardManager.CreateRewardGoods(XKillZoneConfigs.ItemIdCoinB, res.AddCoinB)) + + if cb then cb(rewardGoods) end + end) + end + + --请求使用插件(pluginId为0时代表卸下当前槽位插件) + function XKillZoneManager.KillZoneUsePluginRequest(slot, pluginId, isTakeOff, cb) + local paramPluginId = pluginId + if isTakeOff then + paramPluginId = 0 + slot = XKillZoneManager.GetPluginWearingSlot(pluginId) + end + + local req = { SlotId = slot, PluginId = paramPluginId } + XNetwork.Call("KillZoneUsePluginRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + if isTakeOff then + TakeOffPlugin(pluginId) + else + PutOnPlugin(pluginId, slot) + end + + XEventManager.DispatchEvent(XEventId.EVENT_KILLZONE_PLUGIN_CHANGE) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_KILLZONE_PLUGIN_CHANGE) + + if cb then cb() end + end) + end + + --请求解锁插件 + function XKillZoneManager.KillZoneUnlockPluginRequest(pluginId, cb) + local req = { PluginId = pluginId } + XNetwork.Call("KillZoneUnlockPluginRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + UpdatePlugins({ res.PluginDb }) + + if cb then cb() end + end) + end + + --请求激活/升级插件 + function XKillZoneManager.KillZoneUpgradePluginRequest(pluginId, cb) + local req = { PluginId = pluginId } + XNetwork.Call("KillZoneUpgradePluginRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + UpdatePlugins({ res.PluginDb }) + + if cb then cb() end + end) + end + -----------------插件相关 end------------------ + ---------------------副本相关 begin------------------ + function XKillZoneManager.InitStageInfo() + XKillZoneManager.InitStageType() + XKillZoneManager.RegisterEditBattleProxy() + end + + function XKillZoneManager.CheckPassedByStageId(stageId) + return XKillZoneManager.IsStageFinished(stageId) + end + + function XKillZoneManager.ShowReward(winData) + local closeCb = function() + UpdateFinishedStages({ winData.SettleData.KillZoneStageResult.StageDb }) + end + XLuaUiManager.Open("UiKillZoneSettleWin", winData, closeCb) + end + + function XKillZoneManager.RegisterEditBattleProxy() + XUiNewRoomSingleProxy.RegisterProxy(XDataCenter.FubenManager.StageType.KillZone, + require("XUi/XUiKillZone/XUiKillZoneNewRoomSingle")) + end + + local function GetCookieKeyTeam() + if not XTool.IsNumberValid(_ActivityId) then return end + return stringFormat("XKillZoneManager_CookieKeyTeam_%d_%d", XPlayer.Id, _ActivityId) + end + + -- 保存编队信息 + function XKillZoneManager.SaveTeamLocal(curTeam) + XSaveTool.SaveData(GetCookieKeyTeam(), curTeam) + end + + -- 读取本地编队信息 + function XKillZoneManager.LoadTeamLocal() + local team = XSaveTool.GetData(GetCookieKeyTeam()) or XDataCenter.TeamManager.EmptyTeam + return XTool.Clone(team) + end + ---------------------副本相关 end------------------ + local function ResetData() + XKillZoneManager.SetActivityEnd() + + _ActivityId = 0 --当前开放活动Id + _FinishStageDic = {} --关卡通关记录 + _FarmRewardObtainCount = 0 --复刷奖励已领取次数 + _DailyStarRewardIndex = 0 --每日星级奖励领取记录(对应配置表Id) + _YesterdayStar = 0 --每日星级奖励档位 + _StarRewardObtainDic = {} --星级奖励领取记录 + _Plugins = {} --插件信息 + _UnlockPluginSlotDic = {} --已解锁插件槽 + + InitPlugins() + end + + function XKillZoneManager.NotifyKillZoneActivityData(data) + local data = data.KillZoneDb + + if XTool.IsNumberValid(_ActivityId) + and data.ActivityId ~= _ActivityId then + ResetData() + end + + UpdateActivityId(data.ActivityId) + UpdateFinishedStages(data.StageDbs) + UpdateFarmRewardObtainCount(data.TakeFarmRewardCount) + UpdateStarRewardRecord(data.DiffStarReward) + UpdateDailyStarRewardIndex(data.DailyStarRewardIndex, data.YesterdayStar) + UpdatePlugins(data.PluginDbs) + UpdatePluginSlots(data.PluginSlotDbs) + + UpdateNewStageCookie() + TryCheckPluginOperateCookie() + end + + --每日重置 + function XKillZoneManager.NotifyKillZoneActivityDailyReset(data) + UpdateFarmRewardObtainCount(data.TakeFarmRewardCount) + UpdateDailyStarRewardIndex(data.DailyStarRewardIndex, data.YesterdayStar) + + UpdateNewStageCookie() + TryCheckPluginOperateCookie() + end + + function XKillZoneManager.Init() + InitPlugins() + end + + XKillZoneManager.Init() + + return XKillZoneManager +end +---------------------Notify begin------------------ +XRpc.NotifyKillZoneActivityData = function(data) + XDataCenter.KillZoneManager.NotifyKillZoneActivityData(data) +end + +XRpc.NotifyKillZoneActivityDailyReset = function(data) + XDataCenter.KillZoneManager.NotifyKillZoneActivityDailyReset(data) +end +---------------------Notify end------------------ \ No newline at end of file diff --git a/Resources/Scripts/XManager/XLoadingManager.lua b/Resources/Scripts/XManager/XLoadingManager.lua new file mode 100644 index 00000000..7d416da7 --- /dev/null +++ b/Resources/Scripts/XManager/XLoadingManager.lua @@ -0,0 +1,82 @@ +LoadingType = { + Fight = "10101", --战斗 + Dormitory = "902", --宿舍 +} + +XLoadingManagerCreator = function() + + local XLoadingManager = {} + + + --初始化 + function XLoadingManager.Init() + + end + + --根据类型以及权重取出loading的tab数据 + function XLoadingManager.GetLoadingTab(type) + + if not type then + return + end + + local loadingList = XLoadingConfig.GetCfgByType(type) + + if not loadingList then + XLog.Error("不存在该类型的LoadingList配置,type =", type) + return + end + + local count = #loadingList + + if count == 0 then + XLog.Error("不存在该类型的LoadingList配置,type =", type) + return + end + + --只有一个直接返回 + if count == 1 then + return loadingList[1] + end + + --打乱数组 + for i = 1, count do + if i < count then + local temp = loadingList[i] + local next = i + 1 + local swapIndex = math.random(next, count) + loadingList[i] = loadingList[swapIndex] + loadingList[swapIndex] = temp + end + end + + --根据权重获取 + local TotalWeight = 0 + + --先计算权重总和 + for _, v in ipairs(loadingList) do + TotalWeight = TotalWeight + v.Weight + end + + local maxValue = 0 + local index = 1 + + --选择权重最高的值 + for k, v in ipairs(loadingList) do + local weight = math.random(0, TotalWeight) + weight = weight + v.Weight + if maxValue < weight then + maxValue = weight + index = k + end + end + + return loadingList[index] + end + + + XLoadingManager.Init() + + return XLoadingManager + +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XLoginManager.lua b/Resources/Scripts/XManager/XLoginManager.lua new file mode 100644 index 00000000..8eba37df --- /dev/null +++ b/Resources/Scripts/XManager/XLoginManager.lua @@ -0,0 +1,985 @@ +XLoginManager = XLoginManager or {} + +local Json = require("XCommon/Json") +local RetCode = { + Success = 0, + ErrServerMaintaining = 1, -- 服务器正常维护 + FirstLoginIsBanned = 11, -- 初次封禁 + MultiLoginIsBanned = 12, -- 多次封禁 +} + + +local NEW_PLAYER_FLAG = 1 << 0 +local SinceStartupTime = function() return CS.UnityEngine.Time.realtimeSinceStartup end +local SinceStartupMilliSeconds = function() return math.floor(CS.UnityEngine.Time.realtimeSinceStartup * 1000) end + +local TableLoginErrCode = "Share/Login/LoginCode.tab" +local LoginErrCodeTemplate + +-- 登陆token缓存 +local LoginTokenCache + +local UI_LOGIN = "UiLogin" +local LoginCb +local IsConnected = false +local IsLogin = false +local FirstOpenMainUi = false --首次登陆成功打开主界面 +local StartGuide = false --首次进入主界面播放完成动画后才能开始引导 +local LimitLoginQuiz = {} +local HeartbeatInterval = CS.XGame.Config:GetInt("HeartbeatInterval") +local HeartbeatTimeout = CS.XGame.Config:GetInt("HeartbeatTimeout") +local HeartbeatTimer +local MaxDisconnectTime = CS.XGame.Config:GetInt("MaxDisconnectTime") --最大断线重连时间(服务器保留时间) +local ReconnectInterval = CS.XGame.Config:GetInt("ReconnectInterval") --重连间隔 +local DelayReconnectTime = CS.XGame.Config:GetInt("DelayReconnectTime") --延迟重连时间 + +local GateHandshakeTimer +local ReconnectTimer +local MaxReconnectTimer + +local LoginTimeOutSecond = CS.XGame.Config:GetInt("LoginTimeOutInterval") +local LoginTimeOutInterval = LoginTimeOutSecond * 1000 +local LoginTimeOutTimer +local LoginNetworkError = CS.XTextManager.GetText("LoginNetworkError") +local LoginHttpError = CS.XTextManager.GetText("LoginHttpError") + +local RetryLoginCount = 0 +local RETRY_LOGIN_MAX_COUNT = 3 + +-- 声明local方法 +local DoReconnect +local DelayReconnect +local StartReconnect +local DoDisconnect +-- local CreateKcpSession +-- local DoKcpHeartbeat +local DoMtpLogin --腾讯反外挂 + +local PingInterval = 1 * 60 * 1000 +local PingDelay = 30 * 1000 + +local TcpPingTimer +local StartTcpPingGate = function() + if TcpPingTimer then + XScheduleManager.UnSchedule(TcpPingTimer) + end + TcpPingTimer = XScheduleManager.ScheduleForever(function() + CS.XNetTool.PingGateTcp() + end, PingInterval, PingDelay) +end + +local ConnectGate = function(cb, bReconnect) + cb = cb or function() + end + + if IsConnected then + cb() + return + end + + local args = {} + args.ConnectCb = function() + --BDC + CS.XHeroBdcAgent.BdcServiceState(XServerManager.Id, "1") + CS.XHeroBdcAgent.IntoGameTimeStart = CS.UnityEngine.Time.time + IsConnected = true + cb() + end + args.DisconnectCb = function() + IsConnected = false + -- IsRehandedKcp = false + if LoginCb then + LoginCb(XCode.Fail) + LoginCb = nil + end + end + args.ReconnectRequestFrequentlyCb = function() + DelayReconnect() + end + args.RemoteDisconnectCb = function() + DoReconnect() + end + args.ErrorCb = function(err) + --BDC + CS.XHeroBdcAgent.BdcServiceState(XServerManager.Id, "2") + if err and (err ~= CS.System.Net.Sockets.SocketError.Success and err ~= CS.System.Net.Sockets.SocketError.OperationAborted) then + local errStr = tostring(err:ToString()) + XLog.Warning("XNetwork.ConnectGateServer error. ============ SocketError." .. errStr) + local msgtab = {} + msgtab["error"] = errStr; + local jsonStr = Json.encode(msgtab); + CS.XRecord.Record(msgtab, "24013", "ConnectGateSeverSocketError") + if LoginCb then + XLuaUiManager.ClearAnimationMask() + XUiManager.SystemDialogTip(CS.XTextManager.GetText("TipTitle"), CS.XTextManager.GetText("NetworkError"), XUiManager.DialogType.OnlySure, nil, nil) + LoginCb(XCode.Fail) + LoginCb = nil + end + end + end + args.MsgErrorCb = function() + if ReconnectTimer then + XScheduleManager.UnSchedule(ReconnectTimer) + end + if MaxReconnectTimer then + XScheduleManager.UnSchedule(MaxReconnectTimer) + end + DoDisconnect() + end + args.IsReconnect = bReconnect + args.RemoveHandshakeTimerCb = function() + if GateHandshakeTimer then + XScheduleManager.UnSchedule(GateHandshakeTimer) + end + end + + XNetwork.ConnectGateServer(args) +end + +local Disconnect = function(bLogout) + if HeartbeatTimer then + XScheduleManager.UnSchedule(HeartbeatTimer) + HeartbeatTimer = nil + end + + CS.XNetwork.Disconnect() + IsConnected = false + + if bLogout then + IsLogin = false + end + + if LoginCb then + LoginCb(XCode.Fail) + LoginCb = nil + end + + XEventManager.DispatchEvent(XEventId.EVENT_NETWORK_DISCONNECT) +end + +DoDisconnect = function() + Disconnect(true) + + if LoginTimeOutTimer then + XScheduleManager.UnSchedule(LoginTimeOutTimer) + LoginTimeOutTimer = nil + end + + if GateHandshakeTimer then + XScheduleManager.UnSchedule(GateHandshakeTimer) + GateHandshakeTimer = nil + end + + if MaxReconnectTimer then + XScheduleManager.UnSchedule(MaxReconnectTimer) + MaxReconnectTimer = nil + end + + if TcpPingTimer then + XScheduleManager.UnSchedule(TcpPingTimer) + TcpPingTimer = nil + end + + XLuaUiManager.ClearAllMask(true) + CS.XRecord.Record("24014", "SocketDisconnect") + local function BackToLogin() + if CS.XFight.Instance ~= nil then + CS.XFight.ClearFight() + end + if XDataCenter.MovieManager then + XDataCenter.MovieManager.StopMovie() + end + CS.Movie.XMovieManager.Instance:Clear() + CsXUiManager.Instance:Clear() + XHomeSceneManager.LeaveScene() + CsXUiManager.Instance:Open(UI_LOGIN) + end + if XDataCenter.FunctionEventManager.CheckFuncDisable() then + BackToLogin() + else + XUiManager.SystemDialogTip(CS.XTextManager.GetText("TipTitle"), CS.XTextManager.GetText("HeartbeatTimeout"), XUiManager.DialogType.OnlySure, nil, BackToLogin) + end +end +XLoginManager.DoDisconnect = DoDisconnect + +local DoHeartbeat +DoHeartbeat = function() + if not IsLogin then + return + end + + HeartbeatTimer = XScheduleManager.ScheduleOnce(function() + -- if CS.XNetwork.IsShowNetLog then + XLog.Debug("tcp heartbeat time out.") + -- end + + StartReconnect() + end, HeartbeatTimeout) + + local reqTime = SinceStartupTime() + if CS.XNetwork.IsShowNetLog then + XLog.Debug("tcp heartbeat request.") + end + XNetwork.Call("HeartbeatRequest", nil, function(res) + XTime.SyncTime(res.UtcServerTime, reqTime, SinceStartupTime()) + XScheduleManager.UnSchedule(HeartbeatTimer) + if CS.XNetwork.IsShowNetLog then + XLog.Debug("tcp heartbeat response.") + end + HeartbeatTimer = XScheduleManager.ScheduleOnce(function() + DoHeartbeat() + end, HeartbeatInterval) + end) +end + +function TestReconnect() + StartReconnect() +end + +StartReconnect = function() + CS.XRecord.Record("24033", "StartReconnect"); + local startReconnectTime = SinceStartupTime() + + if MaxReconnectTimer then + XScheduleManager.UnSchedule(MaxReconnectTimer) + MaxReconnectTimer = nil + end + + MaxReconnectTimer = XScheduleManager.ScheduleForever(function() + if SinceStartupTime() - startReconnectTime > MaxDisconnectTime then + if CS.XNetwork.IsShowNetLog then + XLog.Debug("超过服务器保留最长时间") + end + if HeartbeatTimer then + XScheduleManager.UnSchedule(HeartbeatTimer) + HeartbeatTimer = nil + end + XScheduleManager.UnSchedule(MaxReconnectTimer) + DoDisconnect() + end + end, 1000) + DoReconnect() +end + +DelayReconnect = function() + if CS.XNetwork.IsShowNetLog then + XLog.Debug("重连频繁异常,延后再重连.") + end + + if ReconnectTimer then + XScheduleManager.UnSchedule(ReconnectTimer) + end + + ReconnectTimer = XScheduleManager.ScheduleOnce(function() + CS.XNetwork.Disconnect() + DoReconnect() + end, DelayReconnectTime) +end + +-- 断线重连方法 +DoReconnect = function() + if not IsLogin then + Disconnect(true) + return + end + + if not XUserManager.ReconnectedToken then + DoDisconnect() + return + end + + ReconnectTimer = XScheduleManager.ScheduleOnce(function() + -- if CS.XNetwork.IsShowNetLog then + XLog.Debug("断线重连响应超时") + -- end + CS.XNetwork.Disconnect() + DoReconnect() + end, ReconnectInterval) + + if CS.XNetwork.IsShowNetLog then + XLog.Debug("开始断线重连...") + end + Disconnect(false) + --重连网关 + ConnectGate(function() + XScheduleManager.UnSchedule(ReconnectTimer) + -- if CS.XNetwork.IsShowNetLog then + XLog.Debug("reconnect, then request heart beat.") + -- end + if MaxReconnectTimer then + XScheduleManager.UnSchedule(MaxReconnectTimer) + MaxReconnectTimer = nil + end + DoMtpLogin(XUserManager.UserId, XUserManager.UserName) + DoHeartbeat() + end, true) +end + +DoMtpLogin = function(uid, username) + CS.XMtp.Login(uid, username) +end + +local OnLoginSuccess = function() + CS.XRecord.Record("24018", "OnLoginSuccess") + IsLogin = true + if CS.XNetwork.IsShowNetLog then + XLog.Debug("login success, then request heart beat.") + end + DoMtpLogin(XUserManager.UserId, XUserManager.UserName) + DoHeartbeat() + StartTcpPingGate() + XEventManager.DispatchEvent(XEventId.EVENT_LOGIN_SUCCESS) +end + +-- KCP心跳 +DoKcpHeartbeat = function() + if not IsKcpConnected then + return + end + + KcpHeartbeatTimer = CS.XScheduleManager.Schedule(function() + if not IsKcpConnected then + return + end + + -- if CS.XNetwork.IsShowNetLog then + XLog.Debug("kcp heartbeat time out.") + -- end + + if HeartbeatTimer then + CS.XScheduleManager.UnSchedule(HeartbeatTimer) + HeartbeatTimer = nil + end + + StartReconnect() + end, KcpHeartbeatTimeout, 1) + + if CS.XNetwork.IsShowNetLog then + XLog.Debug("kcp heartbeat request.") + end + XNetwork.CallKcp("KcpHeartbeatRequest", nil, function() + if CS.XNetwork.IsShowNetLog then + XLog.Debug("kcp heartbeat response.") + end + if KcpHeartbeatTimer then + CS.XScheduleManager.UnSchedule(KcpHeartbeatTimer) + KcpHeartbeatTimer = nil + end + + KcpHeartbeatTimer = CS.XScheduleManager.Schedule(function() + DoKcpHeartbeat() + end, KcpHeartbeatInterval, 1) + end) +end + +-- 创建KCP会话 +CreateKcpSession = function(ip, port, remoteConv) + --XLog.Debug("create kcp session. ip=" .. tostring(ip) .. ", port=" .. tostring(port) .. ", remoteConv=" .. tostring(remoteConv)) + IsKcpConnected = false + CS.XNetwork.CreateUdpSession() + CS.XNetwork.UdpConnect(ip, port) + CS.XNetwork.CreateKcpSession(remoteConv) + -- RemoteKcpConv = remoteConv + + if KcpHeartbeatTimer then + CS.XScheduleManager.UnSchedule(KcpHeartbeatTimer) + KcpHeartbeatTimer = nil + end + + if CS.XNetwork.IsShowNetLog then + XLog.Debug("kcp connect request.") + end + + local tryCount = 0 + CS.XNetwork.KcpConnectRequest(remoteConv) + KcpHeartbeatTimer = CS.XScheduleManager.Schedule(function() + if not IsKcpConnected then + if tryCount >= RetryKcpConnectCount then + if not IsRehandedKcp then + IsRehandedKcp = true + --XNetwork.ConnectKcp(CreateKcpSession) + end + return + end + + tryCount = tryCount + 1 + if CS.XNetwork.IsShowNetLog then + XLog.Debug("kcp connect request retry.") + end + CS.XNetwork.KcpConnectRequest(remoteConv) + end + end, KcpConnectRequestInterval, 0) + + StartKcpPingGate() +end + +local OnLogin = function(errCode) + if LoginTimeOutTimer then + XScheduleManager.UnSchedule(LoginTimeOutTimer) + end + + if not errCode or errCode == XCode.Success then + OnLoginSuccess() + else + CS.XRecord.Record("24015", "OnLoginError") + end + if LoginCb then + LoginCb(errCode) + LoginCb = nil + end +end + +local DoLoginTimeOut = function(cb) + Disconnect(true) + XLuaUiManager.ClearAnimationMask() + CS.XRecord.Record("24016", "DoLoginTimeOut") + XUiManager.SystemDialogTip(CS.XTextManager.GetText("TipTitle"), CS.XTextManager.GetText("LoginTimeOut"), XUiManager.DialogType.Normal, function() + OnLogin(XCode.Fail) + end, function() + XLoginManager.Login(cb) + end) +end + +local DoLogin +DoLogin = function(cb) + -- if XUserManager.Channel == nil or + -- XUserManager.UserId == nil then + -- return + -- end + + local loginUrl = XServerManager.GetLoginUrl() .. + "?loginType=" .. XUserManager.Channel .. + "&userId=" .. XUserManager.UserId .. + "&token=" .. (XUserManager.Token or "") .. + "&clientIp=" .. XLoginManager.ExIP + + --测试高防地址响应速度 + local beforeLoginTime = math.floor(CS.UnityEngine.Time.time * 1000); + XLog.Debug("准备访问地址" .. XServerManager.GetLoginUrl() .. ", 当前时间(毫秒):" .. beforeLoginTime); + + local request = CS.UnityEngine.Networking.UnityWebRequest.Get(loginUrl) + request.timeout = LoginTimeOutSecond + CS.XRecord.Record("24009", "RequestLoginHttpSever") + -- XLuaUiManager.SetAnimationMask("RequestLoginHttpSever", true) + CS.XUiManager.Instance:SetAnimationMask(true); + CS.XTool.WaitNativeCoroutine(request:SendWebRequest(), function() + if request.isNetworkError then + XLog.Error("login network error,url is " .. loginUrl .. ", message is " .. request.error) + -- XLuaUiManager.SetAnimationMask("RequestLoginHttpSever", false) + XLuaUiManager.ClearAnimationMask() + XUiManager.SystemDialogTip("", LoginNetworkError, XUiManager.DialogType.OnlySure, nil, function() + if LoginCb then + LoginCb(XCode.Fail) + LoginCb = nil + end + end) + CS.XRecord.Record("24010", "RequestLoginHttpSeverNetWorkError") + return + end + + if request.isHttpError then + XLog.Error("login http error,url is " .. loginUrl .. ", message is " .. request.error) + XLuaUiManager.SetAnimationMask("RequestLoginHttpSever", false) + XLuaUiManager.ClearAnimationMask() + XUiManager.SystemDialogTip("", LoginHttpError, XUiManager.DialogType.OnlySure, nil, function() + if LoginCb then + LoginCb(XCode.Fail) + LoginCb = nil + end + end) + CS.XRecord.Record("24011", "RequestLoginHttpSeverHttpError") + return + end + + local result = Json.decode(request.downloadHandler.text) + if result.code ~= RetCode.Success then + local tipMsg + + if result.code == RetCode.ErrServerMaintaining then + tipMsg = result.msg + elseif result.code == RetCode.FirstLoginIsBanned or result.code == RetCode.MultiLoginIsBanned then + local template = LoginErrCodeTemplate[result.code] + local timeStr = os.date("%Y-%m-%d %H:%M:%S", result.loginLockTime) + tipMsg = string.format(template.Msg, result.playerId, result.reason, timeStr) + else + local template = LoginErrCodeTemplate[result.code] + if template then + tipMsg = template.Msg + else + tipMsg = "login errCode is " .. result.code + end + end + + -- XLuaUiManager.SetAnimationMask("RequestLoginHttpSever", false) + XLuaUiManager.ClearAnimationMask() + XLuaUiManager.Open("UiAssertDialog", "", tipMsg, nil, nil, function() + if LoginCb then + LoginCb(XCode.Fail) + LoginCb = nil + end + end) + CS.XRecord.Record("24012", "RequestLoginHttpSeverLoginError") + return + end + + -- XLuaUiManager.SetAnimationMask("RequestLoginHttpSever", false) + CS.XUiManager.Instance:SetAnimationMask(false); + CS.XRecord.Record("24031", "RequestLoginHttpSeverLoginSuccess") + + local afterLoginTime = math.floor(CS.UnityEngine.Time.time * 1000); + XLog.Debug("高防地址返回成功, 当前时间(毫秒):" .. afterLoginTime .. "共用时:" .. (afterLoginTime - beforeLoginTime) .. "ms"); + + if cb then + cb(result.token, result.ip, result.host, result.port) + end + + request:Dispose() + end) +end + +local DoLoginGame +DoLoginGame = function(cb) + if LoginTimeOutTimer then + XScheduleManager.UnSchedule(LoginTimeOutTimer) + end + + LoginTimeOutTimer = XScheduleManager.ScheduleOnce(function() + DoLoginTimeOut(cb) + end, LoginTimeOutInterval) + + XLog.Debug("login platform is " .. XUserManager.Platform) + + local reqTime = SinceStartupTime() + -- local ServerBean = CS.XHeroBdcAgent.GetServerBean() + local serverBeanStr = CS.XHeroBdcAgent.GetServerBeanStr(); + XNetwork.Call("LoginRequest", { + LoginType = XUserManager.Channel, + LoginPlatform = XUserManager.Platform, + UserId = XUserManager.UserId, + -- ProjectId = CS.XHeroSdkAgent.GetAppProjectId(), + Token = LoginTokenCache, + DeviceId = CS.XHeroBdcAgent.GetDeviceId(), + -- OaId = CS.XHeroSdkAgent.OAID, + ClientVersion = CS.XRemoteConfig.DocumentVersion, + ServerBean = serverBeanStr, + }, function(res) + if res.Code ~= XCode.Success then + --BDC + CS.XHeroBdcAgent.BdcRoleLogin("2", CS.XTextManager.GetCodeText(res.Code)) + if res.Code == XCode.LoginServiceRetry and RetryLoginCount < RETRY_LOGIN_MAX_COUNT then + RetryLoginCount = RetryLoginCount + 1 + local msgtab = {} + msgtab["retry_login_count"] = tostring(RetryLoginCount) + CS.XRecord.Record(msgtab, "24017", "DoLoginGameRequestError") + DoLoginGame(cb) + else + local msgtab = {} + msgtab["retry_login_count"] = tostring(RetryLoginCount) + CS.XRecord.Record(msgtab, "24017", "DoLoginGameRequestError") + RetryLoginCount = 0 + XLuaUiManager.ClearAnimationMask() + XUiManager.SystemDialogTip("", CS.XTextManager.GetCodeText(res.Code), XUiManager.DialogType.OnlySure, nil, function() + OnLogin(res.Code) + end) + end + else + --BDC + CS.XDateUtil.SetGameTimeZone(res.UtcOffset) + -- XHgSdkManager.setServerBeanTmp(ServerBean) + if res.UtcServerTime and res.UtcServerTime ~= 0 then + XTime.SyncTime(res.UtcServerTime, reqTime, SinceStartupTime()) + else + XLog.Error("XNetwork.Call(LoginRequest) Error, UtcServerTime = " .. res.UtcServerTime) + end + CS.XHeroBdcAgent.BdcRoleLogin("1", "") + RetryLoginCount = 0 + XUserManager.ReconnectedToken = res.ReconnectToken + CS.XRecord.Record("24021", "LoginRequestSuccess") + end + end) +end + +function XLoginManager.IsFirstOpenMainUi() + return FirstOpenMainUi +end + +function XLoginManager.IsStartGuide() + return StartGuide +end + +function XLoginManager.SetStartGuide(v) + StartGuide = v +end + +function XLoginManager.SetFirstOpenMainUi(flag) + FirstOpenMainUi = flag +end + +function XLoginManager.IsLogin() + return IsLogin +end + +function XLoginManager.Login(cb) + CS.XRecord.Record("24007", "InvokeLoginStart") + XLoginManager.ExIP = XDataCenter.NoticeManager.GetIp() + CS.XDateUtil.SetGameTimeZone(0) --英文服特殊处理,强行把时区设置为零时区,防止在manager初始化时使用本地时区初始化时间戳 + XDataCenter.Init() + + LoginCb = cb + + DoLogin(function(loginToken, ip, host, port) + XLog.Debug(loginToken, ip, host, port) + if host then + XLog.Debug(host) + local address = CS.System.Net.Dns.GetHostAddresses(host) + XTool.LoopArray(address, function(v) + if v.AddressFamily == CS.System.Net.Sockets.AddressFamily.InterNetwork then + ip = v:ToString() + end + end) + end + + XLog.Debug(loginToken, ip, port) + XNetwork.SetGateAddress(ip, port) + LoginTokenCache = loginToken + + ---- 网关已连接,且与上次登录服务器相同 + if IsConnected and not XNetwork.CheckIsChangedGate() then + DoLoginGame(cb) + return + end + + ---- 网关已连接,切换了服务器 + if IsConnected then + CS.XNetwork.Disconnect() + IsConnected = false + end + + if GateHandshakeTimer then + XScheduleManager.UnSchedule(GateHandshakeTimer) + end + + GateHandshakeTimer = XScheduleManager.ScheduleOnce(function() + CS.XRecord.Record("24008", "GateHandShakeTimeOut") + DoLoginTimeOut(cb) + end, LoginTimeOutInterval) + + ConnectGate(function() + DoLoginGame(cb) + end, false) + end) +end + +local OnCreateRole = function() + XEventManager.DispatchEvent(XEventId.EVENT_NEW_PLAYER) +end + +local function InitLimitLoginData(data) + if data then + LimitLoginQuiz = data.Quizs + else + LimitLoginQuiz = nil + end +end + +XRpc.NotifyLogin = function(data) + CS.XRecord.Record("24022", "NotifyLogin") + local loginProfiler = CS.XProfiler.Create("NotifyLogin") + loginProfiler:Start() + + local playerProfiler = loginProfiler:CreateChild("XPlayer") + playerProfiler:Start() + XPlayer.Init(data.PlayerData) + playerProfiler:Stop() + + local itemProfiler = loginProfiler:CreateChild("ItemManager") + itemProfiler:Start() + XDataCenter.ItemManager.InitItemData(data.ItemList) + XDataCenter.ItemManager.InitItemRecycle(data.ItemRecycleDict) + XDataCenter.ItemManager.InitBatchItemRecycle(data.BatchItemRecycle) + itemProfiler:Stop() + + local characterProfiler = loginProfiler:CreateChild("CharacterManager") + characterProfiler:Start() + XDataCenter.CharacterManager.InitCharacters(data.CharacterList) + characterProfiler:Stop() + + local equipProfiler = loginProfiler:CreateChild("EquipManager") + equipProfiler:Start() + XDataCenter.EquipManager.InitEquipData(data.EquipList) + equipProfiler:Stop() + + local fashionProfiler = loginProfiler:CreateChild("FashionManager") + fashionProfiler:Start() + XDataCenter.FashionManager.InitFashions(data.FashionList) + fashionProfiler:Stop() + + local baseEquipProfiler = loginProfiler:CreateChild("BaseEquipManager") + baseEquipProfiler:Start() + XDataCenter.BaseEquipManager.InitLoginData(data.BaseEquipLoginData) + baseEquipProfiler:Stop() + + local fubenAssignProfiler = loginProfiler:CreateChild("FubenAssignManager") + fubenAssignProfiler:Start() + XDataCenter.FubenAssignManager.InitServerData(data.AssignChapterRecord) + fubenAssignProfiler:Stop() + + local fubenProfiler = loginProfiler:CreateChild("FubenManager") + fubenProfiler:Start() + XDataCenter.FubenManager.InitFubenData(data.FubenData) + fubenProfiler:Stop() + + local fubenMailLineProfiler = loginProfiler:CreateChild("FubenMainLineManager") + fubenMailLineProfiler:Start() + XDataCenter.FubenMainLineManager.InitFubenMainLineData(data.FubenMainLineData) + fubenMailLineProfiler:Stop() + + local fubenExtraChapterProfiler = loginProfiler:CreateChild("FubenExtraChapterManager") + fubenExtraChapterProfiler:Start() + XDataCenter.ExtraChapterManager.InitExtraInfos(data.FubenChapterExtraLoginData) + fubenExtraChapterProfiler:Stop() + + local fubenDailyProfiler = loginProfiler:CreateChild("FubenDailyManager") + fubenDailyProfiler:Start() + XDataCenter.FubenDailyManager.InitFubenDailyData(data.FubenDailyData) + fubenDailyProfiler:Stop() + + local fubenUrgentEventProfiler = loginProfiler:CreateChild("FubenUrgentEventManager") + fubenUrgentEventProfiler:Start() + XDataCenter.FubenUrgentEventManager.InitData(data.FubenUrgentEventData) + fubenUrgentEventProfiler:Stop() + + local autoFightProfiler = loginProfiler:CreateChild("AutoFightManager") + autoFightProfiler:Start() + XDataCenter.AutoFightManager.InitAutoFightData(data.AutoFightRecords) + autoFightProfiler:Stop() + + local teamProfiler = loginProfiler:CreateChild("TeamManager") + teamProfiler:Start() + XDataCenter.TeamManager.InitTeamGroupData(data.TeamGroupData) + XDataCenter.TeamManager.InitTeamPrefabData(data.TeamPrefabData) + teamProfiler:Stop() + + local guildProfiler = loginProfiler:CreateChild("GuideManager") + guildProfiler:Start() + XDataCenter.GuideManager.InitGuideData(data.PlayerData.GuideData) + guildProfiler:Stop() + + local functionOpenProfiler = loginProfiler:CreateChild("FunctionManager") + functionOpenProfiler:Start() + XFunctionManager.InitShieldFuncData(data.PlayerData.ShieldFuncList) + XFunctionManager.InitFuncOpenTime(data.TimeLimitCtrlConfigList) + functionOpenProfiler:Stop() + + local shareConfigProfiler = loginProfiler:CreateChild("PhotographManager") + shareConfigProfiler:Start() + XDataCenter.PhotographManager.InitSharePlatform(data.SharePlatformConfigList) + shareConfigProfiler:Stop() + + local signInProfiler = loginProfiler:CreateChild("SignInManager") + signInProfiler:Start() + XDataCenter.SignInManager.InitData(data.SignInfos) + signInProfiler:Stop() + + local fubenAssignProfiler2 = loginProfiler:CreateChild("FubenAssignManager") + fubenAssignProfiler2:Start() + XDataCenter.FubenAssignManager.UpdateChapterRecords(data.AssignChapterRecord) + fubenAssignProfiler2:Stop() + + local headPortraitProfiler = loginProfiler:CreateChild("headPortraitProfiler") + headPortraitProfiler:Start() + XDataCenter.HeadPortraitManager.AsyncHeadPortraitInfos(data.HeadPortraitList, false) + headPortraitProfiler:Stop() + + XDataCenter.WeaponFashionManager.InitWeaponFashions(data.WeaponFashionList) + + XDataCenter.PartnerManager.UpdatePartnerEntity(data.PartnerList) + --BDC + CS.XHeroBdcAgent.RoleId = data.PlayerData.Id + CS.XHeroBdcAgent.RoleKey = data.PlayerData.ServerId .. "_" .. data.PlayerData.Id + CS.XHeroBdcAgent.ServerId = data.PlayerData.ServerId + local balance = XDataCenter.ItemManager.GetCount(XDataCenter.ItemManager.ItemId.ActionPoint) + local hongka = XDataCenter.ItemManager.GetCount(XDataCenter.ItemManager.ItemId.HongKa) + local heika = XDataCenter.ItemManager.GetCount(XDataCenter.ItemManager.ItemId.FreeGem) + local luomu = XDataCenter.ItemManager.GetCount(XDataCenter.ItemManager.ItemId.Coin) + CS.XHeroBdcAgent.BdcUserInfo(data.PlayerData.Name, data.PlayerData.Level, balance, hongka, heika, luomu) + + if (data.PlayerData.Flags & NEW_PLAYER_FLAG) == NEW_PLAYER_FLAG then + -- new player + OnCreateRole() + end + --设置协议屏蔽列表 + --XNetwork.SetShieldedProtocolList(data.ShieldedProtocolList) + -- 登录答题列表 + InitLimitLoginData(data.LimitedLoginData) + XEventManager.DispatchEvent(XEventId.EVENT_LOGIN_DATA_LOAD_COMPLETE) + + local onloginProfiler = loginProfiler:CreateChild("OnLogin") + onloginProfiler:Start() + OnLogin() + onloginProfiler:Stop() + + loginProfiler:Stop() + XLog.Debug(loginProfiler); +end + +function XLoginManager.Disconnect() + Disconnect(true) +end + +function XLoginManager.Init() + LoginErrCodeTemplate = XTableManager.ReadByIntKey(TableLoginErrCode, XTable.XTableLoginCode, "ErrCode") +end + +function XLoginManager.SetUserType(usertype) + XSaveTool.SaveData(XPrefs.UserType,usertype) +end + +function XLoginManager.CleanUserType() + XSaveTool.RemoveData(XPrefs.UserType) +end +function XLoginManager.GetUserType() + return XSaveTool.GetData(XPrefs.UserType) +end + +function XLoginManager.SetUserId(uid) + XSaveTool.SaveData(XPrefs.UserId,uid) +end + +function XLoginManager.CleanUserId() + XSaveTool.RemoveData(XPrefs.UserId) +end + +function XLoginManager.GetUserId() + return XSaveTool.GetData(XPrefs.UserId) +end + +function XLoginManager.SetToken(token) + XSaveTool.SaveData(XPrefs.Token,token) +end + +function XLoginManager.CleanToken() + XSaveTool.RemoveData(XPrefs.Token) +end + +function XLoginManager.GetToken() + return XSaveTool.GetData(XPrefs.Token) +end + +function XLoginManager.SetPasswordStatus(pwdStatus) + XSaveTool.SaveData(XPrefs.PasswordStatus, pwdStatus) +end + +function XLoginManager.CleanPasswordStatus() + XSaveTool.RemoveData(XPrefs.PasswordStatus) +end + +function XLoginManager.GetPasswordStatus() + return XSaveTool.GetData(XPrefs.PasswordStatus) +end + +function XLoginManager.CheckLimitLogin() + if LimitLoginQuiz and next(LimitLoginQuiz) then + XLuaUiManager.Open("UiLoginVerification", LimitLoginQuiz) + return true + else + return false + end +end + +function XLoginManager.ClearLimitLogin() + LimitLoginQuiz = nil + XEventManager.DispatchEvent(XEventId.EVENT_FUNCTION_EVENT_COMPLETE) +end + +function XLoginManager.SendLoginVerify(quizIdx, answer, useTime, cb) + if not quizIdx or not answer then return end + XNetwork.Call("LimitedLoginVerifyRequest", {QuizIdx = quizIdx, Answer = answer, UseTime = useTime }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + cb(res.IsCorrect) + end) +end + +XRpc.ForceLogoutNotify = function(res) + Disconnect(true) + CS.XFightNetwork.Disconnect() + XScheduleManager.UnSchedule(HeartbeatTimer) + XUiManager.SystemDialogTip(CS.XTextManager.GetText("TipTitle"), CS.XTextManager.GetCodeText(res.Code), XUiManager.DialogType.OnlySure, nil, function() + if CS.XFight.Instance ~= nil then + CS.XFight.ClearFight() + end + if XDataCenter.MovieManager then + XDataCenter.MovieManager.StopMovie() + end + if XDataCenter.PokemonManager then + XDataCenter.PokemonManager.ResetSpeed() + end + CS.Movie.XMovieManager.Instance:Clear() + CsXUiManager.Instance:Clear() + XHomeSceneManager.LeaveScene() + XLuaUiManager.Open(UI_LOGIN) + end) +end + +XRpc.RpcErrorNotify = function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + end +end + +XRpc.ShutdownNotify = function(res) + XUserManager.ClearLoginData() + XUiManager.TipError(CS.XTextManager.GetText("ServerShutdown")) +end + +XRpc.LoginErrorNotify = function(res) + XUiManager.SystemDialogTip(CS.XTextManager.GetText("TipTitle"), CS.XTextManager.GetText("ServerShutdown"), XUiManager.DialogType.OnlySure, nil, function() + XUserManager.ClearLoginData() + end) +end + +local test_id = 1 +local tcp_time_table = {} +-- local kcp_time_table = {} +function XLoginManager.Test() + local i = test_id + test_id = test_id + 1 + + local tcp_time = SinceStartupMilliSeconds() + XNetwork.Call("Ping", { UtcTime = tcp_time }, function() + local delta = SinceStartupMilliSeconds() - tcp_time + + if #tcp_time_table >= 10 then + table.remove(tcp_time_table, 1) + end + table.insert(tcp_time_table, delta) + + local total = 0 + for _, v in ipairs(tcp_time_table) do + total = total + v + end + local average = total / #tcp_time_table + + XLog.Error(string.format("+++++++++++++++++++++++++++++++++ tcp ping. id = %d, delta = %d, average = %s", i, delta, tostring(average))) + end) +end + +XLoginManager.SDKAccountStatus = { + Normal = 0, -- 正常账号 + Cancellation = 1, -- 注销中账号 +} +local CurSDKAccountStatus = 0 + +function XLoginManager.GetSDKAccountStatus() + XLog.Debug("获取SDK账号注销状态:"..tostring(CurSDKAccountStatus)) + return CurSDKAccountStatus +end + +function XLoginManager.SetSDKAccountStatus(status) + XLog.Debug("设置SDK账号注销状态:"..tostring(status)) + CurSDKAccountStatus = status +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XLottoManager.lua b/Resources/Scripts/XManager/XLottoManager.lua new file mode 100644 index 00000000..e6bdb6f8 --- /dev/null +++ b/Resources/Scripts/XManager/XLottoManager.lua @@ -0,0 +1,108 @@ +XLottoManagerCreator = function() + local XLottoGroupEntity = require("XEntity/XLotto/XLottoGroupEntity") + local XLottoManager = {} + local GET_LOTTO_DATA_INTERVAL = 10 + local LastGetLottoRewardInfoTimes = 0 + local LottoGroupDataDic = {} + + local METHOD_NAME = { + LottoInfoRequest = "LottoInfoRequest", + LottoRequest = "LottoRequest", + LottoBuyTicketRequest = "LottoBuyTicketRequest", + } + + function XLottoManager.Init() + + end + + function XLottoManager.GetLottoGroupDataList() + local list = {} + for _,groupData in pairs(LottoGroupDataDic or {}) do + table.insert(list,groupData) + end + + table.sort(list, function (a, b) + return a:GetPriority() < b:GetPriority() + end) + + return list + end + + function XLottoManager.UpdateLottoGroupData(lottoDrawInfoList) + local tmpInfoList = {} + LottoGroupDataDic = {} + for _,drawInfo in pairs(lottoDrawInfoList or {}) do + local drawCfg = XLottoConfigs.GetLottoCfgById(drawInfo.Id) + if drawCfg then + LottoGroupDataDic[drawCfg.LottoGroupId] = LottoGroupDataDic[drawCfg.LottoGroupId] or XLottoGroupEntity.New(drawCfg.LottoGroupId) + tmpInfoList[drawCfg.LottoGroupId] = tmpInfoList[drawCfg.LottoGroupId] or {} + table.insert(tmpInfoList[drawCfg.LottoGroupId],drawInfo) + end + end + + for groupId,infoList in pairs(tmpInfoList or {}) do + table.sort(infoList, function (a, b) + return a.Priority < b.Priority + end) + LottoGroupDataDic[groupId]:UpdateData({DrawInfoList = infoList}) + end + end + + function XLottoManager.UpdateLottoDrawData(lottoDrawId, data) + local drawCfg = XLottoConfigs.GetLottoCfgById(lottoDrawId) + if drawCfg then + local drawData = LottoGroupDataDic[drawCfg.LottoGroupId]:GetDrawData() + local rewardList = drawData:GetLottoRewardList() + table.insert(rewardList, data.LottoRewardId) + local tmpData = {} + tmpData.ExtraRewardState = data.ExtraRewardState + tmpData.LottoRecords = data.LottoRecords + tmpData.LottoRewards = rewardList + drawData:UpdateData(tmpData) + end + end + + function XLottoManager.GetLottoRewardInfoRequest(cb) + local now = XTime.GetServerNowTimestamp() + if LastGetLottoRewardInfoTimes and now - LastGetLottoRewardInfoTimes <= GET_LOTTO_DATA_INTERVAL then + if cb then cb() end + return + end + XNetwork.Call(METHOD_NAME.LottoInfoRequest, {}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + if cb then cb() end + return + end + XLottoManager.UpdateLottoGroupData(res.LottoInfos) + LastGetLottoRewardInfoTimes = XTime.GetServerNowTimestamp() + if cb then cb() end + end) + end + + function XLottoManager.DoLotto(lottoId, cb, errorCb) + XNetwork.Call(METHOD_NAME.LottoRequest, { Id = lottoId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + if errorCb then errorCb() end + return + end + XLottoManager.UpdateLottoDrawData(lottoId, res) + if cb then cb(res.RewardList, res.ExtraRewardList) end + end) + end + + function XLottoManager.BuyTicket(lottoId, BuyTicketRuleId, ticketKey, cb) + XNetwork.Call(METHOD_NAME.LottoBuyTicketRequest, { LottoId = lottoId, TicketId = BuyTicketRuleId, TicketKey = ticketKey}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + local reward = XRewardManager.CreateRewardGoodsByTemplate({ TemplateId = res.ItemId, Count = res.ItemCount }) + if cb then cb({reward}) end + end) + end + + XLottoManager.Init() + return XLottoManager +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XLuaUiManager.lua b/Resources/Scripts/XManager/XLuaUiManager.lua new file mode 100644 index 00000000..5b0695a2 --- /dev/null +++ b/Resources/Scripts/XManager/XLuaUiManager.lua @@ -0,0 +1,612 @@ +------------------------------------------------------------------------------------------------------------- +CsXUiType = CS.XUiType +-- CsXUiResType = CS.XUiResType +CsXUiManager = CS.XUiManager +-- CsIBaseEventListener = CS.IBaseEventListener +CsXGameEventManager = CS.XGameEventManager +-- CsXLuaEventProxy = CS.XLuaEventProxy +-- CsXUi = CS.XUi +-- CsXChildUi = CS.XChildUi +-- CsXGameUi = CS.XGameUi +-- CsXMaskManager = CS.XMaskManager +-- CsXUguiEventListener = CS.XUguiEventListener +-- CsXUiData = CS.XUiData +-- CsXUiStackContainer = CS.XUiStackContainer +-- CsXUiListContainer = CS.XUiListContainer +-- CsXUiChildContainer = CS.XUiChildContainer +CsXUiHelper = CS.XUiHelper +CsXTextManagerGetText = CS.XTextManager.GetText +CSXTextManagerGetText = CsXTextManagerGetText +------------------------------------------------LuaUI--------------------------------------------------------- +XLuaUi = XClass(nil, "XLuaUi") + +function XLuaUi:Ctor(name, uiProxy) + self.Name = name + self.UiProxy = uiProxy + self.Ui = uiProxy.Ui + -- 页面自动关闭时间id + self.AutoCloseTimerId = nil + self.OpenAutoClose = false + self.AutoCloseEndTime = 0 + self.AutoCloseCallback = nil + self.AutoCloseIntervalTime = nil + self.AutoCloseDelayTime = nil +end + +-- PS:如果页面重写了OnEnable和OnDisable,使用时必须在OnEnable和OnDisable调用下父类方法 +-- XXX.Super.OnEnable(self) +-- interval : 间隔多少毫秒执行,默认是一秒 +-- delay : 初次延迟多少毫秒执行,默认是一秒 +function XLuaUi:SetAutoCloseInfo(endTime, callback, interval, delay) + interval = interval or XScheduleManager.SECOND + delay = delay or XScheduleManager.SECOND + self.OpenAutoClose = true + self.AutoCloseEndTime = endTime + self.AutoCloseCallback = callback + self.AutoCloseIntervalTime = interval + self.AutoCloseDelayTime = delay +end + +function XLuaUi:SetGameObject() + self.Transform = self.Ui.Transform + self.GameObject = self.Ui.GameObject + self.UiAnimation = self.Ui.UiAnimation + self.UiSceneInfo = self.Ui.UiSceneInfo + self.UiModelGo = self.Ui.UiModelGo + self.UiModel = self.Ui.UiModel + self:InitUiObjects() +end + +function XLuaUi:OnAwake() +end + +function XLuaUi:OnStart() +end + +function XLuaUi:OnEnable() + if self.OpenAutoClose then + self:_StartAutoCloseTimer() + end +end + +function XLuaUi:OnDisable() + if self.OpenAutoClose then + self:_StopAutoCloseTimer() + end +end + +function XLuaUi:OnDestroy() +end + +function XLuaUi:_StartAutoCloseTimer() + self.AutoCloseTimerId = XScheduleManager.ScheduleForever(function() + local time = XTime.GetServerNowTimestamp() + if time > self.AutoCloseEndTime then + if self.AutoCloseCallback then + self.AutoCloseCallback(true) + end + self:_StopAutoCloseTimer() + else + if self.AutoCloseCallback then + self.AutoCloseCallback(false) + end + end + -- PS:-1 * self.AutoCloseIntervalTime 这么处理是因为XScheduleManager.ScheduleForever里计算时间自动叠加多一次Interval + end, self.AutoCloseIntervalTime, self.AutoCloseDelayTime + -1 * self.AutoCloseIntervalTime) +end + +function XLuaUi:_StopAutoCloseTimer() + if self.AutoCloseTimerId then + XScheduleManager.UnSchedule(self.AutoCloseTimerId) + self.AutoCloseTimerId = nil + end +end + +function XLuaUi:OnReleaseInstOnly() + XLuaUiManager.SetUiData(self.Name, self:OnReleaseInst()) +end + +function XLuaUi:OnReleaseInst() + +end + +function XLuaUi:OnResumeUi() + self:OnResume(XLuaUiManager.GetUiData(self.Name)) + XLuaUiManager.RemoveUiData(self.Name) +end + +function XLuaUi:OnResume() +end + +--用于释放lua的内存 +function XLuaUi:OnRelease() + + --self.Name = nil + self.UiProxy = nil + self.Ui = nil + + self.Transform = nil + self.GameObject = nil + self.UiAnimation = nil + + self.UiSceneInfo = nil + self.UiModelGo = nil + self.UiModel = nil + + if self.Obj and self.Obj:Exist() then + local nameList = self.Obj.NameList + for _, v in pairs(nameList) do + self[v] = nil + end + self.Obj = nil + end + + for k, v in pairs(self) do + local t = type(v) + if t == 'userdata' and CsXUiHelper.IsUnityObject(v) then + self[k] = nil + end + end + +end + +--CS.XEventId.EVENT_UI_ALLOWOPERATE 允许UI操作事件(可以理解为动画播放完成后的回调) +function XLuaUi:OnNotify(evt, ...) +end + +function XLuaUi:OnGetEvents() +end + +function XLuaUi:SetUiSprite(image, spriteName, callBack) + self.UiProxy:SetUiSprite(image, spriteName, callBack) +end + +--快捷隐藏界面(不建议使用) +function XLuaUi:SetActive(active) + local temp = active and true or false + self.UiProxy:SetActive(temp) +end + +--快捷关闭界面 +function XLuaUi:Close() + + if self.UiProxy == nil then + XLog.Error(self.Name .. "重复Close") + else + self.UiProxy:Close() + end + +end + +--快捷移除UI,移除的UI不会播放进场、退场动画 +--不允许用于移除栈顶的UI 使用时注意!!! +function XLuaUi:Remove() + if self.UiProxy then + self.UiProxy:Remove() + end +end + +--注册点击事件 +function XLuaUi:RegisterClickEvent(button, handle, clear) + + clear = clear and true or false + self.UiProxy:RegisterClickEvent(button, function(eventData) + if handle then + handle(self, eventData) + end + end, clear) + +end + +--返回指定名字的子节点的Component +--@name 子节点名称 +--@type Component类型 +function XLuaUi:FindComponent(name, type) + return self.UiProxy:FindComponent(name, type) +end + + +--通过名字查找GameObject 例如:A/B/C +--@name 要查找的名字 +function XLuaUi:FindGameObject(name) + return self.UiProxy:FindGameObject(name) +end + +--通过名字查找Transfrom 例如:A/B/C +--@name 要查找的名字 +function XLuaUi:FindTransform(name) + return self.UiProxy:FindTransform(name) +end + +--打开一个子UI +--@childUIName 子UI名字 +--@... 传到OnStart的参数 +function XLuaUi:OpenChildUi(childUIName, ...) + self.UiProxy:OpenChildUi(childUIName, ...) +end + +--打开一个子UI,会关闭其他已显示的子UI +--@childUIName 子UI名字 +--@... 传到OnStart的参数 +function XLuaUi:OpenOneChildUi(childUIName, ...) + self.UiProxy:OpenOneChildUi(childUIName, ...) + --self.UiProxy:OpenOneChildUi(childUIName, ...) +end + +--关闭子UI +--@childUIName 子UI名字 +function XLuaUi:CloseChildUi(childUIName) + self.UiProxy:CloseChildUi(childUIName) +end + +--查找子窗口对应的lua对象 +--@childUiName 子窗口名字 +function XLuaUi:FindChildUiObj(childUiName) + local childUi = self.UiProxy:FindChildUi(childUiName) + if childUi then + return childUi.UiProxy.UiLuaTable + end +end + +function XLuaUi:InitUiObjects() + self.Obj = self.Transform:GetComponent("UiObject") + if self.Obj ~= nil then + for i = 0, self.Obj.NameList.Count - 1 do + self[self.Obj.NameList[i]] = self.Obj.ObjList[i] + end + end +end + +function XLuaUi:InitChildUis() + if self.Ui == nil then + return + end + + if not self.Ui.UiData.HasChildUi then + return + end + + local childUis = self.Ui:GetAllChildUis() + + if childUis == nil then + return + end + + --子UI初始化完成后可在父UI通过self.Child+子UI名称的方式直接获取句柄 + local childUiName + for k, v in pairs(childUis) do + childUiName = "Child" .. k + if self[childUiName] then + XLog.Error(string.format("%s该名字已被占用", childUiName)) + else + self[childUiName] = v.UiProxy.UiLuaTable + end + end +end + +--播放动画(只支持Timeline模式) +-- 符合以下命名的动画将会自动播放,无须手动调用(AnimStart、AnimEnable、AnimDisable、AnimDestroy) +function XLuaUi:PlayAnimation(animName, callback, beginCallback, wrapMode) + self.UiProxy:PlayAnimation(animName, callback, beginCallback, wrapMode or CS.UnityEngine.Playables.DirectorWrapMode.Hold) +end + +--播放动画(只支持Timeline模式, 增加Mask阻止操作打断动画) +function XLuaUi:PlayAnimationWithMask(animName, callback, beginCallback, wrapMode) + self.UiProxy:PlayAnimation(animName, function(state) + XLuaUiManager.SetMask(false) + if callback then callback(state) end + end, function() + XLuaUiManager.SetMask(true) + if beginCallback then beginCallback() end + end, wrapMode or CS.UnityEngine.Playables.DirectorWrapMode.Hold) +end + +--获取Open传递的参数 +function XLuaUi:GetArgs() + return self.UiProxy:GetArgs() +end + +-- 加载(切换)ui场景 +function XLuaUi:LoadUiScene(sceneUrl, modelUrl, cb, force) + if force == nil then + force = true + end + self.Ui:LoadUiScene(sceneUrl, modelUrl, force) + + if cb then + cb(sceneUrl, modelUrl) + end +end + +-- 根据名字查找虚拟相机位置 +function XLuaUi:FindVirtualCamera(virtualCamName) + local virtualCamTrans = nil + local sceneVirtualCamRoot = self.UiSceneInfo.Transform:FindTransform("UiCamContainer") + if sceneVirtualCamRoot then + virtualCamTrans = sceneVirtualCamRoot:FindTransform(virtualCamName) + if virtualCamTrans then + return virtualCamTrans + end + end + + virtualCamTrans = self.UiModelGo:FindTransform(virtualCamName) + return virtualCamTrans +end + +-- 默认ui场景路径 +function XLuaUi:GetDefaultSceneUrl() + return self.Ui.UiData.SceneUrl +end + +-- 默认ui场景模型路径 +function XLuaUi:GetDefaultUiModelUrl() + return self.Ui.UiData.UiModelUrl +end + +-- 绑定帮助按钮 +function XLuaUi:BindHelpBtn(btn, helpDataKey, cb) + if not btn then + XLog.Error("XLuaUi.BindHelpBtn Error: Buttton Is Nil") + return + end + + if not helpDataKey then + XLog.Error("XLuaUi.BindHelpBtn Error: HelpDataKey Is Nil") + return + end + + if CS.XTool.ConfirmObjectType(btn, "XUiButton") then + btn.CallBack = function() XUiManager.ShowHelpTip(helpDataKey, cb) end + return + end + + if CS.XTool.ConfirmObjectType(btn, "Button") then + self:RegisterClickEvent(btn, function() XUiManager.ShowHelpTip(helpDataKey, cb) end) + return + end + + XLog.Error("XLuaUi.BindHelpBtn Faild") +end + +function XLuaUi:BindHelpBtnNew(btn, getHelpDataFunc, cb) + if not btn then + XLog.Error("XLuaUi.BindHelpBtn Error: Buttton Is Nil") + return + end + + if not getHelpDataFunc then + XLog.Error("XLuaUi.BindHelpBtn Error: GetHelpDataFunc Is Nil") + return + end + + if CS.XTool.ConfirmObjectType(btn, "XUiButton") then + btn.CallBack = function() XUiManager.ShowHelpTipNew(getHelpDataFunc, cb) end + return + end + + if CS.XTool.ConfirmObjectType(btn, "Button") then + self:RegisterClickEvent(btn, function() XUiManager.ShowHelpTipNew(getHelpDataFunc, cb) end) + return + end + + XLog.Error("XLuaUi.BindHelpBtnNew Faild") +end + +function XLuaUi:BindHelpBtnOnly(btn) + -- TODO 对帮助按钮进行统一隐藏 +end + +-- function XLuaUi:GetUiModelRoot() +-- return self.UiModel.UiModelParent +-- end +------------------------------------------------------------------------------------------------------------------------ +XLuaUiManager = XClass(nil, "XLuaUiManager") +local UiData = {} +local ClassType = {} + +--注册UI +-- @super 父类 +-- @uiName UI名字 +function XLuaUiManager.Register(super, uiName) + + super = super or XLuaUi + local uiObject = XClass(super, uiName) + ClassType[uiName] = uiObject + return uiObject + +end + +--创建一个LuaUI的实例 +--@name LuaUI脚本名字 +--@gameUI C#的GameUI +function XLuaUiManager.New(uiName, uiProxy) + + local baseName = uiName + local class = ClassType[baseName] + if not class then + baseName = string.match(baseName, '%w*[^(%d)$*]') -- 解析包含数字后缀的界面 + class = ClassType[baseName] + if not class then + XLog.Error("XLuaUiManager.New error, class not exist, name: " .. uiName) + return nil + end + end + local obj = class.New(uiName, uiProxy) + uiProxy:SetLuaTable(obj) + return obj + +end + +--打开UI +--@uiName 打开的UI名字 +function XLuaUiManager.Open(uiName, ...) + CsXUiManager.Instance:Open(uiName, ...) +end + +--打开UI,完成后执行回调 +--@uiName 打开的UI名称 +--@callback 打开完成回调 +--@... 传递到OnStart的参数 +function XLuaUiManager.OpenWithCallback(uiName, callback, ...) + CsXUiManager.Instance:OpenWithCallback(uiName, callback, ...) +end + +--关闭UI,完成后执行回调 +--@uiName 打开的UI名称 +--@callback 打开完成回调 +function XLuaUiManager.CloseWithCallback(uiName, callback) + CsXUiManager.Instance:CloseWithCallback(uiName, callback) +end + +--针对Normal类型的管理,关闭上一个界面,然后打开下一个界面(无缝切换) +--@uiName 需要打开的UI名字 +--@... 传递到OnStart的参数 +function XLuaUiManager.PopThenOpen(uiName, ...) + CsXUiManager.Instance:PopThenOpen(uiName, ...) +end + +--针对Normal类型的管理,关闭栈中所有界面,然后打开下一个界面(无缝切换) +--@uiName 需要打开的UI名字 +--@... 传递到OnStart的参数 +function XLuaUiManager.PopAllThenOpen(uiName, ...) + CsXUiManager.Instance:PopAllThenOpen(uiName, ...) +end + +--关闭UI +--@uiName 关闭的UI名字(只能关闭当前显示的UI) +function XLuaUiManager.Close(uiName) + CsXUiManager.Instance:Close(uiName) +end + +--移除UI,移除的UI不会播放进场、退场动画 +--@uiName 关闭的UI名字(可以关闭非当前显示UI) +function XLuaUiManager.Remove(uiName) + CsXUiManager.Instance:Remove(uiName) +end + +--某个UI是否显示 +function XLuaUiManager.IsUiShow(uiName) + return CsXUiManager.Instance:IsUiShow(uiName) +end + +--某个UI是否已经加载 +function XLuaUiManager.IsUiLoad(uiName) + return CsXUiManager.Instance:IsUiLoad(uiName) +end + +--设置mask,visible=true时不能操作 +function XLuaUiManager.SetMask(visible) + visible = visible and true or false + CsXUiManager.Instance:SetMask(visible) +end + +--设置animationMask,tag标签,visible=true时不能操作,delay(默认2秒)后会展示菊花 +function XLuaUiManager.SetAnimationMask(tag, visible, delay) + visible = visible and true or false + CsXUiManager.Instance:SetAnimationMask(tag, visible, delay) +end + +function XLuaUiManager.ClearMask(resetMaskCount) + resetMaskCount = resetMaskCount and true or false + CsXUiManager.Instance:ClearMask(resetMaskCount) +end + +function XLuaUiManager.ClearAnimationMask() + CsXUiManager.Instance:ClearAnimationMask() +end + +function XLuaUiManager.ClearAllMask(resetMaskCount) + XLuaUiManager.ClearMask(resetMaskCount) + CsXUiManager.Instance:ClearAnimationMask() +end + +--返回主界面 +function XLuaUiManager.RunMain(notDialogTip) + if XDataCenter.RoomManager.RoomData then + if notDialogTip then + XDataCenter.RoomManager.Quit(function() + CsXUiManager.Instance:RunMain() + end) + + return + end + + -- 如果在房间中,需要先弹确认框 + local title = CsXTextManagerGetText("TipTitle") + local cancelMatchMsg + local stageId = XDataCenter.RoomManager.RoomData.StageId + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + if stageInfo.Type == XDataCenter.FubenManager.StageType.ArenaOnline then + cancelMatchMsg = CsXTextManagerGetText("ArenaOnlineInstanceQuitRoom") + else + cancelMatchMsg = CsXTextManagerGetText("OnlineInstanceQuitRoom") + end + + XUiManager.DialogTip(title, cancelMatchMsg, XUiManager.DialogType.Normal, nil, function() + XDataCenter.RoomManager.Quit(function() + CsXUiManager.Instance:RunMain() + end) + end) + elseif XDataCenter.RoomManager.Matching then + if notDialogTip then + XDataCenter.RoomManager.CancelMatch(function() + CsXUiManager.Instance:RunMain() + end) + + return + end + + local title = CsXTextManagerGetText("TipTitle") + local cancelMatchMsg = CsXTextManagerGetText("OnlineInstanceCancelMatch") + XUiManager.DialogTip(title, cancelMatchMsg, XUiManager.DialogType.Normal, nil, function() + XDataCenter.RoomManager.CancelMatch(function() + CsXUiManager.Instance:RunMain() + end) + end) + else + local unionFightData = XDataCenter.FubenUnionKillRoomManager.GetUnionRoomData() + local unionInfo = XDataCenter.FubenUnionKillManager.GetUnionKillInfo() + local inActivity = false + if unionInfo and unionInfo.Id and unionInfo.Id > 0 then + inActivity = XFubenUnionKillConfigs.UnionKillInActivity(unionInfo.Id) + end + + if inActivity and unionFightData and unionFightData.Id then + local title = CsXTextManagerGetText("TipTitle") + local cancelMatchMsg = CsXTextManagerGetText("UnionKillExitRoom") + XUiManager.DialogTip(title, cancelMatchMsg, XUiManager.DialogType.Normal, nil, function() + XDataCenter.FubenUnionKillRoomManager.LeaveUnionTeamRoom(function() + CsXUiManager.Instance:RunMain() + end) + end) + else + if XLoginManager.IsFirstOpenMainUi() then + CS.XCustomUi.Instance:GetData() + end + CsXUiManager.Instance:RunMain() + end + end +end + +function XLuaUiManager.ShowTopUi() + CsXUiManager.Instance:ShowTopUi() +end + +--获取ui状态 +function XLuaUiManager.GetUiData(uiName) + if UiData then + return UiData[uiName] + end +end + +--缓存ui状态 +function XLuaUiManager.SetUiData(uiName, data) + UiData = UiData and UiData or {} + UiData[uiName] = data +end + +function XLuaUiManager.RemoveUiData(uiName) + if UiData then + UiData[uiName] = nil + end +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XMagicSkillManager.lua b/Resources/Scripts/XManager/XMagicSkillManager.lua new file mode 100644 index 00000000..bc15b7de --- /dev/null +++ b/Resources/Scripts/XManager/XMagicSkillManager.lua @@ -0,0 +1,203 @@ +local pairs = pairs +local table = table +local tableInsert = table.insert + +XMagicSkillManager = XMagicSkillManager or {} + +local GetResonanceSkillLevelInterface +local GetSkillLevelInterfaces = {} +local GetMagicLevelInterfaces = {} +local GetBornMagicLevelInterfaces = {} + +---获取技能等级集合 +---@param npcData userdata npc数据 +---@return XCode,table 状态码和技能等级集合 +local function GetSkillLevelMap(npcData) + local levelMap = {} + + for _, inter in pairs(GetSkillLevelInterfaces) do + local code = inter(npcData, levelMap) + if code ~= XCode.Success then + return code, nil + end + end + + return XCode.Success, levelMap +end + +---获取魔法等级集合 +---@param npcData userdata npc数据 +---@return XCode,table 状态码和魔法等级集合 +local function GetMagicLevelMap(npcData) + local levelMap = {} + + for _, inter in pairs(GetMagicLevelInterfaces) do + local code = inter(npcData, levelMap) + if code ~= XCode.Success then + return code, nil + end + end + + return XCode.Success, levelMap +end + +---获取出生魔法等级集合 +---@param npcData userdata npc数据 +---@return XCode,table 状态码和出生魔法等级集合 +local function GetBornMagicLevelMap(npcData) + local levelMap = {} + + for _, inter in pairs(GetBornMagicLevelInterfaces) do + local code = inter(npcData, levelMap) + if code ~= XCode.Success then + return code, nil + end + end + + return XCode.Success, levelMap +end + +local function TryGetSkillLevelMap(npcData) + local code, levelMap = GetSkillLevelMap(npcData) + if code ~= XCode.Success then + return nil + end + + return levelMap +end + +local function TryGetMagicLevelMap(npcData) + local code, levelMap = GetMagicLevelMap(npcData) + if code ~= XCode.Success then + return nil + end + + return levelMap +end + +local function TryGetBornMagicLevelMap(npcData) + local code, levelMap = GetBornMagicLevelMap(npcData) + if code ~= XCode.Success then + return nil + end + + return levelMap +end + +function XMagicSkillManager.GetResonanceSkillLevelMap(npcData) + return GetResonanceSkillLevelInterface(npcData) +end + +function XMagicSkillManager.RegisterResonanceSkillLevelInterface(inter) + GetResonanceSkillLevelInterface = inter +end + +function XMagicSkillManager.RegisterSkillLevelInterface(inter) + tableInsert(GetSkillLevelInterfaces, inter) +end + +function XMagicSkillManager.RegisterMagicLevelInterface(inter) + tableInsert(GetMagicLevelInterfaces, inter) +end + +function XMagicSkillManager.RegisterBornMagicLevelInterface(inter) + tableInsert(GetBornMagicLevelInterfaces, inter) +end + +---------------------------------------伙伴相关---------------------------------- +local GetPartnerSkillLevelInterfaces = {} +local GetPartnerMagicLevelInterfaces = {} +local GetPartnerBornMagicLevelInterfaces = {} + +---获取技能等级集合 +local function GetPartnerSkillLevelMap(partnerData) + local levelMap = {} + + for _, inter in pairs(GetPartnerSkillLevelInterfaces) do + local code = inter(partnerData, levelMap) + if code ~= XCode.Success then + return code, nil + end + end + + return XCode.Success, levelMap +end + +---获取魔法等级集合 + +local function GetPartnerMagicLevelMap(partnerData) + local levelMap = {} + + for _, inter in pairs(GetPartnerMagicLevelInterfaces) do + local code = inter(partnerData, levelMap) + if code ~= XCode.Success then + return code, nil + end + end + + return XCode.Success, levelMap +end + +---获取出生魔法等级集合 + +local function GetPartnerBornMagicLevelMap(partnerData) + local levelMap = {} + + for _, inter in pairs(GetPartnerBornMagicLevelInterfaces) do + local code = inter(partnerData, levelMap) + if code ~= XCode.Success then + return code, nil + end + end + + return XCode.Success, levelMap +end + +local function TryGetPartnerSkillLevelMap(partnerData) + local code, levelMap = GetPartnerSkillLevelMap(partnerData) + if code ~= XCode.Success then + return nil + end + + return levelMap +end + +local function TryGetPartnerMagicLevelMap(partnerData) + local code, levelMap = GetPartnerMagicLevelMap(partnerData) + if code ~= XCode.Success then + return nil + end + + return levelMap +end + +local function TryGetPartnerBornMagicLevelMap(partnerData) + local code, levelMap = GetPartnerBornMagicLevelMap(partnerData) + if code ~= XCode.Success then + return nil + end + + return levelMap +end + +function XMagicSkillManager.RegisterPartnerSkillLevelInterface(inter) + tableInsert(GetPartnerSkillLevelInterfaces, inter) +end + +function XMagicSkillManager.RegisterPartnerMagicLevelInterface(inter) + tableInsert(GetPartnerMagicLevelInterfaces, inter) +end + +function XMagicSkillManager.RegisterPartnerBornMagicLevelInterface(inter) + tableInsert(GetPartnerBornMagicLevelInterfaces, inter) +end +--------------------------------------------------------------------------------- +function XMagicSkillManager.Init() + CS.XFightDelegate.GetNpcSkillLevelMap = TryGetSkillLevelMap + CS.XFightDelegate.GetNpcMagicLevelMap = TryGetMagicLevelMap + CS.XFightDelegate.GetNpcBornMagicLevelMap = TryGetBornMagicLevelMap + + CS.XFightDelegate.GetPartnerSkillLevelMap = TryGetPartnerSkillLevelMap + CS.XFightDelegate.GetPartnerMagicLevelMap = TryGetPartnerMagicLevelMap + CS.XFightDelegate.GetPartnerBornMagicLevelMap = TryGetPartnerBornMagicLevelMap +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XMailManager.lua b/Resources/Scripts/XManager/XMailManager.lua new file mode 100644 index 00000000..19b23562 --- /dev/null +++ b/Resources/Scripts/XManager/XMailManager.lua @@ -0,0 +1,391 @@ +XMailManagerCreator = function() + + local XMailManager = {} + + local tableInsert = table.insert + + local METHOD_NAME = { + MailReadRequest = "MailReadRequest", + MailGetRewardRequest = "MailGetRewardRequest", + MailGetSingleRewardRequest = "MailGetSingleRewardRequest", + MailDeleteRequest = "MailDeleteRequest", + } + + local MailCache = {} + -- local lastSyncServerTime = 0 + local NewMailMark = false + + XMailManager.MAIL_STATUS_UNREAD = 0 + XMailManager.MAIL_STATUS_READ = 1 + XMailManager.MAIL_STATUS_GETREWARD = 3 + XMailManager.MAIL_STATUS_DELETE = 4 + + local STATUS_UNREAD = 0 + local STATUS_READ = 1 << 0 + local STATUS_GETREWARD = STATUS_READ | (1 << 1) + local STATUS_DELETE = 1 << 2 + + function XMailManager.GetRewardList(mailId) + return XMailConfigs.GetRewardList(mailId) + end + + --==============================-- + --desc: 检查邮件是否过期或失效 + --@mailId: 邮件id + --@return + --==============================-- + local function CheckMailExpire(mailId) + local mail = MailCache[mailId] + if not mail then + return true + end + + if mail.Status == STATUS_DELETE then + return true + end + + if not mail.ExpireTime or mail.ExpireTime <= 0 then + return false + end + + return XTime.GetServerNowTimestamp() > mail.ExpireTime + end + + --==============================-- + --desc: 删除邮件数据 + --@mailId: 邮件id + --@return + --==============================-- + local function DeleteMail(mailId) + MailCache[mailId] = nil + end + + --==============================-- + --desc: 更新邮件数据 + --@mailData: 邮件数据 + --@return + --==============================-- + local function UpdateMail(mailData) + MailCache[mailData.Id] = mailData + end + + --==============================-- + --desc: 处理邮件数据 + --@return + --==============================-- + local function DealMailDatas(mailList, expireIdList) + if mailList then + for _, mail in pairs(mailList) do + UpdateMail(mail) + end + end + + if expireIdList then + for _, id in pairs(expireIdList) do + DeleteMail(id) + end + end + XEventManager.DispatchEvent(XEventId.EVENT_MAIL_SYNC) + end + + function XMailManager.SyncMailEvent() + XEventManager.DispatchEvent(XEventId.EVENT_MAIL_SYNC) + end + + function XMailManager.IsRead(status) + return (status & STATUS_READ) == STATUS_READ + end + + function XMailManager.IsGetReward(status) + return (status & STATUS_GETREWARD) == STATUS_GETREWARD + end + + function XMailManager.IsDelete(status) + return (status & STATUS_DELETE) == STATUS_DELETE + end + + function XMailManager.SetMailStatus(id, status) + local mail = MailCache[id] + if not mail then + return + end + + if status == STATUS_UNREAD or (mail.Status & status) == status then + return + end + + mail.Status = mail.Status | status + end + + function XMailManager.GetNewMailMark() + return NewMailMark + end + + function XMailManager:GetIsUnReadMail() + local mailList = XMailManager.GetMailList() + for _, mailInfo in pairs(mailList) do + if mailInfo.Status == XMailManager.MAIL_STATUS_UNREAD then + return true + end + end + return false + end + + function XMailManager.ReadMail(mailId) + if CheckMailExpire(mailId) then + return + end + + local mail = MailCache[mailId] + if XMailManager.IsRead(mail.Status) or XMailManager.IsDelete(mail.Status) then + return + end + + XNetwork.Call(METHOD_NAME.MailReadRequest, { Id = mailId }, function(res) + if res.Code == XCode.Success then + if XMailManager.HasMailReward(mailId) then + XMailManager.SetMailStatus(mailId, STATUS_READ) + XEventManager.DispatchEvent(XEventId.EVENT_MAIL_READ, mailId) + else + XMailManager.SetMailStatus(mailId, STATUS_GETREWARD) + XEventManager.DispatchEvent(XEventId.MAIL_STATUS_GETREWARD, mailId) + end + end + end) + end + + function XMailManager.GetMailReward(mailId, cb) + if not XMailManager.HasMailReward(mailId) then + XUiManager.TipText("MailGetRewardEmpty") + return + end + + local mailData = MailCache[mailId] + if XMailManager.IsGetReward(mailData.Status) then + XUiManager.TipCode(XCode.MailManagerGetRewardRepeat) + return + end + + + if CheckMailExpire(mailId) then + DeleteMail(mailId) + XUiManager.TipCode(XCode.MailManagerMailWasInvalid) + cb(mailId) + return + end + + XNetwork.Call(METHOD_NAME.MailGetSingleRewardRequest, { Id = mailId }, function(res) + local func = function() + if res.Status == XMailManager.MAIL_STATUS_DELETE then + DeleteMail(mailId) + XUiManager.TipCode(XCode.MailManagerMailWasInvalid) + cb(mailId) + return + end + XMailManager.SetMailStatus(mailId, res.Status) + XEventManager.DispatchEvent(XEventId.EVENT_MAIL_GET_MAIL_REWARD) + cb() + end + + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + func() + else + XUiManager.OpenUiObtain(res.RewardGoodsList, nil, func) + end + end) + end + + function XMailManager.GetAllMailReward(cb) + local mailIds = {} + for id, mail in pairs(MailCache) do + if CheckMailExpire(id) then + DeleteMail(id) + elseif XMailManager.HasMailReward(id) and not XMailManager.IsGetReward(mail.Status) then + tableInsert(mailIds, id) + end + end + + if #mailIds <= 0 then + XUiManager.TipText("MailGetRewardEmpty") + cb() + return + end + + XNetwork.Call(METHOD_NAME.MailGetRewardRequest, { IdList = mailIds }, function(res) + local func = function(resCode) + if resCode == XCode.Success then + if cb then + cb() + end + + XEventManager.DispatchEvent(XEventId.EVENT_MAIL_GET_ALL_MAIL_REWARD) + + elseif resCode == XCode.MailManagerGetMailRewardSomeGoodsMoreThanCapacity then + local title = CS.XTextManager.GetText("TipTitle") + XUiManager.DialogTip(title, CS.XTextManager.GetCodeText(resCode), XUiManager.DialogType.Normal, cb, cb) + else + XUiManager.TipCode(resCode) + if cb then + cb() + end + end + end + + if res.MailStatus then + for id, status in pairs(res.MailStatus) do + if status == XMailManager.MAIL_STATUS_DELETE then + DeleteMail(id) + else + XMailManager.SetMailStatus(id, status) + end + end + end + + if res.RewardGoodsList and #res.RewardGoodsList > 0 then + XUiManager.OpenUiObtain(res.RewardGoodsList, nil, function() + func(res.Code) + end) + else + func(res.Code) + end + end) + end + + function XMailManager.DeleteMail(cb) + XNetwork.Call(METHOD_NAME.MailDeleteRequest, nil, function(res) + if res.DelIdList then + for _, id in pairs(res.DelIdList) do + DeleteMail(id) + end + end + + XEventManager.DispatchEvent(XEventId.EVENT_MAIL_DELETE) + cb() + end) + end + + --==============================-- + --desc: 获取邮件列表 (未读未领奖 > 已读未领奖 > 已读已领奖(没附件相当于已领奖)> 创建时间 > 过期时间) + --@return + --==============================-- + function XMailManager.GetMailList() + local list = {} + for k, mail in pairs(MailCache) do + + if mail.Status == STATUS_READ then + if XMailManager.HasMailReward(mail.Id) then + XMailManager.SetMailStatus(mail.Id, STATUS_READ) + else + XMailManager.SetMailStatus(mail.Id, STATUS_GETREWARD) + end + end + + if not CheckMailExpire(k) then + tableInsert(list, mail) + end + end + + table.sort(list, function(a, b) + if a.Status ~= b.Status then + return a.Status < b.Status + else + return a.ExpireTime < b.ExpireTime + end + end) + + return list + end + + function XMailManager.GetMailCount() + local list = {} + for k, mail in pairs(MailCache) do + if not CheckMailExpire(k) then + tableInsert(list, mail) + end + end + return #list + end + + function XMailManager.GetMailCache(mailId) + return MailCache[mailId] + end + + function XMailManager.HasMailReward(mailId) + local mail = MailCache[mailId] + if not mail then + return false + end + + local rewardList = mail.RewardGoodsList + if not rewardList then + return false + end + + if #rewardList > 0 then + return true + end + + return false + end + + function XMailManager.IsMailGetReward(mailId) + local mail = MailCache[mailId] + if not mail then + return + end + + return XMailManager.IsGetReward(mail.Status) + end + + --检查红点----------------------------------- + --有未读或者有奖励未领取 + function XMailManager.IsMailUnReadOrHasReward(mailId) + if not mailId then + return false + end + + local mailData = MailCache[mailId] + if not mailData then + return false + end + + if CheckMailExpire(mailId) then + return false + end + + if not XMailManager.IsRead(mailData.Status) then + return true + end + + if not XMailManager.IsGetReward(mailData.Status) and XMailManager.HasMailReward(mailId) then + return true + end + + return false + end + + --获取没处理的邮件 + function XMailManager.GetHasUnDealMail() + local mailList = XMailManager.GetMailList() + local result = 0 + for _, mailInfo in pairs(mailList) do + if XMailManager.IsMailUnReadOrHasReward(mailInfo.Id) then + result = result + 1 + end + end + return result + end + + function XMailManager.NotifyMails(data) + -- lastSyncServerTime = XTime.GetServerNowTimestamp() + DealMailDatas(data.NewMailList, data.ExpireIdList) + end + + return XMailManager +end + +XRpc.NotifyMails = function(data) + XDataCenter.MailManager.NotifyMails(data) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_MAIL_COUNT_CHANGE) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XMaintainerActionManager.lua b/Resources/Scripts/XManager/XMaintainerActionManager.lua new file mode 100644 index 00000000..feb21897 --- /dev/null +++ b/Resources/Scripts/XManager/XMaintainerActionManager.lua @@ -0,0 +1,441 @@ +local XBoxNodeEntity = require("XEntity/XMaintainerAction/XBoxNodeEntity") +local XCardChangeNodeEntity = require("XEntity/XMaintainerAction/XCardChangeNodeEntity") +local XDirectionChangeNodeEntity = require("XEntity/XMaintainerAction/XDirectionChangeNodeEntity") +local XExtraActionPointNodeEntity = require("XEntity/XMaintainerAction/XExtraActionPointNodeEntity") +local XFallBackNodeEntity = require("XEntity/XMaintainerAction/XFallBackNodeEntity") +local XFightNodeEntity = require("XEntity/XMaintainerAction/XFightNodeEntity") +local XForwardNodeEntity = require("XEntity/XMaintainerAction/XForwardNodeEntity") +local XMaintainerActionGameDataEntity = require("XEntity/XMaintainerAction/XMaintainerActionGameDataEntity") +local XMaintainerActionPlayerEntity = require("XEntity/XMaintainerAction/XMaintainerActionPlayerEntity") +local XNoneNodeEntity = require("XEntity/XMaintainerAction/XNoneNodeEntity") +local XStartNodeEntity = require("XEntity/XMaintainerAction/XStartNodeEntity") +local XUnKnowNodeEntity = require("XEntity/XMaintainerAction/XUnKnowNodeEntity") +local XSimulationFightNodeEntity = require("XEntity/XMaintainerAction/XSimulationFightNodeEntity") +local XWarehouseNodeEntity = require("XEntity/XMaintainerAction/XWarehouseNodeEntity") +local XExploreNodeEntity = require("XEntity/XMaintainerAction/XExploreNodeEntity") +local XMentorNodeEntity = require("XEntity/XMaintainerAction/XMentorNodeEntity") + +XMaintainerActionManagerCreator = function() + local XMaintainerActionManager = {} + local CSTextManagerGetText = CS.XTextManager.GetText + local CSXGameClientConfig = CS.XGame.ClientConfig + + local MapNodeList = {} + local PlayerDic = {} + local GameData = {} + local RecordData = nil + + local IsFightWin = false + local MessageTypeList = {} + + local RESET_COUNT_DOWN_NAME = "MaintainerActionReset" + + local METHOD_NAME = { + MaintainerActionNodeEventRequest = "MaintainerActionNodeEventRequest", + MaintainerActionPlayCardRequest = "MaintainerActionPlayCardRequest", + MaintainerActionRecordRequest = "MaintainerActionRecordRequest", + } + + function XMaintainerActionManager.Init() + XMaintainerActionManager.ClearRecordData() + end + + function XMaintainerActionManager.CreatePlayer(data) + PlayerDic = {} + for index,player in pairs(data.Players) do + PlayerDic[player.PlayerId] = XMaintainerActionPlayerEntity.New(player.PlayerId) + PlayerDic[player.PlayerId]:UpdateData(player) + end + end + + function XMaintainerActionManager.CreateGameData(data) + GameData = XMaintainerActionGameDataEntity.New() + GameData:UpdateData(data) + local nowTime = XTime.GetServerNowTimestamp() + XCountDown.RemoveTimer(RESET_COUNT_DOWN_NAME) + XCountDown.CreateTimer(RESET_COUNT_DOWN_NAME, data.ResetTime - nowTime) + end + + function XMaintainerActionManager.CreateMap(data) + MapNodeList = {} + for _,node in pairs(data.Nodes) do + MapNodeList = MapNodeList or {} + XMaintainerActionManager.CreateNode(node) + end + end + + function XMaintainerActionManager.CreateNode(node) + local nodeEntity = {} + if node.NodeType == XMaintainerActionConfigs.NodeType.UnKnow then + nodeEntity = XUnKnowNodeEntity.New(node.NodeId, node.NodeType) + elseif node.NodeType == XMaintainerActionConfigs.NodeType.Start then + nodeEntity = XStartNodeEntity.New(node.NodeId, node.NodeType) + elseif node.NodeType == XMaintainerActionConfigs.NodeType.Fight then + nodeEntity = XFightNodeEntity.New(node.NodeId, node.NodeType) + elseif node.NodeType == XMaintainerActionConfigs.NodeType.Box then + nodeEntity = XBoxNodeEntity.New(node.NodeId, node.NodeType) + elseif node.NodeType == XMaintainerActionConfigs.NodeType.None then + nodeEntity = XNoneNodeEntity.New(node.NodeId, node.NodeType) + elseif node.NodeType == XMaintainerActionConfigs.NodeType.Forward then + nodeEntity = XForwardNodeEntity.New(node.NodeId, node.NodeType) + elseif node.NodeType == XMaintainerActionConfigs.NodeType.FallBack then + nodeEntity = XFallBackNodeEntity.New(node.NodeId, node.NodeType) + elseif node.NodeType == XMaintainerActionConfigs.NodeType.CardChange then + nodeEntity = XCardChangeNodeEntity.New(node.NodeId, node.NodeType) + elseif node.NodeType == XMaintainerActionConfigs.NodeType.DirectionChange then + nodeEntity = XDirectionChangeNodeEntity.New(node.NodeId, node.NodeType) + elseif node.NodeType == XMaintainerActionConfigs.NodeType.ActionPoint then + nodeEntity = XExtraActionPointNodeEntity.New(node.NodeId, node.NodeType) + elseif node.NodeType == XMaintainerActionConfigs.NodeType.SimulationFight then + nodeEntity = XSimulationFightNodeEntity.New(node.NodeId, node.NodeType) + elseif node.NodeType == XMaintainerActionConfigs.NodeType.Warehouse then + nodeEntity = XWarehouseNodeEntity.New(node.NodeId, node.NodeType) + elseif node.NodeType == XMaintainerActionConfigs.NodeType.Explore then + nodeEntity = XExploreNodeEntity.New(node.NodeId, node.NodeType) + elseif node.NodeType == XMaintainerActionConfigs.NodeType.Mentor then + nodeEntity = XMentorNodeEntity.New(node.NodeId, node.NodeType) + end + local tmpData = {} + tmpData.Value = node.Value + tmpData.EventId = node.EventId + nodeEntity:UpdateData(tmpData) + MapNodeList[node.NodeId] = nodeEntity + return nodeEntity + end + + function XMaintainerActionManager.CreateRecordData(data) + RecordData = data + end + + function XMaintainerActionManager.UpdateGameData(data) + if GameData and next(GameData) then + GameData:UpdateData(data) + end + end + + function XMaintainerActionManager.GetRecordData() + return RecordData + end + + function XMaintainerActionManager.ClearRecordData() + RecordData = nil + end + + function XMaintainerActionManager.GetGameData() + return GameData + end + + function XMaintainerActionManager.GetPlayerDic() + return PlayerDic + end + + function XMaintainerActionManager.GetPlayerById(id) + return PlayerDic[id] + end + + function XMaintainerActionManager.GetPlayerMySelf() + return PlayerDic[XPlayer.Id] + end + + function XMaintainerActionManager.GetMapNodeList() + return MapNodeList + end + + function XMaintainerActionManager.GetMapNodeById(id) + return MapNodeList[id] + end + + function XMaintainerActionManager.GetResetCountDownName() + return RESET_COUNT_DOWN_NAME + end + + function XMaintainerActionManager.AddMessageType(type) + MessageTypeList = MessageTypeList or {} + MessageTypeList[type] = true + end + + function XMaintainerActionManager.GetMessageTypeList() + return MessageTypeList + end + + function XMaintainerActionManager.GetMaintainerActionName() + local maintainerActionCfg = XMaintainerActionConfigs.GetMaintainerActionTemplates() + return maintainerActionCfg.Name + end + + function XMaintainerActionManager.GetMaintainerActionStartTime() + local maintainerActionCfg = XMaintainerActionConfigs.GetMaintainerActionTemplates() + local startTime = XFunctionManager.GetStartTimeByTimeId(maintainerActionCfg.TimeId) or 0 + return startTime + end + + function XMaintainerActionManager.CheckIsFightComplete() + return GameData:IsFightOver() + end + + function XMaintainerActionManager.CheckIsBoxComplete() + return GameData:IsBoxOver() + end + + function XMaintainerActionManager.CheckIsWarehouseComplete() + return GameData:IsWarehouseOver() or not GameData:GetHasWarehouseNode() + end + + function XMaintainerActionManager.CheckIsActionPointOver() + local maxCount = GameData:GetMaxDailyActionCount() + GameData:GetExtraActionCount() + local IsOver = GameData:GetUsedActionCount() >= maxCount + return IsOver + end + + function XMaintainerActionManager.CheckIsAllComplete() + return XMaintainerActionManager.CheckIsBoxComplete() and + XMaintainerActionManager.CheckIsFightComplete() and + XMaintainerActionManager.CheckIsWarehouseComplete() + end + + function XMaintainerActionManager.CheckDayUpdateMessage() + if MessageTypeList then + if MessageTypeList[XMaintainerActionConfigs.MessageType.DayUpdate] then + XUiManager.TipText("MaintainerActionEventDayUpdate") + XMaintainerActionManager.RemoveMessageType(XMaintainerActionConfigs.MessageType.DayUpdate) + end + end + end + + function XMaintainerActionManager.CheckWeekUpdateMessage() + if MessageTypeList then + if MessageTypeList[XMaintainerActionConfigs.MessageType.WeekUpdate] then + XUiManager.TipText("MaintainerActionEventWeekUpdate") + XScheduleManager.ScheduleOnce(function() + XLuaUiManager.RunMain() + end, 1) + return true + end + end + return false + end + + function XMaintainerActionManager.CheckEventCompleteMessage(cb) + local IsShowMessage = false + if MessageTypeList then + if MessageTypeList[XMaintainerActionConfigs.MessageType.EventComplete] then + local strFight = CSTextManagerGetText("MaintainerActionWinFightText", GameData:GetMaxFightWinCount(), GameData:GetMaxFightWinCount()) + local strBox = CSTextManagerGetText("MaintainerActionWinBoxText", GameData:GetMaxBoxCount(), GameData:GetMaxBoxCount()) + local strWarehouse = GameData:GetHasWarehouseNode() and CSTextManagerGetText("MaintainerActionWinWarehouseText", GameData:GetMaxWarehouseFinishCount(), GameData:GetMaxWarehouseFinishCount()) or nil + local msgList = {strFight, strBox, strWarehouse} + local hintText = CSTextManagerGetText("MaintainerActionFinishHint", CSTextManagerGetText("MaintainerActionTaskCount")) + XScheduleManager.ScheduleOnce(function() + XLuaUiManager.Open("UiFubenMaintaineractionTipLayer", hintText, msgList, XMaintainerActionConfigs.TipType.EventComplete, cb) + end, 1) + XMaintainerActionManager.RemoveMessageType(XMaintainerActionConfigs.MessageType.EventComplete) + XMaintainerActionManager.RemoveMessageType(XMaintainerActionConfigs.MessageType.FightComplete) + IsShowMessage = true + end + end + if not IsShowMessage then + if cb then cb() end + end + end + + function XMaintainerActionManager.CheckFightCompleteMessage(cb) + local IsShowMessage = false + if MessageTypeList then + if MessageTypeList[XMaintainerActionConfigs.MessageType.FightComplete] then + local hintText = CSTextManagerGetText("MaintainerActionFinishHint", CSTextManagerGetText("MaintainerActionWinCount")) + XScheduleManager.ScheduleOnce(function() + XLuaUiManager.Open("UiFubenMaintaineractionTipLayer", hintText, nil, XMaintainerActionConfigs.TipType.FightComplete, cb) + end, 1) + XMaintainerActionManager.RemoveMessageType(XMaintainerActionConfigs.MessageType.FightComplete) + IsShowMessage = true + end + end + if not IsShowMessage then + if cb then cb() end + end + end + + function XMaintainerActionManager.CheckMentorCompleteMessage(cb) + local IsShowMessage = false + local IsMentorFinish = GameData:GetMentorStatus() == XMaintainerActionConfigs.MonterNodeStatus.Finish + if XMaintainerActionManager.CheckIsNewFinish(XMaintainerActionConfigs.MessageType.MentorComplete) and IsMentorFinish then + local hintText = CSTextManagerGetText("MaintainerActionFinishHint", CSTextManagerGetText("MaintainerActionMentorCount")) + XScheduleManager.ScheduleOnce(function() + XLuaUiManager.Open("UiFubenMaintaineractionTipLayer", hintText, nil, XMaintainerActionConfigs.TipType.MentorComplete, cb) + end, 1) + XDataCenter.MaintainerActionManager.AddFinish(XMaintainerActionConfigs.MessageType.MentorComplete, GameData:GetMentorStatus()) + IsShowMessage = true + end + if not IsShowMessage then + if cb then cb() end + end + end + + function XMaintainerActionManager.ClearMessageTypeList() + MessageTypeList = {} + end + + function XMaintainerActionManager.RemoveMessageType(type) + if MessageTypeList and MessageTypeList[type] then + MessageTypeList[type] = nil + end + end + + function XMaintainerActionManager.IsStart() + return GameData and next(GameData) + end + + function XMaintainerActionManager.CheckIsOpen() + local functionId = XFunctionManager.FunctionName.MaintainerAction + local isOpen = XFunctionManager.JudgeCanOpen(functionId) + if isOpen then + if not XDataCenter.MaintainerActionManager.IsStart() then + local startTime = XDataCenter.MaintainerActionManager.GetMaintainerActionStartTime() + local nowTime = XTime.GetServerNowTimestamp() + local desc = "" + if startTime >= nowTime then + local timeStr = XTime.TimestampToGameDateTimeString(startTime, "yyyy/MM/dd") + desc = CS.XTextManager.GetText("MaintainerActionNotStart",timeStr) + else + desc = CS.XTextManager.GetText("MaintainerActionNotOpen") + end + return false, desc + else + return true + end + else + return false, XFunctionManager.GetFunctionOpenCondition(functionId) + end + end + + ---------------------------------------stage相关-------------------------------------->>> + function XMaintainerActionManager.InitStageInfo() + local maintainerActionCfg = XMaintainerActionConfigs.GetMaintainerActionTemplates() + local maintainerActionLevelCfg = XMaintainerActionConfigs.GetMaintainerActionLevelTemplates() + for _, level in pairs(maintainerActionLevelCfg) do + local stageIdList = level.StageIds + for _, stageId in pairs(stageIdList) do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + stageInfo.Type = XDataCenter.FubenManager.StageType.MaintainerAction + stageInfo.ChapterName = maintainerActionCfg.Name + end + end + end + + function XMaintainerActionManager.OpenMaintainerActionWind() + XDataCenter.MaintainerActionManager.ClearMessageTypeList() + XLuaUiManager.Open("UiFubenMaintaineraction") + end + + ---------------------------------------stage相关---------------------------------------<<< + + function XMaintainerActionManager.CheckIsNewStoryID(Id) + if XSaveTool.GetData(string.format("%d%s%s", XPlayer.Id, "MaintainerActionStory", Id)) then + return false + end + return true + end + + function XMaintainerActionManager.MarkStoryID(Id) + if not XSaveTool.GetData(string.format("%d%s%s", XPlayer.Id, "MaintainerActionStory", Id)) then + XSaveTool.SaveData(string.format("%d%s%s", XPlayer.Id, "MaintainerActionStory", Id), Id) + end + end + + function XMaintainerActionManager.CheckIsNewFinish(type) + if XSaveTool.GetData(string.format("%d%s%d", XPlayer.Id, "MaintainerActionMentorFinish", type)) then + return false + end + return true + end + + function XMaintainerActionManager.AddFinish(type, curStatus) + if not XSaveTool.GetData(string.format("%d%s%d", XPlayer.Id, "MaintainerActionMentorFinish", type)) then + XSaveTool.SaveData(string.format("%d%s%d", XPlayer.Id, "MaintainerActionMentorFinish", type), curStatus) + end + end + + function XMaintainerActionManager.DeletFinish(type, curStatus) + local status = XSaveTool.GetData(string.format("%d%s%d", XPlayer.Id, "MaintainerActionMentorFinish", type)) + if status and curStatus < status then + XSaveTool.RemoveData(string.format("%d%s%d", XPlayer.Id, "MaintainerActionMentorFinish", type)) + end + end + + function XMaintainerActionManager.NodeEventRequest(cb, errorCb) + XNetwork.Call(METHOD_NAME.MaintainerActionNodeEventRequest, {}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + if errorCb then errorCb(res.Node) end + return + end + if cb then cb(res.Node) end + end) + end + + function XMaintainerActionManager.PlayerMoveRequest(cardNum, posId, cb) + XNetwork.Call(METHOD_NAME.MaintainerActionPlayCardRequest, {Card = cardNum}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + if cb then cb(res) end + end) + end + + function XMaintainerActionManager.PlayerRecordRequest(cb) + if RecordData then + if cb then cb() end + return + end + XNetwork.Call(METHOD_NAME.MaintainerActionRecordRequest, {}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XMaintainerActionManager.CreateRecordData(res.Records) + if cb then cb() end + end) + end + + XMaintainerActionManager.Init() + return XMaintainerActionManager +end + +XRpc.NotifyMaintainerActionData = function(data) + XDataCenter.MaintainerActionManager.ClearRecordData() + XDataCenter.MaintainerActionManager.CreatePlayer(data) + XDataCenter.MaintainerActionManager.CreateGameData(data) + XDataCenter.MaintainerActionManager.CreateMap(data) + XDataCenter.MaintainerActionManager.AddMessageType(XMaintainerActionConfigs.MessageType.WeekUpdate) + XDataCenter.MaintainerActionManager.DeletFinish(XMaintainerActionConfigs.MessageType.MentorComplete, data.MentorStatus) + XEventManager.DispatchEvent(XEventId.EVENT_MAINTAINERACTION_WEEK_UPDATA) +end + +XRpc.NotifyMaintainerActionDailyReset = function(data) + XDataCenter.MaintainerActionManager.UpdateGameData(data) + XDataCenter.MaintainerActionManager.AddMessageType(XMaintainerActionConfigs.MessageType.DayUpdate) + XEventManager.DispatchEvent(XEventId.EVENT_MAINTAINERACTION_DAY_UPDATA) +end + +XRpc.NotifyMaintainerActionFightWin = function(data) + local mySelf = XDataCenter.MaintainerActionManager.GetPlayerMySelf() + mySelf:MarkNodeEvent() + XDataCenter.MaintainerActionManager.UpdateGameData(data) + + local IsFightComplete = XDataCenter.MaintainerActionManager.CheckIsFightComplete() + local IsAllComplete = XDataCenter.MaintainerActionManager.CheckIsAllComplete() + if IsAllComplete then + XDataCenter.MaintainerActionManager.AddMessageType(XMaintainerActionConfigs.MessageType.EventComplete) + elseif IsFightComplete then + XDataCenter.MaintainerActionManager.AddMessageType(XMaintainerActionConfigs.MessageType.FightComplete) + end +end + +XRpc.NotifyMaintainerActionNodeChange = function(data) + local node = XDataCenter.MaintainerActionManager.CreateNode(data.Node) + if node:GetIsMentor() then + local gameData = XDataCenter.MaintainerActionManager.GetGameData() + gameData:SetMentorStatus(node:GetMentorStatus()) + end + XEventManager.DispatchEvent(XEventId.EVENT_MAINTAINERACTION_NODE_CHANGE) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XMarketingActivityManager.lua b/Resources/Scripts/XManager/XMarketingActivityManager.lua new file mode 100644 index 00000000..52fd8ca4 --- /dev/null +++ b/Resources/Scripts/XManager/XMarketingActivityManager.lua @@ -0,0 +1,1022 @@ +XMarketingActivityManagerCreator = function() + local tableInsert = table.insert + local tableSort = table.sort + local XMarketingActivityManager = {} + local ActivityList = {} + local CharacterList = {} + local WindowsInlayActivityList = {} + local WindowsInlayTokenList = {} + + local PicCompositionCfg = {} + local OtherCompositionDataList = {} + local RankCompositionDataList = {} + local MyCompositionDataList = {} + local PicCompositionUpLoadDayCount = 0 + local PicCompositionUpLoadMaxCount = 0 + local PicCompositionActivityId = 0 + local Json = require("XCommon/Json") + local PicCompositionMemoMax = CS.XGame.ClientConfig:GetInt("PicCompositionMemoMax") + local PicCompositionGetMaxCount = CS.XGame.ClientConfig:GetInt("PicCompositionGetMaxCount") + local PicCompositionBeforStartIndex = 0 + local PicCompositionAfterStartIndex = 0 + local CurCompositionIndex = 0 + local PicCompositionAllCount = 0 + local PicCompositionGetedScheduleIds = {} + local PicCompositionLikeList = {} + local PicCompositionRankRewardInfo = {} + local PicCompositionRankResultList = {} + + local GetMyCompositionRequest = nil + local GetOtherCompositionRequest = nil + local GetRankDataRequest = nil + local GetTrueWordRequest = nil + + local LastSyncRankTimes = 0 + local LastSyncTokenTimes = 0 + local LastSyncPraiseTimes = 0 + local LastSyncMyCompositionTimes = 0 + local LastSyncUploadTimes = 0 + local LastSyncOtherCompositionTimes = {} + + local VoteTokenExpireTime = 0 + + local SIGNSALT = "YzcmCZNvbXocrsz9dm8e" + local SALTINDEX = 50 + + local RANKSYNC_SECOND = 10 + local PRAISESYNC_SECOND = 2 + local UPLOADSYNC_SECOND = 6 + local MYDATASYNC_SECOND = 30 + local OTHERDATASYNC_SECOND = 30 + local TOKENSYNC_SECOND = 40 + local ERROR_CODE = { + ActivityId = 10000, + Rank = 10006, + User = 10008, + } + + local METHOD_NAME = { + PraiseRequest = "PraiseRequest", + UploadCommentRequest = "UploadCommentRequest", + GetCommentScheduleRewardRequest = "GetCommentScheduleRewardRequest", + MarketVoteTokenRequest = "MarketVoteTokenRequest" + } + + local PicComposition_Url = { + GetUser = "/activity/public/user/get?", + GetFavorRank = "/activity/public/favor_rank/get?", + GetTimeRank = "/activity/public/time_rank/get?", + GetArticle = "/activity/public/article/get?", + GetTrueWord = "/web/bad_words/replace?", + } + + local TrueWordUrl = { + BaseUrl = "http://47.112.80.27:10010", + } + + function XMarketingActivityManager.Init() + ActivityList = XMarketingActivityConfigs.GetMarketingActivityConfig() + CharacterList = XMarketingActivityConfigs.GetCompositionCharacterConfigs() + PicCompositionCfg = XMarketingActivityConfigs.GetPicCompositionConfigs() + PicCompositionRankRewardInfo = XMarketingActivityConfigs.GetPicCompositionRankRewardInfoConfigs() + WindowsInlayActivityList = XMarketingActivityConfigs.GetWindowsInlayActivityConfig() + end + ------------------------------看图作文相关---------------------------------->>> + function XMarketingActivityManager.GetActivityList() + local list = {} + if not ActivityList then + return list + end + for _, activity in pairs(ActivityList) do + tableInsert(list, activity) + end + tableSort(list, function(a, b) + return a.Priority > b.Priority + end) + return list + end + + function XMarketingActivityManager.GetCharacterList() + local list = {} + if not CharacterList then + return list + end + for _, character in pairs(CharacterList) do + tableInsert(list, character) + end + tableSort(list, function(a, b) + return a.Id < b.Id + end) + return list + end + + function XMarketingActivityManager.GetPicCompositionInfo() + return PicCompositionCfg + end + + function XMarketingActivityManager.GetPicCompositionMemoMax() + return PicCompositionMemoMax + end + + function XMarketingActivityManager.GetPicCompositionGetMaxCount() + return PicCompositionGetMaxCount + end + + function XMarketingActivityManager.GetPicCompositionBeforStartIndex() + return PicCompositionBeforStartIndex + end + + function XMarketingActivityManager.GetPicCompositionAfterStartIndex() + return PicCompositionAfterStartIndex + end + + function XMarketingActivityManager.GetPicCompositionAllCount() + return PicCompositionAllCount + end + + function XMarketingActivityManager.GetUpLoadDayCount() + return PicCompositionUpLoadDayCount + end + + function XMarketingActivityManager.GetUpLoadMaxCount() + return PicCompositionUpLoadMaxCount + end + + function XMarketingActivityManager.GetGetedScheduleIds() + return PicCompositionGetedScheduleIds + end + + function XMarketingActivityManager.GetPicCompositionLikeList() + return PicCompositionLikeList + end + + function XMarketingActivityManager.GetPicCompositionRankResultList() + return PicCompositionRankResultList + end + + function XMarketingActivityManager.GetPicCompositionRankRewardInfoList() + local list = {} + if not PicCompositionRankRewardInfo then + return list + end + for _, info in pairs(PicCompositionRankRewardInfo) do + tableInsert(list, info) + end + return list + end + + function XMarketingActivityManager.GetNowActivityId() + return PicCompositionActivityId or 0 + end + + function XMarketingActivityManager.GetMyCompositionDataListByType(type) + local list = {} + local myCompositionDatalist = MyCompositionDataList[type] + + if not myCompositionDatalist then + return list + end + for _, data in pairs(myCompositionDatalist) do + tableInsert(list, data) + end + if type == XMarketingActivityConfigs.CompositionType.Examined then + tableSort(list, function(a, b) + if a.Hot ~= b.Hot then + return a.Hot > b.Hot + else + return a.ReviewTime > b.ReviewTime + end + end) + end + return list + end + + function XMarketingActivityManager.GetMyCompositionDataList() + local list = {} + local dialogueData = XMarketingActivityManager.GetMyCompositionDataListByType( + XMarketingActivityConfigs.CompositionType.Examined) + + for _, data in pairs(dialogueData) do + tableInsert(list, data) + end + + dialogueData = XMarketingActivityManager.GetMyCompositionDataListByType( + XMarketingActivityConfigs.CompositionType.Examining) + + for _, data in pairs(dialogueData) do + tableInsert(list, data) + end + + dialogueData = XMarketingActivityManager.GetMyCompositionDataListByType( + XMarketingActivityConfigs.CompositionType.UnExamine) + + for _, data in pairs(dialogueData) do + tableInsert(list, data) + end + + dialogueData = XMarketingActivityManager.GetMyCompositionDataListByType( + XMarketingActivityConfigs.CompositionType.Memo) + + for _, data in pairs(dialogueData) do + tableInsert(list, data) + end + return list + end + + function XMarketingActivityManager.GetPicCompositionTaskDatas() + if PicCompositionActivityId == 0 then + return nil + end + local infoList = XMarketingActivityConfigs.GetPicCompositionActivityInfoConfigs() + local taskGroupId = infoList[PicCompositionActivityId].LimitTaskId + if taskGroupId == 0 then return {} end + return XDataCenter.TaskManager.GetTimeLimitTaskListByGroupId(taskGroupId) + end + + function XMarketingActivityManager.GetOtherCompositionDataList(sortType) + local list = {} + local otherCompositionDataList = OtherCompositionDataList[sortType][CurCompositionIndex] + + if not otherCompositionDataList then + return list + end + + for _, data in pairs(otherCompositionDataList) do + tableInsert(list, data) + end + return list + end + + function XMarketingActivityManager.GetRankCompositionDataList() + local list = {} + if not RankCompositionDataList then + return list + end + for _, data in pairs(RankCompositionDataList) do + tableInsert(list, data) + end + return list + end + + function XMarketingActivityManager.GetUpLoadTime(IsInt) + if PicCompositionActivityId == 0 then + return 0, 0 + end + + local infoList = XMarketingActivityConfigs.GetPicCompositionActivityInfoConfigs() + local uploadBeginTimeStr = XTime.ParseToTimestamp(infoList[PicCompositionActivityId].UploadBeginTimeStr) + local uploadEndTimeStr = XTime.ParseToTimestamp(infoList[PicCompositionActivityId].UploadEndTimeStr) + + if IsInt then + return uploadBeginTimeStr, uploadEndTimeStr + end + + return infoList[PicCompositionActivityId].UploadBeginTimeStr, infoList[PicCompositionActivityId].UploadEndTimeStr + end + + function XMarketingActivityManager.GetPicCompositionTime(type) + if PicCompositionActivityId == 0 then + return nil + end + + local infoList = XMarketingActivityConfigs.GetPicCompositionActivityInfoConfigs() + local beginTime = XTime.ParseToTimestamp(infoList[PicCompositionActivityId].BeginTimeStr) + local endTime = XTime.ParseToTimestamp(infoList[PicCompositionActivityId].EndTimeStr) + local uploadBeginTime = XTime.ParseToTimestamp(infoList[PicCompositionActivityId].UploadBeginTimeStr) + local uploadEndTime = XTime.ParseToTimestamp(infoList[PicCompositionActivityId].UploadEndTimeStr) + + if type == XMarketingActivityConfigs.TimeDataType.BeginTime then + return beginTime + elseif type == XMarketingActivityConfigs.TimeDataType.EndTime then + return endTime + elseif type == XMarketingActivityConfigs.TimeDataType.UploadBeginTime then + return uploadBeginTime + elseif type == XMarketingActivityConfigs.TimeDataType.UploadEndTime then + return uploadEndTime + end + + return nil + end + + function XMarketingActivityManager.SetNowActivityId(id) + PicCompositionActivityId = id + end + + function XMarketingActivityManager.SetGetedScheduleIds(ids) + if not ids then + return + end + + for _, id in pairs(ids) do + PicCompositionGetedScheduleIds[id] = id + end + end + + function XMarketingActivityManager.AddGetedScheduleIds(id) + PicCompositionGetedScheduleIds[id] = id + end + + function XMarketingActivityManager.AddPicCompositionLike(id) + PicCompositionLikeList[id] = id + end + + function XMarketingActivityManager.SetPicCompositionRankResultList(list) + PicCompositionRankResultList = list + end + + function XMarketingActivityManager.ResetPicCompositionRankResultList() + PicCompositionRankResultList = {} + end + + function XMarketingActivityManager.ResetPicCompositionStartIndex() + PicCompositionBeforStartIndex = 0 + PicCompositionAfterStartIndex = 0 + CurCompositionIndex = 0 + end + + function XMarketingActivityManager.ClearOtherCompositionDataList(sortType) + OtherCompositionDataList[sortType] = {} + end + + function XMarketingActivityManager.CheckIsCanUpLoad() + if PicCompositionActivityId == 0 then + return XMarketingActivityConfigs.TimeType.Out + end + + local infoList = XMarketingActivityConfigs.GetPicCompositionActivityInfoConfigs() + local nowTime = XTime.GetServerNowTimestamp() + local beginTimeStr = XTime.ParseToTimestamp(infoList[PicCompositionActivityId].BeginTimeStr) + local endTimeStr = XTime.ParseToTimestamp(infoList[PicCompositionActivityId].EndTimeStr) + local uploadBeginTimeStr = XTime.ParseToTimestamp(infoList[PicCompositionActivityId].UploadBeginTimeStr) + local uploadEndTimeStr = XTime.ParseToTimestamp(infoList[PicCompositionActivityId].UploadEndTimeStr) + + if nowTime > beginTimeStr and nowTime < uploadBeginTimeStr then + return XMarketingActivityConfigs.TimeType.Before + elseif nowTime > uploadBeginTimeStr and nowTime < uploadEndTimeStr then + return XMarketingActivityConfigs.TimeType.In + elseif nowTime > uploadEndTimeStr and nowTime < endTimeStr then + return XMarketingActivityConfigs.TimeType.After + end + + return XMarketingActivityConfigs.TimeType.Out + end + + function XMarketingActivityManager.CheckIsIntime() + if PicCompositionActivityId == 0 then + return false + end + + local infoList = XMarketingActivityConfigs.GetPicCompositionActivityInfoConfigs() + local nowTime = XTime.GetServerNowTimestamp() + local beginTimeStr = XTime.ParseToTimestamp(infoList[PicCompositionActivityId].BeginTimeStr) + local endTimeStr = XTime.ParseToTimestamp(infoList[PicCompositionActivityId].EndTimeStr) + + if nowTime > beginTimeStr and nowTime < endTimeStr then + return true + end + + return false + end + + function XMarketingActivityManager.CheckAnyTaskFinished() + local taskDatas = XMarketingActivityManager.GetPicCompositionTaskDatas() + if not taskDatas then + return false + end + + local achieved = XDataCenter.TaskManager.TaskState.Achieved + for _, taskData in pairs(taskDatas or {}) do + if taskData.State == achieved then + return true + end + end + + return false + end + + function XMarketingActivityManager.CheckHasActiveTaskReward() + if PicCompositionActivityId == 0 then + return false + end + local infoList = XMarketingActivityConfigs.GetPicCompositionActivityInfoConfigs() + local taskItem = infoList[PicCompositionActivityId].ScheduleItemId + local curActivenes = XDataCenter.ItemManager.GetCount(taskItem) + local ActivenesDatas = XMarketingActivityConfigs.GetPicCompositionScheduleRewardInfoConfigs() + for _, activenesData in pairs(ActivenesDatas) do + if activenesData.Schedule <= curActivenes and (not XMarketingActivityManager.IsGetedScheduleReward(activenesData.Id)) then + return true + end + end + return false + end + + function XMarketingActivityManager.CheckItemEnough(count) + local infoList = XMarketingActivityConfigs.GetPicCompositionActivityInfoConfigs() + return count >= infoList[PicCompositionActivityId].PraiseConsume + end + + function XMarketingActivityManager.IsGetedScheduleReward(id) + if PicCompositionGetedScheduleIds[id] then + return true + end + return false + end + + function XMarketingActivityManager.IsDoPicCompositionLike(id) + if PicCompositionLikeList[id] then + return true + end + return false + end + + function XMarketingActivityManager.SetMemoDialogue() + MyCompositionDataList[XMarketingActivityConfigs.CompositionType.Memo] = {} + for id = 1, PicCompositionMemoMax do + local dialogue = XSaveTool.GetData(string.format("%d%d%s", XPlayer.Id, id, "PicCompositionMemo")) + if dialogue then + local memo = {} + memo.Type = XMarketingActivityConfigs.CompositionType.Memo + memo.Dialogue = dialogue.Memo + memo.MemoId = id + tableInsert(MyCompositionDataList[memo.Type], memo) + end + end + end + + function XMarketingActivityManager.AddMemoDialogue(id, dialogue) + if dialogue then + local memo = {} + memo.Type = XMarketingActivityConfigs.CompositionType.Memo + memo.Dialogue = dialogue + memo.MemoId = id + if not MyCompositionDataList[memo.Type] then + MyCompositionDataList[memo.Type] = {} + end + tableInsert(MyCompositionDataList[memo.Type], memo) + end + end + + function XMarketingActivityManager.SaveMemoDialogue(memo, curMemoId, cb) + if PicCompositionActivityId == 0 then + XLog.Error("PicCompositionActivityId Is Error") + return + end + if not curMemoId and #MyCompositionDataList[XMarketingActivityConfigs.CompositionType.Memo] >= PicCompositionMemoMax then + local text = CS.XTextManager.GetText("PicCompositionMemoMax", #MyCompositionDataList[XMarketingActivityConfigs.CompositionType.Memo], PicCompositionMemoMax) + XUiManager.TipMsg(text) + return + end + local memoId = curMemoId and curMemoId or #MyCompositionDataList[XMarketingActivityConfigs.CompositionType.Memo] + 1 + + local data = {} + data.ActivityId = PicCompositionActivityId + data.Memo = memo + XSaveTool.SaveData(string.format("%d%d%s", XPlayer.Id, memoId, "PicCompositionMemo"), data) + local text + if not curMemoId then + XDataCenter.MarketingActivityManager.AddMemoDialogue(memoId, memo) + text = CS.XTextManager.GetText("PicCompositionSave", memoId, PicCompositionMemoMax) + else + XDataCenter.MarketingActivityManager.SetMemoDialogue() + text = CS.XTextManager.GetText("PicCompositionEdit") + end + + XUiManager.TipMsg(text) + if cb then cb() end + end + + function XMarketingActivityManager.DelectTimeOverMemoDialogue() + if PicCompositionActivityId == 0 then + return + end + for index = 1, PicCompositionMemoMax do + local data = XSaveTool.GetData(string.format("%d%d%s", XPlayer.Id, index, "PicCompositionMemo")) + if data and data.ActivityId ~= PicCompositionActivityId then + XSaveTool.RemoveData(string.format("%d%d%s", XPlayer.Id, index, "PicCompositionMemo")) + end + end + end + + function XMarketingActivityManager.DelectMemoDialogue(index) + if PicCompositionActivityId == 0 then + return + end + if not index then + return + end + if XSaveTool.GetData(string.format("%d%d%s", XPlayer.Id, index, "PicCompositionMemo")) then + XSaveTool.RemoveData(string.format("%d%d%s", XPlayer.Id, index, "PicCompositionMemo")) + end + end + + function XMarketingActivityManager.IsCanAutoOpenGuide() --判断是否可以自动打开图文教学 + local data = XSaveTool.GetData(string.format("%d%s", XPlayer.Id, "PicCompositionGuide")) + if not data then + XSaveTool.SaveData(string.format("%d%s", XPlayer.Id, "PicCompositionGuide"), true) + return true + end + return false + end + + function XMarketingActivityManager.GiveUploadComment(Composition, cb) + local now = XTime.GetServerNowTimestamp() + local syscTime = LastSyncUploadTimes + + if syscTime and now - syscTime < UPLOADSYNC_SECOND then + local text = CS.XTextManager.GetText("PicCompositionfrequencyHint", UPLOADSYNC_SECOND) + XUiManager.TipMsg(text) + return + end + XNetwork.Call(METHOD_NAME.UploadCommentRequest, { CommentInfos = Composition }, function(res) + if res.Code ~= XCode.Success then + if res.ErrorIndex and res.ErrorIndex > 0 then + local text = CS.XTextManager.GetText("PicCompositionErrorText", res.ErrorIndex) + XUiManager.TipMsg(text) + else + XUiManager.TipCode(res.Code) + end + LastSyncUploadTimes = XTime.GetServerNowTimestamp() + return + end + LastSyncUploadTimes = XTime.GetServerNowTimestamp() + XUiManager.TipText("PicCompositionUpLoad") + if cb then cb() end + end) + end + + + function XMarketingActivityManager.GivePraise(id, cb) + local now = XTime.GetServerNowTimestamp() + local syscTime = LastSyncPraiseTimes + + if syscTime and now - syscTime < PRAISESYNC_SECOND then + local text = CS.XTextManager.GetText("PicCompositionfrequencyHint", PRAISESYNC_SECOND) + XUiManager.TipMsg(text) + return + end + + XNetwork.Call(METHOD_NAME.PraiseRequest, { CommentId = id }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XUiManager.TipText("PicCompositionPraise") + XMarketingActivityManager.AddPicCompositionLike(id) + LastSyncPraiseTimes = XTime.GetServerNowTimestamp() + if cb then cb() end + end) + end + + function XMarketingActivityManager.GetCommentScheduleReward(id, cb) + XNetwork.Call(METHOD_NAME.GetCommentScheduleRewardRequest, { Id = id }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XUiManager.OpenUiObtain(res.RewardGoodsList) + XMarketingActivityManager.AddGetedScheduleIds(id) + XEventManager.DispatchEvent(XEventId.EVENT_TASK_SYNC) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_TASK_SYNC) + if cb then cb() end + end) + end + + function XMarketingActivityManager.InitMyCompositionDataList() + local now = XTime.GetServerNowTimestamp() + local syscTime = LastSyncMyCompositionTimes + + if syscTime and now - syscTime < MYDATASYNC_SECOND then + XEventManager.DispatchEvent(XEventId.EVENT_PICCOMPOSITION_GET_MYDATA, true) + return + end + + if GetMyCompositionRequest then + return + end + + MyCompositionDataList = {} + local url = string.format("%s%s", CS.XRemoteConfig.PicComposition, PicComposition_Url.GetUser) + local activityId = string.format("activityId=%d", PicCompositionActivityId) + local userId = string.format("&userId=%d", XPlayer.Id) + local sign = string.format("&sign=%s", CS.XTool.ToSHA1(string.format("%s%s%s", activityId, userId, SIGNSALT))) + url = string.format("%s%s%s%s", url, activityId, userId, sign) + GetMyCompositionRequest = CS.UnityEngine.Networking.UnityWebRequest.Get(url) + GetMyCompositionRequest.timeout = CS.XGame.Config:GetInt("LoginTimeOutInterval") + CS.XTool.WaitNativeCoroutine(GetMyCompositionRequest:SendWebRequest(), function() + if GetMyCompositionRequest.isNetworkError then + XLog.Error("network error,url is " .. url .. ", message is " .. GetMyCompositionRequest.error) + XEventManager.DispatchEvent(XEventId.EVENT_PICCOMPOSITION_GET_MYDATA, false) + return + end + + if GetMyCompositionRequest.isHttpError then + XLog.Error("http error,url is " .. url .. ", message is " .. GetMyCompositionRequest.error) + XEventManager.DispatchEvent(XEventId.EVENT_PICCOMPOSITION_GET_MYDATA, false) + return + end + + local result = Json.decode(GetMyCompositionRequest.downloadHandler.text) + if result.status ~= 0 then + if result.status == ERROR_CODE.ActivityId then + XLog.Error("ActivityId error,ActivityId is " .. PicCompositionActivityId) + end + XEventManager.DispatchEvent(XEventId.EVENT_PICCOMPOSITION_GET_MYDATA, false) + return + end + + GetMyCompositionRequest:Dispose() + GetMyCompositionRequest = nil + + PicCompositionUpLoadDayCount = result.data.remainTodayUploadTimes + PicCompositionUpLoadMaxCount = result.data.remainActivityUploadTimes + PicCompositionLikeList = {} + for _, favor in pairs(result.data.favors) do + PicCompositionLikeList[favor] = favor + end + for _, article in pairs(result.data.articles) do + local composition = {} + composition.Id = article.articleId + composition.Type = article.state + composition.ReviewTime = article.reviewTimeStamp + composition.Dialogue = Json.decode(article.content) + composition.Hot = article.scores + if not MyCompositionDataList[composition.Type] then + MyCompositionDataList[composition.Type] = {} + end + tableInsert(MyCompositionDataList[composition.Type], composition) + end + LastSyncMyCompositionTimes = XTime.GetServerNowTimestamp() + XMarketingActivityManager.SetMemoDialogue() + XEventManager.DispatchEvent(XEventId.EVENT_PICCOMPOSITION_GET_MYDATA, true) + end) + end + + function XMarketingActivityManager.InitOtherCompositionDataList(sortType, getType) + local now = XTime.GetServerNowTimestamp() + local syscTime = LastSyncOtherCompositionTimes[sortType] + if not syscTime or now - syscTime > OTHERDATASYNC_SECOND then + XMarketingActivityManager.ClearOtherCompositionDataList(sortType) + end + + local url + if sortType == XMarketingActivityConfigs.SortType.Hot then + url = string.format("%s%s", CS.XRemoteConfig.PicComposition, PicComposition_Url.GetFavorRank) + else + url = string.format("%s%s", CS.XRemoteConfig.PicComposition, PicComposition_Url.GetTimeRank) + end + + if getType == XMarketingActivityConfigs.GetType.Before then + PicCompositionBeforStartIndex = (PicCompositionBeforStartIndex - PicCompositionGetMaxCount) > 0 and + (PicCompositionBeforStartIndex - PicCompositionGetMaxCount) or 0 + PicCompositionAfterStartIndex = PicCompositionBeforStartIndex + PicCompositionGetMaxCount + end + + CurCompositionIndex = getType == XMarketingActivityConfigs.GetType.Before and + CurCompositionIndex - 1 or CurCompositionIndex + 1 + + if not OtherCompositionDataList[sortType][CurCompositionIndex] then + OtherCompositionDataList[sortType][CurCompositionIndex] = {} + else + if getType == XMarketingActivityConfigs.GetType.After then + PicCompositionAfterStartIndex = PicCompositionAfterStartIndex + PicCompositionGetMaxCount + PicCompositionBeforStartIndex = PicCompositionAfterStartIndex - PicCompositionGetMaxCount + end + XEventManager.DispatchEvent(XEventId.EVENT_PICCOMPOSITION_GET_OTHERDATA, true, getType) + return + end + + + local activityId = string.format("activityId=%d", PicCompositionActivityId) + local index = getType == XMarketingActivityConfigs.GetType.Before and PicCompositionBeforStartIndex or PicCompositionAfterStartIndex + local startStr = string.format("&start=%d", index) + local lengthStr = string.format("&length=%d", PicCompositionGetMaxCount) + local sign = string.format("&sign=%s", CS.XTool.ToSHA1(string.format("%s%s%s%s", activityId, startStr, lengthStr, SIGNSALT))) + url = string.format("%s%s%s%s%s", url, activityId, startStr, lengthStr, sign) + if GetOtherCompositionRequest then + GetOtherCompositionRequest:Dispose() + end + GetOtherCompositionRequest = CS.UnityEngine.Networking.UnityWebRequest.Get(url) + GetOtherCompositionRequest.timeout = CS.XGame.Config:GetInt("LoginTimeOutInterval") + CS.XTool.WaitNativeCoroutine(GetOtherCompositionRequest:SendWebRequest(), function() + if GetOtherCompositionRequest.isNetworkError then + XLog.Error("network error,url is " .. url .. ", message is " .. GetOtherCompositionRequest.error) + XEventManager.DispatchEvent(XEventId.EVENT_PICCOMPOSITION_GET_OTHERDATA, false, getType) + return + end + + if GetOtherCompositionRequest.isHttpError then + XLog.Error("http error,url is " .. url .. ", message is " .. GetOtherCompositionRequest.error) + XEventManager.DispatchEvent(XEventId.EVENT_PICCOMPOSITION_GET_OTHERDATA, false, getType) + return + end + + local ok, result = pcall(Json.decode, GetOtherCompositionRequest.downloadHandler.text) + if not ok then + return + end + if result.status ~= 0 then + if result.status == ERROR_CODE.ActivityId then + XLog.Error("ActivityId error,ActivityId is " .. PicCompositionActivityId) + end + XEventManager.DispatchEvent(XEventId.EVENT_PICCOMPOSITION_GET_OTHERDATA, false, getType) + return + end + + GetOtherCompositionRequest:Dispose() + GetOtherCompositionRequest = nil + + PicCompositionAllCount = result.data.total + if getType == XMarketingActivityConfigs.GetType.After then + PicCompositionAfterStartIndex = PicCompositionAfterStartIndex + PicCompositionGetMaxCount + PicCompositionBeforStartIndex = PicCompositionAfterStartIndex - PicCompositionGetMaxCount + end + for _, article in pairs(result.data.articles) do + local composition = {} + composition.Id = article.articleId + composition.Type = article.state + composition.UserName = article.userName + composition.ReviewTime = article.reviewTimeStamp + composition.Dialogue = Json.decode(article.content) + composition.UserId = tonumber(article.userId) + composition.Hot = article.scores + tableInsert(OtherCompositionDataList[sortType][CurCompositionIndex], composition) + end + local indexOffset = 2 + if OtherCompositionDataList[sortType][CurCompositionIndex + indexOffset] then + OtherCompositionDataList[sortType][CurCompositionIndex + indexOffset] = nil + end + if OtherCompositionDataList[sortType][CurCompositionIndex - indexOffset] then + OtherCompositionDataList[sortType][CurCompositionIndex - indexOffset] = nil + end + + LastSyncOtherCompositionTimes[sortType] = XTime.GetServerNowTimestamp() + XEventManager.DispatchEvent(XEventId.EVENT_PICCOMPOSITION_GET_OTHERDATA, true, getType) + + end) + end + + function XMarketingActivityManager.InitRankCompositionDataList() + local now = XTime.GetServerNowTimestamp() + local syscTime = LastSyncRankTimes + + if syscTime and now - syscTime < RANKSYNC_SECOND then + XEventManager.DispatchEvent(XEventId.EVENT_PICCOMPOSITION_GET_RANKDATA, true) + return + end + + if GetRankDataRequest then + return + end + + RankCompositionDataList = {} + local infoList = XMarketingActivityConfigs.GetPicCompositionActivityInfoConfigs() + local rankNum = infoList[PicCompositionActivityId] and + infoList[PicCompositionActivityId].RankNum or nil + + local url = string.format("%s%s", CS.XRemoteConfig.PicComposition, PicComposition_Url.GetFavorRank) + local activityId = string.format("activityId=%d", PicCompositionActivityId) + local startStr = string.format("&start=%d", 0) + local lengthStr = string.format("&length=%d", rankNum) + local sign = string.format("&sign=%s", CS.XTool.ToSHA1(string.format("%s%s%s%s", activityId, startStr, lengthStr, SIGNSALT))) + url = string.format("%s%s%s%s%s", url, activityId, startStr, lengthStr, sign) + GetRankDataRequest = CS.UnityEngine.Networking.UnityWebRequest.Get(url) + GetRankDataRequest.timeout = CS.XGame.Config:GetInt("LoginTimeOutInterval") + CS.XTool.WaitNativeCoroutine(GetRankDataRequest:SendWebRequest(), function() + if GetRankDataRequest.isNetworkError then + XLog.Error("network error,url is " .. url .. ", message is " .. GetRankDataRequest.error) + XEventManager.DispatchEvent(XEventId.EVENT_PICCOMPOSITION_GET_RANKDATA, false) + return + end + + if GetRankDataRequest.isHttpError then + XLog.Error("http error,url is " .. url .. ", message is " .. GetRankDataRequest.error) + XEventManager.DispatchEvent(XEventId.EVENT_PICCOMPOSITION_GET_RANKDATA, false) + return + end + + local result = Json.decode(GetRankDataRequest.downloadHandler.text) + if result.status ~= 0 then + if result.status == ERROR_CODE.ActivityId then + XLog.Error("ActivityId error,ActivityId is " .. PicCompositionActivityId) + end + XEventManager.DispatchEvent(XEventId.EVENT_PICCOMPOSITION_GET_RANKDATA, false) + return + end + + GetRankDataRequest:Dispose() + GetRankDataRequest = nil + + for _, article in pairs(result.data.articles) do + local composition = {} + composition.Id = article.articleId + composition.Type = article.state + composition.UserName = article.userName + composition.ReviewTime = article.reviewTimeStamp + composition.Dialogue = Json.decode(article.content) + composition.Hot = article.scores + composition.HeadPortraitId = tonumber(article.profileId) + composition.HeadFrameId = tonumber(article.headFrameId) + composition.UserId = tonumber(article.userId) + tableInsert(RankCompositionDataList, composition) + end + LastSyncRankTimes = XTime.GetServerNowTimestamp() + XEventManager.DispatchEvent(XEventId.EVENT_PICCOMPOSITION_GET_RANKDATA, true) + end) + end + + function XMarketingActivityManager.GetTrueWord(dialogueText, haveBadWordCb, notHaveBadWordCb, index) + local url = string.format("%s%s", TrueWordUrl.BaseUrl, PicComposition_Url.GetTrueWord) + --local enCodeText = CS.System.Net.WebUtility.UrlEncode(dialogueText) + local content = string.format("content=%s", dialogueText) + url = string.format("%s%s", url, content) + + if GetTrueWordRequest then + GetTrueWordRequest:Dispose() + end + + GetTrueWordRequest = CS.UnityEngine.Networking.UnityWebRequest.Get(url) + GetTrueWordRequest.timeout = CS.XGame.Config:GetInt("LoginTimeOutInterval") + CS.XTool.WaitNativeCoroutine(GetTrueWordRequest:SendWebRequest(), function() + if GetTrueWordRequest.isNetworkError then + XLog.Error("network error,url is " .. url .. ", message is " .. GetTrueWordRequest.error) + XEventManager.DispatchEvent(XEventId.EVENT_PICCOMPOSITION_GET_WORD, false, nil, index) + return + end + + if GetTrueWordRequest.isHttpError then + XLog.Error("http error,url is " .. url .. ", message is " .. GetTrueWordRequest.error) + XEventManager.DispatchEvent(XEventId.EVENT_PICCOMPOSITION_GET_WORD, false, nil, index) + return + end + + local ok, result = pcall(Json.decode, GetTrueWordRequest.downloadHandler.text) + if not ok then + return + end + if result.status ~= 0 then + if result.status == ERROR_CODE.ActivityId then + XLog.Error("ActivityId error,ActivityId is " .. PicCompositionActivityId) + end + XEventManager.DispatchEvent(XEventId.EVENT_PICCOMPOSITION_GET_WORD, false, nil, index) + return + end + + GetTrueWordRequest:Dispose() + GetTrueWordRequest = nil + + local containBadWords = result.data.containBadWords + local dataContent = result.data.content + + if containBadWords then + if haveBadWordCb then haveBadWordCb() end + else + if notHaveBadWordCb then notHaveBadWordCb() end + end + + XEventManager.DispatchEvent(XEventId.EVENT_PICCOMPOSITION_GET_WORD, true, dataContent, index) + + end) + end + ------------------------------看图作文相关----------------------------------<<< + ------------------------------内嵌浏览器相关---------------------------------->>> + + function XMarketingActivityManager.GetWindowsInlayActivityList() + local list = {} + for _, activity in pairs(WindowsInlayActivityList) do + tableInsert(list, activity) + end + tableSort(list, function(a, b) + return a.Priority > b.Priority + end) + return list + end + + function XMarketingActivityManager.GetWindowsInlayInTimeActivityList() + local list = {} + for _, activity in pairs(WindowsInlayActivityList) do + local IsInTime = XMarketingActivityManager.CheckWindowsInlayActivityIsInTime(activity) + if IsInTime then + tableInsert(list, activity) + end + end + tableSort(list, function(a, b) + return a.Priority > b.Priority + end) + return list + end + + function XMarketingActivityManager.GetWindowsInlayActivityById(id) + return WindowsInlayActivityList[id] + end + + function XMarketingActivityManager.GetWindowsInlayTokenByType(type) + return WindowsInlayTokenList[type] + end + + function XMarketingActivityManager.SetWindowsInlayToken(token,type) + WindowsInlayTokenList[type] = token + end + + function XMarketingActivityManager.CheckWindowsInlayActivityIsInTime(windowsInlayActivity) + if not windowsInlayActivity then + return false + end + local nowTime = XTime.GetServerNowTimestamp() + local beginTimeStr = XTime.ParseToTimestamp(windowsInlayActivity.BeginTimeStr) + local endTimeStr = XTime.ParseToTimestamp(windowsInlayActivity.EndTimeStr) + + return not beginTimeStr or (nowTime > beginTimeStr and nowTime < endTimeStr) + end + + function XMarketingActivityManager.IsShowWindowsInlayRedPoint() + local freshTime = XTime.GetSeverTodayFreshTime() + local data = XSaveTool.GetData(string.format("%d%s", XPlayer.Id, "WindowsInlayRedPoint")) + if data then + if freshTime > data then + return true + else + return false + end + else + return true + end + end + + function XMarketingActivityManager.GetSignUrl(Url) + local urlData = {} + local keyList = { + "roleId", + "serverId", + "time", + "deviceNumber", + } + urlData["roleId"] = string.format("roleId=%d", XPlayer.Id) + urlData["serverId"] = string.format("serverId=%s", CS.XHeroBdcAgent.ServerId) + urlData["time"] = string.format("time=%d", XTime.GetServerNowTimestamp()) + urlData["deviceNumber"] = string.format("deviceNumber=%s", CS.UnityEngine.SystemInfo.deviceUniqueIdentifier) + table.sort(keyList,function (a, b) + return string.byte(a) < string.byte(b) + end) + local tmpUrl = string.format("%s&%s&%s&%s", urlData[keyList[1]], urlData[keyList[2]], urlData[keyList[3]], urlData[keyList[4]]) + local saltUrl = XMarketingActivityManager.AddSalt(tmpUrl) + local sign = string.format("&sign=%s", CS.XTool.ToSHA1(saltUrl)) + local url = string.format("%s?%s%s", Url, tmpUrl, sign) + return url + end + + function XMarketingActivityManager.AddSalt(Url) + local strLen = string.len(Url) + local tagStr = Url + if strLen <= SALTINDEX then + tagStr = string.format("%s%s", tagStr, SIGNSALT) + else + local exStr = string.sub(tagStr, 1, SALTINDEX) + local afStr = string.sub(tagStr, SALTINDEX + 1) + tagStr = string.format("%s%s%s", exStr, SIGNSALT, afStr) + end + return tagStr + end + + function XMarketingActivityManager.MarkWindowsInlayRedPoint() + local freshTime = XTime.GetSeverTodayFreshTime() + local data = XSaveTool.GetData(string.format("%d%s", XPlayer.Id, "WindowsInlayRedPoint")) + if data then + if freshTime > data then + XSaveTool.SaveData(string.format("%d%s", XPlayer.Id, "WindowsInlayRedPoint"), freshTime) + end + else + XSaveTool.SaveData(string.format("%d%s", XPlayer.Id, "WindowsInlayRedPoint"), freshTime) + end + end + + function XMarketingActivityManager.RequestVoteToken(type, cb) + local now = XTime.GetServerNowTimestamp() + if now < VoteTokenExpireTime then --根据token的保质期来判断是否需要重新请求 + if cb then cb() end + return + end + XNetwork.Call(METHOD_NAME.MarketVoteTokenRequest, {}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + VoteTokenExpireTime = res.ExpireTime--Token的过期时间 + XMarketingActivityManager.SetWindowsInlayToken(res.Token,type) + if cb then cb() end + end) + end + ------------------------------内嵌浏览器相关----------------------------------<<< + XMarketingActivityManager.Init() + return XMarketingActivityManager +end + + + +XRpc.NotifyCommentRankResult = function(data) + XDataCenter.MarketingActivityManager.SetPicCompositionRankResultList(data) +end + +XRpc.NotifyProductCommentData = function(data) + XDataCenter.MarketingActivityManager.SetNowActivityId(data.Id) + XDataCenter.MarketingActivityManager.SetGetedScheduleIds(data.ScheduleIds) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XMedalManager.lua b/Resources/Scripts/XManager/XMedalManager.lua new file mode 100644 index 00000000..53b7e758 --- /dev/null +++ b/Resources/Scripts/XManager/XMedalManager.lua @@ -0,0 +1,1095 @@ +local XNameplate = require("XEntity/XNameplate/XNameplate") +XMedalManagerCreator = function() + local tableInsert = table.insert + + local XMedalManager = {} + + local METHOD_NAME = { + ScoreTitleShowSetRequest = "ScoreTitleShowSetRequest", + CollectionShowSetRequest = "CollectionShowSetRequest", + WearNameplateRequest = "WearNameplateRequest", + } + + XMedalManager.InType = { Normal = 1, GetMedal = 2, OtherPlayer = 3 } + + XMedalManager.MedalStroyId = CS.XGame.ClientConfig:GetInt("MedalStoryId") + + local NewMedalId = nil + + local ScoreTitleUnLockList = {} -- 收藏品ID为索引,存放服务器下发的解锁收藏品 + + local MedalList = {} + local ScoreTitleList = {} -- Type索引数组,数组存放收藏品配置 + local ScoreTitleDataList = {} -- 收藏品ID为索引,存放收藏品配置 + local ScoreTitleShowStateList = {} + local NewCollectionList = {} + local QualityUpCollectionList = {} + local IsCanCheckQualityUp + + local BaseIconWidth -- 基准图标宽度 + local DEFAULT_BASE_ICON_WIDHT = 160 -- 默认基准图标宽度(玩家信息的收藏品页签中的格子) + + function XMedalManager.Init() + XMedalManager.InitScoreTitleList() + XMedalManager.InitMedalList() + IsCanCheckQualityUp = true + end + + function XMedalManager.GetMedals() + table.sort(MedalList, function(headA, headB) + local weightA = headA.IsLock and 0 or 1 + local weightB = headB.IsLock and 0 or 1 + if weightA == weightB then + return headA.Priority > headB.Priority + end + return weightA > weightB + end) + return MedalList + end + + function XMedalManager.GetMedalById(id) + for _, medal in pairs(MedalList) do + if medal.Id == id then + return medal + end + end + return nil + end + + function XMedalManager.InitMedalList() + local meadalsCfg = XMedalConfigs.GetMeadalConfigs() + for _, meadal in pairs(meadalsCfg or {}) do + + local tmp = {} + for k, v in pairs(meadal) do + tmp[k] = v + end + tmp["Type"] = XMedalConfigs.MedalType.Normal + tmp["IsLock"] = true + tmp["Time"] = 0 + tmp["Num"] = 0 + table.insert(MedalList, tmp) + end + end + + function XMedalManager.CreateOtherPlayerMedalList(medalInfos) + if not medalInfos then + return {} + end + local meadalsCfg = XMedalConfigs.GetMeadalConfigs() + local othermedalList = {} + for _, Info in pairs(medalInfos) do + local cfg = meadalsCfg[Info.Id] + if cfg then + local tmp = {} + for k, v in pairs(cfg) do + tmp[k] = v + end + tmp["Type"] = XMedalConfigs.MedalType.Normal + tmp["IsLock"] = false + tmp["Time"] = Info.Time + tmp["Num"] = Info.Num + othermedalList[tmp.Id] = tmp + end + end + return othermedalList + end + + function XMedalManager.UpdateMedalList() + for _, medal in pairs(MedalList) do + local medalInfo = XPlayer.UnlockedMedalInfos[medal.Id] + if medalInfo then + medal.IsLock = false + medal.Time = medalInfo.Time + medal.Num = medal.Num + end + end + end + + function XMedalManager.GetMeadalInfoById(Id) + return XPlayer.UnlockedMedalInfos[Id] + end + + function XMedalManager.GetMeadalMaxCount() + local maxCount = 0 + local medalsList = XMedalConfigs.GetMeadalConfigs() + for _, _ in pairs(medalsList or {}) do + maxCount = maxCount + 1 + end + return maxCount + end + + function XMedalManager.CheckMedalStoryIsPlayed() + if XSaveTool.GetData(string.format("%d%s", XPlayer.Id, "MedalStoryIsPlayed")) then + return true + end + return false + end + + function XMedalManager.MarkMedalStory() + if not XSaveTool.GetData(string.format("%d%s", XPlayer.Id, "MedalStoryIsPlayed")) then + XSaveTool.SaveData(string.format("%d%s", XPlayer.Id, "MedalStoryIsPlayed"), "MedalStoryIsPlayed") + end + end + + function XMedalManager.CheckHaveNewMedal() + local meadals = XMedalConfigs.GetMeadalConfigs() + if not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.Medal) then + if XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.Medal) then + for _, v in pairs(meadals) do + if XSaveTool.GetData(string.format("%d%s%d%d", XPlayer.Id, "NewMeadal", v.Id, XMedalConfigs.MedalType.Normal)) then + return true + end + end + end + end + if not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.Collection) then + if XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.Collection) then + for _, v in pairs(ScoreTitleDataList) do + if XSaveTool.GetData(string.format("%d%s%d%d", XPlayer.Id, "NewMeadal", v.Id, v.Type)) then + return true + end + end + end + end + + if XMedalManager.CkeckHaveNewNameplate() then + return true + end + return false + end + + function XMedalManager.CheckHaveNewMedalByType(type) + local meadals = XMedalConfigs.GetMeadalConfigs() + if type == XMedalConfigs.ViewType.Medal then + if not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.Medal) then + if XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.Medal) then + for _, v in pairs(meadals) do + if XSaveTool.GetData(string.format("%d%s%d%d", XPlayer.Id, "NewMeadal", v.Id, XMedalConfigs.MedalType.Normal)) then + return true + end + end + end + end + else + if not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.Collection) then + if XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.Collection) then + for _, v in pairs(ScoreTitleDataList) do + if XSaveTool.GetData(string.format("%d%s%d%d", XPlayer.Id, "NewMeadal", v.Id, v.Type)) then + return true + end + end + end + end + end + return false + end + + function XMedalManager.CheckIsNewMedalById(Id, type) + if XSaveTool.GetData(string.format("%d%s%d%d", XPlayer.Id, "NewMeadal", Id, type)) then + return true + end + return false + end + + function XMedalManager.SetMedalForOld(Id, type) + if XSaveTool.GetData(string.format("%d%s%d%d", XPlayer.Id, "NewMeadal", Id, type)) then + XSaveTool.RemoveData(string.format("%d%s%d%d", XPlayer.Id, "NewMeadal", Id, type)) + XEventManager.DispatchEvent(XEventId.EVENT_MEDAL_REDPOINT_CHANGE) + end + end + + function XMedalManager.AddNewMedal(Id, type) + if not XSaveTool.GetData(string.format("%d%s%d%d", XPlayer.Id, "NewMeadal", Id, type)) then + XSaveTool.SaveData(string.format("%d%s%d%d", XPlayer.Id, "NewMeadal", Id, type), Id) + end + end + + function XMedalManager.ShowUnlockTips() + if NewMedalId then + XLuaUiManager.Open("UiMedalUnlockTips", NewMedalId) + NewMedalId = nil + return true + end + return false + end + + function XMedalManager.SetNewMedalId(id) + NewMedalId = id + end + + ------------------------------------------计分徽章--------------------------------->>> + function XMedalManager.InitScoreTitleList() + local scoreTitlesCfg = XMedalConfigs.GetScoreTitlesConfigs() + for _, scoreTitle in pairs(scoreTitlesCfg or {}) do + + if not ScoreTitleList[scoreTitle.Type] then + ScoreTitleList[scoreTitle.Type] = {} + end + + local tmp = {} + for k, v in pairs(scoreTitle) do + tmp[k] = v + end + + tmp["IsLock"] = true + tmp["Quality"] = scoreTitle.InitQuality + tmp["Score"] = 0 + tmp["Time"] = 0 + + table.insert(ScoreTitleList[scoreTitle.Type], tmp) + + end + for _, type in pairs(ScoreTitleList) do + XMedalConfigs.SortByPriority(type) + for _, scoreTitle in pairs(type) do + ScoreTitleDataList[scoreTitle.Id] = scoreTitle + if not ScoreTitleShowStateList[scoreTitle.Type] then + ScoreTitleShowStateList[scoreTitle.Type] = {} + ScoreTitleShowStateList[scoreTitle.Type].Type = scoreTitle.Type + ScoreTitleShowStateList[scoreTitle.Type].Hide = XMedalConfigs.Hide.OFF + end + end + end + end + + function XMedalManager.CreateOtherPlayerScoreTitleList(titleInfos) + if not titleInfos then + return {} + end + local scoreTitlesCfg = XMedalConfigs.GetScoreTitlesConfigs() + local otherScoreTitleList = {} + for _, Info in pairs(titleInfos) do + local cfg = scoreTitlesCfg[Info.Id] + if cfg then + local tmp = {} + for k, v in pairs(cfg) do + tmp[k] = v + end + tmp["IsLock"] = false + tmp["Quality"] = Info.Quality + tmp["Score"] = Info.Score + tmp["Time"] = Info.Time + if Info.ExpandInfo then + tmp["ExpandInfo"] = Info.ExpandInfo + end + table.insert(otherScoreTitleList, tmp) + end + end + return XMedalConfigs.SortByPriority(otherScoreTitleList) + end + + function XMedalManager.CreateOtherPlayerScoreTitle(titleInfo) + if not titleInfo then + return + end + + local scoreTitlesCfg = XMedalConfigs.GetScoreTitlesConfigs() + local cfg = scoreTitlesCfg[titleInfo.Id] + if cfg then + local tmp = {} + for k, v in pairs(cfg) do + tmp[k] = v + end + tmp["IsLock"] = false + tmp["Quality"] = titleInfo.Quality + tmp["Score"] = titleInfo.Score + tmp["Time"] = titleInfo.Time + if titleInfo.ExpandInfo then + tmp["ExpandInfo"] = titleInfo.ExpandInfo + end + return tmp + end + end + + function XMedalManager.GetScoreTitle(type) + local list = {} + + if type then + local titleList = ScoreTitleList[type] + if titleList then + for _, scoreTitle in pairs(titleList) do + if not scoreTitle.IsLock or scoreTitle.ShowType ~= 0 then + table.insert(list, scoreTitle) + end + end + end + return list + end + + for _, tmpType in pairs(ScoreTitleList) do + for _, scoreTitle in pairs(tmpType) do + if not scoreTitle.IsLock or scoreTitle.ShowType ~= 0 then + tableInsert(list, scoreTitle) + end + end + end + + return XMedalConfigs.SortByPriority(list) + end + + function XMedalManager.GetScoreTitleByScreenType(screenType) + local list = {} + for _, tmpType in pairs(ScoreTitleList) do + for _, scoreTitle in pairs(tmpType) do + if (not scoreTitle.IsLock or scoreTitle.ShowType ~= 0) then + local isHasScreenType = screenType and screenType > 0 + local isSameScreenType = scoreTitle.ScreenType == screenType + if not isHasScreenType or (isHasScreenType and isSameScreenType) then + tableInsert(list, scoreTitle) + end + end + end + end + + local resultList = XMedalManager.UpgradeCollection(list) + return XMedalConfigs.SortByPriority(resultList) + end + + function XMedalManager.GetScoreTitleById(id) + for _, tmpType in pairs(ScoreTitleList) do + for _, scoreTitle in pairs(tmpType) do + if scoreTitle.Id == id then + return scoreTitle + end + end + end + end + + ---========================================== + --- 检查传入的 ‘oriList’数组 是否有需要升级的收藏品 + --- 更高级收藏品是一个独立的收藏品,有自己的收藏品Id + --- 更高级收藏品会覆盖低级收藏品,需要把低级收藏品隐藏(去除) + ---@return table + ---========================================== + function XMedalManager.UpgradeCollection(oriList) + if oriList == nil or next(oriList) == nil then + return oriList + end + + local resultList = {} + local groupIdIndex = {} -- GroupId做索引,存放相应的收藏品组 + + -- 区分需要升级与不需要升级的收藏品 + for _, scoreTitle in pairs(oriList) do + if scoreTitle.GroupId == 0 or scoreTitle.GroupId == nil then + -- 收藏品不可以升级,不需要判断显隐 + tableInsert(resultList, scoreTitle) + else + -- 相同组的收藏品放在同一个GroupId表 + if groupIdIndex[scoreTitle.GroupId] == nil then + groupIdIndex[scoreTitle.GroupId] = {} + end + tableInsert(groupIdIndex[scoreTitle.GroupId], scoreTitle) + end + end + + -- 选出每个Group中最高级的收藏品 + for _, group in pairs(groupIdIndex) do + table.sort(group, function(scoreTitle1, scoreTitle2) + if scoreTitle1.GroupLv == nil then + XLog.Error("XMedalManager.UpgradeCollection函数错误,收藏品" .. scoreTitle1.Id .. "的GroupLv为空") + return + elseif scoreTitle2.GroupLv == nil then + XLog.Error("XMedalManager.UpgradeCollection函数错误,收藏品" .. scoreTitle2.Id .. "的GroupLv为空") + return + end + + -- 按GroupLv降序排序 + return scoreTitle1.GroupLv > scoreTitle2.GroupLv + end) + + -- 将最高级的收藏品放入返回结果中 + tableInsert(resultList, group[1]) + end + + return resultList + end + + function XMedalManager.GetMedalData(scoreTitleId) + local scoreTitleData = ScoreTitleDataList[scoreTitleId] + return scoreTitleData + end + + function XMedalManager.GetMedalImg(scoreTitleId) + local scoreTitleData = ScoreTitleDataList[scoreTitleId] + return scoreTitleData and scoreTitleData.MedalImg + end + + function XMedalManager.GetScore(scoreTitleId) + local scoreTitleData = ScoreTitleDataList[scoreTitleId] + return scoreTitleData and scoreTitleData.Score or 0 + end + + function XMedalManager.GetMedalType(scoreTitleId) + local scoreTitleData = ScoreTitleDataList[scoreTitleId] + return scoreTitleData and scoreTitleData.Type or 0 + end + + function XMedalManager.GetQuality(scoreTitleId) + local scoreTitleData = ScoreTitleDataList[scoreTitleId] + return scoreTitleData and (scoreTitleData.Quality or scoreTitleData.InitQuality) or 0 + end + + function XMedalManager.GetIsLock(scoreTitleId) + local scoreTitleData = ScoreTitleDataList[scoreTitleId] + return scoreTitleData and scoreTitleData.IsLock or false + end + + --- + --- 获取'minQuality'与'maxQuality'(包括min与max)区间品质的收藏品id数组 + --- 如果只有一个参数,则获取这个品质的收藏品id数组 + ---@param minQuality number + ---@param maxQuality number + ---@return table + function XMedalManager.GetScoreTitleByQuality(minQuality, maxQuality) + local list = {} + if not minQuality and not maxQuality then + XLog.Error("XMedalManager.GetScoreTitleByQuality函数错误,参数不能全部都为 nil") + return + end + + -- 解锁的收藏品配置 + local unLockList = {} + for _, scoreTitle in pairs(ScoreTitleDataList) do + if (not scoreTitle.IsLock) then + tableInsert(unLockList, scoreTitle) + end + end + -- 合并同一个组的收藏品 + local upgradeList = XMedalManager.UpgradeCollection(unLockList) + + for _, scoreTitle in pairs(upgradeList) do + if maxQuality then + if (scoreTitle.Quality or scoreTitle.InitQuality) <= maxQuality + and (scoreTitle.Quality or scoreTitle.InitQuality) >= minQuality then + table.insert(list, scoreTitle) + end + else + if (scoreTitle.Quality or scoreTitle.InitQuality) == minQuality then + table.insert(list, scoreTitle) + end + end + end + + return list + end + + function XMedalManager.GetLevelIcon(scoreTitleId, curQuality) + local collectionLevel = XMedalConfigs.GetCollectionDefaultLevelConfigs() + local ScoreTitles = XMedalConfigs.GetScoreTitlesConfigs() + local levelIcon = nil + local curIndex = 0 + local qualities = ScoreTitles[scoreTitleId].Qualities + if qualities and #qualities > 0 then + for index, quality in pairs(qualities) do + if quality == curQuality then + curIndex = index + end + for _, level in pairs(collectionLevel) do + if level.CurLevel == curIndex and level.MaxLevel == #qualities then + levelIcon = level.Icon + break + end + end + end + end + return levelIcon + end + + function XMedalManager.GetScoreTitleShowState() + return XTool.Clone(ScoreTitleShowStateList) + end + + function XMedalManager.GetScoreTitleUnLockList() + return XTool.Clone(ScoreTitleUnLockList) + end + + function XMedalManager.CheckCanGetNewCollection() + if #NewCollectionList == 0 then + return false + else + local list = {} + for _, collectionId in pairs(NewCollectionList) do + tableInsert(list, XRewardManager.CreateRewardGoods(collectionId)) + end + XLuaUiManager.Open("UiObtainCollection", list) + XMedalManager.ClearCollectionList() + return true + end + end + + function XMedalManager.CheckQualityUpCollection() + if not QualityUpCollectionList or not next(QualityUpCollectionList) or not IsCanCheckQualityUp then + return + else + IsCanCheckQualityUp = false + local key, value = next(QualityUpCollectionList) + if key then + XLuaUiManager.Open("UiUpgradeCollection", key, value, function() + IsCanCheckQualityUp = true + XMedalManager.ClearQualityUpCollectionById(key) + XMedalManager.CheckQualityUpCollection() + end) + end + end + end + + function XMedalManager.ClearCollectionList() + NewCollectionList = {} + end + + function XMedalManager.GetScoreTitleIconById(id) + if not id then + return nil + end + return ScoreTitleDataList[id] and ScoreTitleDataList[id].MedalIcon or nil + end + + function XMedalManager.CheckScoreTitleIsShow(type) + local state = ScoreTitleShowStateList[type] + if not state then + return false + end + return state.Hide == XMedalConfigs.Hide.OFF + end + + function XMedalManager.CheckScoreTitleIsHaveById(id) + return ScoreTitleUnLockList[id] and true or false + end + + function XMedalManager.CheckHaveScoreTitleType(type) + return ScoreTitleList[type] and true or false + end + + function XMedalManager.CheckScoreTitleInTimeByType(type) + local scoreTitle = ScoreTitleList[type] + if not scoreTitle then + return false + end + for _, title in pairs(scoreTitle) do + local nowTime = XTime.GetServerNowTimestamp() + local beginTime, endTime = XFunctionManager.GetTimeByTimeId(title.TimeId) + if nowTime > beginTime and nowTime < endTime then + return true + end + end + return false + end + + function XMedalManager.UpdateScoreTitle() + for _, scoreTitle in pairs(ScoreTitleUnLockList) do + local scoreTitleData = ScoreTitleDataList[scoreTitle.Id] + if scoreTitleData then + scoreTitleData.IsLock = false + scoreTitleData.Quality = scoreTitle.Quality + scoreTitleData.Score = scoreTitle.Score + scoreTitleData.Time = scoreTitle.Time + if scoreTitle.ExpandInfo then + scoreTitleData.ExpandInfo = scoreTitle.ExpandInfo + end + end + end + end + + function XMedalManager.UpdateScoreTitleShowState(hideTypes) + for _, hideType in pairs(hideTypes or {}) do + local scoreTitleShowState = ScoreTitleShowStateList[hideType] + if scoreTitleShowState then + scoreTitleShowState.Hide = XMedalConfigs.Hide.ON + end + end + end + + function XMedalManager.SetScoreTitleUnLockList(scoreTitleInfoList) + for _, scoreTitle in pairs(scoreTitleInfoList or {}) do + ScoreTitleUnLockList[scoreTitle.Id] = scoreTitle + end + end + + function XMedalManager.AddScoreTitleUnLockList(titles, IsLogined) + for _, scoreTitleInfo in pairs(titles) do + local scoreTitleData = ScoreTitleDataList[scoreTitleInfo.Id] + if scoreTitleData then + local scoreTitleUnLock = ScoreTitleUnLockList[scoreTitleInfo.Id] + if not scoreTitleUnLock then + scoreTitleUnLock = scoreTitleInfo + XDataCenter.MedalManager.AddNewMedal(scoreTitleInfo.Id, scoreTitleData.Type) + if scoreTitleData.IsNotShowGetTip ~= 1 then + table.insert(NewCollectionList, scoreTitleInfo.Id) + end + ScoreTitleUnLockList[scoreTitleInfo.Id] = scoreTitleUnLock + else + scoreTitleUnLock.Score = scoreTitleInfo.Score + if scoreTitleUnLock.Quality ~= scoreTitleInfo.Quality then + + if scoreTitleData.ShowQualityUpTip == XMedalConfigs.ShowScore.ON then + local qualityUpCollection = QualityUpCollectionList[scoreTitleInfo.Id] + if not qualityUpCollection then + qualityUpCollection = {} + qualityUpCollection.BeforeQuality = scoreTitleUnLock.Quality + qualityUpCollection.AfterQuality = scoreTitleInfo.Quality + QualityUpCollectionList[scoreTitleInfo.Id] = qualityUpCollection + else + qualityUpCollection.AfterQuality = scoreTitleInfo.Quality + end + end + scoreTitleUnLock.Quality = scoreTitleInfo.Quality + XDataCenter.MedalManager.AddNewMedal(scoreTitleInfo.Id, scoreTitleData.Type) + end + end + else + XLog.Error("Share/ScoreTitle/ScoreTitle.tab 表中不存在 ScoreTitleId: " .. scoreTitleInfo.Id) + end + end + + if #NewCollectionList > 0 and IsLogined then + XEventManager.DispatchEvent(XEventId.EVENT_SCORETITLE_NEW) + end + end + + function XMedalManager.ClearQualityUpCollectionById(id) + if QualityUpCollectionList[id] then + QualityUpCollectionList[id] = nil + end + end + + function XMedalManager.SetScoreTitleShowData(list) + for _, showSetInfo in pairs(list or {}) do + local scoreTitleShowState = ScoreTitleShowStateList[showSetInfo.Type] + if scoreTitleShowState then + scoreTitleShowState.Hide = showSetInfo.Hide + end + end + end + + function XMedalManager.SetScoreTitleShow(list, cb) + XNetwork.Call(METHOD_NAME.ScoreTitleShowSetRequest, { ScoreTitleShowSetInfos = list }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XMedalManager.SetScoreTitleShowData(list) + if cb then + cb() + end + end) + end + + -- 设置基准图标宽度 + function XMedalManager.SetBaseIconWidth(baseIconWidth) + BaseIconWidth = baseIconWidth + end + + -- 获取基准图标宽度 + function XMedalManager.GetBaseIconWidth() + return BaseIconWidth or DEFAULT_BASE_ICON_WIDHT + end + + ---========================================== + --- 根据'score'的位数和图标宽度‘iconWidth’来得到相应字号 + ---@param score number + ---@param iconWidth number + ---@return number + ---========================================== + function XMedalManager.GetScoreSize(score, iconWidth) + if score == nil or score == 0 then + return nil + end + + local digit = math.floor(math.log(score, 10) + 1) + if digit > #XMedalConfigs.EnumCollectionScoreTextSize then + XLog.Warning("XMedalManager.GetScoreSize函数警告,分数" .. tostring(score) .. "位数大于ClientConfig配置的位数字号") + end + + -- 得到基准图标宽度和基准位数字号,基准位数字号通过配表读取 + local baseIconWidth = XMedalManager.GetBaseIconWidth() + local baseScoreSize = XMedalConfigs.EnumCollectionScoreTextSize[digit] + or XMedalConfigs.EnumCollectionScoreTextSize[#XMedalConfigs.EnumCollectionScoreTextSize] + + if baseIconWidth == 0 then + XLog.Error("XMedalManager.GetScoreSize函数错误,baseIconWidth为0") + return nil + end + + -- 根据比例来算出当前图标宽度对应的字号大小 + return math.floor((baseScoreSize * iconWidth) / baseIconWidth) + end + + --- + --- 设置特定收藏品的最大分数 + --- 把'13006500'机械扭蛋收藏品的最大分数限制为100 + --- 【1.21分支之后优化此代码】 + function XMedalManager.SetSpecificMaxScore(titleInfos) + if titleInfos then + for _, titleInfo in pairs(titleInfos) do + if titleInfo.Id == 13006500 then + if titleInfo.Score >= 100 then + titleInfo.Score = 100 + end + end + if titleInfo.Id == 13007500 then + if titleInfo.Score >= 50 then + titleInfo.Score = 50 + end + end + end + end + end + + ------------------------------------------计分徽章---------------------------------<<< + ------------------------------------------铭牌-------------------------------------- + local NameplateIdDic = {} + local NameplateGroupDic = {} + local NameplateSaveDic = {} + local NameplateRedPointDic = {} + local NameplateLastEqu = {} + local CurWearNameplate = 0 --当前穿戴的铭牌 + local UiNameplateIsOpen = false + --登陆下推 + function XMedalManager.AsyncNameplateLogin(data) + CurWearNameplate = data.CurrentWearNameplate + XMedalManager.InitNameplateSaveRedDic() + NameplateSaveDic = {} + for _, info in ipairs(data.UnlockNameplates) do + XMedalManager.UpdateNameplate(info, true) + NameplateSaveDic[info.Id] = true + end + --登陆时对红点的处理 + local redChange = false + local tmpNameplatePoint = {} + for nameplateId, _ in pairs(NameplateRedPointDic) do + if not NameplateIdDic[nameplateId] or NameplateIdDic[nameplateId]:IsNamepalteExpire() then + tmpNameplatePoint[nameplateId] = nil + if tmpNameplatePoint[nameplateId] then + redChange = true + end + else + if not tmpNameplatePoint[nameplateId] then + redChange = true + end + tmpNameplatePoint[nameplateId] = true + end + end + + if redChange then + NameplateRedPointDic = tmpNameplatePoint + XSaveTool.SaveData(string.format("%d%s", XPlayer.Id, "NameplateRedPointDic"), NameplateRedPointDic) + end + + XEventManager.DispatchEvent(XEventId.EVENT_NAMEPLATE_CHANGE) + end + + --服务端下推处理 铭牌更新 + function XMedalManager.AsyncUpateNameplate(data) + --XLog.Debug("AsyncUpateNameplate", data) + XMedalManager.UpdateNameplate(data) + end + + --服务端下推处理(真实处理数据) + function XMedalManager.UpdateNameplate(data, isLogin) + local nameplateData, lastNameplateData + local redChange = false + local haveNameplateUp = false + local isGetNameplateNew = false + local NameplateGroupId = XMedalConfigs.GetNameplateGroup(data.Id) + if not NameplateGroupDic[NameplateGroupId] then + nameplateData = XNameplate.New(data) + haveNameplateUp = true + else + lastNameplateData = NameplateGroupDic[NameplateGroupId] + if isLogin then + XLog.Error("铭牌数据异常,请服务端检查:", "LastId: " ,lastNameplateData:GetNameplateId(), "Id: ", data.Id, "GroupId: ", NameplateGroupId) + end + if lastNameplateData:GetNameplateId() == data.Id then + if lastNameplateData:IsNamepalteExpire() then --如果过期的刷新时间 可以重新激活红点 + isGetNameplateNew = true + if CurWearNameplate and CurWearNameplate == lastNameplateData:GetNameplateId() then--如果当前存储的已佩戴铭牌过期 重新设置缓存 + CurWearNameplate = 0 + end + end + nameplateData = NameplateGroupDic[NameplateGroupId] + nameplateData:UpdateData(data) + else + if lastNameplateData:IsNamepalteExpire() then --如果当前存储的已佩戴铭牌过期 重新设置缓存 + if CurWearNameplate and CurWearNameplate == lastNameplateData:GetNameplateId() then + CurWearNameplate = 0 + end + end + nameplateData = XNameplate.New(data) + --if lastNameplateData:GetNameplateQuality() < nameplateData:GetNameplateQuality() then + if nameplateData:GetNameplateUpgradeType() == XMedalConfigs.NameplateGetType.TypeFour then --如果铭牌类型是转换道具 暂时不删除信息 帮助转换道具的下推保存数据 + + else + NameplateIdDic[lastNameplateData:GetNameplateId()] = nil --如果铭牌发生变化,清理上一次的更新 + end + if lastNameplateData:GetNameplateId() == CurWearNameplate then + CurWearNameplate = nameplateData:GetNameplateId() + end + + if NameplateRedPointDic[lastNameplateData:GetNameplateId()] then + NameplateSaveDic[lastNameplateData:GetNameplateId()] = true + NameplateRedPointDic[lastNameplateData:GetNameplateId()] = nil + redChange = true + end + haveNameplateUp = true + -- else + -- NameplateSaveDic[data.Id] = true + -- end + end + end + + --铭牌发生替换时 处理保存的逻辑 + if haveNameplateUp then + NameplateIdDic[data.Id] = nameplateData + NameplateGroupDic[NameplateGroupId] = nameplateData + end + + + if not isLogin then + if not NameplateSaveDic[data.Id] or isGetNameplateNew then --如果本地没有存储过这个铭牌的信息或者是新获得的记录红点 + if not NameplateRedPointDic[data.Id] then + redChange = true + end + NameplateRedPointDic[data.Id] = true + end + + if (not nameplateData:IsNamepalteExpire() and nameplateData:GetNameplateUpgradeType() ~= XMedalConfigs.NameplateGetType.TypeFour) --如果获得的铭牌没有过期,并且不是转换道具的铭牌 进入弹窗逻辑 + or ((haveNameplateUp or isGetNameplateNew) and nameplateData:GetNameplateUpgradeType() == XMedalConfigs.NameplateGetType.TypeFour) --如果是转换道具的铭牌并且铭牌是新获得或者升级 进入弹窗逻辑 + then + if isGetNameplateNew then + lastNameplateData = nil + end + XLuaUiManager.Open("UiObtainNameplate", nameplateData, lastNameplateData) + UiNameplateIsOpen = true + end + + if redChange then + XEventManager.DispatchEvent(XEventId.EVENT_NAMEPLATE_CHANGE) + XSaveTool.SaveData(string.format("%d%s", XPlayer.Id, "NameplateRedPointDic"), NameplateRedPointDic) + end + end + + end + + --服务端下推处理 铭牌转换道具 + function XMedalManager.NameplateConvertItem(data) + local nameplateData = NameplateIdDic[data.NameplateId] + NameplateIdDic[data.NameplateId] = nil + if not nameplateData then + local groupId = XMedalConfigs.GetNameplateGroup(data.NameplateId) + local dataByGroup = NameplateGroupDic[groupId] + local tmpData = {} + tmpData.Id = data.NameplateId + tmpData.Exp = 0 + tmpData.EndTime = dataByGroup and dataByGroup:GetNamepalteEndTime() or 0 + tmpData.GetTime = dataByGroup and dataByGroup:GetNamepalteGetTime() or 0 + nameplateData = XNameplate.New(tmpData) + end + XLuaUiManager.Open("UiObtainNameplate", nameplateData, false, data.ConvertItem, data.ConvertCount) + + -- if UiNameplateIsOpen then + -- local tmpData = {} + -- tmpData.NameplateData = nameplateData + -- tmpData.ConvertItem = data.ConvertItem + -- tmpData.ConvertCount = data.ConvertCount + -- table.insert(NameplateLastEqu, tmpData) + -- else + -- if not nameplateData then + -- local tmpData = {} + -- tmpData.Id = data.NameplateId + -- tmpData.Exp = 0 + -- tmpData.EndTime = 0 + -- tmpData.GetTime = 0 + -- nameplateData = XNameplate.New(tmpData) + -- end + -- XLuaUiManager.Open("UiObtainNameplate", nameplateData, false, data.ConvertItem, data.ConvertCount) + -- UiNameplateIsOpen = true + -- end + end + + --获取铭牌数据列表(真实数据信息 + function XMedalManager.GetNameplateGroupList() + local nameplateGroup = {} + for _, data in pairs(NameplateGroupDic) do + table.insert(nameplateGroup, data) + end + table.sort(nameplateGroup, function(a, b) + if a:IsNameplateNew() and not b:IsNameplateNew() then + return true + elseif a:IsNameplateNew() == b:IsNameplateNew() then + if a:IsNameplateDress() and not b:IsNameplateDress() then + return true + elseif a:IsNameplateDress() == b:IsNameplateDress() then + -- if not a:IsNamepalteExpire() and b:IsNamepalteExpire() then + -- return true + -- elseif a:IsNamepalteExpire() == b:IsNamepalteExpire() then + -- return a:GetNameplateId() < b:GetNameplateId() + -- end + if a:IsNamepalteForever() and not b:IsNamepalteForever() then + return true + elseif a:IsNamepalteForever() == b:IsNamepalteForever() then + if a:GetNamepalteLeftTime() > b:GetNamepalteLeftTime() then + return true + elseif a:GetNamepalteLeftTime() == b:GetNamepalteLeftTime() then + return a:GetNameplateId() < b:GetNameplateId() + end + end + end + end + return false + end) + return nameplateGroup + end + + --打开获取铭牌界面(栈方式 暂时废弃 + function XMedalManager.OpenNextUiObtainNameplate() + UiNameplateIsOpen = false + if #NameplateLastEqu > 0 then + local tmpData = table.remove(NameplateLastEqu, 1) + XLuaUiManager.Open("UiObtainNameplate", tmpData.NameplateData, false, tmpData.ConvertItem, tmpData.ConvertCount) + end + end + + --根据GroupId获取服务端推送的铭牌实体数据 + function XMedalManager.CheckNameplateGroupUnluck(group) + return NameplateGroupDic[group] + end + + --获取当前装备的铭牌 + function XMedalManager.GetNameplateCurId() + return CurWearNameplate + end + + --检查是不是新获得的铭牌(红点) + function XMedalManager.CheckNameplateNew(id) + if not NameplateRedPointDic[id] then + return false + end + return true + end + + --初始化本地持久化数据的红点信息 + function XMedalManager.InitNameplateSaveRedDic() + --NameplateSaveDic = XSaveTool.GetData(string.format("%d%s", XPlayer.Id, "NameplateSaveDic")) or {} + NameplateRedPointDic = XSaveTool.GetData(string.format("%d%s", XPlayer.Id, "NameplateRedPointDic")) or {} + end + + --根据规则处理红点的隐藏 + function XMedalManager.SetNameplateRedPointDic(id) + local needChangeRed = false + if not id then + for _, nameplateData in pairs(NameplateGroupDic) do + if NameplateRedPointDic[nameplateData:GetNameplateId()] then + needChangeRed = true + end + NameplateSaveDic[nameplateData:GetNameplateId()] = true + NameplateRedPointDic[nameplateData:GetNameplateId()] = nil + end + else + if NameplateRedPointDic[id] then + NameplateSaveDic[id] = true + NameplateRedPointDic[id] = nil + needChangeRed = true + end + end + + if needChangeRed then + --XSaveTool.SaveData(string.format("%d%s", XPlayer.Id, "NameplateSaveDic"), NameplateSaveDic) + XSaveTool.SaveData(string.format("%d%s", XPlayer.Id, "NameplateRedPointDic"), NameplateRedPointDic) + XEventManager.DispatchEvent(XEventId.EVENT_NAMEPLATE_CHANGE) + end + end + + function XMedalManager.CheckHaveNewNameplateById(id) + return NameplateRedPointDic[id] + end + + --检查是否有新的铭牌 + function XMedalManager.CkeckHaveNewNameplate() + if not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.Nameplate) then + if XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.Nameplate) then + for _, data in pairs(NameplateGroupDic) do + if data:IsNameplateNew() then + return true + end + end + end + end + return false + end + + --佩戴铭牌请求 + function XMedalManager.WearNameplate(nameplateId, cb) + XNetwork.Call(METHOD_NAME.WearNameplateRequest, { NameplateId = nameplateId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + CurWearNameplate = nameplateId + if cb then + cb() + end + XEventManager.DispatchEvent(XEventId.EVENT_NAMEPLATE_CHANGE) + end) + end + + ------------------------------------------铭牌-------------------------------------- + XMedalManager.Init() + return XMedalManager +end + +XRpc.NotifyMedalData = function(data) + if not data then + return + end + XPlayer.AsyncMedalIds(data.MedalInfos, false) + XDataCenter.MedalManager.UpdateMedalList() +end + +XRpc.NotifyUpdateMedalData = function(data) + if not data then + return + end + XPlayer.AsyncMedalIds(data.UpdateInfo, true) + XDataCenter.MedalManager.SetNewMedalId(data.UpdateInfo.Id) + XDataCenter.MedalManager.UpdateMedalList() + --CheckPoint: APPEVENT_BADGE + XAppEventManager.MedalAppLogEvent(data.UpdateInfo.Id) + XEventManager.DispatchEvent(XEventId.EVENT_MEDAL_NOTIFY) +end + +XRpc.NotifyScoreTitleData = function(data) + XDataCenter.MedalManager.SetSpecificMaxScore(data.TitleInfos) + XDataCenter.MedalManager.SetScoreTitleUnLockList(data.TitleInfos) + XDataCenter.MedalManager.UpdateScoreTitleShowState(data.HideTypes) + XDataCenter.MedalManager.UpdateScoreTitle() + + -- 全部已解锁的收藏品墙与装饰品数据 + XDataCenter.CollectionWallManager.SyncWallEntityData(data.WallInfos) + XDataCenter.CollectionWallManager.SyncDecorationData(data.UnlockedDecorationIds) +end + +XRpc.NotifyScoreTitleInfo = function(data) + XDataCenter.MedalManager.SetSpecificMaxScore(data.Titles) + XDataCenter.MedalManager.AddScoreTitleUnLockList(data.Titles, data.IsLogined) + XDataCenter.MedalManager.UpdateScoreTitle() + XEventManager.DispatchEvent(XEventId.EVENT_SCORETITLE_CHANGE) +end + +--铭牌登陆下推 +XRpc.NotifyNameplateLoginData = function(data) + XDataCenter.MedalManager.AsyncNameplateLogin(data) +end + +--铭牌信息改变下推 +XRpc.NotifyNameplateInfo = function(data) + if data.Nameplate then + XDataCenter.MedalManager.AsyncUpateNameplate(data.Nameplate) + end +end + +--铭牌信息改变下推 +XRpc.NotifyNameplateConvertItem = function(data) + XDataCenter.MedalManager.NameplateConvertItem(data) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XMentorSystemManager.lua b/Resources/Scripts/XManager/XMentorSystemManager.lua new file mode 100644 index 00000000..68fc0464 --- /dev/null +++ b/Resources/Scripts/XManager/XMentorSystemManager.lua @@ -0,0 +1,926 @@ +XMentorSystemManagerCreator = function() + local XMentorDataEntity = require("XEntity/XMentorSystem/XMentorDataEntity") + + local XMentorSystemManager = {} + local CSTextManagerGetText = CS.XTextManager.GetText + local CSXGameClientConfig = CS.XGame.ClientConfig + + local MentorData = {} + local ApplyPlayerList = {} + local SpecifyPlayer = {} + local IsApplyListChange = true + local RecommendPlayerList = nil + local ApplyedIdList = {} + local TeacherChangeTaskList = {} + local MentorShipNameList = {} + local IsMentorShipComplete = false + local IsFirstShowTaskGetRedDot = true + + local DefaultIndex = 1 + local DefaultLenth = 1 + + local GraduateRewardList = {} + + local SYNC_TASKREQUEST_SECOND = 10 + local LastSyncTaskRequestTime = 0 + + local SYNC_NAMELISTEQUEST_SECOND = 10 + local SYNC_MESSAGE_SECOND = 1 + local LastSyncNameListRequestTime = 0 + local LastSyncMessageRequestTime = 0 + + local METHOD_NAME = { + GetMentorPlayerInfoListRequest = "GetMentorPlayerInfoListRequest",--获取玩家详情 + GetMentorSpecifyPlayerInfoRequest = "GetMentorSpecifyPlayerInfoRequest",--搜索玩家 + PublishAnnouncementRequest = "PublishAnnouncementRequest",--发布宣言 + OperationApplyMentorRequest = "OperationApplyMentorRequest",--处理申请,同意或者拒绝 + GetMentorRecommendPlayerListRequest = "GetMentorRecommendPlayerListRequest",--获取推荐导师/徒弟 + ApplyMentorRequest = "ApplyMentorRequest",--向师傅/徒弟申请 + TickMentorRequest = "TickMentorRequest",--向师傅/徒弟退出 + MentorGraduateRequest = "MentorGraduateRequest",--徒弟出师 + MentorGetChallengeRewardRequest = "MentorGetChallengeRewardRequest",--师傅领取徒弟的毕业挑战奖励 + MentorGetStageRewardRequest = "MentorGetStageRewardRequest",--师傅领取出师进度奖励 + MentorRefreshGraduateTaskRequest = "MentorRefreshGraduateTaskRequest",--师傅刷新徒弟的毕业任务 + StudentGetTaskProgressRewardRequest = "StudentGetTaskProgressRewardRequest",--徒弟领取每周进度奖励 + StudentReceiveDailyTaskRequest = "StudentReceiveDailyTaskRequest",--徒弟领取每周任务 + StudentDeleteDailyTaskRequest = "StudentDeleteDailyTaskRequest",--徒弟删除每周任务 + MentorGetChangeDailyTaskRequest = "MentorGetChangeDailyTaskRequest",--师傅获取需要更换的任务 + MentorChangeDailyTaskRequest = "MentorChangeDailyTaskRequest",--师傅更换徒弟的任务 + MentorGiveEquipRequest = "MentorGiveEquipRequest",--师傅赠送礼物 + StudentReceiveEquipRequest = "StudentReceiveEquipRequest",--徒弟领取意识 + MentorGetWeeklyTaskRewardRequest = "MentorGetWeeklyTaskRewardRequest",--师傅领取每周任务奖励 + MentorGetNameListRequest = "MentorGetNameListRequest",--获取家族系谱 + MentorPublishMessageBoardRequest = "MentorPublishMessageBoardRequest",--师傅发布留言 + MentorStudentSendRewardRequest = "MentorStudentSendRewardRequest",--徒弟送礼物给师傅 + } + + function XMentorSystemManager.Init() + ApplyPlayerList = {} + SpecifyPlayer = {} + IsApplyListChange = true + RecommendPlayerList = nil + ApplyedIdList = {} + TeacherChangeTaskList = {} + MentorShipNameList = {} + IsMentorShipComplete = false + IsFirstShowTaskGetRedDot = true + GraduateRewardList = {} + MentorData = XMentorDataEntity.New() + end + + function XMentorSystemManager.GetMentorData() + return MentorData + end + + function XMentorSystemManager.GetMentorChannelKey() + return string.format("MentorChannelKey_%s", tostring(XPlayer.Id)) + end + + function XMentorSystemManager.GetRecommendPlayerList() + local list = {} + local studentList = MentorData:GetStudentDataList() + local teacher = MentorData:GetTeacherData() + for _,player in pairs(RecommendPlayerList or {}) do + if not XDataCenter.SocialManager.GetBlackData(player.PlayerId) then + local IsNotIn = true + for _,student in pairs(studentList) do + if player.PlayerId == student.PlayerId then + IsNotIn = false + end + end + if player.PlayerId == teacher.PlayerId then + IsNotIn = false + end + if IsNotIn then + table.insert(list,player) + end + end + end + + return list + end + + function XMentorSystemManager.GetSpecifyPlayer() + return SpecifyPlayer + end + + function XMentorSystemManager.GetApplyPlayerList() + if XTool.IsTableEmpty(ApplyPlayerList) then + return ApplyPlayerList + end + + local applyPlayerList = {} + for _, v in ipairs(ApplyPlayerList) do + if not XDataCenter.SocialManager.GetBlackData(v.PlayerId) then + table.insert(applyPlayerList, v) + end + end + + return applyPlayerList + end + + function XMentorSystemManager.GetTeacherChangeTaskList() + return TeacherChangeTaskList + end + + function XMentorSystemManager.GetMentorShipNameList() + return MentorShipNameList + end + + function XMentorSystemManager.IsApplyed(id) + return ApplyedIdList[id] or false + end + + function XMentorSystemManager.SyncMentorData(data) + MentorData:UpdateData(data) + IsApplyListChange = true + end + + function XMentorSystemManager.SetMentorShipNameList(data) + MentorShipNameList = data + end + + function XMentorSystemManager.SetApplyPlayerList(data) + ApplyPlayerList = data + end + + function XMentorSystemManager.SetSpecifyPlayer(data) + SpecifyPlayer = data + end + + function XMentorSystemManager.SetRecommendPlayerList(data) + RecommendPlayerList = data or {} + end + + function XMentorSystemManager.ClearRecommendPlayerList() + RecommendPlayerList = nil + end + + function XMentorSystemManager.SetTeacherChangeTaskList(data) + TeacherChangeTaskList = data or {} + end + + function XMentorSystemManager.MarkFirstShowTaskGetRedDot() + IsFirstShowTaskGetRedDot = false + end + + function XMentorSystemManager.SetMentorShipComplete(IsTeacher) + if MentorData:IsTeacher() ~= IsTeacher then + IsMentorShipComplete = true + end + end + + function XMentorSystemManager.ShowMentorShipComplete() + local InMainUi = XLuaUiManager.IsUiShow("UiMain") + local InUiMentorMainUi = XLuaUiManager.IsUiShow("UiMentorMain") + local InUiMentorApplicationUi = XLuaUiManager.IsUiShow("UiMentorApplication") + local InUiMentorRecommendationUi = XLuaUiManager.IsUiShow("UiMentorRecommendation") + local InUiMentorRewardUi = XLuaUiManager.IsUiShow("UiMentorReward") + local InUiMentorTaskUi = XLuaUiManager.IsUiShow("UiMentorTask") + local IsCanDo = InMainUi or InUiMentorMainUi or InUiMentorApplicationUi or InUiMentorRecommendationUi or InUiMentorRewardUi or InUiMentorTaskUi + if IsCanDo and IsMentorShipComplete then + XUiManager.TipText("MentorShipComplete") + IsMentorShipComplete = false + end + end + + function XMentorSystemManager.AddMentorApply(applyData) + if MentorData:AddApplyId(applyData) then + IsApplyListChange = true + end + end + + function XMentorSystemManager.AddApplyedIdList(ids) + for _,id in pairs(ids) do + ApplyedIdList[id] = true + end + end + + function XMentorSystemManager.ClearApplyedIdList() + ApplyedIdList = {} + end + + function XMentorSystemManager.ClearManifesto() + MentorData:InitManifesto() + end + + function XMentorSystemManager.AddWeeklyTaskReward(count) + MentorData:AddWeeklyTaskReward(count) + end + + function XMentorSystemManager.AddStageReward(count) + MentorData:AddStageReward(count) + end + + function XMentorSystemManager.AddTeacher(data) + MentorData:AddTeacher(data.Teacher, data.Students, data.Message) + end + + function XMentorSystemManager.RemoveTeacher() + MentorData:RemoveTeacher() + end + + function XMentorSystemManager.AddStudent(data) + MentorData:AddStudent(data.Student) + end + + function XMentorSystemManager.RemoveStudent(data) + MentorData:RemoveStudent(data.Student) + end + + function XMentorSystemManager.GraduateStudent(data) + MentorData:GraduateStudent(data.Student) + end + + function XMentorSystemManager.UpdateMentorData(Data) + if Data then + MentorData:UpdateData(Data) + end + end + + function XMentorSystemManager.UpdateStudentSystemTaskById(systemTask, id) + MentorData:UpdateStudentSystemTaskById(systemTask, id) + end + + function XMentorSystemManager.UpdateStudentWeeklyTaskById(weeklyTask, id) + MentorData:UpdateStudentWeeklyTaskById(weeklyTask, id) + end + + function XMentorSystemManager.UpdateMemberLevelById(level, id) + MentorData:UpdateMemberLevelById(level, id) + end + + function XMentorSystemManager.UpdateMemberOnLineState(IsOnLine, lastLoginTime, id) + MentorData:UpdateMemberOnLineState(IsOnLine, lastLoginTime, id) + end + + function XMentorSystemManager.UpdateStudentSendGiftCount(id) + MentorData:UpdateStudentSendGiftCount(id) + end + + function XMentorSystemManager.WeekReset() + MentorData:WeekReset() + end + + function XMentorSystemManager.DayReset() + MentorData:DayReset() + end + + function XMentorSystemManager.ClearApplyList() + MentorData:ClearApplyIdList() + ApplyPlayerList = {} + end + + function XMentorSystemManager.RemoveApplyList(Id) + MentorData:RemoveApplyId(Id) + for index = #ApplyPlayerList, 1, -1 do + if ApplyPlayerList[index].PlayerId == Id then + table.remove(ApplyPlayerList,index) + end + end + end + + function XMentorSystemManager.SetGraduateReward(rewardList) + GraduateRewardList = rewardList + end + + function XMentorSystemManager.RemoveGraduateReward() + GraduateRewardList = nil + end + + function XMentorSystemManager.GetGraduateReward() + return GraduateRewardList + end + + function XMentorSystemManager.CheckHaveGraduateReward() + local IsHave = false + if GraduateRewardList and next(GraduateRewardList) then + XLuaUiManager.Open("UiMentorGraduation", GraduateRewardList, function () + XEventManager.DispatchEvent(XEventId.EVENT_FUNCTION_EVENT_COMPLETE) + end) + XMentorSystemManager.RemoveGraduateReward() + IsHave = true + end + return IsHave + end + + function XMentorSystemManager.AutoGraduateRunMain() + local InUiMentorMainUi = XLuaUiManager.IsUiShow("UiMentorMain") + local InUiMentorApplicationUi = XLuaUiManager.IsUiShow("UiMentorApplication") + local InUiMentorRecommendationUi = XLuaUiManager.IsUiShow("UiMentorRecommendation") + local InUiMentorRewardUi = XLuaUiManager.IsUiShow("UiMentorReward") + local InUiMentorTaskUi = XLuaUiManager.IsUiShow("UiMentorTask") + local InUiMentorDeclarationUi = XLuaUiManager.IsUiShow("UiMentorDeclaration") + local InUiMentorSelectTaskUi = XLuaUiManager.IsUiShow("UiMentorSelectTask") + local InUiMentorFileUi = XLuaUiManager.IsUiShow("UiMentorFile") + + local IsCanDo = InUiMentorMainUi or InUiMentorApplicationUi or InUiMentorRecommendationUi or InUiMentorRewardUi or InUiMentorTaskUi or InUiMentorDeclarationUi or InUiMentorSelectTaskUi or InUiMentorFileUi + if IsCanDo then + XLuaUiManager.RunMain() + end + end + ---------------------------------------------------------------------------------------------------学生用红点检测 + function XMentorSystemManager.CheckStudentCanGraduate() + local graduateLv = XMentorSystemConfigs.GetMentorSystemData("GraduateLv") + return XPlayer.Level >= graduateLv + end + + function XMentorSystemManager.CheckStudentCanSendGift() + return MentorData:CheckStudentCanSendGiftByIndex(XMentorSystemConfigs.MySelfIndex) + end + + function XMentorSystemManager.CheckStudentCanGetTask() + local curGetedCount = MentorData:GetStudentWeeklyTaskCountByIndex(XMentorSystemConfigs.MySelfIndex) + local maxWeeklyCount = XMentorSystemConfigs.GetMentorSystemData("CompleteTaskCount") + local curDaliyCount = MentorData:GetStudentSystemTaskCountByIndex(XMentorSystemConfigs.MySelfIndex) + local maxDaliyCount = XMentorSystemConfigs.GetMentorSystemData("GetTaskCount") + return curGetedCount < maxWeeklyCount and curDaliyCount < maxDaliyCount and IsFirstShowTaskGetRedDot + end + + function XMentorSystemManager.CheckStudentCanGetWeeklyReward() + local rewardList = MentorData:GetStudentWeeklyRewardList() + + for _,reward in pairs(rewardList or {}) do + local IsCanGet = MentorData:CheckStudentWeeklyRewardCanGetByCount(reward.Count) + local IsGeted = MentorData:CheckStudentWeeklyRewardGetedByCount(reward.Count) + if IsCanGet and not IsGeted then + return true + end + end + return false + end + + function XMentorSystemManager.CheckStudentCanGetTeacherGift() + local studentData = MentorData:GetNotGraduateStudentDataByIndex(XMentorSystemConfigs.MySelfIndex) + if studentData then + for _,task in pairs(studentData.WeeklyTask or {}) do + if task.Status == XMentorSystemConfigs.TaskStatus.GiveEquip then + return true + end + end + end + return false + end + + function XMentorSystemManager.JudgeFailPassTime(lastLoginTime) + local failPassTime = XMentorSystemConfigs.GetMentorSystemData("JudgeFailPassTime") + local nowTime = XTime.GetServerNowTimestamp() + return nowTime - lastLoginTime > failPassTime * 60 + end + + ---------------------------------------------------------------------------------------------------老师用红点检测 + function XMentorSystemManager.CheckTeacherCanGetStudentTaskReward() + for _,student in pairs(MentorData:GetStudentDataList() or {}) do + if XMentorSystemManager.CheckTeacherCanGetStudentTaskRewardByStudent(student) then + return true + end + end + return false + end + + function XMentorSystemManager.CheckTeacherCanGetStudentTaskRewardByStudent(student) + if student and student.IsGraduate then + for _,task in pairs(student.StudentTask or {}) do + if task.State == XDataCenter.TaskManager.TaskState.Achieved then + return true + end + end + end + return false + end + + function XMentorSystemManager.CheckTeacherCanGetGraduateReward() + local rewardList = MentorData:GetTeacherStageRewardList() + + for _,reward in pairs(rewardList or {}) do + local IsCanGet = MentorData:CheckTeacherStageRewardCanGetByCount(reward.Count) + local IsGeted = MentorData:CheckTeacherStageRewardGetedByCount(reward.Count) + if IsCanGet and not IsGeted then + return true + end + end + return false + end + + function XMentorSystemManager.CheckTeacherCanGetStudentWeeklyReward() + for _,student in pairs(MentorData:GetNotGraduateStudentDataList() or {}) do + if XMentorSystemManager.CheckTeacherCanGetStudentWeeklyRewardByStudent(student) then + return true + end + end + return false + end + + function XMentorSystemManager.CheckTeacherCanGetStudentWeeklyRewardByStudent(student) + local taskList = student and student.WeeklyTask or {} + for _,task in pairs(taskList) do + if task.Status == XMentorSystemConfigs.TaskStatus.Completed then + return true + end + end + return false + end + ----------------------------------------------------------------------------------------------Message + function XMentorSystemManager.CheckHasNewMessage(messageTime) + local exTime = XSaveTool.GetData(string.format("%d%s", XPlayer.Id, "MentorMessage")) + if not exTime or (exTime and exTime < messageTime)then + XSaveTool.SaveData(string.format("%d%s", XPlayer.Id, "MentorMessage"),messageTime) + return messageTime > 0 + end + return false + end + ----------------------------------------------------------------------------------------------TeacherGift + function XMentorSystemManager.SaveTeacherGiftData(itemId, count) + local teacherGiftData = XMentorSystemManager.GetTeacherGift() + if itemId and count then + if teacherGiftData then + teacherGiftData.Count = teacherGiftData.Count + count + XSaveTool.SaveData(string.format("%d%s", XPlayer.Id, "MentorTeacherGift"),teacherGiftData) + else + local monday = 1 + local tmpData = {} + tmpData.ItemId = itemId + tmpData.Count = count + tmpData.ResetTime = XTime.GetSeverNextWeekOfDayRefreshTime(monday) + XSaveTool.SaveData(string.format("%d%s", XPlayer.Id, "MentorTeacherGift"),tmpData) + end + end + end + + function XMentorSystemManager.GetTeacherGift() + local teacherGiftData = XSaveTool.GetData(string.format("%d%s", XPlayer.Id, "MentorTeacherGift")) + local nowTime = XTime.GetServerNowTimestamp() + if teacherGiftData and teacherGiftData.ResetTime then + if nowTime >= teacherGiftData.ResetTime then + XSaveTool.RemoveData(string.format("%d%s", XPlayer.Id, "MentorTeacherGift")) + else + return teacherGiftData + end + end + return nil + end + + function XMentorSystemManager.ShowTeacherGift() + local teacherGiftData = XMentorSystemManager.GetTeacherGift() + if teacherGiftData then + XSaveTool.RemoveData(string.format("%d%s", XPlayer.Id, "MentorTeacherGift")) + end + return teacherGiftData + end + ---------------------------------------------------------------------------------------------- + function XMentorSystemManager.GetMentorPlayerInfoListRequest(Ids, cb)--获取玩家详情 + if not IsApplyListChange or not( Ids and next(Ids)) then + if cb then cb() end + return + end + XNetwork.Call(METHOD_NAME.GetMentorPlayerInfoListRequest, {Ids = Ids}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XMentorSystemManager.SetApplyPlayerList(res.PlayerInfoList) + IsApplyListChange = false + if cb then cb() end + end) + end + + function XMentorSystemManager.GetMentorRecommendPlayerListRequest(cb)--获取推荐导师/徒弟 + if RecommendPlayerList then + if cb then cb() end + return + end + XNetwork.Call(METHOD_NAME.GetMentorRecommendPlayerListRequest, {}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + XMentorSystemManager.SetRecommendPlayerList() + if cb then cb() end + return + end + XMentorSystemManager.ClearApplyedIdList() + XMentorSystemManager.SetRecommendPlayerList(res.RecommendList) + if cb then cb() end + end) + end + + function XMentorSystemManager.GetMentorSpecifyPlayerInfoRequest(Id, cb)--搜索玩家 + if not Id then + XUiManager.TipText("MentorPlayerIdErrorText") + return + end + XNetwork.Call(METHOD_NAME.GetMentorSpecifyPlayerInfoRequest, {Id = Id}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XMentorSystemManager.SetSpecifyPlayer(res.PlayerInfo) + if cb then cb() end + end) + end + + function XMentorSystemManager.PublishAnnouncementRequest(tags, onlineTags, announcement, cb)--发布宣言 + XNetwork.Call(METHOD_NAME.PublishAnnouncementRequest, {Tags = tags, OnlineTags = onlineTags, Announcement = announcement}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + local tmpData = {} + tmpData.Tag = tags + tmpData.OnlineTag = onlineTags + tmpData.Announcement = announcement + MentorData:UpdateData(tmpData) + if cb then cb() end + end) + end + + function XMentorSystemManager.OperationApplyMentorRequest(targetPlayerIds, IsAccept, IsAll, cb)--处理申请,同意或者拒绝(可同时多个) + if not (targetPlayerIds and next(targetPlayerIds)) then + return + end + XNetwork.Call(METHOD_NAME.OperationApplyMentorRequest, {TargetPlayerId = targetPlayerIds, IsAccept = IsAccept}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code)--此处失败也会执行下方逻辑 + end + + if IsAll then + XMentorSystemManager.ClearApplyList() + else + XMentorSystemManager.RemoveApplyList(targetPlayerIds[DefaultIndex]) + end + XEventManager.DispatchEvent(XEventId.EVENT_MENTOR_OPERATION_APPLY) + if cb then cb() end + end) + end + + function XMentorSystemManager.ApplyMentorRequest(targetPlayerIds, cb)--向师傅/徒弟申请(可同时多个) + if not (targetPlayerIds and next(targetPlayerIds)) then + return + end + XNetwork.Call(METHOD_NAME.ApplyMentorRequest, {TargetPlayerId = targetPlayerIds}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XMentorSystemManager.AddApplyedIdList(targetPlayerIds) + if cb then cb() end + end) + end + + function XMentorSystemManager.TickMentorRequest(targetPlayerId, cb)--向师傅/徒弟退出 + XNetwork.Call(METHOD_NAME.TickMentorRequest, {TargetPlayerId = targetPlayerId}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + if cb then cb() end + end) + end + + function XMentorSystemManager.MentorGetChallengeRewardRequest(studentId, taskId, cb)--师傅领取徒弟的毕业挑战奖励 + XNetwork.Call(METHOD_NAME.MentorGetChallengeRewardRequest, {StudentId = studentId, TaskId = taskId}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XMentorSystemManager.MentorRefreshGraduateTaskRequest(function () + if cb then cb(res.RewardGoodsList) end + XEventManager.DispatchEvent(XEventId.EVENT_MENTOR_GETREWARD) + end,true) + end) + end + + function XMentorSystemManager.MentorGetStageRewardRequest(count, cb)--师傅领取出师进度奖励 + XNetwork.Call(METHOD_NAME.MentorGetStageRewardRequest, {Index = count}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XMentorSystemManager.AddStageReward(count) + if cb then cb(res.RewardGoodsList) end + XEventManager.DispatchEvent(XEventId.EVENT_MENTOR_GETREWARD) + end) + end + + function XMentorSystemManager.StudentGetTaskProgressRewardRequest(count, cb)--徒弟领取每周进度奖励 + XNetwork.Call(METHOD_NAME.StudentGetTaskProgressRewardRequest, {Index = count}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XMentorSystemManager.AddWeeklyTaskReward(count) + if cb then cb(res.RewardGoodsList) end + XEventManager.DispatchEvent(XEventId.EVENT_MENTOR_GETREWARD) + end) + end + + function XMentorSystemManager.MentorRefreshGraduateTaskRequest(cb,IsNotCD)--师傅刷新徒弟的毕业进度 + local now = XTime.GetServerNowTimestamp() + local syscTime = LastSyncTaskRequestTime + if syscTime and now - syscTime < SYNC_TASKREQUEST_SECOND and not IsNotCD then + if cb then cb() end + return + end + XNetwork.Call(METHOD_NAME.MentorRefreshGraduateTaskRequest, {}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + local tmpData = {} + tmpData.Students = res.Students + MentorData:UpdateData(tmpData) + LastSyncTaskRequestTime = XTime.GetServerNowTimestamp() + if cb then cb() end + end) + end + + function XMentorSystemManager.MentorGraduateRequest(cb)--徒弟毕业 + XNetwork.Call(METHOD_NAME.MentorGraduateRequest, {}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + if cb then cb(res.RewardGoodsList) end + end) + end + + function XMentorSystemManager.MentorGetChangeDailyTaskRequest(studentId, cb)--师傅获取需要更换的任务 + XNetwork.Call(METHOD_NAME.MentorGetChangeDailyTaskRequest, {StudentId = studentId}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XMentorSystemManager.SetTeacherChangeTaskList(res.TaskIds) + if cb then cb() end + end) + end + + function XMentorSystemManager.MentorGetWeeklyTaskRewardRequest(studentId, taskId, cb)--师傅领取每周任务奖励 + XNetwork.Call(METHOD_NAME.MentorGetWeeklyTaskRewardRequest, {StudentId = studentId, TaskId = taskId}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + if cb then cb(res.RewardGoodsList) end + XEventManager.DispatchEvent(XEventId.EVENT_MENTOR_GETREWARD) + end) + end + + function XMentorSystemManager.StudentDeleteDailyTaskRequest(taskId, cb)--徒弟删除每周任务 + XNetwork.Call(METHOD_NAME.StudentDeleteDailyTaskRequest, {TaskId = taskId}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + if cb then cb() end + end) + end + + function XMentorSystemManager.MentorChangeDailyTaskRequest(oldTaskId, newTaskId, studentId, cb)--师傅更换徒弟的任务 + XNetwork.Call(METHOD_NAME.MentorChangeDailyTaskRequest, {OldTaskId = oldTaskId, NewTaskId = newTaskId, StudentId = studentId}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + if cb then cb() end + XEventManager.DispatchEvent(XEventId.EVENT_MENTOR_TEACHER_CHANGECOUNT_PLUS) + end) + end + + function XMentorSystemManager.StudentReceiveDailyTaskRequest(taskId, cb)--徒弟领取每周任务 + XNetwork.Call(METHOD_NAME.StudentReceiveDailyTaskRequest, {TaskId = taskId}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + if cb then cb() end + end) + end + + function XMentorSystemManager.MentorGiveRewardRequest(studentId, taskId, cb, errorCb)--师傅赠送礼物 + XNetwork.Call(METHOD_NAME.MentorGiveEquipRequest, {StudentId = studentId, TaskId = taskId}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + if errorCb then errorCb() end + return + end + if cb then cb() end + end) + end + + function XMentorSystemManager.StudentReceiveRewardRequest(taskId, cb)--徒弟领取礼物 + XNetwork.Call(METHOD_NAME.StudentReceiveEquipRequest, {TaskId = taskId}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + if cb then cb(res.RewardGoodsList) end + XEventManager.DispatchEvent(XEventId.EVENT_MENTOR_GETREWARD) + end) + end + + function XMentorSystemManager.MentorGetNameListRequest(cb)--获取师承关系表 + local now = XTime.GetServerNowTimestamp() + local syscTime = LastSyncNameListRequestTime + if syscTime and now - syscTime < SYNC_NAMELISTEQUEST_SECOND then + if cb then cb() end + return + end + XNetwork.Call(METHOD_NAME.MentorGetNameListRequest, {}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XMentorSystemManager.SetMentorShipNameList(res.StudentNameList) + LastSyncNameListRequestTime = XTime.GetServerNowTimestamp() + if cb then cb() end + end) + end + + function XMentorSystemManager.MentorPublishMessageBoardRequest(message, cb)--师傅发布留言 + local now = XTime.GetServerNowTimestamp() + local syscTime = LastSyncMessageRequestTime + if syscTime and now - syscTime < SYNC_MESSAGE_SECOND then + XUiManager.TipText("RegressionAcceptInvitationUseCodeFrequently") + return + end + XNetwork.Call(METHOD_NAME.MentorPublishMessageBoardRequest, {Message = message}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + LastSyncMessageRequestTime = XTime.GetServerNowTimestamp() + if cb then cb() end + end) + end + + function XMentorSystemManager.MentorStudentSendRewardRequest(teacherId, cb)--徒弟送礼物给师傅 + XNetwork.Call(METHOD_NAME.MentorStudentSendRewardRequest, {MentorId = teacherId}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XDataCenter.MentorSystemManager.UpdateStudentSendGiftCount(XPlayer.Id) + if cb then cb() end + end) + end + + XMentorSystemManager.Init() + return XMentorSystemManager +end + +----------------------------------通用---------------------------------------->>>>> +XRpc.NotifyMentorData = function(data)--师徒信息(登录时) + XDataCenter.MentorSystemManager.SyncMentorData(data) +end + +XRpc.NotifyAddMentorApply = function(data)--收到申请消息 + XDataCenter.MentorSystemManager.AddMentorApply(data) + XEventManager.DispatchEvent(XEventId.EVENT_MENTOR_GET_APPLY, true) + XLog.Debug("MentorSystem-AddMentorApply") +end + +XRpc.NotifyAddStudent = function(data)--增加一个学生 + XDataCenter.MentorSystemManager.AddStudent(data) + XDataCenter.MentorSystemManager.SetMentorShipComplete(false) + XDataCenter.MentorSystemManager.ShowMentorShipComplete() + XEventManager.DispatchEvent(XEventId.EVENT_MENTOR_GET_STUDENT) + XEventManager.DispatchEvent(XEventId.EVENT_MENTOR_TEACHERORSTUDENT_CHANGE) + XLog.Debug("MentorSystem-AddStudent") +end + +XRpc.NotifyDeleteStudent = function(data)--减少一个学生 + XDataCenter.MentorSystemManager.RemoveStudent(data) + XEventManager.DispatchEvent(XEventId.EVENT_MENTOR_LOSE_STUDENT) + XEventManager.DispatchEvent(XEventId.EVENT_MENTOR_TEACHERORSTUDENT_CHANGE) + XLog.Debug("MentorSystem-RemoveStudent") +end + +XRpc.NotifyMentorChangeData = function(data)--身份改变 + XDataCenter.MentorSystemManager.ClearManifesto() + XDataCenter.MentorSystemManager.ClearRecommendPlayerList() + XDataCenter.MentorSystemManager.ClearApplyList() + XDataCenter.MentorSystemManager.SyncMentorData(data) + XEventManager.DispatchEvent(XEventId.EVENT_MENTOR_SHIPCHANGE) + XLog.Debug("MentorSystem-MentorShipChange") +end + +XRpc.NotifyStudentGraduate = function(data)--有学生毕业 + XDataCenter.MentorSystemManager.GraduateStudent(data) + XEventManager.DispatchEvent(XEventId.EVENT_MENTOR_GRADUATE_STUDENT) + XEventManager.DispatchEvent(XEventId.EVENT_MENTOR_TEACHERORSTUDENT_CHANGE) + XLog.Debug("MentorSystem-GraduateStudent") +end + +XRpc.NotifyMentorMemberWeeklyReset = function(data)--通知老师和学生每周重置 + XDataCenter.MentorSystemManager.WeekReset() + XDataCenter.MentorSystemManager.UpdateMentorData({WeeklyLevel = data.WeeklyLevel}) + XEventManager.DispatchEvent(XEventId.EVENT_MENTOR_WEEK_RESET) + XLog.Debug("MentorSystem-WeekReset") +end + +XRpc.NotifyMemberLevelChange = function(data)--通知成员等级改变 + XDataCenter.MentorSystemManager.UpdateMemberLevelById(data.Level, data.MemberId) + + XEventManager.DispatchEvent(XEventId.EVENT_MENTOR_MEMBERLEVEL_CHANGE) + XLog.Debug("MentorSystem-MemberLevelChange") +end + +XRpc.NotifyMentorMemberMessageUpdate = function(data)--通知所有人留言改变 + XDataCenter.MentorSystemManager.UpdateMentorData({Message = data.Message}) + XEventManager.DispatchEvent(XEventId.EVENT_MENTOR_MESSAGE_UPDATE) + XLog.Debug("MentorSystem-MessageUpdate") +end + +XRpc.NotifyMemberOnlineStatusChange = function(data)--通知成员在线状态改变 + XDataCenter.MentorSystemManager.UpdateMemberOnLineState(data.Online, data.LastLoginTime, data.MemberId) + XEventManager.DispatchEvent(XEventId.EVENT_MENTOR_ONLINE_UPDATE) + XLog.Debug("MentorSystem-OnlineStatusChange") +end +----------------------------------通用---------------------------------------<<<<< + +----------------------------------学生专用---------------------------------------->>>>> +XRpc.NotifyAddTeacher = function(data)--得到老师 + XDataCenter.MentorSystemManager.AddTeacher(data) + XDataCenter.MentorSystemManager.SetMentorShipComplete(true) + XDataCenter.MentorSystemManager.ShowMentorShipComplete() + XEventManager.DispatchEvent(XEventId.EVENT_MENTOR_GET_TEACHER) + XEventManager.DispatchEvent(XEventId.EVENT_MENTOR_TEACHERORSTUDENT_CHANGE) + XLog.Debug("MentorSystem-AddTeacher") +end + +XRpc.NotifyDoTickMentor = function(data)--失去老师 + XDataCenter.MentorSystemManager.RemoveTeacher(data) + XEventManager.DispatchEvent(XEventId.EVENT_MENTOR_LOSE_TEACHER) + XEventManager.DispatchEvent(XEventId.EVENT_MENTOR_TEACHERORSTUDENT_CHANGE) + XLog.Debug("MentorSystem-RemoveTeacher") +end + +XRpc.NotifyStudentDailyTaskChange = function(data)--师傅替换了任务(当自己是学生时) + XDataCenter.MentorSystemManager.UpdateStudentSystemTaskById(data.SystemTask, XPlayer.Id) + XEventManager.DispatchEvent(XEventId.EVENT_MENTOR_STUDENT_SYSTEMTASK_CHANGE) + XLog.Debug("MentorSystem-SelfSystemTaskChange") +end + +XRpc.NotifyStudentWeeklyTaskChange = function(data)--通知学生已领取的每周任务有修改,师傅领取奖励,师傅赠送了意识(当自己是学生时) + XDataCenter.MentorSystemManager.UpdateStudentWeeklyTaskById(data.WeeklyTask, XPlayer.Id) + XEventManager.DispatchEvent(XEventId.EVENT_MENTOR_STUDENT_WEEKLYTASK_CHANGE) + XLog.Debug("MentorSystem-SelfWeeklyTaskChange") +end + +XRpc.NotifyStudentWeeklyTaskProgress = function(data)--通知学生有每周任务完成(当自己是学生时) + XDataCenter.MentorSystemManager.UpdateMentorData({WeeklyTaskCompleteCount = data.WeeklyTaskCompleteCount}) + XEventManager.DispatchEvent(XEventId.EVENT_MENTOR_STUDENT_TASKCOUNT_CHANGE) + XLog.Debug("MentorSystem-WeeklyTaskComplete") +end + +XRpc.NotifyStudentDailyReset = function(data)--通知学生每日重置 + XDataCenter.MentorSystemManager.DayReset() + XDataCenter.MentorSystemManager.UpdateStudentSystemTaskById(data.SystemTask, XPlayer.Id) + XEventManager.DispatchEvent(XEventId.EVENT_MENTOR_DAY_RESET) + XLog.Debug("MentorSystem-DayReset") +end + +XRpc.NotifyIGraduate = function(data)--通知学生到达等级后自动毕业 + XDataCenter.MentorSystemManager.AutoGraduateRunMain() + XDataCenter.MentorSystemManager.SetGraduateReward(data.RewardGoodsList) + XEventManager.DispatchEvent(XEventId.EVENT_MENTOR_AUTO_GRADUATE) + XLog.Debug("MentorSystem-DayReset") +end +----------------------------------学生专用---------------------------------------<<<<< + +----------------------------------老师专用---------------------------------------->>>>> +XRpc.NotifyMentorStudentDailyTaskChange = function(data)--通知老师,有新接的任务(当自己是老师时) + XDataCenter.MentorSystemManager.UpdateStudentSystemTaskById(data.SystemTask, data.StudentId ) + XEventManager.DispatchEvent(XEventId.EVENT_MENTOR_TEACHER_STUDENTSYSTEMTASK_CHANGE) + XLog.Debug("MentorSystem-StudentSystemTaskChange") +end + +XRpc.NotifyMentorStudentWeeklyTaskChange = function(data)--通知老师,任务进度更新,任务状态跟新,有新接的任务(当自己是老师时) + XDataCenter.MentorSystemManager.UpdateStudentWeeklyTaskById(data.WeeklyTask, data.StudentId ) + XEventManager.DispatchEvent(XEventId.EVENT_MENTOR_TEACHER_STUDENTWEEKLYTASK_CHANGE) + XLog.Debug("MentorSystem-StudentWeeklyTaskChange") +end + +XRpc.NotifyTeacherDailyReset = function(data)--通知老师每日重置 + XDataCenter.MentorSystemManager.DayReset() + for _,taskdata in pairs(data.StudentMentorTasks) do + XDataCenter.MentorSystemManager.UpdateStudentSystemTaskById(taskdata.MentorTask, taskdata.StudentId ) + end + + XEventManager.DispatchEvent(XEventId.EVENT_MENTOR_DAY_RESET) + XLog.Debug("MentorSystem-DayReset") +end + +XRpc.NotifyMentorStudentMonthlyCountUpdate = function(data)--通知老师本月已招募学员数改变 + XDataCenter.MentorSystemManager.UpdateMentorData({MonthlyStudentCount = data.Count}) + XEventManager.DispatchEvent(XEventId.EVENT_MENTOR_TEACHER_MONTHLYSTUDENTCOUNT_UPDATE) + XLog.Debug("MentorSystem-MonthlyCountUpdate") +end + +XRpc.NotifyMentorActivationReward = function(data)--通知老师获得活跃度礼物 + XDataCenter.MentorSystemManager.SaveTeacherGiftData(data.ItemId, data.Count) + XEventManager.DispatchEvent(XEventId.EVENT_MENTOR_TEACHER_ACTIVATION_UPDATE) + XLog.Debug("MentorSystem-ActivationReward") +end + +----------------------------------老师专用---------------------------------------<<<<< \ No newline at end of file diff --git a/Resources/Scripts/XManager/XMineSweepingManager.lua b/Resources/Scripts/XManager/XMineSweepingManager.lua new file mode 100644 index 00000000..569dc82c --- /dev/null +++ b/Resources/Scripts/XManager/XMineSweepingManager.lua @@ -0,0 +1,281 @@ +local XMineSweepingGame = require("XEntity/XMineSweeping/XMineSweepingGame") +local tableInsert = table.insert +local tableSort = table.sort + +XMineSweepingManagerCreator = function() + local XMineSweepingManager = {} + + local METHOD_NAME = { + MineSweepingStartStageRequest = "MineSweepingStartStageRequest",--开始关卡请求 + MineSweepingOpenRequest = "MineSweepingOpenRequest",--扫雷翻开方格请求 + MineSweepingFlagRequest = "MineSweepingFlagRequest",--扫雷标记方格请求 + } + + local MineSweepingGameData = {} + + function XMineSweepingManager.Init() + XMineSweepingManager.InitGameData() + end + + function XMineSweepingManager.InitGameData() + MineSweepingGameData = XMineSweepingGame.New() + end + + function XMineSweepingManager.UpdateGameData(data) + MineSweepingGameData:UpdateData(data) + end + + function XMineSweepingManager.UpdateStageInfoByChapterId(chapterId, stageInfo) + local chapterEntity = MineSweepingGameData:GetChapterEntityById(chapterId) + local activityStageList = XTool.Clone(chapterEntity:GetActivityStageList()) + for index,info in pairs(activityStageList) do + if info.ActivityStageId == stageInfo.ActivityStageId then + activityStageList[index] = stageInfo + end + end + chapterEntity:UpdateData({ActivityStageList = activityStageList}) + end + + function XMineSweepingManager.UpdateChallengeCountByChapterId(chapterId, challengeCounts) + local chapterEntity = MineSweepingGameData:GetChapterEntityById(chapterId) + chapterEntity:UpdateData({ChallengeCounts = challengeCounts}) + end + + function XMineSweepingManager.UpdateCurGridListByChapterId(chapterId, curGridList) + local chapterEntity = MineSweepingGameData:GetChapterEntityById(chapterId) + chapterEntity:UpdateData({CurGridList = curGridList}) + end + + function XMineSweepingManager.GetPreStageByStageId(id) + local preStageDic = MineSweepingGameData:GetPreStageDic() + return preStageDic[id] + end + + function XMineSweepingManager.GetChapterByChapterId(chapterId) + local chapterEntity = MineSweepingGameData:GetChapterEntityById(chapterId) + return chapterEntity + end + + function XMineSweepingManager.GetChapterMineIcon(chapterId) + local chapterEntity = MineSweepingGameData:GetChapterEntityById(chapterId) + chapterEntity:GetMineIcon() + end + + function XMineSweepingManager.ResetMineGridByChapterId(chapterId) + local chapterEntity = MineSweepingGameData:GetChapterEntityById(chapterId) + chapterEntity:ResetGrid() + end + + function XMineSweepingManager.GetMineSweepingData() + return MineSweepingGameData + end + + function XMineSweepingManager.GetMineSweepingActivityId() + return MineSweepingGameData:GetActivityId() + end + + function XMineSweepingManager.GetMineSweepingCoinItemId() + return MineSweepingGameData:GetCoinItemId() + end + + function XMineSweepingManager.GetMineSweepingCoinItemCount() + local id = MineSweepingGameData:GetCoinItemId() + return XDataCenter.ItemManager.GetCount(id) + end + + function XMineSweepingManager.GetChapterEntityDic() + return MineSweepingGameData:GetChapterEntityDic() + end + + function XMineSweepingManager.GetChapterIds() + return MineSweepingGameData:GetChapterIds() + end + + function XMineSweepingManager.GetChapterEntityByIndex(index) + local id = MineSweepingGameData:GetChapterIdByIndex(index) + return XMineSweepingManager.GetChapterEntityById(id) + end + + function XMineSweepingManager.GetChapterEntityById(chapterId) + return MineSweepingGameData:GetChapterEntityById(chapterId) + end + + function XMineSweepingManager.GetNewChapterIndex() + return MineSweepingGameData:GetNewChapterIndex() + end + + function XMineSweepingManager.GetMineSweepingTimeLeft() + local activityId = MineSweepingGameData:GetActivityId() + if activityId ~= 0 then + local timeId = MineSweepingGameData:GetTimeId() + local endTime = XFunctionManager.GetEndTimeByTimeId(timeId) or 0 + local timeLeft = endTime - XTime.GetServerNowTimestamp() + return timeLeft + else + return 0 + end + end + + function XMineSweepingManager.CheckIsInTime() + local activityId = MineSweepingGameData:GetActivityId() + if activityId ~= 0 then + local timeId = MineSweepingGameData:GetTimeId() + local startTime = XFunctionManager.GetStartTimeByTimeId(timeId) or 0 + local endTime = XFunctionManager.GetEndTimeByTimeId(timeId) or 0 + local nowTime = XTime.GetServerNowTimestamp() + return endTime == 0 or (nowTime > startTime and nowTime < endTime) + else + return false + end + end + + function XMineSweepingManager.CheckIsOpen() + local functionId = XFunctionManager.FunctionName.MineSweeping + local isCanOpen = XFunctionManager.JudgeCanOpen(functionId) + if isCanOpen then + local isInTime = XMineSweepingManager.CheckIsInTime() + if not isInTime then + return false, CS.XTextManager.GetText("MineSweepingNotOpenHint") + else + return true + end + else + return false, XFunctionManager.GetFunctionOpenCondition(functionId) + end + end + + function XMineSweepingManager.OpenMineSweeping() + local IsOpen,desc = XMineSweepingManager.CheckIsOpen() + if IsOpen then + XLuaUiManager.Open("UiMineSweepingMain") + else + XUiManager.TipMsg(desc) + end + end + + function XMineSweepingManager.CheckHaveRed() + local IsHaveRed = false + local idList = MineSweepingGameData:GetChapterIds() + for _,id in pairs(idList) do + if XMineSweepingManager.CheckHaveRedByChapterId(id) then + IsHaveRed = true + break + end + end + return IsHaveRed + end + + function XMineSweepingManager.CheckShowHelp() + local IsShow = false + local activityId = XMineSweepingManager.GetMineSweepingActivityId() + local hitFaceData = XSaveTool.GetData(string.format( "%sMineSweepingHelp%s", XPlayer.Id, activityId)) + if not hitFaceData then + IsShow = true + XSaveTool.SaveData(string.format("%sMineSweepingHelp%s", XPlayer.Id, activityId), true) + end + return IsShow + end + + function XMineSweepingManager.CheckStoryRed(chapterId) + local IsShow = false + local activityId = XMineSweepingManager.GetMineSweepingActivityId() + local data = XSaveTool.GetData(string.format("%sMineSweepingStoryRed%s_%s", XPlayer.Id, activityId, chapterId)) + if not data then + IsShow = true + end + return IsShow + end + + function XMineSweepingManager.MarkStoryRed(chapterId) + local activityId = XMineSweepingManager.GetMineSweepingActivityId() + local data = XSaveTool.GetData(string.format("%sMineSweepingStoryRed%s_%s", XPlayer.Id, activityId, chapterId)) + if not data then + XSaveTool.SaveData(string.format("%sMineSweepingStoryRed%s_%s", XPlayer.Id, activityId, chapterId), true) + end + end + + function XMineSweepingManager.CheckHaveRedByChapterId(chapterId) + local chapterEntity = MineSweepingGameData:GetChapterEntityById(chapterId) + if not chapterEntity then + return false + end + + local curStageEntity = chapterEntity:GetCurStageEntity() + if not curStageEntity then + return false + end + + if chapterEntity:IsSweeping() then + return true + end + + if chapterEntity:IsFailed() then + return true + end + + if chapterEntity:IsFinish() and XMineSweepingManager.CheckStoryRed(chapterId) and chapterEntity:GetCompleteStoryId() then + return true + end + + local coinId = XDataCenter.MineSweepingManager.GetMineSweepingCoinItemId() + local coinCount = XDataCenter.ItemManager.GetCount(coinId) + local costCoinNum = curStageEntity:GetCostCoinNum() + + if not chapterEntity:IsLock() and chapterEntity:IsPrepare() and coinCount >= costCoinNum then + return true + end + end + + function XMineSweepingManager.MineSweepingStartStageRequest(chapterId, stageId, cb) + XNetwork.Call(METHOD_NAME.MineSweepingStartStageRequest, + {ActivityChapterId = chapterId, ActivityStageId = stageId}, + function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XMineSweepingManager.ResetMineGridByChapterId(chapterId) + XMineSweepingManager.UpdateStageInfoByChapterId(chapterId, res.ActivityStageInfo) + XMineSweepingManager.UpdateChallengeCountByChapterId(chapterId, res.ChallengeCounts) + + if cb then cb() end + XEventManager.DispatchEvent(XEventId.EVENT_MINESWEEPING_STAGESTART) + end) + end + + function XMineSweepingManager.MineSweepingOpenRequest(chapterId, stageId, xIndex, yIndex, cb) + XNetwork.Call(METHOD_NAME.MineSweepingOpenRequest, + {ActivityChapterId = chapterId, ActivityStageId = stageId, XIndex = xIndex, YIndex = yIndex}, + function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XMineSweepingManager.UpdateStageInfoByChapterId(chapterId, res.ActivityStageInfo) + XMineSweepingManager.UpdateCurGridListByChapterId(chapterId, res.RefreshGridList) + + if cb then cb(res.RewardGoodsList) end + XEventManager.DispatchEvent(XEventId.EVENT_MINESWEEPING_GRIDOPEN) + end) + end + + function XMineSweepingManager.MineSweepingFlagRequest(chapterId, stageId, xIndex, yIndex, isFlag, cb)--暂时不用 + XNetwork.Call(METHOD_NAME.MineSweepingFlagRequest, + {ActivityChapterId = chapterId, ActivityStageId = stageId, XIndex = xIndex, YIndex = yIndex, IsFlag = isFlag}, + function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + if cb then cb() end + end) + end + + XMineSweepingManager.Init() + return XMineSweepingManager +end + +XRpc.NotifyMineSweepingData = function(res) --登陆时,章节最后一关通关时 + XDataCenter.MineSweepingManager.UpdateGameData(res) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XModelManager.lua b/Resources/Scripts/XManager/XModelManager.lua new file mode 100644 index 00000000..66d04be3 --- /dev/null +++ b/Resources/Scripts/XManager/XModelManager.lua @@ -0,0 +1,573 @@ +XModelManager = XModelManager or {} + +local Ui_MODEL_TRANSFORM_PATH = "Client/Ui/UiModelTransform.tab" +local Ui_SCENE_TRANSFORM_PATH = "Client/Ui/UiSceneTransform.tab" +local MODEL_TABLE_PATH = "Client/ResourceLut/Model/Model.tab" +local UIMODEL_TABLE_PATH = "Client/ResourceLut/Model/UIModel.tab" +local XEquipModel = require("XEntity/XEquip/XEquipModel") + +XModelManager.MODEL_ROTATION_VALUE = 10 + +XModelManager.MODEL_UINAME = { + XUiMain = "UiMain", + XUiCharacter = "UiCharacter", + XUiPanelCharLevel = "UiPanelCharLevel", + XUiPanelCharQuality = "UiPanelCharQuality", + XUiPanelCharSkill = "UiPanelCharSkill", + XUiPanelCharGrade = "UiPanelCharGrade", + XUiPanelSelectLevelItems = "UiPanelSelectLevelItems", + XUiPreFight = "UiPreFight", + XUiDisplay = "UiDisplay", + XUiFashion = "UiFashion", + XUiFashionDetail = "UiFashionDetail", + XUiNewPlayerTask = "UiNewPlayerTask", + XUiBossSingle = "UiPanelBossDetail", + XUiOnlineBoss = "UiOnlineBoss", + XUiDormCharacterDetail = "UiDormCharacterDetail", + XUiFurnitureDetail = "UiDormFurnitureDetail", + XUiFavorabilityLineRoomCharacter = "UiFavorabilityLineRoomCharacter", + XUiDrawShow = "UiDrawShow", + XUiBabelTowerRoomCharacter = "UiBabelTowerRoomCharacter", + UiArchiveMonsterDetail = "UiArchiveMonsterDetail", + XUiRogueLikeRoomCharacter = "UiRogueLikeRoomCharacter", + XUiUnionKillSelectRole = "UiUnionKillXuanRen", + XUiUnionKillRank = "UiUnionKillRank", + XUiGuildMain = "UiGuildMain", + XUiWorldBossBossArea = "UiWorldBossBossArea", + XUiExhibitionInfo = "UiExhibitionInfo", + XUiPhotograph = "UiPhotograph", + XUiActivityBriefBase = "XUiActivityBriefBase", + XUiTRPGYingDi = "XUiTRPGYingDi", + XUiTRPGWorldBossBossArea = "UiTRPGWorldBossBossArea", + XUiNieRPOD = "XUiNieRPOD", + XUiPokemonMonster = "UiPokemonMonster", + XUiLottoShow = "UiLottoShow", + XUiPartnerMain = "UiPartnerMain", + XUiMoeWarMessage = "UiMoeWarMessage", + XUiMoeWarSchedule = "UiMoeWarSchedule", + XUiMoeWarVote = "UiMoeWarVote", + UiReform = "UiReform", +} + +--local RoleModelPool = {} --保存模型 +local UiModelTransformTemplates = {} -- Ui模型位置配置表 +local UiSceneTransformTemplates = {} -- Ui模型位置配置表 +local ModelTemplates = {} -- 模型相关配置 +local UIModelTemplates = {} -- UI模型相关配置 +local LuaBehaviourDict = {} -- 武器生命周期对象 + +--角色Model配置表 +function XModelManager.Init() + ModelTemplates = XTableManager.ReadByStringKey(MODEL_TABLE_PATH, XTable.XTableModel, "Id") + UIModelTemplates = XTableManager.ReadByStringKey(UIMODEL_TABLE_PATH, XTable.XTableUiModel, "Id") + + UiModelTransformTemplates = {} + UiSceneTransformTemplates = {} + + local tab = XTableManager.ReadByIntKey(Ui_MODEL_TRANSFORM_PATH, XTable.XTableUiModelTransform, "Id") + for _, config in pairs(tab) do + if not UiModelTransformTemplates[config.UiName] then + UiModelTransformTemplates[config.UiName] = {} + end + UiModelTransformTemplates[config.UiName][config.ModelName] = config + end + + local sceneTab = XTableManager.ReadByIntKey(Ui_SCENE_TRANSFORM_PATH, XTable.XTableUiSceneTransform, "Id") + for _, config in pairs(sceneTab) do + if not UiSceneTransformTemplates[config.UiName] then + UiSceneTransformTemplates[config.UiName] = {} + end + UiSceneTransformTemplates[config.UiName][config.SceneUrl] = config + end +end + +local function GetUiModelConfig(modelId) + local config = UIModelTemplates[modelId]--UI模型配置 + or ModelTemplates[modelId]--战斗模型配置(保底配置) + if not config then + XLog.Error("XModelManager GetUiModelConfig error: 模型配置不存在, modelId: " .. modelId .. " ,配置路径: " .. UIMODEL_TABLE_PATH) + return + end + return config +end + +local function GetModelConfig(modelId) + local config = ModelTemplates[modelId]--战斗模型配置 + if not config then + XLog.Error("XModelManager GetModelConfig error: 模型配置不存在, modelId: " .. modelId .. " ,配置路径: " .. MODEL_TABLE_PATH) + return + end + return config +end + +------UI调用 begin -------- +function XModelManager.GetUiModelPath(modelId) + local config = GetUiModelConfig(modelId) + return config.ModelPath +end + +function XModelManager.GetUiDisplayControllerPath(modelId) + local config = GetUiModelConfig(modelId) + return config.DisplayControllerPath +end + +function XModelManager.GetUiDefaultAnimationPath(modelId) + local config = GetUiModelConfig(modelId) + return config.UiDefaultAnimationPath +end + +function XModelManager.GetUiControllerPath(modelId) + local config = GetUiModelConfig(modelId) + return config.ControllerPath +end + +--特殊时装会用到的动画状态机路径 +function XModelManager.GetUiFashionControllerPath(modelId) + local config = GetUiModelConfig(modelId) + return config.FashionControllerPath +end +------UI调用 end -------- +------战斗C#调用 begin -------- +function XModelManager.GetModelPath(modelId) + local config = GetModelConfig(modelId) + return config.ModelPath +end + +function XModelManager.GetLowModelPath(modelId) + local config = GetModelConfig(modelId) + return config.LowModelPath +end + +function XModelManager.GetControllerPath(modelId) + local config = GetModelConfig(modelId) + return config.ControllerPath +end +------战斗C#调用 end -------- +function XModelManager.GetRoleModelConfig(uiName, modelName) + if not uiName or not modelName then + XLog.Error("XModelManager.GetRoleMoadelConfig 函数错误: 参数uiName和modelName都不能为空") + return + end + + if UiModelTransformTemplates[uiName] then + return UiModelTransformTemplates[uiName][modelName] + end +end + +function XModelManager.GetSceneModelConfig(uiName, sceneUrl) + if not uiName or not sceneUrl then + XLog.Error("XModelManager.GetSceneModelConfig 函数错误: 参数uiName和sceneUrl都不能为空") + return + end + + if UiSceneTransformTemplates[uiName] then + return UiSceneTransformTemplates[uiName][sceneUrl] + end +end + +function XModelManager.LoadSceneModel(sceneUrl, parent, uiName) + local scene = CS.LoadHelper.InstantiateScene(sceneUrl) + scene.transform:SetParent(parent, false) + if uiName then + XModelManager.SetSceneTransform(sceneUrl, scene, uiName) + end + return scene +end + +--新UI框架 +function XModelManager.LoadRoleModel(modelId, target, refName, cb) + if not modelId or not target then + return + end + + local modelPath = XModelManager.GetUiModelPath(modelId) + local model = CS.LoadHelper.InstantiateNpc(modelPath, refName) + model.transform:SetParent(target, false) + model.gameObject:SetLayerRecursively(target.gameObject.layer) + model.transform.localScale = CS.UnityEngine.Vector3.one + model.transform.localPosition = CS.UnityEngine.Vector3.zero + model.transform.localRotation = CS.UnityEngine.Quaternion.identity + + if cb then + cb(model) + end +end + +local setModeTransform = function(target, config) + if not target or not config then + return + end + + target.transform.localPosition = CS.UnityEngine.Vector3(config.PositionX, config.PositionY, config.PositionZ) + --检查数据 模型旋转 + target.transform.localEulerAngles = CS.UnityEngine.Vector3(config.RotationX, config.RotationY, config.RotationZ) + --检查数据 模型大小 + target.transform.localScale = CS.UnityEngine.Vector3( + config.ScaleX == 0 and 1 or config.ScaleX, + config.ScaleY == 0 and 1 or config.ScaleY, + config.ScaleZ == 0 and 1 or config.ScaleZ + ) +end + +function XModelManager.SetSceneTransform(sceneUrl, target, uiName) + target.transform.localPosition = CS.UnityEngine.Vector3.zero + target.transform.localEulerAngles = CS.UnityEngine.Vector3.zero + target.transform.localScale = CS.UnityEngine.Vector3.one + + if not uiName then + return + end + + local config = XModelManager.GetSceneModelConfig(uiName, sceneUrl) + if not config then + return + end + + setModeTransform(target, config) + +end + +function XModelManager.SetRoleTransform(name, target, uiName) + target.transform.localPosition = CS.UnityEngine.Vector3.zero + target.transform.localEulerAngles = CS.UnityEngine.Vector3.zero + target.transform.localScale = CS.UnityEngine.Vector3.one + + if not uiName then + return + end + + local config = XModelManager.GetRoleModelConfig(uiName, name) + if not config then + return + end + + setModeTransform(target, config) +end + +function XModelManager.CheckAnimatorAction(animator, actionName) + if not actionName then + return false + end + if not (animator and animator:Exist() and animator.runtimeAnimatorController and animator.gameObject.activeInHierarchy) then + return false + end + + local animationClips = animator.runtimeAnimatorController.animationClips + for i = 0, animationClips.Length - 1 do + local tempClip = animationClips[i] + if tempClip:Exist() and tempClip.name == actionName then + return true + end + end + XLog.Warning(animator.runtimeAnimatorController.name .. " 不存在動作ID:" .. actionName) + return false +end + +---================================================= +--- 在当前播放中的动画播放完后执行回调 +---@overload fun(callBack:function) +---@param callBack function +---================================================= +local CheckAnimeFinish = function(animator, behaviour, animaName, callBack)--如果动画被打断或是停止都会调用回调 + local animatorInfo = animator:GetCurrentAnimatorStateInfo(0) + if (animatorInfo:IsName(animaName) and animatorInfo.normalizedTime >= 1) or not animatorInfo:IsName(animaName) then--normalizedTime的值为0~1,0为开始,1为结束。 + if callBack then callBack() end + behaviour.enabled = false + end +end + +local AddPlayingAnimCallBack = function(obj, animator, animaName, callBack) + local animatorInfo = animator:GetCurrentAnimatorStateInfo(0) + + if not animatorInfo:IsName(animaName) or animatorInfo.normalizedTime >= 1 then--normalizedTime的值为0~1,0为开始,1为结束。 + return + end + + local behaviour = obj.transform:GetComponent(typeof(CS.XLuaBehaviour)) + if not behaviour then + behaviour = obj.gameObject:AddComponent(typeof(CS.XLuaBehaviour)) + else + behaviour.enabled = true + end + + behaviour.LuaUpdate = function() + CheckAnimeFinish(animator, behaviour, animaName, callBack) + end +end + +---================================================= +--- 播放'AnimaName'动画,‘fromBegin’决定动画是否需要调整到从0开始播放,默认值为false +---@overload fun(AnimaName:string) +---@param obj 场景对象 +---@param animator Animator组件 +---@param animaName string +---@param fromBegin boolean +---@param callBack function 播放成功回调 +---@param finishCallBack function 播放成功且播放完之后的回调 +---@param errorCb function 失败之后的回调 +---================================================= +function XModelManager.PlayAnima(obj, animator, animaName, fromBegin, callBack, errorCb, finishCallBack) + local isCanPlay = XModelManager.CheckAnimatorAction(animator, animaName) + if isCanPlay and animator then + if fromBegin then + animator:Play(animaName, 0, 0) + else + animator:Play(animaName) + end + if finishCallBack then + XScheduleManager.ScheduleOnce(function() + AddPlayingAnimCallBack(obj, animator, animaName, finishCallBack) + end, 1) + end + if callBack then + XScheduleManager.ScheduleOnce(function() + callBack() + end, 1) + end + else + if errorCb then + errorCb() + end + end +end + +--==============================-- +--@param: 武器模型id列表 +-- showEffect 显示特效 +-- gameObject 用于绑定生命周期 +-- noShowing 不需要变形(变形动画、变形音效、循环动画) +-- noRotation 不需要自转 +-- usage 武器用途(XEquipConfig.WeaponUsage) +-- noSound 不需要声音 +function XModelManager.LoadWeaponModel(modelId, target, transformConfig, uiName, cb, param) + if not modelId or XTool.UObjIsNil(target) then + return + end + + if type(transformConfig) == "function" then + cb = transformConfig + transformConfig = nil + end + + local XEquipConfig = XEquipConfig + local usage = param and param.usage or XEquipConfig.WeaponUsage.Show + local name = XEquipConfig.GetEquipModelName(modelId, usage) + + local model = target:LoadPrefab(name, false) + if transformConfig then + setModeTransform(model, transformConfig) + end + + if not param or not param.showEffect then -- 默认显示特效 + local effectPath = XEquipConfig.GetEquipModelEffectPath(modelId, usage) + XModelManager.LoadWeaponEffect(model, effectPath) + end + + local gameObject = param and param.gameObject + XModelManager.PlayWeaponShowing(model, modelId, uiName, gameObject, param) + + -- 自转逻辑 + if gameObject and not (param and param.noRotation) then + XModelManager.AutoRotateWeapon(target, model, modelId, gameObject) + end + + if cb then + cb(model) + end +end + +function XModelManager.AutoRotateWeapon(target, model, modelId, go) + local equipModelObj = XModelManager.GetOrCreateLuaBehaviour(go) + equipModelObj:AutoRotateWeapon(target, model, modelId) +end + +-- 播放变形动画及音效 +-- param参数见 XModelManager.LoadWeaponModel +function XModelManager.PlayWeaponShowing(target, modelId, uiName, go, param) + + local usage = param and param.usage or XEquipConfig.WeaponUsage.Show + local noShowing = param and param.noShowing + local noSound = param and param.noSound + local roleModelId = param and param.roleModelId + local notCareNoAnim = false + + local animController = XEquipConfig.GetEquipAnimController(modelId, usage) + local animator + + if animController and uiName then + animator = target:GetComponent("Animator") + animator.runtimeAnimatorController = CS.LoadHelper.LoadUiController(animController, uiName) + + if animator.runtimeAnimatorController and roleModelId then + local params = XEquipConfig.GetEquipAnimParams(roleModelId) + if params ~= 0 then + animator:SetInteger("UiAnime", params) + notCareNoAnim = true + end + + end + + -- 切换动作状态机前 先停止音效 + local equipModelObj = XModelManager.GetLuaBehaviour(go) + if equipModelObj then + equipModelObj:ClearAudioInfo() + end + end + + --某些特殊类型无视关闭动画效果 + if notCareNoAnim then + else + if noShowing then + return + end + end + + local playSound = true + -- 武器动画逻辑:静止 - 展开 - 待机循环(默认) + local animStateName = XEquipConfig.GetEquipUiAnimStateName(modelId, usage) + if animStateName then + animator = animator or target:GetComponent("Animator") + if animator and XModelManager.CheckAnimatorAction(animator, animStateName) then + -- 静止 + animator:Play(animStateName) + -- 展开 + local hasUiParam = false + local parameters = animator.parameters + for i = 0, parameters.Length - 1 do + if parameters[i].name == "UiActionBegin" then + hasUiParam = true + break + end + end + if hasUiParam then + local animDelay = XEquipConfig.GetEquipUiAnimDelay(modelId, usage) + if animDelay and animDelay > 0 then + playSound = false + XScheduleManager.ScheduleOnce(function() + if not XTool.UObjIsNil(animator) then + animator:SetBool("UiActionBegin", true) + if not noSound then + XModelManager.PlayWeaponSound(modelId, go, usage) + end + end + end, animDelay) + else + animator:SetBool("UiActionBegin", true) + end + end + else + playSound = false + end + end + if playSound then + if not noSound then + XModelManager.PlayWeaponSound(modelId, go, usage) + end + end +end + +function XModelManager.PlayWeaponSound(modelId, go, usage) + if not go then -- 音效需要gameObject绑定生命周期 + return + end + + local animCueId = XEquipConfig.GetEquipUiAnimCueId(modelId, usage) + if animCueId and animCueId ~= 0 then + local audioInfo = CS.XAudioManager.PlaySound(animCueId) -- 音效 + XModelManager.AddAudioInfo(go, audioInfo) + end +end + +-- 记录模型音效,跟随gameObject生命周期 +function XModelManager.AddAudioInfo(go, audioInfo) + local equipModelObj = XModelManager.GetOrCreateLuaBehaviour(go) + equipModelObj:AddAudioInfo(audioInfo) +end + +-- 武器共鸣特效 +function XModelManager.LoadWeaponEffect(model, effectPath) + if not effectPath then return end + if XTool.UObjIsNil(model) then return end + + local target = model.transform:FindTransform("WeaponCenter") + if XTool.UObjIsNil(target) then return end + + target:LoadPrefab(effectPath, false) +end + +--==============================-- +--desc: 加载角色武器 +--@roleModel: 角色模型 +--@equipModelIdList: 武器模型id列表 +--==============================-- +function XModelManager.LoadRoleWeaponModel(roleModel, equipModelIdList, refName, cb, hideEffect, go, roleModelId) + if not roleModel then + return + end + + local isShowing = (XDataCenter.SetManager.WeaponTransType == XSetConfigs.WeaponTransEnum.Open) + + local usage = XEquipConfig.WeaponUsage.Role + for i = 1, #equipModelIdList do + local modelId = equipModelIdList[i] + if modelId then + local weaponCase = roleModel.transform.FindTransform(roleModel.transform, "WeaponCase" .. i) + if not weaponCase then + XLog.Warning("XModelManager.LoadRoleWeaponModel warning, " .. "WeaponCase" .. i .. " not found") + else + XModelManager.LoadWeaponModel(modelId, weaponCase, nil, refName, cb, { showEffect = not hideEffect, noShowing = not isShowing, noRotation = true, usage = usage, gameObject = go, noSound = true, roleModelId = roleModelId }) + end + end + end + + -- 如果不加载武器,则直接执行CallBack + if #equipModelIdList <= 0 and cb then + cb() + end +end + +-- 根据FightNpcData创建武器模型及其特效 +function XModelManager.LoadRoleWeaponModelByFight(roleModel, fightNpcData, refName, go, roleModelId) + if not roleModel then + return + end + + local isShowing = (XDataCenter.SetManager.WeaponTransType == XSetConfigs.WeaponTransEnum.Open) + + local usage = XEquipConfig.WeaponUsage.Role + local idList = XDataCenter.EquipManager.GetEquipModelIdListByFight(fightNpcData) + for i, modelId in ipairs(idList) do + local weaponCase = roleModel.transform.FindTransform(roleModel.transform, "WeaponCase" .. i) + if not weaponCase then + XLog.Warning("XModelManager.LoadRoleWeaponModel warning, " .. "WeaponCase" .. i .. " not found") + else + XModelManager.LoadWeaponModel(modelId, weaponCase, nil, refName, nil, { noShowing = not isShowing, noRotation = true, usage = usage, gameObject = go, noSound = true, roleModelId = roleModelId }) + end + end +end + +--============================== +--desc: 为装备添加XLuaBehaviour,用于生命周期管理 +--============================== +function XModelManager.GetLuaBehaviour(go) + if XTool.UObjIsNil(go) then + return nil + end + return LuaBehaviourDict[go] +end + +function XModelManager.GetOrCreateLuaBehaviour(go) + if not LuaBehaviourDict[go] then + local behaviour = go:GetComponent(typeof(CS.XLuaBehaviour)) + if not behaviour then + behaviour = go:AddComponent(typeof(CS.XLuaBehaviour)) + end + local obj = XEquipModel.New(go, behaviour) + LuaBehaviourDict[go] = obj + end + return LuaBehaviourDict[go] +end + +function XModelManager.RemoveLuaBehaviour(go) + LuaBehaviourDict[go] = nil +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XMoeWarManager.lua b/Resources/Scripts/XManager/XMoeWarManager.lua new file mode 100644 index 00000000..279f5f8d --- /dev/null +++ b/Resources/Scripts/XManager/XMoeWarManager.lua @@ -0,0 +1,1220 @@ +local XMoeWarPreparationBaseData = require("XEntity/XMoeWar/XMoeWarPreparationBaseData") +local XMoeWarPlayer = require("XEntity/XMoeWar/XMoeWarPlayer") +local XMoeWarMatch = require("XEntity/XMoeWar/XMoeWarMatch") +local XMoeWarVoteItem = require("XEntity/XMoeWar/XMoeWarVoteItem") + +local RankReqIntervalTime = 60 * 2 +XMoeWarManagerCreator = function() + local tableInsert = table.insert + local tableSort = table.sort + local stringFormat = string.format + local mathFloor = math.floor + local pairs = pairs + local ipairs = ipairs + local mathMax = math.max + local CSXTextManagerGetText = CS.XTextManager.GetText + local ActivityInfo = nil + local DefaultActivityInfo = nil + local CurMatchEntity = nil + local Timer + local CurMatchId = 0 + local VoteDaily = 0 + local ScreenRecordDic = {} + local PlayerDic = {} + local MatchDic = {} + local MatchGroup = {} + local VoteItemDic = {} + local SessionList = {} + local RankCache = {} + local TabIndexCache = {} + local GROUP_TAB_INDEX_KEY + local StatusInFightChangeCache = false -- 是否在战斗中缓存 + + local PrepareTeamData = {} + local ExcludeWrongAnswersDic = {} + + local PlayerScreenRecordSize = CS.XGame.ClientConfig:GetInt("MoeWarPlayerScreenRecordSize") + local MoeWarPlayerScreenRecordShowNumber = CS.XGame.ClientConfig:GetInt("MoeWarPlayerScreenRecordShowNumber") + + local MoeWarPreparationBaseData = XMoeWarPreparationBaseData.New() + ---------------------本地接口 begin------------------ + local function Init() + local activityTemplates = XMoeWarConfig.GetActTemplates() + local nowTime = XTime.GetServerNowTimestamp() + for _, template in pairs(activityTemplates) do + DefaultActivityInfo = XMoeWarConfig.GetActivityTemplateById(template.Id) + local timeId = template.ActivityTimeId + local startTime, endTime = XFunctionManager.GetTimeByTimeId(timeId) + if nowTime > startTime and nowTime < endTime then + if not ActivityInfo then + ActivityInfo = XMoeWarConfig.GetActivityTemplateById(template.Id) + end + + if Timer then + XScheduleManager.UnSchedule(Timer) + end + Timer = XScheduleManager.ScheduleForever(function() + if not XFunctionManager.CheckInTimeByTimeId(timeId) then + CsXGameEventManager.Instance:Notify(XEventId.EVENT_MOE_WAR_ACTIVITY_END) + XScheduleManager.UnSchedule(Timer) + end + end, XScheduleManager.SECOND * 3) + end + end + + if ActivityInfo then + for _, v in pairs(XMoeWarConfig.GetPlayers()) do + PlayerDic[v.Id] = XMoeWarPlayer.New(v.Id) + end + for _, v in pairs(XMoeWarConfig.GetMatchCfgs()) do + local match = XMoeWarMatch.New(v.Id) + MatchDic[v.Id] = match + if not MatchGroup[v.SessionId] then + MatchGroup[v.SessionId] = {} + end + MatchGroup[v.SessionId][v.Type] = match + if v.Type == XMoeWarConfig.MatchType.Publicity then + SessionList[v.SessionId] = match + end + end + GROUP_TAB_INDEX_KEY = stringFormat("%s_%s", XMoeWarConfig.KEY_GROUP_TAB_INDEX, XPlayer.Id) + TabIndexCache = XSaveTool.GetData(GROUP_TAB_INDEX_KEY) or {} + for _, v in pairs(XMoeWarConfig.GetVoteItems()) do + VoteItemDic[v.No] = XMoeWarVoteItem.New(v.No) + end + end + end + + local SetExcludeWrongAnswers = function(excludeWrongAnswers) + ExcludeWrongAnswersDic = {} + for _, excludeWrongAnswerIndex in ipairs(excludeWrongAnswers or {}) do + ExcludeWrongAnswersDic[excludeWrongAnswerIndex] = true + end + end + + --返回剩余未恢复的支援次数 + local GetLastNotRecoverCount = function() + local assistanceCount = MoeWarPreparationBaseData:GetAssistanceCount() + local maxCount = XMoeWarConfig.GetPreparationAssistanceSupportMaxCount() + return mathMax(maxCount - assistanceCount, 0) + end + + -- 状态改变直接回到主界面 + local JudgeGotoMain = function(newMatchId, newActivityId) + if not XLuaUiManager.IsUiLoad("UiMoeWarPreparation") then + return + end + + -- 如果玩家在战斗中 先做缓存 + if CS.XFight.IsRunning or XLuaUiManager.IsUiLoad("UiLoading") then + StatusInFightChangeCache = true + return + end + + local oldMatchId = MoeWarPreparationBaseData:GetMatchId() + local oldActivityId = MoeWarPreparationBaseData:GetActivityId() + if oldMatchId ~= newMatchId or oldActivityId ~= newActivityId then + XUiManager.TipText("ActivityStateChange") + XLuaUiManager.RunMain() + XLuaUiManager.Open("UiMoeWarMain") + end + end + + local GetQuestionTemplate = function(questionId, desc, recruitMsgType, isPlayMsgAnima, isOverPlayMsgAnima) + return { + QuestionId = questionId, + Desc = desc, + RecruitMsgType = recruitMsgType, + IsPlayMsgAnima = isPlayMsgAnima, + IsOverPlayMsgAnima = false + } + end + ---------------------本地接口 end-------------------- + local MoeWarManager = {} + + ---------------------选手与赛程接口 begin-------------------- + function MoeWarManager.GetActivityInfo() + return ActivityInfo + end + + function MoeWarManager.GetActivityShopIds() + return ActivityInfo.ShopIds + end + + function MoeWarManager.GetPlayer(id) + return PlayerDic[id] + end + + function MoeWarManager.GetMySupportCount(playerId, matchId) + -- matchId 为空则获取总支持数 + local player = PlayerDic[playerId] + if not player then + return 0 + else + return player:GetMySupportCount(matchId) + end + end + + function MoeWarManager.GetMatch(sId) + return SessionList[sId] + end + + function MoeWarManager.GetVoteItem(id) + return VoteItemDic[id] + end + + function MoeWarManager.GetMatchById(Id) + return MatchDic[Id] + end + + function MoeWarManager.GetCurMatch() + return CurMatchEntity + end + + function MoeWarManager.GetCurMatchId() + return CurMatchId + end + + function MoeWarManager.GetVoteMatch(sId) + if not MatchGroup[sId] then return end + return MatchGroup[sId][XMoeWarConfig.MatchType.Voting] + end + + function MoeWarManager.GetSessionList() + return SessionList + end + + function MoeWarManager.GetRankTabList() + local list = XTool.Clone(XMoeWarConfig.GetRankGroups()) + + local playerList = {} + for i, v in pairs(PlayerDic) do + tableInsert(playerList, v) + end + + tableSort(playerList, function(a, b) + if a.IsEliminate == b.IsEliminate then + return a.Id < b.Id + else + return b.IsEliminate + end + end) + + for i, v in ipairs(playerList) do + local info = { TagName = v:GetName(), RankType = XMoeWarConfig.RankType.Player, PlayerId = v.Id, HasSub = false, IsSub = true } + tableInsert(list, info) + end + + for k, v in pairs(list) do + if v.IsSub then + if list[k - 1].IsSub then + v.SecondTagType = XMoeWarConfig.SubTagType.Mid + else + v.SecondTagType = XMoeWarConfig.SubTagType.Top + end + + if list[k + 1] then + if not list[k + 1].IsSub then + if v.SecondTagType == XMoeWarConfig.SubTagType.Mid then + v.SecondTagType = XMoeWarConfig.SubTagType.Btm + else + v.SecondTagType = XMoeWarConfig.SubTagType.All + end + end + else + if v.SecondTagType == XMoeWarConfig.SubTagType.Mid then + v.SecondTagType = XMoeWarConfig.SubTagType.Btm + else + v.SecondTagType = XMoeWarConfig.SubTagType.All + end + end + end + end + + + return list + end + + function MoeWarManager.GetUserSupportPlayer(sId) + local userSupportPlayer = 0 + local pairListIndex = 0 + local maxSupportCount = 0 + + local match = MoeWarManager.GetMatch(sId) + for i, v in ipairs(match.PairList) do + for _, playerId in ipairs(v.Players) do + local count = XDataCenter.MoeWarManager.GetMySupportCount(playerId) + if count > maxSupportCount then + userSupportPlayer = playerId + pairListIndex = i + maxSupportCount = count + end + end + end + + return userSupportPlayer, pairListIndex, maxSupportCount + end + + function MoeWarManager.GetNextTabIndex(sType) + local tabIndex = TabIndexCache[sType] or 0 + local nextIndex = tabIndex % #XMoeWarConfig.GetGroups() + 1 + TabIndexCache[sType] = nextIndex + XSaveTool.SaveData(GROUP_TAB_INDEX_KEY, TabIndexCache) + return nextIndex + end + ---------------------选手与赛程接口 end-------------------- + ---------------------投票接口 begin-------------------- + function MoeWarManager.NotifyMoeWarVoteScreenRecord(data) + if not data then return end + if MoeWarManager.IsSelectSkip() then return end + for i = 1,#data.Records do + local playerId = data.Records[i].TargetId + if not ScreenRecordDic[playerId] then + ScreenRecordDic[playerId] = XQueue.New() + end + if ScreenRecordDic[playerId]:Count() >= PlayerScreenRecordSize then + ScreenRecordDic[playerId]:Dequeue() + end + ScreenRecordDic[playerId]:Enqueue(data.Records[i]) + end + end + + function MoeWarManager.NotifyMoeWarVoteShowChange(data) + if not data then return end + CurMatchEntity:UpdateInfo(data.Match) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_MOE_WAR_UPDATE) + end + + function MoeWarManager.NotifyMoeWarDailyReset(data) + VoteDaily = 0 + for _,player in pairs(PlayerDic) do + for _,voteItem in pairs(VoteItemDic) do + player:UpdateDailyVote(voteItem:GetVoteItemId(),0) + end + end + end + function MoeWarManager.SetIsSelectSkip(isSkip) + XSaveTool.SaveData(string.format("%s_%s_%s",XMoeWarConfig.SKIP_KEY_PREFIX,XPlayer.Id,MoeWarManager.GetCurMatch():GetType()),isSkip) + end + function MoeWarManager.IsSelectSkip() + local isSkip = XSaveTool.GetData(string.format("%s_%s_%s",XMoeWarConfig.SKIP_KEY_PREFIX,XPlayer.Id,MoeWarManager.GetCurMatch():GetType())) or false + return isSkip + end + function MoeWarManager.GetDailyVoteCount() + return VoteDaily + end + + function MoeWarManager.GetScreenRecordByPlayerId(playerId) + if ScreenRecordDic[playerId] and ScreenRecordDic[playerId]:Count() > 0 then + return ScreenRecordDic[playerId]:Dequeue() + end + return nil + end + function MoeWarManager.ClearAllScreenRecord() + for _,queue in pairs(ScreenRecordDic) do + queue:Clear() + end + end + + function MoeWarManager:GetDefaultSelect() + local match = MoeWarManager.GetCurMatch() + local pairList = match:GetPairList() + local player,index,maxCount = MoeWarManager.GetUserSupportPlayer(match:GetSessionId()) + if maxCount > 0 then + return index,false + end + local defaultSelectKey = string.format("%s_%s",XMoeWarConfig.DEFAULT_SELECT_KEY_PREFIX,tostring(XPlayer.Id)) + local selectIndex = XSaveTool.GetData(defaultSelectKey) + if match:GetSessionId() == XMoeWarConfig.SessionType.Game24In12 then + if selectIndex then + return selectIndex,false + else + return math.random(1,#pairList),true + end + else + local lastPlayer,lastIndex,lastMaxCount = XDataCenter.MoeWarManager.GetUserSupportPlayer(match:GetSessionId() - 1) + local lastPlayerEntity = MoeWarManager.GetPlayer(lastPlayer) + if (lastPlayerEntity and lastPlayerEntity:GetIsEliminate()) or lastMaxCount == 0 then + return math.random(1,#pairList),true + else + for i = 1,#pairList do + for j = 1,#(pairList[i].Players) do + if pairList[i].Players[j] == lastPlayer then + return i,false + end + end + end + end + end + end + + function MoeWarManager:GetMatchPerGroupCount() + local match = MoeWarManager.GetCurMatch() + local sessionId = match:GetSessionId() + if sessionId == XMoeWarConfig.SessionType.Game24In12 then + return 4 + elseif sessionId == XMoeWarConfig.SessionType.Game12In6 then + return 2 + elseif sessionId == XMoeWarConfig.SessionType.Game6In3 then + return 1 + else + return 0 + end + end + + function MoeWarManager.GetDefaultSelectGroup() + local index,isRandom = MoeWarManager.GetDefaultSelect() + local perGroupCount = MoeWarManager.GetMatchPerGroupCount() + return (isRandom and { nil } or { math.ceil(index / perGroupCount) })[1] + end + + + --每次播放完弹幕动画清空缓存列表 + function MoeWarManager.GetScreenRecord() + return ScreenRecord + end + + function MoeWarManager.UpdateDailyVoteCount(addCount) + VoteDaily = VoteDaily + addCount + end + function MoeWarManager.IsInStatistics() + return MoeWarManager.GetCurMatch():GetVoteEnd() and (not MoeWarManager.GetCurMatch():GetResultOut()) + end + ---------------------投票接口 end---------------------- + ---------------------赛况同步 begin-------------------- + function MoeWarManager.HandleActivityData(data) + if not ActivityInfo or ActivityInfo.Id ~= data.ActivityNo then + ActivityInfo = XMoeWarConfig.GetActivityTemplateById(data.ActivityNo) + Init() + end + + for _, matchData in ipairs(data.Matches) do + local matchEntity = MatchDic[matchData.MatchId] + matchEntity:UpdateInfo(matchData) + if (matchEntity:GetIsEnd(true) and matchEntity:GetType() == XMoeWarConfig.MatchType.Publicity) or + (matchEntity:GetNotOpen(true) and matchEntity:GetType() == XMoeWarConfig.MatchType.Voting) or + matchEntity:GetInTime(true) then + SessionList[matchEntity:GetSessionId()] = matchEntity + end + end + + for _, dailyRecord in ipairs(data.MyVoteItemDailyRecord) do + local player = PlayerDic[dailyRecord.PlayerId] + player:UpdateDailyVote(dailyRecord.ItemId,dailyRecord.MyVote) + end + + CurMatchId = data.CurMatchId + VoteDaily = data.VoteDaily + CurMatchEntity = MatchDic[CurMatchId] + + for _, myVoteData in ipairs(data.MyVoteRecord) do + PlayerDic[myVoteData.PlayerId]:UpdateMatchMyVote(myVoteData) + end + + if CurMatchEntity:GetType() == XMoeWarConfig.MatchType.Publicity then + for _,queue in pairs(ScreenRecordDic) do + queue:Clear() + end + end + CsXGameEventManager.Instance:Notify(XEventId.EVENT_MOE_WAR_UPDATE) + end + ---------------------赛况同步 end-------------------- + ---------------------赛事筹备 begin------------------ + ----筹备界面begin + function MoeWarManager.GetStagesAndOneReserveStage() + return MoeWarPreparationBaseData:GetStagesAndOneReserveStage() + end + + function MoeWarManager.GetPreparationAllOpenStageIdList() + return MoeWarPreparationBaseData:GetAllOpenStageIdList() + end + + function MoeWarManager.GetReserveStageTimeByIndex(index) + return MoeWarPreparationBaseData:GetReserveStageTimeByIndex(index) + end + + function MoeWarManager.IsOpenPreparationStageByIndex(index) + local reserveStageTime = MoeWarManager.GetReserveStageTimeByIndex(index) + local nowServerTime = XTime.GetServerNowTimestamp() + return nowServerTime >= reserveStageTime + end + + function MoeWarManager.IsPreparationGetRewardGears(gearId) + return MoeWarPreparationBaseData:IsGetRewardGears(gearId) + end + + function MoeWarManager.GetPreparationMatchOpenState(matchId) + local nowServerTime = XTime.GetServerNowTimestamp() + local timeId = XMoeWarConfig.GetPreparationMatchTimeId(matchId) + local startTime, endTime = XFunctionManager.GetTimeByTimeId(timeId) + local matchState + if nowServerTime < startTime then + matchState = XMoeWarConfig.MatchState.NotOpen + elseif nowServerTime >= endTime then + matchState = XMoeWarConfig.MatchState.Over + else + matchState = XMoeWarConfig.MatchState.Open + end + return matchState + end + + function MoeWarManager.GetPreparationAllOpenStageCount() + return MoeWarPreparationBaseData:GetAllOpenStageCount() + end + ----筹备界面end + ----招募通讯begin + function MoeWarManager.GetRecruitHelperStatus(helperId) + return MoeWarPreparationBaseData:GetHelperStatus(helperId) + end + + function MoeWarManager.GetRecruitHelperExpirationTime(helperId) + return MoeWarPreparationBaseData:GetHelperExpirationTime(helperId) + end + + function MoeWarManager.GetTotalQuestionCount(helperId) + return MoeWarPreparationBaseData:GetTotalQuestionCount(helperId) + end + + --当前通讯进度 + function MoeWarManager.GetCurrQuestionCount(helperId) + local finishQuestionCount = MoeWarManager.GetFinishQuestionCount(helperId) + local answerRecords = MoeWarPreparationBaseData:GetAnswerRecords(helperId) + local errorQuestionCount = 0 + local questionId + local questionType + local answerId + for _, answerRecord in ipairs(answerRecords) do + questionId = answerRecord:GetQuestionId() + questionType = XMoeWarConfig.GetPreparationQuestionType(questionId) + answerId = answerRecord:GetAnswerId() + if not answerRecord:QuestionIsRight() and XTool.IsNumberValid(answerId) and questionType == XMoeWarConfig.QuestionType.RandomQuestion then + errorQuestionCount = errorQuestionCount + 1 + end + end + return errorQuestionCount + finishQuestionCount + end + + function MoeWarManager.GetRecruitQuestionIsRight(helperId, questionId) + return MoeWarPreparationBaseData:QuestionIsRight(helperId, questionId) + end + + function MoeWarManager.GetRecruitAnswerId(helperId, questionId) + return MoeWarPreparationBaseData:GetAnswerId(helperId, questionId) + end + + function MoeWarManager.GetFinishQuestionCount(helperId) + return MoeWarPreparationBaseData:GetFinishQuestionCount(helperId) + end + + function MoeWarManager.GetAnswerRecordsTemplate(helperId) + return MoeWarPreparationBaseData:GetAnswerRecords(helperId) + end + + function MoeWarManager.GetAssistanceCount() + local nowServerTime = XTime.GetServerNowTimestamp() + local effectId = MoeWarManager.GetSupportTakeEffectIdByEffectType(XMoeWarConfig.PreparationAssistanceEffectType.RecoveryTime) + local recoveryTime = MoeWarPreparationBaseData:GetAssistanceRecoveryTime() + local cd = XMoeWarConfig.GetPreparationAssistanceParam(effectId) + local addCount = 0 + local lastNotRecover = GetLastNotRecoverCount() + local assistanceCount = MoeWarPreparationBaseData:GetAssistanceCount() + + for i = 1, lastNotRecover do + local recoveryTimeTemp = recoveryTime + (i - 1) * cd + if nowServerTime < recoveryTimeTemp then + break + else + addCount = addCount + 1 + end + end + return assistanceCount + addCount + end + + function MoeWarManager.GetAssistanceRecoveryTime() + local nowServerTime = XTime.GetServerNowTimestamp() + local recoveryTime = MoeWarPreparationBaseData:GetAssistanceRecoveryTime() + local effectId = MoeWarManager.GetSupportTakeEffectIdByEffectType(XMoeWarConfig.PreparationAssistanceEffectType.RecoveryTime) + local lastNotRecover = GetLastNotRecoverCount() + + local cd = XMoeWarConfig.GetPreparationAssistanceParam(effectId) + for i = 1, lastNotRecover do + local recoveryTimeTemp = recoveryTime + (i - 1) * cd + if nowServerTime < recoveryTimeTemp then + return recoveryTimeTemp + end + end + return 0 + end + + function MoeWarManager.GetPreparationOwnHelperRobotIdList() + local helpersDic = MoeWarPreparationBaseData:GetAllHelpersDic() + local robotIdList = {} + local robotId + for helperId, helper in pairs(helpersDic) do + if helper:GetStatus() == XMoeWarConfig.PreparationHelperStatus.RecruitFinish then + robotId = XMoeWarConfig.GetMoeWarPreparationHelperRobotId(helperId) + tableInsert(robotIdList, robotId) + end + end + return robotIdList + end + + function MoeWarManager.GetPreparationOwnHelperIdByRobotId(robotId) + local helpersDic = MoeWarPreparationBaseData:GetAllHelpersDic() + local robotIdTemp + for helperId, helper in pairs(helpersDic) do + if helper:GetStatus() == XMoeWarConfig.PreparationHelperStatus.RecruitFinish then + robotIdTemp = XMoeWarConfig.GetMoeWarPreparationHelperRobotId(helperId) + if robotIdTemp == robotId then + return helperId + end + end + end + return 0 + end + + function MoeWarManager.GetAllQuestionTemplateByHelperId(helperId) + local answerRecords = MoeWarManager.GetAnswerRecordsTemplate(helperId) + local data = {} + local questionType + local questionId + local isPlayMsgAnima = false + for _, v in ipairs(answerRecords) do + questionId = v:GetQuestionId() + questionType = XMoeWarConfig.GetPreparationQuestionType(questionId) + if questionType == XMoeWarConfig.QuestionType.RandomQuestion then + --问题 + tableInsert(data, 1, GetQuestionTemplate(questionId, XMoeWarConfig.GetPreparationQuestion(questionId), XMoeWarConfig.RecruitMsgType.OtherMsg, isPlayMsgAnima)) + local answerId = v:GetAnswerId() + if answerId ~= 0 then + --我的回答 + local recruitMsgType = v:QuestionIsRight() and XMoeWarConfig.RecruitMsgType.MyYes or XMoeWarConfig.RecruitMsgType.MyNo + local myDesc = XMoeWarConfig.GetPreparationQuestionAnswer(questionId, answerId) + tableInsert(data, 1, GetQuestionTemplate(questionId, myDesc, recruitMsgType, isPlayMsgAnima)) + + --回答回复 + local replyDesc = v:QuestionIsRight() and XMoeWarConfig.GetPreparationQuestionRightReply(questionId) or XMoeWarConfig.GetPreparationQuestionWrongReply(questionId) + tableInsert(data, 1, GetQuestionTemplate(questionId, replyDesc, XMoeWarConfig.RecruitMsgType.OtherMsg, isPlayMsgAnima)) + tableInsert(data, 1, GetQuestionTemplate(questionId, "", XMoeWarConfig.RecruitMsgType.Line, isPlayMsgAnima)) + end + elseif questionType == XMoeWarConfig.QuestionType.RecruitRight or questionType == XMoeWarConfig.QuestionType.RecruitLose then + tableInsert(data, 1, GetQuestionTemplate(questionId, XMoeWarConfig.GetPreparationQuestionChat(questionId), XMoeWarConfig.RecruitMsgType.OtherMsg, isPlayMsgAnima)) + tableInsert(data, 1, GetQuestionTemplate(questionId, XMoeWarConfig.GetPreparationQuestionChatReply(questionId), XMoeWarConfig.RecruitMsgType.MyMsg, isPlayMsgAnima)) + else + tableInsert(data, 1, GetQuestionTemplate(questionId, XMoeWarConfig.GetPreparationQuestionChat(questionId), XMoeWarConfig.RecruitMsgType.OtherMsg, isPlayMsgAnima)) + end + end + return data + end + + function MoeWarManager.IsQuestionAllRight(helperId) + local rightQuestionCount = MoeWarManager.GetFinishQuestionCount(helperId) + local totalCount = XMoeWarConfig.GetMoeWarPreparationHelperTotalQuestionCount(helperId) + return rightQuestionCount == totalCount + end + + function MoeWarManager.SetHelperStatus(helperId, status) + MoeWarPreparationBaseData:SetHelperStatus(helperId, status) + end + + function MoeWarManager.IsExcludeWrongAnswer(answerIndex) + return ExcludeWrongAnswersDic[answerIndex] or false + end + + function MoeWarManager.CheckHelperRedPoint(helperId) + local status = MoeWarPreparationBaseData:GetHelperStatus(helperId) + return status == XMoeWarConfig.PreparationHelperStatus.Communicating + end + + function MoeWarManager.CheckAllHelpersRedPoint() + local helpersDic = MoeWarPreparationBaseData:GetAllHelpersDic() + for helperId in pairs(helpersDic) do + if MoeWarManager.CheckHelperRedPoint(helperId) then + return true + end + end + return false + end + + function MoeWarManager.CheckAllOwnHelpersIsResetStatus() + local ownHelpers = MoeWarPreparationBaseData:GetAllHelpersDic() + for helperId in pairs(ownHelpers) do + MoeWarManager.CheckIsResetHelperStatus(helperId) + end + end + + function MoeWarManager.CheckIsResetHelperStatus(helperId) + local isExpired = MoeWarManager.IsHelperExpired(helperId) + if isExpired then + XDataCenter.MoeWarManager.SetHelperStatus(helperId, XMoeWarConfig.PreparationHelperStatus.NotCommunicating) + end + end + + --已招募的帮手是否过期 + function MoeWarManager.IsHelperExpired(helperId) + if not XTool.IsNumberValid(helperId) then + return false + end + local nowServerTime = XTime.GetServerNowTimestamp() + local expirationTime = XDataCenter.MoeWarManager.GetRecruitHelperExpirationTime(helperId) + local status = MoeWarPreparationBaseData:GetHelperStatus(helperId) + if expirationTime ~= 0 and nowServerTime >= expirationTime and status == XMoeWarConfig.PreparationHelperStatus.RecruitFinish then + return true + end + return false + end + ----招募通讯end + ----场外应援begin + function MoeWarManager.GetSupportVoteItemCount(itemId) + return MoeWarPreparationBaseData:GetVoteItemCount(itemId) + end + + --返回当前支援类型生效的id + function MoeWarManager.GetSupportTakeEffectIdByEffectType(effectType) + local effectIdList = XMoeWarConfig.GetPreparationAssistanceEffectIdList() + local ownVoteItemCount + local effectTypeTemp + local voteItemCount + local voteItemId + local effectLevel + local takeEffectMaxlevel = 0 + local supportTakeEffectId + + for _, effectId in ipairs(effectIdList) do + effectTypeTemp = XMoeWarConfig.GetPreparationAssistanceEffectType(effectId) + voteItemCount = XMoeWarConfig.GetPreparationAssistanceVoteItemCount(effectId) + voteItemId = XMoeWarConfig.GetPreparationAssistanceVoteItemId(effectId) + ownVoteItemCount = MoeWarManager.GetSupportVoteItemCount(voteItemId) + effectLevel = XMoeWarConfig.GetPreparationAssistanceLevel(effectId) + + if effectTypeTemp == effectType and ownVoteItemCount >= voteItemCount and effectLevel >= takeEffectMaxlevel then + takeEffectMaxlevel = effectLevel + supportTakeEffectId = effectId + end + end + return supportTakeEffectId + end + ----场外应援end + ----选人界面begin + function MoeWarManager.SetPrepareTeamData(teamData) + PrepareTeamData = teamData + end + + function MoeWarManager.GetPrepareTeamData() + return XTool.IsTableEmpty(PrepareTeamData) and { 0, 0, 0 } or PrepareTeamData + end + + function MoeWarManager.ClearPrepareTeamData() + PrepareTeamData = {} + end + + function MoeWarManager.GetPrepareOwnHelperId(charId) + if XRobotManager.CheckIsRobotId(charId) then + return MoeWarManager.GetPreparationOwnHelperIdByRobotId(charId) + end + + local robotIdToChatId + local ownHelpers = MoeWarPreparationBaseData:GetAllHelpersDic() + local robotId + for helperId in pairs(ownHelpers) do + robotId = XMoeWarConfig.GetMoeWarPreparationHelperRobotId(helperId) + robotIdToChatId = XRobotManager.GetCharacterId(robotId) + if robotIdToChatId == charId then + return helperId + end + end + return 0 + end + ----选人界面end + --萌战赛事筹备领取奖励 + function MoeWarManager.RequestMoeWarPreparationGearReward(gearId, cb) + local req = { GearId = gearId } + XNetwork.Call("MoeWarPreparationGearRewardRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + XUiManager.OpenUiObtain(res.RewardGoodsList) + MoeWarPreparationBaseData:SetOverReceiveRewardGear(gearId) + if cb then + cb() + end + XEventManager.DispatchEvent(XEventId.EVENT_MOE_WAR_PREPARATION_GEAR_REWARD) + end) + end + + --萌战赛事筹备通讯 + --refreshCb:刷新答题界面回调 + --receiveChatHandlerCb:播放问答动画回调 + --currSelectContactBtnIndex:帮手对应的按钮下标 + --setMsgListPanelHelperIdCb:设置当前通讯中的帮手id回调 + --requestFailCb:请求失败回调 + function MoeWarManager.RequestMoeWarPreparationHelperCommunicate(helperId, refreshCb, receiveChatHandlerCb, currSelectContactBtnIndex, setMsgListPanelHelperIdCb, requestFailCb) + local req = { HelperId = helperId } + XNetwork.Call("MoeWarPreparationHelperCommunicateRequest", req, function(res) + if res.Code ~= XCode.Success then + if requestFailCb then + requestFailCb() + end + XUiManager.TipCode(res.Code) + return + end + + if setMsgListPanelHelperIdCb then + setMsgListPanelHelperIdCb(helperId) + end + + local setData = function() + MoeWarManager.SetHelperStatus(helperId, XMoeWarConfig.PreparationHelperStatus.Communicating) + MoeWarPreparationBaseData:InsertQuestion(helperId, res.QuestionId) + MoeWarPreparationBaseData:SetCurrQuestionId(helperId, res.QuestionId) + SetExcludeWrongAnswers(res.ExcludeWrongAnswers) + end + + local isPlayMsgAnima = false + local status = MoeWarPreparationBaseData:GetHelperStatus(helperId) + --不在通讯中状态,先刷新下答题界面,再插入打招呼和问题,接着再设置数据刷新除答题界面外的其他界面 + if status ~= XMoeWarConfig.PreparationHelperStatus.Communicating then + if refreshCb then + refreshCb(helperId, currSelectContactBtnIndex) + end + + local data = {} + local questionStartList = XMoeWarConfig.GetPreparationQuestionIdListByType(helperId, XMoeWarConfig.QuestionType.QuestionStart) + for _, questionId in ipairs(questionStartList) do + tableInsert(data, GetQuestionTemplate(questionId, XMoeWarConfig.GetPreparationQuestionChat(questionId), XMoeWarConfig.RecruitMsgType.OtherMsg, isPlayMsgAnima)) + end + tableInsert(data, GetQuestionTemplate(res.QuestionId, XMoeWarConfig.GetPreparationQuestion(res.QuestionId), XMoeWarConfig.RecruitMsgType.OtherMsg, isPlayMsgAnima)) + + if receiveChatHandlerCb then + receiveChatHandlerCb(data) + end + setData() + + if refreshCb then + refreshCb(helperId, currSelectContactBtnIndex, true) + end + else + setData() + if refreshCb then + refreshCb(helperId, currSelectContactBtnIndex) + end + end + XEventManager.DispatchEvent(XEventId.EVENT_MOE_WAR_CHECK_RECRUIT_RED_POINT) + end) + end + + --萌战赛事筹备通讯答题 + function MoeWarManager.RequestMoeWarPreparationHelperAnswer(helperId, answerId, refreshCb, receiveChatHandlerCb) + local req = { HelperId = helperId, AnswerId = answerId } + XNetwork.Call("MoeWarPreparationHelperAnswerRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + SetExcludeWrongAnswers({}) + + local questionId = MoeWarPreparationBaseData:GetCurrQuestionId(helperId) + MoeWarPreparationBaseData:UpdateAnswerRecord(helperId, answerId, res.IsRight) + if res.IsRight then + MoeWarPreparationBaseData:AddOnceFinishQuestionCount(helperId) + end + + local isPlayMsgAnima = false --回答错误播放动画 + local replyDesc = res.IsRight and XMoeWarConfig.GetPreparationQuestionRightReply(questionId) or XMoeWarConfig.GetPreparationQuestionWrongReply(questionId) + local recruitMsgType = res.IsRight and XMoeWarConfig.RecruitMsgType.MyYes or XMoeWarConfig.RecruitMsgType.MyNo + local myDesc = XMoeWarConfig.GetPreparationQuestionAnswer(questionId, answerId) + local data = {} + tableInsert(data, GetQuestionTemplate(questionId, myDesc, recruitMsgType, isPlayMsgAnima)) + tableInsert(data, GetQuestionTemplate(questionId, replyDesc, XMoeWarConfig.RecruitMsgType.OtherMsg, not res.IsRight)) + tableInsert(data, GetQuestionTemplate(0, "", XMoeWarConfig.RecruitMsgType.Line, isPlayMsgAnima)) + + if res.NextQuestionId ~= 0 then --下个题目 id,0 表示没有题目了 + MoeWarPreparationBaseData:InsertQuestion(helperId, res.NextQuestionId) + tableInsert(data, GetQuestionTemplate(res.NextQuestionId, XMoeWarConfig.GetPreparationQuestion(res.NextQuestionId), XMoeWarConfig.RecruitMsgType.OtherMsg, isPlayMsgAnima)) + else + local status = MoeWarManager.IsQuestionAllRight(helperId) and XMoeWarConfig.PreparationHelperStatus.RecruitFinish or XMoeWarConfig.PreparationHelperStatus.CommunicationEnd + MoeWarManager.SetHelperStatus(helperId, status) + if receiveChatHandlerCb then + local questionType = status == XMoeWarConfig.PreparationHelperStatus.CommunicationEnd and XMoeWarConfig.QuestionType.RecruitLose or XMoeWarConfig.QuestionType.RecruitRight + local questionId = XMoeWarConfig.GetPreparationQuestionId(helperId, questionType) + tableInsert(data, GetQuestionTemplate(questionId, XMoeWarConfig.GetPreparationQuestionChat(questionId), XMoeWarConfig.RecruitMsgType.OtherMsg, questionType == XMoeWarConfig.QuestionType.RecruitLose)) + tableInsert(data, GetQuestionTemplate(questionId, XMoeWarConfig.GetPreparationQuestionChatReply(questionId), XMoeWarConfig.RecruitMsgType.MyMsg, isPlayMsgAnima)) + end + end + + if receiveChatHandlerCb then + receiveChatHandlerCb(data) + end + + if refreshCb then + refreshCb() + end + + if res.NextQuestionId == 0 then + MoeWarPreparationBaseData:ClearAnswerRecords(helperId) + end + MoeWarPreparationBaseData:SetCurrQuestionId(helperId, res.NextQuestionId) + XEventManager.DispatchEvent(XEventId.EVENT_MOE_WAR_CHECK_RECRUIT_RED_POINT) + end) + end + + --萌战赛事筹备答题场外援助 + function MoeWarManager.RequestMoeWarPreparationAssistance(helperId, cb) + local req = { HelperId = helperId } + XNetwork.Call("MoeWarPreparationAssistanceRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + SetExcludeWrongAnswers(res.ExcludeWrongAnswers) + if cb then + cb() + end + end) + end + + --推送萌战赛事筹备数据(进入服务器、活动重置、赛事阶段变更推送) + function MoeWarManager.NotifyMoeWarPreparationData(data) + JudgeGotoMain(data.Data.MatchId, data.Data.ActivityId) + MoeWarPreparationBaseData:UpdateData(data.Data) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_MOE_WAR_PREPARATION_UPDATE) + end + + --萌战赛事筹备关卡变化 + function MoeWarManager.NotifyMoeWarPreparationStage(data) + MoeWarPreparationBaseData:UpdateStage(data.Stage) + end + + --萌战赛事筹备援助变化 + function MoeWarManager.NotifyMoeWarPreparationAssistance(data) + MoeWarPreparationBaseData:UpdateAssistance(data.Assistance) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_MOE_WAR_PREPARATION_NOTIFY_ASSISTANCE) + end + + --萌战赛事筹备应援道具变化 + function MoeWarManager.NotifyMoeWarPreparationVoteItem(data) + MoeWarPreparationBaseData:UpdateVoteItem(data.VoteItem) + end + + --萌战招募成功推送 + function MoeWarManager.NotifyMoeWarPreparationHelper(data) + local helper = data.Helper + MoeWarManager.SetHelperStatus(helper.Id, helper.Status) + MoeWarPreparationBaseData:SetHelperExpirationTime(helper.Id, helper.ExpirationTime) + end + + --萌战赛事筹备每日重置 + function MoeWarManager.NotifyMoeWarPreparationDailyReset(data) + MoeWarPreparationBaseData:ClearGetRewardGears() + CsXGameEventManager.Instance:Notify(XEventId.EVENT_MOE_WAR_PREPARATION_DAILY_RESET) + end + ---------------------赛事筹备 end-------------------- + --萌战排行榜请求 + function MoeWarManager.RequestRank(rankType, playerId, cb) + if not RankCache[rankType] then + return + end + local cache = RankCache[rankType][playerId] + if cache then + local nowTime = XTime.GetServerNowTimestamp() + if nowTime <= cache.RefreshTime + RankReqIntervalTime then + if cb then + cb(cache) + end + return + end + end + + local req = { RankType = rankType, PlayerId = playerId } + XNetwork.Call("MoeWarOpenRankRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + if cb then + cb({ RankingList = {} }) + end + return + end + + local nowTime = XTime.GetServerNowTimestamp() + local rankData = { RefreshTime = nowTime, + UserRank = res.MyRankInfo, + RankingList = res.RankList,} + RankCache[rankType][playerId] = rankData + + if cb then + cb(rankData) + end + end) + end + + --萌战排行榜请求 + function MoeWarManager.ClearCache() + for _, v in pairs(XMoeWarConfig.RankType) do + RankCache[v] = {} + end + end + ---------------------活动相关 begin-------------------- + function MoeWarManager.GetActivityStartTime() + if DefaultActivityInfo then + return XFunctionManager.GetStartTimeByTimeId(DefaultActivityInfo.ActivityTimeId) or 0 + end + return 0 + end + + function MoeWarManager.GetActivityEndTime() + if DefaultActivityInfo then + return XFunctionManager.GetEndTimeByTimeId(DefaultActivityInfo.ActivityTimeId) or 0 + end + return 0 + end + + function MoeWarManager.OnOpenMain() + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.MoeWar) then + return + end + if not MoeWarManager.IsOpen() then + XUiManager.TipText("MoeWarNotOpen") + return + end + local isPlayedStory = XSaveTool.GetData(string.format("%s_%s","MoeWarPlayedStory",XPlayer.Id)) + if isPlayedStory then + XLuaUiManager.Open("UiMoeWarMain") + else + if ActivityInfo and XMovieConfigs.CheckMovieConfigExist(XMoeWarConfig.GetBeginStoryId()) then + XDataCenter.MovieManager.PlayMovie(XMoeWarConfig.GetBeginStoryId(), function() + XLuaUiManager.Open("UiMoeWarMain") + XSaveTool.SaveData(string.format("%s_%s","MoeWarPlayedStory",XPlayer.Id),true) + end) + else + XLog.Error("剧情不存在 MovieId:",ActivityInfo.BeginStoryId) + XLuaUiManager.Open("UiMoeWarMain") + end + end + end + + function MoeWarManager.IsOpen() + if not ActivityInfo then return false end + return XFunctionManager.CheckInTimeByTimeId(ActivityInfo.ActivityTimeId) + end + + function MoeWarManager.OnActivityEnd() + if CS.XFight.IsRunning or XLuaUiManager.IsUiLoad("UiLoading") then + return + end + + XUiManager.TipText("ActivityMainLineEnd") + XLuaUiManager.RunMain() + end + + function MoeWarManager.OpenVotePanel(index) + local match = MoeWarManager.GetCurMatch() + local key = string.format("%s_%s","MOE_WAR_VOTE_SHOW_MATCH_SCENE",tostring(XPlayer.Id)) + local isShowMatchPanel = XSaveTool.GetData(key) + if match and match:GetSessionId() == XMoeWarConfig.SessionType.Game24In12 and match:GetType() == XMoeWarConfig.MatchType.Voting then + if not isShowMatchPanel then + XLuaUiManager.Open("UiMoeWarGroupList") + else + XLuaUiManager.Open("UiMoeWarVote",index) + end + else + XLuaUiManager.Open("UiMoeWarVote",index) + end + end + + function MoeWarManager.GetActivityChapter() + local chapters = {} + if MoeWarManager.IsOpen() then + local temp = {} + local template = XMoeWarConfig.GetActivityTemplateById(1) + temp.Id = template.Id + temp.Name = template.Name + temp.Background = template.Background + temp.Type = XDataCenter.FubenManager.ChapterType.MoeWar + tableInsert(chapters, temp) + end + return chapters + end + + function MoeWarManager.RequestShare(playerId,cb) + local req = {PlayerId = playerId} + XNetwork.Call("MoeWarShareRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + if cb then + cb() + end + end) + + end + + -- 战斗结束后判断是否跳到主界面 + function MoeWarManager.JudgeGotoMainWhenFightOver() + if not XLuaUiManager.IsUiLoad("UiMoeWarPreparation") then + StatusInFightChangeCache = false + return + end + + if not StatusInFightChangeCache then + return false + end + + StatusInFightChangeCache = false + XUiManager.TipText("ActivityStateChange") + XLuaUiManager.RunMain() + XLuaUiManager.Open("UiMoeWarMain") + end + ---------------------活动相关 end-------------------- + ---------------------任务相关 begin-------------------- + function MoeWarManager.GetTaskListByType(type,groupId) + local taskList = {} + local sortList = {} + if type == XMoeWarConfig.TaskType.Daily then + taskList = XDataCenter.TaskManager.GetMoeWarDailyTaskList() + else + taskList = XDataCenter.TaskManager.GetMoeWarNormalTaskList() + end + for id,task in pairs(taskList) do + local config = XTaskConfig.GetTaskCfgById(task.Id) + if config.GroupId == groupId then + tableInsert(sortList,task) + end + end + return sortList + end + + function MoeWarManager.CheckTaskRedPoint(type,groupId) + local taskList = MoeWarManager.GetTaskListByType(type,groupId) + for _,task in pairs(taskList) do + if XDataCenter.TaskManager.CheckTaskAchieved(task.Id) then + return true + end + end + return false + end + + + ---------------------任务相关 end-------------------- + ---------------------场景动画相关 begin-------------------- + --public class XMoeWarPlayerPair <==> pairInfo + --{ + -- public int WinnerId; + -- public int SecondId; + -- public List Players = new List(); + --} + function MoeWarManager.EnterAnimation(pairInfo, matchEntity, closeCallback) + local winnerIndex = 0 + local animGroupIds = {} + + local match = matchEntity or XDataCenter.MoeWarManager.GetCurMatch() + local sessionId = match:GetSessionId() + + for index, playerId in ipairs(pairInfo.Players) do + local animGroupId + + if XTool.IsNumberValid(playerId) then + local player = MoeWarManager.GetPlayer(playerId) + + if playerId == pairInfo.WinnerId then + winnerIndex = index + animGroupId = player:GetWinAnimGroupId(sessionId) + elseif playerId == pairInfo.SecondId then + animGroupId = player:GetSecondAnimGroupId(sessionId) + else + animGroupId = player:GetLoseAnimGroupId(sessionId) + end + + tableInsert(animGroupIds, animGroupId) + end + end + + if not XTool.IsNumberValid(winnerIndex) then + XLog.Error("MoeWarManager.EnterAnimation error: 萌战动画播放错误,找不到胜利者,pairInfo:", pairInfo) + return + end + + XLuaUiManager.Open("UiMoeWarAnimation", animGroupIds, winnerIndex, closeCallback) + end + ---------------------场景动画相关 end-------------------- + ---------------------通用 begin-------------------- + function MoeWarManager.CheckRespondItemIsMax(isShow) + local match = XDataCenter.MoeWarManager.GetCurMatch() + if not match then + return false + end + + --公示期不弹出提示框 + if not isShow then + local matchType = match:GetType() + local session = match:GetSessionId() + if matchType ~= XMoeWarConfig.MatchType.Voting then + return false + end + end + + local itemId = XDataCenter.ItemManager.ItemId.MoeWarRespondItemId + local itemMaxCount = XDataCenter.ItemManager.GetMaxCount(itemId) + local itemCount = XDataCenter.ItemManager.GetCount(itemId) + if itemCount == itemMaxCount then + local itemName = XDataCenter.ItemManager.GetItemName(itemId) + local title = CSXTextManagerGetText("MoeWarRespondItemMaxTitle", itemName) + local content = CSXTextManagerGetText("MoeWarRespondItemMaxDesc", itemName) + local sureCallback = function() + XLuaUiManager.Open("UiMoeWarVote") + end + XUiManager.DialogTip(title, content, nil, nil, sureCallback, {sureText = CSXTextManagerGetText("MoeWarGoToVote")}) + return true + end + return false + end + ---------------------通用 begin-------------------- + XEventManager.AddEventListener(XEventId.EVENT_LOGIN_DATA_LOAD_COMPLETE, Init) + return MoeWarManager +end + +---------------------(服务器推送)begin------------------ +XRpc.NotifyMoeWarActivityData = function(data) + XDataCenter.MoeWarManager.HandleActivityData(data) +end + +XRpc.NotifyMoeWarPreparationData = function(data) + XDataCenter.MoeWarManager.NotifyMoeWarPreparationData(data) +end + +XRpc.NotifyMoeWarPreparationStage = function(data) + XDataCenter.MoeWarManager.NotifyMoeWarPreparationStage(data) +end + +XRpc.NotifyMoeWarVoteRecord = function(data) + XDataCenter.MoeWarManager.NotifyMoeWarVoteScreenRecord(data) +end + +XRpc.NotifyMoeWarVoteShowChange = function(data) + XDataCenter.MoeWarManager.NotifyMoeWarVoteShowChange(data) +end + +XRpc.NotifyMoeWarDailyReset = function(data) + XDataCenter.MoeWarManager.NotifyMoeWarDailyReset(data) +end + +XRpc.NotifyMoeWarPreparationAssistance = function(data) + XDataCenter.MoeWarManager.NotifyMoeWarPreparationAssistance(data) +end + +XRpc.NotifyMoeWarPreparationVoteItem = function(data) + XDataCenter.MoeWarManager.NotifyMoeWarPreparationVoteItem(data) +end + +XRpc.NotifyMoeWarPreparationHelper = function(data) + XDataCenter.MoeWarManager.NotifyMoeWarPreparationHelper(data) +end + +XRpc.NotifyMoeWarPreparationDailyReset = function(data) + XDataCenter.MoeWarManager.NotifyMoeWarPreparationDailyReset(data) +end +---------------------(服务器推送)end-------------------- \ No newline at end of file diff --git a/Resources/Scripts/XManager/XMovieAssembleManager.lua b/Resources/Scripts/XManager/XMovieAssembleManager.lua new file mode 100644 index 00000000..16f82210 --- /dev/null +++ b/Resources/Scripts/XManager/XMovieAssembleManager.lua @@ -0,0 +1,38 @@ +XMovieAssembleManagerCreator = function () + local XMovieAssembleManager = {} + + function XMovieAssembleManager.CheckMovieIsWatched(movieId) + local movieWatchState = XSaveTool.GetData(string.format("%s%s%s", XMovieAssembleConfig.MovieAssembleWatchedKey, XPlayer.Id, movieId)) + if not movieWatchState or movieWatchState == XMovieAssembleConfig.MovieWatchedState.NotWatch then + return false + elseif movieWatchState == XMovieAssembleConfig.MovieWatchedState.Watched then + return true + end + return false + end + + function XMovieAssembleManager.CheckMovieTmpRedPoint(movieId) + if not movieId then + return false + end + local conditionId = XMovieAssembleConfig.GetMovieConditionIdById(movieId) + if not conditionId or conditionId == 0 then + return not XMovieAssembleManager.CheckMovieIsWatched(movieId) + end + + return XConditionManager.CheckCondition(conditionId) and not XMovieAssembleManager.CheckMovieIsWatched(movieId) + end + + function XMovieAssembleManager.CheckMovieAssembleRedPoint(assembleId) + local movieIds = XMovieAssembleConfig.GetMovieTmpIdsById(assembleId) + for _, movieId in ipairs(movieIds) do + if XMovieAssembleManager.CheckMovieTmpRedPoint(movieId) then + return true + end + end + + return false + end + + return XMovieAssembleManager +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XMovieManager.lua b/Resources/Scripts/XManager/XMovieManager.lua new file mode 100644 index 00000000..524e438d --- /dev/null +++ b/Resources/Scripts/XManager/XMovieManager.lua @@ -0,0 +1,443 @@ +local tonumber = tonumber +local tostring = tostring +local mathFloor = math.floor +local tableInsert = table.insert +local tableRemove = table.remove +local next = next +local CSMovieXMovieManagerInstance = CS.Movie.XMovieManager.Instance + +local UI_MOVIE = "UiMovie" +local RESOLUTION_RATIO = CS.XResolutionManager.OriginWidth / CS.XResolutionManager.OriginHeight / CS.XUiManager.DefaultScreenRatio +local TIMELINE_SECONDS_TRANS = 1 / 60 +local IS_DEBUG = XMain.IsDebug + +local ActionClass = { + [101] = require("XMovieActions/XMovieActionBgSwitch"), --背景切换 + [102] = require("XMovieActions/XMovieActionTheme"), --章节主题 + + [201] = require("XMovieActions/XMovieActionActorAppear"), --演员出现 + [202] = require("XMovieActions/XMovieActionActorDisappear"), --演员消失 + [203] = require("XMovieActions/XMovieActionActorShift"), --演员位移 + [204] = require("XMovieActions/XMovieActionActorChangeFace"), --演员表情 + + [301] = require("XMovieActions/XMovieActionDialog"), --普通对话 + [302] = require("XMovieActions/XMovieActionSelection"), --选择分支对话 + [303] = require("XMovieActions/XMovieActionDelaySkip"), --延迟跳转 + [304] = require("XMovieActions/XMovieActionFullScreenDialog"), --全屏字幕 + [305] = require("XMovieActions/XMovieActionYieldResume"), --挂起/恢复 + + [401] = require("XMovieActions/XMovieActionSoundPlay"), --BGM/CV/音效 播放 + [402] = require("XMovieActions/XMovieActionAudioInterrupt"), --BGM/CV/音效 打断 + + [501] = require("XMovieActions/XMovieActionEffectPlay"), --特效播放 + [502] = require("XMovieActions/XMovieActionAnimationPlay"), --UI动画播放 + [503] = require("XMovieActions/XMovieActionVideoPlay"), --视频播放 + [504] = require("XMovieActions/XMovieActionSetGray"), --灰度设置 + [505] = require("XMovieActions/XMovieActionUnLoad"), --动效卸载 + [506] = require("XMovieActions/XMovieActionPrefabAnimation"), --预制体动画 + + [601] = require("XMovieActions/XMovieActionStaff"), --staff职员表 +} + +--可以通过上一页返回到的节点 +local MovieBackFilter = { + [301] = true, --普通对话 +} + +XMovieManagerCreator = function() + local AllMovieActions = {} + local ActionIdToIndexDics = {} + + local CurPlayingMovieId + local CurPlayingActionIndex + local AutoPlay + local WaitToPlayList = {} + local DelaySelectionDic = {} + local ReviewDialogList = {} + local EndCallBack + local IsPlaying + local IsYield + local IsPause = false + local YieldCallBack + local MovieBackStack = XStack.New() + + local function InitMovieActions(movieId) + local movieActions = {} + local actionIdToIndexDic = {} + + local findEnd = false + local movieCfg = XMovieConfigs.GetMovieCfg(movieId) + for index, actionData in ipairs(movieCfg) do + local actionClass = ActionClass[actionData.Type] + if not actionClass then + XLog.Error("XMovieManager.InitMovieActions 配置节点类型错误,找不到对应的节点,Type: " .. actionData.Type) + return + end + + tableInsert(movieActions, actionClass.New(actionData)) + actionIdToIndexDic[actionData.ActionId] = index + + if actionData.IsEnd ~= 0 then + findEnd = true + end + end + + if not findEnd then + XLog.Error("XMovieManager.InitMovieActions error:没有配置结束标记IsEnd, movieId: ", movieId) + return + end + + AllMovieActions[movieId] = movieActions + ActionIdToIndexDics[movieId] = actionIdToIndexDic + + return movieActions + end + + local function GetMovieActions(movieId) + if not AllMovieActions[movieId] then + InitMovieActions(movieId) + end + + if not AllMovieActions[movieId] then + XLog.Error("XMovieManager GetMovieActions error:actions not exsit, movieId is: ", movieId) + return + end + + return AllMovieActions[movieId] + end + + local function GetActionIndexById(movieId, actionId) + local dic = ActionIdToIndexDics[movieId] + if not dic then + XLog.Error("XMovieManager GetActionIndexById error:dic not exsit, movieId is: " .. movieId .. ", actionId is: " .. actionId) + return + end + + local index = dic[actionId] + if not index then + XLog.Error("XMovieManager GetActionIndexById error:index not exsit, actionId is: " .. actionId) + end + return index + end + + local function OnPlayBegin(movieId, hideSkipBtn) + CurPlayingMovieId = movieId + CurPlayingActionIndex = 1 + WaitToPlayList = GetMovieActions(movieId) + ReviewDialogList = {} + MovieBackStack:Clear() + IsPlaying = true + IsPause = false + CsXGameEventManager.Instance:Notify(XEventId.EVENT_MOVIE_BEGIN, movieId) + XEventManager.DispatchEvent(XEventId.EVENT_MOVIE_BEGIN, movieId) + if not XLuaUiManager.IsUiShow(UI_MOVIE) then + XLuaUiManager.Open(UI_MOVIE, hideSkipBtn) + end + end + + local function OnPlayEnd() + if not CurPlayingMovieId then return end + + CurPlayingMovieId = nil + CurPlayingActionIndex = nil + AutoPlay = nil + ReviewDialogList = {} + DelaySelectionDic = {} + WaitToPlayList = {} + IsPlaying = nil + IsYield = nil + IsPause = false + YieldCallBack = nil + MovieBackStack:Clear() + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_MOVIE_END) + XEventManager.DispatchEvent(XEventId.EVENT_MOVIE_END) + + if XLuaUiManager.IsUiShow(UI_MOVIE) then + XLuaUiManager.Close(UI_MOVIE) + end + end + + --剧情UI完全关闭,所有节点清理行为结束 + local function AfterUiClosed() + if EndCallBack then + EndCallBack() + EndCallBack = nil + end + end + + local function DoAction(ignoreLock) + if not CurPlayingActionIndex or not next(WaitToPlayList) then + OnPlayEnd() + return + end + + if IsYield then + return + end + + if IsPause then + return + end + local action = WaitToPlayList[CurPlayingActionIndex] + + if not ignoreLock and action:IsWaiting() then + return + end + + if action:Destroy() then + if action:IsEnding() then + OnPlayEnd() + return + end + MovieBackStack:Push(CurPlayingActionIndex) + local indexChanged + + local selectedActionId = action:GetSelectedActionId() + if selectedActionId ~= 0 then + CurPlayingActionIndex = GetActionIndexById(CurPlayingMovieId, selectedActionId) + indexChanged = true + end + + local delaySelectedActionId = action:GetDelaySelectActionId() + if delaySelectedActionId ~= 0 then + CurPlayingActionIndex = GetActionIndexById(CurPlayingMovieId, delaySelectedActionId) + indexChanged = true + end + + local resumeActionId = action:GetResumeActionId() + if resumeActionId ~= 0 then + CurPlayingActionIndex = GetActionIndexById(CurPlayingMovieId, resumeActionId) + indexChanged = true + end + + if not indexChanged then + local nextActionId = action:GetNextActionId() + if nextActionId ~= 0 then + CurPlayingActionIndex = GetActionIndexById(CurPlayingMovieId, nextActionId) + indexChanged = true + end + end + + if not indexChanged then + CurPlayingActionIndex = CurPlayingActionIndex + 1 + end + + action = WaitToPlayList[CurPlayingActionIndex] + if not action then + OnPlayEnd() + return + end + end + + action:ChangeStatus() + end + + local XMovieManager = {} + + function XMovieManager.Init() + XEventManager.AddEventListener(XEventId.EVENT_MOVIE_BREAK_BLOCK, DoAction) + XEventManager.AddEventListener(XEventId.EVENT_MOVIE_UI_CLOSED, AfterUiClosed) + end + + local function PlayOldMovie(movieId, cb) + if not CSMovieXMovieManagerInstance:CheckMovieExist(movieId) then return end + CSMovieXMovieManagerInstance:PlayById(movieId, function() + if cb then cb() end + end) + end + + local function PlayNewMovie(movieId, cb, yieldCb, hideSkipBtn) + EndCallBack = cb + YieldCallBack = yieldCb + OnPlayBegin(movieId, hideSkipBtn) + end + + function XMovieManager.PlayMovie(movieId, cb, yieldCb, hideSkipBtn) + movieId = tostring(movieId) + if XMovieConfigs.CheckMovieConfigExist(movieId) then + PlayNewMovie(movieId, cb, yieldCb, hideSkipBtn) + else + PlayOldMovie(movieId, cb) + end + end + + function XMovieManager.StopMovie() + if not XMovieManager.IsPlayingMovie() then return end + if not XLuaUiManager.IsUiShow(UI_MOVIE) then return end + OnPlayEnd() + end + + function XMovieManager.BackToLastAction() + local curAction = WaitToPlayList[CurPlayingActionIndex] + local lastId = MovieBackStack:Peek() + if lastId ~= CurPlayingActionIndex then + curAction:OnUndo() + curAction:OnReset() + end + if MovieBackStack:Count() == 0 then + CurPlayingActionIndex = 1 + end + while(MovieBackStack:Count() ~= 0) do + local currIndex = MovieBackStack:Pop() + local action = WaitToPlayList[currIndex] + action:OnUndo() + action:OnReset() + if MovieBackFilter[action:GetType()] then + CurPlayingActionIndex = currIndex + break + end + if MovieBackStack:Count() == 0 then + CurPlayingActionIndex = 1 + break + end + end + XEventManager.DispatchEvent(XEventId.EVENT_MOVIE_BREAK_BLOCK) + end + + local function IsPlayingNewMovie() + return IsPlaying + end + + local function IsPlayingOldMovie() + return CSMovieXMovieManagerInstance:IsPlayingMovie() + end + + function XMovieManager.IsPlayingMovie() + return IsPlayingNewMovie() or IsPlayingOldMovie() + end + + function XMovieManager.IsMovieYield() + if not XMovieManager.IsPlayingMovie() then return false end + return IsYield or false + end + + function XMovieManager.YiledMovie() + if not YieldCallBack then return end --没有恢复回调时不允许挂起 + + IsYield = true + + YieldCallBack() + YieldCallBack = nil + end + + function XMovieManager.IsMoviePause() + if not XMovieManager.IsPlayingMovie() then return false end + return IsPause or false + end + + function XMovieManager.SetMoviePause(isPause) + IsPause = isPause + end + + function XMovieManager.SwitchMovieState() + IsPause = not IsPause + local action = WaitToPlayList[CurPlayingActionIndex] + if (not IsPause) and action:CanContinue() then + DoAction() + end + end + + function XMovieManager.ResumeMovie(index) + if not IsPlayingNewMovie() then + if IsPlayingOldMovie() then + XLog.Error("XMovieManager.ResumeMovie Error: 老版剧情不支持挂起恢复操作") + return + end + + XLog.Error("XMovieManager.ResumeMovie Error: 当前没有播放中的剧情") + return + end + + local action = WaitToPlayList[CurPlayingActionIndex] + if not IsYield or not action.ResumeAtIndex then + XLog.Error("XMovieManager.ResumeMovie Error: 当前没有挂起中的剧情, action: ", action) + return + end + + IsYield = nil + action:ResumeAtIndex(index) + DoAction() + end + + function XMovieManager.PushInReviewDialogList(roleName, dialogContent) + roleName = roleName and roleName ~= "" and roleName .. ": " or "" + dialogContent = dialogContent and dialogContent ~= "" and '"' .. dialogContent .. '"' or "" + + local data = { + RoleName = roleName, + Content = dialogContent, + } + tableInsert(ReviewDialogList, data) + end + + function XMovieManager.RemoveFromReviewDialogList() + if ReviewDialogList and #ReviewDialogList > 0 then + tableRemove(ReviewDialogList) + end + end + + function XMovieManager.DelaySelectAction(key, actionId) + DelaySelectionDic[key] = actionId + end + + function XMovieManager.GetDelaySelectActionId(key) + local actionId = DelaySelectionDic[key] + if actionId then + DelaySelectionDic[key] = nil + else + actionId = 0 + end + return actionId + end + + function XMovieManager.SwitchAutoPlay() + AutoPlay = not AutoPlay + local action = WaitToPlayList[CurPlayingActionIndex] + if action and action:CanContinue() then + XEventManager.DispatchEvent(XEventId.EVENT_MOVIE_AUTO_PLAY, AutoPlay) + end + end + + function XMovieManager.IsAutoPlay() + return AutoPlay + end + + function XMovieManager.GetReviewDialogList() + return ReviewDialogList + end + + function XMovieManager.ReplacePlayerName(str) + return XUiHelper.ReplaceWithPlayerName(str, XMovieConfigs.PLAYER_NAME_REPLACEMENT) + end + + function XMovieManager.Fit(width) + return width * RESOLUTION_RATIO + end + + function XMovieManager.ParamToNumber(param) + return param and param ~= "" and tonumber(param) or 0 + end + + function XMovieManager.TransTimeLineSeconds(time) + time = time or 0 + local interger = mathFloor(time) + local decimal = time - interger + return interger + TIMELINE_SECONDS_TRANS * decimal + end + + function XMovieManager.ReloadMovies() + if not IS_DEBUG then return end + + AllMovieActions = {} + ActionIdToIndexDics = {} + XMovieConfigs.DeleteMovieCfgs() + end + + function XMovieManager.GetMovieDescription() + return XMovieConfigs.GetMovieSkipSkipDesc(CurPlayingMovieId) + end + + XMovieManager.Init() + return XMovieManager +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XMusicPlayerManager.lua b/Resources/Scripts/XManager/XMusicPlayerManager.lua new file mode 100644 index 00000000..0fd1c396 --- /dev/null +++ b/Resources/Scripts/XManager/XMusicPlayerManager.lua @@ -0,0 +1,38 @@ + +-- +--Author: wujie +--Note: 音乐播放器管理 + +XMusicPlayerManagerCreator = function() + local XMusicPlayerManager = {} + + local UiMainNeedPlayedAlbumId + + function XMusicPlayerManager.Init() + local albumId = XSaveTool.GetData(XMusicPlayerConfigs.UiMainSavedAlbumIdKey) + if not albumId or not XMusicPlayerConfigs.IsHaveAlbumById(albumId) then + albumId = CS.XGame.ClientConfig:GetInt("MusicPlayerMainViewNeedPlayedAlbumId") + if albumId == 0 then + XLog.Error("Client/Config/ClientConfig.tab 表里面的 MusicPlayerMainViewNeedPlayedAlbumId 字段对应的值不能为0") + end + end + UiMainNeedPlayedAlbumId = albumId + local template = XMusicPlayerConfigs.GetAlbumTemplateById(albumId) + CS.XAudioManager.UiMainNeedPlayedBgmCueId = template.CueId + end + + function XMusicPlayerManager.ChangeUiMainAlbumId(albumId) + UiMainNeedPlayedAlbumId = albumId + XSaveTool.SaveData(XMusicPlayerConfigs.UiMainSavedAlbumIdKey, albumId) + local template = XMusicPlayerConfigs.GetAlbumTemplateById(albumId) + CS.XAudioManager.UiMainNeedPlayedBgmCueId = template.CueId + end + + function XMusicPlayerManager.GetUiMainNeedPlayedAlbumId() + return UiMainNeedPlayedAlbumId + end + + XMusicPlayerManager.Init() + return XMusicPlayerManager +end + diff --git a/Resources/Scripts/XManager/XNewRoleShowManager.lua b/Resources/Scripts/XManager/XNewRoleShowManager.lua new file mode 100644 index 00000000..9b7a8b93 --- /dev/null +++ b/Resources/Scripts/XManager/XNewRoleShowManager.lua @@ -0,0 +1,22 @@ +-- 未使用 +XNewRoleShowManager = XNewRoleShowManager or {} +-- +--local TABLE_NEWROLE_PATH = "Client/Story/StoryRole.tab" +--local RoleTemplate = {} +-- +function XNewRoleShowManager.Init() +-- RoleTemplate = XTableManager.ReadByIntKey(TABLE_NEWROLE_PATH, XTable.XTableStoryRole, "RoleId") +end +-- +--function XNewRoleShowManager.GetNewRoleShowTemplate(roleid) +-- if not roleid then +-- XLog.Error("XNewRoleShowManager.GetNewRoleShowTemplate 函数错误: 参数roleid不能为空") +-- return +-- end +-- local result = RoleTemplate[roleid] +-- if not result then +-- XLog.ErrorTableDataNotFound("XNewRoleShowManager.GetNewRoleShowTemplate", "result", TABLE_NEWROLE_PATH, "roleid", tostring(roleid)) +-- return +-- end +-- return result +--end diff --git a/Resources/Scripts/XManager/XNieRManager.lua b/Resources/Scripts/XManager/XNieRManager.lua new file mode 100644 index 00000000..ef94bc08 --- /dev/null +++ b/Resources/Scripts/XManager/XNieRManager.lua @@ -0,0 +1,1429 @@ +local XNieRChapter = require("XEntity/XNieR/XNieRChapter") +local XNieRCharacter = require("XEntity/XNieR/XNieRCharacter") +local XNieRRepeat = require("XEntity/XNieR/XNieRRepeat") +local XNieRBoss = require("XEntity/XNieR/XNieRBoss") +local XNierPOD = require("XEntity/XNieR/XNierPOD") +--尼尔玩法管理器 +XNieRManagerCreator = function() + local XNieRManager = {} + local NieRRepeatPOIndex = 3--复刷权限关在主线关卡位置 + local ActivityId = XNieRConfigs.GetDefaultActivityId() + local CurActivityConfig = {} + local ChapterDataList = {} + local ChapterDataDic = {} + local RepeatDataList = {} + local RepeatDataDic = {} + local BossStageIdToChapterId = {} + + local IsActivityEnd = true + local PassMainStageCount = 0 + local AllMainStageCount = 0 + + local NieRCharacterDic = {} + local NieRRobotIdToCharacterIdDic = {} + local SelCharacterId = 0 + local NieRBossDic = {} + + local NieRMainLineStageDic = {} + local NieRMainLineBossStageDic = {} + local NieRRepeatMainStage = {} + local NieRRepeatStage = {} + local NieREasterEggStage = {} + local NieRTeachingStage = {} + local SaveRepeatConsumCount = 0 + + + + local NierPODData = nil + + local BeginNieRData = {} + + local PlayerTeamData = {} + local TypeId = CS.XGame.Config:GetInt("TypeIdNieR") + local RepeatTypeId = CS.XGame.Config:GetInt("TypeIdNieRRepeat") + local DefaultTeam = { + CaptainPos = 1, + FirstFightPos = 1, + TeamData = { 0, 0, 0 }, + } + + local IsRegisterEditBattleProxy = false + local NierFubenPassed = false + + local NieREasterEggData = {} + local IsNieREasterEggDataRealPass = false + local CurSelEasterEggDataIndex = 0 + local LastSelEasterEggDataIndex = 0 + + local NieRRpc = { + NieRCharacterChangeFashion = "NieRCharacterChangeFashionRequest", --更换涂装请求 + NieRUpdateBossScore = "NieRUpdateBossScoreRequest", --保存BOSS分数 + NieRUpgradeSupportSkill = "NieRUpgradeSupportSkillRequest", --辅助机技能升级 + NieRSelectSupportSkill = "NieRSelectSupportSkillRequest", --选择辅助机技能 + NieREasterEggLeaveMessage = "NieREasterEggLeaveMessageRequest", --尼尔彩蛋关留言请求 + } + + local NieREasterEggStageShow = false + + local NierCharacterAbilityDicInit = false + local NieRCharacterAbilityDic = {} + local NieRRepeatExStagePass = false + + local NieRMainLineUITipsInfoInit = false + local NieRCharacterOpenDic = {} + local NieRRepeatPoStageOpenDic = {} + local NieRBossStageOpenDic = {} + local NierMainLineStagePass = false + + + function XNieRManager.RegisterEditBattleProxy() + if IsRegisterEditBattleProxy then return end + IsRegisterEditBattleProxy = true + XUiNewRoomSingleProxy.RegisterProxy(XDataCenter.FubenManager.StageType.NieR, + require("XUi/XUiNieR/XUiNieRNewRoomSingle")) + end + -- 初始化副本info + function XNieRManager.InitStageInfo() + local nieRType = XDataCenter.FubenManager.StageType.NieR + local nierChapterCfgs = XNieRConfigs.GetAllChapterConfig() + local nierCharacterCfgs = XNieRConfigs.GetAllCharacterConfig() + --主线剧情关 + for _, chapterCfg in pairs(nierChapterCfgs) do + for index, stageId in ipairs(chapterCfg.StageIds) do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + if stageInfo then + if stageInfo.Type and stageInfo.Type ~= nieRType then + XLog.Error(string.format("%s已设置了Type", stageId)) + end + stageInfo.Type = nieRType + else + XLog.Error(string.format("没有找到StageInfo,stageId:%s", stageId)) + end + NieRMainLineStageDic[stageId] = chapterCfg.ChapterId + end + local stageInfo = XDataCenter.FubenManager.GetStageInfo(chapterCfg.BossStageId) + if stageInfo then + if stageInfo.Type and stageInfo.Type ~= nieRType then + XLog.Error(string.format("%s已设置了Type", stageId)) + end + stageInfo.Type = nieRType + else + XLog.Error(string.format("没有找到StageInfo,stageId:%s", chapterCfg.BossStageId)) + end + NieRMainLineBossStageDic[chapterCfg.BossStageId] = chapterCfg.ChapterId + end + -- --教学关 + for _, characterCfg in pairs(nierCharacterCfgs) do + for _, stageId in pairs(characterCfg.TeachingStageIds) do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + if stageInfo then + if stageInfo.Type and stageInfo.Type ~= nieRType then + XLog.Error(string.format("%s已设置了Type", stageId)) + end + stageInfo.Type = nieRType + else + XLog.Error(string.format("没有%s", stageId)) + end + NieRTeachingStage[stageId] = characterCfg.CharacterId + end + end + --复刷关 + local repeatableCfgs = XNieRConfigs.GetRepeatableStageConfig() + for _, repeatableCfg in pairs(repeatableCfgs) do + for _, stageId in pairs(repeatableCfg.ExStageIds) do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + if stageInfo then + if stageInfo.Type and stageInfo.Type ~= nieRType then + XLog.Error(string.format("%s已设置了Type", stageId)) + end + stageInfo.Type = nieRType + else + XLog.Error(string.format("没有找到StageInfo,stageId:%s", stageId)) + end + NieRRepeatStage[stageId] = repeatableCfg.RepeatableStageId + end + local stageInfo = XDataCenter.FubenManager.GetStageInfo(repeatableCfg.RepeatableStageId) + if stageInfo then + if stageInfo.Type and stageInfo.Type ~= nieRType then + XLog.Error(string.format("%s已设置了Type", stageId)) + end + stageInfo.Type = nieRType + else + XLog.Error(string.format("没有找到StageInfo,stageId:%s", repeatableCfg.RepeatableStageId)) + end + NieRRepeatMainStage[repeatableCfg.RepeatableStageId] = repeatableCfg.RepeatableStageId + end + --彩蛋关 + local nieRActivityConfigs = XNieRConfigs.GetAllActivityConfig() + for _, nieRActiveityCfg in pairs(nieRActivityConfigs) do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(nieRActiveityCfg.EasterEggStageId) + if stageInfo then + if stageInfo.Type and stageInfo.Type ~= nieRType then + XLog.Error(string.format("%s已设置了Type", stageId)) + end + stageInfo.Type = nieRType + else + XLog.Error(string.format("没有找到StageInfo,stageId:%s", stageId)) + end + NieREasterEggStage[nieRActiveityCfg.EasterEggStageId] = nieRActiveityCfg.EasterEggStageId + end + + for _, nieRCharacter in pairs(NieRCharacterDic) do + nieRCharacter:ResetNeedUpdateNieRCharAbility() + end + end + + function XNieRManager.CheckPreFight(stage, challengeCount) + local stageId = stage.StageId + + if NieRRepeatMainStage[stageId] then + local repeatData = XNieRManager.GetRepeatDataById(stageId) + local itemId, count = XDataCenter.NieRManager.GetRepeatStageConsumeId(), repeatData:GetNierRepeatStageConsumeCount() + local itemCount = XDataCenter.ItemManager.GetCount(itemId) + if not XDataCenter.ItemManager.DoNotEnoughBuyAsset(itemId, count, 1, nil, "NieRRepeatTickNotEnough") then + return false + end + elseif NieRRepeatStage[stageId] then + local repeatData = XNieRManager.GetRepeatDataById(NieRRepeatStage[stageId]) + local itemId, count = repeatData:GetExConsumIdAndCount(stageId) + if not XDataCenter.ItemManager.DoNotEnoughBuyAsset(itemId, count, 1, nil, "NieRRepeatTickNotEnough") then + return false + end + end + + return true + end + --战斗开始前记录一部分数据 + function XNieRManager.OpenFightLoading(stageId) + if NieRRepeatMainStage[stageId] or NieRRepeatStage[stageId] then + for _, nierCharcter in pairs(XNieRManager.GetNieRCharacterDic()) do + local tmpCharacter = {} + tmpCharacter.Id = nierCharcter:GetNieRCharacterId() + tmpCharacter.OldLevel = nierCharcter:GetNieRCharacterLevel() + tmpCharacter.OldExp = nierCharcter:GetNieRCharacterExp() + tmpCharacter.OldMaxExp = nierCharcter:GetNieRCharacterMaxExp() + tmpCharacter.IsOldMaxLevel = nierCharcter:CheckNieRCharacterMaxLevel() + BeginNieRData.NierCharacter = BeginNieRData.NierCharacter or {} + BeginNieRData.NierCharacter[nierCharcter:GetNieRCharacterUpLevelItemId()] = tmpCharacter + end + if NierPODData then + local tmpNieRPOD = {} + tmpNieRPOD.Id = NierPODData:GetNieRPODId() + tmpNieRPOD.OldLevel = NierPODData:GetNieRPODLevel() + tmpNieRPOD.OldExp = NierPODData:GetNieRPODExp() + tmpNieRPOD.IsOldMaxLevel = NierPODData:CheckNieRPODMaxLevel() + tmpNieRPOD.OldMaxExp = NierPODData:GetNieRPODMaxExp() + BeginNieRData.NierPOD = BeginNieRData.NierPOD or {} + BeginNieRData.NierPOD[NierPODData:GetNieRPODUpLevelItemId()] = tmpNieRPOD + end + end + NierFubenPassed = XDataCenter.FubenManager.CheckStageIsPass(stageId) + XDataCenter.FubenManager.OpenFightLoading(stageId) + end + + function XNieRManager.ShowReward(winData) + if not winData then return end + if NierFubenPassed then + XEventManager.DispatchEvent(XEventId.EVENT_FUBEN_NIER_STAGE_REWARD) + NierFubenPassed = false + end + if winData.SettleData.NieRBossFightResult then + XLuaUiManager.Open("UiNieRBossFightResult", winData) + return + end + if NieREasterEggStage[winData.StageId] then + XLuaUiManager.Open("UiNieREasterEgg", true, false) + return + end + + if NieRRepeatStage[winData.StageId] then + NieRRepeatExStagePass = true + end + if NieRMainLineStageDic[winData.StageId] then + NierMainLineStagePass = true + end + + local closeCb = function() + local stageId = winData.StageId + if (NieRRepeatMainStage[stageId] or NieRRepeatStage[stageId]) and next(BeginNieRData) ~= nil then + local showList = {} + local podInfo + for _, item in pairs(winData.SettleData.RewardGoodsList) do + local nierCharacterData = BeginNieRData.NierCharacter[item.TemplateId] + if nierCharacterData then + -- local nierCharacterId = nierCharacterData.id + -- local nierCharcter = XNieRManager.GetNieRCharacterByCharacterId(nierCharacterId) + -- nierCharacterData.NewLevel = nierCharcter:GetNieRCharacterLevel() + -- nierCharacterData.NewExp = nierCharcter:GetNieRCharacterExp() + nierCharacterData.Item = item + table.insert(showList, nierCharacterData) + end + if not podInfo and BeginNieRData.NierPOD[item.TemplateId] then + podInfo = BeginNieRData.NierPOD[item.TemplateId] + if podInfo then + podInfo.Item = item + end + end + end + + if #showList > 0 or podInfo then + local donotShow = true + if #showList > 0 then + for _, info in ipairs(showList) do + if not info.IsOldMaxLevel then + donotShow = false + break + end + end + end + if donotShow and podInfo and not podInfo.IsOldMaxLevel then + donotShow = false + end + if donotShow then + else + XLuaUiManager.Open("UiFubenNierShengji", showList, podInfo) + end + end + elseif (NieRMainLineStageDic[stageId] or NieRMainLineBossStageDic[stageId]) then + local nieRChapterId = NieRMainLineStageDic[stageId] or NieRMainLineBossStageDic[stageId] + local nieRChapter = XNieRManager.GetChapterDataById(nieRChapterId) + if not nieRChapter:CheckNieRChapterUnLock() then + XUiManager.TipText("NieRActivityChapterEnd") + XLuaUiManager.RunMain() + + end + end + BeginNieRData = {} + end + XLuaUiManager.Open("UiSettleWin", winData, nil, closeCb, true) + end + + --判断活动是否开启 + function XNieRManager.GetIsActivityEnd() + local timeNow = XTime.GetServerNowTimestamp() + local isEnd = timeNow >= XNieRManager.GetEndTime() + local isStart = timeNow >= XNieRManager.GetStartTime() + local inActivity = (not isEnd) and (isStart) + return IsActivityEnd or not inActivity, timeNow < XNieRManager.GetStartTime() + end + + --获取本轮开始时间 + function XNieRManager.GetStartTime() + if not CurActivityConfig then return 0 end + return XFunctionManager.GetStartTimeByTimeId(CurActivityConfig.TimeId) or 0 + end + + --获取本轮结束时间 + function XNieRManager.GetEndTime() + if not CurActivityConfig then return 0 end + return XFunctionManager.GetEndTimeByTimeId(CurActivityConfig.TimeId) or 0 + end + + --=================== + --获取活动配置简表 + --=================== + function XNieRManager.GetActivityChapters() + local chapters = {} + if CurActivityConfig and not XNieRManager.GetIsActivityEnd() then + local tempChapter = {} + tempChapter.Id = CurActivityConfig.Id + tempChapter.Name = XNieRManager.GetActivityName() + tempChapter.Type = XDataCenter.FubenManager.ChapterType.NieR + tempChapter.BannerBg = CurActivityConfig.BannerBg + table.insert(chapters, tempChapter) + -- else + -- local nieRActivityConfigs = XNieRConfigs.GetAllActivityConfig() + -- if nieRActivityConfigs then + -- for _, cfg in pairs(nieRActivityConfigs) do + -- local startTime = XFunctionManager.GetStartTimeByTimeId(cfg.TimeId) + -- local endTime = XFunctionManager.GetEndTimeByTimeId(cfg.TimeId) + -- local timeNow = XTime.GetServerNowTimestamp() + -- XLog.Debug(".GetActivityChapters..",startTime,endTime,timeNow) + -- if timeNow >= startTime and timeNow < endTime then + -- local tempChapter = {} + -- tempChapter.Id = cfg.Id + -- tempChapter.Name = cfg.Name or "" + -- tempChapter.Type = XDataCenter.FubenManager.ChapterType.NieR + -- tempChapter.BannerBg = cfg.BannerBg + -- table.insert(chapters, tempChapter) + -- break + -- end + -- end + -- end + end + + return chapters + end + + --获取当前已通过的关卡数 + function XNieRManager.GetPassMainStageCount() + PassMainStageCount = 0 + if not CurActivityConfig then + return 0 + end + for index, chapterId in ipairs(CurActivityConfig.ChapterIds) do + local chapterConfig = XNieRConfigs.GetChapterConfigById(chapterId) + for __, stageId in ipairs(chapterConfig.StageIds) do + + if XDataCenter.FubenManager.CheckStageIsPass(stageId) then + PassMainStageCount = PassMainStageCount + 1 + end + end + if chapterConfig.BossStageId ~= 0 then + if XDataCenter.FubenManager.CheckStageIsPass(chapterConfig.BossStageId) then + PassMainStageCount = PassMainStageCount + 1 + end + end + end + return PassMainStageCount + end + + --获取所有的关卡数 + function XNieRManager.GetAllMainStageCount() + return AllMainStageCount + end + + --获取当前通关情况的字符串 + function XNieRManager.GetChapterProgressStr() + return CS.XTextManager.GetText("NieRChapterProgressStr", XNieRManager.GetPassMainStageCount(), XNieRManager.GetAllMainStageCount()) + end + + --获得活动名字 + function XNieRManager.GetActivityName() + if not CurActivityConfig then return "" end + return CurActivityConfig.Name or "" + end + + --处理当前活动状态改变的方法 + function XNieRManager.CurActivtityConfigChange() + PassMainStageCount = 0 + AllMainStageCount = 0 + ChapterDataList = {} + ChapterDataDic = {} + RepeatDataList = {} + RepeatDataDic = {} + BossStageIdToChapterId = {} + + NierCharacterAbilityDicInit = false + NieRCharacterAbilityDic = {} + NieRRepeatExStagePass = false + + NieRMainLineUITipsInfoInit = false + NieRCharacterOpenDic = {} + NieRRepeatPoStageOpenDic = {} + NieRBossStageOpenDic = {} + NierMainLineStagePass = false + + if ActivityId == 0 then return end + CurActivityConfig = XNieRConfigs.GetActivityConfigById(ActivityId) + + + if not CurActivityConfig then + return + end + for index, chapterId in ipairs(CurActivityConfig.ChapterIds) do + local chapterConfig = XNieRConfigs.GetChapterConfigById(chapterId) + + for __, stageId in ipairs(chapterConfig.StageIds) do + AllMainStageCount = AllMainStageCount + 1 + end + if chapterConfig.BossStageId ~= 0 then + AllMainStageCount = AllMainStageCount + 1 + end + BossStageIdToChapterId[chapterConfig.BossStageId] = chapterId + XNieRManager.InitChapterEntity(chapterId, index) + end + for index, repeatId in ipairs(CurActivityConfig.RepeatableStageIds) do + XNieRManager.InitRepeatEntity(repeatId, index) + end + + IsActivityEnd = false + end + + --获取当前活动的章节表 + function XNieRManager.GetCurActivityChapterIds() + if not CurActivityConfig then return {} end + return CurActivityConfig.ChapterIds or {} + end + + function XNieRManager.GetCurDevelopCharacterIds() + if not CurActivityConfig then return {} end + return CurActivityConfig.DevelopCharacterIds + end + + --初始化章节对象 + function XNieRManager.InitChapterEntity(chapterId, index) + local tmpChapterData = XNieRChapter.New(chapterId, index) + local lastChapterData + if index > 1 then + lastChapterData = ChapterDataList[index - 1] + end + + + table.insert(ChapterDataList, tmpChapterData) + ChapterDataDic[chapterId] = tmpChapterData + end + + --获取章节对象列表 + function XNieRManager.GetChapterDataList() + return ChapterDataList + end + + --根据Index获取章节对象 + function XNieRManager.GetChapterDataByIndex(index) + return ChapterDataList[index] + end + + --根据Id获取章节对象 + function XNieRManager.GetChapterDataById(chapterId) + return ChapterDataDic[chapterId] + end + + --尼尔玩法复刷关信息 + --初始化复刷关对象 + function XNieRManager.InitRepeatEntity(repeatId, index) + local tmpRepeatData = XNieRRepeat.New(repeatId, index) + local lastChapterData + + table.insert(RepeatDataList, tmpRepeatData) + RepeatDataDic[repeatId] = tmpRepeatData + end + + --获取复刷关对象列表 + function XNieRManager.GetRepeatDataList() + return RepeatDataList + end + + --根据Index获取复刷关对象 + function XNieRManager.GetRepeatDataByIndex(index) + return RepeatDataList[index] + end + + --根据Id获取复刷关对象 + function XNieRManager.GetRepeatDataById(repeatId) + return RepeatDataDic[repeatId] + end + + --根据Id获取复刷关门票Id + function XNieRManager.GetRepeatStageConsumeId() + if not CurActivityConfig then return 0 end + return CurActivityConfig.RepeatableConsumeId + end + + --获得复刷关门票最大数量 + function XNieRManager.GetNieRRepeatConsumeMaxCount() + if not CurActivityConfig then return 0 end + return CurActivityConfig.RepeatableConsumeMaxCount or 0 + end + + function XNieRManager.CheckNieRRepeatMainStage(stageId) + return NieRRepeatMainStage[stageId] or false + end + + --处理尼尔POD辅助机 + function XNieRManager.UpdateNieRPODData(data) + if not NierPODData then + NierPODData = XNierPOD.New(data) + else + NierPODData:UpdateNierPOD(data) + end + end + + function XNieRManager.GetNieRPODData() + return NierPODData + end + + --处理尼尔Boss + function XNieRManager.UpdateNieRBossData(data) + local stageId = data.StageId + + if not NieRBossDic[stageId] then + NieRBossDic[stageId] = XNieRBoss.New(data, BossStageIdToChapterId[stageId]) + else + NieRBossDic[stageId]:UpdateData(data, BossStageIdToChapterId[stageId]) + end + return NieRBossDic[stageId] + end + + function XNieRManager.GetNieRBossDataById(stageId) + if not NieRBossDic[stageId] then + local data = {} + data.StageId = stageId + data.LeftHp = XNieRConfigs.GetChapterConfigById(BossStageIdToChapterId[stageId]).BossHp + data.Score = 0 + NieRBossDic[stageId] = XNieRBoss.New(data, BossStageIdToChapterId[stageId]) + end + return NieRBossDic[stageId] + end + + --处理尼尔角色 + function XNieRManager.UpdateNieRCharacterData(data) + local characterId = data.CharacterId + if not NieRCharacterDic[characterId] then + NieRCharacterDic[characterId] = XNieRCharacter.New(data) + local robotId = NieRCharacterDic[characterId]:GetNieRCharacterRobotId() + NieRRobotIdToCharacterIdDic[robotId] = characterId + else + local nieRCharacter = NieRCharacterDic[characterId] + local lastRobotId = nieRCharacter:GetNieRCharacterRobotId() + NieRRobotIdToCharacterIdDic[lastRobotId] = nil + nieRCharacter:UpdateNieRCharacter(data) + local robotId = NieRCharacterDic[characterId]:GetNieRCharacterRobotId() + NieRRobotIdToCharacterIdDic[robotId] = characterId + NieRCharacterDic[characterId]:ResetNeedUpdateNieRCharAbility() + if lastRobotId ~= robotId then + XNieRManager.ChangeAllPlayerTeam(lastRobotId, robotId, TypeId) + XNieRManager.ChangeAllPlayerTeam(lastRobotId, robotId, RepeatTypeId) + end + end + end + + --获得角色列表 + function XNieRManager.GetChapterCharacterList(repeatId, chapterId) + local CharacterList = {} + local CharacterDic = {} + if not repeatId then + local roboteIds = XNieRManager.GetChapterDataById(chapterId):GetNierChapterRobotIds() or {} + for _, robotId in ipairs(roboteIds) do + table.insert(CharacterList, robotId) + CharacterDic[robotId] = true + end + else + local nieRRepeat = XNieRManager.GetRepeatDataById(repeatId) + local roboteIds = nieRRepeat:GetNieRRepeatRobotIds() or {} + for _, robotId in ipairs(roboteIds) do + table.insert(CharacterList, robotId) + CharacterDic[robotId] = true + end + end + local characterIds = XNieRManager.GetCurDevelopCharacterIds() + for _, id in pairs(characterIds) do + local nieRCharacter = NieRCharacterDic[id] + if nieRCharacter:CheckNieRCharacterCondition() then + local robotId = nieRCharacter:GetNieRCharacterRobotId() + table.insert(CharacterList, robotId) + CharacterDic[robotId] = true + end + end + return CharacterList, CharacterDic + end + + function XNieRManager.GetCharacterCount() + local count, unlockCount = 0, 0 + local characterIds = XNieRManager.GetCurDevelopCharacterIds() or {} + for _, id in pairs(characterIds) do + local nieRCharacter = NieRCharacterDic[id] + if nieRCharacter and nieRCharacter:CheckNieRCharacterCondition() then + unlockCount = unlockCount + 1 + end + count = count + 1 + end + return unlockCount, count + end + + --根据机器人Id获取尼尔角色的角色Id + function XNieRManager.GetCharacterIdByNieRRobotId(robotId) + return NieRRobotIdToCharacterIdDic[robotId] or 0 + end + + function XNieRManager.SetSelCharacterId(value) + SelCharacterId = value + end + + function XNieRManager.GetSelNieRCharacter() + return NieRCharacterDic[SelCharacterId] + end + + function XNieRManager.GetNieRCharacterByCharacterId(characterId) + return NieRCharacterDic[characterId] + end + + function XNieRManager.GetNieRCharacterDic() + return NieRCharacterDic + end + + --获取尼尔玩法队伍信息 + function XNieRManager.GetPlayerTeamData(stageId) + local typeId = TypeId + local robotList + local robotDic = {} + local CurTeamData + local teamData + if NieREasterEggStage[stageId] then + local characterIds = XNieRManager.GetCurDevelopCharacterIds() + local CharacterList = {} + for _, id in pairs(characterIds) do + local nieRCharacter = NieRCharacterDic[id] + if nieRCharacter:CheckNieRCharacterCondition() and nieRCharacter:GetNieRCharacterCfgEasterEggFightTag() ~= 0 then + table.insert(CharacterList, nieRCharacter) + end + end + table.sort(CharacterList, function(a, b) + return a:GetNieRCharacterCfgEasterEggFightTag() < b:GetNieRCharacterCfgEasterEggFightTag() + end) + teamData = XTool.Clone(DefaultTeam) + for key, id in pairs(teamData.TeamData) do + if CharacterList[key] then + teamData.TeamData[key] = CharacterList[key]:GetNieRCharacterRobotId() + end + end + return teamData + elseif NieRRepeatMainStage[stageId] or NieRRepeatStage[stageId] then + typeId = RepeatTypeId + robotList, robotDic = XDataCenter.NieRManager.GetChapterCharacterList(NieRRepeatMainStage[stageId] or NieRRepeatStage[stageId], nil) + elseif NieRMainLineBossStageDic[stageId] or NieRMainLineStageDic[stageId] then + typeId = TypeId + robotList, robotDic = XDataCenter.NieRManager.GetChapterCharacterList(nil, NieRMainLineBossStageDic[stageId] or NieRMainLineStageDic[stageId]) + end + local teamId = XDataCenter.TeamManager.GetTeamId(typeId) + + if XDataCenter.TeamManager.GetPlayerTeamData(teamId) then + CurTeamData = XDataCenter.TeamManager.GetPlayerTeamData(teamId) + teamData = XTool.Clone(CurTeamData) + else + DefaultTeam.TeamId = teamId + teamData = XTool.Clone(DefaultTeam) + end + + for key, id in pairs(teamData.TeamData) do + if not robotDic[id] then + teamData.TeamData[key] = 0 + end + end + return teamData + end + + function XNieRManager.SetPlayerTeamData(curTeam, stageId) + local typeId = TypeId + if NieRRepeatMainStage[stageId] or NieRRepeatStage[stageId] then + typeId = RepeatTypeId + elseif NieRMainLineBossStageDic[stageId] then + typeId = TypeId + end + XDataCenter.TeamManager.SetPlayerTeam(curTeam, false, function() + + end) + end + + function XNieRManager.ChangeAllPlayerTeam(lastRobotId, robotId, typeId) + local teamId = XDataCenter.TeamManager.GetTeamId(typeId) + local CurTeamData = XDataCenter.TeamManager.GetPlayerTeamData(teamId) + if not CurTeamData or not CurTeamData.TeamData then + return + end + + local needSaveToServer = false + for key, id in ipairs(CurTeamData.TeamData) do + if id == lastRobotId then + CurTeamData.TeamData[key] = robotId + needSaveToServer = true + break + end + end + + if needSaveToServer then + XDataCenter.TeamManager.SetPlayerTeam(CurTeamData, false, function() + + end) + end + end + + function XNieRManager.CheckCharacterInformationUnlock(id, isUnlockClick) + local isUnlock = XSaveTool.GetData(string.format("%d%s%d", XPlayer.Id, "NieRCharacterInformation", id)) + if not isUnlock then + XSaveTool.SaveData(string.format("%d%s%d", XPlayer.Id, "NieRCharacterInformation", id), isUnlockClick) + if isUnlockClick then + XEventManager.DispatchEvent(XEventId.EVENT_NIER_CHARACTER_UPDATE) + end + return false + else + return true + end + end + + function XNieRManager.SaveSelRepeatStageId(stageId) + XSaveTool.SaveData(string.format("%d%s", XPlayer.Id, "NieRRepeatSelMainStageId"), stageId) + end + + function XNieRManager.GetSelRepeatStageId() + local lastSelStageId = XSaveTool.GetData(string.format("%d%s", XPlayer.Id, "NieRRepeatSelMainStageId")) + return lastSelStageId or 0 + end + + function XNieRManager.RemoveAllPreData() + local allCharacterConfig = XNieRConfigs.GetAllCharacterConfig() + for _, charConfig in pairs(allCharacterConfig) do + local inforList = XNieRConfigs.GetNieRCharacterInforListById(charConfig.CharacterId) + for _, config in ipairs(inforList) do + XSaveTool.RemoveData(string.format("%d%s%d", XPlayer.Id, "NieRCharacterInformation", config.Id)) + end + end + + XSaveTool.RemoveData(string.format("%d%s", XPlayer.Id, "NieRRepeatSelMainStageId")) + XSaveTool.RemoveData(string.format("%d%s", XPlayer.Id, "NieREasterEggStageShow")) + XSaveTool.RemoveData(string.format("%d%s", XPlayer.Id, "NieRRepeatRedCheckCount")) + XSaveTool.RemoveData(string.format("%d%s", XPlayer.Id, "NieRActivityIdSave")) + end + + --尼尔玩法商店信息 + function XNieRManager.GetActivityShopIds() + if not CurActivityConfig then return {} end + return CurActivityConfig.ShopIds + end + + function XNieRManager.GetActivityShopConditionByShopId(shopId) + return XShopManager.GetShopConditionIdList(shopId) + end + + function XNieRManager.GetActivityShopGoodsByShopId(shopId) + local goods = XShopManager.GetShopGoodsList(shopId) + return goods + end + + function XNieRManager.GetActivityShopBtnNameById(shopId) + return XNieRConfigs.GetNieRShopById(shopId).BtnName + end + + function XNieRManager.GetActivityShopItemBgById(shopId) + return XNieRConfigs.GetNieRShopById(shopId).ShopItemBg + end + + function XNieRManager.GetActivityShopBgById(shopId) + return XNieRConfigs.GetNieRShopById(shopId).ShopBg + end + + function XNieRManager.GetActivityShopIconById(shopId) + return XNieRConfigs.GetNieRShopById(shopId).ShopIcon + end + + function XNieRManager.GetActivityNierTaskGroupList() + local taskGroupList = CurActivityConfig and CurActivityConfig.TaskGroupIds or {} + local taskGroupCfgsList = {} + + for _, groupId in ipairs(taskGroupList) do + local cfg = XNieRConfigs.GetNieRTaskGroupByGroupId(groupId) + if not XNieRManager.CheckNieREasterEggStagePassed() and cfg.EasterEggTask == 1 then + else + table.insert(taskGroupCfgsList, cfg) + end + + end + table.sort(taskGroupCfgsList, function(a, b) + return a.Priority < b.Priority + end) + return taskGroupCfgsList + end + + --处理尼尔玩法任务部分 + function XNieRManager.GetActivityNierTaskByChapterId(groupId) + return XDataCenter.TaskManager.GetNierTaskListByGroupId(groupId) + end + + --检查尼尔玩法任务红点 + function XNieRManager.CheckNieRTaskRed(groupId) + if XNieRManager.GetIsActivityEnd() then return false end + if groupId > 0 then + local taskList = XDataCenter.TaskManager.GetNierTaskListByGroupId(groupId) + for _, tasks in ipairs(taskList) do + if tasks ~= nil and tasks.State == XDataCenter.TaskManager.TaskState.Achieved then + return true + end + end + else + return XDataCenter.TaskManager.GetIsRewardForEx(XDataCenter.TaskManager.TaskType.NieR) + end + end + + -----------------------------------------尼尔彩蛋关----------------------------------------------- + function XNieRManager.UpdateNieREasterEggData(players) + NieREasterEggData = {} + CurSelEasterEggDataIndex = 0 + LastSelEasterEggDataIndex = 0 + for _, info in pairs(players) do + local tmp = {} + tmp.PlayerId = info.PlayerId + tmp.PlayerName = info.PlayerName + tmp.MessageId = info.MessageId + tmp.Age = info.Age + tmp.LabelId = info.LabelId + table.insert(NieREasterEggData, tmp) + end + local needCount = XNieRManager.GetCurMaxEasterEggMessageCount() - #NieREasterEggData + if needCount > 0 then + local ConfigMsg = XNieRConfigs.GetNieREasterEggInitMessageConfig() + for i = 1, needCount do + local config = ConfigMsg[i] + if config then + local tmp = {} + tmp.PlayerName = config.PlayerName + tmp.MessageId = config.MessageId + tmp.Age = config.Age + tmp.LabelId = config.LabelId + table.insert(NieREasterEggData, tmp) + end + end + end + end + + function XNieRManager.NieREasterEggDataRealPass() + IsNieREasterEggDataRealPass = true + end + + function XNieRManager.GetNieREasterEggData() + return NieREasterEggData + end + + function XNieRManager.GetCurNieREasterEggStageId() + if not CurActivityConfig then return 0 end + return CurActivityConfig.EasterEggStageId + end + + function XNieRManager.GetCurNieREasterEggAgeInfo() + if not CurActivityConfig then return 0, 0 end + return CurActivityConfig.EasterEggMinAge, CurActivityConfig.EasterEggMaxAge + end + + function XNieRManager.GetCurMaxEasterEggMessageCount() + if not CurActivityConfig then return 0 end + return CurActivityConfig.MaxEasterEggMessageCount + end + + function XNieRManager.OpenNieREasterEggCom() + if not XLuaUiManager.IsUiLoad("UiFunctionalOpen") then + XLuaUiManager.Open("UiFunctionalOpen", XNieRConfigs.GetNieREasterEggComConfig(), false, false) + end + end + + function XNieRManager.OpenNieRDataSaveUi() + XLuaUiManager.Open("UiNieRSaveData") + end + + function XNieRManager.GetNieREasrerEggPlayerName() + local lastName, nowName + if LastSelEasterEggDataIndex == 0 then + CurSelEasterEggDataIndex = CurSelEasterEggDataIndex + 1 + nowName = NieREasterEggData[CurSelEasterEggDataIndex].PlayerName + else + lastName = NieREasterEggData[LastSelEasterEggDataIndex].PlayerName + nowName = NieREasterEggData[CurSelEasterEggDataIndex].PlayerName + end + LastSelEasterEggDataIndex = CurSelEasterEggDataIndex + CurSelEasterEggDataIndex = CurSelEasterEggDataIndex + 1 + CurSelEasterEggDataIndex = CurSelEasterEggDataIndex > XNieRManager.GetCurMaxEasterEggMessageCount() and 1 or CurSelEasterEggDataIndex + return lastName, nowName + end + + --检查是否需要显示彩蛋关(每次BOSS数据更新后检查) + function XNieRManager.CheckNieREasterEggStageShow() + if NieREasterEggStageShow then return end + for _, nieRBossData in pairs(NieRBossDic) do + if not nieRBossData:IsBossDeath() then + NieREasterEggStageShow = false + return + end + end + NieREasterEggStageShow = true + end + + --获取彩蛋关显示状态 + function XNieRManager.GetNieREasterEggStageShow() + return NieREasterEggStageShow + end + + --是否第一次通过所有BOSS播放彩蛋剧情 + function XNieRManager.CheckFirstNieREasterEggStageShow() + if NieREasterEggStageShow then + if not XSaveTool.GetData(string.format("%d%s", XPlayer.Id, "NieREasterEggStageShow")) then + XSaveTool.SaveData(string.format("%d%s", XPlayer.Id, "NieREasterEggStageShow"), true) + return true + end + end + return false + end + + --检查彩蛋关是否已经完成 + function XNieRManager.CheckNieREasterEggStagePassed() + return IsNieREasterEggDataRealPass + end + -----------------------------------------尼尔彩蛋关结束----------------------------------------------- + -----------------------------------------尼尔内部条件检测---------------------------------------------- + function XNieRManager.CheckNieRMainLineUITips() + local nierCharacterDic = XNieRManager.GetNieRCharacterDic() or {} + + if not NieRMainLineUITipsInfoInit then + local nierChapterDataList = XNieRManager.GetChapterDataList() or {} + for key, nieRCharacter in pairs(nierCharacterDic) do + if not nieRCharacter:CheckNieRCharacterCondition() then + NieRCharacterOpenDic[key] = true + end + end + for _, nieRChapter in pairs(nierChapterDataList) do + local stageId = nieRChapter:GetNieRRepeatPoStageId() + if not XDataCenter.FubenManager.CheckStageIsUnlock(stageId) then + NieRRepeatPoStageOpenDic[stageId] = true + end + stageId = nieRChapter:GetNieRBossStageId() + if not XDataCenter.FubenManager.CheckStageIsUnlock(stageId) then + NieRBossStageOpenDic[stageId] = true + end + end + NieRMainLineUITipsInfoInit = true + else + if not NierMainLineStagePass then return end + local haveOpenBoss = {} + local haveOpenCharacter = {} + local haveOpenRepeatPo = {} + for stageId, _ in pairs(NieRBossStageOpenDic) do + if XDataCenter.FubenManager.CheckStageIsUnlock(stageId) then + haveOpenBoss[stageId] = true + end + end + for characterId, _ in pairs(NieRCharacterOpenDic) do + local character = nierCharacterDic[characterId] + if character and character:CheckNieRCharacterCondition() then + haveOpenCharacter[characterId] = true + end + end + for stageId, _ in pairs(NieRRepeatPoStageOpenDic) do + if XDataCenter.FubenManager.CheckStageIsUnlock(stageId) then + haveOpenRepeatPo[stageId] = true + end + end + for stageId, _ in pairs(haveOpenBoss) do + NieRBossStageOpenDic[stageId] = nil + XUiManager.TipMsgEnqueue(CS.XTextManager.GetText("NieRMainLineNewJieDuanOpenTips")) + end + for characterId, _ in pairs(haveOpenCharacter) do + NieRCharacterOpenDic[characterId] = nil + local character = nierCharacterDic[characterId] + if character then + local name = character:GetNieRCharName() + XUiManager.TipMsgEnqueue(CS.XTextManager.GetText("NieRNewCharacterOpenTips", name)) + end + end + for stageId, _ in pairs(haveOpenRepeatPo) do + NieRRepeatPoStageOpenDic[stageId] = nil + XUiManager.TipMsgEnqueue(CS.XTextManager.GetText("NieRNewQuanXianStageOpenTips")) + end + NierMainLineStagePass = false + end + end + + --检查尼尔角色能力开启(优化TIPS弹出) + function XNieRManager.CheckNieRCharacterAbilityOpen() + local nierCharacterDic = XNieRManager.GetNieRCharacterDic() or {} + if not NierCharacterAbilityDicInit then + for _, nieRCharacter in pairs(nierCharacterDic) do + local abilityConfigList = nieRCharacter:GetAllNieRAbilityConfigList() + local tmpNotOpenAbility = {} + for _, config in pairs(abilityConfigList) do + if config.Condition ~= 0 and not XConditionManager.CheckCondition(config.Condition) then + tmpNotOpenAbility[config.Id] = config + end + end + NieRCharacterAbilityDic[nieRCharacter:GetNieRCharacterId()] = tmpNotOpenAbility + end + NierCharacterAbilityDicInit = true + else + if not NieRRepeatExStagePass then return end + for nieRCharacterId, notOpenAbilityList in pairs(NieRCharacterAbilityDic) do + local haveOpenAbility = {} + for _, config in pairs(notOpenAbilityList) do + if XConditionManager.CheckCondition(config.Condition) then + local tmp = {} + tmp.NieRCharacterId = nieRCharacterId + tmp.ConfigName = config.TitleStr or "" + haveOpenAbility[config.Id] = tmp + end + end + for id, info in pairs(haveOpenAbility) do + notOpenAbilityList[id] = nil + local nierCharacter = nierCharacterDic[info.NieRCharacterId] + if nierCharacter then + local name = nierCharacter:GetNieRCharName() + XUiManager.TipMsgEnqueue(CS.XTextManager.GetText("NieRCharacterAbilityOpenTips", name, info.ConfigName)) + end + + end + end + NieRRepeatExStagePass = false + end + end + + -----------------------------------------尼尔内部条件检测结束------------------------------------------- + function XNieRManager.SaveNieRRepeatRedCheckCount() + -- local consumeId, consumCount = XNieRManager.GetRepeatStageConsumeId(), 0 + -- local haveCount = XDataCenter.ItemManager.GetCount(consumeId) + -- SaveRepeatConsumCount = haveCount + -- XSaveTool.SaveData(string.format("%d%s", XPlayer.Id, "NieRRepeatRedCheckCount"), haveCount) + local nowTime = XTime.GetServerNowTimestamp() + XSaveTool.SaveData(string.format("%d%s", XPlayer.Id, "NieRRepeatRedCheckCount"), nowTime) + end + + function XNieRManager.CheckNieRRepeatRedTime() + -- local saveCount + -- if SaveRepeatConsumCount ~= 0 then + -- saveCount = SaveRepeatConsumCount + -- else + -- saveCount = XSaveTool.GetData(string.format("%d%s", XPlayer.Id, "NieRRepeatRedCheckCount")) + -- end + -- if saveCount then + -- return tonumber(saveCount) + -- end + -- return 0 + local saveTime = XSaveTool.GetData(string.format("%d%s", XPlayer.Id, "NieRRepeatRedCheckCount")) or 0 + local nowTime = XTime.GetServerNowTimestamp() + local refreshTime = XTime.GetSeverTodayFreshTime() + local lastRefreshTime = XTime.GetSeverYesterdayFreshTime() + if saveTime <= refreshTime then + if saveTime > lastRefreshTime then + return false + else + return true + end + else + return false + end + end + + --检查尼尔玩法复刷关红点 + function XNieRManager.CheckRepeatRed() + if XNieRManager.GetIsActivityEnd() then return false end + + local nierRepeatList = XNieRManager.GetRepeatDataList() + local consumeId, consumCount = XNieRManager.GetRepeatStageConsumeId(), 0 + local haveCount = XDataCenter.ItemManager.GetCount(consumeId) + local haveCountEx = 0 + + -- local saveCount + -- if SaveRepeatConsumCount ~= 0 then + -- saveCount = SaveRepeatConsumCount + -- else + -- saveCount = XSaveTool.GetData(string.format("%d%s", XPlayer.Id, "NieRRepeatRedCheckCount")) + -- end + -- if saveCount then + -- local numCount = tonumber(saveCount) + -- if numCount == haveCount then + -- return false + -- elseif numCount > haveCount then + -- SaveRepeatConsumCount = haveCount + -- XSaveTool.SaveData(string.format("%d%s", XPlayer.Id, "NieRRepeatRedCheckCount"), haveCount) + -- return false + -- end + -- end + if not XNieRManager.CheckNieRRepeatRedTime() then + return false + end + + for _, repeatData in ipairs(nierRepeatList) do + if repeatData:CheckNieRRepeatMainStageUnlock() then + consumCount = repeatData:GetNierRepeatStageConsumeCount() + local stageCfg = XDataCenter.FubenManager.GetStageCfg(repeatData:GetNieRRepeatStageId()) + local needActionPoint = stageCfg.RequireActionPoint + local haveActionPoint = XDataCenter.ItemManager.GetCount(XDataCenter.ItemManager.ItemId.ActionPoint) + if haveCount >= consumCount and haveActionPoint >= needActionPoint then + return true + end + -- for _, stageId in ipairs(repeatData:GetNieRExStageIds()) do + -- if repeatData:CheckNieRRepeatStageUnlock(stageId) then + -- consumeId, consumCount = repeatData:GetExConsumIdAndCount(stageId) + -- if consumeId ~= 0 then + -- haveCountEx = XDataCenter.ItemManager.GetCount(consumeId) + -- if haveCountEx >= consumCount then + -- return true + -- end + -- end + -- end + -- end + end + end + return false + end + + --检查尼尔玩家红点 + function XNieRManager.CheckNieRCharacterRed(characterId, isInfor, isTeach) + if XNieRManager.GetIsActivityEnd() then return false end + local nieRCharacterDic = XNieRManager.GetNieRCharacterDic() or {} + if characterId > 0 then + local nieRCharacter = nieRCharacterDic[characterId] + if nieRCharacter and nieRCharacter:CheckNieRCharacterCondition() then + if isInfor then + local inforList = XNieRConfigs.GetNieRCharacterInforListById(characterId) + for _, config in ipairs(inforList) do + local condit + if config.UnlockCondition ~= 0 then + condit = XConditionManager.CheckCondition(config.UnlockCondition) + else + condit = true + end + if condit then + if not XDataCenter.NieRManager.CheckCharacterInformationUnlock(config.Id, false) then + return true + end + + end + end + end + if isTeach then + local teachingStageIds = nieRCharacter:GetTeachingStageIds() + for _, stageId in pairs(teachingStageIds) do + if XDataCenter.FubenManager.CheckStageIsUnlock(stageId) and not XDataCenter.FubenManager.CheckStageIsPass(stageId) then + return true + end + end + end + + end + else + for tmpCharacterId, nieRCharacter in pairs(nieRCharacterDic) do + if nieRCharacter:CheckNieRCharacterCondition() then + if isInfor then + local inforList = XNieRConfigs.GetNieRCharacterInforListById(tmpCharacterId) + for _, config in ipairs(inforList) do + local condit + if config.UnlockCondition ~= 0 then + condit = XConditionManager.CheckCondition(config.UnlockCondition) + else + condit = true + end + if condit then + if not XDataCenter.NieRManager.CheckCharacterInformationUnlock(config.Id, false) then + return true + end + + end + end + end + if isTeach then + local teaChaningStageIds = nieRCharacter:GetTeachingStageIds() + for _, stageId in pairs(teaChaningStageIds) do + if XDataCenter.FubenManager.CheckStageIsUnlock(stageId) and not XDataCenter.FubenManager.CheckStageIsPass(stageId) then + return true + end + end + end + end + end + end + return false + end + + --检查尼尔POD红点 + function XNieRManager.CheckNieRPODRed() + if XNieRManager.GetIsActivityEnd() then return false end + local nieRPODData = XNieRManager.GetNieRPODData() + if not nieRPODData then return false end + for _, skill in pairs(nieRPODData:GetNieRPODSkillList()) do + if nieRPODData:CheckNieRPODSkillActive(skill.SkillId) and nieRPODData:CheckNieRPODSkillUpLevel(skill.SkillId) then + local cousumId, consumCount = nieRPODData:GetNieRPODSkillUpLevelItem(skill.SkillId) + if cousumId ~= 0 then + local haveCount = XDataCenter.ItemManager.GetCount(cousumId) + if haveCount >= consumCount then + return true + end + end + + end + end + return false + end + + --检查尼尔活动入口可挑战条件 + function XNieRManager.CheckNieRCanFightTag() + if not XNieRManager.CheckRepeatRed() then return false end + + --有角色未达到满级 + local nierCharacters = XNieRManager.GetCurDevelopCharacterIds() + for _, characterId in pairs(nierCharacters) do + local nieRCharacter = XNieRManager.GetNieRCharacterByCharacterId(characterId) + if nieRCharacter:CheckNieRCharacterCondition() and not nieRCharacter:CheckNieRCharacterMaxLevel() then + return true + end + end + + return false + end + + function XNieRManager.OnActivityEnd() + if CS.XFight.IsRunning or XLuaUiManager.IsUiLoad("UiLoading") then + return + end + XUiManager.TipText("NieREnd") + XLuaUiManager.RunMain() + end + + --服务端下推部分 + --处理尼尔数据 + function XNieRManager.AsyncNieRData(notifyData) + if notifyData.ActivityId ~= 0 then + ActivityId = notifyData.ActivityId + NieRRobotIdToCharacterIdDic = {} + NieRCharacterDic = {} + NieRBossDic = {} + NieREasterEggStageShow = false + IsNieREasterEggDataRealPass = false + XNieRManager.CurActivtityConfigChange() + local nierSaveActivityId = XSaveTool.GetData(string.format("%d%s", XPlayer.Id, "NieRActivityIdSave")) + if not nierSaveActivityId then + XSaveTool.SaveData(string.format("%d%s", XPlayer.Id, "NieRActivityIdSave"), ActivityId) + else + if nierSaveActivityId ~= ActivityId then + XSaveTool.SaveData(string.format("%d%s", XPlayer.Id, "NieRActivityIdSave"), ActivityId) + XNieRManager.RemoveAllPreData() + end + end + else + ActivityId = XNieRConfigs.GetDefaultActivityId() + IsNieREasterEggDataRealPass = false + IsActivityEnd = true + CurActivityConfig = false + XNieRManager.CurActivtityConfigChange() + XNieRManager.RemoveAllPreData() + XEventManager.DispatchEvent(XEventId.EVENT_NIER_ACTIVITY_END) + return + end + + for _, data in ipairs(notifyData.Characters) do + XNieRManager.UpdateNieRCharacterData(data) + end + if notifyData.Bosses then + for _, data in ipairs(notifyData.Bosses) do + XNieRManager.UpdateNieRBossData(data) + end + end + XNieRManager.UpdateNieRPODData(notifyData.Support) + XNieRManager.RegisterEditBattleProxy() + XNieRManager.CheckNieREasterEggStageShow() + IsNieREasterEggDataRealPass = notifyData.EasterEggFinish + XEventManager.DispatchEvent(XEventId.EVENT_NIER_ACTIVITY_REFRESH) + end + + --处理尼尔角色数据 + function XNieRManager.AsyncNieRCharacterData(notifyData) + XNieRManager.UpdateNieRCharacterData(notifyData.Character) + XEventManager.DispatchEvent(XEventId.EVENT_NIER_CHARACTER_UPDATE, notifyData.Character.CharacterId) + end + --服务端下推部分结束 + --服务器请求部分 + function XNieRManager.NieRCharacterChangeFashion(characterId, fashionId, func) + XNetwork.Call(NieRRpc.NieRCharacterChangeFashion, { + CharacterId = characterId, + FashionId = fashionId + }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XNieRManager.GetNieRCharacterByCharacterId(characterId):ChangeNieRFashionId(fashionId) + if func then + func() + end + end) + end + + function XNieRManager.NieRUpdateBossScore(func) + XNetwork.Call(NieRRpc.NieRUpdateBossScore, { + + }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + if func then + func() + end + end) + end + + function XNieRManager.NieRUpgradeSupportSkill(skillId, func) + XNetwork.Call(NieRRpc.NieRUpgradeSupportSkill, { + SkillId = skillId + }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + local nierPOD = XNieRManager.GetNieRPODData() + nierPOD:AddNieRPODSkillLevelById(skillId) + XEventManager.DispatchEvent(XEventId.EVENT_NIER_POD_UPDATE) + if func then + func() + end + end) + end + + function XNieRManager.NieRSelectSupportSkill(skillId, func) + XNetwork.Call(NieRRpc.NieRSelectSupportSkill, { + SkillId = skillId + }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + local nierPOD = XNieRManager.GetNieRPODData() + nierPOD:SetNieRPODSelectSkillId(skillId) + if func then + func() + end + end) + + end + + function XNieRManager.NieREasterEggLeaveMessage(messageId, age, labelId, func) + XNetwork.Call(NieRRpc.NieREasterEggLeaveMessage, { + MessageId = messageId, + Age = age, + LabelId = labelId + }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + if func then + func(res.RewardGoodsList) + end + end) + end + --服务器请求部分结束 + --[[ ================ + 本地初始化管理器 + ================ + ]] + function XNieRManager.Init() + XNieRManager.CurActivtityConfigChange() + XNieRManager.UpdateNieREasterEggData({}) + end + + XNieRManager.Init() + return XNieRManager +end + +-- 通知玩法数据 +XRpc.NotifyNieRData = function(notifyData) + XDataCenter.NieRManager.AsyncNieRData(notifyData) +end + +-- 通知玩法角色数据 +XRpc.NotifyNieRCharacterData = function(notifyData) + XDataCenter.NieRManager.AsyncNieRCharacterData(notifyData) +end + +--通知玩法BOSS数据 +XRpc.NotifyNieRBossData = function(notifyData) + local bossData = XDataCenter.NieRManager.UpdateNieRBossData(notifyData.Boss) + if bossData:IsBossDeath() then + XDataCenter.NieRManager.CheckNieREasterEggStageShow() + end +end + +--通知辅助机数据 +XRpc.NotifyNieRSupportData = function(notifyData) + XDataCenter.NieRManager.UpdateNieRPODData(notifyData.Support) + XEventManager.DispatchEvent(XEventId.EVENT_NIER_POD_UPDATE) +end + +--通知彩蛋关数据 +XRpc.NotifyNieREasterEggData = function(notifyData) + XDataCenter.NieRManager.UpdateNieREasterEggData(notifyData.Messages) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XNoticeManager.lua b/Resources/Scripts/XManager/XNoticeManager.lua new file mode 100644 index 00000000..d3b4ea1b --- /dev/null +++ b/Resources/Scripts/XManager/XNoticeManager.lua @@ -0,0 +1,1244 @@ +local tableInsert = table.insert + +XNoticeManagerCreator = function() + local Json = require("XCommon/Json") + local pcall = pcall + local XNoticeManager = {} + + local NoticePicList = {} + + local NowTextNotice = nil + local NowPicNotice = nil + + local InGameNoticeReadList = {} + local InGameNoticeMap = {} + local InGameNoticeReadKey = "_InGameNoticeReadKey" + + local SubMenuNoticeReadList = {} + local SubMenuNoticeMap = {} + local SubMenuNoticeReadKey = "_SubMenuNoticeReadKey" + + local ScrollCountList = {} + local ScrollCountSaveKey = "_NoticeScrollCountList" + + local LoginNotice = nil + local LoginNoticeTimeInfo = {} + local LoginNoticeCacheKey = "LoginNotice" + + local TextNoticeHideCache = {} + local TextNoticeHideCacheKey = "_TextNotice" + ------------------------------------------------------ + local NoticeRequestTimer = nil + -- 向服务端请求数据的最小间隔周期(秒) + local NoticeRequestTimerInterval = 10 + local NoticeRequestTimeOut = 30 + + local DefaultTextScrollInterval = 10 + + local ScreenShotFlag = false + + -- local XNoticeStatus = { + -- -- 未发布 + -- Unpublished = 0, + -- -- 等待发布 + -- PublishWait = 1, + -- -- 发布成功 + -- Published = 2, + -- -- 发布失败 + -- PublishFail = 3, + -- -- 过期 + -- OverTime = 4, + -- } + + local XNoticeType = { + -- 顶部文字滚动公告 + ScrollText = 0, + -- 主界面广告图 + ScrollPic = 1, + -- 游戏内公告 + InGame = 2, + -- 登陆公告 + Login = 3, + -- 主界面二级菜单 + SubMenu = 4, + } + + -- 自动向服务端请求数据的间隔周期(秒) + local RequestInterval = { + [XNoticeType.ScrollText] = 30, + [XNoticeType.ScrollPic] = 60, + [XNoticeType.InGame] = 120, + [XNoticeType.Login] = 0, + [XNoticeType.SubMenu] = 120, + } + + local LastRequestTime = { + [XNoticeType.ScrollText] = 0, + [XNoticeType.ScrollPic] = 0, + [XNoticeType.InGame] = 0, + [XNoticeType.SubMenu] = 0, + } + + local NoticeRequestHandler = { + [XNoticeType.ScrollText] = function(notice) XNoticeManager.HandleRequestScrollTextNotice(notice) end, + [XNoticeType.ScrollPic] = function(notice) XNoticeManager.HandleRequestScrollPicNotice(notice) end, + [XNoticeType.InGame] = function(notice) XNoticeManager.HandleRequestInGameNotice(notice) end, + [XNoticeType.SubMenu] = function(notice) XNoticeManager.HandleRequestSubMenuNotice(notice) end, + } + + local NoticeRequestFailHandler = { + [XNoticeType.ScrollText] = function() XNoticeManager.HandleRequestScrollTextNotice() end, + [XNoticeType.ScrollPic] = function() XNoticeManager.HandleRequestScrollPicNoticeFail() end, + [XNoticeType.InGame] = function() XNoticeManager.HandleRequestInGameNotice() end, + [XNoticeType.SubMenu] = function() XNoticeManager.HandleRequestSubMenuNotice() end, + } + + -- local NoticeData = { + -- [XNoticeType.ScrollText] = nil, + -- [XNoticeType.ScrollPic] = nil, + -- [XNoticeType.InGame] = nil, + -- } + + ----------------------------------初始化公告cdn路径 beg---------------------------------- + local NoticeCdnUrl = {} + local NoticeFileName = { + [XNoticeType.ScrollText] = "ScrollTextNotice.json", + [XNoticeType.ScrollPic] = "ScrollPicNotice.json", + [XNoticeType.InGame] = "GameNotice.json", + [XNoticeType.Login] = "LoginNotice.json", + [XNoticeType.SubMenu] = "SecondMenuNotice.json", + } + + function XNoticeManager.GetNoticeUrl(noticeType) + return NoticeCdnUrl[noticeType] + end + + function XNoticeManager.InitNoticeCdnUrl() + local noticePathPrefix = CS.XGame.ClientConfig:GetString("NoticePathPrefix") + for k, v in pairs(NoticeFileName) do + NoticeCdnUrl[k] = noticePathPrefix .. CS.XInfo.Identifier .. "/" .. CS.XRemoteConfig.ApplicationVersion .. "/" .. v + end + end + ----------------------------------初始化公告cdn路径 end---------------------------------- + ----------------------------------获取公网ip地址 beg---------------------------------- + local Ip = "" + local IpUrlIndex = 0 + local IpUrls = { + "https://ipv4.icanhazip.com/", + "https://api.ipify.org/" + } + + function XNoticeManager.RequestIp() + IpUrlIndex = IpUrlIndex + 1 + if IpUrlIndex > #IpUrls then + return + end + + local request = CS.UnityEngine.Networking.UnityWebRequest.Get(IpUrls[IpUrlIndex]) + local requestEnd = function() + if request.isNetworkError or request.isHttpError then + XNoticeManager.RequestIp() + end + + Ip = request.downloadHandler.text + + request:Dispose() + end + + CS.XTool.WaitNativeCoroutine(request:SendWebRequest(), requestEnd) + end + + function XNoticeManager.GetIp() + return Ip + end + ----------------------------------获取公网ip地址 end---------------------------------- + --------------------------cache beg-------------------------- + function XNoticeManager.ReadTextNoticeHideCache() + local cache = CS.UnityEngine.PlayerPrefs.GetString(tostring(XPlayer.Id) .. TextNoticeHideCacheKey) + if string.IsNilOrEmpty(cache) then + return + end + + TextNoticeHideCache = Json.decode(cache) + + for k, v in pairs(TextNoticeHideCache) do + if XTime.GetServerNowTimestamp() > v.EndTime then + TextNoticeHideCache[k] = nil + end + end + + end + + function XNoticeManager.SaveTextNoticeHideCache() + if not TextNoticeHideCache then + return + end + + CS.UnityEngine.PlayerPrefs.SetString(tostring(XPlayer.Id) .. TextNoticeHideCacheKey, Json.encode(TextNoticeHideCache)) + CS.UnityEngine.PlayerPrefs.Save() + end + + function XNoticeManager.GetInGameNoticeReadKey() + return tostring(XPlayer.Id) .. InGameNoticeReadKey + end + + function XNoticeManager.SaveInGameNoticeReadList() + if not InGameNoticeReadList then return end + + local saveContent = "" + local splitMark = "\n" + for _, v in pairs(InGameNoticeReadList) do + local list = {} + tableInsert(list, v.Id) + tableInsert(list, v.Index) + tableInsert(list, (v.IsRead and 1 or 0)) + tableInsert(list, v.EndTime) + tableInsert(list, v.ModifyTime) + + local tempStr = table.concat(list, "\t") + saveContent = string.format("%s%s%s", tempStr, splitMark, saveContent) + end + + CS.UnityEngine.PlayerPrefs.SetString(XNoticeManager.GetInGameNoticeReadKey(), saveContent) + CS.UnityEngine.PlayerPrefs.Save() + + XEventManager.DispatchEvent(XEventId.EVENT_ACTIVITY_NOTICE_READ_CHANGE) + end + + function XNoticeManager.ReadInGameNoticeReadList() + InGameNoticeReadList = {} + if not CS.UnityEngine.PlayerPrefs.HasKey(XNoticeManager.GetInGameNoticeReadKey()) then + return + end + + local dataStr = CS.UnityEngine.PlayerPrefs.GetString(XNoticeManager.GetInGameNoticeReadKey()) + + local msgTab = string.Split(dataStr, '\n') + if not msgTab or #msgTab <= 0 then + return + end + + for _, content in ipairs(msgTab) do + if (not string.IsNilOrEmpty(content)) then + local tab = string.Split(content, '\t') + if tab then + local readInfo = { + Id = tostring(tab[1]), + Index = tonumber(tab[2]), + IsRead = tonumber(tab[3]) > 0, + EndTime = tonumber(tab[4]), + ModifyTime = tonumber(tab[5]), + } + if readInfo.ModifyTime and readInfo.EndTime and readInfo.EndTime > XTime.GetServerNowTimestamp() then + local dataKey = XNoticeManager.GetGameNoticeReadDataKey(readInfo, readInfo.Index) + InGameNoticeReadList[dataKey] = readInfo + end + end + end + end + end + + function XNoticeManager.GetSubMenuNoticeReadKey() + return tostring(XPlayer.Id) .. SubMenuNoticeReadKey + end + + function XNoticeManager.SaveSubMenuNoticeReadList() + if not SubMenuNoticeReadList then return end + + local saveContent = "" + local splitMark = "\n" + for _, v in pairs(SubMenuNoticeReadList) do + local list = {} + tableInsert(list, v.Id) + tableInsert(list, v.EndTime) + tableInsert(list, v.TipResetTime) + tableInsert(list, v.LastReadTime) + + local tempStr = table.concat(list, "\t") + saveContent = string.format("%s%s%s", tempStr, splitMark, saveContent) + end + -- XLog.Warning("save",saveContent) + CS.UnityEngine.PlayerPrefs.SetString(XNoticeManager.GetSubMenuNoticeReadKey(), saveContent) + CS.UnityEngine.PlayerPrefs.Save() + + XEventManager.DispatchEvent(XEventId.EVENT_ACTIVITY_SUBMENU_READ_CHANGE) + end + + function XNoticeManager.ReadSubMenuNoticeReadList() + SubMenuNoticeReadList = {} + if not CS.UnityEngine.PlayerPrefs.HasKey(XNoticeManager.GetSubMenuNoticeReadKey()) then + return + end + + local dataStr = CS.UnityEngine.PlayerPrefs.GetString(XNoticeManager.GetSubMenuNoticeReadKey()) + + local msgTab = string.Split(dataStr, '\n') + if not msgTab or #msgTab <= 0 then + return + end + + for _, content in ipairs(msgTab) do + if (not string.IsNilOrEmpty(content)) then + local tab = string.Split(content, '\t') + if tab then + local readInfo = { + Id = tostring(tab[1]), + EndTime = tonumber(tab[2]), + TipResetTime = tonumber(tab[3]), + LastReadTime = tonumber(tab[4]), + } + if readInfo.EndTime and readInfo.EndTime > XTime.GetServerNowTimestamp() then + SubMenuNoticeReadList[readInfo.Id] = readInfo + end + end + end + end + --XLog.Warning("ReadSubMenuNoticeReadList",SubMenuNoticeReadList) + end + + function XNoticeManager.GetScrollCountSaveKey() + return tostring(XPlayer.Id) .. ScrollCountSaveKey + end + + function XNoticeManager.SaveScrollCountList() + if not ScrollCountList then + return + end + local saveContent = '' + for _, v in pairs(ScrollCountList) do + saveContent = saveContent .. v.id .. '\t' + saveContent = saveContent .. v.maxCount .. '\t' + saveContent = saveContent .. v.nowCount .. '\t' + saveContent = saveContent .. v.overTime .. '\n' + end + + CS.UnityEngine.PlayerPrefs.SetString(XNoticeManager.GetScrollCountSaveKey(), saveContent) + CS.UnityEngine.PlayerPrefs.Save() + end + + function XNoticeManager.ReadScrollCountList() + ScrollCountList = {} + if not CS.UnityEngine.PlayerPrefs.HasKey(XNoticeManager.GetScrollCountSaveKey()) then + return + end + local dataStr = CS.UnityEngine.PlayerPrefs.GetString(XNoticeManager.GetScrollCountSaveKey()) + local msgTab = string.Split(dataStr, '\n') + if not msgTab or #msgTab <= 0 then + return + end + + for _, content in ipairs(msgTab) do + if (not string.IsNilOrEmpty(content)) then + local tab = string.Split(content, '\t') + if tab then + local countInfo = { + id = tostring(tab[1]), + maxCount = tonumber(tab[2]), + nowCount = tonumber(tab[3]), + overTime = tonumber(tab[4]), + } + if countInfo.overTime and countInfo.overTime > XTime.GetServerNowTimestamp() then + ScrollCountList[countInfo.id] = countInfo + end + end + end + end + end + --------------------------cache end-------------------------- + --------------------------text beg-------------------------- + function XNoticeManager.HandleRequestScrollTextNotice(notice) + -- XLog.Warning("new text notice",notice) + NowTextNotice = notice + + if not XNoticeManager.CheckTextNoticeValid(notice) then + CsXGameEventManager.Instance:Notify(XEventId.EVENT_NOTICE_CLOSE_TEXT_NOTICE) + else + XLuaUiManager.Open("UiNoticeTips") + end + + if NowTextNotice then + local key = XNoticeManager.GetTextNoticeKey(NowTextNotice) + if not ScrollCountList or not ScrollCountList[key] then + XNoticeManager.CreateDefaultScrollCountData(NowTextNotice) + end + end + end + + function XNoticeManager.GetTextNoticeKey(notice) + return notice.Id .. "_" .. notice.ModifyTime + end + + function XNoticeManager.CreateDefaultScrollCountData(notice) + local key = XNoticeManager.GetTextNoticeKey(notice) + local countInfo = { + id = key, + maxCount = notice.ScrollTimes, + nowCount = 0, + overTime = notice.EndTime, + } + ScrollCountList[key] = countInfo + end + + function XNoticeManager.CheckTextNoticeValid(notice) + notice = notice or NowTextNotice + + if not XNoticeManager.CheckNoticeValid(notice) then + return false + end + + if not XNoticeManager.CheckTextNoticeHideCache(notice) then + return false + end + + if notice.ShowInFight < 1 and not CS.XFight.IsOutFight then + return false + end + + if notice.ShowInPhotograph < 1 and ScreenShotFlag then + return false + end + + local key = XNoticeManager.GetTextNoticeKey(notice) + if ScrollCountList[key] + and ScrollCountList[key].nowCount > ScrollCountList[key].maxCount then + + return false + end + + return true + end + + function XNoticeManager.GetTextNoticeContent() + if not NowTextNotice then + return + end + return NowTextNotice.Content + end + + function XNoticeManager.AddTextNoticeCount() + if not NowTextNotice then + return + end + + local key = XNoticeManager.GetTextNoticeKey(NowTextNotice) + + if not ScrollCountList[key] then + XNoticeManager.CreateDefaultScrollCountData(NowTextNotice) + end + + ScrollCountList[key].nowCount = ScrollCountList[key].nowCount + 1 + + XNoticeManager.SaveScrollCountList() + end + + function XNoticeManager.GetTextNoticeScrollInterval() + if not NowTextNotice then + return DefaultTextScrollInterval + end + return tonumber(NowTextNotice.ScrollInterval) or DefaultTextScrollInterval + end + + + function XNoticeManager.ChangeTextNoticeHideCache(notice) + notice = notice or NowTextNotice + if not notice then + return + end + + local key = XNoticeManager.GetTextNoticeKey(notice) + if not TextNoticeHideCache[key] then + TextNoticeHideCache[key] = { + Id = key, + IsHide = 1, + EndTime = notice.EndTime + } + else + TextNoticeHideCache[key].IsHide = not TextNoticeHideCache[key].IsHide + end + + XNoticeManager.SaveTextNoticeHideCache() + end + + + function XNoticeManager.CheckTextNoticeHideCache(notice) + notice = notice or NowTextNotice + if not notice then + return false + end + + local key = XNoticeManager.GetTextNoticeKey(notice) + if not TextNoticeHideCache[key] then + return true + end + + return TextNoticeHideCache[key].IsHide < 0 + end + --------------------------text end-------------------------- + ----------------------Scroll Pic beg---------------------- + + function XNoticeManager.HandleRequestScrollPicNoticeFail() + if not NowPicNotice then + return + end + + NowPicNotice = nil + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_NOTICE_PIC_CHANGE) + end + + function XNoticeManager.HandleRequestScrollPicNotice(notice) + if not notice then + return + end + + if NowPicNotice and NowPicNotice.Id == notice.Id and NowPicNotice.ModifyTime == notice.ModifyTime then + return + end + + NowPicNotice = notice + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_NOTICE_PIC_CHANGE) + end + + function XNoticeManager.GetScrollPicList() + XNoticeManager.RequestNoticeByType(XNoticeType.ScrollPic, true) + if not NowPicNotice then + return + end + + local scrollPicList = {} + for _, v in ipairs(NowPicNotice.Content) do + local isOpen = true + + if not v.BeginTime or not v.EndTime or not v.AppearanceDay or not v.AppearanceTime + or not v.DisappearanceCondition or not v.AppearanceCondition then + isOpen = false + end + + if isOpen then + isOpen = false + if XTime.GetServerNowTimestamp() >= tonumber(v.BeginTime) and XTime.GetServerNowTimestamp() < tonumber(v.EndTime) then--是否在开放区间内(日期) + isOpen = true + end + end + + if isOpen then + isOpen = false + if #v.AppearanceDay > 0 then + for _, day in ipairs(v.AppearanceDay) do + if day == XDataCenter.FubenDailyManager.GetNowDayOfWeekByRefreshTime() then--是否位于可以显示的周目 + isOpen = true + end + end + else + isOpen = true + end + end + + if isOpen then + isOpen = false + if #v.AppearanceTime > 0 then + for _, time in ipairs(v.AppearanceTime) do + if XTime.GetServerNowTimestamp() - XTime.GetTodayTime(0, 0, 0) >= time[1] and XTime.GetServerNowTimestamp() - XTime.GetTodayTime(0, 0, 0) < time[2] then--是否位于可以显示的时间段 + isOpen = true + end + end + else + isOpen = true + end + end + + if isOpen then + if #v.DisappearanceCondition > 0 then + for _, condition in ipairs(v.DisappearanceCondition) do--是否符合不显示的条件 + if XConditionManager.CheckCondition(condition) then + isOpen = false + end + end + end + end + + if isOpen then + if #v.AppearanceCondition > 0 then + for _, condition in ipairs(v.AppearanceCondition) do + if not XConditionManager.CheckCondition(condition) then--是否不符合显示条件 + isOpen = false + end + end + end + end + + if isOpen then + if not XNoticeManager.IsWhiteIp(v.WhiteLists) then + isOpen = false + end + end + + if isOpen then + v.Interval = tonumber(v.Interval) + table.insert(scrollPicList, v) + end + end + + return scrollPicList + end + ----------------------Scroll Pic end---------------------- + ----------------------InGame Notice beg---------------------- + function XNoticeManager.HandleRequestInGameNotice(notice) + InGameNoticeMap = {} + if not notice then + return + end + + if type(notice) ~= "table" then + XLog.Error("InGame notice invalid format: " .. tostring(notice)) + return + end + + for _, v in ipairs(notice) do + if XNoticeManager.CheckNoticeValid(v) then + if not InGameNoticeMap[v.Type] then + InGameNoticeMap[v.Type] = {} + end + + local content = {} + for _, item in ipairs(v.Content) do + if XNoticeManager.IsWhiteIp(item.WhiteLists) then + table.insert(content, item) + end + end + + if #content > 0 then + v.Content = content + table.insert(InGameNoticeMap[v.Type], v) + end + end + end + + for _, v in pairs(InGameNoticeMap) do + XNoticeManager.InitInGameReadList(v) + + local sortFunc = function(l, r) + return l.Order > r.Order + end + table.sort(v, sortFunc) + end + end + + function XNoticeManager.GetInGameNoticeMap(type) + return InGameNoticeMap[type] + end + + function XNoticeManager.CheckHaveNotice(type) + XNoticeManager.RequestNoticeByType(XNoticeType.InGame, true) + if not InGameNoticeMap then + return false + end + + if not InGameNoticeMap[type] or not next(InGameNoticeMap[type]) then + return false + end + + return true + end + + function XNoticeManager.CheckInGameNoticeRedPoint(type) + if not InGameNoticeMap or not InGameNoticeMap[type] then + return false + end + + for _, notice in pairs(InGameNoticeMap[type]) do + for i, _ in ipairs(notice.Content) do + if XNoticeManager.CheckInGameNoticeRedPointIndividual(notice, i) then + return true + end + end + end + return false + end + + function XNoticeManager.InitInGameReadList(noticeList) + if not noticeList then + return + end + + if not InGameNoticeReadList then + InGameNoticeReadList = {} + end + + for _, noticeData in pairs(noticeList) do + for i, _ in pairs(noticeData.Content) do + local dataKey = XNoticeManager.GetGameNoticeReadDataKey(noticeData, i) + if not InGameNoticeReadList[dataKey] then + InGameNoticeReadList[dataKey] = {} + InGameNoticeReadList[dataKey].Id = noticeData.Id + InGameNoticeReadList[dataKey].EndTime = noticeData.EndTime + InGameNoticeReadList[dataKey].Index = i + InGameNoticeReadList[dataKey].IsRead = false + InGameNoticeReadList[dataKey].ModifyTime = noticeData.ModifyTime + end + end + end + + XEventManager.DispatchEvent(XEventId.EVENT_ACTIVITY_NOTICE_READ_CHANGE) + end + + function XNoticeManager.GetGameNoticeReadDataKey(noticeData, index) + return noticeData.Id .. "_" .. noticeData.ModifyTime .. "_" .. index + end + + function XNoticeManager.CheckInGameNoticeRedPointIndividual(notice, index) + if not InGameNoticeReadList then + return false + end + + local redPointKey = XNoticeManager.GetGameNoticeReadDataKey(notice, index) + if not InGameNoticeReadList[redPointKey] then + return false + end + + return not InGameNoticeReadList[redPointKey].IsRead + end + + function XNoticeManager.ChangeInGameNoticeReadStatus(dataKey, isRead) + if not InGameNoticeReadList then + return + end + + InGameNoticeReadList[dataKey].IsRead = isRead + XNoticeManager.SaveInGameNoticeReadList() + end + ----------------------InGame Notice end---------------------- + -------------------------Sub Menu beg------------------------ + --[[ 二级菜单配置 json数据格式 + {"Id":每次生成配置时的唯一标识, + "ModifyTime":配置最后修改时间, + "Content":配置具体内容,可以包含多个按钮 [ + "Id":唯一按钮Id, + "Title":按钮名称, + "SubTitle":按钮描述(显示在第二行), + "JumpType":1表示网址,2表示游戏内跳转, + "JumpAddr":跳转地址, + "BeginTime":开始显示时间, + "EndTime":结束显示时间, + "AppearanceDay":一周内出现的日子,不填则为全部出现, + "AppearanceTime":每天出现的时间段,不填则为全天出现, + "TipResetTime":红点重置时间, + "ModifyTime":最后修改时间 ] * N } + --]] + function XNoticeManager.HandleRequestSubMenuNotice(notice) + SubMenuNoticeMap = {} + if not notice then + return + end + + if type(notice) ~= "table" then + XLog.Error("SubMenu notice invalid format: " .. tostring(notice)) + return + end + + for _, v in ipairs(notice.Content) do + if XNoticeManager.CheckNoticeValid(v) then + table.insert(SubMenuNoticeMap, v) + end + end + + XNoticeManager.InitSubMenuReadList(notice) + end + + function XNoticeManager.GetMainUiSubMenu() + XNoticeManager.RequestNoticeByType(XNoticeType.SubMenu, true) + if not SubMenuNoticeMap then + return + end + + --XLog.Warning("start",SubMenuNoticeMap) + + local subMenuList = {} + for _, v in ipairs(SubMenuNoticeMap) do + local isOpen = true + + if not v.BeginTime or not v.EndTime or not v.AppearanceDay or not v.AppearanceTime then + isOpen = false + end + + if isOpen then + isOpen = false + if XTime.GetServerNowTimestamp() >= tonumber(v.BeginTime) and XTime.GetServerNowTimestamp() < tonumber(v.EndTime) then--是否在开放区间内(日期) + isOpen = true + end + end + + if isOpen then + isOpen = false + if #v.AppearanceDay > 0 then + for _, day in ipairs(v.AppearanceDay) do + if day == XDataCenter.FubenDailyManager.GetNowDayOfWeekByRefreshTime() then--是否位于可以显示的周目 + isOpen = true + end + end + else + isOpen = true + end + end + + if isOpen then + isOpen = false + if #v.AppearanceTime > 0 then + for _, time in ipairs(v.AppearanceTime) do + if XTime.GetServerNowTimestamp() - XTime.GetTodayTime(0, 0, 0) >= time[1] and XTime.GetServerNowTimestamp() - XTime.GetTodayTime(0, 0, 0) < time[2] then--是否位于可以显示的时间段 + isOpen = true + end + end + else + isOpen = true + end + end + + if isOpen then + if v.DisappearanceCondition and #v.DisappearanceCondition > 0 then + for _, condition in ipairs(v.DisappearanceCondition) do--是否符合不显示的条件 + if XConditionManager.CheckCondition(condition) then + isOpen = false + end + end + end + end + + if isOpen then + if v.AppearanceCondition and #v.AppearanceCondition > 0 then + for _, condition in ipairs(v.AppearanceCondition) do + if not XConditionManager.CheckCondition(condition) then--是否不符合显示条件 + isOpen = false + end + end + end + end + + if isOpen then + if not XNoticeManager.IsWhiteIp(v.WhiteLists) then + isOpen = false + end + end + + if isOpen then + table.insert(subMenuList, v) + end + end + + return subMenuList + end + + function XNoticeManager.CheckSubMenuRedPoint() + if not SubMenuNoticeMap then return false end + + for _, data in pairs(SubMenuNoticeMap) do + if XNoticeManager.CheckSubMenuRedPointIndividual(data.Id) then + return true + end + end + return false + end + + function XNoticeManager.InitSubMenuReadList(notice) + if not notice then + return + end + + if not SubMenuNoticeReadList then + SubMenuNoticeReadList = {} + end + + for _, noticeData in pairs(notice.Content) do + local dataKey = noticeData.Id + if not SubMenuNoticeReadList[dataKey] then + SubMenuNoticeReadList[dataKey] = {} + SubMenuNoticeReadList[dataKey].Id = noticeData.Id + SubMenuNoticeReadList[dataKey].LastReadTime = 0 + end + SubMenuNoticeReadList[dataKey].EndTime = noticeData.EndTime + SubMenuNoticeReadList[dataKey].TipResetTime = noticeData.TipResetTime or 0 + end + + XEventManager.DispatchEvent(XEventId.EVENT_ACTIVITY_SUBMENU_READ_CHANGE) + -- CsXGameEventManager.Instance:Notify(XEventId.EVENT_ACTIVITY_SUBMENU_READ_CHANGE) + end + + function XNoticeManager.CheckSubMenuRedPointIndividual(id) + if not SubMenuNoticeReadList then + return false + end + + local data = SubMenuNoticeReadList[id] + if not data then + return false + end + + if data.TipResetTime > XTime.GetServerNowTimestamp() then return false end + return data.LastReadTime < data.TipResetTime + end + + function XNoticeManager.ChangeSubMenuReadStatus(dataKey, time) + if not SubMenuNoticeReadList then + return + end + + SubMenuNoticeReadList[dataKey].LastReadTime = time or XTime.GetServerNowTimestamp() + --XLog.Warning("ChangeSubMenuReadStatus",SubMenuNoticeReadList) + XNoticeManager.SaveSubMenuNoticeReadList() + end + -------------------------Sub Menu end------------------------ + + ----------------------------------------login beg---------------------------------------- + + function XNoticeManager.RequestLoginNotice(cb) + local requestCb = function(notice) + local valid = XNoticeManager.CheckNoticeValid(notice, os.time()) + if not valid then + if cb then + cb(valid) + end + + local msgtab = {} + msgtab.error = valid + CS.XRecord.Record(msgtab, "24000", "RequestLoginNoticeError") + return + end + + if LoginNotice and LoginNotice.Id == notice.Id and LoginNotice.ModifyTime == notice.ModifyTime then + if cb then + cb(valid) + end + + local msgtab = {} + msgtab.error = valid + CS.XRecord.Record(msgtab, "24006", "RequestLoginNoticeError") + return + end + + LoginNotice = notice + local openNotice = false + if XNoticeManager.CheckLoginNoticeDailyAutoShow(LoginNotice) then + openNotice = true + end + CS.XRecord.Record("24005", "RequestLoginNoticeEnd") + if cb then + cb(valid, openNotice) + end + end + CS.XRecord.Record("24004", "RequestLoginNoticeStart") + XNoticeManager.RequestNotice(XNoticeType.Login, requestCb, requestCb, RequestInterval[XNoticeType.Login]) + end + + function XNoticeManager.AutoOpenLoginNotice() + if XNoticeManager.CheckLoginNoticeDailyAutoShow(LoginNotice) then + if not XNoticeManager.CheckNoticeValid(LoginNotice, os.time()) then + return + end + + XLuaUiManager.Open("UiLoginNotice", LoginNotice) + XNoticeManager.RefreshLoginNoticeTime() + end + end + + function XNoticeManager.OpenLoginNotice() + if not LoginNotice then + XNoticeManager.RequestLoginNotice(function(isValid) + if isValid then + XLuaUiManager.Open("UiLoginNotice", LoginNotice) + XNoticeManager.RefreshLoginNoticeTime() + return true + end + end) + else + if not XNoticeManager.CheckNoticeValid(LoginNotice, os.time()) then + return false + end + + XLuaUiManager.Open("UiLoginNotice", LoginNotice) + XNoticeManager.RefreshLoginNoticeTime() + return true + end + return false + end + + function XNoticeManager.ReadLoginNoticeTime() + local cache = CS.UnityEngine.PlayerPrefs.GetString(LoginNoticeCacheKey) + if string.IsNilOrEmpty(cache) then + return + end + + LoginNoticeTimeInfo = Json.decode(cache) + end + + function XNoticeManager.CheckLoginNoticeDailyAutoShow(notice) + if not notice then + return + end + + local id = notice.Id .. notice.ModifyTime + local resetTime = CS.XReset.GetNextDailyResetTime() - CS.XDateUtil.ONE_DAY_SECOND + if LoginNoticeTimeInfo[id] and LoginNoticeTimeInfo[id].Time > resetTime then + return false + end + + return true + end + + function XNoticeManager.RefreshLoginNoticeTime() + if not LoginNotice then + return + end + + local id = LoginNotice.Id .. LoginNotice.ModifyTime + LoginNoticeTimeInfo[id] = { + Id = id, + -- 此处有可能无法获取到真实时间(尚未与服务端同步时间) + Time = XTime.GetServerNowTimestamp() + } + + CS.UnityEngine.PlayerPrefs.SetString(LoginNoticeCacheKey, Json.encode(LoginNoticeTimeInfo)) + CS.UnityEngine.PlayerPrefs.Save() + end + + ----------------------------------------login end---------------------------------------- + ----------------------------image process beg---------------------------- + function XNoticeManager.LoadPicFromLocal(url, successCb) + if NoticePicList and NoticePicList[url] then + if successCb then + successCb(NoticePicList[url]) + end + return NoticePicList[url] + end + + local fileName = XNoticeManager.GetImgNameByUrl(url) + CS.XTool.LoadLocalNoticeImg(fileName, function(texture) + if not texture then + XNoticeManager.LoadPic(url, successCb) + else + NoticePicList[url] = texture + if successCb then + successCb(texture) + end + end + end) + end + + function XNoticeManager.LoadPic(url, successCb) + local request = CS.XUriPrefixRequest.Get(url, function() + return CS.UnityEngine.Networking.DownloadHandlerTexture(true) + end, NoticeRequestTimeOut, false) + + CS.XTool.WaitCoroutine(request:SendWebRequest(), function() + if request.isNetworkError or request.isHttpError then + return + end + + local texture = request.downloadHandler.texture; + if not texture then + return + end + + local fileName = XNoticeManager.GetImgNameByUrl(url) + CS.XTool.SaveNoticeImg(fileName, texture) + + NoticePicList[url] = texture + if successCb then + successCb(texture) + end + + request:Dispose() + end) + end + + function XNoticeManager.GetImgNameByUrl(url) + local _, _, _, fileName = url:find("(.+)/(.+)") + return fileName + end + ----------------------------image process end---------------------------- + + --function XNoticeManager.UrlDecode(s) + -- s = string.gsub(s, '%%(%x%x)', function(h) + -- return string.char(tonumber(h, 16)) + -- end) + -- return s + --end + + function XNoticeManager.CheckNoticeValid(notice, nowTime) + if not notice then + return false + end + + nowTime = nowTime or XTime.GetServerNowTimestamp() + if nowTime < notice.BeginTime then + return false + end + + if nowTime > notice.EndTime then + return false + end + + if not XNoticeManager.IsWhiteIp(notice.WhiteLists) then + return false + end + + return true + end + + function XNoticeManager.IsWhiteIp(whiteList) + if not whiteList then + return true + end + + if string.IsNilOrEmpty(Ip) then + return false + end + + for _, whiteIp in pairs(whiteList) do + if string.find(Ip, whiteIp) then + return true + end + end + + return false + end + + function XNoticeManager.RequestNoticeByType(noticeType, proactiveRequest) + local successCb = NoticeRequestHandler[noticeType] + local failCb = NoticeRequestFailHandler[noticeType] + local interval = proactiveRequest and NoticeRequestTimerInterval or RequestInterval[noticeType] + -- XLog.Warning("RequestNoticeByType", NoticeRequestTimerInterval, "type", RequestInterval[noticeType], "主动", proactiveRequest) + XNoticeManager.RequestNotice(noticeType, successCb, failCb, interval) + end + + function XNoticeManager.RequestNotice(noticeType, successCb, failCb, interval) + if not noticeType then + return + end + + local nowTime = XTime.GetServerNowTimestamp() + --if ((not nowTime) or (not noticeType) or (not interval)) then + -- XLog.Warning("XNoticeManager nowTime", nowTime,"noticeType", noticeType,"LastRequestTime", LastRequestTime[noticeType],"interval", interval) + --end + if LastRequestTime[noticeType] and LastRequestTime[noticeType] > 0 + and nowTime - LastRequestTime[noticeType] < interval then + return + end + LastRequestTime[noticeType] = nowTime + + local url = XNoticeManager.GetNoticeUrl(noticeType) + if string.IsNilOrEmpty(url) then + return + end + + local request = CS.XUriPrefixRequest.Get(url, nil, NoticeRequestTimeOut, false, true) + CS.XTool.WaitCoroutine(request:SendWebRequest(), function() + if not request then + if failCb then + failCb() + end + return + end + + if request.isNetworkError or request.isHttpError then + if failCb then + failCb() + end + return + end + + if not request.downloadHandler then + if failCb then + failCb() + end + return + end + + if string.IsNilOrEmpty(request.downloadHandler.text) then + if failCb then + failCb() + end + return + end + + local ok, notice = pcall(Json.decode, request.downloadHandler.text) + if not ok then + XLog.Error("XNoticeManager json 解码失败. 数据是:", request.downloadHandler.data) + if failCb then + failCb() + end + return + end + + if not notice then + if failCb then + failCb() + end + return + end + + if successCb then + successCb(notice) + end + + request:Dispose() + end) + end + + function XNoticeManager.InitTimer() + if NoticeRequestTimer then + return + end + + for noticeType, _ in pairs(RequestInterval) do + XNoticeManager.RequestNoticeByType(noticeType) + end + + NoticeRequestTimer = XScheduleManager.ScheduleForever(function() + for noticeType, _ in pairs(RequestInterval) do + XNoticeManager.RequestNoticeByType(noticeType) + end + end, NoticeRequestTimerInterval * 1000) + end + + function XNoticeManager.OnLogin() + XNoticeManager.ReadScrollCountList() + XNoticeManager.ReadInGameNoticeReadList() + XNoticeManager.ReadTextNoticeHideCache() + XNoticeManager.ReadSubMenuNoticeReadList() + + XNoticeManager.InitTimer() + end + + function XNoticeManager.OnLogout() + if NoticeRequestTimer then + XScheduleManager.UnSchedule(NoticeRequestTimer) + NoticeRequestTimer = nil + end + + for _, v in pairs(NoticePicList) do + if v and v:Exist() then + CS.UnityEngine.Object.Destroy(v) + end + end + NoticePicList = {} + end + + function XNoticeManager.Init() + XNoticeManager.InitNoticeCdnUrl() + XNoticeManager.RequestIp() + XNoticeManager.ReadLoginNoticeTime() + + XEventManager.AddEventListener(XEventId.EVENT_USER_LOGOUT, XNoticeManager.OnLogout) + XEventManager.AddEventListener(XEventId.EVENT_LOGIN_DATA_LOAD_COMPLETE, XNoticeManager.OnLogin) + XEventManager.AddEventListener(XEventId.EVENT_PHOTO_ENTER, function() + ScreenShotFlag = true + end) + XEventManager.AddEventListener(XEventId.EVENT_PHOTO_LEAVE, function() + ScreenShotFlag = false + end) + end + + XNoticeManager.Init() + return XNoticeManager +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XNotifyManager.lua b/Resources/Scripts/XManager/XNotifyManager.lua new file mode 100644 index 00000000..6a1e7d82 --- /dev/null +++ b/Resources/Scripts/XManager/XNotifyManager.lua @@ -0,0 +1,210 @@ +--红点通知 +local Notify = {} + +--单个红点类 +local NotifyPoint = XClass(nil, "NotifyPoint") + +function NotifyPoint:Ctor() + self.data = { cnt = 0 } --?cnt条件 +end + +function NotifyPoint:BindTo(node, customFunc) + return XBindTool.BindNode(node, self.data, "cnt", function(v, oldV) + if customFunc then + customFunc(v, oldV) + else + if node.SetActive then + node:SetActive(v > 0) + end + local gameObject = node.gameObject or node.GameObject + if gameObject and gameObject.SetActive then + gameObject:SetActive(v > 0) + end + end + end) +end + +function NotifyPoint:SetBindCnt(cnt) + self.data.cnt = cnt +end + +function NotifyPoint:InitWrap() + self:Init() +end + +function NotifyPoint:Init() + +end + +function NotifyPoint:Check() + +end + +Notify.NotifyPoint = NotifyPoint +----------------------------------------------------- +local NotifyGroup = XClass(NotifyPoint, "NotifyGroup") + +function NotifyGroup:Ctor() + self.handles = {} + self.pointMap = {} +end + +function NotifyGroup:GetPoint(key) + return self.pointMap[key] +end + +function NotifyGroup:AddPoint(item, key) + if key ~= nil then + self.pointMap[key] = item + end + local h = XBindTool.BindAttr(item.data, "cnt", function(v, o_v) + o_v = o_v or 0 + self.data.cnt = self.data.cnt + (v - o_v) + end) + self.handles[item] = h + if self.isInit then + item:InitWrap() + item:Check() + end +end + +function NotifyGroup:RemovePoint(item) + self.data.cnt = self.data.cnt - item.data.cnt + XBindTool.UnBind(self.handles[item]) + self.handles[item] = nil +end + +function NotifyGroup:InitWrap() + if self.isInit then return end + self.isInit = true + self:Init() + for item, _ in pairs(self.handles) do + item:InitWrap() + end +end + +function NotifyGroup:Check(...) + for item, _ in pairs(self.handles) do + item:Check(...) + end +end + +Notify.NotifyGroup = NotifyGroup +----------------------------------------------------- +local NotifyMgr = XClass(nil, "NotifyMgr") +local UpdateTime = 10 * XScheduleManager.SECOND + +function NotifyMgr:Ctor() + self.mapValue = {} + self.updateArr = {} +end + +function NotifyMgr:RegistPoint(pType, point) + self.mapValue[pType] = point + if self.isStart then + point:InitWrap() + point:Check() + end +end + +function NotifyMgr:RemovePoint(ptype) + local point = self.mapValue[ptype] + if point then + self.mapValue[ptype] = nil + for index, v in ipairs(self.updateArr) do + if v == point then + table.remove(self.updateArr, index) + return + end + end + end +end + +function NotifyMgr:RegistUpdatePoint(pType, point) + self.mapValue[pType] = point; + table.insert(self.updateArr, point) + if self.isStart then + point:InitWrap() + point:Check() + self:CheckRecycle() + end +end + +function NotifyMgr:GetPoint(pType) + return self.mapValue[pType] +end + +function NotifyMgr:Start() + if self.isStart then return end + self.isStart = true; + for _, point in pairs(self.mapValue) do + point:InitWrap(); + point:Check(); + end + self:CheckRecycle() +end + +function NotifyMgr:CheckRecycle() + if #self.updateArr > 0 and not self.updateHandler then + self.updateHandler = XScheduleManager.ScheduleForever(function(timer) + self:Update(timer) + end, UpdateTime, 0) + self:Update(0) + else + if #self.updateArr == 0 and self.updateHandler then + XScheduleManager.UnSchedule(self.updateHandler) + self.updateHandler = nil + end + end +end + +function NotifyMgr:Update() + for _, v in pairs(self.updateArr) do + v:Check() + end +end + +Notify.NotifyMgr = NotifyMgr.New() + +------------------------------------------------------------ +-------------------下面是对外的接口--------------------------- +XNotifyManager = XNotifyManager or {} + +function XNotifyManager.BindNode(node, types, customFunc) + local group = NotifyGroup.New() + for _, ptype in ipairs(types) do + local point = Notify.NotifyMgr:GetPoint(ptype) + if point then + group:AddPoint(point) + end + end + group:BindTo(node, customFunc) +end + +function XNotifyManager.BindNodeWithKey(node, ptype, keys, customFunc) + local point = Notify.NotifyMgr:GetPoint(ptype) + for _, v in ipairs(keys) do + if point and point.GetPoint then + point = point:GetPoint(v) + else + break + end + end + if point then + point:BindTo(node, customFunc) + end +end + +-- 考虑放在登录后再开启 +function XNotifyManager.Start() + Notify.NotifyMgr:Start() +end + +----------------------------------------------------- +--这里添加所有的红点系统的名字 +XNotifyManager.GNotifyName = { + UrgentEvent = "UrgentEvent", + CharacterStory = "CharacterStory", +} + +return Notify \ No newline at end of file diff --git a/Resources/Scripts/XManager/XPartnerManager.lua b/Resources/Scripts/XManager/XPartnerManager.lua new file mode 100644 index 00000000..f2f4f125 --- /dev/null +++ b/Resources/Scripts/XManager/XPartnerManager.lua @@ -0,0 +1,882 @@ +local XPartner = require("XEntity/XPartner/XPartner") + +XPartnerManagerCreator = function() + local XPartnerManager = {} + local PartnerEntityDic = {} + local CSTextManagerGetText = CS.XTextManager.GetText + local tableInsert = table.insert + local PartnerNameMaxLength = CS.XGame.Config:GetInt("PartnerNameMaxLength") + local PartnerLockCount = 0 + local PartnerLockCountMax = 2 + local SYNC_PARTNERLOCK_SECOND = 1 + local LastSyncPartnerLockTime = 0 + local PartnerCarrierIdDic = {} + local PartnerUnLockStoryList = {} + local PartnerMaxCount = CS.XGame.Config:GetInt("PartnerMaxCount") + local PartnerAbilityConvert = CS.XGame.Config:GetFloat("PartnerAbilityConvert") + local PartnerDecomposeExpItemRebate = CS.XGame.Config:GetString("PartnerDecomposeExpItemRebate") + local PartnerDecomposeLevelBreakRebate = CS.XGame.Config:GetFloat("PartnerDecomposeLevelBreakRebate") + local PartnerDecomposeEvolutionRebate = CS.XGame.Config:GetFloat("PartnerDecomposeEvolutionRebate") + local PartnerDecomposeSkillRebate = CS.XGame.Config:GetFloat("PartnerDecomposeSkillRebate") + + local METHOD_NAME = { + PartnerComposeRequest = "PartnerComposeRequest",--伙伴合成请求 + PartnerCarryRequest = "PartnerCarryRequest",--伙伴携带请求 + PartnerBreakAwayRequest = "PartnerBreakAwayRequest",--伙伴解除携带请求 + PartnerChangeNameRequest = "PartnerChangeNameRequest",--伙伴改名请求 + PartnerUpdateLockRequest = "PartnerUpdateLockRequest",--伙伴锁定请求 + PartnerLevelUpRequest = "PartnerLevelUpRequest",--伙伴升级请求 + PartnerBreakThroughRequest = "PartnerBreakThroughRequest",--伙伴突破请求 + PartnerStarActivateRequest = "PartnerStarActivateRequest",--伙伴升星(融合)请求 + PartnerEvolutionRequest = "PartnerEvolutionRequest",--伙伴进化请求 + PartnerSkillUpRequest = "PartnerSkillUpRequest",--伙伴技能升级请求 + PartnerSkillWearRequest = "PartnerSkillWearRequest",--伙伴技能穿戴请求 + PartnerDecomposeRequest = "PartnerDecomposeRequest",--伙伴分解请求 + } + + function XPartnerManager.Init() + + end + + function XPartnerManager.GetPartnerOverviewDataList(SelectId, partnerType, IsShowStack)--取得伙伴总览队列 + local overviewDataList = {} + local stackCount = {} + local overviewIndex = 1 + local indexMemo = {} + for _,entity in pairs(PartnerEntityDic or {}) do + local IsSameType = true + if partnerType then + IsSameType = entity:GetCarryCharacterType() == partnerType or entity:GetCarryCharacterType() == XPartnerConfigs.PartnerType.All + end + + if IsSameType then + if entity:GetIsByOneself() and IsShowStack then + + -- 将可以堆叠的伙伴全部放入一个虚拟的伙伴中,如果堆叠伙伴中有在列表中被选中的那么将此伙伴ID赋给虚拟的堆叠伙伴 + if not stackCount[entity:GetTemplateId()] then + stackCount[entity:GetTemplateId()] = 1 + overviewDataList[overviewIndex] = entity + indexMemo[entity:GetTemplateId()] = overviewIndex + overviewIndex = overviewIndex + 1 + end + + local tmpData = {} + tmpData.StackCount = stackCount[entity:GetTemplateId()] + stackCount[entity:GetTemplateId()] = stackCount[entity:GetTemplateId()] + 1 + + if SelectId and SelectId == entity:GetId() then + overviewDataList[indexMemo[entity:GetTemplateId()]] = entity + end + + overviewDataList[indexMemo[entity:GetTemplateId()]]:UpdateData(tmpData) + else + overviewDataList[overviewIndex] = entity + overviewIndex = overviewIndex + 1 + end + end + end + + return overviewDataList + end + + function XPartnerManager.GetPartnerComposeDataList()--取得伙伴合成队列 + local composeDataList = {} + local canComposeIdList = {} + local canComposeCount = 0 + local tmpId = 1 + local templateList = XPartnerConfigs.GetPartnerTemplateCfg() + for _,template in pairs(templateList or {}) do + local chipCurCount = XDataCenter.ItemManager.GetCount(template.ChipItemId) + local chipNeedCount = template.ChipNeedCount + local count = math.floor(chipCurCount / chipNeedCount) + + if count > 0 then + table.insert(canComposeIdList, template.Id) + canComposeCount = canComposeCount + count + end + + local entity = XPartner.New(tmpId, template.Id, false) + tmpId = tmpId + 1 + entity:UpdateData({ChipBaseCount = chipCurCount}) + table.insert(composeDataList,entity) + end + + return composeDataList, canComposeIdList, canComposeCount + end + + function XPartnerManager.GetPartnerQualityUpDataList(partnerId)--取得进化狗粮列表 + local qualityUpDataList = {} + local curPartnerEntity = PartnerEntityDic[partnerId] + for _,entity in pairs(PartnerEntityDic or {}) do + local IsCanEat = not entity:GetIsCarry() and + not entity:GetIsLock() and + partnerId ~= entity:GetId() and + curPartnerEntity:GetTemplateId() == entity:GetTemplateId() + + if IsCanEat then + table.insert(qualityUpDataList,entity) + end + end + + return qualityUpDataList + end + + function XPartnerManager.GetPartnerDecomposionList()--取得分解列表 + local decomposionDataList = {} + for _,entity in pairs(PartnerEntityDic or {}) do + local IsCanDecomposion = not entity:GetIsCarry() and not entity:GetIsLock() + if IsCanDecomposion then + table.insert(decomposionDataList,entity) + end + end + return decomposionDataList + end + + function XPartnerManager.GetCarryPartnerIdByCarrierId(carrierId)--根据装备者ID获取装备的宠物ID + return PartnerCarrierIdDic[carrierId] + end + + function XPartnerManager.GetCarryPartnerEntityByCarrierId(carrierId)--根据装备者ID获取装备的宠物 + local carryPartnerId = PartnerCarrierIdDic[carrierId] + return carryPartnerId and PartnerEntityDic[carryPartnerId] + end + + function XPartnerManager.GetCarryPartnerAbilityByCarrierId(carrierId)--根据装备者ID获取装备的宠物战力 + local carryPartner = XPartnerManager.GetCarryPartnerEntityByCarrierId(carrierId) + local partnerAbility = carryPartner and carryPartner:GetAbility() or 0 + return XMath.ToMinInt(partnerAbility * PartnerAbilityConvert) + end + + function XPartnerManager.GetCarryPartnerAbility(entity)--根据宠物的数据实体获取宠物战力 + local partnerAbility = entity and entity:GetAbility() or 0 + return XMath.ToMinInt(partnerAbility * PartnerAbilityConvert) + end + + function XPartnerManager.IsPartnerListEmpty() + return (not PartnerEntityDic or not next(PartnerEntityDic)) and true or false + end + + function XPartnerManager.GetPartnerEntityById(partnerId) + return PartnerEntityDic[partnerId] + end + + function XPartnerManager.CreatePartnerEntityByPartnerData(partnerData, IsPreview) + if partnerData and partnerData.Id and partnerData.TemplateId then + local entity = XPartner.New(partnerData.Id, partnerData.TemplateId, true, IsPreview) + entity:UpdateData(partnerData) + return entity + end + return nil + end + + function XPartnerManager.GoPartnerCarry(characterId, IsCanSkipProperty)--跳转至伙伴装备界面 + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.Partner) then + return + end + + if XPartnerManager.IsPartnerListEmpty() then + XUiManager.TipText("PartnerListIsEmpty") + if IsCanSkipProperty then + XLuaUiManager.Open("UiPartnerMain") + end + return + end + XLuaUiManager.Open("UiPartnerCarry", characterId, IsCanSkipProperty) + end + + function XPartnerManager.UpdatePartnerEntity(dataList) + for _,data in pairs(dataList or {}) do + if not PartnerEntityDic[data.Id] then + PartnerEntityDic[data.Id] = XPartner.New(data.Id, data.TemplateId, true) + end + PartnerEntityDic[data.Id]:UpdateData(data) + end + + XPartnerManager.UpdateCarrierIdDic() + end + + function XPartnerManager.UpdateCarrierIdDic() + PartnerCarrierIdDic = {} + for _,entity in pairs (PartnerEntityDic or {}) do + if entity:GetIsCarry() then + PartnerCarrierIdDic[entity:GetCharacterId()] = entity:GetId() + end + end + end + + function XPartnerManager.RemovePartnerEntity(ids) + for _,id in pairs(ids or {}) do + if PartnerEntityDic[id] then + PartnerEntityDic[id] = nil + end + end + end + + function XPartnerManager.ConstructPartnerAttrMap(attrs, isIncludeZero, remainDigitTwo) + local attrMap = {} + for _, attrIndex in pairs(XPartnerConfigs.AttrSortType or {}) do + local value = attrs and attrs[attrIndex] + --默认保留两位小数 + if not remainDigitTwo then + value = value and FixToInt(value) + else + value = value and tonumber(string.format("%0.2f", FixToDouble(value))) + end + + if isIncludeZero or value and value > 0 then + tableInsert(attrMap, { + AttrIndex = attrIndex, + Name = XAttribManager.GetAttribNameByIndex(attrIndex), + Value = value or 0, + }) + end + end + return attrMap + end + + function XPartnerManager.UpdateAllPartnerStory()--更新所有宠物的故事列表 + local PartnerUnLockStoryList = XDataCenter.ArchiveManager.GetPartnerSettingUnLockDic() + for _,entity in pairs(PartnerEntityDic or {}) do + entity:UpdateStoryEntity(PartnerUnLockStoryList) + end + end + + function XPartnerManager.UpdatePartnerStoryByEntity(entity)--更新某个宠物的故事列表 + local PartnerUnLockStoryList = XDataCenter.ArchiveManager.GetPartnerSettingUnLockDic() + entity:UpdateStoryEntity(PartnerUnLockStoryList) + end + + function XPartnerManager.UpdatePartnerNameById(partnerdId, name)--更新某个宠物的名字 + if not partnerdId then return end + local entity = XPartnerManager.GetPartnerEntityById(partnerdId) + if entity then + local tmpData = { + Name = name or "" + } + entity:UpdateData(tmpData) + end + end + + function XPartnerManager.GetCanEatItemIds() + local itemIds = {} + + local items = XDataCenter.ItemManager.GetPartnerExpItems() + for _, item in pairs(items or {}) do + tableInsert(itemIds, item.Id) + end + + return itemIds + end + + function XPartnerManager.GetEatItemsCostMoney(itemIdDic) + local costMoney = 0 + + for itemId, count in pairs(itemIdDic or {}) do + costMoney = costMoney + XDataCenter.ItemManager.GetItemsAddEquipCost(itemId, count) + end + + return costMoney + end + + function XPartnerManager.GetPartnerCountByTemplateId(id) + local count = 0 + for _,entity in pairs(PartnerEntityDic or {}) do + if entity:GetTemplateId() == id then + count = count + 1 + end + end + return count + end + + + function XPartnerManager.GetPartnerCount() + local count = 0 + for _,_ in pairs(PartnerEntityDic or {}) do + count = count + 1 + end + return count + end + + function XPartnerManager.GetMaxPartnerCount() + return PartnerMaxCount + end + + function XPartnerManager.GetExpItemList() + local expItemIdStrs = string.Split(PartnerDecomposeExpItemRebate,"|") + local expItemList = {} + for _,itemIdStr in pairs(expItemIdStrs) do + if itemIdStr and type(itemIdStr) == "string" and not string.IsNilOrEmpty(itemIdStr) then + table.insert(expItemList, XDataCenter.ItemManager.GetItemTemplate(tonumber(itemIdStr))) + end + end + + table.sort(expItemList, function (a, b) + return a.GetExp() > b.GetExp() + end) + + return expItemList + end + + local SetDecomposeBackItem = function(itemDic, partner) + local decomposeBackItems = partner:GetDecomposeBackItem() + for _,item in pairs(decomposeBackItems) do + itemDic[item.Id] = itemDic[item.Id] or {} + itemDic[item.Id].Count = itemDic[item.Id].Count or 0 + itemDic[item.Id].Count = itemDic[item.Id].Count + item.Count + end + end + + local SetBreakthroughBackItem = function(itemDic, partner) + local curBreakThrough = partner:GetBreakthrough() + local breakThroughExp = 0 + for breakThrough = 1, curBreakThrough do + local levelLimit = partner:GetBreakthroughLevelLimit(breakThrough - 1) + breakThroughExp = breakThroughExp + partner:GetLevelUpInfoAllExp(breakThrough - 1, levelLimit) + + local breakthroughItems = partner:GetBreakthroughCostItem(breakThrough - 1) + for _,item in pairs(breakthroughItems) do + itemDic[item.Id] = itemDic[item.Id] or {} + itemDic[item.Id].Count = itemDic[item.Id].Count or 0 + itemDic[item.Id].Count = itemDic[item.Id].Count + item.Count * PartnerDecomposeLevelBreakRebate + end + end + -----------------------经验值道具-------------------------- + local exp = (partner:GetExp() + partner:GetLevelUpInfoAllExp() + breakThroughExp) + local ratedExp = exp * PartnerDecomposeLevelBreakRebate + local expItemList = XPartnerManager.GetExpItemList() + local IsHasSurplus = true + while(IsHasSurplus)do + IsHasSurplus = false + for _,item in pairs(expItemList) do + if ratedExp - item.GetExp() >= 0 then + itemDic[item.Id] = itemDic[item.Id] or {} + itemDic[item.Id].Count = itemDic[item.Id].Count or 0 + itemDic[item.Id].Count = itemDic[item.Id].Count + 1 + local coin = XDataCenter.ItemManager.ItemId.Coin + itemDic[coin] = itemDic[coin] or {} + itemDic[coin].Count = itemDic[coin].Count or 0 + itemDic[coin].Count = itemDic[coin].Count + item.GetCost() + ratedExp = ratedExp - item.GetExp() + IsHasSurplus = true + break + end + end + end + end + + local SetQualityUpBackItem = function(itemDic, partner) + local initQuality = partner:GetInitQuality() + local curQuality = partner:GetQuality() + local partnerClipId = partner:GetChipItemId() + + for quality = initQuality + 1, curQuality do + local qualityUpItems = partner:GetQualityEvolutionCostItem(quality - 1) + for _,item in pairs(qualityUpItems) do + itemDic[item.Id] = itemDic[item.Id] or {} + itemDic[item.Id].Count = itemDic[item.Id].Count or 0 + itemDic[item.Id].Count = itemDic[item.Id].Count + item.Count * PartnerDecomposeEvolutionRebate + end + end + + if partner:GetStarSchedule() > 0 then + itemDic[partnerClipId] = itemDic[partnerClipId] or {} + itemDic[partnerClipId].Count = itemDic[partnerClipId].Count or 0 + itemDic[partnerClipId].Count = itemDic[partnerClipId].Count + partner:GetStarSchedule() * PartnerDecomposeEvolutionRebate + end + end + + local SetSkillLevelUpBackItem = function(itemDic, partner) + local miniSkillLevel = partner:GetMiniSkillLevelLimit() + local curSkillLevel = partner:GetTotalSkillLevel() + + for skillLevel = miniSkillLevel + 1, curSkillLevel do + local skillUpItems = partner:GetSkillUpgradeCostItem() + for _,item in pairs(skillUpItems) do + itemDic[item.Id] = itemDic[item.Id] or {} + itemDic[item.Id].Count = itemDic[item.Id].Count or 0 + itemDic[item.Id].Count = itemDic[item.Id].Count + item.Count * PartnerDecomposeSkillRebate + end + end + end + + function XPartnerManager.GetPartnerDecomposeRewards(partnerList) + local itemInfoList = {} + local itemDic = {} + XTool.LoopCollection(partnerList, function(partner) + ---------------------分解返还-------------------------- + SetDecomposeBackItem(itemDic, partner) + --------------------突破返还-------------------------- + SetBreakthroughBackItem(itemDic, partner) + -----------------------进化返还-------------------------- + SetQualityUpBackItem(itemDic, partner) + -------------------------技能升级返还-------------------------- + SetSkillLevelUpBackItem(itemDic, partner) + end) + + for id, item in pairs(itemDic) do + item.Count = math.floor(item.Count) + local reward = XRewardManager.CreateRewardGoods(id, item.Count) + tableInsert(itemInfoList, reward) + end + itemInfoList = XRewardManager.SortRewardGoodsList(itemInfoList) + + return itemInfoList + end + + function XPartnerManager.CheckIsPartnerByTemplateId(id) + return XArrangeConfigs.GetType(id) == XArrangeConfigs.Types.Partner + end + + function XPartnerManager.CheckMaxCount(count) + if count and count > 0 then + return XPartnerManager.GetPartnerCount() + count > PartnerMaxCount + else + return XPartnerManager.GetPartnerCount() >= PartnerMaxCount + end + end + + function XPartnerManager.CheckPartnerCount(count) + if XPartnerManager.CheckMaxCount(count) then + XUiManager.TipMsg(CSXTextManagerGetText("PartnerIsMaxHint"), XUiManager.UiTipType.Tip) + return false + end + return true + end + + function XPartnerManager.TipDialog(cancelCb, confirmCb, textKey, textParam) + local desc = "" + if textParam then + desc = CSTextManagerGetText(textKey, textParam) + else + desc = CSTextManagerGetText(textKey) + end + CsXUiManager.Instance:Open("UiDialog", CSTextManagerGetText("TipTitle"), desc, + XUiManager.DialogType.Normal, cancelCb, confirmCb) + end +-----------------------------------------------------------------红点---------------------------------------------------- + + function XPartnerManager.CheckComposeRedOfAll() + local templateCfg = XPartnerConfigs.GetPartnerTemplateCfg() + local IsShowRed = false + for _,template in pairs(templateCfg or {}) do + if XPartnerManager.CheckComposeRedByTemplateId(template.Id) then + IsShowRed = true + break + end + end + return IsShowRed + end + + function XPartnerManager.CheckComposeRedByTemplateId(templateId) + local templateCfg = XPartnerConfigs.GetPartnerTemplateCfg() + local template = templateCfg[templateId] + local chipCurCount = XDataCenter.ItemManager.GetCount(template.ChipItemId) + local chipNeedCount = template.ChipNeedCount + local count = math.floor(chipCurCount / chipNeedCount) + return count > 0 + end + + function XPartnerManager.MarkedNewSkillRed(partnerId) + if XSaveTool.GetData(string.format("%d%s%d", XPlayer.Id, "PartnerSkill", partnerId)) then + XSaveTool.RemoveData(string.format("%d%s%d", XPlayer.Id, "PartnerSkill", partnerId)) + end + end + + function XPartnerManager.CheckNewSkillRedOfAll() + local IsShowRed = false + for _,entity in pairs(PartnerEntityDic or {}) do + if XPartnerManager.CheckNewSkillRedByPartnerId(entity:GetId()) then + IsShowRed = true + break + end + end + return IsShowRed + end + + function XPartnerManager.CheckNewSkillRedByPartnerId(partnerId) + if XSaveTool.GetData(string.format("%d%s%d", XPlayer.Id, "PartnerSkill", partnerId)) then + return true + end + return false + end + + function XPartnerManager.SetNewSkillRedByPartnerId(partnerId) + if not XSaveTool.GetData(string.format("%d%s%d", XPlayer.Id, "PartnerSkill", partnerId)) then + XSaveTool.SaveData(string.format("%d%s%d", XPlayer.Id, "PartnerSkill", partnerId),true) + end + end + + function XPartnerManager.GetCheckEventIds() + local templateCfg = XPartnerConfigs.GetPartnerTemplateCfg() + local eventIds = {} + for _,cfg in pairs(templateCfg or {}) do + tableInsert(eventIds, string.format("%s%d", XEventId.EVENT_ITEM_COUNT_UPDATE_PREFIX, cfg.ChipItemId)) + end + return eventIds + end +-----------------------------------------------------------------服务器通讯---------------------------------------------------- + + function XPartnerManager.PartnerComposeRequest(templateIds, isOneKey)--伙伴合成请求 + XNetwork.Call(METHOD_NAME.PartnerComposeRequest, {TemplateIds = templateIds, IsOneKey = isOneKey}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XLuaUiManager.Open("UiPartnerPopupTip", CSTextManagerGetText("PartnerComposeFinish")) + --XUiManager.TipText("PartnerComposeFinish") + end) + end + + function XPartnerManager.PartnerCarryRequest(characterId, partnerId, errorCb)--伙伴携带请求 + local partnerEntity = PartnerEntityDic[partnerId] + + XNetwork.Call(METHOD_NAME.PartnerCarryRequest, {CharacterId = characterId, PartnerId = partnerId}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + if errorCb then errorCb() end + return + end + end) + end + + function XPartnerManager.PartnerBreakAwayRequest(partnerId, errorCb)--伙伴脱离请求 + local partnerEntity = PartnerEntityDic[partnerId] + + XNetwork.Call(METHOD_NAME.PartnerBreakAwayRequest, {PartnerId = partnerId}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + if errorCb then errorCb() end + return + end + end) + end + + function XPartnerManager.PartnerChangeNameRequest(partnerId, name, cb)--伙伴改名请求 + local partnerEntity = PartnerEntityDic[partnerId] + + XNetwork.Call(METHOD_NAME.PartnerChangeNameRequest, {PartnerId = partnerId, Name = name}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + local tmpData = { + Name = name + } + partnerEntity:UpdateData(tmpData) + if cb then cb() end + end) + end + + function XPartnerManager.PartnerUpdateLockRequest(partnerId, isLock, cb)--伙伴更新锁定状态请求 + local partnerEntity = PartnerEntityDic[partnerId] + local now = XTime.GetServerNowTimestamp() + local syscTime = LastSyncPartnerLockTime + + if not PartnerLockCount or PartnerLockCount >= PartnerLockCountMax then + if syscTime and now - syscTime < SYNC_PARTNERLOCK_SECOND then + XUiManager.TipText("PartnerSyncPartnerError") + PartnerLockCount = nil + return + end + end + + if not PartnerLockCount then + PartnerLockCount = 0 + end + + XNetwork.Call(METHOD_NAME.PartnerUpdateLockRequest, {PartnerId = partnerId, IsLock = isLock}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + local tmpData = { + IsLock = isLock + } + partnerEntity:UpdateData(tmpData) + LastSyncPartnerLockTime = XTime.GetServerNowTimestamp() + PartnerLockCount = PartnerLockCount + 1 + if cb then cb() end + end) + end + + function XPartnerManager.PartnerLevelUpRequest(partnerId, useItems, cb)--伙伴升级请求 + local partnerEntity = PartnerEntityDic[partnerId] + if partnerEntity:GetIsLevelMax() then + XUiManager.TipText("PartnerLevelUpMaxLevel") + return + end + + local costEmpty = true + local costMoney = 0 + + if useItems and next(useItems) then + costEmpty = nil + costMoney = costMoney + XPartnerManager.GetEatItemsCostMoney(useItems) + XMessagePack.MarkAsTable(useItems) + end + + if costEmpty then + XUiManager.TipText("PartnerLevelUpItemEmpty") + return + end + + if not XDataCenter.ItemManager.DoNotEnoughBuyAsset(XDataCenter.ItemManager.ItemId.Coin, costMoney, 1, function() + XPartnerManager.PartnerLevelUpRequest(partnerId, useItems, cb) + end, "PartnerCoinNotEnough") then + return + end + + XNetwork.Call(METHOD_NAME.PartnerLevelUpRequest, {PartnerId = partnerId, UseItems = useItems}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + local tmpData = { + Level = res.Level, + Exp = res.Exp + } + partnerEntity:UpdateData(tmpData) + XEventManager.DispatchEvent(XEventId.EVENT_PARTNER_ABLITYCHANGE) + if cb then cb() end + end) + end + + function XPartnerManager.PartnerBreakThroughRequest(partnerId, cb)--伙伴突破请求 + local partnerEntity = PartnerEntityDic[partnerId] + + if partnerEntity:GetIsMaxBreakthrough() then + XUiManager.TipText("PartnerBreakMax") + return + end + + if not partnerEntity:GetIsLevelMax() then + XUiManager.TipText("PartnerBreakMinLevel") + return + end + + local consumeItems = partnerEntity:GetBreakthroughItem() + if not XDataCenter.ItemManager.CheckItemsCount(consumeItems) then + XUiManager.TipText("PartnerItemNotEnough") + return + end + + local money = partnerEntity:GetBreakthroughMoney() + if not XDataCenter.ItemManager.DoNotEnoughBuyAsset(money.Id, + money.Count, + 1, + function() + XPartnerManager.PartnerBreakThroughRequest(partnerId, cb) + end, + "PartnerCoinNotEnough") then + return + end + + XNetwork.Call(METHOD_NAME.PartnerBreakThroughRequest, {PartnerId = partnerId}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + local tmpData = { + BreakThrough = res.BreakTimes, + Level = 1, + Exp = 0, + } + partnerEntity:UpdateData(tmpData) + XEventManager.DispatchEvent(XEventId.EVENT_PARTNER_ABLITYCHANGE) + if cb then cb() end + end) + end + + function XPartnerManager.PartnerStarActivateRequest(partnerId, costPartnerIds, cb)--伙伴星数进度激活请求 + local partnerEntity = PartnerEntityDic[partnerId] + + if not costPartnerIds or not next(costPartnerIds) then + XUiManager.TipText("PartnerQualityUpEmpty") + return + end + + if partnerEntity:GetCanUpQuality() then + XUiManager.TipText("PartnerAllStarActivate") + return + end + + XNetwork.Call(METHOD_NAME.PartnerStarActivateRequest, {PartnerId = partnerId, CostPartnerIds = costPartnerIds}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + local tmpData = { + StarSchedule = res.StarSchedule + } + partnerEntity:UpdateData(tmpData) + + local backItemList = res.RewardGoodsList + if backItemList then + XUiManager.OpenUiObtain(backItemList, CSTextManagerGetText("PartnerBackItem")) + end + + XPartnerManager.RemovePartnerEntity(costPartnerIds) + XEventManager.DispatchEvent(XEventId.EVENT_PARTNER_ABLITYCHANGE) + if cb then cb() end + end) + end + + function XPartnerManager.PartnerEvolutionRequest(partnerId, cb)--伙伴进化请求 + local partnerEntity = PartnerEntityDic[partnerId] + + if partnerEntity:GetIsMaxQuality() then + XUiManager.TipText("PartnerQualityMax") + return + end + + if not partnerEntity:GetCanUpQuality() then + XUiManager.TipText("PartnerClipNotEnough") + return + end + + local money = partnerEntity:GetQualityEvolutionMoney() + if not XDataCenter.ItemManager.DoNotEnoughBuyAsset(money.Id, + money.Count, + 1, + function() + XPartnerManager.PartnerEvolutionRequest(partnerId, cb) + end, + "PartnerCoinNotEnough") then + return + end + + XNetwork.Call(METHOD_NAME.PartnerEvolutionRequest, {PartnerId = partnerId}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + local tmpData = { + Quality = res.Quality + } + partnerEntity:UpdateData(tmpData) + + local backItemList = res.RewardGoodsList + if backItemList then + XUiManager.OpenUiObtain(backItemList, CSTextManagerGetText("PartnerBackItem")) + end + if cb then cb() end + end) + end + + function XPartnerManager.PartnerSkillUpRequest(partnerId, count, cb, errorCb)--伙伴技能升级请求 + local partnerEntity = PartnerEntityDic[partnerId] + + if partnerEntity:GetIsTotalSkillLevelMax() then + XUiManager.TipText("PartnerAllSkillLevelMax") + if errorCb then errorCb() end + return + end + + if partnerEntity:GetSkillLevelGap() < count then + XUiManager.TipText("PartnerSkillLevelOverFlow") + if errorCb then errorCb() end + return + end + + local consumeItems = partnerEntity:GetSkillUpgradeItem() + if not XDataCenter.ItemManager.CheckItemsCountByTimes(consumeItems, count) then + XUiManager.TipText("PartnerItemNotEnough") + if errorCb then errorCb() end + return + end + + local money = partnerEntity:GetSkillUpgradeMoney() + if not XDataCenter.ItemManager.DoNotEnoughBuyAsset(money.Id, + money.Count * count, + 1, + function() + XPartnerManager.PartnerSkillUpRequest(partnerId, cb, errorCb) + end, + "PartnerCoinNotEnough") then + if errorCb then errorCb() end + return + end + + XNetwork.Call(METHOD_NAME.PartnerSkillUpRequest, {PartnerId = partnerId, Times = count}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + if errorCb then errorCb() end + return + end + if cb then cb(res.SkillUpInfo) end + end) + end + + function XPartnerManager.PartnerSkillWearRequest(partnerId, skillDic, skillType, errorCb)--伙伴技能穿戴请求 + local partnerEntity = PartnerEntityDic[partnerId] + + local skillIdToWear = {} + for key,value in pairs(skillDic or {}) do + table.insert(skillIdToWear,{SkillId = key, IsWear = value}) + end + + XNetwork.Call(METHOD_NAME.PartnerSkillWearRequest, {PartnerId = partnerId, SkillIdToWear = skillIdToWear, SkillType = skillType}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + if errorCb then errorCb() end + return + end + end) + end + + function XPartnerManager.PartnerDecomposeRequest(partnerIds, cb)--伙伴分解请求 + XNetwork.Call(METHOD_NAME.PartnerDecomposeRequest, {PartnerIds = partnerIds}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local backItemList = res.RewardGoodsList + if backItemList then + XUiManager.OpenUiObtain(backItemList, CSTextManagerGetText("PartnerBackItem")) + end + + XPartnerManager.RemovePartnerEntity(partnerIds) + XEventManager.DispatchEvent(XEventId.EVENT_PARTNER_DECOMPOSE) + if cb then cb() end + end) + end + + XPartnerManager.Init() + return XPartnerManager +end + +XRpc.NotifyPartnerDataList = function(data) + XDataCenter.PartnerManager.UpdatePartnerEntity(data.PartnerDataList) + XEventManager.DispatchEvent(XEventId.EVENT_PARTNER_DATAUPDATE) + XEventManager.DispatchEvent(XEventId.EVENT_PARTNER_ABLITYCHANGE) + + for _,type in pairs(data.OperateTypes or {}) do + if type == XPartnerConfigs.DataSyncType.Obtain then + local entityList = {} + for _,partnerdata in pairs(data.PartnerDataList or {}) do + local entity = XDataCenter.PartnerManager.GetPartnerEntityById(partnerdata.Id) + if entity then + table.insert(entityList, entity) + XDataCenter.PartnerManager.UpdatePartnerStoryByEntity(entity) + end + end + XEventManager.DispatchEvent(XEventId.EVENT_PARTNER_OBTAIN, entityList) + elseif type == XPartnerConfigs.DataSyncType.Skill then + XEventManager.DispatchEvent(XEventId.EVENT_PARTNER_SKILLCHANGE) + elseif type == XPartnerConfigs.DataSyncType.Carry then + XEventManager.DispatchEvent(XEventId.EVENT_PARTNER_CARRY) + elseif type == XPartnerConfigs.DataSyncType.UnlockSkillGroup then + for _,partnerdata in pairs(data.PartnerDataList or {}) do + XDataCenter.PartnerManager.SetNewSkillRedByPartnerId(partnerdata.Id) + end + XEventManager.DispatchEvent(XEventId.EVENT_PARTNER_SKILLUNLOCK) + elseif type == XPartnerConfigs.DataSyncType.QualityUp then + XEventManager.DispatchEvent(XEventId.EVENT_PARTNER_QUALITYUP) + end + end +end + +XRpc.NotifyPartnerName = function(data) + XDataCenter.PartnerManager.UpdatePartnerNameById(data.PartnerId, data.PartnerName) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XPartnerTeachingManager.lua b/Resources/Scripts/XManager/XPartnerTeachingManager.lua new file mode 100644 index 00000000..98f86219 --- /dev/null +++ b/Resources/Scripts/XManager/XPartnerTeachingManager.lua @@ -0,0 +1,129 @@ +XPartnerTeachingManagerCreator = function() + local XPartnerTeachingManager = {} + + -------------------------------------------------------副本相关------------------------------------------------------ + function XPartnerTeachingManager.InitStageInfo() + local allChapterId = XPartnerTeachingConfigs.GetAllChapterId() + for _, chapterId in pairs(allChapterId) do + local stageIdList = XPartnerTeachingConfigs.GetChapterStageIds(chapterId) + for i, stageId in ipairs(stageIdList) do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + stageInfo.Type = XDataCenter.FubenManager.StageType.PartnerTeaching + stageInfo.OrderId = i + end + end + end + -------------------------------------------------------------------------------------------------------------------- + + --- + --- 'chapterId'章节是否处于活动时间 + ---@return boolean + function XPartnerTeachingManager.WhetherInActivity(chapterId) + local activeTimeId = XPartnerTeachingConfigs.GetChapterActivityTimeId(chapterId) + return XFunctionManager.CheckInTimeByTimeId(activeTimeId) + end + + --- + --- 获取活动的剩余时间戳 + function XPartnerTeachingManager.GetLeftTimeStamp(chapterId) + local activeTimeId = XPartnerTeachingConfigs.GetChapterActivityTimeId(chapterId) + local endTime = XFunctionManager.GetEndTimeByTimeId(activeTimeId) + return endTime > 0 and endTime - XTime.GetServerNowTimestamp() or 0 + end + + --- + --- 'chapterId'章节是否解锁,如果未解锁,额外返回未满足条件的描述 + ---@return boolean|string 是否解锁|未满足条件的描述 + function XPartnerTeachingManager.WhetherUnLockChapter(chapterId) + local isInActive = XPartnerTeachingManager.WhetherInActivity(chapterId) + + local conditionList + if isInActive then + conditionList = XPartnerTeachingConfigs.GetChapterActivityCondition(chapterId) + else + conditionList = XPartnerTeachingConfigs.GetChapterOpenCondition(chapterId) + end + + local lockTip + local isUnlock = true + if conditionList or next(conditionList) then + for _, conditionId in ipairs(conditionList) do + local result, desc = XConditionManager.CheckCondition(conditionId) + if not result then + lockTip = desc + isUnlock = false + break + end + end + end + return isUnlock, lockTip + end + + --- + --- 得到排序后的教学章节Id数组 + function XPartnerTeachingManager.GetSortedChapterList() + local allChapterIdList = XPartnerTeachingConfigs.GetAllChapterId() + + table.sort(allChapterIdList, function(a, b) + -- 解锁 > 锁定 + local aIsUnlock = XPartnerTeachingManager.WhetherUnLockChapter(a) + local bIsUnlock = XPartnerTeachingManager.WhetherUnLockChapter(b) + if aIsUnlock ~= bIsUnlock then + return aIsUnlock + end + + -- 活动状态 > 普通状态 + local aIsInActive = XPartnerTeachingManager.WhetherInActivity(a) + local bIsInActive = XPartnerTeachingManager.WhetherInActivity(b) + if aIsInActive ~= bIsInActive then + return aIsInActive + end + + -- 未通关 > 通关 + local aIsPass = XPartnerTeachingManager.WhetherPassChapter(a) + local bIsPass = XPartnerTeachingManager.WhetherPassChapter(b) + if aIsPass ~= bIsPass then + return bIsPass + end + return a < b + end) + + return allChapterIdList + end + + --- + --- 得到 'chapterId' 的关卡进度 + ---@return number 通关关卡数|总关卡数 + function XPartnerTeachingManager.GetChapterProgress(chapterId) + local stageIdList = XPartnerTeachingConfigs.GetChapterStageIds(chapterId) + local passNum = 0 + local totalNum = #stageIdList + + for _, stageId in ipairs(stageIdList) do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + if stageInfo.Passed then + passNum = passNum + 1 + end + end + + return passNum, totalNum + end + + --- + --- 是否通关了 'chapterId' 章节 + ---@return boolean + function XPartnerTeachingManager.WhetherPassChapter(chapterId) + local passStageNum, totalStageNum = XPartnerTeachingManager.GetChapterProgress(chapterId) + return passStageNum == totalStageNum + end + + --- + --- 获取 'chapterId' 中 ‘stageId' 的编号名称 + function XPartnerTeachingManager.GetOrderName(chapterId, stageId) + local stagePrefix = XPartnerTeachingConfigs.GetChapterStagePrefix(chapterId) + local orderId = XDataCenter.FubenManager.GetStageOrderId(stageId) + return string.format("%s%d", stagePrefix, orderId) + end + + return XPartnerTeachingManager +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XPassportManager.lua b/Resources/Scripts/XManager/XPassportManager.lua new file mode 100644 index 00000000..1cc1fa0a --- /dev/null +++ b/Resources/Scripts/XManager/XPassportManager.lua @@ -0,0 +1,381 @@ +local XPassportBaseInfo = require("XEntity/XPassport/XPassportBaseInfo") +local XPassportInfo = require("XEntity/XPassport/XPassportInfo") + +XPassportManagerCreator = function() + local BaseInfo = XPassportBaseInfo.New() --基础信息 + local PassportInfosDic = {} --已解锁通行证字典 + local LastTimeBaseInfo = XPassportBaseInfo.New() --上一期活动基础信息 + local CurrMainViewSelectTagIndex --缓存主界面选择的页签 + + ---------------------本地接口 begin------------------ + local UpdatePassportInfosDic = function(passportInfos) + local passportInfo + for _, data in pairs(passportInfos) do + passportInfo = PassportInfosDic[data.Id] + if not passportInfo then + passportInfo = XPassportInfo.New() + PassportInfosDic[data.Id] = passportInfo + end + passportInfo:UpdateData(data) + end + end + + local SetPassportReceiveReward = function(passportId, passportRewardId) + local passportInfo = XDataCenter.PassportManager.GetPassportInfos(passportId) + if passportInfo then + passportInfo:SetReceiveReward(passportRewardId) + end + end + ---------------------本地接口 end------------------ + local XPassportManager = {} + + --获得玩家通行证信息 + --id:通行证id + function XPassportManager.GetPassportInfos(passportId) + return PassportInfosDic[passportId] + end + + --是否已领取奖励 + function XPassportManager.IsReceiveReward(passportId, passportRewardId) + local passportInfo = XPassportManager.GetPassportInfos(passportId) + return passportInfo and passportInfo:IsReceiveReward(passportRewardId) + end + + --是否可领取奖励 + function XPassportManager.IsCanReceiveReward(passportId, passportRewardId) + local passportInfo = XPassportManager.GetPassportInfos(passportId) + local isUnLock = passportInfo and true or false + local baseInfo = XPassportManager.GetPassportBaseInfo() + local currLevel = baseInfo:GetLevel() + local levelCfg = XPassportConfigs.GetPassportRewardLevel(passportRewardId) + return currLevel >= levelCfg and isUnLock + end + + function XPassportManager.GetPassportBaseInfo() + return BaseInfo + end + + function XPassportManager.GetPassportLastTimeBaseInfo() + return LastTimeBaseInfo + end + + ---------------------红点 begin--------------------- + --通行证检查是否可领取等级奖励 + function XPassportManager.CheckPassportRewardRedPoint() + local baseInfo = XPassportManager.GetPassportBaseInfo() + local currLevel = baseInfo:GetLevel() + local typeInfoIdList = XPassportConfigs.GetPassportActivityIdToTypeInfoIdList() + local passportRewardIdList + local levelCfg + + for _, passportId in ipairs(typeInfoIdList) do + if XPassportManager.GetPassportInfos(passportId) then + passportRewardIdList = XPassportConfigs.GetPassportRewardIdList(passportId) + for _, passportRewardId in ipairs(passportRewardIdList) do + levelCfg = XPassportConfigs.GetPassportRewardLevel(passportRewardId) + if currLevel < levelCfg then + break + end + if not XPassportManager.IsReceiveReward(passportId, passportRewardId) then + return true + end + end + end + end + return false + end + + function XPassportManager.CheckPassportAchievedTaskRedPoint(taskType) + local taskIdList = taskType == XPassportConfigs.TaskType.Activity and XPassportConfigs.GetPassportBPTask() or XPassportConfigs.GetPassportTaskGroupCurrOpenTaskIdList(taskType) + for _, taskId in pairs(taskIdList) do + if XDataCenter.TaskManager.CheckTaskAchieved(taskId) then + return true + end + end + return false + end + ---------------------红点 end----------------------- + + ---------------------活动入口 begin--------------------- + --活动是否已结束 + function XPassportManager.IsActivityClose() + local nowServerTime = XTime.GetServerNowTimestamp() + local timeId = XPassportConfigs.GetPassportActivityTimeId() + local endTime = XFunctionManager.GetEndTimeByTimeId(timeId) + return nowServerTime >= endTime + end + + --检查活动没开回主界面 + function XPassportManager.CheckActivityIsOpen() + local timeId = XPassportConfigs.GetPassportActivityTimeId() + if not XFunctionManager.CheckInTimeByTimeId(timeId) then + if CS.XFight.IsRunning or XLuaUiManager.IsUiLoad("UiLoading") then + return false + end + + XUiManager.TipText("ActivityMainLineEnd") + XLuaUiManager.RunMain() + return false + end + return true + end + ---------------------活动入口 end----------------------- + + ---------------------主界面 begin--------------------- + function XPassportManager.CatchCurrMainViewSelectTagIndex(currSelectTagIndex) + CurrMainViewSelectTagIndex = currSelectTagIndex + end + + function XPassportManager.GetCurrMainViewSelectTagIndex() + return CurrMainViewSelectTagIndex or 1 + end + ---------------------主界面 end----------------------- + + ---------------------任务 begin------------------ + function XPassportManager.GetClearTaskCount(taskType) + local taskIdList = taskType == XPassportConfigs.TaskType.Activity and XPassportConfigs.GetPassportBPTask() or XPassportConfigs.GetPassportTaskGroupCurrOpenTaskIdList(taskType) + local clearTotalCount = 0 + for _, taskId in ipairs(taskIdList) do + if XDataCenter.TaskManager.CheckTaskFinished(taskId) then + clearTotalCount = clearTotalCount + 1 + end + end + return clearTotalCount + end + + function XPassportManager.GetPassportTask(taskType) + local taskIdList = taskType == XPassportConfigs.TaskType.Activity and XPassportConfigs.GetPassportBPTask() or XPassportConfigs.GetPassportTaskGroupCurrOpenTaskIdList(taskType) + local taskList = {} + local tastData + for _, taskId in pairs(taskIdList) do + tastData = XDataCenter.TaskManager.GetTaskDataById(taskId) + if tastData then + table.insert(taskList, tastData) + end + end + + local achieved = XDataCenter.TaskManager.TaskState.Achieved + local finish = XDataCenter.TaskManager.TaskState.Finish + table.sort(taskList, function(a, b) + if a.State ~= b.State then + if a.State == achieved then + return true + end + if b.State == achieved then + return false + end + if a.State == finish then + return false + end + if b.State == finish then + return true + end + end + + local templatesTaskA = XDataCenter.TaskManager.GetTaskTemplate(a.Id) + local templatesTaskB = XDataCenter.TaskManager.GetTaskTemplate(b.Id) + return templatesTaskA.Priority > templatesTaskB.Priority + end) + + return taskList + end + + --返回当前任务列表中已获得的经验,和能获得的总经验 + function XPassportManager.GetPassportTaskExp(passportTaskGroupId) + local taskIdList = XPassportConfigs.GetPassportTaskGroupTaskIdList(passportTaskGroupId) + local rewardId + local totalExp = 0 + local currExp = 0 + local rewards + local itemId = XDataCenter.ItemManager.ItemId.PassportExp + local isTaskFinish + + for _, taskId in ipairs(taskIdList) do + rewardId = XTaskConfig.GetTaskRewardId(taskId) + rewards = XRewardManager.GetRewardList(rewardId) + isTaskFinish = XDataCenter.TaskManager.CheckTaskFinished(taskId) + for _, v in pairs(rewards) do + if v.TemplateId == itemId then + totalExp = totalExp + v.Count + if isTaskFinish then + currExp = currExp + v.Count + end + end + end + end + + return currExp, totalExp + end + + function XPassportManager.GetPassportAchievedTaskIdList(taskType) + local taskIdList = taskType == XPassportConfigs.TaskType.Activity and XPassportConfigs.GetPassportBPTask() or XPassportConfigs.GetPassportTaskGroupCurrOpenTaskIdList(taskType) + local achievedTaskIdList = {} + local tastData + for _, taskId in pairs(taskIdList) do + if XDataCenter.TaskManager.CheckTaskAchieved(taskId) then + table.insert(achievedTaskIdList, taskId) + end + end + return achievedTaskIdList + end + ---------------------任务 end-------------------- + + ---------------------奖励 begin----------------------- + function XPassportManager.GetCookieAutoGetTaskRewardList() + local key = XPassportManager.GetAutoGetTaskRewardListCookieKey() + return XSaveTool.GetData(key) + end + + function XPassportManager.InsertCookieAutoGetTaskRewardList(rewardList) + local key = XPassportManager.GetAutoGetTaskRewardListCookieKey() + local cookieRewardList = XPassportManager.GetCookieAutoGetTaskRewardList() + if cookieRewardList then + for _, rewardData in ipairs(rewardList) do + table.insert(cookieRewardList, rewardData) + end + end + XSaveTool.SaveData(key, cookieRewardList or rewardList) + end + + function XPassportManager.ClearCookieAutoGetTaskRewardList() + local key = XPassportManager.GetAutoGetTaskRewardListCookieKey() + XSaveTool.RemoveData(key) + end + + function XPassportManager.GetAutoGetTaskRewardListCookieKey() + return XPlayer.Id .. "_XPassportManager_AutoGetTaskRewardList" + end + ---------------------奖励 end----------------------- + + ---------------------protocol begin------------------ + --登录推送数据 + function XPassportManager.NotifyPassportData(data) + XPassportConfigs.SetDefaultActivityId(data.ActivityId) + BaseInfo:SetToLevel(data.Level or data.BaseInfo.Level) + LastTimeBaseInfo:UpdateData(data.LastTimeBaseInfo) + + UpdatePassportInfosDic(data.PassportInfos) + end + + --通知基础信息变化 + function XPassportManager.NotifyPassportBaseInfo(data) + BaseInfo:UpdateData(data.Level or data.BaseInfo.Level) + XEventManager.DispatchEvent(XEventId.EVENT_NOTIFY_PASSPORT_BASE_INFO) + end + + --通知自动领取任务奖励列表 + function XPassportManager.NotifyAutoGetTaskRewardList(data) + XPassportManager.InsertCookieAutoGetTaskRewardList(data.RewardList or {}) + XEventManager.DispatchEvent(XEventId.EVENT_AUTO_GET_TASK_REWARD_LIST) + end + + --购买通行证请求 + function XPassportManager.RequestPassportBuyPassport(id, cb) + XNetwork.Call("PassportBuyPassportRequest", { Id = id }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local name = XPassportConfigs.GetPassportTypeInfoName(id) + local msg = CS.XTextManager.GetText("SuccessfulItemPurchase", name) + XUiManager.TipMsg(msg) + + XUiManager.OpenUiObtain(res.RewardList or {}) + UpdatePassportInfosDic({res.PassportInfo}) + + if cb then + cb() + end + + XEventManager.DispatchEvent(XEventId.EVENT_BUY_PASSPORT_COMPLEATE) + end) + end + + --购买通行证经验(等级)请求 + function XPassportManager.RequestPassportBuyExp(toLevel, cb) + XNetwork.Call("PassportBuyExpRequest", { ToLevel = toLevel }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + XUiManager.TipText("PassportBuyExpCompleate") + BaseInfo:SetToLevel(toLevel) + + if cb then + cb() + end + + XEventManager.DispatchEvent(XEventId.EVENT_BUY_EXP_COMPLEATE) + end) + end + + --领取单个奖励请求 + function XPassportManager.RequestPassportRecvReward(passportRewardId, cb) + XNetwork.Call("PassportRecvRewardRequest", { Id = passportRewardId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local passportId = XPassportConfigs.GetPassportRewardPassportId(passportRewardId) + SetPassportReceiveReward(passportId, passportRewardId) + + XUiManager.OpenUiObtain(res.RewardList or {}) + + if cb then + cb() + end + + XEventManager.DispatchEvent(XEventId.EVENT_BUY_RECV_REWARD_COMPLEATE) + end) + end + + --一键领取奖励请求 + function XPassportManager.RequestPassportRecvAllReward(cb) + XNetwork.Call("PassportRecvAllRewardRequest", nil, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + XUiManager.OpenUiObtain(res.RewardList or {}) + UpdatePassportInfosDic(res.PassportInfos) + + if cb then + cb() + end + + XEventManager.DispatchEvent(XEventId.EVENT_BUY_RECV_ALL_REWARD_COMPLEATE) + end) + end + + --批量领取任务奖励 + function XPassportManager.FinishMultiTaskRequest(taskType) + local taskIds = XPassportManager.GetPassportAchievedTaskIdList(taskType) + if XTool.IsTableEmpty(taskIds) then + return + end + + XDataCenter.TaskManager.FinishMultiTaskRequest(taskIds, function(rewardGoodsList) + XUiManager.OpenUiObtain(rewardGoodsList) + end) + end + ---------------------protocol end------------------ + return XPassportManager +end + +---------------------(服务器推送)begin------------------ +XRpc.NotifyPassportData = function(data) + XDataCenter.PassportManager.NotifyPassportData(data) +end + +XRpc.NotifyPassportBaseInfo = function(data) + XDataCenter.PassportManager.NotifyPassportBaseInfo(data) +end + +XRpc.NotifyAutoGetTaskRewardList = function(data) + XDataCenter.PassportManager.NotifyAutoGetTaskRewardList(data) +end +---------------------(服务器推送)end-------------------- \ No newline at end of file diff --git a/Resources/Scripts/XManager/XPayManager.lua b/Resources/Scripts/XManager/XPayManager.lua new file mode 100644 index 00000000..9f096339 --- /dev/null +++ b/Resources/Scripts/XManager/XPayManager.lua @@ -0,0 +1,240 @@ +XPayManagerCreator = function() + local Application = CS.UnityEngine.Application + local Platform = Application.platform + local RuntimePlatform = CS.UnityEngine.RuntimePlatform + local PayAgent = nil + + local XPayManager = {} + local IsGetFirstRechargeReward -- 是否领取首充奖励 + local IsFirstRecharge -- 是否首充 + + local METHOD_NAME = { + Initiated = "PayInitiatedRequest", + CheckResult = "PayCheckResultRequest", + GetFirstPayReward = "GetFirstPayRewardRequest", -- 获取首充奖励 + } + + local NearPayId = nil + local CurrentPayIds = {} + local PurchasePayLockGoodsTime = CS.XGame.ClientConfig:GetFloat("PurchasePayLockGoodsTime") + + local function IsSupportPay() + return Application.isMobilePlatform or + (Platform == RuntimePlatform.WindowsPlayer or Platform == RuntimePlatform.WindowsEditor) + end + + local function InitAgent() + if Platform == RuntimePlatform.Android then + PayAgent = XPayHeroAgent.New(XPlayer.Id) + elseif Platform == RuntimePlatform.IPhonePlayer then + PayAgent = XPayHeroAgent.New(XPlayer.Id) + elseif Platform == RuntimePlatform.WindowsPlayer or Platform == RuntimePlatform.WindowsEditor then + PayAgent = XPayAgent.New(XPlayer.Id) + -- else + + end + end + + local function DoInit() + XEventManager.AddEventListener(XEventId.EVENT_LOGIN_SUCCESS, function() + InitAgent() + end) + CurrentPayIds = {} + XEventManager.AddEventListener(XEventId.EVENT_PURCHASEBUY_PAYCANCELORFAIL, function() + XPayManager.ClearCurrentPayId() + end) + end + + local DoPay = function(productKey, cpOrderId, goodsId) + PayAgent:Pay(productKey, cpOrderId, goodsId) + end + + function XPayManager.PurchasePayLock(id) + --XLog.Error("当前锁住的id是" .. tostring(id)) + CurrentPayIds[id] = XTime.GetServerNowTimestamp() + end + + function XPayManager.SetNearPayId(id) + NearPayId = id + end + + function XPayManager.GetCurrentPayIds() + return CurrentPayIds + end + + function XPayManager.ClearCurrentPayId(id) + local currentId = id and id or NearPayId + if not currentId then + return + end + --XLog.Error("清空缓存id是:" .. tostring(id)) + CurrentPayIds[currentId] = nil + --XLog.Error("清空缓存此时的缓存数据是:") + for k, _ in pairs(CurrentPayIds) do + XLog.Error(tostring(k)) + end + --XLog.Error("--------------------------------------------") + end + + function XPayManager.CheckCanBuy(id) + local now = XTime.GetServerNowTimestamp() + local lastBuyTime = CurrentPayIds[id] + if not lastBuyTime then + return true + end + + if now - lastBuyTime > PurchasePayLockGoodsTime then + CurrentPayIds[id] = nil + return true + else + XUiManager.TipText("PurchaseCurrentPayTips") + return false + end + end + + function XPayManager.Pay(productKey, ptype, params, id, callback) + if XUserManager.HasLoginError() then -- 临时兼容sdk会回调多次登陆成功的问题 + XUiManager.SystemDialogTip(CS.XTextManager.GetText("TipTitle"), "账号信息过期,请重新登陆", XUiManager.DialogType.OnlySure, nil, function() + XUserManager.ClearLoginData() + end) + return + end + + if not IsSupportPay() or not PayAgent then + return + end + + local template = XPayConfigs.GetPayTemplate(productKey) + if not template then + return + end + + local TargetParam = {} + TargetParam.TargetType = ptype + TargetParam.Params = params + --锁住当前购买id等待支付失败解锁,服务端成功解锁 以及超时解锁 + if ptype then + XPayManager.SetNearPayId(id) + XPayManager.PurchasePayLock(id) + end + --CheckPoint: APPEVENT_REDEEMED_AND_MONTHCARD + XAppEventManager.PurchasePayAppLogEvent(template.PayId) + + XNetwork.Call(METHOD_NAME.Initiated, {Key = productKey, TargetParam = TargetParam}, function (res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + if ptype then + XPayManager.ClearCurrentPayId(id) + end + return + end + + --BDC + CS.XHeroBdcAgent.BdcCreateOrder(tostring(template.PayId), template.Type, XTime.GetServerNowTimestamp(), res.GameOrder) + + DoPay(productKey, res.GameOrder, template.GoodsId) + if callback then + callback() + end + end) + end + + -- 领取首充奖励请求 + function XPayManager.GetFirstPayRewardReq(cb) + XNetwork.Call(METHOD_NAME.GetFirstPayReward, nil, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + IsGetFirstRechargeReward = true + if cb then + cb() + end + XUiManager.OpenUiObtain(res.RewardList) + XEventManager.DispatchEvent(XEventId.EVENT_CARD_REFRESH_WELFARE_BTN) + end) + end + + function XPayManager.GetFirstRecharge() + return IsFirstRecharge + end + + function XPayManager.GetFirstRechargeReward() + return IsGetFirstRechargeReward + end + + -- 是否首充奖励领取 + function XPayManager.IsGotFirstReCharge() + local isRecharge = XPayManager.GetFirstRecharge() + if not isRecharge then + return true + end + + local isGot = XPayManager.GetFirstRechargeReward() + return isGot + end + + -- 是否月卡奖励领取 + function XPayManager.IsGotCard(uiType, id) + local isBuy = XDataCenter.PurchaseManager.IsYkBuyed(uiType, id) + if not isBuy then + return true + end + + local data = XDataCenter.PurchaseManager.GetYKInfoData(uiType, id) + return data.IsDailyRewardGet + end + + function XPayManager.NotifyPayResult(data) + if not data then return end + + IsFirstRecharge = XPayConfigs.CheckFirstPay(data.TotalPayMoney) + local orderList = data.DealGameOrderList + -- 测试充值 + if not orderList or #orderList == 0 then + return + end + + PayAgent:OnDealSuccess(orderList) + XEventManager.DispatchEvent(XEventId.EVENT_CARD_REFRESH_WELFARE_BTN) + end + + function XPayManager.NotifyPayInfo(data) + if not data then return end + + IsGetFirstRechargeReward = data.IsGetFirstPayReward + IsFirstRecharge = XPayConfigs.CheckFirstPay(data.TotalPayMoney) + XPayManager.TotalPayMoney = data.TotalPayMoney or 0 + end + + DoInit() + + return XPayManager +end + +XRpc.NotifyPayResult = function(data) + -- 测试充值 + -- XLog.Error("充值结果回调--data--Begin") + -- XLog.Error(data) + -- XLog.Error("充值结果回调--data--End") + if not data then return end + + if data.TotalPayMoney and data.TotalPayMoney > 0 then + if XDataCenter.PayManager.LastTotalPayMoney == nil then + XDataCenter.PayManager.LastTotalPayMoney = XDataCenter.PayManager.TotalPayMoney + if XDataCenter.PayManager.LastTotalPayMoney == 0 then + --CheckPoint: APPEVENT_FIRST_BUY + XAppEventManager.AppLogEvent(XAppEventManager.CommonEventNameConfig.First_buy) + end + end + --CheckPoint: APPEVENT_PURCHASED + XAppEventManager.PayAppLogEvent(data.TotalPayMoney - XDataCenter.PayManager.LastTotalPayMoney) + XDataCenter.PayManager.LastTotalPayMoney = data.TotalPayMoney + end + XDataCenter.PayManager.NotifyPayResult(data) +end + +XRpc.NotifyPayInfo = function(data) + XDataCenter.PayManager.NotifyPayInfo(data) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XPermissionManager.lua b/Resources/Scripts/XManager/XPermissionManager.lua new file mode 100644 index 00000000..3df542b2 --- /dev/null +++ b/Resources/Scripts/XManager/XPermissionManager.lua @@ -0,0 +1,82 @@ +XPermissionManager = XPermissionManager or {} + +-- 权限授权状态 +local PERMISSION_DENIED = -1 +local PERMISSION_GRANTED = 0 +local PERMISSION_CUSTOMER_DENIED = 1 +local PERMISSION_STATE_NONE = 2 + +local PERMISSION_STATE_KEY = "PERMISSION_GRANTED_" +local CSXToolGetPermission = function() print("PermissionManager not init") end + +local PermissionStateMap = {} +local PermissionTextMap = {} + +-- [权限] = 设置权限文字提示key +local PermissionEnumMap = { + [CS.XPermissionEnum.CAMERA] = "PremissionCameraDesc", + [CS.XPermissionEnum.READ_EXTERNAL_STORAGE] = "PremissionReadDesc", + [CS.XPermissionEnum.WRITE_EXTERNAL_STORAGE] = "PremissionWriteDesc", +} + +-- 权限初始化逻辑 +function XPermissionManager.Init() + + -- 暂不允许直接调用请求权限接口 + CSXToolGetPermission = CS.XTool.GetPermission + CS.XTool.GetPermission = nil + + for enum, desc in pairs(PermissionEnumMap) do + local code = enum:GetHashCode() + PermissionTextMap[code] = CS.XTextManager.GetText(desc) + end + + if not CS.XTool.CheckPermission then -- 兼容线上版本 + return + end + + for enum, desc in pairs(PermissionEnumMap) do + local code = enum:GetHashCode() + local customerState = CS.UnityEngine.PlayerPrefs.GetInt(PERMISSION_STATE_KEY .. code, PERMISSION_STATE_NONE) + PermissionStateMap[code] = customerState + + local state = CS.XTool.CheckPermission(enum) -- 设备权限情况 + if state == PERMISSION_GRANTED then + CS.UnityEngine.PlayerPrefs.SetInt(PERMISSION_STATE_KEY .. code, state) + PermissionStateMap[code] = state + end + end +end + +-- 检查并获取权限(拒绝后不重复询问) +function XPermissionManager.TryGetPermission(permissionEnum, description, cb) + local code = permissionEnum:GetHashCode() + + if PermissionStateMap[code] == PERMISSION_CUSTOMER_DENIED and + (CS.XTool.CheckPermission == nil or CS.XTool.CheckPermission(permissionEnum) ~= PERMISSION_GRANTED) then + local text = PermissionTextMap[code] + if not PermissionTextMap[code] then + XLog.Error("获取权限错误,在PermissionEnumMap中缺少处理代码") + end + text = text or CS.XTextManager.GetText("PremissionDesc") + XUiManager.TipMsg(text, XUiManager.UiTipType.Tip) + return + end + + local resultCB = function(isGranted, dontTip) + local state = isGranted and PERMISSION_GRANTED or PERMISSION_CUSTOMER_DENIED + if PermissionStateMap[code] ~= state then + CS.UnityEngine.PlayerPrefs.SetInt(PERMISSION_STATE_KEY .. code, state) + CS.UnityEngine.PlayerPrefs.Save() + PermissionStateMap[code] = state + end + cb(isGranted, dontTip) + end + return CSXToolGetPermission(permissionEnum, description, resultCB) +end + + +function XPermissionManager.GetPermissionStateMap() + return PermissionStateMap +end + diff --git a/Resources/Scripts/XManager/XPersonalInfoManager.lua b/Resources/Scripts/XManager/XPersonalInfoManager.lua new file mode 100644 index 00000000..fbd417e5 --- /dev/null +++ b/Resources/Scripts/XManager/XPersonalInfoManager.lua @@ -0,0 +1,349 @@ +XPersonalInfoManagerCreator = function() + + local XPersonalInfoManager = {} + + -- local PanelPersonalInfo = nil + + local DailyItemsPools = {}--自己日记item缓存池 + local OtherDailyItemsPools = {}--其它人日记item缓存池 + local DailyServerDataPools = {} --服务器数据缓存池 + + local DailyDict = {} + local PlayerId = nil + local LeaveMsgs = {} + + XPersonalInfoManager.ItemPanelType = { + NorDaily = 1, + DailyleaveMsg = 2, + } + + XPersonalInfoManager.OpenViewType = { + Personal = 1, + Social = 2, + } + + local showLog = false + function XPersonalInfoManager.DebugLog(...) + if showLog then + XLog.Error(...) + end + end + + function XPersonalInfoManager.Init() + end + + function XPersonalInfoManager.ReqShowInfoPanel(id, loadCompleteCB, closeCB, chatContent)--查看个人信息 + if id == XPlayer.Id then + if loadCompleteCB then + loadCompleteCB() + end + XLuaUiManager.Open("UiPlayer", closeCB) + return + end + --查看个人信息 + XDataCenter.PlayerInfoManager.RequestPlayerInfoData(id, function(data) + XLuaUiManager.Open("UiPlayerInfo", data, chatContent) + if loadCompleteCB then + loadCompleteCB() + end + end) + end + + --日记模块 + function XPersonalInfoManager.RefreshLeaveMsgData(id, pageNum, cb) + if PlayerId ~= nil then + XPersonalInfoManager.LookOverLeaveMsg(id, pageNum, cb) + end + end + + function XPersonalInfoManager.RefreshDailyData(pageNum, cb) + if PlayerId ~= nil then + XPersonalInfoManager.GetDailys(PlayerId, pageNum, cb) + end + end + + function XPersonalInfoManager.OpenInputView(cb) + if XPersonalInfoManager.PanelMsgBoard ~= nil then + XPersonalInfoManager.PanelMsgBoard.XUiPanelWriteDiary:OpenView(cb) + end + end + + --增加管理对象 + function XPersonalInfoManager.AddPanelPersonalInfo() + -- PanelPersonalInfo = obj + end + --End 增加管理对象 + --Protolcol Model + local PROTOL_METHOD_NAME = { + GetDailys = "GetDailysRequest", + WriteDaily = "WriteDailyRequest", + GiveALike = "GiveLikeRequest", + AddLeaveMsg = "LeaveMsgRequest", + LookOverLeaveMsg = "LookOverLeaveMsgRequest", + DeleteDaily = "DeleteDailyRequest", + DeleteLeaveMsg = "DeleteLeaveMsgRequest", + BanWriteMsg = "BanMsgRequest", + ViewPersonalInfo = "ViewPersonalInfoRequest" + } + + function XPersonalInfoManager.GetDailys(playerId, pageNum, cb)--获得日记内容,cb一般是用来刷新界面回调 + PlayerId = playerId + local req = { PlayerId = playerId, PageNum = pageNum } + XNetwork.Call(PROTOL_METHOD_NAME.GetDailys, req, + function(response) + if response.Code ~= XCode.Success then + XUiManager.TipCode(response.Code) + return + end + local pool = XPersonalInfoManager.GetPool(DailyServerDataPools, pageNum) + for _ = 1, #pool do--清除原有数据 + table.remove(pool) + end + XTool.LoopCollection(response.DailyList, function(data) + table.insert(pool, data) + DailyDict[data.Id] = data + end) + if cb then + cb() + end + end) + end + + function XPersonalInfoManager.WriteDaily(content, cb)--写日记 + local req = { DailyContent = content } + XNetwork.Call(PROTOL_METHOD_NAME.WriteDaily, req, + function(response) + if response.Code ~= XCode.Success then + XUiManager.TipCode(response.Code) + return + end + if cb then + cb() + end + end) + end + + function XPersonalInfoManager.GiveALike(playerId, dailyId, cb)--点赞 + local req = { PlayerId = playerId, DailyId = dailyId } + XNetwork.Call(PROTOL_METHOD_NAME.GiveALike, req, + function(response) + if response.Code == XCode.DailyGiveALikeFail then + XUiManager.TipCode(response.Code) + return + end + if response.Code == XCode.DailyAddLikeSuccess and cb then + cb(true) + return + end + if response.Code == XCode.DailyDelLikeSuccess and cb then + cb(false) + return + end + end) + end + + function XPersonalInfoManager.AddLeaveMsg(playerId, dailyId, content, cb)--留言 + local req = { PlayerId = playerId, DailyId = dailyId, LeaveMsg = content } + XNetwork.Call(PROTOL_METHOD_NAME.AddLeaveMsg, req, + function(response) + if response.Code ~= XCode.Success then + XUiManager.TipCode(response.Code) + return + end + if cb then + cb() + return + end + end) + end + + function XPersonalInfoManager.LookOverLeaveMsg(id, pageNum, cb)--查看留言 + local req = { PlayerId = PlayerId, DailyId = id } + XNetwork.Call(PROTOL_METHOD_NAME.LookOverLeaveMsg, req, + function(response) + if response.Code ~= XCode.Success then + XUiManager.TipCode(response.Code) + return + end + local pool = XPersonalInfoManager.GetPool(DailyServerDataPools, pageNum) + for _, v in pairs(pool) do + if v.Id == id then + v.Msgs = {} + XTool.LoopCollection(response.MsgArray, function(data) + table.insert(v.Msgs, data) + end) + break + end + end + if cb then + cb() + return + end + end) + end + + function XPersonalInfoManager.DeleteDaily(id, cb)--删除日记 + local req = { DailyId = id } + XNetwork.Call(PROTOL_METHOD_NAME.DeleteDaily, req, + function(response) + if response.Code ~= XCode.Success then + XUiManager.TipCode(response.Code) + return + end + if cb then + cb() + return + end + end) + end + + function XPersonalInfoManager.DeleteLeaveMsg(dailyId, msgId, cb)--删除留言 + local req = { DailyId = dailyId, MsgId = msgId } + XNetwork.Call(PROTOL_METHOD_NAME.DeleteLeaveMsg, req, + function(response) + if response.Code ~= XCode.Success then + XUiManager.TipCode(response.Code) + return + end + if DailyDict[dailyId] ~= nil then + DailyDict[dailyId].LeaveMsgCount = DailyDict[dailyId].LeaveMsgCount - 1 + end + if cb then + cb() + return + end + end) + end + + + function XPersonalInfoManager.BanWriteMsg(id, cb)--禁止留言 + local req = { DailyId = id } + XNetwork.Call(PROTOL_METHOD_NAME.BanWriteMsg, req, + function(response) + if response.Code ~= XCode.Success then + XUiManager.TipCode(response.Code) + return + end + if cb then + cb() + return + end + end) + end + + function XPersonalInfoManager.ViewPersonalInfo(findId, cb) + XNetwork.Call(PROTOL_METHOD_NAME.ViewPersonalInfo, { viewId = findId }, function(response) + if response.Code ~= XCode.Success then + XUiManager.TipCode(response.Code) + return + end + if cb then + cb(response.Code, response.data) + end + end) + end + + --End Protolcol Model + --Create Pool + function XPersonalInfoManager.GetPool(findPools, poolIndex) + if not findPools then + findPools = {} + end + local pool = findPools[poolIndex] + if not pool then + pool = {} + findPools[poolIndex] = pool + end + return pool + end + local GetLeaveMsgsById = function(pageNum, id)--取出当前Id的留言消息 + LeaveMsgs = {} + local pool = XPersonalInfoManager.GetPool(DailyServerDataPools, pageNum) + for _, v in pairs(pool) do + if v.Id == id then + XTool.LoopCollection(v.Msgs, function(data) + table.insert(LeaveMsgs, data) + end) + return LeaveMsgs + end + end + return LeaveMsgs + end + + local GetCallback = function(pageNum, id) + return function(item, data, i) + item:SetProperty(data, i, pageNum, id) + end + end + + function XPersonalInfoManager.CreateItems(rootUi, item, parent, pageNum, id, selType, callback) + --pageNum页数 --id页数item里面的ID + local pool = selType == XPersonalInfoManager.ItemPanelType.DailyleaveMsg + and XPersonalInfoManager.GetPool(XPlayer.Id == PlayerData.Id + and DailyItemsPools or OtherDailyItemsPools, tonumber(pageNum .. id)) + or XPersonalInfoManager.GetPool(XPlayer.Id == PlayerData.Id + and DailyItemsPools or OtherDailyItemsPools, pageNum) + local datas = selType == XPersonalInfoManager.ItemPanelType.DailyleaveMsg + and GetLeaveMsgsById(pageNum, id) + or XPersonalInfoManager.GetPool(DailyServerDataPools, pageNum) + local ctor = selType == XPersonalInfoManager.ItemPanelType.DailyleaveMsg and XUiPanelLeaveMsgItem.New or XUiPanelMsgBoardItem.New + local template = item + local onCreate = GetCallback(pageNum, id) + --1 对象池 2 数据源 3 Item构造 4 Clone源 5 Parent 6 create 7 Callback + XPersonalInfoManager.CreateTemplateItems(rootUi, pool, datas, ctor, template, parent, onCreate, callback) + end + + function XPersonalInfoManager.CreateTemplateItems(rootUi, pool, datas, ctor, template, parent, onCreate, callback) + local tempTable = {} + local poolCount = #pool + if template then + template.gameObject:SetActive(false) + end + for i = 1, #datas do + local data = datas[i] + local item + if i <= poolCount then + item = pool[i] + else + if i == 1 then + item = template + else + item = CS.UnityEngine.Object.Instantiate(template) + end + item.transform:SetParent(parent, false) + item.transform.localEulerAngles = CS.UnityEngine.Vector3.zero + item.transform.localScale = CS.UnityEngine.Vector3.one + item = ctor(rootUi, item) + pool[i] = item + end + if onCreate then + onCreate(item, data, i) + end + table.insert(tempTable, item) + end + for i = #datas + 1, #pool do + local item = pool[i] + item.GameObject:SetActive(false) + end + if callback then + callback(tempTable) + end + end + + --End Create Pool + function XPersonalInfoManager.OnDispose() + if PlayerId ~= nil and XPlayer.Id == PlayerId then + DailyItemsPools = {} + else + OtherDailyItemsPools = {} + end + DailyServerDataPools = {} + PlayerId = nil + LeaveMsgs = {} + XPersonalInfoManager.PanelMsgBoard = nil + -- PanelPersonalInfo = nil + end + + XPersonalInfoManager.Init() + return XPersonalInfoManager +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XPhotographManager.lua b/Resources/Scripts/XManager/XPhotographManager.lua new file mode 100644 index 00000000..cce2e01a --- /dev/null +++ b/Resources/Scripts/XManager/XPhotographManager.lua @@ -0,0 +1,406 @@ +local CSTextManagerGetText = CS.XTextManager.GetText +local tableInsert = table.insert +local tableSort = table.sort + +XPhotographManagerCreator = function() + local XPhotographManager = {} + local SceneIdList = {} -- 场景Id列表 + local SceneIdListInTime = {} -- 当前时间可以显示的场景列表Id + local OwnCharDatas = {} -- 拥有的角色数据表 + local OwnCharDatasDic = {} -- 拥有的角色数据字典 + local HasSceneIdDic = {} -- 拥有的场景Id字典 + local TextureCache = {} -- 已保存图片缓存 + local ShareSDKIds = {} -- 当前渠道分享类型 + local CurSceneId = 0 + local CurSelectSceneId = 0 -- 当前选中的场景ID + local DirPath = "" -- 准备分享的照片保存路径 + + local PHOTOGRAPH_PROTO = { + ChangeDisplayRequest = "ChangeDisplayRequest", + ShareBackgroundRequest = "ShareBackgroundRequest", -- 分享消息 + PhotoBackgroundRequest = "PhotoBackgroundRequest", -- 拍照消息 + } + + function XPhotographManager.Init() + for id in pairs(XPhotographConfigs.GetSceneTemplates()) do + tableInsert(SceneIdList, id) + end + XEventManager.AddEventListener(XEventId.EVENT_CHARACTER_FIRST_GET, function() XPhotographManager.InitCharacterList() end) + XEventManager.AddEventListener(XEventId.EVENT_FAVORABILITY_LEVELCHANGED, function() XPhotographManager.InitCharacterList() end) + + if XUserManager.Platform == XUserManager.PLATFORM.Android then + DirPath = CS.UnityEngine.Application.persistentDataPath .. "/../../../../DCIM/ScreenShot/" + elseif XUserManager.Platform == XUserManager.PLATFORM.IOS then + DirPath = CS.UnityEngine.Application.persistentDataPath .. "/" + elseif XUserManager.Platform == XUserManager.PLATFORM.Win then + DirPath = CS.UnityEngine.Application.persistentDataPath .. "/PhotoAlbum/" + else + DirPath = CS.UnityEngine.Application.persistentDataPath .. "/" + end + end + + function XPhotographManager.InitSharePlatform(list) + if not list then return end + local channelId = 0 -- 默认值 + if XUserManager.Channel == XUserManager.CHANNEL.HERO then + channelId = CS.XHgSdkAgent.GetChannelId() + end + for _,config in pairs(list) do + if config.Id == channelId then + ShareSDKIds = config.SdkId + end + end + end + + function XPhotographManager.HandlerPhotoLoginData(data) + CurSceneId = data.UseBackgroundId + CurSelectSceneId = CurSceneId + local haveSceneIds = data.HaveBackgroundIds + HasSceneIdDic = {} + for _, id in pairs(haveSceneIds) do + HasSceneIdDic[id] = id + end + XPhotographManager.SortSceneIdList() -- 场景列表排序 + XPhotographManager.InitCharacterList() -- 网络数据下发时可以初始化一下角色数据列表 避免获取时再初始化 + end + + function XPhotographManager.HandlerAddPhotoScene(data) + HasSceneIdDic[data.BackgroundId] = data.BackgroundId + XPhotographManager.SortSceneIdList() + end + + function XPhotographManager.GetSceneIdList() + XPhotographManager.InitSceneIdListInTime() + return SceneIdListInTime + end + + function XPhotographManager.InitSceneIdListInTime() + local nowTimeStamp = XTime.GetServerNowTimestamp() + SceneIdListInTime = {} + for _, id in ipairs(SceneIdList) do + local timeStr = XPhotographManager.GetSceneTemplateById(id).ShowStr + if not timeStr or timeStr == "" then + tableInsert(SceneIdListInTime, id) + else + if XTime.ParseToTimestamp(timeStr) <= nowTimeStamp then + tableInsert(SceneIdListInTime, id) + end + end + end + end + + function XPhotographManager.SortSceneIdList() + tableSort(SceneIdList, function(idA, idB) + if idA ~= CurSelectSceneId and idB ~= CurSelectSceneId then + local isSceneAHave = XPhotographManager.CheckSceneIsHaveById(idA) + local isSceneBHave = XPhotographManager.CheckSceneIsHaveById(idB) + if isSceneAHave == isSceneBHave then + local priorityA = XPhotographManager.GetSceneTemplateById(idA).Priority + local priorityB = XPhotographManager.GetSceneTemplateById(idB).Priority + if priorityA == priorityB then + return idA < idB + else + return priorityA > priorityB + end + else + return isSceneAHave + end + else + return idA == CurSelectSceneId + end + end) + end + + function XPhotographManager.GetSceneIdByIndex(index) + if not SceneIdListInTime or #SceneIdListInTime <= 0 then + XPhotographManager.InitSceneIdListInTime() + end + + return SceneIdListInTime[index] + end + + function XPhotographManager.GetSceneTemplateById(id) + return XPhotographConfigs.GetSceneTemplateById(id) + end + + function XPhotographManager.InitCharacterList() + local allCharDatas = XDataCenter.CharacterManager.GetCharacterList() + local curAssistantId = XDataCenter.DisplayManager.GetDisplayChar().Id + + OwnCharDatas = {} + for _, v in pairs(allCharDatas or {}) do + local characterId = v.Id + local isOwn = XDataCenter.CharacterManager.IsOwnCharacter(characterId) + if isOwn then + local name = XCharacterConfigs.GetCharacterName(characterId) + local tradeName = XCharacterConfigs.GetCharacterTradeName(characterId) + local logName = XCharacterConfigs.GetCharacterLogName(characterId) + local enName = XCharacterConfigs.GetCharacterEnName(characterId) + + tableInsert(OwnCharDatas, { + Id = characterId, + Name = name, + TradeName = tradeName, + LogName = logName, + EnName = enName, + TrustLv = v.TrustLv or 1, + Selected = (curAssistantId == characterId), + }) + OwnCharDatasDic[characterId] = { + Name = name, + TradeName = tradeName, + LogName = logName, + EnName = enName, + TrustLv = v.TrustLv or 1, + } + end + end + tableSort(OwnCharDatas, function(dataA, dataB) + if dataA.TrustLv == dataB.TrustLv then + return dataA.Id < dataB.Id + else + return dataA.TrustLv > dataB.TrustLv + end + end) + end + + function XPhotographManager.GetCharacterList() + if not OwnCharDatas or #OwnCharDatas <= 0 then + XPhotographManager.InitCharacterList() + end + + if not OwnCharDatas or #OwnCharDatas <= 0 then + return nil + end + + return OwnCharDatas + end + + function XPhotographManager.GetCharacterDataByIndex(index) + if not OwnCharDatas or #OwnCharDatas <= 0 then + XPhotographManager.InitCharacterList() + end + + if not OwnCharDatas or #OwnCharDatas <= 0 then + return nil + end + + return OwnCharDatas[index] + end + + function XPhotographManager.GetCharacterDataById(id) + if not OwnCharDatasDic then + return nil + end + + return OwnCharDatasDic[id] + end + + function XPhotographManager.CheckSceneIsHaveById(id) + if HasSceneIdDic and HasSceneIdDic[id] then + return true + else + return false + end + end + + function XPhotographManager.GetCurSceneId() + return CurSceneId + end + + function XPhotographManager.GetSceneIndexById(sceneId) + if not SceneIdListInTime or #SceneIdListInTime <= 0 then + XPhotographManager.InitSceneIdListInTime() + end + + for index, id in ipairs(SceneIdListInTime) do + if sceneId == id then + return index + end + end + + return nil + end + + function XPhotographManager.GetCharIndexById(charId) + for index, data in ipairs(OwnCharDatas) do + if charId == data.Id then + return index + end + end + + return nil + end + + function XPhotographManager.GetFashionIndexByFashionList(charId, fashionList) + local curFashionId = XDataCenter.FashionManager.GetFashionIdByCharId(charId) + for index, fashionId in ipairs(fashionList) do + if curFashionId == fashionId then + return index + end + end + + return nil + end + + function XPhotographManager.SharePhoto(photoName, texture, platformType) + if not photoName or not texture then + return + end + + local writeDesc = CS.XTextManager.GetText("PremissionWriteDesc") + XPermissionManager.TryGetPermission(CS.XPermissionEnum.WRITE_EXTERNAL_STORAGE, writeDesc, function(isWriteGranted, dontTip) + if not isWriteGranted then + XUiManager.TipText("PremissionDesc", XUiManager.UiTipType.Tip) + XLog.Debug("获取权限错误_NotisWriteGranted") + return + end + + if not XPhotographManager.IsInTextureCache(photoName) then + CS.XTool.SavePhotoAlbumImg(photoName, texture, function(errorCode) + if errorCode > 0 then + XUiManager.TipText("PremissionDesc", XUiManager.UiTipType.Tip) -- ios granted总是true, 权限未开通code返回1 + XLog.Debug("照片保存失败 Code:"..errorCode) + return + end + XPhotographManager.SetTextureCache(photoName) + XPhotographManager.DoShare(photoName, platformType) + end) + else + XPhotographManager.DoShare(photoName, platformType) + end + end) + end + + function XPhotographManager.DoShare(photoName, platformType) + if platformType == XPlatformShareConfigs.PlatformType.Local then -- 本地保存 + XUiManager.TipText("PhotoModeSaveSuccess", XUiManager.UiTipType.Tip) + else + local cfg = XPhotographConfigs.GetShareInfoByType(platformType) + local fileFullPath = string.format("%s%s%s", DirPath, photoName, ".png") + -- XLog.Debug("fileFullPath", fileFullPath, "cfg.Text", cfg.Text, "platformType", platformType, "XPlatformShareConfigs.ShareType.Image", XPlatformShareConfigs.ShareType.Image, "XPhotographManager.ShareCallback", XPhotographManager.ShareCallback) + XPlatformShareManager.Share(XPlatformShareConfigs.ShareType.Image, platformType, XPhotographManager.ShareCallback, fileFullPath, cfg.Text, cfg.Param[1], cfg.Param[2], false) + XNetwork.Send(PHOTOGRAPH_PROTO.ShareBackgroundRequest, {}) + end + end + + function XPhotographManager.ShareCallback(result) + -- XLog.Debug("ShareCallback result:", result) + if result == XPlatformShareConfigs.ShareResult.Successful then + XUiManager.TipText("PhotoModeShareSuccess", XUiManager.UiTipType.Tip) + elseif result == XPlatformShareConfigs.ShareResult.Canceled then + XUiManager.TipText("PhotoModeShareCancel", XUiManager.UiTipType.Tip) + elseif result == XPlatformShareConfigs.ShareResult.Failed then + XUiManager.TipText("PhotoModeShareFailed", XUiManager.UiTipType.Tip) + end + end + + function XPhotographManager.SetTextureCache(photoName) + tableInsert(TextureCache, photoName) + end + + function XPhotographManager.IsInTextureCache(photoName) + for i = #TextureCache, 1, -1 do + if TextureCache[i] == photoName then + return true + end + end + + return false + end + + function XPhotographManager.ClearTextureCache() + if XUserManager.Platform == XUserManager.PLATFORM.IOS then + if next(TextureCache) then + for _, textureName in pairs(TextureCache) do + local fileFullPath = string.format("%s%s%s", DirPath, textureName, ".png") + CS.XTool.DeleteFile(fileFullPath) + end + end + end + TextureCache = {} + end + + function XPhotographManager.ChangeDisplay(sceneId, charId, fashionId, cb) + if not XPhotographManager.CheckSceneIsHaveById(sceneId) then -- 场景未拥有 + XUiManager.TipError(CSTextManagerGetText("PhotoModeChangeFailedNotHasBackground")) + return + end + + if not XDataCenter.CharacterManager.IsOwnCharacter(charId) then -- 角色未拥有 + XUiManager.TipError(CSTextManagerGetText("PhotoModeChangeFailedNotHasCharacter")) + return + end + + if not XDataCenter.FashionManager.CheckHasFashion(fashionId) then -- 涂装未拥有 + XUiManager.TipError(CSTextManagerGetText("PhotoModeChangeFailedNotHasFashion")) + return + end + + XNetwork.Call(PHOTOGRAPH_PROTO.ChangeDisplayRequest, { BackgroundId = sceneId, CharId = charId, FashionId = fashionId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + CurSceneId = sceneId + XPhotographManager.SortSceneIdList() + + local curDisplayCharId = XDataCenter.DisplayManager.GetDisplayChar().Id + if curDisplayCharId ~= charId then + XDataCenter.SignBoardManager.ChangeDisplayCharacter(charId) + end + XDataCenter.DisplayManager.SetDisplayCharByCharacterId(charId) + XPlayer.SetDisplayCharId(charId) + + XUiManager.TipMsg(CSTextManagerGetText("PhotoModeChangeSuccess")) + if cb then + cb() + end + end) + end + + function XPhotographManager.GetShareSDKIds() + return ShareSDKIds + end + + function XPhotographManager.GetShareTypeByIndex(index) + if not ShareSDKIds then + return nil + end + + return ShareSDKIds[index] + end + + function XPhotographManager.SetCurSelectSceneId(SceneId) + local sceneId = SceneId + if not SceneId then + sceneId = CurSceneId + end + CurSelectSceneId = sceneId + XPhotographManager.SortSceneIdList() + end + + function XPhotographManager.GetCurSelectSceneId() + return CurSelectSceneId + end + + function XPhotographManager.SendPhotoGraphRequest() + XNetwork.Send(PHOTOGRAPH_PROTO.PhotoBackgroundRequest, {}) + end + + XPhotographManager.Init() + return XPhotographManager +end + +XRpc.NotifyBackgroundLoginData = function(data) + XDataCenter.PhotographManager.HandlerPhotoLoginData(data) +end + +XRpc.NotifyAddBackground = function(data) + XDataCenter.PhotographManager.HandlerAddPhotoScene(data) +end + +XRpc.NotifySharePlatformConfigList = function (data) + XDataCenter.PhotographManager.InitSharePlatform(data) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XPlatformShareManager.lua b/Resources/Scripts/XManager/XPlatformShareManager.lua new file mode 100644 index 00000000..21c4089d --- /dev/null +++ b/Resources/Scripts/XManager/XPlatformShareManager.lua @@ -0,0 +1,133 @@ + +-- +--Author: wujie +--Note: 平台分享操作管理 + +local CSXHeroShareAgent = CS.XHeroShareAgent + +XPlatformShareManager = XPlatformShareManager or {} + +-- CS.XHeroShareAgent.Share方法中的isEmbedImage目前不需要,均传false即可 +-- CS.XHeroShareAgent.Share方法中showUi为是否使用sdk自带的渠道分享窗口 + +-- path为必传字符串 +function XPlatformShareManager.ShareImage(platformType, callback, path, text, showUi) + if string.IsNilOrEmpty(path) then + XLog.Error("XPlatformShareManager.ShareImage函数错误,image路径不能为空") + return + end + local targetPlatformType = XPlatformShareConfigs.PlatformTypeToHeroSharePlatform[platformType] + if not targetPlatformType then + XLog.Error("XPlatformShareManager.ShareImage函数错误, platformType不存在,platformType是 " .. platformType) + return + end + + CSXHeroShareAgent.Share( + callback, + showUi or false, + XPlatformShareConfigs.ShareTypeToHeroShareType[XPlatformShareConfigs.ShareType.Image], + targetPlatformType, + text, + false, + path + ) +end + +-- shareLink, shareLinkTitle为必传字符串 +function XPlatformShareManager.ShareLink(platformType, callback, shareLink, shareLinkTitle, shareLinkDesc, imageLink, showUi) + if string.IsNilOrEmpty(shareLink) then + XLog.Error("XPlatformShareManager.ShareLink函数错误, shareLink 分享的链接不能为空") + return + end + if string.IsNilOrEmpty(shareLinkTitle) then + XLog.Error("XPlatformShareManager.ShareLink函数错误, shareLinkTitle 不能为空") + return + end + local targetPlatformType = XPlatformShareConfigs.PlatformTypeToHeroSharePlatform[platformType] + if not targetPlatformType then + XLog.Error("XPlatformShareManager.ShareLink函数错误, platformType不存在,platformType是 " .. platformType) + return + end + + CSXHeroShareAgent.Share( + callback, + showUi or false, + XPlatformShareConfigs.ShareTypeToHeroShareType[XPlatformShareConfigs.ShareType.Link], + targetPlatformType, + nil, + false, + nil, + imageLink, + shareLink, + shareLinkTitle, + shareLinkDesc + ) +end + +-- text为必传字段 +function XPlatformShareManager.ShareText(platformType, callback, text, showUi) + if string.IsNilOrEmpty(text) then + XLog.Error("text is nil Or empty") + return + end + local targetPlatformType = XPlatformShareConfigs.PlatformTypeToHeroSharePlatform[platformType] + if not targetPlatformType then + XLog.Error("platformType not exist, platformType is " .. platformType) + return + end + + if platformType == XPlatformShareConfigs.PlatformType.WeChatTimeline and XUserManager.Platform == XUserManager.PLATFORM.Android then + CSXHeroShareAgent.Share( + callback, + showUi or false, + XPlatformShareConfigs.ShareTypeToHeroShareType[XPlatformShareConfigs.ShareType.Text], + targetPlatformType, + text, + false, + nil, + nil, + nil, + " ", + nil + ) + else + CSXHeroShareAgent.Share( + callback, + showUi or false, + XPlatformShareConfigs.ShareTypeToHeroShareType[XPlatformShareConfigs.ShareType.Text], + targetPlatformType, + text, + false + ) + end +end + + + +--callback 为非必传字段,不一定需要 +function XPlatformShareManager.Share(shareType, platformType, callback, param1, param2, param3, param4, showUi) + if shareType == XPlatformShareConfigs.ShareType.Image then + XPlatformShareManager.ShareImage(platformType, callback, param1, param2, showUi) + elseif shareType == XPlatformShareConfigs.ShareType.Link then + XPlatformShareManager.ShareLink(platformType, callback, param1, param2, param3, param4, showUi) + elseif shareType == XPlatformShareConfigs.ShareType.Text then + XPlatformShareManager.ShareText(platformType, callback, param1, showUi) + else + XLog.Error("XPlatformShareManager.Share 函数错误,不能分享 类型为: " .. shareType .. "的内容") + end +end + +--当分享内容完全依赖表格时可以调用这个接口 +function XPlatformShareManager.ShareByPlatformShareId(platformType, callback, platformShareId, showUi) + local template = XPlatformShareConfigs.GetPlatformShareTemplate(platformShareId) + XPlatformShareManager.Share( + template.ShareType, + platformType, + callback, + template.ShareParam[1], + template.ShareParam[2], + template.ShareParam[3], + template.ShareParam[4], + showUi + ) +end diff --git a/Resources/Scripts/XManager/XPlayerInfoManager.lua b/Resources/Scripts/XManager/XPlayerInfoManager.lua new file mode 100644 index 00000000..88607720 --- /dev/null +++ b/Resources/Scripts/XManager/XPlayerInfoManager.lua @@ -0,0 +1,216 @@ +--查看玩家信息管理器 +XPlayerInfoManagerCreator = function() + local XPlayerInfoManager = {} + + local GET_PLAYER_INFO_INTERVAL = 120 + + --缓存信息 + --结构为 key:playerId value:dataType + --如果dataType为CharacterInfo,则CharacterInfo继续细分 key:characterId value:具体角色信息 + local cache = {} + local cacheTime = {} + + local dataType = { + PlayerInfo = 1, --玩家信息 + PlayerCharacter = 2, --展示的成员列表 + PlayerFashion = 3, --成员涂装 + PlayerWeaponFashion = 4, --武器涂装 + PlayerTitle = 5, --收藏品列表 + CharacterInfo = 6 --成员的详情信息(等级、技能、装备等) + } + + local PlayerInfoRequest = { + RequestPlayerInfo = "QueryPlayerDetailRequest", --获取玩家信息 + RequestPlayerCharacterList = "QueryPlayerCharacterListRequest", --查看玩家成员展示信息 + RequestPlayerFashion = "QueryPlayerFashionRequest", --查看玩家涂装展示信息 + RequestPlayerWeaponFashion = "QueryPlayerWeaponFashionRequest", --查看玩家武器涂装展示信息 + RequestPlayerTitle = "QueryPlayerTitleRequest", --查看玩家收藏品展示信息 + RequestCharacterInfo = "QueryCharacterInfoRequest" --查看成员详情 + } + + --保存展示信息 + function XPlayerInfoManager.SaveData(charactersAppearanceType, characterIds, appearanceSettingInfo, cb) + XPlayer.SetAppearance(charactersAppearanceType, characterIds, appearanceSettingInfo, cb) + end + + local function CanRequest(playerId, type, characterId) + if cache[playerId] == nil then + --没有请求过该玩家的信息 + cache[playerId] = {} + cacheTime[playerId] = {} + return true + else + if cache[playerId][type] then + --缓存着玩家的这个种类的信息 + + if dataType.CharacterInfo == type then + --若是角色详情,判断是否请求过该角色的信息 + if cache[playerId][type][characterId] then + return XTime.GetServerNowTimestamp() - cacheTime[playerId][type][characterId] > GET_PLAYER_INFO_INTERVAL + else + return true + end + end + + return XTime.GetServerNowTimestamp() - cacheTime[playerId][type] > GET_PLAYER_INFO_INTERVAL + else + --该玩家的这个种类的信息没有请求过 + cache[playerId][type] = {} + cacheTime[playerId][type] = {} + return true + end + end + end + + --请求玩家信息 + function XPlayerInfoManager.RequestPlayerInfoData(playerId, cb) + --检查缓存 + if CanRequest(playerId, dataType.PlayerInfo) then + XNetwork.Call(PlayerInfoRequest.RequestPlayerInfo, { PlayerId = playerId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + cache[playerId][dataType.PlayerInfo] = res.Detail + cacheTime[playerId][dataType.PlayerInfo] = XTime.GetServerNowTimestamp() + + if cb then + cb(cache[playerId][dataType.PlayerInfo]) + end + end) + else + if cb then + cb(cache[playerId][dataType.PlayerInfo]) + end + end + end + + -- 请求玩家收藏品展示信息 + function XPlayerInfoManager.RequestPlayerTitleData(playerId, cb) + --检查缓存 + if CanRequest(playerId, dataType.PlayerTitle) then + XNetwork.Call(PlayerInfoRequest.RequestPlayerTitle, { PlayerId = playerId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + cache[playerId][dataType.PlayerTitle].Titles = res.Titles + cache[playerId][dataType.PlayerTitle].Walls = res.Walls + cacheTime[playerId][dataType.PlayerTitle] = XTime.GetServerNowTimestamp() + + if cb then + cb(cache[playerId][dataType.PlayerTitle]) + end + end) + else + if cb then + cb(cache[playerId][dataType.PlayerTitle]) + end + end + end + + -- 请求玩家成员展示信息 + function XPlayerInfoManager.RequestPlayerCharacterListData(playerId, cb) + --检查缓存 + if CanRequest(playerId, dataType.PlayerCharacter) then + XNetwork.Call(PlayerInfoRequest.RequestPlayerCharacterList, { PlayerId = playerId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + cache[playerId][dataType.PlayerCharacter] = res.CharacterShows + cacheTime[playerId][dataType.PlayerCharacter] = XTime.GetServerNowTimestamp() + + if cb then + cb(cache[playerId][dataType.PlayerCharacter]) + end + end) + else + if cb then + cb(cache[playerId][dataType.PlayerCharacter]) + end + end + + end + + -- 请求玩家涂装展示信息 + function XPlayerInfoManager.RequestPlayerFashionData(playerId, cb) + --检查缓存 + if CanRequest(playerId, dataType.PlayerFashion) then + XNetwork.Call(PlayerInfoRequest.RequestPlayerFashion, { PlayerId = playerId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + cache[playerId][dataType.PlayerFashion] = res.Fashions + cacheTime[playerId][dataType.PlayerFashion] = XTime.GetServerNowTimestamp() + + if cb then + cb(cache[playerId][dataType.PlayerFashion]) + end + end) + else + if cb then + cb(cache[playerId][dataType.PlayerFashion]) + end + end + end + + -- 请求玩家武器涂装展示信息 + function XPlayerInfoManager.RequestPlayerWeaponFashionData(playerId, cb) + --检查缓存 + if CanRequest(playerId, dataType.PlayerWeaponFashion) then + XNetwork.Call(PlayerInfoRequest.RequestPlayerWeaponFashion, { PlayerId = playerId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + cache[playerId][dataType.PlayerWeaponFashion] = res.WeaponFashions + cacheTime[playerId][dataType.PlayerWeaponFashion] = XTime.GetServerNowTimestamp() + + if cb then + cb(cache[playerId][dataType.PlayerWeaponFashion]) + end + end) + else + if cb then + cb(cache[playerId][dataType.PlayerWeaponFashion]) + end + end + end + + -- 请求角色详情 + function XPlayerInfoManager.RequestCharacterInfoData(playerId, characterId, cb) + --检查缓存 + if CanRequest(playerId, dataType.CharacterInfo, characterId) then + XNetwork.Call(PlayerInfoRequest.RequestCharacterInfo, { PlayerId = playerId, CharacterId = characterId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + local characterInofo = { CharacterData = res.CharacterData + , EquipData = res.EquipData + , PartnerData = res.PartnerData + , WeaponFashionId = res.WeaponFashionId + , AssignChapterRecords = res.AssignChapterRecords + , IsSelfData = playerId == XPlayer.Id } -- 设置是否为属于玩家和非玩家(好友)标志 + cache[playerId][dataType.CharacterInfo][characterId] = characterInofo + cacheTime[playerId][dataType.CharacterInfo][characterId] = XTime.GetServerNowTimestamp() + + if cb then + cb(cache[playerId][dataType.CharacterInfo][characterId]) + end + end) + else + if cb then + cb(cache[playerId][dataType.CharacterInfo][characterId]) + end + end + end + + return XPlayerInfoManager +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XPlayerManager.lua b/Resources/Scripts/XManager/XPlayerManager.lua new file mode 100644 index 00000000..6357235a --- /dev/null +++ b/Resources/Scripts/XManager/XPlayerManager.lua @@ -0,0 +1,118 @@ +--[[ + 说明:等级现在分普通等级和荣耀等级(当普通等级达到120会转为荣耀等级),使用下面的方法注意区分等级类型,在此对参数作统一说明 + --@level:等级可以是默认的普通等级或荣耀等级,等级是荣耀等级@isHonor必须传true + --@isHonor: 是否使用荣耀勋阶的表,true(使用荣耀表),否则使用默认的等级表 +]] + +XPlayerManager = XPlayerManager or {} + +local TABLE_PLAYER = "Share/Player/Player.tab" +local TABLE_HONORLEVEL = "Share/Player/HonorLevel.tab" +local PlayerTable +local HonorLevelTable + +XPlayerManager.PlayerChangeNameInterval = CS.XGame.Config:GetInt("PlayerChangeNameInterval") +XPlayerManager.PlayerMaxLevel = CS.XGame.Config:GetInt("PlayerMaxLevel") + +function XPlayerManager.Init() + PlayerTable = XTableManager.ReadByIntKey(TABLE_PLAYER, XTable.XTablePlayer, "Level") + HonorLevelTable = XTableManager.ReadByIntKey(TABLE_HONORLEVEL, XTable.XTableHonorLevel, "HonorLevel") + + if not PlayerTable then + XLog.Error("读取Player Table发生错误 表的路径是: " .. TABLE_PLAYER) + end + if not HonorLevelTable then + XLog.Error("读取HonorLevel Table发生错误 表的路径是: " .. TABLE_HONORLEVEL) + end +end + +local function GetTableByLevel(level, isHonor, functionName) + local table + + if isHonor then + table = HonorLevelTable + else + table = PlayerTable + end + + if not table[level] then + --注意阅读上面的参数说明 + if isHonor then + XLog.ErrorTableDataNotFound("XPlayerManager." .. functionName, "HonorLevelTable", TABLE_HONORLEVEL, "HonorLevel", tostring(level)) + else + XLog.ErrorTableDataNotFound("XPlayerManager." .. functionName, "PlayerTable", TABLE_PLAYER, "level", tostring(level)) + end + else + return table[level] + end +end + +function XPlayerManager.GetMaxExp(level, isHonor) + local maxExp = 0 + local table = GetTableByLevel(level, isHonor, "GetMaxExp") + if table then + maxExp = table.MaxExp + end + return maxExp +end + +function XPlayerManager.GetMaxActionPoint(level, isHonor) + local maxActp = 0 + local table = GetTableByLevel(level, isHonor, "GetMaxActionPoint") + if table then + maxActp = table.MaxActionPoint + end + return maxActp +end + +function XPlayerManager.GetMaxFriendCount(level, isHonor) + local maxCount = 0 + local table = GetTableByLevel(level, isHonor, "GetMaxFriendCount") + if table then + maxCount = table.MaxFriendCount + end + return maxCount +end + +--注意:荣誉等级没有FreeActionPoint字段 +function XPlayerManager.GetFreeActionPoint(level) + local freeActp = 0 + local table = GetTableByLevel(level, false, "GetFreeActionPoint") + if table then + freeActp = table.FreeActionPoint + end + return freeActp +end + +function XPlayerManager.GetRewardId(level) + local RewardId = 0 + local table = GetTableByLevel(level, true, "RewardId") + if table then + RewardId = table.RewardId + end + return RewardId +end + +function XPlayerManager.GetHeadPortraitInfoById(id) + return XDataCenter.HeadPortraitManager.GetHeadPortraitInfoById(id) +end + +--==============================-- +--desc: 获取玩家信息 +--@id: 玩家id +--@cb: 结果回调 +--==============================-- +function XPlayerManager.GetPlayerInfos(id, cb) + local req = { id = id } + XNetwork.Call("GetPlayerInfoRequest", req, + function(result) + if result.Code and result.Code ~= XCode.Success then + XUiManager.TipCode(result.Code) + return + end + if cb then + cb(result.Code, result.PlayerData) + end + end + ) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XPokemonManager.lua b/Resources/Scripts/XManager/XPokemonManager.lua new file mode 100644 index 00000000..51803b73 --- /dev/null +++ b/Resources/Scripts/XManager/XPokemonManager.lua @@ -0,0 +1,1003 @@ +local XPokemonMonster = require("XEntity/XPokemon/XPokemonMonster") +local XPokemonTeamPosData = require("XEntity/XPokemon/XPokemonTeamPosData") +local NORMAL_SPEED = 1 +local DOUBLE_SPEED = 2 +XPokemonManagerCreator = function() + local tableInsert = table.insert + local pairs = pairs + local tonumber = tonumber + + local XPokemonManager = {} + function XPokemonManager.GetSpeedUpSaveKey() + return string.format("%s_%s","PokemonSpeedUp",XPlayer.Id) + end + + function XPokemonManager.IsSpeedUp() + return XSaveTool.GetData(XPokemonManager.GetSpeedUpSaveKey()) == 1 + end + + function XPokemonManager.SetSpeedUp(isSpeedUp) + if isSpeedUp then + XSaveTool.SaveData(XPokemonManager.GetSpeedUpSaveKey(),1) + else + XSaveTool.SaveData(XPokemonManager.GetSpeedUpSaveKey(),0) + end + end + + function XPokemonManager.ChangeSpeed() + CS.UnityEngine.Time.timeScale = DOUBLE_SPEED + end + + function XPokemonManager.ResetSpeed() + if CS.UnityEngine.Time.timeScale ~= NORMAL_SPEED then + CS.UnityEngine.Time.timeScale = NORMAL_SPEED + end + end + + function XPokemonManager.CloseFightLoading() + XDataCenter.FubenManager.CloseFightLoading() + if XPokemonManager.IsSpeedUp() then + XPokemonManager.ChangeSpeed() + end + end + + function XPokemonManager.CallFinishFight() + XPokemonManager.ResetSpeed() + XDataCenter.FubenManager.CallFinishFight() + end + + -----------------怪物相关 begin---------------- + local _Monsters = {} + local _NewMonsterIds = {} + + local function GetMonster(monsterId) + return _Monsters[monsterId] + end + + local function UpdateMonster(data, checkNew) + if not data then return end + + local monsterId = data.Id + + local monster = GetMonster(monsterId) + if not monster then + monster = XPokemonMonster.New(monsterId) + _Monsters[monsterId] = monster + local newMonsterId = checkNew and monsterId + if newMonsterId then + tableInsert(_NewMonsterIds, newMonsterId) + end + end + + monster:UpdateData(data) + end + + local function UpdateMonsters(datas, checkNew) + if not datas then return end + + for _, data in pairs(datas) do + UpdateMonster(data, checkNew) + end + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_POKEMON_MONSTERS_DATA_CHANGE) + end + + function XPokemonManager.NotifyPokemonMonster(data) + UpdateMonsters(data.MonsterList, true) + end + + function XPokemonManager.CheckNewMonsterIds() + if XTool.IsTableEmpty(_NewMonsterIds) then return end + + local monsterIds = XTool.Clone(_NewMonsterIds) + XLuaUiManager.Open("UiPokemonMonsterObtain", monsterIds) + + _NewMonsterIds = {} + end + + function XPokemonManager.GetOwnMonsterIds(monsterType) + local monsterIdList = {} + for monsterId in pairs(_Monsters) do + if monsterType then + if XPokemonConfigs.CheckMonsterType(monsterId, monsterType) then + tableInsert(monsterIdList, monsterId) + end + else + tableInsert(monsterIdList, monsterId) + end + end + return monsterIdList + end + + function XPokemonManager.GetOwnMonsterIdsByCareer(career) + local monsterIdList = {} + for monsterId in pairs(_Monsters) do + if career then + if XPokemonConfigs.CheckMonsterCareer(monsterId, career) then + tableInsert(monsterIdList, monsterId) + end + else + tableInsert(monsterIdList, monsterId) + end + end + return monsterIdList + end + + function XPokemonManager.CheckOwnMonsterEmptyByCareer(career) + local isEmpty = true + for monsterId in pairs(_Monsters) do + if career then + if XPokemonConfigs.CheckMonsterCareer(monsterId, career) then + isEmpty = false + break + end + else + isEmpty = false + break + end + end + + return isEmpty + end + + function XPokemonManager.CheckBagMonsterEmptyByCareer(career) + local isEmpty = true + local teamMonsterDic = XPokemonManager.GetTeamMonstersIdDic() + for monsterId in pairs(_Monsters) do + if career then + if XPokemonConfigs.CheckMonsterCareer(monsterId, career) and not teamMonsterDic[monsterId] then + isEmpty = false + break + end + else + isEmpty = false + break + end + end + + return isEmpty + end + + function XPokemonManager.CheckOwnMonsterEmpty(monsterType) + local isEmpty = true + for monsterId in pairs(_Monsters) do + if monsterType then + if XPokemonConfigs.CheckMonsterType(monsterId, monsterType) then + isEmpty = false + break + end + else + isEmpty = false + break + end + end + return isEmpty + end + + function XPokemonManager.CheckBagMonsterEmpty(monsterType) + local isEmpty = true + local teamMonsterDic = XPokemonManager.GetTeamMonstersIdDic() + for monsterId in pairs(_Monsters) do + if monsterType then + if XPokemonConfigs.CheckMonsterType(monsterId, monsterType) and not teamMonsterDic[monsterId] then + isEmpty = false + break + end + else + isEmpty = false + break + end + end + return isEmpty + end + + function XPokemonManager.GetMonsterStar(monsterId) + local monster = GetMonster(monsterId) + return monster and monster:GetStar() or 0 + end + + function XPokemonManager.GetMonsterLevel(monsterId) + local monster = GetMonster(monsterId) + return monster and monster:GetLevel() or 0 + end + + function XPokemonManager.GetMonsterAbility(monsterId) + local monster = GetMonster(monsterId) + return monster and monster:GetAbility() or 0 + end + + function XPokemonManager.GetMonsterHp(monsterId) + local monster = GetMonster(monsterId) + return monster and monster:GetHp() or 0 + end + + function XPokemonManager.GetMonsterAttack(monsterId) + local monster = GetMonster(monsterId) + return monster and monster:GetAttack() or 0 + end + + --获取升级后预览属性 + ---@param 预览等级 + ---@return 生命, 攻击 + function XPokemonManager.GetMonsterPreHpAndPreAttack(monsterId, preLevel) + local monster = GetMonster(monsterId) + if not monster then + return 0, 0 + end + return monster:GetPreHpAndPreAttack(preLevel) + end + + function XPokemonManager.IsMonsterMaxLevel(monsterId) + local monster = GetMonster(monsterId) + return monster and monster:IsMaxLevel() or false + end + + function XPokemonManager.GetMonsterMaxLevel(monsterId) + local monster = GetMonster(monsterId) + return monster and monster:GetMaxLevel() or 0 + end + + function XPokemonManager.IsMonsterMaxStar(monsterId) + local monster = GetMonster(monsterId) + return monster and monster:IsMaxStar() or false + end + + function XPokemonManager.GetMonsterLevelUpCostItemInfo(monsterId) + local monster = GetMonster(monsterId) + if not monster then + return XPokemonConfigs.GetMonsterLevelCostItemInfo(monsterId, 1) + end + return monster:GetLevelUpCostItemInfo() + end + + function XPokemonManager.GetMonsterStarUpCostItemInfo(monsterId) + local monster = GetMonster(monsterId) + if not monster then + return XPokemonConfigs.GetMonsterStarCostItemInfo(monsterId, 1) + end + return monster:GetStarUpCostItemInfo() + end + + function XPokemonManager.GetMonsterUsingSkillIdList(monsterId) + local monster = GetMonster(monsterId) + return monster and monster:GetUsingSkillIdList() or {} + end + + function XPokemonManager.GetMonsterCanSwitchSkillIdList(monsterId, skillId) + local monster = GetMonster(monsterId) + return monster and monster:GetCanSwitchSkillIds(skillId) or {} + end + + function XPokemonManager.IsMonsterSkillUnlock(monsterId, skillId) + local monster = GetMonster(monsterId) + return monster and monster:IsSkillUnlock(skillId) or false + end + + function XPokemonManager.IsMonsterSkillUsing(monsterId, skillId) + local monster = GetMonster(monsterId) + return monster and monster:IsSkillUsing(skillId) or false + end + + function XPokemonManager.IsMonsterSkillCanSwitch(monsterId, skillId) + local monster = GetMonster(monsterId) + return monster and monster:IsSkillCanSwitch(skillId) or false + end + + --获取该星级可解锁技能Id列表 + function XPokemonManager.GetMonsterStarUnlockSkillIds(monsterId, star) + local monster = GetMonster(monsterId) + return monster and monster:GetStarUnlockSkillIds(star) or {} + end + + --获取当前拥有道具足够升级的最大次数 + function XPokemonManager.GetMonsterCanLevelUpTimes(monsterId) + local times = 0 + local costItemDic = {} + + local bagItemDic = {} + local curLevel = XPokemonManager.GetMonsterLevel(monsterId) + local maxLevel = XPokemonManager.GetMonsterMaxLevel(monsterId) + for level = curLevel, maxLevel - 1 do + + local costItemId, costItemCount = XPokemonConfigs.GetMonsterLevelCostItemInfo(monsterId, level) + local haveItemCount = bagItemDic[costItemId] or XDataCenter.ItemManager.GetCount(costItemId) + + haveItemCount = haveItemCount - costItemCount + if haveItemCount < 0 then + break + end + + bagItemDic[costItemId] = haveItemCount + costItemDic[costItemId] = costItemDic[costItemId] and costItemDic[costItemId] + costItemCount or costItemCount + times = times + 1 + + end + + return times, costItemDic + end + + function XPokemonManager.OpenMonsterUi() + if XDataCenter.PokemonManager.CheckOwnMonsterEmpty() then + XLog.Error("XPokemonManager.OpenMonsterUi error: 尚未获得怪物,不能打开怪物培养UI") + return + end + XLuaUiManager.Open("UiPokemonMonster") + end + + --怪物升级 + function XPokemonManager.PokemonLevelUpRequest(monsterId, times, cb) + times = times or 1 + local req = { MonsterId = monsterId, Times = times } + XNetwork.Call("PokemonLevelUpRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local monster = GetMonster(monsterId) + monster:UpLevel(times) + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_POKEMON_MONSTERS_LEVEL_UP) + XEventManager.DispatchEvent(XEventId.EVENT_POKEMON_MONSTERS_LEVEL_UP, monsterId) + + if cb then cb() end + end) + end + + --怪物升星 + function XPokemonManager.PokemonStarUpRequest(monsterId, cb) + local req = { MonsterId = monsterId } + XNetwork.Call("PokemonStarUpRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local monster = GetMonster(monsterId) + local addStar = 1 + monster:UpStar(addStar) + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_POKEMON_MONSTERS_STAR_UP) + XEventManager.DispatchEvent(XEventId.EVENT_POKEMON_MONSTERS_STAR_UP, monsterId) + + if cb then cb() end + end) + end + + --怪物技能切换 + function XPokemonManager.PokemonSetSkillRequest(monsterId, skillId, cb) + local req = { MonsterId = monsterId, SkillId = skillId } + XNetwork.Call("PokemonSetSkillRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local monster = GetMonster(monsterId) + monster:SwitchSkill(skillId) + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_POKEMON_MONSTERS_SKILL_SWITCH) + + if cb then cb() end + end) + end + + function XPokemonManager.PokemonResetUpgradeRequest(monsterId,cb) + local req = {MonsterId = monsterId} + local monster = _Monsters[monsterId] + if monster then + monster:InitSkillGroups() + end + XNetwork.Call("PokemonResetUpgradeRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_POKEMON_MONSTERS_DATA_CHANGE) + + if cb then cb(res.RewardGoods) end + end) + end + -----------------怪物相关 end---------------- + -----------------队伍相关 begin---------------- + local _MaxEnergy = 0 + local _Team = {} + local TEAM_MEMBER_NUM = XPokemonConfigs.TeamNum + local _RandomMonsterList = {} + local _RandomStageId = 1 + + local function GetTeamPosData(pos) + return _Team[pos] + end + + local function UpdateRandomMonsterData(randomStageData) + if not randomStageData then return end + _RandomMonsterList = {} + _RandomStageId = randomStageData.StageId + for _, npcGroupList in pairs(randomStageData.NpcGroupList) do + if not npcGroupList.NpcList then break end + for _, npcInfo in pairs(npcGroupList.NpcList) do + table.insert(_RandomMonsterList, XPokemonConfigs.GetMonsterIdByNpcId(npcInfo.Id)) + end + end + end + + local function UpdateMaxEnergy(maxEnergy) + _MaxEnergy = maxEnergy or _MaxEnergy + end + + local function UpdateUnlockedPositionList(unlockedPositionList) + if not unlockedPositionList then return end + for _, pos in pairs(unlockedPositionList) do + local posData = GetTeamPosData(pos) + posData:Unlock() + end + end + + local function UpdateTeam(mosnterIdDic) + if not mosnterIdDic then return end + for pos, monsterId in pairs(mosnterIdDic) do + local posData = GetTeamPosData(pos) + posData:SetMonsterId(monsterId) + end + end + + function XPokemonManager.InitTeam() + _Team = {} + for pos = 1, TEAM_MEMBER_NUM do + _Team[pos] = XPokemonTeamPosData.New(pos) + end + end + + function XPokemonManager.IsTeamPosLock(pos) + local posData = GetTeamPosData(pos) + return posData and posData:IsLock() + end + + function XPokemonManager.GetTeamMonsterIds() + local monsterIds = {} + + for pos = 1, TEAM_MEMBER_NUM do + local posData = GetTeamPosData(pos) + local monsterId = posData and posData:GetMonsterId() or 0 + monsterIds[pos] = monsterId + end + + return monsterIds + end + + function XPokemonManager.GetTeamMonstersIdDic() + local monstersIdDic = {} + for _, v in pairs(_Team) do + monstersIdDic[v:GetMonsterId()] = v:GetMonsterId() + end + return monstersIdDic + end + + function XPokemonManager.CheckMonsterIsInTeam(monsterId) + local monsterDic = XPokemonManager.GetTeamMonstersIdDic() + local monster = monsterDic[monsterId] or 0 + return monster > 0 + end + + function XPokemonManager.NotifyPokemonUnlock(data) + UpdateMaxEnergy(data.MaxEnergy) + UpdateUnlockedPositionList(data.UnlockedPositionList) + UpdateRandomMonsterData(data.RandomStageData) + end + + function XPokemonManager.GetMaxEnergy() + return _MaxEnergy + end + + function XPokemonManager.GetRandomMonsters() + return _RandomMonsterList or {} + end + + function XPokemonManager.GetRandomStageId() + return _RandomStageId + end + + + --队伍信息同步 + function XPokemonManager.PokemonSetFormationRequest(monsterIdList, cb) + local req = { MonsterIdList = monsterIdList } + XNetwork.Call("PokemonSetFormationRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + UpdateTeam(monsterIdList) + + if cb then cb() end + end) + end + -----------------队伍相关 end---------------- + -----------------章节相关 begin-------------- + function XPokemonManager.GetChapters() + return XPokemonConfigs.GetChapters(XPokemonManager.GetCurrActivityId()) + end + + function XPokemonManager.GetSelectChapterName() + return XPokemonConfigs.GetChapterName(XPokemonManager.GetSelectChapter()) + end + + function XPokemonManager.GetSelectChapterDesc() + return XPokemonConfigs.GetChapterDesc(XPokemonManager.GetSelectChapter()) + end + + function XPokemonManager.GetSelectChapterType() + return XPokemonConfigs.GetChapterType(XPokemonManager.GetSelectChapter()) + end + + function XPokemonManager.GetSelectChapterTitleImage() + return XPokemonConfigs.GetChapterTitleImage(XPokemonManager.GetSelectChapter()) + end + + function XPokemonManager.GetChapterScrollBg() + return XPokemonConfigs.GetChapterScrollBg(XPokemonManager.GetSelectChapter()) + end + -----------------章节相关 end---------------- + -----------------关卡相关 begin---------------- + local _PassedStageDic = {} + local _SkipStageInfo = {} + local _RemainingTimes = XPokemonConfigs.GetDefaultStageTimes() + local _IsSwitchToInfinity = false + local _NextRecoverTime = 0 + local _StageSkipTimes = 0 + local _SelectChapter = 31 + + local function UpdateStageSkipTimes(data) + if not data then return end + _StageSkipTimes = data + end + + function XPokemonManager.GetStageSkipTimes() + return _StageSkipTimes + end + + function XPokemonManager.CheckCanSkip() + return _StageSkipTimes > 0 + end + + local function UpdateSkipStageInfo(data) + if not data then return end + _SkipStageInfo = data + end + + function XPokemonManager.GetSkipStageInfo() + return _SkipStageInfo + end + + function XPokemonManager.CheckIsSkip(stageId) + for _,skipId in ipairs(_SkipStageInfo) do + if skipId == stageId then + return true + end + end + return false + end + + local function UpdateNextRecoverTime(time) + _NextRecoverTime = time or 0 + end + + function XPokemonManager.GetNextRecoverTime() + return _NextRecoverTime + end + + function XPokemonManager.SetSelectChapter(data) + local chapters = XPokemonManager.GetChapters() + _SelectChapter = chapters[data].Id + end + + function XPokemonManager.GetSelectChapter() + return _SelectChapter + end + + local function UpdatePassedStage(data) + data = data or {} + for i = 1, #data do + local value = data[i] + if not _PassedStageDic[value] then + _PassedStageDic[value] = value + end + end + end + + local function UpdateRemainingTimes(times) + if not times then return end + _RemainingTimes = times + CsXGameEventManager.Instance:Notify(XEventId.EVENT_POKEMON_REMAINING_TIMES_CHANGE) + end + + function XPokemonManager.GetIsSwitchToInfinity() + return _IsSwitchToInfinity + end + + function XPokemonManager.SetIsSwitchToInfinity(v) + _IsSwitchToInfinity = v + end + + function XPokemonManager.NotifyPokemonStagePassed(data) + if data and data.StageId then + _PassedStageDic[data.StageId] = data.StageId + --if XPokemonManager.GetPassedCount() == XPokemonManager.GetStageCountByType(XPokemonConfigs.StageType.Normal) then + -- XPokemonManager.SetIsSwitchToInfinity(true) + --end + CsXGameEventManager.Instance:Notify(XEventId.EVENT_POKEMON_PASSED_STAGE_CHANGE) + end + end + + function XPokemonManager.NotifyPokemonRemainingTimesChange(data) + if not data then return end + _RemainingTimes = data.StageTimes or _RemainingTimes + _NextRecoverTime = data.StageTimesNextRecoverTime or 0 + CsXGameEventManager.Instance:Notify(XEventId.EVENT_POKEMON_REMAINING_TIMES_CHANGE) + end + + function XPokemonManager.CheckStageIsPassed(stageId) + return _PassedStageDic[stageId] and true + end + + function XPokemonManager.GetPassedCount() + local count = 0 + for k, v in pairs(_PassedStageDic) do + count = count + 1 + end + return count + end + + function XPokemonManager.GetPassedCountByChapterId(chapterId) + local count = 0 + for k, v in pairs(_PassedStageDic) do + local cId = XPokemonConfigs.GetStageChapterIdByFightStageId(XDataCenter.PokemonManager.GetCurrActivityId(),k) + if cId == chapterId then + count = count + 1 + end + end + for _,fightStageId in pairs(_SkipStageInfo) do + local cId = XPokemonConfigs.GetStageChapterIdByFightStageId(XDataCenter.PokemonManager.GetCurrActivityId(),fightStageId) + if cId == chapterId then + count = count + 1 + end + end + return count + end + + function XPokemonManager.GetNextStage() + local nextIndex = XPokemonManager.GetPassedCount() + 1 + local totalCount = XPokemonManager.GetStageCountByType(XPokemonConfigs.StageType.Normal) + XPokemonManager.GetStageCountByType(XPokemonConfigs.StageType.Skip) + nextIndex = XMath.Clamp(nextIndex, 1, totalCount) + return nextIndex + end + + function XPokemonManager.GetStageTotalCount() + return XPokemonManager.GetStageCountByType(XPokemonConfigs.StageType.Normal) + XPokemonManager.GetStageCountByType(XPokemonConfigs.StageType.Skip) + end + + function XPokemonManager.GetRemainingTimes() + return _RemainingTimes + end + + function XPokemonManager.CheckRemainingTimes() + return true + --return XPokemonManager.GetRemainingTimes() > 0 + end + + function XPokemonManager.IsInfinity() + return XPokemonManager.GetPassedCount() >= XPokemonManager.GetStageCountByType(XPokemonConfigs.StageType.Normal) + end + + function XPokemonManager.GetPokemonStageId(index) + return XPokemonConfigs.GetPokemonStageId(index, XPokemonManager.GetCurrActivityId(), XPokemonManager.GetSelectChapter()) + end + + function XPokemonManager.GetStageUnlockDesc(stageId) + return XPokemonConfigs.GetStageUnlockDesc(stageId, XPokemonManager.GetCurrActivityId(),XPokemonManager.GetSelectChapter()) + end + + function XPokemonManager.GetStageFightStageId(stageId) + return XPokemonConfigs.GetStageFightStageId(stageId, XPokemonManager.GetCurrActivityId(),XPokemonManager.GetSelectChapter()) + end + + function XPokemonManager.GetStageMonsterIds(stageId) + return XPokemonConfigs.GetStageMonsterIds(stageId, XPokemonManager.GetCurrActivityId(),XPokemonManager.GetSelectChapter()) + end + + function XPokemonManager.GetStageIcon(stageId) + return XPokemonConfigs.GetStageIcon(stageId, XPokemonManager.GetCurrActivityId(),XPokemonManager.GetSelectChapter()) + end + + function XPokemonManager.GetStageName(stageId) + return XPokemonConfigs.GetStageName(stageId, XPokemonManager.GetCurrActivityId(),XPokemonManager.GetSelectChapter()) + end + + function XPokemonManager.GetStageBg(stageId) + return XPokemonConfigs.GetStageBg(stageId, XPokemonManager.GetCurrActivityId(),XPokemonManager.GetSelectChapter()) + end + + function XPokemonManager.GetStageBossHeadIcon(stageId) + return XPokemonConfigs.GetStageBossHeadIcon(stageId, XPokemonManager.GetCurrActivityId(),XPokemonManager.GetSelectChapter()) + end + + function XPokemonManager.IsBossStage(stageId) + return XPokemonConfigs.IsBossStage(stageId, XPokemonManager.GetCurrActivityId(),XPokemonManager.GetSelectChapter()) + end + + function XPokemonManager.IsInfinityStage(stageId) + return XPokemonConfigs.IsInfinityStage(stageId, XPokemonManager.GetCurrActivityId(),XPokemonManager.GetSelectChapter()) + end + + function XPokemonManager.IsCanSkipStage(stageId) + return XPokemonConfigs.IsCanSkipStage(stageId, XPokemonManager.GetCurrActivityId(),XPokemonManager.GetSelectChapter()) + end + + + function XPokemonManager.GetStageCountByType(type) + return XPokemonConfigs.GetStageCountByType(type, XPokemonManager.GetCurrActivityId(),XPokemonManager.GetSelectChapter()) + end + + function XPokemonManager.GetStageCountByChapter() + return XPokemonConfigs.GetStageCountByChapter(XPokemonManager.GetCurrActivityId(),XPokemonManager.GetSelectChapter()) + end + + function XPokemonManager.GetShowAbility(stageId, pos) + return XPokemonConfigs.GetShowAbility(stageId, XPokemonManager.GetCurrActivityId(), pos,XPokemonManager.GetSelectChapter()) + end + + function XPokemonManager.GetChapterPerPageStageCount() + return XPokemonConfigs.GetChapterPerPageStageCount(XPokemonManager.GetSelectChapter()) + end + + function XPokemonManager.GetChapterUiTemplateCount() + return XPokemonConfigs.GetUiTemplateCountByChapter(XPokemonManager.GetSelectChapter()) + end + + function XPokemonManager.GetUiTemplate(index,type) + return XPokemonConfigs.GetUiTemplate(XPokemonManager.GetSelectChapter(), index, type) + end + + function XPokemonManager.PokemonSkipStageRequest(stageId,cb) + local req = {StageId = stageId} + XNetwork.Call("PokemonSkipStageRequest",req,function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + CsXGameEventManager.Instance:Notify(XEventId.EVENT_POKEMON_PASSED_STAGE_CHANGE) + if cb then + cb(res.RewardGoods) + end + end) + end + + function XPokemonManager.NotifyPokemonStageSkipInfo(data) + if not data then return end + UpdateSkipStageInfo(data.SkipedStageIdList) + UpdateStageSkipTimes(data.StageSkipTimes) + end + + function XPokemonManager.NotifyPokemonRemoveStageSkiped(data) + if not data then return end + for i = #_SkipStageInfo, 1, -1 do + if _SkipStageInfo[i] == data then + table.remove(_SkipStageInfo, i) + end + end + end + + -----------------关卡相关 end---------------- + -----------------其他部分XXX begin---------------- + local _TimeSupplyLastGetTime = 0 + local _CurrActivityId = XPokemonConfigs.GetDefaultActivityId() + + function XPokemonManager.GetCurrActivityId() + return _CurrActivityId + end + + local function UpdateActivityId(activityId) + if not XTool.IsNumberValid(activityId) then return end + _CurrActivityId = activityId or XPokemonConfigs.GetDefaultActivityId() + end + + function XPokemonManager.GetCurrTaskTimeLimitId() + return XPokemonConfigs.GetActivityTaskTimeLimitId(XPokemonManager.GetCurrActivityId()) + end + + function XPokemonManager.GetPokemonTimeLimitTask() + local groupId = XPokemonManager.GetCurrTaskTimeLimitId() + if groupId == 0 then return {} end + return XDataCenter.TaskManager.GetTimeLimitTaskListByGroupId(groupId) + end + + function XPokemonManager.GetActivityChapters() + local chapters = {} + if XPokemonConfigs.HasActivityInTime() then + local tempChapter = {} + tempChapter.Id = XPokemonManager.GetCurrActivityId() + tempChapter.Type = XDataCenter.FubenManager.ChapterType.Pokemon + tempChapter.BannerBg = XPokemonConfigs.GetActivityBg(tempChapter.Id) + tableInsert(chapters, tempChapter) + end + return chapters + end + + function XPokemonManager.IsOpen() + local nowTime = XTime.GetServerNowTimestamp() + local beginTime = XPokemonManager.GetStartTime() + local endTime = XPokemonManager.GetEndTime() + return beginTime <= nowTime and nowTime < endTime + end + + function XPokemonManager.GetStartTime() + return XPokemonConfigs.GetActivityStartTime(XPokemonManager.GetCurrActivityId()) or 0 + end + + function XPokemonManager.GetEndTime() + return XPokemonConfigs.GetActivityEndTime(XPokemonManager.GetCurrActivityId()) or 0 + end + + function XPokemonManager.GetCurrActivityTime() + return XPokemonManager.GetStartTime(), XPokemonManager.GetEndTime() + end + + local function InitStageType(stageId) + stageId = tonumber(stageId) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + if stageInfo then + stageInfo.Type = XDataCenter.FubenManager.StageType.Pokemon + end + end + + function XPokemonManager.InitStageInfo() + local stageIds = XPokemonConfigs.GetFightStageIds() + for _, stageId in pairs(stageIds) do + InitStageType(stageId) + end + end + + local function GetTimeSupplyLastGetTime() + return _TimeSupplyLastGetTime or 0 + end + + local function UpdateTimeSupplyLastGetTime(time) + _TimeSupplyLastGetTime = time or 0 + end + + function XPokemonManager.PokemonGetTimeSupplyRewardRequest(callback) + XNetwork.Call("PokemonGetTimeSupplyRewardRequest", nil, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + local rewardsList = res.RewardGoods or {} + UpdateTimeSupplyLastGetTime(res.TimeSupplyLastGetTime) + XEventManager.DispatchEvent(XEventId.EVENT_POKEMON_RED_POINT_TIME_SUPPLY) + if callback then callback(rewardsList) end + end) + end + + function XPokemonManager.GetTimeSupplyOffsetTime() + local now = XTime.GetServerNowTimestamp() + local offset = now - GetTimeSupplyLastGetTime() + offset = XMath.Clamp(offset, 0, XPokemonConfigs.GetTimeSupplyMaxCount() * XPokemonConfigs.GetTimeSupplyInterval()) + return offset or 0 + end + + function XPokemonManager.CheckCanGetTimeSupply() + return XPokemonManager.GetTimeSupplyOffsetTime() >= XPokemonConfigs.GetTimeSupplyInterval() + end + -----------------其他部分XXX end------------------ + local _IsFirstEnter = false + + local function ResetPokemonData(isReset) + _Monsters = {} + _NewMonsterIds = {} + _MaxEnergy = 0 + XPokemonManager.InitTeam() + _PassedStageDic = {} + _RemainingTimes = XPokemonConfigs.GetDefaultStageTimes() + _TimeSupplyLastGetTime = 0 + _IsFirstEnter = true + _IsSwitchToInfinity = false + _NextRecoverTime = 0 + _SkipStageInfo = {} + _StageSkipTimes = 0 + end + + function XPokemonManager.OnActivityEnd() + if CS.XFight.IsRunning or XLuaUiManager.IsUiLoad("UiLoading") or XLuaUiManager.IsUiLoad("UiSettleLose") or XLuaUiManager.IsUiLoad("UiSettleWin") then + return + end + XUiManager.TipText("PokemonOver") + XLuaUiManager.RunMain() + end + + function XPokemonManager.OpenPokemonMainUi() + if XPokemonManager.IsOpen() then + local movieId = XPokemonConfigs.GetEnterMovieId() + if _IsFirstEnter and (not string.IsNilOrEmpty(movieId))then + XDataCenter.MovieManager.PlayMovie(movieId, function() + XLuaUiManager.Open("UiPokemonMainLineBanner") + end) + _IsFirstEnter = false + else + XLuaUiManager.Open("UiPokemonMainLineBanner") + end + else + XUiManager.TipText("PokemonOver") + end + end + + function XPokemonManager.CheckPokemonTaskRedPoint() + return XDataCenter.TaskManager.CheckLimitTaskList(XPokemonManager.GetCurrTaskTimeLimitId()) + end + + function XPokemonManager.CheckPokemonEnterRedPoint() + if not XPokemonManager.IsOpen() then return false end + + local timeSupplyOffset = XPokemonManager.GetTimeSupplyOffsetTime() + local maxTimeSupply = XPokemonConfigs.GetTimeSupplyMaxCount() * XPokemonConfigs.GetTimeSupplyInterval() + return timeSupplyOffset >= maxTimeSupply + end + + function XPokemonManager.NotifyPokemonData(data) + local isReset = data.IsActivityReset + if isReset then ResetPokemonData() end + + local checkNew = isReset and true --重置时获得的所有怪物均为新获得 + UpdateMonsters(data.MonsterList, checkNew) + UpdateMaxEnergy(data.MaxEnergy) + UpdateUnlockedPositionList(data.UnlockedPositionList) + UpdateTeam(data.FormationData and data.FormationData.MonsterIdList) + UpdatePassedStage(data.PassedStageIdList) + UpdateRemainingTimes(data.StageTimes) + UpdateTimeSupplyLastGetTime(data.TimeSupplyLastGetTime) + UpdateActivityId(data.ActivityId) + UpdateRandomMonsterData(data.RandomStageData) + UpdateNextRecoverTime(data.StageTimesNextRecoverTime) + UpdateStageSkipTimes(data.StageSkipTimes) + UpdateSkipStageInfo(data.SkipedStageIdList) + end + + function XPokemonManager.Init() + XPokemonManager.InitTeam() + end + + XPokemonManager.Init() + + return XPokemonManager +end +---------------------(服务器推送) begin------------------ +XRpc.NotifyPokemonData = function(data) + XDataCenter.PokemonManager.NotifyPokemonData(data) +end + +XRpc.NotifyPokemonMonster = function(data) + XDataCenter.PokemonManager.NotifyPokemonMonster(data) +end + +XRpc.NotifyPokemonUnlock = function(data) + XDataCenter.PokemonManager.NotifyPokemonUnlock(data) +end + +XRpc.NotifyPokemonStagePassed = function(data) + XDataCenter.PokemonManager.NotifyPokemonStagePassed(data) +end + +XRpc.NotifyPokemonStageTimesInfo = function(data) + XDataCenter.PokemonManager.NotifyPokemonRemainingTimesChange(data) +end + +XRpc.NotifyPokemonStageSkipInfo = function(data) + XDataCenter.PokemonManager.NotifyPokemonStageSkipInfo(data) +end + +XRpc.NotifyPokemonRemoveStageSkiped = function(data) + XDataCenter.PokemonManager.NotifyPokemonRemoveStageSkiped(data) +end + +---------------------(服务器推送)end------------------ \ No newline at end of file diff --git a/Resources/Scripts/XManager/XPokerGuessingManager.lua b/Resources/Scripts/XManager/XPokerGuessingManager.lua new file mode 100644 index 00000000..120c872d --- /dev/null +++ b/Resources/Scripts/XManager/XPokerGuessingManager.lua @@ -0,0 +1,238 @@ +XPokerGuessingMangerCreator = function() + local XPokerGuessingManager = {} + + + local _CurrActivityId = XPokerGuessingConfig.GetDefaultActivityId() + + ---------玩法相关 begin------- + --数据结构 GuessInfo + --比赛状态 PokerGuessingStatusType ActivityStatus + --明牌的Id int DisplayCardId + --当前积分 int CurrentWinCounts + --记牌器列表 List RecordCardIds + + local _LastCardId = 0 + local _LastGuessType = 0 + local _DisplayCardId = 0 + local _CurrentScore = 0 + local _RecordCardIdsDic = {} + local _CurrGameStatus = 0 + local _OldScore = 0 + local _RequestLock = false + local _IsEnterCost = true + + local UpdateGuessingInfo = function(guessInfo) + if not guessInfo then return end + _LastCardId = _DisplayCardId + _CurrentScore = guessInfo.CurrentWinCounts + _DisplayCardId = guessInfo.DisplayCardId + _CurrGameStatus = guessInfo.ActivityStatus + _IsEnterCost = guessInfo.IsEnterCost + _RecordCardIdsDic = {} + if guessInfo.RecordCardIds then + for _,id in pairs(guessInfo.RecordCardIds) do + _RecordCardIdsDic[id] = id + end + end + end + + function XPokerGuessingManager.IsInRecordCardDic(id) + return _RecordCardIdsDic[id] or false + end + + function XPokerGuessingManager.GetDisplayCardId() + return _DisplayCardId + end + + function XPokerGuessingManager.GetCurrentScore() + return _CurrentScore + end + + function XPokerGuessingManager.GetCurrGameStatus() + return _CurrGameStatus + end + + function XPokerGuessingManager.GetOldScore() + return _OldScore + end + + function XPokerGuessingManager.GetIsEnterCost() + return _IsEnterCost + end + + function XPokerGuessingManager.GetResult() + local lastNum = XPokerGuessingConfig.GetCardNumber(_LastCardId) + local currNum = XPokerGuessingConfig.GetCardNumber(_DisplayCardId) + if lastNum == currNum then return XPokerGuessingConfig.GameStatus.Drawn end + local isWin = _LastGuessType == XPokerGuessingConfig.GuessType.Greater and (currNum > lastNum) or (currNum < lastNum) + return isWin and XPokerGuessingConfig.GameStatus.Victory or XPokerGuessingConfig.GameStatus.Failed + end + function XPokerGuessingManager.IsContinueGuessRequest(isContinue) + if _RequestLock then return end + _RequestLock = true + local req = {IsContinue = isContinue} + XNetwork.Call("IsContinueGuessRequest",req,function(rsp) + _RequestLock = false + if rsp.Code ~= XCode.Success then + XUiManager.TipCode(rsp.Code) + return + end + UpdateGuessingInfo(rsp.GuessInfo) + CS.XGameEventManager.Instance:Notify(XEventId.EVENT_POKER_GUESSING_UPDATE_STATE) + end) + end + + function XPokerGuessingManager.StartNewPokerGuessingRequest(cb) + if _RequestLock then return end + _RequestLock = true + XNetwork.Call("StartNewPokerGuessingRequest",nil,function(rsp) + _RequestLock = false + if rsp.Code ~= XCode.Success then + XUiManager.TipCode(rsp.Code) + return + end + UpdateGuessingInfo(rsp.GuessInfo) + CS.XGameEventManager.Instance:Notify(XEventId.EVENT_POKER_GUESSING_UPDATE_STATE) + if cb then + cb() + end + end) + end + + function XPokerGuessingManager.GuessCompareRequest(guessType,cb) + if _RequestLock then return end + _RequestLock = true + local req = {GuessType = guessType} + _LastGuessType = guessType + XNetwork.Call("GuessCompareRequest",req,function(rsp) + _RequestLock = false + if rsp.Code ~= XCode.Success then + XUiManager.TipCode(rsp.Code) + return + end + _OldScore = _CurrentScore + UpdateGuessingInfo(rsp.GuessInfo) + CS.XGameEventManager.Instance:Notify(XEventId.EVENT_POKER_GUESSING_UPDATE_STATE) + if cb then + cb() + end + end) + end + + ---------玩法相关 end--------- + ---------配置相关 begin------- + function XPokerGuessingManager.GetBackAssetPath() + return XPokerGuessingConfig.GetBackAssetPath(_CurrActivityId) + end + + function XPokerGuessingManager.GetCostItemName() + return XPokerGuessingConfig.GetCostItemName(_CurrActivityId) + end + + function XPokerGuessingManager.GetCostItemCount() + return XPokerGuessingConfig.GetCostItemCount(_CurrActivityId) + end + + function XPokerGuessingManager.GetCostItemIcon() + return XPokerGuessingConfig.GetCostItemIcon(_CurrActivityId) + end + + function XPokerGuessingManager.GetShopSkipId() + return XPokerGuessingConfig.GetShopSkipId(_CurrActivityId) + end + + function XPokerGuessingManager.GetPokerGroup() + return XPokerGuessingConfig.GetPokerGroup(_CurrActivityId) + end + + ---------配置相关 end--------- + + + ---------活动相关 begin------- + + function XPokerGuessingManager.OnOpenMain() + XSaveTool.SaveData(XPokerGuessingManager.GetPlayerPrefsKey(), true) + XLuaUiManager.Open("UiFubenPokerGuessing") + end + + function XPokerGuessingManager.OnActivityEnd() + + end + + function XPokerGuessingManager.GetStartTime() + return XFunctionManager.GetStartTimeByTimeId(XPokerGuessingConfig.GetActivityTimeId(_CurrActivityId)) + end + + function XPokerGuessingManager.GetEndTime() + return XFunctionManager.GetEndTimeByTimeId(XPokerGuessingConfig.GetActivityTimeId(_CurrActivityId)) + end + + function XPokerGuessingManager.IsOpen() + return XFunctionManager.CheckInTimeByTimeId(XPokerGuessingConfig.GetActivityTimeId(_CurrActivityId)) + end + + function XPokerGuessingManager.GetChapters() + local chapters = {} + if XPokerGuessingManager.IsOpen() then + local tempChapter = {} + tempChapter.Id = _CurrActivityId + tempChapter.Name = XPokerGuessingConfig.GetActivityName(_CurrActivityId) + tempChapter.Type = XDataCenter.FubenManager.ChapterType.PokerGuessing + tempChapter.BannerBg = XPokerGuessingConfig.GetBannerBg(_CurrActivityId) + table.insert(chapters, tempChapter) + end + return chapters + end + + function XPokerGuessingManager.GetPlayerPrefsKey() + local severNextRefreshTime = XTime.GetSeverNextRefreshTime() + return string.format("%s_%s_%s", XPlayer.Id, "PokerGuessingBannerRed", severNextRefreshTime) + end + + function XPokerGuessingManager.CheckBannerRedPoint() + if not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.PokerGuessing) then + return false + end + if not XPokerGuessingManager.IsOpen() then + return false + end + local taskList = XDataCenter.TaskManager.GetPokerGuessingTaskList() + for k,v in pairs(taskList) do + if XDataCenter.TaskManager.CheckTaskAchieved(v.Id) then + return true + end + end + if XSaveTool.GetData(XPokerGuessingManager.GetPlayerPrefsKey()) then + return false + end + local taskList = XDataCenter.TaskManager.GetPokerGuessingTaskList() + for _,task in pairs(taskList) do + if task.State == XDataCenter.TaskManager.TaskState.Active then + return true + end + end + return false + end + ---------活动相关 end -------- + + ---------推送相关 begin -------- + + function XPokerGuessingManager.NotifyPokerGuessingData(data) + if not data then return end + if data.ActivityId ~= 0 then + _CurrActivityId = data.ActivityId + elseif data.ActivityId == 0 then + CS.XGameEventManager.Instance:Notify(XEventId.EVENT_POKER_GUESSING_ACTIVITY_END) + end + UpdateGuessingInfo(data.GuessInfo) + end + + ---------推送相关 end ---------- + + return XPokerGuessingManager +end + +XRpc.NotifyPokerGuessingData = function(data) + XDataCenter.PokerGuessingManager.NotifyPokerGuessingData(data) +end + diff --git a/Resources/Scripts/XManager/XPracticeManager.lua b/Resources/Scripts/XManager/XPracticeManager.lua new file mode 100644 index 00000000..b7e45630 --- /dev/null +++ b/Resources/Scripts/XManager/XPracticeManager.lua @@ -0,0 +1,202 @@ +XPracticeManagerCreator = function() + local XPracticeManager = {} + local PracticeChapterInfos = {} + local PracticeStageInfo = {} + + function XPracticeManager.Init() + XEventManager.AddEventListener(XEventId.EVENT_PLAYER_LEVEL_CHANGE, XPracticeManager.RefreshStagePassed) + end + + function XPracticeManager.InitStageInfo() + local allPracticeChapters = XPracticeConfigs.GetPracticeChapters() + for _, chapter in pairs(allPracticeChapters) do + for _, stageId in pairs(chapter.StageId) do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + if stageInfo then + stageInfo.Type = XDataCenter.FubenManager.StageType.Practice + end + end + end + XPracticeManager.RefreshStagePassed() + end + + function XPracticeManager.ShowReward(winData) + if not winData then return end + XPracticeManager.RefreshStagePassedBySettleDatas(winData.SettleData) + + XLuaUiManager.Open("UiSettleWin", winData) + end + + function XPracticeManager.CheckPracticeStageOpen(stageId) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + + if not stageInfo.Unlock then return false, CS.XTextManager.GetText("FubenNotUnlock") end + + if stageCfg.RequireLevel > 0 and XPlayer.Level < stageCfg.RequireLevel then + return false, CS.XTextManager.GetText("TeamLevelToOpen", stageCfg.RequireLevel) + end + + local actInfo = XPracticeConfigs.GetPracticeActivityInfo(stageId) + local condition = {} + if XPracticeManager.CheckStageInActivity(stageId) then + condition = actInfo.ActivityCondition + elseif actInfo then + condition = actInfo.OpenCondition + end + + for _, conditionId in pairs(condition or {}) do + local ret, desc = XConditionManager.CheckCondition(conditionId) + if not ret then + return false, desc + end + end + return true + end + + function XPracticeManager.GetSortedChapterStage(chapterId) + local stageIds = XPracticeConfigs.GetPracticeChapterById(chapterId).StageId + local sortedNodes = {} + for _, stageId in pairs(stageIds) do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + local isOpen = XPracticeManager.CheckPracticeStageOpen(stageId) + local inActivity = XPracticeManager.CheckStageInActivity(stageId) + local weight + if stageInfo.Passed then + -- 已通关 + weight = 3 + elseif isOpen then + -- 可打未通过 + weight = 1 + else + -- 未解锁 + weight = 2 + end + table.insert(sortedNodes, { + StageId = stageId, + InActivity = inActivity, + Weight = weight + }) + end + table.sort(sortedNodes, function(nodeA, nodeB) + if nodeA.InActivity ~= nodeB.InActivity then + return nodeA.InActivity and not nodeB.InActivity + end + if nodeA.Weight == nodeB.Weight then + return nodeA.StageId < nodeB.StageId + else + return nodeA.Weight < nodeB.Weight + end + end) + return sortedNodes + end + + -- 已解锁 + function XPracticeManager.CheckPracticeStageIsUnlock(stageId) + return PracticeStageInfo[stageId] or false + end + + -- 进度是否完成 + --function XPracticeManager.IsPracticeStageFinish(chapterId, stageId) + -- local practiceDatas = PracticeChapterInfos[chapterId] + -- if not practiceDatas then return false end + -- for _, finishStageId in pairs(practiceDatas) do + -- if finishStageId == stageId then + -- return true + -- end + -- end + -- return false + --end + + -- 是否处于活动期间 + function XPracticeManager.CheckStageInActivity(stageId) + local actInfo = XPracticeConfigs.GetPracticeActivityInfo(stageId) + if actInfo and actInfo.ActivityTimeId and + XFunctionManager.CheckInTimeByTimeId(actInfo.ActivityTimeId) then + return true + else + return false + end + end + + function XPracticeManager.RefreshStagePassedBySettleDatas(settleData) + if not settleData then return end + + local allPracticeChapters = XPracticeConfigs.GetPracticeChapters() + local chapterId = 0 + for id, chapter in pairs(allPracticeChapters) do + for _, stageId in pairs(chapter.StageId) do + if stageId == settleData.StageId then + chapterId = id + break + end + end + if chapterId ~= 0 then + if not PracticeChapterInfos[chapterId] then + PracticeChapterInfos[chapterId] = {} + end + PracticeChapterInfos[chapterId][settleData.StageId] = true + PracticeStageInfo[settleData.StageId] = true + XPracticeManager.RefreshStagePassed() + XEventManager.DispatchEvent(XEventId.EVENT_PRACTICE_ON_DATA_REFRESH) + break + end + end + end + + function XPracticeManager.RefreshStagePassed() + local allPracticeChapters = XPracticeConfigs.GetPracticeChapters() + for _, chapter in pairs(allPracticeChapters) do + for _, stageId in pairs(chapter.StageId) do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + if stageInfo then + stageInfo.Passed = PracticeStageInfo[stageId] or false + + stageInfo.Unlock = true + stageInfo.IsOpen = true + + if stageCfg.RequireLevel > 0 and XPlayer.Level < stageCfg.RequireLevel then + stageInfo.Unlock = false + stageInfo.IsOpen = false + end + for _, prestageId in pairs(stageCfg.PreStageId or {}) do + if prestageId > 0 then + if not PracticeStageInfo[prestageId] then + stageInfo.Unlock = false + stageInfo.IsOpen = false + break + end + end + end + + end + end + end + end + + + -- 同步数据 + function XPracticeManager.OnAsyncPracticeData(chapterInfos) + if not chapterInfos then return end + for _, v in pairs(chapterInfos) do + if not PracticeChapterInfos[v.Id] then + PracticeChapterInfos[v.Id] = {} + end + for _, stageId in pairs(v.FinishStages or {}) do + PracticeChapterInfos[v.Id][stageId] = true + PracticeStageInfo[stageId] = true + end + end + + XPracticeManager.RefreshStagePassed() + end + + XPracticeManager.Init() + return XPracticeManager +end + +XRpc.NotifyPracticeData = function(response) + if not response then return end + XDataCenter.PracticeManager.OnAsyncPracticeData(response.ChapterInfos) +end diff --git a/Resources/Scripts/XManager/XPrequelManager.lua b/Resources/Scripts/XManager/XPrequelManager.lua new file mode 100644 index 00000000..dddfbbbd --- /dev/null +++ b/Resources/Scripts/XManager/XPrequelManager.lua @@ -0,0 +1,483 @@ +XPrequelManagerCreator = function() + local XPrequelManager = {} + + local UnlockChallengeStages = {} + local RewardedStages = {} + local NextCheckPoint = nil + -- manager层 + local Cover2ChapterMap = {}--记录上一个封面 + local CoverPrefix = "CoverPrefix" + local Stage2ChapterMap = {} + + function XPrequelManager.InitPrequelData(fubenPrequelData) + if not fubenPrequelData then return end + for _, v in pairs(fubenPrequelData.RewardedStages or {}) do + RewardedStages[v] = true + end + for _, v in pairs(fubenPrequelData.UnlockChallengeStages or {}) do + UnlockChallengeStages[v.StageId] = v + end + end + + function XPrequelManager.SaveCoverChapterHint(key, value) + if XPlayer.Id then + key = string.format("%s_%s", tostring(XPlayer.Id), key) + CS.UnityEngine.PlayerPrefs.SetInt(key, value) + CS.UnityEngine.PlayerPrefs.Save() + end + end + + function XPrequelManager.GetCoverChapterHint(key, defaultValue) + if XPlayer.Id then + key = string.format("%s_%s", tostring(XPlayer.Id), key) + if CS.UnityEngine.PlayerPrefs.HasKey(key) then + local newPlayerHint = CS.UnityEngine.PlayerPrefs.GetInt(key) + return (newPlayerHint == nil or newPlayerHint == 0) and defaultValue or newPlayerHint + end + end + return defaultValue + end + + function XPrequelManager.InitStageInfo() + for chapterId, chapterCfg in pairs(XPrequelConfigs.GetPequelAllChapter() or {}) do + for _, stageId in pairs(chapterCfg.StageId or {}) do + Stage2ChapterMap[stageId] = chapterId + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + if stageInfo then + stageInfo.Type = XDataCenter.FubenManager.StageType.Prequel + end + end + end + + for _, coverCfg in pairs(XPrequelConfigs.GetPrequelCoverList() or {}) do + for _, stageId in pairs(coverCfg.ChallengeStage or {}) do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + if stageInfo then + stageInfo.Type = XDataCenter.FubenManager.StageType.Prequel + end + end + end + end + + -- [更新封面显示的chapter] + function XPrequelManager.UpdateShowChapter(stageId) + if not stageId then return end + local chapterId = XPrequelConfigs.GetChapterByStageId(stageId) + if not chapterId then return end + local coverId = XPrequelConfigs.GetCoverByChapterId(chapterId) + if not coverId then return end + local key = string.format("%s%s", CoverPrefix, tostring(coverId)) + XPrequelManager.SaveCoverChapterHint(key, chapterId) + Cover2ChapterMap[coverId] = chapterId + end + + function XPrequelManager.ShowReward(winData) + XLuaUiManager.Open("UiSettleWin", winData) + end + + -- [获取已经解锁的挑战关卡,nil代表未解锁] + function XPrequelManager.GetUnlockChallengeStagesByStageId(stageId) + return UnlockChallengeStages[stageId] + end + + -- [解锁挑战] + function XPrequelManager.UnlockPrequelChallengeRequest(coverId, challengeIdx, stageId, cb) + XNetwork.Call("UnlockPrequelChallengeRequest", { CoverId = coverId, ChallengeId = challengeIdx }, function(res) + cb = cb or function() end + if res.Code == XCode.Success then + UnlockChallengeStages[stageId] = res.ChallengeStage + cb(res) + else + XUiManager.TipCode(res.Code) + end + end) + end + -- [前传奖励领取] + function XPrequelManager.ReceivePrequelRewardRequest(stageId, cb) + XNetwork.Call("ReceivePrequelRewardRequest", { StageId = stageId }, function(res) + cb = cb or function() end + if res.Code == XCode.Success then + RewardedStages[res.StageId] = true + -- 显示奖励 + XUiManager.OpenUiObtain(res.RewardGoodsList, CS.XTextManager.GetText("DailyActiveRewardTitle")) + cb(res) + else + XUiManager.TipCode(res.Code) + end + end) + end + + -- [剧情] + function XPrequelManager.FinishStoryRequest(stageId, cb) + XNetwork.Call("EnterStoryRequest", { StageId = stageId }, function(res) + cb = cb or function() end + if res.Code == XCode.Success then + cb(res) + else + XUiManager.TipCode(res.Code) + end + end) + end + + function XPrequelManager.GetRewardedStages() + return RewardedStages + end + + function XPrequelManager.IsRewardStageCollected(stageId) + return RewardedStages[stageId] + end + + function XPrequelManager.IsStoryStage(stageId) + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + if not stageCfg then return false end + return stageCfg.StageType == XFubenConfigs.STAGETYPE_STORYEGG + end + + -- [服务器同步领取奖励的剧情关卡数据] + function XPrequelManager.OnSyncRewardedStage(response) + for _, v in pairs(response.RewardedStages or {}) do + RewardedStages[v] = true + end + end + + -- [服务器同步解锁的挑战关卡数据] + function XPrequelManager.OnSyncUnlockChallengeStage(response) + UnlockChallengeStages = response.UnlockChallengeStages + XEventManager.DispatchEvent(XEventId.EVENT_NOTICE_CHALLENGESTAGES_CHANGE) + end + + function XPrequelManager.OnSyncSingleUnlockChallengeStage(response) + local currentStage = response.ChallengeStage + UnlockChallengeStages[currentStage.StageId] = currentStage + XEventManager.DispatchEvent(XEventId.EVENT_NOTICE_CHALLENGESTAGES_CHANGE) + end + + -- [刷新时间-需要通知界面及时更新] + function XPrequelManager.OnSyncNextRefreshTime(response) + NextCheckPoint = response.NextRefreshTime + XEventManager.DispatchEvent(XEventId.EVENT_NOTICE_REFRESHTIME_CHANGE) + end + + -- [判断解锁条件] + function XPrequelManager.CheckPrequelStageOpen(stageId) + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + local isUnlock = stageInfo.Unlock + if stageInfo.Unlock then + for _, conditionId in pairs(stageCfg.ForceConditionId or {}) do + local rect, _ = XConditionManager.CheckCondition(conditionId) + if not rect then + return rect + end + end + end + if stageCfg.StageType == XFubenConfigs.STAGETYPE_STORYEGG or stageCfg.StageType == XFubenConfigs.STAGETYPE_FIGHTEGG then + return isUnlock and XDataCenter.FubenManager.GetUnlockHideStageById(stageId) + end + return isUnlock + end + + function XPrequelManager.GetCoverUnlockDescription(coverId) + local coverInfos = XPrequelConfigs.GetPrequelCoverById(coverId) + local chapterIds = coverInfos.ChapterId + + for _, chapterId in pairs(chapterIds or {}) do + local chapterInfo = XPrequelConfigs.GetPrequelChapterById(chapterId) + for _, openConditoinId in pairs(chapterInfo.OpenCondition or {}) do + local rect, desc = XConditionManager.CheckCondition(openConditoinId) + if not rect then + return desc + end + end + end + return "" + end + + -- 检查章节开启条件 + function XPrequelManager.GetChapterUnlockDescription(chapterId) + local chapterTemplate = XPrequelConfigs.GetPrequelChapterById(chapterId) + -- 如果处于活动,优先判断活动的Condition + local inActivity = XPrequelManager.IsChapterInActivity(chapterId) + if chapterTemplate.ActivityCondition ~= 0 and inActivity then + local rect, desc = XConditionManager.CheckCondition(chapterTemplate.ActivityCondition) + if not rect then + return desc + end + return nil + end + + for _, openConditoinId in pairs(chapterTemplate.OpenCondition or {}) do + local rect, desc = XConditionManager.CheckCondition(openConditoinId) + if not rect then + return desc + end + end + end + + -- [进度] + function XPrequelManager.GetChapterProgress(chapterId) + local chapterInfos = XPrequelConfigs.GetPrequelChapterById(chapterId) + local total = 0 + local finishedStageNum = 0 + for _, stageId in pairs(chapterInfos.StageId or {}) do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + if stageCfg.StageType ~= XFubenConfigs.STAGETYPE_STORYEGG and stageCfg.StageType ~= XFubenConfigs.STAGETYPE_FIGHTEGG then + total = total + 1 + if stageInfo.Passed then + finishedStageNum = finishedStageNum + 1 + end + end + end + return finishedStageNum, total + end + + -- [寻找一个可以使用的章节] + function XPrequelManager.GetSelectableChaperIndex(cover) + local showChapter = cover.ShowChapter + local defaultChapter = 1 + local hasDefault = false + local reverseId = #cover.CoverActiveChapterIds --章节UI页签按钮是以倒序显示的 + for index, chapterId in pairs(cover.CoverActiveChapterIds or {}) do + local chapterDescription = XPrequelManager.GetChapterUnlockDescription(chapterId) + if chapterDescription == nil then + if showChapter and showChapter == chapterId then + return reverseId + end + if not hasDefault then + hasDefault = true + defaultChapter = index + end + end + reverseId = reverseId - 1 + end + return defaultChapter + end + + function XPrequelManager.GetIndexByChapterId(cover, chapterId) + if not chapterId then return nil end + local index = #cover.CoverActiveChapterIds + for _, id in pairs(cover.CoverActiveChapterIds or {}) do + if XPrequelManager.IsChapterInActivity(id) or not XPrequelManager.GetChapterLockStatus(id) then + if chapterId == id then + return index + end + end + index = index - 1 + end + return index + end + + -- [获取章节锁定状态] + function XPrequelManager.GetChapterLockStatus(chapterId) + local chapterInfo = XPrequelConfigs.GetPrequelChapterById(chapterId) + for _, conditionId in pairs(chapterInfo.OpenCondition or {}) do + local rect, _ = XConditionManager.CheckCondition(conditionId) + if not rect then + return true + end + end + return false + end + + -- [章节是否处于活动中] + function XPrequelManager.IsInActivity() + local chapters = XPrequelConfigs.GetPequelAllChapter() + + for chapterId in pairs(chapters) do + if XPrequelManager.IsChapterInActivity(chapterId) then + return true + end + end + + return false + end + + -- [是否有章节处于活动中] + function XPrequelManager.IsChapterInActivity(chapterId) + local config = XPrequelConfigs.GetPrequelChapterById(chapterId) + return XFunctionManager.CheckInTimeByTimeId(config.TimeId) + end + + -- 支线奖励 + function XPrequelManager.CheckRewardAvailable(chapterId) + local chapterInfos = XPrequelConfigs.GetPrequelChapterById(chapterId) + local rewardedStages = XPrequelManager.GetRewardedStages() + for _, stageId in pairs(chapterInfos.StageId or {}) do + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + if stageCfg.FirstRewardShow > 0 and stageInfo.Passed and rewardedStages and (not rewardedStages[stageId]) then + return true + end + end + return false + end + + function XPrequelManager.GetListCovers() + local coverList = {} + for k, v in pairs(XPrequelConfigs.GetPrequelCoverList() or {}) do + local showChapter, isActivity, isAllChapterLock, isActivityNotOpen = XPrequelManager.GetPriorityChapter(v.ChapterId, k) + local chapterWeight = 0 + if isActivity then + chapterWeight = 4 + else + if isAllChapterLock == false then + chapterWeight = 3 + end + if isActivityNotOpen then + chapterWeight = 2 + end + end + local activeChapterIds = XPrequelManager.GetListActiveChapterIdsByCoverId(k) + if #activeChapterIds > 0 then -- 如果存在当前时间下激活的章节才显示 + table.insert(coverList, { + CoverId = k, + CoverVal = v, + ShowChapter = showChapter, + IsActivity = isActivity, + IsAllChapterLock = isAllChapterLock, + IsActivityNotOpen = isActivityNotOpen, + ChapterWeight = chapterWeight, + CoverActiveChapterIds = activeChapterIds, + }) + end + end + table.sort(coverList, function(coverA, coverB) + local coverAWeight = coverA.ChapterWeight + local coverBWeight = coverB.ChapterWeight + if coverAWeight == coverBWeight then + return coverA.CoverVal.Priority < coverB.CoverVal.Priority + end + return coverAWeight > coverBWeight + end) + return coverList + end + + -- 获取当前时间已激活的章节Id列表 + function XPrequelManager.GetListActiveChapterIdsByCoverId(coverId) + local coverTemplate = XPrequelConfigs.GetPrequelCoverById(coverId) + local activeChapterIdList = {} + local nowTimeStamp = XTime.GetServerNowTimestamp() + for i, v in ipairs(coverTemplate.ChapterId) do + local isActive = false + if coverTemplate.ActiveTimes[i] ~= nil and coverTemplate.ActiveTimes[i] ~= "" then + local activeTime = XTime.ParseToTimestamp(coverTemplate.ActiveTimes[i]) + if nowTimeStamp >= activeTime then + isActive = true + end + else + isActive = true + end + + if isActive then + table.insert(activeChapterIdList, coverTemplate.ChapterId[i]) + end + end + + return activeChapterIdList + end + + function XPrequelManager.GetPriorityChapter(chapters, coverId) + local currentChapter = chapters[1] + local currentPriority = 0 + local isActivity = false + local isActivityNotOpen = false + local isAllChapterLock = true + for _, chapterId in pairs(chapters or {}) do + local chapterInfo = XPrequelConfigs.GetPrequelChapterById(chapterId) + + if XPrequelManager.IsChapterInActivity(chapterId) then + if currentPriority < chapterInfo.Priority then + isActivityNotOpen = true + if chapterInfo.ActivityCondition <= 0 or (chapterInfo.ActivityCondition > 0 + and XConditionManager.CheckCondition(chapterInfo.ActivityCondition)) then + currentChapter = chapterId + currentPriority = chapterInfo.Priority + isActivity = true + isActivityNotOpen = false + end + end + end + + for _, conditionId in pairs(chapterInfo.OpenCondition or {}) do + local rect, _ = XConditionManager.CheckCondition(conditionId) + if rect then + isAllChapterLock = false + end + end + end + -- [寻找一个正确的显示在封面的章节] + if (not isAllChapterLock) and (not isActivity) then + for _, chapterId in pairs(chapters or {}) do + if not XDataCenter.PrequelManager.GetChapterLockStatus(chapterId) then + currentChapter = chapterId + break + end + end + end + -- 优先显示上一次打过的章节 + if not Cover2ChapterMap[coverId] then + local key = string.format("%s%s", CoverPrefix, tostring(coverId)) + local recordChapter = XPrequelManager.GetCoverChapterHint(key, currentChapter) + local isRecordChapterInActivity = XPrequelManager.IsChapterInActivity(recordChapter) + local recordChapterDescription = XPrequelManager.GetChapterUnlockDescription(recordChapter) + if isRecordChapterInActivity then + currentChapter = recordChapter + else + if recordChapterDescription == nil then + currentChapter = recordChapter + end + end + elseif Cover2ChapterMap[coverId] and Cover2ChapterMap[coverId] ~= currentChapter then + local recordChapter = Cover2ChapterMap[coverId] + local recordChapterDescription = XPrequelManager.GetChapterUnlockDescription(recordChapter) + local isRecordChapterInActivity = XPrequelManager.IsChapterInActivity(recordChapter) + if isRecordChapterInActivity then + currentChapter = Cover2ChapterMap[coverId] + else + if recordChapterDescription == nil then + currentChapter = recordChapter + end + end + end + return currentChapter, isActivity, isAllChapterLock, isActivityNotOpen + end + + function XPrequelManager.GetNextCheckPointTime() + return NextCheckPoint + end + + function XPrequelManager.GetChapterIdByStageId(stageId) + return Stage2ChapterMap[stageId] + end + + return XPrequelManager +end + +XRpc.NotifyFubenPrequelData = function(response) + if not response then return end + XDataCenter.PrequelManager.InitPrequelData(response.FubenPrequelData) +end + +-- [领取奖励] +XRpc.NotifyPrequelRewardedStages = function(response) + if not response then return end + XDataCenter.PrequelManager.OnSyncRewardedStage(response) +end + +-- [解锁挑战关卡回复] +XRpc.NotifyPrequelUnlockChallengeStages = function(response) + if not response then return end + XDataCenter.PrequelManager.OnSyncUnlockChallengeStage(response) +end + +XRpc.NotifyPrequelChallengeStage = function(response) + if not response then return end + XDataCenter.PrequelManager.OnSyncSingleUnlockChallengeStage(response) +end + +-- [下一个刷新时间] +XRpc.NotifyPrequelChallengeRefreshTime = function(response) + if not response then return end + XDataCenter.PrequelManager.OnSyncNextRefreshTime(response) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XPurchaseManager.lua b/Resources/Scripts/XManager/XPurchaseManager.lua new file mode 100644 index 00000000..09d0109f --- /dev/null +++ b/Resources/Scripts/XManager/XPurchaseManager.lua @@ -0,0 +1,870 @@ +XPurchaseManagerCreator = function() + local XPurchaseManager = {} + local PurchaseRequest = { + PurchaseGetDailyRewardReq = "PurchaseGetDailyRewardRequest", + GetPurchaseListReq = "GetPurchaseListRequest", -- 采购列表请求 + PurchaseReq = "PurchaseRequest", -- 普通采购请求 + } + + local Next = _G.next + local PurchaseInfosData = {} + local PurchaseLbRedUiTypes = {} + local AccumulatedData = {} + local LBExpireIdKey = "LBExpireIdKey" + local LBExpireIdDic = nil + local IsYKShowConitnueBuy = false + local PurchaseInfoDataDic = {} + local MutexPurchaseDic = {} + + function XPurchaseManager.Init() + XPurchaseManager.CurBuyIds = {} + XPurchaseManager.GiftValidCb = function(uiTypeList, cb) XDataCenter.PurchaseManager.PurchaseGiftValidTimeCb(uiTypeList, cb) end + end + + -- 按UiTypes取数据 + function XPurchaseManager.GetDatasByUiTypes(uitypes) + local data = {} + for _, uitype in pairs(uitypes) do + table.insert(data, PurchaseInfosData[uitype] or {}) + end + + return data + end + + -- 判断是否UiTypes都有数据 + function XPurchaseManager.IsHaveDataByUiTypes(uitypes) + for _, uitype in pairs(uitypes) do + if not PurchaseInfosData[uitype] then + return false + end + end + + return true + end + + -- 按UiType取数据 + function XPurchaseManager.GetDatasByUiType(uitype) + local payuitypes = XPurchaseConfigs.GetPayUiTypes() + if payuitypes[uitype] then + return XPayConfigs.GetPayConfig() + end + return PurchaseInfosData[uitype] + end + + function XPurchaseManager.ClearData() + local uitypes = XPurchaseConfigs.GetYKUiTypes() + local yktype = nil + if uitypes and uitypes[1] then + yktype = uitypes[1] + end + if yktype then + local d = PurchaseInfosData[yktype] + PurchaseInfosData = {} + PurchaseInfosData[yktype] = d + else + PurchaseInfosData = {} + end + end + + -- RPC + -- // 失效时间 + -- public int TimeToInvalid; + -- 采购列表请求 + -- public List PurchaseInfoList; + function XPurchaseManager.GetPurchaseListRequest(uiTypeList, cb) + XNetwork.Call(PurchaseRequest.GetPurchaseListReq, { UiTypeList = uiTypeList }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + XPurchaseManager.HandlePurchaseData(uiTypeList, res.PurchaseInfoList) + if cb then + cb() + end + XEventManager.DispatchEvent(XEventId.EVENT_PURCAHSE_YKMAINREFRESH) + local LBDicTmp = XPurchaseConfigs.GetLBUiTypesDic() + local YKDicTmp = XPurchaseConfigs.GetYKUiTypesDic() + local isLbData = false + local isYKData = false + for _,v in pairs(uiTypeList)do + if not isLbData and LBDicTmp[v] then + XEventManager.DispatchEvent(XEventId.EVENT_LB_UPDATE) + XEventManager.DispatchEvent(XEventId.EVENT_PURCAHSE_BUYUSERIYUAN) + isLbData = true + end + if not isYKData and YKDicTmp[v] then + XEventManager.DispatchEvent(XEventId.EVENT_YK_UPDATE) + isYKData = true + end + end + end) + end + + -- 处理返回的数据 + function XPurchaseManager.HandlePurchaseData(uiTypeList, purchaseInfoList) + if not purchaseInfoList then + return + end + + for _, uiType in pairs(uiTypeList) do + PurchaseInfosData[uiType] = {} + PurchaseInfoDataDic[uiType] = {} + MutexPurchaseDic[uiType] = {} + end + + for _, v in pairs(purchaseInfoList) do + if v.UiType then + table.insert(PurchaseInfosData[v.UiType], v) + PurchaseInfoDataDic[v.UiType][v.Id] = v + --以下用于处理互斥内容 + if v.MutexPurchaseIds and next(v.MutexPurchaseIds) ~= nil then + MutexPurchaseDic[v.UiType][v.Id] = v.MutexPurchaseIds + end + end + end + end + + -- 普通采购请求 + -- public List RewardList; + function XPurchaseManager.PurchaseRequest(id, cb, count, discountId, uiTypeList) + if not discountId then -- 等于 -1 为不使用打折券 + discountId = -1 + end + if not count then -- 默认数量为1 + count = 1 + end + if count > 1 and discountId ~= -1 then -- 打折券不能使用批量购买 + XUiManager.TipError(CS.XTextManager.GetText("PurchaseErrorCantMultiplyWithDiscount")) + return + end + if not uiTypeList then + uiTypeList = {} + end + XNetwork.Call(PurchaseRequest.PurchaseReq, { Id = id, Count = count, DiscountId = discountId, UiTypeList = uiTypeList }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + XPurchaseManager.CurBuyIds[id] = id + + if res.RewardList and res.RewardList[1] and Next(res.RewardList[1]) then + XUiManager.OpenUiObtain(res.RewardList) + else + XUiManager.TipText("PurchaseLBBuySuccessTips") + end + + XPurchaseManager.PurchaseSuccess(id, res.PurchaseInfo, res.NewPurchaseInfoList) + if cb then + cb(res.RewardList) + end + + XEventManager.DispatchEvent(XEventId.EVENT_LB_UPDATE) + XEventManager.DispatchEvent(XEventId.EVENT_CARD_REFRESH_WELFARE_BTN) + end) + end + + -- 采购成功修正数据 + function XPurchaseManager.PurchaseSuccess(id, purchaseInfo, newPurchaseInfoList) + XPurchaseManager.UpdateSingleData(id, purchaseInfo) + if newPurchaseInfoList and Next(newPurchaseInfoList) then + local uiTypeList = {} + for _, v in pairs(newPurchaseInfoList) do + if nil == uiTypeList[v.UiType] then + uiTypeList[v.UiType] = {} + end + table.insert(uiTypeList[v.UiType], v) + end + + for uiType,purchaseList in pairs(uiTypeList) do + PurchaseInfosData[uiType] = purchaseList + end + end + + local LbExpireIds = XPurchaseManager.GetLbExpireIds() + if XPurchaseManager.HaveNewPlayerHint(id) then + LbExpireIds[id] = nil + XPurchaseManager.SaveLBExpreIds(LbExpireIds) + end + end + + function XPurchaseManager.UpdateSingleData(id, purchaseInfo) + local f = false + for _, datas in pairs(PurchaseInfosData) do + for _, data in pairs(datas) do + if data.Id == id then + if (not purchaseInfo or Next(purchaseInfo) == nil) then + data.IsSelloutHide = true + elseif data.BuyLimitTimes == data.BuyTimes + 1 then + data.BuyTimes = data.BuyLimitTimes + else + XPurchaseManager.SetData(data, purchaseInfo) + end + f = true + break + end + end + if f then + break + end + end + end + + function XPurchaseManager.SetData(data, purchaseInfo) + if not purchaseInfo then + return + end + + data.TimeToUnShelve = purchaseInfo.TimeToUnShelve + data.Tag = purchaseInfo.Tag + data.Priority = purchaseInfo.Priority + data.Icon = purchaseInfo.Icon + data.DailyRewardRemainDay = purchaseInfo.DailyRewardRemainDay + data.UiType = purchaseInfo.UiType + data.ConsumeId = purchaseInfo.ConsumeId + data.TimeToShelve = purchaseInfo.TimeToShelve + data.BuyTimes = purchaseInfo.BuyTimes + data.Desc = purchaseInfo.Desc + data.RewardGoodsList = purchaseInfo.RewardGoodsList + data.BuyLimitTimes = purchaseInfo.BuyLimitTimes + data.ConsumeCount = purchaseInfo.ConsumeCount + data.Name = purchaseInfo.Name + data.TimeToInvalid = purchaseInfo.TimeToInvalid + data.IsDailyRewardGet = purchaseInfo.IsDailyRewardGet + data.Id = purchaseInfo.Id + data.DailyRewardGoodsList = purchaseInfo.DailyRewardGoodsList + data.FirstRewardGoods = purchaseInfo.FirstRewardGoods + data.ExtraRewardGoods = purchaseInfo.ExtraRewardGoods + data.ClientResetInfo = purchaseInfo.ClientResetInfo + data.IsUseMail = purchaseInfo.IsUseMail or false + data.PayKeySuffix = purchaseInfo.PayKeySuffix + data.MailCount = purchaseInfo.MailCount + end + + -- 领奖(月卡) + function XPurchaseManager.PurchaseGetDailyRewardRequest(id, cb, failCb) + XNetwork.Call(PurchaseRequest.PurchaseGetDailyRewardReq, { Id = id }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + if failCb then + failCb() + end + return + end + + XPurchaseManager.GetRewardSuccess(id, res.PurchaseInfo) + + if cb then + cb(res.RewardList) + end + -- 设置月卡信息本地缓存 + XPurchaseManager.SetYKLoaclCache() + + XEventManager.DispatchEvent(XEventId.EVENT_CARD_REFRESH_WELFARE_BTN) + end) + end + + -- 领奖成功修正数据 + function XPurchaseManager.GetRewardSuccess(id, purchaseInfo) + XPurchaseManager.UpdateSingleData(id, purchaseInfo) + end + + -- 请求礼包数据 + function XPurchaseManager.LBInfoDataReq(cb) + local uiTypeList = XPurchaseConfigs.GetLBUiTypesList() + XPurchaseManager.GetPurchaseListRequest(uiTypeList, cb) + end + + -- 请求月卡数据 + function XPurchaseManager.YKInfoDataReq(cb) + local uiTypeList = XPurchaseConfigs.GetYKUiTypes() + XPurchaseManager.GetPurchaseListRequest(uiTypeList, cb) + end + + --这里用于查询互斥的月卡是否已经被购入过 + function XPurchaseManager.CheckMutexPurchaseYKBuy(uiType, id) + if MutexPurchaseDic[uiType] and MutexPurchaseDic[uiType][id] then + local MutexPurList = MutexPurchaseDic[uiType][id] + for _, kId in pairs(MutexPurList) do + return XPurchaseManager.IsYkBuyed(uiType, kId) + end + end + return false + end + + -- Get月卡数据 + function XPurchaseManager.GetYKInfoData(uitype, id) + if PurchaseInfoDataDic[uitype] and PurchaseInfoDataDic[uitype][id] then + return PurchaseInfoDataDic[uitype][id] + end + + return nil + end + + -- 获取当前已购买非邮件发放月卡数据(只能有一种已购买月卡) + -- 只能写死UiType类型:2 + function XPurchaseManager.GetCurBoughtYKData() + if PurchaseInfoDataDic[2] and next(PurchaseInfoDataDic[2]) then + for id, data in pairs(PurchaseInfoDataDic[2]) do + if not data.IsUseMail and XPurchaseManager.IsYkBuyed(2, id) then + return data + end + end + end + + return nil + end + + -- 是否已经买过了 + function XPurchaseManager.IsYkBuyed(uitype, id) + local data = XPurchaseManager.GetYKInfoData(uitype, id) + if not data then + return false + end + + return data.DailyRewardRemainDay > 0 + end + + function XPurchaseManager.FreeLBRed() + if not XPurchaseManager.CurFreeRewardId or not Next(XPurchaseManager.CurFreeRewardId) then + return false + end + + if not XPurchaseManager.CurBuyIds or not Next(XPurchaseManager.CurBuyIds) then + return true + end + + for _, id in pairs(XPurchaseManager.CurFreeRewardId) do + if not XPurchaseManager.CurBuyIds[id] then + return true + end + end + return false + end + + -- Notify + function XPurchaseManager.PurchaseDailyNotify(info) + XPurchaseManager.CurFreeRewardId = {} + if info and info.FreeRewardInfoList and Next(info.FreeRewardInfoList) then + for _, v in pairs(info.FreeRewardInfoList) do + XPurchaseManager.CurFreeRewardId[v.Id] = v.Id + end + end + + if info and info.ExpireInfoList and Next(info.ExpireInfoList) then + XPurchaseManager:UpdatePurchaseGiftValidTime(info.ExpireInfoList) + end + + -- 处理月卡红点 + if info and info.DailyRewardInfoList and Next(info.DailyRewardInfoList) then + for _, v in pairs(info.DailyRewardInfoList) do + if v.Id == XPurchaseConfigs.PurChaseCardId or v.Id == XPurchaseConfigs.PurChaseCardId1 then + XDataCenter.PurchaseManager.YKInfoDataReq(function() + XEventManager.DispatchEvent(XEventId.EVENT_CARD_REFRESH_WELFARE_BTN) + + -- 设置月卡信息本地缓存 + XDataCenter.PurchaseManager.SetYKLoaclCache() + XEventManager.DispatchEvent(XEventId.EVENT_DAYLY_REFESH_RECHARGE_BTN) + end) + end + end + end + end + + function XPurchaseManager:UpdatePurchaseGiftValidTime(expireInfoList) + local uiTypeList = XPurchaseConfigs.GetLBUiTypesList() + for _, v in pairs(expireInfoList) do + if v.Id == XPurchaseConfigs.PurChaseCardId then + XDataCenter.PurchaseManager.YKInfoDataReq(function() + XEventManager.DispatchEvent(XEventId.EVENT_CARD_REFRESH_WELFARE_BTN) + + -- 设置月卡信息本地缓存 + XDataCenter.PurchaseManager.SetYKLoaclCache() + XEventManager.DispatchEvent(XEventId.EVENT_DAYLY_REFESH_RECHARGE_BTN) + end) + end + end + if uiTypeList and Next(uiTypeList) ~= nil then + XPurchaseManager.GetPurchaseListRequest(uiTypeList, function() + XDataCenter.PurchaseManager.PurchaseGiftValidTimeCb(uiTypeList, expireInfoList) + end) + end + end + + function XPurchaseManager.PurchaseGiftValidTimeCb(uiTypeList, expireInfoList) + local datas = XPurchaseManager.GetDatasByUiTypes(uiTypeList) + -- local f = false--是否有一个礼包重新买了。 + local count = 0 + local LbExpireIds = XPurchaseManager.GetLbExpireIds() + if datas then + for _, v0 in pairs(expireInfoList) do + if XPurchaseConfigs.IsLBByPassID(v0.Id) then + for _, data in pairs(datas) do + for _, v1 in pairs(data) do + if v1.Id == v0.Id then + if v1.BuyTimes > 0 and v1.DailyRewardRemainDay > 0 then + if XPurchaseManager.HaveNewPlayerHint(v0.Id) then + LbExpireIds[v0.Id] = nil + end + else + if not XPurchaseManager.HaveNewPlayerHint(v0.Id) then + LbExpireIds[v0.Id] = v0.Id + count = count + 1 + end + end + end + end + end + end + end + end + + XPurchaseManager.SaveLBExpreIds(LbExpireIds) + XPurchaseManager.ExpireCount = count + + -- local f = count == 0 + -- if not f then + -- XEventManager.DispatchEvent(XEventId.EVENT_LB_EXPIRE_NOTIFY,count) + -- end + end + + function XPurchaseManager.HaveNewPlayerHint(id) + if not id then + return false + end + + local ids = XPurchaseManager.GetLbExpireIds() + return ids[id] ~= nil + end + + function XPurchaseManager.SaveLBExpreIds(ids) + if XPlayer.Id and ids then + local idsstr = "" + for _, v in pairs(ids) do + if v then + idsstr = idsstr .. v .. "_" + end + end + + local key = string.format("%s_%s", tostring(XPlayer.Id), LBExpireIdKey) + CS.UnityEngine.PlayerPrefs.SetString(key, idsstr) + CS.UnityEngine.PlayerPrefs.Save() + LBExpireIdDic = nil + end + end + + function XPurchaseManager.GetLbExpireIds() + if LBExpireIdDic then + return LBExpireIdDic + end + + if XPlayer.Id then + LBExpireIdDic = {} + local key = string.format("%s_%s", tostring(XPlayer.Id), LBExpireIdKey) + if CS.UnityEngine.PlayerPrefs.HasKey(key) then + local str = CS.UnityEngine.PlayerPrefs.GetString(key) or "" + for id in string.gmatch(str, "%d+") do + local v = tonumber(id) + LBExpireIdDic[v] = v + end + end + end + + return LBExpireIdDic + end + + -- 红点相关 + function XPurchaseManager.LBRedPoint() + local uiTypeList = XPurchaseConfigs.GetLBUiTypesList() + local datas = XPurchaseManager.GetDatasByUiTypes(uiTypeList) + PurchaseLbRedUiTypes = {} + if datas then + local f = false + for _, data in pairs(datas) do + for _, v in pairs(data) do + if v and v.ConsumeCount == 0 and v.PayKeySuffix == nil then + local curtime = XTime.GetServerNowTimestamp() + if (v.BuyTimes == 0 or v.BuyTimes < v.BuyLimitTimes) and (v.TimeToShelve == 0 or v.TimeToShelve < curtime) + and (v.TimeToUnShelve == 0 or v.TimeToUnShelve > curtime) then + f = true + PurchaseLbRedUiTypes[v.UiType] = v.UiType + end + end + end + end + return f + end + + return false + end + + function XPurchaseManager.LBRedPointUiTypes() + return PurchaseLbRedUiTypes + end + + -- 累计充值相关 + function XPurchaseManager.NotifyAccumulatedPayData(info) + if not info then + return + end + AccumulatedData.PayId = info.PayId or 0--累计充值id + AccumulatedData.PayMoney = info.PayMoney or 0--累计充值数量 + AccumulatedData.PayRewardIds = {}--已领取的奖励Id + if info.PayRewardIds then + for _, id in pairs(info.PayRewardIds) do + AccumulatedData.PayRewardIds[id] = id + end + end + end + + function XPurchaseManager.IsAccumulateEnterOpen() + return AccumulatedData.PayId and AccumulatedData.PayId > 0 and XFunctionManager.JudgeOpen(XFunctionManager.FunctionName.PurchaseAdd) + and not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.PurchaseAdd) + end + + function XPurchaseManager.NotifyAccumulatedPayMoney(info) + if not info then + return + end + + AccumulatedData.PayMoney = info.PayMoney + XEventManager.DispatchEvent(XEventId.EVENT_ACCUMULATED_UPDATE) + end + + -- 累计充值数量 + function XPurchaseManager.GetAccumulatedPayCount() + return math.floor(AccumulatedData.PayMoney or 0) + end + + -- 领取累计充值奖励 + function XPurchaseManager.GetAccumulatePayReq(payid, rewardid, cb) + if not payid or not rewardid then + return + end + + XNetwork.Call("GetAccumulatePayRequest", { PayId = payid, RewardId = rewardid }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + AccumulatedData.PayRewardIds[rewardid] = rewardid + local rewardGoodsList = res.RewardGoodsList + if rewardGoodsList and Next(rewardGoodsList) then + XUiManager.OpenUiObtain(rewardGoodsList) + if cb then + cb(rewardGoodsList) + end + end + --CheckPoint: APPEVENT_TOTAL_PURCHASE + XAppEventManager.AccumulatePayAppLogEvent(rewardid) + XEventManager.DispatchEvent(XEventId.EVENT_ACCUMULATED_REWARD) + end + ) + end + + -- 奖励是否已经领过 + function XPurchaseManager.AccumulateRewardGeted(id) + if not id then + return false + end + + return AccumulatedData.PayRewardIds[id] ~= nil + end + + -- 取当前累计充值id + function XPurchaseManager.GetAccumulatePayId() + return AccumulatedData.PayId + end + + -- 累计充值奖励 + function XPurchaseManager.GetAccumulatePayConfig() + local id = AccumulatedData.PayId + if not id or id < 0 then + return + end + + return XPurchaseConfigs.GetAccumulatePayConfigById(id) + end + + function XPurchaseManager.GetAccumulatePayTimeStr() + local id = AccumulatedData.PayId + if not id or id < 0 then + return + end + + local config = XPurchaseConfigs.GetAccumulatePayConfigById(id) + if config.Type == XPurchaseConfigs.PayAddType.Forever then + return + end + + local beginTime, endTime = XFunctionManager.GetTimeByTimeId(config.TimeId) + return XTime.TimestampToGameDateTimeString(beginTime), XTime.TimestampToGameDateTimeString(endTime) + end + + -- 累计充值奖励红点 + function XPurchaseManager.AccumulatePayRedPoint() + local id = AccumulatedData.PayId + if not id or id < 0 then + return false + end + + local payconfig = XPurchaseConfigs.GetAccumulatePayConfigById(id) + if payconfig then + local rewardsId = payconfig.PayRewardId + if rewardsId or Next(rewardsId) then + for _, tmpId in pairs(rewardsId) do + local payrewardconfig = XPurchaseConfigs.GetAccumulateRewardConfigById(tmpId) + local count = AccumulatedData.PayMoney + if payrewardconfig and payrewardconfig.Money then + if payrewardconfig.Money <= count then + if not XPurchaseManager.AccumulateRewardGeted(tmpId) then + return true + end + end + end + end + end + end + return false + end + + function XPurchaseManager.PurchaseResponse(data) + if data.RewardList and data.RewardList[1] and Next(data.RewardList[1]) then + XUiManager.OpenUiObtain(data.RewardList) + else + XUiManager.TipText("PurchaseLBBuySuccessTips") + end + if data.PurchaseInfo and (data.PurchaseInfo.UiType == XPurchaseConfigs.YKType.Month) then + if data and data.PurchaseInfo and data.PurchaseInfo.DailyRewardGoodsList and #data.PurchaseInfo.DailyRewardGoodsList > 0 then + XDataCenter.PurchaseManager.PurchaseGetDailyRewardRequest(data.Id, function(rewardItems) + XUiManager.OpenUiObtain(rewardItems) --海外定制:自动领取月卡时候弹窗 + end) + end + end + + XPurchaseManager.PurchaseSuccess(data.Id, data.PurchaseInfo, data.NewPurchaseInfoList) + XEventManager.DispatchEvent(XEventId.EVENT_CARD_REFRESH_WELFARE_BTN) + XEventManager.DispatchEvent(XEventId.EVENT_PURCAHSE_BUYUSERIYUAN) + XEventManager.DispatchEvent(XEventId.EVENT_LB_UPDATE) + XDataCenter.PayManager.ClearCurrentPayId(data.Id) + end + + function XPurchaseManager.PurchaseAddRewardState(id) + if not id then + return + end + + local itemData = XPurchaseConfigs.GetAccumulateRewardConfigById(id) + if not itemData then + return + end + + local money = itemData.Money + local count = XPurchaseManager.GetAccumulatedPayCount() + if count >= money then + if not XPurchaseManager.AccumulateRewardGeted(id) then + --能领,没有领。 + return XPurchaseConfigs.PurchaseRewardAddState.CanGet + else + --已经领 + return XPurchaseConfigs.PurchaseRewardAddState.Geted + end + else + --退款 + if XPurchaseManager.AccumulateRewardGeted(id) then + --已经领 + return XPurchaseConfigs.PurchaseRewardAddState.Geted + end + --不能领,钱不够。 + return XPurchaseConfigs.PurchaseRewardAddState.CanotGet + end + end + + -- 月卡继续购买红点相关 + function XPurchaseManager.SetYKLoaclCache() + local data = XPurchaseManager.GetCurBoughtYKData() + if not data then + return + end + + local key = XPrefs.YKLocalCache .. tostring(XPlayer.Id) + local count = 0 + if CS.UnityEngine.PlayerPrefs.HasKey(key) then + count = CS.UnityEngine.PlayerPrefs.GetInt(key) + else + CS.UnityEngine.PlayerPrefs.SetInt(key, count) + end + + if data.DailyRewardRemainDay and count ~= data.DailyRewardRemainDay then + local continueBuyDays = XPurchaseConfigs.PurYKContinueBuyDays + if data.DailyRewardRemainDay > continueBuyDays then + CS.UnityEngine.PlayerPrefs.SetInt(key, data.DailyRewardRemainDay) + end + + if count > 0 and data.DailyRewardRemainDay <= continueBuyDays then + IsYKShowConitnueBuy = true + else + IsYKShowConitnueBuy = false + end + end + end + + -- 检查是否显示购买月卡红点 + function XPurchaseManager.CheckYKContinueBuy() + if not IsYKShowConitnueBuy then + return IsYKShowConitnueBuy + end + + local key = XPrefs.YKContinueBuy .. tostring(XPlayer.Id) + if CS.UnityEngine.PlayerPrefs.HasKey(key) then + local time = CS.UnityEngine.PlayerPrefs.GetString(key) + local now = XTime.GetServerNowTimestamp() + local todayFreshTime = XTime.GetSeverTodayFreshTime() + local yesterdayFreshTime = XTime.GetSeverYesterdayFreshTime() + local tempTime = now >= todayFreshTime and todayFreshTime or yesterdayFreshTime + return tostring(tempTime) ~= time + else + return true + end + end + + -- 设置当日购买月卡红点已读 + function XPurchaseManager.SetYKContinueBuy() + local key = XPrefs.YKContinueBuy .. tostring(XPlayer.Id) + local now = XTime.GetServerNowTimestamp() + local todayFreshTime = XTime.GetSeverTodayFreshTime() + local yesterdayFreshTime = XTime.GetSeverYesterdayFreshTime() + local tempTime = now >= todayFreshTime and todayFreshTime or yesterdayFreshTime + CS.UnityEngine.PlayerPrefs.SetString(key, tostring(tempTime)) + + local data = XPurchaseManager.GetCurBoughtYKData() + if not data then + return + end + + local cachaeKey = XPrefs.YKLocalCache .. tostring(XPlayer.Id) + if data.DailyRewardRemainDay <= 0 then + CS.UnityEngine.PlayerPrefs.SetInt(cachaeKey, data.DailyRewardRemainDay) + end + end + + -- 获取折扣值 0-1 的值 + function XPurchaseManager.GetLBDiscountValue(lbData) + local buyTimes = lbData.BuyTimes + local normalDiscounts = lbData.NormalDiscounts + local disCountValue = 1 + if not normalDiscounts or #normalDiscounts <= 0 then + disCountValue = 1 + else + for i = buyTimes, 0, -1 do + local curTimes = i + 1 + if normalDiscounts[curTimes] then + disCountValue = normalDiscounts[curTimes] / 10000 + break + end + end + end + + return disCountValue + end + + function XPurchaseManager.GetLBCouponDiscountValue(lbData, index) + if not lbData.DiscountCouponInfos then + return nil + end + + if not lbData.DiscountCouponInfos[index] then + return nil + end + + return lbData.DiscountCouponInfos[index].Value / 10000 + end + + function XPurchaseManager.RemoveNotInTimeDiscountCoupon(lbData) + if not lbData.DiscountCouponInfos or #lbData.DiscountCouponInfos <= 0 then + return + end + + local nowTime = XTime.GetServerNowTimestamp() + for i=#lbData.DiscountCouponInfos, 1, -1 do + local startTime = lbData.DiscountCouponInfos[i].BeginTime + local endTime = lbData.DiscountCouponInfos[i].EndTime + if nowTime < startTime or nowTime > endTime then + table.remove(lbData.DiscountCouponInfos, i) + end + end + end + + function XPurchaseManager.GetPurchaseData(uitype, id) + local payuitypes = XPurchaseConfigs.GetPayUiTypes() + local infos + if payuitypes[uitype] then + infos = XPayConfigs.GetPayConfig() + for _, v in pairs(infos or {}) do + if v.Id == id then + return v + end + end + end + infos = PurchaseInfosData[uitype] + for _, v in pairs(infos or {}) do + if v.Id == id then + return v + end + end + end + + function XPurchaseManager.GetPurchaseMaxBuyCount(purchaseData) + local buyTimes = purchaseData.BuyTimes + local maxBuyTimes = nil + if purchaseData.BuyLimitTimes and purchaseData.BuyLimitTimes > 0 then -- 限购数量 + maxBuyTimes = purchaseData.BuyLimitTimes - buyTimes + end + + if purchaseData.NormalDiscounts then -- 存在打折 + local curTimes = buyTimes + 1 + local lastDiscountAreaTimes = 0 -- 下一个打折区间次数 + for times, _ in pairs(purchaseData.NormalDiscounts) do + if curTimes < times then + if lastDiscountAreaTimes == 0 then + lastDiscountAreaTimes = times + else + if lastDiscountAreaTimes > times then + lastDiscountAreaTimes = times + end + end + end + end + + if lastDiscountAreaTimes ~= 0 then + local canBuyCountByDiscount = lastDiscountAreaTimes - curTimes + if maxBuyTimes > canBuyCountByDiscount then + maxBuyTimes = canBuyCountByDiscount + end + end + end + + return maxBuyTimes + end + + XPurchaseManager.Init() + return XPurchaseManager +end + +XRpc.PurchaseDailyNotify = function(info) + XDataCenter.PurchaseManager.PurchaseDailyNotify(info) +end + +XRpc.NotifyAccumulatedPayData = function(info) + XDataCenter.PurchaseManager.NotifyAccumulatedPayData(info) +end + +XRpc.NotifyAccumulatedPayMoney = function(info) + XDataCenter.PurchaseManager.NotifyAccumulatedPayMoney(info) +end + +XRpc.PurchaseResponse = function(info) + XDataCenter.PurchaseManager.PurchaseResponse(info) +end diff --git a/Resources/Scripts/XManager/XPuzzleActivityManager.lua b/Resources/Scripts/XManager/XPuzzleActivityManager.lua new file mode 100644 index 00000000..56633acb --- /dev/null +++ b/Resources/Scripts/XManager/XPuzzleActivityManager.lua @@ -0,0 +1,192 @@ +XPuzzleActivityManagerCreator = function() + local ParseToTimestamp = XTime.ParseToTimestamp + local CSUnityEnginePlayerPrefs = CS.UnityEngine.PlayerPrefs + local CSGameEventManager = CS.XGameEventManager.Instance + local XPuzzleActivityData = require("XEntity/XPuzzleActivityData") + local PuzzleActivityGroupInfos = nil + local PuzzleActivityPiecesData = {} + local PiecesFlipRedPointCount = {} + local IsPuzzleActivityHaveReward = {} + local ItemIdToActId = {} + + local XPuzzleActivityManager = {} + local ActRpc = { + PuzzleActData = "PuzzleActivityDataRequest", --获得活动数据 + PuzzleActFlipPiece = "PuzzleActivityFlipPieceRequest", --获得碎片翻转数据 + PuzzleActGetReward = "PuzzleActivityGetRewardRequest", --请求获得奖励 + } + + function XPuzzleActivityManager.Init() + XEventManager.AddEventListener(XEventId.EVENT_LOGIN_DATA_LOAD_COMPLETE, function() + XPuzzleActivityManager.InitPuzzleActivityGroupInfos() + end) + end + + --构建拼图活动组 + function XPuzzleActivityManager.InitPuzzleActivityGroupInfos() + PuzzleActivityGroupInfos = {} + local activityGroupTemplates = XPuzzleActivityConfigs.GetTemplates() + for actId, activity in pairs(activityGroupTemplates) do + PuzzleActivityGroupInfos[actId] = XPuzzleActivityData.New(actId) + XPuzzleActivityManager.InitEventListener(actId) + end + end + + function XPuzzleActivityManager.InitEventListener(actId) + local activity = PuzzleActivityGroupInfos[actId] + local id = XDataCenter.ActivityManager.PuzzleActIdToActId(actId) + if XDataCenter.ActivityManager.IsActivityOpen(id) then + XPuzzleActivityManager.PuzzleActivityDataRequest(actId) + for _,piece in pairs(activity.PieceCfgs) do + ItemIdToActId[piece.ItemId] = actId + XEventManager.AddEventListener(XEventId.EVENT_ITEM_COUNT_UPDATE_PREFIX .. piece.ItemId, XPuzzleActivityManager.OnEventItemCountChange) + end + end + end + + function XPuzzleActivityManager.OnEventItemCountChange(itemId) + XPuzzleActivityManager.PuzzleActivityDataRequest(ItemIdToActId[itemId]) + end + + --获取拼图活动服务端状态 + function XPuzzleActivityManager.PuzzleActivityDataRequest(id, cb) + XNetwork.Call(ActRpc.PuzzleActData, { Id = id }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XPuzzleActivityManager.HandlePuzzleActivityData(id, res.PieceStates, res.RewardState) + CSGameEventManager:Notify(XEventId.EVENT_ACTIVITY_INFO_UPDATE, XActivityConfigs.ActivityType.JigsawPuzzle) + XEventManager.DispatchEvent(XEventId.EVENT_ACTIVITY_INFO_UPDATE) + if cb then + cb() + end + end) + end + + function XPuzzleActivityManager.HandlePuzzleActivityData(id, pieceStates, rewardState) + local condition = XPuzzleActivityConfigs.PuzzleCondition + local puzzleActData = XPuzzleActivityManager.GetActivityPuzzleTemplateById(id) + PiecesFlipRedPointCount[id] = 0 + local collectComplete = true + --for i = 1,#puzzleActData.PieceCfgs do + for index, template in ipairs(puzzleActData.PieceCfgs) do + pieceStates[index] = pieceStates[index] or condition.NotCollected + if pieceStates[index] == condition.NotCollected then + if XDataCenter.ItemManager.CheckItemCountById( + template.ItemId, template.ItemCount) then + pieceStates[index] = condition.Inactivated + PiecesFlipRedPointCount[id] = PiecesFlipRedPointCount[id] + 1 + end + end + if pieceStates[index] ~= condition.Activated then + collectComplete = false + end + end + if next(pieceStates) then + PuzzleActivityPiecesData[id] = pieceStates + end + if rewardState == XPuzzleActivityConfigs.PuzzleRewardState.Unrewarded and collectComplete then + rewardState = XPuzzleActivityConfigs.PuzzleRewardState.CanReward + IsPuzzleActivityHaveReward[id] = true + end + puzzleActData:SetRewardState(rewardState) + end + + function XPuzzleActivityManager.HandlePuzzlePieceData(id, pieceId, state) + local condition = XPuzzleActivityConfigs.PuzzleCondition + local puzzleActData = XPuzzleActivityManager.GetActivityPuzzleTemplateById(id) + if state ~= condition.Activated then + return + end + if pieceId then + PuzzleActivityPiecesData[id][pieceId] = state + end + PiecesFlipRedPointCount[id] = PiecesFlipRedPointCount[id] - 1 + local collectComplete = true + for k,v in ipairs(PuzzleActivityPiecesData[id])do + if v ~= condition.Activated then + collectComplete = false + end + end + if collectComplete then + puzzleActData:SetRewardState(XPuzzleActivityConfigs.PuzzleRewardState.CanReward) + end + end + + function XPuzzleActivityManager.HandlePuzzleRewardData(id, state) + local puzzleActData = XPuzzleActivityManager.GetActivityPuzzleTemplateById(id) + puzzleActData:SetRewardState(state) + if state == XPuzzleActivityConfigs.PuzzleRewardState.Rewarded then + IsPuzzleActivityHaveReward[id] = false + end + end + + --请求翻牌 + function XPuzzleActivityManager.PuzzleActivityFlipPieceRequest(id, pieceId, cb) + XNetwork.Call(ActRpc.PuzzleActFlipPiece, { Id = id, PieceId = pieceId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XPuzzleActivityManager.HandlePuzzlePieceData(id, res.PieceId, res.State) + CSGameEventManager:Notify(XEventId.EVENT_ACTIVITY_INFO_UPDATE, XActivityConfigs.ActivityType.JigsawPuzzle) + XEventManager.DispatchEvent(XEventId.EVENT_ACTIVITY_INFO_UPDATE) + if cb then + cb() + end + end) + end + + -- 领取奖励 + function XPuzzleActivityManager.PuzzleActivityGetRewardRequest(id, cb) + XNetwork.Call(ActRpc.PuzzleActGetReward, { Id = id }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XPuzzleActivityManager.HandlePuzzleRewardData(id, res.RewardState) + if cb then + cb(res.RewardGoods) + end + CSGameEventManager:Notify(XEventId.EVENT_ACTIVITY_INFO_UPDATE, XActivityConfigs.ActivityType.JigsawPuzzle) + XEventManager.DispatchEvent(XEventId.EVENT_ACTIVITY_INFO_UPDATE) + end) + end + + function XPuzzleActivityManager.GetActivityPuzzleTemplateById(puzzleId) + return PuzzleActivityGroupInfos[puzzleId] + end + + function XPuzzleActivityManager.GetPieceAmountById(id) + return PuzzleActivityGroupInfos[id]:GetPieceAmount() + end + + function XPuzzleActivityManager.GetPieceTemplate(id, index) + return PuzzleActivityGroupInfos[id].PieceCfgs[index] + end + + function XPuzzleActivityManager.GetPuzzleActPieceData(id, index) + return PuzzleActivityPiecesData[id][index] + end + + function XPuzzleActivityManager.IsHaveRedPointById(id) + return IsPuzzleActivityHaveReward[id] or (PiecesFlipRedPointCount[id] and PiecesFlipRedPointCount[id] > 0) + end + + function XPuzzleActivityManager.IsHaveRedPoint() + for _,v in pairs(IsPuzzleActivityHaveReward) do + if v == true then + return true + end + end + for _,v in pairs(PiecesFlipRedPointCount) do + if v > 0 then + return true + end + end + end + + XPuzzleActivityManager.Init() + return XPuzzleActivityManager +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XRTextureManager.lua b/Resources/Scripts/XManager/XRTextureManager.lua new file mode 100644 index 00000000..75c6bba9 --- /dev/null +++ b/Resources/Scripts/XManager/XRTextureManager.lua @@ -0,0 +1,33 @@ +XRTextureManager = XRTextureManager or {} + + +local RTextureCache = nil + + +function XRTextureManager.SetTextureCache(rtImg) + --if not RTextureCache then + -- local screenWid = CS.XUiManager.RealScreenWidth + -- local screenHei = CS.XUiManager.RealScreenHeight + -- RTextureCache = CS.UnityEngine.RenderTexture(screenWid,screenHei,24) + -- RTextureCache.antiAliasing = 2 + --end + --XRTextureManager.SetCamerRT() + --rtImg.texture = RTextureCache + --rtImg.gameObject:SetActive(true) + rtImg.gameObject:SetActive(false) +end + +function XRTextureManager.ClearCamerRT() + --local cameraRest = CS.XUiManager.UiModelCamera + --cameraRest.targetTexture = nil +end + +function XRTextureManager.SetCamerRT() + --local cameraRest = CS.XUiManager.UiModelCamera + --cameraRest.targetTexture = RTextureCache +end + +function XRTextureManager.DeleteTextureCache() + if not RTextureCache then return end + RTextureCache = nil +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XRedPointManager.lua b/Resources/Scripts/XManager/XRedPointManager.lua new file mode 100644 index 00000000..7dd12d47 --- /dev/null +++ b/Resources/Scripts/XManager/XRedPointManager.lua @@ -0,0 +1,189 @@ +--红点管理器 +XRedPointManager = XRedPointManager or {} +require("XRedPoint/XRedPointConditions") + +local RedPointEventDic = {} +local RedPointFiitterEvents = {} +local eventIdPool = 0 + +function XRedPointManager.Init() + RedPointEventDic = RedPointEventDic or {} + RedPointFiitterEvents = RedPointFiitterEvents or {} +end + +--添加过滤 +function XRedPointManager.AddRedPointFitterEvent(conditionId) + if not XRedPointManager[conditionId] then + XLog.Warning("Event type not found :" .. conditionId) + return + end + + RedPointFiitterEvents = RedPointFiitterEvents or {} + RedPointFiitterEvents[conditionId] = conditionId +end + +--移除过滤 +function XRedPointManager.RemoveRedPointFitterEvent(conditionId) + if not RedPointFiitterEvents or not RedPointFiitterEvents[conditionId] then + return + end + + RedPointFiitterEvents[conditionId] = nil +end + + +function XRedPointManager.GenarateEventId() + eventIdPool = eventIdPool + 1 + return eventIdPool +end + +--增加一个红点事件 +function XRedPointManager.AddRedPointEvent(node, func, listener, conditionGroup, args, isCheck) + + if not node then + XLog.Warning("该绑定节点为空,需要检查UI预设") + return + end + + local eventId = XRedPointManager.GenarateEventId() + + --创建一个事件组 + local condition = XRedPointConditionGroup.New(conditionGroup) + + --创建监听者 + local pointListener = XRedPointListener.New() + pointListener.listener = listener + pointListener.func = func + + --创建红点事件 + local pointEvent = XRedPointEvent.New(eventId, node, condition, pointListener, args) + RedPointEventDic[eventId] = pointEvent + + if isCheck == nil or isCheck == true then + XRedPointManager.Check(eventId) + end + + return eventId +end + +--删除一个红点事件 +function XRedPointManager.RemoveRedPointEvent(eventId) + + if RedPointEventDic == nil or not RedPointEventDic[eventId] then + return + end + + local pointEvent = RedPointEventDic[eventId] + if pointEvent then + pointEvent:Release() + end + + RedPointEventDic[eventId] = nil +end + +--删除一个红点事件 +function XRedPointManager.RemoveRedPointEventOnly(eventId) + if RedPointEventDic == nil or not RedPointEventDic[eventId] then + return + end + + RedPointEventDic[eventId] = nil +end + +--检测红点 +function XRedPointManager.Check(eventId, args) + if not eventId or eventId <= 0 then + return + end + + if RedPointEventDic == nil or not RedPointEventDic[eventId] then + return + end + + local pointEvent = RedPointEventDic[eventId] + + if pointEvent then + pointEvent:Check(args) + end +end + +--检测红点,直接判断不持有节点 +function XRedPointManager.CheckOnce(func, listener, conditionGroup, args) + local result = -1 + + for _, v in ipairs(conditionGroup) do + if XRedPointConditions[v] ~= nil then + if not XRedPointManager.CheckIsFitter(v) then + + local r = XRedPointConditions[v].Check(args) + + if type(r) == "number" then + result = result + r + elseif r == true and result == -1 then + result = 0 + end + + end + end + end + + if func then + func(listener, result, args) + end +end + +function XRedPointManager.CheckOnceByButton(button, conditionGroup, args) + XRedPointManager.CheckOnce(function(_, count) + button:ShowReddot(count >= 0) + end, nil , conditionGroup,args) +end + +--检测红点通过节点 +function XRedPointManager.CheckByNode(node, args) + if RedPointEventDic == nil then + return + end + + local redPointEvent = nil + for _, v in pairs(RedPointEventDic) do + if v:CheckNode() and v.node == node then + redPointEvent = v + break + end + end + + if redPointEvent then + redPointEvent:Check(args) + end +end + +--检测红点过滤 +function XRedPointManager.CheckIsFitter(conditionId) + if not RedPointFiitterEvents then + return false + end + + if not RedPointFiitterEvents[conditionId] then + return false + end + + return true +end + +--自动释放 +function XRedPointManager.AutoReleseRedPointEvent() + if not RedPointEventDic then + return + end + + local removeEvents = {} + for _, v in pairs(RedPointEventDic) do + if not v:CheckNode() then + table.insert(removeEvents, v) + end + end + + for _, v in ipairs(removeEvents) do + XRedPointManager.RemoveRedPointEvent(v.id) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XReformActivityManager.lua b/Resources/Scripts/XManager/XReformActivityManager.lua new file mode 100644 index 00000000..3a5f9034 --- /dev/null +++ b/Resources/Scripts/XManager/XReformActivityManager.lua @@ -0,0 +1,555 @@ +local XRobot = require("XEntity/XRobot/XRobot") +local XReformBaseStage = require("XEntity/XReform/XReformBaseStage") + +XReformActivityManagerCreator = function() + local Debug = false + local XReformActivityManager = {} + -- XReformBaseStage 基础关卡数据 + local BaseStageDic = {} + -- XReformConfigs.ActivityConfig + local Config = nil + -- 当前打开的关卡id + -- 默认拿第一关,如果服务器有返回拿最后到达的关卡 + local CurrentStageId = XReformConfigs.GetStageConfigIds()[1] + -- 是否已经发起进入请求,用来避免重复请求 + local IsEnterRequest = false + -- 记录所有改造关卡最大分数字典数据,主要用来检测小红点 + local EvolvableStageMaxScoreDic = {} + local EvolvableStageMaxScoreHistoryDic = nil + local BaseStageRedDotHistoryDic = nil + local EvolvableStageMaxScoreHistoryDicKey = nil + local BaseStageRedDotHistoryDicKey = nil + -- 接口定义 + local NetApiDic = { + EnterRequest = "FubenReformEnterRequest", + EnemyReplaceRequest = "ReformEnemyRequest", + MemberReplaceRequest = "ReformMemberRequest", + BuffUpdateRequest = "ReformAdditionRequest", + EnvironmentUpdateRequest = "ReformEnvRequest", + ChageStageDiffRequest = "ReformChangeStageDiffRequest", + } + + function XReformActivityManager.GetAvailableChapters() + local result = {} + if not XReformActivityManager.GetIsOpen() then + return result + end + table.insert(result, { + Id = Config.Id, + Type = XDataCenter.FubenManager.ChapterType.Reform, + Name = XReformActivityManager.GetActivityName(), + Icon = XReformActivityManager.GetBannerIcon(), + }) + return result + end + + function XReformActivityManager.GetActivityName() + return Config.Name + end + + function XReformActivityManager.GetId() + return Config.Id + end + + function XReformActivityManager.GetBannerIcon() + return Config.BannerIcon + end + + function XReformActivityManager.GetHelpName() + return Config.HelpName + end + + function XReformActivityManager.GetScoreHelpName() + return Config.ScoreHelpName + end + + function XReformActivityManager.GetScoreItemId() + if Config == nil then return -1 end + return Config.ScoreItemId + end + + function XReformActivityManager.GetTaskFinishScore(taskId) + local conditionConfig = XTaskConfig.GetTaskConditionConfigs(taskId)[1] + if conditionConfig == nil then + return 0 + end + if #conditionConfig.Params <= 0 then + return 0 + end + return conditionConfig.Params[1] + end + + -- 获取玩法剩余时间 + function XReformActivityManager.GetLeaveTimeStr() + local endTime = XFunctionManager.GetEndTimeByTimeId(Config.OpenTimeId) + local nowTime = XTime.GetServerNowTimestamp() + return XUiHelper.GetTime(endTime - nowTime, XUiHelper.TimeFormatType.ACTIVITY) + end + + function XReformActivityManager.HandleActivityEndTime() + XLuaUiManager.RunMain() + XUiManager.TipError(CS.XTextManager.GetText("ReformAtivityTimeEnd")) + end + + function XReformActivityManager.GetActivityStartTime() + if Config == nil then return 0 end + return XFunctionManager.GetStartTimeByTimeId(Config.OpenTimeId) + end + + function XReformActivityManager.GetActivityEndTime() + if Config == nil then return 0 end + return XFunctionManager.GetEndTimeByTimeId(Config.OpenTimeId) + end + + -- 获取玩法当前进度 + function XReformActivityManager.GetCurrentProgress() + local result = 0 + for _, baseStage in pairs(BaseStageDic) do + if baseStage:GetIsPassed() then + result = result + 1 + end + end + return result + end + + -- 获取玩法最大进度 + function XReformActivityManager.GetMaxProgress() + return #XReformConfigs.GetStageConfigIds() + end + + -- 获取任务奖励最大分数 + function XReformActivityManager.GetTaskMaxScore() + local maxScore = 0 + -- local taskDatas = XReformActivityManager.GetTaskDatas() + -- local maxTaskScore = XReformActivityManager.GetTaskFinishScore(taskDatas[#taskDatas].Id) + for _, baseStage in pairs(BaseStageDic) do + for _, evolvableStage in pairs(baseStage:GetEvolvableStageDic()) do + maxScore = maxScore + evolvableStage:GetMaxScore() + -- if maxScore >= maxTaskScore then + -- return maxTaskScore + -- end + end + end + return maxScore + end + + function XReformActivityManager.GetAllStageAccumulativeScore() + local result = 0 + for _, baseStage in pairs(BaseStageDic) do + result = result + baseStage:GetAccumulativeScore() + end + return result + end + + -- 获取当前战斗队伍数据 + function XReformActivityManager.GetFightTeam() + -- PS:TeamId来源于Config.tab和TeamType.tab + return XDataCenter.TeamManager.GetPlayerTeam(CS.XGame.Config:GetInt("TypeIdReform")) + end + + function XReformActivityManager.GetBaseStages() + local configIds = XReformConfigs.GetStageConfigIds() + local result = {} + local baseStage = nil + for _, id in pairs(configIds) do + baseStage = XReformActivityManager.GetBaseStage(id) + table.insert(result, baseStage) + end + return result + end + + function XReformActivityManager.CheckBaseStageIsShowRedDot(baseStageId) + if Config == nil then return false end + if baseStageId ~= nil then + return XReformActivityManager.CheckBaseStageIsShowRedDotInner(baseStageId) + else + for stageId, config in pairs(XReformConfigs.GetStageConfigDic()) do + if XReformActivityManager.CheckBaseStageIsShowRedDotInner(stageId) then + return true + end + end + end + return false + end + + function XReformActivityManager.CheckBaseStageIsShowRedDotInner(baseStageId) + if Config == nil then return false end + -- 如果有历史记录的话根据是否有改造难度开启 + if XReformActivityManager.GetBaseStageRedDotHistory(baseStageId) then + return XReformActivityManager.CheckEvolvableDiffIsShowRedDot(baseStageId) + end + local config = XReformConfigs.GetStageConfigById(baseStageId) + return XFunctionManager.CheckInTimeByTimeId(config.OpenTimeId) + end + + function XReformActivityManager.SetBaseStageRedDotHistory(baseStageId) + if BaseStageRedDotHistoryDic == nil then + BaseStageRedDotHistoryDic = {} + end + BaseStageRedDotHistoryDic[baseStageId] = true + XSaveTool.SaveData(BaseStageRedDotHistoryDicKey, BaseStageRedDotHistoryDic) + end + + function XReformActivityManager.GetBaseStageRedDotHistory(baseStageId) + if BaseStageRedDotHistoryDic == nil then + return false + end + return BaseStageRedDotHistoryDic[baseStageId] or false + end + + function XReformActivityManager.CheckEvolvableDiffIsShowRedDot(baseStageId, evolvableDiffIndex) + if Config == nil then return false end + if baseStageId ~= nil and evolvableDiffIndex ~= nil then + if XReformActivityManager.GetEvolableStageRedDotHistory(baseStageId, evolvableDiffIndex) then + return false + end + return XReformActivityManager.GetDifficultyIsOpen(baseStageId, evolvableDiffIndex) + elseif baseStageId ~= nil and evolvableDiffIndex == nil then + for i = 2, 4 do + if not XReformActivityManager.GetEvolableStageRedDotHistory(baseStageId, i) + and XReformActivityManager.GetDifficultyIsOpen(baseStageId, i) then + return true + end + end + else + for stageId, _ in pairs(XReformConfigs.GetStageConfigDic()) do + for i = 2, 4 do + if not XReformActivityManager.GetEvolableStageRedDotHistory(stageId, i) + and XReformActivityManager.GetDifficultyIsOpen(stageId, i) then + return true + end + end + end + end + return false + end + + function XReformActivityManager.SetEvolableStageRedDotHistory(baseStageId, diffIndex) + if EvolvableStageMaxScoreHistoryDic == nil then + EvolvableStageMaxScoreHistoryDic = {} + end + EvolvableStageMaxScoreHistoryDic[baseStageId] = EvolvableStageMaxScoreHistoryDic[baseStageId] or {} + EvolvableStageMaxScoreHistoryDic[baseStageId][diffIndex] = true + XSaveTool.SaveData(EvolvableStageMaxScoreHistoryDicKey, EvolvableStageMaxScoreHistoryDic) + end + + function XReformActivityManager.GetEvolableStageRedDotHistory(baseStageId, diffIndex) + if EvolvableStageMaxScoreHistoryDic == nil then + return false + end + if not EvolvableStageMaxScoreHistoryDic[baseStageId] then + return false + end + if not EvolvableStageMaxScoreHistoryDic[baseStageId][diffIndex] then + return false + end + return true + end + + function XReformActivityManager.GetDifficultyIsOpen(baseStageId, evolvableDiffIndex) + local baseStageConfig = XReformConfigs.GetStageConfigById(baseStageId) + -- 是否已经通关了基础关卡 + if EvolvableStageMaxScoreDic[baseStageId] == nil or + EvolvableStageMaxScoreDic[baseStageId][1] == nil then + return false + end + if not XReformActivityManager.GetBaseStage(baseStageId):GetIsPassed() then + return false + end + local nextEvolvableStageId = baseStageConfig.StageDiff[evolvableDiffIndex] + local nextEvolvableStageConfig = XReformConfigs.GetStageDiffConfigById(nextEvolvableStageId) + return XReformActivityManager.GetEvolvableMaxScore(baseStageId, evolvableDiffIndex - 1) + >= nextEvolvableStageConfig.UnlockScore + end + + function XReformActivityManager.GetCurrentBaseStage() + return XReformActivityManager.GetBaseStage(CurrentStageId) + end + + function XReformActivityManager.GetCurrentBaseStageId() + return CurrentStageId + end + + function XReformActivityManager.SetCurrentBaseStageId(value) + CurrentStageId = value + end + + function XReformActivityManager.GetBaseStage(id) + local baseStage = BaseStageDic[id] + if baseStage == nil then + local config = XReformConfigs.GetStageConfigById(id) + baseStage = XReformBaseStage.New(config) + BaseStageDic[id] = baseStage + end + return baseStage + end + + function XReformActivityManager.GetTaskDatas() + local result = XDataCenter.TaskManager.GetTaskList(TaskType.Reform) + table.sort(result, function(taskA, taskB) + return taskA.Id < taskB.Id + end) + return result + end + + function XReformActivityManager.AddEvolvableMaxScore(baseStageId, diffIndex, maxScore) + EvolvableStageMaxScoreDic[baseStageId] = EvolvableStageMaxScoreDic[baseStageId] or {} + EvolvableStageMaxScoreDic[baseStageId][diffIndex] = maxScore + end + + function XReformActivityManager.GetEvolvableMaxScore(baseStageId, diffIndex) + if not EvolvableStageMaxScoreDic[baseStageId] then + return 0 + end + if not EvolvableStageMaxScoreDic[baseStageId][diffIndex] then + return 0 + end + return EvolvableStageMaxScoreDic[baseStageId][diffIndex] + end + + --######################## 代理副本接口 ######################## + + function XReformActivityManager.InitStageInfo() + local stageConfigs = XReformConfigs.GetStageConfigDic() + local stageInfo = nil + for _, config in pairs(stageConfigs) do + stageInfo = XDataCenter.FubenManager.GetStageInfo(config.Id) + stageInfo.Type = XDataCenter.FubenManager.StageType.Reform + end + end + + function XReformActivityManager.PreFight(stage, teamId, isAssist, challengeCount, challengeId) + local baseStage = XReformActivityManager.GetBaseStage(stage.StageId) + local evolvableStage = baseStage:GetCurrentEvolvableStage() + local teamData = evolvableStage:GetTeamData() + local memberGroup = evolvableStage:GetEvolvableGroupByType(XReformConfigs.EvolvableGroupType.Member) + local robotIds = {} + local source = nil + for _, sourceId in ipairs(teamData.SourceIdsInTeam) do + source = memberGroup:GetSourceById(sourceId) + if source then + table.insert(robotIds, source:GetRobotId()) + else + table.insert(robotIds, 0) + end + end + return { + StageId = stage.StageId, + IsHasAssist = false, + ChallengeCount = 1, + RobotIds = robotIds, + CaptainPos = teamData.CaptainPos, + FirstFightPos = teamData.FirstFightPos + } + end + + function XReformActivityManager.ShowReward(winData) + local settleData = winData.SettleData + local reformFightResult = settleData.ReformFightResult + if reformFightResult then + local baseStage = XReformActivityManager.GetBaseStage(winData.StageId) + -- -- 如果当前通关的是基础关卡,直接过渡到改造等级1的关卡 + -- if reformFightResult.CurrDiff == 0 then + -- baseStage:SetCurrentDiffIndex(2) + -- XReformActivityManager.ChageStageDiffRequest(baseStage:GetId(), 1) + -- end + local evolvableStage = baseStage:GetEvolvableStageByDiffIndex(reformFightResult.CurrDiff + 1) + -- 更新最大分数 + evolvableStage:UpdateMaxScore(math.max(reformFightResult.Score, evolvableStage:GetMaxScore())) + -- 更新最大难度 + baseStage:UpdateUnlockDiffIndex(math.max(reformFightResult.UnlockDiff + 1, baseStage:GetUnlockDiffIndex())) + XReformActivityManager.AddEvolvableMaxScore(winData.StageId, evolvableStage:GetDifficulty(), evolvableStage:GetMaxScore()) + end + XLuaUiManager.Open("UiReformCombatSettleWin", winData) + end + + --######################## 接口 ######################## + + function XReformActivityManager.EnterRequest(callback) + if Debug then + if callback then callback() end + return + end + -- 避免重复请求 + if IsEnterRequest then + if callback then callback() end + return + end + XNetwork.Call(NetApiDic.EnterRequest, nil, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XReformActivityManager.InitWithServerData(res) + IsEnterRequest = true + if callback then callback() end + end) + end + + -- 敌人替换请求 + function XReformActivityManager.EnemyReplaceRequest(stageId, diffIndex, replaceIdDbs, callback) + if replaceIdDbs == nil then replaceIdDbs = {} end + if Debug then + local baseStage = XReformActivityManager.GetBaseStage(stageId) + local evolvableStage = baseStage:GetEvolvableStageByDiffIndex(diffIndex) + evolvableStage:UpdateEnemyReplaceIds(replaceIdDbs) + XEventManager.DispatchEvent(XEventId.EVENT_REFORM_EVOLVABLE_GROUP_UPDATE, XReformConfigs.EvolvableGroupType.Enemy) + if callback then callback() end + return + end + XNetwork.Call(NetApiDic.EnemyReplaceRequest, { StageId = stageId, DiffIndex = diffIndex - 1, ReplaceIds = replaceIdDbs }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + -- ReformStageReplaceIdDb + local baseStage = XReformActivityManager.GetBaseStage(res.StageId) + local evolvableStage = baseStage:GetEvolvableStageByDiffIndex(res.DiffIndex + 1) + evolvableStage:UpdateEnemyReplaceIds(res.ReplaceIds or {}) + XEventManager.DispatchEvent(XEventId.EVENT_REFORM_EVOLVABLE_GROUP_UPDATE, XReformConfigs.EvolvableGroupType.Enemy) + if callback then callback() end + end) + end + + -- 成员替换请求 + function XReformActivityManager.MemberReplaceRequest(stageId, diffIndex, replaceIdDbs, callback) + if replaceIdDbs == nil then replaceIdDbs = {} end + if Debug then + local baseStage = XReformActivityManager.GetBaseStage(stageId) + local evolvableStage = baseStage:GetEvolvableStageByDiffIndex(diffIndex) + evolvableStage:UpdateMemberReplaceIds(replaceIdDbs) + XEventManager.DispatchEvent(XEventId.EVENT_REFORM_EVOLVABLE_GROUP_UPDATE, XReformConfigs.EvolvableGroupType.Member) + if callback then callback() end + return + end + XNetwork.Call(NetApiDic.MemberReplaceRequest, { StageId = stageId, DiffIndex = diffIndex - 1, ReplaceIds = replaceIdDbs }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + -- ReformStageReplaceIdDb + local baseStage = XReformActivityManager.GetBaseStage(res.StageId) + local evolvableStage = baseStage:GetEvolvableStageByDiffIndex(res.DiffIndex + 1) + evolvableStage:UpdateMemberReplaceIds(res.ReplaceIds or {}) + XEventManager.DispatchEvent(XEventId.EVENT_REFORM_EVOLVABLE_GROUP_UPDATE, XReformConfigs.EvolvableGroupType.Member) + if callback then callback() end + end) + end + + -- 更新buff + function XReformActivityManager.BuffUpdateRequest(stageId, diffIndex, buffIds, buffId) + if buffIds == nil then buffIds = {} end + if Debug then + local baseStage = XReformActivityManager.GetBaseStage(stageId) + local evolvableStage = baseStage:GetEvolvableStageByDiffIndex(diffIndex) + evolvableStage:UpdateBuffIds(buffIds) + XEventManager.DispatchEvent(XEventId.EVENT_REFORM_EVOLVABLE_GROUP_UPDATE, XReformConfigs.EvolvableGroupType.Buff) + return + end + XNetwork.Call(NetApiDic.BuffUpdateRequest, { StageId = stageId, DiffIndex = diffIndex - 1, BuffIds = buffIds }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + local baseStage = XReformActivityManager.GetBaseStage(res.StageId) + local evolvableStage = baseStage:GetEvolvableStageByDiffIndex(res.DiffIndex + 1) + evolvableStage:UpdateBuffIds(res.BuffIds or {}) + XEventManager.DispatchEvent(XEventId.EVENT_REFORM_EVOLVABLE_GROUP_UPDATE, XReformConfigs.EvolvableGroupType.Buff, buffId) + end) + end + + function XReformActivityManager.EnvironmentUpdateRequest(stageId, diffIndex, environmentIds, operateData) + if environmentIds == nil then environmentIds = {} end + if Debug then + local baseStage = XReformActivityManager.GetBaseStage(stageId) + local evolvableStage = baseStage:GetEvolvableStageByDiffIndex(diffIndex) + evolvableStage:UpdateEnvironmentIds(environmentIds) + XEventManager.DispatchEvent(XEventId.EVENT_REFORM_EVOLVABLE_GROUP_UPDATE, XReformConfigs.EvolvableGroupType.Environment) + return + end + XNetwork.Call(NetApiDic.EnvironmentUpdateRequest, { StageId = stageId, DiffIndex = diffIndex - 1, EnvIds = environmentIds }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + local baseStage = XReformActivityManager.GetBaseStage(res.StageId) + local evolvableStage = baseStage:GetEvolvableStageByDiffIndex(res.DiffIndex + 1) + evolvableStage:UpdateEnvironmentIds(res.EnvIds or {}) + XEventManager.DispatchEvent(XEventId.EVENT_REFORM_EVOLVABLE_GROUP_UPDATE, XReformConfigs.EvolvableGroupType.Environment, operateData) + end) + end + + function XReformActivityManager.ChageStageDiffRequest(stageId, diffIndex, callback) + if Debug then + if callback then callback() end + return + end + XNetwork.Call(NetApiDic.ChageStageDiffRequest, { StageId = stageId, DiffIndex = diffIndex - 1}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + if callback then callback() end + end) + end + + --######################## 私有方法 ######################## + + function XReformActivityManager.Init() + if XReformActivityManager.GetIsOpen() then + EvolvableStageMaxScoreHistoryDicKey = "XReformActivityManager.EvolvableStageMaxScoreHistoryDicKey" .. XPlayer.Id .. Config.Id + BaseStageRedDotHistoryDicKey = "XReformActivityManager.BaseStageRedDotHistoryDicKey" .. XPlayer.Id .. Config.Id + BaseStageRedDotHistoryDic = XSaveTool.GetData(BaseStageRedDotHistoryDicKey) or {} + EvolvableStageMaxScoreHistoryDic = XSaveTool.GetData(EvolvableStageMaxScoreHistoryDicKey) or {} + XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.Reform, true, true) + end + end + + function XReformActivityManager.InitConfig(id) + Config = XReformConfigs.GetActivityConfig(id) + end + + function XReformActivityManager.GetIsOpen() + if Config == nil then return false end + return XFunctionManager.CheckInTimeByTimeId(Config.OpenTimeId) + end + + function XReformActivityManager.InitWithServerData(data) + -- XReformFubenDb + local reformFubenDb = data.ReformFubenDb + XReformActivityManager.InitConfig(reformFubenDb.ActivityId) + XReformActivityManager.Init() + local baseStage = nil + local firstNotPassId = nil + local maxStageId = 0 + for _, stageDb in ipairs(reformFubenDb.StageDbs) do + baseStage = XReformActivityManager.GetBaseStage(stageDb.Id) + if baseStage == nil then + XLog.Warning(string.format("服务器基础关卡Id%s在本地配置找不到", stageDb.Id)) + else + baseStage:InitWithServerData(stageDb) + maxStageId = math.max(stageDb.Id, maxStageId) + end + end + local stageConfigIds = XReformConfigs.GetStageConfigIds() + for _, id in ipairs(stageConfigIds) do + baseStage = XReformActivityManager.GetBaseStage(id) + if firstNotPassId == nil and baseStage:GetIsUnlock() and not baseStage:GetIsPassed() then + firstNotPassId = baseStage:GetId() + end + end + if firstNotPassId ~= nil then + CurrentStageId = firstNotPassId + else + CurrentStageId = maxStageId + end + end + + XReformActivityManager.InitConfig() + + return XReformActivityManager +end + +XRpc.NotifyReformFubenActivity = function(data) + XDataCenter.ReformActivityManager.InitWithServerData(data) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XRegressionManager.lua b/Resources/Scripts/XManager/XRegressionManager.lua new file mode 100644 index 00000000..eb2fd96b --- /dev/null +++ b/Resources/Scripts/XManager/XRegressionManager.lua @@ -0,0 +1,562 @@ +XRegressionManagerCreator = function() + local XRegressionManager = {} + + local METHOD_NAME = { + GetScheduleRewardRequest = "GetScheduleRewardRequest", + CreateInviteCodeRequest = "CreateInviteCodeRequest", + GetInviteMsgRequest = "GetInviteMsgRequest", + GetInviteRewardRequest = "GetInviteRewardRequest", + UseInviteCodeRequest = "UseInviteCodeRequest", + } + + -->>>回归任务活动数据相关 + local TaskData + local TaskScheduleItemId + local TaskScheduleRewardHaveGetDic = {} + local TaskScheduleRewardCanGetDic = {} + local TaskScheduleRewardSumRedPointCount = 0 --进度奖励总红点 + --<<<回归任务活动数据相关 + -->>>回归活动剧情数据 + local NeedAutoPlayStory + local NeedToPlayStoryActivityId + --<<<回归活动剧情数据 + -->>> 发送邀请活动数据相关 + -- ps:在客户端邀请/被邀请活动界面与回归活动(任务等)界面是分开的,但是邀请活动的数据存储在此模块 + local InvitationActivityData + local InvitationActivitiesStartTime + local InvitationActivitiesEndTime + local LastRequestInvitationMsgTime = 0 + local RequestInvitationMsgInternalTime = CS.XGame.ClientConfig:GetInt("RegressionRequestInvitationMsgInternalTime") --请求间隔限制 + local InvitationCode + local AcceptMyInvitationCount = 0 + local SendInvitationRewardCanGetDic = {} + local SendInvitationRewardHaveGetDic = {} + local SendInvitationRedPointCount = 0 + --<<< 发送邀请活动数据相关 + -->>> 接受邀请活动数据相关 + local LastRequestUseInvitationCodeTime = 0 + local RequestUseInvitationCodeInternalTime = CS.XGame.ClientConfig:GetInt("RegressionRequestUseInvitationCodeInternalTime") --请求间隔限制 + --<<< 接受邀请活动数据相关 + local IsSendInvitationActivityNeedRead + local IsAcceptInvitationActivityNeedRead + + local UpdateTaskSchedule = function(activityId, itemId, schedule) + local itemManager = XDataCenter.ItemManager + schedule = schedule or itemManager.GetCount(itemId) + local groupId = XRegressionConfigs.GetTaskScheduleGroupId(activityId) + local scheduleRewardList = XRegressionConfigs.GetTaskScheduleRewardList(groupId) + local scheduleId + for _, scheduleReward in ipairs(scheduleRewardList) do + scheduleId = scheduleReward.Id + if not TaskScheduleRewardHaveGetDic[scheduleId] and not TaskScheduleRewardCanGetDic[scheduleId] then + if schedule >= scheduleReward.Schedule then + TaskScheduleRewardCanGetDic[scheduleId] = true + TaskScheduleRewardSumRedPointCount = TaskScheduleRewardSumRedPointCount + 1 + end + end + end + end + + local GetUseCodeList = function() + return InvitationActivityData and InvitationActivityData.UseCodeList + end + + local GetLocalSavedKey = function(key, activityId, startTimeStamp) + return string.format("%s%d%d%d", key, XPlayer.Id, activityId, startTimeStamp) + end + + function XRegressionManager.Init() + local activityTemplates = XRegressionConfigs.GetActivityTemplates() + for _, template in pairs(activityTemplates) do + if template.Type == XRegressionConfigs.ActivityType.Task then + XEventManager.AddEventListener(XEventId.EVENT_ITEM_COUNT_UPDATE_PREFIX .. template.ScheduleItemId, XRegressionManager.OnEventItemCountChange) + end + end + end + + function XRegressionManager.IsRegressionActivityOpen(type) + local isOpen = false + if type == XRegressionConfigs.ActivityType.Task then + isOpen = TaskData ~= nil + end + return isOpen + end + + -- 是否有一个回归活动开启 + function XRegressionManager.IsHaveOneRegressionActivityOpen() + return XRegressionManager.IsRegressionActivityOpen(XRegressionConfigs.ActivityType.Task) + end + + function XRegressionManager.GetTaskActivityId() + return TaskData and TaskData.Id + end + + function XRegressionManager.GetTaskStartTime() + return TaskData and TaskData.BeginTime + end + + function XRegressionManager.GetTaskEndTime() + return TaskData and TaskData.EndTime + end + + function XRegressionManager.GetTaskScheduleItemId() + return TaskScheduleItemId + end + + function XRegressionManager.IsTaskHaveRedPointByType(type) + return XDataCenter.TaskManager.GetRegressionTaskTypeToRedPointCount(type) > 0 + end + + function XRegressionManager.IsTaskHaveRedPoint() + local count = XDataCenter.TaskManager.GetRegressionTaskRedPointCount() + TaskScheduleRewardSumRedPointCount + return count > 0 + end + + function XRegressionManager.IsTaskScheduleRewardHaveGet(id) + return TaskScheduleRewardHaveGetDic[id] == true + end + + function XRegressionManager.IsTaskScheduleRewardCanGet(id) + return TaskScheduleRewardCanGetDic[id] == true + end + + -- 目前根据回归任务的期数来判断是否需要打脸 + function XRegressionManager.CheckNeedAutoWindow() + local isNeed = false + if XRegressionManager.IsRegressionActivityOpen(XRegressionConfigs.ActivityType.Task) then + local localSavedKey = GetLocalSavedKey(XRegressionConfigs.AutoWindowKey, TaskData.Id, TaskData.BeginTime) + if not XSaveTool.GetData(localSavedKey) then + isNeed = true + XSaveTool.SaveData(localSavedKey, true) + end + end + + return isNeed + end + + function XRegressionManager.SetPlayStoryInfo() + NeedAutoPlayStory = false + if XRegressionManager.IsRegressionActivityOpen(XRegressionConfigs.ActivityType.Task) then + local storyId = XRegressionConfigs.GetActivityStoryId(TaskData.Id) + if storyId then + NeedToPlayStoryActivityId = TaskData.Id + local localSavedKey = GetLocalSavedKey(XRegressionConfigs.AutoStoryKey, TaskData.Id, TaskData.BeginTime) + if not XSaveTool.GetData(localSavedKey) then + NeedAutoPlayStory = true + end + end + end + end + + function XRegressionManager.HandlePlayStory(checkIsFirst) + if not NeedToPlayStoryActivityId then return end + local storyId = XRegressionConfigs.GetActivityStoryId(NeedToPlayStoryActivityId) + if not storyId then return end + local activityTemplate = XRegressionConfigs.GetActivityTemplateByActivityId(NeedToPlayStoryActivityId) + local activityType = activityTemplate.Type + if not XRegressionManager.IsRegressionActivityOpen(activityType) then return end + if checkIsFirst then + if NeedAutoPlayStory then + XDataCenter.MovieManager.PlayMovie(storyId) + if activityType == XRegressionConfigs.ActivityType.Task then + local localSavedKey = GetLocalSavedKey(XRegressionConfigs.AutoStoryKey, TaskData.Id, TaskData.BeginTime) + XSaveTool.SaveData(localSavedKey, true) + end + NeedAutoPlayStory = false + end + else + XDataCenter.MovieManager.PlayMovie(storyId) + end + end + + function XRegressionManager.IsShowActivityViewStoryBtn() + return NeedToPlayStoryActivityId ~= nil + end + + function XRegressionManager.IsInvitationActivityInTime() + local nowTime = XTime.GetServerNowTimestamp() + if InvitationActivitiesStartTime and InvitationActivitiesEndTime then + if InvitationActivitiesStartTime < nowTime and nowTime < InvitationActivitiesEndTime then + return true + end + end + return false + end + + -- 获取邀请活动中的子类是否开启的 + function XRegressionManager.IsActivityOpenInUiActivityBase(type) + if not InvitationActivityData then return false end + if not XRegressionManager.IsInvitationActivityInTime() then return false end + local invitationStatus = InvitationActivityData.InviteType + if invitationStatus == XRegressionConfigs.InvitationStatus.Both then return true end + + if type == XActivityConfigs.ActivityType.SendInvitation and invitationStatus == XRegressionConfigs.InvitationStatus.SendInvitation then + return true + elseif type == XActivityConfigs.ActivityType.AcceptInvitation and invitationStatus == XRegressionConfigs.InvitationStatus.AcceptInvitation then + return true + end + return false + end + + function XRegressionManager.IsSendInvitationRewardCanGet(id) + return SendInvitationRewardCanGetDic[id] == true + end + + function XRegressionManager.IsSendInvitationRewardHaveGet(id) + return SendInvitationRewardHaveGetDic[id] == true + end + + function XRegressionManager.GetInvitationActivityId() + return InvitationActivityData and InvitationActivityData.Id + end + + function XRegressionManager.GetInvitationStatus() + return InvitationActivityData and InvitationActivityData.InviteType + end + + function XRegressionManager.GetAcceptMyInvitationCount() + return AcceptMyInvitationCount + end + + function XRegressionManager.GetInvitationCode() + return InvitationCode + end + + function XRegressionManager.IsSendInvitationHaveRedPoint() + return IsSendInvitationActivityNeedRead or SendInvitationRedPointCount > 0 + end + + function XRegressionManager.IsAcceptInvitationHaveRedPoint() + return IsAcceptInvitationActivityNeedRead == true + end + + function XRegressionManager.IsUseInvitationCodeRewardHaveGet(index) + local useCodeList = GetUseCodeList() + if useCodeList then + return index <= #useCodeList + end + return false + end + + function XRegressionManager.IsInvitationCodeHaveUse(code) + local useCodeList = GetUseCodeList() + if useCodeList then + for _, v in ipairs(useCodeList) do + if code == v then + return true + end + end + end + return false + end + + function XRegressionManager.InitInvitationReadStatus() + if not InvitationActivityData then return end + local activityId = InvitationActivityData.Id + + local activityTemplate = XRegressionConfigs.GetActivityTemplateByActivityId(activityId) + if not activityTemplate then return end + + local startTime = XRegressionConfigs.GetActivityTime(activityId) + local startTimeStr = XTime.TimestampToGameDateTimeString(startTime) + + --获取本地邀请他人活动是否已读 + local localSavedKey = GetLocalSavedKey(XRegressionConfigs.SendInvitationReadKey, XPlayer.Id, activityId, startTimeStr) + if IsSendInvitationActivityNeedRead == nil then + if XSaveTool.GetData(localSavedKey) then + IsSendInvitationActivityNeedRead = false + else + IsSendInvitationActivityNeedRead = true + end + end + + --获取本地接受邀请活动是否已读 + localSavedKey = GetLocalSavedKey(XRegressionConfigs.AcceptInvitationReadKey, XPlayer.Id, activityId, startTimeStr) + if IsAcceptInvitationActivityNeedRead == nil then + if XSaveTool.GetData(localSavedKey) then + IsAcceptInvitationActivityNeedRead = false + else + IsAcceptInvitationActivityNeedRead = true + end + end + end + + function XRegressionManager.HandleReadSendInvitationActivity() + if not InvitationActivityData then return end + if not IsSendInvitationActivityNeedRead then return end + local activityId = InvitationActivityData.Id + + local activityTemplate = XRegressionConfigs.GetActivityTemplateByActivityId(activityId) + if not activityTemplate then return end + + local startTime = XRegressionConfigs.GetActivityTime(activityId) + local startTimeStr = XTime.TimestampToGameDateTimeString(startTime) + local localSavedKey = GetLocalSavedKey(XRegressionConfigs.SendInvitationReadKey, XPlayer.Id, activityId, startTimeStr) + + XSaveTool.SaveData(localSavedKey, true) + IsSendInvitationActivityNeedRead = false + XEventManager.DispatchEvent(XEventId.EVENT_ACTIVITY_ACTIVITIES_READ_CHANGE) + end + + function XRegressionManager.HandleReadAcceptInvitationActivity() + if not InvitationActivityData then return end + if not IsAcceptInvitationActivityNeedRead then return end + local activityId = InvitationActivityData.Id + local activityTemplate = XRegressionConfigs.GetActivityTemplateByActivityId(activityId) + if not activityTemplate then return end + + local startTime = XRegressionConfigs.GetActivityTime(activityId) + local startTimeStr = XTime.TimestampToGameDateTimeString(startTime) + + local localSavedKey = GetLocalSavedKey(XRegressionConfigs.AcceptInvitationReadKey, XPlayer.Id, activityId, startTimeStr) + XSaveTool.SaveData(localSavedKey, true) + IsAcceptInvitationActivityNeedRead = false + XEventManager.DispatchEvent(XEventId.EVENT_ACTIVITY_ACTIVITIES_READ_CHANGE) + end + + --服务端数据处理相关------------------------>>> + function XRegressionManager.InitTaskData(data) + if not data then return end + TaskData = data + if data.ScheduleRewards then + for _, scheduleId in ipairs(data.ScheduleRewards) do + TaskScheduleRewardHaveGetDic[scheduleId] = true + end + data.ScheduleRewards = nil + end + + TaskScheduleItemId = XRegressionConfigs.GetScheduleItemIdByActivityId(TaskData.Id) + UpdateTaskSchedule(TaskData.Id, TaskScheduleItemId) + XEventManager.DispatchEvent(XEventId.EVENT_REGRESSION_TASK_SCHEDULE_UPDATE) + end + + function XRegressionManager.InitInvitationActivityData(data) + if not data then return end + InvitationActivityData = data + + if data.InviteRewards then + for _, id in ipairs(data.InviteRewards) do + if SendInvitationRewardCanGetDic[id] then + SendInvitationRewardCanGetDic[id] = nil + SendInvitationRedPointCount = SendInvitationRedPointCount - 1 + end + if not SendInvitationRewardHaveGetDic[id] then + SendInvitationRewardHaveGetDic[id] = true + end + end + end + + InvitationActivityData.InviteRewards = nil + InvitationActivitiesStartTime, InvitationActivitiesEndTime = XRegressionConfigs.GetActivityTime(data.Id) + + --在活动开启时初始化已读信息 + XRegressionManager.InitInvitationReadStatus() + XEventManager.DispatchEvent(XEventId.EVENT_ACTIVITY_ACTIVITIES_READ_CHANGE) + end + + function XRegressionManager.InitSendInvitationInfo() + InvitationCode = "" + AcceptMyInvitationCount = 0 + end + + function XRegressionManager.UpdateLastRequestInvitationMsgTime() + LastRequestInvitationMsgTime = XTime.GetServerNowTimestamp() + end + + function XRegressionManager.UpdateSendInvitationInfo(invitationInfo) + InvitationCode = invitationInfo.InviteCode + + local isNeedEvent = false + if InvitationActivityData and AcceptMyInvitationCount ~= invitationInfo.InviteCount then + AcceptMyInvitationCount = invitationInfo.InviteCount + local invitationTemplateId = XRegressionConfigs.GetInvitationTemplateId(InvitationActivityData.Id) + local invitationTemplate = XRegressionConfigs.GetInvitationTemplate(invitationTemplateId) + local needCount + for _, id in ipairs(invitationTemplate.InviteRewardId) do + if not SendInvitationRewardCanGetDic[id] and not SendInvitationRewardHaveGetDic[id] then + needCount = XRegressionConfigs.GetSendInvitationRewardNeedCount(id) + if AcceptMyInvitationCount >= needCount then + SendInvitationRewardCanGetDic[id] = true + SendInvitationRedPointCount = SendInvitationRedPointCount + 1 + isNeedEvent = true + end + end + end + end + + if isNeedEvent then + XEventManager.DispatchEvent(XEventId.EVENT_REGRESSION_SEND_INVITATION_INFO_UPDATE) + end + return isNeedEvent + end + + function XRegressionManager.RequestGetRegressionScheduleReward(id, callback) + XNetwork.Call(METHOD_NAME.GetScheduleRewardRequest, { Id = id }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + TaskScheduleRewardCanGetDic[id] = false + TaskScheduleRewardHaveGetDic[id] = true + TaskScheduleRewardSumRedPointCount = TaskScheduleRewardSumRedPointCount - 1 + + XUiManager.OpenUiObtain(res.RewardList) + if callback then + callback() + end + XEventManager.DispatchEvent(XEventId.EVENT_REGRESSION_TASK_SCHEDULE_REWARD_GET) + end) + end + + function XRegressionManager.RequestCreateInviteCode(callback) + LastRequestInvitationMsgTime = XTime.GetServerNowTimestamp() + XNetwork.Call(METHOD_NAME.CreateInviteCodeRequest, nil, function(res) + LastRequestInvitationMsgTime = XTime.GetServerNowTimestamp() --收到服务端的消息再次刷新上次请求时间 + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local isNeedUpdate = XRegressionManager.UpdateSendInvitationInfo(res.Info) + if not isNeedUpdate and callback then + callback() + end + end) + end + + function XRegressionManager.RequestGetInviteMsg(callback) + LastRequestInvitationMsgTime = XTime.GetServerNowTimestamp() + XNetwork.Call(METHOD_NAME.GetInviteMsgRequest, nil, function(res) + LastRequestInvitationMsgTime = XTime.GetServerNowTimestamp() --收到服务端的消息再次刷新上次请求时间 + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local isNeedUpdate = XRegressionManager.UpdateSendInvitationInfo(res.Info) + if not isNeedUpdate and callback then + callback() + end + end) + end + + --邀请码为nil或者邀请好友活动没开启时不进行处理,主界面和活动界面共用此api,主界面不能创建邀请码,进入活动才可以 + function XRegressionManager.HandleGetInvitationCodeInfoRequest(isCanRequestCreateCode, callback) + if not InvitationCode then return end + -- 请求前检查活动是否开启 + if not XRegressionManager.IsActivityOpenInUiActivityBase(XActivityConfigs.ActivityType.SendInvitation) then + if callback then + callback() + end + return + end + + --为主界面请求时,不进行创建邀请码的判断(登陆时如果有邀请资格但从未生成邀请码,则会为空字符串) + if InvitationCode == "" then + if isCanRequestCreateCode then + XRegressionManager.RequestCreateInviteCode(callback) + end + return + end + if XTime.GetServerNowTimestamp() - LastRequestInvitationMsgTime > RequestInvitationMsgInternalTime then + XRegressionManager.RequestGetInviteMsg(callback) + return + end + + if callback then + callback() + end + end + + function XRegressionManager.RequestGetInviteReward(id, callback) + XNetwork.Call(METHOD_NAME.GetInviteRewardRequest, { Id = id }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + SendInvitationRewardCanGetDic[id] = nil + SendInvitationRewardHaveGetDic[id] = true + SendInvitationRedPointCount = SendInvitationRedPointCount - 1 + XUiManager.OpenUiObtain(res.RewardList) + if callback then + callback() + end + XEventManager.DispatchEvent(XEventId.EVENT_REGRESSION_SEND_INVITATION_INFO_UPDATE) + end) + end + + function XRegressionManager.RequestUseInvitationCode(code, callback) + LastRequestUseInvitationCodeTime = XTime.GetServerNowTimestamp() + XNetwork.Call(METHOD_NAME.UseInviteCodeRequest, { InviteCode = code }, function(res) + LastRequestUseInvitationCodeTime = XTime.GetServerNowTimestamp() --收到服务端的消息再次刷新上次请求时间 + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local useCodeList = GetUseCodeList() + if useCodeList then + table.insert(useCodeList, code) + end + XUiManager.OpenUiObtain(res.RewardList) + if callback then + callback() + end + end) + end + + function XRegressionManager.HandleUseInvitationCodeRequest(code, callback) + if XTime.GetServerNowTimestamp() - LastRequestUseInvitationCodeTime > RequestUseInvitationCodeInternalTime then + XRegressionManager.RequestUseInvitationCode(code, callback) + else + XUiManager.TipError(CS.XTextManager.GetText("RegressionAcceptInvitationUseCodeFrequently")) + end + end + + function XRegressionManager.CloseActivity(idList) + local type + local activityTemplate + for _, id in ipairs(idList) do + activityTemplate = XRegressionConfigs.GetActivityTemplateByActivityId(id) + type = activityTemplate.Type + if type == XRegressionConfigs.ActivityType.Task then + TaskData = nil + TaskScheduleItemId = nil + end + end + XEventManager.DispatchEvent(XEventId.EVENT_REGRESSION_OPEN_STATUS_UPDATE) + end + + function XRegressionManager.OnEventItemCountChange(itemId, count) + if not TaskData or not TaskScheduleItemId or itemId ~= TaskScheduleItemId then return end + UpdateTaskSchedule(TaskData.Id, itemId, count) + XEventManager.DispatchEvent(XEventId.EVENT_REGRESSION_TASK_SCHEDULE_UPDATE) + end + --服务端数据处理相关-----------------------------------------<<< + XRegressionManager.Init() + return XRegressionManager +end + +XRpc.NotifyRegressionActivityData = function(data) + XDataCenter.RegressionManager.InitTaskData(data.TaskData) + XDataCenter.RegressionManager.SetPlayStoryInfo() + XDataCenter.RegressionManager.InitInvitationActivityData(data.InviteData) +end + +XRpc.NotifyRegressionActivityClose = function(data) + XDataCenter.RegressionManager.CloseActivity(data.CloseIds) +end + +-- 登陆时如果有邀请资格但从未生成邀请码,则邀请码为空字符串,邀请人数为0;如果已经生成过,登陆时会发非空字符串的邀请码; +-- 请求CreateInviteCodeRequest与GetInviteMsgRequest协议时也会从这里更新邀请码和邀请人数的信息 +XRpc.NotifyInviteCodeData = function(data) + XDataCenter.RegressionManager.UpdateLastRequestInvitationMsgTime() + XDataCenter.RegressionManager.UpdateSendInvitationInfo(data.Info) +end + +XRpc.NotifyRegressInviteData = function(data) + XDataCenter.RegressionManager.InitInvitationActivityData(data.InviteData) + XDataCenter.RegressionManager.InitSendInvitationInfo() -- 等级上升时服务端不推送NotifyInviteCodeData,得客户端初始化数据 +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XReportManager.lua b/Resources/Scripts/XManager/XReportManager.lua new file mode 100644 index 00000000..2890693b --- /dev/null +++ b/Resources/Scripts/XManager/XReportManager.lua @@ -0,0 +1,36 @@ +XReportManagerCreater = function() + local XReportManager = {} + + local LastReportTime = -9999 + local ReportInterval = CS.XGame.Config:GetInt("ReportInterval") + + function XReportManager.Report(playerId, playerName, mainType, subType, msg, playerLevel, chatContent) + if LastReportTime < 0 then + LastReportTime = XPlayer.ReportTime + end + local now = XTime.GetServerNowTimestamp() + if now - LastReportTime < ReportInterval then + local tempTime = (ReportInterval - (now - LastReportTime)) + XUiManager.TipError(CS.XTextManager.GetText("ReportError", tostring(tempTime))) + else + XNetwork.Call("ReportRequest", { + PlayerId = playerId, + PlayerName = playerName, + FirstTag = mainType, + SecondTag = subType, + Message = msg, + PlayerLevel = playerLevel, + ReportMessage = chatContent + }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + LastReportTime = res.ReportTime + XUiManager.TipText("ReportFinish") + end) + end + end + + return XReportManager +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XResetManager.lua b/Resources/Scripts/XManager/XResetManager.lua new file mode 100644 index 00000000..11db524e --- /dev/null +++ b/Resources/Scripts/XManager/XResetManager.lua @@ -0,0 +1,80 @@ +XResetManager = XResetManager or {} + +local insert = table.insert + +local DailyResetSpan = CS.XGame.Config:GetInt("DailyResetTimestamp") +local ResetCfg = {} +local TABLE_RESET = "Share/Reset/SystemResetConfig.tab" + +XResetManager.ResetType = { + NoNeed = 0, -- 无需重置 + Interval = 1, -- 间隔一段时间 + Daily = 2, -- 每天 + Weekly = 3, -- 每周 + Monthly = 4 -- 每月 +} + +function XResetManager.Init() + ResetCfg = XTableManager.ReadByIntKey(TABLE_RESET, XTable.XTableSystemReset, "ResetKey") +end + +-- function XResetManager.GetTodayRemainTime(checkTime) +-- checkTime = checkTime or XTime.GetServerNowTimestamp() +-- local targetTime = CS.XDateUtil.GetGameDateTime(checkTime).Date:AddSeconds(DailyResetSpan):ToTimestamp() +-- targetTime = checkTime > targetTime and (targetTime + CS.XDateUtil.ONE_DAY_SECOND) or targetTime +-- return targetTime - checkTime +-- end + +function XResetManager.GetResetTimeByString(resetType, timeStr) + local seconds, days = {}, {} + + if resetType == XResetManager.ResetType.Interval or resetType == XResetManager.ResetType.Daily then + seconds = string.ToIntArray(timeStr, '|') + elseif resetType == XResetManager.ResetType.Weekly or resetType == XResetManager.ResetType.Monthly then + local times = string.Split(timeStr) + for _, str in pairs(times) do + local dayAndSecond = string.ToIntArray(str, '#') + if #dayAndSecond > 1 then + insert(days, dayAndSecond[1]) + insert(seconds, dayAndSecond[2]) + elseif #dayAndSecond > 0 then + insert(days, dayAndSecond[1]) + insert(seconds, DailyResetSpan) + end + end + end + + return seconds, days +end + +-- function XResetManager.GetResetTodayDayOfWeek() +-- local day = XTime.DayOfWeekToInt(CS.XDateUtil.GetGameNow().DayOfWeek) +-- local now = XTime.GetServerNowTimestamp() +-- local stamp = CS.XDateUtil.GetGameDateTime(checkTime).Date:AddSeconds(DailyResetSpan):ToTimestamp() + +-- if now >= stamp then -- 超过属于后面的一天 +-- day = (day + 1) % 7 +-- end +-- return day +-- end + +function XResetManager.GetNextResetTime(resetType, lastTime, seconds, days) + return CS.XReset.GetNextResetTime(resetType, lastTime, seconds, days) +end + +function XResetManager.GetRemainTime(resetCfg, lastTime) + local resetType = resetCfg.ResetType + local recTime = resetCfg.ResetTime + local seconds, days = XResetManager.GetResetTimeByString(resetType, recTime) + return CS.XReset.GetNextResetTime(resetType, lastTime, seconds, days) - XTime.GetServerNowTimestamp() +end + +function XResetManager.GetResetCfg(reseTimeId) + local cfg = ResetCfg[reseTimeId] + if not cfg then + XLog.ErrorTableDataNotFound("XResetManager.GetResetCfg", "cfg", TABLE_RESET, "reseTimeId", tostring(reseTimeId)) + return + end + + return cfg +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XRewardManager.lua b/Resources/Scripts/XManager/XRewardManager.lua new file mode 100644 index 00000000..09883ffe --- /dev/null +++ b/Resources/Scripts/XManager/XRewardManager.lua @@ -0,0 +1,760 @@ +local pairs = pairs +local table = table +local tableInsert = table.insert +local tableSort = table.sort + +XRewardManager = XRewardManager or {} + +local XRewardType = { + Item = 1, + Character = 2, + Equip = 3, + Fashion = 4, + BaseEquip = 5, + Furniture = 9, + HeadPortrait = 10, + DormCharacter = 11, + ChatEmoji = 12, + WeaponFashion = 13, + Collection = 14, + Background = 15, + Pokemon = 16, + Partner = 17, + Nameplate = 18, +} + +--local HeadPortraitQuality = CS.XGame.Config:GetInt("HeadPortraitQuality") +local TABLE_REWARD_PATH = "Share/Reward/Reward.tab" +local TABLE_REWARD_GOODS_PATH = "Share/Reward/RewardGoods.tab" + +local RewardTemplates = {} +local RewardSubIds = {} + +local Arrange2RewardType = { + [XArrangeConfigs.Types.Item] = XRewardType.Item, + [XArrangeConfigs.Types.Character] = XRewardType.Character, + [XArrangeConfigs.Types.Weapon] = XRewardType.Equip, + [XArrangeConfigs.Types.Wafer] = XRewardType.Equip, + [XArrangeConfigs.Types.Fashion] = XRewardType.Fashion, + [XArrangeConfigs.Types.BaseEquip] = XRewardType.BaseEquip, + [XArrangeConfigs.Types.Furniture] = XRewardType.Furniture, + [XArrangeConfigs.Types.HeadPortrait] = XRewardType.HeadPortrait, + [XArrangeConfigs.Types.DormCharacter] = XRewardType.DormCharacter, + [XArrangeConfigs.Types.ChatEmoji] = XRewardType.ChatEmoji, + [XArrangeConfigs.Types.WeaponFashion] = XRewardType.WeaponFashion, + [XArrangeConfigs.Types.Collection] = XRewardType.Collection, + [XArrangeConfigs.Types.Background] = XRewardType.Background, + [XArrangeConfigs.Types.Pokemon] = XRewardType.Pokemon, + [XArrangeConfigs.Types.Partner] = XRewardType.Partner, + [XArrangeConfigs.Types.Nameplate] = XRewardType.Nameplate, +} + +local CreateGoodsFunc = { + [XRewardType.Item] = function(templateId, count) + return { + RewardType = XRewardType.Item, + TemplateId = templateId, + Count = count and count or 1 + } + end, + + [XRewardType.Character] = function(templateId, count, args) + local template = XCharacterConfigs.GetCharacterBorderTemplate(templateId) + if not template then + local path = XCharacterConfigs.GetCharacterElementPath() + XLog.ErrorTableDataNotFound("CreateGoodsFunc", "template", path, "templateId", tostring(templateId)) + return + end + + local len = #args + local level, quality, grade = template.MinLevel, template.MinQuality, template.MinGrade + + if len > 0 and args[1] > 0 then + level = args[1] + if level > template.MaxLevel or level < template.MinLevel then + XLog.Error("XRewardManager CreateRewardCharacter 函数错误: level超出范围, id is ", templateId, " level is ", + level, " 最小 level is ", template.MinLeXvel, " 最大 level is ", template.MaxLeXvel) + return + end + end + + if len > 1 and args[2] > 0 then + quality = args[2] + if quality > template.MaxQuality or quality < template.MinQuality then + XLog.Error("XRewardManager CreateRewardCharacter 函数错误: quality 超出范围, id is ", templateId, " quality is ", + quality, " 最小 quality is ", template.MinQuality, " 最大 quality is ", template.MaxQuality) + return + end + end + + if len > 2 and args[3] > 0 then + grade = args[3] + if grade > template.MaxGrade or grade < template.MinGrade then + XLog.Error("XRewardManager CreateRewardCharacter 函数错误: grade 超出范围, id is ", templateId, " grade is ", + grade, " 最小 grade is ", template.MinGrade, " 最大 grade is ", template.MaxGrade) + return + end + end + + return { + RewardType = XRewardType.Character, + TemplateId = templateId, + Count = count and count or 1, + Level = level, + Quality = quality, + Grade = grade + } + end, + + [XRewardType.Equip] = function(templateId, count, args) + local len = args and #args or 0 + local level, breakthrough + local borderCfg = XEquipConfig.GetEquipBorderCfg(templateId) + if borderCfg == nil then + return + end + + if len > 0 and args[1] then + level = args[1] + if level > borderCfg.MaxLevel or level < borderCfg.MinLevel then + XLog.Error("XRewardManager CreateRewardEquip 函数错误: level 超出范围, id is ", templateId, "level is ", level, + " 最小 level is ", borderCfg.MinLevel, " 最大 level is ", borderCfg.MaxLevel) + return + end + else + level = borderCfg.MinLevel + end + + if len > 2 and args[3] > 0 then + breakthrough = args[3] + if breakthrough > borderCfg.MaxBreakthrough or breakthrough < borderCfg.MinBreakthrough then + XLog.Error("XRewardManager CreateRewardEquip 函数错误: breakthrough 超出范围, id is ", templateId, " breakthrough is ", breakthrough, + " 最小 breakthrough is ", borderCfg.MinBreakthrough, " 最大 breakthrough is ", borderCfg.MaxBreakthrough) + return + end + else + breakthrough = borderCfg.MinBreakthrough + end + + return { + RewardType = XRewardType.Equip, + TemplateId = templateId, + Count = count and count or 1, + Level = level, + Breakthrough = breakthrough + } + end, + + [XRewardType.Fashion] = function(templateId, count) + return { + RewardType = XRewardType.Fashion, + TemplateId = templateId, + Count = count and count or 1 + } + end, + + [XRewardType.BaseEquip] = function(templateId, count) + return { + RewardType = XRewardType.BaseEquip, + TemplateId = templateId, + Count = count and count or 1 + } + end, + + [XRewardType.Furniture] = function(templateId, count) + local quality = XDataCenter.FurnitureManager.GetRewardFurnitureQuality(templateId) + return { + XRewardType = XRewardType.Furniture, + TemplateId = templateId, + Count = count and count or 1, + Quality = quality, + } + end, + + [XRewardType.HeadPortrait] = function(templateId, count) + return { + RewardType = XRewardType.HeadPortrait, + TemplateId = templateId, + Count = count and count or 1, + } + end, + + [XRewardType.DormCharacter] = function(templateId, count) + return { + RewardType = XRewardType.DormCharacter, + TemplateId = templateId, + Count = count and count or 1, + } + end, + + [XRewardType.ChatEmoji] = function(templateId, count) + return { + RewardType = XRewardType.ChatEmoji, + TemplateId = templateId, + Count = count and count or 1, + } + end, + + [XRewardType.WeaponFashion] = function(templateId, count) + return { + RewardType = XRewardType.WeaponFashion, + TemplateId = templateId, + Count = count and count or 1 + } + end, + [XRewardType.Collection] = function(templateId, count) + return { + RewardType = XRewardType.Collection, + TemplateId = templateId, + Count = count and count or 1 + } + end, + [XRewardType.Background] = function(templateId, count) + return { + RewardType = XRewardType.Collection, + TemplateId = templateId, + Count = count and count or 1 + } + end, + [XRewardType.Pokemon] = function(templateId, count) + return { + RewardType = XRewardType.Pokemon, + TemplateId = templateId, + Count = count and count or 1 + } + end, + [XRewardType.Partner] = function(templateId, count) + return { + RewardType = XRewardType.Partner, + TemplateId = templateId, + Count = count and count or 1 + } + end, + [XRewardType.Nameplate] = function(templateId, count) + return { + RewardType = XRewardType.Nameplate, + TemplateId = templateId, + Count = count and count or 1 + } + end, +} + +local CloneRewardGoods = function(rewardGoods) + return { + RewardType = rewardGoods.RewardType, + TemplateId = rewardGoods.TemplateId, + Count = rewardGoods.Count, + Level = rewardGoods.Level, + Quality = rewardGoods.Quality, + Grade = rewardGoods.Grade, + Star = rewardGoods.Star, + ConvertFrom = rewardGoods.ConvertFrom, + Breakthrough = rewardGoods.Breakthrough + } +end + +local CreateRewardGoods = function(templateId, count, args) + local idType = XArrangeConfigs.GetType(templateId) + local rewardType = Arrange2RewardType[idType] + + if not rewardType then + XLog.Error("XRewardManager.CreateRewardGoodsByTemplate error: reward type not support, templateId is " .. templateId) + return + end + + return CreateGoodsFunc[rewardType](templateId, count, args) +end + +local CreateRewardGoodsByTemplate = function(tab) + return CreateRewardGoods(tab.TemplateId, tab.Count, tab.Params) +end + +--==============================-- +--desc: 通用角色奖励排序 +--==============================-- +local SortCharacters = function(a, b) + local tmpId1 = a.TemplateId and a.TemplateId or a.Id + local tmpId2 = b.TemplateId and b.TemplateId or b.Id + + local quality1 = a.Quality and a.Quality or XCharacterConfigs.GetCharMinQuality(tmpId1) + local quality2 = b.Quality and b.Quality or XCharacterConfigs.GetCharMinQuality(tmpId2) + + if quality1 ~= quality2 then + return quality1 > quality2 + end + + local priority1 = XCharacterConfigs.GetCharacterPriority(tmpId1) + local priority2 = XCharacterConfigs.GetCharacterPriority(tmpId2) + + if priority1 ~= priority2 then + return priority1 > priority2 + end + + return tmpId1 > tmpId2 +end + +--==============================-- +--desc: 通用时装奖励排序 +--==============================-- +local SortFashions = function(a, b) + local tmpId1 = a.TemplateId and a.TemplateId or a.Id + local tmpId2 = b.TemplateId and b.TemplateId or b.Id + + local quality1 = XDataCenter.FashionManager.GetFashionQuality(tmpId1) + local quality2 = XDataCenter.FashionManager.GetFashionQuality(tmpId2) + + if quality1 ~= quality2 then + return quality1 > quality2 + end + + local priority1 = XDataCenter.FashionManager.GetFashionPriority(tmpId1) + local priority2 = XDataCenter.FashionManager.GetFashionPriority(tmpId2) + + if priority1 ~= priority2 then + return priority1 > priority2 + end + + return tmpId1 > tmpId2 +end + +--==============================-- +--desc: 通用装备奖励排序 +--==============================-- +local SortEquips = function(a, b) + local tmpId1 = a.TemplateId + local tmpId2 = b.TemplateId + + local quality1 = XDataCenter.EquipManager.GetEquipQuality(tmpId1) + local quality2 = XDataCenter.EquipManager.GetEquipQuality(tmpId2) + + if quality1 ~= quality2 then + return quality1 > quality2 + end + + if a.Star ~= b.Star then + return a.Star > b.Star + end + + if a.Level ~= b.Level then + return a.Level > b.Level + end + + local priority1 = XDataCenter.EquipManager.GetEquipPriority(tmpId1) + local priority2 = XDataCenter.EquipManager.GetEquipPriority(tmpId2) + + if priority1 ~= priority2 then + return priority1 > priority2 + end + + return tmpId1 > tmpId2 +end + +--==============================-- +--desc: 通用基地装备奖励排序 +--==============================-- +local SortBaseEquips = function(a, b) + -- 等级 > 品质 + local tmpId1 = a.TemplateId + local tmpId2 = b.TemplateId + + local template1 = XDataCenter.BaseEquipManager.GetBaseEquipTemplate(tmpId1) + local template2 = XDataCenter.BaseEquipManager.GetBaseEquipTemplate(tmpId2) + + if template1.Level ~= template2.Level then + return template1.Level > template2.Level + end + + if template1.Quality ~= template2.Quality then + return template1.Quality > template2.Quality + end + + if template1.Priority ~= template2.Priority then + return template1.Priority > template2.Priority + end + + return tmpId1 > tmpId2 +end + +--==============================-- +--desc: 通用家具奖励排序 +--==============================-- +local SortFurnitures = function(a, b) + return a.TemplateId < b.TemplateId +end + +--==============================-- +--desc: 通用道具奖励排序 +--==============================-- +local SortItems = function(a, b) + local tmpId1 = a.TemplateId and a.TemplateId or a.Id + local tmpId2 = b.TemplateId and b.TemplateId or b.Id + + local quality1 = XDataCenter.ItemManager.GetItemQuality(tmpId1) + local quality2 = XDataCenter.ItemManager.GetItemQuality(tmpId2) + + if quality1 ~= quality2 then + return quality1 > quality2 + end + + local priority1 = XDataCenter.ItemManager.GetItemPriority(tmpId1) + local priority2 = XDataCenter.ItemManager.GetItemPriority(tmpId2) + + if priority1 ~= priority2 then + return priority1 > priority2 + end + + return tmpId1 > tmpId2 +end + +--==============================-- +--desc: 通用头像奖励排序 +--==============================-- +local SortHeadPortraits = function(a, b) + return a.TemplateId > b.TemplateId +end + +local SortDormCharacter = function(a, b) + return a.TemplateId > b.TemplateId +end + +local SortChatEmoji = function(a, b) + return a.TemplateId > b.TemplateId +end + +local SortWeaponFashions = function(a, b) + local tmpId1 = a.TemplateId and a.TemplateId or a.Id + local tmpId2 = b.TemplateId and b.TemplateId or b.Id + + local quality1 = XDataCenter.WeaponFashionManager.GetFashionQuality(tmpId1) + local quality2 = XDataCenter.WeaponFashionManager.GetFashionQuality(tmpId2) + + if quality1 ~= quality2 then + return quality1 > quality2 + end + + local priority1 = XDataCenter.WeaponFashionManager.GetFashionPriority(tmpId1) + local priority2 = XDataCenter.WeaponFashionManager.GetFashionPriority(tmpId2) + + if priority1 ~= priority2 then + return priority1 > priority2 + end + + return tmpId1 > tmpId2 +end + +local SortCollection = function(a, b) + local priority1 = XMedalConfigs.GetCollectionPriorityById(a.TemplateId) + local priority2 = XMedalConfigs.GetCollectionPriorityById(b.TemplateId) + + if priority1 ~= priority2 then + return priority1 > priority2 + end + return a.TemplateId > b.TemplateId +end + +local SortBackground = function(a, b) + local priority1 = XPhotographConfigs.GetBackgroundPriorityById(a.TemplateId) + local priority2 = XPhotographConfigs.GetBackgroundPriorityById(b.TemplateId) + + if priority1 ~= priority2 then + return priority1 > priority2 + end + return a.TemplateId > b.TemplateId +end + +local SortPartner = function(a, b) + local priority1 = XPartnerConfigs.GetPartnerTemplateQuality(a.TemplateId) + local priority2 = XPartnerConfigs.GetPartnerTemplateQuality(b.TemplateId) + + if priority1 ~= priority2 then + return priority1 > priority2 + end + return a.TemplateId > b.TemplateId +end + +local SortNameplate = function(a, b) + local priority1 = XPartnerConfigs.GetPartnerTemplateQuality(a.TemplateId) + local priority2 = XPartnerConfigs.GetPartnerTemplateQuality(b.TemplateId) + + if priority1 ~= priority2 then + return priority1 > priority2 + end + return a.TemplateId > b.TemplateId +end + +local SortRewardTypePrioriy = { + [XRewardType.Item] = 1, + [XRewardType.Character] = 4, + [XRewardType.Equip] = 2, + [XRewardType.Fashion] = 3, + [XRewardType.BaseEquip] = 5, + [XRewardType.Furniture] = 9, + [XRewardType.HeadPortrait] = 10, + [XRewardType.DormCharacter] = 11, + [XRewardType.ChatEmoji] = 12, + [XRewardType.Collection] = 14, + [XRewardType.Partner] = 15, + [XRewardType.Nameplate] = 16, + [XRewardType.Background] = 17, +} + +local SortFunc = { + [XRewardType.Item] = SortItems, + [XRewardType.Character] = SortCharacters, + [XRewardType.Equip] = SortEquips, + [XRewardType.Fashion] = SortFashions, + [XRewardType.BaseEquip] = SortBaseEquips, + [XRewardType.Furniture] = SortFurnitures, + [XRewardType.HeadPortrait] = SortHeadPortraits, + [XRewardType.DormCharacter] = SortDormCharacter, + [XRewardType.ChatEmoji] = SortChatEmoji, + [XRewardType.WeaponFashion] = SortWeaponFashions, + [XRewardType.Collection] = SortCollection, + [XRewardType.Background] = SortBackground, + [XRewardType.Partner] = SortPartner, + [XRewardType.Nameplate] = SortNameplate, +} + +local RewardsFilter = { + [XRewardType.Pokemon] = 16 +} +--==============================-- +--desc: 奖励过滤 +--@rewardGoodsList: 奖励列表 +--@return 过滤后列表 +--==============================-- +local function FilterRewardsGoodsList(rewardGoodsList) + local rewardList = {} + for k, v in pairs(rewardGoodsList) do + if not RewardsFilter[v.RewardType] then + tableInsert(rewardList, v) + end + end + + return rewardList +end + +--==============================-- + +--desc: 奖励排序 +--@rewardGoodsList: 奖励列表 +--@return 排序后列表 +--==============================-- +local function SortRewardGoodsList(rewardGoodsList) + if not rewardGoodsList then + XLog.Warning("XRewardManager.SortRewardGoodsList: rewardGoodsList is nil") + return + end + + tableSort(rewardGoodsList, function(a, b) + local rewardType1, rewardType2 = a.RewardType, b.RewardType + + if rewardType1 ~= rewardType2 then + return SortRewardTypePrioriy[rewardType1] > SortRewardTypePrioriy[rewardType2] + end + + return SortFunc[rewardType1](a, b) + end) + + return rewardGoodsList +end + +--==============================-- +--desc: 合并相同奖励 +--@rewardGoodsList: 奖励列表 +--@return 合并列表 +--==============================-- +local function MergeRewardGoodsList(rewardGoodsList) + if not rewardGoodsList then + XLog.Warning("XRewardManager.MergeRewardGoodsList: rewardGoodsList is nil") + return + end + + local mergeList = {} + local mergeDict = {} + + for _, goods in pairs(rewardGoodsList) do + if goods.RewardType == XRewardType.Character or + goods.RewardType == XRewardType.Equip then + tableInsert(mergeList, goods) + else + local oldGoods = mergeDict[goods.TemplateId] + + if oldGoods then + mergeDict[goods.TemplateId].Count = mergeDict[goods.TemplateId].Count + goods.Count + else + mergeDict[goods.TemplateId] = CloneRewardGoods(goods) + end + end + end + + for _, goods in pairs(mergeDict) do + tableInsert(mergeList, goods) + end + + return mergeList +end + +--==============================-- +--desc: 奖励合并排序 +--@rewardGoodsList: 奖励列表 +--@return 处理完列表 +--==============================-- +local function MergeAndSortRewardGoodsList(rewardGoodsList) + if not rewardGoodsList then + XLog.Warning("XRewardManager.MergeAndSortRewardGoodsList: rewardGoodsList is nil") + return + end + + return SortRewardGoodsList(MergeRewardGoodsList(rewardGoodsList)) +end + +function XRewardManager.Init() + local rewardTable = XTableManager.ReadByIntKey(TABLE_REWARD_PATH, XTable.XTableReward, "Id") + local rewardGoodsTable = XTableManager.ReadByIntKey(TABLE_REWARD_GOODS_PATH, XTable.XTableRewardGoods, "Id") + + for k, v in pairs(rewardTable) do + local list = {} + for _, id in pairs(v.SubIds) do + local tab = rewardGoodsTable[id] + if not tab then + XLog.Error("XRewardManager.Init error: can not found reward, id = " .. id) + return + end + local temp = XRewardManager.CreateRewardGoodsByTemplate(tab) + if temp then + tableInsert(list, temp) + end + end + + RewardSubIds[k] = v.SubIds + RewardTemplates[k] = list + end + + RewardTemplates = XReadOnlyTable.Create(RewardTemplates) + RewardSubIds = XReadOnlyTable.Create(RewardSubIds) +end + +function XRewardManager.GetRewardSubId(id, index) + local rewardSubIds = RewardSubIds[id] + if not rewardSubIds then + XLog.Error("XRewardManager.GetRewardSubId error: can not found SubIds, id is " .. id) + return + end + + return rewardSubIds[index] +end + +function XRewardManager.GetRewardList(id) + local rewardList = RewardTemplates[id] + if not rewardList then + XLog.Error("XRewardManager.GetRewardList error: can not found reward, id is " .. id) + return + end + + return rewardList +end + +function XRewardManager.GetRewardListNotCount(id) + local rewardList = RewardTemplates[id] + local rewardNotCountList = {} + if not rewardList then + XLog.Error("XRewardManager.GetRewardList error: can not found reward, id is " .. id) + return + end + + for _, Val in pairs(rewardList) do + local tmpList = {} + for k, v in pairs(Val) do + if k ~= "Count" then + tmpList[k] = v + end + end + table.insert(rewardNotCountList, tmpList) + end + return rewardNotCountList +end + +function XRewardManager.CheckRewardOwn(rewardType, templateId) + local isHave = false + local ownRewardIsLimitTime = false --拥有的是否限时 + local rewardIsLimitTime = false + local leftTime = 0 + if not rewardType or not templateId then return isHave, ownRewardIsLimitTime, rewardIsLimitTime, leftTime end + + if XRewardManager.IsRewardFashion(rewardType, templateId) then + isHave = true + elseif XRewardManager.IsRewardWeaponFashion(rewardType, templateId) then + local weaponFashionId = XDataCenter.ItemManager.GetWeaponFashionId(templateId) + local ownWeaponFashion = XDataCenter.WeaponFashionManager.GetWeaponFashion(weaponFashionId) + if ownWeaponFashion then + isHave = XDataCenter.WeaponFashionManager.CheckHasFashion(weaponFashionId) + ownRewardIsLimitTime = ownWeaponFashion:IsTimeLimit() + rewardIsLimitTime = XDataCenter.ItemManager.IsWeaponFashionTimeLimit(templateId) + leftTime = ownWeaponFashion:GetLeftTime() + end + elseif XRewardManager.IsRewardHeadPortrait(rewardType, templateId) then + isHave = true + elseif XRewardManager.IsRewardDormCharacter(rewardType, templateId) then + isHave = true + elseif XRewardManager.IsRewardBackground(rewardType, templateId) then + isHave = true + elseif XRewardManager.IsRewardCharacter(rewardType, templateId) then + isHave = true + -- elseif XRewardManager.IsRewardEquip(rewardType, templateId) then -- 取消装备已拥有显示限制 + -- isHave = true + end + return isHave, ownRewardIsLimitTime, rewardIsLimitTime, leftTime +end + +function XRewardManager.CheckRewardGoodsListIsOwn(rewardGoodsList) + if not rewardGoodsList then return false end + local isHave = false + local ownRewardIsLimitTime = false + local rewardIsLimitTime = false + local leftTime = 0 + + for k, v in pairs(rewardGoodsList) do + isHave, ownRewardIsLimitTime, rewardIsLimitTime, leftTime = XRewardManager.CheckRewardOwn(v.RewardType, v.TemplateId) + if isHave then + return isHave, ownRewardIsLimitTime, rewardIsLimitTime, leftTime + end + end + return isHave, ownRewardIsLimitTime, rewardIsLimitTime, leftTime +end + +function XRewardManager.IsRewardWeaponFashion(rewardType, templateId) -- 是否拥有武器涂装 + return (rewardType == XRewardManager.XRewardType.Item or rewardType == XRewardManager.XRewardType.WeaponFashion) and XDataCenter.ItemManager.IsWeaponFashion(templateId) +end + +function XRewardManager.IsRewardFashion(rewardType, templateId) -- 是否拥有涂装 + return (rewardType == XRewardManager.XRewardType.Fashion and XDataCenter.FashionManager.CheckHasFashion(templateId)) + or (rewardType == XRewardManager.XRewardType.Character and XDataCenter.CharacterManager.IsOwnCharacter(templateId)) +end + +function XRewardManager.IsRewardHeadPortrait(rewardType, templateId) -- 是否拥有头像 + return (rewardType == XRewardManager.XRewardType.HeadPortrait and XDataCenter.HeadPortraitManager.IsHeadPortraitValid(templateId)) +end + +function XRewardManager.IsRewardDormCharacter(rewardType, templateId) -- 是否拥有宿舍小人 + return (rewardType == XRewardManager.XRewardType.DormCharacter and XDataCenter.DormManager.CheckHaveDormCharacterByRewardId(templateId)) +end + +function XRewardManager.IsRewardBackground(rewardType, templateId) -- 是否拥有界面场景 + return (rewardType == XRewardManager.XRewardType.Background and XDataCenter.PhotographManager.CheckSceneIsHaveById(templateId)) +end + +function XRewardManager.IsRewardCharacter(rewardType, templateId) -- 是否拥有角色 + return (rewardType == XRewardManager.XRewardType.Character and XDataCenter.CharacterManager.IsOwnCharacter(templateId)) +end + +function XRewardManager.IsRewardEquip(rewardType, templateId) -- 是否拥有武器 + return (rewardType == XRewardManager.XRewardType.Equip and XDataCenter.EquipManager.GetFirstEquip(templateId)) +end + +XRewardManager.XRewardType = XRewardType +XRewardManager.CreateRewardGoodsByTemplate = CreateRewardGoodsByTemplate +XRewardManager.CreateRewardGoods = CreateRewardGoods +XRewardManager.SortRewardGoodsList = SortRewardGoodsList +XRewardManager.MergeAndSortRewardGoodsList = MergeAndSortRewardGoodsList +XRewardManager.FilterRewardGoodsList = FilterRewardsGoodsList \ No newline at end of file diff --git a/Resources/Scripts/XManager/XRobotManager.lua b/Resources/Scripts/XManager/XRobotManager.lua new file mode 100644 index 00000000..99004ae8 --- /dev/null +++ b/Resources/Scripts/XManager/XRobotManager.lua @@ -0,0 +1,285 @@ +local XRobot = require("XEntity/XRobot/XRobot") + +local pairs = pairs +local tableInsert = table.insert +local stringFormat = string.format +local mathFloor = math.floor +local CsXTextManagerGetText = CsXTextManagerGetText + +local TABLE_ROBOT = "Share/Robot/Robot.tab" +local TABLE_ROBOT_PARTNER = "Share/Robot/RobotPartner.tab" + +local RobotTemplates = {} +local RobotPartnerTemplates = {} +local Robots = {} + +XRobotManager = XRobotManager or {} + +function XRobotManager.Init() + RobotTemplates = XTableManager.ReadByIntKey(TABLE_ROBOT, XTable.XTableRobot, "Id") + RobotPartnerTemplates = XTableManager.ReadByIntKey(TABLE_ROBOT_PARTNER, XTable.XTableRobotPartner, "Id") +end + +local function GetRobot(robotId) + local robot = Robots[robotId] + if not robot then + robot = XRobot.New(robotId) + Robots[robotId] = robot + end + return robot +end + +function XRobotManager.GetConfigPath() + return TABLE_ROBOT +end + +function XRobotManager.CheckRobotExist(robotId) + if not XTool.IsNumberValid(robotId) then return false end + return not XTool.IsTableEmpty(RobotTemplates[robotId]) +end + +function XRobotManager.GetCharacterId(robotId) + if not XRobotManager.CheckIsRobotId(robotId) then return robotId end + local charId = 0 + if RobotTemplates[robotId] then + charId = RobotTemplates[robotId].CharacterId + end + return charId +end + +function XRobotManager.GetRobotTemplate(robotId) + if not XTool.IsNumberValid(robotId) then return end + + local config = RobotTemplates[robotId] + if not config then + XLog.Error("XRobotManager.GetRobotTemplate error: 配置不存在, robotId: " .. robotId .. ", path: " .. TABLE_ROBOT) + return + end + return config +end + +function XRobotManager.GetRobotPartnerTemplate(robotPartnerId) + if not XTool.IsNumberValid(robotPartnerId) then return end + + local config = RobotPartnerTemplates[robotPartnerId] + if not config then + XLog.Error("XRobotManager.GetRobotPartnerTemplate error: 配置不存在, robotPartnerId: " .. robotPartnerId .. ", path: " .. TABLE_ROBOT_PARTNER) + return + end + return config +end + +function XRobotManager.GetRobotSkillRemoveDic(robotId) + local removeDic = {} + local config = XRobotManager.GetRobotTemplate(robotId) + for _, skillId in pairs(config.RemoveSkillId) do + if XTool.IsNumberValid(skillId) then + removeDic[skillId] = skillId + end + end + return removeDic +end + +function XRobotManager.GetRobotNpcTemplate(robotId) + local RobotCfg = RobotTemplates[robotId] + if not RobotCfg then return end + local npcId = XCharacterConfigs.GetCharNpcId(RobotCfg.CharacterId, RobotCfg.CharacterQuality) + local template = XCharacterConfigs.GetNpcTemplate(npcId) + return template +end + +function XRobotManager.GetRobotJobType(robotId) + local template = XRobotManager.GetRobotNpcTemplate(robotId) + return template and template.Type or 0 +end + +function XRobotManager.GetRobotCharacterQuality(robotId) + local template = XRobotManager.GetRobotTemplate(robotId) + return template and template.CharacterQuality or 0 +end + +function XRobotManager.CheckIsRobotId(id) + return XTool.IsNumberValid(id) and id < 1000000 +end + +function XRobotManager.GetRobotCharacterType(robotId) + local characterId = XRobotManager.GetCharacterId(robotId) + if not XTool.IsNumberValid(characterId) then return end + return XCharacterConfigs.GetCharacterType(characterId) +end + +function XRobotManager.GetRobotCharacterLevel(robotId) + local template = XRobotManager.GetRobotTemplate(robotId) + return template and template.CharacterLevel or 0 +end + +function XRobotManager.CheckIdToCharacterId(id) + if XRobotManager.CheckIsRobotId(id) then + return XRobotManager.GetCharacterId(id) + else + return id + end +end + +--是否为授格者 +function XRobotManager.IsIsomer(robotId) + local characterId = XRobotManager.GetCharacterId(robotId) + return XCharacterConfigs.IsIsomer(characterId) +end + +function XRobotManager.GetRobotIdFilterListByCharacterType(robotIdList, characterType) + local filterRobotIdList = {} + if XTool.IsTableEmpty(robotIdList) then + return filterRobotIdList + end + + local robotCharacterType + local characterId + for _, robotId in ipairs(robotIdList) do + characterId = XRobotManager.GetCharacterId(robotId) + if characterId > 0 then + robotCharacterType = XCharacterConfigs.GetCharacterType(characterId) + if robotCharacterType == characterType then + tableInsert(filterRobotIdList, robotId) + end + end + end + return filterRobotIdList +end + +---========================================================== +--- 根据‘robotId’获取机器人的头像,如果没有配置时装,则使用默认时装头像 +--- 返回的是头像路径 +---@param robotId number +---@return string +---========================================================== +function XRobotManager.GetRobotSmallHeadIcon(robotId) + local robotTemplate = RobotTemplates[robotId] + if robotTemplate == nil then + XLog.ErrorTableDataNotFound("XRobotManager.GetRobotSmallHeadIcon", "机器人配置数据", TABLE_ROBOT, "id", tostring(robotId)) + return + end + + local result + local fashionId + local isAchieveMaxLiberation = XDataCenter.ExhibitionManager.IsMaxLiberationLevel(robotTemplate.LiberateLv) + + if robotTemplate.FashionId then + -- 配置了机器人的FashionId + fashionId = robotTemplate.FashionId + else + -- 默认时装 + local characterId = XRobotManager.GetCharacterId(robotId) + fashionId = XCharacterConfigs.GetCharacterTemplate(characterId).DefaultNpcFashtionId + end + + result = isAchieveMaxLiberation and XDataCenter.FashionManager.GetFashionSmallHeadIconLiberation(fashionId) or + XDataCenter.FashionManager.GetFashionSmallHeadIcon(fashionId) + + return result +end + +--==============================-- +--desc: 获取机器人队长技能描述 +--@robotId: 机器人id +--@return 技能Data +--==============================-- +function XRobotManager.GetRobotCaptainSkillInfo(robotId) + local robotTemplate = XRobotManager.GetRobotTemplate(robotId) + local captianSkillId = XCharacterConfigs.GetCharacterCaptainSkill(robotTemplate.CharacterId) + local skillLevel = 1 + + return XCharacterConfigs.GetCaptainSkillInfo(robotTemplate.CharacterId, skillLevel) +end + +--desc: 获取机器人队长技能描述 +function XRobotManager.GetRobotCaptainSkillDesc(robotId) + local captianSkillInfo = XRobotManager.GetRobotCaptainSkillInfo(robotId) + return captianSkillInfo and captianSkillInfo.Level > 0 and captianSkillInfo.Intro or stringFormat("%s%s", captianSkillInfo.Intro, CsXTextManagerGetText("CaptainSkillLock")) +end + +--desc: 获取机器人武器涂装 +function XRobotManager.GetRobotWeaponFashionId(robotId) + local config = XRobotManager.GetRobotTemplate(robotId) + if not config then return end + + local weaponFashionId = config.WeaponFashion + if not XTool.IsNumberValid(weaponFashionId) then return end + + return weaponFashionId +end + +local function GetRobotShowAbility(robotId) + local template = XRobotManager.GetRobotTemplate(robotId) + return template and template.ShowAbility or 0 +end + +function XRobotManager.GetRobotShowAbility(robotId) + return GetRobotShowAbility(robotId) +end + +--获取机器人战力 +function XRobotManager.GetRobotAbility(robotId) + --当配置了展示用战力字段时,直接返回ShowAbility + local ability = GetRobotShowAbility(robotId) + if XTool.IsNumberValid(ability) then + return ability + end + + --否则获取公式计算值 + local robot = GetRobot(robotId) + return robot:GetAbility() +end + +--获取机器人技能等级字典 +--@param forDisplay:是否用于展示 +function XRobotManager.GetRobotSkillLevelDic(robotId, forDisplay) + local robot = GetRobot(robotId) + return robot:GetSkillLevelDic(forDisplay) +end + +--获取机器人原始属性 +function XRobotManager.GetRobotAttribs(robotId) + local robot = GetRobot(robotId) + return robot:GetAtrributes() +end + +--获取机器人宠物 +function XRobotManager.GetRobotPartner(robotId) + local robot = GetRobot(robotId) + return robot:GetPartner() +end + +--获取机器人宠物战力 +function XRobotManager.GetRobotPartnerAbility(robotId) + local partner = XRobotManager.GetRobotPartner(robotId) + return not XTool.IsTableEmpty(partner) and partner:GetAbility() or 0 +end + +--获取机器人装备共鸣增加额外属性列表 +function XRobotManager.GetRobotResonanceAbilityList(robotId) + local robot = GetRobot(robotId) + return robot:ConstructResonanceAbilityList() +end + +--获取机器人装备觉醒(超频)增加额外属性列表 +function XRobotManager.GetRobotAwakenAbilityList(robotId) + local robot = GetRobot(robotId) + return robot:ConstructAwakenAbilityList() +end + +--获取机器人属性 + 额外属性 +function XRobotManager.GetRobotAttribWithExtraAttrib(robotId, extraAttribIds) + local robot = GetRobot(robotId) + local attrs = XTool.Clone(robot:GetAtrributes()) + for _, attribId in pairs(extraAttribIds or {}) do + XAttribManager.DoAddAttribsByAttrAndAddId(attrs, attribId) + end + return attrs +end + +--获取一个可以自由设置属性的机器人实体 +function XRobotManager.GetRobotTemp(robotId) + local robot = GetRobot(robotId) + return XTool.Clone(robot) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XRoomCharFilterTipsManager.lua b/Resources/Scripts/XManager/XRoomCharFilterTipsManager.lua new file mode 100644 index 00000000..d5921c9b --- /dev/null +++ b/Resources/Scripts/XManager/XRoomCharFilterTipsManager.lua @@ -0,0 +1,357 @@ +XRoomCharFilterTipsManagerCreator = function() + local XRoomCharFilterTipsManager = {} + + local SelectTag = {} + local TempSelectTag = {} + + local SortTag + local TempSortTag + + local CharacterTypeDic = {} + local SortFunction = {} + + local function InitSortFunction() + local LevelSort = function(idA, idB, isAscendOrder) + local levelA = XDataCenter.CharacterManager.GetCharacterLevel(idA) + local levelB = XDataCenter.CharacterManager.GetCharacterLevel(idB) + local isSort = false + if levelA ~= levelB then + isSort = true + if isAscendOrder then + return isSort, levelA < levelB + end + return isSort, levelA > levelB + end + return isSort + end + + local QualitySort = function(idA, idB, isAscendOrder) + local qualityA = XDataCenter.CharacterManager.GetCharacterQuality(idA) + local qualityB = XDataCenter.CharacterManager.GetCharacterQuality(idB) + local isSort = false + if qualityA ~= qualityB then + isSort = true + if isAscendOrder then + return isSort, qualityA < qualityB + end + return isSort, qualityA > qualityB + end + return isSort + end + + local AbilitySort = function(idA, idB, isAscendOrder) + local abilityA = XDataCenter.CharacterManager.GetCharacterHaveRobotAbilityById(idA) + local abilityB = XDataCenter.CharacterManager.GetCharacterHaveRobotAbilityById(idB) + local isSort = false + if abilityA ~= abilityB then + isSort = true + if isAscendOrder then + return isSort, abilityA < abilityB + end + return isSort, abilityA > abilityB + end + return isSort + end + + SortFunction[XRoomCharFilterTipsConfigs.EnumSortTag.Default] = function(idA, idB, isAscendOrder, alreadySortTag, isSortAbility) + local isSort, sortResult + if alreadySortTag ~= XRoomCharFilterTipsConfigs.EnumSortTag.Level then + isSort, sortResult = LevelSort(idA, idB, isAscendOrder) + if isSort then + return sortResult + end + end + + if isSortAbility and alreadySortTag ~= XRoomCharFilterTipsConfigs.EnumSortTag.Ability then + isSort, sortResult = AbilitySort(idA, idB, isAscendOrder) + if isSort then + return sortResult + end + end + + if alreadySortTag ~= XRoomCharFilterTipsConfigs.EnumSortTag.Quality then + isSort, sortResult = QualitySort(idA, idB, isAscendOrder) + if isSort then + return sortResult + end + end + + local priorityA = XCharacterConfigs.GetCharacterPriority(idA) + local priorityB = XCharacterConfigs.GetCharacterPriority(idB) + if priorityA ~= priorityB then + if isAscendOrder then + return priorityA < priorityB + end + return priorityA > priorityB + end + + return idA > idB + end + SortFunction[XRoomCharFilterTipsConfigs.EnumSortTag.Quality] = function(idA, idB, isAscendOrder) + local isSort, sortResult = QualitySort(idA, idB, isAscendOrder) + if isSort then + return sortResult + end + return SortFunction[XRoomCharFilterTipsConfigs.EnumSortTag.Default](idA, idB, isAscendOrder, XRoomCharFilterTipsConfigs.EnumSortTag.Quality, true) + end + SortFunction[XRoomCharFilterTipsConfigs.EnumSortTag.Level] = function(idA, idB, isAscendOrder) + local isSort, sortResult = LevelSort(idA, idB, isAscendOrder) + if isSort then + return sortResult + end + return SortFunction[XRoomCharFilterTipsConfigs.EnumSortTag.Default](idA, idB, isAscendOrder, XRoomCharFilterTipsConfigs.EnumSortTag.Level, true) + end + SortFunction[XRoomCharFilterTipsConfigs.EnumSortTag.Ability] = function(idA, idB, isAscendOrder) + local isSort, sortResult = AbilitySort(idA, idB, isAscendOrder) + if isSort then + return sortResult + end + return SortFunction[XRoomCharFilterTipsConfigs.EnumSortTag.Default](idA, idB, isAscendOrder, XRoomCharFilterTipsConfigs.EnumSortTag.Ability) + end + end + + local function GetSelectTagByCharacterType(characterType) + if not characterType then + characterType = XCharacterConfigs.CharacterType.Normal + end + return CharacterTypeDic[characterType] and CharacterTypeDic[characterType]["SelectTag"] or {} + end + + local function GetSortTagByCharacterType(characterType) + if not characterType then + characterType = XCharacterConfigs.CharacterType.Normal + end + return CharacterTypeDic[characterType] and CharacterTypeDic[characterType]["SortTag"] + end + + --- + --- 根据character的类型来获取characterId + local function GetCharacterIdByValueType(character) + local characterId + if type(character) == "table" then + characterId = character.GetCharacterId and character:GetCharacterId() or character.Id + else + characterId = character + end + return characterId + end + + --- + --- 初始化缓存 + function XRoomCharFilterTipsManager.InitTemp(characterType) + local selectTag = GetSelectTagByCharacterType(characterType) + TempSelectTag = XTool.Clone(selectTag) + TempSortTag = GetSortTagByCharacterType(characterType) + end + + --- + --- 使用缓存 + function XRoomCharFilterTipsManager.UseTemp(characterType) + if not characterType then + characterType = XCharacterConfigs.CharacterType.Normal + end + if not CharacterTypeDic[characterType] then + CharacterTypeDic[characterType] = {} + end + CharacterTypeDic[characterType]["SelectTag"] = TempSelectTag + CharacterTypeDic[characterType]["SortTag"] = TempSortTag + end + + --- + --- 清除缓存 + function XRoomCharFilterTipsManager.ClearTemp() + TempSelectTag = {} + TempSortTag = nil + end + + --- + --- 被筛选的UI切换或关闭时将所有的选择标签数据还原成默认状态 + function XRoomCharFilterTipsManager.Reset() + TempSelectTag = {} + TempSortTag = nil + CharacterTypeDic = {} + end + + function XRoomCharFilterTipsManager.Init() + InitSortFunction() + end + ---------------------------------------------------- 筛选标签 --------------------------------------------------------- + + --- + --- 更新缓存中的筛选标签选择状态 + function XRoomCharFilterTipsManager.SetSelectFilterTag(groupId, filterTagId, isSelect) + if isSelect then + if not TempSelectTag[groupId] then + TempSelectTag[groupId] = {} + end + TempSelectTag[groupId][filterTagId] = filterTagId + else + (TempSelectTag[groupId] or {})[filterTagId] = nil + if XTool.IsTableEmpty(TempSelectTag[groupId]) then + TempSelectTag[groupId] = nil + end + end + end + + --- + --- 获取缓存中的选择筛选标签,返回给UI进行筛选 + function XRoomCharFilterTipsManager.GetSelectFilterTag() + return TempSelectTag + end + + -- 判断是否满足筛选项 + function XRoomCharFilterTipsManager.IsFilterSelectTag(templateId, characterType, isUseTempSelectTag) + local selectTag = isUseTempSelectTag and TempSelectTag or GetSelectTagByCharacterType(characterType) + if XTool.IsTableEmpty(selectTag) then + return true + end + + local career = XCharacterConfigs.GetCharDetailCareer(templateId) + local obtainElementList = XCharacterConfigs.GetCharDetailObtainElementList(templateId) + local tagValue + local isFill + for groupId, filterTagIdDic in pairs(selectTag) do + for filterTagId, _ in pairs(filterTagIdDic) do + tagValue = XRoomCharFilterTipsConfigs.GetFilterTagValue(filterTagId) + if groupId == XRoomCharFilterTipsConfigs.EnumFilterTagGroup.Career then + if tagValue ~= career then + return false + end + elseif groupId == XRoomCharFilterTipsConfigs.EnumFilterTagGroup.Element then + isFill = false + for _, element in pairs(obtainElementList) do + if element == tagValue then + isFill = true + break + end + end + if not isFill then + return false + end + end + end + end + return true + end + + --- + --- 打开界面时,检查当前筛选标签是否被选中 + function XRoomCharFilterTipsManager.CheckFilterTagIsSelect(groupId, filterTagId, characterType) + local isSelect = false + local selectTag = GetSelectTagByCharacterType(characterType) + + if (selectTag[groupId] or {})[filterTagId] then + isSelect = true + end + + return isSelect + end + + --- + --- 根据选择的标签'selectTagGroupDic'构建'tagCacheDic'与'selectTagList' + --- + ---@param tagCacheDic table 存放在具体玩法界面上的 标签对应角色的缓存,筛选过一次后,不必每次都重新生成 + ---@param selectTagGroupDic table 选择的筛选标签字典,由XUiRoomCharacterFilterTips传递 + --- + ---@param allCharList table 存放未进行筛选时的所有相同角色类型的角色 + ---存放的值为number时就是characterId + ---存放的值为table(Entity)时,一定要有 GetCharacterId()接口 或 Id 字段 + --- + ---@param judgeCb function 判断是否满足筛选条件的函数,由具体玩法实现 + ---@param filterRefreshCb function 筛选后的刷新函数,由具体玩法实现 + ---@param isThereFilterDataCb function 判断是否有符合筛选角色的函数,由XUiRoomCharacterFilterTips传递 + function XRoomCharFilterTipsManager.Filter(tagCacheDic, selectTagGroupDic, allCharList, judgeCb, filterRefreshCb, isThereFilterDataCb) + local filteredData = {} + local selectTagList = {} -- 选择的标签Id数组 + + if XTool.IsTableEmpty(allCharList) then + XLog.Error("XRoomCharFilterTipsManager.Filter函数错误,参数allCharList为空") + return + end + + local characterType = XCharacterConfigs.GetCharacterType(GetCharacterIdByValueType(allCharList[1])) or XCharacterConfigs.CharacterType.Normal + -- 遍历选择的标签 + for groupId, tagDic in pairs(selectTagGroupDic) do + for tag, _ in pairs(tagDic) do + if tagCacheDic[tag] == nil then + tagCacheDic[tag] = {} + end + + if tagCacheDic[tag][characterType] == nil then + tagCacheDic[tag][characterType] = {} + local tagValue = XRoomCharFilterTipsConfigs.GetFilterTagValue(tag) + -- 遍历所有角色 + for _, character in pairs(allCharList) do + if judgeCb(groupId, tagValue, character) then + -- 当前角色满足该标签 + local characterId = GetCharacterIdByValueType(character) + tagCacheDic[tag][characterType][characterId] = character + end + end + end + table.insert(selectTagList, tag) + end + end + + -- 没有选择筛选标签 + if next(selectTagList) == nil then + if isThereFilterDataCb and isThereFilterDataCb(allCharList) then + filterRefreshCb(allCharList) + return + end + end + + -- 遍历所有角色,进行过滤 + for _, character in pairs(allCharList) do + local isPass = true + for _,tag in pairs(selectTagList) do + local characterId = GetCharacterIdByValueType(character) + if not tagCacheDic[tag][characterType][characterId] then + -- 不满足其中一个标签,跳出标签遍历 + isPass = false + break + end + end + if isPass then + table.insert(filteredData, character) + end + end + + if isThereFilterDataCb and isThereFilterDataCb(filteredData) then + filterRefreshCb(filteredData) + end + end + + + ---------------------------------------------------- 排序标签 --------------------------------------------------------- + + --- + --- 更新缓存中的的排序标签 + function XRoomCharFilterTipsManager.SetSelectSortTag(sortTagId) + TempSortTag = sortTagId + end + + --- + --- 获取缓存中的选择筛选标签,返回给UI进行排序 + function XRoomCharFilterTipsManager.GetSelectSortTag() + return TempSortTag + end + + --- + --- 打开界面时,检查当前排序标签是否被选中 + function XRoomCharFilterTipsManager.CheckSortTagIsSelect(sortTagId, characterType) + local sortTag = GetSortTagByCharacterType(characterType) + return sortTag == sortTagId + end + + function XRoomCharFilterTipsManager.GetSort(idA, idB, characterType, isAscendOrder) + if not idA or not idB then + return false + end + local sortTag = TempSortTag or GetSortTagByCharacterType(characterType) or XRoomCharFilterTipsConfigs.EnumSortTag.Default + return SortFunction[sortTag](idA, idB, isAscendOrder) + end + + XRoomCharFilterTipsManager.Init() + return XRoomCharFilterTipsManager +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XRoomManager.lua b/Resources/Scripts/XManager/XRoomManager.lua new file mode 100644 index 00000000..2df98cf5 --- /dev/null +++ b/Resources/Scripts/XManager/XRoomManager.lua @@ -0,0 +1,1949 @@ +XRoomManagerCreator = function() + local XRoomManager = { + IsOpen = false, + UiRoom = nil, + UiOnlineInstance = nil, + Matching = false, + MatchStageId = nil, + RoomData = nil, + StageInfo = nil, --关卡 + } + + XRoomManager.PlayerState = { + Normal = 0, + Ready = 1, + Select = 2, + Clump = 3, + Fight = 4, + Settle = 5, + } + + XRoomManager.IndexType = { + Left = 1, + Center = 2, + Right = 3, + Max = 3 + } + + XRoomManager.RoomState = + { + Normal = 0, + Fight = 1, + Settle = 2, + Close = 3, + } + + + local RequestProto = { + -- gateServer + JoinFightRequest = "JoinFightRequest", --请求进入战斗服(gate) + + -- 普通联机 + CreateRoomRequest = "CreateRoomRequest", --创建房间 + MatchRoomRequest = "MatchRoomRequest", --匹配 + CancelMatchRequest = "CancelMatchRequest", --取消匹配 + QuitRoomRequest = "QuitRoomRequest", --退出房间 + ReadyRequest = "ReadyRequest", --准备 + CancelReadyRequest = "CancelReadyRequest", --取消准备 + EnterFightRequest = "EnterFightRequest", -- 进入战斗 + SelectRequest = "SelectRequest", --抽卡 + ChangeLeaderRequest = "ChangeLeaderRequest", --切换房主 + KickOutRequest = "KickOutRequest", --踢人 + AddLikeRequest = "AddLikeRequest", -- 添加喜欢 + UpdateLoadProcessRequest = "UpdateLoadProcessRequest", -- 更新进度 + EnterTargetRoomRequest = "EnterTargetRoomRequest", -- 进入目标房间 + SelectRewardRequest = "SelectRewardRequest", -- 选择奖励 + BeginSelectRequest = "BeginSelectRequest", -- 进入切换角色状态 + EndSelectRequest = "EndSelectRequest", -- 退出切换角色状态 + SetStageLevelRequest = "SetStageLevelRequest", -- 请求设置副本难度 + SetAutoMatchRequest = "SetAutoMatchRequest", --设置自动匹配是否开启 + SetAbilityLimitRequest = "SetAbilityLimitRequest", --修改房间战力限制 + + -- 区域联机相关 + ArenaOnlineCreateRoomRequest = "ArenaOnlineCreateRoomRequest", --创建房间 + ArenaOnlineStartMatchReqeust = "ArenaOnlineStartMatchReqeust", --匹配 + ArenaOnlineCancelMatchRequest = "ArenaOnlineCancelMatchRequest", --取消匹配 + ArenaOnlineQuitRoomRequest = "ArenaOnlineQuitRoomRequest", --退出房间 + ArenaOnlineReadyRequest = "ArenaOnlineReadyRequest", --准备 + ArenaOnlineCancelReadyRequest = "ArenaOnlineCancelReadyRequest", --取消准备 + ArenaOnlineEnterFightRequest = "ArenaOnlineEnterFightRequest", -- 进入战斗 + ArenaOnlineSelectRequest = "ArenaOnlineSelectRequest", --抽卡 + ArenaOnlineChangeLeaderRequest = "ArenaOnlineChangeLeaderRequest", --切换房主 + ArenaOnlineKickOutRequest = "ArenaOnlineKickOutRequest", --踢人 + ArenaOnlineAddLikeRequest = "ArenaOnlineAddLikeRequest", -- 添加喜欢 + ArenaOnlineUpLoadProcessRequest = "ArenaOnlineUpLoadProcessRequest", -- 更新进度 + ArenaOnlineEnterRoomRequest = "ArenaOnlineEnterRoomRequest", -- 进入目标房间 + ArenaOnlineSelectRewardRequest = "ArenaOnlineSelectRewardRequest", -- 选择奖励 + ArenaOnlineBeginSelectRequest = "ArenaOnlineBeginSelectRequest", -- 进入切换角色状态 + ArenaOnlineEndSelectRequest = "ArenaOnlineEndSelectRequest", -- 退出切换角色状态 + ArenaOnlineSetLevelRequest = "ArenaOnlineSetLevelRequest", -- 请求设置副本难度 + ArenaOnlineSetAutoMatchRequest = "ArenaOnlineSetAutoMatchRequest", --设置自动匹配是否开启 + ArenaOnlineSetAbilityLimitRequest = "ArenaOnlineSetAbilityLimitRequest", --修改房间战力限制 + ArenaOnlineSetStageIdRequest = "ArenaOnlineSetStageIdRequest", --修改关卡 + + -- 夏活拍照关联机相关 + FubenPhotoCreateRoomRequest = "FubenPhotoCreateRoomRequest", --创建房间 + FubenPhotoMatchRoomRequest = "FubenPhotoMatchRoomRequest", --匹配 + FubenPhotoCancelMatchRequest = "FubenPhotoCancelMatchRequest", --取消匹配 + FubenPhotoQuitRoomRequest = "FubenPhotoQuitRoomRequest", --退出房间 + FubenPhotoReadyRequest = "FubenPhotoReadyRequest", --准备 + FubenPhotoCancelReadyRequest = "FubenPhotoCancelReadyRequest", --取消准备 + FubenPhotoEnterFightRequest = "FubenPhotoEnterFightRequest", -- 进入战斗 + FubenPhotoChangeLeaderRequest = "FubenPhotoChangeLeaderRequest", --切换房主 + FubenPhotoKickOutRequest = "FubenPhotoKickOutRequest", --踢人 + FubenPhotoAddLikeRequest = "FubenPhotoAddLikeRequest", -- 添加喜欢 + FubenPhotoUpdateLoadProcessRequest = "FubenPhotoUpdateLoadProcessRequest", -- 更新进度 + FubenPhotoEnterTargetRoomRequest = "FubenPhotoEnterTargetRoomRequest", -- 进入目标房间 + FubenPhotoBeginSelectRequest = "FubenPhotoBeginSelectRequest", -- 进入切换角色状态 + FubenPhotoEndSelectRequest = "FubenPhotoEndSelectRequest", -- 退出切换角色状态 + FubenPhotoSetAutoMatchRequest = "FubenPhotoSetAutoMatchRequest", --设置自动匹配是否开启 + FubenPhotoChangeMapRequest = "FubenPhotoChangeMapRequest", --修改关卡 + FubenPhotoSelectRequest = "FubenPhotoSelectRequest", --选择角色 + } + + function XRoomManager.Init() + CsXGameEventManager.Instance:RegisterEvent(XEventId.EVENT_FIGHT_EXIT, XRoomManager.OnFightExit) + end + + function XRoomManager.OnFightExit() + XLog.Debug("XRoomManager.OnFightExit") + CS.XFightNetwork.Disconnect() + end + + function XRoomManager.SetRoomData(roomData) + XRoomManager.RoomData = roomData + if not roomData and not XLuaUiManager.IsUiShow("UiMultiplayerRoom") and XLuaUiManager.IsUiLoad("UiMultiplayerRoom") then + XLuaUiManager.Remove("UiMultiplayerRoom") + end + end + + --获取默认角色 + function XRoomManager.GetDefaultChar() + local list = XDataCenter.CharacterManager.GetOwnCharacterList() + local char + for _, v in pairs(list) do + if not char or v.Ability > char.Ability then + char = v + end + end + return char + end + + function XRoomManager.CheckPlayerStagePass() + if not XRoomManager.RoomData then + return false + end + + for _, v in pairs(XRoomManager.RoomData.PlayerDataList) do + if v.Id == XPlayer.Id and v.HaveFirstPass then + return true + end + end + + return false + end + + --创建房间 + function XRoomManager.CreateRoom(stageId, cb) + local req = { + StageId = stageId, + StageLevel = 1, + AutoMatch = true, + } + XNetwork.Call(RequestProto.CreateRoomRequest, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XRoomManager.Matching = false + XRoomManager.MatchStageId = nil + XRoomManager.OnCreateRoom(res.RoomData) + if cb then + cb() + end + end) + end + + --夏活照相关创建房间 + function XRoomManager.PhotoCreateRoom(stageId, cb) + local req = { + StageId = stageId, + StageLevel = 1, + AutoMatch = true, + } + XNetwork.Call(RequestProto.FubenPhotoCreateRoomRequest, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XRoomManager.Matching = false + XRoomManager.MatchStageId = nil + XRoomManager.OnCreateRoom(res.RoomData) + if cb then + cb() + end + end) + end + + -- 区域联机创建房间 + function XRoomManager.ArenaOnlineCreateRoom(stageId, cb) + local req = { + ChallengeId = stageId, + ChallengeLevel = 1, + AutoMatch = true, + } + XNetwork.Call(RequestProto.ArenaOnlineCreateRoomRequest, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XRoomManager.Matching = false + XRoomManager.MatchStageId = nil + XRoomManager.OnCreateRoom(res.Room, XDataCenter.FubenManager.StageType.ArenaOnline) + if cb then + cb() + end + end) + end + + function XRoomManager.OnCreateRoom(roomData,stagetype) + -- 创建房间 + if XDataCenter.RoomManager.RoomData then + XLog.Error("XRoomManager.OnCreateRoom错误, RoomManager中RoomData已经有数据") + XRoomManager.SetRoomData(roomData) + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_REFRESH, roomData) + else + XRoomManager.SetRoomData(roomData) + XRoomManager.Matching = false + XRoomManager.MatchStageId = nil + --如果是聊天跳转,需要先关闭聊天 + if XLuaUiManager.IsUiShow("UiChatServeMain") then + XLuaUiManager.Close("UiChatServeMain") + end + -- XLuaUiManager.Open("UiOnLineTranscriptRoom") + XLuaUiManager.Open("UiMultiplayerRoom") + local stageId = roomData.StageId + local challengeId = roomData.ChallengeId + local stageInfo + if XDataCenter.FubenManager.StageType.ArenaOnline == stagetype then + stageInfo = XDataCenter.ArenaOnlineManager.GetStageInfo(challengeId) + else + stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + end + XDataCenter.RoomManager.StageInfo = stageInfo + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_ENTER_ROOM) + end + end + + function XRoomManager.BeginSelectRequest(cb) + if XRoomManager.StageInfo.Type == XDataCenter.FubenManager.StageType.ArenaOnline then + XRoomManager.ArenaOnlineBeginSelectRequest(cb) + elseif XRoomManager.StageInfo.Type == XDataCenter.FubenManager.StageType.SpecialTrain then + XRoomManager.PhotoBeginSelectRequest(cb) + else + XRoomManager.NormalBeginSelectRequest(cb) + end + end + + function XRoomManager.NormalBeginSelectRequest(cb) + XNetwork.Call(RequestProto.BeginSelectRequest, {}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + if cb then + cb() + end + end) + end + + function XRoomManager.PhotoBeginSelectRequest(cb) + XNetwork.Call(RequestProto.FubenPhotoBeginSelectRequest, {}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + if cb then + cb() + end + end) + end + + function XRoomManager.ArenaOnlineBeginSelectRequest(cb) + XNetwork.Call(RequestProto.ArenaOnlineBeginSelectRequest, {}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local roomData = XRoomManager.RoomData + for _, playerData in pairs(roomData.PlayerDataList) do + if XPlayer.Id == playerData.Id then + playerData.State = XDataCenter.RoomManager.PlayerState.Select + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_PLAYER_STAGE_REFRESH, playerData) + break + end + end + + if cb then + cb() + end + end) + end + + function XRoomManager.EndSelectRequest(cb) + if XRoomManager.StageInfo.Type == XDataCenter.FubenManager.StageType.ArenaOnline then + XRoomManager.ArenaOnlineEndSelectRequest(cb) + elseif XRoomManager.StageInfo.Type == XDataCenter.FubenManager.StageType.SpecialTrain then + XRoomManager.PhotoEndSelectRequest(cb) + else + XRoomManager.NormalEndSelectRequest(cb) + end + end + + function XRoomManager.NormalEndSelectRequest(cb) + XNetwork.Call(RequestProto.EndSelectRequest, {}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + if cb then + cb() + end + end) + end + + function XRoomManager.PhotoEndSelectRequest(cb) + XNetwork.Call(RequestProto.FubenPhotoEndSelectRequest, {}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + if cb then + cb() + end + end) + end + + function XRoomManager.ArenaOnlineEndSelectRequest(cb) + XNetwork.Call(RequestProto.ArenaOnlineEndSelectRequest, {}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local roomData = XRoomManager.RoomData + for _, playerData in pairs(roomData.PlayerDataList) do + if XPlayer.Id == playerData.Id then + playerData.State = XDataCenter.RoomManager.PlayerState.STOP + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_PLAYER_STAGE_REFRESH, playerData) + break + end + end + + if cb then + cb() + end + end) + end + + --匹配 + function XRoomManager.Match(stageId, cb) + local req = { StageId = stageId } + + XNetwork.Call(RequestProto.MatchRoomRequest, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XRoomManager.Matching = true + XRoomManager.MatchStageId = stageId + + if cb then + cb() + end + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_MATCH) + end) + end + + --匹配 + function XRoomManager.PhotoMatch(stageId, cb) + local req = { StageId = stageId } + XRoomManager.MatchType = XDataCenter.FubenManager.StageType.SpecialTrain + + XNetwork.Call(RequestProto.FubenPhotoMatchRoomRequest, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XRoomManager.Matching = true + XRoomManager.MatchStageId = stageId + + if cb then + cb() + end + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_MATCH) + end) + end + + -- 区域联机匹配 + function XRoomManager.AreanaOnlineMatch(stageId, cb) + local req = { ChallengeId = stageId } + XRoomManager.MatchType = XDataCenter.FubenManager.StageType.ArenaOnline + + XNetwork.Call(RequestProto.ArenaOnlineStartMatchReqeust, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XRoomManager.Matching = true + XRoomManager.MatchStageId = stageId + + if cb then + cb() + end + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_MATCH) + end) + end + + --取消匹配 + function XRoomManager.CancelMatch(cb) + if XRoomManager.MatchType == XDataCenter.FubenManager.StageType.ArenaOnline then + XRoomManager.CancelArenaOnlineMatch(cb) + elseif XRoomManager.MatchType == XDataCenter.FubenManager.StageType.SpecialTrain then + XRoomManager.CancelPhotoMatch(cb) + else + XRoomManager.CancelNormalMatch(cb) + end + end + + --取消正常匹配 + function XRoomManager.CancelNormalMatch(cb) + if XRoomManager.DoingCancel or not XRoomManager.Matching then + return + end + XRoomManager.DoingCancel = true + + local req = { StageId = XRoomManager.MatchStageId } + XNetwork.Call(RequestProto.CancelMatchRequest, req, function(res) + XRoomManager.DoingCancel = false + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + XRoomManager.Matching = false + XRoomManager.MatchStageId = nil + + if cb then + cb() + end + + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_CANCEL_MATCH) + end) + end + + --取消夏活照相关匹配 + function XRoomManager.CancelPhotoMatch(cb) + if XRoomManager.DoingCancel or not XRoomManager.Matching then + return + end + XRoomManager.DoingCancel = true + + local req = { StageId = XRoomManager.MatchStageId } + XNetwork.Call(RequestProto.FubenPhotoCancelMatchRequest, req, function(res) + XRoomManager.DoingCancel = false + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + XRoomManager.Matching = false + XRoomManager.MatchStageId = nil + + if cb then + cb() + end + + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_CANCEL_MATCH) + end) + end + + -- 区域联机取消匹配 + function XRoomManager.CancelArenaOnlineMatch(cb) + XRoomManager.MatchType = nil + if XRoomManager.DoingCancel or not XRoomManager.Matching then + return + end + XRoomManager.DoingCancel = true + + local req = { } + XNetwork.Call(RequestProto.ArenaOnlineCancelMatchRequest, req, function(res) + XRoomManager.DoingCancel = false + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + XRoomManager.Matching = false + XRoomManager.MatchStageId = nil + + if cb then + cb() + end + + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_CANCEL_MATCH) + end) + end + + --退出房间 + function XRoomManager.Quit(cb) + if XRoomManager.StageInfo.Type == XDataCenter.FubenManager.StageType.ArenaOnline then + XRoomManager.ArenaOnlineQuit(cb) + elseif XRoomManager.StageInfo.Type == XDataCenter.FubenManager.StageType.SpecialTrain then + XRoomManager.PhotoQuit(cb) + else + XRoomManager.NormalQuit(cb) + end + end + + --普通退出房间 + function XRoomManager.NormalQuit(cb) + local req = {} + XNetwork.Call(RequestProto.QuitRoomRequest, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + end + if XFightNetwork.IsConnected() then + -- 退出房间时如果已经连接战斗服,则断开连接 + CS.XFightNetwork.Disconnect() + end + XRoomManager.SetRoomData(nil) + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_LEAVE_ROOM) + if cb then + cb() + end + end) + end + + --夏活照相关退出房间 + function XRoomManager.PhotoQuit(cb) + local req = {} + XNetwork.Call(RequestProto.FubenPhotoQuitRoomRequest, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + end + if XFightNetwork.IsConnected() then + -- 退出房间时如果已经连接战斗服,则断开连接 + CS.XFightNetwork.Disconnect() + end + XRoomManager.SetRoomData(nil) + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_LEAVE_ROOM) + if cb then + cb() + end + end) + end + + --区域联机退出房间 + function XRoomManager.ArenaOnlineQuit(cb) + local req = {} + XNetwork.Call(RequestProto.ArenaOnlineQuitRoomRequest, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + end + if XFightNetwork.IsConnected() then + -- 退出房间时如果已经连接战斗服,则断开连接 + CS.XFightNetwork.Disconnect() + end + XRoomManager.RoomData = nil + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_LEAVE_ROOM) + if cb then + cb() + end + end) + end + + -- 准备 + function XRoomManager.Ready(cb) + if XRoomManager.StageInfo.Type == XDataCenter.FubenManager.StageType.ArenaOnline then + XRoomManager.ArenaOnlineReady(cb) + elseif XRoomManager.StageInfo.Type == XDataCenter.FubenManager.StageType.SpecialTrain then + XRoomManager.PhotoReady(cb) + else + XRoomManager.NormalReady(cb) + end + end + + --普通准备 + function XRoomManager.NormalReady(cb) + XNetwork.Call(RequestProto.ReadyRequest, {}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + if cb then + cb() + end + end) + end + + --夏活照相关准备 + function XRoomManager.PhotoReady(cb) + XNetwork.Call(RequestProto.FubenPhotoReadyRequest, {}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + if cb then + cb() + end + end) + end + + --区域联机准备 + function XRoomManager.ArenaOnlineReady(cb) + XNetwork.Call(RequestProto.ArenaOnlineReadyRequest, {}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local roomData = XDataCenter.RoomManager.RoomData + if roomData then + for _, v in pairs(roomData.PlayerDataList) do + if v.Id == XPlayer.Id then + v.State = XRoomManager.PlayerState.Ready + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_PLAYER_STAGE_REFRESH, v) + return + end + end + end + + if cb then + cb() + end + end) + end + + --取消准备 + function XRoomManager.CancelReady(cb) + if XRoomManager.StageInfo.Type == XDataCenter.FubenManager.StageType.ArenaOnline then + XRoomManager.CancelAreanOnlineReady(cb) + elseif XRoomManager.StageInfo.Type == XDataCenter.FubenManager.StageType.SpecialTrain then + XRoomManager.CancelPhotoReady() + else + XRoomManager.CancelNormalReady() + end + end + + --普通取消准备 + function XRoomManager.CancelNormalReady() + XNetwork.Send(RequestProto.CancelReadyRequest, {}) + end + + --夏活照相关取消准备 + function XRoomManager.CancelPhotoReady() + XNetwork.Send(RequestProto.FubenPhotoCancelReadyRequest, {}) + end + + --区域联机取消准备 + function XRoomManager.CancelAreanOnlineReady(cb) + XNetwork.Call(RequestProto.ArenaOnlineCancelReadyRequest, {}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local roomData = XDataCenter.RoomManager.RoomData + if roomData then + for _, v in pairs(roomData.PlayerDataList) do + if v.Id == XPlayer.Id then + v.State = XRoomManager.PlayerState.Normal + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_PLAYER_STAGE_REFRESH, v) + return + end + end + end + + if cb then + cb() + end + end) + end + + --进入战斗 + function XRoomManager.Enter(cb) + if XRoomManager.StageInfo.Type == XDataCenter.FubenManager.StageType.ArenaOnline then + XRoomManager.ArenaOnlineEnter(cb) + elseif XRoomManager.StageInfo.Type == XDataCenter.FubenManager.StageType.SpecialTrain then + XRoomManager.PhotoEnter(cb) + else + XRoomManager.NormalEnter(cb) + end + end + + --普通进入战斗 + function XRoomManager.NormalEnter(cb) + if not XRoomManager.RoomData then + return + end + + local stageInfo = XDataCenter.FubenManager.GetStageInfo(XRoomManager.RoomData.StageId) + if stageInfo.Type == XDataCenter.FubenManager.StageType.BossOnline and XDataCenter.FubenBossOnlineManager.CheckOnlineBossTimeOut() then + XUiManager.TipMsg(CS.XTextManager.GetText("OnlineBossTimeOut")) + return + end + + XNetwork.Call(RequestProto.EnterFightRequest, {}, function(res) + if res.Code ~= XCode.Success then + if res.Code ~= XCode.MatchRoomInFight then + XUiManager.TipCode(res.Code) + end + XLog.Debug("XRoomManager.NormalEnter error, " .. tostring(res.Code)) + return + end + + if cb then + cb(res) + end + end) + end + + --夏活照相关进入战斗 + function XRoomManager.PhotoEnter(cb) + if not XRoomManager.RoomData then + return + end + + XNetwork.Call(RequestProto.FubenPhotoEnterFightRequest, {}, function(res) + if res.Code ~= XCode.Success then + if res.Code ~= XCode.MatchRoomInFight then + XUiManager.TipCode(res.Code) + end + XLog.Debug("XRoomManager.PhotoEnter error, " .. tostring(res.Code)) + return + end + if cb then + cb(res) + end + end) + end + + --区域联机进入战斗 + function XRoomManager.ArenaOnlineEnter(cb) + if not XRoomManager.RoomData then + return + end + + XNetwork.Call(RequestProto.ArenaOnlineEnterFightRequest, {}, function(res) + if res.Code ~= XCode.Success then + if res.Code ~= XCode.MatchRoomInFight then + XUiManager.TipCode(res.Code) + end + XLog.Debug("XRoomManager.ArenaOnlineEnter error, " .. tostring(res.Code)) + return + end + if cb then + cb(res) + end + end) + end + + function XRoomManager.Select(charId, cb) + if XRoomManager.StageInfo.Type == XDataCenter.FubenManager.StageType.ArenaOnline then + XRoomManager.ArenaOnlineSelect(charId, cb) + elseif XRoomManager.StageInfo.Type == XDataCenter.FubenManager.StageType.SpecialTrain then + XRoomManager.PhotoSelect(charId,cb) + else + XRoomManager.NormalSelect(charId, cb) + end + end + + function XRoomManager.NormalSelect(charId, cb) + local req = { CharacterId = charId } + + XNetwork.Call(RequestProto.SelectRequest, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + if cb then + cb(res.Code) + end + end) + end + + function XRoomManager.PhotoSelect(charId, cb) + local req = { CharacterId = charId } + + XNetwork.Call(RequestProto.FubenPhotoSelectRequest, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + if cb then + cb(res.Code) + end + end) + end + + + function XRoomManager.ArenaOnlineSelect(charId, cb) + local req = { CharacterId = charId } + + XNetwork.Call(RequestProto.ArenaOnlineSelectRequest, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + if cb then + cb(res.Code) + end + end) + end + + --切换房主 + function XRoomManager.ChangeLeader(playerId, cb) + if XRoomManager.StageInfo.Type == XDataCenter.FubenManager.StageType.ArenaOnline then + XRoomManager.ArenaOnlineChangeLeader(playerId, cb) + elseif XRoomManager.StageInfo.Type == XDataCenter.FubenManager.StageType.SpecialTrain then + XRoomManager.PhotoChangeLeader(playerId, cb) + else + XRoomManager.NormalChangeLeader(playerId, cb) + end + end + + --普通切换房主 + function XRoomManager.NormalChangeLeader(playerId, cb) + local req = { PlayerId = playerId } + XNetwork.Call(RequestProto.ChangeLeaderRequest, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + if cb then + cb() + end + end) + end + + --夏活照相关切换房主 + function XRoomManager.PhotoChangeLeader(playerId, cb) + local req = { PlayerId = playerId } + XNetwork.Call(RequestProto.FubenPhotoChangeLeaderRequest, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + if cb then + cb() + end + end) + end + + --区域联机切换房主 + function XRoomManager.ArenaOnlineChangeLeader(playerId, cb) + local req = { PlayerId = playerId } + XNetwork.Call(RequestProto.ArenaOnlineChangeLeaderRequest, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local roomData = XDataCenter.RoomManager.RoomData + if roomData then + for _, v in pairs(roomData.PlayerDataList) do + if v.Id == playerId then + v.Leader = true + else + v.Leader = false + end + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_PLAYER_NPC_REFRESH, v) + end + end + + if cb then + cb() + end + end) + end + + --踢出房间 + function XRoomManager.KickOut(playerId, cb) + if XRoomManager.StageInfo.Type == XDataCenter.FubenManager.StageType.ArenaOnline then + XRoomManager.ArenaOnlineKickOut(playerId, cb) + elseif XRoomManager.StageInfo.Type == XDataCenter.FubenManager.StageType.SpecialTrain then + XRoomManager.PhotoKickOut(playerId, cb) + else + XRoomManager.NormalKickOut(playerId, cb) + end + end + + --普通踢出房间 + function XRoomManager.NormalKickOut(playerId, cb) + local req = { PlayerId = playerId } + XNetwork.Call(RequestProto.KickOutRequest, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + if cb then + cb() + end + end) + end + + --普通踢出房间 + function XRoomManager.PhotoKickOut(playerId, cb) + local req = { PlayerId = playerId } + XNetwork.Call(RequestProto.FubenPhotoKickOutRequest, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + if cb then + cb() + end + end) + end + + --踢出房间 + function XRoomManager.ArenaOnlineKickOut(playerId, cb) + local req = { PlayerId = playerId } + XNetwork.Call(RequestProto.ArenaOnlineKickOutRequest, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + if cb then + cb() + end + end) + end + + -- 设置房间等级难度 + function XRoomManager.SetStageLevel(level, cb) + if XRoomManager.StageInfo.Type == XDataCenter.FubenManager.StageType.ArenaOnline then + XRoomManager.AreanOnlineSetStageLevel(level, cb) + else + XRoomManager.NormalSetStageLevel(level, cb) + end + end + + -- 普通设置房间等级难度 + function XRoomManager.NormalSetStageLevel(level, cb) + local req = { Level = level } + XNetwork.Call(RequestProto.SetStageLevelRequest, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + if cb then + cb() + end + end) + end + + -- 区域联机设置房间等级难度 + function XRoomManager.AreanOnlineSetStageLevel(level, cb) + local data = XDataCenter.RoomManager.RoomData + local req = { ChallengeId = data.ChallengeId,ChallengeLevel = level } + XNetwork.Call(RequestProto.ArenaOnlineSetStageIdRequest, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + if cb then + cb() + end + end) + end + + -- 夏活照相关设置关卡 + function XRoomManager.PhotoChangeMapRequest(stageId, cb) + local req = {StageId = stageId} + XNetwork.Call(RequestProto.FubenPhotoChangeMapRequest, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + if cb then + cb() + end + end) + end + + -- 设置房间是否自动匹配 + function XRoomManager.SetAutoMatch(autoMatch, cb) + if XRoomManager.StageInfo.Type == XDataCenter.FubenManager.StageType.ArenaOnline then + XRoomManager.ArenaOnlineSetAutoMatch(autoMatch, cb) + elseif XRoomManager.StageInfo.Type == XDataCenter.FubenManager.StageType.SpecialTrain then + XRoomManager.PhotoSetAutoMatch(autoMatch, cb) + else + XRoomManager.NormalSetAutoMatch(autoMatch, cb) + end + end + + -- 普通设置房间是否自动匹配 + function XRoomManager.NormalSetAutoMatch(autoMatch, cb) + local req = { AutoMatch = autoMatch } + XNetwork.Call(RequestProto.SetAutoMatchRequest, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + if cb then + cb() + end + end) + end + + -- 夏活照相关设置房间是否自动匹配 + function XRoomManager.PhotoSetAutoMatch(autoMatch, cb) + local req = { AutoMatch = autoMatch } + XNetwork.Call(RequestProto.FubenPhotoSetAutoMatchRequest, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + if cb then + cb() + end + end) + end + + -- 区域联机设置房间是否自动匹配 + function XRoomManager.ArenaOnlineSetAutoMatch(autoMatch, cb) + local req = { AutoMatch = autoMatch } + XNetwork.Call(RequestProto.ArenaOnlineSetAutoMatchRequest, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + if cb then + cb() + end + end) + end + + -- 设置房间战力限制 + function XRoomManager.SetAbilityLimit(abilityLimit, cb) + if XRoomManager.StageInfo.Type == XDataCenter.FubenManager.StageType.ArenaOnline then + XRoomManager.ArenaOnlineSetAbilityLimit(abilityLimit, cb) + else + XRoomManager.NormalSetAbilityLimit(abilityLimit, cb) + end + end + + -- 普通设置房间战力限制 + function XRoomManager.NormalSetAbilityLimit(abilityLimit, cb) + local req = { AbilityLimit = abilityLimit } + XNetwork.Call(RequestProto.SetAbilityLimitRequest, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + if cb then + cb() + end + end) + end + + -- 区域联机设置房间战力限制 + function XRoomManager.ArenaOnlineSetAbilityLimit(abilityLimit, cb) + local req = { AbilityLimit = abilityLimit } + XNetwork.Call(RequestProto.ArenaOnlineSetAbilityLimitRequest, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + if cb then + cb() + end + end) + end + + -- 区域联机设置关卡 + function XRoomManager.ArenaOnlineSetStageId(stageId, cb) + local data = XDataCenter.RoomManager.RoomData + local req = { ChallengeId = stageId,ChallengeLevel = data.ChallengeLevel } + XNetwork.Call(RequestProto.ArenaOnlineSetStageIdRequest, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + if cb then + cb() + end + end) + end + + -- + function XRoomManager.AddLike(playerId) + if XRoomManager.StageInfo.Type == XDataCenter.FubenManager.StageType.ArenaOnline then + XRoomManager.AddArenaOnlineLike(playerId) + elseif XRoomManager.StageInfo.Type == XDataCenter.FubenManager.StageType.SpecialTrain then + XRoomManager.AddPhotoLike(playerId) + else + XRoomManager.AddNormalLike(playerId) + end + end + + function XRoomManager.AddNormalLike(playerId) + local req = { PlayerId = playerId } + XNetwork.Send(RequestProto.AddLikeRequest, req) + end + + function XRoomManager.AddArenaOnlineLike(playerId) + local req = { PlayerId = playerId } + XNetwork.Send(RequestProto.ArenaOnlineAddLikeRequest, req) + end + --夏活拍照关喜欢 + function XRoomManager.AddPhotoLike(playerId) + local req = { PlayerId = playerId } + XNetwork.Send(RequestProto.FubenPhotoAddLikeRequest, req) + end + + function XRoomManager.UpdateLoadProcess(progress) + if not XRoomManager.RoomData then + return + end + --战斗计算进度时会出现除零,导致progress无限小,服务端报错。Lua临时处理。 + if progress < 0 then + return + end + --更新进度 + local req = { Process = progress } + if XRoomManager.StageInfo.Type == XDataCenter.FubenManager.StageType.ArenaOnline then + XNetwork.Send(RequestProto.ArenaOnlineUpLoadProcessRequest, req) + elseif XRoomManager.StageInfo.Type == XDataCenter.FubenManager.StageType.SpecialTrain then + XNetwork.Send(RequestProto.FubenPhotoUpdateLoadProcessRequest, req) + else + XNetwork.Send(RequestProto.UpdateLoadProcessRequest, req) + end + + end + + function XRoomManager.ClickEnterRoomHref(param, createTime) + -- 前置自定义按键冲突检测 + if XDataCenter.FubenManager.CheckCustomUiConflict() then return end + + if not param then + return + end + + local result = string.Split(param, '|') + local roomId = result[1] + local stageId = tonumber(result[2]) + local roomType = tonumber(result[3]) + + -- 处理开房链接,狙击战走这里,其他走通用 + local unionFightData = XDataCenter.FubenUnionKillRoomManager.GetUnionRoomData() + if unionFightData and unionFightData.Id then + XUiManager.TipCode(XCode.MatchPlayerAlreadyInRoom) + return + end + if MultipleRoomType.UnionKill == roomType then + XDataCenter.FubenUnionKillRoomManager.ClickEnterRoomHref(roomId, createTime) + return + end + + local tempStageId = stageId + if MultipleRoomType.ArenaOnline == roomType then + local level = tonumber(result[4]) + tempStageId = XDataCenter.ArenaOnlineManager.GetStageIdByIdAndLevel(stageId, level) + end + + local stageInfo = XDataCenter.FubenManager.GetStageInfo(tempStageId) + if not stageInfo then + return + end + + local fubenName = "" + if stageInfo.Type == XDataCenter.FubenManager.StageType.BossOnline then + fubenName = XFunctionManager.FunctionName.FubenActivity + elseif stageInfo.Type == XDataCenter.FubenManager.StageType.Daily then + local challengeCfg = XDataCenter.FubenDailyManager.GetDailyCfgBySectionId(stageInfo.DailySectionId) + if challengeCfg and challengeCfg.Type == XDataCenter.FubenManager.ChapterType.EMEX then + fubenName = XFunctionManager.FunctionName.FubenDailyEMEX + end + elseif stageInfo.Type == XDataCenter.FubenManager.StageType.ArenaOnline then + fubenName = XFunctionManager.FunctionName.ArenaOnline + elseif stageInfo.Type == XDataCenter.FubenManager.StageType.SpecialTrain then + fubenName = XFunctionManager.FunctionName.SpecialTrain + end + + if not XFunctionManager.DetectionFunction(fubenName) then + return + end + + --超链接点击 + if stageInfo.Type == XDataCenter.FubenManager.StageType.ArenaOnline then + --XRoomManager.ArenaOnlineEnterTargetRoom(roomId, stageId, createTime) + XUiManager.TipText("ActivityAlreadyClose") + elseif stageInfo.Type == XDataCenter.FubenManager.StageType.SpecialTrain then + XRoomManager.PhotoEnterTargetRoom(roomId, stageId, createTime) + else + XRoomManager.NormalEnterTargetRoom(roomId, stageId, createTime) + end + end + + function XRoomManager.NormalEnterTargetRoom(roomId, stageId, createTime) + --进入房间 + if XRoomManager.RoomData then + XUiManager.TipCode(XCode.MatchPlayerAlreadyInRoom) + return + end + + if XTime.GetServerNowTimestamp() > createTime + CS.XGame.Config:GetInt("RoomHrefDisableTime") then + XUiManager.TipText("RoomHrefDisabled") + return + end + + local req = { RoomId = roomId, StageId = stageId } + XNetwork.Call(RequestProto.EnterTargetRoomRequest, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + XRoomManager.OnCreateRoom(res.RoomData) + XUiManager.TipText("OnlineInstanceEnterRoom", XUiManager.UiTipType.Success) + end) + end + + function XRoomManager.PhotoEnterTargetRoom(roomId, stageId, createTime) + --进入房间 + if XRoomManager.RoomData then + XUiManager.TipCode(XCode.MatchPlayerAlreadyInRoom) + return + end + + if XTime.GetServerNowTimestamp() > createTime + CS.XGame.Config:GetInt("RoomHrefDisableTime") then + XUiManager.TipText("RoomHrefDisabled") + return + end + + local req = { RoomId = roomId, StageId = stageId } + XNetwork.Call(RequestProto.FubenPhotoEnterTargetRoomRequest, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + XRoomManager.OnCreateRoom(res.RoomData) + XUiManager.TipText("OnlineInstanceEnterRoom", XUiManager.UiTipType.Success) + end) + end + + + function XRoomManager.ArenaOnlineEnterTargetRoom(roomId, stageId, createTime) + --进入房间 + if XRoomManager.RoomData then + XUiManager.TipCode(XCode.MatchPlayerAlreadyInRoom) + return + end + + if XTime.GetServerNowTimestamp() > createTime + CS.XGame.Config:GetInt("RoomHrefDisableTime") then + XUiManager.TipText("RoomHrefDisabled") + return + end + + local req = { RoomId = roomId, StageId = stageId} + XNetwork.Call(RequestProto.ArenaOnlineEnterRoomRequest, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XDataCenter.ArenaOnlineManager.SetCurChapterId() + XRoomManager.OnCreateRoom(res.Room) + XUiManager.TipText("OnlineInstanceEnterRoom", XUiManager.UiTipType.Success) + end) + end + + + function XRoomManager.SelectReward(pos) + if XRoomManager.StageInfo.Type == XDataCenter.FubenManager.StageType.ArenaOnline then + XRoomManager.ArenaOnlineSelectReward(pos) + else + XRoomManager.NormalSelectReward(pos) + end + end + + function XRoomManager.NormalSelectReward(pos) + local req = { Pos = pos } + XNetwork.Send(RequestProto.SelectRewardRequest, req) + end + + function XRoomManager.ArenaOnlineSelectReward(pos) + local req = { Pos = pos } + XNetwork.Send(RequestProto.ArenaOnlineSelectRewardRequest, req) + end + + function XRoomManager.OnJoinFightNotify(response) + local roomData = XDataCenter.RoomManager.RoomData + if not roomData then + XLog.Error("XRoomManager.OnJoinFightNotify错误, RoomManager中RoomData没有数据,说明初始化数据失败或者还没有创建房间") + return + end + + XRoomManager.ChallengeId = XRoomManager.RoomData.ChallengeId + + XNetwork.Call(RequestProto.JoinFightRequest, { NodeId = response.NodeId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + -- 进入战斗前关闭所有弹出框 + XDataCenter.FubenManager.OnEnterFight(res.FightData) + end) + end + + function XRoomManager.OnNewJoinFightNotify(response) + XLog.Debug("XRoomManager.OnNewJoinFightNotify") + XLog.Debug(response) + local roomData = XDataCenter.RoomManager.RoomData + if not roomData then + XLog.Error("XRoomManager.OnNewJoinFightNotify error, roomData is nil") + return + end + + local cb = function(success) + XLog.Debug("XRoomManager.OnNewJoinFightNotify Cb " .. tostring(success)) + if success then + XFightNetwork.Call("JoinFightRequest", {FightId = response.FightId, PlayerId = XPlayer.Id, Token = response.Token}, function(res) + XRoomManager.OnJoinFightResponse(res, response.IpAddress) + end) + elseif not CS.XFight.IsOutFight then + if CS.XFight.Instance then + -- 网络错误,如果战斗已经启动,则退出战斗 + CS.XFight.Instance.ExitOnOnlineDisconnect() + end + end + end + + XFightNetwork.Connect(response.IpAddress, response.Port, cb) + end + + function XRoomManager.OnJoinFightResponse(response, ip) + XLog.Debug("XRoomManager.OnJoinFightResponse") + + if response.Code ~= XCode.Success then + XLog.Error("XRoomManager.OnJoinFightResponse error, Code:" .. tostring(response.Code)) + return + end + + if not response.FightData then + XLog.Error("XRoomManager.OnJoinFightResponse error, fightData is nil") + CS.XFightNetwork.Disconnect() + return + end + + local roomData = XDataCenter.RoomManager.RoomData + if not roomData then + XLog.Error("XRoomManager.OnJoinFightResponse error, roomData is nil") + CS.XFightNetwork.Disconnect() + return + end + + -- 连接战斗成功后开始心跳 + XFightNetwork.DoHeartbeat() + + if not response.Port or not response.Conv then + XLog.Error("XRoomManager.OnJoinFightResponse error, port:" .. tostring(response.Port) .. " conv:" .. tostring(response.Conv)) + -- 跳过kcp连接,直接进入战斗 + XDataCenter.FubenManager.OnEnterFight(response.FightData) + return + end + + local cb = function(success) + XLog.Debug("XRoomManager.OnJoinFightResponse Cb " .. tostring(success)) + if not success then + XLog.Error("kcp disconnect! use tcp for fight") + end + + local roomData = XDataCenter.RoomManager.RoomData + if not roomData then + XLog.Error("XRoomManager.OnJoinFightResponse Cb error, roomData is nil") + CS.XFightNetwork.Disconnect() + return + end + + XDataCenter.FubenManager.OnEnterFight(response.FightData) + end + + -- 连接kcp + XFightNetwork.ConnectKcp(ip, response.Port, response.Conv, cb) + end + + function XRoomManager.IsLeader(playerId) + for _, v in pairs(XRoomManager.RoomData.PlayerDataList) do + if v.Id == playerId and v.Leader then + return true + end + end + + return false + end + + function XRoomManager.OnDisconnect() + -- -- 区域联机重连不做任何处理 + -- if XRoomManager.StageInfo and XRoomManager.StageInfo.Type == XDataCenter.FubenManager.StageType.ArenaOnline then + -- return + -- end + + -- if XRoomManager.Matching then + -- XRoomManager.Matching = false + -- XEventManager.DispatchEvent(XEventId.EVENT_ROOM_CANCEL_MATCH) + -- end + + -- if XRoomManager.RoomData then + -- -- 关战斗 + -- if CS.XFight.Instance and CS.XFight.Instance.Online then + -- XLuaUiManager.Close("UiLoading") + -- XLuaUiManager.Close("UiOnLineLoading") + -- CS.XFight.ClearFight() + -- end + + -- if XLuaUiManager.IsUiShow("UiChatServeMain") then + -- XLuaUiManager.Close("UiChatServeMain") + -- end + + -- if XLuaUiManager.IsUiShow("UiDialog") then + -- XLuaUiManager.Close("UiDialog") + -- end + + -- -- 关房间 + -- if XLuaUiManager.IsUiShow("UiMultiplayerRoom") then + -- XLuaUiManager.Close("UiMultiplayerRoom") + -- else + -- XLuaUiManager.Remove("UiMultiplayerRoom") + -- end + + -- XLuaUiManager.ShowTopUi() + + -- -- 提示&清数据 + -- XUiManager.TipText("OnlineRoomOnDisconnet") + -- XRoomManager.RoomData = nil + -- XEventManager.DispatchEvent(XEventId.EVENT_ROOM_LEAVE_ROOM) + -- end + end + + -- 监听断网 + XEventManager.AddEventListener(XEventId.EVENT_NETWORK_DISCONNECT, XRoomManager.OnDisconnect, XRoomManager) + + XRoomManager.Init() + return XRoomManager +end + +XRpc.SelectRewardNotify = function(data) + XEventManager.DispatchEvent(XEventId.EVENT_ONLINEBOSS_DROPREWARD_NOTIFY, data) +end + +XRpc.NotifyArenaOnlineSelectReward = function(data) + XEventManager.DispatchEvent(XEventId.EVENT_ONLINEBOSS_DROPREWARD_NOTIFY, data) +end + +--踢出房间 +XRpc.KickOutNotify = function(response) + if response.Code and response.Code ~= XCode.Success and response.Code ~= XCode.MatchPlayerOffline then + XUiManager.TipCode(response.Code) + end + if XFightNetwork.IsConnected() then + -- 退出房间时如果已经连接战斗服,则断开连接 + CS.XFightNetwork.Disconnect() + end + XDataCenter.RoomManager.SetRoomData(nil) + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_LEAVE_ROOM) + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_KICKOUT) +end + +--踢出房间 +XRpc.FubenPhotoKickOutNotify = function(response) + if response.Code and response.Code ~= XCode.Success and response.Code ~= XCode.MatchPlayerOffline then + XUiManager.TipCode(response.Code) + end + if XFightNetwork.IsConnected() then + -- 退出房间时如果已经连接战斗服,则断开连接 + CS.XFightNetwork.Disconnect() + end + XDataCenter.RoomManager.SetRoomData(nil) + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_LEAVE_ROOM) + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_KICKOUT) +end + +--更新进度条 +XRpc.RefreshLoadProcessNotify = function(response) + XEventManager.DispatchEvent(XEventId.EVENT_FIGHT_PROGRESS, response.PlayerId, response.Process) +end + +--更新进度条 +XRpc.FubenPhotoRefreshLoadProcessNotify = function(response) + XEventManager.DispatchEvent(XEventId.EVENT_FIGHT_PROGRESS, response.PlayerId, response.Process) +end + +XRpc.FightPlayerListNotify = function(response) + XDataCenter.RoomManager.FightPlayerList = response.PlayerIdList +end + +--踢人倒计时 +XRpc.OnCountDownNotify = function(response) + if response.TimeCount == 0 then + XDataCenter.RoomManager.CountDowning = false + else + XDataCenter.RoomManager.CountDowning = true + end + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_COUNT_DOWN, response.TimeCount) +end + +--匹配通知 +XRpc.MatchNotify = function(response) + if not XDataCenter.RoomManager.Matching then + return + end + + if response.Code == XCode.Success then + XDataCenter.RoomManager.OnCreateRoom(response.RoomData) + else + XDataCenter.RoomManager.Matching = false + XDataCenter.RoomManager.MatchStageId = nil + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_CANCEL_MATCH) + end +end + +--匹配通知 +XRpc.FubenPhotoMatchNotify = function(response) + if not XDataCenter.RoomManager.Matching then + return + end + + if response.Code == XCode.Success then + XDataCenter.RoomManager.OnCreateRoom(response.RoomData) + else + XDataCenter.RoomManager.Matching = false + XDataCenter.RoomManager.MatchStageId = nil + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_CANCEL_MATCH) + end +end + +--联机匹配成功通知 +XRpc.NotifyArenaOnlineMatchFinish = function(response) + if not XDataCenter.RoomManager.Matching then + return + end + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_CANCEL_MATCH) + XDataCenter.RoomManager.OnCreateRoom(response.Room) +end + +--联机匹配失败通知 +XRpc.NotifyArenaOnlineMatchFail = function() + if not XDataCenter.RoomManager.Matching then + return + end + + XDataCenter.RoomManager.Matching = false + XDataCenter.RoomManager.MatchStageId = nil + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_CANCEL_MATCH) +end + +XRpc.PlayerSyncInfoNotify = function(response) + local roomData = XDataCenter.RoomManager.RoomData + if roomData then + for _, playerInfo in pairs(response.PlayerInfoList) do + for _, v in pairs(roomData.PlayerDataList) do + if v.Id == playerInfo.Id then + v.State = playerInfo.State + v.Leader = playerInfo.Leader + if playerInfo.FightNpcData then + v.FightNpcData = playerInfo.FightNpcData + end + break + end + end + end + + -- 先赋值再通知事件 + for _, playerInfo in pairs(response.PlayerInfoList) do + for _, v in pairs(roomData.PlayerDataList) do + if v.Id == playerInfo.Id then + if playerInfo.FightNpcData then + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_PLAYER_NPC_REFRESH, v) + else + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_PLAYER_STAGE_REFRESH, v) + end + break + end + end + end + end +end + +XRpc.FubenPhotoPlayerSyncInfoNotify = function(response) + local roomData = XDataCenter.RoomManager.RoomData + if roomData then + for _, playerInfo in pairs(response.PlayerInfoList) do + for _, v in pairs(roomData.PlayerDataList) do + if v.Id == playerInfo.Id then + v.State = playerInfo.State + v.Leader = playerInfo.Leader + if playerInfo.FightNpcData then + v.FightNpcData = playerInfo.FightNpcData + end + break + end + end + end + + -- 先赋值再通知事件 + for _, playerInfo in pairs(response.PlayerInfoList) do + for _, v in pairs(roomData.PlayerDataList) do + if v.Id == playerInfo.Id then + if playerInfo.FightNpcData then + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_PLAYER_NPC_REFRESH, v) + else + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_PLAYER_STAGE_REFRESH, v) + end + break + end + end + end + end +end + + +XRpc.NotifyArenaOnlineFightNpcData = function(response) + local roomData = XDataCenter.RoomManager.RoomData + if roomData then + for _, v in pairs(roomData.PlayerDataList) do + if v.Id == response.PlayerId then + if response.FightNpcData then + v.FightNpcData = response.FightNpcData + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_PLAYER_NPC_REFRESH, v) + return + end + end + end + end +end + +XRpc.NotifyArenaOnlineLeaderChange = function(response) + local roomData = XDataCenter.RoomManager.RoomData + if roomData then + for _, v in pairs(roomData.PlayerDataList) do + if v.Id == response.LeaderId then + v.Leader = true + else + v.Leader = false + end + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_PLAYER_NPC_REFRESH, v) + end + end +end + +XRpc.NotifyArenaOnlinePlayerState = function(response) + local roomData = XDataCenter.RoomManager.RoomData + if roomData then + for _, state in pairs(response.PlayerStateList) do + for _, playerData in pairs(roomData.PlayerDataList) do + if state.PlayerId == playerData.Id then + playerData.State = state.PlayerState + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_PLAYER_STAGE_REFRESH, playerData) + break + end + end + end + end +end + +XRpc.PlayerEnterNotify = function(response) + local roomData = XDataCenter.RoomManager.RoomData + if roomData then + table.insert(roomData.PlayerDataList, response.PlayerData) + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_PLAYER_ENTER, response.PlayerData) + end +end + +XRpc.FubenPhotoPlayerEnterNotify = function(response) + local roomData = XDataCenter.RoomManager.RoomData + if roomData then + table.insert(roomData.PlayerDataList, response.PlayerData) + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_PLAYER_ENTER, response.PlayerData) + end +end + +XRpc.NotifyArenaOnlinePlayerEnter = function(response) + local roomData = XDataCenter.RoomManager.RoomData + if roomData then + table.insert(roomData.PlayerDataList, response.Player) + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_PLAYER_ENTER, response.Player) + end +end + +XRpc.PlayerLeaveNotify = function(response) + local roomData = XDataCenter.RoomManager.RoomData + if roomData then + for _, targetId in pairs(response.Players) do + for k, v in pairs(roomData.PlayerDataList) do + if v.Id == targetId then + table.remove(roomData.PlayerDataList, k) + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_PLAYER_LEAVE, targetId) + break + end + end + end + end +end + +XRpc.FubenPhotoPlayerLeaveNotify = function(response) + local roomData = XDataCenter.RoomManager.RoomData + if roomData then + for _, targetId in pairs(response.Players) do + for k, v in pairs(roomData.PlayerDataList) do + if v.Id == targetId then + table.remove(roomData.PlayerDataList, k) + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_PLAYER_LEAVE, targetId) + break + end + end + end + end +end + +XRpc.NotifyArenaOnlinePlayerLeave = function(response) + local roomData = XDataCenter.RoomManager.RoomData + if roomData then + for k, v in pairs(roomData.PlayerDataList) do + if v.Id == response.PlayerId then + table.remove(roomData.PlayerDataList, k) + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_PLAYER_LEAVE, response.PlayerId) + break + end + end + end + + if response.NewLeaderId <= 0 then return end + if not roomData then return end + for _, v in pairs(roomData.PlayerDataList) do + if v.Id == response.NewLeaderId then + v.Leader = true + else + v.Leader = false + end + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_PLAYER_NPC_REFRESH, v) + end +end + +XRpc.NotifyArenaOnlineForceBanish = function(response) + local roomData = XDataCenter.RoomManager.RoomData + if not roomData then return end + + if response.PlayerId == XPlayer.Id then + if XDataCenter.RoomManager.IsLeader(response.PlayerId) then + XUiManager.TipCode(XCode.MatchStartTimeout) + else + XUiManager.TipCode(XCode.MatchRoomLeaderForceLeave) + end + if XFightNetwork.IsConnected() then + -- 退出房间时如果已经连接战斗服,则断开连接 + CS.XFightNetwork.Disconnect() + end + XDataCenter.RoomManager.SetRoomData(nil) + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_LEAVE_ROOM) + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_KICKOUT) + else + for k, v in pairs(roomData.PlayerDataList) do + if v.Id == response.PlayerId then + table.remove(roomData.PlayerDataList, k) + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_PLAYER_LEAVE, response.PlayerId) + break + end + end + end +end + + +XRpc.JoinFightNotify = function(response) + if not XDataCenter.RoomManager.RoomData then + return + end + XDataCenter.RoomManager.OnJoinFightNotify(response) +end + +XRpc.NewJoinFightNotify = function(response) + if not XDataCenter.RoomManager.RoomData then + XLog.Error("XRpc.NewJoinFightNotify, RoomManager中RoomData没有数据,说明初始化数据失败或者还没有创建房间") + return + end + XDataCenter.RoomManager.OnNewJoinFightNotify(response) +end + +XRpc.RoomInfoChangeNotify = function(response) + local roomData = XDataCenter.RoomManager.RoomData + local lastAutoMatch = roomData.AutoMatch + local lastStageLevel = roomData.StageLevel + local lastAbilityLimit = roomData.AbilityLimit + roomData.AutoMatch = response.AutoMatch + roomData.StageLevel = response.StageLevel + roomData.AbilityLimit = response.AbilityLimit + -- 先全部赋值再发事件 + if lastAutoMatch ~= roomData.AutoMatch then + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_AUTO_MATCH_CHANGE, roomData.AutoMatch) + end + if lastStageLevel ~= roomData.StageLevel then + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_STAGE_LEVEL_CHANGE, lastStageLevel, roomData.StageLevel) + end + if lastAbilityLimit ~= roomData.AbilityLimit then + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_STAGE_ABILITY_LIMIT_CHANGE, lastAbilityLimit, roomData.AbilityLimit) + end +end + +XRpc.FubenPhotoRoomInfoChangeNotify = function(response) + local roomData = XDataCenter.RoomManager.RoomData + local lastAutoMatch = roomData.AutoMatch + local lastStageLevel = roomData.StageLevel + local lastAbilityLimit = roomData.AbilityLimit + roomData.AutoMatch = response.AutoMatch + roomData.StageLevel = response.StageLevel + roomData.AbilityLimit = response.AbilityLimit + -- 先全部赋值再发事件 + if lastAutoMatch ~= roomData.AutoMatch then + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_AUTO_MATCH_CHANGE, roomData.AutoMatch) + end + if lastStageLevel ~= roomData.StageLevel then + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_STAGE_LEVEL_CHANGE, lastStageLevel, roomData.StageLevel) + end + if lastAbilityLimit ~= roomData.AbilityLimit then + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_STAGE_ABILITY_LIMIT_CHANGE, lastAbilityLimit, roomData.AbilityLimit) + end +end + +-- 区域联机战力变化 +XRpc.NotifyArenaOnlineAbilityLimit = function(response) + local roomData = XDataCenter.RoomManager.RoomData + local lastAbilityLimit = roomData.AbilityLimit + roomData.AbilityLimit = response.AbilityLimit + + if lastAbilityLimit ~= roomData.AbilityLimit then + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_STAGE_ABILITY_LIMIT_CHANGE, lastAbilityLimit, roomData.AbilityLimit) + end +end + +-- 区域联机难度变化 +--XRpc.NotifyArenaOnlineStageLevel = function(response) +--local roomData = XDataCenter.RoomManager.RoomData +--local lastStageLevel = roomData.StageLevel +--roomData.StageLevel = response.StageLevel + +--if lastStageLevel ~= roomData.StageLevel then +--XEventManager.DispatchEvent(XEventId.EVENT_ROOM_STAGE_LEVEL_CHANGE, lastStageLevel, roomData.StageLevel) +--end +--end + +-- 区域联机快速匹配变化 +XRpc.NotifyArenaOnlineAutoMatch = function(response) + local roomData = XDataCenter.RoomManager.RoomData + local lastAutoMatch = roomData.AutoMatch + roomData.AutoMatch = response.AutoMatch + + if lastAutoMatch ~= roomData.AutoMatch then + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_AUTO_MATCH_CHANGE, roomData.AutoMatch) + end +end + +XRpc.RoomStateNotify = function(response) + local roomData = XDataCenter.RoomManager.RoomData + roomData.State = response.State + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_STAGE_CHANGE, response.State) +end + +XRpc.FubenPhotoRoomStateNotify = function(response) + local roomData = XDataCenter.RoomManager.RoomData + roomData.State = response.State + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_STAGE_CHANGE, response.State) +end + +XRpc.NotifyArenaOnlineRoomState = function(response) + local roomData = XDataCenter.RoomManager.RoomData + if not roomData then return end + + if response.RoomState == XDataCenter.RoomManager.RoomState.Close then + XUiManager.TipMsg(CS.XTextManager.GetText("OnlineRoomClose")) + if XFightNetwork.IsConnected() then + -- 退出房间时如果已经连接战斗服,则断开连接 + CS.XFightNetwork.Disconnect() + end + XDataCenter.RoomManager.SetRoomData(nil) + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_LEAVE_ROOM) + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_KICKOUT) + else + roomData.State = response.RoomState + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_STAGE_CHANGE, response.RoomState) + end +end + +-- 切换关卡通知 +XRpc.NotifyArenaOnlineStageId = function(response) + local roomData = XDataCenter.RoomManager.RoomData + local oldLevel = roomData.ChallengeLevel + local oldChallengeId = roomData.ChallengeId + roomData.ChallengeId = response.ChallengeId + roomData.ChallengeLevel = response.ChallengeLevel + roomData.StageId = response.StageId + roomData.StageLevel = response.StageLevel + + local showChange = oldChallengeId == response.ChallengeId + + if showChange then + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_STAGE_LEVEL_CHANGE, oldLevel, roomData.StageLevel) + else + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_CHANGE_STAGE) + end +end + +-- 战斗结束玩家信息推送 +XRpc.NotifyArenaOnlinePlayerInfoChange = function(response) + local roomData = XDataCenter.RoomManager.RoomData + if roomData then + for _, v in pairs(roomData.PlayerDataList) do + if v.Id == response.PlayerId then + v.AssistCount = response.AssistCount + v.HaveFirstPass = response.HaveFirstPass + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_PLAYER_NPC_REFRESH, v) + break + end + end + end +end + + +XRpc.NotifyArenaOnlineTimeout = function() + XUiManager.TipText("ArenaOnlineRoomConnectTimeOut") + + if XFightNetwork.IsConnected() then + -- 退出房间时如果已经连接战斗服,则断开连接 + CS.XFightNetwork.Disconnect() + end + XDataCenter.RoomManager.SetRoomData(nil) + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_LEAVE_ROOM) + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_KICKOUT) +end + +XRpc.FubenPhotoChangeMapNotify = function(response) + local roomData = XDataCenter.RoomManager.RoomData + if roomData then + roomData.StageId = response.StageId + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_CHANGE_STAGE_SUMMER_EPISODE) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XRoomSingleManager.lua b/Resources/Scripts/XManager/XRoomSingleManager.lua new file mode 100644 index 00000000..ce51efc5 --- /dev/null +++ b/Resources/Scripts/XManager/XRoomSingleManager.lua @@ -0,0 +1,52 @@ +XRoomSingleManager = XRoomSingleManager or {} + +XRoomSingleManager.PlayerType = { + None = 0, + Firend = 1, + Guild = 2, + Stranger = 3, +} + +XRoomSingleManager.BtnType = { + None = 0, + SelectStage = 1, + Again = 2, + Next = 3, + Main = 4, + ArenaOnlineBack = 5, + ArenaOnlineAgain = 6, +} + +local FIGHT_EVENT = "Share/Fight/FightEvent.tab" +local FightEventCfg = {} + +function XRoomSingleManager.Init() + FightEventCfg = XTableManager.ReadByIntKey(FIGHT_EVENT, XTable.XTableFightEvent, "Id") +end + +function XRoomSingleManager.GetEventDescByMapId(stageId) + local eventId = XDataCenter.FubenManager.GetStageCfg(stageId).EventId + if eventId <= 0 then + return nil + end + local eventCfg = FightEventCfg[eventId] + if not eventCfg then + return nil + end + return eventCfg.Description +end + +function XRoomSingleManager.GetEvenDesc(eventId) + local eventCfg = FightEventCfg[eventId] + return eventCfg.Description +end + +function XRoomSingleManager.GetBtnText(btnType) + if btnType == XRoomSingleManager.BtnType.SelectStage then return CS.XTextManager.GetText("BattleWinSelectStage") + elseif btnType == XRoomSingleManager.BtnType.Again then return CS.XTextManager.GetText("BattleWinAgain") + elseif btnType == XRoomSingleManager.BtnType.Next then return CS.XTextManager.GetText("BattleWinNext") + elseif btnType == XRoomSingleManager.BtnType.Main then return CS.XTextManager.GetText("BattleWinMain") + elseif btnType == XRoomSingleManager.BtnType.ArenaOnlineBack then return CS.XTextManager.GetText("BattleWinArenaOnlineBack") + elseif btnType == XRoomSingleManager.BtnType.ArenaOnlineAgain then return CS.XTextManager.GetText("BattleWinArenaOnlineAgain") + else return "" end +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XRpgMakerGameManager.lua b/Resources/Scripts/XManager/XRpgMakerGameManager.lua new file mode 100644 index 00000000..1eb478d5 --- /dev/null +++ b/Resources/Scripts/XManager/XRpgMakerGameManager.lua @@ -0,0 +1,631 @@ +local XRpgMakerGameActivityDb = require("XEntity/XRpgMakerGame/XRpgMakerGameActivityDb") +local XRpgMakerGameEnterStageDb = require("XEntity/XRpgMakerGame/XRpgMakerGameEnterStageDb") +local XRpgMakerGameEndPoint = require("XEntity/XRpgMakerGame/Object/XRpgMakerGameEndPoint") +local XRpgMakerGameMonsterData = require("XEntity/XRpgMakerGame/Object/XRpgMakerGameMonsterData") +local XRpgMakerGamePlayer = require("XEntity/XRpgMakerGame/Object/XRpgMakerGamePlayer") +local XRpgMakerGameTriggerData = require("XEntity/XRpgMakerGame/Object/XRpgMakerGameTriggerData") +local XUiRpgMakerGamePlayScene = require("XUi/XUiRpgMakerGame/PlayMain/XUiRpgMakerGamePlayScene") + +XRpgMakerGameManagerCreator = function() + local tableInsert = table.insert + local tableSort = table.sort + local tableRemove = table.remove + local tonumber = tonumber + local pairs = pairs + local CSXTextManagerGetText = CS.XTextManager.GetText + local stringFormat = string.format + + local RpgMakerGameActivityDb = XRpgMakerGameActivityDb.New() + local RpgMakerGameEnterStageDb = XRpgMakerGameEnterStageDb.New() + local PlayerObj = XRpgMakerGamePlayer.New() + local EndPointObj = XRpgMakerGameEndPoint.New() + local GameMonsterObjDic = {} --怪物对象字典 + local TriggerObjDic = {} --机关对象字典 + local Actions = {} --状态列表 + local CurrentCount = 0 --当前回合数 + local CurrentScene = XUiRpgMakerGamePlayScene.New() + local CurrTabGroupIndexByUiMainTemp --缓存主界面选择的chapter对应的TabGroupIndex + + ---------------------本地接口 begin------------------ + local InitMonsetObj = function(mapId) + GameMonsterObjDic = {} + local monsterIdList = XRpgMakerGameConfigs.GetRpgMakerGameMapIdToMonsterIdList(mapId) + local monsterObj + for _, monsterId in ipairs(monsterIdList) do + GameMonsterObjDic[monsterId] = XRpgMakerGameMonsterData.New(monsterId) + end + end + + local ClearMonsterObj = function() + for _, monsterObj in pairs(GameMonsterObjDic) do + monsterObj:Dispose() + end + GameMonsterObjDic = {} + end + + local ResetMonsetObj = function() + for _, monsterObj in pairs(GameMonsterObjDic) do + monsterObj:InitData() + end + end + + local InitTriggerObjDic = function(mapId) + TriggerObjDic = {} + local triggerIdList = XRpgMakerGameConfigs.GetRpgMakerGameMapIdToTriggerIdList(mapId) + local monsterObj + for _, triggerId in ipairs(triggerIdList) do + TriggerObjDic[triggerId] = XRpgMakerGameTriggerData.New(triggerId) + end + end + + local ClearTriggerObj = function() + for _, triggerObj in pairs(TriggerObjDic) do + triggerObj:Dispose() + end + TriggerObjDic = {} + end + + local ResetTriggerObj = function() + for _, triggerObj in pairs(TriggerObjDic) do + triggerObj:InitData() + end + end + + local _CurrentReqMoveLock --请求移动协议结果未处理之前不允许接着请求 + + local LockReqMove = function() + _CurrentReqMoveLock = true + end + + local UnLockReqMove = function() + _CurrentReqMoveLock = nil + end + + local IsLockReqMove = function() + return _CurrentReqMoveLock or false + end + + local ResetStepCount = function() + XDataCenter.RpgMakerGameManager.SetCurrentCount(0) + end + + local InsertAction = function(action) + tableInsert(Actions, action) + end + ---------------------本地接口 end-------------------- + + local XRpgMakerGameManager = {} + -----------------功能入口 begin---------------- + function XRpgMakerGameManager.GetRpgMakerGameStageStatus(rpgMakerGameStageId) + local stageIsClear = XRpgMakerGameManager.IsStageClear(rpgMakerGameStageId) + if stageIsClear then + return XRpgMakerGameConfigs.RpgMakerGameStageStatus.Clear + end + + local preStage = XRpgMakerGameConfigs.GetRpgMakerGameStagePreStage(rpgMakerGameStageId) + local preStageIsClear = not XTool.IsNumberValid(preStage) and true or XRpgMakerGameManager.IsStageClear(preStage) + if preStageIsClear then + return XRpgMakerGameConfigs.RpgMakerGameStageStatus.UnLock + end + + return XRpgMakerGameConfigs.RpgMakerGameStageStatus.Lock + end + + function XRpgMakerGameManager.IsStageClear(stageId) + local stageDb = XRpgMakerGameManager.GetRpgMakerActivityStageDb(stageId) + return stageDb and true or false + end + + function XRpgMakerGameManager.CheckActivityIsOpen() + local id = XRpgMakerGameConfigs.GetDefaultActivityId() + local timeId = XRpgMakerGameConfigs.GetRpgMakerGameActivityTimeId(id) + if not XFunctionManager.CheckInTimeByTimeId(timeId) then + if CS.XFight.IsRunning or XLuaUiManager.IsUiLoad("UiLoading") then + return false + end + + XUiManager.TipText("ActivityMainLineEnd") + XLuaUiManager.RunMain() + return false + end + return true + end + + function XRpgMakerGameManager.GetActivityTime() + local id = XRpgMakerGameConfigs.GetDefaultActivityId() + local timeId = XRpgMakerGameConfigs.GetRpgMakerGameActivityTimeId(id) + return XFunctionManager.GetTimeByTimeId(timeId) + end + + function XRpgMakerGameManager.CheckActivityCondition() + local functionId = XFunctionManager.FunctionName.RpgMakerActivity + local isOpen = XFunctionManager.JudgeCanOpen(functionId) + local desc = XFunctionManager.GetFunctionOpenCondition(functionId) + if not isOpen then + XUiManager.TipMsg(desc) + end + return isOpen, desc + end + + function XRpgMakerGameManager.CheckRedPoint() + local groupId = XRpgMakerGameManager.GetCurrTaskTimeLimitId() + return XDataCenter.TaskManager.CheckLimitTaskList(groupId) + end + -----------------功能入口 end------------------ + + -----------------主界面 begin------------------ + function XRpgMakerGameManager.GetRpgMakerActivityStageDb(stageCfgId) + return RpgMakerGameActivityDb:GetStageDb(stageCfgId) + end + + function XRpgMakerGameManager.GetRpgMakerChapterClearStarCount(chapterId) + local stageIdList = XRpgMakerGameConfigs.GetRpgMakerGameStageIdList(chapterId) + local stageDb + local starCount = 0 + for _, stageId in ipairs(stageIdList) do + stageDb = XRpgMakerGameManager.GetRpgMakerActivityStageDb(stageId) + if stageDb then + starCount = starCount + stageDb:GetStarCount() + end + end + return starCount + end + + function XRpgMakerGameManager.IsChapterUnLock(chapterId) + if not XTool.IsNumberValid(chapterId) then + return true + end + local timeId = XRpgMakerGameConfigs.GetRpgMakerGameChapterOpenTimeId(chapterId) + return XFunctionManager.CheckInTimeByTimeId(timeId) + end + + function XRpgMakerGameManager.IsStageUnLock(stageId) + local stageStatus = XRpgMakerGameManager.GetRpgMakerGameStageStatus(stageId) + if stageStatus ~= XRpgMakerGameConfigs.RpgMakerGameStageStatus.Lock then + return true + end + + local preStage = XRpgMakerGameConfigs.GetRpgMakerGameStagePreStage(stageId) + local preStageName = XRpgMakerGameConfigs.GetRpgMakerGameStageName(preStage) + local desc = CS.XTextManager.GetText("RpgMakerGameStageNotOpen", preStageName) + return false, desc + end + + function XRpgMakerGameManager.GetCurrTaskTimeLimitId() + local activityId = XRpgMakerGameConfigs.GetDefaultActivityId() + return XRpgMakerGameConfigs.GetRpgMakerGameActivityTaskTimeLimitId(activityId) + end + + function XRpgMakerGameManager.GetTimeLimitTask() + local groupId = XRpgMakerGameManager.GetCurrTaskTimeLimitId() + return XDataCenter.TaskManager.GetTimeLimitTaskListByGroupId(groupId) + end + + function XRpgMakerGameManager.SetCurrTabGroupIndexByUiMainTemp(currTabGroupIndexByUiMainTemp) + CurrTabGroupIndexByUiMainTemp = currTabGroupIndexByUiMainTemp + end + + function XRpgMakerGameManager.SetCurrClearButtonGroupIndex() + XSaveTool.SaveData("RpgMakerGameCurrClearButtonGroupIndex" .. XPlayer.Id, CurrTabGroupIndexByUiMainTemp) + end + + function XRpgMakerGameManager.GetCurrClearButtonGroupIndex() + return XSaveTool.GetData("RpgMakerGameCurrClearButtonGroupIndex" .. XPlayer.Id) + end + -----------------主界面 end-------------------- + + -----------------关卡内 begin------------------ + function XRpgMakerGameManager.InitStageMap(mapId, selectRoleId) + PlayerObj:InitData(mapId, selectRoleId) + EndPointObj:InitData(mapId) + InitMonsetObj(mapId) + InitTriggerObjDic(mapId) + ResetStepCount() + end + + function XRpgMakerGameManager.ResetStageMap() + local enterStageDb = XRpgMakerGameManager:GetRpgMakerGameEnterStageDb() + local mapId = enterStageDb:GetMapId() + local selectRoleId = enterStageDb:GetSelectRoleId() + PlayerObj:InitData(mapId, selectRoleId) + EndPointObj:InitData(mapId) + ResetTriggerObj() + ResetMonsetObj() + ResetStepCount() + XRpgMakerGameManager.ResetActions() + end + + function XRpgMakerGameManager.ClearStageMap() + PlayerObj:Dispose() + EndPointObj:Dispose() + ClearMonsterObj() + ClearTriggerObj() + ResetStepCount() + end + + function XRpgMakerGameManager.GetNextAction() + local action = tableRemove(Actions, 1) + XRpgMakerGameManager.UpdateActionData(action) + return action + end + + function XRpgMakerGameManager.IsActionsEmpty() + return XTool.IsTableEmpty(Actions) + end + + --更新状态数据,不播放动画 + function XRpgMakerGameManager.UpdateActionData(action) + if action.ActionType == XRpgMakerGameConfigs.RpgMakerGameActionType.ActionPlayerMove then + XRpgMakerGameManager.SetCurrentCount(action.CurrentCount) + PlayerObj:SetFaceDirection(action.Direction) + PlayerObj:UpdatePosition(action.EndPosition) + return + end + + if action.ActionType == XRpgMakerGameConfigs.RpgMakerGameActionType.ActionKillMonster then + local monsterObj = XRpgMakerGameManager.GetMonsterObj(action.MonsterId) + if monsterObj then + monsterObj:Die() + end + return + end + + if action.ActionType == XRpgMakerGameConfigs.RpgMakerGameActionType.ActionStageWin then + local enterStageDb = XRpgMakerGameManager:GetRpgMakerGameEnterStageDb() + local stageId = enterStageDb:GetStageId() + local selectRoleId = enterStageDb:GetSelectRoleId() + local stepCount = XRpgMakerGameManager.GetCurrentCount() + local stageDb = XRpgMakerGameManager.GetRpgMakerActivityStageDb(stageId) + local starCount = action.StarCondition and #action.StarCondition or 0 + + if stageDb then + if stageDb:GetStarCount() < starCount then + stageDb:SetRoleId(selectRoleId) + stageDb:SetStepCount(stepCount) + stageDb:SetStarCondition(action.StarCondition) + end + else + RpgMakerGameActivityDb:UpdateStageDb({StageCfgId = stageId, RoleId = selectRoleId, StepCount = stepCount, StarCondition = action.StarCondition}) + end + return + end + + if action.ActionType == XRpgMakerGameConfigs.RpgMakerGameActionType.ActionEndPointOpen then + EndPointObj:EndPointOpen() + return + end + + if action.ActionType == XRpgMakerGameConfigs.RpgMakerGameActionType.ActionMonsterRunAway + or action.ActionType == XRpgMakerGameConfigs.RpgMakerGameActionType.ActionMonsterPatrol then + local monsterObj = XRpgMakerGameManager.GetMonsterObj(action.MonsterId) + if monsterObj then + monsterObj:SetFaceDirection(action.Direction) + monsterObj:UpdatePosition(action.EndPosition) + end + return + end + + if action.ActionType == XRpgMakerGameConfigs.RpgMakerGameActionType.ActionMonsterChangeDirection then + local monsterObj = XRpgMakerGameManager.GetMonsterObj(action.MonsterId) + if monsterObj then + monsterObj:SetFaceDirection(action.Direction) + end + return + end + + if action.ActionType == XRpgMakerGameConfigs.RpgMakerGameActionType.ActionMonsterKillPlayer then + PlayerObj:Die() + return + end + + if action.ActionType == XRpgMakerGameConfigs.RpgMakerGameActionType.ActionTriggerStatusChange then + local triggerObj = XRpgMakerGameManager.GetTriggerObj(action.TriggerId) + if triggerObj then + triggerObj:SetTriggerStatus(action.TriggerStatus) + end + return + end + + if action.ActionType == XRpgMakerGameConfigs.RpgMakerGameActionType.ActionUnlockRole then + RpgMakerGameActivityDb:UpdateUnlockRoleId(action.RoleId) + return + end + end + + --地图某一时刻的状态 + function XRpgMakerGameManager.UpdateMapStatusDb(data) + --玩家状态 + PlayerObj:UpdateData(data.GamePlayer) + --终点状态 + EndPointObj:UpdateData(data.EndPoint) + --怪物状态 + for _, monsterData in ipairs(data.GameMonsters) do + local id = monsterData.Id + local monsterObj = GameMonsterObjDic[id] + if monsterObj then + monsterObj:UpdateData(monsterData) + end + end + --机关 + for _, triggerData in ipairs(data.Triggers) do + local id = triggerData.Id + local triggerObj = TriggerObjDic[id] + if triggerObj then + triggerObj:UpdateData(triggerData) + end + end + + XDataCenter.RpgMakerGameManager.SetCurrentCount(data.CurrentRound) + end + + function XRpgMakerGameManager.SetCurrentCount(currentCount) + CurrentCount = currentCount + end + + function XRpgMakerGameManager.GetCurrentCount() + return CurrentCount + end + + function XRpgMakerGameManager.GetMonsterObj(monsterId) + return XTool.IsNumberValid(monsterId) and GameMonsterObjDic[monsterId] + end + + --获得怪物死亡的数量 + function XRpgMakerGameManager.GetMonsterDeathCount() + local normalMonsterDeathCount = 0 + local bossDeathCount = 0 + local totalDeathCount = 0 + local monsterTypeCfg + for _, obj in pairs(GameMonsterObjDic) do + monsterTypeCfg = XRpgMakerGameConfigs.GetRpgMakerGameMonsterType(obj:GetId()) + if monsterTypeCfg == XRpgMakerGameConfigs.XRpgMakerGameMonsterType.Normal and obj:IsDeath() then + normalMonsterDeathCount = normalMonsterDeathCount + 1 + elseif monsterTypeCfg == XRpgMakerGameConfigs.XRpgMakerGameMonsterType.BOSS and obj:IsDeath() then + bossDeathCount = bossDeathCount + 1 + end + end + + totalDeathCount = normalMonsterDeathCount + bossDeathCount + return totalDeathCount, normalMonsterDeathCount, bossDeathCount + end + + function XRpgMakerGameManager.GetTriggerObj(triggerId) + return XTool.IsNumberValid(triggerId) and TriggerObjDic[triggerId] + end + + function XRpgMakerGameManager.GetRpgMakerGameEnterStageDb() + return RpgMakerGameEnterStageDb + end + + function XRpgMakerGameManager.GetPlayerObj() + return PlayerObj + end + + function XRpgMakerGameManager.GetEndPointObj() + return EndPointObj + end + + function XRpgMakerGameManager.ResetActions() + Actions = {} + end + + function XRpgMakerGameManager.GetCurrentScene() + return CurrentScene + end + + --获得一个随机对话内容的id + function XRpgMakerGameManager.GetRandomDialogBoxId() + --设置随机数种子 + math.randomseed(os.time()) + + local idList = XRpgMakerGameConfigs.GetRpgMakerGameRandomDialogBoxIdList() + local clearStageIdList = {} + local preStageId + local isStageClear + local weight + local sum = 0 + local randomDialogBoxId + + --获取权重总和 + for _, id in ipairs(idList) do + preStageId = XRpgMakerGameConfigs.GetRpgMakerGameRandomDialogBoxPreStage(id) + isStageClear = not XTool.IsNumberValid(preStageId) and true or XRpgMakerGameManager.IsStageClear(preStageId) + weight = XRpgMakerGameConfigs.GetRpgMakerGameRandomDialogBoxWeight(id) + if isStageClear then + table.insert(clearStageIdList, id) + sum = sum + weight + end + end + + --随机数加上权重,越大的权重,数值越大 + local maxRand = 0 + local rand + for _, id in ipairs(clearStageIdList) do + rand = math.random(0, sum) + weight = XRpgMakerGameConfigs.GetRpgMakerGameRandomDialogBoxWeight(id) + if rand + weight > maxRand then + maxRand = rand + weight + randomDialogBoxId = id + end + end + + return randomDialogBoxId + end + + function XRpgMakerGameManager.GetSceneCubeObj(row, col) + local currentScene = XRpgMakerGameManager.GetCurrentScene() + return currentScene and currentScene:GetCubeObj(row, col) + end + + function XRpgMakerGameManager.GetSceneCubeUpCenterPosition(row, col) + local cubeObj = XRpgMakerGameManager.GetSceneCubeObj(row, col) + return cubeObj and cubeObj:GetGameObjUpCenterPosition() + end + + function XRpgMakerGameManager.GetSceneCubeTransform(row, col) + local cubeObj = XRpgMakerGameManager.GetSceneCubeObj(row, col) + return cubeObj and cubeObj:GetTransform() + end + -----------------关卡内 end-------------------- + + -----------------角色相关 begin---------------- + function XRpgMakerGameManager.GetOnceUnLockRoleId() + local roleIdList = XRpgMakerGameConfigs.GetRpgMakerGameRoleIdList() + for _, roleId in ipairs(roleIdList) do + if XRpgMakerGameManager.IsUnlockRole(roleId) then + return roleId + end + end + return roleIdList[1] + end + + function XRpgMakerGameManager.IsUnlockRole(roleId) + if not XTool.IsNumberValid(roleId) then + return false + end + + local unlockRoleIdList = XRpgMakerGameManager.GetUnlockRoleIdList() + for _, unlockRoleId in ipairs(unlockRoleIdList) do + if unlockRoleId == roleId then + return true + end + end + + return false, XRpgMakerGameConfigs.GetRpgMakerGameRoleLockTipsDesc(roleId) + end + + function XRpgMakerGameManager.GetUnlockRoleIdList() + return RpgMakerGameActivityDb:GetUnlockRoleIdList() + end + -----------------角色相关 end------------------ + + -----------------协议相关 begin---------------- + --进入活动请求 + function XRpgMakerGameManager.RequestRpgMakerGameEnter() + if not XDataCenter.RpgMakerGameManager.CheckActivityCondition() then + return + end + + XNetwork.Call("RpgMakerGameEnterRequest", {}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + RpgMakerGameActivityDb:UpdateData(res.ActivityDb or res.ActivityData) --中途改了名字,防止出错 + if not XLuaUiManager.IsUiLoad("UiRpgMakerGameMain") then + XLuaUiManager.Open("UiRpgMakerGameMain") + end + end) + end + + --进入一个TileMap + function XRpgMakerGameManager.RequestRpgMakerGameEnterStage(stageId, selectRoleId, cb) + local req = { StageId = stageId, SelectRoleId = selectRoleId } + XNetwork.Call("RpgMakerGameEnterStageRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + CurrentScene:RemoveScene() + XRpgMakerGameManager.ResetActions() + + RpgMakerGameEnterStageDb:UpdateData(res) + for _, action in ipairs(res.Actions or {}) do + InsertAction(action) + end + XRpgMakerGameManager.InitStageMap(res.MapId, res.SelectRoleId) + + + XLuaUiManager.Open("UiFubenRpgMakerGameMovie", stageId) + CurrentScene:LoadScene(res.MapId, function() + local delay = CS.XGame.ClientConfig:GetInt("RpgMakerGameLoadingDelayClose") --延迟Loading界面关闭的时间 + + XScheduleManager.ScheduleOnce(function() + XLuaUiManager.Close("UiFubenRpgMakerGameMovie") + CurrentScene:SetSceneActive(false) --处理光照异常 + CurrentScene:SetSceneActive(true) + if cb then + cb() + end + end, delay) + end, "UiRpgMakerGamePlayMain") + end) + end + + --玩家移动 + function XRpgMakerGameManager.RequestRpgMakerGameMapMove(mapId, direction, cb) + if IsLockReqMove() then return end + + local req = { MapId = mapId, Direction = direction } + LockReqMove() + XNetwork.Call("RpgMakerGameMapMoveRequest", req, function(res) + if res.Code ~= XCode.Success then + UnLockReqMove() + XUiManager.TipCode(res.Code) + return + end + + for _, action in ipairs(res.Actions) do + InsertAction(action) + end + + + UnLockReqMove() + + if cb then + cb() + end + end) + end + + --重置游戏 + function XRpgMakerGameManager.RequestRpgMakerGameMapResetGame(mapId, cb) + local req = { MapId = mapId } + XNetwork.Call("RpgMakerGameMapResetGameRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + XRpgMakerGameManager.ResetStageMap() + for _, action in ipairs(res.Actions or {}) do + InsertAction(action) + end + + if cb then + cb() + end + end) + end + + --后退 + function XRpgMakerGameManager.RequestRpgMakerGameMapBackUp(mapId, cb) + local currCount = XRpgMakerGameManager.GetCurrentCount() + if currCount == 0 then + return + end + + local req = { MapId = mapId } + XNetwork.Call("RpgMakerGameMapBackUpRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + XRpgMakerGameManager.UpdateMapStatusDb(res.GameMapStatusDb) + for _, action in ipairs(res.Actions or {}) do + InsertAction(action) + end + + local currentRound = res.GameMapStatusDb.CurrentRound + if cb then + cb(currentRound) + end + end) + end + -----------------协议相关 end---------------- + + return XRpgMakerGameManager +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XRpgTowerManager.lua b/Resources/Scripts/XManager/XRpgTowerManager.lua new file mode 100644 index 00000000..426af719 --- /dev/null +++ b/Resources/Scripts/XManager/XRpgTowerManager.lua @@ -0,0 +1,791 @@ +--兵法蓝图玩法管理器 +XRpgTowerManagerCreator = function() + local XRpgTowerManager = {} + local RpgTowerConfig = XRpgTowerConfig + local RpgTowerCharacter = require("XEntity/XRpgTower/XRpgTowerCharacter") + local RpgTowerStage = require("XEntity/XRpgTower/XRpgTowerStage") + local RpgTowerChapter = require("XEntity/XRpgTower/XRpgTowerChapter") +--[[ + *********搜索以下关键字快速到达该类方法模块********* + =========初始化方法 + =========角色管理方法 + =========FubenManager代理方法 + =========协议方法 + =========玩法配置Get方法 + =========XRpc方法 +]]-- + +-- **** 玩法基础配置变量 + local CurrentConfig -- 基本活动配置,读取RpgConfig表 + local StartTime = 0 -- 本轮结束时间 + local EndTime = 0 -- 本轮开始时间 +-- **** 玩法关卡管理模块变量 + local CurrentChapter -- 现在的章节对象 + local RStageList = {} --关卡对象列表 + local HadGetDailyReward = true --是否领取了今日宝箱 +-- **** 玩法角色管理模块变量 + local MyTeamMember = {} -- 角色小队 + local PreTeamLevel = 1 --经验变化前一个节点的队伍等级 + local TeamLevel = 1 --队伍等级 + local PreTeamExp = 0 --经验变化前一个节点的当前队伍等级经验 + local TeamExp = 0 --当前队伍等级的经验 + local ChangeExp = 0 --等级变化增加的经验值 + local TeamExpNewChange = false --是否有新的经验变动 + local IsActivityEnd = false -- 是否玩法已关闭(优先判断此条件) + local IsInit = false -- 是否从服务器获取消息并初始化了数据 + local IsReset = false -- 是否重置了数据 + local IsStageDataInit = false -- 是否已初始化过关卡信息 + local IsRegisterEditBattleProxy = false -- 是否已注册出战界面代理 + local UPGRADE_ITEM_ID = 60815 +-- **** 玩法枚举类型 +--================ +--协议名称 +--================ + local REQUEST_NAMES = { --请求名称 + CharaUpgrade = "RpgUpgradeRequest", -- 角色升星 + CharaTalentActive = "RpgActivateTalentRequest", -- 角色激活天赋 + CharaTalentReset = "RpgResetTalentRequest", --角色天赋重置 + GetDailyReward = "RpgGetDailyRewardRequest", -- 角色重置 + } + +--================ +--角色头像面板展示样式 +--================ + XRpgTowerManager.CharaItemShowType = { + Normal = 1, -- Ui有头像,星数,名称,战力 + OnlyIconAndStar = 2 -- Ui仅有头像和星数 + } + +--================ +--怪兽模型位置 +--================ + XRpgTowerManager.MonsterModelPos = { + Middle = 1, + Left = 2, + Right = 3 + } +--================ +--主界面关卡图标枚举 +--================ + XRpgTowerManager.StageDifficultyData = { + [1] = { + IconPath = CS.XGame.ClientConfig:GetString("RpgTowerStageIconNormal") + }, + [2] = { + IconPath = CS.XGame.ClientConfig:GetString("RpgTowerStageIconHard") + }, + [3] = { + IconPath = CS.XGame.ClientConfig:GetString("RpgTowerStageIconChallenge") + } + } +--================ +--玩法养成界面的3D镜头枚举 +--================ + XRpgTowerManager.UiCharacter_Camera = { + MAIN = 0, -- 主页面镜头 + ADAPT = 1, + LEVELUP = 2, -- 升级页签镜头 + NATURE = 4, -- 天赋页签镜头 + CHANGEMEMBER = 5 -- 切换队员镜头 + } +--================ +--玩法养成界面的子页面枚举 +--================ + XRpgTowerManager.PARENT_PAGE = { + MAIN = 1, -- 主页面 + ADAPT = 2, -- 改造页面 + CHANGEMEMBER = 3, -- 切换队员 + } +--================ +--编队界面警告面板 +--================ + XRpgTowerManager.STAGE_WARNING_LEVEL = { + NoWarning = 1, --无警告 + Warning = 2, --警告 + Danger = 3, --危险 + } +-- 相关数据模型 +--[[ + **** 协议用角色模型数据 + XRpgCharacter = + { + int CharacterId, + int Level, + HashSet Talents + } + + **** 刷新玩法数据协议(在服务器推送刷新数据和开始玩法时传入) + NotifyRpgData = + { + int ActivityId; + List Characters; + } + + **** 玩法角色模型类(客户端构建) + XRpgTowerCharacter +]] + +-- ========= ========= +-- =========初始化方法========= +-- ========= ========= + +--[[ +================ +本地初始化管理器 +================ +]] + function XRpgTowerManager.Init() + CurrentChapter = RpgTowerChapter.New() + end + +--[[ +================ +注册出战界面代理 +================ +]] + function XRpgTowerManager.RegisterEditBattleProxy() + if IsRegisterEditBattleProxy then return end + IsRegisterEditBattleProxy = true + XUiNewRoomSingleProxy.RegisterProxy(XDataCenter.FubenManager.StageType.RpgTower, + require("XUi/XUiRpgTower/Battle/EditBattleUi/XUiRpgTowerNewRoomSingle")) + end +--[[ +================ +初始化/重置玩法数据 +@param:notifyRpgData 后端推送的初始化数据 +================ +]] + function XRpgTowerManager.Reset(notifyRpgData) + CurrentConfig = RpgTowerConfig.GetRpgTowerConfigById(notifyRpgData.ActivityId) + if CurrentConfig then + XRpgTowerManager.InitTeamMember() + XRpgTowerManager.SetTeam(notifyRpgData.Characters) + if IsInit then + IsReset = true + CurrentChapter:ResetStage() + end + IsInit = true + else + XLog.Error(string.format("兵法蓝图配置未成功初始化!将导致玩法不能正常运行,请检查!%s", + tostring(notifyRpgData.ActivityId))) + IsActivityEnd = true + IsReset = true + return + end + if not CurrentChapter then + CurrentChapter = RpgTowerChapter.New(notifyRpgData.ActivityId) + else + CurrentChapter:RefreshData(notifyRpgData.ActivityId) + end + CsXGameEventManager.Instance:Notify(XEventId.EVENT_RPGTOWER_RESET) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_ACTIVITY_ON_RESET, XDataCenter.FubenManager.StageType.RpgTower) + end + +--[[ +================ +关闭玩法(在后端推送活动结束时调用) +================ +]] + function XRpgTowerManager.EndActivity() + if CurrentConfig then + StartTime = XRpgTowerManager.GetStartTime() + EndTime = XRpgTowerManager.GetEndTime() + XRpgTowerManager.InitTeamMember() + end + IsActivityEnd = true + IsReset = true + CsXGameEventManager.Instance:Notify(XEventId.EVENT_RPGTOWER_RESET) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_ACTIVITY_ON_RESET, XDataCenter.FubenManager.StageType.RpgTower) + end + +-- ========= ========= +-- =========FubenManager代理方法========= +-- ========= ========= + +--[[ +================ +初始化关卡信息 +================ +]] + function XRpgTowerManager.InitStageInfo(checkNewUnlock) + local stageList = RpgTowerConfig.GetRStageList() + RStageList = {} + for rStageId, rStageCfg in pairs(stageList) do + RStageList[rStageId] = RpgTowerStage.New(rStageId) + end + end +--[[ +================ +初始化关卡信息 +================ +]] + function XRpgTowerManager.PreFight(stage, teamId, isAssist, challengeCount,challengeId) + local preFight = {} + preFight.CardIds = {} + preFight.StageId = stage.StageId + preFight.IsHasAssist = isAssist and true or false + preFight.ChallengeCount = challengeCount or 1 + preFight.RobotIds = {} + local teamData = XDataCenter.TeamManager.GetTeamData(teamId) + for i in pairs(teamData) do + preFight.CardIds[i] = teamData[i] + end + preFight.CaptainPos = XDataCenter.TeamManager.GetTeamCaptainPos(teamId) + preFight.FirstFightPos = XDataCenter.TeamManager.GetTeamFirstFightPos(teamId) + return preFight + end + +--=================== +--调用结算界面 +--=================== + function XRpgTowerManager.ShowReward(winData) + XLuaUiManager.Open("UiRpgTowerSettleWin", winData) + end +-- ========= ========= +-- =========角色管理方法========= +-- ========= ========= + +--[[ +================ +初始化角色数据,在初始化管理器时调用 +================ +]] + function XRpgTowerManager.InitTeamMember() + if not CurrentConfig then + XLog.Error("兵法蓝图配置未成功初始化!将导致玩法不能正常运行,请检查!") + return + end + MyTeamMember = {} + for i = 1, #CurrentConfig.CharacterIds do + local chara = RpgTowerCharacter.New(CurrentConfig.CharacterIds[i], i) + if chara then MyTeamMember[chara:GetCharacterId()] = chara end + end + end +--[[ +================ +设置新的角色数据,在重置数据和刷新数据时调用 +@param teamInfo 角色数据 List +================ +]] + function XRpgTowerManager.SetTeam(teamInfo) + for _, memberInfo in pairs(teamInfo) do + if not MyTeamMember[memberInfo.CharacterId] then + XLog.Error(string.format("兵法蓝图要刷新的成员不存在!角色Id:%s", + tostring(memberInfo.CharacterId))) + XLog.Debug("本地兵法蓝图成员数据:", MyTeamMember) + return + else + MyTeamMember[memberInfo.CharacterId]:RefreshCharacterData(memberInfo) + end + end + CsXGameEventManager.Instance:Notify(XEventId.EVENT_RPGTOWER_MEMBERCHANGE) + end + +-- ========= ========= +-- =========玩法配置Get方法========= +-- ========= ========= + +--=================== +--获取活动配置简表 +--=================== + function XRpgTowerManager.GetActivityChapters() + if not CurrentConfig then + CurrentConfig = RpgTowerConfig.GetLatestConfig() + end + local timeNow = XTime.GetServerNowTimestamp() + local isEnd = 0 + local isStart = 0 + isEnd = timeNow >= XRpgTowerManager.GetEndTime() + isStart = timeNow >= XRpgTowerManager.GetStartTime() + local inActivity = (not isEnd) and (isStart) + if not inActivity then return {} end + local chapters = {} + local tempChapter = {} + tempChapter.Type = XDataCenter.FubenManager.ChapterType.RpgTower + tempChapter.Id = CurrentConfig.Id + table.insert(chapters, tempChapter) + return chapters + end +--=================== +--获取活动名称 +--=================== + function XRpgTowerManager.GetActivityName() + return CurrentConfig.ActivityName + end +--=================== +--获取活动入口配图地址 +--=================== + function XRpgTowerManager.GetEntryTexture() + return CurrentConfig.EntryTexture + end +--[[ +================ +使用关卡ID获取玩法关卡对象 +@param stageId:关卡ID +================ +]] + function XRpgTowerManager.GetRStageByStageId(stageId) + local rStageId = RpgTowerConfig.GetRStageIdByStageId(stageId) + return RStageList[rStageId] + end +--[[ +================ +获取所有队员信息 +================ +]] + function XRpgTowerManager.GetTeam() + local team = {} + for _, member in pairs(MyTeamMember) do + team[member:GetOrder()] = member + end + return team + end +--[[ +================ +通过角色ID获取队员信息 +================ +]] + function XRpgTowerManager.GetTeamMemberByCharacterId(charaId) + if not charaId then return nil end + if not MyTeamMember[charaId] then + XLog.Error(string.format("要查找的成员数据不存在!请检查!角色ID:%s", + tostring(charaId))) + XLog.Debug("本地兵法蓝图成员数据:", MyTeamMember) + return nil + end + return MyTeamMember[charaId] + end +--================ +--检查总成员等级是否高于检查数值 +--@param checkNum:检查数值 +--================ + function XRpgTowerManager.GetMemberTotalLevelReachNum(checkNum) + local total = 0 + for _, member in pairs(MyTeamMember) do + total = total + member:GetLevel() + end + return total >= checkNum + end +--[[ +================ +检查玩法角色中是否存在指定角色ID +================ +]] + function XRpgTowerManager.GetTeamMemberExist(charaId) + if not charaId then return false end + if not MyTeamMember[charaId] then return false end + return true + end +--[[ +================ +检查对应角色是否在出战队伍中 +================ +]] + function XRpgTowerManager.GetCharacterIsInTeam(charaId) + local teamInfos = XDataCenter.TeamManager.GetPlayerTeam(CS.XGame.Config:GetInt("TypeIdRpgTower")) + if not teamInfos or not charaId then return false end + for _, v in pairs(teamInfos.TeamData) do + if v == charaId then + return true + end + end + return false + end +--[[ +================ +获取队员未使用的天赋点数 +================ +]] + function XRpgTowerManager.GetTeamMemberTalentPointsByCharacterId(charaId) + if not MyTeamMember[charaId] then + XLog.Error(string.format("要查找的成员数据不存在!请检查!角色ID:%s", + tostring(charaId))) + XLog.Debug("本地兵法蓝图成员数据:", MyTeamMember) + return 0 + end + return MyTeamMember[charaId]:GetTalentPoints() + end +--[[ +================ +获取剩余挑战次数字符串 +================ +]] + function XRpgTowerManager.GetChallengeCountStr() + return CS.XTextManager.GetText("RpgTowerChallengeCountStr", + XRpgTowerManager.GetChallengeCount(), + CurrentConfig.MaxChallengeCount) + end +--[[ +================ +获取能否挑战关卡 +================ +]] + function XRpgTowerManager.GetCanChallenge() + return true + end +--[[ +================ +获取当前章节通关进度字符串 +================ +]] + function XRpgTowerManager.GetChapterProgressStr() + return CurrentChapter:GetPassProgressStr() + end +--[[ +================ +获取玩法是否关闭(用于判断玩法入口,进入活动条件等) +@return param1:玩法是否关闭 +@return param2:是否活动未开启 +================ +]] + function XRpgTowerManager.GetIsEnd() + local timeNow = XTime.GetServerNowTimestamp() + local isEnd = timeNow >= XRpgTowerManager.GetEndTime() + local isStart = timeNow >= XRpgTowerManager.GetStartTime() + local inActivity = (not isEnd) and (isStart) + return IsActivityEnd or not inActivity, timeNow < XRpgTowerManager.GetStartTime() + end +--[[ +================ +获取本轮开始时间 +================ +]] + function XRpgTowerManager.GetStartTime() + if not CurrentConfig then + CurrentConfig = RpgTowerConfig.GetLatestConfig() + end + return XFunctionManager.GetStartTimeByTimeId(CurrentConfig.TimeId) or 0 + end +--[[ +================ +获取本轮结束时间 +================ +]] + function XRpgTowerManager.GetEndTime() + if not CurrentConfig then + CurrentConfig = RpgTowerConfig.GetLatestConfig() + end + return XFunctionManager.GetEndTimeByTimeId(CurrentConfig.TimeId) or 0 + end +--[[ +================ +获取现在的章节对象 +================ +]] + function XRpgTowerManager.GetCurrentChapter() + return CurrentChapter + end +--[[ +================ +获取是否可挑战新关卡 +================ +]] + function XRpgTowerManager.GetHaveNewStage() + return (not CurrentChapter:GetIsClear()) + end +--================ +--获取是否有角色可以升级天赋 +--================ + function XRpgTowerManager.GetMemberCanActiveTalent() + for _, member in pairs(MyTeamMember) do + if member:CheckCanActiveTalent() then return true end + end + return false + end +--[[ +================ +获取是否重置了数据(用于重置数据后的边界处理) +================ +]] + function XRpgTowerManager.GetIsReset() + return IsReset + end +--[[ +================ +获取本轮的天赋道具ID(玩法道具Id) +================ +]] + function XRpgTowerManager.GetTalentItemId() + return CurrentConfig.TalentItemId + end +--[[ +================ +获取本轮的升级道具ID +================ +]] + function XRpgTowerManager.GetLevelUpItemId() + return UPGRADE_ITEM_ID + end +--============== +--初始化数据是否重置的状态(重置数据后再次重新进入玩法时初始化) +--============== + function XRpgTowerManager.SetNewBegining() + IsReset = false + end +--================ +--判断是否第一次进入玩法(本地存储纪录) +--================ + function XRpgTowerManager.GetIsFirstIn() + local localData = XSaveTool.GetData("RpgTowerFirstIn" .. XPlayer.Id .. CurrentConfig.ActivityName) + if localData == nil then + XSaveTool.SaveData("RpgTowerFirstIn".. XPlayer.Id .. CurrentConfig.ActivityName, true) + return true + end + return false + end +--================ +--判断是否能获取每日补给 +--================ + function XRpgTowerManager.GetCanReceiveSupply() + return not HadGetDailyReward + end +--================ +--获取队伍等级最大值 +--================ + function XRpgTowerManager.GetMaxLevel() + return RpgTowerConfig.GetTeamMaxLevel() + end +--================ +--获取当前等级 +--================ + function XRpgTowerManager.GetCurrentLevel() + return TeamLevel + end +--================ +--获取当前等级配置 +--================ + function XRpgTowerManager.GetCurrentLevelCfg() + return RpgTowerConfig.GetTeamLevelCfgByLevel(XRpgTowerManager.GetCurrentLevel()) + end +--================ +--获取当前经验值字符串 +--================ + function XRpgTowerManager.GetCurrentExp() + return TeamExp + end +--================ +--获取等级变化信息 +--================ + function XRpgTowerManager.GetExpChanges() + local changes = { + TeamExpNewChange = TeamExpNewChange, + PreTeamExp = PreTeamExp, + PreTeamLevel = PreTeamLevel, + TeamExp = TeamExp, + TeamLevel = TeamLevel, + ChangeExp = ChangeExp + } + TeamExpNewChange = false + return changes + end +--================ +--检查是否有等级变动 +--================ + function XRpgTowerManager.CheckExpChange() + local result = TeamExpNewChange + return result + end +-- ========= ========= +-- =========跳转方法 ========= +-- ========= ========= +--[[ +================ +跳转到活动主界面 +================ +]] + function XRpgTowerManager.JumpTo() + if XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.RpgTower) then + local canGoTo, notStart = XRpgTowerManager.CheckCanGoTo() + if canGoTo then + XLuaUiManager.Open("UiRpgTowerMain") + elseif notStart then + XUiManager.TipMsg(CS.XTextManager.GetText("RpgTowerNotStart")) + else + XUiManager.TipMsg(CS.XTextManager.GetText("RpgTowerEnd")) + end + end + end +--[[ +================ +检查是否能进入玩法 +@return param1:是否在活动时间内(true为在活动时间内) +@return param2:是否未开始活动(true为未开始活动) +================ +]] + function XRpgTowerManager.CheckCanGoTo() + local isActivityEnd, notStart = XRpgTowerManager.GetIsEnd() + return not isActivityEnd, notStart + end +-- ========= ========= +-- =========协议方法========= +-- ========= ========= + +--[[ +================ +请求:激活天赋 +================ +]] + function XRpgTowerManager.CharaTalentActive(rTalent) + if rTalent:GetIsUnLock() then + XUiManager.TipMsg(CS.XTextManager.GetText("RpgTowerCharaTalentIsAlreadyUnlock")) + return + end + if not rTalent:CheckNeedTeamLevel() then + XUiManager.TipMsg(CS.XTextManager.GetText("RpgTowerTalentLevelNotEnough", rTalent:GetNeedTeamLevel())) + return + end + if not rTalent:GetCanUnLock() then + if not rTalent:CheckCostEnough() then + XUiManager.TipMsg(CS.XTextManager.GetText("RpgTowerTalentPointsNotEnough")) + else + XUiManager.TipMsg(CS.XTextManager.GetText("RpgTowerTalentCannotUnlock")) + end + return + end + local characterId = rTalent:GetCharacterId() + if not MyTeamMember[characterId] then + XLog.Error(string.format("要激活天赋的成员数据不存在!请检查!角色ID:%s", + tostring(characterId))) + XLog.Debug("本地兵法蓝图成员数据:", MyTeamMember) + return + end + if MyTeamMember[characterId]:GetTalentPoints() < rTalent:GetTalentConsume() then + XUiManager.TipMsg(CS.XTextManager.GetText("RpgTowerTalentPointsNotEnough")) + return + end + XNetwork.Call(REQUEST_NAMES.CharaTalentActive, {CharacterId = characterId, TalentId = rTalent:GetId()}, function(reply) + if reply.Code ~= XCode.Success then + XUiManager.TipCode(reply.Code) + return + end + MyTeamMember[characterId]:TalentActive(rTalent, reply.TalentPoints) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_RPGTOWER_MEMBERCHANGE) + end) + end +--[[ +================ +请求:重置天赋 +================ +]] + function XRpgTowerManager.CharacterReset(characterId) + local tipTitle = CS.XTextManager.GetText("RpgTowerResetTalentConfirmTitle") + local content = CS.XTextManager.GetText("RpgTowerResetTalentConfirmContent") + local confirmCb = function() + if not MyTeamMember[characterId] then + XLog.Error(string.format("要激活天赋的成员数据不存在!请检查!角色ID:%s", + tostring(characterId))) + XLog.Debug("本地兵法蓝图成员数据:", MyTeamMember) + return + end + XNetwork.Call(REQUEST_NAMES.CharaTalentReset, {CharacterId = characterId}, function(reply) + if reply.Code ~= XCode.Success then + XUiManager.TipCode(reply.Code) + return + end + MyTeamMember[characterId]:CharacterReset(reply.TalentPoints) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_RPGTOWER_MEMBERCHANGE) + end) + end + CsXUiManager.Instance:Open("UiDialog", tipTitle, content, XUiManager.DialogType.Normal, nil, confirmCb) + end +--================ +--请求:获取今日补给 +--================ + function XRpgTowerManager.ReceiveSupply() + if not XRpgTowerManager.GetCanReceiveSupply() then + XUiManager.TipMsg(CS.XTextManager.GetText("RpgTowerCantGetSupply")) + return + end + XNetwork.Call(REQUEST_NAMES.GetDailyReward, { }, function(reply) + if reply.Code ~= XCode.Success then + XUiManager.TipCode(reply.Code) + return + end + XUiManager.OpenUiObtain(reply.RewardGoodsList) + HadGetDailyReward = true + CsXGameEventManager.Instance:Notify(XEventId.EVENT_RPGTOWER_REFRESH_DAILYREWARD) + end) + end +--[[ +================ +协议处理:初始化玩法数据 +================ +]] + function XRpgTowerManager.RefreshData(data) + if data.ActivityId == 0 then + XRpgTowerManager.EndActivity() + elseif CurrentChapter:GetChapterId() ~= data.ActivityId then + TeamLevel = data.TeamLevel + TeamExp = data.TeamExp + HadGetDailyReward = data.HadGetDailyReward + XRpgTowerManager.Reset(data) + XRpgTowerManager.RegisterEditBattleProxy() + else + IsActivityEnd = false + TeamLevel = data.TeamLevel + TeamExp = data.TeamExp + HadGetDailyReward = data.HadGetDailyReward + XRpgTowerManager.SetTeam(data.Characters) -- List + XRpgTowerManager.RegisterEditBattleProxy() + end + end +--[[ +================ +协议处理:每日重置处理 +================ +]] + function XRpgTowerManager.DailyReset() + HadGetDailyReward = false + CsXGameEventManager.Instance:Notify(XEventId.EVENT_RPGTOWER_REFRESH_DAILYREWARD) + end +--================ +--协议处理:刷新队伍等级 +--@param data : { +-- int TeamLevel +-- int TeamExp +-- List Characters +-- int AddExp } +--================ + function XRpgTowerManager.RefreshTeamLevelData(data) + if data.AddExp <= 0 then return end + PreTeamExp = TeamExp + PreTeamLevel = TeamLevel + TeamExp = data.TeamExp + TeamLevel = data.TeamLevel + ChangeExp = data.AddExp + TeamExpNewChange = true + XRpgTowerManager.SetTeam(data.Characters) + end + + XRpgTowerManager.Init() + return XRpgTowerManager +end + +-- ========= ========= +-- =========XRpc方法========= +-- ========= ========= + +--================ +--初始化活动数据 +--================ +XRpc.NotifyRpgData = function(data) + XDataCenter.RpgTowerManager.RefreshData(data.Data) +end + +--================ +--通知每日重置 +--================ +XRpc.NotifyRpgDailyReset = function() + XDataCenter.RpgTowerManager.DailyReset() +end +--================ +--通知队伍经验变化 +--@param data : { +-- int TeamLevel +-- int TeamExp +-- List Characters +-- int AddExp } +--================ +XRpc.NotifyRpgTeamData = function(data) + XDataCenter.RpgTowerManager.RefreshTeamLevelData(data) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XScratchTicketManager.lua b/Resources/Scripts/XManager/XScratchTicketManager.lua new file mode 100644 index 00000000..722ea4c6 --- /dev/null +++ b/Resources/Scripts/XManager/XScratchTicketManager.lua @@ -0,0 +1,134 @@ +-- 刮刮乐活动管理器 +XScratchTicketManagerCreator = function() + local XScratchTicketManager = {} + local AllActivities = {} + XScratchTicketManager.PlayStatus = { + NotStart = 1, --未开始游戏 + Playing = 2, --正在游玩 + } + local REQUEST_NAMES = { + StartScratch = "ScratchTicketActivityStartRequest", --开始刮刮卡游戏 + OpenGrid = "ScratchTicketActivityOpenGridRequest", --预览格子 + ExChange = "ScratchTicketActivityEndRequest", --开奖 + Reset = "ScratchTicketActivityResetRequest", --重置刮刮卡(完成一局游戏) + } + function XScratchTicketManager.Init() + + end + + function XScratchTicketManager.UpdateActivity(id, activityDb) + + end + --================ + --刷新活动数据 + --[[ + public class ScratchTicketActivityDb + { + public int Id; --对应Activity表Id + + //已经开放的Grid + public List OpenGrid = new List(); + + //缓存配置表 + public int LuckNumber { get; set; } + + //选择哪一个开奖列 + public int SelectOpen { get; set; } + + public int GridCfgIndex { get; set; } --ScratchTicket表GridIds的序号,对应Grid表 + + public int CfgIndex { get; set; } --Activity表ScratchTicket数组的序号,对应ScratchTicket的Id + } + + public class ScratchTicketActivityOpenGridDb + { + public int Index; + public int Num; + } + ]] + --================ + function XScratchTicketManager.UpdateActivities(activityDbs) + for id, activity in pairs(activityDbs) do + if not AllActivities[activity.Id] then + local controllerScript = require("XEntity/XScratchTicket/XScratchTicketActivityController") + AllActivities[activity.Id] = controllerScript.New(activity.Id) + end + AllActivities[activity.Id]:UpdateData(activity) + end + end + + function XScratchTicketManager.GetActivityController(id) + if not AllActivities[id] then + local controllerScript = require("XEntity/XScratchTicket/XScratchTicketActivityController") + AllActivities[id] = controllerScript.New(id) + end + return AllActivities[id] + end + + function XScratchTicketManager.StartGame(activityId) + if XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.ScratchTicket, true) then + XNetwork.Call(REQUEST_NAMES.StartScratch, { Id = activityId }, function(reply) + if reply.Code ~= XCode.Success then + XUiManager.TipCode(reply.Code) + return + end + AllActivities[activityId]:UpdateData(reply.ActivityDb) + XEventManager.DispatchEvent(XEventId.EVENT_SCRATCH_TICKET_ACTIVITY_START, activityId) + end) + end + end + + function XScratchTicketManager.OpenGrid(activityId, gridIndex) + XNetwork.Call(REQUEST_NAMES.OpenGrid, { Id = activityId, GridIndex = gridIndex - 1 }, function(reply) + if reply.Code ~= XCode.Success then + XUiManager.TipCode(reply.Code) + return + end + AllActivities[reply.Id]:OpenGrid(reply.GridIndex + 1, reply.Num) + XEventManager.DispatchEvent(XEventId.EVENT_SCRATCH_TICKET_OPEN_GRID, activityId) + end) + end + + function XScratchTicketManager.ExChange(activityId, openIndex) + XNetwork.Call(REQUEST_NAMES.ExChange, { Id = activityId, OpenIndex = openIndex }, function(reply) + if reply.Code ~= XCode.Success then + XUiManager.TipCode(reply.Code) + return + end + AllActivities[reply.ActivityDb.Id]:UpdateData(reply.ActivityDb) + local ticket = AllActivities[reply.ActivityDb.Id]:GetTicket() + local rewardId + local rewardList + if reply.ActivityDb.IsWin then + rewardId = ticket:GetWinRewardId() + else + rewardId = ticket:GetLoseRewardId() + end + if rewardId and rewardId > 0 then + rewardList = XRewardManager.GetRewardList(rewardId) + end + XEventManager.DispatchEvent(XEventId.EVENT_SCRATCH_TICKET_SHOW_RESULT, activityId, rewardList) + end) + end + + function XScratchTicketManager.ResetGame(activityId) + XNetwork.Call(REQUEST_NAMES.Reset, { Id = activityId }, function(reply) + if reply.Code ~= XCode.Success then + XUiManager.TipCode(reply.Code) + return + end + AllActivities[activityId]:UpdateData(reply.ActivityDb) + XEventManager.DispatchEvent(XEventId.EVENT_SCRATCH_TICKET_RESET, activityId) + end) + end + XScratchTicketManager.Init() + return XScratchTicketManager +end + +--=============== +--刮刮乐活动数据推送 +--@param db : {List} +--=============== +XRpc.NotifyScratchTicketActivity = function(db) + XDataCenter.ScratchTicketManager.UpdateActivities(db.ActivityDbs) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XServerManager.lua b/Resources/Scripts/XManager/XServerManager.lua new file mode 100644 index 00000000..e172cb68 --- /dev/null +++ b/Resources/Scripts/XManager/XServerManager.lua @@ -0,0 +1,245 @@ +local Platform = CS.UnityEngine.Application.platform +local RuntimePlatform = CS.UnityEngine.RuntimePlatform + +XServerManager = XServerManager or {} + +local Json = require("XCommon/Json") +local LoginTimeOutSecond = CS.XGame.Config:GetInt("LoginTimeOutInterval") +local SERVER_CONNECT_TIME_KEY = "SERVER_CONNECT_TIME_KEY" +local RECENT_TIME_PERIOD = 3600 * 24 * 7 +local GetTime = os.time + +XServerManager.SERVER_STATE = { + MAINTAIN = 0, -- 维护 + LOW = 1, -- 畅通 + HIGH = 2, -- 爆满 + CHECK = 3, -- 检测中 + FAIL = 4, -- 失败 +} + +local ServerList = {} +local SortedList = {} +local TempServerDic = {} +local LastServerCheckTime = {} +local LastServerConnectTime = {} + +local AndroidPayCallList = {} +local IosPayCallList = {} + +function XServerManager.SplitPayCallList(list, str) + if str == "" or str == nil then + return + end + local strs = string.Split(str, '#') + local i = 1 + for _, value in ipairs(strs) do + list[i] = value + i = i + 1 + end +end + +XServerManager.Id = nil +XServerManager.ServerName = nil + +function XServerManager.GetLoginUrl() + local server = ServerList[XServerManager.Id] + if not server then + return nil + end + + if XMain.IsDebug then + server.LastTime = GetTime() + LastServerConnectTime[server.Name] = server.LastTime + XSaveTool.SaveData(SERVER_CONNECT_TIME_KEY, LastServerConnectTime) + end + + return server.LoginUrl +end + +function XServerManager.Init(cb) + XServerManager.Id = CS.UnityEngine.PlayerPrefs.GetInt(XPrefs.ServerId, 1) + + ServerList = {} + local i = 1 + local strs = string.Split(CS.XRemoteConfig.ServerListStr, "|") + for _, value in ipairs(strs) do + local item = string.Split(value, "#") + if #item >= 2 then + local server = {} + server.Id = i + server.Name = item[1] + server.LoginUrl = item[2] + + ServerList[server.Id] = server + i = i + 1 + end + end + + if not ServerList or #ServerList <= 0 then + XLog.Error("Get ServerList error. content = " .. CS.XRemoteConfig.ServerListStr) + return + end + + local androidCallbackListStr = CS.XRemoteConfig.AndroidPayCallbackList + local iosCallbackListStr = CS.XRemoteConfig.IosPayCallbackList + XServerManager.SplitPayCallList(AndroidPayCallList, androidCallbackListStr) + XServerManager.SplitPayCallList(IosPayCallList, iosCallbackListStr) + + if XServerManager.Id and ServerList[XServerManager.Id] then + XServerManager.Select(ServerList[XServerManager.Id]) + else + XServerManager.Select(ServerList[1]) + end + + XServerManager.UpdateSortedServer() + + if cb then + cb() + end +end + +function XServerManager.UpdateSortedServer() + if XMain.IsDebug then + SortedList = {} + LastServerConnectTime = XSaveTool.GetData(SERVER_CONNECT_TIME_KEY) or {} + for _, v in pairs(ServerList) do + v.LastTime = LastServerConnectTime[v.Name] or 0 + table.insert(SortedList, v) + end + end +end + +function XServerManager.InsertTempServer(ip) + if not XMain.IsDebug then + return false, "该功能仅Debug模式下可使用!" + end + + if not string.IsIp(ip) then + return false, "请输入合法Ip地址!" + end + + if TempServerDic[ip] then + return false, "该临时服已存在" + end + + local tempServer = { + Id = #ServerList + 1, + Name = "临时服: " .. ip, + LastTime = 0, + LoginUrl = string.format("http://%s:2333/api/Login/Login", ip), + IsTempServer = true, + } + + table.insert(ServerList, tempServer) + TempServerDic[ip] = true + XServerManager.UpdateSortedServer() + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_SERVER_LIST_CHANGE) + return true +end + +function XServerManager.Select(server) + if not server then + XLog.Error("Selected Server is nil.") + return + end + + XServerManager.Id = server.Id + XServerManager.ServerName = server.Name + CS.UnityEngine.PlayerPrefs.SetInt(XPrefs.ServerId, server.Id) + if XUserManager.UserId then -- 海外修改 + XSaveTool.SaveData(XPrefs.User_ServerId..XUserManager.UserId, tostring(server.Id)) + end + + if Platform == RuntimePlatform.Android then + if server.Id > #AndroidPayCallList then + XLog.Error("支付服务器地址数量与服务器数量不匹配") + return + end + XHgSdkManager.SetCallBackUrl(AndroidPayCallList[server.Id]) + elseif true or Platform == RuntimePlatform.IPhonePlayer then + if server.Id > #IosPayCallList then + XLog.Error("支付服务器地址数量与服务器数量不匹配") + return + end + XHgSdkManager.SetCallBackUrl(IosPayCallList[server.Id]) + else + XLog.Debug("其他平台无需设置支付回调地址") + end +end + +function XServerManager.CheckOpenSelect() + return ServerList and #ServerList > 1 +end + +function XServerManager.GetServerList(needSort) + if not XMain.IsDebug or not needSort then + return ServerList + end + + table.sort(SortedList, function(a, b) + if a.IsTempServer ~= b.IsTempServer then + return a.IsTempServer + end + + if GetTime() - a.LastTime < RECENT_TIME_PERIOD + or GetTime() - b.LastTime < RECENT_TIME_PERIOD then + return a.LastTime > b.LastTime + else + return a.Id < b.Id + end + end) + + return SortedList +end + +function XServerManager.GetCurServerName() + return XServerManager.ServerName +end + +function XServerManager.TestConnectivity(server, gridCb) + if not server or not gridCb then return end + local id = server.Id + if LastServerCheckTime[id] + and LastServerCheckTime[id] + LoginTimeOutSecond > GetTime() then + gridCb() + return + end + + ServerList[id].State = XServerManager.SERVER_STATE.CHECK + LastServerCheckTime[id] = GetTime() + gridCb() + + local loginUrl = server.LoginUrl + if not XUserManager.IsNeedLogin() then + loginUrl = server.LoginUrl .. + "?loginType=" .. XUserManager.Channel .. + "&userId=" .. XUserManager.UserId .. + "&projectId=" .. CS.XHgSdkAgent.GetAppProjectId() .. + "&token=" .. (XUserManager.Token or "") + end + + local request = CS.UnityEngine.Networking.UnityWebRequest.Get(loginUrl) + request.timeout = LoginTimeOutSecond + CS.XTool.WaitNativeCoroutine(request:SendWebRequest(), function() + LastServerCheckTime[id] = GetTime() + if request.isNetworkError or request.isHttpError then + ServerList[id].State = XServerManager.SERVER_STATE.FAIL + gridCb() + return + end + + local result = Json.decode(request.downloadHandler.text) + if result.code == 1 -- 服务器暂未开放 + or result.code == 8 -- 服务器未开放 + or result.code == 9 -- 服务器已满员 + or result.code == 10 then + -- 服务器内部错误 + ServerList[id].State = XServerManager.SERVER_STATE.MAINTAIN + gridCb() + return + end + ServerList[id].State = XServerManager.SERVER_STATE.LOW + gridCb() + end) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XSetManager.lua b/Resources/Scripts/XManager/XSetManager.lua new file mode 100644 index 00000000..0d355201 --- /dev/null +++ b/Resources/Scripts/XManager/XSetManager.lua @@ -0,0 +1,209 @@ +XSetManagerCreator = function() + local XSetManager = {} + local SelfNumDefaultSize + local MaxScreenOff + local GlobalIllumination + local SceneType + XSetManager.DynamicJoystick = CS.UnityEngine.PlayerPrefs.GetInt(XPrefs.DynamicJoystick, XSetConfigs.DefaultDynamicJoystick) + XSetManager.FocusType = CS.UnityEngine.PlayerPrefs.GetInt(XPrefs.FocusType, XSetConfigs.DefaultFocusType) + XSetManager.FocusButton = CS.UnityEngine.PlayerPrefs.GetInt(XPrefs.FocusButton, XSetConfigs.DefaultFocusButton) + XSetManager.InviteButton = CS.UnityEngine.PlayerPrefs.GetInt(XPrefs.InviteButton, XSetConfigs.DefaultInviteButton) + XSetManager.WeaponTransType = CS.UnityEngine.PlayerPrefs.GetInt(XPrefs.WeaponTransType, XSetConfigs.DefaultWeaponTransType) + XSetManager.RechargeType = CS.UnityEngine.PlayerPrefs.GetInt(XPrefs.RechargeType, XSetConfigs.DefaultRechargeType) + + function XSetManager.Init() + GlobalIllumination = CS.XGlobalIllumination + SceneType = CS.XSceneType + SelfNumDefaultSize = CS.XGame.ClientConfig:GetInt("SelfNumDefault") or 0 + MaxScreenOff = CS.XGame.ClientConfig:GetFloat("SpecialScreenOff") or 0 + XSetManager.SetDynamicJoystick(XSetManager.DynamicJoystick) + XSetManager.SetFocusType(XSetManager.FocusType) + XSetManager.SetFocusButtonActive(XSetManager.FocusButton == 1) + XSetManager.SetInviteButtonActive(XSetManager.InviteButton == 1) + XSetManager.SetWeaponTransType(XSetManager.WeaponTransType) + XSetManager.SetRechargeType(XSetManager.RechargeType) + XEventManager.AddEventListener(XEventId.EVNET_FAIL_PAY, XSetManager.SetSceneUIType) + end + + function XSetManager.SetDynamicJoystick(value) + CS.XRLFightSettings.SetDynamicJoystick(value == 1) + XSetManager.DynamicJoystick = value + end + + function XSetManager.SetFocusType(type) + if type == 0 then + return + end + XSetManager.FocusType = type + CS.XRLFightSettings.SetFocusType(type) + CS.UnityEngine.PlayerPrefs.SetInt(XPrefs.FocusType, type) + CS.UnityEngine.PlayerPrefs.Save() + end + + function XSetManager.SetFocusButtonActive(value) + CS.XRLFightSettings.SetFocusButtonActive(value) + XSetManager.FocusButton = value and 1 or 0 + CS.UnityEngine.PlayerPrefs.SetInt(XPrefs.FocusButton, XSetManager.FocusButton) + CS.UnityEngine.PlayerPrefs.Save() + end + + function XSetManager.SetInviteButtonActive(value) + XSetManager.InviteButton = value and 1 or 0 + CS.UnityEngine.PlayerPrefs.SetInt(XPrefs.InviteButton, XSetManager.InviteButton) + CS.UnityEngine.PlayerPrefs.Save() + + if not value and XLuaUiManager.IsUiShow("UiArenaOnlineInvitation") then + XDataCenter.ArenaOnlineManager.ClearPrivateChatData() + XLuaUiManager.Close("UiArenaOnlineInvitation") + end + end + + function XSetManager.SetWeaponTransType(type) + if type == 0 then + return + end + XSetManager.WeaponTransType = type + CS.UnityEngine.PlayerPrefs.SetInt(XPrefs.WeaponTransType, type) + CS.UnityEngine.PlayerPrefs.Save() + end + + function XSetManager.SetRechargeType(type) + if type == 0 then + return + end + XSetManager.RechargeType = type + CS.UnityEngine.PlayerPrefs.SetInt(XPrefs.RechargeType, type) + CS.UnityEngine.PlayerPrefs.Save() + end + + function XSetManager.SetOwnFontSize(size) + CS.XRLFightSettings.SetOwnFontSize(size) + end + + function XSetManager.SetAllyDamage(value) + CS.XRLFightSettings.SetAllyDamage(value) + end + + function XSetManager.SetAllyEffect(value) + CS.XRLFightSettings.SetAllyEffect(value) + end + + function XSetManager.SetDefaultFontSize() + local size = SelfNumDefaultSize + CS.XRLFightSettings.SetDefaultFontSize(size) + end + + function XSetManager.SetOwnFontSizeByKey(key) + local size = XSetConfigs.SelfNumSizes[key] or 0 + XSetManager.SetOwnFontSize(size) + end + + function XSetManager.SetOwnFontSizeByCache() + local tab = XSetManager.GetOwnFontSizeByCache() + XSetManager.SetOwnFontSizeByTab(tab) + end + + function XSetManager.GetOwnFontSizeByCache() + local tab = XSaveTool.GetData(XSetConfigs.SelfNum) + if tab == nil or tab == "" then + tab = XSetConfigs.SelfNumEnum.Middle + end + return tab + end + + function XSetManager.SetAllyDamageByCache() + local v = XSetManager.GetAllyDamageByCache() + XSetManager.SetAllyDamage(v == XSetConfigs.FriendNumEnum.Open) + end + + function XSetManager.GetAllyDamageByCache() + local v = XSaveTool.GetData(XSetConfigs.FriendNum) + if v == nil or v == "" then + v = XSetConfigs.FriendNumEnum.Close + end + + return v + end + + function XSetManager.SetAllyEffectByCache() + local v = XSetManager.GetAllyEffectByCache() + XSetManager.SetAllyEffect(v == XSetConfigs.FriendEffectEnum.Open) + end + + function XSetManager.GetAllyEffectByCache() + local v = XSaveTool.GetData(XSetConfigs.FriendEffect) + if v == nil or v == "" then + v = XSetConfigs.FriendEffectEnum.Open + end + + return v + end + + function XSetManager.SetOwnFontSizeByTab(tab) + local k = XSetConfigs.SelfNumKeyIndexConfig[tab] + if k == 0 then + XSetManager.SetOwnFontSize(0) + else + XSetManager.SetOwnFontSizeByKey(k) + end + end + + function XSetManager.SetCurSeleButton(tab) + XSetManager.CurSeleBtn = tab + end + + function XSetManager.GetCurSeleButton() + return XSetManager.CurSeleBtn or 0 + end + + function XSetManager.SaveSelfNum(value) + XSaveTool.SaveData(XSetConfigs.SelfNum, value) + end + + function XSetManager.SaveFriendNum(value) + XSaveTool.SaveData(XSetConfigs.FriendNum, value) + end + + function XSetManager.SaveFriendEffect(value) + XSaveTool.SaveData(XSetConfigs.FriendEffect, value) + end + + function XSetManager.SaveScreenOff(value) + XSaveTool.SaveData(XSetConfigs.ScreenOff, value) + end + + function XSetManager.GetScreenOff() + return XSaveTool.GetData(XSetConfigs.ScreenOff) or 0 + end + + function XSetManager.SetScreenOff() + local d = XSetManager.GetScreenOff() + CS.XUiSafeAreaAdapter.SetSpecialScreenOff(d * MaxScreenOff) + end + + function XSetManager.SetUiResolutionEventFlag(flag) + CS.XUiSafeAreaAdapter.SetUiResolutionEventFlag(flag) + end + + function XSetManager.SetSceneUIType() + -- if GlobalIllumination.SceneType ~= SceneType.Ui then + XSetManager.SetUiResolutionEventFlag(true) + GlobalIllumination.SetSceneType(SceneType.Ui, true) + -- end + end + + function XSetManager.IsAdaptorScreen() + if XSetManager.IsChange then + XSetManager.IsChange = false + return true + end + return false + end + + function XSetManager.SetAdaptorScreenChange() + XSetManager.IsChange = true + end + + XSetManager.Init() + return XSetManager +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XShopManager.lua b/Resources/Scripts/XManager/XShopManager.lua new file mode 100644 index 00000000..ae7ffb62 --- /dev/null +++ b/Resources/Scripts/XManager/XShopManager.lua @@ -0,0 +1,827 @@ +local pairs = pairs +local table = table +local tableInsert = table.insert +local tableSort = table.sort +local MinCount = 0 +local MaxCount = 999 +XShopManager = XShopManager or {} + +local CSUnityEnginePlayerPrefs = CS.UnityEngine.PlayerPrefs + +local SYNC_SHOP_SECOND = 5 + +-- local ShopBaseInfosTemplates = {} -- Tap显示信息(普通+活动) +local LastSyncShopTimes = {} -- 商店刷新时间 +local ActivityLastSyncShopTime = {} -- 活动商店刷新时间 + +-- local LastSyncBaseInfoTime = 0 -- 商店基础信息同步时间 +local ShopBaseInfoDict = {} -- 商店基础信息 +local ShopDict = {} -- 商店详细信息 +local ShopGroup = {} + +local ScreenGoodsList = {} +local ScreenTagList = {} + +local ScreenAll = CS.XTextManager.GetText("ScreenAll") +local ScreenOther = CS.XTextManager.GetText("ScreenOther") + +local COOKIE_DAILYSHOPNEWSUIT_KEY = "DailyShopNewSuit" + +local METHOD_NAME = { + GetShopInfoList = "GetFixedShopListRequest", + GetShopInfo = "GetShopInfoRequest", + RefreshShop = "RefreshShopRequest", + GetShopBaseInfo = "GetShopBaseInfoRequest", + Buy = "BuyRequest", +} + +XShopManager.ShopType = { + Common = 1, -- 普通商店 + Activity = 2, -- 活动商店 + Dorm = 101, + Boss = 102, + Arena = 103, + Guild = 301, + FubenDaily = 401, + WorldBoss = 501, --世界Boss +} + +XShopManager.ShopTags = { + Not = 0, --无 + HotSale = 1, --热销 + Recommend = 2, --推荐 + TimeLimit = 3, --限时 + DisCount = 4, --打折 + New = 5, --上新 +} + +XShopManager.SecondTagType = { + Top = 0, --顶部 + Mid = 1, --中间 + Btm = 2, --底部 + All = 3, --唯一 +} + +XShopManager.ScreenType = { + SuitPos = 1, --意识位置 + SuitName = 2, --意识套装 + WeaponType = 3, --武器种类 + FashionType = 4, --涂装所属 + ItemType = 5, --道具种类 + AwakeItemType = 6, --超频道具种类 + ActivitySuitName = 8, --活动套装商店 +} + +--活动商店 +XShopManager.ActivityShopType = { + BriefShop = 1, --活动界面商店 + NieRShop = 2, --尼尔活动商店 + MoeWarShop = 3, --萌战活动商店 +} + +function XShopManager.ClearBaseInfoData() + ShopBaseInfoDict = {} +end + +function XShopManager.GetShopBaseInfoByType(type) + local list = {} + for _, info in pairs(ShopBaseInfoDict) do + if info.Type == type then + tableInsert(list, info) + end + end + + tableSort(list, function(a, b) + if a.SecondType == b.SecondType then + return a.Priority > b.Priority + else + return a.SecondType < b.SecondType + end + end) + + return list +end + +function XShopManager.GetShopBaseInfoByTypeAndTag(type) + local tmp = {} + local list = {} + local tagList = {} + local shopGroup = XShopManager.GetShopGroup() + + for _, info in pairs(ShopBaseInfoDict) do + if info.Type == type then + tableInsert(tmp, info) + end + end + + tableSort(tmp, function(a, b) + if a.SecondType == b.SecondType then + return a.Priority > b.Priority + else + return a.SecondType < b.SecondType + end + end) + + for _, v in pairs(tmp) do + local tagData = {} + if v.SecondType > 0 then + if shopGroup[v.SecondType] then + if not tagList[v.SecondType] then + for i, d in pairs(v) do + tagData[i] = d + end + tagData.Id = 0 + tagData.SecondType = 0 + tagData.Name = shopGroup[v.SecondType].TagName + tagData.IsHasSnd = true + tableInsert(list, tagData) + tagList[v.SecondType] = v.SecondType + end + else + v.SecondType = 0 + v.IsHasSnd = false + end + else + v.IsHasSnd = false + end + tableInsert(list, v) + end + + for k, v in pairs(list) do + if v.SecondType > 0 then + if list[k - 1].SecondType == 0 then + v.SecondTagType = XShopManager.SecondTagType.Top + else + v.SecondTagType = XShopManager.SecondTagType.Mid + end + + if list[k + 1] then + if list[k + 1].SecondType == 0 then + if v.SecondTagType == XShopManager.SecondTagType.Mid then + v.SecondTagType = XShopManager.SecondTagType.Btm + else + v.SecondTagType = XShopManager.SecondTagType.All + end + end + else + if v.SecondTagType == XShopManager.SecondTagType.Mid then + v.SecondTagType = XShopManager.SecondTagType.Btm + else + v.SecondTagType = XShopManager.SecondTagType.All + end + end + end + end + + + return list +end + +function XShopManager.GetShopType(shopId) + local info = ShopBaseInfoDict[shopId] + if not info then + XLog.Error("XShopManager.GetShopType error: can not found info, id is " .. shopId) + return + end + + return info.Type +end + +function XShopManager.GetShopShowIdList(shopId) + local info = ShopDict[shopId] + if not info then + XLog.Error("XShopManager.GetShopShowIdList error: can not found info, id is " .. shopId) + return + end + + local list = {} + if info.ShowIds and #info.ShowIds > 0 then + list = info.ShowIds + end + + return list +end + +function XShopManager.GetShopName(shopId) + local info = ShopDict[shopId] + if not info then + XLog.Error("XShopManager.GetShopName error: can not found info, id is " .. shopId) + return + end + return info.Name +end + +function XShopManager.GetShopConditionIdList(shopId) + local info = ShopDict[shopId] + if not info then + XLog.Error("XShopManager.GetShopConditionIdList error: can not found info, id is " .. shopId) + return + end + + local list = {} + if info.ConditionIds and #info.ConditionIds > 0 then + list = info.ConditionIds + end + + return list +end + +function XShopManager.GetShopScreenGroupIDList(shopId) + local info = ShopDict[shopId] + if not info then + XLog.Error("XShopManager.GetShopScreenGroupIDList error: can not found info, id is " .. shopId) + return + end + + local list = {} + if info.ScreenGroupList and #info.ScreenGroupList > 0 and info.ScreenGroupList[1] ~= 0 then + list = info.ScreenGroupList + end + + return list +end + +function XShopManager.GetManualRefreshCost(shopId) + local shop = ShopDict[shopId] + if not shop then + XLog.Error("XShopManager.GetManualRefreshCost error: can not found shop, id is " .. shopId) + return + end + + local costInfo = {} + if shop.RefreshCostId and shop.RefreshCostId > 0 then + costInfo.RefreshCostId = shop.RefreshCostId + costInfo.RefreshCostCount = shop.RefreshCostCount + end + + if shop.ManualResetTimesLimit and shop.ManualResetTimesLimit ~= 0 then + costInfo.ManualRefreshTimes = shop.ManualRefreshTimes + costInfo.ManualResetTimesLimit = shop.ManualResetTimesLimit + end + + return costInfo +end + +function XShopManager.GetShopBuyInfo(shopId) + local shop = ShopDict[shopId] + if not shop then + XLog.Error("XShopManager.GetShopBuyInfo error: can not found shop, id is " .. shopId) + return + end + + return { + TotalBuyTimes = shop.TotalBuyTimes, + BuyTimesLimit = shop.BuyTimesLimit + } +end + +function XShopManager.GetShopLeftBuyTimes(shopId) + local shop = ShopDict[shopId] + if not shop then + XLog.Error("XShopManager.GetShopBuyInfo error: can not found shop, id is " .. shopId) + return + end + + local buyTimesLimit = shop.BuyTimesLimit + if not buyTimesLimit or buyTimesLimit <= 0 then + return + end + + local totalBuyTimes = shop.TotalBuyTimes and shop.TotalBuyTimes or 0 + + return buyTimesLimit - totalBuyTimes +end + +function XShopManager.GetShopTimeInfo(shopId) + local shop = ShopDict[shopId] + if not shop then + XLog.Error("XShopManager.GetShopTimeInfo error: can not found shop, id is " .. shopId) + return + end + + local info = {} + local now = XTime.GetServerNowTimestamp() + + if shop.RefreshTime and shop.RefreshTime > 0 then + info.RefreshLeftTime = shop.RefreshTime > now and shop.RefreshTime - now or 0 + end + + if shop.ClosedTime and shop.ClosedTime > 0 then + info.ClosedLeftTime = shop.ClosedTime > now and shop.ClosedTime - now or 0 + end + + return info +end + +function XShopManager.GetLeftTime(endTime) + return endTime > 0 and endTime - XTime.GetServerNowTimestamp() or endTime +end + +function XShopManager.IsShopExist(shopId) + return ShopBaseInfoDict[shopId] ~= nil +end + +function XShopManager.GetShopGoodsList(shopId) + local shop = ShopDict[shopId] + if not shop then + XLog.Error("XShopManager.GetShopGoodsList error: can not found shop, id is " .. shopId) + return {} + end + + local list = {} + for _, goods in pairs(shop.GoodsList) do + local IsLock = false + for _, v in pairs(goods.ConditionIds) do + local ret = XConditionManager.CheckCondition(v) + if not ret then + IsLock = true + break + end + end + + if not (IsLock and goods.IsHideWhenConditionLimit) then + tableInsert(list, goods) + end + end + + --排序优先级 + tableSort(list, function(a, b) + -- 是否卖光 + if a.BuyTimesLimit > 0 or b.BuyTimesLimit > 0 then + -- 如果商品有次数限制,并且达到次数限制,则判断为售罄 + local isSellOutA = a.BuyTimesLimit == a.TotalBuyTimes and a.BuyTimesLimit > 0 + local isSellOutB = b.BuyTimesLimit == b.TotalBuyTimes and b.BuyTimesLimit > 0 + if isSellOutA ~= isSellOutB then + return isSellOutB + end + end + + --是否条件受限 + local IsLockA = false + local IsLockB = false + for _, v in pairs(a.ConditionIds) do + local ret = XConditionManager.CheckCondition(v) + if not ret then + IsLockA = true + break + end + end + for _, v in pairs(b.ConditionIds) do + local ret = XConditionManager.CheckCondition(v) + if not ret then + IsLockB = true + break + end + end + if IsLockA ~= IsLockB then + return IsLockB + end + + -- 是否限时 + if a.SelloutTime ~= b.SelloutTime then + if a.SelloutTime > 0 and b.SelloutTime > 0 then + return a.SelloutTime < b.SelloutTime + elseif a.SelloutTime > 0 and b.SelloutTime <= 0 then + return XShopManager.GetLeftTime(a.SelloutTime) > 0 + elseif a.SelloutTime <= 0 and b.SelloutTime > 0 then + return XShopManager.GetLeftTime(b.SelloutTime) < 0 + end + end + + if a.Tags ~= b.Tags and a.Tags ~= 0 and b.Tags ~= 0 then + return a.Tags < b.Tags + end + + if a.Priority ~= b.Priority then + return a.Priority > b.Priority + end + end) + return list +end + +function XShopManager.GetDefaultShopId() + local list = XShopManager.GetShopBaseInfoByTypeAndTag(XShopManager.ShopType.Common) + return list[1].Id +end + +local function AddBuyTimes(shopId, goodsId, count) + local shop = ShopDict[shopId] + if not shop then + XLog.Error("XShopManager AddBuyTimes Error: can not found shop, shopId is " .. shopId) + return + end + + shop.TotalBuyTimes = shop.TotalBuyTimes + count + + for _, goods in pairs(shop.GoodsList) do + if goods.Id == goodsId then + goods.TotalBuyTimes = goods.TotalBuyTimes + count + break + end + end +end + +function XShopManager.AddBuyTime(shopId, goodsId, count) + AddBuyTimes(shopId, goodsId, count) + --触发界面消息 + XEventManager.DispatchEvent(XEventId.EVENT_SHOP_BUYUSERIYUAN, shopId) +end + +local function SetShop(shop) + ShopDict[shop.Id] = shop + LastSyncShopTimes[shop.Id] = XTime.GetServerNowTimestamp() +end + +local function SetShopBaseInfoList(shopBaseInfoList) + -- LastSyncBaseInfoTime = XTime.GetServerNowTimestamp() + for _, info in pairs(shopBaseInfoList) do + ShopBaseInfoDict[info.Id] = info + end +end + +function XShopManager.GetShopInfo(shopId, cb, pleaseDoNotTip) + local now = XTime.GetServerNowTimestamp() + local syscTime = LastSyncShopTimes[shopId] + + if syscTime and now - syscTime < SYNC_SHOP_SECOND then + if cb then + cb() + return + end + end + + XNetwork.Call(METHOD_NAME.GetShopInfo, { Id = shopId }, function(res) + if res.Code ~= XCode.Success then + if not pleaseDoNotTip then + XUiManager.TipCode(res.Code) + end + return + end + SetShop(res.ClientShop) + XShopManager.SetScreenData(res.ClientShop.Id) + if cb then cb() end + end) +end + +function XShopManager.GetShopInfoList(shopIdList, cb, shopType) + shopType = shopType or XShopManager.ActivityShopType.BriefShop + local now = XTime.GetServerNowTimestamp() + local syscTime = ActivityLastSyncShopTime[shopType] or 0 + if syscTime and now - syscTime < SYNC_SHOP_SECOND then + if cb then + cb() + return + end + end + XNetwork.Call(METHOD_NAME.GetShopInfoList, { IdList = shopIdList }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + ActivityLastSyncShopTime[shopType] = XTime.GetServerNowTimestamp() + for _, v in pairs(res.ClientShopList) do + SetShop(v) + XShopManager.SetScreenData(v.Id) + end + if cb then cb() end + end) +end + +local function CheckResfreshShopLimit(shopId) + local shop = ShopDict[shopId] + if not shop then + XUiManager.TipCode(XCode.ShopManagerShopNotExist) + return false + end + + if shop.BuyTimesLimit and shop.BuyTimesLimit > 0 then + if shop.TotalBuyTimes >= shop.BuyTimesLimit then + XUiManager.TipCode(XCode.ShopManagerShopNotBuyTimes) + return false + end + end + + if shop.ManualResetTimesLimit and shop.ManualResetTimesLimit >= 0 then + if shop.ManualRefreshTimes >= shop.ManualResetTimesLimit then + XUiManager.TipError(CS.XTextManager.GetText("DifferentRefreshTimes")) + return false + end + end + + if shop.RefreshCostId and shop.RefreshCostId > 0 then + if shop.RefreshCostCount > XDataCenter.ItemManager.GetItem(shop.RefreshCostId):GetCount() then + XUiManager.TipError(CS.XTextManager.GetText("RefreshShopItemNotEnough")) + return false + end + end + return true +end + +function XShopManager.RefreshShopGoods(shopId, cb) + if not CheckResfreshShopLimit(shopId) then + return + end + + XNetwork.Call(METHOD_NAME.RefreshShop, { Id = shopId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + SetShop(res.ClientShop) + if cb then cb() end + end) +end + +function XShopManager.GetBaseInfo(cb) + XNetwork.Call(METHOD_NAME.GetShopBaseInfo, nil, function(res) + SetShopBaseInfoList(res.ShopBaseInfoList) + if cb then cb() end + end) +end + +function XShopManager.BuyShop(shopId, goodsId, count, cb, err_cb) + local req = { ShopId = shopId, GoodsId = goodsId, Count = count } + XNetwork.Call(METHOD_NAME.Buy, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + if err_cb then + err_cb() + end + return + end + AddBuyTimes(shopId, goodsId, count) + cb() + end) +end + +function XShopManager.GetShopGroup() + ShopGroup = XShopConfigs.GetShopGroupTemplate() + return ShopGroup +end + +function XShopManager.GetShopTypeDatas() + local typeData = XShopConfigs.GetShopTypeNameTemplate() + return typeData +end + +function XShopManager.GetShopTypeDataById(id) + local typeData = XShopConfigs.GetShopTypeNameTemplate() + return typeData[id] +end + +function XShopManager.GetShopScreenGroupDataById(id) + local screenData = XShopConfigs.GetShopScreenGroupTemplate() + return screenData[id] +end + +function XShopManager.GetShopScreenGroupNameById(id) + local screenData = XShopConfigs.GetShopScreenGroupTemplate() + if not screenData[id] then + return "" + end + return screenData[id].GroupName +end + +function XShopManager.GetShopScreenGroupIconById(id) + local screenData = XShopConfigs.GetShopScreenGroupTemplate() + if (not id) or (not screenData[id]) then + return nil + end + return screenData[id].GroupIcon +end + +function XShopManager.GetScreenGoodsListByTag(shopId, group, tag) + local goodsList = ScreenGoodsList[shopId][group] + if not goodsList then + return XShopManager.GetShopGoodsList(shopId) + end + if not goodsList[tag] then + return XShopManager.GetShopGoodsList(shopId) + end + return goodsList[tag] +end + +function XShopManager.GetScreenTagListById(shopId, groupId) + return ScreenTagList[shopId][groupId] +end + +function XShopManager.SetScreenData(id) + local GoodsList = XShopManager.GetShopGoodsList(id) + local ScreenGroupIDList = XShopManager.GetShopScreenGroupIDList(id) + ScreenGoodsList[id] = {} + ScreenTagList[id] = {} + + if ScreenGroupIDList then + for _, screenGroupId in pairs(ScreenGroupIDList) do + local screenGroup = ScreenGoodsList[id][screenGroupId] + if not screenGroup then ScreenGoodsList[id][screenGroupId] = {} end + + local tagGroup = ScreenTagList[id][screenGroupId] + if not tagGroup then ScreenTagList[id][screenGroupId] = {} end + + for _, goods in pairs(GoodsList or {}) do + if screenGroupId == XShopManager.ScreenType.SuitPos then + XShopManager.DoScreen(id, XArrangeConfigs.Types.Wafer, + screenGroupId, + goods, + function() + return { XDataCenter.EquipManager.GetEquipSiteByTemplateId(goods.RewardGoods.TemplateId) } + end + ) + elseif screenGroupId == XShopManager.ScreenType.SuitName + or screenGroupId == XShopManager.ScreenType.ActivitySuitName then + XShopManager.DoScreen(id, XArrangeConfigs.Types.Wafer, + screenGroupId, + goods, + function() + return { XDataCenter.EquipManager.GetSuitIdByTemplateId(goods.RewardGoods.TemplateId) } + end + ) + elseif screenGroupId == XShopManager.ScreenType.WeaponType then + XShopManager.DoScreen(id, XArrangeConfigs.Types.Weapon, + screenGroupId, + goods, + function() + return { XDataCenter.EquipManager.GetEquipTypeByTemplateId(goods.RewardGoods.TemplateId) } + end + ) + elseif screenGroupId == XShopManager.ScreenType.FashionType then + XShopManager.DoScreen(id, XArrangeConfigs.Types.Fashion, + screenGroupId, + goods, + function() + return { XDataCenter.FashionManager.GetCharacterId(goods.RewardGoods.TemplateId) } + end + ) + elseif screenGroupId == XShopManager.ScreenType.ItemType then + XShopManager.DoScreen(id, XArrangeConfigs.Types.Item, + screenGroupId, + goods, + function() + return { XDataCenter.ItemManager.GetItemType(goods.RewardGoods.TemplateId) } + end + ) + elseif screenGroupId == XShopManager.ScreenType.AwakeItemType then + XShopManager.DoScreen(id, XArrangeConfigs.Types.Item, + screenGroupId, + goods, + function() + return XDataCenter.EquipManager.GetAwakeItemApplicationScope(goods.RewardGoods.TemplateId) + end + ) + end + end + end + end + + if ScreenTagList[id] then + for index, screenTag in pairs(ScreenTagList[id]) do + local list = {} + for _, v in pairs(screenTag) do + table.insert(list, v) + end + tableSort(list, function(a, b) + return a.Key < b.Key + end) + ScreenTagList[id][index] = list + end + end +end + +function XShopManager.DoScreen(id, goodstype, screenGroupId, goods, getkeyList) + local tmpScreenData = XShopManager.GetShopScreenGroupDataById(screenGroupId) + local screenGroup = ScreenGoodsList[id][screenGroupId] + local tagGroup = ScreenTagList[id][screenGroupId] + if XArrangeConfigs.GetType(goods.RewardGoods.TemplateId) == goodstype then + local IsIn = false + local keyList = getkeyList() + if keyList and tmpScreenData and tmpScreenData.ScreenID then + for _, key in pairs(keyList) do + for index, screenID in pairs(tmpScreenData.ScreenID) do + if key ~= screenID then + goto continue + end + + local screenName = tmpScreenData.ScreenName[index] + local goodsList = screenGroup[screenName] + if not goodsList then + goodsList = {} + screenGroup[screenName] = goodsList + end + table.insert(goodsList, goods) + + local tag = tagGroup[screenName] + if not tag then + tag = {} + tag.Text = screenName + tag.Key = index + tagGroup[screenName] = tag + end + + IsIn = true + break + + :: continue :: + end + end + end + + if not IsIn then + local otherGoodsList = screenGroup[ScreenOther] + if not otherGoodsList then + otherGoodsList = {} + screenGroup[ScreenOther] = otherGoodsList + end + table.insert(otherGoodsList, goods) + + local otherTag = tagGroup[ScreenOther] + if not otherTag then + otherTag = {} + otherTag.Text = ScreenOther + otherTag.Key = MaxCount + tagGroup[ScreenOther] = otherTag + end + end + else + local otherGoodsList = screenGroup[ScreenOther] + if not otherGoodsList then + otherGoodsList = {} + screenGroup[ScreenOther] = otherGoodsList + end + table.insert(otherGoodsList, goods) + + local otherTag = tagGroup[ScreenOther] + if not otherTag then + otherTag = {} + otherTag.Text = ScreenOther + otherTag.Key = MaxCount + tagGroup[ScreenOther] = otherTag + end + end + + local allGoodsList = screenGroup[ScreenAll] + if not allGoodsList then + allGoodsList = {} + screenGroup[ScreenAll] = allGoodsList + end + table.insert(allGoodsList, goods) + + local allTag = tagGroup[ScreenAll] + if not allTag then + allTag = {} + allTag.Text = ScreenAll + allTag.Key = MinCount + tagGroup[ScreenAll] = allTag + end +end + + +function XShopManager.CheckDailyShopSuitIsNew(suitId, suitShopItemList) + for _, v in ipairs(suitShopItemList) do + if v.Tags == XShopManager.ShopTags.New then + local key = COOKIE_DAILYSHOPNEWSUIT_KEY .. suitId + return not XShopManager.ReadCookie(key) + end + end + + return false +end + +function XShopManager.SetDailyShopSuitNotNew(suitId) + local key = COOKIE_DAILYSHOPNEWSUIT_KEY .. suitId + CSUnityEnginePlayerPrefs.SetInt(XShopManager.GetCookieKeyStr(key), 1) + CSUnityEnginePlayerPrefs.Save() +end + +function XShopManager.CheckDailyShopHasNewSuit(shopItemList) + if not shopItemList then + return false + end + + for _, data in ipairs(shopItemList) do + if data.Tags == XShopManager.ShopTags.New then + local suitId = XDataCenter.EquipManager.GetSuitIdByTemplateId(data.RewardGoods.TemplateId) + local key = COOKIE_DAILYSHOPNEWSUIT_KEY .. suitId + if not XShopManager.ReadCookie(key) then + return true + end + end + end + return false +end + +function XShopManager.GetCookieKeyStr(key) + local str = string.format("%s%s%s", "SHOP_COOKIE", XPlayer.Id, key) + return str +end + +function XShopManager.ReadCookie(key) + return CSUnityEnginePlayerPrefs.HasKey(XShopManager.GetCookieKeyStr(key)) +end + + +--商店使用日元购买完成之后服务端主动推 +XRpc.BuyResponse = function(data) + XShopManager.AddBuyTime(data.ShopId, data.GoodsId, data.Count) + XDataCenter.PayManager.ClearCurrentPayId(data.GoodsId) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XSignBoardManager.lua b/Resources/Scripts/XManager/XSignBoardManager.lua new file mode 100644 index 00000000..6454eb1f --- /dev/null +++ b/Resources/Scripts/XManager/XSignBoardManager.lua @@ -0,0 +1,597 @@ +local SignBoardCondition = { + --邮件 + [XSignBoardEventType.MAIL] = function() + return XDataCenter.MailManager.GetHasUnDealMail() > 0 + end, + + --任务 + [XSignBoardEventType.TASK] = function() + if XDataCenter.TaskManager.GetIsRewardForEx(XDataCenter.TaskManager.TaskType.Story) then + return true + end + + if XFunctionManager.JudgeOpen(XFunctionManager.FunctionName.TaskDay) and XDataCenter.TaskManager.GetIsRewardForEx(XDataCenter.TaskManager.TaskType.Daily) then + return true + end + + if XFunctionManager.JudgeOpen(XFunctionManager.FunctionName.TaskActivity) and XDataCenter.TaskManager.GetIsRewardForEx(XDataCenter.TaskManager.TaskType.Activity) then + return true + end + + return false + end, + + --日活跃 + [XSignBoardEventType.DAILY_REWARD] = function() + return XDataCenter.TaskManager.CheckHasDailyActiveTaskReward() + end, + + --登陆 + [XSignBoardEventType.LOGIN] = function(param) + local loginTime = XDataCenter.SignBoardManager.GetLoginTime() + local offset = XTime.GetServerNowTimestamp() - loginTime + + return offset <= param + end, + + --n天没登陆 + [XSignBoardEventType.COMEBACK] = function(param) + local lastLoginTime = XDataCenter.SignBoardManager.GetlastLoginTime() + local todayTime = XTime.GetTodayTime() + local offset = todayTime - lastLoginTime + local day = math.ceil(offset / 86400) + return day >= param + end, + + --收到礼物 + [XSignBoardEventType.RECEIVE_GIFT] = function() + return false + end, + + --赠送礼物 + [XSignBoardEventType.GIVE_GIFT] = function(param, displayCharacterId, eventParam) + if eventParam == nil then + return false + end + + return eventParam.CharacterId == displayCharacterId + end, + + --战斗胜利 + [XSignBoardEventType.WIN] = function() + local signBoardEvent = XDataCenter.SignBoardManager.GetSignBoardEvent() + if signBoardEvent[XSignBoardEventType.WIN] then + return true + end + end, + + --战斗胜利 + [XSignBoardEventType.WINBUT] = function() + local signBoardEvent = XDataCenter.SignBoardManager.GetSignBoardEvent() + if signBoardEvent[XSignBoardEventType.WINBUT] then + return true + end + end, + + --战斗失败 + [XSignBoardEventType.LOST] = function() + local signBoardEvent = XDataCenter.SignBoardManager.GetSignBoardEvent() + if signBoardEvent[XSignBoardEventType.LOST] then + return true + end + end, + + --战斗失败 + [XSignBoardEventType.LOSTBUT] = function() + local signBoardEvent = XDataCenter.SignBoardManager.GetSignBoardEvent() + if signBoardEvent[XSignBoardEventType.LOSTBUT] then + return true + end + end, + + --电量 + [XSignBoardEventType.LOW_POWER] = function(param) + return XDataCenter.ItemManager.GetCount(XDataCenter.ItemManager.ItemId.ActionPoint) <= param + end, + + + --游戏时间 + [XSignBoardEventType.PLAY_TIME] = function(param) + local loginTime = XDataCenter.SignBoardManager.GetLoginTime() + local offset = XTime.GetServerNowTimestamp() - loginTime + return offset >= param + end, + + + --长时间待机 + [XSignBoardEventType.IDLE] = function() + return true + end, + + --换人 + [XSignBoardEventType.CHANGE] = function(param, displayCharacterId) + return displayCharacterId == XDataCenter.SignBoardManager.ChangeDisplayId + end, + + --好感度提升 + [XSignBoardEventType.FAVOR_UP] = function() + return true + end, +} + +--看板互动 +XSignBoardManagerCreator = function() + local XSignBoardManager = {} + + XSignBoardManager.ChangeDisplayId = -1 + + XSignBoardManager.ShowType = { + Normal = 0, --可以重复播放 + PerLogin = 1, --每次登陆只会播放一次 + Daily = 2 --每日只能播放一次 + } + + local LoginTime = -1 --登录时间 + local LastLoginTime = -1 --上次登录时间 + -- local TodayFirstLoginTime = -1 --今天首次登陆时间 + + --记录需要做出反馈的事件 + local SignBoarEvents = {} + --播放器数据 + local PlayerData = nil + + --播放过的 + local PlayedList = {} + + --默认 0 普通待机,1 待机站立 + local StandType = 0 + + --这次登陆已经播放过的 + local PreLoginPlayedList = {} + + + --初始化 + function XSignBoardManager.Init() + + + -- --记录今天首次登陆时间 + -- local key = tostring(XPlayer.Id) .. "_TodayFirstLoginTime" + -- TodayFirstLoginTime = CS.UnityEngine.PlayerPrefs.GetInt(key, -1) + -- if TodayFirstLoginTime < XTime.GetTodayTime(5) then + -- CS.UnityEngine.PlayerPrefs.SetInt(key, TodayFirstLoginTime) + -- end + + + XEventManager.AddEventListener(XEventId.EVENT_LOGIN_SUCCESS, function() + local key = tostring(XPlayer.Id) .. "_LastLoginTime" + LastLoginTime = CS.UnityEngine.PlayerPrefs.GetInt(key, -1) + LoginTime = XTime.GetServerNowTimestamp() + if LastLoginTime == -1 then + LastLoginTime = LoginTime + end + CS.UnityEngine.PlayerPrefs.SetInt(key, LoginTime) + end) + end + + --获取登陆时间 + function XSignBoardManager.GetLoginTime() + return LoginTime + end + + --获取上次登陆时间 + function XSignBoardManager.GetlastLoginTime() + return LastLoginTime + end + + --获取事件 + function XSignBoardManager.GetSignBoardEvent() + return SignBoarEvents + end + + -- + function XSignBoardManager.GetSignBoardPlayerData() + if not PlayerData then + PlayerData = {} + PlayerData.PlayerList = {} --播放列表 + PlayerData.PlayingElement = nil --播放对象 + PlayerData.PlayedList = {} --播放过的列表 + PlayerData.LastPlayTime = -1 --上次播放时间 + end + + return PlayerData + end + + + --监听 + function XSignBoardManager.OnNotify(event, ...) + if event == XEventId.EVENT_FIGHT_RESULT then + local displayCharacterId = XDataCenter.DisplayManager.GetDisplayChar().Id + + local settle = ... + local info = settle[0] + local isExist = false + + local beginData = XDataCenter.FubenManager.GetFightBeginData() + if beginData then + for _, v in pairs(beginData.CharList) do + if v == displayCharacterId then + isExist = true + break + end + end + end + + if isExist and info.IsWin then + SignBoarEvents[XSignBoardEventType.WIN] = SignBoarEvents[XSignBoardEventType.WIN] or {} + SignBoarEvents[XSignBoardEventType.WIN].Time = XTime.GetServerNowTimestamp() + elseif not isExist and info.IsWin then + SignBoarEvents[XSignBoardEventType.WINBUT] = SignBoarEvents[XSignBoardEventType.WINBUT] or {} + SignBoarEvents[XSignBoardEventType.WINBUT].Time = XTime.GetServerNowTimestamp() + elseif isExist and not info.IsWin then + SignBoarEvents[XSignBoardEventType.LOST] = SignBoarEvents[XSignBoardEventType.LOST] or {} + SignBoarEvents[XSignBoardEventType.LOST].Time = XTime.GetServerNowTimestamp() + elseif not isExist and not info.IsWin then + SignBoarEvents[XSignBoardEventType.LOSTBUT] = SignBoarEvents[XSignBoardEventType.LOSTBUT] or {} + SignBoarEvents[XSignBoardEventType.LOSTBUT].Time = XTime.GetServerNowTimestamp() + end + + elseif event == XEventId.EVENT_FAVORABILITY_GIFT then + local characterId = ... + SignBoarEvents[XSignBoardEventType.GIVE_GIFT] = SignBoarEvents[XSignBoardEventType.GIVE_GIFT] or {} + SignBoarEvents[XSignBoardEventType.GIVE_GIFT].Time = XTime.GetServerNowTimestamp() + SignBoarEvents[XSignBoardEventType.GIVE_GIFT].CharacterId = characterId + + end + + + end + + --设置待机类型 + function XSignBoardManager.SetStandType(standType) + StandType = standType + end + + --获取互动的事件 + function XSignBoardManager.GetPlayElements(displayCharacterId) + local elements = XSignBoardConfigs.GetPassiveSignBoardConfig(displayCharacterId) + if not elements then + return + end + + elements = XSignBoardManager.FitterPlayElementByStandType(elements) + elements = XSignBoardManager.FitterPlayElementByShowTime(elements) + elements = XSignBoardManager.FitterPlayElementByFavorLimit(elements, displayCharacterId) + elements = XSignBoardManager.FitterCurLoginPlayed(elements) + elements = XSignBoardManager.FitterDailyPlayed(elements) + + local all = {} + + if not elements or #elements <= 0 then + return {} + end + + for _, tab in ipairs(elements) do + + local param = SignBoarEvents[tab.ConditionId] + + local condition = SignBoardCondition[tab.ConditionId] + + if condition and condition(tab.ConditionParam, displayCharacterId, param) then + local element = {} + element.Id = tab.Id --Id + element.AddTime = SignBoarEvents[tab.ConditionId] and SignBoarEvents[tab.ConditionId].Time or XTime.GetServerNowTimestamp() -- 添加事件 + element.StartTime = -1 --开始播放的时间 + element.EndTime = -1 --结束时间 + + -- 获取相应语言的动作持续时间 + local duration + local defaultCvType = CS.XGame.Config:GetInt("DefaultCvType") + local cvType = CS.UnityEngine.PlayerPrefs.GetInt("CV_TYPE", defaultCvType) + + if tab.Duration[cvType] == nil then + if tab.Duration[defaultCvType] == nil then + XLog.Error(string.format("XSignBoardPlayer:Play函数错误,配置表SignboardFeedback.tab没有配置Id:%s的Duration数据", tostring(element.Id))) + return {} + end + duration = tab.Duration[defaultCvType] + else + duration = tab.Duration[cvType] + end + + element.Duration = duration --播放持续时间 + element.Validity = tab.Validity --有效期 + element.CoolTime = tab.CoolTime --冷却时间 + element.Weight = tab.Weight --权重 + element.SignBoardConfig = tab + + table.insert(all, element) + end + end + + table.sort(all, function(a, b) + return a.Weight > b.Weight + end) + + XDataCenter.SignBoardManager.ChangeDisplayId = -1 + return all + end + + --获取打断的播放 + function XSignBoardManager.GetBreakPlayElements() + return XSignBoardConfigs.GetBreakPlayElements() + end + + --通过点击次数获取事件 + function XSignBoardManager.GetRandomPlayElementsByClick(clickTimes, displayCharacterId) + + local configs = XSignBoardConfigs.GetSignBoardConfigByFeedback(displayCharacterId, XSignBoardEventType.CLICK, clickTimes) + configs = XSignBoardManager.FitterPlayElementByStandType(configs) + configs = XSignBoardManager.FitterCurLoginPlayed(configs) + + configs = XSignBoardManager.FitterPlayElementByShowTime(configs) + configs = XSignBoardManager.FitterPlayElementByFavorLimit(configs, displayCharacterId) + configs = XSignBoardManager.FitterPlayed(configs) + + local element = XSignBoardManager.WeightRandomSelect(configs) + + if element then + PlayedList[element.Id] = element + end + + return element + end + + --通过摇晃获取事件 + function XSignBoardManager.GetRandomPlayElementsByRoll(time, displayCharacterId) + + local configs = XSignBoardConfigs.GetSignBoardConfigByFeedback(displayCharacterId, XSignBoardEventType.ROCK) + configs = XSignBoardManager.FitterPlayElementByStandType(configs) + configs = XSignBoardManager.FitterCurLoginPlayed(configs) + + configs = XSignBoardManager.FitterPlayElementByShowTime(configs) + configs = XSignBoardManager.FitterPlayElementByFavorLimit(configs, displayCharacterId) + configs = XSignBoardManager.FitterPlayed(configs) + + local element = XSignBoardManager.WeightRandomSelect(configs) + + if element then + PlayedList[element.Id] = element + end + + return element + end + + --过滤播放过的 + function XSignBoardManager.FitterPlayed(elements) + if not elements or #elements <= 0 then + return + end + + local configs = {} + for _, v in ipairs(elements) do + if not PlayedList[v.Id] then + table.insert(configs, v) + end + end + + if #configs <= 0 then + PlayedList = {} + return elements + end + + return configs + end + + function XSignBoardManager.FitterCurLoginPlayed(elements) + if not elements or #elements <= 0 then + return + end + + local configs = {} + for _, v in ipairs(elements) do + local key = XSignBoardManager.GetSignBoardKey(v) + if not PreLoginPlayedList[key] then + table.insert(configs, v) + end + end + + return configs + end + + ---==================================== + --- 过滤当天播放过的动作,返回当天未播放过的动作 + ---@param elements table + ---@return table + ---==================================== + function XSignBoardManager.FitterDailyPlayed(elements) + if not elements or #elements <= 0 then + return + end + + local configs = {} + local nowTimeStamp = XTime.GetServerNowTimestamp() + local nowTime = XTime.TimestampToLocalDateTimeString(nowTimeStamp, "yyyy-MM-dd") + local nowTimeTable = string.Split(nowTime, "-") + + for _, v in ipairs(elements) do + local key = XSignBoardManager.GetSignBoardKey(v) + + if CS.UnityEngine.PlayerPrefs.HasKey(key) then + local oldPlayedTime = CS.UnityEngine.PlayerPrefs.GetString(key) + local oldPlayedTimeTable = string.Split(oldPlayedTime, "-") + + if tonumber(oldPlayedTimeTable[1]) ~= tonumber(nowTimeTable[1]) + or tonumber(oldPlayedTimeTable[2]) ~= tonumber(nowTimeTable[2]) + or tonumber(oldPlayedTimeTable[3]) ~= tonumber(nowTimeTable[3]) then + -- 年或月或日不相等,不是同一天 + table.insert(configs, v) + end + + else + table.insert(configs, v) + end + end + + return configs + end + + --权重随机算法 + function XSignBoardManager.WeightRandomSelect(elements) + if not elements or #elements <= 0 then + return + end + + if #elements == 1 then + return elements[1] + end + + --获取权重总和 + local sum = 0 + for _, v in ipairs(elements) do + sum = sum + v.Weight + end + + --设置随机数种子 + math.randomseed(os.time()) + + --随机数加上权重,越大的权重,数值越大 + local weightList = {} + for i, v in ipairs(elements) do + local rand = math.random(0, sum) + local seed = {} + seed.Index = i + seed.Weight = rand + v.Weight + table.insert(weightList, seed) + end + + --排序 + table.sort(weightList, function(x, y) + return x.Weight > y.Weight + end) + + --返回最大的权重值 + local index = weightList[1].Index + return elements[index] + end + + --通过显示时间过滤 + function XSignBoardManager.FitterPlayElementByShowTime(elements) + if not elements or #elements <= 0 then + return + end + + local todayTime = XTime.GetTodayTime(0) + + local configs = {} + local curTime = XTime.GetServerNowTimestamp() + for _, v in ipairs(elements) do + if not v.ShowTime then + table.insert(configs, v) + else + local showTime = string.Split(v.ShowTime, "|") + if #showTime == 2 then + local start = tonumber(showTime[1]) + local stop = tonumber(showTime[2]) + if curTime >= todayTime + start and curTime <= stop + todayTime then + table.insert(configs, v) + end + end + end + end + + return configs + end + + --通过好感度过滤 + function XSignBoardManager.FitterPlayElementByFavorLimit(elements, displayCharacterId) + + if not elements or #elements <= 0 then + return + end + + local favor = XDataCenter.FavorabilityManager.GetCurrCharacterFavorabilityLevel(displayCharacterId) + local configs = {} + + for _, v in ipairs(elements) do + if not v.FavorLimit then + table.insert(configs, v) + else + local showTime = string.Split(v.FavorLimit, "|") + if #showTime == 2 then + local start = tonumber(showTime[1]) + local stop = tonumber(showTime[2]) + if favor >= start and favor <= stop then + table.insert(configs, v) + end + end + end + end + + return configs + end + + --通过待机状态过滤 + function XSignBoardManager.FitterPlayElementByStandType(elements) + + if not elements or #elements <= 0 then + return + end + + local configs = {} + + for _, v in ipairs(elements) do + if v.StandType == StandType then + table.insert(configs, v) + end + end + + return configs + end + + function XSignBoardManager.ChangeDisplayCharacter(id) + XSignBoardManager.ChangeDisplayId = id + PlayedList = {} + end + + function XSignBoardManager.ChangeStandType(standType) + if standType == StandType then + return + end + + XSignBoardManager.SetStandType(standType) + PlayedList = {} + + return true + end + + function XSignBoardManager.GetStandType() + return StandType + end + + --记录播放过的看板动作 + function XSignBoardManager.RecordSignBoard(signboard) + local showType = signboard.ShowType + + if XSignBoardManager.ShowType.PerLogin == showType then + local key = XSignBoardManager.GetSignBoardKey(signboard) + PreLoginPlayedList[key] = signboard + + elseif XSignBoardManager.ShowType.Daily == showType then + + local nowTimeStamp = XTime.GetServerNowTimestamp() + local nowTime = XTime.TimestampToLocalDateTimeString(nowTimeStamp, "yyyy-MM-dd") + local key = XSignBoardManager.GetSignBoardKey(signboard) + CS.UnityEngine.PlayerPrefs.SetString(key, nowTime) + end + + end + + --获取键值 + function XSignBoardManager.GetSignBoardKey(signboard) + local key = string.format("%s_%s_%s", signboard.ShowType, signboard.ConditionId, signboard.ConditionParam) + return key + end + + XSignBoardManager.Init() + return XSignBoardManager +end diff --git a/Resources/Scripts/XManager/XSignInManager.lua b/Resources/Scripts/XManager/XSignInManager.lua new file mode 100644 index 00000000..45debded --- /dev/null +++ b/Resources/Scripts/XManager/XSignInManager.lua @@ -0,0 +1,308 @@ +XSignInManagerCreator = function() + local XSignInManager = {} + + local SignInData = {} -- 签到数据 + local SignInRequest = {SignInRequest = "SignInRequest", NewYearDivining = "DailyLotteryRequest"} -- 签到请求 + local NotifySignIn = false -- 是否打出服务器推送签到 + local IsTotalDivining = false --今天是不是已经占卜过了 + local DiviningId + local DiviningRecords = {} + local DiviningRewards = {} + + -- 推送初始化数据 + function XSignInManager.InitData(data) + if not data then + return + end + + SignInData = {} + for _, v in ipairs(data) do + SignInData[v.Id] = v + end + end + + -- 获取数据 + function XSignInManager.GetSignInData(signInId) + local signInData = SignInData[signInId] + if not signInData then + return nil + end + + return signInData + end + + --- + --- 获取当前轮次 + --- 'isDistinguishType'为 false或nil 则使用signData.Round数据 + function XSignInManager.GetSignRound(signInId, isDistinguishType) + local cfg = XSignInConfigs.GetSignInConfig(signInId) + local signData = XSignInManager.GetSignInData(signInId) + if not signData then + return 1 + end + + if not isDistinguishType then + return signData.Round + end + + if cfg.Type == XSignInConfigs.SignType.Activity + or cfg.Type == XSignInConfigs.SignType.PurchasePackage then + return signData.Round + else + local subRoundId = cfg.SubRoundId[signData.Round] + local subRoundCfg = XSignInConfigs.GetSubRoundConfig(subRoundId) + local day = 0 + for i = 1, #subRoundCfg.SubRoundDays do + day = day + subRoundCfg.SubRoundDays[i] + if signData.Day <= day then + return i + end + end + end + end + + -- 获取当前天数 + function XSignInManager.GetSignDay(signInId) + local signData = XSignInManager.GetSignInData(signInId) + if not signData then + return 1 + end + + return signData.Day + end + + -- 设置已经签到领取奖励 + function XSignInManager.SetSignRewardGet(signInId) + local signData = XSignInManager.GetSignInData(signInId) + if not signData then + return + end + signData.Got = true + end + + --- + --- 判断是否显示签到 + --- 福利界面打开时,'isSignInUi'为true,判断全部奖励领取之后是否继续再福利界面显示 + function XSignInManager.IsShowSignIn(signInId, isSignInUi) + if not XSignInConfigs.IsShowSignIn(signInId) then + return false + end + + local signData = XSignInManager.GetSignInData(signInId) + if not signData then + return false + end + + if isSignInUi then + return XSignInConfigs.JudgeLastDayGet(signInId, signData) + end + + -- 当天奖励领取之后是否显示 + local isShowWhenDayOver = XSignInConfigs.GetSignInShowWhenDayOver(signInId) + if not isShowWhenDayOver and signData.Got then + return false + end + + return true + end + + -- 判断是否已经领取过 + function XSignInManager.JudgeAlreadyGet(signInId, round, day) + local signData = XSignInManager.GetSignInData(signInId) + if not signData then + return false + end + + if round < signData.Round then + return true + end + + if round == signData.Round and day < signData.Day then + return true + end + + if round == signData.Round and day == signData.Day then + return signData.Got + end + + return false + end + + -- 判断月卡所在的签到是否过期,是否能跳转月卡 + function XSignInManager.JudgeYKInSignOverdue(signInId, round, day, remainday) + local signData = XSignInManager.GetSignInData(signInId) + if not signData then + return true, false + end + + if round < signData.Round then + return true, false + end + + if round == signData.Round and day < signData.Day then + return true, false + end + + local offsizeDay = XSignInConfigs.GetDayOffsize(signInId, signData.Round, signData.Day, round, day) + return offsizeDay > remainday, offsizeDay > remainday + end + + -- 判断是否是明日领取 + function XSignInManager.JudgeTomorrow(signInId, round, day) + local signData = XSignInManager.GetSignInData(signInId) + if not signData then + return false + end + + local isRoundLastDay = XSignInConfigs.JudgeLastRoundDay(signInId, signData.Round, signData.Day) + local cfg = XSignInConfigs.GetSignInConfig(signInId) + + if isRoundLastDay and cfg.Type == XSignInConfigs.SignType.Activity then + if round == signData.Round + 1 and day == 1 then + return true + end + else + if round == signData.Round and day == signData.Day + 1 then + return true + end + end + + return false + end + + --- + --- 判断'signInd'的第'round'轮第'day'天是不是今日奖励 + --- 如果为今日奖励,则继续判断是否领取了奖励 + --- + ---@return boolean 是否为今日奖励 + ---@return boolean 如果为今日奖励,是否已经领取了奖励 + function XSignInManager.JudgeTodayGet(signInId, round, day) + local isToday = false + local isGet = false + + local signData = XSignInManager.GetSignInData(signInId) + if not signData then + return isToday, isGet + end + + if round == signData.Round and day == signData.Day then + isToday = true + isGet = signData.Got + end + + return isToday, isGet + end + + --- + --- 判断'signInId'的今日奖励是否已经领取 + ---@return boolean + function XSignInManager.JudgeTodayIsGet(signInId) + local isGet = false + local signData = XSignInManager.GetSignInData(signInId) + if signData then + isGet = signData.Got + else + XLog.Error(string.format("XSignInManager.JudgeTodayIsGet函数错误,没有signInId:%s 的SignInData",tostring(signInId))) + end + return isGet + end + + -- 设置推送签到 + function XSignInManager.SetNotifySign(isNotify) + NotifySignIn = isNotify + end + + -- 判断是否有推送签到 + function XSignInManager.CheckNotifySign() + return NotifySignIn + end + + -- 领取签到奖励请求 + function XSignInManager.SignInRequest(signInId, successCb, failCb) + XNetwork.Call(SignInRequest.SignInRequest, { Id = signInId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + if failCb then + failCb() + end + return + end + + XSignInManager.SetSignRewardGet(signInId) + if successCb then + successCb(res.RewardGoodsList) + end + end) + end + + --请求占卜 + function XSignInManager.RequestNewYearDivining(id, cb) + XNetwork.Call(SignInRequest.NewYearDivining, {Id = id}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + table.insert(DiviningRecords, res.Record) + DiviningRewards = res.RewardGoodsList + IsTotalDivining = true + XEventManager.DispatchEvent(XEventId.EVENT_CARD_REFRESH_WELFARE_BTN) + if cb then + cb() + end + end) + end + + --服务端推送占卜记录 + function XSignInManager.UpdateNewYearDiviningData(data) + for _, info in pairs(data.Lotteries) do + if not DiviningId or DiviningId <= info.Id then + IsTotalDivining = info.IsRewardGot + DiviningId = info.Id + DiviningRecords = info.Records + end + end + XEventManager.DispatchEvent(XEventId.EVENT_CARD_REFRESH_WELFARE_BTN) + end + + function XSignInManager.GetDiviningActivityId() + return DiviningId + end + + --得到今天的占卜状态 + function XSignInManager.GetTodayDiviningState() + return IsTotalDivining + end + + function XSignInManager.CheckTodayDiviningState() + local cfg = XSignInConfigs.GetNewYearSignInConfig(DiviningId) + if cfg and XPlayer.Level and XPlayer.Level >= cfg.OpenLevel and not IsTotalDivining and XSignInConfigs.IsShowDivining(DiviningId) then + return true + end + return false + end + + --获取今天占卜的领奖数据 + function XSignInManager.GetDiviningTodayData() + local data + + for _, v in pairs(DiviningRecords) do + data = v + end + return data + end + + function XSignInManager.GetAllDiviningDatas() + return DiviningRecords + end + + return XSignInManager +end + +XRpc.NotifySignInData = function(data) + XDataCenter.SignInManager.InitData(data.SignInfos) + XDataCenter.SignInManager.SetNotifySign(true) +end + +XRpc.NotifyDailyLotteryData = function(data) + XDataCenter.SignInManager.UpdateNewYearDiviningData(data) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XSocialManager.lua b/Resources/Scripts/XManager/XSocialManager.lua new file mode 100644 index 00000000..2a318a8c --- /dev/null +++ b/Resources/Scripts/XManager/XSocialManager.lua @@ -0,0 +1,907 @@ +XSocialManagerCreator = function() + local Json = require("XCommon/Json") + local XSocialManager = {} + local FRIEND_ID_DATA_NAME = "SocialFriendIdList" + + local FRIEND_SEARCH_INTERVAL_TIME = 0 --搜索冷却时间 + local FRIEND_DELETE_APPLY_INTERVAL_SECOND = 0 --删除申请冷却时间 + local FRIEND_REFUSE_APPLY_INTERVAL_SECOND = 0 --拒绝申请冷却时间 + -- local FRIEND_MAINMAXCLICK_INTERVAL_TIME = 0 + local GET_GIFT_MAXCOUNT_EVERYDAY = 0 --当日收取礼物次数 + + local FriendMap = {} --好友列表 + local WaitPassMap = {} --申请列表 + local RecommendList = {} --推荐好友列表 + local ApplyedList = {} --已申请玩家列表 + local WaitPassLocalMap = {} --本地申请记录 + local RemarksMap = {} --好有名备注 + local BlackMap = {} --拉黑玩家字典 + + local LastRecommendTime = 0 --上次推荐时间 + local ApplyCount = 0 + local A_WEEK = 60 * 60 * 24 * 7 --记录保存时长 + + local SocialDataTimeInterval = 2 * 60 + local SocialPlayerCache = {} + + local METHOD_NAME = { + GetRecommendPlayers = "GetRecommendPlayerListRequest", --获取推荐的好友 + ApplyFriend = "ApplyFriendRequest", --申请好友 + OperationFriendReq = "OperationApplyFriendRequest", --同意或者拒绝的时候调用 + DeleteFriends = "DeleteFriendRequest", --删除好友 + GetSpecifyPlayer = "GetSpecifyPlayerInfoRequest", --获取指定的玩家信息 搜索 + GetPlayerInfoList = "GetPlayerInfoListRequest", --根据Id获取玩家列表 + FriendRemark = "FriendRemarkRequest", --设置玩家备注名 + BlackPlayer = "BlockPlayerRequest", --拉黑玩家 + RemoveBlacklist = "RemoveBlacklistRequest", --移出黑名单 + } + + --------------------------Init---------------------------- + function XSocialManager.Init() + FRIEND_SEARCH_INTERVAL_TIME = CS.XGame.Config:GetInt("FriendSearchSinglePlayerIntervalTime") + FRIEND_DELETE_APPLY_INTERVAL_SECOND = CS.XGame.Config:GetInt("FriendDeleteApplyIntervalSecond") + FRIEND_REFUSE_APPLY_INTERVAL_SECOND = CS.XGame.Config:GetInt("FriendRefuseApplyIntervalSecond") + -- FRIEND_MAINMAXCLICK_INTERVAL_TIME = CS.XGame.Config:GetInt("FriendMainMaxClickIntervalTime") + GET_GIFT_MAXCOUNT_EVERYDAY = CS.XGame.Config:GetInt("GetGiftMaxCountEveryDay") + end + + --Public Method + --初始化社交数据 + function XSocialManager.InitSocialData(socialData) + + if socialData.Remarks then + XTool.LoopCollection(socialData.Remarks, function(value) + -- local remark = (value.Remark ~= "") and value.Remark or nil + RemarksMap[value.Id] = value.Remark + end) + end + + if socialData.FriendData then + FriendMap = {} + + XTool.LoopCollection(socialData.FriendData, function(value) + XSocialManager.AddFriend(XFriend.New(value.PlayerId, value.CreateTime)) + end) + + -- 清除无效好友聊天数据 + XSocialManager.CheckDeleteFriend() + end + + if socialData.ApplyData then + WaitPassMap = {} + XTool.LoopCollection(socialData.ApplyData, function(value) + XSocialManager.AddWaitPassFriend(XFriend.New(value.PlayerId, value.CreateTime), true) + end) + XSocialManager.InitCheckWaitPassLocalMap() + end + + --拉黑数据 + if socialData.BlockData then + XTool.LoopCollection(socialData.BlockData, function(value) + XSocialManager.AddBlack(XFriend.New(value.PlayerId, value.BlockTime), true) + end) + end + + --加载私聊数据 + XDataCenter.ChatManager.InitFriendPrivateChatData() + + -- 监听角色数据查询结果,更新好友数据 + XEventManager.AddEventListener(XEventId.EVENT_REQUEST_PLAYER_INFO_BACK, XSocialManager.UpdateSinglePlayerCache) + end + + -- 获取缓存的好友id列表 + function XSocialManager.GetTempFriendIdList() + local tempFriendIdList = {} + if CS.UnityEngine.PlayerPrefs.HasKey(FRIEND_ID_DATA_NAME) then + local content = CS.UnityEngine.PlayerPrefs.GetString(FRIEND_ID_DATA_NAME) + local tab = string.Split(content, '\t') + for _, v in pairs(tab) do + local friendId = tonumber(v) + if friendId then + tempFriendIdList[friendId] = true + end + end + end + return tempFriendIdList + end + + -- 清除无效好友聊天数据 + function XSocialManager.CheckDeleteFriend() + local lastList = XSocialManager.GetTempFriendIdList() + for friendId, _ in pairs(lastList) do + if not FriendMap[friendId] then + XDataCenter.ChatManager.ClearFriendChatContent(friendId) + end + end + end + + -- 缓存好友id列表 + function XSocialManager.SaveTempFriendIdList() + local saveContent = "" + + for _, v in pairs(FriendMap) do + saveContent = saveContent .. v.FriendId .. '\t' + end + CS.UnityEngine.PlayerPrefs.SetString(FRIEND_ID_DATA_NAME, saveContent) + CS.UnityEngine.PlayerPrefs.Save() + end + + function XSocialManager.CheckIsFriend(playerId) + return XSocialManager.GetFriendInfo(playerId) ~= nil + end + + function XSocialManager.CheckIsApplyed(playerId) + for _, v in pairs(ApplyedList) do + if v == playerId then + return true + end + end + return false + end + + function XSocialManager.AddFriend(friendData) + if not friendData then + return + end + FriendMap[friendData.FriendId] = friendData + + XSocialManager.SaveTempFriendIdList() + end + + function XSocialManager.DelFriend(friendId) + if not friendId then + return + end + XDataCenter.ChatManager.ClearFriendChatContent(friendId) + + if SocialPlayerCache[friendId] then + SocialPlayerCache[friendId].FriendExp = 0 + end + + FriendMap[friendId] = nil + RemarksMap[friendId] = nil + + XSocialManager.SaveTempFriendIdList() + + XEventManager.DispatchEvent(XEventId.EVENT_FRIEND_DELETE, friendId) + end + + --添加等待通过数据 + function XSocialManager.AddWaitPassFriend(friendData, ignoreCheckWaitPass) + if not friendData then + return + end + + ApplyCount = ApplyCount + 1 + WaitPassMap[friendData.FriendId] = friendData + + if not ignoreCheckWaitPass then + XEventManager.DispatchEvent(XEventId.EVENT_FRIEND_WAITING_PASS) + end + end + + -- 登录初始化WaitPassMap,初始化本地数据,然后触发一次检查 + function XSocialManager.InitCheckWaitPassLocalMap() + local key = string.format("%s_WaitPass", tostring(XPlayer.Id)) + local cache = CS.UnityEngine.PlayerPrefs.GetString(key) + local now = XTime.GetServerNowTimestamp() + if not string.IsNilOrEmpty(cache) then + local cacheTable = Json.decode(cache) + for playerId, overTime in pairs(cacheTable or {}) do + if now < overTime then + WaitPassLocalMap[tostring(playerId)] = overTime + end + end + end + XEventManager.DispatchEvent(XEventId.EVENT_FRIEND_WAITING_PASS) + end + + -- 点击等待通过-保存已经点了的数据-清除过期数据 + function XSocialManager.ResetWaitPassLocalMap() + local key = string.format("%s_WaitPass", tostring(XPlayer.Id)) + local now = XTime.GetServerNowTimestamp() + WaitPassLocalMap = {} + for k, v in pairs(WaitPassMap or {}) do + local overTime = v.CreateTime + A_WEEK + if now < overTime then + WaitPassLocalMap[tostring(k)] = overTime + end + end + CS.UnityEngine.PlayerPrefs.SetString(key, Json.encode(WaitPassLocalMap)) + CS.UnityEngine.PlayerPrefs.Save() + XEventManager.DispatchEvent(XEventId.EVENT_FRIEND_WAITING_PASS) + end + + -- 红点检查 + function XSocialManager.HasFriendApplyWaitPass() + -- local key = string.format("%s_WaitPass", tostring(XPlayer.Id)) + local now = XTime.GetServerNowTimestamp() + for playerId, playerData in pairs(WaitPassMap or {}) do + local overTime = playerData.CreateTime + A_WEEK + if not WaitPassLocalMap[tostring(playerId)] and now < overTime then + return true + end + end + return false + end + + function XSocialManager.RefreshRecommendData(dataList) + if dataList then + LastRecommendTime = XTime.GetServerNowTimestamp() + RecommendList = {} + XTool.LoopCollection(dataList, function(item) + local friend = XFriend.New(0, 0, 0) + friend:Update(item) + table.insert(RecommendList, friend) + end) + end + end + --End Public Method + --Get Method + --获取好友ID + function XSocialManager.GetFriendIds() + local list = {} + for key, _ in pairs(FriendMap) do + table.insert(list, key) + end + return list + end + + --上次推荐好友刷新时间 + function XSocialManager.GetLastRecommendTime() + return LastRecommendTime + end + + --推荐好友列表 + function XSocialManager.GetRecommendList() + return RecommendList + end + + function XSocialManager.RemoveRecommendPlay(id) + local index = 0 + for i, info in ipairs(RecommendList) do + if info.FriendId == id then + index = i + break + end + end + + if index > 0 then + table.remove(RecommendList, index) + end + end + + function XSocialManager.IsPlayerValid(playerData) + if not playerData or playerData.Level == 0 or playerData.LastLoginTime == 0 or string.IsNilOrEmpty(playerData.NickName) then + return false + end + + return true + end + + --好友申请者信息列表 + function XSocialManager.GetApplyFriendList() + local list = {} + for key, value in pairs(WaitPassMap) do + if not XSocialManager.CheckIsFriend(key) and XSocialManager.IsPlayerValid(value) then + table.insert(list, value) + end + end + return list + end + + --单个好友信息 + function XSocialManager.GetFriendInfo(friendId) + return FriendMap[friendId] + end + + --全部好友信息列表 + function XSocialManager.GetFriendList() + local list = {} + for _, value in pairs(FriendMap) do + table.insert(list, value) + end + + table.sort(list, function(a, b) + if a.IsOnline ~= b.IsOnline then + return a.IsOnline + end + + return a.FriendId < b.FriendId + end) + + return list + end + + --好友数量 + function XSocialManager.GetFriendCount() + local friendIds = XSocialManager.GetFriendIds() + return #friendIds + end + + function XSocialManager.GetSearchFriendCoolDownTime() + return FRIEND_SEARCH_INTERVAL_TIME + end + + function XSocialManager.GetDeleteApplyCoolDownTime() + return FRIEND_DELETE_APPLY_INTERVAL_SECOND + end + + function XSocialManager.GetRefuseApplyCoolDownTime() + return FRIEND_REFUSE_APPLY_INTERVAL_SECOND + end + + --配置表每日最大可领取礼物的数量 + function XSocialManager.GetGiftMaxCount() + return GET_GIFT_MAXCOUNT_EVERYDAY + end + --End Get Method + --刷新推荐列表 + function XSocialManager.GetRecommendPlayers(cb) + cb = cb or function() + end + + XNetwork.Call(METHOD_NAME.GetRecommendPlayers, nil, function(response) + if response.Code ~= XCode.Success then + XUiManager.TipCode(response.Code) + cb(response.Code, response.RefreshTime) + return + end + XSocialManager.RefreshRecommendData(response.RecommendFriendsList) + cb(response.Code, response.RefreshTime) + end) + end + + --处理服务器返回的错误码 + function XSocialManager:HandleErrorCode(code) + if code == XCode.FriendManagerApplyFriendFailedIsDeleted then + return XSocialManager.GetDeleteApplyCoolDownTime() + elseif code == XCode.FriendManagerApplyFriendFailedIsRefused then + return XSocialManager.GetRefuseApplyCoolDownTime() + else + XUiManager.TipCode(code) + end + return nil + end + + --申请添加好友 + function XSocialManager.ApplyFriend(id, successCb, failedCb) + if not id or id <= 0 then + return + end + failedCb = failedCb or function() end + if XSocialManager.CheckIsFriend(id) then + XUiManager.TipText("AlreadyFriends") + failedCb() + return + end + + successCb = successCb or function() + end + XNetwork.Call(METHOD_NAME.ApplyFriend, { TargetPlayerId = id }, function(response) + if not XSocialManager.CheckIsApplyed(id) then + table.insert(ApplyedList, id) + end + if response.Code ~= XCode.FriendManagerApplySuccess then + local interval = XSocialManager:HandleErrorCode(response.Code) + if interval ~= nil then + local curTime = XTime.GetServerNowTimestamp() + local timeDifference = (response.OperationTime + interval - curTime) / 3600 + XUiManager.TipError(CS.XTextManager.GetText("ApplyForTip", math.ceil(timeDifference))) + end + failedCb() + return + end + XUiManager.TipText("FriendApplySuccess") + successCb(response.Code) + end) + end + + --更新好友信息列表 + function XSocialManager.GetFriendsInfo(cb) + cb = cb or function() + end + local ids = {} + for key, _ in pairs(FriendMap) do + table.insert(ids, key) + end + local func = function(list) + if not list then + cb() + return + end + + for _, playerInfo in ipairs(list) do + local friend = FriendMap[playerInfo.Id] + if friend then + friend:Update(playerInfo) + end + end + cb() + end + XSocialManager.GetPlayerInfoList(ids, func) + end + + --更新好友申请列表 + function XSocialManager.GetApplyFriendsInfo(cb) + cb = cb or function() + end + local ids = {} + for key, _ in pairs(WaitPassMap) do + table.insert(ids, key) + end + local func = function(list) + if not list then + cb() + return + end + + for _, playerInfo in ipairs(list) do + local applyData = WaitPassMap[playerInfo.Id] + if applyData then + applyData:Update(playerInfo) + end + end + cb() + end + XSocialManager.GetPlayerInfoList(ids, func) + end + + --------------------------------社交系统相关角色数据缓存 beg-------------------------------- + function XSocialManager.GetPlayerCache(playerId) + if not playerId then + return + end + + local playerCache = SocialPlayerCache[playerId] + if not playerCache then + return + end + + if not playerCache.UpdateTime or XTime.GetServerNowTimestamp() - playerCache.UpdateTime > SocialDataTimeInterval then + return + end + + return playerCache + end + + function XSocialManager.UpdateSinglePlayerCache(playerId, playerInfo) + + SocialPlayerCache[playerId] = SocialPlayerCache[playerId] or {} + + local friend = SocialPlayerCache[playerId] + + friend.NickName = playerInfo.BaseInfo.Name + friend.Level = playerInfo.BaseInfo.Level + friend.CurrHeadPortraitId = playerInfo.BaseInfo.CurrHeadPortraitId + friend.CurrHeadFrameId = playerInfo.BaseInfo.CurrHeadFrameId + end + + + function XSocialManager.UpdatePlayerCache(playerInfoList) + for _, playerData in pairs(playerInfoList) do + SocialPlayerCache[playerData.Id] = playerData + SocialPlayerCache[playerData.Id].UpdateTime = XTime.GetServerNowTimestamp() + end + end + + --------------------------------社交系统相关角色数据缓存 end-------------------------------- + --搜索好友 + function XSocialManager.SearchPlayer(id, cb) + if not id then + return + end + + local playerCache = XSocialManager.GetPlayerCache(id) + if playerCache then + local friend = XFriend.New(0, 0, 0) + friend:Update(playerCache) + if cb then + cb(friend) + end + return + end + + XSocialManager.SearchPlayerByServer(id, function(playerInfo) + XSocialManager.UpdatePlayerCache({ playerInfo }) + if cb then + local friend = XFriend.New(0, 0, 0) + friend:Update(playerInfo) + cb(friend) + end + end) + end + + function XSocialManager.SearchPlayerByServer(id, cb) + XNetwork.Call(METHOD_NAME.GetSpecifyPlayer, { Id = id }, function(response) + if response.Code ~= XCode.Success then + XUiManager.TipCode(response.Code) + return + end + + if cb then + cb(response.PlayerInfo) + end + end) + end + + + function XSocialManager.GetPlayerInfoList(idList, cb) + if not idList or #idList <= 0 then + if cb then + cb() + end + return + end + + local needRequestList = {} + local playerCacheList = {} + for _, id in pairs(idList) do + local playerCache = XSocialManager.GetPlayerCache(id) + if playerCache then + table.insert(playerCacheList, playerCache) + else + table.insert(needRequestList, id) + end + end + + if #needRequestList <= 0 then + if cb then + cb(playerCacheList) + end + return + end + + XSocialManager.GetPlayerInfoListByServer(needRequestList, function(playerInfoList) + XSocialManager.UpdatePlayerCache(playerInfoList) + for _, v in pairs(playerInfoList) do + table.insert(playerCacheList, v) + end + + if cb then + cb(playerCacheList) + end + end) + end + + --根据id数组获取好友列表 + function XSocialManager.GetPlayerInfoListByServer(idList, cb) + XNetwork.Call(METHOD_NAME.GetPlayerInfoList, { Ids = idList }, function(response) + if response.Code ~= XCode.Success then + XUiManager.TipCode(response.Code) + return + end + + if cb then + cb(response.PlayerInfoList or {}) + end + end) + end + + --同意或者拒绝添加好友 + function XSocialManager.AcceptApplyFriend(friendId, isAgreed, cb) + friendId = friendId or 0 + isAgreed = isAgreed or false + cb = cb or function() + end + local request = { TargetPlayerId = friendId, IsAccept = isAgreed } + XNetwork.Call(METHOD_NAME.OperationFriendReq, request, function(response) + WaitPassMap[friendId] = nil + XSocialManager.ResetWaitPassLocalMap() + if response.Code ~= XCode.Success then + XUiManager.TipCode(response.Code) + cb() + return + end + if isAgreed then + XSocialManager.SearchPlayer(friendId, function(friendData) + XSocialManager.AddFriend(friendData) + end) + XUiManager.TipText("FriendAgree") + else + XUiManager.TipText("FriendRefuse") + end + cb() + end) + end + + --删除好友 + function XSocialManager.DeleteFriends(friendIds, cb) + friendIds = friendIds or {} + cb = cb or function() + end + if #friendIds <= 0 then + cb() + return + end + + local playerIds = {} + for _, id in ipairs(friendIds) do + table.insert(playerIds, id) + end + + local request = { Ids = playerIds } + XNetwork.Call(METHOD_NAME.DeleteFriends, request, function(response) + XUiManager.TipCode(response.Code) + if response.Code ~= XCode.FriendManagerDeleteSuccess then + return + end + for _, id in ipairs(friendIds) do + XSocialManager.DelFriend(id) + XDataCenter.ChatManager.ClearFriendChatContent(id) + end + cb() + end) + end + + -- 设置玩家备注名 + function XSocialManager.RemarkFriendName(friendId, friendName, cb) + cb = cb or function() end + -- 同名判断 + if RemarksMap[friendId] and RemarksMap[friendId] == friendName then + XUiManager.TipError(CS.XTextManager.GetText("SocialRemarkIsSame")) + return + end + + -- 是否是好友 + if XSocialManager.CheckIsFriend(friendId) then + XNetwork.Call(METHOD_NAME.FriendRemark, { Id = friendId, Name = friendName }, function(response) + if friendName == nil or friendName == "" then + XUiManager.TipMsg(CS.XTextManager.GetText("SocialDeleteRemarkSucceed")) + else + XUiManager.TipCode(response.Code) + end + if response.Code ~= XCode.Success then + return + end + local remark = (friendName ~= "") and friendName or nil + RemarksMap[friendId] = remark + XEventManager.DispatchEvent(XEventId.EVENT_FRIEND_REMARK_NAME, friendId) + cb() + end) + end + + end + + function XSocialManager.NotifyFriendExp(notify) + local player = SocialPlayerCache[notify.FriendId] + if not player then + return + end + + player.FriendExp = notify.Exp + end + ----------------------End Net----------------------- + function XSocialManager.GetFriendExp(playerId) + if not playerId then + return 0 + end + + local friend = FriendMap[playerId] + if not friend then + return 0 + end + + return friend.FriendExp + end + + function XSocialManager.GetFriendExpLevel(playerId) + local curExp = XSocialManager.GetFriendExp(playerId) + local fetterLevelTemplates = XPlayerInfoConfigs.GetFettersCfg() + local maxLevelTemplate = fetterLevelTemplates[#fetterLevelTemplates] + + for level, v in ipairs(fetterLevelTemplates) do + if curExp < v.Exp then + return level, v.Exp - curExp + end + if curExp >= maxLevelTemplate.Exp then + return maxLevelTemplate.Level, maxLevelTemplate.Exp + end + end + + return 1, 0 + end + + function XSocialManager.GetFetterTableDataByLevel(level) + local fetterLevelTemplates = XPlayerInfoConfigs.GetFettersCfg() + return fetterLevelTemplates[level] + end + + function XSocialManager.ResetApplyCount() + ApplyCount = 0 + XEventManager.DispatchEvent(XEventId.EVENT_FRIEND_WAITING_PASS) + end + + -- 好友备注名、没有返回好友名字 + function XSocialManager.GetPlayerRemark(playerId, defaultName) + if XSocialManager.CheckIsFriend(playerId) then + local friendInfo = XSocialManager.GetFriendInfo(playerId) + return RemarksMap[playerId] or friendInfo.NickName + end + return defaultName + end + + -- 好友备注名、没有返回"" + function XSocialManager.GetFriendRemark(friendId) + return RemarksMap[friendId] or "" + end + + --------------------------------------------- + function XSocialManager.NotifyAddFriend(friend) + XSocialManager.SearchPlayer(friend.FriendId, function(friendData) + FriendMap[friend.FriendId] = friendData + if WaitPassMap[friend.FriendId] then + WaitPassMap[friend.FriendId] = nil + end + end) + end + + -------------------黑名单 begin---------------------- + function XSocialManager.AddBlack(blackTemplate, isNotDeleteBlackPlayerData) + if not blackTemplate then + return + end + + local playerId = blackTemplate.FriendId + BlackMap[playerId] = blackTemplate + + if not isNotDeleteBlackPlayerData then + XSocialManager.DeleteBlackPlayerData(playerId) + end + end + + function XSocialManager.RemoveBlack(playerId) + if BlackMap[playerId] then + BlackMap[playerId] = nil + end + end + + function XSocialManager.GetBlackPlayerIdList() + local blackPlayerIdList = {} + local blackTempList = {} + for _, data in pairs(BlackMap) do + table.insert(blackTempList, data) + end + + table.sort(blackTempList, function(a, b) + if a.CreateTime ~= b.CreateTime then + return a.CreateTime > b.CreateTime + end + return a.FriendId < b.FriendId + end) + + for _, v in ipairs(blackTempList) do + table.insert(blackPlayerIdList, v.FriendId) + end + + return blackPlayerIdList + end + + function XSocialManager.GetBlackData(playerId) + return playerId and BlackMap[playerId] + end + + function XSocialManager.DeleteBlackPlayerData(playerId) + WaitPassMap[playerId] = nil + XSocialManager.DelFriend(playerId) + WaitPassLocalMap[playerId] = nil + XSocialManager.RemoveRecommendPlay(playerId) + XDataCenter.ChatManager.ClearFriendChatContent(playerId) + XDataCenter.MentorSystemManager.RemoveApplyList(playerId) + XDataCenter.ArenaOnlineManager.RemovePrivateChatData(playerId) + end + + --通知被拉黑玩家 + function XSocialManager.NotifyBlock(notifyData) + local playerId = notifyData.PlayerId + XSocialManager.DeleteBlackPlayerData(playerId) + XEventManager.DispatchEvent(XEventId.EVENT_BLACK_DATA_CHANGE) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_BLACK_DATA_CHANGE) + end + + function XSocialManager.RequestBlackPlayer(playerId, cb) + local request = { PlayerId = playerId } + XNetwork.Call(METHOD_NAME.BlackPlayer, request, function(response) + if response.Code ~= XCode.Success then + XUiManager.TipCode(response.Code) + return + end + + XUiManager.TipText("SocialBlackEnterSuccess") + + local serverTimestamp = XTime.GetServerNowTimestamp() + XSocialManager.AddBlack(XFriend.New(playerId, serverTimestamp)) + + if cb then + cb() + end + + XEventManager.DispatchEvent(XEventId.EVENT_BLACK_DATA_CHANGE) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_BLACK_DATA_CHANGE) + end) + end + + function XSocialManager.RequestRemoveBlacklist(playerId, cb) + local request = { PlayerId = playerId } + XNetwork.Call(METHOD_NAME.RemoveBlacklist, request, function(response) + if response.Code ~= XCode.Success then + XUiManager.TipCode(response.Code) + return + end + + XSocialManager.RemoveBlack(playerId) + if cb then + cb() + end + + XEventManager.DispatchEvent(XEventId.EVENT_BLACK_DATA_CHANGE) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_BLACK_DATA_CHANGE) + end) + end + + --更新黑名单详细列表 + function XSocialManager.GetBlacksInfo(cb) + cb = cb or function() + end + local ids = {} + for key in pairs(BlackMap) do + table.insert(ids, key) + end + local func = function(list) + if not list then + cb() + return + end + + for _, playerInfo in ipairs(list) do + local applyData = BlackMap[playerInfo.Id] + if applyData then + applyData:Update(playerInfo) + end + end + cb() + end + XSocialManager.GetPlayerInfoList(ids, func) + end + + -------------------黑名单 end---------------------- + + XSocialManager.Init() + return XSocialManager +end + +--当在线被人申请的时候,增加等待通过数据 +XRpc.NotifyAddApply = function(notifyData) + XDataCenter.SocialManager.AddWaitPassFriend(XFriend.New(notifyData.ApplyId, notifyData.CreateTime)) +end + +--当在线添加 好友成功之后 +XRpc.NotifyAddFriend = function(notifyData) + local friend = XFriend.New(notifyData.PlayerId, notifyData.CreateTime, notifyData.Exp) + XDataCenter.SocialManager.NotifyAddFriend(friend) +end + +--当在线被人拒绝的时候 +XRpc.NotifyRefuseApply = function() + +end + +--当在线被人删除的时候 +XRpc.NotifyDeleteFriend = function(notifyData) + XDataCenter.SocialManager.DelFriend(notifyData.PlayerId) +end + +--登陆返回基础好友数据 +XRpc.NotifySocialData = function(notifyData) + XDataCenter.SocialManager.InitSocialData(notifyData) +end + +-- 羁绊等级改变 +XRpc.NotifyFriendExp = function(notifyData) + XDataCenter.SocialManager.NotifyFriendExp(notifyData) +end + +--通知被拉黑玩家 +XRpc.NotifyBlock = function(notifyData) + XDataCenter.SocialManager.NotifyBlock(notifyData) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XSoundManager.lua b/Resources/Scripts/XManager/XSoundManager.lua new file mode 100644 index 00000000..f3e59620 --- /dev/null +++ b/Resources/Scripts/XManager/XSoundManager.lua @@ -0,0 +1,264 @@ +local CSXAudioManager = CS.XAudioManager + +XSoundManager = XSoundManager or {} + +XSoundManager.SoundType = { + BGM = 1, + Sound = 2, + CV = 3, +} + +XSoundManager.PlayFunc = { + [XSoundManager.SoundType.BGM] = CSXAudioManager.PlayMusic, + [XSoundManager.SoundType.Sound] = CSXAudioManager.PlaySound, + [XSoundManager.SoundType.CV] = CSXAudioManager.PlayCv, +} + +XSoundManager.SetVolumeFunc = { + [XSoundManager.SoundType.BGM] = CSXAudioManager.ChangeMusicVolume, + [XSoundManager.SoundType.Sound] = CSXAudioManager.ChangeSoundVolume, + [XSoundManager.SoundType.CV] = CSXAudioManager.ChangeCvVolume, +} + +XSoundManager.GetVolumeFunc = { + [XSoundManager.SoundType.BGM] = CSXAudioManager.GetMusicVolume, + [XSoundManager.SoundType.Sound] = CSXAudioManager.GetSoundVolume, + [XSoundManager.SoundType.CV] = CSXAudioManager.GetCvVolume, +} + +XSoundManager.UiBasicsMusic = { + NoSound = 0, -- 无音效 + ClickOn = 501, -- 按钮点击 + Intercept = 504, -- 点击拦截 + Success = 505, -- 成功 + Defeat = 507, -- 失败 + Promotion = 506, -- 提升 + Slide = 508, + + --添加 + Main_huge = 1011, --主界面大按钮 + Main_middle = 1012, --主界面中按钮 + Main_small = 1013, --主界面中按钮 + Main_turnOver = 1014, --主界面翻转 + + --公共 + Tip_small = 1021, + Tip_Big = 1022, + Skip = 1023, --跳过 + Return = 1024, --返回 + Confirm = 1025, --确认 + Triangle = 1026, --三角形按钮 + Tip_Up = 1027, --数值增 + Tip_Down = 1028, --数值减 + + --通用 + Common_UiPlayerUp = 1094, --指挥官升级 + Common_UiFunctionalOpen = 1099, --通讯出来 + Common_UiObtain = 1095, --奖励弹窗 + + --角色 + UiCharacter_LevelUp = 1094, --升级成功 + UiCharacter_GradeUp = 1094, --晋升成功 + UiCharacter_QualityUp = 1094, --进化成功 + UiCharacter_Liberation = 1094, --解放成功 + UiCharacter_QualityFragments = 1097, --使用碎片激活 + UiCharacter_UnlockBegin = 1101, --解锁角色 动画出现时 + UiCharacter_UnlockEnd = 1094, --解锁角色 动画结束时 + + --装备 + UiEquip_BreakThroughPopUp = 1094, --武器突破成功 + UiEquip_ResonanceSelectAfter = 1096, --武器共鸣成功 + + --副本 + Fight_Difficult_Select = 1031, --难度选择 + Fight_PageSwitch = 1032, --页面切换 + Fight_Start_Fight = 1041, --进入作战 + Fight_PageSwitch_Up = 1042, --关卡上翻页 + Fight_PageSwitch_Down = 1043, --关卡上翻页 + Fight_Collect = 1044, --收集率奖励入口 + + Fight_Enter_Game = 1034, -- 进入游戏按钮音效 + Fight_Click_Role = 1051, -- 点击角色 + Fight_Switch_Site = 1052, --换阵位 + Fight_Click_Team = 1053, -- 点击队伍 + Fight_Open_Help = 1054, -- 点击助战 + Fight_Close_Help = 1055, -- 关闭助战 + + Fuben_UiRoomCharacter_Fashion = 1056, -- 点击队员编辑界面时装按钮音效 + Fuben_UiRoomCharacter_Equip = 1057, -- 点击队员编辑界面装备按钮音效 + Fuben_UiRoomCharacter_QuitTeam = 1058, -- 点击队员编辑界面移出队伍音效 + Fuben_UiRoomCharacter_JoinTeam = 1059, -- 点击队员编辑界面编入队伍音效 + + UiActivityBranch_SwitchBg = 1102, --极地副本切换背景图 + UiActivityBrief_Anim = 1103, --极地活动简介入场动画音效 + + UiActivity_Jidi_BGM = 6, --极地暗流版本BGM + UiActivity_ChinaBoat_BGM = 18, --中国船BGM + UiActivity_NewYear_BGM = 11, --新年活动BGM + UiActivity_FoolsDay_BGM = 205, --愚人节活动BGM + + --时装/仓库 + UiFashion_Click = 1060, -- 点击不同时装音效 + UiEquipReplace_Click = 1061, -- 点击选择武器 + --仓库 + UiBag_Chip_Click = 1062, -- 点击选择不同意识 + UiBag_EquipInfo_Click = 1063, -- 点击装备界面详细信息查看音效 + UiBag_EquipOn_Click = 1064, -- 点击装备界面装备按钮音效 + UiBag_EquipOff_Click = 1065, -- 点击装备界面卸下按钮音效 + UiBag_EquipSelect_Click = 1066, -- 点击装备界面功能选择按钮音效 + UiBag_EquipRes_Click = 1067, -- 点击装备界面材料按钮音效 + + UiEquip_Intensify_Click = 1068, -- 点击强化按钮音效 + UiEquip_Intensify_Up_Click = 1069, -- 装备强化等级提升 + UiEquip_Awake_Click = 1070, -- 点击装备觉醒按钮音效 + UiEquip_Awake_Up_Click = 1071, -- 装备觉醒等级提升 + + --抽卡 + UiDrawCard_BoxOpen = 1517, --开启宝箱音效 + UiDrawCard_GachaOpen = 1617, --开启活动魔方音效 + UiDrawCard_Type = { --卡片展示音效 + --普通 + Normal = { + Start = 1518, + Show = 1530, + }, + --五星 + FiveStar = { + Start = 1519, + Show = 1531, + }, + --六星 + SixStar = { + Start = 1520, + Show = 1532, + }, + }, + UiDrawCard_Reward_Normal = 1521, --普通获得奖励音效 + UiDrawCard_Reward_Suipian = 1522, --获得奖励转为碎片音效 + UiDrawCard_Chouka_Name = 1533, --抽卡-角色名字出现 + + -- 结算 + UiSettle_Win_Number = 1098, -- 战斗结算播放分数音效 + + --追击玩法 + ChessPursuit_BossJump = 841, + ChessPursuit_FightWarning = 842, + + UiLuckDraw_DragCoin = 114, -- 元旦抽奖音效 + UiLuckDraw_Cube = 1617, -- 元旦抽奖音效 + + --2021端午活动 + RpgMakerGame_Move = 875, --移动音效 + RpgMakerGame_Death = 876, --死亡音效 + RpgMakerGame_EndPointOpen = 877, --终点开启音效 + RpgMakerGame_TriggerType2 = 878, --机关类型2的触发音效 + RpgMakerGame_TriggerType3 = 879, --机关类型3的触发音效 +} + +local onValueTime = true +local soundTime = 0 + +XSoundManager.GetSoundTime = function(time) + if onValueTime == false then + if soundTime == 0 then + soundTime = math.ceil(time) * 1000 + XScheduleManager.ScheduleOnce(function() + onValueTime = true + soundTime = 0 + end, math.ceil(time) * 1000) + end + end +end + +function XSoundManager.PlayBtnMusic(value, type) + if type == "onClick" then + if value == 0 then + return + end + end + if type == "onValueChanged" then + if onValueTime == true then + --onValueTime = false + if value then + if value == 0 then + onValueTime = true + return + end + CSXAudioManager.PlaySound(value) + end + end + end + if type == "onEndEdit" then + if value == nil then + CSXAudioManager.PlaySound(XSoundManager.UiBasicsMusic.ClickOn) + else + if value == 0 then + return + end + CSXAudioManager.PlaySound(value) + end + end +end + +-- 延迟播放BGM(临时解决) +function XSoundManager.PlaySoundDoNotInterrupt(cueId) + XScheduleManager.ScheduleOnce(function() + CSXAudioManager.PlayMusic(cueId) + end, 100) +end + +function XSoundManager.PlaySoundByType(cueId, soundType) + if not cueId then + XLog.Error("XSoundManager.PlaySoundByType函数错误,参数cueId不能为空") + return + end + + local func = XSoundManager.PlayFunc[soundType] + if not func then + XLog.Error("XSoundManager.PlaySoundByType 函数错误, 不存在此声音类型, 类型是:" .. soundType) + return + end + + return func(cueId) +end + +function XSoundManager.SetVolumeByType(volume, soundType) + if not volume then + XLog.Error("XSoundManager.SetVolumeByType 函数错误: 参数volume不能为空") + return + end + + local func = XSoundManager.SetVolumeFunc[soundType] + if not func then + XLog.Error("XSoundManager.SetVolumeByType 函数错误, 不存在此声音类型, 类型是: " .. soundType) + return + end + + func(volume) +end + +function XSoundManager.GetVolumeByType(soundType) + local func = XSoundManager.GetVolumeFunc[soundType] + if not func then + XLog.Error("XSoundManager.GetVolumeFunc 函数错误, 不存在此声音类型, 类型是: " .. soundType) + return + end + + return func() +end + +function XSoundManager.PauseMusic() + CSXAudioManager.PauseMusic() +end + +function XSoundManager.ResumeMusic() + CSXAudioManager.ResumeMusic() +end + +function XSoundManager.GetCurrentBgmCueId() + return CSXAudioManager.CurrentMusicId +end + +function XSoundManager.Stop(cueId) + CSXAudioManager.Stop(cueId) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XSpecialShopManager.lua b/Resources/Scripts/XManager/XSpecialShopManager.lua new file mode 100644 index 00000000..68d90ec6 --- /dev/null +++ b/Resources/Scripts/XManager/XSpecialShopManager.lua @@ -0,0 +1,168 @@ +XSpecialShopManagerCreator = function() + local XSpecialShopManager = {} + + --- + --- 根据商品数据,得到对应的配置Id + local function GetFashionId(shopGoodsData) + local templateId = 0 + + if type(shopGoodsData.RewardGoods) == "number" then + templateId = shopGoodsData.RewardGoods + else + templateId = (shopGoodsData.RewardGoods.TemplateId and shopGoodsData.RewardGoods.TemplateId > 0) and + shopGoodsData.RewardGoods.TemplateId or + shopGoodsData.RewardGoods.Id + end + + local isWeaponFashion = XDataCenter.ItemManager.IsWeaponFashion(templateId) + local id = isWeaponFashion and XDataCenter.ItemManager.GetWeaponFashionId(templateId) or templateId + return id + end + + --- + --- 排序角色涂装数据 + --- 涂装系列Id从小到大,0为最后 + --- 可购买优于不可购买 + --- 角色Id从小到大 + local function Sort(a, b) + local aFashionId = GetFashionId(a) + local bFashionId = GetFashionId(b) + + -- 涂装系列Id排序,从小到大,0为末尾 + local aSeries = XDataCenter.FashionManager.GetFashionSeries(aFashionId) + local bSeries = XDataCenter.FashionManager.GetFashionSeries(bFashionId) + if aSeries ~= bSeries then + if aSeries == 0 then + return false + end + if bSeries == 0 then + return true + end + return aSeries < bSeries + end + + -- 购买条件排序,满足条件的排前面 + local aMeetCondition = 1 + local bMeetCondition = 1 + local aConditionIds = a.ConditionIds + if aConditionIds and #aConditionIds > 0 then + for _, id in pairs(aConditionIds) do + local ret = XConditionManager.CheckCondition(id) + if not ret then + aMeetCondition = 0 + end + end + end + local bConditionIds = b.ConditionIds + if bConditionIds and #bConditionIds > 0 then + for _, id in pairs(bConditionIds) do + local ret = XConditionManager.CheckCondition(id) + if not ret then + bMeetCondition = 0 + end + end + end + if aMeetCondition ~= bMeetCondition then + return aMeetCondition > bMeetCondition + end + + -- 售罄排序,已售罄的排后面 + local aSellOut = 0 + local bSellOut = 0 + if a.BuyTimesLimit > 0 then + if a.TotalBuyTimes >= a.BuyTimesLimit then + aSellOut = 1 + end + end + if b.BuyTimesLimit > 0 then + if b.TotalBuyTimes >= b.BuyTimesLimit then + bSellOut = 1 + end + end + if aSellOut ~= bSellOut then + return aSellOut < bSellOut + end + + -- 角色Id排序,从小到大 + local aCharacterId = XDataCenter.FashionManager.GetCharacterId(aFashionId) + local bCharacterId = XDataCenter.FashionManager.GetCharacterId(bFashionId) + return aCharacterId < bCharacterId + end + + --- + --- 将'fashionData'分成最大长度为'maxSegSize'的分段,每一段都是同一系列的涂装 + --- + --- 'fashionData'为 按涂装系列Id排序 的数组 + --- 长度不足'maxSegSize'的分段,剩余的数据为nil + --- 'isSeries'是否要区分系列 + local function Segment(fashionData, maxSegSize, isSeries) + local result = {} + local segmentation = {} + if next(fashionData) and isSeries then + segmentation.First = true -- 同系列的首个片段 + end + + local preSeries -- 当前片段上一个涂装所属的系列,如果为nil,说明当前片段为空 + + for _, data in ipairs(fashionData) do + if #segmentation == maxSegSize then + -- 到达最大长度 + table.insert(result, segmentation) + segmentation = {} + preSeries = nil + end + + local curFashionId = GetFashionId(data) + local curSeries = XDataCenter.FashionManager.GetFashionSeries(curFashionId) + + -- 是否需要区分系列 + if preSeries and isSeries then + if preSeries ~= curSeries then + -- 当前涂装与segmentation内的涂装不同系列,使用新的片段 + table.insert(result, segmentation) + segmentation = {} + segmentation.First = true + preSeries = nil + end + end + + if not segmentation.SeriesId then + segmentation.SeriesId = curSeries + end + + table.insert(segmentation, data) + preSeries = curSeries + end + + if next(segmentation) then + -- 把在循环中剩余的片段放入结果中 + table.insert(result, segmentation) + segmentation = {} + preSeries = nil + end + + return result + end + + --- + --- 得到商品行的数据,一行有 XSpecialShopConfigs.MAX_COUNT 个商品 + --- 'groupId'筛选组Id + --- 'selectTag'筛选标签 + --- 'isSeries'是否要区分系列,true区分,false不区分 + function XSpecialShopManager.GetCommodityLineData(shopId, groupId, selectTag, isSeries) + local goodsList = XShopManager.GetScreenGoodsListByTag(shopId, groupId, selectTag) + table.sort(goodsList, Sort) + + goodsList = Segment(goodsList, XSpecialShopConfigs.MAX_COUNT, isSeries) + return goodsList + end + + --- + --- 判断是否显示活动商店入口 + function XSpecialShopManager:IsShowEntrance() + local timeId = XSpecialShopConfigs.GetTimeId() + return XFunctionManager.CheckInTimeByTimeId(timeId) + end + + return XSpecialShopManager +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XSpringFestivalActivityManager.lua b/Resources/Scripts/XManager/XSpringFestivalActivityManager.lua new file mode 100644 index 00000000..b986e835 --- /dev/null +++ b/Resources/Scripts/XManager/XSpringFestivalActivityManager.lua @@ -0,0 +1,717 @@ +local XSpringFestivalBoxGift = require("XEntity/XSpringFestival/XSpringFestivalBoxGift") +local XSpringFestivalFriendRequestInfo = require("XEntity/XSpringFestival/XSpringFestivalFriendRequestInfo") +XSpringFestivalActivityManagerCreator = function() + local tableInsert = table.insert + local tableRemove = table.remove + local tableSort = table.sort + local pairs = pairs + local XSpringFestivalActivityManager = {} + + local _CurrRecvRewardInfo = {} + local _RecvFinalRewardTimes = 0 + local _CurrActivityId = 0 + local _GiftBoxData = {} + local _FriendRequestList = {} + local _RequestWordId = 0 + local _LastRequestTime = 0 + local _LastSendGuildRequestTime = 0 + local _SequenceSuccessCount = 0 + local _EggList = {} + local _TodayScore = 0 + local _CurrentScore = 0 + local _HighestScore = 0 + local _TodayScoreRewardStatus = 0 + local _LastUseItemData = { + Buff = 0, + SafetyProtect = 0, + Hammer = 1 + } + local CollectWordsRequestWordCd = CS.XGame.Config:GetInt("CollectWordsRequestWordCd") + local CollectWordsRequestWordGuildCd = CS.XGame.Config:GetInt("CollectWordsRequestWordGuildCd") + local CollectWordsGiftBoxMaxCount = CS.XGame.Config:GetInt("CollectWordsGiftBoxMaxCount") + local CollectWordsRecvRequestMaxCount = CS.XGame.Config:GetInt("CollectWordsRecvRequestMaxCount") + local CollectWordsRequestWordFriendCd = CS.XGame.Config:GetInt("CollectWordsRequestWordFriendCd") + + -----------------------集字相关 begin---------------------------- + + local GetAlreadyRecvTimes = function(type) + for i = 1, #_CurrRecvRewardInfo do + if type == _CurrRecvRewardInfo[i].Id then + return _CurrRecvRewardInfo[i].AlreadyRecvTimes + end + end + return 0 + end + + function XSpringFestivalActivityManager.GetCanGetNumberByType(type) + local itemList = XSpringFestivalActivityConfigs.GetWordsItemListByType(type) + local min + for _, item in pairs(itemList) do + local count = XDataCenter.ItemManager.GetCount(item.Id) + if not min or count < min then + min = count + end + end + return XMath.Clamp(min, 0, XSpringFestivalActivityConfigs.GetCollectWordsRewardMaxCount(type) - GetAlreadyRecvTimes(type)) + end + + function XSpringFestivalActivityManager.CheckRewardIsMaxCount(type) + for i = 1, #_CurrRecvRewardInfo do + if type == _CurrRecvRewardInfo[i].Id then + return _CurrRecvRewardInfo[i].AlreadyRecvTimes >= XSpringFestivalActivityConfigs.GetCollectWordsRewardMaxCount(type) + end + end + return false + end + + function XSpringFestivalActivityManager.CheckIsInGuildRequestCd() + local now = XTime.GetServerNowTimestamp() + local offset = now - _LastSendGuildRequestTime + return offset < CollectWordsRequestWordGuildCd, CollectWordsRequestWordGuildCd - offset + end + + function XSpringFestivalActivityManager.GetAlreadyRecvTimes(type) + for _,v in pairs(_CurrRecvRewardInfo) do + if v.Id == type then + return v.AlreadyRecvTimes + end + end + end + + function XSpringFestivalActivityManager.GetCollectWordDuringDay() + local startTime = XSpringFestivalActivityManager.GetActivityStartTime() + local now = XTime.GetServerNowTimestamp() + local offset = now - startTime + return math.ceil(offset / (3600 * 24)) + end + + function XSpringFestivalActivityManager.GetGiftBoxDataByIndex(index) + return _GiftBoxData[index] + end + + function XSpringFestivalActivityManager.GetGiftCount() + return #_GiftBoxData + end + + function XSpringFestivalActivityManager.GetRequestWordId() + return _RequestWordId + end + + function XSpringFestivalActivityManager.HasRequestWord() + return _RequestWordId > 0 + end + + function XSpringFestivalActivityManager.GetNextRequestRefreshTime() + local nextRecoverTime = XTime.GetSeverNextRefreshTime() + local now = XTime.GetServerNowTimestamp() + return nextRecoverTime - now + end + + function XSpringFestivalActivityManager.GetNextRequestTime() + local now = XTime.GetServerNowTimestamp() + local during = now - _LastRequestTime + local offset = CollectWordsRequestWordCd - during + if offset < 0 then + offset = 0 + end + return offset + end + + function XSpringFestivalActivityManager.CheckCanGetCollectWordsReward(type) + if type == XSpringFestivalActivityConfigs.CollectWordsRewardType.Final then + return XSpringFestivalActivityManager.GetCanRecvFinalRewardTimes() > 0 + end + + if XSpringFestivalActivityManager.CheckRewardIsMaxCount(type) then + return false + end + + local costItemList = XSpringFestivalActivityConfigs.GetCollectWordsRewardCostItemList(type) + local costItemCount = XSpringFestivalActivityConfigs.GetCollectWordsRewardCostCountList(type) + local need = 0 + for i = 1, #costItemList do + local itemCount = XDataCenter.ItemManager.GetCount(costItemList[i]) + if itemCount < costItemCount[i] then + need = need + costItemCount[i] - itemCount + end + end + + local universalWordId = XSpringFestivalActivityConfigs.GetWordsItemListByType(XSpringFestivalActivityConfigs.CollectCardType.Universal) + local universalWordCount = 0 + for i = 1, #universalWordId do + universalWordCount = universalWordCount + XDataCenter.ItemManager.GetCount(universalWordId[i].Id) + end + return need == 0 or universalWordCount >= need, need + end + + function XSpringFestivalActivityManager.CheckCanGetRewardWithoutUniversal(type) + local costItemList = XSpringFestivalActivityConfigs.GetCollectWordsRewardCostItemList(type) + local costItemCount = XSpringFestivalActivityConfigs.GetCollectWordsRewardCostCountList(type) + local need = 0 + for i = 1, #costItemList do + local itemCount = XDataCenter.ItemManager.GetCount(costItemList[i]) + if itemCount < costItemCount[i] then + need = need + costItemCount[i] - itemCount + end + end + return need == 0 + end + function XSpringFestivalActivityManager.GetCanRecvFinalRewardTimes() + local min = _CurrRecvRewardInfo[1].AlreadyRecvTimes + return XMath.Clamp(min - _RecvFinalRewardTimes, 0, min) + end + + function XSpringFestivalActivityManager.GetRecvFinalRewardTimes() + return _RecvFinalRewardTimes + end + + function XSpringFestivalActivityManager.CheckHasUnReceiveGift() + for _,giftInfo in pairs(_GiftBoxData) do + if not giftInfo:IsReceive() then + return true + end + end + + return false + end + + + -----------------------集字相关 end---------------------------- + -----------------------砸蛋相关 begin-------------------------- + local ResetEggList = function() + for _, v in pairs(_EggList) do + v.IsBroken = false + end + end + + local UpdateEggListByPlace = function(place, isBroken) + for _, v in pairs(_EggList) do + if v.Place == place then + v.IsBroken = isBroken + end + end + end + + local UpdateLastUseItemData = function(data) + if not data then + return + end + _LastUseItemData.Hammer = data.Hammer == 0 and 1 or data.Hammer + _LastUseItemData.SafetyProtect = data.SafetyProtect + _LastUseItemData.Buff = data.Buff + end + + function XSpringFestivalActivityManager.GetSmashEggsSequenceSuccessCount() + return _SequenceSuccessCount + end + + function XSpringFestivalActivityManager.GetSmashEggsEggList() + return _EggList + end + + function XSpringFestivalActivityManager.GetSmashEggsTodayScore() + return _TodayScore + end + + function XSpringFestivalActivityManager.GetSmashEggsCurrentScore() + return _CurrentScore + end + + function XSpringFestivalActivityManager.GetSmashEggsHighestScore() + return _HighestScore + end + + function XSpringFestivalActivityManager.CheckRewardIsReceive(index) + return 1 << index & _TodayScoreRewardStatus > 0 + end + + function XSpringFestivalActivityManager.GetTodayScoreRewardStatus() + return _TodayScoreRewardStatus + end + + function XSpringFestivalActivityManager.GetCurrHammer() + return _LastUseItemData.Hammer + end + + function XSpringFestivalActivityManager.GetCurrBuffItem() + return _LastUseItemData.Buff + end + + function XSpringFestivalActivityManager.GetCurrSafetyProtect() + return _LastUseItemData.SafetyProtect + end + + function XSpringFestivalActivityManager.CheckIsNeedTip() + return _SequenceSuccessCount >= XSpringFestivalActivityConfigs.GetNeedTipCount() + end + + function XSpringFestivalActivityManager.GetSequenceSuccessCount() + return _SequenceSuccessCount + end + -----------------------砸蛋相关 end---------------------------- + -----------------------活动相关 begin-------------------------- + + function XSpringFestivalActivityManager.IsOpen() + local isOpen = XFunctionManager.CheckInTimeByTimeId(XSpringFestivalActivityConfigs.GetSpringFestivalActivityTimeId()) + if not isOpen then + XUiManager.TipText("SpringFestivalNotOpen") + end + return isOpen + end + + function XSpringFestivalActivityManager.IsActivityEnd() + local endTime = XSpringFestivalActivityManager.GetActivityEndTime() + local now = XTime.GetServerNowTimestamp() + return now >= endTime + end + + function XSpringFestivalActivityManager.IsActivityStart() + local startTime = XSpringFestivalActivityManager.GetActivityStartTime() + local now = XTime.GetServerNowTimestamp() + return now >= startTime + end + + function XSpringFestivalActivityManager.OpenActivityMain() + if XSpringFestivalActivityManager.IsOpen() then + XLuaUiManager.Open("UiFubenSpringFestivalChapter") + else + end + end + + function XSpringFestivalActivityManager.OpenMainWithClose() + if XSpringFestivalActivityManager.IsOpen() then + XLuaUiManager.PopThenOpen("UiFubenSpringFestivalChapter") + else + end + end + + function XSpringFestivalActivityManager.GetSmashEggsActivityDay() + local smashActivityTimeId = XSpringFestivalActivityConfigs.GetSpringFestivalActivityTimeId() + local now = XTime.GetServerNowTimestamp() + local startTime = XFunctionManager.GetStartTimeByTimeId(smashActivityTimeId) + return math.ceil((now-startTime) / (3600 * 24)) + end + + function XSpringFestivalActivityManager.OnActivityEnd() + if CS.XFight.IsRunning or XLuaUiManager.IsUiLoad("UiLoading") or XLuaUiManager.IsUiLoad("UiSettleLose") or XLuaUiManager.IsUiLoad("UiSettleWin") then + return + end + XUiManager.TipText("SpringFestivalOver") + XLuaUiManager.RunMain() + end + + function XSpringFestivalActivityManager.GetActivityStartTime() + local timeId = XSpringFestivalActivityConfigs.GetSpringFestivalActivityTimeId() + return XFunctionManager.GetStartTimeByTimeId(timeId) + end + + function XSpringFestivalActivityManager.GetActivityEndTime() + local timeId = XSpringFestivalActivityConfigs.GetSpringFestivalActivityTimeId() + return XFunctionManager.GetEndTimeByTimeId(timeId) + end + + function XSpringFestivalActivityManager.GetActivityChapter() + local chapter = {} + if XSpringFestivalActivityManager.IsOpen() then + local tempChapter = {} + tempChapter.Id = XSpringFestivalActivityConfigs.GetSpringFestivalActivityId() + tempChapter.Type = XDataCenter.FubenManager.ChapterType.SpringFestivalActivity + tempChapter.BannerBg = XSpringFestivalActivityConfigs.GetSpringFestivalActivityBg() + tableInsert(chapter, tempChapter) + end + return chapter + end + -----------------------活动相关 end---------------------------- + -----------------------数据相关 begin---------------------------- + local function UpdateRequestWordList(requestList) + _FriendRequestList = {} + for _, requestInfo in pairs(requestList) do + local temp = XSpringFestivalFriendRequestInfo.New(requestInfo) + tableInsert(_FriendRequestList, temp) + end + end + + function XSpringFestivalActivityManager.GetFriendRequestList() + return _FriendRequestList + end + + function XSpringFestivalActivityManager.GetFriendRequestByType(type) + local requestList = {} + for _, info in pairs(_FriendRequestList) do + if info:GetFromType() == type then + tableInsert(requestList, info) + end + end + return requestList + end + + function XSpringFestivalActivityManager.GetFriendRequestInfoByIndex(index) + return _FriendRequestList[index] + end + + -----------------------数据相关 end------------------------------ + -----------------------推送相关 begin---------------------------- + local UpdateCurrActivityId = function(Id) + _CurrActivityId = Id or _CurrActivityId + end + + local UpdateGetRewardInfo = function(data) + if not data then + return + end + _CurrRecvRewardInfo = data + table.sort(_CurrRecvRewardInfo, function(a, b) + return a.AlreadyRecvTimes < b.AlreadyRecvTimes + end) + end + + local UpdateRecvFinalRewardTimes = function(times) + if not times then + return + end + _RecvFinalRewardTimes = times + end + + local function UpdateGiftBoxData(data) + if not data then + return + end + _GiftBoxData = {} + + for _, v in pairs(data) do + local temp = XSpringFestivalBoxGift.New(v) + tableInsert(_GiftBoxData, temp) + end + tableSort(_GiftBoxData,function(a,b) + if a:IsReceive() ~= b:IsReceive() then + return not a:IsReceive() + end + end) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_SPRING_FESTIVAL_GIFT_BAG_REFRESH) + end + + local function SetAllGiftReceived() + for _, v in pairs(_GiftBoxData) do + v:SetReceive(true) + end + end + + local function UpdateRequestWordData(data) + if not data then + return + end + _RequestWordId = data.WordId or _RequestWordId + _LastRequestTime = data.LastRequestTime or _LastRequestTime + _LastSendGuildRequestTime = data.LastSendGuildRequestTime or _LastSendGuildRequestTime + end + + function XSpringFestivalActivityManager.NotifyCollectWordsActivityData(data) + if not data then + return + end + UpdateRecvFinalRewardTimes(data.JackpotRecvRewardTime) + UpdateGetRewardInfo(data.RecvHalfRewardRecordData) + UpdateCurrActivityId(data.ActivityId) + UpdateGiftBoxData(data.GiftBoxData) + UpdateRequestWordData(data.RequestWordData) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_SPRING_FESTIVAL_COLLECT_CARD_REFRESH) + end + + function XSpringFestivalActivityManager.NotifyRecvHalfRewardRecordInfo(data) + if not data then + return + end + UpdateRecvFinalRewardTimes(data.JackpotRecvRewardTime) + UpdateGetRewardInfo(data.RecvHalfRewardRecordData) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_SPRING_FESTIVAL_COLLECT_CARD_REFRESH) + end + + function XSpringFestivalActivityManager.NotifyCollectWordsRequestInfoChange(data) + if not data then return end + UpdateRequestWordData(data.RequestWordData) + end + + function XSpringFestivalActivityManager.NotifyRecvGiftFromOther(data) + if not data and not data.GiftData then + return + end + for i = 1,#data.GiftData do + local giftData = XSpringFestivalBoxGift.New(data.GiftData[i]) + tableInsert(_GiftBoxData, giftData) + if #_GiftBoxData > CollectWordsGiftBoxMaxCount then + local min = XTime.GetServerNowTimestamp() + local index = 0 + for i = 1, #_GiftBoxData do + if min > _GiftBoxData[i]:GetTime() then + min = _GiftBoxData[i]:GetTime() + index = i + end + end + tableRemove(_GiftBoxData,index) + end + end + tableSort(_GiftBoxData,function(a,b) + if a:IsReceive() ~= b:IsReceive() then + return not a:IsReceive() + end + end) + XEventManager.DispatchEvent(XEventId.EVENT_SPRING_FESTIVAL_GIFT_BAG_RED) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_SPRING_FESTIVAL_GIFT_BAG_REFRESH) + end + + function XSpringFestivalActivityManager.NotifySmashEggsActivityData(data) + if not data then + return + end + _SequenceSuccessCount = data.SequenceSuccessCount or _SequenceSuccessCount + _EggList = data.EggsData or _EggList + _TodayScore = data.TodayScore or _TodayScore + _CurrentScore = data.CurrentScore or _CurrentScore + _HighestScore = data.HighestScore or _HighestScore + _TodayScoreRewardStatus = data.TodayScoreRewardStatus or _TodayScoreRewardStatus + UpdateLastUseItemData(data.LastUseItemData) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_SPRING_FESTIVAL_SMASH_EGGS_REFRESH) + end + + function XSpringFestivalActivityManager.NotifySmashEggsActivityDailyReset(data) + if not data then + return + end + _TodayScoreRewardStatus = data.TodayScoreRewardStatus or _TodayScoreRewardStatus + _TodayScore = data.TodayScore or _TodayScore + CsXGameEventManager.Instance:Notify(XEventId.EVENT_SPRING_FESTIVAL_SMASH_EGGS_REFRESH) + end + -----------------------推送相关 end---------------------------- + -----------------------请求相关 begin---------------------------- + --送字给好友或公会成员请求 + function XSpringFestivalActivityManager.CollectWordsGiveWordToOthersRequest(wordId, otherId,isRequest, callback) + local count = XDataCenter.ItemManager.GetCount(wordId) + if count == 0 then + XUiManager.TipText("SpringFestivalItemCantSend") + return + end + local request = { WordId = wordId, OtherId = otherId,IsRequest = isRequest } + XNetwork.Call("CollectWordsGiveWordToOthersRequest", request, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + if callback then + callback(res.RewardGoodsList) + end + end) + end + --领取上下阕奖励请求 + function XSpringFestivalActivityManager.CollectWordsRecvRewardRequest(type, callback) + local request = { Type = type } + XNetwork.Call("CollectWordsRecvRewardRequest", request, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + CsXGameEventManager.Instance:Notify(XEventId.EVENT_SPRING_FESTIVAL_COLLECT_CARD_REFRESH) + if callback then + callback(res.RewardGoodsList) + end + end) + end + -- 领取终极大奖奖励请求 + function XSpringFestivalActivityManager.CollectWordsRecvGrandPrizeRewardRequest(callback) + XNetwork.Call("CollectWordsRecvGrandPrizeRewardRequest", nil, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + if callback then + callback(res.RewardGoodsList) + end + end) + end + + --更新求字请求 + function XSpringFestivalActivityManager.CollectWordsRequestWordRequest(wordId, callback) + local request = { WordId = wordId } + XNetwork.Call("CollectWordsRequestWordRequest", request, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + UpdateRequestWordData(res.RequestWordInfo) + if XDataCenter.GuildManager.IsJoinGuild() then + local chatData = { + ChannelType = ChatChannelType.Guild, + MsgType = ChatMsgType.SpringFestival, + Content = CS.XTextManager.GetText("SpringFestivalCollectCardGuildHelp", XDataCenter.ItemManager.GetItemName(XSpringFestivalActivityManager.GetRequestWordId())), + TargetIds = { XPlayer.Id } + } + XDataCenter.ChatManager.SendChat(chatData, function() + if callback then + callback() + end + end) + else + if callback then + callback() + end + end + + end) + end + + function XSpringFestivalActivityManager.CollectWordsRequestWordToFriendRequest(friendId, callback) + local request = { FriendId = friendId } + XNetwork.Call("CollectWordsRequestWordToFriendRequest", request, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + if callback then + callback() + end + end) + end + + --向公会求字请求 + function XSpringFestivalActivityManager.CollectWordsRequestWordToGuildRequest(callback) + XNetwork.Call("CollectWordsRequestWordToGuildRequest", nil, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + local chatData = { + ChannelType = ChatChannelType.Guild, + MsgType = ChatMsgType.SpringFestival, + Content = CS.XTextManager.GetText("SpringFestivalCollectCardGuildHelp", XDataCenter.ItemManager.GetItemName(XSpringFestivalActivityManager.GetRequestWordId())), + TargetIds = { XPlayer.Id } + } + XDataCenter.ChatManager.SendChat(chatData, function() + if callback then + callback() + end + end) + end) + end + + --一键领取礼物盒中的礼物请求 + function XSpringFestivalActivityManager.CollectWordsRecvWordGiftFromGiftBoxRequest(callback) + XNetwork.Call("CollectWordsRecvWordGiftFromGiftBoxRequest", nil, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + SetAllGiftReceived() + CsXGameEventManager.Instance:Notify(XEventId.EVENT_SPRING_FESTIVAL_COLLECT_CARD_REFRESH) + if callback then + callback() + end + end) + end + + function XSpringFestivalActivityManager.CollectWordsRefreshRequestWordListRequest(callback) + XNetwork.Call("CollectWordsRefreshRequestWordListRequest", nil, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + UpdateRequestWordList(res.RequestList) + if callback then + callback() + end + end) + end + + function XSpringFestivalActivityManager.SmashEggRequest(eggPlace, useItem, callback) + local request = { + EggPlace = eggPlace, + UseItemData = useItem + } + XNetwork.Call("SmashEggRequest", request, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + CsXGameEventManager.Instance:Notify(XEventId.EVENT_SPRING_FESTIVAL_SMASH_EGGS_REFRESH) + if callback then + callback(res.IsSuccess, res.DropItem, res.AddScore) + end + end) + end + + function XSpringFestivalActivityManager.SmashEggsGetActivationDailyRewardRequest(index, callback) + local request = { + StageIndex = index + } + XNetwork.Call("SmashEggsGetActivationDailyRewardRequest", request, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + _TodayScoreRewardStatus = res.TodayScoreRewardStatus or _TodayScoreRewardStatus + CsXGameEventManager.Instance:Notify(XEventId.EVENT_SPRING_FESTIVAL_SMASH_EGGS_REFRESH) + if callback then + callback(res.RewardList) + end + end) + end + + function XSpringFestivalActivityManager.SmashEggsConvertScoreRequest(callback) + XNetwork.Call("SmashEggsConvertScoreRequest", nil, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + _CurrentScore = 0 + _SequenceSuccessCount = 0 + CsXGameEventManager.Instance:Notify(XEventId.EVENT_SPRING_FESTIVAL_SMASH_EGGS_REFRESH) + if callback then + callback() + end + end) + end + + function XSpringFestivalActivityManager.SmashEggsResetEggsRequest(list, callback) + local request = { + ResetList = list + } + XNetwork.Call("SmashEggsResetEggsRequest", request, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + ResetEggList() + if callback then + callback() + end + end) + end + + -----------------------请求相关 end---------------------------- + return XSpringFestivalActivityManager +end + +-----------------------协议相关 begin---------------------------- +XRpc.NotifyCollectWordsActivityData = function(data) + XDataCenter.SpringFestivalActivityManager.NotifyCollectWordsActivityData(data) +end + +XRpc.NotifyCollectWordsRequestInfoChange = function(data) + XDataCenter.SpringFestivalActivityManager.NotifyCollectWordsRequestInfoChange(data) +end + +XRpc.NotifyRecvHalfRewardRecordInfo = function(data) + XDataCenter.SpringFestivalActivityManager.NotifyRecvHalfRewardRecordInfo(data) +end + +XRpc.NotifyRecvGiftFromOther = function(data) + XDataCenter.SpringFestivalActivityManager.NotifyRecvGiftFromOther(data) +end + +XRpc.NotifySmashEggsActivityData = function(data) + XDataCenter.SpringFestivalActivityManager.NotifySmashEggsActivityData(data) +end + +XRpc.NotifySmashEggsActivityDailyReset = function(data) + XDataCenter.SpringFestivalActivityManager.NotifySmashEggsActivityDailyReset(data) +end +-----------------------协议相关 end---------------------------- diff --git a/Resources/Scripts/XManager/XStoryManager.lua b/Resources/Scripts/XManager/XStoryManager.lua new file mode 100644 index 00000000..422090de --- /dev/null +++ b/Resources/Scripts/XManager/XStoryManager.lua @@ -0,0 +1,30 @@ +XStoryManagerCreator = function() + + local XStoryManager = {} + + function XStoryManager.Init() + -- CsXGameEventManager.Instance:RegisterEvent(CS.XEventId.EVENT_STOP_MOVIE, function(evt,args,...) + -- local storyId = args[0] + -- XStoryManager.FinishStory(storyId) + -- end) + + -- CsXGameEventManager.Instance:RegisterEvent(CS.XEventId.EVENT_PLAY_MOVIE, function(evt,args, ...) + -- local storyId = args[0] + -- XStoryManager.StartStory(storyId) + -- end) + end + + + -- function XStoryManager.StartStory(storyId) + -- XNetwork.Send("StartStoryRequest", { StoryId = storyId }) + -- end + + -- function XStoryManager.FinishStory(storyId, cb) + -- XNetwork.Send("FinishStoryRequest", { StoryId = storyId }) + -- end + + + XStoryManager.Init() + + return XStoryManager +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XStrongholdManager.lua b/Resources/Scripts/XManager/XStrongholdManager.lua new file mode 100644 index 00000000..340d7797 --- /dev/null +++ b/Resources/Scripts/XManager/XStrongholdManager.lua @@ -0,0 +1,2905 @@ +local XStrongholdMineRecord = require("XEntity/XStronghold/XStrongholdMineRecord") +local XStrongholdGroupInfo = require("XEntity/XStronghold/XStrongholdGroupInfo") +local XStrongholdTeam = require("XEntity/XStronghold/XStrongholdTeam") +local XStrongholdAssistantRecord = require("XEntity/XStronghold/XStrongholdAssistantRecord") +local _ActivityTimer + +XStrongholdManagerCreator = function() + local tableInsert = table.insert + local tableSort = table.sort + local tableRemove = table.remove + local tonumber = tonumber + local mathFloor = math.floor + local mathMax = math.max + local mathCeil = math.ceil + local ipairs = ipairs + local pairs = pairs + local CsXTextManagerGetText = CsXTextManagerGetText + local stringFormat = string.format + local stringIsNilOrEmpty = string.IsNilOrEmpty + local IsNumberValid = XTool.IsNumberValid + local IsTableEmpty = XTool.IsTableEmpty + local Clone = XTool.Clone + + local XStrongholdManager = {} + -----------------功能入口 begin---------------- + local ACTIVITY_STATUS = { + DEFAULT = 0, --未开启 + ACTIVITY_BEGIN = 1, --开启中 + FIGHT_BEGIN = 2, --战斗开启 + FIGHT_END = 3, --战斗结束 + ACTIVITY_END = 4, --已结束 + } + + local _ActivityStatus = ACTIVITY_STATUS.DEFAULT --活动状态 + local _ActivityId = 0 --活动期数 + local _BeginTime = 0 --活动开启时间 + local _FightBeginTime = 0 --挑战开启时间 + local _FightAutoBeginTime = 0 --挑战自动开启时间 + local _FightEndTime = 0 --挑战结束时间 + local _EndTime = 0 --活动结束时间 + local _CurDay = 0 --当前天数(挑战开始后) + local _TotalDay = 0 --挑战总天数(挑战开始后) + local _ActivityEnd = false --活动是否重置 + + local function ClearActivityTimer() + if _ActivityTimer then + XScheduleManager.UnSchedule(_ActivityTimer) + _ActivityTimer = nil + end + end + + local UpdateActivityStatus + UpdateActivityStatus = function() + local leftTime = 0 --距离下一阶段剩余时间 + XCountDown.RemoveTimer(XCountDown.GTimerName.Stronghold) + + --活动未开启 + if not IsNumberValid(_BeginTime) + or not IsNumberValid(_ActivityId) + then + _ActivityStatus = ACTIVITY_STATUS.DEFAULT + leftTime = 0 + end + + local nowTime = XTime.GetServerNowTimestamp() + + if not IsNumberValid(_FightBeginTime) then + + --活动开启中,等待挑战开始(手动第一次战斗后记录开启挑战时间) + local lastTime = XStrongholdConfigs.GetActivityFightAutoBeginSeconds(_ActivityId) + _FightAutoBeginTime = _BeginTime + lastTime + + leftTime = _FightAutoBeginTime - nowTime + if leftTime > 0 then + _ActivityStatus = ACTIVITY_STATUS.ACTIVITY_BEGIN + else + _ActivityStatus = ACTIVITY_STATUS.ACTIVITY_END + end + + else + + local lastTime = XStrongholdConfigs.GetActivityFightContinueSeconds(_ActivityId) + _FightEndTime = _FightBeginTime + lastTime + if nowTime < _FightEndTime then + --挑战开启中 + _ActivityStatus = ACTIVITY_STATUS.FIGHT_BEGIN + leftTime = _FightEndTime - nowTime + + elseif nowTime < _EndTime then + --挑战已结束 + _ActivityStatus = ACTIVITY_STATUS.FIGHT_END + leftTime = _EndTime - nowTime + + else + --活动已结束 + leftTime = 0 + _ActivityStatus = ACTIVITY_STATUS.ACTIVITY_END + + end + + end + + XCountDown.RemoveTimer(XCountDown.GTimerName.Stronghold) + XCountDown.CreateTimer(XCountDown.GTimerName.Stronghold, leftTime) + + ClearActivityTimer() + + if leftTime > 0 then + _ActivityTimer = XScheduleManager.ScheduleOnce(function() + UpdateActivityStatus() + end, leftTime * XScheduleManager.SECOND) + end + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_STRONGHOLD_ACTIVITY_STATUS_CHANGE) + XEventManager.DispatchEvent(XEventId.EVENT_STRONGHOLD_ACTIVITY_STATUS_CHANGE) + + end + + local function UpdateActivityInfo(activityId, beginTime, fightBeginTime) + _ActivityId = activityId + _BeginTime = beginTime + _FightBeginTime = fightBeginTime + _EndTime = _BeginTime + XStrongholdConfigs.GetActivityOneCycleSeconds(_ActivityId) + _TotalDay = XStrongholdConfigs.GetActivityFightTotalDay(activityId) + end + + local function UpdateCurDay(data, fightBeginTime) + if not data then return end + + local totalDay = XStrongholdManager.GetTotalDay() + _CurDay = data <= totalDay and data or _CurDay + _FightBeginTime = fightBeginTime or _FightBeginTime + + UpdateActivityStatus() + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_STRONGHOLD_CUR_DAY_CHANGE) + end + + local function CheckActivityReset(activityId) + return IsNumberValid(_ActivityId) + and _ActivityId ~= activityId + end + + function XStrongholdManager.ClearActivityEnd() + _ActivityEnd = nil + end + + function XStrongholdManager.OnActivityEnd() + if not _ActivityEnd then return false end + + if CS.XFight.IsRunning or XLuaUiManager.IsUiLoad("UiLoading") then + return false + end + + --延迟是为了防止打断UI动画 + XScheduleManager.ScheduleOnce(function() + XUiManager.TipText("ActivityBranchOver") + XLuaUiManager.RunMain() + end, 1000) + + XStrongholdManager.ClearActivityEnd() + + return true + end + + --活动开启 + function XStrongholdManager.IsOpen() + return _ActivityStatus ~= ACTIVITY_STATUS.DEFAULT and _ActivityStatus ~= ACTIVITY_STATUS.ACTIVITY_END + end + + --挑战开始前 + function XStrongholdManager.IsActivityBegin() + return _ActivityStatus == ACTIVITY_STATUS.ACTIVITY_BEGIN + end + + --挑战开始 + function XStrongholdManager.IsFightBegin() + return _ActivityStatus == ACTIVITY_STATUS.FIGHT_BEGIN + end + + --挑战结束 + function XStrongholdManager.IsFightEnd() + return _ActivityStatus == ACTIVITY_STATUS.FIGHT_END + end + + --活动结束 + function XStrongholdManager.IsEnd() + return not XStrongholdManager.IsOpen() + end + + function XStrongholdManager.CheckActivityStatus(status) + return IsNumberValid(status) and status == _ActivityStatus + end + + function XStrongholdManager.GetStartTime() + if not IsNumberValid(_BeginTime) then + return XStrongholdConfigs.GetActivityDefaultOpenTime() + end + + return _BeginTime + end + + function XStrongholdManager.GetEndTime() + if not IsNumberValid(_BeginTime) then + return XStrongholdConfigs.GetActivityDefaultEndTime() + end + + return _EndTime + end + + --获取挑战时间 + function XStrongholdManager.GetFightTime() + return _FightBeginTime, _FightEndTime + end + + --获取挑战自动开启时间 + function XStrongholdManager.GetFightAutoBeginTime() + return _FightAutoBeginTime + end + + function XStrongholdManager.GetCurDay() + return _CurDay + end + + function XStrongholdManager.GetTotalDay() + return _TotalDay + end + + --获取每日结算时间 HH:mm + function XStrongholdManager.GetCountTimeStr() + local fightBeginTime = XStrongholdManager.GetFightTime() + if not IsNumberValid(fightBeginTime) then return "" end + return XTime.TimestampToGameDateTimeString(fightBeginTime, "HH:mm") + end + + --获取延后结算时间 X月X日HH:mm + function XStrongholdManager.GetDelayCountTimeStr() + local fightBeginTime = XStrongholdManager.GetFightTime() + local countDay = XStrongholdManager.GetCurDay() + XStrongholdManager.GetDelayDays() + local countTime = fightBeginTime + countDay * 3600 * 24 + return XTime.TimestampToGameDateTimeString(countTime, CsXTextManagerGetText("StrongholdTimeFormat")) + end + + function XStrongholdManager.EnterUiMain(beforeOpenUiCb) + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.Stronghold) then return end + + if not XStrongholdManager.IsOpen() then + XUiManager.TipText("StrongholdActivityNotOpen") + return + end + + local callFunc = function() + if beforeOpenUiCb then + beforeOpenUiCb(function() + XLuaUiManager.Open("UiStrongholdMain") + end) + else + XLuaUiManager.Open("UiStrongholdMain") + end + end + + if not XStrongholdManager.IsSelectedLevelId() then + XLuaUiManager.Open("UiStrongholdChooseLevelType", callFunc) + else + callFunc() + end + end + -----------------功能入口 end------------------ + -----------------矿场相关 begin------------------ + local _TotalMineral = 0 --历史累计矿石数量 + local _MineralLeft = 0 --可领矿石 + local _MinerItemId = 0 --矿工物品Id + local _MineralItemId = 0 --矿石物品Id + local _MinerEfficiency = 0 --矿工效率 + local _MinerGrowRate = 0 --矿工增殖百分比 + local _MineRecords = {} --产出记录 + local _MineRecordSynDic = {} --产出历史记录(服务端同步) + local _OldMineralItemCount = 0 --缓存旧的矿石物品数量 + local _OldTotalMineralCount = 0 --缓存旧的预期总产出 + local _BatteryItemId = 0 --电池道具Id + + + local function InitMine() + _MinerItemId = XStrongholdConfigs.GetCommonConfig("MinerId") + _MineralItemId = XStrongholdConfigs.GetCommonConfig("MineralId") + _MinerEfficiency = XStrongholdConfigs.GetCommonConfig("MinerEfficiency") + _MinerGrowRate = XStrongholdConfigs.GetCommonConfig("MinerGrowRate") + _BatteryItemId = XStrongholdConfigs.GetCommonConfig("BatteryItemId") + end + + local function UpdateTotalMineral(data) + if not data then return end + _TotalMineral = data + end + + local function UpdateMineralLeft(data) + if not data then return end + _MineralLeft = data + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_STRONGHOLD_MINERAL_LEFT_CHANGE) + end + + local function GetMineRecord(day) + local record = _MineRecords[day] + if not record then + record = XStrongholdMineRecord.New(day) + _MineRecords[day] = record + end + return record + end + + local function CalcMineRecords() + local totalMineralCount = 0 + local totalDay = XStrongholdManager.GetTotalDay() + for day = 1, totalDay do + local minerCount, mineralCount = 0, 0 + + local synRecord = _MineRecordSynDic[day] + if synRecord then + minerCount = synRecord.MinerCount + mineralCount = synRecord.MineralCount + else + minerCount = XStrongholdManager.GetPredictMinerCount(day) + mineralCount = XStrongholdManager.GetPredictMineralCount(day) + end + + totalMineralCount = totalMineralCount + mineralCount + + local record = GetMineRecord(day) + record:UpdateData(minerCount, mineralCount, totalMineralCount) + end + end + + local function UpdateMineRecords(data) + _MineRecordSynDic = {} + for _, synRecord in pairs(data or {}) do + local synDay = synRecord.Day + _MineRecordSynDic[synDay] = synRecord + end + + CalcMineRecords() + CsXGameEventManager.Instance:Notify(XEventId.EVENT_STRONGHOLD_MINERAL_RECORD_CHANGE) + end + + function XStrongholdManager.HasMineralLeft() + if not XStrongholdManager.IsOpen() + or XStrongholdManager.IsFightEnd() + then + return false + end + + return _MineralLeft > 0 + end + + function XStrongholdManager.EnterUiMine() + XLuaUiManager.Open("UiStrongholdMining") + end + + function XStrongholdManager.GetMinerItemId() + return _MinerItemId + end + + --获取当前矿工人数 + function XStrongholdManager.GetMinerCount() + return XDataCenter.ItemManager.GetCount(_MinerItemId) + end + + --预期矿工人数 = 当前矿工人数 + 当前矿工人数 * 增殖百分比 + function XStrongholdManager.GetPredictMinerCount(day) + local predictMinerCount = XStrongholdManager.GetMinerCount() + + local curDay = XStrongholdManager.GetCurDay() + day = day or curDay + + --修改为由矿产日志最后一次记录开始推算 + local lastRecordDay = curDay + for i = 1, day do + if not _MineRecordSynDic[i] then + lastRecordDay = i + break + end + end + + for i = lastRecordDay, day - 1 do + predictMinerCount = mathCeil(predictMinerCount + predictMinerCount * _MinerGrowRate * 0.01) + end + + return predictMinerCount + end + + --预期矿产数 + function XStrongholdManager.GetPredictMineralCount(day) + day = day or XStrongholdManager.GetCurDay() + local predictMinerCount = XStrongholdManager.GetPredictMinerCount(day) + return XStrongholdManager.GetMineralOutput(predictMinerCount) + end + + --获取上一次查看的矿工人数 + function XStrongholdManager.GetCookieMinerCount() + local key = XStrongholdManager.GetMinerCountCookieKey() + return XSaveTool.GetData(key) or 0 + end + + function XStrongholdManager.SetCookieMinerCount(count) + local key = XStrongholdManager.GetMinerCountCookieKey() + XSaveTool.SaveData(key, count) + end + + function XStrongholdManager.ClearCookieMinerCount() + local key = XStrongholdManager.GetMinerCountCookieKey() + XSaveTool.RemoveData(key) + end + + function XStrongholdManager.GetMinerCountCookieKey() + if not IsNumberValid(_ActivityId) then return end + return XPlayer.Id .. _ActivityId .. "_XStrongholdManager_CookieMinerCount" + end + + function XStrongholdManager.GetMineralItemId() + return _MineralItemId + end + + function XStrongholdManager.GetMineralCount() + return XDataCenter.ItemManager.GetCount(_MinerItemId) + end + + function XStrongholdManager.GetTotalMineralCount() + return _TotalMineral or 0 + end + + function XStrongholdManager.GetTotalMinerEfficiency() + return _MinerEfficiency or 0 + end + + function XStrongholdManager.GetTotalMinerGrowRate() + return _MinerGrowRate or 0 + end + + --产出矿石 = 矿工数量 * 矿工效率(向上取整) + function XStrongholdManager.GetMineralOutput(minerCount) + minerCount = minerCount or XStrongholdManager.GetMinerCount() + return mathCeil(minerCount * _MinerEfficiency) + end + + function XStrongholdManager.GetMineRecordsForShow() + local showRecords = {} + CalcMineRecords()--修改为获取时实时计算 + + for _, record in ipairs(_MineRecords) do + local showRecord = {} + showRecord.Day = record:GetDay() + showRecord.MinerCount = record:GetMinerCount() + showRecord.MineralCount = record:GetMineralCount() + showRecord.TotalMineralCount = record:GetTotalMineralCount() + + tableInsert(showRecords, showRecord) + end + + return showRecords + end + + --预期总产出 = 矿产记录最后一天总产出 + function XStrongholdManager.GetPredictTotalMineralCount() + CalcMineRecords()--修改为获取时实时计算 + local totalDay = XStrongholdManager.GetTotalDay() + local record = GetMineRecord(totalDay) + return record:GetTotalMineralCount() + end + + function XStrongholdManager.NotifyStrongholdTotalMineral(data) + UpdateTotalMineral(data.TotalMineral) + end + + --领取矿石 + function XStrongholdManager.GetStrongholdMineralRequest(cb) + XNetwork.Call("GetStrongholdMineralRequest", nil, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + UpdateMineralLeft(0) + + local mineralCount = res.MineralCount + if cb then cb(mineralCount) end + end) + end + + function XStrongholdManager.CatchOldMineralItemCount(itemCount) + _OldMineralItemCount = itemCount + end + + function XStrongholdManager.GetOldItemCount() + return _OldMineralItemCount + end + + function XStrongholdManager.CatchOldTotalMineralCount() + _OldTotalMineralCount = XStrongholdManager.GetPredictTotalMineralCount() + end + + function XStrongholdManager.GetOldTotalMineralCount() + return _OldTotalMineralCount + end + -----------------矿场相关 end------------------ + -----------------电场相关 begin------------------ + local _MaxElectricEnergy = 0 --电能上限 + local _ElectricTeamMaxCharacterNum = 0 --电能队伍最大人数 + local _ElectricCharacterIdDic = {} --电能队伍 + + local function IniElectric() + _ElectricTeamMaxCharacterNum = XStrongholdConfigs.GetCommonConfig("MaxElectricTeamMemberCount") + end + + local function UpdateElectricEnergy(data) + _MaxElectricEnergy = data or _MaxElectricEnergy + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_STRONGHOLD_MAX_ELECTRIC_CHANGE) + end + + local function UpdateElectricCharacters(data) + _ElectricCharacterIdDic = {} + + local count = 0 + for _, characterId in ipairs(data or {}) do + if count > _ElectricTeamMaxCharacterNum then + XLog.Error("XStrongholdManager UpdateElectricCharacters error: 同步电能队伍数据出错,超出最大队伍人数上限: " .. _ElectricTeamMaxCharacterNum .. ", data: ", data) + break + end + + if characterId > 0 then + _ElectricCharacterIdDic[characterId] = characterId + count = count + 1 + end + end + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_STRONGHOLD_MAX_ELECTRIC_CHANGE) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_STRONGHOLD_ELECTRIC_CHARACTER_CHANGE) + end + + function XStrongholdManager.GetMaxElectricEnergy() + return _MaxElectricEnergy + end + + --电能队伍战力达到要求后会额外增加电能上限 + function XStrongholdManager.GetExtraElectricEnergy() + local totalAbility = XStrongholdManager.GetElectricCharactersTotalAbility() + return XStrongholdConfigs.GetTeamAbilityToExtraElectric(totalAbility) + end + + function XStrongholdManager.GetTotalElectricEnergy() + return _MaxElectricEnergy + XStrongholdManager.GetExtraElectricEnergy() + end + + function XStrongholdManager.GetAddElectricEnergy() + local day = XStrongholdManager.GetCurDay() + local levelId = XStrongholdManager.GetLevelId() + + if XStrongholdManager.IsAnyDayPaused() then + --暂停时获取电能上限累积 + local totalCount = 0 + local totalDay = XStrongholdManager.GetTotalDay() + local isContinuePaused = false + for countDay = 1, totalDay do + if XStrongholdManager.IsDayPaused(countDay) then + isContinuePaused = true + totalCount = totalCount + XStrongholdConfigs.GetElectricAdd(countDay, levelId) + else + if isContinuePaused then + isContinuePaused = false + totalCount = totalCount + XStrongholdConfigs.GetElectricAdd(countDay, levelId) + end + end + end + return totalCount + else + return XStrongholdConfigs.GetElectricAdd(day, levelId) + end + end + + --检查已使用电能是否溢出 + function XStrongholdManager.CheckElectricOverLimit(cancelCharacterId, teamList) + local totalElectric = 0 + if IsNumberValid(cancelCharacterId) then + --撤回电能支援队员时电力减少值 + local ability = XDataCenter.CharacterManager.GetCharacterAbilityById(cancelCharacterId) + local totalAbility = XStrongholdManager.GetElectricCharactersTotalAbility() - ability + totalElectric = XStrongholdConfigs.GetTeamAbilityToExtraElectric(totalAbility) + _MaxElectricEnergy + else + totalElectric = XStrongholdManager.GetTotalElectricEnergy() + end + + local useElectric = XStrongholdManager.GetTotalUseElectricEnergy(teamList) + return useElectric > totalElectric + end + + --获取电能队伍总战力 + function XStrongholdManager.GetElectricCharactersTotalAbility() + local totalAbility = 0 + for _, characterId in pairs(_ElectricCharacterIdDic) do + local ability = XDataCenter.CharacterManager.GetCharacterAbilityById(characterId) + totalAbility = totalAbility + ability + end + return totalAbility + end + + --获取可上阵电能支援角色 + function XStrongholdManager.GetCanElectricCharacters(characterType) + local characterList = XDataCenter.CharacterManager.GetOwnCharacterList(characterType) + tableSort(characterList, function(a, b) + --电能支援 + local aIsElectric = XStrongholdManager.CheckInElectricTeam(a.Id) + local bIsElectric = XStrongholdManager.CheckInElectricTeam(b.Id) + if aIsElectric ~= bIsElectric then + return aIsElectric + end + + --已经上阵 + local aIsInTeam = XStrongholdManager.CheckInTeamList(a.Id) + local bIsInTeam = XStrongholdManager.CheckInTeamList(b.Id) + if aIsInTeam ~= bIsInTeam then + return not aIsInTeam + end + + return false + end) + + return characterList + end + + function XStrongholdManager.GetCookieElectricEnergy() + local key = XStrongholdManager.GetElectricEnergyCookieKey() + return XSaveTool.GetData(key) or 0 + end + + function XStrongholdManager.SetCookieElectricEnergy(count) + local key = XStrongholdManager.GetElectricEnergyCookieKey() + XSaveTool.SaveData(key, count) + end + + function XStrongholdManager.ClearCookieElectricEnergy() + local key = XStrongholdManager.GetElectricEnergyCookieKey() + XSaveTool.RemoveData(key) + end + + function XStrongholdManager.GetElectricEnergyCookieKey() + if not IsNumberValid(_ActivityId) then return end + return XPlayer.Id .. _ActivityId .. "_XStrongholdManager_MaxElectricEnergy" + end + + function XStrongholdManager.GetElectricCharacterIds() + local characterIds = {} + for _, characterId in pairs(_ElectricCharacterIdDic) do + tableInsert(characterIds, characterId) + end + return characterIds + end + + function XStrongholdManager.GetElectricTeamMaxCharacterNum() + return _ElectricTeamMaxCharacterNum + end + + function XStrongholdManager.CheckInElectricTeam(characterId) + return _ElectricCharacterIdDic[characterId] and true or false + end + + function XStrongholdManager.CheckElectricMaxNum() + local curNum = 0 + for _, characterId in pairs(_ElectricCharacterIdDic) do + if characterId > 0 then + curNum = curNum + 1 + end + end + local maxNum = XStrongholdManager.GetElectricTeamMaxCharacterNum() + return curNum >= maxNum + end + + --设置电能队伍 + function XStrongholdManager.SetStrongholdElectricTeamRequest(characterIds, cb) + local req = { CharacterIds = characterIds } + XNetwork.Call("SetStrongholdElectricTeamRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + UpdateElectricCharacters(characterIds) + + if cb then cb() end + end) + end + + function XStrongholdManager.GetBatteryItemId() + return _BatteryItemId + end + -----------------电场相关 end------------------ + -----------------耐力相关 begin------------------ + local _Endurance = 0 --耐力值 + + local function UpdateEndurance(data) + _Endurance = data or 0 + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_STRONGHOLD_ENDURANCE_CHANGE) + end + + --当据点为章节关底时,消耗耐力应为之前未通关的关卡数之和 + function XStrongholdManager.GetGroupCostEndurance(groupId) + if XStrongholdManager.IsGroupFinished(groupId) + or XStrongholdManager.CheckGroupHasFinishedStage(groupId) + then return 0 end + + local costEndurance = XStrongholdConfigs.GetGroupCostEndurance(groupId) + + local allGroupIds = {} + + local recurFunc + recurFunc = function(tb) + if IsTableEmpty(tb) then return end + + for _, toFinisheGroupId in pairs(tb) do + if not XStrongholdManager.IsGroupFinished(toFinisheGroupId) then + allGroupIds[toFinisheGroupId] = toFinisheGroupId + end + + local toFinishGroupIds = XStrongholdConfigs.GetGroupFinishRelatedId(toFinisheGroupId) + recurFunc(toFinishGroupIds) + end + end + local toFinishGroupIds = XStrongholdConfigs.GetGroupFinishRelatedId(groupId) + recurFunc(toFinishGroupIds) + + for _, groupId in pairs(allGroupIds) do + costEndurance = costEndurance + XStrongholdConfigs.GetGroupCostEndurance(groupId) + end + + return costEndurance + end + + function XStrongholdManager.GetMaxEndurance() + local curDay = XStrongholdManager.GetCurDay() + local levelId = XStrongholdManager.GetLevelId() + return XStrongholdConfigs.GetMaxEndurance(curDay - 1, levelId) + XStrongholdConfigs.GetLevelInitEndurance(levelId) + end + + function XStrongholdManager.GetMaxLimitEndurance() + local totalDay = XStrongholdManager.GetTotalDay() + local levelId = XStrongholdManager.GetLevelId() + return XStrongholdConfigs.GetMaxEndurance(totalDay, levelId) + XStrongholdConfigs.GetLevelInitEndurance(levelId) + end + + function XStrongholdManager.GetCurEndurance() + return _Endurance + end + + function XStrongholdManager.NotifyStrongholdEnduranceData(data) + UpdateEndurance(data.Endurance) + end + -----------------耐力相关 end------------------ + -----------------据点相关 begin------------------ + local _AllGroupCount = 0--章节据点总数 + local _FinishGroupIdDic = {}--已完成据点Id字典 + local _NewFinishGroupIds = {}--最新完成据点Id列表 + local _GroupInfos = {}--据点信息 + local _CurrentSelectGroupId = 0--当前选择的据点Id,用于检查队伍是否符合条件 + + local function InitGroupInfos() + local groupIds = XStrongholdConfigs.GetAllGroupIds() + + _AllGroupCount = 0 + for _, groupId in pairs(groupIds) do + local groupInfo = XStrongholdGroupInfo.New(groupId) + _GroupInfos[groupId] = groupInfo + _AllGroupCount = _AllGroupCount + 1 + end + end + + local function GetGroupInfo(groupId) + local groupInfo = _GroupInfos[groupId] + if not groupInfo then + XLog.Error("XStrongholdManager GetGroupInfo error, groupId与服务端数据不对应, groupId: ", groupId .. ", _GroupInfos: ", _GroupInfos) + return + end + return groupInfo + end + + local function ResetGroupInfo(groupId, stageId) + if not IsNumberValid(groupId) then return end + local groupInfo = GetGroupInfo(groupId) + + if XTool.IsNumberValid(stageId) then + groupInfo:ResetFinishStage(stageId) + else + groupInfo:ResetFinishStages() + end + end + + local function UpdateGroupStageDatas(data) + if IsTableEmpty(data) then return end + + for _, stageData in pairs(data) do + local groupId = stageData.Id + if not IsNumberValid(groupId) then + XLog.Error("XStrongholdManager UpdateGroupStageDatas error, groupId非法, data: ", data) + end + + local stageIds = stageData.StageIds + local stageBuffIdDic = stageData.StageBuffId + local supportId = stageData.SupportId + local groupInfo = GetGroupInfo(groupId, true) + + if groupInfo then + groupInfo:InitStageData(stageIds, stageBuffIdDic, supportId) + end + end + + XStrongholdManager.InitStageInfo() + end + + local function UpdateGroupInfos(data) + if IsTableEmpty(data) then return end + + for _, groupData in pairs(data) do + local groupId = groupData.Id + local finishStageIds = groupData.FinishStageIds + local groupInfo = GetGroupInfo(groupId) + groupInfo:UpdateFinishStages(finishStageIds) + end + end + + local function UpdateFinishGroupIds(data) + _FinishGroupIdDic = {} + for _, groupId in pairs(data) do + if groupId > 0 then + _FinishGroupIdDic[groupId] = groupId + end + end + + XDataCenter.GuideManager.CheckGuideOpen()--触发新手引导 + CsXGameEventManager.Instance:Notify(XEventId.EVENT_STRONGHOLD_FINISH_GROUP_CHANGE) + end + + local function UpdateNewFinishGroupIds(data) + if IsTableEmpty(data) then return end + + _NewFinishGroupIds = {} + for _, groupId in pairs(data) do + if groupId > 0 + and not _FinishGroupIdDic[groupId] + then + tableInsert(_NewFinishGroupIds, groupId) + end + end + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_STRONGHOLD_NEW_FINISH_GROUP_CHANGE) + end + + function XStrongholdManager.CheckNewFinishGroupIds() + if IsTableEmpty(_NewFinishGroupIds) then return end + + local tipGroupId + local tipLastGroupDebuff = false--配置了StageBuff字段且非关底的据点通过时提示关底被削弱 + local tipNewChapter = false--通过关底据点时提示解锁新章节(此条弹出时忽略上一条提示) + + for _, groupId in pairs(_NewFinishGroupIds) do + if XStrongholdConfigs.IsChapterLastGroupId(groupId) then + tipNewChapter = true + tipGroupId = groupId + break + end + + if XStrongholdConfigs.CheckHasGroupBossBuffId(groupId, _ActivityId) then + tipLastGroupDebuff = true + tipGroupId = groupId + end + end + + if tipNewChapter then + --新章节开启提示 + local chapterId = XStrongholdConfigs.GetChapterIdByGroupId(tipGroupId) + local nextChapterId = XStrongholdConfigs.GetNextChapterId(chapterId) + if nextChapterId then + local chapterName = XStrongholdConfigs.GetChapterName(nextChapterId) + local msg = CsXTextManagerGetText("StrongholdtipNewChapter", chapterName) + XUiManager.TipMsg(msg) + end + + elseif tipLastGroupDebuff then + --关底BUFF削弱提示 + local chapterId = XStrongholdConfigs.GetChapterIdByGroupId(tipGroupId) + local lastGroupId = XStrongholdConfigs.GetChapterLastGroupId(chapterId) + local groupOrder = XStrongholdConfigs.GetGroupOrder(lastGroupId) + local msg = CsXTextManagerGetText("StrongholdTipLastGroupDebuff", groupOrder) + XUiManager.TipMsg(msg) + end + + _NewFinishGroupIds = {} + end + + function XStrongholdManager.GetGroupStageIds(groupId) + local groupInfo = GetGroupInfo(groupId) + return groupInfo and groupInfo:GetStageIds() or {} + end + + function XStrongholdManager.GetAllGroupStageIds() + local allStageIds = {} + for groupId in pairs(_GroupInfos) do + local stageIds = XStrongholdManager.GetGroupStageIds(groupId) + for _, stageId in pairs(stageIds) do + tableInsert(allStageIds, stageId) + end + end + return allStageIds + end + + function XStrongholdManager.GetGroupStageId(groupId, stageIndex) + local groupInfo = GetGroupInfo(groupId) + return groupInfo and groupInfo:GetStageId(stageIndex) or 0 + end + + function XStrongholdManager.GetGroupStageName(groupId, stageIndex) + local stageId = XStrongholdManager.GetGroupStageId(groupId, stageIndex) + return stageId ~= 0 and XDataCenter.FubenManager.GetStageName(stageId) or "" + end + + function XStrongholdManager.GetGroupStageBuffDesc(groupId, stageIndex) + local groupInfo = GetGroupInfo(groupId) + local buffId = groupInfo:GetStageBuffId(stageIndex) + return buffId > 0 and XStrongholdConfigs.GetBuffDesc(buffId) or "" + end + + --获取据点BaseBuff + function XStrongholdManager.GetGroupBaseBuffIds(groupId) + return XStrongholdConfigs.GetGroupBaseBuffIds(groupId, _ActivityId) + end + + --获取据点BossBuff + function XStrongholdManager.GetGroupBossBuffIds(groupId) + return XStrongholdConfigs.GetGroupBossBuffIds(groupId, _ActivityId) + end + + --获取据点首通奖励Id + function XStrongholdManager.GetGroupRewardId(groupId) + local levelId = XStrongholdManager.GetLevelId() + return XStrongholdConfigs.GetGroupRewardId(groupId, levelId) + end + + function XStrongholdManager.CheckAnyGroupHasFinishedStage() + for groupId, groupInfo in pairs(_GroupInfos) do + if groupInfo:CheckHasStageFinished() then + return groupId + end + end + return false + end + + --检查据点是否有挑战中的关卡进度 + function XStrongholdManager.CheckGroupHasFinishedStage(groupId) + local groupInfo = GetGroupInfo(groupId) + return groupInfo and groupInfo:CheckHasStageFinished() or false + end + + function XStrongholdManager.IsGroupStageFinished(groupId, stageIndex) + if not IsNumberValid(groupId) + or not IsNumberValid(stageIndex) + then return false end + + local requireTeamMemberDic = XStrongholdManager.GetGroupRequireTeamMemberDic(groupId) + if not requireTeamMemberDic[stageIndex] then + return false + end + + local groupInfo = GetGroupInfo(groupId) + return groupInfo and groupInfo:IsStageFinished(stageIndex) or false + end + + function XStrongholdManager.GetGroupNextFightStageIndex(groupId) + local groupInfo = GetGroupInfo(groupId) + return groupInfo and groupInfo:GetNextFightStageIndex() or 0 + end + + function XStrongholdManager.GetGroupStageNum(groupId) + return #XStrongholdManager.GetGroupStageIds(groupId) + end + + function XStrongholdManager.GetGroupSupportId(groupId) + local groupInfo = GetGroupInfo(groupId) + return groupInfo and groupInfo:GetSupportId() or 0 + end + + --获取据点要求梯队数量 + function XStrongholdManager.GetGroupRequireTeamNum(groupId) + local groupInfo = GetGroupInfo(groupId) + return groupInfo and groupInfo:GetRequireTeamNum() or 0 + end + + --获取据点要求梯队数量 + function XStrongholdManager.GetGroupRequireTeamIds(groupId) + local requireTeamIds = {} + + if not groupId then + --预设模式下返回默认最大数量 + local maxTeamNum = XStrongholdConfigs.GetMaxTeamNum() + for teamId = 1, maxTeamNum do + tableInsert(requireTeamIds, teamId) + end + else + --读取战斗关卡要求队伍成员数量 + local requireTeamNum = XStrongholdManager.GetGroupRequireTeamNum(groupId) + for teamId = 1, requireTeamNum do + tableInsert(requireTeamIds, teamId) + end + end + + return requireTeamIds + end + + function XStrongholdManager.GetGroupRequireTeamMemberDic(groupId) + local requireTeamMemberDic = {} + local requireTeamNum = XStrongholdManager.GetGroupRequireTeamNum(groupId) + for teamId = 1, requireTeamNum do + local requireCount = XStrongholdConfigs.GetGroupRequireTeamMemberNum(groupId, teamId) + if requireCount > 0 then + requireTeamMemberDic[teamId] = requireCount + end + end + return requireTeamMemberDic + end + + function XStrongholdManager.GetGroupRequireAbility(groupId) + if not IsNumberValid(groupId) then return 0 end + local supportId = XStrongholdManager.GetGroupSupportId(groupId) + return supportId > 0 and XStrongholdConfigs.GetSupportRequireAbility(supportId) or 0 + end + + --检查完美战术是否激活 + function XStrongholdManager.CheckSupportActive(supportId, teamList) + local conditionIds = XStrongholdConfigs.GetSupportConditionIds(supportId) + for _, conditionId in pairs(conditionIds) do + if not XConditionManager.CheckCondition(conditionId, teamList) then + return false + end + end + return true + end + + function XStrongholdManager.CheckGroupSupportAcitve(groupId, teamList) + local supportId = XStrongholdManager.GetGroupSupportId(groupId) + return XStrongholdManager.CheckSupportActive(supportId, teamList) + end + + function XStrongholdManager.OpenUiSupport(groupId, teamList) + local supportId = XStrongholdManager.GetGroupSupportId(groupId) + if not IsNumberValid(supportId) then + XLog.Error("XUiStrongholdDetail:OnClickBtnAssitantBuff error: 支援方案Id未配置, groupId: ", groupId) + return + end + XLuaUiManager.Open("UiStrongholdSupportTips", supportId, teamList) + end + + function XStrongholdManager.GetAllGroupCount() + return _AllGroupCount or 0 + end + + function XStrongholdManager.GetFinishGroupCount() + local count = 0 + for groupId in pairs(_FinishGroupIdDic) do + if groupId > 0 then + count = count + 1 + end + end + return count + end + + function XStrongholdManager.IsGroupFinished(groupId) + return _FinishGroupIdDic[groupId] and true or false + end + + --据点解锁条件为前置据点是否通关 + function XStrongholdManager.IsGroupUnlock(groupId) + local preGroupId = XStrongholdConfigs.GetGroupPreGroupId(groupId) + if not IsNumberValid(preGroupId) then return true end + return XStrongholdManager.IsGroupFinished(preGroupId) + end + + --章节解锁条件为第一个据点是否解锁 + function XStrongholdManager.CheckChapterUnlock(chapterId) + local isUnlock, conditionDes = false, "" + + local firstGroupId = XStrongholdConfigs.GetChapterFirstGroupId(chapterId) + isUnlock = XStrongholdManager.IsGroupUnlock(firstGroupId) + + local preGroupId = XStrongholdConfigs.GetGroupPreGroupId(firstGroupId) + if IsNumberValid(preGroupId) then + local groupName = XStrongholdConfigs.GetGroupOrder(preGroupId) + conditionDes = CsXTextManagerGetText("StrongholdChapterUnlockCondition", groupName) + end + + return isUnlock, conditionDes + end + + --获取单章节进度 + function XStrongholdManager.GetChapterGroupProgress(chapterId) + local finishCount, totalCount = 0, 0 + + local groupIds = XStrongholdConfigs.GetGroupIds(chapterId) + totalCount = #groupIds + for _, groupId in pairs(groupIds) do + if XStrongholdManager.IsGroupFinished(groupId) then + finishCount = finishCount + 1 + end + end + + return finishCount, totalCount + end + + --检查词缀是否激活 + function XStrongholdManager.CheckBuffActive(buffId, isBossBuff) + local ret, desc = true, "" + local conditionId = XStrongholdConfigs.GetBuffConditionId(buffId) + if IsNumberValid(conditionId) then + ret, desc = XConditionManager.CheckCondition(conditionId) + end + return ret, desc + end + + function XStrongholdManager.GetCurrentSelectGroupId() + return _CurrentSelectGroupId + end + + function XStrongholdManager.SetCurrentSelectGroupId(groupId) + _CurrentSelectGroupId = groupId or 0 + end + + --检查是否有未完成的据点,并有足够耐力挑战 + function XStrongholdManager.CheckHasUnFinishedCanFightGroup() + local groupIds = XStrongholdConfigs.GetAllGroupIds() + + for _, groupId in pairs(groupIds) do + if not XStrongholdManager.IsGroupFinished(groupId) then + local costEndurance = XStrongholdManager.GetGroupCostEndurance(groupId) + local curEndurance = XStrongholdManager.GetCurEndurance() + return costEndurance <= curEndurance + end + end + + return false + end + + --重置据点进度 + function XStrongholdManager.ResetStrongholdGroupRequest(groupId, cb) + local req = { Id = groupId } + XNetwork.Call("ResetStrongholdGroupRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + ResetGroupInfo(groupId) + XStrongholdManager.KickOutInvalidMembersInTeamList()--队伍信息中的援助角色也已经失效,需要清理 + XStrongholdManager.ResetCurFightInfo() + + if cb then cb() end + end) + end + + --重置关卡进度 + function XStrongholdManager.ResetStrongholdStageRequest(groupId, stageId, cb) + local req = { GroupId = groupId, StageId = stageId } + XNetwork.Call("ResetStrongholdStageRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + ResetGroupInfo(groupId, stageId) + XStrongholdManager.KickOutInvalidMembersInTeamList()--队伍信息中的援助角色也已经失效,需要清理 + XStrongholdManager.ResetCurFightInfo() + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_STRONGHOLD_FINISH_GROUP_CHANGE) + + if cb then cb() end + end) + end + + --更新完成过的据点列表 + function XStrongholdManager.NotifyStrongholdFinishGroupId(data) + UpdateNewFinishGroupIds(data.FinishGroupIds) + UpdateFinishGroupIds(data.FinishGroupIds) + end + + --更新据点信息 + function XStrongholdManager.NotifyUpdateStrongholdGroupData(data) + UpdateGroupInfos({ data.GroupInfo }) + end + + --删除据点信息 + function XStrongholdManager.NotifyDeleteStrongholdGroupData(data) + ResetGroupInfo(data.Id) + end + -----------------据点相关 end------------------ + -----------------队伍相关 begin------------------ + local _TeamList = {} --队伍列表 + local _MaxTeamNum = 0 --最大队伍数量 + + local function InitTeamList() + _MaxTeamNum = XStrongholdConfigs.GetMaxTeamNum() + + for teamId = 1, _MaxTeamNum do + local team = XStrongholdTeam.New(teamId) + _TeamList[teamId] = team + end + end + + local function GetTeam(teamId) + local team = _TeamList[teamId] + if not team then + XLog.Error("XStrongholdManager GetTeam error, 找不到队伍数据, teamId: ", teamId .. ", _TeamList: ", _TeamList) + return + end + return team + end + + local function ClearTeamList() + for teamId, team in pairs(_TeamList) do + team:Reset() + end + end + + --原始需求: + --战斗队伍的修改要同步到预设队伍 + --战斗队伍的修改不能影响到预设队伍其他未使用梯队 + --需求冲突: + --无法保证被部分修改后的预设队伍合法性 + local function UpdateTeamList(data) + ClearTeamList() + if IsTableEmpty(data) then return end + + -- local synedTeamIdCheckDic = {} + --从服务端同步的真实队伍信息 + for _, teamInfo in pairs(data) do + local teamId = teamInfo.Id + -- synedTeamIdCheckDic[teamId] = teamId + local team = GetTeam(teamId) + team:Reset() + team:SetCaptainPos(teamInfo.CaptainPos) + team:SetFirstPos(teamInfo.FirstPos) + team:SetRune(teamInfo.RuneId, teamInfo.SubRuneId) + + for _, memberInfo in pairs(teamInfo.CharacterInfos) do + team:SetMember(memberInfo.Pos, memberInfo.Id, memberInfo.PlayerId, memberInfo.RobotId, memberInfo.Ability) + end + + for _, pluginInfo in pairs(teamInfo.PluginInfos) do + team:SetPlugin(pluginInfo.Id, pluginInfo.Count) + end + end + + -- --同步完毕后对本地缓存队伍进行队员重复性检查 + -- for teamId, team in pairs(_TeamList) do + -- if not synedTeamIdCheckDic[teamId] then + -- end + -- end + CsXGameEventManager.Instance:Notify(XEventId.EVENT_STRONGHOLD_TEAMLIST_CHANGE) + end + + --从队伍列表生成原始服务端队伍数据 + local function GenerateOriginalTeamInfos(teamList) + local teamInfos = {} + + for _, team in pairs(teamList) do + local teamInfo = {} + + teamInfo.Id = team:GetId() + teamInfo.CaptainPos = team:GetCaptainPos() + teamInfo.FirstPos = team:GetFirstPos() + teamInfo.RuneId, teamInfo.SubRuneId = team:GetRune() + + teamInfo.CharacterInfos = {} + local members = team:GetAllMembers() + + --一队固定3角色 + for i = 1, 3 do + local member = members[i] + local characterInfo = {} + characterInfo.Pos = member and member:GetPos() or i + local robotId = member and member:GetRobotId() or 0 + characterInfo.RobotId = robotId + local characterId = member and member:GetCharacterId() or 0 + characterInfo.Id = IsNumberValid(characterId) and characterId or XRobotManager.GetCharacterId(robotId)--服务端他一定要kt. + characterInfo.PlayerId = member and member:GetPlayerId() or 0 + characterInfo.Ability = member and member:GetAbility() or 0 + tableInsert(teamInfo.CharacterInfos, characterInfo) + end + + teamInfo.PluginInfos = {} + local plugins = team:GetAllPlugins() + for _, plugin in pairs(plugins) do + local pluginInfo = {} + pluginInfo.Id = plugin:GetId() + pluginInfo.Count = plugin:GetCount() + tableInsert(teamInfo.PluginInfos, pluginInfo) + end + + tableInsert(teamInfos, teamInfo) + end + + return teamInfos + end + + function XStrongholdManager.GetTeamListTemp() + return Clone(_TeamList) + end + + --获取根据据点人数要求裁剪后的队伍列表Clone(bad performance cause GC) + function XStrongholdManager.GetTeamListClipTemp(groupId, teamList) + local teamList = teamList and Clone(teamList) or Clone(_TeamList) + + local isPrefab = not IsNumberValid(groupId) + + if not isPrefab then + --战斗编队模式下按照关卡队伍要求修整队伍 + local requireTeamMemberDic = XStrongholdManager.GetGroupRequireTeamMemberDic(groupId) + + --剔除不在配置的队伍要求人数字典中的队伍 + for teamId in pairs(teamList) do + if not requireTeamMemberDic[teamId] then + teamList[teamId] = nil + end + end + + --按照队伍要求人数裁剪每个队伍中多余的队员 + for teamId, requireTeamMember in pairs(requireTeamMemberDic) do + local team = teamList[teamId] + team:ClipMembers(requireTeamMember) + end + + else + --预设模式下剔除掉自己拥有的角色以外的队伍成员 + for _, team in pairs(teamList) do + team:KickOutOtherMembers() + end + + end + + XStrongholdManager.KickOutInvalidMembersInTeamList(teamList, groupId) + + return teamList + end + + --剔除队伍列表中已经失效的援助角色 + function XStrongholdManager.KickOutInvalidMembersInTeamList(teamList, groupId) + teamList = teamList or _TeamList + for stageIndex, team in pairs(teamList) do + --有关卡挑战进度的援助角色不清 + if not XStrongholdManager.IsGroupStageFinished(groupId, stageIndex) then + team:KickOutInvalidMembers() + end + end + end + + --重置队伍列表 + function XStrongholdManager.ClearTeamList(teamList) + teamList = teamList or _TeamList + for _, team in pairs(teamList) do + team:Clear() + end + end + + --自动编队 + --依照玩家拥有的角色进行填充,自队伍1至队伍5 + --填充时先按照最后一个关卡组中的每个关卡对应的优势属性,优先上阵推荐属性的角色 + --然后按照玩家拥有角色的战力高低进行填充 + --支援和试用角色不会自动上阵 + --未设置符文的梯队自左至右,按照符文表的ID依次填充,全部使用第一个子符文 + function XStrongholdManager.AutoTeam(teamList) + teamList = teamList or _TeamList + + XStrongholdManager.ClearTeamList(teamList) + + local lastGroupId = XStrongholdManager.GetLastGroupId() + local stageIdList = XStrongholdManager.GetGroupStageIds(lastGroupId) + + --自动编队仅上阵已拥有构造体 + local ownCharacters = XDataCenter.CharacterManager.GetOwnCharacterList() + tableSort(ownCharacters, function(a, b) + return a.Ability > b.Ability + end) + + local waitCharacterIds = {} + for _, character in ipairs(ownCharacters) do + local characterId = character.Id + --不能在电能支援队伍中 + if not XStrongholdManager.CheckInElectricTeam(characterId) then + tableInsert(waitCharacterIds, characterId) + end + end + + local requireTeamIds = XStrongholdManager.GetGroupRequireTeamIds() + + --每支队伍先上阵推荐属性的角色 + for _, teamId in ipairs(requireTeamIds) do + local team = teamList[teamId] + local stageId = stageIdList[teamId] + local memberNum = XStrongholdConfigs.GetMaxTeamMemberNum() + for pos = 1, memberNum do + if stageId then + for index, characterId in ipairs(waitCharacterIds) do + if XFubenConfigs.IsStageRecommendCharacterType(stageId, characterId) then + local member = team:GetMember(pos) + member:SetCharacterId(characterId) + tableRemove(waitCharacterIds, index) + break + end + end + end + end + end + + for _, teamId in ipairs(requireTeamIds) do + local team = teamList[teamId] + local memberNum = XStrongholdConfigs.GetMaxTeamMemberNum() + for pos = 1, memberNum do + local member = team:GetMember(pos) + if member:IsEmpty() then + + for index, characterId in ipairs(waitCharacterIds) do + local characterType = XCharacterConfigs.GetCharacterType(characterId) + if not team:ExistDifferentCharacterType(characterType) then + member:SetCharacterId(characterId) + tableRemove(waitCharacterIds, index) + break + end + end + end + end + end + + XStrongholdManager.AutoRune(teamList) + end + + function XStrongholdManager.GetLastGroupId() + local allChapterIds = XStrongholdConfigs.GetAllChapterIds() + local lastChapter = allChapterIds[#allChapterIds] + local groupIds = XStrongholdConfigs.GetGroupIds(lastChapter) + return groupIds[#groupIds] + end + + --获取已使用电能总和 + function XStrongholdManager.GetTotalUseElectricEnergy(teamList) + local useElectric = 0 + + teamList = teamList or _TeamList + for _, team in pairs(teamList) do + useElectric = useElectric + team:GetUseElectricEnergy() + end + + return useElectric + end + + --检查队伍是否符合当前挑战的关卡中的队伍人数要求 + function XStrongholdManager.CheckCurGroupTeamFull(teamList) + local groupId = XStrongholdManager.GetCurrentSelectGroupId() + if not IsNumberValid(groupId) then return false end + + teamList = teamList or _TeamList + local requireTeamMemberDic = XStrongholdManager.GetGroupRequireTeamMemberDic(groupId) + for teamId, requireTeamMemberNum in pairs(requireTeamMemberDic) do + local team = teamList[teamId] + for pos = 1, requireTeamMemberNum do + local member = team:GetMember(pos) + if not member or member:IsEmpty() then + return false + end + end + end + + return true + end + + --获取队伍列表战力总和 + function XStrongholdManager.GetTeamListTotalAbility(teamList) + local totalAbility = 0 + teamList = teamList or _TeamList + for _, team in pairs(teamList) do + local ability = team:GetTeamAbility() + totalAbility = totalAbility + ability + end + return totalAbility + end + + --检查队伍列表平均战力是否符合要求 + function XStrongholdManager.CheckTeamListAverageAbility(requireAbility, teamList) + local groupId = XStrongholdManager.GetCurrentSelectGroupId() + if not IsNumberValid(groupId) then return false end + + local totalAbility, memberCount = 0, 0 + + teamList = teamList or _TeamList + local requireTeamNum = XStrongholdManager.GetGroupRequireTeamNum(groupId) + for teamId = 1, requireTeamNum do + local team = teamList[teamId] + local requireTeamMemberNum = XStrongholdConfigs.GetGroupRequireTeamMemberNum(groupId, teamId) + for pos = 1, requireTeamMemberNum do + if not team:CheckPosEmpty(pos) then + totalAbility = totalAbility + team:GetTeamMemberAbility(pos) + memberCount = memberCount + 1 + end + end + end + + local averageAbility = memberCount > 0 and totalAbility / memberCount or 0 + return averageAbility >= requireAbility, averageAbility + end + + --检查队伍列表内的队伍中每名成员是否符合战力要求 + function XStrongholdManager.CheckTeamListEveryMemberAbility(requireAbility, teamList) + local groupId = XStrongholdManager.GetCurrentSelectGroupId() + if not IsNumberValid(groupId) then return false end + + teamList = teamList or _TeamList + local requireTeamNum = XStrongholdManager.GetGroupRequireTeamNum(groupId) + for teamId = 1, requireTeamNum do + local team = teamList[teamId] + local requireTeamMemberNum = XStrongholdConfigs.GetGroupRequireTeamMemberNum(groupId, teamId) + if not team:CheckTeamEveryMemberAbility(requireAbility, requireTeamMemberNum) then + return false + end + end + + return true + end + + --检查角色是否在队伍列表中 + function XStrongholdManager.CheckInTeamList(characterId, teamList, playerId, notCheckTeamId) + if not IsNumberValid(characterId) then return false end + teamList = teamList or _TeamList + for _, team in pairs(teamList) do + if team:GetId() ~= notCheckTeamId and team:CheckInTeam(characterId, playerId) then + return true + end + end + return false + end + + function XStrongholdManager.GetCharacterInTeamId(characterId, teamList, playerId) + if not IsNumberValid(characterId) then return 0 end + teamList = teamList or _TeamList + local isInTeam, pos + for teamId, team in pairs(teamList) do + isInTeam, pos = team:CheckInTeam(characterId, playerId) + if isInTeam then + return teamId, pos + end + end + return 0, 0 + end + + function XStrongholdManager.GetTeamCaptinPosAndFirstPos(teamId, teamList) + local team = teamList and teamList[teamId] or GetTeam(teamId) + return team:GetCaptainPos(), team:GetFirstPos() + end + + function XStrongholdManager.GetTeamShowCharacterIds(teamId, teamList) + local team = teamList and teamList[teamId] or GetTeam(teamId) + return team:GetShowCharacterIds() + end + + --检查角色是否在队伍列表中并存在通关记录 + function XStrongholdManager.CheckInTeamListLock(groupId, characterId, teamList, playerId) + if not IsNumberValid(groupId) then return false end + local stageIndex = XStrongholdManager.GetCharacterInTeamId(characterId, teamList, playerId) + if not IsNumberValid(stageIndex) then return false end + return XStrongholdManager.IsGroupStageFinished(groupId, stageIndex) + end + + --检查队伍列表中是否已上阵相同型号角色 + function XStrongholdManager.CheckTeamListExistSameCharacter(waitCharacterId, teamList, playerId, selectTeamId, selectMemberIndex) + if not IsNumberValid(waitCharacterId) then return false end + teamList = teamList or _TeamList + + local count = 1 + + --在队伍中找到的相同型号角色的位置 + local findTeamId, findMemberIndex = 0, 0 + for teamId, team in pairs(teamList) do + findMemberIndex = team:GetSameCharacterPos(waitCharacterId) + if IsNumberValid(findMemberIndex) then + findTeamId = teamId + break + end + end + + --存在相同型号角色 + local existSameCharacter = IsNumberValid(findTeamId) and IsNumberValid(findMemberIndex) + if existSameCharacter then + count = count + 1 + + --找到的角色位置即将被替换掉 + if selectTeamId == findTeamId + and selectMemberIndex == findMemberIndex then + count = count - 1 + end + end + + --在队伍中找到的待操作角色的位置 + local waitTeamId, waitMemberIndex = 0, 0 + for teamId, team in pairs(teamList) do + waitMemberIndex = team:GetInTeamMemberIndex(waitCharacterId, playerId) + if IsNumberValid(waitMemberIndex) then + waitTeamId = teamId + break + end + end + + --待操作角色已经在队伍中 + local waitCharacterInTeam = IsNumberValid(waitTeamId) and IsNumberValid(waitMemberIndex) + if waitCharacterInTeam then + + --找到的位置和待操作角色的位置相同 + local samePos = findTeamId == waitTeamId and findMemberIndex == waitMemberIndex + if samePos then + count = count - 1 + end + end + + return count > 1 + end + + --检查队伍列表中是否已上阵支援角色(只能上阵一个) + function XStrongholdManager.CheckTeamListExistAssitantCharacter(teamList) + teamList = teamList or _TeamList + for teamId, team in pairs(teamList) do + if team:CheckExistAssitantCharacter() then + return true + end + end + return false + end + + --检查队伍列表是否为空 + function XStrongholdManager.CheckTeamListEmpty(teamList, groupId) + teamList = teamList or _TeamList + for teamId, team in pairs(teamList) do + local requireTeamMemberNum = XStrongholdConfigs.GetGroupRequireTeamMemberNum(groupId, teamId) + for pos = 1, requireTeamMemberNum do + if not team:CheckPosEmpty(pos) then + return false + end + end + end + return true + end + + --检查队伍列表中所有队伍是否均有队长/首发 + function XStrongholdManager.CheckTeamListAllHasCaptainAndFirstPos(groupId, teamList) + local allHasCaptain, allHasFirstPos = true, true + + local requireTeamNum = XStrongholdManager.GetGroupRequireTeamNum(groupId) + teamList = teamList or _TeamList + for teamId = 1, requireTeamNum do + local team = teamList[teamId] + if not team then return false, false end + + if not team:CheckHasCaptain() then + allHasCaptain = false + end + if not team:CheckHasFirstPos() then + allHasFirstPos = false + end + end + + return allHasCaptain, allHasFirstPos + end + + --获取可上阵已拥有角色/机器人 + function XStrongholdManager.GetCanUseCharacterOrRobotIds(groupId, stageIndex, characterType, teamList) + local isPrefab = not IsNumberValid(groupId) + local levelId = XStrongholdManager.GetLevelId() + local ids = not isPrefab and XStrongholdConfigs.GetGroupCanUseRobotIds(groupId, characterType, levelId) or {} + + local characterList = XDataCenter.CharacterManager.GetOwnCharacterList(characterType) + for _, character in pairs(characterList) do + tableInsert(ids, character.Id) + end + + local stageId = groupId and XStrongholdManager.GetGroupStageId(groupId, stageIndex) or nil + teamList = teamList or _TeamList + tableSort(ids, function(aId, bId) + --电能支援 + local aIsElectric = XStrongholdManager.CheckInElectricTeam(aId) + local bIsElectric = XStrongholdManager.CheckInElectricTeam(bId) + if aIsElectric ~= bIsElectric then + return not aIsElectric + end + + --已经上阵 + local aIsInTeam = XStrongholdManager.CheckInTeamList(aId, teamList) + local bIsInTeam = XStrongholdManager.CheckInTeamList(bId, teamList) + if aIsInTeam ~= bIsInTeam then + return not aIsInTeam + end + + --关卡推荐排序 + if stageId then + local aIsStageRecomend = XFubenConfigs.IsStageRecommendCharacterType(stageId, aId) + local bIsStageRecomend = XFubenConfigs.IsStageRecommendCharacterType(stageId, bId) + if aIsStageRecomend ~= bIsStageRecomend then + return aIsStageRecomend + end + end + + --自己战力比试玩推荐角色高的优先 + if stageId then + local aIsMediumRecommend = XStrongholdManager.CheckIsMediumRecommend(aId, stageId) + local bIsMediumRecommend = XStrongholdManager.CheckIsMediumRecommend(bId, stageId) + if aIsMediumRecommend ~= bIsMediumRecommend then + return aIsMediumRecommend + end + end + + --试玩角色 + local aIsRobot = XRobotManager.CheckIsRobotId(aId) + local bIsRobot = XRobotManager.CheckIsRobotId(bId) + if aIsRobot ~= bIsRobot then + return aIsRobot + end + + --战力排序 + local aAbility = aIsRobot and XRobotManager.GetRobotAbility(aId) or XDataCenter.CharacterManager.GetCharacterAbilityById(aId) + local bAbility = bIsRobot and XRobotManager.GetRobotAbility(bId) or XDataCenter.CharacterManager.GetCharacterAbilityById(bId) + if aAbility ~= bAbility then + return aAbility > bAbility + end + + return false + end) + + return ids + end + + --检查是否中等推荐 + function XStrongholdManager.CheckIsMediumRecommend(charId, stageId) + if not stageId then + return false + end + + local isStageRecomend = XFubenConfigs.IsStageRecommendCharacterType(stageId, charId) + if not isStageRecomend then + return false + end + + local isRobot = XRobotManager.CheckIsRobotId(charId) + if not isRobot then + return true + end + + local notRobotCharacterId = XRobotManager.GetCharacterId(charId) + local notRobotCharAbility = XDataCenter.CharacterManager.GetCharacterAbilityById(notRobotCharacterId) + local robotCharAbility = XRobotManager.GetRobotAbility(charId) + return robotCharAbility > notRobotCharAbility + end + + function XStrongholdManager.CompareTeamLists(teamList1, teamList2) + if IsTableEmpty(teamList1) + and IsTableEmpty(teamList2) + then + return true + end + + if not teamList1 then return false end + if not teamList2 then return false end + + for teamId, team1 in pairs(teamList1) do + local team2 = teamList2[teamId] + if not team1:Compare(team2) then + return false + end + end + + return true + end + + --设置预设队伍 + function XStrongholdManager.SetStrongholdTeamRequest(teamList, isOwn, cb) + if not XStrongholdManager.IsOpen() then return end + + local teamInfos = GenerateOriginalTeamInfos(teamList) + if isOwn == nil then + isOwn = false--是否仅保存自己拥有的角色 + end + + --队伍数据未变动时不同步服务端 + if XStrongholdManager.CompareTeamLists(teamList, _TeamList) then + UpdateTeamList(teamInfos) + if cb then cb() end + + return + end + + local req = { TeamInfos = teamInfos, Own = isOwn } + XNetwork.Call("SetStrongholdTeamRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + UpdateTeamList(teamInfos) + + if cb then cb() end + end) + end + + --设置战斗队伍 + function XStrongholdManager.SetStrongholdFightTeamRequest(groupId, teamList, cb, ignoreRepeatCheck) + if not XStrongholdManager.IsOpen() then return end + + --检查耐力 + local costEndurance = XStrongholdManager.GetGroupCostEndurance(groupId) + local curEndurance = XStrongholdManager.GetCurEndurance() + if costEndurance > curEndurance then + XUiManager.TipText("StrongholdEnterFightEnduranceLack") + return + end + + --检查电能是否溢出 + if XStrongholdManager.CheckElectricOverLimit(nil, teamList) then + XUiManager.TipText("StrongholdEnterFightElectricOver") + return + end + + --检查队伍列表中所有需要的队伍是否均有队长/首发 + local allHasCaptain, allHasFirstPos = XStrongholdManager.CheckTeamListAllHasCaptainAndFirstPos(groupId, teamList) + if not allHasCaptain then + XUiManager.TipText("StrongholdEnterFightTeamListNoCaptain") + return + end + if not allHasFirstPos then + XUiManager.TipText("StrongholdEnterFightTeamListNoFirstPos") + return + end + + --使用了支援角色 + if XStrongholdManager.CheckTeamListExistAssitantCharacter(teamList) then + --支援次数不足 + local times = XStrongholdManager.GetBorrowCount() + local maxTimes = XStrongholdConfigs.GetBorrowMaxTimes() + if times >= maxTimes then + XUiManager.TipText("StrongholdBorrowMaxTimes") + return + end + + --支援消耗不足 + local itemId, count = XStrongholdConfigs.GetBorrowCostItemInfo(times) + if not XDataCenter.ItemManager.CheckItemCountById(itemId, count) then + XUiManager.TipText("StrongholdBorrowCostLack") + return + end + end + + local teamInfos = GenerateOriginalTeamInfos(teamList) + --队伍数据未变动时不同步服务端 + if not ignoreRepeatCheck and XStrongholdManager.CompareTeamLists(teamList, _TeamList) then + UpdateTeamList(teamInfos) + if cb then cb() end + + return + end + + local req = { Id = groupId, TeamInfos = teamInfos } + XNetwork.Call("SetStrongholdFightTeamRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local itemId = XStrongholdManager.GetMineralItemId() + local itemCount = XDataCenter.ItemManager.GetCount(itemId) + local minerCount = XStrongholdManager.GetMinerCount() + XStrongholdManager.CatchOldMineralItemCount(itemCount) + XStrongholdManager.CatchOldTotalMineralCount() + XStrongholdManager.SetCookieMinerCount(minerCount) + + + if cb then cb() end + end) + end + -----------------队伍相关 end------------------ + -----------------援助角色(来自于其他玩家) begin------------------ + local _BorrowCount = 0 --援助次数 + local _AssistantCharacters = {} --援助角色列表(来自于其他玩家) + + local function UpdateBorrowCount(data) + _BorrowCount = data or _BorrowCount + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_STRONGHOLD_BORROW_COUNT_CHANGE) + end + + --[[ // 援助角色详情 +[MessagePackObject(keyAsPropertyName: true)] +public class StrongholdAssistCharacterDetail +{ + public int Id; + public string Name; + public XCharacterData Character; + public List Equips = new List(); +} + ]] + local function UpdateAssistantCharacters(data) + _AssistantCharacters = {} + for _, info in pairs(data) do + local id = info.Id + _AssistantCharacters[id] = info + end + end + + local function GetAssistantInfo(playerId) + if not IsNumberValid(playerId) then return end + return _AssistantCharacters[playerId] + end + XStrongholdManager.GetAssistantInfo = GetAssistantInfo + + function XStrongholdManager.GetBorrowCount() + return _BorrowCount + end + + function XStrongholdManager.GetAssistantPlayerIds(groupId, stageIndex, teamList) + local playerIds = {} + for playerId in pairs(_AssistantCharacters) do + tableInsert(playerIds, playerId) + end + + teamList = teamList or _TeamList + local stageId = groupId and XStrongholdManager.GetGroupStageId(groupId, stageIndex) or nil + tableSort(playerIds, function(aPlayerId, bPlayerId) + local aId = XStrongholdManager.GetAssistantPlayerCharacterId(aPlayerId) + local bId = XStrongholdManager.GetAssistantPlayerCharacterId(bPlayerId) + + --已经上阵 + local aIsInTeam = XStrongholdManager.CheckInTeamList(aId, teamList, aPlayerId) + local bIsInTeam = XStrongholdManager.CheckInTeamList(bId, teamList, bPlayerId) + if aIsInTeam ~= bIsInTeam then + return not aIsInTeam + end + + --关卡推荐排序 + if stageId then + local aIsStageRecomend = XFubenConfigs.IsStageRecommendCharacterType(stageId, aId) + local bIsStageRecomend = XFubenConfigs.IsStageRecommendCharacterType(stageId, bId) + if aIsStageRecomend ~= bIsStageRecomend then + return aIsStageRecomend + end + end + + --战力排序 + local aAbility = XStrongholdManager.GetAssistantPlayerAbiility(aPlayerId) + local bAbility = XStrongholdManager.GetAssistantPlayerAbiility(bPlayerId) + if aAbility ~= bAbility then + return aAbility > bAbility + end + + return false + end) + + return playerIds + end + + function XStrongholdManager.GetAssistantPlayerCharacterId(playerId) + local info = GetAssistantInfo(playerId) + return info and info.Character.Id or 0 + end + + function XStrongholdManager.GetAssistantPlayerFashionId(playerId) + local info = GetAssistantInfo(playerId) + return info and info.Character.FashionId or 0 + end + + function XStrongholdManager.GetAssistantPlayerLiberateLv(playerId) + local info = GetAssistantInfo(playerId) + return info and info.Character.LiberateLv or 0 + end + + function XStrongholdManager.GetAssistantPlayerAbiility(playerId) + local info = GetAssistantInfo(playerId) + return info and info.Character and info.Character.Ability or 0 + end + + function XStrongholdManager.CheckAssitantValid(playerId, characterId) + local info = GetAssistantInfo(playerId) + if IsTableEmpty(info) then return false end + return IsNumberValid(characterId) and XStrongholdManager.GetAssistantPlayerCharacterId(playerId) == characterId + end + + function XStrongholdManager.CheckAssitantListWaitInit() + return IsTableEmpty(_AssistantCharacters) and XStrongholdManager.CheckAssitantRefreshCD() + end + + local _LastTimeGetStrongholdAssistCharacterListRequest = 0 + local _CDGetStrongholdAssistCharacterListRequest = XStrongholdConfigs.GetCommonConfig("RefreshAssistCharacterInterval") + function XStrongholdManager.CheckAssitantRefreshCD() + local now = XTime.GetServerNowTimestamp() + local lastCd = mathCeil(_LastTimeGetStrongholdAssistCharacterListRequest + _CDGetStrongholdAssistCharacterListRequest - now) + if lastCd > 0 then + local desc = CS.XTextManager.GetText("StrongholdRefershAssistCharacterInCD", lastCd) + return false, desc + end + return true, "" + end + + --请求援助角色列表 + function XStrongholdManager.GetStrongholdAssistCharacterListRequest(cb) + local now = XTime.GetServerNowTimestamp() + local isRefreshCd, desc = XStrongholdManager.CheckAssitantRefreshCD() + if not isRefreshCd then + XUiManager.TipMsg(desc) + return + end + _LastTimeGetStrongholdAssistCharacterListRequest = XTime.GetServerNowTimestamp() + + XNetwork.Call("GetStrongholdAssistCharacterListRequest", nil, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + UpdateAssistantCharacters(res.CharacterDetails) + + if cb then cb() end + end) + end + + --通知借用次数 + function XStrongholdManager.NotifyStrongholdBorrowCount(data) + UpdateBorrowCount(data.BorrowCount) + end + -----------------援助角色(来自于其他玩家) end------------------ + -----------------支援相关(共享角色) begin------------------ + local _AssistantCharacterId = 0 --共享角色Id + local _AssistantRecords = {} --支援记录 + + local function UpdateShareCharacterId(data) + if not IsNumberValid(data) then return end + _AssistantCharacterId = data + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_STRONGHOLD_SHARE_CHARACTER_CHANGE) + end + + local function ClearAssitantRecords() + _AssistantRecords = {} + end + + local function UpdateAssistantRecords(data) + ClearAssitantRecords() + + if not IsNumberValid(data) then return end + + for _, recordInfo in pairs(data) do + local day = recordInfo.Id + local record = XStrongholdAssistantRecord.New(day) + record:UpdateData(recordInfo) + _AssistantRecords[day] = record + end + end + + local function CheckHaveAssistantRecord() + return not IsTableEmpty(_AssistantRecords) + end + + function XStrongholdManager.GetAssitantRecordStrList() + local recordStrList = {} + + local recordStr, record = "" + local totalDay = XStrongholdManager.GetTotalDay() + for day = 1, totalDay do + record = _AssistantRecords[day] + if record then + if record:IsPause() then + recordStr = record:GetDelayRecordString() + if not stringIsNilOrEmpty(recordStr) then + tableInsert(recordStrList, recordStr) + end + else + recordStr = record:GetDurationRewardRecordString() + if not stringIsNilOrEmpty(recordStr) then + tableInsert(recordStrList, recordStr) + end + + recordStr = record:GetLendRewardRecordString() + if not stringIsNilOrEmpty(recordStr) then + tableInsert(recordStrList, recordStr) + end + end + end + end + + return recordStrList + end + + --援助开启 + function XStrongholdManager.CheckAssistantOpen() + local conditionId = XStrongholdConfigs.GetCommonConfig("SetAssistCharacterCondition") + return XConditionManager.CheckCondition(conditionId) + end + + function XStrongholdManager.CheckCookieAssistantFirstOpen() + if not XStrongholdManager.CheckAssistantOpen() then return end + if XStrongholdManager.GetCookieAssistantFirstOpen() then return end + + XUiManager.TipText("StrongholdAssistantFirstOpen") + XStrongholdManager.SetCookieAssistantFirstOpen() + end + + function XStrongholdManager.SetCookieAssistantFirstOpen() + local key = XStrongholdManager.GetAssistantFirstOpenCookieKey() + XSaveTool.SaveData(key, true) + end + + function XStrongholdManager.GetCookieAssistantFirstOpen() + local key = XStrongholdManager.GetAssistantFirstOpenCookieKey() + return XSaveTool.GetData(key) and true or false + end + + function XStrongholdManager.GetAssistantFirstOpenCookieKey() + if not IsNumberValid(_ActivityId) then return end + return XPlayer.Id .. _ActivityId .. "_XStrongholdManager_CookieAssistantFirstOpen" + end + + function XStrongholdManager.IsHaveAssistantCharacter() + return _AssistantCharacterId > 0 + end + + function XStrongholdManager.GetAssistantCharacterId() + return _AssistantCharacterId + end + + function XStrongholdManager.CheckIsAssistantCharacter(characterId) + return IsNumberValid(characterId) and _AssistantCharacterId == characterId + end + + function XStrongholdManager.EnterUiAssistant() + if not XStrongholdManager.CheckAssistantOpen() then return end + + --未拥有支援角色时直接打开UI + if not XStrongholdManager.IsHaveAssistantCharacter() then + XLuaUiManager.Open("UiStrongholdHelp") + return + end + + --拥有支援角色记录时直接打开UI + if CheckHaveAssistantRecord() then + XLuaUiManager.Open("UiStrongholdHelp") + return + end + + --未拥有支援角色记录时先请求记录 + local cb = function() + XLuaUiManager.Open("UiStrongholdHelp") + end + XStrongholdManager.GetStrongholdLendDetailRequest(cb) + end + + --设置共享角色 + local _LastTimeSetStrongholdAssistCharacterRequest = 0 + local _CDSetStrongholdAssistCharacterRequest = XStrongholdConfigs.GetCommonConfig("SetAssistCharacterInterval") + function XStrongholdManager.SetStrongholdAssistCharacterRequest(characterId, cb) + local now = XTime.GetServerNowTimestamp() + local lastCd = mathCeil(_LastTimeSetStrongholdAssistCharacterRequest + _CDSetStrongholdAssistCharacterRequest - now) + if lastCd > 0 then + local desc = CS.XTextManager.GetText("StrongholdSetAssistCharacterInCD", lastCd) + XUiManager.TipMsg(desc) + return + end + _LastTimeSetStrongholdAssistCharacterRequest = now + + local req = { CharacterId = characterId } + XNetwork.Call("SetStrongholdAssistCharacterRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + UpdateShareCharacterId(characterId) + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_STRONGHOLD_ASSISTANT_CHARACTER_SET_CHANGE, characterId) + + if cb then cb() end + end) + end + + --查询借出奖励记录 + function XStrongholdManager.GetStrongholdLendDetailRequest(cb) + XNetwork.Call("GetStrongholdLendDetailRequest", nil, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + UpdateAssistantRecords(res.LendDayInfos) + + if cb then cb() end + end) + end + -----------------支援相关(共享角色) end------------------ + -----------------奖励(任务) begin------------------ + local _FinishedRewardIdDic = {}--已领取奖励Id字典 + + local function UpdateFinishedRewardIds(data) + if IsTableEmpty(data) then return end + + for _, rewardId in pairs(data) do + if rewardId and rewardId > 0 then + _FinishedRewardIdDic[rewardId] = rewardId + end + end + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_STRONGHOLD_FINISH_REWARDS_CHANGE) + end + + function XStrongholdManager.GetAllRewardIds(levelId) + levelId = levelId or XStrongholdManager.GetLevelId() + local rewardIds = XStrongholdConfigs.GetAllRewardIds(levelId) + + tableSort(rewardIds, function(aId, bId) + local aCanGet = XStrongholdManager.IsRewardCanGet(aId) + local bCanGet = XStrongholdManager.IsRewardCanGet(bId) + if aCanGet ~= bCanGet then + return aCanGet + end + + local aIsFinished = XStrongholdManager.IsRewardFinished(aId) + local bIsFinished = XStrongholdManager.IsRewardFinished(bId) + if aIsFinished ~= bIsFinished then + return not aIsFinished + end + + return aId < bId + end) + + return rewardIds + end + + function XStrongholdManager.IsRewardFinished(rewardId) + return _FinishedRewardIdDic[rewardId] + end + + function XStrongholdManager.IsRewardCanGet(rewardId) + if not XStrongholdManager.IsOpen() + or XStrongholdManager.IsFightEnd() + then return end + + local conditionId = XStrongholdConfigs.GetRewardConditionId(rewardId) + local ret, des, haveCount, requireCount = XConditionManager.CheckCondition(conditionId) + return ret and not XStrongholdManager.IsRewardFinished(rewardId) + end + + function XStrongholdManager.IsAnyRewardCanGet() + if not XStrongholdManager.IsOpen() then return end + + local rewardIds = XStrongholdManager.GetAllRewardIds() + for _, rewardId in pairs(rewardIds) do + if XStrongholdManager.IsRewardCanGet(rewardId) then + return true + end + end + return false + end + + --领取奖励 + function XStrongholdManager.GetStrongholdRewardRequest(rewardId, cb) + local req = { Id = rewardId } + XNetwork.Call("GetStrongholdRewardRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + UpdateFinishedRewardIds({ rewardId }) + + local rewardGoods = res.RewardGoodsList + if cb then cb(rewardGoods) end + end) + end + -----------------奖励(任务) end------------------ + -----------------上期战报 begin------------------ + local _LastActivityId = 0 --活动id + local _LastMinerCount = 0 --矿工数量 + local _LastMineralCount = 0 --矿石数量 + local _LastAssistCount = 0 --支援次数 + local _LastAssistRewardValue = 0 --支援奖励 + local _LastFinishCount = 0 --完成据点数量 + + local function UpdateLastAcitivityRecord(data) + + if IsTableEmpty(data) then return end + + _LastActivityId = data.Id or 0 + _LastMinerCount = data.MinerCount or 0 + _LastMineralCount = data.MineralCount or 0 + _LastAssistCount = data.AssistCount or 0 + _LastAssistRewardValue = data.AssistRewardValue or 0 + _LastFinishCount = data.FinishCount or 0 + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_STRONGHOLD_ACTIVITY_RESULT_CHANGE) + end + + function XStrongholdManager.CheckShowLastActivityRecord() + if not IsNumberValid(_LastActivityId) then return false end + if XStrongholdManager.GetCookieLastActivityRecord() ~= 0 then return false end + if _LastActivityId ~= _ActivityId then return true end + return false + end + + function XStrongholdManager.GetCookieLastActivityRecord() + local key = XStrongholdManager.GetLastActivityRecordCookieKey() + return XSaveTool.GetData(key) or 0 + end + + function XStrongholdManager.SetCookieGetCookieLastActivityRecord() + local key = XStrongholdManager.GetLastActivityRecordCookieKey() + XSaveTool.SaveData(key, 1) + end + + function XStrongholdManager.GetLastActivityRecordCookieKey() + if not IsNumberValid(_LastActivityId) then return end + return XPlayer.Id .. _LastActivityId .. "_XStrongholdManager_CookieLastActivityRecord" + end + + function XStrongholdManager.GetLastFinishCount() + return _LastFinishCount or 0 + end + + function XStrongholdManager.GetLastMinerCount() + return _LastMinerCount or 0 + end + + function XStrongholdManager.GetLastMineralCount() + return _LastMineralCount or 0 + end + + function XStrongholdManager.GetLastAssistCount() + return _LastAssistCount or 0 + end + + function XStrongholdManager.GetLastAssistRewardValue() + return _LastAssistRewardValue or 0 + end + + --通知战报信息 + function XStrongholdManager.NotifyStrongholdResultRecord(data) + UpdateLastAcitivityRecord(data.Record) + end + -----------------上期战报 end------------------ + -----------------副本相关 begin------------------ + local _CurFightGroupId = 0 + local _CurFightStageIndex = 0 + local _SingleFight = false --是否挑战单关卡 + + local function InitStageType(stageId) + stageId = tonumber(stageId) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + if stageInfo then + stageInfo.Type = XDataCenter.FubenManager.StageType.Stronghold + end + end + + function XStrongholdManager.InitStageInfo() + local stageIds = XStrongholdManager.GetAllGroupStageIds() + for _, stageId in pairs(stageIds) do + InitStageType(stageId) + end + end + + function XStrongholdManager.ResetCurFightInfo() + _CurFightGroupId = 0 + _CurFightStageIndex = 0 + end + + function XStrongholdManager.OpenFightLoading(stageId) + if _SingleFight then + XDataCenter.FubenManager.OpenFightLoading(stageId) + return + end + + local groupId = _CurFightGroupId + local stageIndex = _CurFightStageIndex + if stageIndex == 1 and XStrongholdConfigs.IsChapterLastGroupId(groupId) then return end + XLuaUiManager.Open("UiStrongholdInfo", groupId, stageIndex) + end + + function XStrongholdManager.CloseFightLoading(stageId) + if _SingleFight then + XDataCenter.FubenManager.CloseFightLoading(stageId) + else + XLuaUiManager.Remove("UiStrongholdInfo") + end + end + + function XStrongholdManager.ShowReward(winData) + local groupId = _CurFightGroupId + local stageCount = XStrongholdManager.GetGroupStageNum(groupId) + local stageIndex = _CurFightStageIndex + local allFinished = winData.SettleData.StrongholdFightResult.AllFinished --当前据点所有关卡是否都挑战通过 + + if _SingleFight then + --单关卡挑战 + _SingleFight = false + else + --多波连续挑战 + if not allFinished and stageIndex < stageCount then + _CurFightStageIndex = stageIndex + 1 + XStrongholdManager.EnterFight(groupId, nil, nil, true) + end + end + + if allFinished then + XStrongholdManager.ResetCurFightInfo() + XLuaUiManager.Remove("UiStrongholdDeploy") + XLuaUiManager.Open("UiStrongholdFightSettleWin", winData) + end + end + + function XStrongholdManager.ChallengeLose() + XStrongholdManager.ResetCurFightInfo() + _SingleFight = false + end + + function XStrongholdManager.TryEnterFight(groupId, teamId, oTeamList) + local callFunc = function() + local teamList = XStrongholdManager.GetTeamListClipTemp(groupId, oTeamList) + + local enterFunc = function() + local cb = function() + XStrongholdManager.EnterFight(groupId, teamList, teamId) + end + local setStrongholdTeamCb = function() + local ignoreRepeatCheck = true + XStrongholdManager.SetStrongholdFightTeamRequest(groupId, teamList, cb, ignoreRepeatCheck) + end + XStrongholdManager.SetStrongholdTeamRequest(oTeamList, nil, setStrongholdTeamCb) + end + + local notRune = false + if XTool.IsNumberValid(teamId) then + --单梯队作战 + local team = teamList[teamId] + notRune = not team:HasRune() + else + for _, team in pairs(teamList) do + if not team:HasRune() then + notRune = true + break + end + end + end + + if notRune then + --符文配置不全提示 + local title = CSXTextManagerGetText("StrongholdTeamAutoRuneConfirmTitle") + local content = CSXTextManagerGetText("StrongholdTeamAutoRuneConfirmContent") + local setRuneFunc = function() + XStrongholdManager.AutoRune(teamList) + + --拷贝符文到队伍预设 + for teamId, team in pairs(teamList) do + local oTeam = oTeamList[teamId] + if not XTool.IsTableEmpty(oTeam) then + local runeId, subRuneId = team:GetRune() + oTeam:SetRune(runeId, subRuneId) + end + end + + enterFunc() + end + XUiManager.DialogTip(title, content, XUiManager.DialogType.Normal, nil, setRuneFunc) + else + enterFunc() + end + end + + if XStrongholdManager.IsFightBegin() then + callFunc() + else + --首次进入玩法战斗提示 + local title = CSXTextManagerGetText("StrongholdFirstFightConfirmTitle") + local fightAutoBeginTime = XStrongholdManager.GetFightAutoBeginTime() + local timeStr = XUiHelper.GetTime(fightAutoBeginTime - XTime.GetServerNowTimestamp(), XUiHelper.TimeFormatType.STRONGHOLD) + local content = CSXTextManagerGetText("StrongholdFirstFightConfirmContent", timeStr) + XUiManager.DialogTip(title, content, XUiManager.DialogType.Normal, nil, callFunc) + end + end + + function XStrongholdManager.EnterFight(groupId, teamList, stageIndex, isContinueFight) + local teamList = XStrongholdManager.GetTeamListClipTemp(groupId, teamList) + + --单队挑战单关卡 + if XTool.IsNumberValid(stageIndex) then + _SingleFight = true + end + + _CurFightGroupId = groupId + + stageIndex = stageIndex or _CurFightStageIndex + if not IsNumberValid(stageIndex) or XStrongholdManager.IsGroupStageFinished(groupId, stageIndex) then + stageIndex = XStrongholdManager.GetGroupNextFightStageIndex(groupId) + end + _CurFightStageIndex = stageIndex + + local stageId = XStrongholdManager.GetGroupStageId(groupId, stageIndex) + local enterFight = function() + local teamId = stageIndex + local captainPos, firstFightPos = XStrongholdManager.GetTeamCaptinPosAndFirstPos(teamId, teamList) + local characterIds = XStrongholdManager.GetTeamShowCharacterIds(teamId, teamList) + XDataCenter.FubenManager.EnterStrongholdFight(stageId, characterIds, captainPos, firstFightPos) + end + + if XStrongholdConfigs.IsChapterLastGroupId(groupId) then + if not _SingleFight then + XLuaUiManager.Open("UiStrongholdInfo", groupId, stageIndex) + end + + --连续挑战不显示词缀界面 + if isContinueFight then + enterFight() + else + XLuaUiManager.Open("UiStrongholdAnimation", groupId, enterFight) + end + else + enterFight() + end + end + -----------------副本相关 end------------------ + -----------------等级分区 begin------------------ + local _LevelId = 0--当前选择的分区 + + function XStrongholdManager.GetLevelId() + return _LevelId + end + + local function UpdateLevelId(levelId) + _LevelId = levelId or _LevelId + + InitGroupInfos()--根据分区初始化关卡信息 + end + + --是否已经选择过分区 + function XStrongholdManager.IsSelectedLevelId() + return IsNumberValid(_LevelId) + end + + --选择等级分区 + function XStrongholdManager.SelectStrongholdLevelRequest(levelId, cb) + if XStrongholdManager.IsSelectedLevelId() then + XUiManager.tiptext("StrongholdAlreadySelectLevel") + return + end + + local req = { LevelId = levelId } + XNetwork.Call("SelectStrongholdLevelRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + UpdateLevelId(levelId) + UpdateGroupStageDatas(res.GroupStageDatas) + UpdateElectricEnergy(res.ElectricEnergy) + UpdateEndurance(res.Endurance) + + if cb then cb() end + end) + end + -----------------等级分区 end------------------ + -----------------暂停结算 begin------------------ + local _PauseDays = {}--暂停结算的天数(下次结算后清除) + + local function InitPauseDays() + _PauseDays = {} + local totalDay = XStrongholdManager.GetTotalDay() + for day = 1, totalDay do + _PauseDays[day] = false + end + end + + local function UpdatePauseDays(days) + InitPauseDays() + + for _, day in pairs(days or {}) do + _PauseDays[day] = true + end + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_STRONGHOLD_PAUSE_DAY_CHANGE) + end + + --该天数是否暂停了结算 + function XStrongholdManager.IsDayPaused(day) + day = day or XStrongholdManager.GetCurDay() + return _PauseDays[day] and true or false + end + + --是否有处于暂停中的天数(昨天/前天/...) + function XStrongholdManager.IsAnyDayPaused() + for _, isPause in pairs(_PauseDays) do + if isPause then + return true + end + end + return false + end + + --获取暂停天数(from curDay) + function XStrongholdManager.GetDelayDays() + local delayDays = 0 + + local curDay = XStrongholdManager.GetCurDay() + local totalDay = XStrongholdManager.GetTotalDay() + for day = curDay, totalDay do + if not XStrongholdManager.IsDayPaused(day) then + break + end + delayDays = delayDays + 1 + end + + return delayDays + end + + --挑战开始后48小时不可设置暂停 + local PAUSE_DELAY_AFTER_FIGHT_BEGIN = 48 * 3600 + function XStrongholdManager.CheckPauseTimeAfterFightBegin() + local nowTime = XTime.GetServerNowTimestamp() + local fightBeginTime = XStrongholdManager.GetFightTime() + return nowTime - fightBeginTime >= PAUSE_DELAY_AFTER_FIGHT_BEGIN + end + + --挑战结束前24小时不可设置暂停 + local PAUSE_DELAY_BEFORE_FIGHT_END = 24 * 3600 + function XStrongholdManager.CheckPauseTimeBeforeFightEnd() + local nowTime = XTime.GetServerNowTimestamp() + local delayDays = XStrongholdManager.GetDelayDays() + local _, fightEndTime = XStrongholdManager.GetFightTime() + return fightEndTime - nowTime - delayDays * 24 * 3600 >= PAUSE_DELAY_BEFORE_FIGHT_END + end + + --是否可以暂停结算 + function XStrongholdManager.IsCanPaused() + return XStrongholdManager.IsFightBegin()--作战期开始 + and XStrongholdManager.CheckPauseTimeAfterFightBegin() + and XStrongholdManager.CheckPauseTimeBeforeFightEnd() + end + + local _LastTimeSetStrongholdStayRequest = 0 + local _CDSetStrongholdStayRequest = 3 + function XStrongholdManager.CheckSetStrongholdStayRequestCD() + local now = XTime.GetServerNowTimestamp() + local lastCd = _LastTimeSetStrongholdStayRequest + _CDSetStrongholdStayRequest - now + if lastCd > 0 then + return false + end + return true + end + + --设置暂停 + function XStrongholdManager.SetStrongholdStayRequest(cb) + if not XStrongholdManager.IsCanPaused() then + return + end + + if not XStrongholdManager.CheckSetStrongholdStayRequestCD() then + return + end + + XNetwork.Call("SetStrongholdStayRequest", nil, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + _LastTimeSetStrongholdStayRequest = XTime.GetServerNowTimestamp() + + UpdatePauseDays(res.StayDays) + + if cb then cb() end + end) + end + -----------------暂停结算 end------------------ + -----------------符文 begin------------------ + local _RuneIdList = {} --本期符文Id列表 + local _UsingRuneIdDic = {} --使用中符文Id字典 + local _UsingSubRuneIdDic = {} --使用中子符文Id字典 + + local function UpdateRuneIds(data) + _RuneIdList = {} + for _, runeId in pairs(data or {}) do + if XTool.IsNumberValid(runeId) then + tableInsert(_RuneIdList, runeId) + end + end + + tableSort(_RuneIdList, function(a, b) + return a < b + end) + end + + function XStrongholdManager.GetAllRuneIds() + return XTool.Clone(_RuneIdList) + end + + function XStrongholdManager.UseRune(runeId, subRuneId, teamId) + if XTool.IsNumberValid(runeId) then + _UsingRuneIdDic[runeId] = teamId + end + if XTool.IsNumberValid(subRuneId) then + _UsingSubRuneIdDic[subRuneId] = teamId + end + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_STRONGHOLD_RUNE_CHANGE) + end + + function XStrongholdManager.TakeOffRune(runeId, subRuneId) + if XTool.IsNumberValid(runeId) then + _UsingRuneIdDic[runeId] = nil + end + if XTool.IsNumberValid(subRuneId) then + _UsingSubRuneIdDic[subRuneId] = nil + end + end + + function XStrongholdManager.GetRuneUsingTeamId(runeId) + return _UsingRuneIdDic[runeId] + end + + --符文是否锁定(被有通关记录的队伍使用) + function XStrongholdManager.IsRuneLock(runeId, groupId, subRuneId) + if not XTool.IsNumberValid(groupId) then return false end + + if XTool.IsNumberValid(subRuneId) + and not XStrongholdManager.IsSubRuneUsing(subRuneId) then + return false + end + + local usingTeamId = XStrongholdManager.GetRuneUsingTeamId(runeId) + if not XTool.IsNumberValid(usingTeamId) then return false end + return XStrongholdManager.IsGroupStageFinished(groupId, usingTeamId) + end + + function XStrongholdManager.IsRuneUsing(runeId) + return _UsingRuneIdDic[runeId] and true or false + end + + function XStrongholdManager.IsSubRuneUsing(subRuneId) + return _UsingSubRuneIdDic[subRuneId] and true or false + end + + function XStrongholdManager.GetNextCanUseRuneId() + for _, runeId in ipairs(_RuneIdList) do + if not XStrongholdManager.IsRuneUsing(runeId) then + return runeId + end + end + return 0 + end + + function XStrongholdManager.AutoRune(teamList) + teamList = teamList or _TeamList + + for _, team in pairs(teamList) do + if not team:HasRune() then + local runeId = XStrongholdManager.GetNextCanUseRuneId() + if XTool.IsNumberValid(runeId) then + local subRuneId = XStrongholdConfigs.GetSubRuneIds(runeId)[1] + team:SetRune(runeId, subRuneId) + end + end + end + end + -----------------符文 end------------------ + --登录通知 + function XStrongholdManager.NotifyStrongholdLoginData(data) + if CheckActivityReset(data.Id) then + XStrongholdManager.Reset() + end + + XStrongholdManager.Init() + + UpdateActivityInfo(data.Id, data.BeginTime, data.FightBeginTime) + UpdateLevelId(data.LevelId) + UpdatePauseDays(data.StayDays) + UpdateCurDay(data.CurDay, data.FightBeginTime) + UpdateTotalMineral(data.TotalMineral) + UpdateMineralLeft(data.MineralLeft) + UpdateEndurance(data.Endurance) + UpdateElectricEnergy(data.ElectricEnergy) + UpdateElectricCharacters(data.ElectricCharacterIds) + UpdateBorrowCount(data.BorrowCount) + UpdateFinishGroupIds(data.FinishGroupIds) + UpdateFinishedRewardIds(data.RewardIds) + UpdateMineRecords(data.MineRecords) + UpdateGroupStageDatas(data.GroupStageDatas) + UpdateGroupInfos(data.GroupInfos) + UpdateLastAcitivityRecord(data.LastResultRecord) + UpdateTeamList(data.TeamInfos) + UpdateShareCharacterId(data.AssistCharacterId) + UpdateRuneIds(data.RuneList) + end + + --活动结束 + function XStrongholdManager.NotifyStrongholdEnd() + XStrongholdManager.Reset() + end + + --通知天数改变 + function XStrongholdManager.NotifyStrongholdChangeDay(data) + UpdateCurDay(data.CurDay, data.FightBeginTime) + UpdatePauseDays(data.StayDays) + UpdateMineralLeft(data.MineralLeft) + UpdateEndurance(data.Endurance) + UpdateElectricEnergy(data.ElectricEnergy) + UpdateMineRecords(data.MineRecords) + UpdateBorrowCount(data.BorrowCount) + ClearAssitantRecords() + end + + --在线重置 + function XStrongholdManager.Reset() + _ActivityStatus = ACTIVITY_STATUS.DEFAULT --活动状态 + _ActivityId = 0 --活动期数 + _BeginTime = 0 --活动开启时间 + _FightBeginTime = 0 --挑战开启时间 + _FightAutoBeginTime = 0 --挑战自动开启时间 + _FightEndTime = 0 --挑战结束时间 + _EndTime = 0 --活动结束时间 + _CurDay = 0 --当前天数(挑战开始后) + _TotalDay = 0 --挑战总天数(挑战开始后) + _TotalMineral = 0 --历史累计矿石数量 + _MineralLeft = 0 --可领矿石 + _MineRecords = {} --产出记录 + _MineRecordSynDic = {} --产出历史记录(服务端同步) + _Endurance = 0 --耐力值 + _MaxElectricEnergy = 0 --电能上限 + _BorrowCount = 0 --援助次数 + _FinishGroupIdDic = {}--已完成据点Id字典 + _NewFinishGroupIds = {}--最新完成据点Id列表 + _FinishedRewardIdDic = {}--已领取奖励Id字典 + _GroupInfos = {}--据点信息 + _TeamList = {}--队伍列表 + _AssistantCharacters = {} --援助角色列表(来自于其他玩家) + _AssistantCharacterId = 0 --共享角色Id + _PauseDays = {}--暂停结算的天数 + _LevelId = 0--当前选择的分区 + _RuneIdList = {} --本期符文Id列表 + _UsingRuneIdDic = {} --使用中符文Id字典 + _UsingSubRuneIdDic = {} --使用中子符文Id字典 + + _ActivityEnd = true + CsXGameEventManager.Instance:Notify(XEventId.EVENT_STRONGHOLD_ACTIVITY_END) + end + + function XStrongholdManager.Init() + InitMine() + InitTeamList() + IniElectric() + InitPauseDays() + + XEventManager.AddEventListener(XEventId.EVENT_FIGHT_FINISH_LOSEUI_CLOSE, XStrongholdManager.ChallengeLose) + end + + return XStrongholdManager +end +---------------------(服务器推送)begin------------------ +XRpc.NotifyStrongholdLoginData = function(data) + XDataCenter.StrongholdManager.NotifyStrongholdLoginData(data) +end + +XRpc.NotifyStrongholdChangeDay = function(data) + XDataCenter.StrongholdManager.NotifyStrongholdChangeDay(data) +end + +XRpc.NotifyStrongholdTotalMineral = function(data) + XDataCenter.StrongholdManager.NotifyStrongholdTotalMineral(data) +end + +XRpc.NotifyStrongholdResultRecord = function(data) + XDataCenter.StrongholdManager.NotifyStrongholdResultRecord(data) +end + +XRpc.NotifyStrongholdBorrowCount = function(data) + XDataCenter.StrongholdManager.NotifyStrongholdBorrowCount(data) +end + +XRpc.NotifyStrongholdFinishGroupId = function(data) + XDataCenter.StrongholdManager.NotifyStrongholdFinishGroupId(data) +end + +XRpc.NotifyUpdateStrongholdGroupData = function(data) + XDataCenter.StrongholdManager.NotifyUpdateStrongholdGroupData(data) +end + +XRpc.NotifyDeleteStrongholdGroupData = function(data) + XDataCenter.StrongholdManager.NotifyDeleteStrongholdGroupData(data) +end + +XRpc.NotifyStrongholdEnduranceData = function(data) + XDataCenter.StrongholdManager.NotifyStrongholdEnduranceData(data) +end + +XRpc.NotifyStrongholdEnd = function(data) + XDataCenter.StrongholdManager.NotifyStrongholdEnd(data) +end +---------------------(服务器推送)end------------------ \ No newline at end of file diff --git a/Resources/Scripts/XManager/XSuperTowerManager.lua b/Resources/Scripts/XManager/XSuperTowerManager.lua new file mode 100644 index 00000000..4a51cd5f --- /dev/null +++ b/Resources/Scripts/XManager/XSuperTowerManager.lua @@ -0,0 +1,1054 @@ +--=========================== +--超级爬塔管理器 +--模块负责:吕天元,陈思亮,张爽 +--=========================== + +--==================== +--打印没有当前活动配置错误日志 +--==================== +local DebugNoCurrentActivityCfg = function() + XLog.Error("【超级爬塔】XSuperTowerManager:当前活动配置为空!") +end +--==================== +--管理器 +--==================== +XSuperTowerManagerCreator = function() + local XSuperTowerManager = {} + local StageManager --关卡管理器 + local RoleManager --角色管理器 + local BagManager --仓库管理器 + local TeamManager --队伍管理器 + local FunctionManager --特权管理器 + local ShopManager --商店管理器 + local IsShowSettleDark --结算遮罩控制 + local IsCallFinishBattle --是否已经调用FinishBattle + local HoldFinishBattle --是否挂起了结算战斗 + local HoldSettleData --挂起时缓存的结算数据 + local InitialManagers = false + local DEBUG = false + ------------------------------------------------------------------ + ------------------------------------------------------------------ + --=============== + --超级爬塔关卡类型枚举 + --=============== + XSuperTowerManager.StageType = { + None = 0, -- 缺省类型,表示空值(用于查询时) + SingleTeamOneWave = 1, -- 单队伍单波 + SingleTeamMultiWave = 2, -- 单队伍多波 + MultiTeamMultiWave = 3, -- 多队伍多波 + LllimitedTower = 4, -- 无限爬塔 + } + --=============== + --超级爬塔关卡队伍字典 + --=============== + XSuperTowerManager.TeamId = { + [XSuperTowerManager.StageType.SingleTeamOneWave] = 1, -- 单队伍单波 + [XSuperTowerManager.StageType.SingleTeamMultiWave] = 1, -- 单队伍多波 + [XSuperTowerManager.StageType.LllimitedTower] = 2, -- 无限爬塔 + [XSuperTowerManager.StageType.MultiTeamMultiWave] = 3, -- 多队多波 + } + --=============== + --超级爬塔队伍类型枚举 + --=============== + XSuperTowerManager.TeamType = { + SingleTeam = 1, --单队伍 + Tier = 2, --爬塔 + } + --=============== + --超级爬塔 爬塔结算分数项枚举 + --=============== + XSuperTowerManager.ScoreType = { + Tier = 1, --通关层数 + NormalBattle = 2, --普通战斗层 + EliteBattle = 3, --精英战斗层 + BossBattle = 4, --Boss战斗层 + EnhancerGet = 5, --获得增益数 + PluginsGet = 6 --获得插件数 + } + --=============== + --超级爬塔 目标关卡奖励获取状态 + --=============== + XSuperTowerManager.StageRewardState = { + Complete = 1, --已获得 + CanGet = 2, --可获得 + Lock = 3, --未解锁 + } + --=============== + --超级爬塔 基础配置Key值枚举 + --=============== + XSuperTowerManager.BaseCfgKey = { + ScoreItemId = "ScoreItemId", --积分物品id + InitBagCapacity = "InitBagCapacity", --初始背包容量 + MaxBagCapacity = "MaxBagCapacity", --最大背包容量 + MaxTeamPluginCount = "MaxTeamPluginCount", + SingleCapacityCount = "SingleCapacityCount", --单次扩容数量 + BagCacheCapacity = "BagCacheCapacity", --背包缓存容量 + MainAssetsPanelItem1 = "CurrencyItem1", --主界面和角色货币栏道具1 + MainAssetsPanelItem2 = "CurrencyItem2", --主界面和角色货币栏道具2 + MainAssetsPanelItem3 = "CurrencyItem3", --主界面和角色货币栏道具3 + BagAssetsPanelItem1 = "CurrencyItemOther1", --商店和背包货币栏道具1 + BagAssetsPanelItem2 = "CurrencyItemOther2", --商店和背包货币栏道具2 + BagAssetsPanelItem3 = "CurrencyItemOther3", --商店和背包货币栏道具3 + } + --=============== + --超级爬塔 特权Key枚举 + --=============== + XSuperTowerManager.FunctionName = { + Shop = "CheckMallIsOpen", --商店 + Transfinite = "CheckSuperLimitIsOpen", --角色超限 + BonusChara = "CheckSpecialCharacterIsOpen", --特典角色 + MultiTeam = "CheckMultiTeamChallengeOpen", --多队伍挑战 + Exclusive = "CheckSlotIsOpen" --专属槽 + } + --=============== + --超级爬塔 主题Index + --=============== + XSuperTowerManager.ThemeIndex = { + ThemeAll = 0, --主题区域总览 + } + --=============== + --超级爬塔 关卡Index + --=============== + XSuperTowerManager.StageIndex = { + StageAll = 0, --关卡区域总览 + } + --=============== + --超级爬塔 协议名 + --=============== + local METHOD_NAME = { + StConfirmTargetResultRequest = "StConfirmTargetResultRequest",--确认目标关卡战斗结果 + } + --=============== + --超级爬塔 道具类型 + --=============== + XSuperTowerManager.ItemType = { + Enhance = 1, + Plugin = 2, + } + --=============== + --目标关卡 目标关卡属性类型 + --=============== + XSuperTowerManager.StageElement = { + None = 0, --无 + NextFloor = 2, --下一层 + Keep = 3, --保持现状,暂时离开 + } + ------------------------------------------------------------------ + ------------------------------------------------------------------ + --=============== + --初始化 + --=============== + function XSuperTowerManager.Init() + XSuperTowerManager.InitActivityCfg() + if not XSuperTowerManager.CheckActivityIsInTime() and not DEBUG then + return + end + XSuperTowerManager.InitManagers() + end + + function XSuperTowerManager.InitManagers() + if InitialManagers then return end + XSuperTowerManager.InitStageManager() + XSuperTowerManager.InitRoleManager() + XSuperTowerManager.InitBagManager() + XSuperTowerManager.InitTeamManager() + XSuperTowerManager.InitFunctionManager() + XSuperTowerManager.InitShopManager() + InitialManagers = true + end + --=============== + --初始化活动配置 + --=============== + local CurrentActivityCfg + function XSuperTowerManager.InitActivityCfg() + CurrentActivityCfg = XSuperTowerConfigs.GetCurrentActivity() + end + --=============== + --初始化关卡管理器 + --=============== + function XSuperTowerManager.InitStageManager() + local script = require("XEntity/XSuperTower/Stages/XSuperTowerStageManager") + StageManager = script.New(XSuperTowerManager) + end + --=============== + --初始化角色管理器 + --=============== + function XSuperTowerManager.InitRoleManager() + local script = require("XEntity/XSuperTower/Role/XSuperTowerRoleManager") + RoleManager = script.New(XSuperTowerManager) + end + + function XSuperTowerManager.InitFunctionManager() + local script = require("XEntity/XSuperTower/Function/XSuperTowerFunctionManager") + FunctionManager = script.New(XSuperTowerManager) + end + --=============== + --初始化队伍管理器 + --=============== + function XSuperTowerManager.InitTeamManager() + local script = require("XEntity/XSuperTower/XSuperTowerTeamManager") + TeamManager = script.New(XSuperTowerManager) + end + --=============== + --获取队伍管理器 + --=============== + function XSuperTowerManager.InitBagManager() + local script = require("XEntity/XSuperTower/XSuperTowerBagManager") + BagManager = script.New(XSuperTowerManager) + end + --=============== + --初始化商店管理器 + --=============== + function XSuperTowerManager.InitShopManager() + local script = require("XEntity/XSuperTower/Shop/XSuperTowerShopManager") + ShopManager = script.New(XSuperTowerManager) + end + --=============== + --FubenManager代理方法:初始化StageInfo + --=============== + function XSuperTowerManager.InitStageInfo() + if StageManager then + StageManager:InitStageInfo() + end + end + --=============== + --FubenManager代理方法:检查stageId是否有通关 + --=============== + function XSuperTowerManager.CheckPassedByStageId(stageId) + local targetStage = StageManager:GetTargetStageByStageId(stageId) + if targetStage then + return targetStage:CheckIsClear() + else + return false + end + end + --=============== + --FubenManager代理方法:出战前检查 + --=============== + function XSuperTowerManager.CheckPreFight(stage, challengeCount) + local stageType = XSuperTowerManager.GetStageTypeByStageId(stage.StageId) + if stageType == XSuperTowerManager.StageType.None then + XUiManager.TipError("关卡不存在!") + return false + elseif stageType == XSuperTowerManager.StageType.LllimitedTower then + local team = XSuperTowerManager.GetTeamByStageId(stage.StageId) + --爬塔需要3个人 + local isFullMember = team:GetIsFullMember() + if not isFullMember then XUiManager.TipText("STTierStageNotFullMemember") end + return isFullMember + else + --XUiManager.TipMsg("TODO -- 目标关卡战斗前检查") + return true + end + end + --=============== + --FubenManager代理方法:准备出战数据 + --=============== + function XSuperTowerManager.PreFight(stage, team, isAssist, challengeCount, challengeId) + local preFight = {} + preFight.CardIds = {} + preFight.RobotIds = {} + preFight.StageId = stage.StageId + preFight.IsHasAssist = isAssist and true or false + preFight.ChallengeCount = challengeCount or 1 + local stageType = XSuperTowerManager.GetStageTypeByStageId(stage.StageId) + if stageType == XSuperTowerManager.StageType.None then + return nil + else + local team = XSuperTowerManager.GetTeamByStageId(stage.StageId) + if team then + for i = 1, 3 do + local entityId = team:GetEntityIdByTeamPos(i) + local role = RoleManager:GetRole(entityId) + preFight.CardIds[i] = role and role:GetCharacterId() or 0 + if role and role:GetIsRobot() then + preFight.RobotIds[i] = role:GetId() + else + preFight.RobotIds[i] = 0 + end + end + preFight.CaptainPos = team:GetCaptainPos() + preFight.FirstFightPos = team:GetFirstFightPos() + end + end + return preFight + end + --=============== + --FubenManager代理方法:结束战斗 + --=============== + function XSuperTowerManager.FinishFight(settleData) + if not IsCallFinishBattle then + HoldFinishBattle = true + HoldSettleData = settleData + return + end + local stageInfo = XDataCenter.FubenManager.GetStageInfo(settleData.StageId) + if stageInfo.Type ~= XDataCenter.FubenManager.StageType.SuperTower then + return + end + + local stageId = settleData.StageId + local stageType = XSuperTowerManager.GetStageTypeByStageId(stageId) + if stageType == XSuperTowerManager.StageType.LllimitedTower then + XSuperTowerManager.TierStageFinish(settleData) + else + XSuperTowerManager.TargetStageFinish(settleData) + end + + IsShowSettleDark = false + HoldFinishBattle = false + IsCallFinishBattle = false + HoldSettleData = nil + end + --=============== + --FubenManager代理方法:调用结算战斗时 + --=============== + function XSuperTowerManager.CallFinishFight() + local XFubenManager = XDataCenter.FubenManager + local res = XFubenManager.FubenSettleResult + XFubenManager.FubenSettling = false + XFubenManager.FubenSettleResult = nil + + --通知战斗结束,关闭战斗设置页面 + CS.XGameEventManager.Instance:Notify(XEventId.EVENT_FIGHT_FINISH) + + if not res then + IsShowSettleDark = true + IsCallFinishBattle = true + return + end + + if res.Code ~= XCode.Success then + CS.XGameEventManager.Instance:Notify(XEventId.EVENT_FUBEN_SETTLE_FAIL, res.Code) + return + end + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_FIGHT_RESULT, res.Settle) + IsCallFinishBattle = true + if HoldFinishBattle then + XSuperTowerManager.FinishFight(HoldSettleData) + end + end + --=============== + --进入战斗 + --=============== + function XSuperTowerManager.EnterFight(stageId) + local stageConfig = XDataCenter.FubenManager.GetStageCfg(stageId) + local stageType = XSuperTowerManager.GetStageTypeByStageId(stageId) + if stageType == XSuperTowerManager.StageType.None then + XUiHelper.GetText("STNoStageType") + return + elseif stageType == XSuperTowerManager.StageType.LllimitedTower then --爬塔直接调用EnterFight + local isAssist = false + local challengeCount = 1 + XDataCenter.FubenManager.EnterFight(stageConfig, nil, isAssist, challengeCount) + else --目标关卡需先设定队伍信息,成功后再进入关卡 + local isAssist = false + local challengeCount = 1 + XDataCenter.FubenManager.EnterFight(stageConfig, nil, isAssist, challengeCount) + end + end + --=============== + --爬塔关卡结束时 + --=============== + function XSuperTowerManager.TierStageFinish(settleData) + local theme = StageManager:GetThemeByStageId(settleData.StageId) + XSuperTowerManager:GetStageManager():RefreshStMapTierData(settleData.stMapTierDataOperation) + --[[if settleData.IsWin then + if theme:GetResetFlag() then + XLuaUiManager.Open("UiSuperTowerInfiniteSettleWin", settleData) + end + else + if theme:GetResetFlag() then + XLuaUiManager.Open("UiSuperTowerInfiniteSettleWin", settleData) + end + end]] + --XLog.Debug("================爬塔关卡结束:SettleData:", settleData) + if theme:GetResetFlag() then + XLuaUiManager.Open("UiSuperTowerInfiniteSettleWin", settleData) + end + end + --=============== + --目标关卡结束时 + --=============== + function XSuperTowerManager.TargetStageFinish(settleData) + local stageId = settleData.StageId + local stageType = XSuperTowerManager.GetStageTypeByStageId(stageId) + local targetStage = XSuperTowerManager.GetTargetStageByStageId(stageId) + XSuperTowerManager.GetStageManager():SetTempProgress(settleData.stTargetStageFightResult) + local tempProgress = StageManager:GetTempProgressByTargetId(targetStage:GetId()) + local IsMultiTeam = stageType ==XSuperTowerManager.StageType.MultiTeamMultiWave + local teamList = IsMultiTeam and XSuperTowerManager.GetTeamByStageId(stageId) or + {XSuperTowerManager.GetTeamByStageId(stageId)} + + if IsMultiTeam then + local teamCount = targetStage:GetTeamCount() + teamList = XSuperTowerManager.GetTeamByStageType(stageType,teamCount) + else + teamList = {XSuperTowerManager.GetTeamByStageId(stageId)} + end + + local battledTeamList = {} + local pulginList = {} + for index,team in pairs(teamList or {}) do + if index <= tempProgress then + local pluginSlotManger = team:GetExtraData() + local plugins = pluginSlotManger:GetPlugins() + for _,plugin in pairs(plugins or {}) do + if type(plugin) == "table" then + table.insert(pulginList, plugin) + end + end + table.insert(battledTeamList, team) + end + end + if settleData.IsWin and IsMultiTeam then + if not StageManager:IsSetTempProgress() then + XLog.Error("SuperTower SetTempProgress Is Late!") + end + StageManager:ClearTempProgressMark() + + if tempProgress < targetStage:GetProgress() then + local nextIndex = tempProgress + 1 + local nextStageId = targetStage:GetStageIdByIndex(nextIndex) + local nextTeam = XSuperTowerManager.GetTeamByStageId(nextStageId) + XSuperTowerManager.EnterFight(nextStageId) + else + XLuaUiManager.Open("UiSuperTowerSettleWin",targetStage, pulginList, tempProgress, battledTeamList) + end + else + XLuaUiManager.Open("UiSuperTowerSettleWin",targetStage, pulginList, tempProgress, battledTeamList) + end + end + ------------------------------------------------------------------ + ------------------------------------------------------------------ + --=============== + --获取当前活动配置ID + --=============== + function XSuperTowerManager.GetActivityId() + if not CurrentActivityCfg then + DebugNoCurrentActivityCfg() + return 1 + end + return CurrentActivityCfg.Id + end + --=============== + --获取当前活动TimeId + --=============== + function XSuperTowerManager.GetActivityTimeId() + if not CurrentActivityCfg then + DebugNoCurrentActivityCfg() + return 0 + end + return CurrentActivityCfg.TimeId + end + --=============== + --获取当前活动的主题组ID + --=============== + function XSuperTowerManager.GetThemeIds() + if not CurrentActivityCfg then + DebugNoCurrentActivityCfg() + return {} + end + return CurrentActivityCfg.MapId + end + --=============== + --获取当前活动的名字 + --=============== + function XSuperTowerManager.GetActivityName() + if not CurrentActivityCfg then + DebugNoCurrentActivityCfg() + return {} + end + return CurrentActivityCfg.Name + end + + function XSuperTowerManager.GetActivityEntryImage() + if not CurrentActivityCfg then + DebugNoCurrentActivityCfg() + return "" + end + return CurrentActivityCfg.EntryImage + end + --=============== + --获取当前活动序言故事ID + --=============== + function XSuperTowerManager.GetPrefaceStoryId() + if not CurrentActivityCfg then + DebugNoCurrentActivityCfg() + return {} + end + return CurrentActivityCfg.PrefaceStoryId + end + --=============== + --获取背包管理器 + --=============== + function XSuperTowerManager.GetBagManager() + return BagManager + end + --=============== + --获取角色管理器 + --=============== + function XSuperTowerManager.GetRoleManager() + return RoleManager + end + --=============== + --获取关卡管理器 + --=============== + function XSuperTowerManager.GetStageManager() + return StageManager + end + --=============== + --获取队伍管理器 + --=============== + function XSuperTowerManager.GetTeamManager() + return TeamManager + end + --=============== + --获取特权管理器 + --=============== + function XSuperTowerManager.GetFunctionManager() + return FunctionManager + end + --=============== + --获取商店管理器 + --=============== + ---@return XSuperTowerShopManager + function XSuperTowerManager.GetShopManager() + return ShopManager + end + --=============== + --检测结算遮罩是否打开 + --=============== + ---@return IsShowSettleDark + function XSuperTowerManager.CheckShowSettleDark() + return IsShowSettleDark + end + --=============== + --获取当前活动开始时间戳(根据TimeId) + --=============== + function XSuperTowerManager.GetActivityStartTime() + return XFunctionManager.GetStartTimeByTimeId(XSuperTowerManager.GetActivityTimeId()) + end + --=============== + --获取当前活动结束时间戳(根据TimeId) + --=============== + function XSuperTowerManager.GetActivityEndTime() + return XFunctionManager.GetEndTimeByTimeId(XSuperTowerManager.GetActivityTimeId()) + end + --=============== + --根据关卡Id获取关卡类型(XSuperTowerManager.StageType) + --若查不到结果,会返回XSuperTowerManager.StageType.None + --@param stageId:关卡Id + --=============== + function XSuperTowerManager.GetStageTypeByStageId(stageId) + return StageManager:GetStageTypeByStageId(stageId) + end + --=============== + --根据关卡Id获取关卡序号 + --若查不到结果,会返回0 + --@param stageId:关卡Id + --=============== + function XSuperTowerManager.GetStageIndexByStageId(stageId) + return StageManager:GetStageIndexByStageId(stageId) + end + --=============== + --根据关卡Id获取队伍ID + --若查不到结果,会返回nil + --@param stageId:关卡Id + --=============== + function XSuperTowerManager.GetTeamIdByStageId(stageId) + local stageType = XSuperTowerManager.GetStageTypeByStageId(stageId) + return XSuperTowerManager.GetTeamIdByStageType(stageType) + end + --=============== + --根据关卡类型获取队伍ID + --若查不到结果,会返回nil + --@param stageType:(XSuperTowerManager.StageType) + --=============== + function XSuperTowerManager.GetTeamIdByStageType(stageType) + return XSuperTowerManager.TeamId[stageType] + end + --=============== + --根据关卡ID获取队伍对象 + --若查不到结果,会返回nil + --@param stageId:关卡Id + --=============== + function XSuperTowerManager.GetTeamByStageId(stageId) + local teamId = XSuperTowerManager.GetTeamIdByStageId(stageId) + local stageIndex = XSuperTowerManager.GetStageIndexByStageId(stageId) + + if teamId and stageIndex > 0 then + return TeamManager:GetTeamById(teamId, stageIndex) + end + return nil + end + --=============== + --=============== + --根据关卡类型获取队伍对象(多队伍时会返回该类型所有队伍对象) + --若查不到结果,会返回nil + --@param stageType:(XSuperTowerManager.StageType) + --@param teamCount:多队伍类型时需要获取的队伍数 + --=============== + function XSuperTowerManager.GetTeamByStageType(stageType, teamCount) + local teamId = XSuperTowerManager.GetTeamIdByStageType(stageType) + if teamId then + if stageType == XSuperTowerManager.StageType.MultiTeamMultiWave then + local teamList = {} + local count = teamCount or 0 + for index = 1, count do + table.insert(teamList, TeamManager:GetTeamById(teamId, index)) + end + return next(teamList) and teamList + else + return TeamManager:GetTeamById(teamId)--单队伍时不需要设置关卡序号(有且仅有1),默认为1 + end + end + return nil + end + --=============== + --根据关卡ID获取目标关卡ID + --=============== + function XSuperTowerManager.GetTargetStageIdByStageId(stageId) + return StageManager:GetTargetStageIdByStageId(stageId) + end + --=============== + --根据关卡ID获取目标关卡的关卡数量 + --=============== + function XSuperTowerManager.GetTargetStageCountByStageId(stageId) + local targetStage = StageManager:GetTargetStageByStageId(stageId) + if targetStage == nil then return 0 end + return #targetStage:GetStageId() + end + --=============== + --根据关卡ID获取目标关卡数据实体 + --=============== + function XSuperTowerManager.GetTargetStageByStageId(stageId) + return StageManager:GetTargetStageByStageId(stageId) + end + --=============== + --根据关卡Id获取关卡在目标关卡中的序号 + --=============== + function XSuperTowerManager.GetStageIndexByStageId(stageId) + return StageManager:GetStageIndexByStageId(stageId) + end + --=============== + --根据队伍实体获取该队伍中所有角色ID + --=============== + function XSuperTowerManager.GetCharacterIdListByTeamEntity(stTeam) + local characterIds = {} + if stTeam then + for index,id in pairs(stTeam:GetEntityIds()) do + local role = RoleManager:GetRole(id) + if role then + characterIds[index] = role:GetCharacterId() + else + characterIds[index] = 0 + end + end + end + return characterIds + end + --=============== + --清除多队伍关卡的所有队伍数据 + --=============== + function XSuperTowerManager.ClearAllMultiTeamsData() + local teamMaxCount = StageManager:GetMaxStageCount() + local teamId = XSuperTowerManager.TeamId[XSuperTowerManager.StageType.MultiTeamMultiWave] + for index = 1,teamMaxCount do + TeamManager:ClearTeam(teamId, index) + end + end + --=============== + --一键上阵 + --=============== + function XSuperTowerManager.AutoTeam(stStage) + local normalRoleList = RoleManager:GetCanFightRoles(XCharacterConfigs.CharacterType.Normal) + local isomerRoleList = RoleManager:GetCanFightRoles(XCharacterConfigs.CharacterType.Isomer) + + XSuperTowerManager.ClearAllMultiTeamsData() + + local stageIdList = stStage:GetStageId() + + table.sort(normalRoleList, function(a, b) + return a:GetAbility() > b:GetAbility() + end) + table.sort(isomerRoleList, function(a, b) + return a:GetAbility() > b:GetAbility() + end) + + -- 正在使用的角色id字典 + local usingCharacterIdDic = {} + + for index,stageId in pairs(stageIdList or {}) do --优先选择倾向构造体 + local memberCount = stStage:GetMemberCountByIndex(index) + local recommendType = XFubenConfigs.GetStageRecommendCharacterType(stageId) or XCharacterConfigs.CharacterType.Normal + local team = XSuperTowerManager.GetTeamByStageId(stageId) + team:Clear() + local charIndex = 1 + local curCount = 1 + + local roleList + if recommendType == XCharacterConfigs.CharacterType.Isomer then + roleList = isomerRoleList + elseif recommendType == XCharacterConfigs.CharacterType.Normal then + roleList = normalRoleList + end + + while curCount <= memberCount do + local role = roleList[charIndex] + if role then + if XFubenConfigs.IsStageRecommendCharacterType(stageId, role:GetId()) and + -- not team:CheckHasSameCharacterId(role:GetId() + not usingCharacterIdDic[role:GetCharacterId()] then + + team:UpdateEntityTeamPos(role:GetId(), curCount, true) + usingCharacterIdDic[role:GetCharacterId()] = true + if curCount == 1 then + team:UpdateFirstFightPos(curCount) + team:UpdateCaptianPos(curCount) + end + + table.remove(roleList,charIndex) + charIndex = charIndex - 1 + curCount = curCount + 1 + end + else + break + end + charIndex = charIndex + 1 + end + end + + for index,stageId in pairs(stageIdList or {}) do --补足非倾向构造体 + local memberCount = stStage:GetMemberCountByIndex(index) + local recommendType = XFubenConfigs.GetStageRecommendCharacterType(stageId) or XCharacterConfigs.CharacterType.Normal + local team = XSuperTowerManager.GetTeamByStageId(stageId) + local charIndex = 1 + local curCount = 1 + + local roleList + if recommendType == XCharacterConfigs.CharacterType.Isomer then + roleList = isomerRoleList + elseif recommendType == XCharacterConfigs.CharacterType.Normal then + roleList = normalRoleList + end + + while curCount <= memberCount do + if team:GetEntityIdByTeamPos(curCount) == 0 then + local role = roleList[charIndex] + if role then + -- not team:CheckHasSameCharacterId(role:GetId()) + if not usingCharacterIdDic[role:GetCharacterId()] then + team:UpdateEntityTeamPos(role:GetId(), curCount, true) + usingCharacterIdDic[role:GetCharacterId()] = true + if curCount == 1 then + team:UpdateFirstFightPos(curCount) + team:UpdateCaptianPos(curCount) + end + + table.remove(roleList,charIndex) + charIndex = charIndex - 1 + curCount = curCount + 1 + end + else + break + end + charIndex = charIndex + 1 + else + curCount = curCount + 1 + end + end + end + end + + --=============== + --一键填充插件 + --stStage : XSuperTowerTargetStage + --=============== + function XSuperTowerManager.AutoPulgin(stStage) + local teamManager = XDataCenter.SuperTowerManager.GetTeamManager() + local teams = teamManager:GetTeamsByIdAndCount(XDataCenter.SuperTowerManager.TeamId[stStage:GetStageType()] + , XSuperTowerConfigs.MaxMultiTeamCount) + teamManager:AutoSelectPlugins2Teams(teams) + end + --=============== + --检查背包与特权弹窗 + --=============== + function XSuperTowerManager.CheckPopupWindow(callBack) + local unLockFuncList = FunctionManager:GetUnlockList() + if unLockFuncList and #unLockFuncList > 0 then + XLuaUiManager.Open("UiSuperTowerUnlockTips", unLockFuncList, function() + XSuperTowerManager.CheckPopupWindow(callBack) + end) + return + end + local hasUpdate, last, current = BagManager:CheckMaxCapacityUpdate() + if hasUpdate then + XLuaUiManager.Open("UiSupertowerUpTips", last, current, function() + XSuperTowerManager.CheckPopupWindow(callBack) + end) + return + end + if callBack then + callBack() + end + end + --=============== + --根据关卡ID获取队伍对象 + --若查不到结果,会返回nil + --@param stStage:目标关卡 + --=============== + function XSuperTowerManager.CheckTeamListAllHasCaptainAndFirstPos(stStage) + local IsNotHasCaptain = false + local IsNotHasFirstPos = false + for index,stageId in pairs(stStage:GetStageId() or {}) do + local teamId = XSuperTowerManager.GetTeamIdByStageId(stageId) + if teamId then + local team = TeamManager:GetTeamById(teamId, index) + if not team:GetCaptainPosEntityId() or team:GetCaptainPosEntityId() == 0 then + IsNotHasCaptain = true + end + if not team:GetFirstFightPosEntityId() or team:GetFirstFightPosEntityId() == 0 then + IsNotHasFirstPos = true + end + end + end + return not IsNotHasCaptain, not IsNotHasFirstPos + end + --=============== + --检查现在是否在活动时间内(根据TimeId) + --=============== + function XSuperTowerManager.CheckActivityIsInTime() + local now = XTime.GetServerNowTimestamp() + return (now >= XSuperTowerManager.GetActivityStartTime()) + and (now < XSuperTowerManager.GetActivityEndTime()) + end + --=============== + --根据特权Key检查特权是否解锁 + --@param key:特权键值 XSuperTowerManager.FunctionName + --=============== + function XSuperTowerManager.CheckFunctionUnlockByKey(key) + return FunctionManager:CheckFunctionUnlockByKey(key) + end + ------------------------------------------------------------------ + ------------------------------------------------------------------ + --=============== + --获取主题选择状态的本地数据 + -- + --=============== + function XSuperTowerManager.GetCurSelectThemeIndex() + local activityId = XSuperTowerManager.GetActivityId() + return XSaveTool.GetData(string.format( "%sSuperTowerCurSelectThemeIndex%s", XPlayer.Id, activityId)) + end + --=============== + --保存主题选择状态的本地数据 + --index:主题序号 + --=============== + function XSuperTowerManager.SaveCurSelectThemeIndex(index) + local activityId = XSuperTowerManager.GetActivityId() + local data = XSaveTool.GetData(string.format( "%sSuperTowerCurSelectThemeIndex%s", XPlayer.Id, activityId)) + if not data then + XSaveTool.SaveData(string.format( "%sSuperTowerCurSelectThemeIndex%s", XPlayer.Id, activityId), index) + end + end + --=============== + --删除主题选择状态的本地数据 + --=============== + function XSuperTowerManager.RemoveCurSelectThemeIndex() + local activityId = XSuperTowerManager.GetActivityId() + local data = XSaveTool.GetData(string.format( "%sSuperTowerCurSelectThemeIndex%s", XPlayer.Id, activityId)) + if data then + XSaveTool.RemoveData(string.format( "%sSuperTowerCurSelectThemeIndex%s", XPlayer.Id, activityId)) + end + end + ------------------------------------------------------------------ + ------------------------------------------------------------------ + --===================== + --确认目标关卡战斗结果 + --@param targetStageId :目标关卡ID + --@response res.RewardGoodsList :奖励列表 + --===================== + function XSuperTowerManager.ConfirmTargetResultRequest(targetStageId, cb) + XNetwork.Call(METHOD_NAME.StConfirmTargetResultRequest, {TargetId = targetStageId}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + if cb then cb(res.RewardGoodsList) end + end) + end + ------------------------------------------------------------------ + ------------------------------------------------------------------ + --===================== + --处理登陆活动内容推送 + --@data : { + -- 活动id public int Id, + -- 地图信息列表 public List MapInfos, + -- 超限角色信息 public List CharacterInfos, + -- 背包信息 public StBagInfo BagInfo } + --===================== + function XSuperTowerManager.RefreshLoginData(data) + if data and next(data) and not InitialManagers then + XSuperTowerManager.InitManagers() + XSuperTowerManager.InitStageInfo() + end + StageManager:RefreshNotifyMapInfo(data.MapInfos) + RoleManager:InitWithServerData(data.CharacterInfos) + BagManager:InitWithServerData(data.BagInfo) + ShopManager:UpdateShopData(data.MallInfo) + FunctionManager:SetUnLockEvent() --初始化特权需要在首次刷新关卡数据的时候 + end + --===================== + --替换fubenmanager里的OpenFightLoading() + --===================== + function XSuperTowerManager.OpenFightLoading(stageId) + local stageType = XSuperTowerManager.GetStageTypeByStageId(stageId) + if stageType == XSuperTowerManager.StageType.MultiTeamMultiWave then + local targetStage = XSuperTowerManager.GetTargetStageByStageId(stageId) + local tempProgress = StageManager:GetTempProgressByTargetId(targetStage:GetId()) + XLuaUiManager.Open("UiSuperTowerLoading", targetStage, tempProgress + 1) + else + XDataCenter.FubenManager.OpenFightLoading(stageId) + end + end + --===================== + --替换fubenmanager里的CloseFightLoading() + --===================== + function XSuperTowerManager.CloseFightLoading(stageId) + local stageType = XSuperTowerManager.GetStageTypeByStageId(stageId) + if stageType == XSuperTowerManager.StageType.MultiTeamMultiWave then + if XLuaUiManager.IsUiLoad("UiSuperTowerLoading") then + XLuaUiManager.Remove("UiSuperTowerLoading") + end + else + XDataCenter.FubenManager.CloseFightLoading(stageId) + end + end + --=================================入口,跳转相关============================= + --=================== + --获取活动配置简表 + --=================== + function XSuperTowerManager.GetActivityChapters() + --只有活动开启期间显示入口 + local isEnd = XSuperTowerManager.GetIsEnd() + if isEnd then return {} end + local chapters = {} + local tempChapter = {} + tempChapter.Type = XDataCenter.FubenManager.ChapterType.SuperTower + tempChapter.Id = XSuperTowerManager.GetActivityId() + table.insert(chapters, tempChapter) + return chapters + end + --================ + --跳转到活动主界面 + --================ + function XSuperTowerManager.JumpTo() + if XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.SuperTower) then + local canGoTo, notStart = XSuperTowerManager.CheckCanGoTo() + if canGoTo then + XLuaUiManager.Open("UiSuperTowerMain") + elseif notStart then + XUiManager.TipMsg(CS.XTextManager.GetText("CommonActivityNotStart")) + else + XUiManager.TipMsg(CS.XTextManager.GetText("CommonActivityEnd")) + end + end + end + --================ + --检查是否能进入玩法 + --@return param1:是否在活动时间内(true为在活动时间内) + --@return param2:是否未开始活动(true为未开始活动) + --================ + function XSuperTowerManager.CheckCanGoTo() + local isActivityEnd, notStart = XSuperTowerManager.GetIsEnd() + return not isActivityEnd, notStart + end + --================ + --跳转到爬塔关卡准备界面 + --若有正在爬的塔则跳转到正在爬的塔 + --没有的话跳转到最新章节的塔 + --================ + function XSuperTowerManager.SkipToSuperTowerTier() + local playingId = StageManager:GetPlayingTierId() + local theme + if playingId > 0 then + theme = StageManager:GetThemeById(playingId) + else + theme = StageManager:GetThemeByClearProgress() + end + XLuaUiManager.Open("UiSuperTowerStageDetail04", theme) + end + --================ + --获取玩法是否关闭(用于判断玩法入口,进入活动条件等) + --@return param1:玩法是否关闭 + --@return param2:是否活动未开启 + --================ + function XSuperTowerManager.GetIsEnd() + local timeNow = XTime.GetServerNowTimestamp() + local isEnd = timeNow >= XSuperTowerManager.GetActivityEndTime() + local isStart = timeNow >= XSuperTowerManager.GetActivityStartTime() + local inActivity = (not isEnd) and (isStart) + return not inActivity, timeNow < XSuperTowerManager.GetActivityStartTime() + end + --================ + --玩法关闭时弹出主界面 + --================ + function XSuperTowerManager.HandleActivityEndTime() + XLuaUiManager.RunMain() + XUiManager.TipMsg(CS.XTextManager.GetText("STActivityTimeEnd")) + end + --===================================================================== + XSuperTowerManager.Init() + XEventManager.AddEventListener(XEventId.EVENT_FUBEN_SETTLE_REWARD,XSuperTowerManager.FinishFight) + return XSuperTowerManager +end +--===================== +--登陆活动内容推送 +--@data : { +-- 活动id public int Id, +-- 地图信息列表 public List MapInfos, +-- 超限角色信息 public List CharacterInfos, +-- 背包信息 public StBagInfo BagInfo } +--===================== +XRpc.NotifySuperTowerLoginData = function(data) + XDataCenter.SuperTowerManager.RefreshLoginData(data) +end +--[[ +XRpc.NotifyStMapTierData = function(data) + XDataCenter.SuperTowerManager.GetStageManager():RefreshStMapTierData(data) +end +]] +XRpc.NotifyStMapTargetData = function(data) + XDataCenter.SuperTowerManager.GetStageManager():RefreshStMapTargetData(data) +end +--[[ +XRpc.NotifyTargetStageFightResult = function(data) + XDataCenter.SuperTowerManager.GetStageManager():SetTempProgress(data) +end +]] +XRpc.NotifySuperTowerMallRefreshData = function(data) + local shopManager = XDataCenter.SuperTowerManager.GetShopManager() + if shopManager then + shopManager:OnrMallRefreshData(data) + end +end +XRpc.NotifySuperTowerMallData = function(data) + local shopManager = XDataCenter.SuperTowerManager.GetShopManager() + if shopManager then + shopManager:UpdateShopData(data.MallInfo) + end +end +-- 背包最大容量 +XRpc.NotifyStBagCapacity = function(data) + XDataCenter.SuperTowerManager.GetBagManager():UpdateMaxCapacity(data.Capacity) +end +-- 背包插件更新 +XRpc.NotifyStBagPluginChange = function(data) + XDataCenter.SuperTowerManager.GetBagManager():OnBagPluginChange(data) +end +-- 通知背包插件合成数据 +-- data : List +XRpc.NotifyStBagPluginSynthesisData = function(pluginSynthesisInfos) + XDataCenter.SuperTowerManager.GetBagManager():OnBagPluginSynthesisData(pluginSynthesisInfos) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XTRPGManager.lua b/Resources/Scripts/XManager/XTRPGManager.lua new file mode 100644 index 00000000..7e41d128 --- /dev/null +++ b/Resources/Scripts/XManager/XTRPGManager.lua @@ -0,0 +1,2271 @@ +local XTRPGMaze = require("XEntity/XTRPG/XTRPGMaze") +local XTRPGBaseInfo = require("XEntity/XTRPG/XTRPGBaseInfo") +local XTRPGThirdAreaInfo = require("XEntity/XTRPG/XTRPGThirdAreaInfo") +local XTRPGRole = require("XEntity/XTRPG/XTRPGRole") +local XTRPGClientShopInfo = require("XEntity/XTRPG/XTRPGClientShopInfo") +local XTRPGBossInfo = require("XEntity/XTRPG/XTRPGBossInfo") +local XTRPGExamine = require("XEntity/XTRPG/XTRPGExamine") + +XTRPGManagerCreator = function() + local tableInsert = table.insert + local tableSort = table.sort + local tonumber = tonumber + local mathFloor = math.floor + local mathMax = math.max + local mathCeil = math.ceil + local pairs = pairs + local CSXTextManagerGetText = CS.XTextManager.GetText + local stringFormat = string.format + + local BaseInfo = XTRPGBaseInfo.New() + local TargetList = {} --已完成的目标 + local RewardList = {} --已领取的奖励id + local ThirdAreaInfos = {} + local DEFUALT_thirdAreaId_FOR_STUPID_DESIGN = -1--数据不一致兼容 + local Roles = {} + local ShopInfos = {} + local MazeInfos = {} + local MemoirList = {} + local ItemList = {} + local BossInfo = XTRPGBossInfo.New() + local CurrTargetId = 0 + local CurrTargetLinkId = 0 + local AddItemMaxCountNum = 0 + local CurExmaine = XTRPGExamine.New() --当前检定信息 + local AlreadyOpenMazeList = {} --已开启的迷宫列表 + local CurrAreaOpenNum = 0 + local OldCurrTargetId = 0 + local NewTargetTime = 0 + local IsCanCheckOpenNewMaze = false + local IsNormalPage = false --当前跑团页面模式,false是探索,true是常规主线 + local StagePassDic = {} --已完成关卡记录 + + local BagHideItemIdList = { + [XDataCenter.ItemManager.ItemId.TRPGTalen] = 1, + [XDataCenter.ItemManager.ItemId.TRPGMoney] = 1, + [XDataCenter.ItemManager.ItemId.TRPGEXP] = 1, + [XDataCenter.ItemManager.ItemId.TRPGEndurance] = 1, + } + + ---------------------本地接口 begin------------------ + local function UpdateShopInfos(shopInfos) + if not shopInfos then return end + for _, v in pairs(shopInfos) do + if not ShopInfos[v.Id] then + ShopInfos[v.Id] = XTRPGClientShopInfo.New() + end + ShopInfos[v.Id]:UpdateData(v) + end + CsXGameEventManager.Instance:Notify(XEventId.EVENT_TRPG_SHOP_INFO_CHANGE) + end + + local function UpdateShopExtraData(extraDatas) + if not extraDatas then return end + for _, v in ipairs(extraDatas) do + if not ShopInfos[v.Id] then + ShopInfos[v.Id] = XTRPGClientShopInfo.New() + end + ShopInfos[v.Id]:UpdateData(v) + end + CsXGameEventManager.Instance:Notify(XEventId.EVENT_TRPG_SHOP_INFO_CHANGE) + end + + local function AddBuyTimes(shopId, itemId, count) + if not ShopInfos[shopId] then + XLog.Error("XTRPGManager AddBuyTimes Error: can not found shop, shopId is " .. shopId) + return + end + ShopInfos[shopId]:AddItemBuyCount(itemId, count) + end + + local function UpdateCurrTargetLinkId(currTargetLinkId, isNotPlayNewAnima) + local currTargetLinkIsFinish, targetId = XDataCenter.TRPGManager.GetTargetLinkIsFinish(currTargetLinkId) + if currTargetLinkIsFinish then + CurrTargetLinkId, CurrTargetId = XDataCenter.TRPGManager.GetOneCanFindTarget() + else + CurrTargetLinkId, CurrTargetId = currTargetLinkId, targetId + end + XEventManager.DispatchEvent(XEventId.EVENT_TRPG_UPDATE_TARGET, isNotPlayNewAnima) + end + + local function UpdateMemoirInfos(memoirList) + for _, memoirId in pairs(memoirList) do + MemoirList[memoirId] = 1 + end + end + + local function UpdateBossInfo(bossInfo) + if not bossInfo then return end + BossInfo:UpdateBaseData(bossInfo) + end + + local function UpdateBossHpInfo(hpInfo) + if not hpInfo then return end + BossInfo:UpdateHpData(hpInfo) + XEventManager.DispatchEvent(XEventId.EVENT_TRPG_BOSS_HP_SYN) + end + + local function UpdateBossPhasesRewardListInfo(PhasesRewardList) + if not PhasesRewardList then return end + BossInfo:UpdatePhasesRewardList(PhasesRewardList) + end + + local function UpdateWorldBossChallengeCount(count) + BossInfo:UpdateWorldBossChallengeCount(count) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_TRPG_WORLDBOSS_SYNCDATA) + end + + local function UpdateRewardList(rewardList) + if not rewardList then return end + for _, rewardId in pairs(rewardList) do + RewardList[rewardId] = 1 + end + end + + local function UpdateTargetList(targetList) + if not targetList then return end + for _, targetId in pairs(targetList) do + if not TargetList[targetId] then + TargetList[targetId] = 1 + end + end + end + + local function UpdateAlreadyOpenMaze(mazeId) + AlreadyOpenMazeList[mazeId] = 1 + end + + local function IsOpenMaze(mazeId) + return AlreadyOpenMazeList[mazeId] + end + + local function InitAleardyOpenMazeList() + local secondAreaIdToMazeIdDic = XTRPGConfigs.GetSecondAreaIdToMazeIdDic() + local condition, ret + for secondAreaId, mazeId in pairs(secondAreaIdToMazeIdDic) do + condition = XTRPGConfigs.GetSecondAreaCondition(secondAreaId) + ret = XConditionManager.CheckCondition(condition) + if ret then + UpdateAlreadyOpenMaze(mazeId) + end + end + end + + local function UpdateOldCurrTargetId() + OldCurrTargetId = XDataCenter.TRPGManager.GetCurrTargetId() + end + + local function GetOldCurrTargetId() + return OldCurrTargetId + end + + local function SetIsCanCheckOpenNewMaze(isCanCheckOpenNewMaze) + IsCanCheckOpenNewMaze = isCanCheckOpenNewMaze + end + + local function SetIsNormalPage(isNormalPage) + IsNormalPage = isNormalPage + end + + local function UpdateStagePassDic(stageList) + for _, stageId in ipairs(stageList or {}) do + StagePassDic[stageId] = true + end + end + ---------------------本地接口 end------------------ + local XTRPGManager = {} + + -----------------功能入口begin---------------- + function XTRPGManager.GetProgress() + local areaMaxNum = XTRPGConfigs.GetMainAreaMaxNum() + local curAreaPercent + local totalPercent = 0 + for id = 1, areaMaxNum do + curAreaPercent = XTRPGManager.GetAreaRewardPercent(id) + curAreaPercent = curAreaPercent / areaMaxNum + totalPercent = totalPercent + curAreaPercent + end + return mathFloor(totalPercent * 100) + end + + function XTRPGManager.InitCurrAreaOpenNum() + local currAreaOpenNum = XSaveTool.GetData("TRPGCurrAreaOpenNum_" .. XPlayer.Id) + if currAreaOpenNum then + XTRPGManager.SetCurrAreaOpenNum(currAreaOpenNum) + end + end + + function XTRPGManager.SetCurrAreaOpenNum(currAreaOpenNum) + CurrAreaOpenNum = currAreaOpenNum + end + + function XTRPGManager.UpdateCurrAreaOpenNum() + local areaOpenNum = XTRPGManager.GetAreaOpenNum() + XTRPGManager.SetCurrAreaOpenNum(areaOpenNum) + XSaveTool.SaveData("TRPGCurrAreaOpenNum_" .. XPlayer.Id, areaOpenNum) + end + + function XTRPGManager.IsActivityShowTag() + local areaOpenNum = XTRPGManager.GetAreaOpenNum() + return CurrAreaOpenNum ~= areaOpenNum + end + + function XTRPGManager.IsTRPGClear() + local progress = XTRPGManager.GetProgress() + return progress == 100 + end + -----------------功能入口end------------------ + -----------------迷宫begin---------------- + local __CurrentMazeId = 0 + + local function GetMaze(mazeId) + return MazeInfos[mazeId] + end + + local function InitMazes() + local mazeIds = XTRPGConfigs.GetMazeIds() + for mazeId in pairs(mazeIds) do + local maze = GetMaze(mazeId) + if not maze then + maze = XTRPGMaze.New(mazeId) + MazeInfos[mazeId] = maze + end + end + end + + local function UpdateMazeInfo(data) + if not data then return end + local mazeId = data.Id + local maze = GetMaze(mazeId) + maze:UpdateData(data) + end + + local function UpdateMazeInfos(mazeInfos) + if not mazeInfos then return end + for _, data in pairs(mazeInfos) do + UpdateMazeInfo(data) + end + end + + function XTRPGManager.EnterMaze(mazeId) + __CurrentMazeId = mazeId + + local maze = GetMaze(mazeId) + maze:Enter() + + XTRPGManager.UnlockSelectCard() + + XLuaUiManager.Open("UiTRPGMaze", mazeId) + end + + function XTRPGManager.QuitMaze() + if __CurrentMazeId == 0 then return end + + __CurrentMazeId = 0 + + if XLuaUiManager.IsUiShow("UiTRPGMaze") then + XLuaUiManager.Close("UiTRPGMaze") + end + end + + function XTRPGManager.TipQuitMaze(callBack) + local title = CSXTextManagerGetText("TRPGMazeLeaveTipTitle") + local content = CSXTextManagerGetText("TRPGMazeLeaveTipContent") + XUiManager.DialogTip(title, content, XUiManager.DialogType.Normal, nil, callBack) + end + + function XTRPGManager.TipCurrentMaze() + if __CurrentMazeId == 0 then return end + + local mazeId = __CurrentMazeId + local mazeName = XTRPGConfigs.GetMazeName(mazeId) + + local layerId = XTRPGManager.GetMazeCurrentLayerId(mazeId) + local layerName = XTRPGConfigs.GetMazeLayerName(layerId) + + local msg = CSXTextManagerGetText("TRPGMazeTipCurrentPos", mazeName, layerName) + XUiManager.TipMsg(msg) + end + + local function RestartCurrentMaze() + if __CurrentMazeId == 0 then return end + + local maze = GetMaze(__CurrentMazeId) + maze:RestartCurrentLayer() + end + + local _ToRestartCurrentMaze + function XTRPGManager.ReqMazeRestart() + if __CurrentMazeId == 0 then return end + + RestartCurrentMaze() + + if XLuaUiManager.IsUiShow("UiTRPGMaze") then + CsXGameEventManager.Instance:Notify(XEventId.EVENT_TRPG_MAZE_RESTART) + else + _ToRestartCurrentMaze = true + end + end + + function XTRPGManager.IsMazeNeedRestart() + return _ToRestartCurrentMaze or false + end + + function XTRPGManager.ClearMazeNeedRestart() + _ToRestartCurrentMaze = nil + end + + function XTRPGManager.GetMazeCurrentLayerId(mazeId) + local maze = GetMaze(mazeId) + return maze:GetCurrentLayerId() + end + + function XTRPGManager.GetMazeCurrentNodeId(mazeId) + local maze = GetMaze(mazeId) + return maze:GetCurrentNodeId() + end + + function XTRPGManager.GetMazeCurrentStandNodeIndex(mazeId, layerId) + local maze = GetMaze(mazeId) + return maze:GetCurrentStandNodeIndex(layerId) + end + + function XTRPGManager.GetMazeProgress(mazeId) + local maze = GetMaze(mazeId) + return maze:GetProgress() + end + + function XTRPGManager.GetMazeNodeIdList(mazeId, layerId, notSort) + local maze = GetMaze(mazeId) + return maze:GetLayerNodeIdList(layerId, notSort) + end + + function XTRPGManager.GetMazeCardBeginEndPos(mazeId, layerId, nodeId) + local maze = GetMaze(mazeId) + return maze:GetLayerCardBeginEndPos(layerId, nodeId) + end + + function XTRPGManager.GetMazeCardNum(mazeId, layerId, nodeId) + local maze = GetMaze(mazeId) + return maze:GetLayerCardNum(layerId, nodeId) + end + + function XTRPGManager.GetMazeCardId(mazeId, layerId, nodeId, cardIndex) + local maze = GetMaze(mazeId) + return maze:GetLayerCardId(layerId, nodeId, cardIndex) + end + + function XTRPGManager.GetMazeRecordGroupCardCount(mazeId, cardRecordGroupId) + local maze = GetMaze(mazeId) + return maze:GetRecordGroupCardCount(cardRecordGroupId) + end + + function XTRPGManager.IsCurrentLayer(mazeId, layerId) + local maze = GetMaze(mazeId) + return layerId and layerId == maze:GetCurrentLayerId() + end + + function XTRPGManager.IsNodeReachable(mazeId, layerId, nodeId) + local maze = GetMaze(mazeId) + return maze:IsNodeReachable(layerId, nodeId) + end + + function XTRPGManager.IsCardReachable(mazeId, layerId, nodeId, cardIndex) + local maze = GetMaze(mazeId) + return maze:IsCardReachable(layerId, nodeId, cardIndex) + end + + function XTRPGManager.CheckCardCurrentType(layerId, nodeId, cardId, cardType) + if __CurrentMazeId == 0 then return false end + local maze = GetMaze(__CurrentMazeId) + return maze:CheckCardCurrentType(layerId, nodeId, cardId, cardType) + end + + function XTRPGManager.IsMazeCardFinished(mazeId, layerId, cardId) + local maze = GetMaze(mazeId) + if not maze then return false end + return maze:IsCardFinished(layerId, cardId) + end + + function XTRPGManager.IsMazeCardDisposeableForeverFinished(mazeId, layerId, cardId) + local maze = GetMaze(mazeId) + if not maze then return false end + return maze:IsCardDisposeableForeverFinished(layerId, cardId) + end + + function XTRPGManager.GetCardFinishedId(mazeId, layerId, nodeId, cardIndex) + local maze = GetMaze(mazeId) + return maze:GetCardFinishedId(layerId, nodeId, cardIndex) + end + + function XTRPGManager.IsCardAfterCurrentStand(mazeId, layerId, nodeId, cardIndex) + local maze = GetMaze(mazeId) + return maze:IsCardAfterCurrentStand(layerId, nodeId, cardIndex) + end + + function XTRPGManager.IsCardCurrentStand(mazeId, layerId, nodeId, cardIndex) + local maze = GetMaze(mazeId) + return maze:IsCardCurrentStand(layerId, nodeId, cardIndex) + end + + function XTRPGManager.GetMazeCardMoveDelta(cardIndex) + if __CurrentMazeId == 0 then return end + local maze = GetMaze(__CurrentMazeId) + return maze:GetMoveDelta(cardIndex) + end + + function XTRPGManager.CheckQuickFight(challengeLevel) + return challengeLevel and XTRPGManager.GetExploreLevel() >= challengeLevel + end + + --请求进入迷宫 + local EnterMazeCD = 2 + local LastEnterMazeTime = 0 + function XTRPGManager.TRPGEnterMazeRequest(mazeId, cb) + local nowTime = XTime.GetServerNowTimestamp() + if nowTime < LastEnterMazeTime + EnterMazeCD then + return + end + LastEnterMazeTime = nowTime + + local req = { MazeId = mazeId } + XNetwork.Call("TRPGEnterMazeRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local currentPos = res.CurrentPos + UpdateMazeInfo(res.MazeInfo) + + XTRPGManager.EnterMaze(mazeId) + + if cb then cb() end + end) + end + + --请求迷宫位置整体移动:数据更新需在界面动画表现执行完毕之后,否则会增加冗余计算量 + local _ToMoveCardIndex, _ToPlayMovieId + function XTRPGManager.ReqMazeMoveNext(cardIndex, movieId) + if __CurrentMazeId == 0 then return end + + if XLuaUiManager.IsUiShow("UiTRPGMaze") then + CsXGameEventManager.Instance:Notify(XEventId.EVENT_TRPG_MAZE_MOVE_NEXT, cardIndex) + else + _ToMoveCardIndex = cardIndex + _ToPlayMovieId = movieId + end + end + + function XTRPGManager.GetMazeNeedMoveNextCardIndex() + return _ToMoveCardIndex, _ToPlayMovieId + end + + function XTRPGManager.ClearMazeNeedMoveNextCardIndex() + _ToMoveCardIndex = nil + _ToPlayMovieId = nil + end + + function XTRPGManager.MazeMoveNext(cardIndex) + if __CurrentMazeId == 0 then return end + + local maze = GetMaze(__CurrentMazeId) + maze:MoveNext(cardIndex) + end + + function XTRPGManager.MazeMoveTo(layerId, nodeId, cardIndex) + if __CurrentMazeId == 0 then return end + local maze = GetMaze(__CurrentMazeId) + maze:MoveTo(layerId, nodeId, cardIndex) + end + + function XTRPGManager.SelectCard(cardIndex) + if __CurrentMazeId == 0 then return end + + local maze = GetMaze(__CurrentMazeId) + maze:SelectCard(cardIndex) + end + + local _CurrentSelectCardLock--本次选择结果未处理之前不允许进行下一次选择操作 + function XTRPGManager.LockSelectCard() + _CurrentSelectCardLock = true + end + + function XTRPGManager.UnlockSelectCard() + _CurrentSelectCardLock = nil + end + + function XTRPGManager.IsSelectCardLock() + return _CurrentSelectCardLock or false + end + + --请求选择卡牌 + function XTRPGManager.TRPGMazeSelectCardRequest(cardIndex) + + if __CurrentMazeId == 0 then return end + if XTRPGManager.IsSelectCardLock() then return end + + local selectPos = { + LayerId = XTRPGManager.GetMazeCurrentLayerId(__CurrentMazeId), + NodeId = XTRPGManager.GetMazeCurrentNodeId(__CurrentMazeId), + Index = cardIndex, + } + local req = { SelectPos = selectPos } + + local cardId = XTRPGManager.GetMazeCardId(__CurrentMazeId, selectPos.LayerId, selectPos.NodeId, cardIndex) + + XTRPGManager.LockSelectCard() + + XNetwork.Call("TRPGMazeSelectCardRequest", req, function(res) + + XTRPGManager.UnlockSelectCard() + + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local resultData = res.Result + local maze = GetMaze(__CurrentMazeId) + maze:OnCardResult(cardIndex, resultData) + end) + end + + function XTRPGManager.NotifyTRPGMazeSelectCardResult(data) + local resultData = data.Result + if XTool.IsTableEmpty(resultData) then return end + if __CurrentMazeId == 0 then return end + + local maze = GetMaze(__CurrentMazeId) + local cardIndex = resultData.CurPos.Index + maze:OnCardResult(cardIndex, resultData) + end + + function XTRPGManager.NotifyMazeRecordCardId(data) + if XTool.IsTableEmpty(data) then return end + + local mazeId = data.Id + local maze = GetMaze(mazeId) + local cardIds = { data.RecordCardId } + maze:UpdateRecordCards(cardIds) + end + + --请求放弃挑战 + function XTRPGManager.TRPGMazeGiveUpChallengeRequest(cardIndex, cardId) + if __CurrentMazeId == 0 then return end + + local layerId = XTRPGManager.GetMazeCurrentLayerId(__CurrentMazeId) + local nodeId = XTRPGManager.GetMazeCurrentNodeId(__CurrentMazeId) + local cardId = XTRPGManager.GetMazeCardId(__CurrentMazeId, layerId, nodeId, cardIndex) + if not XTRPGConfigs.CheckMazeCardType(cardId, XTRPGConfigs.CardType.Fight) + and not XTRPGConfigs.CheckMazeCardType(cardId, XTRPGConfigs.CardType.Random) then--随机牌可能随出战斗牌 + return + end + + local selectPos = { + LayerId = layerId, + NodeId = nodeId, + Index = cardIndex, + } + local req = { Pos = selectPos } + XNetwork.Call("TRPGMazeGiveUpChallengeRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local resultData = res.Result + local maze = GetMaze(__CurrentMazeId) + maze:OnCardResult(cardIndex, resultData) + end) + end + + --请求快速挑战 + function XTRPGManager.TRPGMazeQuickChallengeRequest(cardIndex) + if __CurrentMazeId == 0 then return end + + local selectPos = { + LayerId = XTRPGManager.GetMazeCurrentLayerId(__CurrentMazeId), + NodeId = XTRPGManager.GetMazeCurrentNodeId(__CurrentMazeId), + Index = cardIndex, + } + local req = { Pos = selectPos } + XNetwork.Call("TRPGMazeQuickChallengeRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local resultData = res.Result + local maze = GetMaze(__CurrentMazeId) + maze:OnCardResult(cardIndex, resultData) + end) + end + -----------------迷宫end------------------ + -----------------主界面begin------------------ + function XTRPGManager.GetAreaState(areaId) + local openLastTimestamp = XTRPGConfigs.GetAreaOpenLastTimeStamp(areaId) + if openLastTimestamp > 0 then + return XTRPGConfigs.AreaStateType.NotOpen + elseif XTRPGManager.IsAreaExplored(areaId) then + return XTRPGConfigs.AreaStateType.Over + end + return XTRPGConfigs.AreaStateType.Open + end + + function XTRPGManager.IsAreaExplored(areaId) + local percent = XTRPGManager.GetMainLineTargetLinkPercentByAreaId(areaId) + return percent == 1 + end + + function XTRPGManager.GetAreaOpenNum() + local mainAreaTemplate = XTRPGConfigs.GetMainAreaTemplate() + local currAreaOpenNum = 0 + local areaState + for id in pairs(mainAreaTemplate) do + areaState = XTRPGManager.GetAreaState(id) + if areaState == XTRPGConfigs.AreaStateType.Open then + currAreaOpenNum = currAreaOpenNum + 1 + end + end + return currAreaOpenNum + end + + function XTRPGManager.IsNormalPage() + return IsNormalPage + end + -----------------主界面end------------------ + -----------------商店begin---------------- + function XTRPGManager.GetShopItemAlreadyBuyCount(shopId, itemId) + local shopInfo = ShopInfos[shopId] + return shopInfo and shopInfo:GetItemCount(itemId) or 0 + end + + function XTRPGManager.GetShopItemAddBuyCount(shopId) + local shopInfo = ShopInfos[shopId] + return shopInfo and shopInfo:GetAddBuyCount() or 0 + end + + function XTRPGManager.GetShopItemCanBuyCount(shopId, shopItemId) + local alreadyBuyCount = XTRPGManager.GetShopItemAlreadyBuyCount(shopId, shopItemId) + local shopItemCount = XTRPGConfigs.GetShopItemCount(shopId, shopItemId) + local addBuyCount = XTRPGManager.GetShopItemAddBuyCount(shopId) + return mathMax(shopItemCount - alreadyBuyCount + addBuyCount, 0) + end + + function XTRPGManager.GetShopItemConsumeCount(shopId, shopItemId) + local shopInfo = ShopInfos[shopId] + local disCount = shopInfo and shopInfo:GetDisCount() + local consumeCount = XTRPGConfigs.GetShopItemConsumeCount(shopItemId) + if disCount then + consumeCount = consumeCount * (disCount / 100) + end + return mathCeil(consumeCount) + end + + function XTRPGManager.GetShopItemIdList(shopId) + local shopItemIdList = XTRPGConfigs.GetShopItemIdList(shopId) + local list = {} + local condition, ret + local itemId, itemTemplate + + for _, shopItemId in ipairs(shopItemIdList) do + condition = XTRPGConfigs.GetShopItemCondition(shopItemId) + ret = XConditionManager.CheckCondition(condition) + itemId = XTRPGConfigs.GetItemIdByShopItemId(shopItemId) + itemTemplate = XDataCenter.ItemManager.GetItemTemplate(itemId) + if ret and itemTemplate then + tableInsert(list, shopItemId) + end + end + + tableSort(list, function(shopItemIdA, shopItemIdB) + local shopItemLimitCountA = XTRPGConfigs.GetShopItemCount(shopId, shopItemIdA) + local shopItemLimitCountB = XTRPGConfigs.GetShopItemCount(shopId, shopItemIdB) + -- 是否卖光 + if (shopItemLimitCountA and shopItemLimitCountA > 0) or (shopItemLimitCountB and shopItemLimitCountB > 0) then + local canBuyCountA = XDataCenter.TRPGManager.GetShopItemCanBuyCount(shopId, shopItemIdA) + local canBuyCountB = XDataCenter.TRPGManager.GetShopItemCanBuyCount(shopId, shopItemIdB) + -- 如果商品有次数限制,并且可购买的数量为0,则判断为售罄 + local isSellOutA = canBuyCountA == 0 and shopItemLimitCountA > 0 + local isSellOutB = canBuyCountB == 0 and shopItemLimitCountB > 0 + if isSellOutA ~= isSellOutB then + return isSellOutB + end + end + return shopItemIdA < shopItemIdB + end) + return list + end + -----------------商店end------------------ + -----------------探索等级 begin---------------- + function XTRPGManager.GetExploreLevel() + return BaseInfo:GetLevel() + end + + function XTRPGManager.GetExploreCurExp() + return BaseInfo:GetExp() + end + + function XTRPGManager.GetExploreMaxExp() + return BaseInfo:GetMaxExp() + end + + function XTRPGManager.GetExploreCurEndurance() + return BaseInfo:GetEndurance() + end + + function XTRPGManager.GetExploreMaxEndurance() + return BaseInfo:GetMaxEndurance() + end + + function XTRPGManager.GetMaxTalentPoint() + return BaseInfo:GetMaxTalentPoint() + end + + function XTRPGManager.CheckSaveIsAlreadyOpenPanelLevel() + if not XTRPGManager.IsAlreadyLevelUp() then + return + end + if not XSaveTool.GetData(stringFormat("%d%s", XPlayer.Id, "IsAlreadyOpenPanelLevel")) then + XSaveTool.SaveData(stringFormat("%d%s", XPlayer.Id, "IsAlreadyOpenPanelLevel"), true) + end + end + + function XTRPGManager.CheckIsAlreadyOpenPanelLevel() + return XSaveTool.GetData(stringFormat("%d%s", XPlayer.Id, "IsAlreadyOpenPanelLevel")) or false + end + + function XTRPGManager.SaveExploreRedPointLevel(level) + if not XSaveTool.GetData(stringFormat("%d%s", XPlayer.Id, "ExploreRedPointLevel")) then + XSaveTool.SaveData(stringFormat("%d%s", XPlayer.Id, "ExploreRedPointLevel"), level) + end + end + + function XTRPGManager.GetExploreRedPointLevel() + return XSaveTool.GetData(stringFormat("%d%s", XPlayer.Id, "ExploreRedPointLevel")) + end + + function XTRPGManager.IsAlreadyLevelUp() + local redPointLevel = BaseInfo:GetRedPointLevel() + local exploreLevel = XTRPGManager.GetExploreLevel() + if exploreLevel and redPointLevel then + return exploreLevel > redPointLevel + end + return false + end + + --第1次升级后显示蓝点,打开说明弹窗后隐藏蓝点 + function XTRPGManager.IsShowExploreRedPointLevel() + local isAlreadyLevelUp = XTRPGManager.IsAlreadyLevelUp() + local isAlreadyOpen = XTRPGManager.CheckIsAlreadyOpenPanelLevel() + return not isAlreadyOpen and isAlreadyLevelUp + end + -----------------探索等级 end------------------ + -----------------调查员 begin---------------- + local function GetRole(roleId) + return Roles[roleId] + end + + local function UpdateRole(data, checkNew) + if not data then return end + + local roleId = data.Id + local newRoleId + + local role = GetRole(roleId) + if not role then + role = XTRPGRole.New(roleId) + Roles[roleId] = role + newRoleId = checkNew and roleId + end + + role:UpdateData(data) + + if newRoleId then + XLuaUiManager.Open("UiTRPGNewCharacter", newRoleId) + end + end + + local function UpdateRoles(datas, checkNew) + if not datas then return end + for _, data in pairs(datas) do + UpdateRole(data, checkNew) + end + CsXGameEventManager.Instance:Notify(XEventId.EVENT_TRPG_ROLES_DATA_CHANGE) + XEventManager.DispatchEvent(XEventId.EVENT_TRPG_ROLES_DATA_CHANGE) + end + + function XTRPGManager.GetOwnRoleIds() + local roleIdList = {} + for roleId in pairs(Roles) do + tableInsert(roleIdList, roleId) + end + return roleIdList + end + + function XTRPGManager.GetSortedAllRoleIds() + return XTRPGConfigs.GetAllRoleIds() + end + + function XTRPGManager.IsRolesEmpty() + return XTool.IsTableEmpty(Roles) + end + + function XTRPGManager.IsRoleOwn(roleId) + return GetRole(roleId) and true or false + end + + function XTRPGManager.IsRoleHaveBuffUp(roleId) + local role = GetRole(roleId) + return role:IsHaveBuffUp() + end + + function XTRPGManager.IsRoleHaveBuffDown(roleId) + local role = GetRole(roleId) + return role:IsHaveBuffDown() + end + + function XTRPGManager.GetRoleBuffIds(roleId) + local role = GetRole(roleId) + return role:GetBuffIds() + end + + function XTRPGManager.GetRoleAttributes(roleId) + local role = GetRole(roleId) + return role:GetAttributes() + end + + function XTRPGManager.GetRoleCommonTalentIds(roleId) + local role = GetRole(roleId) + return role:GetCommonTalentIds() + end + + function XTRPGManager.GetRoleTalentIds(roleId) + local role = GetRole(roleId) + return role:GetTalentIds() + end + + function XTRPGManager.GetRoleUsedTalentPoints(roleId) + local role = GetRole(roleId) + if not role then return 0 end + return role:GetUsedTalentPoint() + end + + function XTRPGManager.GetTotalUsedTalentPoints() + local totalPoints = 0 + for _, role in pairs(Roles) do + totalPoints = totalPoints + role:GetUsedTalentPoint() + end + return totalPoints + end + + function XTRPGManager.GetRoleHaveTalentPoints() + local maxPoints = XTRPGManager.GetMaxTalentPoint() + local totalUsedPoints = XTRPGManager.GetTotalUsedTalentPoints() + return maxPoints - totalUsedPoints + end + + function XTRPGManager.GetActiveTalentCostPoint(roleId, talentId) + local role = GetRole(roleId) + return role:GetTalentCostPoint(talentId) + end + + function XTRPGManager.IsActiveTalentCostEnough(roleId, talentId) + local havePoints = XTRPGManager.GetRoleHaveTalentPoints() + local costPoints = XTRPGManager.GetActiveTalentCostPoint(roleId, talentId) + return havePoints >= costPoints + end + + function XTRPGManager.IsTalentResetCostEnough() + local costItemId = XTRPGConfigs.GetTalentResetCostItemId() + local costItemCount = XTRPGConfigs.GetTalentResetCostItemCount() + return XDataCenter.ItemManager.CheckItemCountById(costItemId, costItemCount) + end + + function XTRPGManager.IsRoleAnyTalentActive(roleId) + local role = GetRole(roleId) + return role:IsAnyTalentActive() + end + + function XTRPGManager.IsRoleTalentActive(roleId, talentId) + local role = GetRole(roleId) + return role:IsTalentActive(talentId) + end + + function XTRPGManager.IsRoleTalentCanActive(roleId, talentId) + local role = GetRole(roleId) + return role:CanActiveTalent(talentId) + end + + function XTRPGManager.CheckRoleTalentRedPoint() + if not XTRPGConfigs.CheckButtonCondition(XTRPGConfigs.ButtonConditionId.Talent) then + return false + end + + for _, role in pairs(Roles) do + if role:CanActiveAnyTalent() then + return true + end + end + + return false + end + + function XTRPGManager.GetRoleAttributeMinRollValue(roleId, attributeType) + local role = GetRole(roleId) + return role:GetAttributeMinRollValue(attributeType) + end + + function XTRPGManager.GetRoleAttributeMaxRollValue(roleId, attributeType) + local role = GetRole(roleId) + return role:GetAttributeMaxRollValue(attributeType) + end + + function XTRPGManager.GetRolesTotalCanRollValue(attributeType) + local totalMinValue, totalMaxValue = 0, 0 + for roleId in pairs(Roles) do + totalMinValue = totalMinValue + XTRPGManager.GetRoleAttributeMinRollValue(roleId, attributeType) + totalMaxValue = totalMaxValue + XTRPGManager.GetRoleAttributeMaxRollValue(roleId, attributeType) + end + return totalMinValue, totalMaxValue + end + + --请求激活天赋 + function XTRPGManager.TRPGActivateTalentRequest(roleId, talentId, cb) + local req = { CharacterId = roleId, TalentId = talentId } + XNetwork.Call("TRPGActivateTalentRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + if cb then + cb() + end + end) + end + + --请求重置天赋 + function XTRPGManager.TRPGResetTalentRequest(roleId, cb) + local req = { CharacterId = roleId } + XNetwork.Call("TRPGResetTalentRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + if cb then + cb() + end + end) + end + + function XTRPGManager.GetTalentPointTipsData() + local goodsShowParams = XGoodsCommonManager.GetGoodsShowParamsByTemplateId(XDataCenter.ItemManager.ItemId.TRPGTalen) + local data = { + Name = goodsShowParams.Name, + Count = XTRPGManager.GetRoleHaveTalentPoints(), + Icon = goodsShowParams.BigIcon or goodsShowParams.Icon, + Quality = goodsShowParams.Quality, + WorldDesc = XGoodsCommonManager.GetGoodsWorldDesc(XDataCenter.ItemManager.ItemId.TRPGTalen), + Description = XGoodsCommonManager.GetGoodsDescription(XDataCenter.ItemManager.ItemId.TRPGTalen), + IsTempItemData = true + } + return data + end + -----------------调查员 end---------------- + -----------------背包begin---------------- + local function UpdateCapacity(capacity) + AddItemMaxCountNum = capacity or 0 + end + + function XTRPGManager.GetItemMaxCount(itemId) + local maxCount = XTRPGConfigs.GetItemMaxCount(itemId) + maxCount = maxCount + AddItemMaxCountNum + return maxCount + end + + function XTRPGManager.IsItemMaxCount(itemId) + local haveCount = XDataCenter.ItemManager.GetCount(itemId) + local maxCount = XTRPGManager.GetItemMaxCount(itemId) + return haveCount >= maxCount + end + + function XTRPGManager.GetItemListByType(itemType) + local itemList = XDataCenter.ItemManager.GetItemsByType(XItemConfigs.ItemType.TRPGItem) + local itemTypeCfg + local list = {} + for _, v in ipairs(itemList) do + if not XTRPGManager.IsBagHideItem(v.Id) then + itemTypeCfg = XTRPGConfigs.GetItemType(v.Id) + if itemType == itemTypeCfg then + table.insert(list, v) + end + end + end + + tableSort(list, function(itemA, itemB) + return itemA.Id < itemB.Id + end) + + return list + end + + function XTRPGManager.IsBagHideItem(id) + return BagHideItemIdList[id] + end + -----------------背包end------------------ + -----------------奖励begin------------------ + function XTRPGManager.IsReceiveReward(id) + return RewardList[id] + end + + function XTRPGManager.CheckRewardCondition(trpgRewardId, secondMainId) + local conditionList = XTRPGConfigs.GetRewardCondition(trpgRewardId) + local conditionId = secondMainId and conditionList[2] or conditionList[1] --常规模式领取条件用2,探索模式用1 + if not XTool.IsNumberValid(conditionId) or XConditionManager.CheckCondition(conditionId) then + return true + end + return false + end + + function XTRPGManager.GetAreaRewardPercent(areaId) + local areaState = XTRPGManager.GetAreaState(areaId) + if areaState == XTRPGConfigs.AreaStateType.NotOpen then + return 0 + end + + local areaRewardIdList = XTRPGConfigs.GetAreaRewardIdList(areaId) + local maxNum = #areaRewardIdList + local ret + local num = 0 + for _, trpgRewardId in pairs(areaRewardIdList) do + ret = XTRPGManager.CheckRewardCondition(trpgRewardId) + if ret then + num = num + 1 + end + end + return maxNum > 0 and num / maxNum or 0 + end + + function XTRPGManager.GetSecondMainStagePercent(secondMainId) + local secondMainStageIdList = XTRPGConfigs.GetSecondMainStageId(secondMainId) + local secondMainStageFinishNum = 0 + local allSecondMainStageCount = #secondMainStageIdList + local stageId + + for _, secondMainStageId in ipairs(secondMainStageIdList) do + stageId = XTRPGConfigs.GetSecondMainStageStageId(secondMainStageId) + if XTRPGManager.IsStagePass(stageId) then + secondMainStageFinishNum = secondMainStageFinishNum + 1 + end + end + return allSecondMainStageCount > 0 and secondMainStageFinishNum / allSecondMainStageCount or 0 + end + + function XTRPGManager.CheckAreaRewardByAreaId(areaId) + local areaState = XDataCenter.TRPGManager.GetAreaState(areaId) + if areaState == XTRPGConfigs.AreaStateType.NotOpen then + return false + end + + local areaRewardIdList = XTRPGConfigs.GetAreaRewardIdList(areaId) + local condition, ret + local isReceiveReward + for _, trpgRewardId in pairs(areaRewardIdList) do + ret = XTRPGManager.CheckRewardCondition(trpgRewardId) + isReceiveReward = XDataCenter.TRPGManager.IsReceiveReward(trpgRewardId) + if ret and not isReceiveReward then + return true + end + end + return false + end + + function XTRPGManager.CheckAllAreaReward() + local mainAreaMaxNum = XTRPGConfigs.GetMainAreaMaxNum() + for areaId = 1, mainAreaMaxNum do + if XTRPGManager.CheckAreaRewardByAreaId(areaId) then + return true + end + end + return false + end + -----------------奖励end------------------ + -----------------任务目标begin----------------- + function XTRPGManager.GetCurrTargetLinkId() + return CurrTargetLinkId + end + + function XTRPGManager.GetCurrTargetId() + return CurrTargetId + end + + function XTRPGManager.GetCurrTargetDesc() + local currTargetId = XTRPGManager.GetCurrTargetId() + return XTRPGConfigs.GetTargetDesc(currTargetId) + end + + function XTRPGManager.IsTargetFinish(target) + local notPreTargetId = XTRPGConfigs.GetNotPreTargetId() + if type(target) == "string" then --目标类型string的是前置目标 + local preTargetList = string.Split(target, "|") + local preTargetId + local isFinish + for _, preTargetIdStr in ipairs(preTargetList) do + isFinish = false + preTargetId = tonumber(preTargetIdStr) + if preTargetId == notPreTargetId then + return true + end + if TargetList[preTargetId] then + isFinish = true + end + if not isFinish then + break + end + end + return isFinish + else + if target == notPreTargetId then + return true + end + return TargetList[target] + end + end + + --return 目标链是否完成,未完成的目标id + function XTRPGManager.GetTargetLinkIsFinish(targetLinkId) + if not targetLinkId or targetLinkId == 0 then + return true, 0 + end + + local targetIsFinish + local preTargetIsFinish + local preTarget + local targetIdList = XTRPGConfigs.GetTargetIdList(targetLinkId) + + for _, targetId in pairs(targetIdList) do + targetIsFinish = XTRPGManager.IsTargetFinish(targetId) + preTarget = XTRPGConfigs.GetPreTargetByTargetId(targetId) + preTargetIsFinish = XTRPGManager.IsTargetFinish(preTarget) + if not targetIsFinish and preTargetIsFinish then + return false, targetId + end + end + return true, 0 + end + + function XTRPGManager.GetAllCanFindTargetLink() + local targetLinkTemplate = XTRPGConfigs.GetTargetLinkTemplate() + local allCanFindTarget = { + [XTRPGConfigs.MissionType.MainLine] = {}, + } + local targetMissionType + local targetIsFinish + local preTargetIsFinish + + for _, v in pairs(targetLinkTemplate) do + local isInsert = false + for index, targetId in ipairs(v.TargetId) do + targetIsFinish = XTRPGManager.IsTargetFinish(targetId) + preTargetIsFinish = XTRPGManager.IsTargetFinish(v.PreTarget[index]) + if v.TargetMissionType == XTRPGConfigs.MissionType.SubLine and index == 1 and preTargetIsFinish then + isInsert = true + end + if not targetIsFinish and preTargetIsFinish then + local targetTable = { TargetLinkId = v.Id, TargetId = targetId } + targetMissionType = XTRPGConfigs.GetTargetLinkMissionType(v.Id) + if not allCanFindTarget[targetMissionType] then + allCanFindTarget[targetMissionType] = {} + end + tableInsert(allCanFindTarget[targetMissionType], targetTable) + isInsert = false + break + end + end + + if isInsert then + if not allCanFindTarget[XTRPGConfigs.MissionType.SubLine] then + allCanFindTarget[XTRPGConfigs.MissionType.SubLine] = {} + end + tableInsert(allCanFindTarget[XTRPGConfigs.MissionType.SubLine], { TargetLinkId = v.Id, TargetId = 0 }) + end + end + return allCanFindTarget + end + + function XTRPGManager.GetOneCanFindTarget() + local targetLinkTemplate = XTRPGConfigs.GetTargetLinkTemplate() + local targetId + local targetLinkIsFinish + for _, v in pairs(targetLinkTemplate) do + targetLinkIsFinish, targetId = XTRPGManager.GetTargetLinkIsFinish(v.Id) + if not targetLinkIsFinish then + return v.Id, targetId + end + end + return 0, 0 + end + + function XTRPGManager.IsTargetAllFinish() + local targetTotalNum = XTRPGConfigs.GetTargetTotalNum() + local finishTargetNum = 0 + for _ in pairs(TargetList) do + finishTargetNum = finishTargetNum + 1 + end + return targetTotalNum == finishTargetNum + end + + function XTRPGManager.GetTargetLinkPercent(targetLinkId) + local targetIdList = XTRPGConfigs.GetTargetIdList(targetLinkId) + local finishNum = 0 + local totalNum = #targetIdList + for _, targetId in pairs(targetIdList) do + if XTRPGManager.IsTargetFinish(targetId) then + finishNum = finishNum + 1 + end + end + return totalNum == 0 and 0 or finishNum / totalNum + end + + function XTRPGManager.GetMainLineTargetLinkPercentByAreaId(areaId) + local targetLinkIdList = XTRPGConfigs.GetTargetLinkIdList(areaId) + for _, targetLinkId in pairs(targetLinkIdList) do + local msiionType = XTRPGConfigs.GetTargetLinkMissionType(targetLinkId) + if msiionType == XTRPGConfigs.MissionType.MainLine then + return XTRPGManager.GetTargetLinkPercent(targetLinkId) + end + end + return 0 + end + + function XTRPGManager.IsMovieTargetFinish(movieId) + local targetId = XTRPGConfigs.GetMovieTargetId(movieId) + if not targetId or targetId == 0 then + return false + end + + return XTRPGManager.IsTargetFinish(targetId) + end + + function XTRPGManager.CheckRequestTargetLink(currTargetLinkId) + local notTargetLinkDefaultId = XTRPGConfigs.NotTargetLinkDefaultId + if notTargetLinkDefaultId == currTargetLinkId and notTargetLinkDefaultId ~= CurrTargetLinkId then + XDataCenter.TRPGManager.RequestSelectTargetLinkSend(CurrTargetLinkId, true) + end + end + + function XTRPGManager.CheckOpenNewMazeTips() + if not IsCanCheckOpenNewMaze then return end + + SetIsCanCheckOpenNewMaze(false) + local secondAreaIdToMazeIdDic = XTRPGConfigs.GetSecondAreaIdToMazeIdDic() + local condition, ret + local name + local msg + for secondAreaId, mazeId in pairs(secondAreaIdToMazeIdDic) do + if not IsOpenMaze(mazeId) then + condition = XTRPGConfigs.GetSecondAreaCondition(secondAreaId) + ret = XConditionManager.CheckCondition(condition) + if ret then + UpdateAlreadyOpenMaze(mazeId) + name = XTRPGConfigs.GetSecondAreaName(secondAreaId) + msg = CSXTextManagerGetText("TRPGAreaAleardyOpen", name) + XUiManager.TipMsgEnqueue(msg) + end + end + end + end + + function XTRPGManager.GetTaskPanelNewShowTime() + local oldCurrTargetId = GetOldCurrTargetId() + local currTargetId = XTRPGManager.GetCurrTargetId() + if oldCurrTargetId ~= currTargetId then + UpdateOldCurrTargetId() + local serverTimestamp = XTime.GetServerNowTimestamp() + local taskPanelNewShowTimeCfg = XTRPGConfigs.GetTaskPanelNewShowTime() + return serverTimestamp + taskPanelNewShowTimeCfg + end + return 0 + end + + function XTRPGManager.SetNewTargetTime(newTargetTime) + NewTargetTime = newTargetTime + end + + function XTRPGManager.GetNewTargetTime() + return NewTargetTime + end + + function XTRPGManager.ClearNewTargetTime() + NewTargetTime = 0 + end + -----------------任务目标end------------------ + -----------------求真之路begin------------------ + function XTRPGManager.GetTruthRoadPercent(truthRoadGroupId) + local truthRoadIdList = XTRPGConfigs.GetTruthRoadIdList(truthRoadGroupId) + local truthRoadFinishNum = 0 + for _, truthRoadId in pairs(truthRoadIdList) do + local condition = XTRPGConfigs.GetTruthRoadCondition(truthRoadId) + local ret = XConditionManager.CheckCondition(condition) + if ret then + truthRoadFinishNum = truthRoadFinishNum + 1 + end + end + return #truthRoadIdList > 0 and truthRoadFinishNum / #truthRoadIdList or 0 + end + + function XTRPGManager.IsTruthRoadOpenArea(areaId) + local truthRoadGroupIdList = XTRPGConfigs.GetTruthRoadGroupIdList(areaId) + local condition + local ret + for i, truthRoadGroupId in ipairs(truthRoadGroupIdList) do + condition = XTRPGConfigs.GetTruthRoadGroupCondition(truthRoadGroupId) + ret = XConditionManager.CheckCondition(condition) + if ret then + return true, i + end + end + return false + end + + function XTRPGManager.IsTruthRoadGroupConditionFinish(areaId, index) + local truthRoadGroupId = XTRPGConfigs.GetTruthRoadGroupId(areaId, index) + local condition = XTRPGConfigs.GetTruthRoadGroupCondition(truthRoadGroupId) + local ret, desc = XConditionManager.CheckCondition(condition) + return ret, desc + end + + function XTRPGManager.CheckTruthRoadReward(truthRoadGroupId) + local rewardIdList = XTRPGConfigs.GetTruthRoadRewardIdList(truthRoadGroupId) + local conditionId, ret + local isReceiveReward + for _, trpgRewardId in ipairs(rewardIdList) do + ret = XTRPGManager.CheckRewardCondition(trpgRewardId) + isReceiveReward = XTRPGManager.IsReceiveReward(trpgRewardId) + if ret and not isReceiveReward then + return true + end + end + return false + end + + function XTRPGManager.CheckTruthRoadAreaReward(areaId) + local truthRoadGroupIdList = XTRPGConfigs.GetTruthRoadGroupIdList(areaId) + for _, truthRoadGroupId in ipairs(truthRoadGroupIdList) do + if XTRPGManager.CheckTruthRoadReward(truthRoadGroupId) then + return true + end + end + return false + end + + function XTRPGManager.CheckTruthRoadAllReward() + local mainAreaMaxNum = XTRPGConfigs.GetMainAreaMaxNum() + for i = 1, mainAreaMaxNum do + if XTRPGManager.CheckTruthRoadAreaReward(i) then + return true + end + end + return false + end + + function XTRPGManager.SaveIsAlreadyOpenTruthRoad() + if not XSaveTool.GetData(stringFormat("%d%s", XPlayer.Id, "IsAlreadyOpenTruthRoad")) then + XSaveTool.SaveData(stringFormat("%d%s", XPlayer.Id, "IsAlreadyOpenTruthRoad"), true) + XEventManager.DispatchEvent("EVENT_TRPG_FIRST_OPEN_TRUTH_ROAD") + end + end + + function XTRPGManager.CheckIsAlreadyOpenTruthRoad() + return XSaveTool.GetData(stringFormat("%d%s", XPlayer.Id, "IsAlreadyOpenTruthRoad")) or false + end + -----------------求真之路end-------------------- + ---------------------珍藏-回忆begin------------------------- + function XTRPGManager.IsPlayedMemoir(id) + return MemoirList[id] + end + + function XTRPGManager.IsCanPlayMemoir(id) + local itemId = XTRPGConfigs.GetMemoireStoryUnlockItemId(id) + local ownCount = XDataCenter.ItemManager.GetCount(itemId) + local maxCount = XTRPGConfigs.GetMemoireStoryUnlockItemCount(id) + return ownCount >= maxCount + end + + function XTRPGManager.CheckFirstPlayMemoirStoryById(id) + local isCanPlay = XTRPGManager.IsCanPlayMemoir(id) + local isPlayed = XTRPGManager.IsPlayedMemoir(id) + return isCanPlay and not isPlayed + end + + function XTRPGManager.CheckFirstPlayMemoirStory() + local maxNum = XTRPGConfigs.GetMemoirStoryMaxNum() + for i = 1, maxNum do + if XTRPGManager.CheckFirstPlayMemoirStoryById(i) then + return true + end + end + return false + end + + function XTRPGManager.SaveIsAlreadyOpenCollection() + if not XSaveTool.GetData(string.format("%d%s", XPlayer.Id, "IsAlreadyOpenCollection")) then + XSaveTool.SaveData(string.format("%d%s", XPlayer.Id, "IsAlreadyOpenCollection"), true) + XEventManager.DispatchEvent("EVENT_TRPG_FIRST_OPEN_COLLECTION") + end + end + + function XTRPGManager.CheckIsAlreadyOpenCollection() + return XSaveTool.GetData(stringFormat("%d%s", XPlayer.Id, "IsAlreadyOpenCollection")) or false + end + ---------------------珍藏-回忆end--------------------------- + ---------------------第三区域 begin------------------------- + local function SetThirdAreaFunctionFinish(thirdAreaId, functionId) + thirdAreaId = DEFUALT_thirdAreaId_FOR_STUPID_DESIGN or thirdAreaId + + if not ThirdAreaInfos[thirdAreaId] then + ThirdAreaInfos[thirdAreaId] = XTRPGThirdAreaInfo.New() + end + ThirdAreaInfos[thirdAreaId]:SetFunctionFinished(functionId) + end + + local function UpdateThirdAreaInfos(thirdAreaInfos) + if not thirdAreaInfos then return end + + if DEFUALT_thirdAreaId_FOR_STUPID_DESIGN then + local thirdAreaId = DEFUALT_thirdAreaId_FOR_STUPID_DESIGN + for _, functionId in pairs(thirdAreaInfos) do + SetThirdAreaFunctionFinish(thirdAreaId, functionId) + end + + return + end + + for thirdAreaId, functionIds in pairs(thirdAreaInfos) do + for _, functionId in pairs(functionIds) do + SetThirdAreaFunctionFinish(thirdAreaId, functionId) + end + end + end + + local function GetThirdAreaInfo(thirdAreaId) + thirdAreaId = DEFUALT_thirdAreaId_FOR_STUPID_DESIGN or thirdAreaId + return ThirdAreaInfos[thirdAreaId] + end + + function XTRPGManager.IsFunctionGroupConditionFinish(functionGroupId) + local condition = XTRPGConfigs.GetFunctionGroupConditionId(functionGroupId) + local ret, desc = XConditionManager.CheckCondition(condition) + return ret, desc + end + + function XTRPGManager.IsThirdAreaFunctionFinish(thirdAreaId, functionId) + local areaInfo = GetThirdAreaInfo(thirdAreaId) + return areaInfo and areaInfo:IsFunctionFinished(functionId) + end + + function XTRPGManager.IsThirdAreaFunctionAllFinish(thirdAreaId) + return #XTRPGManager.GetUnFinishedFunctionIdList(thirdAreaId) == 0 + end + + function XTRPGManager.GetUnFinishedFunctionIdList(thirdAreaId) + local functionIdList = {} + + local functionGroupIds = XTRPGConfigs.GetThirdAreaFunctionGroupIds(thirdAreaId) + for _, functionGroupId in ipairs(functionGroupIds) do + if XTRPGManager.IsFunctionGroupConditionFinish(functionGroupId) then + + local functionIds = XTRPGConfigs.GetFunctionGroupFunctionIds(functionGroupId) + for _, functionId in ipairs(functionIds) do + if not XTRPGManager.IsThirdAreaFunctionFinish(thirdAreaId, functionId) then + tableInsert(functionIdList, functionId) + break + end + end + + end + end + + return functionIdList + end + + local __ToFinishFightFunctionId = 0 --战斗胜利后请求完成的FunctionId + function XTRPGManager.EnterFunctionFight(functionId) + if not XTRPGConfigs.CheckFunctionType(functionId, XTRPGConfigs.TRPGFunctionType.FinishStage) then + return + end + + __ToFinishFightFunctionId = functionId + + local params = XTRPGConfigs.GetFunctionParams(functionId) + local stageId = tonumber(params[1]) + XLuaUiManager.Open("UiNewRoomSingle", stageId) + end + + function XTRPGManager.ReqFinishFunctionAfterFight(thirdAreaId) + local functionId = __ToFinishFightFunctionId + if not functionId or functionId == 0 then return end + + XDataCenter.TRPGManager.RequestFunctionFinishSend(thirdAreaId, functionId) + end + + --请求完成功能id + function XTRPGManager.RequestFunctionFinishSend(thirdAreaId, functionId) + if not XTRPGConfigs.CheckFunctionNeedSave(functionId) then return end + + local req = { FunctionId = functionId } + XNetwork.Call("TRPGFunctionFinishRequest", req, function(res) + + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + if XTRPGConfigs.CheckFunctionType(functionId, XTRPGConfigs.TRPGFunctionType.CommitItem) then + local params = XTRPGConfigs.GetFunctionParams(functionId) + local itemId = tonumber(params[1]) + XLuaUiManager.Open("UiTRPGCommitItem", itemId) + end + + XTRPGManager.OnGetReward(res.RewardList) + + SetThirdAreaFunctionFinish(thirdAreaId, functionId) + + XEventManager.DispatchEvent(XEventId.EVENT_TRPG_FUNCTION_FINISH_SYN) + end) + end + + function XTRPGManager.OnGetReward(rewardList, closeCb) + if XTool.IsTableEmpty(rewardList) then return end + + local reward = rewardList[1] + local itemId = reward.TemplateId + local itemCount = reward.Count + XLuaUiManager.Open("UiTRPGObtain", itemId, itemCount, closeCb) + end + ---------------------第三区域 end--------------------------- + ---------------------世界BOSS begin-------------------- + function XTRPGManager.GetWorldBossLoseHp() + return BossInfo:GetLoseHp() + end + + function XTRPGManager.GetWorldBossTotalHp() + return BossInfo:GetTotalHp() + end + + function XTRPGManager.GetWorldBossCurHpPercer() + local loseHp = XDataCenter.TRPGManager.GetWorldBossLoseHp() + local totalHp = XDataCenter.TRPGManager.GetWorldBossTotalHp() + return totalHp > 0 and (totalHp - loseHp) / totalHp or 0 + end + + function XTRPGManager.IsWorldBossAleardyReceiveReward(id) + return BossInfo:IsReceiveReward(id) + end + + function XTRPGManager.IsWorldBossCanReceiveReward(id) + local curPercent = XTRPGManager.GetWorldBossCurHpPercer() + local percentCfg = XTRPGConfigs.GetBossPhasesRewardPercent(id) + percentCfg = percentCfg * 0.01 + return curPercent <= percentCfg + end + + function XTRPGManager.GetWorldBossChallengeCount() + return BossInfo:GetChallengeCount() + end + + function XTRPGManager.GetWorldBossOpenState() + local nowTime = XTime.GetServerNowTimestamp() + local timeId = XTRPGConfigs.GetBossTimeId() + local startTime, endTime = XFunctionManager.GetTimeByTimeId(timeId) + if nowTime < startTime then + return XTRPGConfigs.AreaStateType.NotOpen, startTime - nowTime + elseif nowTime >= startTime and nowTime < endTime then + return XTRPGConfigs.AreaStateType.Open, endTime - nowTime + else + return XTRPGConfigs.AreaStateType.Over, 0 + end + end + + function XTRPGManager.CheckWorldBossReward() + local openState = XTRPGManager.GetWorldBossOpenState() + if openState ~= XTRPGConfigs.AreaStateType.Open then + return false + end + + local isAleardyReceive + local isCanReceive + local bossPhasesRewardTemplate = XTRPGConfigs.GetBossPhasesRewardTemplate() + for _, v in pairs(bossPhasesRewardTemplate) do + isCanReceive = XDataCenter.TRPGManager.IsWorldBossCanReceiveReward(v.Id) + isAleardyReceive = XDataCenter.TRPGManager.IsWorldBossAleardyReceiveReward(v.Id) + if isCanReceive and not isAleardyReceive then + return true + end + end + return false + end + ---------------------世界BOSS end--------------------- + ---------------------检定相关 begin--------------------------- + function XTRPGManager.GetExamineActionDifficult(actionId) + --道具检定无难度 + if XTRPGConfigs.CheckExamineActionType(actionId, XTRPGConfigs.TRPGExamineActionType.ConsumeItem) then + return XTRPGConfigs.TRPGExamineActionDifficult.Default + end + + local needValue = XTRPGConfigs.GetExamineActionNeedValue(actionId) + local _, totalMaxValue = XTRPGManager.GetExamineActionTotalCallRollValue(actionId) + local delta = totalMaxValue - needValue + return XTRPGConfigs.GetExamineActionDifficultByDelta(delta) + end + + --return 所有角色单属性所有轮次可摇点最小值,最大值 + function XTRPGManager.GetExamineActionTotalCallRollValue(actionId) + local attributeType = XTRPGConfigs.GetExamineActionNeedAttrType(actionId) + local totalMinValue, totalMaxValue = XTRPGManager.GetRolesTotalCanRollValue(attributeType) + local round = XTRPGConfigs.GetExamineActionRound(actionId) + return round * totalMinValue, round * totalMaxValue + end + + function XTRPGManager.CheckExamineCostEnduranceEnough(examineId) + local costEndurance = XTRPGConfigs.GetExamineCostEndurance(examineId) + local curEndurance = XTRPGManager.GetExploreCurEndurance() + return curEndurance >= costEndurance + end + + function XTRPGManager.EnterExamine(examineId) + local enterFunc = function() + XLuaUiManager.Open("UiTRPGTestDetailsTips", examineId) + end + local endCallBack = function() + XDataCenter.TRPGManager.CheckOpenNewMazeTips() + end + + local movieId = XTRPGConfigs.GetExamineStartMovieId(examineId) + if not string.IsNilOrEmpty(movieId) then + local yieldCb = enterFunc + local hideSkipBtn = true + XDataCenter.MovieManager.PlayMovie(movieId, endCallBack, yieldCb, hideSkipBtn) + else + XLuaUiManager.Open("UiTRPGTestDetailsTips", examineId) + end + end + + function XTRPGManager.StartExamine(examineId, actionId) + CurExmaine:Start(examineId, actionId) + XLuaUiManager.Open("UiTRPGTest") + end + + function XTRPGManager.FinishExamine() + CurExmaine:Clear() + end + + function XTRPGManager.EnterExaminePunish() + CurExmaine:EnterPunish() + end + + function XTRPGManager.GetCurExamineId() + return CurExmaine:GetId() + end + + function XTRPGManager.GetCurExamineActionId() + return CurExmaine:GetActionId() + end + + function XTRPGManager.GetCurExamineCurAndReqScore() + return CurExmaine:GetScores() + end + + function XTRPGManager.GetCurExamineCurRound() + return CurExmaine:GetCurRound() + end + + function XTRPGManager.GetCurExamineRoleScore(roleId) + return CurExmaine:GetRoleScore(roleId) + end + + function XTRPGManager.CheckExamineStatus(examineStatus) + return CurExmaine:CheckStatus(examineStatus) + end + + function XTRPGManager.IsExaminePassed() + return CurExmaine:IsPassed() + end + + function XTRPGManager.IsExamineCanEnterNextRound() + return CurExmaine:IsCanEnternNextRound() + end + + function XTRPGManager.IsExamineRoleAlreadyRolled(roleId) + return CurExmaine:IsRoleAlreadyRolled(roleId) + end + + function XTRPGManager.IsExamineLastRound() + return CurExmaine:IsLastRound() + end + + function XTRPGManager.GetCurExaminePunishId() + return CurExmaine:GetPunishId() + end + + local function UpdateCurExmaineResult(data) + if XTool.IsTableEmpty(data) then return end + CurExmaine:UpdateResult(data) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_TRPG_EXAMINE_RESULT_SYN) + end + + local function UpdateCurExmaineScore(data) + if XTool.IsTableEmpty(data) then return end + CurExmaine:UpdateScore(data) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_TRPG_EXAMINE_DATA_CHANGE) + end + + --请求检定 + local ExamineAsynLock + function XTRPGManager.RequestExamineSend(examineId, actionId, cb) + if ExamineAsynLock then return end + ExamineAsynLock = true + + local req = { Id = examineId, ActionId = actionId } + XNetwork.Call("TRPGExamineRequest", req, function(res) + ExamineAsynLock = nil + + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + if cb then cb() end + + XTRPGManager.StartExamine(examineId, actionId) + end) + end + + --请求检定单个角色 + function XTRPGManager.RequestExamineCharacterSend(examineId, actionId, roleId, useItemId) + local curRound = XTRPGManager.GetCurExamineCurRound() + if XTRPGConfigs.CheckDefaultEffectItemId(useItemId) then + useItemId = nil + end + + local req = { Id = examineId, ActionId = actionId, Round = curRound, CharacterId = roleId, UseItemId = useItemId } + XNetwork.Call("TRPGExamineCharacterRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local data = { + RoleId = roleId, + Score = res.Score, + } + UpdateCurExmaineScore(data) + end) + end + + --确定检定结果 + function XTRPGManager.RequestExamineResult(examineId) + local req = { Id = examineId } + XNetwork.Call("TRPGExamineResultRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + UpdateCurExmaineResult(res) + end) + end + + --重置检定 + function XTRPGManager.TRPGExamineCharacterResetRequest(roleId) + local req = { CharacterId = roleId } + XNetwork.Call("TRPGExamineCharacterResetRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local data = { + RoleId = roleId, + Score = 0, + } + UpdateCurExmaineScore(data) + end) + end + + --进入下一轮检定 + function XTRPGManager.TRPGExamineChangeRoundRequest() + XNetwork.Call("TRPGExamineChangeRoundRequest", nil, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + CurExmaine:EnterNextRound() + CsXGameEventManager.Instance:Notify(XEventId.EVENT_TRPG_EXAMINE_ROUND_CHANGE) + end) + end + ---------------------检定相关 end--------------------------- + ---------------------protocol begin------------------ + --商店购买 + function XTRPGManager.RequestShopBuyItemSend(shopId, itemId, itemCount, cb) + local req = { ShopId = shopId, ItemId = itemId, ItemCount = itemCount } + XNetwork.Call("TRPGShopBuyItemRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + AddBuyTimes(shopId, itemId, itemCount) + XUiManager.OpenUiObtain(res.RewardList) + if cb then + cb() + end + end) + end + + --更新探索员信息 + function XTRPGManager.NotifyTRPGCharacterData(data) + local checkNew = true + UpdateRoles(data.Characters, checkNew) + end + + --更新已完成目标(增量更新) + function XTRPGManager.NotifyTRPGTargetFinish(data) + local tempCurrTargetLinkId = CurrTargetLinkId + UpdateTargetList(data.TargetList) + UpdateCurrTargetLinkId(CurrTargetLinkId) + + SetIsCanCheckOpenNewMaze(true) + + if tempCurrTargetLinkId ~= CurrTargetLinkId then + XTRPGManager.CheckRequestTargetLink(XTRPGConfigs.NotTargetLinkDefaultId) + end + end + + function XTRPGManager.NotifyTRPGFunctionFinish(data) + end + + --更新商店打折和购买上限 + function XTRPGManager.NotifyTRPGShopExtraData(data) + UpdateShopExtraData(data.ExtraDatas) + end + + --更新商店信息 + function XTRPGManager.NotifyTRPGClientShopInfo(data) + UpdateShopInfos(data.ShopInfos) + end + + --重置数据 + function XTRPGManager.NotifyTRPGDailyResetData(data) + BaseInfo:UpdateEndurance(data.Endurance) + UpdateCapacity(data.ItemCapacityAdd) + UpdateRoles(data.Characters) + UpdateWorldBossChallengeCount(data.BossChallengeCount) + UpdateShopInfos(data.ShopInfos) + end + + function XTRPGManager.RequestSelectTargetLinkSend(targetLinkid, isHideTip, isNotPlayNewAnima) + local req = { Id = targetLinkid } + XNetwork.Call("TRPGSelectTargetLinkRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + UpdateCurrTargetLinkId(targetLinkid, isNotPlayNewAnima) + if not isHideTip then + XUiManager.TipText("TRPGSwitchTargetComplete") + end + end) + end + + function XTRPGManager.NotifyTRPGItemCapacityChange(data) + UpdateCapacity(data.ItemCapacityAdd) + end + + function XTRPGManager.NotifyTRPGBaseInfo(data) + BaseInfo:UpdateData(data.BaseInfo) + end + + function XTRPGManager.NotifyTRPGData(data) + UpdateBossInfo(data.BossInfo) + UpdateTargetList(data.TargetList) + UpdateCurrTargetLinkId(data.CurTargetLink) + UpdateRewardList(data.RewardList) + UpdateRoles(data.Characters) + UpdateShopInfos(data.ShopInfos) + UpdateMazeInfos(data.MazeInfos) + UpdateMemoirInfos(data.MemoirList) + UpdateCapacity(data.ItemCapacityAdd) + BaseInfo:UpdateData(data.BaseInfo) + -- UpdateThirdAreaInfos(data.ThirdAreaInfos)--数据预期不一致兼容 + UpdateThirdAreaInfos(data.FuncList) + SetIsNormalPage(data.IsNormalPage) + UpdateStagePassDic(data.StageList) + + InitAleardyOpenMazeList() + UpdateOldCurrTargetId() + XTRPGManager.CheckRequestTargetLink(data.CurTargetLink) + XTRPGManager.RequestTRPGBossDetailSend() + end + + --使用道具 + function XTRPGManager.RequestUseItemRequestSend(itemId, itemCount, characterId, cb) + local req = { ItemId = itemId, ItemCount = itemCount, CharacterId = characterId } + XNetwork.Call("TRPGUseItemRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XUiManager.TipText("TRPGUseItemComplete") + if cb then + cb() + end + end) + end + + --请求领取奖励 + function XTRPGManager.RequestRewardSend(id, cb) + local req = { Id = id } + XNetwork.Call("TRPGRewardRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + UpdateRewardList({ id }) + XUiManager.OpenUiObtain(res.RewardList) + if cb then + cb() + end + XEventManager.DispatchEvent("EVENT_TRPG_GET_REWARD") + end) + end + + --请求播放记忆剧情 + function XTRPGManager.RequestTRPGOpenMemoirSend(id, cb) + local req = { Id = id } + XNetwork.Call("TRPGOpenMemoirRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + UpdateMemoirInfos({ req.Id }) + if cb then + cb() + end + XEventManager.DispatchEvent("EVENT_TRPG_GET_MEMOIR_REWARD") + end) + end + + --请求boss血量 + function XTRPGManager.RequestTRPGBossDetailSend(cb) + local openState = XTRPGManager.GetWorldBossOpenState() + if openState ~= XTRPGConfigs.AreaStateType.Open then + return + end + + XNetwork.Call("TRPGBossDetailRequest", nil, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + UpdateBossHpInfo(res) + if cb then + cb() + end + end) + end + + --请求boss阶段奖励 + function XTRPGManager.RequestTRPGBossPhasesRewardSend(id, cb) + local req = { Id = id } + XNetwork.Call("TRPGBossPhasesRewardRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + UpdateBossPhasesRewardListInfo({ req.Id }) + XUiManager.OpenUiObtain(res.RewardList) + if cb then + cb() + end + end) + end + + --世界BOSS信息发生改变 + function XTRPGManager.NotifyTRPGClientBossData(data) + UpdateBossInfo(data.BaseInfo) + end + + --请求改变模式 + function XTRPGManager.RequestTRPGChangePageStatus(status) + local req = {Status = status} + XNetwork.Call("TRPGChangePageStatusRequest", req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + SetIsNormalPage(status) + end) + end + ---------------------protocol end------------------ + ---------------------FubenManager begin------------------ + local function InitStageType(stageId) + stageId = tonumber(stageId) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + if stageInfo then + stageInfo.Type = XDataCenter.FubenManager.StageType.TRPG + end + end + + function XTRPGManager.InitStageInfo() + local stageId = XTRPGConfigs.GetBossStageId() + InitStageType(stageId) + + local stageIds = XTRPGConfigs.GetFunctionStageIds() + for _, stageId in pairs(stageIds) do + InitStageType(stageId) + end + + local secondMainIdList = XTRPGConfigs.GetSecondMainIdList() + for _, secondMainId in ipairs(secondMainIdList) do + local secondMainStageIdList = XTRPGConfigs.GetSecondMainStageId(secondMainId) + for _, secondMainStageId in ipairs(secondMainStageIdList) do + local stageId = XTRPGConfigs.GetSecondMainStageStageId(secondMainStageId) + InitStageType(stageId) + end + end + end + + function XTRPGManager.ShowReward(winData) + if XTRPGConfigs.IsBossStage(winData.StageId) then + XLuaUiManager.Open("UiTRPGWinWorldBoss", winData) + else + XTRPGManager.ReqFinishFunctionAfterFight() + XDataCenter.FubenManager.ShowReward(winData) + end + XTRPGManager.SetStagePass(winData.StageId) + end + ---------------------FubenManager end------------------ + function XTRPGManager.Init() + InitMazes() + XEventManager.AddEventListener(XEventId.EVENT_LOGIN_DATA_LOAD_COMPLETE, function() + XDataCenter.TRPGManager.InitCurrAreaOpenNum() + end) + end + + --------------------首次播放剧情 begin------------------------ + function XTRPGManager.MarkStoryID(Id, key) + if not XSaveTool.GetData(string.format("%d%s%s", XPlayer.Id, key, Id)) then + XSaveTool.SaveData(string.format("%d%s%s", XPlayer.Id, key, Id), Id) + end + end + + function XTRPGManager.CheckIsNewStoryID(Id, key) + if XSaveTool.GetData(string.format("%d%s%s", XPlayer.Id, key, Id)) then + return false + end + return true + end + --------------------首次播放剧情 end-------------------------- + --------------------跳转 start-------------------------- + function XTRPGManager.SkipTRPGMain() + local uiName = XTRPGManager.GetMainName() + + if XDataCenter.FubenMainLineManager.IsMainLineActivityOpen() then + local chapterId = XDataCenter.FubenMainLineManager.TRPGChapterId + local ret, desc = XDataCenter.FubenMainLineManager.CheckActivityCondition(chapterId) + if ret then + XLuaUiManager.OpenWithCallback(uiName, XTRPGManager.UpdateCurrAreaOpenNum) + else + XUiManager.TipError(desc) + end + elseif XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.MainLineTRPG) then + XLuaUiManager.OpenWithCallback(uiName, XTRPGManager.UpdateCurrAreaOpenNum) + end + end + + function XTRPGManager.GetMainName() + local isNormalPage = XTRPGManager.IsNormalPage() + return isNormalPage and "UiTRPGSecondMain" or "UiTRPGMain" + end + --------------------跳转 end-------------------------- + --------------------抢先体验 begin--------------------- + function XTRPGManager.CheckActivityEnd() + if not XDataCenter.FubenMainLineManager.IsMainLineActivityOpen() and not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.MainLineTRPG) then + XTRPGManager.OnActivityEnd() + end + end + + function XTRPGManager.OnActivityMainLineStateChange(chapterIds) + if not chapterIds then + return + end + for _, chapterId in pairs(chapterIds) do + if chapterId == XDataCenter.FubenMainLineManager.TRPGChapterId then + XTRPGManager.OnActivityEnd() + return + end + end + end + + function XTRPGManager.OnActivityEnd() + if CS.XFight.IsRunning or XLuaUiManager.IsUiLoad("UiLoading") then + return + end + XUiManager.TipText("ActivityMainLineEnd") + XLuaUiManager.RunMain() + end + --------------------抢先体验 end--------------------- + --------------------区域(城市和迷宫)地图 start--------------------- + function XTRPGManager.SaveIsAlreadyOpenExploreChapter(secondAreaId, mainAreaId) + if not XSaveTool.GetData(stringFormat("%d%s%s%s", XPlayer.Id, "IsAlreadyOpenExploreChapter", secondAreaId, mainAreaId)) then + XSaveTool.SaveData(stringFormat("%d%s%s%s", XPlayer.Id, "IsAlreadyOpenExploreChapter", secondAreaId, mainAreaId), true) + end + end + + function XTRPGManager.CheckIsAlreadyOpenExploreChapter(secondAreaId, mainAreaId) + return XSaveTool.GetData(stringFormat("%d%s%s%s", XPlayer.Id, "IsAlreadyOpenExploreChapter", secondAreaId, mainAreaId)) or false + end + + function XTRPGManager.SaveIsAlreadyEnterMaze(mazeId) + if not XSaveTool.GetData(stringFormat("%d%s%s", XPlayer.Id, "IsAlreadyEnterMaze", mazeId)) then + XSaveTool.SaveData(stringFormat("%d%s%s", XPlayer.Id, "IsAlreadyEnterMaze", mazeId), true) + end + end + + function XTRPGManager.CheckIsAlreadyEnterMaze(mazeId) + local mazeProgress = XTRPGManager.GetMazeProgress(mazeId) + if mazeProgress > 0 or XSaveTool.GetData(stringFormat("%d%s%s", XPlayer.Id, "IsAlreadyEnterMaze", mazeId)) then + return true + end + return false + end + --------------------区域(城市和迷宫)地图 end--------------------- + --------------------常规主线 start--------------------- + --是否有可领取的奖励 + function XTRPGManager.IsSecondMainCanReward(secondMainId) + local ret = XTRPGManager.CheckSecondMainCondition(secondMainId) + if not ret then + return false + end + + local secondMainStageIdList = XTRPGConfigs.GetSecondMainStageId(secondMainId) + local trpgRewardId + local isReceiveReward + for _, secondMainStageId in ipairs(secondMainStageIdList) do + trpgRewardId = XTRPGConfigs.GetSecondMainStageRewardId(secondMainStageId) + if not XTool.IsNumberValid(trpgRewardId) then + goto continue + end + + ret = XTRPGManager.CheckRewardCondition(trpgRewardId, secondMainId) + isReceiveReward = XDataCenter.TRPGManager.IsReceiveReward(trpgRewardId) + if ret and not isReceiveReward then + return true + end + :: continue :: + end + return false + end + + function XTRPGManager.CheckSecondMainCondition(secondMainId) + local conditionList = XTRPGConfigs.GetSecondMainCondition(secondMainId) + local ret + local desc = "" + for i, condition in ipairs(conditionList) do + ret, desc = XConditionManager.CheckCondition(condition) + if ret then + return true + end + end + return false, desc + end + + function XTRPGManager.CheckSecondMainStageCondition(secondMainStageId) + local conditionList = XTRPGConfigs.GetSecondMainStageCondition(secondMainStageId) + local ret + local desc = "" + for i, condition in ipairs(conditionList) do + ret, desc = XConditionManager.CheckCondition(condition) + if ret then + return true + end + end + return false, desc + end + + function XTRPGManager.SetStagePass(stageId) + StagePassDic[stageId] = true + end + + function XTRPGManager.IsStagePass(stageId) + return StagePassDic[stageId] or false + end + + function XTRPGManager.IsSecondMainReward() + local secondMainIdList = XTRPGConfigs.GetSecondMainIdList() + for i, secondMainId in ipairs(secondMainIdList) do + if XDataCenter.TRPGManager.IsSecondMainCanReward(secondMainId) then + return true + end + end + return false + end + --------------------常规主线 start--------------------- + XTRPGManager.Init() + + return XTRPGManager +end +---------------------(服务器推送)begin------------------ +XRpc.NotifyTRPGCharacterData = function(data) + XDataCenter.TRPGManager.NotifyTRPGCharacterData(data) +end + +XRpc.NotifyTRPGTargetFinish = function(data) + XDataCenter.TRPGManager.NotifyTRPGTargetFinish(data) +end + +XRpc.NotifyTRPGData = function(data) + XDataCenter.TRPGManager.NotifyTRPGData(data) +end + +XRpc.NotifyTRPGFunctionFinish = function(data) + XDataCenter.TRPGManager.NotifyTRPGFunctionFinish(data) +end + +XRpc.NotifyTRPGShopExtraData = function(data) + XDataCenter.TRPGManager.NotifyTRPGShopExtraData(data) +end + +XRpc.NotifyTRPGItemCapacityChange = function(data) + XDataCenter.TRPGManager.NotifyTRPGItemCapacityChange(data) +end + +XRpc.NotifyTRPGClientShopInfo = function(data) + XDataCenter.TRPGManager.NotifyTRPGClientShopInfo(data) +end + +XRpc.NotifyTRPGDailyResetData = function(data) + XDataCenter.TRPGManager.NotifyTRPGDailyResetData(data) +end + +XRpc.NotifyTRPGBaseInfo = function(data) + XDataCenter.TRPGManager.NotifyTRPGBaseInfo(data) +end + +XRpc.NotifyTRPGMazeSelectCardResult = function(data) + XDataCenter.TRPGManager.NotifyTRPGMazeSelectCardResult(data) +end + +XRpc.NotifyMazeRecordCardId = function(data) + XDataCenter.TRPGManager.NotifyMazeRecordCardId(data) +end + +XRpc.NotifyTRPGClientBossData = function(data) + XDataCenter.TRPGManager.NotifyTRPGClientBossData(data) +end +---------------------(服务器推送)end------------------ \ No newline at end of file diff --git a/Resources/Scripts/XManager/XTableManager.lua b/Resources/Scripts/XManager/XTableManager.lua new file mode 100644 index 00000000..6821efca --- /dev/null +++ b/Resources/Scripts/XManager/XTableManager.lua @@ -0,0 +1,670 @@ +XTableManager = XTableManager or {} + +local rawget = rawget +local pairs = pairs +local tonumber = tonumber +local tostring = tostring +local math = math +local mathFloor = math.floor +local string = string +local stringFind = string.find +local stringSub = string.sub +local stringGmatch = string.gmatch +local stringSplit = string.Split +local table = table +local tableInsert = table.insert + +local loadFileProfiler = XGame.Profiler:CreateChild("LoadTableFile") +local readTabFileProfiler = XGame.Profiler:CreateChild("ReadTabFile") +--只读标志 +local NeedSetReadonly = CS.XLuaEngine.LuaReadonlyTableMode ~= CS.XMode.Release +--只读元表 +local ReadOnlyTable = { + __newindex = function() + XLog.Error("attempt to update a readonly table") + end +} + +local WhiteTable = { + ["Share/Condition/Condition.tab"] = 1, + ["Share/Player/HonorLevel.tab"] = 1, + ["Client/ResourceLut/Model/Model.tab"] = 1, + ["Share/Fashion/Fashion.tab"] = 1, + ["Share/Fuben/Experiment/BattleExperiment.tab"] = 1, + + --| |--NotifyTask [Count: 1, Time: 65.00 ms]: -1734165120 + ["Share/Task/Task.tab"] = 1, + + --| |--NotifyStageData [Count: 1, Time: 733.79 ms]: -666193280 + ["Share/Fuben/Stage.tab"] = 1, + ["Share/Fuben/MainLine/ChapterMain.tab"] = 1, + ["Share/Fuben/MainLine/Chapter.tab"] = 1, + ["Share/Fuben/MainLine/Treasure.tab"] = 1, + ["Share/Fuben/Daily/DailyDungeonData.tab"] = 1, + ["Share/Fuben/UrgentEvent/UrgentEvent.tab"] = 1, + ["Share/Fuben/BossSingle/BossSingleSection.tab"] = 1, + ["Share/Fuben/BossSingle/BossSingleStage.tab"] = 1, + ["Share/Fuben/BossOnline/BossOnlineSection.tab"] = 1, + ["Share/Fuben/Bfrt/BfrtGroup.tab"] = 1, + ["Share/BountyTask/BountyTask.tab"] = 1, + ["Share/Fuben/Prequel/Chapter.tab"] = 1, + ["Share/Fuben/Prequel/Cover.tab"] = 1, + ["Share/Fuben/Arena/AreaStage.tab"] = 1, + ["Share/Fuben/Experiment/ExperimentLevel.tab"] = 1, + ["Share/Fuben/Explore/ExploreNode.tab"] = 1, + ["Share/Fuben/FubenBranch/FubenBranchSection.tab"] = 1, + ["Share/Fuben/BossActivity/BossSection.tab"] = 1, + ["Share/Fuben/BossActivity/BossChallenge.tab"] = 1, + ["Share/Fuben/Practice/PracticeChapter.tab"] = 1, + ["Share/Fuben/Festival/FestivalActivity.tab"] = 1, + ["Share/Fuben/BabelTower/BabelTowerActivity.tab"] = 1, + ["Share/Fuben/RepeatChallenge/RepeatChallengeActivity.tab"] = 1, + ["Share/Fuben/RepeatChallenge/RepeatChallengeChapter.tab"] = 1, + ["Share/Fuben/RogueLike/RogueLikeNode.tab"] = 1, + ["Share/Fuben/Assign/AssignChapter.tab"] = 1, + ["Share/Fuben/Assign/AssignGroup.tab"] = 1, + ["Share/Fuben/ArenaOnline/ArenaOnlineStage.tab"] = 1, + ["Share/Fuben/StageMultiplayerLevelControl.tab"] = 1, + ["Share/Fuben/ExtraChapter/ChapterExtra.tab"] = 1, + ["Share/Fuben/ExtraChapter/ChapterExtraDetails.tab"] = 1, + ["Share/Fuben/ExtraChapter/ChapterExtraStarTreasure.tab"] = 1, + ["Share/Fuben/SpecialTrain/Chapter.tab"] = 1, + ["Share/Fuben/InfestorExplore/ExploreNode.tab"] = 1, + ["Share/Fuben/InfestorExplore/InfestorActivity.tab"] = 1, + ["Share/Fuben/Expedition/ExpeditionStage.tab"] = 1, + ["Share/Fuben/Expedition/ExpeditionChapter.tab"] = 1, + ["Share/Fuben/WorldBoss/WorldBossAttributeArea.tab"] = 1, + ["Share/Fuben/WorldBoss/WorldBossBossArea.tab"] = 1, + ["Share/Fuben/Rpg/RpgStage.tab"] = 1, + ["Share/Fuben/MaintainerAction/MaintainerActionConfig.tab"] = 1, + ["Share/Fuben/MaintainerAction/MaintainerActionLevel.tab"] = 1, + ["Share/TRPG/Boss/TRPGBoss.tab"] = 1, + ["Share/TRPG/TRPGFunction.tab"] = 1, + ["Share/TRPG/SecondMain/TRPGSecondMain.tab"] = 1, + ["Share/TRPG/SecondMain/TRPGSecondMainStage.tab"] = 1, + ["Share/Fuben/NieR/NieRChapter.tab"] = 1, + ["Share/Fuben/NieR/NieRCharacter.tab"] = 1, + ["Share/Fuben/NieR/NieRRepeatableStage.tab"] = 1, + ["Share/Fuben/NieR/NieRActivity.tab"] = 1, + ["Share/Fuben/ZhouMu/ZhouMuChapter.tab"] = 1, + ["Share/Fuben/Teaching/TeachingActivity.tab"] = 1, + ["Share/ChessPursuit/ChessPursuitBoss.tab"] = 1, + ["Share/Fuben/Hack/HackStage.tab"] = 1, + ["Share/Fuben/Hack/HackChapter.tab"] = 1, + ["Share/Fuben/PartnerTeaching/PartnerTeachingChapter.tab"] = 1, + ["Share/Fuben/Reform/ReformStage.tab"] = 1, + ["Share/Fuben/KillZone/KillZoneStage.tab"] = 1, + ["Share/Fuben/FashionStory/FashionStory.tab"] = 1, + ["Share/Fuben/CoupleCombat/CoupleCombatChapter.tab"] = 1, + ["Share/Fuben/CoupleCombat/CoupleCombatStage.tab"] = 1, + + --| |--NotifyArchiveMonsterRecord [Count: 1, Time: 29.42 ms]: -1491350400 + ["Share/Archive/Monster.tab"] = 1, + ["Share/Archive/MonsterInfo.tab"] = 1, + ["Share/Archive/MonsterSetting.tab"] = 1, + + --| |--NotifyCharacterDataList [Count: 1, Time: 243.18 ms]: 742671616 + ["Share/Fight/Npc/Npc"] = 1, + ["Share/Attrib/AttribDesc.tab"] = 1, + ["Share/Attrib/AttribAbility.tab"] = 1, + ["Share/Equip/WeaponSkill.tab"] = 1, + ["Share/Equip/EquipSuit.tab"] = 1, + ["Share/Equip/EquipSuitEffect.tab"] = 1, + + + ["Share/Character/Character.tab"] = 1, + -- ["Share/Character/LevelUpTemplate/1.tab"] = 1, -- +} + +--默认类型 +local DefaultOfType = { + ["int"] = 0, + ["float"] = 0, + ["string"] = nil, + ["bool"] = false, + ["fix"] = fix.zero, +} + +local ToInt = function(value) + return mathFloor(value) +end + +local ToFloat = function(value) + return tonumber(value) +end + +local ToString = function(value) + return tostring(value) +end + +local ToBool = function(value) + return tonumber(value) ~= 0 and true or false +end + +local ToFix = function(value) + return FixParse(value) +end + +local LIST_FLAG = 1 +local DICTIONARY_FLAG = 2 + +local ValueFunc = { + ["int"] = ToInt, + ["float"] = ToFloat, + ["string"] = ToString, + ["bool"] = ToBool, + ["fix"] = ToFix, +} + +local KeyFunc = { + ["int"] = ToInt, + ["string"] = ToString, +} + +local GetSingleValueNew = function(type, value) + local func = ValueFunc[type] + if not func then + return + end + + if not value or #value == 0 then + return nil + end + + return func(value) +end + +local GetSingleValue = function(type, value) + local func = ValueFunc[type] + if not func then + return + end + + if not value or #value == 0 then + return DefaultOfType[type] + end + + return func(value) +end + +local GetContainerValue = function(type, value) + local func = ValueFunc[type] + if not func then + return + end + + if not value or #value == 0 then + return + end + + return func(value) +end + +local GetDictionaryKey = function(type, value) + local func = KeyFunc[type] + if not func then + return + end + + if not value or #value == 0 then + return + end + + return func(value) +end + +local IsDictionary = function(paramConfig) + return paramConfig.Type == DICTIONARY_FLAG +end + +local IsList = function(paramConfig) + return paramConfig.Type == LIST_FLAG +end + +local IsTable = function(pramsConfig) + return IsDictionary(pramsConfig) or IsList(pramsConfig) +end + +local EmptyTable = {} + +-- type func end-- +local READ_KEY_TYPE = { + INT = 0, + STRING = 1 +} + +local Split = function(str) + local arr = {} + for v in stringGmatch(str, '[^\t]*') do + tableInsert(arr, v) + end + return arr +end + +local CreateColElems = function(tableConfig) + local elems = {} + for key, paramConfig in pairs(tableConfig) do + if IsTable(paramConfig) then + elems[key] = {} + else + elems[key] = DefaultOfType[paramConfig.ValueType] + end + end + + return elems +end + +local ReadWithContext = function(context, tableConfig, keyType, identifier, path) + local file = assert(context) + local iter = stringSplit(file, "\r\n") --每一行内容 + local names = Split(iter[1])-- 表头 + local keys = {} --存储某一列字典类型的键值 + local cols = #names + local keyIndexTable = {} + local j = 1 + + -- 表头解析和检查 + for i = 1, cols do + local name = names[i] + local key + local startIndex = stringFind(name, "[[]") + if startIndex and startIndex > 0 then + local endIndex = stringFind(name, "[]]") + if startIndex ~= endIndex and endIndex == #name then-- 处理数组表头 + key = stringSub(name, startIndex + 1, endIndex - 1) --Dic key Array[2]中的 2 + name = stringSub(name, 1, startIndex - 1) + names[i] = name --Id Name Array[1] Array[2] ->Id Name Array Array + if not keyIndexTable[name] then + keyIndexTable[name] = j + j = j + 1 + end + else + XLog.Error("XTableManager.ReadTabFile 函数错误, 读取数据失败, 路径是 = " .. path .. ", 名字 = " .. name .. ", 开始索引 = " .. startIndex .. ", 结束索引 = " .. endIndex) + return + end + else + keyIndexTable[name] = j + j = j + 1 + end + + + -- 检查属性是否有配置 + local paramConfig = tableConfig[name] + if not paramConfig then + goto continue + end + + -- 字典类型处理 + if IsDictionary(paramConfig) then + if not key then + XLog.Error("XTableManager.ReadTabFile 函数错误: 读取数据失败,路径 = " .. path .. ", name = " .. name) + return + end + + local ret = GetDictionaryKey(paramConfig.KeyType, key) --Array[key] 吧key转成目标类型 + if not ret then + XLog.Error("XTableManager.ReadTabFile 函数错误: 读取数据失败,路径 = " .. path .. ", name = " .. name .. ", type = " .. paramConfig.KeyType .. ", key = " .. key) + return + end + + keys[i] = ret + end + + :: continue :: + end + ---每一个表对应一个元表 + local metaTable = {} + + metaTable.__index = function(tbl, keyIndex) + local idx = keyIndexTable[keyIndex] + + if not idx or not tbl then + return nil + end + + local result = rawget(tbl, idx) + local resultType = tableConfig[keyIndex] + + if not resultType then + XLog.Error(string.format("找不到键值 Key:%s 请检查该键值和表头是否匹配", keyIndex)) + end + + if not result then + if resultType and IsTable(resultType) then + result = EmptyTable + else + result = DefaultOfType[resultType.ValueType] + end + end + + return result + end + + metaTable.__newindex = function() + XLog.Error("attempt to update a readonly table") + end + + metaTable.__metatable = "readonly table" + + + metaTable.__pairs = function(t) + local function stateless_iter(tbl, key) + local nk = next(tbl, key) + + if nk and type(nk) == "string" then + local k = keyIndexTable[nk] + local nv = t[k] or t[nk] + return nk, nv + end + end + + return stateless_iter, tableConfig, nil + end + + local tab = {} + local index = 1 + local lineCount = #iter + for i = 2, lineCount do -- 遍历每一行表内容 + local line = iter[i] + + if not line or #line == 0 then + goto nextLine + end + + local elemArray = {} + local elems = {} --CreateColElems(tableConfig) --存储每一列类型的默认值 + local tmpElems = Split(line) --分割每一行内容,\t + --如果表头长度和内容长度匹配不上 + if #tmpElems ~= cols then + XLog.Warning("XTableManager.ReadTabFile warning: cols not match, path = " .. path .. ", row = " .. index .. ", cols = " .. cols .. ", cells length = " .. #tmpElems) + end + + for i2 = 1, cols do + local name = names[i2] --表头键值 + local value = tmpElems[i2] -- 单元格内容 + local paramConfig = tableConfig[name] --单元格类型 + + if paramConfig then + --如果是列表 + if IsList(paramConfig) then -- 数组 + value = GetContainerValue(paramConfig.ValueType, value) --单元格字符串转换成目标类型 + if not elems[name] or not next(elems[name]) then + elems[name] = {} + if NeedSetReadonly then + setmetatable(elems[name], ReadOnlyTable) + end + end + + if value then + local len = #elems[name] + rawset(elems[name], len + 1, value) + end + elseif IsDictionary(paramConfig) then -- 字典 + value = GetContainerValue(paramConfig.ValueType, value) + if not elems[name] or not next(elems[name]) then + elems[name] = {} + + if NeedSetReadonly then + setmetatable(elems[name], ReadOnlyTable) + end + end + + if value then + local key = keys[i2] + rawset(elems[name], key, value) + end + else + elems[name] = GetSingleValueNew(paramConfig.ValueType, value) + end + + elemArray[keyIndexTable[name]] = elems[name] + --else + --- XLog.Warning(string.format("表格%s 没有导出XTable.lua ,没找到Key:%s", path, name)) + end + end + + + if identifier then + local mainKey = elems[identifier] + if not mainKey then + XLog.Warning("表格有空行, path = " .. path .. ", row = " .. index .. ", cols = " .. cols .. ", cells length = " .. #tmpElems) + goto nextLine + end + + local id = keyType == READ_KEY_TYPE.STRING and tostring(mainKey) or mathFloor(mainKey) + if tab[id] then + XLog.Error("表格有重复键值, path = " .. path .. ", row = " .. index .. ", cols = " .. cols .. ", key = " .. id .. ", cells length = " .. #tmpElems) + goto nextLine + end + tab[id] = elemArray + else + tab[index] = elemArray + end + + setmetatable(elemArray, metaTable) + + index = index + 1 + + :: nextLine :: + end + + return tab +end + +local ReadTabFile = function(path, tableConfig, keyType, identifier) + loadFileProfiler:Start() + local context = CS.XTableManager.Load(path) + loadFileProfiler:Stop() + + readTabFileProfiler:Start() + local content = ReadWithContext(context, tableConfig, keyType, identifier, path) + readTabFileProfiler:Stop() + + return content +end + +function XTableManager.ReadByIntKeyWithContent(context, xtable, identifier) + return ReadWithContext(context, xtable, READ_KEY_TYPE.INT, identifier, "unknown") +end + +function XTableManager.ReadByStringKeyWithContent(context, xtable, identifier) + return ReadWithContext(context, xtable, READ_KEY_TYPE.STRING, identifier, "unknown") +end + +local TableCache = {} + +function XTableManager.ReleaseTableCache() + for k, v in pairs(TableCache) do + if not WhiteTable[k] then + TableCache[k] = nil + end + end +end + +function XTableManager.ReadByIntKey(path, xtable, identifier) + local tab = {} + + local tableHandle = XTableManager.ReadByIntKeyInner(path, xtable, identifier) + TableCache[path] = tableHandle + + local len = #tableHandle + + local mate = {} + mate.__index = function(tab, key) + if not key then + return nil + end + + local _ = TableCache[path] + + if not _ then + _ = XTableManager.ReadByIntKeyInner(path, xtable, identifier) + TableCache[path] = _ + end + + local data = _[key] + return data + end + + mate.__newindex = function() + XLog.Error("attempt to update a readonly table") + end + + mate.__metatable = "readonly table" + + mate.__len = function(t) + return len + end + + mate.__pairs = function(t) + local _ = TableCache[path] + + if not _ then + _ = XTableManager.ReadByIntKeyInner(path, xtable, identifier) + TableCache[path] = _ + end + + + local function stateless_iter(tbl, key) + local nk, nv = next(tbl, key) + return nk, nv + end + + return stateless_iter, _, nil + end + + setmetatable(tab, mate) + return tab +end + + + +function XTableManager.ReadByStringKey(path, xtable, identifier) + local tab = {} + + local tableHandle = XTableManager.ReadByStringKeyInner(path, xtable, identifier) + + TableCache[path] = tableHandle + + local len = #tableHandle + + local mate = {} + mate.__index = function(tab, key) + if not key then + return nil + end + + local _ = TableCache[path] + + if not _ then + _ = XTableManager.ReadByStringKeyInner(path, xtable, identifier) + TableCache[path] = _ + end + + local data = _[key] + return data + end + + mate.__newindex = function() + XLog.Error("attempt to update a readonly table") + end + + mate.__metatable = "readonly table" + + mate.__len = function(t) + return len + end + + mate.__pairs = function(t) + local _ = TableCache[path] + + if not _ then + _ = XTableManager.ReadByStringKeyInner(path, xtable, identifier) + TableCache[path] = _ + end + + + local function stateless_iter(tbl, key) + local nk, nv = next(tbl, key) + return nk, nv + end + + return stateless_iter, _, nil + end + + setmetatable(tab, mate) + return tab +end + +function XTableManager.ReadByIntKeyInner(path, xtable, identifier) + if path == nil or #path == 0 then + XLog.Error("XTableManager ReadByIntKey 函数错误, 表的路径不能为空Path: " .. xtable) + return + end + + if xtable == nil then + XLog.Error("XTableManager ReadByIntKey 函数错误, 配置表需要在xtable中定义相应的字段, 路径是: " .. path) + return + end + + if string.EndsWith(path, ".tab") then + return ReadTabFile(path, xtable, READ_KEY_TYPE.INT, identifier) + end + + local paths = CS.XTableManager.GetPaths(path) + local mergeTable = {} + + XTool.LoopCollection(paths, function(tmpPath) + local t = ReadTabFile(tmpPath, xtable, READ_KEY_TYPE.INT, identifier) + for k, v in pairs(t) do + if mergeTable[k] then + XLog.Error("XTableManager ReadByIntKey 函数错误, 配置表项键值重复检查配置表, 路径: " .. tmpPath .. ", identifier: " .. identifier .. ", key: " .. k) + return + end + mergeTable[k] = v + end + end) + + return mergeTable +end + +function XTableManager.ReadByStringKeyInner(path, xtable, identifier) + if path == nil or #path == 0 then + XLog.Error("XTableManager ReadByStringKey 函数错误, 配置表的路径不能为空, path: " .. path) + return + end + + if xtable == nil then + XLog.Error("XTableManager ReadByStringKey 函数错误, 必须根据此配置表在xtable中定义相应的字段, 配置表路径: " .. path) + return + end + + if identifier == nil or #identifier == 0 then + XLog.Error("XTableManager ReadByStringKey 函数错误, 参数identifier不能为空, path: " .. path) + return + end + + if string.EndsWith(path, ".tab") then + return ReadTabFile(path, xtable, READ_KEY_TYPE.STRING, identifier) + end + + local paths = CS.XTableManager.GetPaths(path) + local mergeTable = {} + + XTool.LoopCollection(paths, function(tmpPath) + local t = ReadTabFile(tmpPath, xtable, READ_KEY_TYPE.STRING, identifier) + for k, v in pairs(t) do + if mergeTable[k] then + XLog.Error("XTableManager ReadByStringKey函数错误, 配置表项键值重复检查配置表, 路径: " .. tmpPath .. ", identifier: " .. identifier .. ", key: " .. k) + return + end + mergeTable[k] = v + end + end) + + return mergeTable +end + +function XTableManager.ReadArray(path, xtable, identifier) + return XTableManager.ReadByIntKey(path, xtable) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XTaskForceManager.lua b/Resources/Scripts/XManager/XTaskForceManager.lua new file mode 100644 index 00000000..ad9ff2e1 --- /dev/null +++ b/Resources/Scripts/XManager/XTaskForceManager.lua @@ -0,0 +1,917 @@ +XTaskForceManagerCreator = function() + --派遣 + local XTaskForceManager = {} + + --派遣任务状态 + XTaskForceManager.TaskForceTaskStatus = { + Normal = 0, + Accept = 1, + Complete = 2, + } + + local TaskForceConfig = {} + local TaskForceExpendConfig = {} + local TaskForceSectionConfig = {} + local TaskForceTaskPoolConfig = {} + local TaskForceCountConfig = {} + + local MaxRefreshTimes = 0 --最大刷新次数,可以超过 + local TotalFreeRefreshTimes = 0 -- 总的免费次数 + local TotalSectionCount = 0 -- 总的章节数 + + + local TaskForceInfo = {} --所有派遣信息 + local NextRefreshTime = -1 + + local XTaskForceRequest = { + TaskForceRefreshRequest = "TaskForceRefreshRequest", + AcceptTaskForceTaskRequest = "AcceptTaskForceTaskRequest", + GiveUpTaskForceTaskRequest = "GiveUpTaskForceTaskRequest", + TaskForceTaskFinishRequest = "TaskForceTaskFinishRequest", + AcceptTaskForceRewardRequest = "AcceptTaskForceRewardRequest", + } + + + --初始化 + function XTaskForceManager.Init() + XTaskForceManager.InitConfig() + end + + + --初始化表 + function XTaskForceManager.InitConfig() + TaskForceConfig = XTaskForceConfigs.GetTaskForceConfig() + TaskForceExpendConfig = XTaskForceConfigs.GetTaskForceExpendConfig() + TaskForceSectionConfig = XTaskForceConfigs.GetTaskForceSectionConfig() + TaskForceTaskPoolConfig = XTaskForceConfigs.GetTaskForceTaskPoolConfig() + TaskForceCountConfig = XTaskForceConfigs.GetTaskForceCountConfig() + + MaxRefreshTimes = XTaskForceConfigs.MaxRefreshTimes + TotalFreeRefreshTimes = XTaskForceConfigs.TotalFreeRefreshTimes + TotalSectionCount = XTaskForceConfigs.TotalSectionCount + end + + --获取章节表 + function XTaskForceManager.GetTaskForceSectionConfig() + return TaskForceSectionConfig + end + + --获取当前章节Id + function XTaskForceManager.GetCurTaskForceSectionId() + if not TaskForceInfo then + return -1 + end + + return TaskForceInfo.SectionId + end + + --获取派遣上限相关 + function XTaskForceManager.GetTaskForceConfigById(id) + if not TaskForceConfig then + XLog.ErrorTableDataNotFound("XTaskForceManager.GetTaskForceConfigById", + "TaskForceConfig", "Share/TaskForce/TaskForceConfig.tab", "id", tostring(id)) + return + end + + return TaskForceConfig[id] + end + + ---获取总章节数 + function XTaskForceManager.GetTotalTaskForeSectionCount() + return TotalSectionCount + end + + --获取章节 + function XTaskForceManager.GetTaskForceSectionConfigById(id) + if not TaskForceSectionConfig then + XLog.ErrorTableDataNotFound("XTaskForceManager.GetTaskForceSectionConfigById", + "TaskForceSectionConfig", "Share/TaskForce/TaskForceSection.tab", "id", tostring(id)) + return + end + + return TaskForceSectionConfig[id] + end + + ---获取派遣最大次数条件数据 + function XTaskForceManager.GetTaskForceConfigInfo() + return TaskForceConfig + end + + ---获取派遣数据 + function XTaskForceManager.GetTaskForeInfo() + return TaskForceInfo + end + + --获取下次更新时间 + function XTaskForceManager.GetNextRefreshTime() + return NextRefreshTime + end + + --获取最近一个要完成的派遣任务 + function XTaskForceManager.GetLatelyTaskForeInfo() + if not TaskForceInfo then + return + end + + if not TaskForceInfo.TaskList or #TaskForceInfo.TaskList <= 0 then + return + end + + local taskForeInfo = nil + for _, v in ipairs(TaskForceInfo.TaskList) do + if v.Status == XTaskForceManager.TaskForceTaskStatus.Accept then + if taskForeInfo then + taskForeInfo = taskForeInfo.UtcFinishTime < v.UtcFinishTime and taskForeInfo or v + else + taskForeInfo = v + end + end + end + + return taskForeInfo + end + + --获取进行中的任务数量 + function XTaskForceManager.GetWorkingTaskCount() + if not TaskForceInfo then + return 0 + end + + if not TaskForceInfo.TaskList then + return 0 + end + + local taskCount = 0 + for _, v in ipairs(TaskForceInfo.TaskList) do + if v.Status ~= XTaskForceManager.TaskForceTaskStatus.Normal then + taskCount = taskCount + 1 + end + end + + return taskCount + end + + + --获取任务池数据 + function XTaskForceManager.GetTaskPoolInfo() + + if not TaskForceTaskPoolConfig then + return + end + + if not TaskForceInfo then + return + end + + local tasks = {} + + for _, v in ipairs(TaskForceInfo.TaskList) do + local task = {} + task.TaskCfg = TaskForceTaskPoolConfig[v.TaskId] + task.Task = v + task.IsWorking = v.Status ~= XTaskForceManager.TaskForceTaskStatus.Normal + table.insert(tasks, task) + end + + table.sort(tasks, function(a, b) + return tonumber(a.Task.Status) > tonumber(b.Task.Status) + end) + + return tasks + end + + --获取免费刷新总次数 + function XTaskForceManager.GetTotalFreeRefreshTimes() + return TotalFreeRefreshTimes + end + + --获取刷新信息 + function XTaskForceManager.GetRefreshInfoByTimes(times) + if not TaskForceExpendConfig then + return + end + + if times <= MaxRefreshTimes then + return TaskForceExpendConfig[times] + end + + return TaskForceExpendConfig[MaxRefreshTimes] + end + + --刷新任务池 + function XTaskForceManager.CheckCanRefresh(id, count) + if count < 0 then + return false + end + + local enough = XDataCenter.ItemManager.CheckItemCountById(id, count) + if not enough then + local itemName = XDataCenter.ItemManager.GetItemName(id) + local text = CS.XTextManager.GetText('AssetsBuyConsumeNotEnough', itemName) + XUiManager.TipMsg(text, XUiManager.UiTipType.Tip) + return false + end + + return true + end + + --檢查隊伍條件 + function XTaskForceManager.CheckTeamCondition(taskId, characterIds) + if #characterIds <= 0 then + return false, CS.XTextManager.GetText("MissionConditionMemberLimit") + end + + + if not TaskForceTaskPoolConfig then + return false + end + + local taskCfg = TaskForceTaskPoolConfig[taskId] + if not taskCfg then + return false + end + + local requireMemberCount = taskCfg.MemberCount + if #characterIds < requireMemberCount then + return false, CS.XTextManager.GetText("MissionConditionMemberLimit") + end + --[[ local characterLevelLimit = taskCfg.CharacterLevelLimit + for i, id in ipairs(characterIds) do + local character = XDataCenter.CharacterManager.GetCharacter(id) + if character.Level < characterLevelLimit then + return false, CS.XTextManager.GetText("MissionConditionNotEnough") + end + end]] + -- + return true + end + + local DefaultSort = function(a, b) + + if a.IsWorking ~= b.IsWorking then + return a.IsWorking < b.IsWorking + end + + if a.Level ~= b.Level then + return a.Level > b.Level + end + + if a.Quality ~= b.Quality then + return a.Quality > b.Quality + end + + local priorityA = XCharacterConfigs.GetCharacterPriority(a.Id) + local priorityB = XCharacterConfigs.GetCharacterPriority(b.Id) + + if priorityA ~= priorityB then + return priorityA < priorityB + end + + return a.Id > b.Id + end + + --获取可选择的角色 + function XTaskForceManager.GetOwnCharacterList() + local characterList = XDataCenter.CharacterManager.GetOwnCharacterList() + if not characterList then + return + end + + if not TaskForceInfo or not TaskForceInfo.TaskList or #TaskForceInfo.TaskList == 0 then + return characterList + end + + + local workingId = {} + for _, v in ipairs(TaskForceInfo.TaskList) do + if v.Status ~= XTaskForceManager.TaskForceTaskStatus.Normal then + local members = v.Members + for _, id in ipairs(members) do + workingId[id] = true + end + end + end + + for _, v in ipairs(characterList) do + if workingId[v.Id] then + v.IsWorking = 1 + else + v.IsWorking = 0 + end + end + + table.sort(characterList, DefaultSort) + + return characterList + end + + + --获取可选择的角色 + function XTaskForceManager.GetOwnCharacterCanTeamList() + local characterList = XDataCenter.CharacterManager.GetOwnCharacterList() + if not characterList then + return + end + + if not TaskForceInfo or not TaskForceInfo.TaskList or #TaskForceInfo.TaskList == 0 then + return characterList + end + + local workingId = {} + for _, v in ipairs(TaskForceInfo.TaskList) do + if v.Status ~= XTaskForceManager.TaskForceTaskStatus.Normal then + local members = v.Members + for _, id in ipairs(members) do + workingId[id] = true + end + end + end + + local list = {} + for _, v in ipairs(characterList) do + if not workingId[v.Id] then + table.insert(list, v.Id) + end + end + + return list + end + + --一键选择 + function XTaskForceManager.AutoChoiceCharacter(taskId) + local emptyTable = {} + if not TaskForceTaskPoolConfig then + return emptyTable + end + + local taskCfg = TaskForceTaskPoolConfig[taskId] + if not taskCfg then + return emptyTable + end + + local requireMemberCount = taskCfg.MemberCount + + local charIds = XTaskForceManager.GetOwnCharacterCanTeamList() + + if not charIds or #charIds <= 0 then + return emptyTable + end + + --条件筛选 + local conditions = {} + local conditionIds = taskCfg.ConditionList + for _, id in ipairs(conditionIds) do + local conditionRequireMember = XTaskForceManager.GetConditionRequireMember(id) + if conditionRequireMember == requireMemberCount then + charIds = XTaskForceManager.FitterPriorityCondition(charIds, id) + else + local condition = {} + condition.Id = id + condition.Members = {} + condition.MemberIndexs = {} + condition.ConditionRequireMember = conditionRequireMember + table.insert(conditions, condition) + end + end + + if not charIds or #charIds < requireMemberCount then + return emptyTable + end + + --如果没有需要匹配的条件 + if not conditions or #conditions <= 0 then + local newCharIds = {} + for _ = 1, requireMemberCount, 1 do + local rand = math.random(1, #charIds) + table.insert(newCharIds, charIds[rand]) + table.remove(charIds, rand) + end + return newCharIds + end + + --乱序 + charIds = XTool.RandomBreakTableOrder(charIds) + + --获得多个条件集合 + for index = 1, #conditions, 1 do + local condition = conditions[index] + for _, id in ipairs(charIds) do + if XTaskForceManager.CheckCondition(condition.Id, id) then + condition.Members[id] = id + table.insert(condition.MemberIndexs, id) + end + end + + --某一个条件不满足 + if #condition.MemberIndexs < condition.ConditionRequireMember then + return emptyTable + end + end + + local ret, tmpCharIds = XTaskForceManager.RandomMultContionCalculate(charIds, requireMemberCount, conditions) + + if not ret then + return emptyTable + end + + return tmpCharIds + end + + --多条件随机算法 + function XTaskForceManager.RandomMultContionCalculate(charIds, requireCount, conditions) + local charIdMap = {} + local count = 0 + local ret + + ret, charIdMap, count = XTaskForceManager.RecursionCalculate(charIdMap, requireCount, conditions, count, 1) + if not ret then + return false + end + + --提前满足条件,随机补充 + while count < requireCount do + local rand = math.random(1, #charIds) + local id = charIds[rand] + if not charIdMap[id] then + charIdMap[id] = id + count = count + 1 + end + end + + local Ids = {} + for k, _ in pairs(charIdMap) do + table.insert(Ids, k) + end + + return true, Ids + end + + --递归检查条件 + function XTaskForceManager.RecursionCalculate(charIds, requireCount, conditions, count, index) + + --超出条件上限 + if index > #conditions then + return false + end + + local curCondition = conditions[index] + + for randIndex = 1, #curCondition.MemberIndexs do + local id = curCondition.MemberIndexs[randIndex] + if not charIds[id] then + charIds[id] = id + --检测是否行得通 + local result, refCount = XTaskForceManager.CheckAllConditionEnough(charIds, conditions, requireCount, count + 1) + if result == 1 then + return true, charIds, count + 1 + elseif result == 0 then + if refCount[index] >= curCondition.ConditionRequireMember then + return XTaskForceManager.RecursionCalculate(charIds, requireCount, conditions, count + 1, index + 1) + else + count = count + 1 + end + else + charIds[id] = nil + end + end + end + + return false + end + + --检测 + --返回 1 完成 + --返回 0 继续 + --返回 -1 返回上一步 + function XTaskForceManager.CheckAllConditionEnough(charIds, conditions, requireCount, count) + + --检测每个条件的满足情况 + local refCount = {} + local compeltedCount = 0 + for index, condition in ipairs(conditions) do + refCount[index] = refCount[index] or 0 + for _, v in pairs(charIds) do + if condition.Members[v] then + refCount[index] = refCount[index] + 1 + end + end + + --当前条件的需求数量大于坑位数 + if refCount[index] >= condition.ConditionRequireMember then + compeltedCount = compeltedCount + 1 + elseif condition.ConditionRequireMember - refCount[index] > requireCount - count then + return -1 + end + end + + --满足了所有条件 + if compeltedCount == #conditions then + return 1 + end + + --没有坑位 + if count == requireCount then + return -1 + end + + return 0, refCount + + end + + + --过滤全条件不满足的构造体 + function XTaskForceManager.FitterPriorityCondition(charIdList, id) + if not charIdList or #charIdList <= 0 then + return + end + + local newList = {} + + for _, charId in ipairs(charIdList) do + if XTaskForceManager.CheckCondition(id, charId) then + table.insert(newList, charId) + end + end + + return newList + end + + --检测红点 + function XTaskForceManager.CheckTaskForceCompleted() + + if not TaskForceInfo or not TaskForceInfo.TaskList or #TaskForceInfo.TaskList == 0 then + return false + end + + for _, v in ipairs(TaskForceInfo.TaskList) do + if v.Status == XTaskForceManager.TaskForceTaskStatus.Complete then + return true + end + end + + return false + end + ------------------------------------------------------------ + --完成任务 + function XTaskForceManager.CompletedTaskForceTask(taskId) + if not TaskForceInfo then + return + end + + if not TaskForceInfo.TaskList or #TaskForceInfo.TaskList <= 0 then + return + end + + for _, var in ipairs(TaskForceInfo.TaskList) do + if var.TaskId == taskId then + var.Status = XTaskForceManager.TaskForceTaskStatus.Complete + break + end + end + + end + + + --网络协议---------------------------- + --放弃任务 + function XTaskForceManager.GiveUpTaskForceTaskRequest(taskId) + XNetwork.Call(XTaskForceRequest.GiveUpTaskForceTaskRequest, { TaskId = taskId }, function(resp) + if resp.Code ~= XCode.Success then + XUiManager.TipCode(resp.Code) + return + end + + if not TaskForceInfo then + return + end + + if not TaskForceInfo.TaskList or #TaskForceInfo.TaskList <= 0 then + return + end + + -- local removeIndex = -1 + for _, var in ipairs(TaskForceInfo.TaskList) do + if var.TaskId == resp.TaskId then + var.Members = {} + var.Status = XTaskForceManager.TaskForceTaskStatus.Normal + break + end + end + + -- if removeIndex > 0 then + -- table.remove(TaskForceInfo.TaskList, removeIndex) + -- end + XUiManager.TipMsg(CS.XTextManager.GetText("MissionGiveupSuccess")) + + + XEventManager.DispatchEvent(XEventId.EVENT_TASKFORCE_GIVEUP_TASK_REQUEST) + end) + end + + --接受任务 + function XTaskForceManager.AcceptTaskForceTaskRequest(taskId, members, callback) + XNetwork.Call(XTaskForceRequest.AcceptTaskForceTaskRequest, { TaskId = taskId, Members = members }, function(resp) + if resp.Code ~= XCode.Success then + XUiManager.TipCode(resp.Code) + return + end + + if not TaskForceInfo then + return + end + + local removeIndex = -1 + for index, v in ipairs(TaskForceInfo.TaskList) do + if resp.TaskId == v.TaskId then + removeIndex = index + --v.Status = XTaskForceManager.TaskForceTaskStatus.Accept + break + end + end + + + if removeIndex > 0 then + TaskForceInfo.TaskList[removeIndex] = resp.TaskInfo + end + + if callback then + callback() + end + + --XUiManager.TipMsg(CS.XTextManager.GetText("MissionSendSuccess")) + XEventManager.DispatchEvent(XEventId.EVENT_TASKFORCE_ACCEPT_TASK_REQUEST) + end) + end + + --请求刷新任务池 + function XTaskForceManager.TaskForceRefreshRequest(cb) + XNetwork.Call(XTaskForceRequest.TaskForceRefreshRequest, nil, function(resp) + if resp.Code ~= XCode.Success then + XUiManager.TipCode(resp.Code) + return + end + + if not TaskForceInfo then + return + end + + TaskForceInfo.TaskList = resp.TaskList + TaskForceInfo.RefreshCount = TaskForceInfo.RefreshCount + 1 + + --XUiManager.TipMsg(CS.XTextManager.GetText("MissionRefreshSuccess")) + if cb then + cb() + end + + XEventManager.DispatchEvent(XEventId.EVENT_TASKFORCE_REFRESH_REQUEST) + end) + end + + --请求立即完成任务 + function XTaskForceManager.TaskForceTaskFinishRequest(taskId) + XNetwork.Call(XTaskForceRequest.TaskForceTaskFinishRequest, { TaskId = taskId }, function(resp) + if resp.Code ~= XCode.Success then + XUiManager.TipCode(resp.Code) + return + end + + if not TaskForceInfo then + return + end + + if not TaskForceInfo.TaskList or #TaskForceInfo.TaskList <= 0 then + return + end + + for _, var in ipairs(TaskForceInfo.TaskList) do + if var.TaskId == resp.TaskId then + var.Status = XTaskForceManager.TaskForceTaskStatus.Complete + break + end + end + + XEventManager.DispatchEvent(XEventId.EVENT_TASKFORCE_TASKFINISH_REQUEST, { taskId }) + + end) + end + + --请求领取奖励 + function XTaskForceManager.AcceptTaskForceRewardRequest(taskId, callback) + XNetwork.Call(XTaskForceRequest.AcceptTaskForceRewardRequest, { TaskId = taskId }, function(resp) + if resp.Code ~= XCode.Success then + XUiManager.TipCode(resp.Code) + return + end + + if not TaskForceInfo then + return + end + + if not TaskForceInfo.TaskList or #TaskForceInfo.TaskList <= 0 then + return + end + + + TaskForceInfo.TaskList = resp.TaskList + + local result = {} + result.DropList = {} + result.ExtraRewardList = {} + result.Rewards = {} + + if resp.DropList and #resp.DropList > 0 then + result.IsBigReward = true + for _, var in ipairs(resp.DropList) do + table.insert(result.DropList, var) + end + end + + + if resp.ExtraRewardList and #resp.ExtraRewardList > 0 then + for _, var in ipairs(resp.ExtraRewardList) do + table.insert(result.ExtraRewardList, var) + end + end + + if resp.RewardList and #resp.RewardList > 0 then + for _, var in ipairs(resp.RewardList) do + table.insert(result.Rewards, var) + end + end + + if callback then + callback(result) + end + + XEventManager.DispatchEvent(XEventId.EVENT_TASKFORCE_ACCEPT_REWARD_REQUEST) + + end) + end + + XTaskForceManager.ShowMaxTaskForceTeamCountChangeTips = false + XTaskForceManager.ShowMaxTaskForceCountChangeTips = false + --消息推送 + function XTaskForceManager.TaskForceInfoNotify(data) + + if TaskForceInfo and TaskForceInfo.ConfigIndex then + if data.TaskForceInfo.ConfigIndex ~= TaskForceInfo.ConfigIndex then + XTaskForceManager.ShowMaxTaskForceTeamCountChangeTips = true + end + end + + TaskForceInfo = data.TaskForceInfo + NextRefreshTime = data.NextRefreshTime + + + XEventManager.DispatchEvent(XEventId.EVENT_TASKFORCE_INFO_NOTIFY) + end + + --章节变化 + function XTaskForceManager.TaskForceSectionChangeNotify(data) + if not TaskForceInfo then + return + end + + TaskForceInfo.SectionId = data.SectionId + XEventManager.DispatchEvent(XEventId.EVENT_TASKFORCE_SECTIONCHANGE_NOTIFY) + + end + + --可派遣队伍最大数量改变通知 + function XTaskForceManager.MaxTaskForceCountChangeNotify(data) + if not TaskForceInfo then + return + end + + if TaskForceCountConfig and TaskForceCountConfig[data.MaxTaskForceCount] then + local config = TaskForceCountConfig[data.MaxTaskForceCount] + TaskForceInfo.ConfigIndex = config.Id + end + + XEventManager.DispatchEvent(XEventId.EVENT_TASKFORCE_MAXTASKFORCECOUNT_CHANGE_NOTIFY) + end + + --任务完成 + function XTaskForceManager.TaskForceCompleteNotify(data) + if not TaskForceInfo then + return + end + + local taskList = data.TaskList + for _, taskId in ipairs(taskList) do + XTaskForceManager.CompletedTaskForceTask(taskId) + end + + XEventManager.DispatchEvent(XEventId.EVENT_TASKFORCE_COMPLETE_NOTIFY, data.TaskList) + end + + function XTaskForceManager.HandlerPlayTipMission() + if XDataCenter.TaskForceManager.ShowMaxTaskForceTeamCountChangeTips then + local missionData = XDataCenter.TaskForceManager.GetTaskForeInfo() + local taskForeCfg = XDataCenter.TaskForceManager.GetTaskForceConfigById(missionData.ConfigIndex) + XUiManager.TipMsg(string.format(CS.XTextManager.GetText("MissionTaskTeamCountContent"), taskForeCfg.MaxTaskForceCount), nil, function() + XEventManager.DispatchEvent(XEventId.EVENT_TASKFORCE_TIP_MISSION_END) + end) + XDataCenter.TaskForceManager.ShowMaxTaskForceTeamCountChangeTips = false + return true + end + return false + end + --------------------------------------- + local Condition = { + [18105] = function(condition, characterId) -- 派遣中拥有指定数量指定兵种构造 + local character = XDataCenter.CharacterManager.GetCharacter(characterId) + local npcId = XCharacterConfigs.GetCharNpcId(character.Id, character.Quality) + local npcTemplate = CS.XNpcManager.GetNpcTemplate(npcId) + if npcTemplate.Type == condition.Params[1] then + return true + end + return false, condition.Desc + end, + + [18106] = function() -- 派遣中拥有指定数量达到指定战斗力的构造体 + return true + end, + + [18107] = function(condition, characterId) -- 派遣中拥有指定数量达到指定品质的构造体 + local character = XDataCenter.CharacterManager.GetCharacter(characterId) + if character.Quality >= condition.Params[1] then + return true + end + return false, condition.Desc + end, + + [18108] = function(condition, characterId) -- 派遣中拥有指定数量达到指定等级的构造体 + local character = XDataCenter.CharacterManager.GetCharacter(characterId) + return character.Level >= condition.Params[1], condition.Desc + end, + + [18109] = function(condition, characterId) -- 派遣中拥有指定数量指定性别的构造体 + local characterTemplate = XCharacterConfigs.GetCharacterTemplate(characterId) + return characterTemplate.Sex == condition.Params[1], condition.Desc + end, + + [18110] = function(condition, characterId) -- 派遣中拥有构造体 + if characterId == condition.Params[1] then + return true + end + + return false, condition.Desc + end, + } + + ---检查单个 + function XTaskForceManager.CheckCondition(conditionId, characterId) + + local template = XConditionManager.GetConditionTemplate(conditionId) + if not template then + XLog.ErrorTableDataNotFound("XTaskForceManager.CheckCondition", "template", + "Share/Condition/Condition.tab", "conditionId", tostring(conditionId)) + return false + end + + local func = Condition[template.Type] + if not func then + local tempStr = "XConditionManager.CheckCharacterCondition错误:无法根据Share/Condition/Condition.tab 表中conditionId:" + XLog.Error(tempStr .. conditionId .. " 的type:" .. template.Type .. "找到Condition对应的函数") + return false + end + + return func(template, characterId) + end + + ---检查需求人数 + function XTaskForceManager.GetConditionRequireMember(conditionId) + local template = XConditionManager.GetConditionTemplate(conditionId) + if not template then + XLog.ErrorTableDataNotFound("XTaskForceManager.GetConditionRequireMember", + "template", "Share/Condition/Condition.tab", "conditionId", tostring(conditionId)) + return 0 + end + + if template.Type >= 18105 and template.Type < 18110 then + return template.Params[2] + end + + return 1 + end + ------ + XTaskForceManager.Init() + return XTaskForceManager +end + +XRpc.TaskForceInfoNotify = function(data) + XDataCenter.TaskForceManager.TaskForceInfoNotify(data) +end + +XRpc.TaskForceSectionChangeNotify = function(data) + XDataCenter.TaskForceManager.TaskForceSectionChangeNotify(data) +end + +XRpc.MaxTaskForceCountChangeNotify = function(data) + XDataCenter.TaskForceManager.MaxTaskForceCountChangeNotify(data) +end + +XRpc.TaskForceCompleteNotify = function(data) + XDataCenter.TaskForceManager.TaskForceCompleteNotify(data) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XTaskManager.lua b/Resources/Scripts/XManager/XTaskManager.lua new file mode 100644 index 00000000..ffa4f1d4 --- /dev/null +++ b/Resources/Scripts/XManager/XTaskManager.lua @@ -0,0 +1,2462 @@ +TaskType = { + Story = 1, -- 普通/剧情 + Daily = 2, -- 每日 + Weekly = 3,-- 每周 + Achievement = 4, -- 成就 + Activity = 5, -- 活动 + OffLine = 6, -- 下线(未使用) + NewPlayer = 7, -- 新手目标 + CharacterStory = 8, -- 角色剧情(未使用) + Bfrt = 9, -- 据点任务(未使用) + ArenaChallenge = 10, + TimeLimit = 11, --限时任务 + DormNormal = 12, --宿舍普通 + DormDaily = 13, --宿舍日常 + BossSingle = 14, -- 单挑boss(未使用) + BabelTower = 15, --巴别塔任务 + RogueLike = 16, --爬塔玩法 + Regression = 17, --回归活动 + GuildMainly = 18, --公会主线 + GuildDaily = 19, -- 公会日常 + ArenaOnlineWeekly = 20, -- 区域联机 + SpecialTrain = 21, -- 特训关日常任务(未使用) + InfestorWeekly = 22, -- 异聚迷宫 + GuildWeekly = 23, --工会周长 + BossOnLine = 24, --日服联机boss + WorldBoss = 25, --世界boss + Expedition = 26, -- 远征自走棋(未使用) + RpgTower = 27, --兵法蓝图 + MentorShipGrow = 28, -- 师徒成长任务 + MentorShipGraduate = 29, -- 师徒毕业挑战 + MentorShipWeekly = 30, -- 师徒每周任务 + NieR = 31, --尼尔玩法 + Pokemon = 32, --口袋战双 + ZhouMu = 39, --多周目 + ChristmasTree = 40, --圣诞树(未使用) + ChessPursuit = 41, --追击玩法(未使用) + Couplet = 42, --春节对联小游戏 + SimulatedCombat = 43, --模拟作战 + WhiteValentine = 44, --白色情人节 + MoeWarDaily = 45, -- 萌战每日任务 + MoeWarNormal = 46, -- 萌战累计任务 + FingerGuessing = 47, -- 猜拳小游戏 + PokerGuessing = 48, --翻牌猜大小 + Reform = 49, -- 改造玩法 + PokerGuessingCollection = 50, --翻牌猜大小收藏品任务 + Passport = 51, --通行证任务 + CoupleCombat = 52, -- 双人玩法 +} + +XTaskManagerCreator = function() + local tableInsert = table.insert + local tableSort = table.sort + + local Json = require("XCommon/Json") + local WeekTaskRefreshId = 10001 + local WeekTaskEpochTime = 0 + local WeekTaskRefreshDay = 1 + + local XTaskManager = {} + + local ITEM_NEWBIE_PROGRESS_ID = CS.XGame.ClientConfig:GetInt("NewPlayerTaskExpId") + + XTaskManager.TaskType = TaskType + XTaskManager.OperationState = { + DoWork = 1, + GetReward = 2, + GetedReward = 3 + } + + XTaskManager.ActiveRewardType = { + Daily = 1, + Weekly = 2 + } + + XTaskManager.AchvType = { + Fight = 1, + Collect = 2, + Social = 3, + Other = 4, + } + + XTaskManager.TaskState = { + InActive = -1, --未激活 + Standby = 0, --待命 + Active = 1, --已激活 + Accepted = 2, --已接受 + Achieved = 3, --完成(未领奖励) + Finish = 4, --结束(领取奖励) + Invalid = 5, --已失效/过期 + } + + XTaskManager.NewPlayerTaskGroupState = { + Lock = 1, --未解锁 + AllTodo = 2, --待完成 + HasAward = 3, --有奖励没领取 + AllFinish = 4, --全都结束 + } + + XTaskManager.CourseType = { + None = 0, -- 无状态 + Reward = 1, -- 有经历节点 + Function = 2, -- 有功能开启节点 + Normal = 3, -- 普通节点 + } + + XTaskManager.UpdateViewCallback = nil + + local CourseInfos = {} -- {key = ChapterId, Value = {LasetId, NextChapterId, Courses = {stageId, type, nextType......}}} + local CourseChapterRewards = {} + + local TaskDataGroup = {} + + -- 创建新系统或者优化原有系统时请使用新的通用任务接口 + ------------------------------------------------------- + local CourseData = {} + local TotalTaskData = {} + local StoryTaskData = {} + local DailyTaskData = {} + local WeeklyTaskData = {} + local ActivityTaskData = {} + local NewPlayerTaskData = {} + local AchvTaskData = {} + local ArenaTaskData = {} + local TimeLimitTaskData = {} + local ArenaOnlineWeeklyTaskData = {} + local InfestorWeeklyTaskData = {} + local BossOnlineTaskData = {} + local StoryGroupTaskData = {} + local DormStoryGroupTaskData = {} + local DormDailyGroupTaskData = {} + local FinishedTasks = {} + + -- 宿舍任务 + local DormNormalTaskData = {} + local DormDailyTaskData = {} + + local BabelTowerTaskData = {} + local RogueLikeTaskData = {} + local WorldBossTaskData = {} + + --师徒任务 + local MentorGrowTaskData = {} + local MentorGraduateTaskData = {} + local MentorWeeklyTaskData = {} + + local RpgTowerTaskData = {} + local WhiteValentineTaskData = {} + local FingerGuessingTaskData = {} + local PokerGuessingTaskData = {} + local GuildDailyTaskData = {} + local GuildMainlyTaskData = {} + local GuildWeeklyTaskData = {} + local ZhouMuTaskData = {} + + local RegressionTaskData = {} + local LinkTaskTimeDict = {} + local NieRTaskData = {} + + local PokemonTaskData = {} + -- 小游戏 + local CoupletTaskData = {} + local SimulatedCombatTaskData = {} + + local MoeWarDailyTaskData = {} + local MoeWarNormalTaskData = {} + + --通行证 + local PassportTaskData = {} + ------------------------------------------------------- + + local NewbieActivenessRecord = {} + XTaskManager.NewPlayerLastSelectTab = "NewPlayerHint_LastSelectTab" + XTaskManager.TaskLastSelectTab = "TaskHint_LastSelectTab" + XTaskManager.DormTaskLastSelectTab = "DormTaskHint_LastSelectTab" + XTaskManager.NewPLayerTaskFirstTalk = "NewPlayerHint_FirstTalk" + + local RegressionTaskRedPointCount = 0 + local RegressionTaskCanGetDic = {} + local RegressionTaskTypeToRedPointCountDic = {} + + function XTaskManager.Init() + XEventManager.AddEventListener(XEventId.EVENT_FUBEN_STAGE_SYNC, XTaskManager.SetCourseOnSyncStageData) + + local alarmClockData = XTaskConfig.GetAlarmClockById(WeekTaskRefreshId) + local jsonFormatData = Json.decode(alarmClockData.DayOfWeek) + WeekTaskEpochTime = alarmClockData.EpochTime + WeekTaskRefreshDay = jsonFormatData[1] + end + + function XTaskManager.InitTaskData(data) + local taskdata = data.Tasks + FinishedTasks = {} + for _, v in pairs(data.FinishedTasks or {}) do + FinishedTasks[v] = true + end + + if data.TaskLimitIdActiveInfos then + for _, v in pairs(data.TaskLimitIdActiveInfos) do + LinkTaskTimeDict[v.TaskLimitId] = v.ActiveTime + XEventManager.DispatchEvent(XEventId.EVENT_ACTIVITY_INFO_UPDATE) + end + end + NewbieActivenessRecord = data.NewPlayerRewardRecord + XTaskManager.InitCourseData(data.Course) + + for _, value in pairs(taskdata) do + TotalTaskData[value.Id] = value + end + local taskTemplate = XTaskConfig.GetTaskTemplate() + for k, v in pairs(taskTemplate) do + if not TotalTaskData[k] and v.Type ~= XTaskManager.TaskType.Daily and v.Type ~= XTaskManager.TaskType.Weekly and v.Type ~= XTaskManager.TaskType.InfestorWeekly then + TotalTaskData[k] = {} + TotalTaskData[k].Id = k + TotalTaskData[k].Schedule = {} + local conditions = v.Condition + + for _, var in ipairs(conditions) do + if FinishedTasks and FinishedTasks[k] then + tableInsert(TotalTaskData[k].Schedule, { Id = var, Value = v.Result }) + TotalTaskData[k].State = XTaskManager.TaskState.Finish + else + tableInsert(TotalTaskData[k].Schedule, { Id = var, Value = 0 }) + TotalTaskData[k].State = XTaskManager.TaskState.Active + end + end + + end + end + + local regressionTaskType + for k, v in pairs(TotalTaskData) do + local taskType = taskTemplate[k] and taskTemplate[k].Type or nil + if (taskTemplate[k] == nil) then + XLog.Warning("服务端数据异常 不存在任务配置id:", k) +-- 创建新系统或者优化原有系统时请使用新的通用任务接口 +------------------------------------------------------- + elseif taskType == XTaskManager.TaskType.Story then + StoryTaskData[k] = v + elseif taskType == XTaskManager.TaskType.Daily then + DailyTaskData[k] = v + elseif taskType == XTaskManager.TaskType.Weekly then + WeeklyTaskData[k] = v + elseif taskType == XTaskManager.TaskType.Activity then + ActivityTaskData[k] = v + elseif taskType == XTaskManager.TaskType.NewPlayer then + NewPlayerTaskData[k] = v + elseif taskType == XTaskManager.TaskType.Achievement then + AchvTaskData[k] = v + elseif taskType == XTaskManager.TaskType.ArenaChallenge then + ArenaTaskData[k] = v + elseif taskType == XTaskManager.TaskType.TimeLimit then + TimeLimitTaskData[k] = v + elseif taskType == XTaskManager.TaskType.DormNormal then + DormNormalTaskData[k] = v + elseif taskType == XTaskManager.TaskType.DormDaily then + DormDailyTaskData[k] = v + elseif taskType == XTaskManager.TaskType.BabelTower then + BabelTowerTaskData[k] = v + elseif taskType == XTaskManager.TaskType.RogueLike then + RogueLikeTaskData[k] = v + elseif taskType == XTaskManager.TaskType.WorldBoss then + WorldBossTaskData[k] = v + elseif taskType == XTaskManager.TaskType.RpgTower then + RpgTowerTaskData[k] = v + elseif taskType == XTaskManager.TaskType.WhiteValentine then + WhiteValentineTaskData[k] = v + elseif taskType == XTaskManager.TaskType.FingerGuessing then + FingerGuessingTaskData[k] = v + elseif taskType == XTaskManager.TaskType.ZhouMu then + ZhouMuTaskData[k] = v + elseif taskType == XTaskManager.TaskType.GuildDaily then + GuildDailyTaskData[k] = v + elseif taskType == XTaskManager.TaskType.GuildMainly then + GuildMainlyTaskData[k] = v + elseif taskType == XTaskManager.TaskType.GuildWeekly then + GuildWeeklyTaskData[k] = v + elseif taskType == XTaskManager.TaskType.MentorShipGrow then + MentorGrowTaskData[k] = v + elseif taskType == XTaskManager.TaskType.MentorShipGraduate then + MentorGraduateTaskData[k] = v + elseif taskType == XTaskManager.TaskType.MentorShipWeekly then + MentorWeeklyTaskData[k] = v + elseif taskType == XTaskManager.TaskType.Regression then + regressionTaskType = XRegressionConfigs.GetTaskTypeById(k) + RegressionTaskData[k] = v + if RegressionTaskCanGetDic[k] then + if v.State ~= XDataCenter.TaskManager.TaskState.Achieved then + RegressionTaskTypeToRedPointCountDic[regressionTaskType] = RegressionTaskTypeToRedPointCountDic[regressionTaskType] - 1 + RegressionTaskRedPointCount = RegressionTaskRedPointCount - 1 + RegressionTaskCanGetDic[k] = nil + end + else + if v.State == XDataCenter.TaskManager.TaskState.Achieved then + RegressionTaskCanGetDic[k] = true + RegressionTaskTypeToRedPointCountDic[regressionTaskType] = RegressionTaskTypeToRedPointCountDic[regressionTaskType] or 0 + RegressionTaskTypeToRedPointCountDic[regressionTaskType] = RegressionTaskTypeToRedPointCountDic[regressionTaskType] + 1 + RegressionTaskRedPointCount = RegressionTaskRedPointCount + 1 + end + end + elseif taskType == XTaskManager.TaskType.ArenaOnlineWeekly then + ArenaOnlineWeeklyTaskData[k] = v + elseif taskType == XTaskManager.TaskType.InfestorWeekly then + InfestorWeeklyTaskData[k] = v + elseif taskType == XTaskManager.TaskType.NieR then + NieRTaskData[k] = v + elseif taskType == XTaskManager.TaskType.Pokemon then + PokemonTaskData[k] = v + elseif taskType == XTaskManager.TaskType.Couplet then + CoupletTaskData[k] = v + elseif taskType == XTaskManager.TaskType.SimulatedCombat then + SimulatedCombatTaskData[k] = v + elseif taskType == XTaskManager.TaskType.MoeWarDaily then + MoeWarDailyTaskData[k] = v + elseif taskType == XTaskManager.TaskType.MoeWarNormal then + MoeWarNormalTaskData[k] = v + elseif taskType == XTaskManager.TaskType.PokerGuessing or taskType == XTaskManager.TaskType.PokerGuessingCollection then + PokerGuessingTaskData[k] = v + elseif taskType == XTaskManager.TaskType.Passport then + PassportTaskData[k] = v + elseif taskType == XTaskManager.TaskType.BossOnLine then + BossOnlineTaskData[k] = v + ------------------------------------------------------- + elseif taskType and taskType ~= XTaskManager.TaskType.OffLine then + -- XLog.Warning(taskType, k, v, "TaskDataGroup",TaskDataGroup) + if not TaskDataGroup[taskType] then + TaskDataGroup[taskType] = {} + end + TaskDataGroup[taskType][k] = v + + end + end + + XEventManager.DispatchEvent(XEventId.EVENT_TASK_SYNC) + XEventManager.DispatchEvent(XEventId.EVENT_NOTICE_TASKINITFINISHED)--上面那个事件触发太频繁,这里只需要监听初始完成 + CsXGameEventManager.Instance:Notify(XEventId.EVENT_TASK_SYNC) + end + + function XTaskManager.InitCourseInfos() + local courseChapterRewardTemp = {} + local courseTemplate = XTaskConfig.GetCourseTemplate() + for k, v in pairs(courseTemplate) do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(v.StageId) + local stageCfg = XDataCenter.FubenManager.GetStageCfg(v.StageId) + if not stageInfo or not stageCfg then + local path = XTaskConfig.GetTaskCoursePath() + XLog.ErrorTableDataNotFound("XTaskManager.InitCourseInfos", "StageId", path, "CourseId", tostring(k)) + return + end + + local SetType = function(cfg) + if cfg.RewardId and cfg.RewardId > 0 then + return XTaskManager.CourseType.Reward + elseif cfg.Tip and cfg.Tip ~= "" then + return XTaskManager.CourseType.Function + else + return XTaskManager.CourseType.Normal + end + end + + local SetCourse = function(lastStageId) + local type = SetType(v) + + local nextType = XTaskManager.CourseType.None + if stageInfo.NextStageId and courseTemplate[stageInfo.NextStageId] then + local nextCfg = courseTemplate[stageInfo.NextStageId] + nextType = SetType(nextCfg) + end + + local chapter = XDataCenter.FubenMainLineManager.GetChapterCfg(stageInfo.ChapterId) + local name = chapter.OrderId .. "-" .. stageCfg.OrderId + + -- 寻找还没有领奖励的关卡 + if type == XTaskManager.CourseType.Reward or lastStageId == v.StageId then + if XTaskManager.CheckCourseCanGet(v.StageId) then + if courseChapterRewardTemp[stageInfo.ChapterId] then + if type == XTaskManager.CourseType.Reward then + tableInsert(courseChapterRewardTemp[stageInfo.ChapterId].stageIds, v.StageId) + end + + local stageInfo1 = XDataCenter.FubenManager.GetStageInfo(lastStageId) + if lastStageId == v.StageId and not stageInfo1.Passed then + courseChapterRewardTemp[stageInfo1.ChapterId].LastStageId = v.StageId + end + else + if type == XTaskManager.CourseType.Reward then + courseChapterRewardTemp[stageInfo.ChapterId] = {} + courseChapterRewardTemp[stageInfo.ChapterId].ChapterId = stageInfo.ChapterId + courseChapterRewardTemp[stageInfo.ChapterId].OrderId = chapter.OrderId + courseChapterRewardTemp[stageInfo.ChapterId].stageIds = {} + tableInsert(courseChapterRewardTemp[stageInfo.ChapterId].stageIds, v.StageId) + end + + local stageInfo2 = XDataCenter.FubenManager.GetStageInfo(lastStageId) + if lastStageId == v.StageId and not stageInfo2.Passed then + if courseChapterRewardTemp[stageInfo2.ChapterId] then + courseChapterRewardTemp[stageInfo2.ChapterId].LastStageId = v.StageId + else + courseChapterRewardTemp[stageInfo2.ChapterId] = {} + courseChapterRewardTemp[stageInfo2.ChapterId].ChapterId = stageInfo2.ChapterId + courseChapterRewardTemp[stageInfo2.ChapterId].OrderId = chapter.OrderId + courseChapterRewardTemp[stageInfo2.ChapterId].stageIds = {} + courseChapterRewardTemp[stageInfo2.ChapterId].LastStageId = v.StageId + end + end + end + end + end + -- 寻找还没有领奖励的关卡 + return { + CouresType = type, + NextCouresType = nextType, + StageId = v.StageId, + Tip = v.Tip, + TipEn = v.TipEn, + RewardId = v.RewardId, + ShowId = v.ShowId, + OrderId = stageCfg.OrderId, + Name = name, + PreStageId = stageCfg.PreStageId + } + end + + if CourseInfos[stageInfo.ChapterId] then + local course = SetCourse(CourseInfos[stageInfo.ChapterId].LastStageId) + tableInsert(CourseInfos[stageInfo.ChapterId].Courses, course) + else + local nextChapterId = XDataCenter.FubenMainLineManager.GetNextChapterId(stageInfo.ChapterId) + local lastStageId = XDataCenter.FubenMainLineManager.GetLastStageId(stageInfo.ChapterId) + local isStageIdTableEmpty = XDataCenter.FubenMainLineManager.IsStageIdTableEmpty(stageInfo.ChapterId) + if not isStageIdTableEmpty then + CourseInfos[stageInfo.ChapterId] = {} + CourseInfos[stageInfo.ChapterId].Courses = {} + CourseInfos[stageInfo.ChapterId].NextChapterId = nextChapterId + CourseInfos[stageInfo.ChapterId].LastStageId = lastStageId + local course = SetCourse(lastStageId) + tableInsert(CourseInfos[stageInfo.ChapterId].Courses, course) + end + end + end + + local needk + for k, v in pairs(CourseInfos) do + if not needk or needk < k then + needk = k + end + tableSort(v.Courses, function(a, b) + return a.OrderId < b.OrderId + end) + end + + for _, v in pairs(courseChapterRewardTemp) do + tableSort(v.stageIds, function(a, b) + return a < b + end) + tableInsert(CourseChapterRewards, v) + end + + tableSort(CourseChapterRewards, function(a, b) + return a.OrderId < b.OrderId + end) + end + + function XTaskManager.InitCourseData(coursedata) + CourseData = {} + CourseInfos = {} + CourseChapterRewards = {} + + if coursedata then + XTool.LoopCollection(coursedata, function(key) + CourseData[key] = key + end) + end + XTaskManager.InitCourseInfos() + end + + function XTaskManager.SetCourseData(stageId) + local allRewardGet = false + if not CourseData[stageId] then + CourseData[stageId] = stageId + + --移除 CourseChapterRewards 里的Id,并判断是否领取完 + local remov_stage_i = -1 + local remov_stage_j = -1 + local remov_chapter_i = -1 + for i = 1, #CourseChapterRewards do + for j = 1, #CourseChapterRewards[i].stageIds do + if CourseChapterRewards[i].stageIds[j] == stageId then + remov_stage_i = i + remov_stage_j = j + if #CourseChapterRewards[i].stageIds <= 1 then + local lastId = CourseChapterRewards[i].LastStageId + local stageInfo = XDataCenter.FubenManager.GetStageInfo(lastId) + if (stageInfo and stageInfo.Passed) or not lastId then + remov_chapter_i = i + end + end + break + end + end + end + + if remov_stage_i > 0 and remov_stage_j > 0 then + table.remove(CourseChapterRewards[remov_stage_i].stageIds, remov_stage_j) + end + + if remov_chapter_i > 0 then + table.remove(CourseChapterRewards, remov_chapter_i) + allRewardGet = true + end + end + return allRewardGet + end + + --判断是否有进度 + function XTaskManager.CheckTaskHasSchedule(task) + local hasSchedule = false + XTool.LoopMap(task.Schedule, function(_, pair) + if pair.Value > 0 then + hasSchedule = true + end + end) + + return hasSchedule + end + + function XTaskManager.CheckCourseCanGet(stageId) + if CourseData[stageId] then + return false + else + return true + end + end + + function XTaskManager.GetCourseInfo(chapterId) + return CourseInfos[chapterId] + end + + function XTaskManager.GetCourseCurChapterId() + if not CourseChapterRewards or #CourseChapterRewards <= 0 then + return nil + end + return CourseChapterRewards[1].ChapterId + end + + function XTaskManager.SetCourseOnSyncStageData(stageId) + local remov_chapter_i = -1 + for i = 1, #CourseChapterRewards do + local lastId = CourseChapterRewards[i].LastStageId + local stageInfo = XDataCenter.FubenManager.GetStageInfo(lastId) + if #CourseChapterRewards[i].stageIds <= 0 and lastId == stageId and stageInfo.Passed then + remov_chapter_i = i + break + end + end + + if remov_chapter_i > 0 then + table.remove(CourseChapterRewards, remov_chapter_i) + end + end + + function XTaskManager.GetCourseCurRewardIndex(curChapterId) + if not CourseChapterRewards or #CourseChapterRewards <= 0 then + return nil + end + + if not CourseChapterRewards[1].stageIds[1] and #CourseChapterRewards[1].stageIds <= 0 then + return nil + end + + local stageId = CourseChapterRewards[1].stageIds[1] + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + if not stageInfo.Passed then + return nil + end + local courses = CourseInfos[curChapterId].Courses + for i = 1, #courses do + if stageId == courses[i].StageId then + return i + end + end + return nil + end + + function XTaskManager.GetTaskDataById(taskid) + return TotalTaskData[taskid] + end + + function XTaskManager.IsTaskFinished(taskId) + return FinishedTasks[taskId] + end + + local function CheckTask(task) + if not task then return false end + + local template = XTaskConfig.GetTaskTemplate()[task.Id] + + -- startTime限制 + if template.StartTime ~= nil and template.StartTime ~= "" then + local now = XTime.GetServerNowTimestamp() + local startTime = XTime.ParseToTimestamp(template.StartTime) + if startTime and startTime > now then return false end + end + + -- showCondition限制 + if template.ShowCondition ~= nil and template.ShowCondition ~= 0 then + -- 不满足返回false + if not XConditionManager.CheckCondition(template.ShowCondition) then + return false + end + end + + local preId = template and template.ShowAfterTaskId or -1 + if preId > 0 then + local preTask = TotalTaskData[preId] + + if preTask then + if preTask.State ~= XTaskManager.TaskState.Finish and preTask.State ~= XTaskManager.TaskState.Invalid then + return false + end + else + if FinishedTasks[preId] then + return true + end + return false + end + end + return true + end + + local function State2Num(state) + if state == XTaskManager.TaskState.Achieved then + return 1 + end + if state == XTaskManager.TaskState.Finish then + return -1 + end + return 0 + end + + local function CompareState(stateA, stateB) + if stateA == stateB then + return 0 + end + local a = State2Num(stateA) + local b = State2Num(stateB) + if a > b then return 1 end + if a < b then return -1 end + return 0 + end + + local function GetTaskList(tasks) + local list = {} + local type + local taskTemplate = XTaskConfig.GetTaskTemplate() + for _, task in pairs(tasks) do + type = taskTemplate[task.Id].Type + break + end + if type == XTaskManager.TaskType.Achievement + or type == XTaskManager.TaskType.ArenaChallenge + or type == XTaskManager.TaskType.Regression + or type == XTaskManager.TaskType.NieR + or type == XTaskManager.TaskType.MoeWarDaily + or type == XTaskManager.TaskType.MoeWarNormal + or type == XTaskManager.TaskType.PokerGuessing then + for _, task in pairs(tasks) do + if CheckTask(task) then + tableInsert(list, task) + end + end + else + for _, task in pairs(tasks) do + if task.State ~= XTaskManager.TaskState.Finish and task.State ~= XTaskManager.TaskState.Invalid then + if CheckTask(task) then + tableInsert(list, task) + end + end + end + end + + tableSort(list, function(a, b) + local pa, pb = taskTemplate[a.Id].Priority, taskTemplate[b.Id].Priority + local stateA = TotalTaskData[a.Id].State + local stateB = TotalTaskData[b.Id].State + local compareResult = CompareState(stateA, stateB) + if compareResult == 0 then + if pa ~= pb then + return pa > pb + else + return a.Id > b.Id + end + else + return compareResult > 0 + end + end) + + return list + end + + + function XTaskManager.SetAchievedList() + local tasks = XTaskManager.GetTaskDataByTaskType(XTaskManager.TaskType.Achievement) + local list = {} + + local taskTemplate = XTaskConfig.GetTaskTemplate() + for _, task in pairs(tasks) do + if not (task.State == XTaskManager.TaskState.Invalid) then + if taskTemplate[task.Id] and taskTemplate[task.Id].ShowAfterTaskId > 0 then + local preId = taskTemplate[task.Id].ShowAfterTaskId + if TotalTaskData[preId] then + if (TotalTaskData[preId].State == XTaskManager.TaskState.Finish or TotalTaskData[preId].State == XTaskManager.TaskState.Invalid) then + tableInsert(list, task) + end + elseif FinishedTasks[preId] then + tableInsert(list, task) + end + else + tableInsert(list, task) + end + end + end + + local listAchieved = {} + for _, v in pairs(list) do + if v.State == XTaskManager.TaskState.Achieved or v.State == XTaskManager.TaskState.Finish then + tableInsert(listAchieved, v) + end + end + end + + --获取成就任务已完成和总数量 + function XTaskManager.GetAchievedTasksByType(achvType) + + local achieveCount = 0 + local totalCount = 0 + local achieveList = {} + local achvTaskData = XTaskManager.GetAchvTaskList() + for _, task in pairs(achvTaskData) do + local _achvType = XTaskConfig.GetTaskTemplate()[task.Id].AchvType + if _achvType == achvType and task ~= nil then + tableInsert(achieveList, task) + totalCount = totalCount + 1 + if task.State == XTaskManager.TaskState.Finish or task.State == XTaskManager.TaskState.Achieved then + achieveCount = achieveCount + 1 + end + end + end + + return achieveList, achieveCount, totalCount + end + + --红点--------------------------------------------------------- + --根据成就任务类型判断是否有奖励可以领取 + function XTaskManager.HasAchieveTaskRewardByAchieveType(achvType) + for _, task in pairs(AchvTaskData) do + local _achvType = XTaskConfig.GetTaskTemplate()[task.Id].AchvType + if _achvType == achvType and task ~= nil and task.State == XTaskManager.TaskState.Achieved then + return true + end + end + + return false + end + + --判断历程是否有奖励获取 + function XTaskManager.CheckAllCourseCanGet() + + if not CourseInfos then + return false + end + + local curChapterId = XTaskManager.GetCourseCurChapterId() + if not CourseInfos[curChapterId] then + return + end + + local canGet = false + for _, v in ipairs(CourseInfos[curChapterId].Courses) do + + local stageId = v.StageId + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + + if v.CouresType == XTaskManager.CourseType.Reward and stageInfo.Passed and XTaskManager.CheckCourseCanGet(stageId) then + canGet = true + break + end + end + + return canGet + end + + --根据任务类型判断是否有奖励可以领取 + function XTaskManager.GetIsRewardForEx(taskType, groupId) + local taskList = nil + + -- 创建新系统或者优化原有系统时请使用新的通用任务接口 + ------------------------------------------------------- + if taskType == XTaskManager.TaskType.Story then + taskList = XTaskManager.GetStoryTaskList() + elseif taskType == XTaskManager.TaskType.Daily then + taskList = XTaskManager.GetDailyTaskList() + elseif taskType == XTaskManager.TaskType.Weekly then + taskList = XTaskManager.GetWeeklyTaskList() + elseif taskType == XTaskManager.TaskType.Activity then + taskList = XTaskManager.GetActivityTaskList() + elseif taskType == XTaskManager.TaskType.Achievement then + taskList = XTaskManager.GetAchvTaskList() + elseif taskType == XTaskManager.TaskType.DormDaily then + taskList = XTaskManager.GetDormDailyTaskList() + elseif taskType == XTaskManager.TaskType.DormNormal then + taskList = XTaskManager.GetDormNormalTaskList() + elseif taskType == XTaskManager.TaskType.BabelTower then + taskList = XTaskManager.GetBabelTowerTaskList() + elseif taskType == XTaskManager.TaskType.RogueLike then + taskList = XTaskManager.GetRogueLikeTaskList() + elseif taskType == XTaskManager.TaskType.GuildDaily then + taskList = XTaskManager.GetGuildDailyTaskList() + elseif taskType == XTaskManager.TaskType.GuildMainly then + taskList = XTaskManager.GetGuildMainlyTaskList() + elseif taskType == XTaskManager.TaskType.GuildWeekly then + taskList = XTaskManager.GetGuildWeeklyTaskList() + elseif taskType == XTaskManager.TaskType.ArenaOnlineWeekly then + taskList = XTaskManager.GetArenaOnlineWeeklyTaskList() + elseif taskType == XTaskManager.TaskType.InfestorWeekly then + taskList = XTaskManager.GetInfestorWeeklyTaskList() + elseif taskType == XTaskManager.TaskType.WorldBoss then + taskList = XTaskManager.GetWorldBossTaskList() + elseif taskType == XTaskManager.TaskType.MentorShipGrow then + taskList = XTaskManager.GetMentorGrowTaskList() + elseif taskType == XTaskManager.TaskType.MentorShipGraduate then + taskList = XTaskManager.GetMentorGraduateTaskList() + elseif taskType == XTaskManager.TaskType.MentorShipWeekly then + taskList = XTaskManager.GetMentorWeeklyTaskList() + elseif taskType == XTaskManager.TaskType.NieR then + taskList = XTaskManager.GetNieRTaskList() + elseif taskType == XTaskManager.TaskType.Pokemon then + taskList = XTaskManager.GetPokemonTaskList() + elseif taskType == XTaskManager.TaskType.Couplet then + taskList = XTaskManager.GetCoupletTaskList() + elseif taskType == XTaskManager.TaskType.SimulatedCombat then + taskList = XTaskManager.GetSimulatedCombatTaskList() + elseif taskType == XTaskManager.TaskType.MoeWarDaily then + taskList = XTaskManager.GetMoeWarDailyTaskList() + elseif taskType == XTaskManager.TaskType.MoeWarNormal then + taskList = XTaskManager.GetMoeWarNormalTaskList() + elseif taskType == XTaskManager.TaskType.Passport then + taskList = XTaskManager.GetPassportTaskList() + elseif taskType == XTaskManager.TaskType.BossOnLine then + taskList = XTaskManager.GetBossOnlineTaskListData() + ------------------------------------------------------- + elseif taskType then + taskList = XTaskManager.GetTaskList(taskType, groupId) + end + + if taskList == nil then + return false + end + for _, taskInfo in pairs(taskList) do + if taskInfo ~= nil and taskInfo.State == XTaskManager.TaskState.Achieved then + return true + end + end + return false + end + + --判断新手任务是否有奖励可以领取 + function XTaskManager.CheckIsNewPlayerTaskReward() + local newPlayerTaskGroupTemplate = XTaskConfig.GetNewPlayerTaskGroupTemplate() + if not newPlayerTaskGroupTemplate then + return false + end + + + local hasReward = false + + for k, _ in pairs(newPlayerTaskGroupTemplate) do + local state = XTaskManager.GetNewPlayerGroupTaskStatus(k) + + local talkConfig = XTaskManager.GetNewPlayerTaskTalkConfig(k) + local isNewPlayerTaskUIGroupActive = XPlayer.IsNewPlayerTaskUIGroupActive(k) + if talkConfig and not isNewPlayerTaskUIGroupActive and talkConfig.StoryId and state ~= XTaskManager.NewPlayerTaskGroupState.Lock then + hasReward = true + break + end + + if state == XTaskManager.NewPlayerTaskGroupState.HasAward then + hasReward = true + break + end + end + + return hasReward + end + + --判断是否有每日活跃任务是否有奖励可以领取 + function XTaskManager.CheckHasWeekActiveTaskReward() + local wActiveness = XDataCenter.ItemManager.GetWeeklyActiveness().Count + local weekActiveness = XTaskConfig.GetWeeklyActiveness() + + for i = 1, 2 do + if weekActiveness[i] <= wActiveness and (not XPlayer.IsGetWeeklyActivenessReward(i)) then + return true + end + end + + return false + end + + + --判断是否有周活跃任务是否有奖励可以领取 + function XTaskManager.CheckHasDailyActiveTaskReward() + local dActiveness = XDataCenter.ItemManager.GetDailyActiveness().Count + local dailyActiveness = XTaskConfig.GetDailyActiveness() + for i = 1, 5 do + if dailyActiveness[i] <= dActiveness and (not XPlayer.IsGetDailyActivenessReward(i)) then + return true + end + end + + return false + end + + -- 创建新系统或者优化原有系统时请使用新的通用任务接口 + ------------------------------------------------------- + function XTaskManager.GetStoryTaskList() + return GetTaskList(XTaskManager.GetTaskDataByTaskType(XTaskManager.TaskType.Story)) + end + + function XTaskManager.GetDailyTaskList() + return GetTaskList(XTaskManager.GetTaskDataByTaskType(XTaskManager.TaskType.Daily)) + end + + function XTaskManager.GetWeeklyTaskList() + local weeklyTasks = XTaskManager.GetTaskDataByTaskType(XTaskManager.TaskType.Weekly) or {} + local arenaOnlineWeeklyTasks = XTaskManager.GetTaskDataByTaskType(XTaskManager.TaskType.ArenaOnlineWeekly) or {} + local guildWeeklyTasks = XTaskManager.GetTaskDataByTaskType(XTaskManager.TaskType.GuildWeekly) or {} + local infestorWeeklyTasks = XTaskManager.GetTaskDataByTaskType(XTaskManager.TaskType.InfestorWeekly) or {} + + local tasks = {} + for k, v in pairs(weeklyTasks) do + tasks[k] = v + end + + for k, v in pairs(arenaOnlineWeeklyTasks) do + tasks[k] = v + end + + for k, v in pairs(guildWeeklyTasks) do + tasks[k] = v + end + + for k, v in pairs(infestorWeeklyTasks) do + tasks[k] = v + end + + return GetTaskList(tasks) + end + + function XTaskManager.GetActivityTaskList() + return GetTaskList(XTaskManager.GetTaskDataByTaskType(XTaskManager.TaskType.Activity)) + end + + function XTaskManager.GetAchvTaskList() + return GetTaskList(XTaskManager.GetTaskDataByTaskType(XTaskManager.TaskType.Achievement)) + end + + function XTaskManager.GetTimeLimitTaskList() + return GetTaskList(XTaskManager.GetTaskDataByTaskType(XTaskManager.TaskType.TimeLimit)) + end + + function XTaskManager.GetArenaChallengeTaskList() + return GetTaskList(XTaskManager.GetTaskDataByTaskType(XTaskManager.TaskType.ArenaChallenge)) + end + + function XTaskManager.GetDormNormalTaskList() + return GetTaskList(XTaskManager.GetTaskDataByTaskType(XTaskManager.TaskType.DormNormal)) + end + + function XTaskManager.GetDormDailyTaskList() + return GetTaskList(XTaskManager.GetTaskDataByTaskType(XTaskManager.TaskType.DormDaily)) + end + + function XTaskManager.GetBabelTowerTaskList() + return GetTaskList(XTaskManager.GetTaskDataByTaskType(XTaskManager.TaskType.BabelTower)) + end + + function XTaskManager.GetArenaOnlineWeeklyTaskList() + return GetTaskList(XTaskManager.GetTaskDataByTaskType(XTaskManager.TaskType.ArenaOnlineWeekly)) + end + + function XTaskManager.GetInfestorWeeklyTaskList() + return GetTaskList(XTaskManager.GetTaskDataByTaskType(XTaskManager.TaskType.InfestorWeekly)) + end + + -- 包括已完成的任务 + function XTaskManager.GetBabelTowerFullTaskList() + local tasks = {} + for _, v in pairs(BabelTowerTaskData) do + table.insert(tasks, v) + end + return tasks + end + + function XTaskManager.GetRogueLikeTaskList() + return GetTaskList(XTaskManager.GetTaskDataByTaskType(XTaskManager.TaskType.RogueLike)) + end + + function XTaskManager.GetRogueLikeFullTaskList() + local tasks = {} + for _, v in pairs(RogueLikeTaskData) do + table.insert(tasks, v) + end + return tasks + end + + function XTaskManager.GetRpgTowerTaskList() + return GetTaskList(XTaskManager.GetTaskDataByTaskType(XTaskManager.TaskType.RpgTower)) + end + + function XTaskManager.GetRpgTowerFullTaskList() + local tasks = {} + for _, v in pairs(RpgTowerTaskData) do + table.insert(tasks, v) + end + return tasks + end + + function XTaskManager.GetWhiteValentineTaskList() + return GetTaskList(XTaskManager.GetTaskDataByTaskType(XTaskManager.TaskType.WhiteValentine)) + end + + function XTaskManager.GetWhiteValentineFullTaskList() + local tasks = {} + for _, v in pairs(WhiteValentineTaskData) do + table.insert(tasks, v) + end + return tasks + end + + function XTaskManager.GetWhiteValentineFirstNotAcheivedMission() + local taskList = XDataCenter.TaskManager.GetWhiteValentineFullTaskList() + for _, v in pairs(taskList or {}) do + v.SortWeight = 2 + if v.State == XDataCenter.TaskManager.TaskState.Achieved then + v.SortWeight = 1 + elseif v.State == XDataCenter.TaskManager.TaskState.Finish or v.State == XDataCenter.TaskManager.TaskState.Invalid then + v.SortWeight = 3 + end + end + table.sort(taskList, function(taskA, taskB) + if taskA.SortWeight == taskB.SortWeight then + return taskA.Id < taskB.Id + end + return taskA.SortWeight < taskB.SortWeight + end) + return taskList[1] + end + + function XTaskManager.GetPokerGuessingTaskList() + return GetTaskList(PokerGuessingTaskData) + end + + function XTaskManager.GetFingerGuessingTaskList() + return GetTaskList(XTaskManager.GetTaskDataByTaskType(XTaskManager.TaskType.FingerGuessing)) + end + + function XTaskManager.GetFingerGuessingFullTaskList() + local tasks = {} + for _, v in pairs(FingerGuessingTaskData) do + table.insert(tasks, v) + end + return tasks + end + + function XTaskManager.GetZhouMuFullTaskList() + local tasks = {} + for _, v in pairs(ZhouMuTaskData) do + table.insert(tasks, v) + end + return tasks + end + + function XTaskManager.GetWorldBossTaskList() + return GetTaskList(XTaskManager.GetTaskDataByTaskType(XTaskManager.TaskType.WorldBoss)) + end + + function XTaskManager.GetNierTaskListByGroupId(groupId) + local tasksCfgs = XTaskConfig.GetTaskTemplate() + local result = {} + for _, task in pairs(NieRTaskData) do + local taskId = task.Id + local task = NieRTaskData[taskId] + if tasksCfgs[taskId].GroupId == groupId and task then + result[taskId] = task + end + end + return GetTaskList(result) + end + + function XTaskManager.GetNieRTaskList() + return GetTaskList(XTaskManager.GetTaskDataByTaskType(XTaskManager.TaskType.NieR)) + end + + function XTaskManager.GetWorldBossFullTaskList() + local tasks = {} + local bossTaskDataDic = XDataCenter.WorldBossManager.GetWorldBossBossTaskDataDic() + + for _, v in pairs(WorldBossTaskData) do + local IsCanShow = true + for _, data in pairs(bossTaskDataDic and bossTaskDataDic[v.Id] or {}) do + if data:GetIsLock() then + IsCanShow = false + break + end + end + if IsCanShow then + table.insert(tasks, v) + end + end + return tasks + end + + function XTaskManager.GetMentorGrowTaskList() + return GetTaskList(XTaskManager.GetTaskDataByTaskType(XTaskManager.TaskType.MentorShipGrow)) + end + + function XTaskManager.GetMentorGrowFullTaskList() + local taskTemplate = XTaskConfig.GetTaskTemplate() + local tasks = {} + for _, v in pairs(MentorGrowTaskData) do + table.insert(tasks, v) + end + tableSort(tasks, function(a, b) + local pa, pb = taskTemplate[a.Id].Priority, taskTemplate[b.Id].Priority + local stateA = TotalTaskData[a.Id].State + local stateB = TotalTaskData[b.Id].State + local compareResult = CompareState(stateA, stateB) + if compareResult == 0 then + if pa ~= pb then + return pa > pb + else + return a.Id > b.Id + end + else + return compareResult > 0 + end + end) + + return tasks + end + + function XTaskManager.GetMentorGraduateTaskList() + return GetTaskList(XTaskManager.GetTaskDataByTaskType(XTaskManager.TaskType.MentorShipGraduate)) + end + + function XTaskManager.GetMentorGraduateFullTaskList() + local taskTemplate = XTaskConfig.GetTaskTemplate() + local tasks = {} + for _, v in pairs(MentorGraduateTaskData) do + table.insert(tasks, v) + end + tableSort(tasks, function(a, b) + local pa, pb = taskTemplate[a.Id].Priority, taskTemplate[b.Id].Priority + local stateA = TotalTaskData[a.Id].State + local stateB = TotalTaskData[b.Id].State + local compareResult = CompareState(stateA, stateB) + if compareResult == 0 then + if pa ~= pb then + return pa > pb + else + return a.Id > b.Id + end + else + return compareResult > 0 + end + end) + return tasks + end + + function XTaskManager.GetCoupletTaskList() + local tasks = {} + for _, v in pairs(CoupletTaskData) do + table.insert(tasks, v) + end + return tasks + end + + function XTaskManager.GetSimulatedCombatTaskList() + local tasks = {} + for _, v in pairs(SimulatedCombatTaskData) do + table.insert(tasks, v) + end + return tasks + end + + + + function XTaskManager.CheckMentorGraduateAllAchieved() + local taskTemplate = XTaskConfig.GetTaskTemplate() + for _, v in pairs(MentorGraduateTaskData) do + if TotalTaskData[v.Id].State < XTaskManager.TaskState.Achieved then + return false + end + end + return true + end + + function XTaskManager.GetMentorWeeklyTaskList() + return GetTaskList(XTaskManager.GetTaskDataByTaskType(XTaskManager.TaskType.MentorShipWeekly)) + end + + function XTaskManager.GetMentorWeeklyFullTaskList() + local taskTemplate = XTaskConfig.GetTaskTemplate() + local tasks = {} + for _, v in pairs(MentorWeeklyTaskData) do + table.insert(tasks, v) + end + tableSort(tasks, function(a, b) + local pa, pb = taskTemplate[a.Id].Priority, taskTemplate[b.Id].Priority + local stateA = TotalTaskData[a.Id].State + local stateB = TotalTaskData[b.Id].State + local compareResult = CompareState(stateA, stateB) + if compareResult == 0 then + if pa ~= pb then + return pa > pb + else + return a.Id > b.Id + end + else + return compareResult > 0 + end + end) + return tasks + end + + -- 包括已完成的任务 + function XTaskManager.GetGuildDailyTaskList() + return GetTaskList(XTaskManager.GetTaskDataByTaskType(XTaskManager.TaskType.GuildDaily)) + end + + function XTaskManager.GetGuildDailyFullTaskList() + local tasks = {} + for _, v in pairs(GuildDailyTaskData) do + table.insert(tasks, v) + end + return tasks + end + + function XTaskManager.GetGuildMainlyTaskList() + return GetTaskList(XTaskManager.GetTaskDataByTaskType(XTaskManager.TaskType.GuildMainly)) + end + + function XTaskManager.GetGuildMainlyFullTaskList() + local tasks = {} + for _, v in pairs(GuildMainlyTaskData) do + table.insert(tasks, v) + end + return tasks + end + + function XTaskManager.GetGuildWeeklyTaskList() + return GetTaskList(XTaskManager.GetTaskDataByTaskType(XTaskManager.TaskType.GuildWeekly)) + end + + function XTaskManager.GetGuildWeeklyFullTaskList() + local tasks = {} + for _, v in pairs(GuildWeeklyTaskData) do + table.insert(tasks, v) + end + return tasks + end + + function XTaskManager.CheckLimitTaskList(taskGroupId) + local tasks = XTaskManager.GetTimeLimitTaskListByGroupId(taskGroupId) + for _, v in pairs(tasks or {}) do + if v.State == XTaskManager.TaskState.Achieved then + return true + end + end + return false + end + + function XTaskManager.GetTimeLimitTaskListByGroupId(taskGroupId) + local taskDatas = {} + + local timeLimitTaskCfg = taskGroupId ~= 0 and XTaskConfig.GetTimeLimitTaskCfg(taskGroupId) + if not timeLimitTaskCfg then return taskDatas end + + if not XTaskConfig.IsTimeLimitTaskInTime(taskGroupId) then + return taskDatas + end + + for _, taskId in ipairs(timeLimitTaskCfg.TaskId) do + local taskData = XDataCenter.TaskManager.GetTaskDataById(taskId) + if CheckTask(taskData) then + tableInsert(taskDatas, taskData) + end + end + for _, taskId in ipairs(timeLimitTaskCfg.DayTaskId) do + local taskData = XDataCenter.TaskManager.GetTaskDataById(taskId) + if CheckTask(taskData) then + tableInsert(taskDatas, taskData) + end + end + for _, taskId in ipairs(timeLimitTaskCfg.WeekTaskId) do + local taskData = XDataCenter.TaskManager.GetTaskDataById(taskId) + if CheckTask(taskData) then + tableInsert(taskDatas, taskData) + end + end + + local achieved = XDataCenter.TaskManager.TaskState.Achieved + local finish = XDataCenter.TaskManager.TaskState.Finish + tableSort(taskDatas, function(a, b) + if a.State ~= b.State then + if a.State == achieved then + return true + end + if b.State == achieved then + return false + end + if a.State == finish then + return false + end + if b.State == finish then + return true + end + end + + local templatesTaskA = XDataCenter.TaskManager.GetTaskTemplate(a.Id) + local templatesTaskB = XDataCenter.TaskManager.GetTaskTemplate(b.Id) + return templatesTaskA.Priority > templatesTaskB.Priority + end) + + return taskDatas + end + + function XTaskManager.GetPokemonTaskList() + return GetTaskList(XTaskManager.GetTaskDataByTaskType(XTaskManager.TaskType.Pokemon)) + end + + function XTaskManager.GetMoeWarDailyTaskList() + return GetTaskList(MoeWarDailyTaskData) + end + + function XTaskManager.GetMoeWarNormalTaskList() + return GetTaskList(MoeWarNormalTaskData) + end + + function XTaskManager.GetPassportTaskList() + return GetTaskList(PassportTaskData) + end + + ---------------- 仅支持使用通用接口的任务类型 -------------- + function XTaskManager.GetTaskList(taskType, groupId) + local tasks = {} + + if TaskDataGroup[taskType] ~= nil then + for _, v in pairs(TaskDataGroup[taskType]) do + if groupId then + local templates = XTaskConfig.GetTaskCfgById(v.Id) + if templates.GroupId ~= groupId then + goto CONTINUE + end + end + table.insert(tasks, v) + ::CONTINUE:: + end + end + return tasks + end + + function XTaskManager.GetTaskProgress(taskType, groupId) + local passCount = 0 + local allCount = 0 + if TaskDataGroup[taskType] ~= nil then + for _, task in pairs(TaskDataGroup[taskType]) do + if groupId then + local templates = XTaskConfig.GetTaskCfgById(task.Id) + if templates.GroupId ~= groupId then + goto CONTINUE + end + end + allCount = allCount + 1 + if task.State == XDataCenter.TaskManager.TaskState.Finish then + passCount = passCount + 1 + end + ::CONTINUE:: + end + end + return passCount, allCount + end + --------------------------------------------------- + + --根据任务类型获得成就任务 + function XTaskManager.GetAchvTaskByAchieveType(achvType) + local achieveTasks = XTaskManager.GetAchvTaskList() + local taskList = {} + for _, var in achieveTasks do + if var.AchvType == achvType then + tableInsert(taskList, var) + end + end + end + + function XTaskManager.GetTaskDataByTaskType(taskType) + local datas = {} + + if taskType == XTaskManager.TaskType.Story then + datas = StoryTaskData + elseif taskType == XTaskManager.TaskType.Daily then + datas = DailyTaskData + elseif taskType == XTaskManager.TaskType.Weekly then + datas = WeeklyTaskData + elseif taskType == XTaskManager.TaskType.Activity then + datas = ActivityTaskData + elseif taskType == XTaskManager.TaskType.NewPlayer then + datas = NewPlayerTaskData + elseif taskType == XTaskManager.TaskType.Achievement then + datas = AchvTaskData + elseif taskType == XTaskManager.TaskType.ArenaChallenge then + datas = ArenaTaskData + elseif taskType == XTaskManager.TaskType.TimeLimit then + datas = TimeLimitTaskData + elseif taskType == XTaskManager.TaskType.DormDaily then + datas = DormDailyTaskData + elseif taskType == XTaskManager.TaskType.DormNormal then + datas = DormNormalTaskData + elseif taskType == XTaskManager.TaskType.BabelTower then + datas = BabelTowerTaskData + elseif taskType == XTaskManager.TaskType.RogueLike then + datas = RogueLikeTaskData + elseif taskType == XTaskManager.TaskType.GuildDaily then + datas = GuildDailyTaskData + elseif taskType == XTaskManager.TaskType.GuildMainly then + datas = GuildMainlyTaskData + elseif taskType == XTaskManager.TaskType.GuildWeekly then + datas = GuildWeeklyTaskData + elseif taskType == XTaskManager.TaskType.ArenaOnlineWeekly then + datas = ArenaOnlineWeeklyTaskData + elseif taskType == XTaskManager.TaskType.InfestorWeekly then + datas = InfestorWeeklyTaskData + elseif taskType == XTaskManager.TaskType.WorldBoss then + datas = WorldBossTaskData + elseif taskType == XTaskManager.TaskType.RpgTower then + datas = RpgTowerTaskData + elseif taskType == XTaskManager.TaskType.WhiteValetine then + datas = WhiteValentineTaskData + elseif taskType == XTaskManager.TaskType.FingerGuessing then + datas = FingerGuessingTaskData + elseif taskType == XTaskManager.TaskType.MentorShipGrow then + datas = MentorGrowTaskData + elseif taskType == XTaskManager.TaskType.MentorShipGraduate then + datas = MentorGraduateTaskData + elseif taskType == XTaskManager.TaskType.MentorShipWeekly then + datas = MentorWeeklyTaskData + elseif taskType == XTaskManager.TaskType.NieR then + datas = NieRTaskData + elseif taskType == XTaskManager.TaskType.Pokemon then + datas = PokemonTaskData + elseif taskType == XTaskManager.TaskType.Couplet then + datas = CoupletTaskData + elseif taskType == XTaskManager.TaskType.SimulatedCombat then + datas = SimulatedCombatTaskData + elseif taskType == XTaskManager.TaskType.MoeWarDaily then + datas = MoeWarDailyTaskData + elseif taskType == XTaskManager.TaskType.MoeWarNormal then + datas = MoeWarNormalTaskData + elseif taskType == XTaskManager.TaskType.PokerGuessing or taskType == XTaskManager.TaskType.PokerGuessingCollection then + datas = PokerGuessingTaskData + elseif taskType == XTaskManager.TaskType.Passport then + datas = PassportTaskData + elseif taskType then + datas = TaskDataGroup[taskType] + end + local result = {} + for k, v in pairs(datas) do + --原: v.State ~= XTaskManager.TaskState.Finish and v.State ~= XTaskManager.TaskState.Invalid + if XTaskConfig.GetTaskTemplate()[v.Id].Type == XTaskManager.TaskType.Achievement and v.State == XTaskManager.TaskState.Finish then + result[k] = v + elseif v.State ~= XTaskManager.TaskState.Finish and v.State ~= XTaskManager.TaskState.Invalid then + result[k] = v + elseif XTaskConfig.GetTaskTemplate()[v.Id].Type == XTaskManager.TaskType.ArenaChallenge and v.State ~= XTaskManager.TaskState.Invalid then + result[k] = v + end + end + return result + end + + function XTaskManager.ResetStoryGroupTaskData() + for _, v in pairs(StoryGroupTaskData) do + v.UnfinishCount = 0 + end + end + + function XTaskManager.GetCurrentStoryTaskGroupId() + XTaskManager.ResetStoryGroupTaskData() + + local headGroupId = 1 + for _, v in pairs(StoryTaskData) do + local templates = XTaskManager.GetTaskTemplate(v.Id) + if templates.GroupId > 0 then + if templates.ShowAfterGroup <= 0 then + headGroupId = templates.GroupId + end + local groupDatas = StoryGroupTaskData[templates.GroupId] + if groupDatas == nil then + StoryGroupTaskData[templates.GroupId] = {} + groupDatas = StoryGroupTaskData[templates.GroupId] + groupDatas.GroupId = templates.GroupId + groupDatas.ShowAfterGroup = templates.ShowAfterGroup + groupDatas.UnfinishCount = 0 + end + + if v.State ~= XTaskManager.TaskState.Finish and v.State ~= XTaskManager.TaskState.Invalid then + groupDatas.UnfinishCount = groupDatas.UnfinishCount + 1 + end + end + end + + for _, groupDatas in pairs(StoryGroupTaskData) do + if groupDatas.ShowAfterGroup > 0 then + StoryGroupTaskData[groupDatas.ShowAfterGroup].NextGroupId = groupDatas.GroupId + end + end + + local currentGoupId = headGroupId + local currentGroupDatas = StoryGroupTaskData[currentGoupId] + while currentGroupDatas and currentGroupDatas.UnfinishCount <= 0 do + currentGoupId = currentGroupDatas.NextGroupId + if currentGoupId == nil then break end + currentGroupDatas = StoryGroupTaskData[currentGoupId] + end + return currentGoupId + end + + function XTaskManager.ResetDormStoryGroupTaskData() + for _, v in pairs(DormStoryGroupTaskData) do + v.UnfinishCount = 0 + end + end + + function XTaskManager.ResetDormDailyGroupTaskData() + for _, v in pairs(DormDailyGroupTaskData) do + v.UnfinishCount = 0 + end + end + + function XTaskManager.GetCurrentDormDailyTaskGroupId() + XTaskManager.ResetDormDailyGroupTaskData() + + local headGroupId = 1 + for _, v in pairs(DormDailyTaskData) do + local templates = XTaskManager.GetTaskTemplate(v.Id) + if templates.GroupId > 0 then + if templates.ShowAfterGroup <= 0 then + headGroupId = templates.GroupId + end + local groupDatas = DormDailyGroupTaskData[templates.GroupId] + if groupDatas == nil then + DormDailyGroupTaskData[templates.GroupId] = {} + groupDatas = DormDailyGroupTaskData[templates.GroupId] + groupDatas.GroupId = templates.GroupId + groupDatas.ShowAfterGroup = templates.ShowAfterGroup + groupDatas.UnfinishCount = 0 + end + + if v.State ~= XTaskManager.TaskState.Finish and v.State ~= XTaskManager.TaskState.Invalid then + groupDatas.UnfinishCount = groupDatas.UnfinishCount + 1 + end + end + end + + for _, groupDatas in pairs(DormDailyGroupTaskData) do + if groupDatas.ShowAfterGroup > 0 then + DormDailyGroupTaskData[groupDatas.ShowAfterGroup].NextGroupId = groupDatas.GroupId + end + end + + local currentGoupId = headGroupId + local currentGroupDatas = DormDailyGroupTaskData[currentGoupId] + while currentGroupDatas and currentGroupDatas.UnfinishCount <= 0 do + currentGoupId = currentGroupDatas.NextGroupId + if currentGoupId == nil then break end + currentGroupDatas = DormDailyGroupTaskData[currentGoupId] + end + return currentGoupId + end + + function XTaskManager.GetCurrentDormStoryTaskGroupId() + XTaskManager.ResetDormStoryGroupTaskData() + + local headGroupId = 1 + for _, v in pairs(DormNormalTaskData) do + local templates = XTaskManager.GetTaskTemplate(v.Id) + if templates.GroupId > 0 then + if templates.ShowAfterGroup <= 0 then + headGroupId = templates.GroupId + end + local groupDatas = DormStoryGroupTaskData[templates.GroupId] + if groupDatas == nil then + DormStoryGroupTaskData[templates.GroupId] = {} + groupDatas = DormStoryGroupTaskData[templates.GroupId] + groupDatas.GroupId = templates.GroupId + groupDatas.ShowAfterGroup = templates.ShowAfterGroup + groupDatas.UnfinishCount = 0 + end + + if v.State ~= XTaskManager.TaskState.Finish and v.State ~= XTaskManager.TaskState.Invalid then + groupDatas.UnfinishCount = groupDatas.UnfinishCount + 1 + end + end + end + + for _, groupDatas in pairs(DormStoryGroupTaskData) do + if groupDatas.ShowAfterGroup > 0 then + DormStoryGroupTaskData[groupDatas.ShowAfterGroup].NextGroupId = groupDatas.GroupId + end + end + + local currentGoupId = headGroupId + local currentGroupDatas = DormStoryGroupTaskData[currentGoupId] + while currentGroupDatas and currentGroupDatas.UnfinishCount <= 0 do + currentGoupId = currentGroupDatas.NextGroupId + if currentGoupId == nil then break end + currentGroupDatas = DormStoryGroupTaskData[currentGoupId] + end + return currentGoupId + end + -- 检查主线剧情任务的红点 + function XTaskManager.CheckStoryTaskByGroup() + -- 只检查当前组和当前没有组id的任务时候可以领取 + local currTaskGroupId = XDataCenter.TaskManager.GetCurrentStoryTaskGroupId() + + for _, taskInfo in pairs(StoryTaskData) do + local templates = XDataCenter.TaskManager.GetTaskTemplate(taskInfo.Id) + -- 分组任务和非组任务 + if templates.GroupId > 0 then + --组任务 + if currTaskGroupId and currTaskGroupId == templates.GroupId then + if taskInfo ~= nil and currTaskGroupId == templates.GroupId and taskInfo.State == XTaskManager.TaskState.Achieved then + return true + end + end + else + --非组任务 + if taskInfo ~= nil and taskInfo.State == XTaskManager.TaskState.Achieved then + return true + end + end + end + return false + end + + + function XTaskManager.GetTaskTemplate(templateId) + local template = XTaskConfig.GetTaskTemplate()[templateId] + if not template then + local path = XTaskConfig.GetTaskPath() + XLog.ErrorTableDataNotFound("XTaskManager.GetTaskTemplate", "template", path, "templateId", tostring(templateId)) + else + return template + end + end + + function XTaskManager.GetShowAfterTaskId(templateId) + local template = XTaskManager.GetTaskTemplate(templateId) + if template then + return template.ShowAfterTaskId + end + end + + function XTaskManager.SyncTasks(data) + if data.TaskLimitIdActiveInfos then + for _, v in pairs(data.TaskLimitIdActiveInfos) do + LinkTaskTimeDict[v.TaskLimitId] = v.ActiveTime + XEventManager.DispatchEvent(XEventId.EVENT_ACTIVITY_INFO_UPDATE) + end + end + local tasks = data.Tasks + XTool.LoopCollection(tasks.Tasks, function(value) + local taskType = XTaskManager.GetTaskTemplate(value.Id).Type + TotalTaskData[value.Id] = value + XAppEventManager.TaskAppLogEvent(value.Id,value.State) + if taskType == XTaskManager.TaskType.Story then + StoryTaskData[value.Id] = value + elseif taskType == XTaskManager.TaskType.Daily then + DailyTaskData[value.Id] = value + elseif taskType == XTaskManager.TaskType.Weekly then + WeeklyTaskData[value.Id] = value + elseif taskType == XTaskManager.TaskType.Activity then + ActivityTaskData[value.Id] = value + elseif taskType == XTaskManager.TaskType.NewPlayer then + NewPlayerTaskData[value.Id] = value + elseif taskType == XTaskManager.TaskType.Achievement then + AchvTaskData[value.Id] = value + elseif taskType == XTaskManager.TaskType.ArenaChallenge then + ArenaTaskData[value.Id] = value + elseif taskType == XTaskManager.TaskType.TimeLimit then + TimeLimitTaskData[value.Id] = value + elseif taskType == XTaskManager.TaskType.DormDaily then + DormDailyTaskData[value.Id] = value + elseif taskType == XTaskManager.TaskType.DormNormal then + DormNormalTaskData[value.Id] = value + elseif taskType == XTaskManager.TaskType.BabelTower then + BabelTowerTaskData[value.Id] = value + elseif taskType == XTaskManager.TaskType.RogueLike then + RogueLikeTaskData[value.Id] = value + elseif taskType == XTaskManager.TaskType.GuildDaily then + GuildDailyTaskData[value.Id] = value + elseif taskType == XTaskManager.TaskType.GuildMainly then + GuildMainlyTaskData[value.Id] = value + elseif taskType == XTaskManager.TaskType.GuildWeekly then + GuildWeeklyTaskData[value.Id] = value + elseif taskType == XTaskManager.TaskType.Regression then + local id = value.Id + local regressionTaskType = XRegressionConfigs.GetTaskTypeById(id) + RegressionTaskData[id] = value + if RegressionTaskCanGetDic[id] then + if value.State ~= XDataCenter.TaskManager.TaskState.Achieved then + RegressionTaskTypeToRedPointCountDic[regressionTaskType] = RegressionTaskTypeToRedPointCountDic[regressionTaskType] - 1 + RegressionTaskRedPointCount = RegressionTaskRedPointCount - 1 + RegressionTaskCanGetDic[id] = nil + end + else + if value.State == XDataCenter.TaskManager.TaskState.Achieved then + RegressionTaskCanGetDic[id] = true + RegressionTaskTypeToRedPointCountDic[regressionTaskType] = RegressionTaskTypeToRedPointCountDic[regressionTaskType] or 0 + RegressionTaskTypeToRedPointCountDic[regressionTaskType] = RegressionTaskTypeToRedPointCountDic[regressionTaskType] + 1 + RegressionTaskRedPointCount = RegressionTaskRedPointCount + 1 + end + end + elseif taskType == XTaskManager.TaskType.ArenaOnlineWeekly then + ArenaOnlineWeeklyTaskData[value.Id] = value + elseif taskType == XTaskManager.TaskType.InfestorWeekly then + InfestorWeeklyTaskData[value.Id] = value + elseif taskType == XTaskManager.TaskType.WorldBoss then + WorldBossTaskData[value.Id] = value + elseif taskType == XTaskManager.TaskType.RpgTower then + RpgTowerTaskData[value.Id] = value + elseif taskType == XTaskManager.TaskType.MentorShipGrow then + MentorGrowTaskData[value.Id] = value + elseif taskType == XTaskManager.TaskType.MentorShipGraduate then + MentorGraduateTaskData[value.Id] = value + elseif taskType == XTaskManager.TaskType.MentorShipWeekly then + MentorWeeklyTaskData[value.Id] = value + elseif taskType == XTaskManager.TaskType.ZhouMu then + ZhouMuTaskData[value.Id] = value + elseif taskType == XTaskManager.TaskType.NieR then + NieRTaskData[value.Id] = value + elseif taskType == XTaskManager.TaskType.Pokemon then + PokemonTaskData[value.Id] = value + elseif taskType == XTaskManager.TaskType.Couplet then + CoupletTaskData[value.Id] = value + elseif taskType == XTaskManager.TaskType.SimulatedCombat then + SimulatedCombatTaskData[value.Id] = value + elseif taskType == XTaskManager.TaskType.WhiteValentine then + WhiteValentineTaskData[value.Id] = value + elseif taskType == XTaskManager.TaskType.FingerGuessing then + FingerGuessingTaskData[value.Id] = value + elseif taskType == XTaskManager.TaskType.MoeWarDaily then + MoeWarDailyTaskData[value.Id] = value + elseif taskType == XTaskManager.TaskType.MoeWarNormal then + MoeWarNormalTaskData[value.Id] = value + elseif taskType == XTaskManager.TaskType.PokerGuessing or taskType == XTaskManager.TaskType.PokerGuessingCollection then + PokerGuessingTaskData[value.Id] = value + elseif taskType == XTaskManager.TaskType.Passport then + PassportTaskData[value.Id] = value + elseif taskType == XTaskManager.TaskType.BossOnLine then + BossOnlineTaskData[value.Id] = value + else + TaskDataGroup[taskType][value.Id] = value + end + end) + XEventManager.DispatchEvent(XEventId.EVENT_TASK_SYNC) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_TASK_SYNC) + end + --根据任务类型判断是否有奖励可以领取 + function XTaskManager.GetIsRewardFor(taskType) + local taskList = nil + if taskType == XTaskManager.TaskType.Story then + taskList = StoryTaskData + elseif taskType == XTaskManager.TaskType.Daily then + taskList = DailyTaskData + elseif taskType == XTaskManager.TaskType.Activity then + taskList = ActivityTaskData + elseif taskType == XTaskManager.TaskType.Achievement then + taskList = AchvTaskData + elseif taskType == XTaskManager.TaskType.ArenaChallenge then + taskList = ArenaTaskData + elseif taskType == XTaskManager.TaskType.TimeLimit then + taskList = TimeLimitTaskData + elseif taskType == XTaskManager.TaskType.DormDaily then + taskList = DormDailyTaskData + elseif taskType == XTaskManager.TaskType.DormNormal then + taskList = DormNormalTaskData + elseif taskType == XTaskManager.TaskType.BabelTower then + taskList = BabelTowerTaskData + elseif taskType == XTaskManager.TaskType.RogueLike then + taskList = RogueLikeTaskData + elseif taskType == XTaskManager.TaskType.GuildDaily then + taskList = GuildDailyTaskData + elseif taskType == XTaskManager.TaskType.GuildMainly then + taskList = GuildMainlyTaskData + elseif taskType == XTaskManager.TaskType.GuildWeekly then + taskList = GuildWeeklyTaskData + elseif taskType == XTaskManager.TaskType.ArenaOnlineWeekly then + taskList = XTaskManager.GetArenaOnlineWeeklyTaskList() + elseif taskType == XTaskManager.TaskType.InfestorWeekly then + taskList = XTaskManager.GetInfestorWeeklyTaskList() + elseif taskType == XTaskManager.TaskType.WorldBoss then + taskList = WorldBossTaskData + elseif taskType == XTaskManager.TaskType.RpgTower then + taskList = RpgTowerTaskData + elseif taskType == XTaskManager.TaskType.MentorShipGrow then + taskList = MentorGrowTaskData + elseif taskType == XTaskManager.TaskType.MentorShipGraduate then + taskList = MentorGraduateTaskData + elseif taskType == XTaskManager.TaskType.MentorShipWeekly then + taskList = MentorWeeklyTaskData + elseif taskType == XTaskManager.TaskType.ZhouMu then + taskList = ZhouMuTaskData + elseif taskType == XTaskManager.TaskType.NieR then + taskList = NieRTaskData + elseif taskType == XTaskManager.TaskType.Pokemon then + taskList = PokemonTaskData + elseif taskType == XTaskManager.TaskType.Couplet then + taskList = CoupletTaskData + elseif taskType == XTaskManager.TaskType.SimulatedCombat then + taskList = SimulatedCombatTaskData + elseif taskType == XTaskManager.TaskType.WhiteValentine then + taskList = WhiteValentineTaskData + elseif taskType == XTaskManager.TaskType.FingerGuessing then + taskList = FingerGuessingTaskData + elseif taskType == XTaskManager.TaskType.MoeWarDaily then + taskList = MoeWarDailyTaskData + elseif taskType == XTaskManager.TaskType.MoeWarNormal then + taskList = MoeWarNormalTaskData + elseif taskType == XTaskManager.TaskType.PokerGuessing or taskType == XTaskManager.TaskType.PokerGuessingCollection then + taskList = PokerGuessingTaskData + elseif taskType == XTaskManager.TaskType.Passport then + taskList = PassportTaskData + else + taskList = TaskDataGroup[taskType] + end + + if taskList == nil then + return false + end + + if taskType == XTaskManager.TaskType.Story then + return XTaskManager.CheckStoryTaskByGroup() + end + + for _, taskInfo in pairs(taskList) do + if taskInfo ~= nil and taskInfo.State == XTaskManager.TaskState.Achieved then + return true + end + end + return false + end + --获取周奖励 + function XTaskManager.GetIsWeekReward() + local activeness = XDataCenter.ItemManager.GetWeeklyActiveness().Count + local rewardIds = XTaskManager.GetWeeklyActivenessRewardIds() + for index = 1, #rewardIds do + if activeness >= rewardIds[index] then + return true + end + end + return false + end + + function XTaskManager.FinishTask(taskId, cb) + cb = cb or function() end + XNetwork.Call("FinishTaskRequest", { TaskId = taskId }, function(reply) + if reply.Code ~= XCode.Success then + XUiManager.TipCode(reply.Code) + XEventManager.DispatchEvent(XEventId.EVENT_TASK_FINISH_FAIL) + --BDC + CS.XHeroBdcAgent.BdcAwardButtonClick(taskId, 2) + return + end + --BDC + CS.XHeroBdcAgent.BdcAwardButtonClick(taskId, 1) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_FINISH_TASK) + XEventManager.DispatchEvent(XEventId.EVENT_FINISH_TASK) + + cb(reply.RewardGoodsList) + + end) + end + + --批量领取任务奖励 + function XTaskManager.FinishMultiTaskRequest(taskIds, cb) + cb = cb or function() end + XNetwork.Call("FinishMultiTaskRequest", { TaskIds = taskIds }, function(reply) + if reply.Code ~= XCode.Success then + XUiManager.TipCode(reply.Code) + XEventManager.DispatchEvent(XEventId.EVENT_TASK_FINISH_FAIL) + return + end + + cb(reply.RewardGoodsList) + end) + end + + --获取历程奖励 + function XTaskManager.GetCourseReward(stageId, cb) + cb = cb or function() end + XNetwork.Call("GetCourseRewardRequest", { StageId = stageId }, function(reply) + if reply.Code ~= XCode.Success then + XUiManager.TipCode(reply.Code) + return + end + + -- 这里顺序不要变 + local allRewardGet = XTaskManager.SetCourseData(stageId) + if cb then cb(allRewardGet) end + + XUiManager.OpenUiObtain(reply.RewardGoodsList) + XEventManager.DispatchEvent(XEventId.EVENT_TASK_COURSE_REWAED) + end) + end + + function XTaskManager.GetActivenessReward(index, rewardId, rewardType, cb) + index = index - 1 -- 客户端从1开始,服务端从0开始 + cb = cb or function() end + XNetwork.Call("GetActivenessRewardRequest", { StageIndex = index, RewardId = rewardId, RewardType = rewardType }, function(reply) + if reply.Code ~= XCode.Success then + XUiManager.TipCode(reply.Code) + return + end + + cb() + + XEventManager.DispatchEvent(XEventId.EVENT_TASK_SYNC) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_TASK_SYNC) + XUiManager.OpenUiObtain(reply.RewardGoodsList) + end, "XTaskService", "GetActivenessReward", index, rewardId, rewardType) + end + + ----NewPlayerTask + function XTaskManager.GetNewPlayerTaskTalkConfig(group) + return XTaskConfig.GetNewPlayerTaskTalkTemplate()[group] + end + + function XTaskManager.GetNewPlayerTaskGroup(group) + return XTaskConfig.GetNewPlayerTaskGroupTemplate()[group] + end + + function XTaskManager.GetNewbiePlayTaskReddotByOpenDay(openDay) + + if XPlayer.NewPlayerTaskActiveDay == nil then + return false + end + + if XPlayer.NewPlayerTaskActiveDay < openDay then + return false + end + + local tasks = XTaskConfig.GetNewPlayerTaskGroupTemplate()[openDay] + if not tasks or not tasks.TaskId then return false end + + for _, id in pairs(tasks.TaskId) do + local stateTask = XTaskManager.GetTaskDataById(id) + if stateTask and stateTask.State == XTaskManager.TaskState.Achieved then + return true + end + end + return false + end + + function XTaskManager.GetNewPlayerTaskListByGroup(group) + local tTaskGroupConfig = XTaskConfig.GetNewPlayerTaskGroupTemplate()[group] + if not tTaskGroupConfig then return end + local tTaskIdList = tTaskGroupConfig.TaskId + if not tTaskIdList then return end + local tCurGroupTaskList = {} + for _, v in ipairs(tTaskIdList) do + local template = XTaskConfig.GetTaskTemplate()[v] + local preId = template and template.ShowAfterTaskId + preId = preId and preId > 0 and preId + local preTask = preId and NewPlayerTaskData[preId] + if not preTask or preTask and preTask.State == XTaskManager.TaskState.Finish then + tableInsert(tCurGroupTaskList, v) + end + end + tableSort(tCurGroupTaskList, function(aId, bId) + local a = NewPlayerTaskData[aId] + local b = NewPlayerTaskData[bId] + local fCallfunc = function(aId2, bId2) + return aId2 < bId2 + end + if a and b then + if a.State ~= b.State then + if a.State == XTaskManager.TaskState.Achieved then + return true + end + if b.State == XTaskManager.TaskState.Achieved then + return false + end + if a.State == XTaskManager.TaskState.Finish or a.State == XTaskManager.TaskState.Invalid then + return false + end + if b.State == XTaskManager.TaskState.Finish or b.State == XTaskManager.TaskState.Invalid then + return true + end + else + return fCallfunc(aId, bId) + end + else + if a and a.State == XTaskManager.TaskState.Finish then + return false + end + if b and b.State == XTaskManager.TaskState.Finish then + return true + end + return fCallfunc(aId, bId) + end + + end) + return tCurGroupTaskList + end + + function XTaskManager.GetNewPlayerGroupTaskStatus(group) + + if XPlayer.NewPlayerTaskActiveDay < group then + return XTaskManager.NewPlayerTaskGroupState.Lock + end + + local tTaskGroupConfig = XTaskConfig.GetNewPlayerTaskGroupTemplate()[group] + if not tTaskGroupConfig then return end + local tTaskIdList = tTaskGroupConfig.TaskId + if not tTaskIdList then return end + local finishCount = 0 + for _, v in ipairs(tTaskIdList) do + local tTaskData = NewPlayerTaskData[v] + if not tTaskData then + return XTaskManager.NewPlayerTaskGroupState.Lock + end + local template = XTaskManager.GetTaskTemplate(tTaskData.Id) + local preId = template and template.ShowAfterTaskId + local preTask = preId == 0 and nil or TotalTaskData[preId] + + if preTask then + if preTask.State == XTaskManager.TaskState.Finish and tTaskData.State == XTaskManager.TaskState.Achieved then + return XTaskManager.NewPlayerTaskGroupState.HasAward + end + elseif FinishedTasks[preId] then + return XTaskManager.NewPlayerTaskGroupState.HasAward + end + + if not preTask and tTaskData.State == XTaskManager.TaskState.Achieved then + return XTaskManager.NewPlayerTaskGroupState.HasAward + end + + if tTaskData.State == XTaskManager.TaskState.Finish then + finishCount = finishCount + 1 + end + end + + if finishCount == #tTaskIdList then + return XTaskManager.NewPlayerTaskGroupState.AllFinish + end + + return XTaskManager.NewPlayerTaskGroupState.AllTodo + end + + function XTaskManager.FindNewPlayerTaskTalkContent(group) + local config = XTaskConfig.GetNewPlayerTaskTalkTemplate()[group] + if not config then + return + end + local tTaskGroupConfig = XTaskConfig.GetNewPlayerTaskGroupTemplate()[group] + if not tTaskGroupConfig then return end + local tTaskIdList = tTaskGroupConfig.TaskId + if not tTaskIdList then return end + local finishCount = 0 + for _, v in ipairs(tTaskIdList) do + local tTaskData = NewPlayerTaskData[v] + if tTaskData and tTaskData.State == XTaskManager.TaskState.Finish then + finishCount = finishCount + 1 + end + end + + local index = 1 + for i, v in ipairs(config.GetCount) do + if finishCount >= v then + index = i + end + end + return config.TalkContent[index], config + end + + function XTaskManager.SetNewPlayerTaskActiveUi(group) + XNetwork.Call("SetNewPlayerTaskActiveUiRequest", { Group = group }, function(reply) + if reply.Code ~= XCode.Success then + XUiManager.TipCode(reply.Code) + return + end + XPlayer.SetNewPlayerTaskActiveUi(reply.Result) + end) + end + + function XTaskManager.CheckTaskFinished(taskId) + local taskData = XTaskManager.GetTaskDataById(taskId) + return taskData and taskData.State == XTaskManager.TaskState.Finish + end + + function XTaskManager.CheckTaskAchieved(taskId) + local taskData = XTaskManager.GetTaskDataById(taskId) + return taskData and taskData.State == XTaskManager.TaskState.Achieved + end + + function XTaskManager.GetFinalChapterId() + for k, v in pairs(CourseInfos or {}) do + if v.NextChapterId == nil then + return k + end + end + return nil + end + + function XTaskManager.CheckNewbieActivenessAvailable() + local currentCount = XDataCenter.ItemManager.GetCount(ITEM_NEWBIE_PROGRESS_ID) + for _, v in pairs(XTaskConfig.GetTaskNewbieActivenessTemplate().Activeness or {}) do + if not XTaskManager.CheckNewbieActivenessRecord(v) and currentCount >= v then + return true + end + end + return false + end + + function XTaskManager.CheckNewbieTaskAvailable() + if not XFunctionManager.JudgeOpen(XFunctionManager.FunctionName.Target) then + return false + end + + if XTaskManager.CheckNewbieActivenessAvailable() then + return true + end + + for _, groupDatas in pairs(XTaskConfig.GetNewPlayerTaskGroupTemplate() or {}) do + for _, taskId in pairs(groupDatas.TaskId or {}) do + local stateTask = XTaskManager.GetTaskDataById(taskId) + if stateTask and stateTask.State ~= XTaskManager.TaskState.Finish and stateTask.State ~= XTaskManager.TaskState.Invalid then + return true + end + end + end + return false + end + + function XTaskManager.CheckNewbieActivenessRecord(activenessId) + for _, record in pairs(NewbieActivenessRecord or {}) do + if activenessId == record then + return true + end + end + return false + end + + function XTaskManager.UpdateNewbieActivenessRecord(activenessId) + for _, record in pairs(NewbieActivenessRecord or {}) do + if activenessId == record then + return + end + end + NewbieActivenessRecord[#NewbieActivenessRecord + 1] = activenessId + end + + function XTaskManager.GetStoryTaskShowId() + local groupId = XTaskManager.GetCurrentStoryTaskGroupId() + if groupId == nil or groupId <= 0 then + return 0 + end + -- 有没有主题任务。 + local maxPriority = 0 + local currentTask = 0 + for _, v in pairs(StoryTaskData) do + local templates = XTaskManager.GetTaskTemplate(v.Id) + if templates.GroupId == groupId and templates.ShowType == 1 then + if v.State ~= XTaskManager.TaskState.Finish and v.State ~= XTaskManager.TaskState.Invalid then + if templates.Priority >= maxPriority then + maxPriority = templates.Priority + currentTask = v.Id + end + end + end + end + return currentTask + end + + function XTaskManager.SaveNewPlayerHint(key, value) + if XPlayer.Id then + key = string.format("%s_%s", tostring(XPlayer.Id), key) + CS.UnityEngine.PlayerPrefs.SetInt(key, value) + CS.UnityEngine.PlayerPrefs.Save() + end + end + + function XTaskManager.GetNewPlayerHint(key, defaultValue) + if XPlayer.Id then + key = string.format("%s_%s", tostring(XPlayer.Id), key) + if CS.UnityEngine.PlayerPrefs.HasKey(key) then + local newPlayerHint = CS.UnityEngine.PlayerPrefs.GetInt(key) + return (newPlayerHint == nil or newPlayerHint == 0) and defaultValue or newPlayerHint + end + end + return defaultValue + end + + function XTaskManager.GetNewPlayerRewardReq(activeness, rewardList, cb) + XNetwork.Call("GetNewPlayerRewardRequest", { Activeness = activeness }, function(response) + cb = cb or function() end + if response.Code == XCode.Success then + XUiManager.OpenUiObtain(rewardList, CS.XTextManager.GetText("DailyActiveRewardTitle")) + XTaskManager.UpdateNewbieActivenessRecord(activeness) + cb() + XEventManager.DispatchEvent(XEventId.EVENT_NEWBIETASK_PROGRESSCHANGED) + else + XUiManager.TipCode(response.Code) + end + end) + end + + function XTaskManager.GetDormTaskDailyListData() + return XTaskManager.SortDormDailyTaskByGroup(XTaskManager.GetDormDailyTaskList()) or {} + end + + function XTaskManager.GetDormTaskStoryListData() + return XTaskManager.SortDormStoryTaskByGroup(XTaskManager.GetDormNormalTaskList()) or {} + end + + function XTaskManager.SortDormStoryTaskByGroup(tasks) + local currTaskGroupId = XDataCenter.TaskManager.GetCurrentDormStoryTaskGroupId() + if currTaskGroupId == nil or currTaskGroupId <= 0 then return tasks end + return XTaskManager.SortDormTask(tasks, currTaskGroupId) + end + + function XTaskManager.SortDormDailyTaskByGroup(tasks) + local currTaskGroupId = XDataCenter.TaskManager.GetCurrentDormDailyTaskGroupId() + if currTaskGroupId == nil or currTaskGroupId <= 0 then return tasks end + return XTaskManager.SortDormTask(tasks, currTaskGroupId) + end + + function XTaskManager.SortDormTask(tasks, currTaskGroupId) + local sortedTasks = {} + -- 过滤,留下组id相同,没有组id的任务 + for _, v in pairs(tasks) do + local templates = XDataCenter.TaskManager.GetTaskTemplate(v.Id) + if templates.GroupId <= 0 or templates.GroupId == currTaskGroupId then + + v.SortWeight = 1 + v.SortWeight = (templates.GroupId > 0) and 2 or v.SortWeight + v.SortWeight = (v.State == XDataCenter.TaskManager.TaskState.Achieved) and 3 or v.SortWeight + v.SortWeight = (templates.GroupTheme == 1) and 4 or v.SortWeight + v.GroupTheme = templates.GroupTheme + tableInsert(sortedTasks, v) + end + end + + -- 排序,主题任务,可领取的任务,不能领取的任务 + tableSort(sortedTasks, function(taskA, taskB) + local templatesTaskA = XDataCenter.TaskManager.GetTaskTemplate(taskA.Id) + local templatesTaskB = XDataCenter.TaskManager.GetTaskTemplate(taskB.Id) + if taskA.SortWeight == taskB.SortWeight then + return templatesTaskA.Priority > templatesTaskB.Priority + end + return taskA.SortWeight > taskB.SortWeight + end) + + return sortedTasks + end + + --宿舍主界面,任务提示。(可领奖励或未完成的) + function XTaskManager.GetDormTaskTips() + local storytasks = XTaskManager.GetDormTaskStoryListData() + local taskguideids = XDormConfig.GetDormitoryGuideTaskCfg() + if _G.next(storytasks) then + for _, data in pairs(storytasks) do + if data.State == XTaskManager.TaskState.Achieved and taskguideids[data.Id] then + return data, XTaskManager.TaskType.DormNormal, XTaskManager.TaskState.Achieved + end + end + end + + if _G.next(storytasks) then + for _, data in pairs(storytasks) do + if data.State ~= XTaskManager.TaskState.Achieved and data.State ~= XTaskManager.TaskState.Finish and taskguideids[data.Id] and data.GroupTheme ~= 1 then + return data, XTaskManager.TaskType.DormNormal, XTaskManager.TaskState.Standby + end + end + end + + local dailytasks = XTaskManager.GetDormDailyTaskList() or {} + if _G.next(dailytasks) then + for _, data in pairs(dailytasks) do + if data.State == XTaskManager.TaskState.Achieved then + return data, XTaskManager.TaskType.DormDaily, XTaskManager.TaskState.Achieved + end + end + end + + if _G.next(dailytasks) then + for _, data in pairs(dailytasks) do + if data.State ~= XTaskManager.TaskState.Achieved and data.State ~= XTaskManager.TaskState.Finish then + return data, XTaskManager.TaskType.DormDaily, XTaskManager.TaskState.Standby + end + end + end + end + + -- 获取每周任务刷新时间 + function XTaskManager.GetWeeklyTaskRefreshTime() + return WeekTaskRefreshDay, WeekTaskEpochTime + end + + -- 检查任务是否特定时间刷新(每日/每周) + function XTaskManager.CheckTaskRefreshable(taskId) + local config = XTaskManager.GetTaskTemplate(taskId) + if not config then return false end + + + local taskType = config.Type + if taskType == XTaskManager.TaskType.Daily then + return true + end + + if taskType == XTaskManager.TaskType.Weekly then + return true + end + + if taskType == XTaskManager.TaskType.TimeLimit then + return XTaskConfig.GetTimeLimitWeeklyTasksCheckTable()[taskId] + end + + return false + end + --============ + --获取兵法蓝图玩法是否有未领取奖励的任务 + --============ + function XTaskManager.GetRpgTowerHaveAchievedTask() + local haveTask = false + for _, task in pairs(RpgTowerTaskData) do + if task.State == XTaskManager.TaskState.Achieved then + haveTask = true + break + end + end + return haveTask + end + --============ + --获取白色情人节玩法是否有未领取奖励的任务 + --============ + function XTaskManager.GetWhiteValentineHaveAchievedTask() + local haveTask = false + for _, task in pairs(WhiteValentineTaskData) do + if task.State == XTaskManager.TaskState.Achieved then + haveTask = true + break + end + end + return haveTask + end + --============ + --获取猜拳玩法是否有未领取奖励的任务 + --============ + function XTaskManager.GetFingerGuessingHaveAchievedTask() + local haveTask = false + for _, task in pairs(FingerGuessingTaskData) do + if task.State == XTaskManager.TaskState.Achieved then + haveTask = true + break + end + end + return haveTask + end + --============ + --获取猜拳玩法已完成任务和任务总数 + --============ + function XTaskManager.GetFingerGuessingTaskNum() + local total = 0 + local achived = 0 + for _, task in pairs(FingerGuessingTaskData) do + total = total + 1 + if task.State == XTaskManager.TaskState.Achieved or task.State == XTaskManager.TaskState.Finish then + achived = achived + 1 + end + end + return achived, total + end + -- 判断累积消费活动是否有未领取奖励任务 + XTaskManager.ConsumeRewardTaskIds = {[39301] = 39301, [39302] = 39302, [39303] = 39303, [39304] = 39304, [39305] = 39305, [39306] = 39306, [39307] = 39307 } -- 累消任务ID + function XTaskManager.CheckConsumeTaskHaveReward() + local haveReward = false + for _, task in pairs(TimeLimitTaskData) do + if XTaskManager.ConsumeRewardTaskIds[task.Id] and task.State == XTaskManager.TaskState.Achieved then + haveReward = true + break + end + end + return haveReward + end + + --回归活动任务相关------------------------------------------------------------------------>>> + function XTaskManager.GetRegressionTaskRedPointCount() + return RegressionTaskRedPointCount + end + + function XTaskManager.GetRegressionTaskTypeToRedPointCount(type) + return RegressionTaskTypeToRedPointCountDic[type] or 0 + end + + --获取链接公告任务开启的时间戳 + function XTaskManager.GetLinkTimeTaskOpenTime(id) + return LinkTaskTimeDict[id] + end + + function XTaskManager.GetRegressionTaskByType(type) + local activityId = XDataCenter.RegressionManager.GetTaskActivityId() + if not XTool.IsNumberValid(activityId) then + return + end + local groupId = XRegressionConfigs.GetTaskGroupIdByActivityId(activityId) + local taskIdList = XRegressionConfigs.GetTaskIdListByIdAndType(groupId, type) + local taskList + if taskIdList then + taskList = {} + local oneTaskData + for _, id in ipairs(taskIdList) do + oneTaskData = RegressionTaskData[id] + if oneTaskData then + tableInsert(taskList, oneTaskData) + end + end + return GetTaskList(taskList) + end + end + --获取协同合作任务列表,包括已经完成的任务 + function XTaskManager.GetBossOnlineTaskListData() + local task = {} + + for _, v in pairs(BossOnlineTaskData) do + tableInsert(task, v) + end + + return task + end + XTaskManager.Init() + return XTaskManager +end + + +XRpc.NotifyTask = function(data) + XDataCenter.TaskManager.SyncTasks(data) +end + +XRpc.NotifyTaskData = function(data) + XDataCenter.TaskManager.InitTaskData(data.TaskData) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XTeamManager.lua b/Resources/Scripts/XManager/XTeamManager.lua new file mode 100644 index 00000000..116a6990 --- /dev/null +++ b/Resources/Scripts/XManager/XTeamManager.lua @@ -0,0 +1,492 @@ +XTeamManagerCreator = function() + local XTeamManager = {} + + local TeamDataKey = "STAGE_TEAM_DATA_" + + local MaxPos = CS.XGame.Config:GetInt("TeamMaxPos") -- 默认一个队伍的位置数 + local CaptainPos -- 队长位 + local FirstFightPos -- 首发位 + local EmptyTeam = { + TeamData = {}, + CaptainPos = 1, + FirstFightPos = 1, + -- 0表示仅保存在本地 + TeamId = 0, + } + + local PlayerTeamGroupData = {} + local PlayerTeamPrefabData = {} + + local METHOD_NAME = { + SetTeam = "TeamSetTeamRequest", + } + + --SetTeamPos + function XTeamManager.Init() + CaptainPos = 0 + FirstFightPos = 0 + for _, cfg in pairs(XTeamConfig.GetTeamCfg()) do + if cfg.IsCaptain and CaptainPos == 0 then + CaptainPos = cfg.Id + end + + if cfg.IsFirstFight and FirstFightPos == 0 then + FirstFightPos = cfg.Id + end + end + + for i = 1, MaxPos do + EmptyTeam.TeamData[i] = 0 + end + EmptyTeam = XReadOnlyTable.Create(EmptyTeam) + XTeamManager.EmptyTeam = EmptyTeam + end + + function XTeamManager.GetTeamId(typeId, stageId) + local teams = XTeamConfig.GetTeamsByTypeId(typeId) + if teams == nil then + return nil + end + + local sectionId = 0 + local chapterId = 0 + if stageId ~= nil then + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + sectionId = stageInfo.SectionId + chapterId = stageInfo.ChpaterId + if sectionId == nil or chapterId == nil then + return nil + end + end + + -- 匹配规则:chapterId, sectionId, stageId 逐级查找,某一项为 nil 时,表示匹配上一级 + for _, val in pairs(teams) do + if #val.ChapterId <= 0 then + return val.TeamId -- 匹配 TypeId + end + + for _, cId in pairs(val.ChapterId) do + if chapterId > 0 and cId == chapterId then + if #val.SectionId <= 0 then + return val.TeamId -- 匹配 chapterId + end + + for _, sId in pairs(val.SectionId) do + if sectionId > 0 and sId == sectionId then + if #val.StageId <= 0 then + return val.TeamId -- 匹配 sectionId + end + + for _, stId in pairs(val.StageId) do + if stId == stageId then + return val.TeamId -- 匹配 stageId + end + end + end + end + end + end + end + + return nil + end + + -- 玩家队伍中队长的位置Id + function XTeamManager.GetTeamCaptainKey(teamId) + return teamId << 8 + end + + function XTeamManager.GetValidPos(teamData) + local posId = 1 + for k, v in pairs(teamData) do + if v > 0 then + posId = k + break + end + end + return posId + end + + local function GetTeamKey(stageId) + local info = XDataCenter.FubenManager.GetStageInfo(stageId) + return string.format("%s%s_%d_%s", TeamDataKey, tostring(XPlayer.Id), info.Type, tostring(stageId)) + end + + -- 使用stageId作为Key本地保存编队信息 + function XTeamManager.SaveTeamLocal(curTeam, stageId) + if not stageId then + XLog.Warning("stageId is nil !!") + return + end + XSaveTool.SaveData(GetTeamKey(stageId), curTeam) + end + + -- 使用stageId作为Key读取本地编队信息 + function XTeamManager.LoadTeamLocal(stageId) + if not stageId then + XLog.Warning("stageId is nil") + return EmptyTeam + end + + local team = XSaveTool.GetData(GetTeamKey(stageId)) or EmptyTeam + for _, v in ipairs(team.TeamData) do + if v ~= 0 and not XRobotManager.CheckIsRobotId(v) and not XDataCenter.CharacterManager.IsOwnCharacter(v) then + return EmptyTeam + end + end + + return team + end + + -- 使用TeamSetTeamRequest协议保存使用TeamId的XTeamData + function XTeamManager.SetPlayerTeam(curTeam, isPrefab, cb) + local curTeamId = curTeam.TeamId + if curTeamId == 0 then + XTeamManager.SetPlayerTeamLocal(curTeam, isPrefab, cb) + return + end + + local params = {} + params.TeamData = {} + params.TeamId = curTeamId + XMessagePack.MarkAsTable(params.TeamData) + for k, v in pairs(curTeam.TeamData) do + params.TeamData[k] = v + end + params.CaptainPos = curTeam.CaptainPos + params.FirstFightPos = curTeam.FirstFightPos + params.TeamName = curTeam.TeamName + + local req = { TeamData = params, IsPrefab = isPrefab } + XNetwork.Call(METHOD_NAME.SetTeam, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XTeamManager.SetPlayerTeamLocal(curTeam, isPrefab, cb) + end) + end + + -- 更新TeamId的数据缓存,服务器的XTeamData只在登录的时候下发 + function XTeamManager.SetPlayerTeamLocal(curTeam, isPrefab, cb) + local curTeamId = curTeam.TeamId + local characterCheckTable = {} + + local changeCharacter = {} -- 更改成员的Id数组 + local playCvCharacterInfo = {} -- 要播放语音的角色信息 + playCvCharacterInfo.Id = 0 + playCvCharacterInfo.IsCaptain = false + + -- 更改成员数,数量等于1,播放该角色的入队语音,数量大于等于2,只播放队长语音,没有队长就不播放语音 + local changeCount = 0 + + local playerTeamData = isPrefab and PlayerTeamPrefabData or PlayerTeamGroupData + -- 更新客户端队伍缓存 + if playerTeamData[curTeamId] == nil then + playerTeamData[curTeamId] = {} + else + for _, characterId in pairs(playerTeamData[curTeamId].TeamData) do + characterCheckTable[characterId] = true + end + + for pos, characterId in pairs(curTeam.TeamData) do + if (not characterCheckTable[characterId]) and (characterId ~= 0) then + + changeCount = changeCount + 1 + if pos == curTeam.CaptainPos then + playCvCharacterInfo.Id = characterId + playCvCharacterInfo.IsCaptain = true + break + end + + table.insert(changeCharacter, characterId) + end + end + + -- 更改角色不是队长,但只更改了一个角色,播放该角色的入队语音 + if playCvCharacterInfo.Id == 0 and changeCount == 1 then + playCvCharacterInfo.Id = changeCharacter[1] + end + + XEventManager.DispatchEvent(XEventId.EVENT_TEAM_MEMBER_CHANGE, curTeamId, playCvCharacterInfo.Id, playCvCharacterInfo.IsCaptain) + end + playerTeamData[curTeamId].TeamId = curTeamId + playerTeamData[curTeamId].CaptainPos = curTeam.CaptainPos + playerTeamData[curTeamId].FirstFightPos = curTeam.FirstFightPos + playerTeamData[curTeamId].TeamData = curTeam.TeamData + playerTeamData[curTeamId].TeamName = curTeam.TeamName + if cb then cb() end + + XEventManager.DispatchEvent(XEventId.EVENT_TEAM_PREFAB_CHANGE, curTeamId, playerTeamData[curTeamId]) + end + + function XTeamManager.SetExpeditionTeamData(curTeam, cb) + local curTeamId = curTeam.TeamId + local params = {} + params.TeamData = {} + params.TeamId = curTeamId + XMessagePack.MarkAsTable(params.TeamData) + for k, v in pairs(curTeam.TeamData) do + params.TeamData[k] = v + end + params.CaptainPos = curTeam.CaptainPos + params.FirstFightPos = curTeam.FirstFightPos + local req = { TeamData = params, IsPrefab = false } + XNetwork.Call(METHOD_NAME.SetTeam, req, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + local characterCheckTable = {} + local playerTeamData = PlayerTeamGroupData + -- 更新客户端队伍缓存 + if playerTeamData[curTeamId] == nil then + playerTeamData[curTeamId] = {} + else + for _, baseId in pairs(playerTeamData[curTeamId].TeamData) do + characterCheckTable[baseId] = true + end + + for pos, baseId in pairs(curTeam.TeamData) do + if not characterCheckTable[baseId] then + local charId = XExpeditionConfig.GetCharacterIdByBaseId(baseId) + XEventManager.DispatchEvent(XEventId.EVENT_TEAM_MEMBER_CHANGE, curTeamId, charId, pos == curTeam.CaptainPos) + end + end + end + playerTeamData[curTeamId].TeamId = curTeamId + playerTeamData[curTeamId].CaptainPos = curTeam.CaptainPos + playerTeamData[curTeamId].FirstFightPos = curTeam.FirstFightPos + playerTeamData[curTeamId].TeamData = curTeam.TeamData + playerTeamData[curTeamId].TeamName = curTeam.TeamName + + if cb then cb() end + + XEventManager.DispatchEvent(XEventId.EVENT_TEAM_PREFAB_CHANGE, curTeamId, playerTeamData[curTeamId]) + end) + end + + function XTeamManager.GetPlayerTeamData(teamId) + return PlayerTeamGroupData[teamId] or false + end + + function XTeamManager.GetTeamData(teamId) + if not XTeamConfig.GetTeamTypeCfg(teamId) and teamId ~= 0 then + XLog.Error("XTeamManager.GetTeamCaptainPos, 缺少TeamTypeCfg,teamId = ", tostring(teamId)) + return + end + + local teamData = nil + if PlayerTeamGroupData[teamId] ~= nil then + teamData = PlayerTeamGroupData[teamId].TeamData + end + + if teamData == nil or next(teamData) == nil then + teamData = {} + for i = 1, MaxPos do + teamData[i] = 0 + end + end + return teamData + end + + function XTeamManager.GetTeamCaptainPos(teamId) + if not XTeamConfig.GetTeamTypeCfg(teamId) and teamId ~= 0 then + XLog.Error("XTeamManager.GetTeamCaptainPos, 缺少TeamTypeCfg,teamId = ", tostring(teamId)) + return + end + + local captainPos = XTeamManager.GetCaptainPos() + if PlayerTeamGroupData[teamId] ~= nil then + captainPos = PlayerTeamGroupData[teamId].CaptainPos + end + return captainPos + end + + ---========================================== + --- 根据'teamId'得到当前的首发位置,中间是1,左边是2,右边是3 + --- 若第一次进入玩法,没有设置相应的'teamId‘数据,则初始位置为1 + ---@param teamId number + ---@return number + ---========================================== + function XTeamManager.GetTeamFirstFightPos(teamId) + if not XTeamConfig.GetTeamTypeCfg(teamId) and teamId ~= 0 then + XLog.Error("XTeamManager.GetTeamFirstFightPos, 缺少TeamTypeCfg,teamId = ", tostring(teamId)) + return + end + + -- 初始位置为1 + local posId = 1 + + -- 是否设置过该teamId数据 + if PlayerTeamGroupData[teamId] ~= nil then + posId = PlayerTeamGroupData[teamId].FirstFightPos + end + return posId + end + + function XTeamManager.GetTeamCaptainId(teamId) + if not XTeamConfig.GetTeamTypeCfg(teamId) and teamId ~= 0 then + XLog.Error("XTeamManager.GetTeamCaptainId, 缺少TeamTypeCfg,teamId = ", tostring(teamId)) + return + end + + if PlayerTeamGroupData[teamId] == nil then + return nil + end + + local captainPos = PlayerTeamGroupData[teamId].CaptainPos + return PlayerTeamGroupData[teamId].TeamData[captainPos] + end + + ---========================================== + --- 根据'teamId'得到当前的首发位的角色Id + ---@param teamId number + ---@return number + ---========================================== + function XTeamManager.GetTeamFirstFightId(teamId) + if not XTeamConfig.GetTeamTypeCfg(teamId) and teamId ~= 0 then + XLog.Error("XTeamManager.GetTeamFirstFightId, 缺少TeamTypeCfg,teamId = ", tostring(teamId)) + return + end + + if PlayerTeamGroupData[teamId] == nil then + return nil + end + + local firstFightPos = PlayerTeamGroupData[teamId].FirstFightPos + return PlayerTeamGroupData[teamId].TeamData[firstFightPos] + end + + -- 得到对应玩法的TeamId与Team数据 + function XTeamManager.GetPlayerTeam(typeId, stageId) + local curTeamId = XTeamManager.GetTeamId(typeId, stageId) + if curTeamId == nil then + XLog.ErrorTableDataNotFound("XTeamManager.GetPlayerTeam", "curTeamId", + TABLE_PATH, "typeId : stageId :", tostring(typeId) .. tostring(stageId)) + return nil + end + + local CurTeam = { + ["TeamId"] = curTeamId, + ["TeamData"] = XTeamManager.GetTeamData(curTeamId), + ["CaptainPos"] = XTeamManager.GetTeamCaptainPos(curTeamId), + ["FirstFightPos"] = XTeamManager.GetTeamFirstFightPos(curTeamId), + } + return CurTeam + end + + function XTeamManager.CheckInTeam(characterId) + local typeId = CS.XGame.Config:GetInt("TypeIdMainLine") + local curTeamId = XTeamManager.GetTeamId(typeId) + if curTeamId == nil then + XLog.ErrorTableDataNotFound("XTeamManager.CheckInTeam", "curTeamId", TABLE_PATH, "typeId : stageId :", tostring(typeId)) + return nil + end + + local teamData = XTeamManager.GetTeamData(curTeamId) + for _, v in pairs(teamData) do + if characterId == v then + return true + end + end + return false + end + + function XTeamManager.GetInTeamCheckTable() + local inTeamCheckTable = {} + + local typeId = CS.XGame.Config:GetInt("TypeIdMainLine") + local curTeamId = XTeamManager.GetTeamId(typeId) + local teamData = XTeamManager.GetTeamData(curTeamId) + for _, v in pairs(teamData) do + if v > 0 then + inTeamCheckTable[v] = true + end + end + + return inTeamCheckTable + end + + -- 在NotifyLogin中获取队伍数据 + function XTeamManager.InitTeamGroupData(teamGroupData) + if teamGroupData == nil then + return + end + + for key, value in pairs(teamGroupData) do + local teamTemp = {} + for teamDataKey, teamDataValue in pairs(value.TeamData) do + teamTemp[teamDataKey] = teamDataValue + end + + PlayerTeamGroupData[key] = {} + PlayerTeamGroupData[key].TeamId = value.TeamId + PlayerTeamGroupData[key].CaptainPos = value.CaptainPos + PlayerTeamGroupData[key].FirstFightPos = value.FirstFightPos + PlayerTeamGroupData[key].TeamData = teamTemp + end + end + + + -- 在NotifyLogin中获取预编译队伍 + function XTeamManager.InitTeamPrefabData(teamPrefabData) + if teamPrefabData == nil then + return + end + + for key, value in pairs(teamPrefabData) do + local teamTemp = {} + for teamDataKey, teamDataValue in pairs(value.TeamData) do + teamTemp[teamDataKey] = teamDataValue + end + + PlayerTeamPrefabData[key] = {} + PlayerTeamPrefabData[key].TeamId = value.TeamId + PlayerTeamPrefabData[key].CaptainPos = value.CaptainPos + PlayerTeamPrefabData[key].FirstFightPos = value.FirstFightPos + PlayerTeamPrefabData[key].TeamData = teamTemp + PlayerTeamPrefabData[key].TeamName = value.TeamName + end + end + + + + function XTeamManager.GetCaptainPos() + return CaptainPos + end + + function XTeamManager.GetFirstFightPos() + return FirstFightPos + end + + function XTeamManager.GetMaxPos() + return MaxPos + end + + function XTeamManager.GetTeamMemberColor(id) + local colorStr = XTeamConfig.GetTeamCfgById(id).Color + local color = XUiHelper.Hexcolor2Color(colorStr) + return color + end + + function XTeamManager.GetTeamPrefabData() + return PlayerTeamPrefabData + end + + function XTeamManager.ResetTeamData(teamId) + local teamInfos = XTeamManager.GetPlayerTeamData(teamId) + if not teamInfos then return end + teamInfos.CaptainPos = 1 + for index in pairs(teamInfos.TeamData) do + teamInfos.TeamData[index] = 0 + end + end + + XTeamManager.Init() + return XTeamManager +end + +XRpc.NotifyTeamClear = function(data) + XDataCenter.TeamManager.ResetTeamData(data.TeamId) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XTipManager.lua b/Resources/Scripts/XManager/XTipManager.lua new file mode 100644 index 00000000..ad6ff4b9 --- /dev/null +++ b/Resources/Scripts/XManager/XTipManager.lua @@ -0,0 +1,90 @@ +XTipManager = XTipManager or {} + +--local TABLE_TIP = "Client/Tip/Tip.tab" +--local TeamTipCfg = {} +-- +-- +function XTipManager.Init() +-- TeamTipCfg = XTableManager.ReadByIntKey(TABLE_TIP, XTable.XTableTip, "Id") +end +-- +----==============================-- +----desc: 获取提示信息 +----@id: 提示表 Id +----@return: 1.是否显示提示 +----@return: 2.提示描述 +----==============================-- +--function XTipManager.GetTipInfo(id) +-- local isShow = false +-- local deesc = "" +-- if TeamTipCfg[id] then +-- local key = tostring(XPlayer.Id) .. id +-- if not CS.UnityEngine.PlayerPrefs.HasKey(key) then +-- isShow = true +-- deesc = TeamTipCfg[id].Description +-- end +-- end +-- return isShow, deesc +--end +-- +----==============================-- +----desc: 永久取消提示 +----@id: 提示表 Id +----==============================-- +--function XTipManager.DeleteTip(id) +-- if TeamTipCfg[id] then +-- local key = tostring(XPlayer.Id) .. id +-- if not CS.UnityEngine.PlayerPrefs.HasKey(key) then +-- CS.UnityEngine.PlayerPrefs.SetString(key, key) +-- CS.UnityEngine.PlayerPrefs.Save() +-- end +-- end +--end + +--===========================================================================================-- +local State = { + Standby = 1, + Suspend = 2, + Playing = 3 +} +local state = State.Standby +local first +local last + +function XTipManager.Add(tip) + if not first then + first = { + cb = tip, + next = nil + } + last = first + else + local next = { + cb = tip, + next = nil + } + last.next = next + last = next + end + + if state == State.Standby then + XTipManager.Execute() + end +end + +function XTipManager.Execute() + if first then + local cb = first.cb + first = first.next + state = State.Playing + cb() + else + state = State.Standby + end +end + +function XTipManager.Suspend() + if state == State.Standby then + state = State.Suspend + end +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XTrialManager.lua b/Resources/Scripts/XManager/XTrialManager.lua new file mode 100644 index 00000000..74e0f71c --- /dev/null +++ b/Resources/Scripts/XManager/XTrialManager.lua @@ -0,0 +1,473 @@ +XTrialManagerCreator = function() + local XTrialManager = {} + local TrialInfos = nil + local PreFinishTrial = {} + local IsTrialChanllenge = false + + XTrialManager.TrialTypeCfg = { + TrialFor = 1, + TrialBackEnd = 2 + } + --关卡打开,玩家点过后红点消失。 + XTrialManager.UnLockRed = false + -- Rpc请求 + -- 领取关卡奖励 + function XTrialManager.OnTrialPassRewardRequest(trialId, cb) + if not trialId then + return + end + XTrialManager.TrialRewardId = trialId + XNetwork.Call( + "TrialPassRewardRequest", + { TrialId = trialId }, + function(res) + cb = cb or function() + end + + if res.Code == XCode.Success then + if not TrialInfos then + TrialInfos = {} + TrialInfos.rewardRecord = {} + end + TrialInfos.rewardRecord[trialId] = trialId + local rewardGoodsList = res.RewardGoodsList + cb(rewardGoodsList) + else + XUiManager.TipCode(res.Code) + end + end + ) + end + + -- 领取类型奖励 + function XTrialManager.OnTrialTypeRewardRequest(trialType, cb) + if not trialType then + return + end + + XNetwork.Call( + "TrialTypeRewardRequest", + { Type = trialType }, + function(res) + cb = cb or function() + end + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + if not TrialInfos then + TrialInfos = {} + TrialInfos.typeRewardRecord = {} + end + + TrialInfos.typeRewardRecord[trialType] = trialType + local rewardGoodsList = res.RewardGoodsList + cb(rewardGoodsList) + end + ) + end + + -- 通知更新角色信息 + function XTrialManager.OnTrialInfoUpdate(response) + if response then --有通关 + TrialInfos = {} + TrialInfos.finishTrial = response.FinishTrial + TrialInfos.rewardRecord = {} + XTool.LoopMap(response.RewardRecord, function(_, v) + TrialInfos.rewardRecord[v] = v + end) + TrialInfos.typeRewardRecord = response.TypeRewardRecord + PreFinishTrial = TrialInfos.finishTrial + else + TrialInfos = nil + end + end + + -- 判断当前完成到前段还是后段关卡,前段返回1,后段返回2。 + function XTrialManager.FinishTrialType() + if (not TrialInfos) or (not TrialInfos.finishTrial) then + return XDataCenter.TrialManager.TrialTypeCfg.TrialFor + end + + local finishtrial = TrialInfos.finishTrial + local forcfgdata = XTrialConfigs.GetForTotalData(XDataCenter.TrialManager.TrialTypeCfg.TrialFor) + for _, v in pairs(forcfgdata) do + if finishtrial[v.Id] ~= v.Id then --没有在里面,前段没有完成。 + return XDataCenter.TrialManager.TrialTypeCfg.TrialFor + end + end + + return XDataCenter.TrialManager.TrialTypeCfg.TrialBackEnd + end + + -- 判断当前关卡是否已经领取了奖励,levelId-->TrialChallenge表Id,false:没有 true:领了 + function XTrialManager.TrialRewardGeted(trialId) + if (not TrialInfos) or (not TrialInfos.rewardRecord) then + return false + end + + local rewardRecord = TrialInfos.rewardRecord + return rewardRecord[trialId] == trialId + end + + -- 判断当前关卡是否完成,trialId-->TrialChallenge表Id,false:没有 true:过了 + function XTrialManager.TrialLevelFinished(trialId) + if (not TrialInfos) or (not TrialInfos.finishTrial) then + return false + end + + local finishtrial = TrialInfos.finishTrial + return finishtrial[trialId] == trialId + end + + -- 判断类型奖励是否领过。false:没有 true:领过(总) + function XTrialManager.TypeRewardGeted() + return TrialInfos and TrialInfos.typeRewardRecord + end + + -- 判断当前类型奖励是否已经领了。false:没有 true:领过 + function XTrialManager.TypeRewardByTrialtype(trialtype) + if not XTrialManager.TypeRewardGeted() then + return false + end + + local typeRewardRecord = TrialInfos.typeRewardRecord + return typeRewardRecord[trialtype] == trialtype + end + + -- 判断当前关卡是否是否解锁,trialId-->TrialChallenge表Id,false:没有解锁,true:解锁 + function XTrialManager.TrialLevelLock(trialId) + local trialcfg = XTrialConfigs.GetForDataByLevel(trialId) or + XTrialConfigs.GetBackEndDataByLevel(trialId - XTrialConfigs.GetForTotalLength()) + + local level = XPlayer.Level or 0 + if not trialcfg or trialcfg.Unlocklevel > level then + return false + end + + return trialcfg.PreId == 0 or XDataCenter.TrialManager.TrialLevelFinished(trialcfg.PreId) + end + + -- 打过关卡 + function XTrialManager.OnSettleTrial() + local res = XDataCenter.FubenManager.FubenSettleResult + if not res or not res.Settle then + return + end + + local settle = res.Settle + local isWin = settle.IsWin and res.Code == 0 + if not isWin then + return + end + + local StageId = settle.StageId + local forcfgdata = XTrialConfigs.GetForTotalData() + for _, v in pairs(forcfgdata) do + if v.StageId == StageId then + XDataCenter.TrialManager.TrialLevelPassState(v.Id) + end + end + + local backendcfgdata = XTrialConfigs.GetBackEndTotalData() + for _, v in pairs(backendcfgdata) do + if v.StageId == StageId then + XDataCenter.TrialManager.TrialLevelPassState(v.Id) + end + end + end + -- 关卡通关改状态,trialId-->TrialChallenge表Id,stageId-->关卡Id + function XTrialManager.TrialLevelPassState(trialId, stageId) + if not TrialInfos then + TrialInfos = {} + TrialInfos.finishTrial = {} + end + + XDataCenter.TrialManager.SetTrialFinishJustState(true) + TrialInfos.finishTrial[trialId] = trialId + XEventManager.DispatchEvent(XEventId.EVENT_TRIAL_LEVEL_FINISH, stageId) + end + + -- 判断前段是否刚好完成 + function XTrialManager.ForTrialFinishJust() + if XDataCenter.TrialManager.FinishTrialType() ~= XDataCenter.TrialManager.TrialTypeCfg.TrialBackEnd then + return false + end + + return XTrialConfigs.GetForTotalLength() == #TrialInfos.finishTrial --刚好完成前段 + end + + -- 判断后段是否刚好完成 + function XTrialManager.BackEndTrialFinishJust() + if XDataCenter.TrialManager.FinishTrialType() ~= XDataCenter.TrialManager.TrialTypeCfg.TrialBackEnd then + return false + end + + local cfg = XTrialConfigs.GetBackEndTotalData() + for _, v in pairs(cfg) do + if not TrialInfos.finishTrial[v.Id] then + return false + end + end + + return true + end + + -- 是否刚通关 + function XTrialManager.IsTrialFinishJust() + return IsTrialChanllenge + end + + -- 设置是否刚通关 + function XTrialManager.SetTrialFinishJustState(state) + IsTrialChanllenge = state + end + + -- 判断是否要打开入口 true:打开 false:关闭 + --条件-->所有关卡打过&&奖励都领完。 + function XTrialManager.EntranceOpen() + -- 判断类型奖励 + for _, v in pairs(XDataCenter.TrialManager.TrialTypeCfg) do + if not XDataCenter.TrialManager.TypeRewardByTrialtype(v) and XDataCenter.TrialManager.TrialTypeRewardGeted(v) then + return true + end + end + + -- 判断关卡是否通过而且奖励是否已经领取 + local cfg = XTrialConfigs.GetForTotalData() + for _, v in pairs(cfg) do + if not XDataCenter.TrialManager.TrialLevelFinished(v.Id) or not XDataCenter.TrialManager.TrialRewardGeted(v.Id) then + return true + end + end + + cfg = XTrialConfigs.GetBackEndTotalData() + for _, v in pairs(cfg) do + if not XDataCenter.TrialManager.TrialLevelFinished(v.Id) or not XDataCenter.TrialManager.TrialRewardGeted(v.Id) then + return true + end + end + return false + end + + -- 红点相关 + -- 判断该关卡奖励是否可领,trialId-->TrialChallenge表Id + function XTrialManager.TrialLevelRewardGetSignRedPoint(trialId) + if XDataCenter.TrialManager.TrialLevelFinished(trialId) and not XDataCenter.TrialManager.TrialRewardGeted(trialId) then + return true + end + return false + end + + -- 判断该关卡是否刚刚解锁,trialId-->TrialChallenge表Id。关卡打完,角色等级变化都需要判断一下。 + function XTrialManager.TrialLevelLockSignRedPoint() + local playerLevel = XPlayer.Level or 1 + -- 通关的时候 + local finishTrial = TrialInfos.finishTrial + local trialId = -1 + for _, v in pairs(finishTrial) do + if not PreFinishTrial[v] then + trialId = v + PreFinishTrial[v] = trialId + end + end + + if not XDataCenter.TrialManager.PreLevel or XDataCenter.TrialManager.PreLevel < playerLevel then + XDataCenter.TrialManager.PreLevel = playerLevel + XDataCenter.TrialManager.UnLockRed = false + end + + if XDataCenter.TrialManager.UnLockRed then + return false + end + + if trialId ~= -1 then + local cfg = XTrialConfigs.GetForDataByLevel(trialId) or XTrialConfigs.GetBackEndDataByLevel(trialId - XTrialConfigs.GetForTotalLength()) + if cfg and cfg.Unlocklevel <= playerLevel then + return true + end + end + + -- 等级 + local finishTrial2 = TrialInfos.finishTrial + local cfg = XTrialConfigs.GetForTotalData() + if XDataCenter.TrialManager.FinishTrialType() == XDataCenter.TrialManager.TrialTypeCfg.TrialBackEnd then + cfg = XTrialConfigs.GetBackEndTotalData() + end + + for _, v in pairs(cfg) do + if not finishTrial2[v.Id] then + if v.Unlocklevel <= playerLevel then + return true + end + end + end + + return false + end + + --判断类型奖励是否可领 + function XTrialManager.TrialTypeRewardRedPoint() + for _, v in pairs(XDataCenter.TrialManager.TrialTypeCfg) do + if XDataCenter.TrialManager.TypeRewardByTrialtype(v) and not XDataCenter.TrialManager.TrialTypeRewardGeted(v) then + return true + end + end + + return false + end + + -- 前段打到第几关 + function XTrialManager.TrialForFinishLevel() + local cfg = XTrialConfigs.GetForTotalData() + + for _, v in pairs(cfg) do + if v then + if not XDataCenter.TrialManager.TrialLevelFinished(v.Id) then + return v.Id - 1 + end + end + end + + return XTrialConfigs.GetForTotalLength() + end + + -- 后段打到第几关 + function XTrialManager.TrialBackEndFinishLevel() + local cfg = XTrialConfigs.GetBackEndTotalData() + + for _, v in pairs(cfg) do + if v then + if not XDataCenter.TrialManager.TrialLevelFinished(v.Id) then + return v.Id - XTrialConfigs.GetForTotalLength() - 1 + end + end + end + + return XTrialConfigs.GetBackEndTotalLength() + end + + -- 是否所有关卡打完 + function XTrialManager.IsAllLevelFinish() + local cfg = XTrialConfigs.GetForTotalData() or {} + + for _, v in pairs(cfg) do + if v then + if not XDataCenter.TrialManager.TrialLevelFinished(v.Id) then + return false + end + end + end + + cfg = XTrialConfigs.GetBackEndTotalData() or {} + + for _, v in pairs(cfg) do + if v then + if not XDataCenter.TrialManager.TrialLevelFinished(v.Id) then + return false + end + end + end + + return true + end + -- 前段奖励是否领完 + function XTrialManager.TrialRewardGetedFinish() + local cfg = XTrialConfigs.GetForTotalData() + + for _, v in pairs(cfg) do + if v then + if not XDataCenter.TrialManager.TrialRewardGeted(v.Id) then + return false + end + end + end + + return true + end + + -- 后段奖励是否领完 + function XTrialManager.TrialRewardGetedBackEndFinish() + local cfg = XTrialConfigs.GetBackEndTotalData() + + for _, v in pairs(cfg) do + if v then + if not XDataCenter.TrialManager.TrialRewardGeted(v.Id) then + return false + end + end + end + + return true + end + + -- 判断前段奖励领取是不是最后一关 + function XTrialManager.TrialRewardIdIsForEnd() + local cfg = XTrialConfigs.GetForTotalData() + + if not XTrialManager.TrialRewardId or not cfg or not cfg[#cfg] or XTrialManager.TrialRewardId ~= cfg[#cfg].Id then + return false + end + return true + end + + -- 前段奖励领了多少 + function XTrialManager.TrialRewardGetedForCount() + local cfg = XTrialConfigs.GetForTotalData() + local count = 0 + + for _, v in pairs(cfg) do + if v then + if XDataCenter.TrialManager.TrialRewardGeted(v.Id) then + count = count + 1 + end + end + end + + return count + end + + -- 后段奖励领了多少 + function XTrialManager.TrialRewardGetedBackEndCount() + local cfg = XTrialConfigs.GetBackEndTotalData() + local count = 0 + + for _, v in pairs(cfg) do + if v then + if XDataCenter.TrialManager.TrialRewardGeted(v.Id) then + count = count + 1 + end + end + end + + return count + end + -- 关卡奖励领取完判断 + function XTrialManager.TrialTypeRewardGeted(trialtype) + if trialtype == XDataCenter.TrialManager.TrialTypeCfg.TrialFor then + return XDataCenter.TrialManager.TrialRewardGetedFinish() + end + + return XDataCenter.TrialManager.TrialRewardGetedBackEndFinish() + end + XEventManager.AddEventListener(XEventId.EVENT_FUBEN_SETTLE_REWARD, XTrialManager.OnSettleTrial, XTrialManager) + + function XTrialManager.InitStageInfo() + local forcfgdata = XTrialConfigs.GetForTotalData(XDataCenter.TrialManager.TrialTypeCfg.TrialFor) + for _, v in pairs(forcfgdata) do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(v.StageId) + stageInfo.Type = XDataCenter.FubenManager.StageType.Trial + end + end + + return XTrialManager +end + +-- 记录玩家---完成的关卡、奖励记录、类型奖励记录 +-- 完成的关卡-->对应TrialChallenge表的id +-- 奖励记录-->对应TrialTypeReward表的id +-- 类型奖励记录-->1:前段,2:后段。 +XRpc.NotifyTrialData = function(response) + XDataCenter.TrialManager.OnTrialInfoUpdate(response) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XTypeManager.lua b/Resources/Scripts/XManager/XTypeManager.lua new file mode 100644 index 00000000..975c539a --- /dev/null +++ b/Resources/Scripts/XManager/XTypeManager.lua @@ -0,0 +1,51 @@ +XTypeManager = XTypeManager or {} + +local GetNameFuncs = {} +local GetQualityFuncs = {} + +----Initialize---- +function XTypeManager.Init() + GetNameFuncs[XArrangeConfigs.Types.Character] = XCharacterConfigs.GetCharacterName + GetNameFuncs[XArrangeConfigs.Types.Weapon] = XDataCenter.EquipManager.GetEquipName + GetNameFuncs[XArrangeConfigs.Types.Wafer] = XDataCenter.EquipManager.GetEquipName + GetNameFuncs[XArrangeConfigs.Types.Item] = XDataCenter.ItemManager.GetItemName + GetNameFuncs[XArrangeConfigs.Types.Fashion] = XDataCenter.FashionManager.GetFashionName + GetNameFuncs[XArrangeConfigs.Types.Furniture] = XFurnitureConfigs.GetFurnitureNameById + GetNameFuncs[XArrangeConfigs.Types.HeadPortrait] = XDataCenter.HeadPortraitManager.GetHeadPortraitNameById + GetNameFuncs[XArrangeConfigs.Types.ChatEmoji] = XDataCenter.ChatManager.GetEmojiName + GetNameFuncs[XArrangeConfigs.Types.WeaponFashion] = XWeaponFashionConfigs.GetFashionName + GetNameFuncs[XArrangeConfigs.Types.Collection] = XMedalConfigs.GetCollectionNameById + GetNameFuncs[XArrangeConfigs.Types.Partner] = XPartnerConfigs.GetPartnerTemplateName + + GetQualityFuncs[XArrangeConfigs.Types.Character] = XCharacterConfigs.GetCharMinQuality + GetQualityFuncs[XArrangeConfigs.Types.Weapon] = XDataCenter.EquipManager.GetEquipQuality + GetQualityFuncs[XArrangeConfigs.Types.Wafer] = XDataCenter.EquipManager.GetEquipQuality + GetQualityFuncs[XArrangeConfigs.Types.Item] = XDataCenter.ItemManager.GetItemQuality + GetQualityFuncs[XArrangeConfigs.Types.Fashion] = XDataCenter.FashionManager.GetFashionQuality + GetQualityFuncs[XArrangeConfigs.Types.Furniture] = XDataCenter.FurnitureManager.GetRewardFurnitureQuality + GetQualityFuncs[XArrangeConfigs.Types.HeadPortrait] = XDataCenter.HeadPortraitManager.GetHeadPortraitQualityById + GetQualityFuncs[XArrangeConfigs.Types.DormCharacter] = XDormConfig.GetDormCharacterRewardQualityById + GetQualityFuncs[XArrangeConfigs.Types.ChatEmoji] = XDataCenter.ChatManager.GetEmojiQuality + GetQualityFuncs[XArrangeConfigs.Types.WeaponFashion] = XWeaponFashionConfigs.GetFashionQuality + GetQualityFuncs[XArrangeConfigs.Types.Collection] = XMedalConfigs.GetCollectionDefaultQualityById + GetQualityFuncs[XArrangeConfigs.Types.Partner] = XPartnerConfigs.GetPartnerTemplateQuality +end + +----Public Methods---- +local GetTypeById = function(id) + return XArrangeConfigs.GetType(id) +end + +local GetNameById = function(id) + local type = GetTypeById(id) + return GetNameFuncs[type](id) +end + +local GetQualityById = function(id) + local type = GetTypeById(id) + return GetQualityFuncs[type](id) +end + +XTypeManager.GetTypeById = GetTypeById --(id) +XTypeManager.GetQualityById = GetQualityById --(id) +XTypeManager.GetNameById = GetNameById --(id) \ No newline at end of file diff --git a/Resources/Scripts/XManager/XUiManager.lua b/Resources/Scripts/XManager/XUiManager.lua new file mode 100644 index 00000000..2c929c1e --- /dev/null +++ b/Resources/Scripts/XManager/XUiManager.lua @@ -0,0 +1,350 @@ +local tableUnpack = table.unpack + +XUi = XClass(nil, "XUi") + +function XUi:Ctor(name, ui) + self.Name = name + self.CsUi = ui + self.Transform = ui.Transform + self.GameObject = ui.GameObject + self.UiAnimation = ui.UiAnimation +end + +function XUi:OnOpen() +end + +function XUi:OnClose() +end + +function XUi:OnShow() +end + +function XUi:OnHide() +end + +function XUi:SetUiSprite(image, name, callBack) + if not XTool.UObjIsNil(self.CsUi) then + self.CsUi:SetUiSprite(image, name, callBack) + end +end + +local TipMsgQueue --重复弹条提示队列 +local ClearMsgEvent +local CurrentTipState -- 弹条状态 + +local TipState = { + IDLE = 1, + SHOWING = 2, + LOCK = 3 +} + +XUiManager = XUiManager or {} + +function XUiManager.Init() + CurrentTipState = TipState.IDLE + TipMsgQueue = XQueue.New() + XUiManager.IsHideFunc = CS.XRemoteConfig.IsHideFunc +end + +local ClassTable = {} +local ClassObj = {} + +function XUiManager.Register(name, super) + super = super or XUi + --CS.XUiManager.Register(name) + local class = XClass(super, name) + ClassTable[name] = class + return class +end + +function XUiManager.FindClassType(name) + for k, v in pairs(ClassObj) do + if k == name then + return v + end + end + return nil +end + +function XUiManager.RemoveClassType(name) + for k, _ in pairs(ClassObj) do + if k == name then + ClassObj[k] = nil + end + end +end + +function XUiManager.New(name, ui) + local baseName = name + local class = ClassTable[baseName] + if not class then + baseName = string.match(baseName, '%w*[^(%d)$*]') -- 解析包含数字后缀的界面 + class = ClassTable[baseName] + if not class then + XLog.Error("XUiManager.New error, class not exist, name: " .. name) + return nil + end + end + local obj = class.New(name, ui) + ClassObj[name] = obj + return obj +end + +--XUiManager.XUiEvent = { +-- Show = 1, +-- Hide = 2, +-- Open = 3, +-- Close = 4, +--} + +XUiManager.UiTipType = { + Tip = 1, + Wrong = 2, + Success = 3, +} + +XUiManager.DialogType = { + Normal = "Normal", + OnlyClose = "OnlyClose", + OnlySure = "OnlySure", + NoBtn = "NoBtn", + NormalAndNoBtnTanchuangClose = "NormalAndNoBtnTanchuangClose", +} + +XUiManager.IsHideFunc = false + +function XUiManager.ClearTipMsgQueue() + CurrentTipState = TipState.IDLE + TipMsgQueue:Clear() +end + +function XUiManager.TipMsgEnqueue(msg, type, cb, hideCloseMark) + if CurrentTipState == TipState.IDLE then + XUiManager.TipMsg(msg, type, cb, hideCloseMark) + else + local msgData = { msg, type, cb, hideCloseMark } + TipMsgQueue:Enqueue(msgData) + ClearMsgEvent = ClearMsgEvent or XEventManager.AddEventListener(XEventId.EVENT_MAINUI_ENABLE, XUiManager.ClearTipMsgQueue) + end +end + +function XUiManager.TipMsgDequeue() + if CurrentTipState == TipState.SHOWING then return end + local msgData = TipMsgQueue:Dequeue() + if msgData then + XUiManager.TipMsg(tableUnpack(msgData)) + else + XEventManager.RemoveEventListener(XEventId.EVENT_MAINUI_ENABLE, XUiManager.ClearTipMsgQueue) + ClearMsgEvent = nil + end +end + +function XUiManager.TipMsg(msg, type, cb, hideCloseMark) + if not msg then + XLog.Error("XUiManager.TipMsg error, msg is nil") + return + end + + if not type then + type = XUiManager.UiTipType.Tip + end + if CurrentTipState == TipState.SHOWING then return end + CurrentTipState = TipState.SHOWING + CS.XAudioManager.PlaySound(XSoundManager.UiBasicsMusic.Tip_small) + local callback = function() + if cb then cb() end + CurrentTipState = TipState.IDLE + XUiManager.TipMsgDequeue() + end + --CS.XUiManager.TipsManager:Push("UiTipLayer", true, true, msg, type) + XLuaUiManager.Open("UiTipLayer", msg, type, callback, hideCloseMark) +end + +function XUiManager.TipText(key, type, isEnqueue) + if not type then + type = XUiManager.UiTipType.Wrong + end + local text = CS.XTextManager.GetText(key) + if isEnqueue then + XUiManager.TipMsgEnqueue(text, type) + else + XUiManager.TipMsg(text, type) + end +end + +function XUiManager.TipSuccess(msg, hideCloseMark) + XUiManager.TipMsg(msg, XUiManager.UiTipType.Success, nil, hideCloseMark) +end + +function XUiManager.TipError(msg) + XUiManager.TipMsg(msg, XUiManager.UiTipType.Wrong) +end + +function XUiManager.TipCode(code, ...) + local text = CS.XTextManager.GetCodeText(code, ...) + if code == XCode.Success then + XUiManager.TipSuccess(text) + else + XUiManager.TipError(text) + end +end + +function XUiManager.DialogTip(title, content, dialogType, closeCallback, sureCallback, extraData) + if not title and not content then + XLog.Error("XUiManager.DialogTip error, title and content is nil") + return + end + + dialogType = dialogType or XUiManager.DialogType.Normal + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_UIDIALOG_VIEW_ENABLE) + + CS.XAudioManager.PlaySound(XSoundManager.UiBasicsMusic.Tip_Big) + + --CS.XUiManager.DialogManager:Push("UiDialog", true, true, title, content, dialogType, closeCallback, sureCallback) + CsXUiManager.Instance:Open("UiDialog", title, content, dialogType, closeCallback, sureCallback, extraData) +end + +function XUiManager.DialogDragTip(title, content, dialogType, closeCallback, sureCallback, extraData) + if not title and not content then + XLog.Error("XUiManager.DialogTip error, title and content is nil") + return + end + + dialogType = dialogType or XUiManager.DialogType.Normal + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_UIDIALOG_VIEW_ENABLE) + + CS.XAudioManager.PlaySound(XSoundManager.UiBasicsMusic.Tip_Big) + + CsXUiManager.Instance:Open("UiDialogDrag", title, content, dialogType, closeCallback, sureCallback, extraData) +end + +--带今日内不再提示选项的提示框 +function XUiManager.DialogHintTip(title, content, content2, closeCallback, sureCallback, hintInfo) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_UIDIALOG_VIEW_ENABLE) + CS.XAudioManager.PlaySound(XSoundManager.UiBasicsMusic.Tip_Big) + XLuaUiManager.Open("UiCueMark", title, content, content2, closeCallback, sureCallback, hintInfo) +end + +--弹出系统提示 +function XUiManager.SystemDialogTip(title, content, dialogType, closeCallback, sureCallback) + if not title or not content then + XLog.Error("XUiManager.SystemDialogTip error, title or content is nil") + return + end + + if not XUiManager.DialogType[dialogType] then + XLog.Error("XUiManager.SystemDialogTip error, dialogType is error") + return + end + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_UIDIALOG_VIEW_ENABLE) + + CS.XAudioManager.PlaySound(XSoundManager.UiBasicsMusic.Tip_Big) + + CsXUiManager.Instance:Open("UiSystemDialog", title, content, dialogType, closeCallback, sureCallback) +end + +-- 显示帮助界面 +-- Param:cb 关闭帮助界面时执行的回调 +function XUiManager.ShowHelpTip(helpDataKey, cb) + local config = XHelpCourseConfig.GetHelpCourseTemplateByFunction(helpDataKey) + if not config then + return + end + + if config.IsShowCourse == 1 then + XLuaUiManager.Open("UiHelp", config, cb) + else + XUiManager.UiFubenDialogTip(config.Name, config.Describe) + end +end + +function XUiManager.ShowHelpTipNew(getHelpDataFunc, cb) + if not getHelpDataFunc then + XLog.Error("XUiManager.ShowHelpTipNew Error: GetHelpDataFunc is Nil") + return + end + + local helpData = getHelpDataFunc() + if not helpData or not next(helpData) then + return + end + + XLuaUiManager.Open("UiHelpNew", helpData, cb) +end + +function XUiManager.UiFubenDialogTip(title, content, closeCallback, sureCallback) + if not title or not content then + XLog.Error("XUiManager.UiFubenDialog error, title or content is nil") + return + end + + CS.XAudioManager.PlaySound(1100) + XLuaUiManager.Open("UiFubenDialog", title, content, closeCallback, sureCallback) +end + +function XUiManager.OpenBuyAssetPanel(id, successCallback) + XDataCenter.ItemManager.SelectBuyAssetType(id, successCallback, nil, nil) +end + +function XUiManager.OpenUiObtain(data, title, closeCallback, sureCallback) + XLuaUiManager.Open("UiObtain", data, title, closeCallback, sureCallback) +end + +function XUiManager.OpenUiTipReward(data, title, closeCallback, sureCallback) + XLuaUiManager.Open("UiTipReward", data, title, closeCallback, sureCallback) +end + +function XUiManager.OpenUiTipRewardByRewardId(id, title, closeCallback, sureCallback) + local data = XRewardManager.GetRewardList(id) + if not data then return end + XLuaUiManager.Open("UiTipReward", data, title, closeCallback, sureCallback) +end + +function XUiManager.WhenUiLoaded(cb) + CS.XUiManager.WhenUiLoaded(cb) +end + +function XUiManager.LoadUiWithCb(name, root, cb, cache, ...) + cache = cache and true or false + local result = CS.XUiManager.Load(name, root, cb, cache, ...) + return result +end + +function XUiManager.PushLoadUiWithCb(name, root, cb, cache, ...) + cache = cache and true or false + return CS.XUiManager.PushLoad(name, root, cb, cache, ...) +end + +function XUiManager.OpenMainUi() + local guideFight = XDataCenter.GuideManager.GetNextGuideFight() + if guideFight then + XLuaUiManager.Close("UiGuide") + XDataCenter.FubenManager.EnterGuideFight(guideFight.Id, guideFight.StageId, guideFight.NpcId, guideFight.Weapon) + else + XLuaUiManager.RunMain() + end +end + +function XUiManager.CheckTopUi(type, name) + local ui = CsXUiManager.Instance:GetTopUi(type) + return ui.UiData.UiName == name +end + +function XUiManager.OpenPopWebview(url, title) + --如果是PC正常使用URL跳转,手机平台才用WEB VIEW打开 + if CS.UnityEngine.Application.platform == CS.UnityEngine.RuntimePlatform.WindowsEditor or + CS.UnityEngine.Application.platform == CS.UnityEngine.RuntimePlatform.WindowsPlayer then + CS.UnityEngine.Application.OpenURL(url) + else + XLuaUiManager.Open("UiLoginNotice", { + HtmlUrl = url, + Title = title and XUiHelper.RichTextToTextString(title) or CS.XTextManager.GetText("Agreement"), + isFullUrl = true + }) + end +end + +XUiManager.Init() \ No newline at end of file diff --git a/Resources/Scripts/XManager/XUiPcManager.lua b/Resources/Scripts/XManager/XUiPcManager.lua new file mode 100644 index 00000000..dff07e7d --- /dev/null +++ b/Resources/Scripts/XManager/XUiPcManager.lua @@ -0,0 +1,156 @@ +XUiPcManagerCreator = function() + ---@class XUiPcManager + local XUiPcManager = {} + + XUiPcManager.Init = function() + -- if not XUiPcManager.IsPc() then + -- return + -- end + -- CsXGameEventManager.Instance:RegisterEvent( + -- CS.XEventId.EVENT_UI_AWAKE, + -- function(evt, ui) + -- XUiPcManager.OnUiSceneLoaded(ui) + -- end + -- ) + end + + XUiPcManager.OnEscBtnClick = function() + -- 它自己 + if XLuaUiManager.IsUiShow("UiSystemDialog") then + XLuaUiManager.Close("UiSystemDialog") + return + end + + if XLuaUiManager.IsUiShow("UiGuide") then + XUiPcManager.ExitGame() + return; + end + + -- -- cg + -- if XLuaUiManager.IsUiShow("UiFightVideoPlayer") then + -- return + -- end + + -- 战斗中 + if CS.XFight.IsRunning then + if CS.XFight.Instance.HideCloseButton then + return + end + if XLuaUiManager.IsUiShow("UiSet") then + XUiPcManager.ExitGame(); + return + end + XLuaUiManager.Open("UiSet", true) + return + end + -- -- 剧情 + -- if XLuaUiManager.IsUiShow("UiMovie") then + -- return + -- end + + -- -- loading 界面 + -- if XLuaUiManager.IsUiShow("UiLoading") then + -- return + -- end + -- -- loading 界面 边界公约 + -- if XLuaUiManager.IsUiShow("UiAssignInfo") then + -- return + -- end + --退出游戏 + + XUiPcManager.ExitGame() + end + + XUiPcManager.ExitGame = function() + local title = CS.XTextManager.GetText("TipTitle") + local content = CS.XTextManager.GetText("GameExitMsg") + local confirmCb = function() + CS.XDriver.Exit() + end + -- 会关闭公告, 尝试不发此事件 + -- CsXGameEventManager.Instance:Notify(XEventId.EVENT_UIDIALOG_VIEW_ENABLE) + CS.XAudioManager.PlaySound(XSoundManager.UiBasicsMusic.Tip_Big) + XLuaUiManager.Open("UiSystemDialog", title, content, XUiManager.DialogType.Normal, nil, confirmCb) + -- XLuaUiManager.Open("UiDialogExitGame", title, content, XUiManager.DialogType.Normal, nil, confirmCb) + end + + XUiPcManager.IsPc = function() + return true + --if true then + -- return true + --end + -- 除了windows都不开 + -- local platform = CS.UnityEngine.Application.platform + -- if platform ~= CS.UnityEngine.RuntimePlatform.WindowsEditor + -- and platform ~= CS.UnityEngine.RuntimePlatform.WindowsPlayer + -- then + -- return false + -- end + -- if CS.XCustomUi.PCSetEnable then + -- return true + -- end + -- return false + end + + -- 设备分辨率,非游戏分辨率 + local _DeviceScreenResolution = false + XUiPcManager.GetDeviceScreenResolution = function() + if not _DeviceScreenResolution then + local resolutions = CS.UnityEngine.Screen.resolutions + local maxResolution = 0 + local maxIndex = 1 + for i = 1, resolutions.Length - 1 do + local resolution = resolutions[i] + local product = resolution.width * resolution.height + if product > maxResolution then + maxResolution = product + maxIndex = i + end + end + local resolution = resolutions[maxIndex] + _DeviceScreenResolution = { + Width = resolution.width, + Height = resolution.height + } + end + return _DeviceScreenResolution.Width, _DeviceScreenResolution.Height + end + + XUiPcManager.GetTabUiPcResolution = function() + local config = XUiPcConfig.GetTabUiPcResolution() + local deviceWidth, deviceHeight = XUiPcManager.GetDeviceScreenResolution() + local result = {} + for i, size in pairs(config) do + if size.y <= (deviceHeight - 50) + and size.x <= deviceWidth + then + result[#result + 1] = size + end + end + return result + end + + XUiPcManager.OnUiSceneLoaded = function(ui) + local ui = ui[0] + local uiName = ui.UiData.UiName + -- local prefabPath = ui.UiData.PrefabUrl + local replaceDataArray = XUiPcConfig.GetTabUiPcReplace(uiName) + if #replaceDataArray > 0 then + local root = ui.GameObject.transform + for i = 1, #replaceDataArray do + local replaceData = replaceDataArray[i] + local buttonTransform = root:Find(replaceData.ButtonPath) + if buttonTransform then + if not buttonTransform:GetComponent('XUiPcControl') then + local uiPcControl = buttonTransform.gameObject:AddComponent(typeof(CS.XUiPc.XUiPcControl)) + uiPcControl:SetReferenceDataEx(replaceData.PrefabPath, replaceData.PrefabGuid) + XLog.Debug('自动添加了组件Pc ui:' .. replaceData.ButtonPath) + end + end + end + end + end + + XUiPcManager.Init() + return XUiPcManager +end diff --git a/Resources/Scripts/XManager/XUploadLogManager.lua b/Resources/Scripts/XManager/XUploadLogManager.lua new file mode 100644 index 00000000..f9ae0a4e --- /dev/null +++ b/Resources/Scripts/XManager/XUploadLogManager.lua @@ -0,0 +1,75 @@ +-- 错误信息收集和日志文件上传 +XUploadLogManagerCreator = function() + local XUploadLogManager = {} + + local MASK_UPLOAD_LOG = "UploadLog" + + local ErrorUrl = "" + local LogUrl = "" + local NeedUploadError = false + local NeedUploadLog = false + local FullLogId -- 用于后台生成文件名 + local UPLOAD_LOG_DAY = 1 -- 规定上传多少天内日志 + + function XUploadLogManager.Init() + XUploadLogManager.InitConfig() + XUploadLogManager.InitErrorUploader() + XEventManager.AddEventListener(XEventId.EVENT_LOGIN_DATA_LOAD_COMPLETE, XUploadLogManager.InitLogUploader) + end + + function XUploadLogManager.InitConfig() + local UploadLogUrl = CS.XRemoteConfig.UploadLogUrl + if (UploadLogUrl and UploadLogUrl ~= "") then + local strs = string.Split(UploadLogUrl, "|") + local url = strs[1] + + UPLOAD_LOG_DAY = tonumber(strs[3]) or 0 + + ErrorUrl = url .. "/client_error/" + LogUrl = url .. "/client_log/" + NeedUploadError = strs[2] == "1" + NeedUploadLog = UPLOAD_LOG_DAY > 0 + else + NeedUploadError = false + NeedUploadLog = false + end + end + + function XUploadLogManager.InitErrorUploader() + CS.XLogUploader:GetInstance().NeedUploadLog = NeedUploadError + CS.XLogUploader:GetInstance().LOG_HTTP = ErrorUrl + end + + function XUploadLogManager.InitLogUploader() + FullLogId = tostring(XPlayer.Id) + CS.XFullLogUploader:GetInstance():SetId(FullLogId) + CS.XFullLogUploader:GetInstance().NeedUploadLog = NeedUploadLog + CS.XFullLogUploader:GetInstance().LOG_HTTP = LogUrl + end + + -- 主动上传本地日志 + -- day 几天内 + -- extraParam 额外参数 + function XUploadLogManager.UplodaFullLog(day, extraParam) + if not FullLogId or FullLogId == "" then + XLog.Error("FullLogId invalid : " .. tostring(FullLogId)) + return + end + + day = day or UPLOAD_LOG_DAY + if not day or day <= 0 then + XLog.Error("upload full log with invalid day " .. tostring(day)) + return + end + + extraParam = extraParam or "" + XLuaUiManager.SetAnimationMask(MASK_UPLOAD_LOG, true, 0) + CS.XFullLogUploader:GetInstance():Upload(day, function() + XLog.Debug("finish Upload Log!!!") + XLuaUiManager.SetAnimationMask(MASK_UPLOAD_LOG, false) + end, extraParam) + end + + XUploadLogManager.Init() + return XUploadLogManager +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XUserManager.lua b/Resources/Scripts/XManager/XUserManager.lua new file mode 100644 index 00000000..b36e3035 --- /dev/null +++ b/Resources/Scripts/XManager/XUserManager.lua @@ -0,0 +1,211 @@ +XUserManager = XUserManager or {} + +local Application = CS.UnityEngine.Application +local Platform = Application.platform +local RuntimePlatform = CS.UnityEngine.RuntimePlatform + +XUserManager.CHANNEL = { + HARU = 1, + HERO = 2, + Android = 3, + IOS = 4, + ONESTORE = 5, + HUAWEI = 6, + OPPO = 7, + KuroPC = 15, +} + +XUserManager.PLATFORM = { + Win = 0, + Android = 1, + IOS = 2 +} + +XUserManager.UserId = nil +XUserManager.UserName = nil +XUserManager.Token = nil +XUserManager.ReconnectedToken = nil +XUserManager.Channel = nil +XUserManager.Platform = nil + +local UserType = XHgSdkManager.UserType + +local InitPlatform = function() + if Platform == RuntimePlatform.Android then + XUserManager.Platform = XUserManager.PLATFORM.Android + XHgSdkManager.SetCallBackUrl(CS.XRemoteConfig.AndroidPayCallbackUrl) + elseif Platform == RuntimePlatform.IPhonePlayer then + XUserManager.Platform = XUserManager.PLATFORM.IOS + XHgSdkManager.SetCallBackUrl(CS.XRemoteConfig.IosPayCallbackUrl) + else + XUserManager.Platform = XUserManager.PLATFORM.Win + end +end + +function XUserManager.Init() + XUserManager.Channel = CS.XHgSdkAgent.LoginType or XUserManager.CHANNEL.HARU + XUserManager.UserId = XLoginManager.GetUserId() + XUserManager.UserType = XLoginManager.GetUserType() or UserType.Vistor + XUserManager.PasswordStatus = tonumber(XLoginManager.GetPasswordStatus() or "0") or 0 + if XUserManager.Channel ~= XUserManager.CHANNEL.Android and XUserManager.Channel ~= XUserManager.CHANNEL.IOS then + XUserManager.Token = XLoginManager.GetToken() + XUserManager.SetPasswordStatus(0) + end + InitPlatform() +end + +function XUserManager.IsNeedLogin() + if (XUserManager.Channel == XUserManager.CHANNEL.Android) or (XUserManager.Channel == XUserManager.CHANNEL.IOS) or XUserManager.Channel == XUserManager.CHANNEL.KuroPC then + return XHgSdkManager.IsNeedLogin() + else + return XHaruUserManager.IsNeedLogin() + end +end + +function XUserManager.HasLoginError() + if XUserManager.Channel == XUserManager.CHANNEL.HERO then + return XHeroSdkManager.HasLoginError() + else + return false + end +end + +function XUserManager.ShowLogin() + if XUserManager.Channel == XUserManager.CHANNEL.Android or XUserManager.Channel == XUserManager.CHANNEL.IOS or XUserManager.Channel == XUserManager.CHANNEL.KuroPC then + XHgSdkManager.Login(XHgSdkManager.UserType.Quickly) -- 默认快速登录逻辑 + else + XHaruUserManager.Login() + end +end + +function XUserManager.ShowLogout() + if XUserManager.Channel == XUserManager.CHANNEL.Android or XUserManager.Channel == XUserManager.CHANNEL.IOS then + XHgSdkManager.BackToLogin() + elseif XUserManager.Channel == XUserManager.CHANNEL.KuroPC then + XHgSdkManager.Logout() + else + XHaruUserManager.Logout() + end +end + +function XUserManager.Logout(cb) + if XUserManager.Channel == XUserManager.CHANNEL.Android or XUserManager.Channel == XUserManager.CHANNEL.IOS or XUserManager.Channel == XUserManager.CHANNEL.KuroPC then + XHgSdkManager.Logout(cb) + else + XHaruUserManager.Logout(cb) + end +end + +function XUserManager.ClearLoginData() + if XUserManager.Channel == XUserManager.CHANNEL.Android or XUserManager.Channel == XUserManager.CHANNEL.IOS or XUserManager.Channel == XUserManager.CHANNEL.KuroPC then + XHgSdkManager.Logout() + else + XUserManager.SignOut() + end +end + +function XUserManager.SetUserId(userId) + XUserManager.UserId = userId + CS.XHeroBdcAgent.UserId = "HeroEn#" .. (userId or "") + XLoginManager.SetUserId(userId) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_USERID_CHANGE, userId) +end + +function XUserManager.CleanUserId() + XUserManager.UserId = nil + XLoginManager.CleanUserId() + XEventManager.DispatchEvent(XEventId.EVENT_USERID_CHANGE, nil) +end + +function XUserManager.SetUserType(userType) + XUserManager.UserType = userType + XLoginManager.SetUserType(userType) +end + +function XUserManager.CleanUserType() + XUserManager.UserType = nil + XLoginManager.CleanUserType() +end + +function XUserManager.SetPasswordStatus(status) + XUserManager.PasswordStatus = status + XLoginManager.SetPasswordStatus(status) +end + +function XUserManager.SetUserName(userName) + XUserManager.UserName = userName + if XUserManager.Channel ~= XUserManager.CHANNEL.HERO then + CS.UnityEngine.PlayerPrefs.SetString(XPrefs.UserName, XUserManager.UserName) + CS.UnityEngine.PlayerPrefs.Save() + end + CsXGameEventManager.Instance:Notify(XEventId.EVENT_USERNAME_CHANGE, userName) +end + +function XUserManager.SetToken(token) + XUserManager.Token = token + if XUserManager.Channel ~= XUserManager.CHANNEL.Android and XUserManager.Channel ~= XUserManager.CHANNEL.IOS and XUserManager.Channel ~= XUserManager.CHANNEL.KuroPC then + XLoginManager.SetToken(token) + end +end + +function XUserManager.CleanToken() + XUserManager.Token = nil + XLoginManager.CleanToken() +end + +local DoRunLogin = function() + if CS.XFight.Instance ~= nil then + CS.XFight.ClearFight() + end + if XDataCenter.MovieManager then + XDataCenter.MovieManager.StopMovie() + end + CS.Movie.XMovieManager.Instance:Clear() + CsXUiManager.Instance:Clear() + XHomeSceneManager.LeaveScene() + CsXUiManager.Instance:Open("UiLogin") +end + +function XUserManager.SignOut() + XLoginManager.Disconnect() + + if XUserManager.Channel ~= XUserManager.CHANNEL.Android and XUserManager.Channel ~= XUserManager.CHANNEL.IOS then + XUserManager.SetUserId(nil) + XUserManager.SetUserName(nil) + XUserManager.SetToken(nil) + XUserManager.SetPasswordStatus(0) + end + + XEventManager.DispatchEvent(XEventId.EVENT_USER_LOGOUT) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_USER_LOGOUT) + XDataCenter.Init() + DoRunLogin() +end + +function XUserManager.OnSwitchAccountSuccess(uid, token, userType) + XLoginManager.Disconnect() + + XUserManager.SetUserId(uid) + XUserManager.SetUserType(userType) + XUserManager.SetToken(token) + + XEventManager.DispatchEvent(XEventId.EVENT_USER_LOGOUT) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_USER_LOGOUT) + + XDataCenter.Init() + DoRunLogin() +end + +XRpc.LoginResponse = function(response) + if response.Token then + XUserManager.ReconnectedToken = response.Token + --BDC + CS.XHeroBdcAgent.UserId = "HeroEn#" .. XUserManager.UserId + if XUserManager.Channel ~= XUserManager.CHANNEL.Android and XUserManager.Channel ~= XUserManager.CHANNEL.IOS then + XLoginManager.SetUserId(XUserManager.UserId) + XLoginManager.SetToken(XUserManager.Token) + XLoginManager.SetUserType(XUserManager.UserType) + XLoginManager.SetPasswordStatus(XUserManager.PasswordStatus) + end + end +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XVideoManager.lua b/Resources/Scripts/XManager/XVideoManager.lua new file mode 100644 index 00000000..5d6bdcf7 --- /dev/null +++ b/Resources/Scripts/XManager/XVideoManager.lua @@ -0,0 +1,92 @@ +XVideoManagerCreator = function() + + local XVideoManager = {} + + local VideoPlayState = { + Stop = 0, + Playing = 1, + Pause = 2 + } + + local State = VideoPlayState.Stop + -- local PlayingId = -1 + local VideoPlayer = nil + + function XVideoManager.PlayMovie(id, callback, needAuto, needSkip) + if not id then + return + end + + if State == VideoPlayState.Playing then + XLog.Error("XVideoManager.PlayMovie: Video正在播放") + return + end + + local config = XVideoConfig.GetMovieById(id) + + if not CS.XResourceManager.HasFile(config.VideoUrl) then + if callback then + callback() + end + return + end + -- PlayingId = id + State = VideoPlayState.Playing + + CsXUiManager.Instance:Open("UiVideoPlayer", id, callback, needAuto, needSkip) + end + + --停止播放 + function XVideoManager.Stop() + if State ~= VideoPlayState.Playing then + return + end + + if not VideoPlayer then + return + end + + State = VideoPlayState.Stop + -- PlayingId = -1 + VideoPlayer = nil + + end + + function XVideoManager.Pause() + if State ~= VideoPlayState.Playing then + return + end + + if not VideoPlayer then + return + end + + State = VideoPlayState.Pause + VideoPlayer:Pause() + + end + + function XVideoManager.Resume() + if State ~= VideoPlayState.Pause then + return + end + + if not VideoPlayer then + return + end + + State = VideoPlayState.Playing + VideoPlayer:Resume() + + end + + function XVideoManager.SetVideoPlayer(player) + VideoPlayer = player + end + + function XVideoManager.IsPlaying() + return VideoPlayer and VideoPlayer:IsPlaying() + end + + return XVideoManager +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XVoteManager.lua b/Resources/Scripts/XManager/XVoteManager.lua new file mode 100644 index 00000000..adc30a88 --- /dev/null +++ b/Resources/Scripts/XManager/XVoteManager.lua @@ -0,0 +1,152 @@ +XVoteManagerCreator = function() + local XVoteManager = {} + + ---key: voteId + ---value: { voteNum: 投票数, group: 这个投票属于哪个 投票分组 } + local VoteMap = {} + + --key: groupId(投票分组Id) + --value: { groupId: 分组Id, TimeToClose: 分组关闭时间, VoteMap: 分组包括的投票Id } + local GroupMap + + --- {Id: 分组Id,SelectId:选择投票Id} + local VoteGroupInfo = {} + + local METHOD_NAME = { + GetVoteGroupListRequest = "GetVoteGroupListRequest", + AddVoteRequest = "AddVoteRequest", + } + + function XVoteManager.GetVoteGroupListRequest(cb) + XNetwork.Call(METHOD_NAME.GetVoteGroupListRequest, {}, function(res) + VoteMap = {} + GroupMap = {} + local groupList = res.VoteGroupList + for _, v in pairs(groupList) do + local groupItem = {} + groupItem.GroupId = v.Id + groupItem.TimeToClose = v.TimeToClose + groupItem.VoteMap = {} + + for voteId, voteNum in pairs(v.VoteDic) do + VoteMap[voteId] = {} + VoteMap[voteId].VoteNum = voteNum + VoteMap[voteId].GroupId = v.Id + table.insert(groupItem.VoteMap, voteId) + end + + GroupMap[v.Id] = groupItem + end + + XEventManager.DispatchEvent(XEventId.EVENT_VOTE_REFRESH) + if cb then + cb() + end + end) + end + + function XVoteManager.AddVote(voteId, cb) + if not VoteMap[voteId] then + XLog.Error(" XVoteManager.AddVote VoteId is not exist " .. voteId) + return + end + + XNetwork.Call(METHOD_NAME.AddVoteRequest, { VoteId = voteId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + VoteMap[voteId].VoteNum = VoteMap[voteId].VoteNum + 1 + XEventManager.DispatchEvent(XEventId.EVENT_VOTE_REFRESH) + if cb then + cb() + end + end) + end + + --判断是否已经从后端拿到 投票数据 + function XVoteManager.IsInit() + return not (GroupMap == nil) + end + + --判断投票是否已经关闭 + function XVoteManager.IsGroupVoteClose(groupId) + if GroupMap == nil then + return true + else + local groupMo = GroupMap[groupId] + if not groupMo then + XLog.Error(" XVoteManager.IsGroupVoteClose is not exist " .. groupId) + return true + end + + local remainTime = groupMo.TimeToClose - XTime.GetServerNowTimestamp() + if remainTime > 0 then + return false + else + return true + end + end + end + + --判断是否已经投过票 + function XVoteManager.IsGroupVoted(groupId) + if not VoteGroupInfo[groupId] then + return false + else + return true + end + end + + function XVoteManager.IsVoteSelected(groupId,voteId) + local info = VoteGroupInfo[groupId] + if not info then + return false + end + + if info.SelectId ~= voteId then + return false + end + + return true + end + + --根据 VoteId 得到投票数据 + --如果已经请求过后端数据,直接return voteMo + function XVoteManager.GetVote(voteId) + if GroupMap == nil then + return + else + local voteMo = VoteMap[voteId] + if not voteMo then + XLog.Error(" XVoteManager.GetVote voteId is not exist " .. voteId) + return + end + return voteMo + end + end + + function XVoteManager.RefreshGroupInfo(groupData) + VoteGroupInfo = {} + for _, v in pairs(groupData) do + VoteGroupInfo[v.Id] = v + end + end + + function XVoteManager.GetVoteIdListByGroupId(groupId) + local group = GroupMap[groupId] + if not group then + XLog.Error("XVoteManager.GetVoteIdListByGroupId error. group id is not exist. groupId = " .. groupId) + return {} + end + + return group.VoteMap + end + + return XVoteManager + +end + +XRpc.NotifyVoteData = function(data) + XDataCenter.VoteManager.RefreshGroupInfo(data.VoteAlarmDic) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XWeaponFashionManager.lua b/Resources/Scripts/XManager/XWeaponFashionManager.lua new file mode 100644 index 00000000..b88ed42e --- /dev/null +++ b/Resources/Scripts/XManager/XWeaponFashionManager.lua @@ -0,0 +1,274 @@ +local next = next +local pairs = pairs +local table = table +local tableInsert = table.insert +local tableSort = table.sort +local XWeaponFashion = require("XEntity/XEquip/XWeaponFashion") + +XWeaponFashionManagerCreator = function() + local XWeaponFashionManager = {} + + local OwnWeaponFashions = {} + + XWeaponFashionManager.FashionStatus = { + UnOwned = 0, -- 未拥有 + UnLock = 1, -- 已解锁 + Dressed = 2, -- 已穿戴 + } + + local IsNotifyWeaponFashionTransform = false + + function XWeaponFashionManager.InitWeaponFashions(fashions) + if not fashions then return end + + for _, data in pairs(fashions) do + OwnWeaponFashions[data.Id] = XWeaponFashion.New(data) + end + end + + function XWeaponFashionManager.RecycleWeaponFashions(fashionIds) + if not fashionIds then return end + + for _, fashionId in pairs(fashionIds) do + OwnWeaponFashions[fashionId] = nil + end + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_FASHION_WEAPON_EXPIRED_REFRESH, fashionIds) + end + + function XWeaponFashionManager.NotifyWeaponFashionInfo(data) + XWeaponFashionManager.InitWeaponFashions(data.WeaponFashionDataList) + XWeaponFashionManager.RecycleWeaponFashions(data.ExpireList) + end + + function XWeaponFashionManager.NotifyWeaponFashionTransform(data) + IsNotifyWeaponFashionTransform = true + if not data or not next(data) then return end + local rewards = {} + tableInsert(rewards, { TemplateId = data.ItemId, Count = data.ItemCount }) + XUiManager.OpenUiObtain(rewards) + end + + function XWeaponFashionManager.GetIsNotifyWeaponFashionTransform() + return IsNotifyWeaponFashionTransform + end + + function XWeaponFashionManager.ResetIsNotifyWeaponFashionTransform() + IsNotifyWeaponFashionTransform = false + end + + function XWeaponFashionManager.CheckHasFashion(id) + if not id then return false end + if XWeaponFashionConfigs.IsDefaultId(id) then return true end + return OwnWeaponFashions[id] ~= nil + end + + function XWeaponFashionManager.IsFashionTimeLimit(id) + local fashion = XWeaponFashionManager.GetWeaponFashion(id) + if not fashion then return false end + return fashion:IsTimeLimit() + end + + function XWeaponFashionManager.CheckFashionTimeLimit(id) + local beginTime = XWeaponFashionConfigs.GetFashionBeginTime(id) + local endTime = XWeaponFashionConfigs.GetFashionExpireTime(id) + return beginTime ~= 0 or endTime ~= 0 + end + + function XWeaponFashionManager.IsFashionInTime(id) + local fitBegin + local beginTime = XWeaponFashionConfigs.GetFashionBeginTime(id) + if beginTime == 0 then + fitBegin = true + else + local nowTime = XTime.GetServerNowTimestamp() + fitBegin = nowTime >= beginTime + end + + local fitEnd + local endTime = XWeaponFashionConfigs.GetFashionExpireTime(id) + if endTime == 0 then + fitEnd = true + else + local nowTime = XTime.GetServerNowTimestamp() + fitEnd = nowTime < endTime + end + + return fitBegin and fitEnd and true + end + + function XWeaponFashionManager.GetCharacterWearingWeaponFashionId(characterId) + local weaponFashionId = XWeaponFashionConfigs.DefaultWeaponFashionId + + for _, fashion in pairs(OwnWeaponFashions) do + if fashion:IsDressed(characterId) then + weaponFashionId = fashion:GetId() + break + end + end + + return weaponFashionId + end + + function XWeaponFashionManager.GetWeaponFashion(id) + return OwnWeaponFashions[id] + end + + function XWeaponFashionManager.GetOwnWeaponFashion() + return XTool.Clone(OwnWeaponFashions) + end + + local SortStatusPriority = { + [XWeaponFashionManager.FashionStatus.UnOwned] = 1, + [XWeaponFashionManager.FashionStatus.UnLock] = 2, + [XWeaponFashionManager.FashionStatus.Dressed] = 3, + } + + function XWeaponFashionManager.GetSortedWeaponFashionIdsByCharacterId(characterId) + local sortedFashionIds = {} + + local characterEquipType = XCharacterConfigs.GetCharacterEquipType(characterId) + local fashionIds = XWeaponFashionConfigs.GetWeaponFashionIdsByEquipType(characterEquipType) + for _, id in pairs(fashionIds) do + if XWeaponFashionManager.IsFashionInTime(id) then + tableInsert(sortedFashionIds, id) + end + end + tableInsert(sortedFashionIds, XWeaponFashionConfigs.DefaultWeaponFashionId) + + tableSort(sortedFashionIds, function(a, b) + local status1, status2 = XWeaponFashionManager.GetFashionStatus(a, characterId), XWeaponFashionManager.GetFashionStatus(b, characterId) + if status1 ~= status2 then + return SortStatusPriority[status1] > SortStatusPriority[status2] + end + + local aIsDefault = XWeaponFashionConfigs.IsDefaultId(a) + local bIsDefault = XWeaponFashionConfigs.IsDefaultId(b) + if aIsDefault ~= bIsDefault then + return aIsDefault + end + + return XWeaponFashionConfigs.GetFashionPriority(a) > XWeaponFashionConfigs.GetFashionPriority(b) + end) + + return sortedFashionIds + end + + function XWeaponFashionManager.GetFashionStatus(fashionId, characterId) + if XWeaponFashionConfigs.IsDefaultId(fashionId) then + for _, fashion in pairs(OwnWeaponFashions) do + if fashion:IsDressed(characterId) then + return XWeaponFashionManager.FashionStatus.UnLock + end + end + return XWeaponFashionManager.FashionStatus.Dressed + end + + local fashion = XWeaponFashionManager.GetWeaponFashion(fashionId) + if not fashion then + return XWeaponFashionManager.FashionStatus.UnOwned + end + + return fashion:IsDressed(characterId) and XWeaponFashionManager.FashionStatus.Dressed or XWeaponFashionManager.FashionStatus.UnLock + end + + function XWeaponFashionManager.IsCharacterFashion(fashionId, characterId) + local fashionList = XWeaponFashionManager.GetSortedWeaponFashionIdsByCharacterId(characterId) + for _, fashionIdTemp in pairs(fashionList) do + if fashionIdTemp == fashionId then + return true + end + end + return false + end + + function XWeaponFashionManager.GetWeaponFashionName(weaponFashionId, characterId) + local fashionName + + if XWeaponFashionConfigs.IsDefaultId(weaponFashionId) then + local templateId + if not XDataCenter.CharacterManager.IsOwnCharacter(characterId) then + templateId = XCharacterConfigs.GetCharacterDefaultEquipId(characterId) + else + local equipId = XDataCenter.EquipManager.GetCharacterWearingWeaponId(characterId) + templateId = XDataCenter.EquipManager.GetEquipTemplateId(equipId) + end + fashionName = XDataCenter.EquipManager.GetEquipName(templateId) + else + fashionName = XWeaponFashionConfigs.GetFashionName(weaponFashionId) + end + + return fashionName + end + + function XWeaponFashionManager.GetWeaponModelCfg(weaponFashionId, characterId, uiName) + local modelConfig = {} + + local IsOwnCharacter = XDataCenter.CharacterManager.IsOwnCharacter(characterId) + if XWeaponFashionConfigs.IsDefaultId(weaponFashionId) then + if not IsOwnCharacter then + local templateId = XCharacterConfigs.GetCharacterDefaultEquipId(characterId) + modelConfig = XDataCenter.EquipManager.GetWeaponModelCfg(templateId, uiName, 0, 0) + else + local equipId = XDataCenter.EquipManager.GetCharacterWearingWeaponId(characterId) + local templateId = XDataCenter.EquipManager.GetEquipTemplateId(equipId) + local breakthroughTimes = XDataCenter.EquipManager.GetBreakthroughTimes(equipId) + local resonanceCount = XDataCenter.EquipManager.GetResonanceCount(equipId) + modelConfig = XDataCenter.EquipManager.GetWeaponModelCfg(templateId, uiName, breakthroughTimes, resonanceCount) + end + else + local resonanceCount = 0 + local equipType = XWeaponFashionConfigs.GetFashionEquipType(weaponFashionId) + if IsOwnCharacter then + local equipId = XDataCenter.EquipManager.GetCharacterWearingWeaponId(characterId) + resonanceCount = XDataCenter.EquipManager.GetResonanceCount(equipId) + end + local modelId = XWeaponFashionConfigs.GetWeaponResonanceModelId(XEquipConfig.WeaponCase.Case1, weaponFashionId, resonanceCount) + modelConfig.ModelId = modelId + modelConfig.TransformConfig = XEquipConfig.GetEquipModelTransformCfg(nil, uiName, resonanceCount, modelId, equipType) + end + + return modelConfig + end + + function XWeaponFashionManager.UseFashion(fashionId, characterId, cb) + if not XDataCenter.CharacterManager.IsOwnCharacter(characterId) then + XUiManager.TipText("CharacterLock") + return + end + + if not XWeaponFashionManager.CheckHasFashion(fashionId) then + XUiManager.TipText("WeaponFashionNotOwn") + return + end + + XNetwork.Call("WeaponFashionUseRequest", { Id = fashionId, CharacterId = characterId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + + local oldFashion = XWeaponFashionManager.GetWeaponFashion(fashionId) + if oldFashion then + oldFashion:TakeOff(characterId) + end + + local fashion = XWeaponFashionManager.GetWeaponFashion(fashionId) + if fashion then + fashion:Dress(characterId) + end + + if cb then cb() end + end) + end + + return XWeaponFashionManager +end + +XRpc.NotifyWeaponFashionInfo = function(data) + XDataCenter.WeaponFashionManager.NotifyWeaponFashionInfo(data) +end + +XRpc.NotifyWeaponFashionTransform = function(data) + XDataCenter.WeaponFashionManager.NotifyWeaponFashionTransform(data) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XWhiteValentineManager.lua b/Resources/Scripts/XManager/XWhiteValentineManager.lua new file mode 100644 index 00000000..1b3f79e2 --- /dev/null +++ b/Resources/Scripts/XManager/XWhiteValentineManager.lua @@ -0,0 +1,281 @@ +--2021年白情约会活动管理器 +XWhiteValentineManagerCreator = function() + --================ + --请求协议名称 + --================ + local REQUEST_NAMES = { --请求名称 + EnterActivity = "WhiteValentinesDayActivityEnterRequest", -- 购买商店物品 + Encounter = "WhiteValentinesDayActivityRandomMeetRequest", -- 刷新商店商品 + Invite = "WhiteValentinesDayActivityInviteRequest", -- 领取合成进度奖励 + Dispatch = "WhiteValentinesDayActivityDispatchRequest", -- 派遣角色 + FinishEvent = "WhiteValentinesDayActivityFinishEventRequest", -- 结束事件 + CancelDispatch = "WhiteValentinesDayActivityCancelDispatchRequest", -- 取消派遣 + } + + local WhiteValentineManager = {} + local ScheduleId + WhiteValentineManager.StoryType = { + Encounter = 1, --偶遇 + Invite = 2, --邀请 + } + + WhiteValentineManager.StoryTypeName = { + [1] = "Encounter", --偶遇 + [2] = "Invite", --邀请 + } + --活动控制器对象 + local GameControl + --================= + --初始化 + --================= + function WhiteValentineManager.Init() + local XGame = require("XEntity/XMiniGame/WhiteValentine2021/XWhiteValentineGame") + GameControl = XGame.New() + end + --================= + --构建奖励列表(用于UiObtain显示奖励) + --================= + function WhiteValentineManager.CreateRewardList(contributionCount, coinCount) + if not contributionCount or not coinCount then return nil end + local rewardList = {} + local contributionItem = { RewardType = 1, TemplateId = GameControl:GetContributionItemId(), Count = contributionCount} + local coinItem = { RewardType = 1, TemplateId = GameControl:GetCoinItemId(), Count = coinCount} + table.insert(rewardList, contributionItem) + table.insert(rewardList, coinItem) + return rewardList + end + --================= + --播放角色通讯 + --================= + function WhiteValentineManager.PlayCommu(roleDb, callBack) + if not roleDb then return end + local chara = GameControl:GetChara(roleDb.Id) + if not chara then return end + if not XPlayer.IsCommunicationMark(chara:GetCommuId()) then + XDataCenter.CommunicationManager.ShowGameStoryCommunication(chara:GetCommuId(), callBack) + end + end + --================= + --进入活动时请求 + --@param callBack:回调 + --================= + function WhiteValentineManager.OnEnterActivity(callBack) + XNetwork.Call(REQUEST_NAMES.EnterActivity, {}, function(reply) + if reply.Code ~= XCode.Success then + XUiManager.TipCode(reply.Code) + return + end + GameControl:RefreshData(reply.ActivityDb) + WhiteValentineManager.ScheduleCanFinishEvent() + XEventManager.DispatchEvent(XEventId.EVENT_WHITEVALENTINE_SHOW_PLACE) + if callBack then callBack() end + end) + end + --================= + --发起偶遇角色请求 + --@param callBack:成功时回调 + --================= + function WhiteValentineManager.EncounterChara(callBack) + if not GameControl then return end + if GameControl:CheckCanEncounter() then + XNetwork.Call(REQUEST_NAMES.Encounter, {}, function(reply) + -- reply = {XCode Code //错误码, int RoleId //偶遇的角色Id} + if reply.Code ~= XCode.Success then + XUiManager.TipCode(reply.Code) + return + end + GameControl:AddNewChara(reply.RoleId) + if callBack then callBack() end + CsXGameEventManager.Instance:Notify(XEventId.EVENT_WHITEVALENTINE_ENCOUNTER_CHARA, GameControl:GetChara(reply.RoleId)) + end) + end + end + --================= + --发起邀请角色请求 + --@param chara:邀请角色对象 + --@param callBack:成功时回调 + --================= + function WhiteValentineManager.InviteChara(chara, callBack) + XNetwork.Call(REQUEST_NAMES.Invite, { RoleId = chara:GetCharaId() }, function(reply) + -- reply = {XCode Code //错误码, + -- int RoleId //邀请的角色Id} + if reply.Code ~= XCode.Success then + XUiManager.TipCode(reply.Code) + return + end + GameControl:AddNewChara(reply.RoleId) + GameControl:SetInviteChance(GameControl:GetInviteChance() - 1) + if callBack then callBack() end + CsXGameEventManager.Instance:Notify(XEventId.EVENT_WHITEVALENTINE_INVITE_CHARA, chara) + end) + end + --================= + --发起角色派遣请求 + --@param place:要派遣的地点对象 + --@param chara:要派遣的角色对象 + --@param callBack:成功时回调 + --================= + function WhiteValentineManager.CharaDispatch(place, chara, callBack) + if not GameControl:CheckCanDispatch(place) then return end + XNetwork.Call(REQUEST_NAMES.Dispatch, { PlaceId = place:GetPlaceId(), RoleId = chara:GetCharaId() }, function(reply) + -- reply = {XCode Code //错误码, + -- XWhiteValentinesDayRoleDb RoleDb //派遣出去的角色Id + -- XWhiteValentinesDayPlaceDb PlaceDb //事件Id + -- int SubEnergy //扣除的体力 + -- int LastRefreshTimestamp //下次体力刷新时间} + if reply.Code ~= XCode.Success then + XUiManager.TipCode(reply.Code) + return + end + GameControl:CharaDispatch(reply.PlaceDb, reply.RoleDb, reply.SubEnergy, reply.LastRefreshTimestamp) + if callBack then callBack() end + XEventManager.DispatchEvent(XEventId.EVENT_WHITEVALENTINE_REFRESH_PLACE, place:GetPlaceId()) + end) + end + --================= + --取消角色派遣请求 + --@param place:要派遣的地点对象 + --@param chara:要派遣的角色对象 + --@param callBack:成功时回调 + --================= + function WhiteValentineManager.CancelDispatch(place, callBack) + if place:CheckCanFinishEvent() then + XUiManager.TipMsg(CS.XTextManager.GetText("WhiteValentineAlreadyFinishEvent")) + return + end + XNetwork.Call(REQUEST_NAMES.CancelDispatch, { PlaceId = place:GetPlaceId() }, function(reply) + -- reply = {XCode Code //错误码, + -- XWhiteValentinesDayRoleDb RoleDb //派遣出去的角色Id + -- XWhiteValentinesDayPlaceDb PlaceDb //事件Id} + if reply.Code ~= XCode.Success then + XUiManager.TipCode(reply.Code) + return + end + GameControl:RefreshChara(reply.RoleDb) + GameControl:RefreshPlace(reply.PlaceDb) + if callBack then callBack() end + XEventManager.DispatchEvent(XEventId.EVENT_WHITEVALENTINE_REFRESH_PLACE, place:GetPlaceId()) + end) + end + --================= + --发起完成事件请求 + --@param place:要完成事件的地点 + --@param callBack:成功时回调 + --================= + function WhiteValentineManager.FinishEvent(place, callBack) + if place:CheckCanFinishEvent() then + XNetwork.Call(REQUEST_NAMES.FinishEvent, { PlaceId = place:GetPlaceId() }, function(reply) + -- reply = {XCode Code //错误码, XWhiteValentinesDayRoleDb UpdateRoleDb //刷新的角色数据 + -- XWhiteValentinesDayPlaceDb UpdatePlaceDb //刷新的地点数据 + -- List NewPlaceDb //新增的地点数据 + -- int AddContribution //奖励的贡献值 + -- int AddCoin //奖励的金币} + if reply.Code ~= XCode.Success then + XUiManager.TipCode(reply.Code) + return + end + GameControl:RefreshChara(reply.UpdateRoleDb) + GameControl:RefreshPlace(reply.UpdatePlaceDb) + GameControl:RefreshPlaceRange(reply.NewPlaceDb) + if callBack then callBack() end + CsXGameEventManager.Instance:Notify(XEventId.EVENT_WHITEVALENTINE_REFRESH_PLACE, reply.UpdatePlaceDb.Id) + + local rewardList = WhiteValentineManager.CreateRewardList(reply.AddContribution, reply.AddCoin) + if rewardList then XUiManager.OpenUiObtain + (rewardList, nil, + function() + if reply.UpdateRoleDb.FinishEventCount >= 1 then + WhiteValentineManager.PlayCommu(reply.UpdateRoleDb, function() CsXGameEventManager.Instance:Notify(XEventId.EVENT_WHITEVALENTINE_OPEN_PLACE, reply.NewPlaceDb) end) + else + CsXGameEventManager.Instance:Notify(XEventId.EVENT_WHITEVALENTINE_OPEN_PLACE, reply.NewPlaceDb) + end + end) + end + end) + else + XUiManager.TipMsg(CS.XTextManager.GetText("WhiteValentineEventNotFinish")) + return + end + end + --================= + --游戏登陆时刷新活动数据 + --================= + function WhiteValentineManager.RefreshData(data) + GameControl:RefreshData(data.ActivityDb) + WhiteValentineManager.ScheduleCanFinishEvent() + end + + function WhiteValentineManager.ScheduleCanFinishEvent() + if ScheduleId then return end + GameControl:CheckCanFinishEvent() + XEventManager.DispatchEvent(XEventId.EVENT_FINGER_GUESS_CHECK_EVENT_FINISH) + ScheduleId = XScheduleManager.ScheduleForever(function() + if ScheduleId and not WhiteValentineManager.CheckCanGoTo() then + XScheduleManager.UnSchedule(ScheduleId) + end + GameControl:CheckCanFinishEvent() + XEventManager.DispatchEvent(XEventId.EVENT_FINGER_GUESS_CHECK_EVENT_FINISH) + XEventManager.DispatchEvent(XEventId.EVENT_ACTIVITY_INFO_UPDATE, XActivityConfigs.ActivityType.Skip) + end, + 5000 + ) + end + --================= + --获取活动控制器 + --================= + function WhiteValentineManager.GetGameController() + return GameControl + end + --================= + --获取地点管理器 + --================= + function WhiteValentineManager.GetPlaceManager() + return GameControl:GetPlaceManager() + end + --================= + --获取角色管理器 + --================= + function WhiteValentineManager.GetCharaManager() + return GameControl:GetCharaManager() + end + --================= + --获取是否有完成事件未领取奖励 + --================= + function WhiteValentineManager.GetCanFinishEvent() + return GameControl:GetCanFinishEvent() + end + --================ + --跳转到活动主界面 + --================ + function WhiteValentineManager.JumpTo() + local canGoTo, notStart = WhiteValentineManager.CheckCanGoTo() + if notStart then + XUiManager.TipMsg(CS.XTextManager.GetText("CommonActivityNotStart")) + elseif XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.WhiteValentineDay) and + canGoTo then + XLuaUiManager.Open("UiWhitedayMain") + else + XUiManager.TipMsg(CS.XTextManager.GetText("CommonActivityEnd")) + end + end + --================ + --检查是否能进入玩法 + --@return param1:是否在活动时间内(true为在活动时间内) + --@return param2:是否未开始活动(true为未开始活动) + --================ + function WhiteValentineManager.CheckCanGoTo() + local endTime = GameControl:GetActivityEndTime() + local startTime = GameControl:GetActivityStartTime() + local nowTime = XTime.GetServerNowTimestamp() + local isActivityEnd = (nowTime >= endTime) and (nowTime > startTime) + local notStart = nowTime < startTime + return not isActivityEnd, notStart + end + + WhiteValentineManager.Init() + return WhiteValentineManager +end + +XRpc.NotifyWhiteValentinesDayActivity = function(data) + XDataCenter.WhiteValentineManager.RefreshData(data) +end \ No newline at end of file diff --git a/Resources/Scripts/XManager/XWorldBossManager.lua b/Resources/Scripts/XManager/XWorldBossManager.lua new file mode 100644 index 00000000..c95c0114 --- /dev/null +++ b/Resources/Scripts/XManager/XWorldBossManager.lua @@ -0,0 +1,632 @@ +XWorldBossManagerCreator = function() + local XWorldBossActivityEntity = require("XEntity/XWorldBoss/XWorldBossActivityEntity") + local XBuffEntity = require("XEntity/XWorldBoss/XBuffEntity") + local XWorldBossManager = {} + local CSTextManagerGetText = CS.XTextManager.GetText + local CSXGameClientConfig = CS.XGame.ClientConfig + + local METHOD_NAME = { + GetWorldBossGlobalDataRequest = "GetWorldBossGlobalDataRequest", + GetAttributeAreaRewardRequest = "GetAttributeAreaRewardRequest", + GetAttributeAreaStageRewardRequest = "GetAttributeAreaStageRewardRequest", + GetBossPhasesRewardRequest = "GetBossPhasesRewardRequest", + WorldBossShopBuyRequest = "WorldBossShopBuyRequest", + WorldBossAttributeAreaRankRequest = "WorldBossAttributeAreaRankRequest", + GetWorldBossReportRequest = "GetWorldBossReportRequest", + } + + local SYNC_GLOBALDATA_SECOND = 30 + local LastSyncGlobaldataTime = 0 + + local WorldBossActivityDic = {} + local WorldBossGlobalData = {} + local WorldBossMySelfData = {} + local WorldBossBuffDic = {} + local WorldBossBuffGroupDic = {} + local WorldBossBossStageDic = {} + local FightReportList = {} + local AreaRankData = {} + local BossStageLevel = 1 + + function XWorldBossManager.Init() + WorldBossBuffGroupDic = {} + XWorldBossManager.CreateWorldBossActivity() + XWorldBossManager.CreateWorldBossBuffDic() + XWorldBossManager.CreateWorldBossBossStageDic() + end + + function XWorldBossManager.CreateWorldBossActivity() + local activityCfgs = XWorldBossConfigs.GetActivityTemplates() + for _, cgf in pairs(activityCfgs) do + WorldBossActivityDic[cgf.Id] = XWorldBossActivityEntity.New(cgf.Id) + end + end + + function XWorldBossManager.UpdateWorldBossActivity() + local worldBossActivity = XWorldBossManager.GetCurWorldBossActivity() + if worldBossActivity then + local tmpData = {} + tmpData.GlobalData = WorldBossGlobalData + tmpData.PrivateData = WorldBossMySelfData + worldBossActivity:UpdateData(tmpData) + worldBossActivity:UpdateEntityDic() + end + end + + function XWorldBossManager.CreateWorldBossBuffDic() + local buffCfgs = XWorldBossConfigs.GetBuffTemplates() + for _, buffCfg in pairs(buffCfgs) do + local tmpEntity = XBuffEntity.New(buffCfg.Id) + WorldBossBuffDic[buffCfg.Id] = tmpEntity + end + end + + function XWorldBossManager.UpdateGetedBossBuff(buffList)--如果在多个地方都涉及buff更新,则因为等级关系所带来的条件提示文字也会得到正确的影响 + for _, buffId in pairs(buffList) do + local buffEntity = XWorldBossManager.GetWorldBossBuffById(buffId) + local tmpEntity = WorldBossBuffGroupDic[buffEntity:GetGroupId()] + local tmpData = {} + if buffEntity:GetGroupId() == 0 then + tmpData.LockDesc = buffEntity:GetType() == XWorldBossConfigs.BuffType.Buff and + CSTextManagerGetText("WorldBossBuffGeted") or CSTextManagerGetText("WorldBossRobotGeted") + tmpData.LockDescColor = CSXGameClientConfig:GetString("WorldBossBuffUnLockColor") + tmpData.InfoTextColor = CSXGameClientConfig:GetString("WorldBossUnLockInfoColor") + buffEntity:UpdateData(tmpData) + else + if (not tmpEntity) or (tmpEntity:GetLevel() <= buffEntity:GetLevel()) then + if tmpEntity then + tmpData.LockDesc = CSTextManagerGetText("WorldBossBuffLevelLow") + tmpData.LockDescColor = CSXGameClientConfig:GetString("WorldBossBuffLowColor") + tmpData.InfoTextColor = CSXGameClientConfig:GetString("WorldBossLockInfoColor") + tmpEntity:UpdateData(tmpData) + end + tmpData.LockDesc = buffEntity:GetType() == XWorldBossConfigs.BuffType.Buff and + CSTextManagerGetText("WorldBossBuffGeted") or CSTextManagerGetText("WorldBossRobotGeted") + tmpData.LockDescColor = CSXGameClientConfig:GetString("WorldBossBuffUnLockColor") + tmpData.InfoTextColor = CSXGameClientConfig:GetString("WorldBossUnLockInfoColor") + buffEntity:UpdateData(tmpData) + WorldBossBuffGroupDic[buffEntity:GetGroupId()] = buffEntity + else + tmpData.LockDesc = CSTextManagerGetText("WorldBossBuffLevelLow") + tmpData.LockDescColor = CSXGameClientConfig:GetString("WorldBossBuffLowColor") + tmpData.InfoTextColor = CSXGameClientConfig:GetString("WorldBossLockInfoColor") + buffEntity:UpdateData(tmpData) + end + end + buffEntity:UpdateData({ IsLock = false }) + end + end + + function XWorldBossManager.CreateWorldBossBossStageDic() + local stageCfgs = XWorldBossConfigs.GetBossStageTemplates() + for _, stageCfg in pairs(stageCfgs) do + local bossStage = WorldBossBossStageDic[stageCfg.StageId] + if not bossStage then + bossStage = {} + WorldBossBossStageDic[stageCfg.StageId] = bossStage + end + bossStage[stageCfg.Level] = bossStage[stageCfg.Level] or {} + bossStage[stageCfg.Level] = stageCfg + end + end + + function XWorldBossManager.IsInActivity() + local worldBossActivity = XWorldBossManager.GetCurWorldBossActivity() + if worldBossActivity then + local nowTime = XTime.GetServerNowTimestamp() + if nowTime > worldBossActivity:GetBeginTime() and nowTime < worldBossActivity:GetEndTime() then + return true + end + end + return false + end + + function XWorldBossManager.GetCurWorldBossActivity() + local activityId = WorldBossMySelfData.ActivityId + if not activityId then + return nil + end + return WorldBossActivityDic[activityId] + end + + function XWorldBossManager.GetWorldBossActivityById(activityId) + if not activityId then + return + end + return WorldBossActivityDic[activityId] + end + + function XWorldBossManager.GetWorldBossBuffDic() + return WorldBossBuffDic + end + + function XWorldBossManager.GetWorldBossBuffById(id) + return WorldBossBuffDic[id] + end + + function XWorldBossManager.GetBossStageGroupByIdAndLevel(stageId, Level) + if not WorldBossBossStageDic[stageId] then + XLog.Error("Share/Fuben/WorldBoss/WorldBossBossStage.tab Id = " .. stageId .. " Is Null") + return + end + return Level and WorldBossBossStageDic[stageId][Level] or WorldBossBossStageDic[stageId] + end + + function XWorldBossManager.GetSameGroupBossBuffByGroupId(id) + local buffList = {} + if not id or id == 0 then + return nil + end + for _, buff in pairs(WorldBossBuffDic) do + if buff:GetGroupId() == id then + table.insert(buffList, buff) + end + end + table.sort(buffList, function(a, b) + return a:GetLevel() < b:GetLevel() + end) + return buffList + end + + function XWorldBossManager.GetSameGroupToLevelpBossBuffByGroupId(id) + local buffList = {} + local DefaultIndex = 1 + if not id or id == 0 then + return nil + end + for _, buff in pairs(WorldBossBuffDic) do + if buff:GetGroupId() == id then + table.insert(buffList, buff) + end + end + + table.sort(buffList, function(a, b) + if a:GetIsLock() and b:GetIsLock() then + return a:GetLevel() < b:GetLevel() + elseif not a:GetIsLock() and not b:GetIsLock() then + return a:GetLevel() > b:GetLevel() + else + return not a:GetIsLock() + end + end) + + return buffList[DefaultIndex] + end + + function XWorldBossManager.GetFightReportTypeById(id) + local reportCfg = XWorldBossConfigs.GetReportTemplatesById(id) + if reportCfg.Type == 1 or reportCfg.Type == 2 or reportCfg.Type == 3 then + return 1 + else + return 2 + end + end + + function XWorldBossManager.GetWorldBossSection()--获取入口数据 + local sections = {} + if XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.WorldBoss) then + return sections + end + local worldBossActivity = XWorldBossManager.GetCurWorldBossActivity() + if worldBossActivity and XWorldBossManager.IsInActivity() then + local defaultBossAreaId = worldBossActivity:GetBossAreaIds()[1] + local bossArea = worldBossActivity:GetBossAreaEntityById(defaultBossAreaId) + local section = { + Id = worldBossActivity:GetId(), + Type = XDataCenter.FubenManager.ChapterType.WorldBoss, + Name = worldBossActivity:GetName(), + BannerBg = worldBossActivity:GetBg(), + BossHpPercent = bossArea:GetHpPercent(), + } + table.insert(sections, section) + end + + return sections + end + + function XWorldBossManager.GetWorldBossBossTaskDataDic() + local bossAreaDatas = XWorldBossManager.GetBossAreaDic() + local bossTaskDataDic = {} + if not bossAreaDatas then + return bossTaskDataDic + end + for _, data in pairs(bossAreaDatas) do + local taskIds = data:GetBossTaskIds() + for _, taskId in pairs(taskIds) do + bossTaskDataDic[taskId] = bossTaskDataDic[taskId] or {} + table.insert(bossTaskDataDic[taskId], data) + end + end + return bossTaskDataDic + end + + function XWorldBossManager.GetAttributeAreaDic() + local worldBossActivity = XWorldBossManager.GetCurWorldBossActivity() + return worldBossActivity and worldBossActivity:GetAttributeAreaEntityDic() + end + + function XWorldBossManager.GetBossAreaDic() + local worldBossActivity = XWorldBossManager.GetCurWorldBossActivity() + return worldBossActivity and worldBossActivity:GetBossAreaEntityDic() + end + + function XWorldBossManager.GetSpecialSaleDic() + local worldBossActivity = XWorldBossManager.GetCurWorldBossActivity() + return worldBossActivity and worldBossActivity:GetSpecialSaleEntityDic() + end + + function XWorldBossManager.GetAttributeAreaById(id) + local worldBossActivity = XWorldBossManager.GetCurWorldBossActivity() + return worldBossActivity and worldBossActivity:GetAttributeAreaEntityById(id) + end + + function XWorldBossManager.GetAttributeStageById(areaId, id) + local worldBossActivity = XWorldBossManager.GetCurWorldBossActivity() + local attributeArea = worldBossActivity:GetAttributeAreaEntityById(areaId) + return worldBossActivity and attributeArea and attributeArea:GetStageEntityById(id) + end + + function XWorldBossManager.GetBossAreaById(id) + local worldBossActivity = XWorldBossManager.GetCurWorldBossActivity() + return worldBossActivity and worldBossActivity:GetBossAreaEntityById(id) + end + + function XWorldBossManager.GetSpecialSaleById(id) + local worldBossActivity = XWorldBossManager.GetCurWorldBossActivity() + return worldBossActivity and worldBossActivity:GetSpecialSaleEntityById(id) + end + + + function XWorldBossManager.GetCurrentActivityNo()--获取当前活动ID,如果活动未开始则返回默认活动ID + local DefaultActivityId = XWorldBossConfigs.GetActivityLastTemplate().Id + return WorldBossMySelfData.ActivityId or DefaultActivityId + end + + function XWorldBossManager.GetActivityBeginTime() + local activityId = XWorldBossManager.GetCurrentActivityNo() + if not activityId then + return nil + end + local worldBossActivity = XWorldBossManager.GetWorldBossActivityById(activityId) + return worldBossActivity and worldBossActivity:GetBeginTime() or 0 + end + + function XWorldBossManager.GetActivityEndTime() + local activityId = XWorldBossManager.GetCurrentActivityNo() + if not activityId then + return nil + end + local worldBossActivity = XWorldBossManager.GetWorldBossActivityById(activityId) + return worldBossActivity and worldBossActivity:GetEndTime() or 0 + end + + function XWorldBossManager.SetBossStageLevel(level) + BossStageLevel = level + end + + function XWorldBossManager.GetBossStageLevel() + return BossStageLevel + end + + function XWorldBossManager.UpdateWorldBossGlobalData(globalData) + WorldBossGlobalData = globalData + end + + function XWorldBossManager.UpdateWorldBossMySelfData(mySelfData) + WorldBossMySelfData = mySelfData + end + + function XWorldBossManager.SetWorldBossReportList(reportList) + FightReportList = reportList + end + + function XWorldBossManager.GetWorldBossReportList() + return FightReportList + end + + function XWorldBossManager.GetWorldBossNewReport() + return FightReportList and #FightReportList > 0 and FightReportList[#FightReportList] or nil + end + + function XWorldBossManager.SetAreaRankData(rankList) + AreaRankData = rankList + end + + function XWorldBossManager.GetMyAreaRankData() + local tmpData = {} + tmpData.Rank = AreaRankData.Rank + tmpData.ToTalRank = AreaRankData.ToTalRank + tmpData.Score = AreaRankData.Score + return tmpData + end + + function XWorldBossManager.GetOtherAreaRankData() + return AreaRankData.RankList or {} + end + + function XWorldBossManager.UpdateMySelfBossAreaData(mySelfData) + local IsHave = false + for index, areaData in pairs(WorldBossMySelfData.BossAreaDatas) do + if areaData.Id == mySelfData.Id then + WorldBossMySelfData.BossAreaDatas[index] = mySelfData + IsHave = true + break + end + end + if not IsHave then + table.insert(WorldBossMySelfData.BossAreaDatas, mySelfData) + end + end + + function XWorldBossManager.UpdateMySelfAttributeAreaData(mySelfData) + local IsHave = false + for index, areaData in pairs(WorldBossMySelfData.AttributeAreaDatas) do + if areaData.Id == mySelfData.Id then + WorldBossMySelfData.AttributeAreaDatas[index] = mySelfData + IsHave = true + break + end + end + if not IsHave then + table.insert(WorldBossMySelfData.AttributeAreaDatas, mySelfData) + end + end + + function XWorldBossManager.CheckWorldBossActivityReset() + if CS.XFight.IsRunning or XLuaUiManager.IsUiLoad("UiLoading") then + return + end + local notInActivity = not XWorldBossManager.IsInActivity() + if notInActivity then + XUiManager.TipMsg(CS.XTextManager.GetText("WorldBossNotInActivityTime")) + XScheduleManager.ScheduleOnce(function() + XLuaUiManager.RunMain() + end, 200) + end + end + + function XWorldBossManager.CheckWorldBossActivityRedPoint() + local worldBossActivity = XWorldBossManager.GetCurWorldBossActivity() + local attributeAreaIds = worldBossActivity:GetAttributeAreaIds() + local bossAreaIds = worldBossActivity:GetBossAreaIds() + local IsHaveRed = false + for _, areaId in pairs(attributeAreaIds) do + IsHaveRed = XWorldBossManager.CheckWorldBossAttributeArearRedPoint(areaId) + if IsHaveRed then + return true + end + end + for _, areaId in pairs(bossAreaIds) do + IsHaveRed = XWorldBossManager.CheckWorldBossBossArearRedPoint(areaId) + if IsHaveRed then + return true + end + end + end + + function XWorldBossManager.CheckWorldBossBossArearRedPoint(areaId) + local IsHaveRed = false + local areaData = XWorldBossManager.GetBossAreaById(areaId) + local phasesRewardDatas = areaData:GetPhasesRewardEntityDic() + for _, phasesRewardData in pairs(phasesRewardDatas) do + local IsCanGet = phasesRewardData:GetIsCanGet() + local IsGeted = phasesRewardData:GetIsGeted() + IsHaveRed = IsCanGet and not IsGeted + if IsHaveRed then + return true + end + end + return IsHaveRed + end + + function XWorldBossManager.CheckWorldBossAttributeArearRedPoint(areaId) + local IsHaveRed = false + local areaData = XWorldBossManager.GetAttributeAreaById(areaId) + local stageIds = areaData:GetStageIds() + + local IsCanGet = areaData:GetIsAreaFinish() + local IsGeted = areaData:GetIsRewardGeted() + + IsHaveRed = IsCanGet and not IsGeted + if IsHaveRed then + return true + end + + for _, stageId in pairs(stageIds) do + IsHaveRed = XWorldBossManager.CheckWorldBossStageRedPoint(areaId, stageId) + if IsHaveRed then + return true + end + end + return IsHaveRed + end + + function XWorldBossManager.CheckWorldBossStageRedPoint(areaId, stageId) + local stageData = XWorldBossManager.GetAttributeStageById(areaId, stageId) + local rewardId = stageData:GetFinishReward() + local IsCanGet = stageData:GetIsFinish() + local IsGeted = stageData:GetIsRewardGeted() + local IsHaveRed = IsCanGet and not IsGeted and rewardId > 0 + return IsHaveRed + end + + function XWorldBossManager.CheckAnyTaskFinished() + local taskDatas = XDataCenter.TaskManager.GetWorldBossFullTaskList() + if not taskDatas then + return false + end + + local achieved = XDataCenter.TaskManager.TaskState.Achieved + for _, taskData in pairs(taskDatas or {}) do + if taskData.State == achieved then + return true + end + end + + return false + end + + ---------------------------------------stage相关-------------------------------------->>> + function XWorldBossManager.InitStageInfo() + for _, activity in pairs(WorldBossActivityDic) do + local attributeAreaDic = activity:GetAttributeAreaEntityDic() + local bossAreaDic = activity:GetBossAreaEntityDic() + for _, attributeArea in pairs(attributeAreaDic) do + for _, stageId in pairs(attributeArea:GetStageIds()) do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + stageInfo.Type = XDataCenter.FubenManager.StageType.WorldBoss + stageInfo.ChapterName = attributeArea:GetName() + stageInfo.AreaType = XWorldBossConfigs.AreaType.Attribute + end + end + + for _, bossArea in pairs(bossAreaDic) do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(bossArea:GetStageId()) + stageInfo.Type = XDataCenter.FubenManager.StageType.WorldBoss + stageInfo.ChapterName = bossArea:GetName() + stageInfo.AreaType = XWorldBossConfigs.AreaType.Boss + end + end + end + + function XWorldBossManager.FinishFight(settle) + if settle.IsWin then + XLuaUiManager.Open("UiSettleWinWorldBoss", settle) + else + XLuaUiManager.Open("UiSettleLose", settle) + end + end + + function XWorldBossManager.OpenWorldMainWind() + XWorldBossManager.GetWorldBossGlobalData(function() + XWorldBossManager.GetWorldBossReport(function() + XLuaUiManager.Open("UiWorldBossMain") + end) + end) + end + + ---------------------------------------stage相关---------------------------------------<<< + function XWorldBossManager.CheckIsNewStoryID(Id) + if XSaveTool.GetData(string.format("%d%s%s", XPlayer.Id, "WorldBossStory", Id)) then + return false + end + return true + end + + function XWorldBossManager.MarkStoryID(Id) + if not XSaveTool.GetData(string.format("%d%s%s", XPlayer.Id, "WorldBossStory", Id)) then + XSaveTool.SaveData(string.format("%d%s%s", XPlayer.Id, "WorldBossStory", Id), Id) + end + end + + function XWorldBossManager.GetWorldBossGlobalData(cb) + local now = XTime.GetServerNowTimestamp() + local syscTime = LastSyncGlobaldataTime + + if syscTime and now - syscTime < SYNC_GLOBALDATA_SECOND then + if cb then + cb() + end + return + end + + XNetwork.Call(METHOD_NAME.GetWorldBossGlobalDataRequest, {}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XWorldBossManager.UpdateWorldBossGlobalData(res.GlobalData) + XWorldBossManager.UpdateWorldBossActivity() + LastSyncGlobaldataTime = XTime.GetServerNowTimestamp() + XEventManager.DispatchEvent(XEventId.EVENT_WORLDBOSS_SYNCDATA) + if cb then cb() end + end) + end + + function XWorldBossManager.GetAttributeAreaReward(areaId, cb) + XNetwork.Call(METHOD_NAME.GetAttributeAreaRewardRequest, { AreaId = areaId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XUiManager.OpenUiObtain(res.RewardGoodsList) + if cb then cb() end + end) + end + + function XWorldBossManager.GetAttributeAreaStageReward(areaId, stageId, cb) + XNetwork.Call(METHOD_NAME.GetAttributeAreaStageRewardRequest, { AreaId = areaId, StageId = stageId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XUiManager.OpenUiObtain(res.RewardGoodsList) + if cb then cb() end + end) + end + + function XWorldBossManager.GetBossPhasesReward(bossAreaId, bossPhasesId, cb) + XNetwork.Call(METHOD_NAME.GetBossPhasesRewardRequest, { AreaId = bossAreaId, PhasesId = bossPhasesId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XUiManager.OpenUiObtain(res.RewardGoodsList) + if cb then cb() end + end) + end + + function XWorldBossManager.WorldBossShopBuy(bossShopId, cb) + XNetwork.Call(METHOD_NAME.WorldBossShopBuyRequest, { ShopId = bossShopId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XUiManager.OpenUiObtain(res.RewardGoodsList) + if cb then cb() end + end) + end + + function XWorldBossManager.GetAttributeAreaRank(areaId, cb) + XNetwork.Call(METHOD_NAME.WorldBossAttributeAreaRankRequest, { AreaId = areaId }, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XWorldBossManager.SetAreaRankData(res) + if cb then cb() end + end) + end + + function XWorldBossManager.GetWorldBossReport(cb) + XNetwork.Call(METHOD_NAME.GetWorldBossReportRequest, {}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XEventManager.DispatchEvent(XEventId.EVENT_WORLDBOSS_REPORT) + XWorldBossManager.SetWorldBossReportList(res.ReportList) + if cb then cb() end + end) + end + + XWorldBossManager.Init() + return XWorldBossManager +end + +XRpc.NotifyWorldBossData = function(data) + XDataCenter.WorldBossManager.UpdateWorldBossMySelfData(data.SingleData) + XDataCenter.WorldBossManager.UpdateWorldBossGlobalData(data.GlobalData) + XDataCenter.WorldBossManager.UpdateWorldBossActivity() + XEventManager.DispatchEvent(XEventId.EVENT_WORLDBOSS_TASK_RESET) +end + +XRpc.NotifyWorldBossAttributeAreaData = function(data) + XDataCenter.WorldBossManager.UpdateMySelfAttributeAreaData(data.AttributeAreaData) + XDataCenter.WorldBossManager.UpdateWorldBossActivity() +end + +XRpc.NotifyWorldBossBossAreaData = function(data) + XDataCenter.WorldBossManager.UpdateMySelfBossAreaData(data.BossAreaData) + XDataCenter.WorldBossManager.UpdateWorldBossActivity() +end \ No newline at end of file diff --git a/Resources/Scripts/XMerge/XMergeAppEventChecker.lua b/Resources/Scripts/XMerge/XMergeAppEventChecker.lua new file mode 100644 index 00000000..3a603d52 --- /dev/null +++ b/Resources/Scripts/XMerge/XMergeAppEventChecker.lua @@ -0,0 +1,73 @@ +--- +--- Generated by EmmyLua(https://github.com/EmmyLua) +--- Created by admin. +--- DateTime: 2021/2/1 16:19 +--- + +XMergeAppEventChecker = {} +local this = XMergeAppEventChecker +local Helper = CS.XMergeHelper + +local checkCsharpList = +{ + {"XApplication/SplashController.cs", "APPEVENT_LOGO_IOS"}, + {"XApplication/SplashController.cs", "APPEVENT_WORDS"}, + {"XManager/XFileManager.cs", "APPEVENT_VERSION_CHECKING_START"}, + {"XManager/XFileManager.cs", "APPEVENT_VERSION_CHECKING_END"}, + {"XManager/XFileManager.cs", "APPEVENT_RESOURCE_DOWNLOAD_START"}, + {"XApplication/XApplication.cs", "APPEVENT_GAME_INITIALIZE"}, + {"XApplication/XObbChecker.cs", "APPEVENT_SKIP_PV"}, +} + +local checkLuaList = +{ + {"XUi/XUiLogin/XUiLoginAgreePanel.lua", "APPEVENT_GAME_PRIVACY"}, + {"XUi/XUiLogin/XUiLogin.lua", "APPEVENT_CHANGE_ACCOUNT"}, + {"XManager/XHgSdkManager.lua", "APPEVENT_SDK_INITIALIZE"}, + {"XUi/XUiLogin/XUiLogin.lua", "APPEVENT_SDK_LOGIN"}, + {"XUi/XUiLogin/XUiLogin.lua", "APPEVENT_ANIM_START_1"}, + {"XUi/XUiLogin/XUiLogin.lua", "APPEVENT_ANIM_START_2"}, + {"XUi/XUiLogin/XUiLogin.lua", "APPEVENT_COMPLETED_REGISTRATION_1"}, + {"XUi/XUiLogin/XUiLogin.lua", "APPEVENT_COMPLETED_REGISTRATION_2"}, + {"XManager/XFubenManager.lua", "APPEVENT_FIRST_BATTLE_FINISH"}, + {"XManager/XFubenManager.lua", "APPEVENT_SECOND_BATTLE_END"}, + {"XManager/XGuideManager.lua", "APPEVENT_THIRD_BATTLE_END"}, + {"XManager/XTaskManager.lua", "APPEVENT_NEWBEE_AND_TASK"}, + {"XManager/XPayManager.lua", "APPEVENT_PURCHASED"}, + {"XManager/XPayManager.lua", "APPEVENT_FIRST_BUY"}, + {"XUi/XUiDraw/XUiDrawControl.lua", "APPEVENT_DRAWS_ROLE_10_1"}, + {"XUi/XUiDraw/XUiDrawControl.lua", "APPEVENT_DRAWS_ROLE_10_2"}, + {"XUi/XUiDraw/XUiDrawControl.lua", "APPEVENT_DRAWS_WEAPON_10_1"}, + {"XUi/XUiDraw/XUiDrawControl.lua", "APPEVENT_DRAWS_WEAPON_10_2"}, + {"XUi/XUiDraw/XUiDrawControl.lua", "APPEVENT_DRAWS_LIMIT_10"}, + {"XManager/XPurchaseManager.lua", "APPEVENT_TOTAL_PURCHASE"}, + {"XManager/XPayManager.lua", "APPEVENT_REDEEMED_AND_MONTHCARD"}, + {"XEntity/XPlayer.lua", "APPEVENT_LEVEL"}, + {"XUi/XUiTask/XDynamicDailyTask.lua", "APPEVENT_WAR_AND_PAINGAGE"}, + {"XManager/XMedalManager.lua", "APPEVENT_BADGE"}, + +} + +function this.Check() + for _, v in pairs(checkCsharpList) do + if not v[1] or not v[2] then + XLog.Error("请检查XMergeAppEventChecker CheckCsharpList 确保数组中都含有两个元素") + else + local r = Helper.CheckCSharp(v[1], "CheckPoint:\\s+" .. v[2]) + if not r then + XLog.Error("" .. v[1] .. " 文件缺少埋点 " .. v[2] .. "") + end + end + end + + for _, v in pairs(checkLuaList) do + if not v[1] or not v[2] then + XLog.Error("请检查XMergeAppEventChecker CheckLuaList 确保数组中都含有两个元素") + else + local r = Helper.CheckLua(v[1], "CheckPoint:\\s+" .. v[2]) + if not r then + XLog.Error("" .. v[1] .. " 文件缺少埋点 " .. v[2] .. "") + end + end + end +end \ No newline at end of file diff --git a/Resources/Scripts/XMerge/XMergeChecker.lua b/Resources/Scripts/XMerge/XMergeChecker.lua new file mode 100644 index 00000000..e949cc28 --- /dev/null +++ b/Resources/Scripts/XMerge/XMergeChecker.lua @@ -0,0 +1,16 @@ +--- +--- Generated by EmmyLua(https://github.com/EmmyLua) +--- Created by admin. +--- DateTime: 2021/2/1 15:09 +--- + +XMergeChecker = {} + +function XMergeChecker.Check() + XLog.Error("开始检查搬运情况"); + XLog.Error("============="); + CS.XMergeChecker.Check() + XMergeAppEventChecker.Check() + XLog.Error("============="); + XLog.Error("搬运情况检查结束"); +end \ No newline at end of file diff --git a/Resources/Scripts/XMovieActions/XMovieActionActorAppear.lua b/Resources/Scripts/XMovieActions/XMovieActionActorAppear.lua new file mode 100644 index 00000000..49c2df9f --- /dev/null +++ b/Resources/Scripts/XMovieActions/XMovieActionActorAppear.lua @@ -0,0 +1,61 @@ +local vector = CS.UnityEngine.Vector3 + +local XMovieActionActorAppear = XClass(XMovieActionBase, "XMovieActionActorAppear") + +function XMovieActionActorAppear:Ctor(actionData) + local params = actionData.Params + local paramToNumber = XDataCenter.MovieManager.ParamToNumber + + local actorIndex = paramToNumber(params[1]) + if actorIndex == 0 or actorIndex > XMovieConfigs.MAX_ACTOR_NUM then + XLog.Error("XMovieActionActorAppear:Ctor error:ActorIndex is not match, actionId is " .. self.ActionId) + return + end + self.ActorIndex = actorIndex + + self.ActorId = paramToNumber(params[2]) + self.FaceId = paramToNumber(params[3]) + + local posX = paramToNumber(params[4]) + local posY = paramToNumber(params[5]) + local posZ = paramToNumber(params[6]) + self.FixPos = vector(XDataCenter.MovieManager.Fit(posX), posY, posZ) + + self.SkipRoleAnim = paramToNumber(params[7]) ~= 0 +end + +function XMovieActionActorAppear:OnInit() + local actor = self.UiRoot:GetActor(self.ActorIndex) + self.Record = { + ActorId = actor:GetActorId(), + FaceId = actor:GetFaceId(), + ImagePos = actor:GetImagePos(), + IsHide = actor:IsHide() + } + actor:UpdateActor(self.ActorId) + actor:SetImagePos(self.FixPos) + actor:SetFace(self.FaceId) +end + +function XMovieActionActorAppear:OnRunning() + local actor = self.UiRoot:GetActor(self.ActorIndex) + actor:PlayAnimEnable(self.SkipRoleAnim) +end + +function XMovieActionActorAppear:OnUndo() + local actor = self.UiRoot:GetActor(self.ActorIndex) + if self.Record.IsHide then + actor:PlayAnimDisable(self.SkipRoleAnim) + else + if self.Record.ActorId ~= 0 then + actor:UpdateActor(self.Record.ActorId) + end + actor:SetFace(self.Record.FaceId) + if self.Record.ImagePos then + actor:SetImagePos(self.Record.ImagePos) + end + end + +end + +return XMovieActionActorAppear \ No newline at end of file diff --git a/Resources/Scripts/XMovieActions/XMovieActionActorChangeFace.lua b/Resources/Scripts/XMovieActions/XMovieActionActorChangeFace.lua new file mode 100644 index 00000000..8c62bb2d --- /dev/null +++ b/Resources/Scripts/XMovieActions/XMovieActionActorChangeFace.lua @@ -0,0 +1,26 @@ +local XMovieActionActorChangeFace = XClass(XMovieActionBase, "XMovieActionActorChangeFace") + +function XMovieActionActorChangeFace:Ctor(actionData) + local params = actionData.Params + local paramToNumber = XDataCenter.MovieManager.ParamToNumber + + local actorIndex = paramToNumber(params[1]) + if actorIndex == 0 or actorIndex > XMovieConfigs.MAX_ACTOR_NUM then + XLog.Error("XMovieActionActorChangeFace:Ctor error:ActorIndex is not match, actionId is " .. self.ActionId) + return + end + self.ActorIndex = actorIndex + + self.FaceId = paramToNumber(params[2]) +end + +function XMovieActionActorChangeFace:OnRunning() + local actor = self.UiRoot:GetActor(self.ActorIndex) + actor:SetFace(self.FaceId) +end + +function XMovieActionActorChangeFace:OnSkip() + self:OnRunning() +end + +return XMovieActionActorChangeFace \ No newline at end of file diff --git a/Resources/Scripts/XMovieActions/XMovieActionActorDisappear.lua b/Resources/Scripts/XMovieActions/XMovieActionActorDisappear.lua new file mode 100644 index 00000000..3b5ddff2 --- /dev/null +++ b/Resources/Scripts/XMovieActions/XMovieActionActorDisappear.lua @@ -0,0 +1,49 @@ +local XMovieActionActorDisappear = XClass(XMovieActionBase, "XMovieActionActorDisappear") + +function XMovieActionActorDisappear:Ctor(actionData) + local params = actionData.Params + local paramToNumber = XDataCenter.MovieManager.ParamToNumber + + self.ActorIndexs = {} + self.Record = {} + for i = 1, XMovieConfigs.MAX_ACTOR_NUM do + local actorIndex = paramToNumber(params[i]) + if actorIndex ~= 0 then + self.ActorIndexs[actorIndex] = actorIndex + end + end + self.SkipAnim = paramToNumber(params[6]) ~= 0 +end + +function XMovieActionActorDisappear:OnInit() + for actorIndex,_ in pairs(self.ActorIndexs) do + local actor = self.UiRoot:GetActor(actorIndex) + self.Record[actorIndex] = {} + self.Record[actorIndex].ActorId = actor:GetActorId() + self.Record[actorIndex].FaceId = actor:GetFaceId() + self.Record[actorIndex].ImgPos = actor:GetImagePos() + end +end + +function XMovieActionActorDisappear:OnRunning() + for _, actorIndex in pairs(self.ActorIndexs) do + local actor = self.UiRoot:GetActor(actorIndex) + actor:PlayAnimDisable(self.SkipAnim) + end +end + +function XMovieActionActorDisappear:OnUndo() + for _, actorIndex in pairs(self.ActorIndexs) do + local actor = self.UiRoot:GetActor(actorIndex) + if self.Record[actorIndex].ActorId ~= 0 then + actor:UpdateActor(self.Record[actorIndex].ActorId) + end + if self.Record[actorIndex].ImgPos then + actor:SetImagePos(self.Record[actorIndex].ImgPos) + end + actor:SetFace(self.Record[actorIndex].FaceId) + actor:PlayAnimEnable(self.SkipAnim) + end +end + +return XMovieActionActorDisappear \ No newline at end of file diff --git a/Resources/Scripts/XMovieActions/XMovieActionActorShift.lua b/Resources/Scripts/XMovieActions/XMovieActionActorShift.lua new file mode 100644 index 00000000..4fc1ed3c --- /dev/null +++ b/Resources/Scripts/XMovieActions/XMovieActionActorShift.lua @@ -0,0 +1,45 @@ +local mathMax = math.max +local vector = CS.UnityEngine.Vector3 +local LineAnimCurve = CS.UnityEngine.AnimationCurve.Linear(0, 0, 1, 1) + +local XMovieActionActorShift = XClass(XMovieActionBase, "XMovieActionActorShift") + +function XMovieActionActorShift:Ctor(actionData) + local params = actionData.Params + local paramToNumber = XDataCenter.MovieManager.ParamToNumber + + local actorIndex = paramToNumber(params[1]) + if actorIndex == 0 or actorIndex > XMovieConfigs.MAX_ACTOR_NUM then + XLog.Error("XMovieActionActorShift:Ctor error:ActorIndex is not match, actionId is " .. self.ActionId) + return + end + self.ActorIndex = actorIndex + + self.Duration = paramToNumber(params[2]) + + local posX = paramToNumber(params[3]) + local posY = paramToNumber(params[4]) + local posZ = paramToNumber(params[5]) + self.TargetPos = vector(XDataCenter.MovieManager.Fit(posX), posY, posZ) +end + +function XMovieActionActorShift:OnRunning() + local actor = self.UiRoot:GetActor(self.ActorIndex) + local startPos = actor:GetImagePos() + self.Record = { + OriginPos = startPos + } + local targetPos = self.TargetPos + local transPos = targetPos - startPos + local duration = mathMax(0, self.Duration) + XUiHelper.Tween(duration, function(t) + actor:SetImagePos(startPos + transPos * LineAnimCurve:Evaluate(t)) + end) +end + +function XMovieActionActorShift:OnUndo() + local actor = self.UiRoot:GetActor(self.ActorIndex) + actor:SetImagePos(self.Record.OriginPos) +end + +return XMovieActionActorShift \ No newline at end of file diff --git a/Resources/Scripts/XMovieActions/XMovieActionAnimationPlay.lua b/Resources/Scripts/XMovieActions/XMovieActionAnimationPlay.lua new file mode 100644 index 00000000..ba4eb6d2 --- /dev/null +++ b/Resources/Scripts/XMovieActions/XMovieActionAnimationPlay.lua @@ -0,0 +1,22 @@ +local XMovieActionAnimationPlay = XClass(XMovieActionBase, "XMovieActionAnimationPlay") + +function XMovieActionAnimationPlay:Ctor(actionData) + local params = actionData.Params + self.AnimName = params[1] +end + +function XMovieActionAnimationPlay:OnRunning() + local animName = self.AnimName + local anim = self.UiRoot[animName] + if not anim then + XLog.Error("XMovieActionAnimationPlay:OnRunning error: Animation not Exist, animName is: " .. animName) + return + end + + anim.gameObject:SetActiveEx(true) + anim:PlayTimelineAnimation(function() + anim.gameObject:SetActiveEx(false) + end) +end + +return XMovieActionAnimationPlay \ No newline at end of file diff --git a/Resources/Scripts/XMovieActions/XMovieActionAudioInterrupt.lua b/Resources/Scripts/XMovieActions/XMovieActionAudioInterrupt.lua new file mode 100644 index 00000000..1574f275 --- /dev/null +++ b/Resources/Scripts/XMovieActions/XMovieActionAudioInterrupt.lua @@ -0,0 +1,15 @@ +local XMovieActionInterrupt = XClass(XMovieActionBase, "XMovieActionInterrupt") + +function XMovieActionInterrupt:Ctor(actionData) + local params = actionData.Params + local paramToNumber = XDataCenter.MovieManager.ParamToNumber + + self.CueId = paramToNumber(params[1]) +end + +function XMovieActionInterrupt:OnRunning() + XSoundManager.Stop(self.CueId) +end + + +return XMovieActionInterrupt \ No newline at end of file diff --git a/Resources/Scripts/XMovieActions/XMovieActionBase.lua b/Resources/Scripts/XMovieActions/XMovieActionBase.lua new file mode 100644 index 00000000..d51552c0 --- /dev/null +++ b/Resources/Scripts/XMovieActions/XMovieActionBase.lua @@ -0,0 +1,238 @@ +local CSXScheduleManagerScheduleOnce = XScheduleManager.ScheduleOnce +local CSXScheduleManagerUnSchedule = XScheduleManager.UnSchedule + +local ActionStatus = { + UNINIIALIZED = "UNINIIALIZED", + ENTER = "ENTER", + RUNNING = "RUNNING", + BLOCK = "BLOCK", + EXIT = "EXIT", + TERMINATED = "TERMINATED", +} + +local _ActiveActionCount = 0 --记录所有已激活剧情节点,用于判断退出剧情后所有节点清理行为完全结束的状态 + +XMovieActionBase = XClass(nil, "XMovieActionBase") + +function XMovieActionBase:Ctor(actionData) + local paramToNumber = XDataCenter.MovieManager.ParamToNumber + self.Status = ActionStatus.UNINIIALIZED + self.ActionId = actionData.ActionId + self.IsActionBlock = paramToNumber(actionData.IsBlock) ~= 0 + self.IsEnd = actionData.IsEnd ~= 0 + self.NextActionId = actionData.NextActionId + self.BeginAnim = actionData.BeginAnim + self.EndAnim = actionData.EndAnim + self.BeginDelay = actionData.BeginDelay + self.EndDelay = actionData.EndDelay + self.Type = actionData.Type + + XEventManager.AddEventListener(XEventId.EVENT_MOVIE_UI_OPEN, self.InitUiRoot, self) + XEventManager.AddEventListener(XEventId.EVENT_MOVIE_UI_DESTROY, self.ClearUiRoot, self) + XEventManager.AddEventListener(XEventId.EVENT_MOVIE_AUTO_PLAY, self.OnSwitchAutoPlay, self) +end + +function XMovieActionBase:GetNextActionId() + return self.NextActionId +end + +function XMovieActionBase:GetSelectedActionId() + return 0 +end + +function XMovieActionBase:GetDelaySelectActionId() + return 0 +end + +function XMovieActionBase:GetResumeActionId() + return 0 +end + +function XMovieActionBase:GetBeginAnim() + return self.BeginAnim +end + +function XMovieActionBase:GetEndAnim() + return self.EndAnim +end + +function XMovieActionBase:GetBeginDelay() + return self.BeginDelay +end + +function XMovieActionBase:GetEndDelay() + return self.EndDelay +end + +function XMovieActionBase:GetType() + return self.Type +end + +function XMovieActionBase:IsBlock() + return self.IsActionBlock +end + +function XMovieActionBase:IsEnding() + return self.IsEnd +end + +function XMovieActionBase:IsWaiting() + return self.Lock +end + +function XMovieActionBase:InitUiRoot(uiRoot) + _ActiveActionCount = _ActiveActionCount + 1 + + self.UiRoot = uiRoot + self:OnUiRootInit(uiRoot) +end + +function XMovieActionBase:ClearUiRoot() + self.UiRoot = {} + if self.DelayId then + CSXScheduleManagerUnSchedule(self.DelayId) + self.DelayId = nil + end + self.Status = ActionStatus.UNINIIALIZED + self:OnUiRootDestroy() + + _ActiveActionCount = _ActiveActionCount - 1 + if _ActiveActionCount == 0 then + XEventManager.DispatchEvent(XEventId.EVENT_MOVIE_UI_CLOSED) + end +end + +function XMovieActionBase:Enter() + if self.Status ~= ActionStatus.ENTER then return end + self:OnInit() + self:ChangeStatus(self:GetBeginDelay(), self:GetBeginAnim()) +end + +function XMovieActionBase:BlockSelf() + if self.Status ~= ActionStatus.BLOCK then return end +end + +function XMovieActionBase:Run() + if self.Status ~= ActionStatus.RUNNING then return end + self:OnRunning() + self:ChangeStatus() +end + +function XMovieActionBase:Exit() + if self.Status ~= ActionStatus.EXIT then return end + self:ChangeStatus(self:GetEndDelay(), self:GetEndAnim()) +end + +function XMovieActionBase:Destroy() + if self.Status ~= ActionStatus.TERMINATED then return end + self.Status = ActionStatus.UNINIIALIZED + self:OnDestroy() + return true +end + +function XMovieActionBase:ChangeStatus(delay, animName) + self.Lock = true + + local changeFunc = function() + self.Lock = nil + if XTool.UObjIsNil(self.UiRoot.GameObject) then return end + + if self.Status == ActionStatus.UNINIIALIZED then + self.Status = ActionStatus.ENTER + self:Enter() + elseif self.Status == ActionStatus.ENTER then + self.Status = ActionStatus.RUNNING + self:Run() + elseif self.Status == ActionStatus.RUNNING then + if self:IsBlock() then + self.Status = ActionStatus.BLOCK + self:BlockSelf() + else + self.Status = ActionStatus.EXIT + self:Exit() + end + elseif self.Status == ActionStatus.BLOCK then + self.Status = ActionStatus.EXIT + self:Exit() + elseif self.Status == ActionStatus.EXIT then + self.Status = ActionStatus.TERMINATED + self:OnExit() + XEventManager.DispatchEvent(XEventId.EVENT_MOVIE_BREAK_BLOCK) + end + end + + local animCb = function() + if delay and delay ~= 0 then + self.DelayId = self.DelayId or CSXScheduleManagerScheduleOnce(function() + self.DelayId = nil + changeFunc() + end, delay) + else + changeFunc() + end + end + + if animName and animName ~= "NoAnim" then + if XTool.UObjIsNil(self.UiRoot.GameObject) then return end + + local anim = self.UiRoot[animName] + if not anim then + XLog.Error("animName error: animName is: " .. animName) + return + end + + anim.gameObject:SetActiveEx(true) + if not anim.gameObject.activeInHierarchy then return end + anim:PlayTimelineAnimation(function() + XLuaUiManager.SetMask(false) + anim.gameObject:SetActiveEx(false) + animCb() + end, function() + XLuaUiManager.SetMask(true) + end) + else + animCb() + end +end + + + +function XMovieActionBase:OnUiRootInit() + +end + +function XMovieActionBase:OnUiRootDestroy() + +end + +function XMovieActionBase:OnInit() + +end + +function XMovieActionBase:OnRunning() + +end + +function XMovieActionBase:OnExit() + +end + +function XMovieActionBase:OnDestroy() + +end + +function XMovieActionBase:OnSwitchAutoPlay() + +end + +function XMovieActionBase:CanContinue() + return true +end + +function XMovieActionBase:OnReset() + self.Status = ActionStatus.UNINIIALIZED +end + +function XMovieActionBase:OnUndo() + +end \ No newline at end of file diff --git a/Resources/Scripts/XMovieActions/XMovieActionBgSwitch.lua b/Resources/Scripts/XMovieActions/XMovieActionBgSwitch.lua new file mode 100644 index 00000000..bd1d442a --- /dev/null +++ b/Resources/Scripts/XMovieActions/XMovieActionBgSwitch.lua @@ -0,0 +1,84 @@ +local DefaultPos = CS.UnityEngine.Vector3(0, 0, 0) +local DefaultScale = CS.UnityEngine.Vector3(1.1, 1.1, 1.1) +local DefaultAspectRatio = 1 + +local AspectRatioFitter +local AspectRatioFitter2 +local CanvasGroup +local CanvasGroupBg + +local XMovieActionBgSwitch = XClass(XMovieActionBase, "XMovieActionBgSwitch") + +function XMovieActionBgSwitch:Ctor(actionData) + local params = actionData.Params + local paramToNumber = XDataCenter.MovieManager.ParamToNumber + self.Record = {} + self.BgPath = params[1] + self.AspectRatioPercent = paramToNumber(params[2]) + self.NeedSupportAnim = self.BeginAnim == "RImgBg2Enable" + + local param = params[3] + self.BgAlpha = param and param ~= "" and tonumber(param) or nil +end + +function XMovieActionBgSwitch:OnUiRootInit() + AspectRatioFitter = self.UiRoot.RImgBg1.transform:GetComponent("XAspectRatioFitter") + AspectRatioFitter2 = self.UiRoot.RImgBg2.transform:GetComponent("XAspectRatioFitter") + CanvasGroup = self.UiRoot.RImgBg1.transform:GetComponent("CanvasGroup") + DefaultAspectRatio = AspectRatioFitter.aspectRatio + CanvasGroupBg = self.UiRoot.Transform:FindTransform("FullScreenBackground"):GetComponent("CanvasGroup") +end + +function XMovieActionBgSwitch:OnUiRootDestroy() + CanvasGroup = nil + AspectRatioFitter = nil + AspectRatioFitter2 = nil + DefaultAspectRatio = 1 +end + +function XMovieActionBgSwitch:OnInit() + local bgPath = self.BgPath + local aspectRatioPercent = self.AspectRatioPercent + local ratio = aspectRatioPercent > 0 and DefaultAspectRatio * aspectRatioPercent or DefaultAspectRatio + local rImgBg = self.UiRoot.RImgBg1 + local loadRawImage = rImgBg.gameObject:GetComponent("XLoadRawImage") + if loadRawImage then + self.Record.BgPath = loadRawImage.AssetUrl + end + rImgBg.rectTransform.anchoredPosition3D = DefaultPos + rImgBg.transform.localScale = DefaultScale + AspectRatioFitter.aspectRatio = ratio + rImgBg.gameObject:SetActiveEx(true) + + if self.NeedSupportAnim then + rImgBg = self.UiRoot.RImgBg2 + rImgBg:SetRawImage(bgPath) + rImgBg.transform.localScale = DefaultScale + rImgBg.rectTransform.anchoredPosition3D = DefaultPos + AspectRatioFitter2.aspectRatio = ratio + rImgBg.gameObject:SetActiveEx(true) + else + rImgBg:SetRawImage(bgPath) + end + + local bgAlpha = self.BgAlpha + if bgAlpha then + CanvasGroupBg.alpha = bgAlpha + end +end + +function XMovieActionBgSwitch:OnExit() + if self.NeedSupportAnim then + CanvasGroup.alpha = 1 + self.UiRoot.RImgBg1:SetRawImage(self.BgPath) + self.UiRoot.RImgBg2.gameObject:SetActiveEx(false) + end +end + +function XMovieActionBgSwitch:OnUndo() + if self.Record.BgPath then + self.UiRoot.RImgBg1:SetRawImage(self.Record.BgPath) + end +end + +return XMovieActionBgSwitch \ No newline at end of file diff --git a/Resources/Scripts/XMovieActions/XMovieActionDelaySkip.lua b/Resources/Scripts/XMovieActions/XMovieActionDelaySkip.lua new file mode 100644 index 00000000..11c215d7 --- /dev/null +++ b/Resources/Scripts/XMovieActions/XMovieActionDelaySkip.lua @@ -0,0 +1,14 @@ +local XMovieActionDelaySkip = XClass(XMovieActionBase, "XMovieActionDelaySkip") + +function XMovieActionDelaySkip:Ctor(actionData) + local params = actionData.Params + local paramToNumber = XDataCenter.MovieManager.ParamToNumber + + self.DelaySelectKey = paramToNumber(params[1]) +end + +function XMovieActionDelaySkip:GetDelaySelectActionId() + return XDataCenter.MovieManager.GetDelaySelectActionId(self.DelaySelectKey) +end + +return XMovieActionDelaySkip \ No newline at end of file diff --git a/Resources/Scripts/XMovieActions/XMovieActionDialog.lua b/Resources/Scripts/XMovieActions/XMovieActionDialog.lua new file mode 100644 index 00000000..97cfc0d9 --- /dev/null +++ b/Resources/Scripts/XMovieActions/XMovieActionDialog.lua @@ -0,0 +1,118 @@ +local pairs = pairs +local stringUtf8Len = string.Utf8Len + +local XMovieActionDialog = XClass(XMovieActionBase, "XMovieActionDialog") + +function XMovieActionDialog:Ctor(actionData) + local params = actionData.Params + local paramToNumber = XDataCenter.MovieManager.ParamToNumber + + self.SkipRoleAnim = paramToNumber(params[1]) ~= 0 + self.RoleName = XDataCenter.MovieManager.ReplacePlayerName(params[2]) + local dialogContent = XDataCenter.MovieManager.ReplacePlayerName(params[3]) + if not dialogContent or dialogContent == "" then + XLog.Error("XMovieActionDialog:OnRunning error:DialogContent is empty, actionId is: " .. self.ActionId) + return + end + self.DialogContent = dialogContent + self.SpeakerIndexDic = {} + for i = 1, XMovieConfigs.MAX_ACTOR_ROLE_NUM do + local actorIndex = paramToNumber(params[i + 3]) + if actorIndex ~= 0 then + self.SpeakerIndexDic[actorIndex] = true + end + end +end + +function XMovieActionDialog:GetEndDelay() + return self.IsAutoPlay and XMovieConfigs.AutoPlayDelay or 0 +end + +function XMovieActionDialog:IsBlock() + return true +end + +function XMovieActionDialog:OnInit() + self.IsAutoPlay = XDataCenter.MovieManager.IsAutoPlay() + self.UiRoot.BtnSkipDialog.CallBack = function() self:OnClickBtnSkipDialog() end + self.UiRoot.DialogTypeWriter.CompletedHandle = function() self:OnTypeWriterComplete() end + self.UiRoot.PanelDialog.gameObject:SetActiveEx(true) + self.Record = { + DialogContent = self.UiRoot.TxtWords.text, + IsActive = self.UiRoot.PanelDialog.gameObject.activeSelf + } + local roleName = self.RoleName + local dialogContent = self.DialogContent + self.UiRoot.TxtName.text = roleName + self.UiRoot.TxtWords.text = dialogContent + + self.IsTyping = true + local typeWriter = self.UiRoot.DialogTypeWriter + typeWriter.Duration = stringUtf8Len(dialogContent) * XMovieConfigs.TYPE_WRITER_SPEED + typeWriter:Play() + + self:PlaySpeakerAnim() + XDataCenter.MovieManager.PushInReviewDialogList(roleName, dialogContent) +end + +function XMovieActionDialog:OnDestroy() + self.IsTyping = nil + self.Skipped = nil + self.IsAutoPlay = nil +end + +function XMovieActionDialog:OnClickBtnSkipDialog() + if self.IsTyping then + self.IsTyping = false + self.Skipped = true + self.UiRoot.DialogTypeWriter:Stop() + else + self.Skipped = true + self:OnTypeWriterComplete() + end +end + +function XMovieActionDialog:CanContinue() + return not self.IsTyping +end + +function XMovieActionDialog:OnTypeWriterComplete() + self.IsTyping = false + if self.IsAutoPlay or self.Skipped then + self.Skipped = nil + local ignoreLock = self.IsAutoPlay + XEventManager.DispatchEvent(XEventId.EVENT_MOVIE_BREAK_BLOCK, ignoreLock) + end +end + +function XMovieActionDialog:OnSwitchAutoPlay(autoPlay) + self.IsAutoPlay = autoPlay + if autoPlay and self.IsTyping == false then + XEventManager.DispatchEvent(XEventId.EVENT_MOVIE_BREAK_BLOCK) + end +end + +function XMovieActionDialog:PlaySpeakerAnim() + local skipAnim = self.SkipRoleAnim + + local speakerIndexDic = self.SpeakerIndexDic + local actors = self.UiRoot.Actors + for index, actor in pairs(actors) do + if not speakerIndexDic[index] then + actor:PlayAnimBack(skipAnim) + else + actor:PlayAnimFront(skipAnim) + end + end +end + + +function XMovieActionDialog:OnUndo() + self.UiRoot.TxtWords.text = self.Record.DialogContent + self.UiRoot.PanelDialog.gameObject:SetActiveEx(self.Record.IsActive) + self.UiRoot.DialogTypeWriter.CompletedHandle = nil + self:OnDestroy() + XDataCenter.MovieManager.RemoveFromReviewDialogList(self.ActionId) +end + +return XMovieActionDialog \ No newline at end of file diff --git a/Resources/Scripts/XMovieActions/XMovieActionEffectPlay.lua b/Resources/Scripts/XMovieActions/XMovieActionEffectPlay.lua new file mode 100644 index 00000000..86573d4d --- /dev/null +++ b/Resources/Scripts/XMovieActions/XMovieActionEffectPlay.lua @@ -0,0 +1,59 @@ +local stringFormat = string.format +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate + +local XMovieActionEffectPlay = XClass(XMovieActionBase, "XMovieActionEffectPlay") + +function XMovieActionEffectPlay:Ctor(actionData) + local params = actionData.Params + local paramToNumber = XDataCenter.MovieManager.ParamToNumber + + self.EffectPath = params[1] + self.EffectLayer = paramToNumber(params[2]) + self.EffectActorIndex = paramToNumber(params[3]) +end + +function XMovieActionEffectPlay:OnInit() + XLuaUiManager.SetMask(true) +end + +function XMovieActionEffectPlay:OnRunning() + local effectPath = self.EffectPath + local effectActorIndex = self.EffectActorIndex + local isActorEffect = effectActorIndex > 0 and effectActorIndex <= XMovieConfigs.MAX_ACTOR_NUM + local effectKey = isActorEffect and stringFormat("%s%s", effectPath, effectActorIndex) or effectPath + + local effectGo = self.UiRoot.EffectGoDic[effectPath] + if not effectGo then + local baseEffectGo, parentGo, effectLayer + + if isActorEffect then + local actor = self.UiRoot:GetActor(effectActorIndex) + baseEffectGo = actor:GetEffectGo() + parentGo = actor:GetEffectParentGo() + else + effectLayer = self.EffectLayer + baseEffectGo = self.UiRoot.PanelEffects[effectLayer] + parentGo = self.UiRoot.PanelEffect + end + + if not baseEffectGo then + XLog.Error("XMovieActionEffectPlay:OnRunning error: can Not find baseEffectGo, effectActorIndex is: " .. effectActorIndex .. ", effectLayer is: " .. effectLayer) + return + end + + effectGo = CSUnityEngineObjectInstantiate(baseEffectGo) + effectGo.transform:SetParent(parentGo, false) + + self.UiRoot.EffectGoDic[effectKey] = effectGo + effectGo.gameObject:LoadUiEffect(effectPath) + else + effectGo.gameObject:SetActiveEx(false) + effectGo.gameObject:SetActiveEx(true) + end +end + +function XMovieActionEffectPlay:OnExit() + XLuaUiManager.SetMask(false) +end + +return XMovieActionEffectPlay \ No newline at end of file diff --git a/Resources/Scripts/XMovieActions/XMovieActionFullScreenDialog.lua b/Resources/Scripts/XMovieActions/XMovieActionFullScreenDialog.lua new file mode 100644 index 00000000..8a3d394c --- /dev/null +++ b/Resources/Scripts/XMovieActions/XMovieActionFullScreenDialog.lua @@ -0,0 +1,187 @@ +local pairs = pairs +local XUiGridSingleDialog = require("XUi/XUiMovie/XUiGridSingleDialog") +local DefaultColor = CS.UnityEngine.Color.white +local PlayingCvInfo + +local XMovieActionFullScreenDialog = XClass(XMovieActionBase, "XMovieActionFullScreenDialog") + +function XMovieActionFullScreenDialog:Ctor(actionData) + local params = actionData.Params + local paramToNumber = XDataCenter.MovieManager.ParamToNumber + + local dialogContent = XDataCenter.MovieManager.ReplacePlayerName(params[1]) + if not dialogContent or dialogContent == "" then + XLog.Error("XMovieActionFullScreenDialog:Ctor error:DialogContent is empty, actionId is: " .. self.ActionId) + return + end + self.DialogContent = dialogContent + self.Color = params[2] + self.Duration = paramToNumber(params[3]) + self.BgPath = params[4] + self.CvId = paramToNumber(params[5]) + self.IsCanSkip = paramToNumber(params[6]) ~= 0 + self.ChangeLinePlus = paramToNumber(params[7]) + self.IsReset = paramToNumber(params[8]) ~= 0 + self.IsClose = paramToNumber(params[9]) ~= 0 +end + +function XMovieActionFullScreenDialog:GetEndDelay() + return self.IsAutoPlay and XMovieConfigs.AutoPlayDelay or 0 +end + +function XMovieActionFullScreenDialog:IsBlock() + return true +end + +function XMovieActionFullScreenDialog:CanContinue() + return not self.IsTyping +end + +function XMovieActionFullScreenDialog:OnUiRootDestroy() + self:StopLastCv() +end + +function XMovieActionFullScreenDialog:OnInit() + self.IsAutoPlay = XDataCenter.MovieManager.IsAutoPlay() + + self.UiRoot.BtnSkiplFullScreenDialog.CallBack = function() self:OnClickBtnSkipDialog() end + self.UiRoot.PanelFullScreenDialog.gameObject:SetActiveEx(true) + self.UiRoot.GridSingleDialog.gameObject:SetActiveEx(false) + + local bgPath = self.BgPath + if bgPath then + self.UiRoot.RImgBgFullScreenDialog:SetRawImage(bgPath) + end + + local dialogContent = self.DialogContent + local grid = self:GetDialogGridFromPool() + grid:Refresh(dialogContent, self.Color, self.Duration, function() + self:OnTypeWriterComplete() + end) + grid.GameObject:SetActiveEx(true) + self.IsTyping = true + + local isEmptyGrid = true + local emptyGridNum = self.ChangeLinePlus + for _ = 1, emptyGridNum do + local tmpGrid = self:GetDialogGridFromPool(isEmptyGrid) + local tmpDialogContent = " " + tmpGrid:Refresh(tmpDialogContent) + tmpGrid.GameObject:SetActiveEx(true) + end + + local imgNext = self.UiRoot.ImgNext + imgNext.transform:SetParent(grid.Transform, false) + imgNext.gameObject:SetActiveEx(false) + + local iconNext = self.UiRoot.IconNext + local color = self.Color and self.Color or DefaultColor + iconNext.color = XUiHelper.Hexcolor2Color(color) + + local cvId = self.CvId + if cvId ~= 0 then + self:StopLastCv() + PlayingCvInfo = XSoundManager.PlaySoundByType(cvId, XSoundManager.SoundType.CV) + end + + local dialogName = "" + XDataCenter.MovieManager.PushInReviewDialogList(dialogName, dialogContent) +end + +function XMovieActionFullScreenDialog:OnDestroy() + self.IsTyping = nil + self.Skipped = nil + self.IsAutoPlay = nil + + if self.IsReset then + self:ClearAllDialogGrids() + end + + if self.IsClose then + self:ClearAllDialogGrids() + self.UiRoot.PanelFullScreenDialog.gameObject:SetActiveEx(false) + end +end + +function XMovieActionFullScreenDialog:OnClickBtnSkipDialog() + if self.IsTyping then + if not self.IsCanSkip then return end + + self.IsTyping = false + self.Skipped = true + + local grid = self:GetCurDialogGrid() + grid:StopTypeWriter() + self.UiRoot.ImgNext.gameObject:SetActiveEx(true) + else + self.Skipped = true + + self:OnTypeWriterComplete() + end +end + +function XMovieActionFullScreenDialog:OnTypeWriterComplete() + self.IsTyping = false + self.UiRoot.ImgNext.gameObject:SetActiveEx(true) + + if self.IsAutoPlay or self.Skipped then + self.Skipped = nil + local ignoreLock = self.IsAutoPlay + XEventManager.DispatchEvent(XEventId.EVENT_MOVIE_BREAK_BLOCK, ignoreLock) + end +end + +function XMovieActionFullScreenDialog:OnSwitchAutoPlay(autoPlay) + self.IsAutoPlay = autoPlay + if autoPlay and self.IsTyping == false then + XEventManager.DispatchEvent(XEventId.EVENT_MOVIE_BREAK_BLOCK) + end +end + +function XMovieActionFullScreenDialog:GetDialogGridFromPool(isEmptyGrid) + local gridList = self.UiRoot.FullScreenDialogGrids + local curIndex = self.UiRoot.FullScreenDialogUsingIndex + + self.CurIndex = not isEmptyGrid and curIndex or self.CurIndex + local grid = gridList[curIndex] + if not grid then + local obj = CS.UnityEngine.Object.Instantiate(self.UiRoot.GridSingleDialog, self.UiRoot.PanleContents) + grid = XUiGridSingleDialog.New(obj) + gridList[curIndex] = grid + end + self.UiRoot.FullScreenDialogUsingIndex = curIndex + 1 + + return grid +end + +function XMovieActionFullScreenDialog:GetCurDialogGrid() + local gridList = self.UiRoot.FullScreenDialogGrids + local curIndex = self.CurIndex + return gridList[curIndex] +end + +function XMovieActionFullScreenDialog:ClearAllDialogGrids() + self.UiRoot.FullScreenDialogUsingIndex = 1 + self.CurIndex = nil + + local gridList = self.UiRoot.FullScreenDialogGrids + for _, grid in pairs(gridList) do + grid:Reset() + grid.GameObject:SetActiveEx(false) + end +end + +function XMovieActionFullScreenDialog:StopLastCv() + if PlayingCvInfo then + if PlayingCvInfo.Playing then + PlayingCvInfo:Stop() + end + PlayingCvInfo = nil + end +end + +function XMovieActionFullScreenDialog:OnUndo() + XDataCenter.MovieManager.RemoveFromReviewDialogList() +end + +return XMovieActionFullScreenDialog \ No newline at end of file diff --git a/Resources/Scripts/XMovieActions/XMovieActionPrefabAnimation.lua b/Resources/Scripts/XMovieActions/XMovieActionPrefabAnimation.lua new file mode 100644 index 00000000..a74a3b76 --- /dev/null +++ b/Resources/Scripts/XMovieActions/XMovieActionPrefabAnimation.lua @@ -0,0 +1,69 @@ +local next = next + +local XMovieActionPrefabAnimation = XClass(XMovieActionBase, "XMovieActionPrefabAnimation") + +function XMovieActionPrefabAnimation:Ctor(actionData) + local params = actionData.Params + local paramToNumber = XDataCenter.MovieManager.ParamToNumber + local transTimeLineSeconds = XDataCenter.MovieManager.TransTimeLineSeconds + + self.ParentName = params[1] + self.PrefabPath = params[2] + self.AnimName = params[3] + self.PauseTime = transTimeLineSeconds(paramToNumber(params[4])) + self.Resume = paramToNumber(params[5]) ~= 0 +end + +function XMovieActionPrefabAnimation:OnInit() + local parentName = self.ParentName + local parent = self.UiRoot[parentName] + if XTool.UObjIsNil(parent) then + XLog.Error("XMovieActionPrefabAnimation:OnInit error: parentName is: " .. parentName) + return + end + + local prefabPath = self.PrefabPath + local animName = self.AnimName + local animInfo = self.UiRoot.AnimPrefabDic[prefabPath] or {} + if not next(animInfo) then + local prefab = parent.gameObject:LoadPrefab(prefabPath) + animInfo.Prefab = prefab + + local transfrom = prefab:FindTransform(animName) + animInfo.Transform = transfrom + + self.UiRoot.AnimPrefabDic[prefabPath] = animInfo + end +end + +function XMovieActionPrefabAnimation:OnRunning() + local prefabPath = self.PrefabPath + local animInfo = self.UiRoot.AnimPrefabDic[prefabPath] + local transfrom = animInfo.Transform + + if not animInfo.IsPlaying then + transfrom.gameObject:SetActiveEx(true) + transfrom:PlayTimelineAnimation(function() + transfrom.gameObject:SetActiveEx(false) + animInfo.IsPlaying = nil + end) + animInfo.IsPlaying = true + end + + local animScript = animInfo.AnimScript + if not animScript then + animScript = transfrom:GetComponent("XUiPlayTimelineAnimation") + animInfo.AnimScript = animScript + end + + local pauseTime = self.PauseTime + if pauseTime > 0 then + animScript:SetPauseTime(pauseTime) + end + + if self.Resume then + animScript:Resume() + end +end + +return XMovieActionPrefabAnimation \ No newline at end of file diff --git a/Resources/Scripts/XMovieActions/XMovieActionSelection.lua b/Resources/Scripts/XMovieActions/XMovieActionSelection.lua new file mode 100644 index 00000000..fc9c6c77 --- /dev/null +++ b/Resources/Scripts/XMovieActions/XMovieActionSelection.lua @@ -0,0 +1,124 @@ +local tableInsert = table.insert + +local MAX_SELECTION_NUM = 3 +local ROLE_NAME = "[ " .. CS.XTextManager.GetText("StoryReviewTip") .. " ]" + +local LastSelectedId + +local XMovieActionSelection = XClass(XMovieActionBase, "XMovieActionSelection") + +function XMovieActionSelection:Ctor(actionData) + local params = actionData.Params + local paramToNumber = XDataCenter.MovieManager.ParamToNumber + local replacePlayerName = XDataCenter.MovieManager.ReplacePlayerName + + self.DelaySelectKey = paramToNumber(params[1]) + + local selectList = {} + local selectParamsNum = MAX_SELECTION_NUM * 2 + 1 + for i = 2, selectParamsNum, 2 do + if params[i] and params[i] ~= "" then + local data = {} + data.DialogContent = replacePlayerName(params[i]) + data.ActionId = paramToNumber(params[i + 1]) + tableInsert(selectList, data) + end + end + self.OriginalSelectList = selectList +end + +function XMovieActionSelection:IsBlock() + return true +end + +function XMovieActionSelection:CanContinue() + return false +end + +function XMovieActionSelection:GetSelectedActionId() + return self.SelectedActionId or 0 +end + +function XMovieActionSelection:GetBeginAnim() + return self.BeginAnim or "SelectEnable" +end + +function XMovieActionSelection:OnUiRootInit() + self.TabGroupList = { + self.UiRoot.BtnSelect1, + self.UiRoot.BtnSelect2, + self.UiRoot.BtnSelect3, + } +end + +function XMovieActionSelection:OnUiRootDestroy() + LastSelectedId = nil + self.RepeatClick = nil + self.TabGroupList = {} +end + +function XMovieActionSelection:OnInit() + self.UiRoot.TabBtnSelectGroup:Init(self.TabGroupList, function(tabIndex) self:OnClickTabCallBack(tabIndex) end) + self.UiRoot.PanelSelectableDialog.gameObject:SetActiveEx(true) + + self.SelectedActionId = 0 + + --成环时隐藏掉导致成环的分支 + self.SelectList = {} + for _, data in pairs(self.OriginalSelectList) do + if data.ActionId ~= LastSelectedId then + tableInsert(self.SelectList, data) + end + end + + if not next(self.SelectList) then + XLog.Error("XMovieActionSelection:OnRunning error:SelectList is empty, actionId is: " .. self.ActionId) + return + end + + local dataNum = #self.SelectList + for i = 1, dataNum do + local btn = self.TabGroupList[i] + local data = self.SelectList[i] + btn:SetName(data.DialogContent) + btn.gameObject:SetActiveEx(true) + end + + for i = dataNum + 1, MAX_SELECTION_NUM do + self.TabGroupList[i].gameObject:SetActiveEx(false) + end +end + +function XMovieActionSelection:OnRunning() + self.RepeatClick = nil--进入动画播放完毕后按钮恢复可点击状态 +end + +function XMovieActionSelection:OnDestroy() + self.RepeatClick = nil + self.UiRoot.PanelSelectableDialog.gameObject:SetActiveEx(false) +end + +function XMovieActionSelection:OnClickTabCallBack(tabIndex) + if self.RepeatClick then return end + self.RepeatClick = true + + local selectedData = self.SelectList[tabIndex] + local delaySelectKey = self.DelaySelectKey + local actionId = selectedData.ActionId + if delaySelectKey == 0 then + self.SelectedActionId = actionId + else + XDataCenter.MovieManager.DelaySelectAction(delaySelectKey, actionId) + end + + LastSelectedId = self.SelectedActionId + XDataCenter.MovieManager.PushInReviewDialogList(ROLE_NAME, selectedData.DialogContent) + XEventManager.DispatchEvent(XEventId.EVENT_MOVIE_BREAK_BLOCK) +end + +function XMovieActionSelection:OnUndo() + XDataCenter.MovieManager.RemoveFromReviewDialogList() + LastSelectedId = nil +end + +return XMovieActionSelection \ No newline at end of file diff --git a/Resources/Scripts/XMovieActions/XMovieActionSetGray.lua b/Resources/Scripts/XMovieActions/XMovieActionSetGray.lua new file mode 100644 index 00000000..e4683c3c --- /dev/null +++ b/Resources/Scripts/XMovieActions/XMovieActionSetGray.lua @@ -0,0 +1,47 @@ +local pairs = pairs +local tableInsert = table.insert + +local XMovieActionSetGray = XClass(XMovieActionBase, "XMovieActionSetGray") + +function XMovieActionSetGray:Ctor(actionData) + local params = actionData.Params + local paramToNumber = XDataCenter.MovieManager.ParamToNumber + + self.Value = XMath.Clamp(paramToNumber(params[1]), 0, 1) + self.IndexList = {} + local maxParamNum = XMovieConfigs.MAX_ACTOR_NUM + 1 + for i = 1, maxParamNum do + local index = paramToNumber(params[i + 1]) + if index ~= 0 then + tableInsert(self.IndexList, index) + end + end +end + +function XMovieActionSetGray:OnRunning() + local value = self.Value + local maxActorNum = XMovieConfigs.MAX_ACTOR_NUM + local indexList = self.IndexList + local setValue = false + + for _, index in pairs(indexList) do + if index > 0 and index < maxActorNum then + local actor = self.UiRoot:GetActor(index) + actor:SetGray(value) + setValue = true + else + self.UiRoot.MaterialBg:SetGrayScale(value) + setValue = true + end + end + + if not setValue then + self.UiRoot.MaterialBg:SetGrayScale(value) + for index = 1, maxActorNum do + local actor = self.UiRoot:GetActor(index) + actor:SetGrayScale(value) + end + end +end + +return XMovieActionSetGray \ No newline at end of file diff --git a/Resources/Scripts/XMovieActions/XMovieActionSoundPlay.lua b/Resources/Scripts/XMovieActions/XMovieActionSoundPlay.lua new file mode 100644 index 00000000..e9d8545c --- /dev/null +++ b/Resources/Scripts/XMovieActions/XMovieActionSoundPlay.lua @@ -0,0 +1,78 @@ +local UiInited, LastBgmCueId +local PlayingCvInfo +local OldVolume = {} + +local CSXAudioManager = CS.XAudioManager + +local XMovieActionSoundPlay = XClass(XMovieActionBase, "XMovieActionSoundPlay") + +function XMovieActionSoundPlay:Ctor(actionData) + local params = actionData.Params + local paramToNumber = XDataCenter.MovieManager.ParamToNumber + + self.SoundType = paramToNumber(params[1]) + self.CueId = paramToNumber(params[2]) + self.Volume = paramToNumber(params[3]) +end + +function XMovieActionSoundPlay:OnUiRootInit() + if UiInited then return end + UiInited = true + + OldVolume[XSoundManager.SoundType.CV] = XSoundManager.GetVolumeByType(XSoundManager.SoundType.CV) + OldVolume[XSoundManager.SoundType.BGM] = XSoundManager.GetVolumeByType(XSoundManager.SoundType.BGM) + OldVolume[XSoundManager.SoundType.Sound] = XSoundManager.GetVolumeByType(XSoundManager.SoundType.Sound) + + LastBgmCueId = XSoundManager.GetCurrentBgmCueId() + CSXAudioManager.StopMusic() +end + +function XMovieActionSoundPlay:OnUiRootDestroy() + if not UiInited then return end + UiInited = nil + if OldVolume[XSoundManager.SoundType.CV] then + XSoundManager.SetVolumeByType(OldVolume[XSoundManager.SoundType.CV], XSoundManager.SoundType.CV) + end + if OldVolume[XSoundManager.SoundType.BGM] then + XSoundManager.SetVolumeByType(OldVolume[XSoundManager.SoundType.BGM], XSoundManager.SoundType.BGM) + end + if OldVolume[XSoundManager.SoundType.Sound] then + XSoundManager.SetVolumeByType(OldVolume[XSoundManager.SoundType.Sound], XSoundManager.SoundType.Sound) + end + OldVolume = {} + self:StopLastCv() + CSXAudioManager.StopAll() + XSoundManager.PlaySoundByType(LastBgmCueId, XSoundManager.SoundType.BGM) +end + +function XMovieActionSoundPlay:OnRunning() + + CS.XTool.WaitForEndOfFrame(function() + local soundType = self.SoundType + + local cueId = self.CueId + if soundType == XSoundManager.SoundType.CV then + self:StopLastCv() + PlayingCvInfo = XSoundManager.PlaySoundByType(cueId, soundType) + else + XSoundManager.PlaySoundByType(cueId, soundType) + end + + local volume = self.Volume + if volume ~= 0 and CSXAudioManager.Control == 1 then + XSoundManager.SetVolumeByType(volume, soundType) + end + end) + +end + +function XMovieActionSoundPlay:StopLastCv() + if PlayingCvInfo then + if PlayingCvInfo.Playing then + PlayingCvInfo:Stop() + end + PlayingCvInfo = nil + end +end + +return XMovieActionSoundPlay \ No newline at end of file diff --git a/Resources/Scripts/XMovieActions/XMovieActionStaff.lua b/Resources/Scripts/XMovieActions/XMovieActionStaff.lua new file mode 100644 index 00000000..e73e3586 --- /dev/null +++ b/Resources/Scripts/XMovieActions/XMovieActionStaff.lua @@ -0,0 +1,155 @@ +local XUIGridStaff = require("XUi/XUiMovie/XUIGridStaff") + +local ipairs = ipairs +local mathAbs = math.abs +local CSXScheduleManagerScheduleOnce = XScheduleManager.ScheduleOnce +local CSXScheduleManagerUnSchedule = XScheduleManager.UnSchedule +local Lerp = CS.UnityEngine.Vector3.Lerp +local Vector3 = CS.UnityEngine.Vector3 + +local DEFAULT_ANIM_DURATION_PRE_LINE = 0.5--每行字幕滚动时间/s + +local XMovieActionStaff = XClass(XMovieActionBase, "XMovieActionStaff") + +function XMovieActionStaff:Ctor(actionData) + local params = actionData.Params + local paramToNumber = XDataCenter.MovieManager.ParamToNumber + + self.StaffPath = params[1]--职员表配置路径 + self.BgPath = params[2]--背景路径(默认黑色背景) + self.IsCanSkip = paramToNumber(params[3]) ~= 0--是否跳过(非0可跳过,否则隐藏skip按钮) + local speed = paramToNumber(params[4]) + self.AnimDurationPreLine = speed == 0 and DEFAULT_ANIM_DURATION_PRE_LINE or speed--每行字幕滚动时间(s) + self.DelayAtBegin = paramToNumber(params[5]) * XScheduleManager.SECOND--开头字幕停留时间(s) + self.DelayAtEnd = paramToNumber(params[6]) * XScheduleManager.SECOND--结尾字幕停留时间(s) +end + +function XMovieActionStaff:OnInit() + local bgPath = self.BgPath + if not string.IsNilOrEmpty(bgPath) then + self.UiRoot.RImgBgStaff:SetRawImage(bgPath) + end + + if not self:IsBlock() then + self.UiRoot.PanelDialog.gameObject:SetActiveEx(false)--对话节点无法通过正常exit逻辑退出,需手动隐藏 + end + self.UiRoot.BtnSkip.gameObject:SetActiveEx(self.IsCanSkip) + self.UiRoot.TxtStaffName.gameObject:SetActiveEx(false) + self.UiRoot.BtnSkipStaff.CallBack = function() self:OnClickBtnSkipStaff() end + + local staffPath = self.StaffPath + local staffIds = XMovieConfigs.GetStaffIdList(staffPath) + self.GridList = {} + self.StaffIds = staffIds + for index, staffId in ipairs(staffIds) do + local grid = self.GridList[index] + if not grid then + local obj = CS.UnityEngine.Object.Instantiate(self.UiRoot.TxtStaffName.gameObject, self.UiRoot.PanelStaffContent) + grid = XUIGridStaff.New(obj) + self.GridList[index] = grid + end + grid:Refresh(staffPath, staffId) + grid.GameObject:SetActiveEx(true) + end + + self.UiRoot.PanelStaff.gameObject:SetActiveEx(true) + self.UiRoot.PanelStaff.transform.localPosition = Vector3(0, -10000, 0) + + self.NeedDelay = self.DelayAtEnd ~= 0 + CSXScheduleManagerScheduleOnce(function() + self.UiRoot.PanelStaff.transform.localPosition = Vector3(0, 0, 0) + + local contentGo = self.UiRoot.PanelStaffContent + local viewHeight = self.UiRoot.StaffViewport.transform.rect.height + local initPos = contentGo.transform.localPosition + local startPos = Vector3(initPos.x, initPos.y - viewHeight * 0.5, initPos.z) + local targetPos = Vector3(startPos.x, contentGo.transform.rect.height - viewHeight, startPos.z) + local duration = self.AnimDurationPreLine * #self.StaffIds + + contentGo.transform.localPosition = startPos + + CSXScheduleManagerScheduleOnce(function() + self:LetsRoll(startPos, targetPos, duration) + end, self.DelayAtBegin) + end, 0) +end + +function XMovieActionStaff:OnAnimEnd() + self:DestroyTimer() + self:DestroyDelayTimer() + self.UiRoot.PanelStaff.gameObject:SetActiveEx(false) + self.UiRoot.BtnSkip.gameObject:SetActiveEx(true) +end + +function XMovieActionStaff:OnClickBtnSkipStaff() + if self.IsRoll then return end +end + +function XMovieActionStaff:LetsRoll(startPos, targetPos, duration) + local contentGo = self.UiRoot.PanelStaffContent + local onRefreshFunc = function(time) + + if XTool.UObjIsNil(contentGo) then + self:DestroyTimer() + return true + end + + local tf = contentGo.transform + if tf.localPosition == targetPos then + return true + end + + tf.localPosition = Lerp(startPos, targetPos, time) + + end + + local finishCb = function() + if XTool.UObjIsNil(contentGo) then return end + + if self.NeedDelay then + + self:DestroyDelayTimer() + local delayTime = self.DelayAtEnd + self.DelayTimer = CSXScheduleManagerScheduleOnce(function() + if XTool.UObjIsNil(contentGo) then return end + + self.NeedDelay = nil + local startPos = contentGo.transform.localPosition + local targetPos = Vector3(startPos.x, contentGo.transform.rect.height, startPos.z) + local duration = self.AnimDurationPreLine * 10--默认空白10行 + self:LetsRoll(startPos, targetPos, duration) + + end, delayTime) + + return + end + + self.IsRoll = nil + self:OnAnimEnd() + + if self:IsBlock() then + XEventManager.DispatchEvent(XEventId.EVENT_MOVIE_BREAK_BLOCK) + end + + end + + self:DestroyTimer() + self.IsRoll = true + self.Timer = XUiHelper.Tween(duration, onRefreshFunc, finishCb) +end + +function XMovieActionStaff:DestroyTimer() + if self.Timer then + CSXScheduleManagerUnSchedule(self.Timer) + self.Timer = nil + end +end + +function XMovieActionStaff:DestroyDelayTimer() + if self.DelayTimer then + CSXScheduleManagerUnSchedule(self.DelayTimer) + self.DelayTimer = nil + end +end + +return XMovieActionStaff \ No newline at end of file diff --git a/Resources/Scripts/XMovieActions/XMovieActionTheme.lua b/Resources/Scripts/XMovieActions/XMovieActionTheme.lua new file mode 100644 index 00000000..63b249a8 --- /dev/null +++ b/Resources/Scripts/XMovieActions/XMovieActionTheme.lua @@ -0,0 +1,22 @@ +local XMovieActionTheme = XClass(XMovieActionBase, "XMovieActionTheme") + +function XMovieActionTheme:Ctor(actionData) + local params = actionData.Params + + self.Title = params[1] + self.Content = params[2] + self.LogoPath = params[3] +end + +function XMovieActionTheme:OnInit() + self.UiRoot.TxtTitle.text = self.Title + self.UiRoot.TxtContent.text = self.Content + self.UiRoot:SetUiSprite(self.UiRoot.ImgLogo, self.LogoPath) + self.UiRoot.PanelTheme.gameObject:SetActiveEx(true) +end + +function XMovieActionTheme:OnExit() + -- self.UiRoot.PanelTheme.gameObject:SetActiveEx(false) +end + +return XMovieActionTheme \ No newline at end of file diff --git a/Resources/Scripts/XMovieActions/XMovieActionUnLoad.lua b/Resources/Scripts/XMovieActions/XMovieActionUnLoad.lua new file mode 100644 index 00000000..3e3f65da --- /dev/null +++ b/Resources/Scripts/XMovieActions/XMovieActionUnLoad.lua @@ -0,0 +1,49 @@ +local stringFormat = string.format + +local XMovieActionUnLoad = XClass(XMovieActionBase, "XMovieActionUnLoad") + +function XMovieActionUnLoad:Ctor(actionData) + local params = actionData.Params + local paramToNumber = XDataCenter.MovieManager.ParamToNumber + self.AnimName = params[1] + self.EffectPath = params[2] + self.PrefabAnimPath = params[3] + self.EffectActorIndex = paramToNumber(params[4]) + + if not self.AnimName and not self.EffectPath and not self.PrefabAnimPath then + XLog.Error("XMovieActionUnLoad:Ctor error: params can not be empty!") + return + end +end + +function XMovieActionUnLoad:OnRunning() + local animName = self.AnimName + local effectPath = self.EffectPath + local effectActorIndex = self.EffectActorIndex + local isActorEffect = effectActorIndex > 0 and effectActorIndex <= XMovieConfigs.MAX_ACTOR_NUM + local effectKey = isActorEffect and stringFormat("%s%s", effectPath, effectActorIndex) or effectPath + + if animName then + local anim = self.UiRoot[animName] + if not XTool.UObjIsNil(anim) then + anim.gameObject:SetActiveEx(false) + end + end + + if effectPath then + local effectGo = self.UiRoot.EffectGoDic[effectKey] + if not XTool.UObjIsNil(effectGo) then + effectGo.gameObject:SetActiveEx(false) + end + end + + local prefabAnimPath = self.PrefabAnimPath + if prefabAnimPath then + local animInfo = self.UiRoot.AnimPrefabDic[prefabAnimPath] + if animInfo then + animInfo.Prefab.gameObject:SetActiveEx(false) + end + end +end + +return XMovieActionUnLoad \ No newline at end of file diff --git a/Resources/Scripts/XMovieActions/XMovieActionVideoPlay.lua b/Resources/Scripts/XMovieActions/XMovieActionVideoPlay.lua new file mode 100644 index 00000000..6c382446 --- /dev/null +++ b/Resources/Scripts/XMovieActions/XMovieActionVideoPlay.lua @@ -0,0 +1,27 @@ +local XMovieActionVideoPlay = XClass(XMovieActionBase, "XMovieActionVideoPlay") + +function XMovieActionVideoPlay:Ctor(actionData) + local params = actionData.Params + local paramToNumber = XDataCenter.MovieManager.ParamToNumber + + self.VideoId = paramToNumber(params[1]) +end + +function XMovieActionVideoPlay:IsBlock() + return true +end + +function XMovieActionVideoPlay:GetBeginDelay() + return 1000 +end + +function XMovieActionVideoPlay:OnRunning() + self.UiRoot:Hide() + XDataCenter.VideoManager.PlayMovie(self.VideoId, function() + self.UiRoot:Show() + XEventManager.DispatchEvent(XEventId.EVENT_MOVIE_BREAK_BLOCK) + end) +end + + +return XMovieActionVideoPlay \ No newline at end of file diff --git a/Resources/Scripts/XMovieActions/XMovieActionYieldResume.lua b/Resources/Scripts/XMovieActions/XMovieActionYieldResume.lua new file mode 100644 index 00000000..83624936 --- /dev/null +++ b/Resources/Scripts/XMovieActions/XMovieActionYieldResume.lua @@ -0,0 +1,35 @@ +local XMovieActionYieldResume = XClass(XMovieActionBase, "XMovieActionYieldResume") + +local tableInsert = table.insert +local MAX_SKIP_NUM = 3 + +function XMovieActionYieldResume:Ctor(actionData) + local params = actionData.Params + local paramToNumber = XDataCenter.MovieManager.ParamToNumber + + self.ResumeActionIds = {} + for i = 1, MAX_SKIP_NUM do + local actionId = paramToNumber(params[i]) + if actionId ~= 0 then + tableInsert(self.ResumeActionIds, actionId) + end + end +end + +function XMovieActionYieldResume:OnInit() + self.ResumeActionId = 0 +end + +function XMovieActionYieldResume:OnRunning() + XDataCenter.MovieManager.YiledMovie() +end + +function XMovieActionYieldResume:ResumeAtIndex(index) + self.ResumeActionId = self.ResumeActionIds[index] or 0 +end + +function XMovieActionYieldResume:GetResumeActionId() + return self.ResumeActionId +end + +return XMovieActionYieldResume \ No newline at end of file diff --git a/Resources/Scripts/XOverseas/XConfig/XSlotMachineConfigs.lua b/Resources/Scripts/XOverseas/XConfig/XSlotMachineConfigs.lua new file mode 100644 index 00000000..5ab996cd --- /dev/null +++ b/Resources/Scripts/XOverseas/XConfig/XSlotMachineConfigs.lua @@ -0,0 +1,142 @@ +local tableInsert = table.insert +XSlotMachineConfigs = XSlotMachineConfigs or {} + +local TABLE_SLOT_MACHINE_ACTIVITY_PATH = "Share/SlotMachines/SlotMachinesActivity.tab" +local TABLE_SLOT_MACHINE_PATH = "Share/SlotMachines/SlotMachines.tab" +local TABLE_SLOT_MACHINE_ICON_PATH = "Share/SlotMachines/SlotMachinesIcon.tab" +local TABLE_SLOT_MACHINE_RULES_PATH = "Share/SlotMachines/SlotMachinesRules.tab" + +local SlotMachinesActivityTemplates = {} +local SlotMachinesTemplates = {} +local SlotMachinesIconTemplates = {} +local SlotMachinesRulesTemplates = {} + +XSlotMachineConfigs.SlotMachineState = { + Locked = 1, + Running = 2, + Finish = 3, +} + +XSlotMachineConfigs.RewardTakeState = { + NotFinish = 1, + NotTook = 2, + Took = 3, +} + +XSlotMachineConfigs.TaskType = { + Daily = 1, + Cumulative = 2, +} + +XSlotMachineConfigs.RulesPanelType = { + Rules = 1, + Research = 2, +} + +XSlotMachineConfigs.ExchangeType = { + Normal = 0, + OnlyTask = 1, +} + +function XSlotMachineConfigs.Init() + SlotMachinesActivityTemplates = XTableManager.ReadByIntKey(TABLE_SLOT_MACHINE_ACTIVITY_PATH, XTable.XTableSlotMachinesActivity, "Id") + SlotMachinesTemplates = XTableManager.ReadByIntKey(TABLE_SLOT_MACHINE_PATH, XTable.XTableSlotMachines, "Id") + SlotMachinesIconTemplates = XTableManager.ReadByIntKey(TABLE_SLOT_MACHINE_ICON_PATH, XTable.XTableSlotMachinesIcon, "Id") + SlotMachinesRulesTemplates = XTableManager.ReadByIntKey(TABLE_SLOT_MACHINE_RULES_PATH, XTable.XTableSlotMachinesRules, "Id") +end + +function XSlotMachineConfigs.GetSlotMachinesActivityTemplate() + if not SlotMachinesActivityTemplates then + XLog.Error("XSlotMachineConfigs.GetSlotMachinesActivityTemplate Error, SlotMachinesActivityTemplates is nil") + end + + return SlotMachinesActivityTemplates +end + +function XSlotMachineConfigs.GetSlotMachinesActivityTemplateById(id) + if not SlotMachinesActivityTemplates[id] then + XLog.Error("XSlotMachineConfigs.GetSlotMachinesActivityTemplateById Error, Can't find Template by Id:"..id) + end + + return SlotMachinesActivityTemplates[id] +end + +function XSlotMachineConfigs.GetSlotMachinesTemplateById(id) + if not SlotMachinesTemplates[id] then + XLog.Error("XSlotMachineConfigs.GetSlotMachinesTemplateById Error, Can't find Template by Id:"..id) + end + + return SlotMachinesTemplates[id] +end + +function XSlotMachineConfigs.GetSlotMachinesIconTemplateById(id) + if not SlotMachinesIconTemplates[id] then + XLog.Error("XSlotMachineConfigs.GetSlotMachinesIconTemplateById Error, Can't find Template by Id:"..id) + end + + return SlotMachinesIconTemplates[id] +end + +function XSlotMachineConfigs.GetSlotMachinesRulesTemplateById(id) + if not SlotMachinesRulesTemplates[id] then + XLog.Error("XSlotMachineConfigs.GetSlotMachinesRulesTemplateById Error, Can't find Template by Id:"..id) + end + + return SlotMachinesRulesTemplates[id] +end + +function XSlotMachineConfigs.GetActivityStartTimeByActId(id) + local activityTmp = XSlotMachineConfigs.GetSlotMachinesActivityTemplateById(id) + if not activityTmp then + return + end + + return activityTmp.StartTimeStr, activityTmp.EndTimeStr +end + +function XSlotMachineConfigs.GetIconImageById(iconId) + local iconTmp = XSlotMachineConfigs.GetSlotMachinesIconTemplateById(iconId) + if not iconTmp then + return + end + + return iconTmp.IconImage +end + +function XSlotMachineConfigs.GetIconNameById(iconId) + local iconTmp = XSlotMachineConfigs.GetSlotMachinesIconTemplateById(iconId) + if not iconTmp then + return + end + + return iconTmp.IconName +end + +function XSlotMachineConfigs.GetSlotMachinesItemExchangeRatio(actId) + if not actId then + return + end + + local activityTmp = XSlotMachineConfigs.GetSlotMachinesActivityTemplateById(actId) + if not activityTmp then + return + end + + return activityTmp.ExchangeRatio +end + +function XSlotMachineConfigs.GetSlotMachinesItemExchangeType(actId) + if not actId then + return + end + + local activityTmp = XSlotMachineConfigs.GetSlotMachinesActivityTemplateById(actId) + if not activityTmp then + return + end + if activityTmp.ExchangeType then + return activityTmp.ExchangeType + else + return XSlotMachineConfigs.ExchangeType.Normal + end +end \ No newline at end of file diff --git a/Resources/Scripts/XOverseas/XEntity/XSlotMachine/XSlotMachineDataEntity.lua b/Resources/Scripts/XOverseas/XEntity/XSlotMachine/XSlotMachineDataEntity.lua new file mode 100644 index 00000000..75d30232 --- /dev/null +++ b/Resources/Scripts/XOverseas/XEntity/XSlotMachine/XSlotMachineDataEntity.lua @@ -0,0 +1,161 @@ +local XSlotMachineDataEntity = XClass(nil, "XSlotMachineDataEntity") +local tableRemove = table.remove +local tableInsert = table.insert + +local Default = { + -- Client + Id = 0, + Tmp = {}, -- 配置数据 + -- Sever + RockTimes = 0, -- 摇奖次数 + TotalScore = 0, -- 当前积分 + RecvIndex = {}, -- 已领取奖励下标 + SlotMachineRecords = {}, -- 抽奖记录 +} + +function XSlotMachineDataEntity:Ctor(template, slotMachineData) + for key in pairs(Default) do + self[key] = Default[key] + end + + if template then + self.Tmp = template + self.Id = template.Id + end + + self:RefreshItem(slotMachineData) +end + +function XSlotMachineDataEntity:RefreshItem(slotMachineData) + if not slotMachineData then + return + end + + if slotMachineData.RockTimes then + self.RockTimes = slotMachineData.RockTimes + end + + if slotMachineData.TotalScore then + self.TotalScore = slotMachineData.TotalScore + end + + if slotMachineData.RecvIndex then + self.RecvIndex = slotMachineData.RecvIndex + end + + if slotMachineData.SlotMachineRecords then + self.SlotMachineRecords = slotMachineData.SlotMachineRecords + end +end + +-- Begain Get +-- Client +function XSlotMachineDataEntity:GetId() + return self.Id +end + +function XSlotMachineDataEntity:GetName() + return self.Tmp.Name +end + +function XSlotMachineDataEntity:GetConsumeItemId() + return self.Tmp.ConsumeItemId +end + +function XSlotMachineDataEntity:GetConsumeCount() + return self.Tmp.ConsumeCount +end + +function XSlotMachineDataEntity:GetUnlockNeedPreScore() + return self.Tmp.UnlockNeedPreScore +end + +function XSlotMachineDataEntity:GetScoreLimit() + return self.Tmp.ScoreLimit +end + +function XSlotMachineDataEntity:GetBgImage() + return self.Tmp.BgImage +end + +function XSlotMachineDataEntity:GetMachineImage() + return self.Tmp.MachineImage +end + +function XSlotMachineDataEntity:GetMachineLockImage() + return self.Tmp.MachineLockImage +end + +function XSlotMachineDataEntity:GetNextMachineBtnImage() + return self.Tmp.NextMachineBtnImage +end + +function XSlotMachineDataEntity:GetNextMachineBtnText() + return self.Tmp.NextMachineBtnText +end + +function XSlotMachineDataEntity:GetRulesIds() + return self.Tmp.RulesIds +end + +function XSlotMachineDataEntity:GetIcons() + return self.Tmp.Icons +end + +function XSlotMachineDataEntity:GetRewardIds() + return self.Tmp.RewardIds +end + +function XSlotMachineDataEntity:GetRewardScores() + return self.Tmp.RewardScores +end + +function XSlotMachineDataEntity:GetPrixBottomTimes() + return self.Tmp.PrixBottomTimes +end + +function XSlotMachineDataEntity:GetTaskDailyLimitId() + return self.Tmp.TaskDailyLimitId +end + +function XSlotMachineDataEntity:GetTaskCumulativeLimitId() + return self.Tmp.TaskCumulativeLimitId +end + +-- Sever +function XSlotMachineDataEntity:GetRockTimes() + return self.RockTimes +end + +function XSlotMachineDataEntity:GetTotalScore() + return self.TotalScore +end + +function XSlotMachineDataEntity:GetRecvIndex() + return self.RecvIndex +end + +function XSlotMachineDataEntity:GetSlotMachineRecords() + return self.SlotMachineRecords +end +-- End Get + +-- Begain Set +function XSlotMachineDataEntity:SetRockTimes(rockTimes) + self.RockTimes = rockTimes +end + +function XSlotMachineDataEntity:SetTotalScore(totalScore) + self.TotalScore = totalScore +end + +function XSlotMachineDataEntity:SetSlotMachineRecords(slotMachineRecords) + self.SlotMachineRecords = slotMachineRecords +end + +function XSlotMachineDataEntity:SetRecvIndex(index) + tableInsert(self.RecvIndex, index) +end +-- End Set + +return XSlotMachineDataEntity \ No newline at end of file diff --git a/Resources/Scripts/XOverseas/XManager/XFireworksManager.lua b/Resources/Scripts/XOverseas/XManager/XFireworksManager.lua new file mode 100644 index 00000000..3cbc2654 --- /dev/null +++ b/Resources/Scripts/XOverseas/XManager/XFireworksManager.lua @@ -0,0 +1,169 @@ +--Description +--烟花活动管理器 +--涉及修改 +--FireworksManager.lua +--XTable.XTableFireworks +--XTable.XTableSignFireworks +--SignFireworks.tab +--XAutoWindowConfigs - 增加autoWindowConfig 1001 +--XDateCenter 增加管理器入口 +--XUiSign增加界面lua绑定相关 +--XSignInConfigs增加相关配置 +--XRedPoint相关红点 +--XUISignBanner +--XAutoWindowController.tab +--XSkipFunctional.tab + +XFireworksManagerCreator = function() + local FIREWORK_CONFIG_PATH = "Share/EnKrFireworks/Fireworks.tab" + local FIREWORK_REWARD_CONFIG_PATH = "Share/EnKrFireworks/FireworksReward.tab" + local FIREWORK_RULE_PATH = "Client/EnKrFireworks/FireworksRules.tab" + + local FireworksManager = {} + + local curFireworksActivityId = 1 + + local FireworksProto = { + Fire = "FireworksRequest" + } + + local config + local rewardConfigs + + local hadFireTimes + + local records + + local ruleConfigs + + local function InitData() + records = {} + hadFireTimes = 0; + end + + function FireworksManager.Init() + config = XTableManager.ReadByIntKey(FIREWORK_CONFIG_PATH, XTable.XTableFireworks, "Id")[curFireworksActivityId] + rewardConfigs = XTableManager.ReadByIntKey(FIREWORK_REWARD_CONFIG_PATH, XTable.XTableFireworksReward, "Id") + if config == nil then + XLog.Error("烟花活动Id配置不存在,Id为" .. curFireworksActivityId) + return + end + ruleConfigs = XTableManager.ReadByIntKey(FIREWORK_RULE_PATH, XTable.XTableFireworksRules, "Id") + InitData() + end + + function FireworksManager.IsActivityOpen() + if config == nil then return false end + local startTime = XTime.ParseToTimestamp(config.StartTimeStr) + local endTime = XTime.ParseToTimestamp(config.CloseTimeStr) + local nowTime = XTime.GetServerNowTimestamp() + return startTime <= nowTime and nowTime <= endTime + end + + function FireworksManager.IsPlayerQualified() + return XPlayer.Level >= config.OpenLevel and (config.OpenStage == nil or config.OpenStage <= 0 or XDataCenter.FubenManager.CheckStageIsPass(config.OpenStage)) + end + + function FireworksManager.HasAvailableFireTimes() + return hadFireTimes < config.DailyResetTimes + end + + function FireworksManager.HasRedDot() + return FireworksManager.IsActivityOpen() and FireworksManager.HasAvailableFireTimes() + end + + + function FireworksManager.SyncData(remoteData) + local found = false + for i = 1, #remoteData.Fireworks do + if (remoteData.Fireworks[i].Id == curFireworksActivityId) then + found = true + FireworksManager.SyncRecords(remoteData.Fireworks[i].Records) + hadFireTimes = remoteData.Fireworks[i].UseTimes + break + end + end + + if not found then + InitData() + end + end + + function FireworksManager.SyncRecords(recordList) + records = recordList + table.sort(records, function(a, b) return a.Time > b.Time end) + end + + function FireworksManager.OnFire(callback) + XNetwork.Call(FireworksProto.Fire, {FireworksId = curFireworksActivityId}, function(res) + if res.Code ~= XCode.Success then + callback(false, nil) + return + end + hadFireTimes = hadFireTimes + 1 --服务端未同步,手动同步 + table.insert(records, 1, res.Record) + if #records > 10 then + table.remove(records) + end + callback(true, res) + end) + end + + function FireworksManager.GetRules() + local config = ruleConfigs[curFireworksActivityId] + if config == nil then + XLog.Error("Fireworks rule does not exists, id is " .. curFireworksActivityId) + return {} + end + return config + end + + function FireworksManager.GetRecords() + return records + end + + function FireworksManager.GetLastRecordType() + if #records <= 0 then + return nil + end + local dropId = records[1].DropId + local effectId = FireworksManager.GetEffectIdByDropId(dropId) + if effectId == nil then + XLog.Error("FireworksReward Id " .. lastRecordId .. "不存在") + end + return effectId + end + + function FireworksManager.GetEffectIdByDropId(dropId) + if rewardConfigs[dropId] == nil then + return nil + end + return rewardConfigs[dropId].FireworksEffects + end + + function FireworksManager.GetDropNameByDropId(dropId) + if rewardConfigs[dropId] == nil then + return "Mystery" + end + return rewardConfigs[dropId].FireworksDes + end + + function FireworksManager.GetRecordString(record) + local name = FireworksManager.GetDropNameByDropId(record.DropId) + local infoStr = "" + local rewards = record.FireworksReward + for i = 1, #rewards do + local common = XGoodsCommonManager.GetGoodsShowParamsByTemplateId(rewards[i].TemplateId) + infoStr = infoStr .. string.format("%s*%d", common.Name, rewards[i].Count) .. " " + end + local time = XTime.TimestampToGameDateTimeString(record.Time) + return name, infoStr, time + end + + FireworksManager.Init() + return FireworksManager +end + +XRpc.NotifyFireworksData = function(data) + XDataCenter.FireworksManager.SyncData(data) +end \ No newline at end of file diff --git a/Resources/Scripts/XOverseas/XManager/XSlotMachineManager.lua b/Resources/Scripts/XOverseas/XManager/XSlotMachineManager.lua new file mode 100644 index 00000000..bc130495 --- /dev/null +++ b/Resources/Scripts/XOverseas/XManager/XSlotMachineManager.lua @@ -0,0 +1,455 @@ +local tableInsert = table.insert +local CSXTextManagerGetText = CS.XTextManager.GetText + +local XSlotMachineDataEntity = require("XOverseas/XEntity/XSlotMachine/XSlotMachineDataEntity") + +XSlotMachineManagerCreator = function() + local XSlotMachineManager = {} + local ActId = 0 + local SlotMachineDataEntityList = {} + local SlotMachineDataEntityAllList = {} --再加一层以满足多个老虎机活动存在 + + local SLOT_MACHINE_PROTO = { + GetSlotMachineInfoRequest = "GetSlotMachineInfoRequest", -- 老虎机数据请求 + SlotMachineRequest = "SlotMachineRequest", -- 老虎机抽奖请求 + SlotMachineRewardRequest = "SlotMachineRewardRequest", -- 老虎机领奖请求 + SlotMachineExchangeItemRequest = "SlotMachineExchangeItemRequest", -- 老虎机兑换道具请求 + } + function XSlotMachineManager.Init() + + end + + function XSlotMachineManager.GetSlotMachineInfoRequest(actId, cb) + XNetwork.Call(SLOT_MACHINE_PROTO.GetSlotMachineInfoRequest, {ActivityId = actId}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + ActId = actId + XSlotMachineManager.SlotMachineInfoListHandle(res.SlotMachineClientDataList) + --XLog.Warning(res.SlotMachineClientDataList) + if cb then cb() end + end) + end + + function XSlotMachineManager.SlotMachineInfoListHandle(slotMachineClientDataList) + if slotMachineClientDataList and next(slotMachineClientDataList) then + --SlotMachineDataEntityList = {} + SlotMachineDataEntityAllList[ActId] = {} + for _, slotMachineInfo in ipairs(slotMachineClientDataList) do + local slotMachineTmp = XSlotMachineConfigs.GetSlotMachinesTemplateById(slotMachineInfo.Id) + local slotMachineDataEntity = XSlotMachineDataEntity.New(slotMachineTmp, slotMachineInfo) + tableInsert(SlotMachineDataEntityAllList[ActId], slotMachineDataEntity) + end + end + end + + function XSlotMachineManager.SlotMachineAllInfoListHandle(slotMachineClientDataList) + if slotMachineClientDataList and next(slotMachineClientDataList) then + --SlotMachineDataEntityList = {} + for _, slotMachineInfo in ipairs(slotMachineClientDataList) do + local slotMachineTmp = XSlotMachineConfigs.GetSlotMachinesTemplateById(slotMachineInfo.Id) + local slotMachineDataEntity = XSlotMachineDataEntity.New(slotMachineTmp, slotMachineInfo) + local tmpActId = XSlotMachineManager.CheckMachineActId(slotMachineInfo.Id) + if tmpActId and not SlotMachineDataEntityAllList[tmpActId] then + SlotMachineDataEntityAllList[tmpActId] = {} + end + tableInsert(SlotMachineDataEntityAllList[tmpActId], slotMachineDataEntity) + end + end + end + + function XSlotMachineManager.CheckMachineActId(machineId) + local lotMachineListTmp = XSlotMachineConfigs.GetSlotMachinesActivityTemplate() + for _, slotMachineInfo in ipairs(lotMachineListTmp) do + for _, machineTmpId in pairs(slotMachineInfo.SlotMachinesIds) do + if machineTmpId == machineId then + return slotMachineInfo.Id + end + end + end + XLog.Error("can't check actId in slotmachinesActivity, machineId is:"..machineId) + return nil + end + + function XSlotMachineManager.NotifyAllSlotMachineInfo(req) + XSlotMachineManager.SlotMachineAllInfoListHandle(req.SlotMachineClientDataList) + end + + function XSlotMachineManager.StartSlotMachine(machineId) + -- 校验 + if not machineId then + return + end + local isEnough, lackCount = XSlotMachineManager.CheckConsumeItemIsEnough(machineId) + if isEnough then + XNetwork.Call(SLOT_MACHINE_PROTO.SlotMachineRequest, {ActivityId = ActId, Id = machineId}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + local machineDataEntity = XSlotMachineManager.GetSlotMachineDataEntityById(machineId) + if machineDataEntity then + local lastTotalScore = machineDataEntity:GetTotalScore() + machineDataEntity:SetRockTimes(res.RockTimes) + machineDataEntity:SetTotalScore(res.TotalScore) + machineDataEntity:SetSlotMachineRecords(res.SlotMachineRecords) + + local addScore = res.TotalScore - lastTotalScore + --XEventManager.DispatchEvent(XEventId.EVENT_SLOT_MACHINE_STARTED, res.IconList, addScore) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_SLOT_MACHINE_STARTED, res.IconList, addScore) + end + end) + else + if lackCount > 0 and ActId and ActId ~= 0 then + if XDataCenter.SlotMachineManager.GetSlotMachineActExchangeType() == XSlotMachineConfigs.ExchangeType.Normal then + local exchangeRatio = XSlotMachineConfigs.GetSlotMachinesItemExchangeRatio(ActId) + XUiManager.DialogTip(CSXTextManagerGetText("SlotMachineExchangeTitle"), CSXTextManagerGetText("SlotMachineExchangeContent", exchangeRatio*lackCount, lackCount), XUiManager.DialogType.Normal, nil, function() + XSlotMachineManager.SlotMachineExchangeItem(machineId, lackCount) + end) + elseif XDataCenter.SlotMachineManager.GetSlotMachineActExchangeType() == XSlotMachineConfigs.ExchangeType.OnlyTask then + XUiManager.TipError(CSXTextManagerGetText("SlotMachineCellBatteryNotEnough")) + end + end + end + + end + + function XSlotMachineManager.GetSlotMachineReward(machineId, index) + if not machineId or machineId == 0 or not index or index == 0 then + XLog.Error("The Proto SlotMachineRewardRequest Param Invalid") + return + end + + XNetwork.Call(SLOT_MACHINE_PROTO.SlotMachineRewardRequest, {ActivityId = ActId, Id = machineId, Index = index}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XUiManager.OpenUiObtain(res.RewardList) + + local machineDataEntity = XSlotMachineManager.GetSlotMachineDataEntityById(machineId) + + machineDataEntity:SetRecvIndex(index) + --XEventManager.DispatchEvent(XEventId.EVENT_SLOT_MACHINE_GET_REWARD) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_SLOT_MACHINE_GET_REWARD) + end) + end + + function XSlotMachineManager.SlotMachineExchangeItem(machineId, count) + if not machineId or not count or count <= 0 then + return + end + + XNetwork.Call(SLOT_MACHINE_PROTO.SlotMachineExchangeItemRequest, {ActivityId = ActId, Id = machineId, ItemCount = count}, function(res) + if res.Code ~= XCode.Success then + XUiManager.TipCode(res.Code) + return + end + XUiManager.TipText("SlotMachineExchangeSuccess", XUiManager.UiTipType.Tip) + end) + end + + function XSlotMachineManager.GetSlotMachineDataEntityList() + return SlotMachineDataEntityAllList[ActId] + end + + function XSlotMachineManager.GetSlotMachineDataEntityById(id,actId) + local tempId = ActId + if actId then + tempId = actId + end + for _, slotMachineDataEntity in pairs(SlotMachineDataEntityAllList[tempId]) do + if slotMachineDataEntity.Id == id then + return slotMachineDataEntity + end + end + XLog.Error("Not find SlotMachineDataEntity by Id:"..id) + end + + function XSlotMachineManager.GetSlotMachineDataEntityByIndex(index) + if not SlotMachineDataEntityAllList[ActId] then + XLog.Error("Not find SlotMachineDataEntity by ActId:"..ActId) + return + end + if not SlotMachineDataEntityAllList[ActId][index] then + XLog.Error("Not find SlotMachineDataEntity by Index:"..index) + return + end + + return SlotMachineDataEntityAllList[ActId][index] + end + + function XSlotMachineManager.OpenSlotMachine(actId) + if not actId then + return + end + + local startTime, endTime = XSlotMachineManager.GetActivityTime(actId) + local nowTime = XTime.GetServerNowTimestamp() + if nowTime < startTime then + XUiManager.TipMsg(CSXTextManagerGetText("SlotMachineTimeNotOpen"), XUiManager.UiTipType.Wrong, function() + XLuaUiManager.RunMain() + end) + elseif nowTime > endTime then + XUiManager.TipMsg(CSXTextManagerGetText("SlotMachineTimeEnd"), XUiManager.UiTipType.Wrong, function() + XLuaUiManager.RunMain() + end) + end + + if SlotMachineDataEntityAllList[actId] and next(SlotMachineDataEntityAllList[actId]) then -- 存在老虎机数据就不请求 + ActId = actId + XLuaUiManager.Open("UiSlotmachine") + return + end + + if actId and actId ~= 0 and actId ~= ActId then -- 不存在老虎机数据 + XSlotMachineManager.GetSlotMachineInfoRequest(actId, function() + XLuaUiManager.Open("UiSlotmachine") + end) + end + end + + function XSlotMachineManager.GetCurMachineId() + local curMachineId = 0 + for _, machineDataEntity in ipairs(SlotMachineDataEntityAllList[ActId]) do + curMachineId = machineDataEntity:GetId() + if machineDataEntity:GetScoreLimit() > machineDataEntity:GetTotalScore() then + return curMachineId + end + end + return curMachineId + end + + function XSlotMachineManager.GetActivityTime(actId) + local activityId = actId or ActId + if activityId and activityId ~= 0 then + local startTimeStr, endTimeStr = XSlotMachineConfigs.GetActivityStartTimeByActId(activityId) + local startTime = XTime.ParseToTimestamp(startTimeStr) + local endTime = XTime.ParseToTimestamp(endTimeStr) + return startTime, endTime + end + end + + function XSlotMachineManager.CheckSlotMachineState(machineId) + local machineEntity = XSlotMachineManager.GetSlotMachineDataEntityById(machineId) + + if not machineEntity then + return XSlotMachineConfigs.SlotMachineState.Locked + end + + if machineEntity:GetTotalScore() >= machineEntity:GetScoreLimit() then + return XSlotMachineConfigs.SlotMachineState.Finish + else + for i = 1, #SlotMachineDataEntityAllList[ActId] do + if SlotMachineDataEntityAllList[ActId][i]:GetId() == machineId then + if i == 1 then + return XSlotMachineConfigs.SlotMachineState.Running + else + local lastMachineEntity = SlotMachineDataEntityAllList[ActId][i-1] + if lastMachineEntity:GetTotalScore() >= lastMachineEntity:GetScoreLimit() then + return XSlotMachineConfigs.SlotMachineState.Running + else + return XSlotMachineConfigs.SlotMachineState.Locked + end + end + end + end + end + end + + function XSlotMachineManager.CheckRewardState(machineId, rewardIdx,actId) + local machineEntity = XSlotMachineManager.GetSlotMachineDataEntityById(machineId,actId) + if not machineEntity then + return XSlotMachineConfigs.RewardTakeState.NotFinish + end + + if machineEntity:GetTotalScore() >= machineEntity:GetRewardScores()[rewardIdx] then + local receiveIndex = machineEntity:GetRecvIndex() + for _, receiveIdx in ipairs(receiveIndex) do + if receiveIdx == rewardIdx then + return XSlotMachineConfigs.RewardTakeState.Took + end + end + return XSlotMachineConfigs.RewardTakeState.NotTook + else + return XSlotMachineConfigs.RewardTakeState.NotFinish + end + end + + function XSlotMachineManager.GetNextMachineId(machineId) + local machineEntity = XSlotMachineManager.GetSlotMachineDataEntityById(machineId) + if not machineEntity then + return nil + end + + for index, machineData in ipairs(SlotMachineDataEntityAllList[ActId]) do + if machineData:GetId() == machineId then + if SlotMachineDataEntityAllList[ActId][index+1] then + return SlotMachineDataEntityAllList[ActId][index+1]:GetId() + else + return SlotMachineDataEntityAllList[ActId][1]:GetId() + end + end + end + end + + function XSlotMachineManager.FinishTask(taskId) + XDataCenter.TaskManager.FinishTask(taskId, function(rewardGoodsList) + XUiManager.OpenUiObtain(rewardGoodsList) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_SLOT_MACHINE_FINISH_TASK) + end) + end + + function XSlotMachineManager.CheckIconListIsPrix(iconIdList) + if iconIdList and next(iconIdList) then + local isPrix = XSlotMachineConfigs.GetSlotMachinesIconTemplateById(iconIdList[1]).IsPrix + if not isPrix then + return false + end + for _, iconId in ipairs(iconIdList) do + if iconId ~= iconIdList[1] then + return false + end + end + + return true + else + return false + end + end + + function XSlotMachineManager.CheckConsumeItemIsEnough(machineId) + if not machineId then + return false + end + + local machineEntity = XSlotMachineManager.GetSlotMachineDataEntityById(machineId) + local itemCount = XDataCenter.ItemManager.GetCount(machineEntity:GetConsumeItemId()) + local onceNeedCount = machineEntity:GetConsumeCount() + + if itemCount >= onceNeedCount then + return true, 0 + else + return false, (onceNeedCount - itemCount) + end + end + + function XSlotMachineManager.CheckCanFinishTaskByType(machineId, taskType,actId) + if not machineId or not taskType then + return + end + local machineEntity = XSlotMachineManager.GetSlotMachineDataEntityById(machineId,actId) + local taskIds = nil + if taskType == XSlotMachineConfigs.TaskType.Daily then + taskIds = XTaskConfig.GetTimeLimitTaskCfg(machineEntity:GetTaskDailyLimitId()).DayTaskId + elseif taskType == XSlotMachineConfigs.TaskType.Cumulative then + taskIds = XTaskConfig.GetTimeLimitTaskCfg(machineEntity:GetTaskCumulativeLimitId()).TaskId + end + if taskIds then + for _, taskId in pairs(taskIds) do + if XDataCenter.TaskManager.GetTaskDataById(taskId).State == XDataCenter.TaskManager.TaskState.Achieved then + return true + end + end + end + + return false + end + + function XSlotMachineManager.CheckHasRewardCanTake(machineId,actId) + if not machineId then + return + end + local machineEntity = XSlotMachineManager.GetSlotMachineDataEntityById(machineId,actId) + if machineEntity then + local rewardIds = machineEntity:GetRewardIds() + for index, _ in ipairs(rewardIds) do + if XSlotMachineManager.CheckRewardState(machineId, index,actId) == XSlotMachineConfigs.RewardTakeState.NotTook then + return true + end + end + end + + return false + end + + function XSlotMachineManager.CheckTaskCanTakeByAllType(machineId,actId) + for _, taskType in pairs(XSlotMachineConfigs.TaskType) do + if XSlotMachineManager.CheckCanFinishTaskByType(machineId, taskType,actId) then + return true + end + end + + return false + end + + function XSlotMachineManager.GetSlotMachineActExchangeType() + if ActId and ActId ~= 0 then + return XSlotMachineConfigs.GetSlotMachinesItemExchangeType(ActId) + end + end + + function XSlotMachineManager.CheckRedPoint() + local isRewardCanTake = false + local isTaskCanFinish = false + local actId = 1 + local configs = XActivityBriefConfigs.GetNowActivityEntryConfig() + for key, value in pairs(configs) do + if value.SkipId == 1400008 then + actId = value.Id + end + end + if not SlotMachineDataEntityAllList[actId] then + return false + end + for index, machineData in ipairs(SlotMachineDataEntityAllList[actId]) do + local machineID = machineData:GetId() + if XSlotMachineManager.CheckHasRewardCanTake(machineID,actId) then + isRewardCanTake = true + break + end + if XSlotMachineManager.CheckTaskCanTakeByAllType(machineID,actId) then + isTaskCanFinish = true + break + end + end + local result = isRewardCanTake or isTaskCanFinish + return result + end + + function XSlotMachineManager.CheckRedPointL() + local isRewardCanTake = false + local isTaskCanFinish = false + local actId = 2 + local configs = XActivityBriefConfigs.GetNowActivityEntryConfig() + for key, value in pairs(configs) do + if value.SkipId == 1400009 then + actId = value.Id + end + end + if not SlotMachineDataEntityAllList[actId] then + return false + end + for index, machineData in ipairs(SlotMachineDataEntityAllList[actId]) do + local machineID = machineData:GetId() + if XSlotMachineManager.CheckHasRewardCanTake(machineID,actId) then + isRewardCanTake = true + break + end + if XSlotMachineManager.CheckTaskCanTakeByAllType(machineID,actId) then + isTaskCanFinish = true + break + end + end + local result = isRewardCanTake or isTaskCanFinish + return result + end + + XSlotMachineManager.Init() + return XSlotMachineManager + end + + XRpc.NotifyAllSlotMachineInfo = function(req) + XDataCenter.SlotMachineManager.NotifyAllSlotMachineInfo(req) + end \ No newline at end of file diff --git a/Resources/Scripts/XOverseas/XUi/XUiBubbleTip/XUiBubbleTip.lua b/Resources/Scripts/XOverseas/XUi/XUiBubbleTip/XUiBubbleTip.lua new file mode 100644 index 00000000..d994d84c --- /dev/null +++ b/Resources/Scripts/XOverseas/XUi/XUiBubbleTip/XUiBubbleTip.lua @@ -0,0 +1,18 @@ +local XUiBubbleTip = XLuaUiManager.Register(XLuaUi, "UiBubbleTip") + +function XUiBubbleTip:OnAwake() + self.XSetBubbleTipLayout:SetParameters(self.TextBg, 400, 100) +end + +function XUiBubbleTip:OnStart(pointOrTouchData, content) + self.TxtContent.text = content + self.XSetBubbleTipLayout:SetUiLayout(pointOrTouchData.position) +end + +function XUiBubbleTip:OnEnable() + self:PlayAnimation("AnimEnableManual") +end + +function XUiBubbleTip:OnDisable() + self.AnimEnableManual:Stop() +end \ No newline at end of file diff --git a/Resources/Scripts/XOverseas/XUi/XUiFireworks/XUiFireworks.lua b/Resources/Scripts/XOverseas/XUi/XUiFireworks/XUiFireworks.lua new file mode 100644 index 00000000..66a1329a --- /dev/null +++ b/Resources/Scripts/XOverseas/XUi/XUiFireworks/XUiFireworks.lua @@ -0,0 +1,106 @@ +local XUiFireworks = XClass(nil, "XUiFireworks") +local CSScheduleMng = CS.XScheduleManager + +function XUiFireworks:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + + XTool.InitUiObject(self) + self:InitAddListen() +end + +function XUiFireworks:OnHide() + self:Clear() +end + +function XUiFireworks:OnShow() + +end + +function XUiFireworks:Clear() + if self.AnimationSchedule ~= nil then + CSScheduleMng.UnSchedule(self.AnimationSchedule) + self.AnimationSchedule = nil + end + for i = 1, 3 do + self.EffectAList[i]:SetActiveEx(false) + self.EffectBList[i]:SetActiveEx(false) + end +end + +function XUiFireworks:InitAddListen() + self.EffectAList = {} + self.EffectBList = {} + for i = 1, 3 do + self.EffectAList[i] = self.Transform:Find("PanelRound1/EffectA" .. i).gameObject + self.EffectBList[i] = self.Transform:Find("PanelRound1/EffectB" .. i).gameObject + end + self.BtnTab.CallBack = function() self:OnDrawClick() end + self.BtnHelp.CallBack = function() XLuaUiManager.Open("UiFireworksLog") end +end + +function XUiFireworks:OnDrawClick() + if not XDataCenter.FireworksManager.IsPlayerQualified() then + XUiManager.TipText("EnKrFireworksLeveldonotenough") + return + end + self:Clear() + self.BtnTab.gameObject:SetActiveEx(false) + XDataCenter.FireworksManager.OnFire(function(success, res) + if not success then + XUiManager.TipCode(res.Code) + return + end + + local rewardList = res.RewardGoodsList + local dropId = res.DropId + local effectId = XDataCenter.FireworksManager.GetEffectIdByDropId(dropId) + + if effectId == nil or effectId <= 0 or effectId > 3 then + XLog.Error("Firework Effect Id doesn't exist") + XLuaUiManager.Open("UiObtain", rewardList) + return + end + + self.EffectAList[effectId]:SetActiveEx(true) + XLuaUiManager.SetAnimationMask("Firework", true) + self.AnimationSchedule = CSScheduleMng.ScheduleOnce(function() + self.EffectAList[effectId]:SetActiveEx(false) + XLuaUiManager.SetAnimationMask("Firework", false) + local function playEffectB() + self.EffectBList[effectId]:SetActiveEx(true) + end + XLuaUiManager.Open("UiObtain", rewardList, nil, playEffectB, playEffectB) + XEventManager.DispatchEvent(XEventId.EVENT_CARD_REFRESH_WELFARE_BTN) + + if XDataCenter.FireworksManager.HasAvailableFireTimes() then + self.BtnTab.gameObject:SetActiveEx(true) + end + end, 1800) + end) +end + +function XUiFireworks:Refresh(configId) + XEventManager.DispatchEvent(XEventId.EVENT_SING_IN_OPEN_BTN, true) + for i = 1, 3 do + self.EffectAList[i]:SetActiveEx(false) + self.EffectBList[i]:SetActiveEx(false) + end + if XDataCenter.FireworksManager.HasAvailableFireTimes() then + self.BtnTab.gameObject:SetActiveEx(true) + else + self.BtnTab.gameObject:SetActiveEx(false) + self:PlayLastFirework() + end +end + +function XUiFireworks:PlayLastFirework() + local lastId = XDataCenter.FireworksManager.GetLastRecordType() + if lastId == nil then + return + end + self.EffectBList[lastId]:SetActiveEx(true) +end + +return XUiFireworks \ No newline at end of file diff --git a/Resources/Scripts/XOverseas/XUi/XUiFireworks/XUiFireworksLog.lua b/Resources/Scripts/XOverseas/XUi/XUiFireworks/XUiFireworksLog.lua new file mode 100644 index 00000000..463f8d30 --- /dev/null +++ b/Resources/Scripts/XOverseas/XUi/XUiFireworks/XUiFireworksLog.lua @@ -0,0 +1,34 @@ + +local this = XLuaUiManager.Register(XLuaUi, "UiFireworksLog") +local panelRule = require("XOverseas/XUi/XUiFireworks/XUiFireworksPanelRule") +local panelRecord = require("XOverseas/XUi/XUiFireworks/XUiFireworksPanelRecord") + +function this:OnAwake() + self:AutoAddListener() +end + +function this:OnStart() + self.Panels[1].Refresh() + self.Panels[2].Refresh() + self.PanelTabTc:SelectIndex(1) +end + +function this:AutoAddListener() + + local tabList = { self.BtnTab1, self.BtnTab2 } + self.PanelTabTc:Init(tabList, function(index) + self:SelectPanel(index) + end) + + self.BtnTanchuangClose.CallBack = function() XLuaUiManager.Close("UiFireworksLog") end + + panelRule.Init(self.Panel1.gameObject) + panelRecord.Init(self.Panel2.gameObject) + + self.Panels = { panelRule, panelRecord } +end + +function this:SelectPanel(index) + self.Panels[index].Show() + self.Panels[3 - index].Hide() +end \ No newline at end of file diff --git a/Resources/Scripts/XOverseas/XUi/XUiFireworks/XUiFireworksPanelRecord.lua b/Resources/Scripts/XOverseas/XUi/XUiFireworks/XUiFireworksPanelRecord.lua new file mode 100644 index 00000000..790f175e --- /dev/null +++ b/Resources/Scripts/XOverseas/XUi/XUiFireworks/XUiFireworksPanelRecord.lua @@ -0,0 +1,43 @@ +local this = {} + +function this.Init(go) + this.GameObject = go + this.Transform = go.transform + XTool.InitUiObject(this) + this.GridLogLow.gameObject:SetActiveEx(false) + this.Pools = {} + for i = 1, 10 do + local item = {} + item.GameObject = CS.UnityEngine.Object.Instantiate(this.GridLogLow.gameObject) + item.Transform = item.GameObject.transform + XTool.InitUiObject(item) + item.Transform:SetParent(this.PanelContent, false) + item.GameObject:SetActiveEx(false) + this.Pools[i] = item + end +end + +function this.Refresh() + local records = XDataCenter.FireworksManager.GetRecords() + for i = 1, #records do + local name, info, time = XDataCenter.FireworksManager.GetRecordString(records[i]) + this.Pools[i].TxtName.text = name + this.Pools[i].TxtItems.text = info + this.Pools[i].TxtTime.text = time + this.Pools[i].GameObject:SetActiveEx(true) + end + + for i = #records + 1, #this.Pools do + this.Pools[i].GameObject:SetActiveEx(false) + end +end + +function this.Show() + this.GameObject:SetActiveEx(true) +end + +function this.Hide() + this.GameObject:SetActiveEx(false) +end + +return this \ No newline at end of file diff --git a/Resources/Scripts/XOverseas/XUi/XUiFireworks/XUiFireworksPanelRule.lua b/Resources/Scripts/XOverseas/XUi/XUiFireworks/XUiFireworksPanelRule.lua new file mode 100644 index 00000000..79a2215f --- /dev/null +++ b/Resources/Scripts/XOverseas/XUi/XUiFireworks/XUiFireworksPanelRule.lua @@ -0,0 +1,37 @@ +local this = {} + + +function this.Init(go) + this.GameObject = go + this.Transform = go.transform + local ruleConfig = XDataCenter.FireworksManager.GetRules() + XTool.InitUiObject(this) + this.PanelTxt.gameObject:SetActiveEx(false) + for i = 1, #ruleConfig.RuleTitle do + local go = CS.UnityEngine.Object.Instantiate(this.PanelTxt.gameObject) + go.transform:SetParent(this.PanelContent, false) + local item = {} + item.GameObject = go + item.Transform = go.transform + XTool.InitUiObject(item) + item.GameObject:SetActiveEx(true) + item.TxtRuleTittle.text = ruleConfig.RuleTitle[i] + local toReplace = ruleConfig.RuleContent[i] + toReplace = string.gsub(toReplace, "\\n", "\n") + item.TxtRule.text = toReplace + end +end + +function this.Refresh() + +end + +function this.Show() + this.GameObject:SetActiveEx(true) +end + +function this.Hide() + this.GameObject:SetActiveEx(false) +end + +return this \ No newline at end of file diff --git a/Resources/Scripts/XOverseas/XUi/XUiSlotMachine/XUiSlotMachine.lua b/Resources/Scripts/XOverseas/XUi/XUiSlotMachine/XUiSlotMachine.lua new file mode 100644 index 00000000..8d53d7c9 --- /dev/null +++ b/Resources/Scripts/XOverseas/XUi/XUiSlotMachine/XUiSlotMachine.lua @@ -0,0 +1,259 @@ +local CSXTextManagerGetText = CS.XTextManager.GetText +local CSXScheduleManager = CS.XScheduleManager +local tablePack = table.pack + +local XUiSlotMachineRewardPanel = require("XOverseas/XUi/XUiSlotMachine/XUiSlotMachineRewardPanel") +local XUiSlotMachinePanel = require("XOverseas/XUi/XUiSlotMachine/XUiSlotMachinePanel") +local XUiSlotMachineTipsPanel = require("XOverseas/XUi/XUiSlotMachine/XUiSlotMachineTipsPanel") + +local XUiSlotMachine = XLuaUiManager.Register(XLuaUi, "UiSlotmachine") + +function XUiSlotMachine:OnAwake() + self.RewardPanel = XUiSlotMachineRewardPanel.New(self, self.RewardBg) + self.MachinePanel = XUiSlotMachinePanel.New(self, self.PanelSlotmachine) + self.TipsPanel = XUiSlotMachineTipsPanel.New(self, self.PanelTips) +end + +function XUiSlotMachine:OnStart() + self:AutoAddListener() + local machineId = XDataCenter.SlotMachineManager.GetCurMachineId() + self:Refresh(machineId) +end + +function XUiSlotMachine:OnEnable() + self.BtnTask:ShowReddot(XDataCenter.SlotMachineManager.CheckTaskCanTakeByAllType(self.CurMachineEntity:GetId())) + self:StartActivityTimer() +end + +function XUiSlotMachine:OnDisable() + self:StopActivityTimer() +end + +function XUiSlotMachine:OnDestroy() + XEventManager.UnBindEvent(self) +end + +function XUiSlotMachine:AutoAddListener() + self.BtnBack.CallBack = function() self:Close() end + self.BtnMainUi.CallBack = function() XLuaUiManager.RunMain() end + self.BtnStart.CallBack = function() self:OnBtnStartClick() end + self.BtnNextMachine.CallBack = function() self:OnBtnNextMachineClick() end + self.BtnRules.CallBack = function() self:OnBtnRulesClick() end + self.BtnTask.CallBack = function() self:OnBtnTaskClick() end + self.BtnObtain.CallBack = function() self:OnBtnObtainClick() end +end + +function XUiSlotMachine:OnGetEvents() + return { + XEventId.EVENT_SLOT_MACHINE_STARTED, + XEventId.EVENT_SLOT_MACHINE_GET_REWARD, + XEventId.EVENT_SLOT_MACHINE_FINISH_TASK, + } +end + +function XUiSlotMachine:OnNotify(evt, ...) + local args = tablePack(...) + if evt == XEventId.EVENT_SLOT_MACHINE_STARTED then + self.RaycastCover.gameObject:SetActiveEx(true) + self.EffectPinmu.gameObject:SetActiveEx(false) -- 关闭屏幕特效 + self:PlayAnimation("SlotmachineEnable", function() + self.RaycastCover.gameObject:SetActiveEx(false) + self.HidePanel.gameObject:SetActiveEx(false) + self.EffectFloor.gameObject:SetActiveEx(true) -- 底部流光特效 + self.MachinePanel:StartRoll(args[1], function() + self.EffectDajiang.gameObject:SetActiveEx(false) + if XDataCenter.SlotMachineManager.CheckIconListIsPrix(args[1]) then + CSXScheduleManager.ScheduleOnce(function() + self.EffectDajiang.gameObject:SetActiveEx(true) + CSXScheduleManager.ScheduleOnce(function() + self.EffectFloor.gameObject:SetActiveEx(false) -- 底部流光特效 + self:ShowObtainpointsTips(args[2]) + end, 1100) + end, 600) + else + CSXScheduleManager.ScheduleOnce(function() + self.EffectFloor.gameObject:SetActiveEx(false) -- 底部流光特效 + self:ShowObtainpointsTips(args[2]) + end, 1000) + end + end) + end) + elseif evt == XEventId.EVENT_SLOT_MACHINE_GET_REWARD then + self.RewardPanel:Refresh(self.CurMachineEntity:GetId()) + elseif evt == XEventId.EVENT_SLOT_MACHINE_FINISH_TASK then + self.BtnTask:ShowReddot(XDataCenter.SlotMachineManager.CheckTaskCanTakeByAllType(self.CurMachineEntity:GetId())) + end +end + +function XUiSlotMachine:OnBtnStartClick() + if self.CurMachineEntity then + local machineState = XDataCenter.SlotMachineManager.CheckSlotMachineState(self.CurMachineEntity:GetId()) + if machineState == XSlotMachineConfigs.SlotMachineState.Locked then + XUiManager.TipError(CSXTextManagerGetText("SlotMachineIsLocked")) + elseif machineState == XSlotMachineConfigs.SlotMachineState.Finish then + XUiManager.TipError(CSXTextManagerGetText("SlotMachineIsFinish")) + else + XDataCenter.SlotMachineManager.StartSlotMachine(self.CurMachineEntity:GetId()) + end + end +end + +function XUiSlotMachine:OnBtnNextMachineClick() + if self.CurMachineEntity then + self:Refresh(XDataCenter.SlotMachineManager.GetNextMachineId(self.CurMachineEntity:GetId())) + self:PlayAnimation("QieHuan") + end +end + +function XUiSlotMachine:OnBtnRulesClick() + self:OpenChildUi("UiSlotmachineRules", self) +end + +function XUiSlotMachine:OnBtnTaskClick() + self:OpenChildUi("UiSlotmachineTask", self) +end + +function XUiSlotMachine:OnBtnObtainClick() + self.PanelObtainpointsTips.gameObject:SetActiveEx(false) + self.HidePanel.gameObject:SetActiveEx(true) + self:RefreshOnFinishRoll() + self:PlayAnimation("SlotmachineDisable", function() + self.EffectPinmu.gameObject:SetActiveEx(true) -- 打开屏幕特效 + end) +end + +function XUiSlotMachine:Refresh(machineId) + self.CurMachineEntity = XDataCenter.SlotMachineManager.GetSlotMachineDataEntityById(machineId) + self:RefreshBg() + self:RefreshTitle() + self:RefreshAssetPanel() + self:RefreshBtnStart() + self:RefreshBtnNextMachine() + self.RewardPanel:Refresh(machineId, true) + self.MachinePanel:Refresh(machineId) + self.TipsPanel:Refresh(machineId) + self:AddItemUpdateListener() + self.Effect01.gameObject:SetActiveEx(false) + self.Effect02.gameObject:SetActiveEx(false) + self.Effect03.gameObject:SetActiveEx(false) + self.EffectDajiang.gameObject:SetActiveEx(false) +end + +function XUiSlotMachine:RefreshOnFinishRoll() + if self.CurMachineEntity then + local machineId = self.CurMachineEntity:GetId() + self:RefreshBtnStart() + self.RewardPanel:Refresh(machineId) + self.TipsPanel:Refresh(machineId) + end +end + +function XUiSlotMachine:RefreshBg() + if self.CurMachineEntity then + self.BgImage:SetRawImage(self.CurMachineEntity:GetBgImage()) + end +end + +function XUiSlotMachine:RefreshTitle() + if self.CurMachineEntity then + self.TxtTitle.text = self.CurMachineEntity:GetName() + self.TxtTimeDes.text = CSXTextManagerGetText("SlotMachineTimeTextDesc") + self.BtnTask:ShowReddot(XDataCenter.SlotMachineManager.CheckTaskCanTakeByAllType(self.CurMachineEntity:GetId())) + end +end + +function XUiSlotMachine:RefreshAssetPanel() + if self.CurMachineEntity then + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, self.CurMachineEntity:GetConsumeItemId()) + if XDataCenter.SlotMachineManager.GetSlotMachineActExchangeType() == XSlotMachineConfigs.ExchangeType.OnlyTask then + XUiHelper.RegisterClickEvent(self, self.AssetPanel.BtnBuyJump1, function() + self:OnBtnTaskClick() + end) + end + end +end + +function XUiSlotMachine:RefreshBtnStart() + if self.CurMachineEntity then + local machineState = XDataCenter.SlotMachineManager.CheckSlotMachineState(self.CurMachineEntity:GetId()) + if machineState == XSlotMachineConfigs.SlotMachineState.Locked then + self.BtnStart:SetDisable(true) + self.BtnStart:SetName(CSXTextManagerGetText("SlotMachineBtnStartLockName")) + self.ConsumeCount.text = self.CurMachineEntity:GetConsumeCount() + else + self.BtnStart:SetDisable(false) + self.BtnStart:SetName(CSXTextManagerGetText("SlotMachineBtnStartUnLockName")) + if XDataCenter.SlotMachineManager.CheckConsumeItemIsEnough(self.CurMachineEntity:GetId()) then + self.ConsumeCount.text = self.CurMachineEntity:GetConsumeCount() + else + self.ConsumeCount.text = string.format("%s%s%s", "", self.CurMachineEntity:GetConsumeCount(), "") + end + end + + self.ConsumeImage:SetRawImage(XDataCenter.ItemManager.GetItemIcon(self.CurMachineEntity:GetConsumeItemId())) + end +end + +function XUiSlotMachine:RefreshBtnNextMachine() + local machineEntityList = XDataCenter.SlotMachineManager.GetSlotMachineDataEntityList() + if #machineEntityList <= 1 then + self.BtnNextMachine.gameObject:SetActiveEx(false) + return + end + if self.CurMachineEntity then + self.BtnNextMachine:SetSprite(self.CurMachineEntity:GetNextMachineBtnImage()) + self.BtnNextMachine:SetName(self.CurMachineEntity:GetNextMachineBtnText()) + local nextMachineId = XDataCenter.SlotMachineManager.GetNextMachineId(self.CurMachineEntity:GetId()) + self.BtnNextMachine:ShowReddot(XDataCenter.SlotMachineManager.CheckHasRewardCanTake(nextMachineId)) + end +end + +function XUiSlotMachine:ShowObtainpointsTips(addScore) + if self.CurMachineEntity then + self.PanelObtainpointsTips.gameObject:SetActiveEx(true) + self.TxtScore.text = addScore + self:PlayAnimation("TipsEnable") + end +end + +function XUiSlotMachine:AddItemUpdateListener() + if self.CurMachineEntity then + XEventManager.UnBindEvent(self) + XDataCenter.ItemManager.AddCountUpdateListener(self.CurMachineEntity:GetConsumeItemId(), function() + self:RefreshBtnStart() + end, self) + end +end + +function XUiSlotMachine:StartActivityTimer() + local startTime, endTime = XDataCenter.SlotMachineManager.GetActivityTime() + local nowTime = XTime.GetServerNowTimestamp() + self.TxtTime.text = XUiHelper.GetTime(endTime - nowTime, XUiHelper.TimeFormatType.ACTIVITY) + if nowTime < startTime then + XUiManager.TipMsg(CSXTextManagerGetText("SlotMachineTimeNotOpen"), XUiManager.UiTipType.Wrong, function() + XLuaUiManager.RunMain() + end) + elseif nowTime > endTime then + XUiManager.TipMsg(CSXTextManagerGetText("SlotMachineTimeEnd"), XUiManager.UiTipType.Wrong, function() + XLuaUiManager.RunMain() + end) + else + self.ActivityTimer = CSXScheduleManager.ScheduleForever(function() + local time = XTime.GetServerNowTimestamp() + if time > endTime then + XUiManager.TipError(CSXTextManagerGetText("SlotMachineTimeEnd")) + self:StopActivityTimer() + XLuaUiManager.RunMain() + return + end + self.TxtTime.text = XUiHelper.GetTime(endTime - time, XUiHelper.TimeFormatType.ACTIVITY) + end, CSXScheduleManager.SECOND, 0) + end +end + +function XUiSlotMachine:StopActivityTimer() + if self.ActivityTimer then + CSXScheduleManager.UnSchedule(self.ActivityTimer) + self.ActivityTimer = nil + end +end \ No newline at end of file diff --git a/Resources/Scripts/XOverseas/XUi/XUiSlotMachine/XUiSlotMachineIconItem.lua b/Resources/Scripts/XOverseas/XUi/XUiSlotMachine/XUiSlotMachineIconItem.lua new file mode 100644 index 00000000..e7bb6202 --- /dev/null +++ b/Resources/Scripts/XOverseas/XUi/XUiSlotMachine/XUiSlotMachineIconItem.lua @@ -0,0 +1,20 @@ +local XUiSlotMachineIconItem = XClass(nil, "XUiSlotMachineIconItem") + +function XUiSlotMachineIconItem:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RectTransform = ui + self.RootUi = rootUi + XTool.InitUiObject(self) +end + +function XUiSlotMachineIconItem:OnCreate(data) + local IconImageUrl = XSlotMachineConfigs.GetIconImageById(data.IconId) + self.IconImage:SetRawImage(IconImageUrl) +end + +function XUiSlotMachineIconItem:SetActiveEx(bool) + self.GameObject:SetActiveEx(bool) +end + +return XUiSlotMachineIconItem \ No newline at end of file diff --git a/Resources/Scripts/XOverseas/XUi/XUiSlotMachine/XUiSlotMachinePanel.lua b/Resources/Scripts/XOverseas/XUi/XUiSlotMachine/XUiSlotMachinePanel.lua new file mode 100644 index 00000000..1d32ec0f --- /dev/null +++ b/Resources/Scripts/XOverseas/XUi/XUiSlotMachine/XUiSlotMachinePanel.lua @@ -0,0 +1,151 @@ +local CSDGTweeningEase_Linear = CS.DG.Tweening.Ease.Linear +local Vector3 = CS.UnityEngine.Vector3 + +local tableInsert = table.insert + +local XUiSlotMachineIconItem = require("XOverseas/XUi/XUiSlotMachine/XUiSlotMachineIconItem") + +local XUiSlotMachinePanel = XClass(nil, "XUiSlotMachinePanel") + +local ROLL_ONE_CIRCLE_TIME = 0.5 -- 匀速滚动一圈时间 +local ICON_LAST_ROLL_TIME = 0.8 +local ICON_LIST01_ROLL_COUNT = 4 +local ICON_LIST02_ROLL_COUNT = 6 +local ICON_LIST03_ROLL_COUNT = 8 + +function XUiSlotMachinePanel:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RectTransform = ui + self.RootUi = rootUi + XTool.InitUiObject(self) + + self:Init() +end + +function XUiSlotMachinePanel:Init() + self.IconHeight = self.IconTmp.rect.height + self.IconsPool1 = {} + self.IconsPool2 = {} + self.IconsPool3 = {} +end + +function XUiSlotMachinePanel:Refresh(machineId) + self.CurMachineEntity = XDataCenter.SlotMachineManager.GetSlotMachineDataEntityById(machineId) + self.MachineState = XDataCenter.SlotMachineManager.CheckSlotMachineState(machineId) + if self.MachineState == XSlotMachineConfigs.SlotMachineState.Locked then + self.SlotmachineLock:SetRawImage(self.CurMachineEntity:GetMachineLockImage()) + self.SlotmachineLock.gameObject:SetActiveEx(true) + self.SlotmachineBg.gameObject:SetActiveEx(false) + self.RootUi.EffectPinmu.gameObject:SetActiveEx(false) + self.RootUi.EffectWord.gameObject:SetActiveEx(false) -- 文字特效 + else + self.SlotmachineBg:SetRawImage(self.CurMachineEntity:GetMachineImage()) + self.SlotmachineBg.gameObject:SetActiveEx(true) + self.SlotmachineLock.gameObject:SetActiveEx(false) + self.RootUi.EffectPinmu.gameObject:SetActiveEx(true) + self.RootUi.EffectWord.gameObject:SetActiveEx(machineId == 2) -- 文字特效 + + self:RefreshWindow() + end +end + +function XUiSlotMachinePanel:RefreshWindow() + if self.CurMachineEntity then + local reverseIconList = self:GetReverseTable(self.CurMachineEntity:GetIcons()) + self.MaxIconListHeight = #reverseIconList * self.IconHeight + tableInsert(reverseIconList, reverseIconList[1]) + + local IconsData = {} + self.IconIdToIndex = {} + local iconsCount = #reverseIconList + for index, iconId in ipairs(reverseIconList) do + local data = { + IconId = iconId, + } + tableInsert(IconsData, data) + local positionIndex = (iconsCount-index+1) + if not self.IconIdToIndex[iconId] then + self.IconIdToIndex[iconId] = positionIndex + end + end + + local onCreateCb = function (item, data) + item:SetActiveEx(true) + item:OnCreate(data) + end + + XUiHelper.CreateTemplates(self.RootUi, self.IconsPool1, IconsData, XUiSlotMachineIconItem.New, self.IconTmp, self.IconList01, onCreateCb) + XUiHelper.CreateTemplates(self.RootUi, self.IconsPool2, IconsData, XUiSlotMachineIconItem.New, self.IconTmp, self.IconList02, onCreateCb) + XUiHelper.CreateTemplates(self.RootUi, self.IconsPool3, IconsData, XUiSlotMachineIconItem.New, self.IconTmp, self.IconList03, onCreateCb) + end +end + +function XUiSlotMachinePanel:StartRoll(iconIdList, cb) + if #iconIdList ~= 3 then + XLog.Error("Icon Count Is Not 3") + return + end + self:PlayRollAnimation(self.IconIdToIndex[iconIdList[1]], self.IconIdToIndex[iconIdList[2]], self.IconIdToIndex[iconIdList[3]], cb) +end + +function XUiSlotMachinePanel:PlayRollAnimation(idx1, idx2, idx3, cb) + self.IconList01.transform:DOLocalMoveY(-self.MaxIconListHeight, ROLL_ONE_CIRCLE_TIME):SetEase(CSDGTweeningEase_Linear):OnComplete(function() + self:RollUniformSpeed(self.IconList01.gameObject, ICON_LIST01_ROLL_COUNT, function() + self:RollToIconByIndex(self.IconList01.gameObject, idx1, function() + self.RootUi.Effect01.gameObject:SetActiveEx(false) + self.RootUi.Effect01.gameObject:SetActiveEx(true) + end) + end) + end) + self.IconList02.transform:DOLocalMoveY(-self.MaxIconListHeight, ROLL_ONE_CIRCLE_TIME):SetEase(CSDGTweeningEase_Linear):OnComplete(function() + self:RollUniformSpeed(self.IconList02.gameObject, ICON_LIST02_ROLL_COUNT, function() + self:RollToIconByIndex(self.IconList02.gameObject, idx2, function() + self.RootUi.Effect02.gameObject:SetActiveEx(false) + self.RootUi.Effect02.gameObject:SetActiveEx(true) + end) + end) + end) + self.IconList03.transform:DOLocalMoveY(-self.MaxIconListHeight, ROLL_ONE_CIRCLE_TIME):SetEase(CSDGTweeningEase_Linear):OnComplete(function() + self:RollUniformSpeed(self.IconList03.gameObject, ICON_LIST03_ROLL_COUNT, function() + self:RollToIconByIndex(self.IconList03.gameObject, idx3, function() + self.RootUi.Effect03.gameObject:SetActiveEx(false) + self.RootUi.Effect03.gameObject:SetActiveEx(true) + if cb then cb() end + end) + end) + end) +end + +function XUiSlotMachinePanel:RollUniformSpeed(gameObject, rollCount, cb) + gameObject.transform.localPosition = Vector3(gameObject.transform.localPosition.x, 0, 0) + gameObject.transform:DOLocalMoveY(-self.MaxIconListHeight, ROLL_ONE_CIRCLE_TIME):SetLoops(rollCount):SetEase(CSDGTweeningEase_Linear):OnComplete(function() + if cb then cb() end + end) +end + +function XUiSlotMachinePanel:RollToIconByIndex(gameObject, index , cb) + if index > 0 then + local iconCount = index - 1 + local needRollPix = iconCount * self.IconHeight + gameObject.transform.localPosition = Vector3(gameObject.transform.localPosition.x, 0, 0) + if cb then + gameObject.transform:DOLocalMoveY(-needRollPix, ICON_LAST_ROLL_TIME):OnComplete(function() + cb() + end) + else + gameObject.transform:DOLocalMoveY(-needRollPix, ICON_LAST_ROLL_TIME) + end + end +end + +function XUiSlotMachinePanel:GetReverseTable(arr) -- 翻转数组(只能是数组) + local tmp = {} + for i = #arr, 1, -1 do + tableInsert(tmp, arr[i]) + end + + return tmp +end + +return XUiSlotMachinePanel \ No newline at end of file diff --git a/Resources/Scripts/XOverseas/XUi/XUiSlotMachine/XUiSlotMachineRewardItem.lua b/Resources/Scripts/XOverseas/XUi/XUiSlotMachine/XUiSlotMachineRewardItem.lua new file mode 100644 index 00000000..e384867e --- /dev/null +++ b/Resources/Scripts/XOverseas/XUi/XUiSlotMachine/XUiSlotMachineRewardItem.lua @@ -0,0 +1,53 @@ +local XUiSlotMachineRewardItem = XClass(nil, "XUiSlotMachineRewardItem") + +function XUiSlotMachineRewardItem:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RectTransform = ui + self.RootUi = rootUi + XTool.InitUiObject(self) + + self:Init() +end + +function XUiSlotMachineRewardItem:Init() + self.CommonGrid = XUiGridCommon.New(self.RootUi, self.Reward) + if not self.CommonGrid.TxtCount then + self.CommonGrid.TxtCount = XUiHelper.TryGetComponent(self.CommonGrid.Transform, "PanelTxt/TxtCount", "Text") + end + self.BtnActive.CallBack = function () + if self.BtnActiveCb then self.BtnActiveCb() end + end +end + +function XUiSlotMachineRewardItem:OnCreat(data) + local rewardData = XRewardManager.GetRewardList(data.RewardId)[1] + self.CommonGrid:Refresh(rewardData) + self.TxtValue.text = data.RewardScore +end + +function XUiSlotMachineRewardItem:SetTakedState(rewardState) + if rewardState == XSlotMachineConfigs.RewardTakeState.NotFinish then + self.BtnActive.gameObject:SetActiveEx(false) + self.ImgRe.gameObject:SetActiveEx(false) + self.PanelEffect.gameObject:SetActiveEx(false) + elseif rewardState == XSlotMachineConfigs.RewardTakeState.NotTook then + self.BtnActive.gameObject:SetActiveEx(true) + self.ImgRe.gameObject:SetActiveEx(false) + self.PanelEffect.gameObject:SetActiveEx(true) + elseif rewardState == XSlotMachineConfigs.RewardTakeState.Took then + self.BtnActive.gameObject:SetActiveEx(false) + self.ImgRe.gameObject:SetActiveEx(true) + self.PanelEffect.gameObject:SetActiveEx(false) + end +end + +function XUiSlotMachineRewardItem:SetBtnActiveCallBack(cb) + self.BtnActiveCb = cb +end + +function XUiSlotMachineRewardItem:SetActiveEx(bool) + self.GameObject:SetActiveEx(bool) +end + +return XUiSlotMachineRewardItem \ No newline at end of file diff --git a/Resources/Scripts/XOverseas/XUi/XUiSlotMachine/XUiSlotMachineRewardPanel.lua b/Resources/Scripts/XOverseas/XUi/XUiSlotMachine/XUiSlotMachineRewardPanel.lua new file mode 100644 index 00000000..60e21838 --- /dev/null +++ b/Resources/Scripts/XOverseas/XUi/XUiSlotMachine/XUiSlotMachineRewardPanel.lua @@ -0,0 +1,135 @@ +local tableInsert = table.insert +local Vector3 = CS.UnityEngine.Vector3 + +local XUiSlotMachineRewardItem = require("XOverseas/XUi/XUiSlotMachine/XUiSlotMachineRewardItem") + +local XUiSlotMachineRewardPanel = XClass(nil, "XUiSlotMachineRewardPanel") + +function XUiSlotMachineRewardPanel:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RectTransform = ui + self.RootUi = rootUi + XTool.InitUiObject(self) + + self:Init() +end + +function XUiSlotMachineRewardPanel:Init() + self.RewardsPool = {} +end + +function XUiSlotMachineRewardPanel:Refresh(machineId, isResetContentPos) + self.CurMachineEntity = XDataCenter.SlotMachineManager.GetSlotMachineDataEntityById(machineId) + self.CurMachineConfig = XSlotMachineConfigs.GetSlotMachinesTemplateById(machineId) + self.CurMachineActAmount = #(XSlotMachineConfigs.GetSlotMachinesActivityTemplate()) + local totalScore = self.CurMachineEntity:GetTotalScore() + self.TxtCurScore.text = totalScore + --self.ImgProgress.fillAmount = totalScore / self.CurMachineEntity:GetScoreLimit() + if isResetContentPos then + self.Content.transform.localPosition = Vector3(self.Content.transform.localPosition.x, 0, 0) + end + self:RefreshRewardGrid() + self:SetMoreWardsState() + self.Content.transform:DOLocalMoveY(self.Content.transform.localPosition.y - 1, 0.05):OnComplete(function() -- 这里目的是让content移动一下,规避奖励特效不出现问题 + self.Content.transform:DOLocalMoveY(self.Content.transform.localPosition.y + 1, 0.05) + end) +end + +function XUiSlotMachineRewardPanel:RefreshRewardGrid() + if self.CurMachineEntity then + local rewardList = self:GetReverseTable(self.CurMachineEntity:GetRewardIds()) + local rewardScore = self:GetReverseTable(self.CurMachineEntity:GetRewardScores()) + local totalScore = self.CurMachineEntity:GetTotalScore() + + local rewardDatas = {} + local rewardCount = #rewardList + local curReachIndex = 0 + for index, rewardId in ipairs(rewardList) do + local data = { + Index = (rewardCount-index+1), + RewardId = rewardId, + RewardScore = rewardScore[index], + } + if totalScore>=rewardScore[index] then + curReachIndex = curReachIndex+1 + end + tableInsert(rewardDatas, data) + end + local onCreatCb = function (item, data) + item:SetActiveEx(true) + item:OnCreat(data) + item:SetTakedState(XDataCenter.SlotMachineManager.CheckRewardState(self.CurMachineEntity:GetId(), data.Index)) + item:SetBtnActiveCallBack(function () self:TakeReward(data.Index) end) + end + local process = 1 + local oneProcess = math.floor(1/rewardCount*100)/100 --每一份奖励所占进度 + if curReachIndex<10 then + local nextReachIndex = rewardCount-curReachIndex + local temp = rewardScore[nextReachIndex] + local tempL = 0 + if nextReachIndex < 10 then + tempL = rewardScore[nextReachIndex+1] + end + local processL = ((totalScore-tempL)/(temp-tempL))*oneProcess + process = (math.floor((curReachIndex/rewardCount)*100)/100)+processL + process = math.floor(process*100)/100 + end + self.ImgProgress.fillAmount = process + XUiHelper.CreateTemplates(self.RootUi, self.RewardsPool, rewardDatas, XUiSlotMachineRewardItem.New, self.RewardRoot, self.RewardPanel, onCreatCb) + end +end + +function XUiSlotMachineRewardPanel:SetMoreWardsState() + if self.CurMachineEntity then + local rewardList = self.CurMachineEntity:GetRewardIds() + local rewardScore = self.CurMachineEntity:GetRewardScores() + if #rewardList > 5 then + for i = 6, #rewardList do + local rewardState = XDataCenter.SlotMachineManager.CheckRewardState(self.CurMachineEntity:GetId(), i) + if rewardState == XSlotMachineConfigs.RewardTakeState.NotTook then + --self.PanelMorerewards.gameObject:SetActiveEx(true) + self:SetMoreRewardPanelActive(true) + return + end + end + end + end + --self.PanelMorerewards.gameObject:SetActiveEx(false) + self:SetMoreRewardPanelActive(false) +end + +function XUiSlotMachineRewardPanel:SetMoreRewardPanelActive(flag) + if not flag then + for i = 1, self.CurMachineActAmount do + if self["Highlight"..i] then + self["Highlight"..i].gameObject:SetActiveEx(false) + end + end + else + for i = 1, self.CurMachineActAmount do + if self["Highlight"..i] then + if i == self.CurMachineConfig.HighLight then + self["Highlight"..i].gameObject:SetActiveEx(true) + else + self["Highlight"..i].gameObject:SetActiveEx(false) + end + end + end + end +end + +function XUiSlotMachineRewardPanel:TakeReward(index) + XDataCenter.SlotMachineManager.GetSlotMachineReward(self.CurMachineEntity:GetId(), index) +end + +function XUiSlotMachineRewardPanel:GetReverseTable(arr) -- 翻转数组(只能是数组) + local tmp = {} + for i = #arr, 1, -1 do + tableInsert(tmp, arr[i]) + end + + return tmp +end + +return XUiSlotMachineRewardPanel \ No newline at end of file diff --git a/Resources/Scripts/XOverseas/XUi/XUiSlotMachine/XUiSlotMachineRules.lua b/Resources/Scripts/XOverseas/XUi/XUiSlotMachine/XUiSlotMachineRules.lua new file mode 100644 index 00000000..a89d20d2 --- /dev/null +++ b/Resources/Scripts/XOverseas/XUi/XUiSlotMachine/XUiSlotMachineRules.lua @@ -0,0 +1,50 @@ +local XUiSlotMachineRulesPanel = require("XOverseas/XUi/XUiSlotMachine/XUiSlotMachineRulesPanel") +local XUiSlotMachineRulesResearchPanel = require("XOverseas/XUi/XUiSlotMachine/XUiSlotMachineRulesResearchPanel") + +local XUiSlotMachineRules = XLuaUiManager.Register(XLuaUi, "UiSlotmachineRules") + +function XUiSlotMachineRules:OnAwake() + self.RulesPanel = XUiSlotMachineRulesPanel.New(self, self.PanelRules) + self.ResearchPanel = XUiSlotMachineRulesResearchPanel.New(self, self.PanelResearch) +end + +function XUiSlotMachineRules:OnStart(father) + self.Father = father + self:AutoAddListener() + self:InitTabGroup() +end + +function XUiSlotMachineRules:OnEnable() + self.CurMachineEntity = self.Father.CurMachineEntity + self:Refresh(self.CurMachineEntity:GetId()) +end + +function XUiSlotMachineRules:AutoAddListener() + self.BtnClose.CallBack = function() self:Close() end + self.BtnTanchuangClose.CallBack = function() self:Close() end +end + +function XUiSlotMachineRules:Refresh(machineId) + self.CurMachineEntity = XDataCenter.SlotMachineManager.GetSlotMachineDataEntityById(machineId) + self.TabGroup:SelectIndex(self.LastSelectIndex or 1) +end + +function XUiSlotMachineRules:InitTabGroup() + self.TabList = {} + table.insert(self.TabList, self.BtnTab1) + table.insert(self.TabList, self.BtnTab2) + self.TabGroup:Init(self.TabList, function(index) self:OnTaskPanelSelect(index) end) +end + +function XUiSlotMachineRules:OnTaskPanelSelect(index) + self.LastSelectIndex = index + if index == XSlotMachineConfigs.RulesPanelType.Rules then + self.PanelRules.gameObject:SetActiveEx(true) + self.PanelResearch.gameObject:SetActiveEx(false) + self.RulesPanel:Refresh(self.CurMachineEntity:GetId()) + elseif index == XSlotMachineConfigs.RulesPanelType.Research then + self.PanelRules.gameObject:SetActiveEx(false) + self.PanelResearch.gameObject:SetActiveEx(true) + self.ResearchPanel:Refresh(self.CurMachineEntity:GetId()) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XOverseas/XUi/XUiSlotMachine/XUiSlotMachineRulesItem.lua b/Resources/Scripts/XOverseas/XUi/XUiSlotMachine/XUiSlotMachineRulesItem.lua new file mode 100644 index 00000000..0a03dccf --- /dev/null +++ b/Resources/Scripts/XOverseas/XUi/XUiSlotMachine/XUiSlotMachineRulesItem.lua @@ -0,0 +1,20 @@ +local XUiSlotMachineRulesItem = XClass(nil, "XUiSlotMachineRulesItem") + +function XUiSlotMachineRulesItem:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RectTransform = ui + self.RootUi = rootUi + XTool.InitUiObject(self) +end + +function XUiSlotMachineRulesItem:OnCreate(data) + self.TxtRuleTittle.text = data.Title + self.TxtRule.text = string.gsub(data.Desc, "\\n", "\n") +end + +function XUiSlotMachineRulesItem:SetActiveEx(bool) + self.GameObject:SetActiveEx(bool) +end + +return XUiSlotMachineRulesItem \ No newline at end of file diff --git a/Resources/Scripts/XOverseas/XUi/XUiSlotMachine/XUiSlotMachineRulesPanel.lua b/Resources/Scripts/XOverseas/XUi/XUiSlotMachine/XUiSlotMachineRulesPanel.lua new file mode 100644 index 00000000..b0684273 --- /dev/null +++ b/Resources/Scripts/XOverseas/XUi/XUiSlotMachine/XUiSlotMachineRulesPanel.lua @@ -0,0 +1,42 @@ +local tableInsert = table.insert + +local XUiSlotMachineRulesItem = require("XOverseas/XUi/XUiSlotMachine/XUiSlotMachineRulesItem") + +local XUiSlotMachineRulesPanel = XClass(nil, "XUiSlotMachineRulesPanel") + +function XUiSlotMachineRulesPanel:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RectTransform = ui + self.RootUi = rootUi + XTool.InitUiObject(self) + + self:Init() +end + +function XUiSlotMachineRulesPanel:Init() + self.TextPanelPool = {} +end + +function XUiSlotMachineRulesPanel:Refresh(machineId) + self.CurMachineEntity = XDataCenter.SlotMachineManager.GetSlotMachineDataEntityById(machineId) + local rulesIds = self.CurMachineEntity:GetRulesIds() + local rulesDataList = {} + for _, rulesId in ipairs(rulesIds) do + local rulesData = XSlotMachineConfigs.GetSlotMachinesRulesTemplateById(rulesId) + local data = { + Title = rulesData.Title, + Desc = rulesData.Desc, + } + tableInsert(rulesDataList, data) + end + + local onCreateCb = function (item, data) + item:SetActiveEx(true) + item:OnCreate(data) + end + + XUiHelper.CreateTemplates(self.RootUi, self.TextPanelPool, rulesDataList, XUiSlotMachineRulesItem.New, self.PanelTxt, self.PanelContent, onCreateCb) +end + +return XUiSlotMachineRulesPanel \ No newline at end of file diff --git a/Resources/Scripts/XOverseas/XUi/XUiSlotMachine/XUiSlotMachineRulesResearchLogItem.lua b/Resources/Scripts/XOverseas/XUi/XUiSlotMachine/XUiSlotMachineRulesResearchLogItem.lua new file mode 100644 index 00000000..74d503c7 --- /dev/null +++ b/Resources/Scripts/XOverseas/XUi/XUiSlotMachine/XUiSlotMachineRulesResearchLogItem.lua @@ -0,0 +1,40 @@ +local CSXTextManagerGetText = CS.XTextManager.GetText +local CSFormatTime = function(timestamp) + return CS.XDateUtil.GetLocalDateTime(timestamp):ToString("yyyy-MM-dd HH:mm:ss") +end + +local XUiSlotMachineRulesResearchLogItem = XClass(nil, "XUiSlotMachineRulesResearchLogItem") + +function XUiSlotMachineRulesResearchLogItem:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RectTransform = ui + self.RootUi = rootUi + XTool.InitUiObject(self) +end + +function XUiSlotMachineRulesResearchLogItem:OnCreate(data) + if data then + local iconList = data.IconList + local isPrix = XDataCenter.SlotMachineManager.CheckIconListIsPrix(iconList) + if isPrix then + self.GridLogHigh.gameObject:SetActiveEx(true) + self.GridLogLow.gameObject:SetActiveEx(false) + self.TxtNameHigh.text = CSXTextManagerGetText("SlotMachineLogNameText", XSlotMachineConfigs.GetIconNameById(iconList[1]), XSlotMachineConfigs.GetIconNameById(iconList[2]), XSlotMachineConfigs.GetIconNameById(iconList[3])) + self.TxtScoreHigh.text = CSXTextManagerGetText("SlotMachineLogScoreText", data.Score) + self.TxtTimeHigh.text = CSFormatTime(data.Timestamp) + else + self.GridLogHigh.gameObject:SetActiveEx(false) + self.GridLogLow.gameObject:SetActiveEx(true) + self.TxtNameLow.text = CSXTextManagerGetText("SlotMachineLogNameText", XSlotMachineConfigs.GetIconNameById(iconList[1]), XSlotMachineConfigs.GetIconNameById(iconList[2]), XSlotMachineConfigs.GetIconNameById(iconList[3])) + self.TxtScoreLow.text = CSXTextManagerGetText("SlotMachineLogScoreText", data.Score) + self.TxtTimeLow.text = CSFormatTime(data.Timestamp) + end + end +end + +function XUiSlotMachineRulesResearchLogItem:SetActiveEx(bool) + self.GameObject:SetActiveEx(bool) +end + +return XUiSlotMachineRulesResearchLogItem \ No newline at end of file diff --git a/Resources/Scripts/XOverseas/XUi/XUiSlotMachine/XUiSlotMachineRulesResearchPanel.lua b/Resources/Scripts/XOverseas/XUi/XUiSlotMachine/XUiSlotMachineRulesResearchPanel.lua new file mode 100644 index 00000000..e4951dbd --- /dev/null +++ b/Resources/Scripts/XOverseas/XUi/XUiSlotMachine/XUiSlotMachineRulesResearchPanel.lua @@ -0,0 +1,48 @@ +local tableInsert = table.insert + +local XUiSlotMachineRulesResearchLogItem = require("XOverseas/XUi/XUiSlotMachine/XUiSlotMachineRulesResearchLogItem") + +local XUiSlotMachineRulesResearchPanel = XClass(nil, "XUiSlotMachineRulesResearchPanel") + +function XUiSlotMachineRulesResearchPanel:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RectTransform = ui + self.RootUi = rootUi + XTool.InitUiObject(self) + + self:Init() +end + +function XUiSlotMachineRulesResearchPanel:Init() + self.LogGridPool = {} +end + +function XUiSlotMachineRulesResearchPanel:Refresh(machineId) + self.CurMachineEntity = XDataCenter.SlotMachineManager.GetSlotMachineDataEntityById(machineId) + self:RefreshLogPanel() +end + +function XUiSlotMachineRulesResearchPanel:RefreshLogPanel() + if self.CurMachineEntity then + local researchLogs = self.CurMachineEntity:GetSlotMachineRecords() + local logDataList = {} + for _, logData in ipairs(researchLogs) do + local data = { + IconList = logData.IconList, + Timestamp = logData.Timestamp, + Score = logData.Score, + } + tableInsert(logDataList, data) + end + + local onCreateCb = function (item, data) + item:SetActiveEx(true) + item:OnCreate(data) + end + + XUiHelper.CreateTemplates(self.RootUi, self.LogGridPool, logDataList, XUiSlotMachineRulesResearchLogItem.New, self.GridLog, self.PanelContent, onCreateCb) + end +end + +return XUiSlotMachineRulesResearchPanel \ No newline at end of file diff --git a/Resources/Scripts/XOverseas/XUi/XUiSlotMachine/XUiSlotMachineTask.lua b/Resources/Scripts/XOverseas/XUi/XUiSlotMachine/XUiSlotMachineTask.lua new file mode 100644 index 00000000..6dffa32d --- /dev/null +++ b/Resources/Scripts/XOverseas/XUi/XUiSlotMachine/XUiSlotMachineTask.lua @@ -0,0 +1,72 @@ +local XUiSlotMachineTaskContentPanel = require("XOverseas/XUi/XUiSlotMachine/XUiSlotMachineTaskContentPanel") + +local XUiSlotMachineTask = XLuaUiManager.Register(XLuaUi, "UiSlotmachineTask") + +function XUiSlotMachineTask:OnAwake() + self.TaskContentPanel = XUiSlotMachineTaskContentPanel.New(self, self.PanelTaskContent) +end + +function XUiSlotMachineTask:OnStart(father) + self.Father = father + self:AutoAddListener() + self:InitTabGroup() +end + +function XUiSlotMachineTask:OnEnable() + self.CurMachineEntity = self.Father.CurMachineEntity + self:Refresh(self.CurMachineEntity:GetId()) +end + +function XUiSlotMachineTask:AutoAddListener() + self.BtnBack.CallBack = function() self:Close() end + self.BtnMainUi.CallBack = function() XLuaUiManager.RunMain() end +end + +function XUiSlotMachineTask:OnGetEvents() + return { + XEventId.EVENT_SLOT_MACHINE_FINISH_TASK, + } +end + +function XUiSlotMachineTask:OnNotify(evt, ...) + if evt == XEventId.EVENT_SLOT_MACHINE_FINISH_TASK then + self:Refresh(self.CurMachineEntity:GetId()) + end +end + +function XUiSlotMachineTask:Refresh(machineId) + self.CurMachineEntity = XDataCenter.SlotMachineManager.GetSlotMachineDataEntityById(machineId) + self:RefreshAssetPanel() + self.TogDaily:ShowReddot(XDataCenter.SlotMachineManager.CheckCanFinishTaskByType(machineId, XSlotMachineConfigs.TaskType.Daily)) + self.TogCumulative:ShowReddot(XDataCenter.SlotMachineManager.CheckCanFinishTaskByType(machineId, XSlotMachineConfigs.TaskType.Cumulative)) + self.TabPanelGroup:SelectIndex(self.LastSelectIndex or 1) +end + +function XUiSlotMachineTask:InitTabGroup() + self.TabList = {} + table.insert(self.TabList, self.TogDaily) + table.insert(self.TabList, self.TogCumulative) + self.TabPanelGroup:Init(self.TabList, function(index) self:OnTaskPanelSelect(index) end) +end + +function XUiSlotMachineTask:OnTaskPanelSelect(index) + self.LastSelectIndex = index + if index == XSlotMachineConfigs.TaskType.Daily then + local dailyTaskLimitId = self.CurMachineEntity:GetTaskDailyLimitId() + self.TaskContentPanel:Refresh(dailyTaskLimitId, index) + elseif index == XSlotMachineConfigs.TaskType.Cumulative then + local cumulativeTaskLimitId = self.CurMachineEntity:GetTaskCumulativeLimitId() + self.TaskContentPanel:Refresh(cumulativeTaskLimitId, index) + end +end + +function XUiSlotMachineTask:RefreshAssetPanel() + if self.CurMachineEntity then + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, self.CurMachineEntity:GetConsumeItemId()) + if XDataCenter.SlotMachineManager.GetSlotMachineActExchangeType() == XSlotMachineConfigs.ExchangeType.OnlyTask then + if self.AssetPanel.BtnBuyJump1 then self.AssetPanel.BtnBuyJump1.gameObject:SetActiveEx(false) end + if self.AssetPanel.BtnBuyJump2 then self.AssetPanel.BtnBuyJump2.gameObject:SetActiveEx(false) end + if self.AssetPanel.BtnBuyJump3 then self.AssetPanel.BtnBuyJump3.gameObject:SetActiveEx(false) end + end + end +end \ No newline at end of file diff --git a/Resources/Scripts/XOverseas/XUi/XUiSlotMachine/XUiSlotMachineTaskContentPanel.lua b/Resources/Scripts/XOverseas/XUi/XUiSlotMachine/XUiSlotMachineTaskContentPanel.lua new file mode 100644 index 00000000..432e9908 --- /dev/null +++ b/Resources/Scripts/XOverseas/XUi/XUiSlotMachine/XUiSlotMachineTaskContentPanel.lua @@ -0,0 +1,77 @@ +local tableSort = table.sort +local tableInsert = table.insert + +local XSlotMachineTaskGrid = require("XOverseas/XUi/XUiSlotMachine/XUiSlotMachineTaskGrid") + +local XUiSlotMachineTaskContentPanel = XClass(nil, "XUiSlotMachineTaskContentPanel") + +function XUiSlotMachineTaskContentPanel:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RectTransform = ui + self.RootUi = rootUi + XTool.InitUiObject(self) + + self:Init() +end + +function XUiSlotMachineTaskContentPanel:Init() + self.DynamicTable = XDynamicTableNormal.New(self.PanelTaskList.gameObject) + self.DynamicTable:SetProxy(XSlotMachineTaskGrid) + self.DynamicTable:SetDelegate(self) +end + +function XUiSlotMachineTaskContentPanel:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local taskId = self.TaskIds[index] + if taskId == nil then return end + grid:Init(self.RootUi) + grid:UpdateGrid(XDataCenter.TaskManager.GetTaskDataById(taskId)) + end +end + +function XUiSlotMachineTaskContentPanel:Refresh(taskTimeLimitId, taskType) + self.TaskTimeLimitId = taskTimeLimitId + if self.TaskTimeLimitId then + local taskCfg = XTaskConfig.GetTimeLimitTaskCfg(self.TaskTimeLimitId) + self.TaskIds = {} + local readOnlyTaskIds = {} + if taskType == XSlotMachineConfigs.TaskType.Daily then + readOnlyTaskIds = taskCfg.DayTaskId + elseif taskType == XSlotMachineConfigs.TaskType.Cumulative then + readOnlyTaskIds = taskCfg.TaskId + end + for _, taskId in ipairs(readOnlyTaskIds) do + tableInsert(self.TaskIds, taskId) + end + self:SortTaskIds(self.TaskIds) + self.DynamicTable:SetDataSource(self.TaskIds) + self.DynamicTable:ReloadDataASync() + end +end + +function XUiSlotMachineTaskContentPanel:SortTaskIds(taskIds) + tableSort(taskIds, function(taskId1, taskId2) + local taskData1 = XDataCenter.TaskManager.GetTaskDataById(taskId1) + local taskData2 = XDataCenter.TaskManager.GetTaskDataById(taskId2) + if taskData1.State ~= taskData2.State then + if taskData1.State == XDataCenter.TaskManager.TaskState.Achieved then + return true + else + if taskData1.State == XDataCenter.TaskManager.TaskState.Active and taskData2.State == XDataCenter.TaskManager.TaskState.Finish then + return true + else + return false + end + end + else + if taskId1 < taskId2 then + return true + else + return false + end + end + end) +end + +return XUiSlotMachineTaskContentPanel \ No newline at end of file diff --git a/Resources/Scripts/XOverseas/XUi/XUiSlotMachine/XUiSlotMachineTaskGrid.lua b/Resources/Scripts/XOverseas/XUi/XUiSlotMachine/XUiSlotMachineTaskGrid.lua new file mode 100644 index 00000000..fff569b3 --- /dev/null +++ b/Resources/Scripts/XOverseas/XUi/XUiSlotMachine/XUiSlotMachineTaskGrid.lua @@ -0,0 +1,89 @@ +local tableInsert = table.insert +local CSXTextManagerGetText = CS.XTextManager.GetText + +local XSlotMachineTaskGrid = XClass(nil, "XSlotMachineTaskGrid") + +function XSlotMachineTaskGrid:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RectTransform = ui + XTool.InitUiObject(self) +end + +function XSlotMachineTaskGrid:Init(rootUi) + self.RootUi = rootUi + self:AutoRegisterBtn() +end + +function XSlotMachineTaskGrid:UpdateGrid(data) + self.Data = data + self.TaskConfig = XTaskConfig.GetTaskConfigById(data.Id) + self.TxtTaskName.text = self.TaskConfig.Title + self.TxtTaskDescribe.text = self.TaskConfig.Desc + local scheduleValue = data.Schedule[1] and data.Schedule[1].Value or 0 + self.TxtTaskNumQian.text = CSXTextManagerGetText("SlotMachineTaskNumProcess", scheduleValue, self.TaskConfig.Result) + self.ImgProgress.fillAmount = scheduleValue / self.TaskConfig.Result + local rewards = XRewardManager.GetRewardList(self.TaskConfig.RewardId) + local rewardCount = #rewards + local GridCommonUiList = {} + for i = 0, self.GridCommon.parent.childCount-1 do + if i > rewardCount-1 then + self.GridCommon.parent:GetChild(i).gameObject:SetActiveEx(false) + else + tableInsert(GridCommonUiList, self.GridCommon.parent:GetChild(i)) + end + end + for i = 1, #rewards do + local gridCommonUi = GridCommonUiList[i] + local gridCommon = nil + if not gridCommonUi then + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommon) + ui.transform:SetParent(self.GridCommon.parent, false) + gridCommon = XUiGridCommon.New(self.RootUi, ui) + else + gridCommon = XUiGridCommon.New(self.RootUi, gridCommonUi) + end + gridCommon:Refresh(rewards[i]) + end + + self:SetState(data.State) +end + +function XSlotMachineTaskGrid:SetState(state) + if state == XDataCenter.TaskManager.TaskState.Active then + self.BtnSkip.gameObject:SetActiveEx(true) + self.ImgComplete.gameObject:SetActiveEx(false) + self.BtnFinish.gameObject:SetActiveEx(false) + elseif state == XDataCenter.TaskManager.TaskState.Achieved then + self.BtnSkip.gameObject:SetActiveEx(false) + self.ImgComplete.gameObject:SetActiveEx(false) + self.BtnFinish.gameObject:SetActiveEx(true) + elseif state == XDataCenter.TaskManager.TaskState.Finish then + self.BtnSkip.gameObject:SetActiveEx(false) + self.ImgComplete.gameObject:SetActiveEx(true) + self.BtnFinish.gameObject:SetActiveEx(false) + end +end + +function XSlotMachineTaskGrid:AutoRegisterBtn() + self.BtnFinish.CallBack = function () self:OnClickBtnReceive() end + self.BtnSkip.CallBack = function () self:OnClickBtnSkip() end +end + +function XSlotMachineTaskGrid:OnClickBtnReceive() + if not self.Data then + return + end + + XDataCenter.SlotMachineManager.FinishTask(self.Data.Id) +end + +function XSlotMachineTaskGrid:OnClickBtnSkip() + if not self.TaskConfig then + return + end + + XFunctionManager.SkipInterface(self.TaskConfig.SkipId) +end + +return XSlotMachineTaskGrid \ No newline at end of file diff --git a/Resources/Scripts/XOverseas/XUi/XUiSlotMachine/XUiSlotMachineTipsPanel.lua b/Resources/Scripts/XOverseas/XUi/XUiSlotMachine/XUiSlotMachineTipsPanel.lua new file mode 100644 index 00000000..ad6479d0 --- /dev/null +++ b/Resources/Scripts/XOverseas/XUi/XUiSlotMachine/XUiSlotMachineTipsPanel.lua @@ -0,0 +1,38 @@ +local CSXTextManagerGetText = CS.XTextManager.GetText + +local XUiSlotMachineTipsPanel = XClass(nil, "XUiSlotMachineTipsPanel") + +function XUiSlotMachineTipsPanel:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RectTransform = ui + self.RootUi = rootUi + XTool.InitUiObject(self) + + self:Init() +end + +function XUiSlotMachineTipsPanel:Init() + +end + +function XUiSlotMachineTipsPanel:Refresh(machineId) + self.CurMachineEntity = XDataCenter.SlotMachineManager.GetSlotMachineDataEntityById(machineId) + local machineState = XDataCenter.SlotMachineManager.CheckSlotMachineState(machineId) + if machineState == XSlotMachineConfigs.SlotMachineState.Finish then + self.GameObject:SetActiveEx(false) + elseif machineState == XSlotMachineConfigs.SlotMachineState.Locked then + self.GameObject:SetActiveEx(true) + self.LockTips.gameObject:SetActiveEx(true) + self.UnLockTips.gameObject:SetActiveEx(false) + self.TxtLock.text = CSXTextManagerGetText("SlotMachineTipsLock") + elseif machineState == XSlotMachineConfigs.SlotMachineState.Running then + self.GameObject:SetActiveEx(true) + self.LockTips.gameObject:SetActiveEx(false) + self.UnLockTips.gameObject:SetActiveEx(true) + self.TxtDesc.text = CSXTextManagerGetText("SlotMachineTipsUnLockDesc") + self.TxtGuaranteed.text = CSXTextManagerGetText("SlotMachineTipsUnLock", self.CurMachineEntity:GetRockTimes(), self.CurMachineEntity:GetPrixBottomTimes()+1) + end +end + +return XUiSlotMachineTipsPanel \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditionGroup.lua b/Resources/Scripts/XRedPoint/XRedPointConditionGroup.lua new file mode 100644 index 00000000..6fa72cf3 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditionGroup.lua @@ -0,0 +1,88 @@ +--XRedPointConditionGroup 條件組 +--XRedPointConditionGroup.Conditions 存的是KEY[k1,k2......] 只要有一个条件满足就有红点 +--XRedPointConditionGroup.Events 需要监听的事件[.....] +local XRedPointConditionGroup = XClass(nil, "XRedPointConditionGroup") + +--构成 +function XRedPointConditionGroup:Ctor(conditions) + self.Conditions = conditions + self.Events = {} + if conditions and #conditions > 0 then + for _, var in ipairs(conditions) do + self:GetSubConditions(var) + end + end +end + +--递归获取需要监听的事件 +function XRedPointConditionGroup:GetSubConditions(conditionId) + local condition = XRedPointConditions[conditionId] + if condition then + --收集子事件 + if condition.GetSubEvents then + local events = condition.GetSubEvents() + if events then + for _, var in ipairs(events) do + self:AddConditions(var) + end + end + end + + --收集子条件 + if condition.GetSubConditions then + local subConditions = condition.GetSubConditions() + if subConditions then + for _, var in ipairs(subConditions) do + self:GetSubConditions(var) + end + end + end + + end +end + +--添加一个子事件 +function XRedPointConditionGroup:AddConditions(element) + if not element then + return + end + + if self.Events[element.EventId] then + -- XLog:Warning("RedPoint Condition Events Repeated!!!"..element.EventId) + return + end + + self.Events[element.EventId] = element +end + +--条件组检测 返回 0 代表true ,大于0 代表有数量 ,-1就是条件不满足 +function XRedPointConditionGroup:Check(args) + if not self.Conditions or #self.Conditions <= 0 then + return -1 + end + + local result = -1 + + for _, v in ipairs(self.Conditions) do + if XRedPointConditions[v] ~= nil then + if not XRedPointManager.CheckIsFitter(v) then --检测需要过滤的红点事件 + local r = XRedPointConditions[v].Check(args) + -- 0 代表true ,大于0 代表有数量 ,-1就是条件不满足 + if type(r) == "number" then + if result >= 0 or r <= 0 then + result = result + r + else + result = r + end + elseif r == true and result == -1 then + result = 0 + end + + end + end + end + + return result +end + +return XRedPointConditionGroup \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions.lua b/Resources/Scripts/XRedPoint/XRedPointConditions.lua new file mode 100644 index 00000000..73f30131 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions.lua @@ -0,0 +1,387 @@ +XRedPointConditionGroup = require("XRedPoint/XRedPointConditionGroup") +XRedPointEvent = require("XRedPoint/XRedPointEvent") +XRedPointListener = require("XRedPoint/XRedPointListener") +XRedPointEventElement = require("XRedPoint/XRedPointEventElement") + +XRedPointConditions = XRedPointConditions or {} +XRedPointConditions.Conditions = { + --角色界面红点相关UiCharacter----------------------------------------------- + CONDITION_CHARACTER = "XRedPointConditionCharacter", --角色列表红点,培养 + CONDITION_CHARACTER_GRADE = "XRedPointConditionCharacterGrade", --晋升标签 + CONDITION_CHARACTER_QUALITY = "XRedPointConditionCharacterQuality", --升品标签 + CONDITION_CHARACTER_SKILL = "XRedPointConditionCharacterSkill", --技能标签 + CONDITION_CHARACTER_LEVEL = "XRedPointConditionCharacterLevel", --升级标签 + CONDITION_CHARACTER_UNLOCK = "XRedPointConditionCharacterUnlock", --解锁 + + --好友红点相关 UiSocial----------------------------------------------- + CONDITION_FRIEND_WAITPASS = "XRedPointConditionFriendWaitPass", --等待通过 + CONDITION_FRIEND_CONTACT = "XRedPointConditionFriendContact", --私聊信息标签 + CONDITION_FRIEND_CHAT_PRIVATE = "XRedPointConditionFriendChatPrivate", --个人私聊信息 + + --邮件红点相关 UiMail----------------------------------------------- + CONDITION_MAIL_PERSONAL = "XRedPointConditionMailPersonal", --邮件 + + --主界面红点相关 UiMain----------------------------------------------- + CONDITION_MAIN_MEMBER = "XRedPointConditionMainMember", --成员 + CONDITION_MAIN_FRIEND = "XRedPointConditionMainFriend", --好友 + CONDITION_MAIN_NOTICE = "XRedPointConditionMainNotice", --活动系统 + CONDITION_MAIN_MAIL = "XRedPointConditionMainMail", --邮件 + CONDITION_MAIN_SET = "XRedPointConditionMainSet", --设置 + CONDITION_MAIN_NEWPLAYER_TASK = "XRedPointConditionMainNewPlayerTask", --新手任务 + CONDITION_MAIN_TASK = "XRedPointConditionMainTask", --任务 + CONDITION_MAIN_CHAPTER = "XRedPointConditionMainChapter", --主线副本 + CONDITION_BASEEQUIP = "XRedPointConditionBaseEquip", --基地装备 + CONDITION_MAIN_DISPATCH = "XRedPointConditionMainDispatch", --派遣 + CONDITION_MAIN_SPECIAL_SHOP = "XRedPointConditionMainSpecialShop", -- 特殊商店 + + --玩家红点相关 UiPlayer----------------------------------------------- + CONDITION_PLAYER_SETNAME = "XRedPointConditionPlayerSetName", + CONDITION_PLAYER_ACHIEVE = "XRedPointConditionPlayerAchieve", --成就标签 + CONDITION_PLAYER_ACHIEVE_TYPE = "XRedPointConditionPlayerAchieveType", --各类型成就标签 + + -- 聊天红点相关 UiChatServeMain---------------------------------------- + CONDITION_RECEIVE_CHAT = "XRedPointConditionReceiveChat", -- 接收到消息 + + --玩家任务红点相关 UiTask----------------------------------------------- + CONDITION_TASK_TYPE = "XRedPointConditionTaskType", --是否有对应类型的任务奖励 + CONDITION_TASK_COURSE = "XRedPointConditionTaskCourse", --是否有历程任务奖励 + CONDITION_TASK_WEEK_ACTIVE = "XRedPointConditionTaskWeekActive", --是否有周活跃任务奖励 + CONDITION_TASK_LIMIT_TYPE = "XRedPointConditionTaskLimited", + --赏金任务 + CONDITION_BOUNTYTASK = "XRedPointConditionBountyTask", --是否有赏金任务奖励 + --竞技 + CONDITION_ARENA_APPLY = "XRedPointConditionArenaApply", --是否有申请数据 + + --玩家章节红点相关 UiFuBen----------------------------------------------- + CONDITION_MAINLINE_CHAPTER_REWARD = "XRedPointConditionChapterReward", --是否有主线章节进度奖励(包括收集进度与周目挑战任务) + CONDITION_BFRT_CHAPTER_REWARD = "XRedPointConditionBfrtChapterReward", --是否有据点战章节进度奖励 + CONDITION_CHALLEGE_NEW = "XRedPointConditionNewChallenge", --是否有在版本新玩法出现后点击过挑战页签 + CONDITION_EXTRA_CHAPTER_REWARD = "XRedPointConditionExtraChapterReward", --是否有番外章节进度奖励(包括收集进度与周目挑战任务) + + CONDITION_ZHOUMU_TASK = "XRedPointConditionZhouMuTask", -- 是否有周目任务奖励 + CONDITION_MAINLINE_TREASURE = "XRedPointConditionMainLineTreasure", -- 是否有主线收集进度 + CONDITION_EXTRA_TREASURE = "XRedPointConditionExtraTreasure", -- 是否有外篇收集进度 + CONDITION_NEWCHARACT_TREASURE = "XRedPointConditionNewCharActTreasure", -- 是否有新角色教学关卡收集进度 + + CONDITION_EXPERIMENT_CHAPTER_REWARD = "XRedPointConditionExperimentChapterReward", -- 试玩关章节是否有未领取奖励 + CONDITION_EXPERIMENT_RED = "XRedPointConditionExperimentRed", -- 副本界面试玩关红点条件 + + -- 好感度 + CONDITION_FAVORABILITY_RED = "XRedPointConditionFavorability", --好感度红点 + CONDITION_FAVORABILITY_DOCUMENT = "XRedPointConditionFavorabilityDocument", --好感度-档案 + CONDITION_FAVORABILITY_DOCUMENT_INFO = "XRedPointConditionFavorabilityInfo", --好感度-档案-资料 + CONDITION_FAVORABILITY_DOCUMENT_RUMOR = "XRedPointConditionFavorabilityRumor", --好感度-档案-异闻 + CONDITION_FAVORABILITY_DOCUMENT_AUDIO = "XRedPointConditionFavorabilityAudio", --好感度-档案-语音 + CONDITION_FAVORABILITY_DOCUMENT_ACTION = "XRedPointConditionFavorabilityAction", --好感度-档案-动作 + CONDITION_FAVORABILITY_PLOT = "XRedPointConditionFavorabilityPlot", --好感度-剧情 + CONDITION_FAVORABILITY_GIFT = "XRedPointConditionFavorabilityGift", --好感度-礼物 + -- 试炼 + CONDITION_TRIAL_RED = "XRedPointConditionTrial", --试炼关卡奖励 + CONDITION_TRIAL_REWARD_RED = "XRedPointConditionTrialReward", --试炼关卡奖励 + CONDITION_TRIAL_UNLOCK_RED = "XRedPointConditionTrialUnlock", --试炼关卡解锁 + + -- 探索 + CONDITION_EXPLORE_REWARD = "XRedPointConditionExplore", --是否有探索奖励可领取 + + -- 驻守玩法 + CONDITION_ASSIGN_REWARD = "XRedPointConditionAssign", --是否有驻守副本奖励可领取 + + --竞技 + CONDITION_ARENA_MAIN_TASK = "XRedPointConditionArenaTask", --竞技战区任务 + + --展示厅 + CONDITION_EXHIBITION_NEW = "XRedPointConditionExhibitionNew", --构造展示厅奖励可领取 + + --活动系统 + CONDITION_ACTIVITY_NEW_ACTIVITIES = "XRedPointConditionActivityNewAcitivies", --活动系统-新活动 + CONDITION_ACTIVITY_NEW_NOTICES = "XRedPointConditionActivityNewNotices", --活动系统-新公告 + CONDITION_ACTIVITY_NEW_ACTIVITY_NOTICES = "XRedPointConditionActivityNewActivityNotices", --活动系统-新活动公告 + CONDITION_ACTIVITY_NEW_ACTIVITIES_TOGS = "XRedPointConditionActivityNewAcitiviesTogs", --活动系统-新活动的标签按钮红点 + -- 运营相关 + CONDITION_SUBMENU_NEW_NOTICES = "XRedPointConditionSubMenuNewNotices", -- 主界面二级菜单-新按钮 + + --单机Boss奖励 + CONDITION_BOSS_SINGLE_REWARD = "XRedPointConditionBossSingleReward", --单机Boss奖励领取 + + --充值 + CONDITION_PURCHASE_RED = "XRedPointConditionPurchase", + CONDITION_PURCHASE_LB_RED = "XRedPointConditionPurchaseLB", + CONDITION_PURCHASE_GET_RERARGE = "XRedPointConditionGetFirstRecharge", -- 是否有首充奖励领取 + CONDITION_PURCHASE_GET_CARD = "XRedPointConditionGetCard", -- 是否有月卡奖励领取 + CONDITION_NEWYEARDIVINING_NOTGET = "XRedPointConditionNewYearDiviningNotGet", + CONDITION_ACCUMULATE_PAY_RED = "XRedPointConditionPurchaseAccumulate", -- 是否有累计奖励领取 + --宿舍红点 + CONDITION_DORM_RED = "XRedPointConditionDormRed", -- 宿舍红点 + CONDITION_DORM_TASK = "XRedPointConditionDormTaskType", -- 是否有奖励领取 + CONDITION_FURNITURE_CREATE = "XRedPointConditionFurnitureCreate", --是否有家具可以领取 + CONDITION_DORM_WORK_RED = "XRedPointConditionDormWork", -- 宿舍打工 + CONDITION_DORM_MAIN_TASK_RED = "XRedPointConditionDormMainTaskRed", -- 是否有奖励领取(宿舍主界面) + + --研究红点 + CONDITION_ACTIVITYDRAW_RED = "XRedPointConditionActivityDrawNew", -- 研究活动卡池红点 + + --头像红点 + CONDITION_HEADPORTRAIT_RED = "XRedPointConditionHeadPortraitNew", + --勋章红点 + CONDITION_MEDAL_RED = "XRedPointConditionMedalNew", + + --活动简介红点 + CONDITION_ACTIVITY_BRIRF_TASK_FINISHED = "XRedPointConditionActivityBriefTaskFinished", --活动简介任务完成 + + --复刷关奖励红点 + CONDITION_REPEAT_CHALLENGE_REWARD = "XRedPointConditionRepeatChallengeReward", --是否有复刷关奖励 + CONDITION_REPEAT_CHALLENGE_CHAPTER_REWARD = "XRedPointConditionRepeatChallengeChapterReward", --是否有复刷关章节进度奖励 + + --图鉴红点相关 + CONDITION_ARCHIVE_WEAPON = "XRedPointConditionArchiveWeapon", + CONDITION_ARCHIVE_AWARENESS = "XRedPointConditionArchiveAwareness", + + CONDITION_ARCHIVE_WEAPON_NEW_TAG = "XRedPointConditionArchiveWeaponNewTag", --一级界面是否解锁了新武器 + CONDITION_ARCHIVE_WEAPON_GRID_NEW_TAG = "XRedPointConditionArchiveWeaponGridNewTag", --一级界面格子中是否解锁了新武器 + CONDITION_ARCHIVE_WEAPON_SETTING_RED = "XRedPointConditionArchiveWeaponSettingUnlock", --是否解锁了新武器设定 + + CONDITION_ARCHIVE_AWARENESS_NEW_TAG = "XRedPointConditionArchiveAwarenessNewTag", --一级界面是否解锁了新意识 + CONDITION_ARCHIVE_AWARENESS_GRID_NEW_TAG = "XRedPointConditionArchiveAwarenessGridNewTag", --一级界面格子中是否解锁了新意识 + CONDITION_ARCHIVE_AWARENESS_SETTING_RED = "XRedPointConditionArchiveAwarenessSettingUnlock", --是否解锁了新意识设定 + + CONDITION_ARCHIVE_MONSTER_ALL = "XRedPointConditionArchiveMonsterAll", --全部类型中是否有新怪或怪的新属性 + CONDITION_ARCHIVE_MONSTER_TYPE_RED = "XRedPointConditionArchiveMonsterTypeRed", --某种类型中是否有新怪或怪的新属性 + CONDITION_ARCHIVE_MONSTER_TYPE_TAG = "XRedPointConditionArchiveMonsterTypeTag", --某种类型中是否有新怪或怪的新属性 + CONDITION_ARCHIVE_MONSTER_RED = "XRedPointConditionArchiveMonsterRed", --是否有具体新怪 + CONDITION_ARCHIVE_MONSTER_TAG = "XRedPointConditionArchiveMonsterTag", --是否有具体新怪 + CONDITION_ARCHIVE_MONSTER_INFO = "XRedPointConditionArchiveMonsterInfo", --是否有新怪信息 + CONDITION_ARCHIVE_MONSTER_SKILL = "XRedPointConditionArchiveMonsterSkill", --是否有新怪技能 + CONDITION_ARCHIVE_MONSTER_SETTING = "XRedPointConditionArchiveMonsterSetting", --是否有新怪设定 + + CONDITION_ARCHIVE_CG_ALL = "XRedPointConditionArchiveCGAll", --全部类型中是否有新CG + CONDITION_ARCHIVE_CG_TYPE_RED = "XRedPointConditionArchiveCGTypeRed", --某种类型中是否有新CG + CONDITION_ARCHIVE_CG_RED = "XRedPointConditionArchiveCGRed", --是否有具体新CG + + --活动简介红点 + CONDITION_PIC_COMPOSITION_TASK_FINISHED = "XRedPointConditionPicCompositionTaskFinished", --看图作文任务完成 + CONDITION_WINDOWS_COMPOSITION_DAILY = "XRedPointConditionWindowsInlay", --内嵌浏览器每日红点 + --回归活动红点相关 + CONDITION_REGRESSION = "XRedPointConditionRegression", --回归活动(回归任务等后续任务) + CONDITION_REGRESSION_TASK_TYPE = "XRedPointConditionRegressionTaskType", --回归活动子类型任务(历程、每日、每天) + CONDITION_REGRESSION_TASK = "XRedPointConditionRegressionTask", --回归活动任务(历程、每日、每天、进度奖励) + + -- 公会相关红点 + CONDITION_GUILD_MEMBER = "XRedPointConditionGuildMember", --公会成员相关红点 + CONDITION_GUILD_INFO = "XRedPointConditionGuildInformation", --公会主界面信息红点 + CONDITION_GUILD_APPLYLIST = "XRedPointConditionGuildApplyList", --公会招募红点 + CONDITION_GUILD_ACTIVEGIFT = "XRedPointConditionGuildActiveGift", --公会活跃度礼包红点 + CONDITION_GUILD_CHALLENGE = "XRedPointConditionGuildChallenge", --公会挑战红点 + CONDITION_GUILD_NEWS = "XRedPointConditionUnGuildNews", --未加入公会收到消息红点 + + -- 工会boss相关红点 + CONDITION_GUILDBOSS_BOSSHP = "XRedPointConditionGuildBossHp", --有工会bosshp宝箱可以领取 + CONDITION_GUILDBOSS_SCORE = "XRedPointConditionGuildBossScore", --有工会boss积分宝箱可以领取 + + -- 主干探索玩法相关红点 + CONDITION_EXPLORE_ITEM_GET = "XRedPointConditionMainLineExploreItem", --获取新探索道具 + CONDITION_EXTRA_EXPLORE_ITEM_GET = "XRedPointConditionExtraChapterExploreItem", --番外获取新探索道具 + + -- 副本补给商店相关红点 + CONDITION_FUBEN_DAILY_SHOP = "XRedPointConditionFubenDailyShop", --副本补给商店新套装红点 + + --水上乐园相关红点 + CONDITION_ACTIVITY_NEW_MAINENTRY = "XRedPointConditionBriefEntry", --Brief活动入口处红点 + CONDITION_ACTIVITY_NEW_ILLUSTRATEDHANDBOOK = "XRedPointConditionShortStory", --短篇故事新开启 + + --虚像地平线相关红点 + CONDITION_EXPEDITION_CAN_RECRUIT = "XRedPointConditionExpeditionRecruit", --活动入口处红点 + --世界boss相关红点 + CONDITION_WORLDBOSS_RED = "XRedPointConditionWorldBossRed", --活动入口处红点 + + -- 点消小游戏红点 + CONDITION_FUBEN_CLICKCLEARGAME_RED = "XRedPointConditionFuBenClickClearGameRed", --中元节点消小游戏副本入口红点 + CONDITION_CLICKCLEARGAME_DIFFICULT_UNLOCK = "XRedPointConditionClickClearDifficultUnlock", -- 点消小游戏难度红点 + CONDITION_CLICKCLEARGAME_REWARD = "XRedPointConditionClickClearReward", -- 点消小游戏奖励红点 + + -- 预热关拼图游戏红点 + CONDITION_FUBEN_DRAGPUZZLEGAME_RED = "XRedPointConditionFuBenDragPuzzleGameRed", --预热关拼图小游戏副本入口红点 + CONDITION_DRAG_PUZZLE_GAME_SWITCH = "XRedPointConditionDragPuzzleSwitch", -- 转换碎片按钮红点 + CONDITION_DRAG_PUZZLE_GAME_AWARD = "XRedPointConditionDragPuzzleAward", -- 奖励红点 + CONDITION_DRAG_PUZZLE_GAME_VIDEO = "XRedPointConditionDragPuzzleVideo", -- 播放剧情红点 + CONDITION_DRAG_PUZZLE_GAME_TAB = "XRedPointConditionDragPuzzleTab", -- 关卡标题红点 + CONDITION_DRAG_PUZZLE_GAME_DECRYPTION = "XRedPointConditionDragPuzzleDecryption", -- 解密红点(特效) + + -- 圣诞树装饰小游戏红点 + CONDITION_CHRISTMAS_TREE = "XRedPointConditionChristmasTree", -- 小游戏红点 + CONDITION_CHRISTMAS_TREE_ORNAMENT_READ = "XRedPointConditionChristmasTreeOrnamentRead", -- 新饰品红点 + CONDITION_CHRISTMAS_TREE_ORNAMENT_ACTIVE = "XRedPointConditionChristmasTreeOrnamentActive", -- 兑换饰品红点 + CONDITION_CHRISTMAS_TREE_AWARD = "XRedPointConditionChristmasTreeAward", -- 奖励红点 + + -- 春节对联小游戏红点 + CONDITION_COUPLET_GAME = "XRedPointConditionCoupletGameRed", -- 小游戏红点 + CONDITION_COUPLET_GAME_REWARD_TASK = "XRedPointConditionCoupletGameRewardTask", -- 奖励任务红点 + CONDITION_COUPLET_GAME_PLAY_VIDEO = "XRedPointConditionCoupletGamePlayVideo", -- 播放剧情红点 + + --跑团红点(主线终焉福音) + CONDITION_TRPG_MAIN_VIEW = "XRedPointConditionTRPGMainView", --主线界面红点 + CONDITION_TRPG_MAIN_MODE = "XRedPointConditionTRPGMainMode", --探索模式红点 + CONDITION_TRPG_TRUTH_ROAD_REWARD = "XRedPointTRPGTruthRoadReward", --求真之路奖励 + CONDITION_TRPG_COLLECTION_MEMOIR = "XRedPointTRPGCollectionMemoir", --珍藏-回忆 + CONDITION_TRPG_AREA_REWARD = "XRedPointTRPGAreaReward", --区域探索度奖励 + CONDITION_TRPG_WORLD_BOSS_REWARD = "XRedPointTRPGWorldBossReward", --跑团世界BOSS奖励 + CONDITION_TRPG_ROLE_TALENT = "XRedPointTRPGRoleTalent", --调查员天赋 + CONDITION_TRPG_SECOND_MAIN_REWARD = "XRedPointTRPGSecondMainReward", --常规主线奖励 + + --活动入口可挑战 + CONDITION_ACTIVITYBRIE_ROGUELIKEMAIN = "XRedPointConditionRogueLikeMain", --roguelike爬塔红点 + CONDITION_ACTIVITYBRIE_BABELTOWER = "XRedPointConditionBabelTower", --巴别塔红点 + CONDITION_ACTIVITYBRIE_BOSSSINGLE = "XRedPointConditionBossSingle", --超难关 + CONDITION_ACTIVITYBRIE_EXTRA = "XRedPointConditionExtra", --番外剧情 + CONDITION_ACTIVITYBRIE_PREQUEL = "XRedPointConditionPrequel", --间章剧情 + CONDITION_ACTIVITYBRIE_NIER = "XRedPointConditionNierCanFight", --尼尔玩法可挑战 + + -- 兵法蓝图玩法红点 + CONDITION_RPGTOWER_TEAM_RED = "XRedPointConditionRpgTowerTeamRed", --有可升星角色时 + CONDITION_RPGTOWER_TASK_RED = "XRedPointConditionRpgTowerTaskRed", --有可领取奖励的任务时 + CONDITION_RPGTOWER_DAILYREWARD_RED = "XRedPointConditionRpgTowerDailyRewardRed", --有每日奖励可领取时 + -- 尼尔玩法红点 + CONDITION_NIER_RED = "XRedPointConditionNieRRed", + CONDITION_NIER_TASK_RED = "XRedPointConditionNieRTaskRed", + CONDITION_NIER_POD_RED = "XRedPointConditionNieRPODRed", + CONDITION_NIER_REPEAT_RED = "XRedPointConditionNieRRepeatRed", + CONDITION_NIER_CHARACTER_RED = "XRedPointConditionNieRCharacterRed", + + -- 特训关三期红点显示 + CONDITION_SPECIALTRAIN_RED = "XRedPointConditionSpecialTrain", + CONDITION_SPECIALTRAINPOINT_RED = "XRedPointConditionSpecialTrainPoint", + --师徒系统相关红点 + CONDITION_MENTOR_APPLY_RED = "XRedPointConditionMentorApplyRed", --申请列表红点 + CONDITION_MENTOR_REWARD_RED = "XRedPointConditionMentorRewardRed", --奖励红点 + CONDITION_MENTOR_TASK_RED = "XRedPointConditionMentorTaskRed", --任务红点 + + --炸服押注红点 + CONDITION_GUARD_CAMP_RED = "XRedPointConditionGuardCampRed", + + --口袋战双红点 + CONDITION_POKEMON_TIME_SUPPLY_RED = "XRedPointConditionPokemonCanGetTimeSupply", --口袋战双时间奖励红点 + CONDITION_POKEMON_RED = "XRedPointConditionPokemonRed", --口袋战双入口红点 + CONDITION_POKEMON_TASK_RED = "XRedPointConditionPokemonTaskRed", --口袋战双任务红点 + CONDITION_POKEMON_NEW_ROLE = "XRedPointConditionPokemonNewRole", --口袋战双培养界面新角色 + + -- 模拟作战红点 + CONDITION_SIMULATED_COMBAT = "XRedPointConditionSimulatedCombat", + CONDITION_SIMULATED_COMBAT_CHALLENGE = "XRedPointConditionSimulatedCombatChallenge", + CONDITION_SIMULATED_COMBAT_POINT = "XRedPointConditionSimulatedCombatPoint", + CONDITION_SIMULATED_COMBAT_STAR = "XRedPointConditionSimulatedCombatStar", + CONDITION_SIMULATED_COMBAT_TASK = "XRedPointConditionSimulatedCombatTask", + + -- 骇入玩法 + CONDITION_FUBEN_HACK_STAR = "XRedPointConditionFubenHackStar", -- 星级奖励 + CONDITION_FUBEN_HACK_BUFF = "XRedPointConditionFubenHackBuff", -- Buff解锁 + + -- 双人玩法 + CONDITION_COUPLE_COMBAT_NORMAL = "XRedPointConditionCoupleCombatNormal", -- 普通模式 + CONDITION_COUPLE_COMBAT_HARD = "XRedPointConditionCoupleCombatHard", -- 挑战模式 + + --追击玩法奖励可以领取 + CONDITION_CHESSPURSUIT_REWARD_RED = "XRedPointConditionChessPursuitReward", + + --超级据点 + XRedPointConditionStrongholdMineralLeft = "XRedPointConditionStrongholdMineralLeft", --有剩余矿石可领取 + XRedPointConditionStrongholdRewardCanGet = "XRedPointConditionStrongholdRewardCanGet", --有任务奖励未领取 + + --巴别塔奖励可领取 + CONDITION_ACTIVITYBRIE_BABELTOWER_REWARD = "XRedPointConditionBabelTowerReward", + + --伙伴 + CONDITION_PARTNER_COMPOSE_RED = "XRedPointConditionPartnerCanCompose", --是否可以合成 + CONDITION_PARTNER_NEWSKILL_RED = "XRedPointConditionPartnerNewSkill", --是否有新技能解锁 + + --春节集字活动红点 + CONDITION_SPRINGFESTIVAL_TASK_RED = "XRedPointConditionSpringFestivalTaskRed", + CONDITION_SPRINGFESTIVAL_BAG_RED = "XRedPointConditionSpringFestivalBagRed", + CONDITION_SPRINGFESTIVAL_GET_REWARD_RED = "XRedPointConditionSpringFestivalRewardRed", + -- 海外定制烟花活动红点 + CONDITION_FIREWORKS_AVAILABLE = "XRedPointConditionFireworks", + --2021白色情人节活动 + CONDITION_WHITEVALENTINE2021_INVITE = "XRedPointConditionWhite2021Invite", --邀约红点 + CONDITION_WHITEVALENTINE2021_ENCOUNTER = "XRedPointConditionWhite2021Encounter", --偶遇红点 + CONDITION_WHITEVALENTINE2021_TASK = "XRedPointConditionWhite2021Task", --任务红点 + CONDITION_WHITEVALENTINE2021_ENTRYRED = "XRedPointConditionWhiteValentineTaskRed", --入口红点 + + --猜拳小游戏红点 + CONDITION_FINGERGUESSING_TASK = "XRedPointConditionFingerGuessingTaskRed", --猜拳小游戏任务红点 + + --库洛姆人物活动红点 + CONDITION_KOROMCHARACTIVITYMAINRED = "XRedPointConditionKoroCharActivity", --库洛姆人物活动主界面红点 + CONDITION_KOROMCHARACTIVITYCHALLENGERED = "XRedPointConditionKoroCharActivityChallenge", --挑战关红点 + CONDITION_KOROMCHARACTIVITYTEACHINGRED = "XRedPointConditionKoroCharActivityTeaching", --教学关红点 + + --萌战红点 + CONDITION_MOEWAR_PREPARATION = "XRedPointConditionMoeWarPreparation", --筹备红点 + CONDITION_MOEWAR_PREPARATION_REWARD = "XRedPointConditionMoeWarPreparationReward", --筹备奖励可领取 + CONDITION_MOEWAR_PREPARATION_OPEN_STAGE = "XRedPointConditionMoeWarPreparationOpenStage", --筹备关卡开启数量达到配置提醒的数量及以上 + CONDITION_MOEWAR_RECRUIT = "XRedPointConditionMoeWarRecruit", --招募通讯中 + CONDITION_MOEWAR_TASK_TAB = "XRedPointConditionMoeWarTaskTab", --任务面板红点 + CONDITION_MOEWAR_TASK = "XRedPointConditionMoeWarTask", --任务面板红点 + CONDITION_MOEWAR_DRAW = "XRedPointConditionMoeWarDrawRed", --抽奖红点 + + --翻牌猜大小红点 + CONDITION_POKER_GUESSING_RED = "XRedPointConditionPokerGuessingRed", --翻牌猜大小活动列表红点 + -- 改造玩法红点 + CONDITION_REFORM_All_RED_POINT = "XRedPointConditionReformAllRedPoint", -- 改造玩法任务奖励获取 + CONDITION_REFORM_TASK_GET_REWARD = "XRedPointConditionReformTaskGetReward", -- 改造玩法任务奖励获取 + CONDITION_REFORM_BASE_STAGE_OPEN = "XRedPointConditionReformBaseStageOpen", -- 改造玩法基础关卡开启 + CONDITION_REFORM_EVOLVABLE_STAGE_UNLOCK = "XRedPointConditionReformEvolvableStageUnlock", -- 改造玩法改造难度解锁 + + -- 剧情合集剧情红点 + CONDITION_MOVIE_ASSEMBLE_MOVIE_RED = "XRedPointConditionMovieAssembleMovieRed", -- 剧情上的红点 + CONDITION_MOVIE_ASSEMBLE_RED = "XRedPointConditionMovieAssembleRed", -- 剧情合集红点条件(参数:合集Id) + CONDITION_MOVIE_ASSEMBLE_01 = "XRedPointConditionMovieAssemble01Red", -- 剧情合集Id为1的红点 + -- 翻牌小游戏红点 + CONDITION_INVERTCARDGAME_RED = "XRedPointConditionInvertCardGameRed", -- 翻牌小游戏红点条件 + CONDITION_INVERTCARDGAME_TOG = "XRedPointConditionInvertCardGameTog", -- 翻牌小游戏左侧标签红点 + --扫雷小游戏 + CONDITION_MINSWEEPING_RED = "XRedPointConditionMineSweepingRed",--门票剩余时有关卡未通关 + + -- 系列涂装剧情活动 + CONDITION_FASHION_STORY_HAVE_STAGE = "XRedPointConditionFashionStoryHaveStage", -- 有关卡尚未通关 + + --杀戮空间 + XRedPointConditionKillZoneActivity = "XRedPointConditionKillZoneActivity", --入口红点 + XRedPointConditionKillZoneNewChapter = "XRedPointConditionKillZoneNewChapter", --有新章节可挑战 + XRedPointConditionKillZoneNewDiff = "XRedPointConditionKillZoneNewDiff", --挑战模式已开启 + XRedPointConditionKillZoneStarReward = "XRedPointConditionKillZoneStarReward", --星级奖励可领取 + XRedPointConditionKillZoneDailyStarReward = "XRedPointConditionKillZoneDailyStarReward", --每日星级奖励可领取 + XRedPointConditionKillZonePluginOperate = "XRedPointConditionKillZonePluginOperate", --插件待操作 + + --2021端午活动 + CONDITION_RPG_MAKER_GAME_RED = "XRedPointConditionRpgMakerGame", + + --战斗通行证 + CONDITION_PASSPORT_RED = "XRedPointConditionPassport", --入口红点 + CONDITION_PASSPORT_PANEL_REWARD_RED = "XRedPointConditionPassportPanelReward", --主界面奖励可领取 + CONDITION_PASSPORT_TASK_DAILY_RED = "XRedPointConditionPassportTaskDaily", --每日任务奖励可领取 + CONDITION_PASSPORT_TASK_WEEKLY_RED = "XRedPointConditionPassportTaskWeekly", --每周任务奖励可领取 + CONDITION_PASSPORT_TASK_ACTIVITY_RED = "XRedPointConditionPassportTaskActivity", --活动任务奖励可领取 + + --超级爬塔 + CONDITION_SUPERTOWER_ROLE_LEVELUP = "XRedPointConditionSTRoleLevelUp", -- 超级爬塔角色超限升级红点 + CONDITION_SUPERTOWER_ROLE_PLUGIN = "XRedPointConditionSTRolePlugin", -- 超级爬塔角色专属插件红点 + CONDITION_SUPERTOWER_ROLE_INDULT = "XRedPointConditionSTRoleInDult", -- 超级爬塔角色特典红点 + --日服老虎机活动红点 + CONDITION_SLOTMACHINE_RED = "XRedPointConditionSlotMachine", + CONDITION_SLOTMACHINE_REDL = "XRedPointConditionSlotMachineL", +} + +--注册所有条件 +function XRedPointConditions.RegisterAllConditions() + if not XRedPointConditions.Conditions then + return + end + + XRedPointConditions.Types = {} + for key, value in pairs(XRedPointConditions.Conditions) do + local m = require("XRedPoint/XRedPointConditions/" .. value) + rawset(_G, value, m) + XRedPointConditions[key] = m + XRedPointConditions.Types[key] = key + end +end + +XRedPointConditions.RegisterAllConditions() \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionActivityBriefTaskFinished.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionActivityBriefTaskFinished.lua new file mode 100644 index 00000000..784cfa5a --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionActivityBriefTaskFinished.lua @@ -0,0 +1,18 @@ +---------------------------------------------------------------- +--新手任务奖励检测 +local XRedPointConditionActivityBriefTaskFinished = {} +local Events = nil + +function XRedPointConditionActivityBriefTaskFinished.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_TASK_SYNC), + } + return Events +end + +function XRedPointConditionActivityBriefTaskFinished.Check() + return XDataCenter.ActivityBriefManager.CheckAnyTaskFinished() +end + +return XRedPointConditionActivityBriefTaskFinished \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionActivityDrawNew.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionActivityDrawNew.lua new file mode 100644 index 00000000..9a156bca --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionActivityDrawNew.lua @@ -0,0 +1,19 @@ +---------------------------------------------------------------- +-- 是否有新活动奖池开启 +local XRedPointConditionActivityDrawNew = {} + +local Events = nil +function XRedPointConditionActivityDrawNew.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_DRAW_ACTIVITYDRAW_CHANGE), + XRedPointEventElement.New(XEventId.EVENT_MAINUI_ENABLE), + } + return Events +end + +function XRedPointConditionActivityDrawNew.Check() + return XDataCenter.DrawManager.CheckNewActivityDraw() +end + +return XRedPointConditionActivityDrawNew \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionActivityNewAcitivies.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionActivityNewAcitivies.lua new file mode 100644 index 00000000..1e53d122 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionActivityNewAcitivies.lua @@ -0,0 +1,19 @@ +---------------------------------------------------------------- +local XRedPointConditionActivityNewAcitivies = {} +local Events = nil + +function XRedPointConditionActivityNewAcitivies.GetSubEvents() + Events = Events or { + XRedPointEventElement.New(XEventId.EVENT_ACTIVITY_ACTIVITIES_READ_CHANGE), + XRedPointEventElement.New(XEventId.EVENT_REGRESSION_SEND_INVITATION_INFO_UPDATE), + XRedPointEventElement.New(XEventId.EVENT_ACTIVITY_INFO_UPDATE), + XRedPointEventElement.New(XEventId.EVENT_TASK_SYNC), + } + return Events +end + +function XRedPointConditionActivityNewAcitivies.Check() + return XDataCenter.ActivityManager.CheckRedPoint() +end + +return XRedPointConditionActivityNewAcitivies \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionActivityNewAcitiviesTogs.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionActivityNewAcitiviesTogs.lua new file mode 100644 index 00000000..91fdee51 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionActivityNewAcitiviesTogs.lua @@ -0,0 +1,16 @@ +---------------------------------------------------------------- +local XRedPointConditionActivityNewAcitiviesTogs = {} +local Events = nil + +function XRedPointConditionActivityNewAcitiviesTogs.GetSubEvents() + Events = Events or { + XRedPointEventElement.New(XEventId.EVENT_REGRESSION_SEND_INVITATION_INFO_UPDATE), + } + return Events +end + +function XRedPointConditionActivityNewAcitiviesTogs.Check() + return true +end + +return XRedPointConditionActivityNewAcitiviesTogs \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionActivityNewActivityNotices.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionActivityNewActivityNotices.lua new file mode 100644 index 00000000..1fbdc37f --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionActivityNewActivityNotices.lua @@ -0,0 +1,16 @@ +---------------------------------------------------------------- +local XRedPointConditionActivityNewActivityNotices = {} +local Events = nil + +function XRedPointConditionActivityNewActivityNotices.GetSubEvents() + Events = Events or { + XRedPointEventElement.New(XEventId.EVENT_ACTIVITY_NOTICE_READ_CHANGE), + } + return Events +end + +function XRedPointConditionActivityNewActivityNotices.Check() + return XDataCenter.NoticeManager.CheckInGameNoticeRedPoint(0) +end + +return XRedPointConditionActivityNewActivityNotices \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionActivityNewNotices.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionActivityNewNotices.lua new file mode 100644 index 00000000..900428c0 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionActivityNewNotices.lua @@ -0,0 +1,16 @@ +---------------------------------------------------------------- +local XRedPointConditionActivityNewNotices = {} +local Events = nil + +function XRedPointConditionActivityNewNotices.GetSubEvents() + Events = Events or { + XRedPointEventElement.New(XEventId.EVENT_ACTIVITY_NOTICE_READ_CHANGE), + } + return Events +end + +function XRedPointConditionActivityNewNotices.Check() + return XDataCenter.NoticeManager.CheckInGameNoticeRedPoint(1) +end + +return XRedPointConditionActivityNewNotices \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveAwareness.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveAwareness.lua new file mode 100644 index 00000000..31bd1c97 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveAwareness.lua @@ -0,0 +1,23 @@ +-- +-- Author: wujie +-- Note: 图鉴意识红点 + +local XRedPointConditionArchiveAwareness = {} +local Events = nil + +function XRedPointConditionArchiveAwareness.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENET_ARCHIVE_NEW_AWARENESS_SUIT), + XRedPointEventElement.New(XEventId.EVENET_ARCHIVE_UNLOCK_AWARENESS_SUIT), + XRedPointEventElement.New(XEventId.EVENET_ARCHIVE_UNLOCK_AWARENESS_SETTING), + } + return Events +end + +function XRedPointConditionArchiveAwareness.Check() + return (XDataCenter.ArchiveManager.IsHaveNewAwarenessSuit() or XDataCenter.ArchiveManager.IsHaveNewAwarenessSetting()) + and XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.Archive) +end + +return XRedPointConditionArchiveAwareness \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveAwarenessGridNewTag.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveAwarenessGridNewTag.lua new file mode 100644 index 00000000..15f64009 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveAwarenessGridNewTag.lua @@ -0,0 +1,18 @@ +-- Author: wujie +-- Note: 图鉴武器新得时的红点 +local XRedPointConditionArchiveAwarenessGridNewTag = {} +local Events = nil + +function XRedPointConditionArchiveAwarenessGridNewTag.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENET_ARCHIVE_NEW_AWARENESS_SUIT), + } + return Events +end + +function XRedPointConditionArchiveAwarenessGridNewTag.Check(suitId) + return XDataCenter.ArchiveManager.IsNewAwarenessSuit(suitId) +end + +return XRedPointConditionArchiveAwarenessGridNewTag \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveAwarenessNewTag.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveAwarenessNewTag.lua new file mode 100644 index 00000000..c7cf595d --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveAwarenessNewTag.lua @@ -0,0 +1,19 @@ +-- Author: wujie +-- Note: 图鉴武器新得时的红点 +local XRedPointConditionArchiveAwarenessNewTag = {} +local Events = nil + +function XRedPointConditionArchiveAwarenessNewTag.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENET_ARCHIVE_NEW_AWARENESS_SUIT), + XRedPointEventElement.New(XEventId.EVENET_ARCHIVE_UNLOCK_AWARENESS_SUIT), + } + return Events +end + +function XRedPointConditionArchiveAwarenessNewTag.Check() + return true +end + +return XRedPointConditionArchiveAwarenessNewTag \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveAwarenessSettingUnlock.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveAwarenessSettingUnlock.lua new file mode 100644 index 00000000..2e9629c8 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveAwarenessSettingUnlock.lua @@ -0,0 +1,19 @@ +-- Author: wujie +-- Note: 图鉴武器设定新得时的红点 + +local XRedPointConditionArchiveAwarenessSettingUnlock = {} +local Events = nil + +function XRedPointConditionArchiveAwarenessSettingUnlock.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENET_ARCHIVE_UNLOCK_AWARENESS_SETTING), + } + return Events +end + +function XRedPointConditionArchiveAwarenessSettingUnlock.Check(suitId) + return XDataCenter.ArchiveManager.IsNewAwarenessSetting(suitId) +end + +return XRedPointConditionArchiveAwarenessSettingUnlock \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveCGAll.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveCGAll.lua new file mode 100644 index 00000000..c2f810b9 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveCGAll.lua @@ -0,0 +1,17 @@ +local XRedPointConditionArchiveCGAll = {} +local Events = nil + +function XRedPointConditionArchiveCGAll.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENET_ARCHIVE_MARK_CG), + XRedPointEventElement.New(XEventId.EVENET_ARCHIVE_NEW_CG), + } + return Events +end + +function XRedPointConditionArchiveCGAll.Check() + return XDataCenter.ArchiveManager.CheckCGRedPointByGroup() and XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.Archive) +end + +return XRedPointConditionArchiveCGAll \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveCGRed.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveCGRed.lua new file mode 100644 index 00000000..be5c413f --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveCGRed.lua @@ -0,0 +1,17 @@ +local XRedPointConditionArchiveCGRed = {} +local Events = nil + +function XRedPointConditionArchiveCGRed.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENET_ARCHIVE_MARK_CG), + XRedPointEventElement.New(XEventId.EVENET_ARCHIVE_NEW_CG), + } + return Events +end + +function XRedPointConditionArchiveCGRed.Check(id) + return XDataCenter.ArchiveManager.CheckCGRedPoint(id) +end + +return XRedPointConditionArchiveCGRed \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveCGTypeRed.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveCGTypeRed.lua new file mode 100644 index 00000000..9b8825e8 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveCGTypeRed.lua @@ -0,0 +1,17 @@ +local XRedPointConditionArchiveCGTypeRed = {} +local Events = nil + +function XRedPointConditionArchiveCGTypeRed.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENET_ARCHIVE_MARK_CG), + XRedPointEventElement.New(XEventId.EVENET_ARCHIVE_NEW_CG), + } + return Events +end + +function XRedPointConditionArchiveCGTypeRed.Check(groupId) + return XDataCenter.ArchiveManager.CheckCGRedPointByGroup(groupId) +end + +return XRedPointConditionArchiveCGTypeRed \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveMonsterAll.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveMonsterAll.lua new file mode 100644 index 00000000..6cbc74bf --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveMonsterAll.lua @@ -0,0 +1,19 @@ +local XRedPointConditionArchiveMonsterAll = {} +local Events = nil + +function XRedPointConditionArchiveMonsterAll.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVNET_ARCHIVE_MONSTER_UNLOCKMONSTER), + XRedPointEventElement.New(XEventId.EVNET_ARCHIVE_MONSTER_UNLOCKMONSTERINFO), + XRedPointEventElement.New(XEventId.EVNET_ARCHIVE_MONSTER_UNLOCKMONSTERSKILL), + XRedPointEventElement.New(XEventId.EVNET_ARCHIVE_MONSTER_UNLOCKMONSTERSETTING), + } + return Events +end + +function XRedPointConditionArchiveMonsterAll.Check() + return XDataCenter.ArchiveManager.IsMonsterHaveRedPointByAll() and XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.Archive) +end + +return XRedPointConditionArchiveMonsterAll \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveMonsterInfo.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveMonsterInfo.lua new file mode 100644 index 00000000..959c291a --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveMonsterInfo.lua @@ -0,0 +1,16 @@ +local XRedPointConditionArchiveMonsterInfo = {} +local Events = nil + +function XRedPointConditionArchiveMonsterInfo.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVNET_ARCHIVE_MONSTER_UNLOCKMONSTERINFO), + } + return Events +end + +function XRedPointConditionArchiveMonsterInfo.Check(monsterId) + return XDataCenter.ArchiveManager.IsHaveNewMonsterInfoByNpcId(monsterId) +end + +return XRedPointConditionArchiveMonsterInfo \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveMonsterRed.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveMonsterRed.lua new file mode 100644 index 00000000..114cf2ff --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveMonsterRed.lua @@ -0,0 +1,20 @@ +local XRedPointConditionArchiveMonsterRed = {} +local Events = nil + +function XRedPointConditionArchiveMonsterRed.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVNET_ARCHIVE_MONSTER_UNLOCKMONSTER), + XRedPointEventElement.New(XEventId.EVNET_ARCHIVE_MONSTER_UNLOCKMONSTERINFO), + XRedPointEventElement.New(XEventId.EVNET_ARCHIVE_MONSTER_UNLOCKMONSTERSKILL), + XRedPointEventElement.New(XEventId.EVNET_ARCHIVE_MONSTER_UNLOCKMONSTERSETTING), + } + return Events +end + +function XRedPointConditionArchiveMonsterRed.Check(monsterId) + return XDataCenter.ArchiveManager.IsMonsterHaveRedPointById(monsterId) and + not XDataCenter.ArchiveManager.IsMonsterHaveNewTagById(monsterId) +end + +return XRedPointConditionArchiveMonsterRed \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveMonsterSetting.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveMonsterSetting.lua new file mode 100644 index 00000000..8ae44c2d --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveMonsterSetting.lua @@ -0,0 +1,16 @@ +local XRedPointConditionArchiveMonsterSetting = {} +local Events = nil + +function XRedPointConditionArchiveMonsterSetting.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVNET_ARCHIVE_MONSTER_UNLOCKMONSTERSETTING), + } + return Events +end + +function XRedPointConditionArchiveMonsterSetting.Check(monsterId) + return XDataCenter.ArchiveManager.IsHaveNewMonsterSettingByNpcId(monsterId) +end + +return XRedPointConditionArchiveMonsterSetting \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveMonsterSkill.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveMonsterSkill.lua new file mode 100644 index 00000000..8a46c597 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveMonsterSkill.lua @@ -0,0 +1,16 @@ +local XRedPointConditionArchiveMonsterSkill = {} +local Events = nil + +function XRedPointConditionArchiveMonsterSkill.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVNET_ARCHIVE_MONSTER_UNLOCKMONSTERSKILL), + } + return Events +end + +function XRedPointConditionArchiveMonsterSkill.Check(monsterId) + return XDataCenter.ArchiveManager.IsHaveNewMonsterSkillByNpcId(monsterId) +end + +return XRedPointConditionArchiveMonsterSkill \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveMonsterTag.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveMonsterTag.lua new file mode 100644 index 00000000..a24c04e4 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveMonsterTag.lua @@ -0,0 +1,16 @@ +local XRedPointConditionArchiveMonsterTag = {} +local Events = nil + +function XRedPointConditionArchiveMonsterTag.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVNET_ARCHIVE_MONSTER_UNLOCKMONSTER), + } + return Events +end + +function XRedPointConditionArchiveMonsterTag.Check(monsterId) + return XDataCenter.ArchiveManager.IsMonsterHaveNewTagById(monsterId) +end + +return XRedPointConditionArchiveMonsterTag \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveMonsterTypeRed.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveMonsterTypeRed.lua new file mode 100644 index 00000000..8b7e847e --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveMonsterTypeRed.lua @@ -0,0 +1,20 @@ +local XRedPointConditionArchiveMonsterTypeRed = {} +local Events = nil + +function XRedPointConditionArchiveMonsterTypeRed.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVNET_ARCHIVE_MONSTER_UNLOCKMONSTER), + XRedPointEventElement.New(XEventId.EVNET_ARCHIVE_MONSTER_UNLOCKMONSTERINFO), + XRedPointEventElement.New(XEventId.EVNET_ARCHIVE_MONSTER_UNLOCKMONSTERSKILL), + XRedPointEventElement.New(XEventId.EVNET_ARCHIVE_MONSTER_UNLOCKMONSTERSETTING), + } + return Events +end + +function XRedPointConditionArchiveMonsterTypeRed.Check(type) + return XDataCenter.ArchiveManager.IsMonsterHaveRedPointByType(type) and + not XDataCenter.ArchiveManager.IsMonsterHaveNewTagByType(type) +end + +return XRedPointConditionArchiveMonsterTypeRed \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveMonsterTypeTag.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveMonsterTypeTag.lua new file mode 100644 index 00000000..04a64a00 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveMonsterTypeTag.lua @@ -0,0 +1,16 @@ +local XRedPointConditionArchiveMonsterTypeTag = {} +local Events = nil + +function XRedPointConditionArchiveMonsterTypeTag.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVNET_ARCHIVE_MONSTER_UNLOCKMONSTER), + } + return Events +end + +function XRedPointConditionArchiveMonsterTypeTag.Check(type) + return XDataCenter.ArchiveManager.IsMonsterHaveNewTagByType(type) +end + +return XRedPointConditionArchiveMonsterTypeTag \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveWeapon.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveWeapon.lua new file mode 100644 index 00000000..33e0fd6b --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveWeapon.lua @@ -0,0 +1,23 @@ +-- +-- Author: wujie +-- Note: 图鉴武器红点 + +local XRedPointConditionArchiveWeapon = {} +local Events = nil + +function XRedPointConditionArchiveWeapon.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENET_ARCHIVE_NEW_WEAPON), + XRedPointEventElement.New(XEventId.EVENET_ARCHIVE_UNLOCK_WEAPON), + XRedPointEventElement.New(XEventId.EVENET_ARCHIVE_UNLOCK_WEAPON_SETTING), + } + return Events +end + +function XRedPointConditionArchiveWeapon.Check() + return (XDataCenter.ArchiveManager.IsHaveNewWeapon() or XDataCenter.ArchiveManager.IsHaveNewWeaponSetting()) + and XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.Archive) +end + +return XRedPointConditionArchiveWeapon \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveWeaponGridNewTag.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveWeaponGridNewTag.lua new file mode 100644 index 00000000..23408d3d --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveWeaponGridNewTag.lua @@ -0,0 +1,19 @@ +-- Author: wujie +-- Note: 图鉴武器新得时的红点 + +local XRedPointConditionArchiveWeaponGridNewTag = {} +local Events = nil + +function XRedPointConditionArchiveWeaponGridNewTag.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENET_ARCHIVE_NEW_WEAPON), + } + return Events +end + +function XRedPointConditionArchiveWeaponGridNewTag.Check(templateId) + return XDataCenter.ArchiveManager.IsNewWeapon(templateId) +end + +return XRedPointConditionArchiveWeaponGridNewTag \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveWeaponNewTag.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveWeaponNewTag.lua new file mode 100644 index 00000000..ad383501 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveWeaponNewTag.lua @@ -0,0 +1,20 @@ +-- Author: wujie +-- Note: 图鉴武器新得时的红点 + +local XRedPointConditionArchiveWeaponNewTag = {} +local Events = nil + +function XRedPointConditionArchiveWeaponNewTag.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENET_ARCHIVE_NEW_WEAPON), + XRedPointEventElement.New(XEventId.EVENET_ARCHIVE_UNLOCK_WEAPON), + } + return Events +end + +function XRedPointConditionArchiveWeaponNewTag.Check() + return true +end + +return XRedPointConditionArchiveWeaponNewTag \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveWeaponSettingUnlock.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveWeaponSettingUnlock.lua new file mode 100644 index 00000000..1f9e84e9 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArchiveWeaponSettingUnlock.lua @@ -0,0 +1,19 @@ +-- Author: wujie +-- Note: 图鉴武器设定新得时的红点 + +local XRedPointConditionArchiveWeaponSettingUnlock = {} +local Events = nil + +function XRedPointConditionArchiveWeaponSettingUnlock.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENET_ARCHIVE_UNLOCK_WEAPON_SETTING), + } + return Events +end + +function XRedPointConditionArchiveWeaponSettingUnlock.Check(templateId) + return XDataCenter.ArchiveManager.IsNewWeaponSetting(templateId) +end + +return XRedPointConditionArchiveWeaponSettingUnlock \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArenaApply.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArenaApply.lua new file mode 100644 index 00000000..6fd938ff --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArenaApply.lua @@ -0,0 +1,19 @@ +local XRedPointConditionArenaApply = {} + +local Events = nil +function XRedPointConditionArenaApply.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_ARENA_TEAM_CHANGE), + XRedPointEventElement.New(XEventId.EVENT_ARENA_TEAM_INITIATIVE_LEAVE), + XRedPointEventElement.New(XEventId.EVENT_ARENA_TEAM_RECEIVE_APPLY_DATA), + XRedPointEventElement.New(XEventId.EVENT_ARENA_TEAM_NEW_APPLY_ENTER), + } + return Events +end + +function XRedPointConditionArenaApply.Check() + return XDataCenter.ArenaManager.CheckHaveApplyData() +end + +return XRedPointConditionArenaApply \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArenaTask.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArenaTask.lua new file mode 100644 index 00000000..7d443771 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionArenaTask.lua @@ -0,0 +1,16 @@ +---------------------------------------------------------------- +-- 竞技任务领取检测 +local XRedPointConditionArenaTask = {} + +function XRedPointConditionArenaTask.Check() + local dailyTasks = XDataCenter.TaskManager.GetArenaChallengeTaskList() + for _, dailyTask in ipairs(dailyTasks) do + if dailyTask.State == XDataCenter.TaskManager.TaskState.Achieved then + return true + end + end + + return false +end + +return XRedPointConditionArenaTask \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionAssign.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionAssign.lua new file mode 100644 index 00000000..a8fffc32 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionAssign.lua @@ -0,0 +1,18 @@ +-- 红点条件检测器 +--默认 +local XRedPointConditionAssign = {} + +local Events = nil +function XRedPointConditionAssign.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENET_ASSIGN_CAN_REWARD), + } + return Events +end +--检测 +function XRedPointConditionAssign.Check() + return XDataCenter.FubenAssignManager.IsRedPoint() +end + +return XRedPointConditionAssign \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionBabelTower.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionBabelTower.lua new file mode 100644 index 00000000..31f3880a --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionBabelTower.lua @@ -0,0 +1,37 @@ +---------------------------------------------------------------- +--巴别塔:0分的时候会显示红点 + +local XRedPointConditionBabelTower = {} +local Events = nil +local SubCondition = nil +function XRedPointConditionBabelTower.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_BABEL_ACTIVITY_STATUS_CHANGED), + XRedPointEventElement.New(XEventId.EVENT_PLAYER_LEVEL_CHANGE), + } + return Events +end + +function XRedPointConditionBabelTower.GetSubConditions() + SubCondition = SubCondition or { + XRedPointConditions.Types.CONDITION_ACTIVITYBRIE_BABELTOWER_REWARD, + } + return SubCondition +end + +function XRedPointConditionBabelTower.Check() + local isOpen = XActivityBrieIsOpen.Get(XActivityBriefConfigs.ActivityGroupId.BabelTower) + if not isOpen then + return false + end + + local curScore, maxScore = XDataCenter.FubenBabelTowerManager.GetCurrentActivityScores() + if curScore == 0 then + return true + end + + return false +end + +return XRedPointConditionBabelTower \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionBabelTowerReward.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionBabelTowerReward.lua new file mode 100644 index 00000000..54427fe6 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionBabelTowerReward.lua @@ -0,0 +1,12 @@ +local XRedPointConditionBabelTowerReward = {} + +function XRedPointConditionBabelTowerReward.Check() + local isRewardFor = XDataCenter.TaskManager.GetIsRewardFor(XDataCenter.TaskManager.TaskType.BabelTower) + if isRewardFor then + return true + end + + return false +end + +return XRedPointConditionBabelTowerReward \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionBaseEquip.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionBaseEquip.lua new file mode 100644 index 00000000..6eec9b63 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionBaseEquip.lua @@ -0,0 +1,24 @@ +---------------------------------------------------------------- +local XRedPointConditionBaseEquip = {} +local Events = nil +function XRedPointConditionBaseEquip.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_BASE_EQUIP_DATA_REFRESH), + } + return Events +end + +function XRedPointConditionBaseEquip.Check() + if not XFunctionManager.JudgeOpen(XFunctionManager.FunctionName.Domitory) then + return false + end + + if XDataCenter.BaseEquipManager.CheckBaseEquipHint() then--基地装备 + return true + end + + return false +end + +return XRedPointConditionBaseEquip \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionBfrtChapterReward.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionBfrtChapterReward.lua new file mode 100644 index 00000000..c664f501 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionBfrtChapterReward.lua @@ -0,0 +1,18 @@ +---------------------------------------------------------------- +--节红点检测 +local XRedPointConditionBfrtChapterReward = {} + +local Events = nil +function XRedPointConditionBfrtChapterReward.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_FINISH_TASK) + } + return Events +end + +function XRedPointConditionBfrtChapterReward.Check(chapterId) + return XDataCenter.BfrtManager.CheckAnyTaskRewardCanGet(chapterId) +end + +return XRedPointConditionBfrtChapterReward \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionBossSingle.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionBossSingle.lua new file mode 100644 index 00000000..1e24cc1d --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionBossSingle.lua @@ -0,0 +1,35 @@ +---------------------------------------------------------------- +--超难关:有可挑战的关卡 + +local XRedPointConditionBossSingle = {} +local Events = nil +function XRedPointConditionBossSingle.GetSubEvents() + Events = Events or + { + } + return Events +end + +--有关卡还没打, 而且开放了 +function XRedPointConditionBossSingle.Check() + local isOpen = XActivityBrieIsOpen.Get(XActivityBriefConfigs.ActivityGroupId.BossSingle) + if isOpen then + local sectionId = XDataCenter.FubenActivityBossSingleManager.GetCurSectionId() + local stageIds = XDataCenter.FubenActivityBossSingleManager.GetSectionStageIdList(sectionId) + for i,stageId in ipairs(stageIds) do + local isUnLock = XDataCenter.FubenActivityBossSingleManager.IsChallengeUnlockByStageId(stageId) + if isUnLock then + local isPassed = XDataCenter.FubenActivityBossSingleManager.IsChallengePassedByStageId(stageId) + if not isPassed then + return true + end + end + end + + return false + else + return false + end +end + +return XRedPointConditionBossSingle \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionBossSingleReward.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionBossSingleReward.lua new file mode 100644 index 00000000..07dc4e32 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionBossSingleReward.lua @@ -0,0 +1,9 @@ +---------------------------------------------------------------- +-- 单机Boss检查奖励领取 +local XRedPointConditionBossSingleReward = {} + +function XRedPointConditionBossSingleReward.Check() + return XDataCenter.FubenBossSingleManager.CheckRewardRedHint() +end + +return XRedPointConditionBossSingleReward \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionBountyTask.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionBountyTask.lua new file mode 100644 index 00000000..afcbb1eb --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionBountyTask.lua @@ -0,0 +1,25 @@ +local XRedPointConditionBountyTask = {} +local Events = nil +function XRedPointConditionBountyTask.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_BOUNTYTASK_ACCEPT_TASK_REWARD), + XRedPointEventElement.New(XEventId.EVENT_BOUNTYTASK_TASK_COMPLETE_NOTIFY), + XRedPointEventElement.New(XEventId.EVENT_BOUNTYTASK_INFO_CHANGE_NOTIFY), + + } + return Events +end + +function XRedPointConditionBountyTask.Check() + + if not XFunctionManager.JudgeOpen(XFunctionManager.FunctionName.BountyTask) then + return false + end + + local completeCount = XDataCenter.BountyTaskManager.GetBountyTaskCompletedAndAcceptRewardCount() + return completeCount < XDataCenter.BountyTaskManager.MAX_BOUNTY_TASK_COUNT and (XDataCenter.BountyTaskManager.CheckBountyTaskHasReward() + or XDataCenter.BountyTaskManager.IsFirstTimeLoginInWeek()) +end + +return XRedPointConditionBountyTask \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionBriefEntry.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionBriefEntry.lua new file mode 100644 index 00000000..4407b7a6 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionBriefEntry.lua @@ -0,0 +1,42 @@ +---------------------------------------------------------------- +--短篇故事解锁红点检测 +local XRedPointConditionBriefEntry = {} +local Events = nil +function XRedPointConditionBriefEntry.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_CHARACTER_LEVEL_UP), + XRedPointEventElement.New(XEventId.EVENT_FUBEN_SETTLE_REWARD), + XRedPointEventElement.New(XEventId.EVENT_STORY_DISTORY), + } + return Events +end + +function XRedPointConditionBriefEntry.Check() + local Config = XDataCenter.ActivityBriefManager.GetActivityStoryConfig() + if not Config then + return false + end + local isUnlock + local desc = "" + local unLockCount = 0 + local playedCount = 0 + for key, value in pairs(Config) do + local ConfigValue = value + isUnlock,desc = XConditionManager.CheckCondition(value.ConditionId) + if isUnlock then + unLockCount = unLockCount + 1 + end + end + --获得读过的表 + local played = XDataCenter.ActivityBriefManager.GetPlayedStoryDic() + for storyId, isPlayed in pairs(played) do + playedCount = playedCount + 1 + end + if unLockCount > playedCount then + return true + end + return false +end + +return XRedPointConditionBriefEntry \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionChapterReward.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionChapterReward.lua new file mode 100644 index 00000000..49b5413a --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionChapterReward.lua @@ -0,0 +1,35 @@ + +---------------------------------------------------------------- +--章节红点检测 +local XRedPointConditionChapterReward = {} + +local SubCondition = nil +function XRedPointConditionChapterReward.GetSubConditions() + SubCondition = SubCondition or + { + XRedPointConditions.Types.CONDITION_MAINLINE_TREASURE, -- 主线章节收集奖励 + XRedPointConditions.Types.CONDITION_ZHOUMU_TASK, -- 周目挑战任务 + XRedPointConditions.Types.CONDITION_TRPG_MAIN_VIEW, -- 周年庆跑团 + } + return SubCondition +end + +function XRedPointConditionChapterReward.Check(chapterId) + if XRedPointConditionMainLineTreasure.Check(chapterId) then + return true + end + + local chapterInfo = XDataCenter.FubenMainLineManager.GetChapterInfo(chapterId) + local chapterMainId = chapterInfo and chapterInfo.ChapterMainId or 0 + if XRedPointConditionZhouMuTask.Check(chapterMainId) then + return true + end + + if XRedPointConditionTRPGMainView.Check(chapterId) then + return true + end + + return false +end + +return XRedPointConditionChapterReward \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionChapterSectionReward.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionChapterSectionReward.lua new file mode 100644 index 00000000..36436e8b --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionChapterSectionReward.lua @@ -0,0 +1,18 @@ +---------------------------------------------------------------- +--节红点检测 +local XRedPointConditionChapterSectionReward = {} + +local Events = nil +function XRedPointConditionChapterSectionReward.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_FUBEN_CHAPTER_SECTION_REWARD) + } + return Events +end + +function XRedPointConditionChapterSectionReward.Check(sectionId) + return XDataCenter.FubenMainLineManager.CheckSectionTreasureReward(sectionId) +end + +return XRedPointConditionChapterSectionReward \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionCharacter.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionCharacter.lua new file mode 100644 index 00000000..5cb723a5 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionCharacter.lua @@ -0,0 +1,41 @@ + +---------------------------------------------------------------- +--角色入口红点检测 +local XRedPointConditionCharacter = {} +local SubCondition = nil +function XRedPointConditionCharacter.GetSubConditions() + SubCondition = SubCondition or { + XRedPointConditions.Types.CONDITION_CHARACTER_GRADE , + XRedPointConditions.Types.CONDITION_CHARACTER_QUALITY, + XRedPointConditions.Types.CONDITION_CHARACTER_UNLOCK, + XRedPointConditions.Types.CONDITION_EXHIBITION_NEW, + } + return SubCondition +end + +function XRedPointConditionCharacter.Check(characterId) + if not characterId then + return false + end + + if XRedPointConditionCharacterUnlock.Check(characterId) then + return true + end + + if XRedPointConditionCharacterGrade.Check(characterId) then + return true + end + + if XRedPointConditionCharacterQuality.Check(characterId) then + return true + end + + if XRedPointConditionExhibitionNew.Check(characterId) then + return true + end + + return false + +end + +return XRedPointConditionCharacter \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionCharacterGrade.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionCharacterGrade.lua new file mode 100644 index 00000000..dd54821a --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionCharacterGrade.lua @@ -0,0 +1,30 @@ + +---------------------------------------------------------------- +--角色晋升红点检测 +local XRedPointConditionCharacterGrade = {} +local Events = nil + +function XRedPointConditionCharacterGrade.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_CHARACTER_LEVEL_UP), + XRedPointEventElement.New(XEventId.EVENT_CHARACTER_GRADE), + XRedPointEventElement.New(XEventId.EVENT_CHARACTER_GRADE_PART), + XRedPointEventElement.New(XEventId.EVENT_ITEM_BUYASSET, {XDataCenter.ItemManager.ItemId.Coin}) + } + return Events +end + +function XRedPointConditionCharacterGrade.Check(characterId) + if not characterId then + return false + end + + if not XFunctionManager.JudgeOpen(XFunctionManager.FunctionName.CharacterGrade) then + return false + end + + return XDataCenter.CharacterManager.CanPromoteGrade(characterId) +end + +return XRedPointConditionCharacterGrade \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionCharacterLevel.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionCharacterLevel.lua new file mode 100644 index 00000000..f016be41 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionCharacterLevel.lua @@ -0,0 +1,35 @@ + +---------------------------------------------------------------- +--角色升级红点检测 +local XRedPointConditionCharacterLevel = {} +local Events = nil +function XRedPointConditionCharacterLevel.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_CHARACTER_LEVEL_UP), + XRedPointEventElement.New(XEventId.EVENT_PLAYER_LEVEL_CHANGE), + } + return Events +end + +function XRedPointConditionCharacterLevel.Check(characterId) + if not characterId then + return false + end + + if not XFunctionManager.JudgeOpen(XFunctionManager.FunctionName.Character) then + return false + end + + if XDataCenter.CharacterManager.CanLevelUp(characterId) then + return true + end + + if XRedPointConditionExhibitionNew.Check(characterId) then + return true + end + + return false +end + +return XRedPointConditionCharacterLevel \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionCharacterQuality.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionCharacterQuality.lua new file mode 100644 index 00000000..7442f1ef --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionCharacterQuality.lua @@ -0,0 +1,29 @@ + +---------------------------------------------------------------- +--角色升品红点检测 +local XRedPointConditionCharacterQuality = {} +local Events = nil +function XRedPointConditionCharacterQuality.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_CHARACTER_QUALITY_STAR_PROMOTE), + XRedPointEventElement.New(XEventId.EVENT_CHARACTER_QUALITY_PROMOTE), + } + return Events +end + +function XRedPointConditionCharacterQuality.Check(characterId) + + if not characterId then + return false + end + + if not XFunctionManager.JudgeOpen(XFunctionManager.FunctionName.CharacterQuality) then + return false + end + + local canPromote = XDataCenter.CharacterManager.CanPromoteQuality(characterId) + return canPromote +end + +return XRedPointConditionCharacterQuality \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionCharacterSkill.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionCharacterSkill.lua new file mode 100644 index 00000000..3b44d08b --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionCharacterSkill.lua @@ -0,0 +1,30 @@ + +---------------------------------------------------------------- +--角色技能红点检测 +local XRedPointConditionCharacterSkill = {} +local Events = nil +function XRedPointConditionCharacterSkill.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_CHARACTER_LEVEL_UP), + XRedPointEventElement.New(XEventId.EVENT_CHARACTER_SKILL_UP), + XRedPointEventElement.New(XEventId.EVENT_CHARACTER_QUALITY_PROMOTE), + XRedPointEventElement.New(XEventId.EVENT_CHARACTER_SKILL_UNLOCK), + } + return Events +end + +function XRedPointConditionCharacterSkill.Check(characterId) + + if not characterId then + return false + end + + if not XFunctionManager.JudgeOpen(XFunctionManager.FunctionName.CharacterSkill) then + return false + end + + return XDataCenter.CharacterManager.CanPromoteSkill(characterId) +end + +return XRedPointConditionCharacterSkill \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionCharacterUnlock.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionCharacterUnlock.lua new file mode 100644 index 00000000..ebd8d6b9 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionCharacterUnlock.lua @@ -0,0 +1,15 @@ + +---------------------------------------------------------------- +--角色解锁红点检测 +local XRedPointConditionCharacterUnlock = {} + +function XRedPointConditionCharacterUnlock.Check(characterId) + if not characterId then + return false + end + + local canUnlock = XDataCenter.CharacterManager:CanCharacterUnlock(characterId) + return canUnlock +end + +return XRedPointConditionCharacterUnlock \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionChessPursuitReward.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionChessPursuitReward.lua new file mode 100644 index 00000000..cca128c2 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionChessPursuitReward.lua @@ -0,0 +1,16 @@ +local XRedPointConditionChessPursuitReward = {} +local Events = nil +--追击玩法有奖励可以领取 +function XRedPointConditionChessPursuitReward.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_CHESSPURSUIT_MAP_UPDATE) + } + return Events +end + +function XRedPointConditionChessPursuitReward.Check() + return XDataCenter.ChessPursuitManager.IsCanTakeReward() +end + +return XRedPointConditionChessPursuitReward \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionChristmasTree.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionChristmasTree.lua new file mode 100644 index 00000000..a6a6460c --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionChristmasTree.lua @@ -0,0 +1,31 @@ +---------------------------------------------------------------- +--圣诞小游戏相关红点 +local XRedPointConditionChristmasTree = {} +local SubCondition = nil +function XRedPointConditionChristmasTree.GetSubConditions() + SubCondition = SubCondition or + { + XRedPointConditions.Types.CONDITION_CHRISTMAS_TREE_ORNAMENT_READ, + XRedPointConditions.Types.CONDITION_CHRISTMAS_TREE_ORNAMENT_ACTIVE, + XRedPointConditions.Types.CONDITION_CHRISTMAS_TREE_AWARD, + } + return SubCondition +end + +function XRedPointConditionChristmasTree.Check() + if XRedPointConditionChristmasTreeOrnamentActive.Check() then + return true + end + + if XRedPointConditionChristmasTreeAward.Check() then + return true + end + + if XRedPointConditionChristmasTreeOrnamentRead.Check() then + return true + end + + return false +end + +return XRedPointConditionChristmasTree \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionChristmasTreeAward.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionChristmasTreeAward.lua new file mode 100644 index 00000000..2c4e5557 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionChristmasTreeAward.lua @@ -0,0 +1,17 @@ +---------------------------------------------------------------- +-- 圣诞树装饰小游戏 领取奖励红点 +local XRedPointConditionChristmasTreeAward = {} +local Events = nil +function XRedPointConditionChristmasTreeAward.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_CHRISTMAS_TREE_GOT_REWARD), + } + return Events +end + +function XRedPointConditionChristmasTreeAward.Check() + return XDataCenter.ChristmasTreeManager.HasTaskReward() +end + +return XRedPointConditionChristmasTreeAward \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionChristmasTreeOrnamentActive.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionChristmasTreeOrnamentActive.lua new file mode 100644 index 00000000..e6a4157b --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionChristmasTreeOrnamentActive.lua @@ -0,0 +1,17 @@ +---------------------------------------------------------------- +-- 圣诞树装饰小游戏 兑换饰品红点 +local XRedPointConditionChristmasTreeOrnamentActive = {} +local Events = nil +function XRedPointConditionChristmasTreeOrnamentActive.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_CHRISTMAS_TREE_ORNAMENT_ACTIVE), + } + return Events +end + +function XRedPointConditionChristmasTreeOrnamentActive.Check() + return XDataCenter.ChristmasTreeManager.CheckCanGetOrnament() +end + +return XRedPointConditionChristmasTreeOrnamentActive \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionChristmasTreeOrnamentRead.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionChristmasTreeOrnamentRead.lua new file mode 100644 index 00000000..d22396de --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionChristmasTreeOrnamentRead.lua @@ -0,0 +1,17 @@ +---------------------------------------------------------------- +-- 圣诞树装饰小游戏 饰品未查看红点 +local XRedPointConditionChristmasTreeOrnamentRead = {} +local Events = nil +function XRedPointConditionChristmasTreeOrnamentRead.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_CHRISTMAS_TREE_ORNAMENT_READ), + } + return Events +end + +function XRedPointConditionChristmasTreeOrnamentRead.Check() + return XDataCenter.ChristmasTreeManager.CheckOrnamentGrpUnread() +end + +return XRedPointConditionChristmasTreeOrnamentRead \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionClickClearDifficultUnlock.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionClickClearDifficultUnlock.lua new file mode 100644 index 00000000..24d97e55 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionClickClearDifficultUnlock.lua @@ -0,0 +1,17 @@ +---------------------------------------------------------------- +--点消小游戏普通关卡解锁检测 +local XRedPointConditionClickClearDifficultUnlock = {} +local Events = nil +function XRedPointConditionClickClearDifficultUnlock.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_CLICKCLEARGAME_FINISHED_GAME), + } + return Events +end + +function XRedPointConditionClickClearDifficultUnlock.Check(difficulty) + return XDataCenter.XClickClearGameManager.CheckDifficultyRedPoint(difficulty) +end + +return XRedPointConditionClickClearDifficultUnlock \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionClickClearReward.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionClickClearReward.lua new file mode 100644 index 00000000..1fed1270 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionClickClearReward.lua @@ -0,0 +1,18 @@ +---------------------------------------------------------------- +--点消小游戏奖励 +local XRedPointConditionClickClearReward = {} +local Events = nil +function XRedPointConditionClickClearReward.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_CLICKCLEARGAME_FINISHED_GAME), + XRedPointEventElement.New(XEventId.EVENT_CLICKCLEARGAME_TAKED_REWARD), + } + return Events +end + +function XRedPointConditionClickClearReward.Check() + return XDataCenter.XClickClearGameManager.CheckRewardRedPoint() +end + +return XRedPointConditionClickClearReward \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionCoupleCombatHard.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionCoupleCombatHard.lua new file mode 100644 index 00000000..5072f368 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionCoupleCombatHard.lua @@ -0,0 +1,25 @@ +---------------------------------------------------------------- +-- +local XRedPointConditionCoupleCombatHard = {} +local Events = nil +function XRedPointConditionCoupleCombatHard.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_FUBEN_COUPLECOMBAT_UPDATE), + } + return Events +end + +function XRedPointConditionCoupleCombatHard.Check() + if XDataCenter.FubenCoupleCombatManager.GetIsActivityEnd() then return false end + if not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.FubenCoupleCombat) then return false end + local type = XFubenCoupleCombatConfig.StageType.Hard + if XDataCenter.FubenCoupleCombatManager.CheckNewStage(type) or + XDataCenter.TaskManager.GetIsRewardForEx(TaskType.CoupleCombat, type) then + return true + end + + return false +end + +return XRedPointConditionCoupleCombatHard \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionCoupleCombatNormal.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionCoupleCombatNormal.lua new file mode 100644 index 00000000..fe2bba20 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionCoupleCombatNormal.lua @@ -0,0 +1,25 @@ +---------------------------------------------------------------- +-- +local XRedPointConditionCoupleCombatNormal = {} +local Events = nil +function XRedPointConditionCoupleCombatNormal.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_FUBEN_COUPLECOMBAT_UPDATE), + } + return Events +end + +function XRedPointConditionCoupleCombatNormal.Check() + if XDataCenter.FubenCoupleCombatManager.GetIsActivityEnd() then return false end + if not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.FubenCoupleCombat) then return false end + local type = XFubenCoupleCombatConfig.StageType.Normal + if XDataCenter.FubenCoupleCombatManager.CheckNewStage(type) or + XDataCenter.TaskManager.GetIsRewardForEx(TaskType.CoupleCombat, type) then + return true + end + + return false +end + +return XRedPointConditionCoupleCombatNormal \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionCoupletGamePlayVideo.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionCoupletGamePlayVideo.lua new file mode 100644 index 00000000..5722aadb --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionCoupletGamePlayVideo.lua @@ -0,0 +1,17 @@ +-- 春节对联小游戏奖励红点 +local XRedPointConditionCoupletGamePlayVideo = {} +local Events = nil +function XRedPointConditionCoupletGamePlayVideo.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_COUPLET_GAME_COMPLETE), + XRedPointEventElement.New(XEventId.EVENT_COUPLET_GAME_PLAYED_VIDEO), + } + return Events +end + +function XRedPointConditionCoupletGamePlayVideo.Check() + return XDataCenter.CoupletGameManager.CheckHasNoPlayVideo() +end + +return XRedPointConditionCoupletGamePlayVideo \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionCoupletGameRed.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionCoupletGameRed.lua new file mode 100644 index 00000000..a1b3853d --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionCoupletGameRed.lua @@ -0,0 +1,39 @@ +---------------------------------------------------------------- +--春节对联小游戏入口 +local XRedPointConditionCoupletGameRed = {} +local SubCondition = nil +local Events = nil +function XRedPointConditionCoupletGameRed.GetSubConditions() + SubCondition = SubCondition or + { + XRedPointConditions.Types.CONDITION_COUPLET_GAME_REWARD_TASK, + XRedPointConditions.Types.CONDITION_COUPLET_GAME_PLAY_VIDEO, + } + return SubCondition +end + +function XRedPointConditionCoupletGameRed.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_ITEM_COUNT_UPDATE_PREFIX), + } + return Events +end + +function XRedPointConditionCoupletGameRed.Check() + if XDataCenter.CoupletGameManager.CheckCanExchangeWord() then + return true + end + + if XRedPointConditionCoupletGameRewardTask.Check() then + return true + end + + if XRedPointConditionCoupletGamePlayVideo.Check() then + return true + end + + return false +end + +return XRedPointConditionCoupletGameRed \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionCoupletGameRewardTask.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionCoupletGameRewardTask.lua new file mode 100644 index 00000000..bb790f15 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionCoupletGameRewardTask.lua @@ -0,0 +1,17 @@ +-- 春节对联小游戏奖励红点 +local XRedPointConditionCoupletGameRewardTask = {} +local Events = nil +function XRedPointConditionCoupletGameRewardTask.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_COUPLET_GAME_COMPLETE), + XRedPointEventElement.New(XEventId.EVENT_COUPLET_GAME_FINISH_TASK), + } + return Events +end + +function XRedPointConditionCoupletGameRewardTask.Check() + return XDataCenter.CoupletGameManager.CheckRewardTaskRedPoint() +end + +return XRedPointConditionCoupletGameRewardTask \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionDefault.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionDefault.lua new file mode 100644 index 00000000..27f9131e --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionDefault.lua @@ -0,0 +1,11 @@ +-- 红点条件检测器 +--默认 +local XRedPointConditionDefault = {} +XRedPointConditionDefault.__index = XRedPointConditionDefault + +--检测 +function XRedPointConditionDefault.Check() + return false +end + +return XRedPointConditionDefault \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionDormMainTaskRed.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionDormMainTaskRed.lua new file mode 100644 index 00000000..73d08f95 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionDormMainTaskRed.lua @@ -0,0 +1,21 @@ +---------------------------------------------------------------- +--单个类型任务奖励检测 +local XRedPointConditionDormMainTaskRed = {} +local Events = nil +function XRedPointConditionDormMainTaskRed.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_TASK_SYNC), + XRedPointEventElement.New(XEventId.EVENT_FUNCTION_OPEN_COMPLETE), + } + return Events +end + +function XRedPointConditionDormMainTaskRed.Check() + local dormNormal = XDataCenter.TaskManager.TaskType.DormNormal + local dormDaily = XDataCenter.TaskManager.TaskType.DormDaily + local red = XDataCenter.TaskManager.GetIsRewardForEx(dormNormal) or XDataCenter.TaskManager.GetIsRewardForEx(dormDaily) + return red +end + +return XRedPointConditionDormMainTaskRed \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionDormRed.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionDormRed.lua new file mode 100644 index 00000000..411c9d7f --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionDormRed.lua @@ -0,0 +1,34 @@ +---------------------------------------------------------------- +local XRedPointConditionDormRed = {} +local SubCondition = nil +function XRedPointConditionDormRed.GetSubConditions() + SubCondition = + SubCondition or + { + XRedPointConditions.Types.CONDITION_DORM_TASK, + XRedPointConditions.Types.CONDITION_DORM_WORK_RED, + XRedPointConditions.Types.CONDITION_FURNITURE_CREATE, + } + return SubCondition +end + + +function XRedPointConditionDormRed.Check() + local red = XRedPointConditionDormWork.Check() + if red then + return true + end + + red = XRedPointConditionFurnitureCreate.Check() + if red then + return true + end + red = XRedPointConditionDormTaskType.Check(XDataCenter.TaskManager.TaskType.DormNormal) + or XRedPointConditionDormTaskType.Check(XDataCenter.TaskManager.TaskType.DormDaily) + if red then + return true + end + return false +end + +return XRedPointConditionDormRed diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionDormTaskType.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionDormTaskType.lua new file mode 100644 index 00000000..1c6d4e6d --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionDormTaskType.lua @@ -0,0 +1,18 @@ +---------------------------------------------------------------- +--单个类型任务奖励检测 +local XRedPointConditionDormTaskType = {} +local Events = nil +function XRedPointConditionDormTaskType.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_TASK_SYNC), + XRedPointEventElement.New(XEventId.EVENT_FUNCTION_OPEN_COMPLETE), + } + return Events +end + +function XRedPointConditionDormTaskType.Check(taskType) + return XDataCenter.TaskManager.GetIsRewardForEx(taskType) +end + +return XRedPointConditionDormTaskType \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionDormWork.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionDormWork.lua new file mode 100644 index 00000000..b86faa4a --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionDormWork.lua @@ -0,0 +1,16 @@ +---------------------------------------------------------------- +local XRedPointConditionDormWork = {} +local Events = nil +function XRedPointConditionDormWork.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_DORM_WORK_REDARD), + } + return Events +end + +function XRedPointConditionDormWork.Check() + return XDataCenter.DormManager.DormWorkRedFun() +end + +return XRedPointConditionDormWork \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionDragPuzzleAward.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionDragPuzzleAward.lua new file mode 100644 index 00000000..86211c61 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionDragPuzzleAward.lua @@ -0,0 +1,19 @@ +---------------------------------------------------------------- +--预热关拼图小游戏有可领取奖励红点 +local XRedPointConditionDragPuzzleAward = {} +local Events = nil +function XRedPointConditionDragPuzzleAward.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_DRAG_PUZZLE_GAME_PUZZLE_CHANGED), + XRedPointEventElement.New(XEventId.EVENT_DRAG_PUZZLE_GAME_PUZZLE_COMPLETE), + XRedPointEventElement.New(XEventId.EVENT_DRAG_PUZZLE_GAME_GOT_REWARD), + } + return Events +end + +function XRedPointConditionDragPuzzleAward.Check() + return XDataCenter.FubenActivityPuzzleManager.CheckAwardRedPoint() +end + +return XRedPointConditionDragPuzzleAward \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionDragPuzzleDecryption.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionDragPuzzleDecryption.lua new file mode 100644 index 00000000..edb2dd68 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionDragPuzzleDecryption.lua @@ -0,0 +1,18 @@ +---------------------------------------------------------------- +--预热关拼图小游戏解密面板特效 +local XRedPointConditionDragPuzzleDecryption = {} +local Events = nil +function XRedPointConditionDragPuzzleDecryption.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_DRAG_PUZZLE_GAME_PUZZLE_DECRYPTION), + XRedPointEventElement.New(XEventId.EVENT_DRAG_PUZZLE_GAME_PUZZLE_COMPLETE), + } + return Events +end + +function XRedPointConditionDragPuzzleDecryption.Check(puzzleId) + return XDataCenter.FubenActivityPuzzleManager.CheckDecryptionRedPoint(puzzleId) +end + +return XRedPointConditionDragPuzzleDecryption \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionDragPuzzleSwitch.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionDragPuzzleSwitch.lua new file mode 100644 index 00000000..750ce3e5 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionDragPuzzleSwitch.lua @@ -0,0 +1,17 @@ +---------------------------------------------------------------- +--预热关拼图小游戏碎片转化红点 +local XRedPointConditionDragPuzzleSwitch = {} +local Events = nil +function XRedPointConditionDragPuzzleSwitch.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_DRAG_PUZZLE_GAME_GET_PIECE), + } + return Events +end + +function XRedPointConditionDragPuzzleSwitch.Check() + return XDataCenter.FubenActivityPuzzleManager.CheckSwitchRedPoint() +end + +return XRedPointConditionDragPuzzleSwitch \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionDragPuzzleTab.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionDragPuzzleTab.lua new file mode 100644 index 00000000..17de7950 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionDragPuzzleTab.lua @@ -0,0 +1,21 @@ +---------------------------------------------------------------- +--预热关拼图小游戏关卡标题红点 +local XRedPointConditionDragPuzzleTab = {} +local Events = nil +function XRedPointConditionDragPuzzleTab.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_DRAG_PUZZLE_GAME_PUZZLE_CHANGED), + XRedPointEventElement.New(XEventId.EVENT_DRAG_PUZZLE_GAME_PUZZLE_COMPLETE), + XRedPointEventElement.New(XEventId.EVENT_DRAG_PUZZLE_GAME_GOT_REWARD), + XRedPointEventElement.New(XEventId.EVENT_DRAG_PUZZLE_GAME_PLAYED_VIDEO), + XRedPointEventElement.New(XEventId.EVENT_DRAG_PUZZLE_GAME_GET_PIECE), + } + return Events +end + +function XRedPointConditionDragPuzzleTab.Check(index) + return XDataCenter.FubenActivityPuzzleManager.CheckTabRedPointByIndex(index) +end + +return XRedPointConditionDragPuzzleTab \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionDragPuzzleVideo.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionDragPuzzleVideo.lua new file mode 100644 index 00000000..0328aeb4 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionDragPuzzleVideo.lua @@ -0,0 +1,18 @@ +---------------------------------------------------------------- +--预热关拼图小游戏有未观看剧情红点 +local XRedPointConditionDragPuzzleVideo = {} +local Events = nil +function XRedPointConditionDragPuzzleVideo.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_DRAG_PUZZLE_GAME_PLAYED_VIDEO), + XRedPointEventElement.New(XEventId.EVENT_DRAG_PUZZLE_GAME_GOT_REWARD), + } + return Events +end + +function XRedPointConditionDragPuzzleVideo.Check(puzzleId) + return XDataCenter.FubenActivityPuzzleManager.CheckVideoRedPoint(puzzleId) +end + +return XRedPointConditionDragPuzzleVideo \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionExhibitionNew.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionExhibitionNew.lua new file mode 100644 index 00000000..6fd324f2 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionExhibitionNew.lua @@ -0,0 +1,22 @@ +---------------------------------------------------------------- +-- 构造体展示厅奖励领取检测 +local XRedPointConditionExhibitionNew = {} + +local Events = nil +function XRedPointConditionExhibitionNew.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_CHARACTER_EXHIBITION_REFRESH), + } + return Events +end + +function XRedPointConditionExhibitionNew.Check(characterId) + if XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.CharacterExhibition) then + return false + end + characterId = type(characterId) == "table" and characterId[1] or characterId + return XDataCenter.ExhibitionManager.CheckNewCharacterReward(characterId) +end + +return XRedPointConditionExhibitionNew \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionExpeditionRecruit.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionExpeditionRecruit.lua new file mode 100644 index 00000000..6a501159 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionExpeditionRecruit.lua @@ -0,0 +1,30 @@ +local XRedPointConditionExpeditionRecruit = {} +local Events = nil +--虚像地平线入口处红点(早期的类名改得不好,这里沿用) +function XRedPointConditionExpeditionRecruit.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_EXPEDITION_RECRUITTIME_REFRESH) + } + return Events +end + +function XRedPointConditionExpeditionRecruit.Check() + return XRedPointConditionExpeditionRecruit.CanGetReward() --or XDataCenter.ExpeditionManager.CheckRecruitRedPoint() +end + +function XRedPointConditionExpeditionRecruit.CanGetReward() + if XDataCenter.ExpeditionManager.GetIsChapterClear(XDataCenter.ExpeditionManager.StageDifficulty.Normal) then + if not XDataCenter.ExpeditionManager.GetIsReceivedReward(XDataCenter.ExpeditionManager.StageDifficulty.Normal) then + return true + end + end + if XDataCenter.ExpeditionManager.GetIsChapterClear(XDataCenter.ExpeditionManager.StageDifficulty.NightMare) then + if not XDataCenter.ExpeditionManager.GetIsReceivedReward(XDataCenter.ExpeditionManager.StageDifficulty.NightMare) then + return true + end + end + return false +end + +return XRedPointConditionExpeditionRecruit \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionExperimentChapterReward.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionExperimentChapterReward.lua new file mode 100644 index 00000000..7bac79da --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionExperimentChapterReward.lua @@ -0,0 +1,19 @@ +---------------------------------------------------------------- +--试玩关有可领取的奖励 +local XRedPointConditionExperimentChapterReward = {} +local Events = nil + +function XRedPointConditionExperimentChapterReward.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_UPDATE_EXPERIMENT), + XRedPointEventElement.New(XEventId.EVENT_EXPERIMENT_GET_STAR_REWARD), + } + return Events +end + +function XRedPointConditionExperimentChapterReward.Check(trialLevelInfo) + return XDataCenter.FubenExperimentManager.CheckBannerRedPoint(trialLevelInfo) +end + +return XRedPointConditionExperimentChapterReward \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionExperimentRed.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionExperimentRed.lua new file mode 100644 index 00000000..6519cbfb --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionExperimentRed.lua @@ -0,0 +1,19 @@ +---------------------------------------------------------------- +--副本界面试玩关红点条件 +local XRedPointConditionExperimentRed = {} +local Events = nil + +function XRedPointConditionExperimentRed.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_UPDATE_EXPERIMENT), + XRedPointEventElement.New(XEventId.EVENT_EXPERIMENT_GET_STAR_REWARD), + } + return Events +end + +function XRedPointConditionExperimentRed.Check() + return XDataCenter.FubenExperimentManager.CheckExperimentRedPoint() +end + +return XRedPointConditionExperimentRed \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionExplore.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionExplore.lua new file mode 100644 index 00000000..b196c405 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionExplore.lua @@ -0,0 +1,11 @@ +-- 红点条件检测器 +--默认 +local XRedPointConditionExplore = {} +XRedPointConditionExplore.__index = XRedPointConditionExplore + +--检测 +function XRedPointConditionExplore.Check() + return XDataCenter.FubenExploreManager.IsRedPoint() +end + +return XRedPointConditionExplore \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionExtra.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionExtra.lua new file mode 100644 index 00000000..956785b5 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionExtra.lua @@ -0,0 +1,54 @@ +---------------------------------------------------------------- +--番外剧情:有可挑战关卡 + +local XRedPointConditionExtra = {} +local Events = nil +function XRedPointConditionExtra.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_FUBEN_STAGE_SYNC), + } + return Events +end + +function XRedPointConditionExtra.Check(args) + local isOpen = XActivityBrieIsOpen.Get(args.activityGroupId, args) + if isOpen then + local mainChapter = XRedPointConditionExtra.GetMainChapter() + local chapter = XRedPointConditionExtra.GetChapterByDifficult(mainChapter, args.difficultType) + + return XRedPointConditionExtra.CheckIsNew(chapter) + else + return false + end +end + +function XRedPointConditionExtra.GetChapterByDifficult(mainChapter, difficult) + local chapterInfo = XDataCenter.ExtraChapterManager.GetChapterInfoForOrderId(difficult, mainChapter.OrderId) + local chapterId = XDataCenter.ExtraChapterManager.GetChapterIdByChapterExtraId(chapterInfo.ChapterMainId, difficult) + local chapter = XDataCenter.ExtraChapterManager.GetChapterDetailsCfg(chapterId) + + return chapter +end + +function XRedPointConditionExtra.CheckIsNew(chapter) + local stageIds = chapter.StageId + for i,stageId in ipairs(stageIds) do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + if stageInfo.Unlock and not stageInfo.Passed then + return true + end + end +end + +function XRedPointConditionExtra.GetMainChapter() + local config = XActivityBriefConfigs.GetActivityGroupConfig(XActivityBriefConfigs.ActivityGroupId.Extra) + local skipId = config.SkipId + local jumpData = XFunctionConfig.GetSkipList(skipId) + local chapterId = jumpData.CustomParams[1] + local mainChapter = XDataCenter.ExtraChapterManager.GetChapterDetailsCfg(chapterId) + + return mainChapter +end + +return XRedPointConditionExtra \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionExtraChapterExploreItem.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionExtraChapterExploreItem.lua new file mode 100644 index 00000000..e5ec3da5 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionExtraChapterExploreItem.lua @@ -0,0 +1,17 @@ +--番外探索道具红点 +local XRedPointConditionExtraChapterExploreItem = {} +local Events = nil + +function XRedPointConditionExtraChapterExploreItem.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_EXTRACHAPTER_EXPLORE_ITEM_GET), + XRedPointEventElement.New(XEventId.EVENT_EXTRACHAPTER_EXPLORE_ITEMBOX_CLOSE), + } + return Events +end + +function XRedPointConditionExtraChapterExploreItem.Check(chapterId) + return XDataCenter.ExtraChapterManager.CheckHaveNewExploreItemByChapterId(chapterId) +end +return XRedPointConditionExtraChapterExploreItem \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionExtraChapterReward.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionExtraChapterReward.lua new file mode 100644 index 00000000..1f323cce --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionExtraChapterReward.lua @@ -0,0 +1,31 @@ +local XRedPointConditionExtraChapterReward = {} +local SubCondition = nil + +function XRedPointConditionExtraChapterReward.GetSubConditions() + SubCondition = SubCondition or + { + XRedPointConditions.Types.CONDITION_EXTRA_TREASURE, -- 外篇章节收集奖励 + XRedPointConditions.Types.CONDITION_ZHOUMU_TASK, -- 周目挑战任务 + } + return SubCondition +end + +function XRedPointConditionExtraChapterReward.Check(chapterId) + if XRedPointConditionExtraTreasure.Check(chapterId) then + return true + end + + local chapterInfo = XDataCenter.ExtraChapterManager.GetChapterInfo(chapterId) + local chapterMainId = (chapterInfo or {}).ChapterMainId or 0 + local zhouMuId = XFubenExtraChapterConfigs.GetZhouMuId(chapterMainId) + if zhouMuId == 0 then + return false + end + + if XRedPointConditionZhouMuTask.Check(zhouMuId) then + return true + end + + return false +end +return XRedPointConditionExtraChapterReward \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionExtraTreasure.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionExtraTreasure.lua new file mode 100644 index 00000000..cdd3d19f --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionExtraTreasure.lua @@ -0,0 +1,15 @@ +local XRedPointConditionExtraTreasure = {} +local Events = nil + +function XRedPointConditionExtraTreasure.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_FUBEN_EXTRACHAPTER_REWARD) + } + return Events +end + +function XRedPointConditionExtraTreasure.Check(chapterId) + return XDataCenter.ExtraChapterManager.CheckTreasureReward(chapterId) +end +return XRedPointConditionExtraTreasure \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFashionStoryHaveStage.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFashionStoryHaveStage.lua new file mode 100644 index 00000000..1b4f7593 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFashionStoryHaveStage.lua @@ -0,0 +1,39 @@ +local XRedPointConditionFashionStoryHaveStage = {} + +function XRedPointConditionFashionStoryHaveStage.Check(activityId) + local curActivity = activityId + if not curActivity then + local activeChapter = XDataCenter.FashionStoryManager.GetActivityChapters() + if not XTool.IsTableEmpty(activeChapter) then + -- 参数activityId为空时(主界面快捷入口的红点检测不会传入检测的activityId),默认取第一个活动的Id来检测 + -- 如果有多个活动同时开启,这里需要处理 + curActivity = activeChapter[1].Id + else + return false + end + end + + if XDataCenter.FashionStoryManager.IsActivityInTime(curActivity) then + -- 章节关是否未全部通关 + local passNum, totalNum = XDataCenter.FashionStoryManager.GetChapterProgress(curActivity) + if passNum < totalNum then + return true + end + + -- 试玩关是否有未通关关卡 + local trialList = XFashionStoryConfigs.GetTrialStagesList(curActivity) + if not XTool.IsTableEmpty(trialList) then + for _, trialId in ipairs(trialList) do + if XDataCenter.FashionStoryManager.IsTrialStageInTime(trialId) then + local isPassed = XDataCenter.FubenManager.CheckStageIsPass(trialId) + if not isPassed then + return true + end + end + end + end + end + return false +end + +return XRedPointConditionFashionStoryHaveStage \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFavorability.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFavorability.lua new file mode 100644 index 00000000..d18b888d --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFavorability.lua @@ -0,0 +1,58 @@ +---------------------------------------------------------------- +--单个邮件检测 +local XRedPointConditionFavorability = {} + +local SubCondition = nil +function XRedPointConditionFavorability.GetSubConditions() + SubCondition = SubCondition or { + XRedPointConditions.Types.CONDITION_FAVORABILITY_DOCUMENT_INFO, + XRedPointConditions.Types.CONDITION_FAVORABILITY_DOCUMENT_RUMOR, + XRedPointConditions.Types.CONDITION_FAVORABILITY_DOCUMENT_AUDIO, + XRedPointConditions.Types.CONDITION_FAVORABILITY_DOCUMENT_ACTION, + XRedPointConditions.Types.CONDITION_FAVORABILITY_PLOT, + XRedPointConditions.Types.CONDITION_FAVORABILITY_GIFT, + } + return SubCondition +end + +function XRedPointConditionFavorability.Check(currCharacter) + local allCharDatas = XDataCenter.CharacterManager.GetCharacterList() + for _, v in pairs(allCharDatas or {}) do + local isOwn = XDataCenter.CharacterManager.IsOwnCharacter(v.Id) + local isCurrCharacter = (v.Id == currCharacter.CharacterId) + --未拥有角色与当前选中角色的状态不计算红点 + if isOwn and not isCurrCharacter then + local args = {} + args.CharacterId = v.Id + if XRedPointConditionFavorabilityInfo.Check(args) then + return true + end + + if XRedPointConditionFavorabilityRumor.Check(args) then + return true + end + + if XRedPointConditionFavorabilityAudio.Check(args) then + return true + end + + if XRedPointConditionFavorabilityAction.Check(args) then + return true + end + + if XRedPointConditionFavorabilityPlot.Check(args) then + return true + end + + if XRedPointConditionFavorabilityGift.Check(args) then + return true + end + end + end + + return false +end + + + +return XRedPointConditionFavorability \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFavorabilityAction.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFavorabilityAction.lua new file mode 100644 index 00000000..0dc586b9 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFavorabilityAction.lua @@ -0,0 +1,22 @@ +---------------------------------------------------------------- +--资料检测:只关心依赖度等级变化,需要参数characterId,动作有变化也检查 +local XRedPointConditionFavorabilityAction = {} +local Events = nil +function XRedPointConditionFavorabilityAction.GetSubEvents() + Events = Events or { + XRedPointEventElement.New(XEventId.EVENT_FAVORABILITY_LEVELCHANGED), + XRedPointEventElement.New(XEventId.EVENT_FAVORABILITY_ACTIONUNLOCK), + } + return Events +end + +function XRedPointConditionFavorabilityAction.Check(checkArgs) + if not checkArgs then return false end + local characterId = checkArgs.CharacterId + if characterId == nil then return false end + local isOpen = XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.FavorabilityFile) + if not isOpen then return false end + return XDataCenter.FavorabilityManager.HasActionToBeUnlock(characterId) +end + +return XRedPointConditionFavorabilityAction \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFavorabilityAudio.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFavorabilityAudio.lua new file mode 100644 index 00000000..e13a1879 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFavorabilityAudio.lua @@ -0,0 +1,22 @@ +---------------------------------------------------------------- +--资料检测:只关心依赖度等级变化,需要参数characterId,语音有变化也检查 +local XRedPointConditionFavorabilityAudio = {} +local Events = nil +function XRedPointConditionFavorabilityAudio.GetSubEvents() + Events = Events or { + XRedPointEventElement.New(XEventId.EVENT_FAVORABILITY_LEVELCHANGED), + XRedPointEventElement.New(XEventId.EVENT_FAVORABILITY_AUDIOUNLOCK), + } + return Events +end + +function XRedPointConditionFavorabilityAudio.Check(checkArgs) + if not checkArgs then return false end + local characterId = checkArgs.CharacterId + if characterId == nil then return false end + local isOpen = XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.FavorabilityFile) + if not isOpen then return false end + return XDataCenter.FavorabilityManager.HasAudioToBeUnlock(characterId) +end + +return XRedPointConditionFavorabilityAudio \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFavorabilityDocument.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFavorabilityDocument.lua new file mode 100644 index 00000000..dddec473 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFavorabilityDocument.lua @@ -0,0 +1,41 @@ +---------------------------------------------------------------- +--单个邮件检测 +local XRedPointConditionFavorabilityDocument = {} + +local SubCondition = nil +function XRedPointConditionFavorabilityDocument.GetSubConditions() + SubCondition = SubCondition or { + XRedPointConditions.Types.CONDITION_FAVORABILITY_DOCUMENT_INFO , + XRedPointConditions.Types.CONDITION_FAVORABILITY_DOCUMENT_RUMOR, + XRedPointConditions.Types.CONDITION_FAVORABILITY_DOCUMENT_AUDIO, + } + return SubCondition +end + +function XRedPointConditionFavorabilityDocument.Check(checkArgs) + if XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.FavorabilityFile) then + return false + end + + if not checkArgs then return false end + local characterId = checkArgs.CharacterId + if characterId == nil then return false end + + if XRedPointConditionFavorabilityInfo.Check(checkArgs) then + return true + end + + if XRedPointConditionFavorabilityRumor.Check(checkArgs) then + return true + end + + if XRedPointConditionFavorabilityAudio.Check(checkArgs) then + return true + end + + return false +end + + + +return XRedPointConditionFavorabilityDocument \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFavorabilityGift.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFavorabilityGift.lua new file mode 100644 index 00000000..2f81f2b9 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFavorabilityGift.lua @@ -0,0 +1,29 @@ +---------------------------------------------------------------- +--好感度奖励检测,跟好感度等级,角色战斗参数,角色等级,角色品质关联,需要参数characterId +local XRedPointConditionFavorabilityGift = {} +local Events = nil +function XRedPointConditionFavorabilityGift.GetSubEvents() + Events = Events or { + XRedPointEventElement.New(XEventId.EVENT_FAVORABILITY_LEVELCHANGED), + XRedPointEventElement.New(XEventId.EVENT_FAVORABILITY_CHAR_ABILITY_CHANGED), + XRedPointEventElement.New(XEventId.EVENT_CHARACTER_LEVEL_UP), + XRedPointEventElement.New(XEventId.EVENT_CHARACTER_QUALITY_PROMOTE), + XRedPointEventElement.New(XEventId.EVENT_FAVORABILITY_COLLECTGIFT), + } + return Events +end + +function XRedPointConditionFavorabilityGift.Check(checkArgs) + if XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.FavorabilityGift) then + return false + end + + if not checkArgs then return false end + local characterId = checkArgs.CharacterId + if characterId == nil then return false end + local isOpen = XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.FavorabilityGift) + if not isOpen then return false end + return false +end + +return XRedPointConditionFavorabilityGift \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFavorabilityInfo.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFavorabilityInfo.lua new file mode 100644 index 00000000..3ad75ce5 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFavorabilityInfo.lua @@ -0,0 +1,24 @@ +---------------------------------------------------------------- +--资料检测:只关心依赖度等级变化,需要参数characterId +local XRedPointConditionFavorabilityInfo = {} +local Events = nil +function XRedPointConditionFavorabilityInfo.GetSubEvents() + Events = Events or { + XRedPointEventElement.New(XEventId.EVENT_FAVORABILITY_LEVELCHANGED), + XRedPointEventElement.New(XEventId.EVENT_FAVORABILITY_INFOUNLOCK), + } + return Events +end + +function XRedPointConditionFavorabilityInfo.Check(checkArgs) + if not checkArgs then return false end + local characterId = checkArgs.CharacterId + if characterId == nil then return false end + local isOpen = XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.FavorabilityFile) + if not isOpen then return false end + return XDataCenter.FavorabilityManager.HasDataToBeUnlock(characterId) +end + + + +return XRedPointConditionFavorabilityInfo \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFavorabilityPlot.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFavorabilityPlot.lua new file mode 100644 index 00000000..12d288c1 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFavorabilityPlot.lua @@ -0,0 +1,28 @@ +---------------------------------------------------------------- +--异闻检测:信赖度等级,需要参数characterId +local XRedPointConditionFavorabilityPlot = {} +local Events = nil +function XRedPointConditionFavorabilityPlot.GetSubEvents() + Events = Events or { + XRedPointEventElement.New(XEventId.EVENT_FAVORABILITY_LEVELCHANGED), + XRedPointEventElement.New(XEventId.EVENT_FAVORABILITY_PLOTUNLOCK), + } + return Events +end + +function XRedPointConditionFavorabilityPlot.Check(checkArgs) + if XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.FavorabilityStory) then + return false + end + + if not checkArgs then return false end + local characterId = checkArgs.CharacterId + if characterId == nil then return false end + local isOpen = XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.FavorabilityStory) + if not isOpen then return false end + return XDataCenter.FavorabilityManager.HasStroyToBeUnlock(characterId) +end + + + +return XRedPointConditionFavorabilityPlot \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFavorabilityRumor.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFavorabilityRumor.lua new file mode 100644 index 00000000..e6c10c59 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFavorabilityRumor.lua @@ -0,0 +1,22 @@ +---------------------------------------------------------------- +--异闻检测:两种条件:信赖度等级以及宿舍事件,宿舍事件暂时还没有,需要参数characterId +local XRedPointConditionFavorabilityRumor = {} +local Events = nil +function XRedPointConditionFavorabilityRumor.GetSubEvents() + Events = Events or { + XRedPointEventElement.New(XEventId.EVENT_FAVORABILITY_LEVELCHANGED), + XRedPointEventElement.New(XEventId.EVENT_FAVORABILITY_RUMERUNLOCK), + } + return Events +end + +function XRedPointConditionFavorabilityRumor.Check(checkArgs) + if not checkArgs then return false end + local characterId = checkArgs.CharacterId + if characterId == nil then return false end + local isOpen = XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.FavorabilityFile) + if not isOpen then return false end + return XDataCenter.FavorabilityManager.HasRumorsToBeUnlock(characterId) +end + +return XRedPointConditionFavorabilityRumor \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFingerGuessingTaskRed.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFingerGuessingTaskRed.lua new file mode 100644 index 00000000..cd691e99 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFingerGuessingTaskRed.lua @@ -0,0 +1,15 @@ +--猜拳小游戏活动有未领取任务时的红点 +local XRedPointConditionFingerGuessingTaskRed = {} +local Events = nil +function XRedPointConditionFingerGuessingTaskRed.GetSubEvents() + Events = Events or { + XRedPointEventElement.New(XEventId.EVENT_TASK_SYNC) + } + return Events +end + +function XRedPointConditionFingerGuessingTaskRed.Check() + return XDataCenter.TaskManager.GetFingerGuessingHaveAchievedTask() +end + +return XRedPointConditionFingerGuessingTaskRed \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFireworks.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFireworks.lua new file mode 100644 index 00000000..c32f32e1 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFireworks.lua @@ -0,0 +1,18 @@ +---------------------------------------------------------------- +--节红点检测 +local XRedPointConditionFireworks = {} +local Events = nil + +function XRedPointConditionFireworks.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_CARD_REFRESH_WELFARE_BTN), + } + return Events +end + +function XRedPointConditionFireworks.Check() + return XDataCenter.FireworksManager.HasRedDot() +end + +return XRedPointConditionFireworks \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFriendChatPrivate.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFriendChatPrivate.lua new file mode 100644 index 00000000..56454aed --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFriendChatPrivate.lua @@ -0,0 +1,22 @@ +---------------------------------------------------------------- +--好友联系红点检测 +local XRedPointConditionFriendChatPrivate = {} +local Events = nil +function XRedPointConditionFriendChatPrivate.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_CHAT_RECEIVE_PRIVATECHAT), + XRedPointEventElement.New(XEventId.EVENT_CHAT_MSG_SYNC), + } + return Events +end + +function XRedPointConditionFriendChatPrivate.Check(friendId) + if not friendId then + return false + end + + return XDataCenter.ChatManager.GetPrivateUnreadChatCountByFriendId(friendId) +end + +return XRedPointConditionFriendChatPrivate \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFriendContact.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFriendContact.lua new file mode 100644 index 00000000..cb77cf22 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFriendContact.lua @@ -0,0 +1,19 @@ +---------------------------------------------------------------- +--好友联系红点检测 +local XRedPointConditionFriendContact = {} +local Events = nil +function XRedPointConditionFriendContact.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_FRIEND_READ_PRIVATE_MSG), + XRedPointEventElement.New(XEventId.EVENT_FRIEND_DELETE), + XRedPointEventElement.New(XEventId.EVENT_CHAT_RECEIVE_PRIVATECHAT), + } + return Events +end + +function XRedPointConditionFriendContact.Check() + return XDataCenter.ChatManager.GetAllPrivateChatMsgCount() +end + +return XRedPointConditionFriendContact \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFriendWaitPass.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFriendWaitPass.lua new file mode 100644 index 00000000..49c075ca --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFriendWaitPass.lua @@ -0,0 +1,17 @@ +---------------------------------------------------------------- +--角色晋升红点检测 +local XRedPointConditionFriendWaitPass = {} +local Events = nil +function XRedPointConditionFriendWaitPass.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_FRIEND_WAITING_PASS), + } + return Events +end + +function XRedPointConditionFriendWaitPass.Check() + return XDataCenter.SocialManager.HasFriendApplyWaitPass() +end + +return XRedPointConditionFriendWaitPass \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFuBenClickClearGameRed.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFuBenClickClearGameRed.lua new file mode 100644 index 00000000..99ec9a05 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFuBenClickClearGameRed.lua @@ -0,0 +1,22 @@ +---------------------------------------------------------------- +--中元节副本点消小游戏入口 +local XRedPointConditionFuBenClickClearGameRed = {} +local SubCondition = nil +function XRedPointConditionFuBenClickClearGameRed.GetSubConditions() + SubCondition = SubCondition or + { + XRedPointConditions.Types.CONDITION_CLICKCLEARGAME_REWARD, + } + return SubCondition +end + +function XRedPointConditionFuBenClickClearGameRed.Check() + local f = XRedPointConditionClickClearReward.Check() + if f then + return true + end + + return false +end + +return XRedPointConditionFuBenClickClearGameRed \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFuBenDragPuzzleGameRed.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFuBenDragPuzzleGameRed.lua new file mode 100644 index 00000000..0c1ecf40 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFuBenDragPuzzleGameRed.lua @@ -0,0 +1,36 @@ +---------------------------------------------------------------- +--预热关拼图小游戏入口 +local XRedPointConditionFuBenDragPuzzleGameRed = {} +local SubCondition = nil +function XRedPointConditionFuBenDragPuzzleGameRed.GetSubConditions() + SubCondition = SubCondition or + { + XRedPointConditions.Types.CONDITION_DRAG_PUZZLE_GAME_SWITCH, + XRedPointConditions.Types.CONDITION_DRAG_PUZZLE_GAME_AWARD, + XRedPointConditions.Types.CONDITION_DRAG_PUZZLE_GAME_VIDEO, + XRedPointConditions.Types.CONDITION_DRAG_PUZZLE_GAME_DECRYPTION, + } + return SubCondition +end + +function XRedPointConditionFuBenDragPuzzleGameRed.Check() + if XRedPointConditionDragPuzzleSwitch.Check() then + return true + end + + if XRedPointConditionDragPuzzleAward.Check() then + return true + end + + if XDataCenter.FubenActivityPuzzleManager.CheckAllVideoRedPoint() then + return true + end + + if XDataCenter.FubenActivityPuzzleManager.CheckAllPuzzleDecryptionRedPoint() then + return true + end + + return false +end + +return XRedPointConditionFuBenDragPuzzleGameRed \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFubenDailyShop.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFubenDailyShop.lua new file mode 100644 index 00000000..71e66b3b --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFubenDailyShop.lua @@ -0,0 +1,15 @@ +local XRedPointConditionFubenDailyShop = {} +local Events = nil + +function XRedPointConditionFubenDailyShop.GetSubEvents() + Events = Events or { + XRedPointEventElement.New(XEventId.EVENT_FUBEN_DAILY_SHOP_CHECK_NEW), + } + return Events +end + +function XRedPointConditionFubenDailyShop.Check(shopItemList) + return XShopManager.CheckDailyShopHasNewSuit(shopItemList) +end + +return XRedPointConditionFubenDailyShop \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFubenHackBuff.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFubenHackBuff.lua new file mode 100644 index 00000000..36258f1f --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFubenHackBuff.lua @@ -0,0 +1,20 @@ +---------------------------------------------------------------- +-- +local XRedPointConditionFubenHackBuff = {} +local Events = nil +function XRedPointConditionFubenHackBuff.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_FUBEN_HACK_UPDATE), + } + return Events +end + +function XRedPointConditionFubenHackBuff.Check() + if XDataCenter.FubenHackManager.GetIsActivityEnd() then return false end + if XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.FubenHack) then + return XDataCenter.FubenHackManager.CheckAffixRedPoint() + end +end + +return XRedPointConditionFubenHackBuff \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFubenHackStar.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFubenHackStar.lua new file mode 100644 index 00000000..2dd342b3 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFubenHackStar.lua @@ -0,0 +1,20 @@ +---------------------------------------------------------------- +-- +local XRedPointConditionFubenHackStar = {} +local Events = nil +function XRedPointConditionFubenHackStar.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_FUBEN_HACK_UPDATE), + } + return Events +end + +function XRedPointConditionFubenHackStar.Check() + if XDataCenter.FubenHackManager.GetIsActivityEnd() then return false end + + local _, canGet = XDataCenter.FubenHackManager.GetStarRewardList() + return canGet +end + +return XRedPointConditionFubenHackStar \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFurnitureCreate.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFurnitureCreate.lua new file mode 100644 index 00000000..e674b52d --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionFurnitureCreate.lua @@ -0,0 +1,17 @@ +--家具建造红点 +local XRedPointConditionFurnitureCreate = {} +local Events = nil +function XRedPointConditionFurnitureCreate.GetSubEvents() + Events = + Events or + { + XRedPointEventElement.New(XEventId.EVENT_FURNITURE_CREATE_CHANGED), + } + return Events +end + +function XRedPointConditionFurnitureCreate.Check() + return XDataCenter.FurnitureManager.HasCollectableFurniture() +end + +return XRedPointConditionFurnitureCreate diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionGetCard.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionGetCard.lua new file mode 100644 index 00000000..4274eba8 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionGetCard.lua @@ -0,0 +1,28 @@ +---------------------------------------------------------------- +-- 月卡奖励领取 +local XRedPointConditionGetCard = {} +local Events = nil +function XRedPointConditionGetCard.GetSubEvents() + Events = Events or { + XRedPointEventElement.New(XEventId.EVENT_YK_UPDATE), + } + return Events +end + +function XRedPointConditionGetCard.Check() + local cardList = XSignInConfigs.GetSignCardConfigs() + local isCanGotCard = false + for _,v in pairs(cardList) do + local uiType = v.Param[1] + local id = v.Param[2] + if uiType and id then + isCanGotCard = not XDataCenter.PayManager.IsGotCard(uiType, id) + end + if isCanGotCard then + return isCanGotCard + end + end + return isCanGotCard +end + +return XRedPointConditionGetCard \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionGetFirstRecharge.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionGetFirstRecharge.lua new file mode 100644 index 00000000..f86c6c97 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionGetFirstRecharge.lua @@ -0,0 +1,9 @@ +---------------------------------------------------------------- +-- 首充奖励领取 +local XRedPointConditionGetFirstRecharge = {} + +function XRedPointConditionGetFirstRecharge.Check() + return not XDataCenter.PayManager.IsGotFirstReCharge() +end + +return XRedPointConditionGetFirstRecharge \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionGuardCampRed.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionGuardCampRed.lua new file mode 100644 index 00000000..683e2f8d --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionGuardCampRed.lua @@ -0,0 +1,19 @@ + +local XRedPointConditionGuardCampRed = {} +local Events = nil +function XRedPointConditionGuardCampRed.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_GUARD_CAMP_ACTIVITY_DATA_CHANGE), + } + return Events +end + +function XRedPointConditionGuardCampRed.Check() + if XDataCenter.GuardCampManager.CheckRedPoint() then + return true + end + return false +end + +return XRedPointConditionGuardCampRed \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionGuildActiveGift.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionGuildActiveGift.lua new file mode 100644 index 00000000..d42015d7 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionGuildActiveGift.lua @@ -0,0 +1,30 @@ + +local XRedPointConditionGuildActiveGift = {} +local Events = nil +function XRedPointConditionGuildActiveGift.GetSubEvents() + Events = Events or { + XRedPointEventElement.New(XEventId.EVENT_GUILD_GIFT_CONTRIBUTE_CHANGED), + } + return Events +end + + +function XRedPointConditionGuildActiveGift.Check() + if not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.Guild) then + return false + end + + -- 礼包红点 + local giftGuildLevel = XDataCenter.GuildManager.GetGiftGuildLevel() + local allGifts = XGuildConfig.GetGuildGiftByGuildLevel(giftGuildLevel) + + for _, v in pairs(allGifts or {}) do + if XDataCenter.GuildManager.CanCollectGift(v.GiftLevel) then + return true + end + end + + return false +end + +return XRedPointConditionGuildActiveGift \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionGuildApplyList.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionGuildApplyList.lua new file mode 100644 index 00000000..97df5d9c --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionGuildApplyList.lua @@ -0,0 +1,25 @@ + +local XRedPointConditionGuildApplyList = {} +local Events = nil +function XRedPointConditionGuildApplyList.GetSubEvents() + Events = Events or { + XRedPointEventElement.New(XEventId.EVENT_GUILD_APPLY_LIST_CHANGED), + XRedPointEventElement.New(XEventId.EVENT_GUILD_RANKLEVEL_CHANGED), + } + return Events +end + +function XRedPointConditionGuildApplyList.Check() + -- 招募红点 + if not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.Guild) then + return false + end + + if XDataCenter.GuildManager.GetHasApplyMemberList() then + return true + end + return false +end + + +return XRedPointConditionGuildApplyList \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionGuildBoss.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionGuildBoss.lua new file mode 100644 index 00000000..127fdeac --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionGuildBoss.lua @@ -0,0 +1,27 @@ + +local XRedPointConditionGuildBoss = {} + +local SubCondition = nil +function XRedPointConditionGuildBoss.GetSubConditions() + SubCondition = SubCondition or { + XRedPointConditions.Types.CONDITION_GUILDBOSS_BOSSHP, + XRedPointConditions.Types.CONDITION_GUILDBOSS_SCORE, + } + return SubCondition +end + +function XRedPointConditionGuildBoss.Check() + if XRedPointConditionGuildBossHp.Check() then + return true + end + + if XRedPointConditionGuildBossScore.Check() then + return true + end + + return false +end + + + +return XRedPointConditionGuildBoss \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionGuildBossHp.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionGuildBossHp.lua new file mode 100644 index 00000000..65cfb74b --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionGuildBossHp.lua @@ -0,0 +1,22 @@ +local XRedPointConditionGuildBossHp = {} +local Events = nil + +function XRedPointConditionGuildBossHp.GetSubEvents() + Events = Events or { + XRedPointEventElement.New(XEventId.EVENT_GUILDBOSS_HPBOX_CHANGED), + } + return Events +end + +function XRedPointConditionGuildBossHp.Check() + if not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.GuildBoss) then + return false + end + + if XDataCenter.GuildBossManager.IsBossHpReward() then + return true + end + return false +end + +return XRedPointConditionGuildBossHp \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionGuildBossScore.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionGuildBossScore.lua new file mode 100644 index 00000000..5b04f207 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionGuildBossScore.lua @@ -0,0 +1,18 @@ +local XRedPointConditionGuildBossScore = {} +local Events = nil + +function XRedPointConditionGuildBossScore.GetSubEvents() + Events = Events or { + XRedPointEventElement.New(XEventId.EVENT_GUILDBOSS_SCOREBOX_CHANGED), + } + return Events +end + +function XRedPointConditionGuildBossScore.Check() + if XDataCenter.GuildBossManager.IsScoreReward() then + return true + end + return false +end + +return XRedPointConditionGuildBossScore \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionGuildChallenge.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionGuildChallenge.lua new file mode 100644 index 00000000..b43dc9da --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionGuildChallenge.lua @@ -0,0 +1,32 @@ + +local XRedPointConditionGuildChallenge = {} + +local SubCondition = nil +function XRedPointConditionGuildChallenge.GetSubConditions() + SubCondition = SubCondition or { + XRedPointConditions.Types.CONDITION_TASK_TYPE, + } + return SubCondition +end + +function XRedPointConditionGuildChallenge.Check() + if not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.Guild) then + return false + end + + if XRedPointConditionTaskType.Check(XDataCenter.TaskManager.TaskType.GuildDaily) then + return true + end + + if XRedPointConditionTaskType.Check(XDataCenter.TaskManager.TaskType.GuildMainly) then + return true + end + + if XRedPointConditionTaskType.Check(XDataCenter.TaskManager.TaskType.GuildWeekly) then + return true + end + + return false +end + +return XRedPointConditionGuildChallenge \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionGuildInformation.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionGuildInformation.lua new file mode 100644 index 00000000..0e3b57b1 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionGuildInformation.lua @@ -0,0 +1,28 @@ + +local XRedPointConditionGuildInformation = {} + +local SubCondition = nil +function XRedPointConditionGuildInformation.GetSubConditions() + SubCondition = SubCondition or { + XRedPointConditions.Types.CONDITION_GUILD_APPLYLIST, + XRedPointConditions.Types.CONDITION_GUILD_ACTIVEGIFT, + } + return SubCondition +end + +function XRedPointConditionGuildInformation.Check() + -- 礼包红点 + if XRedPointConditionGuildActiveGift.Check() then + return true + end + -- 招募红点 + if XRedPointConditionGuildApplyList.Check() then + return true + end + + return false +end + + + +return XRedPointConditionGuildInformation \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionGuildMember.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionGuildMember.lua new file mode 100644 index 00000000..ed4013c3 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionGuildMember.lua @@ -0,0 +1,22 @@ + +local XRedPointConditionGuildMember = {} +local Events = nil +function XRedPointConditionGuildMember.GetSubEvents() + Events = Events or { + XRedPointEventElement.New(XEventId.EVENT_GUILD_MEMBER_CONTRIBUTE_CONDITION), + XRedPointEventElement.New(XEventId.EVENT_GUILD_LEADER_DISSMISS), + } + return Events +end + +function XRedPointConditionGuildMember.Check() + if not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.Guild) then + return false + end + + return XDataCenter.GuildManager.CanCollectContributeReward() +end + + + +return XRedPointConditionGuildMember \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionHeadPortraitNew.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionHeadPortraitNew.lua new file mode 100644 index 00000000..ca01284f --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionHeadPortraitNew.lua @@ -0,0 +1,19 @@ +---------------------------------------------------------------- +-- 构造体展示厅奖励领取检测 +local XRedPointConditionHeadPortraitNew = {} + +local Events = nil +function XRedPointConditionHeadPortraitNew.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_HEAD_PORTRAIT_NOTIFY), + XRedPointEventElement.New(XEventId.EVENT_HEAD_PORTRAIT_RESETINFO), + } + return Events +end + +function XRedPointConditionHeadPortraitNew.Check() + return XDataCenter.HeadPortraitManager.CheckIsNewHeadPortrait() +end + +return XRedPointConditionHeadPortraitNew \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionInvertCardGameRed.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionInvertCardGameRed.lua new file mode 100644 index 00000000..7220749e --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionInvertCardGameRed.lua @@ -0,0 +1,16 @@ +-- 翻牌小游戏入口红点 +local XRedPointConditionInvertCardGameRed = {} +local SubCondition = nil +function XRedPointConditionInvertCardGameRed.GetSubConditions() + SubCondition = SubCondition or + { + XRedPointConditions.Types.CONDITION_INVERTCARDGAME_TOG, + } + return SubCondition +end + +function XRedPointConditionInvertCardGameRed.Check() + return XDataCenter.InvertCardGameManager.CheckAllGameRedPoint() +end + +return XRedPointConditionInvertCardGameRed \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionInvertCardGameTog.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionInvertCardGameTog.lua new file mode 100644 index 00000000..8b871dc2 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionInvertCardGameTog.lua @@ -0,0 +1,16 @@ +local XRedPointConditionInvertCardGameTog = {} +local Events = nil +function XRedPointConditionInvertCardGameTog.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_INVERT_CARD_GAME_CARD_CHANGED), + XRedPointEventElement.New(XEventId.EVENT_INVERT_CARD_GAME_GET_REWARD), + } + return Events +end + +function XRedPointConditionInvertCardGameTog.Check(index) + return XDataCenter.InvertCardGameManager.CheckTogRedPoint(index) +end + +return XRedPointConditionInvertCardGameTog \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionKillZoneActivity.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionKillZoneActivity.lua new file mode 100644 index 00000000..9eddbdee --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionKillZoneActivity.lua @@ -0,0 +1,34 @@ +local Events = nil +local SubCondition = nil + +local XRedPointConditionKillZoneActivity = {} + +function XRedPointConditionKillZoneActivity.GetSubConditions() + SubCondition = SubCondition or { + XRedPointConditions.Types.XRedPointConditionKillZoneStarReward, + XRedPointConditions.Types.XRedPointConditionKillZoneDailyStarReward, + } + return SubCondition +end + +function XRedPointConditionKillZoneActivity.Check(chapterId) + if not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.KillZone) then + return false + end + + if not XDataCenter.KillZoneManager.IsOpen() then + return false + end + + if XDataCenter.KillZoneManager.IsAnyStarRewardCanGet() then + return true + end + + if XRedPointConditionKillZoneDailyStarReward.Check() then + return true + end + + return false +end + +return XRedPointConditionKillZoneActivity \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionKillZoneDailyStarReward.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionKillZoneDailyStarReward.lua new file mode 100644 index 00000000..64823c7a --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionKillZoneDailyStarReward.lua @@ -0,0 +1,25 @@ +local Events = nil + +local XRedPointConditionKillZoneDailyStarReward = {} + +function XRedPointConditionKillZoneDailyStarReward.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_KILLZONE_DAILYSTARREWARDINDEX_CHANGE), + } + return Events +end + +function XRedPointConditionKillZoneDailyStarReward.Check() + if not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.KillZone) then + return false + end + + if not XDataCenter.KillZoneManager.IsOpen() then + return false + end + + return not XDataCenter.KillZoneManager.IsDailyStarRewardObtained() +end + +return XRedPointConditionKillZoneDailyStarReward \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionKillZoneNewChapter.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionKillZoneNewChapter.lua new file mode 100644 index 00000000..6460f584 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionKillZoneNewChapter.lua @@ -0,0 +1,23 @@ +local Events = nil + +local XRedPointConditionKillZoneNewChapter = {} + +function XRedPointConditionKillZoneNewChapter.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_KILLZONE_NEW_CHAPTER_CHANGE), + } + return Events +end + +function XRedPointConditionKillZoneNewChapter.Check(chapterId) + if not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.KillZone) then + return false + end + + if not XDataCenter.KillZoneManager.IsOpen() then return false end + + return XDataCenter.KillZoneManager.CheckNewChapterRedPoint(chapterId) +end + +return XRedPointConditionKillZoneNewChapter \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionKillZoneNewDiff.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionKillZoneNewDiff.lua new file mode 100644 index 00000000..961af322 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionKillZoneNewDiff.lua @@ -0,0 +1,26 @@ +local Events = nil + +local XRedPointConditionKillZoneNewDiff = {} + +function XRedPointConditionKillZoneNewDiff.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_KILLZONE_NEW_DIFF_CHANGE), + } + return Events +end + +function XRedPointConditionKillZoneNewDiff.Check() + if not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.KillZone) then + return false + end + + if not XDataCenter.KillZoneManager.IsOpen() then + return false + end + + return XDataCenter.KillZoneManager.IsDiffHardUnlock() + and not XDataCenter.KillZoneManager.GetCookieNewDiffClicked() +end + +return XRedPointConditionKillZoneNewDiff \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionKillZonePluginOperate.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionKillZonePluginOperate.lua new file mode 100644 index 00000000..9ca2f684 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionKillZonePluginOperate.lua @@ -0,0 +1,27 @@ +local Events = nil + +local XRedPointConditionKillZonePluginOperate = {} + +function XRedPointConditionKillZonePluginOperate.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_ITEM_COUNT_UPDATE_PREFIX .. XKillZoneConfigs.ItemIdCoinA), + XRedPointEventElement.New(XEventId.EVENT_ITEM_COUNT_UPDATE_PREFIX .. XKillZoneConfigs.ItemIdCoinB), + XRedPointEventElement.New(XEventId.EVENT_KILLZONE_PLUGIN_OPERATE_CHANGE), + } + return Events +end + +function XRedPointConditionKillZonePluginOperate.Check() + if not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.KillZone) then + return false + end + + if not XDataCenter.KillZoneManager.IsOpen() then + return false + end + + return XDataCenter.KillZoneManager.CheckPluginsCanOperateRedPoint() +end + +return XRedPointConditionKillZonePluginOperate \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionKillZoneStarReward.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionKillZoneStarReward.lua new file mode 100644 index 00000000..20e78e15 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionKillZoneStarReward.lua @@ -0,0 +1,26 @@ +local Events = nil + +local XRedPointConditionKillZoneStarReward = {} + +function XRedPointConditionKillZoneStarReward.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_KILLZONE_STAGE_CHANGE), + XRedPointEventElement.New(XEventId.EVENT_KILLZONE_STAR_REWARD_OBTAIN_RECORD_CHANGE), + } + return Events +end + +function XRedPointConditionKillZoneStarReward.Check(diff) + if not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.KillZone) then + return false + end + + if not XDataCenter.KillZoneManager.IsOpen() then + return false + end + + return XDataCenter.KillZoneManager.IsAnyStarRewardCanGetByDiff(diff) +end + +return XRedPointConditionKillZoneStarReward \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionKoroCharActivity.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionKoroCharActivity.lua new file mode 100644 index 00000000..d5ca6f72 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionKoroCharActivity.lua @@ -0,0 +1,32 @@ +local XRedPointConditionKoroCharActivity = {} +local SubCondition = nil +function XRedPointConditionKoroCharActivity.GetSubConditions() + SubCondition = SubCondition or + { + XRedPointConditions.Types.CONDITION_KOROMCHARACTIVITYCHALLENGERED, + XRedPointConditions.Types.CONDITION_KOROMCHARACTIVITYTEACHINGRED, + } + return SubCondition +end + +function XRedPointConditionKoroCharActivity.Check() + if not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.NewCharAct) then + return false + end + + if not XDataCenter.FubenNewCharActivityManager.IsOpen() then + return false + end + + if XRedPointConditionKoroCharActivityChallenge.Check() then + return true + end + + if XRedPointConditionKoroCharActivityTeaching.Check() then + return true + end + + return false +end + +return XRedPointConditionKoroCharActivity \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionKoroCharActivityChallenge.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionKoroCharActivityChallenge.lua new file mode 100644 index 00000000..e05248aa --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionKoroCharActivityChallenge.lua @@ -0,0 +1,15 @@ +local XRedPointConditionKoroCharActivityChallenge = {} +local Events = nil +function XRedPointConditionKoroCharActivityChallenge.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_KORO_CHAR_ACTIVITY_REDPOINTEVENT), + } + return Events +end + +function XRedPointConditionKoroCharActivityChallenge.Check() + return XDataCenter.FubenNewCharActivityManager.CheckChallengeRedPoint() +end + +return XRedPointConditionKoroCharActivityChallenge \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionKoroCharActivityTeaching.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionKoroCharActivityTeaching.lua new file mode 100644 index 00000000..d539cfb5 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionKoroCharActivityTeaching.lua @@ -0,0 +1,15 @@ +local XRedPointConditionKoroCharActivityTeaching = {} +local Events = nil +function XRedPointConditionKoroCharActivityTeaching.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_KORO_CHAR_ACTIVITY_REDPOINTEVENT), + } + return Events +end + +function XRedPointConditionKoroCharActivityTeaching.Check() + return XDataCenter.FubenNewCharActivityManager.CheckTeachingRedPoint() +end + +return XRedPointConditionKoroCharActivityTeaching \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMailPersonal.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMailPersonal.lua new file mode 100644 index 00000000..bcc39c24 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMailPersonal.lua @@ -0,0 +1,21 @@ +---------------------------------------------------------------- +--单个邮件检测 +local XRedPointConditionMailPersonal = {} +local Events = nil +function XRedPointConditionMailPersonal.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_MAIL_SYNC), + XRedPointEventElement.New(XEventId.EVENT_MAIL_GET_ALL_MAIL_REWARD), + XRedPointEventElement.New(XEventId.EVENT_MAIL_DELETE), + XRedPointEventElement.New(XEventId.EVENT_MAIL_READ), + XRedPointEventElement.New(XEventId.EVENT_MAIL_GET_MAIL_REWARD), + } + return Events +end + +function XRedPointConditionMailPersonal.Check(mailId) + return XDataCenter.MailManager.IsMailUnReadOrHasReward(mailId) +end + +return XRedPointConditionMailPersonal \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMainChapter.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMainChapter.lua new file mode 100644 index 00000000..6ecf9094 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMainChapter.lua @@ -0,0 +1,19 @@ + +---------------------------------------------------------------- +--角色入口红点检测 +local XRedPointConditionMainChapter = {} +local SubConditions = nil +function XRedPointConditionMainChapter.Check() + return XDataCenter.FubenMainLineManager.CheckAllChapterReward() + or XDataCenter.BfrtManager.CheckAllChapterReward() + or XDataCenter.ExtraChapterManager.CheckAllChapterReward() + or XDataCenter.TaskManager.GetIsRewardFor(XDataCenter.TaskManager.TaskType.ZhouMu) + or XRedPointConditionTRPGMainView.Check(XDataCenter.FubenMainLineManager.TRPGChapterId) +end + +function XRedPointConditionMainChapter.GetSubConditions() + SubConditions = SubConditions or { XRedPointConditions.Types.CONDITION_MAINLINE_CHAPTER_REWARD, XRedPointConditions.Types.CONDITION_BFRT_CHAPTER_REWARD, XRedPointConditions.Types.CONDITION_TRPG_MAIN_VIEW} + return SubConditions +end + +return XRedPointConditionMainChapter \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMainDispatch.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMainDispatch.lua new file mode 100644 index 00000000..96f1067f --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMainDispatch.lua @@ -0,0 +1,22 @@ + +---------------------------------------------------------------- +--角色入口红点检测 +local XRedPointConditionMainDispatch = {} +local Events = nil + +function XRedPointConditionMainDispatch.Check() + return XDataCenter.TaskForceManager.CheckTaskForceCompleted() +end + +function XRedPointConditionMainDispatch.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_TASKFORCE_TASKFINISH_REQUEST), + XRedPointEventElement.New(XEventId.EVENT_TASKFORCE_COMPLETE_NOTIFY), + XRedPointEventElement.New(XEventId.EVENT_TASKFORCE_ACCEPT_REWARD_REQUEST), + + } + return Events +end + +return XRedPointConditionMainDispatch \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMainFriend.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMainFriend.lua new file mode 100644 index 00000000..27e0d203 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMainFriend.lua @@ -0,0 +1,26 @@ + +---------------------------------------------------------------- +--角色入口红点检测 +local XRedPointConditionMainFriend = {} +local SubConditions = nil + +function XRedPointConditionMainFriend.Check() + local count = XRedPointConditionFriendContact.Check() + if count > 0 then + return count + end + + if XRedPointConditionFriendWaitPass.Check() then + return true + end +end + +function XRedPointConditionMainFriend.GetSubConditions() + SubConditions = SubConditions or { + XRedPointConditions.Types.CONDITION_FRIEND_CONTACT, --私聊信息标签 + XRedPointConditions.Types.CONDITION_FRIEND_WAITPASS + } + return SubConditions +end + +return XRedPointConditionMainFriend \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMainLineExploreItem.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMainLineExploreItem.lua new file mode 100644 index 00000000..6488323e --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMainLineExploreItem.lua @@ -0,0 +1,19 @@ +---------------------------------------------------------------- +--新手任务奖励检测 +local XRedPointConditionMainLineExploreItem = {} +local Events = nil + +function XRedPointConditionMainLineExploreItem.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_MAINLINE_EXPLORE_ITEM_GET), + XRedPointEventElement.New(XEventId.EVENT_MAINLINE_EXPLORE_ITEMBOX_CLOSE), + } + return Events +end + +function XRedPointConditionMainLineExploreItem.Check(mainChapterId) + return XDataCenter.FubenMainLineManager.CheckHaveNewExploreItemByChapterId(mainChapterId) +end + +return XRedPointConditionMainLineExploreItem \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMainLineTreasure.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMainLineTreasure.lua new file mode 100644 index 00000000..541c992a --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMainLineTreasure.lua @@ -0,0 +1,16 @@ +local XRedPointConditionMainLineTreasure = {} +local Events = nil + +function XRedPointConditionMainLineTreasure.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_FUBEN_CHAPTER_REWARD) + } + return Events +end + +function XRedPointConditionMainLineTreasure.Check(chapterId) + return XDataCenter.FubenMainLineManager.CheckTreasureReward(chapterId) +end + +return XRedPointConditionMainLineTreasure \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMainMail.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMainMail.lua new file mode 100644 index 00000000..95c14839 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMainMail.lua @@ -0,0 +1,15 @@ +---------------------------------------------------------------- +--单个邮件检测 +local XRedPointConditionMainMail = {} +local SubConditions = nil + +function XRedPointConditionMainMail.GetSubConditions() + SubConditions = SubConditions or { XRedPointConditions.Types.CONDITION_MAIL_PERSONAL } + return SubConditions +end + +function XRedPointConditionMainMail.Check() + return XDataCenter.MailManager.GetHasUnDealMail() +end + +return XRedPointConditionMainMail \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMainMember.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMainMember.lua new file mode 100644 index 00000000..aff30873 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMainMember.lua @@ -0,0 +1,36 @@ + +---------------------------------------------------------------- +--角色入口红点检测 +local XRedPointConditionMainMember = {} +local SubConditions = nil +function XRedPointConditionMainMember.Check() + local characterList = XDataCenter.CharacterManager.GetCharacterList() + + if not characterList then + return false + end + + local count = #characterList + local isEnough = false + + for i = 1, count do + local character = characterList[i] + if XRedPointConditionCharacter.Check(character.Id) then + isEnough = true + break + end + end + + return isEnough +end + + +function XRedPointConditionMainMember.GetSubConditions() + SubConditions = SubConditions or + { + XRedPointConditions.Types.CONDITION_CHARACTER, + } + return SubConditions +end + +return XRedPointConditionMainMember \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMainNewPlayerTask.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMainNewPlayerTask.lua new file mode 100644 index 00000000..c05c0635 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMainNewPlayerTask.lua @@ -0,0 +1,37 @@ +---------------------------------------------------------------- +--新手任务奖励检测 +local XRedPointConditionMainNewPlayerTask = {} +local Events = nil + +function XRedPointConditionMainNewPlayerTask.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_TASK_SYNC), + XRedPointEventElement.New(XEventId.EVENT_FUNCTION_OPEN_COMPLETE), + XRedPointEventElement.New(XEventId.EVENT_NEWBIETASK_DAYCHANGED), + XRedPointEventElement.New(XEventId.EVENT_NEWBIETASK_PROGRESSCHANGED), + } + return Events +end + +function XRedPointConditionMainNewPlayerTask.Check() + + if not XFunctionManager.JudgeOpen(XFunctionManager.FunctionName.Target) then + return false + end + + if XDataCenter.TaskManager.CheckNewbieActivenessAvailable() then + return true + end + + local newbieTasks = XTaskConfig.GetNewPlayerTaskGroupTemplate() + for _, v in pairs(newbieTasks or {}) do + if XDataCenter.TaskManager.GetNewbiePlayTaskReddotByOpenDay(v.OpenDay) then + return true + end + end + return false + +end + +return XRedPointConditionMainNewPlayerTask \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMainNotice.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMainNotice.lua new file mode 100644 index 00000000..d0c3b7ce --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMainNotice.lua @@ -0,0 +1,19 @@ + +---------------------------------------------------------------- +local XRedPointConditionMainNotice = {} +local SubConditions = nil + +function XRedPointConditionMainNotice.Check() + return XRedPointConditionActivityNewAcitivies.Check() or XRedPointConditionActivityNewNotices.Check() + or XRedPointConditionActivityNewActivityNotices.Check() +end + +function XRedPointConditionMainNotice.GetSubConditions() + return SubConditions or { + XRedPointConditions.Types.CONDITION_ACTIVITY_NEW_ACTIVITIES, + XRedPointConditions.Types.CONDITION_ACTIVITY_NEW_NOTICES, + XRedPointConditions.Types.CONDITION_ACTIVITY_NEW_ACTIVITY_NOTICES, + } +end + +return XRedPointConditionMainNotice \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMainSet.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMainSet.lua new file mode 100644 index 00000000..61300736 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMainSet.lua @@ -0,0 +1,17 @@ +---------------------------------------------------------------- +--检测设置自定义键位冲突 +local XRedPointConditionMainSet = {} +local Events = nil +function XRedPointConditionMainSet.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_CUSTOM_UI_SCHEME_CHANGED) + } + return Events +end + +function XRedPointConditionMainSet.Check() + return CS.XRLFightSettings.UiConflict +end + +return XRedPointConditionMainSet \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMainSpecialShop.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMainSpecialShop.lua new file mode 100644 index 00000000..d763d9ee --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMainSpecialShop.lua @@ -0,0 +1,12 @@ +-- 特殊商店红点检测 +local XRedPointConditionMainSpecialShop = {} + +function XRedPointConditionMainSpecialShop.Check() + if XDataCenter.SpecialShopManager:IsShowEntrance() then + return not XSaveTool.GetData(string.format("%d%s", XPlayer.Id, "SpecialShopAlreadyIn")) + else + return false + end +end + +return XRedPointConditionMainSpecialShop \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMainTask.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMainTask.lua new file mode 100644 index 00000000..911772b2 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMainTask.lua @@ -0,0 +1,40 @@ +---------------------------------------------------------------- +--主界面任务奖励检测 +local XRedPointConditionMainTask = {} +local SubConditions = nil +function XRedPointConditionMainTask.GetSubConditions() + SubConditions = SubConditions or + { + XRedPointConditions.Types.CONDITION_TASK_COURSE, + XRedPointConditions.Types.CONDITION_TASK_TYPE, + } + return SubConditions +end + +function XRedPointConditionMainTask.Check() + + if XRedPointConditionTaskCourse.Check() and (not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.TaskStory)) then + return true + end + + if XRedPointConditionTaskType.Check(XDataCenter.TaskManager.TaskType.Story) then + return true + end + + if XRedPointConditionTaskType.Check(XDataCenter.TaskManager.TaskType.Daily) then + return true + end + + if XRedPointConditionTaskType.Check(XDataCenter.TaskManager.TaskType.Weekly) then + return true + end + + if XRedPointConditionTaskType.Check(XDataCenter.TaskManager.TaskType.Activity) then + return true + end + + + return false +end + +return XRedPointConditionMainTask \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMedalNew.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMedalNew.lua new file mode 100644 index 00000000..af4aaa6f --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMedalNew.lua @@ -0,0 +1,21 @@ +---------------------------------------------------------------- +-- 勋章检测 +local XRedPointConditionMedalNew = {} + +local Events = nil +function XRedPointConditionMedalNew.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_MEDAL_NOTIFY), + XRedPointEventElement.New(XEventId.EVENT_MEDAL_REDPOINT_CHANGE), + XRedPointEventElement.New(XEventId.EVENT_SCORETITLE_CHANGE), + XRedPointEventElement.New(XEventId.EVENT_NAMEPLATE_CHANGE), + } + return Events +end + +function XRedPointConditionMedalNew.Check() + return XDataCenter.MedalManager.CheckHaveNewMedal() +end + +return XRedPointConditionMedalNew \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMentorApplyRed.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMentorApplyRed.lua new file mode 100644 index 00000000..a1db045d --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMentorApplyRed.lua @@ -0,0 +1,22 @@ +---------------------------------------------------------------- +local XRedPointConditionMentorApplyRed = {} + +local Events = nil +function XRedPointConditionMentorApplyRed.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_MENTOR_GET_APPLY), + XRedPointEventElement.New(XEventId.EVENT_MENTOR_OPERATION_APPLY), + XRedPointEventElement.New(XEventId.EVENT_MAINUI_ENABLE), + XRedPointEventElement.New(XEventId.EVENT_MENTOR_TEACHERORSTUDENT_CHANGE), + XRedPointEventElement.New(XEventId.EVENT_BLACK_DATA_CHANGE), + } + return Events +end + +function XRedPointConditionMentorApplyRed.Check() + local mentorData = XDataCenter.MentorSystemManager.GetMentorData() + return XFunctionManager.JudgeOpen(XFunctionManager.FunctionName.MentorSystem) and mentorData:IsHasApply() and mentorData:IsCanDoApply(false) +end + +return XRedPointConditionMentorApplyRed \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMentorRewardRed.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMentorRewardRed.lua new file mode 100644 index 00000000..3e1a1cbc --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMentorRewardRed.lua @@ -0,0 +1,36 @@ +---------------------------------------------------------------- +local XRedPointConditionMentorRewardRed = {} + +local Events = nil +function XRedPointConditionMentorRewardRed.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_TASK_SYNC), + XRedPointEventElement.New(XEventId.EVENT_PLAYER_LEVEL_CHANGE), + XRedPointEventElement.New(XEventId.EVENT_MENTOR_GRADUATE_STUDENT), + XRedPointEventElement.New(XEventId.EVENT_MAINUI_ENABLE), + XRedPointEventElement.New(XEventId.EVENT_FINISH_TASK), + XRedPointEventElement.New(XEventId.EVENT_MENTOR_GETREWARD), + XRedPointEventElement.New(XEventId.EVENT_MENTOR_TEACHERORSTUDENT_CHANGE), + } + return Events +end + +function XRedPointConditionMentorRewardRed.Check() + local mentorData = XDataCenter.MentorSystemManager.GetMentorData() + if mentorData:IsTeacher() then + local teacherCheck = XDataCenter.MentorSystemManager.CheckTeacherCanGetStudentTaskReward() or + XDataCenter.MentorSystemManager.CheckTeacherCanGetGraduateReward() + + return XFunctionManager.JudgeOpen(XFunctionManager.FunctionName.MentorSystem) and teacherCheck + elseif mentorData:IsStudent() then + local studentCheck = XDataCenter.TaskManager.GetIsRewardFor(XDataCenter.TaskManager.TaskType.MentorShipGrow) or + XDataCenter.TaskManager.GetIsRewardFor(XDataCenter.TaskManager.TaskType.MentorShipGraduate) + + return XFunctionManager.JudgeOpen(XFunctionManager.FunctionName.MentorSystem) and studentCheck + else + return false + end +end + +return XRedPointConditionMentorRewardRed \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMentorTaskRed.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMentorTaskRed.lua new file mode 100644 index 00000000..5bf1142a --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMentorTaskRed.lua @@ -0,0 +1,39 @@ +---------------------------------------------------------------- +local XRedPointConditionMentorTaskRed = {} + +local Events = nil +function XRedPointConditionMentorTaskRed.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_MENTOR_STUDENT_TASKCOUNT_CHANGE), + XRedPointEventElement.New(XEventId.EVENT_MENTOR_STUDENT_WEEKLYTASK_CHANGE), + XRedPointEventElement.New(XEventId.EVENT_MENTOR_TEACHER_STUDENTWEEKLYTASK_CHANGE), + XRedPointEventElement.New(XEventId.EVENT_MAINUI_ENABLE), + XRedPointEventElement.New(XEventId.EVENT_MENTOR_GETREWARD), + XRedPointEventElement.New(XEventId.EVENT_MENTOR_INTASKUI), + XRedPointEventElement.New(XEventId.EVENT_MENTOR_TEACHERORSTUDENT_CHANGE), + XRedPointEventElement.New(XEventId.EVENT_MENTOR_GRADUATE_STUDENT), + XRedPointEventElement.New(XEventId.EVENT_MENTOR_LOSE_STUDENT), + } + return Events +end + +function XRedPointConditionMentorTaskRed.Check() + local mentorData = XDataCenter.MentorSystemManager.GetMentorData() + if mentorData:IsTeacher() then + local teacherCheck = XDataCenter.MentorSystemManager.CheckTeacherCanGetStudentWeeklyReward() + + return XFunctionManager.JudgeOpen(XFunctionManager.FunctionName.MentorSystem) and teacherCheck + elseif mentorData:IsStudent() then + local IsSystemTaskNotEmpty = mentorData:CheckStudentSystemTaskIsEnmtyByIndex(XMentorSystemConfigs.MySelfIndex) + local studentCheck = XDataCenter.MentorSystemManager.CheckStudentCanGetTask() or + XDataCenter.MentorSystemManager.CheckStudentCanGetWeeklyReward() or + XDataCenter.MentorSystemManager.CheckStudentCanGetTeacherGift() + + return XFunctionManager.JudgeOpen(XFunctionManager.FunctionName.MentorSystem) and IsSystemTaskNotEmpty and studentCheck + else + return false + end +end + +return XRedPointConditionMentorTaskRed \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMineSweepingRed.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMineSweepingRed.lua new file mode 100644 index 00000000..37703d64 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMineSweepingRed.lua @@ -0,0 +1,18 @@ +local XRedPointConditionMineSweepingRed = {} +local Events = nil +function XRedPointConditionMineSweepingRed.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_MAINUI_ENABLE), + XRedPointEventElement.New(XEventId.EVENT_MINESWEEPING_STAGESTART), + XRedPointEventElement.New(XEventId.EVENT_MINESWEEPING_GRIDOPEN), + XRedPointEventElement.New(XEventId.EVENT_MINESWEEPING_STORYPLAY), + } + return Events +end + +function XRedPointConditionMineSweepingRed.Check() + return XDataCenter.MineSweepingManager.CheckHaveRed() +end + +return XRedPointConditionMineSweepingRed \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMoeWarDrawRed.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMoeWarDrawRed.lua new file mode 100644 index 00000000..e3155976 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMoeWarDrawRed.lua @@ -0,0 +1,18 @@ +local XRedPointConditionMoeWarDrawRed = {} +local Events = nil +local itemId = CS.XGame.ClientConfig:GetInt("MoeWarGachaItem") +local showCount = CS.XGame.ClientConfig:GetInt("MoeWarGachaItemNum") +function XRedPointConditionMoeWarDrawRed.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_ITEM_COUNT_UPDATE_PREFIX..itemId), + } + return Events +end + +function XRedPointConditionMoeWarDrawRed.Check() + local itemCount = XDataCenter.ItemManager.GetCount(itemId) + return itemCount >= showCount +end + +return XRedPointConditionMoeWarDrawRed \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMoeWarPreparation.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMoeWarPreparation.lua new file mode 100644 index 00000000..2d939a70 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMoeWarPreparation.lua @@ -0,0 +1,30 @@ +local XRedPointConditionMoeWarPreparation = {} +local SubConditions = nil + +function XRedPointConditionMoeWarPreparation.GetSubConditions() + SubConditions = SubConditions or + { + XRedPointConditions.Types.CONDITION_MOEWAR_PREPARATION_REWARD, + XRedPointConditions.Types.CONDITION_MOEWAR_PREPARATION_OPEN_STAGE, + } + return SubConditions +end + +function XRedPointConditionMoeWarPreparation.Check() + local preparationActivityId = XMoeWarConfig.GetPreparationActivityIdInTime() + if not preparationActivityId then + return false + end + + if XRedPointConditionMoeWarPreparationReward.Check() then + return true + end + + if XRedPointConditionMoeWarPreparationOpenStage.Check() then + return true + end + + return false +end + +return XRedPointConditionMoeWarPreparation \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMoeWarPreparationOpenStage.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMoeWarPreparationOpenStage.lua new file mode 100644 index 00000000..fbb91098 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMoeWarPreparationOpenStage.lua @@ -0,0 +1,19 @@ +local XRedPointConditionMoeWarPreparationOpenStage = {} + +function XRedPointConditionMoeWarPreparationOpenStage.Check() + local preparationActivityId = XMoeWarConfig.GetPreparationActivityIdInTime() + if not preparationActivityId then + return false + end + + local openStageIdList = XDataCenter.MoeWarManager.GetPreparationAllOpenStageIdList() + local openStageIdCount = #openStageIdList + local redminNum = XMoeWarConfig.GetPreparationActivityRedminNum(preparationActivityId) + if openStageIdCount >= redminNum then + return true + end + + return false +end + +return XRedPointConditionMoeWarPreparationOpenStage \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMoeWarPreparationReward.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMoeWarPreparationReward.lua new file mode 100644 index 00000000..6aa27f35 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMoeWarPreparationReward.lua @@ -0,0 +1,33 @@ +local XRedPointConditionMoeWarPreparationReward = {} +local Events = nil +function XRedPointConditionMoeWarPreparationReward.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_MOE_WAR_PREPARATION_GEAR_REWARD), + } + return Events +end + +function XRedPointConditionMoeWarPreparationReward.Check() + local preparationActivityId = XMoeWarConfig.GetPreparationActivityIdInTime() + if not preparationActivityId then + return false + end + + local gears = XMoeWarConfig.GetPreparationActivityPreparationGears(preparationActivityId) + local haveCount = XDataCenter.ItemManager.GetCount(XDataCenter.ItemManager.ItemId.MoeWarPreparationItemId) + local needCount + local isCanReceive + local isGetReward + for i, gearId in ipairs(gears) do + needCount = XMoeWarConfig.GetPreparationGearNeedCount(gearId) + isCanReceive = haveCount >= needCount + isGetReward = XDataCenter.MoeWarManager.IsPreparationGetRewardGears(gearId) + if not isGetReward and isCanReceive then + return true + end + end + return false +end + +return XRedPointConditionMoeWarPreparationReward \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMoeWarRecruit.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMoeWarRecruit.lua new file mode 100644 index 00000000..8c21de6e --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMoeWarRecruit.lua @@ -0,0 +1,15 @@ +local XRedPointConditionMoeWarRecruit = {} +local Events = nil +function XRedPointConditionMoeWarRecruit.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_MOE_WAR_CHECK_RECRUIT_RED_POINT), + } + return Events +end + +function XRedPointConditionMoeWarRecruit.Check() + return XDataCenter.MoeWarManager.CheckAllHelpersRedPoint() +end + +return XRedPointConditionMoeWarRecruit \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMoeWarTask.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMoeWarTask.lua new file mode 100644 index 00000000..0b3c5958 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMoeWarTask.lua @@ -0,0 +1,22 @@ +local XRedPointConditionMoeWarTask = {} +local Events = nil +function XRedPointConditionMoeWarTask.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_TASK_SYNC), + XRedPointEventElement.New(XEventId.EVENT_FINISH_TASK), + } + return Events +end + +function XRedPointConditionMoeWarTask.Check() + local taskCount = XMoeWarConfig.GetTaskGroupCount() + for i = 1,taskCount do + if XDataCenter.MoeWarManager.CheckTaskRedPoint(i,XMoeWarConfig.GetTaskGroupId(i)) then + return true + end + end + return false +end + +return XRedPointConditionMoeWarTask \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMoeWarTaskTab.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMoeWarTaskTab.lua new file mode 100644 index 00000000..5a0cc038 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMoeWarTaskTab.lua @@ -0,0 +1,16 @@ +local XRedPointConditionMoeWarTaskTab = {} +local Events = nil +function XRedPointConditionMoeWarTaskTab.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_TASK_SYNC), + XRedPointEventElement.New(XEventId.EVENT_FINISH_TASK), + } + return Events +end + +function XRedPointConditionMoeWarTaskTab.Check(type) + return XDataCenter.MoeWarManager.CheckTaskRedPoint(type,XMoeWarConfig.GetTaskGroupId(type)),type +end + +return XRedPointConditionMoeWarTaskTab \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMovieAssemble01Red.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMovieAssemble01Red.lua new file mode 100644 index 00000000..3f18f7ad --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMovieAssemble01Red.lua @@ -0,0 +1,15 @@ +local XRedPointConditionMovieAssemble01Red = {} +local Events = nil +function XRedPointConditionMovieAssemble01Red.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_MOVIE_ASSEMBLE_WATCH_MOVIE), + } + return Events +end + +function XRedPointConditionMovieAssemble01Red.Check() + return XDataCenter.MovieAssembleManager.CheckMovieAssembleRedPoint(1) +end + +return XRedPointConditionMovieAssemble01Red \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMovieAssembleMovieRed.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMovieAssembleMovieRed.lua new file mode 100644 index 00000000..2605b321 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMovieAssembleMovieRed.lua @@ -0,0 +1,15 @@ +local XRedPointConditionMovieAssembleMovieRed = {} +local Events = nil +function XRedPointConditionMovieAssembleMovieRed.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_MOVIE_ASSEMBLE_WATCH_MOVIE), + } + return Events +end + +function XRedPointConditionMovieAssembleMovieRed.Check(movieId) + return XDataCenter.MovieAssembleManager.CheckMovieTmpRedPoint(movieId) +end + +return XRedPointConditionMovieAssembleMovieRed \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMovieAssembleRed.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMovieAssembleRed.lua new file mode 100644 index 00000000..8360fdcc --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionMovieAssembleRed.lua @@ -0,0 +1,15 @@ +local XRedPointConditionMovieAssembleRed = {} +local Events = nil +function XRedPointConditionMovieAssembleRed.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_MOVIE_ASSEMBLE_WATCH_MOVIE), + } + return Events +end + +function XRedPointConditionMovieAssembleRed.Check(assembleId) + return XDataCenter.MovieAssembleManager.CheckMovieAssembleRedPoint(assembleId) +end + +return XRedPointConditionMovieAssembleRed \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionNewChallenge.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionNewChallenge.lua new file mode 100644 index 00000000..6ec47ea6 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionNewChallenge.lua @@ -0,0 +1,16 @@ +-- 副本挑战页签红点 (版本新玩法出现时) +local XRedPointConditionNewChallenge = {} +local Events = nil +function XRedPointConditionNewChallenge.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_FUBEN_NEW_CHALLEGE), + } + return Events +end +--检测 +function XRedPointConditionNewChallenge.Check() + return XDataCenter.FubenManager.IsNewChallengeRedPoint() +end + +return XRedPointConditionNewChallenge \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionNewCharActTreasure.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionNewCharActTreasure.lua new file mode 100644 index 00000000..13524a1a --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionNewCharActTreasure.lua @@ -0,0 +1,16 @@ +local XRedPointConditionNewCharActTreasure = {} +local Events = nil + +function XRedPointConditionNewCharActTreasure.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_FUBEN_NEWCHARACT_REWARD) + } + return Events +end + +function XRedPointConditionNewCharActTreasure.Check(actId) + return XDataCenter.FubenNewCharActivityManager.CheckTreasureReward(actId) +end + +return XRedPointConditionNewCharActTreasure \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionNewYearDiviningNotGet.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionNewYearDiviningNotGet.lua new file mode 100644 index 00000000..f85ac358 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionNewYearDiviningNotGet.lua @@ -0,0 +1,7 @@ +local XRedPointConditionNewYearDiviningNotGet = {} + +function XRedPointConditionNewYearDiviningNotGet.Check() + return XDataCenter.SignInManager.CheckTodayDiviningState() +end + +return XRedPointConditionNewYearDiviningNotGet \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionNieRCharacterRed.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionNieRCharacterRed.lua new file mode 100644 index 00000000..dc6a9d27 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionNieRCharacterRed.lua @@ -0,0 +1,22 @@ + +local XRedPointConditionNieRCharacterRed = {} +local Events = nil +function XRedPointConditionNieRCharacterRed.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_FUBEN_NIER_STAGE_REWARD), + XRedPointEventElement.New(XEventId.EVENT_NIER_CHARACTER_UPDATE), + XRedPointEventElement.New(XEventId.EVENT_FUBEN_REFRESH_STAGE_DATA), + } + return Events +end + +function XRedPointConditionNieRCharacterRed.Check(args) + local characterId = args.CharacterId + local isInfor = args.IsInfor + local isTeach = args.IsTeach + local red = XDataCenter.NieRManager.CheckNieRCharacterRed(characterId, isInfor, isTeach) + return red +end + +return XRedPointConditionNieRCharacterRed \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionNieRPODRed.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionNieRPODRed.lua new file mode 100644 index 00000000..a800ddb2 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionNieRPODRed.lua @@ -0,0 +1,29 @@ + +local XRedPointConditionNieRPODRed = {} +local Events = nil +function XRedPointConditionNieRPODRed.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_FUBEN_NIER_STAGE_REWARD), + XRedPointEventElement.New(XEventId.EVENT_NIER_POD_UPDATE), + XRedPointEventElement.New(XEventId.EVENT_NIER_CHARACTER_UPDATE), + } + local consumeIdDic = {} + local podSkillLevelCfgs = XNieRConfigs.GetAllNieRSupportSkillLevelConfig() + + for _, cfg in pairs(podSkillLevelCfgs) do + local consumeId = cfg.UpgradeConsumeId + if consumeId ~= 0 and not consumeIdDic[consumeId] then + consumeIdDic[consumeId] = true + table.insert(Events, XRedPointEventElement.New(XEventId.EVENT_ITEM_COUNT_UPDATE_PREFIX .. consumeId)) + end + end + return Events +end + +function XRedPointConditionNieRPODRed.Check() + local red = XDataCenter.NieRManager.CheckNieRPODRed() + return red +end + +return XRedPointConditionNieRPODRed \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionNieRRed.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionNieRRed.lua new file mode 100644 index 00000000..c5e623b2 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionNieRRed.lua @@ -0,0 +1,41 @@ +XRedPointConditionNieRRed = {} +--local Events = nil +local SubConditions = nil +-- function XRedPointConditionNieRRed.GetSubEvents() +-- Events = Events or { +-- XRedPointEventElement.New(XEventId.EVENT_TASK_SYNC) +-- } +-- return Events +-- end +function XRedPointConditionNieRRed.GetSubConditions() + SubConditions = SubConditions or + { + XRedPointConditions.Types.CONDITION_NIER_TASK_RED, + XRedPointConditions.Types.CONDITION_NIER_POD_RED, + XRedPointConditions.Types.CONDITION_NIER_REPEAT_RED, + XRedPointConditions.Types.CONDITION_NIER_CHARACTER_RED, + } + return SubConditions +end + +function XRedPointConditionNieRRed.Check() + if XRedPointConditionNieRPODRed.Check() then + return true + end + + if XRedPointConditionNieRRepeatRed.Check() then + return true + end + + if XRedPointConditionNieRTaskRed.Check(-1) then + return true + end + + if XRedPointConditionNieRCharacterRed.Check( {CharacterId = -1, IsInfor = true, IsTeach = true}) then + return true + end + + return false +end + +return XRedPointConditionNieRRed \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionNieRRepeatRed.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionNieRRepeatRed.lua new file mode 100644 index 00000000..86559c04 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionNieRRepeatRed.lua @@ -0,0 +1,30 @@ +local tableInsert = table.insert +local XRedPointConditionNieRRepeatRed = {} +local Events = nil + +function XRedPointConditionNieRRepeatRed.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_FUBEN_NIER_STAGE_REWARD), + XRedPointEventElement.New(XEventId.EVENT_NIER_CHARACTER_UPDATE), + XRedPointEventElement.New(XEventId.EVENT_NIER_REPEAT_CLICK), + XRedPointEventElement.New(XEventId.EVENT_FUBEN_REFRESH_STAGE_DATA), + } + local nierConfigs = XNieRConfigs.GetAllActivityConfig() + for _, cfg in pairs(nierConfigs) do + local nierRepeatConsumId = cfg.RepeatableConsumeId + if nierRepeatConsumId and nierRepeatConsumId ~= 0 then + tableInsert(Events, XRedPointEventElement.New(XEventId.EVENT_ITEM_COUNT_UPDATE_PREFIX .. nierRepeatConsumId)) + end + end + + + return Events +end + +function XRedPointConditionNieRRepeatRed.Check() + local red = XDataCenter.NieRManager.CheckRepeatRed() + return red +end + +return XRedPointConditionNieRRepeatRed \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionNieRTaskRed.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionNieRTaskRed.lua new file mode 100644 index 00000000..cdd8c628 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionNieRTaskRed.lua @@ -0,0 +1,16 @@ +local XRedPointConditionNieRTaskRed = {} +local Events = nil +function XRedPointConditionNieRTaskRed.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_TASK_SYNC), + } + return Events +end + +function XRedPointConditionNieRTaskRed.Check(chapterId) + local red = XDataCenter.NieRManager.CheckNieRTaskRed(chapterId) + return red +end + +return XRedPointConditionNieRTaskRed \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionNierCanFight.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionNierCanFight.lua new file mode 100644 index 00000000..d35be078 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionNierCanFight.lua @@ -0,0 +1,23 @@ +---------------------------------------------------------------- +--roguelike爬塔:每日行动力不为零的红点检测 + +local XRedPointConditionNierCanFight = {} +local Events = nil +function XRedPointConditionNierCanFight.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_ROGUELIKE_ACTIONPOINT_CHARACTER_CHANGED), + } + return Events +end + +function XRedPointConditionNierCanFight.Check() + local isOpen = XActivityBrieIsOpen.Get(XActivityBriefConfigs.ActivityGroupId.Nier) + if isOpen then + return XDataCenter.NieRManager.CheckNieRCanFightTag() + else + return false + end +end + +return XRedPointConditionNierCanFight \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPartnerCanCompose.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPartnerCanCompose.lua new file mode 100644 index 00000000..fb4b9a07 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPartnerCanCompose.lua @@ -0,0 +1,21 @@ +---------------------------------------------------------------- +-- 勋章检测 +local XRedPointConditionPartnerCanCompose = {} + +local Events = nil +function XRedPointConditionPartnerCanCompose.GetSubEvents() + local eventIds = XDataCenter.PartnerManager.GetCheckEventIds() + Events = {} + for _,id in pairs(eventIds or {}) do + table.insert(Events, XRedPointEventElement.New(id)) + end + table.insert(Events, XRedPointEventElement.New(XEventId.EVENT_MAINUI_ENABLE)) + + return Events +end + +function XRedPointConditionPartnerCanCompose.Check() + return XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.Partner) and XDataCenter.PartnerManager.CheckComposeRedOfAll() +end + +return XRedPointConditionPartnerCanCompose \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPartnerNewSkill.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPartnerNewSkill.lua new file mode 100644 index 00000000..5fd59d16 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPartnerNewSkill.lua @@ -0,0 +1,20 @@ +---------------------------------------------------------------- +-- 勋章检测 +local XRedPointConditionPartnerNewSkill = {} + +local Events = nil +function XRedPointConditionPartnerNewSkill.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_PARTNER_SKILLUNLOCK), + XRedPointEventElement.New(XEventId.EVENT_MAINUI_ENABLE), + + } + return Events +end + +function XRedPointConditionPartnerNewSkill.Check() + return XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.Partner) and XDataCenter.PartnerManager.CheckNewSkillRedOfAll() +end + +return XRedPointConditionPartnerNewSkill \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPassport.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPassport.lua new file mode 100644 index 00000000..f6ba64b8 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPassport.lua @@ -0,0 +1,50 @@ + +local XRedPointConditionPassport = {} +local SubConditions = nil + +local Events = nil + +function XRedPointConditionPassport.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_AUTO_GET_TASK_REWARD_LIST), + } + return Events +end + +function XRedPointConditionPassport.GetSubConditions() + SubConditions = SubConditions or + { + XRedPointConditions.Types.CONDITION_PASSPORT_PANEL_REWARD_RED, + XRedPointConditions.Types.CONDITION_PASSPORT_TASK_DAILY_RED, + XRedPointConditions.Types.CONDITION_PASSPORT_TASK_WEEKLY_RED, + XRedPointConditions.Types.CONDITION_PASSPORT_TASK_ACTIVITY_RED, + } + return SubConditions +end + +function XRedPointConditionPassport.Check() + if XDataCenter.PassportManager.IsActivityClose() then + return false + end + + if XRedPointConditionPassportPanelReward.Check() then + return true + end + + if XRedPointConditionPassportTaskDaily.Check() then + return true + end + + if XRedPointConditionPassportTaskWeekly.Check() then + return true + end + + if XRedPointConditionPassportTaskActivity.Check() then + return true + end + + return false +end + +return XRedPointConditionPassport \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPassportPanelReward.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPassportPanelReward.lua new file mode 100644 index 00000000..809a06d2 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPassportPanelReward.lua @@ -0,0 +1,25 @@ + +local XRedPointConditionPassportPanelReward = {} + +local Events = nil + +function XRedPointConditionPassportPanelReward.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_NOTIFY_PASSPORT_BASE_INFO), + XRedPointEventElement.New(XEventId.EVENT_BUY_PASSPORT_COMPLEATE), + XRedPointEventElement.New(XEventId.EVENT_BUY_EXP_COMPLEATE), + XRedPointEventElement.New(XEventId.EVENT_BUY_RECV_REWARD_COMPLEATE), + XRedPointEventElement.New(XEventId.EVENT_BUY_RECV_ALL_REWARD_COMPLEATE), + } + return Events +end + +function XRedPointConditionPassportPanelReward.Check() + if XDataCenter.PassportManager.CheckPassportRewardRedPoint() then + return true + end + return false +end + +return XRedPointConditionPassportPanelReward \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPassportTaskActivity.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPassportTaskActivity.lua new file mode 100644 index 00000000..9cd23b0c --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPassportTaskActivity.lua @@ -0,0 +1,22 @@ + +local XRedPointConditionPassportTaskActivity = {} + +local Events = nil + +function XRedPointConditionPassportTaskActivity.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_TASK_SYNC), + XRedPointEventElement.New(XEventId.EVENT_FINISH_TASK), + } + return Events +end + +function XRedPointConditionPassportTaskActivity.Check() + if XDataCenter.PassportManager.CheckPassportAchievedTaskRedPoint(XPassportConfigs.TaskType.Activity) then + return true + end + return false +end + +return XRedPointConditionPassportTaskActivity \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPassportTaskDaily.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPassportTaskDaily.lua new file mode 100644 index 00000000..12a678cb --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPassportTaskDaily.lua @@ -0,0 +1,22 @@ + +local XRedPointConditionPassportTaskDaily = {} + +local Events = nil + +function XRedPointConditionPassportTaskDaily.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_TASK_SYNC), + XRedPointEventElement.New(XEventId.EVENT_FINISH_TASK), + } + return Events +end + +function XRedPointConditionPassportTaskDaily.Check() + if XDataCenter.PassportManager.CheckPassportAchievedTaskRedPoint(XPassportConfigs.TaskType.Daily) then + return true + end + return false +end + +return XRedPointConditionPassportTaskDaily \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPassportTaskWeekly.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPassportTaskWeekly.lua new file mode 100644 index 00000000..adc1ee3c --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPassportTaskWeekly.lua @@ -0,0 +1,22 @@ + +local XRedPointConditionPassportTaskWeekly = {} + +local Events = nil + +function XRedPointConditionPassportTaskWeekly.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_TASK_SYNC), + XRedPointEventElement.New(XEventId.EVENT_FINISH_TASK), + } + return Events +end + +function XRedPointConditionPassportTaskWeekly.Check() + if XDataCenter.PassportManager.CheckPassportAchievedTaskRedPoint(XPassportConfigs.TaskType.Weekly) then + return true + end + return false +end + +return XRedPointConditionPassportTaskWeekly \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPicCompositionTaskFinished.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPicCompositionTaskFinished.lua new file mode 100644 index 00000000..a5393153 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPicCompositionTaskFinished.lua @@ -0,0 +1,19 @@ +---------------------------------------------------------------- +--新手任务奖励检测 +local XRedPointConditionPicCompositionTaskFinished = {} +local Events = nil + +function XRedPointConditionPicCompositionTaskFinished.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_TASK_SYNC), + XRedPointEventElement.New(XEventId.EVENT_PLAYER_LEVEL_CHANGE), + } + return Events +end + +function XRedPointConditionPicCompositionTaskFinished.Check() + return XDataCenter.MarketingActivityManager.CheckAnyTaskFinished() or XDataCenter.MarketingActivityManager.CheckHasActiveTaskReward() +end + +return XRedPointConditionPicCompositionTaskFinished \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPlayerAchieve.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPlayerAchieve.lua new file mode 100644 index 00000000..a0321966 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPlayerAchieve.lua @@ -0,0 +1,40 @@ +---------------------------------------------------------------- +--成就标签奖励检测 +local XRedPointConditionPlayerAchieve = {} +local SubConditions = nil + +function XRedPointConditionPlayerAchieve.GetSubConditions() + SubConditions = SubConditions or { XRedPointConditions.Types.CONDITION_PLAYER_ACHIEVE_TYPE } + return SubConditions +end + +function XRedPointConditionPlayerAchieve.Check() + + if XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.PlayerAchievement) then + return false + end + + if not XFunctionManager.JudgeOpen(XFunctionManager.FunctionName.PlayerAchievement) then + return false + end + + if XRedPointConditionPlayerAchieveType.Check(XDataCenter.TaskManager.AchvType.Fight) then + return true + end + + if XRedPointConditionPlayerAchieveType.Check(XDataCenter.TaskManager.AchvType.Collect) then + return true + end + + if XRedPointConditionPlayerAchieveType.Check(XDataCenter.TaskManager.AchvType.Social) then + return true + end + + if XRedPointConditionPlayerAchieveType.Check(XDataCenter.TaskManager.AchvType.Other) then + return true + end + + return false +end + +return XRedPointConditionPlayerAchieve \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPlayerAchieveType.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPlayerAchieveType.lua new file mode 100644 index 00000000..acc2d755 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPlayerAchieveType.lua @@ -0,0 +1,21 @@ +---------------------------------------------------------------- +--单个类型成就奖励检测 +local XRedPointConditionPlayerAchieveType = {} +local Events = nil +function XRedPointConditionPlayerAchieveType.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_TASK_SYNC), + } + return Events +end + +function XRedPointConditionPlayerAchieveType.Check(achieveType) + if not XFunctionManager.JudgeOpen(XFunctionManager.FunctionName.PlayerAchievement) then + return false + end + + return XDataCenter.TaskManager.HasAchieveTaskRewardByAchieveType(achieveType) +end + +return XRedPointConditionPlayerAchieveType \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPlayerSetName.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPlayerSetName.lua new file mode 100644 index 00000000..89b829e3 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPlayerSetName.lua @@ -0,0 +1,21 @@ +---------------------------------------------------------------- +--玩家改名检测 +local XRedPointConditionPlayerSetName = {} + +local Events = nil +function XRedPointConditionPlayerSetName.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_PLAYER_SET_NAME) + } + return Events +end + +function XRedPointConditionPlayerSetName.Check() + if XPlayer.ChangeNameTime == 0 then + return true + end + return false +end + +return XRedPointConditionPlayerSetName \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPokemonCanGetTimeSupply.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPokemonCanGetTimeSupply.lua new file mode 100644 index 00000000..a57ab51b --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPokemonCanGetTimeSupply.lua @@ -0,0 +1,16 @@ +local XRedPointConditionPokemonCanGetTimeSupply = {} +local Events = nil + +function XRedPointConditionPokemonCanGetTimeSupply.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_POKEMON_RED_POINT_TIME_SUPPLY), + } + return Events +end + +function XRedPointConditionPokemonCanGetTimeSupply.Check() + return XDataCenter.PokemonManager.CheckCanGetTimeSupply() +end + +return XRedPointConditionPokemonCanGetTimeSupply \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPokemonNewRole.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPokemonNewRole.lua new file mode 100644 index 00000000..2f89350a --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPokemonNewRole.lua @@ -0,0 +1,16 @@ +local XRedPointConditionPokemonNewRole = {} +local Events = nil + +function XRedPointConditionPokemonNewRole.GetSubEvents() +end + +function XRedPointConditionPokemonNewRole.Check(monsterId) + if not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.Pokemon) then + return false + end + local key = string.format("%s_%s_%s", XPokemonConfigs.PokemonNewRoleClickedPrefix, tostring(XPlayer.Id), tostring(monsterId)) + local isClicked = XSaveTool.GetData(key) + return isClicked +end + +return XRedPointConditionPokemonNewRole \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPokemonRed.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPokemonRed.lua new file mode 100644 index 00000000..acd2c919 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPokemonRed.lua @@ -0,0 +1,14 @@ +local XRedPointConditionPokemonRed = {} +local Events = nil + +function XRedPointConditionPokemonRed.GetSubEvents() +end + +function XRedPointConditionPokemonRed.Check() + if not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.Pokemon) then + return false + end + return XDataCenter.PokemonManager.CheckPokemonEnterRedPoint() +end + +return XRedPointConditionPokemonRed \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPokemonTaskRed.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPokemonTaskRed.lua new file mode 100644 index 00000000..204b867e --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPokemonTaskRed.lua @@ -0,0 +1,11 @@ +local XRedPointConditionPokemonTaskRed = {} +local Events = nil + +function XRedPointConditionPokemonTaskRed.GetSubEvents() +end + +function XRedPointConditionPokemonTaskRed.Check() + return XDataCenter.PokemonManager.CheckPokemonTaskRedPoint() +end + +return XRedPointConditionPokemonTaskRed \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPokerGuessingRed.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPokerGuessingRed.lua new file mode 100644 index 00000000..b89393d9 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPokerGuessingRed.lua @@ -0,0 +1,11 @@ +local XRedPointConditionPokerGuessingRed = {} +local Events = nil + +function XRedPointConditionPokerGuessingRed.GetSubEvents() +end + +function XRedPointConditionPokerGuessingRed.Check() + return XDataCenter.PokerGuessingManager.CheckBannerRedPoint() +end + +return XRedPointConditionPokerGuessingRed \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPrequel.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPrequel.lua new file mode 100644 index 00000000..020c9346 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPrequel.lua @@ -0,0 +1,36 @@ +---------------------------------------------------------------- +--间章剧情:有可挑战关卡 + +local XRedPointConditionPrequel = {} +local Events = nil +function XRedPointConditionPrequel.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_FUBEN_STAGE_SYNC), + } + return Events +end + +function XRedPointConditionPrequel.Check(args) + local isOpen = XActivityBrieIsOpen.Get(args.activityGroupId) + if isOpen then + return XRedPointConditionPrequel.CheckIsNew(args.chapterId) + else + return false + end +end + +function XRedPointConditionPrequel.CheckIsNew(chapterId) + local chapter = XPrequelConfigs.GetPrequelChapterById(chapterId) + + local stageIds = chapter.StageId + for i,stageId in ipairs(stageIds) do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + if XDataCenter.PrequelManager.CheckPrequelStageOpen(stageId) and not stageInfo.Passed then + return true + end + end +end + + +return XRedPointConditionPrequel \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPurchase.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPurchase.lua new file mode 100644 index 00000000..cff99fa4 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPurchase.lua @@ -0,0 +1,25 @@ +---------------------------------------------------------------- +local XRedPointConditionPurchase = {} +local SubCondition = nil +function XRedPointConditionPurchase.GetSubConditions() + SubCondition = SubCondition or + { + XRedPointConditions.Types.CONDITION_PURCHASE_LB_RED, + XRedPointConditions.Types.CONDITION_ACCUMULATE_PAY_RED, + } + return SubCondition +end + +function XRedPointConditionPurchase.Check() + local f = XRedPointConditionPurchaseLB.Check() + if f then + return true + end + f = XRedPointConditionPurchaseAccumulate.Check() + if f then + return true + end + return false +end + +return XRedPointConditionPurchase \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPurchaseAccumulate.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPurchaseAccumulate.lua new file mode 100644 index 00000000..04ed9e94 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPurchaseAccumulate.lua @@ -0,0 +1,20 @@ +---------------------------------------------------------------- +local XRedPointConditionPurchaseAccumulate = {} +local Events = nil + +function XRedPointConditionPurchaseAccumulate.GetSubEvents() + Events = Events or { + XRedPointEventElement.New(XEventId.EVENT_ACCUMULATED_UPDATE), + XRedPointEventElement.New(XEventId.EVENT_ACCUMULATED_REWARD) + } + return Events +end + +function XRedPointConditionPurchaseAccumulate.Check() + if XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.PurchaseAdd) then + return false + end + return XDataCenter.PurchaseManager.AccumulatePayRedPoint() +end + +return XRedPointConditionPurchaseAccumulate \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPurchaseLB.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPurchaseLB.lua new file mode 100644 index 00000000..5416c6e4 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionPurchaseLB.lua @@ -0,0 +1,16 @@ +---------------------------------------------------------------- +local XRedPointConditionPurchaseLB = {} +local Events = nil + +function XRedPointConditionPurchaseLB.GetSubEvents() + Events = Events or { + XRedPointEventElement.New(XEventId.EVENT_LB_UPDATE), + } + return Events +end + +function XRedPointConditionPurchaseLB.Check() + return XDataCenter.PurchaseManager.LBRedPoint() +end + +return XRedPointConditionPurchaseLB \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionReceiveChat.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionReceiveChat.lua new file mode 100644 index 00000000..59c1733f --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionReceiveChat.lua @@ -0,0 +1,19 @@ +---------------------------------------------------------------- +local XRedPointConditionReceiveChat = {} +local Events = nil + +function XRedPointConditionReceiveChat.GetSubEvents() + Events = Events or { + XRedPointEventElement.New(XEventId.EVENT_CHAT_RECEIVE_WORLD_MSG), + XRedPointEventElement.New(XEventId.EVENT_GUILD_RECEIVE_CHAT), + XRedPointEventElement.New(XEventId.EVENT_CHAT_RECEIVE_ROOM_MSG), + XRedPointEventElement.New(XEventId.EVENT_CHAT_RECEIVE_MENTOR_MSG), + } + return Events +end + +function XRedPointConditionReceiveChat.Check() + return true +end + +return XRedPointConditionReceiveChat \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionReformAllRedPoint.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionReformAllRedPoint.lua new file mode 100644 index 00000000..ae46b1a8 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionReformAllRedPoint.lua @@ -0,0 +1,22 @@ +local XRedPointConditionReformAllRedPoint = {} + +function XRedPointConditionReformAllRedPoint.Check() + if not XDataCenter.ReformActivityManager.GetIsOpen() then + return false + end + if not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.Reform) then + return false + end + if XRedPointConditionReformTaskGetReward.Check() then + return true + end + if XRedPointConditionReformBaseStageOpen.Check() then + return true + end + if XRedPointConditionReformEvolvableStageUnlock.Check() then + return true + end + return false +end + +return XRedPointConditionReformAllRedPoint \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionReformBaseStageOpen.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionReformBaseStageOpen.lua new file mode 100644 index 00000000..bd8e52bc --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionReformBaseStageOpen.lua @@ -0,0 +1,14 @@ +local XRedPointConditionReformBaseStageOpen = {} + +function XRedPointConditionReformBaseStageOpen.GetEvents() + if XRedPointConditionReformBaseStageOpen.Events == nil then + XRedPointConditionReformBaseStageOpen.Events = {} + end + return XRedPointConditionReformBaseStageOpen.Events +end + +function XRedPointConditionReformBaseStageOpen.Check(baseStageId) + return XDataCenter.ReformActivityManager.CheckBaseStageIsShowRedDot(baseStageId) +end + +return XRedPointConditionReformBaseStageOpen \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionReformEvolvableStageUnlock.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionReformEvolvableStageUnlock.lua new file mode 100644 index 00000000..7a0c26e5 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionReformEvolvableStageUnlock.lua @@ -0,0 +1,15 @@ +local XRedPointConditionReformEvolvableStageUnlock = {} + +function XRedPointConditionReformEvolvableStageUnlock.GetEvents() + if XRedPointConditionReformEvolvableStageUnlock.Events == nil then + XRedPointConditionReformEvolvableStageUnlock.Events = { } + end + return XRedPointConditionReformEvolvableStageUnlock.Events +end + +function XRedPointConditionReformEvolvableStageUnlock.Check(args) + args = args or {} + return XDataCenter.ReformActivityManager.CheckEvolvableDiffIsShowRedDot(args.BaseStageId, args.EvolvableDiffIndex) +end + +return XRedPointConditionReformEvolvableStageUnlock \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionReformTaskGetReward.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionReformTaskGetReward.lua new file mode 100644 index 00000000..df0014e5 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionReformTaskGetReward.lua @@ -0,0 +1,22 @@ +local XRedPointConditionReformTaskGetReward = {} + +function XRedPointConditionReformTaskGetReward.GetEvents() + if XRedPointConditionReformTaskGetReward.Events == nil then + XRedPointConditionReformTaskGetReward.Events = { + XRedPointEventElement.New(XEventId.EVENT_FINISH_TASK) + } + end + return XRedPointConditionReformTaskGetReward.Events +end + +function XRedPointConditionReformTaskGetReward.Check() + local taskDatas = XDataCenter.TaskManager.GetTaskList(TaskType.Reform) + for _, taskData in pairs(taskDatas) do + if taskData.State == XDataCenter.TaskManager.TaskState.Achieved then + return true + end + end + return false +end + +return XRedPointConditionReformTaskGetReward \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionRegression.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionRegression.lua new file mode 100644 index 00000000..ffdbc8d3 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionRegression.lua @@ -0,0 +1,25 @@ +-- Author: wujie +-- Note: 回归活动红点 +local XRedPointConditionRegression = {} +local Events = nil +local SubCondition = nil + +function XRedPointConditionRegression.GetSubEvents() + Events = Events or { + XRedPointEventElement.New(XEventId.EVENT_REGRESSION_OPEN_STATUS_UPDATE), + } + return Events +end + +function XRedPointConditionRegression.GetSubConditions() + SubCondition = SubCondition or { + XRedPointConditions.Types.CONDITION_REGRESSION_TASK, + } + return SubCondition +end + +function XRedPointConditionRegression.Check() + return XRedPointConditionRegressionTask.Check() +end + +return XRedPointConditionRegression \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionRegressionTask.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionRegressionTask.lua new file mode 100644 index 00000000..92825137 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionRegressionTask.lua @@ -0,0 +1,21 @@ +-- Author: wujie +-- Note: 回归活动任务红点 +local XRedPointConditionRegressionTask = {} +local Events = nil + +function XRedPointConditionRegressionTask.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_TASK_SYNC), + XRedPointEventElement.New(XEventId.EVENT_REGRESSION_TASK_SCHEDULE_UPDATE), + XRedPointEventElement.New(XEventId.EVENT_REGRESSION_TASK_SCHEDULE_REWARD_GET), + } + return Events +end + +function XRedPointConditionRegressionTask.Check() + return XDataCenter.RegressionManager.IsRegressionActivityOpen(XRegressionConfigs.ActivityType.Task) + and XDataCenter.RegressionManager.IsTaskHaveRedPoint() +end + +return XRedPointConditionRegressionTask \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionRegressionTaskType.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionRegressionTaskType.lua new file mode 100644 index 00000000..62627e70 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionRegressionTaskType.lua @@ -0,0 +1,20 @@ +-- +-- Author: wujie +-- Note: 回归活动任务红点 + +local XRedPointConditionRegressionTaskType = {} +local Events = nil + +function XRedPointConditionRegressionTaskType.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_TASK_SYNC), + } + return Events +end + +function XRedPointConditionRegressionTaskType.Check(type) + return XDataCenter.RegressionManager.IsTaskHaveRedPointByType(type) +end + +return XRedPointConditionRegressionTaskType \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionRepeatChallengeChapterReward.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionRepeatChallengeChapterReward.lua new file mode 100644 index 00000000..ff8d4591 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionRepeatChallengeChapterReward.lua @@ -0,0 +1,9 @@ +---------------------------------------------------------------- +--节红点检测 +local XRedPointConditionRepeatChallengeChapterReward = {} + +function XRedPointConditionRepeatChallengeChapterReward.Check(chapterId) + return XDataCenter.FubenRepeatChallengeManager.CheckChapterRewardCanGetReal(chapterId) +end + +return XRedPointConditionRepeatChallengeChapterReward \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionRepeatChallengeReward.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionRepeatChallengeReward.lua new file mode 100644 index 00000000..31544ee9 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionRepeatChallengeReward.lua @@ -0,0 +1,23 @@ +--角色入口红点检测 +local XRedPointConditionRepeatChallengeReward = {} +local SubCondition = nil +function XRedPointConditionRepeatChallengeReward.GetSubConditions() + SubCondition = SubCondition or { + XRedPointConditions.Types.CONDITION_REPEAT_CHALLENGE_CHAPTER_REWARD, + } + return SubCondition +end + +function XRedPointConditionRepeatChallengeReward.Check() + local allChapterIds = XDataCenter.FubenRepeatChallengeManager.GetAllChapterIds() + + for _, chapterId in pairs(allChapterIds) do + if XRedPointConditionRepeatChallengeChapterReward.Check(chapterId) then + return true + end + end + + return false +end + +return XRedPointConditionRepeatChallengeReward \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionRogueLikeMain.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionRogueLikeMain.lua new file mode 100644 index 00000000..27fd46b1 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionRogueLikeMain.lua @@ -0,0 +1,24 @@ +---------------------------------------------------------------- +--roguelike爬塔:每日行动力不为零的红点检测 + +local XRedPointConditionRogueLikeMain = {} +local Events = nil +function XRedPointConditionRogueLikeMain.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_ROGUELIKE_ACTIONPOINT_CHARACTER_CHANGED), + } + return Events +end + +function XRedPointConditionRogueLikeMain.Check() + local isOpen = XActivityBrieIsOpen.Get(XActivityBriefConfigs.ActivityGroupId.RougueLike) + if isOpen then + local actionPoint = XDataCenter.FubenRogueLikeManager.GetRogueLikeActionPoint() + return actionPoint > 0 + else + return false + end +end + +return XRedPointConditionRogueLikeMain \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionRpgMakerGame.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionRpgMakerGame.lua new file mode 100644 index 00000000..f733050b --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionRpgMakerGame.lua @@ -0,0 +1,11 @@ + +local XRedPointConditionRpgMakerGame = {} + +function XRedPointConditionRpgMakerGame.Check() + if XDataCenter.RpgMakerGameManager.CheckRedPoint() then + return true + end + return false +end + +return XRedPointConditionRpgMakerGame \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionRpgTower.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionRpgTower.lua new file mode 100644 index 00000000..ff014503 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionRpgTower.lua @@ -0,0 +1,27 @@ +---------------------------------------------------------------- +--RPG玩法:有可挑战关卡 + +local XRedPointConditionRpgTower = {} +local Events = nil +function XRedPointConditionRpgTower.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_RPGTOWER_CHALLENGE_COUNT_CHANGE), + } + return Events +end + +function XRedPointConditionRpgTower.Check() + local isOpen = XActivityBrieIsOpen.Get(XActivityBriefConfigs.ActivityGroupId.RpgTower) + if isOpen then + if XDataCenter.RpgTowerManager.GetChallengeCount() > 0 and XDataCenter.RpgTowerManager.GetHaveNewStage() then + return true + else + return false + end + else + return false + end +end + +return XRedPointConditionRpgTower \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionRpgTowerDailyRewardRed.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionRpgTowerDailyRewardRed.lua new file mode 100644 index 00000000..c756b52c --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionRpgTowerDailyRewardRed.lua @@ -0,0 +1,17 @@ +-- 可领取每日任务时红点 + +local XRedPointConditionRpgTowerDailyRewardRed = {} +local Events = nil +function XRedPointConditionRpgTowerDailyRewardRed.GetSubEvents() + Events = Events or { + XRedPointEventElement.New(XEventId.EVENT_RPGTOWER_REFRESH_DAILYREWARD) + } + return Events +end + +function XRedPointConditionRpgTowerDailyRewardRed.Check() + return XDataCenter.RpgTowerManager.GetCanReceiveSupply() + and (XDataCenter.RpgTowerManager.GetCurrentLevel() < XDataCenter.RpgTowerManager.GetMaxLevel()) +end + +return XRedPointConditionRpgTowerDailyRewardRed \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionRpgTowerTaskRed.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionRpgTowerTaskRed.lua new file mode 100644 index 00000000..f1d58ce3 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionRpgTowerTaskRed.lua @@ -0,0 +1,15 @@ +-- 有可领取奖励的任务时红点 +local XRedPointConditionRpgTowerTaskRed = {} +local Events = nil +function XRedPointConditionRpgTowerTaskRed.GetSubEvents() + Events = Events or { + XRedPointEventElement.New(XEventId.EVENT_TASK_SYNC) + } + return Events +end + +function XRedPointConditionRpgTowerTaskRed.Check() + return XDataCenter.TaskManager.GetRpgTowerHaveAchievedTask() +end + +return XRedPointConditionRpgTowerTaskRed \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionRpgTowerTeamRed.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionRpgTowerTeamRed.lua new file mode 100644 index 00000000..699f09b6 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionRpgTowerTeamRed.lua @@ -0,0 +1,15 @@ +-- 兵法蓝图有可升星角色时红点 +local XRedPointConditionRpgTowerTeamRed = {} +local Events = nil +function XRedPointConditionRpgTowerTeamRed.GetSubEvents() + Events = Events or { + XRedPointEventElement.New(XEventId.EVENT_RPGTOWER_MEMBERCHANGE) + } + return Events +end + +function XRedPointConditionRpgTowerTeamRed.Check() + return XDataCenter.RpgTowerManager.GetMemberCanActiveTalent() +end + +return XRedPointConditionRpgTowerTeamRed \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSTRoleInDult.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSTRoleInDult.lua new file mode 100644 index 00000000..4454a4a1 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSTRoleInDult.lua @@ -0,0 +1,10 @@ +local XRedPointConditionSTRoleInDult = {} + +function XRedPointConditionSTRoleInDult.Check() + local superTowerManager = XDataCenter.SuperTowerManager + -- 活动没开启不处理 + if superTowerManager.GetIsEnd() then return false end + return XDataCenter.SuperTowerManager.GetRoleManager():CheckRoleInDultShowRedDot() +end + +return XRedPointConditionSTRoleInDult \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSTRoleLevelUp.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSTRoleLevelUp.lua new file mode 100644 index 00000000..f9e29f68 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSTRoleLevelUp.lua @@ -0,0 +1,11 @@ +local XRedPointConditionSTRoleLevelUp = {} + +function XRedPointConditionSTRoleLevelUp.Check(roleId) + local superTowerManager = XDataCenter.SuperTowerManager + -- 活动没开启不处理 + if superTowerManager.GetIsEnd() then return false end + return XDataCenter.SuperTowerManager.GetRoleManager() + :CheckRolesSuperLevelUpShowRedDot(roleId) +end + +return XRedPointConditionSTRoleLevelUp \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSTRolePlugin.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSTRolePlugin.lua new file mode 100644 index 00000000..0f433253 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSTRolePlugin.lua @@ -0,0 +1,11 @@ +local XRedPointConditionSTRolePlugin = {} + +function XRedPointConditionSTRolePlugin.Check(roleId) + local superTowerManager = XDataCenter.SuperTowerManager + -- 活动没开启不处理 + if superTowerManager.GetIsEnd() then return false end + return XDataCenter.SuperTowerManager.GetRoleManager() + :CheckRolePluginShowRedDot(roleId) +end + +return XRedPointConditionSTRolePlugin \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionShortStory.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionShortStory.lua new file mode 100644 index 00000000..011662f8 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionShortStory.lua @@ -0,0 +1,33 @@ + +---------------------------------------------------------------- +--短篇故事解锁红点检测 +local XRedPointConditionShortStory = {} +local Events = nil +function XRedPointConditionShortStory.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_CHARACTER_LEVEL_UP), + XRedPointEventElement.New(XEventId.EVENT_FUBEN_SETTLE_REWARD), + XRedPointEventElement.New(XEventId.EVENT_STORY_DISTORY), + } + return Events +end + +function XRedPointConditionShortStory.Check(characterId) + if not characterId then + return false + end + local isUnlock + local desc = "" + isUnlock,desc = XConditionManager.CheckCondition(characterId.ConditionId) + local played = XDataCenter.ActivityBriefManager.GetPlayedStoryDic() + if not isUnlock then + return false + end + if played[characterId.Id] == true then + return false + end + return isUnlock +end + +return XRedPointConditionShortStory \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSimulatedCombat.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSimulatedCombat.lua new file mode 100644 index 00000000..2f506837 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSimulatedCombat.lua @@ -0,0 +1,39 @@ + +local XRedPointConditionSimulatedCombat = {} +local SubCondition = nil +function XRedPointConditionSimulatedCombat.GetSubConditions() + SubCondition = SubCondition or + { + XRedPointConditions.Types.CONDITION_SIMULATED_COMBAT_CHALLENGE, + XRedPointConditions.Types.CONDITION_SIMULATED_COMBAT_POINT, + XRedPointConditions.Types.CONDITION_SIMULATED_COMBAT_STAR, + XRedPointConditions.Types.CONDITION_SIMULATED_COMBAT_TASK, + } + return SubCondition +end + +function XRedPointConditionSimulatedCombat.Check() + if not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.FubenSimulatedCombat) then + return false + end + + if not XDataCenter.FubenSimulatedCombatManager.GetCurrentActTemplate() then + return false + end + + if XRedPointConditionSimulatedCombatPoint.Check() then + return true + end + + if XRedPointConditionSimulatedCombatTask.Check() then + return true + end + + if XRedPointConditionSimulatedCombatChallenge.Check() then + return true + end + + return false +end + +return XRedPointConditionSimulatedCombat \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSimulatedCombatChallenge.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSimulatedCombatChallenge.lua new file mode 100644 index 00000000..b0b2ff57 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSimulatedCombatChallenge.lua @@ -0,0 +1,32 @@ +---------------------------------------------------------------- +-- 挑战模式红点 +local XRedPointConditionSimulatedCombatChallenge = {} +local Events = nil +function XRedPointConditionSimulatedCombatChallenge.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_FUBEN_SIMUCOMBAT_UPDATE), + } + return Events +end + +function XRedPointConditionSimulatedCombatChallenge.Check() + local actTemplate = XDataCenter.FubenSimulatedCombatManager.GetCurrentActTemplate() + if not actTemplate then return false end + local isOpen = XConditionManager.CheckCondition(actTemplate.HardConditionId) + if not isOpen then + return false + end + local remainTime = XDataCenter.FubenSimulatedCombatManager.GetDailyRewardRemainCount() + if remainTime > 0 then + return true + end + + if XRedPointConditionSimulatedCombatStar.Check() then + return true + end + + return false +end + +return XRedPointConditionSimulatedCombatChallenge \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSimulatedCombatPoint.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSimulatedCombatPoint.lua new file mode 100644 index 00000000..2831e844 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSimulatedCombatPoint.lua @@ -0,0 +1,30 @@ +---------------------------------------------------------------- +-- +local XRedPointConditionSimulatedCombatPoint = {} +local Events = nil +function XRedPointConditionSimulatedCombatPoint.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_FUBEN_SIMUCOMBAT_UPDATE), + } + return Events +end + +function XRedPointConditionSimulatedCombatPoint.Check() + local actTemplate = XDataCenter.FubenSimulatedCombatManager.GetCurrentActTemplate() + if not actTemplate then return false end + + local pointCount = XDataCenter.ItemManager.GetCount(actTemplate.PointId) + local pointRewardCfg = XFubenSimulatedCombatConfig.GetPointReward() + + for index in ipairs(pointRewardCfg) do + local pointCfg = XFubenSimulatedCombatConfig.GetPointRewardById(index) + if pointCount >= pointCfg.NeedPoint and + not XDataCenter.FubenSimulatedCombatManager.CheckPointRewardGet(pointCfg.Id) then + return true + end + end + return false +end + +return XRedPointConditionSimulatedCombatPoint \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSimulatedCombatStar.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSimulatedCombatStar.lua new file mode 100644 index 00000000..733d4a0f --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSimulatedCombatStar.lua @@ -0,0 +1,22 @@ +---------------------------------------------------------------- +-- +local XRedPointConditionSimulatedCombatStar = {} +local Events = nil +function XRedPointConditionSimulatedCombatStar.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_FUBEN_SIMUCOMBAT_UPDATE), + } + return Events +end + +function XRedPointConditionSimulatedCombatStar.Check() + local actTemplate = XDataCenter.FubenSimulatedCombatManager.GetCurrentActTemplate() + if not actTemplate then return false end + + local _, canGet = XDataCenter.FubenSimulatedCombatManager.GetStarRewardList() + + return canGet +end + +return XRedPointConditionSimulatedCombatStar \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSimulatedCombatTask.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSimulatedCombatTask.lua new file mode 100644 index 00000000..97723ac8 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSimulatedCombatTask.lua @@ -0,0 +1,38 @@ +---------------------------------------------------------------- +-- 模拟作战每日任务红点 +local XRedPointConditionSimulatedCombatTask = {} +local Events = nil +function XRedPointConditionSimulatedCombatTask.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_FUBEN_SIMUCOMBAT_UPDATE), + } + return Events +end + +function XRedPointConditionSimulatedCombatTask.Check() + local actTemplate = XDataCenter.FubenSimulatedCombatManager.GetCurrentActTemplate() + if not actTemplate then return false end + + --若玩家已领取所有积分奖励,则蓝点提示消除 + local pointRewardCfg = XFubenSimulatedCombatConfig.GetPointReward() + local isGetAllPointReward = true + for index in ipairs(pointRewardCfg) do + local pointCfg = XFubenSimulatedCombatConfig.GetPointRewardById(index) + if not XDataCenter.FubenSimulatedCombatManager.CheckPointRewardGet(pointCfg.Id) then + isGetAllPointReward = false + end + end + if isGetAllPointReward then return false end + + local taskList = XDataCenter.TaskManager.GetSimulatedCombatTaskList() + for _, task in ipairs(taskList) do + if task.State == XDataCenter.TaskManager.TaskState.Achieved then + return true + end + end + + return false +end + +return XRedPointConditionSimulatedCombatTask \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSlotMachine.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSlotMachine.lua new file mode 100644 index 00000000..4cc38bb7 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSlotMachine.lua @@ -0,0 +1,11 @@ + +local XRedPointConditionSlotMachine = {} + +function XRedPointConditionSlotMachine.Check() + if XDataCenter.SlotMachineManager.CheckRedPoint() then + return true + end + return false +end + +return XRedPointConditionSlotMachine \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSlotMachineL.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSlotMachineL.lua new file mode 100644 index 00000000..1f69ee46 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSlotMachineL.lua @@ -0,0 +1,11 @@ + +local XRedPointConditionSlotMachineL = {} + +function XRedPointConditionSlotMachineL.Check() + if XDataCenter.SlotMachineManager.CheckRedPointL() then + return true + end + return false +end + +return XRedPointConditionSlotMachineL \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSpecialTrain.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSpecialTrain.lua new file mode 100644 index 00000000..1662bb2a --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSpecialTrain.lua @@ -0,0 +1,29 @@ +---------------------------------------------------------------- +local XRedPointConditionSpecialTrain = {} +local Events = nil +local SubCondition = nil +function XRedPointConditionSpecialTrain.GetSubEvents() + Events = Events or { + XRedPointEventElement.New(XEventId.EVENT_TASK_SYNC), + } + return Events +end + +function XRedPointConditionSpecialTrain.GetSubConditions() + SubCondition = SubCondition or { + XRedPointConditions.Types.CONDITION_SPECIALTRAINPOINT_RED, + } + return SubCondition +end + +function XRedPointConditionSpecialTrain.Check() + if XDataCenter.FubenSpecialTrainManager.CheckConditionSpecialTrainRedPoint() then + return true + end + if XRedPointConditionSpecialTrainPoint.Check() then + return true + end + return false +end + +return XRedPointConditionSpecialTrain \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSpecialTrainPoint.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSpecialTrainPoint.lua new file mode 100644 index 00000000..7c2d299e --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSpecialTrainPoint.lua @@ -0,0 +1,16 @@ +local XRedPointConditionSpecialTrainPoint = {} +local Events = nil + +function XRedPointConditionSpecialTrainPoint.GetSubEvents() + Events = Events or { + + XRedPointEventElement.New(XEventId.EVENT_ITEM_COUNT_UPDATE_PREFIX .. XDataCenter.FubenSpecialTrainManager.GetSpecialTrainPointItemId()), + } + return Events +end + +function XRedPointConditionSpecialTrainPoint.Check() + return XDataCenter.FubenSpecialTrainManager.CheckConditionSpecialTrainPointRedPoint() +end + +return XRedPointConditionSpecialTrainPoint \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSpringFestivalBagRed.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSpringFestivalBagRed.lua new file mode 100644 index 00000000..30d26d5d --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSpringFestivalBagRed.lua @@ -0,0 +1,17 @@ + +local XRedPointConditionSpringFestivalBagRed = {} +local Events = nil + +function XRedPointConditionSpringFestivalBagRed.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_SPRING_FESTIVAL_GIFT_BAG_RED), + } + return Events +end + +function XRedPointConditionSpringFestivalBagRed.Check() + return XDataCenter.SpringFestivalActivityManager.CheckHasUnReceiveGift() +end + +return XRedPointConditionSpringFestivalBagRed \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSpringFestivalRewardRed.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSpringFestivalRewardRed.lua new file mode 100644 index 00000000..8da409f5 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSpringFestivalRewardRed.lua @@ -0,0 +1,29 @@ + +local XRedPointConditionSpringFestivalRewardRed = {} +local Events = nil + +function XRedPointConditionSpringFestivalRewardRed.GetSubEvents() + local itemsEventId = XSpringFestivalActivityConfigs.GetWordItemsEventId() + Events = {XRedPointEventElement.New(XEventId.EVENT_SPRING_FESTIVAL_REWARD_RED)} + + for i = 1,#itemsEventId do + local element = XRedPointEventElement.New(itemsEventId[i]) + table.insert(Events,element) + end + return Events +end + +function XRedPointConditionSpringFestivalRewardRed.Check(type) + if type == XSpringFestivalActivityConfigs.CollectWordsRewardType.Final then + return XDataCenter.SpringFestivalActivityManager.CheckCanGetCollectWordsReward(type) + else + local rewardTimes = XDataCenter.SpringFestivalActivityManager.GetAlreadyRecvTimes(type) + local maxTimes = XSpringFestivalActivityConfigs.GetCollectWordsRewardMaxCount(type) + if rewardTimes >= maxTimes then + return false + end + return XDataCenter.SpringFestivalActivityManager.CheckCanGetRewardWithoutUniversal(type) + end +end + +return XRedPointConditionSpringFestivalRewardRed \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSpringFestivalTaskRed.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSpringFestivalTaskRed.lua new file mode 100644 index 00000000..0d161097 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSpringFestivalTaskRed.lua @@ -0,0 +1,16 @@ +local XRedPointConditionSpringFestivalTaskRed = {} +local Events = nil + +function XRedPointConditionSpringFestivalTaskRed.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_FINISH_TASK), + } + return Events +end + +function XRedPointConditionSpringFestivalTaskRed.Check(id) + return XDataCenter.ActivityManager.CheckRedPointByActivityId(id) +end + +return XRedPointConditionSpringFestivalTaskRed \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionStrongholdMineralLeft.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionStrongholdMineralLeft.lua new file mode 100644 index 00000000..fc7e7c3e --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionStrongholdMineralLeft.lua @@ -0,0 +1,11 @@ +local XRedPointConditionStrongholdMineralLeft = {} + +function XRedPointConditionStrongholdMineralLeft.Check() + if not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.Stronghold) then + return false + end + + return XDataCenter.StrongholdManager.HasMineralLeft() +end + +return XRedPointConditionStrongholdMineralLeft \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionStrongholdRewardCanGet.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionStrongholdRewardCanGet.lua new file mode 100644 index 00000000..53ce37e2 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionStrongholdRewardCanGet.lua @@ -0,0 +1,21 @@ +local Events = nil + +local XRedPointConditionStrongholdRewardCanGet = {} + +function XRedPointConditionStrongholdRewardCanGet.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_STRONGHOLD_FINISH_REWARDS_CHANGE), + } + return Events +end + +function XRedPointConditionStrongholdRewardCanGet.Check() + if not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.Stronghold) then + return false + end + + return XDataCenter.StrongholdManager.IsAnyRewardCanGet() +end + +return XRedPointConditionStrongholdRewardCanGet \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSubMenuNewNotices.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSubMenuNewNotices.lua new file mode 100644 index 00000000..5565cd6d --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionSubMenuNewNotices.lua @@ -0,0 +1,16 @@ +---------------------------------------------------------------- +local XRedPointConditionSubMenuNewNotices = {} +local Events = nil + +function XRedPointConditionSubMenuNewNotices.GetSubEvents() + Events = Events or { + XRedPointEventElement.New(XEventId.EVENT_ACTIVITY_SUBMENU_READ_CHANGE), + } + return Events +end + +function XRedPointConditionSubMenuNewNotices.Check() + return XDataCenter.NoticeManager.CheckSubMenuRedPoint() +end + +return XRedPointConditionSubMenuNewNotices \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionTRPGChapterReward.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionTRPGChapterReward.lua new file mode 100644 index 00000000..3e99fa2f --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionTRPGChapterReward.lua @@ -0,0 +1,16 @@ +local XRedPointConditionTRPGChapterReward = {} +local Events = nil + +function XRedPointConditionTRPGChapterReward.GetSubEvents() + -- Events = Events or + -- { + -- XRedPointEventElement.New(XEventId.EVENT_FUBEN_CHAPTER_REWARD) + -- } + -- return Events +end + +function XRedPointConditionTRPGChapterReward.Check(chapterId) + -- return XDataCenter.FubenMainLineManager.CheckTreasureReward(chapterId) +end + +return XRedPointConditionTRPGChapterReward \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionTRPGMainMode.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionTRPGMainMode.lua new file mode 100644 index 00000000..e416c084 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionTRPGMainMode.lua @@ -0,0 +1,30 @@ +local XRedPointConditionTRPGMainMode = {} +local SubCondition = nil + +function XRedPointConditionTRPGMainMode.GetSubConditions() + SubCondition = SubCondition or { + XRedPointConditions.Types.CONDITION_TRPG_TRUTH_ROAD_REWARD, + XRedPointConditions.Types.CONDITION_TRPG_COLLECTION_MEMOIR, + XRedPointConditions.Types.CONDITION_TRPG_AREA_REWARD, + XRedPointConditions.CONDITION_TRPG_WORLD_BOSS_REWARD, + } + return SubCondition +end + +function XRedPointConditionTRPGMainMode.Check() + if XRedPointTRPGTruthRoadReward.Check() then + return true + end + if XRedPointTRPGCollectionMemoir.Check() then + return true + end + if XRedPointTRPGAreaReward.Check() then + return true + end + if XRedPointTRPGWorldBossReward.Check() then + return true + end + return false +end + +return XRedPointConditionTRPGMainMode \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionTRPGMainView.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionTRPGMainView.lua new file mode 100644 index 00000000..c175afa2 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionTRPGMainView.lua @@ -0,0 +1,33 @@ +local XRedPointConditionTRPGMainView = {} +local SubCondition = nil + +function XRedPointConditionTRPGMainView.GetSubConditions() + SubCondition = SubCondition or { + XRedPointConditions.Types.CONDITION_TRPG_MAIN_MODE, + XRedPointConditions.Types.CONDITION_TRPG_SECOND_MAIN_REWARD, + } + return SubCondition +end + +function XRedPointConditionTRPGMainView.Check(chapterId) + if chapterId ~= XDataCenter.FubenMainLineManager.TRPGChapterId then + return false + end + + local chapterInfo = XDataCenter.FubenMainLineManager.GetChapterInfo(chapterId) + if (not chapterInfo) or (not chapterInfo.Unlock and not chapterInfo.IsOpen) then + return false + end + + if XRedPointConditionTRPGMainMode.Check() then + return true + end + + if XRedPointTRPGSecondMainReward.Check() then + return true + end + + return false +end + +return XRedPointConditionTRPGMainView \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionTaskCourse.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionTaskCourse.lua new file mode 100644 index 00000000..c4f59231 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionTaskCourse.lua @@ -0,0 +1,17 @@ +---------------------------------------------------------------- +--单个类型任务奖励检测 +local XRedPointConditionTaskCourse = {} +local Events = nil +function XRedPointConditionTaskCourse.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_TASK_COURSE_REWAED), + } + return Events +end + +function XRedPointConditionTaskCourse.Check() + return XDataCenter.TaskManager.CheckAllCourseCanGet() +end + +return XRedPointConditionTaskCourse \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionTaskLimited.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionTaskLimited.lua new file mode 100644 index 00000000..9a976894 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionTaskLimited.lua @@ -0,0 +1,25 @@ + +local XRedPointConditionTaskLimited = {} +local Events = nil +function XRedPointConditionTaskLimited.GetSubEvents() + Events = Events or { + XRedPointEventElement.New(XEventId.EVENT_TASK_SYNC), + } + return Events +end + +function XRedPointConditionTaskLimited.Check(limitedId) + if not limitedId then + return false + end + for _, taskGroupId in pairs(limitedId) do + if XDataCenter.TaskManager.CheckLimitTaskList(taskGroupId) then + return true + end + end + return false +end + + + +return XRedPointConditionTaskLimited \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionTaskType.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionTaskType.lua new file mode 100644 index 00000000..8510ca83 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionTaskType.lua @@ -0,0 +1,69 @@ +---------------------------------------------------------------- +--单个类型任务奖励检测 +local XRedPointConditionTaskType = {} +local Events = nil +function XRedPointConditionTaskType.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_TASK_SYNC), + XRedPointEventElement.New(XEventId.EVENT_FUNCTION_OPEN_COMPLETE), + } + return Events +end + +function XRedPointConditionTaskType.Check(taskTypeList) + if type(taskTypeList) == "table" then + for _, taskType in pairs(taskTypeList) do + if XRedPointConditionTaskType.CheckImpl(taskType) then + return true + end + end + else + return XRedPointConditionTaskType.CheckImpl(taskTypeList) + end + + return false +end + +function XRedPointConditionTaskType.CheckImpl(taskType) + if taskType == XDataCenter.TaskManager.TaskType.Activity and (not XFunctionManager.JudgeOpen(XFunctionManager.FunctionName.TaskActivity) + or XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.TaskActivity)) then + return false + end + + if taskType == XDataCenter.TaskManager.TaskType.Daily and (not XFunctionManager.JudgeOpen(XFunctionManager.FunctionName.TaskDay) + or XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.TaskDay)) then + return false + end + + if taskType == XDataCenter.TaskManager.TaskType.Weekly and (not XFunctionManager.JudgeOpen(XFunctionManager.FunctionName.TaskWeekly) + or XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.TaskWeekly)) then + return false + end + + if taskType == XDataCenter.TaskManager.TaskType.Story and XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.TaskStory) then + return false + end + + if taskType == XDataCenter.TaskManager.TaskType.ArenaOnlineWeekly and (not XFunctionManager.JudgeOpen(XFunctionManager.FunctionName.ArenaOnline) or XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.ArenaOnline)) then + return false + end + + if taskType == XDataCenter.TaskManager.TaskType.InfestorWeekly and (not XFunctionManager.JudgeOpen(XFunctionManager.FunctionName.FubenInfesotorExplore) or XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.FubenInfesotorExplore)) then + return false + end + + if taskType == XDataCenter.TaskManager.TaskType.Daily then --日活跃 + if XDataCenter.TaskManager.CheckHasDailyActiveTaskReward() then + return true + end + --去掉周任务判断 + -- if XDataCenter.TaskManager.CheckHasWeekActiveTaskReward() then + -- return true + -- end + end + + return XDataCenter.TaskManager.GetIsRewardForEx(taskType) +end + +return XRedPointConditionTaskType \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionTaskWeekActive.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionTaskWeekActive.lua new file mode 100644 index 00000000..838ed2cd --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionTaskWeekActive.lua @@ -0,0 +1,21 @@ +---------------------------------------------------------------- +--单个类型任务奖励检测 +local XRedPointConditionTaskWeekActive = {} +local Events = nil +function XRedPointConditionTaskWeekActive.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_TASK_SYNC), + } + return Events +end + +function XRedPointConditionTaskWeekActive.Check() + if not XFunctionManager.JudgeOpen(XFunctionManager.FunctionName.TaskActivity) then + return false + end + + return XDataCenter.TaskManager.CheckHasWeekActiveTaskReward() +end + +return XRedPointConditionTaskWeekActive \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionTrial.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionTrial.lua new file mode 100644 index 00000000..5b983612 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionTrial.lua @@ -0,0 +1,31 @@ +---------------------------------------------------------------- +local XRedPointConditionTrial = {} +local SubCondition = nil +function XRedPointConditionTrial.GetSubConditions() + SubCondition = + SubCondition or + { + XRedPointConditions.Types.CONDITION_TRIAL_REWARD_RED + } + return SubCondition +end + +function XRedPointConditionTrial.Check() + -- 没有开启 + if XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.FubenChallengeTrial) then + return false + end + + local isOpen = XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.FubenChallengeTrial) + if not isOpen then + return false + end + + if XRedPointConditionTrialReward.Check() then + return true + end + + return false +end + +return XRedPointConditionTrial \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionTrialReward.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionTrialReward.lua new file mode 100644 index 00000000..25f80690 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionTrialReward.lua @@ -0,0 +1,31 @@ +---------------------------------------------------------------- +--关卡奖励 +local XRedPointConditionTrialReward = {} +local Events = nil + +function XRedPointConditionTrialReward.GetSubEvents() + Events = Events or { + XRedPointEventElement.New(XEventId.EVENT_TRIAL_LEVEL_FINISH), + } + return Events +end + +function XRedPointConditionTrialReward.Check() + local cfg = XTrialConfigs.GetForTotalData() + for _, v in pairs(cfg) do + if XDataCenter.TrialManager.TrialLevelRewardGetSignRedPoint(v.Id) then + return true + end + end + + cfg = XTrialConfigs.GetBackEndTotalData() + for _, v in pairs(cfg) do + if XDataCenter.TrialManager.TrialLevelRewardGetSignRedPoint(v.Id) then + return true + end + end + + return XDataCenter.TrialManager.TrialTypeRewardRedPoint() +end + +return XRedPointConditionTrialReward \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionTrialUnlock.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionTrialUnlock.lua new file mode 100644 index 00000000..0efe07ef --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionTrialUnlock.lua @@ -0,0 +1,18 @@ +---------------------------------------------------------------- +--关卡解锁 +local XRedPointConditionTrialUnlock = {} +local Events = nil + +function XRedPointConditionTrialUnlock.GetSubEvents() + Events = Events or { + XRedPointEventElement.New(XEventId.EVENT_TRIAL_LEVEL_FINISH), + XRedPointEventElement.New(XEventId.EVENT_PLAYER_LEVEL_CHANGE), + } + return Events +end + +function XRedPointConditionTrialUnlock.Check() + return XDataCenter.TrialManager.TrialLevelLockSignRedPoint() +end + +return XRedPointConditionTrialUnlock \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionUnGuildNews.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionUnGuildNews.lua new file mode 100644 index 00000000..f1d5ada0 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionUnGuildNews.lua @@ -0,0 +1,28 @@ + +local XRedPointConditionUnGuildNews = {} +local Events = nil +function XRedPointConditionUnGuildNews.GetSubEvents() + Events = Events or { + XRedPointEventElement.New(XEventId.EVENT_GUILD_RECRUIT_LIST_CHANGED), + } + return Events +end + +function XRedPointConditionUnGuildNews.Check() + if not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.Guild) then + return false + end + + if XDataCenter.GuildManager.IsJoinGuild() then + return false + end + + if XDataCenter.GuildManager.HasGuildRecruitList() then + return true + end + + return false +end + + +return XRedPointConditionUnGuildNews \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionWhite2021Encounter.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionWhite2021Encounter.lua new file mode 100644 index 00000000..7659ed66 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionWhite2021Encounter.lua @@ -0,0 +1,17 @@ +--2021白色情人节活动偶遇红点 +local XRedPointConditionWhite2021Encounter = {} +local Events = nil +function XRedPointConditionWhite2021Encounter.GetSubEvents() + Events = Events or { + XRedPointEventElement.New(XEventId.EVENT_WHITEVALENTINE_CHARA_CHANGE), + XRedPointEventElement.New(XEventId.EVENT_ITEM_COUNT_UPDATE_PREFIX .. XDataCenter.WhiteValentineManager.GetGameController():GetCoinItemId()) + } + return Events +end + +function XRedPointConditionWhite2021Encounter.Check() + local GameController = XDataCenter.WhiteValentineManager.GetGameController() + return GameController:CheckCanEncounter() +end + +return XRedPointConditionWhite2021Encounter \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionWhite2021Invite.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionWhite2021Invite.lua new file mode 100644 index 00000000..579ab73b --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionWhite2021Invite.lua @@ -0,0 +1,16 @@ +--2021白色情人节活动邀约红点 +local XRedPointConditionWhite2021Invite = {} +local Events = nil +function XRedPointConditionWhite2021Invite.GetSubEvents() + Events = Events or { + XRedPointEventElement.New(XEventId.EVENT_WHITEVALENTINE_INVITE_CHANCE_REFRESH), + XRedPointEventElement.New(XEventId.EVENT_WHITEVALENTINE_CHARA_CHANGE) + } + return Events +end + +function XRedPointConditionWhite2021Invite.Check() + local GameController = XDataCenter.WhiteValentineManager.GetGameController() + return GameController:CheckCanInviteChara() +end +return XRedPointConditionWhite2021Invite \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionWhite2021Task.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionWhite2021Task.lua new file mode 100644 index 00000000..44bde0ae --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionWhite2021Task.lua @@ -0,0 +1,15 @@ +--白情约会活动有未领取任务时的红点 +local XRedPointConditionWhiteValentineTaskRed = {} +local Events = nil +function XRedPointConditionWhiteValentineTaskRed.GetSubEvents() + Events = Events or { + XRedPointEventElement.New(XEventId.EVENT_TASK_SYNC) + } + return Events +end + +function XRedPointConditionWhiteValentineTaskRed.Check() + return XDataCenter.TaskManager.GetWhiteValentineHaveAchievedTask() +end + +return XRedPointConditionWhiteValentineTaskRed \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionWhiteValentineTaskRed.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionWhiteValentineTaskRed.lua new file mode 100644 index 00000000..a941545a --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionWhiteValentineTaskRed.lua @@ -0,0 +1,17 @@ +--2021白色情人节活动任务红点 +local XRedPointConditionWhite2021Task = {} +local Events = nil +function XRedPointConditionWhite2021Task.GetSubEvents() + Events = Events or { + XRedPointEventElement.New(XEventId.EVENT_TASK_SYNC), + XRedPointEventElement.New(XEventId.EVENT_FINGER_GUESS_CHECK_EVENT_FINISH) + } + return Events +end + +function XRedPointConditionWhite2021Task.Check() + return XDataCenter.TaskManager.GetWhiteValentineHaveAchievedTask() or + XDataCenter.WhiteValentineManager.GetCanFinishEvent() +end + +return XRedPointConditionWhite2021Task \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionWindowsInlay.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionWindowsInlay.lua new file mode 100644 index 00000000..1407060f --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionWindowsInlay.lua @@ -0,0 +1,19 @@ +---------------------------------------------------------------- +--新手任务奖励检测 +local XRedPointConditionWindowsInlay = {} +local Events = nil + +function XRedPointConditionWindowsInlay.GetSubEvents() + Events = Events or + { + XRedPointEventElement.New(XEventId.EVENT_FUBEN_DAILY_REFRESH), + XRedPointEventElement.New(XEventId.EVENT_MAINUI_ENABLE), + } + return Events +end + +function XRedPointConditionWindowsInlay.Check() + return XDataCenter.MarketingActivityManager.IsShowWindowsInlayRedPoint() +end + +return XRedPointConditionWindowsInlay \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionWorldBossRed.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionWorldBossRed.lua new file mode 100644 index 00000000..59b3e5f5 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionWorldBossRed.lua @@ -0,0 +1,26 @@ +---------------------------------------------------------------- +local XRedPointConditionWorldBossRed = {} + +local Events = nil +function XRedPointConditionWorldBossRed.GetSubEvents() + Events = Events or + { + + } + return Events +end + +function XRedPointConditionWorldBossRed.Check() + if XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.WorldBoss) then + return false + end + if not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.WorldBoss) then + return false + end + if not XDataCenter.WorldBossManager.IsInActivity() then + return false + end + return XDataCenter.WorldBossManager.CheckWorldBossActivityRedPoint() or XDataCenter.WorldBossManager.CheckAnyTaskFinished() +end + +return XRedPointConditionWorldBossRed \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionZhouMuTask.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionZhouMuTask.lua new file mode 100644 index 00000000..ce78162c --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointConditionZhouMuTask.lua @@ -0,0 +1,24 @@ +-- 有可领取奖励的任务时红点 +local XRedPointConditionZhouMuTask = {} +local Events = nil + +function XRedPointConditionZhouMuTask.GetSubEvents() + Events = Events or { + XRedPointEventElement.New(XEventId.EVENT_TASK_SYNC) + } + return Events +end + +function XRedPointConditionZhouMuTask.Check(chapterMainId) + if chapterMainId == 0 then + return false + end + + local zhouMuId = XFubenMainLineConfigs.GetZhouMuId(chapterMainId) + if zhouMuId == 0 then + return false + end + return XDataCenter.FubenZhouMuManager.HasTaskReward(zhouMuId) +end + +return XRedPointConditionZhouMuTask \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointTRPGAreaReward.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointTRPGAreaReward.lua new file mode 100644 index 00000000..c160b863 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointTRPGAreaReward.lua @@ -0,0 +1,10 @@ + +---------------------------------------------------------------- +--主线跑团所有区域红点检测 +local XRedPointTRPGAreaReward = {} + +function XRedPointTRPGAreaReward.Check() + return XDataCenter.TRPGManager.CheckAllAreaReward() +end + +return XRedPointTRPGAreaReward \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointTRPGCollectionMemoir.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointTRPGCollectionMemoir.lua new file mode 100644 index 00000000..3a18f892 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointTRPGCollectionMemoir.lua @@ -0,0 +1,39 @@ + +---------------------------------------------------------------- +--主线跑团珍藏-回忆红点检测 +local XRedPointTRPGCollectionMemoir = {} +local Events = nil + +function XRedPointTRPGCollectionMemoir.GetSubEvents() + if not Events then + local redPointEventElementList = {} + local memoirStoryTemplate = XTRPGConfigs.GetMemoirStoryTemplate() + local unlockItemId + local aleardyUnlockItemIdList = {} + for id in pairs(memoirStoryTemplate) do + unlockItemId = XTRPGConfigs.GetMemoireStoryUnlockItemId(id) + if not aleardyUnlockItemIdList[unlockItemId] then + table.insert(redPointEventElementList, XRedPointEventElement.New(XEventId.EVENT_ITEM_COUNT_UPDATE_PREFIX .. unlockItemId)) + aleardyUnlockItemIdList[unlockItemId] = 1 + end + end + table.insert(redPointEventElementList, XRedPointEventElement.New(XEventId.EVENT_TRPG_GET_MEMOIR_REWARD)) + table.insert(redPointEventElementList, XRedPointEventElement.New(XEventId.EVENT_TRPG_FIRST_OPEN_COLLECTION)) + Events = redPointEventElementList + end + return Events +end + +function XRedPointTRPGCollectionMemoir.Check() + local ret = XTRPGConfigs.CheckButtonCondition(XTRPGConfigs.ButtonConditionId.Collection) + if not ret then + return false + end + + if not XDataCenter.TRPGManager.CheckIsAlreadyOpenCollection() then + return true + end + return XDataCenter.TRPGManager.CheckFirstPlayMemoirStory() +end + +return XRedPointTRPGCollectionMemoir \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointTRPGRoleTalent.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointTRPGRoleTalent.lua new file mode 100644 index 00000000..445a380e --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointTRPGRoleTalent.lua @@ -0,0 +1,18 @@ +---------------------------------------------------------------- +--主线跑团调查员天赋红点检测 +local XRedPointTRPGRoleTalent = {} +local Events = nil + +function XRedPointTRPGRoleTalent.GetSubEvents() + Events = Events or { + XRedPointEventElement.New(XEventId.EVENT_TRPG_BASE_INFO_CHANGE), + XRedPointEventElement.New(XEventId.EVENT_TRPG_ROLES_DATA_CHANGE), + } + return Events +end + +function XRedPointTRPGRoleTalent.Check() + return XDataCenter.TRPGManager.CheckRoleTalentRedPoint() +end + +return XRedPointTRPGRoleTalent \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointTRPGSecondMainReward.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointTRPGSecondMainReward.lua new file mode 100644 index 00000000..e7b44cc5 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointTRPGSecondMainReward.lua @@ -0,0 +1,10 @@ + +---------------------------------------------------------------- +--主线跑团常规主线红点检测 +local XRedPointTRPGSecondMainReward = {} + +function XRedPointTRPGSecondMainReward.Check() + return XDataCenter.TRPGManager.IsSecondMainReward() +end + +return XRedPointTRPGSecondMainReward \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointTRPGTruthRoadReward.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointTRPGTruthRoadReward.lua new file mode 100644 index 00000000..9984d97c --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointTRPGTruthRoadReward.lua @@ -0,0 +1,22 @@ + +---------------------------------------------------------------- +--主线跑团求真之路红点检测 +local XRedPointTRPGTruthRoadReward = {} +local Events = nil + +function XRedPointTRPGTruthRoadReward.GetSubEvents() + Events = Events or { + XRedPointEventElement.New(XEventId.EVENT_TRPG_GET_REWARD), + XRedPointEventElement.New(XEventId.EVENT_TRPG_FIRST_OPEN_TRUTH_ROAD), + } + return Events +end + +function XRedPointTRPGTruthRoadReward.Check() + if not XDataCenter.TRPGManager.CheckIsAlreadyOpenTruthRoad() then + return true + end + return XDataCenter.TRPGManager.CheckTruthRoadAllReward() +end + +return XRedPointTRPGTruthRoadReward \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointTRPGWorldBossReward.lua b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointTRPGWorldBossReward.lua new file mode 100644 index 00000000..efdfe130 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointConditions/XRedPointTRPGWorldBossReward.lua @@ -0,0 +1,18 @@ + +---------------------------------------------------------------- +--主线跑团世界BOSS红点检测 +local XRedPointTRPGWorldBossReward = {} +local Events = nil + +function XRedPointTRPGWorldBossReward.GetSubEvents() + Events = Events or { + XRedPointEventElement.New(XEventId.EVENT_TRPG_BOSS_HP_SYN) + } + return Events +end + +function XRedPointTRPGWorldBossReward.Check() + return XDataCenter.TRPGManager.CheckWorldBossReward() +end + +return XRedPointTRPGWorldBossReward \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointEvent.lua b/Resources/Scripts/XRedPoint/XRedPointEvent.lua new file mode 100644 index 00000000..990e68bf --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointEvent.lua @@ -0,0 +1,143 @@ +--[[--红点事件个体类 +RedPointEvent.id 唯一Id +RedPointEvent.conditionGroup 类型 XRedPointConditionGroup +RedPointEvent.listener 类型 XRedPointListener +RedPointEvent.node 持有的节点用于判断释放 +]] +-- +local XRedPointEvent = XClass(nil, "XRedPointEvent") + +local EventHandler = function(method, eventId) + return function(obj, ...) + return method(obj, eventId, ...) + end +end + + + +--构造 +function XRedPointEvent:Ctor(id, node, condition, listener, args) + self.id = id + self.condition = condition + self.listener = listener + self.node = node + self.args = args + self:AddConditonsChangeEvent() + + self.checkExist = nil + + if node.Exist then + self.checkExist = function() return node:Exist() end + else + local gameObject = node.GameObject or node.gameObject or node.Transform or node.transform + if gameObject and gameObject.Exist then + self.checkExist = function() return gameObject:Exist() end + end + end +end + +--检测红点条件 +function XRedPointEvent:Check(args) + + if not self:CheckNode() then + self:Release() + return + end + + if self.condition then + --如果条件参数改变,则替换 + if args then + self.args = args + end + + --条件检测 + local result = self.condition:Check(self.args) + + --回调 + if self.listener then + if self.listener.func then + self.listener:Call(result, self.args) + else + self.node.gameObject:SetActive(result >= 0) + end + end + end +end + +--添加事件監聽 +function XRedPointEvent:AddConditonsChangeEvent() + if not self.condition then + return + end + + local events = self.condition.Events + + if not events then + return + end + + for _, var in pairs(events) do + XEventManager.AddEventListener(var.EventId, EventHandler(self.OnCondintionChange, var.EventId), self) + end +end + +--删除事件監聽 +function XRedPointEvent:RemoveConditonsChageEvent() + if not self.condition then + return + end + + local events = self.condition.Events + + if not events then + return + end + + for _, var in pairs(events) do + XEventManager.RemoveEventListener(var.EventId, EventHandler(self.OnCondintionChange, var.EventId), self) + end +end + +--条件改变事件回调 +function XRedPointEvent:OnCondintionChange(eventId, args) + + -- 分析参数 + if self.condition and self.condition.Events and self.condition.Events[eventId] then + local element = self.condition.Events[eventId] + if element:Equal(eventId, args) then + self:Check() + return + end + end + + if self.args == nil or args == nil then + self:Check(args) + elseif self.args == args and args ~= nil then + self:Check(args) + end +end + +--检测是否已经被释放 +function XRedPointEvent:CheckNode() + if self.checkExist == nil then + return false + end + + if not self.checkExist() then + return false + end + + return true +end + +--释放 +function XRedPointEvent:Release() + self:RemoveConditonsChageEvent() + self.checkExist = nil + self.listener:Release() + self.node = nil + + XRedPointManager.RemoveRedPointEventOnly(self.id) +end + +return XRedPointEvent \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointEventElement.lua b/Resources/Scripts/XRedPoint/XRedPointEventElement.lua new file mode 100644 index 00000000..519e9cc5 --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointEventElement.lua @@ -0,0 +1,27 @@ +--事件单元 +local XRedPointEventElement = XClass(nil, "XRedPointEventElement") +-- +function XRedPointEventElement:Ctor(id, args) + self.EventId = id + self.EventArgs = args +end + +function XRedPointEventElement:Equal(id, arg) + if self.EventId ~= id then + return false + end + + if not self.EventArgs then + return true + end + + for _, v in ipairs(self.EventArgs) do + if v == arg then + return true + end + end + + return false +end + +return XRedPointEventElement \ No newline at end of file diff --git a/Resources/Scripts/XRedPoint/XRedPointListener.lua b/Resources/Scripts/XRedPoint/XRedPointListener.lua new file mode 100644 index 00000000..acc9783d --- /dev/null +++ b/Resources/Scripts/XRedPoint/XRedPointListener.lua @@ -0,0 +1,26 @@ + +--[[ +监听者个体类 +XRedPointListener.listener 监听者 +XRedPointListener.func 监听函数 +]]-- +local XRedPointListener = XClass(nil, "XRedPointListener") + +function XRedPointListener:Ctor() + +end + +function XRedPointListener:Release() + self.listener = nil + self.func = nil +end + +function XRedPointListener:Call(result,args) + if self.listener and self.func then + self.func(self.listener,result,args) + elseif self.func then + self.func(result,args) + end +end + +return XRedPointListener \ No newline at end of file diff --git a/Resources/Scripts/XUi/UiLoading/XUiLoading.lua b/Resources/Scripts/XUi/UiLoading/XUiLoading.lua new file mode 100644 index 00000000..f4e88400 --- /dev/null +++ b/Resources/Scripts/XUi/UiLoading/XUiLoading.lua @@ -0,0 +1,40 @@ +local XUiLoading = XLuaUiManager.Register(XLuaUi, "UiLoading") + +function XUiLoading:OnAwake() + XTool.InitUiObject(self) +end + +function XUiLoading:OnStart(...) + local args = { ... } + self.LoadingTab = XDataCenter.LoadingManager.GetLoadingTab(args[1]) + + if not self.LoadingTab then + return + end + + --设置背景 + if self.LoadingTab.ImageUrl then + self.Bg = self.Bg:SetRawImage(self.LoadingTab.ImageUrl) + else + self.Bg.texture = nil + end + + --设置标题 + if self.LoadingTab.Title then + + self.TitleText.gameObject:SetActive(true) + self.TitleText.text = self.LoadingTab.Title + + --设置内容 + if self.LoadingTab.Desc then + self.Desc.gameObject:SetActive(true) + self.Desc.text = string.gsub(self.LoadingTab.Desc, "\\n", "\n") + else + self.Desc.gameObject:SetActive(false) + end + + else + self.TitleText.gameObject:SetActive(false) + end + +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiActivityBase/ScratchTicket/XUiScratchTicketGrid.lua b/Resources/Scripts/XUi/XUiActivityBase/ScratchTicket/XUiScratchTicketGrid.lua new file mode 100644 index 00000000..5aa4708e --- /dev/null +++ b/Resources/Scripts/XUi/XUiActivityBase/ScratchTicket/XUiScratchTicketGrid.lua @@ -0,0 +1,102 @@ +---@class XUiScratchTicketGrid +local XUiScratchTicketGrid = XClass(nil, "XUiScratchTicketGrid") +local GridStatus = { + Front = 1, + Back = 2 + } +function XUiScratchTicketGrid:Ctor(uiGameObject, gridIndex, panel) + XTool.InitUiObjectByUi(self, uiGameObject) + self.Index = gridIndex + self.Panel = panel + self:InitGrid() +end + +function XUiScratchTicketGrid:InitGrid() + self:Refresh() + XUiHelper.RegisterClickEvent(self, self.Transform, function() self:OnClick() end) +end + +function XUiScratchTicketGrid:Refresh() + local ticket = self.Panel:GetTicket() + if ticket then + if ticket:CheckGridIsOpenByGridIndex(self.Index) then + self:SetFrontStatus() + self.GridStatus = GridStatus.Front + else + self:SetBackStatus() + self.GridStatus = GridStatus.Back + end + self.TxtNum.text = ticket:GetGridNumByGridIndex(self.Index) + else + self:SetBackStatus() + self.GridStatus = GridStatus.Back + end +end + +function XUiScratchTicketGrid:SetMask() + if self.GridStatus == GridStatus.Front then + self:SetFrontWithMask() + elseif self.GridStatus == GridStatus.Back then + self:SetBackWithMask() + end +end + +function XUiScratchTicketGrid:HideMask() + if self.GridStatus == GridStatus.Front then + self:SetFrontStatus() + elseif self.GridStatus == GridStatus.Back then + self:SetBackStatus() + end +end + +function XUiScratchTicketGrid:SetBackStatus() + self.BackStatus.gameObject:SetActiveEx(true) + self.FrontStatus.gameObject:SetActiveEx(false) + self.FrontMask.gameObject:SetActiveEx(false) + self.BackMask.gameObject:SetActiveEx(false) +end + +function XUiScratchTicketGrid:SetFrontStatus() + if self.GridStatus == GridStatus.Back then + if self.AnimCardFlip then + self.AnimCardFlip:Play() + end + end + --self.BackStatus.gameObject:SetActiveEx(false) + self.FrontStatus.gameObject:SetActiveEx(true) + self.FrontMask.gameObject:SetActiveEx(false) + self.BackMask.gameObject:SetActiveEx(false) +end + +function XUiScratchTicketGrid:SetFrontWithMask() + if self.GridStatus == GridStatus.Back then + if self.AnimCardFlip then + self.AnimCardFlip:Play() + end + end + --self.BackStatus.gameObject:SetActiveEx(false) + self.FrontStatus.gameObject:SetActiveEx(true) + self.FrontMask.gameObject:SetActiveEx(true) + self.BackMask.gameObject:SetActiveEx(false) +end + +function XUiScratchTicketGrid:SetBackWithMask() + self.BackStatus.gameObject:SetActiveEx(false) + self.FrontStatus.gameObject:SetActiveEx(false) + self.FrontMask.gameObject:SetActiveEx(false) + self.BackMask.gameObject:SetActiveEx(true) +end + +function XUiScratchTicketGrid:OnClick() + if self.GridStatus == GridStatus.Front then + XUiManager.TipMsg(CS.XTextManager.GetText("ScratchTicketGridAlreadyOpenTips")) + return + end + if self.Panel.Controller:CheckPreviewFinish() then + XUiManager.TipMsg(CS.XTextManager.GetText("ScratchTicketMaxOpenTips")) + return + end + XDataCenter.ScratchTicketManager.OpenGrid(self.Panel.Controller:GetId(), self.Index) +end + +return XUiScratchTicketGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiActivityBase/ScratchTicket/XUiScratchTicketPanelChose.lua b/Resources/Scripts/XUi/XUiActivityBase/ScratchTicket/XUiScratchTicketPanelChose.lua new file mode 100644 index 00000000..8e8c1ba0 --- /dev/null +++ b/Resources/Scripts/XUi/XUiActivityBase/ScratchTicket/XUiScratchTicketPanelChose.lua @@ -0,0 +1,32 @@ +-- 横纵列选择按钮控件 +local XUiScratchTicketPanelChose = XClass(nil, "XUiScratchTicketPanelChose") + +function XUiScratchTicketPanelChose:Ctor(uiGameObject, gameController, rootUi) + XTool.InitUiObjectByUi(self, uiGameObject) + self.Controller = gameController + self.RootUi = rootUi + self:InitPanel() +end + +function XUiScratchTicketPanelChose:InitPanel() + for i = 1, 8 do + local button = self["Btn" .. i] + if button then + button.CallBack = function() self:OnClickChoseButton(i) end + end + end +end + +function XUiScratchTicketPanelChose:OnClickChoseButton(index) + self.RootUi:SelectChose(index) +end + +function XUiScratchTicketPanelChose:ShowPanel() + self.GameObject:SetActiveEx(true) +end + +function XUiScratchTicketPanelChose:HidePanel() + self.GameObject:SetActiveEx(false) +end + +return XUiScratchTicketPanelChose \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiActivityBase/ScratchTicket/XUiScratchTicketPanelGrids.lua b/Resources/Scripts/XUi/XUiActivityBase/ScratchTicket/XUiScratchTicketPanelGrids.lua new file mode 100644 index 00000000..2c49142b --- /dev/null +++ b/Resources/Scripts/XUi/XUiActivityBase/ScratchTicket/XUiScratchTicketPanelGrids.lua @@ -0,0 +1,91 @@ +-- 刮刮卡九宫格面板 +local XUiScratchTicketPanelGrids = XClass(nil, "XUiScratchTicketPanelGrids") + +function XUiScratchTicketPanelGrids:Ctor(uiGameObject, gameController, rootUi) + -- 这个面板没有使用UiObject + self.GameObject = uiGameObject.gameObject + self.Transform = uiGameObject.transform + self.RootUi = rootUi + self.Controller = gameController + self:InitPanel() +end + +function XUiScratchTicketPanelGrids:GetTicket() + if not self.Ticket then self.Ticket = self.Controller:GetTicket() end + return self.Ticket +end +--================== +--初始化面板 +--================== +function XUiScratchTicketPanelGrids:InitPanel() + local ticket = self:GetTicket() + if ticket and ticket:GetPlayStatus() ~= XDataCenter.ScratchTicketManager.PlayStatus.NotStart then + self:ShowPanel() + else + self:HidePanel() + end + self:InitGrids() +end +--================== +--初始化九宫格 +--================== +function XUiScratchTicketPanelGrids:InitGrids() + local gridScript = require("XUi/XUiActivityBase/ScratchTicket/XUiScratchTicketGrid") + local gridIndex = 1 + self.Grids = {} + while(gridIndex < 100) do + local gridGameObject = self.GameObject:FindGameObject("Grid" .. gridIndex) + if not gridGameObject then + break + end + self.Grids[gridIndex] = gridScript.New(gridGameObject, gridIndex, self) + gridIndex = gridIndex + 1 + end +end +--================== +--刷新九宫格 +--================== +function XUiScratchTicketPanelGrids:Refresh() + self:HideAllMasks() + for _, grid in pairs(self.Grids) do + grid:Refresh() + end +end + +function XUiScratchTicketPanelGrids:SetMaskOnChoseSelect(choseIndex) + local choseCfg = XScratchTicketConfig.GetChoseConfigById(choseIndex, true) + if choseCfg then + local selectIndexs = {} + for _, gridIndex in pairs(choseCfg.GridIndex) do + selectIndexs[gridIndex] = true + end + for index, grid in pairs(self.Grids) do + if selectIndexs[index] then + grid:HideMask() + else + grid:SetMask() + end + end + self:ShowPanel() + end +end + +function XUiScratchTicketPanelGrids:HideAllMasks() + for _, grid in pairs(self.Grids) do + grid:HideMask() + end +end +--================== +--显示面板 +--================== +function XUiScratchTicketPanelGrids:ShowPanel() + self.GameObject:SetActiveEx(true) +end +--================== +--隐藏面板 +--================== +function XUiScratchTicketPanelGrids:HidePanel() + self.GameObject:SetActiveEx(false) +end + +return XUiScratchTicketPanelGrids \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiActivityBase/ScratchTicket/XUiScratchTicketPanelLeft.lua b/Resources/Scripts/XUi/XUiActivityBase/ScratchTicket/XUiScratchTicketPanelLeft.lua new file mode 100644 index 00000000..dc164b30 --- /dev/null +++ b/Resources/Scripts/XUi/XUiActivityBase/ScratchTicket/XUiScratchTicketPanelLeft.lua @@ -0,0 +1,131 @@ +-- 刮刮乐PanelTop面板控件 +local XUiScratchTicketPanelLeft = XClass(nil, "XUiScratchTicketPanelLeft") +local STR_UNKNOWN = "?" +function XUiScratchTicketPanelLeft:Ctor(uiGameObject, controller, rootUi) + XTool.InitUiObjectByUi(self, uiGameObject) + self.Controller = controller + self.RootUi = rootUi + self.ObjLuckyRewardSelect.gameObject:SetActiveEx(false) + if self.ObjNormalRewardSelect then self.ObjNormalRewardSelect.gameObject:SetActiveEx(false) end + self:InitBtns() + self:RefreshPanel() +end + +function XUiScratchTicketPanelLeft:InitBtns() + if self.BtnLuckyReward then self.BtnLuckyReward.CallBack = function() self:OnLuckyRewardClick() end end + if self.BtnLuckyRewardSelect then self.BtnLuckyRewardSelect.CallBack = function() self:OnLuckyRewardClick() end end + if self.BtnNormalReward then self.BtnNormalReward.CallBack = function() self:OnNormalRewardClick() end end + if self.BtnNormalRewardSelect then self.BtnNormalRewardSelect.CallBack = function() self:OnNormalRewardClick() end end +end + +function XUiScratchTicketPanelLeft:RefreshPanel() + self.Ticket = self.Controller:GetTicket() + self:RefreshLuckyReward() + self:RefreshNormalReward() +end + +function XUiScratchTicketPanelLeft:RefreshLuckyReward() + local isStart = false + if self.Ticket then + local playStatus = self.Ticket:GetPlayStatus() + isStart = playStatus ~= XDataCenter.ScratchTicketManager.PlayStatus.NotStart + end + self.ObjLuckyRewardNormal.gameObject:SetActiveEx(true) + self.TxtLuckyNum.text = isStart and self.Ticket:GetLuckyNum() or STR_UNKNOWN + if self.Controller:GetIsCanReset() then + self.RImgLuckyReward.gameObject:SetActiveEx(true) + if self.RImgLuckyRewardBg then self.RImgLuckyRewardBg.gameObject:SetActiveEx(true) end + self.RImgLuckyReward:SetRawImage(self.Controller:GetGoldRewardItemIcon()) + self.TxtLuckyRewardNum.text = "x" .. self.Controller:GetGoldRewardItemNum() or STR_UNKNOWN + else + self.RImgLuckyReward.gameObject:SetActiveEx(isStart) + if self.RImgLuckyRewardBg then self.RImgLuckyRewardBg.gameObject:SetActiveEx(isStart) end + if isStart then self.RImgLuckyReward:SetRawImage(self.Ticket:GetWinRewardItemIcon()) end + self.TxtLuckyRewardNum.text = isStart and "x" .. self.Ticket:GetWinRewardItemNum() or STR_UNKNOWN + end +end + +function XUiScratchTicketPanelLeft:RefreshNormalReward() + --黄金刮刮没有普通奖励 + if self.Controller:GetIsCanReset() then return end + local isStart = false + if self.Ticket then + local playStatus = self.Ticket:GetPlayStatus() + isStart = playStatus ~= XDataCenter.ScratchTicketManager.PlayStatus.NotStart + end + self.ObjNormalRewardNormal.gameObject:SetActiveEx(true) + self.RImgNormalReward.gameObject:SetActiveEx(isStart) + if self.RImgNormalRewardBg then self.RImgNormalRewardBg.gameObject:SetActiveEx(isStart) end + if isStart then self.RImgNormalReward:SetRawImage(self.Ticket:GetLoseRewardItemIcon()) end + self.TxtNormalRewardNum.text = isStart and "x" .. self.Ticket:GetLoseRewardItemNum() or STR_UNKNOWN +end + +function XUiScratchTicketPanelLeft:RefreshSelect() + if not self.Ticket then self.Ticket = self.Controller:GetTicket() end + if not self.Ticket then return end + local isCorrent = self.Ticket:CheckIsSelectCorrent() + self.ObjLuckyRewardSelect.gameObject:SetActiveEx(isCorrent) + if not self.Controller:GetIsCanReset() then + self.ObjNormalRewardSelect.gameObject:SetActiveEx(not self.Ticket:CheckIsSelectCorrent()) + end + if isCorrent then + self.ObjLuckyRewardNormal.gameObject:SetActiveEx(false) + self.RImgLuckyRewardSelect:SetRawImage(self.Ticket:GetWinRewardItemIcon()) + self.TxtLuckyRewardNumSelect.text = "x" .. self.Ticket:GetWinRewardItemNum() + else + if not self.Controller:GetIsCanReset() then + self.ObjNormalRewardNormal.gameObject:SetActiveEx(false) + self.RImgNormalRewardSelect:SetRawImage(self.Ticket:GetLoseRewardItemIcon()) + self.TxtNormalRewardNumSelect.text = "x" .. self.Ticket:GetLoseRewardItemNum() + end + end +end + +function XUiScratchTicketPanelLeft:OnReset() + local isGold = self.Controller:GetIsCanReset() + self.TxtLuckyNum.text = STR_UNKNOWN + self.RImgLuckyReward.gameObject:SetActiveEx(isGold) + if self.RImgLuckyRewardBg then self.RImgLuckyRewardBg.gameObject:SetActiveEx(isGold) end + if not isGold then + self.TxtLuckyRewardNum.text = STR_UNKNOWN + end + self.ObjLuckyRewardNormal.gameObject:SetActiveEx(true) + self.ObjLuckyRewardSelect.gameObject:SetActiveEx(false) + if isGold then return end + self.ObjNormalRewardNormal.gameObject:SetActiveEx(true) + self.RImgNormalReward.gameObject:SetActiveEx(false) + if self.RImgNormalRewardBg then self.RImgNormalRewardBg.gameObject:SetActiveEx(false) end + self.TxtNormalRewardNum.text = STR_UNKNOWN + if not self.Controller:GetIsCanReset() then + self.ObjNormalRewardSelect.gameObject:SetActiveEx(false) + end +end + +function XUiScratchTicketPanelLeft:OnLuckyRewardClick() + local isGold = self.Controller:GetIsCanReset() + if not isGold and not self.Ticket then return end + local itemId + if not self.Ticket and isGold then + itemId = self.Controller:GetGoldRewardItemId() + else + itemId = self.Ticket:GetWinRewardItemId() + end + if itemId and itemId > 0 then + XLuaUiManager.Open("UiTip", itemId, true, nil) + end +end + +function XUiScratchTicketPanelLeft:OnNormalRewardClick() + local isGold = self.Controller:GetIsCanReset() + if isGold then return end + local itemId = self.Ticket:GetLoseRewardItemId() + if itemId and itemId > 0 then + XLuaUiManager.Open("UiTip", itemId, true, nil) + end +end + +function XUiScratchTicketPanelLeft:OnDestroy() + +end + +return XUiScratchTicketPanelLeft \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiActivityBase/ScratchTicket/XUiScratchTicketPanelPlay.lua b/Resources/Scripts/XUi/XUiActivityBase/ScratchTicket/XUiScratchTicketPanelPlay.lua new file mode 100644 index 00000000..e1e75241 --- /dev/null +++ b/Resources/Scripts/XUi/XUiActivityBase/ScratchTicket/XUiScratchTicketPanelPlay.lua @@ -0,0 +1,199 @@ +-- +local XUiScratchTicketPanelPlay = XClass(nil, "XUiScratchTicketPanelPlay") + +local PANEL_INDEX = { + Ready = 1, + Preview = 2, + Grids = 3, + Chose = 4, + SelectBlue = 5, + SelectRed = 6, + WrongAnswer = 7, + CorrectAnswer = 8, + BtnExchange = 9, + BtnDetermine = 10 + } + +function XUiScratchTicketPanelPlay:Ctor(uiGameObject, controller, rootUi) + XTool.InitUiObjectByUi(self, uiGameObject) + self.Controller = controller + self.RootUi = rootUi + self:InitPanels() +end + +function XUiScratchTicketPanelPlay:InitPanels() + self.Ticket = self.Controller:GetTicket() + self.ChildPanels = {} + self:InitPanelReady() + self:InitPanelPreview() + self:InitPanelGrids() + self:InitPanelChose() + self:InitPanelSelectChose() + self.ChildPanels[PANEL_INDEX.WrongAnswer] = self.PanelWrongAnswer + self.ChildPanels[PANEL_INDEX.CorrectAnswer] = self.PanelCorrectAnswer + self:InitButtons() +end + +function XUiScratchTicketPanelPlay:InitPanelReady() + local panelScript = require("XUi/XUiActivityBase/ScratchTicket/XUiScratchTicketPanelReady") + self.ReadyPanel = panelScript.New(self.PanelReady, self.Controller, self) + self.ChildPanels[PANEL_INDEX.Ready] = self.ReadyPanel +end + +function XUiScratchTicketPanelPlay:InitPanelPreview() + local panelScript = require("XUi/XUiActivityBase/ScratchTicket/XUiScratchTicketPanelPreview") + self.PreviewPanel = panelScript.New(self.PanelPreview, self.Controller, self) + self.ChildPanels[PANEL_INDEX.Preview] = self.PreviewPanel +end + +function XUiScratchTicketPanelPlay:InitPanelGrids() + local panelScript = require("XUi/XUiActivityBase/ScratchTicket/XUiScratchTicketPanelGrids") + self.GridsPanel = panelScript.New(self.PanelGrids, self.Controller, self) + self.ChildPanels[PANEL_INDEX.Grids] = self.GridsPanel +end + +function XUiScratchTicketPanelPlay:InitPanelChose() + local panelScript = require("XUi/XUiActivityBase/ScratchTicket/XUiScratchTicketPanelChose") + self.ChosePanel = panelScript.New(self.PanelChose, self.Controller, self) + self.ChildPanels[PANEL_INDEX.Chose] = self.ChosePanel +end + +function XUiScratchTicketPanelPlay:InitPanelSelectChose() + local panelScript = require("XUi/XUiActivityBase/ScratchTicket/XUiScratchTicketPanelSelectChose") + self.SelectBluePanel = panelScript.New(self.PanelSelectBlueGrids, self.Controller, self) + self.SelectRedPanel = panelScript.New(self.PanelSelectRedGrids, self.Controller, self) + self.ChildPanels[PANEL_INDEX.SelectBlue] = self.SelectBluePanel + self.ChildPanels[PANEL_INDEX.SelectRed] = self.SelectRedPanel +end + +function XUiScratchTicketPanelPlay:SelectChose(index) + self.ChoseSelect = index + self.SelectBluePanel:SelectChose(index) +end + +function XUiScratchTicketPanelPlay:InitButtons() + self.BtnExchange.CallBack = function() self:OnClickBtnExchange() end + self.BtnDetermine.CallBack = function() self:OnClickBtnDetermine() end + self.BtnExchange.gameObject:SetActiveEx(false) + self.BtnDetermine.gameObject:SetActiveEx(false) + self.ChildPanels[PANEL_INDEX.BtnExchange] = self.BtnExchange + self.ChildPanels[PANEL_INDEX.BtnDetermine] = self.BtnDetermine +end + +function XUiScratchTicketPanelPlay:GetTicket() + if not self.Ticket then + self.Ticket = self.Controller:GetTicket() + end + return self.Ticket +end + +function XUiScratchTicketPanelPlay:OnOpenGrid() + self:GetTicket() + self.GridsPanel:Refresh() + self.PreviewPanel:Refresh() + if self.Controller:CheckPreviewFinish() then + self:ShowChooseChose() + end +end + +function XUiScratchTicketPanelPlay:ShowChildPanel(panelIndexGroup) + for index, panel in pairs(self.ChildPanels) do + if panelIndexGroup[index] then + if panel["ShowPanel"] then + panel["ShowPanel"](panel) + else + panel.gameObject:SetActiveEx(true) + end + else + if panel["HidePanel"] then + panel["HidePanel"](panel) + else + panel.gameObject:SetActiveEx(false) + end + end + end +end + +function XUiScratchTicketPanelPlay:ShowReady() + local panelIndexGroup = {} + panelIndexGroup[PANEL_INDEX.Ready] = true + self:ShowChildPanel(panelIndexGroup) + self.ReadyPanel:Refresh() + self.PreviewPanel:Refresh() + self.RootUi:PlayAnimation("PanelReadyEnable") +end + +function XUiScratchTicketPanelPlay:ShowGaming() + self:GetTicket() + self:ShowChildPanel( + { [PANEL_INDEX.Grids] = true, + [PANEL_INDEX.Preview] = true, + } + ) + self.GridsPanel:Refresh() + self.PreviewPanel:Refresh() + self.RootUi:PlayAnimation("AnimBgQieHuan") +end + +function XUiScratchTicketPanelPlay:ShowChooseChose() + self:GetTicket() + self:ShowChildPanel( + { [PANEL_INDEX.Chose] = true, + [PANEL_INDEX.Grids] = true, + [PANEL_INDEX.BtnExchange] = true, + [PANEL_INDEX.SelectBlue] = true + }) + self.SelectBluePanel:Reset() + self.RootUi:PlayAnimation("AnimBtnContenrEnable") +end + +function XUiScratchTicketPanelPlay:ShowResult() + local ticket = self:GetTicket() + local isCorrect = ticket:CheckIsSelectCorrent() + local animName = isCorrect and "AnimPanelCorrectAnswerEnable" or "AnimPanelWrongAnswerEnable" + self:ShowChildPanel( + { + [PANEL_INDEX.WrongAnswer] = not isCorrect, + [PANEL_INDEX.CorrectAnswer] = isCorrect, + [PANEL_INDEX.BtnDetermine] = true, + [PANEL_INDEX.Grids] = true, + }) + if not isCorrect then + self.SelectRedPanel:SelectChose(ticket:GetSelectChoseId()) + self.SelectBluePanel:SelectChose(ticket:GetCorrectChose()[1]) + else + self.SelectBluePanel:SelectChose(ticket:GetSelectChoseId()) + end + self.GridsPanel:Refresh() + self.ChoseSelect = nil + self.RootUi:PlayAnimation(animName) +end + +function XUiScratchTicketPanelPlay:SelectChose(index) + self:GetTicket() + self.ChoseSelect = index + self.SelectBluePanel:SelectChose(index) + self.GridsPanel:SetMaskOnChoseSelect(index) +end + +function XUiScratchTicketPanelPlay:OnClickBtnExchange() + if not self.ChoseSelect then + XUiManager.TipMsg(CS.XTextManager.GetText("ScratchTicketSelectChoseTips")) + return + end + XDataCenter.ScratchTicketManager.ExChange(self.Controller:GetId(), self.ChoseSelect) +end + +function XUiScratchTicketPanelPlay:OnClickBtnDetermine() + self.RootUi:OnReady() +end + +function XUiScratchTicketPanelPlay:OnDisable() + self:ShowChildPanel({}) +end + +function XUiScratchTicketPanelPlay:OnDestroy() + +end + +return XUiScratchTicketPanelPlay \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiActivityBase/ScratchTicket/XUiScratchTicketPanelPreview.lua b/Resources/Scripts/XUi/XUiActivityBase/ScratchTicket/XUiScratchTicketPanelPreview.lua new file mode 100644 index 00000000..c1592686 --- /dev/null +++ b/Resources/Scripts/XUi/XUiActivityBase/ScratchTicket/XUiScratchTicketPanelPreview.lua @@ -0,0 +1,29 @@ +---@class XUiScratchTicketPanelPreview +local XUiScratchTicketPanelPreview = XClass(nil, "XUiScratchTicketPanelPreview") + +function XUiScratchTicketPanelPreview:Ctor(uiGameObject, gameController, rootUi) + XTool.InitUiObjectByUi(self, uiGameObject) + self.Controller = gameController + self.RootUi = rootUi + self:InitPanel() +end + +function XUiScratchTicketPanelPreview:InitPanel() + self:Refresh() +end + +function XUiScratchTicketPanelPreview:Refresh() + if not self.RootUi.Ticket then return end + self.TxtCount.text = self.RootUi.Ticket:GetOpenGridNum() + self.TxtMaxCount.text = "/" .. self.Controller:GetPreviewCount() +end + +function XUiScratchTicketPanelPreview:ShowPanel() + self.GameObject:SetActiveEx(true) +end + +function XUiScratchTicketPanelPreview:HidePanel() + self.GameObject:SetActiveEx(false) +end + +return XUiScratchTicketPanelPreview \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiActivityBase/ScratchTicket/XUiScratchTicketPanelReady.lua b/Resources/Scripts/XUi/XUiActivityBase/ScratchTicket/XUiScratchTicketPanelReady.lua new file mode 100644 index 00000000..b14d11a6 --- /dev/null +++ b/Resources/Scripts/XUi/XUiActivityBase/ScratchTicket/XUiScratchTicketPanelReady.lua @@ -0,0 +1,71 @@ +---@class XUiScratchTicketPanelReady +local XUiScratchTicketPanelReady = XClass(nil, "XUiScratchTicketPanelReady") + +function XUiScratchTicketPanelReady:Ctor(uiGameObject, gameController, rootUi) + XTool.InitUiObjectByUi(self, uiGameObject) + self.RootUi = rootUi + self.Controller = gameController + self:InitPanel() +end +--================== +--初始化面板 +--================== +function XUiScratchTicketPanelReady:InitPanel() + self.ImgTicket:SetSprite(self.Controller:GetSpendItemIcon()) + self.TxtTicketNum.text = self.Controller:GetSpendItemNum() + self.BtnStart.CallBack = function() self:OnClickBtnStart() end + if self.BtnRestart then + --只有黄金刮有这个按钮 + self.BtnRestart.CallBack = function() self:OnClickBtnRestart() end + end + self.Ticket = self.Controller:GetTicket() + if (not self.Ticket) or self.Ticket:GetPlayStatus() == XDataCenter.ScratchTicketManager.PlayStatus.NotStart then + self:ShowPanel() + else + self:HidePanel() + end +end + +function XUiScratchTicketPanelReady:Refresh() + self.Ticket = self.Controller:GetTicket() + if self.Controller:GetIsCanReset() then + --黄金刮刮 + self.BtnRestart.gameObject:SetActiveEx(self.Controller:GetResetStatus()) + if self.TxtRestart then self.TxtRestart.gameObject:SetActiveEx(self.Controller:GetResetStatus()) end + if self.ObjTicketNum then self.ObjTicketNum.gameObject:SetActiveEx(not self.Controller:GetResetStatus()) end + self.BtnStart.gameObject:SetActiveEx(not self.Controller:GetResetStatus()) + end +end +--================== +--显示面板 +--================== +function XUiScratchTicketPanelReady:ShowPanel() + self.GameObject:SetActiveEx(true) + self.ObjBgReady.gameObject:SetActiveEx(true) + if self.ObjBg then self.ObjBg.gameObject:SetActiveEx(false) end +end +--================== +--隐藏面板 +--================== +function XUiScratchTicketPanelReady:HidePanel() + self.GameObject:SetActiveEx(false) + self.ObjBgReady.gameObject:SetActiveEx(false) + if self.ObjBg then self.ObjBg.gameObject:SetActiveEx(true) end +end +--================== +--点击开始游戏 +--================== +function XUiScratchTicketPanelReady:OnClickBtnStart() + if self.Controller:CheckIsLastTicket() then + XUiManager.TipMsg(CS.XTextManager.GetText("ScratchTicketAllFinishTips")) + return + end + XDataCenter.ScratchTicketManager.StartGame(self.Controller:GetId()) +end +--================== +--点击重置黄金刮刮 +--================== +function XUiScratchTicketPanelReady:OnClickBtnRestart() + XDataCenter.ScratchTicketManager.ResetGame(self.Controller:GetId()) +end +return XUiScratchTicketPanelReady \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiActivityBase/ScratchTicket/XUiScratchTicketPanelSelectChose.lua b/Resources/Scripts/XUi/XUiActivityBase/ScratchTicket/XUiScratchTicketPanelSelectChose.lua new file mode 100644 index 00000000..423438af --- /dev/null +++ b/Resources/Scripts/XUi/XUiActivityBase/ScratchTicket/XUiScratchTicketPanelSelectChose.lua @@ -0,0 +1,55 @@ +---@class XUiScratchTicketPanelSelectChose +local XUiScratchTicketPanelSelectChose = XClass(nil, "XUiScratchTicketPanelSelectChose") + +function XUiScratchTicketPanelSelectChose:Ctor(uiGameObject, gameController, rootUi) + self.GameObject = uiGameObject.gameObject + self.Controller = gameController + self.RootUi = rootUi + self:InitPanel() +end + +function XUiScratchTicketPanelSelectChose:InitPanel() + local gridIndex = 1 + self.Grids = {} + while(gridIndex < 100) do + local gridGameObject = self.GameObject:FindGameObject("Grid" .. gridIndex) + if not gridGameObject then + break + end + self.Grids[gridIndex] = gridGameObject + gridIndex = gridIndex + 1 + end + self:HidePanel() +end + +function XUiScratchTicketPanelSelectChose:Reset() + for index, grid in pairs(self.Grids) do + grid.gameObject:SetActiveEx(false) + end +end + +function XUiScratchTicketPanelSelectChose:SelectChose(index) + local choseCfg = XScratchTicketConfig.GetChoseConfigById(index, true) + if choseCfg then + local selectIndexs = {} + for _, gridIndex in pairs(choseCfg.GridIndex) do + selectIndexs[gridIndex] = true + end + for index, grid in pairs(self.Grids) do + grid.gameObject:SetActiveEx(selectIndexs[index]) + end + self:ShowPanel() + else + self:HidePanel() + end +end + +function XUiScratchTicketPanelSelectChose:ShowPanel() + self.GameObject:SetActiveEx(true) +end + +function XUiScratchTicketPanelSelectChose:HidePanel() + self.GameObject:SetActiveEx(false) +end + +return XUiScratchTicketPanelSelectChose \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiActivityBase/ScratchTicket/XUiScratchTicketPanelTop.lua b/Resources/Scripts/XUi/XUiActivityBase/ScratchTicket/XUiScratchTicketPanelTop.lua new file mode 100644 index 00000000..48e4db88 --- /dev/null +++ b/Resources/Scripts/XUi/XUiActivityBase/ScratchTicket/XUiScratchTicketPanelTop.lua @@ -0,0 +1,69 @@ +-- 刮刮乐PanelTop面板控件 +local XUiScratchTicketPanelTop = XClass(nil, "XUiScratchTicketPanelTop") + +function XUiScratchTicketPanelTop:Ctor(uiGameObject, controller, rootUi) + XTool.InitUiObjectByUi(self, uiGameObject) + self.Controller = controller + self.RootUi = rootUi + self:InitPanel() +end + +function XUiScratchTicketPanelTop:InitPanel() + self:InitTicket() + self:InitTime() + self:InitBtns() +end + +--============= +--初始化门票数量显示 +--============= +function XUiScratchTicketPanelTop:InitTicket() + local XUiCommonAsset = require("XUi/XUiCommon/XUiCommonAsset") + local AssetPanel = require("XUi/XUiCommon/XUiCommonAssetPanel") + local AssetsList = {} + local assetItem1 = { + ShowType = XUiCommonAsset.ShowType.BagItem, + ItemId = self.Controller:GetSpendItemId(), + } + table.insert(AssetsList, assetItem1) + self.AssetPanel = AssetPanel.New(self.GameObject, AssetsList) +end + +function XUiScratchTicketPanelTop:InitTime() + self:SetTimer() +end + +function XUiScratchTicketPanelTop:SetTimer() + if self.Timer then return end + self.Timer = XScheduleManager.ScheduleForever(function() + if not self.RootUi:Exist() then return end + local endTimeSecond = self.Controller:GetEndTime() + local now = XTime.GetServerNowTimestamp() + local leftTime = endTimeSecond - now + self.TxtTime.text = CS.XTextManager.GetText("ScratchTicketActivityLeftTime") .. XUiHelper.GetTime(leftTime, XUiHelper.TimeFormatType.ACTIVITY) + if leftTime <= 0 then + self.RootUi:OnGameEnd() + end + end, 0) +end + +function XUiScratchTicketPanelTop:StopTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end + +function XUiScratchTicketPanelTop:InitBtns() + self.BtnHelp.CallBack = function() self:OnClickBtnHelp() end +end + +function XUiScratchTicketPanelTop:OnClickBtnHelp() + XUiManager.ShowHelpTip("ScratchTicketHelp") +end + +function XUiScratchTicketPanelTop:OnDestroy() + self:StopTimer() +end + +return XUiScratchTicketPanelTop \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiActivityBase/XUiActivityBase.lua b/Resources/Scripts/XUi/XUiActivityBase/XUiActivityBase.lua new file mode 100644 index 00000000..299afb2d --- /dev/null +++ b/Resources/Scripts/XUi/XUiActivityBase/XUiActivityBase.lua @@ -0,0 +1,134 @@ +local next = next +local XUiActivityBase = XLuaUiManager.Register(XLuaUi, "UiActivityBase") + +XUiActivityBase.BtnTabIndex = { + Activity = 1, + Notice = 2, + ActivityNotice = 3, + ActivityLink = 4, +} + +XUiActivityBase.GameNoticeType = { + ActivityNotice = 0, + Notice = 1, +} + +function XUiActivityBase:OnAwake() + self:InitAutoScript() + + local tabGroup = { + self.BtnActivity, + self.BtnGameNotice, + self.BtnActivityNotice, + self.BtnLink, + } + self.PanelType:Init(tabGroup, function(tabIndex) self:OnClickTabCallBack(tabIndex) end) + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + + XRedPointManager.AddRedPointEvent(self.BtnActivity, self.OnCheckNewActivities, self, { XRedPointConditions.Types.CONDITION_ACTIVITY_NEW_ACTIVITIES }) + XRedPointManager.AddRedPointEvent(self.BtnGameNotice, self.OnCheckNewGameNotices, self, { XRedPointConditions.Types.CONDITION_ACTIVITY_NEW_NOTICES }) + XRedPointManager.AddRedPointEvent(self.BtnActivityNotice, self.OnCheckNewActivityNotices, self, { XRedPointConditions.Types.CONDITION_ACTIVITY_NEW_ACTIVITY_NOTICES }) +end + +function XUiActivityBase:OnGetEvents() + return { XEventId.EVENT_UIDIALOG_VIEW_ENABLE } +end + +function XUiActivityBase:OnNotify(evt) + if evt == XEventId.EVENT_UIDIALOG_VIEW_ENABLE then + self:Close() + end +end + +function XUiActivityBase:OnCheckNewGameNotices(count) + self.BtnGameNotice:ShowReddot(count >= 0) +end + +function XUiActivityBase:OnCheckNewActivities(count) + self.BtnActivity:ShowReddot(count >= 0) +end + +function XUiActivityBase:OnCheckNewActivityNotices(count) + self.BtnActivityNotice:ShowReddot(count >= 0) +end + +function XUiActivityBase:OnStart(skipIndex, subSkipIndex, subSkipId) + local defaultSelectIndex = skipIndex + self.SubSkipIndex = subSkipIndex + self.SubSkipId = subSkipId + self.ActivityGroupInfos = XDataCenter.ActivityManager.GetActivityGroupInfos() + + local HaveGameNotice = XDataCenter.NoticeManager.CheckHaveNotice(XUiActivityBase.GameNoticeType.Notice) + local HaveActivityNotice = XDataCenter.NoticeManager.CheckHaveNotice(XUiActivityBase.GameNoticeType.ActivityNotice) + local HaveActivity = next(self.ActivityGroupInfos) + + if HaveActivity then + defaultSelectIndex = defaultSelectIndex or XUiActivityBase.BtnTabIndex.Activity + elseif HaveActivityNotice then + defaultSelectIndex = defaultSelectIndex or XUiActivityBase.BtnTabIndex.ActivityNotice + else + defaultSelectIndex = defaultSelectIndex or XUiActivityBase.BtnTabIndex.Activity + end + + self.BtnGameNotice:SetDisable(not HaveGameNotice) + self.BtnActivityNotice:SetDisable(not HaveActivityNotice) + + if defaultSelectIndex then + self.PanelType:SelectIndex(defaultSelectIndex) + end +end + +function XUiActivityBase:InitAutoScript() + self:AutoAddListener() +end + +function XUiActivityBase:AutoAddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) +end + +function XUiActivityBase:OnBtnBackClick() + self:Close() +end + +function XUiActivityBase:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiActivityBase:OnClickTabCallBack(tabIndex) + if self.SelectedIndex and self.SelectedIndex == tabIndex then + return + end + + if tabIndex == XUiActivityBase.BtnTabIndex.Activity then + self:OpenOneChildUi("UiActivityBaseChild", self.ActivityGroupInfos, self.SubSkipIndex, self.SubSkipId) + elseif tabIndex == XUiActivityBase.BtnTabIndex.Notice then + if not XDataCenter.NoticeManager.CheckHaveNotice(XUiActivityBase.GameNoticeType.Notice) then + XUiManager.TipText("NoInGameNotice") + return + end + + if not XLuaUiManager.IsUiShow("UiGameNotice") then + self:OpenOneChildUi("UiGameNotice", self, self.SubSkipIndex, self.SubSkipId, XUiActivityBase.GameNoticeType.Notice) + else + CsXGameEventManager.Instance:Notify(XEventId.EVENT_NOTICE_TYPE_CHANAGE, XUiActivityBase.GameNoticeType.Notice) + end + elseif tabIndex == XUiActivityBase.BtnTabIndex.ActivityNotice then + if not XDataCenter.NoticeManager.CheckHaveNotice(XUiActivityBase.GameNoticeType.ActivityNotice) then + XUiManager.TipText("NoActivities") + return + end + + if not XLuaUiManager.IsUiShow("UiGameNotice") then + self:OpenOneChildUi("UiGameNotice", self, self.SubSkipIndex, self.SubSkipId, XUiActivityBase.GameNoticeType.ActivityNotice) + else + CsXGameEventManager.Instance:Notify(XEventId.EVENT_NOTICE_TYPE_CHANAGE, XUiActivityBase.GameNoticeType.ActivityNotice) + end + elseif tabIndex == XUiActivityBase.BtnTabIndex.ActivityLink then + self:OpenOneChildUi("UiActivityBaseLink") + end + self.SubSkipIndex = nil + self.SubSkipId = nil + + self.SelectedIndex = tabIndex +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiActivityBase/XUiActivityBaseChild.lua b/Resources/Scripts/XUi/XUiActivityBase/XUiActivityBaseChild.lua new file mode 100644 index 00000000..0a557ff5 --- /dev/null +++ b/Resources/Scripts/XUi/XUiActivityBase/XUiActivityBaseChild.lua @@ -0,0 +1,421 @@ +local next = next +local tableInsert = table.insert + +local XUiPanelTask = require("XUi/XUiActivityBase/XUiPanelTask") +local XUiPanelShop = require("XUi/XUiActivityBase/XUiPanelShop") +local XUiPanelSkip = require("XUi/XUiActivityBase/XUiPanelSkip") +local XUiPanelLink = require("XUi/XUiActivityBase/XUiPanelLink") +local XUiPanelSendInvitation = require("XUi/XUiActivityBase/XUiPanelSendInvitation") +local XUiPanelAcceptInvitation = require("XUi/XUiActivityBase/XUiPanelAcceptInvitation") +local XUiJigsawPuzzle = require("XUi/XUiActivityBase/XUiJigsawPuzzle") +local XUiConsumeReward = require("XUi/XUiActivityBase/XUiConsumeReward") +local XUiScratchTicket = require("XUi/XUiActivityBase/XUiScratchTicket") +local BTN_INDEX = { + First = 1, + Second = 2, +} + +local XUiActivityBaseChild = XLuaUiManager.Register(XLuaUi, "UiActivityBaseChild") + +function XUiActivityBaseChild:OnStart(activityGroupInfos, selectIndex, selectId) + local isAcitivityOpen = next(activityGroupInfos) + self.PaneNothing.gameObject:SetActiveEx(not isAcitivityOpen) + self.ScrollTitleTab.gameObject:SetActiveEx(isAcitivityOpen) + self.PanelRightContent.gameObject:SetActiveEx(isAcitivityOpen) + self.RImgContentBg.gameObject:SetActiveEx(isAcitivityOpen) + if not isAcitivityOpen then return end + self.PanelLoadPrefabList = { + self.PanelLoadPrefab1, + self.PanelLoadPrefab2, + } + self.PanelDic = {} + self.UnusedLoadPrefabIndex = 1 + self.AcitivityTypeGroups = {} + self.ActivityGroupInfos = activityGroupInfos + self:UpdateActivityInfos(selectIndex, selectId) + XRedPointManager.AddRedPointEvent(self.PanelNoticeTitleBtnGroup, self.OnCheckRedPointRegression, self, { XRedPointConditions.Types.CONDITION_ACTIVITY_NEW_ACTIVITIES_TOGS }, nil, false) +end + +function XUiActivityBaseChild:OnEnable() + if self.SelectIndex then + self.PanelNoticeTitleBtnGroup:SelectIndex(self.SelectIndex) + end + XEventManager.AddEventListener(XEventId.EVENT_NEWYEARYUNSHI_CLOSE_REFRESH, self.Update, self) +end + +function XUiActivityBaseChild:OnDestroy() + if self.ShopPanel then + self.ShopPanel:OnDestroy() + end + if self.PanelDic and next(self.PanelDic) then + for _, panel in pairs(self.PanelDic) do + if panel.OnDestroy then + panel:OnDestroy() + end + end + end +end + +function XUiActivityBaseChild:OnDisable() + XEventManager.RemoveEventListener(XEventId.EVENT_NEWYEARYUNSHI_CLOSE_REFRESH, self.Update, self) +end + +function XUiActivityBaseChild:Update() + self:OnSelectedTog(self.SelectIndex) +end + +function XUiActivityBaseChild:OnGetEvents() + return { XEventId.EVENT_FINISH_TASK, XEventId.EVENT_ACTIVITY_INFO_UPDATE } +end + +function XUiActivityBaseChild:OnNotify(evt, ...) + local args = {...} + if evt == XEventId.EVENT_FINISH_TASK then + self.AutoRefresh = true + self.PanelNoticeTitleBtnGroup:SelectIndex(self.SelectIndex) + elseif evt == XEventId.EVENT_ACTIVITY_INFO_UPDATE then + if next(self.AcitivityTypeGroups[args[1]]) then + self:OnCheckRedPointByType(args[1]) + end + local panel = self.SelectedPanel + if panel.UpdateInfo then + panel:UpdateInfo() + end + end + +end + +function XUiActivityBaseChild:OnCheckRedPointRegression() + self:OnCheckRedPoint() +end + +-- 只刷新tog红点不刷新界面 +function XUiActivityBaseChild:OnCheckRedPoint(index, id) + index = index or self.SelectIndex + id = id or self.SelectActvityId + if not index or not id then return end + local uiButton = self.TabBtns[index] + local needRedPoint = XDataCenter.ActivityManager.CheckRedPointByActivityId(id) + if not uiButton then -- 海外修改 + return + end + uiButton:ShowReddot(needRedPoint) + + local subGroupIndex = uiButton.SubGroupIndex + if subGroupIndex and self.TabBtns[subGroupIndex] then + local needRed = false + for _, btn in pairs(self.TabBtns) do + if btn.SubGroupIndex and btn.SubGroupIndex == subGroupIndex + and btn.ReddotObj.activeSelf then + needRed = true + break + end + end + self.TabBtns[subGroupIndex]:ShowReddot(needRed) + end +end + +-- 刷新该活动类型的tog红点 +function XUiActivityBaseChild:OnCheckRedPointByType(type) + if not type then return end + local typeGroup = self.AcitivityTypeGroups[type] + if not typeGroup then return end + for k, v in pairs(typeGroup) do + self:OnCheckRedPoint(v.BtnIndex, v.ActId) + end +end + +function XUiActivityBaseChild:GetCertainBtnModel(index, hasChild, pos, totalNum) + if index == BTN_INDEX.First then + if hasChild then + return self.BtnFirstHasSnd + else + return self.BtnFirst + end + elseif index == BTN_INDEX.Second then + if totalNum == 1 then + return self.BtnSecondAll + end + + if pos == 1 then + return self.BtnSecondTop + elseif pos == totalNum then + return self.BtnSecondBottom + else + return self.BtnSecond + end + end +end + +function XUiActivityBaseChild:UpdateActivityInfos(selectIndex, selectId) + self.AcitivityIndexDic = {} + self:UpdateLeftTabBtns(selectIndex, selectId) +end + +function XUiActivityBaseChild:UpdateLeftTabBtns(selectIndex, selectId) + self.TabBtns = {} + local btnIndex = 0 + local selectIdToIndex = selectIndex + local firstRedPointIndex + + --一级标题 + for groupId, activityGroupInfo in ipairs(self.ActivityGroupInfos) do + local activityGroupCfg = activityGroupInfo.ActivityGroupCfg + local activityCfgs = activityGroupInfo.ActivityCfgs + local numOfActivityCfgs = #activityCfgs + + local btnModel = self:GetCertainBtnModel(BTN_INDEX.First, numOfActivityCfgs > 1) + local btn = CS.UnityEngine.Object.Instantiate(btnModel) + btn.transform:SetParent(self.PanelNoticeTitleBtnGroup.transform, false) + btn.gameObject:SetActiveEx(true) + btn:SetName(activityGroupCfg.Name) + + local bg1 = btn.transform:FindTransform("RImgBg1") + if bg1 then bg1:GetComponent("RawImage"):SetRawImage(activityGroupCfg.Bg) end + local bg2 = btn.transform:FindTransform("RImgBg2") + if bg2 then bg2:GetComponent("RawImage"):SetRawImage(activityGroupCfg.Bg) end + local bg3 = btn.transform:FindTransform("RImgBg3") + if bg3 then bg3:GetComponent("RawImage"):SetRawImage(activityGroupCfg.Bg) end + + local uiButton = btn:GetComponent("XUiButton") + tableInsert(self.TabBtns, uiButton) + btnIndex = btnIndex + 1 + local firstNeedRed = false + + --二级标题 + local needRedPoint + local firstIndex = btnIndex + local onlyOne = numOfActivityCfgs == 1 + for activityIndex, activityCfg in ipairs(activityCfgs) do + needRedPoint = XDataCenter.ActivityManager.CheckRedPointByActivityId(activityCfg.Id) + if not onlyOne then + local tmpBtnModel = self:GetCertainBtnModel(BTN_INDEX.Second, nil, activityIndex, numOfActivityCfgs) + local tmpBtn = CS.UnityEngine.Object.Instantiate(tmpBtnModel) + tmpBtn:SetName(activityCfg.Name) + tmpBtn.transform:SetParent(self.PanelNoticeTitleBtnGroup.transform, false) + tmpBtn.gameObject:SetActiveEx(true) + + local tmpUiButton = tmpBtn:GetComponent("XUiButton") + tmpUiButton.SubGroupIndex = firstIndex + tableInsert(self.TabBtns, tmpUiButton) + btnIndex = btnIndex + 1 + + if needRedPoint then + tmpUiButton:ShowReddot(true) + if not firstRedPointIndex then + firstRedPointIndex = btnIndex + end + firstNeedRed = true + else + tmpUiButton:ShowReddot(false) + end + else + firstNeedRed = needRedPoint + if needRedPoint then + if not firstRedPointIndex then + firstRedPointIndex = btnIndex + end + end + end + + local activityIndexInfo = { + ActivityIndex = activityIndex, + GroupId = groupId + } + self.AcitivityIndexDic[btnIndex] = activityIndexInfo + if activityCfg.Id == selectId then + selectIdToIndex = btnIndex + end + if not self.AcitivityTypeGroups[activityCfg.ActivityType] then + self.AcitivityTypeGroups[activityCfg.ActivityType] = {} + end + tableInsert(self.AcitivityTypeGroups[activityCfg.ActivityType] ,{BtnIndex = btnIndex, ActId = activityCfg.Id}) + end + uiButton:ShowReddot(firstNeedRed) + end + + self.PanelNoticeTitleBtnGroup:Init(self.TabBtns, function(index) self:OnSelectedTog(index) end) + self.SelectIndex = selectIdToIndex or selectIndex or firstRedPointIndex or 1 +end + +function XUiActivityBaseChild:OnSelectedTog(index) + self.SelectIndex = index + + local activityIndexInfo = self.AcitivityIndexDic[index] + if not activityIndexInfo or not next(activityIndexInfo) then + return + end + local groupId = activityIndexInfo.GroupId + local activityIndex = activityIndexInfo.ActivityIndex + local activityGroupInfo = self.ActivityGroupInfos[groupId] + local activityCfgs = activityGroupInfo.ActivityCfgs + local activityCfg = activityCfgs[activityIndex] + self.SelectActvityId = activityCfg.Id + + if self.SelectedPanel then + if self.SelectedPanel.OnDisable then + self.SelectedPanel:OnDisable() + end + self.SelectedPanel.GameObject:SetActiveEx(false) + end + --刷新右边UI + if activityCfg.ActivityType == XActivityConfigs.ActivityType.Task then + self.PanelTask.gameObject:SetActiveEx(true) + self:UpdatePanelTask(activityCfg) + self.SelectedPanel = self.TaskPanel + elseif activityCfg.ActivityType == XActivityConfigs.ActivityType.Shop then + self.PanelShop.gameObject:SetActiveEx(true) + self:UpdatePanelShop(activityCfg) + self.SelectedPanel = self.ShopPanel + elseif activityCfg.ActivityType == XActivityConfigs.ActivityType.Skip then + self.PanelSkip.gameObject:SetActiveEx(true) + self:UpdatePanelSkip(activityCfg) + self.SelectedPanel = self.SkipPanel + elseif activityCfg.ActivityType == XActivityConfigs.ActivityType.Link then + self.PanelReward.gameObject:SetActiveEx(true) + self:UpdatePanelLink(activityCfg) + self.SelectedPanel = self.LinkPanel + else + self:UpdatePanel(activityCfg) + end + + if activityCfg.ActivityType ~= XActivityConfigs.ActivityType.Task then + self.PanelTask.gameObject:SetActiveEx(false) + end + + if activityCfg.ActivityBgType == XActivityConfigs.ActivityBgType.Image then + self.SpineRoot.gameObject:SetActiveEx(false) + self.RImgContentBg.gameObject:SetActiveEx(true) + self.RImgContentBg:SetRawImage(activityCfg.ActivityBg) + elseif activityCfg.ActivityBgType == XActivityConfigs.ActivityBgType.Spine then + self.SpineRoot.gameObject:SetActiveEx(true) + self.RImgContentBg.gameObject:SetActiveEx(false) + self.SpineRoot:LoadPrefab(activityCfg.ActivityBg) + else + self.SpineRoot.gameObject:SetActiveEx(false) + self.RImgContentBg.gameObject:SetActiveEx(true) + self.RImgContentBg:SetRawImage(activityCfg.ActivityBg) + end + + --刷新小红点 + if activityCfg.ActivityType == XActivityConfigs.ActivityType.SendInvitation then + XDataCenter.RegressionManager.HandleReadSendInvitationActivity() + elseif activityCfg.ActivityType == XActivityConfigs.ActivityType.AcceptInvitation then + XDataCenter.RegressionManager.HandleReadAcceptInvitationActivity() + elseif activityCfg.ActivityType == XActivityConfigs.ActivityType.Link then + XDataCenter.ActivityManager.HandleLinkActivityRedPoint(activityCfg.Id) + else + XDataCenter.ActivityManager.SaveInGameNoticeReadList(activityCfg.Id) + end + + local uiButton = self.TabBtns[index] + local needRedPoint = XDataCenter.ActivityManager.CheckRedPointByActivityId(activityCfg.Id) + uiButton:ShowReddot(needRedPoint) + + --判断一级按钮小红点 + local subGroupIndex = uiButton.SubGroupIndex + if subGroupIndex and self.TabBtns[subGroupIndex] then + local needRed = false + for _, btn in pairs(self.TabBtns) do + if btn.SubGroupIndex and btn.SubGroupIndex == subGroupIndex + and btn.ReddotObj.activeSelf then + needRed = true + break + end + end + self.TabBtns[subGroupIndex]:ShowReddot(needRed) + end + + if not self.AutoRefresh then + self:PlayAnimation("QieHuanTwo", function() + XLuaUiManager.SetMask(false) + self:OnAnimFinished(activityCfg) + end, function() + XLuaUiManager.SetMask(true) + self:OnAnimBegin(activityCfg) + end) + else + self.AutoRefresh = nil + end +end + +function XUiActivityBaseChild:UpdatePanelTask(activityCfg) + self.TaskPanel = self.TaskPanel or XUiPanelTask.New(self.PanelTask.gameObject, self) + self.TaskPanel:Refresh(activityCfg) +end + +function XUiActivityBaseChild:UpdatePanelShop(activityCfg) + self.ShopPanel = self.ShopPanel or XUiPanelShop.New(self.PanelShop.gameObject, self) + self.ShopPanel:Refresh(activityCfg) +end + +function XUiActivityBaseChild:UpdatePanelSkip(activityCfg) + self.SkipPanel = self.SkipPanel or XUiPanelSkip.New(self.PanelSkip.gameObject) + self.SkipPanel:Refresh(activityCfg) +end + +function XUiActivityBaseChild:UpdatePanelLink(activityCfg) + self.LinkPanel = self.LinkPanel or XUiPanelLink.New(self.PanelReward.gameObject, self) + self.LinkPanel:Refresh(activityCfg) +end + +function XUiActivityBaseChild:UpdatePanel(activityCfg) + local assetPath = activityCfg.ActivityPrefabPath + if not assetPath then return end + local type = activityCfg.ActivityType + + if not self.PanelDic[type] then + local panelLoadPrefab = self.PanelLoadPrefabList[self.UnusedLoadPrefabIndex] + if not panelLoadPrefab then + XLog.Error("PanelLoadPrefab is not engough, you need to mod the asset in res") + return + end + local panelGameObject = panelLoadPrefab:LoadPrefab(assetPath) + self.UnusedLoadPrefabIndex = self.UnusedLoadPrefabIndex + 1 + if type == XActivityConfigs.ActivityType.SendInvitation then + self.PanelDic[type] = XUiPanelSendInvitation.New(panelGameObject, self) + elseif type == XActivityConfigs.ActivityType.AcceptInvitation then + self.PanelDic[type] = XUiPanelAcceptInvitation.New(panelGameObject, self) + elseif type == XActivityConfigs.ActivityType.JigsawPuzzle then + self.PanelDic[type] = XUiJigsawPuzzle.New(panelGameObject, self) + elseif type == XActivityConfigs.ActivityType.ConsumeReward then + self.PanelDic[type] = XUiConsumeReward.New(panelGameObject, self) + elseif type == XActivityConfigs.ActivityType.ScratchTicket then + self.PanelDic[type] = XUiScratchTicket.New(panelGameObject, self) + elseif type == XActivityConfigs.ActivityType.ScratchTicketGolden then + self.PanelDic[type] = XUiScratchTicket.New(panelGameObject, self) + end + end + + if self.PanelDic[type] then + local selectedPanel = self.PanelDic[type] + selectedPanel.GameObject:SetActiveEx(true) + selectedPanel:Refresh(activityCfg) + self.SelectedPanel = selectedPanel + else + -- 进入此处说明未用ClassName.New(panelGameObject)对gameObject进行初始化 + XLog.Error("you need to use ClassName.New(panelGameObject) in this activityType, activityType is " .. type) + end +end + +function XUiActivityBaseChild:OnAnimFinished(activityCfg) + local type = activityCfg.ActivityType + local panel = self.PanelDic[type] + if not panel then + return + end + if panel.OnAnimFinished then + panel:OnAnimFinished() + end +end + +function XUiActivityBaseChild:OnAnimBegin(activityCfg) + local type = activityCfg.ActivityType + local panel = self.PanelDic[type] + if not panel then + return + end + if panel.OnAnimBegin then + panel:OnAnimBegin() + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiActivityBase/XUiActivityLink.lua b/Resources/Scripts/XUi/XUiActivityBase/XUiActivityLink.lua new file mode 100644 index 00000000..bf076121 --- /dev/null +++ b/Resources/Scripts/XUi/XUiActivityBase/XUiActivityLink.lua @@ -0,0 +1,28 @@ +local XUiGridActivityLink = require("XUi/XUiActivityBase/XUiGridActivityLink") +local XUiActivityBaseLink = XLuaUiManager.Register(XLuaUi, "UiActivityBaseLink") + +function XUiActivityBaseLink:OnStart() + self:InitDynamicTable() + self:UpdateList() + --local bg = self.BtnFirst.transform:Find("RImgBg"):GetComponent("RawImage") + --bg:SetRawImage(CS.XGame.ClientConfig:GetString("ActivityLinkButtonBg")) + self.BtnFirst:SetName(CS.XGame.ClientConfig:GetString("ActivityLinkButtonName")) +end + +function XUiActivityBaseLink:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.SViewLinkList) + self.DynamicTable:SetProxy(XUiGridActivityLink) + self.DynamicTable:SetDelegate(self) +end + +function XUiActivityBaseLink:UpdateList() + self.LinkDataList = XActivityConfigs.GetActivityLinkTemplate() + self.DynamicTable:SetDataSource(self.LinkDataList) + self.DynamicTable:ReloadDataASync() +end + +function XUiActivityBaseLink:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:UpdateGrid(self.LinkDataList[index]) + end +end diff --git a/Resources/Scripts/XUi/XUiActivityBase/XUiConsumeReward.lua b/Resources/Scripts/XUi/XUiActivityBase/XUiConsumeReward.lua new file mode 100644 index 00000000..110f8649 --- /dev/null +++ b/Resources/Scripts/XUi/XUiActivityBase/XUiConsumeReward.lua @@ -0,0 +1,115 @@ +local CSXTextManagerGetText = CS.XTextManager.GetText +local tableInsert = table.insert +local ForceRebuildLayoutImmediate = CS.UnityEngine.UI.LayoutRebuilder.ForceRebuildLayoutImmediate + +local XUiGridConsumeReward = require("XUi/XUiActivityBase/XUiGridConsumeReward") + +local XPuzzleActivityManager +local XUiConsumeReward = XClass(nil, "XUiConsumeReward") + +function XUiConsumeReward:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + self:Init() +end + +function XUiConsumeReward:Init() + self.LayoutGroup = self.GridRewardPanel:GetComponent("HorizontalLayoutGroup") + self.GridRewardPool = {} + self.GridMiniRewardPool = {} + self.LimitPosArr = {} + self.BarWidth = self.ImgJd.transform.rect.width +end + +function XUiConsumeReward:Refresh(activityCfg) + local taskLimitId = activityCfg.Params[1] + local taskLimitCfg = XTaskConfig.GetTimeLimitTaskCfg(taskLimitId) + self.TaskIdList = taskLimitCfg.TaskId + local showBeginTime = activityCfg.ShowBeginTime + local showEndTime = activityCfg.ShowEndTime + self.TxtTime.text = CSXTextManagerGetText("ActivityConsumeRewardTime", showBeginTime, showEndTime) + + self.CurIndex, self.CurProgress, self.CurConsumeValue, self.CurTargetValue = self:GetTargetRewardIndexandProgress() + -- XLog.Debug(self.CurIndex, self.CurProgress, self.CurConsumeValue, self.CurTargetValue) + self.TxtTarget.text = "/"..self.CurTargetValue + + self:RefreshGridReward() + self:RefreshProgressBar() + self.TxtNumber.text = self.CurConsumeValue + self:RefreshFinalReward(activityCfg) +end + +function XUiConsumeReward:RefreshFinalReward(activityCfg) + if activityCfg.Params[2] and activityCfg.Params[2] ~= 0 then + local taskLimitId = activityCfg.Params[2] + local taskLimitCfg = XTaskConfig.GetTimeLimitTaskCfg(taskLimitId) + local onCreate = function(item, data) + item:Refresh(data) + end + XUiHelper.CreateTemplates(self.RootUi, self.GridMiniRewardPool, taskLimitCfg.TaskId, XUiGridConsumeReward.New, self.GridMiniReward.gameObject, self.GridMiniRewardPanel, onCreate) + end +end + +function XUiConsumeReward:RefreshGridReward() + local halfGapWidth = (self.BarWidth / #self.TaskIdList - self.GridReward.transform.rect.width) / 2 + self.LayoutGroup.padding.left = math.ceil(-halfGapWidth) + self.LayoutGroup.padding.right = math.ceil(-halfGapWidth) + local onCreate = function(item, data) + item:Refresh(data) + end + XUiHelper.CreateTemplates(self.RootUi, self.GridRewardPool, self.TaskIdList, XUiGridConsumeReward.New, self.GridReward.gameObject, self.GridRewardPanel, onCreate) + ForceRebuildLayoutImmediate(self.GridRewardPanel) -- 强制刷新布局 +end + +function XUiConsumeReward:RefreshProgressBar() + local halfBarWidth = math.ceil(self.BarWidth/2) + self.LimitPosArr = {} + for i = 0, self.GridRewardPanel.childCount - 1 do + local limitPos = halfBarWidth + math.floor(self.GridRewardPanel:GetChild(i).transform.localPosition.x) + tableInsert(self.LimitPosArr, limitPos) + end + + if self.CurIndex == 1 then + self.ImgJd.fillAmount = self.LimitPosArr[1] * self.CurProgress / self.BarWidth + elseif self.CurIndex == #self.LimitPosArr and self.CurConsumeValue >= self.CurTargetValue then + self.ImgJd.fillAmount = 1 + self.CurConsumeValue = self.CurTargetValue + else + local curBarPix = (self.LimitPosArr[self.CurIndex] - self.LimitPosArr[self.CurIndex-1]) * self.CurProgress + self.ImgJd.fillAmount = (curBarPix + self.LimitPosArr[self.CurIndex-1]) / self.BarWidth + end +end + +function XUiConsumeReward:GetTargetRewardIndexandProgress() -- 返回值:当前的目标序号,从上一目标到当前目标的进度,当前的总消费值,当前目标的消费值 + if not self.TaskIdList then + return 1, 0 + end + + local curConsumeValue = XDataCenter.TaskManager.GetTaskDataById(self.TaskIdList[#self.TaskIdList]).Schedule[1].Value -- 取最后一个任务进度作为当前任务总进度 + local targetRewardIndex = 1 + local progress = 0 + local lastTargetConsumeValue = 0 + for _, taskId in ipairs(self.TaskIdList) do + local taskCfg = XTaskConfig.GetTaskCfgById(taskId) + if curConsumeValue >= taskCfg.Result then + targetRewardIndex = targetRewardIndex + 1 + lastTargetConsumeValue = taskCfg.Result + else + local remainConsume = curConsumeValue - lastTargetConsumeValue + progress = remainConsume / (taskCfg.Result - lastTargetConsumeValue) + + break + end + end + + if targetRewardIndex > #self.TaskIdList then + targetRewardIndex = #self.TaskIdList + progress = 1 + end + + return targetRewardIndex, progress, curConsumeValue, XTaskConfig.GetTaskCfgById(self.TaskIdList[targetRewardIndex]).Result +end + +return XUiConsumeReward \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiActivityBase/XUiGridAcceptInvitation.lua b/Resources/Scripts/XUi/XUiActivityBase/XUiGridAcceptInvitation.lua new file mode 100644 index 00000000..adcda330 --- /dev/null +++ b/Resources/Scripts/XUi/XUiActivityBase/XUiGridAcceptInvitation.lua @@ -0,0 +1,25 @@ +-- +--Author: wujie +--Note: 回归活动发送邀请奖励格子 + +local XUiGridAcceptInvitation = XClass(nil, "XUiGridAcceptInvitation") + +function XUiGridAcceptInvitation:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + + self.GridCommon = XUiGridCommon.New(rootUi, self.PanelGridCommon) +end + +function XUiGridAcceptInvitation:UpdateGetStatus(isGet) + self.ImgGet.gameObject:SetActiveEx(isGet) +end + +function XUiGridAcceptInvitation:Refresh(itemId) + if not itemId then return end + self.GridCommon:Refresh(itemId) +end + +return XUiGridAcceptInvitation \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiActivityBase/XUiGridActivityLink.lua b/Resources/Scripts/XUi/XUiActivityBase/XUiGridActivityLink.lua new file mode 100644 index 00000000..6b26ab57 --- /dev/null +++ b/Resources/Scripts/XUi/XUiActivityBase/XUiGridActivityLink.lua @@ -0,0 +1,28 @@ +local XUiGridActivityLink = XClass(nil, "XUiGridActivityLink") + +function XUiGridActivityLink:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:AutoAddListener() +end + +function XUiGridActivityLink:AutoAddListener() + self.BtnGo.CallBack = function() + self:OnBtnLinkClick() + end +end + +function XUiGridActivityLink:UpdateGrid(data) + self.Data = data + --刷新图标 + self.ImgIcon:SetRawImage(self.Data.Icon) + --显示链接名字 + self.TxtLink.text = self.Data.LinkName +end + +function XUiGridActivityLink:OnBtnLinkClick() + CS.UnityEngine.Application.OpenURL(self.Data.LinkUrl) +end + +return XUiGridActivityLink \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiActivityBase/XUiGridConsumeReward.lua b/Resources/Scripts/XUi/XUiActivityBase/XUiGridConsumeReward.lua new file mode 100644 index 00000000..d8952ca2 --- /dev/null +++ b/Resources/Scripts/XUi/XUiActivityBase/XUiGridConsumeReward.lua @@ -0,0 +1,46 @@ +local XUiGridConsumeReward = XClass(nil, "XUiGridConsumeReward") + +function XUiGridConsumeReward:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:Init(rootUi) +end + +function XUiGridConsumeReward:Init(rootUi) + self.RootUi = rootUi + self.CommonGrid = XUiGridCommon.New(self.RootUi, self.GridCommon) +end + +function XUiGridConsumeReward:Refresh(taskId) + self.GameObject:SetActiveEx(true) + self:RegisterBtnListener(taskId) + self.TaskId = taskId + local taskCfg = XTaskConfig.GetTaskCfgById(taskId) + local taskData = XDataCenter.TaskManager.GetTaskDataById(taskId) + local rewardGood = XRewardManager.GetRewardList(taskCfg.RewardId)[1] + self.CommonGrid:Refresh(rewardGood) + if self.TxtNumber then + self.TxtNumber.text = taskCfg.Result + end + + self.PanelEffect.gameObject:SetActiveEx(false) + self.BtnGet.gameObject:SetActiveEx(false) + self.ImgReceive.gameObject:SetActiveEx(false) + if taskData.State == XDataCenter.TaskManager.TaskState.Achieved then + self.PanelEffect.gameObject:SetActiveEx(true) + self.BtnGet.gameObject:SetActiveEx(true) + elseif taskData.State == XDataCenter.TaskManager.TaskState.Finish then + self.ImgReceive.gameObject:SetActiveEx(true) + end +end + +function XUiGridConsumeReward:RegisterBtnListener(taskId) + self.BtnGet.CallBack = function () + XDataCenter.TaskManager.FinishTask(taskId, function(rewardGoodsList) + XUiManager.OpenUiObtain(rewardGoodsList) + end) + end +end + +return XUiGridConsumeReward \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiActivityBase/XUiGridPuzzlePiece.lua b/Resources/Scripts/XUi/XUiActivityBase/XUiGridPuzzlePiece.lua new file mode 100644 index 00000000..4709c17b --- /dev/null +++ b/Resources/Scripts/XUi/XUiActivityBase/XUiGridPuzzlePiece.lua @@ -0,0 +1,78 @@ +XUiGridPuzzlePiece = XClass(nil, "XUiGridPuzzlePiece") + +function XUiGridPuzzlePiece:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + self.GameObject:SetActiveEx(true) + self:SetButtonCallBack() + self.LastState = XPuzzleActivityConfigs.PuzzleCondition.Activated + self.EffectHint.gameObject:SetActiveEx(false) + self.EffectFlip.gameObject:SetActiveEx(false) +end + +function XUiGridPuzzlePiece:OnDestroy() +end + +function XUiGridPuzzlePiece:RemoveTimer() + if self.OpenTimer then + XScheduleManager.UnSchedule(self.OpenTimer) + self.OpenTimer = nil + end + if self.CloseTimer then + XScheduleManager.UnSchedule(self.CloseTimer) + self.CloseTimer = nil + end +end + +function XUiGridPuzzlePiece:SetButtonCallBack() + self.Btn.CallBack = function() + self:OnBtnActiveClick() + end +end + +function XUiGridPuzzlePiece:OnBtnActiveClick() + if self.State ~= XPuzzleActivityConfigs.PuzzleRewardState.CanReward then + if self.State == XPuzzleActivityConfigs.PuzzleRewardState.Unrewarded then + XUiManager.TipText("ActivityPuzzleNoItem") + end + return + end + XDataCenter.PuzzleActivityManager.PuzzleActivityFlipPieceRequest(self.PuzzleId, self.Index) +end + +function XUiGridPuzzlePiece:Refresh() + self.State = XDataCenter.PuzzleActivityManager.GetPuzzleActPieceData(self.PuzzleId ,self.Index) + if self.State ~= self.LastState then + if self.State == XPuzzleActivityConfigs.PuzzleCondition.NotCollected then + -- do nothing + elseif self.State == XPuzzleActivityConfigs.PuzzleCondition.Inactivated then + self.EffectHint.gameObject:SetActiveEx(true) + elseif self.State == XPuzzleActivityConfigs.PuzzleCondition.Activated then + self:ShowFlipEffect() + end + end + if self.State == XPuzzleActivityConfigs.PuzzleCondition.Activated then + self.Btn:SetButtonState(CS.UiButtonState.Disable) + end + self.LastState = self.State +end + +function XUiGridPuzzlePiece:ShowFlipEffect() + self:RemoveTimer() + CS.XAudioManager.PlaySound(XSoundManager.UiBasicsMusic.Common_UiObtain) + self.OpenTimer = XScheduleManager.ScheduleOnce(function() + self.EffectFlip.gameObject:SetActiveEx(true) + end, 20) + self.CloseTimer = XScheduleManager.ScheduleOnce(function() + self.EffectFlip.gameObject:SetActiveEx(false) + end, 1500) +end + +function XUiGridPuzzlePiece:Init(puzzleId, index) + self.PuzzleId = puzzleId + self.Index = index + self.PieceTemplate = XDataCenter.PuzzleActivityManager.GetPieceTemplate(puzzleId, index) + self.Btn:SetRawImage(self.PieceTemplate.CoverImage) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiActivityBase/XUiGridSendInvitation.lua b/Resources/Scripts/XUi/XUiActivityBase/XUiGridSendInvitation.lua new file mode 100644 index 00000000..6cd435a1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiActivityBase/XUiGridSendInvitation.lua @@ -0,0 +1,57 @@ +-- +--Author: wujie +--Note: 回归活动发送邀请奖励格子 + +local XUiGridSendInvitation = XClass(nil, "XUiGridSendInvitation") + +function XUiGridSendInvitation:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + + self.GridCommon = XUiGridCommon.New(rootUi, self.PanelGridCommon) + self.BtnGet.CallBack = function() self:OnBtnGetClick() end +end + +function XUiGridSendInvitation:UpdateGetStatus() + local isHaveGet = XDataCenter.RegressionManager.IsSendInvitationRewardHaveGet(self.InvitationRewardId) + self.ImgGet.gameObject:SetActiveEx(isHaveGet) + local isCanGet = XDataCenter.RegressionManager.IsSendInvitationRewardCanGet(self.InvitationRewardId) + self.PanelEffect.gameObject:SetActiveEx(isCanGet) +end + +function XUiGridSendInvitation:Refresh(id) + if not id then return end + self.InvitationRewardId = id + local sendInvitationRewardTemplate = XRegressionConfigs.GetSendInvitationRewardTemplate(id) + local rewardList = XRewardManager.GetRewardList(sendInvitationRewardTemplate.RewardId) + local firstIndex = 1 + local reward = rewardList[firstIndex] + if reward then + self.GridCommon:Refresh(reward) + end + local needAcceptedCount = sendInvitationRewardTemplate.People + self.TxtInvitationNum.text = needAcceptedCount + self:UpdateGetStatus() +end + +function XUiGridSendInvitation:OnBtnGetClick() + if not self.InvitationRewardId then return end + if not XDataCenter.RegressionManager.IsInvitationActivityInTime() then + XUiManager.TipError(CS.XTextManager.GetText("RegressionInvitationActivityOver")) + return + end + + if XDataCenter.RegressionManager.IsSendInvitationRewardHaveGet(self.InvitationRewardId) then + XUiManager.TipError(CS.XTextManager.GetText("RegressionTaskScheduleRewardHaveGet")) + elseif XDataCenter.RegressionManager.IsSendInvitationRewardCanGet(self.InvitationRewardId) then + XDataCenter.RegressionManager.RequestGetInviteReward(self.InvitationRewardId, function() + self:UpdateGetStatus() + end) + else + XUiManager.TipError(CS.XTextManager.GetText("RegressionSendInvitationRewardNeedMore")) + end +end + +return XUiGridSendInvitation \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiActivityBase/XUiJigsawPuzzle.lua b/Resources/Scripts/XUi/XUiActivityBase/XUiJigsawPuzzle.lua new file mode 100644 index 00000000..97389a68 --- /dev/null +++ b/Resources/Scripts/XUi/XUiActivityBase/XUiJigsawPuzzle.lua @@ -0,0 +1,124 @@ +local XUiJigsawPuzzle = XClass(nil, "XUiJigsawPuzzle") + +function XUiJigsawPuzzle:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self.RewardPanelList = {} + self.PieceGroup = {} + self.IsInit = false + self.ButtonLastState = nil + XTool.InitUiObject(self) + self.ImgComplete.gameObject:SetActiveEx(false) + self.BtnFinish.gameObject:SetActiveEx(true) + self.BtnFinish.CallBack = function() self:OnBtnFinishClick() end +end + +function XUiJigsawPuzzle:OnDestroy() + for _,v in pairs(self.PieceGroup) do + v:RemoveTimer() + end +end + +function XUiJigsawPuzzle:InitButton() + local count = XDataCenter.PuzzleActivityManager.GetPieceAmountById(self.PuzzleId) + for index=1, count do + local ui = CS.UnityEngine.Object.Instantiate(self.GridPiece) + ui.transform:SetParent(self.GridPiece.parent, false) + local pieceGrid = XUiGridPuzzlePiece.New(ui) + pieceGrid:Init(self.PuzzleId, index) + self.PieceGroup[index] = pieceGrid + end +end + +function XUiJigsawPuzzle:Refresh(activityCfg) + if not (self.ActivityCfg or activityCfg) then return end + if not self.IsInit or self.ActivityCfg ~= activityCfg then + self.ActivityCfg = activityCfg or self.ActivityCfg + self.PuzzleId = self.ActivityCfg.Params[1] + + self.TxtContentTimeTask.text = XActivityConfigs.GetActivityTimeStr(self.ActivityCfg.Id) + self.TxtContentTitleTask.text = self.ActivityCfg.ActivityTitle + self.TxtContentTask.text = self.ActivityCfg.ActivityDes + -- end set normal activity info -- + + self.PuzzleData = XDataCenter.PuzzleActivityManager.GetActivityPuzzleTemplateById(self.PuzzleId) + self.ImgPicture:SetRawImage(self.PuzzleData.GroupCfg.BgImage) + XDataCenter.PuzzleActivityManager.PuzzleActivityDataRequest(self.PuzzleId) + self:SetReward() + self:InitButton() + self.IsInit = true + end + self:UpdateInfo() +end + +function XUiJigsawPuzzle:UpdateInfo() + for index, grid in ipairs(self.PieceGroup) do + grid:Refresh() + end + self:UpdateButtonState() +end + +function XUiJigsawPuzzle:OnAnimFinished() + self.ImgPicture.enabled = true +end + +function XUiJigsawPuzzle:OnAnimBegin() + self.ImgPicture.enabled = false +end + +function XUiJigsawPuzzle:UpdateButtonState() + local state = self.PuzzleData.RewardState + if state ~= self.ButtonLastState then + if state == XPuzzleActivityConfigs.PuzzleRewardState.Unrewarded then + self.BtnFinish:SetButtonState(CS.UiButtonState.Disable) + elseif state == XPuzzleActivityConfigs.PuzzleRewardState.Rewarded then + self.BtnFinish.gameObject:SetActiveEx(false) + self.ImgComplete.gameObject:SetActiveEx(true) + elseif state == XPuzzleActivityConfigs.PuzzleRewardState.CanReward then + self.BtnFinish:SetButtonState(CS.UiButtonState.Normal) + end + end + self.ButtonLastState = state +end + +function XUiJigsawPuzzle:OnBtnFinishClick() + if self.PuzzleData.RewardState ~= XPuzzleActivityConfigs.PuzzleRewardState.CanReward then + return + end + local closeCallback = self:UpdateInfo() + XDataCenter.PuzzleActivityManager.PuzzleActivityGetRewardRequest(self.PuzzleId, function(rewardGoodsList) + self.ImgComplete.gameObject:SetActiveEx(true) + self.BtnFinish.gameObject:SetActiveEx(false) + XUiManager.OpenUiObtain(rewardGoodsList, nil, closeCallback, nil) + end) +end + +function XUiJigsawPuzzle:SetReward() + local rewards = XRewardManager.GetRewardList(self.PuzzleData.GroupCfg.RewardId) + -- reset reward panel + for i = 1, #self.RewardPanelList do + self.RewardPanelList[i]:Refresh() + end + + if not rewards then + return + end + + for i = 1, #rewards do + local panel = self.RewardPanelList[i] + if not panel then + if #self.RewardPanelList == 0 then + panel = XUiGridCommon.New(self.RootUi, self.GridCommon) + else + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommon) + ui.transform:SetParent(self.GridCommon.parent, false) + panel = XUiGridCommon.New(self.RootUi, ui) + end + table.insert(self.RewardPanelList, panel) + end + panel:Refresh(rewards[i]) + end +end + +return XUiJigsawPuzzle \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiActivityBase/XUiPanelAcceptInvitation.lua b/Resources/Scripts/XUi/XUiActivityBase/XUiPanelAcceptInvitation.lua new file mode 100644 index 00000000..1b4acbe2 --- /dev/null +++ b/Resources/Scripts/XUi/XUiActivityBase/XUiPanelAcceptInvitation.lua @@ -0,0 +1,143 @@ +-- +--Author: wujie +--Note: 回归活动接受邀请界面 +local XUiPanelAcceptInvitation = XClass(nil, "XUiPanelAcceptInvitation") + +local XUiGridAcceptInvitation = require("XUi/XUiActivityBase/XUiGridAcceptInvitation") + +function XUiPanelAcceptInvitation:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + + self.GridRewardList = { + XUiGridAcceptInvitation.New(self.GridReward1, rootUi), + XUiGridAcceptInvitation.New(self.GridReward2, rootUi), + XUiGridAcceptInvitation.New(self.GridReward3, rootUi), + } + self.InputField.placeholder.text = CS.XTextManager.GetText("RegressionAcceptInvitationDefaultText") + self.BtnHelp.CallBack = function() self:OnBtnHelpClick() end + self.RootUi:BindHelpBtnOnly(self.BtnHelp) + self.BtnCanGet.CallBack = function() self:OnBtnCanGetClick() end + self.InputField.onValueChanged:AddListener(function() self:OnInputFieldTextChanged() end) +end + +function XUiPanelAcceptInvitation:UpdateHeadContent() + if not self.ActivityId or not self.ActivityCfg then return end + local startTime, endTime = XRegressionConfigs.GetActivityTime(self.ActivityId) + if startTime and endTime then + local formatStr = "yyyy-MM-dd HH:mm" + self.TxtStartTime.text = XTime.TimestampToGameDateTimeString(startTime, formatStr) + self.TxtEndTime.text = XTime.TimestampToGameDateTimeString(endTime, formatStr) + end + + local helpId = self.ActivityCfg.Params[2] + self.BtnHelp.gameObject:SetActiveEx(helpId ~= nil and helpId ~= 0) + + self.TxtActivityTitle.text = self.ActivityCfg.ActivityTitle + local matchedStr = "\\n" + local replacedStr = "\n" + self.TxtActivityDesc.text = string.gsub(self.ActivityCfg.ActivityDes, matchedStr, replacedStr) +end + +function XUiPanelAcceptInvitation:UpdateInvitationContent(index) + if not self.UseCodeRewardIdList then return end + + local isGet = XDataCenter.RegressionManager.IsUseInvitationCodeRewardHaveGet(index) + local rewardList = XRewardManager.GetRewardList(self.UseCodeRewardIdList[index]) + local rewardCount = #rewardList + for i, grid in ipairs(self.GridRewardList) do + if i > rewardCount then + grid.GameObject:SetActiveEx(false) + else + grid.GameObject:SetActiveEx(true) + grid:Refresh(rewardList[i]) + grid:UpdateGetStatus(isGet) + end + end +end + +function XUiPanelAcceptInvitation:UpdateBtnStatus(index) + local isGet = XDataCenter.RegressionManager.IsUseInvitationCodeRewardHaveGet(index) + if isGet then + self.BtnCanGet.gameObject:SetActiveEx(false) + self.ImgNotGet.gameObject:SetActiveEx(false) + self.ImgHaveGet.gameObject:SetActiveEx(true) + self.ImgInputFieldBg.gameObject:SetActiveEx(false) + else + self.ImgInputFieldBg.gameObject:SetActiveEx(true) + self.ImgHaveGet.gameObject:SetActiveEx(false) + local invitationCode = self.InputField.text + if string.IsNilOrEmpty(invitationCode) then + self.BtnCanGet.gameObject:SetActiveEx(false) + self.ImgNotGet.gameObject:SetActiveEx(true) + else + self.BtnCanGet.gameObject:SetActiveEx(true) + self.ImgNotGet.gameObject:SetActiveEx(false) + end + end +end + +function XUiPanelAcceptInvitation:Refresh(activityCfg) + self.ActivityCfg = activityCfg + local activityId = XDataCenter.RegressionManager.GetInvitationActivityId() + local invitationTemplateId = XRegressionConfigs.GetInvitationTemplateId(activityId) + local invitationTemplate = XRegressionConfigs.GetInvitationTemplate(invitationTemplateId) + self.ActivityId = activityId + self.UseCodeRewardIdList = invitationTemplate.UseCodeReward + + self:UpdateHeadContent() + for i, _ in ipairs(self.UseCodeRewardIdList) do + if not XDataCenter.RegressionManager.IsUseInvitationCodeRewardHaveGet(i) then + self.ShowedRewardIndex = i + break + end + end + + self.ShowedRewardIndex = self.ShowedRewardIndex or #self.UseCodeRewardIdList + self:UpdateInvitationContent(self.ShowedRewardIndex) + self:UpdateBtnStatus(self.ShowedRewardIndex) +end + +function XUiPanelAcceptInvitation:OnBtnHelpClick() + if not self.ActivityCfg then return end + local helpId = self.ActivityCfg.Params[2] + local template = XHelpCourseConfig.GetHelpCourseTemplateById(helpId) + XUiManager.ShowHelpTip(template.Function) +end + +function XUiPanelAcceptInvitation:OnBtnCanGetClick() + if not XDataCenter.RegressionManager.IsInvitationActivityInTime() then + XUiManager.TipError(CS.XTextManager.GetText("RegressionInvitationActivityOver")) + return + end + + local invitationCode = self.InputField.text + if string.IsNilOrEmpty(invitationCode) then return end + if XDataCenter.RegressionManager.GetInvitationCode() == invitationCode then + XUiManager.TipError(CS.XTextManager.GetText("RegressionAcceptInvitationCodeNotUseSelf")) + return + elseif XDataCenter.RegressionManager.IsInvitationCodeHaveUse(invitationCode) then + XUiManager.TipError(CS.XTextManager.GetText("RegressionAcceptInvitationCodeHaveUse")) + return + end + XDataCenter.RegressionManager.HandleUseInvitationCodeRequest(invitationCode, function() + self:OnUseInviteCode() + end) +end + +function XUiPanelAcceptInvitation:OnInputFieldTextChanged() + if self.ShowedRewardIndex then + self:UpdateBtnStatus(self.ShowedRewardIndex) + end +end + +function XUiPanelAcceptInvitation:OnUseInviteCode() + if not self.UseCodeRewardIdList or not self.ShowedRewardIndex then return end + self.ShowedRewardIndex = math.min(self.ShowedRewardIndex, #self.UseCodeRewardIdList) + self:UpdateInvitationContent(self.ShowedRewardIndex) + self:UpdateBtnStatus(self.ShowedRewardIndex) +end + +return XUiPanelAcceptInvitation \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiActivityBase/XUiPanelLink.lua b/Resources/Scripts/XUi/XUiActivityBase/XUiPanelLink.lua new file mode 100644 index 00000000..c4de3367 --- /dev/null +++ b/Resources/Scripts/XUi/XUiActivityBase/XUiPanelLink.lua @@ -0,0 +1,113 @@ +local stringGsub = string.gsub +local tableInsert = table.insert +local CSGameEventManager = CS.XGameEventManager.Instance +local XUiPanelLink = XClass(nil, "XUiPanelLink") + +function XUiPanelLink:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + + self.RewardList = {} + self:AutoAddListener() +end + +function XUiPanelLink:AutoAddListener() + self.BtnGo.CallBack = function() + self:OnBtnGoClick() + end + self.BtnFinish.CallBack = function() + self:OnBtnFinishClick() + end +end + +function XUiPanelLink:Refresh(activityCfg) + self.ActivityCfg = activityCfg or self.ActivityCfg + + self.LinkCfg = XActivityConfigs.GetActivityLinkCfg(self.ActivityCfg.Params[1]) + self.TxtTitle.text = stringGsub(self.ActivityCfg.ActivityTitle, "\\n", "\n") + + local openTime = XDataCenter.TaskManager.GetLinkTimeTaskOpenTime(self.ActivityCfg.Params[2]) + local format = "yyyy-MM-dd HH:mm" + local openTimeStr = XTime.TimestampToGameDateTimeString(openTime, format) + --获取持续时间 + local timeLimitCfg = XTaskConfig.GetTimeLimitTaskCfg(self.ActivityCfg.Params[2]) + local durationTime = timeLimitCfg.Duration + local endTime = openTime + durationTime + local endTimeStr = XTime.TimestampToGameDateTimeString(endTime, format) + self.TxtTime.text = string.format("%s%s%s", openTimeStr, '~', endTimeStr) + self.TxtContent.text = stringGsub(self.ActivityCfg.ActivityDes, "\\n", "\n") + + --获取该活动对应的任务 + self.TaskDatas = XDataCenter.TaskManager.GetTimeLimitTaskListByGroupId(self.ActivityCfg.Params[2]) + if not self.TaskDatas or not self.TaskDatas[1] then + return + end + local taskConfig = XDataCenter.TaskManager.GetTaskTemplate(self.TaskDatas[1].Id) + self:RefreshButton() + --刷新奖励列表 + local rewards = XRewardManager.GetRewardList(taskConfig.RewardId) + if not rewards then + return + end + + for i = 1, #rewards do + local grid = self.RewardList[i] + if not grid then + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommon) + local tempTab = {} + tempTab.Transform = ui.transform + tempTab.GameObject = ui.gameObject + XTool.InitUiObject(tempTab) + ui.gameObject:SetActiveEx(true) + ui.transform:SetParent(self.PanelReward, false) + tempTab.Item = XUiGridCommon.New(self.RootUi, tempTab.GirdItem) + grid = tempTab + tableInsert(self.RewardList, tempTab) + end + grid.Item:Refresh(rewards[i]) + grid.PanelReceive.gameObject:SetActiveEx(false) + grid.PanelReceived.gameObject:SetActiveEx(false) + if self.TaskDatas[1].State == XDataCenter.TaskManager.TaskState.Achieved then + grid.PanelReceive.gameObject:SetActiveEx(true) + elseif self.TaskDatas[1].State == XDataCenter.TaskManager.TaskState.Finish then + grid.PanelReceived.gameObject:SetActiveEx(true) + end + end +end + +--根据任务状态刷新按钮显示 +function XUiPanelLink:RefreshButton() + self.BtnFinish.gameObject:SetActiveEx(false) + self.BtnGo.gameObject:SetActiveEx(false) + + if self.TaskDatas[1].State == XDataCenter.TaskManager.TaskState.Achieved then + self.BtnFinish.gameObject:SetActiveEx(true) + elseif self.TaskDatas[1].State == XDataCenter.TaskManager.TaskState.Active or self.TaskDatas[1].State == XDataCenter.TaskManager.TaskState.Finish then + self.BtnGo.gameObject:SetActiveEx(true) + end +end + +function XUiPanelLink:OnBtnGoClick() + --通知后端任务完成了 + if self.TaskDatas and self.TaskDatas[1] then + local taskCfg = XTaskConfig.GetTaskCfgById(self.TaskDatas[1].Id) + local conditionTemplates = XTaskConfig.GetTaskCondition(taskCfg.Condition[1]) + XDataCenter.ActivityManager.TellFinishLinkTask(conditionTemplates.Params[2], function() + self:Refresh() + CSGameEventManager:Notify(XEventId.EVENT_ACTIVITY_INFO_UPDATE, XActivityConfigs.ActivityType.Link) + end) + end + CS.UnityEngine.Application.OpenURL(self.LinkCfg.LinkUrl) +end + +function XUiPanelLink:OnBtnFinishClick() + XDataCenter.TaskManager.FinishTask(self.TaskDatas[1].Id, function(rewards) + XUiManager.OpenUiObtain(rewards, nil, function() + self:Refresh() + end, nil) + end) +end + +return XUiPanelLink \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiActivityBase/XUiPanelSendInvitation.lua b/Resources/Scripts/XUi/XUiActivityBase/XUiPanelSendInvitation.lua new file mode 100644 index 00000000..5282b867 --- /dev/null +++ b/Resources/Scripts/XUi/XUiActivityBase/XUiPanelSendInvitation.lua @@ -0,0 +1,147 @@ +-- +--Author: wujie +--Note: 回归活动发送邀请界面 +local XUiPanelSendInvitation = XClass(nil, "XUiPanelSendInvitation") + +local XUiGridSendInvitation = require("XUi/XUiActivityBase/XUiGridSendInvitation") + +function XUiPanelSendInvitation:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + + self.GridRewardList = { + XUiGridSendInvitation.New(self.GridReward1, rootUi), + XUiGridSendInvitation.New(self.GridReward2, rootUi), + XUiGridSendInvitation.New(self.GridReward3, rootUi), + } + + self.BtnShareList = { + self.BtnShare1, + self.BtnShare2, + self.BtnShare3, + self.BtnShare4, + self.BtnShare5, + } + + self.BtnHelp.CallBack = function() self:OnBtnHelpClick() end + self.RootUi:BindHelpBtnOnly(self.BtnHelp) + self.BtnCopy.CallBack = function() self:OnBtnCopyClick() end +end + +function XUiPanelSendInvitation:UpdateHeadContent() + if not self.ActivityId or not self.ActivityCfg then return end + + local startTime, endTime = XRegressionConfigs.GetActivityTime(self.ActivityId) + if startTime and endTime then + local formatStr = "yyyy-MM-dd HH:mm" + self.TxtStartTime.text = XTime.TimestampToGameDateTimeString(startTime, formatStr) + self.TxtEndTime.text = XTime.TimestampToGameDateTimeString(endTime, formatStr) + end + + local helpId = self.ActivityCfg.Params[2] + self.BtnHelp.gameObject:SetActiveEx(helpId ~= nil and helpId ~= 0) + + self.TxtActivityTitle.text = self.ActivityCfg.ActivityTitle + local matchedStr = "\\n" + local replacedStr = "\n" + self.TxtActivityDesc.text = string.gsub(self.ActivityCfg.ActivityDes, matchedStr, replacedStr) +end + +function XUiPanelSendInvitation:UpdateInvitationContent() + if not self.InvitationTemplate then return end + local invitationTemplate = self.InvitationTemplate + local maxInvitationCount = XRegressionConfigs.GetInvitationRewardMaxPeople(invitationTemplate.Id) + local curInvitationCount = XDataCenter.RegressionManager.GetAcceptMyInvitationCount() + self.TxtCurInvitationNum.text = math.min(curInvitationCount, maxInvitationCount) + self.TxtMaxInvitationNum.text = maxInvitationCount + self.TxtInvitationCode.text = XDataCenter.RegressionManager.GetInvitationCode() + local invitationRewardIdList = invitationTemplate.InviteRewardId + local rewardCount = #invitationRewardIdList + for i, grid in ipairs(self.GridRewardList) do + if i > rewardCount then + grid.GameObject:SetActiveEx(false) + else + grid.GameObject:SetActiveEx(true) + grid:Refresh(invitationRewardIdList[i]) + end + end +end + +function XUiPanelSendInvitation:UpdateShare() + --当 1.活动配置存在 2.服务端未屏蔽邀请码分享 3.当前玩家所在服务器可以进行分享 4.目前仅限英雄互娱的包 时 可以分享 + if self.ActivityCfg + and not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.InvitationCodeShare) + and XPlatformShareConfigs.IsPlatformShareOpen(XPlayer.ServerId) + and CS.XAppPlatBridge.GetAppPackageName() == XAppConfigs.PackageName.Hero then + self.PanelShareBtn.gameObject:SetActiveEx(true) + local platformShareId = self.ActivityCfg.Params[3] + local platformShareTemplate = XPlatformShareConfigs.GetPlatformShareTemplate(platformShareId) + for i, btn in ipairs(self.BtnShareList) do + if platformShareTemplate.PlatformType[i] then + btn.gameObject:SetActiveEx(true) + btn:SetSprite(platformShareTemplate.PlatformIcon[i]) + btn:SetName(platformShareTemplate.PlatformShowedText[i]) + btn.CallBack = function() self:OnBtnShareClick(platformShareTemplate.PlatformType[i], platformShareTemplate) end + else + btn.gameObject:SetActiveEx(false) + end + end + else + self.PanelShareBtn.gameObject:SetActiveEx(false) + end +end + +function XUiPanelSendInvitation:Refresh(activityCfg) + self.ActivityCfg = activityCfg + XDataCenter.RegressionManager.HandleGetInvitationCodeInfoRequest(true, function() self:OnUpdateInfo() end) + + self:UpdateShare() +end + +function XUiPanelSendInvitation:OnShareCallback(result) + if result == XPlatformShareConfigs.ShareResult.Failed then + XUiManager.TipError(CS.XTextManager.GetText("RegressionSendInvitationShareFailed")) + end +end + +function XUiPanelSendInvitation:OnBtnHelpClick() + if not self.ActivityCfg then return end + local helpId = self.ActivityCfg.Params[2] + local template = XHelpCourseConfig.GetHelpCourseTemplateById(helpId) + XUiManager.ShowHelpTip(template.Function) +end + +function XUiPanelSendInvitation:OnBtnCopyClick() + XUiManager.TipError(CS.XTextManager.GetText("RegressionAcceptInvitationCodeCopy")) + CS.XAppPlatBridge.CopyStringToClipboard(tostring(self.TxtInvitationCode.text)) +end + +function XUiPanelSendInvitation:OnBtnShareClick(targetPlatformType, platformShareTemplate) + local invitationCode = XDataCenter.RegressionManager.GetInvitationCode() + if string.IsNilOrEmpty(invitationCode) then return end + local shareText = string.format(platformShareTemplate.ShareParam[1], invitationCode) + XPlatformShareManager.Share(platformShareTemplate.ShareType, targetPlatformType, function(result) self:OnShareCallback(result) end, shareText) +end + +function XUiPanelSendInvitation:OnUpdateInfo() + if not self.ActivityId or self.InvitationTemplate then + local activityId = XDataCenter.RegressionManager.GetInvitationActivityId() + local invitationTemplateId = XRegressionConfigs.GetInvitationTemplateId(activityId) + local invitationTemplate = XRegressionConfigs.GetInvitationTemplate(invitationTemplateId) + self.ActivityId = activityId + self.InvitationTemplate = invitationTemplate + self:UpdateHeadContent() + self:UpdateInvitationContent() + else + local rewardCount = #self.InvitationTemplate.InviteRewardId + for i, grid in ipairs(self.GridRewardList) do + if i <= rewardCount then + grid:UpdateGetStatus() + end + end + end +end + +return XUiPanelSendInvitation \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiActivityBase/XUiPanelShop.lua b/Resources/Scripts/XUi/XUiActivityBase/XUiPanelShop.lua new file mode 100644 index 00000000..cdd89e0d --- /dev/null +++ b/Resources/Scripts/XUi/XUiActivityBase/XUiPanelShop.lua @@ -0,0 +1,182 @@ +local CSXTextManagerGetText = CS.XTextManager.GetText + +local XUiPanelShop = XClass(nil, "XUiPanelShop") + +function XUiPanelShop:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + + self.AssetActivityPanel = XUiPanelActivityAsset.New(self.PanelActivityAsset) + self.ItemActivity = XUiPanelItemList.New(self.PanelItemActivity, self, self.RootUi) +end + +function XUiPanelShop:OnDestroy() + self:RemoveTimer() +end + +function XUiPanelShop:Refresh(activityCfg) + if not activityCfg then return end + + self.TxtContentTimeShop.text = XActivityConfigs.GetActivityTimeStr(activityCfg.Id) + self.TxtContentTitleShop.text = activityCfg.ActivityTitle + + self.PanelShopInformation.gameObject:SetActive(false) + + self.ShopId = activityCfg.Params[1] + XShopManager.ClearBaseInfoData() + XShopManager.GetBaseInfo(function() + self:UpdateShopInfo() + end) +end + +function XUiPanelShop:UpdateShopInfo() + local shopId = self.ShopId + XShopManager.GetShopInfo(shopId, function() + self:UpdateBuyInfo() + self:UpdateManualRefreshInfo() + self:UpdateTimeInfo() + self.AssetActivityPanel:Refresh(XShopManager.GetShopShowIdList(shopId)) + self.ItemActivity:ShowPanel(shopId) + end) +end + +function XUiPanelShop:UpdateManualRefreshInfo() + local costInfo = XShopManager.GetManualRefreshCost(self.ShopId) + if not costInfo or not costInfo.ManualResetTimesLimit then + self.BtnRefresh.gameObject:SetActive(false) + self.TxtRefreshFrequency.gameObject:SetActive(false) + return + end + + if costInfo.RefreshCostId and costInfo.RefreshCostId > 0 and + costInfo.RefreshCostCount and costInfo.RefreshCostCount > 0 then + self.TxtAmount.text = "X " .. costInfo.RefreshCostCount + self.RImgIconProp:SetRawImage(XDataCenter.ItemManager.GetItemIcon(costInfo.RefreshCostId)) + self.TxtAmount.gameObject:SetActive(true) + self.RImgIconProp.gameObject:SetActive(true) + else + self.TxtAmount.gameObject:SetActive(false) + self.RImgIconProp.gameObject:SetActive(false) + end + + local manualResetTimesLimit = costInfo.ManualResetTimesLimit + if manualResetTimesLimit == -1 then + self.TxtRefreshFrequency.gameObject:SetActive(false) + else + local leftTimes = manualResetTimesLimit - costInfo.ManualRefreshTimes + self.TxtRefreshFrequency.text = leftTimes .. "/" .. manualResetTimesLimit + self.TxtRefreshFrequency.gameObject:SetActive(true) + self.PanelShopInformation.gameObject:SetActive(true) + end + + self.BtnRefresh.gameObject:SetActive(true) +end + +--购买次数信息 +function XUiPanelShop:UpdateBuyInfo() + local buyInfo = XShopManager.GetShopBuyInfo(self.ShopId) + if buyInfo then + local buyTimes = buyInfo.TotalBuyTimes + local limitTimes = buyInfo.BuyTimesLimit + if limitTimes > 0 then + local buyCount = buyTimes and limitTimes - buyTimes or limitTimes + self.TxtAllLeftCout.text = CSXTextManagerGetText("BuyCount", buyCount, limitTimes) + self.TxtBuyFrequency.gameObject:SetActive(true) + self.PanelShopInformation.gameObject:SetActive(true) + else + self.TxtBuyFrequency.gameObject:SetActive(false) + end + else + self.TxtBuyFrequency.gameObject:SetActive(false) + end +end + +function XUiPanelShop:UpdateTimeInfo() + self:RemoveTimer() + self.TxtLeftTime.gameObject:SetActive(false) + self.TxtRefreshTime.gameObject:SetActive(false) + + local timeInfo = XShopManager.GetShopTimeInfo(self.ShopId) + if not timeInfo or not next(timeInfo) then + return + end + + local refreshFunc, closedFunc + + local leftTime = timeInfo.RefreshLeftTime + if leftTime and leftTime > 0 then + refreshFunc = function() + local dataTime = XUiHelper.GetTime(leftTime, XUiHelper.TimeFormatType.SHOP) + self.TxtRefreshTime.text = CSXTextManagerGetText("ShopAutoRefresh") .. dataTime + leftTime = leftTime - 1 + + if leftTime < 0 then + refreshFunc = nil + end + end + end + + local closedLeftTime = timeInfo.ClosedLeftTime + if closedLeftTime and closedLeftTime > 0 then + closedFunc = function() + local dataTime = XUiHelper.GetTime(closedLeftTime, XUiHelper.TimeFormatType.SHOP) + self.TxtLeftTime.text = CSXTextManagerGetText("ActiveTime", dataTime) + closedLeftTime = closedLeftTime - 1 + + if closedLeftTime < 0 then + closedFunc = nil + end + end + end + + if refreshFunc then + refreshFunc() + self.TxtRefreshTime.gameObject:SetActive(true) + self.PanelShopInformation.gameObject:SetActive(true) + end + + if closedFunc then + closedFunc() + self.TxtLeftTime.gameObject:SetActive(true) + self.PanelShopInformation.gameObject:SetActive(true) + end + + self.Timer = XScheduleManager.ScheduleForever(function() + if not refreshFunc and not closedFunc then + self:RemoveTimer() + return + end + + if refreshFunc then + refreshFunc() + end + + if closedFunc then + closedFunc() + end + end, 1000) +end + +function XUiPanelShop:RemoveTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + end +end + +function XUiPanelShop:GetCurShopId() + return self.ShopId +end + +function XUiPanelShop:RefreshBuy() + local shopId = self.ShopId + self.AssetActivityPanel:Refresh(XShopManager.GetShopShowIdList(shopId)) + self:UpdateShopInfo() +end + +function XUiPanelShop:UpdateBuy(data, cb) + XLuaUiManager.Open("UiShopItem", self, data, cb) +end + +return XUiPanelShop \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiActivityBase/XUiPanelSkip.lua b/Resources/Scripts/XUi/XUiActivityBase/XUiPanelSkip.lua new file mode 100644 index 00000000..5acf2145 --- /dev/null +++ b/Resources/Scripts/XUi/XUiActivityBase/XUiPanelSkip.lua @@ -0,0 +1,23 @@ + +local XUiPanelSkip = XClass(nil, "XUiPanelSkip") + +function XUiPanelSkip:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiPanelSkip:Refresh(activityCfg) + if not activityCfg then return end + + self.TxtContentTimeNotice.text = XActivityConfigs.GetActivityTimeStr(activityCfg.Id) + self.TxtContentTitleNotice.text = string.gsub(activityCfg.ActivityTitle, "\\n", "\n") + self.TxtContentNotice.text = string.gsub(activityCfg.ActivityDes, "\\n", "\n") + + local skipId = activityCfg.Params[1] + CsXUiHelper.RegisterClickEvent(self.BtnGo, function() + XFunctionManager.SkipInterface(skipId) + end) +end + +return XUiPanelSkip \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiActivityBase/XUiPanelTask.lua b/Resources/Scripts/XUi/XUiActivityBase/XUiPanelTask.lua new file mode 100644 index 00000000..141e9203 --- /dev/null +++ b/Resources/Scripts/XUi/XUiActivityBase/XUiPanelTask.lua @@ -0,0 +1,87 @@ +local BtnGoRedPointConditions = { + [XActivityConfigs.TaskPanelSkipType.CanZhangHeMing_Qu] = { XRedPointConditions.Types.CONDITION_FUBEN_DRAGPUZZLEGAME_RED }, + [XActivityConfigs.TaskPanelSkipType.CanZhangHeMing_LuNa] = { XRedPointConditions.Types.CONDITION_FUBEN_DRAGPUZZLEGAME_RED }, + [XActivityConfigs.TaskPanelSkipType.ChrismasTree_Dress] = { XRedPointConditions.Types.CONDITION_CHRISTMAS_TREE }, + [XActivityConfigs.TaskPanelSkipType.Couplet_Game] = { XRedPointConditions.Types.CONDITION_COUPLET_GAME }, + [XActivityConfigs.TaskPanelSkipType.CanZhangHeMing_SP] = { XRedPointConditions.Types.CONDITION_FUBEN_DRAGPUZZLEGAME_RED }, + [XActivityConfigs.TaskPanelSkipType.InvertCard_Game] = { XRedPointConditions.Types.CONDITION_INVERTCARDGAME_RED }, +} + +local XUiPanelTask = XClass(nil, "XUiPanelTask") + +function XUiPanelTask:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + + self.DynamicTable = XDynamicTableNormal.New(self.PanelTaskActivityList) + self.DynamicTable:SetProxy(XDynamicDailyTask) + self.DynamicTable:SetDelegate(self) +end + +function XUiPanelTask:Refresh(activityCfg) + if not activityCfg then return end + self.ActivityCfg = activityCfg + self.TxtContentTimeTask.text = self:GetTxtContentTimeTask(activityCfg) + self.TxtContentTitleTask.text = activityCfg.ActivityTitle + self.TxtContentTask.text = activityCfg.ActivityDes + + local skipId = activityCfg.Params[2] + if skipId and skipId ~= 0 then + self.BtnGo.gameObject:SetActiveEx(true) + CsXUiHelper.RegisterClickEvent(self.BtnGo, function() + if XFunctionManager.CheckSkipInDuration(skipId) then + XFunctionManager.SkipInterface(skipId) + else + XUiManager.TipText("ActivityBaseTaskSkipNotInDuring") + end + end) + if not self.BtnGoRedPointIdDic then self.BtnGoRedPointIdDic = {} end + if self.BtnGoRedPointIdDic[skipId] then + XRedPointManager.Check(self.BtnGoRedPointIdDic[skipId]) + else + if BtnGoRedPointConditions[skipId] and XFunctionManager.IsCanSkip(skipId) then + self.BtnGoRedPointIdDic[skipId] = XRedPointManager.AddRedPointEvent(self.BtnGo, self.OnRedPointEvent, self, BtnGoRedPointConditions[skipId], nil, true) + else + self.BtnGo:ShowReddot(false) + end + end + else + self.BtnGo.gameObject:SetActiveEx(false) + end + + self:UpdateDynamicTable() +end + +function XUiPanelTask:GetTxtContentTimeTask(activityCfg) + local taskGroupId = activityCfg.Params[1] + local beginTime, endTime = XTaskConfig.GetTimeLimitTaskTime(taskGroupId) + + return XActivityConfigs.GetActivityTimeStr(activityCfg.Id, beginTime, endTime) +end + +function XUiPanelTask:UpdateDynamicTable() + self.TaskDatas = XDataCenter.ActivityManager.GetActivityTaskData(self.ActivityCfg.Id) + self.ImgEmpty.gameObject:SetActive(#self.TaskDatas <= 0) + self.DynamicTable:SetDataSource(self.TaskDatas) + self.DynamicTable:ReloadDataSync(1) +end + +function XUiPanelTask:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid.RootUi = self.RootUi + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.TaskDatas[index] + + grid:ResetData(data) + + + end +end + +function XUiPanelTask:OnRedPointEvent(count) + self.BtnGo:ShowReddot(count >= 0) +end + +return XUiPanelTask \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiActivityBase/XUiScratchTicket.lua b/Resources/Scripts/XUi/XUiActivityBase/XUiScratchTicket.lua new file mode 100644 index 00000000..a533cc1a --- /dev/null +++ b/Resources/Scripts/XUi/XUiActivityBase/XUiScratchTicket.lua @@ -0,0 +1,164 @@ +-- 刮刮乐界面控件 +local XUiScratchTicket = XClass(nil, "XUiScratchTicket") + +function XUiScratchTicket:Ctor(uiGameObject, rootUi) + XTool.InitUiObjectByUi(self, uiGameObject) + self.RootUi = rootUi + self:RegisterEventListeners() +end + +function XUiScratchTicket:Refresh(activityCfg) + local activityId = activityCfg.Params[1] + self.Controller = XDataCenter.ScratchTicketManager.GetActivityController(activityId) + if not self.Controller then + XLog.Error("没有找到刮刮乐控制器! activityId:" .. activityId) + return + end + self:InitPanels() +end + +function XUiScratchTicket:InitPanels() + self:InitTicketPanel() + self:InitTopPanel() + self:InitLeftPanel() + self:InitPlayPanel() + self:ShowPanels() +end + +function XUiScratchTicket:InitTicketPanel() + local isOrdinaryTicket = not self.Controller:GetIsCanReset() + self.OrdinaryTicket.gameObject:SetActiveEx(isOrdinaryTicket) + self.GoldenTicket.gameObject:SetActiveEx(not isOrdinaryTicket) + self.TicketPanel = {} + XTool.InitUiObjectByUi(self.TicketPanel, isOrdinaryTicket and self.OrdinaryTicket or self.GoldenTicket) +end + +function XUiScratchTicket:InitTopPanel() + local panelScript = require("XUi/XUiActivityBase/ScratchTicket/XUiScratchTicketPanelTop") + self.TopPanel = panelScript.New(self.TicketPanel.PanelTop, self.Controller, self) +end + +function XUiScratchTicket:InitLeftPanel() + local panelScript = require("XUi/XUiActivityBase/ScratchTicket/XUiScratchTicketPanelLeft") + self.LeftPanel = panelScript.New(self.TicketPanel.PanelLeft, self.Controller, self) +end + +function XUiScratchTicket:InitPlayPanel() + local panelScript = require("XUi/XUiActivityBase/ScratchTicket/XUiScratchTicketPanelPlay") + self.PlayPanel = panelScript.New(self.TicketPanel.PanelPlay, self.Controller, self) +end + +function XUiScratchTicket:ShowPanels() + local ticket = self.Controller:GetTicket() + local playStatus = ticket and ticket:GetPlayStatus() or XDataCenter.ScratchTicketManager.PlayStatus.NotStart + if playStatus == XDataCenter.ScratchTicketManager.PlayStatus.NotStart then + self:OnReady() + elseif playStatus == XDataCenter.ScratchTicketManager.PlayStatus.Playing then + if self.Controller:CheckPreviewFinish() then + self.PlayPanel:ShowChooseChose() + else + self:OnGameStart() + end + end +end + +function XUiScratchTicket:OnGameEnd() + if not self:Exist() then return end + XLuaUiManager.RunMain() + XUiManager.TipMsg(CS.XTextManager.GetText("CommonActivityEnd")) +end + +function XUiScratchTicket:OnOpenGrid(activityId) + if not self:Exist() then return end + if activityId and self.Controller:GetId() ~= activityId then return end + self.PlayPanel:OnOpenGrid() +end + +function XUiScratchTicket:OnShowResult(activityId, rewardList) + if not self:Exist() then return end + if activityId and self.Controller:GetId() ~= activityId then return end + if rewardList and not self.Mask then + self.Mask = true + XLuaUiManager.SetMask(true) + end + self.LeftPanel:RefreshSelect() + self.PlayPanel:ShowResult() + self.ResultTimer = XScheduleManager.ScheduleOnce(function() + if self.Mask then + self.Mask = false + XLuaUiManager.SetMask(false) + end + if rewardList then + XUiManager.OpenUiObtain(rewardList, nil, function() + self.ResultTimer = nil + end) + end + end, 1000) +end + +function XUiScratchTicket:Exist() + if XTool.UObjIsNil(self.Transform) then + self:OnDestroy() + return false + end + return true +end + +function XUiScratchTicket:OnGameStart(activityId) + if not self:Exist() then return end + if activityId and self.Controller:GetId() ~= activityId then return end + self.LeftPanel:RefreshPanel() + self.PlayPanel:ShowGaming() +end + +function XUiScratchTicket:OnReady(activityId) + if not self:Exist() then return end + if activityId and self.Controller:GetId() ~= activityId then return end + self.LeftPanel:OnReset() + self.PlayPanel:ShowReady() +end + +function XUiScratchTicket:PlayAnimation(animName) + if self.TicketPanel[animName] then + self.TicketPanel[animName]:Stop() + self.TicketPanel[animName]:Play() + end +end + +function XUiScratchTicket:RegisterEventListeners() + if self.ListenersAdded then return end + self.ListenersAdded = true + XEventManager.AddEventListener(XEventId.EVENT_SCRATCH_TICKET_ACTIVITY_START, self.OnGameStart, self) + XEventManager.AddEventListener(XEventId.EVENT_SCRATCH_TICKET_OPEN_GRID, self.OnOpenGrid, self) + XEventManager.AddEventListener(XEventId.EVENT_SCRATCH_TICKET_SHOW_RESULT, self.OnShowResult, self) + XEventManager.AddEventListener(XEventId.EVENT_SCRATCH_TICKET_RESET, self.OnGameStart, self) +end + +function XUiScratchTicket:RemoveEventListeners() + if not self.ListenersAdded then return end + XEventManager.RemoveEventListener(XEventId.EVENT_SCRATCH_TICKET_ACTIVITY_START, self.OnGameStart, self) + XEventManager.RemoveEventListener(XEventId.EVENT_SCRATCH_TICKET_OPEN_GRID, self.OnOpenGrid, self) + XEventManager.RemoveEventListener(XEventId.EVENT_SCRATCH_TICKET_SHOW_RESULT, self.OnShowResult, self) + XEventManager.RemoveEventListener(XEventId.EVENT_SCRATCH_TICKET_RESET, self.OnReset, self) + self.ListenersAdded = false +end + +function XUiScratchTicket:OnDisable() + self.PlayPanel:OnDisable() +end + +function XUiScratchTicket:OnDestroy() + self.TopPanel:OnDestroy() + self.LeftPanel:OnDestroy() + self.PlayPanel:OnDestroy() + if self.Mask then + XLuaUiManager.SetMask(false) + end + if self.ResultTimer then + XScheduleManager.UnSchedule(self.ResultTimer) + self.ResultTimer = nil + end + self:RemoveEventListeners() +end + +return XUiScratchTicket \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiActivityBossSingle/XUiActivityBossSingle.lua b/Resources/Scripts/XUi/XUiActivityBossSingle/XUiActivityBossSingle.lua new file mode 100644 index 00000000..067a842e --- /dev/null +++ b/Resources/Scripts/XUi/XUiActivityBossSingle/XUiActivityBossSingle.lua @@ -0,0 +1,304 @@ +local tableInsert = table.insert +local CsXTextManager = CS.XTextManager +local CsXScheduleManager = XScheduleManager + +local XUiGridActivityBossSingle = require("XUi/XUiActivityBossSingle/XUiGridActivityBossSingle") + +local XUiActivityBossSingle = XLuaUiManager.Register(XLuaUi, "UiActivityBossSingle") + +local StageCount = 5 +local StarDescCount = 3 + +function XUiActivityBossSingle:OnStart(sectionId) + self.SectionId = sectionId + self:AutoAddListener() + self.StageIds = XDataCenter.FubenActivityBossSingleManager.GetSectionStageIdList(self.SectionId) + self.GridList = {} + self:InitPanel() +end + +function XUiActivityBossSingle:OnEnable() + self.PanelDetail.gameObject:SetActiveEx(false) + self.AnimBgLoop.gameObject:SetActiveEx(true) + self:RefreshPanel() +end + +function XUiActivityBossSingle:OnDisable() + self:DestroyActivityTimer() +end + +--初始化面板 +function XUiActivityBossSingle:InitPanel() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + --不显示描述按钮 + self.BtnActDesc.gameObject:SetActiveEx(false) + --初始化选项卡 + self:InitStageCapter() + self:InitStarDesc() + self:CreateActivityTimer() +end + +function XUiActivityBossSingle:CreateActivityTimer() + self:DestroyActivityTimer() + + local time = XTime.GetServerNowTimestamp() + local fightEndTime = XDataCenter.FubenActivityBossSingleManager.GetFightEndTime() + local activityEndTime = XDataCenter.FubenActivityBossSingleManager.GetActivityEndTime() + local shopStr = CsXTextManager.GetText("ActivityBranchShopLeftTime") + local fightStr = CsXTextManager.GetText("ActivityBranchFightLeftTime") + + if XDataCenter.FubenActivityBossSingleManager.IsStatusEqualFightEnd() then + self.TxtResetDesc.text = shopStr + self.TxtLeftTime.text = XUiHelper.GetTime(activityEndTime - time, XUiHelper.TimeFormatType.ACTIVITY) + else + self.TxtResetDesc.text = fightStr + self.TxtLeftTime.text = XUiHelper.GetTime(fightEndTime - time, XUiHelper.TimeFormatType.ACTIVITY) + end + + self.ActivityTimer = CsXScheduleManager.ScheduleForever(function() + if XTool.UObjIsNil(self.TxtLeftTime) then + self:DestroyActivityTimer() + return + end + + time = time + 1 + + if time >= activityEndTime then + self:DestroyActivityTimer() + XDataCenter.FubenActivityBossSingleManager.OnActivityEnd() + elseif fightEndTime <= time then + local leftTime = activityEndTime - time + if leftTime > 0 then + self.TxtResetDesc.text = shopStr + self.TxtLeftTime.text = XUiHelper.GetTime(leftTime, XUiHelper.TimeFormatType.ACTIVITY) + end + else + local leftTime = fightEndTime - time + if leftTime > 0 then + self.TxtResetDesc.text = fightStr + self.TxtLeftTime.text = XUiHelper.GetTime(leftTime, XUiHelper.TimeFormatType.ACTIVITY) + else + self:DestroyActivityTimer() + self:CreateActivityTimer() + end + end + end, CsXScheduleManager.SECOND, 0) +end + +function XUiActivityBossSingle:DestroyActivityTimer() + if self.ActivityTimer then + CsXScheduleManager.UnSchedule(self.ActivityTimer) + self.ActivityTimer = nil + end +end + +--初始化副本选择卡,选择卡是定死的,不使用滑动条 +function XUiActivityBossSingle:InitStageCapter() + self.ChapterGrids = {} + + for i = 1, StageCount do + local chapterGrid = XUiGridActivityBossSingle.New(self, self["PanelImg" .. i]) + tableInsert(self.ChapterGrids, chapterGrid) + end +end + +function XUiActivityBossSingle:RefreshPanel() + self:RefreshSchedule() + self:RefreshTreasureInfo() + --统一进行刷新,根据stageId + for gridIndex = 1, #self.ChapterGrids do + self.ChapterGrids[gridIndex]:Refresh(self.StageIds[gridIndex], gridIndex) + end +end + +--初始化详细信息面板的挑战目标 +function XUiActivityBossSingle:InitStarDesc() + self.GridStarList = {} + for i = 1, StarDescCount do + local ui = self["GridStageStar" .. i] + ui.gameObject:SetActiveEx(true) + local grid = XUiGridStageStar.New(ui) + self.GridStarList[i] = grid + end +end + +--刷新收集进度条显示 +function XUiActivityBossSingle:RefreshSchedule() + local curStarsCount = XDataCenter.FubenActivityBossSingleManager.GetCurStarsCount() + local totalStarsCount = XDataCenter.FubenActivityBossSingleManager.GetAllStarsCount() + if totalStarsCount ~= 0 then + self.ImgSchedule.fillAmount = curStarsCount / totalStarsCount + end + + self.TxtSchedule.text = CsXTextManager.GetText("ActivityBossSingleSchedule", curStarsCount, totalStarsCount) +end + +--刷新左下角奖励信息 +function XUiActivityBossSingle:RefreshTreasureInfo() + local starsTotalCount = XDataCenter.FubenActivityBossSingleManager.GetAllStarsCount() + local starsCurCount = XDataCenter.FubenActivityBossSingleManager.GetCurStarsCount() + + self.ImgJindu.fillAmount = starsTotalCount > 0 and starsCurCount / starsTotalCount or 0 + self.ImgJindu.gameObject:SetActiveEx(true) + + --设置是否全部领取完成 + local isAllFinish = XDataCenter.FubenActivityBossSingleManager.CheckIsAllFinish() + self.BtnTreasure.gameObject:SetActiveEx(true) + self.ImgLingqu.gameObject:SetActiveEx(isAllFinish) + + --红点 + local isShowRedPoint = XDataCenter.FubenActivityBossSingleManager.CheckRedPoint() + self.ImgRedProgress.gameObject:SetActiveEx(isShowRedPoint) +end + +--点击副本卡的时候回调 +function XUiActivityBossSingle:SelectStageCallBack(index) + XLuaUiManager.SetMask(true) + self:PlayAnimation("FuBenImg" .. index .. "Up", function() + XLuaUiManager.SetMask(false) + + for i = 1, StageCount do + local animStr = string.format("%s%d%s", "AnimFuBenImg", i, "Loop") + self[animStr].gameObject:SetActiveEx(false) + if i == self.CurrentSelectIndex then + self[animStr].gameObject:SetActiveEx(true) + end + end + end) + --标记正在显示详细信息 + self.IsInDetail = true + self.CurrentSelectIndex = index + self.CurrentSelectStageId = self.StageIds[index] + + self:InitStageDetailInfo(self.CurrentSelectStageId) + self:PlayAnimation("DetailEnable") + self.PanelDetail.gameObject:SetActiveEx(true) + self.PanelLeftTreasure.gameObject:SetActiveEx(false) +end + +--初始化副本的详细信息 +function XUiActivityBossSingle:InitStageDetailInfo(stageId) + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + local starsMap = XDataCenter.FubenActivityBossSingleManager.GetStageStarMap(stageId) + + --加载特效 + local effectPath = XFubenActivityBossSingleConfigs.GetBossChallengeEffectPath(stageId) + self.PanelEffectDetail.gameObject:LoadUiEffect(effectPath) + + --刷新消耗数量 + self.TxtATNums.text = stageCfg.RequireActionPoint + + --TODO 显示挑战目标 + for i = 1, StarDescCount do + self.GridStarList[i]:Refresh(stageCfg.StarDesc[i], starsMap[i]) + end + + --标题 + self.ImgBt:SetRawImage(stageCfg.Icon) + + --显示奖励,根据stageCfg + local rewardId = 0 + local isFirst = false + local cfg = XDataCenter.FubenManager.GetStageLevelControl(stageCfg.StageId) + if not XDataCenter.FubenActivityBossSingleManager.IsChallengePassedByStageId(stageCfg.StageId) then + rewardId = cfg and cfg.FirstRewardShow or stageCfg.FirstRewardShow + if cfg and cfg.FirstRewardShow > 0 or stageCfg.FirstRewardShow > 0 then + isFirst = true + end + end + self.TxtFirstDrop.gameObject:SetActiveEx(isFirst) + self.TxtDrop.gameObject:SetActiveEx(not isFirst) + if rewardId == 0 then + rewardId = cfg and cfg.FinishRewardShow or stageCfg.FinishRewardShow + end + if rewardId == 0 then + for j = 1, #self.GridList do + self.GridList[j].GameObject:SetActive(false) + end + return + end + + local rewards = isFirst and XRewardManager.GetRewardList(rewardId) or XRewardManager.GetRewardListNotCount(rewardId) + if rewards then + for i, item in ipairs(rewards) do + local grid + if self.GridList[i] then + grid = self.GridList[i] + else + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommon) + grid = XUiGridCommon.New(self, ui) + grid.Transform:SetParent(self.PanelDropContent, false) + self.GridList[i] = grid + end + grid:Refresh(item) + grid.GameObject:SetActive(true) + end + end + + local rewardsCount = 0 + if rewards then + rewardsCount = #rewards + end + + for j = 1, #self.GridList do + if j > rewardsCount then + self.GridList[j].GameObject:SetActive(false) + end + end +end + +--打开详细信息的时候先退回副本选择卡界面,并刷新一次界面 +function XUiActivityBossSingle:OnBtnBackClick() + if self.IsInDetail == true then + self.IsInDetail = false + self:PlayAnimation("AnimEnable") + self.PanelDetail.gameObject:SetActiveEx(false) + self:RefreshPanel() + return + end + + self:Close() +end + +function XUiActivityBossSingle:AutoAddListener() + self.BtnBack.CallBack = function() + self:OnBtnBackClick() + end + self.BtnMainUi.CallBack = function() + self:OnBtnMainUiClick() + end + self.BtnEnter.CallBack = function() + self:OnBtnEnterClick() + end + self.BtnTreasure.CallBack = function() + self:OnBtnTreasureClick() + end + self.BtnNote.CallBack = function() + self:OnBtnNoteClick() + end +end + +--作战准备按钮点击 +function XUiActivityBossSingle:OnBtnEnterClick() + self.IsInDetail = false + self.PanelDetail.gameObject:SetActiveEx(false) + XLuaUiManager.Open("UiNewRoomSingle", self.CurrentSelectStageId) +end + +function XUiActivityBossSingle:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiActivityBossSingle:OnBtnTreasureClick() + XLuaUiManager.Open("UiActivityBossSingleReward", self.SectionId, function() + self:RefreshTreasureInfo() + end) +end + +--点击描述按钮显示的注意事项 +function XUiActivityBossSingle:OnBtnNoteClick() + local attentionDesc = XFubenActivityBossSingleConfigs.GetStageAttention(self.StageIds[self.CurrentSelectIndex]) + local attentionDescTitle = XFubenActivityBossSingleConfigs.GetStageAttentionTitle(self.StageIds[self.CurrentSelectIndex]) + local title = CsXTextManager.GetText("ActivityBossSingleAttention") + XLuaUiManager.Open("UiAttentionDesc", title, attentionDesc, attentionDescTitle) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiActivityBossSingle/XUiActivityBossSingleReward.lua b/Resources/Scripts/XUi/XUiActivityBossSingle/XUiActivityBossSingleReward.lua new file mode 100644 index 00000000..3de1e85a --- /dev/null +++ b/Resources/Scripts/XUi/XUiActivityBossSingle/XUiActivityBossSingleReward.lua @@ -0,0 +1,44 @@ +local XUiBossSingleTreasureGrid = require("XUi/XUiActivityBossSingle/XUiBossSingleTreasureGrid") +local XUiActivityBossSingleReward = XLuaUiManager.Register(XLuaUi, "UiActivityBossSingleReward") + +function XUiActivityBossSingleReward:OnStart(sectionId, cb) + self.CallBack = cb + self.SectionId = sectionId + self.StarRewardIds = XFubenActivityBossSingleConfigs.GetBossSectionRewardIds(sectionId) + self:InitDynamicList() + self:AutoAddListener() + self:Refresh() + self:PlayAnimation("AnimEnable") +end + +function XUiActivityBossSingleReward:InitDynamicList() + self.DynamicTable = XDynamicTableNormal.New(self.SViewRewardList) + self.DynamicTable:SetProxy(XUiBossSingleTreasureGrid) + self.DynamicTable:SetDelegate(self) +end + +function XUiActivityBossSingleReward:AutoAddListener() + self.BtnClose.CallBack = function() + self:OnBtnCloseClick() + end +end + +function XUiActivityBossSingleReward:Refresh() + self.DynamicTable:SetDataSource(self.StarRewardIds) + self.DynamicTable:ReloadDataASync() +end + +function XUiActivityBossSingleReward:OnBtnCloseClick() + self:Close() + if self.CallBack ~= nil then + self.CallBack() + end +end + +function XUiActivityBossSingleReward:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Refresh(self, self.StarRewardIds[index]) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:Refresh(self, self.StarRewardIds[index]) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiActivityBossSingle/XUiAttentionDesc.lua b/Resources/Scripts/XUi/XUiActivityBossSingle/XUiAttentionDesc.lua new file mode 100644 index 00000000..bc5b51d0 --- /dev/null +++ b/Resources/Scripts/XUi/XUiActivityBossSingle/XUiAttentionDesc.lua @@ -0,0 +1,37 @@ +XUiAttentionDesc = XLuaUiManager.Register(XLuaUi, "UiAttentionDesc") + +function XUiAttentionDesc:OnStart(panelTitle, contextList, contextTitleList) + self.PanelTitle = panelTitle + self.ContextList = contextList + self.ContextTitleList = contextTitleList + self:AutoAddListener() + self.PanelTxt.gameObject:SetActiveEx(false) + self:Refresh() +end + +function XUiAttentionDesc:Refresh() + self.TxtlTitle.text = self.PanelTitle + for k, _ in pairs(self.ContextTitleList) do + local go = CS.UnityEngine.Object.Instantiate(self.PanelTxt, self.PanelContent) + local tmpObj = {} + tmpObj.Transform = go.transform + tmpObj.GameObject = go.gameObject + XTool.InitUiObject(tmpObj) + tmpObj.TxtRuleTittle.text = self.ContextTitleList[k] + tmpObj.TxtRule.text = self.ContextList[k] + tmpObj.GameObject:SetActiveEx(true) + end +end + +function XUiAttentionDesc:AutoAddListener() + self.BtnTanchuangClose.CallBack = function() + self:OnBtnCloseClick() + end + self.BtnClose.CallBack = function() + self:OnBtnCloseClick() + end +end + +function XUiAttentionDesc:OnBtnCloseClick() + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiActivityBossSingle/XUiBossSingleTreasureGrid.lua b/Resources/Scripts/XUi/XUiActivityBossSingle/XUiBossSingleTreasureGrid.lua new file mode 100644 index 00000000..bade3c5e --- /dev/null +++ b/Resources/Scripts/XUi/XUiActivityBossSingle/XUiBossSingleTreasureGrid.lua @@ -0,0 +1,99 @@ +local XUiBossSingleTreasureGrid = XClass(nil, "XUiBossSingleTreasureGrid") + +function XUiBossSingleTreasureGrid:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:AutoAddListener() + self.RewardPanelList = {} +end + +function XUiBossSingleTreasureGrid:AutoAddListener() + self.BtnReceive.CallBack = function() + self:OnBtnReceiveClick() + end +end + +function XUiBossSingleTreasureGrid:OnBtnReceiveClick() + XDataCenter.FubenActivityBossSingleManager.ReceiveTreasureReward(self.BossStarRewardTemplate.Id, function(reward) + XUiManager.OpenUiObtain(reward, CS.XTextManager.GetText("Award")) + self:UpdatePanel() + end) +end + +function XUiBossSingleTreasureGrid:Refresh(rootUi, Id) + self.RootUi = rootUi + self.BossStarRewardTemplate = XFubenActivityBossSingleConfigs.GetStarRewardCfg(Id) + self:UpdatePanel() +end + +function XUiBossSingleTreasureGrid:UpdatePanel() + if self.BossStarRewardTemplate == nil then + return + end + --获取当前的总星数 + local curStarsCount = XDataCenter.FubenActivityBossSingleManager.GetCurStarsCount() + --获取当前的need星数 + local curNeedCount = self.BossStarRewardTemplate.RequireStar + if curStarsCount >= curNeedCount then + self:SetStarsActive(true) + if XDataCenter.FubenActivityBossSingleManager.CheckRewardIsFinish(self.BossStarRewardTemplate.Id) then + --已经领取 + self:SetBtnAlreadyReceive() + else + self:SetBtnActive() + end + else + self:SetStarsActive(false) + self:SetBtnCannotReceive() + end + + --显示星数文本 + self.TxtGradeStarNums.text = CS.XTextManager.GetText("GradeStarNum", curStarsCount, curNeedCount) + + --显示奖励 + local rewards = XRewardManager.GetRewardList(self.BossStarRewardTemplate.RewardId) + if not rewards then + return + end + + for i = 1, #rewards do + local panel = self.RewardPanelList[i] + if not panel then + if #self.RewardPanelList == 0 then + panel = XUiGridCommon.New(self.RootUi, self.GridCommon) + else + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommon) + ui.transform:SetParent(self.GridCommon.parent, false) + panel = XUiGridCommon.New(self.RootUi, ui) + end + table.insert(self.RewardPanelList, panel) + end + panel:Refresh(rewards[i]) + end +end + +function XUiBossSingleTreasureGrid:SetBtnActive() + self.BtnReceive.gameObject:SetActive(true) + self.ImgAlreadyReceived.gameObject:SetActive(false) + self.ImgCannotReceive.gameObject:SetActive(false) +end + +function XUiBossSingleTreasureGrid:SetBtnCannotReceive() + self.BtnReceive.gameObject:SetActive(false) + self.ImgAlreadyReceived.gameObject:SetActive(false) + self.ImgCannotReceive.gameObject:SetActive(true) +end + +function XUiBossSingleTreasureGrid:SetBtnAlreadyReceive() + self.BtnReceive.gameObject:SetActive(false) + self.ImgAlreadyReceived.gameObject:SetActive(true) + self.ImgCannotReceive.gameObject:SetActive(false) +end + +function XUiBossSingleTreasureGrid:SetStarsActive(flag) + self.ImgGradeStarActive.gameObject:SetActive(flag) + self.ImgGradeStarUnactive.gameObject:SetActive(not flag) +end + +return XUiBossSingleTreasureGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiActivityBossSingle/XUiGridActivityBossSingle.lua b/Resources/Scripts/XUi/XUiActivityBossSingle/XUiGridActivityBossSingle.lua new file mode 100644 index 00000000..0bb5965b --- /dev/null +++ b/Resources/Scripts/XUi/XUiActivityBossSingle/XUiGridActivityBossSingle.lua @@ -0,0 +1,48 @@ +local CsXTextManager = CS.XTextManager +local tableInsert = table.insert +local XUiGridActivityBossSingle = XClass(nil, "XUiGridActivityBossSingle") + +function XUiGridActivityBossSingle:Ctor(parent, ui) + self.Parent = parent + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:AutoAddListener() +end + +function XUiGridActivityBossSingle:AutoAddListener() + self.BtnStage.CallBack = function() + self:OnBtnStageClick() + end +end + +function XUiGridActivityBossSingle:Refresh(stageId, index) + self.Index = index + --刷新是否解锁 + local isUnLock = XDataCenter.FubenActivityBossSingleManager.IsChallengeUnlockByStageId(stageId) + self.PanelStageLockParent.gameObject:SetActiveEx(not isUnLock) + self.PanelNor.gameObject:SetActiveEx(isUnLock) + --self.BtnStage.gameObject:SetActiveEx(isUnLock) + self.IsUnLock = isUnLock + --刷新红点显示 + local starMap = XDataCenter.FubenActivityBossSingleManager.GetStageStarMap(stageId) + for i = 1, #starMap do + self["ImgOn" .. i].gameObject:SetActiveEx(starMap[i]) + self["ImgOff" .. i].gameObject:SetActiveEx(not starMap[i]) + end + --刷新是否通关显示 + local isPassed = XDataCenter.FubenActivityBossSingleManager.IsChallengePassedByStageId(stageId) + self.PanelKillParent.gameObject:SetActiveEx(isPassed) +end + +function XUiGridActivityBossSingle:OnBtnStageClick() + if self.IsUnLock == false then + XUiManager.TipText("ActivityBossOpenTip") + return + end + self.BtnStage.gameObject:SetActiveEx(false) + self.PanelKillParent.gameObject:SetActiveEx(false) + self.Parent:SelectStageCallBack(self.Index) +end + +return XUiGridActivityBossSingle \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiActivityBossSingleDetail/XUiActivityBossSingleDetail.lua b/Resources/Scripts/XUi/XUiActivityBossSingleDetail/XUiActivityBossSingleDetail.lua new file mode 100644 index 00000000..3df0b3b5 --- /dev/null +++ b/Resources/Scripts/XUi/XUiActivityBossSingleDetail/XUiActivityBossSingleDetail.lua @@ -0,0 +1,173 @@ +local XUiActivityBossSingleDetail = XLuaUiManager.Register(XLuaUi, "UiActivityBossSingleDetail") + +function XUiActivityBossSingleDetail:OnAwake() + self:InitAutoScript() + self.GridCommon.gameObject:SetActive(false) + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) +end + +function XUiActivityBossSingleDetail:OnStart(challengeId) + self.ChallengeId = challengeId + self.GridList = {} + XEventManager.AddEventListener(XEventId.EVENT_ENTER_FIGHT, self.OnBtnBackClick, self) + self:Refresh(self.ChallengeId) +end + +function XUiActivityBossSingleDetail:OnDestroy() + XEventManager.RemoveEventListener(XEventId.EVENT_ENTER_FIGHT, self.OnBtnBackClick, self) +end + +function XUiActivityBossSingleDetail:Refresh(challengeId) + self.ChallengeId = challengeId + self:InitCommon() + self:InitRewards() +end + +function XUiActivityBossSingleDetail:InitCommon() + local challengeId = self.ChallengeId + local stageId = XFubenActivityBossSingleConfigs.GetStageId(challengeId) + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + local nanDuIcon = XDataCenter.FubenManager.GetDifficultIcon(stageId) + local maxChallengeNum = XDataCenter.FubenManager.GetStageMaxChallengeNums(stageId) + local buyChallengeCount = XDataCenter.FubenManager.GetStageBuyChallengeCount(stageId) + local challengeResCfg = XFubenActivityBossSingleConfigs.GetChallengeResCfg(challengeId) + + self.RImgNandu:SetRawImage(nanDuIcon) + self.TxtTitle.text = stageCfg.Name + self.TxtLevelVal.text = stageCfg.RecommandLevel + self.TxtATNums.text = stageCfg.RequireActionPoint + self.PanelNums.gameObject:SetActive(maxChallengeNum > 0) + self.PanelNoLimitCount.gameObject:SetActive(maxChallengeNum <= 0) + self.BtnAddNum.gameObject:SetActive(buyChallengeCount > 0) + for i = 1, 3 do + self["TxtActive" .. i].text = stageCfg.StarDesc[i] + end + + if maxChallengeNum > 0 then + local stageData = XDataCenter.FubenManager.GetStageData(stageId) + local chanllengeNum = stageData and stageData.PassTimesToday or 0 + self.TxtAllNums.text = "/" .. maxChallengeNum + self.TxtLeftNums.text = maxChallengeNum - chanllengeNum + end + + local firstDrop = false + if not XDataCenter.FubenActivityBossSingleManager.IsChallengePassed(self.ChallengeId) then + local cfg = XDataCenter.FubenManager.GetStageLevelControl(stageId) + if cfg and cfg.FirstRewardShow > 0 or stageCfg.FirstRewardShow > 0 then + firstDrop = true + end + end + self.TxtFirstDrop.gameObject:SetActive(firstDrop) + self.TxtDrop.gameObject:SetActive(not firstDrop) + + self.RImgBg:SetRawImage(challengeResCfg.BgPath) + + if challengeResCfg.EffectPath then + self.Effect.gameObject:LoadPrefab(challengeResCfg.EffectPath) + self.Effect.gameObject:SetActiveEx(true) + self.Effect:Init() + else + self.Effect.gameObject:SetActiveEx(false) + end +end + +function XUiActivityBossSingleDetail:InitRewards() + local stageId = XFubenActivityBossSingleConfigs.GetStageId(self.ChallengeId) + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + + -- 获取显示奖励Id + local rewardId = 0 + local IsFirst = false + local cfg = XDataCenter.FubenManager.GetStageLevelControl(stageCfg.StageId) + if not XDataCenter.FubenActivityBossSingleManager.IsChallengePassed(self.ChallengeId) then + rewardId = cfg and cfg.FirstRewardShow or stageCfg.FirstRewardShow + if cfg and cfg.FirstRewardShow > 0 or stageCfg.FirstRewardShow > 0 then + IsFirst = true + end + end + if rewardId == 0 then + rewardId = cfg and cfg.FinishRewardShow or stageCfg.FinishRewardShow + end + if rewardId == 0 then + for j = 1, #self.GridList do + self.GridList[j].GameObject:SetActive(false) + end + return + end + + local rewards = IsFirst and XRewardManager.GetRewardList(rewardId) or XRewardManager.GetRewardListNotCount(rewardId) + if rewards then + for i, item in ipairs(rewards) do + local grid + if self.GridList[i] then + grid = self.GridList[i] + else + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommon) + grid = XUiGridCommon.New(self, ui) + grid.Transform:SetParent(self.PanelDropContent, false) + self.GridList[i] = grid + end + grid:Refresh(item) + grid.GameObject:SetActive(true) + end + end + + local rewardsCount = 0 + if rewards then + rewardsCount = #rewards + end + + for j = 1, #self.GridList do + if j > rewardsCount then + self.GridList[j].GameObject:SetActive(false) + end + end +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiActivityBossSingleDetail:InitAutoScript() + self:AutoAddListener() +end + +function XUiActivityBossSingleDetail:AutoAddListener() + self:RegisterClickEvent(self.BtnAddNum, self.OnBtnAddNumClick) + self:RegisterClickEvent(self.BtnEnter, self.OnBtnEnterClick) + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:RegisterClickEvent(self.BtnAttention, self.OnBtnAttentionClick) +end +-- auto +function XUiActivityBossSingleDetail:OnBtnAddNumClick() + local stageId = XFubenActivityBossSingleConfigs.GetStageId(self.ChallengeId) + local challengeData = XDataCenter.FubenMainLineManager.GetStageBuyChallengeData(stageId) + XLuaUiManager.Open("UiBuyAsset", 1, function() + self:InitCommon() + end, challengeData) +end + +function XUiActivityBossSingleDetail:OnBtnEnterClick() + local stageId = XFubenActivityBossSingleConfigs.GetStageId(self.ChallengeId) + XLuaUiManager.Open("UiNewRoomSingle", stageId) + self:Close() +end + +function XUiActivityBossSingleDetail:OnBtnBackClick() + if not self.GameObject.activeSelf then + self:Close() + return + end + self:PlayAnimation("AnimOnDisable", function() + self:Close() + end) +end + +function XUiActivityBossSingleDetail:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiActivityBossSingleDetail:OnBtnAttentionClick() + local stageId = XFubenActivityBossSingleConfigs.GetStageId(self.ChallengeId) + local attentionDesc = XFubenActivityBossSingleConfigs.GetStageAttention(stageId) + XUiManager.UiFubenDialogTip(CS.XTextManager.GetText("ActivityBossSingleAttention"), attentionDesc) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiActivityBranch/XUiActivityBranch.lua b/Resources/Scripts/XUi/XUiActivityBranch/XUiActivityBranch.lua new file mode 100644 index 00000000..36c23406 --- /dev/null +++ b/Resources/Scripts/XUi/XUiActivityBranch/XUiActivityBranch.lua @@ -0,0 +1,283 @@ +local stringGsub = string.gsub +local CsXTextManagerGetText = CS.XTextManager.GetText +local TimeFormat = "yyyy-MM-dd" +local CsXScheduleManager = XScheduleManager +local XUiGridChapter = require("XUi/XUiFubenMainLineChapter/XUiGridChapter") +local ChildDetailUi = "UiFubenBranchStageDetail" + +local XUiActivityBranch = XLuaUiManager.Register(XLuaUi, "UiActivityBranch") + +function XUiActivityBranch:OnAwake() + self:InitAutoScript() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self.BtnActDesc.gameObject:SetActiveEx(false) +end + +function XUiActivityBranch:OnStart(sectionId, difficultType, stageId) + self.SectionId = sectionId + self.DefaultStageId = stageId + self.ChapterList = {} + if difficultType then + XDataCenter.FubenActivityBranchManager.SelectDifficult(difficultType == XDataCenter.FubenActivityBranchManager.BranchType.Difficult) + end + + self.AnimBeijingEnable = self:FindGameObject("AnimBeijingEnable") --这个timeline影响了透明度还原,要强制打断 + self.AnimBeijingDisable = self:FindGameObject("AnimBeijingDisable") --这个timeline影响了透明度还原,要强制打断 +end + +function XUiActivityBranch:OnEnable() + self:Refresh() +end + +function XUiActivityBranch:OnDisable() + self:DestroyActivityTimer() +end + +function XUiActivityBranch:Refresh() + local sectionId = self.SectionId + local sectionCfg = XFubenActivityBranchConfigs.GetSectionCfg(sectionId) + local chapterId = XDataCenter.FubenActivityBranchManager.GetCurChapterId(sectionId) + + local chapterCfg = XFubenActivityBranchConfigs.GetChapterCfg(chapterId) + local isSelectDifficult = XDataCenter.FubenActivityBranchManager.IsSelectDifficult() + + self.TxtTitle.text = chapterCfg.Name + self.TxtSection.text = sectionCfg.Name + self.TxtLevel.text = CsXTextManagerGetText("ActivityBranchLevelDes", sectionCfg.MinLevel, sectionCfg.MaxLevel) + self.RImgBg1:SetRawImage(chapterCfg.Bg1) + self.RImgBg2:SetRawImage(chapterCfg.Bg2) + self.BtnSwitch2Fight.gameObject:SetActiveEx(not isSelectDifficult) + self.BtnSwitch2Regional.gameObject:SetActiveEx(isSelectDifficult) + self.ImgLock.gameObject:SetActiveEx(not XDataCenter.FubenActivityBranchManager.CheckActivityCondition(sectionId)) + + self:CreateActivityTimer() + self:RefreshChapterList() +end + +function XUiActivityBranch:RefreshChapterList() + local chapterId = XDataCenter.FubenActivityBranchManager.GetCurChapterId(self.SectionId) + local chapterCfg = XFubenActivityBranchConfigs.GetChapterCfg(chapterId) + local data = { + Chapter = chapterCfg, + StageList = chapterCfg.StageId, + HideStageCb = handler(self, self.CloseStageDetailCb), + ShowStageCb = handler(self, self.ShowStageDetail), + } + + local prefabName = chapterCfg.Prefab + local grid = self.ChapterList[prefabName] + if not grid or XTool.UObjIsNil(grid.GameObject) then + local go = self.PanelActivityBranchStages:LoadPrefab(prefabName) + if not XTool.UObjIsNil(go) then + local autoChangeBgArgs = { + AutoChangeBgCb = function(autoChangeBgFlag) + self.RImgBg1.gameObject:SetActiveEx(true) + self.RImgBg2.gameObject:SetActiveEx(true) + if autoChangeBgFlag then + self:PlayAnimationWithMask("AnimBeijingDisable") + else + self:PlayAnimationWithMask("AnimBeijingEnable") + end + CS.XAudioManager.PlaySound(XSoundManager.UiBasicsMusic.UiActivityBranch_SwitchBg) + end, + DatumLinePrecent = XDataCenter.FubenActivityBranchManager.GetChapterDatumLinePrecent(chapterId), + StageIndex = XDataCenter.FubenActivityBranchManager.GetChapterMoveStageIndex(chapterId), + } + + grid = XUiGridChapter.New(self, go, autoChangeBgArgs) + self.ChapterList[prefabName] = grid + end + end + + grid.FirstAnim = true + grid:UpdateChapterGrid(data) + + -- 初始背景图片透明度设置 + local isSelectDifficult = XDataCenter.FubenActivityBranchManager.IsSelectDifficult() + local fitCondition = grid.FirstSetBg + if isSelectDifficult or fitCondition then + self.RImgBg1.gameObject:SetActiveEx(true) + self.AnimBeijingEnable:SetActiveEx(false) + self.AnimBeijingEnable:SetActiveEx(true) + self.RImgBg1.color = CS.UnityEngine.Color(1, 1, 1, 1) + else + self.RImgBg1.gameObject:SetActiveEx(false) + end + if not isSelectDifficult and not fitCondition then + self.RImgBg2.gameObject:SetActiveEx(true) + self.AnimBeijingDisable:SetActiveEx(false) + self.AnimBeijingDisable:SetActiveEx(true) + self.RImgBg2.color = CS.UnityEngine.Color(1, 1, 1, 1) + else + self.RImgBg2.gameObject:SetActiveEx(false) + end + + -- 默认选中 + if self.DefaultStageId then + grid:ClickStageGridByStageId(self.DefaultStageId) + self.DefaultStageId = nil + end + + self.CurGrid = grid +end + +function XUiActivityBranch:ShowStageDetail(stage) + if XDataCenter.FubenActivityBranchManager.IsStatusEqualFightEnd() then + XUiManager.TipText("ActivityBranchFightEnd") + return + end + + self:OpenOneChildUi(ChildDetailUi, self) + self:FindChildUiObj(ChildDetailUi):Refresh(stage) +end + +function XUiActivityBranch:CloseStageDetailCb() + if XLuaUiManager.IsUiShow(ChildDetailUi) then + self:FindChildUiObj(ChildDetailUi):CloseWithAnimDisable() + end +end + +function XUiActivityBranch:CloseStageDetail() + if self.CurGrid then + self.CurGrid:CancelSelect() + end +end + +function XUiActivityBranch:CreateActivityTimer() + self:DestroyActivityTimer() + + local time = XTime.GetServerNowTimestamp() + local fightEndTime = XDataCenter.FubenActivityBranchManager.GetFightEndTime() + local activityEndTime = XDataCenter.FubenActivityBranchManager.GetActivityEndTime() + local shopStr = CsXTextManagerGetText("ActivityBranchShopLeftTime") + local fightStr = CsXTextManagerGetText("ActivityBranchFightLeftTime") + + if XDataCenter.FubenActivityBranchManager.IsStatusEqualFightEnd() then + self.TxtResetDesc.text = shopStr + self.TxtLeftTime.text = XUiHelper.GetTime(activityEndTime - time, XUiHelper.TimeFormatType.ACTIVITY) + else + self.TxtResetDesc.text = fightStr + self.TxtLeftTime.text = XUiHelper.GetTime(fightEndTime - time, XUiHelper.TimeFormatType.ACTIVITY) + end + + self.ActivityTimer = CsXScheduleManager.ScheduleForever(function() + if XTool.UObjIsNil(self.TxtLeftTime) then + self:DestroyActivityTimer() + return + end + + time = time + 1 + + if time >= activityEndTime then + self:DestroyActivityTimer() + XDataCenter.FubenActivityBranchManager.OnActivityEnd() + elseif fightEndTime <= time then + local leftTime = activityEndTime - time + if leftTime > 0 then + self.TxtResetDesc.text = shopStr + self.TxtLeftTime.text = XUiHelper.GetTime(leftTime, XUiHelper.TimeFormatType.ACTIVITY) + end + else + local leftTime = fightEndTime - time + if leftTime > 0 then + self.TxtResetDesc.text = fightStr + self.TxtLeftTime.text = XUiHelper.GetTime(leftTime, XUiHelper.TimeFormatType.ACTIVITY) + else + self:DestroyActivityTimer() + self:CreateActivityTimer() + end + end + end, CsXScheduleManager.SECOND, 0) +end + +function XUiActivityBranch:DestroyActivityTimer() + if self.ActivityTimer then + CsXScheduleManager.UnSchedule(self.ActivityTimer) + self.ActivityTimer = nil + end +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiActivityBranch:InitAutoScript() + self:AutoAddListener() +end + +function XUiActivityBranch:AutoAddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:RegisterClickEvent(self.BtnActDesc, self.OnBtnActDescClick) + self:RegisterClickEvent(self.BtnSwitch2Fight, self.OnBtnSwitch2FightClick) + self:RegisterClickEvent(self.BtnSwitch2Regional, self.OnBtnSwitch2RegionalClick) + self:RegisterClickEvent(self.BtnDrop, self.OnBtnDropClick) + self:RegisterClickEvent(self.BtnShop, self.OnBtnShopClick) + self:RegisterClickEvent(self.BtnCloseDetail, self.OnBtnCloseDetailClick) +end +-- auto +function XUiActivityBranch:OnBtnBackClick() + if XLuaUiManager.IsUiShow(ChildDetailUi) then + self:CloseStageDetail() + else + self:Close() + end +end + +function XUiActivityBranch:OnBtnCloseDetailClick() + self:CloseStageDetail() +end + +function XUiActivityBranch:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiActivityBranch:OnBtnActDescClick() + local chapterId = XDataCenter.FubenActivityBranchManager.GetCurChapterId(self.SectionId) + local chapterCfg = XFubenActivityBranchConfigs.GetChapterCfg(chapterId) + local description = stringGsub(chapterCfg.Description, "\\n", "\n") + XUiManager.UiFubenDialogTip("", description) +end + +function XUiActivityBranch:OnBtnSwitch2FightClick() + if not XDataCenter.FubenActivityBranchManager.IsStatusEqualChallengeBegin() then + local chanllengeBeginTime = XDataCenter.FubenActivityBranchManager.GetActivityChallengeBeginTime() + local timeStr = XTime.TimestampToGameDateTimeString(chanllengeBeginTime, TimeFormat) + local desc = CsXTextManagerGetText("ActivityBranchChallengeBeginTime", timeStr) + XUiManager.TipError(desc) + return + end + + local ret, desc = XDataCenter.FubenActivityBranchManager.CheckActivityCondition(self.SectionId) + if not ret then + XUiManager.TipError(desc) + return + end + + XDataCenter.FubenActivityBranchManager.SelectDifficult(true) + self:CloseStageDetail() + self:Refresh() + CS.XAudioManager.PlaySound(XSoundManager.UiBasicsMusic.UiActivityBranch_SwitchBg) + self:PlayAnimationWithMask("BranchStagesQieHuan") +end + +function XUiActivityBranch:OnBtnSwitch2RegionalClick() + XDataCenter.FubenActivityBranchManager.SelectDifficult(false) + self:CloseStageDetail() + self:Refresh() + CS.XAudioManager.PlaySound(XSoundManager.UiBasicsMusic.UiActivityBranch_SwitchBg) + self:PlayAnimationWithMask("BranchStagesQieHuan") +end + +function XUiActivityBranch:OnBtnDropClick() + local sectionCfgs = XFubenActivityBranchConfigs.GetSectionCfgs() + local curSectionId = XDataCenter.FubenActivityBranchManager.GetCurSectionId() + XLuaUiManager.Open("UiActivityBranchReward", sectionCfgs, curSectionId) +end + +function XUiActivityBranch:OnBtnShopClick() + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.ShopCommon) then + return + end + + local sectionCfg = XFubenActivityBranchConfigs.GetSectionCfg(self.SectionId) + XFunctionManager.SkipInterface(sectionCfg.SkipId) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiActivityBranch/XUiActivityBranchReward.lua b/Resources/Scripts/XUi/XUiActivityBranch/XUiActivityBranchReward.lua new file mode 100644 index 00000000..dbb603e3 --- /dev/null +++ b/Resources/Scripts/XUi/XUiActivityBranch/XUiActivityBranchReward.lua @@ -0,0 +1,48 @@ +local XUiGridActivityBranchReward = require("XUi/XUiActivityBranch/XUiGridActivityBranchReward") + +local XUiActivityBranchReward = XLuaUiManager.Register(XLuaUi, "UiActivityBranchReward") + +function XUiActivityBranchReward:OnAwake() + self:InitAutoScript() + self:InitDynamicTable() +end + +function XUiActivityBranchReward:OnStart(sectionCfgs, curSectionId) + self.SectionCfgs = sectionCfgs + self.CurSectionId = curSectionId + self:RefreshDynamicTable() +end + +function XUiActivityBranchReward:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelScroll) + self.DynamicTable:SetProxy(XUiGridActivityBranchReward) + self.DynamicTable:SetDelegate(self) +end + +function XUiActivityBranchReward:RefreshDynamicTable() + self.DynamicTable:SetDataSource(self.SectionCfgs) + self.DynamicTable:ReloadDataASync() +end + +--动态列表事件 +function XUiActivityBranchReward:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:SetRootUi(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:Refresh(self.SectionCfgs[index], self.CurSectionId) + end +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiActivityBranchReward:InitAutoScript() + self:AutoAddListener() +end + +function XUiActivityBranchReward:AutoAddListener() + self:RegisterClickEvent(self.BtnBg, self.OnBtnBgClick) +end +-- auto +function XUiActivityBranchReward:OnBtnBgClick() + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiActivityBranch/XUiFubenBranchStageDetail.lua b/Resources/Scripts/XUi/XUiActivityBranch/XUiFubenBranchStageDetail.lua new file mode 100644 index 00000000..099cce0d --- /dev/null +++ b/Resources/Scripts/XUi/XUiActivityBranch/XUiFubenBranchStageDetail.lua @@ -0,0 +1,153 @@ +local XUiFubenBranchStageDetail = XLuaUiManager.Register(XLuaUi, "UiFubenBranchStageDetail") + +function XUiFubenBranchStageDetail:OnAwake() + self:InitAutoScript() + self.GridCommon.gameObject:SetActive(false) + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) +end + +function XUiFubenBranchStageDetail:OnStart(parent) + self.GridList = {} + self.Parent = parent +end + +function XUiFubenBranchStageDetail:OnEnable() + self.Parent.PanelAsset.gameObject:SetActiveEx(false) +end + +function XUiFubenBranchStageDetail:OnDisable() + self.Parent.PanelAsset.gameObject:SetActiveEx(true) +end + +function XUiFubenBranchStageDetail:Refresh(stage) + self.Stage = stage + self:UpdateCommon() + self:UpdateRewards() +end + +function XUiFubenBranchStageDetail:UpdateCommon() + local stageId = self.Stage.StageId + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + local nanDuIcon = XDataCenter.FubenManager.GetDifficultIcon(stageId) + local maxChallengeNum = XDataCenter.FubenManager.GetStageMaxChallengeNums(stageId) + local buyChallengeCount = XDataCenter.FubenManager.GetStageBuyChallengeCount(stageId) + + self.RImgNandu:SetRawImage(nanDuIcon) + self.TxtTitle.text = self.Stage.Name + self.TxtLevelVal.text = self.Stage.RecommandLevel + self.TxtATNums.text = self.Stage.RequireActionPoint + self.PanelNums.gameObject:SetActive(maxChallengeNum > 0) + self.PanelNoLimitCount.gameObject:SetActive(maxChallengeNum <= 0) + self.BtnAddNum.gameObject:SetActive(buyChallengeCount > 0) + for i = 1, 3 do + self["TxtActive" .. i].text = stageCfg.StarDesc[i] + end + + if maxChallengeNum > 0 then + local stageData = XDataCenter.FubenManager.GetStageData(stageId) + local chanllengeNum = stageData and stageData.PassTimesToday or 0 + self.TxtAllNums.text = "/" .. maxChallengeNum + self.TxtLeftNums.text = maxChallengeNum - chanllengeNum + end + + local firstDrop = false + if not stageInfo.Passed then + local cfg = XDataCenter.FubenManager.GetStageLevelControl(stageId) + if cfg and cfg.FirstRewardShow > 0 or self.Stage.FirstRewardShow > 0 then + firstDrop = true + end + end + self.TxtFirstDrop.gameObject:SetActive(firstDrop) + self.TxtDrop.gameObject:SetActive(not firstDrop) +end + +function XUiFubenBranchStageDetail:UpdateRewards() + local stage = self.Stage + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stage.StageId) + + -- 获取显示奖励Id + local rewardId = 0 + local IsFirst = false + local cfg = XDataCenter.FubenManager.GetStageLevelControl(stage.StageId) + if not stageInfo.Passed then + rewardId = cfg and cfg.FirstRewardShow or stage.FirstRewardShow + if cfg and cfg.FirstRewardShow > 0 or stage.FirstRewardShow > 0 then + IsFirst = true + end + end + if rewardId == 0 then + rewardId = cfg and cfg.FinishRewardShow or stage.FinishRewardShow + end + if rewardId == 0 then + for j = 1, #self.GridList do + self.GridList[j].GameObject:SetActive(false) + end + return + end + + local rewards = IsFirst and XRewardManager.GetRewardList(rewardId) or XRewardManager.GetRewardListNotCount(rewardId) + if rewards then + for i, item in ipairs(rewards) do + local grid + if self.GridList[i] then + grid = self.GridList[i] + else + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommon) + grid = XUiGridCommon.New(self, ui) + grid.Transform:SetParent(self.PanelDropContent, false) + self.GridList[i] = grid + end + grid:Refresh(item) + grid.GameObject:SetActive(true) + end + end + + local rewardsCount = 0 + if rewards then + rewardsCount = #rewards + end + + for j = 1, #self.GridList do + if j > rewardsCount then + self.GridList[j].GameObject:SetActive(false) + end + end +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiFubenBranchStageDetail:InitAutoScript() + self:AutoAddListener() +end + +function XUiFubenBranchStageDetail:AutoAddListener() + self:RegisterClickEvent(self.BtnAddNum, self.OnBtnAddNumClick) + self:RegisterClickEvent(self.BtnEnter, self.OnBtnEnterClick) + self:RegisterClickEvent(self.BtnClose, self.OnBtnCloseClick) +end + +function XUiFubenBranchStageDetail:OnBtnCloseClick() + self:CloseWithAnimDisable() +end +-- auto +function XUiFubenBranchStageDetail:OnBtnAddNumClick() + local challengeData = XDataCenter.FubenMainLineManager.GetStageBuyChallengeData(self.Stage.StageId) + XLuaUiManager.Open("UiBuyAsset", 1, function() + self:UpdateCommon() + end, challengeData) +end + +function XUiFubenBranchStageDetail:OnBtnEnterClick() + local stage = self.Stage + if XDataCenter.FubenManager.CheckPreFight(stage) then + self.Parent:CloseStageDetail() + XLuaUiManager.Open("UiNewRoomSingle", stage.StageId) + end +end + +function XUiFubenBranchStageDetail:CloseWithAnimDisable() + self:PlayAnimation("AnimEnd", function() + self:Close() + end) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiActivityBranch/XUiGridActivityBranchReward.lua b/Resources/Scripts/XUi/XUiActivityBranch/XUiGridActivityBranchReward.lua new file mode 100644 index 00000000..e90f735d --- /dev/null +++ b/Resources/Scripts/XUi/XUiActivityBranch/XUiGridActivityBranchReward.lua @@ -0,0 +1,74 @@ +local CsXTextManager = CS.XTextManager + +local XUiGridActivityBranchReward = XClass(nil, "XUiGridActivityBranchReward") + +function XUiGridActivityBranchReward:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self:InitAutoScript() + self.GridList = {} +end + +function XUiGridActivityBranchReward:SetRootUi(rootUi) + self.RootUi = rootUi +end + +function XUiGridActivityBranchReward:Refresh(sectionCfg, curSectionId) + local sectionId = sectionCfg.Id + + self.TxtSection.text = sectionCfg.Name + self.TxtLevel.text = CsXTextManager.GetText("ActivityBranchCurLevelDes", sectionCfg.MinLevel, sectionCfg.MaxLevel) + self.TxtCur.gameObject:SetActive(curSectionId == sectionId) + self.RootUi:SetUiSprite(self.ImgIcon, sectionCfg.Icon) + + --显示的奖励 + local rewards = XRewardManager.GetRewardList(sectionCfg.ShowRewardId) + local start = 0 + for i, item in ipairs(rewards) do + start = i + local grid + if self.GridList[i] then + grid = self.GridList[i] + else + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommon) + grid = XUiGridCommon.New(self.RootUi, ui) + grid.Transform:SetParent(self.PanelRewards, false) + self.GridList[i] = grid + end + grid:Refresh(item) + grid.GameObject:SetActive(true) + end + + for j = start + 1, #self.GridList do + self.GridList[j].GameObject:SetActive(false) + end +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiGridActivityBranchReward:InitAutoScript() + XTool.InitUiObject(self) + self:AutoAddListener() +end + +function XUiGridActivityBranchReward:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiGridActivityBranchReward:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiGridActivityBranchReward:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiGridActivityBranchReward:AutoAddListener() +end +-- auto +return XUiGridActivityBranchReward \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiActivityBrief/XActivityBrieButton.lua b/Resources/Scripts/XUi/XUiActivityBrief/XActivityBrieButton.lua new file mode 100644 index 00000000..0de60a6f --- /dev/null +++ b/Resources/Scripts/XUi/XUiActivityBrief/XActivityBrieButton.lua @@ -0,0 +1,104 @@ +local XActivityBrieButton = XClass(nil, "XActivityBrieButton") + + +local ACTIVITYBRIEBUTTONISFIRSTTIMECLICK = "ActivityBrieButtonIsFirstTimeClick" + +function XActivityBrieButton:Ctor(ui, uiRoot, activityGroupId) + self.BtnCom = ui + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + self.activityGroupId = activityGroupId + self.IsAlwaysCheck = false + self.BtnCom:ShowTag(false) + self.BtnCom:ShowReddot(false) +end + +function XActivityBrieButton:Refresh(args) + local isOpen, str, timeStr = XActivityBrieIsOpen.Get(self.activityGroupId, args) + self.args = args + + if not string.IsNilOrEmpty(timeStr) then + self.BtnCom:SetNameByGroup(0, timeStr) + else + local config = XActivityBriefConfigs.GetActivityGroupConfig(self.activityGroupId) + self.BtnCom:SetNameByGroup(0, "") + end + + self.BtnCom:SetDisable(not isOpen) +end + +--可挑战Tag,第一次点击后消失 +--添加特殊处理,需要一直显示Tag的则第三个参数为true +function XActivityBrieButton:AddNewTagEvent(conditionGroup, args, isAlwaysCheck) + self.IsAlwaysCheck = isAlwaysCheck + if self:CheckFirstClicked() or isAlwaysCheck then + XRedPointManager.AddRedPointEvent(self.BtnCom, self.OnNewTagEvent, self, conditionGroup, args, true) + else + self.BtnCom:ShowTag(false) + end +end + +function XActivityBrieButton:OnNewTagEvent(count) + self:ShowTag(count > -1) +end + +function XActivityBrieButton:ShowTag(isShow) + local isOpen = XActivityBrieIsOpen.Get(self.activityGroupId, self.args) + + if (self:CheckFirstClicked() or self.IsAlwaysCheck) and isOpen then + self.BtnCom:ShowTag(isShow) + else + self.BtnCom:ShowTag(false) + end +end + +function XActivityBrieButton:CheckFirstClicked() + return not XSaveTool.GetData(self:GetPlayerPrefsKey()) +end + +--红点 +function XActivityBrieButton:AddRedPointEvent(conditionGroup, args) + XRedPointManager.AddRedPointEvent(self.BtnCom, self.OnRedPointEvent, self, conditionGroup, args, true) +end + +function XActivityBrieButton:OnRedPointEvent(count) + self:ShowReddot(count >= 0) +end + +function XActivityBrieButton:ShowReddot(value) + local isOpen = XActivityBrieIsOpen.Get(self.activityGroupId, self.args) + if not isOpen then + value = false + end + + self.BtnCom:ShowReddot(value) +end + +function XActivityBrieButton:GetButtonCom() + return self.BtnCom +end + +function XActivityBrieButton:SetOnClick(func) + self.BtnCom.CallBack = function() + local isOpen, str = XActivityBrieIsOpen.Get(self.activityGroupId, self.args) + if isOpen then + XSaveTool.SaveData(self:GetPlayerPrefsKey(), true) + func() + else + if string.IsNilOrEmpty(str) then + XLog.Error("没有返回未开放的点击提示,activityGroupId:" .. self.activityGroupId) + else + XUiManager.TipMsg(str) + end + end + end +end + +-- 记录是否第一次点击 +function XActivityBrieButton:GetPlayerPrefsKey() + local severNextRefreshTime = XTime.GetSeverNextRefreshTime() + return string.format("%s_%s_%s_%s", XPlayer.Id, ACTIVITYBRIEBUTTONISFIRSTTIMECLICK, severNextRefreshTime, self.activityGroupId) +end + +return XActivityBrieButton \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiActivityBrief/XActivityBrieIsOpen.lua b/Resources/Scripts/XUi/XUiActivityBrief/XActivityBrieIsOpen.lua new file mode 100644 index 00000000..a2be1194 --- /dev/null +++ b/Resources/Scripts/XUi/XUiActivityBrief/XActivityBrieIsOpen.lua @@ -0,0 +1,749 @@ +--@description 获取活动简介的活动是否开放 +--[[ 对应活动的开放判断函数默认返回的参数: + @返回参数1:是否开放 + @返回参数2:未开放的点击提示 + @返回参数3:活动时间(可不返回) +]] +XActivityBrieIsOpen = {} + +local TimeFormat = "MM/dd" +local CSXTextManagerGetText = CS.XTextManager.GetText +local TimestampToGameDateTimeString = XTime.TimestampToGameDateTimeString + +--对应下面的开放判断函数 +XActivityBrieIsOpen.IsOpenFunc = { + [XActivityBriefConfigs.ActivityGroupId.MainLine] = "MainLine", --主线活动 + [XActivityBriefConfigs.ActivityGroupId.Branch] = "Branch", --支线活动 + [XActivityBriefConfigs.ActivityGroupId.BossSingle] = "BossSingle", --单机Boss活动 + [XActivityBriefConfigs.ActivityGroupId.BossOnline] = "BossOnline", --联机Boss活动 + [XActivityBriefConfigs.ActivityGroupId.Prequel] = "Prequel", --间章故事-角色A + [XActivityBriefConfigs.ActivityGroupId.BabelTower] = "BabelTower", --巴别塔 + [XActivityBriefConfigs.ActivityGroupId.RougueLike] = "RougueLike", --爬塔 + [XActivityBriefConfigs.ActivityGroupId.RepeatChallenge] = "RepeatChallenge", --复刷关 + [XActivityBriefConfigs.ActivityGroupId.ArenaOnline] = "ArenaOnline", --区域联机 + [XActivityBriefConfigs.ActivityGroupId.UnionKill] = "UnionKill", --狙击战 + [XActivityBriefConfigs.ActivityGroupId.ShortStories] = "ShortStories", --短篇故事 + [XActivityBriefConfigs.ActivityGroupId.Prequel2] = "Prequel2", --间章故事-角色B + [XActivityBriefConfigs.ActivityGroupId.Labyrinth] = "Labyrinth", --迷宫 + [XActivityBriefConfigs.ActivityGroupId.Society] = "Society", --公会 + [XActivityBriefConfigs.ActivityGroupId.Resource] = "Resource", --资源 + [XActivityBriefConfigs.ActivityGroupId.BigWar] = "BigWar", --大作战 + [XActivityBriefConfigs.ActivityGroupId.Extra] = "Extra", --番外-普通 + [XActivityBriefConfigs.ActivityGroupId.WorldBoss] = "WorldBoss", --世界Boss + [XActivityBriefConfigs.ActivityGroupId.Expedition] = "Expedition", --自走棋 + [XActivityBriefConfigs.ActivityGroupId.FubenBossSingle] = "FubenBossSingle", --幻痛囚笼 + [XActivityBriefConfigs.ActivityGroupId.ActivityBriefShop] = "ActivityBriefShop", --活动商店 + [XActivityBriefConfigs.ActivityGroupId.Extra2] = "Extra", --番外-隐藏 + [XActivityBriefConfigs.ActivityGroupId.MaintainerAction] = "MaintainerAction", --大富翁玩法 + [XActivityBriefConfigs.ActivityGroupId.RpgTower] = "RpgTower", --RPG玩法 + [XActivityBriefConfigs.ActivityGroupId.ActivityDrawCard] = "ActivityDrawCard", --活动抽卡 + [XActivityBriefConfigs.ActivityGroupId.TRPGMainLine] = "TRPGMainLine", --终焉福音-主线跑团活动 + [XActivityBriefConfigs.ActivityGroupId.NewCharActivity] = "NewCharActivity", -- 新角色教学活动 + [XActivityBriefConfigs.ActivityGroupId.FubenActivityTrial] = "FubenActivityTrial", -- 试玩关 + [XActivityBriefConfigs.ActivityGroupId.ShiTu] = "ShiTu", -- 师徒系统 + [XActivityBriefConfigs.ActivityGroupId.Nier] = "Nier", -- 尼尔玩法 + [XActivityBriefConfigs.ActivityGroupId.Pokemon] = "Pokemon", -- 口袋战双 + [XActivityBriefConfigs.ActivityGroupId.Pursuit] = "Pursuit", -- 追击玩法 + [XActivityBriefConfigs.ActivityGroupId.Simulate] = "Simulate", --模拟战 + [XActivityBriefConfigs.ActivityGroupId.StrongHold] = "StrongHold", --超级据点 + [XActivityBriefConfigs.ActivityGroupId.Partner] = "Partner", --伙伴系统 + [XActivityBriefConfigs.ActivityGroupId.MoeWar] = "MoeWar", --萌战 + [XActivityBriefConfigs.ActivityGroupId.PetCard] = "PetCard", --宠物抽卡 + [XActivityBriefConfigs.ActivityGroupId.PetTrial] = "PetTrial", --新宠物活动 + [XActivityBriefConfigs.ActivityGroupId.PokerGuessing] = "PokerGuessing", --翻牌拼大小 + [XActivityBriefConfigs.ActivityGroupId.Hack] = "Hack", --骇客玩法 + [XActivityBriefConfigs.ActivityGroupId.RpgMaker] = "RpgMaker", --端午活动 + [XActivityBriefConfigs.ActivityGroupId.Reform] = "Reform", --改造玩法 + [XActivityBriefConfigs.ActivityGroupId.CoupleCombat] = "CoupleCombat", --双人同行 + [XActivityBriefConfigs.ActivityGroupId.SuperTower] = "SuperTower", --双人同行 + [XActivityBriefConfigs.ActivityGroupId.KillZone] = "KillZone", --双人同行 + [XActivityBriefConfigs.ActivityGroupId.SummerSeries] = "SummerSeries", --双人同行 +} + +function XActivityBrieIsOpen.Get(activityGroupId, ...) + local funcName = XActivityBrieIsOpen.IsOpenFunc[activityGroupId] + if funcName then + local func = XActivityBrieIsOpen[funcName] + + if not func then + return + end + + return func(...) + else + XLog.Error("活动没有配置开放条件:" .. funcName) + return false + end +end + +--@region 对应活动的开放判断函数 +function XActivityBrieIsOpen.MainLine() + local functionId = XFunctionManager.FunctionName.FubenActivityMainLine + local isOpen = XFunctionManager.JudgeCanOpen(functionId) and XDataCenter.FubenMainLineManager.IsMainLineActivityOpen() + return isOpen, XDataCenter.FubenMainLineManager.IsMainLineActivityOpen() and XFunctionManager.GetFunctionOpenCondition(functionId) or CSXTextManagerGetText("ActivityBriefMainlineNotInTime") +end + +function XActivityBrieIsOpen.Branch() + local beginTime = XDataCenter.FubenActivityBranchManager.GetActivityBeginTime() + local fightEndTime = XDataCenter.FubenActivityBranchManager.GetFightEndTime() + local endTime = XDataCenter.FubenActivityBranchManager.GetActivityEndTime() + local inTime, timeStr, openTimeTipsStr = XActivityBrieIsOpen.RefreshAcitivityTime(beginTime, fightEndTime, endTime) + if inTime then + local functionId = XFunctionManager.FunctionName.FubenActivityBranch + local isOpen = XFunctionManager.JudgeCanOpen(functionId) + return isOpen, XFunctionManager.GetFunctionOpenCondition(functionId), timeStr + else + return false, openTimeTipsStr, timeStr + end +end + +function XActivityBrieIsOpen.BossSingle() + local beginTime = XDataCenter.FubenActivityBossSingleManager.GetActivityBeginTime() + local fightEndTime = XDataCenter.FubenActivityBossSingleManager.GetFightEndTime() + local endTime = XDataCenter.FubenActivityBossSingleManager.GetActivityEndTime() + local inTime, timeStr, openTimeTipsStr = XActivityBrieIsOpen.RefreshAcitivityTime(beginTime, fightEndTime, endTime) + + if inTime then + local functionId = XFunctionManager.FunctionName.FubenActivitySingleBoss + local isOpen = XFunctionManager.JudgeCanOpen(functionId) + return isOpen, XFunctionManager.GetFunctionOpenCondition(functionId), timeStr + else + return false, openTimeTipsStr, timeStr + end +end + +function XActivityBrieIsOpen.BossOnline() + local functionId = XFunctionManager.FunctionName.FubenActivityOnlineBoss + local isOpen = XFunctionManager.JudgeCanOpen(functionId) and XDataCenter.FubenBossOnlineManager.GetIsActivity() + return isOpen, XUiManager.TipText("ActivityBossOnlineOver") --* +end + +function XActivityBrieIsOpen.BabelTower() + local newActivityId = XDataCenter.FubenBabelTowerManager.GetNewActivityNo() + local beginTime = XDataCenter.FubenBabelTowerManager.GetActivityBeginTime(newActivityId) + local fightEndTime = XDataCenter.FubenBabelTowerManager.GetFightEndTime(newActivityId) + local endTime = XDataCenter.FubenBabelTowerManager.GetActivityEndTime(newActivityId) + local inTime, timeStr, openTimeTipsStr = XActivityBrieIsOpen.RefreshAcitivityTime(beginTime, fightEndTime, endTime) + + if inTime then + local functionId = XFunctionManager.FunctionName.BabelTower + local isOpen = XFunctionManager.JudgeCanOpen(functionId) + return isOpen, XFunctionManager.GetFunctionOpenCondition(functionId), timeStr + else + return false, openTimeTipsStr, timeStr + end +end + +function XActivityBrieIsOpen.RepeatChallenge() + local beginTime = XDataCenter.FubenRepeatChallengeManager.GetActivityBeginTime() + local fightEndTime = XDataCenter.FubenRepeatChallengeManager.GetFightEndTime() + local endTime = XDataCenter.FubenRepeatChallengeManager.GetActivityEndTime() + local inTime, timeStr, openTimeTipsStr = XActivityBrieIsOpen.RefreshAcitivityTime(beginTime, fightEndTime, endTime) + + if inTime then + local functionId = XFunctionManager.FunctionName.RepeatChallenge + local isOpen = XFunctionManager.JudgeCanOpen(functionId) + return isOpen, XFunctionManager.GetFunctionOpenCondition(functionId), timeStr + else + return false, openTimeTipsStr, timeStr + end +end + +function XActivityBrieIsOpen.ArenaOnline() + local functionId = XFunctionManager.FunctionName.ArenaOnline + local isOpen = XFunctionManager.JudgeCanOpen(functionId) + return isOpen, XFunctionManager.GetFunctionOpenCondition(functionId) +end + +function XActivityBrieIsOpen.UnionKill() + local beginTime, endTime = XDataCenter.FubenUnionKillManager.GetUnionActivityTimes() + local fightEndTime = endTime + local inTime, timeStr, openTimeTipsStr = XActivityBrieIsOpen.RefreshAcitivityTime(beginTime, fightEndTime, endTime) + + if inTime then + local functionId = XFunctionManager.FunctionName.FubenUnionKill + local isOpen = XFunctionManager.JudgeCanOpen(functionId) + return isOpen, XFunctionManager.GetFunctionOpenCondition(functionId), timeStr + else + return false, openTimeTipsStr, timeStr + end +end + +function XActivityBrieIsOpen.ShortStories() + return true +end + +--@region 间章 +local function GetPrequelBeginTime(coverId) + local coverTemplate = XPrequelConfigs.GetPrequelCoverById(coverId) + local time = coverTemplate.ActiveTimes[1] + if time then + return XTime.ParseToTimestamp(time) + else + return 0 + end +end + +local function Prequel(activityGroupId) + local config = XActivityBriefConfigs.GetActivityGroupConfig(activityGroupId) + local skipId = config.SkipId + local skipList = XFunctionConfig.GetSkipList(skipId) + local coverId = skipList.CustomParams[1] + local chapterId = skipList.CustomParams[2] + local nowTimeStamp = XTime.GetServerNowTimestamp() + local activeTime = GetPrequelBeginTime(coverId) + + if nowTimeStamp >= activeTime then + local functionId = XFunctionManager.FunctionName.Prequel + local isOpen = XFunctionManager.JudgeCanOpen(functionId) + + if isOpen then + local IsCanOpen = XDataCenter.FunctionalSkipManager.IsCanOpenUiPrequel(skipList) + local desc = XDataCenter.PrequelManager.GetChapterUnlockDescription(chapterId) + + return IsCanOpen, desc + else + return false, XFunctionManager.GetFunctionOpenCondition(functionId) + end + else + return false, XActivityBrieIsOpen.GetOpenTimeTipsStr(true, activeTime) + end +end + +function XActivityBrieIsOpen.Prequel() + return Prequel(XActivityBriefConfigs.ActivityGroupId.Prequel) +end + +function XActivityBrieIsOpen.Prequel2() + return Prequel(XActivityBriefConfigs.ActivityGroupId.Prequel2) +end + +--@endregion +function XActivityBrieIsOpen.Labyrinth() + local functionId = XFunctionManager.FunctionName.FubenInfesotorExplore + local isOpen = XFunctionManager.JudgeCanOpen(functionId) + return isOpen, XFunctionManager.GetFunctionOpenCondition(functionId) +end + +function XActivityBrieIsOpen.Society() + local functionId = XFunctionManager.FunctionName.Guild + local isOpen = XFunctionManager.JudgeCanOpen(functionId) + -- return isOpen, XFunctionManager.GetFunctionOpenCondition(functionId) + return false, CSXTextManagerGetText("ActivityGuildNotOpen")--因为延期,暂时写死 +end + +function XActivityBrieIsOpen.Resource() + local functionId = XFunctionManager.FunctionName.FubenDailyXYZB + local isOpen = XFunctionManager.JudgeCanOpen(functionId) + return isOpen, XFunctionManager.GetFunctionOpenCondition(functionId) +end + +function XActivityBrieIsOpen.BigWar() + local activityId = XDataCenter.FubenSpecialTrainManager.GetCurActivityId() + local config = XFubenSpecialTrainConfig.GetActivityConfigById(activityId) + local beginTime, endTime = XFunctionManager.GetTimeByTimeId(config.TimeId) + local fightEndTime = endTime + local inTime, timeStr, openTimeTipsStr = XActivityBrieIsOpen.RefreshAcitivityTime(beginTime, fightEndTime, endTime) + + if inTime then + local functionId = XFunctionManager.FunctionName.SpecialTrain + local isOpen = XFunctionManager.JudgeCanOpen(functionId) + return isOpen, XFunctionManager.GetFunctionOpenCondition(functionId), timeStr + else + return false, openTimeTipsStr, timeStr + end +end + +function XActivityBrieIsOpen.Extra(args) + local config = XActivityBriefConfigs.GetActivityGroupConfig(args.activityGroupId) + local skipList = XFunctionConfig.GetSkipList(config.SkipId) + local chapterId = skipList.CustomParams[1] + local specialTip = CsXTextManagerGetText("ActivityBriefExtraNotInTime") + local checkResult, checkDesription = XDataCenter.ExtraChapterManager.CheckCanGoTo(chapterId, nil, specialTip) + + if checkResult then + --如果是隐藏关卡还需要判断是否解锁 + if args.difficultType == XDataCenter.FubenManager.DifficultHard then + if not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.FubenDifficulty) then + return false, XFunctionManager.GetFunctionOpenCondition(XFunctionManager.FunctionName.FubenDifficulty) + end + end + + local timeStr = "" + local functionId = XFunctionManager.FunctionName.FubenActivityMainLine---这里实际上用了一个弃用系统的FO--在此仅相当于一个条件来使用 + local isOpen = XFunctionManager.JudgeCanOpen(functionId) and XDataCenter.ExtraChapterManager.IsExtraActivityOpen() + return isOpen, CSXTextManagerGetText("ActivityExpeditionOver") + else + return false, checkDesription + end +end + +function XActivityBrieIsOpen.WorldBoss() + local beginTime = XDataCenter.WorldBossManager.GetActivityBeginTime() + local endTime = XDataCenter.WorldBossManager.GetActivityEndTime() + local fightEndTime = endTime + local inTime, timeStr, openTimeTipsStr = XActivityBrieIsOpen.RefreshAcitivityTime(beginTime, fightEndTime, endTime) + if inTime then + local functionId = XFunctionManager.FunctionName.WorldBoss + local isOpen = XFunctionManager.JudgeCanOpen(functionId) and XDataCenter.WorldBossManager.IsInActivity() + return isOpen, XFunctionManager.GetFunctionOpenCondition(functionId), timeStr + else + return false, openTimeTipsStr, timeStr + end +end + +function XActivityBrieIsOpen.Expedition() + local beginTime = XDataCenter.ExpeditionManager.GetStartTime() + local endTime = XDataCenter.ExpeditionManager.GetEndTime() + local fightEndTime = endTime + local inTime, timeStr, openTimeTipsStr = XActivityBrieIsOpen.RefreshAcitivityTime(beginTime, fightEndTime, endTime) + + if inTime then + local functionId = XFunctionManager.FunctionName.Expedition + local isOpen = XFunctionManager.JudgeCanOpen(functionId) and not XDataCenter.ExpeditionManager.GetIsActivityEnd() + return isOpen, XFunctionManager.GetFunctionOpenCondition(functionId), timeStr + else + return false, openTimeTipsStr, timeStr + end +end + +function XActivityBrieIsOpen.FubenBossSingle() + local functionId = XFunctionManager.FunctionName.FubenChallengeBossSingle + local isOpen = XFunctionManager.JudgeCanOpen(functionId) + return isOpen, XFunctionManager.GetFunctionOpenCondition(functionId) +end + +function XActivityBrieIsOpen.ActivityBriefShop() + local beginTime = XActivityBriefConfigs.GetActivityBeginTime() + local endTime = XActivityBriefConfigs.GetActivityEndTime() + local fightEndTime = endTime + local inTime, timeStr, openTimeTipsStr = XActivityBrieIsOpen.RefreshAcitivityTime(beginTime, fightEndTime, endTime) + + if inTime then + local functionId = XFunctionManager.FunctionName.ShopActive + local isOpen = XFunctionManager.JudgeCanOpen(functionId) + return isOpen, XFunctionManager.GetFunctionOpenCondition(functionId), timeStr + else + return false, openTimeTipsStr, timeStr + end +end + +function XActivityBrieIsOpen.RougueLike() + local functionId = XFunctionManager.FunctionName.RogueLike + local beginTime = XDataCenter.FubenRogueLikeManager.GetActivityBeginTime() + local fightEndTime = XDataCenter.FubenRogueLikeManager.GetFightEndTime() + local endTime = XDataCenter.FubenRogueLikeManager.GetActivityEndTime() + local inTime, timeStr, openTimeTipsStr = XActivityBrieIsOpen.RefreshAcitivityTime(beginTime, fightEndTime, endTime) + + if inTime then + local isOpen = XFunctionManager.JudgeCanOpen(functionId) + return isOpen, XFunctionManager.GetFunctionOpenCondition(functionId), timeStr + else + return false, openTimeTipsStr, timeStr + end +end + + +function XActivityBrieIsOpen.MaintainerAction() + local ret, msg = XDataCenter.MaintainerActionManager.CheckIsOpen() + return ret, msg +end + +function XActivityBrieIsOpen.RpgTower() + local beginTime = XDataCenter.RpgTowerManager.GetStartTime() + local endTime = XDataCenter.RpgTowerManager.GetEndTime() + local fightEndTime = endTime + local inTime, _, openTimeTipsStr = XActivityBrieIsOpen.RefreshAcitivityTime(beginTime, fightEndTime, endTime) + local timeStr = XActivityBrieIsOpen.GetTimeStr(beginTime, endTime) + + if inTime then + local functionId = XFunctionManager.FunctionName.RpgTower + local isOpen = XFunctionManager.JudgeCanOpen(functionId) + return isOpen, XFunctionManager.GetFunctionOpenCondition(functionId), timeStr + else + return false, openTimeTipsStr, timeStr + end +end + +function XActivityBrieIsOpen.ActivityDrawCard() + local beginTime = XActivityBriefConfigs.GetActivityBeginTime() + local endTime = XActivityBriefConfigs.GetActivityEndTime() + local inTime, timeStr, openTimeTipsStr = XActivityBrieIsOpen.RefreshAcitivityTime(beginTime, endTime, endTime) + local functionId = XFunctionManager.FunctionName.ActivityDrawCard + + if inTime then + local isOpen = XFunctionManager.JudgeCanOpen(functionId) + return isOpen, XFunctionManager.GetFunctionOpenCondition(functionId), timeStr + else + return false, openTimeTipsStr, timeStr + end +end + +function XActivityBrieIsOpen.TRPGMainLine() + if XDataCenter.FubenMainLineManager.IsMainLineActivityOpen() then + local chapterId = XDataCenter.FubenMainLineManager.TRPGChapterId + local ret, desc = XDataCenter.FubenMainLineManager.CheckActivityCondition(chapterId) + return ret, desc + end + + local functionId = XFunctionManager.FunctionName.MainLineTRPG + local isOpen = XFunctionManager.JudgeCanOpen(functionId) + return isOpen, XFunctionManager.GetFunctionOpenCondition(functionId) +end + +function XActivityBrieIsOpen.NewCharActivity(actId) + local functionId = XFunctionManager.FunctionName.NewCharAct + local _, beginTime, endTime = XDataCenter.FubenNewCharActivityManager.IsOpen(actId) + local inTime, timeStr, openTimeTipsStr = XActivityBrieIsOpen.RefreshAcitivityTime(beginTime, endTime, endTime) + + if inTime then + local isOpen = XFunctionManager.JudgeCanOpen(functionId) + return isOpen, XFunctionManager.GetFunctionOpenCondition(functionId), timeStr + else + return false, openTimeTipsStr, timeStr + end +end + +function XActivityBrieIsOpen.FubenActivityTrial() + local functionId = XFunctionManager.FunctionName.FashionStory + --夏活版本涂装试玩关暂时移到FashionStory展示 + local chapters = XDataCenter.FashionStoryManager.GetActivityChapters(true) + local beginTime = math.huge + local endTime = 0 + for _,chapter in pairs(chapters) do + local chapterStartTime, chapterEndTime = XDataCenter.FashionStoryManager.GetActivityTime(chapter.Id) + if beginTime > chapterStartTime then + beginTime = chapterStartTime + end + if endTime < chapterEndTime then + endTime = chapterEndTime + end + end + local inTime, timeStr, openTimeTipsStr = XActivityBrieIsOpen.RefreshAcitivityTime(beginTime, endTime, endTime) + + if inTime then + local isOpen = XFunctionManager.JudgeCanOpen(functionId) + local timeStr = XActivityBrieIsOpen.GetTimeStr(beginTime, endTime) + + return isOpen, XFunctionManager.GetFunctionOpenCondition(functionId), timeStr + else + return false, openTimeTipsStr, timeStr + end +end + +function XActivityBrieIsOpen.ShiTu() + local functionId = XFunctionManager.FunctionName.MentorSystem + local isOpen = XFunctionManager.JudgeCanOpen(functionId) + + return isOpen, XFunctionManager.GetFunctionOpenCondition(functionId), "" +end + +function XActivityBrieIsOpen.Nier() + local beginTime = XDataCenter.NieRManager.GetStartTime() + local endTime = XDataCenter.NieRManager.GetEndTime() + local fightEndTime = endTime + local inTime, timeStr, openTimeTipsStr = XActivityBrieIsOpen.RefreshAcitivityTime(beginTime, fightEndTime, endTime) + + if inTime then + local functionId = XFunctionManager.FunctionName.NieR + local isOpen = XFunctionManager.JudgeCanOpen(functionId) and not XDataCenter.NieRManager.GetIsActivityEnd() + return isOpen, XFunctionManager.GetFunctionOpenCondition(functionId), timeStr + else + return false, openTimeTipsStr, timeStr + end +end + +function XActivityBrieIsOpen.Pokemon() + local beginTime = XDataCenter.PokemonManager.GetStartTime() + local endTime = XDataCenter.PokemonManager.GetEndTime() + local fightEndTime = endTime + local inTime, timeStr, openTimeTipsStr = XActivityBrieIsOpen.RefreshAcitivityTime(beginTime, fightEndTime, endTime) + + if inTime then + local functionId = XFunctionManager.FunctionName.Pokemon + local isOpen = XFunctionManager.JudgeCanOpen(functionId) and XDataCenter.PokemonManager.IsOpen() + return isOpen, XFunctionManager.GetFunctionOpenCondition(functionId), timeStr + else + return false, openTimeTipsStr, timeStr + end +end + +function XActivityBrieIsOpen.Pursuit() + local beginTime = XChessPursuitConfig.GetActivityFullBeginTime() + local endTime = XChessPursuitConfig.GetActivityFullEndTime() + local fightEndTime = endTime + local inTime, timeStr, openTimeTipsStr = XActivityBrieIsOpen.RefreshAcitivityTime(beginTime, fightEndTime, endTime) + + if inTime then + local functionId = XFunctionManager.FunctionName.ChessPursuitMain + local isOpen = XFunctionManager.JudgeCanOpen(functionId) + return isOpen, XFunctionManager.GetFunctionOpenCondition(functionId), timeStr + else + return false, openTimeTipsStr, timeStr + end +end + +function XActivityBrieIsOpen.Simulate() + local beginTime = XDataCenter.FubenSimulatedCombatManager.GetStartTime() + local endTime = XDataCenter.FubenSimulatedCombatManager.GetEndTime() + local fightEndTime = endTime + local inTime, timeStr, openTimeTipsStr = XActivityBrieIsOpen.RefreshAcitivityTime(beginTime, fightEndTime, endTime) + + if inTime then + local functionId = XFunctionManager.FunctionName.FubenSimulatedCombat + local isOpen = XFunctionManager.JudgeCanOpen(functionId) + return isOpen, XFunctionManager.GetFunctionOpenCondition(functionId), timeStr + else + return false, openTimeTipsStr, timeStr + end +end + +function XActivityBrieIsOpen.StrongHold() + local beginTime = XDataCenter.StrongholdManager.GetStartTime() + local endTime = XDataCenter.StrongholdManager.GetEndTime() + local fightEndTime = endTime + local inTime, timeStr, openTimeTipsStr = XActivityBrieIsOpen.RefreshAcitivityTime(beginTime, fightEndTime, endTime) + + if inTime then + local functionId = XFunctionManager.FunctionName.Stronghold + local isOpen = XFunctionManager.JudgeCanOpen(functionId) + return isOpen, XFunctionManager.GetFunctionOpenCondition(functionId), timeStr + else + return false, openTimeTipsStr, timeStr + end +end + +function XActivityBrieIsOpen.Partner() + local functionId = XFunctionManager.FunctionName.Partner + local isOpen = XFunctionManager.JudgeCanOpen(functionId) + + return isOpen, XFunctionManager.GetFunctionOpenCondition(functionId), "" +end + +function XActivityBrieIsOpen.MoeWar() + local beginTime = XDataCenter.MoeWarManager.GetActivityStartTime() + local endTime = XDataCenter.MoeWarManager.GetActivityEndTime() + local fightEndTime = endTime + local inTime, timeStr, openTimeTipsStr = XActivityBrieIsOpen.RefreshAcitivityTime(beginTime, fightEndTime, endTime) + + if inTime then + local functionId = XFunctionManager.FunctionName.MoeWar + local isOpen = XFunctionManager.JudgeCanOpen(functionId) + return isOpen, XFunctionManager.GetFunctionOpenCondition(functionId), timeStr + else + return false, openTimeTipsStr, timeStr + end +end + +function XActivityBrieIsOpen.PetCard() + local functionId = XFunctionManager.FunctionName.Partner + local isOpen = XFunctionManager.JudgeCanOpen(functionId) + local config = XActivityBriefConfigs.GetActivityGroupConfig(XActivityBriefConfigs.ActivityGroupId.PetCard) + local skipId = config.SkipId + local skipConfig = XFunctionConfig.GetSkipList(skipId) + if skipConfig then + local isInTime = XFunctionManager.CheckSkipInDuration(skipId) + if not isInTime then + return isInTime,CSXTextManagerGetText("ActivityBriefNotOpenTips",skipConfig.StartTime) + end + end + return isOpen, XFunctionManager.GetFunctionOpenCondition(functionId), "" +end + +function XActivityBrieIsOpen.PetTrial() + local config = XActivityBriefConfigs.GetActivityGroupConfig(XActivityBriefConfigs.ActivityGroupId.PetTrial) + local skipId = config.SkipId + local skipConfig = XFunctionConfig.GetSkipList(skipId) + if skipConfig then + local timeId = XPartnerTeachingConfigs.GetChapterActivityTimeId(skipConfig.CustomParams[1]) + local beginTime = XFunctionManager.GetStartTimeByTimeId(timeId) + local endTime = XFunctionManager.GetEndTimeByTimeId(timeId) + local fightEndTime = endTime + local inTime, timeStr, openTimeTipsStr = XActivityBrieIsOpen.RefreshAcitivityTime(beginTime, fightEndTime, endTime) + + if inTime then + local functionId = XFunctionManager.FunctionName.PartnerTeaching + local isOpen = XFunctionManager.JudgeCanOpen(functionId) + return isOpen, XFunctionManager.GetFunctionOpenCondition(functionId), timeStr + else + return false, openTimeTipsStr, timeStr + end + end +end + +--翻牌猜大小 +function XActivityBrieIsOpen.PokerGuessing() + local beginTime = XDataCenter.PokerGuessingManager.GetStartTime() + local endTime = XDataCenter.PokerGuessingManager.GetEndTime() + local fightEndTime = endTime + local inTime, timeStr, openTimeTipsStr = XActivityBrieIsOpen.RefreshAcitivityTime(beginTime, fightEndTime, endTime) + + if inTime then + local functionId = XFunctionManager.FunctionName.PokerGuessing + local isOpen = XFunctionManager.JudgeCanOpen(functionId) + return isOpen, XFunctionManager.GetFunctionOpenCondition(functionId), timeStr + else + return false, openTimeTipsStr, timeStr + end +end + +function XActivityBrieIsOpen.Hack() + local beginTime = XDataCenter.FubenHackManager.GetStartTime() + local endTime = XDataCenter.FubenHackManager.GetEndTime() + local fightEndTime = endTime + local inTime, timeStr, openTimeTipsStr = XActivityBrieIsOpen.RefreshAcitivityTime(beginTime, fightEndTime, endTime) + + if inTime then + local functionId = XFunctionManager.FunctionName.FubenHack + local isOpen = XFunctionManager.JudgeCanOpen(functionId) + return isOpen, XFunctionManager.GetFunctionOpenCondition(functionId), timeStr + else + return false, openTimeTipsStr, timeStr + end +end + +function XActivityBrieIsOpen.RpgMaker() + local beginTime,endTime = XDataCenter.RpgMakerGameManager.GetActivityTime() + local fightEndTime = endTime + local inTime, timeStr, openTimeTipsStr = XActivityBrieIsOpen.RefreshAcitivityTime(beginTime, fightEndTime, endTime) + + if inTime then + local functionId = XFunctionManager.FunctionName.RpgMakerActivity + local isOpen = XFunctionManager.JudgeCanOpen(functionId) + return isOpen, XFunctionManager.GetFunctionOpenCondition(functionId), timeStr + else + return false, openTimeTipsStr, timeStr + end +end + +function XActivityBrieIsOpen.Reform() + local beginTime = XDataCenter.ReformActivityManager.GetActivityStartTime() + local endTime = XDataCenter.ReformActivityManager.GetActivityEndTime() + local fightEndTime = endTime + local inTime, timeStr, openTimeTipsStr = XActivityBrieIsOpen.RefreshAcitivityTime(beginTime, fightEndTime, endTime) + + if inTime then + local functionId = XFunctionManager.FunctionName.Reform + local isOpen = XFunctionManager.JudgeCanOpen(functionId) + return isOpen, XFunctionManager.GetFunctionOpenCondition(functionId), timeStr + else + return false, openTimeTipsStr, timeStr + end +end + +function XActivityBrieIsOpen.CoupleCombat() + local beginTime = XDataCenter.FubenCoupleCombatManager.GetStartTime() + local endTime = XDataCenter.FubenCoupleCombatManager.GetEndTime() + local fightEndTime = endTime + local inTime, timeStr, openTimeTipsStr = XActivityBrieIsOpen.RefreshAcitivityTime(beginTime, fightEndTime, endTime) + + if inTime then + local functionId = XFunctionManager.FunctionName.FubenCoupleCombat + local isOpen = XFunctionManager.JudgeCanOpen(functionId) + return isOpen, XFunctionManager.GetFunctionOpenCondition(functionId), timeStr + else + return false, openTimeTipsStr, timeStr + end +end + +function XActivityBrieIsOpen.SuperTower() + local beginTime = XDataCenter.SuperTowerManager.GetActivityStartTime() + local endTime = XDataCenter.SuperTowerManager.GetActivityEndTime() + local fightEndTime = endTime + local inTime, timeStr, openTimeTipsStr = XActivityBrieIsOpen.RefreshAcitivityTime(beginTime, fightEndTime, endTime) + + if inTime then + local functionId = XFunctionManager.FunctionName.SuperTower + local isOpen = XFunctionManager.JudgeCanOpen(functionId) + return isOpen, XFunctionManager.GetFunctionOpenCondition(functionId), timeStr + else + return false, openTimeTipsStr, timeStr + end +end + +function XActivityBrieIsOpen.KillZone() + local beginTime = XDataCenter.KillZoneManager.GetStartTime() + local endTime = XDataCenter.KillZoneManager.GetEndTime() + local fightEndTime = endTime + local inTime, timeStr, openTimeTipsStr = XActivityBrieIsOpen.RefreshAcitivityTime(beginTime, fightEndTime, endTime) + + if inTime then + local functionId = XFunctionManager.FunctionName.KillZone + local isOpen = XFunctionManager.JudgeCanOpen(functionId) + return isOpen, XFunctionManager.GetFunctionOpenCondition(functionId), timeStr + else + return false, openTimeTipsStr, timeStr + end +end + +function XActivityBrieIsOpen.SummerSeries() + local config = XActivityBriefConfigs.GetActivityGroupConfig(XActivityBriefConfigs.ActivityGroupId.SummerSeries) + local skipId = config.SkipId + local skipList = XFunctionConfig.GetSkipList(skipId) + if skipList then + local chapterId = skipList.CustomParams[1] + local chapterConfig = XFestivalActivityConfig.GetFestivalById(chapterId) + local beginTime = XFunctionManager.GetStartTimeByTimeId(chapterConfig.TimeId) + local endTime = XFunctionManager.GetEndTimeByTimeId(chapterConfig.TimeId) + local fightEndTime = endTime + local inTime, timeStr, openTimeTipsStr = XActivityBrieIsOpen.RefreshAcitivityTime(beginTime, fightEndTime, endTime) + + if inTime then + local functionId = XFunctionManager.FunctionName.FestivalActivity + local isOpen = XFunctionManager.JudgeCanOpen(functionId) + return isOpen, XFunctionManager.GetFunctionOpenCondition(functionId), timeStr + else + return false, openTimeTipsStr, timeStr + end + end +end + + + +--@endregion +function XActivityBrieIsOpen.RefreshAcitivityTime(beginTime, fightEndTime, endTime) + local inTime, timeStr, aheadTime = false, "", false + + if not beginTime or not fightEndTime or not endTime then + return inTime, timeStr, aheadTime + end + + local nowTime = XTime.GetServerNowTimestamp() + if nowTime >= beginTime and nowTime < fightEndTime then + inTime = true + aheadTime = false + elseif nowTime >= fightEndTime and nowTime < endTime then + inTime = false + aheadTime = false + elseif nowTime >= endTime then + inTime = false + aheadTime = false + else + inTime = false + aheadTime = true + end + + timeStr = XActivityBrieIsOpen.GetTimeStr(beginTime, fightEndTime) + return inTime, timeStr, XActivityBrieIsOpen.GetOpenTimeTipsStr(aheadTime, beginTime) +end + +function XActivityBrieIsOpen.GetTimeStr(beginTime, endTime) + local beginTimeStr = TimestampToGameDateTimeString(beginTime, TimeFormat) + if endTime then + local endTimeStr = TimestampToGameDateTimeString(endTime, TimeFormat) + return string.format("%s", CSXTextManagerGetText("ActivityBriefFightTime", beginTimeStr, endTimeStr)) + else + return string.format("%s", CSXTextManagerGetText("ActivityBriefAloneTime", beginTimeStr)) + end +end + +function XActivityBrieIsOpen.GetOpenTimeTipsStr(aheadTime, beginTime) + if aheadTime then + local timeStr = XTime.TimestampToGameDateTimeString(beginTime, "yyyy/MM/dd") + return CSXTextManagerGetText("MaintainerActionNotStart", timeStr) + else + return CSXTextManagerGetText("ActivityShopOver") + end +end + +return XActivityBrieIsOpen \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiActivityBrief/XUiActivityBriefBase.lua b/Resources/Scripts/XUi/XUiActivityBrief/XUiActivityBriefBase.lua new file mode 100644 index 00000000..82f72204 --- /dev/null +++ b/Resources/Scripts/XUi/XUiActivityBrief/XUiActivityBriefBase.lua @@ -0,0 +1,203 @@ +--[[ 活动界面的功能相关和各版本的界面临时代码写在这里 + XUiActivityBriefRefreshButton.lua:活动按钮相关的代码(按钮的点击、刷新,红点显示、跳转) + XActivityBrieIsOpen.lua:管理各按钮的开放条件与显示日期的代码 + XActivityBrieButton.lua:按钮的交互逻辑代码 +]] +local XUiActivityBriefBase = XLuaUiManager.Register(XLuaUi, "UiActivityBriefBase") +local OpMovieId = CS.XGame.ClientConfig:GetInt("ActivityBriefMovie") +local CSXTextManagerGetText = CS.XTextManager.GetText +local XUiActivityBriefRefreshButton = require("XUi/XUiActivityBrief/XUiActivityBriefRefreshButton") + +local Vector2 = CS.UnityEngine.Vector2 + +--@region 主要逻辑 +function XUiActivityBriefBase:OnAwake() + self.UiActivityBriefRefreshButton = XUiActivityBriefRefreshButton.New(self) + + self:AutoAddListener() +end + +function XUiActivityBriefBase:OnStart() + self.IsFromMain = true + local firstOpen = XDataCenter.ActivityBriefManager.IsFirstOpen() + if firstOpen and OpMovieId ~= 0 then + self:PlayMovie(function() + XDataCenter.ActivityBriefManager.SetNotFirstOpen() + self:InitModel() + self:PlayAnimationWithMask("AnimEnable2") + --self:PlayEnterSpineAnimation() + end) + else + self:PlayAnimationWithMask("AnimEnable2") + --self:PlayEnterSpineAnimation() + self:InitModel() + end + + self:SpineAutoFit() +end + +function XUiActivityBriefBase:OnEnable() + local firstOpen = XDataCenter.ActivityBriefManager.IsFirstOpen() + if firstOpen then + XDataCenter.ActivityBriefManager.SetNotFirstOpen() + --self:PlayEnterSpineAnimation() + else + if not self.IsFromMain then + self:PlayAnimationWithMask("AnimEnable1") + --self:PlayEnableSpineAnimation() + end + end + self.IsFromMain = false + self.UiActivityBriefRefreshButton:Refresh() +end + +function XUiActivityBriefBase:OnDisable() +end + +function XUiActivityBriefBase:OnDestroy() +end + +--@endregion +--@region 监听事件 +function XUiActivityBriefBase:AutoAddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:RegisterClickEvent(self.BtnVideo, self.OnClickBtnVideo) + self:RegisterClickEvent(self.BtnNotice, self.OnClickBtnDetail) +end + +function XUiActivityBriefBase:OnBtnBackClick() + self:Close() +end + +function XUiActivityBriefBase:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiActivityBriefBase:OnClickBtnDetail() + XLuaUiManager.Open("UiActivityBase") +end + +function XUiActivityBriefBase:OnClickBtnVideo() + --if self.PanelSpine then + -- CS.UnityEngine.GameObject.Destroy(self.PanelSpine:GetComponent("XLoadSpinePrefab")) + --end + --if self.PanelSpine1 then + -- CS.UnityEngine.GameObject.Destroy(self.PanelSpine1:GetComponent("XLoadSpinePrefab")) + --end + self:PlayMovie(function() + self:PlayAnimationWithMask("AnimEnable2") + --self:PlayEnterSpineAnimation() + end) +end +--@endregion +--@region 初始化模型 +function XUiActivityBriefBase:InitModel() + -- if not self.RoleModelPanel then + -- local models = XActivityBriefConfigs.GetActivityModels() + -- if models and #models >= 1 then + -- local root = self.UiModelGo.transform + -- self.PanelModel = root:FindTransform("PanelModel") + -- self.RoleModelPanel = XUiPanelRoleModel.New(self.PanelModel, self.Name, nil, true) + -- self:LoadModel(models[XDataCenter.ActivityBriefManager.GetModelRankIndex()]) + -- end + -- end +end + +function XUiActivityBriefBase:LoadSpine(gameObject, index) + local path = XActivityBriefConfigs.GetSpinePath(index) + if not string.IsNilOrEmpty(path) then + local obj = gameObject:LoadSpinePrefab(path):GetComponent("SkeletonAnimation") + return obj + end +end + +--加载模型 +function XUiActivityBriefBase:LoadModel(modelName) + if not self.RoleModelPanel or modelName == "" then + return + end + + self.RoleModelPanel:UpdateBossModel(modelName, XModelManager.MODEL_UINAME.XUiActivityBriefBase, nil, function(model) + --必须等延迟0.5秒后才执行(等动作执行完,不然Center节点的坐标会是动作执行前的坐标) + XScheduleManager.ScheduleOnce(function() + self:DoAutoRotateWeapon(model) + end, 500) + end, true) + self.PanelModel.gameObject:SetActive(false) + self.PanelModel.gameObject:SetActive(true) +end + +function XUiActivityBriefBase:DoAutoRotateWeapon(model) + local rotate = self.PanelModel:GetComponent("XAutoRotation") + if rotate then + rotate.RotateSelf = false + rotate.Inited = true + rotate.Target = model.transform + rotate:SetCenterPoint(model.transform:Find("Bip001/Center")) + end +end +--@endregion +--@region 通用函数 +function XUiActivityBriefBase:PlayMovie(cbFunc) + --此处不用self:SetActive, 由于self:SetActive会把uiModel的也隐藏导致无法播放下面的动画 + self.GameObject:SetActiveEx(false) + + XDataCenter.VideoManager.PlayMovie(OpMovieId, function() + self.GameObject:SetActiveEx(true) + if cbFunc then + cbFunc() + end + end) +end + +function XUiActivityBriefBase:PlayEnterSpineAnimation() + if XTool.UObjIsNil(self.SpineObject1) then + self.SpineObject1 = self:LoadSpine(self.PanelSpine1, 2) + end + self.SpineObject1.state:SetAnimation(0, "1", false) + self.SpineObject1.state:AddAnimation(0, "2", false, 0) + self.SpineObject1.state:AddAnimation(0, "loop1", true, 0) + --Delegate += 操作Lua写法 + local completeCb + completeCb = function(track) + if track.Animation.Name == "1" then + if XTool.UObjIsNil(self.SpineObject) then + self.SpineObject = self:LoadSpine(self.PanelSpine, 1) + self.SpineObject.state:SetAnimation(0, "loop2", true) + end + self.SpineObject1.state:Complete('-', completeCb) + end + end + self.SpineObject1.state:Complete('+', completeCb) +end + +function XUiActivityBriefBase:PlayEnableSpineAnimation() + if XTool.UObjIsNil(self.SpineObject1) then + self.SpineObject1 = self:LoadSpine(self.PanelSpine1, 2) + end + if XTool.UObjIsNil(self.SpineObject) then + self.SpineObject = self:LoadSpine(self.PanelSpine, 1) + end + self.SpineObject1.state:SetAnimation(0, "loop1", true) + self.SpineObject.state:SetAnimation(0, "loop2", true) +end + +--播放场景预设上的Timeline +function XUiActivityBriefBase:PlayAnimationForScene(animName, cbFunc) + local root = self.UiModelGo.transform + local transform = root:FindTransform(animName) + + if transform then + transform:PlayTimelineAnimation(cbFunc) + end +end +--@endregion +--spine动画底边对齐适配 +function XUiActivityBriefBase:SpineAutoFit() + local transform = self.ActivitySpineLogin + if XTool.UObjIsNil(transform) then return end + + local rate = transform.localScale.y / 60 + transform.anchoredPosition = Vector2(transform.anchoredPosition.x, transform.anchoredPosition.y * rate) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiActivityBrief/XUiActivityBriefRefreshButton.lua b/Resources/Scripts/XUi/XUiActivityBrief/XUiActivityBriefRefreshButton.lua new file mode 100644 index 00000000..c1654792 --- /dev/null +++ b/Resources/Scripts/XUi/XUiActivityBrief/XUiActivityBriefRefreshButton.lua @@ -0,0 +1,882 @@ +--[[ 管理界面的活动按钮相关, + 功能相关和各版本临时代码写在XUiActivityBriefBase.lua(尽量) +]] +local XUiActivityBriefRefreshButton = XClass(nil, "XUiActivityBriefRefreshButton") +local CSXTextManagerGetText = CS.XTextManager.GetText +local XActivityBrieButton = require("XUi/XUiActivityBrief/XActivityBrieButton") + +function XUiActivityBriefRefreshButton:Ctor(rootUi) + self.GameObject = rootUi.GameObject + self.Transform = rootUi.Transform + self.RootUi = rootUi + self.TlActivityBrieButton = {} + + XTool.InitUiObject(self) +end + +--@region 按钮的刷新逻辑 +function XUiActivityBriefRefreshButton:Refresh() + self:RefreshLogo() + self:RefreshActivityMainLine() + self:RefreshActivityBranch() + self:RefreshActivityBossSingle() + self:RefreshActivityBossOnline() + self:RefreshAllActivityPrequel() + self:RefreshActivityBabelTower() + self:RefreshActivityRogueLike() + self:RefreshActivityRepeateChallenge() + self:RefreshActivityArenaOnline() + self:RefreshActivityUnionKill() + self:RefreshActivityShortStories() + self:RefreshActivityLabyrinth() + self:RefreshActivitySociety() + self:RefreshActivityResource() + self:RefreshActivityBigWar() + self:RefreshActivityExtra() + self:RefreshWorldBoss() + self:RefreshExpedition() + self:RefreshFubenBossSingle() + self:RefreshActivityShop() + self:RefreshMaintainerAction() + self:RefreshRpgTower() + self:RefreshDrawActivity() + self:RefreshTRPG() + self:RefreshNewCharActivity() + self:RefreshFubenActivityTrial() + self:RefreshShiTu() + self:RefreshNier() + self:RefreshPokemon() + self:RefreshPursuit() + self:RefreshSimulate() + self:RefreshStrongHold() + self:RefreshPartner() + self:RefreshMoeWar() + self:RefreshPetCard() + self:RefreshPetTrial() + self:RefreshPokerGuessing() + self:RefreshRpgMaker() + self:RefreshHack() + self:RefreshReform() + self:RefreshCoupleCombat() + self:RefreshSuperTower() + self:RefreshKillZone() + self:RefreshSummerSeries() +end + +--@endregion +--@region 活动的各个按钮处理函数 +--Logo节点的 +function XUiActivityBriefRefreshButton:RefreshLogo() + local nowTime = XTime.GetServerNowTimestamp() + local taskBeginTime = XActivityBriefConfigs.GetActivityBeginTime() + local taskEndTime = XActivityBriefConfigs.GetActivityEndTime() + if taskBeginTime > nowTime or nowTime >= taskEndTime then + self.TxtTime.gameObject:SetActiveEx(false) + else + local timeStr = XUiHelper.GetTime(taskEndTime - nowTime, XUiHelper.TimeFormatType.ACTIVITY) + -- local textStr = CSXTextManagerGetText("ActivityBriefLeftTime", timeStr) + self.TxtTime.text = timeStr + self.TxtTime.gameObject:SetActiveEx(true) + end +end + +--- 商店 +function XUiActivityBriefRefreshButton:RefreshActivityShop() + local activityBrieButton = self:GetActivityBrieButton(XActivityBriefConfigs.ActivityGroupId.ActivityBriefShop) + if not activityBrieButton then + return + end + + activityBrieButton:Refresh() + activityBrieButton:SetOnClick(function() + local closeCb = function() + self.RootUi:PlayAnimationWithMask("AnimEnable1") + end + local openCb = function() + self.RootUi:Close() + end + XShopManager.GetShopInfoList(XDataCenter.ActivityBriefManager.GetActivityShopIds(),function() + XLuaUiManager.Open("UiActivityBriefShop", closeCb, openCb) + end) + end) +end + +--- 抽卡 +function XUiActivityBriefRefreshButton:RefreshDrawActivity() + local activityBrieButton = self:GetActivityBrieButton(XActivityBriefConfigs.ActivityGroupId.ActivityDrawCard) + if not activityBrieButton then + return + end + + activityBrieButton:Refresh() + activityBrieButton:SetOnClick(function() + local config = XActivityBriefConfigs.GetActivityGroupConfig(XActivityBriefConfigs.ActivityGroupId.ActivityDrawCard) + local skipId = config.SkipId + + XFunctionManager.SkipInterface(skipId) + end) +end + +---幻痛囚笼 +function XUiActivityBriefRefreshButton:RefreshFubenBossSingle() + local activityBrieButton = self:GetActivityBrieButton(XActivityBriefConfigs.ActivityGroupId.FubenBossSingle) + if not activityBrieButton then + return + end + + activityBrieButton:Refresh() + activityBrieButton:SetOnClick(function() + local config = XActivityBriefConfigs.GetActivityGroupConfig(XActivityBriefConfigs.ActivityGroupId.FubenBossSingle) + local skipId = config.SkipId + + XFunctionManager.SkipInterface(skipId) + end) +end + +--自走棋 +function XUiActivityBriefRefreshButton:RefreshExpedition() + local activityBrieButton = self:GetActivityBrieButton(XActivityBriefConfigs.ActivityGroupId.Expedition) + if not activityBrieButton then + return + end + + local isShowTag = XDataCenter.ExpeditionManager.CheckActivityRedPoint() + + activityBrieButton:Refresh() + activityBrieButton:ShowTag(isShowTag) + activityBrieButton:SetOnClick(function() + local config = XActivityBriefConfigs.GetActivityGroupConfig(XActivityBriefConfigs.ActivityGroupId.Expedition) + local skipId = config.SkipId + + XFunctionManager.SkipInterface(skipId) + end) +end + +--世界Boss +function XUiActivityBriefRefreshButton:RefreshWorldBoss() + local activityBrieButton = self:GetActivityBrieButton(XActivityBriefConfigs.ActivityGroupId.WorldBoss) + if not activityBrieButton then + return + end + + activityBrieButton:Refresh() + activityBrieButton:SetOnClick(function() + local config = XActivityBriefConfigs.GetActivityGroupConfig(XActivityBriefConfigs.ActivityGroupId.WorldBoss) + local skipId = config.SkipId + + XFunctionManager.SkipInterface(skipId) + end) +end + +function XUiActivityBriefRefreshButton:RefreshActivityMainLine() + local activityBrieButton = self:GetActivityBrieButton(XActivityBriefConfigs.ActivityGroupId.MainLine) + if not activityBrieButton then + return + end + local skipConfig = XActivityBriefConfigs.GetActivityGroupConfig(XActivityBriefConfigs.ActivityGroupId.MainLine).SkipId + local skipList = XFunctionConfig.GetSkipList(skipConfig) + local stageId = skipList and skipList.CustomParams[1] + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + activityBrieButton:AddRedPointEvent({XRedPointConditions.Types.CONDITION_MAINLINE_CHAPTER_REWARD},stageInfo.ChapterId) + activityBrieButton:Refresh() + activityBrieButton:SetOnClick(function() + local config = XActivityBriefConfigs.GetActivityGroupConfig(XActivityBriefConfigs.ActivityGroupId.MainLine) + local skipId = config.SkipId + + XFunctionManager.SkipInterface(skipId) + end) +end + +--番外篇,普通或困难 +function XUiActivityBriefRefreshButton:RefreshActivityExtra() + self:RefreshActivityExtraByType(XActivityBriefConfigs.ActivityGroupId.Extra, XDataCenter.FubenManager.DifficultNormal) + self:RefreshActivityExtraByType(XActivityBriefConfigs.ActivityGroupId.Extra2, XDataCenter.FubenManager.DifficultHard) +end + +function XUiActivityBriefRefreshButton:RefreshActivityExtraByType(activityGroupId, difficultType) + local activityBrieButton = self:GetActivityBrieButton(activityGroupId) + if not activityBrieButton then + return + end + + activityBrieButton:Refresh({ + activityGroupId = activityGroupId, + difficultType = difficultType + }) + + activityBrieButton:AddNewTagEvent({ XRedPointConditions.Types.CONDITION_ACTIVITYBRIE_EXTRA }, { + activityGroupId = activityGroupId, + difficultType = difficultType + }) + + local config = XActivityBriefConfigs.GetActivityGroupConfig(activityGroupId) + local skipId = config and config.SkipId + local showRed = false + if skipId then + local skipList = XFunctionConfig.GetSkipList(config.SkipId) + local chapterId = skipList and skipList.CustomParams[1] + showRed = chapterId and XDataCenter.ExtraChapterManager.CheckTreasureReward(chapterId) + end + activityBrieButton:ShowReddot(showRed) + + activityBrieButton:SetOnClick(function() + local config = XActivityBriefConfigs.GetActivityGroupConfig(activityGroupId) + local skipId = config.SkipId + XFunctionManager.SkipInterface(skipId) + end) +end + +--大作战 +function XUiActivityBriefRefreshButton:RefreshActivityBigWar() + local activityBrieButton = self:GetActivityBrieButton(XActivityBriefConfigs.ActivityGroupId.BigWar) + if not activityBrieButton then + return + end + + local isShowTag = XDataCenter.FubenSpecialTrainManager.CheckNotPassStage() + + activityBrieButton:Refresh() + activityBrieButton:ShowTag(isShowTag) + activityBrieButton:AddRedPointEvent({ XRedPointConditions.Types.CONDITION_SPECIALTRAIN_RED }) + activityBrieButton:SetOnClick(function() + local config = XActivityBriefConfigs.GetActivityGroupConfig(XActivityBriefConfigs.ActivityGroupId.BigWar) + local skipId = config.SkipId + + XFunctionManager.SkipInterface(skipId) + end) +end + +--资源 +function XUiActivityBriefRefreshButton:RefreshActivityResource() + local activityBrieButton = self:GetActivityBrieButton(XActivityBriefConfigs.ActivityGroupId.Resource) + if not activityBrieButton then + return + end + + activityBrieButton:Refresh() + activityBrieButton:SetOnClick(function() + local config = XActivityBriefConfigs.GetActivityGroupConfig(XActivityBriefConfigs.ActivityGroupId.Resource) + local skipId = config.SkipId + + XFunctionManager.SkipInterface(skipId) + end) +end + +--公会 +function XUiActivityBriefRefreshButton:RefreshActivitySociety() + local activityBrieButton = self:GetActivityBrieButton(XActivityBriefConfigs.ActivityGroupId.Society) + if not activityBrieButton then + return + end + + activityBrieButton:Refresh() + activityBrieButton:GetButtonCom():SetDisable(true) --因为延期,暂时写死 + + activityBrieButton:SetOnClick(function() + local config = XActivityBriefConfigs.GetActivityGroupConfig(XActivityBriefConfigs.ActivityGroupId.Society) + local skipId = config.SkipId + + XFunctionManager.SkipInterface(skipId) + end) +end + +--迷宫 +function XUiActivityBriefRefreshButton:RefreshActivityLabyrinth() + local activityBrieButton = self:GetActivityBrieButton(XActivityBriefConfigs.ActivityGroupId.Labyrinth) + if not activityBrieButton then + return + end + + activityBrieButton:Refresh() + activityBrieButton:SetOnClick(function() + local config = XActivityBriefConfigs.GetActivityGroupConfig(XActivityBriefConfigs.ActivityGroupId.Labyrinth) + local skipId = config.SkipId + + XFunctionManager.SkipInterface(skipId) + end) +end + +function XUiActivityBriefRefreshButton:RefreshActivityShortStories() + local activityBrieButton = self:GetActivityBrieButton(XActivityBriefConfigs.ActivityGroupId.ShortStories) + if not activityBrieButton then + return + end + + activityBrieButton:Refresh() + activityBrieButton:SetOnClick(function() + XLuaUiManager.Open("UiActivityBriefStory") + end) +end + +function XUiActivityBriefRefreshButton:RefreshActivityBranch() + local activityBrieButton = self:GetActivityBrieButton(XActivityBriefConfigs.ActivityGroupId.Branch) + if not activityBrieButton then + return + end + + activityBrieButton:Refresh() + activityBrieButton:SetOnClick(function() + local config = XActivityBriefConfigs.GetActivityGroupConfig(XActivityBriefConfigs.ActivityGroupId.Branch) + local skipId = config.SkipId + + XFunctionManager.SkipInterface(skipId) + end) +end + +function XUiActivityBriefRefreshButton:RefreshActivityBossSingle() + local activityBrieButton = self:GetActivityBrieButton(XActivityBriefConfigs.ActivityGroupId.BossSingle) + if not activityBrieButton then + return + end + + activityBrieButton:Refresh() + activityBrieButton:AddNewTagEvent({ XRedPointConditions.Types.CONDITION_ACTIVITYBRIE_BOSSSINGLE }) + + activityBrieButton:SetOnClick(function() + local config = XActivityBriefConfigs.GetActivityGroupConfig(XActivityBriefConfigs.ActivityGroupId.BossSingle) + local skipId = config.SkipId + + XFunctionManager.SkipInterface(skipId) + end) +end + +function XUiActivityBriefRefreshButton:RefreshActivityBossOnline() + local activityBrieButton = self:GetActivityBrieButton(XActivityBriefConfigs.ActivityGroupId.BossOnline) + if not activityBrieButton then + return + end + + activityBrieButton:Refresh() + activityBrieButton:SetOnClick(function() + local config = XActivityBriefConfigs.GetActivityGroupConfig(XActivityBriefConfigs.ActivityGroupId.BossOnline) + local skipId = config.SkipId + + XFunctionManager.SkipInterface(skipId) + end) +end + +function XUiActivityBriefRefreshButton:RefreshAllActivityPrequel()--全部间章 + self:RefreshActivityPrequel(XActivityBriefConfigs.ActivityGroupId.Prequel) + self:RefreshActivityPrequel(XActivityBriefConfigs.ActivityGroupId.Prequel2) +end + +function XUiActivityBriefRefreshButton:RefreshActivityPrequel(activityGroupId) + local activityBrieButton = self:GetActivityBrieButton(activityGroupId) + if not activityBrieButton then + return + end + + local config = XActivityBriefConfigs.GetActivityGroupConfig(activityGroupId) + local skipId = config.SkipId + local skipList = XFunctionConfig.GetSkipList(skipId) + local isShowRed = XDataCenter.PrequelManager.CheckRewardAvailable(skipList.CustomParams[2]) + activityBrieButton:Refresh(activityGroupId) + activityBrieButton:ShowReddot(isShowRed) + activityBrieButton:AddNewTagEvent({ XRedPointConditions.Types.CONDITION_ACTIVITYBRIE_PREQUEL }, { + activityGroupId = activityGroupId, + chapterId = skipList.CustomParams[2] + }) + + activityBrieButton:SetOnClick(function() + XFunctionManager.SkipInterface(skipId) + end) +end + +function XUiActivityBriefRefreshButton:RefreshActivityBabelTower() + local activityBrieButton = self:GetActivityBrieButton(XActivityBriefConfigs.ActivityGroupId.BabelTower) + if not activityBrieButton then + return + end + + activityBrieButton:Refresh() + activityBrieButton:AddNewTagEvent({ XRedPointConditions.Types.CONDITION_ACTIVITYBRIE_BABELTOWER }) + activityBrieButton:AddRedPointEvent({ XRedPointConditions.Types.CONDITION_ACTIVITYBRIE_BABELTOWER_REWARD }) + activityBrieButton:SetOnClick(function() + local config = XActivityBriefConfigs.GetActivityGroupConfig(XActivityBriefConfigs.ActivityGroupId.BabelTower) + local skipId = config.SkipId + + XFunctionManager.SkipInterface(skipId) + end) +end + +function XUiActivityBriefRefreshButton:RefreshActivityRogueLike() -- 爬塔 + local activityBrieButton = self:GetActivityBrieButton(XActivityBriefConfigs.ActivityGroupId.RougueLike) + if not activityBrieButton then + return + end + + activityBrieButton:Refresh() + activityBrieButton:AddNewTagEvent({ XRedPointConditions.Types.CONDITION_ACTIVITYBRIE_ROGUELIKEMAIN }) + activityBrieButton:SetOnClick(function() + local config = XActivityBriefConfigs.GetActivityGroupConfig(XActivityBriefConfigs.ActivityGroupId.RougueLike) + local skipId = config.SkipId + + XFunctionManager.SkipInterface(skipId) + end) +end + +function XUiActivityBriefRefreshButton:RefreshActivityRepeateChallenge()--复刷 + local activityBrieButton = self:GetActivityBrieButton(XActivityBriefConfigs.ActivityGroupId.RepeatChallenge) + if not activityBrieButton then + return + end + + activityBrieButton:Refresh() + activityBrieButton:AddRedPointEvent({ XRedPointConditions.Types.CONDITION_REPEAT_CHALLENGE_REWARD }) + activityBrieButton:SetOnClick(function() + local config = XActivityBriefConfigs.GetActivityGroupConfig(XActivityBriefConfigs.ActivityGroupId.RepeatChallenge) + local skipId = config.SkipId + + XFunctionManager.SkipInterface(skipId) + end) +end + +function XUiActivityBriefRefreshButton:RefreshActivityArenaOnline() + local activityBrieButton = self:GetActivityBrieButton(XActivityBriefConfigs.ActivityGroupId.ArenaOnline) + if not activityBrieButton then + return + end + + activityBrieButton:Refresh() + activityBrieButton:SetOnClick(function() + local config = XActivityBriefConfigs.GetActivityGroupConfig(XActivityBriefConfigs.ActivityGroupId.ArenaOnline) + local skipId = config.SkipId + + XFunctionManager.SkipInterface(skipId) + end) +end + +function XUiActivityBriefRefreshButton:RefreshActivityUnionKill() + local activityBrieButton = self:GetActivityBrieButton(XActivityBriefConfigs.ActivityGroupId.UnionKill) + if not activityBrieButton then + return + end + + activityBrieButton:Refresh() + activityBrieButton:SetOnClick(function() + local config = XActivityBriefConfigs.GetActivityGroupConfig(XActivityBriefConfigs.ActivityGroupId.UnionKill) + local skipId = config.SkipId + + XFunctionManager.SkipInterface(skipId) + end) +end + +function XUiActivityBriefRefreshButton:RefreshMaintainerAction() + local activityBrieButton = self:GetActivityBrieButton(XActivityBriefConfigs.ActivityGroupId.MaintainerAction) + if not activityBrieButton then + return + end + + activityBrieButton:Refresh() + activityBrieButton:SetOnClick(function() + local config = XActivityBriefConfigs.GetActivityGroupConfig(XActivityBriefConfigs.ActivityGroupId.MaintainerAction) + local skipId = config.SkipId + + XFunctionManager.SkipInterface(skipId) + end) +end + +function XUiActivityBriefRefreshButton:RefreshRpgTower() + local activityBrieButton = self:GetActivityBrieButton(XActivityBriefConfigs.ActivityGroupId.RpgTower) + if not activityBrieButton then + return + end + + activityBrieButton:Refresh() + activityBrieButton:AddRedPointEvent({ XRedPointConditions.Types.CONDITION_RPGTOWER_TEAM_RED,XRedPointConditions.Types.CONDITION_RPGTOWER_TASK_RED,XRedPointConditions.Types.CONDITION_RPGTOWER_DAILYREWARD_RED }) + local isShowTag = XDataCenter.RpgTowerManager.GetHaveNewStage() + activityBrieButton:ShowTag(isShowTag) + activityBrieButton:SetOnClick(function() + local config = XActivityBriefConfigs.GetActivityGroupConfig(XActivityBriefConfigs.ActivityGroupId.RpgTower) + local skipId = config.SkipId + + XFunctionManager.SkipInterface(skipId) + end) +end + +function XUiActivityBriefRefreshButton:RefreshTRPG() + local activityBrieButton = self:GetActivityBrieButton(XActivityBriefConfigs.ActivityGroupId.TRPGMainLine) + if not activityBrieButton then + return + end + + local curEndurance = XDataCenter.TRPGManager.GetExploreCurEndurance() + local maxEndurance = XDataCenter.TRPGManager.GetExploreMaxEndurance() + local isShowTag = XDataCenter.TRPGManager.IsActivityShowTag() + + self.TxtEndurance.text = CSXTextManagerGetText("TRPGExploreEnduranceForActivity", curEndurance, maxEndurance) + activityBrieButton:Refresh() + activityBrieButton:ShowTag(isShowTag) + activityBrieButton:SetOnClick(function() + local config = XActivityBriefConfigs.GetActivityGroupConfig(XActivityBriefConfigs.ActivityGroupId.TRPGMainLine) + local skipId = config.SkipId + + XFunctionManager.SkipInterface(skipId) + end) +end + +--- 新角色预热 +function XUiActivityBriefRefreshButton:RefreshNewCharActivity() + local activityGroupId = XActivityBriefConfigs.ActivityGroupId.NewCharActivity + local activityBrieButton = self:GetActivityBrieButton(activityGroupId) + if not activityBrieButton then + return + end + + local config = XActivityBriefConfigs.GetActivityGroupConfig(activityGroupId) + local skipList = XFunctionConfig.GetSkipList(config.SkipId) + local actId = skipList.CustomParams[1] + local isShowTag = XDataCenter.FubenNewCharActivityManager.IsChallengeable(actId) + activityBrieButton:Refresh(actId) + activityBrieButton:AddRedPointEvent({XRedPointConditions.Types.CONDITION_KOROMCHARACTIVITYMAINRED}) + activityBrieButton:ShowTag(isShowTag) + activityBrieButton:SetOnClick(function() + XFunctionManager.SkipInterface(config.SkipId) + end) +end + +function XUiActivityBriefRefreshButton:RefreshFubenActivityTrial() + local activityGroupId = XActivityBriefConfigs.ActivityGroupId.FubenActivityTrial + local activityBrieButton = self:GetActivityBrieButton(activityGroupId) + if not activityBrieButton then + return + end + --local isShowTag = XDataCenter.FubenExperimentManager.CheckSkinTrialRedPoint() + + activityBrieButton:Refresh() + activityBrieButton:AddRedPointEvent({ XRedPointConditions.Types.CONDITION_FASHION_STORY_HAVE_STAGE }) + --activityBrieButton:ShowTag(isShowTag) + activityBrieButton:SetOnClick(function() + local config = XActivityBriefConfigs.GetActivityGroupConfig(activityGroupId) + local skipId = config.SkipId + + XFunctionManager.SkipInterface(skipId) + end) +end + +function XUiActivityBriefRefreshButton:RefreshShiTu() + local activityGroupId = XActivityBriefConfigs.ActivityGroupId.ShiTu + local activityBrieButton = self:GetActivityBrieButton(activityGroupId) + if not activityBrieButton then + return + end + + activityBrieButton:Refresh() + activityBrieButton:SetOnClick(function() + local config = XActivityBriefConfigs.GetActivityGroupConfig(activityGroupId) + local skipId = config.SkipId + + XFunctionManager.SkipInterface(skipId) + end) +end + +--尼尔玩法 +function XUiActivityBriefRefreshButton:RefreshNier() + local activityBrieButton = self:GetActivityBrieButton(XActivityBriefConfigs.ActivityGroupId.Nier) + if not activityBrieButton then + return + end + + activityBrieButton:Refresh() + activityBrieButton:AddNewTagEvent({ XRedPointConditions.Types.CONDITION_ACTIVITYBRIE_NIER }) + activityBrieButton:AddRedPointEvent({ XRedPointConditions.Types.CONDITION_NIER_RED }) + activityBrieButton:SetOnClick(function() + local config = XActivityBriefConfigs.GetActivityGroupConfig(XActivityBriefConfigs.ActivityGroupId.Nier) + local skipId = config.SkipId + + XFunctionManager.SkipInterface(skipId) + end) +end + +--口袋战双 +function XUiActivityBriefRefreshButton:RefreshPokemon() + local activityBrieButton = self:GetActivityBrieButton(XActivityBriefConfigs.ActivityGroupId.Pokemon) + if not activityBrieButton then + return + end + + activityBrieButton:Refresh() + local isShowRed = XRedPointConditionPokemonRed.Check() + activityBrieButton:ShowReddot(isShowRed) + activityBrieButton:SetOnClick(function() + local config = XActivityBriefConfigs.GetActivityGroupConfig(XActivityBriefConfigs.ActivityGroupId.Pokemon) + local skipId = config.SkipId + + XFunctionManager.SkipInterface(skipId) + end) +end + +--追击玩法 +function XUiActivityBriefRefreshButton:RefreshPursuit() + local activityBrieButton = self:GetActivityBrieButton(XActivityBriefConfigs.ActivityGroupId.Pursuit) + if not activityBrieButton then + return + end + + activityBrieButton:Refresh() + local isShowRed = XDataCenter.ChessPursuitManager.CheckIsCanFightTips() + activityBrieButton:ShowTag(isShowRed) + activityBrieButton:AddRedPointEvent({ XRedPointConditions.Types.CONDITION_CHESSPURSUIT_REWARD_RED }) + activityBrieButton:SetOnClick(function() + local config = XActivityBriefConfigs.GetActivityGroupConfig(XActivityBriefConfigs.ActivityGroupId.Pursuit) + local skipId = config.SkipId + + XFunctionManager.SkipInterface(skipId) + end) +end + +--模拟战 +function XUiActivityBriefRefreshButton:RefreshSimulate() + local activityBrieButton = self:GetActivityBrieButton(XActivityBriefConfigs.ActivityGroupId.Simulate) + if not activityBrieButton then + return + end + + activityBrieButton:Refresh() + activityBrieButton:AddRedPointEvent({ XRedPointConditions.Types.CONDITION_SIMULATED_COMBAT }) + local isShowTag = XDataCenter.FubenSimulatedCombatManager.IsChallengeable() + activityBrieButton:ShowTag(isShowTag) + activityBrieButton:SetOnClick(function() + local config = XActivityBriefConfigs.GetActivityGroupConfig(XActivityBriefConfigs.ActivityGroupId.Simulate) + local skipId = config.SkipId + + XFunctionManager.SkipInterface(skipId) + end) +end + +--据点 +function XUiActivityBriefRefreshButton:RefreshStrongHold() + local activityBrieButton = self:GetActivityBrieButton(XActivityBriefConfigs.ActivityGroupId.StrongHold) + if not activityBrieButton then + return + end + + activityBrieButton:Refresh() + local isShowRed = XRedPointConditionStrongholdMineralLeft.Check() or XDataCenter.StrongholdManager.IsAnyRewardCanGet() + activityBrieButton:ShowReddot(isShowRed) + local isShowTag = XDataCenter.StrongholdManager.CheckHasUnFinishedCanFightGroup() + activityBrieButton:ShowTag(isShowTag) + activityBrieButton:SetOnClick(function() + local config = XActivityBriefConfigs.GetActivityGroupConfig(XActivityBriefConfigs.ActivityGroupId.StrongHold) + local skipId = config.SkipId + + XFunctionManager.SkipInterface(skipId) + end) +end + +--伙伴系统 +function XUiActivityBriefRefreshButton:RefreshPartner() + local activityBrieButton = self:GetActivityBrieButton(XActivityBriefConfigs.ActivityGroupId.Partner) + if not activityBrieButton then + return + end + activityBrieButton:Refresh() + activityBrieButton:AddRedPointEvent({ XRedPointConditions.Types.CONDITION_PARTNER_COMPOSE_RED,XRedPointConditions.Types.CONDITION_PARTNER_NEWSKILL_RED }) + + activityBrieButton:SetOnClick(function() + local config = XActivityBriefConfigs.GetActivityGroupConfig(XActivityBriefConfigs.ActivityGroupId.Partner) + local skipId = config.SkipId + + XFunctionManager.SkipInterface(skipId) + end) +end +--萌战 +function XUiActivityBriefRefreshButton:RefreshMoeWar() + local activityBrieButton = self:GetActivityBrieButton(XActivityBriefConfigs.ActivityGroupId.MoeWar) + if not activityBrieButton then + return + end + activityBrieButton:AddRedPointEvent({XRedPointConditions.Types.CONDITION_MOEWAR_PREPARATION_REWARD,XRedPointConditions.Types.CONDITION_MOEWAR_TASK}) + activityBrieButton:AddNewTagEvent({ XRedPointConditions.Types.CONDITION_MOEWAR_PREPARATION_OPEN_STAGE }, nil, true) + activityBrieButton:Refresh() + activityBrieButton:SetOnClick(function() + local config = XActivityBriefConfigs.GetActivityGroupConfig(XActivityBriefConfigs.ActivityGroupId.MoeWar) + local skipId = config.SkipId + XFunctionManager.SkipInterface(skipId) + end) +end +--宠物抽卡 +function XUiActivityBriefRefreshButton:RefreshPetCard() + local activityBrieButton = self:GetActivityBrieButton(XActivityBriefConfigs.ActivityGroupId.PetCard) + if not activityBrieButton then + return + end + activityBrieButton:Refresh() + activityBrieButton:SetOnClick(function() + local config = XActivityBriefConfigs.GetActivityGroupConfig(XActivityBriefConfigs.ActivityGroupId.PetCard) + local skipId = config.SkipId + XFunctionManager.SkipInterface(skipId) + end) +end + +--宠物试玩 +function XUiActivityBriefRefreshButton:RefreshPetTrial() + local activityBrieButton = self:GetActivityBrieButton(XActivityBriefConfigs.ActivityGroupId.PetTrial) + if not activityBrieButton then + return + end + activityBrieButton:Refresh() + activityBrieButton:SetOnClick(function() + local config = XActivityBriefConfigs.GetActivityGroupConfig(XActivityBriefConfigs.ActivityGroupId.PetTrial) + local skipId = config.SkipId + XFunctionManager.SkipInterface(skipId) + end) +end + +--翻牌 +function XUiActivityBriefRefreshButton:RefreshPokerGuessing() + local activityBrieButton = self:GetActivityBrieButton(XActivityBriefConfigs.ActivityGroupId.PokerGuessing) + if not activityBrieButton then + return + end + activityBrieButton:Refresh() + activityBrieButton:AddRedPointEvent({ XRedPointConditions.Types.CONDITION_POKER_GUESSING_RED }) + activityBrieButton:SetOnClick(function() + local config = XActivityBriefConfigs.GetActivityGroupConfig(XActivityBriefConfigs.ActivityGroupId.PokerGuessing) + local skipId = config.SkipId + XFunctionManager.SkipInterface(skipId) + end) +end + +--端午活动 +function XUiActivityBriefRefreshButton:RefreshRpgMaker() + local activityBrieButton = self:GetActivityBrieButton(XActivityBriefConfigs.ActivityGroupId.RpgMaker) + if not activityBrieButton then + return + end + activityBrieButton:Refresh() + activityBrieButton:AddRedPointEvent({ XRedPointConditions.Types.CONDITION_RPG_MAKER_GAME_RED }) + activityBrieButton:SetOnClick(function() + local config = XActivityBriefConfigs.GetActivityGroupConfig(XActivityBriefConfigs.ActivityGroupId.RpgMaker) + local skipId = config.SkipId + XFunctionManager.SkipInterface(skipId) + end) +end + +--骇客 +function XUiActivityBriefRefreshButton:RefreshHack() + local activityBrieButton = self:GetActivityBrieButton(XActivityBriefConfigs.ActivityGroupId.Hack) + if not activityBrieButton then + return + end + activityBrieButton:Refresh() + activityBrieButton:AddRedPointEvent({ XRedPointConditions.Types.CONDITION_FUBEN_HACK_STAR }) + local isShowTag = XDataCenter.FubenHackManager.IsChallengeable() + activityBrieButton:ShowTag(isShowTag) + activityBrieButton:SetOnClick(function() + local config = XActivityBriefConfigs.GetActivityGroupConfig(XActivityBriefConfigs.ActivityGroupId.Hack) + local skipId = config.SkipId + XFunctionManager.SkipInterface(skipId) + end) +end + +--改造 +function XUiActivityBriefRefreshButton:RefreshReform() + local activityBrieButton = self:GetActivityBrieButton(XActivityBriefConfigs.ActivityGroupId.Reform) + if not activityBrieButton then + return + end + activityBrieButton:Refresh() + activityBrieButton:AddRedPointEvent({ XRedPointConditions.Types.CONDITION_REFORM_All_RED_POINT }) + activityBrieButton:SetOnClick(function() + local config = XActivityBriefConfigs.GetActivityGroupConfig(XActivityBriefConfigs.ActivityGroupId.Reform) + local skipId = config.SkipId + XFunctionManager.SkipInterface(skipId) + end) +end + +--双人同行 +function XUiActivityBriefRefreshButton:RefreshCoupleCombat() + local activityBrieButton = self:GetActivityBrieButton(XActivityBriefConfigs.ActivityGroupId.CoupleCombat) + if not activityBrieButton then + return + end + activityBrieButton:Refresh() + activityBrieButton:AddRedPointEvent({ XRedPointConditions.Types.CONDITION_COUPLE_COMBAT_NORMAL, XRedPointConditions.Types.CONDITION_COUPLE_COMBAT_HARD }) + local isShowTag = XDataCenter.FubenCoupleCombatManager.IsChallengeable() + activityBrieButton:ShowTag(isShowTag) + activityBrieButton:SetOnClick(function() + local config = XActivityBriefConfigs.GetActivityGroupConfig(XActivityBriefConfigs.ActivityGroupId.CoupleCombat) + local skipId = config.SkipId + XFunctionManager.SkipInterface(skipId) + end) +end + +--超级爬塔 +function XUiActivityBriefRefreshButton:RefreshSuperTower() + local activityBrieButton = self:GetActivityBrieButton(XActivityBriefConfigs.ActivityGroupId.SuperTower) + if not activityBrieButton then + return + end + activityBrieButton:Refresh() + activityBrieButton:AddRedPointEvent({ XRedPointConditions.Types.CONDITION_SUPERTOWER_ROLE_LEVELUP, XRedPointConditions.Types.CONDITION_SUPERTOWER_ROLE_PLUGIN, XRedPointConditions.Types.CONDITION_SUPERTOWER_ROLE_INDULT }) + local gachaNeedItemCount = XSuperTowerConfigs.GetClientBaseConfigByKey("GachaNeedItemCount", true) + local gachaItem = XSuperTowerConfigs.GetClientBaseConfigByKey("GachaItemId", true) + local gachaItemCount = XDataCenter.ItemManager.GetCount(gachaItem) + activityBrieButton:ShowReddot(gachaItemCount >= gachaNeedItemCount) + activityBrieButton:ShowTag(true) + activityBrieButton:SetOnClick(function() + local config = XActivityBriefConfigs.GetActivityGroupConfig(XActivityBriefConfigs.ActivityGroupId.SuperTower) + local skipId = config.SkipId + XFunctionManager.SkipInterface(skipId) + end) +end + +--杀戮无双 +function XUiActivityBriefRefreshButton:RefreshKillZone() + local activityBrieButton = self:GetActivityBrieButton(XActivityBriefConfigs.ActivityGroupId.KillZone) + if not activityBrieButton then + return + end + activityBrieButton:Refresh() + activityBrieButton:AddRedPointEvent({ XRedPointConditions.Types.XRedPointConditionKillZoneActivity }) + activityBrieButton:SetOnClick(function() + local config = XActivityBriefConfigs.GetActivityGroupConfig(XActivityBriefConfigs.ActivityGroupId.KillZone) + local skipId = config.SkipId + XFunctionManager.SkipInterface(skipId) + end) +end + +--夏活系列关 +function XUiActivityBriefRefreshButton:RefreshSummerSeries() + local activityBrieButton = self:GetActivityBrieButton(XActivityBriefConfigs.ActivityGroupId.SummerSeries) + if not activityBrieButton then + return + end + activityBrieButton:Refresh() + local config = XActivityBriefConfigs.GetActivityGroupConfig(XActivityBriefConfigs.ActivityGroupId.SummerSeries) + local skipId = config.SkipId + local skipList = XFunctionConfig.GetSkipList(skipId) + if skipList then + local chapterId = skipList.CustomParams[1] + local passCount,totalCount = XDataCenter.FubenFestivalActivityManager.GetFestivalProgress(chapterId) + activityBrieButton:ShowTag(passCount < totalCount) + end + activityBrieButton:SetOnClick(function() + XFunctionManager.SkipInterface(skipId) + end) +end + +--@endregion +--@region 通用函数 +function XUiActivityBriefRefreshButton:GetActivityBrieButton(activityGroupId) + local btnName = XDataCenter.ActivityBriefManager.GetEntryBtnName(activityGroupId) + if not btnName or btnName == "" then + return + end + + local btn = self[btnName] + if XTool.UObjIsNil(btn) then + return + end + + if self.TlActivityBrieButton[activityGroupId] then + return self.TlActivityBrieButton[activityGroupId] + else + self.TlActivityBrieButton[activityGroupId] = XActivityBrieButton.New(btn, self, activityGroupId) + return self.TlActivityBrieButton[activityGroupId] + end +end + +--@endregion +return XUiActivityBriefRefreshButton \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiActivityBrief/XUiActivityBriefShop.lua b/Resources/Scripts/XUi/XUiActivityBrief/XUiActivityBriefShop.lua new file mode 100644 index 00000000..12028539 --- /dev/null +++ b/Resources/Scripts/XUi/XUiActivityBrief/XUiActivityBriefShop.lua @@ -0,0 +1,265 @@ +local XUiActivityBriefShop = XLuaUiManager.Register(XLuaUi, "UiActivityBriefShop") + +local CSXTextManagerGetText = CS.XTextManager.GetText +local ShopHintText = CS.XTextManager.GetText("ActivityBriefShopLock") +local Dropdown = CS.UnityEngine.UI.Dropdown + +function XUiActivityBriefShop:Init() + self:OnAwake() + self:OnStart() + self:OnEnable() +end + +function XUiActivityBriefShop:OnAwake() + self.GridShop.gameObject:SetActiveEx(false) + self.TxtTime.gameObject:SetActiveEx(false) + self.HintTxt.gameObject:SetActiveEx(false) + self.AssetActivityPanel = XUiPanelActivityAsset.New(self.PanelActivityAsset, true) + self:InitDynamicTable() + self:InitPanels() +end + +function XUiActivityBriefShop:OnStart(closeCb, openCb) + self.CloseCb = closeCb + self.OpenCb = openCb + self.IsCanCheckLock = false + self.ShopIdList = XDataCenter.ActivityBriefManager.GetActivityShopIds() + self.ShopItemTextColor = {} + self.ShopItemTextColor.CanBuyColor = CS.XGame.ClientConfig:GetString("ActivityShopItemTextCanBuyColor") + self.ShopItemTextColor.CanNotBuyColor = CS.XGame.ClientConfig:GetString("ActivityShopItemTextCanNotBuyColor") + + XShopManager.GetShopInfoList(self.ShopIdList, function() + self.IsCanCheckLock = true + self:CheckShopLock() + self:InitShopButton() + self:SetButtonLock() + end) +end + +function XUiActivityBriefShop:OnEnable() + if self.IsCanCheckLock then + self:CheckShopLock() + self:SetButtonLock() + self:RefreshBuy() + end + self.FromEnable = true + self.EffectRefresh.gameObject:SetActiveEx(false) + + self:PlayAnimationWithMask("ShopEnable", function() + if self.OpenCb then self.OpenCb() end + end) +end + +function XUiActivityBriefShop:InitShopButton() + local shopBtns = { + self.BtnTong1, + self.BtnTong2, + self.BtnTong3, + self.BtnTong4, + } + self.CurIndex = 1 + self.ShopBtn = shopBtns + + local btnNum = #self.ShopIdList + for index, shopBtn in pairs(shopBtns) do + shopBtn.gameObject:SetActiveEx(index <= btnNum) + end + + self.FromInit = true + self.BtnTab:Init(shopBtns, function(index) + if not self.FromEnable then + self.EffectRefresh.gameObject:SetActiveEx(false) + else + self.FromEnable = nil + end + + if not self.FromInit and not self.FromEnable then + self.EffectRefresh.gameObject:SetActiveEx(true) + else + self.FromInit = nil + end + + self:SelectShop(index) + end) + self.BtnTab:SelectIndex(self.CurIndex) +end + +function XUiActivityBriefShop:CheckShopLock() + self.IsShopLock = {} + self.ShopLockDecs = {} + for k, v in pairs(self.ShopIdList) do + local conditions = XDataCenter.ActivityBriefManager.GetActivityShopConditionByShopId(v) + self.IsShopLock[k] = false + self.ShopLockDecs[k] = "" + for _, condition in pairs(conditions or {}) do + if condition ~= 0 then + self.IsShopLock[k], self.ShopLockDecs[k] = XConditionManager.CheckCondition(condition) + self.IsShopLock[k] = not self.IsShopLock[k] + if self.IsShopLock[k] then + break + end + end + end + end +end + +function XUiActivityBriefShop:SetButtonLock() + for k, v in pairs(self.ShopBtn or {}) do + v:ShowTag(self.IsShopLock[k]) + end +end + +function XUiActivityBriefShop:InitPanels() + self.ImgEmpty.gameObject:SetActiveEx(true) + self.AssetActivityPanel.GameObject:SetActiveEx(false) + self.BtnBack.CallBack = function() + self:Close() + if self.CloseCb then self.CloseCb() end + end + + self.BtnScreenWords.onValueChanged:AddListener(function() + self:UpdateDynamicTable() + self:PlayAnimation("QieHuan") + end) +end + +function XUiActivityBriefShop:UpdatePanels() + local shopGoods = XDataCenter.ActivityBriefManager.GetActivityShopGoodsByShopIndex(self.CurIndex) + local isEmpty = not next(shopGoods) + self.ImgEmpty.gameObject:SetActiveEx(isEmpty) + self.AssetActivityPanel.GameObject:SetActiveEx(not isEmpty) + + local shopId = self.ShopIdList[self.CurIndex] + local shopTimeInfo = XShopManager.GetShopTimeInfo(shopId) + local leftTime = shopTimeInfo.ClosedLeftTime + if leftTime and leftTime > 0 then + local timeStr = XUiHelper.GetTime(leftTime, XUiHelper.TimeFormatType.ACTIVITY) + self.TxtTime.text = CSXTextManagerGetText("ActivityBriefShopLeftTime", timeStr) + self.TxtTime.gameObject:SetActiveEx(true) + else + self.TxtTime.gameObject:SetActiveEx(false) + end +end + +function XUiActivityBriefShop:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelItemList) + self.DynamicTable:SetProxy(XUiGridShop) + self.DynamicTable:SetDelegate(self) +end + +function XUiActivityBriefShop:UpdateDynamicTable() + local shopGoods + if self:IsShowDropdown() then + shopGoods = XShopManager.GetScreenGoodsListByTag(self:GetCurShopId(), self.ScreenGroupIDList[1], self.BtnScreenWords.captionText.text) + else + shopGoods = XDataCenter.ActivityBriefManager.GetActivityShopGoodsByShopIndex(self.CurIndex) + end + + self.ShopGoods = shopGoods + self.DynamicTable:SetDataSource(shopGoods) + self.DynamicTable:ReloadDataASync() +end + +function XUiActivityBriefShop:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self, self.RootUi) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.ShopGoods[index] + self:SetShopItemLock(grid) + self:SetShopItemBg(grid) + grid:UpdateData(data, self.ShopItemTextColor) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_RECYCLE then + grid:OnRecycle() + end +end + +function XUiActivityBriefShop:InitDropdown() + local shopId = self:GetCurShopId() + self.ScreenGroupIDList = XShopManager.GetShopScreenGroupIDList(shopId) + + if self:IsShowDropdown() then + self.BtnScreenWords.gameObject:SetActiveEx(true) + + local screenTagList = XShopManager.GetScreenTagListById(shopId, self.ScreenGroupIDList[1]) + self.BtnScreenWords:ClearOptions() + self.BtnScreenWords.captionText.text = CSXTextManagerGetText("ScreenAll") + for _, v in pairs(screenTagList or {}) do + local op = Dropdown.OptionData() + op.text = v.Text + self.BtnScreenWords.options:Add(op) + end + self.BtnScreenWords.value = 0 + else + self.BtnScreenWords.gameObject:SetActiveEx(false) + end +end + +function XUiActivityBriefShop:IsShowDropdown() + if self.ScreenGroupIDList and next(self.ScreenGroupIDList) then + return true + else + return false + end +end + +function XUiActivityBriefShop:UpdateBuy(data, cb) + local shopId = XDataCenter.ActivityBriefManager.GetActivityShopIds() + if shopId == nil then + XUiManager.TipText("BriefActivityEndTipText") + XLuaUiManager.RunMain() + return + end + for _, v in pairs(shopId) do + local shopTimeInfo = XShopManager.GetShopTimeInfo(v) + local leftTime = shopTimeInfo.ClosedLeftTime + if leftTime <= 0 then + XUiManager.TipText("BriefActivityEndTipText") + XLuaUiManager.RunMain() + return + end + end + XLuaUiManager.Open("UiShopItem", self, data, cb, "000000ff") + -- self:PlayAnimation("ShopItemEnable") +end + +function XUiActivityBriefShop:GetCurShopId() + return self.ShopIdList[self.CurIndex] +end + +function XUiActivityBriefShop:RefreshBuy() + local shopId = self:GetCurShopId() + self.AssetActivityPanel:Refresh(XShopManager.GetShopShowIdList(shopId)) + self:UpdateDynamicTable() +end + +function XUiActivityBriefShop:SetShopItemBg(grid) + local bg = XDataCenter.ActivityBriefManager.GetActivityShopItemBgByIndex(self.CurIndex) + if grid.ItemBg and bg then + grid.ItemBg:SetRawImage(bg) + end +end + +function XUiActivityBriefShop:SetShopItemLock(grid) + grid.IsShopLock = self.IsShopLock[self.CurIndex] + grid.ShopLockDecs = ShopHintText + if grid.ImgLock then + grid.ImgLock.gameObject:SetActiveEx(self.IsShopLock[self.CurIndex]) + end +end + +function XUiActivityBriefShop:SelectShop(index) + self.CurIndex = index + self:PlayAnimation("QieHuan") + self.HintTxt.gameObject:SetActiveEx(self.IsShopLock[self.CurIndex]) + self.HintTxt.text = self.ShopLockDecs[self.CurIndex] + + -- local bg = XDataCenter.ActivityBriefManager.GetActivityShopBgByIndex(self.CurIndex) + -- self.RImgBg:SetRawImage(bg) + -- local icon = XDataCenter.ActivityBriefManager.GetActivityShopIconByIndex(self.CurIndex) + -- self.RImgShopIcon:SetRawImage(icon) + XShopManager.GetShopInfoList(self.ShopIdList, function() + self:UpdatePanels() + self:RefreshBuy() + self:InitDropdown() + end) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiActivityBrief/XUiActivityBriefStory.lua b/Resources/Scripts/XUi/XUiActivityBrief/XUiActivityBriefStory.lua new file mode 100644 index 00000000..3a3b7a59 --- /dev/null +++ b/Resources/Scripts/XUi/XUiActivityBrief/XUiActivityBriefStory.lua @@ -0,0 +1,65 @@ +local XUiActivityBriefStory = XLuaUiManager.Register(XLuaUi, "UiActivityBriefStory") + +local tableInsert = table.insert +local tableSort = table.sort + +function XUiActivityBriefStory:OnAwake() + self.DynamicTableAudios = XDynamicTableNormal.New(self.PanelList.gameObject) + self.DynamicTableAudios:SetProxy(XUiPanelStory) + self.DynamicTableAudios:SetDelegate(self) + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self.BtnBack.CallBack = function() + XEventManager.DispatchEvent(XEventId.EVENT_STORY_DISTORY) + self:Close() + end + self.BtnMainUi.CallBack = function() + XEventManager.DispatchEvent(XEventId.EVENT_STORY_DISTORY) + XLuaUiManager.RunMain() + end +end + +function XUiActivityBriefStory:OnStart() + self.Config = XDataCenter.ActivityBriefManager.GetActivityStoryConfig() + self.RankedConfig = {} + self.NotOpenConfig = {} + local isUnlock + local desc = "" + for i = 1, #self.Config do + isUnlock,desc = XConditionManager.CheckCondition(self.Config[i].ConditionId) + if isUnlock then + tableInsert(self.RankedConfig,self.Config[i]) + else + tableInsert(self.NotOpenConfig,self.Config[i]) + end + end + table.sort(self.RankedConfig, function(a, b) + return a.Priority < b.Priority + end) + table.sort(self.NotOpenConfig, function(a, b) + return a.Priority < b.Priority + end) + for i = 1, #self.NotOpenConfig do + tableInsert(self.RankedConfig,self.NotOpenConfig[i]) + end + self:RefreshIllustratedHandBook() +end + +function XUiActivityBriefStory:RefreshIllustratedHandBook() + if self.DynamicTableAudios then + self.DynamicTableAudios:SetDataSource(self.RankedConfig) + self.DynamicTableAudios:ReloadDataASync() + end + +end + +function XUiActivityBriefStory:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.RankedConfig[index] + if data ~= nil then + grid:OnRefreshDatas(data) + end + end +end + diff --git a/Resources/Scripts/XUi/XUiActivityBrief/XUiActivityBriefTask.lua b/Resources/Scripts/XUi/XUiActivityBrief/XUiActivityBriefTask.lua new file mode 100644 index 00000000..774d5b84 --- /dev/null +++ b/Resources/Scripts/XUi/XUiActivityBrief/XUiActivityBriefTask.lua @@ -0,0 +1,118 @@ +local XUiActivityBriefTask = XLuaUiManager.Register(XLuaUi, "UiActivityBriefTask") + +local CSXTextManagerGetText = CS.XTextManager.GetText + +function XUiActivityBriefTask:OnAwake() + self.GridTask.gameObject:SetActiveEx(false) + self.BtnBack.CallBack = function() + self:Close() + if self.CloseCb then self.CloseCb() end + end + self.BtnActDesc.CallBack = function() + self:OnBtnActDescClick() + end + self:InitDynamicTable() +end + +function XUiActivityBriefTask:OnStart(closeCb, base) + self.CloseCb = closeCb + self.Base = base + self:InitLeftTime() + self:InitActivityPointIcon() + self:SetTaskBg() +end + +function XUiActivityBriefTask:OnEnable() + if self.Base then + self.Base.BasePane.gameObject:SetActiveEx(false) + end + self:UpdateDynamicTable() + self:UpdateActivityPointCount() +end + +function XUiActivityBriefTask:OnGetEvents() + return { XEventId.EVENT_FINISH_TASK } +end + +function XUiActivityBriefTask:OnNotify(evt) + if evt == XEventId.EVENT_FINISH_TASK then + self:UpdateDynamicTable() + end +end + +function XUiActivityBriefTask:InitLeftTime() + if not XDataCenter.ActivityBriefManager.IsActivityTaskInTime() then + self.TxtTime.gameObject:SetActiveEx(false) + else + local nowTime = XTime.GetServerNowTimestamp() + local _, taskEndTime = XDataCenter.ActivityBriefManager.GetActivityTaskTime() + local timeStr = XUiHelper.GetTime(taskEndTime - nowTime, XUiHelper.TimeFormatType.ACTIVITY) + self.TxtTime.text = CSXTextManagerGetText("ActivityBriefTaskLeftTime", timeStr) + self.TxtTime.gameObject:SetActiveEx(true) + end +end + +function XUiActivityBriefTask:InitActivityPointIcon() + local pointId = XDataCenter.ActivityBriefManager.GetActivityActivityPointId() + local point = XUiGridCommon.New(self, self.UseItemGrid) + point:Refresh(pointId) +end + +function XUiActivityBriefTask:SetTaskBg() + self.TaskBg = XDataCenter.ActivityBriefManager.GetActivityTaskBg() + self.TaskVipBg = XDataCenter.ActivityBriefManager.GetActivityTaskVipBg() + self.TaskGotBg = XDataCenter.ActivityBriefManager.GetActivityTaskGotBg() + self.TaskVipGotBg = XDataCenter.ActivityBriefManager.GetActivityTaskVipGotBg() +end + +function XUiActivityBriefTask:UpdateActivityPointCount() + local pointId = XDataCenter.ActivityBriefManager.GetActivityActivityPointId() + self.TxtNumber.text = XDataCenter.ItemManager.GetCount(pointId) +end + +function XUiActivityBriefTask:OnBtnActDescClick() + XUiManager.UiFubenDialogTip(CSXTextManagerGetText("ActivityBriefTaskMissionInfo"), CSXTextManagerGetText("ActivityBriefTaskDesc") or "") +end + +function XUiActivityBriefTask:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelTaskStoryList) + self.DynamicTable:SetProxy(XDynamicActivityTask) + self.DynamicTable:SetDelegate(self) +end + +function XUiActivityBriefTask:UpdateDynamicTable() + local taskDatas = XDataCenter.ActivityBriefManager.GetActivityTaskDatas() + local pointId = XDataCenter.ActivityBriefManager.GetActivityActivityPointId() + if not next(taskDatas) then + XUiManager.TipText("ActivityBriefNoTask") + return + end + self.TaskDatas = {} + + for _, data in pairs(taskDatas) do + local tmpData = {} + for k, v in pairs(data) do + tmpData[k] = v + if k == "Id" then + if XDataCenter.ActivityBriefManager.CheckTaskIsInMark(v) then + tmpData["IsMark"] = true + else + tmpData["IsMark"] = false + end + end + end + tmpData["PointId"] = pointId + table.insert(self.TaskDatas, tmpData) + end + self.DynamicTable:SetDataSource(self.TaskDatas) + self.DynamicTable:ReloadDataASync() +end + +function XUiActivityBriefTask:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid.RootUi = self + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.TaskDatas[index] + grid:ResetData(data, self) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiActivityBrief/XUiPanelStory.lua b/Resources/Scripts/XUi/XUiActivityBrief/XUiPanelStory.lua new file mode 100644 index 00000000..a35b0a85 --- /dev/null +++ b/Resources/Scripts/XUi/XUiActivityBrief/XUiPanelStory.lua @@ -0,0 +1,66 @@ +XUiPanelStory = XClass(nil, "XUiPanelStory") + + +function XUiPanelStory:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.BtnStory01.CallBack = function() self:OnBtnStoryClick() end + +end + +function XUiPanelStory:Init(rootUi) + self.RootUi = rootUi +end + +function XUiPanelStory:OnRefreshDatas(configInfo) + self.ConfigInfo = configInfo + self:UpdateBtnImageAndText() +end + +function XUiPanelStory:UpdateBtnImageAndText() + XRedPointManager.AddRedPointEvent(self.BtnStory01, self.OnCheckStoryRedPoint, self, { XRedPointConditions.Types.CONDITION_ACTIVITY_NEW_ILLUSTRATEDHANDBOOK },self.ConfigInfo) + self.ImagePre:SetRawImage(self.ConfigInfo.BgImage) + local isUnlock + local desc = "" + isUnlock,desc = XConditionManager.CheckCondition(self.ConfigInfo.ConditionId) + if isUnlock then + self.BtnStory01:SetButtonState(CS.UiButtonState.Normal) + self.ImageNor:SetRawImage(self.ConfigInfo.BgImage) + else + self.BtnStory01:SetButtonState(CS.UiButtonState.Disable) + self.ImageDis:SetRawImage(self.ConfigInfo.UnlockBgImage) + local con = XConditionManager.GetConditionDescById(self.ConfigInfo.ConditionId) + self.Text.text = con + end +end + + + +function XUiPanelStory:OnBtnStoryClick() + local isUnlock + local desc = "" + isUnlock,desc = XConditionManager.CheckCondition(self.ConfigInfo.ConditionId) + if isUnlock then + self.BtnStory01:ShowReddot(false) + XDataCenter.MovieManager.PlayMovie(self.ConfigInfo.StoryId) + XDataCenter.ActivityBriefManager.QueryStatistics(self.ConfigInfo.Id) + else + local con = XConditionManager.GetConditionDescById(self.ConfigInfo.ConditionId) + XUiManager.TipMsg(con) + end +end + +function XUiPanelStory:OnCheckStoryRedPoint(count) + self.BtnStory01:ShowReddot(count >= 0) +end + + + + + + + + + + diff --git a/Resources/Scripts/XUi/XUiArchive/XUiArchiveAwareness.lua b/Resources/Scripts/XUi/XUiArchive/XUiArchiveAwareness.lua new file mode 100644 index 00000000..c0172638 --- /dev/null +++ b/Resources/Scripts/XUi/XUiArchive/XUiArchiveAwareness.lua @@ -0,0 +1,313 @@ +-- +-- Author: wujie +-- Note: 图鉴意识一级界面 +local XUiArchiveAwareness = XLuaUiManager.Register(XLuaUi, "UiArchiveAwareness") + +local XUiGridArchiveAwareness = require("XUi/XUiArchive/XUiGridArchiveAwareness") +local Object = CS.UnityEngine.Object +local DrdSortIndexToType = { + XArchiveConfigs.EquipStarType.All, + XArchiveConfigs.EquipStarType.Two, + XArchiveConfigs.EquipStarType.Three, + XArchiveConfigs.EquipStarType.Four, + XArchiveConfigs.EquipStarType.Five, + XArchiveConfigs.EquipStarType.Six, +} + +local StarTypeToStarNum = function(type) + if type == XArchiveConfigs.EquipStarType.All then XLog.Error("StarType.All cannot be passed in") end + return type +end + +function XUiArchiveAwareness:OnAwake() + XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + + self.IsHaveCallOnEnable = false + self:InitTabBtnGroup() + self:InitDrdSort() + self:InitDynamicTable() + self:AutoAddListener() + + self.EventIdAwarenessRedPoint = XRedPointManager.AddRedPointEvent( + self.TabBtnGroup, + self.OnCheckAwarenessRedPoint, + self, + { XRedPointConditions.Types.CONDITION_ARCHIVE_AWARENESS_NEW_TAG, XRedPointConditions.Types.CONDITION_ARCHIVE_AWARENESS_SETTING_RED }, + nil, + false + ) +end + +function XUiArchiveAwareness:OnStart() + self.IsStarAscendOrder = false + self.SecondHierarchyFilterSelectIndex = self.DrdSort.value + 1 + self.AwarenessDataDic = XArchiveConfigs.GetAwarenessTypeToGroupDatasDic() + + XRedPointManager.Check(self.EventIdAwarenessRedPoint) + self:UpdateOrderStatus(self.IsStarAscendOrder) + local btnCount = #self.GroupTypeList + if btnCount > 0 then + self.TabBtnGroup:SelectIndex(1) + end +end + +function XUiArchiveAwareness:OnEnable() + if self.IsHaveCallOnEnable then + self.DynamicTable:ReloadDataASync() + return + end + self.IsHaveCallOnEnable = true +end + +function XUiArchiveAwareness:OnDestroy() + XDataCenter.ArchiveManager.HandleCanUnlockAwarenessSuit() + XDataCenter.ArchiveManager.HandleCanUnlockAwarenessSetting() +end + +function XUiArchiveAwareness:InitTabBtnGroup() + self.GroupTypeList = XArchiveConfigs.GetAwarenessGroupTypes() + self.BtnTypeList = {} + self.TabBtnTypeDic = {} + self.BtnAwareness.gameObject:SetActiveEx(false) + for index, v in pairs(self.GroupTypeList) do + local btn = Object.Instantiate(self.BtnAwareness) + btn.gameObject:SetActive(true) + btn.transform:SetParent(self.TabBtnGroup.transform, false) + local btncs = btn:GetComponent("XUiButton") + local name = v.GroupName + btncs:SetName(name or "Null") + table.insert(self.BtnTypeList, btncs) + self.TabBtnTypeDic[v.GroupId] = btncs + end + + self.TabBtnGroup:Init(self.BtnTypeList, handler(self, self.OnTabBtnGroupClick)) +end + +function XUiArchiveAwareness:InitDrdSort() + local StarToQualityName = XArchiveConfigs.StarToQualityName + self.DrdSort:ClearOptions() + local firstOptionType = DrdSortIndexToType[1] + self.DrdSort.captionText.text = StarToQualityName[firstOptionType] + local CsDropdown = CS.UnityEngine.UI.Dropdown + for _, starType in ipairs(DrdSortIndexToType) do + local op = CsDropdown.OptionData() + op.text = StarToQualityName[starType] + self.DrdSort.options:Add(op) + end +end + +function XUiArchiveAwareness:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelDynamicTable) + self.DynamicTable:SetProxy(XUiGridArchiveAwareness) + self.DynamicTable:SetDelegate(self) +end + +function XUiArchiveAwareness:AutoAddListener() + self.BtnBack.CallBack = function() self:Close() end + self.BtnMainUi.CallBack = function() XLuaUiManager.RunMain() end + self.DrdSort.onValueChanged:AddListener(function() + local CSArrayIndexToLuaTableIndex = function(index) return index + 1 end + self:OnDrdSortClick(CSArrayIndexToLuaTableIndex(self.DrdSort.value)) + end) + self.BtnOrder.CallBack = function() self:OnBtnOrderClick() end +end + +-- function XUiArchiveAwareness:OnPlayAnimation() +-- -- self:PlayAnimation("AnimStartEnable") +-- end +-- 第一层判断 +function XUiArchiveAwareness:FirstHierarchyFilter(originDataList, filterType) + return originDataList[filterType] or {} +end + +-- 第二层判断 +function XUiArchiveAwareness:SecondHierarchyFilter(firstHierarchyFilterDataList, filterType) + local dataList = {} + if filterType == XArchiveConfigs.EquipStarType.All then + return firstHierarchyFilterDataList + else + local filterStar = StarTypeToStarNum(filterType) + for _, data in ipairs(firstHierarchyFilterDataList) do + if XDataCenter.EquipManager.GetSuitStar(data.Id) == filterStar then + table.insert(dataList, data) + end + end + end + return dataList +end + +-- 按星级高低顺序来排序,默认降序(可变为升序),在此之下默认TemplateId排序 +function XUiArchiveAwareness:SortEquipDataList(dataList, isAscendOrder) + if not dataList then return end + -- 需要调整 + if isAscendOrder then + table.sort(dataList, function(aData, bData) + local aId = aData.Id + local bId = bData.Id + + local aStar = XDataCenter.EquipManager.GetSuitStar(aId) + local bStar = XDataCenter.EquipManager.GetSuitStar(bId) + + if aStar == bStar then + return aId < bId + else + return aStar < bStar + end + end) + else + table.sort(dataList, function(aData, bData) + local aId = aData.Id + local bId = bData.Id + + local aStar = XDataCenter.EquipManager.GetSuitStar(aId) + local bStar = XDataCenter.EquipManager.GetSuitStar(bId) + + + if aStar == bStar then + return aId > bId + else + return aStar > bStar + end + end) + end +end + +function XUiArchiveAwareness:ResetDrdSort() + local selectIndex = 1 + for index, filterType in ipairs(DrdSortIndexToType) do + if filterType == XArchiveConfigs.EquipStarType.All then + selectIndex = index + break + end + end + self.DrdSort.value = selectIndex - 1 +end + +--排序按钮状态 +function XUiArchiveAwareness:UpdateOrderStatus(isAscendOrder) + self.ImgAscend.gameObject:SetActiveEx(isAscendOrder) + self.ImgDescend.gameObject:SetActiveEx(not isAscendOrder) +end + +--设置动态列表 +function XUiArchiveAwareness:UpdateDynamicTable() + self:PlayAnimation("QieHuan") + self.DynamicTableDataList = self.DynamicTableDataList or {} + local isEmpty = #self.DynamicTableDataList == 0 + self.DynamicTable:SetDataSource(self.DynamicTableDataList) + self.DynamicTable:ReloadDataASync(isEmpty and -1 or 1) + self.PanelEmpty.gameObject:SetActiveEx(isEmpty) +end + +function XUiArchiveAwareness:UpdateCollection() + self.TxtCollectionDesc.text = self.GroupTypeList[self.FirstHierarchyFilterSelectIndex] and + self.GroupTypeList[self.FirstHierarchyFilterSelectIndex].GroupName or "" + + local sumNum = 0 + local collectionNum = 0 + local suitId + local awarenessIdList + local isGetFunc = XDataCenter.ArchiveManager.IsAwarenessGet + for _, groupData in ipairs(self.FirstHierarchyFilterDataList) do + suitId = groupData.Id + awarenessIdList = XEquipConfig.GetEquipTemplateIdsBySuitId(suitId) + sumNum = sumNum + #awarenessIdList + for _, templateId in ipairs(awarenessIdList) do + if isGetFunc(templateId) then + collectionNum = collectionNum + 1 + end + end + end + + if sumNum == 0 then + self.TxtCollectionRate.text = 0 + return + end + + local percentNum = math.floor(collectionNum * 100 / sumNum) + self.TxtCollectionRate.text = percentNum +end + +-----------------------------------事件相关----------------------------------------->>> +function XUiArchiveAwareness:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:InitRootUi(self) + grid:SetClickCallback(handler(self, self.OnGridClick)) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:Refresh(self.DynamicTableDataList, index) + end +end + +function XUiArchiveAwareness:OnGridClick(suitIdList,index) + XLuaUiManager.Open("UiArchiveAwarenessDetail", suitIdList,index) +end + +-- 需注意,index不一定就是type,需要结合业务具体考虑 +function XUiArchiveAwareness:OnTabBtnGroupClick(index) + if self.FirstHierarchyFilterSelectIndex == index then return end + + if self.FirstHierarchyFilterSelectIndex then + local oldFilterType = self.GroupTypeList[self.FirstHierarchyFilterSelectIndex] and + self.GroupTypeList[self.FirstHierarchyFilterSelectIndex].GroupId or 0 + if oldFilterType ~= 0 then + XDataCenter.ArchiveManager.HandleCanUnlockAwarenessSuitByGetType(oldFilterType) + XDataCenter.ArchiveManager.HandleCanUnlockAwarenessSettingByGetType(oldFilterType) + end + end + + local filterType = self.GroupTypeList[index] and self.GroupTypeList[index].GroupId or 0 + if filterType ~= 0 then + self.DynamicTableDataList = self:FirstHierarchyFilter(self.AwarenessDataDic, filterType) + self.FirstHierarchyFilterDataList = self.DynamicTableDataList + self.FirstHierarchyFilterSelectIndex = index + + self:UpdateCollection() + + if DrdSortIndexToType[self.SecondHierarchyFilterSelectIndex] == XArchiveConfigs.EquipStarType.All then + self:SortEquipDataList(self.DynamicTableDataList, self.IsStarAscendOrder) + self:UpdateDynamicTable() + else + self:ResetDrdSort() + end + end +end + +function XUiArchiveAwareness:OnDrdSortClick(index) + if self.SecondHierarchyFilterSelectIndex == index then return end + + if self.FirstHierarchyFilterDataList then + self.DynamicTableDataList = self:SecondHierarchyFilter(self.FirstHierarchyFilterDataList, DrdSortIndexToType[index]) + end + self.SecondHierarchyFilterSelectIndex = index + + self:SortEquipDataList(self.DynamicTableDataList, self.IsStarAscendOrder) + self:UpdateDynamicTable() +end + +function XUiArchiveAwareness:OnBtnOrderClick() + self.IsStarAscendOrder = not self.IsStarAscendOrder + self:UpdateOrderStatus(self.IsStarAscendOrder) + self:SortEquipDataList(self.DynamicTableDataList, self.IsStarAscendOrder) + self:UpdateDynamicTable() +end + +-- 有new标签时显示new标签,如果只有红点显示红点,红点和new标签同时存在则只显示new标签 +function XUiArchiveAwareness:OnCheckAwarenessRedPoint() + local btn + local isShowTag + for type, _ in pairs(self.AwarenessDataDic) do + btn = self.TabBtnTypeDic[type] + if btn then + isShowTag = XDataCenter.ArchiveManager.IsHaveNewAwarenessSuitByGetType(type) + if isShowTag then + btn:ShowTag(true) + btn:ShowReddot(false) + else + btn:ShowTag(false) + btn:ShowReddot(XDataCenter.ArchiveManager.IsHaveNewAwarenessSettingByGetType(type)) + end + end + end +end + +-----------------------------------事件相关-----------------------------------------<<< \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArchive/XUiArchiveAwarenessDetail.lua b/Resources/Scripts/XUi/XUiArchive/XUiArchiveAwarenessDetail.lua new file mode 100644 index 00000000..a3e15f25 --- /dev/null +++ b/Resources/Scripts/XUi/XUiArchive/XUiArchiveAwarenessDetail.lua @@ -0,0 +1,336 @@ + +-- +-- Author: wujie +-- Note: 图鉴武器详情界面 + +local XUiArchiveAwarenessDetail = XLuaUiManager.Register(XLuaUi, "UiArchiveAwarenessDetail") + +local XUiGridArchiveAwarenessDetail = require("XUi/XUiArchive/XUiGridArchiveAwarenessDetail") +local XUiGridArchiveEquipSetting = require("XUi/XUiArchive/XUiGridArchiveEquipSetting") + +local FirstIndex = 1 + +function XUiArchiveAwarenessDetail:OnAwake() + XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + + self.IsSettingOpen = false + self:InitGridSites() + self.TxtSkillDescList = { + self.TxtSkillDes1, + self.TxtSkillDes2, + self.TxtSkillDes3, + } + + self.GridSettingList = { + XUiGridArchiveEquipSetting.New(self.GridSetting1), + XUiGridArchiveEquipSetting.New(self.GridSetting2), + } + + self.GridStoryList = { + XUiGridArchiveEquipSetting.New(self.GridStory1), + XUiGridArchiveEquipSetting.New(self.GridStory2), + XUiGridArchiveEquipSetting.New(self.GridStory3), + XUiGridArchiveEquipSetting.New(self.GridStory4), + XUiGridArchiveEquipSetting.New(self.GridStory5), + } + + self:AutoAddListener() +end + +function XUiArchiveAwarenessDetail:OnStart(suitIdList,index) + self:InitScene3DRoot() + self:Init(suitIdList,index) +end + +function XUiArchiveAwarenessDetail:Init(suitIdList,index) + local suitId = suitIdList and suitIdList[index] + if not suitId then + return + end + self.SuitId = suitId + self.SuitIdList = suitIdList + self.SuitIdIndex = index + + self:UpdateSpecialIcon() + self:UpdateSites() + self:UpdateSetting() + self:CheckNextMonsterAndPreMonster() + + self.SelectSiteIndex = nil + for _,grid in pairs(self.GridSiteList or {}) do + grid:ShowSelect(false) + end + + if #self.TemplateIdList > 1 then + local firstSiteIndex = 1 + self:OnBtnGroupClick(firstSiteIndex) + end +end + +function XUiArchiveAwarenessDetail:OnDestroy() + self.Scene3DRoot.PanelWeaponPlane.gameObject:SetActiveEx(true) +end + +function XUiArchiveAwarenessDetail:AutoAddListener() + self.BtnBack.CallBack = function() self:Close() end + self.BtnMainUi.CallBack = function() XLuaUiManager.RunMain() end + self.BtnNext.CallBack = function() + self:OnBtnNextClick() + end + self.BtnLast.CallBack = function() + self:OnBtnLastClick() + end +end + +function XUiArchiveAwarenessDetail:InitGridSites() + self.GridSiteList = { + XUiGridArchiveAwarenessDetail.New(self.GridSite1), + XUiGridArchiveAwarenessDetail.New(self.GridSite2), + XUiGridArchiveAwarenessDetail.New(self.GridSite3), + XUiGridArchiveAwarenessDetail.New(self.GridSite4), + XUiGridArchiveAwarenessDetail.New(self.GridSite5), + XUiGridArchiveAwarenessDetail.New(self.GridSite6), + } + for i, grid in ipairs(self.GridSiteList) do + grid:SetClickCallback(function() self:OnBtnGroupClick(i) end) + end +end + +function XUiArchiveAwarenessDetail:InitScene3DRoot() + if self.Scene3DRoot then return end + self.Scene3DRoot = {} + local root = self.Scene3DRoot + local sceneRoot = self.UiSceneInfo.Transform + root.Transform = sceneRoot + root.PanelWeapon = self.UiModelGo:FindTransform("PanelWeapon"):GetComponent(typeof(CS.XAutoRotation)) + root.PanelWeaponPlane = sceneRoot:FindTransform("Plane") + root.PanelWeaponPlane.gameObject:SetActiveEx(false) +end + +function XUiArchiveAwarenessDetail:UpdateSpecialIcon() + local iconPath = XArchiveConfigs.GetAwarenessSuitInfoIconPath(self.SuitId) + if iconPath then + self.ImgSpecialIcon.gameObject:SetActiveEx(true) + self:SetUiSprite(self.ImgSpecialIcon, iconPath) + else + self.ImgSpecialIcon.gameObject:SetActiveEx(false) + end +end + +function XUiArchiveAwarenessDetail:UpdateSites() + local templateIdList = XEquipConfig.GetEquipTemplateIdsBySuitId(self.SuitId) + table.sort(templateIdList, function(aId, bId) + local aSite = XDataCenter.EquipManager.GetEquipSiteByTemplateId(aId) + local bSite = XDataCenter.EquipManager.GetEquipSiteByTemplateId(bId) + return aSite < bSite + end) + + self.TemplateIdList = templateIdList + local siteCount = #templateIdList + local templateId + local site + local isGet + for i, grid in ipairs(self.GridSiteList) do + if i > siteCount then + grid.GameObject:SetActiveEx(false) + else + grid.GameObject:SetActiveEx(true) + + templateId = templateIdList[i] + site = XDataCenter.EquipManager.GetEquipSiteByTemplateId(templateId) + isGet = XDataCenter.ArchiveManager.IsAwarenessGet(templateId) + grid:SetName(XEquipConfig.AwarenessSiteToStr[site]) + grid:SetGet(isGet) + end + end +end + +function XUiArchiveAwarenessDetail:UpdateAwareness() + local imgPath = XDataCenter.EquipManager.GetEquipLiHuiPath(self.SelectedTemplateId, 0) + if imgPath then + self.RImgAwareness:SetRawImage(imgPath) + self.PlayableDirectorLoop:Stop() + self:PlayAnimation("LihuiEnable", function() self.PlayableDirectorLoop:Play() end) + end + + local site = XDataCenter.EquipManager.GetEquipSiteByTemplateId(self.SelectedTemplateId) + self:SetUiSprite(self.ImgSiteBg, XArchiveConfigs.SiteToBgPath[site]) +end + +function XUiArchiveAwarenessDetail:UpdateResume() + local templateId = self.SelectedTemplateId + local awarenessName = XDataCenter.EquipManager.GetEquipName(templateId) + self.TxtAwarenessName.text = awarenessName + local site = XDataCenter.EquipManager.GetEquipSiteByTemplateId(templateId) + self.TxtAwarenessSite.text = XEquipConfig.AwarenessSiteToStr[site] + self.TxtAwarenessPainter.text = XDataCenter.EquipManager.GetEquipPainterName(templateId) + self.TxtAwarenessMaxLv.text = XDataCenter.EquipManager.GetEquipMaxLevel(templateId) + self.TxtAwarenessMaxBreakthrough.text = XDataCenter.EquipManager.GetEquipMaxBreakthrough(templateId) +end + +function XUiArchiveAwarenessDetail:UpdateSetting() + local suitId = self.SuitId + XRedPointManager.CheckOnce(self.OnCheckRedPoint, self, {XRedPointConditions.Types.CONDITION_ARCHIVE_AWARENESS_SETTING_RED}, suitId) + if XDataCenter.ArchiveManager.IsNewAwarenessSuit(suitId) then + XDataCenter.ArchiveManager.RequestUnlockAwarenessSuit({suitId}) + end + + local newSettingIdList = XDataCenter.ArchiveManager.GetNewAwarenessSettingIdList(suitId) + if newSettingIdList and #newSettingIdList > 0 then + XDataCenter.ArchiveManager.RequestUnlockAwarenessSetting(newSettingIdList) + end + + local settingDataList = XArchiveConfigs.GetAwarenessSettingList(suitId) + local settingType + local showedSettingCount = 0 + local showedStoryCount = 0 + local grid + for _, settingData in ipairs(settingDataList) do + settingType = settingData.Type + if settingType == XArchiveConfigs.SettingType.Setting then + showedSettingCount = showedSettingCount + 1 + grid = self.GridSettingList[showedSettingCount] + if grid then + grid:Refresh(XArchiveConfigs.SubSystemType.Awareness, settingData) + grid.GameObject:SetActiveEx(true) + else + XLog.Error("there is not enough grid in the awareness setting, suitId is " .. suitId .. ", settingid is " .. settingData.Id .. ", check then awareness setting table") + end + elseif settingType == XArchiveConfigs.SettingType.Story then + showedStoryCount = showedStoryCount + 1 + grid = self.GridStoryList[showedStoryCount] + if grid then + grid:Refresh(XArchiveConfigs.SubSystemType.Awareness, settingData) + grid.GameObject:SetActiveEx(true) + else + XLog.Error("there is not enough grid in the awareness story, suitid is " .. suitId .. ", settingid is " .. settingData.Id .. ", check then awareness setting table") + end + end + end + + if showedSettingCount == 0 then + self.PanelSetting.gameObject:SetActiveEx(false) + else + self.PanelSetting.gameObject:SetActiveEx(true) + for i = showedSettingCount+1, #self.GridSettingList do + self.GridSettingList[i].GameObject:SetActiveEx(false) + end + end + + if showedStoryCount == 0 then + self.PanelStory.gameObject:SetActiveEx(false) + else + self.PanelStory.gameObject:SetActiveEx(true) + for i = showedStoryCount+1, #self.GridStoryList do + self.GridStoryList[i].GameObject:SetActiveEx(false) + end + end + + CS.UnityEngine.UI.LayoutRebuilder.ForceRebuildLayoutImmediate(self.PanelSettingContent) +end + +function XUiArchiveAwarenessDetail:UpdateSkill() + local skillDesList = XDataCenter.EquipManager.GetSuitSkillDesList(self.SuitId) + + local isHaveSkill = false + for _, skillDes in pairs(skillDesList) do + if skillDes then + isHaveSkill = true + break + end + end + + if isHaveSkill then + local txtSkillDesc + for i = 1, XEquipConfig.MAX_SUIT_SKILL_COUNT do + txtSkillDesc = self.TxtSkillDescList[i] + if skillDesList[i * 2] then + txtSkillDesc.text = skillDesList[i * 2] + txtSkillDesc.gameObject:SetActiveEx(true) + else + txtSkillDesc.gameObject:SetActiveEx(false) + end + end + self.PanelNoSkill.gameObject:SetActiveEx(false) + self.PanelSkill.gameObject:SetActiveEx(true) + else + self.PanelNoSkill.gameObject:SetActiveEx(true) + self.PanelSkill.gameObject:SetActiveEx(false) + end +end + +function XUiArchiveAwarenessDetail:OnBtnNextClick() + if self.NextIndex == 0 then + return + end + self:Init(self.SuitIdList,self.NextIndex) +end + +function XUiArchiveAwarenessDetail:OnBtnLastClick() + if self.PreviousIndex == 0 then + return + end + self:Init(self.SuitIdList,self.PreviousIndex) +end + +function XUiArchiveAwarenessDetail:CheckNextMonsterAndPreMonster() + self.NextIndex = self:CheckIndex(self.SuitIdIndex + 1) + self.PreviousIndex = self:CheckIndex(self.SuitIdIndex - 1) + + if self.NextIndex == 0 then + self.NextIndex = self:CheckIndex(FirstIndex) + end + + if self.PreviousIndex == 0 then + self.PreviousIndex = self:CheckIndex(#self.SuitIdList) + end +end + +function XUiArchiveAwarenessDetail:CheckIndex(index) + return self.SuitIdList[index] and index or 0 +end + +-----------------------------------事件相关----------------------------------------->>> +function XUiArchiveAwarenessDetail:OnBtnGroupClick(index) + if self.SelectSiteIndex == index then return end + if not self.TemplateIdList or not self.TemplateIdList[index] then return end + + if self.SelectSiteIndex then + self.GridSiteList[self.SelectSiteIndex]:ShowSelect(false) + end + self.GridSiteList[index]:ShowSelect(true) + self.SelectSiteIndex = index + + self.SelectedTemplateId = self.TemplateIdList[index] + self:UpdateAwareness() + self:UpdateResume() + self:UpdateSkill() +end + +function XUiArchiveAwarenessDetail:OnCheckRedPoint(count) + if count < 0 then + self.PanelSettingRedPoint.gameObject:SetActiveEx(false) + self.PanelStoryRedPoint.gameObject:SetActiveEx(false) + else + local newSettingIdList = XDataCenter.ArchiveManager.GetNewAwarenessSettingIdList(self.SuitId) + if newSettingIdList then + local type + local isShowSettingReddot = false + local isShowStoryReddot = false + for _, id in ipairs(newSettingIdList) do + type = XArchiveConfigs.GetAwarenessSettingType(id) + if type == XArchiveConfigs.SettingType.Setting then + isShowSettingReddot = true + elseif type == XArchiveConfigs.SettingType.Story then + isShowStoryReddot = true + end + end + self.PanelSettingRedPoint.gameObject:SetActiveEx(isShowSettingReddot) + self.PanelStoryRedPoint.gameObject:SetActiveEx(isShowStoryReddot) + else + self.PanelSettingRedPoint.gameObject:SetActiveEx(false) + self.PanelStoryRedPoint.gameObject:SetActiveEx(false) + end + end +end +-----------------------------------事件相关-----------------------------------------<<< \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArchive/XUiArchiveCG.lua b/Resources/Scripts/XUi/XUiArchive/XUiArchiveCG.lua new file mode 100644 index 00000000..f80a8c38 --- /dev/null +++ b/Resources/Scripts/XUi/XUiArchive/XUiArchiveCG.lua @@ -0,0 +1,105 @@ +local XUiArchiveCG = XLuaUiManager.Register(XLuaUi, "UiArchiveCG") +local Object = CS.UnityEngine.Object + +function XUiArchiveCG:OnEnable() + self:DynamicTableDataSync() +end + +function XUiArchiveCG:OnStart() + self.CGIndex = {} + self:SetButtonCallBack() + self:InitDynamicTable() + self:InitTypeButton() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) +end + +function XUiArchiveCG:OnDestroy() + XDataCenter.ArchiveManager.ClearCGRedPointByGroup() +end + +function XUiArchiveCG:InitRedPoint(btn,type) + XRedPointManager.AddRedPointEvent(btn, + function (_,count) + btn:ShowReddot(count >= 0) + end, self, + { XRedPointConditions.Types.CONDITION_ARCHIVE_CG_TYPE_RED }, + type) +end + +function XUiArchiveCG:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelDynamicTable) + self.DynamicTable:SetProxy(XUiGridArchiveCG) + self.DynamicTable:SetDelegate(self) + self.GridCGItem.gameObject:SetActiveEx(false) +end + +function XUiArchiveCG:SetupDynamicTable(type) + self.PageDatas = XDataCenter.ArchiveManager.GetArchiveCGDetailList(type) + self.DynamicTable:SetDataSource(self.PageDatas) + self.DynamicTable:ReloadDataSync() +end + +function XUiArchiveCG:DynamicTableDataSync() + self.DynamicTable:ReloadDataSync() +end + +function XUiArchiveCG:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:UpdateGrid(self.PageDatas, self, index) + end +end + +function XUiArchiveCG:SetButtonCallBack() + self.BtnBack.CallBack = function() + self:OnBtnBackClick() + end + self.BtnMainUi.CallBack = function() + self:OnBtnMainUiClick() + end +end + +function XUiArchiveCG:InitTypeButton() + self.GroupList = XDataCenter.ArchiveManager.GetArchiveCGGroupList() + self.CurType = 1 + self.CGGroupBtn = {} + for _, v in pairs(self.GroupList) do + local btn = Object.Instantiate(self.BtnTabShortNew) + btn.gameObject:SetActive(true) + btn.transform:SetParent(self.TabBtnContent.transform, false) + local btncs = btn:GetComponent("XUiButton") + local name = v.Name + btncs:SetName(name or "") + + table.insert(self.CGGroupBtn, btncs) + self:InitRedPoint(btncs,v.Id) + end + self.TabBtnContent:Init(self.CGGroupBtn, function(index) self:SelectType(index) end) + self.BtnTabShortNew.gameObject:SetActiveEx(false) + self.TabBtnContent:SelectIndex(self.CurType) +end + +function XUiArchiveCG:SelectType(index) + self.CurType = index + self:SetupDynamicTable(self.GroupList[index].Id) + self:PlayAnimation("QieHuan") + self:ShowCGRateInfo(index) + + if self.OldType then + XDataCenter.ArchiveManager.ClearCGRedPointByGroup(self.GroupList[self.OldType].Id) + end + + self.OldType = index +end + +function XUiArchiveCG:OnBtnBackClick() + self:Close() +end + +function XUiArchiveCG:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiArchiveCG:ShowCGRateInfo(index) + self.TxtCollectionDesc.text = self.GroupList[index].Name + self.RateNum.text = string.format("%d%s", XDataCenter.ArchiveManager.GetCGCompletionRate(self.GroupList[index].Id), "%") +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArchive/XUiArchiveCGDetail.lua b/Resources/Scripts/XUi/XUiArchive/XUiArchiveCGDetail.lua new file mode 100644 index 00000000..42b8390b --- /dev/null +++ b/Resources/Scripts/XUi/XUiArchive/XUiArchiveCGDetail.lua @@ -0,0 +1,154 @@ +local XUiArchiveCGDetail = XLuaUiManager.Register(XLuaUi, "UiArchiveCGDetail") +local FirstIndex = 1 + +function XUiArchiveCGDetail:OnEnable() + +end + +function XUiArchiveCGDetail:OnStart(dataList, index) + self:SetButtonCallBack() + self:Init(dataList, index) +end + +function XUiArchiveCGDetail:Init(dataList, index) + local data = dataList and dataList[index] + if data then + self.Data = data + self.DataList = dataList + self.DataIndex = index + self:SetMonsterData() + self:CheckNextMonsterAndPreMonster() + XDataCenter.ArchiveManager.ClearCGRedPointById(data:GetId()) + end + self.BtnShowUI.gameObject:SetActiveEx(false) + self.BtnHideUI.gameObject:SetActiveEx(true) +end + +function XUiArchiveCGDetail:SetButtonCallBack() + self.BtnBack.CallBack = function() + self:OnBtnBackClick() + end + self.BtnMainUi.CallBack = function() + self:OnBtnMainUiClick() + end + self.BtnRight.CallBack = function() + self:OnBtnNextClick() + end + self.BtnLeft.CallBack = function() + self:OnBtnLastClick() + end + self.BtnShowUI.CallBack = function() + self:OnBtnShowUIClick() + end + self.BtnHideUI.CallBack = function() + self:OnBtnHideUIClick() + end +end + +function XUiArchiveCGDetail:OnBtnBackClick() + self:Close() +end + +function XUiArchiveCGDetail:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiArchiveCGDetail:SetMonsterData() + local spineBg = self.Data:GetSpineBg() + if spineBg and spineBg ~= "" then + self.CGImage.gameObject:SetActiveEx(false) + self.CGSpineRoot.gameObject:SetActiveEx(true) + self.CGSpineRoot:LoadPrefab(spineBg) + else + self.CGSpineRoot.gameObject:SetActiveEx(false) + self.CGImage.gameObject:SetActiveEx(true) + if self.Data:GetBg() and #self.Data:GetBg() > 0 then + self.CGImage:SetRawImage(self.Data:GetBg()) + end + end + self.TitleText.text = self.Data:GetName() + self.PainterText.text = self.Data:GetAuthor() + self.TxtDesc.text = self.Data:GetDesc() + local width = self.Data:GetBgWidth() ~= 0 and self.Data:GetBgWidth() or 1 + local high = self.Data:GetBgHigh() ~= 0 and self.Data:GetBgHigh() or 1 + self.CGImgAspect.aspectRatio = width / high +end + +function XUiArchiveCGDetail:OnBtnNextClick() + if self.NextIndex == 0 then + return + end + self:Init(self.DataList, self.NextIndex) +end + +function XUiArchiveCGDetail:OnBtnLastClick() + if self.PreviousIndex == 0 then + return + end + self:Init(self.DataList, self.PreviousIndex) +end + +function XUiArchiveCGDetail:OnBtnShowUIClick() + self.BtnShowUI.gameObject:SetActiveEx(false) + self.BtnHideUI.gameObject:SetActiveEx(true) + XLuaUiManager.SetMask(true) + self:PlayAnimation("ScreenShotEnable",function () + self:SetButtonHide(false) + XLuaUiManager.SetMask(false) + end) +end + +function XUiArchiveCGDetail:OnBtnHideUIClick() + self.BtnShowUI.gameObject:SetActiveEx(true) + self.BtnHideUI.gameObject:SetActiveEx(false) + self:SetButtonHide(true) + XLuaUiManager.SetMask(true) + self:PlayAnimation("ScreenShotDisable",function () + XLuaUiManager.SetMask(false) + end) +end + +function XUiArchiveCGDetail:CheckNextMonsterAndPreMonster() + self.NextIndex = self:CheckNext(self.DataIndex + 1) + self.PreviousIndex = self:CheckPrevious(self.DataIndex - 1) + + if self.NextIndex == 0 then + self.NextIndex = self:CheckNext(FirstIndex) + end + + if self.PreviousIndex == 0 then + self.PreviousIndex = self:CheckPrevious(#self.DataList) + end +end + +function XUiArchiveCGDetail:SetButtonHide(IsHide) + self.BtnBack.gameObject:SetActiveEx(not IsHide) + self.BtnMainUi.gameObject:SetActiveEx(not IsHide) + --self.BtnDown.gameObject:SetActiveEx(not IsHide) + self.BtnLeft.gameObject:SetActiveEx(not IsHide) + self.BtnRight.gameObject:SetActiveEx(not IsHide) +end + +function XUiArchiveCGDetail:CheckNext(index) + local next = 0 + for i = index , #self.DataList , 1 do + local tmpData = self.DataList[i] + if tmpData and not tmpData:GetIsLock() then + next = i + break + end + end + return next +end + +function XUiArchiveCGDetail:CheckPrevious(index) + local previous = 0 + for i = index , FirstIndex , -1 do + local tmpData = self.DataList[i] + if tmpData and not tmpData:GetIsLock() then + previous = i + break + end + end + return previous +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArchive/XUiArchiveEmail.lua b/Resources/Scripts/XUi/XUiArchive/XUiArchiveEmail.lua new file mode 100644 index 00000000..586e819a --- /dev/null +++ b/Resources/Scripts/XUi/XUiArchive/XUiArchiveEmail.lua @@ -0,0 +1,172 @@ +local XUiArchiveEmail = XLuaUiManager.Register(XLuaUi, "UiArchiveEmail") +local Object = CS.UnityEngine.Object + +function XUiArchiveEmail:OnEnable() + self:SetupDynamicTable() +end + +function XUiArchiveEmail:OnStart() + self.MailGridState = {} + self.CurTag = {} + self.CurTag[XArchiveConfigs.EmailType.Email] = 1 + self.CurTag[XArchiveConfigs.EmailType.Communication] = 1 + self.CurType = 1 + self.TabBtnContent = {} + self.TabBtnContent[XArchiveConfigs.EmailType.Email] = self.TabMailBtnContent + self.TabBtnContent[XArchiveConfigs.EmailType.Communication] = self.TabCommuniContent + self:SetButtonCallBack() + self:InitEmailDynamicTable() + self:InitCommunicationDynamicTable() + self:InitTagButton() + self:InitTypeButton() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) +end + +function XUiArchiveEmail:OnDestroy() + XDataCenter.ArchiveManager.ClearCGRedPointByGroup() +end +------------------------------------------EMail---------------------------->>> +function XUiArchiveEmail:InitEmailDynamicTable() + self.EmailDynamicTable = XDynamicTableIrregular.New(self.PanelArchiveEmailList) + self.EmailDynamicTable:SetDynamicEventDelegate(function(event, index, grid) + self:OnEmailDynamicTableEvent(event, index, grid) + end) + self.EmailDynamicTable:SetProxy("XUiGridArchiveEmail", XUiGridArchiveEmail, self.EmalItem.gameObject) + self.EmailDynamicTable:SetDelegate(self) + self.EmalItem.gameObject:SetActiveEx(false) +end + +function XUiArchiveEmail:GetProxyType() + return "XUiGridArchiveEmail" +end + +function XUiArchiveEmail:SetupEmailDynamicTable(tag) + XScheduleManager.ScheduleOnce(function()--异形屏适配需要 + self.PageEmailDatas = XDataCenter.ArchiveManager.GetArchiveMailList(tag) + self.EmailDynamicTable:SetDataSource(self.PageEmailDatas) + self.EmailDynamicTable:ReloadDataSync(1) + end, 1) + +end + +function XUiArchiveEmail:OnEmailDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:UpdateGrid(self.PageEmailDatas[index],self.MailGridState) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + self:OnGridClick(self.PageEmailDatas[index]) + end +end + +function XUiArchiveEmail:OnGridClick(chapter) + if chapter then + if self.OldId and self.OldId ~= chapter:GetId() then + self.MailGridState[self.OldId] = false + end + self.MailGridState[chapter:GetId()] = self.MailGridState[chapter:GetId()] or false + self.MailGridState[chapter:GetId()] = not self.MailGridState[chapter:GetId()] + self.EmailDynamicTable:ReloadDataSync() + self.OldId = chapter:GetId() + end + +end +------------------------------------------EMail----------------------------<<< + +------------------------------------------Communication---------------------------->>> +function XUiArchiveEmail:InitCommunicationDynamicTable() + self.CommunicationDynamicTable = XDynamicTableNormal.New(self.PanelArchiveCommunicationList) + self.CommunicationDynamicTable:SetDynamicEventDelegate(function(event, index, grid) + self:OnCommunicationDynamicTableEvent(event, index, grid) + end) + self.CommunicationDynamicTable:SetProxy(XUiGridArchiveCommunication) + self.CommunicationDynamicTable:SetDelegate(self) + self.CommunicationItem.gameObject:SetActiveEx(false) +end + +function XUiArchiveEmail:SetupCommunicationDynamicTable(tag) + self.PageCommunicationDatas = XDataCenter.ArchiveManager.GetArchiveCommunicationList(tag) + self.CommunicationDynamicTable:SetDataSource(self.PageCommunicationDatas) + self.CommunicationDynamicTable:ReloadDataSync(1) +end + +function XUiArchiveEmail:OnCommunicationDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:UpdateGrid(self.PageCommunicationDatas[index]) + end +end +------------------------------------------Communication----------------------------<<< +function XUiArchiveEmail:SetButtonCallBack() + self.BtnBack.CallBack = function() + self:OnBtnBackClick() + end + self.BtnMainUi.CallBack = function() + self:OnBtnMainUiClick() + end +end + +function XUiArchiveEmail:InitTagButton() + self.TagList = XDataCenter.ArchiveManager.GetEventDateGroupList() + for type, group in pairs(self.TagList) do + local eventDateGroupBtn = {} + for _,v in pairs(group)do + local btn = Object.Instantiate(self.BtnTabShortNew) + btn.gameObject:SetActiveEx(true) + btn.transform:SetParent(self.TabBtnContent[type].transform, false) + local btncs = btn:GetComponent("XUiButton") + local name = v.Name + btncs:SetName(name or "") + + table.insert(eventDateGroupBtn, btncs) + end + self.TabBtnContent[type]:Init(eventDateGroupBtn, function(index) self:SelectTag(index) end) + self.TabBtnContent[type]:SelectIndex(self.CurTag[type]) + end + + self.BtnTabShortNew.gameObject:SetActiveEx(false) +end + +function XUiArchiveEmail:SelectTag(index) + self.CurTag[self.CurType] = index + self:SetupDynamicTable() +end + +function XUiArchiveEmail:CheckTagButtonType() + self.PanelMailTab.gameObject:SetActiveEx(self.CurType == XArchiveConfigs.EmailType.Email) + self.PanelCommuniTab.gameObject:SetActiveEx(self.CurType == XArchiveConfigs.EmailType.Communication) +end + + +function XUiArchiveEmail:InitTypeButton() + self.TypeList = {self.BtnEmail, self.BtnCommunication} + self.PanelTabBtns:Init(self.TypeList, function(index) self:SelectType(index) end) + self.PanelTabBtns:SelectIndex(self.CurType) +end + +function XUiArchiveEmail:SelectType(index) + self.CurType = index + self:SetupDynamicTable() + self:CheckTagButtonType() +end + +function XUiArchiveEmail:SetupDynamicTable() + local tagId = self.TagList[self.CurType][self.CurTag[self.CurType]].Id + if self.CurType == XArchiveConfigs.EmailType.Email then + self:SetupEmailDynamicTable(tagId) + elseif self.CurType == XArchiveConfigs.EmailType.Communication then + self:SetupCommunicationDynamicTable(tagId) + end + + self.PanelMailTab.gameObject:SetActiveEx(self.CurType == XArchiveConfigs.EmailType.Email) + self.PanelCommuniTab.gameObject:SetActiveEx(self.CurType == XArchiveConfigs.EmailType.Communication) + + self.PanelArchiveEmail.gameObject:SetActiveEx(self.CurType == XArchiveConfigs.EmailType.Email) + self.PanelArchiveCommunication.gameObject:SetActiveEx(self.CurType == XArchiveConfigs.EmailType.Communication) +end + + +function XUiArchiveEmail:OnBtnBackClick() + self:Close() +end + +function XUiArchiveEmail:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArchive/XUiArchiveMain.lua b/Resources/Scripts/XUi/XUiArchive/XUiArchiveMain.lua new file mode 100644 index 00000000..d53fe8a8 --- /dev/null +++ b/Resources/Scripts/XUi/XUiArchive/XUiArchiveMain.lua @@ -0,0 +1,52 @@ +local XUiArchiveMain = XLuaUiManager.Register(XLuaUi, "UiArchiveMain") + +function XUiArchiveMain:OnEnable() + self.ArchiveDatas = XDataCenter.ArchiveManager.GetArchives() + for index, archive in pairs(self.ArchiveList) do + archive:UpdateGrid(self.ArchiveDatas[index], self, index) + end +end + +function XUiArchiveMain:OnStart() + self:SetButtonCallBack() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + + self.ArchiveObj = {[XArchiveConfigs.SubSystemType.Monster] = self.GridArchive1, + [XArchiveConfigs.SubSystemType.Weapon] = self.GridArchive2, + [XArchiveConfigs.SubSystemType.Awareness] = self.GridArchive3, + [XArchiveConfigs.SubSystemType.Story] = self.GridArchive4, + [XArchiveConfigs.SubSystemType.CG] = self.GridArchive5, + [XArchiveConfigs.SubSystemType.NPC] = self.GridArchive6, + [XArchiveConfigs.SubSystemType.Email] = self.GridArchive7, + [XArchiveConfigs.SubSystemType.Partner] = self.GridArchive8 } + + self:InitArchiveList() + XDataCenter.ArchiveManager.UpdateStoryData() + XDataCenter.ArchiveManager.UpdateStoryNpcData() + XDataCenter.ArchiveManager.UpdateMailAndCommunicationData() +end + +function XUiArchiveMain:InitArchiveList() + self.ArchiveList = {} + for index, archiveObj in pairs(self.ArchiveObj) do + self.ArchiveList[index] = XUiGridArchive.New(archiveObj) + self.ArchiveList[index]:AddRedPointEvent(index) + end +end + +function XUiArchiveMain:SetButtonCallBack() + self.BtnBack.CallBack = function() + self:OnBtnBackClick() + end + self.BtnMainUi.CallBack = function() + self:OnBtnMainUiClick() + end +end + +function XUiArchiveMain:OnBtnBackClick() + self:Close() +end + +function XUiArchiveMain:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end diff --git a/Resources/Scripts/XUi/XUiArchive/XUiArchiveMonster.lua b/Resources/Scripts/XUi/XUiArchive/XUiArchiveMonster.lua new file mode 100644 index 00000000..8435bfd7 --- /dev/null +++ b/Resources/Scripts/XUi/XUiArchive/XUiArchiveMonster.lua @@ -0,0 +1,154 @@ +local XUiArchiveMonster = XLuaUiManager.Register(XLuaUi, "UiArchiveMonster") + +function XUiArchiveMonster:OnEnable() + --self:SetupDynamicTable(self.CurType) + self:DynamicTableDataSync() +end + +function XUiArchiveMonster:OnStart() + self:SetButtonCallBack() + self:InitDynamicTable() + self:Init() + self:InitNewTag() + self:InitRedPoint() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) +end + +function XUiArchiveMonster:OnDestroy() + local datas = XDataCenter.ArchiveManager.GetArchiveMonsterList() + XDataCenter.ArchiveManager.ClearMonsterNewTag(datas) + XDataCenter.ArchiveManager.ClearDetailRedPoint(XArchiveConfigs.MonsterDetailType.Info, datas) + XDataCenter.ArchiveManager.ClearDetailRedPoint(XArchiveConfigs.MonsterDetailType.Setting, datas) + XDataCenter.ArchiveManager.ClearDetailRedPoint(XArchiveConfigs.MonsterDetailType.Skill, datas) +end + +function XUiArchiveMonster:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelArchiveMonsterList) + self.DynamicTable:SetProxy(XUiGridArchiveMonster) + self.DynamicTable:SetDelegate(self) + self.GridArchiveMonster.gameObject:SetActiveEx(false) +end + +function XUiArchiveMonster:SetupDynamicTable(type) + self.PageDatas = XDataCenter.ArchiveManager.GetArchiveMonsterList(type) + self.DynamicTable:SetDataSource(self.PageDatas) + self.DynamicTable:ReloadDataSync() +end + +function XUiArchiveMonster:DynamicTableDataSync() + self.DynamicTable:ReloadDataSync() +end + +function XUiArchiveMonster:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:UpdateGrid(self.PageDatas, self, index) + end +end + +function XUiArchiveMonster:SetButtonCallBack() + self.BtnBack.CallBack = function() + self:OnBtnBackClick() + end + self.BtnMainUi.CallBack = function() + self:OnBtnMainUiClick() + end +end + +function XUiArchiveMonster:Init() + self.CurType = 1 + self.BtnList = { + [1] = self.BtnFirst1, + [2] = self.BtnFirst2, + [3] = self.BtnFirst3 + } + + self.TypeList = { + [1] = XArchiveConfigs.MonsterType.Pawn, + [2] = XArchiveConfigs.MonsterType.Elite, + [3] = XArchiveConfigs.MonsterType.Boss + } + + self.BtnContent:Init(self.BtnList, function(index) self:SelectType(index) end) + self.BtnContent:SelectIndex(self.CurType) +end + +function XUiArchiveMonster:InitRedPoint() + XRedPointManager.AddRedPointEvent(self.BtnFirst1, + self.OnCheckPawnRedPoint, self, + { XRedPointConditions.Types.CONDITION_ARCHIVE_MONSTER_TYPE_RED }, + XArchiveConfigs.MonsterType.Pawn) + XRedPointManager.AddRedPointEvent(self.BtnFirst2, + self.OnCheckEliteRedPoint, self, + { XRedPointConditions.Types.CONDITION_ARCHIVE_MONSTER_TYPE_RED }, + XArchiveConfigs.MonsterType.Elite) + XRedPointManager.AddRedPointEvent(self.BtnFirst3, + self.OnCheckBossRedPoint, self, + { XRedPointConditions.Types.CONDITION_ARCHIVE_MONSTER_TYPE_RED }, + XArchiveConfigs.MonsterType.Boss) +end + +function XUiArchiveMonster:InitNewTag() + XRedPointManager.AddRedPointEvent(self.BtnFirst1, + self.OnCheckPawnTag, self, + { XRedPointConditions.Types.CONDITION_ARCHIVE_MONSTER_TYPE_TAG }, + XArchiveConfigs.MonsterType.Pawn) + XRedPointManager.AddRedPointEvent(self.BtnFirst2, + self.OnCheckEliteTag, self, + { XRedPointConditions.Types.CONDITION_ARCHIVE_MONSTER_TYPE_TAG }, + XArchiveConfigs.MonsterType.Elite) + XRedPointManager.AddRedPointEvent(self.BtnFirst3, + self.OnCheckBossTag, self, + { XRedPointConditions.Types.CONDITION_ARCHIVE_MONSTER_TYPE_TAG }, + XArchiveConfigs.MonsterType.Boss) +end + +function XUiArchiveMonster:SelectType(index) + + self.CurType = index + + self:SetupDynamicTable(self.TypeList[index]) + self.RateNum.text = string.format("%d%s", XDataCenter.ArchiveManager.GetMonsterCompletionRate(self.TypeList[index]), "%") + self:PlayAnimation("QieHuan") + + if self.OldType then + local datas = XDataCenter.ArchiveManager.GetArchiveMonsterList(self.TypeList[self.OldType]) + XDataCenter.ArchiveManager.ClearMonsterNewTag(datas) + XDataCenter.ArchiveManager.ClearDetailRedPoint(XArchiveConfigs.MonsterDetailType.Info, datas) + XDataCenter.ArchiveManager.ClearDetailRedPoint(XArchiveConfigs.MonsterDetailType.Setting, datas) + XDataCenter.ArchiveManager.ClearDetailRedPoint(XArchiveConfigs.MonsterDetailType.Skill, datas) + end + + self.OldType = index +end + +function XUiArchiveMonster:OnBtnBackClick() + self:Close() +end + +function XUiArchiveMonster:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiArchiveMonster:OnCheckPawnRedPoint(count) + self.BtnFirst1:ShowReddot(count >= 0) +end + +function XUiArchiveMonster:OnCheckEliteRedPoint(count) + self.BtnFirst2:ShowReddot(count >= 0) +end + +function XUiArchiveMonster:OnCheckBossRedPoint(count) + self.BtnFirst3:ShowReddot(count >= 0) +end + +function XUiArchiveMonster:OnCheckPawnTag(count) + self.BtnFirst1:ShowTag(count >= 0) +end + +function XUiArchiveMonster:OnCheckEliteTag(count) + self.BtnFirst2:ShowTag(count >= 0) +end + +function XUiArchiveMonster:OnCheckBossTag(count) + self.BtnFirst3:ShowTag(count >= 0) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArchive/XUiArchiveMonsterComment.lua b/Resources/Scripts/XUi/XUiArchive/XUiArchiveMonsterComment.lua new file mode 100644 index 00000000..3ce1a7ed --- /dev/null +++ b/Resources/Scripts/XUi/XUiArchive/XUiArchiveMonsterComment.lua @@ -0,0 +1,142 @@ +local XUiArchiveMonsterComment = XLuaUiManager.Register(XLuaUi, "UiArchiveMonsterComment") +local tableInsert = table.insert +local Vector3 = CS.UnityEngine.Vector3 +local CSTextManagerGetText = CS.XTextManager.GetText +local ScoreMax = 5 +local DifficultyMax = 5 +local TagMax = 10 + +function XUiArchiveMonsterComment:OnEnable() + self.InfoData = self.Base.CurInfoData + self.EvaluateData = self.Base.CurEvaluateData + self:SetPaneBaseInfo() + self:SetPanelTag() +end + +function XUiArchiveMonsterComment:OnStart(base) + self.Base = base + self.PaneBaseInfo = {} + self.PanelTag = {} + + self:SetButtonCallBack() + self:InitMonsterComment(self.PaneBaseInfo, self.PaneBaseInfoObj) + self:InitMonsterComment(self.PanelTag, self.PanelTagObj) + + self.PaneBaseInfo.ScoreImg = { + self.PaneBaseInfo.ScoreImg1, + self.PaneBaseInfo.ScoreImg2, + self.PaneBaseInfo.ScoreImg3, + self.PaneBaseInfo.ScoreImg4, + self.PaneBaseInfo.ScoreImg5 + } + self.PaneBaseInfo.LevelImg = { + self.PaneBaseInfo.LevelImg1, + self.PaneBaseInfo.LevelImg2, + self.PaneBaseInfo.LevelImg3, + self.PaneBaseInfo.LevelImg4, + self.PaneBaseInfo.LevelImg5 + } + self.PanelTag.TagItemObj = { + self.PanelTag.TagItemObj1, + self.PanelTag.TagItemObj2, + self.PanelTag.TagItemObj3, + self.PanelTag.TagItemObj4, + self.PanelTag.TagItemObj5, + self.PanelTag.TagItemObj6, + self.PanelTag.TagItemObj7, + self.PanelTag.TagItemObj8, + self.PanelTag.TagItemObj9, + self.PanelTag.TagItemObj10 + } +end + +function XUiArchiveMonsterComment:SetButtonCallBack() + self.BtnClose.CallBack = function() + self:OnBtnCloseClick() + end + self.BtnBigClose.CallBack = function() + self:OnBtnCloseClick() + end +end + +function XUiArchiveMonsterComment:InitMonsterComment(tmp, obj) + tmp.Transform = obj.transform + tmp.GameObject = obj.gameObject + XTool.InitUiObject(tmp) +end + +function XUiArchiveMonsterComment:SetPaneBaseInfo() + self.PaneBaseInfo.TxtName.text = self.InfoData.Name + self.PaneBaseInfo.RImgIcon:SetRawImage(self.InfoData.Img) + self.PaneBaseInfo.ScoreNumTxt.text = CSTextManagerGetText("ChannelNumberLabel", self.EvaluateData and self.EvaluateData.ScoreCount or 0) + self.PaneBaseInfo.LevelNumTxt.text = CSTextManagerGetText("ChannelNumberLabel", self.EvaluateData and self.EvaluateData.DifficultyCount or 0) + + for index = 1, ScoreMax do + local isActive = self.EvaluateData and self.EvaluateData.AverageScore and index <= self.EvaluateData.AverageScore + self.PaneBaseInfo.ScoreImg[index].gameObject:SetActiveEx(isActive) + end + + for index = 1, DifficultyMax do + local isActive = self.EvaluateData and self.EvaluateData.AverageDifficulty and index <= self.EvaluateData.AverageDifficulty + self.PaneBaseInfo.LevelImg[index].gameObject:SetActiveEx(isActive) + end +end + +function XUiArchiveMonsterComment:SetPanelTag() + self.PanelTag.ImgIcon:SetRawImage(self.InfoData.Icon) + self.PanelTag.CountList = {} + for index = 1, TagMax do + if self.EvaluateData and self.EvaluateData.Tags and self.EvaluateData.Tags[index] then + if not self.PanelTag.TagItem then self.PanelTag.TagItem = {} end + + if not self.PanelTag.TagItem[index] then + self.PanelTag.TagItem[index] = {} + self.PanelTag.TagItem[index].Transform = self.PanelTag.TagItemObj[index].transform + self.PanelTag.TagItem[index].GameObject = self.PanelTag.TagItemObj[index].gameObject + XTool.InitUiObject(self.PanelTag.TagItem[index]) + end + local countList = {} + countList.Index = index + countList.Count = self.EvaluateData.Tags[index].Count + tableInsert(self.PanelTag.CountList, countList) + self.PanelTag.TagItem[index].TxtNum.text = CSTextManagerGetText("ChannelNumberLabel", XArchiveConfigs.GetCountUnitChange(self.EvaluateData.Tags[index].Count)) + self.PanelTag.TagItem[index].TxtTag.text = XArchiveConfigs.GetArchiveTagCfgById(self.EvaluateData.Tags[index].Id).Name + self.PanelTag.TagItem[index].TxtTag.color = XUiHelper.Hexcolor2Color(XArchiveConfigs.GetArchiveTagCfgById(self.EvaluateData.Tags[index].Id).Color) + local bgImg = XArchiveConfigs.GetArchiveTagCfgById(self.EvaluateData.Tags[index].Id).Bg + if bgImg then self:SetUiSprite(self.PanelTag.TagItem[index].Bg, bgImg) end + end + local isActive = (self.EvaluateData and self.EvaluateData.Tags and self.EvaluateData.Tags[index]) and true or false + self.PanelTag.TagItemObj[index].gameObject:SetActiveEx(isActive) + end + self:SetTagSize() +end + +function XUiArchiveMonsterComment:SetTagSize() + if not self.PanelTag.TagItem then + return + end + local smallCount = math.floor(#self.PanelTag.TagItem / 3) + local bigCount = math.floor(#self.PanelTag.TagItem / 3) + local mdCount = #self.PanelTag.TagItem - bigCount - smallCount + table.sort(self.PanelTag.CountList, function(a, b) + return a.Count > b.Count + end) + + for _, count in pairs(self.PanelTag.CountList) do + if bigCount > 0 then + self.PanelTag.TagItemObj[count.Index].transform.localScale = Vector3(1.2, 1.2, 1.2) + bigCount = bigCount - 1 + elseif mdCount > 0 then + self.PanelTag.TagItemObj[count.Index].transform.localScale = Vector3(1, 1, 1) + mdCount = mdCount - 1 + elseif smallCount > 0 then + self.PanelTag.TagItemObj[count.Index].transform.localScale = Vector3(0.8, 0.8, 0.8) + smallCount = smallCount - 1 + end + + end +end + +function XUiArchiveMonsterComment:OnBtnCloseClick() + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArchive/XUiArchiveMonsterDetail.lua b/Resources/Scripts/XUi/XUiArchive/XUiArchiveMonsterDetail.lua new file mode 100644 index 00000000..328a54ca --- /dev/null +++ b/Resources/Scripts/XUi/XUiArchive/XUiArchiveMonsterDetail.lua @@ -0,0 +1,433 @@ +local XUiArchiveMonsterDetail = XLuaUiManager.Register(XLuaUi, "UiArchiveMonsterDetail") +local tableInsert = table.insert +local Object = CS.UnityEngine.Object +local Vector3 = CS.UnityEngine.Vector3 +local Dropdown = CS.UnityEngine.UI.Dropdown + +local FirstIndex = 1 + +local CameraType = { + Main = 1, + Info = 2, + Setting = 3, + Skill = 4, + Zoom = 5, +} + +function XUiArchiveMonsterDetail:OnEnable() + +end + +function XUiArchiveMonsterDetail:OnDestroy() + self.ArchiveMonsterSynopsis:Destroy() +end + +function XUiArchiveMonsterDetail:OnAwake() + self.OperationType = XArchiveConfigs.MonsterDetailUiType.Default +end + +-- dataList : XArchiveMonsterEntity list +-- index : number +-- operationType : XArchiveConfigs.MonsterDetailUiType +function XUiArchiveMonsterDetail:OnStart(dataList, index, operationType) + if operationType == nil then operationType = XArchiveConfigs.MonsterDetailUiType.Default end + self.OperationType = operationType + self.Data = dataList and dataList[index] + self.DataList = dataList + + if not self.Data then + return + end + + self.MonsterIndex = index + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self:Init() + XDataCenter.ArchiveManager.ClearMonsterNewTag({ self.Data }) + -- if self.OperationType == XArchiveConfigs.MonsterDetailUiType.Default then + -- XDataCenter.ArchiveManager.ClearMonsterNewTag({ self.Data }) + -- end +end + +function XUiArchiveMonsterDetail:Init() + self.ArchiveMonsterSynopsis = XUiArchiveMonsterSynopsis.New(self.PanelMonsterSynopsis, self.Data, self) + self.ArchiveMonsterInfo = XUiArchiveMonsterInfo.New(self.PanelMonsterIntro, self.Data, self) + self.ArchiveMonsterSetting = XUiArchiveMonsterSetting.New(self.PanelMonsterSet, self.Data, self) + self.ArchiveMonsterSkill = XUiArchiveMonsterSkill.New(self.PanelMonsterSkill, self.Data, self) + self.IsInit = true + self.MosterHideParts = {} + self.MosterEffects = {} + self:InitScene3DRoot() + self:SetButtonCallBack() + self:InitTypeGroup() + self:SelectDetailState(XArchiveConfigs.MonsterDetailType.Synopsis) + self:CheckNextMonsterAndPreMonster() + self:InitUiDetailByOperationType(self.OperationType) +end + +function XUiArchiveMonsterDetail:InitUiDetailByOperationType(operationType) + self.ArchiveMonsterSynopsis.BtnEvaluate.gameObject:SetActiveEx(operationType == XArchiveConfigs.MonsterDetailUiType.Default) + self.ArchiveMonsterSynopsis.BtnGroupContent.gameObject:SetActiveEx(operationType == XArchiveConfigs.MonsterDetailUiType.Default) +end + +function XUiArchiveMonsterDetail:InitScene3DRoot() + if self.Scene3DRoot then return end + self.Scene3DRoot = {} + self.Scene3DRoot.Transform = self.UiModelGo.transform + XTool.InitUiObject(self.Scene3DRoot) + self.CamFar = { + [CameraType.Zoom] = self.Scene3DRoot.UiCamFarZoom, + [CameraType.Main] = self.Scene3DRoot.UiCamFarMain, + [CameraType.Info] = self.Scene3DRoot.UiCamFarMonsterInfo, + [CameraType.Setting] = self.Scene3DRoot.UiCamFarMonsterSetting, + [CameraType.Skill] = self.Scene3DRoot.UiCamFarMonsterSkill, + } + self.CamNear = { + [CameraType.Zoom] = self.Scene3DRoot.UiCamNearZoom, + [CameraType.Main] = self.Scene3DRoot.UiCamNearMain, + [CameraType.Info] = self.Scene3DRoot.UiCamNearMonsterInfo, + [CameraType.Setting] = self.Scene3DRoot.UiCamNearMonsterSetting, + [CameraType.Skill] = self.Scene3DRoot.UiCamNearMonsterSkill, + } + self.RoleModelPanel = XUiPanelRoleModel.New(self.Scene3DRoot.PanelModel, "", nil, true) + XUiHelper.RegisterSliderChangeEvent(self, self.SliderCharacterHight, self.OnSliderCharacterHightChanged) + self.Scene3DRoot.ImgEffectHuanrenWhite.gameObject:SetActiveEx(false) + self.Scene3DRoot.ImgEffectHuanrenBlack.gameObject:SetActiveEx(false) +end + +function XUiArchiveMonsterDetail:SetButtonCallBack() + self.BtnBack.CallBack = function() + self:OnBtnBackClick() + end + self.BtnMainUi.CallBack = function() + self:OnBtnMainUiClick() + end + self.BtnScreenShot.CallBack = function() + self:OnBtnScreenShotClick() + end + self.BtnHide.CallBack = function() + self:OnBtnHideClick() + end + self.BtnLensIn.CallBack = function() + self:OnBtnLensInClick() + end + self.BtnLensOut.CallBack = function() + self:OnBtnLensOutClick() + end + self.BtnNext.CallBack = function() + self:OnBtnNextClick() + end + self.BtnLast.CallBack = function() + self:OnBtnLastClick() + end + self.BtnStateWords.onValueChanged:AddListener(function() + self.CurNpcState = self.BtnStateWords.value + 1 + self:UpdateModel(self.CurType) + end) +end + +function XUiArchiveMonsterDetail:InitTypeGroup() + self.TypeBtn = {} + self.MonsterSwitchItem.gameObject:SetActiveEx(false) + self.CurType = 1 + for k, _ in pairs(self.Data:GetNpcId() or {}) do + local btn = Object.Instantiate(self.MonsterSwitchItem) + btn.gameObject:SetActiveEx(true) + btn.transform:SetParent(self.MonsterSwitch.transform, false) + local btncs = btn:GetComponent("XUiButton") + local name = "0" .. k + btncs:SetName(name or "Null") + tableInsert(self.TypeBtn, btncs) + end + self.MonsterSwitch:Init(self.TypeBtn, function(index) self:SelectType(index, true) end) + self.MonsterSwitch:SelectIndex(self.CurType) + self.MonsterSwitch.gameObject:SetActiveEx(#self.TypeBtn >= 2) +end + +function XUiArchiveMonsterDetail:UpdateDropdown(index) + local npcId = self.Data:GetNpcId(index) + self.MonsterStateList = XArchiveConfigs.GetMonsterTransDataGroup(npcId) + if self.MonsterStateList then + self.IsHasScreen = true + else + self.IsHasScreen = false + end + self.CurNpcState = 1 + self.PanelState.gameObject:SetActiveEx(self.IsHasScreen) + if not self.IsHasScreen then + return + end + + self.BtnStateWords:ClearOptions() + local tabName = self.MonsterStateList[1] and self.MonsterStateList[1].StateText or "" + self.BtnStateWords.captionText.text = tabName + + for _,v in pairs(self.MonsterStateList) do + local op = Dropdown.OptionData() + op.text = v.StateText or "" + self.BtnStateWords.options:Add(op) + end + + self.BtnStateWords.value = 0 +end + +function XUiArchiveMonsterDetail:SelectType(index, IsUpdateNpcModel) + self.CurType = index + if self.DetailType == XArchiveConfigs.MonsterDetailType.Synopsis then + self.ArchiveMonsterSynopsis:SelectType(index) + elseif self.DetailType == XArchiveConfigs.MonsterDetailType.Info then + self.ArchiveMonsterInfo:SelectType(index) + elseif self.DetailType == XArchiveConfigs.MonsterDetailType.Setting then + self.ArchiveMonsterSetting:SelectType(index) + elseif self.DetailType == XArchiveConfigs.MonsterDetailType.Skill then + self.ArchiveMonsterSkill:SelectType(index) + end + if IsUpdateNpcModel then + self:UpdateDropdown(index) + self:UpdateModel(index) + end +end +function XUiArchiveMonsterDetail:UpdateModel(index) + local func = function(model) + if not model then return end + self.PanelDragMid.Target = model.transform + self.PanelDragLeft.Target = model.transform + self.PanelDragRight.Target = model.transform + self.Scene3DRoot.ImgEffectHuanrenBlack.gameObject:SetActiveEx(false) + self.Scene3DRoot.ImgEffectHuanrenBlack.gameObject:SetActiveEx(true) + + end + + for _,prats in pairs(self.MosterHideParts) do + if not XTool.UObjIsNil(prats) then + prats.gameObject:SetActiveEx(true) + end + end + for _,effect in pairs(self.MosterEffects) do + if not XTool.UObjIsNil(effect) then + effect.gameObject:SetActiveEx(false) + end + end + self.MosterHideParts = {} + self.MosterEffects = {} + local npcId = self.Data:GetNpcId(index) + local modelId = XArchiveConfigs.GetMonsterModel(npcId) + local transDatas = XArchiveConfigs.GetMonsterTransDatas(npcId,self.CurNpcState)---yaogai + local effectDatas = XArchiveConfigs.GetMonsterEffectDatas(npcId,self.CurNpcState) + + self.RoleModelPanel:SetDefaultAnimation(transDatas and transDatas.StandAnime) + self.RoleModelPanel:UpdateArchiveMonsterModel(modelId, XModelManager.MODEL_UINAME.UiArchiveMonsterDetail, nil, func) + self.RoleModelPanel:ShowRoleModel() + + if transDatas then + for _,node in pairs(transDatas.HideNodeName or {}) do + local parts = self.RoleModelPanel.GameObject:FindTransform(node) + if not XTool.UObjIsNil(parts) then + parts.gameObject:SetActiveEx(false) + tableInsert(self.MosterHideParts,parts) + else + XLog.Error("HideNodeName Is Wrong :"..node) + end + end + end + + if effectDatas then + for node,effectPath in pairs(effectDatas) do + local parts = self.RoleModelPanel.GameObject:FindTransform(node) + if not XTool.UObjIsNil(parts) then + local effect = parts.gameObject:LoadPrefab(effectPath,false) + if effect then + effect.gameObject:SetActiveEx(true) + tableInsert(self.MosterEffects,effect) + end + else + XLog.Error("EffectNodeName Is Wrong :"..node) + end + end + end + +end +function XUiArchiveMonsterDetail:SetCameraType(type) + local camType = (type == XArchiveConfigs.MonsterDetailType.ScreenShot) and + XArchiveConfigs.MonsterDetailType.Synopsis or type + + for k, _ in pairs(self.CamFar) do + self.CamFar[k].gameObject:SetActiveEx(k == camType) + end + + for k, _ in pairs(self.CamNear) do + self.CamNear[k].gameObject:SetActiveEx(k == camType) + end +end + +function XUiArchiveMonsterDetail:SelectDetailState(type) + self.DetailType = type + self:SetCameraType(type) + self:SelectType(self.CurType, false) + self.PanelMonsterSynopsis.gameObject:SetActiveEx(type == XArchiveConfigs.MonsterDetailType.Synopsis or + type == XArchiveConfigs.MonsterDetailType.ScreenShot) + + self.PanelMonsterIntro.gameObject:SetActiveEx(type == XArchiveConfigs.MonsterDetailType.Info) + + self.PanelMonsterSet.gameObject:SetActiveEx(type == XArchiveConfigs.MonsterDetailType.Setting) + + self.PanelMonsterSkill.gameObject:SetActiveEx(type == XArchiveConfigs.MonsterDetailType.Skill) + + self.TopControl.gameObject:SetActiveEx(type ~= XArchiveConfigs.MonsterDetailType.ScreenShot and + type ~= XArchiveConfigs.MonsterDetailType.Zoom) + + self.PanelAsset.gameObject:SetActiveEx(type ~= XArchiveConfigs.MonsterDetailType.ScreenShot and + type ~= XArchiveConfigs.MonsterDetailType.Zoom) + + self.PanelDragGroup.gameObject:SetActiveEx(not self.Data:GetIsLockMain()) + + self.BtnRight.gameObject:SetActiveEx((not self.Data:GetIsLockMain()) and + type == XArchiveConfigs.MonsterDetailType.Synopsis or + type == XArchiveConfigs.MonsterDetailType.ScreenShot or + type == XArchiveConfigs.MonsterDetailType.Zoom) + + self.PanelDragMid.gameObject:SetActiveEx( + type ~= XArchiveConfigs.MonsterDetailType.Skill and + type ~= XArchiveConfigs.MonsterDetailType.Setting) + + self.PanelDragLeft.gameObject:SetActiveEx(type == XArchiveConfigs.MonsterDetailType.Skill) + + self.PanelDragRight.gameObject:SetActiveEx(type == XArchiveConfigs.MonsterDetailType.Setting) + + self:PlayUIAnim(type) +end + +function XUiArchiveMonsterDetail:PlayUIAnim(type) + if type == XArchiveConfigs.MonsterDetailType.Synopsis then + if self.IsInit then + self:PlayAnimation("MonsterSynopsisEnable") + self.IsInit = false + else + self:PlayAnimation("MonsterSwitchEnable") + end + + elseif type == XArchiveConfigs.MonsterDetailType.Info then + self:PlayAnimation("MonsterInfoEnable") + elseif type == XArchiveConfigs.MonsterDetailType.Setting then + self:PlayAnimation("MonsterSetEnable") + elseif type == XArchiveConfigs.MonsterDetailType.Skill then + self:PlayAnimation("MonsterSkillEnable") + elseif type == XArchiveConfigs.MonsterDetailType.ScreenShot then + self:PlayAnimationWithMask("MonsterSwitchDisable", function() + self.PanelMonsterSynopsis.gameObject:SetActiveEx(false) + end) + end +end + +function XUiArchiveMonsterDetail:OnSliderCharacterHightChanged() + local pos = self.CamNear[CameraType.Zoom].position + self.CamNear[CameraType.Zoom].position = Vector3(pos.x, 1.7 - self.SliderCharacterHight.value, pos.z) +end + +function XUiArchiveMonsterDetail:ResetScreenShot() + self.BtnScreenShot.gameObject:SetActiveEx(true) + self.BtnHide.gameObject:SetActiveEx(false) + self.BtnLensIn.gameObject:SetActiveEx(false) + self.BtnLensOut.gameObject:SetActiveEx(false) + --self:UpdateModel(self.CurType) +end + +function XUiArchiveMonsterDetail:OnBtnBackClick() + if self.DetailType ~= XArchiveConfigs.MonsterDetailType.Synopsis then + self:SelectDetailState(XArchiveConfigs.MonsterDetailType.Synopsis) + else + self:Close() + end +end + +function XUiArchiveMonsterDetail:OnBtnBackClick() + if self.DetailType ~= XArchiveConfigs.MonsterDetailType.Synopsis then + self:SelectDetailState(XArchiveConfigs.MonsterDetailType.Synopsis) + self:ResetScreenShot() + else + self:Close() + end +end + +function XUiArchiveMonsterDetail:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiArchiveMonsterDetail:OnBtnScreenShotClick() + self:SelectDetailState(XArchiveConfigs.MonsterDetailType.ScreenShot) + self.BtnScreenShot.gameObject:SetActiveEx(false) + self.BtnHide.gameObject:SetActiveEx(true) + self.BtnLensIn.gameObject:SetActiveEx(false)--模型精度不够,暂关闭 + self.BtnLensOut.gameObject:SetActiveEx(false)--模型精度不够,暂关闭 +end + +function XUiArchiveMonsterDetail:OnBtnHideClick() + self:SelectDetailState(XArchiveConfigs.MonsterDetailType.Synopsis) + self:ResetScreenShot() +end + +function XUiArchiveMonsterDetail:OnBtnLensInClick() + self:SelectDetailState(XArchiveConfigs.MonsterDetailType.ScreenShot) + self.BtnLensIn.gameObject:SetActiveEx(false)--模型精度不够,暂关闭 + self.BtnLensOut.gameObject:SetActiveEx(false)--模型精度不够,暂关闭 +end + +function XUiArchiveMonsterDetail:OnBtnLensOutClick() + self:SelectDetailState(XArchiveConfigs.MonsterDetailType.Zoom) + self.BtnLensIn.gameObject:SetActiveEx(false)--模型精度不够,暂关闭 + self.BtnLensOut.gameObject:SetActiveEx(false)--模型精度不够,暂关闭 +end + +function XUiArchiveMonsterDetail:OnBtnNextClick() + if self.NextIndex == 0 then + return + end + XDataCenter.ArchiveManager.GetMonsterEvaluateFromSever(self.DataList[self.NextIndex]:GetNpcId(), function() + XLuaUiManager.PopThenOpen("UiArchiveMonsterDetail", self.DataList, self.NextIndex, self.OperationType) + end) +end + +function XUiArchiveMonsterDetail:OnBtnLastClick() + if self.PreviousIndex == 0 then + return + end + XDataCenter.ArchiveManager.GetMonsterEvaluateFromSever(self.DataList[self.PreviousIndex]:GetNpcId(), function() + XLuaUiManager.PopThenOpen("UiArchiveMonsterDetail", self.DataList, self.PreviousIndex, self.OperationType) + end) +end + +function XUiArchiveMonsterDetail:CheckNextMonsterAndPreMonster() + self.NextIndex = self:CheckNext(self.MonsterIndex + 1) + self.PreviousIndex = self:CheckPrevious(self.MonsterIndex - 1) + + if self.NextIndex == 0 then + self.NextIndex = self:CheckNext(FirstIndex) + end + + if self.PreviousIndex == 0 then + self.PreviousIndex = self:CheckPrevious(#self.DataList) + end +end + +function XUiArchiveMonsterDetail:CheckNext(index) + local next = 0 + for i = index , #self.DataList , 1 do + local tmpData = self.DataList[i] + if tmpData and not tmpData:GetIsLockMain() then + next = i + break + end + end + return next +end + +function XUiArchiveMonsterDetail:CheckPrevious(index) + local previous = 0 + for i = index , FirstIndex , -1 do + local tmpData = self.DataList[i] + if tmpData and not tmpData:GetIsLockMain() then + previous = i + break + end + end + return previous +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArchive/XUiArchiveMonsterEvaluate.lua b/Resources/Scripts/XUi/XUiArchive/XUiArchiveMonsterEvaluate.lua new file mode 100644 index 00000000..e672ab90 --- /dev/null +++ b/Resources/Scripts/XUi/XUiArchive/XUiArchiveMonsterEvaluate.lua @@ -0,0 +1,176 @@ +local XUiArchiveMonsterEvaluate = XLuaUiManager.Register(XLuaUi, "UiArchiveMonsterEvaluate") +local tableInsert = table.insert +local ScoreMax = 5 +local DifficultyMax = 5 +local TagMax = 3 +local TagAddMax = 3 + +function XUiArchiveMonsterEvaluate:OnEnable() + self.InfoData = self.Base.CurInfoData + self.MySelfEvaluateData = self.Base.CurMySelfEvaluateData + self:SetPaneBaseInfo() + self:SetData() + self:SetPanelTag() +end + +function XUiArchiveMonsterEvaluate:OnStart(base, callBack) + self.Base = base + self.CallBack = callBack + self.PaneBaseInfo = {} + self.PanelTag = {} + self.TagGroupId = self.Base.Data:GetTagGroupId() + self:InitMonsterComment(self.PaneBaseInfo, self.PaneBaseInfoObj) + self:InitMonsterComment(self.PanelTag, self.PanelTagObj) + + self.PaneBaseInfo.ScoreImg = { self.PaneBaseInfo.ScoreImg1, self.PaneBaseInfo.ScoreImg2, self.PaneBaseInfo.ScoreImg3, self.PaneBaseInfo.ScoreImg4, self.PaneBaseInfo.ScoreImg5 } + self.PaneBaseInfo.LevelImg = { self.PaneBaseInfo.LevelImg1, self.PaneBaseInfo.LevelImg2, self.PaneBaseInfo.LevelImg3, self.PaneBaseInfo.LevelImg4, self.PaneBaseInfo.LevelImg5 } + self.PaneBaseInfo.ScoreItem = { self.PaneBaseInfo.ScoreItem1, self.PaneBaseInfo.ScoreItem2, self.PaneBaseInfo.ScoreItem3, self.PaneBaseInfo.ScoreItem4, self.PaneBaseInfo.ScoreItem5 } + self.PaneBaseInfo.LevelItem = { self.PaneBaseInfo.LevelItem1, self.PaneBaseInfo.LevelItem2, self.PaneBaseInfo.LevelItem3, self.PaneBaseInfo.LevelItem4, self.PaneBaseInfo.LevelItem5 } + self.PanelTag.TagItemObj = { self.PanelTag.TagItemObj1, self.PanelTag.TagItemObj2, self.PanelTag.TagItemObj3 } + self.PanelTag.TagItemAdd = { self.PanelTag.TagItemAdd1, self.PanelTag.TagItemAdd2, self.PanelTag.TagItemAdd3 } + self:SetButtonCallBack() +end + +function XUiArchiveMonsterEvaluate:OnDestroy() + +end + +function XUiArchiveMonsterEvaluate:InitMonsterComment(tmp, obj) + tmp.Transform = obj.transform + tmp.GameObject = obj.gameObject + XTool.InitUiObject(tmp) +end + +function XUiArchiveMonsterEvaluate:SetButtonCallBack() + self.BtnClose.CallBack = function() + self:OnBtnCloseClick() + end + + self.BtnSubmit.CallBack = function() + self:OnBtnSubmitClick() + end + + for index = 1, ScoreMax do + self.PaneBaseInfo.ScoreItem[index].CallBack = function() + self:OnBtnScoreItemClick(index) + end + end + + for index = 1, DifficultyMax do + self.PaneBaseInfo.LevelItem[index].CallBack = function() + self:OnBtnLevelItemClick(index) + end + end + +end + +function XUiArchiveMonsterEvaluate:OnBtnScoreItemClick(index) + self.MyScore = index + for idx = 1, ScoreMax do + self.PaneBaseInfo.ScoreImg[idx].gameObject:SetActiveEx(idx <= self.MyScore) + end +end + +function XUiArchiveMonsterEvaluate:OnBtnLevelItemClick(index) + self.MyDifficulty = index + for idx = 1, DifficultyMax do + self.PaneBaseInfo.LevelImg[idx].gameObject:SetActiveEx(idx <= self.MyDifficulty) + end +end + +function XUiArchiveMonsterEvaluate:OnBtnCloseClick() + self:Close() +end + +function XUiArchiveMonsterEvaluate:OnBtnSubmitClick() + local IsScoreChange = self.MyScore ~= self.OldMyScore + local IsDifficultyChange = self.MyDifficulty ~= self.OldMyDifficulty + local IsTagChange = #self.MyTagIds ~= #self.OldMyTagIds + + if not IsTagChange then + for index, _ in pairs(self.MyTagIds) do + IsTagChange = IsTagChange or (self.MyTagIds[index] ~= self.OldMyTagIds[index]) + if IsTagChange then + break + end + end + end + + if IsScoreChange or IsDifficultyChange or IsTagChange then + XDataCenter.ArchiveManager.MonsterGiveEvaluate(self.Base.Data:GetNpcId(self.Base.CurType), self.MyScore, self.MyDifficulty, self.MyTagIds, function() + self:Close() + end, self.CallBack) + else + self:Close() + end + XUiManager.TipText("ArchiveMonsterEvaluateHint") +end + +function XUiArchiveMonsterEvaluate:SetData() + self.MyScore = self.MySelfEvaluateData and self.MySelfEvaluateData.Score or 0 + self.OldMyScore = self.MySelfEvaluateData and self.MySelfEvaluateData.Score or 0 + self.MyDifficulty = self.MySelfEvaluateData and self.MySelfEvaluateData.Difficulty or 0 + self.OldMyDifficulty = self.MySelfEvaluateData and self.MySelfEvaluateData.Difficulty or 0 + self.MyTagIds = {} + self.OldMyTagIds = {} + for _, tag in pairs(self.MySelfEvaluateData and self.MySelfEvaluateData.Tags or {}) do + tableInsert(self.MyTagIds, tag) + tableInsert(self.OldMyTagIds, tag) + end +end + +function XUiArchiveMonsterEvaluate:SetPaneBaseInfo() + self.PaneBaseInfo.TxtName.text = self.InfoData.Name + self.PaneBaseInfo.RImgIcon:SetRawImage(self.InfoData.Img) + + for index = 1, ScoreMax do + self.PaneBaseInfo.ScoreImg[index].gameObject:SetActiveEx(self.MySelfEvaluateData and self.MySelfEvaluateData.Score and index <= self.MySelfEvaluateData.Score) + end + + for index = 1, DifficultyMax do + self.PaneBaseInfo.LevelImg[index].gameObject:SetActiveEx(self.MySelfEvaluateData and self.MySelfEvaluateData.Difficulty and index <= self.MySelfEvaluateData.Difficulty) + end + + self.MyScore = self.MySelfEvaluateData and self.MySelfEvaluateData.Score or 0 + self.OldMyScore = self.MySelfEvaluateData and self.MySelfEvaluateData.Score or 0 + self.MyDifficulty = self.MySelfEvaluateData and self.MySelfEvaluateData.Difficulty or 0 + self.OldMyDifficulty = self.MySelfEvaluateData and self.MySelfEvaluateData.Difficulty or 0 +end + +function XUiArchiveMonsterEvaluate:SetPanelTag() + for index = 1, TagMax do + if self.MyTagIds[index] then + if not self.PanelTag.TagItem then self.PanelTag.TagItem = {} end + + if not self.PanelTag.TagItem[index] then + self.PanelTag.TagItem[index] = {} + self.PanelTag.TagItem[index].Transform = self.PanelTag.TagItemObj[index].transform + self.PanelTag.TagItem[index].GameObject = self.PanelTag.TagItemObj[index].gameObject + XTool.InitUiObject(self.PanelTag.TagItem[index]) + self.PanelTag.TagItemObj[index].CallBack = function() + self:OnBtnTag() + end + end + self.PanelTag.TagItem[index].TxtTag.text = XArchiveConfigs.GetArchiveTagCfgById(self.MyTagIds[index]).Name + self.PanelTag.TagItem[index].TxtTag.color = XUiHelper.Hexcolor2Color(XArchiveConfigs.GetArchiveTagCfgById(self.MyTagIds[index]).Color) + local bgImg = XArchiveConfigs.GetArchiveTagCfgById(self.MyTagIds[index]).Bg + if bgImg then self:SetUiSprite(self.PanelTag.TagItem[index].Bg, bgImg) end + end + self.PanelTag.TagItemObj[index].gameObject:SetActiveEx(self.MyTagIds[index] and true or false) + end + + for index = 1, TagAddMax do + if not self.PanelTag.TagItemAdd[index].CallBack then + self.PanelTag.TagItemAdd[index].CallBack = function() + self:OnBtnTag() + end + end + self.PanelTag.TagItemAdd[index].gameObject:SetActiveEx(index > #self.MyTagIds) + end + + +end + +function XUiArchiveMonsterEvaluate:OnBtnTag() + XLuaUiManager.Open("UiArchiveMonsterSelectTag", self) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArchive/XUiArchiveMonsterInfo.lua b/Resources/Scripts/XUi/XUiArchive/XUiArchiveMonsterInfo.lua new file mode 100644 index 00000000..be3187b9 --- /dev/null +++ b/Resources/Scripts/XUi/XUiArchive/XUiArchiveMonsterInfo.lua @@ -0,0 +1,86 @@ +XUiArchiveMonsterInfo = XClass(nil, "XUiArchiveMonsterInfo") + +local CSTextManagerGetText = CS.XTextManager.GetText +local EvaluateOneForAll = XArchiveConfigs.EvaluateOnForAll +local InfoShortMax = 4 +local InfoLongMax = 5 +function XUiArchiveMonsterInfo:Ctor(ui, data, base) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + self.Data = data + self.Base = base + + self.InfoContent = { + self.InfoContent1, + self.InfoContent2, + self.InfoContent3, + self.InfoContent4 + } + self.DetailContent = { + self.DetailContent1, + self.DetailContent2, + self.DetailContent3, + self.DetailContent4, + self.DetailContent5 + } +end + +function XUiArchiveMonsterInfo:SelectType(index) + self:SetMonsterBaseInfoData(index) + self:SetMonsterShortInfoData(index) + self:SetMonsterLongInfoData(index) +end + +function XUiArchiveMonsterInfo:SetMonsterBaseInfoData(type) + self.MonsterNameTex.text = (EvaluateOneForAll == XArchiveConfigs.OnForAllState.On) and self.Data:GetName() or self.Data:GetRealName(self.Data:GetNpcId()[type]) + self.KillCount.text = CSTextManagerGetText("ArchiveMonsterKillText", self.Data.Kill[self.Data:GetNpcId()[type]]) + self.ImgIcon:SetRawImage(self.Data:GetIcon()) +end + +function XUiArchiveMonsterInfo:SetMonsterShortInfoData(type) + local infoList = XDataCenter.ArchiveManager.GetArchiveMonsterInfoList(self.Data:GetNpcId()[type], XArchiveConfigs.MonsterInfoType.Short) + + for index = 1, InfoShortMax do + if infoList[index] then + if not self.MonsterInfo then self.MonsterInfo = {} end + + if not self.MonsterInfo[index] then + self.MonsterInfo[index] = {} + self.MonsterInfo[index].Transform = self.InfoContent[index].transform + self.MonsterInfo[index].GameObject = self.InfoContent[index].gameObject + XTool.InitUiObject(self.MonsterInfo[index]) + end + self.MonsterInfo[index].TxtTitle.text = infoList[index]:GetTitle() + self.MonsterInfo[index].TxtDesc.text = infoList[index]:GetText() + self.MonsterInfo[index].TxtLock.text = infoList[index]:GetLockDesc() + self.MonsterInfo[index].UnLock.gameObject:SetActiveEx(not infoList[index]:GetIsLock()) + self.MonsterInfo[index].Lock.gameObject:SetActiveEx(infoList[index]:GetIsLock()) + end + self.InfoContent[index].gameObject:SetActiveEx(infoList[index] and true or false) + end +end + +function XUiArchiveMonsterInfo:SetMonsterLongInfoData(type) + local infoList = XDataCenter.ArchiveManager.GetArchiveMonsterInfoList(self.Data:GetNpcId()[type], XArchiveConfigs.MonsterInfoType.Long) + + for index = 1, InfoLongMax do + if infoList[index] then + if not self.MonsterDetail then self.MonsterDetail = {} end + + if not self.MonsterDetail[index] then + self.MonsterDetail[index] = {} + self.MonsterDetail[index].Transform = self.DetailContent[index].transform + self.MonsterDetail[index].GameObject = self.DetailContent[index].gameObject + XTool.InitUiObject(self.MonsterDetail[index]) + end + self.MonsterDetail[index].TxtTitle.text = infoList[index]:GetTitle() + self.MonsterDetail[index].TxtDesc.text = infoList[index]:GetText() + self.MonsterDetail[index].TxtLock.text = infoList[index]:GetLockDesc() + self.MonsterDetail[index].UnLock.gameObject:SetActiveEx(not infoList[index]:GetIsLock()) + self.MonsterDetail[index].Lock.gameObject:SetActiveEx(infoList[index]:GetIsLock()) + end + self.DetailContent[index].gameObject:SetActiveEx(infoList[index] and true or false) + end +end diff --git a/Resources/Scripts/XUi/XUiArchive/XUiArchiveMonsterSelectTag.lua b/Resources/Scripts/XUi/XUiArchive/XUiArchiveMonsterSelectTag.lua new file mode 100644 index 00000000..0d739883 --- /dev/null +++ b/Resources/Scripts/XUi/XUiArchive/XUiArchiveMonsterSelectTag.lua @@ -0,0 +1,59 @@ +local XUiArchiveMonsterSelectTag = XLuaUiManager.Register(XLuaUi, "UiArchiveMonsterSelectTag") +local tableInsert = table.insert +function XUiArchiveMonsterSelectTag:OnEnable() + self.InfoData = self.Base.CurInfoData + self.EvaluateData = self.Base.CurEvaluateData + self:SetupDynamicTable() +end + +function XUiArchiveMonsterSelectTag:OnStart(base) + self.Base = base + local taglist = {} + for _, tag in pairs(self.Base.MyTagIds or {}) do + tableInsert(taglist, tag) + end + self.TagIds = taglist + self:SetButtonCallBack() + self:InitDynamicTable() +end + +function XUiArchiveMonsterSelectTag:SetButtonCallBack() + self.BtnClose.CallBack = function() + self:OnBtnCloseClick() + end + self.BtnSubmit.CallBack = function() + self:OnBtnSubmitClick() + end +end + +function XUiArchiveMonsterSelectTag:OnBtnCloseClick() + self:Close() +end + +function XUiArchiveMonsterSelectTag:OnBtnSubmitClick() + local taglist = {} + for _, tag in pairs(self.TagIds or {}) do + tableInsert(taglist, tag) + end + self.Base.MyTagIds = taglist + self.Base:SetPanelTag() + self:Close() +end + +function XUiArchiveMonsterSelectTag:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelTagScroll) + self.DynamicTable:SetProxy(XUiGridArchiveTag) + self.DynamicTable:SetDelegate(self) +end + +function XUiArchiveMonsterSelectTag:SetupDynamicTable() + self.PageDatas = XDataCenter.ArchiveManager.GetArchiveTagList(self.Base.TagGroupId) + self.DynamicTable:SetDataSource(self.PageDatas) + self.DynamicTable:ReloadDataSync(1) +end + +function XUiArchiveMonsterSelectTag:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:UpdateGrid(self.PageDatas[index], self) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArchive/XUiArchiveMonsterSetting.lua b/Resources/Scripts/XUi/XUiArchive/XUiArchiveMonsterSetting.lua new file mode 100644 index 00000000..ea4726a2 --- /dev/null +++ b/Resources/Scripts/XUi/XUiArchive/XUiArchiveMonsterSetting.lua @@ -0,0 +1,80 @@ +XUiArchiveMonsterSetting = XClass(nil, "XUiArchiveMonsterSetting") + +local SettingMax = 5 +local StoryMax = 5 + +function XUiArchiveMonsterSetting:Ctor(ui, data, base) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + self.Data = data + self.Base = base + + self.SettingContent = { + self.SettingContent1, + self.SettingContent2, + self.SettingContent3, + self.SettingContent4, + self.SettingContent5 + } + self.StoryContent = { + self.StoryContent1, + self.StoryContent2, + self.StoryContent3, + self.StoryContent4, + self.StoryContent5 + } +end + +function XUiArchiveMonsterSetting:SelectType(index) + self:SetMonsterSettingData(index) + self:SetMonsterStoryData(index) +end + +function XUiArchiveMonsterSetting:SetMonsterSettingData(type) + local settingList = XDataCenter.ArchiveManager.GetArchiveMonsterSettingList(self.Data:GetNpcId(type), XArchiveConfigs.MonsterSettingType.Setting) + + for index = 1, SettingMax do + if settingList[index] then + if not self.SettingItem then self.SettingItem = {} end + + if not self.SettingItem[index] then + self.SettingItem[index] = {} + self.SettingItem[index].Transform = self.SettingContent[index].transform + self.SettingItem[index].GameObject = self.SettingContent[index].gameObject + XTool.InitUiObject(self.SettingItem[index]) + end + self.SettingItem[index].TxtTitle.text = settingList[index]:GetTitle() + self.SettingItem[index].TxtDesc.text = settingList[index]:GetText() + self.SettingItem[index].TxtLock.text = settingList[index]:GetLockDesc() + self.SettingItem[index].UnLock.gameObject:SetActiveEx(not settingList[index]:GetIsLock()) + self.SettingItem[index].Lock.gameObject:SetActiveEx(settingList[index]:GetIsLock()) + end + self.SettingContent[index].gameObject:SetActiveEx(settingList[index] and true or false) + end +end + +function XUiArchiveMonsterSetting:SetMonsterStoryData(type) + local settingList = XDataCenter.ArchiveManager.GetArchiveMonsterSettingList(self.Data:GetNpcId(type), XArchiveConfigs.MonsterSettingType.Story) + + for index = 1, StoryMax do + if settingList[index] then + if not self.StoryItem then self.StoryItem = {} end + + if not self.StoryItem[index] then + self.StoryItem[index] = {} + self.StoryItem[index].Transform = self.StoryContent[index].transform + self.StoryItem[index].GameObject = self.StoryContent[index].gameObject + XTool.InitUiObject(self.StoryItem[index]) + end + self.StoryItem[index].TxtTitle.text = settingList[index]:GetTitle() + self.StoryItem[index].TxtDesc.text = settingList[index]:GetText() + self.StoryItem[index].TxtLock.text = settingList[index]:GetLockDesc() + self.StoryItem[index].UnLock.gameObject:SetActiveEx(not settingList[index]:GetIsLock()) + self.StoryItem[index].Lock.gameObject:SetActiveEx(settingList[index]:GetIsLock()) + end + self.StoryContent[index].gameObject:SetActiveEx(settingList[index] and true or false) + end +end + diff --git a/Resources/Scripts/XUi/XUiArchive/XUiArchiveMonsterSkill.lua b/Resources/Scripts/XUi/XUiArchive/XUiArchiveMonsterSkill.lua new file mode 100644 index 00000000..d325a4a1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiArchive/XUiArchiveMonsterSkill.lua @@ -0,0 +1,58 @@ +XUiArchiveMonsterSkill = XClass(nil, "XUiArchiveMonsterSkill") + +local SkillMax = 15 + +function XUiArchiveMonsterSkill:Ctor(ui, data, base) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + self.Data = data + self.Base = base + + self.TxtContent = { + self.TxtContent1, + self.TxtContent2, + self.TxtContent3, + self.TxtContent4, + self.TxtContent5, + self.TxtContent6, + self.TxtContent7, + self.TxtContent8, + self.TxtContent9, + self.TxtContent10, + self.TxtContent11, + self.TxtContent12, + self.TxtContent13, + self.TxtContent14, + self.TxtContent15, + } +end + +function XUiArchiveMonsterSkill:SelectType(index) + self:SetMonsterSkillData(index) +end + +function XUiArchiveMonsterSkill:SetMonsterSkillData(type) + local skillList = XDataCenter.ArchiveManager.GetArchiveMonsterSkillList(self.Data:GetNpcId(type)) + + for index = 1, SkillMax do + if skillList[index] then + if not self.SkillItem then self.SkillItem = {} end + + if not self.SkillItem[index] then + self.SkillItem[index] = {} + self.SkillItem[index].Transform = self.TxtContent[index].transform + self.SkillItem[index].GameObject = self.TxtContent[index].gameObject + XTool.InitUiObject(self.SkillItem[index]) + end + self.SkillItem[index].TxtTitle.text = skillList[index]:GetTitle() + self.SkillItem[index].TxtDesc.text = skillList[index]:GetText() + self.SkillItem[index].TxtLock.text = skillList[index]:GetLockDesc() + self.SkillItem[index].UnLock.gameObject:SetActiveEx(not skillList[index]:GetIsLock()) + self.SkillItem[index].Lock.gameObject:SetActiveEx(skillList[index]:GetIsLock()) + end + self.TxtContent[index].gameObject:SetActiveEx(skillList[index] and true or false) + end +end + diff --git a/Resources/Scripts/XUi/XUiArchive/XUiArchiveMonsterSynopsis.lua b/Resources/Scripts/XUi/XUiArchive/XUiArchiveMonsterSynopsis.lua new file mode 100644 index 00000000..0a92c500 --- /dev/null +++ b/Resources/Scripts/XUi/XUiArchive/XUiArchiveMonsterSynopsis.lua @@ -0,0 +1,416 @@ +XUiArchiveMonsterSynopsis = XClass(nil, "XUiArchiveMonsterSynopsis") + +local tableInsert = table.insert +local Object = CS.UnityEngine.Object +local LockNameText = CS.XTextManager.GetText("ArchiveLockNameText") +local CSTextManagerGetText = CS.XTextManager.GetText + +local childUiComment = "UiArchiveMonsterComment" +local childUiEvaluate = "UiArchiveMonsterEvaluate" + +local EvaluateOneForAll = XArchiveConfigs.EvaluateOnForAll +local InfoMax = 4 +local TagMax = 3 +local ScoreMax = 5 +local DifficultyMax = 5 + +function XUiArchiveMonsterSynopsis:Ctor(ui, data, base) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + self.Data = data + self.Base = base + self.MonsterInfo = {} + self.MonsterSetting = {} + self.MonsterFeatures = {} + self.MonsterSkillState = {} + self.PlayerEvaluate = {} + + self.MyDisCount = {} + self.MyLikeCount = {} + self.DisCount = {} + self.LikeCount = {} + + self.LikeStatus = {} + self.OldLikeStatus = {} + self.IsLikeInit = {} + + self.CurEvaluateData = {} + self.CurInfoData = {} + self.CurSkillData = {} + self.CurSettingData = {} + + self:Init() +end + +function XUiArchiveMonsterSynopsis:Destroy() + self:GiveLikeStatus() + self.Base:CloseChildUi(childUiComment) + self.Base:CloseChildUi(childUiEvaluate) +end + +function XUiArchiveMonsterSynopsis:Init() + self:InitMonsterDeatail(self.MonsterInfo, self.MonsterInfoObj) + self:InitMonsterDeatail(self.MonsterSetting, self.MonsterSettingObj) + self:InitMonsterDeatail(self.MonsterFeatures, self.MonsterFeaturesObj) + self:InitMonsterDeatail(self.PlayerEvaluate, self.PlayerEvaluateObj) + self:InitObjGroup() + self:SetButtonCallBack() + self:InitEvaluate() + self:InitLikeAndDis() + self:InitRedPoint() +end + +function XUiArchiveMonsterSynopsis:InitMonsterDeatail(tmp, obj) + tmp.Transform = obj.transform + tmp.GameObject = obj.gameObject + XTool.InitUiObject(tmp) +end + +function XUiArchiveMonsterSynopsis:InitObjGroup() + self.MonsterInfo.InfoContent = { + self.MonsterInfo.InfoContent1, + self.MonsterInfo.InfoContent2, + self.MonsterInfo.InfoContent3, + self.MonsterInfo.InfoContent4 + } + self.MonsterFeatures.TagItemObj = { + self.MonsterFeatures.TagItemObj1, + self.MonsterFeatures.TagItemObj2, + self.MonsterFeatures.TagItemObj3 + } + self.PlayerEvaluate.TagItemObj = { + self.PlayerEvaluate.TagItemObj1, + self.PlayerEvaluate.TagItemObj2, + self.PlayerEvaluate.TagItemObj3 + } + self.PlayerEvaluate.GradeIcon = { + self.PlayerEvaluate.GradeIcon1, + self.PlayerEvaluate.GradeIcon2, + self.PlayerEvaluate.GradeIcon3, + self.PlayerEvaluate.GradeIcon4, + self.PlayerEvaluate.GradeIcon5 + } + self.PlayerEvaluate.LevelIcon = { + self.PlayerEvaluate.LevelIcon1, + self.PlayerEvaluate.LevelIcon2, + self.PlayerEvaluate.LevelIcon3, + self.PlayerEvaluate.LevelIcon4, + self.PlayerEvaluate.LevelIcon5 + } +end + +function XUiArchiveMonsterSynopsis:InitRedPoint() + XRedPointManager.AddRedPointEvent(self.MonsterInfo.BtnMore, self.OnCheckInfoRedDot, self, + { XRedPointConditions.Types.CONDITION_ARCHIVE_MONSTER_INFO }, self.Data:GetId()) + + XRedPointManager.AddRedPointEvent(self.MonsterSetting.BtnSet, self.OnCheckSettingRedDot, self, + { XRedPointConditions.Types.CONDITION_ARCHIVE_MONSTER_SETTING }, self.Data:GetId()) + + XRedPointManager.AddRedPointEvent(self.MonsterSetting.BtnSkill, self.OnCheckSkillRedDot, self, + { XRedPointConditions.Types.CONDITION_ARCHIVE_MONSTER_SKILL }, self.Data:GetId()) +end + +function XUiArchiveMonsterSynopsis:SetButtonCallBack() + self.PlayerEvaluate.BtnMore.CallBack = function() + self:OnBtnPlayerEvaluateClick() + end + self.BtnEvaluate.CallBack = function() + self:OnBtnEvaluateClick() + end + + self.MonsterInfo.BtnMore.CallBack = function() + self:OnMonsterInfoBtnClick() + end + + self.MonsterSetting.BtnSet.CallBack = function() + self:OnMonsterSetBtnClick() + end + + self.MonsterSetting.BtnSkill.CallBack = function() + self:OnMonsterSkillStateBtnClick() + end + +end + +function XUiArchiveMonsterSynopsis:InitEvaluate() + self.EvaluateList = XDataCenter.ArchiveManager.GetArchiveMonsterEvaluateList() + self.MySelfEvaluateList = XDataCenter.ArchiveManager.GetArchiveMonsterMySelfEvaluateList() + + for _, npcId in pairs(self.Data:GetNpcId()) do + self.IsLikeInit[npcId] = false + self.LikeStatus[npcId] = self.MySelfEvaluateList[npcId] and self.MySelfEvaluateList[npcId].LikeStatus or XArchiveConfigs.EquipLikeType.NULL + self.OldLikeStatus[npcId] = self.MySelfEvaluateList[npcId] and self.MySelfEvaluateList[npcId].LikeStatus or XArchiveConfigs.EquipLikeType.NULL + self.DisCount[npcId] = self.EvaluateList[npcId] and self.EvaluateList[npcId].DislikeCount or 0 + self.LikeCount[npcId] = self.EvaluateList[npcId] and self.EvaluateList[npcId].LikeCount or 0 + end +end + +function XUiArchiveMonsterSynopsis:InitLikeAndDis() + self.LikeBtnGroupList = {} + self.LikeBtnObjList = {} + for _, npcId in pairs(self.Data:GetNpcId()) do + if not self.LikeBtnObjList[npcId] then self.LikeBtnObjList[npcId] = {} end + + local btnGroupObj = Object.Instantiate(self.BtnGroup) + btnGroupObj.transform:SetParent(self.BtnGroupContent.transform, false) + + self.LikeBtnObjList[npcId].Transform = btnGroupObj.transform + self.LikeBtnObjList[npcId].GameObject = btnGroupObj.gameObject + XTool.InitUiObject(self.LikeBtnObjList[npcId]) + + self.LikeBtnGroupList[npcId] = btnGroupObj:GetComponent("XUiButtonGroup") + local btnLikeAndDis = { self.LikeBtnObjList[npcId].BtnStep, self.LikeBtnObjList[npcId].BtnLike } + self.LikeBtnGroupList[npcId]:Init(btnLikeAndDis, function(index) self:SelectLikeOrDis(npcId, index) end) + self.LikeBtnGroupList[npcId].CurSelectId = -1 + self.LikeBtnGroupList[npcId].CanDisSelect = true + + if self.LikeStatus[npcId] ~= XArchiveConfigs.EquipLikeType.NULL then + self.IsLikeInit[npcId] = true + self.LikeBtnGroupList[npcId]:SelectIndex(self.LikeStatus[npcId]) + else + self:ChangeLikeCount(npcId) + end + + if EvaluateOneForAll == XArchiveConfigs.OnForAllState.On then + break + end + end + self.BtnGroup.gameObject:SetActiveEx(false) +end + +function XUiArchiveMonsterSynopsis:SelectLikeOrDis(npcId, index) + if not self.IsLikeInit[npcId] then + if index == self.LikeStatus[npcId] then + self.LikeStatus[npcId] = XArchiveConfigs.EquipLikeType.NULL + else + self.LikeStatus[npcId] = index + end + XUiManager.TipText("ArchiveMonsterEvaluateHint") + end + + self.IsLikeInit[npcId] = false + self:ChangeLikeCount(npcId) + +end + +function XUiArchiveMonsterSynopsis:ChangeLikeCount(npcId) + if self.LikeStatus[npcId] == XArchiveConfigs.EquipLikeType.Dis then + self.MyDisCount = 1 + self.MyLikeCount = 0 + elseif self.LikeStatus[npcId] == XArchiveConfigs.EquipLikeType.Like then + self.MyDisCount = 0 + self.MyLikeCount = 1 + else + self.MyDisCount = 0 + self.MyLikeCount = 0 + end + + if self.OldLikeStatus[npcId] == XArchiveConfigs.EquipLikeType.Dis then + self.MyDisCount = self.MyDisCount - 1 + elseif self.OldLikeStatus[npcId] == XArchiveConfigs.EquipLikeType.Like then + self.MyLikeCount = self.MyLikeCount - 1 + end + + self.LikeBtnObjList[npcId].BtnStep:SetName(CSTextManagerGetText("ChannelNumberLabel", + XArchiveConfigs.GetCountUnitChange(self.DisCount[npcId] + self.MyDisCount))) + + self.LikeBtnObjList[npcId].BtnLike:SetName(CSTextManagerGetText("ChannelNumberLabel", + XArchiveConfigs.GetCountUnitChange(self.LikeCount[npcId] + self.MyLikeCount))) +end + +function XUiArchiveMonsterSynopsis:SelectType(index) + self:SetMonsterInfoData(index) + self:SetMonsterSettingData(index) + self:SetMonsterFeaturesData() + self:SetPlayerEvaluateData(index) +end + +function XUiArchiveMonsterSynopsis:SetMonsterInfoData(type) + local infoList = XDataCenter.ArchiveManager.GetArchiveMonsterInfoList(self.Data:GetNpcId(type), XArchiveConfigs.MonsterInfoType.Short) + + self.MonsterInfo.LockedGroup.gameObject:SetActiveEx(self.Data:GetIsLockMain()) + self.MonsterInfo.UnLock.gameObject:SetActiveEx(not self.Data:GetIsLockMain()) + self.MonsterInfo.MonsterNameTex.text = self.Data:GetIsLockMain() and LockNameText or + ((EvaluateOneForAll == XArchiveConfigs.OnForAllState.On) and self.Data:GetName() or self.Data:GetRealName(self.Data:GetNpcId(type))) + + if self.Data:GetIsLockMain() then + return + end + self.MonsterInfo.KillCount.text = CSTextManagerGetText("ArchiveMonsterKillText", self.Data:GetKill(self.Data:GetNpcId(type))) + + for index = 1, InfoMax do + if infoList[index] then + if not self.Info then self.Info = {} end + + if not self.Info[index] then + self.Info[index] = {} + self.Info[index].Transform = self.MonsterInfo.InfoContent[index].transform + self.Info[index].GameObject = self.MonsterInfo.InfoContent[index].gameObject + XTool.InitUiObject(self.Info[index]) + end + self.Info[index].TxtTitle.text = infoList[index]:GetTitle() + self.Info[index].TxtDesc.text = infoList[index]:GetText() + self.Info[index].TxtLock.text = infoList[index]:GetLockDesc() + self.Info[index].UnLock.gameObject:SetActiveEx(not infoList[index]:GetIsLock()) + self.Info[index].Lock.gameObject:SetActiveEx(infoList[index]:GetIsLock()) + end + self.MonsterInfo.InfoContent[index].gameObject:SetActiveEx(infoList[index] and true or false) + end + + self.CurInfoData.Name = self.MonsterInfo.MonsterNameTex.text + self.CurInfoData.Icon = self.Data:GetIcon() + self.CurInfoData.Img = self.Data:GetPic() +end + +function XUiArchiveMonsterSynopsis:SetMonsterSettingData(type) + local skillList = XDataCenter.ArchiveManager.GetArchiveMonsterSkillList(self.Data:GetNpcId(type)) + self.MonsterSetting.UnLock.gameObject:SetActiveEx(not self.Data:GetIsLockMain()) + self.MonsterSetting.BtnSkill.gameObject:SetActiveEx(#skillList > 0) +end + +function XUiArchiveMonsterSynopsis:SetMonsterFeaturesData() + local featuresIds = self.Data:GetTagIds() + self.MonsterFeatures.LockedGroup.gameObject:SetActiveEx(self.Data:GetIsLockMain()) + self.MonsterFeatures.UnLock.gameObject:SetActiveEx(not self.Data:GetIsLockMain()) + + if self.Data:GetIsLockMain() then + return + end + + for index = 1, TagMax do + if featuresIds[index] then + if not self.MonsterFeatures.TagItem then self.MonsterFeatures.TagItem = {} end + + if not self.MonsterFeatures.TagItem[index] then + self.MonsterFeatures.TagItem[index] = {} + self.MonsterFeatures.TagItem[index].Transform = self.MonsterFeatures.TagItemObj[index].transform + self.MonsterFeatures.TagItem[index].GameObject = self.MonsterFeatures.TagItemObj[index].gameObject + XTool.InitUiObject(self.MonsterFeatures.TagItem[index]) + end + self.MonsterFeatures.TagItem[index].TxtTag.text = XArchiveConfigs.GetArchiveTagCfgById(featuresIds[index]).Name + local hexColor = XArchiveConfigs.GetArchiveTagCfgById(featuresIds[index]).Color + self.MonsterFeatures.TagItem[index].TxtTag.color = XUiHelper.Hexcolor2Color(hexColor) + local bgImg = XArchiveConfigs.GetArchiveTagCfgById(featuresIds[index]).Bg + if bgImg then self.Base:SetUiSprite(self.MonsterFeatures.TagItem[index].Bg, bgImg) end + end + self.MonsterFeatures.TagItemObj[index].gameObject:SetActiveEx(featuresIds[index] and true or false) + end +end + +function XUiArchiveMonsterSynopsis:SetPlayerEvaluateData(type) + local NpcType + local evaluate + local mySelfEvaluateList + self.PlayerEvaluate.LockedGroup.gameObject:SetActiveEx(self.Data:GetIsLockMain()) + self.PlayerEvaluate.UnLock.gameObject:SetActiveEx(not self.Data:GetIsLockMain()) + self.RightBottom.gameObject:SetActiveEx(not self.Data:GetIsLockMain()) + if self.Data:GetIsLockMain() then + return + end + + NpcType = (EvaluateOneForAll == XArchiveConfigs.OnForAllState.On) and 1 or type + evaluate = self.EvaluateList[self.Data:GetNpcId(NpcType)] + + if evaluate then + local score = math.floor(evaluate.Score / (evaluate.ScoreCount ~= 0 and evaluate.ScoreCount or 1)) + evaluate.AverageScore = evaluate.Score and score or 0 + + local difficulty = math.floor(evaluate.Difficulty / (evaluate.DifficultyCount ~= 0 and evaluate.DifficultyCount or 1)) + evaluate.AverageDifficulty = evaluate.Difficulty and difficulty or 0 + end + + mySelfEvaluateList = self.MySelfEvaluateList[self.Data:GetNpcId(NpcType)] + self:SelectLikeBtnGroup(self.Data:GetNpcId(NpcType)) + --------------------------------------------------------------------------------评价 + for index = 1, TagMax do + if evaluate and evaluate.Tags and evaluate.Tags[index] then + if not self.PlayerEvaluate.TagItem then self.PlayerEvaluate.TagItem = {} end + + if not self.PlayerEvaluate.TagItem[index] then + self.PlayerEvaluate.TagItem[index] = {} + self.PlayerEvaluate.TagItem[index].Transform = self.PlayerEvaluate.TagItemObj[index].transform + self.PlayerEvaluate.TagItem[index].GameObject = self.PlayerEvaluate.TagItemObj[index].gameObject + XTool.InitUiObject(self.PlayerEvaluate.TagItem[index]) + end + self.PlayerEvaluate.TagItem[index].TxtTag.text = XArchiveConfigs.GetArchiveTagCfgById(evaluate.Tags[index].Id).Name + local hexColor = XArchiveConfigs.GetArchiveTagCfgById(evaluate.Tags[index].Id).Color + self.PlayerEvaluate.TagItem[index].TxtTag.color = XUiHelper.Hexcolor2Color(hexColor) + local bgImg = XArchiveConfigs.GetArchiveTagCfgById(evaluate.Tags[index].Id).Bg + if bgImg then self.Base:SetUiSprite(self.PlayerEvaluate.TagItem[index].Bg, bgImg) end + end + self.PlayerEvaluate.TagItemObj[index].gameObject:SetActiveEx((evaluate and evaluate.Tags and evaluate.Tags[index]) and true or false) + end + --------------------------------------------------------------------------------评分 + for index = 1, ScoreMax do + self.PlayerEvaluate.GradeIcon[index].gameObject:SetActiveEx(evaluate and evaluate.AverageScore and index <= evaluate.AverageScore) + end + + for index = 1, DifficultyMax do + self.PlayerEvaluate.LevelIcon[index].gameObject:SetActiveEx(evaluate and evaluate.AverageDifficulty and index <= evaluate.AverageDifficulty) + end + --------------------------------------------------------------------------------记录 + self.CurEvaluateData = evaluate + self.CurMySelfEvaluateData = mySelfEvaluateList + self.CurType = NpcType +end + +function XUiArchiveMonsterSynopsis:SelectLikeBtnGroup(npcId) + for id, likeBtnGroup in pairs(self.LikeBtnGroupList or {}) do + likeBtnGroup.gameObject:SetActiveEx(npcId == id) + end +end + +function XUiArchiveMonsterSynopsis:GiveLikeStatus() + local changedLikeList = {} + for k, _ in pairs(self.LikeStatus or {}) do + if self.LikeStatus[k] ~= self.OldLikeStatus[k] then + local tmp = {} + tmp.Id = k + tmp.LikeStatus = self.LikeStatus[k] + tableInsert(changedLikeList, tmp) + end + end + if #changedLikeList > 0 then + XDataCenter.ArchiveManager.MonsterGiveLike(changedLikeList) + end +end + + +function XUiArchiveMonsterSynopsis:OnBtnPlayerEvaluateClick() + self.Base:OpenOneChildUi(childUiComment, self) +end + +function XUiArchiveMonsterSynopsis:OnBtnEvaluateClick() + self.Base:OpenOneChildUi(childUiEvaluate, self, function() + self:SelectType(self.CurType) + end) +end + +function XUiArchiveMonsterSynopsis:OnMonsterInfoBtnClick() + self.Base:SelectDetailState(XArchiveConfigs.MonsterDetailType.Info) + XDataCenter.ArchiveManager.ClearDetailRedPoint(XArchiveConfigs.MonsterDetailType.Info, { self.Data }) +end + +function XUiArchiveMonsterSynopsis:OnMonsterSetBtnClick() + self.Base:SelectDetailState(XArchiveConfigs.MonsterDetailType.Setting) + XDataCenter.ArchiveManager.ClearDetailRedPoint(XArchiveConfigs.MonsterDetailType.Setting, { self.Data }) +end + +function XUiArchiveMonsterSynopsis:OnMonsterSkillStateBtnClick() + self.Base:SelectDetailState(XArchiveConfigs.MonsterDetailType.Skill) + XDataCenter.ArchiveManager.ClearDetailRedPoint(XArchiveConfigs.MonsterDetailType.Skill, { self.Data }) +end + +function XUiArchiveMonsterSynopsis:OnCheckInfoRedDot(count) + self.MonsterInfo.BtnMore:ShowReddot(count >= 0) +end + +function XUiArchiveMonsterSynopsis:OnCheckSkillRedDot(count) + self.MonsterSetting.BtnSkill:ShowReddot(count >= 0) +end + +function XUiArchiveMonsterSynopsis:OnCheckSettingRedDot(count) + self.MonsterSetting.BtnSet:ShowReddot(count >= 0) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArchive/XUiArchiveNpc.lua b/Resources/Scripts/XUi/XUiArchive/XUiArchiveNpc.lua new file mode 100644 index 00000000..b0d6dddd --- /dev/null +++ b/Resources/Scripts/XUi/XUiArchive/XUiArchiveNpc.lua @@ -0,0 +1,258 @@ +local XUiArchiveNpc = XLuaUiManager.Register(XLuaUi, "UiArchiveNpc") +local FirstIndex = 1 +function XUiArchiveNpc:OnEnable() + self:SetupDynamicTable() + self:SetRoteData() + self.BtnCloseGird.gameObject:SetActiveEx(false) + if self.IsInit then + self.GridState = XArchiveConfigs.NpcGridState.Open + self.CurIndex = #self.PageDatas + 1 + self.IsInit = false + end +end + +function XUiArchiveNpc:OnStart() + self.IsInit = true + self.GridDic = {} + self:SetButtonCallBack() + self:InitDynamicTable() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) +end + +function XUiArchiveNpc:OnDestroy() + +end + +function XUiArchiveNpc:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelArchiveList) + self.DynamicTable:SetProxy(XUiGridArchiveNpc) + self.DynamicTable:SetDelegate(self) + self.GridArchiveNpc.gameObject:SetActiveEx(false) +end + +function XUiArchiveNpc:SetupDynamicTable() + self.PageDatas = XDataCenter.ArchiveManager.GetArchiveStoryNpcList() + self.DynamicTable:SetDataSource(self.PageDatas) + self.DynamicTable:ReloadDataSync(1) +end + +function XUiArchiveNpc:OnlyReloadDataSync() + self.DynamicTable:ReloadDataSync(-1) +end + +function XUiArchiveNpc:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:UpdateGrid(self.PageDatas[index], self, index) + self:SetGridDic(index,grid) + end +end + +function XUiArchiveNpc:SetButtonCallBack() + self.BtnBack.CallBack = function() + self:OnBtnBackClick() + end + self.BtnMainUi.CallBack = function() + self:OnBtnMainUiClick() + end + self.BtnCloseGird.CallBack = function() + self:OnBtnCloseGirdClick() + end +end + +function XUiArchiveNpc:OnBtnBackClick() + self:Close() +end + +function XUiArchiveNpc:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiArchiveNpc:SetGridDic(npcIndex,npcGrid) + for index,grid in pairs(self.GridDic) do + if grid == npcGrid then + self.GridDic[index] = nil + break + end + end + self:CheckGirdState(npcIndex,npcGrid) + self.GridDic[npcIndex] = npcGrid +end + +function XUiArchiveNpc:CheckGirdState(index,grid) + if self.GridState == XArchiveConfigs.NpcGridState.Open then + if index < self.CurIndex then + grid:SetLeftEndPos() + grid:SetStartScale() + grid:SetEndAlpha() + grid:SetDetailStartAlpha() + grid:StopTween() + elseif index > self.CurIndex then + grid:SetRightEndPos() + grid:SetStartScale() + grid:SetEndAlpha() + grid:SetDetailStartAlpha() + grid:StopTween() + else + grid:SetStartPos() + grid:SetEndScale() + grid:SetStartAlpha() + grid:SetDetailEndAlpha() + grid:StopTween() + end + elseif self.GridState == XArchiveConfigs.NpcGridState.Close then + grid:SetStartPos() + grid:SetStartScale() + grid:SetEndAlpha() + grid:SetDetailStartAlpha() + grid:StopTween() + end +end + +function XUiArchiveNpc:SelectNpc(Index) + if self.CurIndex then + if self.CurIndex ~= Index then + if Index > self.CurIndex then + self:RightOpenGird(function () + self.CurIndex = Index + end) + else + self:LeftOpenGird(function () + self.CurIndex = Index + end) + end + end + else + self.CurIndex = Index + self:OpenGird() + end + self.GridState = XArchiveConfigs.NpcGridState.Open +end + +function XUiArchiveNpc:UnSelectNpc() + if self.CurIndex then + self:CloseGird(nil) + self.CurIndex = nil + end + self.GridState = XArchiveConfigs.NpcGridState.Close +end + +function XUiArchiveNpc:LeftOpenGird(cb) + local curGrid = self.GridDic[self.CurIndex] + XLuaUiManager.SetMask(true) + if curGrid then + curGrid:SetItemDailyDisable(function () + curGrid:SetStartPos() + curGrid:SetItemEnable(function () + XLuaUiManager.SetMask(false) + end) + if cb then cb() end + self:OpenGird() + end) + else + XLuaUiManager.SetMask(false) + if cb then cb() end + self:OpenGird() + end +end + +function XUiArchiveNpc:RightOpenGird(cb) + local curGrid = self.GridDic[self.CurIndex] + XLuaUiManager.SetMask(true) + if curGrid then + curGrid:SetItemDailyDisable(function () + curGrid:SetStartPos() + curGrid:SetItemEnable(function () + XLuaUiManager.SetMask(false) + end) + if cb then cb() end + self:OpenGird() + end) + else + XLuaUiManager.SetMask(false) + if cb then cb() end + self:OpenGird() + end +end + +function XUiArchiveNpc:OpenGird() + local curGrid = self.GridDic[self.CurIndex] + XLuaUiManager.SetMask(true) + local IsPlayed = false + if curGrid then + self.DynamicTable:CenterToSelected(curGrid.GameObject,0.5) + curGrid:SetItemDisable(function () + local fun = function () + if not IsPlayed then + IsPlayed = true + curGrid:SetItemDailyEnable(function () + XLuaUiManager.SetMask(false) + end) + end + end + for index,grid in pairs(self.GridDic) do + if index < self.CurIndex then + grid:GoLeft(fun) + elseif index > self.CurIndex then + grid:GoRight(fun) + end + end + end) + else + local fun = function () + if not IsPlayed then + IsPlayed = true + XLuaUiManager.SetMask(false) + end + end + for index,grid in pairs(self.GridDic) do + if index < self.CurIndex then + grid:GoLeft(fun) + elseif index > self.CurIndex then + grid:GoRight(fun) + end + end + end +end + +function XUiArchiveNpc:CloseGird(cb) + local curGrid = self.GridDic[self.CurIndex] + XLuaUiManager.SetMask(true) + if curGrid then + curGrid:SetItemDailyDisable(function () + curGrid:SetItemEnable() + self:GirdGoBack(function () + if cb then cb() end + XLuaUiManager.SetMask(false) + end,true) + end) + else + self:GirdGoBack(function () + if cb then cb() end + XLuaUiManager.SetMask(false) + end,false) + end +end + +function XUiArchiveNpc:GirdGoBack(cb,IsMove) + local IsOver = false + for index,grid in pairs(self.GridDic) do + if index ~= self.CurIndex then + grid:GoBack(function () + if not IsOver then + IsOver = true + if cb then cb() end + end + end,IsMove) + end + end +end + +function XUiArchiveNpc:SetRoteData() + local unLockCount = 0 + for _,data in pairs(self.PageDatas) do + if not data:GetIsLock() then + unLockCount = unLockCount + 1 + end + end + self.RateNum.text = string.format("%d/%d", unLockCount, #self.PageDatas) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArchive/XUiArchivePartner.lua b/Resources/Scripts/XUi/XUiArchive/XUiArchivePartner.lua new file mode 100644 index 00000000..f22833e2 --- /dev/null +++ b/Resources/Scripts/XUi/XUiArchive/XUiArchivePartner.lua @@ -0,0 +1,88 @@ +local XUiArchivePartner = XLuaUiManager.Register(XLuaUi, "UiArchivePartner") +local XUiGridArchivePartner = require("XUi/XUiArchive/XUiGridArchivePartner") +local Object = CS.UnityEngine.Object + +function XUiArchivePartner:OnEnable() + self:DynamicTableDataSync() +end + +function XUiArchivePartner:OnStart() + self:SetButtonCallBack() + self:InitDynamicTable() + self:InitTypeButton() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) +end + +function XUiArchivePartner:OnDestroy() + +end + +function XUiArchivePartner:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelArchivePartnerList) + self.DynamicTable:SetProxy(XUiGridArchivePartner) + self.DynamicTable:SetDelegate(self) + self.GridArchivePartner.gameObject:SetActiveEx(false) +end + +function XUiArchivePartner:SetupDynamicTable(type) + self.PageDatas = XDataCenter.ArchiveManager.GetArchivePartnerList(type) + self.DynamicTable:SetDataSource(self.PageDatas) + self.DynamicTable:ReloadDataSync() +end + +function XUiArchivePartner:DynamicTableDataSync() + self.DynamicTable:ReloadDataSync() +end + +function XUiArchivePartner:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:UpdateGrid(self.PageDatas, index) + end +end + +function XUiArchivePartner:SetButtonCallBack() + self.BtnBack.CallBack = function() + self:OnBtnBackClick() + end + self.BtnMainUi.CallBack = function() + self:OnBtnMainUiClick() + end +end + +function XUiArchivePartner:InitTypeButton() + self.GroupList = XDataCenter.ArchiveManager.GetPartnerGroupList() + self.CurType = 1 + self.PartnerGroupBtn = {} + for _, v in pairs(self.GroupList) do + local btn = Object.Instantiate(self.BtnType) + btn.gameObject:SetActive(true) + btn.transform:SetParent(self.BtnContent.transform, false) + local btncs = btn:GetComponent("XUiButton") + local name = v.GroupName + btncs:SetName(name or "") + table.insert(self.PartnerGroupBtn, btncs) + end + self.BtnContent:Init(self.PartnerGroupBtn, function(index) self:SelectType(index) end) + self.BtnType.gameObject:SetActiveEx(false) + self.BtnContent:SelectIndex(self.CurType) +end + +function XUiArchivePartner:SelectType(index) + self.CurType = index + self:SetupDynamicTable(self.GroupList[index].Id) + self:PlayAnimation("QieHuan") + self:ShowPartnerRateInfo(index) +end + +function XUiArchivePartner:OnBtnBackClick() + self:Close() +end + +function XUiArchivePartner:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiArchivePartner:ShowPartnerRateInfo(index) + self.RateText.text = self.GroupList[index].GroupName + self.RateNum.text = string.format("%d%s", XDataCenter.ArchiveManager.GetPartnerCompletionRate(self.GroupList[index].Id), "%") +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArchive/XUiArchivePartnerDetail.lua b/Resources/Scripts/XUi/XUiArchive/XUiArchivePartnerDetail.lua new file mode 100644 index 00000000..616a53c4 --- /dev/null +++ b/Resources/Scripts/XUi/XUiArchive/XUiArchivePartnerDetail.lua @@ -0,0 +1,354 @@ +local XUiArchivePartnerDetail = XLuaUiManager.Register(XLuaUi, "UiArchivePartnerDetail") +local tableInsert = table.insert +local Object = CS.UnityEngine.Object +local Vector3 = CS.UnityEngine.Vector3 +local Dropdown = CS.UnityEngine.UI.Dropdown + +local FirstIndex = 1 +local CSUnityEngineGameObject = CS.UnityEngine.GameObject +function XUiArchivePartnerDetail:OnEnable() + +end + +function XUiArchivePartnerDetail:OnDisable() + self.RoleModelPanel:HideAllEffects() +end + +function XUiArchivePartnerDetail:OnStart(dataList, index) + self.Data = dataList and dataList[index] + self.DataList = dataList + + if not self.Data then + return + end + + self.ModelEffect = {} + self.CurPartnerState = XPartnerConfigs.PartnerState.Standby + self.PartnerIndex = index + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self:Init() + +end + +function XUiArchivePartnerDetail:Init() + self.MosterEffects = {} + self:InitScene3DRoot() + self:SetButtonCallBack() + self:UpdateRoleModel(self.Data:GetStandbyModel(), self.Data, true) + self:UpdateCamera() + self:CheckNextPartnerAndPrePartner() + self:UpdatePartnerInfo() +end + +function XUiArchivePartnerDetail:InitScene3DRoot() + local root = self.UiModelGo.transform + + self.PanelRoleModel = root:FindTransform("PanelRoleModel") + self.ImgEffectHuanren = root:FindTransform("ImgEffectHuanren") + + self.CameraFar = { + [XPartnerConfigs.CameraType.Standby] = root:FindTransform("UiCamFarStandby"), + [XPartnerConfigs.CameraType.Combat] = root:FindTransform("UiCamFarCombat"), + } + self.CameraNear = { + [XPartnerConfigs.CameraType.Standby] = root:FindTransform("UiCamNearStandby"), + [XPartnerConfigs.CameraType.Combat] = root:FindTransform("UiCamNearCombat"), + } + + self.RoleModelPanel = XUiPanelRoleModel.New(self.PanelRoleModel, self.Name, nil, true, nil, true) +end + +function XUiArchivePartnerDetail:SetButtonCallBack() + self.BtnBack.CallBack = function() + self:OnBtnBackClick() + end + self.BtnMainUi.CallBack = function() + self:OnBtnMainUiClick() + end + self.BtnScreenShot.CallBack = function() + self:OnBtnScreenShotClick() + end + self.BtnHide.CallBack = function() + self:OnBtnHideClick() + end + self.BtnNext.CallBack = function() + self:OnBtnNextClick() + end + self.BtnLast.CallBack = function() + self:OnBtnLastClick() + end + self.BtnStandby.CallBack = function() + self:OnBtnStandbyClick() + end + self.BtnCombat.CallBack = function() + self:OnBtnCombatClick() + end + self.BtnMoveStroy.CallBack = function() + self:OnBtnMoveStroyClick() + end + +end + +function XUiArchivePartnerDetail:DoPartnerStateChange(state) + if state == self.CurPartnerState then + return + end + + local partner = self.Data + + XLuaUiManager.SetMask(true) + local closeMask = function() + XLuaUiManager.SetMask(false) + end + + if self:IsPartnerStandby() then + + local voiceId = partner:GetSToCVoice() + if voiceId and voiceId > 0 then + XSoundManager.PlaySoundByType(voiceId, XSoundManager.SoundType.Sound) + end + + self.CurPartnerState = state + self:UpdateCamera() + self.RoleModelPanel:LoadEffect(partner:GetSToCEffect(), "ModelOffEffect", true, true) + self:PlayPartnerAnima(partner:GetSToCAnime(), true, function () + self:UpdateRoleModel(partner:GetCombatModel(), partner, false) + self.RoleModelPanel:LoadEffect(partner:GetCombatBornEffect(), "ModelOnEffect", true, true) + self:PlayPartnerAnima(partner:GetCombatBornAnime(), true, closeMask) + end) + + elseif self:IsPartnerCombat() then + + local voiceId = partner:GetCToSVoice() + if voiceId and voiceId > 0 then + XSoundManager.PlaySoundByType(voiceId, XSoundManager.SoundType.Sound) + end + self.RoleModelPanel:LoadEffect(partner:GetCToSEffect(), "ModelOnEffect", true, true) + self:PlayPartnerAnima(partner:GetCToSAnime(), true, function () + self.CurPartnerState = state + self:UpdateCamera() + self:UpdateRoleModel(partner:GetStandbyModel(), partner, false) + self.RoleModelPanel:LoadEffect(partner:GetStandbyBornEffect(), "ModelOffEffect", true, true) + self:PlayPartnerAnima(partner:GetStandbyBornAnime(), true, closeMask) + end) + + else + closeMask() + end +end + +function XUiArchivePartnerDetail:PlayPartnerAnima(animaName, fromBegin, callBack) + local IsCanPlay = self.RoleModelPanel:PlayAnima(animaName, fromBegin, callBack) + if not IsCanPlay then + if callBack then callBack() end + end +end + +--更新模型 +function XUiArchivePartnerDetail:UpdateRoleModel(modelId, partner, IsShowEffect) + self.RoleModelPanel:UpdatePartnerModel(modelId, XModelManager.MODEL_UINAME.XUiPartnerMain, nil, function(model) + self.PanelDrag.Target = model.transform + if IsShowEffect then + self.ImgEffectHuanren.gameObject:SetActiveEx(false) + self.ImgEffectHuanren.gameObject:SetActiveEx(true) + end + end, false, true) + +end + +function XUiArchivePartnerDetail:SetCameraType(type) + for k, _ in pairs(self.CameraFar) do + self.CameraFar[k].gameObject:SetActiveEx(k == type) + end + + for k, _ in pairs(self.CameraNear) do + self.CameraNear[k].gameObject:SetActiveEx(k == type) + end +end + +function XUiArchivePartnerDetail:UpdateCamera() + if self:IsPartnerCombat() then + self:SetCameraType(XPartnerConfigs.CameraType.Combat) + elseif self:IsPartnerStandby() then + self:SetCameraType(XPartnerConfigs.CameraType.Standby) + end +end + +function XUiArchivePartnerDetail:UpdatePartnerInfo() + local storyId = self.Data:GetStoryId() + self.PartnerNameText.text = self.Data:GetOriginalName() + + if not string.IsNilOrEmpty(storyId) then + self.BtnMoveStroy:SetName(self.Data:GetStoryTitle()) + self.BtnMoveStroy.gameObject:SetActiveEx(true) + else + self.BtnMoveStroy.gameObject:SetActiveEx(false) + end + + self:UpdatePartnerStory() + self:UpdatePartnerSetting() +end + +function XUiArchivePartnerDetail:UpdatePartnerStory() + local storyDataList = self.Data:GetStoryEntityList() + local storyObjList = { + self.PartnerStory:GetObject("GridStory1"), + self.PartnerStory:GetObject("GridStory2"), + self.PartnerStory:GetObject("GridStory3"), + self.PartnerStory:GetObject("GridStory4"), + self.PartnerStory:GetObject("GridStory5") + } + + for index,grid in pairs(storyObjList or {}) do + if storyDataList[index] then + grid.gameObject:SetActiveEx(true) + self:UpdateGrid(storyDataList[index],grid) + else + grid.gameObject:SetActiveEx(false) + end + end +end + +function XUiArchivePartnerDetail:UpdatePartnerSetting() + local IsEmpty = true + local settingDataList = self.Data:GetSettingEntityList() + local settingObjList = { + self.PartnerSetting:GetObject("GridSetting1"), + self.PartnerSetting:GetObject("GridSetting2"), + self.PartnerSetting:GetObject("GridSetting3"), + self.PartnerSetting:GetObject("GridSetting4"), + self.PartnerSetting:GetObject("GridSetting5") + } + + for index,grid in pairs(settingObjList or {}) do + if settingDataList[index] then + grid.gameObject:SetActiveEx(true) + self:UpdateGrid(settingDataList[index],grid) + IsEmpty = false + else + grid.gameObject:SetActiveEx(false) + end + end + + self.PartnerSetting:GetObject("PanelNoSetting").gameObject:SetActiveEx(IsEmpty) +end + +function XUiArchivePartnerDetail:UpdateGrid(data,grid) + if not data:GetIsLock() then + grid:GetObject("TxtTitle").text = data:GetTitle() + grid:GetObject("TxtContent").text = string.gsub(data:GetText(), "\\n", "\n") + else + grid:GetObject("TxtLockContent").text = data:GetConditionDesc() + end + grid:GetObject("PanelUnlock").gameObject:SetActiveEx(not data:GetIsLock()) + grid:GetObject("PanelLock").gameObject:SetActiveEx(data:GetIsLock()) +end + +function XUiArchivePartnerDetail:IsPartnerStandby() + return self.CurPartnerState == XPartnerConfigs.PartnerState.Standby +end + +function XUiArchivePartnerDetail:IsPartnerCombat() + return self.CurPartnerState == XPartnerConfigs.PartnerState.Combat +end + +function XUiArchivePartnerDetail:OnBtnBackClick() + if self.IsHide then + return + end + self:Close() +end + +function XUiArchivePartnerDetail:OnBtnMainUiClick() + if self.IsHide then + return + end + XLuaUiManager.RunMain() +end + +function XUiArchivePartnerDetail:OnBtnScreenShotClick() + self.IsHide = true + self.BtnScreenShot.gameObject:SetActiveEx(false) + self.BtnHide.gameObject:SetActiveEx(true) + self.AssetPanel.GameObject:SetActiveEx(false) + self:PlayAnimation("UiDisable") +end + +function XUiArchivePartnerDetail:OnBtnHideClick() + self.IsHide = false + self.BtnScreenShot.gameObject:SetActiveEx(true) + self.BtnHide.gameObject:SetActiveEx(false) + self.AssetPanel.GameObject:SetActiveEx(true) + self:PlayAnimation("UiEnable") +end + +function XUiArchivePartnerDetail:OnBtnStandbyClick() + self:DoPartnerStateChange(XPartnerConfigs.PartnerState.Standby) +end + +function XUiArchivePartnerDetail:OnBtnCombatClick() + self:DoPartnerStateChange(XPartnerConfigs.PartnerState.Combat) +end + +function XUiArchivePartnerDetail:OnBtnMoveStroyClick() + if self.IsHide then + return + end + + local storyId = self.Data:GetStoryId() + + if not string.IsNilOrEmpty(storyId) then + XDataCenter.MovieManager.PlayMovie(storyId) + end +end + +function XUiArchivePartnerDetail:OnBtnNextClick() + if self.NextIndex == 0 then + return + end + XLuaUiManager.PopThenOpen("UiArchivePartnerDetail", self.DataList, self.NextIndex) +end + +function XUiArchivePartnerDetail:OnBtnLastClick() + if self.PreviousIndex == 0 then + return + end + XLuaUiManager.PopThenOpen("UiArchivePartnerDetail", self.DataList, self.PreviousIndex) +end + +function XUiArchivePartnerDetail:CheckNextPartnerAndPrePartner() + self.NextIndex = self:CheckNext(self.PartnerIndex + 1) + self.PreviousIndex = self:CheckPrevious(self.PartnerIndex - 1) + + if self.NextIndex == 0 then + self.NextIndex = self:CheckNext(FirstIndex) + end + + if self.PreviousIndex == 0 then + self.PreviousIndex = self:CheckPrevious(#self.DataList) + end +end + +function XUiArchivePartnerDetail:CheckNext(index) + local next = 0 + for i = index , #self.DataList , 1 do + local tmpData = self.DataList[i] + if tmpData and not tmpData:GetIsArchiveLock() then + next = i + break + end + end + return next +end + +function XUiArchivePartnerDetail:CheckPrevious(index) + local previous = 0 + for i = index , FirstIndex , -1 do + local tmpData = self.DataList[i] + if tmpData and not tmpData:GetIsArchiveLock() then + previous = i + break + end + end + return previous +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArchive/XUiArchiveStory.lua b/Resources/Scripts/XUi/XUiArchive/XUiArchiveStory.lua new file mode 100644 index 00000000..a0438fdf --- /dev/null +++ b/Resources/Scripts/XUi/XUiArchive/XUiArchiveStory.lua @@ -0,0 +1,100 @@ +local XUiArchiveStory = XLuaUiManager.Register(XLuaUi, "UiArchiveStory") +local Object = CS.UnityEngine.Object + +function XUiArchiveStory:OnEnable() + self:DynamicTableDataSync() +end + +function XUiArchiveStory:OnStart() + self:SetButtonCallBack() + self:InitDynamicTable() + self:InitTypeButton() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) +end + +function XUiArchiveStory:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelDynamicTable) + self.DynamicTable:SetProxy(XUiGridArchiveStory) + self.DynamicTable:SetDelegate(self) + self.GridStoryItem.gameObject:SetActiveEx(false) +end + +function XUiArchiveStory:SetupDynamicTable(type) + self.PageDatas = XDataCenter.ArchiveManager.GetArchiveStoryChapterList(type) + self.DynamicTable:SetDataSource(self.PageDatas) + self.DynamicTable:ReloadDataSync(1) +end + +function XUiArchiveStory:DynamicTableDataSync() + self.DynamicTable:ReloadDataSync() +end + +function XUiArchiveStory:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:UpdateGrid(self.PageDatas, self, index) + end +end + +function XUiArchiveStory:SetButtonCallBack() + self.BtnBack.CallBack = function() + self:OnBtnBackClick() + end + self.BtnMainUi.CallBack = function() + self:OnBtnMainUiClick() + end +end + +function XUiArchiveStory:InitTypeButton() + self.GroupList = XDataCenter.ArchiveManager.GetArchiveStoryGroupList() + self.CurType = 1 + self.StoryGroupBtn = {} + for _, v in pairs(self.GroupList) do + local btn = Object.Instantiate(self.BtnTabShortNew) + btn.gameObject:SetActive(true) + btn.transform:SetParent(self.TabBtnContent.transform, false) + local btncs = btn:GetComponent("XUiButton") + local name = v.Name + btncs:SetName(name or "Null") + + table.insert(self.StoryGroupBtn, btncs) + end + self.TabBtnContent:Init(self.StoryGroupBtn, function(index) self:SelectType(index) end) + self.BtnTabShortNew.gameObject:SetActiveEx(false) + self.TabBtnContent:SelectIndex(self.CurType) +end + +function XUiArchiveStory:SelectType(index) + self.CurType = index + self:SetupDynamicTable(self.GroupList[index].Id) + self:PlayAnimation("QieHuan") + self:ShowStoryRateInfo(index) +end + +function XUiArchiveStory:OnBtnBackClick() + self:Close() +end + +function XUiArchiveStory:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiArchiveStory:ShowStoryRateInfo(index) + local count = 0 + local maxCount = #self.PageDatas + for _,data in pairs(self.PageDatas) do + if not data:GetIsLock() then + count = count + 1 + end + end + self.TxtHaveCollectNum.text = count + self.TxtMaxCollectNum.text = maxCount + self.TitleText.text = self.GroupList[index].Name +end + +function XUiArchiveStory:OnCheckArchiveRedPoint() + +end + +function XUiArchiveStory:OnCheckArchiveTag() + +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArchive/XUiArchiveStoryDetail.lua b/Resources/Scripts/XUi/XUiArchive/XUiArchiveStoryDetail.lua new file mode 100644 index 00000000..f0ff89ec --- /dev/null +++ b/Resources/Scripts/XUi/XUiArchive/XUiArchiveStoryDetail.lua @@ -0,0 +1,132 @@ +local XUiArchiveStoryDetail = XLuaUiManager.Register(XLuaUi, "UiArchiveStoryDetail") +local FirstIndex = 1 + +function XUiArchiveStoryDetail:OnStart(dataList, index) + self:SetButtonCallBack() + self:InitDynamicTable() + self:Init(dataList, index) +end + +function XUiArchiveStoryDetail:OnDestroy() +end + +function XUiArchiveStoryDetail:Init(dataList, index) + local data = dataList and dataList[index] + if data then + self.Data = data + self.DataList = dataList + self.DataIndex = index + self.UnLockCount = 0 + self:SetupDynamicTable() + self:SetStoryData() + self:CheckNextMonsterAndPreMonster() + end +end + +function XUiArchiveStoryDetail:SetStoryData() + for _, story in pairs(self.PageDatas) do + if not story:GetIsLock() then + self.UnLockCount = self.UnLockCount + 1 + end + end + + self.StoryTitleTxt.text = self.Data:GetName() + self.LevelText.text = string.format("%d/%d", self.UnLockCount, #self.PageDatas) + local width = self.Data:GetBgWidth() ~= 0 and self.Data:GetBgWidth() or 1 + local high = self.Data:GetBgHigh() ~= 0 and self.Data:GetBgHigh() or 1 + self.StoryImgAspect.aspectRatio = width / high + self.StoryImg:SetRawImage(self.Data:GetBg()) +end + +function XUiArchiveStoryDetail:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.StoryChapterDetailScrollView) + self.DynamicTable:SetProxy(XUiGridArchiveStoryDetail) + self.DynamicTable:SetDelegate(self) + self.ChapterDetailItem.gameObject:SetActiveEx(false) +end + +function XUiArchiveStoryDetail:SetupDynamicTable() + self.PageDatas = XDataCenter.ArchiveManager.GetArchiveStoryDetailList(self.Data:GetId()) + self.DynamicTable:SetDataSource(self.PageDatas) + self.DynamicTable:ReloadDataSync(1) +end + +function XUiArchiveStoryDetail:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:UpdateGrid(self.PageDatas and self.PageDatas[index] or nil, self) + end +end + +function XUiArchiveStoryDetail:SetButtonCallBack() + self.BtnBack.CallBack = function() + self:OnBtnBackClick() + end + self.BtnMainUi.CallBack = function() + self:OnBtnMainUiClick() + end + self.BtnRight.CallBack = function() + self:OnBtnNextClick() + end + self.BtnLeft.CallBack = function() + self:OnBtnLastClick() + end +end + +function XUiArchiveStoryDetail:OnBtnBackClick() + self:Close() +end + +function XUiArchiveStoryDetail:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiArchiveStoryDetail:OnBtnNextClick() + if self.NextIndex == 0 then + return + end + self:Init(self.DataList, self.NextIndex) +end + +function XUiArchiveStoryDetail:OnBtnLastClick() + if self.PreviousIndex == 0 then + return + end + self:Init(self.DataList, self.PreviousIndex) +end + +function XUiArchiveStoryDetail:CheckNextMonsterAndPreMonster() + self.NextIndex = self:CheckNext(self.DataIndex + 1) + self.PreviousIndex = self:CheckPrevious(self.DataIndex - 1) + + if self.NextIndex == 0 then + self.NextIndex = self:CheckNext(FirstIndex) + end + + if self.PreviousIndex == 0 then + self.PreviousIndex = self:CheckPrevious(#self.DataList) + end +end + +function XUiArchiveStoryDetail:CheckNext(index) + local next = 0 + for i = index , #self.DataList , 1 do + local tmpData = self.DataList[i] + if tmpData and not tmpData:GetIsLock() then + next = i + break + end + end + return next +end + +function XUiArchiveStoryDetail:CheckPrevious(index) + local previous = 0 + for i = index , FirstIndex , -1 do + local tmpData = self.DataList[i] + if tmpData and not tmpData:GetIsLock() then + previous = i + break + end + end + return previous +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArchive/XUiArchiveStoryDialog.lua b/Resources/Scripts/XUi/XUiArchive/XUiArchiveStoryDialog.lua new file mode 100644 index 00000000..da95ae37 --- /dev/null +++ b/Resources/Scripts/XUi/XUiArchive/XUiArchiveStoryDialog.lua @@ -0,0 +1,70 @@ +local XUiArchiveStoryDialog = XLuaUiManager.Register(XLuaUi, "UiArchiveStoryDialog") +local CSTextManagerGetText = CS.XTextManager.GetText +local OneStory = 1 +local TwoStory = 2 + +function XUiArchiveStoryDialog:OnEnable() + +end + +function XUiArchiveStoryDialog:OnStart(data) + self.Data = data + self:Init() + self:SetButtonCallBack() +end + +function XUiArchiveStoryDialog:Init() + local title = self.Data:GetName() + if self.Data:GetSubName() then + local tmpText = string.gsub(self.Data:GetSubName(), "_", "-") + title = string.format("%s%s",tmpText,self.Data:GetName()) + end + self.TxtStoryDec.text = title + self.TxtStoryName.text = self.Data:GetDesc() + self.PlayType = #self.Data:GetStoryId() + if self.PlayType == TwoStory then + self.BtnEnterStoryBefore.gameObject:SetActiveEx(true) + self.BtnEnterStoryAfter.gameObject:SetActiveEx(true) + + self.BtnEnterStoryBefore:SetName(CSTextManagerGetText("PlayBeforeStory")) + self.BtnEnterStoryAfter:SetName(CSTextManagerGetText("PlayAfterStory")) + elseif self.PlayType == OneStory then + self.BtnEnterStoryBefore.gameObject:SetActiveEx(true) + self.BtnEnterStoryAfter.gameObject:SetActiveEx(false) + + self.BtnEnterStoryBefore:SetName(CSTextManagerGetText("PlayStory")) + else + self.BtnEnterStoryBefore.gameObject:SetActiveEx(false) + self.BtnEnterStoryAfter.gameObject:SetActiveEx(false) + end +end + +function XUiArchiveStoryDialog:SetButtonCallBack() + self.BtnMask.CallBack = function() + self:OnBtnBackClick() + end + + if self.PlayType == TwoStory then + self.BtnEnterStoryBefore.CallBack = function() + self:OnBtnPlayClick(1) + end + self.BtnEnterStoryAfter.CallBack = function() + self:OnBtnPlayClick(2) + end + + elseif self.PlayType == OneStory then + self.BtnEnterStoryBefore.CallBack = function() + self:OnBtnPlayClick(1) + end + end +end + +function XUiArchiveStoryDialog:OnBtnBackClick() + self:Close() +end + +function XUiArchiveStoryDialog:OnBtnPlayClick(index) + XDataCenter.MovieManager.PlayMovie(self.Data:GetStoryId(index)) +end + + diff --git a/Resources/Scripts/XUi/XUiArchive/XUiArchiveWeapon.lua b/Resources/Scripts/XUi/XUiArchive/XUiArchiveWeapon.lua new file mode 100644 index 00000000..58d34f78 --- /dev/null +++ b/Resources/Scripts/XUi/XUiArchive/XUiArchiveWeapon.lua @@ -0,0 +1,390 @@ +-- +-- Author: wujie +-- Note: 图鉴武器一级界面 + +local XUiArchiveWeapon = XLuaUiManager.Register(XLuaUi, "UiArchiveWeapon") +local XUiGridArchiveWeapon = require("XUi/XUiArchive/XUiGridArchiveWeapon") +local Object = CS.UnityEngine.Object + +local OwnStatusType = { + All = 1, + Owned = 2, + NotOwned = 3, +} + +local DrdSortIndexToType = { + OwnStatusType.All, + OwnStatusType.Owned, + OwnStatusType.NotOwned, +} + +local MinIndex = 1 + +function XUiArchiveWeapon:OnAwake() + XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + + self.IsHaveCallOnEnable = false + + self.EventIdWeaponRedPoint = XRedPointManager.AddRedPointEvent( + self.TabBtnGroup, + self.OnCheckWeaponRedPoint, + self, + { XRedPointConditions.Types.CONDITION_ARCHIVE_WEAPON_NEW_TAG, XRedPointConditions.Types.CONDITION_ARCHIVE_WEAPON_SETTING_RED }, + nil, + false + ) +end + +function XUiArchiveWeapon:OnStart() + self.IsStarAscendOrder = false + + self.SecondHierarchyFilterSelectIndex = self.DrdSort.value + 1 + self.WeaponDataDic = XArchiveConfigs.GetWeaponTypeToIdsDic() + + self:InitDynamicTable() + self:InitTabBtnGroup() + self:AutoAddListener() + + XRedPointManager.Check(self.EventIdWeaponRedPoint) + + self:UpdateOrderStatus(self.IsStarAscendOrder) +end + +function XUiArchiveWeapon:OnEnable() + if self.IsHaveCallOnEnable then + self.DynamicTable:ReloadDataASync() + return + end + self.IsHaveCallOnEnable = true +end + +function XUiArchiveWeapon:OnDestroy() + XDataCenter.ArchiveManager.HandleCanUnlockWeapon() + XDataCenter.ArchiveManager.HandleCanUnlockWeaponSetting() +end + +function XUiArchiveWeapon:InitTabBtnGroup() + self.TabBtnList = {} + self.BtnGroupTypeList = XArchiveConfigs.GetShowedWeaponTypeList() + for _, v in pairs(self.BtnGroupTypeList) do + local btn = Object.Instantiate(self.BtnTog) + btn.gameObject:SetActive(true) + btn.transform:SetParent(self.TabBtnGroup.transform, false) + local btncs = btn:GetComponent("XUiButton") + local name = XArchiveConfigs.GetWeaponGroupName(v) + btncs:SetName(name or "") + table.insert(self.TabBtnList, btncs) + end + self.TabBtnGroup:Init(self.TabBtnList, handler(self, self.OnTabBtnGroupClick)) + + self.TabBtnTypeDic = {} + local weaponType + for i, btn in ipairs(self.TabBtnList) do + weaponType = self.BtnGroupTypeList[i] + self.TabBtnTypeDic[weaponType] = btn + end + + self.TabBtnGroup:SelectIndex(1) + self:SaveCollectionDefaultData() +end + +function XUiArchiveWeapon:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelDynamicTable) + self.DynamicTable:SetProxy(XUiGridArchiveWeapon) + self.DynamicTable:SetDelegate(self) +end + +function XUiArchiveWeapon:AutoAddListener() + self.BtnBack.CallBack = function() self:Close() end + self.BtnMainUi.CallBack = function() XLuaUiManager.RunMain() end + + self.DrdSort.onValueChanged:AddListener(function() + local CSArrayIndexToLuaTableIndex = function(index) return index + 1 end + self:OnDrdSortClick(CSArrayIndexToLuaTableIndex(self.DrdSort.value)) + end) + + self.BtnOrder.CallBack = function() self:OnBtnOrderClick() end +end + +-- function XUiArchiveWeapon:OnPlayAnimation() +-- -- self:PlayAnimation("AnimStartEnable") +-- end +-- 第一层判断 +function XUiArchiveWeapon:FirstHierarchyFilter(originDataList, filterType) + return originDataList[filterType] or {} +end + +-- 第二层判断 +function XUiArchiveWeapon:SecondHierarchyFilter(firstHierarchyFilterDataList, filterType) + local dataList = {} + if filterType == OwnStatusType.All then + return firstHierarchyFilterDataList + elseif filterType == OwnStatusType.Owned then + for _, templateId in ipairs(firstHierarchyFilterDataList) do + if XDataCenter.ArchiveManager.IsWeaponGet(templateId) then + table.insert(dataList, templateId) + end + end + elseif filterType == OwnStatusType.NotOwned then + for _, templateId in ipairs(firstHierarchyFilterDataList) do + if not XDataCenter.ArchiveManager.IsWeaponGet(templateId) then + table.insert(dataList, templateId) + end + end + end + + return dataList +end + +-- 按星级高低顺序来排序,默认降序(可变为升序),在此之下默认TemplateId排序 +function XUiArchiveWeapon:SortEquipDataList(dataList, isAscendOrder) + if not dataList then return end + if isAscendOrder then + table.sort(dataList, function(aId, bId) + local aTemplateData = XEquipConfig.GetEquipCfg(aId) + local bTemplateData = XEquipConfig.GetEquipCfg(bId) + + local aPriority = aTemplateData.Priority + local bPriority = bTemplateData.Priority + + local aStar = aTemplateData.Star + local bStar = bTemplateData.Star + + if aStar == bStar then + return aPriority < bPriority + else + return aStar < bStar + end + end) + else + table.sort(dataList, function(aId, bId) + local aTemplateData = XEquipConfig.GetEquipCfg(aId) + local bTemplateData = XEquipConfig.GetEquipCfg(bId) + + local aPriority = aTemplateData.Priority + local bPriority = bTemplateData.Priority + + local aStar = aTemplateData.Star + local bStar = bTemplateData.Star + + if aStar == bStar then + return aPriority > bPriority + else + return aStar > bStar + end + end) + end +end + +function XUiArchiveWeapon:ResetDrdSort() + local selectIndex = 1 + for index, filterType in ipairs(DrdSortIndexToType) do + if filterType == OwnStatusType.All then + selectIndex = index + break + end + end + self.DrdSort.value = selectIndex - 1 +end + +--排序按钮状态 +function XUiArchiveWeapon:UpdateOrderStatus(isAscendOrder) + self.ImgAscend.gameObject:SetActiveEx(isAscendOrder) + self.ImgDescend.gameObject:SetActiveEx(not isAscendOrder) +end + +--设置动态列表 +function XUiArchiveWeapon:UpdateDynamicTable() + self:PlayAnimation("QieHuan") + self.DynamicTableDataList = self.DynamicTableDataList or {} + local isEmpty = #self.DynamicTableDataList == 0 + self.DynamicTable:SetDataSource(self.DynamicTableDataList) + self.DynamicTable:ReloadDataASync(isEmpty and -1 or 1) + self.PanelEmpty.gameObject:SetActiveEx(isEmpty) +end + +function XUiArchiveWeapon:UpdateCollection() + local selectEquipType = self.BtnGroupTypeList[self.FirstHierarchyFilterSelectIndex] + self.TxtCollectionDesc.text = XArchiveConfigs.GetWeaponGroupName(selectEquipType) + + local sumNum = #self.FirstHierarchyFilterDataList + if sumNum == 0 then + self.TxtCollectionRate.text = 0 + return + end + + local collectionNum = 0 + for _, templateId in ipairs(self.FirstHierarchyFilterDataList) do + if XDataCenter.ArchiveManager.IsWeaponGet(templateId) then + collectionNum = collectionNum + 1 + end + end + local percentNum = math.floor(collectionNum * 100 / sumNum) + self.TxtCollectionRate.text = percentNum +end + +function XUiArchiveWeapon:UpdateAchievement() + local selectEquipType = self.BtnGroupTypeList[self.FirstHierarchyFilterSelectIndex] + local groupData = XArchiveConfigs.GetWeaponGroupByType(selectEquipType) + local needCollectNumList = groupData.CollectNum + local achievementNum = needCollectNumList and #needCollectNumList or 0 + + local haveCollectNum = 0 + for _, templateId in ipairs(self.FirstHierarchyFilterDataList) do + if XDataCenter.ArchiveManager.IsWeaponGet(templateId) then + haveCollectNum = haveCollectNum + 1 + end + end + + local nextAchievementIndex = 0 + local needCollectNum = 0 + for i = 1, achievementNum do + needCollectNum = needCollectNumList[i] + if haveCollectNum < needCollectNum then + break + end + nextAchievementIndex = i + end + self:CheckLevelUp(selectEquipType,nextAchievementIndex,groupData) + + self.LockedAchievement.gameObject:SetActiveEx(achievementNum ~= 0 and nextAchievementIndex == 0) + nextAchievementIndex = math.max(MinIndex, nextAchievementIndex) + + local content = groupData.CollectionContent[nextAchievementIndex] + self.TxtAchievementName.text = content or self.TxtAchievementName.text + + local iconPath = groupData.IconPath[nextAchievementIndex] + if iconPath then + self.RImgAchievementIcon:SetRawImage(iconPath) + self.RImgAchievementIcon.gameObject:SetActiveEx(true) + else + self.RImgAchievementIcon.gameObject:SetActiveEx(false) + end + + haveCollectNum = math.min(haveCollectNum, needCollectNum) + self.TxtHaveCollectNum.text = haveCollectNum + self.TxtNeedCollectNum.text = needCollectNum + + local IsCountShow = haveCollectNum ~= needCollectNum + self.TxtHaveCollectNum.gameObject:SetActiveEx(IsCountShow) + +end + +function XUiArchiveWeapon:SaveCollectionDefaultData() + for _,type in pairs(self.BtnGroupTypeList) do + local groupData = XArchiveConfigs.GetWeaponGroupByType(type) + local needCollectNumList = groupData.CollectNum + local achievementNum = needCollectNumList and #needCollectNumList or 0 + + local haveCollectNum = 0 + local dataList = self:FirstHierarchyFilter(self.WeaponDataDic, type) + for _, templateId in ipairs(dataList) do + if XDataCenter.ArchiveManager.IsWeaponGet(templateId) then + haveCollectNum = haveCollectNum + 1 + end + end + + local nextAchievementIndex = 0 + local needCollectNum + for i = 1, achievementNum do + needCollectNum = needCollectNumList[i] + if haveCollectNum < needCollectNum then + break + end + nextAchievementIndex = i + end + XDataCenter.ArchiveManager.SaveWeaponsCollectionDefaultData(type,nextAchievementIndex) + end +end + +function XUiArchiveWeapon:CheckLevelUp(selectEquipType,level,groupData) + local IsLevel,OldLevel = XDataCenter.ArchiveManager.CheckWeaponsCollectionLevelUp(selectEquipType,level) + if IsLevel then + local firstIndex = 1 + local levelData = {} + levelData.Level = OldLevel + levelData.OldIcon = groupData.IconPath[OldLevel] or groupData.IconPath[firstIndex] + levelData.CurIcon = groupData.IconPath[level] + levelData.OldText = groupData.CollectionTitle[OldLevel] or groupData.IconPath[firstIndex] + levelData.CurText = groupData.CollectionTitle[level] + XLuaUiManager.Open("UiArchiveWeaponsCollectionTips", levelData) + end +end + +-----------------------------------事件相关----------------------------------------->>> +function XUiArchiveWeapon:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:InitRootUi(self) + grid:SetClickCallback(handler(self, self.OnGridClick)) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:Refresh(self.DynamicTableDataList,index) + end +end + +function XUiArchiveWeapon:OnGridClick(templateIdList,index) + XLuaUiManager.Open("UiArchiveWeaponDetail", templateIdList,index) +end + +function XUiArchiveWeapon:OnTabBtnGroupClick(index) + if self.FirstHierarchyFilterSelectIndex == index then return end + + if self.FirstHierarchyFilterSelectIndex then + local oldFilterType = self.BtnGroupTypeList[self.FirstHierarchyFilterSelectIndex] + XDataCenter.ArchiveManager.HandleCanUnlockWeaponByWeaponType(oldFilterType) + XDataCenter.ArchiveManager.HandleCanUnlockWeaponSettingByWeaponType(oldFilterType) + end + + local filterType = self.BtnGroupTypeList[index] + self.DynamicTableDataList = self:FirstHierarchyFilter(self.WeaponDataDic, filterType) + self.FirstHierarchyFilterDataList = self.DynamicTableDataList + self.FirstHierarchyFilterSelectIndex = index + + self:UpdateCollection() + self:UpdateAchievement() + + if DrdSortIndexToType[self.SecondHierarchyFilterSelectIndex] == OwnStatusType.All then + self:SortEquipDataList(self.DynamicTableDataList, self.IsStarAscendOrder) + self:UpdateDynamicTable() + else + self:ResetDrdSort() + end +end + +function XUiArchiveWeapon:OnDrdSortClick(index) + if self.SecondHierarchyFilterSelectIndex == index then return end + + if self.FirstHierarchyFilterDataList then + self.DynamicTableDataList = self:SecondHierarchyFilter(self.FirstHierarchyFilterDataList, DrdSortIndexToType[index]) + end + self.SecondHierarchyFilterSelectIndex = index + + self:SortEquipDataList(self.DynamicTableDataList, self.IsStarAscendOrder) + self:UpdateDynamicTable() +end + +function XUiArchiveWeapon:OnBtnOrderClick() + self.IsStarAscendOrder = not self.IsStarAscendOrder + self:UpdateOrderStatus(self.IsStarAscendOrder) + self:SortEquipDataList(self.DynamicTableDataList, self.IsStarAscendOrder) + self:UpdateDynamicTable() +end + +-- 有new标签时显示new标签,如果只有红点显示红点,红点和new标签同时存在则只显示new标签 +function XUiArchiveWeapon:OnCheckWeaponRedPoint() + local btn + local isShowTag + for type, _ in pairs(self.WeaponDataDic) do + btn = self.TabBtnTypeDic[type] + if btn then + isShowTag = XDataCenter.ArchiveManager.IsHaveNewWeaponByWeaponType(type) + if isShowTag then + btn:ShowTag(true) + btn:ShowReddot(false) + else + btn:ShowTag(false) + btn:ShowReddot(XDataCenter.ArchiveManager.IsHaveNewWeaponSettingByWeaponType(type)) + end + end + end +end +-----------------------------------事件相关-----------------------------------------<<< \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArchive/XUiArchiveWeaponAchievement.lua b/Resources/Scripts/XUi/XUiArchive/XUiArchiveWeaponAchievement.lua new file mode 100644 index 00000000..77cddac7 --- /dev/null +++ b/Resources/Scripts/XUi/XUiArchive/XUiArchiveWeaponAchievement.lua @@ -0,0 +1,62 @@ + +-- +-- Author: wujie +-- Note: 图鉴武器成就系统 + +local XUiArchiveWeaponAchievement = XLuaUiManager.Register(XLuaUi, "UiArchiveWeaponAchievement") + +local XUiGridArchiveWeaponAchievement = require("XUi/XUiArchive/XUiGridArchiveWeaponAchievement") + +function XUiArchiveWeaponAchievement:OnAwake() + self.GridCollectionList = { + XUiGridArchiveWeaponAchievement.New(self.GridCollection1), + XUiGridArchiveWeaponAchievement.New(self.GridCollection2), + XUiGridArchiveWeaponAchievement.New(self.GridCollection3), + } + for _, grid in ipairs(self.GridCollectionList) do + grid:SetClickCallback(handler(self, self.OnGridClick)) + end + + self:AutoAddListener() +end + +function XUiArchiveWeaponAchievement:OnStart(parent) + self.Parent = parent +end + +function XUiArchiveWeaponAchievement:OnEnable() + if not self.Parent then return end + local type = self.Parent.BtnGroupTypeList[self.Parent.FirstHierarchyFilterSelectIndex] + local idList = XArchiveConfigs.GetWeaponTemplateIdListByType(type) + local haveCollectNum = 0 + for _, templateId in pairs(idList) do + if XDataCenter.ArchiveManager.IsWeaponGet(templateId) then + haveCollectNum = haveCollectNum + 1 + end + end + + local groupData = XArchiveConfigs.GetWeaponGroupByType(type) + local achievementNum = #groupData.CollectNum + + for i, grid in ipairs(self.GridCollectionList) do + if i > achievementNum then + grid.GameObject:SetActiveEx(false) + else + grid.GameObject:SetActiveEx(true) + grid:Refresh(groupData, i, haveCollectNum) + end + end +end + +function XUiArchiveWeaponAchievement:AutoAddListener() + self.BtnClose.CallBack = function() self:Close() end + self.BtnBg.CallBack = function() self:Close() end +end + +-----------------------------------事件相关----------------------------------------->>> +function XUiArchiveWeaponAchievement:OnGridClick(cgId) + if cgId and cgId ~= 0 then + XDataCenter.MovieManager.PlayMovie(cgId) + end +end +-----------------------------------事件相关-----------------------------------------<<< \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArchive/XUiArchiveWeaponDetail.lua b/Resources/Scripts/XUi/XUiArchive/XUiArchiveWeaponDetail.lua new file mode 100644 index 00000000..0de62f8e --- /dev/null +++ b/Resources/Scripts/XUi/XUiArchive/XUiArchiveWeaponDetail.lua @@ -0,0 +1,290 @@ + +-- +-- Author: wujie +-- Note: 图鉴武器详情界面 + +local XUiArchiveWeaponDetail = XLuaUiManager.Register(XLuaUi, "UiArchiveWeaponDetail") + +local XUiGridArchiveEquipSetting = require("XUi/XUiArchive/XUiGridArchiveEquipSetting") + +local delayTime = CS.XGame.ClientConfig:GetInt("ArchiveWeaponShowDelayTime") + +local FirstIndex = 1 + +function XUiArchiveWeaponDetail:OnAwake() + XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + + self:InitBtnGroup() + + self.LeftRightIndex = 0 + self.LeftRightMax = 1 + self.LeftRightMin = 1 + + self.IsSettingOpen = false + + self.GridSettingList = { + XUiGridArchiveEquipSetting.New(self.GridSetting1), + XUiGridArchiveEquipSetting.New(self.GridSetting2), + XUiGridArchiveEquipSetting.New(self.GridSetting3), + XUiGridArchiveEquipSetting.New(self.GridSetting4), + XUiGridArchiveEquipSetting.New(self.GridSetting5), + } + + self.GridStoryList = { + XUiGridArchiveEquipSetting.New(self.GridStory1), + XUiGridArchiveEquipSetting.New(self.GridStory2), + XUiGridArchiveEquipSetting.New(self.GridStory3), + XUiGridArchiveEquipSetting.New(self.GridStory4), + XUiGridArchiveEquipSetting.New(self.GridStory5), + } + + self:AutoAddListener() +end + +function XUiArchiveWeaponDetail:OnStart(templateIdList,index) + self:InitScene3DRoot() + self:Init(templateIdList,index) +end + +function XUiArchiveWeaponDetail:Init(templateIdList,index) + local templateId = templateIdList[index] + if not templateId then + return + end + self.TemplateId = templateId + self.TemplateIdList = templateIdList + self.TemplateIndex = index + + if XDataCenter.ArchiveManager.IsNewWeapon(templateId) then + XDataCenter.ArchiveManager.RequestUnlockWeapon({templateId}) + end + + self:UpdateResume() + self:UpdateSetting() + self:UpdateSkill() + self:UpdateSwitch() + self:CheckNextMonsterAndPreMonster() +end + +function XUiArchiveWeaponDetail:OnDestroy() + self.Scene3DRoot.PanelWeaponPlane.gameObject:SetActiveEx(true) +end + +function XUiArchiveWeaponDetail:InitBtnGroup() + self.BtnSwitchModelList = { + self.BtnSwitchModel1, + self.BtnSwitchModel2, + self.BtnSwitchModel3, + self.BtnSwitchModel4, + } + self.BtnGroupSwitchModel:Init(self.BtnSwitchModelList, handler(self,self.OnTabBtnGroupClick)) +end + +function XUiArchiveWeaponDetail:InitScene3DRoot() + if self.Scene3DRoot then return end + self.Scene3DRoot = {} + local root = self.Scene3DRoot + local sceneRoot = self.UiSceneInfo.Transform + root.Transform = sceneRoot + root.AutoRationPanel = self.UiModelGo:FindTransform("PanelWeapon"):GetComponent(typeof(CS.XAutoRotation)) + root.PanelEffect = self.UiModelGo:FindTransform("EffectGo") + root.PanelWeaponPlane = sceneRoot:FindTransform("Plane") + root.PanelWeaponPlane.gameObject:SetActiveEx(false) +end + +function XUiArchiveWeaponDetail:AutoAddListener() + self.BtnBack.CallBack = function() self:Close() end + self.BtnMainUi.CallBack = function() XLuaUiManager.RunMain() end + self.BtnNext.CallBack = function() + self:OnBtnNextClick() + end + self.BtnLast.CallBack = function() + self:OnBtnLastClick() + end +end + +function XUiArchiveWeaponDetail:UpdateWeaponModel(modelConfig) + local root = self.Scene3DRoot + XScheduleManager.ScheduleOnce(function() + XModelManager.LoadWeaponModel(modelConfig.ModelId, root.AutoRationPanel.transform, modelConfig.TransformConfig, self.Name, function(model) + model.gameObject:SetActiveEx(true) + local panelEffect = root.PanelEffect + panelEffect.gameObject:SetActiveEx(false) + panelEffect.gameObject:SetActiveEx(true) + end, {gameObject = self.GameObject}) + end, delayTime) +end + +function XUiArchiveWeaponDetail:UpdateResume() + local templateId = self.TemplateId + local weaponName = XDataCenter.EquipManager.GetEquipName(templateId) + self.TxtWeaponNameHorizontal.text = weaponName + self.TxtWeaponNameVertical.text = weaponName + self.TxtWeaponMaxLv.text = XDataCenter.EquipManager.GetEquipMaxLevel(templateId) + self.TxtWeaponMaxBreakthrough.text = XDataCenter.EquipManager.GetEquipMaxBreakthrough(templateId) +end + +function XUiArchiveWeaponDetail:UpdateSetting() + local templateId = self.TemplateId + XRedPointManager.CheckOnce(self.OnCheckRedPoint, self, {XRedPointConditions.Types.CONDITION_ARCHIVE_WEAPON_SETTING_RED}, templateId) + local newSettingIdList = XDataCenter.ArchiveManager.GetNewWeaponSettingIdList(templateId) + if newSettingIdList and #newSettingIdList > 0 then + XDataCenter.ArchiveManager.RequestUnlockWeaponSetting(newSettingIdList) + end + + local settingDataList = XArchiveConfigs.GetWeaponSettingList(templateId) + local settingType + local showedSettingCount = 0 + local showedStoryCount = 0 + local grid + for _, settingData in ipairs(settingDataList) do + settingType = settingData.Type + if settingType == XArchiveConfigs.SettingType.Setting then + showedSettingCount = showedSettingCount + 1 + grid = self.GridSettingList[showedSettingCount] + if grid then + grid:Refresh(XArchiveConfigs.SubSystemType.Weapon, settingData) + grid.GameObject:SetActiveEx(true) + else + local path = XArchiveConfigs.GetWeaponSettingPath() + local tempStr = "XUiArchiveWeaponDetail:UpdateSetting函数错误,武器数据个数大于显示结点个数, weaponid Id是 " + XLog.Error(tempStr .. templateId .. ", settingid is " .. settingData.Id .. "weapon setting表路径是" .. path) + end + elseif settingType == XArchiveConfigs.SettingType.Story then + showedStoryCount = showedStoryCount + 1 + grid = self.GridStoryList[showedStoryCount] + if grid then + grid:Refresh(XArchiveConfigs.SubSystemType.Weapon, settingData) + grid.GameObject:SetActiveEx(true) + else + local path = XArchiveConfigs.GetWeaponSettingPath() + local tempStr = "XUiArchiveWeaponDetail:UpdateSetting函数错误,武器数据个数大于显示结点个数, weaponid Id是 " + XLog.Error(tempStr .. templateId .. ", settingid is " .. settingData.Id .. "weapon setting表路径是" .. path) + end + end + end + + if showedSettingCount == 0 then + self.PanelSetting.gameObject:SetActiveEx(false) + else + self.PanelSetting.gameObject:SetActiveEx(true) + for i = showedSettingCount+1, #self.GridSettingList do + self.GridSettingList[i].GameObject:SetActiveEx(false) + end + end + + if showedStoryCount == 0 then + self.PanelStory.gameObject:SetActiveEx(false) + else + self.PanelStory.gameObject:SetActiveEx(true) + for i = showedStoryCount+1, #self.GridStoryList do + self.GridStoryList[i].GameObject:SetActiveEx(false) + end + end + + CS.UnityEngine.UI.LayoutRebuilder.ForceRebuildLayoutImmediate(self.PanelSettingContent) +end + +function XUiArchiveWeaponDetail:UpdateSkill() + local weaponSkillInfo = XDataCenter.EquipManager.GetOriginWeaponSkillInfo(self.TemplateId) + if weaponSkillInfo.Name and weaponSkillInfo.Description then + self.PanelNoSkill.gameObject:SetActiveEx(false) + self.PanelSkill.gameObject:SetActiveEx(true) + self.TxtSkillName.text = weaponSkillInfo.Name + self.TxtSkillDesc.text = weaponSkillInfo.Description + else + self.PanelNoSkill.gameObject:SetActiveEx(true) + self.PanelSkill.gameObject:SetActiveEx(false) + end +end + +function XUiArchiveWeaponDetail:UpdateSwitch() + self.ModelCfgList = XEquipConfig.GetWeaponModelCfgList(self.TemplateId, self.Name, 0) + local modelCount = #self.ModelCfgList + + self.Scene3DRoot.PanelWeaponPlane.gameObject:SetActiveEx(modelCount == 0) + + local firstModelIndex = 1 + if modelCount <= firstModelIndex then + self.PanelWeaponSwitch.gameObject:SetActiveEx(false) + if modelCount == firstModelIndex then + self:UpdateWeaponModel(self.ModelCfgList[firstModelIndex]) + end + else + self.PanelWeaponSwitch.gameObject:SetActiveEx(true) + self.SelectWeaponIndex = nil + for i, btn in ipairs(self.BtnSwitchModelList) do + btn.gameObject:SetActiveEx(i <= modelCount) + end + if not self.SelectWeaponIndex and modelCount > 0 then + self.BtnGroupSwitchModel:SelectIndex(1) + end + end +end + +function XUiArchiveWeaponDetail:OnBtnNextClick() + if self.NextIndex == 0 then + return + end + self:Init(self.TemplateIdList,self.NextIndex) +end + +function XUiArchiveWeaponDetail:OnBtnLastClick() + if self.PreviousIndex == 0 then + return + end + self:Init(self.TemplateIdList,self.PreviousIndex) +end + +function XUiArchiveWeaponDetail:CheckNextMonsterAndPreMonster() + self.NextIndex = self:CheckIndex(self.TemplateIndex + 1) + self.PreviousIndex = self:CheckIndex(self.TemplateIndex - 1) + + if self.NextIndex == 0 then + self.NextIndex = self:CheckIndex(FirstIndex) + end + + if self.PreviousIndex == 0 then + self.PreviousIndex = self:CheckIndex(#self.TemplateIdList) + end +end + +function XUiArchiveWeaponDetail:CheckIndex(index) + return self.TemplateIdList[index] and index or 0 +end + +-----------------------------------事件相关----------------------------------------->>> +-- 切换武器形态 +function XUiArchiveWeaponDetail:OnTabBtnGroupClick(index) + if self.SelectWeaponIndex == index or not self.ModelCfgList or #self.ModelCfgList <= 1 then return end + self.SelectWeaponIndex = index + self:UpdateWeaponModel(self.ModelCfgList[index]) +end + +function XUiArchiveWeaponDetail:OnCheckRedPoint(count) + if count < 0 then + self.PanelSettingRedPoint.gameObject:SetActiveEx(false) + self.PanelStoryRedPoint.gameObject:SetActiveEx(false) + else + local newSettingIdList = XDataCenter.ArchiveManager.GetNewWeaponSettingIdList(self.TemplateId) + if newSettingIdList then + local type + local isShowSettingReddot = false + local isShowStoryReddot = false + for _, id in ipairs(newSettingIdList) do + type = XArchiveConfigs.GetWeaponSettingType(id) + if type == XArchiveConfigs.SettingType.Setting then + isShowSettingReddot = true + elseif type == XArchiveConfigs.SettingType.Story then + isShowStoryReddot = true + end + end + self.PanelSettingRedPoint.gameObject:SetActiveEx(isShowSettingReddot) + self.PanelStoryRedPoint.gameObject:SetActiveEx(isShowStoryReddot) + else + self.PanelSettingRedPoint.gameObject:SetActiveEx(false) + self.PanelStoryRedPoint.gameObject:SetActiveEx(false) + end + end +end +-----------------------------------事件相关-----------------------------------------<<< \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArchive/XUiArchiveWeaponsCollectionTips.lua b/Resources/Scripts/XUi/XUiArchive/XUiArchiveWeaponsCollectionTips.lua new file mode 100644 index 00000000..c46d840c --- /dev/null +++ b/Resources/Scripts/XUi/XUiArchive/XUiArchiveWeaponsCollectionTips.lua @@ -0,0 +1,28 @@ +local XUiArchiveWeaponsCollectionTips = XLuaUiManager.Register(XLuaUi, "UiArchiveWeaponsCollectionTips") +local FirstLevel = 0 +function XUiArchiveWeaponsCollectionTips:OnStart(data) + self.Data = data + self:AutoAddListener() +end + +function XUiArchiveWeaponsCollectionTips:OnEnable() + if not self.Data then return end + self.RImgOldIconLock.gameObject:SetActiveEx(self.Data.Level == FirstLevel) + self.RImgOldIcon.gameObject:SetActiveEx(self.Data.Level ~= FirstLevel) + self.RImgOldTitleText.gameObject:SetActiveEx(self.Data.Level ~= FirstLevel) + + if self.Data.OldIcon then + self.RImgOldIcon:SetRawImage(self.Data.OldIcon) + self.RImgOldIconLock:SetRawImage(self.Data.OldIcon) + end + if self.Data.CurIcon then + self.RImgCurIcon:SetRawImage(self.Data.CurIcon) + end + + self.RImgOldTitleText.text = self.Data.OldText or "" + self.RImgCurTitleText.text = self.Data.CurText or "" +end + +function XUiArchiveWeaponsCollectionTips:AutoAddListener() + self.BtnClose.CallBack = function() self:Close() end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArchive/XUiGridArchive.lua b/Resources/Scripts/XUi/XUiArchive/XUiGridArchive.lua new file mode 100644 index 00000000..f04f25e0 --- /dev/null +++ b/Resources/Scripts/XUi/XUiArchive/XUiGridArchive.lua @@ -0,0 +1,106 @@ +XUiGridArchive = XClass(nil, "XUiGridArchive") + +function XUiGridArchive:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:SetButtonCallBack() +end + +function XUiGridArchive:AddRedPointEvent(type) + if type == XArchiveConfigs.SubSystemType.Monster then + XRedPointManager.AddRedPointEvent(self.ArchiveBtn, + self.OnCheckArchiveRedPoint, + self, + { XRedPointConditions.Types.CONDITION_ARCHIVE_MONSTER_ALL }) + elseif type == XArchiveConfigs.SubSystemType.Weapon then + XRedPointManager.AddRedPointEvent(self.ArchiveBtn, + self.OnCheckArchiveRedPoint, + self, + { XRedPointConditions.Types.CONDITION_ARCHIVE_WEAPON }) + elseif type == XArchiveConfigs.SubSystemType.Awareness then + XRedPointManager.AddRedPointEvent(self.ArchiveBtn, + self.OnCheckArchiveRedPoint, + self, + { XRedPointConditions.Types.CONDITION_ARCHIVE_AWARENESS }) + elseif type == XArchiveConfigs.SubSystemType.CG then + XRedPointManager.AddRedPointEvent(self.ArchiveBtn, + self.OnCheckArchiveRedPoint, + self, + { XRedPointConditions.Types.CONDITION_ARCHIVE_CG_ALL }) + end + +end + +function XUiGridArchive:SetButtonCallBack() + self.ArchiveBtn.CallBack = function() + self:OnBtnSelect() + end +end + +function XUiGridArchive:OnBtnSelect() + if self.SkipId then + XFunctionManager.SkipInterface(self.SkipId) + end +end + +function XUiGridArchive:UpdateGrid(chapter, parent, type) + self.Base = parent + self:SetArchiveData(chapter) + self:SetCompletionRate(type) + self:CheckLock() +end + +function XUiGridArchive:CheckLock() + local IsLock = true + local SkipFunctional = XFunctionConfig.GetSkipList(self.SkipId) + if SkipFunctional then + IsLock = not XFunctionManager.JudgeCanOpen(SkipFunctional.FunctionalId) + end + self:ShowLock(IsLock) +end + +function XUiGridArchive:ShowLock(Lock) + self.LockedGroup.gameObject:SetActiveEx(Lock) + self.UnLockedGroup.gameObject:SetActiveEx(not Lock) +end + +function XUiGridArchive:OnCheckArchiveRedPoint(count) + self.ArchiveBtn:ShowReddot(count >= 0) +end + +function XUiGridArchive:SetArchiveData(chapter) + self.SkipId = chapter.SkipId + self.ArchiveTitle.text = chapter.Name + self.ProgressText.text = chapter.TagText + + self.GridTemplateTitle.gameObject:SetActiveEx(chapter.ShowTag > 0) + + if chapter.lockBg and #chapter.lockBg > 0 then + self.LockedArchiveImg:SetRawImage(chapter.lockBg) + end + if chapter.UnLockBg and #chapter.UnLockBg > 0 then + self.UnLockedArchiveImg:SetRawImage(chapter.UnLockBg) + end +end + +function XUiGridArchive:SetCompletionRate(type) + local rate = 0 + if type == XArchiveConfigs.SubSystemType.Monster then + rate = XDataCenter.ArchiveManager.GetMonsterCompletionRate() + elseif type == XArchiveConfigs.SubSystemType.Weapon then + rate = XDataCenter.ArchiveManager.GetWeaponCollectRate() + elseif type == XArchiveConfigs.SubSystemType.Awareness then + rate = XDataCenter.ArchiveManager.GetAwarenessCollectRate() + elseif type == XArchiveConfigs.SubSystemType.Story then + rate = XDataCenter.ArchiveManager.GetStoryCollectRate() + elseif type == XArchiveConfigs.SubSystemType.CG then + rate = XDataCenter.ArchiveManager.GetCGCompletionRate() + elseif type == XArchiveConfigs.SubSystemType.NPC then + rate = XDataCenter.ArchiveManager.GetNPCCompletionRate() + elseif type == XArchiveConfigs.SubSystemType.Partner then + rate = XDataCenter.ArchiveManager.GetPartnerCompletionRate() + end + self.ProgressNub.text = string.format("%d%s", rate, "%") + self.ProgressSlider.value = rate / 100 +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArchive/XUiGridArchiveAwareness.lua b/Resources/Scripts/XUi/XUiArchive/XUiGridArchiveAwareness.lua new file mode 100644 index 00000000..2bdc484b --- /dev/null +++ b/Resources/Scripts/XUi/XUiArchive/XUiGridArchiveAwareness.lua @@ -0,0 +1,137 @@ +-- +-- Author: wujie +-- Note: 图鉴意识一级界面的格子 +local XUiGridArchiveAwareness = XClass(nil, "XUiGridArchiveAwareness") + +function XUiGridArchiveAwareness:Ctor(ui, clickCb, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self.ClickCb = clickCb + + XTool.InitUiObject(self) + + self.ImgGirdStarList = { + self.ImgGirdStar1, + self.ImgGirdStar2, + self.ImgGirdStar3, + self.ImgGirdStar4, + self.ImgGirdStar5, + self.ImgGirdStar6, + } + + self.BtnClick.CallBack = function() self:OnBtnClick() end +end + +function XUiGridArchiveAwareness:InitRootUi(rootUi) + self.RootUi = rootUi +end + +function XUiGridArchiveAwareness:SetClickCallback(callback) + self.ClickCb = callback +end + +function XUiGridArchiveAwareness:UpdateStar() + local star = XDataCenter.EquipManager.GetSuitStar(self.SuitId) + for i = 1, XEquipConfig.MAX_STAR_COUNT do + if self.ImgGirdStarList[i] then + self.ImgGirdStarList[i].gameObject:SetActiveEx(i <= star) + end + end +end + +function XUiGridArchiveAwareness:UpdateCollectedCount() + local suitId = self.SuitId + local templateIdList = XEquipConfig.GetEquipTemplateIdsBySuitId(suitId) + local sumCount = #templateIdList + local curCount = XDataCenter.ArchiveManager.GetAwarenessCountBySuitId(suitId) + self.TxtSumCount.text = sumCount + self.TxtCurCount.text = curCount +end + +function XUiGridArchiveAwareness:Refresh(dataList,index) + local data = dataList and dataList[index] + if not data then + return + end + self.Data = data + local suitId = data.Id + self.SuitId = suitId + self.SuitIdList = {} + + for dataIndex,tmpData in pairs(dataList) do + self.SuitIdList[dataIndex] = tmpData.Id + end + + self.DataIndex = index + + local isBigIcon = true + if self.RImgIcon then + if XEquipConfig.IsDefaultSuitId(suitId) then + self.RImgIcon.gameObject:SetActiveEx(false) + else + local icon + if isBigIcon then + icon = XDataCenter.EquipManager.GetSuitBigIconBagPath(suitId) + else + icon = XDataCenter.EquipManager.GetSuitIconBagPath(suitId) + end + + self.RImgIcon:SetRawImage(icon) + self.RImgIcon.gameObject:SetActiveEx(true) + end + end + + --装备专用的竖条品质色 + if self.ImgEquipQuality then + self.RootUi:SetUiSprite(self.ImgEquipQuality, XDataCenter.EquipManager.GetSuitQualityIcon(suitId)) + end + + if self.TxtName then + self.TxtName.text = XDataCenter.EquipManager.GetSuitName(suitId) + end + + if self.Data.Add and #self.Data.Add > 0 then + self.TxtActivity.text = self.Data.Add + self.TxtActivity.gameObject:SetActiveEx(true) + else + self.TxtActivity.gameObject:SetActiveEx(false) + end + + + self:UpdateStar() + self:UpdateCollectedCount() + XRedPointManager.CheckOnce( + self.OnCheckRedPoint, + self, + { XRedPointConditions.Types.CONDITION_ARCHIVE_AWARENESS_GRID_NEW_TAG, XRedPointConditions.Types.CONDITION_ARCHIVE_AWARENESS_SETTING_RED }, + self.SuitId + ) +end + +-----------------------------------事件相关----------------------------------------->>> +function XUiGridArchiveAwareness:OnBtnClick() + if self.ClickCb then + self.ClickCb(self.SuitIdList,self.DataIndex, self) + end +end + +-- 有new标签时显示new标签,如果只有红点显示红点,红点和new标签同时存在则只显示new标签 +function XUiGridArchiveAwareness:OnCheckRedPoint(count) + local suitId = self.SuitId + if count < 0 or not suitId then + self.PanelNewTag.gameObject:SetActiveEx(false) + self.PanelRedPoint.gameObject:SetActiveEx(false) + else + local isShowTag = XDataCenter.ArchiveManager.IsNewAwarenessSuit(suitId) + if isShowTag then + self.PanelNewTag.gameObject:SetActiveEx(true) + self.PanelRedPoint.gameObject:SetActiveEx(false) + else + self.PanelNewTag.gameObject:SetActiveEx(false) + self.PanelRedPoint.gameObject:SetActiveEx(XDataCenter.ArchiveManager.IsNewAwarenessSetting(suitId)) + end + end +end +-----------------------------------事件相关-----------------------------------------<<< +return XUiGridArchiveAwareness \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArchive/XUiGridArchiveAwarenessDetail.lua b/Resources/Scripts/XUi/XUiArchive/XUiGridArchiveAwarenessDetail.lua new file mode 100644 index 00000000..9f7286f9 --- /dev/null +++ b/Resources/Scripts/XUi/XUiArchive/XUiGridArchiveAwarenessDetail.lua @@ -0,0 +1,39 @@ +-- +-- Author: wujie +-- Note: 图鉴意识详情格子 + +local XUiGridArchiveAwarenessDetail = XClass(nil, "XUiGridArchiveAwarenessDetail") + +function XUiGridArchiveAwarenessDetail:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + self.BtnClick.CallBack = function() self:OnBtnClick() end +end + +function XUiGridArchiveAwarenessDetail:OnBtnClick() + if self.ClickCb then + self.ClickCb() + end +end + +function XUiGridArchiveAwarenessDetail:SetClickCallback(clickCb) + self.ClickCb = clickCb +end + +function XUiGridArchiveAwarenessDetail:SetName(txt) + self.TxtGet.text = txt + self.TxtNotGet.text = txt +end + +function XUiGridArchiveAwarenessDetail:SetGet(isGet) + self.PanelGet.gameObject:SetActiveEx(isGet) + self.PanelNotGet.gameObject:SetActiveEx(not isGet) +end + +function XUiGridArchiveAwarenessDetail:ShowSelect(isShow) + self.ImgSelect.gameObject:SetActiveEx(isShow) +end + +return XUiGridArchiveAwarenessDetail \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArchive/XUiGridArchiveAwarenessSetting.lua b/Resources/Scripts/XUi/XUiArchive/XUiGridArchiveAwarenessSetting.lua new file mode 100644 index 00000000..8962f60c --- /dev/null +++ b/Resources/Scripts/XUi/XUiArchive/XUiGridArchiveAwarenessSetting.lua @@ -0,0 +1,20 @@ +-- +-- Author: wujie +-- Note: 图鉴意识详细设定格子信息 + +local XUiGridArchiveAwarenessSetting = XClass(nil, "XUiGridArchiveAwarenessSetting") + +function XUiGridArchiveAwarenessSetting:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + + XTool.InitUiObject(self) +end + +function XUiGridArchiveAwarenessSetting:Refresh(data) + self.TxtTitle.text = data.Title + self.TxtContent.text = data.IsOpen and data.ContentDesc or data.ConditionDesc +end + +return XUiGridArchiveAwarenessSetting \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArchive/XUiGridArchiveCG.lua b/Resources/Scripts/XUi/XUiArchive/XUiGridArchiveCG.lua new file mode 100644 index 00000000..ee82a7db --- /dev/null +++ b/Resources/Scripts/XUi/XUiArchive/XUiGridArchiveCG.lua @@ -0,0 +1,80 @@ +XUiGridArchiveCG = XClass(nil, "XUiGridArchiveCG") +local Rect = CS.UnityEngine.Rect(1, 1, 1, 1) +local LockNameText = CS.XTextManager.GetText("ArchiveLockNameText") +local LockCGIconAspectRatio = CS.XGame.ClientConfig:GetFloat("LockStoryIconAspectRatio") +function XUiGridArchiveCG:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:SetButtonCallBack() +end + +function XUiGridArchiveCG:SetButtonCallBack() + self.CGBtn.CallBack = function() + self:OnBtnSelect() + end +end + +function XUiGridArchiveCG:OnBtnSelect() + if self.Chapter:GetIsLock() then + XUiManager.TipError(self.Chapter:GetLockDesc()) + return + end + XLuaUiManager.Open("UiArchiveCGDetail", self.ChapterList, self.CurIndex) +end + +function XUiGridArchiveCG:UpdateGrid(chapterList, base, index) + local chapter = chapterList and chapterList[index] + if chapter then + self.Chapter = chapter + self.ChapterList = chapterList + self:SetMonsterData(chapter) + self:CheckRedPoint(chapter:GetId()) + self.Base = base + self.CurIndex = index + end +end + +function XUiGridArchiveCG:SetMonsterData(chapter) + if chapter:GetIsLock() then + if chapter:GetLockBg() and #chapter:GetLockBg() > 0 then + self.CGImg:SetRawImage(chapter:GetLockBg()) + end + self.CGTitle.text = LockNameText + Rect.x = 0 + Rect.y = 0 + self.CGImg.uvRect = Rect + self.CGImgAspect.aspectRatio = LockCGIconAspectRatio + self.PanelLabelDynamic.gameObject:SetActiveEx(false) + else + local spineBg = chapter:GetSpineBg() + if spineBg and spineBg ~= "" then + self.PanelLabelDynamic.gameObject:SetActiveEx(true) + else + self.PanelLabelDynamic.gameObject:SetActiveEx(false) + end + if chapter:GetBg() and #chapter:GetBg() > 0 then + self.CGImg:SetRawImage(chapter:GetBg()) + end + self.CGTitle.text = chapter:GetName() + Rect.x = chapter:GetBgOffSetX() / 100 + Rect.y = chapter:GetBgOffSetY() / 100 + self.CGImg.uvRect = Rect + local width = chapter:GetBgWidth() ~= 0 and chapter:GetBgWidth() or 1 + local high = chapter:GetBgHigh() ~= 0 and chapter:GetBgHigh() or 1 + self.CGImgAspect.aspectRatio = width / high + end +end + +function XUiGridArchiveCG:CheckRedPoint(id) + XRedPointManager.CheckOnce( + self.OnCheckArchiveRedPoint, + self, + { XRedPointConditions.Types.CONDITION_ARCHIVE_CG_RED }, + id + ) +end + +function XUiGridArchiveCG:OnCheckArchiveRedPoint(count) + self.CGBtn:ShowReddot(count >= 0) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArchive/XUiGridArchiveCommunication.lua b/Resources/Scripts/XUi/XUiArchive/XUiGridArchiveCommunication.lua new file mode 100644 index 00000000..4062440f --- /dev/null +++ b/Resources/Scripts/XUi/XUiArchive/XUiGridArchiveCommunication.lua @@ -0,0 +1,32 @@ +XUiGridArchiveCommunication = XClass(nil, "XUiGridArchiveCommunication") + +function XUiGridArchiveCommunication:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:SetButtonCallBack() +end + +function XUiGridArchiveCommunication:SetButtonCallBack() + self.BtnPlay.CallBack = function() + self:OnBtnPlay() + end +end + +function XUiGridArchiveCommunication:OnBtnPlay() + XLuaUiManager.Open("UiFunctionalOpen", self.Chapter:GetCfg(), true, false) +end + +function XUiGridArchiveCommunication:UpdateGrid(chapter) + if chapter then + self.Chapter = chapter + self:SetMonsterData(chapter) + end +end + +function XUiGridArchiveCommunication:SetMonsterData(chapter) + if chapter:GetCommunicationIcon() then + self.RawImage:SetRawImage(chapter:GetCommunicationIcon()) + end + self.CommunicationText.text = chapter:GetName() or "" +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArchive/XUiGridArchiveEmail.lua b/Resources/Scripts/XUi/XUiArchive/XUiGridArchiveEmail.lua new file mode 100644 index 00000000..b8121ff7 --- /dev/null +++ b/Resources/Scripts/XUi/XUiArchive/XUiGridArchiveEmail.lua @@ -0,0 +1,54 @@ +XUiGridArchiveEmail = XClass(nil, "XUiGridArchiveEmail") + +local GridState = {Close = false ,Open = true} +local TabState = { + Normal = 0, + Press = 1, + Select = 2, + Disable = 3, +} +function XUiGridArchiveEmail:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:SetButtonCallBack() +end + +function XUiGridArchiveEmail:SetButtonCallBack() + self.BtnSelect.CallBack = function() + self:OnBtnSelect() + end +end + +function XUiGridArchiveEmail:OnBtnSelect() + +end + +function XUiGridArchiveEmail:UpdateGrid(chapter,stateList) + if chapter then + self:SetMonsterData(chapter,stateList) + end +end + +function XUiGridArchiveEmail:SetMonsterData(chapter,stateList) + if chapter:GetNpcHandIcon() then + self.RawImage:SetRawImage(chapter:GetNpcHandIcon()) + end + self.TitleText.text = chapter:GetTitle() or "" + self.EmailSender.text = chapter:GetSendName() or "" + self.ContentsText.text = string.gsub(chapter:GetContent(), "\\n", "\n") + + local state = stateList and stateList[chapter:GetId()] or false + if state == GridState.Close then + self.EmailContent.gameObject:SetActiveEx(false) + self.BtnSelect:SetButtonState(TabState.Normal) + elseif state == GridState.Open then + self.EmailContent.gameObject:SetActiveEx(true) + self.BtnSelect:SetButtonState(TabState.Select) + end + + self.EmailContentNote:SetDirty() + self.EmalItemNode:SetDirty() + self.Contents.sizeDelta = CS.UnityEngine.Vector2(self.EmailTitle.sizeDelta.x, self.Contents.sizeDelta.y) +end + diff --git a/Resources/Scripts/XUi/XUiArchive/XUiGridArchiveEquipSetting.lua b/Resources/Scripts/XUi/XUiArchive/XUiGridArchiveEquipSetting.lua new file mode 100644 index 00000000..9b0dce19 --- /dev/null +++ b/Resources/Scripts/XUi/XUiArchive/XUiGridArchiveEquipSetting.lua @@ -0,0 +1,49 @@ +-- +-- Author: wujie +-- Note: 图鉴装备和意识的设定/故事格子 + +local XUiGridArchiveEquipSetting = XClass(nil, "XUiGridArchiveEquipSetting") + +local stringFind = string.find +local stringGsub = string.gsub + +function XUiGridArchiveEquipSetting:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) +end + +function XUiGridArchiveEquipSetting:Refresh(subSystemType, settingData) + local settingId = settingData.Id + local isOpen = false + if subSystemType == XArchiveConfigs.SubSystemType.Weapon then + isOpen = XDataCenter.ArchiveManager.IsWeaponSettingOpen(settingId) + elseif subSystemType == XArchiveConfigs.SubSystemType.Awareness then + isOpen = XDataCenter.ArchiveManager.IsAwarenessSettingOpen(settingId) + end + + if isOpen then + self.PanelUnlock.gameObject:SetActiveEx(true) + self.PanelLock.gameObject:SetActiveEx(false) + self.TxtSettingTitle.text = settingData.Title + + local handledStr = settingData.Text + local matchedStr = "\\n" + local replacedStr = "\n" + if stringFind(handledStr, matchedStr) then + self.TxtSettingContent.text = stringGsub(handledStr, matchedStr, replacedStr) + else + self.TxtSettingContent.text = handledStr + end + else + self.PanelUnlock.gameObject:SetActiveEx(false) + self.PanelLock.gameObject:SetActiveEx(true) + local conditionId = settingData.Condition + local conditionTemplate = XConditionManager.GetConditionTemplate(conditionId) + local conditionDesc = conditionTemplate.Desc + self.TxtLockContent.text = conditionDesc + end +end + +return XUiGridArchiveEquipSetting \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArchive/XUiGridArchiveMonster.lua b/Resources/Scripts/XUi/XUiArchive/XUiGridArchiveMonster.lua new file mode 100644 index 00000000..ca1c5597 --- /dev/null +++ b/Resources/Scripts/XUi/XUiArchive/XUiGridArchiveMonster.lua @@ -0,0 +1,78 @@ +XUiGridArchiveMonster = XClass(nil, "XUiGridArchiveMonster") + +local LockNameText = CS.XTextManager.GetText("ArchiveLockNameText") + +function XUiGridArchiveMonster:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:SetButtonCallBack() +end + +function XUiGridArchiveMonster:SetButtonCallBack() + self.TemplateBtn.CallBack = function() + self:OnBtnSelect() + end +end + +function XUiGridArchiveMonster:OnBtnSelect() + if self.Chapter:GetIsLockMain() then + XUiManager.TipText("ArchiveMonsterLock") + return + end + XDataCenter.ArchiveManager.GetMonsterEvaluateFromSever(self.Chapter:GetNpcId(), function() + XLuaUiManager.Open("UiArchiveMonsterDetail", self.ChapterList, self.CurIndex) + end) +end + +function XUiGridArchiveMonster:UpdateGrid(chapterList, base, index) + if chapterList and chapterList[index] then + self.Chapter = chapterList[index] + self.ChapterList = chapterList + self:SetMonsterData(self.Chapter) + self:CheckNewTag(self.Chapter:GetId()) + self:CheckRedPoint(self.Chapter:GetId()) + end + self.Base = base + self.CurIndex = index +end + +function XUiGridArchiveMonster:CheckNewTag(monsterId) + XRedPointManager.CheckOnce( + self.OnCheckArchiveTag, + self, + { XRedPointConditions.Types.CONDITION_ARCHIVE_MONSTER_TAG }, + monsterId + ) +end + +function XUiGridArchiveMonster:CheckRedPoint(monsterId) + XRedPointManager.CheckOnce( + self.OnCheckArchiveRedPoint, + self, + { XRedPointConditions.Types.CONDITION_ARCHIVE_MONSTER_RED }, + monsterId + ) +end + +function XUiGridArchiveMonster:SetMonsterData(chapter) + if chapter:GetIsLockMain() then + self.MonsterName.text = LockNameText + if chapter:GetLockPic() and #chapter:GetLockPic() > 0 then + self.MonsterImg:SetRawImage(chapter:GetLockPic()) + end + else + self.MonsterName.text = XDataCenter.ArchiveManager.GetMonsterArchiveName(chapter) + if chapter:GetPic() and #chapter:GetPic() > 0 then + self.MonsterImg:SetRawImage(chapter:GetPic()) + end + end +end + +function XUiGridArchiveMonster:OnCheckArchiveRedPoint(count) + self.TemplateBtn:ShowReddot(count >= 0) +end + +function XUiGridArchiveMonster:OnCheckArchiveTag(count) + self.TemplateBtn:ShowTag(count >= 0) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArchive/XUiGridArchiveNpc.lua b/Resources/Scripts/XUi/XUiArchive/XUiGridArchiveNpc.lua new file mode 100644 index 00000000..505bb291 --- /dev/null +++ b/Resources/Scripts/XUi/XUiArchive/XUiGridArchiveNpc.lua @@ -0,0 +1,234 @@ +XUiGridArchiveNpc = XClass(nil, "XUiGridArchiveNpc") + +local ShortSettingMax = 5 +local LongSettingMax = 5 + +local LockNameText = CS.XTextManager.GetText("ArchiveLockNameText") + +local TweenSpeed = { + High = 0.15, + Mid = 0.2, + Low = 0.5, +} + +function XUiGridArchiveNpc:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:SetButtonCallBack() + self:SetGridAnimeData() + self.ShortSettingItem = {} + self.LongSettingItem = {} + self:SetStartPos() + self:SetStartScale() + self:SetEndAlpha() + self:SetDetailStartAlpha() +end + +function XUiGridArchiveNpc:SetButtonCallBack() + self.ArchiveNpcBtn.CallBack = function() + self:OnBtnSelect() + end + self.ArchiveNpcCloseBtn.CallBack = function() + self:OnBtnUnSelect() + end +end + +function XUiGridArchiveNpc:OnBtnSelect() + if self.Chapter:GetIsLock() then + XUiManager.TipError(self.Chapter:GetLockDesc()) + return + end + self.Base:SelectNpc(self.CurIndex) +end + +function XUiGridArchiveNpc:OnBtnUnSelect() + self.Base:SelectNpc(#self.Base.PageDatas + 1) + --self.Base:UnSelectNpc() +end + +function XUiGridArchiveNpc:UpdateGrid(chapter, base, index) + self.Chapter = chapter + self:SetNpcData(chapter) + self:SetNpcDetailData(chapter) + self.Base = base + self.CurIndex = index +end + +function XUiGridArchiveNpc:SetNpcData(chapter) + self.NpcData = {} + self.NpcData.GameObject = self.NpcItem.gameObject + self.NpcData.Transform = self.NpcItem.transform + XTool.InitUiObject(self.NpcData) + self.NpcData.ArchiveNpcName.text = chapter:GetIsLock() and LockNameText or chapter:GetName() + self.NpcData.NPCImg.gameObject:SetActiveEx(not chapter:GetIsLock()) + self.NpcData.NPCLockImg.gameObject:SetActiveEx(chapter:GetIsLock()) + self.NpcData.NPCImg:SetRawImage(chapter:GetPicSmall()) + self.NpcData.NPCLockImg:SetRawImage(chapter:GetPicSmall()) +end + +function XUiGridArchiveNpc:SetNpcDetailData(chapter) + self.NpcDetailData = {} + self.NpcDetailData.GameObject = self.NpcItemDaily.gameObject + self.NpcDetailData.Transform = self.NpcItemDaily.transform + XTool.InitUiObject(self.NpcDetailData) + self.NpcDetailData.NpcName.text = chapter:GetName() + self.NpcDetailData.NPCImg:SetRawImage(chapter:GetPicBig()) + self.NpcDetailData.ShortSettingObjs = {self.NpcDetailData.DailyItem1, + self.NpcDetailData.DailyItem2, + self.NpcDetailData.DailyItem3, + self.NpcDetailData.DailyItem4, + self.NpcDetailData.DailyItem5, + } + self.NpcDetailData.LongSettingObjs = {self.NpcDetailData.StoryText1, + self.NpcDetailData.StoryText2, + self.NpcDetailData.StoryText3, + self.NpcDetailData.StoryText4, + self.NpcDetailData.StoryText5, + } + + self:SetNpcShortSetting() + self:SetNpcLongSetting() +end + +function XUiGridArchiveNpc:SetNpcShortSetting() + local shortSettingList = XDataCenter.ArchiveManager.GetArchiveStoryNpcSettingList(self.Chapter:GetId(),XArchiveConfigs.SettingType.Setting) + for index = 1,ShortSettingMax do + local setting = shortSettingList[index] + if setting then + local item = self.ShortSettingItem[index] + if not item then + item = {} + item.Transform = self.NpcDetailData.ShortSettingObjs[index].transform + item.GameObject = self.NpcDetailData.ShortSettingObjs[index].gameObject + XTool.InitUiObject(item) + self.ShortSettingItem[index] = item + end + + item.SettingTitle.text = setting:GetTitle() + if setting:GetIsLock() then + item.SettingText.text = setting:GetLockDesc() + else + item.SettingText.text = setting:GetText() + end + end + self.NpcDetailData.ShortSettingObjs[index].gameObject:SetActiveEx(setting and true or false) + end +end + +function XUiGridArchiveNpc:SetNpcLongSetting() + local longSettingList = XDataCenter.ArchiveManager.GetArchiveStoryNpcSettingList(self.Chapter:GetId(),XArchiveConfigs.SettingType.Story) + for index = 1, LongSettingMax do + local setting = longSettingList[index] + if setting then + local item = self.LongSettingItem[index] + if not item then + item = {} + item.Transform = self.NpcDetailData.LongSettingObjs[index].transform + item.GameObject = self.NpcDetailData.LongSettingObjs[index].gameObject + XTool.InitUiObject(item) + self.LongSettingItem[index] = item + end + + item.StoryTitle.text = setting:GetTitle() + if setting:GetIsLock() then + item.StoryText.text = setting:GetLockDesc() + else + item.StoryText.text = setting:GetText() + end + end + self.NpcDetailData.LongSettingObjs[index].gameObject:SetActiveEx(setting and true or false) + end +end + +function XUiGridArchiveNpc:SetGridAnimeData() + local delta = self.NpcItemDaily.rect.width - self.NpcItem.rect.width + + self.StartPos = self.NpcItem.transform.localPosition + self.LeftEndPos = self.NpcItem.transform.localPosition - CS.UnityEngine.Vector3(delta / 2, 0, 0) + self.RightEndPos = self.NpcItem.transform.localPosition + CS.UnityEngine.Vector3(delta / 2, 0, 0) + + self.StartAlpha = 0 + self.EndAlpha = 1 + + self.StartScale = CS.UnityEngine.Vector3(1.2,1.2,1) + self.EndScale = CS.UnityEngine.Vector3(1,1,1) +end + +function XUiGridArchiveNpc:SetStartPos() + self.NpcItem.localPosition = self.StartPos +end +function XUiGridArchiveNpc:SetLeftEndPos() + self.NpcItem.localPosition = self.LeftEndPos +end +function XUiGridArchiveNpc:SetRightEndPos() + self.NpcItem.localPosition = self.RightEndPos +end + +function XUiGridArchiveNpc:SetStartScale() + self.NpcItemDaily.localScale = self.StartScale + self.NpcItemDaily.gameObject:SetActiveEx(false) +end +function XUiGridArchiveNpc:SetEndScale() + self.NpcItemDaily.localScale = self.EndScale + self.NpcItemDaily.gameObject:SetActiveEx(true) +end + +function XUiGridArchiveNpc:SetDetailStartAlpha() + self.NpcItemDailyCanvasGroup.alpha = self.StartAlpha +end +function XUiGridArchiveNpc:SetDetailEndAlpha() + self.NpcItemDailyCanvasGroup.alpha = self.EndAlpha +end + +function XUiGridArchiveNpc:SetStartAlpha() + self.NpcItemCanvasGroup.alpha = self.StartAlpha +end +function XUiGridArchiveNpc:SetEndAlpha() + self.NpcItemCanvasGroup.alpha = self.EndAlpha +end + +function XUiGridArchiveNpc:SetItemEnable(cb) + self.NpcItemCanvasGroupAlphaTimer = XUiHelper.DoAlpha(self.NpcItemCanvasGroup, self.StartAlpha, self.EndAlpha, TweenSpeed.Low, XUiHelper.EaseType.Sin, cb) +end +function XUiGridArchiveNpc:SetItemDisable(cb) + self.NpcItemCanvasGroupAlphaTimer = XUiHelper.DoAlpha(self.NpcItemCanvasGroup, self.EndAlpha, self.StartAlpha, TweenSpeed.High, XUiHelper.EaseType.Sin, cb) +end +function XUiGridArchiveNpc:SetItemDailyEnable(cb) + self.NpcItemDailyCanvasGroupAlphaTimer = XUiHelper.DoAlpha(self.NpcItemDailyCanvasGroup, self.StartAlpha, self.EndAlpha, TweenSpeed.Mid, XUiHelper.EaseType.Sin, nil) + self.NpcItemDailyScaleTimer = XUiHelper.DoScale(self.NpcItemDaily,self.StartScale , self.EndScale, TweenSpeed.Mid, XUiHelper.EaseType.Sin, cb) + XScheduleManager.ScheduleOnce(function () + self.NpcItemDaily.gameObject:SetActiveEx(true) + end, 1) +end +function XUiGridArchiveNpc:SetItemDailyDisable(cb) + self.NpcItemDailyCanvasGroupAlphaTimer = XUiHelper.DoAlpha(self.NpcItemDailyCanvasGroup, self.EndAlpha, self.StartAlpha, TweenSpeed.Mid, XUiHelper.EaseType.Sin, nil) + self.NpcItemDailyScaleTimer = XUiHelper.DoScale(self.NpcItemDaily, self.EndScale, self.StartScale, TweenSpeed.Mid, XUiHelper.EaseType.Sin, function () + self.NpcItemDaily.gameObject:SetActiveEx(false) + if cb then cb() end + end) +end +function XUiGridArchiveNpc:GoLeft(cb) + self.NpcItemMoveTimer = XUiHelper.DoMove(self.NpcItem, self.LeftEndPos, TweenSpeed.High, XUiHelper.EaseType.Sin, cb) +end +function XUiGridArchiveNpc:GoRight(cb) + self.NpcItemMoveTimer = XUiHelper.DoMove(self.NpcItem, self.RightEndPos, TweenSpeed.High, XUiHelper.EaseType.Sin, cb) +end +function XUiGridArchiveNpc:GoBack(cb,IsMove) + self.NpcItemMoveTimer = XUiHelper.DoMove(self.NpcItem, self.StartPos, IsMove and TweenSpeed.High or 0, XUiHelper.EaseType.Sin, cb) +end +function XUiGridArchiveNpc:StopTween() + if self.NpcItemMoveTimer then + XScheduleManager.UnSchedule(self.NpcItemMoveTimer) + end + if self.NpcItemDailyScaleTimer then + XScheduleManager.UnSchedule(self.NpcItemDailyScaleTimer) + end + if self.NpcItemDailyCanvasGroupAlphaTimer then + XScheduleManager.UnSchedule(self.NpcItemDailyCanvasGroupAlphaTimer) + end + if self.NpcItemCanvasGroupAlphaTimer then + XScheduleManager.UnSchedule(self.NpcItemCanvasGroupAlphaTimer) + end + +end diff --git a/Resources/Scripts/XUi/XUiArchive/XUiGridArchivePartner.lua b/Resources/Scripts/XUi/XUiArchive/XUiGridArchivePartner.lua new file mode 100644 index 00000000..be46482a --- /dev/null +++ b/Resources/Scripts/XUi/XUiArchive/XUiGridArchivePartner.lua @@ -0,0 +1,49 @@ +local XUiGridArchivePartner = XClass(nil, "XUiGridArchivePartner") + +local LockNameText = CS.XTextManager.GetText("ArchiveLockNameText") + +function XUiGridArchivePartner:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:SetButtonCallBack() +end + +function XUiGridArchivePartner:SetButtonCallBack() + self.TemplateBtn.CallBack = function() + self:OnBtnSelect() + end +end + +function XUiGridArchivePartner:OnBtnSelect() + if self.Chapter:GetIsArchiveLock() then + XUiManager.TipText("ArchivePartnerLock") + return + end + XLuaUiManager.Open("UiArchivePartnerDetail", self.ChapterList, self.CurIndex) +end + +function XUiGridArchivePartner:UpdateGrid(chapterList, index) + if chapterList and chapterList[index] then + self.Chapter = chapterList[index] + self.ChapterList = chapterList + self:SetMonsterData(self.Chapter) + end + self.CurIndex = index +end + +function XUiGridArchivePartner:SetMonsterData(chapter) + if chapter:GetIsArchiveLock() then + self.PartnerName.text = LockNameText + if chapter:GetLockIcon() and #chapter:GetLockIcon() > 0 then + self.PartnerImg:SetRawImage(chapter:GetLockIcon()) + end + else + self.PartnerName.text = chapter:GetOriginalName() + if chapter:GetIcon() and #chapter:GetIcon() > 0 then + self.PartnerImg:SetRawImage(chapter:GetIcon()) + end + end +end + +return XUiGridArchivePartner diff --git a/Resources/Scripts/XUi/XUiArchive/XUiGridArchiveStory.lua b/Resources/Scripts/XUi/XUiArchive/XUiGridArchiveStory.lua new file mode 100644 index 00000000..95df2b96 --- /dev/null +++ b/Resources/Scripts/XUi/XUiArchive/XUiGridArchiveStory.lua @@ -0,0 +1,59 @@ +XUiGridArchiveStory = XClass(nil, "XUiGridArchiveStory") +local Rect = CS.UnityEngine.Rect(1, 1, 1, 1) +local LockNameText = CS.XTextManager.GetText("ArchiveLockNameText") +local LockStoryIconAspectRatio = CS.XGame.ClientConfig:GetFloat("LockStoryIconAspectRatio") +function XUiGridArchiveStory:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:SetButtonCallBack() +end + +function XUiGridArchiveStory:SetButtonCallBack() + self.StoryBtn.CallBack = function() + self:OnBtnSelect() + end +end + +function XUiGridArchiveStory:OnBtnSelect() + if self.Chapter:GetIsLock() then + XUiManager.TipError(self.Chapter:GetLockDesc()) + return + end + XLuaUiManager.Open("UiArchiveStoryDetail", self.ChapterList, self.CurIndex) +end + +function XUiGridArchiveStory:UpdateGrid(chapterList, base, index) + local chapter = chapterList and chapterList[index] + if chapter then + self.Chapter = chapter + self.ChapterList = chapterList + self:SetMonsterData(chapter) + self.Base = base + self.CurIndex = index + end +end + +function XUiGridArchiveStory:SetMonsterData(chapter) + if chapter:GetIsLock() then + if chapter:GetLockBg() and #chapter:GetLockBg() > 0 then + self.StoryImg:SetRawImage(chapter:GetLockBg()) + end + self.StoryTitle.text = LockNameText + Rect.x = 0 + Rect.y = 0 + self.StoryImg.uvRect = Rect + self.StoryImgAspect.aspectRatio = LockStoryIconAspectRatio + else + if chapter:GetBg() and #chapter:GetBg() > 0 then + self.StoryImg:SetRawImage(chapter:GetBg()) + end + self.StoryTitle.text = chapter:GetName() + Rect.x = chapter:GetBgOffSetX() / 100 + Rect.y = chapter:GetBgOffSetY() / 100 + self.StoryImg.uvRect = Rect + local width = chapter:GetBgWidth() ~= 0 and chapter:GetBgWidth() or 1 + local high = chapter:GetBgHigh() ~= 0 and chapter:GetBgHigh() or 1 + self.StoryImgAspect.aspectRatio = width / high + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArchive/XUiGridArchiveStoryDetail.lua b/Resources/Scripts/XUi/XUiArchive/XUiGridArchiveStoryDetail.lua new file mode 100644 index 00000000..de485996 --- /dev/null +++ b/Resources/Scripts/XUi/XUiArchive/XUiGridArchiveStoryDetail.lua @@ -0,0 +1,39 @@ +XUiGridArchiveStoryDetail = XClass(nil, "XUiGridArchiveStoryDetail") + +function XUiGridArchiveStoryDetail:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:SetButtonCallBack() +end + +function XUiGridArchiveStoryDetail:SetButtonCallBack() + self.BtnTanchuang.CallBack = function() + self:OnBtnSelect() + end +end + +function XUiGridArchiveStoryDetail:OnBtnSelect() + if self.Chapter:GetIsLock() then + XUiManager.TipError(self.Chapter:GetLockDesc()) + return + end + XLuaUiManager.Open("UiArchiveStoryDialog", self.Chapter) +end + +function XUiGridArchiveStoryDetail:UpdateGrid(chapter, base) + self.Base = base + self.Chapter = chapter + self:SetMonsterData(chapter) +end + +function XUiGridArchiveStoryDetail:SetMonsterData(chapter) + local btnStatus = chapter:GetIsLock() and CS.UiButtonState.Disable or CS.UiButtonState.Normal + self.BtnTanchuang:SetButtonState(btnStatus) + self.ChapterTitle.text = chapter:GetName() + if chapter:GetSubName() then + self.ChapterTitleNum.text = string.gsub(chapter:GetSubName(), "_", "-") + end + + self.ChapterTitleNum.gameObject:SetActiveEx(chapter:GetSubName() and #chapter:GetSubName() > 0) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArchive/XUiGridArchiveTag.lua b/Resources/Scripts/XUi/XUiArchive/XUiGridArchiveTag.lua new file mode 100644 index 00000000..51584ccf --- /dev/null +++ b/Resources/Scripts/XUi/XUiArchive/XUiGridArchiveTag.lua @@ -0,0 +1,58 @@ +XUiGridArchiveTag = XClass(nil, "XUiGridArchiveTag") +local tableInsert = table.insert +local Select = CS.UiButtonState.Select +local Normal = CS.UiButtonState.Normal + +function XUiGridArchiveTag:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:SetButtonCallBack() +end + +function XUiGridArchiveTag:SetButtonCallBack() + self.BtnTagItem.CallBack = function() + self:OnBtnSelect() + end +end + +function XUiGridArchiveTag:OnBtnSelect() + if self.BtnTagItem.ButtonState ~= Select then + for index, tagId in pairs(self.Base.TagIds) do + if self.Data.Id == tagId then + self.Base.TagIds[index] = nil + end + end + else + + local count = 0 + for _, _ in pairs(self.Base.TagIds) do + count = count + 1 + end + if count < 3 then + tableInsert(self.Base.TagIds, self.Data.Id) + else + XUiManager.TipText("ArchiveTagMaxText") + self.BtnTagItem:SetButtonState(Normal) + end + end +end + +function XUiGridArchiveTag:UpdateGrid(chapter, parent) + self.Base = parent + self.Data = chapter + self:SetTag(chapter) +end + +function XUiGridArchiveTag:SetTag(chapter) + self.TxtTag.text = XArchiveConfigs.GetArchiveTagCfgById(chapter.Id).Name + self.TxtTag.color = XUiHelper.Hexcolor2Color(XArchiveConfigs.GetArchiveTagCfgById(chapter.Id).Color) + local bgImg = XArchiveConfigs.GetArchiveTagCfgById(chapter.Id).Bg + if bgImg then self.Base:SetUiSprite(self.Bg, bgImg) end + for _, tagId in pairs(self.Base.TagIds) do + if chapter.Id == tagId then + self.BtnTagItem:SetButtonState(Select) + end + end + +end diff --git a/Resources/Scripts/XUi/XUiArchive/XUiGridArchiveWeapon.lua b/Resources/Scripts/XUi/XUiArchive/XUiGridArchiveWeapon.lua new file mode 100644 index 00000000..5da020d3 --- /dev/null +++ b/Resources/Scripts/XUi/XUiArchive/XUiGridArchiveWeapon.lua @@ -0,0 +1,86 @@ +-- +-- Author: wujie +-- Note: 图鉴武器格子信息 +local XUiGridArchiveWeapon = XClass(nil, "XUiGridArchiveWeapon") + +function XUiGridArchiveWeapon:Ctor(ui, clickCb, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self.ClickCb = clickCb + + XTool.InitUiObject(self) + + self.BtnClick.CallBack = function() self:OnBtnClick() end +end + +function XUiGridArchiveWeapon:InitRootUi(rootUi) + self.RootUi = rootUi +end + +function XUiGridArchiveWeapon:SetClickCallback(callback) + self.ClickCb = callback +end + +function XUiGridArchiveWeapon:Refresh(templateIdList,index) + local templateId = templateIdList and templateIdList[index] + if not templateId then return end + self.TemplateId = templateId + self.TemplateIdList = templateIdList + self.TemplateIndex = index + local templateData = XEquipConfig.GetEquipCfg(templateId) + + local isGet = XDataCenter.ArchiveManager.IsWeaponGet(templateId) + local iconPath = XDataCenter.EquipManager.GetEquipBigIconPath(templateId, 0) + if isGet then + self.RImgIcon:SetRawImage(iconPath, nil, true) + self.RImgIcon.gameObject:SetActiveEx(true) + self.RImgDarkIcon.gameObject:SetActiveEx(false) + else + self.RImgDarkIcon:SetRawImage(iconPath, nil, true) + self.RImgIcon.gameObject:SetActiveEx(false) + self.RImgDarkIcon.gameObject:SetActiveEx(true) + end + + if self.ImgQuality then + self.RootUi:SetUiSprite(self.ImgQuality, XDataCenter.EquipManager.GetEquipQualityPath(templateId)) + end + + if self.TxtName then + self.TxtName.text = templateData.Name + end + + XRedPointManager.CheckOnce( + self.OnCheckRedPoint, + self, + { XRedPointConditions.Types.CONDITION_ARCHIVE_WEAPON_GRID_NEW_TAG, XRedPointConditions.Types.CONDITION_ARCHIVE_WEAPON_SETTING_RED }, + self.TemplateId + ) +end + +-----------------------------------事件相关----------------------------------------->>> +function XUiGridArchiveWeapon:OnBtnClick() + if self.ClickCb then + self.ClickCb(self.TemplateIdList,self.TemplateIndex, self) + end +end + +-- 有new标签时显示new标签,如果只有红点显示红点,红点和new标签同时存在则只显示new标签 +function XUiGridArchiveWeapon:OnCheckRedPoint(count) + local templateId = self.TemplateId + if count < 0 or not templateId then + self.PanelNewTag.gameObject:SetActiveEx(false) + self.PanelRedPoint.gameObject:SetActiveEx(false) + else + local isShowTag = XDataCenter.ArchiveManager.IsNewWeapon(templateId) + if isShowTag then + self.PanelNewTag.gameObject:SetActiveEx(true) + self.PanelRedPoint.gameObject:SetActiveEx(false) + else + self.PanelNewTag.gameObject:SetActiveEx(false) + self.PanelRedPoint.gameObject:SetActiveEx(XDataCenter.ArchiveManager.IsNewWeaponSetting(templateId)) + end + end +end +-----------------------------------事件相关-----------------------------------------<<< +return XUiGridArchiveWeapon \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArchive/XUiGridArchiveWeaponAchievement.lua b/Resources/Scripts/XUi/XUiArchive/XUiGridArchiveWeaponAchievement.lua new file mode 100644 index 00000000..f0c5f765 --- /dev/null +++ b/Resources/Scripts/XUi/XUiArchive/XUiGridArchiveWeaponAchievement.lua @@ -0,0 +1,88 @@ +-- +-- Author: wujie +-- Note: 图鉴武器成就格子 +local XUiGridArchiveWeaponAchievement = XClass(nil, "XUiGridArchiveWeaponAchievement") + +local StoryUncollectedDescStr = CS.XTextManager.GetText("ArchiveWeaponAchievementStoryUncollectedDesc") +local StoryCollectedDescStr = CS.XTextManager.GetText("ArchiveWeaponAchievementStoryCollectedDesc") + +function XUiGridArchiveWeaponAchievement:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + -- self.RootUi = rootUi + -- self.ClickCb = clickCb + + XTool.InitUiObject(self) + self.BtnClick.CallBack = function() self:OnBtnClick() end +end + +function XUiGridArchiveWeaponAchievement:InitRootUi(rootUi) + self.RootUi = rootUi +end + +function XUiGridArchiveWeaponAchievement:SetClickCallback(callback) + self.ClickCb = callback +end + +function XUiGridArchiveWeaponAchievement:SetGetState(isGet) + if not self.GroupData or not self.Index then return end + if isGet then + self.RImgCollectedIcon.gameObject:SetActiveEx(true) + self.RImgUncollectedIcon.gameObject:SetActiveEx(false) + self.RImgCollectedIcon:SetRawImage(self.GroupData.IconPath[self.Index]) + else + self.RImgCollectedIcon.gameObject:SetActiveEx(false) + self.RImgUncollectedIcon.gameObject:SetActiveEx(true) + self.RImgUncollectedIcon:SetRawImage(self.GroupData.IconPath[self.Index]) + end + self.ImgLock.gameObject:SetActiveEx(not isGet) + self.ImgFinish.gameObject:SetActiveEx(isGet) +end + +function XUiGridArchiveWeaponAchievement:SetStory(CgId) + if not CgId or CgId == 0 then + self.TxtStory.gameObject:SetActiveEx(false) + else + self.TxtStory.gameObject:SetActiveEx(true) + if self.IsGet then + self.TxtStory.text = StoryCollectedDescStr + else + self.TxtStory.text = StoryUncollectedDescStr + end + end +end + +function XUiGridArchiveWeaponAchievement:Refresh(groupData, index, haveCollectNum) + self.GroupData = groupData + self.Index = index + + self.TxtTitle.text = groupData.CollectionTitle[index] + self.TxtContent.text = groupData.CollectionContent[index] + + local needCollectNum = groupData.CollectNum[index] + haveCollectNum = math.min(haveCollectNum, needCollectNum) + local isGet = haveCollectNum == needCollectNum + self.IsGet = isGet + if isGet then + self.TxtBlueHaveCollectNum.gameObject:SetActiveEx(true) + self.TxtRedHaveCollectNum.gameObject:SetActiveEx(false) + self.TxtBlueHaveCollectNum.text = haveCollectNum + else + self.TxtBlueHaveCollectNum.gameObject:SetActiveEx(false) + self.TxtRedHaveCollectNum.gameObject:SetActiveEx(true) + self.TxtRedHaveCollectNum.text = haveCollectNum + end + self.TxtNeedCollectNum.text = needCollectNum + + self:SetGetState(isGet) + self:SetStory(groupData.CgId[index]) +end + +-----------------------------------事件相关-----------------------------------------<<< +function XUiGridArchiveWeaponAchievement:OnBtnClick() + if self.ClickCb and self.GroupData and self.IsGet then + self.ClickCb(self.GroupData.CgId[self.Index], self) + end +end +-----------------------------------事件相关----------------------------------------->>> +return XUiGridArchiveWeaponAchievement \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArena/XUiArena.lua b/Resources/Scripts/XUi/XUiArena/XUiArena.lua new file mode 100644 index 00000000..ad195ef1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiArena/XUiArena.lua @@ -0,0 +1,58 @@ +local XUiArena = XLuaUiManager.Register(XLuaUi, "UiArena") + +local XUiPanelActive = require("XUi/XUiArena/XUiPanelActive") +local XUiPanelPrepare = require("XUi/XUiArena/XUiPanelPrepare") + +function XUiArena:OnAwake() + self:AutoAddListener() +end + +function XUiArena:OnStart() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + + self.ActivePanel = XUiPanelActive.New(self.PanelActive, self) + self.PreparePanel = XUiPanelPrepare.New(self.PanelPrepare, self) +end + +function XUiArena:OnEnable() + XDataCenter.ArenaManager.OpenArenaActivityResult() + self:Refresh() + + -- 刷新任务红点 + if self.ActivePanel then + self.ActivePanel:CheckRedPoint() + end +end + +function XUiArena:OnDestroy() + self.ActivePanel:UnBindTimer() +end + +function XUiArena:AutoAddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:BindHelpBtn(self.BtnHelp, "Arena") +end + +function XUiArena:OnBtnBackClick() + self:Close() +end + +function XUiArena:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiArena:Refresh() + if not self.GameObject:Exist() then + return + end + + local status = XDataCenter.ArenaManager.GetArenaActivityStatus() + if status == XArenaActivityStatus.Fight then + self.ActivePanel:Show() + self.PreparePanel:Hide() + else + self.PreparePanel:Show() + self.ActivePanel:Hide() + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArena/XUiArenaContributeScore.lua b/Resources/Scripts/XUi/XUiArena/XUiArenaContributeScore.lua new file mode 100644 index 00000000..306cf44b --- /dev/null +++ b/Resources/Scripts/XUi/XUiArena/XUiArenaContributeScore.lua @@ -0,0 +1,29 @@ +---通用接口,处理战区的贡献分 +local XUiArenaContributeScore = {} +local TXT_COLOR_RED = "FF3F3FFF" +local defaultColor = nil + +--[[ + --@txtCom:text component + --@contributeScore:贡献分 + --@point:战区积分 + --@defaultColor: 默认的颜色值 +]] +function XUiArenaContributeScore.Refresh(txtCom, contributeScore, point, defaultColor) + if XTool.UObjIsNil(txtCom) or not contributeScore or not point then + XLog.Error("参数不可以有空的") + return + end + + if contributeScore == 0 and point == 0 then + txtCom.color = XUiHelper.Hexcolor2Color(TXT_COLOR_RED) + else + if defaultColor then + txtCom.color = XUiHelper.Hexcolor2Color(defaultColor) + end + end + + txtCom.text = "+" .. contributeScore +end + +return XUiArenaContributeScore \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArena/XUiArenaContributeTips.lua b/Resources/Scripts/XUi/XUiArena/XUiArenaContributeTips.lua new file mode 100644 index 00000000..030bf400 --- /dev/null +++ b/Resources/Scripts/XUi/XUiArena/XUiArenaContributeTips.lua @@ -0,0 +1,103 @@ +local XUiArenaContributeTips = XLuaUiManager.Register(XLuaUi, "UiArenaContributeTips") +local XUiArenaContributeTipsGrid = require("XUi/XUiArena/XUiArenaContributeTipsGrid") +local CsXTextManagerGetText = CS.XTextManager.GetText + +local TAB_TYPE = { + EXPLAIN = 1, --说明 + OBTAIN = 2, --列表 +} + +function XUiArenaContributeTips:OnAwake() + self:AutoAddListener() +end + +--[[ + --@isNow: + true:当前竞技场的数据 + false:上一期的数据 + --@tabIndex: + 初始化时候对应要选中的页签:TAB_TYPE +]] +function XUiArenaContributeTips:OnStart(isNow, tabIndex) + self.IsNow = isNow + if self.IsNow then + self.ChallengeCfg = XDataCenter.ArenaManager.GetCurChallengeCfg() + self.ArenaLevel = XDataCenter.ArenaManager.GetCurArenaLevel() + else + self.ChallengeCfg = XDataCenter.ArenaManager.GetLastChallengeCfg() + self.ArenaLevel = XDataCenter.ArenaManager.GetLastArenaLevel() + end + + self:InitDynamicTable() + self:InitTabGroup(tabIndex) +end + +--@region 点击事件 +function XUiArenaContributeTips:AutoAddListener() + self:RegisterClickEvent(self.BtnTanchuangClose, self.OnBtnTangchuangCloseClick) +end + +function XUiArenaContributeTips:OnBtnTangchuangCloseClick() + self:Close() +end + +function XUiArenaContributeTips:OnTabClick(index) + self.SelectTabType = index + self:Refresh() +end +--@endregion + +function XUiArenaContributeTips:InitTabGroup(tabIndex) + self.PanelTab:Init({ + self.BtnTab1, + self.BtnTab2, + }, function(index) + self:OnTabClick(index) + end) + + if tabIndex then + self.PanelTab:SelectIndex(tabIndex) + else + self.PanelTab:SelectIndex(TAB_TYPE.EXPLAIN) + end +end + +function XUiArenaContributeTips:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.SViewContribute) + self.DynamicTable:SetProxy(XUiArenaContributeTipsGrid) + self.DynamicTable:SetDelegate(self) +end + +function XUiArenaContributeTips:Refresh() + if self.SelectTabType == TAB_TYPE.EXPLAIN then + self.PanelExplain.gameObject:SetActiveEx(true) + self.PanelObtain.gameObject:SetActiveEx(false) + self:RefreshPanelExplain() + elseif self.SelectTabType == TAB_TYPE.OBTAIN then + self.PanelExplain.gameObject:SetActiveEx(false) + self.PanelObtain.gameObject:SetActiveEx(true) + self:RefreshPanelObtain() + end +end + +function XUiArenaContributeTips:RefreshPanelExplain() + self.TxtContentNotice.text = string.gsub(CsXTextManagerGetText("ContributeScoreDesc"), "\\n", "\n") +end + +function XUiArenaContributeTips:RefreshPanelObtain() + local arenaLevelCfg = XArenaConfigs.GetArenaLevelCfgByLevel(self.ArenaLevel) + self.List = self.ChallengeCfg.ContributeScore + self.DynamicTable:SetDataSource(self.List) + self.DynamicTable:ReloadDataSync() + self.TxtPeople.text = #self.List + self.TxtArena.text = self.ChallengeCfg.Name + self.RImgIconArena:SetRawImage(arenaLevelCfg.Icon) +end + +function XUiArenaContributeTips:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:Refresh(index, self.List[index]) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArena/XUiArenaContributeTipsGrid.lua b/Resources/Scripts/XUi/XUiArena/XUiArenaContributeTipsGrid.lua new file mode 100644 index 00000000..cf08da58 --- /dev/null +++ b/Resources/Scripts/XUi/XUiArena/XUiArenaContributeTipsGrid.lua @@ -0,0 +1,19 @@ +local XUiArenaContributeTipsGrid = XClass(nil, "UiArenaContributeTipsGrid") + +function XUiArenaContributeTipsGrid:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) +end + +function XUiArenaContributeTipsGrid:Init(uiRoot) + self.UiRoot = uiRoot +end + +function XUiArenaContributeTipsGrid:Refresh(index, contributeScore) + self.TxtRank.text = "No." .. index + self.TxtNumber.text = "+" .. contributeScore +end + +return XUiArenaContributeTipsGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArena/XUiArenaGrid.lua b/Resources/Scripts/XUi/XUiArena/XUiArenaGrid.lua new file mode 100644 index 00000000..9b696314 --- /dev/null +++ b/Resources/Scripts/XUi/XUiArena/XUiArenaGrid.lua @@ -0,0 +1,50 @@ +local XUiArenaGrid = XClass(nil, "XUiArenaGrid") +local XUiArenaContributeScore = require("XUi/XUiArena/XUiArenaContributeScore") + +function XUiArenaGrid:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + self:AutoAddListener() +end + +function XUiArenaGrid:AutoAddListener() + CsXUiHelper.RegisterClickEvent(self.BtnHead, function() + if self.PlayerInfo.Id == XPlayer.Id then + return + else + XDataCenter.PersonalInfoManager.ReqShowInfoPanel(self.PlayerInfo.Id) + end + end) +end + +function XUiArenaGrid:Refresh(index, playerInfo, regionIndex) + local challengeCfg = XDataCenter.ArenaManager.GetCurChallengeCfg() + local contributeScore = XDataCenter.ArenaManager.GetContributeScoreByCfg(index, challengeCfg, playerInfo.Point) + self.PlayerInfo = playerInfo + + local pos = regionIndex % 3 + if pos == 1 then + self.PanelInfo.localPosition = self.PanelPos1.localPosition + elseif pos == 2 then + self.PanelInfo.localPosition = self.PanelPos2.localPosition + else + self.PanelInfo.localPosition = self.PanelPos3.localPosition + end + self.TxtNickname.text = XDataCenter.SocialManager.GetPlayerRemark(playerInfo.Id, playerInfo.Name) + XUiPLayerHead.InitPortrait(playerInfo.CurrHeadPortraitId, playerInfo.CurrHeadFrameId, self.Head) + + self.TxtRank.text = "No." .. index + self.TxtPoint.text = playerInfo.Point + + XUiArenaContributeScore.Refresh(self.TxtNumber, contributeScore, playerInfo.Point, "FFFFFFFF") + + self.GameObject:SetActive(true) +end + +function XUiArenaGrid:SetSiblingIndex(siblingIndex) + self.Transform:SetSiblingIndex(siblingIndex) +end + +return XUiArenaGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArena/XUiArenaRank.lua b/Resources/Scripts/XUi/XUiArena/XUiArenaRank.lua new file mode 100644 index 00000000..32b4977c --- /dev/null +++ b/Resources/Scripts/XUi/XUiArena/XUiArenaRank.lua @@ -0,0 +1,246 @@ +local XUiArenaRank = XLuaUiManager.Register(XLuaUi, "UiArenaRank") +local XUiArenaRankGrid = require("XUi/XUiArena/XUiArenaRankGrid") +local XUiArenaContributeScore = require("XUi/XUiArena/XUiArenaContributeScore") + +function XUiArenaRank:OnAwake() + self:AutoAddListener() +end + +function XUiArenaRank:OnStart() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + + self.TeamMemberList = {} + table.insert(self.TeamMemberList, self.GridMember1) + table.insert(self.TeamMemberList, self.GridMember2) + + self.GridTitleCache = {} + table.insert(self.GridTitleCache, self.GridTitle) + self.GridPlayerCache = {} + + self.GridMember1.transform.parent.gameObject:SetActiveEx(false) + self.GridPlayer.gameObject:SetActiveEx(false) + self:Refresh() +end + +function XUiArenaRank:AutoAddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:RegisterClickEvent(self.BtnTeamRank, self.OnBtnTeamRankClick) + self:RegisterClickEvent(self.BtnArenaLevelDetail, self.OnBtnArenaLevelDetailClick) + self:RegisterClickEvent(self.BtnDetailsA, self.OnBtnBtnDetailsClick) + self:RegisterClickEvent(self.BtnDetailsB, self.OnBtnBtnDetailsClick) + self:RegisterClickEvent(self.BtnTxtNumber, self.OnBtnTxtNumber) +end + +function XUiArenaRank:OnBtnBtnDetailsClick() + XLuaUiManager.Open("UiArenaContributeTips", false) +end + +function XUiArenaRank:OnBtnTxtNumber() + XLuaUiManager.Open("UiArenaContributeTips", false, 2) +end + +function XUiArenaRank:OnBtnBackClick() + self:Close() +end + +function XUiArenaRank:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiArenaRank:OnBtnArenaLevelDetailClick() + XLuaUiManager.Open("UiArenaLevelDetail") +end + +function XUiArenaRank:OnBtnTeamRankClick() + XDataCenter.ArenaManager.RequestTeamRankData(function() + XLuaUiManager.Open("UiArenaTeamRank") + end) +end + +function XUiArenaRank:Refresh() + local challengeCfg = XDataCenter.ArenaManager.GetLastChallengeCfg() + if challengeCfg then + self.TxtLevelRange.text = CS.XTextManager.GetText("ArenaPlayerLevelRange", challengeCfg.MinLv, challengeCfg.MaxLv) + self.TxtArenaRegion.text = challengeCfg.Name + end + + local arenaLevel = XDataCenter.ArenaManager.GetLastArenaLevel() + local arenaLevelCfg = XArenaConfigs.GetArenaLevelCfgByLevel(arenaLevel) + if arenaLevelCfg then + self.RImgArenaLevel:SetRawImage(arenaLevelCfg.Icon) + end + + self.TxtRankDesc.gameObject:SetActiveEx(false) + self:RefreshSelfInfo() + self:RefreshTeamInfo() + self:RefreshArenaPlayerRank() +end + +-- 自身 +function XUiArenaRank:RefreshSelfInfo() + local wave = XDataCenter.ArenaManager.GetWaveLastRate() + local rank, region = XDataCenter.ArenaManager.GetLastPlayerArenaRankAndRegion() + local selfInfo = XDataCenter.ArenaManager.GetPlayerLastArenaInfo() + local challengeCfg = XDataCenter.ArenaManager.GetLastChallengeCfg() + local contributeScore = XDataCenter.ArenaManager.GetContributeScoreByCfg(rank, challengeCfg, selfInfo.Point) + local maxContributeScore = XDataCenter.ArenaManager.GetLastContributeScore() + + self.TxtWave.text = CS.XTextManager.GetText("ArenaWaveRate", wave) + self.TxtSelfNickname.text = selfInfo.Name + self.TxtPoint.text = selfInfo.Point + self.TxtRank.text = "No." .. rank + self.TxtRankRange.text = XArenaConfigs.GetRankRegionText(region) + XUiPLayerHead.InitPortrait(selfInfo.CurrHeadPortraitId, selfInfo.CurrHeadFrameId, self.Head) + + if maxContributeScore >= CS.XGame.Config:GetInt("ArenaProtectContributeScore") then + self.PanelContribute.gameObject:SetActiveEx(false) + self.PanelContributeActivation.gameObject:SetActiveEx(true) + else + self.TxtSumNumber.text = maxContributeScore + self.ImgJd.fillAmount = maxContributeScore / CS.XGame.Config:GetInt("ArenaMaxContributeScore") + + self.PanelContribute.gameObject:SetActiveEx(true) + self.PanelContributeActivation.gameObject:SetActiveEx(false) + end + XUiArenaContributeScore.Refresh(self.TxtNumber, contributeScore, selfInfo.Point, "000000FF") +end + +-- 队伍 +function XUiArenaRank:RefreshTeamInfo() + self.TxtTeamPoint.text = XDataCenter.ArenaManager.GetLastArenaTeamTotalPoint() + local teamMemberList = XDataCenter.ArenaManager.GetPlayerLastArenaTeamMemberInfo() + for i, grid in ipairs(self.TeamMemberList) do + local head = XUiHelper.TryGetComponent(grid.transform, "Head") + local nickname = XUiHelper.TryGetComponent(grid.transform, "TxtNickname", "Text") + local btnHead = XUiHelper.TryGetComponent(grid.transform, "BtnHead", "Button") + + CsXUiHelper.RegisterClickEvent(btnHead, function() + local memberInfo = teamMemberList[i] + if memberInfo then + XDataCenter.PersonalInfoManager.ReqShowInfoPanel(memberInfo.Id) + end + end, true) + + local member = teamMemberList[i] + if member then + nickname.text = XDataCenter.SocialManager.GetPlayerRemark(member.Id, member.Name) + XUiPLayerHead.InitPortrait(member.CurrHeadPortraitId, member.CurrHeadFrameId, head) + else + nickname.text = "" + XUiPLayerHead.Hide(head) + end + end +end + +function XUiArenaRank:RefreshArenaPlayerRank() + local challengeCfg = XDataCenter.ArenaManager.GetLastChallengeCfg() + local rankData = XDataCenter.ArenaManager.GetLastPlayerArenaRankList() + + for _, v in ipairs(self.GridTitleCache) do + v.gameObject:SetActiveEx(false) + end + for _, v in ipairs(self.GridPlayerCache) do + v.GameObject:SetActiveEx(false) + end + + if not challengeCfg then + return + end + + self.SiblingIndex = 1 + local titleIndex = 1 + local playerIndex = 1 + + -- 晋级区 + if challengeCfg.DanUpRank > 0 then + self:AddTitle(titleIndex, challengeCfg.UpRewardId) + for _, info in ipairs(rankData.UpList) do + self:AddPlayer(playerIndex, info) + playerIndex = playerIndex + 1 + end + end + + -- 保级区 + titleIndex = titleIndex + 1 + self:AddTitle(titleIndex, challengeCfg.KeepRewardId) + for _, info in ipairs(rankData.KeepList) do + self:AddPlayer(playerIndex, info) + playerIndex = playerIndex + 1 + end + + -- 降级区 + if challengeCfg.DanDownRank > 0 then + titleIndex = titleIndex + 1 + self:AddTitle(titleIndex, challengeCfg.DownRewardId) + for _, info in ipairs(rankData.DownList) do + self:AddPlayer(playerIndex, info) + playerIndex = playerIndex + 1 + end + end +end + +function XUiArenaRank:AddTitle(rankRegion, rewardId) + local grid = self.GridTitleCache[rankRegion] + if not grid then + local go = CS.UnityEngine.GameObject.Instantiate(self.GridTitle.gameObject) + grid = go.transform + grid:SetParent(self.PanelContent, false) + table.insert(self.GridTitleCache, grid) + end + grid.gameObject:SetActiveEx(true) + + grid:SetSiblingIndex(self.SiblingIndex - 1) + self.SiblingIndex = self.SiblingIndex + 1 + + -- 界面显示 + local rankRange = XUiHelper.TryGetComponent(grid.transform, "TxtRankRange", "Text") + local rewardIcon = XUiHelper.TryGetComponent(grid.transform, "ImgReward", "Image") + local rewardCount = XUiHelper.TryGetComponent(grid.transform, "ImgRewardCount", "Text") + local btnTitle = XUiHelper.TryGetComponent(grid.transform, "BtnTitle", "Button") + local btnReward = XUiHelper.TryGetComponent(grid.transform, "ImgReward/BtnReward", "Button") + + CsXUiHelper.RegisterClickEvent(btnTitle, function() + XLuaUiManager.Open("UiArenaLevelDetail") + end, true) + + CsXUiHelper.RegisterClickEvent(btnReward, function() + local list = XRewardManager.GetRewardList(rewardId) + if not list or #list <= 0 then + return + end + local goodsShowParams = XGoodsCommonManager.GetGoodsShowParamsByTemplateId(list[1].TemplateId) + if goodsShowParams.RewardType == XRewardManager.XRewardType.Character then + XLuaUiManager.Open("UiCharacterDetail", list[1].TemplateId) + elseif goodsShowParams.RewardType == XRewardManager.XRewardType.Equip then + XLuaUiManager.Open("UiEquipDetail", list[1].TemplateId, true) + else + XLuaUiManager.Open("UiTip", list[1] and list[1] or list[1].TemplateId) + end + end, true) + + rankRange.text = XArenaConfigs.GetRankRegionText(rankRegion) + local rewards = XRewardManager.GetRewardList(rewardId) + if not rewards or #rewards <= 0 then + return + end + local iconPath = XGoodsCommonManager.GetGoodsIcon(rewards[1].TemplateId) + self:SetUiSprite(rewardIcon, iconPath) + rewardCount.text = rewards[1].Count +end + +function XUiArenaRank:AddPlayer(index, playerInfo) + local xUiArenaRankGrid = self.GridPlayerCache[index] + if not xUiArenaRankGrid then + local grid = CS.UnityEngine.GameObject.Instantiate(self.GridPlayer.gameObject) + grid.transform:SetParent(self.PanelContent, false) + xUiArenaRankGrid = XUiArenaRankGrid.New(grid) + table.insert(self.GridPlayerCache, xUiArenaRankGrid) + end + + xUiArenaRankGrid:Refresh(index, playerInfo) + xUiArenaRankGrid:SetSiblingIndex(self.SiblingIndex - 1) + self.SiblingIndex = self.SiblingIndex + 1 +end + +return XUiArenaRank \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArena/XUiArenaRankGrid.lua b/Resources/Scripts/XUi/XUiArena/XUiArenaRankGrid.lua new file mode 100644 index 00000000..1f4455bb --- /dev/null +++ b/Resources/Scripts/XUi/XUiArena/XUiArenaRankGrid.lua @@ -0,0 +1,75 @@ +local XUiArenaRankGrid = XClass(nil, "XUiArenaRankGrid") +local XUiArenaContributeScore = require("XUi/XUiArena/XUiArenaContributeScore") + +function XUiArenaRankGrid:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + self:AutoAddListener() +end + +function XUiArenaRankGrid:AutoAddListener() + self.BtnHead.CallBack = function() self:OnBtnHeadClick() end +end + +function XUiArenaRankGrid:OnBtnHeadClick() + if self.PlayerInfo.Id == XPlayer.Id then + return + end + XDataCenter.PersonalInfoManager.ReqShowInfoPanel(self.PlayerInfo.Id) +end + +function XUiArenaRankGrid:Refresh(index, playerInfo) + self.PlayerInfo = playerInfo + local challengeCfg = XDataCenter.ArenaManager.GetLastChallengeCfg() + local contributeScore = XDataCenter.ArenaManager.GetContributeScoreByCfg(index, challengeCfg, playerInfo.Point) + + self.TxtNickname.text = XDataCenter.SocialManager.GetPlayerRemark(playerInfo.Id, playerInfo.Name) + XUiPLayerHead.InitPortrait(playerInfo.CurrHeadPortraitId, playerInfo.CurrHeadFrameId, self.Head) + + self.TxtRank.text = "No." .. index + self.TxtPoint.text = CS.XTextManager.GetText("ArenaRankPonit", playerInfo.Point) + + if playerInfo.LastPointTime == nil or playerInfo.LastPointTime == 0 then + self.TxtTime.gameObject:SetActiveEx(false) + else + self.TxtTime.gameObject:SetActiveEx(true) + local timeStr = XTime.TimestampToGameDateTimeString(playerInfo.LastPointTime, "yyyy/MM/dd HH:mm") + self.TxtTime.text = CS.XTextManager.GetText("ArenaRankPlayerPointTimeDesc", timeStr) + end + + local rankNum = XDataCenter.ArenaManager.GetResultFormLocal(playerInfo.Id) + if not rankNum then + self.ImgChangeJia.gameObject:SetActiveEx(false) + self.ImgChangeJian.gameObject:SetActiveEx(false) + self.ImgChange.gameObject:SetActiveEx(false) + return + end + + local score = rankNum - index + if score > 0 then + self.ImgChangeJia.gameObject:SetActiveEx(true) + self.ImgChangeJian.gameObject:SetActiveEx(false) + self.ImgChange.gameObject:SetActiveEx(false) + self.TxtJia.text = score + elseif score < 0 then + self.ImgChangeJia.gameObject:SetActiveEx(false) + self.ImgChangeJian.gameObject:SetActiveEx(true) + self.ImgChange.gameObject:SetActiveEx(false) + self.TxtJian.text = math.abs(score) + else + self.ImgChangeJia.gameObject:SetActiveEx(false) + self.ImgChangeJian.gameObject:SetActiveEx(false) + self.ImgChange.gameObject:SetActiveEx(true) + end + + XUiArenaContributeScore.Refresh(self.TxtNumber, contributeScore, playerInfo.Point, "FFFFFFFF") + self.GameObject:SetActive(true) +end + +function XUiArenaRankGrid:SetSiblingIndex(siblingIndex) + self.Transform:SetSiblingIndex(siblingIndex) +end + +return XUiArenaRankGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArena/XUiPanelActive.lua b/Resources/Scripts/XUi/XUiArena/XUiPanelActive.lua new file mode 100644 index 00000000..b2194e86 --- /dev/null +++ b/Resources/Scripts/XUi/XUiArena/XUiPanelActive.lua @@ -0,0 +1,341 @@ +local XUiPanelActive = XClass(nil, "XUiPanelActive") +local XUiArenaGrid = require("XUi/XUiArena/XUiArenaGrid") +local XUiArenaContributeScore = require("XUi/XUiArena/XUiArenaContributeScore") + +function XUiPanelActive:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + self:AutoAddListener() + self:RegisterRedPointEvent() + + self.TeamMemberList = {} + table.insert(self.TeamMemberList, self.GridMember1) + table.insert(self.TeamMemberList, self.GridMember2) + + self.GridTitleCache = {} + table.insert(self.GridTitleCache, self.GridTitle) + self.GridPlayerCache = {} + + self.GridPlayer.gameObject:SetActive(false) + self.IsShow = false + self.GameObject:SetActive(false) +end + +function XUiPanelActive:CheckRedPoint() + if self.EventId then + XRedPointManager.Check(self.EventId) + end +end + +function XUiPanelActive:RegisterRedPointEvent() + self.EventId = XRedPointManager.AddRedPointEvent(self.ImgRedLegion, self.OnCheckTaskNews, self, { XRedPointConditions.Types.CONDITION_ARENA_MAIN_TASK }) +end + +--@region 注册点击事件 + +function XUiPanelActive:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelActive:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelActive:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelActive:AutoAddListener() + self:RegisterClickEvent(self.BtnDetail, self.OnBtnDetailClick) + self:RegisterClickEvent(self.BtnTeamRank, self.OnBtnTeamRankClick) + self:RegisterClickEvent(self.BtnSelectWarZone, self.OnBtnSelectWarZoneClick) + self:RegisterClickEvent(self.BtnArenaTask, self.OnBtnArenaTaskClick) + self:RegisterClickEvent(self.BtnArenaLevelDetail, self.OnBtnArenaLevelDetailClick) + self:RegisterClickEvent(self.BtnShop, self.OnBtnShopClick) + self:RegisterClickEvent(self.BtnDetailsA, self.OnBtnBtnDetailsClick) + self:RegisterClickEvent(self.BtnDetailsB, self.OnBtnBtnDetailsClick) + self:RegisterClickEvent(self.BtnTxtNumber, self.OnBtnTxtNumber) +end + +function XUiPanelActive:OnBtnArenaLevelDetailClick() + XLuaUiManager.Open("UiArenaLevelDetail") +end + +function XUiPanelActive:OnBtnDetailClick() + XUiManager.UiFubenDialogTip("", CS.XTextManager.GetText("ArenaActivityStrategyContent") or "") +end + +function XUiPanelActive:OnBtnTeamRankClick() + XDataCenter.ArenaManager.RequestTeamRankData(function() + XLuaUiManager.Open("UiArenaTeamRank") + end) +end + +function XUiPanelActive:OnBtnSelectWarZoneClick() + XLuaUiManager.Open("UiArenaWarZone") +end + +function XUiPanelActive:OnBtnArenaTaskClick() + XLuaUiManager.Open("UiArenaTask") +end + +function XUiPanelActive:OnBtnShopClick() + XLuaUiManager.Open("UiShop", XShopManager.ShopType.Arena) +end + +function XUiPanelActive:OnBtnBtnDetailsClick() + XLuaUiManager.Open("UiArenaContributeTips", true) +end + +function XUiPanelActive:OnBtnTxtNumber() + XLuaUiManager.Open("UiArenaContributeTips", true, 2) +end + +--@endregion + +function XUiPanelActive:Show() + if self.IsShow then + XDataCenter.ArenaManager.RequestGroupMember() + return + end + + self.IsShow = true + self.GameObject:SetActive(true) + + XEventManager.AddEventListener(XEventId.EVENT_ARENA_MAIN_INFO, self.RefreshMainInfo, self) + + XDataCenter.ArenaManager.RequestGroupMember() + self:Refresh() +end + +function XUiPanelActive:Hide() + if not self.IsShow then + return + end + + self.IsShow = false + self.GameObject:SetActive(false) + + XEventManager.RemoveEventListener(XEventId.EVENT_ARENA_MAIN_INFO, self.RefreshMainInfo, self) +end + +function XUiPanelActive:Refresh() + local challengeCfg = XDataCenter.ArenaManager.GetCurChallengeCfg() + if challengeCfg then + self.TxtLevelRange.text = CS.XTextManager.GetText("ArenaPlayerLevelRange", challengeCfg.MinLv, challengeCfg.MaxLv) + self.TxtArenaRegion.text = challengeCfg.Name + end + + local arenaLevel = XDataCenter.ArenaManager.GetCurArenaLevel() + local arenaLevelCfg = XArenaConfigs.GetArenaLevelCfgByLevel(arenaLevel) + if arenaLevelCfg then + self.RImgArenaLevel:SetRawImage(arenaLevelCfg.Icon) + end + + XCountDown.BindTimer(self.TxtCountDownTime.gameObject, XArenaConfigs.ArenaTimerName, function(v) + self.TxtCountDownTime.text = CS.XTextManager.GetText("ArenaActivityEndCountDown", XUiHelper.GetTime(v, XUiHelper.TimeFormatType.CHALLENGE)) + end) +end + +function XUiPanelActive:UnBindTimer() + XCountDown.UnBindTimer(self.TxtCountDownTime.gameObject, XArenaConfigs.ArenaTimerName) +end + +function XUiPanelActive:RefreshMainInfo() + if not self.GameObject:Exist() then + return + end + + self:RefreshSelfInfo() + self:RefreshTeamInfo() + self:RefreshArenaPlayerRank() +end + +-- 自身 +function XUiPanelActive:RefreshSelfInfo() + local wave = XDataCenter.ArenaManager.GetWaveRate() + local selfInfo = XDataCenter.ArenaManager.GetPlayerArenaInfo() + local rank, region = XDataCenter.ArenaManager.GetPlayerArenaRankAndRegion() + local challengeCfg = XDataCenter.ArenaManager.GetCurChallengeCfg() + local contributeScore = XDataCenter.ArenaManager.GetContributeScoreByCfg(rank, challengeCfg, selfInfo.Point) + local sumContributeScore = XDataCenter.ArenaManager.GetContributeScore() + + self.TxtWave.text = CS.XTextManager.GetText("ArenaWaveRate", wave) + self.TxtSelfNickname.text = selfInfo.Name + self.TxtPoint.text = selfInfo.Point + self.TxtRank.text = "No." .. rank + self.TxtRankRange.text = XArenaConfigs.GetRankRegionText(region) + XUiPLayerHead.InitPortrait(selfInfo.CurrHeadPortraitId, selfInfo.CurrHeadFrameId, self.Head) + + if sumContributeScore >= CS.XGame.Config:GetInt("ArenaProtectContributeScore") then + self.PanelContribute.gameObject:SetActiveEx(false) + self.PanelContributeActivation.gameObject:SetActiveEx(true) + else + local max = CS.XGame.Config:GetInt("ArenaMaxContributeScore") + + self.TxtSumNumber.text = sumContributeScore + self.ImgJd.fillAmount = sumContributeScore / max + self.TxtMaxNumber.text = "/" .. max + self.TxtNumberDesc.text = CS.XTextManager.GetText("ContributeScoreNumberDesc", max) + self.PanelContribute.gameObject:SetActiveEx(true) + self.PanelContributeActivation.gameObject:SetActiveEx(false) + end + XUiArenaContributeScore.Refresh(self.TxtNumber, contributeScore, selfInfo.Point, "000000FF") +end + +-- 队伍 +function XUiPanelActive:RefreshTeamInfo() + self.TxtTeamPoint.text = XDataCenter.ArenaManager.GetArenaTeamTotalPoint() + local teamMemberList = XDataCenter.ArenaManager.GetPlayerArenaTeamMemberInfo() + for i, grid in ipairs(self.TeamMemberList) do + local head = XUiHelper.TryGetComponent(grid.transform, "Head") + local nickname = XUiHelper.TryGetComponent(grid.transform, "TxtNickname", "Text") + local btnHead = XUiHelper.TryGetComponent(grid.transform, "BtnHead", "Button") + + CsXUiHelper.RegisterClickEvent(btnHead, function() + local memberInfo = teamMemberList[i] + if memberInfo then + XDataCenter.PersonalInfoManager.ReqShowInfoPanel(memberInfo.Id) + end + end, true) + + local member = teamMemberList[i] + if member then + nickname.text = XDataCenter.SocialManager.GetPlayerRemark(member.Id, member.Name) + XUiPLayerHead.InitPortrait(member.CurrHeadPortraitId, member.CurrHeadFrameId, head) + else + nickname.text = "" + XUiPLayerHead.Hide(head) + end + end +end + + + +function XUiPanelActive:RefreshArenaPlayerRank() + local challengeCfg = XDataCenter.ArenaManager.GetCurChallengeCfg() + local rankData = XDataCenter.ArenaManager.GetPlayerArenaRankList() + + for _, v in ipairs(self.GridTitleCache) do + v.gameObject:SetActiveEx(false) + end + for _, v in ipairs(self.GridPlayerCache) do + v.GameObject:SetActiveEx(false) + end + + if not challengeCfg then + return + end + + self.SiblingIndex = 1 + local titleIndex = 1 + local playerIndex = 1 + + -- 晋级区 + if challengeCfg.DanUpRank > 0 then + self:AddTitle(titleIndex, challengeCfg.UpRewardId) + for i, info in ipairs(rankData.UpList) do + self:AddPlayer(playerIndex, info, i) + playerIndex = playerIndex + 1 + end + end + + -- 保级区 + titleIndex = titleIndex + 1 + self:AddTitle(titleIndex, challengeCfg.KeepRewardId) + for i, info in ipairs(rankData.KeepList) do + self:AddPlayer(playerIndex, info, i) + playerIndex = playerIndex + 1 + end + + -- 降级区 + if challengeCfg.DanDownRank > 0 then + titleIndex = titleIndex + 1 + self:AddTitle(titleIndex, challengeCfg.DownRewardId) + for i, info in ipairs(rankData.DownList) do + self:AddPlayer(playerIndex, info, i) + playerIndex = playerIndex + 1 + end + end +end + +function XUiPanelActive:AddTitle(rankRegion, rewardId) + local grid = self.GridTitleCache[rankRegion] + if not grid then + local go = CS.UnityEngine.GameObject.Instantiate(self.GridTitle.gameObject) + grid = go.transform + grid:SetParent(self.PanelContent, false) + table.insert(self.GridTitleCache, grid) + end + grid.gameObject:SetActive(true) + + grid:SetSiblingIndex(self.SiblingIndex - 1) + self.SiblingIndex = self.SiblingIndex + 1 + + -- 界面显示 + local rankRange = XUiHelper.TryGetComponent(grid.transform, "TxtRankRange", "Text") + local rewardIcon = XUiHelper.TryGetComponent(grid.transform, "ImgReward", "Image") + local rewardCount = XUiHelper.TryGetComponent(grid.transform, "ImgRewardCount", "Text") + local btnTitle = XUiHelper.TryGetComponent(grid.transform, "BtnTitle", "Button") + local btnReward = XUiHelper.TryGetComponent(grid.transform, "ImgReward/BtnReward", "Button") + + CsXUiHelper.RegisterClickEvent(btnTitle, function() + XLuaUiManager.Open("UiArenaLevelDetail") + end, true) + + CsXUiHelper.RegisterClickEvent(btnReward, function() + local list = XRewardManager.GetRewardList(rewardId) + if not list or #list <= 0 then + return + end + local goodsShowParams = XGoodsCommonManager.GetGoodsShowParamsByTemplateId(list[1].TemplateId) + if goodsShowParams.RewardType == XRewardManager.XRewardType.Character then + --从Tips的ui跳转需要关闭Tips的UI + XLuaUiManager.Open("UiCharacterDetail", list[1].TemplateId) + elseif goodsShowParams.RewardType == XRewardManager.XRewardType.Equip then + XLuaUiManager.Open("UiEquipDetail", list[1].TemplateId, true) + --从Tips的ui跳转需要关闭Tips的UI + else + XLuaUiManager.Open("UiTip", list[1] and list[1] or list[1].TemplateId) + end + end, true) + + rankRange.text = XArenaConfigs.GetRankRegionText(rankRegion) + local rewards = XRewardManager.GetRewardList(rewardId) + if not rewards or #rewards <= 0 then + return + end + local iconPath = XGoodsCommonManager.GetGoodsIcon(rewards[1].TemplateId) + self.RootUi:SetUiSprite(rewardIcon, iconPath) + rewardCount.text = rewards[1].Count +end + +function XUiPanelActive:AddPlayer(index, playerInfo, regionIndex) + local xUiArenaGrid = self.GridPlayerCache[index] + if not xUiArenaGrid then + local grid = CS.UnityEngine.GameObject.Instantiate(self.GridPlayer.gameObject) + grid.transform:SetParent(self.PanelContent, false) + xUiArenaGrid = XUiArenaGrid.New(grid) + table.insert(self.GridPlayerCache, xUiArenaGrid) + end + + xUiArenaGrid:Refresh(index, playerInfo, regionIndex) + xUiArenaGrid:SetSiblingIndex(self.SiblingIndex - 1) + self.SiblingIndex = self.SiblingIndex + 1 +end + +-- 红点 +function XUiPanelActive:OnCheckTaskNews(count) + if self.ImgRedLegion then + self.ImgRedLegion.gameObject:SetActive(count >= 0) + end +end + +return XUiPanelActive \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArena/XUiPanelPrepare.lua b/Resources/Scripts/XUi/XUiArena/XUiPanelPrepare.lua new file mode 100644 index 00000000..ae525830 --- /dev/null +++ b/Resources/Scripts/XUi/XUiArena/XUiPanelPrepare.lua @@ -0,0 +1,125 @@ +local XUiPanelPrepare = XClass(nil, "XUiPanelPrepare") + +function XUiPanelPrepare:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + self:AutoAddListener() + + self.IsShow = false + self.GameObject:SetActiveEx(false) + + self.RedPointApplyId = XRedPointManager.AddRedPointEvent(self.ImgRed, nil, self, { XRedPointConditions.Types.CONDITION_ARENA_APPLY }) +end + +function XUiPanelPrepare:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelPrepare:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelPrepare:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelPrepare:AutoAddListener() + self:RegisterClickEvent(self.BtnCreateTeam, self.OnBtnCreateTeamClick) + self:RegisterClickEvent(self.BtnLevelReward, self.OnBtnLevelRewardClick) + self:RegisterClickEvent(self.BtnShop, self.OnBtnShopClick) + self.BtnTranscript.CallBack = function() + self:OnBtnTranscriptClick() + end +end + +function XUiPanelPrepare:OnBtnCreateTeamClick() + if not XDataCenter.ArenaManager.CheckInTeamState() then + XUiManager.TipText("ArenaActivityTeamStatusWrong") + return + end + + XDataCenter.ArenaManager.RequestMyTeamInfo(function() + XLuaUiManager.Open("UiArenaTeam") + end) + XDataCenter.ArenaManager.RequestApplyData() +end + + +function XUiPanelPrepare:OnBtnLevelRewardClick() + XLuaUiManager.Open("UiArenaLevelDetail") +end + +function XUiPanelPrepare:OnBtnShopClick() + XLuaUiManager.Open("UiShop", XShopManager.ShopType.Arena) +end + +function XUiPanelPrepare:Show() + if self.IsShow then + return + end + + self.IsShow = true + self.GameObject:SetActiveEx(true) + self:Refresh() +end + +function XUiPanelPrepare:Hide() + if not self.IsShow then + return + end + + self.IsShow = false + self.GameObject:SetActiveEx(false) +end + +function XUiPanelPrepare:OnCheckApplyData(count) + self.ImgRed.gameObject:SetActiveEx(count > 0) +end + +function XUiPanelPrepare:Refresh() + local arenaLevel = XDataCenter.ArenaManager.GetCurArenaLevel() + local arenaLevelCfg = XArenaConfigs.GetArenaLevelCfgByLevel(arenaLevel) + if arenaLevelCfg then + self.RImgLevel:SetRawImage(arenaLevelCfg.Icon) + end + + local challengeCfg = XDataCenter.ArenaManager.GetCurChallengeCfg() + if challengeCfg then + self.TxtLevel.text = CS.XTextManager.GetText("ArenaPlayerLevelRange", challengeCfg.MinLv, challengeCfg.MaxLv) + end + + local isEnd = XDataCenter.ArenaManager.GetArenaActivityStatus() == XArenaActivityStatus.Over + self.PanelNorResult.gameObject:SetActiveEx(not isEnd) + self.PanelSelectResult.gameObject:SetActiveEx(isEnd) + self.PanelNorTeam.gameObject:SetActiveEx(isEnd) + self.PanelSelectTeam.gameObject:SetActiveEx(not isEnd) + self.TxtSelectResultTime.gameObject:SetActiveEx(isEnd) + self.TxtNorResultTime.gameObject:SetActiveEx(isEnd) + + local resultTime = XDataCenter.ArenaManager.GetResultStartTime() + self.TxtNorResultTime.text = resultTime + self.TxtSelectResultTime.text = resultTime + + local fightTime = XDataCenter.ArenaManager.GetFightStartTime() + self.TxtNorFightTime.text = fightTime + + local teamTime = XDataCenter.ArenaManager.GetTeamStartTime() + self.TxtNorTeamTime.text = teamTime + self.TxtSelectTeamTime.text = teamTime +end + +--成绩单按钮点击 +function XUiPanelPrepare:OnBtnTranscriptClick() + XDataCenter.ArenaManager.ScoreQueryReq(function() + XLuaUiManager.Open("UiArenaRank") + end) +end + +return XUiPanelPrepare \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArenaActivityResult/XUiArenaActivityResult.lua b/Resources/Scripts/XUi/XUiArenaActivityResult/XUiArenaActivityResult.lua new file mode 100644 index 00000000..50595a78 --- /dev/null +++ b/Resources/Scripts/XUi/XUiArenaActivityResult/XUiArenaActivityResult.lua @@ -0,0 +1,100 @@ +local XUiArenaActivityResult = XLuaUiManager.Register(XLuaUi, "UiArenaActivityResult") + +function XUiArenaActivityResult:OnAwake() + self:AutoAddListener() +end + +function XUiArenaActivityResult:OnStart(data, callBack, closeCb) + self.GridCommon.gameObject:SetActive(false) + + self.DynamicTable = XDynamicTableNormal.New(self.SViewReward.transform) + self.DynamicTable:SetProxy(XUiGridCommon) + self.DynamicTable:SetDelegate(self) + + self.Data = data + self.CallBack = callBack + self.CloseCb = closeCb + + XDataCenter.ArenaManager.ScoreQueryReq(function() + self:Refresh() + end) +end + +function XUiArenaActivityResult:AutoAddListener() + self:RegisterClickEvent(self.BtnBg, self.OnBtnBgClick) + self:RegisterClickEvent(self.BtnRanking, self.OnBtnRankingClick) +end + +function XUiArenaActivityResult:OnBtnBgClick() + self:Close() + if self.CloseCb then + self.CloseCb() + end +end + +function XUiArenaActivityResult:OnBtnRankingClick() + self:Close() + XLuaUiManager.Open("UiArenaRank") +end + +function XUiArenaActivityResult:Refresh() + if not self.Data then + return + end + + local arenaLevelCfg = XArenaConfigs.GetArenaLevelCfgByLevel(self.Data.NewArenaLevel) + local str + + --降级保护 + if self.Data.IsProtected then + str = CS.XTextManager.GetText("ArenaActivityProtected", arenaLevelCfg.Name) + else + if self.Data.OldArenaLevel < self.Data.NewArenaLevel then + str = CS.XTextManager.GetText("ArenaActivityResultUp", arenaLevelCfg.Name) + elseif self.Data.OldArenaLevel == self.Data.NewArenaLevel then + str = CS.XTextManager.GetText("ArenaActivityResultKeep", arenaLevelCfg.Name) + else + str = CS.XTextManager.GetText("ArenaActivityResultDown", arenaLevelCfg.Name) + end + end + self.RewardGoodsList = self:RewardGoodsList() + + self.TxtInfo.text = str + self.RImgArenaLevel:SetRawImage(arenaLevelCfg.Icon) + self.DynamicTable:SetDataSource(self.RewardGoodsList) + self.DynamicTable:ReloadDataASync() + + if self.CallBack then + self.CallBack() + end +end + +function XUiArenaActivityResult:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.RewardGoodsList[index] + grid.RootUi = self + grid:Refresh(data) + end +end + +function XUiArenaActivityResult:RewardGoodsList() + local list = {} + for i,v in ipairs(self.Data.RewardGoodsList) do + table.insert(list, v) + end + + local challengeCfg = XArenaConfigs.GetChallengeArenaCfgById(self.Data.ChallengeId) + local selfInfo = XDataCenter.ArenaManager.GetPlayerLastArenaInfo() + local point = selfInfo and selfInfo.Point or 0 + local contributeScore = XDataCenter.ArenaManager.GetContributeScoreByCfg(self.Data.GroupRank, challengeCfg, point) + + --显示战区贡献积分 + if contributeScore then + table.insert(list, { + TemplateId = XArenaConfigs.CONTRIBUTESCORE_ID, + Count = contributeScore, + }) + end + + return list +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArenaFightResult/XUiArenaFightResult.lua b/Resources/Scripts/XUi/XUiArenaFightResult/XUiArenaFightResult.lua new file mode 100644 index 00000000..59329d64 --- /dev/null +++ b/Resources/Scripts/XUi/XUiArenaFightResult/XUiArenaFightResult.lua @@ -0,0 +1,300 @@ +local XUiArenaFightResult = XLuaUiManager.Register(XLuaUi, "UiArenaFightResult") + +function XUiArenaFightResult:OnAwake() + self:AutoAddListener() +end + +function XUiArenaFightResult:OnStart(winData) + self.WinData = winData +end + +function XUiArenaFightResult:OnEnable() + self:Refresh() + self:RefreshUnionKill() +end + +function XUiArenaFightResult:AutoAddListener() + self:RegisterClickEvent(self.BtnNext, self.OnBtnNextClick) + self:RegisterClickEvent(self.BtnReFight, self.OnBtnReFightClick) + self:RegisterClickEvent(self.BtnExitFight, self.OnBtnExitFightClick) +end + +function XUiArenaFightResult:OnBtnNextClick() + if XDataCenter.ArenaManager.JudgeGotoMainWhenFightOver() then + return + end + + self:StopAudio() + self:Close() + local info = XDataCenter.ArenaManager.GetEnterAreaStageInfo() + local areaCfg = XArenaConfigs.GetArenaAreaStageCfgByAreaId(info.AreaId) + local index = info.StageIndex + 1 + XDataCenter.ArenaManager.SetEnterAreaStageInfo(info.AreaId, index) + XLuaUiManager.Open("UiNewRoomSingle", areaCfg.StageId[index]) +end + +function XUiArenaFightResult:OnBtnReFightClick() + + if self:IsUnionKillType() then + self:UnionKillHandelRefight() + return + end + + if XDataCenter.ArenaManager.JudgeGotoMainWhenFightOver() then + return + end + + self:StopAudio() + self:Close() + local info = XDataCenter.ArenaManager.GetEnterAreaStageInfo() + local areaCfg = XArenaConfigs.GetArenaAreaStageCfgByAreaId(info.AreaId) + XDataCenter.ArenaManager.SetEnterAreaStageInfo(info.AreaId, info.StageIndex) + XLuaUiManager.Open("UiNewRoomSingle", areaCfg.StageId[info.StageIndex]) +end + +function XUiArenaFightResult:OnBtnExitFightClick() + + if self:IsUnionKillType() then + self:StopAudio() + self:Close() + return + end + + if XDataCenter.ArenaManager.JudgeGotoMainWhenFightOver() then + return + end + + self:StopAudio() + self:Close() +end + +function XUiArenaFightResult:StopAudio() + if self.AudioInfo then + self.AudioInfo:Stop() + end +end + +function XUiArenaFightResult:IsUnionKillType() + if not self.WinData then return false end + local stageId = self.WinData.SettleData.StageId + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + return stageInfo.Type == XDataCenter.FubenManager.StageType.UnionKill +end + +-- 玩家点击了狙击战的重打 +function XUiArenaFightResult:UnionKillHandelRefight() + + local fightRoomData = XDataCenter.FubenUnionKillManager.GetCurRoomData() + -- 过期 + if fightRoomData and fightRoomData.LeaveReson and fightRoomData.LeaveReson > 0 then + self:StopAudio() + self:Close() + return + end + + -- trial + if fightRoomData.BossHpLeft <= 0 then + self:StopAudio() + self:Close() + + local unionKill = XDataCenter.FubenUnionKillManager.GetUnionKillInfo() + if unionKill and unionKill.CurSectionId > 0 then + local sectionTemplate = XFubenUnionKillConfigs.GetUnionSectionById(unionKill.CurSectionId) + XLuaUiManager.Open("UiNewRoomSingle", sectionTemplate.TrialStage) + end + else + self:StopAudio() + self:Close() + -- boss + local stageId = self.WinData.SettleData.StageId + XLuaUiManager.Open("UiNewRoomSingle", stageId) + end +end + +--[[狙击战]] +--[[失败:通用失败界面]] +--[[成功:点赞界面(如果有) --> 事件关(角色结算)--> 核心关(当前界面)]] +function XUiArenaFightResult:RefreshUnionKill() + if not self.WinData or not self.WinData.SettleData or + not self.WinData.SettleData.UnionKillResult then + return + end + self.BtnReFight.gameObject:SetActiveEx(false) + + local stageId = self.WinData.SettleData.StageId + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + + local data = self.WinData.SettleData.UnionKillResult + local scoreResultInfos = data.ScoreResultInfo + local time = CS.XGame.ClientConfig:GetFloat("BossSingleAnimaTime") + + self.PanelBossLoseHp.gameObject:SetActiveEx(true) + self.PanelSurplusHp.gameObject:SetActiveEx(true) + self.PanelLeftTime.gameObject:SetActiveEx(true) + self.PanelGroupCount.gameObject:SetActiveEx(false) + + local SetMaxTextDesc = function(text, ponit) + if ponit > 0 then + text.text = CS.XTextManager.GetText("ArenaMaxSingleScore", ponit) + else + text.text = CS.XTextManager.GetText("ArenaMaxSingleNoScore") + end + end + + local scoreRuleConfig = XFubenUnionKillConfigs.GetUnionScoreRuleById(stageId) + + SetMaxTextDesc(self.TxtHitSocreMax, scoreRuleConfig ~= nil and scoreRuleConfig.DamageMaxScore or 0) + SetMaxTextDesc(self.TxtRemainHpScoreMax, scoreRuleConfig ~= nil and scoreRuleConfig.HpMaxScore or 0) + SetMaxTextDesc(self.TxtRemainTimeScoreMax, scoreRuleConfig ~= nil and scoreRuleConfig.TimeMaxScore or 0) + + -- Region + self.TxtTile.text = stageCfg.Name + self.PanelNewRecord.gameObject:SetActiveEx(scoreResultInfos.Point > scoreResultInfos.OldPoint) + + XUiHelper.Tween(time, function(f) + if XTool.UObjIsNil(self.Transform) then + return + end + + -- PanelBossLoseHp + local hitCombo = math.floor(f * scoreResultInfos.EnemyHurt) + local hitScore = '+' .. math.floor(f * scoreResultInfos.EnemyPoint) + self.TxtHitCombo.text = hitCombo + self.TxtHitScore.text = hitScore + + -- PanelSurplusHp + local remainHp = math.floor(f * scoreResultInfos.MyHpLeft) .. "%" + local remainHpScore = '+' .. math.floor(f * scoreResultInfos.MyHpPoint) + self.TxtRemainHp.text = remainHp + self.TxtRemainHpScore.text = remainHpScore + + -- PanelLeftTime + local remainTime = XUiHelper.GetTime(math.floor(f * scoreResultInfos.TimeLeft), XUiHelper.TimeFormatType.SHOP) + local remainTimeSacore = '+' .. math.floor(f * scoreResultInfos.TimePoint) + self.TxtRemainTime.text = remainTime + self.TxtRemainTimeScore.text = remainTimeSacore + + -- StageTime + local costTime = XUiHelper.GetTime(math.floor(f * scoreResultInfos.FightTime), XUiHelper.TimeFormatType.SHOP) + self.TxtCostTime.text = costTime + + -- -- 当前总分 + local point = math.floor(f * scoreResultInfos.Point) + self.TxtPoint.text = point + + -- -- 历史最高分 + local highScore = math.floor(f * scoreResultInfos.OldPoint) + self.TxtHighScore.text = highScore + + end, function() + self:StopAudio() + end) + +end + +--[[纷争战区]] +function XUiArenaFightResult:Refresh() + if not self.WinData or not self.WinData.SettleData or + not self.WinData.SettleData.ArenaResult then + return + end + + self.BtnReFight.gameObject:SetActiveEx(true) + local time = CS.XGame.ClientConfig:GetFloat("BossSingleAnimaTime") + local data = self.WinData.SettleData.ArenaResult + local info = XDataCenter.ArenaManager.GetEnterAreaStageInfo() + self.TxtTile.text = CS.XTextManager.GetText("ArenaActivityStage", info.StageIndex) + self.PanelNewRecord.gameObject:SetActiveEx(data.Point > data.OldPoint) + local markCfg = XDataCenter.ArenaManager.GetMarkCfg() + + local isShowEnemyHp = (markCfg and markCfg.EnemyHpPoint ~= nil) and markCfg.EnemyHpPoint ~= "" + local isShowMyHp = (markCfg and markCfg.MyHpPoint ~= nil) and markCfg.MyHpPoint ~= "" + local isShowLeftTime = (markCfg and markCfg.TimePoint ~= nil) and markCfg.TimePoint ~= "" + local isShowGourp = (markCfg and markCfg.NpcGroupPoint ~= nil) and markCfg.NpcGroupPoint ~= "" + + self.PanelBossLoseHp.gameObject:SetActiveEx(isShowEnemyHp) + self.PanelSurplusHp.gameObject:SetActiveEx(isShowMyHp) + self.PanelLeftTime.gameObject:SetActiveEx(isShowLeftTime) + self.PanelGroupCount.gameObject:SetActiveEx(isShowGourp) + + local SetMaxTextDesc = function(text, ponit) + if ponit > 0 then + text.text = CS.XTextManager.GetText("ArenaMaxSingleScore", ponit) + else + text.text = CS.XTextManager.GetText("ArenaMaxSingleNoScore") + end + end + + SetMaxTextDesc(self.TxtHitSocreMax, markCfg ~= nil and markCfg.MaxEnemyHpPoint or 0) + SetMaxTextDesc(self.TxtRemainHpScoreMax, markCfg ~= nil and markCfg.MaxMyHpPoint or 0) + SetMaxTextDesc(self.TxtRemainTimeScoreMax, markCfg ~= nil and markCfg.MaxTimePoint or 0) + SetMaxTextDesc(self.TxtGroupCountScoreMax, markCfg ~= nil and markCfg.MaxNpcGroupPoint or 0) + + if markCfg and data.Point > data.OldPoint then + XDataCenter.ArenaManager.ChangeArenaStageScore(info.AreaId, info.StageIndex, data.Point) + end + -- 刷新副本入口数据 + XDataCenter.ArenaManager.RequestGroupMember() + -- 播放音效 + self.AudioInfo = CS.XAudioManager.PlaySound(XSoundManager.UiBasicsMusic.UiSettle_Win_Number) + + XUiHelper.Tween(time, function(f) + if XTool.UObjIsNil(self.Transform) then + return + end + + -- 歼敌奖励 + if isShowEnemyHp then + local hitCombo = math.floor(f * data.EnemyHurt) + local hitScore = '+' .. math.floor(f * data.EnemyPoint) + self.TxtHitCombo.text = hitCombo + self.TxtHitScore.text = hitScore + end + + -- 我方血量 + if isShowMyHp then + local remainHp = math.floor(f * data.MyHpLeft) .. "%" + local remainHpScore = '+' .. math.floor(f * data.MyHpPoint) + self.TxtRemainHp.text = remainHp + self.TxtRemainHpScore.text = remainHpScore + end + + -- 剩余时间 + if isShowLeftTime then + local remainTime = XUiHelper.GetTime(math.floor(f * data.TimeLeft), XUiHelper.TimeFormatType.SHOP) + local remainTimeSacore = '+' .. math.floor(f * data.TimePoint) + self.TxtRemainTime.text = remainTime + self.TxtRemainTimeScore.text = remainTimeSacore + end + + -- 波次奖励 + if isShowGourp then + local groupCount = CS.XTextManager.GetText("ArenaGrouplScore", math.floor(f * data.NpcGroup)) + local groupCountSacore = '+' .. math.floor(f * data.NpcGroupPoint) + self.TxtGroupCount.text = groupCount + self.TxtGroupCountScore.text = groupCountSacore + end + + -- 通关时间 + local costTime = XUiHelper.GetTime(math.floor(f * data.FightTime), XUiHelper.TimeFormatType.SHOP) + self.TxtCostTime.text = costTime + + -- 当前总分 + local point = math.floor(f * data.Point) + if markCfg and data.Point >= markCfg.MaxPoint and markCfg.MaxPoint > 0 then + self.TxtPoint.text = CS.XTextManager.GetText("ArenaMaxAllScore", point) + else + self.TxtPoint.text = point + end + + -- 历史最高分 + local highScore = math.floor(f * data.OldPoint) + if markCfg and data.OldPoint >= markCfg.MaxPoint and markCfg.MaxPoint > 0 then + self.TxtHighScore.text = highScore .. "/" .. markCfg.MaxPoint + else + self.TxtHighScore.text = highScore + end + end, function() + self:StopAudio() + end) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArenaLevelDetail/ArenaLevelDetailCommon/XUiGridArenaLevel.lua b/Resources/Scripts/XUi/XUiArenaLevelDetail/ArenaLevelDetailCommon/XUiGridArenaLevel.lua new file mode 100644 index 00000000..dbe33437 --- /dev/null +++ b/Resources/Scripts/XUi/XUiArenaLevelDetail/ArenaLevelDetailCommon/XUiGridArenaLevel.lua @@ -0,0 +1,21 @@ +local XUiGridArenaLevel = XClass(nil, "XUiGridArenaLevel") + +function XUiGridArenaLevel:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiGridArenaLevel:ResetData(level, curLevel, icon, name) + self.ImgCurLevel.gameObject:SetActiveEx(level == curLevel) + self.RImgIcon:SetRawImage(icon) + if self.TxtName then + self.TxtName.text = name + end +end + +function XUiGridArenaLevel:SetSelect(isSelected) + self.ImgSelected.gameObject:SetActiveEx(isSelected) +end + +return XUiGridArenaLevel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArenaLevelDetail/ArenaLevelDetailCommon/XUiGridRegion.lua b/Resources/Scripts/XUi/XUiArenaLevelDetail/ArenaLevelDetailCommon/XUiGridRegion.lua new file mode 100644 index 00000000..bf2f8e19 --- /dev/null +++ b/Resources/Scripts/XUi/XUiArenaLevelDetail/ArenaLevelDetailCommon/XUiGridRegion.lua @@ -0,0 +1,44 @@ +local XUiGridRegion = XClass(nil, "XUiGridRegion") + +function XUiGridRegion:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + + self.GridCommon.gameObject:SetActive(false) + + self.IsShow = true + self.GameObject:SetActive(true) + + self.DynamicTable = XDynamicTableNormal.New(self.SViewReward.transform) + self.DynamicTable:SetProxy(XUiGridCommon) + self.DynamicTable:SetDelegate(self) +end + +function XUiGridRegion:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = nil + if self.DataList then + data = self.DataList[index] + end + + grid.RootUi = self.RootUi + grid:Refresh(data) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + grid:OnBtnClickClick() + end +end + +function XUiGridRegion:SetMetaData(title, des, isNotBorder, rewardList) + self.TxtRankRegion.text = title + self.TxtRegionDesc.text = des + self.SViewReward.gameObject:SetActive(isNotBorder) + if isNotBorder then + self.DataList = rewardList or {} + self.DynamicTable:SetTotalCount(#self.DataList) + self.DynamicTable:ReloadDataSync() + end +end + +return XUiGridRegion \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArenaLevelDetail/XUiArenaLevelDetail.lua b/Resources/Scripts/XUi/XUiArenaLevelDetail/XUiArenaLevelDetail.lua new file mode 100644 index 00000000..0ddf72d5 --- /dev/null +++ b/Resources/Scripts/XUi/XUiArenaLevelDetail/XUiArenaLevelDetail.lua @@ -0,0 +1,114 @@ +local XUiArenaLevelDetail = XLuaUiManager.Register(XLuaUi, "UiArenaLevelDetail") + +local XUiGridArenaLevel = require("XUi/XUiArenaLevelDetail/ArenaLevelDetailCommon/XUiGridArenaLevel") +local XUiGridRegion = require("XUi/XUiArenaLevelDetail/ArenaLevelDetailCommon/XUiGridRegion") + +function XUiArenaLevelDetail:OnAwake() + self:AutoAddListener() + self.GridArenaLevel.gameObject:SetActive(false) +end + +function XUiArenaLevelDetail:OnStart() + self.GridRegionList = {} + for i = 1, 3 do + local regionGrid = XUiGridRegion.New(self["GridRegion" .. i], self) + table.insert(self.GridRegionList, regionGrid) + end + + self.DynamicTable = XDynamicTableNormal.New(self.SViewArenaLevel.transform) + self.DynamicTable:SetProxy(XUiGridArenaLevel) + self.DynamicTable:SetDelegate(self) +end + +function XUiArenaLevelDetail:OnEnable() + self:SetUiMetaData() +end + +function XUiArenaLevelDetail:AutoAddListener() + self:RegisterClickEvent(self.BtnBg, self.OnBtnBgClick) +end + +function XUiArenaLevelDetail:OnBtnBgClick() + self:Close() +end + +--动态列表事件 +function XUiArenaLevelDetail:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.DataList[index] + local level = data.ArenaLv + local curLevel = XDataCenter.ArenaManager.GetCurArenaLevel() + local cfg = XArenaConfigs.GetArenaLevelCfgByLevel(level) + grid:ResetData(level, curLevel, cfg.Icon) + grid:SetSelect(index == self.CurIndex) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + if index == self.CurIndex then + return + end + + local lastGrid = self.DynamicTable:GetGridByIndex(self.CurIndex) + if lastGrid then + lastGrid:SetSelect(false) + end + grid:SetSelect(true) + + self.CurIndex = index + self:RefreshSelect() + end +end + +function XUiArenaLevelDetail:SetUiMetaData() + local challengeId = XDataCenter.ArenaManager.GetCurChallengeId() + local arenaLevel = XDataCenter.ArenaManager.GetCurArenaLevel() + + self.DataList = XArenaConfigs.GetChallengeCfgListById(challengeId) + local challengeCfg = XDataCenter.ArenaManager.GetCurChallengeCfg() + if challengeCfg then + self.TxtGrade.text = "Lv" .. challengeCfg.MinLv .. "-" .. challengeCfg.MaxLv + end + + self.DynamicTable:SetTotalCount(#self.DataList) + if #self.DataList > 0 then + self.DynamicTable:ReloadDataSync(1) + else + self.DynamicTable:ReloadDataSync() + end + + self.CurIndex = 0 + for i, cfg in ipairs(self.DataList) do + if cfg.ArenaLv == arenaLevel then + self.CurIndex = i + end + end + self:RefreshSelect() +end + +function XUiArenaLevelDetail:RefreshSelect() + if not self.GameObject:Exist() then + return + end + + if not self.DataList then + return + end + + if not self.CurIndex or self.CurIndex <= 0 then + return + end + + self:RefreshRankRegionGrid() +end + +function XUiArenaLevelDetail:RefreshRankRegionGrid() + local challengeCfg = self.DataList[self.CurIndex] + for region, grid in ipairs(self.GridRegionList) do + local isNotBorder = not ((challengeCfg.ArenaLv == 1 and region == XArenaPlayerRankRegion.DownRegion) or + (XDataCenter.ArenaManager.IsMaxArenaLevel(challengeCfg.ArenaLv) and region == XArenaPlayerRankRegion.UpRegion)) + + local des = isNotBorder and XArenaConfigs.GetRankRegionDescText(region, challengeCfg) or XArenaConfigs.GetRankNotRegionDescText(region) + local title = XArenaConfigs.GetRankRegionColorText(region) + local rewardId = XArenaConfigs.GetRankRegionRewardId(region, challengeCfg) + local rewardList = rewardId and rewardId ~= 0 and XRewardManager.GetRewardList(rewardId) or {} + grid:SetMetaData(title, des, isNotBorder, rewardList) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArenaOnline/XUiArenaOnlineChapter.lua b/Resources/Scripts/XUi/XUiArenaOnline/XUiArenaOnlineChapter.lua new file mode 100644 index 00000000..f0307541 --- /dev/null +++ b/Resources/Scripts/XUi/XUiArenaOnline/XUiArenaOnlineChapter.lua @@ -0,0 +1,103 @@ +local XUiArenaOnlineChapter = XLuaUiManager.Register(XLuaUi, "UiArenaOnlineChapter") +local XUiChapterPrefab = require("XUi/XUiArenaOnline/XUiChapterPrefab") + +function XUiArenaOnlineChapter:OnAwake() + self:AutoAddListener() +end + +function XUiArenaOnlineChapter:OnStart() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + local chapterCfg = XDataCenter.ArenaOnlineManager.GetCurChapterCfg() + if not chapterCfg then return end + + self:CheckFirstOpen() + self.Resource = CS.XResourceManager.Load(chapterCfg.PrefabPath) + local prefab = CS.UnityEngine.Object.Instantiate(self.Resource.Asset) + prefab.transform:SetParent(self.PanelChapter, false) + prefab.gameObject:SetLayerRecursively(self.PanelChapter.gameObject.layer) + + self.ChapterGrid = XUiChapterPrefab.New(prefab, self) +end + +function XUiArenaOnlineChapter:OnEnable() + XEventManager.AddEventListener(XEventId.EVENT_ARENAONLINE_WEEK_REFRESH, self.OnArenaOnlineWeekRefrsh, self) + XEventManager.AddEventListener(XEventId.EVENT_ARENAONLINE_DAY_REFRESH, self.OnArenaOnlineDayRefrsh, self) + + if self.ChapterGrid then + self.ChapterGrid:OnEnable() + end +end + +function XUiArenaOnlineChapter:OnDisable() + if self.ChapterGrid then + self.ChapterGrid:OnDisable() + end + + XEventManager.RemoveEventListener(XEventId.EVENT_ARENAONLINE_WEEK_REFRESH, self.OnArenaOnlineWeekRefrsh, self) + XEventManager.RemoveEventListener(XEventId.EVENT_ARENAONLINE_DAY_REFRESH, self.OnArenaOnlineDayRefrsh, self) +end + +function XUiArenaOnlineChapter:GetSortingOrder() + return self.Canvas.sortingOrder +end + +function XUiArenaOnlineChapter:CheckFirstOpen() + local firstOpen = XDataCenter.ArenaOnlineManager.CheckFirstOpen() + if firstOpen then + local chapterCfg = XDataCenter.ArenaOnlineManager.GetCurChapterCfg() + XDataCenter.MovieManager.PlayMovie(chapterCfg.StoryId, function() + XDataCenter.ArenaOnlineManager.SetFirstOpen() + XSoundManager.PauseMusic() + end) + end +end + +-- 区域联机周刷新 +function XUiArenaOnlineChapter:OnArenaOnlineWeekRefrsh() + XDataCenter.ArenaOnlineManager.RunMain() +end + +-- 区域联机日刷新 +function XUiArenaOnlineChapter:OnArenaOnlineDayRefrsh() + if self.ChapterGrid then + self.ChapterGrid:OnEnable() + end +end + +function XUiArenaOnlineChapter:OnDestroy() + if self.Resource then + self.Resource:Release() + end + + if self.ChapterGrid then + self.ChapterGrid:OnDestroy() + CS.UnityEngine.Object.Destroy(self.ChapterGrid.GameObject) + end +end + +function XUiArenaOnlineChapter:AutoAddListener() + self:BindHelpBtn(self.BtnHelp, "ArenaOnline") + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end +end + +function XUiArenaOnlineChapter:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiArenaOnlineChapter:OnBtnBackClick() + self:Close() +end + +function XUiArenaOnlineChapter:OnGetEvents() + return {CS.XEventId.EVENT_UI_DONE} +end + +function XUiArenaOnlineChapter:OnNotify(evt) + if evt == CS.XEventId.EVENT_UI_DONE then + --区域变更播放动画 + if XDataCenter.ArenaOnlineManager.IsAreaChanged() then + self.ChapterGrid:PlayTipsAnimation() + end + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArenaOnline/XUiArenaOnlineInvitation.lua b/Resources/Scripts/XUi/XUiArenaOnline/XUiArenaOnlineInvitation.lua new file mode 100644 index 00000000..60aee4e5 --- /dev/null +++ b/Resources/Scripts/XUi/XUiArenaOnline/XUiArenaOnlineInvitation.lua @@ -0,0 +1,199 @@ +local XUiArenaOnlineInvitation = XLuaUiManager.Register(XLuaUi, "UiArenaOnlineInvitation") +local AreaOnlineInvitationDes +local AreaOnlineShowTime + +local HideInvitationWnds = +{ + ["UiNewDrawMain"] = true, + ["UiDraw"] = true, + ["UiPurchase"] = true, + ["UiNewRoomSingle"] = true, + ["UiLoading"] = true, + ["UiSettleLose"] = true, + ["UiMovie"] = true, + ["UiMultiplayerRoom"] = true, + ["UiSocial"] = true, + ["UiRoomCharacter"] = true, + ["UiFight"] = true, + ["UiDormMain"] = true, +} + +function XUiArenaOnlineInvitation:OnAwake() + AreaOnlineInvitationDes = CS.XTextManager.GetText("AreaOnlineInvitationDes") + AreaOnlineShowTime = XArenaOnlineConfigs.ArenaOnlineShowTime + + self.BtnInvite.gameObject:SetActiveEx(false) + self.BtnMainInvite.gameObject:SetActiveEx(false) + + self:AddListener() + self.WndCount = 0 --用于记录需要隐藏的窗口的数量 +end + +function XUiArenaOnlineInvitation:OnStart() + for k,_ in pairs(HideInvitationWnds) do + if XLuaUiManager.IsUiShow(k) then + self.WndCount = self.WndCount + 1 + end + end + self:CheckShowInvitationButton() +end + +function XUiArenaOnlineInvitation:OnEnable() + self:TimerEvent() + XEventManager.AddEventListener(XEventId.EVENT_CHAT_RECEIVE_PRIVATECHAT, self.OnPrivateChat, self) + XEventManager.AddEventListener(XEventId.EVENT_BLACK_DATA_CHANGE, self.OnBlackDataChange, self) +end + +function XUiArenaOnlineInvitation:OnGetEvents() + return + { CS.XEventId.EVENT_UI_ENABLE, + CS.XEventId.EVENT_UI_DISABLE, + XEventId.EVENT_MOVIE_BEGIN, + XEventId.EVENT_MOVIE_END, + CS.XEventId.EVENT_VIDEO_ACTION_PLAY, + CS.XEventId.EVENT_VIDEO_ACTION_STOP, + } +end + +function XUiArenaOnlineInvitation:OnNotify(evt, ...) + + --剧情相关、录像相关 + if evt == XEventId.EVENT_MOVIE_BEGIN or + evt == XEventId.EVENT_MOVIE_END or + evt == CS.XEventId.EVENT_VIDEO_ACTION_PLAY or + evt == CS.XEventId.EVENT_VIDEO_ACTION_STOP then + self:CheckShowInvitationButton() + return + end + + local args = {...} + local uiObject = args[1] + + if uiObject.UiData.UiType ~= CS.XUiType.Normal then + return + end + + local uiName = uiObject.UiData.UiName + + if uiName == self.Name then + return + end + + if HideInvitationWnds[uiName] then + if evt == CS.XEventId.EVENT_UI_ENABLE then + self.WndCount = self.WndCount + 1 + elseif evt == CS.XEventId.EVENT_UI_DISABLE then + self.WndCount = self.WndCount - 1 + end + end + + if evt == CS.XEventId.EVENT_UI_ENABLE then + self:CheckShowInvitationButton() + end +end + +function XUiArenaOnlineInvitation:TimerEvent() + if AreaOnlineShowTime < 0 then + return + end + + self.Timer = XScheduleManager.ScheduleOnce(function() + self:Close() + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end, AreaOnlineShowTime * 1000) +end + +function XUiArenaOnlineInvitation:OnDisable() + XEventManager.RemoveEventListener(XEventId.EVENT_CHAT_RECEIVE_PRIVATECHAT, self.OnPrivateChat, self) + XEventManager.RemoveEventListener(XEventId.EVENT_BLACK_DATA_CHANGE, self.OnBlackDataChange, self) +end + +function XUiArenaOnlineInvitation:OnDestroy() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end + +function XUiArenaOnlineInvitation:AddListener() + self.BtnInvite.CallBack = function() self:OnBtnInviteClick() end + self.BtnMainInvite.CallBack = function() self:OnBtnInviteClick() end +end + +function XUiArenaOnlineInvitation:OnBtnInviteClick() + self:Close() + XUiManager.DialogTip("", AreaOnlineInvitationDes, XUiManager.DialogType.Normal, function () + XDataCenter.ArenaOnlineManager.ClearPrivateChatData() + end, + function() + self:OnBtnSocialClick() + end) +end + +function XUiArenaOnlineInvitation:RefreshCount() + local datas = XDataCenter.ArenaOnlineManager.GetPrivateChatData() or {} + local count = #datas + + local text = count == 0 and "" or (count > 99 and "..." or count) + self.TxtCount0.text = text + self.TxtCount1.text = text +end + +function XUiArenaOnlineInvitation:OnPrivateChat() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end + self:TimerEvent() + self.Datas = XDataCenter.ArenaOnlineManager.GetPrivateChatData() + self.Count = #self.Datas + self:RefreshCount() +end + +function XUiArenaOnlineInvitation:OnBtnSocialClick() + XDataCenter.ArenaOnlineManager.ClearPrivateChatData() + if XLuaUiManager.IsUiShow("UiSocial") then + XLuaUiManager.PopThenOpen("UiSocial", function() + XEventManager.DispatchEvent(XEventId.EVENT_FRIEND_OPEN_PRIVATE_VIEW, self.Datas[self.Count].SenderId) + end) + else + XLuaUiManager.Open("UiSocial", function() + XEventManager.DispatchEvent(XEventId.EVENT_FRIEND_OPEN_PRIVATE_VIEW, self.Datas[self.Count].SenderId) + end) + end + +end + +function XUiArenaOnlineInvitation:CheckShowInvitationButton() + + self.Datas = XDataCenter.ArenaOnlineManager.GetPrivateChatData() + self.Count = #self.Datas + + if self.WndCount > 0 or CS.XFight.IsRunning + or XDataCenter.MovieManager.IsPlayingMovie() or + XDataCenter.VideoManager.IsPlaying() or + XHomeSceneManager.IsInHomeScene() then + self.BtnInvite.gameObject:SetActiveEx(false) + self.BtnMainInvite.gameObject:SetActiveEx(false) + else + self:RefreshCount() + if XLuaUiManager.IsUiShow("UiMain") then + self.BtnInvite.gameObject:SetActiveEx(false) + self.BtnMainInvite.gameObject:SetActiveEx(true) + else + self.BtnInvite.gameObject:SetActiveEx(true) + self.BtnMainInvite.gameObject:SetActiveEx(false) + end + end +end + +function XUiArenaOnlineInvitation:OnBlackDataChange() + local data = XDataCenter.ArenaOnlineManager.GetPrivateChatData() + local count = #data + if not XTool.IsNumberValid(count) then + self:Close() + return + end + self:OnPrivateChat() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArenaOnline/XUiArenaOnlineSection.lua b/Resources/Scripts/XUi/XUiArenaOnline/XUiArenaOnlineSection.lua new file mode 100644 index 00000000..ff3ba116 --- /dev/null +++ b/Resources/Scripts/XUi/XUiArenaOnline/XUiArenaOnlineSection.lua @@ -0,0 +1,122 @@ +local XUiArenaOnlineSection = XLuaUiManager.Register(XLuaUi, "UiArenaOnlineSection") +local XUiSectionPrefab = require("XUi/XUiArenaOnline/XUiSectionPrefab") +local XUiPanelStageDetail = require("XUi/XUiArenaOnline/XUiPanelStageDetail") + +function XUiArenaOnlineSection:OnAwake() + self:AutoAddListener() +end + +function XUiArenaOnlineSection:OnStart() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self.DetailPanel = XUiPanelStageDetail.New(self, self.PanelDetail, function() + self.AssetPanel.GameObject:SetActiveEx(false) + end, function() + self.AssetPanel.GameObject:SetActiveEx(true) + end) + + local sectionCfg = XDataCenter.ArenaOnlineManager.GetCurSectionCfg() + if not sectionCfg then return end + + local prefabpath = XDataCenter.ArenaOnlineManager.GetCurSectionPrefabPath() + if prefabpath then + self.Resource = CS.XResourceManager.Load(prefabpath) + end + local prefab = CS.UnityEngine.Object.Instantiate(self.Resource.Asset) + prefab.transform:SetParent(self.PanelCase, false) + prefab.gameObject:SetLayerRecursively(self.PanelCase.gameObject.layer) + + self.SectionGrid = XUiSectionPrefab.New(prefab, self) +end + +function XUiArenaOnlineSection:OpenStageDetial(stageId) + self.DetailPanel:Show(stageId) +end + +function XUiArenaOnlineSection:OnEnable() + if self.SectionGrid then + self.SectionGrid:OnEnable() + end + + if self.DetailPanel then + self.DetailPanel:Refresh(true) + end + + XEventManager.AddEventListener(XEventId.EVENT_ROOM_CANCEL_MATCH, self.OnCancelMatch, self) + XEventManager.AddEventListener(XEventId.EVENT_ROOM_ENTER_ROOM, self.EnterRoom, self) + XEventManager.AddEventListener(XEventId.EVENT_ARENAONLINE_WEEK_REFRESH, self.OnArenaOnlineWeekRefrsh, self) + XEventManager.AddEventListener(XEventId.EVENT_ARENAONLINE_DAY_REFRESH, self.OnArenaOnlineDayRefrsh, self) +end + +function XUiArenaOnlineSection:OnDisable() + XEventManager.RemoveEventListener(XEventId.EVENT_ROOM_CANCEL_MATCH, self.OnCancelMatch, self) + XEventManager.RemoveEventListener(XEventId.EVENT_ROOM_ENTER_ROOM, self.EnterRoom, self) + XEventManager.RemoveEventListener(XEventId.EVENT_ARENAONLINE_WEEK_REFRESH, self.OnArenaOnlineWeekRefrsh, self) + XEventManager.RemoveEventListener(XEventId.EVENT_ARENAONLINE_DAY_REFRESH, self.OnArenaOnlineDayRefrsh, self) +end + +-- 区域联机周刷新 +function XUiArenaOnlineSection:OnArenaOnlineWeekRefrsh() + XDataCenter.ArenaOnlineManager.RunMain() +end + +-- 区域联机日刷新 +function XUiArenaOnlineSection:OnArenaOnlineDayRefrsh() + local refresh = XDataCenter.ArenaOnlineManager.CheckCurSectionDayRefrsh() + if not refresh then return end + + XUiManager.TipMsg(CS.XTextManager.GetText("ArenaOnlineDayTimeOut")) + if XDataCenter.RoomManager.Matching then + XDataCenter.RoomManager.CancelMatch(function() + self.DetailPanel:OnCancelMatch() + self:Close() + end) + else + self:Close() + end +end + +function XUiArenaOnlineSection:OnDestroy() + if self.Resource then + self.Resource:Release() + end + + if self.SectionGrid then + self.SectionGrid:OnDestroy() + CS.UnityEngine.Object.Destroy(self.SectionGrid.GameObject) + end +end + +function XUiArenaOnlineSection:OnHideDetail() + self.DetailPanel:Hide() +end + +function XUiArenaOnlineSection:AutoAddListener() + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end +end + +function XUiArenaOnlineSection:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiArenaOnlineSection:OnCancelMatch() + self.DetailPanel:OnCancelMatch() +end + +function XUiArenaOnlineSection:EnterRoom() + self.DetailPanel:ResetState() +end + +function XUiArenaOnlineSection:OnBtnBackClick() + if XDataCenter.RoomManager.Matching then + local title = CS.XTextManager.GetText("TipTitle") + local cancelMatchMsg = CS.XTextManager.GetText("OnlineInstanceCancelMatch") + XUiManager.DialogTip(title, cancelMatchMsg, XUiManager.DialogType.Normal, nil, function() + XDataCenter.RoomManager.CancelMatch(function() + self:Close() + end) + end) + else + self:Close() + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArenaOnline/XUiChapterPrefab.lua b/Resources/Scripts/XUi/XUiArenaOnline/XUiChapterPrefab.lua new file mode 100644 index 00000000..8e4df135 --- /dev/null +++ b/Resources/Scripts/XUi/XUiArenaOnline/XUiChapterPrefab.lua @@ -0,0 +1,130 @@ +local XUiChapterPrefab = XClass(nil, "XUiChapterPrefab") +local XUiGridSection = require("XUi/XUiArenaOnline/XUiGridSection") + +local MAX_SECTION_COUNT = 10 +function XUiChapterPrefab:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + self.SectionGrids = {} + XTool.InitUiObject(self) + self.Canvas.sortingOrder = self.Canvas.sortingOrder + self.UiRoot:GetSortingOrder() + self.PanelTip.sortingOrder = self.PanelTip.sortingOrder + self.UiRoot:GetSortingOrder() + self.PanelTip.gameObject:SetActiveEx(false) +end + +function XUiChapterPrefab:OnEnable() + self.Show = true + self:Refresh() + --XEventManager.AddEventListener(XEventId.EVENT_ARENAONLINE_WEEK_REFRESH, self.AreaChange, self) +end + +function XUiChapterPrefab:OnDisable() + self.Show = false +end + +function XUiChapterPrefab:Refresh() + self.AnimEnable:PlayTimelineAnimation() + local chapterCfg = XDataCenter.ArenaOnlineManager.GetCurChapterCfg() + if not chapterCfg then return end + + self.TxtName.text = chapterCfg.Title + self.TxtLv.text = CS.XTextManager.GetText("ArenaOnlineChapterLevel", chapterCfg.MinLevel, chapterCfg.MaxLevel) + self:SetSectionInfo() + self:SetTimer() +end + +function XUiChapterPrefab:SetSectionInfo() + local sectionDatas = XDataCenter.ArenaOnlineManager.GetSectionData() + local index = 0 + for _, sectionData in ipairs(sectionDatas) do + index = index + 1 + local name = "GridSection" .. index + local go = XUiHelper.TryGetComponent(self.PanelSectionContent, name) + if go then + if not self.SectionGrids[sectionData.Id] then + self.SectionGrids[sectionData.Id] = XUiGridSection.New(go, self.UiRoot) + end + + self.SectionGrids[sectionData.Id]:Refresh(sectionData.Id) + end + end + + index = index + 1 + for i = index, MAX_SECTION_COUNT do + local name = "GridSection" .. i + local go = XUiHelper.TryGetComponent(self.PanelSectionContent, name) + if go then + go.gameObject:SetActiveEx(false) + end + end +end + +function XUiChapterPrefab:SetTimer() + local endTimeSecond = XDataCenter.ArenaOnlineManager.GetNextRefreshTime() + local now = XTime.GetServerNowTimestamp() + if now <= endTimeSecond then + local activeOverStr = CS.XTextManager.GetText("ArenaOnlineLeftTimeOver") + self:StopTimer() + if now <= endTimeSecond then + self.TxtLeftTime.text = CS.XTextManager.GetText("ArenaOnlineChapterLeftTime", XUiHelper.GetTime(endTimeSecond - now, XUiHelper.TimeFormatType.DEFAULT)) + else + self.TxtLeftTime.text = activeOverStr + end + + self.Timer = XScheduleManager.ScheduleForever(function() + now = XTime.GetServerNowTimestamp() + if now > endTimeSecond then + self:StopTimer() + return + end + if now <= endTimeSecond then + self.TxtLeftTime.text = CS.XTextManager.GetText("ArenaOnlineChapterLeftTime", XUiHelper.GetTime(endTimeSecond - now, XUiHelper.TimeFormatType.DEFAULT)) + else + self.TxtLeftTime.text = activeOverStr + end + end, XScheduleManager.SECOND, 0) + end +end + +function XUiChapterPrefab:StopTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end + +function XUiChapterPrefab:OnDestroy() + --XEventManager.RemoveEventListener(XEventId.EVENT_ARENAONLINE_WEEK_REFRESH, self.AreaChange, self) + + self:StopTimer() + if not self.SectionGrids then return end + + for _, v in pairs(self.SectionGrids) do + v:OnDestroy() + end +end + +function XUiChapterPrefab:PlayTipsAnimation() + local begin = function() + XLuaUiManager.SetMask(true) + XDataCenter.ArenaOnlineManager.SetAreaChanged(false) + end + + local finished = function() + XLuaUiManager.SetMask(false) + self.PanelTip.gameObject:SetActiveEx(false) + end + + self.PanelTip.gameObject:SetActiveEx(true) + self.TipEnable:PlayTimelineAnimation(finished, begin) +end + +function XUiChapterPrefab:AreaChange() + if not self.Show then + return + end + self:PlayTipsAnimation() +end + +return XUiChapterPrefab \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArenaOnline/XUiGridSection.lua b/Resources/Scripts/XUi/XUiArenaOnline/XUiGridSection.lua new file mode 100644 index 00000000..0701ad0c --- /dev/null +++ b/Resources/Scripts/XUi/XUiArenaOnline/XUiGridSection.lua @@ -0,0 +1,87 @@ +local XUiGridSection = XClass(nil, "XUiGridSection") + +function XUiGridSection:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + + XTool.InitUiObject(self) + self:AutoAddListener() + self.Canvas.sortingOrder = self.Canvas.sortingOrder + self.UiRoot:GetSortingOrder() +end + +function XUiGridSection:AutoAddListener() + self.BtnStage.CallBack = function() self:OnBtnStageClick() end +end + +function XUiGridSection:OnBtnStageClick() + if self.LeftTime ~= 0 then + XUiManager.TipMsg(CS.XTextManager.GetText("ArenaOnlineSectionClose")) + return + end + XDataCenter.ArenaOnlineManager.OpenArenaOnlineSection(self.ScetionId) +end + +function XUiGridSection:Refresh(sectionId) + if sectionId then + self.ScetionId = sectionId + end + + self:StopTimer() + self.LeftTime = XDataCenter.ArenaOnlineManager.CheckSectionLeftTime(self.ScetionId) + if self.LeftTime < 0 then + self.PanelNor.gameObject:SetActiveEx(false) + self.PanelLock.gameObject:SetActiveEx(false) + elseif self.LeftTime == 0 then + self:HandlerOpen() + else + self:HandlerClose() + end + self.PanelClear.gameObject:SetActiveEx(false) + local path = XDataCenter.ArenaOnlineManager.GetCurSectionIcon(self.ScetionId) + self.NorBg2:SetRawImage(path) +end + +function XUiGridSection:HandlerOpen() + self.PanelNor.gameObject:SetActiveEx(true) + self.PanelLock.gameObject:SetActiveEx(false) + + local stars, allStars = XDataCenter.ArenaOnlineManager.GetStarInfoBySectionid(self.ScetionId) + local passCount, allCount = XDataCenter.ArenaOnlineManager.GetStageScheduleByScetionId(self.ScetionId) + self.TxtAllCollect.text = CS.XTextManager.GetText("ArenaOnlineStarDesc", allStars) + self.TxtCollect.text = stars + self.TxtStage.text = CS.XTextManager.GetText("ArenaOnlinePassDesc", passCount, allCount) +end + +function XUiGridSection:HandlerClose() + self.PanelNor.gameObject:SetActiveEx(false) + self.PanelLock.gameObject:SetActiveEx(true) + + self.Timer = XScheduleManager.ScheduleForever(function() + if XTool.UObjIsNil(self.Transform) then + return + end + + self.LeftTime = self.LeftTime - 1 + if self.LeftTime <= 0 then + self:Refresh() + return + end + + local str = XUiHelper.GetTime(self.LeftTime, XUiHelper.TimeFormatType.DEFAULT) + self.TxtLeftTime.text = CS.XTextManager.GetText("ArenaOnlineSectionLeftTime", str) + end, XScheduleManager.SECOND, 0) +end + +function XUiGridSection:StopTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end + +function XUiGridSection:OnDestroy() + self:StopTimer() +end + +return XUiGridSection \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArenaOnline/XUiGridStage.lua b/Resources/Scripts/XUi/XUiArenaOnline/XUiGridStage.lua new file mode 100644 index 00000000..ae1dc965 --- /dev/null +++ b/Resources/Scripts/XUi/XUiArenaOnline/XUiGridStage.lua @@ -0,0 +1,49 @@ +local XUiGridStage = XClass(nil, "XUiGridStage") +local XUiPanelStars = require("XUi/XUiFubenMainLineChapter/XUiPanelStars") + +function XUiGridStage:Ctor(ui, uiRoot, parent, challengeId, clickCb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + self.Parent = parent + self.ChallengeId = challengeId + self.ClickCb = clickCb + + XTool.InitUiObject(self) + self:AutoAddListener() + self:Refresh() +end + +function XUiGridStage:AutoAddListener() + self.BtnStage.CallBack = function() self:OnBtnStageClick() end +end + +function XUiGridStage:SetStageSelect() + self.PanelSlect.gameObject:SetActiveEx(true) +end + +function XUiGridStage:SetStageActive() + self.PanelSlect.gameObject:SetActiveEx(false) +end + +function XUiGridStage:OnBtnStageClick() + self.UiRoot:OpenStageDetial(self.ChallengeId) + if self.ClickCb then self.ClickCb(self) end +end + +function XUiGridStage:Refresh() + local arenaOnlieStageCfg = XArenaOnlineConfigs.GetStageById(self.ChallengeId) + local stagePass = XDataCenter.ArenaOnlineManager.CheckStagePass(self.ChallengeId) + self:SetStageActive() + if not arenaOnlieStageCfg then return end + + self.TxtStage.text = arenaOnlieStageCfg.Name + self.RImgBg:SetRawImage(arenaOnlieStageCfg.BgIcon) + self.RImgName:SetRawImage(arenaOnlieStageCfg.NameIcon) + self.PanelStars = XUiPanelStars.New(self.PanelStar) + local starsMap = XDataCenter.ArenaOnlineManager.GetStageStarsMapByChallengeId(self.ChallengeId) + self.PanelStars:OnEnable(starsMap) + self.PanelClear.gameObject:SetActiveEx(stagePass) +end + +return XUiGridStage \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArenaOnline/XUiPanelBuffDetail.lua b/Resources/Scripts/XUi/XUiArenaOnline/XUiPanelBuffDetail.lua new file mode 100644 index 00000000..1fadbccc --- /dev/null +++ b/Resources/Scripts/XUi/XUiArenaOnline/XUiPanelBuffDetail.lua @@ -0,0 +1,63 @@ +local XUiPanelBuffDetail = XClass(nil, "XUiPanelBuffDetail") + +function XUiPanelBuffDetail:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.GridBuffList = {} + XTool.InitUiObject(self) + self:AutoAddListener() + self.GirdBuff.gameObject:SetActiveEx(false) +end + +function XUiPanelBuffDetail:AutoAddListener() + self.BtnClose.CallBack = function() self:Hide() end +end + +function XUiPanelBuffDetail:Show(stageId) + if self.StageId == stageId then + self.GameObject:SetActiveEx(true) + return + end + + self.StageId = stageId + self:Refresh() + self.GameObject:SetActiveEx(true) +end + +function XUiPanelBuffDetail:Hide() + self.GameObject:SetActiveEx(false) +end + +function XUiPanelBuffDetail:Refresh() + local t = XDataCenter.ArenaOnlineManager.GetArenaOnlineStageInfo(self.StageId) + local buffIds = t.BuffIds + for _, v in ipairs(self.GridBuffList) do + v.gameObject:SetActive(false) + end + + if not buffIds or #buffIds <= 0 then + return + end + + for index, buffId in ipairs(buffIds) do + local grid = self.GridBuffList[index] + if not grid then + local go = CS.UnityEngine.GameObject.Instantiate(self.GirdBuff.gameObject) + grid = go.transform + grid:SetParent(self.PanelContent, false) + table.insert(self.GridBuffList, grid) + end + grid.gameObject:SetActive(true) + + local icon = XUiHelper.TryGetComponent(grid.transform, "RImgIcon", "RawImage") + local name = XUiHelper.TryGetComponent(grid.transform, "TxtName", "Text") + local desc = XUiHelper.TryGetComponent(grid.transform, "TxtDesc", "Text") + + local cfg = XArenaOnlineConfigs.GetNpcAffixById(buffId) + icon:SetRawImage(cfg.Icon) + name.text = cfg.Name + desc.text = cfg.Description + end +end + +return XUiPanelBuffDetail \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArenaOnline/XUiPanelStagInfo.lua b/Resources/Scripts/XUi/XUiArenaOnline/XUiPanelStagInfo.lua new file mode 100644 index 00000000..8d8611e1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiArenaOnline/XUiPanelStagInfo.lua @@ -0,0 +1,121 @@ +local XUiPanelStagInfo = XClass(nil, "XUiPanelStagInfo") +local MAX_START = 3 + +function XUiPanelStagInfo:Ctor(uiRoot, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + self.GridList = {} + + XTool.InitUiObject(self) + self:InitStarPanels() + self.GridCommon.gameObject:SetActiveEx(false) +end + +function XUiPanelStagInfo:InitStarPanels() + self.GridStarList = {} + for i = 1, MAX_START do + local ui = self["GridStageStar" .. i] + ui.gameObject:SetActiveEx(true) + local grid = XUiGridStageStar.New(ui) + self.GridStarList[i] = grid + end +end + +function XUiPanelStagInfo:Show(challengeId, multiplayerMode, checkActive) + -- if self.StageId == stageId and not checkActive then + -- self.CanvasGroup.alpha = 0 + -- self.GameObject:SetActiveEx(true) + -- self.UiRoot:PlayAnimation("StageInfoQieHuan") + -- return + -- end + + self.ChallengeId = challengeId + self.MultiplayerMode = multiplayerMode + local id = XDataCenter.ArenaOnlineManager.GetStageId(self.ChallengeId) + self.StageCfg = XDataCenter.FubenManager.GetStageCfg(id) + self.StarsMap = XDataCenter.ArenaOnlineManager.GetStageStarsMapByChallengeId(challengeId) + self:Refresh() + self.CanvasGroup.alpha = 0 + self.GameObject:SetActiveEx(true) + self.UiRoot:PlayAnimation("StageInfoQieHuan") +end + +function XUiPanelStagInfo:Hide() + self.GameObject:SetActiveEx(false) +end + +function XUiPanelStagInfo:Refresh() + self:SetStartList() + self:SetDropList() +end + +function XUiPanelStagInfo:SetStartList() + local isNoStart = not self.StageCfg.StarDesc or #self.StageCfg.StarDesc <= 0 + self.PanelStartList.gameObject:SetActiveEx(not isNoStart) + self.PanelTargetNone.gameObject:SetActiveEx(isNoStart) + if isNoStart then return end + + for i = 1, MAX_START do + self.GridStarList[i]:Refresh(self.StageCfg.StarDesc[i], self.StarsMap[i]) + end +end + +function XUiPanelStagInfo:SetDropList() + local stagePass = XDataCenter.ArenaOnlineManager.CheckStagePass(self.ChallengeId) + self.PanelDropList.gameObject:SetActiveEx(not stagePass) + self.PanelDorptNone.gameObject:SetActiveEx(stagePass) + self.TxtOnlineHint.gameObject:SetActiveEx(self.MultiplayerMode) + local allCount = XDataCenter.ArenaOnlineManager.GetStageTotalCount(self.ChallengeId) + local curCount = XDataCenter.ArenaOnlineManager.GetStagePassCount(self.ChallengeId) + self.TxtDorpDesc.text = CS.XTextManager.GetText("ArenaOnlineStageDropDesc", allCount, curCount, allCount) + if stagePass then return end + + -- 获取显示奖励Id + local IsFirst = false + local cfg = XDataCenter.FubenManager.GetStageLevelControl(self.ChallengeId) + local rewardId = cfg and cfg.FirstRewardShow or self.StageCfg.FirstRewardShow + if cfg and cfg.FirstRewardShow > 0 or self.StageCfg.FirstRewardShow > 0 then + IsFirst = true + end + + if rewardId == 0 then + rewardId = cfg and cfg.FinishRewardShow or self.StageCfg.FinishRewardShow + end + if rewardId == 0 then + for j = 1, #self.GridList do + self.GridList[j].GameObject:SetActiveEx(false) + end + return + end + + local rewards = IsFirst and XRewardManager.GetRewardList(rewardId) or XRewardManager.GetRewardListNotCount(rewardId) + if rewards then + for i, item in ipairs(rewards) do + local grid + if self.GridList[i] then + grid = self.GridList[i] + else + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommon) + grid = XUiGridCommon.New(self.UiRoot, ui) + grid.Transform:SetParent(self.PanelDropContent, false) + self.GridList[i] = grid + end + grid:Refresh(item) + grid.GameObject:SetActiveEx(true) + end + end + + local rewardsCount = 0 + if rewards then + rewardsCount = #rewards + end + + for j = 1, #self.GridList do + if j > rewardsCount then + self.GridList[j].GameObject:SetActiveEx(false) + end + end +end + +return XUiPanelStagInfo \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArenaOnline/XUiPanelStageDetail.lua b/Resources/Scripts/XUi/XUiArenaOnline/XUiPanelStageDetail.lua new file mode 100644 index 00000000..54423fea --- /dev/null +++ b/Resources/Scripts/XUi/XUiArenaOnline/XUiPanelStageDetail.lua @@ -0,0 +1,176 @@ +local XUiPanelStageDetail = XClass(nil, "XUiPanelStageDetail") +local XUiPanelStagInfo = require("XUi/XUiArenaOnline/XUiPanelStagInfo") +local XUiPanelTargetInfo = require("XUi/XUiArenaOnline/XUiPanelTargetInfo") +local XUiPanelBuffDetail = require("XUi/XUiArenaOnline/XUiPanelBuffDetail") + +local Select = CS.UiButtonState.Select +local Normal = CS.UiButtonState.Normal + +function XUiPanelStageDetail:Ctor(uiRoot, ui, openCb, closeCb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + self.OpenCb = openCb + self.CloseCb = closeCb + + XTool.InitUiObject(self) + self:AutoAddListener() + self:Init() + self.GameObject:SetActiveEx(false) +end + +function XUiPanelStageDetail:Init() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint) + self.StageInfoPanel = XUiPanelStagInfo.New(self.UiRoot, self.PanelStageInfo) + self.TargetInfoPanel = XUiPanelTargetInfo.New(self.UiRoot, self, self.PanelTargetInfo) + self.BuffDetailPanel = XUiPanelBuffDetail.New(self.PanelBuffDetail) +end + +function XUiPanelStageDetail:Show(stageId) + if self.StageId == stageId then + self.GameObject:SetActiveEx(true) + if self.OpenCb then self.OpenCb() end + return + end + self.MultiplayerMode = true + self.StageId = stageId + self:Refresh() +end + +function XUiPanelStageDetail:Refresh(checkActive) + if not self.StageId then return end + if checkActive and not self.GameObject.activeSelf then return end + + self.ArenaStageCfg = XArenaOnlineConfigs.GetStageById(self.StageId) + local id = XDataCenter.ArenaOnlineManager.GetStageId(self.StageId) + self.FubenStageCfg = XDataCenter.FubenManager.GetStageCfg(id) + local leastPlayer = self.FubenStageCfg.OnlinePlayerLeast <= 0 and 1 or self.FubenStageCfg.OnlinePlayerLeast + self.TxtTitle.text = self.ArenaStageCfg.Name + self.TxtPeople.text = leastPlayer + local stageInfo = XDataCenter.ArenaOnlineManager.GetStageInfo(self.StageId) + local atNums = stageInfo.Passed and 0 or self.ArenaStageCfg.EnduranceCost + self.TxtATNums.text = atNums + self.PanelMatching.gameObject:SetActiveEx(false) + self.BtnModeToggle.gameObject:SetActiveEx(self.ArenaStageCfg.SingleSwitch) + self.BtnModeToggle:SetButtonState(not self.MultiplayerMode and Select or Normal) + self.TxtConsumeHint.text = self.MultiplayerMode and CS.XTextManager.GetText("ArenaOnlineStageDetailHintOnline") or CS.XTextManager.GetText("ArenaOnlineStageDetailHintSingle") + self.BtnCreateRoom:SetName(self.MultiplayerMode and CS.XTextManager.GetText("ArenaOnlineCreateRoomOnline") or CS.XTextManager.GetText("ArenaOnlineCreateRoomSingle")) + local isNoStart = not self.FubenStageCfg.StarDesc or #self.FubenStageCfg.StarDesc <= 0 + if isNoStart then + self.StageInfoPanel:Hide() + self.TargetInfoPanel:Show(self.StageId, checkActive) + else + self.StageInfoPanel:Show(self.StageId, self.MultiplayerMode, checkActive) + self.TargetInfoPanel:Hide() + end + + self.BtnTarget.gameObject:SetActiveEx(not isNoStart) + self.BtnStage.gameObject:SetActiveEx(isNoStart) + + local isMatching = XDataCenter.RoomManager.Matching + self.BtnMatch.gameObject:SetActive(not isMatching and self.MultiplayerMode) + self.PanelMatching.gameObject:SetActive(isMatching and self.MultiplayerMode) + self.BtnCreateRoom.interactable = not isMatching + + self.GameObject:SetActiveEx(true) + if self.OpenCb then self.OpenCb() end +end + +function XUiPanelStageDetail:BuffDetailShow(stageId) + self.BuffDetailPanel:Show(stageId) + self.UiRoot:PlayAnimation("BuffDetailEnable") +end + +function XUiPanelStageDetail:Hide() + self.GameObject:SetActiveEx(false) + if self.CloseCb then self.CloseCb() end +end + +function XUiPanelStageDetail:AutoAddListener() + self.BtnStage.CallBack = function() self:OnBtnStageClick() end + self.BtnTarget.CallBack = function() self:OnBtnTargetClick() end + self.BtnMatch.CallBack = function() self:OnBtnMatchClick() end + self.BtnCreateRoom.CallBack = function() self:OnBtnCreateRoomClick() end + self.BtnModeToggle.CallBack = function() self:OnBtnModeToggleClick() end +end + +function XUiPanelStageDetail:OnBtnStageClick() + self.StageInfoPanel:Show(self.StageId, self.MultiplayerMode) + self.TargetInfoPanel:Hide() + + self.BtnTarget.gameObject:SetActiveEx(true) + self.BtnStage.gameObject:SetActiveEx(false) +end + +function XUiPanelStageDetail:OnBtnTargetClick() + self.StageInfoPanel:Hide() + self.TargetInfoPanel:Show(self.StageId) + + self.BtnTarget.gameObject:SetActiveEx(false) + self.BtnStage.gameObject:SetActiveEx(true) +end + +function XUiPanelStageDetail:OnBtnModeToggleClick() + self.MultiplayerMode = not self.BtnModeToggle:GetToggleState() + self:Refresh() +end + +function XUiPanelStageDetail:OnBtnCreateRoomClick() + if XDataCenter.RoomManager.Matching then + XUiManager.TipMsg(CS.XTextManager.GetText("OnlineInstanceMatching")) + return + end + + if XDataCenter.ArenaOnlineManager.CheckTimeOut() then + XUiManager.TipMsg(CS.XTextManager.GetText("ArenaOnlineTimeOut")) + return + end + -- if XDataCenter.FubenManager.CheckPreFight(self.Stage) then + -- self.Parent:CloseStageDetail() + -- end + if self.MultiplayerMode then + XDataCenter.FubenManager.RequestArenaOnlineCreateRoom(self.FubenStageCfg, self.StageId) + else + -- local id = XDataCenter.ArenaOnlineManager.GetStageId(self.StageId) + -- XLog.Warning(id, self.StageId) + local data = {ChallengeId = self.StageId} + local cfg = XDataCenter.ArenaOnlineManager.GetArenaOnlineStageCfgStageId(self.StageId) + local levelControl = XFubenConfigs.GetStageMultiplayerLevelControlCfgById(cfg.SingleDiff[1]) + XLuaUiManager.Open("UiNewRoomSingle", levelControl.StageId, data) + end +end + +function XUiPanelStageDetail:OnBtnMatchClick() + if XDataCenter.ArenaOnlineManager.CheckTimeOut() then + XUiManager.TipMsg(CS.XTextManager.GetText("ArenaOnlineTimeOut")) + return + end + + if XDataCenter.RoomManager.Matching then + return + end + + XDataCenter.FubenManager.RequestAreanaOnlineMatchRoom(self.FubenStageCfg, self.StageId, function() + if XDataCenter.RoomManager.Matching then + XLuaUiManager.Open("UiOnLineMatching", self.FubenStageCfg) + end + self.BtnCreateRoom.interactable = false + self.BtnMatch.gameObject:SetActiveEx(false) + self.PanelMatching.gameObject:SetActiveEx(true) + end) +end + +function XUiPanelStageDetail:OnCancelMatch() + self.BtnCreateRoom.interactable = true + self.BtnMatch.gameObject:SetActiveEx(self.MultiplayerMode) + self.PanelMatching.gameObject:SetActiveEx(false) +end + +function XUiPanelStageDetail:ResetState() + self.BtnMatch.gameObject:SetActive(self.MultiplayerMode) + self.PanelMatching.gameObject:SetActive(false) + self.BtnCreateRoom.interactable = true +end + + +return XUiPanelStageDetail \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArenaOnline/XUiPanelTargetInfo.lua b/Resources/Scripts/XUi/XUiArenaOnline/XUiPanelTargetInfo.lua new file mode 100644 index 00000000..2d93480b --- /dev/null +++ b/Resources/Scripts/XUi/XUiArenaOnline/XUiPanelTargetInfo.lua @@ -0,0 +1,102 @@ +local XUiPanelTargetInfo = XClass(nil, "XUiPanelTargetInfo") + +function XUiPanelTargetInfo:Ctor(uiRoot,parent, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + self.Parent = parent + self.GridSkillList = {} + self.GridBuffList = {} + + XTool.InitUiObject(self) + self.GridSkill.gameObject:SetActiveEx(false) + self.GridBuff.gameObject:SetActiveEx(false) +end + +function XUiPanelTargetInfo:Show(stageId) + if self.StageId == stageId then + self.CanvasGroup.alpha = 0 + self.GameObject:SetActiveEx(true) + self.UiRoot:PlayAnimation("TargetInfoQieHuan") + return + end + + self.StageId = stageId + self.ArenaStageCfg = XArenaOnlineConfigs.GetStageById(stageId) + self:Refresh() + self.CanvasGroup.alpha = 0 + self.GameObject:SetActiveEx(true) + self.UiRoot:PlayAnimation("TargetInfoQieHuan") +end + +function XUiPanelTargetInfo:Hide() + self.GameObject:SetActiveEx(false) +end + +function XUiPanelTargetInfo:Refresh() + self.TxtCondition.text = self.ArenaStageCfg.ConditionDesc + self:SetSkillInfo() + self:SetBuffInfo() +end + +function XUiPanelTargetInfo:SetSkillInfo() + local titles = self.ArenaStageCfg.SkillTitle + local descs = self.ArenaStageCfg.SkillDesc + for _, v in ipairs(self.GridSkillList) do + v.gameObject:SetActive(false) + end + + if not titles or #titles <= 0 then + return + end + + for index, title in ipairs(titles) do + local grid = self.GridSkillList[index] + if not grid then + local go = CS.UnityEngine.GameObject.Instantiate(self.GridSkill.gameObject) + grid = go.transform + grid:SetParent(self.PanelSkillContent, false) + table.insert(self.GridSkillList, grid) + end + grid.gameObject:SetActive(true) + + local textTitle = XUiHelper.TryGetComponent(grid.transform, "TxtTitle", "Text") + local textDesc = XUiHelper.TryGetComponent(grid.transform, "TxtDesc", "Text") + textTitle.text = title + textDesc.text = descs[index] + end +end + +function XUiPanelTargetInfo:SetBuffInfo() + local t = XDataCenter.ArenaOnlineManager.GetArenaOnlineStageInfo(self.StageId) + local buffIds = t.BuffIds + for _, v in ipairs(self.GridBuffList) do + v.gameObject:SetActive(false) + end + + if not buffIds or #buffIds <= 0 then + return + end + + for index, buffId in ipairs(buffIds) do + local grid = self.GridBuffList[index] + if not grid then + local go = CS.UnityEngine.GameObject.Instantiate(self.GridBuff.gameObject) + grid = go.transform + grid:SetParent(self.PanelBuffContent, false) + table.insert(self.GridBuffList, grid) + end + grid.gameObject:SetActive(true) + + local icon = XUiHelper.TryGetComponent(grid.transform, "RImgIcon", "RawImage") + local btn = XUiHelper.TryGetComponent(grid.transform, "BtnClick", "Button") + + local cfg = XArenaOnlineConfigs.GetNpcAffixById(buffId) + icon:SetRawImage(cfg.Icon) + btn.CallBack = function() + self.Parent:BuffDetailShow(self.StageId) + end + end +end + +return XUiPanelTargetInfo \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArenaOnline/XUiSectionPrefab.lua b/Resources/Scripts/XUi/XUiArenaOnline/XUiSectionPrefab.lua new file mode 100644 index 00000000..abf13809 --- /dev/null +++ b/Resources/Scripts/XUi/XUiArenaOnline/XUiSectionPrefab.lua @@ -0,0 +1,225 @@ +local XUiSectionPrefab = XClass(nil, "XUiSectionPrefab") +local XUiGridStage = require("XUi/XUiArenaOnline/XUiGridStage") +local XUguiDragProxy = CS.XUguiDragProxy + +local MAX_SECTION_COUNT = 10 +function XUiSectionPrefab:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + + XTool.InitUiObject(self) + self:SetUiData() +end + +function XUiSectionPrefab:OnEnable() + self:Refresh() +end + +function XUiSectionPrefab:Refresh() + self.AnimEnable:PlayTimelineAnimation() + local sectionCfg = XDataCenter.ArenaOnlineManager.GetCurSectionCfg() + local chapterCfg = XDataCenter.ArenaOnlineManager.GetCurChapterCfg() + if not sectionCfg or not chapterCfg then return end + + self.StageGrids = {} + self.TxtName.text = sectionCfg.Name + self.TxtLv.text = CS.XTextManager.GetText("ArenaOnlineChapterLevel", chapterCfg.MinLevel, chapterCfg.MaxLevel) + self:SetStageInfo() + self:SetTimer() +end + +function XUiSectionPrefab:SetUiData() + self:RegisterClickEvent(self.ScrollRect, handler(self, self.CancelSelect)) + local dragProxy = self.ScrollRect:GetComponent(typeof(XUguiDragProxy)) + if not dragProxy then + dragProxy = self.ScrollRect.gameObject:AddComponent(typeof(XUguiDragProxy)) + end + dragProxy:RegisterHandler(handler(self, self.OnDragProxy)) +end + +function XUiSectionPrefab:SetStageInfo() + local sectionData = XDataCenter.ArenaOnlineManager.GetCurSectionData() + local index = 0 + for _, stageId in pairs(sectionData.Stages) do + index = index + 1 + local name = "GridStage" .. index + local go = XUiHelper.TryGetComponent(self.PanelStageContent, name) + if go then + self.StageGrids[index] = XUiGridStage.New(go, self.UiRoot, self.PanelStageContent, stageId, function(grid) + self:ClickStageGrid(grid) + end) + end + end + + for i = index, MAX_SECTION_COUNT do + local name = "Line" .. i + local go = XUiHelper.TryGetComponent(self.PanelStageContent, name) + if go then + go.gameObject:SetActiveEx(false) + end + end + + index = index + 1 + for i = index, MAX_SECTION_COUNT do + local name = "GridStage" .. i + local go = XUiHelper.TryGetComponent(self.PanelStageContent, name) + if go then + go.gameObject:SetActiveEx(false) + end + end +end + +function XUiSectionPrefab:SetTimer() + local sectionCfg = XDataCenter.ArenaOnlineManager.GetCurSectionCfg() + local endTimeSecond = XDataCenter.ArenaOnlineManager.GetNextRefreshTime() + local now = XTime.GetServerNowTimestamp() + if now <= endTimeSecond then + local activeOverStr = CS.XTextManager.GetText("ArenaOnlineLeftTimeOver") + self:StopTimer() + if now <= endTimeSecond then + self.TxtLeftTime.text = CS.XTextManager.GetText(sectionCfg.LeftTimeDesc, XUiHelper.GetTime(endTimeSecond - now, XUiHelper.TimeFormatType.DEFAULT)) + else + self.TxtLeftTime.text = activeOverStr + end + + self.Timer = XScheduleManager.ScheduleForever(function() + now = XTime.GetServerNowTimestamp() + if now > endTimeSecond then + self:StopTimer() + return + end + if now <= endTimeSecond then + self.TxtLeftTime.text = CS.XTextManager.GetText(sectionCfg.LeftTimeDesc, XUiHelper.GetTime(endTimeSecond - now, XUiHelper.TimeFormatType.DEFAULT)) + else + self.TxtLeftTime.text = activeOverStr + end + end, XScheduleManager.SECOND, 0) + end +end + +function XUiSectionPrefab:StopTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end + +function XUiSectionPrefab:OnDestroy() + self:StopTimer() +end + +function XUiSectionPrefab:OnDragProxy(dragType) + if dragType == 0 then + self:OnScrollRectBeginDrag() + elseif dragType == 2 then + self:OnScrollRectEndDrag() + end +end + +function XUiSectionPrefab:OnScrollRectBeginDrag() + if self:CancelSelect() then + self.ScrollRect.enabled = false + end +end + +function XUiSectionPrefab:OnScrollRectEndDrag() + self.ScrollRect.enabled = true +end + +-- 选中一个 stage grid +function XUiSectionPrefab:ClickStageGrid(grid) + local curGrid = self.CurStageGrid + if curGrid and curGrid.StageId == grid.StageId then + return + end + + -- 选中回调 + if self.ShowStageCb then + self.ShowStageCb(grid.Stage, grid.ChapterOrderId) + end + + -- 取消上一个选择 + if curGrid then + curGrid:SetStageActive() + end + + -- 选中当前选择 + grid:SetStageSelect() + + -- 滚动容器自由移动 + self.ScrollRect.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Unrestricted + + -- 面板移动 + self:PlayScrollViewMove(grid) + + self.CurStageGrid = grid +end + +function XUiSectionPrefab:PlayScrollViewMove(grid) + -- 动画 + local gridTf = grid.GameObject:GetComponent("RectTransform") + local diffX = gridTf.localPosition.x + self.PanelStageContent.localPosition.x + if diffX < XDataCenter.FubenMainLineManager.UiGridChapterMoveMinX or diffX > XDataCenter.FubenMainLineManager.UiGridChapterMoveMaxX then + local tarPosX = XDataCenter.FubenMainLineManager.UiGridChapterMoveTargetX - gridTf.localPosition.x + local tarPos = self.PanelStageContent.localPosition + tarPos.x = tarPosX + XLuaUiManager.SetMask(true) + XUiHelper.DoMove(self.PanelStageContent, tarPos, XDataCenter.FubenMainLineManager.UiGridChapterMoveDuration, XUiHelper.EaseType.Sin, function() + XLuaUiManager.SetMask(false) + end) + end +end + +-- 返回滚动容器是否动画回弹 +function XUiSectionPrefab:CancelSelect() + if not self.CurStageGrid then + return false + end + + self.CurStageGrid:SetStageActive() + self.CurStageGrid = nil + self.UiRoot:OnHideDetail() + return self:ScrollRectRollBack() +end + +function XUiSectionPrefab:ScrollRectRollBack() + -- 滚动容器回弹 + local width = self.RectTransform.rect.width + local innerWidth = self.PanelStageContent.rect.width + innerWidth = innerWidth < width and width or innerWidth + local diff = innerWidth - width + local tarPosX + if self.PanelStageContent.localPosition.x < -width / 2 - diff then + tarPosX = -width / 2 - diff + elseif self.PanelStageContent.localPosition.x > -width / 2 then + tarPosX = -width / 2 + else + self.ScrollRect.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Elastic + return false + end + + self:PlayScrollViewMoveBack(tarPosX) + return true +end + +function XUiSectionPrefab:PlayScrollViewMoveBack(tarPosX) + local tarPos = self.PanelStageContent.localPosition + tarPos.x = tarPosX + XLuaUiManager.SetMask(true) + + XUiHelper.DoMove(self.PanelStageContent, tarPos, XDataCenter.FubenMainLineManager.UiGridChapterMoveDuration, XUiHelper.EaseType.Sin, function() + self.ScrollRect.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Elastic + XLuaUiManager.SetMask(false) + end) +end + +function XUiSectionPrefab:RegisterClickEvent(uiNode, func) + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +return XUiSectionPrefab \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArenaStage/ArenaStageCommon/XUiGridArenaPassContent.lua b/Resources/Scripts/XUi/XUiArenaStage/ArenaStageCommon/XUiGridArenaPassContent.lua new file mode 100644 index 00000000..e4299bb6 --- /dev/null +++ b/Resources/Scripts/XUi/XUiArenaStage/ArenaStageCommon/XUiGridArenaPassContent.lua @@ -0,0 +1,51 @@ +local XUiGridArenaPassContent = XClass(nil, "XUiGridArenaPassContent") + +function XUiGridArenaPassContent:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + + self.GridPlayer.gameObject:SetActive(false) + + self.PlayerList = {} + table.insert(self.PlayerList, self.GridPlayer) +end + +function XUiGridArenaPassContent:SetMetaData(data) + if not data then + return + end + + for _, v in ipairs(self.PlayerList) do + v.gameObject:SetActive(false) + end + + for i, playerInfo in ipairs(data.PlayerInfoList) do + local grid = self.PlayerList[i] + if not grid then + local go = CS.UnityEngine.GameObject.Instantiate(self.GridPlayer.gameObject) + grid = go.transform + grid:SetParent(self.GridPlayer.parent, false) + table.insert(self.PlayerList, grid) + end + grid.gameObject:SetActive(true) + + local head = XUiHelper.TryGetComponent(grid, "Bg/Head") + local nickname = XUiHelper.TryGetComponent(grid, "TxtNickname", "Text") + local btnHead = XUiHelper.TryGetComponent(grid, "BtnHead", "Button") + + CsXUiHelper.RegisterClickEvent(btnHead, function() + if playerInfo.Id == XPlayer.Id then + return + end + XDataCenter.PersonalInfoManager.ReqShowInfoPanel(playerInfo.Id) + end, true) + nickname.text = XDataCenter.SocialManager.GetPlayerRemark(playerInfo.Id, playerInfo.Name) + + XUiPLayerHead.InitPortrait(playerInfo.CurrHeadPortraitId, playerInfo.CurrHeadFrameId, head) + grid:SetSiblingIndex(i - 1) + end +end + +return XUiGridArenaPassContent \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArenaStage/ArenaStageCommon/XUiGridArenaStage.lua b/Resources/Scripts/XUi/XUiArenaStage/ArenaStageCommon/XUiGridArenaStage.lua new file mode 100644 index 00000000..fc166dbc --- /dev/null +++ b/Resources/Scripts/XUi/XUiArenaStage/ArenaStageCommon/XUiGridArenaStage.lua @@ -0,0 +1,75 @@ +local XUiGridArenaStage = XClass(nil, "XUiGridArenaStage") + +function XUiGridArenaStage:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + self:AutoAddListener() +end + +function XUiGridArenaStage:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiGridArenaStage:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiGridArenaStage:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiGridArenaStage:AutoAddListener() + self:RegisterClickEvent(self.BtnStage, self.OnBtnStageClick) + self:RegisterClickEvent(self.BtnLock, self.OnBtnLockClick) +end + +function XUiGridArenaStage:OnBtnLockClick() + XUiManager.TipMsg(CS.XTextManager.GetText("ArenaConnotPassTip")) +end + +function XUiGridArenaStage:OnBtnStageClick() + XLuaUiManager.Open("UiEnterFight", XFubenExploreConfigs.NodeTypeEnum.Arena, nil, nil, nil, nil, function() + self.AreaCfg = XArenaConfigs.GetArenaAreaStageCfgByAreaId(self.AreaId) + if not self.CurIndex then + return + end + + if not self.AreaCfg then + return + end + + XDataCenter.ArenaManager.SetEnterAreaStageInfo(self.AreaId, self.CurIndex) + XLuaUiManager.Open("UiNewRoomSingle", self.AreaCfg.StageId[self.CurIndex]) + end, self.StageId, self.AreaId) +end + +function XUiGridArenaStage:Refresh(index, curIndex, score, stageId, areaId) + if not index then + return + end + self.StageId = stageId + self.AreaId = areaId + self.CurIndex = index + local config = XArenaConfigs.GetArenaStageConfig(stageId) + self.TxtScore.text = CS.XTextManager.GetText("ArenaStaSocre", score) + self.RImgBg:SetRawImage(config.BgIconSmall) + self.ImgDifficulty:SetRawImage(config.DifficuIocn) + self.TxtTitle.text = config.Name + + if index <= curIndex then + self.BtnLock.gameObject:SetActive(false) + self.TxtScore.gameObject:SetActive(true) + else + self.BtnLock.gameObject:SetActive(true) + self.TxtScore.gameObject:SetActive(false) + end +end + +return XUiGridArenaStage \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArenaStage/XUiArenaStage.lua b/Resources/Scripts/XUi/XUiArenaStage/XUiArenaStage.lua new file mode 100644 index 00000000..7a091ca7 --- /dev/null +++ b/Resources/Scripts/XUi/XUiArenaStage/XUiArenaStage.lua @@ -0,0 +1,126 @@ +local XUiArenaStage = XLuaUiManager.Register(XLuaUi, "UiArenaStage") + +local XUiPanelPassDetail = require("XUi/XUiArenaStage/XUiPanelPassDetail") +local XUiGridArenaStage = require("XUi/XUiArenaStage/ArenaStageCommon/XUiGridArenaStage") + +function XUiArenaStage:OnAwake() + self:AutoAddListener() +end + +function XUiArenaStage:OnStart(areaId) + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self.PanelArenaStage.gameObject:SetActive(true) + self.PassDetailPanel = XUiPanelPassDetail.New(self.PanelPassDetail, self) + self.PassDetailPanel:Hide() + + self.StageList = {} + for i = 1, 3 do + local grid = XUiGridArenaStage.New(self["GridStage" .. i], self) + table.insert(self.StageList, grid) + end + + self.LordList = {} + for i = 1, 3 do + table.insert(self.LordList, self["GridLord" .. i]) + end + + self.AreaId = areaId +end + + +function XUiArenaStage:OnEnable() + if XDataCenter.ArenaManager.IsChangeStatusInFight() then + return + end + + XDataCenter.ArenaManager.RequestAreaData() + self:Refresh() +end + +function XUiArenaStage:OnGetEvents() + return { XEventId.EVENT_ARENA_REFRESH_AREA_INFO } +end + + +function XUiArenaStage:OnNotify(evt) + if evt == XEventId.EVENT_ARENA_REFRESH_AREA_INFO then + self:Refresh() + end +end + +function XUiArenaStage:AutoAddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:RegisterClickEvent(self.BtnPassDetail, self.OnBtnPassDetailClick) + self:BindHelpBtn(self.BtnHelpCourse, "Arena") +end + +function XUiArenaStage:OnBtnBackClick() + if self.PassDetailPanel.IsShow then + self.PanelArenaStage.gameObject:SetActive(true) + self.PassDetailPanel:Hide() + return + end + + self:Close() +end + +function XUiArenaStage:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiArenaStage:OnBtnPassDetailClick() + XDataCenter.ArenaManager.RequestStagePassDetail(self.AreaId, function(detailMap) + self.PanelArenaStage.gameObject:SetActive(false) + self.PassDetailPanel:Show(self.AreaCfg.StageId, detailMap) + end) +end + +function XUiArenaStage:Refresh() + local areaInfo = XDataCenter.ArenaManager.GetArenaAreaDataByAreaId(self.AreaId) + self.TxtPoint.text = areaInfo.Point + self.AreaCfg = XArenaConfigs.GetArenaAreaStageCfgByAreaId(self.AreaId) + self.TxtStageName.text = self.AreaCfg.Name + self.TxtStageDesc.text = self.AreaCfg.BuffDesc + + self.CanEnterStageIndex = XDataCenter.ArenaManager.GetCurStageIndexByAreaId(self.AreaId) + if self.CanEnterStageIndex > #self.AreaCfg.StageId then + self.CanEnterStageIndex = #self.AreaCfg.StageId + end + + for i, grid in ipairs(self.StageList) do + local stageId = self.AreaCfg.StageId[i] + local score = XDataCenter.ArenaManager.GetArenaStageScore(self.AreaId, stageId) + grid:Refresh(i, self.CanEnterStageIndex, score, stageId, self.AreaId) + end + + for i, grid in ipairs(self.LordList) do + local head = XUiHelper.TryGetComponent(grid, "Head") + local rank = XUiHelper.TryGetComponent(grid, "TxtRank", "Text") + local point = XUiHelper.TryGetComponent(grid, "TxtPoint", "Text") + local nickname = XUiHelper.TryGetComponent(grid, "TxtNickname", "Text") + local btnHead = XUiHelper.TryGetComponent(grid, "BtnHead", "Button") + + CsXUiHelper.RegisterClickEvent(btnHead, function() + local data = areaInfo.LordList[i] + if not data or data.Id == XPlayer.Id then + return + end + XDataCenter.PersonalInfoManager.ReqShowInfoPanel(data.Id) + end, true) + + rank.text = i + + local lordInfo = areaInfo.LordList[i] + if lordInfo then + nickname.text = XDataCenter.SocialManager.GetPlayerRemark(lordInfo.Id, lordInfo.Name) + point.text = lordInfo.Point + + XUiPLayerHead.InitPortrait(lordInfo.CurrHeadPortraitId, lordInfo.CurrHeadFrameId, head) + else + nickname.text = CS.XTextManager.GetText("ArenaActivityLordIsEmpty") + point.text = "" + XUiPLayerHead.Hide(head) + end + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArenaStage/XUiPanelPassDetail.lua b/Resources/Scripts/XUi/XUiArenaStage/XUiPanelPassDetail.lua new file mode 100644 index 00000000..7deaf13e --- /dev/null +++ b/Resources/Scripts/XUi/XUiArenaStage/XUiPanelPassDetail.lua @@ -0,0 +1,88 @@ +local XUiPanelPassDetail = XClass(nil, "XUiPanelPassDetail") + +local XUiGridArenaPassContent = require("XUi/XUiArenaStage/ArenaStageCommon/XUiGridArenaPassContent") + +function XUiPanelPassDetail:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + + self.IsShow = false + self.GameObject:SetActive(false) + + self.GridPassTitle.gameObject:SetActive(false) + self.GridPassContent.gameObject:SetActive(false) + + self.TitleList = {} + table.insert(self.TitleList, self.GridPassTitle) + self.ContentList = {} +end + +function XUiPanelPassDetail:Show(stageIds, dataMap) + if self.IsShow then + return + end + + self.IsShow = true + self.GameObject:SetActive(true) + + self:Refresh(stageIds, dataMap) +end + +function XUiPanelPassDetail:Hide() + if not self.IsShow then + return + end + + self.IsShow = false + self.GameObject:SetActive(false) +end + +function XUiPanelPassDetail:Refresh(stageIds, dataMap) + if not stageIds then + return + end + + if not dataMap then + return + end + + for _, v in ipairs(self.TitleList) do + v.gameObject:SetActive(false) + end + + for _, v in ipairs(self.ContentList) do + v.GameObject:SetActive(false) + end + + for i, id in ipairs(stageIds) do + --标题 + local title_grid = self.TitleList[i] + if not title_grid then + local go = CS.UnityEngine.GameObject.Instantiate(self.GridPassTitle.gameObject) + title_grid = go.transform + title_grid:SetParent(self.GridPassTitle.parent, false) + table.insert(self.TitleList, title_grid) + end + title_grid.gameObject:SetActive(true) + + local title = XUiHelper.TryGetComponent(title_grid, "Image/TxtTitle", "Text") + title.text = CS.XTextManager.GetText("ArenaActivityStage", i) + title_grid:SetSiblingIndex(0) + + --玩家信息 + local content_grid = self.ContentList[i] + if not content_grid then + local go = CS.UnityEngine.GameObject.Instantiate(self.GridPassContent.gameObject) + content_grid = XUiGridArenaPassContent.New(go.transform, self) + go.transform:SetParent(self.GridPassContent.parent, false) + table.insert(self.ContentList, content_grid) + end + content_grid.GameObject:SetActive(true) + content_grid:SetMetaData(dataMap[id]) + content_grid.Transform:SetSiblingIndex(1) + end +end + +return XUiPanelPassDetail \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArenaTask/XUiArenaTask.lua b/Resources/Scripts/XUi/XUiArenaTask/XUiArenaTask.lua new file mode 100644 index 00000000..b79cb32b --- /dev/null +++ b/Resources/Scripts/XUi/XUiArenaTask/XUiArenaTask.lua @@ -0,0 +1,56 @@ +local XUiArenaTask = XLuaUiManager.Register(XLuaUi, "UiArenaTask") + +function XUiArenaTask:OnAwake() + self:AutoAddListener() +end + +function XUiArenaTask:OnStart() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + + self.GridTask.gameObject:SetActive(false) + + self.DynamicTable = XDynamicTableNormal.New(self.SViewTask.transform) + self.DynamicTable:SetProxy(XDynamicGridTask) + self.DynamicTable:SetDelegate(self) +end + +function XUiArenaTask:OnEnable() + XEventManager.AddEventListener(XEventId.EVENT_FINISH_TASK, self.Refresh, self) + self:Refresh() +end + +function XUiArenaTask:OnDisable() + XEventManager.RemoveEventListener(XEventId.EVENT_FINISH_TASK, self.Refresh, self) +end + +function XUiArenaTask:AutoAddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) +end + +function XUiArenaTask:OnBtnBackClick() + self:Close() +end + +function XUiArenaTask:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +--动态列表事件 +function XUiArenaTask:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.DailyTasks[index] + grid.RootUi = self + grid:ResetData(data) + end +end + +function XUiArenaTask:Refresh() + if not self.GameObject:Exist() then + return + end + + self.DailyTasks = XDataCenter.TaskManager.GetArenaChallengeTaskList() + self.DynamicTable:SetDataSource(self.DailyTasks) + self.DynamicTable:ReloadDataASync() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArenaTeam/XUiArenaTeam.lua b/Resources/Scripts/XUi/XUiArenaTeam/XUiArenaTeam.lua new file mode 100644 index 00000000..a548ff3f --- /dev/null +++ b/Resources/Scripts/XUi/XUiArenaTeam/XUiArenaTeam.lua @@ -0,0 +1,81 @@ +local XUiArenaTeam = XLuaUiManager.Register(XLuaUi, "UiArenaTeam") + +local XUiPanelMyTeam = require("XUi/XUiArenaTeam/XUiPanelMyTeam") +local XUiPanelHall = require("XUi/XUiArenaTeam/XUiPanelHall") +local XUiPanelApply = require("XUi/XUiArenaTeam/XUiPanelApply") +local XUiPanelInviteFriend = require("XUi/XUiArenaTeam/XUiPanelInviteFriend") + +local ARENA_TEAM_PANEL_INDEX = { + MY_TEAM = 1, + HALL = 2, + APPLY = 3, + INVITE_FRIEND = 4, +} + +function XUiArenaTeam:OnAwake() + self:AutoAddListener() + self.RedPointApplyId = XRedPointManager.AddRedPointEvent(self.BtnTabApply, self.OnCheckApplyData, self, { XRedPointConditions.Types.CONDITION_ARENA_APPLY }) +end + +function XUiArenaTeam:OnStart() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + + self.MyTeamPanel = XUiPanelMyTeam.New(self.PanelMyTeam, self) + self.HallPanel = XUiPanelHall.New(self.PanelHall, self) + self.ApplyPanel = XUiPanelApply.New(self.PanelApply, self) + self.InviteFriendPanel = XUiPanelInviteFriend.New(self.PanelInviteFriend, self) + + self.PanelList = {} + table.insert(self.PanelList, self.MyTeamPanel) + table.insert(self.PanelList, self.HallPanel) + table.insert(self.PanelList, self.ApplyPanel) + table.insert(self.PanelList, self.InviteFriendPanel) + + self.BtnList = {} + table.insert(self.BtnList, self.BtnTabMyTeam) + table.insert(self.BtnList, self.BtnTabHall) + table.insert(self.BtnList, self.BtnTabApply) + table.insert(self.BtnList, self.BtnTabInvite) + + + self.TeamTabGroup:Init(self.BtnList, function(index) + self:RefreshSelectedPanel(index) + end) + + -- 默认第一标签页 + self.TeamTabGroup:SelectIndex(ARENA_TEAM_PANEL_INDEX.MY_TEAM) +end + +function XUiArenaTeam:AutoAddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) +end + +function XUiArenaTeam:OnBtnBackClick() + self:Close() +end + +function XUiArenaTeam:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiArenaTeam:OnCheckApplyData(count) + self.BtnTabApply:ShowReddot(count >= 0) +end + +function XUiArenaTeam:RefreshSelectedPanel(index) + for i, panel in ipairs(self.PanelList) do + if i == index then + panel:Show() + else + panel:Hide() + end + end +end + +function XUiArenaTeam:JumpToHallPanel(index) + self.TeamTabGroup:SelectIndex(ARENA_TEAM_PANEL_INDEX.HALL) + if index then + self.HallPanel.TypeTabGroup:SelectIndex(index) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArenaTeam/XUiArenaTeamCommon/XUiGridArenaMyTeamMember.lua b/Resources/Scripts/XUi/XUiArenaTeam/XUiArenaTeamCommon/XUiGridArenaMyTeamMember.lua new file mode 100644 index 00000000..de4683e1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiArenaTeam/XUiArenaTeamCommon/XUiGridArenaMyTeamMember.lua @@ -0,0 +1,110 @@ +local XUiGridArenaMyTeamMember = XClass(nil, "XUiGridArenaMyTeamMember") + +function XUiGridArenaMyTeamMember:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + + XTool.InitUiObject(self) + self:AutoAddListener() +end + +function XUiGridArenaMyTeamMember:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiGridArenaMyTeamMember:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiGridArenaMyTeamMember:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiGridArenaMyTeamMember:AutoAddListener() + self:RegisterClickEvent(self.BtnKickOut, self.OnBtnKickOutClick) + self:RegisterClickEvent(self.BtnHead, self.OnBtnHeadClick) + self:RegisterClickEvent(self.BtnAddTeamMember, self.OnBtnAddTeamMemberClick) +end + +function XUiGridArenaMyTeamMember:OnBtnHeadClick() + if not self.Data or self.Data.Id == XPlayer.Id then + return + end + + XDataCenter.PersonalInfoManager.ReqShowInfoPanel(self.Data.Id) +end + +function XUiGridArenaMyTeamMember:OnBtnKickOutClick() + if not self.Data then + return + end + + if self.Data.Id == XPlayer.Id then + return + end + + if not XDataCenter.ArenaManager.CheckSelfIsCaptain() then + return + end + + XUiManager.DialogTip("", CS.XTextManager.GetText("ArenaTeamKickOutMemberConfirm", self.Data.Name), XUiManager.DialogType.Normal, nil, function() + XDataCenter.ArenaManager.RequestKickTeam(self.Data.Id) + end) +end + +function XUiGridArenaMyTeamMember:OnBtnAddTeamMemberClick() + if self.Data then + return + end + + if not XDataCenter.ArenaManager.CheckSelfIsCaptain() then + return + end + + self.RootUi:JumpToHallPanel(2) +end + +function XUiGridArenaMyTeamMember:Refresh(data) + self.Data = data + + -- 是否队长权限 + local isSelfCaptain = XDataCenter.ArenaManager.CheckSelfIsCaptain() + self.ImgAdd.gameObject:SetActive(isSelfCaptain) + self.BtnKickOut.gameObject:SetActive(isSelfCaptain) + + -- 没有队员 + if not data then + self.PanelSomeOne.gameObject:SetActive(false) + self.PanelNone.gameObject:SetActive(true) + return + end + + -- 有队员 + self.PanelSomeOne.gameObject:SetActive(true) + self.PanelNone.gameObject:SetActive(false) + + -- 是否队长 + local isCaptain = XDataCenter.ArenaManager.CheckPlayerIsCaptain(self.Data.Id) + self.ImgCaptain.gameObject:SetActive(isCaptain) + + -- 是否自己 + local isSelf = self.Data.Id == XPlayer.Id + self.PanelSelf.gameObject:SetActive(isSelf) + self.PanelOthers.gameObject:SetActive(not isSelf) + + -- 显示信息 + self.TxtNickname.text = XDataCenter.SocialManager.GetPlayerRemark(self.Data.Id, self.Data.Name) + self.TxtPlayerLevel.text = self.Data.Level + self.TxtOnline.gameObject:SetActive(self.Data.Online == 1) + self.TxtOffline.gameObject:SetActive(self.Data.Online ~= 1) + + XUiPLayerHead.InitPortrait(self.Data.CurrHeadPortraitId, self.Data.CurrHeadFrameId, self.Head) +end + +return XUiGridArenaMyTeamMember \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArenaTeam/XUiArenaTeamCommon/XUiGridArenaTeam.lua b/Resources/Scripts/XUi/XUiArenaTeam/XUiArenaTeamCommon/XUiGridArenaTeam.lua new file mode 100644 index 00000000..26d6c621 --- /dev/null +++ b/Resources/Scripts/XUi/XUiArenaTeam/XUiArenaTeamCommon/XUiGridArenaTeam.lua @@ -0,0 +1,84 @@ +local XUiGridArenaTeam = XClass(nil, "XUiGridArenaTeam") + +local XUiGridArenaTeamMember = require("XUi/XUiArenaTeam/XUiArenaTeamCommon/XUiGridArenaTeamMember") + +function XUiGridArenaTeam:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:AutoAddListener() + + self.Member1 = XUiGridArenaTeamMember.New(self.GridTeamMember1) + self.Member2 = XUiGridArenaTeamMember.New(self.GridTeamMember2) + self.Member3 = XUiGridArenaTeamMember.New(self.GridTeamMember3) + + self.MemberList = {} + table.insert(self.MemberList, self.Member1) + table.insert(self.MemberList, self.Member2) + table.insert(self.MemberList, self.Member3) +end + +function XUiGridArenaTeam:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiGridArenaTeam:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiGridArenaTeam:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiGridArenaTeam:AutoAddListener() + self:RegisterClickEvent(self.BtnJoinTeam, self.OnBtnJoinTeamClick) +end + +function XUiGridArenaTeam:OnBtnJoinTeamClick() + if not self.Data then + return + end + + if self.Data.Apply == 1 then + return + end + + local teamId = XDataCenter.ArenaManager.GetTeamId() + if teamId > 0 then + XUiManager.TipError(CS.XTextManager.GetText("ArenaTeamAlreadyHaveTeam")) + return + end + + XDataCenter.ArenaManager.RequestApplyTeam(self.Data.Info.TeamId, function() + self:Refresh() + end) +end + +function XUiGridArenaTeam:ResetData(data, rootUi) + self.RootUi = rootUi + self.Data = data + self:Refresh() +end + +function XUiGridArenaTeam:Refresh() + if not self.Data then + return + end + + local isApplied = self.Data.Apply == 1 + self.BtnJoinTeam.interactable = not isApplied + self.TxtIsApplied.gameObject:SetActive(isApplied) + self.TxtJoin.gameObject:SetActive(not isApplied) + + for i, member in ipairs(self.MemberList) do + local info = self.Data.Info.ShowList[i] + member:SetData(info, self.Data.Info.Captain, self.RootUi) + end +end + +return XUiGridArenaTeam \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArenaTeam/XUiArenaTeamCommon/XUiGridArenaTeamApply.lua b/Resources/Scripts/XUi/XUiArenaTeam/XUiArenaTeamCommon/XUiGridArenaTeamApply.lua new file mode 100644 index 00000000..618270f2 --- /dev/null +++ b/Resources/Scripts/XUi/XUiArenaTeam/XUiArenaTeamCommon/XUiGridArenaTeamApply.lua @@ -0,0 +1,89 @@ +local XUiGridArenaTeamApply = XClass(nil, "XUiGridArenaTeamApply") + +function XUiGridArenaTeamApply:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:AutoAddListener() +end + +function XUiGridArenaTeamApply:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiGridArenaTeamApply:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiGridArenaTeamApply:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiGridArenaTeamApply:AutoAddListener() + self:RegisterClickEvent(self.BtnRefuse, self.OnBtnRefuseClick) + self:RegisterClickEvent(self.BtnAccept, self.OnBtnAcceptClick) + self:RegisterClickEvent(self.BtnHead, self.OnBtnHeadClick) +end + +function XUiGridArenaTeamApply:OnBtnHeadClick() + if not self.Data or self.Data.Id == XPlayer.Id then + return + end + + XDataCenter.PersonalInfoManager.ReqShowInfoPanel(self.Data.Id) +end + +function XUiGridArenaTeamApply:OnBtnRefuseClick() + if not self.Data then + return + end + + if self.IsInTeam then + if XDataCenter.ArenaManager.CheckSelfIsCaptain() then + XDataCenter.ArenaManager.RequestRefuseApply(self.Data.Id) + end + else + XDataCenter.ArenaManager.RequestRefuseInvite(self.Data.Id) + end +end + +function XUiGridArenaTeamApply:OnBtnAcceptClick() + if not self.Data then + return + end + + if self.IsInTeam then + if XDataCenter.ArenaManager.CheckSelfIsCaptain() then + XDataCenter.ArenaManager.RequestAcceptApply(self.Data.Id) + end + else + XDataCenter.ArenaManager.RequestAcceptInvite(self.Data.Id) + end +end + +function XUiGridArenaTeamApply:ResetData(data, rootUi) + self.Data = data + self.RootUi = rootUi + self:Refresh() +end + +function XUiGridArenaTeamApply:Refresh() + if not self.Data then + return + end + + self.IsInTeam = XDataCenter.ArenaManager.GetTeamId() > 0 + self.TxtApplyOfPlayer.gameObject:SetActive(self.IsInTeam) + self.TxtApplyOfTeam.gameObject:SetActive(not self.IsInTeam) + self.TxtNickname.text = XDataCenter.SocialManager.GetPlayerRemark(self.Data.Id, self.Data.Name) + self.TxtPlayerLevel.text = self.Data.Level + + XUiPLayerHead.InitPortrait(self.Data.CurrHeadPortraitId, self.Data.CurrHeadFrameId, self.Head) +end + +return XUiGridArenaTeamApply \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArenaTeam/XUiArenaTeamCommon/XUiGridArenaTeamMember.lua b/Resources/Scripts/XUi/XUiArenaTeam/XUiArenaTeamCommon/XUiGridArenaTeamMember.lua new file mode 100644 index 00000000..b4686f74 --- /dev/null +++ b/Resources/Scripts/XUi/XUiArenaTeam/XUiArenaTeamCommon/XUiGridArenaTeamMember.lua @@ -0,0 +1,58 @@ +local XUiGridArenaTeamMember = XClass(nil, "XUiGridArenaTeamMember") + +function XUiGridArenaTeamMember:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:AutoAddListener() +end + +function XUiGridArenaTeamMember:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiGridArenaTeamMember:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiGridArenaTeamMember:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiGridArenaTeamMember:AutoAddListener() + self:RegisterClickEvent(self.BtnHead, self.OnBtnHeadClick) +end + +function XUiGridArenaTeamMember:OnBtnHeadClick() + if not self.Data or self.Data.Id == XPlayer.Id then + return + end + + XDataCenter.PersonalInfoManager.ReqShowInfoPanel(self.Data.Id) +end + +function XUiGridArenaTeamMember:SetData(data, captainId) + self.Data = data + + if not data then + self.PanelSomeOne.gameObject:SetActive(false) + self.PanelNone.gameObject:SetActive(true) + return + end + + self.PanelSomeOne.gameObject:SetActive(true) + self.PanelNone.gameObject:SetActive(false) + self.TxtNickname.text = XDataCenter.SocialManager.GetPlayerRemark(data.Id, data.Name) + self.TxtPlayerLevel.text = data.Level + local isCaptain = data.Id == captainId + self.ImgCaptain.gameObject:SetActive(isCaptain) + + XUiPLayerHead.InitPortrait(data.CurrHeadPortraitId, data.CurrHeadFrameId, self.Head) +end + +return XUiGridArenaTeamMember \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArenaTeam/XUiArenaTeamCommon/XUiGridArenaTeamSingle.lua b/Resources/Scripts/XUi/XUiArenaTeam/XUiArenaTeamCommon/XUiGridArenaTeamSingle.lua new file mode 100644 index 00000000..4b3815af --- /dev/null +++ b/Resources/Scripts/XUi/XUiArenaTeam/XUiArenaTeamCommon/XUiGridArenaTeamSingle.lua @@ -0,0 +1,133 @@ +local XUiGridArenaTeamSingle = XClass(nil, "XUiGridArenaTeamSingle") + +function XUiGridArenaTeamSingle:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:AutoAddListener() + self.ArenaLevel = XUiHelper.TryGetComponent(self.Transform, "ArenaLevel", nil).gameObject +end + +function XUiGridArenaTeamSingle:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiGridArenaTeamSingle:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiGridArenaTeamSingle:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiGridArenaTeamSingle:AutoAddListener() + self:RegisterClickEvent(self.BtnInvite, self.OnBtnInviteClick) + self:RegisterClickEvent(self.BtnHead, self.OnBtnHeadClick) + self:RegisterClickEvent(self.BtnInviteDis, self.OnBtnInviteDisClick) +end + +function XUiGridArenaTeamSingle:OnBtnHeadClick() + if not self.Data or not self.Data.Info or self.Data.Info.Id == XPlayer.Id then + return + end + + XDataCenter.PersonalInfoManager.ReqShowInfoPanel(self.Data.Info.Id) +end + +function XUiGridArenaTeamSingle:OnBtnInviteDisClick() + -- if not self.Data then + -- return + -- end + -- local text = "" + -- if self.Data.ChallengeId > 0 then + -- text = CS.XTextManager.GetText("ArenaTeamLevelError") + -- else + -- text = CS.XTextManager.GetText("ArenaTeamChallengeError") + -- end + -- XUiManager.TipError(text) +end + +function XUiGridArenaTeamSingle:OnBtnInviteClick() + if not self.Data then + return + end + + if self.Data.Invite == 1 then + return + end + + local teamId = XDataCenter.ArenaManager.GetTeamId() + if teamId <= 0 then + XUiManager.TipError(CS.XTextManager.GetText("ArenaTeamCanNotInvite")) + return + end + + if not XDataCenter.ArenaManager.CheckSelfIsCaptain() then + XUiManager.TipError(CS.XTextManager.GetText("ArenaTeamIsNotCaptain")) + return + end + + XDataCenter.ArenaManager.RequestInvitePlayer(self.Data.Info.Id, function() + self.Data.ChallengeId = XDataCenter.ArenaManager.GetCurChallengeId() + self:Refresh() + end) +end + +function XUiGridArenaTeamSingle:ResetData(data, rootUi) + self.Data = data + self.RootUi = rootUi + self:Refresh() +end + +function XUiGridArenaTeamSingle:Refresh() + if not self.Data then + return + end + + self.TxtNickname.text = XDataCenter.SocialManager.GetPlayerRemark(self.Data.Info.Id, self.Data.Info.Name) + self.TxtPlayerLevel.text = self.Data.Info.Level + + local isOnline = self.Data.Info.Online == 1 + self.TxtOnline.gameObject:SetActiveEx(isOnline) + self.TxtOffline.gameObject:SetActiveEx(not isOnline) + + local isInvited = self.Data.Invite == 1 + self.TxtInvited.gameObject:SetActiveEx(isInvited) + self.TxtNotInvited.gameObject:SetActiveEx(not isInvited) + if self.BtnInviteDis and not XTool.UObjIsNil(self.BtnInviteDis) then + self.BtnInviteDis.gameObject:SetActiveEx(false) + end + + XUiPLayerHead.InitPortrait(self.Data.Info.CurrHeadPortraitId, self.Data.Info.CurrHeadFrameId, self.Head) + + if self.Data.ArenaLevel then + self.ArenaLevel:SetActiveEx(true) + local isSameId = self.Data.ChallengeId == XDataCenter.ArenaManager.GetCurChallengeId() + if self.BtnInviteDis and not XTool.UObjIsNil(self.BtnInviteDis) and (not isInvited) then + self.BtnInviteDis.gameObject:SetActiveEx(not isSameId) + end + + if not isSameId and self.TxtInviteDis then + self.TxtNotInvited.gameObject:SetActiveEx(isSameId) + if self.Data.ChallengeId > 0 then + self.TxtInviteDis.text = CS.XTextManager.GetText("ArenaTeamLevelError") + else + self.TxtInviteDis.text = CS.XTextManager.GetText("ArenaTeamChallengeError") + end + end + + self.RImgArenaLevel.gameObject:SetActiveEx(true) + local arenaCfg = XArenaConfigs.GetArenaLevelCfgByLevel(self.Data.ArenaLevel) + self.RImgArenaLevel:SetRawImage(arenaCfg.Icon) + else + self.ArenaLevel:SetActiveEx(false) + self.RImgArenaLevel.gameObject:SetActiveEx(false) + end +end + +return XUiGridArenaTeamSingle \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArenaTeam/XUiPanelApply.lua b/Resources/Scripts/XUi/XUiArenaTeam/XUiPanelApply.lua new file mode 100644 index 00000000..8b1dfed5 --- /dev/null +++ b/Resources/Scripts/XUi/XUiArenaTeam/XUiPanelApply.lua @@ -0,0 +1,73 @@ +local XUiPanelApply = XClass(nil, "XUiPanelApply") + +local XUiGridArenaTeamApply = require("XUi/XUiArenaTeam/XUiArenaTeamCommon/XUiGridArenaTeamApply") + +function XUiPanelApply:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + self.GridTeamApply.gameObject:SetActive(false) + + self.RootUi = rootUi + self.IsShow = false + self.GameObject:SetActive(false) + + self.DynamicTable = XDynamicTableNormal.New(self.SViewSingle.transform) + self.DynamicTable:SetProxy(XUiGridArenaTeamApply) + self.DynamicTable:SetDelegate(self) +end + +function XUiPanelApply:Show() + if self.IsShow then + return + end + + self.IsShow = true + self.GameObject:SetActive(true) + self.RootUi:PlayAnimation("ApplyQieHuan") + XEventManager.AddEventListener(XEventId.EVENT_ARENA_TEAM_APPLY_CHANGE, self.Refresh, self) + XEventManager.AddEventListener(XEventId.EVENT_ARENA_TEAM_NEW_APPLY_ENTER, self.Refresh, self) + self:Refresh() +end + +function XUiPanelApply:Hide() + if not self.IsShow then + return + end + + self.IsShow = false + self.GameObject:SetActive(false) + XEventManager.RemoveEventListener(XEventId.EVENT_ARENA_TEAM_APPLY_CHANGE, self.Refresh, self) + XEventManager.RemoveEventListener(XEventId.EVENT_ARENA_TEAM_NEW_APPLY_ENTER, self.Refresh, self) +end + +function XUiPanelApply:Refresh() + if not self.GameObject:Exist() then + return + end + + local func = function() + self.DataList = XDataCenter.ArenaManager.GetApplyDataList() + self.DynamicTable:SetTotalCount(#self.DataList) + if #self.DataList > 0 then + self.TxtNoApply.gameObject:SetActive(false) + self.DynamicTable:ReloadDataASync(1) + else + self.TxtNoApply.gameObject:SetActive(true) + self.DynamicTable:ReloadDataASync() + end + end + + XDataCenter.ArenaManager.RequestApplyData(func) +end + +--动态列表事件 +function XUiPanelApply:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.DataList[index] + grid:ResetData(data, self.RootUi) + end +end + +return XUiPanelApply \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArenaTeam/XUiPanelHall.lua b/Resources/Scripts/XUi/XUiArenaTeam/XUiPanelHall.lua new file mode 100644 index 00000000..479ab512 --- /dev/null +++ b/Resources/Scripts/XUi/XUiArenaTeam/XUiPanelHall.lua @@ -0,0 +1,143 @@ +local XUiPanelHall = XClass(nil, "XUiPanelHall") + +local XUiGridArenaTeam = require("XUi/XUiArenaTeam/XUiArenaTeamCommon/XUiGridArenaTeam") +local XUiGridArenaTeamSingle = require("XUi/XUiArenaTeam/XUiArenaTeamCommon/XUiGridArenaTeamSingle") + +local ARENA_HALL_TAB = { + TEAM = 1, + SINGLE = 2, +} + +function XUiPanelHall:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:AutoAddListener() + + self.GridTeam.gameObject:SetActive(false) + self.GridTeamSingle.gameObject:SetActive(false) + + self.RootUi = rootUi + self.IsShow = false + self.GameObject:SetActive(false) + + self.DynamicTeamTable = XDynamicTableNormal.New(self.SViewTeam.transform) + self.DynamicTeamTable:SetProxy(XUiGridArenaTeam) + self.DynamicTeamTable:SetDelegate(self) + + self.DynamicSingleTable = XDynamicTableNormal.New(self.SViewSingle.transform) + self.DynamicSingleTable:SetProxy(XUiGridArenaTeamSingle) + self.DynamicSingleTable:SetDelegate(self) + + self.BtnList = {} + table.insert(self.BtnList, self.BtnTabTeam) + table.insert(self.BtnList, self.BtnTabSingle) + + self.TypeTabGroup:Init(self.BtnList, function(index) + self:RefreshSelectedPanel(index) + end) +end + +function XUiPanelHall:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelHall:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelHall:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelHall:AutoAddListener() + self:RegisterClickEvent(self.BtnRefresh, self.OnBtnRefreshClick) +end + +function XUiPanelHall:OnBtnRefreshClick() + self:Refresh() +end + +function XUiPanelHall:Show() + if self.IsShow then + return + end + + self.IsShow = true + self.GameObject:SetActive(true) + self.RootUi:PlayAnimation("HallQieHuan") + self.TypeTabGroup:SelectIndex(ARENA_HALL_TAB.TEAM) +end + +function XUiPanelHall:Hide() + if not self.IsShow then + return + end + + self.IsShow = false + self.GameObject:SetActive(false) +end + +--动态列表事件 +function XUiPanelHall:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.DataList[index] + grid:ResetData(data, self.RootUi) + end +end + +function XUiPanelHall:Refresh() + local func = function() + self.TxtNoPlayer.gameObject:SetActive(false) + self.TxtNoTeam.gameObject:SetActive(false) + + if self.SelectedIndex == ARENA_HALL_TAB.TEAM then + self.DataList = XDataCenter.ArenaManager.GetHallTeamList() + + self.DynamicTeamTable:SetTotalCount(#self.DataList) + if #self.DataList > 0 then + self.TxtNoTeam.gameObject:SetActive(false) + self.DynamicTeamTable:ReloadDataASync(1) + else + self.TxtNoTeam.gameObject:SetActive(true) + self.DynamicTeamTable:ReloadDataASync() + end + else + self.DataList = XDataCenter.ArenaManager.GetHallPlayerList() + + self.DynamicSingleTable:SetTotalCount(#self.DataList) + if #self.DataList > 0 then + self.TxtNoPlayer.gameObject:SetActive(false) + self.DynamicSingleTable:ReloadDataASync(1) + else + self.TxtNoPlayer.gameObject:SetActive(true) + self.DynamicSingleTable:ReloadDataASync() + end + end + end + + if self.SelectedIndex == ARENA_HALL_TAB.TEAM then + XDataCenter.ArenaManager.RequestHallTeamList(func) + else + XDataCenter.ArenaManager.RequestHallPlayerList(func) + end +end + +function XUiPanelHall:RefreshSelectedPanel(index) + self.SelectedIndex = index + if index == ARENA_HALL_TAB.TEAM then + self.SViewTeam.gameObject:SetActive(true) + self.SViewSingle.gameObject:SetActive(false) + else + self.SViewTeam.gameObject:SetActive(false) + self.SViewSingle.gameObject:SetActive(true) + end + self:Refresh() +end + +return XUiPanelHall \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArenaTeam/XUiPanelInviteFriend.lua b/Resources/Scripts/XUi/XUiArenaTeam/XUiPanelInviteFriend.lua new file mode 100644 index 00000000..da788ebb --- /dev/null +++ b/Resources/Scripts/XUi/XUiArenaTeam/XUiPanelInviteFriend.lua @@ -0,0 +1,65 @@ +local XUiPanelInviteFriend = XClass(nil, "XUiPanelInviteFriend") + +local XUiGridArenaTeamSingle = require("XUi/XUiArenaTeam/XUiArenaTeamCommon/XUiGridArenaTeamSingle") + +function XUiPanelInviteFriend:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.GridTeamSingle.gameObject:SetActive(false) + + self.RootUi = rootUi + self.IsShow = false + self.GameObject:SetActive(false) + + self.DynamicTable = XDynamicTableNormal.New(self.SViewSingle.transform) + self.DynamicTable:SetProxy(XUiGridArenaTeamSingle) + self.DynamicTable:SetDelegate(self) +end + +function XUiPanelInviteFriend:Show() + if self.IsShow then + return + end + + self.IsShow = true + self.GameObject:SetActive(true) + + self:Refresh() +end + +function XUiPanelInviteFriend:Hide() + if not self.IsShow then + return + end + + self.IsShow = false + self.GameObject:SetActive(false) + self.RootUi:PlayAnimation("InviteFriendQieHuan") +end + +function XUiPanelInviteFriend:Refresh() + XDataCenter.ArenaManager.RequestFriendArenaInfo(function() + self.DataList = XDataCenter.ArenaManager.GetArenaFriendList() + self.DynamicTable:SetTotalCount(#self.DataList) + if #self.DataList > 0 then + self.TxtNoApply.gameObject:SetActive(false) + self.DynamicTable:ReloadDataASync(1) + else + self.TxtNoApply.gameObject:SetActive(true) + self.DynamicTable:ReloadDataASync() + end + end) + + self.TxtTips.text = CS.XTextManager.GetText("ArenaTeamInvitTip") +end + +--动态列表事件 +function XUiPanelInviteFriend:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.DataList[index] + grid:ResetData(data, self.RootUi) + end +end + +return XUiPanelInviteFriend \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArenaTeam/XUiPanelMyTeam.lua b/Resources/Scripts/XUi/XUiArenaTeam/XUiPanelMyTeam.lua new file mode 100644 index 00000000..55aea5a8 --- /dev/null +++ b/Resources/Scripts/XUi/XUiArenaTeam/XUiPanelMyTeam.lua @@ -0,0 +1,117 @@ +local XUiPanelMyTeam = XClass(nil, "XUiPanelMyTeam") + +local XUiGridArenaMyTeamMember = require("XUi/XUiArenaTeam/XUiArenaTeamCommon/XUiGridArenaMyTeamMember") + +function XUiPanelMyTeam:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:AutoAddListener() + + self.RootUi = rootUi + self.IsShow = false + self.GameObject:SetActive(false) + + self.Member1 = XUiGridArenaMyTeamMember.New(self.GridMyTeamMember1, self.RootUi) + self.Member2 = XUiGridArenaMyTeamMember.New(self.GridMyTeamMember2, self.RootUi) + self.Member3 = XUiGridArenaMyTeamMember.New(self.GridMyTeamMember3, self.RootUi) + + self.MemberList = {} + table.insert(self.MemberList, self.Member1) + table.insert(self.MemberList, self.Member2) + table.insert(self.MemberList, self.Member3) +end + +function XUiPanelMyTeam:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelMyTeam:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelMyTeam:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelMyTeam:AutoAddListener() + self:RegisterClickEvent(self.BtnLeaveTeam, self.OnBtnLeaveTeamClick) + self:RegisterClickEvent(self.BtnJoinTeam, self.OnBtnJoinTeamClick) + self:RegisterClickEvent(self.BtnCreateTeam, self.OnBtnCreateTeamClick) +end + +function XUiPanelMyTeam:OnBtnLeaveTeamClick() + XUiManager.DialogTip("", CS.XTextManager.GetText("ArenaTeamLeveTeamConfirm"), XUiManager.DialogType.Normal, nil, function() + XDataCenter.ArenaManager.RequestLeaveTeam(function() + if self.IsShow and not XTool.UObjIsNil(self.GameObject) then + self:Refresh() + end + end) + end) +end + +function XUiPanelMyTeam:OnBtnJoinTeamClick() + self.RootUi:JumpToHallPanel() +end + +function XUiPanelMyTeam:OnBtnCreateTeamClick() + XDataCenter.ArenaManager.RequestCreateTeam(function() + if self.IsShow and not XTool.UObjIsNil(self.GameObject) then + self:Refresh() + end + end) +end + +function XUiPanelMyTeam:Show() + if self.IsShow then + return + end + + self.IsShow = true + self.GameObject:SetActive(true) + self.RootUi:PlayAnimation("MyTeamQieHuan") + XEventManager.AddEventListener(XEventId.EVENT_ARENA_TEAM_CHANGE, self.Refresh, self) + self:Refresh() +end + +function XUiPanelMyTeam:Hide() + if not self.IsShow then + return + end + + self.IsShow = false + self.GameObject:SetActive(false) + XEventManager.RemoveEventListener(XEventId.EVENT_ARENA_TEAM_CHANGE, self.Refresh, self) +end + +function XUiPanelMyTeam:Refresh() + if not self.GameObject:Exist() then + return + end + + local teamId = XDataCenter.ArenaManager.GetTeamId() + -- 没有队伍 + if teamId == 0 then + self.PanelInTeam.gameObject:SetActive(false) + self.PanelOutTeam.gameObject:SetActive(true) + return + end + + -- 有队伍 + self.PanelInTeam.gameObject:SetActive(true) + self.PanelOutTeam.gameObject:SetActive(false) + + -- 刷新队伍成员信息 + local teamMembers = XDataCenter.ArenaManager.GetMyTeamMemberList() + for i, member in ipairs(self.MemberList) do + local info = teamMembers[i] + member:Refresh(info) + end +end + +return XUiPanelMyTeam \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArenaTeamRank/ArenaTeamRankCommon/XUiGridArenaTeamRank.lua b/Resources/Scripts/XUi/XUiArenaTeamRank/ArenaTeamRankCommon/XUiGridArenaTeamRank.lua new file mode 100644 index 00000000..b15439bb --- /dev/null +++ b/Resources/Scripts/XUi/XUiArenaTeamRank/ArenaTeamRankCommon/XUiGridArenaTeamRank.lua @@ -0,0 +1,74 @@ +local XUiGridArenaTeamRank = XClass(nil, "XUiGridArenaTeamRank") + +function XUiGridArenaTeamRank:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiGridArenaTeamRank:ResetData(rank, data, rootUi, totalRank) + if not self.GameObject:Exist() then + return + end + + if not data then + return + end + + if rank == 1 then + self.TxtRank.text = CS.XTextManager.GetText("Rank1Color", rank) + elseif rank == 2 then + self.TxtRank.text = CS.XTextManager.GetText("Rank2Color", rank) + elseif rank == 3 then + self.TxtRank.text = CS.XTextManager.GetText("Rank3Color", rank) + else + if totalRank and rank > 100 and totalRank > 0 then + local rankRate = math.ceil(rank / totalRank * 100) + if rankRate >= 100 then + rankRate = 99 + end + local rankRateDesc = rankRate .. "%" + self.TxtRank.text = CS.XTextManager.GetText("RankOtherColor", rankRateDesc) + else + self.TxtRank.text = CS.XTextManager.GetText("RankOtherColor", rank) + end + end + + if self.ImgTeamBg then + self.ImgTeamBg.gameObject:SetActive(rank % 2 == 0) + end + + self.TxtPoint.text = data.Point + + local captain = data.Captain + + for i = 1, 3 do + local grid = self["GridMember" .. i] + local head = XUiHelper.TryGetComponent(grid, "Head") + local nickname = XUiHelper.TryGetComponent(grid, "GridName/TxtNickname", "Text") + local captainTrans = XUiHelper.TryGetComponent(grid, "GridName/ImgCaptain", nil) + local btnHead = XUiHelper.TryGetComponent(grid, "BtnHead", "Button") + + CsXUiHelper.RegisterClickEvent(btnHead, function() + local player = data.PlayerList[i] + if not player or player.Id == XPlayer.Id then + return + end + XDataCenter.PersonalInfoManager.ReqShowInfoPanel(player.Id) + end, true) + + local info = data.PlayerList[i] + if info then + nickname.gameObject:SetActive(true) + nickname.text = XDataCenter.SocialManager.GetPlayerRemark(info.Id, info.Name) + captainTrans.gameObject:SetActive(info.Id == captain) + XUiPLayerHead.InitPortrait(info.CurrHeadPortraitId, info.CurrHeadFrameId, head) + else + nickname.gameObject:SetActive(false) + captainTrans.gameObject:SetActive(false) + XUiPLayerHead.Hide(head) + end + end +end + +return XUiGridArenaTeamRank \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArenaTeamRank/ArenaTeamRankCommon/XUiGridArenaTeamReward.lua b/Resources/Scripts/XUi/XUiArenaTeamRank/ArenaTeamRankCommon/XUiGridArenaTeamReward.lua new file mode 100644 index 00000000..8d4f9678 --- /dev/null +++ b/Resources/Scripts/XUi/XUiArenaTeamRank/ArenaTeamRankCommon/XUiGridArenaTeamReward.lua @@ -0,0 +1,46 @@ +local XUiGridArenaTeamReward = XClass(nil, "XUiGridArenaTeamReward") + +function XUiGridArenaTeamReward:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.GridUis = {} + XTool.InitUiObject(self) + + self.GridCommon.gameObject:SetActive(false) +end + +function XUiGridArenaTeamReward:ResetData(data, rootUi) + if not data then + return + end + self.RootUi = rootUi + + local rank = "" + if data.MinRank > 0 then + rank = rank .. data.MinRank .. "%-" + end + rank = rank .. data.MaxRank .. "%" + self.TxtRankRange.text = rank + + local rankRate = XDataCenter.ArenaManager.GetMyTeamRankRate() + self.ImgSelf.gameObject:SetActive(data.MinRank / 100 < rankRate and data.MaxRank / 100 >= rankRate) + + self.DataList = XDataCenter.MailManager.GetRewardList(data.MailId) or {} + for _, ui in pairs(self.GridUis) do + ui.GameObject:SetActive(false) + end + + for i, reward in pairs(self.DataList) do + local ui = self.GridUis[i] + if not ui then + local grid = CS.UnityEngine.Object.Instantiate(self.GridCommon) + grid.transform:SetParent(self.SViewReward.transform, false) + ui = XUiGridCommon.New(self.RootUi, grid) + table.insert(self.GridUis, ui) + end + + ui:Refresh(reward) + end +end + +return XUiGridArenaTeamReward \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArenaTeamRank/XUiArenaTeamRank.lua b/Resources/Scripts/XUi/XUiArenaTeamRank/XUiArenaTeamRank.lua new file mode 100644 index 00000000..c949e6c9 --- /dev/null +++ b/Resources/Scripts/XUi/XUiArenaTeamRank/XUiArenaTeamRank.lua @@ -0,0 +1,58 @@ +local XUiArenaTeamRank = XLuaUiManager.Register(XLuaUi, "UiArenaTeamRank") + +local XUiPanelTeamRank = require("XUi/XUiArenaTeamRank/XUiPanelTeamRank") +local XUiPanelRewardPreview = require("XUi/XUiArenaTeamRank/XUiPanelRewardPreview") + +local ARENA_TEAM_RANK_PANEL_INDEX = { + TEAM_RANK = 1, + REWARD_PREVIEW = 2, +} + +function XUiArenaTeamRank:OnAwake() + self:AutoAddListener() +end + +function XUiArenaTeamRank:OnStart() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + + self.TeamRankPanel = XUiPanelTeamRank.New(self.PanelTeamRank, self) + self.RewardPreviewPanel = XUiPanelRewardPreview.New(self.PanelRewardPreview, self) + + self.PanelList = {} + table.insert(self.PanelList, self.TeamRankPanel) + table.insert(self.PanelList, self.RewardPreviewPanel) + + self.BtnList = {} + table.insert(self.BtnList, self.BtnTeamRank) + table.insert(self.BtnList, self.BtnRewardPreview) + + self.TabGroup = XUiTabBtnGroup.New(self.BtnList, function(index) + self:RefreshSelectedPanel(index) + end) + + -- 默认第一标签页 + self.TabGroup:SelectIndex(ARENA_TEAM_RANK_PANEL_INDEX.TEAM_RANK) +end + +function XUiArenaTeamRank:AutoAddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) +end + +function XUiArenaTeamRank:OnBtnBackClick() + self:Close() +end + +function XUiArenaTeamRank:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiArenaTeamRank:RefreshSelectedPanel(index) + for i, panel in ipairs(self.PanelList) do + if i == index then + panel:Show() + else + panel:Hide() + end + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArenaTeamRank/XUiPanelRewardPreview.lua b/Resources/Scripts/XUi/XUiArenaTeamRank/XUiPanelRewardPreview.lua new file mode 100644 index 00000000..e9656f3c --- /dev/null +++ b/Resources/Scripts/XUi/XUiArenaTeamRank/XUiPanelRewardPreview.lua @@ -0,0 +1,61 @@ +local XUiPanelRewardPreview = XClass(nil, "XUiPanelRewardPreview") + +local XUiGridArenaTeamReward = require("XUi/XUiArenaTeamRank/ArenaTeamRankCommon/XUiGridArenaTeamReward") + +function XUiPanelRewardPreview:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + + self.GridArenaTeamReward.gameObject:SetActive(false) + + self.IsShow = false + self.GameObject:SetActive(false) + + self.DynamicTable = XDynamicTableNormal.New(self.SViewTeamReward.transform) + self.DynamicTable:SetProxy(XUiGridArenaTeamReward) + self.DynamicTable:SetDelegate(self) +end + +function XUiPanelRewardPreview:Show() + if self.IsShow then + return + end + + self.IsShow = true + self.GameObject:SetActive(true) + + self:Refresh() +end + +function XUiPanelRewardPreview:Hide() + if not self.IsShow then + return + end + + self.IsShow = false + self.GameObject:SetActive(false) +end + +function XUiPanelRewardPreview:Refresh() + local challengId = XDataCenter.ArenaManager.GetCurChallengeId() + self.DataList = XArenaConfigs.GetTeamRankRewardCfgList(challengId) + + self.DynamicTable:SetTotalCount(#self.DataList) + if #self.DataList > 0 then + self.DynamicTable:ReloadDataASync(1) + else + self.DynamicTable:ReloadDataASync() + end +end + +--动态列表事件 +function XUiPanelRewardPreview:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.DataList[index] + grid:ResetData(data, self.RootUi) + end +end + +return XUiPanelRewardPreview \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArenaTeamRank/XUiPanelTeamRank.lua b/Resources/Scripts/XUi/XUiArenaTeamRank/XUiPanelTeamRank.lua new file mode 100644 index 00000000..627c4a77 --- /dev/null +++ b/Resources/Scripts/XUi/XUiArenaTeamRank/XUiPanelTeamRank.lua @@ -0,0 +1,83 @@ +local XUiPanelTeamRank = XClass(nil, "XUiPanelTeamRank") + +local XUiGridArenaTeamRank = require("XUi/XUiArenaTeamRank/ArenaTeamRankCommon/XUiGridArenaTeamRank") + +function XUiPanelTeamRank:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + + self.GridArenaTeamRank.gameObject:SetActive(false) + + self.IsShow = false + self.GameObject:SetActive(false) + + self.MyTeamRank = XUiGridArenaTeamRank.New(self.PanelArenaSelfTeamRank) + + self.DynamicTable = XDynamicTableNormal.New(self.SViewRank.transform) + self.DynamicTable:SetProxy(XUiGridArenaTeamRank) + self.DynamicTable:SetDelegate(self) +end + +function XUiPanelTeamRank:Show() + if self.IsShow then + return + end + + self.IsShow = true + self.GameObject:SetActive(true) + + XEventManager.AddEventListener(XEventId.EVENT_ARENA_REFRESH_TEAM_RANK_INFO, self.Refresh, self) + + self:Refresh() +end + +function XUiPanelTeamRank:Hide() + if not self.IsShow then + return + end + + self.IsShow = false + self.GameObject:SetActive(false) + + XEventManager.RemoveEventListener(XEventId.EVENT_ARENA_REFRESH_TEAM_RANK_INFO, self.Refresh, self) +end + +function XUiPanelTeamRank:Refresh() + if not self.GameObject:Exist() then + return + end + + local challengeCfg = XDataCenter.ArenaManager.GetTeamRankChallengeCfg() + if not challengeCfg then + return + end + local arenaCfg = XArenaConfigs.GetArenaLevelCfgByLevel(challengeCfg.ArenaLv) + + self.TxtArenaName.text = challengeCfg.Name + self.RImgArenaLevel:SetRawImage(arenaCfg.Icon) + self.TxtTime.text = XDataCenter.ArenaManager.GetArenaTeamRankTime() + self.TxtLevelRegion.text = challengeCfg.MinLv .. "-" .. challengeCfg.MaxLv + + local rank, totalRank, myTeamInfo = XDataCenter.ArenaManager.GetMyTeamRankAndData() + self.MyTeamRank:ResetData(rank, myTeamInfo, self.RootUi, totalRank) + + self.DataList = XDataCenter.ArenaManager.GetTeamRankList() or {} + self.DynamicTable:SetTotalCount(#self.DataList) + if #self.DataList > 0 then + self.DynamicTable:ReloadDataASync(1) + else + self.DynamicTable:ReloadDataASync() + end +end + +--动态列表事件 +function XUiPanelTeamRank:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.DataList[index] + grid:ResetData(index, data, self.RootUi) + end +end + +return XUiPanelTeamRank \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArenaWarZone/ArenaWarZoneCommon/XUiGridZone.lua b/Resources/Scripts/XUi/XUiArenaWarZone/ArenaWarZoneCommon/XUiGridZone.lua new file mode 100644 index 00000000..e895f2f4 --- /dev/null +++ b/Resources/Scripts/XUi/XUiArenaWarZone/ArenaWarZoneCommon/XUiGridZone.lua @@ -0,0 +1,102 @@ +local XUiGridZone = XClass(nil, "XUiGridZone") + +function XUiGridZone:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + self:AutoAddListener() + + self.LordList = {} + for i = 1, 3 do + table.insert(self.LordList, self["GridLord" .. i]) + end +end + +function XUiGridZone:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiGridZone:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiGridZone:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiGridZone:AutoAddListener() + self:RegisterClickEvent(self.BtnZone, self.OnBtnZoneClick) +end + +function XUiGridZone:OnBtnZoneClick() + if not self.AreaData then + XUiManager.TipError(CS.XTextManager.GetText("ArenaActivityAreaIsNotOpen")) + return + end + + if self.AreaData.Lock == 1 then + --解锁区域 + local areaStageCfg = XArenaConfigs.GetArenaAreaStageCfgByAreaId(self.AreaData.AreaId) + local remainCount = XDataCenter.ArenaManager.GetUnlockArenaAreaCount() + + local unlockStr = CS.XTextManager.GetText("ArenaActivityConfirmUnlockArea", areaStageCfg.Name, remainCount) + XUiManager.DialogTip(CS.XTextManager.GetText("TipTitle"), unlockStr, XUiManager.DialogType.Normal, nil, function() + XDataCenter.ArenaManager.RequestUnlockArea(self.AreaData.AreaId, function() + self:SetMetaData(self.AreaData.AreaId) + end) + end) + return + end + + -- 进入关卡界面 + XLuaUiManager.Open("UiArenaStage", self.AreaData.AreaId) +end + +function XUiGridZone:SetMetaData(areaId) + if not areaId then + -- 没有开启,就不显示 + self.GameObject:SetActive(false) + self.AreaData = nil + return + end + + self.AreaData = XDataCenter.ArenaManager.GetArenaAreaDataByAreaId(areaId) + local areaStageCfg = XArenaConfigs.GetArenaAreaStageCfgByAreaId(areaId) + + self.PanelClose.gameObject:SetActive(self.AreaData == nil) + self.PanelOpen.gameObject:SetActive(self.AreaData ~= nil) + + self.TxtName.text = areaStageCfg.Name + self.TxtOpenName.text = areaStageCfg.Name + self.TxtLockName.text = areaStageCfg.Name + + if not self.AreaData then + return + end + + self.TxtPoint.text = CS.XTextManager.GetText("ArenaActivityPoint", self.AreaData.Point) + self.PanelLock.gameObject:SetActive(self.AreaData.Lock == 1) + self.PanelUnlock.gameObject:SetActive(self.AreaData.Lock == 0) + + for i, grid in ipairs(self.LordList) do + local head = XUiHelper.TryGetComponent(grid, "Head") + local rank = XUiHelper.TryGetComponent(grid, "TxtRank", "Text") + + local info = self.AreaData.LordList[i] + if info then + rank.text = i + XUiPLayerHead.InitPortrait(info.CurrHeadPortraitId, info.CurrHeadFrameId, head) + else + rank.text = "" + XUiPLayerHead.Hide(head) + end + end +end + +return XUiGridZone \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiArenaWarZone/XUiArenaWarZone.lua b/Resources/Scripts/XUi/XUiArenaWarZone/XUiArenaWarZone.lua new file mode 100644 index 00000000..55068774 --- /dev/null +++ b/Resources/Scripts/XUi/XUiArenaWarZone/XUiArenaWarZone.lua @@ -0,0 +1,67 @@ +local XUiArenaWarZone = XLuaUiManager.Register(XLuaUi, "UiArenaWarZone") + +local XUiGridZone = require("XUi/XUiArenaWarZone/ArenaWarZoneCommon/XUiGridZone") + +function XUiArenaWarZone:OnAwake() + self:AutoAddListener() +end + + +function XUiArenaWarZone:OnStart() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + + self.GridList = {} + for i = 1, 5 do + local trans = self["GridZone" .. i] + local grid = XUiGridZone.New(trans, self) + table.insert(self.GridList, grid) + end +end + + +function XUiArenaWarZone:OnEnable() + XDataCenter.ArenaManager.RequestAreaData() + self:Refresh() +end + +function XUiArenaWarZone:OnGetEvents() + return { XEventId.EVENT_ARENA_REFRESH_AREA_INFO, XEventId.EVENT_ARENA_UNLOCK_AREA } +end + +function XUiArenaWarZone:OnNotify(evt) + if evt == XEventId.EVENT_ARENA_REFRESH_AREA_INFO then + self:Refresh() + elseif evt == XEventId.EVENT_ARENA_UNLOCK_AREA then + self:RefreshUnlockCount() + end +end + +function XUiArenaWarZone:AutoAddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:BindHelpBtn(self.BtnHelpCourse, "Arena") +end + +function XUiArenaWarZone:OnBtnBackClick() + self:Close() +end + +function XUiArenaWarZone:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiArenaWarZone:Refresh() + local point = XDataCenter.ArenaManager.GetArenaAreaTotalPoint() + self.TxtTotalPoint.text = point + self:RefreshUnlockCount() + + local challengeCfg = XDataCenter.ArenaManager.GetCurChallengeCfg() + for i, grid in ipairs(self.GridList) do + grid:SetMetaData(challengeCfg.AreaId[i]) + end +end + +function XUiArenaWarZone:RefreshUnlockCount() + local remainCount = XDataCenter.ArenaManager.GetUnlockArenaAreaCount() + self.TxtRemainUnlockTime.text = remainCount +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiAssign/UiAssignSelectOccupy.lua b/Resources/Scripts/XUi/XUiAssign/UiAssignSelectOccupy.lua new file mode 100644 index 00000000..16bf3fa7 --- /dev/null +++ b/Resources/Scripts/XUi/XUiAssign/UiAssignSelectOccupy.lua @@ -0,0 +1,142 @@ +local XUiAssignSelectOccupy = XLuaUiManager.Register(XLuaUi, "UiAssignSelectOccupy") + +local XUiGridAssignSelectOccupy = require("XUi/XUiAssign/XUiGridAssignSelectOccupy") + +function XUiAssignSelectOccupy:OnAwake() + self:InitComponent() +end + +function XUiAssignSelectOccupy:OnStart() +end + +function XUiAssignSelectOccupy:InitComponent() + self.BtnConfirm.CallBack = function() self:OnBtnConfirmClick() end + self.BtnUnselect.CallBack = function() self:OnBtnUnselectClick() end + CsXUiHelper.RegisterClickEvent(self.BtnClose, function() self:Close() end) + self.BtnCancel.CallBack = function() self:Close() end + self.BtnTanchuangClose.CallBack = function() self:Close() end + self.PanelNoCharacter.gameObject:SetActiveEx(false) + self.BtnUnselect.gameObject:SetActiveEx(false) + + self.CharacterGridList = {} + self.GridCharacter.gameObject:SetActiveEx(false) +end + +function XUiAssignSelectOccupy:OnGetEvents() + return { XEventId.EVENT_ASSIGN_SELECT_OCCUPY_BEGIN } +end + +function XUiAssignSelectOccupy:OnNotify(evt) + if evt == XEventId.EVENT_ASSIGN_SELECT_OCCUPY_BEGIN then + self:Refresh() + end +end + +function XUiAssignSelectOccupy:OnEnable() + -- 打开界面自动选中当前角色 + local chapterId = XDataCenter.FubenAssignManager.SelectChapterId + local chapterData = XDataCenter.FubenAssignManager.GetChapterDataById(chapterId) + XDataCenter.FubenAssignManager.SelectCharacterId = chapterData:GetCharacterId() + + self:Refresh() +end + +function XUiAssignSelectOccupy:OnDisable() +end + +function XUiAssignSelectOccupy:GetCharacterGrid(index) + local grid = self.CharacterGridList[index] + if not grid then + local obj = CS.UnityEngine.Object.Instantiate(self.GridCharacter) + obj.transform:SetParent(self.PanelCharacterContent, false) + grid = XUiGridAssignSelectOccupy.New(self, obj) + self.CharacterGridList[index] = grid + end + return grid +end + +function XUiAssignSelectOccupy:ResetCharacterGridList(len) + if #self.CharacterGridList > len then + for _ = len + 1, #self.CharacterGridList do + self.CharacterGridList.GameObject:SetActiveEx(false) + end + end +end + +function XUiAssignSelectOccupy:Refresh() + self.ChapterId = XDataCenter.FubenAssignManager.SelectChapterId + local chapterData = XDataCenter.FubenAssignManager.GetChapterDataById(self.ChapterId) + local selectCharacterId = XDataCenter.FubenAssignManager.SelectCharacterId + + self.IsSelected = (selectCharacterId and selectCharacterId ~= 0) + + -- 选择了当前的驻守成员 则下阵 + if self.IsSelected and selectCharacterId == chapterData:GetCharacterId() then + self.BtnUnselect.gameObject:SetActiveEx(true) + self.BtnConfirm.gameObject:SetActiveEx(false) + else + self.BtnUnselect.gameObject:SetActiveEx(false) + self.BtnConfirm.gameObject:SetActiveEx(true) + self.BtnConfirm:SetButtonState(self.IsSelected and CS.UiButtonState.Normal or CS.UiButtonState.Disable) + end + + local ownCharacters = XDataCenter.CharacterManager.GetOwnCharacterList() + + -- 排序 + -- 未占领>已占领>不可委派 战力>解放阶段>品质 + local tmpChapterData = XDataCenter.FubenAssignManager.GetChapterDataById(self.ChapterId) + local weights = {} -- 满足条件[1位] + 战力[6位] + 终解等级[1位] + 品质[1位] + local CheckCharacterInOccupy = XDataCenter.FubenAssignManager.CheckCharacterInOccupy + local GetCharacterAbility = XDataCenter.CharacterManager.GetCharacterAbility + local GetCharacterGrowUpLevel = XDataCenter.ExhibitionManager.GetCharacterGrowUpLevel + for _, character in ipairs(ownCharacters) do + local isInOccupy = CheckCharacterInOccupy(character.Id) + local isMatch = tmpChapterData:IsCharConditionMatch(character.Id) + local state = isMatch and (not isInOccupy and 3 or 2) or 1 + local ability = GetCharacterAbility(character) + local growUpLevel = GetCharacterGrowUpLevel(character.Id) + local weightState = state * 100000000 + local weightAbility = ability * 100 + local weightGrowUpLevel = growUpLevel * 10 + local weightQuality = character.Quality + weights[character.Id] = weightState + weightAbility + weightGrowUpLevel + weightQuality + -- XLog.Debug("Sort " .. XCharacterConfigs.GetCharacterTradeName(character.Id) .. ": " .. character.Id .. ", weight: " .. weights[character.Id], {"isInOccupy, isMatch, state, ability, growUpLevel", isInOccupy, isMatch, state, ability, growUpLevel}) + end + + table.sort(ownCharacters, function(a, b) + return weights[a.Id] > weights[b.Id] + end) + + self:ResetCharacterGridList(#ownCharacters) + for i, character in ipairs(ownCharacters) do + local grid = self:GetCharacterGrid(i) + grid.GameObject:SetActiveEx(true) + grid:Refresh(character, self.ChapterId) + end +end + +function XUiAssignSelectOccupy:OnBtnConfirmClick() + if not self.IsSelected then + return + end + local selectCharacterId = XDataCenter.FubenAssignManager.SelectCharacterId + local chapterData = XDataCenter.FubenAssignManager.GetChapterDataById(self.ChapterId) + chapterData:SetCharacterId(selectCharacterId) + XDataCenter.FubenAssignManager.AssignSetCharacterRequest(self.ChapterId, selectCharacterId, function() + self:Close() + CsXGameEventManager.Instance:Notify(XEventId.EVENT_ASSIGN_SELECT_OCCUPY_END) -- 刷新驻守界面 + XUiManager.TipMsg(CS.XTextManager.GetText("AssignOccupySelected")) -- 驻守成功 + end) +end + +function XUiAssignSelectOccupy:OnBtnUnselectClick() + local selectCharacterId = 0 + XDataCenter.FubenAssignManager.SelectCharacterId = selectCharacterId + local chapterData = XDataCenter.FubenAssignManager.GetChapterDataById(self.ChapterId) + chapterData:SetCharacterId(selectCharacterId) + XDataCenter.FubenAssignManager.AssignSetCharacterRequest(self.ChapterId, selectCharacterId, function() + self:Close() + CsXGameEventManager.Instance:Notify(XEventId.EVENT_ASSIGN_SELECT_OCCUPY_END) -- 刷新驻守界面 + XUiManager.TipMsg(CS.XTextManager.GetText("AssignOccupyUnselected")) -- 下阵成功 + end) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiAssign/XUiAssignBuff.lua b/Resources/Scripts/XUi/XUiAssign/XUiAssignBuff.lua new file mode 100644 index 00000000..8828c2e4 --- /dev/null +++ b/Resources/Scripts/XUi/XUiAssign/XUiAssignBuff.lua @@ -0,0 +1,73 @@ +local XUiAssignBuff = XLuaUiManager.Register(XLuaUi, "UiAssignBuff") + +local XUiAssignBuffPart = require("XUi/XUiAssign/XUiAssignBuffPart") +local XUiAssignBuffAll = require("XUi/XUiAssign/XUiAssignBuffAll") + +local INDEX_PART = 1 +local INDEX_ALL = 2 + +function XUiAssignBuff:OnAwake() + self:InitComponent() +end + +function XUiAssignBuff:OnStart() +end + +function XUiAssignBuff:OnEnable() + self:Refresh() +end + +function XUiAssignBuff:OnDisable() + XDataCenter.FubenAssignManager.SelectChapterId = nil +end + +function XUiAssignBuff:InitComponent() + -- self.BtnClose.CallBack = function() self:Close() end -- 点击背景关闭 + self.BtnTanchuangClose.CallBack = function() self:Close() end + + self.ImgEmpty.gameObject:SetActiveEx(false) + + + local tags = { self.BtnTab01, self.BtnTab02 } + self.PanelTag:Init(tags, function(index) self:PageTurn(index) end) + + self.PanelPart = XUiAssignBuffPart.New(self, self.PanelPart) + self.PanelPart:Close() + + self.PanelAll = XUiAssignBuffAll.New(self, self.PanelAll) + self.PanelAll:Close() +end + +function XUiAssignBuff:OnGetEvents() + return { XEventId.EVENT_ASSIGN_SELECT_OCCUPY_END } +end + +function XUiAssignBuff:OnNotify(evt) + if evt == XEventId.EVENT_ASSIGN_SELECT_OCCUPY_END then + self:OnOccupySelected() + end +end + +function XUiAssignBuff:Refresh() + self.PanelTag:SelectIndex(INDEX_PART, true) +end + +function XUiAssignBuff:PageTurn(index) + local hasList = false + if index == INDEX_PART then + hasList = self.PanelPart:Show() + self.PanelAll:Close() + elseif index == INDEX_ALL then + hasList = self.PanelAll:Show() + self.PanelPart:Close() + end + self.ImgEmpty.gameObject:SetActiveEx(not hasList) +end + +function XUiAssignBuff:OnOccupySelected() + local chapterId = XDataCenter.FubenAssignManager.SelectChapterId + local characterId = XDataCenter.FubenAssignManager.SelectCharacterId + local chapterData = XDataCenter.FubenAssignManager.GetChapterDataById(chapterId) + chapterData:SetCharacterId(characterId) + self:Refresh() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiAssign/XUiAssignBuffAll.lua b/Resources/Scripts/XUi/XUiAssign/XUiAssignBuffAll.lua new file mode 100644 index 00000000..ca0ab6cc --- /dev/null +++ b/Resources/Scripts/XUi/XUiAssign/XUiAssignBuffAll.lua @@ -0,0 +1,54 @@ +local XUiAssignBuffAll = XClass(nil, "XUiAssignBuffAll") + +function XUiAssignBuffAll:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + self:InitComponent() +end + +function XUiAssignBuffAll:InitComponent() + self.SelectTxtBuff.gameObject:SetActiveEx(false) + self.BuffTextList = {} +end + +function XUiAssignBuffAll:Show() + self.GameObject:SetActiveEx(true) + return self:Refresh() +end + +function XUiAssignBuffAll:Close() + self.GameObject:SetActiveEx(false) +end + +function XUiAssignBuffAll:GetBuffText(index) + local txt = self.BuffTextList[index] + if not txt then + txt = CS.UnityEngine.Object.Instantiate(self.SelectTxtBuff) + txt.transform:SetParent(self.PanelOccupyBuff, false) + self.BuffTextList[index] = txt + end + return txt +end + +function XUiAssignBuffAll:ResetBuffTextList(len) + if #self.BuffTextList > len then + for i = len + 1, #self.BuffTextList do + self.BuffTextList[i].gameObject:SetActiveEx(false) + end + end +end + +function XUiAssignBuffAll:Refresh() + local buffList = XDataCenter.FubenAssignManager.GetAllBuffList() + self:ResetBuffTextList(#buffList) + for i, buffDesc in ipairs(buffList) do + local txt = self:GetBuffText(i) + txt.gameObject:SetActiveEx(true) + txt.text = buffDesc + end + return (#buffList > 0) +end + +return XUiAssignBuffAll \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiAssign/XUiAssignBuffPart.lua b/Resources/Scripts/XUi/XUiAssign/XUiAssignBuffPart.lua new file mode 100644 index 00000000..b313ee13 --- /dev/null +++ b/Resources/Scripts/XUi/XUiAssign/XUiAssignBuffPart.lua @@ -0,0 +1,46 @@ +local XUiAssignBuffPart = XClass(nil, "XUiAssignBuffPart") + +local XUiGridAssignBuffPart = require("XUi/XUiAssign/XUiGridAssignBuffPart") + +function XUiAssignBuffPart:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + self:InitComponent() +end + +function XUiAssignBuffPart:InitComponent() + self.GridBuff.gameObject:SetActiveEx(false) + self.DynamicTable = XDynamicTableNormal.New(self.PanelBufftList) + self.DynamicTable:SetProxy(XUiGridAssignBuffPart) + self.DynamicTable:SetDelegate(self) +end + +function XUiAssignBuffPart:Show() + self.GameObject:SetActiveEx(true) + return self:Refresh() +end + +function XUiAssignBuffPart:Close() + self.GameObject:SetActiveEx(false) +end + +--动态列表事件 +function XUiAssignBuffPart:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT or event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local chapterId = self.ListData[index] + grid:Refresh(chapterId) + end +end + +--设置动态列表 +function XUiAssignBuffPart:Refresh() + --刷新数据 + self.ListData = XDataCenter.FubenAssignManager.GetUnlockChapterIdList() + self.DynamicTable:SetDataSource(self.ListData) + self.DynamicTable:ReloadDataASync() + return (#self.ListData > 0) +end + +return XUiAssignBuffPart \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiAssign/XUiAssignDeploy.lua b/Resources/Scripts/XUi/XUiAssign/XUiAssignDeploy.lua new file mode 100644 index 00000000..3b0f3747 --- /dev/null +++ b/Resources/Scripts/XUi/XUiAssign/XUiAssignDeploy.lua @@ -0,0 +1,124 @@ +local XUiAssignDeploy = XLuaUiManager.Register(XLuaUi, "UiAssignDeploy") + +local table = table +local ipairs = ipairs + +local XUiGridAssignDeployTeam = require("XUi/XUiAssign/XUiGridAssignDeployTeam") +local XUiPanelAssignFormation = require("XUi/XUiAssign/XUiPanelAssignFormation") + +function XUiAssignDeploy:OnAwake() + self:InitComponent() +end + +function XUiAssignDeploy:OnStart() + self.GroupId = XDataCenter.FubenAssignManager.SelectGroupId + self.ChapterId = XDataCenter.FubenAssignManager.SelectChapterId + self:InitGroupInfo() +end + +function XUiAssignDeploy:OnEnable() + self.GroupId = XDataCenter.FubenAssignManager.SelectGroupId + self.ChapterId = XDataCenter.FubenAssignManager.SelectChapterId + self:Refresh() +end + +function XUiAssignDeploy:InitComponent() + self.FormationPanel = XUiPanelAssignFormation.New(self, self.PanelFormation) + self.FormationPanel:Close() + self.GridDeployTeam.gameObject:SetActiveEx(false) + -- self.PanelDanger + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self.BtnAutoTeam.CallBack = function() self:OnBtnAutoTeamClick() end + self.BtnFight.CallBack = function() self:OnBtnFightClick() end + self.BtnFormation.CallBack = function() self:OnBtnFormationClick() end + self.BtnFormation:SetButtonState(XUiButtonState.Disable) +end + +function XUiAssignDeploy:OnGetEvents() + return { XEventId.EVENT_FUBEN_ASSIGN_FORMATION_CONFIRM, XEventId.EVENT_ON_ASSIGN_TEAM_CHANGED, XEventId.EVENT_ASSIGN_REFRESH_FORMATION } +end + +--事件监听 +function XUiAssignDeploy:OnNotify(evt) + if evt == XEventId.EVENT_FUBEN_ASSIGN_FORMATION_CONFIRM then + self:OnFormationConfirm() + elseif evt == XEventId.EVENT_ON_ASSIGN_TEAM_CHANGED then + self:Refresh() + elseif evt == XEventId.EVENT_ASSIGN_REFRESH_FORMATION then + self.FormationPanel:RefreshForAnim() + end +end + +function XUiAssignDeploy:InitGroupInfo() + local data = XDataCenter.FubenAssignManager.GetGroupDataById(self.GroupId) + self.TeamGridList = {} + self.ListData = data:GetTeamInfoId() + self.StageListData = data:GetStageId() + for _, _ in ipairs(self.ListData) do + local ui = CS.UnityEngine.Object.Instantiate(self.GridDeployTeam) + ui.transform:SetParent(self.PanelTeamContent, false) + ui.gameObject:SetActiveEx(true) + local grid = XUiGridAssignDeployTeam.New(self, ui) + table.insert(self.TeamGridList, grid) + end +end + + +function XUiAssignDeploy:Refresh() + local memberCount = XDataCenter.FubenAssignManager.GetGroupMemberCount(self.GroupId) + self.BtnFormation.gameObject:SetActiveEx(memberCount > 0) + self.BtnFormation:SetButtonState(XUiButtonState.Normal) + + for i, grid in ipairs(self.TeamGridList) do + if self.ListData[i] then + grid.GameObject:SetActiveEx(true) + grid:Refresh(self.GroupId, i, self.ListData[i]) + else + grid.GameObject:SetActiveEx(false) + end + end +end + +function XUiAssignDeploy:OnBtnFightClick() + -- --检查挑战次数 + -- local groupData = XDataCenter.FubenAssignManager.GetGroupDataById(self.GroupId) + -- if groupData:GetFightCount() >= groupData:GetMaxFightCount() then + -- XUiManager.TipMsg(CS.XTextManager.GetText("FubenChallengeCountNotEnough")) + -- return + -- end + -- 检查队伍 + local allTeamHasMember, teamCharList, captainPosList, firstFightPosList = XDataCenter.FubenAssignManager.TryGetFightTeamCharList(self.GroupId) + if not allTeamHasMember then + XUiManager.TipMsg(CS.XTextManager.GetText("AssignFightNoMember")) + return + end + + -- 设置队伍 + XDataCenter.FubenAssignManager.AssignSetTeamRequest(self.GroupId, teamCharList, captainPosList, firstFightPosList, function() + self:Close() + -- 打开战斗前loading界面 + XLuaUiManager.Open("UiAssignInfo", self.ChapterId, self.GroupId, teamCharList, captainPosList, firstFightPosList) + end) +end + +function XUiAssignDeploy:OnBtnFormationClick() + self.FormationPanel:Show(self.GroupId) +end + +function XUiAssignDeploy:OnBtnAutoTeamClick() + XDataCenter.FubenAssignManager.AutoTeam(self.GroupId) + self:Refresh() +end + +function XUiAssignDeploy:OnBtnBackClick() + self:Close() +end + +function XUiAssignDeploy:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiAssignDeploy:OnFormationConfirm() + self:Refresh() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiAssign/XUiAssignInfo.lua b/Resources/Scripts/XUi/XUiAssign/XUiAssignInfo.lua new file mode 100644 index 00000000..ae6c6c89 --- /dev/null +++ b/Resources/Scripts/XUi/XUiAssign/XUiAssignInfo.lua @@ -0,0 +1,179 @@ +local XUiAssignInfo = XLuaUiManager.Register(XLuaUi, "UiAssignInfo") + +local ANIMATION_OPEN = { + "Began1", + "Began2", + "Began3", + "Began4", +} + +local ANIMATION_LOOP = { + "Loop1", + "Loop2", + "Loop3", + "Loop4", +} + +local ANIMATION_PANEL = { + "PanelStageList01", + "PanelStageList02", + "PanelStageList03", + "PanelStageList04", +} +local MAX_MEMBER_INDEX = 3 + +function XUiAssignInfo:OnAwake() + self:InitComponent() +end + +function XUiAssignInfo:OnDestroy() + XDataCenter.FubenAssignManager.SetCloseLoadingCb(nil) + XDataCenter.FubenAssignManager.SetFinishFightCb(nil) +end + +function XUiAssignInfo:OnStart(chapterId, groupId, teamCharIdList, captainPosList, firstFightPosList) + self:Refresh(chapterId, groupId, teamCharIdList, captainPosList, firstFightPosList) +end + +function XUiAssignInfo:InitComponent() + -- self.SafeAreaContentPane = self.Transform:Find("SafeAreaContentPane") + -- self.FullScreenBackground = self.Transform:Find("FullScreenBackground") + self.TxtZhangjie.gameObject:SetActiveEx(false) + self.PlayOpenAnimationCB = function() self:PlayLoopAnimation() end + for _, objName in ipairs(ANIMATION_LOOP) do + self[objName].gameObject:SetActiveEx(false) + end +end + +function XUiAssignInfo:OnGetEvents() + return { CS.XEventId.EVENT_FIGHT_FORCE_EXIT, XEventId.EVENT_FUBEN_SETTLE_FAIL } +end + +function XUiAssignInfo:OnNotify(evt) + if evt == CS.XEventId.EVENT_FIGHT_FORCE_EXIT or evt == XEventId.EVENT_FUBEN_SETTLE_FAIL then + self:Close() + end +end + +function XUiAssignInfo:LoadingEnd() + XDataCenter.FubenAssignManager.SetCloseLoadingCb(nil) + XDataCenter.FubenAssignManager.SetFinishFightCb(nil) + self:Close() +end + +function XUiAssignInfo:Refresh(chapterId, groupId, teamCharIdList, captainPosList, firstFightPosList) + self.ChapterId = chapterId + self.GroupId = groupId + self.CurIndex = 1 + + -- local chapterData = XDataCenter.FubenAssignManager.GetChapterDataById(chapterId) + local groupData = XDataCenter.FubenAssignManager.GetGroupDataById(self.GroupId) + local stageIdList = groupData:GetStageId() + local maxIndex = #stageIdList + + -- self.TxtZhangjie.text = chapterData:GetName() + self.TxtGroupName.text = groupData:GetName() + + local updateStageInfofunc = function() + if self.CurIndex > maxIndex then + self:LoadingEnd() + return + end + self.FullScreenBackground.gameObject:SetActiveEx(false) + self.SafeAreaContentPane.gameObject:SetActiveEx(false) + + local stageId = stageIdList[self.CurIndex] + local charIdList = teamCharIdList[self.CurIndex] + local captainPos = captainPosList[self.CurIndex] + local firstFightPos = firstFightPosList[self.CurIndex] + + local startCb = function() + self.FullScreenBackground.gameObject:SetActiveEx(true) + self.SafeAreaContentPane.gameObject:SetActiveEx(true) + self.TxtName.text = CS.XTextManager.GetText("AssignInfoTeamName", self.CurIndex) + self:UpdateAnimationNode() + self:PlayBeginAnimation() + self:UpdateTeamMembers(charIdList) + end + local errorCb = function() + self:LoadingEnd() + end + + XDataCenter.FubenManager.EnterAssignFight(stageId, charIdList, captainPos, startCb, errorCb, firstFightPos) + end + + XDataCenter.FubenAssignManager.SetCloseLoadingCb(function() + self.FullScreenBackground.gameObject:SetActiveEx(false) + self.SafeAreaContentPane.gameObject:SetActiveEx(false) + end) + + XDataCenter.FubenAssignManager.SetFinishFightCb(function(result) + if not result then + self:LoadingEnd() + else + self.CurIndex = self.CurIndex + 1 + updateStageInfofunc() + end + end) + + updateStageInfofunc() +end + +function XUiAssignInfo:UpdateTeamMembers(charIdList) + local count = #charIdList + if count <= 0 then + self.GridTeam.gameObject:SetActiveEx(false) + return + end + + for index = 1, MAX_MEMBER_INDEX do + local order = XDataCenter.FubenAssignManager.GetMemberOrderByIndex(index, count) + self:AddTeamMember(order, charIdList[index]) + end +end + +function XUiAssignInfo:AddTeamMember(order, charId) + if charId and charId > 0 then + self["RImgCharIcon" .. order]:SetRawImage(XDataCenter.CharacterManager.GetCharBigRoundnessNotItemHeadIcon(charId)) + self["PanelCharIcon" .. order].gameObject:SetActiveEx(true) + else + self["PanelCharIcon" .. order].gameObject:SetActiveEx(false) + end +end + +function XUiAssignInfo:UpdateAnimationNode() + for k, v in pairs(ANIMATION_PANEL) do + if k == self.CurIndex then + self[v].gameObject:SetActiveEx(true) + else + self[v].gameObject:SetActiveEx(false) + end + end + + local groupData = XDataCenter.FubenAssignManager.GetGroupDataById(self.GroupId) + local stageIdList = groupData:GetStageId() + for i = #stageIdList + 2, 4 do + local gridBfrtStage = XUiHelper.TryGetComponent(self[ANIMATION_PANEL[self.CurIndex]], "GridBfrtStage" .. i, nil) + if gridBfrtStage then gridBfrtStage.gameObject:SetActiveEx(false) end + end +end + +function XUiAssignInfo:PlayBeginAnimation() + if not ANIMATION_OPEN[self.CurIndex] then + self.PlayOpenAnimationCB() + return + end + self:PlayAnimation(ANIMATION_OPEN[self.CurIndex], self.PlayOpenAnimationCB) +end + +function XUiAssignInfo:PlayLoopAnimation() + -- TimeLine组件会重置PlayMode为Holde,不能循环播放,改用SetActive方式 + for i, objName in ipairs(ANIMATION_LOOP) do + self[objName].gameObject:SetActiveEx(i == self.CurIndex) + end + -- if not ANIMATION_OPEN[self.CurIndex] then + -- self.PlayLoopAnimationCB() + -- return + -- end + -- self:PlayAnimation(ANIMATION_LOOP[self.CurIndex], self.PlayLoopAnimationCB) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiAssign/XUiAssignOccupy.lua b/Resources/Scripts/XUi/XUiAssign/XUiAssignOccupy.lua new file mode 100644 index 00000000..76d28f17 --- /dev/null +++ b/Resources/Scripts/XUi/XUiAssign/XUiAssignOccupy.lua @@ -0,0 +1,113 @@ +local XUiAssignOccupy = XLuaUiManager.Register(XLuaUi, "UiAssignOccupy") + +local XUiGridAssignBuffText = require("XUi/XUiAssign/XUiGridAssignBuffText") + +function XUiAssignOccupy:OnAwake() + self:InitComponent() +end + +function XUiAssignOccupy:OnStart() +end + +function XUiAssignOccupy:OnEnable() + self.ChapterId = XDataCenter.FubenAssignManager.SelectChapterId + self:Refresh() +end + + +function XUiAssignOccupy:OnGetEvents() + return { XEventId.EVENT_ASSIGN_SELECT_OCCUPY_END } +end + +function XUiAssignOccupy:OnNotify(evt) + if evt == XEventId.EVENT_ASSIGN_SELECT_OCCUPY_END then + self:Refresh() + end +end + +function XUiAssignOccupy:InitComponent() + self.BuffTextGridList = {} + self.GridOccupyBuff.gameObject:SetActiveEx(false) + + self.ConditionTxtList = {} + self.TxtCondition.gameObject:SetActiveEx(false) + for i = 1, XDataCenter.FubenAssignManager.MaxSelectConditionNum do + local txt = CS.UnityEngine.Object.Instantiate(self.TxtCondition) + txt.transform:SetParent(self.PanelCondition, false) + self.ConditionTxtList[i] = txt + end + + self.RawImage.gameObject:SetActiveEx(false) + self.Image_Add.gameObject:SetActiveEx(false) + self.Text_Hint.gameObject:SetActiveEx(false) + + self:RegisterClickEvent(self.BtnTanchuangClose, self.OnBtnTangchuangCloseClick) + self:RegisterClickEvent(self.BtnClose, self.OnBtnCloseClick) + self:RegisterClickEvent(self.BtnOccupy, self.OnBtnOccupyClick) +end + +function XUiAssignOccupy:GetBuffTextGrid(index) + local grid = self.BuffTextGridList[index] + if not grid then + local obj = CS.UnityEngine.Object.Instantiate(self.GridOccupyBuff) + obj.transform:SetParent(self.PanelOccupyBuff, false) + grid = XUiGridAssignBuffText.New(obj) + self.BuffTextGridList[index] = grid + end + return grid +end + +function XUiAssignOccupy:ResetBuffTextList(len) + if #self.BuffTextGridList > len then + for i = len + 1, #self.BuffTextGridList do + self.BuffTextGridList[i].GameObject:SetActiveEx(false) + end + end +end + +function XUiAssignOccupy:Refresh() + local chapterData = XDataCenter.FubenAssignManager.GetChapterDataById(self.ChapterId) + local isOccupy = chapterData:IsOccupy() + if isOccupy then + self.Image_Add.gameObject:SetActiveEx(false) + self.RawImage:SetRawImage(chapterData:GetCharacterBodyIcon()) + self.RawImage.gameObject:SetActiveEx(true) + self.Text_Hint.gameObject:SetActiveEx(true) + else + self.Image_Add.gameObject:SetActiveEx(true) + self.RawImage.gameObject:SetActiveEx(false) + self.Text_Hint.gameObject:SetActiveEx(false) + end + + local selectConditions = chapterData:GetSelectCharCondition() + for i, txt in ipairs(self.ConditionTxtList) do + local conditionId = selectConditions[i] + if conditionId then + txt.gameObject:SetActiveEx(true) + -- txt.color = XDataCenter.FubenAssignManager.SelectConditionColor[(XConditionManager.CheckCondition(conditionId))] + txt.text = XConditionManager.GetConditionTemplate(conditionId).Desc + else + txt.gameObject:SetActiveEx(false) + end + end + + local buffList = chapterData:GetBuffDescList() + self:ResetBuffTextList(#buffList) + for i, buffDesc in ipairs(buffList) do + local grid = self:GetBuffTextGrid(i) + grid.GameObject:SetActiveEx(true) + grid:Refresh(buffDesc, isOccupy) + end +end + +function XUiAssignOccupy:OnBtnTangchuangCloseClick() + self:Close() +end + +function XUiAssignOccupy:OnBtnCloseClick() + self:Close() +end + +function XUiAssignOccupy:OnBtnOccupyClick() + XLuaUiManager.Open("UiAssignSelectOccupy") +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiAssign/XUiAssignPostWarCount.lua b/Resources/Scripts/XUi/XUiAssign/XUiAssignPostWarCount.lua new file mode 100644 index 00000000..bce7dccd --- /dev/null +++ b/Resources/Scripts/XUi/XUiAssign/XUiAssignPostWarCount.lua @@ -0,0 +1,95 @@ +local ipairs = ipairs +local XUiGridTeamInfoExp = require("XUi/XUiAssign/XUiGridTeamInfoExp") +local XUiAssignPostWarCount = XLuaUiManager.Register(XLuaUi, "UiAssignPostWarCount") +local ANIMATION_OPEN = "AniBfrtPostWarCountBegin" + +function XUiAssignPostWarCount:OnAwake() + self:InitComponent() +end + +function XUiAssignPostWarCount:OnStart(data) + self:ResetDataInfo() + self:UpdateDataInfo(data) + self:PlayAnimation(ANIMATION_OPEN) +end + +function XUiAssignPostWarCount:InitComponent() + self:RegisterClickEvent(self.BtnExit, self.OnBtnExitClick) + self:RegisterClickEvent(self.BtnClose, self.OnBtnCloseClick) + + self.GridEchelonExp.gameObject:SetActive(false) + self.GridReward.gameObject:SetActive(false) + self.GridEchelonExp.gameObject:SetActive(false) +end + +function XUiAssignPostWarCount:OnNotify(evt, ...) + local args = { ... } + if evt == CS.XEventId.EVENT_UI_ALLOWOPERATE and args[1] == self.Ui then + XDataCenter.FunctionEventManager.UnLockFunctionEvent() + end +end + +function XUiAssignPostWarCount:OnGetEvents() + return { CS.XEventId.EVENT_UI_ALLOWOPERATE } +end + +function XUiAssignPostWarCount:ResetDataInfo() + self.RewardGoodsList = {} + self.GroupId = nil +end + +function XUiAssignPostWarCount:UpdateDataInfo(data) + self.RewardGoodsList = data.RewardGoodsList + self.GroupId = XDataCenter.FubenAssignManager.GetGroupIdByStageId(data.StageId) + + self:UpdatePanelRewardContent() + self:UpdatePanelEchelonExpContent() + self:UpdatePanelPlayer() +end + + +function XUiAssignPostWarCount:OnBtnExitClick() + self:Close() +end + +function XUiAssignPostWarCount:OnBtnCloseClick() + self:Close() +end + +function XUiAssignPostWarCount:UpdatePanelRewardContent() + local rewards = XRewardManager.MergeAndSortRewardGoodsList(self.RewardGoodsList) + for _, item in ipairs(rewards) do + local ui = CS.UnityEngine.Object.Instantiate(self.GridReward) + local grid = XUiGridCommon.New(self, ui) + grid.Transform:SetParent(self.PanelRewardContent, false) + grid:Refresh(item, nil, nil, true) + grid.GameObject:SetActive(true) + end +end + +function XUiAssignPostWarCount:UpdatePanelEchelonExpContent() + local groupData = XDataCenter.FubenAssignManager.GetGroupDataById(self.GroupId) + local baseStageId = groupData:GetBaseStageId() + + for index, teamInfoId in ipairs(groupData:GetTeamInfoId()) do + local ui = CS.UnityEngine.Object.Instantiate(self.GridEchelonExp) + local grid = XUiGridTeamInfoExp.New(self, ui, baseStageId, index, teamInfoId) + grid.Transform:SetParent(self.PanelEchelonExpContent, false) + grid.GameObject:SetActive(true) + end +end + +function XUiAssignPostWarCount:UpdatePanelPlayer() + local groupData = XDataCenter.FubenAssignManager.GetGroupDataById(self.GroupId) + local curLevel = XPlayer.GetLevelOrHonorLevel() + local curExp = XPlayer.Exp + local maxExp = XPlayer.GetMaxExp() + local baseStageCfg = XDataCenter.FubenManager.GetStageCfg(groupData:GetBaseStageId()) + + self.TxtLevel.text = curLevel + if XPlayer.IsHonorLevelOpen() then + self.TxtLevelName.text = CS.XTextManager.GetText("HonorLevel") + end + self.TxtAddExp.text = "+ " .. baseStageCfg.TeamExp + self.ImgExp.fillAmount = curExp / maxExp +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiAssign/XUiAssignRoomCharacter.lua b/Resources/Scripts/XUi/XUiAssign/XUiAssignRoomCharacter.lua new file mode 100644 index 00000000..fd6291b8 --- /dev/null +++ b/Resources/Scripts/XUi/XUiAssign/XUiAssignRoomCharacter.lua @@ -0,0 +1,625 @@ +local CSXTextManagerGetText = CS.XTextManager.GetText + +local TabBtnIndex = { + Normal = 1, + Isomer = 2, +} +local CharacterTypeConvert = { + [TabBtnIndex.Normal] = XCharacterConfigs.CharacterType.Normal, + [TabBtnIndex.Isomer] = XCharacterConfigs.CharacterType.Isomer, +} +local TabBtnIndexConvert = { + [XCharacterConfigs.CharacterType.Normal] = TabBtnIndex.Normal, + [XCharacterConfigs.CharacterType.Isomer] = TabBtnIndex.Isomer, +} + +local XUiAssignRoomCharacter = XLuaUiManager.Register(XLuaUi, "UiAssignRoomCharacter") + +function XUiAssignRoomCharacter:OnAwake() + self:InitComponent() + + self.GridIndex = {} + self.TagCacheDic = {} + self.SortFunction = {} + self.SortFunction[XRoomCharFilterTipsConfigs.EnumSortTag.Default] = function(leftCharacter, rightCharacter) + local leftInTeam = self:IsInTeam(leftCharacter.Id) + local leftLevel = leftCharacter.Level + local leftQuality = leftCharacter.Quality + local leftPriority = XCharacterConfigs.GetCharacterPriority(leftCharacter.Id) + + local rightInTeam = self:IsInTeam(rightCharacter.Id) + local rightLevel = rightCharacter.Level + local rightQuality = rightCharacter.Quality + local rightPriority = XCharacterConfigs.GetCharacterPriority(rightCharacter.Id) + + if leftInTeam ~= rightInTeam then + return rightInTeam + end + + if leftLevel ~= rightLevel then + return leftLevel > rightLevel + end + + if leftQuality ~= rightQuality then + return leftQuality > rightQuality + end + + return leftPriority < rightPriority + end + self.SortFunction[XRoomCharFilterTipsConfigs.EnumSortTag.Quality] = function(leftCharacter, rightCharacter) + local leftQuality = leftCharacter.Quality + local rightQuality = rightCharacter.Quality + if leftQuality ~= rightQuality then + return leftQuality > rightQuality + end + return self.SortFunction[XRoomCharFilterTipsConfigs.EnumSortTag.Default](leftCharacter, rightCharacter) + end + self.SortFunction[XRoomCharFilterTipsConfigs.EnumSortTag.Level] = function(leftCharacter, rightCharacter) + local leftLevel = leftCharacter.Level + local rightLevel = rightCharacter.Level + if leftLevel ~= rightLevel then + return leftLevel > rightLevel + end + return self.SortFunction[XRoomCharFilterTipsConfigs.EnumSortTag.Default](leftCharacter, rightCharacter) + end + self.SortFunction[XRoomCharFilterTipsConfigs.EnumSortTag.Ability] = function(leftCharacter, rightCharacter) + local leftAbility = leftCharacter.Ability + local rightAbility = rightCharacter.Ability + if leftAbility ~= rightAbility then + return leftAbility > rightAbility + end + return self.SortFunction[XRoomCharFilterTipsConfigs.EnumSortTag.Default](leftCharacter, rightCharacter) + end +end + +-- teamCharIdMap, teamSelectPos, cb, canQuitCharIdMap, teamOrderCharIdMap, ablityRequire, curTeamOrder +function XUiAssignRoomCharacter:OnStart(teamCharIdMap, teamSelectPos, cb, teamOrderCharIdMap, canQuitCharIdMap, ablityRequire, curTeamOrder, characterLimitType, limitBuffId, teamId) + self.CharacterGrids = {} + + self.TeamCharIdMap = teamCharIdMap + self.TeamSelectPos = teamSelectPos + self.TeamResultCb = cb + self.TeamOrderCharIdMap = teamOrderCharIdMap + self.CanQuitCharIdMap = canQuitCharIdMap + self.CurTeamOrder = curTeamOrder + self.CharacterLimitType = characterLimitType or XFubenConfigs.CharacterLimitType.All + self.LimitBuffId = limitBuffId + self.TeamId = teamId + + self.TxtTeamInfoName.text = CS.XTextManager.GetText("AssignTeamTitle", self.CurTeamOrder) -- 作战梯队{0} + self.TxtRequireAbility.text = ablityRequire and ablityRequire or "" + + self:InitRequireCharacterInfo() + self:InitCharacterTypeBtns() +end + +function XUiAssignRoomCharacter:OnEnable() + CS.XGraphicManager.UseUiLightDir = true + self:UpdateInfo() +end + +function XUiAssignRoomCharacter:OnDisable() + CS.XGraphicManager.UseUiLightDir = false +end + +function XUiAssignRoomCharacter:InitRequireCharacterInfo() + local characterLimitType = self.CharacterLimitType + + if not XFubenConfigs.IsStageCharacterLimitConfigExist(characterLimitType) then + self.PanelRequireCharacter.gameObject:SetActiveEx(false) + return + else + self.PanelRequireCharacter.gameObject:SetActiveEx(true) + end + + local icon = XFubenConfigs.GetStageCharacterLimitImageTeamEdit(characterLimitType) + self.ImgRequireCharacter:SetSprite(icon) +end + +function XUiAssignRoomCharacter:RefreshCharacterTypeTips() + local limitBuffId = self.LimitBuffId + local characterType = CharacterTypeConvert[self.SelectTabBtnIndex] + local characterLimitType = self.CharacterLimitType + local text = XFubenConfigs.GetStageCharacterLimitTextSelectCharacter(characterLimitType, characterType, limitBuffId) + self.TxtRequireCharacter.text = text +end + +function XUiAssignRoomCharacter:ResetTeamData() + local teamId = self.TeamId + for k, characterId in pairs(self.TeamCharIdMap) do + if XDataCenter.FubenAssignManager.IsCharacterInTeamById(teamId, characterId) then + self.TeamCharIdMap[k] = 0 + end + end +end + +function XUiAssignRoomCharacter:InitCharacterTypeBtns() + self.BtnTabShougezhe.gameObject:SetActiveEx(not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.Isomer)) + + local tabBtns = { self.BtnTabGouzaoti, self.BtnTabShougezhe } + self.PanelCharacterTypeBtns:Init(tabBtns, function(index) self:TrySelectCharacterType(index) end) + + local characterLimitType = self.CharacterLimitType + local lockGouzaoti = characterLimitType == XFubenConfigs.CharacterLimitType.Isomer + local lockShougezhe = not XFunctionManager.JudgeOpen(XFunctionManager.FunctionName.Isomer) or characterLimitType == XFubenConfigs.CharacterLimitType.Normal + self.BtnTabGouzaoti:SetDisable(lockGouzaoti) + self.BtnTabShougezhe:SetDisable(lockShougezhe) + + --检查选择角色类型是否和副本限制类型冲突 + local characterType = XDataCenter.FubenManager.GetDefaultCharacterTypeByCharacterLimitType(self.CharacterLimitType) + local tempCharacterType = self:GetTeamCharacterType() + if tempCharacterType and not (tempCharacterType == XCharacterConfigs.CharacterType.Normal and lockGouzaoti + or tempCharacterType == XCharacterConfigs.CharacterType.Isomer and lockShougezhe) then + characterType = tempCharacterType + end + self.PanelCharacterTypeBtns:SelectIndex(TabBtnIndexConvert[characterType]) +end + +function XUiAssignRoomCharacter:TrySelectCharacterType(index) + local characterType = CharacterTypeConvert[index] + if characterType == XCharacterConfigs.CharacterType.Isomer and not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.Isomer) then return end + + local characterLimitType = self.CharacterLimitType + if characterLimitType == XFubenConfigs.CharacterLimitType.Normal then + if characterType == XCharacterConfigs.CharacterType.Isomer then + XUiManager.TipText("TeamSelectCharacterTypeLimitTipNormal") + return + end + elseif characterLimitType == XFubenConfigs.CharacterLimitType.Isomer then + if characterType == XCharacterConfigs.CharacterType.Normal then + XUiManager.TipText("TeamSelectCharacterTypeLimitTipIsomer") + return + end + -- elseif characterLimitType == XFubenConfigs.CharacterLimitType.IsomerDebuff then + -- if characterType == XCharacterConfigs.CharacterType.Isomer then + -- local buffDes = XFubenConfigs.GetBuffDes(self.LimitBuffId) + -- local content = CSXTextManagerGetText("TeamSelectCharacterTypeLimitTipIsomerDebuff", buffDes) + -- local sureCallBack = function() + -- self:OnSelectCharacterType(index) + -- end + -- local closeCallback = function() + -- self.PanelCharacterTypeBtns:SelectIndex(TabBtnIndexConvert[XCharacterConfigs.CharacterType.Normal]) + -- end + -- XUiManager.DialogTip(nil, content, XUiManager.DialogType.Normal, closeCallback, sureCallBack) + -- return + -- end + -- elseif characterLimitType == XFubenConfigs.CharacterLimitType.NormalDebuff then + -- if characterType == XCharacterConfigs.CharacterType.Normal then + -- local buffDes = XFubenConfigs.GetBuffDes(self.LimitBuffId) + -- local content = CSXTextManagerGetText("TeamSelectCharacterTypeLimitTipNormalDebuff", buffDes) + -- local sureCallBack = function() + -- self:OnSelectCharacterType(index) + -- end + -- local closeCallback = function() + -- self.PanelCharacterTypeBtns:SelectIndex(TabBtnIndexConvert[XCharacterConfigs.CharacterType.Isomer]) + -- end + -- XUiManager.DialogTip(nil, content, XUiManager.DialogType.Normal, closeCallback, sureCallBack) + -- return + -- end + end + + self:OnSelectCharacterType(index) +end + +function XUiAssignRoomCharacter:OnSelectCharacterType(index) + if self.SelectTabBtnIndex == index then return end + self.SelectTabBtnIndex = index + + XDataCenter.RoomCharFilterTipsManager.Reset() + + local characterType = CharacterTypeConvert[index] + + local tmpTeamIdDic = {} + for _, id in pairs(self.TeamCharIdMap) do + tmpTeamIdDic[id] = true + end + + local charlist = XDataCenter.CharacterManager.GetAssignCharacterListInTeam(characterType, tmpTeamIdDic) + local teamCharIdMap = self.TeamCharIdMap + local teamSelectPos = self.TeamSelectPos + local selectId = teamCharIdMap[teamSelectPos] + + table.sort(charlist,self.SortFunction[XRoomCharFilterTipsConfigs.EnumSortTag.Default]) + + self:RefreshCharacterTypeTips() + self:UpdateCharacterList(charlist, function(charDic) + if not selectId or selectId == 0 + or not self.CharacterGrids[selectId] + or characterType ~= XCharacterConfigs.GetCharacterType(selectId) + or not charDic[selectId] + then + selectId = charlist[1].Id + end + + self:SelectCharacter(selectId) + + for _, id in pairs(teamCharIdMap) do + if id > 0 then + local grid = self.CharacterGrids[id] + if grid then + grid:SetInTeam(true) + end + end + end + end) +end + +function XUiAssignRoomCharacter:IsInTeam(charId) + local tmpTeamIdDic = {} + for _, id in pairs(self.TeamCharIdMap) do + tmpTeamIdDic[id] = true + end + return tmpTeamIdDic[charId] +end + +function XUiAssignRoomCharacter:CenterToGrid(grid) + -- local normalizedPosition + -- local count = self.SViewCharacterList.content.transform.childCount + -- local index = grid.Transform:GetSiblingIndex() + -- if index > count / 2 then + -- normalizedPosition = (index + 1) / count + -- else + -- normalizedPosition = (index - 1) / count + -- end + -- self.SViewCharacterList.verticalNormalizedPosition = math.max(0, math.min(1, (1 - normalizedPosition))) +end + +function XUiAssignRoomCharacter:SelectCharacter(id) + local grid = self.CharacterGrids[id] + if grid then + self:CenterToGrid(grid) + end + + local character = grid and grid.Character + self:UpdateInfo(character) +end + +function XUiAssignRoomCharacter:SetPanelEmptyList(isEmpty) + self.BtnQuitTeam.gameObject:SetActiveEx(false) + self.BtnJoinTeam.gameObject:SetActiveEx(false) + + self.BtnConsciousness.gameObject:SetActiveEx(not isEmpty) + self.BtnFashion.gameObject:SetActiveEx(not isEmpty) + self.BtnWeapon.gameObject:SetActiveEx(not isEmpty) + self.BtnPartner.gameObject:SetActiveEx(not isEmpty) + + self.PanelRoleContent.gameObject:SetActiveEx(not isEmpty) + self.PanelRoleModel.gameObject:SetActiveEx(not isEmpty) + self.PanelEmptyList.gameObject:SetActiveEx(isEmpty) +end + +function XUiAssignRoomCharacter:UpdateCharacterList(charList, cb) + if not next(charList) then + self:SetPanelEmptyList(true) + return + end + self:SetPanelEmptyList(false) + + for _, item in pairs(self.CharacterGrids) do + item:Reset() + end + + self.CharacterGrids = {} + local baseItem = self.GridCharacter + local count = #charList + local charDic = {} + + for i = 1, count do + local char = charList[i] + + local grid = self.GridIndex[i] + charDic[char.Id] = char + + if not grid then + local item = CS.UnityEngine.Object.Instantiate(baseItem) + grid = XUiGridCharacter.New(item, self, char, function(character) + self:UpdateInfo(character) + end) + + grid.GameObject.name = char.Id + grid.Transform:SetParent(self.PanelRoleContent, false) + + self.GridIndex[i] = grid + else + grid.GameObject.name = char.Id + end + self.CharacterGrids[char.Id] = grid + grid:UpdateGrid(char) + grid.GameObject:SetActiveEx(true) + grid.Transform:SetAsLastSibling() + end + + if cb then + cb(charDic) + end +end + +function XUiAssignRoomCharacter:UpdateInfo(character) + if character then + self.CurCharacter = character + end + if not self.CurCharacter then return end + + if self.CurCharacterGrid then + self.CurCharacterGrid:SetSelect(false) + end + + self.CurCharacterGrid = self.CharacterGrids[self.CurCharacter.Id] + self.CurCharacterGrid:UpdateGrid() + self.CurCharacterGrid:SetSelect(true) + self:UpdateTeamBtn() + self:UpdateRoleModel() +end + +function XUiAssignRoomCharacter:UpdateTeamBtn() + if not (self.TeamCharIdMap and next(self.TeamCharIdMap)) then + return + end + + self.BtnQuitTeam.gameObject:SetActiveEx(false) + self.BtnJoinTeam.gameObject:SetActiveEx(false) + + -- 等待模型加载后设置按钮状态 + local isInTeam = self.TeamOrderCharIdMap[self.CurCharacter.Id] + local isCanQuit = self.CanQuitCharIdMap[self.CurCharacter.Id] + self.IsShowQuitTeamBtn = isInTeam and isCanQuit + self.IsShowJoinTeamBtn = not isInTeam or not isCanQuit +end + +function XUiAssignRoomCharacter:UpdateRoleModel() + local characterId = self.CurCharacter and self.CurCharacter.Id + if not characterId then return end + local targetPanelRole = self.PanelRoleModel + local targetUiName = self.Name + + local func = function() + self.BtnJoinTeam.gameObject:SetActiveEx(self.IsShowJoinTeamBtn) + self.BtnQuitTeam.gameObject:SetActiveEx(self.IsShowQuitTeamBtn) + end + + local charaterFunc = function(model) + if not model then + return + end + self.PanelDrag.Target = model.transform + if self.SelectTabBtnIndex == TabBtnIndex.Normal then + self.ImgEffectHuanren.gameObject:SetActiveEx(true) + elseif self.SelectTabBtnIndex == TabBtnIndex.Isomer then + self.ImgEffectHuanren1.gameObject:SetActiveEx(true) + end + end + + self.ImgEffectHuanren.gameObject:SetActiveEx(false) + self.ImgEffectHuanren1.gameObject:SetActiveEx(false) + self.RoleModelPanel:UpdateCharacterModel(characterId, targetPanelRole, targetUiName, charaterFunc, func) +end + +function XUiAssignRoomCharacter:InitComponent() + local root = self.UiModelGo.transform + self.PanelRoleModel = root:FindTransform("PanelRoleModel") + self.ImgEffectHuanren = root:FindTransform("ImgEffectHuanren") + self.ImgEffectHuanren1 = root:FindTransform("ImgEffectHuanren1") + self.RoleModelPanel = XUiPanelRoleModel.New(self.PanelRoleModel, self.Name, nil, true) + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self.GridCharacter.gameObject:SetActiveEx(false) + + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnJoinTeam, self.OnBtnJoinTeamClick) + self:RegisterClickEvent(self.BtnConsciousness, self.OnBtnConsciousnessClick) + self:RegisterClickEvent(self.BtnQuitTeam, self.OnBtnQuitTeamClick) + self:RegisterClickEvent(self.BtnFashion, self.OnBtnFashionClick) + self:RegisterClickEvent(self.BtnWeapon, self.OnBtnWeaponClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:RegisterClickEvent(self.BtnPartner, self.OnBtnPartnerClick) + + self.BtnFilter.CallBack = function() + self:OnBtnFilterClick() + end +end + +function XUiAssignRoomCharacter:OnBtnWeaponClick() + XLuaUiManager.Open("UiEquipReplaceNew", self.CurCharacter.Id, nil, true) +end + +function XUiAssignRoomCharacter:OnBtnConsciousnessClick() + XLuaUiManager.Open("UiEquipAwarenessReplace", self.CurCharacter.Id, nil, true) +end + +function XUiAssignRoomCharacter:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiAssignRoomCharacter:OnBtnPartnerClick() + XDataCenter.PartnerManager.GoPartnerCarry(self.CurCharacter.Id, false) +end + +function XUiAssignRoomCharacter:OnBtnBackClick() + if self.TeamResultCb then + self.TeamResultCb(self.TeamCharIdMap) + end + self:Close() +end + +function XUiAssignRoomCharacter:OnBtnJoinTeamClick() + local selectId = self.CurCharacter.Id + + local joinFunc = function(isReset) + local newTeamCharIdMap = self:GetNewTeamCharIdMap() + -- 修改的角色id + local fromCharacterId = newTeamCharIdMap[self.TeamSelectPos] + -- 将要下队 + if not fromCharacterId or fromCharacterId == 0 then + self:OnJoinTeam(isReset) + return + end + + local oldOrder = self.TeamOrderCharIdMap[fromCharacterId] + -- 不在其他梯队 + if not oldOrder then + self:OnJoinTeam(isReset) + return + end + + local newOrder = self.CurTeamOrder + + local title = CS.XTextManager.GetText("AssignDeployTipTitle") + local characterName = XCharacterConfigs.GetCharacterName(fromCharacterId) + local oldTeamName = CS.XTextManager.GetText("AssignTeamTitle", oldOrder) -- 作战梯队1 + local newTeamName = CS.XTextManager.GetText("AssignTeamTitle", newOrder) + local content = CS.XTextManager.GetText("AssignDeployTipContent", characterName, oldTeamName, newTeamName) + XUiManager.DialogTip(title, content, XUiManager.DialogType.Normal, nil, function() + self:OnJoinTeam(isReset) + end) + end + + -- 角色类型不一致拦截 + local inTeamCharacterType = self:GetTeamCharacterType() + if inTeamCharacterType then + local characterType = selectId and selectId ~= 0 and XCharacterConfigs.GetCharacterType(selectId) + if characterType and characterType ~= inTeamCharacterType then + local content = CSXTextManagerGetText("TeamCharacterTypeNotSame") + local sureCallBack = function() + local isReset = true + joinFunc(isReset) + end + XUiManager.DialogTip(nil, content, XUiManager.DialogType.Normal, nil, sureCallBack) + return + end + end + + joinFunc() +end + +function XUiAssignRoomCharacter:GetNewTeamCharIdMap() + local newTeamCharIdMap = XTool.Clone(self.TeamCharIdMap) + local fromCharacterId = self.CurCharacter.Id + local toCharacterId = newTeamCharIdMap[self.TeamSelectPos] or 0 + -- 换人 + for pos, id in pairs(self.TeamCharIdMap) do + if id == fromCharacterId then + newTeamCharIdMap[pos] = toCharacterId + break + end + end + newTeamCharIdMap[self.TeamSelectPos] = fromCharacterId + return newTeamCharIdMap +end + +function XUiAssignRoomCharacter:OnJoinTeam(isReset) + self.TeamCharIdMap = self:GetNewTeamCharIdMap() + if isReset then + self:ResetTeamData() + end + if self.TeamResultCb then + self.TeamResultCb(self.TeamCharIdMap) + end + self:Close() +end + +function XUiAssignRoomCharacter:OnBtnQuitTeamClick() + local count = 0 + for _, v in pairs(self.TeamCharIdMap) do + if v > 0 then + count = count + 1 + end + end + + local id = self.CurCharacter.Id + for k, v in pairs(self.TeamCharIdMap) do + if v == id then + self.TeamCharIdMap[k] = 0 + break + end + end + + if self.TeamResultCb then + self.TeamResultCb(self.TeamCharIdMap) + end + self:Close() +end + +function XUiAssignRoomCharacter:OnBtnFashionClick() + XLuaUiManager.Open("UiFashion", self.CurCharacter.Id) +end + +function XUiAssignRoomCharacter:OnBtnFilterClick() + local characterType = CharacterTypeConvert[self.SelectTabBtnIndex] + XLuaUiManager.Open("UiRoomCharacterFilterTips", + self, + XRoomCharFilterTipsConfigs.EnumFilterType.Assign, + XRoomCharFilterTipsConfigs.EnumSortType.Assign, + characterType) +end + +function XUiAssignRoomCharacter:GetTeamCharacterType() + local teamId = self.TeamId + return XDataCenter.FubenAssignManager.GetTeamCharacterType(teamId) +end + +function XUiAssignRoomCharacter:Filter(selectTagGroupDic, sortTagId, isThereFilterDataCb) + local judgeCb = function(groupId, tagValue, character) + local detailConfig = XCharacterConfigs.GetCharDetailTemplate(character.Id) + local compareValue + if groupId == XRoomCharFilterTipsConfigs.EnumFilterTagGroup.Career then + compareValue = detailConfig.Career + if compareValue == tagValue then + -- 当前角色满足该标签 + return true + end + elseif groupId == XRoomCharFilterTipsConfigs.EnumFilterTagGroup.Element then + compareValue = detailConfig.ObtainElementList + for _, element in pairs(compareValue) do + if element == tagValue then + -- 当前角色满足该标签 + return true + end + end + else + XLog.Error(string.format("XUiBfrtRoomCharacter:Filter函数错误,没有处理排序组:%s的逻辑", groupId)) + return + end + end + + local allChar = XDataCenter.CharacterManager.GetOwnCharacterList(CharacterTypeConvert[self.SelectTabBtnIndex]) + XDataCenter.RoomCharFilterTipsManager.Filter(self.TagCacheDic, selectTagGroupDic, allChar, judgeCb, + function(filteredData) + self:FilterRefresh(filteredData, sortTagId) + end, + isThereFilterDataCb) +end + +function XUiAssignRoomCharacter:FilterRefresh(filteredData, sortTagId) + if self.SortFunction[sortTagId] then + table.sort(filteredData, self.SortFunction[sortTagId]) + else + XLog.Error(string.format("XUiBfrtRoomCharacter:FilterRefresh函数错误,没有定义标签:%s的排序函数", sortTagId)) + return + end + + local characterType = CharacterTypeConvert[self.SelectTabBtnIndex] + local teamCharIdMap = self.TeamCharIdMap + local teamSelectPos = self.TeamSelectPos + local selectId = teamCharIdMap[teamSelectPos] + + self:RefreshCharacterTypeTips() + self:UpdateCharacterList(filteredData, function(charDic) + if not selectId or selectId == 0 + or not self.CharacterGrids[selectId] + or characterType ~= XCharacterConfigs.GetCharacterType(selectId) + or not charDic[selectId] + then + selectId = filteredData[1].Id + end + + self:SelectCharacter(selectId) + + for _, id in pairs(teamCharIdMap) do + if id > 0 then + local grid = self.CharacterGrids[id] + if grid then + grid:SetInTeam(true) + end + end + end + end) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiAssign/XUiAssignStageDetail.lua b/Resources/Scripts/XUi/XUiAssign/XUiAssignStageDetail.lua new file mode 100644 index 00000000..990dd83f --- /dev/null +++ b/Resources/Scripts/XUi/XUiAssign/XUiAssignStageDetail.lua @@ -0,0 +1,205 @@ +local XUiAssignStageDetail = XLuaUiManager.Register(XLuaUi, "UiAssignStageDetail") + +local MAX_STAR = 3 +function XUiAssignStageDetail:OnAwake() + self:InitComponent() +end + +function XUiAssignStageDetail:InitComponent() + self.GridCommon.gameObject:SetActiveEx(false) + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self:RegisterClickEvent(self.BtnAddNum, self.OnBtnAddNumClick) + self:RegisterClickEvent(self.BtnEnter, self.OnBtnEnterClick) + self:RegisterClickEvent(self.BtnClose, self.OnBtnCloseClick) + + + self.PanelNums.gameObject:SetActiveEx(false) + self.PanelNoLimitCount.gameObject:SetActiveEx(true) + self.BtnAddNum.gameObject:SetActiveEx(false) + self.TxtAllNums.text = "" + self.TxtLeftNums.text = "" + self.PanelNums.gameObject:SetActiveEx(false) +end + +function XUiAssignStageDetail:OnStart() + self.GridList = {} +end + +function XUiAssignStageDetail:OnEnable() + self.ChapterId = XDataCenter.FubenAssignManager.SelectChapterId + self.GroupId = XDataCenter.FubenAssignManager.SelectGroupId + + self:Refresh() + + -- 动画 + self.IsPlaying = true + XUiHelper.StopAnimation() + + -- self:PlayAnimation(ANIMATION_OPEN, handler(self, function() + self.IsPlaying = false + -- end)) + self.IsOpen = true +end + +function XUiAssignStageDetail:OnDisable() + self.IsOpen = false +end + +function XUiAssignStageDetail:Refresh() + local groupData = XDataCenter.FubenAssignManager.GetGroupDataById(self.GroupId) + + self.BaseStageId = groupData:GetBaseStageId() + self.Stage = XDataCenter.FubenManager.GetStageCfg(self.BaseStageId) + self.StageInfo = XDataCenter.FubenManager.GetStageInfo(self.BaseStageId) + self.IsPassed = XDataCenter.FubenManager.CheckStageIsPass(self.BaseStageId) + self:UpdatePanelTargetList() + self:UpdateRewards() + self:UpdateDetailText() + self:UpdateDifficulty() + self:UpdateStageFightControl() +end + +function XUiAssignStageDetail:OnBtnAddNumClick() + local challengeData = XDataCenter.FubenMainLineManager.GetStageBuyChallengeData(self.BaseStageId) + local func = function() + self:UpdateDetailText() + end + XLuaUiManager.Open("UiBuyAsset", 1, func, challengeData) +end + +function XUiAssignStageDetail:OnBtnEnterClick() + if self.IsPlaying then + return + end + + if self.BaseStageId == nil then + XLog.Error("OnBtnEnterClick: Can not find baseStageId!") + return + end + + -- 检查体力 前置等 + if not XDataCenter.FubenManager.CheckPreFight(self.Stage) then + return + end + + self:Hide() + XLuaUiManager.Open("UiAssignDeploy") +end + +function XUiAssignStageDetail:OnBtnCloseClick() + self:Hide() +end + +function XUiAssignStageDetail:UpdatePanelTargetList() + for i = 1, MAX_STAR do + self["TxtStarActive" .. i].text = self.Stage.StarDesc[i] + end +end + +function XUiAssignStageDetail:UpdateRewards() + local rewardId + local IsFirst = (not self.IsPassed) + local cfg = self.Stage + if IsFirst then + rewardId = cfg.FirstRewardShow + else + rewardId = cfg.FinishRewardShow + end + + if not rewardId or rewardId == 0 then + for j = 1, #self.GridList do + self.GridList[j].GameObject:SetActiveEx(false) + end + return + end + + local rewards = IsFirst and XRewardManager.GetRewardList(rewardId) or XRewardManager.GetRewardListNotCount(rewardId) + if rewards then + for i, item in ipairs(rewards) do + local grid + if self.GridList[i] then + grid = self.GridList[i] + else + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommon) + grid = XUiGridCommon.New(self, ui) + grid.Transform:SetParent(self.PanelDropContent, false) + self.GridList[i] = grid + end + grid:Refresh(item) + grid.GameObject:SetActiveEx(true) + end + end + + local rewardsCount = 0 + if rewards then + rewardsCount = #rewards + end + + for j = 1, #self.GridList do + if j > rewardsCount then + self.GridList[j].GameObject:SetActiveEx(false) + end + end +end + +function XUiAssignStageDetail:UpdateDetailText() + self.TxtTitle.text = self.Stage.Name + self.TxtLevelVal.text = self.Stage.RecommandLevel + self.TxtDesc.text = self.Stage.Description + self.TxtATNums.text = self.Stage.RequireActionPoint + + -- local groupData = XDataCenter.FubenAssignManager.GetGroupDataById(self.GroupId) + -- local chanllengeNum = groupData:GetFightCount() + -- local maxChallengeNum = groupData:GetMaxFightCount() + -- local buyChallengeCount = XDataCenter.FubenManager.GetStageBuyChallengeCount(self.BaseStageId) + -- self.PanelNums.gameObject:SetActiveEx(maxChallengeNum > 0) + -- self.PanelNoLimitCount.gameObject:SetActiveEx(maxChallengeNum <= 0) + -- self.BtnAddNum.gameObject:SetActiveEx(buyChallengeCount > 0) + -- if maxChallengeNum > 0 then + -- self.TxtAllNums.text = "/" .. maxChallengeNum + -- self.TxtLeftNums.text = maxChallengeNum - chanllengeNum + -- end + self.TxtFirstDrop.gameObject:SetActiveEx(not self.IsPassed) + self.TxtDrop.gameObject:SetActiveEx(self.IsPassed) +end + +function XUiAssignStageDetail:UpdateDifficulty() + local nanDuIcon = XDataCenter.FubenManager.GetDifficultIcon(self.BaseStageId) + self.RImgNandu:SetRawImage(nanDuIcon) +end + +function XUiAssignStageDetail:UpdateStageFightControl() + --暂时屏蔽,后面可能要加回来 + if true then + self.PanelStageFightControl.gameObject:SetActiveEx(false) + return + end + + -- local stageInfo = self.StageInfo + -- self.StageFightControl = self.StageFightControl or XUiStageFightControl.New(self.PanelStageFightControl, self.Stage.FightControlId) + + -- if not self.IsPassed and stageInfo.Unlock then + -- self.StageFightControl.GameObject:SetActiveEx(true) + -- self.StageFightControl:UpdateInfo(self.Stage.FightControlId) + -- else + -- self.StageFightControl.GameObject:SetActiveEx(false) + -- end +end + +function XUiAssignStageDetail:Hide() + if self.IsPlaying or not self.IsOpen then + return + end + + self.IsPlaying = true + XUiHelper.StopAnimation() + + -- self:PlayAnimation(ANIMATION_END, handler(self, function() + -- if XTool.UObjIsNil(self.GameObject) then + -- return + -- end + self.IsPlaying = false + self:Close() + -- end)) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_FUBEN_ASSIGN_STAGE_DETAIL_CLOSE) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiAssign/XUiGridAssignBuffPart.lua b/Resources/Scripts/XUi/XUiAssign/XUiGridAssignBuffPart.lua new file mode 100644 index 00000000..bb625e10 --- /dev/null +++ b/Resources/Scripts/XUi/XUiAssign/XUiGridAssignBuffPart.lua @@ -0,0 +1,102 @@ +local XUiGridAssignBuffPart = XClass(nil, "XUiGridAssignBuffPart") + +local XUiGridAssignBuffText = require("XUi/XUiAssign/XUiGridAssignBuffText") + +function XUiGridAssignBuffPart:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:InitComponent() +end + +function XUiGridAssignBuffPart:InitComponent() + self.BuffTextGridList = {} + self.RImgRole.gameObject:SetActiveEx(false) + self.GridOccupyBuff.gameObject:SetActiveEx(false) + CsXUiHelper.RegisterClickEvent(self.BtnOccupy, function() self:OnBtnOccupyClick() end) +end + +function XUiGridAssignBuffPart:GetBuffTextGrid(index) + local grid = self.BuffTextGridList[index] + if not grid then + local obj = CS.UnityEngine.Object.Instantiate(self.GridOccupyBuff) + obj.transform:SetParent(self.PanelOccupyBuff, false) + grid = XUiGridAssignBuffText.New(obj) + self.BuffTextGridList[index] = grid + end + return grid +end + +function XUiGridAssignBuffPart:ResetBuffTextList(len) + if #self.BuffTextGridList > len then + for i = len + 1, #self.BuffTextGridList do + self.BuffTextGridList[i].GameObject:SetActiveEx(false) + end + end +end + +function XUiGridAssignBuffPart:Refresh(chapterId) + local data = XDataCenter.FubenAssignManager.GetChapterDataById(chapterId) + self.ChapterId = chapterId + self.ChapterData = data + + self.TxtName.text = data:GetDesc() + self.RImgRegionIcon:SetRawImage(data:GetIcon()) + + local isOccupy = data:IsOccupy() + local isCanAssign = data:CanAssign() + local buffList = data:GetBuffDescList() + + self:ResetBuffTextList(#buffList) + for i, buffDesc in ipairs(buffList) do + local grid = self:GetBuffTextGrid(i) + grid.GameObject:SetActiveEx(true) + grid:Refresh(buffDesc, isOccupy) + end + + self.TxtCharacterName.text = "" + if isCanAssign then + self.Occupied.gameObject:SetActiveEx(isOccupy) + self.UnOccupied.gameObject:SetActiveEx(not isOccupy) + self.OccupiedPress.gameObject:SetActiveEx(isOccupy) + self.UnOccupiedPress.gameObject:SetActiveEx(not isOccupy) + self.UnLock.gameObject:SetActiveEx(false) + self.UnLockPress.gameObject:SetActiveEx(false) + + if isOccupy then + local characterIcon = data:GetOccupyCharacterIcon() + self.RImgRole.gameObject:SetActiveEx(true) + self.RImgRole:SetRawImage(characterIcon) + self.TxtCharacterName.text = data:GetOccupyCharacterName() + else + self.RImgRole.gameObject:SetActiveEx(false) + end + else + self.RImgRole.gameObject:SetActiveEx(false) + + self.Occupied.gameObject:SetActiveEx(false) + self.UnOccupied.gameObject:SetActiveEx(false) + self.OccupiedPress.gameObject:SetActiveEx(false) + self.UnOccupiedPress.gameObject:SetActiveEx(false) + self.UnLock.gameObject:SetActiveEx(true) + self.UnLockPress.gameObject:SetActiveEx(true) + end + self.isCanAssign = isCanAssign +end + +function XUiGridAssignBuffPart:OnBtnOccupyClick() + if not self.ChapterData then + return + end + + if not self.isCanAssign then + XUiManager.TipMsg(CS.XTextManager.GetText("AssignBuffOccupyLock")) -- 未满足驻守条件,具体请在关卡中查看 + return + end + + XDataCenter.FubenAssignManager.SelectChapterId = self.ChapterId + XDataCenter.FubenAssignManager.SelectCharacterId = self.ChapterData:GetCharacterId() + XLuaUiManager.Open("UiAssignOccupy") +end + +return XUiGridAssignBuffPart \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiAssign/XUiGridAssignBuffText.lua b/Resources/Scripts/XUi/XUiAssign/XUiGridAssignBuffText.lua new file mode 100644 index 00000000..8aa77f9e --- /dev/null +++ b/Resources/Scripts/XUi/XUiAssign/XUiGridAssignBuffText.lua @@ -0,0 +1,21 @@ +local XUiGridAssignBuffText = XClass(nil, "XUiGridAssignBuffText") + +function XUiGridAssignBuffText:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiGridAssignBuffText:Refresh(text, isActive) + if isActive then + self.NorTxtBuff.gameObject:SetActiveEx(false) + self.SelectTxtBuff.gameObject:SetActiveEx(true) + self.SelectTxtBuff.text = text + else + self.NorTxtBuff.gameObject:SetActiveEx(true) + self.SelectTxtBuff.gameObject:SetActiveEx(false) + self.NorTxtBuff.text = text + end +end + +return XUiGridAssignBuffText \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiAssign/XUiGridAssignChapter.lua b/Resources/Scripts/XUi/XUiAssign/XUiGridAssignChapter.lua new file mode 100644 index 00000000..4416dba5 --- /dev/null +++ b/Resources/Scripts/XUi/XUiAssign/XUiGridAssignChapter.lua @@ -0,0 +1,88 @@ +local XUiGridAssignChapter = XClass(nil, "XUiGridAssignChapter") + +function XUiGridAssignChapter:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + self:InitComponent() +end + +function XUiGridAssignChapter:InitComponent() + CsXUiHelper.RegisterClickEvent(self.BtnAssignChapter, function() self:OnBtnChapterClick() end) + CsXUiHelper.RegisterClickEvent(self.BtnOccupy, function() self:OnBtnOccupyClick() end) + + self.NormalRed.gameObject:SetActiveEx(false) + self.NormalBlue.gameObject:SetActiveEx(false) + self.PressRed.gameObject:SetActiveEx(false) + self.PressBlue.gameObject:SetActiveEx(false) + self.RoleImg.gameObject:SetActiveEx(false) + self.Red.gameObject:SetActiveEx(false) +end + +function XUiGridAssignChapter:OnBtnChapterClick() + if not self.ChapterData then + return + end + + XDataCenter.FubenAssignManager.SelectChapterId = self.ChapterData:GetId() + XLuaUiManager.Open("UiPanelAssignStage") +end + +function XUiGridAssignChapter:OnBtnOccupyClick() + if not self.ChapterData then + return + end + XDataCenter.FubenAssignManager.SelectChapterId = self.ChapterData:GetId() + XDataCenter.FubenAssignManager.SelectCharacterId = self.ChapterData:GetCharacterId() + XLuaUiManager.Open("UiAssignOccupy") +end + +function XUiGridAssignChapter:Refresh(chapterId) + local data = XDataCenter.FubenAssignManager.GetChapterDataById(chapterId) + self.ChapterData = data + + local icon = data:GetIcon() + self.RegionIcon:SetRawImage(icon) + + local progressStr = data:GetProgressStr() + self.TxtCourseNormalBlue.text = progressStr + self.TxtCourseNormalRed.text = progressStr + self.TxtCoursePressBlue.text = progressStr + self.TxtCoursePressRed.text = progressStr + + local chapterName = data:GetDesc() + self.TxtChapterNameNormalBlue.text = chapterName + self.TxtChapterNameNormalRed.text = chapterName + self.TxtChapterNamePressBlue.text = chapterName + self.TxtChapterNamePressRed.text = chapterName + + + local isCurrentChapter = XDataCenter.FubenAssignManager.IsCurrentChapter(chapterId) + + self.NormalRed.gameObject:SetActiveEx(isCurrentChapter) + self.NormalBlue.gameObject:SetActiveEx(not isCurrentChapter) + self.PressRed.gameObject:SetActiveEx(isCurrentChapter) + self.PressBlue.gameObject:SetActiveEx(not isCurrentChapter) + + local isCanAssign = data:CanAssign() + if isCanAssign then + self.BtnOccupy.gameObject:SetActiveEx(true) + local isOccupy = data:IsOccupy() + local occupyState = isOccupy and CS.UiButtonState.Select or CS.UiButtonState.Normal + self.BtnOccupy:SetButtonState(occupyState) + if isOccupy then + local characterIcon = data:GetOccupyCharacterIcon() + self.RoleImg.gameObject:SetActiveEx(true) + self.RoleImg:SetRawImage(characterIcon) + else + self.RoleImg.gameObject:SetActiveEx(false) + end + else + self.BtnOccupy.gameObject:SetActiveEx(false) + end + + self.Red.gameObject:SetActiveEx(data:CanReward()) +end + +return XUiGridAssignChapter diff --git a/Resources/Scripts/XUi/XUiAssign/XUiGridAssignDeployMember.lua b/Resources/Scripts/XUi/XUiAssign/XUiGridAssignDeployMember.lua new file mode 100644 index 00000000..d4a7e6c6 --- /dev/null +++ b/Resources/Scripts/XUi/XUiAssign/XUiGridAssignDeployMember.lua @@ -0,0 +1,124 @@ +local XUiGridAssignDeployMember = XClass(nil, "XUiGridAssignDeployMember") -- XUiGridEchelonMember + +local CONDITION_COLOR = { + [true] = CS.UnityEngine.Color.white, + [false] = CS.UnityEngine.Color.red, +} + +--位置对应的颜色框 +local MEMBER_POS_COLOR = { + [1] = "ImgRed", + [2] = "ImgBlue", + [3] = "ImgYellow", +} + +function XUiGridAssignDeployMember:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + self:InitComponent() + self:ResetMemberInfo() +end + +function XUiGridAssignDeployMember:InitComponent() + CsXUiHelper.RegisterClickEvent(self.BtnClick, function() self:OnMemberClick() end) +end + +function XUiGridAssignDeployMember:ResetMemberInfo() + self.ImgLeaderTag.gameObject:SetActiveEx(false) + self.ImgFirstRole.gameObject:SetActiveEx(false) + self.PanelEmpty.gameObject:SetActiveEx(false) + self.PanelMember.gameObject:SetActiveEx(false) + self.ImgBlue.gameObject:SetActiveEx(false) + self.ImgRed.gameObject:SetActiveEx(false) + self.ImgYellow.gameObject:SetActiveEx(false) +end + +function XUiGridAssignDeployMember:Refresh(groupId, teamOrder, teamData, memberOrder) + self.GroupId = groupId + self.TeamOrder = teamOrder + self.TeamData = teamData + self.MemberOrder = memberOrder + + self.TeamId = self.TeamData:GetId() + + local memberData = teamData:GetMemberList()[memberOrder] + self.MemberData = memberData + self.CurCharacterId = memberData:GetCharacterId() or 0 + + local index = memberData:GetIndex() + local leaderIndex = teamData:GetLeaderIndex() + local firstFightIndex = teamData:GetFirstFightIndex() + + self.ImgLeaderTag.gameObject:SetActiveEx(index == leaderIndex) + self.ImgFirstRole.gameObject:SetActiveEx(index == firstFightIndex) + self[MEMBER_POS_COLOR[index]].gameObject:SetActiveEx(true) + + self.CharacterId = memberData:GetCharacterId() + if self.CharacterId and self.CharacterId ~= 0 then + self.PanelNotPassCondition.gameObject:SetActiveEx(true) + local ability = memberData:GetCharacterAbility() + self.TxtNowAbility.color = CONDITION_COLOR[ability >= teamData:GetRequireAbility()] + self.TxtNowAbility.text = ability + + self.RImgRoleHead:SetRawImage(XDataCenter.CharacterManager.GetCharSmallHeadIcon(self.CharacterId)) + self.PanelMember.gameObject:SetActiveEx(true) + self.PanelEmpty.gameObject:SetActiveEx(false) + + else + self.PanelNotPassCondition.gameObject:SetActiveEx(false) + self.PanelMember.gameObject:SetActiveEx(false) + self.PanelEmpty.gameObject:SetActiveEx(true) + end +end + +function XUiGridAssignDeployMember:OnMemberClick() + local teamIdMap, teamOrderMap = XDataCenter.FubenAssignManager.GetCharacterTeamOderMapByGroup(self.GroupId) + self.TeamIdMap = teamIdMap + self.TeamOrderMap = teamOrderMap + + local teamCharIdMap = {} -- 所有已编队角色 + for i, member in ipairs(self.TeamData:GetMemberList()) do + teamCharIdMap[i] = member:GetCharacterId() or 0 + end + -- 其他队角色 + self.OtherCharacterMap = {} + local memberCount = #teamCharIdMap + local otherCharacters = XDataCenter.FubenAssignManager.GetOtherTeamCharacters(self.GroupId, self.TeamId) + for i, v in ipairs(otherCharacters) do -- v = {teamId, i, characterId} + teamCharIdMap[memberCount + i] = v[3] + self.OtherCharacterMap[memberCount + i] = v + end + + local teamSelectPos = self.MemberOrder + local cb = handler(self, self.OnCharacterSelected) + local canQuitCharIdMap = {[self.CurCharacterId] = true } + local ablityRequire = self.TeamData:GetRequireAbility() + local curTeamOrder = self.TeamOrder + local stageId = self.TeamId + local characterLimitType = XFubenConfigs.GetStageCharacterLimitType(stageId) + local limitBuffId = XFubenConfigs.GetStageCharacterLimitBuffId(stageId) + XLuaUiManager.Open("UiAssignRoomCharacter", teamCharIdMap, teamSelectPos, cb, teamOrderMap, canQuitCharIdMap, ablityRequire, curTeamOrder, characterLimitType, limitBuffId, self.TeamId) +end + +function XUiGridAssignDeployMember:OnCharacterSelected(teamCharIdMap) + -- 修改本队 + local memberList = self.TeamData:GetMemberList() + for i, _ in ipairs(memberList) do + XDataCenter.FubenAssignManager.SetTeamMember(self.TeamId, i, teamCharIdMap[i]) + end + + -- 修改其他队 + local memberCount = #memberList + local info + for i = memberCount + 1, #teamCharIdMap do + if teamCharIdMap[i] and self.OtherCharacterMap[i] then + info = self.OtherCharacterMap[i] + XDataCenter.FubenAssignManager.SetTeamMember(info[1], info[2], teamCharIdMap[i]) + end + end + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_ON_ASSIGN_TEAM_CHANGED) -- TODO 细分刷新所有 还是刷新本类 +end +return XUiGridAssignDeployMember \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiAssign/XUiGridAssignDeployTeam.lua b/Resources/Scripts/XUi/XUiAssign/XUiGridAssignDeployTeam.lua new file mode 100644 index 00000000..5c5aa2db --- /dev/null +++ b/Resources/Scripts/XUi/XUiAssign/XUiGridAssignDeployTeam.lua @@ -0,0 +1,63 @@ + +local XUiGridAssignDeployTeam = XClass(nil, "XUiGridAssignDeployTeam") + +local XUiGridAssignDeployMember = require("XUi/XUiAssign/XUiGridAssignDeployMember") + +function XUiGridAssignDeployTeam:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + self:InitComponent() +end + +function XUiGridAssignDeployTeam:InitComponent() + self.MemberGridList = {} + self.BtnLeader.CallBack = function() self:OnBtnLeaderClick() end + self.GridDeployMember.gameObject:SetActiveEx(false) + self.ImgNotPassCondition.gameObject:SetActiveEx(false) +end + +function XUiGridAssignDeployTeam:OnBtnLeaderClick() + local teamData = XDataCenter.FubenAssignManager.GetTeamDataById(self.TeamInfoId) + + local team = {} + local captainPos = teamData:GetLeaderIndex() + local memberList = teamData:GetMemberList() + for _, memberData in ipairs(memberList) do + local characterId = memberData:GetCharacterId() or 0 + team[memberData:GetIndex()] = characterId + end + + XLuaUiManager.Open("UiNewRoomSingleTip", self, team, captainPos, function(index) + teamData:SetLeaderIndex(index) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_ON_ASSIGN_TEAM_CHANGED) + end) +end + +function XUiGridAssignDeployTeam:Refresh(groupId, teamOrder, teamInfoId) + self.TeamOrder = teamOrder + self.TeamInfoId = teamInfoId + + local teamData = XDataCenter.FubenAssignManager.GetTeamDataById(teamInfoId) + self.TxtTitle.text = CS.XTextManager.GetText("AssignTeamTitle", self.TeamOrder) -- 作战梯队1 + self.TxtRequireAbility.text = teamData:GetRequireAbility() + self.TxtFightTips.text = teamData:GetDesc() + self.TxtLeaderSkill.text = teamData:GetLeaderSkillDesc() + + for i = 1, teamData:GetNeedCharacter() do + local grid = self.MemberGridList[i] + if not grid then + local ui = CS.UnityEngine.Object.Instantiate(self.GridDeployMember) + ui.transform:SetParent(self.PanelDeployMembers, false) + ui.gameObject:SetActiveEx(true) + grid = XUiGridAssignDeployMember.New(self, ui) + self.MemberGridList[i] = grid + end + grid:Refresh(groupId, teamOrder, teamData, i) + end + + -- self.ImgNotPassCondition.gameObject:SetActiveEx(not teamData:IsEnoughAbility()) +end + +return XUiGridAssignDeployTeam \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiAssign/XUiGridAssignFormationMember.lua b/Resources/Scripts/XUi/XUiAssign/XUiGridAssignFormationMember.lua new file mode 100644 index 00000000..da5b8a06 --- /dev/null +++ b/Resources/Scripts/XUi/XUiAssign/XUiGridAssignFormationMember.lua @@ -0,0 +1,165 @@ +local CSXTextManagerGetText = CS.XTextManager.GetText + +local XUiGridAssignFormationMember = XClass(nil, "XUiGridAssignFormationMember") -- XUiGridEchelonMember + +function XUiGridAssignFormationMember:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + self:InitComponent() +end + +function XUiGridAssignFormationMember:InitComponent() + CsXUiHelper.RegisterClickEvent(self.BtnMember, function() self:OnMemberClick() end) + self.RImgRole.gameObject:SetActiveEx(false) + self.ImgLeader.gameObject:SetActiveEx(false) + self.ImgAbility.gameObject:SetActiveEx(false) + -- self.TxtAbility + self.ImgSelect.gameObject:SetActiveEx(false) + self.ImgSelect.gameObject:SetActiveEx(false) + self.PanelEffect.gameObject:SetActiveEx(false) + self.ImgFirstRole.gameObject:SetActiveEx(false) +end + +function XUiGridAssignFormationMember:Refresh(groupId, teamOrder, teamData, memberOrder) + self.GroupId = groupId + self.TeamOrder = teamOrder + self.TeamData = teamData + self.MemberOrder = memberOrder + + local memberData = teamData:GetMemberList()[memberOrder] + self.MemberData = memberData + self.CurCharacterId = nil + + local index = memberData:GetIndex() + local color = XUiHelper.Hexcolor2Color(XDataCenter.FubenAssignManager.MemberColor[index]) + self.ImgLeftSkill.color = color + self.ImgRightSkill.color = color + + self.ImgSelect.gameObject:SetActiveEx(false) + self.PanelEffect.gameObject:SetActiveEx(false) + + self.CharacterId = memberData:GetCharacterId() + if self.CharacterId and self.CharacterId ~= 0 then + self.RImgRole.gameObject:SetActiveEx(true) + self.RImgRole:SetRawImage(XDataCenter.CharacterManager.GetCharSmallHeadIcon(self.CharacterId)) + + else + self.RImgRole.gameObject:SetActiveEx(false) + end + + self:RefreshLeaderIndex() +end + +-- 更新角色grid的队长与首发标签 +function XUiGridAssignFormationMember:RefreshLeaderIndex() + if not self.MemberData then + return + end + local index = self.MemberData:GetIndex() + local leaderIndex = self.TeamData:GetLeaderIndex() + local firstFightIndex = self.TeamData:GetFirstFightIndex() + + self.ImgLeader.gameObject:SetActiveEx(index == leaderIndex) + self.ImgFirstRole.gameObject:SetActiveEx(index == firstFightIndex) +end + +function XUiGridAssignFormationMember:OnMemberClick() + local firstOrder = XDataCenter.FubenAssignManager.OccupyFirstSelectOrder + if not firstOrder and not self.CharacterId then + XLog.Debug("请选中角色") + return + end + + local teamId = self.TeamData:GetId() + local memberList = self.TeamData:GetMemberList() + -- 选第一个 + if not firstOrder then + firstOrder = self.MemberOrder + self.ImgSelect.gameObject:SetActiveEx(true) + + XDataCenter.FubenAssignManager.OccupyFirstSelectTeamId = teamId + XDataCenter.FubenAssignManager.OccupyFirstSelectOrder = firstOrder + else + if teamId == XDataCenter.FubenAssignManager.OccupyFirstSelectTeamId and firstOrder == self.MemberOrder then -- 反选第一个 + -- memberList[firstOrder]:SetCharacterId(nil) + return + else + -- self.ImgSelect.gameObject:SetActiveEx(true) + local srcTeamId = XDataCenter.FubenAssignManager.OccupyFirstSelectTeamId + local srcTeamData = XDataCenter.FubenAssignManager.GetTeamDataById(srcTeamId) + local srcMemberList = srcTeamData:GetMemberList() + local srcCharacterId = srcMemberList[firstOrder]:GetCharacterId() + local dstCharacterId = self.CharacterId + + local swapFunc = function(isReset) + if isReset then + srcTeamData:ClearMemberList() + self.TeamData:ClearMemberList() + end + + srcMemberList[firstOrder]:SetCharacterId(self.CharacterId) + memberList[self.MemberOrder]:SetCharacterId(srcCharacterId) + + XDataCenter.FubenAssignManager.OccupySecondSelectTeamId = teamId + XDataCenter.FubenAssignManager.OccupySecondSelectOrder = self.MemberOrder + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_ASSIGN_REFRESH_FORMATION) -- 刷新编队界面 将调用RefreshEffect + end + + local oldCharacterLimitType = XFubenConfigs.GetStageCharacterLimitType(srcTeamId) + local newCharacterLimitType = XFubenConfigs.GetStageCharacterLimitType(teamId) + + local oldCharacterType = srcTeamData:GetCharacterType() + local newCharacterType = self.TeamData:GetCharacterType() + + --仅当副本限制类型为构造体/感染体强制要求时赋值 + local oldForceCharacterType = XDataCenter.FubenManager.GetForceCharacterTypeByCharacterLimitType(oldCharacterLimitType) + local newForceCharacterType = XDataCenter.FubenManager.GetForceCharacterTypeByCharacterLimitType(newCharacterLimitType) + + --角色类型不符合副本限制类型 + if oldForceCharacterType and newCharacterType and oldForceCharacterType ~= newCharacterType + or newForceCharacterType and oldCharacterType and newForceCharacterType ~= oldCharacterType then + XUiManager.TipText("SwapCharacterTypeIsNotMatch") + return + end + + --角色类型不一致 + if newCharacterType and oldCharacterType and oldCharacterType ~= newCharacterType then + local content = CSXTextManagerGetText("SwapCharacterTypeIsDiffirent") + local sureCallBack = function() swapFunc(true) end + XUiManager.DialogTip(nil, content, XUiManager.DialogType.Normal, nil, sureCallBack) + return + end + + swapFunc() + end + + end +end + + +function XUiGridAssignFormationMember:RefreshEffect(state) + if state == XDataCenter.FubenAssignManager.FormationState.Effect then -- 隐藏选框,显示特效 + local firstTeamId = XDataCenter.FubenAssignManager.OccupyFirstSelectTeamId or 0 + local secondTeamId = XDataCenter.FubenAssignManager.OccupySecondSelectTeamId or 0 + local firstOrder = XDataCenter.FubenAssignManager.OccupyFirstSelectOrder + local secondOrder = XDataCenter.FubenAssignManager.OccupySecondSelectOrder + local teamId = self.TeamData:GetId() + local isFirstSelected = (teamId == firstTeamId and self.MemberOrder == firstOrder) + local isSecondSelect = (teamId == secondTeamId and self.MemberOrder == secondOrder) + self.ImgSelect.gameObject:SetActiveEx(false) + self.PanelEffect.gameObject:SetActiveEx(isFirstSelected or isSecondSelect) + + elseif state == XDataCenter.FubenAssignManager.FormationState.Reset then -- 重置数据 + XDataCenter.FubenAssignManager.OccupyFirstSelectTeamId = nil + XDataCenter.FubenAssignManager.OccupyFirstSelectOrder = nil + XDataCenter.FubenAssignManager.OccupySecondSelectTeamId = nil + XDataCenter.FubenAssignManager.OccupySecondSelectOrder = nil + self.ImgSelect.gameObject:SetActiveEx(false) + self.PanelEffect.gameObject:SetActiveEx(false) + end +end + +return XUiGridAssignFormationMember \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiAssign/XUiGridAssignFormationTeam.lua b/Resources/Scripts/XUi/XUiAssign/XUiGridAssignFormationTeam.lua new file mode 100644 index 00000000..2ba865dd --- /dev/null +++ b/Resources/Scripts/XUi/XUiAssign/XUiGridAssignFormationTeam.lua @@ -0,0 +1,142 @@ +local XUiGridAssignFormationTeam = XClass(nil, "XUiGridAssignFormationTeam") + +local XUiGridAssignFormationMember = require("XUi/XUiAssign/XUiGridAssignFormationMember") + +XUiGridAssignFormationTeam.BtnTabIndex = { + Blue = 2, + Red = 1, -- 注意:队伍位置为1,但显示位置在中间 + Yellow = 3, +} + +function XUiGridAssignFormationTeam:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + self:InitComponent() + self:InitButtonGroup() +end + +function XUiGridAssignFormationTeam:InitComponent() + self.MemberGridList = {} + self.GridTeamMember.gameObject:SetActiveEx(false) +end + +function XUiGridAssignFormationTeam:GetMemberGrid(index) + local grid = self.MemberGridList[index] + if not grid then + local obj = CS.UnityEngine.Object.Instantiate(self.GridTeamMember) + obj.transform:SetParent(self.PanelRole, false) + grid = XUiGridAssignFormationMember.New(self, obj) + self.MemberGridList[index] = grid + end + return grid +end + +function XUiGridAssignFormationTeam:ResetMemberGridList(len) + if #self.MemberGridList > len then + for _ = len + 1, #self.MemberGridList do + self.MemberGridList.GameObject:SetActiveEx(false) + end + end +end + +function XUiGridAssignFormationTeam:InitButtonGroup() + self.TabGroup = { + self.BtnRed, + self.BtnBlue, + self.BtnYellow, + } + self.PanelTabFirst:Init(self.TabGroup, function(tabIndex) self:OnClickTabCallBack(tabIndex) end) + + self.TabGroupCT = { + self.BtnCaptainRed, + self.BtnCaptainBlue, + self.BtnCaptainYellow, + } + self.PanelTabCaptain:Init(self.TabGroupCT, function(tabIndex) self:OnClickTabCallBackCT(tabIndex) end) +end + +function XUiGridAssignFormationTeam:Refresh(groupId, teamOrder, teamInfoId) + local teamData = XDataCenter.FubenAssignManager.GetTeamDataById(teamInfoId) + local lastMemberNum = self.MemberNum + + self.TeamOrder = teamOrder + self.TeamInfoId = teamInfoId + self.MemberNum = teamData:GetNeedCharacter() + + self.TextTitle.text = CS.XTextManager.GetText("AssignTeamTitle", self.TeamOrder) -- 作战梯队1 + + self:ResetMemberGridList(self.MemberNum) + for i = 1, self.MemberNum do + local grid = self:GetMemberGrid(i) + grid.GameObject:SetActiveEx(true) + grid:Refresh(groupId, teamOrder, teamData, i) + end + + local stageId = teamInfoId + local characterLimitType = XFubenConfigs.GetStageCharacterLimitType(teamInfoId) + if not XFubenConfigs.IsStageCharacterLimitConfigExist(characterLimitType) then + self.PanelRequireCharacter.gameObject:SetActiveEx(false) + else + local icon = XFubenConfigs.GetStageCharacterLimitImageTeamEdit(characterLimitType) + self.ImgRequireCharacter:SetSprite(icon) + + local name = XFubenConfigs.GetStageCharacterLimitName(characterLimitType) + self.TxtRequireCharacter.text = name + + self.PanelRequireCharacter.gameObject:SetActiveEx(true) + end + + --队长/首发 + for i = 1, #self.TabGroup do + self.TabGroup[i].gameObject:SetActiveEx(i <= self.MemberNum) + end + local firstFightPos = teamData:GetFirstFightIndex() + self.PanelTabFirst:SelectIndex(firstFightPos) + + for i = 1, #self.TabGroupCT do + self.TabGroupCT[i].gameObject:SetActiveEx(i <= self.MemberNum) + end + local captainPos = teamData:GetLeaderIndex() + self.PanelTabCaptain:SelectIndex(captainPos) +end + +function XUiGridAssignFormationTeam:RefreshMemberEffect(state) + for i = 1, self.MemberNum do + local grid = self:GetMemberGrid(i) + grid:RefreshEffect(state) + end +end + +function XUiGridAssignFormationTeam:OnClickTabCallBack(index) + if self.SelectedIndex and self.SelectedIndex == index then + return + end + self.SelectedIndex = index + + local teamData = XDataCenter.FubenAssignManager.GetTeamDataById(self.TeamInfoId) + teamData:SetFirstFightIndex(index) + + for i = 1, self.MemberNum do + local grid = self:GetMemberGrid(i) + grid:RefreshLeaderIndex() + end +end + +function XUiGridAssignFormationTeam:OnClickTabCallBackCT(index) + if self.SelectedIndexCT and self.SelectedIndexCT == index then + return + end + self.SelectedIndexCT = index + + local teamData = XDataCenter.FubenAssignManager.GetTeamDataById(self.TeamInfoId) + teamData:SetLeaderIndex(index) + + for i = 1, self.MemberNum do + local grid = self:GetMemberGrid(i) + grid:RefreshLeaderIndex() + end +end + +return XUiGridAssignFormationTeam \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiAssign/XUiGridAssignSelectOccupy.lua b/Resources/Scripts/XUi/XUiAssign/XUiGridAssignSelectOccupy.lua new file mode 100644 index 00000000..14dbef08 --- /dev/null +++ b/Resources/Scripts/XUi/XUiAssign/XUiGridAssignSelectOccupy.lua @@ -0,0 +1,71 @@ +local XUiGridAssignSelectOccupy = XClass(nil, "XUiGridAssignSelectOccupy") + +function XUiGridAssignSelectOccupy:Ctor(rootUi, ui) + self.RootUi = rootUi + self.Ui = ui + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.OnClickCallBack = function() self:OnClick() end + self.IsMatch = false + self.IsUsed = true +end + +function XUiGridAssignSelectOccupy:Refresh(character, chapterId) + self.Character = character + self.ChapterId = chapterId + if not self.Grid then + self.Grid = XUiGridCharacter.New(self.Ui, self.RootUi, self.Character, self.OnClickCallBack) + else + self.Grid:UpdateGrid(self.Character) + end + self:UpdateCharacterInfo() + + local chapterData = XDataCenter.FubenAssignManager.GetChapterDataById(self.ChapterId) + + self.IsSelect = (XDataCenter.FubenAssignManager.SelectCharacterId == self.Character.Id) + self.IsMatch = chapterData:IsCharConditionMatch(self.Character.Id) + self.OccupyChapterId = XDataCenter.FubenAssignManager.GetCharacterOccupyChapterId(self.Character.Id) or 0 + self.IsUsed = (self.OccupyChapterId ~= 0) + self.IsCurrentChapter = (self.OccupyChapterId == self.ChapterId) + + self.Grid:SetSelect(self.IsSelect) + self.PanelStateUsed.gameObject:SetActiveEx(self.IsMatch and self.IsUsed) + self.PanelStateNotMatch.gameObject:SetActiveEx(not self.IsMatch) +end + +function XUiGridAssignSelectOccupy:UpdateCharacterInfo() + local characterId = self.Character.Id + local growUpLevel = XDataCenter.ExhibitionManager.GetCharacterGrowUpLevel(characterId) + local levelIcon = XExhibitionConfigs.GetExhibitionLevelIconByLevel(growUpLevel) + if not levelIcon or levelIcon == "" then + self.ImgClassIcon.gameObject:SetActive(false) + else + self.RootUi:SetUiSprite(self.ImgClassIcon, levelIcon) + self.ImgClassIcon.gameObject:SetActive(true) + end +end + + +function XUiGridAssignSelectOccupy:OnClick() + if not (self.ChapterId and self.Character) then + return + end + + if not self.IsMatch then + XUiManager.TipMsg(CS.XTextManager.GetText("AssignSelectNotMatch")) -- "该成员不符合条件" + return + end + + if self.IsUsed and not self.IsCurrentChapter then + XUiManager.TipMsg(CS.XTextManager.GetText("AssignSelectIsUsed")) -- "该成员已在其他区域驻守" + return + end + + local characterId = self.Character.Id + self.Grid:SetSelect(true) + XDataCenter.FubenAssignManager.SelectCharacterId = characterId + CsXGameEventManager.Instance:Notify(XEventId.EVENT_ASSIGN_SELECT_OCCUPY_BEGIN) +end + +return XUiGridAssignSelectOccupy \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiAssign/XUiGridAssignStage.lua b/Resources/Scripts/XUi/XUiAssign/XUiGridAssignStage.lua new file mode 100644 index 00000000..11302594 --- /dev/null +++ b/Resources/Scripts/XUi/XUiAssign/XUiGridAssignStage.lua @@ -0,0 +1,50 @@ +local XUiGridAssignStage = XClass(nil, "XUiGridAssignStage") + +function XUiGridAssignStage:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + self:InitComponent() +end + +function XUiGridAssignStage:InitComponent() + self.GridAssignStage.CallBack = function() self:OnClick() end +end + +function XUiGridAssignStage:Refresh(chapterId, groupId) + self.ChapterId = chapterId + self.GroupId = groupId + local data = XDataCenter.FubenAssignManager.GetGroupDataById(groupId) + self.GroupData = data + + local icon = data:GetIcon() + self.RImgStageNormal:SetRawImage(icon) + self.RImgStageSelect:SetRawImage(icon) + -- self.RImgStageDisable:SetRawImage(icon) -- 未解锁显示默认白色 + local name = data:GetName() + self.TextNameNormal.text = name + self.TextNameSelect.text = name + self.TextNameDisable.text = name + + local needTeamNum = #data:GetTeamInfoId() + self.TextTeamNumNormal.text = needTeamNum + self.TextTeamNumSelect.text = needTeamNum + + self.ImgFubenEnd.gameObject:SetActiveEx(data:IsPass() and not data:GetIsPerfect()) + self.ImgFubenPerfect.gameObject:SetActiveEx(data:IsPass() and data:GetIsPerfect()) + self.GridAssignStage:SetButtonState(data:IsUnlock() and CS.UiButtonState.Normal or CS.UiButtonState.Disable) +end + +function XUiGridAssignStage:OnClick() + if not self.GroupData then + return + end + if not self.GroupData:IsUnlock() then + XUiManager.TipMsg(CS.XTextManager.GetText("AssignStageUnlock")) -- "请先通关前置关卡" + return + end + CsXGameEventManager.Instance:Notify(XEventId.EVENT_FUBEN_ASSIGN_STAGE_CLICK, self) +end + +return XUiGridAssignStage \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiAssign/XUiGridTeamInfoExp.lua b/Resources/Scripts/XUi/XUiAssign/XUiGridTeamInfoExp.lua new file mode 100644 index 00000000..118c70b1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiAssign/XUiGridTeamInfoExp.lua @@ -0,0 +1,60 @@ +local XUiGridTeamInfoExp = XClass(nil, "XUiGridTeamInfoExp") + +function XUiGridTeamInfoExp:Ctor(rootUi, ui, baseStageId, index, teamInfoId) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + self:InitComponent() + self:ResetDataInfo() + self:UpdateDataInfo(baseStageId, index, teamInfoId) +end + +function XUiGridTeamInfoExp:InitComponent() + self.GridCharacter.gameObject:SetActive(false) +end + +function XUiGridTeamInfoExp:ResetDataInfo() + self.BaseStage = nil + self.TeamInfoIndex = nil + self.TeamInfoId = nil +end + +function XUiGridTeamInfoExp:UpdateDataInfo(baseStageId, index, teamInfoId) + self.BaseStage = baseStageId + self.TeamInfoIndex = index + self.TeamInfoId = teamInfoId + self:UpdateTxtExp() + self:UpdateTxtEchelonIndex() + self:UpdateFightTeamCharacter() +end + +function XUiGridTeamInfoExp:UpdateTxtExp() + local stageCfg = XDataCenter.FubenManager.GetStageCfg(self.BaseStage) + self.TxtExp.text = "+" .. stageCfg.CardExp +end + +function XUiGridTeamInfoExp:UpdateTxtEchelonIndex() + self.TxtEchelonIndex.text = CS.XTextManager.GetText("AssignTeamTitle", self.TeamInfoIndex) +end + +function XUiGridTeamInfoExp:UpdateFightTeamCharacter() + local teamData = XDataCenter.FubenAssignManager.GetTeamDataById(self.TeamInfoId) + if not teamData then + XLog.Error("XUiGridTeamInfoExp UpdateFightTeamCharacter error: do not have teamData.") + return + end + + for _, memberData in ipairs(teamData:GetMemberList()) do + local charId = memberData:GetCharacterId() + if charId and charId ~= 0 then + local char = XDataCenter.CharacterManager.GetCharacter(charId) + local ui = CS.UnityEngine.Object.Instantiate(self.GridCharacter) + local grid = XUiGridCharacter.New(ui, self, char) + grid.Transform:SetParent(self.PanelCharacters, false) + grid.GameObject:SetActive(true) + end + end +end + +return XUiGridTeamInfoExp \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiAssign/XUiPanelAssignFormation.lua b/Resources/Scripts/XUi/XUiAssign/XUiPanelAssignFormation.lua new file mode 100644 index 00000000..fdd1e5bb --- /dev/null +++ b/Resources/Scripts/XUi/XUiAssign/XUiPanelAssignFormation.lua @@ -0,0 +1,104 @@ +local XUiPanelAssignFormation = XClass(nil, "XUiPanelAssignFormation") + +local XUiGridAssignFormationTeam = require("XUi/XUiAssign/XUiGridAssignFormationTeam") + +function XUiPanelAssignFormation:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + self:InitComponent() +end + +function XUiPanelAssignFormation:InitComponent() + self.GridFormationTeam.gameObject:SetActiveEx(false) + -- CsXUiHelper.RegisterClickEvent(self.BtnClose, function() self:OnBtnCloseClick() end) + CsXUiHelper.RegisterClickEvent(self.BtnConfirm, function() self:OnBtnConfirmClick() end) + self.TeamGridList = {} +end + +function XUiPanelAssignFormation:Show(groupId) + self.GroupId = groupId + XDataCenter.FubenAssignManager.OccupyFirstSelectTeamId = nil + XDataCenter.FubenAssignManager.OccupyFirstSelectOrder = nil + XDataCenter.FubenAssignManager.OccupySecondSelectTeamId = nil + XDataCenter.FubenAssignManager.OccupySecondSelectOrder = nil + self.GameObject:SetActiveEx(true) + self:Refresh() +end + +function XUiPanelAssignFormation:Close() + self.GameObject:SetActiveEx(false) + self:RemoveTimer() +end + +function XUiPanelAssignFormation:GetTeamGrid(index) + local grid = self.TeamGridList[index] + if not grid then + local obj = CS.UnityEngine.Object.Instantiate(self.GridFormationTeam) + obj.transform:SetParent(self.PanelFormationTeamContent, false) + grid = XUiGridAssignFormationTeam.New(self, obj) + self.TeamGridList[index] = grid + end + return grid +end + +function XUiPanelAssignFormation:ResetTeamGridList(len) + if #self.TeamGridList > len then + for _ = len + 1, #self.TeamGridList do + self.TeamGridList.GameObject:SetActiveEx(false) + end + end +end + +function XUiPanelAssignFormation:Refresh() + local data = XDataCenter.FubenAssignManager.GetGroupDataById(self.GroupId) + self.ListData = data:GetTeamInfoId() + + self:ResetTeamGridList(#self.ListData) + for i, _ in ipairs(self.ListData) do + local grid = self:GetTeamGrid(i) + grid.GameObject:SetActiveEx(true) + grid:Refresh(self.GroupId, i, self.ListData[i]) + end +end + +function XUiPanelAssignFormation:RefreshMemberEffect(state) + for i, _ in ipairs(self.ListData) do + local grid = self:GetTeamGrid(i) + grid.GameObject:SetActiveEx(true) + grid:RefreshMemberEffect(state) + end +end + +function XUiPanelAssignFormation:RefreshForAnim() + self:RemoveTimer() + XLuaUiManager.SetMask(true) + + self:Refresh() + self:RefreshMemberEffect(XDataCenter.FubenAssignManager.FormationState.Effect) + self.scheduleId = XScheduleManager.ScheduleOnce(function() + self:RefreshMemberEffect(XDataCenter.FubenAssignManager.FormationState.Reset) + XLuaUiManager.SetMask(false) + end, XDataCenter.FubenAssignManager.FomationAnimFinishDelay) +end + +function XUiPanelAssignFormation:RemoveTimer() + if self.scheduleId then + XScheduleManager.UnSchedule(self.scheduleId) + self.scheduleId = nil + end +end + +function XUiPanelAssignFormation:OnBtnConfirmClick() + self:Close() + CsXGameEventManager.Instance:Notify(XEventId.EVENT_FUBEN_ASSIGN_FORMATION_CONFIRM) +end + + +function XUiPanelAssignFormation:OnBtnCloseClick() + self:Close() + CsXGameEventManager.Instance:Notify(XEventId.EVENT_FUBEN_ASSIGN_FORMATION_CONFIRM) +end + +return XUiPanelAssignFormation \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiAssign/XUiPanelAssignMain.lua b/Resources/Scripts/XUi/XUiAssign/XUiPanelAssignMain.lua new file mode 100644 index 00000000..043d10b2 --- /dev/null +++ b/Resources/Scripts/XUi/XUiAssign/XUiPanelAssignMain.lua @@ -0,0 +1,130 @@ +-- 边界公约区域界面 +local XUiPanelAssignMain = XLuaUiManager.Register(XLuaUi, "UiPanelAssignMain") + +local XUiGridAssignChapter = require("XUi/XUiAssign/XUiGridAssignChapter") + +function XUiPanelAssignMain:OnAwake() + self:InitComponent() +end + +function XUiPanelAssignMain:OnStart() -- 用于跳转到stageId + self:InitChapterGridList() +end + +function XUiPanelAssignMain:InitComponent() + self.PanelAsset = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + self:BindHelpBtn(self.BtnHelp, "Assign") + self.BtnBuff.CallBack = function() self:OnBtnBuffClick() end +end + +function XUiPanelAssignMain:InitChapterGridList() + self.ListData = XDataCenter.FubenAssignManager.GetChapterIdList() + self.ChapterGridList = {} + local prefabName = CS.XGame.ClientConfig:GetString("GridAssignChapter") + for i, chapterId in ipairs(self.ListData) do + local parent = self["Stage" .. i] + if parent then + local prefab = parent:LoadPrefab(prefabName) + local grid = XUiGridAssignChapter.New(self.RootUi, prefab) + grid.Parent = parent + prefab:SetActiveEx(true) + parent.gameObject:SetActiveEx(false) + table.insert(self.ChapterGridList, grid) + else + XLog.Error("配置章节数超过ui结点数,index:" .. i .. ", chapterId:" .. chapterId) + end + end +end + +function XUiPanelAssignMain:OnEnable() + if self.IsInitialed then + self:Refresh() + else + self.IsInitialed = true + XDataCenter.FubenAssignManager.AssignGetDataRequest(function() + self:InitRefresh() + end) + end +end + +function XUiPanelAssignMain:OnGetEvents() + return { XEventId.EVENT_ASSIGN_SELECT_OCCUPY_END } +end + +--事件监听 +function XUiPanelAssignMain:OnNotify(evt) + if evt == XEventId.EVENT_ASSIGN_SELECT_OCCUPY_END then + self:Refresh() + end +end + +function XUiPanelAssignMain:OnDestroy() +end + +function XUiPanelAssignMain:OnBtnBackClick() + self:Close() +end + +function XUiPanelAssignMain:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiPanelAssignMain:OnBtnBuffClick() + XLuaUiManager.Open("UiAssignBuff") +end + +function XUiPanelAssignMain:InitRefresh() + self:Refresh() + self:ShowCurrentChapter() + self:FirstShowHelpTip() +end + +function XUiPanelAssignMain:Refresh() + for i, grid in ipairs(self.ChapterGridList) do + local chapterId = self.ListData[i] + if not chapterId then + grid.Parent.gameObject:SetActiveEx(false) + else + -- 只显示解锁章节 + local chapterData = XDataCenter.FubenAssignManager.GetChapterDataById(chapterId) + if chapterData:IsPass() or XDataCenter.FubenAssignManager.IsCurrentChapter(chapterId) then + grid.Parent.gameObject:SetActiveEx(true) + grid:Refresh(chapterId) + else + grid.Parent.gameObject:SetActiveEx(false) + end + end + end + + -- 适配所有子RectTransform的大小 + self.BoundSizeFitter:SetLayoutHorizontal() +end + +-- 显示当前章节 +function XUiPanelAssignMain:ShowCurrentChapter() + local showIndex = 0 + for i, _ in ipairs(self.ChapterGridList) do + local chapterId = self.ListData[i] + if chapterId and XDataCenter.FubenAssignManager.IsCurrentChapter(chapterId) then + showIndex = i + break + end + end + if showIndex <= 3 then + return + end + local showGrid = self.ChapterGridList[showIndex] + local posX = showGrid.Parent.transform.localPosition.x - self.RectTransform.rect.width * 0.8 + self.ScrollRect.horizontalNormalizedPosition = posX / (1 * self.ScrollRect.content.rect.width - self.RectTransform.rect.width) +end + +function XUiPanelAssignMain:FirstShowHelpTip() + local key = XDataCenter.FubenAssignManager.GetAccountEnterKey() + local data = XSaveTool.GetData(key) + if not data then + XUiManager.ShowHelpTip("Assign") + XSaveTool.SaveData(key, 1) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiAssign/XUiPanelAssignStage.lua b/Resources/Scripts/XUi/XUiAssign/XUiPanelAssignStage.lua new file mode 100644 index 00000000..272be05e --- /dev/null +++ b/Resources/Scripts/XUi/XUiAssign/XUiPanelAssignStage.lua @@ -0,0 +1,223 @@ +-- 边界公约关卡组界面 +local XUiPanelAssignStage = XLuaUiManager.Register(XLuaUi, "UiPanelAssignStage") + +local XUiGridAssignStage = require("XUi/XUiAssign/XUiGridAssignStage") + +function XUiPanelAssignStage:OnAwake() + self:InitComponent() +end + +function XUiPanelAssignStage:OnStart() + self.ChapterId = XDataCenter.FubenAssignManager.SelectChapterId + self.DefaultContentPosX = self.PanelStageContent.localPosition.x + self.ConditionTxtList = {} + self.GroupGridList = {} + self.RewardGridList = {} + self:InitGroupList() +end + +function XUiPanelAssignStage:OnEnable() + self:Refresh() +end + +function XUiPanelAssignStage:InitComponent() + self.RectTransform = self.Transform:GetComponent("RectTransform") + self.PanelAsset = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + + self.TxtLock.gameObject:SetActiveEx(false) + self.GridCommonPopUp.gameObject:SetActiveEx(false) + self.RImgRoleSelect.gameObject:SetActiveEx(false) + + + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + self:BindHelpBtn(self.BtnHelp, "Assign") + self.BtnTreasure.CallBack = function() self:OnBtnTreasureClick() end + CsXUiHelper.RegisterClickEvent(self.BtnOccupy, function() self:OnBtnOccupyClick() end) +end + +function XUiPanelAssignStage:InitGroupList() + local data = XDataCenter.FubenAssignManager.GetChapterDataById(self.ChapterId) + + self.ListData = data:GetGroupId() + local prefabName = CS.XGame.ClientConfig:GetString("GridAssignStage") + for i, _ in ipairs(self.ListData) do + local parent = self["Stage" .. i] + if not parent then + XLog.Error("找不到ui结点Stage" .. i) + break + end + local prefab = parent:LoadPrefab(prefabName) + prefab:SetActiveEx(false) + local grid = XUiGridAssignStage.New(self, prefab) + grid.Parent = parent + table.insert(self.GroupGridList, grid) + end +end + +function XUiPanelAssignStage:OnGetEvents() + return { XEventId.EVENT_FUBEN_ASSIGN_STAGE_CLICK, XEventId.EVENT_FUBEN_ASSIGN_STAGE_DETAIL_CLOSE, XEventId.EVENT_ASSIGN_SELECT_OCCUPY_END } +end + +--事件监听 +function XUiPanelAssignStage:OnNotify(evt, ...) + local args = { ... } + if evt == XEventId.EVENT_FUBEN_ASSIGN_STAGE_CLICK then + local grid = args[1] + XDataCenter.FubenAssignManager.SelectGroupId = grid.GroupId + self:OnDetailShow(grid) + elseif evt == XEventId.EVENT_FUBEN_ASSIGN_STAGE_DETAIL_CLOSE then + self:OnDetailHide() + elseif evt == XEventId.EVENT_ASSIGN_SELECT_OCCUPY_END then + self:RefreshOccupy() + end +end + +function XUiPanelAssignStage:Refresh() + local data = XDataCenter.FubenAssignManager.GetChapterDataById(self.ChapterId) + self.ChapterData = data + + self.TxtTitle.text = data:GetDesc() + + for i, grid in ipairs(self.GroupGridList) do + if self.ListData[i] then + grid.GameObject:SetActiveEx(true) + grid:Refresh(self.ChapterId, self.ListData[i]) + else + grid.GameObject:SetActiveEx(false) + end + end + + -- 奖励 + local rewards = {} + for _, rewardGroupId in ipairs(data:GetRewardId()) do + for _, id in ipairs(XRewardManager.GetRewardList(rewardGroupId)) do + table.insert(rewards, id) + end + end + for i, reward in ipairs(rewards) do + local grid = self.RewardGridList[i] + if not grid then + local obj = CS.UnityEngine.Object.Instantiate(self.GridCommonPopUp) + obj.transform:SetParent(self.PanelRewrds, false) + grid = XUiGridCommon.New(self, obj) + self.RewardGridList[i] = grid + end + grid.GameObject:SetActiveEx(true) + grid:Refresh(reward) + end + + local isPass = data:IsPass() + if isPass then + local isRewarded = data:IsRewarded() + self.BtnTreasure.gameObject:SetActiveEx(true) + self.BtnTreasure:SetButtonState(isRewarded and XUiButtonState.Disable or XUiButtonState.Normal) + self.TxtCondition.gameObject:SetActiveEx(false) + else + self.BtnTreasure.gameObject:SetActiveEx(false) + self.TxtCondition.gameObject:SetActiveEx(true) + end + + self:RefreshOccupy() +end + +function XUiPanelAssignStage:RefreshOccupy() + local data = XDataCenter.FubenAssignManager.GetChapterDataById(self.ChapterId) + -- 开启驻守条件 + local isMatch = data:IsPass() + for i, conditionId in ipairs(data:GetAssignCondition()) do + local txt = self.ConditionTxtList[i] + if not txt then + txt = CS.UnityEngine.Object.Instantiate(self.TxtLock) + txt.transform:SetParent(self.PanelLock, false) + txt.gameObject:SetActiveEx(true) + self.ConditionTxtList[i] = txt + end + local ret, desc = XConditionManager.CheckCondition(conditionId) + if not (ret) then + isMatch = false + txt.gameObject:GetComponent("CanvasGroup").alpha = 0.3 + else + txt.gameObject:GetComponent("CanvasGroup").alpha = 1 + end + txt.text = desc + end + self.IsMatch = isMatch + + local isOccuy = data:IsOccupy() + if isOccuy then + local characterIcon = data:GetOccupyCharacterIcon() + self.RImgRoleSelect.gameObject:SetActiveEx(true) + self.RImgRoleSelect:SetRawImage(characterIcon) + else + self.RImgRoleSelect.gameObject:SetActiveEx(false) + end + self.BtnOccupy:SetButtonState(isMatch and (isOccuy and CS.UiButtonState.Select or CS.UiButtonState.Normal) or CS.UiButtonState.Disable) +end + +function XUiPanelAssignStage:OnBtnBackClick() + self:Close() +end + +function XUiPanelAssignStage:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiPanelAssignStage:OnBtnOccupyClick() + if not self.ChapterData then + return + end + + if not self.IsMatch then + XUiManager.TipMsg(CS.XTextManager.GetText("AssignStageOccupyLock")) -- 未满足驻守条件 + return + end + + XDataCenter.FubenAssignManager.SelectChapterId = self.ChapterData:GetId() + XDataCenter.FubenAssignManager.SelectCharacterId = self.ChapterData:GetCharacterId() + XLuaUiManager.Open("UiAssignOccupy") +end + +function XUiPanelAssignStage:OnBtnTreasureClick() + if not self.ChapterData then + return + end + -- 领奖 + XDataCenter.FubenAssignManager.AssignGetRewardRequest(self.ChapterId, function() + self:Refresh() + end) +end + +function XUiPanelAssignStage:OnDetailShow(grid) + self.DefaultContentPosX = self.PanelStageContent.localPosition.x + self.PanelAsset.GameObject:SetActiveEx(false) + + self:OpenChildUi("UiAssignStageDetail") + + -- 动画 居中当前grid + self.ScrollRect.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Unrestricted + local gridTf = grid.Parent.gameObject:GetComponent("RectTransform") + local diffX = gridTf.localPosition.x + self.PanelStageContent.localPosition.x + if diffX < XDataCenter.FubenMainLineManager.UiGridChapterMoveMinX or diffX > XDataCenter.FubenMainLineManager.UiGridChapterMoveMaxX then + local tarPosX = XDataCenter.FubenMainLineManager.UiGridChapterMoveTargetX - gridTf.localPosition.x + local tarPos = self.PanelStageContent.localPosition + tarPos.x = tarPosX + XLuaUiManager.SetMask(true) + XUiHelper.DoMove(self.PanelStageContent, tarPos, XDataCenter.FubenMainLineManager.UiGridChapterMoveDuration, XUiHelper.EaseType.Sin, function() + XLuaUiManager.SetMask(false) + end) + end +end + +function XUiPanelAssignStage:OnDetailHide() + self.PanelAsset.GameObject:SetActiveEx(true) + + -- 恢复到原来位置 + local tarPos = self.PanelStageContent.localPosition + tarPos.x = self.DefaultContentPosX + XLuaUiManager.SetMask(true) + XUiHelper.DoMove(self.PanelStageContent, tarPos, XDataCenter.FubenMainLineManager.UiGridChapterMoveDuration, XUiHelper.EaseType.Sin, function() + self.ScrollRect.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Elastic + XLuaUiManager.SetMask(false) + end) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiAutoFightDialog/XUiAutoFightDialog.lua b/Resources/Scripts/XUi/XUiAutoFightDialog/XUiAutoFightDialog.lua new file mode 100644 index 00000000..dcc86484 --- /dev/null +++ b/Resources/Scripts/XUi/XUiAutoFightDialog/XUiAutoFightDialog.lua @@ -0,0 +1,148 @@ +local XUiAutoFightDialog = XLuaUiManager.Register(XLuaUi, "UiAutoFightDialog") + +local mathmin = math.min +local mathfloor = math.floor +local tableinsert = table.insert + +local AnimBegin = "AniAutoFightDialogBegin" + +function XUiAutoFightDialog:OnAwake() + self:InitAutoScript() + self:InitTemplate() +end + +function XUiAutoFightDialog:OnStart(stageId) + self:PlayAnimation(AnimBegin) + + self.TxtAutoFight.text = CS.XTextManager.GetText("AutoFightDialogTitle") + self.TxtDescription.text = CS.XTextManager.GetText("AutoFightDialogDescription") + + self.StageId = stageId + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + local autoFightCfg = XAutoFightConfig.GetCfg(stageCfg.AutoFightId) + self.DailyLimit = stageCfg.MaxChallengeNums > 0 and stageCfg.MaxChallengeNums or autoFightCfg.DailyLimit + + local requireAP = stageCfg.RequireActionPoint + local apId = XDataCenter.ItemManager.ItemId.ActionPoint + local apCount = XDataCenter.ItemManager.GetCount(apId) + local max = mathfloor(apCount / requireAP) + local stageData = XDataCenter.FubenManager.GetStageData(stageId) + local passTimesToday = stageData and stageData.PassTimesToday or 0 + local leftTimes = mathmin(max, self.DailyLimit - passTimesToday) + + self.RequireAP = requireAP + self.LeftTimes = leftTimes + self.TxtTimes.text = leftTimes + self.RecordTime = stageData.LastRecordTime + self:SetFightTimes(1) + + local cardIds = stageData.LastCardIds + if stageCfg.RobotId and #stageCfg.RobotId > 0 then + cardIds = {} + for _,v in pairs(stageCfg.RobotId) do + local charId = XRobotManager.GetCharacterId(v) + tableinsert(cardIds, charId) + end + end + self:InitCharacters(cardIds) +end + +function XUiAutoFightDialog:InitTemplate() + self.Template = self.PanelCharacters:Find("CharacterTemplate") +end + +function XUiAutoFightDialog:InitCharacters(characterIds) + local index = 0 + for _, id in pairs(characterIds) do + if id > 0 then + index = index + 1 + local transform + if index == 1 then + transform = self.Template + else + transform = CS.UnityEngine.Object.Instantiate(self.Template, self.PanelCharacters) + end + + local img = transform:Find("RImgIcon"):GetComponent("RawImage") + local icon = XDataCenter.CharacterManager.GetCharRoundnessHeadIcon(id) + img:SetRawImage(icon) + end + end +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiAutoFightDialog:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiAutoFightDialog:AutoInitUi() + self.PanelAutoFightDialog = self.Transform:Find("SafeAreaContentPane/PanelAutoFightDialog") + self.PanelConsume = self.Transform:Find("SafeAreaContentPane/PanelAutoFightDialog/PanelConsume") + self.TxtTime = self.Transform:Find("SafeAreaContentPane/PanelAutoFightDialog/PanelConsume/TxtTime"):GetComponent("Text") + self.TxtTimes = self.Transform:Find("SafeAreaContentPane/PanelAutoFightDialog/PanelConsume/TxtTimes"):GetComponent("Text") + self.TxtConsume = self.Transform:Find("SafeAreaContentPane/PanelAutoFightDialog/PanelConsume/TxtConsume"):GetComponent("Text") + self.PanelTxt = self.Transform:Find("SafeAreaContentPane/PanelAutoFightDialog/PanelTxt") + self.TxtAutoFight = self.Transform:Find("SafeAreaContentPane/PanelAutoFightDialog/PanelTxt/TxtAutoFight"):GetComponent("Text") + self.TxtDescription = self.Transform:Find("SafeAreaContentPane/PanelAutoFightDialog/PanelTxt/TxtDescription"):GetComponent("Text") + self.PanelTeam = self.Transform:Find("SafeAreaContentPane/PanelAutoFightDialog/PanelTeam") + self.PanelCharacters = self.Transform:Find("SafeAreaContentPane/PanelAutoFightDialog/PanelTeam/PanelCharacters") + self.PanelBtn = self.Transform:Find("SafeAreaContentPane/PanelAutoFightDialog/PanelBtn") + self.TxtFightTimes = self.Transform:Find("SafeAreaContentPane/PanelAutoFightDialog/PanelBtn/TxtFightTimes"):GetComponent("Text") + self.BtnSub = self.Transform:Find("SafeAreaContentPane/PanelAutoFightDialog/PanelBtn/BtnSub"):GetComponent("Button") + self.BtnAdd = self.Transform:Find("SafeAreaContentPane/PanelAutoFightDialog/PanelBtn/BtnAdd"):GetComponent("Button") + self.BtnStart = self.Transform:Find("SafeAreaContentPane/PanelAutoFightDialog/PanelBtn/BtnStart"):GetComponent("Button") + self.BtnClose = self.Transform:Find("SafeAreaContentPane/BtnClose"):GetComponent("Button") +end + +function XUiAutoFightDialog:AutoAddListener() + self:RegisterClickEvent(self.BtnSub, self.OnBtnSubClick) + self:RegisterClickEvent(self.BtnAdd, self.OnBtnAddClick) + self:RegisterClickEvent(self.BtnStart, self.OnBtnStartClick) + self:RegisterClickEvent(self.BtnClose, self.OnBtnCloseClick) +end +-- auto +function XUiAutoFightDialog:OnBtnCloseClick() + self:Close() +end + +function XUiAutoFightDialog:OnBtnSubClick() + local tempTimes = self.FightTimes - 1 + if tempTimes < 1 then + return + end + + self:SetFightTimes(tempTimes) +end + +function XUiAutoFightDialog:OnBtnAddClick() + local tempTimes = self.FightTimes + 1 + if tempTimes > self.LeftTimes then + return + end + + self:SetFightTimes(tempTimes) +end + +function XUiAutoFightDialog:OnBtnStartClick() + if self.FightTimes == 0 then + return + end + + local stageId = self.StageId + local times = self.FightTimes + XDataCenter.AutoFightManager.StartAutoFight(stageId, times, function(res) + if res.Code == XCode.Success then + self:Close() + XLuaUiManager.Open("UiAutoFightTip") + end + end) +end + +function XUiAutoFightDialog:SetFightTimes(value) + self.FightTimes = value + self.TxtFightTimes.text = value + self.TxtConsume.text = value * self.RequireAP + self.TxtTime.text = XUiHelper.GetTime(self.RecordTime * value, XUiHelper.TimeFormatType.DRAW) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiAutoFightDialog/XUiImgIcon.lua b/Resources/Scripts/XUi/XUiAutoFightDialog/XUiImgIcon.lua new file mode 100644 index 00000000..955c9b02 --- /dev/null +++ b/Resources/Scripts/XUi/XUiAutoFightDialog/XUiImgIcon.lua @@ -0,0 +1,41 @@ +local XUiImgIcon = XClass(nil, "XUiImgIcon") + +function XUiImgIcon:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self:InitAutoScript() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiImgIcon:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiImgIcon:AutoInitUi() + self.ImgIcon = self.Transform:GetComponent("Image") +end + +function XUiImgIcon:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiImgIcon:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiImgIcon:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiImgIcon:AutoAddListener() +end +-- auto + +return XUiImgIcon diff --git a/Resources/Scripts/XUi/XUiAutoFightDialog/XUiPanelBtn.lua b/Resources/Scripts/XUi/XUiAutoFightDialog/XUiPanelBtn.lua new file mode 100644 index 00000000..9d10f846 --- /dev/null +++ b/Resources/Scripts/XUi/XUiAutoFightDialog/XUiPanelBtn.lua @@ -0,0 +1,59 @@ +local XUiPanelBtn = XClass(nil, "XUiPanelBtn") + +function XUiPanelBtn:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self:InitAutoScript() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelBtn:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiPanelBtn:AutoInitUi() + self.TxtFightTimes = self.Transform:Find("TxtFightTimes"):GetComponent("Text") + self.BtnSub = self.Transform:Find("BtnSub"):GetComponent("Button") + self.BtnAdd = self.Transform:Find("BtnAdd"):GetComponent("Button") + self.BtnStart = self.Transform:Find("BtnStart"):GetComponent("Button") +end + +function XUiPanelBtn:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelBtn:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelBtn:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelBtn:AutoAddListener() + self:RegisterClickEvent(self.BtnSub, self.OnBtnSubClick) + self:RegisterClickEvent(self.BtnAdd, self.OnBtnAddClick) + self:RegisterClickEvent(self.BtnStart, self.OnBtnStartClick) +end +-- auto + +function XUiPanelBtn:OnBtnSubClick() + +end + +function XUiPanelBtn:OnBtnAddClick() + +end + +function XUiPanelBtn:OnBtnStartClick() + +end + +return XUiPanelBtn \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiAutoFightList/XUiAutoFightList.lua b/Resources/Scripts/XUi/XUiAutoFightList/XUiAutoFightList.lua new file mode 100644 index 00000000..8c8222df --- /dev/null +++ b/Resources/Scripts/XUi/XUiAutoFightList/XUiAutoFightList.lua @@ -0,0 +1,117 @@ +local XUiAutoFightList = XLuaUiManager.Register(XLuaUi, "UiAutoFightList") +local XUiAutoFightRecord = require("XUi/XUiAutoFightList/XUiAutoFightRecord") + +local tableinsert = table.insert +local tableremove = table.remove + +local AnimBegin = "AniAutoFightListBegin" +local AnimEnd = "AniAutoFightListEnd" + +function XUiAutoFightList:OnAwake() + self:InitAutoScript() + self:InitTemplate() +end + +function XUiAutoFightList:OnStart() + self:InitRecords() + + local beginCallback = function() + XLuaUiManager.SetMask(true) + end + + local finishCallBack = function() + XLuaUiManager.SetMask(false) + end + + self:PlayAnimation(AnimBegin, finishCallBack, beginCallback) +end + +function XUiAutoFightList:OnEnable() +end + +function XUiAutoFightList:OnDisable() +end + +function XUiAutoFightList:OnDestroy() +end + +function XUiAutoFightList:OnGetEvents() + return nil +end + +function XUiAutoFightList:OnNotify() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiAutoFightList:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiAutoFightList:AutoInitUi() + self.BtnClose = self.Transform:Find("SafeAreaContentPane/BtnClose"):GetComponent("Button") +end + +function XUiAutoFightList:AutoAddListener() + self:RegisterClickEvent(self.BtnClose, self.OnBtnCloseClick) +end +-- auto +function XUiAutoFightList:OnBtnCloseClick() + self.BtnClose.interactable = false + + for _, v in pairs(self.UiRecords) do + v:OnDestroy() + end + + local beginCallback = function() + XLuaUiManager.SetMask(true) + end + + local finishCallBack = function() + XLuaUiManager.SetMask(false) + self:Remove() + end + + self:PlayAnimation(AnimEnd, finishCallBack, beginCallback) +end + +function XUiAutoFightList:InitTemplate() + self.Container = self.Transform:Find("SafeAreaContentPane/PanelAutoFight/ScrollView/Viewport/Content") + self.Template = self.Transform:Find("SafeAreaContentPane/PanelAutoFight/ScrollView/Viewport/Content/AutoFightTemplate") + self.Template.gameObject:SetActive(false) +end + +function XUiAutoFightList:InitRecords() + self.Records = XDataCenter.AutoFightManager.GetRecords() + self.UiRecords = {} + for index, record in pairs(self.Records) do + self:NewRecord(index, record) + end +end + +function XUiAutoFightList:NewRecord(index, record) + local transform = CS.UnityEngine.Object.Instantiate(self.Template, self.Container) + local uiRecord = XUiAutoFightRecord.New(transform, self) + uiRecord:SetData(index, record, function(idx) + self:RemoveRecord(idx) + end) + tableinsert(self.UiRecords, uiRecord) +end + +function XUiAutoFightList:RemoveRecord(index) + local removeUiRecord = self.UiRecords[index] + removeUiRecord:OnDestroy() + CS.UnityEngine.Object.Destroy(removeUiRecord.GameObject) + + local max = #self.UiRecords - 1 + for i = index, max do + self.UiRecords[i] = self.UiRecords[i + 1] + self.UiRecords[i]:SetIndex(i) + end + tableremove(self.UiRecords, #self.UiRecords) + + if max == 0 then + self:OnBtnCloseClick() + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiAutoFightList/XUiAutoFightRecord.lua b/Resources/Scripts/XUi/XUiAutoFightList/XUiAutoFightRecord.lua new file mode 100644 index 00000000..30e51a28 --- /dev/null +++ b/Resources/Scripts/XUi/XUiAutoFightList/XUiAutoFightRecord.lua @@ -0,0 +1,147 @@ +local XUiAutoFightRecord = XClass(nil, "XUiAutoFightRecord") + +local stringformat = string.format +local tableinsert = table.insert + +local AnimName = "AniAutoFightTemplate" + +function XUiAutoFightRecord:Ctor(ui, parent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Parent = parent + self:InitAutoScript() +end + +function XUiAutoFightRecord:SetData(index, record, onRemove) + self:SetIndex(index) + self:SetStageType(record) + self.Record = record + self.OnRemove = onRemove + self.TxtStageName.text = XDataCenter.FubenManager.GetStageName(record.StageId) + self.TimerName = "AutoFightRecord" .. index + self:InitCharacters() + self:BindTimer() + self.GameObject:SetActive(true) +end + +function XUiAutoFightRecord:SetIndex(index) + self.Index = index + self.TxtIndex.text = stringformat("%02d", index) +end + +-- 新增接口,加入前传类型,默认主线 +function XUiAutoFightRecord:SetStageType(record) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(record.StageId) + if stageInfo.Type == XDataCenter.FubenManager.StageType.Prequel then + self.TxtStageType.text = CS.XTextManager.GetText("AutoFightStagePrequelType") + else + self.TxtStageType.text = CS.XTextManager.GetText("AutoFightStageMainType") + end +end + +function XUiAutoFightRecord:InitCharacters() + local stageCfg = XDataCenter.FubenManager.GetStageCfg(self.Record.StageId) + local cardIds = self.Record.CardIds + if stageCfg.RobotId and #stageCfg.RobotId > 0 then + cardIds = {} + for _, v in pairs(stageCfg.RobotId) do + local charId = XRobotManager.GetCharacterId(v) + tableinsert(cardIds, charId) + end + end + for i, id in pairs(cardIds) do + if id > 0 then + local transform + if i == 1 then + transform = self.CharacterTemplate + else + transform = CS.UnityEngine.Object.Instantiate(self.CharacterTemplate, self.PanelCharacters) + end + + local img = transform:Find("RImgIcon"):GetComponent("RawImage") + local icon = XDataCenter.CharacterManager.GetCharRoundnessHeadIcon(id) + img:SetRawImage(icon) + end + end +end + +function XUiAutoFightRecord:BindTimer() + local now = XTime.GetServerNowTimestamp() + local remainTime = self.Record.CompleteTime - now + local complete = remainTime <= 0 + self:SetState(complete) + XCountDown.CreateTimer(self.TimerName, remainTime, now) + XCountDown.BindTimer(self.GameObject, self.TimerName, function(v) + if v == 0 then + self.Parent:PlayAnimation(AnimName, function() + self:SetState(true) + end) + self:RemoveTimer() + else + self.TxtCountdown.text = XUiHelper.GetTime(v) + end + end) +end + +function XUiAutoFightRecord:RemoveTimer() + XCountDown.RemoveTimer(self.TimerName) +end + +function XUiAutoFightRecord:SetState(complete) + self.PanelFighting.gameObject:SetActive(not complete) + self.BtnObtain.gameObject:SetActive(complete) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiAutoFightRecord:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiAutoFightRecord:AutoInitUi() + self.TxtIndex = self.Transform:Find("RecordTemplate/TxtIndex"):GetComponent("Text") + self.TxtStageType = self.Transform:Find("RecordTemplate/TxtStageType"):GetComponent("Text") + self.TxtStageName = self.Transform:Find("RecordTemplate/TxtStageName"):GetComponent("Text") + self.BtnObtain = self.Transform:Find("RecordTemplate/BtnObtain"):GetComponent("Button") + self.PanelFighting = self.Transform:Find("RecordTemplate/PanelFighting") + self.TxtCountdown = self.Transform:Find("RecordTemplate/PanelFighting/TxtCountdown"):GetComponent("Text") + self.PanelCharacters = self.Transform:Find("RecordTemplate/PanelCharacters") + self.CharacterTemplate = self.Transform:Find("RecordTemplate/PanelCharacters/CharacterTemplate") +end + +function XUiAutoFightRecord:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiAutoFightRecord:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiAutoFightRecord:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiAutoFightRecord:AutoAddListener() + self:RegisterClickEvent(self.BtnObtain, self.OnBtnObtainClick) +end +-- auto +function XUiAutoFightRecord:OnBtnObtainClick() + XDataCenter.AutoFightManager.ObtainRewards(self.Index, function(res) + if res.Code == XCode.Success then + self.OnRemove(self.Index) + end + end) +end + +function XUiAutoFightRecord:OnDestroy() + self.BtnObtain.interactable = false + self:RemoveTimer() +end + +return XUiAutoFightRecord \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiAutoFightReward/XUiAutoFightExp.lua b/Resources/Scripts/XUi/XUiAutoFightReward/XUiAutoFightExp.lua new file mode 100644 index 00000000..b41aef37 --- /dev/null +++ b/Resources/Scripts/XUi/XUiAutoFightReward/XUiAutoFightExp.lua @@ -0,0 +1,47 @@ +local XUiAutoFightExp = XClass(nil, "XUiAutoFightExp") + +local mathfloor = math.floor +local timerManager = CS.XTimerManager +local ticksPerSecond = CS.System.TimeSpan.TicksPerSecond + +function XUiAutoFightExp:Ctor(expBar, expBarReward, startPercent, endPercent, time) + self.ImgExpBar = expBar + self.ImgExpBarReward = expBarReward + self.StartPercent = startPercent + self.EndPercent = endPercent + self.Time = time + self.ImgExpBar.fillAmount = self.StartPercent + self:BindTimer() +end + +function XUiAutoFightExp:BindTimer() + self.StartTime = timerManager.Ticks / ticksPerSecond + self.Timer = timerManager.Add(function() + if not self.ImgExpBar or not self.ImgExpBar:Exist() then + self:RemoveTimer() + return + end + + local time = timerManager.Ticks / ticksPerSecond + local dt = time - self.StartTime + local lerp = dt / self.Time + local cur = self.StartPercent + (self.EndPercent - self.StartPercent) * lerp + if cur > 1 then + self.ImgExpBar.fillAmount = 0 + end + + self.ImgExpBarReward.fillAmount = cur - mathfloor(cur) + + if lerp >= 1 then + self:RemoveTimer() + end + end, 0, 0) +end + +function XUiAutoFightExp:RemoveTimer() + if self.Timer then + timerManager.Remove(self.Timer.Id) + end +end + +return XUiAutoFightExp \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiAutoFightReward/XUiAutoFightReward.lua b/Resources/Scripts/XUi/XUiAutoFightReward/XUiAutoFightReward.lua new file mode 100644 index 00000000..1598a0e7 --- /dev/null +++ b/Resources/Scripts/XUi/XUiAutoFightReward/XUiAutoFightReward.lua @@ -0,0 +1,121 @@ +local XUiAutoFightReward = XLuaUiManager.Register(XLuaUi, "UiAutoFightReward") +local UiCharacter = require("XUi/XUiAutoFightReward/XUiAutoFightRewardCharacter") + +local tableinsert = table.insert + +local AnimBegin = "AniAutoFightRewardBegin" +local AnimEnd = "AniAutoFightRewardEnd" + +function XUiAutoFightReward:OnAwake() + self:InitAutoScript() + self:InitTemplate() +end + +function XUiAutoFightReward:OnStart(cardIds, data) + self.CardIds = cardIds + self.Data = data + + local playerLevel = XPlayer.Level + self.TxtLv.text = playerLevel + self.TxtExp.text = "+" .. data.TeamExp + + for _, id in pairs(cardIds) do + if id > 0 then + self:NewCharacter(id, data.CharacterExp) + end + end + + for _, reward in pairs(data.Rewards) do + self:NewItem(reward) + end + + local playerExp = XPlayer.Exp + local playerMaxExp = XPlayerManager.GetMaxExp(XPlayer.Level) + local expBefore = playerExp - data.TeamExp + self.ImgExpBar.fillAmount = expBefore > 0 and expBefore / playerMaxExp or 0 + self.ImgExpBarReward.fillAmount = playerExp / playerMaxExp + + local beginCallback = function() + XLuaUiManager.SetMask(true) + end + + local finishCallBack = function() + XLuaUiManager.SetMask(false) + end + + self:PlayAnimation(AnimBegin, finishCallBack, beginCallback) +end + +function XUiAutoFightReward:InitTemplate() + self.CharacterContainer = self.PanelCharacters:Find("CharacterContainer") + self.CharacterTemplate = self.CharacterContainer:Find("CharacterTemplate") + self.ItemContainer = self.PanelItems:Find("ScrollView/Viewport/ItemContainer") + self.ItemTemplate = self.ItemContainer:Find("ItemTemplate") +end + +function XUiAutoFightReward:NewCharacter(id, exp) + local transform + if not self.UiCharacters then + transform = self.CharacterTemplate + self.UiCharacters = {} + else + transform = CS.UnityEngine.Object.Instantiate(self.CharacterTemplate, self.CharacterContainer) + end + + local uiCharacter = UiCharacter.New(transform) + uiCharacter:SetData(id, exp) + tableinsert(self.UiCharacters, uiCharacter) +end + +function XUiAutoFightReward:NewItem(data) + local transform + if not self.UiItems then + transform = self.ItemTemplate + self.UiItems = {} + else + transform = CS.UnityEngine.Object.Instantiate(self.ItemTemplate, self.ItemContainer) + end + + local grid = XUiGridCommon.New(self, transform) + grid:Refresh(data) + tableinsert(self.UiItems, grid) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiAutoFightReward:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiAutoFightReward:AutoInitUi() + self.BtnClose = self.Transform:Find("SafeAreaContentPane/BtnClose"):GetComponent("Button") + self.PanelAutoFightReward = self.Transform:Find("SafeAreaContentPane/PanelAutoFightReward") + self.PanelCharacters = self.Transform:Find("SafeAreaContentPane/PanelAutoFightReward/PanelCharacters") + self.PanelCommander = self.Transform:Find("SafeAreaContentPane/PanelAutoFightReward/PanelCommander") + self.TxtLv = self.Transform:Find("SafeAreaContentPane/PanelAutoFightReward/PanelCommander/TxtLv"):GetComponent("Text") + self.TxtExp = self.Transform:Find("SafeAreaContentPane/PanelAutoFightReward/PanelCommander/TxtExp"):GetComponent("Text") + self.ImgExpBarBg = self.Transform:Find("SafeAreaContentPane/PanelAutoFightReward/PanelCommander/ExpBar/ImgExpBarBg"):GetComponent("Image") + self.ImgExpBarReward = self.Transform:Find("SafeAreaContentPane/PanelAutoFightReward/PanelCommander/ExpBar/ImgExpBarReward"):GetComponent("Image") + self.ImgExpBar = self.Transform:Find("SafeAreaContentPane/PanelAutoFightReward/PanelCommander/ExpBar/ImgExpBar"):GetComponent("Image") + self.PanelItems = self.Transform:Find("SafeAreaContentPane/PanelAutoFightReward/PanelItems") +end + +function XUiAutoFightReward:AutoAddListener() + self:RegisterClickEvent(self.BtnClose, self.OnBtnCloseClick) +end +-- auto +function XUiAutoFightReward:OnBtnCloseClick() + self.BtnClose.interactable = false + + local beginCallback = function() + XLuaUiManager.SetMask(true) + end + + local finishCallBack = function() + XLuaUiManager.SetMask(false) + self:Close() + end + + self:PlayAnimation(AnimEnd, finishCallBack, beginCallback) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiAutoFightReward/XUiAutoFightRewardCharacter.lua b/Resources/Scripts/XUi/XUiAutoFightReward/XUiAutoFightRewardCharacter.lua new file mode 100644 index 00000000..3f4432ec --- /dev/null +++ b/Resources/Scripts/XUi/XUiAutoFightReward/XUiAutoFightRewardCharacter.lua @@ -0,0 +1,46 @@ +local XUiAutoFightRewardCharacter = XClass(nil, "XUiAutoFightRewardCharacter") + +function XUiAutoFightRewardCharacter:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self:InitAutoScript() +end + +function XUiAutoFightRewardCharacter:SetData(id, addExp) + self.Id = id + + local character = XDataCenter.CharacterManager.GetCharacter(id) + local level = character and character.Level or 1 + self.TxtLv.text = level + + self.TxtExp.text = "+" .. addExp + + local icon = XDataCenter.CharacterManager.GetCharSmallHeadIcon(id) + self.RImgIcon:SetRawImage(icon) + + local exp = character and character.Exp or 0 + local maxExp = XCharacterConfigs.GetCharMaxLevel(id) + local expBefore = exp - addExp + self.ImgExpBar.fillAmount = expBefore > 0 and expBefore / maxExp or 0 + self.ImgExpBarReward.fillAmount = exp / maxExp +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiAutoFightRewardCharacter:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiAutoFightRewardCharacter:AutoInitUi() + self.RImgIcon = XUiHelper.TryGetComponent(self.Transform, "RImgIcon", "RawImage") + self.TxtLv = XUiHelper.TryGetComponent(self.Transform, "TxtLv", "Text") + self.TxtExp = XUiHelper.TryGetComponent(self.Transform, "TxtExp", "Text") + self.ImgExpBarReward = XUiHelper.TryGetComponent(self.Transform, "ExpBar/ImgExpBarReward", "Image") + self.ImgExpBar = XUiHelper.TryGetComponent(self.Transform, "ExpBar/ImgExpBar", "Image") +end + +function XUiAutoFightRewardCharacter:AutoAddListener() +end +-- auto +return XUiAutoFightRewardCharacter \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiAutoFightTip/XUiAutoFightTip.lua b/Resources/Scripts/XUi/XUiAutoFightTip/XUiAutoFightTip.lua new file mode 100644 index 00000000..59e676bc --- /dev/null +++ b/Resources/Scripts/XUi/XUiAutoFightTip/XUiAutoFightTip.lua @@ -0,0 +1,9 @@ +local XUiAutoFightTip = XLuaUiManager.Register(XLuaUi, "UiAutoFightTip") + +local AnimBegin = "UiAutoFightTipBegin" + +function XUiAutoFightTip:OnStart() + self:PlayAnimation(AnimBegin, function() + self:Close() + end) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiAutoWindow/XUiAutoWindow.lua b/Resources/Scripts/XUi/XUiAutoWindow/XUiAutoWindow.lua new file mode 100644 index 00000000..7085e889 --- /dev/null +++ b/Resources/Scripts/XUi/XUiAutoWindow/XUiAutoWindow.lua @@ -0,0 +1,116 @@ +local XUiAutoWindow = XLuaUiManager.Register(XLuaUi, "UiAutoWindow") + +function XUiAutoWindow:OnAwake() + self:AddListener() +end + +function XUiAutoWindow:OnStart(configId) + self:SetInfo(configId) +end + +function XUiAutoWindow:AddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnCloseClick) + self:RegisterClickEvent(self.BtnGoto, self.OnBtnSkipClick) + self.BtnBigSkin.CallBack = function() self:OnBtnSkipClick() end + self.BtnSpineSkin.CallBack = function() self:OnBtnSkipClick() end +end + +function XUiAutoWindow:OnBtnCloseClick() + self:Close() +end + +function XUiAutoWindow:OnDestroy() + if not self.IsSkip then + XDataCenter.AutoWindowManager.NextAutoWindow() + end +end + +function XUiAutoWindow:OnBtnSkipClick() + if self.ActiveOver then + XUiManager.TipText("ActivityAlreadyOver") + return + end + + if self.Config.SkipURL and self.Config.SkipURL ~= nil then + CS.UnityEngine.Application.OpenURL(self.Config.SkipURL) + elseif self.Config.SkipId and self.Config.SkipId ~= nil then + XFunctionManager.SkipInterface(self.Config.SkipId) + self.IsSkip = true + end + XDataCenter.AutoWindowManager.StopAutoWindow() + self:Close() +end + +function XUiAutoWindow:SetInfo(configId) + self.Config = XAutoWindowConfigs.GetAutoWindowConfig(configId) + self.SkinType = XAutoWindowConfigs.GetAutoWindowSkinType(configId) + + self.PanelBigSkin.gameObject:SetActiveEx(false) + self.PanelBarSkin.gameObject:SetActiveEx(false) + self.PanelSpineSkin.gameObject:SetActiveEx(false) + + if self.SkinType == XAutoWindowConfigs.AutoWindowSkinType.BarSkin then + self.PanelBarSkin.gameObject:SetActiveEx(true) + --self.RImgCharacterBig:SetRawImage(self.Config.CharacterIcon) + self.RImgBg:SetRawImage(self.Config.BgIcon) + elseif self.SkinType == XAutoWindowConfigs.AutoWindowSkinType.BigSkin then + self.PanelBigSkin.gameObject:SetActiveEx(true) + self.RImgBgNormal:SetRawImage(self.Config.BgIcon) + self.RImgBgPress:SetRawImage(self.Config.BgIcon) + elseif self.SkinType == XAutoWindowConfigs.AutoWindowSkinType.SpineSkin then + self.PanelSpineSkin.gameObject:SetActiveEx(true) + self.SpineSkinRoot:LoadPrefab(self.Config.SpineBg) + if self.Config.BgIcon and self.Config.BgIcon ~= "" then + self.RImgUiSpineSkin.gameObject:SetActiveEx(true) + self.RImgUiSpineSkin:SetRawImage(self.Config.BgIcon) + else + self.RImgUiSpineSkin.gameObject:SetActiveEx(false) + end + end + + --local now = XTime.GetServerNowTimestamp() + --local openTime = XTime.ParseToTimestamp(self.Config.OpenTime) + --local closeTime = XTime.ParseToTimestamp(self.Config.CloseTime) + -- + --if now > openTime and now <= closeTime then + self:SetOpenInfo() + --elseif now <= openTime then + -- self:SetCloseInfo(now) + --elseif now > closeTime then + -- self:SetOverInfo(now) + --end +end + +-- 处理活动中 +function XUiAutoWindow:SetOpenInfo() + if self.SkinType == XAutoWindowConfigs.AutoWindowSkinType.BarSkin then + self.PanelNotOpen.gameObject:SetActive(false) + self.PanelOpen.gameObject:SetActive(true) + + --self.TxtOpenTitle.text = self.Config.OpenTitle + --self.TxtOpenTime.text = self.Config.OpenDesc + local scale = (self.Config.SkipURL == nil and self.Config.SkipId <= 0) and CS.UnityEngine.Vector3.zero or CS.UnityEngine.Vector3.one + self.BtnGoto.gameObject.transform.localScale = scale + elseif self.SkinType == XAutoWindowConfigs.AutoWindowSkinType.BigSkin then + self.PanelNotOpen.gameObject:SetActive(false) + self.PanelOpen.gameObject:SetActive(false) + end +end + +-- 处理尚未开启活动 +function XUiAutoWindow:SetCloseInfo(now) + self.PanelNotOpen.gameObject:SetActive(true) + self.PanelOpen.gameObject:SetActive(false) + + --self.TxtTitle.text = self.Config.CloseTitle + --local format = "MM/dd" + --self.TxtOpenDay.text = XTime.TimestampToGameDateTimeString(self.Config.OpenTime, format) + --local leftTime = self.Config.OpenTime - now + --self.TxtLeftTime.text = XUiHelper.GetTime(leftTime, XUiHelper.TimeFormatType.CHALLENGE) +end + +-- 处理活动结束 +function XUiAutoWindow:SetOverInfo() + self.ActiveOver = true + self:SetOpenInfo() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiAwarenessTf/XUiAwarenessTf.lua b/Resources/Scripts/XUi/XUiAwarenessTf/XUiAwarenessTf.lua new file mode 100644 index 00000000..0a5a1ce2 --- /dev/null +++ b/Resources/Scripts/XUi/XUiAwarenessTf/XUiAwarenessTf.lua @@ -0,0 +1,475 @@ +local XUiAwarenessTf = XLuaUiManager.Register(XLuaUi, "UiAwarenessTf") +local XUiGridEquip = require("XUi/XUiEquipAwarenessReplace/XUiGridEquip") +local MAX_MATERIAL_SLOT = 3 +function XUiAwarenessTf:OnAwake() + self:InitAutoScript() +end + + +function XUiAwarenessTf:OnStart(targetTemplateId) + self.TemplateId = targetTemplateId + --当前背包要选择的材料位置(1,2,3) + self.CurSelectPos = 1 + self.CurBagSelectEquipId = { 0, 0, 0 } + --有顺序1(Main),2,3 + self.CurMaterialEquipId = { 0, 0, 0 } + self.MaterialGrid = {} + self.AwarenessTfBagList = {} + self.SuitId = XEquipConfig.GetEquipCfg(self.TemplateId).SuitId + self.EquipIds = XDataCenter.EquipManager.GetEquipIdsBySuitId(self.SuitId) + self.UpSort = true + self:InitTargetInfo() + self:UpdateConformBtn() + self:UpdateMaterialBtn() +end + +function XUiAwarenessTf:OnEnable() +end + + +function XUiAwarenessTf:OnDisable() +end + + +function XUiAwarenessTf:OnDestroy() +end + + +function XUiAwarenessTf:OnGetEvents() + return nil +end + + +function XUiAwarenessTf:OnNotify() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiAwarenessTf:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiAwarenessTf:AutoInitUi() + self.PanelMaterial = self.Transform:Find("SafeAreaContentPane/PanelMaterial") + self.GridMaterial2 = self.Transform:Find("SafeAreaContentPane/PanelMaterial/Material2/GridMaterial2") + self.GridMaterial1 = self.Transform:Find("SafeAreaContentPane/PanelMaterial/Material1/GridMaterial1") + self.BtnSelectMaterial1 = self.Transform:Find("SafeAreaContentPane/PanelMaterial/Material1/BtnSelectMaterial1"):GetComponent("Button") + self.BtnStartTf = self.Transform:Find("SafeAreaContentPane/PanelMaterial/Buttons/BtnStartTf"):GetComponent("Button") + self.BtnDisable = self.Transform:Find("SafeAreaContentPane/PanelMaterial/Buttons/BtnDisable"):GetComponent("Button") + self.BtnSelectMaterial2 = self.Transform:Find("SafeAreaContentPane/PanelMaterial/Material2/BtnSelectMaterial2"):GetComponent("Button") + self.GridMaterial3 = self.Transform:Find("SafeAreaContentPane/PanelMaterial/Material3/GridMaterial3") + self.BtnSelectMaterial3 = self.Transform:Find("SafeAreaContentPane/PanelMaterial/Material3/BtnSelectMaterial3"):GetComponent("Button") + self.GridResult = self.Transform:Find("SafeAreaContentPane/Result/GridResult") + self.ImgGirdStar1 = self.Transform:Find("SafeAreaContentPane/Result/GridResult/Stars/PaneStar1/ImgGirdStar1"):GetComponent("Image") + self.ImgGirdStar2 = self.Transform:Find("SafeAreaContentPane/Result/GridResult/Stars/PaneStar2/ImgGirdStar2"):GetComponent("Image") + self.ImgGirdStar3 = self.Transform:Find("SafeAreaContentPane/Result/GridResult/Stars/PaneStar3/ImgGirdStar3"):GetComponent("Image") + self.ImgGirdStar4 = self.Transform:Find("SafeAreaContentPane/Result/GridResult/Stars/PaneStar4/ImgGirdStar4"):GetComponent("Image") + self.ImgGirdStar5 = self.Transform:Find("SafeAreaContentPane/Result/GridResult/Stars/PaneStar5/ImgGirdStar5"):GetComponent("Image") + self.ImgGirdStar6 = self.Transform:Find("SafeAreaContentPane/Result/GridResult/Stars/PaneStar6/ImgGirdStar6"):GetComponent("Image") + self.TxtResultName = self.Transform:Find("SafeAreaContentPane/Result/GridResult/TxtResultName"):GetComponent("Text") + self.PanelPos = self.Transform:Find("SafeAreaContentPane/Result/GridResult/PanelPos") + self.TxtResultPos = self.Transform:Find("SafeAreaContentPane/Result/GridResult/PanelPos/TxtResultPos"):GetComponent("Text") + self.TxtResultLevel = self.Transform:Find("SafeAreaContentPane/Result/GridResult/Text/TxtResultLevel"):GetComponent("Text") + self.BtnMainUi = self.Transform:Find("SafeAreaContentPane/PaneTop/BtnMainUi"):GetComponent("Button") + self.BtnBack = self.Transform:Find("SafeAreaContentPane/PaneTop/BtnBack"):GetComponent("Button") + self.RImgResultIcon = self.Transform:Find("SafeAreaContentPane/Result/RImgResultIcon"):GetComponent("RawImage") + self.PanelAwarenessBag = self.Transform:Find("SafeAreaContentPane/PanelAwarenessBag") + self.PanelGrid = self.Transform:Find("SafeAreaContentPane/PanelAwarenessBag/PanelGrid") + self.PanelContent = self.Transform:Find("SafeAreaContentPane/PanelAwarenessBag/PanelGrid/ViewPort/PanelContent") + self.GridAwarenessTfSelect = self.Transform:Find("SafeAreaContentPane/PanelAwarenessBag/PanelGrid/ViewPort/PanelContent/GridAwarenessTfSelect") + self.BtnSortUp = self.Transform:Find("SafeAreaContentPane/PanelAwarenessBag/BtnSortUp"):GetComponent("Button") + self.BtnConfirm = self.Transform:Find("SafeAreaContentPane/PanelAwarenessBag/BtnConfirm"):GetComponent("Button") + self.BtnSortDown = self.Transform:Find("SafeAreaContentPane/PanelAwarenessBag/BtnSortDown"):GetComponent("Button") + self.BtnCancel = self.Transform:Find("SafeAreaContentPane/PanelAwarenessBag/BtnCancel"):GetComponent("Button") + self.PanelEmpty = self.Transform:Find("SafeAreaContentPane/PanelAwarenessBag/PanelEmpty") +end + +function XUiAwarenessTf:AutoAddListener() + self:RegisterClickEvent(self.BtnSelectMaterial1, self.OnBtnSelectMaterial1Click) + self:RegisterClickEvent(self.BtnStartTf, self.OnBtnStartTfClick) + self:RegisterClickEvent(self.BtnDisable, self.OnBtnDisableClick) + self:RegisterClickEvent(self.BtnSelectMaterial2, self.OnBtnSelectMaterial2Click) + self:RegisterClickEvent(self.BtnSelectMaterial3, self.OnBtnSelectMaterial3Click) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnSortUp, self.OnBtnSortUpClick) + self:RegisterClickEvent(self.BtnConfirm, self.OnBtnConfirmClick) + self:RegisterClickEvent(self.BtnSortDown, self.OnBtnSortDownClick) + self:RegisterClickEvent(self.BtnCancel, self.OnBtnCancelClick) +end +-- auto +function XUiAwarenessTf:OnBtnSelectMaterial1Click() + self:StartSelectMaterial(1) +end + +function XUiAwarenessTf:OnBtnSelectMaterial2Click() + self:StartSelectMaterial(2) +end + +function XUiAwarenessTf:OnBtnSelectMaterial3Click() + self:StartSelectMaterial(3) +end + +function XUiAwarenessTf:OnBtnCancelClick() + self.CurBagSelectEquipId = { 0, 0, 0 } + self.PanelAwarenessBag.gameObject:SetActive(false) +end + +function XUiAwarenessTf:OnBtnSortDownClick() + self:SortMaterial(true) + self:UpdateBagItem() + self:UpdateBagSelectMark() +end + +function XUiAwarenessTf:OnBtnStartTfClick() + local tfCb = function(equipData) + XLuaUiManager.Open("UiAwarenessTfResult", equipData.Id, self:ClearSelect()) + end + local okCb = function() + local site = XGoodsCommonManager.GetGoodsShowParamsByTemplateId(self.TemplateId).Site + XDataCenter.EquipManager.AwarenessTransform(self.SuitId, site, self.CurMaterialEquipId, tfCb) + end + + local title = CS.XTextManager.GetText("AwarenessTfConfirmTitle") + local hasResonanced = false + for i = 1, MAX_MATERIAL_SLOT do + local resonanceSkillNum = XDataCenter.EquipManager.GetResonanceSkillNum(self.CurMaterialEquipId[i]) + for j = 1, resonanceSkillNum do + if XDataCenter.EquipManager.CheckEquipPosResonanced(self.CurMaterialEquipId[i], j) then + hasResonanced = true + end + end + end + local content + if hasResonanced then + content = CS.XTextManager.GetText("AwarenessTfConfirmContentResonance") + else + content = CS.XTextManager.GetText("AwarenessTfConfirmContent") + end + XLuaUiManager.Open("UiDialog", title, content, XUiManager.DialogType.Normal, nil, okCb) +end + +function XUiAwarenessTf:OnBtnDisableClick() + local text = CS.XTextManager.GetText("AwarenessTfMaterialError") + XUiManager.TipMsg(text, XUiManager.UiTipType.Tip) +end + +function XUiAwarenessTf:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiAwarenessTf:OnBtnBackClick() + self:Close() +end + +function XUiAwarenessTf:OnBtnSortUpClick() + self:SortMaterial(false) + self:UpdateBagItem() + self:UpdateBagSelectMark() +end +--确认背包选择按钮 +function XUiAwarenessTf:OnBtnConfirmClick() + --改变了主材料清空副材料 + if self.CurSelectPos == 1 then + if self.CurMaterialEquipId[1] ~= self.CurBagSelectEquipId[1] then + self.CurMaterialEquipId[1] = self.CurBagSelectEquipId[1] + self.CurMaterialEquipId[2] = 0 + self.CurBagSelectEquipId[2] = 0 + self.CurMaterialEquipId[3] = 0 + self.CurBagSelectEquipId[3] = 0 + end + else + for i = 2, MAX_MATERIAL_SLOT do + self.CurMaterialEquipId[i] = self.CurBagSelectEquipId[i] + end + end + self:UpdateMaterialBtn() + self.PanelAwarenessBag.gameObject:SetActive(false) + self:UpdateTargetLevel() +end + + +function XUiAwarenessTf:InitTargetInfo() + self.PanelAwarenessBag.gameObject:SetActive(false) + self:UpdateBaseInfo() + self:UpdateStar() +end + +--星星 +function XUiAwarenessTf:UpdateStar() + local star = XDataCenter.EquipManager.GetEquipStar(self.TemplateId) + for i = 1, XEquipConfig.MAX_STAR_COUNT do + if self["ImgGirdStar" .. i] then + if i <= star then + self["ImgGirdStar" .. i].gameObject:SetActive(true) + else + self["ImgGirdStar" .. i].gameObject:SetActive(false) + end + end + end +end + +--基础属性(名字,位置,等级,图标),等级默认1级,有继承在更新 +function XUiAwarenessTf:UpdateBaseInfo() + self.TxtResultName.text = XDataCenter.EquipManager.GetEquipName(self.TemplateId) + self.TxtResultPos.text = XGoodsCommonManager.GetGoodsShowParamsByTemplateId(self.TemplateId).Site + self.TxtResultLevel.text = 1 + local icon = XDataCenter.EquipManager.GetEquipLiHuiPath(self.TemplateId) + self.RImgResultIcon:SetRawImage(icon) +end + +--放入主材料后更新等级显示 +function XUiAwarenessTf:UpdateTargetLevel() + if self.CurMaterialEquipId[1] > 0 then + self.TxtResultLevel.text = XDataCenter.EquipManager.GetEquip(self.CurMaterialEquipId[1]).Level + else + self.TxtResultLevel.text = 1 + end +end + +--用于更新改造按钮状态(3个材料都放入) +function XUiAwarenessTf:UpdateConformBtn() + if self.CurMaterialEquipId[1] > 0 and self.CurMaterialEquipId[2] > 0 and self.CurMaterialEquipId[3] > 0 then + self.BtnStartTf.gameObject:SetActive(true) + self.BtnDisable.gameObject:SetActive(false) + else + self.BtnStartTf.gameObject:SetActive(false) + self.BtnDisable.gameObject:SetActive(true) + end +end + +--开始选择材料 +function XUiAwarenessTf:StartSelectMaterial(index) + if index > 1 then + if self.CurMaterialEquipId[1] == 0 then + local text = CS.XTextManager.GetText("AwarenessTfMaterialMainError") + XUiManager.TipMsg(text, XUiManager.UiTipType.Tip) + return + end + end + self.CurSelectPos = index + self:InitMaterialBag() + self.PanelAwarenessBag.gameObject:SetActive(true) +end + +function XUiAwarenessTf:InitMaterialBag() + self.GridAwarenessTfSelect.gameObject:SetActive(false) + + --筛选:去除已穿戴的,锁定的,主材料,与目标同位置的 + self.EquipIds = XDataCenter.EquipManager.GetEquipIdsBySuitId(self.SuitId) + self:FilterMaterial() + --sort(默认升序) + self.UpSort = true + self.BtnSortDown.gameObject:SetActive(false) + self.BtnSortUp.gameObject:SetActive(true) + XDataCenter.EquipManager.SortEquipIdListByPriorType(self.EquipIds) + self:SortMaterial() + --生成Grid + self:UpdateBagItem() + + --设置选中状态 + for i = 1, #self.EquipIds do + if self:IsSelected(self.EquipIds[i]) then + self.AwarenessTfBagList[i]:SetSelected(true) + else + self.AwarenessTfBagList[i]:SetSelected(false) + end + end + --设置已选择的数据 + if self.CurSelectPos == 1 then + return self.CurBagSelectEquipId[1] == self.CurMaterialEquipId[1] + else + for i = 2, MAX_MATERIAL_SLOT do + self.CurBagSelectEquipId[i] = self.CurMaterialEquipId[i] + end + end +end + +function XUiAwarenessTf:UpdateBagSelectMark() + for i = 1, #self.EquipIds do + if self:IsBagSelected(self.EquipIds[i]) then + self.AwarenessTfBagList[i]:SetSelected(true) + else + self.AwarenessTfBagList[i]:SetSelected(false) + end + end +end + +function XUiAwarenessTf:UpdateBagItem() + --init + local clickCb = function(equipId, grid) + if self.CurSelectPos == 1 then + if grid:IsSelected() then + grid:SetSelected(false) + self.CurBagSelectEquipId[self.CurSelectPos] = 0 + else + for _, v in pairs(self.AwarenessTfBagList) do + v:SetSelected(false) + end + grid:SetSelected(true) + self.CurBagSelectEquipId[self.CurSelectPos] = equipId + end + else + if grid:IsSelected() then + grid:SetSelected(false) + if self.CurBagSelectEquipId[2] == equipId then + self.CurBagSelectEquipId[2] = 0 + else + self.CurBagSelectEquipId[3] = 0 + end + else + if self.CurBagSelectEquipId[2] == 0 or self.CurBagSelectEquipId[3] == 0 then + if self.CurBagSelectEquipId[2] == 0 then + self.CurBagSelectEquipId[2] = equipId + elseif self.CurBagSelectEquipId[3] == 0 then + self.CurBagSelectEquipId[3] = equipId + end + grid:SetSelected(true) + else + local text = CS.XTextManager.GetText("AwarenessTfMaterialSelectError") + XUiManager.TipMsg(text, XUiManager.UiTipType.Tip) + end + end + end + end + + for i = 1, #self.EquipIds do + if not self.AwarenessTfBagList[i] then + local tempGo = CS.UnityEngine.Object.Instantiate(self.GridAwarenessTfSelect.gameObject) + tempGo.transform:SetParent(self.PanelContent, false) + self.AwarenessTfBagList[i] = XUiGridEquip.New(tempGo, clickCb, self) + end + self.AwarenessTfBagList[i]:Refresh(self.EquipIds[i]) + self.AwarenessTfBagList[i].GameObject:SetActive(true) + end + + for i = #self.EquipIds + 1, #self.AwarenessTfBagList do + self.AwarenessTfBagList[i].GameObject:SetActive(false) + end + + if #self.EquipIds > 0 then + self.PanelEmpty.gameObject:SetActive(false) + else + self.PanelEmpty.gameObject:SetActive(true) + end +end + +function XUiAwarenessTf:IsSelected(equipId) + if self.CurSelectPos == 1 then + return self.CurMaterialEquipId[1] == equipId + end + for i = 2, MAX_MATERIAL_SLOT do + if self.CurMaterialEquipId[i] == equipId then + return true + end + end + return false +end + +function XUiAwarenessTf:IsBagSelected(equipId) + if self.CurSelectPos == 1 then + return self.CurBagSelectEquipId[1] == equipId + end + for i = 2, MAX_MATERIAL_SLOT do + if self.CurBagSelectEquipId[i] == equipId then + return true + end + end + return false +end + +--更新3个材料槽状态 +function XUiAwarenessTf:UpdateMaterialBtn() + for i = 1, MAX_MATERIAL_SLOT do + if self.CurMaterialEquipId[i] > 0 then + self["GridMaterial" .. i].gameObject:SetActive(true) + self["BtnSelectMaterial" .. i].gameObject:SetActive(false) + else + self["GridMaterial" .. i].gameObject:SetActive(false) + self["BtnSelectMaterial" .. i].gameObject:SetActive(true) + end + end + self:UpdateMaterialGrid() + self:UpdateConformBtn() +end + +function XUiAwarenessTf:SortMaterial(upSort) + if upSort ~= nil then + self.UpSort = upSort + end + if self.UpSort then + self.BtnSortDown.gameObject:SetActive(false) + self.BtnSortUp.gameObject:SetActive(true) + else + self.BtnSortDown.gameObject:SetActive(true) + self.BtnSortUp.gameObject:SetActive(false) + end + + XTool.ReverseList(self.EquipIds) + +--[[ table.sort(self.EquipIds, function(a, b) + if self.UpSort then + return XDataCenter.EquipManager.GetEquip(a).Level < XDataCenter.EquipManager.GetEquip(b).Level + else + return XDataCenter.EquipManager.GetEquip(a).Level > XDataCenter.EquipManager.GetEquip(b).Level + end + end) + --]] +end + +function XUiAwarenessTf:FilterMaterial() + local removeIds = {} + for k, v in pairs(self.EquipIds) do + --已穿戴的 + if XDataCenter.EquipManager.IsWearing(v) then + removeIds[k] = true + end + --锁定的 + if XDataCenter.EquipManager.IsLock(v) then + removeIds[k] = true + end + --主材料 + if self.CurMaterialEquipId[1] > 0 and v == self.CurMaterialEquipId[1] and self.CurSelectPos ~= 1 then + removeIds[k] = true + end + --同位置的 + local targetPos = XGoodsCommonManager.GetGoodsShowParamsByTemplateId(self.TemplateId).Site + local tempPos = XDataCenter.EquipManager.GetEquipSite(v) + if targetPos == tempPos then + removeIds[k] = true + end + end + for i = #self.EquipIds, 1, -1 do + if removeIds[i] then + table.remove(self.EquipIds, i) + end + end +end + +function XUiAwarenessTf:UpdateMaterialGrid() + local clickCb = function(equipId) + for i = 1, MAX_MATERIAL_SLOT do + if self.CurMaterialEquipId[i] == equipId then + self:StartSelectMaterial(i) + end + end + end + for i = 1, MAX_MATERIAL_SLOT do + if not self.MaterialGrid[i] then + self.MaterialGrid[i] = XUiGridEquip.New(self["GridMaterial" .. i], clickCb, self) + end + if self.CurMaterialEquipId[i] > 0 then + self.MaterialGrid[i]:Refresh(self.CurMaterialEquipId[i]) + end + end +end + + +function XUiAwarenessTf:ClearSelect() + self.CurBagSelectEquipId = { 0, 0, 0 } + self.CurMaterialEquipId = { 0, 0, 0 } + self:InitTargetInfo() + self:UpdateConformBtn() + self:UpdateMaterialBtn() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiAwarenessTf/XUiAwarenessTfBtnPos.lua b/Resources/Scripts/XUi/XUiAwarenessTf/XUiAwarenessTfBtnPos.lua new file mode 100644 index 00000000..db0388e7 --- /dev/null +++ b/Resources/Scripts/XUi/XUiAwarenessTf/XUiAwarenessTfBtnPos.lua @@ -0,0 +1,86 @@ +local XUiAwarenessTfBtnPos = XClass(nil, "XUiAwarenessTfBtnPos") + +--has:是否拥有1个以上该位置的意识 +function XUiAwarenessTfBtnPos:Ctor(ui, pos, posNum, templateId, cb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Pos = pos + self.PosNum = posNum + self.CallBack = cb + self.TemplateId = templateId + self:InitAutoScript() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiAwarenessTfBtnPos:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiAwarenessTfBtnPos:AutoInitUi() + self.TxtPosNum = self.Transform:Find("TxtPosNum"):GetComponent("Text") + self.UiBtnBackHas = self.Transform:Find("UiBtnBackHas") + self.UiBtnBackNone = self.Transform:Find("UiBtnBackNone") + self.UiSelectBG = self.Transform:Find("UiSelectBG") + self.BtnPos = self.Transform:Find("BtnPos"):GetComponent("Button") +end + +function XUiAwarenessTfBtnPos:AutoAddListener() + self.AutoCreateListeners = {} + XUiHelper.RegisterClickEvent(self, self.BtnPos, self.OnBtnPosClick) +end +-- auto +function XUiAwarenessTfBtnPos:GetAutoKey(uiNode, eventName) + if not uiNode then + return + end + return eventName .. uiNode:GetHashCode() +end + +function XUiAwarenessTfBtnPos:RegisterListener(uiNode, eventName, func) + if not uiNode then return end + local key = eventName .. uiNode:GetHashCode() + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiBtnTab:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiAwarenessTfBtnPos:OnBtnPosClick() + if self.CallBack then + self.CallBack(self.Pos) + end +end + +function XUiAwarenessTfBtnPos:Refresh(posNum, templateId) + self.PosNum = posNum + self.TemplateId = templateId + self.TxtPosNum.text = self.PosNum + if XDataCenter.EquipManager.GetEquipCountByTemplateID(self.TemplateId) > 0 then + self.UiBtnBackHas.gameObject:SetActive(true) + self.UiBtnBackNone.gameObject:SetActive(false) + else + self.UiBtnBackHas.gameObject:SetActive(false) + self.UiBtnBackNone.gameObject:SetActive(true) + end +end + +function XUiAwarenessTfBtnPos:Select(select) + self.UiSelectBG.gameObject.SetActive(select) +end + +return XUiAwarenessTfBtnPos \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiAwarenessTf/XUiAwarenessTfChoice.lua b/Resources/Scripts/XUi/XUiAwarenessTf/XUiAwarenessTfChoice.lua new file mode 100644 index 00000000..db28ba7a --- /dev/null +++ b/Resources/Scripts/XUi/XUiAwarenessTf/XUiAwarenessTfChoice.lua @@ -0,0 +1,270 @@ +local XUiAwarenessTfChoice = XLuaUiManager.Register(XLuaUi, "UiAwarenessTfChoice") +local XUiGridSuitDetail = require("XUi/XUiEquipAwarenessReplace/XUiGridSuitDetail") +local XUiAwarenessTfBtnPos = require("XUi/XUiAwarenessTf/XUiAwarenessTfBtnPos") +local MAX_AWARENESS_ATTR_COUNT = 4 --包括了共鸣属性,最大有4条 +function XUiAwarenessTfChoice:OnAwake() + self:InitAutoScript() +end + + +function XUiAwarenessTfChoice:OnStart(suitIds, endTime) + self.SuitIds = suitIds + self.EndTime = endTime + self.PartIds = {} + self.PartList = {} + self.SuitList = {} + self.PartGroupGo = {} + self.PanelSelectSuit.gameObject:SetActive(false) + self.PanelSelectPart.gameObject:SetActive(false) + self.CurSelectPos = 1 + self.CurSelectGrid = nil + self:InitSuitList() +end + + +function XUiAwarenessTfChoice:OnEnable() + if self.EndTime > 0 then + self.PanelCountDownA.gameObject:SetActive(true) + self.PanelCountDownB.gameObject:SetActive(true) + self:SetUpCountDown() + else + self.PanelCountDownA.gameObject:SetActive(false) + self.PanelCountDownB.gameObject:SetActive(false) + end +end + + +function XUiAwarenessTfChoice:OnDisable() +end + + +function XUiAwarenessTfChoice:OnDestroy() + if self.EndTime > 0 then + self:RemoveCountDown() + end +end + + +function XUiAwarenessTfChoice:OnGetEvents() + return nil +end + + +function XUiAwarenessTfChoice:OnNotify() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiAwarenessTfChoice:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiAwarenessTfChoice:AutoInitUi() + self.BtnBack = self.Transform:Find("SafeAreaContentPane/PaneTop/BtnBack"):GetComponent("Button") + self.BtnMainUi = self.Transform:Find("SafeAreaContentPane/PaneTop/BtnMainUi"):GetComponent("Button") + self.PanelSelectSuit = self.Transform:Find("SafeAreaContentPane/PanelSelectSuit") + self.PanelSuitContent = self.Transform:Find("SafeAreaContentPane/PanelSelectSuit/Viewport/PanelSuitContent") + self.GridSuitSimple = self.Transform:Find("SafeAreaContentPane/PanelSelectSuit/Viewport/PanelSuitContent/GridSuitSimple") + self.TxtName = self.Transform:Find("SafeAreaContentPane/PanelSelectSuit/Viewport/PanelSuitContent/GridSuitSimple/TxtName"):GetComponent("Text") + self.RImgIcon = self.Transform:Find("SafeAreaContentPane/PanelSelectSuit/Viewport/PanelSuitContent/GridSuitSimple/RImgIcon"):GetComponent("RawImage") + self.PanelCountDownA = self.Transform:Find("SafeAreaContentPane/PanelSelectSuit/Left/PanelCountDownA") + self.TxtCountDownA = self.Transform:Find("SafeAreaContentPane/PanelSelectSuit/Left/PanelCountDownA/TxtCountDownA"):GetComponent("Text") + self.PanelSelectPart = self.Transform:Find("SafeAreaContentPane/PanelSelectPart") + self.PanelPartGroup = self.Transform:Find("SafeAreaContentPane/PanelSelectPart/PanelPartGroup") + self.UiAwarenessTfBtnPos = self.Transform:Find("SafeAreaContentPane/PanelSelectPart/PanelPartGroup/UiAwarenessTfBtnPos") + self.UiSelectBG = self.Transform:Find("SafeAreaContentPane/PanelSelectPart/PanelPartGroup/UiAwarenessTfBtnPos/UiSelectBG") + self.UiBtnBackNone = self.Transform:Find("SafeAreaContentPane/PanelSelectPart/PanelPartGroup/UiAwarenessTfBtnPos/UiBtnBackNone") + self.UiBtnBackHas = self.Transform:Find("SafeAreaContentPane/PanelSelectPart/PanelPartGroup/UiAwarenessTfBtnPos/UiBtnBackHas") + self.TxtPosNum = self.Transform:Find("SafeAreaContentPane/PanelSelectPart/PanelPartGroup/UiAwarenessTfBtnPos/TxtPosNum"):GetComponent("Text") + self.BtnPos = self.Transform:Find("SafeAreaContentPane/PanelSelectPart/PanelPartGroup/UiAwarenessTfBtnPos/BtnPos"):GetComponent("Button") + self.TxtSuitName = self.Transform:Find("SafeAreaContentPane/PanelSelectPart/TxtSuitName"):GetComponent("Text") + self.PanelCountDownB = self.Transform:Find("SafeAreaContentPane/PanelSelectPart/PanelCountDownB") + self.TxtCountDownB = self.Transform:Find("SafeAreaContentPane/PanelSelectPart/PanelCountDownB/TxtCountDownB"):GetComponent("Text") + self.PanelAttrParent = self.Transform:Find("SafeAreaContentPane/PanelSelectPart/GameObject/PanelAttrParent") + self.PanelAttr1 = self.Transform:Find("SafeAreaContentPane/PanelSelectPart/GameObject/PanelAttrParent/PanelAttr1") + self.TxtName1 = self.Transform:Find("SafeAreaContentPane/PanelSelectPart/GameObject/PanelAttrParent/PanelAttr1/TxtName1"):GetComponent("Text") + self.TxtAttr1 = self.Transform:Find("SafeAreaContentPane/PanelSelectPart/GameObject/PanelAttrParent/PanelAttr1/TxtAttr1"):GetComponent("Text") + self.PanelAttr2 = self.Transform:Find("SafeAreaContentPane/PanelSelectPart/GameObject/PanelAttrParent/PanelAttr2") + self.TxtName2 = self.Transform:Find("SafeAreaContentPane/PanelSelectPart/GameObject/PanelAttrParent/PanelAttr2/TxtName2"):GetComponent("Text") + self.TxtAttr2 = self.Transform:Find("SafeAreaContentPane/PanelSelectPart/GameObject/PanelAttrParent/PanelAttr2/TxtAttr2"):GetComponent("Text") + self.PanelAttr3 = self.Transform:Find("SafeAreaContentPane/PanelSelectPart/GameObject/PanelAttrParent/PanelAttr3") + self.TxtName3 = self.Transform:Find("SafeAreaContentPane/PanelSelectPart/GameObject/PanelAttrParent/PanelAttr3/TxtName3"):GetComponent("Text") + self.TxtAttr3 = self.Transform:Find("SafeAreaContentPane/PanelSelectPart/GameObject/PanelAttrParent/PanelAttr3/TxtAttr3"):GetComponent("Text") + self.PanelAttr4 = self.Transform:Find("SafeAreaContentPane/PanelSelectPart/GameObject/PanelAttrParent/PanelAttr4") + self.TxtName4 = self.Transform:Find("SafeAreaContentPane/PanelSelectPart/GameObject/PanelAttrParent/PanelAttr4/TxtName4"):GetComponent("Text") + self.TxtAttr4 = self.Transform:Find("SafeAreaContentPane/PanelSelectPart/GameObject/PanelAttrParent/PanelAttr4/TxtAttr4"):GetComponent("Text") + self.BtnCancle = self.Transform:Find("SafeAreaContentPane/PanelSelectPart/BtnCancle"):GetComponent("Button") + self.PanelContent = self.Transform:Find("SafeAreaContentPane/PanelSelectPart/SuitDis/PanelContent") + self.TxtSkillDes1 = self.Transform:Find("SafeAreaContentPane/PanelSelectPart/SuitDis/PanelContent/TxtSkillDes1"):GetComponent("Text") + self.TxtSkillDes2 = self.Transform:Find("SafeAreaContentPane/PanelSelectPart/SuitDis/PanelContent/TxtSkillDes2"):GetComponent("Text") + self.TxtSkillDes3 = self.Transform:Find("SafeAreaContentPane/PanelSelectPart/SuitDis/PanelContent/TxtSkillDes3"):GetComponent("Text") + self.PanelSelectAwareness = self.Transform:Find("SafeAreaContentPane/PanelSelectPart/PanelSelectAwareness") + self.TxtPosNum = self.Transform:Find("SafeAreaContentPane/PanelSelectPart/PanelSelectAwareness/TxtPosNum"):GetComponent("Text") + self.TxtNum = self.Transform:Find("SafeAreaContentPane/PanelSelectPart/PanelSelectAwareness/TxtNum"):GetComponent("Text") + self.GridCurSelectPart = self.Transform:Find("SafeAreaContentPane/PanelSelectPart/PanelSelectAwareness/GridCurSelectPart") + self.RImgIconA = self.Transform:Find("SafeAreaContentPane/PanelSelectPart/PanelSelectAwareness/GridCurSelectPart/RImgIcon"):GetComponent("RawImage") + self.BtnConfirm = self.Transform:Find("SafeAreaContentPane/PanelSelectPart/BtnConfirm"):GetComponent("Button") +end + +function XUiAwarenessTfChoice:AutoAddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:RegisterClickEvent(self.BtnPos, self.OnBtnPosClick) + self:RegisterClickEvent(self.BtnCancle, self.OnBtnCancleClick) + self:RegisterClickEvent(self.BtnConfirm, self.OnBtnConfirmClick) +end +-- auto + +function XUiAwarenessTfChoice:OnBtnPosClick() + +end + +function XUiAwarenessTfChoice:OnBtnCancleClick() + self.PanelSelectPart.gameObject:SetActive(false) +end + +function XUiAwarenessTfChoice:OnBtnConfirmClick() + self.PanelSelectPart.gameObject:SetActive(false) + XLuaUiManager.Open("UiAwarenessTf", self.PartIds[self.CurSelectPos]) +end + +function XUiAwarenessTfChoice:OnBtnBackClick() + self:Close() +end + +function XUiAwarenessTfChoice:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + + +function XUiAwarenessTfChoice:InitSuitList() + self.GridSuitSimple.gameObject:SetActive(false) + self.PanelSelectSuit.gameObject:SetActive(true) + + local clickCb = function(suitId, grid) + self:OnSuitGridClick(suitId, grid) + end + + for i = 1, #self.SuitIds do + if not self.SuitList[i] then + local tempGo = CS.UnityEngine.Object.Instantiate(self.GridSuitSimple.gameObject) + tempGo.transform:SetParent(self.PanelSuitContent, false) + self.SuitList[i] = XUiGridSuitDetail.New(tempGo, self, clickCb) + end + self.SuitList[i]:Refresh(self.SuitIds[i], nil, true) + self.SuitList[i].GameObject:SetActive(true) + end + + for i = #self.SuitIds + 1, #self.SuitList do + self.SuitList[i].GameObject:SetActive(false) + end +end + +function XUiAwarenessTfChoice:OnSuitGridClick(suitId) + self:InitSelectPart(suitId) + self.PanelSelectPart.gameObject:SetActive(true) +end + +function XUiAwarenessTfChoice:OnSelectPart(pos) + for i = 1, #self.PartIds do + if i == pos then + self.PartList[i].UiSelectBG.gameObject:SetActive(true) + else + self.PartList[i].UiSelectBG.gameObject:SetActive(false) + end + end + self.CurSelectPos = pos + self:UpdateSelectPos() +end + +function XUiAwarenessTfChoice:InitSelectPart(suitId) + self.UiAwarenessTfBtnPos.gameObject:SetActive(false) + local cb = function(pos) + self:OnSelectPart(pos) + end + --套装名字 + self.TxtSuitName.text = XDataCenter.EquipManager.GetSuitName(suitId) + --套装效果 + local skillDesList = XDataCenter.EquipManager.GetSuitSkillDesList(suitId) + for i = 1, XEquipConfig.MAX_SUIT_SKILL_COUNT do + if skillDesList[i * 2] then + self["TxtSkillDes" .. i].text = skillDesList[i * 2] + self["TxtSkillDes" .. i].gameObject:SetActive(true) + else + self["TxtSkillDes" .. i].gameObject:SetActive(false) + end + end + --部位选择 + --获取数据 + self.PartIds = XDataCenter.EquipManager.GetEquipTemplateIdsBySuitId(suitId) + table.sort(self.PartIds, function(a, b) + local aid = XGoodsCommonManager.GetGoodsShowParamsByTemplateId(a) + local bid = XGoodsCommonManager.GetGoodsShowParamsByTemplateId(b) + return aid.Site < bid.Site + end) + self.PartSiteIds = {} + for i = 1, #self.PartIds do + self.PartSiteIds[i] = XGoodsCommonManager.GetGoodsShowParamsByTemplateId(self.PartIds[i]).Site + end + --生成按钮 + for i = 1, #self.PartIds do + if not self.PartList[i] then + local tempGo = CS.UnityEngine.Object.Instantiate(self.UiAwarenessTfBtnPos.gameObject) + tempGo.transform:SetParent(self.PanelPartGroup, false) + tempGo.gameObject:SetActive(true) + self.PartList[i] = XUiAwarenessTfBtnPos.New(tempGo, i, self.PartSiteIds[i], self.PartIds[i], cb) + end + self.PartList[i].GameObject:SetActive(true) + end + + for i = #self.PartIds + 1, #self.PartList do + self.PartList[i].GameObject:SetActive(false) + end + --初始化按钮 + for i = 1, #self.PartIds do + self.PartList[i]:Refresh(self.PartSiteIds[i], self.PartIds[i]) + end + --默认选择1号 + self:OnSelectPart(1) +end +--更新中间的Grid +function XUiAwarenessTfChoice:UpdateSelectPos() + if not self.CurSelectGrid then + self.CurSelectGrid = XUiGridCommon.New(self, self.GridCurSelectPart) + end + self.CurSelectGrid:Refresh(self.PartIds[self.CurSelectPos]) + self.TxtPosNum.text = CS.XTextManager.GetText("AwarenessTfPos", self.PartSiteIds[self.CurSelectPos]) + self.TxtNum.text = XDataCenter.EquipManager.GetEquipCountByTemplateID(self.PartIds[self.CurSelectPos]) + self:UpdateEquipAttr() +end + +--更新属性(未获取只能显示1级的属性) +function XUiAwarenessTfChoice:UpdateEquipAttr() + local attrCount = 1 + local attrMap = XDataCenter.EquipManager.GetTemplateEquipAttrMap(self.PartIds[self.CurSelectPos], 1) + for _, attrInfo in pairs(attrMap) do + if attrCount > MAX_AWARENESS_ATTR_COUNT then break end + self["TxtName" .. attrCount].text = attrInfo.Name + self["TxtAttr" .. attrCount].text = attrInfo.Value + self["PanelAttr" .. attrCount].gameObject:SetActive(true) + attrCount = attrCount + 1 + end + for i = attrCount, MAX_AWARENESS_ATTR_COUNT do + self["PanelAttr" .. i].gameObject:SetActive(false) + end +end + +--设置倒计时 +function XUiAwarenessTfChoice:SetUpCountDown() + local remainTime = self.EndTime - XTime.GetServerNowTimestamp() + XCountDown.CreateTimer(self.GameObject.name, remainTime) + XCountDown.BindTimer(self.GameObject, self.GameObject.name, function(v) + + self.TxtCountDownA.text = XUiHelper.GetTime(v, XUiHelper.TimeFormatType.DRAW) + self.TxtCountDownB.text = self.TxtCountDownA.text + end) +end +function XUiAwarenessTfChoice:RemoveCountDown() + XCountDown.RemoveTimer(self.Name) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiAwarenessTf/XUiAwarenessTfResult.lua b/Resources/Scripts/XUi/XUiAwarenessTf/XUiAwarenessTfResult.lua new file mode 100644 index 00000000..8e3864ae --- /dev/null +++ b/Resources/Scripts/XUi/XUiAwarenessTf/XUiAwarenessTfResult.lua @@ -0,0 +1,145 @@ +local XUiAwarenessTfResult = XLuaUiManager.Register(XLuaUi, "UiAwarenessTfResult") +local MAX_AWARENESS_ATTR_COUNT = 4 +function XUiAwarenessTfResult:OnAwake() + self:InitAutoScript() +end + + +function XUiAwarenessTfResult:OnStart(equipId, cb) + self.EquipId = equipId + self.Cb = cb + self.TemplateId = XDataCenter.EquipManager.GetEquipTemplateId(self.EquipId) + self:UpdateInfo() +end + + +function XUiAwarenessTfResult:OnEnable() +end + + +function XUiAwarenessTfResult:OnDisable() +end + + +function XUiAwarenessTfResult:OnDestroy() +end + + +function XUiAwarenessTfResult:OnGetEvents() + return nil +end + + +function XUiAwarenessTfResult:OnNotify() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiAwarenessTfResult:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiAwarenessTfResult:AutoInitUi() + self.PanelAttr4 = self.Transform:Find("SafeAreaContentPane/Attr/PaneAttrParent/PanelAttr4") + self.TxtName4 = self.Transform:Find("SafeAreaContentPane/Attr/PaneAttrParent/PanelAttr4/TxtName4"):GetComponent("Text") + self.TxtAttr4 = self.Transform:Find("SafeAreaContentPane/Attr/PaneAttrParent/PanelAttr4/TxtAttr4"):GetComponent("Text") + self.PanelAttr3 = self.Transform:Find("SafeAreaContentPane/Attr/PaneAttrParent/PanelAttr3") + self.TxtName3 = self.Transform:Find("SafeAreaContentPane/Attr/PaneAttrParent/PanelAttr3/TxtName3"):GetComponent("Text") + self.TxtAttr3 = self.Transform:Find("SafeAreaContentPane/Attr/PaneAttrParent/PanelAttr3/TxtAttr3"):GetComponent("Text") + self.PanelAttr2 = self.Transform:Find("SafeAreaContentPane/Attr/PaneAttrParent/PanelAttr2") + self.TxtName2 = self.Transform:Find("SafeAreaContentPane/Attr/PaneAttrParent/PanelAttr2/TxtName2"):GetComponent("Text") + self.TxtAttr2 = self.Transform:Find("SafeAreaContentPane/Attr/PaneAttrParent/PanelAttr2/TxtAttr2"):GetComponent("Text") + self.PanelAttr1 = self.Transform:Find("SafeAreaContentPane/Attr/PaneAttrParent/PanelAttr1") + self.TxtName1 = self.Transform:Find("SafeAreaContentPane/Attr/PaneAttrParent/PanelAttr1/TxtName1"):GetComponent("Text") + self.TxtAttr1 = self.Transform:Find("SafeAreaContentPane/Attr/PaneAttrParent/PanelAttr1/TxtAttr1"):GetComponent("Text") + self.RImgIcon = self.Transform:Find("SafeAreaContentPane/RImgIcon"):GetComponent("RawImage") + self.GridSuitResult = self.Transform:Find("SafeAreaContentPane/GridSuitResult") + self.ImgGirdStar1 = self.Transform:Find("SafeAreaContentPane/GridSuitResult/Stars/PaneStar1/ImgGirdStar1"):GetComponent("Image") + self.ImgGirdStar2 = self.Transform:Find("SafeAreaContentPane/GridSuitResult/Stars/PaneStar2/ImgGirdStar2"):GetComponent("Image") + self.ImgGirdStar3 = self.Transform:Find("SafeAreaContentPane/GridSuitResult/Stars/PaneStar3/ImgGirdStar3"):GetComponent("Image") + self.ImgGirdStar4 = self.Transform:Find("SafeAreaContentPane/GridSuitResult/Stars/PaneStar4/ImgGirdStar4"):GetComponent("Image") + self.ImgGirdStar5 = self.Transform:Find("SafeAreaContentPane/GridSuitResult/Stars/PaneStar5/ImgGirdStar5"):GetComponent("Image") + self.ImgGirdStar6 = self.Transform:Find("SafeAreaContentPane/GridSuitResult/Stars/PaneStar6/ImgGirdStar6"):GetComponent("Image") + self.TxtAwarenessName = self.Transform:Find("SafeAreaContentPane/GridSuitResult/TxtAwarenessName"):GetComponent("Text") + self.PanelPos = self.Transform:Find("SafeAreaContentPane/GridSuitResult/PanelPos") + self.TxtPos = self.Transform:Find("SafeAreaContentPane/GridSuitResult/PanelPos/TxtPos"):GetComponent("Text") + self.TxtLevel = self.Transform:Find("SafeAreaContentPane/GridSuitResult/Level/TxtLevel"):GetComponent("Text") + self.BtnBack = self.Transform:Find("SafeAreaContentPane/BtnBack"):GetComponent("Button") + self.PanelContent = self.Transform:Find("SafeAreaContentPane/Content/PanelContent") + self.TxtSkillDes1 = self.Transform:Find("SafeAreaContentPane/Content/PanelContent/TxtSkillDes1"):GetComponent("Text") + self.TxtSkillDes2 = self.Transform:Find("SafeAreaContentPane/Content/PanelContent/TxtSkillDes2"):GetComponent("Text") + self.TxtSkillDes3 = self.Transform:Find("SafeAreaContentPane/Content/PanelContent/TxtSkillDes3"):GetComponent("Text") +end + +function XUiAwarenessTfResult:AutoAddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) +end +-- auto + +function XUiAwarenessTfResult:OnBtnBackClick() + if self.Cb then + self.Cb() + end + self:Close() +end + +function XUiAwarenessTfResult:UpdateInfo() + self:UpdateBaseInfo() + self:UpdateStar() + self:UpdateEquipAttr() + self:UpdateSuitEffect() +end + +--更新属性 +function XUiAwarenessTfResult:UpdateEquipAttr() + local attrCount = 1 + local attrMap = XDataCenter.EquipManager.GetEquipAttrMap(self.EquipId) + for _, attrInfo in pairs(attrMap) do + if attrCount > MAX_AWARENESS_ATTR_COUNT then break end + self["TxtName" .. attrCount].text = attrInfo.Name + self["TxtAttr" .. attrCount].text = attrInfo.Value + self["PanelAttr" .. attrCount].gameObject:SetActive(true) + attrCount = attrCount + 1 + end + for i = attrCount, MAX_AWARENESS_ATTR_COUNT do + self["PanelAttr" .. i].gameObject:SetActive(false) + end +end + +--套装效果 +function XUiAwarenessTfResult:UpdateSuitEffect() + local suitId = XDataCenter.EquipManager.GetSuitIdByTemplateId(self.TemplateId) + local skillDesList = XDataCenter.EquipManager.GetSuitSkillDesList(suitId) + for i = 1, XEquipConfig.MAX_SUIT_SKILL_COUNT do + if skillDesList[i * 2] then + self["TxtSkillDes" .. i].text = skillDesList[i * 2] + self["TxtSkillDes" .. i].gameObject:SetActive(true) + else + self["TxtSkillDes" .. i].gameObject:SetActive(false) + end + end +end + +--星星 +function XUiAwarenessTfResult:UpdateStar() + local star = XDataCenter.EquipManager.GetEquipStar(self.TemplateId) + for i = 1, XEquipConfig.MAX_STAR_COUNT do + if self["ImgGirdStar" .. i] then + if i <= star then + self["ImgGirdStar" .. i].gameObject:SetActive(true) + else + self["ImgGirdStar" .. i].gameObject:SetActive(false) + end + end + end +end + +--基础属性(名字,位置,等级,图标) +function XUiAwarenessTfResult:UpdateBaseInfo() + self.TxtAwarenessName.text = XDataCenter.EquipManager.GetEquipName(self.TemplateId) + self.TxtPos.text = XGoodsCommonManager.GetGoodsShowParamsByTemplateId(self.TemplateId).Site + self.TxtLevel.text = XDataCenter.EquipManager.GetEquip(self.EquipId).Level + local icon = XDataCenter.EquipManager.GetEquipLiHuiPath(self.TemplateId) + self.RImgIcon:SetRawImage(icon) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiBag/XUiBag.lua b/Resources/Scripts/XUi/XUiBag/XUiBag.lua new file mode 100644 index 00000000..9fa2e422 --- /dev/null +++ b/Resources/Scripts/XUi/XUiBag/XUiBag.lua @@ -0,0 +1,804 @@ +local XUiPanelBagItem = require("XUi/XUiBag/XUiPanelBagItem") +local XUiPanelSidePopUp = require("XUi/XUiBag/XUiPanelSidePopUp") +local XUiPanelBagRecycle = require("XUi/XUiBag/XUiPanelBagRecycle") +local XUiPanelSelectGift = require("XUi/XUiBag/XUiPanelSelectGift") +local XUiPanelSelectReplicatedGift = require("XUi/XUiBag/XUiPanelSelectReplicatedGift") +local GridTimeAnimation = 10 +local DefaultSortTypeIndex = 0 +local PartnerPageIndex = 5 + +local CapacityDesStr = { + EquipCapacityDes = CS.XTextManager.GetText("EquipCapacityDes"), + EquipDecomposionCapacityDes = CS.XTextManager.GetText("EquipDecomposionCapacityDes"), + EquipRecycleCapacityDes = CS.XTextManager.GetText("EquipRecycleCapacityDes"), + AwarenessCapacityDes = CS.XTextManager.GetText("AwarenessCapacityDes"), + AwarenessDecomposionCapacityDes = CS.XTextManager.GetText("AwarenessDecomposionCapacityDes"), + AwarenessRecycleCapacityDes = CS.XTextManager.GetText("AwarenessRecycleCapacityDes"), + SuitCapacityDes = CS.XTextManager.GetText("SuitCapacityDes"), + MaterialCapacityDes = CS.XTextManager.GetText("MaterialCapacityDes"), + FragmentCapacityDes = CS.XTextManager.GetText("FragmentCapacityDes"), + PartnerCapacityDes = CS.XTextManager.GetText("PartnerCapacityDes"), + PartnerDecomposionCapacityDes = CS.XTextManager.GetText("PartnerDecomposionCapacityDes"), +} + +local XUiBag = XLuaUiManager.Register(XLuaUi, "UiBag") + +--背包页签按钮索引组 +XUiBag.PageIndexGroup = { + [1] = XItemConfigs.PageType.Equip, --武器 + [2] = XItemConfigs.PageType.SuitCover, --意识套装封面 + [3] = XItemConfigs.PageType.Material, --材料 + [4] = XItemConfigs.PageType.Fragment, --碎片 + [5] = XItemConfigs.PageType.Partner, --伙伴 +} + +--背包页签按钮索引组 +XUiBag.PageTypeToIndex = { + [XItemConfigs.PageType.Equip] = 1, --武器 + [XItemConfigs.PageType.SuitCover] = 2, --意识套装封面 + [XItemConfigs.PageType.Material] = 3, --材料 + [XItemConfigs.PageType.Fragment] = 4, --碎片 + [XItemConfigs.PageType.Awareness] = 2, --意识 + [XItemConfigs.PageType.Partner] = 5, --伙伴 +} + +XUiBag.ItemPageToTypes = { + [XItemConfigs.PageType.Material] = XItemConfigs.Materials, + [XItemConfigs.PageType.Fragment] = { XItemConfigs.ItemType.Fragment }, +} + +--背包操作类型 +XUiBag.OperationType = { + Common = 1, --无操作 + Sell = 2, --出售 + Decomposion = 3, --分解 + Convert = 4, --转化 + Recycle = 5, --回收 + PartnerDecomposion = 6, --伙伴分解 +} + +--道具页签筛选类型 +XUiBag.MaterialType = { + All = 1, --全部 + Material = 2, --材料 + Consumables = 3, --消耗品 + Others = 4, --其他 +} + +XUiBag.MaterialTypeToItemTypes = { + [XUiBag.MaterialType.All] = XItemConfigs.Materials, + [XUiBag.MaterialType.Material] = { + XItemConfigs.ItemType.CardExp, + XItemConfigs.ItemType.EquipExp, + XItemConfigs.ItemType.Material, + XItemConfigs.ItemType.EquipResonanace, + }, + [XUiBag.MaterialType.Consumables] = { + XItemConfigs.ItemType.Gift, + }, + [XUiBag.MaterialType.Others] = { + XItemConfigs.ItemType.ExchangeMoney, + XItemConfigs.ItemType.SpExchangeMoney, + XItemConfigs.ItemType.FavorGift, + XItemConfigs.ItemType.ActiveMoney, + XItemConfigs.ItemType.PlayingItem, + }, +} + +local MaterialTypeCache = XUiBag.MaterialType.All + +function XUiBag:OnAwake() + local togs = { self.BtnTog0, self.BtnTog1, self.BtnTog2, self.BtnTog3, self.BtnTog4 } + self.TabBtnGroup:Init(togs, function(index) self:PageSelect(index) end) + + local isCanOpenPantnerTog = XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.Partner) + self.BtnTog4.gameObject:SetActiveEx(isCanOpenPantnerTog) + + local sorttogs = { self.BtnTogSortStar, self.BtnTogSortBreakthrough, self.BtnTogSortLevel, self.BtnTogSortProceed } + self.SortBtnGroup = XUiTabBtnGroup.New(sorttogs, function(index) self:SortTypeTurn(index) end) + + local partnerSorttogs = { + self.PanelPartnerSort:GetObject("BtnPartnerSortStar"), + self.PanelPartnerSort:GetObject("BtnPartnerSortBreakthrough"), + self.PanelPartnerSort:GetObject("BtnPartnerSortLevel"), + } + self.PartnerSortBtnGroup = XUiTabBtnGroup.New(partnerSorttogs, function(index) self:PartnerSortTypeTurn(index) end) + + local materialTypeTogs = { self.TogAll, self.TogStuff, self.TtogConsumables, self.TogOthers } + self.PanelFilter2:Init(materialTypeTogs, function(index) self:SelectMaterialType(index) end) + + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self.SidePopUpPanel = XUiPanelSidePopUp.New(self.PanelSidePopUp, self) + self.BagRecyclePanel = XUiPanelBagRecycle.New(self, self.PanelBagRecycle) + self.SelectGiftPanel = XUiPanelSelectGift.New(self, self.PanelSelectGift) + self.SelectReplicatedGiftPanel = XUiPanelSelectReplicatedGift.New(self, self.PanelSelectReplicatedGift) + + self.DynamicTable = XDynamicTableNormal.New(self.PanelDynamicTable) + self.DynamicTable:SetProxy(XUiPanelBagItem) + self.DynamicTable:SetDelegate(self) + + self.PanelBagItem.gameObject:SetActiveEx(false) + self.GridBagItemRect = self.PanelBagItem.transform:Find("GridEquip"):GetComponent("RectTransform").rect + self.GridSuitSimpleRect = self.PanelBagItem.transform:Find("GridSuitSimple"):GetComponent("RectTransform").rect + + self:AutoAddListener() +end + +function XUiBag:OnStart(record) + self.PageRecord = record or XDataCenter.ItemManager.PageRecordCache + self.MaterailTypeRecord = MaterialTypeCache + self.IsAscendOrder = false + self.Operation = XUiBag.OperationType.Common + self.SortType = XEquipConfig.PriorSortType.Star + self.PartnerSortType = DefaultSortTypeIndex + self.StarCheckList = {true, true, true, true, true, true } + self.IsFirstAnimation = true + self.SelectList = {} + + --打开背包时如果上次选择是意识那么回到套装封面 + if self.PageRecord == XItemConfigs.PageType.Awareness then + self.PageRecord = XItemConfigs.PageType.SuitCover + end + + self.TabBtnGroup:SelectIndex(XUiBag.PageTypeToIndex[self.PageRecord], false) + self.SortBtnGroup:SelectIndex(self.SortType + 1, false) + self.PartnerSortBtnGroup:SelectIndex(self.PartnerSortType + 1, false) + + self:PlayAnimationWithMask("AnimStartEnable") +end + +function XUiBag:OnEnable() + self.GridCount = 1 + self:Refresh(false) +end + +function XUiBag:OnDestroy() + XDataCenter.ItemManager.SetPageRecordCache(self.PageRecord) + MaterialTypeCache = self.MaterailTypeRecord +end + +--注册监听事件 +function XUiBag:OnGetEvents() + return { + XEventId.EVENT_ITEM_USE, + XEventId.EVENT_ITEM_RECYCLE, + XEventId.EVENT_ITEM_MULTIPLY_USE, + XEventId.EVENT_EQUIP_RECYCLE_NOTIFY, + } +end + +--处理事件监听 +function XUiBag:OnNotify(evt) + if evt == XEventId.EVENT_ITEM_USE + or evt == XEventId.EVENT_ITEM_RECYCLE + or evt == XEventId.EVENT_ITEM_MULTIPLY_USE + then + self:UpdateDynamicTable() + elseif evt == XEventId.EVENT_EQUIP_RECYCLE_NOTIFY then + self:UpdateDynamicTable() + self:OperationTurn(self.OperationType.Common) + end +end + +function XUiBag:Refresh(bReload) + self:UpdateDynamicTable(bReload) + self:UpdatePanels() +end + +--设置动态列表 +function XUiBag:UpdateDynamicTable(bReload) + --刷新数据 + self.PageDatas = self:GetDataByPage() + local gridSize + if self.PageRecord == XItemConfigs.PageType.SuitCover then + --套装的格子比较大 + gridSize = CS.UnityEngine.Vector2(self.GridSuitSimpleRect.width, self.GridSuitSimpleRect.height) + else + gridSize = CS.UnityEngine.Vector2(self.GridBagItemRect.width, self.GridBagItemRect.height) + end + + self.DynamicTable:SetGridSize(gridSize) + self.DynamicTable:SetDataSource(self.PageDatas) + self.DynamicTable:ReloadDataASync(bReload and 1 or -1) + + --刷新容量文本 + local curPageCount = #self.PageDatas + local maxCount + local capacityDes = "" + + if self.PageRecord == XItemConfigs.PageType.Equip then + maxCount = XEquipConfig.GetMaxWeaponCount() + if self.Operation == XUiBag.OperationType.Decomposion then + capacityDes = CapacityDesStr.EquipDecomposionCapacityDes + elseif self.Operation == XUiBag.OperationType.Recycle then + capacityDes = CapacityDesStr.EquipRecycleCapacityDes + else + capacityDes = CapacityDesStr.EquipCapacityDes + end + elseif self.PageRecord == XItemConfigs.PageType.Awareness then + maxCount = XEquipConfig.GetMaxAwarenessCount() + if self.Operation == XUiBag.OperationType.Decomposion then + capacityDes = CapacityDesStr.AwarenessDecomposionCapacityDes + elseif self.Operation == XUiBag.OperationType.Recycle then + capacityDes = CapacityDesStr.AwarenessRecycleCapacityDes + else + capacityDes = CapacityDesStr.AwarenessCapacityDes + end + elseif self.PageRecord == XItemConfigs.PageType.SuitCover then + curPageCount = curPageCount - XEquipConfig.GetDefaultSuitIdCount() --去掉默认全部套装特殊Id + maxCount = XDataCenter.EquipManager.GetMaxSuitCount() + capacityDes = CapacityDesStr.SuitCapacityDes + elseif self.PageRecord == XItemConfigs.PageType.Material then + capacityDes = CapacityDesStr.MaterialCapacityDes + elseif self.PageRecord == XItemConfigs.PageType.Fragment then + capacityDes = CapacityDesStr.FragmentCapacityDes + elseif self.PageRecord == XItemConfigs.PageType.Partner then + maxCount = XDataCenter.PartnerManager.GetMaxPartnerCount() + if self.Operation == XUiBag.OperationType.PartnerDecomposion then + capacityDes = CapacityDesStr.PartnerDecomposionCapacityDes + else + capacityDes = CapacityDesStr.PartnerCapacityDes + end + end + + self.TxtCapacityDes.text = capacityDes + if maxCount then + self.TxtNowCapacity.text = curPageCount + self.TxtMaxCapacity.text = "/" .. maxCount + end + + --刷新消耗品道具剩余时间文本 + if self.PageRecord == XItemConfigs.PageType.Material then + self:CalLeftTime(XUiBag.MaterialTypeToItemTypes[XUiBag.MaterialType.Consumables], self.TxtTimeConsumables) + self:CalLeftTime(XUiBag.MaterialTypeToItemTypes[XUiBag.MaterialType.Others], self.TxtTimeOthers) + end +end + +function XUiBag:CalLeftTime(types, txtGo) + local originData = XDataCenter.ItemManager.GetItemsByTypes(types) + local minLeftTime = XDataCenter.ItemManager.GetBagItemListMinLeftTime(originData) + if minLeftTime > 0 then + local timeStr = XUiHelper.GetBagTimeLimitTimeStrAndBg(minLeftTime) + txtGo.text = timeStr + txtGo.gameObject:SetActiveEx(true) + else + txtGo.gameObject:SetActiveEx(false) + end +end + +--动态列表事件 +function XUiBag:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + if self.IsFirstAnimation then + grid:Init(self, self.PageRecord, true) + else + grid:Init(self, self.PageRecord, false) + end + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local gridSize = self.DynamicTable:GetGridSize() + local data = self.PageDatas[index] + if self.PageRecord == XItemConfigs.PageType.Equip or self.PageRecord == XItemConfigs.PageType.Awareness then + grid:SetupEquip(data, gridSize) + grid:SetSelectedEquip(self.SelectList[data]) + elseif self.PageRecord == XItemConfigs.PageType.SuitCover then + grid:SetupSuit(data, self.PageDatas, gridSize) + elseif self.PageRecord == XItemConfigs.PageType.Partner then --zhang + grid:SetupPartner(data, gridSize) + grid:SetSelectedPartner(self.SelectList[data]) + else + grid:SetupCommon(data, self.PageRecord, self.Operation, gridSize) + grid:SetSelectedCommon(self.SelectList[data.GridIndex] and self.SelectList[data.GridIndex] == data.Data.Id) + end + self.GridCount = self.GridCount + 1 + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_RELOAD_COMPLETED then + local grids = self.DynamicTable:GetGrids() + + self.GridIndex = 1 + local item = grids[self.GridIndex] + if not item or not item.IsFirstAnimation then + return + end + + XLuaUiManager.SetMask(true) + self.CurAnimationTimerId = XScheduleManager.Schedule(function() + item = grids[self.GridIndex] + if item then + item:PlayAnimation() + end + self.GridIndex = self.GridIndex + 1 + end, GridTimeAnimation, self.GridCount, 0) + + XScheduleManager.ScheduleOnce(function() + XLuaUiManager.SetMask(false) + end, XScheduleManager.SECOND * 0.8) + end +end + +function XUiBag:OnDisable() + self.IsFirstAnimation = nil + if self.CurAnimationTimerId then + XScheduleManager.UnSchedule(self.CurAnimationTimerId) + self.CurAnimationTimerId = nil + end +end + +--刷新面板状态 +function XUiBag:UpdatePanels() + local isEmpty = #self.PageDatas <= 0 + self.PanelTag.gameObject:SetActiveEx(self.Operation == XUiBag.OperationType.Common) + self.PanelSort.gameObject:SetActiveEx(self.PageRecord == XItemConfigs.PageType.Equip or self.PageRecord == XItemConfigs.PageType.Awareness) + self.PanelPartnerSort.gameObject:SetActiveEx(self.PageRecord == XItemConfigs.PageType.Partner) + self.PanelFilter.gameObject:SetActiveEx(self.PageRecord == XItemConfigs.PageType.SuitCover) + self.PanelFilter2.gameObject:SetActiveEx(self.PageRecord == XItemConfigs.PageType.Material) + self.PanelEmpty.gameObject:SetActiveEx(isEmpty) + self.TxtNowCapacity.gameObject:SetActiveEx(self.PageRecord == XItemConfigs.PageType.Equip or self.PageRecord == XItemConfigs.PageType.Awareness or self.PageRecord == XItemConfigs.PageType.SuitCover or self.PageRecord == XItemConfigs.PageType.Partner) + self.TxtMaxCapacity.gameObject:SetActiveEx(self.PageRecord == XItemConfigs.PageType.Equip or (self.PageRecord == XItemConfigs.PageType.Awareness and self.SelectSuitId == XEquipConfig.DEFAULT_SUIT_ID) or self.PageRecord == XItemConfigs.PageType.SuitCover or self.PageRecord == XItemConfigs.PageType.Partner) + self.BtnHelp.gameObject:SetActiveEx(self.Operation == XUiBag.OperationType.Recycle) + self.SidePopUpPanel:Refresh() + --操作按钮 + if self.PageRecord == XItemConfigs.PageType.Equip or self.PageRecord == XItemConfigs.PageType.Awareness or self.PageRecord == XItemConfigs.PageType.Partner then--zhang + self.PanelDecomposionBtn.gameObject:SetActiveEx(true) + self.PanelRecycleBtn.gameObject:SetActiveEx(self.PageRecord == XItemConfigs.PageType.Awareness)--装备回收暂时屏蔽武器 + self.BtnDecomposion.gameObject:SetActiveEx(not isEmpty) + self.ImgCantDecomposion.gameObject:SetActiveEx(isEmpty) + else + self.PanelDecomposionBtn.gameObject:SetActiveEx(false) + self.PanelRecycleBtn.gameObject:SetActiveEx(false) + end + + if self.PageRecord == XItemConfigs.PageType.Material then + self.PanelFilter2:SelectIndex(self.MaterailTypeRecord, false) + self.PanelSellBtn.gameObject:SetActiveEx(true) + self.BtnSell.gameObject:SetActiveEx(not isEmpty) + self.ImgCantSell.gameObject:SetActiveEx(isEmpty) + else + self.PanelSellBtn.gameObject:SetActiveEx(false) + end + + if self.PageRecord == XItemConfigs.PageType.Fragment then + self.PanelConvertBtn.gameObject:SetActiveEx(true) + self.BtnConvert.gameObject:SetActiveEx(not isEmpty) + self.ImgCantConvert.gameObject:SetActiveEx(isEmpty) + else + self.PanelConvertBtn.gameObject:SetActiveEx(false) + end +end + +function XUiBag:CheckDecomposeRewardNotOverLimit(equipId, deSelect) + --屏蔽分解拦截 + do return true end + + --if self.Operation == XUiBag.OperationType.Decomposion then return true end + -- local deSelectSymbol = deSelect and -1 or 1 + -- self.CurDecomposeRewardWeaponCount = self.CurDecomposeRewardWeaponCount or XDataCenter.EquipManager.GetWeaponCount() + -- self.CurDecomposeRewardAwarenessCount = self.CurDecomposeRewardAwarenessCount or XDataCenter.EquipManager.GetAwarenessCount() + -- local maxWeaponCount = XEquipConfig.GetMaxWeaponCount() + -- local maxAwarenessCount = XEquipConfig.GetMaxAwarenessCount() + -- local curWeaponCount = self.CurDecomposeRewardWeaponCount + -- local curAwarenessCount = self.CurDecomposeRewardAwarenessCount + -- local tryAddWeaponCount, tryAddAwarenessCount = XDataCenter.EquipManager.GetDecomposeRewardEquipCount(equipId) + -- tryAddWeaponCount = tryAddWeaponCount * deSelectSymbol + -- tryAddAwarenessCount = tryAddAwarenessCount * deSelectSymbol + -- curWeaponCount = curWeaponCount + tryAddWeaponCount + -- if not deSelect and curWeaponCount > maxWeaponCount then + -- XUiManager.TipMsg(XEquipConfig.DecomposeRewardOverLimitTip[XEquipConfig.Classify.Weapon]) + -- return false + -- end + -- self.CurDecomposeRewardWeaponCount = curWeaponCount + -- curAwarenessCount = curAwarenessCount + tryAddAwarenessCount + -- if not deSelect and curAwarenessCount > maxAwarenessCount then + -- XUiManager.TipMsg(XEquipConfig.DecomposeRewardOverLimitTip[XEquipConfig.Classify.Awareness]) + -- return false + -- end + -- self.CurDecomposeRewardAwarenessCount = curAwarenessCount + -- return true +end + +--获取数据 +function XUiBag:GetDataByPage() + --武器 + if self.PageRecord == XItemConfigs.PageType.Equip then + local equipIds + + if self.Operation == XUiBag.OperationType.Decomposion then + equipIds = XDataCenter.EquipManager.GetCanDecomposeWeaponIds() + elseif self.Operation == XUiBag.OperationType.Recycle then + equipIds = XDataCenter.EquipManager.GetCanRecycleWeaponIds() + else + equipIds = XDataCenter.EquipManager.GetWeaponIds() + end + + XDataCenter.EquipManager.SortEquipIdListByPriorType(equipIds, self.SortType) + if self.IsAscendOrder then + XTool.ReverseList(equipIds) + end + + return equipIds + end + + --套装 + if self.PageRecord == XItemConfigs.PageType.SuitCover then + local suitIds = XDataCenter.EquipManager.GetSuitIdsByStars(self.StarCheckList) + return suitIds + end + + --意识 + if self.PageRecord == XItemConfigs.PageType.Awareness then + local awarenessIds + + if self.Operation == XUiBag.OperationType.Decomposion then + awarenessIds = XDataCenter.EquipManager.GetCanDecomposeAwarenessIdsBySuitId(self.SelectSuitId) + elseif self.Operation == XUiBag.OperationType.Recycle then + awarenessIds = XDataCenter.EquipManager.GetCanRecycleAwarenessIdsBySuitId(self.SelectSuitId) + else + awarenessIds = XDataCenter.EquipManager.GetEquipIdsBySuitId(self.SelectSuitId) + end + + XDataCenter.EquipManager.SortEquipIdListByPriorType(awarenessIds, self.SortType) + if self.IsAscendOrder then + XTool.ReverseList(awarenessIds) + end + + return awarenessIds + end + + --材料 + if self.PageRecord == XItemConfigs.PageType.Material then + local types = XUiBag.MaterialTypeToItemTypes[self.MaterailTypeRecord] + local useConsumableSort = self.MaterailTypeRecord ~= XUiBag.MaterialType.All + local originData + if self.Operation == XUiBag.OperationType.Sell then + originData = XDataCenter.ItemManager.GetCanSellItemsByTypes(types, useConsumableSort) + else + originData = XDataCenter.ItemManager.GetItemsByTypes(types, useConsumableSort) + end + return originData + end + + --碎片 + if self.PageRecord == XItemConfigs.PageType.Fragment then + local types = XUiBag.ItemPageToTypes[self.PageRecord] + local originData + if self.Operation == XUiBag.OperationType.Convert then + originData = XDataCenter.ItemManager.GetCanConvertItemsByTypes(types) + else + originData = XDataCenter.ItemManager.GetItemsByTypes(types) + end + return originData + end + + --伙伴 + if self.PageRecord == XItemConfigs.PageType.Partner then--zhang + local originData + if self.Operation == XUiBag.OperationType.PartnerDecomposion then + originData = XDataCenter.PartnerManager.GetPartnerDecomposionList() + + local firstType = XPartnerConfigs.BagSortType[self.PartnerSortType] + XPartnerSort.BagShowSortFunction(originData, firstType, not self.IsAscendOrder) + else + originData = XDataCenter.PartnerManager.GetPartnerOverviewDataList(nil, nil, false) + + local firstType = XPartnerConfigs.BagSortType[self.PartnerSortType] + XPartnerSort.BagShowSortFunction(originData, firstType, not self.IsAscendOrder) + end + return originData + end +end + +function XUiBag:OnGridClick(data, grid) + if self.Operation == XUiBag.OperationType.Common then + self:OpenDetailUi(data, grid) + else + self:SelectGrid(data, grid) + end +end + +function XUiBag:OpenDetailUi(data, grid) + + if self.PageRecord == XItemConfigs.PageType.Equip or self.PageRecord == XItemConfigs.PageType.Awareness then + local equipId = data + local forceShowBindCharacter = true + XLuaUiManager.Open("UiEquipDetail", equipId, nil, nil, forceShowBindCharacter) + elseif self.PageRecord == XItemConfigs.PageType.SuitCover then + self.SelectSuitId = data + self:PageTurn(XItemConfigs.PageType.Awareness) + elseif self.PageRecord == XItemConfigs.PageType.Material or self.PageRecord == XItemConfigs.PageType.Fragment then + local itemId = data.Data.Id + if XDataCenter.ItemManager.IsSelectGift(itemId) then + local canSelectRewardCount = XDataCenter.ItemManager.GetItem(itemId).Template.SelectCount + local ownItemCount = grid.GetGridCount and grid:GetGridCount() or 1 + if ownItemCount and ownItemCount > 1 and canSelectRewardCount == 1 then + self.SelectReplicatedGiftPanel:Open(itemId, ownItemCount * canSelectRewardCount) + else + self.SelectGiftPanel:Refresh(itemId) + end + else + XLuaUiManager.Open("UiBagItemInfoPanel", data) + end + elseif self.PageRecord == XItemConfigs.PageType.Partner then + XLuaUiManager.Open("UiPartnerMain", XPartnerConfigs.MainUiState.Overview, data, false, true) + end +end + +--选中Grid +function XUiBag:SelectGrid(data, grid) + if self.Operation == XUiBag.OperationType.Decomposion then + local equipId = data + local cancelStar + + if self.SelectList[equipId] then + self:CheckDecomposeRewardNotOverLimit(equipId, true) + + self.SelectList[equipId] = nil + grid:SetSelected(false) + + if not XDataCenter.EquipManager.IsEquipResonanced(equipId) then--分解时不选中已共鸣过的装备,反选星级也不需要 + local equip = XDataCenter.EquipManager.GetEquip(equipId) + cancelStar = XDataCenter.EquipManager.GetEquipStar(equip.TemplateId) + end + else + if not self:CheckDecomposeRewardNotOverLimit(equipId) then + return + end + + self.SelectList[equipId] = equipId + grid:SetSelected(true) + end + self.SidePopUpPanel:RefreshDecomposionPreView(self.SelectList, cancelStar) + + elseif self.Operation == XUiBag.OperationType.PartnerDecomposion then--zhang + local Partner = data + if self.SelectList[Partner] then + self.SelectList[Partner] = nil + grid:SetSelected(false) + else + self.SelectList[Partner] = Partner + grid:SetSelected(true) + end + self.SidePopUpPanel:RefreshPartnerDecomposionPreView(self.SelectList) + elseif self.Operation == XUiBag.OperationType.Recycle then + + local equipId = data + local cancelStar + + if self.SelectList[equipId] then + + self.SelectList[equipId] = nil + grid:SetSelected(false) + + local equip = XDataCenter.EquipManager.GetEquip(equipId) + cancelStar = XDataCenter.EquipManager.GetEquipStar(equip.TemplateId) + else + + self.SelectList[equipId] = equipId + grid:SetSelected(true) + + end + self.SidePopUpPanel:RefreshRecyclePreView(self.SelectList, cancelStar) + + elseif self.Operation == XUiBag.OperationType.Sell or self.Operation == XUiBag.OperationType.Convert then + if self.SelectList[data.GridIndex] and self.SelectList[data.GridIndex] == data.Data.Id then return end + + self.SelectList = {} --单选 + self.SelectList[data.GridIndex] = data.Data.Id + + if self.LastSelectCommonGrid then + self.LastSelectCommonGrid:SetSelectState(false) + end + self.LastSelectCommonGrid = grid + self.LastSelectCommonGrid:SetSelectState(true) + + self.SidePopUpPanel:RefreshSellPreView(self.SelectList[data.GridIndex], 1, grid) + end +end + +--选中一个品质 +---@param:isForDecomposion:操作类型为分解/回收 +function XUiBag:SelectByStar(starCheckDic, state, isForDecomposion) + if self.Operation ~= XUiBag.OperationType.Decomposion + and self.Operation ~= XUiBag.OperationType.Recycle + then return end + + for index, equipId in ipairs(self.PageDatas) do + local equip = XDataCenter.EquipManager.GetEquip(equipId) + local equipStar = XDataCenter.EquipManager.GetEquipStar(equip.TemplateId) + local tmpState = state + + if starCheckDic[equipStar] and + (not isForDecomposion or not XDataCenter.EquipManager.IsEquipResonanced(equipId))--分解时不选中已共鸣过的装备 + then + if tmpState then + if not self.SelectList[equipId] then + if not self:CheckDecomposeRewardNotOverLimit(equipId) then + break + end + + self.SelectList[equipId] = equipId + end + else + if self.SelectList[equipId] then + self:CheckDecomposeRewardNotOverLimit(equipId, true) + self.SelectList[equipId] = nil + end + end + + local grid = self.DynamicTable:GetGridByIndex(index) + if grid then + grid:SetSelectedEquip(tmpState) + end + end + + end + + if self.Operation == XUiBag.OperationType.Decomposion then + self.SidePopUpPanel:RefreshDecomposionPreView(self.SelectList) + elseif self.Operation == XUiBag.OperationType.Recycle then + self.SidePopUpPanel:RefreshRecyclePreView(self.SelectList) + end +end + +function XUiBag:AutoAddListener() + self:RegisterClickEvent(self.BtnSell, self.OnBtnSellClick) + self:RegisterClickEvent(self.BtnOrder, self.OnBtnOrderClick) + self:RegisterClickEvent(self.TogStar6, self.OnTogStar6Click) + self:RegisterClickEvent(self.TogStar5, self.OnTogStar5Click) + self:RegisterClickEvent(self.TogStar4, self.OnTogStar4Click) + self:RegisterClickEvent(self.TogStar3, self.OnTogStar3Click) + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:RegisterClickEvent(self.BtnDecomposion, self.OnBtnDecomposionClick) + self:RegisterClickEvent(self.BtnRecycleOpen, self.OnBtnRecycleOpenClick) + self:RegisterClickEvent(self.BtnConvert, self.OnBtnConvertClick) + self:BindHelpBtn(self.BtnHelp, "UiBagHelp") + + self.PanelPartnerSort:GetObject("BtnPartnerOrder").CallBack = function() + self:OnBtnOrderClick() + end +end + +function XUiBag:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiBag:OnBtnBackClick() + if self.Operation ~= XUiBag.OperationType.Common then + self:OperationTurn(XUiBag.OperationType.Common) + elseif self.PageRecord == XItemConfigs.PageType.Awareness then + self:PageTurn(XItemConfigs.PageType.SuitCover) + else + self:Close() + end +end + +function XUiBag:OnBtnSellClick() + self:OperationTurn(XUiBag.OperationType.Sell) +end + +function XUiBag:OnBtnDecomposionClick() + if self.PageRecord == XItemConfigs.PageType.Partner then + self:OperationTurn(XUiBag.OperationType.PartnerDecomposion) + else + self:OperationTurn(XUiBag.OperationType.Decomposion) + end +end + +function XUiBag:OnBtnRecycleOpenClick() + self:OperationTurn(XUiBag.OperationType.Recycle) +end + +function XUiBag:OnBtnConvertClick() + local types = XUiBag.ItemPageToTypes[XUiBag.OperationType.Convert] + local originData = XDataCenter.ItemManager.GetCanConvertItemsByTypes(types) + if not originData or #originData == 0 then + XUiManager.TipText("BagNoOverFragment") + return + end + + self:OperationTurn(XUiBag.OperationType.Convert) +end + +function XUiBag:OnBtnOrderClick() + self:OrderTypeTurn(not self.IsAscendOrder) +end + +function XUiBag:OnTogStar6Click() + self:StarToggleStateChange(6, self.TogStar6.isOn) +end + +function XUiBag:OnTogStar5Click() + self:StarToggleStateChange(5, self.TogStar5.isOn) +end + +function XUiBag:OnTogStar4Click() + self:StarToggleStateChange(4, self.TogStar4.isOn) +end + +function XUiBag:OnTogStar3Click() + self:StarToggleStateChange(3, self.TogStar3.isOn) + self:StarToggleStateChange(2, self.TogStar3.isOn) + self:StarToggleStateChange(1, self.TogStar3.isOn) +end + +--切换页签 +function XUiBag:PageSelect(index) + self:PageTurn(XUiBag.PageIndexGroup[index]) +end + +function XUiBag:PageTurn(page) + if self.PageRecord == page then + return + end + + if self.CurAnimationTimerId then + XScheduleManager.UnSchedule(self.CurAnimationTimerId) + self.CurAnimationTimerId = nil + end + + self.IsFirstAnimation = false + self.PageRecord = page + self:Refresh(true) + if not self.SidePopUpPanel.CurState and not self.IsFirstAnimation then + self:PlayAnimationWithMask("AnimNeiRongEnable") + end +end + +--切换操作 +function XUiBag:OperationTurn(operation) + self.Operation = operation + self.SelectList = {} + self.CurDecomposeRewardWeaponCount = nil + self.CurDecomposeRewardAwarenessCount = nil + + self.SidePopUpPanel:ClearData() + + local isAscendOrder = self.Operation ~= XUiBag.OperationType.Common + self:OrderTypeTurn(isAscendOrder) + + self:UpdatePanels() +end + +--切换排序 +function XUiBag:SortTypeTurn(index) + self.SortType = index - 1 + self:UpdateDynamicTable(true) + if not self.SidePopUpPanel.CurState and not self.IsFirstAnimation then + self:PlayAnimationWithMask("AnimNeiRongEnable") + end +end + +--伙伴切换排序 +function XUiBag:PartnerSortTypeTurn(index) + self.PartnerSortType = index - 1 + self:UpdateDynamicTable(true) +end + +--切换顺序 +function XUiBag:OrderTypeTurn(isAscendOrder) + self.IsAscendOrder = isAscendOrder + self.ImgAscend.gameObject:SetActiveEx(self.IsAscendOrder) + self.ImgDescend.gameObject:SetActiveEx(not self.IsAscendOrder) + self.PanelPartnerSort:GetObject("ImgAscend").gameObject:SetActiveEx(self.IsAscendOrder) + self.PanelPartnerSort:GetObject("ImgDescend").gameObject:SetActiveEx(not self.IsAscendOrder) + self:UpdateDynamicTable(true) + if not self.SidePopUpPanel.CurState and not self.IsFirstAnimation then + self:PlayAnimationWithMask("AnimNeiRongEnable") + end +end + +--筛选同星级套装 +function XUiBag:StarToggleStateChange(star, state) + self.StarCheckList[star] = state + self:UpdateDynamicTable(true) + if not self.SidePopUpPanel.CurState and not self.IsFirstAnimation then + self:PlayAnimationWithMask("AnimNeiRongEnable") + end +end + +--筛选材料类型 +function XUiBag:SelectMaterialType(index) + self.MaterailTypeRecord = index + self:Refresh(true) + if not self.SidePopUpPanel.CurState and not self.IsFirstAnimation then + self:PlayAnimationWithMask("AnimNeiRongEnable") + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiBag/XUiBagItem.lua b/Resources/Scripts/XUi/XUiBag/XUiBagItem.lua new file mode 100644 index 00000000..4e818971 --- /dev/null +++ b/Resources/Scripts/XUi/XUiBag/XUiBagItem.lua @@ -0,0 +1,683 @@ +local mathMin = math.min +local mathMax = math.max +local mathFloor = math.floor + +XUiBagItem = XClass(nil, "XUiBagItem") + +-- 初始化 +function XUiBagItem:Ctor(rootUi, ui, openCloseCb, clickCb) + self.RootUi = rootUi + self.CallBack = openCloseCb + self.ClickCallback = clickCb + self.IsShowBtnMinusWhenMinSelectCount = false + self.GameObject = ui.gameObject + self.Transform = ui.transform + self:InitUi() + self:AddListener() + if self.WgtBtn then + self.WidgetBtnLongClick = XUiButtonLongClick.New(self.WgtBtn, 100, self, nil, self.BtnLongClickCallback, nil, true) + end + if self.WgtBtnMinusSelect then + self.WidgetBtnMinusLongClick = XUiButtonLongClick.New(self.WgtBtnMinusSelect, 100, self, nil, self.BtnMinusSelectLongClickCallback, nil, true) + end + if self.WgtBtnAddSelect then + self.WidgetBtnMinusLongClick = XUiButtonLongClick.New(self.WgtBtnAddSelect, 100, self, nil, self.BtnAddSelectLongClickCallback, nil, true) + end + self.DefaultMinSelectCount = 0 + self.SelectCount = 0 +end + +function XUiBagItem:InitUi() + -- 基础信息 ----------------------------------------------------------------------------- + -- 图标 + self.RImgIcon = XUiHelper.TryGetComponent(self.Transform, "RImgIcon", "RawImage") + -- 图标背景图 + self.ImgIconBg = XUiHelper.TryGetComponent(self.Transform, "ImgIconBg", "Image") + -- 图标品质底图 + self.ImgIconQuality = XUiHelper.TryGetComponent(self.Transform, "ImgIconQuality", "Image") + -- 物品数量 + self.TxtCount = XUiHelper.TryGetComponent(self.Transform, "TxtCount", "Text") + -- 物品名字 + self.TxtName = XUiHelper.TryGetComponent(self.Transform, "TxtName", "Text") + -- 物品描述 + self.TxtDescription = XUiHelper.TryGetComponent(self.Transform, "TxtDescription", "Text") + -- 物品经验是否加倍 + self.TxtEx = XUiHelper.TryGetComponent(self.Transform, "TxtEx", "Text") + -- 世界观描述 + self.TxtWorldDesc = XUiHelper.TryGetComponent(self.Transform, "TxtWorldDesc", "Text") + + -- 自定义回调 ----------------------------------------------------------------------------- + -- 自定义回调Button + self.Btn = XUiHelper.TryGetComponent(self.Transform, "Btn", "Button") + -- 自定义回调Button2 + self.Btn2 = XUiHelper.TryGetComponent(self.Transform, "Btn2", "Button") + -- 自定义Widget + self.WgtBtn = XUiHelper.TryGetComponent(self.Transform, "Btn", "XUiPointer") + + -- 选择相关 ----------------------------------------------------------------------------- + -- 选中Image + self.ImgSelect = XUiHelper.TryGetComponent(self.Transform, "ImgSelect", "Image") + -- 选中Image背景 + self.ImgSelectBg = XUiHelper.TryGetComponent(self.Transform, "ImgSelectBg", "Image") + -- 选择数量 + self.TxtSelect = XUiHelper.TryGetComponent(self.Transform, "TxtSelect", "Text") + -- 选择数量 为0自动隐藏 + self.TxtSelectHide = XUiHelper.TryGetComponent(self.Transform, "TxtSelectHide", "Text") + -- 需要数量 例如升级部件 16/100,其中100为需要数量 + self.TxtNeedCount = XUiHelper.TryGetComponent(self.Transform, "TxtNeedCount", "Text") + -- 现有数量 例如升级部件 16/100,其中16为需现有数量 + self.TxtHaveCount = XUiHelper.TryGetComponent(self.Transform, "TxtHaveCount", "Text") + -- 减少选择按钮 + self.BtnMinusSelect = XUiHelper.TryGetComponent(self.Transform, "BtnMinusSelect", "Button") + -- 减少选择长按组件 + self.WgtBtnMinusSelect = XUiHelper.TryGetComponent(self.Transform, "BtnMinusSelect", "XUiPointer") + -- 增加选择按钮 + self.BtnAddSelect = XUiHelper.TryGetComponent(self.Transform, "BtnAddSelect", "Button") + -- 增加选择长按组件 + self.WgtBtnAddSelect = XUiHelper.TryGetComponent(self.Transform, "BtnAddSelect", "XUiPointer") + -- 全选按钮 + self.BtnMax = XUiHelper.TryGetComponent(self.Transform, "BtnMax", "Button") + + -- 操作按钮 ----------------------------------------------------------------------------- + -- 确定按钮 隐藏Item + self.BtnOk = XUiHelper.TryGetComponent(self.Transform, "BtnOk", "Button") + -- 使用按钮 + self.BtnUse = XUiHelper.TryGetComponent(self.Transform, "BtnUse", "Button") + -- 出售按钮 + self.BtnSell = XUiHelper.TryGetComponent(self.Transform, "BtnSell", "Button") + -- 关闭按钮 + self.BtnClose = XUiHelper.TryGetComponent(self.Transform, "BtnClose", "Button") + -- 获取按钮 + self.BtnGet = XUiHelper.TryGetComponent(self.Transform, "BtnGet", "Button") + -- 阻挡按钮 防穿透 + self.BtnBlock = XUiHelper.TryGetComponent(self.Transform, "BtnBlock", "Button") + -- Tips 显示 + self.BtnItemTip = XUiHelper.TryGetComponent(self.Transform, "BtnItemTip", "Button") + + -- 状态相关 ----------------------------------------------------------------------------- + -- 状态图片 + self.ImgState = XUiHelper.TryGetComponent(self.Transform, "ImgState", "Image") + self.TxtState = XUiHelper.TryGetComponent(self.Transform, "ImgState/TxtState", "Text") + -- 可使用 + self.ImgCanUse = XUiHelper.TryGetComponent(self.Transform, "ImgCanUse", "Image") + -- 物品使用等级 + self.TxtUseLevel = XUiHelper.TryGetComponent(self.Transform, "TxtUseLevel", "Text") + -- 当前格子数量,根据Refresh时传入的GridIndex算 + self.TxtGridCount = XUiHelper.TryGetComponent(self.Transform, "TxtGridCount", "Text") +end + +function XUiBagItem:GetAutoKey(uiNode, eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiBagItem:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiPanelBagItemCommon:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function() + func(self) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiBagItem:AddListener() + self.AutoCreateListeners = {} + + if self.Btn then + XUiHelper.RegisterClickEvent(self, self.Btn, self.OnBtnClick) + end + + if self.Btn2 then + XUiHelper.RegisterClickEvent(self, self.Btn2, self.OnBtn2Click) + end + + if self.BtnOk then + XUiHelper.RegisterClickEvent(self, self.BtnOk, self.Hide) + end + + if self.BtnSell then + XUiHelper.RegisterClickEvent(self, self.BtnSell, self.OnBtnSellClick) + end + + if self.BtnClose then + XUiHelper.RegisterClickEvent(self, self.BtnClose, self.Hide) + end + + if self.BtnGet then + XUiHelper.RegisterClickEvent(self, self.BtnGet, self.OnBtnGetClick) + end + + if self.BtnBlock then + XUiHelper.RegisterClickEvent(self, self.BtnBlock, self.Hide) + end + + if self.BtnMinusSelect then + XUiHelper.RegisterClickEvent(self, self.BtnMinusSelect, self.MinusSelectCount) + end + + if self.BtnAddSelect then + XUiHelper.RegisterClickEvent(self, self.BtnAddSelect, self.AddSelectCount) + end + + if self.BtnMax then + XUiHelper.RegisterClickEvent(self, self.BtnMax, self.SelectAll) + end + + if self.BtnUse then + XUiHelper.RegisterClickEvent(self, self.BtnUse, self.OnBtnUseClick) + end + + if self.BtnItemTip then + XUiHelper.RegisterClickEvent(self, self.BtnItemTip, self.OnBtnItemTipClick) + end +end + +-- 操作回调 +function XUiBagItem:OnBtnItemTipClick() + if self.BtnItemTip then + XLuaUiManager.Open("UiTip", { TemplateId = self.TemplateId, Count = self.Data.Count }) + end +end + +function XUiBagItem:OnBtnClick() + if self.ClickCallback then + self.ClickCallback({ Data = self.Data, GridIndex = self.GridIndex, RecycleBatch = self.RecycleBatch }, self) + end + --CS.XAudioManager.PlaySound(XSoundManager.UiBasicsMusic.UiBag_Chip_Click) +end + +function XUiBagItem:OnBtnUseClick() + if self.SelectCount <= 0 then + return + end + local closeCallback = function() + self:RefreshSelf() + end + local callback = function(rewardGoodsList) + if self.UseRefreshCallback then + self.UseRefreshCallback() + end + XUiManager.OpenUiObtain(rewardGoodsList, nil, closeCallback, nil) + end + XDataCenter.ItemManager.Use(self.Data.Id, self.RecycleBatch and self.RecycleBatch.RecycleTime, self.SelectCount, callback) + if self.CallBack then + self.CallBack(false) + end + self.GameObject:SetActive(false) +end + +function XUiBagItem:OnBtn2Click() + if self.ClickCallback2 then + self.ClickCallback2() + end +end + +function XUiBagItem:Hide() + if self.CallBack then + self.CallBack(false) + end + + self.GameObject:SetActive(false) +end + +function XUiBagItem:OnBtnSellClick() + print("XUiBagItem:OnBtnSellClick") +end +function XUiBagItem:OnBtnGetClick() + XLuaUiManager.Open("UiSkip", self.Template.Id) +end + +function XUiBagItem:BtnLongClickCallback(time) + local maxCount = self:GetGridCount() + if maxCount and self.SelectCount >= maxCount then + return + end + + local delta = mathMax(0, mathFloor(time / 300)) + local count = self.SelectCount + delta + if maxCount and count >= maxCount then + count = maxCount + end + + self:UpdateSelectCount(count) +end + +function XUiBagItem:BtnMinusSelectLongClickCallback(time) + if self.SelectCount == 0 then + return + end + + local delta = mathMax(0, mathFloor(time / 150)) + local count = self.SelectCount - delta + if count <= 0 then + count = 0 + end + self:UpdateSelectCount(count) +end + +function XUiBagItem:BtnAddSelectLongClickCallback(time) + local maxCount = self:GetGridCount() + if maxCount and self.SelectCount >= maxCount then + return + end local delta = mathMax(0, mathFloor(time / 150)) + local count = self.SelectCount + delta + if maxCount and count >= maxCount then + count = maxCount + end + + self:UpdateSelectCount(count) +end + +-- 选择操作接口 +function XUiBagItem:UpdateSelectCount(count) + local newCount = mathMax(count, self.DefaultMinSelectCount) + newCount = mathMin(newCount, self.Data.GridCount or self.Data.Count) + if self.SelectCountChangeCondition and not self.SelectCountChangeCondition(newCount) then + return + end + + if newCount == self.SelectCount then + return + end + + self:SetSelectCount(newCount) +end + +function XUiBagItem:SetSelectCount(newCount) + local oldCount = self.SelectCount + self.SelectCount = mathMax(newCount, self.DefaultMinSelectCount) + if self.BtnUse then + self.BtnUse.interactable = newCount > 0 + end + if self.OnSelectCountChanged then + self.OnSelectCountChanged(newCount - oldCount) + end + self:SetSelectState(newCount > self.DefaultMinSelectCount, true) +end + +function XUiBagItem:MinusSelectCount() + if self.SelectCount <= 0 then + return + end + self:UpdateSelectCount(self.SelectCount - 1) +end + +function XUiBagItem:AddSelectCount() + local maxCount = self:GetGridCount() + if maxCount and self.SelectCount >= maxCount then + return + end + + if self.SelectCount < self.Data.Count then + self:UpdateSelectCount(self.SelectCount + 1) + end +end + +function XUiBagItem:SelectAll() + self:UpdateSelectCount(self.Template.MaxCount) +end + +function XUiBagItem:ClearSelectState() + self:UpdateSelectCount(0) +end + +function XUiBagItem:GetSelectCount() + return self.SelectCount +end + +function XUiBagItem:SetSelectState(isSelected, forceRefresh) + if isSelected ~= self.SelectState then + self.SelectState = isSelected + if self.OnSelectStateChanged then + self.OnSelectStateChanged(self.SelectState) + end + self:RefreshSelectState() + else + if forceRefresh then + self:RefreshSelectState() + end + end +end + +function XUiBagItem:IsSelected() + return self.SelectState +end + +-- 其他接口 +function XUiBagItem:GetGridCount() + if self.RecycleBatch then + return self.RecycleBatch.RecycleCount + end + + local gridCount = self.Template.GridCount + if gridCount <= 0 then + return self.Data.Count + else + if self.TxtGridCount and self.GridIndex then + local minCount = mathMin(self.Data.Count - (self.GridIndex - 1) * gridCount, gridCount) + return minCount + end + end +end + +function XUiBagItem:SetNeedCount(needCount) + if needCount then + self.NeedCount = needCount + self.TxtNeedCount.text = needCount + end +end + +function XUiBagItem:IsEnable() + return self and self.GameObject and self.GameObject.activeSelf +end + +function XUiBagItem:Refresh(data, NeedDefulatQulity, isSmallIcon, notCommonBg) + local showSmallIcon = false + if isSmallIcon then + showSmallIcon = isSmallIcon + end + + if self.CallBack then + self.CallBack(data) + end + + self.GameObject:SetActive(data ~= nil) + + if data == nil then + return + end + + self.SelectCount = self.DefaultMinSelectCount + self.SelectState = false + + if data.Data and data.GridIndex then + self.Data = data.Data + self.GridIndex = data.GridIndex + self.RecycleBatch = data.RecycleBatch + else + self.Data = data + end + + self.TemplateId = self.Data.TemplateId and self.Data.TemplateId or self.Data.Id + if not self.TemplateId then + XLog.Error("XUiBagItem:Refresh 函数错误: 参数data的TemplateId字段和Id字段不能全部为空.. 参数:" .. tostring(data)) + return + end + + self.Template = self.Data.Template or XGoodsCommonManager.GetGoodsShowParamsByTemplateId(self.TemplateId) + + self:RefreshSelf(NeedDefulatQulity, showSmallIcon, notCommonBg) + + self:RefreshSelectState() +end + +function XUiBagItem:RefreshSelectState() + local isNotMaxCount = self.SelectCount ~= self.Data.Count + if self.BtnMinusSelect then + self.BtnMinusSelect.interactable = self.SelectState + if self.SelectCount <= self.DefaultMinSelectCount then + if (not self.IsShowBtnMinusWhenMinSelectCount) then + self.BtnMinusSelect.gameObject:SetActive(false) + end + else + self.BtnMinusSelect.gameObject:SetActive(true) + end + end + if self.BtnAddSelect then + self.BtnAddSelect.interactable = isNotMaxCount + end + if self.TxtSelect then + self.TxtSelect.text = self.SelectCount + if self.SelectCount == 0 then + self.TxtSelect.text = "" + end + end + if self.TxtSelectHide then + self.TxtSelectHide.gameObject:SetActive(self.SelectState) + if self.SelectState then + self.TxtSelectHide.text = "x" .. self.SelectCount + end + end + if self.ImgSelect then + self.ImgSelect.gameObject:SetActive(self.SelectState) + end + if self.ImgSelectBg then + self.ImgSelectBg.gameObject:SetActive(self.SelectState) + end + if self.TxtNeedCount and self.NeedCount then + if self.Data.Count >= self.NeedCount then + self.TxtNeedCount.text = self.Data.Count .. "/" .. self.NeedCount + if self.TxtHaveCount then + self.TxtHaveCount.gameObject:SetActive(false) + end + else + self.TxtNeedCount.text = "/" .. self.NeedCount + if self.TxtHaveCount then + self.TxtHaveCount.text = self.Data.Count + self.TxtHaveCount.gameObject:SetActive(true) + end + end + end +end + +function XUiBagItem:SetDefaultMinSelectCount(minSelectCount) + self.DefaultMinSelectCount = minSelectCount + self.SelectCount = self.DefaultMinSelectCount +end + +function XUiBagItem:ShowBtnMinusWhenMinSelectCount(show) + self.IsShowBtnMinusWhenMinSelectCount = show +end + +function XUiBagItem:RefreshSelf(NeedDefulatQulity, isSmallIcon, notCommonBg) + if self.BtnUse then + local isUseable = XDataCenter.ItemManager.IsUseable(self.TemplateId) + self.BtnUse.gameObject:SetActive(isUseable) + self.BtnUse.interactable = self.SelectCount > 0 + end + + if self.ImgCanUse then + local isUseable = XDataCenter.ItemManager.IsUseable(self.TemplateId) + self.ImgCanUse.gameObject:SetActive(isUseable) + end + + if self.BtnOk then + local isUseable = XDataCenter.ItemManager.IsUseable(self.TemplateId) + self.BtnOk.gameObject:SetActive(not isUseable) + end + + self:RefreshSelfCount() + + local template = self.Template + if self.TxtName then + self.TxtName.text = template.Name + end + + if self.TxtDescription then + self.TxtDescription.text = template.Description + end + + if self.TxtWorldDesc then + self.TxtWorldDesc.text = template.WorldDesc + end + + if self.TxtUseLevel then + self.TxtUseLevel.text = CS.XTextManager.GetText("CharacterUpgradeSkillConsumeTitle") .. "Lv." .. template.UseLevel + end + + if self.TxtCount and self.Data.Count ~= nil then + self.TxtCount.text = self.Data.Count + end + + if self.RImgIcon and isSmallIcon then + self.RImgIcon:SetRawImage(template.Icon) + elseif self.RImgIcon and not isSmallIcon then + self.RImgIcon:SetRawImage(template.BigIcon) + end + + local quality = template.Quality + + -- 角色品质背景特殊处理 + if template.RewardType == XRewardManager.XRewardType.Character then + quality = quality < 3 and 5 or 6 + end + -- 宠物品质背景特殊处理 + if template.RewardType == XRewardManager.XRewardType.Partner then + quality = quality < 3 and 5 or 6 + end + + if self.ImgIconBg then + if self.BtnGet or notCommonBg then + XUiHelper.SetQualityIcon(self.RootUi, self.ImgIconBg, quality) + else + self.RootUi:SetUiSprite(self.ImgIconBg, XArrangeConfigs.GeQualityBgPath(quality)) + end + end + + if self.ImgIconQuality then + XUiHelper.SetQualityIcon(self.RootUi, self.ImgIconQuality, quality) + end + + if NeedDefulatQulity and self.ImgIconBg then + XUiHelper.SetQualityIcon(self.RootUi, self.ImgIconBg, quality) + end + + if self.ImgState then + local sprite = nil + local text = "" + + if XDataCenter.ItemManager.IsCanConvert(self.TemplateId) then + sprite = XUiHelper.TagBgPath.Blue + text = CS.XTextManager.GetText("ItemCanConvert") + elseif XDataCenter.ItemManager.IsTimeLimit(self.TemplateId) then + local leftTime = self.RecycleBatch and self.RecycleBatch.RecycleTime - XTime.GetServerNowTimestamp() + or XDataCenter.ItemManager.GetRecycleLeftTime(self.Data.Id) + local tmpTime = XUiHelper.GetBagTimeStrAndBg(leftTime) + sprite = XUiHelper.TagBgPath.Red + text = tmpTime + end + + if sprite then + self.RootUi:SetUiSprite(self.ImgState, sprite) + self.ImgState.gameObject:SetActive(true) + else + self.ImgState.gameObject:SetActive(false) + end + + if text then + self.TxtState.text = text + self.TxtState.gameObject:SetActive(true) + else + self.TxtState.gameObject:SetActive(false) + end + end + + if self.RefreshCallback then + self.RefreshCallback() + end +end + +function XUiBagItem:RefreshSelfCount(useSelectCout) + if self.TxtGridCount then + local gridCount = self:GetGridCount() + + if useSelectCout and useSelectCout > 0 then + gridCount = gridCount - useSelectCout + end + + if gridCount <= 0 then + if self.CallBack then + self.CallBack(false) + end + + self.GameObject:SetActive(false) + else + self.TxtGridCount.text = gridCount + end + end +end + +function XUiBagItem:SetEnable(active) + if self.Btn then + self.Btn.interactable = active + end + if self.Btn2 then + self.Btn2.interactable = active + end + if self.BtnAddSelect then + self.BtnAddSelect.interactable = active + end + if self.WgtBtnAddSelect then + self.WgtBtnAddSelect.enabled = active + end + if self.BtnMinusSelect then + self.BtnMinusSelect.interactable = active + end + if self.WgtBtnMinusSelect then + self.WgtBtnMinusSelect.enabled = active + end + if self.BtnGet then + self.BtnGet.interactable = active + end + if self.BtnClose then + self.BtnClose.interactable = active + end + if self.BtnOk then + + self.BtnOk.interactable = active + end + if self.BtnUse then + self.BtnUse.interactable = active + end + if self.WgtBtn then + self.WgtBtn.enabled = active + end +end + +-- 回调修改 +-- 参数: 无 +function XUiBagItem:SetClickCallback(callback) + self.ClickCallback = callback +end + +-- 参数: 无 +function XUiBagItem:SetClickCallback2(callback) + self.ClickCallback2 = callback +end + +-- 参数: 无 +function XUiBagItem:SetRefreshCallback(callback) + self.RefreshCallback = callback +end + +-- 参数: 使用数量 +function XUiBagItem:SetUseRefreshCallback(callback) + self.UseRefreshCallback = callback +end + +-- 参数: 变化量 +function XUiBagItem:SetSelectCountChangedCallback(callback) + self.OnSelectCountChanged = callback +end + +-- 参数: 新的选择状态 +function XUiBagItem:SetSelectStateChangedCallback(callback) + self.OnSelectStateChanged = callback +end + +-- 参数: newCount +function XUiBagItem:SetChangeSelectCountCondition(condition) + self.SelectCountChangeCondition = condition +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiBag/XUiBagItemInfoPanel.lua b/Resources/Scripts/XUi/XUiBag/XUiBagItemInfoPanel.lua new file mode 100644 index 00000000..0c6cfe44 --- /dev/null +++ b/Resources/Scripts/XUi/XUiBag/XUiBagItemInfoPanel.lua @@ -0,0 +1,289 @@ +local XUiBagItemInfoPanel = XLuaUiManager.Register(XLuaUi, "UiBagItemInfoPanel") + +local MIN_SELET_COUNT = 1 +local IsLockBtnAdd = false +local IsLockBtnUse = false +function XUiBagItemInfoPanel:OnAwake() + XTool.InitUiObject(self) + self:InitAutoScript() +end + +function XUiBagItemInfoPanel:OnStart(itemData, useCb, isShowUse) + self:CheckChangeBtnUseListener(useCb) + + self.SelectCount = 0 + self.DefaultMinSelectCount = 0 + + self.WgtBtnAddSelect = self.BtnAddSelect.gameObject:GetComponent("XUiPointer") + self.WgtBtnMinusSelect = self.BtnMinusSelect.gameObject:GetComponent("XUiPointer") + + XUiButtonLongClick.New(self.WgtBtnMinusSelect, 100, self, nil, self.BtnMinusSelectLongClickCallback, nil, true) + XUiButtonLongClick.New(self.WgtBtnAddSelect, 100, self, nil, self.BtnAddSelectLongClickCallback, nil, true) + + self.ItemData = itemData.Data + self.GridIndex = itemData.GridIndex + self.RecycleBatch = itemData.RecycleBatch + + local id = self.ItemData.TemplateId and self.ItemData.TemplateId or self.ItemData.Id + if not id then + XLog.Error("XUiBagItem:RefreshSelf 函数错误: 参数itemData的TemplateId字段和Id字段不能全部为空..") + return + end + self.IsUseable = isShowUse or XDataCenter.ItemManager.IsUseable(id) + self:SetupContent() + self:SetBtnShowOfActionPointOverLimit() +end + +function XUiBagItemInfoPanel:SetupContent() + if not self.ItemData then + return + end + + self:SetupOperation() + self:SetupBaseInfo() +end + +function XUiBagItemInfoPanel:CheckChangeBtnUseListener(useCb) + if useCb then + self:RegisterClickEvent(self.BtnUse, function() useCb(self.ItemData.Id, self.SelectCount) end) + end +end + +function XUiBagItemInfoPanel:OnEnable() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiBagItemInfoPanel:InitAutoScript() + self:AutoAddListener() +end + +function XUiBagItemInfoPanel:AutoAddListener() + self:RegisterClickEvent(self.BtnClose, self.OnBtnCloseClick) + self:RegisterClickEvent(self.BtnGet, self.OnBtnGetClick) + self:RegisterClickEvent(self.BtnAddSelect, self.OnBtnAddSelectClick) + self:RegisterClickEvent(self.BtnMinusSelect, self.OnBtnMinusSelectClick) + self:RegisterClickEvent(self.BtnUse, self.OnBtnUseClick) + self:RegisterClickEvent(self.BtnMax, self.OnBtnMaxClick) +end +-- auto +function XUiBagItemInfoPanel:OnBtnAddSelectClick() + if self.SelectCount <= 0 or self.SelectCount >= self:GetGridCount() then + return + end + if IsLockBtnAdd then + XUiManager.TipMsg(CS.XTextManager.GetText("OverLimitCanNotUse")) + return + end + self:SetSelectCount(self.SelectCount + 1) + self:SetBtnShowOfActionPointOverLimit() +end + +function XUiBagItemInfoPanel:OnBtnMinusSelectClick() + if self.SelectCount <= 0 then + return + end + + self:SetSelectCount(self.SelectCount - 1) + self:SetBtnShowOfActionPointOverLimit() +end + +function XUiBagItemInfoPanel:OnBtnCloseClick() + self:Close() +end + +function XUiBagItemInfoPanel:OnBtnGetClick() + XLuaUiManager.Open("UiSkip", self.ItemData.Template.Id) +end + +function XUiBagItemInfoPanel:BtnMinusSelectLongClickCallback(time) + if self.SelectCount == 0 then + return + end + + local delta = math.max(0, math.floor(time / 150)) + local count = self.SelectCount - delta + if count <= 0 then + count = 0 + end + self:SetSelectCount(count) + self:SetBtnShowOfActionPointOverLimit() +end + +function XUiBagItemInfoPanel:BtnAddSelectLongClickCallback(time) + local maxCount = self:GetGridCount() + if maxCount and self.SelectCount >= maxCount then + return + end + if IsLockBtnAdd then + XUiManager.TipMsg(CS.XTextManager.GetText("OverLimitCanNotUse")) + return + end + local delta = math.max(0, math.floor(time / 150)) + local count = self.SelectCount + delta + if maxCount and count >= maxCount then + count = maxCount + end + + self:SetSelectCount(count) + self:SetBtnShowOfActionPointOverLimit() +end + +function XUiBagItemInfoPanel:SetSelectCount(newCount) + self.SelectCount = math.max(newCount, self.DefaultMinSelectCount) + if self.BtnUse then + self.BtnUse.interactable = newCount > 0 + end + + self.TxtSelect.text = tostring(self.SelectCount) +end + +--设置操作 +function XUiBagItemInfoPanel:SetupOperation() + local isUseable = self.IsUseable + if isUseable then + self.DefaultMinSelectCount = MIN_SELET_COUNT + self.SelectCount = self.DefaultMinSelectCount + self.TxtSelect.text = tostring(MIN_SELET_COUNT) + end + self.BtnMax.gameObject:SetActive(isUseable) + self.BtnMinusSelect.gameObject:SetActive(isUseable) + self.BtnAddSelect.gameObject:SetActive(isUseable) + self.TxtSelect.gameObject:SetActive(isUseable) +end + +--获取当前道具的数量包括堆叠显示 +function XUiBagItemInfoPanel:GetGridCount() + if self.RecycleBatch then + return self.RecycleBatch.RecycleCount + end + + if self.ItemData.Template.GridCount <= 0 then + return self.Data.Count + else + if self.GridIndex then + return math.min(self.ItemData.Count - (self.GridIndex - 1) * self.ItemData.Template.GridCount, self.ItemData.Template.GridCount) + end + end + return self.ItemData.Count +end + +function XUiBagItemInfoPanel:OnBtnUseClick() + if self.SelectCount <= 0 then + return + end + if IsLockBtnUse then + XUiManager.TipMsg(CS.XTextManager.GetText("OverLimitCanNotUse")) + return + end + + local itemId = self.ItemData.Id + local callback = function(rewardGoodsList) + if not XDataCenter.ItemManager.IsRedEnvelope(itemId) then + XUiManager.OpenUiObtain(rewardGoodsList) + end + end + + XDataCenter.ItemManager.Use(self.ItemData.Id, self.RecycleBatch and self.RecycleBatch.RecycleTime, self.SelectCount, callback) + + self:OnBtnCloseClick() + self:SetBtnShowOfActionPointOverLimit() +end + +function XUiBagItemInfoPanel:SetBtnShowOfActionPointOverLimit() + IsLockBtnUse = false + IsLockBtnAdd = false + local GoodsNum = 1 + local RewardIndex = 2 + local ActionPoint = XDataCenter.ItemManager.GetItem(XDataCenter.ItemManager.ItemId.ActionPoint) + for _, v in pairs(XDataCenter.ItemManager.GetCurBatterys()) do + if self.ItemData.Id == v.Data.Id then + local goodsList = XRewardManager.GetRewardList(v.Data.Template.SubTypeParams[RewardIndex]) + if goodsList[GoodsNum].Count * self.SelectCount + ActionPoint:GetCount() > ActionPoint.Template.MaxCount then + IsLockBtnUse = true + end + if goodsList[GoodsNum].Count * (self.SelectCount + 1) + ActionPoint:GetCount() > ActionPoint.Template.MaxCount then + IsLockBtnAdd = true + end + end + end +end + +function XUiBagItemInfoPanel:GetMaxCount() + local maxCount = self:GetGridCount() or 0 + if maxCount == 0 then + return maxCount + end + local tmpMaxCount = 1 + local GoodsNum = 1 + local RewardIndex = 2 + local ActionPoint = XDataCenter.ItemManager.GetItem(XDataCenter.ItemManager.ItemId.ActionPoint) + for _, v in pairs(XDataCenter.ItemManager.GetCurBatterys()) do + if self.ItemData.Id == v.Data.Id then + while (true) do + local goodsList = XRewardManager.GetRewardList(v.Data.Template.SubTypeParams[RewardIndex]) + if tmpMaxCount == maxCount then + break + end + if goodsList[GoodsNum].Count * (tmpMaxCount + 1) + ActionPoint:GetCount() <= ActionPoint.Template.MaxCount then + tmpMaxCount = tmpMaxCount + 1 + else + maxCount = tmpMaxCount + break + end + end + end + end + return maxCount +end + +function XUiBagItemInfoPanel:OnBtnMaxClick() + local maxCount = self:GetMaxCount() + if maxCount and self.SelectCount >= maxCount then + return + end + + self:SetSelectCount(maxCount) + self:SetBtnShowOfActionPointOverLimit() +end + +function XUiBagItemInfoPanel:SetupBaseInfo() + self.BtnUse.gameObject:SetActive(self.IsUseable) + self.BtnUse.interactable = self.SelectCount > 0 + + local template = self.ItemData.Template + self.TxtName.text = template.Name + self.TxtDescription.text = template.Description + XDataCenter.ItemManager.GetItemWorldDesc(self.ItemData.Id); + if template.WorldDesc then + self.TxtWorldDesc.text = string.gsub(template.WorldDesc, "\\n", "\n") + else + self.TxtWorldDesc.text = ""; + end + local count = self:GetGridCount() + self.TxtCount.text = tostring(count) + self.RImgIcon:SetRawImage(template.BigIcon) + if XDataCenter.ItemManager.IsTimeLimit(self.ItemData.Id) then + local leftTime + if self.RecycleBatch then + leftTime = self.RecycleBatch.RecycleTime - XTime.GetServerNowTimestamp() + else + leftTime = XDataCenter.ItemManager.GetRecycleLeftTime(self.ItemData.Id) + end + local deadlineStr = XUiHelper.GetTimeDesc(leftTime, 2) + self.TxtDeadLine.text = leftTime <= 0 and "(" .. deadlineStr .. ")" or CS.XTextManager.GetText("ItemDeadLine", deadlineStr) + self.TxtDeadLine.gameObject:SetActive(true) + else + self.TxtDeadLine.gameObject:SetActive(false) + end + + --获取途径按钮 + local skipIdParams = XGoodsCommonManager.GetGoodsSkipIdParams(self.ItemData.Id) + if skipIdParams and #skipIdParams > 0 then + self.BtnGet.gameObject:SetActive(true) + else + self.BtnGet.gameObject:SetActive(false) + end + + self:SetUiSprite(self.ImgIconBg, XArrangeConfigs.GeQualityBgPath(template.Quality)) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiBag/XUiGridSelectGift.lua b/Resources/Scripts/XUi/XUiBag/XUiGridSelectGift.lua new file mode 100644 index 00000000..84f0aeab --- /dev/null +++ b/Resources/Scripts/XUi/XUiBag/XUiGridSelectGift.lua @@ -0,0 +1,137 @@ +-- +-- Author: wujie +-- Note: 重复打开单选礼包界面中的子项,与XUiBagItem多了显示人物全名、拥有状态 + +XUiGridSelectGift = XClass(XUiBagItem, "XUiGridSelectGift") + +--说明,以下修改为了适用于外部控制统一控制最大选择数量的情况 + +-- 初始化 +function XUiGridSelectGift:Ctor() + self:ExtraInit() +end + +function XUiGridSelectGift:ExtraInit() + self.TxtOwned = XUiHelper.TryGetComponent(self.Transform, "TxtOwned", "Text") + -- 选择Transform + self.ImgSelect = XUiHelper.TryGetComponent(self.Transform, "ImgSelect", nil) +end + +-- 主要是修改物品名字,当物品名字为角色时显示为全名 +function XUiGridSelectGift:RefreshSelf(NeedDefulatQulity, isSmallIcon, notCommonBg) + if self.BtnUse then + local isUseable = XDataCenter.ItemManager.IsUseable(self.TemplateId) + self.BtnUse.gameObject:SetActive(isUseable) + self.BtnUse.interactable = self.SelectCount > 0 + end + + if self.ImgCanUse then + local isUseable = XDataCenter.ItemManager.IsUseable(self.TemplateId) + self.ImgCanUse.gameObject:SetActive(isUseable) + end + + if self.BtnOk then + local isUseable = XDataCenter.ItemManager.IsUseable(self.TemplateId) + self.BtnOk.gameObject:SetActive(not isUseable) + end + + self:RefreshSelfCount() + + local template = self.Template + if self.TxtName then + --对人物显示全名 + if self.Template.RewardType == XRewardManager.XRewardType.Character then + self.TxtName.text = XCharacterConfigs.GetCharacterFullNameStr(self.TemplateId) + else + self.TxtName.text = template.Name + end + end + + if self.TxtDescription then + self.TxtDescription.text = template.Description + end + + if self.TxtWorldDesc then + self.TxtWorldDesc.text = template.WorldDesc + end + + if self.TxtUseLevel then + self.TxtUseLevel.text = CS.XTextManager.GetText("CharacterUpgradeSkillConsumeTitle") .. "Lv." .. template.UseLevel + end + + if self.TxtCount and self.Data.Count ~= nil then + self.TxtCount.text = self.Data.Count + end + + if self.RImgIcon and isSmallIcon then + self.RImgIcon:SetRawImage(template.Icon) + elseif self.RImgIcon and not isSmallIcon then + self.RImgIcon:SetRawImage(template.BigIcon) + end + + local quality = template.Quality + + -- 角色品质背景特殊处理 + if template.RewardType == XRewardManager.XRewardType.Character then + quality = quality < 3 and 5 or 6 + end + + -- 宠物品质背景特殊处理 + if template.RewardType == XRewardManager.XRewardType.Partner then + quality = quality < 3 and 5 or 6 + end + + if self.ImgIconBg then + if self.BtnGet or notCommonBg then + XUiHelper.SetQualityIcon(self.RootUi, self.ImgIconBg, quality) + else + self.RootUi:SetUiSprite(self.ImgIconBg, XArrangeConfigs.GeQualityBgPath(quality)) + end + end + + if self.ImgIconQuality then + XUiHelper.SetQualityIcon(self.RootUi, self.ImgIconQuality, quality) + end + + if NeedDefulatQulity and self.ImgIconBg then + XUiHelper.SetQualityIcon(self.RootUi, self.ImgIconBg, quality) + end + + if self.ImgState then + local sprite = nil + local text = "" + + if XDataCenter.ItemManager.IsCanConvert(self.TemplateId) then + sprite = XUiHelper.TagBgPath.Blue + text = CS.XTextManager.GetText("ItemCanConvert") + elseif XDataCenter.ItemManager.IsTimeLimit(self.TemplateId) then + local leftTime = self.RecycleBatch and self.RecycleBatch.RecycleTime - XTime.GetServerNowTimestamp() + or XDataCenter.ItemManager.GetRecycleLeftTime(self.Data.Id) + text, sprite = XUiHelper.GetBagTimeLimitTimeStrAndBg(leftTime) + end + + if sprite then + self.RootUi:SetUiSprite(self.ImgState, sprite) + self.ImgState.gameObject:SetActive(true) + else + self.ImgState.gameObject:SetActive(false) + end + + if text then + self.TxtState.text = text + self.TxtState.gameObject:SetActive(true) + else + self.TxtState.gameObject:SetActive(false) + end + end + + if self.RefreshCallback then + self.RefreshCallback() + end +end + +function XUiGridSelectGift:SetOwnedStatus(status) + if self.TxtOwned then + self.TxtOwned.gameObject:SetActiveEx(status) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiBag/XUiGridSelectReplicatedGift.lua b/Resources/Scripts/XUi/XUiBag/XUiGridSelectReplicatedGift.lua new file mode 100644 index 00000000..83ac4d54 --- /dev/null +++ b/Resources/Scripts/XUi/XUiBag/XUiGridSelectReplicatedGift.lua @@ -0,0 +1,254 @@ +-- +-- Author: wujie +-- Note: 重复打开单选礼包界面中的子项,与XUiGridSelectGift区分,显示选择数量、长按将数量设置为0 + +XUiGridSelectReplicatedGift = XClass(XUiBagItem, "XUiGridSelectReplicatedGift") + +--说明,以下修改为了适用于外部控制统一控制最大选择数量的情况 + +-- 初始化 +function XUiGridSelectReplicatedGift:Ctor() + self:ExtraInit() +end + +function XUiGridSelectReplicatedGift:ExtraInit() + self.TxtOwned = XUiHelper.TryGetComponent(self.Transform, "TxtOwned", "Text") + -- 选择Transform + self.ImgSelect = XUiHelper.TryGetComponent(self.Transform, "ImgSelect", nil) + if self.BtnMinusSelect then + self.XUiBtnMinusSelect = self.BtnMinusSelect.transform:GetComponent("XUiButton") + end +end + +function XUiGridSelectReplicatedGift:AddSelectCount() + self:UpdateSelectCount(self.SelectCount + 1) +end + +-- 选择操作接口,剔除由自身控制最大数量的判断,仅靠外部统一判断当前数量是否达到最大值 +function XUiGridSelectReplicatedGift:UpdateSelectCount(count) + local newCount = math.max(count, self.DefaultMinSelectCount) + -- 此处来在外部进行最大数量的控制判断 + if self.SelectCountChangeCondition and not self.SelectCountChangeCondition(newCount) then + return + end + + if newCount == self.SelectCount then + return + end + + + self:SetSelectCount(newCount) +end + +-- 变更SetSelectState与OnSelectCountChanged调用顺序,便于外部控制一些状态 +function XUiGridSelectReplicatedGift:SetSelectCount(newCount) + local oldCount = self.SelectCount + self.SelectCount = math.max(newCount, self.DefaultMinSelectCount) + if self.BtnUse then + self.BtnUse.interactable = newCount > 0 + end + + self:SetSelectState(newCount > self.DefaultMinSelectCount, true) + if self.OnSelectCountChanged then + self.OnSelectCountChanged(newCount - oldCount) + end +end + +-- 移除数量达到自身最大时禁止BtnAddSelect交互相关代码,由外部调用SetIsMaxCount控制是否达到最大值 +function XUiGridSelectReplicatedGift:RefreshSelectState() + if self.BtnMinusSelect then + self.BtnMinusSelect.interactable = self.SelectState + if self.SelectCount <= self.DefaultMinSelectCount then + if (not self.IsShowBtnMinusWhenMinSelectCount) then + self.BtnMinusSelect.gameObject:SetActive(false) + -- 处理bug,长按减少按钮按钮隐藏时,按钮为按下状态,需要更改为普通状态 + if self.XUiBtnMinusSelect then + self.XUiBtnMinusSelect:SetButtonState(XUiButtonState.Normal) + end + end + else + self.BtnMinusSelect.gameObject:SetActive(true) + end + end + + if self.TxtSelect then + self.TxtSelect.text = self.SelectCount + if self.SelectCount == 0 then + self.TxtSelect.text = "" + end + end + + if self.TxtSelectHide then + self.TxtSelectHide.gameObject:SetActive(self.SelectState) + if self.SelectState then + self.TxtSelectHide.text = self.SelectCount + end + end + + if self.ImgSelect then + self.ImgSelect.gameObject:SetActive(self.SelectState) + end + + if self.ImgSelectBg then + self.ImgSelectBg.gameObject:SetActive(self.SelectState) + end + + if self.TxtNeedCount and self.NeedCount then + if self.Data.Count >= self.NeedCount then + self.TxtNeedCount.text = self.Data.Count .. "/" .. self.NeedCount + if self.TxtHaveCount then + self.TxtHaveCount.gameObject:SetActive(false) + end + else + self.TxtNeedCount.text = "/" .. self.NeedCount + if self.TxtHaveCount then + self.TxtHaveCount.text = self.Data.Count + self.TxtHaveCount.gameObject:SetActive(true) + end + end + end +end + +-- 主要是修改物品名字,当物品名字为角色时显示为全名 +function XUiGridSelectReplicatedGift:RefreshSelf(NeedDefulatQulity, isSmallIcon, notCommonBg) + if self.BtnUse then + local isUseable = XDataCenter.ItemManager.IsUseable(self.TemplateId) + self.BtnUse.gameObject:SetActive(isUseable) + self.BtnUse.interactable = self.SelectCount > 0 + end + + if self.ImgCanUse then + local isUseable = XDataCenter.ItemManager.IsUseable(self.TemplateId) + self.ImgCanUse.gameObject:SetActive(isUseable) + end + + if self.BtnOk then + local isUseable = XDataCenter.ItemManager.IsUseable(self.TemplateId) + self.BtnOk.gameObject:SetActive(not isUseable) + end + + self:RefreshSelfCount() + + local template = self.Template + if self.TxtName then + --对人物显示全名 + if self.Template.RewardType == XRewardManager.XRewardType.Character then + self.TxtName.text = XCharacterConfigs.GetCharacterFullNameStr(self.TemplateId) + else + self.TxtName.text = template.Name + end + end + + if self.TxtDescription then + self.TxtDescription.text = template.Description + end + + if self.TxtWorldDesc then + self.TxtWorldDesc.text = template.WorldDesc + end + + if self.TxtUseLevel then + self.TxtUseLevel.text = CS.XTextManager.GetText("CharacterUpgradeSkillConsumeTitle") .. "Lv." .. template.UseLevel + end + + if self.TxtCount and self.Data.Count ~= nil then + + self.TxtCount.text = self.Data.Count + end + + if self.RImgIcon and isSmallIcon then + self.RImgIcon:SetRawImage(template.Icon) + elseif self.RImgIcon and not isSmallIcon then + self.RImgIcon:SetRawImage(template.BigIcon) + end + + local quality = template.Quality + + if template.RewardType == XRewardManager.XRewardType.Character then + quality = quality < 3 and 5 or 6 + end + + -- 宠物品质背景特殊处理 + if template.RewardType == XRewardManager.XRewardType.Partner then + quality = quality < 3 and 5 or 6 + end + + if self.ImgIconBg then + if self.BtnGet or notCommonBg then + XUiHelper.SetQualityIcon(self.RootUi, self.ImgIconBg, quality) + else + self.RootUi:SetUiSprite(self.ImgIconBg, XArrangeConfigs.GeQualityBgPath(quality)) + end + end + + if self.ImgIconQuality then + XUiHelper.SetQualityIcon(self.RootUi, self.ImgIconQuality, quality) + end + + if NeedDefulatQulity and self.ImgIconBg then + XUiHelper.SetQualityIcon(self.RootUi, self.ImgIconBg, quality) + end + + if self.ImgState then + local sprite = nil + local text = "" + + if XDataCenter.ItemManager.IsCanConvert(self.TemplateId) then + sprite = XUiHelper.TagBgPath.Blue + text = CS.XTextManager.GetText("ItemCanConvert") + elseif XDataCenter.ItemManager.IsTimeLimit(self.TemplateId) then + local leftTime = self.RecycleBatch and self.RecycleBatch.RecycleTime - XTime.GetServerNowTimestamp() + or XDataCenter.ItemManager.GetRecycleLeftTime(self.Data.Id) + text, sprite = XUiHelper.GetBagTimeLimitTimeStrAndBg(leftTime) + end + + if sprite then + self.RootUi:SetUiSprite(self.ImgState, sprite) + self.ImgState.gameObject:SetActive(true) + else + self.ImgState.gameObject:SetActive(false) + end + + if text then + self.TxtState.text = text + self.TxtState.gameObject:SetActive(true) + else + self.TxtState.gameObject:SetActive(false) + end + end + + if self.RefreshCallback then + self.RefreshCallback() + end +end + +-- 策划新需求,长按一会儿将数量设置为0 +function XUiGridSelectReplicatedGift:BtnMinusSelectLongClickCallback(time) + if self.SelectCount == 0 then + return + end + local count = self.SelectCount + local longClickClearSelelctionTime = CS.XGame.ClientConfig:GetInt("SelectReplicatedGiftMinusBtnLongClickTime") + if time > longClickClearSelelctionTime then + count = 0 + else + count = count - 1 + if count <= 0 then + count = 0 + end + end + self:UpdateSelectCount(count) +end + +-- 由外部统一判断是否达到总数量上限 +function XUiGridSelectReplicatedGift:SetIsMaxCount(status) + if self.BtnAddSelect then + self.BtnAddSelect.interactable = not status + end +end + +function XUiGridSelectReplicatedGift:SetOwnedStatus(status) + if self.TxtOwned then + self.TxtOwned.gameObject:SetActiveEx(status) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiBag/XUiPanelBagItem.lua b/Resources/Scripts/XUi/XUiBag/XUiPanelBagItem.lua new file mode 100644 index 00000000..16cf0070 --- /dev/null +++ b/Resources/Scripts/XUi/XUiBag/XUiPanelBagItem.lua @@ -0,0 +1,92 @@ +local XUiGridEquip = require("XUi/XUiEquipAwarenessReplace/XUiGridEquip") +local XUiGridSuitDetail = require("XUi/XUiEquipAwarenessReplace/XUiGridSuitDetail") +local XUiGridBagPartner = require("XUi/XUiPartner/PartnerCommon/XUiGridBagPartner") +local XUiPanelBagItem = XClass(nil, "XUiPanelBagItem") + +function XUiPanelBagItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiPanelBagItem:Init(rootUi, page, isfirstanimation) + self.GameObject:SetActive(true) + self.Parent = rootUi + self.Page = page + self.IsFirstAnimation = isfirstanimation + local clickCb = function(data, grid) + self.Parent:OnGridClick(data, grid) + end + + self.EquipGrid = XUiGridEquip.New(self.GridEquip, clickCb, rootUi) + self.SuitGrid = XUiGridSuitDetail.New(self.GridSuitSimple, rootUi, clickCb) + self.BagItemGrid = XUiBagItem.New(rootUi, self.GridBagItem, nil, clickCb) + self.BagPartnerGrid = XUiGridBagPartner.New(self.GridPartner, clickCb) +end + +function XUiPanelBagItem:SetupCommon(data, pageType, operation, gridSize) + self.BagItemGrid:Refresh(data) + self.BagItemGrid.GameObject:SetActive(true) + self.GridBagItemRect.sizeDelta = gridSize + self.EquipGrid.GameObject:SetActive(false) + self.SuitGrid.GameObject:SetActive(false) + self.BagPartnerGrid.GameObject:SetActive(false) +end + +function XUiPanelBagItem:SetupEquip(equipId, gridSize) + self.EquipGrid:Refresh(equipId) + self.EquipGrid.GameObject:SetActive(true) + self.GridEquipRect.sizeDelta = gridSize + self.SuitGrid.GameObject:SetActive(false) + self.BagItemGrid.GameObject:SetActive(false) + self.BagPartnerGrid.GameObject:SetActive(false) +end + +function XUiPanelBagItem:SetupSuit(suitId, defaultSuitIds, gridSize) + self.SuitGrid:Refresh(suitId, defaultSuitIds, true) + self.SuitGrid.GameObject:SetActive(true) + self.GridSuitSimpleRect.sizeDelta = gridSize + self.EquipGrid.GameObject:SetActive(false) + self.BagItemGrid.GameObject:SetActive(false) + self.BagPartnerGrid.GameObject:SetActive(false) +end + +function XUiPanelBagItem:SetupPartner(partner, gridSize) + self.BagPartnerGrid:UpdateGrid(partner) + self.BagPartnerGrid.GameObject:SetActive(true) + self.BagPartnerGrid.sizeDelta = gridSize + self.EquipGrid.GameObject:SetActive(false) + self.BagItemGrid.GameObject:SetActive(false) + self.SuitGrid.GameObject:SetActive(false) +end + +function XUiPanelBagItem:SetSelectedEquip(bSelect) + self.EquipGrid:SetSelected(bSelect) +end + +function XUiPanelBagItem:SetSelectedCommon(bSelect) + self.BagItemGrid:SetSelectState(bSelect) +end + +function XUiPanelBagItem:SetSelectedPartner(bSelect) + self.BagPartnerGrid:SetSelected(bSelect) +end + +function XUiPanelBagItem:PlayAnimation() + if not self.IsFirstAnimation then + return + end + + self.IsFirstAnimation = false + if self.Page == XItemConfigs.PageType.Equip or self.Page == XItemConfigs.PageType.Awareness then + self.GridEquipTimeline:PlayTimelineAnimation() + elseif self.Page == XItemConfigs.PageType.SuitCover then + self.GridSuitSimpleTimeline:PlayTimelineAnimation() + elseif self.Page == XItemConfigs.PageType.Partner then + self.GridPartnerTimeline:PlayTimelineAnimation() + else + self.GridBagItemTimeline:PlayTimelineAnimation() + end +end + +return XUiPanelBagItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiBag/XUiPanelBagRecycle.lua b/Resources/Scripts/XUi/XUiBag/XUiPanelBagRecycle.lua new file mode 100644 index 00000000..1b411f96 --- /dev/null +++ b/Resources/Scripts/XUi/XUiBag/XUiPanelBagRecycle.lua @@ -0,0 +1,46 @@ +local XUiPanelBagRecycle = XClass(nil, "XUiPanelBagRecycle") + +function XUiPanelBagRecycle:Ctor(rootUi, ui) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RecycleItems = {} + self.RewardItems = {} + + XTool.InitUiObject(self) + self:AutoAddListener() + + self.GridBagItemRecycle.gameObject:SetActive(false) +end + +function XUiPanelBagRecycle:Refresh(recycleItems, rewardItems) + local recycleGridDatas = {} + for index, item in pairs(recycleItems) do + table.insert(recycleGridDatas, { Data = XRewardManager.CreateRewardGoods(item.Id, item.Count), GridIndex = index }) + end + + local rewardGridDatas = {} + local sortedRewardItems = XRewardManager.MergeAndSortRewardGoodsList(rewardItems) + for index, data in pairs(sortedRewardItems) do + table.insert(rewardGridDatas, { Data = data, GridIndex = index }) + end + + local onCreate = function(item, data) + item:Refresh(data, false, true, true) + end + XUiHelper.CreateTemplates(self.RootUi, self.RecycleItems, recycleGridDatas, XUiBagItem.New, self.GridBagItemRecycle.gameObject, self.PanelRecycle, onCreate) + XUiHelper.CreateTemplates(self.RootUi, self.RewardItems, rewardGridDatas, XUiBagItem.New, self.GridBagItemRecycle.gameObject, self.PanelReward, onCreate) + self.GameObject:SetActive(true) + self.RootUi:PlayAnimation("AnimTanChuangEnable") +end + +function XUiPanelBagRecycle:AutoAddListener() + self.BtnClose.CallBack = function() self:OnBtnCloseClick() end +end + +function XUiPanelBagRecycle:OnBtnCloseClick() + self.RootUi:PlayAnimation("AnimTanChuangDisable") + self.GameObject:SetActive(false) +end + +return XUiPanelBagRecycle \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiBag/XUiPanelSelectGift.lua b/Resources/Scripts/XUi/XUiBag/XUiPanelSelectGift.lua new file mode 100644 index 00000000..50ae6710 --- /dev/null +++ b/Resources/Scripts/XUi/XUiBag/XUiPanelSelectGift.lua @@ -0,0 +1,286 @@ +local CsGetText = CS.XTextManager.GetText +local XUiPanelSelectGift = XClass(nil, "XUiPanelSelectGift") + +function XUiPanelSelectGift:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self.RewardItems = {} + + XTool.InitUiObject(self) + self:AutoAddListener() + self.GameObject:SetActiveEx(false) +end + +function XUiPanelSelectGift:Refresh(id) + self.ItemId = id + self.RewardId = XDataCenter.ItemManager.GetSelectGiftRewardId(id) + + + self.GridDatas = {} + local rewardItems = XRewardManager.GetRewardList(self.RewardId) + for index, data in pairs(rewardItems) do + table.insert(self.GridDatas, { Data = data, GridIndex = index }) + end + + local onCreate = function(item, data) + item:Refresh(data, false, true, true) + + item:SetOwnedStatus(XRewardManager.CheckRewardOwn(data.Data.RewardType, data.Data.TemplateId)) + end + self.GridRewardItem.gameObject:SetActiveEx(false) + XUiHelper.CreateTemplates(self.RootUi, self.RewardItems, self.GridDatas, XUiGridSelectGift.New, self.GridRewardItem.gameObject, self.PanelReward, onCreate) + + local count = #self.GridDatas + local grid + for i = 1, count do + grid = self.RewardItems[i] + if grid then + grid:SetClickCallback(function(gridData, tmpGrid) + self:SelectRewardGrid(gridData, tmpGrid) + end) + + local gridData = self.GridDatas[i].Data + grid:SetClickCallback2(function() + self:OpenDetailUi(gridData) + end) + end + + end + + self.SelectGridIndexs = {} + self.SelectCount = 0 + self.LastSelectGrid = nil + local template = XDataCenter.ItemManager.GetItem(id).Template + self.SupposedCount = template.SelectCount + + self.TxtGiftName.text = template.Name + self.TxtCanSelectNum.text = CS.XTextManager.GetText("SelectGiftCount", template.SelectCount) + self.TxtGfitCount.text = CS.XTextManager.GetText("ItemHaveSelectedCount", self.SelectCount, self.SupposedCount) + + self.GameObject:SetActiveEx(true) + self.PanelCantConfirm.gameObject:SetActiveEx(self.SelectCount ~= self.SupposedCount) + self.BtnConfirm.gameObject:SetActiveEx(self.SelectCount == self.SupposedCount) + self.RootUi:PlayAnimation("AnimSelectGiftEnable") +end + +function XUiPanelSelectGift:SelectRewardGrid(gridData, grid) + local id = gridData.Data.TemplateId + if not self.SelectGridIndexs[id] then + if self.SupposedCount == 1 then + if self.LastSelectGrid then + self.SelectGridIndexs = {} + self.LastSelectGrid:SetSelectState(false) + self.SelectCount = 0 + end + self.LastSelectGrid = grid + else + if self.SelectCount >= self.SupposedCount then + XUiManager.TipText("SelectGiftMaxCount") + return + end + end + self.SelectCount = self.SelectCount + 1 + self.SelectGridIndexs[id] = gridData.GridIndex + grid:SetSelectState(true) + else + self.SelectCount = self.SelectCount - 1 + self.SelectGridIndexs[id] = nil + grid:SetSelectState(false) + end + + self.TxtGfitCount.text = CS.XTextManager.GetText("ItemHaveSelectedCount", self.SelectCount, self.SupposedCount) + self.BtnConfirm.gameObject:SetActiveEx(self.SelectCount == self.SupposedCount) + self.PanelCantConfirm.gameObject:SetActiveEx(self.SelectCount ~= self.SupposedCount) +end + +function XUiPanelSelectGift:OpenDetailUi(data) + if data.RewardType == XRewardManager.XRewardType.Character then + XLuaUiManager.Open("UiCharacterDetail", data.TemplateId) + elseif data.RewardType == XRewardManager.XRewardType.Equip then + XLuaUiManager.Open("UiEquipDetail", data.TemplateId, true) + elseif data.RewardType == XRewardManager.XRewardType.Fashion then + XLuaUiManager.Open("UiFashionDetail", data.TemplateId, false, nil) + elseif data.RewardType == XRewardManager.XRewardType.Partner then + local partnerData = {Id = 0,TemplateId = data.TemplateId} + local partner = XDataCenter.PartnerManager.CreatePartnerEntityByPartnerData(partnerData, true) + XLuaUiManager.Open("UiPartnerPreview", partner) + else + if XDataCenter.ItemManager.IsWeaponFashion(data.TemplateId) then + local weaponFashionId = XDataCenter.ItemManager.GetWeaponFashionId(data.TemplateId) + XLuaUiManager.Open("UiFashionDetail", weaponFashionId, true, nil) + else + XLuaUiManager.Open("UiTip", data, true) + end + end +end + +function XUiPanelSelectGift:AutoAddListener() + self.BtnClose.CallBack = function() self:Close() end + self.BtnCloseAllScreen.CallBack = function() self:Close() end + self.BtnConfirm.CallBack = function() self:OnBtnConfirmClick() end + self.BtnClearSelection.CallBack = function() self:OnBtnClearSelectionClick() end +end + +function XUiPanelSelectGift:HandleConfirmClick(itemId ,rewardIds, rewardHasOwnTypeList) + local handle = function() + + local weaponFashionTemplateIdList = {} + --如果武器涂装增加了时间,则循环提示 + local loopTips + loopTips = function() + if #weaponFashionTemplateIdList > 0 then + local currentRewardTemplateId = table.remove(weaponFashionTemplateIdList) + --判断是不是武器涂装类型 + local weaponFashionId = XDataCenter.ItemManager.GetWeaponFashionId(currentRewardTemplateId) + local weaponFashion = XDataCenter.WeaponFashionManager.GetWeaponFashion(weaponFashionId) + local time = XDataCenter.ItemManager.GetWeaponFashionAddTime(currentRewardTemplateId) + if weaponFashion and weaponFashion:IsTimeLimit() and time then + --此时提示叠加时长信息 + local addTime = XUiHelper.GetTime(time, XUiHelper.TimeFormatType.DEFAULT) + local weaponFashionId = XDataCenter.ItemManager.GetWeaponFashionId(currentRewardTemplateId) + local weaponFashionName = XDataCenter.WeaponFashionManager.GetWeaponFashionName(weaponFashionId) + local descStr = CsGetText("WeaponFashionLimitGetAlreadyHaveLimit", weaponFashionName, addTime) + XUiManager.TipMsg(descStr, nil, loopTips) + end + else + return + end + end + + local callback = function(rewardGoodsList) + local resultGoodsList = {} + --如果武器涂装增加了时间,则逐条显示遍历 + local isNotifyWeaponFashionTransform = XDataCenter.WeaponFashionManager.GetIsNotifyWeaponFashionTransform() + weaponFashionTemplateIdList = {} + for _, rewardGoodsId in pairs(rewardGoodsList) do + if XDataCenter.ItemManager.IsWeaponFashion(rewardGoodsId.TemplateId) and isNotifyWeaponFashionTransform then + table.insert(weaponFashionTemplateIdList, rewardGoodsId.TemplateId) + else + table.insert(resultGoodsList, rewardGoodsId) + end + end + + XDataCenter.WeaponFashionManager.ResetIsNotifyWeaponFashionTransform() + + if #resultGoodsList > 0 then + XUiManager.OpenUiObtain(resultGoodsList) + end + loopTips(weaponFashionTemplateIdList) + end + + XDataCenter.ItemManager.Use(itemId, nil, 1, callback, rewardIds) + self:Close() + end + + local confirmCallback + local confirmLoop + confirmCallback = function() + if #rewardHasOwnTypeList > 0 then + if confirmLoop then + confirmLoop() + end + else + handle() + end + end + confirmLoop = function() + local tab = table.remove(rewardHasOwnTypeList) + if XDataCenter.ItemManager.IsWeaponFashion(tab.templateId) then + local weaponFashionId = XDataCenter.ItemManager.GetWeaponFashionId(tab.templateId) + local time = XDataCenter.ItemManager.GetWeaponFashionAddTime(tab.templateId) + local weaponFashion = XDataCenter.WeaponFashionManager.GetWeaponFashion(weaponFashionId) + local title = CsGetText("WeaponFashionGetTitleInfo") + local msg + --判断武器时装是不是永久的 + if weaponFashion and weaponFashion:IsTimeLimit() then + if not time then + msg = CsGetText("WeaponFashionForeverGetAlreadyHaveLimit") + else + confirmCallback() + return + end + else + if not time then + msg = CsGetText("WeaponFashionForeverGetAlreadyHaveForever") + else + msg = CsGetText("WeaponFashionLimitGetAlreadyHaveForever") + end + end + + XUiManager.DialogTip( + title, + msg, + XUiManager.DialogType.Normal, + nil, + confirmCallback + ) + else + local template = XRewardConfigs.GetRewardConfirmTemplate(tab.type) + local title = template.Title + local msg = template.Content + XUiManager.DialogTip( + title, + msg, + XUiManager.DialogType.Normal, + nil, + confirmCallback + ) + end + end + + if rewardHasOwnTypeList then + table.sort(rewardHasOwnTypeList, function(a, b) + local aTemplate = XRewardConfigs.GetRewardConfirmTemplate(a.type) + local bTemplate = XRewardConfigs.GetRewardConfirmTemplate(b.type) + local aPriority = aTemplate and aTemplate.Priority or 1 + local bPriority = bTemplate and bTemplate.Priority or 1 + return aPriority > bPriority + end) + confirmLoop() + else + handle() + end +end + +function XUiPanelSelectGift:OnBtnConfirmClick() + if self.SelectCount ~= self.SupposedCount then return end + + local rewardHasOwnTypeDic + local gridData + local rewardIds = {} + for _, index in pairs(self.SelectGridIndexs) do + table.insert(rewardIds, XRewardManager.GetRewardSubId(self.RewardId, index)) + gridData = self.GridDatas[index].Data + if XRewardManager.CheckRewardOwn(gridData.RewardType, gridData.TemplateId) then + rewardHasOwnTypeDic = rewardHasOwnTypeDic or {} + rewardHasOwnTypeDic[gridData.RewardType] = gridData.TemplateId + end + end + + local rewardHasOwnTypeList + if rewardHasOwnTypeDic then + rewardHasOwnTypeList = {} + for type, templateId in pairs(rewardHasOwnTypeDic) do + local tab = {} + tab.type = type + tab.templateId = templateId + table.insert(rewardHasOwnTypeList, tab) + end + end + self:HandleConfirmClick(self.ItemId, rewardIds, rewardHasOwnTypeList) +end + +function XUiPanelSelectGift:OnBtnClearSelectionClick() + for _, index in pairs(self.SelectGridIndexs)do + self:SelectRewardGrid(self.GridDatas[index], self.RewardItems[index]) + end + self.PanelCantConfirm.gameObject:SetActiveEx(self.SelectCount ~= self.SupposedCount) + self.BtnConfirm.gameObject:SetActiveEx(self.SelectCount == self.SupposedCount) +end + +function XUiPanelSelectGift:Close() + self.GameObject:SetActiveEx(false) +end + +return XUiPanelSelectGift \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiBag/XUiPanelSelectReplicatedGift.lua b/Resources/Scripts/XUi/XUiBag/XUiPanelSelectReplicatedGift.lua new file mode 100644 index 00000000..54cc3a63 --- /dev/null +++ b/Resources/Scripts/XUi/XUiBag/XUiPanelSelectReplicatedGift.lua @@ -0,0 +1,304 @@ +-- +-- Author: wujie +-- Note: 重复打开单选礼包界面,与XUiPanelSelectGift区分,走不同逻辑 +local CsGetText = CS.XTextManager.GetText + +local XUiPanelSelectReplicatedGift = XClass(nil, "XUiPanelSelectReplicatedGift") + +-- local XUiGridSelectReplicatedGift = require("XUi/XUiBag/XUiGridSelectReplicatedGift") + +function XUiPanelSelectReplicatedGift:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + + self.RewardItemList = {} + self.CategoryCount = 0 + self.CurSelectCount = 0 + self.MaxSelectCount = 0 + + XTool.InitUiObject(self) + self:AutoAddListener() + self.GameObject:SetActiveEx(false) +end + +function XUiPanelSelectReplicatedGift:AutoAddListener() + self.BtnClose.CallBack = function() self:Close() end + self.BtnCloseAllScreen.CallBack = function() self:Close() end + self.BtnConfirm.CallBack = function() self:OnBtnConfirmClick() end + self.BtnClearSelection.CallBack = function() self:OnBtnClearSelectionClick() end +end + +function XUiPanelSelectReplicatedGift:Open(itemId,maxSelectCount) + self.GameObject:SetActiveEx(true) + self.ItemId = itemId + + self.CurSelectCount = 0 + self.MaxSelectCount = maxSelectCount + + self.RewardId = XDataCenter.ItemManager.GetSelectGiftRewardId(itemId) + self.GridDataList = {} + local rewardDataList = XRewardManager.GetRewardList(self.RewardId) + for index, data in pairs(rewardDataList) do + table.insert(self.GridDataList, {Data = data, GridIndex = index}) + end + + + local onCreate = function(item, data) + item:Refresh(data, false, true, true) + item:SetOwnedStatus(XRewardManager.CheckRewardOwn(data.Data.RewardType, data.Data.TemplateId)) + end + + self.GridRewardItem.gameObject:SetActiveEx(false) + XUiHelper.CreateTemplates(self.RootUi, self.RewardItemList, self.GridDataList, XUiGridSelectReplicatedGift.New, self.GridRewardItem.gameObject, self.PanelReward, onCreate) + + + local count = #self.GridDataList + self.CategoryCount = count + local grid + for i = 1, count do + grid = self.RewardItemList[i] + if grid then + local gridData = self.GridDataList[i].Data + grid:SetClickCallback2(function() + self:OpenDetailUi(gridData, grid) + end) + + grid:SetChangeSelectCountCondition(function(newCount) + local isInCount = self:JudgeSelectCondition(i, newCount) + if not isInCount then + XUiManager.TipError(CS.XTextManager.GetText("ItemSelectedCountOverLimit")) + end + return isInCount + end) + + grid:SetSelectCountChangedCallback(function(deltaCount) + self:UpdateSelection(deltaCount) + end) + end + end + + local template = XDataCenter.ItemManager.GetItem(itemId).Template + self.TxtGiftName.text = template.Name + self.TxtCanSelectNum.text = CS.XTextManager.GetText("SelectReplicatedGiftCount", maxSelectCount) + + self.TxtGfitCount.text = CS.XTextManager.GetText("ItemHaveSelectedCount", self.CurSelectCount, self.MaxSelectCount) + self:UpdateConfirmStatus() + self.RootUi:PlayAnimation("AnimSelectReplicatedGift") +end + +function XUiPanelSelectReplicatedGift:OpenDetailUi(data) + if data.RewardType == XRewardManager.XRewardType.Character then + XLuaUiManager.Open("UiCharacterDetail", data.TemplateId) + elseif data.RewardType == XRewardManager.XRewardType.Equip then + XLuaUiManager.Open("UiEquipDetail", data.TemplateId, true) + elseif data.RewardType == XRewardManager.XRewardType.Fashion then + XLuaUiManager.Open("UiFashionDetail", data.TemplateId, false, nil) + elseif data.RewardType == XRewardManager.XRewardType.Partner then + local partnerData = {Id = 0,TemplateId = data.TemplateId} + local partner = XDataCenter.PartnerManager.CreatePartnerEntityByPartnerData(partnerData, true) + XLuaUiManager.Open("UiPartnerPreview", partner) + else + if XDataCenter.ItemManager.IsWeaponFashion(data.TemplateId) then + local weaponFashionId = XDataCenter.ItemManager.GetWeaponFashionId(data.TemplateId) + XLuaUiManager.Open("UiFashionDetail", weaponFashionId, true, nil) + else + XLuaUiManager.Open("UiTip", data, true) + end + end +end + +function XUiPanelSelectReplicatedGift:JudgeSelectCondition(index, count) + local deltaCount = count - self.RewardItemList[index]:GetSelectCount() + return self.CurSelectCount + deltaCount <= self.MaxSelectCount +end + +function XUiPanelSelectReplicatedGift:UpdateSelection(deltaCount) + self.CurSelectCount = self.CurSelectCount + deltaCount + self.TxtGfitCount.text = CS.XTextManager.GetText("ItemHaveSelectedCount", self.CurSelectCount, self.MaxSelectCount) + self:UpdateConfirmStatus() +end + +function XUiPanelSelectReplicatedGift:UpdateConfirmStatus() + self.PanelCantConfirm.gameObject:SetActiveEx(self.CurSelectCount == 0) + self.BtnConfirm.gameObject:SetActiveEx(self.CurSelectCount ~= 0) +end + +function XUiPanelSelectReplicatedGift:HandleConfirmClick(useList, rewardHasOwnTypeList) + local handle = function() + + local weaponFashionTemplateIdList = {} + --如果武器涂装增加了时间,则循环提示 + local loopTips + loopTips = function() + if #weaponFashionTemplateIdList > 0 then + local currentRewardTemplateId = table.remove(weaponFashionTemplateIdList) + --判断是不是武器涂装类型 + local weaponFashionId = XDataCenter.ItemManager.GetWeaponFashionId(currentRewardTemplateId) + local weaponFashion = XDataCenter.WeaponFashionManager.GetWeaponFashion(weaponFashionId) + local time = XDataCenter.ItemManager.GetWeaponFashionAddTime(currentRewardTemplateId) + if weaponFashion and weaponFashion:IsTimeLimit() and time then + --此时提示叠加时长信息 + local addTime = XUiHelper.GetTime(time, XUiHelper.TimeFormatType.DEFAULT) + local weaponFashionId = XDataCenter.ItemManager.GetWeaponFashionId(currentRewardTemplateId) + local weaponFashionName = XDataCenter.WeaponFashionManager.GetWeaponFashionName(weaponFashionId) + local descStr = CsGetText("WeaponFashionLimitGetAlreadyHaveLimit", weaponFashionName, addTime) + XUiManager.TipMsg(descStr, nil, loopTips) + end + else + return + end + end + + local callback = function(rewardGoodsList) + local resultGoodsList = {} + --如果武器涂装增加了时间,则逐条显示遍历 + local isNotifyWeaponFashionTransform = XDataCenter.WeaponFashionManager.GetIsNotifyWeaponFashionTransform() + weaponFashionTemplateIdList = {} + for _, rewardGoodsId in pairs(rewardGoodsList) do + if XDataCenter.ItemManager.IsWeaponFashion(rewardGoodsId.TemplateId) and isNotifyWeaponFashionTransform then + table.insert(weaponFashionTemplateIdList, rewardGoodsId.TemplateId) + else + table.insert(resultGoodsList, rewardGoodsId) + end + end + + XDataCenter.WeaponFashionManager.ResetIsNotifyWeaponFashionTransform() + + if #resultGoodsList > 0 then + XUiManager.OpenUiObtain(resultGoodsList) + end + loopTips(weaponFashionTemplateIdList) + end + + XDataCenter.ItemManager.MultiplyUse(useList, callback) + self:Close() + end + + local confirmCallback + local confirmLoop + confirmCallback = function() + if #rewardHasOwnTypeList > 0 then + if confirmLoop then + confirmLoop() + end + else + handle() + end + end + confirmLoop = function() + local tab = table.remove(rewardHasOwnTypeList) + if XDataCenter.ItemManager.IsWeaponFashion(tab.templateId) then + local weaponFashionId = XDataCenter.ItemManager.GetWeaponFashionId(tab.templateId) + local time = XDataCenter.ItemManager.GetWeaponFashionAddTime(tab.templateId) + local weaponFashion = XDataCenter.WeaponFashionManager.GetWeaponFashion(weaponFashionId) + local title = CsGetText("WeaponFashionGetTitleInfo") + local msg + --判断武器时装是不是永久的 + if weaponFashion and weaponFashion:IsTimeLimit() then + if not time then + msg = CsGetText("WeaponFashionForeverGetAlreadyHaveLimit") + else + confirmCallback() + return + end + else + if not time then + msg = CsGetText("WeaponFashionForeverGetAlreadyHaveForever") + else + msg = CsGetText("WeaponFashionLimitGetAlreadyHaveForever") + end + end + + XUiManager.DialogTip( + title, + msg, + XUiManager.DialogType.Normal, + nil, + confirmCallback + ) + else + local template = XRewardConfigs.GetRewardConfirmTemplate(tab.type) + local title = template.Title + local msg = template.Content + XUiManager.DialogTip( + title, + msg, + XUiManager.DialogType.Normal, + nil, + confirmCallback + ) + end + end + + if rewardHasOwnTypeList then + table.sort(rewardHasOwnTypeList, function(a, b) + local aTemplate = XRewardConfigs.GetRewardConfirmTemplate(a.type) + local bTemplate = XRewardConfigs.GetRewardConfirmTemplate(b.type) + local aPriority = aTemplate and aTemplate.Priority or 1 + local bPriority = bTemplate and bTemplate.Priority or 1 + return aPriority > bPriority + end) + confirmLoop() + else + handle() + end +end + +function XUiPanelSelectReplicatedGift:OnBtnConfirmClick() + if self.CurSelectCount == 0 then return end + + local useList = {} + + local grid + local rewardHasOwnTypeDic + local count + local gridData + local useData + for index = 1, self.CategoryCount do + grid = self.RewardItemList[index] + count = grid:GetSelectCount() + + local rewardId = XRewardManager.GetRewardSubId(self.RewardId, index) + for _ = 1, count do + useData = {} + useData.Id = self.ItemId + useData.Count = 1 + useData.SelectRewardIds = {} + table.insert(useData.SelectRewardIds, rewardId) + table.insert(useList, useData) + end + + gridData = self.GridDataList[index].Data + if count > 0 and XRewardManager.CheckRewardOwn(gridData.RewardType, gridData.TemplateId) then + rewardHasOwnTypeDic = rewardHasOwnTypeDic or {} + rewardHasOwnTypeDic[gridData.RewardType] = gridData.TemplateId + end + end + + local rewardHasOwnTypeList + if rewardHasOwnTypeDic then + rewardHasOwnTypeList = {} + for type, templateId in pairs(rewardHasOwnTypeDic) do + local tab = {} + tab.type = type + tab.templateId = templateId + table.insert(rewardHasOwnTypeList, tab) + end + end + self:HandleConfirmClick(useList, rewardHasOwnTypeList) +end + +function XUiPanelSelectReplicatedGift:OnBtnClearSelectionClick() + for i = 1, self.CategoryCount do + self.RewardItemList[i]:ClearSelectState() + end + self.TxtGfitCount.text = CS.XTextManager.GetText("ItemHaveSelectedCount", self.CurSelectCount, self.MaxSelectCount) + self:UpdateConfirmStatus() +end + +function XUiPanelSelectReplicatedGift:Close() + self.GameObject:SetActiveEx(false) +end + +return XUiPanelSelectReplicatedGift \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiBag/XUiPanelSidePopUp.lua b/Resources/Scripts/XUi/XUiBag/XUiPanelSidePopUp.lua new file mode 100644 index 00000000..0d96de43 --- /dev/null +++ b/Resources/Scripts/XUi/XUiBag/XUiPanelSidePopUp.lua @@ -0,0 +1,533 @@ +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate + +local DECOMPOSE_PARTNER_QUALITY = 2 --超过(包含)这个品质的伙伴分解时需要二次确认 +local DECOMPOSE_SECOND_CHECK_EQUIP_STAR = 4 --超过(包含)这个星星的装备分解时需要二次确认 +local RECYCLE_SECOND_CHECK_EQUIP_STAR = 5 --超过(包含)这个星星的装备回收时需要二次确认 +local SECOND_CHECK_ITEM_QUALITY = 5 --超过(包含)这个品质的物品出售时需要二次确认 +local TOG_INDEX_TO_STAR_CHECK_DIC = { + [1] = { + [1] = true, + [2] = true, + [3] = true, + }, + [2] = { + [4] = true, + }, + [3] = { + [5] = true, + }, +} + +local XUiPanelSidePopUp = XClass(nil, "XUiPanelSidePopUp") + +function XUiPanelSidePopUp:Ctor(ui, parent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Parent = parent + self.SelectCount = 0 + + XTool.InitUiObject(self) + self:AutoAddListener() + self:InitDynamicTable() + + self.GridCommonPopUp.gameObject:SetActiveEx(false) +end + +function XUiPanelSidePopUp:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelDynamicTablePopUp) + self.DynamicTable:SetProxy(XUiGridCommon) + self.DynamicTable:SetDelegate(self) +end + +function XUiPanelSidePopUp:UpdateDynamicTable(bReload) + self.DynamicTable:SetDataSource(self.Rewards) + self.DynamicTable:ReloadDataASync(bReload and 1 or -1) +end + +function XUiPanelSidePopUp:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self.Parent) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:Refresh(self.Rewards[index]) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + XLuaUiManager.Open("UiTip", self.Rewards[index]) + end +end + +function XUiPanelSidePopUp:Refresh() + if self.Parent.Operation == self.Parent.OperationType.Common then + self.Parent:PlayAnimation("AnimChuShouDisable", function() + self.CurState = false + self.GameObject:SetActiveEx(false) + end) + else + if self.Parent.Operation == self.Parent.OperationType.Decomposion then + self.PanelNumBtn.gameObject:SetActiveEx(false) + self.PanelSellPopUp.gameObject:SetActiveEx(false) + self.PanelConvertPopUp.gameObject:SetActiveEx(false) + self.TxtTitle.text = CS.XTextManager.GetText("DecomposeTitle") + self.PanelRecycle.gameObject:SetActiveEx(false) + self.PanelDecomposionPopUp.gameObject:SetActiveEx(true) + self.PanelFilterPopUp.gameObject:SetActiveEx(true) + self.PanelSelectNum.gameObject:SetActiveEx(true) + self.PanelSelectNum2.gameObject:SetActiveEx(false) + + --再次打开侧边栏时toggle清空选中状态 + for i = 1, #TOG_INDEX_TO_STAR_CHECK_DIC do + self["TogStar" .. i .. "PopUp"].isOn = false + end + + self:RefreshDecomposionPreView(self.Parent.SelectList) + elseif self.Parent.Operation == self.Parent.OperationType.PartnerDecomposion then + self.PanelNumBtn.gameObject:SetActiveEx(false) + self.PanelSellPopUp.gameObject:SetActiveEx(false) + self.PanelConvertPopUp.gameObject:SetActiveEx(false) + self.TxtTitle.text = CS.XTextManager.GetText("DecomposeTitle") + self.PanelRecycle.gameObject:SetActiveEx(false) + self.PanelDecomposionPopUp.gameObject:SetActiveEx(true) + self.PanelFilterPopUp.gameObject:SetActiveEx(false) + self.PanelSelectNum.gameObject:SetActiveEx(true) + self.PanelSelectNum2.gameObject:SetActiveEx(false) + + self:RefreshPartnerDecomposionPreView(self.Parent.SelectList) + elseif self.Parent.Operation == self.Parent.OperationType.Recycle then + self:CheckFirstOpenHelp() + self.PanelNumBtn.gameObject:SetActiveEx(false) + self.PanelSellPopUp.gameObject:SetActiveEx(false) + self.PanelConvertPopUp.gameObject:SetActiveEx(false) + self.TxtTitle.text = CS.XTextManager.GetText("RecycleTitle") + self.PanelDecomposionPopUp.gameObject:SetActiveEx(false) + self.PanelRecycle.gameObject:SetActiveEx(true) + self.PanelFilterPopUp.gameObject:SetActiveEx(true) + self.PanelSelectNum.gameObject:SetActiveEx(false) + self.PanelSelectNum2.gameObject:SetActiveEx(true) + + --再次打开侧边栏时toggle清空选中状态 + for i = 1, #TOG_INDEX_TO_STAR_CHECK_DIC do + self["TogStar" .. i .. "PopUp"].isOn = false + end + + self:RefreshRecyclePreView(self.Parent.SelectList) + else + if self.Parent.Operation == self.Parent.OperationType.Sell then + self.PanelConvertPopUp.gameObject:SetActiveEx(false) + self.TxtTitle.text = CS.XTextManager.GetText("SellTitle") + self.PanelSellPopUp.gameObject:SetActiveEx(true) + elseif self.Parent.Operation == self.Parent.OperationType.Convert then + self.PanelSellPopUp.gameObject:SetActiveEx(false) + self.TxtTitle.text = CS.XTextManager.GetText("ConverseTitle") + self.PanelConvertPopUp.gameObject:SetActiveEx(true) + end + self.PanelDecomposionPopUp.gameObject:SetActiveEx(false) + self.PanelRecycle.gameObject:SetActiveEx(false) + self.PanelFilterPopUp.gameObject:SetActiveEx(false) + self.PanelSelectNum.gameObject:SetActiveEx(false) + self.PanelSelectNum2.gameObject:SetActiveEx(false) + self.PanelNumBtn.gameObject:SetActiveEx(true) + self:RefreshSellPreView() + end + self.GameObject:SetActiveEx(true) + self.CurState = true + self.Parent:PlayAnimation("AnimChuShouEnable") + end +end + +function XUiPanelSidePopUp:RefreshDecomposionPreView(selectEquipIds, cancelStar) + self.SelectEquipIds = {} + if selectEquipIds then + for _, equipId in pairs(selectEquipIds) do + table.insert(self.SelectEquipIds, equipId) + end + end + + self.TxtSelectNum.text = #self.SelectEquipIds + + local listEmpty = not next(self.SelectEquipIds) + self.ImgCantDecomposionPopUp.gameObject:SetActiveEx(listEmpty) + self.BtnDecomposionPopUp.gameObject:SetActiveEx(not listEmpty) + + self.Rewards = XDataCenter.EquipManager.GetDecomposeRewards(self.SelectEquipIds) + if #self.Rewards == 1 then + if not self.SingleItemGrid then + local ui = CSUnityEngineObjectInstantiate(self.GridCommonPopUp, self.Transform) + self.SingleItemGrid = XUiGridCommon.New(self.Parent, ui) + end + + self.SingleItemGrid:Refresh(self.Rewards[1]) + self.SingleItemGrid.GameObject:SetActiveEx(true) + self.PanelDynamicTablePopUp.gameObject:SetActiveEx(false) + + CsXUiHelper.RegisterClickEvent(self.SingleItemGrid.RImgIcon, function() + XLuaUiManager.Open("UiTip", self.Rewards[1]) + end, true) + else + self:UpdateDynamicTable() + + if self.SingleItemGrid then + self.SingleItemGrid.GameObject:SetActiveEx(false) + end + self.PanelDynamicTablePopUp.gameObject:SetActiveEx(true) + end + + --取消选中时星星筛选tog状态置false + if cancelStar then + for togIndex, starCheckTable in pairs(TOG_INDEX_TO_STAR_CHECK_DIC) do + if starCheckTable[cancelStar] then + local tog = self["TogStar" .. togIndex .. "PopUp"] + if tog then + tog.isOn = false + end + end + end + end + +end + +function XUiPanelSidePopUp:RefreshPartnerDecomposionPreView(selectPartner) + self.SelectPartnerList = {} + if selectPartner then + for _, partner in pairs(selectPartner) do + table.insert(self.SelectPartnerList, partner) + end + end + + self.TxtSelectNum.text = #self.SelectPartnerList + + local listEmpty = not next(self.SelectPartnerList) + self.ImgCantDecomposionPopUp.gameObject:SetActiveEx(listEmpty) + self.BtnDecomposionPopUp.gameObject:SetActiveEx(not listEmpty) + + self.Rewards = XDataCenter.PartnerManager.GetPartnerDecomposeRewards(self.SelectPartnerList) + if #self.Rewards == 1 then + if not self.SingleItemGrid then + local ui = CSUnityEngineObjectInstantiate(self.GridCommonPopUp, self.Transform) + self.SingleItemGrid = XUiGridCommon.New(self.Parent, ui) + end + + self.SingleItemGrid:Refresh(self.Rewards[1]) + self.SingleItemGrid.GameObject:SetActiveEx(true) + self.PanelDynamicTablePopUp.gameObject:SetActiveEx(false) + + CsXUiHelper.RegisterClickEvent(self.SingleItemGrid.RImgIcon, function() + XLuaUiManager.Open("UiTip", self.Rewards[1]) + end, true) + else + self:UpdateDynamicTable() + + if self.SingleItemGrid then + self.SingleItemGrid.GameObject:SetActiveEx(false) + end + self.PanelDynamicTablePopUp.gameObject:SetActiveEx(true) + end +end + +function XUiPanelSidePopUp:RefreshRecyclePreView(selectEquipIds, cancelStar) + self.SelectEquipIds = {} + if selectEquipIds then + for _, equipId in pairs(selectEquipIds) do + table.insert(self.SelectEquipIds, equipId) + end + end + + self.TxtSelectNum2.text = #self.SelectEquipIds + + local listEmpty = not next(self.SelectEquipIds) + self.ImgCantRecycle.gameObject:SetActiveEx(listEmpty) + self.BtnRecycle.gameObject:SetActiveEx(not listEmpty) + + self.Rewards = XDataCenter.EquipManager.GetRecycleRewards(self.SelectEquipIds) + if #self.Rewards == 1 then + if not self.SingleItemGrid then + local ui = CSUnityEngineObjectInstantiate(self.GridCommonPopUp, self.Transform) + self.SingleItemGrid = XUiGridCommon.New(self.Parent, ui) + end + + self.SingleItemGrid:Refresh(self.Rewards[1]) + self.SingleItemGrid.GameObject:SetActiveEx(true) + self.PanelDynamicTablePopUp.gameObject:SetActiveEx(false) + + CsXUiHelper.RegisterClickEvent(self.SingleItemGrid.RImgIcon, function() + XLuaUiManager.Open("UiTip", self.Rewards[1]) + end, true) + + else + self:UpdateDynamicTable() + + if self.SingleItemGrid then + self.SingleItemGrid.GameObject:SetActiveEx(false) + end + self.PanelDynamicTablePopUp.gameObject:SetActiveEx(true) + end + + --取消选中时星星筛选tog状态置false + if cancelStar then + for togIndex, starCheckTable in pairs(TOG_INDEX_TO_STAR_CHECK_DIC) do + if starCheckTable[cancelStar] then + local tog = self["TogStar" .. togIndex .. "PopUp"] + if tog then + tog.isOn = false + end + end + end + end + +end + +function XUiPanelSidePopUp:ClearData() + self.SelectItemId = nil + self.SelectCount = nil + self.SelectGrid = nil +end + +function XUiPanelSidePopUp:RefreshSellPreView(selectItemId, count, selectGrid) + self.SelectItemId = selectItemId or self.SelectItemId + self.SelectCount = count or self.SelectCount + self.SelectGrid = selectGrid or self.SelectGrid + self.GridMaxCount = self.SelectGrid and self.SelectGrid:GetGridCount() or self.GridMaxCount + + local cantSell = not self.SelectItemId or not self.SelectCount or self.SelectCount == 0 + if self.Parent.Operation == self.Parent.OperationType.Sell then + self.BtnSellPopUp.gameObject:SetActiveEx(not cantSell) + self.ImgCantSellPopUp.gameObject:SetActiveEx(cantSell) + elseif self.Parent.Operation == self.Parent.OperationType.Convert then + self.BtnConvertPopUp.gameObject:SetActiveEx(not cantSell) + self.ImgCantConvertPopUp.gameObject:SetActiveEx(cantSell) + end + self.TxtNum.text = self.SelectCount + + local showSub = self.SelectCount ~= 0 + self.BtnSub.gameObject:SetActiveEx(showSub) + self.ImgCantSub.gameObject:SetActiveEx(not showSub) + + local showAdd = self.SelectItemId and (not self.GridMaxCount or self.SelectCount ~= self.GridMaxCount) + self.BtnAdd.gameObject:SetActiveEx(showAdd) + self.ImgCantAdd.gameObject:SetActiveEx(not showAdd) + + local reward = XDataCenter.ItemManager.GetSellReward(self.SelectItemId, self.SelectCount) + if not next(reward) then + if self.SingleItemGrid then + self.SingleItemGrid.GameObject:SetActiveEx(false) + end + else + if not self.SingleItemGrid then + local ui = CSUnityEngineObjectInstantiate(self.GridCommonPopUp, self.Transform) + self.SingleItemGrid = XUiGridCommon.New(self.Parent, ui) + end + self.SingleItemGrid:Refresh(reward) + self.SingleItemGrid.GameObject:SetActiveEx(true) + end + self.PanelDynamicTablePopUp.gameObject:SetActiveEx(false) +end + +function XUiPanelSidePopUp:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelSidePopUp:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelSidePopUp:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelSidePopUp:AutoAddListener() + self:RegisterClickEvent(self.TogStar1PopUp, self.OnTogStar1PopUpClick) + self:RegisterClickEvent(self.TogStar2PopUp, self.OnTogStar2PopUpClick) + self:RegisterClickEvent(self.TogStar3PopUp, self.OnTogStar3PopUpClick) + self:RegisterClickEvent(self.BtnSub, self.OnBtnSubClick) + self:RegisterClickEvent(self.BtnAdd, self.OnBtnAddClick) + self:RegisterClickEvent(self.BtnMax, self.OnBtnMaxClick) + self:RegisterClickEvent(self.BtnSellPopUp, self.OnBtnSellPopUpClick) + self:RegisterClickEvent(self.BtnDecomposionPopUp, self.OnBtnDecomposionPopUpClick) + self:RegisterClickEvent(self.BtnRecycle, self.OnBtnRecycleClick) + self:RegisterClickEvent(self.BtnRecycleSet, self.OnBtnRecycleSetClick) + self:RegisterClickEvent(self.BtnConvertPopUp, self.OnBtnConvertPopUpClick) + self:RegisterClickEvent(self.BtnCha, self.OnBtnChaClick) +end + +function XUiPanelSidePopUp:OnBtnSubClick() + self:RefreshSellPreView(self.SelectItemId, self.SelectCount - 1) +end + +function XUiPanelSidePopUp:OnBtnAddClick() + self:RefreshSellPreView(self.SelectItemId, self.SelectCount + 1) +end + +function XUiPanelSidePopUp:OnBtnMaxClick() + if not self.SelectItemId then return end + self:RefreshSellPreView(self.SelectItemId, self.SelectGrid:GetGridCount()) +end + +function XUiPanelSidePopUp:OnTogStar1PopUpClick() + self.Parent:SelectByStar(TOG_INDEX_TO_STAR_CHECK_DIC[1], self.TogStar1PopUp.isOn, true) +end + +function XUiPanelSidePopUp:OnTogStar2PopUpClick() + self.Parent:SelectByStar(TOG_INDEX_TO_STAR_CHECK_DIC[2], self.TogStar2PopUp.isOn, true) +end + +function XUiPanelSidePopUp:OnTogStar3PopUpClick() + self.Parent:SelectByStar(TOG_INDEX_TO_STAR_CHECK_DIC[3], self.TogStar3PopUp.isOn, true) +end + +function XUiPanelSidePopUp:OnBtnSellPopUpClick() + if not self.SelectItemId or not self.SelectCount or self.SelectCount == 0 then return end + + local sellFunc = function() + local datas = {[self.SelectItemId] = self.SelectCount } + XDataCenter.ItemManager.Sell(datas, function(rewardGoodDic) + self.Parent:OperationTurn(self.Parent.OperationType.Sell) + + local rewards = {} + for key, value in pairs(rewardGoodDic) do + table.insert(rewards, { TemplateId = key, Count = value }) + end + XUiManager.OpenUiObtain(rewards) + end) + end + + local quality = XDataCenter.ItemManager.GetItemQuality(self.SelectItemId) + if quality >= SECOND_CHECK_ITEM_QUALITY then + local title = CS.XTextManager.GetText("SellConfirmTitle") + local content = CS.XTextManager.GetText("SellConfirmTip") + + XUiManager.DialogTip(title, content, XUiManager.DialogType.Normal, nil, function() + sellFunc() + end) + + return + end + + sellFunc() +end + +function XUiPanelSidePopUp:OnBtnDecomposionPopUpClick() + if self.Parent.Operation == self.Parent.OperationType.PartnerDecomposion then + self:PartnerDecomposionPopUpClick() + else + self:EqualDecomposionPopUpClick() + end +end + +function XUiPanelSidePopUp:EqualDecomposionPopUpClick() + local callFunc = function() + XDataCenter.EquipManager.EquipDecompose(self.SelectEquipIds, function(rewardGoodsList) + self.Parent:OperationTurn(self.Parent.OperationType.Decomposion) + if (#rewardGoodsList > 0) then + XUiManager.OpenUiObtain(rewardGoodsList) + end + end) + end + + for _, equipId in pairs(self.SelectEquipIds) do + local equip = XDataCenter.EquipManager.GetEquip(equipId) + local star = XDataCenter.EquipManager.GetEquipStar(equip.TemplateId) + + if star >= DECOMPOSE_SECOND_CHECK_EQUIP_STAR then + local title = CS.XTextManager.GetText("DecomposeConfirmTitle") + local content = CS.XTextManager.GetText("DecomposeConfirmTip") + + XUiManager.DialogTip(title, content, XUiManager.DialogType.Normal, nil, function() + callFunc() + end) + + return + end + end + + callFunc() +end + +function XUiPanelSidePopUp:PartnerDecomposionPopUpClick() + local IsNeedDialog = false + local idList = {} + + for _, partner in pairs(self.SelectPartnerList or {}) do + if partner:GetQuality() >= DECOMPOSE_PARTNER_QUALITY then + IsNeedDialog = true + end + table.insert(idList, partner:GetId()) + end + + if IsNeedDialog then + local title = CS.XTextManager.GetText("DecomposePartnerConfirmTitle") + local content = CS.XTextManager.GetText("DecomposePartnerConfirmTip") + XUiManager.DialogTip(title, content, XUiManager.DialogType.Normal, nil, function() + XDataCenter.PartnerManager.PartnerDecomposeRequest(idList, function() + self.Parent:OperationTurn(self.Parent.OperationType.PartnerDecomposion) + end) + end) + end +end + +function XUiPanelSidePopUp:OnBtnRecycleClick() + local callFunc = function() + XDataCenter.EquipManager.EquipChipRecycleRequest(self.SelectEquipIds, function(rewardGoodsList) + self.Parent:OperationTurn(self.Parent.OperationType.Recycle) + if (#rewardGoodsList > 0) then + XUiManager.OpenUiObtain(rewardGoodsList) + end + end) + end + + for _, equipId in pairs(self.SelectEquipIds) do + local equip = XDataCenter.EquipManager.GetEquip(equipId) + local star = XDataCenter.EquipManager.GetEquipStar(equip.TemplateId) + + if star >= RECYCLE_SECOND_CHECK_EQUIP_STAR then + local title = CS.XTextManager.GetText("EquipRecycleConfirmTitle") + local content = CS.XTextManager.GetText("EquipRecycleConfirmTip") + + XUiManager.DialogTip(title, content, XUiManager.DialogType.Normal, nil, function() + callFunc() + end) + + return + end + end + + callFunc() +end + +function XUiPanelSidePopUp:OnBtnRecycleSetClick() + XLuaUiManager.Open("UiRecyclingSettings") +end + +function XUiPanelSidePopUp:OnBtnConvertPopUpClick() + if not self.SelectItemId or not self.SelectCount or self.SelectCount == 0 then return end + + local datas = {[self.SelectItemId] = self.SelectCount } + XDataCenter.ItemManager.Sell(datas, function(rewardGoodDic) + self.Parent:OperationTurn(self.Parent.OperationType.Convert) + + local rewards = {} + for key, value in pairs(rewardGoodDic) do + table.insert(rewards, { TemplateId = key, Count = value }) + end + XUiManager.OpenUiObtain(rewards) + end) +end + +function XUiPanelSidePopUp:OnBtnChaClick() + + self.Parent:OperationTurn(self.Parent.OperationType.Common) +end + +function XUiPanelSidePopUp:IsFirstOpen() + return XSaveTool.GetData(string.format("%d%s", XPlayer.Id, "IsAlreadyOpenPanelSidePopUp")) or false +end + +function XUiPanelSidePopUp:CheckFirstOpenHelp() + if not XSaveTool.GetData(string.format("%d%s", XPlayer.Id, "IsAlreadyOpenPanelSidePopUp")) then + XUiManager.ShowHelpTip("UiBagHelp") + XSaveTool.SaveData(string.format("%d%s", XPlayer.Id, "IsAlreadyOpenPanelSidePopUp"), true) + end +end + +return XUiPanelSidePopUp \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiBag/XUiRecyclingSettings.lua b/Resources/Scripts/XUi/XUiBag/XUiRecyclingSettings.lua new file mode 100644 index 00000000..4fa89519 --- /dev/null +++ b/Resources/Scripts/XUi/XUiBag/XUiRecyclingSettings.lua @@ -0,0 +1,128 @@ +local pairs = pairs +local tableInsert = table.insert + +local StarTogIndex = { + [1] = { 1, 2, 3 }, + [2] = { 4 }, + [3] = { 5 }, +} + +local DaysTogIndex = { + [1] = 1, + [2] = 3, + [3] = 14, + [4] = 0, +} + +local XUiRecyclingSettings = XLuaUiManager.Register(XLuaUi, "UiRecyclingSettings") + +function XUiRecyclingSettings:OnAwake() + self:AutoAddListener() + + local togs = { + self.BtnDays1 + , self.BtnDays2 + , self.BtnDays3 + , self.BtnDays4 + } + self.DaysBtnGroup:Init(togs, function(index) self:OnSelectDays(index) end) +end + +function XUiRecyclingSettings:OnStart() + self.StarCheckDic = XDataCenter.EquipManager.GetRecycleStarCheckDic() + self.Days = XDataCenter.EquipManager.GetRecycleSettingDays() +end + +function XUiRecyclingSettings:OnEnable() + self:UpdateView() +end + +function XUiRecyclingSettings:AutoAddListener() + self:RegisterClickEvent(self.BtnBack, self.TryClose) + self:RegisterClickEvent(self.BtnTanchuangClose, self.TryClose) + self:RegisterClickEvent(self.BtnTcanchaungBlack, self.TryClose) + self:RegisterClickEvent(self.BtnTcanchaungBlue, self.OnClickBtnConfirm) + + for index in pairs(StarTogIndex) do + local btn = self["BtnAwareness" .. index] + btn.CallBack = function() + local isSelect = btn.ButtonState == CS.UiButtonState.Select + self:OnSelectStar(index, isSelect) + end + end + +end + +function XUiRecyclingSettings:UpdateView() + for star, value in pairs(self.StarCheckDic) do + local isSelect = value and true or false + local index = self:GetStarBtnIndex(star) + self["BtnAwareness" .. index]:SetButtonState(CS.UiButtonState.Select) + end + + local index = self:GetDaysBtnIndex(self.Days) + self.DaysBtnGroup:SelectIndex(index, false) +end + +function XUiRecyclingSettings:OnClickBtnConfirm() + local cb = function() + self:Close() + end + local starList = {} + for star, value in pairs(self.StarCheckDic) do + if value then + tableInsert(starList, star) + end + end + local days = self.Days + XDataCenter.EquipManager.EquipChipSiteAutoRecycleRequest(starList, days, cb) +end + +function XUiRecyclingSettings:TryClose() + local closeFunc = function() + self:Close() + end + + if XDataCenter.EquipManager.CheckRecycleInfoDifferent(self.StarCheckDic, self.Days) then + local title = CsXTextManagerGetText("EquipRecycleSetttingCancelConfirmTitle") + local content = CsXTextManagerGetText("EquipRecycleSetttingCancelConfirmContent") + XUiManager.DialogTip(title, content, XUiManager.DialogType.Normal, nil, closeFunc) + else + closeFunc() + end +end + +function XUiRecyclingSettings:CheckDifferent() + + +end + +function XUiRecyclingSettings:OnSelectStar(index, isSelect) + local starValue = isSelect or nil + local stars = StarTogIndex[index] + for _, star in pairs(stars) do + self.StarCheckDic[star] = starValue + end +end + +function XUiRecyclingSettings:OnSelectDays(index) + self.Days = DaysTogIndex[index] +end + +function XUiRecyclingSettings:GetStarBtnIndex(star) + for index, stars in pairs(StarTogIndex) do + for _, inStar in pairs(stars) do + if inStar == star then + return index + end + end + end +end + +function XUiRecyclingSettings:GetDaysBtnIndex(days) + for index, inDays in pairs(DaysTogIndex) do + if inDays == days then + return index + end + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiBase/XPageView.lua b/Resources/Scripts/XUi/XUiBase/XPageView.lua new file mode 100644 index 00000000..03906cf4 --- /dev/null +++ b/Resources/Scripts/XUi/XUiBase/XPageView.lua @@ -0,0 +1,202 @@ +XPageView = XClass(XLuaBehaviour, "XPageView") +function XPageView:Ctor(rootUi, pageView, innerContainer, pageValue, dir) + self.Dir = dir or XScrollConfig.HORIZONTAL + self.InnerContainer = innerContainer + self.InnerTransform = innerContainer.transform + self.InnerGameObject = innerContainer.gameObject + self.AniCurve = CS.UnityEngine.AnimationCurve.Linear(0, 0, 1, 1) + self.CurPos = CS.UnityEngine.Vector3(0, 0, 0) + local pos = self.InnerTransform.anchoredPosition + self.OriginPos = CS.UnityEngine.Vector3(pos.x, pos.y, 0) + self.LastValue = 0 + self:RegisterListener() + self:SetPageWidth(pageValue) +end + +function XPageView:SetPageWidth(pageValue) + if self.Dir == XScrollConfig.HORIZONTAL then + self.SettedPageWidth = pageValue + self.SettedPageHeight = nil + else + self.SettedPageWidth = nil + self.SettedPageHeight = pageValue + end + self:RefreshSizeData() +end + +function XPageView:RefreshSizeData() + local rect = self.GameObject:GetComponent("RectTransform").rect + self.Width = rect.width + self.Height = rect.height + self.PageWidth = self.SettedPageWidth or rect.width + self.PageHeight = self.SettedPageHeight or rect.height + local innerRectTrans = self.InnerGameObject:GetComponent("RectTransform") + rect = innerRectTrans.rect + self.InnerWidth = rect.width + self.InnerHeight = rect.height + if self.Dir == XScrollConfig.HORIZONTAL then + self.TotalPage = math.ceil((self.InnerWidth - 20) / self.PageWidth) + self.InnerWidth = self.TotalPage * self.PageWidth + self.Reverse = innerRectTrans.pivot.x == 0 and 1 or -1 + self.Offset = innerRectTrans.pivot.x * (self.InnerWidth - self.Width) + else + self.TotalPage = math.ceil((self.InnerHeight - 20) / self.PageHeight) + self.InnerHeight = self.TotalPage * self.PageHeight + self.Reverse = innerRectTrans.pivot.y == 0 and 1 or -1 + self.Offset = innerRectTrans.pivot.y * (self.InnerHeight - self.Height) + end +end + +function XPageView:RefreshView() + CS.UnityEngine.Canvas.ForceUpdateCanvases() + self:RefreshSizeData() +end + +function XPageView:ScrollToPage(pageNum, time) + self.CurAniTime = 0 + pageNum = XMath.Clamp(pageNum, 0, self.TotalPage - 1) + if self.Dir == XScrollConfig.HORIZONTAL then + self.LastValue = self.CurPos.x + local targetP = XMath.Clamp( pageNum * self.PageWidth * self.Reverse, - self.Offset, self.InnerWidth - self.Width - self.Offset) + self.Offset = targetP - self.CurPos.x + else + self.LastValue = self.CurPos.y + local targetP = XMath.Clamp( pageNum * self.PageHeight * self.Reverse, - self.Offset, self.InnerHeight - self.Height - self.Offset) + self.Offset = targetP - self.CurPos.y + end + self.AniTime = time or 0.2 + self.Anim = self.Offset ~= 0 +end + +function XPageView:GetTotalPage() + self:RefreshSizeData() + return self.TotalPage +end + +function XPageView:GetCurPage() + self:RefreshSizeData() + local curPage + if self.Dir == XScrollConfig.HORIZONTAL then + curPage = math.floor(math.abs(self.CurPos.x) / self.PageWidth) + else + curPage = math.floor(math.abs(self.CurPos.y) / self.PageHeight) + end + return curPage +end + +function XPageView:NextPage(time) + self:ScrollToPage(self:GetCurPage() + 1, time) +end + +function XPageView:PrevPage(time) + self:ScrollToPage(self:GetCurPage() - 1, time) +end + +function XPageView:RegisterListener() + self.UiWidget = self.GameObject:AddComponent(typeof(CS.XUiWidget)) + self.UiWidget:AddBeginDragListener(function(eventData) + self:OnBeginDrag(eventData) + end) + self.UiWidget:AddEndDragListener(function(eventData) + self:OnEndDrag(eventData) + end) + self.UiWidget:AddDragListener(function (eventData) + self:OnDrag(eventData) + end) +end + +function XPageView:OnBeginDrag(eventData) + self:RefreshSizeData() + self.StartClickPoint = eventData.position + self.StartPos = CS.UnityEngine.Vector3( self.CurPos.x, self.CurPos.y, self.CurPos.z ) + self.DeltaPos = CS.UnityEngine.Vector3.zero + self.Anim = false + self.IsDrag = true +end + +function XPageView:OnDrag(eventData) + local curPos = eventData.position + self.DeltaPos = self.StartClickPoint - curPos + if self.Dir == XScrollConfig.HORIZONTAL then + self:OnCalcDrag("x", "InnerWidth", "Width") + else + self:OnCalcDrag("y", "InnerHeight", "Height") + end +end + +function XPageView:OnCalcDrag(axisName, totalWidthName, widthName) + local maxPos = self[totalWidthName] - self[widthName] - self.Offset + local minPos = - self.Offset + local calcPos = self.StartPos[axisName] + self.DeltaPos[axisName] + if calcPos < minPos then + calcPos = minPos - (minPos - calcPos) / 5 + elseif calcPos > maxPos then + calcPos = maxPos + (calcPos - maxPos) / 5 + end + self.CurPos[axisName] = calcPos +end + +function XPageView:OnCalcEnd(axisName, pageWidthName, totalWidthName, widthName) + local TargetP + local checkDis = self[pageWidthName] / 4 + local startLoc = math.floor(self.CurPos[axisName] / self[pageWidthName]) * self[pageWidthName] + local offset = self.CurPos[axisName] - startLoc + if offset < checkDis then + TargetP = XMath.Clamp(startLoc, - self.Offset, self[totalWidthName] - self[widthName] - self.Offset) + elseif offset > self[pageWidthName] - checkDis then + TargetP = XMath.Clamp(startLoc + self[pageWidthName], - self.Offset, self[totalWidthName] - self[widthName] - self.Offset) + else + if self.DeltaPos and self.DeltaPos[axisName] > 0 then + TargetP = XMath.Clamp(startLoc + self[pageWidthName], - self.Offset, self[totalWidthName] - self[widthName] - self.Offset) + else + TargetP = XMath.Clamp(startLoc, - self.Offset, self[totalWidthName] - self[widthName]) + end + end + self.Offset = TargetP - self.CurPos[axisName] + self.LastValue = self.CurPos[axisName] + self.AniTime = XMath.Clamp(math.abs(offset * 2 / self[pageWidthName]), 0, 0.2) +end + +function XPageView:OnEndDrag() + if self.Dir == XScrollConfig.HORIZONTAL then + self:OnCalcEnd("x", "PageWidth", "InnerWidth", "Width") + else + self:OnCalcEnd("y", "PageHeight", "InnerHeight", "Height") + end + self.IsDrag = false + self.CurAniTime = 0 + self.Anim = self.Offset ~= 0 +end + +function XPageView:Update() + if not self.IsDrag and not self.Anim then return end + if self.Anim then + self.CurAniTime = self.CurAniTime + CS.UnityEngine.Time.deltaTime + local value + if self.AniTime > 0 then + value = self.AniCurve:Evaluate(self.CurAniTime / self.AniTime) + else + value = self.AniCurve:Evaluate(1) + end + if self.Dir == XScrollConfig.HORIZONTAL then + self.CurPos.x = self.LastValue + self.Offset * value + else + self.CurPos.y = self.LastValue + self.Offset * value + end + if self.CurAniTime >= self.AniTime then + self.Anim = false + end + end + self.InnerTransform.anchoredPosition = CS.UnityEngine.Vector2(self.OriginPos.x - self.CurPos.x, self.OriginPos.y - self.CurPos.y) +end + +function XPageView:Dispose() + local xLuaBehaviour = self.Transform:GetComponent("XLuaBehaviour") + if (xLuaBehaviour) then + CS.UnityEngine.GameObject.Destroy(xLuaBehaviour) + end + + if (self.UiWidget) then + CS.UnityEngine.GameObject.Destroy(self.UiWidget) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiBase/XScrollGrid.lua b/Resources/Scripts/XUi/XUiBase/XScrollGrid.lua new file mode 100644 index 00000000..991a9d78 --- /dev/null +++ b/Resources/Scripts/XUi/XUiBase/XScrollGrid.lua @@ -0,0 +1,31 @@ +XScrollGrid = XClass(nil, "XScrollGrid") + +--==============================-- +--desc: 活动列表节点 +--@ui: 节点ui +--==============================-- +function XScrollGrid:Ctor(rootUi, ui) + self.Transform = ui.transform + self.GameObject = ui.gameObject + + self.Rect = self.Transform:GetComponent("RectTransform") + self.GameObject:SetActive(true) + self.CurveValue = 0 +end + +function XScrollGrid:SetIndex(index) + self.Index = index +end + +function XScrollGrid:SetParent(parent) + self.Parent = parent + self.Transform:SetParent(parent.Transform, false) +end + +--==============================-- +--desc: 滑动回掉 +--@addValue: 增加的曲线值 +--==============================-- +function XScrollGrid:OnDrag() + -- Override this function +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiBase/XScrollView.lua b/Resources/Scripts/XUi/XUiBase/XScrollView.lua new file mode 100644 index 00000000..43d9c34f --- /dev/null +++ b/Resources/Scripts/XUi/XUiBase/XScrollView.lua @@ -0,0 +1,364 @@ +XScrollView = XClass(XLuaBehaviour, "XScrollView") + +local DEFAULT_START_VALUE = 0.1 -- 默认起始坐标参数值 +local DEFAULT_OFFSET_VALUE = 0.2 -- 默认间隔坐标参数值 +local DEFAULT_MIN_VALUE = 0.1 -- 默认最小坐标参数值 +local DEFAULT_MAX_VALUE = 0.9 -- 默认最大坐标参数值 + +local DEFAULT_ANIM_SPEED = 0.5 -- 默认动画速度 + + +--==============================-- +--desc: 构造函数 +--@ui: 滑动展示区域Ui +--@scrollItems: 滑动列表 +--@paramsObj: 扩展参数 +--note: 可用扩展参数 selectIndex(默认显示第几条)、offsetValue(滑动列表间偏移量)、animSpeed(滑动速度)、 +-- moveEndCb(滑动结束回掉)、direction(滑动方向,水平或者垂直)、isLoop(滑动列表是否循环) +--==============================-- +function XScrollView:Ctor(rootUi, ui, scrollItems, paramsObj) + self.ScrollItems = {} + self.MoveEndCb = function() end + self.SelectItemCb = function() end + self.Direction = XScrollConfig.HORIZONTAL + + self.Rect = self.Transform:GetComponent("RectTransform") + self.ContentSize = self.Rect.sizeDelta + + self.StartValue = DEFAULT_START_VALUE + self.OffsetValue = DEFAULT_OFFSET_VALUE + self.MinValue = DEFAULT_MIN_VALUE + self.MaxValue = DEFAULT_MAX_VALUE + self.MinBorder = DEFAULT_MIN_VALUE + self.MaxBorder = DEFAULT_MAX_VALUE + self.AnimSpeed = DEFAULT_ANIM_SPEED + self.ItemsCount = #scrollItems + self.IsLoop = false + + self.TotalOffset = 0 -- 重置总的滑动偏移计算 + + self:InitParams(paramsObj) + self:RegisterListener() + self:InitAnimationCurve() + self:InitScorllItems(scrollItems) +end + +function XScrollView:AddSelectItemCallback(callback) + self.SelectItemCb = callback +end + +function XScrollView:RemoveSelectItemCallback() + self.SelectItemCb = nil +end + +function XScrollView:RegisterListener() + self.UiWidget = self.GameObject:AddComponent(typeof(CS.XUiWidget)) + self.UiWidget:AddBeginDragListener(function(eventData) + self:OnBeginDrag(eventData) + end) + self.UiWidget:AddEndDragListener(function(eventData) + self:OnEndDrag(eventData) + end) + self.UiWidget:AddDragListener(function(eventData) + self:OnDrag(eventData) + end) + self.UiWidget:AddPointerClickListener(function(eventData) + self:OnPointerClick(eventData) + end) +end + +function XScrollView:InitScorllItems(scrollItems) + local count = #scrollItems + + for i = 1, count do + local item = scrollItems[i] + item:SetIndex(i) + item:SetParent(self) + item:OnDrag(self.StartValue + (i - 1) * self.OffsetValue) + if (not self.CurrentItem) and item.CurveValue - 0.5 < 0.05 then + self.CurrentItem = item + end + + table.insert(self.ScrollItems, item) + end + + local minCount = math.floor(1 / self.OffsetValue) -- 滑动区域可展示条目数 + if #self.ScrollItems < minCount then + self.MaxValue = self.StartValue + (minCount - 1) * self.OffsetValue + else + self.MaxValue = self.StartValue + (count - 1) * self.OffsetValue + end + + if self.SelectIndex then + self:SetSelectItem(self.SelectIndex) + end +end + +function XScrollView:InitParams(paramsObj) + if not paramsObj or type(paramsObj) ~= "table" then + return + end + + if paramsObj.selectIndex then + local selectIndex = paramsObj.selectIndex + if selectIndex < 1 or selectIndex > self.ItemsCount then + XLog.Warning("XScrollView InitParams use a Invalid selectIndex, selectIndex = " .. selectIndex) + else + self.SelectIndex = selectIndex + end + end + + if paramsObj.offsetValue then + if paramsObj.offsetValue < 0 then + XLog.Warning("XScrollView InitParams use a Invalid offsetValue, offsetValue = " .. paramsObj.offsetValue) + else + self.OffsetValue = paramsObj.offsetValue + end + end + + if paramsObj.animSpeed then + if paramsObj.animSpeed < 0 then + XLog.Warning("XScrollView InitParams use a Invalid animSpeed, animSpeed = " .. paramsObj.animSpeed) + else + self.AnimSpeed = paramsObj.animSpeed + end + end + + if paramsObj.moveEndCb then + self.MoveEndCb = paramsObj.moveEndCb + end + + if paramsObj.direction then + local direction = paramsObj.direction + if direction ~= XScrollConfig.HORIZONTAL and direction ~= XScrollConfig.VERTICAL then + XLog.Warning("XScrollView InitParams use a Invalid direction, direction = " .. direction) + else + self.Direction = direction + end + end + + if paramsObj.isLoop ~= nil then + self.IsLoop = paramsObj.isLoop + end +end + +function XScrollView:SetSelectItem(index) + self.CurrentItem = self.ScrollItems[index] + local offset = 0.5 - self.CurrentItem.CurveValue + for i = 1, #self.ScrollItems do + local item = self.ScrollItems[i] + item:OnDrag(offset) + end + + self:AdjustScrollItems(offset) + if (self.SelectItemCb) then + self.SelectItemCb(self.CurrentItem) + end +end + +function XScrollView:InitAnimationCurve() + -- Override this function +end + +function XScrollView:OnBeginDrag(eventData) + self.StartPoint = eventData.position + self.AddVector = CS.UnityEngine.Vector3.zero + self.Anim = false +end + +--==============================-- +--desc: 滑动过程回掉 +--@eventData: 回掉数据 +--==============================-- +function XScrollView:OnDrag() + -- Override this function +end + +--==============================-- +--desc: 滑动结束回掉滑动结束回掉 +--@eventData: 回掉数据 +--==============================-- +function XScrollView:OnEndDrag() + -- Override this function +end + +--==============================-- +--desc: 动画曲线值计算接口 +--@curveValue: 曲线值 +--@return 动画计算产生的结果 +--==============================-- +function XScrollView:Evaluate(curveValue) + -- Override this function +end + +--==============================-- +--desc: 调整滑动列表元素 +--@addValue: 增加的偏移量 +--==============================-- +function XScrollView:AdjustScrollItems(addValue) + if not self.IsLoop then + return + end + + local itemCount = #self.ScrollItems + if addValue < 0 then -- left or down + local moveCount = 0 + for i = 1, itemCount do + local item = self.ScrollItems[i] + if item.CurveValue < (self.MinValue - self.OffsetValue / 2) then + moveCount = moveCount + 1 + end + end + + if moveCount > 0 then + for _ = 1, moveCount do + local lastCurveValue = self.ScrollItems[itemCount].CurveValue + local item = table.remove(self.ScrollItems, 1) + item.CurveValue = lastCurveValue + self.OffsetValue + table.insert(self.ScrollItems, item) + end + end + elseif addValue > 0 then -- right or up + local moveCount = 0 + for i = 1, itemCount do + local item = self.ScrollItems[i] + if item.CurveValue >= self.MaxValue then + moveCount = moveCount + 1 + end + + if moveCount > 0 then + local firstCurveValue = self.ScrollItems[1].CurveValue + local tmpItem = table.remove(self.ScrollItems, itemCount) + tmpItem.CurveValue = firstCurveValue - self.OffsetValue + table.insert(self.ScrollItems, 1, tmpItem) + end + end + end +end + +--==============================-- +--desc: 滑动结束动画处理 +--@offset: 偏移量 +--==============================-- +function XScrollView:Anim2End(offset) + self.NeedOffset = offset -- 所需偏移量 + if offset == 0 then + return + end + + if offset > 0 then -- 正方向,向右/向上 + self.MoveDir = 1 + else -- 反方向,向左/向下 + self.MoveDir = -1 + end + + self.Anim = true + self.TotalOffset = 0 -- 重置已偏移统计 +end + +--==============================-- +--desc: 点击回掉,判断点中节点 +--@eventData: 点击回掉数据 +--==============================-- +function XScrollView:OnPointerClick(eventData) + local gameObject = eventData.pointerPressRaycast.gameObject + for i = 1, #self.ScrollItems do + local item = self.ScrollItems[i] + if item.GameObject == gameObject then + if item.GameObject ~= self.CurrentItem.GameObject then + self.CurrentItem = item + self:Anim2End(0.5 - item.CurveValue) + end + break + end + end +end + +function XScrollView:Update() + if not self.Anim then + return + end + + local addOffset = CS.UnityEngine.Time.deltaTime * self.AnimSpeed * self.MoveDir + local totalOffset = self.TotalOffset + addOffset + + if totalOffset > 0 and totalOffset >= self.NeedOffset then + self.Anim = false + addOffset = self.NeedOffset - self.TotalOffset + end + + if totalOffset < 0 and totalOffset <= self.NeedOffset then + self.Anim = false + addOffset = self.NeedOffset - self.TotalOffset + end + + for i = 1, #self.ScrollItems do + local item = self.ScrollItems[i] + item:OnDrag(addOffset) + if math.abs(item.CurveValue - 0.5) < 0.05 then -- 当前选中节点 + self.CurrentItem = item + end + end + + self:AdjustScrollItems(addOffset) + self.TotalOffset = totalOffset + + if not self.Anim then + self.MoveEndCb(self.CurrentItem) + end +end + +function XScrollView:LateUpdate() + local midItem + local minOffset = 1 + for i = 1, #self.ScrollItems do + local item = self.ScrollItems[i] + local v = math.abs(item.CurveValue - 0.5) + -- if math.abs(item.CurveValue - 0.5) < 0.05 then -- 当前选中节点 + -- midItem = item + -- end + if v < minOffset then + minOffset = v + midItem = item + end + + end + + if not midItem then + return + end + + local midIndex = midItem.Index + local maxIndex = #self.ScrollItems + + for i = 1, midIndex - 1 do + local item = self.ScrollItems[i] + -- if item.CurveValue >= self.MinBorder then + item.Rect:SetSiblingIndex(i) + -- else + -- break + -- end + end + + for i = midIndex + 1, maxIndex do + local item = self.ScrollItems[i] + -- if item.CurveValue <= self.MaxBorder then + item.Rect:SetSiblingIndex(maxIndex - i) + -- else + -- break + -- end + end + + midItem.Rect:SetSiblingIndex(maxIndex) +end + +function XScrollView:Dispose() + local xLuaBehaviour = self.Transform:GetComponent("XLuaBehaviour") + if (xLuaBehaviour) then + CS.UnityEngine.GameObject.Destroy(xLuaBehaviour) + end + + if (self.UiWidget) then + CS.UnityEngine.GameObject.Destroy(self.UiWidget) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiBase/XUiBtnTab.lua b/Resources/Scripts/XUi/XUiBase/XUiBtnTab.lua new file mode 100644 index 00000000..2422b242 --- /dev/null +++ b/Resources/Scripts/XUi/XUiBase/XUiBtnTab.lua @@ -0,0 +1,215 @@ +XUiBtnTab = XClass(nil, "XUiBtnTab") + +function XUiBtnTab:Ctor(ui, index, callback, isLockClick) + self.IsLockClick = false + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Index = index + self.Callback = callback + self.IsLockClick = isLockClick + + self:InitAutoScript() + + if (self.ImgLock) then + self.ImgLock.gameObject:SetActive(false) + end + if (self.TxtNormal) then + self.TxtNormal.gameObject:SetActive(true) + end + if (self.TxtSelected) then + self.TxtSelected.gameObject:SetActive(false) + end + + if self.Btn.gameObject:GetComponent(typeof(CS.XUiClickWidget)) == nil then + self.WgtBtn = self.Btn.gameObject:AddComponent(typeof(CS.XUiClickWidget)) + end + -- self.WgtBtn:AddPointerDownListener(function(eventData) self:OnDown() end) +end + +-- function XUiBtnTab:OnDown() +-- if (self.TxtNormal) then +-- self.TxtNormal.gameObject:SetActive(false) +-- end +-- if (self.TxtSelected) then +-- self.TxtSelected.gameObject:SetActive(true) +-- end +-- end +-- auto +-- Automatic generation of code, forbid to edit +function XUiBtnTab:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiBtnTab:AutoInitUi() + self.Btn = self.Transform:GetComponent("Button") + self.Image = self.Transform:GetComponent("Image") + + local lock = self.Transform:Find("ImgLock") + if (lock) then + self.ImgLock = lock:GetComponent("Image") + end + + local normal = self.Transform:Find("TxtNormal") + if (normal) then + self.TxtNormal = normal:GetComponent("Text") + end + + local normalEn = self.Transform:Find("TxtNormal/TxtNormalEn") + if (normalEn) then + self.TxtNormalEn = normalEn:GetComponent("Text") + end + + local locktxt = self.Transform:Find("TxtLock") + if (locktxt) then + self.TxtLock = locktxt:GetComponent("Text") + end + + local lockEn = self.Transform:Find("TxtLock/TxtLockEn") + if (lockEn) then + self.TxtLockEn = lockEn:GetComponent("Text") + end + + local selected = self.Transform:Find("TxtSelected") + if (selected) then + self.TxtSelected = selected:GetComponent("Text") + end + + local selectedEn = self.Transform:Find("TxtSelected/TxtSelectedEn") + if (selectedEn) then + self.TxtSelectedEn = selectedEn:GetComponent("Text") + end + + self.tag = self.Transform:Find("PanelTag") + if (self.tag) then + self.TxtTag = self.Transform:Find("PanelTag/TxtTag"):GetComponent("Text") + end +end + +function XUiBtnTab:RegisterListener(uiNode, eventName, func) + if not uiNode then return end + local key = eventName .. uiNode:GetHashCode() + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiBtnTab:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiBtnTab:AutoAddListener() + self.AutoCreateListeners = {} + XUiHelper.RegisterClickEvent(self, self.Btn, self.OnBtnClick) +end +-- auto +function XUiBtnTab:OnBtnClick() + if (self.Callback) then + self.Callback(self.Index) + end +end + +function XUiBtnTab:OnSelect(isSelected) + self.Btn.interactable = not isSelected + if (self.TxtNormal) then + self.TxtNormal.gameObject:SetActive(not isSelected) + end + if (self.TxtSelected) then + self.TxtSelected.gameObject:SetActive(isSelected) + end + + if (self.TxtLock) then + self.TxtLock.gameObject:SetActive(false) + end +end + +function XUiBtnTab:Lock(isLocked) + if self.IsLockClick then + self.Image.enabled = true + else + self.Image.enabled = not isLocked + end + + if (self.ImgLock) then + self.ImgLock.gameObject:SetActive(isLocked) + end + + if (self.TxtLock) then + self.TxtLock.gameObject:SetActive(isLocked) + end + + if (self.TxtSelected) then + self.TxtSelected.gameObject:SetActive(isLocked) + end + + if (self.TxtNormal) then + self.TxtNormal.gameObject:SetActive(isLocked) + end +end + +function XUiBtnTab:SetName(name, nameEn) + if (self.TxtNormal) then + self.TxtNormal.text = name + end + if (self.TxtSelected) then + self.TxtSelected.text = name + end + if (self.TxtLock) then + self.TxtLock.text = name + end + + if self.TxtNormalEn and nameEn then + self.TxtNormalEn.text = nameEn + end + if self.TxtSelectedEn and nameEn then + self.TxtSelectedEn.text = nameEn + end + if self.TxtLockEn and nameEn then + self.TxtLockEn.text = nameEn + end +end + +function XUiBtnTab:Dispose() + self.Callback = nil + self.GameObject = nil + self.Transform = nil + self.Index = nil + self.Btn = nil + self.Image = nil + + if self.ImgLock then + self.ImgLock = nil + end + + if self.TxtNormal then + self.TxtNormal = nil + end + + if self.TxtSelectedEn then + self.TxtSelectedEn = nil + end + + if self.TxtNormalEn then + self.TxtNormalEn = nil + end + + if self.TxtLock then + self.TxtLock = nil + end + if self.TxtLockEn then + self.TxtLockEn = nil + end + if self.TxtTag then + self.TxtTag = nil + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiBase/XUiChapterBtnTab.lua b/Resources/Scripts/XUi/XUiBase/XUiChapterBtnTab.lua new file mode 100644 index 00000000..b11f5fcf --- /dev/null +++ b/Resources/Scripts/XUi/XUiBase/XUiChapterBtnTab.lua @@ -0,0 +1,84 @@ +XUiChapterBtnTab = XClass(nil, "XUiChapterBtnTab") + +function XUiChapterBtnTab:Ctor(ui, index, callback, isLockClick) + self.IsLockClick = false + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Index = index + self.Callback = callback + self.IsLockClick = isLockClick + self.IsLock = false + XTool.InitUiObject(self) + self.Btn = self.Transform:GetComponent("Button") + self:AutoAddListener() + if self.Btn.gameObject:GetComponent(typeof(CS.XUiClickWidget)) == nil then + self.WgtBtn = self.Btn.gameObject:AddComponent(typeof(CS.XUiClickWidget)) + end +end + +function XUiChapterBtnTab:RegisterListener(uiNode, eventName, func) + if not uiNode then return end + local key = eventName .. uiNode:GetHashCode() + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiBtnTab:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiChapterBtnTab:AutoAddListener() + self.AutoCreateListeners = {} + XUiHelper.RegisterClickEvent(self, self.Btn, self.OnBtnClick) +end + +function XUiChapterBtnTab:OnBtnClick() + if (self.Callback) then + self.Callback(self.Index) + end +end + +function XUiChapterBtnTab:OnSelect(isSelected) + if not self.IsLock then + self.Normal.gameObject:SetActive(not isSelected) + self.Press.gameObject:SetActive(isSelected) + end +end + +function XUiChapterBtnTab:Lock(isLocked) + self.IsLock = isLocked + self.Normal.gameObject:SetActive(not isLocked) + self.Press.gameObject:SetActive(not isLocked) + self.Disable.gameObject:SetActive(isLocked) +end + +function XUiChapterBtnTab:SetName(name1, name2) + self.TxtNormal1.text = name1 + self.TxtNormal2.text = name2 + self.TxtPress1.text = name1 + self.TxtPress2.text = name2 +end + +function XUiChapterBtnTab:SetPic(pic) + self.RImgNormal:SetRawImage(pic) + self.RImgPress:SetRawImage(pic) +end + +function XUiChapterBtnTab:SetRedPoint(isActive) + self.ImgRedTag.gameObject:SetActive(isActive) +end + +function XUiChapterBtnTab:Dispose() + +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiBase/XUiTabBtnGroup.lua b/Resources/Scripts/XUi/XUiBase/XUiTabBtnGroup.lua new file mode 100644 index 00000000..196c7410 --- /dev/null +++ b/Resources/Scripts/XUi/XUiBase/XUiTabBtnGroup.lua @@ -0,0 +1,77 @@ +XUiTabBtnGroup = XClass(XUiTabBtnGroup, "XUiTabBtnGroup") +XUiTabBtnGroup.TabBtnType = { + Normal = 1, + Chapter = 2, +} + +function XUiTabBtnGroup:Ctor(btnList, callback, clickCheck, isLockClick, tabType) + self.TabBtnList = {} + self.Callback = callback + self.ClickCheck = clickCheck + if tabType == nil then + for index, btn in ipairs(btnList) do + local tabBtn = XUiBtnTab.New(btn, index, function(i) self:SelectIndex(i) end, isLockClick) + table.insert(self.TabBtnList, tabBtn) + end + elseif tabType == XUiTabBtnGroup.TabBtnType.Chapter then + for index, btn in ipairs(btnList) do + local tabBtn = XUiChapterBtnTab.New(btn, index, function(i) self:SelectIndex(i) end, isLockClick) + table.insert(self.TabBtnList, tabBtn) + end + end +end + +function XUiTabBtnGroup:SelectIndex(index) + + if self.ClickCheck then + local success = false + for i, btn in ipairs(self.TabBtnList) do + if (i == index) then + if self.ClickCheck(index) then + btn:OnSelect(true) + success = true + end + end + end + if not success then return end + for i, btn in ipairs(self.TabBtnList) do + if (i ~= index) then + btn:OnSelect(false) + end + end + else + for i, btn in ipairs(self.TabBtnList) do + if (i == index) then + btn:OnSelect(true) + else + btn:OnSelect(false) + end + end + end + + if (self.Callback) then + self.Callback(index) + end +end + +function XUiTabBtnGroup:LockIndex(index) + local btn = self.TabBtnList[index] + if (btn) then + btn:Lock(true) + end +end + +function XUiTabBtnGroup:UnLockIndex(index) + local btn = self.TabBtnList[index] + if (btn) then + btn:Lock(false) + end +end + +function XUiTabBtnGroup:Dispose() + for _, btn in ipairs(self.TabBtnList) do + btn:Dispose() + end + self.Callback = nil + self.TabBtnList = nil +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiBaseEquip/XUiBaseEquip.lua b/Resources/Scripts/XUi/XUiBaseEquip/XUiBaseEquip.lua new file mode 100644 index 00000000..b84fa9cd --- /dev/null +++ b/Resources/Scripts/XUi/XUiBaseEquip/XUiBaseEquip.lua @@ -0,0 +1,153 @@ +local XUiBaseEquip = XLuaUiManager.Register(XLuaUi, "UiBaseEquip") + +local XUiGridBaseEquip = require("XUi/XUiBaseEquip/XUiGridBaseEquip") +local XUiPanelBaseEquipPutOn = require("XUi/XUiBaseEquip/XUiPanelBaseEquipPutOn") + +function XUiBaseEquip:OnAwake() + self:InitAutoScript() +end + +function XUiBaseEquip:OnStart(exitCb) + self.ExitCb = exitCb + + self.GridBaseEquip.gameObject:SetActive(false) + self.PanelMain.gameObject:SetActive(true) + + self.GridBaseEquipDict = {} + self.PutOnPanel = XUiPanelBaseEquipPutOn.New(self.PanelBaseEquipPutOn, self) + self.PutOnPanel:HidePanel() + self:ShowMainPanel() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiBaseEquip:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiBaseEquip:AutoInitUi() + self.PanelBaseEquipPutOn = self.Transform:Find("SafeAreaContentPane/PanelBaseEquipPutOn") + self.PanelMain = self.Transform:Find("SafeAreaContentPane/PanelMain") + self.BtnPart1 = self.Transform:Find("SafeAreaContentPane/PanelMain/BtnPart1"):GetComponent("Button") + self.ImgRedPoint1 = self.Transform:Find("SafeAreaContentPane/PanelMain/BtnPart1/ImgRedPoint1"):GetComponent("Image") + self.BtnPart2 = self.Transform:Find("SafeAreaContentPane/PanelMain/BtnPart2"):GetComponent("Button") + self.ImgRedPoint2 = self.Transform:Find("SafeAreaContentPane/PanelMain/BtnPart2/ImgRedPoint2"):GetComponent("Image") + self.BtnPart3 = self.Transform:Find("SafeAreaContentPane/PanelMain/BtnPart3"):GetComponent("Button") + self.ImgRedPoint3 = self.Transform:Find("SafeAreaContentPane/PanelMain/BtnPart3/ImgRedPoint3"):GetComponent("Image") + self.BtnPart4 = self.Transform:Find("SafeAreaContentPane/PanelMain/BtnPart4"):GetComponent("Button") + self.ImgRedPoint4 = self.Transform:Find("SafeAreaContentPane/PanelMain/BtnPart4/ImgRedPoint4"):GetComponent("Image") + self.BtnPart5 = self.Transform:Find("SafeAreaContentPane/PanelMain/BtnPart5"):GetComponent("Button") + self.ImgRedPoint5 = self.Transform:Find("SafeAreaContentPane/PanelMain/BtnPart5/ImgRedPoint5"):GetComponent("Image") + self.BtnPart6 = self.Transform:Find("SafeAreaContentPane/PanelMain/BtnPart6"):GetComponent("Button") + self.ImgRedPoint6 = self.Transform:Find("SafeAreaContentPane/PanelMain/BtnPart6/ImgRedPoint6"):GetComponent("Image") + self.GridBaseEquip = self.Transform:Find("SafeAreaContentPane/PanelMain/GridBaseEquip") + self.PanelTopButton = self.Transform:Find("SafeAreaContentPane/PanelTopButton") + self.BtnBack = self.Transform:Find("SafeAreaContentPane/PanelTopButton/BtnBack"):GetComponent("Button") + self.BtnMainUi = self.Transform:Find("SafeAreaContentPane/PanelTopButton/BtnMainUi"):GetComponent("Button") +end + +function XUiBaseEquip:AutoAddListener() + self:RegisterClickEvent(self.BtnPart1, self.OnBtnPart1Click) + self:RegisterClickEvent(self.BtnPart2, self.OnBtnPart2Click) + self:RegisterClickEvent(self.BtnPart3, self.OnBtnPart3Click) + self:RegisterClickEvent(self.BtnPart4, self.OnBtnPart4Click) + self:RegisterClickEvent(self.BtnPart5, self.OnBtnPart5Click) + self:RegisterClickEvent(self.BtnPart6, self.OnBtnPart6Click) + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) +end +-- auto + +function XUiBaseEquip:OnBtnBackClick() + if self.PutOnPanel:IsShow() then + self.PutOnPanel:HidePanel() + self:ShowMainPanel() + return + end + + if self.ExitCb then + self.ExitCb() + end + + self:Close() +end + +function XUiBaseEquip:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiBaseEquip:OnBtnPart1Click() + self:ShowPart(1) +end + +function XUiBaseEquip:OnBtnPart2Click() + self:ShowPart(2) +end + +function XUiBaseEquip:OnBtnPart3Click() + self:ShowPart(3) +end + +function XUiBaseEquip:OnBtnPart4Click() + self:ShowPart(4) +end + +function XUiBaseEquip:OnBtnPart5Click() + self:ShowPart(5) +end + +function XUiBaseEquip:OnBtnPart6Click() + self:ShowPart(6) +end + +function XUiBaseEquip:ShowPart(part) + self.PutOnPanel:ShowPanel(part) + self.PanelMain.gameObject:SetActive(false) +end + +function XUiBaseEquip:ShowMainPanel() + self:RefreshBaseEquipInfo() + self:CheckRedPoint() + self.PanelMain.gameObject:SetActive(true) +end + +function XUiBaseEquip:CreateBaseEquipGrid(part, baseEquip) + local btnPart = self["BtnPart" .. part] + if not btnPart then + return + end + + local grid = XUiGridBaseEquip.New(CS.UnityEngine.Object.Instantiate(self.GridBaseEquip), baseEquip) + grid:Init(self, self.PutOnPanel) + grid:Refresh(baseEquip) + grid.Transform:SetParent(btnPart.transform, false) + grid.GameObject:SetActive(true) + self.GridBaseEquipDict[part] = grid +end + +function XUiBaseEquip:RefreshBaseEquipInfo() + local infoDict = XDataCenter.BaseEquipManager.GetBaseEquipInfo() + for part, baseEquip in pairs(infoDict) do + self:UpdateBaseEquip(part, baseEquip) + end +end + +function XUiBaseEquip:CheckRedPoint() + for part = 1, 6 do + local panelRedPoint = self["ImgRedPoint" .. part] + if panelRedPoint then + panelRedPoint.gameObject:SetActive(XDataCenter.BaseEquipManager.CheckNewHintByPart(part)) + end + end +end + +function XUiBaseEquip:UpdateBaseEquip(part, baseEquip) + local grid = self.GridBaseEquipDict[part] + if grid then + grid:Refresh(baseEquip) + return + end + + self:CreateBaseEquipGrid(part, baseEquip) +end diff --git a/Resources/Scripts/XUi/XUiBaseEquip/XUiGridBaseEquip.lua b/Resources/Scripts/XUi/XUiBaseEquip/XUiGridBaseEquip.lua new file mode 100644 index 00000000..df5c69c4 --- /dev/null +++ b/Resources/Scripts/XUi/XUiBaseEquip/XUiGridBaseEquip.lua @@ -0,0 +1,218 @@ +local pairs = pairs + +local XUiGridBaseEquip = XClass(nil, "XUiGridBaseEquip") + +function XUiGridBaseEquip:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self:InitAutoScript() + self:ResetUi() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiGridBaseEquip:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiGridBaseEquip:AutoInitUi() + self.ImgSelect = XUiHelper.TryGetComponent(self.Transform, "ImgSelect", "Image") + self.RImgIcon = XUiHelper.TryGetComponent(self.Transform, "RImgIcon", "RawImage") + self.ImgQuality = XUiHelper.TryGetComponent(self.Transform, "ImgQuality", "Image") + self.TxtStar = XUiHelper.TryGetComponent(self.Transform, "TxtStar", "Text") + self.TxtName = XUiHelper.TryGetComponent(self.Transform, "TxtName", "Text") + self.PanelAttrib1 = XUiHelper.TryGetComponent(self.Transform, "PanelAttrib1", nil) + self.PanelAttrib2 = XUiHelper.TryGetComponent(self.Transform, "PanelAttrib2", nil) + self.ImgPutOn = XUiHelper.TryGetComponent(self.Transform, "ImgPutOn", "Image") + self.PanelRedPoint = XUiHelper.TryGetComponent(self.Transform, "PanelRedPoint", "Image") + self.ImgRecycle = XUiHelper.TryGetComponent(self.Transform, "ImgRecycle", nil) + self.ImgLevelLimit = XUiHelper.TryGetComponent(self.Transform, "ImgLevelLimit", "Image") + self.TxtLevelLimit = XUiHelper.TryGetComponent(self.Transform, "TxtLevelLimit", "Text") + self.TxtPart = XUiHelper.TryGetComponent(self.Transform, "TxtPart", "Text") + self.TxtDesc = XUiHelper.TryGetComponent(self.Transform, "TxtDesc", "Text") +end + +function XUiGridBaseEquip:GetAutoKey(uiNode,eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiGridBaseEquip:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiGridBaseEquip:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key],eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiGridBaseEquip:AutoAddListener() + self.AutoCreateListeners = {} +end +-- auto + +function XUiGridBaseEquip:SetUiActive(ui, active) + if not ui or not ui.gameObject then + return + end + + if ui.gameObject.activeSelf == active then + return + end + + ui.gameObject:SetActive(active) +end + +function XUiGridBaseEquip:ResetUi() + self:SetUiActive(self.PanelAttrib1, false) + self:SetUiActive(self.PanelAttrib2, false) + self:SetUiActive(self.ImgSelect, false) + self:SetUiActive(self.PanelRedPoint, false) + self:SetUiActive(self.ImgPutOn, false) +end + +function XUiGridBaseEquip:ShowPanelArrtib(panel, attribInfo) + if not panel or not attribInfo then + return + end + + self:SetUiActive(XUiHelper.TryGetComponent(panel, "TxtNotEvaluated", "Text"), false) + + local txtName = XUiHelper.TryGetComponent(panel, "TxtAttribName", "Text") + if txtName then + txtName.text = attribInfo.Name + self:SetUiActive(txtName, true) + end + + local txtValue = XUiHelper.TryGetComponent(panel, "TxtAttribValue", "Text") + if txtValue then + txtValue.text = attribInfo.Value + self:SetUiActive(txtValue, true) + end + + self:SetUiActive(panel, true) +end + +function XUiGridBaseEquip:ShowEvaluated(id) + local info = XDataCenter.BaseEquipManager.GetEvaluatedAttribShowInfo(id) + if not info then + return + end + + local attriDescList = info.AttriDescList + if attriDescList then + local index = 1 + for _, descInfo in pairs(attriDescList) do + local panelAttrib = self["PanelAttrib" .. index] + if not panelAttrib then + return + end + + self:ShowPanelArrtib(panelAttrib, descInfo) + index = index + 1 + end + end +end + +function XUiGridBaseEquip:Init(rootUi, parent) + self.RootUi = rootUi + self.Parent = parent +end + +function XUiGridBaseEquip:Refresh(baseEquip) + if not baseEquip then + self.GameObject:SetActive(false) + return + end + + local templateId = baseEquip.TemplateId + self:ShowEvaluated(baseEquip.Id) + + local template = XDataCenter.BaseEquipManager.GetBaseEquipTemplate(templateId) + if not template then + return + end + + if self.RImgIcon and template.Icon then + self.RImgIcon:SetRawImage(template.Icon) + self:SetUiActive(self.RImgIcon, true) + end + + if self.ImgQuality and template.Quality then + self.RootUi:SetUiSprite(self.ImgQuality, XArrangeConfigs.GeQualityBgPath(template.Quality)) + self:SetUiActive(self.ImgQuality, true) + end + + if self.TxtStar and template.Star then + self.TxtStar.text = template.Star + self:SetUiActive(self.TxtStar, true) + end + + if self.TxtName and template.Name then + self.TxtName.text = template.Name + self:SetUiActive(self.TxtName, true) + end + + if self.ImgLevelLimit and self.TxtLevelLimit then + if template.Level > XPlayer.Level then + self.TxtLevelLimit.text = CS.XTextManager.GetText("BaseEquipNeedLevel", template.Level) + self:SetUiActive(self.ImgLevelLimit, true) + self:SetUiActive(self.TxtLevelLimit, true) + else + self:SetUiActive(self.ImgLevelLimit, false) + self:SetUiActive(self.TxtLevelLimit, false) + end + end + + if self.TxtPart and self.TxtDesc then + self.TxtPart.text = template.Part + local curType = math.ceil(template.Part /2) + self.TxtDesc.text = CS.XTextManager.GetText("BaseEquipType" .. curType) + self:SetUiActive(self.TxtPart, true) + end + + if XDataCenter.BaseEquipManager.CheckNewHint(baseEquip.Id) then + self:SetUiActive(self.PanelRedPoint, true) + XDataCenter.BaseEquipManager.AddNewHint(baseEquip.Id) + else + self:SetUiActive(self.PanelRedPoint, false) + end + + if self.Parent:CheckRecycle(baseEquip.Id) then + self:SetRecycle(true) + else + self:SetRecycle(false) + end + + self:SetPutOn(XDataCenter.BaseEquipManager.IsBaseEquipPutOn(baseEquip.Id)) + self.GameObject:SetActive(true) +end + +function XUiGridBaseEquip:SetSelect(isSelect) + self:SetUiActive(self.ImgSelect, isSelect) +end + +function XUiGridBaseEquip:SetRecycle(isSelect) + self:SetUiActive(self.ImgRecycle, isSelect) +end +function XUiGridBaseEquip:SetPutOn(isPutOn) + self:SetUiActive(self.ImgPutOn, isPutOn) +end + +return XUiGridBaseEquip \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiBaseEquip/XUiPanelBaseEquipInfo.lua b/Resources/Scripts/XUi/XUiBaseEquip/XUiPanelBaseEquipInfo.lua new file mode 100644 index 00000000..1d71efbb --- /dev/null +++ b/Resources/Scripts/XUi/XUiBaseEquip/XUiPanelBaseEquipInfo.lua @@ -0,0 +1,124 @@ +local XUiPanelBaseEquipInfo = XClass(nil, "XUiPanelBaseEquipInfo") + +function XUiPanelBaseEquipInfo:Ctor(ui, rootUI) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUI + self:InitAutoScript() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelBaseEquipInfo:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiPanelBaseEquipInfo:AutoInitUi() + self.BtnOk = self.Transform:Find("BtnOk"):GetComponent("Button") + self.BtnGet = self.Transform:Find("BtnGet"):GetComponent("Button") + self.ImgQuality = self.Transform:Find("ImgQuality"):GetComponent("Image") + self.RImgIcon = self.Transform:Find("RImgIcon"):GetComponent("RawImage") + self.TxtName = self.Transform:Find("TxtName"):GetComponent("Text") + self.PanelShowAttr1 = self.Transform:Find("PanelShowAttr1") + self.TxtAttrTitle1 = self.Transform:Find("PanelShowAttr1/TxtAttrTitle1"):GetComponent("Text") + self.TxtAttr1 = self.Transform:Find("PanelShowAttr1/TxtAttr1"):GetComponent("Text") + self.PanelShowAttr2 = self.Transform:Find("PanelShowAttr2") + self.TxtAttrTitle2 = self.Transform:Find("PanelShowAttr2/TxtAttrTitle2"):GetComponent("Text") + self.TxtAttr2 = self.Transform:Find("PanelShowAttr2/TxtAttr2"):GetComponent("Text") + self.TxtStar = self.Transform:Find("TxtStar"):GetComponent("Text") + self.TxtLevelLimit = self.Transform:Find("TxtLevelLimit"):GetComponent("Text") + self.TxtPartB = self.Transform:Find("TxtPart"):GetComponent("Text") + self.TxtDescB = self.Transform:Find("TxtDesc"):GetComponent("Text") + self.TxtType = self.Transform:Find("TxtType"):GetComponent("Text") +end + +function XUiPanelBaseEquipInfo:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelBaseEquipInfo:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelBaseEquipInfo:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelBaseEquipInfo:AutoAddListener() + self:RegisterClickEvent(self.BtnOk, self.OnBtnOkClick) + self:RegisterClickEvent(self.BtnGet, self.OnBtnGetClick) +end +-- auto + +function XUiPanelBaseEquipInfo:ShowPanel(equip) + self.CurEquip = equip + local template = XDataCenter.BaseEquipManager.GetBaseEquipTemplate(equip.TemplateId) + local showInfo = XDataCenter.BaseEquipManager.GetEvaluatedAttribShowInfo(equip.Id) + + if showInfo then + local attriDescList = showInfo.AttriDescList + if attriDescList then + local index = 1 + for _, descInfo in pairs(attriDescList) do + if not self["TxtAttrTitle" .. index] then + break + end + self["TxtAttrTitle" .. index].text = descInfo.Name + self["TxtAttr" .. index].text = descInfo.Value + index = index + 1 + end + end + end + + if self.RImgIcon and template.Icon then + self.RImgIcon:SetRawImage(template.Icon) + end + + if self.ImgQuality and template.Quality then + self.RootUi:SetUiSprite(self.ImgQuality, XArrangeConfigs.GeQualityBgPath(template.Quality)) + end + + if self.TxtStar and template.Star then + self.TxtStar.text = template.Star + end + + if self.TxtName and template.Name then + self.TxtName.text = template.Name + end + + if self.TxtLevelLimit and template.Level then + self.TxtLevelLimit.text = template.Level + end + + if self.TxtDescB and template.Description then + self.TxtDescB.text = template.Description + end + + if self.TxtPartB and self.TxtType then + self.TxtPartB.text = template.Part + local curType = math.ceil(template.Part /2) + self.TxtType.text = CS.XTextManager.GetText("BaseEquipType" .. curType) + end + + self.GameObject:SetActive(true) +end + +function XUiPanelBaseEquipInfo:HidePanel() + self.GameObject:SetActive(false) +end + +function XUiPanelBaseEquipInfo:OnBtnOkClick() + self:HidePanel() +end + +function XUiPanelBaseEquipInfo:OnBtnGetClick() + XLuaUiManager.Open("UiSkip", self.CurEquip.TemplateId) +end + +return XUiPanelBaseEquipInfo \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiBaseEquip/XUiPanelBaseEquipPutOn.lua b/Resources/Scripts/XUi/XUiBaseEquip/XUiPanelBaseEquipPutOn.lua new file mode 100644 index 00000000..a76320fa --- /dev/null +++ b/Resources/Scripts/XUi/XUiBaseEquip/XUiPanelBaseEquipPutOn.lua @@ -0,0 +1,379 @@ +local XUiGridBaseEquip = require("XUi/XUiBaseEquip/XUiGridBaseEquip") +local XUiPanelPutOnShowTip = require("XUi/XUiBaseEquip/XUiPanelPutOnShowTip") +local XUiBaseEquipInfo = require("XUi/XUiBaseEquip/XUiPanelBaseEquipInfo") +local XUiPanelBaseEquipRecycle = require("XUi/XUiBaseEquip/XUiPanelBaseEquipRecycle") +local XUiPanelBaseEquipPutOn = XClass(nil, "XUiPanelBaseEquipPutOn") + +function XUiPanelBaseEquipPutOn:Ctor(ui, parent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Parent = parent + self:InitAutoScript() + + self.PutOnTipPanel = XUiPanelPutOnShowTip.New(self.PanelPutOnShowTip) + self.RecyclePanel = XUiPanelBaseEquipRecycle.New(self.PanelBaseEquipRecycle, self, self.Parent) + self.BaseEquipInfoPanel = XUiBaseEquipInfo.New(self.PanelBaseEquipInfo, self.Parent) + self.SelectedGrid = XUiGridBaseEquip.New(self.GridBaseEquipSelected, self.RecyclePanel) + self.SelectedGrid:Init(self.Parent, self) + self.RecycleEquipList = {} + + self:AddCoinListener() + self:ResetUi() + self:InitDynamicTable() +end + +function XUiPanelBaseEquipPutOn:ResetUi() + self.BtnPutOn.gameObject:SetActive(false) + self.GridBaseEquipSelected.gameObject:SetActive(false) + self.PanelBaseEquipList.gameObject:SetActive(true) + self.PutOnTipPanel:HidePanel() +end + +function XUiPanelBaseEquipPutOn:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelBaseEquipView.gameObject) + self.DynamicTable:SetProxy(XUiGridBaseEquip) + self.DynamicTable:SetDelegate(self) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelBaseEquipPutOn:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiPanelBaseEquipPutOn:AutoInitUi() + self.PanelPart = self.Transform:Find("PanelPart") + self.GridBaseEquipSelected = self.Transform:Find("PanelPart/GridBaseEquipSelected") + self.PanelEmpty = self.Transform:Find("PanelPart/PanelEmpty") + self.TxtPart = self.Transform:Find("PanelPart/PanelEmpty/TxtPart"):GetComponent("Text") + self.TxtDesc = self.Transform:Find("PanelPart/PanelEmpty/TxtDesc"):GetComponent("Text") + self.BtnEquipInfo = self.Transform:Find("PanelPart/BtnEquipInfo"):GetComponent("Button") + self.PanelTogglePos = self.Transform:Find("PanelTogglePos") + self.Toggle1 = self.Transform:Find("PanelTogglePos/Toggle1"):GetComponent("Toggle") + self.ImgNew1 = self.Transform:Find("PanelTogglePos/Toggle1/ImgNew1"):GetComponent("Image") + self.Toggle2 = self.Transform:Find("PanelTogglePos/Toggle2"):GetComponent("Toggle") + self.ImgNew2 = self.Transform:Find("PanelTogglePos/Toggle2/ImgNew2"):GetComponent("Image") + self.Toggle3 = self.Transform:Find("PanelTogglePos/Toggle3"):GetComponent("Toggle") + self.ImgNew3 = self.Transform:Find("PanelTogglePos/Toggle3/ImgNew3"):GetComponent("Image") + self.Toggle4 = self.Transform:Find("PanelTogglePos/Toggle4"):GetComponent("Toggle") + self.ImgNew4 = self.Transform:Find("PanelTogglePos/Toggle4/ImgNew4"):GetComponent("Image") + self.Toggle5 = self.Transform:Find("PanelTogglePos/Toggle5"):GetComponent("Toggle") + self.ImgNew5 = self.Transform:Find("PanelTogglePos/Toggle5/ImgNew5"):GetComponent("Image") + self.Toggle6 = self.Transform:Find("PanelTogglePos/Toggle6"):GetComponent("Toggle") + self.ImgNew6 = self.Transform:Find("PanelTogglePos/Toggle6/ImgNew6"):GetComponent("Image") + self.PanelBaseEquipList = self.Transform:Find("PanelBaseEquipList") + self.PanelBaseEquipView = self.Transform:Find("PanelBaseEquipList/PanelBaseEquipView") + self.PanelBaseEquipRecycle = self.Transform:Find("PanelBaseEquipRecycle") + self.BtnPutOn = self.Transform:Find("BtnPutOn"):GetComponent("Button") + self.TxtEmptyTip = self.Transform:Find("TxtEmptyTip"):GetComponent("Text") + self.TxtCapacity = self.Transform:Find("TxtCapacity"):GetComponent("Text") + self.TxtCoinNum = self.Transform:Find("TxtCoinNum"):GetComponent("Text") + self.PanelPutOnShowTip = self.Transform:Find("PanelPutOnShowTip") + self.BtnRecycle = self.Transform:Find("BtnRecycle"):GetComponent("Button") + self.PanelBaseEquipInfo = self.Transform:Find("PanelBaseEquipInfo") +end + +function XUiPanelBaseEquipPutOn:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelBaseEquipPutOn:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelBaseEquipPutOn:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelBaseEquipPutOn:AutoAddListener() + self:RegisterClickEvent(self.BtnEquipInfo, self.OnBtnEquipInfoClick) + self:RegisterClickEvent(self.Toggle1, self.OnToggle1Click) + self:RegisterClickEvent(self.Toggle2, self.OnToggle2Click) + self:RegisterClickEvent(self.Toggle3, self.OnToggle3Click) + self:RegisterClickEvent(self.Toggle4, self.OnToggle4Click) + self:RegisterClickEvent(self.Toggle5, self.OnToggle5Click) + self:RegisterClickEvent(self.Toggle6, self.OnToggle6Click) + self:RegisterClickEvent(self.BtnPutOn, self.OnBtnPutOnClick) + self:RegisterClickEvent(self.BtnRecycle, self.OnBtnRecycleClick) +end +-- auto +function XUiPanelBaseEquipPutOn:OnBtnEquipInfoClick() + if not self.CurIndex then + return + end + + local baseEquip = XDataCenter.BaseEquipManager.GetBaseEquipByPart(self.CurPart) + if not baseEquip then + return + end + self.BaseEquipInfoPanel:ShowPanel(baseEquip) +end + +function XUiPanelBaseEquipPutOn:OnBtnRecycleClick() + self:ShowRecyclePanel() +end + +function XUiPanelBaseEquipPutOn:OnToggle1Click() + self:ShowPanel(1) +end + +function XUiPanelBaseEquipPutOn:OnToggle2Click() + self:ShowPanel(2) +end + +function XUiPanelBaseEquipPutOn:OnToggle3Click() + self:ShowPanel(3) +end + +function XUiPanelBaseEquipPutOn:OnToggle4Click() + self:ShowPanel(4) +end + +function XUiPanelBaseEquipPutOn:OnToggle5Click() + self:ShowPanel(5) +end + +function XUiPanelBaseEquipPutOn:OnToggle6Click() + self:ShowPanel(6) +end + +function XUiPanelBaseEquipPutOn:OnBtnPutOnClick() + if not self.CurIndex then + return + end + + local baseEquip = self.BaseEquipList[self.CurIndex] + if not baseEquip then + return + end + + local oldBaseEquip = XDataCenter.BaseEquipManager.GetBaseEquipByPart(self.CurPart) + XDataCenter.BaseEquipManager.PutOn(baseEquip.Id, function() + self.PutOnTipPanel:ShowPanel(baseEquip.Id, oldBaseEquip and oldBaseEquip.Id or nil) + self:UpdateSelectedGrid(baseEquip) + self:HidePutOn() + self:ResetGrids() + self.CurGrid:SetPutOn(true) + end) +end + +function XUiPanelBaseEquipPutOn:SetRecycleByStar(star, recycle) + for index, data in pairs(self.BaseEquipList) do + if XDataCenter.BaseEquipManager.GetBaseEquipStar(data.TemplateId) == star then + if recycle then + self:AddToRecycleList(data.Id) + else + self:RemoveFromRecycleList(data.Id) + end + + local grid = self.DynamicTable:GetGridByIndex(index) + if grid then + grid:SetRecycle(recycle) + end + end + end +end + +function XUiPanelBaseEquipPutOn:ResetGrids() + for index, _ in pairs(self.BaseEquipList) do + local grid = self.DynamicTable:GetGridByIndex(index) + if grid then + grid:SetPutOn(false) + grid:SetRecycle(false) + end + end +end + +function XUiPanelBaseEquipPutOn:ShowRecyclePanel() + self.RecycleMode = true + if self.CurGrid then + self.CurGrid:SetSelect(false) + self.CurGrid = nil + self.CurIndex = 0 + end + self.BtnPutOn.gameObject:SetActive(false) + self.BtnRecycle.gameObject:SetActive(false) + self.PanelBaseEquipRecycle.gameObject:SetActive(true) + local isShow = XDataCenter.BaseEquipManager.CheckNewHintByPart(self.CurPart) + self["ImgNew" .. self.CurPart].gameObject:SetActive(isShow) + self.BaseEquipList = XDataCenter.BaseEquipManager.GetBaseEquipNotPutOnListByPart(self.CurPart) + self:ReloadDynamicTable() +end + +function XUiPanelBaseEquipPutOn:HideRecyclePanel() + self.RecycleMode = false + self.PanelBaseEquipRecycle.gameObject:SetActive(false) + self.BtnRecycle.gameObject:SetActive(true) + self:ClearRecycleList() + self.RecyclePanel:RefreshRecyclePanel() + local isShow = XDataCenter.BaseEquipManager.CheckNewHintByPart(self.CurPart) + self["ImgNew" .. self.CurPart].gameObject:SetActive(isShow) + self.BaseEquipList = XDataCenter.BaseEquipManager.GetBaseEquipListByPart(self.CurPart) + self:ReloadDynamicTable() +end + +function XUiPanelBaseEquipPutOn:UpdateSelectedGrid(baseEquip) + self.SelectedGrid:Refresh(baseEquip) +end + +function XUiPanelBaseEquipPutOn:ShowPanel(part) + self:ResetUi() + self.CurPart = part + self.CurGrid = nil + self.CurIndex = 0 + if self.RecycleMode then + self.BaseEquipList = XDataCenter.BaseEquipManager.GetBaseEquipNotPutOnListByPart(part) + self:ClearRecycleList() + self.RecyclePanel:RefreshRecyclePanel() + else + self.BaseEquipList = XDataCenter.BaseEquipManager.GetBaseEquipListByPart(part) + end + + self:HidePutOn() + self.GameObject:SetActive(true) + self["Toggle" .. part].isOn = true + + for i = 1, 6 do + local isShow = XDataCenter.BaseEquipManager.CheckNewHintByPart(i) + self["ImgNew" .. i].gameObject:SetActive(isShow) + end + + self.TxtPart.text = part + local curType = math.ceil(part / 2) + self.TxtDesc.text = CS.XTextManager.GetText("BaseEquipType" .. curType) + self:UpdateSelectedGrid(XDataCenter.BaseEquipManager.GetBaseEquipByPart(part)) + self:ReloadDynamicTable() +end + +function XUiPanelBaseEquipPutOn:ReloadDynamicTable() + if self.CurGrid then + self.CurGrid:SetSelect(false) + end + + local count = #self.BaseEquipList + self.TxtEmptyTip.gameObject:SetActive(count <= 0) + self.DynamicTable:SetDataSource(self.BaseEquipList) + self.DynamicTable:ReloadDataASync(count > 0 and 1 or -1) + + self.TxtCapacity.text = count +end + +function XUiPanelBaseEquipPutOn:HidePanel() + self.GameObject:SetActive(false) +end + +function XUiPanelBaseEquipPutOn:IsShow() + return self.GameObject.activeSelf +end + +function XUiPanelBaseEquipPutOn:ShowPutOn() + self.BtnPutOn.gameObject:SetActive(true) +end + +function XUiPanelBaseEquipPutOn:HidePutOn() + self.BtnPutOn.gameObject:SetActive(false) +end + +function XUiPanelBaseEquipPutOn:AddCoinListener() + local coinID = XDataCenter.ItemManager.ItemId.BaseEquipCoin + XDataCenter.ItemManager.AddCountUpdateListener(coinID, function() + self:UpdateBaseEquipCoin() + end, self.TxtCoinNum) + self:UpdateBaseEquipCoin() +end + +function XUiPanelBaseEquipPutOn:UpdateBaseEquipCoin() + local coinID = XDataCenter.ItemManager.ItemId.BaseEquipCoin + self.TxtCoinNum.text = XDataCenter.ItemManager.GetItem(coinID).Count +end + +function XUiPanelBaseEquipPutOn:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self.Parent, self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.BaseEquipList[index] + grid:Refresh(data) + grid:SetSelect(index == self.CurIndex) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + local data = self.BaseEquipList[index] + if self.RecycleMode then + if self:CheckRecycle(data.Id) then + self:RemoveFromRecycleList(data.Id) + self.RecyclePanel:RefreshRecyclePanel() + grid:SetRecycle(false) + else + self:AddToRecycleList(data.Id) + self.RecyclePanel:RefreshRecyclePanel() + grid:SetRecycle(true) + end + else + local oldEquip = XDataCenter.BaseEquipManager.GetBaseEquipByPart(self.CurPart) + + if oldEquip == nil or data.Id ~= oldEquip.Id then + self:ShowPutOn() + else + self:HidePutOn() + end + + if self.CurGrid then + self.CurGrid:SetSelect(false) + end + + grid:SetSelect(true) + self.CurGrid = grid + self.CurIndex = index + end + end +end + +function XUiPanelBaseEquipPutOn:AddToRecycleList(equipId) + self.RecycleEquipList[equipId] = true +end + +function XUiPanelBaseEquipPutOn:RemoveFromRecycleList(equipId) + self.RecycleEquipList[equipId] = nil +end + +function XUiPanelBaseEquipPutOn:CheckRecycle(equipId) + return self.RecycleEquipList[equipId] ~= nil +end + +function XUiPanelBaseEquipPutOn:ClearRecycleList() + self.RecycleEquipList = {} +end + +function XUiPanelBaseEquipPutOn:GetRecycleEquipCount() + local count = 0 + for _, _ in pairs(self.RecycleEquipList) do + count = count + 1 + end + return count +end + +function XUiPanelBaseEquipPutOn:GetRecycleEquipReward() + local rewardGoodsList = {} + for id, _ in pairs(self.RecycleEquipList) do + local equip = XDataCenter.BaseEquipManager.GetBaseEquipById(id) + local rewardId = XDataCenter.BaseEquipManager.GetBaseEquipRecoveryRewardId(equip.TemplateId) + if rewardId then + local rewardList = XRewardManager.GetRewardList(rewardId) + for _, reward in pairs(rewardList) do + table.insert(rewardGoodsList, reward) + end + end + end + + return XRewardManager.MergeAndSortRewardGoodsList(rewardGoodsList) +end + +function XUiPanelBaseEquipPutOn:RefreshAfterRecycle() + self:HideRecyclePanel() +end + +return XUiPanelBaseEquipPutOn \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiBaseEquip/XUiPanelBaseEquipRecycle.lua b/Resources/Scripts/XUi/XUiBaseEquip/XUiPanelBaseEquipRecycle.lua new file mode 100644 index 00000000..ad3834d0 --- /dev/null +++ b/Resources/Scripts/XUi/XUiBaseEquip/XUiPanelBaseEquipRecycle.lua @@ -0,0 +1,128 @@ +local XUiPanelBaseEquipRecycle = XClass(nil, "XUiPanelBaseEquipRecycle") + +function XUiPanelBaseEquipRecycle:Ctor(ui, parent, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Parent = parent + self.RootUI = uiRoot + self:InitAutoScript() + self:InitDynamicTable() +end + +function XUiPanelBaseEquipRecycle:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelRewardView) + self.DynamicTable:SetProxy(XUiGridCommon) + self.DynamicTable:SetDelegate(self) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelBaseEquipRecycle:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiPanelBaseEquipRecycle:AutoInitUi() + self.PanelRewardView = self.Transform:Find("PanelRewardView") + self.BtnCloseRecycle = self.Transform:Find("BtnCloseRecycle"):GetComponent("Button") + self.BtnReset = self.Transform:Find("BtnReset"):GetComponent("Button") + self.BtnDoRecycle = self.Transform:Find("BtnDoRecycle"):GetComponent("Button") + self.TxtSelectedNum = self.Transform:Find("TxtSelectedNum"):GetComponent("Text") + self.TogTwoStar = self.Transform:Find("TogTwoStar"):GetComponent("Toggle") + self.TogThreeStar = self.Transform:Find("TogThreeStar"):GetComponent("Toggle") + self.TogFourStar = self.Transform:Find("TogFourStar"):GetComponent("Toggle") + self.TogOneStar = self.Transform:Find("TogOneStar"):GetComponent("Toggle") +end + +function XUiPanelBaseEquipRecycle:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelBaseEquipRecycle:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelBaseEquipRecycle:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelBaseEquipRecycle:AutoAddListener() + self:RegisterClickEvent(self.BtnCloseRecycle, self.OnBtnCloseRecycleClick) + self:RegisterClickEvent(self.BtnReset, self.OnBtnResetClick) + self:RegisterClickEvent(self.BtnDoRecycle, self.OnBtnDoRecycleClick) + self:RegisterClickEvent(self.TogTwoStar, self.OnTogTwoStarClick) + self:RegisterClickEvent(self.TogThreeStar, self.OnTogThreeStarClick) + self:RegisterClickEvent(self.TogFourStar, self.OnTogFourStarClick) + self:RegisterClickEvent(self.TogOneStar, self.OnTogOneStarClick) +end +-- auto + +function XUiPanelBaseEquipRecycle:OnTogOneStarClick() + self.Parent:SetRecycleByStar(1, self.TogOneStar.isOn) + self:RefreshRecyclePanel() +end + +function XUiPanelBaseEquipRecycle:OnTogTwoStarClick() + self.Parent:SetRecycleByStar(2, self.TogTwoStar.isOn) + self:RefreshRecyclePanel() +end + +function XUiPanelBaseEquipRecycle:OnTogThreeStarClick() + self.Parent:SetRecycleByStar(3, self.TogThreeStar.isOn) + self:RefreshRecyclePanel() +end + +function XUiPanelBaseEquipRecycle:OnTogFourStarClick() + self.Parent:SetRecycleByStar(4, self.TogFourStar.isOn) + self:RefreshRecyclePanel() +end + +function XUiPanelBaseEquipRecycle:OnBtnDoRecycleClick() + local idList = {} + for id, _ in pairs(self.Parent.RecycleEquipList) do + table.insert(idList, id) + end + XDataCenter.BaseEquipManager.Recycle(idList, function() + self.Parent:RefreshAfterRecycle() + end) +end + +function XUiPanelBaseEquipRecycle:RefreshRecyclePanel() + self.TxtSelectedNum.text = self.Parent:GetRecycleEquipCount() + + self.RewardList = self.Parent:GetRecycleEquipReward() + self.DynamicTable:SetDataSource(self.RewardList) + self.DynamicTable:ReloadDataASync() +end + +function XUiPanelBaseEquipRecycle:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self.RootUI) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.RewardList[index] + grid:Refresh(data) + end +end + +function XUiPanelBaseEquipRecycle:OnBtnCloseRecycleClick() + self.TogOneStar.isOn = false + self.TogTwoStar.isOn = false + self.TogThreeStar.isOn = false + self.TogFourStar.isOn = false + self.Parent:HideRecyclePanel() +end + +function XUiPanelBaseEquipRecycle:OnBtnResetClick() + self.TogOneStar.isOn = false + self.TogTwoStar.isOn = false + self.TogThreeStar.isOn = false + self.TogFourStar.isOn = false + self.Parent:HideRecyclePanel() +end + +return XUiPanelBaseEquipRecycle \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiBaseEquip/XUiPanelPutOnShowTip.lua b/Resources/Scripts/XUi/XUiBaseEquip/XUiPanelPutOnShowTip.lua new file mode 100644 index 00000000..a356076d --- /dev/null +++ b/Resources/Scripts/XUi/XUiBaseEquip/XUiPanelPutOnShowTip.lua @@ -0,0 +1,101 @@ +local pairs = pairs + +local XUiPanelPutOnShowTip = XClass(nil, "XUiPanelPutOnShowTip") + +function XUiPanelPutOnShowTip:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self:InitAutoScript() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelPutOnShowTip:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiPanelPutOnShowTip:AutoInitUi() + self.BtnClick = self.Transform:Find("BtnClick"):GetComponent("Button") + self.PanelDetails = self.Transform:Find("PanelDetails") + self.PanelAttrib1 = self.Transform:Find("PanelDetails/PanelAttrib1") + self.PanelAttrib2 = self.Transform:Find("PanelDetails/PanelAttrib2") +end + +function XUiPanelPutOnShowTip:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelPutOnShowTip:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelPutOnShowTip:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelPutOnShowTip:AutoAddListener() + self:RegisterClickEvent(self.BtnClick, self.OnBtnClickClick) +end +-- auto + +function XUiPanelPutOnShowTip:OnBtnClickClick() + self:HidePanel() +end + +function XUiPanelPutOnShowTip:ShowPanelArrtib(panel, attribInfo) + if not panel or not attribInfo then + return + end + + local txtName = XUiHelper.TryGetComponent(panel, "TxtAttribName", "Text") + if txtName then + txtName.text = attribInfo.Name + end + + local txtValue = XUiHelper.TryGetComponent(panel, "TxtAttribValue", "Text") + if txtValue then + txtValue.text = attribInfo.Value + end +end + +function XUiPanelPutOnShowTip:ShowAttribChangeIcon(panel, status) + local imgUp = XUiHelper.TryGetComponent(panel, "ImgUp", "Image") + local imgDown = XUiHelper.TryGetComponent(panel, "ImgDown", "Image") + + imgUp.gameObject:SetActive(status == XDataCenter.BaseEquipManager.XATTRIB_CHANGE.Up) + imgDown.gameObject:SetActive(status == XDataCenter.BaseEquipManager.XATTRIB_CHANGE.Down) +end + +function XUiPanelPutOnShowTip:ShowPanel(newBaseEquipId, oldBaseEquipId) + if not newBaseEquipId then + return + end + + local showInfo = XDataCenter.BaseEquipManager.GetEvaluatedAttribShowInfo(newBaseEquipId) + local compareResultList = XDataCenter.BaseEquipManager.CompareAttrib(newBaseEquipId, oldBaseEquipId) + local attriDescList = showInfo.AttriDescList + + for index, descInfo in pairs(attriDescList) do + local attrPanel = self["PanelAttrib" .. index] + if not attrPanel then + break + end + + self:ShowPanelArrtib(attrPanel, descInfo) + self:ShowAttribChangeIcon(attrPanel, compareResultList[index]) + end + + self.GameObject:SetActive(true) +end + +function XUiPanelPutOnShowTip:HidePanel() + self.GameObject:SetActive(false) +end + +return XUiPanelPutOnShowTip \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiBfrt/XUiBfrtDeploy.lua b/Resources/Scripts/XUi/XUiBfrt/XUiBfrtDeploy.lua new file mode 100644 index 00000000..54f03667 --- /dev/null +++ b/Resources/Scripts/XUi/XUiBfrt/XUiBfrtDeploy.lua @@ -0,0 +1,268 @@ +local pairs = pairs +local ipairs = ipairs +local ANIMATION_OPEN = "AniBfrtDeployBegin" + +local XUiGridEchelon = require("XUi/XUiBfrt/XUiGridEchelon") + +local XUiBfrtDeploy = XLuaUiManager.Register(XLuaUi, "UiBfrtDeploy") + +function XUiBfrtDeploy:OnAwake() + self:AutoAddListener() + self.GridEchelon.gameObject:SetActiveEx(false) + self:ResetGroupInfo() +end + +function XUiBfrtDeploy:OnStart(groupId) + self:InitGroupInfo(groupId) + --self:PlayAnimation(ANIMATION_OPEN) +end + +function XUiBfrtDeploy:OnDestroy() + self:ResetGroupInfo() +end + +function XUiBfrtDeploy:ResetGroupInfo() + self.GroupId = nil + self.FightInfoIdList = {} + self.LogisticsInfoIdList = {} + self.FightTeamList = {} + self.LogisticsTeamList = {} + self.CharacterIdListWrap = {} + self.FightTeamGridList = {} + self.LogisticsTeamGridList = {} +end + +function XUiBfrtDeploy:InitGroupInfo(groupId) + if not groupId then + XLog.Error("XUiBfrtDeploy:InitGroupInfo error: groupId not Exist.") + return + end + self.GroupId = groupId + self.FightInfoIdList = XDataCenter.BfrtManager.GetFightInfoIdList(groupId) + self.LogisticsInfoIdList = XDataCenter.BfrtManager.GetLogisticsInfoIdList(groupId) + self.FightTeamList = XDataCenter.BfrtManager.GetFightTeamList(groupId) + self.LogisticsTeamList = XDataCenter.BfrtManager.GetLogisticsTeamList(groupId) + + self:UpdateEchelonList() +end + +function XUiBfrtDeploy:AutoAddListener() + self.BtnAutoTeam.CallBack = function() self:OnBtnAutoTeamClick() end + self.BtnFight.CallBack = function() self:OnBtnFightClick() end + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + self.BtnQuickDeploy.CallBack = function() self:OnBtnQuickDeployClick() end + + self.BtnHelp.CallBack = function() + self:OnBtnHelpClick() + end +end + +function XUiBfrtDeploy:OnBtnFightClick() + --先检查挑战次数 + local groupId = self.GroupId + local baseStageId = XDataCenter.BfrtManager.GetBaseStage(groupId) + local chanllengeNum = XDataCenter.BfrtManager.GetGroupFinishCount(baseStageId) + local maxChallengeNum = XDataCenter.BfrtManager.GetGroupMaxChallengeNum(baseStageId) + if maxChallengeNum > 0 and chanllengeNum >= maxChallengeNum then + XUiManager.TipMsg(CS.XTextManager.GetText("FubenChallengeCountNotEnough")) + return + end + + --再检查队伍 + local fightTeamList = self.FightTeamList + local logisticsTeamList = self.LogisticsTeamList + local checkTeamCb = function() + self:Close() + XLuaUiManager.Open("UiBfrtInfo", groupId, fightTeamList) + end + + XDataCenter.BfrtManager.CheckTeam(groupId, fightTeamList, logisticsTeamList, checkTeamCb) +end + +function XUiBfrtDeploy:OnBtnAutoTeamClick() + local fightTeamList, logisticsTeamList, anyMemberInTeam = XDataCenter.BfrtManager.AutoTeam(self.GroupId) + if not anyMemberInTeam then + XUiManager.TipMsg(CS.XTextManager.GetText("BfrtAutoTeamNoMember")) + return + end + + self.FightTeamList, self.LogisticsTeamList = fightTeamList, logisticsTeamList + self:UpdateEchelonList() +end + +function XUiBfrtDeploy:OnBtnQuickDeployClick() + local groupId = self.GroupId + local saveCb = function() + self:UpdateEchelonList() + end + self:OpenChildUi("UiBfrtQuickDeploy", groupId, self, saveCb) +end + +function XUiBfrtDeploy:OnBtnBackClick() + self:Close() +end + +function XUiBfrtDeploy:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiBfrtDeploy:UpdateEchelonList() + local passCondition = true + + local data = { + EchelonType = nil, + BfrtGroupId = self.GroupId, + EchelonId = nil, + EchelonIndex = nil, + BaseStage = XDataCenter.BfrtManager.GetBaseStage(self.GroupId), + } + + for index, echelonId in ipairs(self.FightInfoIdList) do + data.EchelonType = XDataCenter.BfrtManager.EchelonType.Fight + data.EchelonId = echelonId + data.EchelonIndex = index + data.TeamList = self.FightTeamList + data.CharacterIdListWrap = self.CharacterIdListWrap + + local grid = self.FightTeamGridList[index] + if not grid then + local ui = CS.UnityEngine.Object.Instantiate(self.GridEchelon) + grid = XUiGridEchelon.New(self, ui, data) + grid.Transform:SetParent(self.PanelEchelonContent, false) + grid.GameObject:SetActiveEx(true) + grid.GameObject.name = tostring(echelonId) + self.FightTeamGridList[index] = grid + else + grid:UpdateEchelonInfo(data) + end + + passCondition = passCondition and grid.ConditionPassed + end + + for i = #self.FightInfoIdList + 1, #self.FightTeamList do + self.FightTeamList[i] = nil + end + + for index, echelonId in ipairs(self.LogisticsInfoIdList) do + data.EchelonType = XDataCenter.BfrtManager.EchelonType.Logistics + data.EchelonId = echelonId + data.EchelonIndex = index + data.TeamList = self.LogisticsTeamList + data.CharacterIdListWrap = self.CharacterIdListWrap + + local grid = self.LogisticsTeamGridList[index] + if not grid then + local ui = CS.UnityEngine.Object.Instantiate(self.GridEchelon) + grid = XUiGridEchelon.New(self, ui, data) + grid.Transform:SetParent(self.PanelEchelonContent, false) + grid.GameObject:SetActiveEx(true) + grid.GameObject.name = tostring(echelonId) + self.LogisticsTeamGridList[index] = grid + else + grid:UpdateEchelonInfo(data) + end + + passCondition = passCondition and grid.ConditionPassed + end + + for i = #self.LogisticsInfoIdList + 1, #self.LogisticsTeamList do + self.LogisticsTeamList[i] = nil + end + + -- self.PanelDanger.gameObject:SetActiveEx(not passCondition) + self.PanelDanger.gameObject:SetActiveEx(false) + + local allTeamEmpty = self:CheckAllTeamEmpty() + self.BtnQuickDeploy.gameObject:SetActiveEx(not allTeamEmpty) +end + +function XUiBfrtDeploy:OnBtnHelpClick() + local helpContent = CS.XGame.ClientConfig:GetString("BfrtShowHelpTip03") + XUiManager.ShowHelpTip(helpContent) +end + +function XUiBfrtDeploy:CheckIsInTeamList(characterId) + if not characterId or characterId == 0 then + return + end + + for echelonIndex, team in pairs(self.FightTeamList) do + for _, id in pairs(team) do + if id == characterId then + return echelonIndex, XDataCenter.BfrtManager.EchelonType.Fight + end + end + end + + for echelonIndex, team in pairs(self.LogisticsTeamList) do + for _, id in pairs(team) do + if id == characterId then + return echelonIndex, XDataCenter.BfrtManager.EchelonType.Logistics + end + end + end +end + +function XUiBfrtDeploy:CheckAllTeamEmpty() + for echelonIndex, team in pairs(self.FightTeamList) do + for _, id in pairs(team) do + if id and id > 0 then + return false + end + end + end + + for echelonIndex, team in pairs(self.LogisticsTeamList) do + for _, id in pairs(team) do + if id and id > 0 then + return false + end + end + end + + return true +end + +function XUiBfrtDeploy:FindTeamPos(characterId) + if not characterId or characterId <= 0 then return end + + local findTeam, findPos + + for _, team in pairs(self.FightTeamList) do + for pos, id in pairs(team) do + if id == characterId then + findTeam = team + findPos = pos + break + end + end + end + + if not findTeam then + for _, team in pairs(self.LogisticsTeamList) do + for pos, id in pairs(team) do + if id == characterId then + findTeam = team + findPos = pos + break + end + end + end + end + + return findTeam, findPos +end + +function XUiBfrtDeploy:CharacterSwapEchelon(oldCharacterId, newCharacterId) + local oldTeam, oldCharacterPos = self:FindTeamPos(oldCharacterId) + local newTeam, newCharacterPos = self:FindTeamPos(newCharacterId) + + if oldTeam and oldCharacterPos then + oldTeam[oldCharacterPos] = newCharacterId + end + + if newTeam and newCharacterPos then + newTeam[newCharacterPos] = oldCharacterId + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiBfrt/XUiBfrtInfo.lua b/Resources/Scripts/XUi/XUiBfrt/XUiBfrtInfo.lua new file mode 100644 index 00000000..d1bdb0f4 --- /dev/null +++ b/Resources/Scripts/XUi/XUiBfrt/XUiBfrtInfo.lua @@ -0,0 +1,132 @@ +local stringFormat = string.format + +local XUiBfrtInfo = XLuaUiManager.Register(XLuaUi, "UiBfrtInfo") + +local ANIMATION_OPEN = "UiBfrtInfoBegan%d" +local ANIMATION_LOOP = "UiBfrtInfoLoop%d" + +local ANIMATION_PANEL = { + "PanelStageList01", + "PanelStageList02", + "PanelStageList03", + "PanelStageList04", +} + +function XUiBfrtInfo:OnGetEvents() + return { CS.XEventId.EVENT_FIGHT_FORCE_EXIT, XEventId.EVENT_FUBEN_SETTLE_FAIL } +end + +function XUiBfrtInfo:OnNotify(evt) + if evt == CS.XEventId.EVENT_FIGHT_FORCE_EXIT or evt == XEventId.EVENT_FUBEN_SETTLE_FAIL then + self:Close() + end +end + +function XUiBfrtInfo:OnStart(groupId, fightTeams) + self:ShowBfrtInfo(groupId, fightTeams) +end + +function XUiBfrtInfo:ShowBfrtInfo(groupId, fightTeams) + self.GroupId = groupId + self.CurIndex = 1 + + local chapterId = XDataCenter.BfrtManager.GetChapterIdByGroupId(groupId) + local chapterCfg = XDataCenter.BfrtManager.GetChapterCfg(chapterId) + local stageIdList = XDataCenter.BfrtManager.GetStageIdList(groupId) + local maxIndex = #stageIdList + + self.TxtZhangjie.text = chapterCfg.ChapterName + self.TxtGroupName.text = chapterCfg.ChapterEn + + local updateStageInfofunc = function() + if self.CurIndex > maxIndex then + XDataCenter.BfrtManager.SetCloseLoadingCb() + XDataCenter.BfrtManager.SetFightCb() + self:Close() + return + end + + self.FullScreenBackground.gameObject:SetActive(true) + self.SafeAreaContentPane.gameObject:SetActive(true) + + local stageId = stageIdList[self.CurIndex] + local team = fightTeams[self.CurIndex] + self:UpdateAnimationNode() + self:PlayBeginAnimation() + self:SetBfrtTeam(team) + + local fightInfoIdList = XDataCenter.BfrtManager.GetFightInfoIdList(groupId) + local echelonId = fightInfoIdList[self.CurIndex] + local captainPos = XDataCenter.BfrtManager.GetTeamCaptainPos(echelonId) + local firstFightPost = XDataCenter.BfrtManager.GetTeamFirstFightPos(echelonId) + XDataCenter.FubenManager.EnterBfrtFight(stageId, team, captainPos, firstFightPost) + + self.TxtName.text = CS.XTextManager.GetText("BfrtInfoTeamName", self.CurIndex) + end + + XDataCenter.BfrtManager.SetCloseLoadingCb(function() + self.FullScreenBackground.gameObject:SetActive(false) + self.SafeAreaContentPane.gameObject:SetActive(false) + end) + + XDataCenter.BfrtManager.SetFightCb(function(result) + if not result then + XDataCenter.BfrtManager.SetCloseLoadingCb() + XDataCenter.BfrtManager.SetFightCb() + self:Close() + else + self.CurIndex = self.CurIndex + 1 + updateStageInfofunc() + end + end) + + updateStageInfofunc() +end + +function XUiBfrtInfo:SetBfrtTeam(team) + local count = #team + if count <= 0 then + self.GridTeam.gameObject:SetActive(false) + return + end + + for i = 1, count do + local viewIndex = XDataCenter.BfrtManager.TeamPosConvert(i) + if team[i] > 0 then + self["RImgCharIcon" .. viewIndex]:SetRawImage(XDataCenter.CharacterManager.GetCharBigRoundnessNotItemHeadIcon(team[i])) + self["PanelCharIcon" .. viewIndex].gameObject:SetActive(true) + else + self["PanelCharIcon" .. viewIndex].gameObject:SetActive(false) + end + end +end + +function XUiBfrtInfo:UpdateAnimationNode() + for k, v in pairs(ANIMATION_PANEL) do + if k == self.CurIndex then + self[v].gameObject:SetActive(true) + else + self[v].gameObject:SetActive(false) + end + end + + local stageList = XDataCenter.BfrtManager.GetStageIdList(self.GroupId) + for i = #stageList + 2, 4 do + local gridBfrtStage = XUiHelper.TryGetComponent(self[ANIMATION_PANEL[self.CurIndex]], "GridBfrtStage" .. i, nil) + if gridBfrtStage then gridBfrtStage.gameObject:SetActive(false) end + end +end + +function XUiBfrtInfo:PlayBeginAnimation() + local endCb = function() + self:PlayLoopAnimation() + end + + local animName = stringFormat(ANIMATION_OPEN, self.CurIndex) + self:PlayAnimation(animName, endCb) +end + +function XUiBfrtInfo:PlayLoopAnimation() + local animName = stringFormat(ANIMATION_LOOP, self.CurIndex) + self:PlayAnimation(animName) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiBfrt/XUiBfrtPostWarCount.lua b/Resources/Scripts/XUi/XUiBfrt/XUiBfrtPostWarCount.lua new file mode 100644 index 00000000..87bd3a56 --- /dev/null +++ b/Resources/Scripts/XUi/XUiBfrt/XUiBfrtPostWarCount.lua @@ -0,0 +1,171 @@ +local ipairs = ipairs +local XUiGridEchelonExp = require("XUi/XUiBfrt/XUiGridEchelonExp") +local XUiBfrtPostWarCount = XLuaUiManager.Register(XLuaUi, "UiBfrtPostWarCount") +local ANIMATION_OPEN = "AniBfrtPostWarCountBegin" + +function XUiBfrtPostWarCount:OnAwake() + self:InitAutoScript() +end + +function XUiBfrtPostWarCount:OnStart(data) + self:InitComponentState() + self:ResetDataInfo() + self:UpdateDataInfo(data) + self:PlayAnimation(ANIMATION_OPEN) +end + +function XUiBfrtPostWarCount:OnNotify(evt, ...) + local args = { ... } + + if evt == CS.XEventId.EVENT_UI_ALLOWOPERATE and args[1] == self.Ui then + XDataCenter.FunctionEventManager.UnLockFunctionEvent() + end +end + +function XUiBfrtPostWarCount:OnGetEvents() + return { CS.XEventId.EVENT_UI_ALLOWOPERATE } +end + +function XUiBfrtPostWarCount:InitComponentState() + self.GridEchelonExp.gameObject:SetActive(false) +end + +function XUiBfrtPostWarCount:ResetDataInfo() + self.RewardGoodsList = {} + self.GroupId = nil + + self.GridReward.gameObject:SetActive(false) + self.GridEchelonExp.gameObject:SetActive(false) +end + +function XUiBfrtPostWarCount:UpdateDataInfo(data) + self.RewardGoodsList = data.RewardGoodsList + self.GroupId = XDataCenter.BfrtManager.GetGroupIdByStageId(data.StageId) + + self:UpdatePanelRewardContent() + self:UpdatePanelEchelonExpContent() + self:UpdatePanelPlayer() +end + +function XUiBfrtPostWarCount:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiBfrtPostWarCount:AutoInitUi() + self.PanelRewardContent = self.Transform:Find("SafeAreaContentPane/PaneReward/RewardList/Viewport/PanelRewardContent") + self.GridReward = self.Transform:Find("SafeAreaContentPane/PaneReward/RewardList/Viewport/PanelRewardContent/GridReward") + self.PanelEchelonExpContent = self.Transform:Find("SafeAreaContentPane/PaneEchelonExp/EchelonExpList/Viewport/PanelEchelonExpContent") + self.GridEchelonExp = self.Transform:Find("SafeAreaContentPane/PaneEchelonExp/EchelonExpList/Viewport/PanelEchelonExpContent/GridEchelonExp") + self.BtnExit = self.Transform:Find("SafeAreaContentPane/BtnExit"):GetComponent("Button") + self.BtnClose = self.Transform:Find("SafeAreaContentPane/BtnClose"):GetComponent("Button") + self.PanelPlayer = self.Transform:Find("SafeAreaContentPane/PanelPlayer") + self.ImgExp = self.Transform:Find("SafeAreaContentPane/PanelPlayer/ImgExp"):GetComponent("Image") + self.TxtAddExp = self.Transform:Find("SafeAreaContentPane/PanelPlayer/TxtAddExp"):GetComponent("Text") + self.TxtLevelA = self.Transform:Find("SafeAreaContentPane/PanelPlayer/TxtLevel"):GetComponent("Text") + self.TxtLevelName = self.Transform:Find("SafeAreaContentPane/PanelPlayer/TxtLevelName"):GetComponent("Text") +end + +function XUiBfrtPostWarCount:GetAutoKey(uiNode, eventName) + if not uiNode then + return + end + return eventName .. uiNode:GetHashCode() +end + +function XUiBfrtPostWarCount:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then + return + end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiBfrtPostWarCount:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiBfrtPostWarCount:AutoAddListener() + self.AutoCreateListeners = {} + self:RegisterClickEvent(self.BtnExit, self.OnBtnExitClick) + self:RegisterClickEvent(self.BtnClose, self.OnBtnCloseClick) +end + +function XUiBfrtPostWarCount:OnBtnExitClick() + self:Close() +end + +function XUiBfrtPostWarCount:OnBtnCloseClick() + self:Close() +end + +function XUiBfrtPostWarCount:UpdatePanelRewardContent() + local rewards = XRewardManager.MergeAndSortRewardGoodsList(self.RewardGoodsList) + for _, item in ipairs(rewards) do + local ui = CS.UnityEngine.Object.Instantiate(self.GridReward) + local grid = XUiGridCommon.New(self, ui) + grid.Transform:SetParent(self.PanelRewardContent, false) + grid:Refresh(item, nil, nil, true) + grid.GameObject:SetActive(true) + end +end + +function XUiBfrtPostWarCount:UpdatePanelEchelonExpContent() + local data = { + GroupId = self.GroupId, + EchelonType = nil, + EchelonIndex = nil, + BaseStage = XDataCenter.BfrtManager.GetBaseStage(self.GroupId), + } + + local fightInfoIdList = XDataCenter.BfrtManager.GetFightInfoIdList(self.GroupId) + for index, _ in ipairs(fightInfoIdList) do + data.EchelonIndex = index + data.EchelonType = XDataCenter.BfrtManager.EchelonType.Fight + + local ui = CS.UnityEngine.Object.Instantiate(self.GridEchelonExp) + local grid = XUiGridEchelonExp.New(self, ui, data) + grid.Transform:SetParent(self.PanelEchelonExpContent, false) + grid.GameObject:SetActive(true) + end + + local lgoisticsInfoIdList = XDataCenter.BfrtManager.GetLogisticsInfoIdList(self.GroupId) + for index, _ in ipairs(lgoisticsInfoIdList) do + data.EchelonIndex = index + data.EchelonType = XDataCenter.BfrtManager.EchelonType.Logistics + + local ui = CS.UnityEngine.Object.Instantiate(self.GridEchelonExp) + local grid = XUiGridEchelonExp.New(self, ui, data) + grid.Transform:SetParent(self.PanelEchelonExpContent, false) + grid.GameObject:SetActive(true) + end +end + +function XUiBfrtPostWarCount:UpdatePanelPlayer() + local curLevel = XPlayer.GetLevelOrHonorLevel() + local curExp = XPlayer.Exp + local maxExp = XPlayer:GetMaxExp() + local baseStageId = XDataCenter.BfrtManager.GetBaseStage(self.GroupId) + local baseStageCfg = XDataCenter.FubenManager.GetStageCfg(baseStageId) + + if XPlayer.IsHonorLevelOpen() then + self.TxtLevelName.text = CS.XTextManager.GetText("HonorLevel") + end + self.TxtLevelA.text = curLevel + self.TxtAddExp.text = "+ " .. baseStageCfg.TeamExp + self.ImgExp.fillAmount = curExp / maxExp +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiBfrt/XUiBfrtQuickDeploy.lua b/Resources/Scripts/XUi/XUiBfrt/XUiBfrtQuickDeploy.lua new file mode 100644 index 00000000..7b8a5070 --- /dev/null +++ b/Resources/Scripts/XUi/XUiBfrt/XUiBfrtQuickDeploy.lua @@ -0,0 +1,182 @@ +local XUiGridQuickDeployTeam = require("XUi/XUiBfrt/XUiGridQuickDeployTeam") + +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate +local CSXTextManagerGetText = CS.XTextManager.GetText + +local XUiBfrtQuickDeploy = XLuaUiManager.Register(XLuaUi, "UiBfrtQuickDeploy") + +function XUiBfrtQuickDeploy:OnAwake() + self.GridQuickDeployTeam.gameObject:SetActiveEx(false) + self:AutoAddListener() +end + +function XUiBfrtQuickDeploy:OnStart(groupId, rootUi, saveCb) + self.GroupId = groupId + self.RootUi = rootUi + self.SaveCb = saveCb + self.StageIds = XDataCenter.BfrtManager.GetStageIdList(groupId) + self.FightInfoIdList = XDataCenter.BfrtManager.GetFightInfoIdList(groupId) + self.LogisticsInfoIdList = XDataCenter.BfrtManager.GetLogisticsInfoIdList(groupId) + self.TeamGridList = {} +end + +function XUiBfrtQuickDeploy:OnEnable() + self:UpdateView() +end + +function XUiBfrtQuickDeploy:OnDisable() + self.OldSelectCharacterId = nil + self.OldTeam = nil + self.OldPos = nil + + if self.LastSelectGrid then + self.LastSelectGrid:SetSelect(false) + self.LastSelectGrid = nil + end +end + +function XUiBfrtQuickDeploy:GetTeamCharacterType(team) + for _, characterId in pairs(team or {}) do + if characterId ~= 0 then + return XCharacterConfigs.GetCharacterType(characterId) + end + end +end + +function XUiBfrtQuickDeploy:UpdateView() + local fightTeamList = self.RootUi.FightTeamList + local logisticsTeamList = self.RootUi.LogisticsTeamList + local fightInfoIdList = self.FightInfoIdList + local logisticsInfoIdList = self.LogisticsInfoIdList + + local memberClickCb = function(characterId, grid, pos, team, characterLimitType) + local oldSelectCharacterId = self.OldSelectCharacterId + if oldSelectCharacterId then + if not (characterId == 0 and oldSelectCharacterId == 0) + and characterId ~= oldSelectCharacterId then + local swapFunc = function(isReset) + self:SwapTeamPos(self.OldTeam, self.OldPos, team, pos, isReset) + self:UpdateView() + + grid:ShowEffect() + self.LastSelectGrid:ShowEffect() + self.LastSelectGrid:SetSelect(false) + self.LastSelectGrid = nil + + self.OldSelectCharacterId = nil + self.OldTeam = nil + self.OldPos = nil + end + + local oldCharacterType = self:GetTeamCharacterType(self.OldTeam) + local newCharacterType = self:GetTeamCharacterType(team) + + --仅当副本限制类型为构造体/感染体强制要求时赋值 + local oldForceCharacterType = XDataCenter.FubenManager.GetForceCharacterTypeByCharacterLimitType(self.OldCharacterLimitType) + local newForceCharacterType = XDataCenter.FubenManager.GetForceCharacterTypeByCharacterLimitType(characterLimitType) + + --角色类型不符合副本限制类型 + if oldForceCharacterType and newCharacterType and oldForceCharacterType ~= newCharacterType + or newForceCharacterType and oldCharacterType and newForceCharacterType ~= oldCharacterType then + XUiManager.TipText("SwapCharacterTypeIsNotMatch") + return + end + + --角色类型不一致 + if newCharacterType and oldCharacterType and oldCharacterType ~= newCharacterType then + local content = CSXTextManagerGetText("SwapCharacterTypeIsDiffirent") + local sureCallBack = function() swapFunc(true) end + XUiManager.DialogTip(nil, content, XUiManager.DialogType.Normal, nil, sureCallBack) + return + end + + swapFunc() + return + end + end + + if self.LastSelectGrid then + self.LastSelectGrid:SetSelect(false) + end + self.LastSelectGrid = grid + self.LastSelectGrid:SetSelect(true) + self.LastSelectGrid:ShowEffect() + + self.OldSelectCharacterId = characterId + self.OldTeam = team + self.OldPos = pos + self.OldCharacterLimitType = characterLimitType + end + + local gridIndex = 1 + local teamGridList = self.TeamGridList + local stageIds = self.StageIds + for index, echelonId in pairs(fightInfoIdList) do + local teamGrid = teamGridList[gridIndex] + if not teamGrid then + local go = CSUnityEngineObjectInstantiate(self.GridQuickDeployTeam, self.PanelFormationTeamContent) + teamGrid = XUiGridQuickDeployTeam.New(go, memberClickCb) + teamGridList[gridIndex] = teamGrid + end + + local team = fightTeamList[index] + local characterLimitType = XFubenConfigs.GetStageCharacterLimitType(stageIds[index]) + teamGrid:Refresh(echelonId, team, index, XDataCenter.BfrtManager.EchelonType.Fight, characterLimitType) + teamGrid.GameObject:SetActiveEx(true) + + gridIndex = gridIndex + 1 + end + + for index, echelonId in pairs(logisticsInfoIdList) do + local teamGrid = teamGridList[gridIndex] + if not teamGrid then + local go = CSUnityEngineObjectInstantiate(self.GridQuickDeployTeam, self.PanelFormationTeamContent) + teamGrid = XUiGridQuickDeployTeam.New(go, memberClickCb) + teamGridList[gridIndex] = teamGrid + end + + local team = logisticsTeamList[index] + local characterLimitType = XFubenConfigs.GetStageCharacterLimitType(stageIds[index]) + teamGrid:Refresh(echelonId, team, index, XDataCenter.BfrtManager.EchelonType.Logistics, characterLimitType) + teamGrid.GameObject:SetActiveEx(true) + + gridIndex = gridIndex + 1 + end + + for i = gridIndex + 1, #teamGridList do + teamGridList[i].GameObject:SetActiveEx(false) + end +end + +function XUiBfrtQuickDeploy:AutoAddListener() + -- self.BtnClose.CallBack = function() self:Close() end + self.BtnConfirm.CallBack = function() self:OnClickBtnConfirm() end +end + +function XUiBfrtQuickDeploy:OnClickBtnConfirm() + self.SaveCb() + self:Close() +end + +function XUiBfrtQuickDeploy:SwapTeamPos(oldTeam, oldCharacterPos, newTeam, newCharacterPos, isReset) + local oldCharacterId = oldTeam[oldCharacterPos] + local newCharacterId = newTeam[newCharacterPos] + + if oldTeam and oldCharacterPos then + if isReset then + for k in pairs(oldTeam) do + oldTeam[k] = 0 + end + end + oldTeam[oldCharacterPos] = newCharacterId + end + + if newTeam and newCharacterPos then + if isReset then + for k in pairs(oldTeam) do + newTeam[k] = 0 + end + end + newTeam[newCharacterPos] = oldCharacterId + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiBfrt/XUiBfrtRoomCharacter.lua b/Resources/Scripts/XUi/XUiBfrt/XUiBfrtRoomCharacter.lua new file mode 100644 index 00000000..04ec56b6 --- /dev/null +++ b/Resources/Scripts/XUi/XUiBfrt/XUiBfrtRoomCharacter.lua @@ -0,0 +1,591 @@ +local XUiGridBfrtCharacter = require("XUi/XUiBfrt/XUiGridBfrtCharacter") + +local CSXTextManagerGetText = CS.XTextManager.GetText +local ANIMATION_OPEN = "AniBfrtRoomCharacterBegin" +local CONDITION_HEX_COLOR = { + [true] = "000000FF", + [false] = "BC0F23FF", +} +local TabBtnIndex = { + Normal = 1, + Isomer = 2, +} +local CharacterTypeConvert = { + [TabBtnIndex.Normal] = XCharacterConfigs.CharacterType.Normal, + [TabBtnIndex.Isomer] = XCharacterConfigs.CharacterType.Isomer, +} +local TabBtnIndexConvert = { + [XCharacterConfigs.CharacterType.Normal] = TabBtnIndex.Normal, + [XCharacterConfigs.CharacterType.Isomer] = TabBtnIndex.Isomer, +} + +local XUiBfrtRoomCharacter = XLuaUiManager.Register(XLuaUi, "UiBfrtRoomCharacter") + +function XUiBfrtRoomCharacter:OnAwake() + self:InitAutoScript() + self:InitComponentState() + + local root = self.UiModelGo.transform + self.PanelRoleModel = root:FindTransform("PanelRoleModel") + self.ImgEffectHuanren = root:FindTransform("ImgEffectHuanren") + self.ImgEffectHuanren1 = root:FindTransform("ImgEffectHuanren1") + self.RoleModelPanel = XUiPanelRoleModel.New(self.PanelRoleModel, self.Name, nil, true, nil, true) + + self.GridIndex = {} + self.TagCacheDic = {} + self.SortFunction = {} + self.SortFunction[XRoomCharFilterTipsConfigs.EnumSortTag.Default] = function(leftCharacter, rightCharacter) + local leftNotInTeam = not self:CheckCharacterInTeam(leftCharacter.Id) + local leftNotInTeamList = self.CheckIsInTeamListCb(leftCharacter.Id) == nil + local leftAbility = leftCharacter.Ability + local leftLevel = leftCharacter.Level + local leftQuality = leftCharacter.Quality + local leftPriority = XCharacterConfigs.GetCharacterPriority(leftCharacter.Id) + + local rightNotInTeam = not self:CheckCharacterInTeam(rightCharacter.Id) + local rightNotInTeamList = self.CheckIsInTeamListCb(rightCharacter.Id) == nil + local rightAbility = rightCharacter.Ability + local rightLevel = rightCharacter.Level + local rightQuality = rightCharacter.Quality + local rightPriority = XCharacterConfigs.GetCharacterPriority(rightCharacter.Id) + + if leftNotInTeam ~= rightNotInTeam then + return leftNotInTeam + end + + if leftNotInTeamList ~= rightNotInTeamList then + return leftNotInTeamList + end + + if leftAbility ~= rightAbility then + return leftAbility > rightAbility + end + + if leftLevel ~= rightLevel then + return leftLevel > rightLevel + end + + if leftQuality ~= rightQuality then + return leftQuality > rightQuality + end + + return leftPriority < rightPriority + end + self.SortFunction[XRoomCharFilterTipsConfigs.EnumSortTag.Quality] = function(leftCharacter, rightCharacter) + local leftQuality = leftCharacter.Quality + local rightQuality = rightCharacter.Quality + if leftQuality ~= rightQuality then + return leftQuality > rightQuality + end + return self.SortFunction[XRoomCharFilterTipsConfigs.EnumSortTag.Default](leftCharacter, rightCharacter) + end + self.SortFunction[XRoomCharFilterTipsConfigs.EnumSortTag.Level] = function(leftCharacter, rightCharacter) + local leftLevel = leftCharacter.Level + local rightLevel = rightCharacter.Level + if leftLevel ~= rightLevel then + return leftLevel > rightLevel + end + return self.SortFunction[XRoomCharFilterTipsConfigs.EnumSortTag.Default](leftCharacter, rightCharacter) + end + self.SortFunction[XRoomCharFilterTipsConfigs.EnumSortTag.Ability] = function(leftCharacter, rightCharacter) + local leftAbility = leftCharacter.Ability + local rightAbility = rightCharacter.Ability + if leftAbility ~= rightAbility then + return leftAbility > rightAbility + end + return self.SortFunction[XRoomCharFilterTipsConfigs.EnumSortTag.Default](leftCharacter, rightCharacter) + end + + self.CharacterGrids = {} +end + +function XUiBfrtRoomCharacter:OnStart(viewData) + self:UpdateViewData(viewData) + self:UpdateTxtRequireAbility() + self:PlayAnimation(ANIMATION_OPEN) +end + +function XUiBfrtRoomCharacter:OnEnable() + CS.XGraphicManager.UseUiLightDir = true + self:UpdateCurCharacterGrid() +end + +function XUiBfrtRoomCharacter:OnDisable() + CS.XGraphicManager.UseUiLightDir = false +end + +function XUiBfrtRoomCharacter:InitComponentState() + self.GridBfrtCharacter.gameObject:SetActiveEx(false) + self.BtnJoinTeam.gameObject:SetActiveEx(false) + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) +end + +function XUiBfrtRoomCharacter:UpdateViewData(viewData) + if not viewData.TeamCharacterIdList or not viewData.TeamSelectPos then + XLog.Error("XUiBfrtRoomCharacter:UpdateViewData error: TeamCharacterIdList or TeamSelectPos do not exist!") + return + end + + self.GroupId = viewData.BfrtGroupId + self.StageId = viewData.StageId + self.RequireAbility = viewData.RequireAbility + self.TeamCharacterIdList = viewData.TeamCharacterIdList + self.TeamSelectPos = viewData.TeamSelectPos + self.EchelonIndex = viewData.EchelonIndex + self.EchelonType = viewData.EchelonType + self.CheckIsInTeamListCb = viewData.CheckIsInTeamListCb + self.CharacterSwapEchelonCb = viewData.CharacterSwapEchelonCb + self.TeamResultCb = viewData.TeamResultCb + self.CharacterLimitType = XFubenConfigs.GetStageCharacterLimitType(self.StageId) + self.LimitBuffId = XFubenConfigs.GetStageCharacterLimitBuffId(self.StageId) + + self:InitRequireCharacterInfo() + self:InitCharacterTypeBtns() +end + +function XUiBfrtRoomCharacter:InitRequireCharacterInfo() + local characterLimitType = self.CharacterLimitType + + if not XFubenConfigs.IsStageCharacterLimitConfigExist(characterLimitType) then + self.PanelRequireCharacter.gameObject:SetActiveEx(false) + return + else + self.PanelRequireCharacter.gameObject:SetActiveEx(true) + end + + local icon = XFubenConfigs.GetStageCharacterLimitImageTeamEdit(characterLimitType) + self.ImgRequireCharacter:SetSprite(icon) +end + +function XUiBfrtRoomCharacter:ResetTeamData() + self.TeamCharacterIdList = { 0, 0, 0 } +end + +function XUiBfrtRoomCharacter:RefreshCharacterTypeTips() + local limitBuffId = self.LimitBuffId + local characterType = CharacterTypeConvert[self.SelectTabBtnIndex] + local characterLimitType = self.CharacterLimitType + local text = XFubenConfigs.GetStageCharacterLimitTextSelectCharacter(characterLimitType, characterType, limitBuffId) + self.TxtRequireCharacter.text = text +end + +function XUiBfrtRoomCharacter:InitCharacterTypeBtns() + self.BtnTabShougezhe.gameObject:SetActiveEx(not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.Isomer)) + + local tabBtns = { self.BtnTabGouzaoti, self.BtnTabShougezhe } + self.PanelCharacterTypeBtns:Init(tabBtns, function(index) self:TrySelectCharacterType(index) end) + + local characterLimitType = self.CharacterLimitType + local lockGouzaoti = characterLimitType == XFubenConfigs.CharacterLimitType.Isomer + local lockShougezhe = not XFunctionManager.JudgeOpen(XFunctionManager.FunctionName.Isomer) or characterLimitType == XFubenConfigs.CharacterLimitType.Normal + self.BtnTabGouzaoti:SetDisable(lockGouzaoti) + self.BtnTabShougezhe:SetDisable(lockShougezhe) + + --检查选择角色类型是否和副本限制类型冲突 + local characterType = XDataCenter.FubenManager.GetDefaultCharacterTypeByCharacterLimitType(self.CharacterLimitType) + local tempCharacterType = self:GetTeamCharacterType() + if tempCharacterType and not (tempCharacterType == XCharacterConfigs.CharacterType.Normal and lockGouzaoti + or tempCharacterType == XCharacterConfigs.CharacterType.Isomer and lockShougezhe) then + characterType = tempCharacterType + end + self.PanelCharacterTypeBtns:SelectIndex(TabBtnIndexConvert[characterType]) +end + +function XUiBfrtRoomCharacter:TrySelectCharacterType(index) + local characterType = CharacterTypeConvert[index] + if characterType == XCharacterConfigs.CharacterType.Isomer and not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.Isomer) then return end + + local characterLimitType = self.CharacterLimitType + if characterLimitType == XFubenConfigs.CharacterLimitType.Normal then + if characterType == XCharacterConfigs.CharacterType.Isomer then + XUiManager.TipText("TeamSelectCharacterTypeLimitTipNormal") + return + end + elseif characterLimitType == XFubenConfigs.CharacterLimitType.Isomer then + if characterType == XCharacterConfigs.CharacterType.Normal then + XUiManager.TipText("TeamSelectCharacterTypeLimitTipIsomer") + return + end + -- elseif characterLimitType == XFubenConfigs.CharacterLimitType.IsomerDebuff then + -- if characterType == XCharacterConfigs.CharacterType.Isomer then + -- local buffDes = XFubenConfigs.GetBuffDes(self.LimitBuffId) + -- local content = CSXTextManagerGetText("TeamSelectCharacterTypeLimitTipIsomerDebuff", buffDes) + -- local sureCallBack = function() + -- self:OnSelectCharacterType(index) + -- end + -- local closeCallback = function() + -- self.PanelCharacterTypeBtns:SelectIndex(TabBtnIndexConvert[XCharacterConfigs.CharacterType.Normal]) + -- end + -- XUiManager.DialogTip(nil, content, XUiManager.DialogType.Normal, closeCallback, sureCallBack) + -- return + -- end + -- elseif characterLimitType == XFubenConfigs.CharacterLimitType.NormalDebuff then + -- if characterType == XCharacterConfigs.CharacterType.Normal then + -- local buffDes = XFubenConfigs.GetBuffDes(self.LimitBuffId) + -- local content = CSXTextManagerGetText("TeamSelectCharacterTypeLimitTipNormalDebuff", buffDes) + -- local sureCallBack = function() + -- self:OnSelectCharacterType(index) + -- end + -- local closeCallback = function() + -- self.PanelCharacterTypeBtns:SelectIndex(TabBtnIndexConvert[XCharacterConfigs.CharacterType.Isomer]) + -- end + -- XUiManager.DialogTip(nil, content, XUiManager.DialogType.Normal, closeCallback, sureCallBack) + -- return + -- end + end + + self:OnSelectCharacterType(index) +end + +function XUiBfrtRoomCharacter:OnSelectCharacterType(index) + if self.SelectTabBtnIndex == index then return end + self.SelectTabBtnIndex = index + + XDataCenter.RoomCharFilterTipsManager.Reset() + + local characterType = CharacterTypeConvert[index] + local charlist = XDataCenter.CharacterManager.GetOwnCharacterList(characterType) + table.sort(charlist,self.SortFunction[XRoomCharFilterTipsConfigs.EnumSortTag.Default]) + + self:RefreshCharacterTypeTips() + self:UpdateCharacterList(charlist) +end + +function XUiBfrtRoomCharacter:UpdateCharacterList(charlist) + if not next(charlist) then + self:SetPanelEmptyList(true) + return + end + self:SetPanelEmptyList(false) + + for _, item in pairs(self.CharacterGrids) do + item.GameObject:SetActiveEx(false) + end + + local charDic = {} + + for i = 1, #charlist do + local character = charlist[i] + local characterId = character.Id + charDic[characterId] = character + + local grid = self.CharacterGrids[characterId] + if not grid then + local item = CS.UnityEngine.Object.Instantiate(self.GridBfrtCharacter) + grid = XUiGridBfrtCharacter.New(self, item, character) + grid.Transform:SetParent(self.PanelRoleContent, false) + self.GridIndex[i] = grid + else + self.GridIndex[i]:Refresh(character) + end + self.CharacterGrids[characterId] = self.GridIndex[i] + self.CharacterGrids[characterId]:SetInTeam(self.CheckIsInTeamListCb(characterId)) + end + + local characterType = CharacterTypeConvert[self.SelectTabBtnIndex] + local teamCharIdMap = self.TeamCharacterIdList + local teamSelectPos = self.TeamSelectPos + local selectId = teamCharIdMap[teamSelectPos] + if not selectId or selectId == 0 + or not self.CharacterGrids[selectId] + or characterType ~= XCharacterConfigs.GetCharacterType(selectId) + or not charDic[selectId] + then + selectId = charlist[1].Id + end + self:OnSelectCharacter(selectId) +end + +function XUiBfrtRoomCharacter:SetPanelEmptyList(isEmpty) + self.BtnQuitTeam.gameObject:SetActiveEx(false) + self.BtnJoinTeam.gameObject:SetActiveEx(false) + + self.BtnConsciousness.gameObject:SetActiveEx(not isEmpty) + self.BtnFashion.gameObject:SetActiveEx(not isEmpty) + self.BtnWeapon.gameObject:SetActiveEx(not isEmpty) + self.BtnPartner.gameObject:SetActiveEx(not isEmpty) + + self.PanelRoleModel.gameObject:SetActiveEx(not isEmpty) + self.PanelRoleContent.gameObject:SetActiveEx(not isEmpty) + self.PanelEmptyList.gameObject:SetActiveEx(isEmpty) +end + +function XUiBfrtRoomCharacter:CenterToGrid(grid) + -- local normalizedPosition + -- local count = self.SViewCharacterList.content.transform.childCount + -- local index = grid.Transform:GetSiblingIndex() + -- if index > count / 2 then + -- normalizedPosition = (index + 1) / count + -- else + -- normalizedPosition = (index - 1) / count + -- end + -- self.SViewCharacterList.verticalNormalizedPosition = math.max(0, math.min(1, (1 - normalizedPosition))) +end + +function XUiBfrtRoomCharacter:OnSelectCharacter(selectId) + if not selectId then + return + end + + self.CurCharacterId = selectId + + if self.CurCharacterGrid then + self.CurCharacterGrid:SetSelect(false) + end + + self.CurCharacterGrid = self.CharacterGrids[self.CurCharacterId] + self.CurCharacterGrid:SetSelect(true) + self:CenterToGrid(self.CurCharacterGrid) + self:UpdateCurCharacterGrid() +end + +function XUiBfrtRoomCharacter:UpdateCurCharacterGrid() + local character = XDataCenter.CharacterManager.GetCharacter(self.CurCharacterId) + self.CurCharacterGrid:Refresh(character) + self:UpdateTeamBtn() + self:UpdateTxtRequireAbilityColor() + self:UpdateRoleModel() +end + +function XUiBfrtRoomCharacter:UpdateTeamBtn() + if not (self.TeamCharacterIdList and next(self.TeamCharacterIdList)) then + return + end + + local isInTeam = self:CheckCharacterInTeam(self.CurCharacterId) + self.BtnQuitTeam.gameObject:SetActiveEx(isInTeam) + self.BtnJoinTeam.gameObject:SetActiveEx(not isInTeam) +end + +function XUiBfrtRoomCharacter:UpdateTxtRequireAbility() + self.TxtRequireAbility.text = self.RequireAbility + self.TxtEchelonName.text = XDataCenter.BfrtManager.GetEchelonNameTxt(self.EchelonType, self.EchelonIndex) +end + +function XUiBfrtRoomCharacter:UpdateTxtRequireAbilityColor() + local curCharacter = XDataCenter.CharacterManager.GetCharacter(self.CurCharacterId) + local passed = curCharacter and curCharacter.Ability >= self.RequireAbility or false + self.TxtRequireAbility.color = XUiHelper.Hexcolor2Color(CONDITION_HEX_COLOR[passed]) +end + +function XUiBfrtRoomCharacter:UpdateRoleModel() + local characterId = self.CurCharacterId + if not characterId then return end + local targetPanelRole = self.PanelRoleModel + local targetUiName = self.Name + local charaterFunc = function(model) + if not model then + return + end + self.PanelDrag.Target = model.transform + if self.SelectTabBtnIndex == TabBtnIndex.Normal then + self.ImgEffectHuanren.gameObject:SetActiveEx(true) + elseif self.SelectTabBtnIndex == TabBtnIndex.Isomer then + self.ImgEffectHuanren1.gameObject:SetActiveEx(true) + end + end + + self.ImgEffectHuanren.gameObject:SetActiveEx(false) + self.ImgEffectHuanren1.gameObject:SetActiveEx(false) + self.RoleModelPanel:UpdateCharacterModel(self.CurCharacterId, targetPanelRole, targetUiName, charaterFunc) +end + +function XUiBfrtRoomCharacter:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiBfrtRoomCharacter:AutoInitUi() + self.BtnFashion = self.Transform:Find("SafeAreaContentPane/CharList/TeamBtn/BtnFashion"):GetComponent("Button") + self.BtnConsciousness = self.Transform:Find("SafeAreaContentPane/CharList/TeamBtn/BtnConsciousness"):GetComponent("Button") + self.BtnJoinTeam = self.Transform:Find("SafeAreaContentPane/CharList/TeamBtn/BtnJoinTeam"):GetComponent("Button") + self.BtnQuitTeam = self.Transform:Find("SafeAreaContentPane/CharList/TeamBtn/BtnQuitTeam"):GetComponent("Button") + self.SViewCharacterList = self.Transform:Find("SafeAreaContentPane/CharList/CharInfo/Left/SViewCharacterList"):GetComponent("ScrollRect") + self.PanelRoleContent = self.Transform:Find("SafeAreaContentPane/CharList/CharInfo/Left/SViewCharacterList/Viewport/PanelRoleContent") + self.GridBfrtCharacter = self.Transform:Find("SafeAreaContentPane/CharList/CharInfo/Left/SViewCharacterList/Viewport/PanelRoleContent/GridBfrtCharacter") + self.PanelDrag = self.Transform:Find("SafeAreaContentPane/CharList/CharInfo/PanelDrag"):GetComponent("XDrag") + self.PanelAsset = self.Transform:Find("SafeAreaContentPane/PanelAsset") + self.BtnBack = self.Transform:Find("SafeAreaContentPane/Top/BtnBack"):GetComponent("Button") + self.BtnMainUi = self.Transform:Find("SafeAreaContentPane/Top/BtnMainUi"):GetComponent("Button") + self.BtnWeapon = self.Transform:Find("SafeAreaContentPane/CharList/TeamBtn/BtnWeapon"):GetComponent("Button") +end + +function XUiBfrtRoomCharacter:AutoAddListener() + self:RegisterClickEvent(self.BtnFashion, self.OnBtnFashionClick) + self:RegisterClickEvent(self.BtnConsciousness, self.OnBtnConsciousnessClick) + self:RegisterClickEvent(self.BtnJoinTeam, self.OnBtnJoinTeamClick) + self:RegisterClickEvent(self.BtnQuitTeam, self.OnBtnQuitTeamClick) + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:RegisterClickEvent(self.BtnWeapon, self.OnBtnWeaponClick) + self.BtnPartner.CallBack = function() + self:OnBtnPartnerClick() + end + self.BtnFilter.CallBack = function() + self:OnBtnFilterClick() + end +end + +function XUiBfrtRoomCharacter:OnBtnConsciousnessClick() + XLuaUiManager.Open("UiEquipAwarenessReplace", self.CurCharacterId, nil, true) +end + +function XUiBfrtRoomCharacter:OnBtnWeaponClick() + XLuaUiManager.Open("UiEquipReplaceNew", self.CurCharacterId, nil, true) +end + +function XUiBfrtRoomCharacter:OnBtnFashionClick() + XLuaUiManager.Open("UiFashion", self.CurCharacterId) +end + +function XUiBfrtRoomCharacter:OnBtnJoinTeamClick() + local selectId = self.CurCharacterId + + local joinFunc = function(isReset) + local echelonIndex, echelonType = self.CheckIsInTeamListCb(selectId) + if echelonIndex and echelonType then + local title = CS.XTextManager.GetText("BfrtDeployTipTitle") + local characterName = XCharacterConfigs.GetCharacterName(selectId) + local oldEchelon = XDataCenter.BfrtManager.GetEchelonNameTxt(echelonType, echelonIndex) + local newEchelon = XDataCenter.BfrtManager.GetEchelonNameTxt(self.EchelonType, self.EchelonIndex) + local content = CS.XTextManager.GetText("BfrtDeployTipContent", characterName, oldEchelon, newEchelon) + + XUiManager.DialogTip(title, content, XUiManager.DialogType.Normal, nil, function() + if isReset then + self:ResetTeamData() + end + + self.CharacterSwapEchelonCb(selectId, self.TeamCharacterIdList[self.TeamSelectPos]) + self.TeamCharacterIdList[self.TeamSelectPos] = selectId + self:Close() + end) + else + if isReset then + self:ResetTeamData() + end + + self:QuitTeam(selectId) + self.TeamCharacterIdList[self.TeamSelectPos] = selectId + self:Close() + end + end + + -- 角色类型不一致拦截 + local inTeamCharacterType = self:GetTeamCharacterType() + if inTeamCharacterType then + local characterType = selectId and selectId ~= 0 and XCharacterConfigs.GetCharacterType(selectId) + if characterType and characterType ~= inTeamCharacterType then + local content = CSXTextManagerGetText("TeamCharacterTypeNotSame") + local sureCallBack = function() + local isReset = true + joinFunc(isReset) + end + XUiManager.DialogTip(nil, content, XUiManager.DialogType.Normal, nil, sureCallBack) + return + end + end + + joinFunc() +end + +function XUiBfrtRoomCharacter:OnBtnQuitTeamClick() + self:QuitTeam(self.CurCharacterId) + self:Close() +end + +function XUiBfrtRoomCharacter:OnBtnBackClick() + self:Close() +end + +function XUiBfrtRoomCharacter:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiBfrtRoomCharacter:OnBtnFilterClick() + local characterType = CharacterTypeConvert[self.SelectTabBtnIndex] + XLuaUiManager.Open("UiRoomCharacterFilterTips", + self, + XRoomCharFilterTipsConfigs.EnumFilterType.Bfrt, + XRoomCharFilterTipsConfigs.EnumSortType.Bfrt, + characterType) +end + +function XUiBfrtRoomCharacter:OnBtnPartnerClick() + XDataCenter.PartnerManager.GoPartnerCarry(self.CurCharacterId, false) +end + +function XUiBfrtRoomCharacter:QuitTeam(characterId) + for index, existCharacterId in pairs(self.TeamCharacterIdList) do + if characterId == existCharacterId then + self.TeamCharacterIdList[index] = 0 + return + end + end +end + +function XUiBfrtRoomCharacter:Close() + if self.TeamResultCb then + self.TeamResultCb(self.TeamCharacterIdList) + end + + XUiBfrtRoomCharacter.Super.Close(self) +end + +function XUiBfrtRoomCharacter:CheckCharacterInTeam(checkCharacterId) + for _, characterId in pairs(self.TeamCharacterIdList) do + if checkCharacterId == characterId then + return true + end + end + return false +end + +function XUiBfrtRoomCharacter:GetTeamCharacterType() + for k, v in pairs(self.TeamCharacterIdList) do + if v ~= 0 then + return XCharacterConfigs.GetCharacterType(v) + end + end +end + +function XUiBfrtRoomCharacter:Filter(selectTagGroupDic, sortTagId, isThereFilterDataCb) + local judgeCb = function(groupId, tagValue, character) + local detailConfig = XCharacterConfigs.GetCharDetailTemplate(character.Id) + local compareValue + if groupId == XRoomCharFilterTipsConfigs.EnumFilterTagGroup.Career then + compareValue = detailConfig.Career + if compareValue == tagValue then + -- 当前角色满足该标签 + return true + end + elseif groupId == XRoomCharFilterTipsConfigs.EnumFilterTagGroup.Element then + compareValue = detailConfig.ObtainElementList + for _, element in pairs(compareValue) do + if element == tagValue then + -- 当前角色满足该标签 + return true + end + end + else + XLog.Error(string.format("XUiBfrtRoomCharacter:Filter函数错误,没有处理排序组:%s的逻辑", groupId)) + return false + end + end + + local allChar = XDataCenter.CharacterManager.GetOwnCharacterList(CharacterTypeConvert[self.SelectTabBtnIndex]) + XDataCenter.RoomCharFilterTipsManager.Filter(self.TagCacheDic, selectTagGroupDic, allChar, judgeCb, + function(filteredData) + self:FilterRefresh(filteredData, sortTagId) + end, + isThereFilterDataCb) +end + +function XUiBfrtRoomCharacter:FilterRefresh(filteredData, sortTagId) + if self.SortFunction[sortTagId] then + table.sort(filteredData, self.SortFunction[sortTagId]) + else + XLog.Error(string.format("XUiBfrtRoomCharacter:FilterRefresh函数错误,没有定义标签:%s的排序函数", sortTagId)) + return + end + self:UpdateCharacterList(filteredData) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiBfrt/XUiBfrtStageDetail.lua b/Resources/Scripts/XUi/XUiBfrt/XUiBfrtStageDetail.lua new file mode 100644 index 00000000..e3e61182 --- /dev/null +++ b/Resources/Scripts/XUi/XUiBfrt/XUiBfrtStageDetail.lua @@ -0,0 +1,236 @@ +local XUiBfrtStageDetail = XLuaUiManager.Register(XLuaUi, "UiBfrtStageDetail") + +local MAX_STAR = 3 +local ANIMATION_OPEN = "UiBfrtStageDetailBegin" +local ANIMATION_END = "UiBfrtStageDetailEnd" + +function XUiBfrtStageDetail:OnAwake() + self:InitAutoScript() + + self.GridCommon.gameObject:SetActive(false) + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) +end + +function XUiBfrtStageDetail:OnStart(fubenMainLineChapter) + self.FubenMainLineChapter = fubenMainLineChapter + self.GridList = {} +end + +function XUiBfrtStageDetail:OnEnable() + self:Refresh() + + -- 动画 + self.IsPlaying = true + XUiHelper.StopAnimation() + + self:PlayAnimation(ANIMATION_OPEN, handler(self, function() + self.IsPlaying = false + end)) + + self.IsOpen = true +end + +function XUiBfrtStageDetail:OnDisable() + self.IsOpen = false +end + +function XUiBfrtStageDetail:Refresh() + self.ChapterOrderId = self.FubenMainLineChapter.ChapterOrderId + self.Stage = self.FubenMainLineChapter.Stage + self.BaseStageId = self.Stage.StageId + self.StageInfo = XDataCenter.FubenManager.GetStageInfo(self.BaseStageId) + self.IsPassed = XDataCenter.FubenManager.CheckStageIsPass(self.BaseStageId) + self:UpdatePanelTargetList() + self:UpdateRewards() + self:UpdateDetailText() + self:UpdateDifficulty() + self:UpdateStageFightControl() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiBfrtStageDetail:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiBfrtStageDetail:AutoInitUi() + self.Panellist = self.Transform:Find("SafeAreaContentPane/Panellist") + self.PanelDropList = self.Transform:Find("SafeAreaContentPane/Panellist/PanelDropList") + self.PanelDrop = self.Transform:Find("SafeAreaContentPane/Panellist/PanelDropList/PanelDrop") + self.TxtDrop = self.Transform:Find("SafeAreaContentPane/Panellist/PanelDropList/PanelDrop/TxtDrop"):GetComponent("Text") + self.TxtDropEn = self.Transform:Find("SafeAreaContentPane/Panellist/PanelDropList/PanelDrop/TxtDropEn"):GetComponent("Text") + self.TxtFirstDrop = self.Transform:Find("SafeAreaContentPane/Panellist/PanelDropList/PanelDrop/TxtFirstDrop"):GetComponent("Text") + self.PanelDropContent = self.Transform:Find("SafeAreaContentPane/Panellist/PanelDropList/DropList/Viewport/PanelDropContent") + self.GridCommon = self.Transform:Find("SafeAreaContentPane/Panellist/PanelDropList/DropList/Viewport/PanelDropContent/GridCommon") + self.PanelNoLimitCount = self.Transform:Find("SafeAreaContentPane/Panellist/PanelNoLimitCount") + self.PanelNums = self.Transform:Find("SafeAreaContentPane/Panellist/PanelNums") + self.TxtAllNums = self.Transform:Find("SafeAreaContentPane/Panellist/PanelNums/TxtAllNums"):GetComponent("Text") + self.TxtLeftNums = self.Transform:Find("SafeAreaContentPane/Panellist/PanelNums/TxtLeftNums"):GetComponent("Text") + self.BtnAddNum = self.Transform:Find("SafeAreaContentPane/Panellist/PanelNums/BtnAddNum"):GetComponent("Button") + self.PanelBottom = self.Transform:Find("SafeAreaContentPane/Panellist/PanelBottom") + self.TxtATNums = self.Transform:Find("SafeAreaContentPane/Panellist/PanelBottom/TxtATNums"):GetComponent("Text") + self.BtnEnter = self.Transform:Find("SafeAreaContentPane/Panellist/PanelBottom/BtnEnter"):GetComponent("Button") + self.PanelDesc = self.Transform:Find("SafeAreaContentPane/Panellist/PanelDesc") + self.TxtTitle = self.Transform:Find("SafeAreaContentPane/Panellist/PanelDesc/TxtTitle"):GetComponent("Text") + self.TxtLevelVal = self.Transform:Find("SafeAreaContentPane/Panellist/PanelDesc/TxtLevelVal"):GetComponent("Text") + self.RImgNandu = self.Transform:Find("SafeAreaContentPane/Panellist/PanelDesc/RImgNandu"):GetComponent("RawImage") + self.TxtDesc = self.Transform:Find("SafeAreaContentPane/Panellist/PanelDesc/TxtDesc"):GetComponent("Text") + self.PanelTargetList = self.Transform:Find("SafeAreaContentPane/Panellist/PanelTargetList") + self.GridStar1 = self.Transform:Find("SafeAreaContentPane/Panellist/PanelTargetList/GridStar1") + self.TxtStarActive1 = self.Transform:Find("SafeAreaContentPane/Panellist/PanelTargetList/GridStar1/TxtStarActive1"):GetComponent("Text") + self.GridStar2 = self.Transform:Find("SafeAreaContentPane/Panellist/PanelTargetList/GridStar2") + self.TxtStarActive2 = self.Transform:Find("SafeAreaContentPane/Panellist/PanelTargetList/GridStar2/TxtStarActive2"):GetComponent("Text") + self.GridStar3 = self.Transform:Find("SafeAreaContentPane/Panellist/PanelTargetList/GridStar3") + self.TxtStarActive3 = self.Transform:Find("SafeAreaContentPane/Panellist/PanelTargetList/GridStar3/TxtStarActive3"):GetComponent("Text") + self.PanelAsset = self.Transform:Find("SafeAreaContentPane/PanelAsset") +end + +function XUiBfrtStageDetail:AutoAddListener() + self:RegisterClickEvent(self.BtnAddNum, self.OnBtnAddNumClick) + self:RegisterClickEvent(self.BtnEnter, self.OnBtnEnterClick) +end +-- auto +--初始化音效 +function XUiBfrtStageDetail:OnBtnAddNumClick() + local challengeData = XDataCenter.FubenMainLineManager.GetStageBuyChallengeData(self.BaseStageId) + local func = function() + self:UpdateDetailText() + end + XLuaUiManager.Open("UiBuyAsset", 1, func, challengeData) +end + +function XUiBfrtStageDetail:OnBtnEnterClick() + if self.IsPlaying then + return + end + + if self.BaseStageId == nil then + XLog.Error("OnBtnEnterClick: Can not find baseStageId!") + return + end + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_FUBEN_ENTERFIGHT, self.Stage) +end + +function XUiBfrtStageDetail:UpdatePanelTargetList() + for i = 1, MAX_STAR do + self["TxtStarActive" .. i].text = self.Stage.StarDesc[i] + end +end + +function XUiBfrtStageDetail:UpdateRewards() + local rewardId + local IsFirst = false + local cfg = XDataCenter.FubenManager.GetStageLevelControl(self.BaseStageId) + if self.IsPassed then + rewardId = cfg and cfg.FinishRewardShow or self.Stage.FinishRewardShow + else + rewardId = cfg and cfg.FirstRewardShow or self.Stage.FirstRewardShow + IsFirst = true + end + + if rewardId == 0 then + for j = 1, #self.GridList do + self.GridList[j].GameObject:SetActive(false) + end + return + end + + local rewards = IsFirst and XRewardManager.GetRewardList(rewardId) or XRewardManager.GetRewardListNotCount(rewardId) + if rewards then + for i, item in ipairs(rewards) do + local grid + if self.GridList[i] then + grid = self.GridList[i] + else + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommon) + grid = XUiGridCommon.New(self, ui) + grid.Transform:SetParent(self.PanelDropContent, false) + self.GridList[i] = grid + end + grid:Refresh(item) + grid.GameObject:SetActive(true) + end + end + + local rewardsCount = 0 + if rewards then + rewardsCount = #rewards + end + + for j = 1, #self.GridList do + if j > rewardsCount then + self.GridList[j].GameObject:SetActive(false) + end + end +end + +function XUiBfrtStageDetail:UpdateDetailText() + local id = "" + if self.ChapterOrderId then + id = self.ChapterOrderId .. "-" .. XDataCenter.BfrtManager.GetGroupOrderIdByStageId(self.BaseStageId) + end + + self.TxtTitle.text = id .. self.Stage.Name + self.TxtLevelVal.text = self.Stage.RecommandLevel + self.TxtDesc.text = self.Stage.Description + self.TxtATNums.text = self.Stage.RequireActionPoint + + local chanllengeNum = XDataCenter.BfrtManager.GetGroupFinishCount(self.BaseStageId) + local maxChallengeNum = XDataCenter.BfrtManager.GetGroupMaxChallengeNum(self.BaseStageId) + local buyChallengeCount = XDataCenter.FubenManager.GetStageBuyChallengeCount(self.BaseStageId) + + self.PanelNums.gameObject:SetActive(maxChallengeNum > 0) + self.PanelNoLimitCount.gameObject:SetActive(maxChallengeNum <= 0) + self.BtnAddNum.gameObject:SetActive(buyChallengeCount > 0) + + if maxChallengeNum > 0 then + self.TxtAllNums.text = "/" .. maxChallengeNum + self.TxtLeftNums.text = maxChallengeNum - chanllengeNum + end + + self.TxtFirstDrop.gameObject:SetActive(not self.IsPassed) + self.TxtDrop.gameObject:SetActive(self.IsPassed) +end + +function XUiBfrtStageDetail:UpdateDifficulty() + local nanDuIcon = XDataCenter.FubenManager.GetDifficultIcon(self.BaseStageId) + self.RImgNandu:SetRawImage(nanDuIcon) +end + +function XUiBfrtStageDetail:UpdateStageFightControl() + --暂时屏蔽,后面可能要加回来 + if true then + self.PanelStageFightControl.gameObject:SetActive(false) + return + end + + -- local stageInfo = self.StageInfo + -- self.StageFightControl = self.StageFightControl or XUiStageFightControl.New(self.PanelStageFightControl, self.Stage.FightControlId) + -- if not self.IsPassed and stageInfo.Unlock then + -- self.StageFightControl.GameObject:SetActive(true) + -- self.StageFightControl:UpdateInfo(self.Stage.FightControlId) + -- else + -- self.StageFightControl.GameObject:SetActive(false) + -- end +end + +function XUiBfrtStageDetail:Hide() + if self.IsPlaying or not self.IsOpen then + return + end + + self.IsPlaying = true + XUiHelper.StopAnimation() + + self:PlayAnimation(ANIMATION_END, handler(self, function() + if XTool.UObjIsNil(self.GameObject) then + return + end + self.IsPlaying = false + self:Close() + end)) + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_FUBEN_CLOSE_FUBENSTAGEDETAIL) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiBfrt/XUiGridBfrtCharacter.lua b/Resources/Scripts/XUi/XUiBfrt/XUiGridBfrtCharacter.lua new file mode 100644 index 00000000..849e79bb --- /dev/null +++ b/Resources/Scripts/XUi/XUiBfrt/XUiGridBfrtCharacter.lua @@ -0,0 +1,121 @@ +local XUiGridBfrtCharacter = XClass(nil, "XUiGridBfrtCharacter") + +function XUiGridBfrtCharacter:Ctor(rootUi, ui, character) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + self:InitAutoScript() + XTool.InitUiObject(self) + self:InitComponentState() + self:Refresh(character) +end + +function XUiGridBfrtCharacter:InitComponentState() + self.PanelTeam.gameObject:SetActiveEx(false) + self.PanelSelected.gameObject:SetActiveEx(false) +end + +function XUiGridBfrtCharacter:Refresh(character) + self:UpdateViewData(character) + self:UpdateGameObject() + self:UpdateCharacterInfo() +end + +function XUiGridBfrtCharacter:UpdateViewData(character) + self.Character = character +end + +function XUiGridBfrtCharacter:UpdateGameObject() + self.GameObject.name = self.Character.Id + self.GameObject:SetActiveEx(true) +end + +function XUiGridBfrtCharacter:UpdateCharacterInfo() + self.TxtFight.text = math.floor(self.Character.Ability) + self.TxtLevel.text = self.Character.Level + self.RImgHeadIcon:SetRawImage(XDataCenter.CharacterManager.GetCharSmallHeadIcon(self.Character.Id)) + self.RImgQuality:SetRawImage(XCharacterConfigs.GetCharacterQualityIcon(self.Character.Quality)) + + if self.PanelCharElement then + local detailConfig = XCharacterConfigs.GetCharDetailTemplate(self.Character.Id) + local elementList = detailConfig.ObtainElementList + for i = 1, 3 do + local rImg = self["RImgCharElement" .. i] + if elementList[i] then + rImg.gameObject:SetActiveEx(true) + local elementConfig = XCharacterConfigs.GetCharElement(elementList[i]) + rImg:SetRawImage(elementConfig.Icon) + else + rImg.gameObject:SetActiveEx(false) + end + end + end +end + +function XUiGridBfrtCharacter:SetInTeam(inEchelonIndex, inEchelonType) + if inEchelonIndex then + if inEchelonType == XDataCenter.BfrtManager.EchelonType.Fight then + self.TxtEchelonIndex.text = CS.XTextManager.GetText("BfrtFightEchelonTitleSimple", inEchelonIndex) + self.PanelTeam.gameObject:SetActiveEx(true) + self.PanelTeamSupport.gameObject:SetActiveEx(false) + elseif inEchelonType == XDataCenter.BfrtManager.EchelonType.Logistics then + self.TxtEchelonIndexA.text = CS.XTextManager.GetText("BfrtLogisticEchelonTitleSimple", inEchelonIndex) + self.PanelTeamSupport.gameObject:SetActiveEx(true) + self.PanelTeam.gameObject:SetActiveEx(false) + end + else + self.PanelTeam.gameObject:SetActiveEx(false) + self.PanelTeamSupport.gameObject:SetActiveEx(false) + end +end + +function XUiGridBfrtCharacter:SetSelect(isSelect) + self.PanelSelected.gameObject:SetActiveEx(isSelect) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiGridBfrtCharacter:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiGridBfrtCharacter:AutoInitUi() + self.PanelSelected = self.Transform:Find("PanelSelected") + self.TxtFight = self.Transform:Find("PaneFight/TxtFight"):GetComponent("Text") + self.TxtLevel = self.Transform:Find("PaneLevel/TxtLevel"):GetComponent("Text") + self.RImgQuality = self.Transform:Find("RImgQuality"):GetComponent("RawImage") + self.RImgHeadIcon = self.Transform:Find("PaneHead/RImgHeadIcon"):GetComponent("RawImage") + self.BtnCharacter = self.Transform:Find("BtnCharacter"):GetComponent("Button") + self.PanelTeam = self.Transform:Find("PanelTeam") + self.TxtEchelonIndex = self.Transform:Find("PanelTeam/TxtEchelonIndex"):GetComponent("Text") + self.PanelTeamSupport = self.Transform:Find("PanelTeamSupport") + self.TxtEchelonIndexA = self.Transform:Find("PanelTeamSupport/TxtEchelonIndex"):GetComponent("Text") +end + +function XUiGridBfrtCharacter:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiGridBfrtCharacter:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiGridBfrtCharacter:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiGridBfrtCharacter:AutoAddListener() + self:RegisterClickEvent(self.BtnCharacter, self.OnBtnCharacterClick) +end +-- auto +function XUiGridBfrtCharacter:OnBtnCharacterClick() + self.RootUi:OnSelectCharacter(self.Character.Id) +end + +return XUiGridBfrtCharacter \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiBfrt/XUiGridEchelon.lua b/Resources/Scripts/XUi/XUiBfrt/XUiGridEchelon.lua new file mode 100644 index 00000000..f09e1747 --- /dev/null +++ b/Resources/Scripts/XUi/XUiBfrt/XUiGridEchelon.lua @@ -0,0 +1,219 @@ +local CONDITION_COLOR = { + [true] = CS.UnityEngine.Color.black, + [false] = CS.UnityEngine.Color.red, +} +local MAX_ECHELON_MEMBER_COUNT = 3 --梯队最大成员数量 +local XUiGridEchelonMember = require("XUi/XUiBfrt/XUiGridEchelonMember") +local XUiGridEchelon = XClass(nil, "XUiGridEchelon") + +function XUiGridEchelon:Ctor(rootUi, ui, data) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + self:InitAutoScript() + self:ResetEchelonInfo() + self:UpdateEchelonInfo(data) +end + +function XUiGridEchelon:ResetEchelonInfo() + self.EchelonType = nil + self.EchelonId = nil + self.EchelonIndex = nil + self.BaseStage = nil + self.EchelonRequireCharacterNum = nil + self.GirdEchelonMemberList = {} + self.TeamList = {} + self.CharacterIdListWrap = {} + + self.GridEchelonMember.gameObject:SetActiveEx(false) + self.TxtDoNotNeedFight.gameObject:SetActiveEx(false) + self.PanelTitleBgFight.gameObject:SetActiveEx(false) + self.PanelTitleBgLogistic.gameObject:SetActiveEx(false) + self.PanelLogisticSkill.gameObject:SetActiveEx(false) + self.PanelLeaderSkill.gameObject:SetActiveEx(false) + self.TxtLeaderSkill.gameObject:SetActiveEx(false) +end + +function XUiGridEchelon:UpdateEchelonInfo(data) + self.GroupId = data.BfrtGroupId + self.EchelonType = data.EchelonType + self.EchelonId = data.EchelonId + self.EchelonIndex = data.EchelonIndex + self.BaseStage = data.BaseStage + self.EchelonRequireCharacterNum = XDataCenter.BfrtManager.GetEchelonNeedCharacterNum(self.EchelonId) + self.ConditionId = XDataCenter.BfrtManager.GetEchelonConditionId(self.EchelonId) + + self.TeamList = data.TeamList + self.CharacterIdListWrap = data.CharacterIdListWrap + + self:UpdateTitle() + self:UpdateTxtExtraCondition() + self:UpdateTxtLeaderSkill() + self:UpdatePanelEchelonMembers() + self:UpdateEchelonConditionState() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiGridEchelon:InitAutoScript() + self:AutoInitUi() +end + +function XUiGridEchelon:AutoInitUi() + self.PanelLeaderSkill = self.Transform:Find("PanelLeaderSkill") + self.TxtLeaderSkill = self.Transform:Find("PanelLeaderSkill/TxtLeaderSkill"):GetComponent("Text") + self.PanelRequire = self.Transform:Find("PanelRequire") + self.TxtExtraCondition = self.Transform:Find("PanelRequire/TxtExtraCondition"):GetComponent("Text") + self.PanelTitleBgLogistic = self.Transform:Find("PanelTitleBgLogistic") + self.TxtTitleA = self.Transform:Find("PanelTitleBgLogistic/TxtTitle"):GetComponent("Text") + self.PanelTitleBgFight = self.Transform:Find("PanelTitleBgFight") + self.TxtTitle = self.Transform:Find("PanelTitleBgFight/TxtTitle"):GetComponent("Text") + self.PanelEchelonMembers = self.Transform:Find("PanelEchelonMembers") + self.GridEchelonMember = self.Transform:Find("PanelEchelonMembers/GridEchelonMember") + self.TxtDoNotNeedFight = self.Transform:Find("TxtDoNotNeedFight"):GetComponent("Text") + self.PanelLogisticSkill = self.Transform:Find("PanelLogisticSkill") + self.TxtLogisticSkill = self.Transform:Find("PanelLogisticSkill/TxtLogisticSkill"):GetComponent("Text") + self.ImgNotPassCondition = self.Transform:Find("ImgNotPassCondition"):GetComponent("Image") + + self.BtnLeader.CallBack = function() self:OnBtnLeaderClick() end +end + +function XUiGridEchelon:OnBtnLeaderClick() + local team = {} + local captainPos = XDataCenter.BfrtManager.GetTeamCaptainPos(self.EchelonId) + + team = self.TeamList[self.EchelonIndex] + + XLuaUiManager.Open("UiNewRoomSingleTip", self, team, captainPos, function(index) + XDataCenter.BfrtManager.SetTeamCaptainPos(self.EchelonId, index) + self:UpdateTxtLeaderSkill() + self:UpdatePanelEchelonMembers() + end) +end + +function XUiGridEchelon:UpdateTitle() + if self.EchelonType == XDataCenter.BfrtManager.EchelonType.Fight then + self.PanelTitleBgFight.gameObject:SetActive(true) + self.TxtTitle.text = CS.XTextManager.GetText("BfrtFightEchelonTitle", self.EchelonIndex) + elseif self.EchelonType == XDataCenter.BfrtManager.EchelonType.Logistics then + self.PanelTitleBgLogistic.gameObject:SetActive(true) + self.TxtDoNotNeedFight.gameObject:SetActive(true) + self.TxtTitleA.text = CS.XTextManager.GetText("BfrtLogisticEchelonTitle", self.EchelonIndex) + end +end + +function XUiGridEchelon:UpdateTxtExtraCondition() + local hasCondition = self.ConditionId > 0 + self.TxtExtraCondition.gameObject:SetActive(hasCondition) + + if hasCondition then + local template = XConditionManager.GetConditionTemplate(self.ConditionId) + if template then + self.TxtExtraCondition.text = template.Desc + end + end +end + +function XUiGridEchelon:UpdateTxtLeaderSkill() + if self.EchelonType == XDataCenter.BfrtManager.EchelonType.Fight then + local team = self.TeamList[self.EchelonIndex] + if team then + local captainPos = XDataCenter.BfrtManager.GetTeamCaptainPos(self.EchelonId) + local captainId = team[captainPos] + if captainId and captainId > 0 then + local captianSkillInfo = XDataCenter.CharacterManager.GetCaptainSkillInfo(captainId) + self.TxtLeaderSkill.text = captianSkillInfo.Level > 0 and captianSkillInfo.Intro or string.format("%s%s", captianSkillInfo.Intro, CS.XTextManager.GetText("CaptainSkillLock")) + self.TxtLeaderSkill.gameObject:SetActive(true) + else + self.TxtLeaderSkill.gameObject:SetActive(false) + end + else + self.TxtLeaderSkill.gameObject:SetActive(false) + end + self.PanelLeaderSkill.gameObject:SetActive(true) + else + local logisticSkillDes = XDataCenter.BfrtManager.GetLogisticSkillDes(self.EchelonId) + self.TxtLogisticSkill.text = logisticSkillDes + self.PanelLogisticSkill.gameObject:SetActive(true) + end +end + +function XUiGridEchelon:UpdatePanelEchelonMembers() + local stageIds = XDataCenter.BfrtManager.GetStageIdList(self.GroupId) + local data = { + BfrtGroupId = self.GroupId, + MemberIndex = nil, + RequireAbility = nil, + StageId = stageIds[self.EchelonIndex], + EchelonRequireCharacterNum = self.EchelonRequireCharacterNum, + EchelonIndex = self.EchelonIndex, + EchelonId = self.EchelonId, + EchelonType = self.EchelonType, + TeamList = self.TeamList, + CharacterIdListWrap = self.CharacterIdListWrap, + TeamHasLeader = self.EchelonType == XDataCenter.BfrtManager.EchelonType.Fight, + TeamHasFirstFight = self.EchelonType == XDataCenter.BfrtManager.EchelonType.Fight, + } + + for i = 1, MAX_ECHELON_MEMBER_COUNT do + data.MemberIndex = XDataCenter.BfrtManager.TeamPosConvert(i) + data.RequireAbility = XDataCenter.BfrtManager.GetEchelonRequireAbility(self.EchelonId) + + if not self.GirdEchelonMemberList[i] then + local ui = CS.UnityEngine.Object.Instantiate(self.GridEchelonMember) + local grid = XUiGridEchelonMember.New(self, ui, data) + grid.Transform:SetParent(self.PanelEchelonMembers, false) + grid.GameObject:SetActiveEx(true) + grid.GameObject.name = "GridEchelonMember" .. i + self.GirdEchelonMemberList[i] = grid + else + self.GirdEchelonMemberList[i]:UpdateMemberInfo(data) + end + end +end + +function XUiGridEchelon:UpdateEchelonConditionState() + local requireAbility = XDataCenter.BfrtManager.GetEchelonRequireAbility(self.EchelonId) + self.TxtRequireAbility.text = requireAbility + + local characterCount = 0 + local allOverAbility = true + local team = self.TeamList[self.EchelonIndex] + for _, characterId in pairs(team) do + if characterId > 0 then + characterCount = characterCount + 1 + local char = XDataCenter.CharacterManager.GetCharacter(characterId) + local nowAbility = char and char.Ability or 0 + if nowAbility < requireAbility then + allOverAbility = false + break + end + end + end + + local retRequireNum = characterCount >= self.EchelonRequireCharacterNum + + local retCondition = self.ConditionId <= 0 or XConditionManager.CheckCondition(self.ConditionId, team) + self.TxtExtraCondition.color = CONDITION_COLOR[retCondition] + + local pass = allOverAbility and retCondition and retRequireNum + -- self.ImgNotPassCondition.gameObject:SetActive(not pass) + self.ImgNotPassCondition.gameObject:SetActiveEx(false) + self.ConditionPassed = pass +end + +function XUiGridEchelon:UpdateTeamInfo(team) + self.TeamList[self.EchelonIndex] = team + self.RootUi:UpdateEchelonList() +end + +function XUiGridEchelon:CheckIsInTeamList(characterId) + return self.RootUi:CheckIsInTeamList(characterId) +end + +function XUiGridEchelon:CharacterSwapEchelon(oldCharacterId, newCharacterId) + return self.RootUi:CharacterSwapEchelon(oldCharacterId, newCharacterId) +end + +return XUiGridEchelon \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiBfrt/XUiGridEchelonExp.lua b/Resources/Scripts/XUi/XUiBfrt/XUiGridEchelonExp.lua new file mode 100644 index 00000000..b1c8dbe8 --- /dev/null +++ b/Resources/Scripts/XUi/XUiBfrt/XUiGridEchelonExp.lua @@ -0,0 +1,138 @@ +local XUiGridEchelonExp = XClass(nil, "XUiGridEchelonExp") + +function XUiGridEchelonExp:Ctor(rootUi, ui, data) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self:InitAutoScript() + self:InitComponentState() + self:ResetDataInfo() + self:UpdateDataInfo(data) +end + +function XUiGridEchelonExp:InitComponentState() + self.GridCharacter.gameObject:SetActive(false) +end + +function XUiGridEchelonExp:ResetDataInfo() + self.GroupId = nil + self.EchelonIndex = nil + self.BaseStage = nil +end + +function XUiGridEchelonExp:UpdateDataInfo(data) + self.GroupId = data.GroupId + self.EchelonIndex = data.EchelonIndex + self.BaseStage = data.BaseStage + self.EchelonType = data.EchelonType + + self:UpdateTxtExp() + self:UpdateTxtEchelonIndex() + self:UpdatePanelMembers() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiGridEchelonExp:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiGridEchelonExp:AutoInitUi() + self.TxtExp = self.Transform:Find("ImageExpTag/TxtExp"):GetComponent("Text") + self.TxtEchelonIndex = self.Transform:Find("TxtEchelonIndex"):GetComponent("Text") + self.PanelCharacters = self.Transform:Find("PanelCharacters") + self.GridCharacter = self.Transform:Find("PanelCharacters/GridCharacter") +end + +function XUiGridEchelonExp:GetAutoKey(uiNode, eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiGridEchelonExp:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiGridEchelonExp:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiGridEchelonExp:AutoAddListener() + self.AutoCreateListeners = {} +end +-- auto +function XUiGridEchelonExp:UpdateTxtExp() + local stageCfg = XDataCenter.FubenManager.GetStageCfg(self.BaseStage) + self.TxtExp.text = "+" .. stageCfg.CardExp +end + +function XUiGridEchelonExp:UpdateTxtEchelonIndex() + self.TxtEchelonIndex.text = XDataCenter.BfrtManager.GetEchelonNameTxt(self.EchelonType, self.EchelonIndex) +end + +function XUiGridEchelonExp:UpdatePanelMembers() + if self.EchelonType == XDataCenter.BfrtManager.EchelonType.Fight then + self:UpdateFightTeamCharacter() + elseif self.EchelonType == XDataCenter.BfrtManager.EchelonType.Logistics then + self:UpdateLogisticsTeamCharacter() + end +end + +function XUiGridEchelonExp:UpdateFightTeamCharacter() + local fightTeamList = XDataCenter.BfrtManager.GetFightTeamList(self.GroupId) + if not fightTeamList then + XLog.Error("XUiGridEchelonExp UpdateFightTeamCharacter 函数错误,根据GroupId: " .. tostring(self.GroupId) .. "获取fightTeamList失败,请检查后端返回的数据") + return + end + + local fightTeam = fightTeamList[self.EchelonIndex] + for index = 1, #fightTeam do + local charId = fightTeam[XDataCenter.BfrtManager.TeamPosConvert(index)] + if charId ~= 0 then + local char = XDataCenter.CharacterManager.GetCharacter(charId) + local ui = CS.UnityEngine.Object.Instantiate(self.GridCharacter) + local grid = XUiGridCharacter.New(ui, self, char) + grid.Transform:SetParent(self.PanelCharacters, false) + grid.GameObject:SetActive(true) + end + end +end + +function XUiGridEchelonExp:UpdateLogisticsTeamCharacter() + local logisticsTeamList = XDataCenter.BfrtManager.GetLogisticsTeamList(self.GroupId) + if not logisticsTeamList then + XLog.Error("XUiGridEchelonExp UpdateLogisticsTeamCharacter 函数错误,根据GroupId: " .. tostring(self.GroupId) .. "获取logisticsTeamList失败,请检查后端返回的数据") + return + end + + local logisticsTeam = logisticsTeamList[self.EchelonIndex] + for index = 1, #logisticsTeam do + local charId = logisticsTeam[index] + if charId ~= 0 then + local char = XDataCenter.CharacterManager.GetCharacter(charId) + local ui = CS.UnityEngine.Object.Instantiate(self.GridCharacter) + local grid = XUiGridCharacter.New(ui, self, char) + grid.Transform:SetParent(self.PanelCharacters, false) + grid.GameObject:SetActive(true) + end + end +end + +return XUiGridEchelonExp \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiBfrt/XUiGridEchelonMember.lua b/Resources/Scripts/XUi/XUiBfrt/XUiGridEchelonMember.lua new file mode 100644 index 00000000..c633b331 --- /dev/null +++ b/Resources/Scripts/XUi/XUiBfrt/XUiGridEchelonMember.lua @@ -0,0 +1,229 @@ +local CONDITION_COLOR = { + [true] = CS.UnityEngine.Color.white, + [false] = CS.UnityEngine.Color.red, +} + +local XUiGridEchelonMember = XClass(nil, "XUiGridEchelonMember") + +--位置对应的颜色框 +local MEMBER_POS_COLOR = { + [1] = "ImgRed", + [2] = "ImgBlue", + [3] = "ImgYellow", +} + +function XUiGridEchelonMember:Ctor(rootUi, ui, data) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + self:InitAutoScript() + self:ResetMemberInfo() + self:UpdateMemberInfo(data) +end + +function XUiGridEchelonMember:ResetMemberInfo() + self.MemberIndex = nil + self.RequireAbility = nil + self.StageId = nil + self.EchelonRequireCharacterNum = nil + self.EchelonIndex = nil + self.EchelonId = nil + self.EchelonType = nil + self.TeamList = {} + self.CharacterIdListWrap = {} + self.TeamHasLeader = false + self.TeamHasFirstFight = false + + self.ImgLeaderTag.gameObject:SetActiveEx(false) + self.ImgFirstRole.gameObject:SetActiveEx(false) + self.PanelEmpty.gameObject:SetActiveEx(false) + self.PanelSlect.gameObject:SetActiveEx(false) + self.PanelLock.gameObject:SetActiveEx(false) + self.PanelColour.gameObject:SetActiveEx(false) + self.ImgBlue.gameObject:SetActiveEx(false) + self.ImgRed.gameObject:SetActiveEx(false) + self.ImgYellow.gameObject:SetActiveEx(false) +end + +function XUiGridEchelonMember:UpdateMemberInfo(data) + self.GroupId = data.BfrtGroupId + self.MemberIndex = data.MemberIndex + self.EchelonRequireCharacterNum = data.EchelonRequireCharacterNum + if self.MemberIndex > self.EchelonRequireCharacterNum then + return + end + + self.RequireAbility = data.RequireAbility + self.StageId = data.StageId + self.EchelonIndex = data.EchelonIndex + self.EchelonId = data.EchelonId + self.EchelonType = data.EchelonType + self.TeamList = data.TeamList + self.CharacterIdListWrap = data.CharacterIdListWrap + self.TeamHasLeader = data.TeamHasLeader + self.TeamHasFirstFight = data.TeamHasFirstFight + self:CheckTeamNum() + self:InitPanelColour() + self:UpdateImgLeaderTag() + self:UpdateImgFirstRole() + self:UpdateCharacterInfo() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiGridEchelonMember:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiGridEchelonMember:AutoInitUi() + self.BtnClick = self.Transform:Find("BtnClick"):GetComponent("Button") + self.PanelSlect = self.Transform:Find("PanelSlect") + self.ImgMask = self.Transform:Find("PanelSlect/ImgMask"):GetComponent("Image") + self.RImgRoleHead = self.Transform:Find("PanelSlect/ImgMask/RImgRoleHead"):GetComponent("RawImage") + self.TxtNowAbility = self.Transform:Find("PanelSlect/PanelNotPassCondition/TxtNowAbility"):GetComponent("Text") + self.PanelEmpty = self.Transform:Find("PanelEmpty") + self.PanelColour = self.Transform:Find("PanelColour") + self.ImgYellow = self.Transform:Find("PanelColour/ImgYellow"):GetComponent("Image") + self.ImgBlue = self.Transform:Find("PanelColour/ImgBlue"):GetComponent("Image") + self.ImgRed = self.Transform:Find("PanelColour/ImgRed"):GetComponent("Image") + self.PanelLock = self.Transform:Find("PanelLock") +end + +function XUiGridEchelonMember:GetAutoKey(uiNode, eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiGridEchelonMember:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiGridEchelonMember:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiGridEchelonMember:AutoAddListener() + self.AutoCreateListeners = {} + XUiHelper.RegisterClickEvent(self, self.BtnClick, self.OnBtnClickClick) +end +-- auto +function XUiGridEchelonMember:OnBtnClickClick() + if self.MemberIndex > self.EchelonRequireCharacterNum then + return + end + + local viewData = { + BfrtGroupId = self.GroupId, + RequireAbility = self.RequireAbility, + TeamCharacterIdList = self.TeamList[self.EchelonIndex], + TeamSelectPos = self.MemberIndex, + EchelonIndex = self.EchelonIndex, + EchelonType = self.EchelonType, + StageId = self.StageId, + CheckIsInTeamListCb = function(characterId) + return self.RootUi:CheckIsInTeamList(characterId) + end, + CharacterSwapEchelonCb = function(oldCharacterId, newCharacterId) + return self.RootUi:CharacterSwapEchelon(oldCharacterId, newCharacterId) + end, + TeamResultCb = function(team) + self.RootUi:UpdateTeamInfo(team) + end, + } + XLuaUiManager.Open("UiBfrtRoomCharacter", viewData) +end + +function XUiGridEchelonMember:UpdateImgLeaderTag() + if not self.TeamHasLeader then + return + end + + local captainPos = XDataCenter.BfrtManager.GetTeamCaptainPos(self.EchelonId) + if self.MemberIndex <= self.EchelonRequireCharacterNum and self.MemberIndex == captainPos then + self.ImgLeaderTag.gameObject:SetActive(true) + else + self.ImgLeaderTag.gameObject:SetActive(false) + end +end + +function XUiGridEchelonMember:UpdateImgFirstRole() + if not self.TeamHasFirstFight then + return + end + + local firstFightPos = XDataCenter.BfrtManager.GetTeamFirstFightPos(self.EchelonId) + + if self.MemberIndex <= self.EchelonRequireCharacterNum and self.MemberIndex == firstFightPos then + self.ImgFirstRole.gameObject:SetActive(true) + else + self.ImgFirstRole.gameObject:SetActive(false) + end +end + +function XUiGridEchelonMember:UpdateCharacterInfo() + if self.MemberIndex > self.EchelonRequireCharacterNum then + return + end + + local characterId = self.TeamList[self.EchelonIndex][self.MemberIndex] + if not characterId or characterId == 0 then + if self.MemberIndex <= self.EchelonRequireCharacterNum then + --没出人 + self.PanelSlect.gameObject:SetActive(false) + self.PanelEmpty.gameObject:SetActive(true) + self.PanelLock.gameObject:SetActive(false) + else + --不能上人(要求两个人,第三个格子的状态) + self.PanelSlect.gameObject:SetActive(false) + self.PanelEmpty.gameObject:SetActive(false) + self.PanelLock.gameObject:SetActive(true) + end + else + --上了人 + self.RImgRoleHead:SetRawImage(XDataCenter.CharacterManager.GetCharSmallHeadIcon(characterId)) + self.PanelSlect.gameObject:SetActive(true) + self.PanelEmpty.gameObject:SetActive(false) + self.PanelLock.gameObject:SetActive(false) + + local char = XDataCenter.CharacterManager.GetCharacter(characterId) + local nowAbility = char and char.Ability or 0 + self.TxtNowAbility.text = math.floor(nowAbility) + self.TxtNowAbility.color = CONDITION_COLOR[nowAbility >= self.RequireAbility] + end +end + +function XUiGridEchelonMember:InitPanelColour() + if not self.TeamHasLeader then + self.PanelColour.gameObject:SetActive(false) + return + end + self[MEMBER_POS_COLOR[self.MemberIndex]].gameObject:SetActive(true) + self.PanelColour.gameObject:SetActive(true) +end + +function XUiGridEchelonMember:CheckTeamNum() + self.TeamList[self.EchelonIndex] = self.TeamList[self.EchelonIndex] or { 0, 0, 0 } + for i = #self.TeamList[self.EchelonIndex], self.EchelonRequireCharacterNum + 1, -1 do + self.TeamList[self.EchelonIndex][i] = 0 + end +end + +return XUiGridEchelonMember \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiBfrt/XUiGridLogisticSkill.lua b/Resources/Scripts/XUi/XUiBfrt/XUiGridLogisticSkill.lua new file mode 100644 index 00000000..ea6463ce --- /dev/null +++ b/Resources/Scripts/XUi/XUiBfrt/XUiGridLogisticSkill.lua @@ -0,0 +1,61 @@ +local XUiGridLogisticSkill = XClass(nil, "XUiGridLogisticSkill") + +function XUiGridLogisticSkill:Ctor(ui, viewData) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self:InitAutoScript() + self:UpdateView(viewData) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiGridLogisticSkill:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiGridLogisticSkill:AutoInitUi() + self.TxtEchelonIndex = self.Transform:Find("ImageBg/TxtEchelonIndex"):GetComponent("Text") + self.TxtSkillDes = self.Transform:Find("TxtSkillDes"):GetComponent("Text") +end + +function XUiGridLogisticSkill:GetAutoKey(uiNode, eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiGridLogisticSkill:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiGridLogisticSkill:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiGridLogisticSkill:AutoAddListener() + self.AutoCreateListeners = {} +end +-- auto +function XUiGridLogisticSkill:UpdateView(viewData) + local logisticSkillDes = XDataCenter.BfrtManager.GetLogisticSkillDes(viewData.EchelonId) + self.TxtEchelonIndex.text = viewData.EchelonIndex + self.TxtSkillDes.text = logisticSkillDes +end + +return XUiGridLogisticSkill \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiBfrt/XUiGridQuickDeployMember.lua b/Resources/Scripts/XUi/XUiBfrt/XUiGridQuickDeployMember.lua new file mode 100644 index 00000000..2ef72f22 --- /dev/null +++ b/Resources/Scripts/XUi/XUiBfrt/XUiGridQuickDeployMember.lua @@ -0,0 +1,65 @@ +local XUiGridQuickDeployMember = XClass(nil, "XUiGridQuickDeployMember") + +function XUiGridQuickDeployMember:Ctor(ui, pos, clickCb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Pos = pos + self.ClickCb = clickCb + + XTool.InitUiObject(self) + self:InitComponent() +end + +function XUiGridQuickDeployMember:InitComponent() + self.RImgRole.gameObject:SetActiveEx(false) + self.ImgLeader.gameObject:SetActiveEx(false) + self.ImgFirstRole.gameObject:SetActiveEx(false) + self.ImgAbility.gameObject:SetActiveEx(false) + self.ImgSelect.gameObject:SetActiveEx(false) + self.PanelEffect.gameObject:SetActiveEx(false) + self.BtnMember.CallBack = function() self:OnMemberClick() end + + local color = XUiHelper.Hexcolor2Color(XBfrtConfigs.MEMBER_POS_COLOR[self.Pos]) + self.ImgLeftSkill.color = color + self.ImgRightSkill.color = color +end + +function XUiGridQuickDeployMember:Refresh(characterId, team, characterLimitType) + self.CharacterId = characterId + self.Team = team + self.CharacterLimitType = characterLimitType + + if characterId and characterId ~= 0 then + self.RImgRole.gameObject:SetActiveEx(true) + self.RImgRole:SetRawImage(XDataCenter.CharacterManager.GetCharSmallHeadIcon(characterId)) + else + self.RImgRole.gameObject:SetActiveEx(false) + end + + self.PanelEffect.gameObject:SetActiveEx(false) +end + +function XUiGridQuickDeployMember:OnMemberClick() + if self.ClickCb then + self.ClickCb(self.CharacterId, self, self.Pos, self.Team, self.CharacterLimitType) + end +end + +function XUiGridQuickDeployMember:ShowEffect() + self.PanelEffect.gameObject:SetActiveEx(false) + self.PanelEffect.gameObject:SetActiveEx(true) +end + +function XUiGridQuickDeployMember:SetSelect(value) + self.ImgSelect.gameObject:SetActiveEx(value) +end + +function XUiGridQuickDeployMember:RefreshCaptainPos(captainPos) + self.ImgLeader.gameObject:SetActiveEx(self.Pos == captainPos) +end + +function XUiGridQuickDeployMember:RefreshFirstFightPos(firstFightPos) + self.ImgFirstRole.gameObject:SetActiveEx(self.Pos == firstFightPos) +end + +return XUiGridQuickDeployMember \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiBfrt/XUiGridQuickDeployTeam.lua b/Resources/Scripts/XUi/XUiBfrt/XUiGridQuickDeployTeam.lua new file mode 100644 index 00000000..5755df24 --- /dev/null +++ b/Resources/Scripts/XUi/XUiBfrt/XUiGridQuickDeployTeam.lua @@ -0,0 +1,137 @@ +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate + +local MAX_GRID_NUM = 3 + +local XUiGridQuickDeployMember = require("XUi/XUiBfrt/XUiGridQuickDeployMember") + +local XUiGridQuickDeployTeam = XClass(nil, "XUiGridQuickDeployTeam") + +function XUiGridQuickDeployTeam:Ctor(ui, memberClickCb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.MemberGridList = {} + self.MemberClickCb = memberClickCb + + XTool.InitUiObject(self) + self.TabGroup = { + self.BtnRed, + self.BtnBlue, + self.BtnYellow, + } + self.PanelTabFirst:Init(self.TabGroup, function(tabIndex) self:OnClickTabCallBack(tabIndex) end) + + self.TabGroupCT = { + self.BtnCaptainRed, + self.BtnCaptainBlue, + self.BtnCaptainYellow, + } + self.PanelTabCaptain:Init(self.TabGroupCT, function(tabIndex) self:OnClickTabCallBackCT(tabIndex) end) + + self.GridTeamMember.gameObject:SetActiveEx(false) +end + +function XUiGridQuickDeployTeam:Refresh(echelonId, team, echelonIndex, echelonType, characterLimitType) + local gridList = self.MemberGridList + self.EchelonId = echelonId + + if echelonType == XDataCenter.BfrtManager.EchelonType.Fight then + self.TextTitle.text = CS.XTextManager.GetText("BfrtFightEchelonTitle", echelonIndex) + elseif echelonType == XDataCenter.BfrtManager.EchelonType.Logistics then + self.TextTitle.text = CS.XTextManager.GetText("BfrtLogisticEchelonTitle", echelonIndex) + end + + for index = 1, MAX_GRID_NUM do + local pos = XDataCenter.BfrtManager.TeamPosConvert(index) + local grid = gridList[index] + local characterId = team[pos] + + if not grid then + local go = CSUnityEngineObjectInstantiate(self.GridTeamMember, self.PanelRole) + local clickCb = function(paramCharacterId, paramGrid, paramPos, cacheTeam, cacheCharacterLimitType) + self.MemberClickCb(paramCharacterId, paramGrid, paramPos, cacheTeam, cacheCharacterLimitType) + end + + grid = XUiGridQuickDeployMember.New(go, pos, clickCb) + gridList[index] = grid + end + local captainPos = XDataCenter.BfrtManager.GetTeamCaptainPos(echelonId) + + grid:Refresh(characterId, team, characterLimitType) + grid:RefreshCaptainPos(captainPos) + grid.GameObject:SetActiveEx(false) + + self.TabGroup[pos].gameObject:SetActiveEx(true) + self.TabGroupCT[pos].gameObject:SetActiveEx(true) + end + + local echelonRequireCharacterNum = XDataCenter.BfrtManager.GetEchelonNeedCharacterNum(self.EchelonId) + for pos = 1, echelonRequireCharacterNum do + local index = XDataCenter.BfrtManager.MemberIndexConvert(pos) + local grid = gridList[index] + if grid then + grid.GameObject:SetActiveEx(true) + end + end + + if not XFubenConfigs.IsStageCharacterLimitConfigExist(characterLimitType) then + self.PanelRequireCharacter.gameObject:SetActiveEx(false) + return + else + self.PanelRequireCharacter.gameObject:SetActiveEx(true) + end + + local icon = XFubenConfigs.GetStageCharacterLimitImageTeamEdit(characterLimitType) + self.ImgRequireCharacter:SetSprite(icon) + + local name = XFubenConfigs.GetStageCharacterLimitName(characterLimitType) + self.TxtRequireCharacter.text = name + + --队长/首发 + for i = echelonRequireCharacterNum + 1, #self.TabGroup do + self.TabGroup[i].gameObject:SetActiveEx(false) + end + local firstFightPos = XDataCenter.BfrtManager.GetTeamFirstFightPos(echelonId) + self.PanelTabFirst:SelectIndex(firstFightPos) + + for i = echelonRequireCharacterNum + 1, #self.TabGroupCT do + self.TabGroupCT[i].gameObject:SetActiveEx(false) + end + local captainPos = XDataCenter.BfrtManager.GetTeamCaptainPos(echelonId) + self.PanelTabCaptain:SelectIndex(captainPos) +end + +function XUiGridQuickDeployTeam:OnClickTabCallBack(firstFightPos) + if self.SelectedIndex and self.SelectedIndex == firstFightPos then + return + end + self.SelectedIndex = firstFightPos + + local echelonId = self.EchelonId + XDataCenter.BfrtManager.SetTeamFirstFightPos(echelonId, firstFightPos) + + local gridList = self.MemberGridList + local gridNum = #gridList + for index = 1, gridNum do + local grid = gridList[index] + grid:RefreshFirstFightPos(firstFightPos) + end +end + +function XUiGridQuickDeployTeam:OnClickTabCallBackCT(captainPos) + if self.SelectedIndexCT and self.SelectedIndexCT == captainPos then + return + end + self.SelectedIndexCT = captainPos + + local echelonId = self.EchelonId + XDataCenter.BfrtManager.SetTeamCaptainPos(echelonId, captainPos) + + local gridList = self.MemberGridList + local gridNum = #gridList + for index = 1, gridNum do + local grid = gridList[index] + grid:RefreshCaptainPos(captainPos) + end +end + +return XUiGridQuickDeployTeam \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiBfrt/XUiTipBfrtLogisticSkill.lua b/Resources/Scripts/XUi/XUiBfrt/XUiTipBfrtLogisticSkill.lua new file mode 100644 index 00000000..7cba85d9 --- /dev/null +++ b/Resources/Scripts/XUi/XUiBfrt/XUiTipBfrtLogisticSkill.lua @@ -0,0 +1,128 @@ +local ANIMATION_OPEN = "AniTipJudianBegin" +-- local ANIMATION_END = "AniTipJudianEnd" +local CLOSE_TIME = 3 + +local XUiTipBfrtLogisticSkill = XLuaUiManager.Register(XLuaUi, "UiTipBfrtLogisticSkill") + +function XUiTipBfrtLogisticSkill:OnStart(groupId) + self.CurShowIndex = 0 + self.LogisticsInfoIdList = XDataCenter.BfrtManager.GetLogisticsInfoIdList(groupId) + self.TotalShowTimes = #self.LogisticsInfoIdList + + self:InitAutoScript() + self:InitComponentState() + self:UpdateView() +end + +function XUiTipBfrtLogisticSkill:InitComponentState() + +end + +function XUiTipBfrtLogisticSkill:OnDestroy() + self:ClearCloseTimer() + self:ClearViewData() +end + +function XUiTipBfrtLogisticSkill:ClearViewData() + self.CurShowIndex = nil + self.TotalShowTimes = nil + self.LogisticsInfoIdList = {} +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiTipBfrtLogisticSkill:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiTipBfrtLogisticSkill:AutoInitUi() + self.PanelTipBfrtLogisticSkill = self.Transform:Find("SafeAreaContentPane/PanelTipBfrtLogisticSkill") + self.TxtEchelonIndex = self.Transform:Find("SafeAreaContentPane/PanelTipBfrtLogisticSkill/TxtEchelonIndex"):GetComponent("Text") + self.TxtSkillDes = self.Transform:Find("SafeAreaContentPane/PanelTipBfrtLogisticSkill/TxtSkillDes"):GetComponent("Text") +end + +function XUiTipBfrtLogisticSkill:GetAutoKey(uiNode, eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiTipBfrtLogisticSkill:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiTipBfrtLogisticSkill:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiTipBfrtLogisticSkill:AutoAddListener() + self.AutoCreateListeners = {} +end +-- auto +function XUiTipBfrtLogisticSkill:UpdateView() + self.CurShowIndex = self.CurShowIndex + 1 + if self.CurShowIndex > self.TotalShowTimes then + self:Close() + return + end + + self:UpdatePanelDes() + self:PlayBeginAnimation() +end + +function XUiTipBfrtLogisticSkill:PlayBeginAnimation() + local endCb = function() + self:AddCloseTimer() + end + + self:PlayAnimation(ANIMATION_OPEN, endCb) + +end + +function XUiTipBfrtLogisticSkill:AddCloseTimer() + self:ClearCloseTimer() + local time = 0 + local function action() + time = time + 1 + if time == CLOSE_TIME then + self:PlayEndAnimation() + end + end + self.Timer = XScheduleManager.Schedule(action, XScheduleManager.SECOND, CLOSE_TIME, 0) +end + +function XUiTipBfrtLogisticSkill:PlayEndAnimation() + -- local endCb = function() + -- self:UpdateView() + -- end +end + +function XUiTipBfrtLogisticSkill:UpdatePanelDes() + local echelonId = self.LogisticsInfoIdList[self.CurShowIndex] + local logisticSkillDes = XDataCenter.BfrtManager.GetLogisticSkillDes(echelonId) + self.TxtEchelonIndex.text = CS.XTextManager.GetText("BfrtLogisticEchelonTitle", self.CurShowIndex) + self.TxtSkillDes.text = logisticSkillDes +end + +function XUiTipBfrtLogisticSkill:ClearCloseTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiBuyAsset/XUiBattery.lua b/Resources/Scripts/XUi/XUiBuyAsset/XUiBattery.lua new file mode 100644 index 00000000..b6e3db21 --- /dev/null +++ b/Resources/Scripts/XUi/XUiBuyAsset/XUiBattery.lua @@ -0,0 +1,195 @@ +XUiBattery = XClass(nil, "XUiBattery") +local GoodsId = 1 +local RewardIndex = 2 +local FoEver = 0 +local FoEverText = CS.XTextManager.GetText("Forever") +local OverdueText = CS.XTextManager.GetText("TaskStateOverdue") +local BatteryOverSelectItemNumText = CS.XTextManager.GetText("BatteryOverSelectItemNum") +local LONG_CLICK_TIME = 300 + +function XUiBattery:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = ui + XTool.InitUiObject(self) + + self.IsLockLongClick = false + self:FlushSelectShow() + self:AutoAddListener() +end + +function XUiBattery:OnRecycle() + if self.Timers then + XScheduleManager.UnSchedule(self.Timers) + self.Timers = nil + end +end + +function XUiBattery:AutoAddListener() + self.BtnClick.CallBack = function() + self:OnBtnClick() + end + self.BtnMinusSelect.CallBack = function() + self:OnBtnMinusSelectCallBack() + end + -- 添加长按事件 + local btnClickPointer = self.BtnClick.gameObject:GetComponent("XUiPointer") + if btnClickPointer then + XUiButtonLongClick.New(btnClickPointer, 100, self, nil, self.OnBtnLongClick, nil, true) + end + local btnMinusSelect = self.BtnMinusSelect:GetComponent("XUiPointer") + XUiButtonLongClick.New(btnMinusSelect, 10, self, nil, self.OnBtnMinusSelectLongClick, nil, true) +end + +function XUiBattery:OnBtnLongClick(time) + if self.IsCantUse then + XUiManager.TipError(OverdueText) + return + end + local selectItemCount = self.Base:GetSelectItemCountByIndex(self.Index) + if selectItemCount >= self.BagItem.Count then + XUiManager.TipMsg(BatteryOverSelectItemNumText) + return + end + self:SetSelectedCount(selectItemCount + 1) +end + +function XUiBattery:OnBtnClick() + if not self.IsCantUse then + local selectItemCount = self.Base:GetSelectItemCountByIndex(self.Index) + if selectItemCount < self.BagItem.Count then + self:SetSelectedCount(selectItemCount + 1) + else + XUiManager.TipMsg(BatteryOverSelectItemNumText) + end + else + XUiManager.TipError(OverdueText) + end +end + +function XUiBattery:SetSelectedCount(count) + local onecElectricNum = self:GetOneElectricCount() + self.Base:SetSelectItemCount(self.Index, count, onecElectricNum) + self:FlushSelectShow() +end + +function XUiBattery:OnBtnMinusSelectCallBack() + self.Base:SubSelectItemCountByIndex(self.Index) + self:FlushSelectShow() +end + +function XUiBattery:OnBtnMinusSelectLongClick(time) + if self.IsLockLongClick or time <= LONG_CLICK_TIME then + return + end + + if time > LONG_CLICK_TIME then + self.IsLockLongClick = true + self.BtnMinusSelect:SetButtonState(CS.UiButtonState.Normal) + end + self.Base:ClearSelectItemCountByIndex(self.Index) + self:FlushSelectShow() + self.IsLockLongClick = false +end + +function XUiBattery:UpdateGrid(bagItem, parent, index) + self.Base = parent + self.BagItem = bagItem + self.Index = index + self.GoodsShowParams = XGoodsCommonManager.GetGoodsShowParamsByTemplateId(self.BagItem.Data.Id) + + local count = bagItem.Count + -- 数量 + if self.TxtCount and count then + self.TxtCount.text = CS.XTextManager.GetText("ShopGridCommonCount", count) + end + + -- 图标 + if self.RImgIcon then + local icon = self.GoodsShowParams.Icon + if icon and #icon > 0 then + self.RImgIcon:SetRawImage(icon) + end + end + + if self.ImgQuality and self.GoodsShowParams.Quality then + local qualityIcon = self.GoodsShowParams.QualityIcon + + if qualityIcon then + parent:SetUiSprite(self.ImgQuality, qualityIcon) + else + XUiHelper.SetQualityIcon(parent, self.ImgQuality, self.GoodsShowParams.Quality) + end + end + + if self.BagItem.Data.Template.TimelinessType and + self.BagItem.Data.Template.TimelinessType ~= FoEver then + self.Timers = XScheduleManager.ScheduleForever(function() self:SetTime() end, XScheduleManager.SECOND) + end + + self:SetTime() + self:FlushSelectShow() +end + +function XUiBattery:SetTime() + local sprite + if self.TxtTime then --海外修改,爆框问题 + self.TxtTime.rectTransform.sizeDelta = CS.UnityEngine.Vector2(108,30) + end + if not self.BagItem.Data.Template.TimelinessType or + self.BagItem.Data.Template.TimelinessType == FoEver then + self.TxtTime.text = FoEverText + sprite = XUiHelper.TagBgPath.Green + self.IsCantUse = false + else + local LifeTime = self.BagItem.RecycleBatch and self.BagItem.RecycleBatch.RecycleTime - XTime.GetServerNowTimestamp() + or XDataCenter.ItemManager.GetRecycleLeftTime(self.BagItem.Data.Id) + + if LifeTime and LifeTime > 0 then + local tmpTime = XUiHelper.GetTime(LifeTime, XUiHelper.TimeFormatType.MAINBATTERY) + self.TxtTime.text = tmpTime + if LifeTime > CS.XDateUtil.ONE_DAY_SECOND * 7 then + sprite = XUiHelper.TagBgPath.Green + elseif LifeTime > CS.XDateUtil.ONE_DAY_SECOND then + sprite = XUiHelper.TagBgPath.Yellow + else + sprite = XUiHelper.TagBgPath.Red + end + self.IsCantUse = false + else + self.TxtTime.text = OverdueText + sprite = XUiHelper.TagBgPath.Red + self.IsCantUse = true + self:OnBtnMinusSelectCallBack() + end + end + self.Base:SetUiSprite(self.TimeTag, sprite) +end + +function XUiBattery:FlushSelectShow() + if self.Base then + local selectItemCount = self.Base:GetSelectItemCountByIndex(self.Index) + self:SetSelectItemCountText(selectItemCount) + self:CheckShowSelect() + end +end + +function XUiBattery:SetSelectItemCountText(selectItemCount) + if self.TxtSelectHide then + self.TxtSelectHide.text = selectItemCount + end +end + +function XUiBattery:GetOneElectricCount() + local goodsList = XRewardManager.GetRewardList(self.BagItem.Data.Template.SubTypeParams[RewardIndex]) + return goodsList[GoodsId].Count +end + +function XUiBattery:CheckShowSelect() + local selectItemCount = self.Base:GetSelectItemCountByIndex(self.Index) + self.ImgSelect.gameObject:SetActiveEx(selectItemCount > 0) + self.BtnMinusSelect.gameObject:SetActiveEx(selectItemCount > 0) + self.TxtSelectHide.gameObject:SetActiveEx(selectItemCount > 0) +end + +return XUiBattery \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiBuyAsset/XUiBuyAsset.lua b/Resources/Scripts/XUi/XUiBuyAsset/XUiBuyAsset.lua new file mode 100644 index 00000000..a4b2cc55 --- /dev/null +++ b/Resources/Scripts/XUi/XUiBuyAsset/XUiBuyAsset.lua @@ -0,0 +1,380 @@ +local CSXTextManagerGetText = CS.XTextManager.GetText + +local XUiBuyAsset = XLuaUiManager.Register(XLuaUi, "UiBuyAsset") + +local WinType = { + "Normal", + "ShortCut" +} + + +function XUiBuyAsset:OnStart(id, successCallback, challengeCountData, buyAmount, isAutoClose) + self.SuccessCallback = successCallback + self.BuyAmount = buyAmount or 1 + self.IsAutoClose = isAutoClose + if challengeCountData ~= nil then + self:RefreshChallengeCount(challengeCountData) + return + end + self.Id = id + + --判断界面的显示类型,根据Id + local exchangeType = XItemConfigs.GetBuyAssetType(self.Id) + self.WinType = WinType[exchangeType] + + --初始化数据 + self.curConsumeIdIndex = 1 + + self:InitUiType() + self:FreshCallBack(id) + self:AutoAddListener() +end + +function XUiBuyAsset:OnEnable() + self:Refresh(self.Id) +end + +function XUiBuyAsset:OnDestroy() + +end + +function XUiBuyAsset:AutoAddListener() + self.BtnCancel.CallBack = function() + self:OnBtnCancelClick() + end + self.BtnConfirm.CallBack = function() + self:OnBtnConfirmClick() + end + self.BtnTanchuangClose.CallBack = function() + self:OnBtnCloseClick() + end + self.BtnPackageExchange.CallBack = function() + self:OnBtnShowTypeClick() + end + --添加 增加减少以及文本框内容改变事件 + self.BtnAddSelect.CallBack = function() + self:OnBtnAddSelectClick() + end + self.BtnMinusSelect.CallBack = function() + self:OnBtnMinusSelectClick() + end + self.TxtSelect.onValueChanged:AddListener(function() + self:OnSelectTextChange() + end) + self.BtnMoneyPackageExchange.CallBack = function() + self:OnBtnMoneyPackageExchangeClicked() + end +end +-- auto +function XUiBuyAsset:OnBtnShowTypeClick() + self:Close() + XLuaUiManager.Open("UiUsePackage", self.Id, self.SuccessCallback, self.ChallengeCountData, self.BuyAmount) +end + +function XUiBuyAsset:OnBtnCloseClick() + self:Close() +end + +function XUiBuyAsset:FreshCallBack(id) + XDataCenter.ItemManager.AddBuyTimesUpdateListener(id, function(targetId) + if self.Data.LeftTimes == 0 then + return + end + if targetId ~= self.Data.TargetId then + return + end + self:Refresh(targetId) + end, self.PanelInfo, self.gameObject) +end + +function XUiBuyAsset:OnBtnCancelClick() + self:Close() +end + +function XUiBuyAsset:OnBtnConfirmClick() + if self.ChallengeCountData ~= nil then + self:OnBtnChallengeCountClick() + return + end + + if self.Data.LeftTimes == 0 then + local itemName = XDataCenter.ItemManager.GetItemName(self.Data.ConsumeId[self.curConsumeIdIndex]) + local text = CS.XTextManager.GetText('BuyCountIsNotEnough', itemName) + XUiManager.TipMsg(text, XUiManager.UiTipType.Tip) + return + end + + if not XDataCenter.ItemManager.CheckItemCountById(self.Data.ConsumeId[self.curConsumeIdIndex], (self.Data.ConsumeCount[self.curConsumeIdIndex]*self.BuyAmount)) then + local itemName = XDataCenter.ItemManager.GetItemName(self.Data.ConsumeId[self.curConsumeIdIndex]) + local text = CS.XTextManager.GetText('AssetsBuyConsumeNotEnough', itemName) + + local itemId = self.Data.ConsumeId[self.curConsumeIdIndex] + if itemId == XDataCenter.ItemManager.ItemId.FreeGem or itemId == XDataCenter.ItemManager.ItemId.PaidGem then + -- 二次确认 + XUiManager.DialogDragTip(CSXTextManagerGetText("TipTitle") ,CsXTextManagerGetText("BuyAssetHKNotEnoughTips"), XUiManager.DialogType.Normal, function () + -- XUiManager.TipMsg(text, XUiManager.UiTipType.Tip) + end, function () + local skipParams = XDataCenter.ItemManager.GetItemSkipIdParams(itemId) + if skipParams then + XFunctionManager.SkipInterface(skipParams[1]) + end + end) + else + XUiManager.TipMsg(text, XUiManager.UiTipType.Tip) + end + return + end + + local callback = function(targetId, targetCount) + local name = XDataCenter.ItemManager.GetItemName(targetId) + XUiManager.TipMsg(CS.XTextManager.GetText("Buy") .." ".. CS.XTextManager.GetText("Success") .. ", " .. targetCount .. " " .. name .." ".. CS.XTextManager.GetText("Acquire"), XUiManager.UiTipType.Tip) -- 海外修改 + self.BuyAmount = 1 + self:Refresh(targetId) + if self.IsAutoClose or XItemConfigs.GetBuyAssetAutoClose(self.Id) ~= 0 then + self:Close() + end + if self.SuccessCallback then + self.SuccessCallback() + end + CsXGameEventManager.Instance:Notify(XEventId.EVENT_ITEM_FAST_TRADING) + end + + -- local failCallBack = function () + -- if itemId == XDataCenter.ItemManager.ItemId.FreeGem or itemId == XDataCenter.ItemManager.ItemId.PaidGem then + -- XFunctionManager.SkipInterface(50024) + -- end + -- end + XDataCenter.ItemManager.BuyAsset(self.Data.TargetId, callback, nil, self.BuyAmount, self.Data.ConsumeId[self.curConsumeIdIndex]) +end + +function XUiBuyAsset:Refresh(targetId) + self.Data = XDataCenter.ItemManager.GetBuyAssetInfo(targetId) + + local active = self.Data ~= nil + self.PanelInfo.gameObject:SetActiveEx(active) + self.PanelMax.gameObject:SetActiveEx(not active) + self.BtnCancel.gameObject:SetActiveEx(true) + self.BtnConfirm.gameObject:SetActiveEx(true) + self.BtnPackageExchange.gameObject:SetActiveEx(self.Data.TargetId == XDataCenter.ItemManager.ItemId.ActionPoint) -- 海外修改,从JP1.17搬过来的 + self.BtnMoneyPackageExchange.gameObject:SetActiveEx(self.Data.TargetId == XDataCenter.ItemManager.ItemId.Coin) + -- 当前状态 + local num = "?" + if self.Data.ConsumeId == XDataCenter.ItemManager.ItemId.Coin then + num = XDataCenter.ItemManager.GetCoinsNum() + end + if self.Data.ConsumeId == XDataCenter.ItemManager.ItemId.FreeGem or targetId == XDataCenter.ItemManager.ItemId.PaidGem then + num = XDataCenter.ItemManager.GetTotalGemsNum() + end + if self.Data.ConsumeId == XDataCenter.ItemManager.ItemId.ActionPoint then + num = XDataCenter.ItemManager.GetActionPointsNum() .. "/" .. XDataCenter.ItemManager.GetMaxActionPoints() + end + if self.Data.ConsumeId == XDataCenter.ItemManager.ItemId.SkillPoint then + num = XDataCenter.ItemManager.GetSkillPointNum() + end + if num == "?" then + local item = XDataCenter.ItemManager.GetItem(self.Data.ConsumeId[self.curConsumeIdIndex]) + num = item.Count + --if item.Template.MaxCount > 0 then + --num = num .. "/" .. item.Template.MaxCount + --end + end + + local curStateIcon = XDataCenter.ItemManager.GetItemIcon(self.Data.ConsumeId[self.curConsumeIdIndex]) + local curStateName = CS.XTextManager.GetText("AtPresent") + local curStateCount = num + + -- 消耗道具信息 + local consumeIcon = XDataCenter.ItemManager.GetItemIcon(self.Data.ConsumeId[self.curConsumeIdIndex]) + local consumeName = XDataCenter.ItemManager.GetItemName(self.Data.ConsumeId[self.curConsumeIdIndex]) + local consumeCount = self.Data.ConsumeCount[self.curConsumeIdIndex] * (self.BuyAmount or 1) + -- 获取道具信息 + local targetIcon = XDataCenter.ItemManager.GetItemIcon(self.Data.TargetId) + local targetName = XDataCenter.ItemManager.GetItemName(self.Data.TargetId) + local targetCount = self.Data.TargetCount * (self.BuyAmount or 1) + + -- 修改Ui + self.TxtCurStateName.text = curStateName + self.TxtCurStateCount.text = curStateCount + if curStateIcon ~= nil then + self.RawImageCurState:SetRawImage(curStateIcon) + end + + self.Time.gameObject:SetActiveEx(self.Data.LeftTimes ~= nil) + self.TxtTimes.text = self.Data.LeftTimes == nil and "∞" or self.Data.LeftTimes + + self.TxtConsumeCount.text = consumeCount + self.TxtConsumeName.text = consumeName + if consumeIcon ~= nil then + self.RawImageConsume:SetRawImage(consumeIcon) + end + + self.TxtTargetCount.text = targetCount + self.TxtTargetName.text = targetName + self.TargetText.text = targetName + if targetIcon ~= nil then + self.RawImageTarget:SetRawImage(targetIcon) + self.TargetImg:SetRawImage(targetIcon) + end + self:CheckBuyAmount() + self.TxtSelect.text = tostring(self.BuyAmount) +end + +function XUiBuyAsset:RefreshChallengeCount(challengeCountData) + self.ChallengeCountData = challengeCountData + + local active = self.ChallengeCountData.BuyCount < self.ChallengeCountData.BuyChallengeCount + self.PanelInfo.gameObject:SetActiveEx(active) + self.PanelMax.gameObject:SetActiveEx(not active) + self.BtnCancel.gameObject:SetActiveEx(active) + self.BtnConfirm.gameObject:SetActiveEx(active) + + local num = (self.ChallengeCountData.MaxChallengeNums - self.ChallengeCountData.PassTimesToday) .. " / " .. self.ChallengeCountData.MaxChallengeNums + + local curStateName = CS.XTextManager.GetText("CanChallegeCount") + local curStateCount = "" .. num .. "" + + local consumeName = XDataCenter.ItemManager.GetItemName(XDataCenter.ItemManager.ItemId.FreeGem) + local consumeCount = self.ChallengeCountData.BuyChallengeCost + + local targetCount = 1 + local targetName = CS.XTextManager.GetText("BuyChallegeDesc") + + self.TxtCurStateName.text = curStateName + self.TxtCurStateCount.text = curStateCount + self.TxtTimes.text = self.ChallengeCountData.BuyChallengeCount - self.ChallengeCountData.BuyCount + self.TxtConsumeCount.text = consumeCount + self.TxtConsumeName.text = consumeName + self.TxtTargetCount.text = targetCount + self.TxtTargetName.text = targetName +end + +function XUiBuyAsset:OnBtnChallengeCountClick() + if not XDataCenter.ItemManager.CheckItemCountById(XDataCenter.ItemManager.ItemId.FreeGem, self.ChallengeCountData.BuyChallengeCost) then + local itemName = XDataCenter.ItemManager.GetItemName(XDataCenter.ItemManager.ItemId.FreeGem) + local text = CS.XTextManager.GetText('AssetsBuyConsumeNotEnough', itemName) + XUiManager.TipMsg(text, XUiManager.UiTipType.Tip) + return + end + + local callback = function() + local name = CS.XTextManager.GetText("BuyChallegeDesc") + XUiManager.TipMsg(CS.XTextManager.GetText("Buy") .. CS.XTextManager.GetText("Success") .. "," .. CS.XTextManager.GetText("Acquire") .. 1 .. name, XUiManager.UiTipType.Tip) + if self.SuccessCallback then + self.SuccessCallback() + end + local challengeCountData = XDataCenter.FubenMainLineManager.GetStageBuyChallengeData(self.ChallengeCountData.StageId) + self:RefreshChallengeCount(challengeCountData) + end + XDataCenter.FubenMainLineManager.BuyMainLineChallengeCount(callback, self.ChallengeCountData.StageId) +end + +--是否显示或隐藏加减按钮 +function XUiBuyAsset:SetCanMutiply(val) + self.BtnAddSelect.gameObject:SetActive(val) + self.BtnMinusSelect.gameObject:SetActive(val) + self.TxtSelect.gameObject:SetActive(val) +end + +--根据WinType初始化Ui类型 +function XUiBuyAsset:InitUiType() + self.Data = XDataCenter.ItemManager.GetBuyAssetInfo(self.Id) + + if self.WinType == WinType[1] then + self.FurnitureBlueItem.gameObject:SetActiveEx(false) + self:SetCanMutiply(false) + self.BtnExchangeSource.gameObject:SetActiveEx(false) + else + self.TargetCount.gameObject:SetActiveEx(false) + self.CurState.gameObject:SetActiveEx(false) + + --修改标题 + self.PanelTitle.text = CS.XTextManager.GetText("BuyAssetPanelTitle") + + --显示或隐藏多选 + local canMutiply = XItemConfigs.GetBuyAssetCanMutiply(self.Id) + if canMutiply == nil or canMutiply == 0 or canMutiply == 1 then + self:SetCanMutiply(false) + else + self:SetCanMutiply(true) + end + + --显示或隐藏兑换转换按钮 + if #self.Data.ConsumeId <= 1 then + self.BtnExchangeSource.gameObject:SetActiveEx(false) + else + self.BtnExchangeSource.gameObject:SetActiveEx(true) + self.BtnExchangeSource.CallBack = function() + self:BtnChangeSourceClick() + end + local nextConsumeIdIndex = self.curConsumeIdIndex + 1 + if nextConsumeIdIndex > #self.Data.ConsumeId then + nextConsumeIdIndex = 1 + end + local curentConsuleName = XDataCenter.ItemManager.GetItemName(self.Data.ConsumeId[nextConsumeIdIndex]) + self.BtnExchangeSource:SetName(curentConsuleName) + end + end +end + +--兑换转换按钮点击 +function XUiBuyAsset:BtnChangeSourceClick() + local currentConsuleName + + self.curConsumeIdIndex = self.curConsumeIdIndex + 1 + if self.curConsumeIdIndex > #self.Data.ConsumeId then + self.curConsumeIdIndex = 1 + end + + local nextConsumeIdIndex = self.curConsumeIdIndex + 1 + if nextConsumeIdIndex > #self.Data.ConsumeId then + nextConsumeIdIndex = 1 + end + + currentConsuleName = XDataCenter.ItemManager.GetItemName(self.Data.ConsumeId[nextConsumeIdIndex]) + self.BtnExchangeSource:SetName(currentConsuleName) + self:Refresh(self.Id) +end + +function XUiBuyAsset:OnBtnAddSelectClick() + self.BuyAmount = self.BuyAmount + 1 + self:CheckBuyAmount() + self:Refresh(self.Id) +end + +function XUiBuyAsset:OnBtnMinusSelectClick() + self.BuyAmount = self.BuyAmount - 1 + if self.BuyAmount < 1 then + self.BuyAmount = 1 + end + self:Refresh(self.Id) +end + +function XUiBuyAsset:OnSelectTextChange() + if self.TxtSelect.text == nil or self.TxtSelect.text == "" then + return + end + + if self.TxtSelect.text == "0" then + self.TxtSelect.text = 1 + end + + self.BuyAmount = tonumber(self.TxtSelect.text) + self:CheckBuyAmount() + self:Refresh(self.Id) +end + +--监测输入框最大数字 +function XUiBuyAsset:CheckBuyAmount() + if self.Data.LeftTimes ~= nil and self.BuyAmount > self.Data.LeftTimes then + if self.Data.LeftTimes == 0 then + self.BuyAmount = 1 + else + self.BuyAmount = self.Data.LeftTimes + end + end +end + +function XUiBuyAsset:OnBtnMoneyPackageExchangeClicked() + self:Close() + XLuaUiManager.Open("UiUseCoinPackage") +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiBuyAsset/XUiCoinPackage.lua b/Resources/Scripts/XUi/XUiBuyAsset/XUiCoinPackage.lua new file mode 100644 index 00000000..a576a7d8 --- /dev/null +++ b/Resources/Scripts/XUi/XUiBuyAsset/XUiCoinPackage.lua @@ -0,0 +1,107 @@ +local XUiCoinPackage = XClass(nil, "XUiCoinPackage") +local COINPACKAGE_OVER_NUM_TIP = CS.XTextManager.GetText("ChoiseNutPackageOver") +local REWARD_CONFIG_INDEX = 2 +local MINUS_LONG_TRIGGER_TIME = 300 + +function XUiCoinPackage:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + -- 当前的item信息 + self.Item = nil + self.Index = 0 + self.UseCoinPackageUi = nil + self.EffectNum = 0 + XTool.InitUiObject(self) + -- 重新注册下ui组件名字 + self.BtnSelf = self.BtnClick + self.BtnMinus = self.BtnMinusSelect + self.TxtSelectCount = self.TxtSelectHide + self:RegisterUiEvents() + -- 螺母包目前没有时间限制 + self.TimeTag.gameObject:SetActiveEx(false) +end + +-- useCoinPackageUi:XUiUseCoinPackage +function XUiCoinPackage:DynamicSetData(item, index, useCoinPackageUi) + self.Item = item + self.Index = index + self.UseCoinPackageUi = useCoinPackageUi + local rewards = XRewardManager.GetRewardList(item.Data.Template.SubTypeParams[REWARD_CONFIG_INDEX]) + self.EffectNum = rewards[1].Count + -- 设置图标 + local goodsShowParams = XGoodsCommonManager.GetGoodsShowParamsByTemplateId(item.Data.Id) + self.RImgIcon:SetRawImage(goodsShowParams.Icon) + -- 物品数量 + self.TxtCount.text = CS.XTextManager.GetText("ShopGridCommonCount", item.Count) + -- 品质 + if goodsShowParams.QualityIcon then + useCoinPackageUi:SetUiSprite(self.ImgQuality, goodsShowParams.QualityIcon) + else + XUiHelper.SetQualityIcon(useCoinPackageUi, self.ImgQuality, goodsShowParams.Quality) + end + self:SetSelectedGosActive(false) +end + +function XUiCoinPackage:OnSelfClicked() + local currentSelectCount = self.UseCoinPackageUi:GetSelectItemCount(self.Index) + if currentSelectCount >= self.Item.Count then + XUiManager.TipMsg(COINPACKAGE_OVER_NUM_TIP) + return + end + self:SetSelectCount(currentSelectCount + 1) +end + +--######################## 私有方法 ######################## + +function XUiCoinPackage:RegisterUiEvents() + self.BtnSelf.CallBack = function() self:OnSelfClicked() end + -- 添加长按事件 + local btnSelfClickPointer = self.BtnSelf.gameObject:GetComponent("XUiPointer") + XUiButtonLongClick.New(btnSelfClickPointer, 90, self, nil, self.OnBtnSelfLongClick, nil, true) + local btnMinusPointer = self.BtnMinus.gameObject:GetComponent("XUiPointer") + XUiButtonLongClick.New(btnMinusPointer, 10, self, nil, self.OnBtnMinusLongClick, nil, true) + self.BtnMinus.CallBack = function() self:OnBtnMinusClicked() end +end + +function XUiCoinPackage:OnBtnSelfLongClick(time) + local currentSelectCount = self.UseCoinPackageUi:GetSelectItemCount(self.Index) + if currentSelectCount >= self.Item.Count then + XUiManager.TipMsg(COINPACKAGE_OVER_NUM_TIP) + return + end + self:SetSelectCount(currentSelectCount + 1) +end + +function XUiCoinPackage:SetSelectCount(count) + self.UseCoinPackageUi:CacheSelectItemCount(self.Index, count, self.EffectNum) + self:SetSelectedGosActive(count > 0) + self.BtnMinus:SetButtonState(CS.UiButtonState.Normal) + self.TxtSelectCount.text = count +end + +function XUiCoinPackage:SetSelectedGosActive(isActive) + self.TxtSelectCount.gameObject:SetActiveEx(isActive) + self.BtnMinus.gameObject:SetActiveEx(isActive) + self.ImgSelect.gameObject:SetActiveEx(isActive) +end + +function XUiCoinPackage:OnBtnMinusClicked() + local currentSelectCount = self.UseCoinPackageUi:GetSelectItemCount(self.Index) + if currentSelectCount <= 0 then + return + end + self:SetSelectCount(currentSelectCount - 1) +end + +function XUiCoinPackage:OnBtnMinusLongClick(time) + if time <= MINUS_LONG_TRIGGER_TIME then + return + end + local currentSelectCount = self.UseCoinPackageUi:GetSelectItemCount(self.Index) + if currentSelectCount <= 0 then + return + end + self:SetSelectCount(0) +end + +return XUiCoinPackage \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiBuyAsset/XUiUseCoinPackage.lua b/Resources/Scripts/XUi/XUiBuyAsset/XUiUseCoinPackage.lua new file mode 100644 index 00000000..7fb10269 --- /dev/null +++ b/Resources/Scripts/XUi/XUiBuyAsset/XUiUseCoinPackage.lua @@ -0,0 +1,156 @@ +local XUiCoinPackage = require("XUi/XUiBuyAsset/XUiCoinPackage") +local XUiUseCoinPackage = XLuaUiManager.Register(XLuaUi, "UiUseCoinPackage") +local NOT_SELECT_TIP = CS.XTextManager.GetText("UseNutPackage") +local OVER_MAX_COUNT_TIP = CS.XTextManager.GetText("NutOverMaxCount") + +function XUiUseCoinPackage:OnAwake() + -- 重新注册下名字 + self.ItemScrollView = self.ElectricPackageScroll + self.TxtCount = self.TxtCurrentElectric + self.TxtGetCount = self.TxtElectricNumPackage + self.BtnExchange = self.BtnElectricExchange + -- 隐藏/显示关联的对象 + --self.TxtElectricNumPackage.gameObject:SetActiveEx(false) + --self.PanelCurrentElectricItem.gameObject:SetActiveEx(false) + --self.TxtCoinGetCount.gameObject:SetActiveEx(true) + --self.PanelCurrentCoinItem.gameObject:SetActiveEx(true) + -- 其他变量 + self.Items = {} + --[[ + { + [index] = { + SelectCount, + EffectNum, + } + } + ]] + self.CurrentSelectItemInfo = {} + self.ItemId = nil + self.GridCommonPopUp.gameObject:SetActiveEx(false) + self:RegisterUiEvents() + -- 初始化动态列表 + self.DynamicTable = XDynamicTableNormal.New(self.ItemScrollView) + self.DynamicTable:SetProxy(XUiCoinPackage) + self.DynamicTable:SetDelegate(self) +end + +function XUiUseCoinPackage:OnEnable() + self.ItemId = XDataCenter.ItemManager.ItemId.Coin + self:RefreshCurrentCount() + self:RefreshDynamicTable() + self.TxtGetCount.text = 0 +end + +function XUiUseCoinPackage:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:DynamicSetData(self.Items[index], index, self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_RELOAD_COMPLETED then + self:SetDefaultSeleteItem() + end +end + +-- 缓存选择的item的数量 +function XUiUseCoinPackage:CacheSelectItemCount(index, count, effectNum) + self.CurrentSelectItemInfo[index] = self.CurrentSelectItemInfo[index] or {} + -- 做一个总获取数量的计算 + local diffCount = count - (self.CurrentSelectItemInfo[index].SelectCount or 0) + self.TxtGetCount.text = tonumber(self.TxtGetCount.text) + diffCount * effectNum + if count <= 0 then + self.CurrentSelectItemInfo[index] = nil + else + self.CurrentSelectItemInfo[index].SelectCount = count + self.CurrentSelectItemInfo[index].EffectNum = effectNum + end +end + +function XUiUseCoinPackage:GetSelectItemCount(index) + return self.CurrentSelectItemInfo[index] and self.CurrentSelectItemInfo[index].SelectCount or 0 +end + +--######################## 私有方法 ######################## + +function XUiUseCoinPackage:RegisterUiEvents() + self.BtnCancel.CallBack = function () + self:Close() + end + self.BtnTanchuangClose.CallBack = function () + self:Close() + end + self.BtnConfirm.CallBack = function() self:OnBtnConfirmClicked() end + self.BtnExchange.CallBack = function() self:OnBtnExchangeClicked() end +end + +function XUiUseCoinPackage:RefreshDynamicTable() + self.Items = XDataCenter.ItemManager.GetCoinPackages() + self.ImgEmpty.gameObject:SetActiveEx(#self.Items <= 0) + self.DynamicTable:SetDataSource(self.Items) + self.DynamicTable:ReloadDataSync(1) +end + +function XUiUseCoinPackage:SetDefaultSeleteItem() + local firstGrid = self.DynamicTable:GetGridByIndex(1) + if firstGrid then + firstGrid:OnSelfClicked() + end +end + +function XUiUseCoinPackage:OnBtnConfirmClicked() + -- 检查是否有选择要使用的物品 + if not next(self.CurrentSelectItemInfo) then + XUiManager.TipError(NOT_SELECT_TIP) + return + end + if XDataCenter.ItemManager.GetCount(self.ItemId) >= XDataCenter.ItemManager.GetMaxCount(self.ItemId) then + XUiManager.TipError(OVER_MAX_COUNT_TIP) + return + end + local totalRewardGoodList = {} + local lastUseIndex = nil + local useItemFunction = function(useIndex, count, callback) + local useItem = self.Items[useIndex] + if not useItem then return end + local recycleTime = useItem.RecycleBatch and useItem.RecycleBatch.RecycleTime + XDataCenter.ItemManager.Use(useItem.Data.Id, recycleTime, count, callback) + end + local addRewardGoodCallback = function(rewardGoodList) + if rewardGoodList and rewardGoodList[1] then + table.insert(totalRewardGoodList, rewardGoodList[1]) + end + end + for index, selectedItemInfo in pairs(self.CurrentSelectItemInfo) do + if selectedItemInfo.SelectCount > 0 then + if lastUseIndex then + useItemFunction(lastUseIndex, self.CurrentSelectItemInfo[lastUseIndex].SelectCount, addRewardGoodCallback) + end + lastUseIndex = index + end + end + local finishedCallback = function(rewardGoodList) + if rewardGoodList and rewardGoodList[1] then + table.insert(totalRewardGoodList, rewardGoodList[1]) + end + -- 刷新最新资源数据 + self.TxtGetCount.text = 0 + self.CurrentSelectItemInfo = {} + self:RefreshCurrentCount() + -- 刷新列表 + self:RefreshDynamicTable() + XUiManager.OpenUiObtain(totalRewardGoodList) + end + useItemFunction(lastUseIndex, self.CurrentSelectItemInfo[lastUseIndex].SelectCount, finishedCallback) +end + +function XUiUseCoinPackage:OnBtnExchangeClicked() + self:Close() + XLuaUiManager.Open("UiBuyAsset", self.ItemId) +end + +function XUiUseCoinPackage:RefreshCurrentCount() + self.TxtCount.text = XDataCenter.ItemManager.GetCount(self.ItemId) + self.TxtCurrentDes.text = CS.XTextManager.GetText("BuyAssetCurNutCaseTxtDesc")--获得螺母 + self.TxtCurItemName.text = CS.XTextManager.GetText("BuyAssetCurNutCaseNameDesc")--现在的螺母 + self.ImgIcon:SetRawImage(XDataCenter.ItemManager.GetItemIcon(self.ItemId)) + self.CurrencyText1.gameObject:SetActive(false) +end + +return XUiUseCoinPackage \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiBuyAsset/XUiUsePackage.lua b/Resources/Scripts/XUi/XUiBuyAsset/XUiUsePackage.lua new file mode 100644 index 00000000..3d18b2a0 --- /dev/null +++ b/Resources/Scripts/XUi/XUiBuyAsset/XUiUsePackage.lua @@ -0,0 +1,225 @@ +local XUiUsePackage = XLuaUiManager.Register(XLuaUi, "UiUsePackage") + +local DefaultIndex = 1 +local SelectItemList = {} + +local tableInsert = table.insert + +function XUiUsePackage:OnStart(id, successCallback, challengeCountData, buyAmount) + self.SuccessCallback = successCallback + self.BuyAmount = buyAmount + self.ChallengeCountData = challengeCountData + self:InitDynamicTable() + self.Id = id + self:SetTxtElectricNumPackage(0) + self:Refresh(id) + self:AddBtnCallBack() + if self.Data.TargetId == XDataCenter.ItemManager.ItemId.ActionPoint then + self.Timers = XScheduleManager.ScheduleForever(function() self:SetRecTime() end, XScheduleManager.SECOND) + end + CsXGameEventManager.Instance:Notify(XEventId.EVENT_UIDIALOG_VIEW_ENABLE) +end + + +function XUiUsePackage:OnDestroy() + if self.Timers then + XScheduleManager.UnSchedule(self.Timers) + self.Timers = nil + end +end + +function XUiUsePackage:AddBtnCallBack() + self.BtnCancel.CallBack = function() + self:OnBtnCancelClick() + end + self.BtnConfirm.CallBack = function() + self:OnBtnConfirmClick() + end + self.BtnTanchuangClose.CallBack = function() + self:OnBtnCloseClick() + end + self.BtnElectricExchange.CallBack = function() + self:OnBtnShowTypeClick() + end +end +-- auto +function XUiUsePackage:OnBtnShowTypeClick() + self:Close() + XLuaUiManager.Open("UiBuyAsset", self.Id, self.SuccessCallback, self.ChallengeCountData, self.BuyAmount) +end + +function XUiUsePackage:OnBtnCloseClick() + self:Close() +end + +function XUiUsePackage:OnBtnCancelClick() + self:Close() +end + +function XUiUsePackage:SetPanelType(targetId) + self.Data = XDataCenter.ItemManager.GetBuyAssetInfo(targetId) + self.TxtElectricDesc.gameObject:SetActiveEx(false) + self.TxtElectricNumPackage.gameObject:SetActiveEx(true) + + if self.Data.TargetId == XDataCenter.ItemManager.ItemId.ActionPoint then + if not XDataCenter.ItemManager.CheckBatteryIsHave() then + self.ImgEmpty.gameObject:SetActiveEx(true) + else + self.ImgEmpty.gameObject:SetActiveEx(false) + end + + self:SetupDynamicTable() + end +end + +function XUiUsePackage:SetRecTime() + local time = XDataCenter.ItemManager.GetActionPointsRefreshResidueSecond() + self.TxtRecoverTime.text = CS.XTextManager.GetText("RecActPoint", XUiHelper.GetTime(time, XUiHelper.TimeFormatType.ONLINE_BOSS)) + self.TxtCurrentElectric.text = XDataCenter.ItemManager.GetActionPointsNum() .. "/" .. XDataCenter.ItemManager.GetMaxActionPoints() + if time == 0 then + self.TxtRecoverTime.text = "" + end +end + +function XUiUsePackage:OnBtnConfirmClick() + if not next(SelectItemList) then + XUiManager.TipError(CS.XTextManager.GetText("UseBattery")) + return + elseif self:CheckActionPointOverLimit() then + XUiManager.TipError(CS.XTextManager.GetText("OverLimitCanNotUse")) + return + end + + local lastUseIndex + local totalRewardGoodsList = {} + local useItemFunction = function(useIndex, count, callback) + local selectItem = self.BatteryDatas[useIndex] + if selectItem then + local recycleTime = selectItem.RecycleBatch and selectItem.RecycleBatch.RecycleTime + XDataCenter.ItemManager.Use(selectItem.Data.Id, recycleTime, count, callback) + end + end + + local addRewardGoodsListCallback = function(rewardGoodsList) + if rewardGoodsList and rewardGoodsList[1] then + tableInsert(totalRewardGoodsList, rewardGoodsList[1]) + end + end + for index, itemList in pairs(SelectItemList) do + if itemList.SelectItemCount > 0 then + if lastUseIndex then + useItemFunction(lastUseIndex, SelectItemList[lastUseIndex].SelectItemCount, addRewardGoodsListCallback) + end + lastUseIndex = index + end + end + + local callback = function(rewardGoodsList) + self:SetPanelType(self.Id) + if self.SuccessCallback then + self.SuccessCallback() + end + tableInsert(totalRewardGoodsList, rewardGoodsList[1]) + XUiManager.OpenUiObtain(totalRewardGoodsList) + end + useItemFunction(lastUseIndex, SelectItemList[lastUseIndex].SelectItemCount, callback) +end + +function XUiUsePackage:Refresh(targetId) + self:SetPanelType(targetId) + local active = self.Data ~= nil + self.PanelInfo.gameObject:SetActiveEx(active) + self.TxtCurrentElectric.text = XDataCenter.ItemManager.GetActionPointsNum() .. "/" .. XDataCenter.ItemManager.GetMaxActionPoints() +end + +function XUiUsePackage:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.ElectricPackageScroll) + self.DynamicTable:SetProxy(XUiBattery) + self.DynamicTable:SetDelegate(self) + self.GridCommonPopUp.gameObject:SetActiveEx(false) +end + +function XUiUsePackage:SetupDynamicTable() + self.BatteryDatas = XDataCenter.ItemManager.GetCurBatterys() + self:RefreshSelectItemList() + self.DynamicTable:SetDataSource(self.BatteryDatas) + self.DynamicTable:ReloadDataSync(1) +end + +function XUiUsePackage:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:UpdateGrid(self.BatteryDatas[index], self, index) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_RECYCLE then + grid:OnRecycle() + end +end + +function XUiUsePackage:CheckActionPointOverLimit() + local ActionPoint = XDataCenter.ItemManager.GetItem(XDataCenter.ItemManager.ItemId.ActionPoint) + local totalSelectItemElectricNum = 0 + for index, itemList in pairs(SelectItemList) do + totalSelectItemElectricNum = totalSelectItemElectricNum + itemList.OnecElectricNum * itemList.SelectItemCount + end + if totalSelectItemElectricNum + ActionPoint:GetCount() > ActionPoint.Template.MaxCount then + return true + end + return false +end + +function XUiUsePackage:SetTxtElectricNumPackage(num) + if num >= 0 then + self.TxtElectricNumPackage.text = num + end +end + +function XUiUsePackage:SetSelectItemCount(index, selectItemCount, onecElectricNum) + self:UpdateSelectItemList(index, selectItemCount, onecElectricNum) + self:SetTxtElectricNumPackage(tonumber(self.TxtElectricNumPackage.text) + onecElectricNum) +end + +function XUiUsePackage:UpdateSelectItemList(index, selectItemCount, onecElectricNum) + if not SelectItemList[index] then + SelectItemList[index] = {} + end + SelectItemList[index]["SelectItemCount"] = selectItemCount + SelectItemList[index]["OnecElectricNum"] = onecElectricNum +end + +function XUiUsePackage:GetSelectItemCountByIndex(index) + return SelectItemList[index] and SelectItemList[index]["SelectItemCount"] or 0 +end + +function XUiUsePackage:GetOnecElectricNumByIndex(index) + return SelectItemList[index] and SelectItemList[index]["OnecElectricNum"] or 0 +end + +function XUiUsePackage:SubSelectItemCountByIndex(index) + local selectItemCount = self:GetSelectItemCountByIndex(index) + if selectItemCount <= 0 then + return + end + local onecElectricNum = self:GetOnecElectricNumByIndex(index) + self:UpdateSelectItemList(index, selectItemCount - 1, onecElectricNum) + self:SetTxtElectricNumPackage(tonumber(self.TxtElectricNumPackage.text) - onecElectricNum) + if self:GetSelectItemCountByIndex(index) <= 0 then + SelectItemList[index] = nil + end +end + +function XUiUsePackage:ClearSelectItemCountByIndex(index) + local onecElectricNum = self:GetOnecElectricNumByIndex(index) + local selectItemCount = self:GetSelectItemCountByIndex(index) + self:SetTxtElectricNumPackage(tonumber(self.TxtElectricNumPackage.text) - onecElectricNum * selectItemCount) + SelectItemList[index] = nil +end + +function XUiUsePackage:RefreshSelectItemList() + self:SetTxtElectricNumPackage(0) + SelectItemList = {} + if self.BatteryDatas and self.BatteryDatas[DefaultIndex] then + local goodsId = 1 + local rewardIndex = 2 + local goodsList = XRewardManager.GetRewardList(self.BatteryDatas[DefaultIndex].Data.Template.SubTypeParams[rewardIndex]) + self:SetSelectItemCount(DefaultIndex, 1, goodsList[goodsId].Count) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCharacter/XUiCharSkillOtherParsing.lua b/Resources/Scripts/XUi/XUiCharacter/XUiCharSkillOtherParsing.lua new file mode 100644 index 00000000..de39bd08 --- /dev/null +++ b/Resources/Scripts/XUi/XUiCharacter/XUiCharSkillOtherParsing.lua @@ -0,0 +1,47 @@ +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate + +local XUiCharSkillOtherParsing = XLuaUiManager.Register(XLuaUi, "UiCharSkillOtherParsing") + +function XUiCharSkillOtherParsing:OnAwake() + self:AutoAddListener() + + self.GridEntry.gameObject:SetActiveEx(false) +end + +function XUiCharSkillOtherParsing:OnStart(entryList) + self.EntryList = entryList + self.EntryGrids = {} + self:InitCanvasOrder() + self:Refresh() +end + +function XUiCharSkillOtherParsing:InitCanvasOrder() + local canvas = self.Transform:GetComponent("Canvas") + + local scrollCanvas = self.Transform.parent:FindTransformWithSplit("PaneSkillInfo/PanelScroll"):GetComponent("Canvas") + scrollCanvas.sortingOrder = canvas.sortingOrder + 1 +end + +function XUiCharSkillOtherParsing:AutoAddListener() + self.BtnClose.IsEventPass = true + self:RegisterClickEvent(self.BtnClose, self.Close) +end + +function XUiCharSkillOtherParsing:Refresh() + for index, entry in ipairs(self.EntryList) do + local grid = self.EntryGrids[index] + if not grid then + local ui = index == 1 and self.GridEntry or CSUnityEngineObjectInstantiate(self.GridEntry, self.PanelEntry) + grid = XTool.InitUiObjectByUi({}, ui) + self.EntryGrids[index] = grid + end + + grid.TxtTitle.text = entry.Name + grid.TxtDesc.text = entry.Desc + + grid.GameObject:SetActiveEx(true) + end + for index = #self.EntryList + 1, #self.EntryGrids do + self.EntryGrids[index].GameObject:SetActiveEx(false) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCharacter/XUiCharacter.lua b/Resources/Scripts/XUi/XUiCharacter/XUiCharacter.lua new file mode 100644 index 00000000..67f33497 --- /dev/null +++ b/Resources/Scripts/XUi/XUiCharacter/XUiCharacter.lua @@ -0,0 +1,516 @@ +local XUiGridCharacterNew = require("XUi/XUiCharacter/XUiGridCharacterNew") + +local CSXTextManagerGetText = CS.XTextManager.GetText + +local CAMERA_NUM = 5 +local TabBtnIndex = { + Normal = 1, + Isomer = 2, +} +local CharacterTypeConvert = { + [TabBtnIndex.Normal] = XCharacterConfigs.CharacterType.Normal, + [TabBtnIndex.Isomer] = XCharacterConfigs.CharacterType.Isomer, +} +local LastSelectTabBtnIndex + +local XUiCharacter = XLuaUiManager.Register(XLuaUi, "UiCharacter") + +function XUiCharacter:OnAwake() + self:InitDynamicTable() + self:AutoAddListener() + + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self.GridCharacterNew.gameObject:SetActiveEx(false) + self.PanelTeamBtn.gameObject:SetActiveEx(false) + + self.LogoCharacterGouzaoti.gameObject:SetActiveEx(false) + self.LogoCharacterShougezhe.gameObject:SetActiveEx(false) + + local tempGo = self.Transform:Find("SafeAreaContentPane/BtnLensOut") + if not XTool.UObjIsNil(tempGo) then + tempGo.gameObject:SetActiveEx(false) + end + self.OnUiSceneLoadedCB = function(lastSceneUrl) self:OnUiSceneLoaded(lastSceneUrl) end + + XDataCenter.RoomCharFilterTipsManager.Reset() +end + +function XUiCharacter:OnStart(characterId, _, openFromTeamInfo, forbidGotoEquip, skipToProperty, isSupport, supportData) + self:InitSceneRoot() + + if openFromTeamInfo then + self.TeamCharIdMap = openFromTeamInfo.TeamCharIdMap + self.TeamSelectPos = openFromTeamInfo.TeamSelectPos + self.TeamResultCb = openFromTeamInfo.TeamResultCb + end + + if forbidGotoEquip then + self.BtnOwnedDetail.gameObject:SetActiveEx(false) + self.BtnFashion.gameObject:SetActiveEx(false) + self.ForbidGotoEquip = true + end + + if isSupport then + self.BtnOwnedDetail.gameObject:SetActiveEx(false) + self.BtnFashion.gameObject:SetActiveEx(false) + self.IsSupport = true + end + + if not XTool.IsTableEmpty(supportData) then + self.BtnShaixuan.gameObject:SetActiveEx(false) + self.BtnShengxu.gameObject:SetActiveEx(false) + self.BtnJiangxu.gameObject:SetActiveEx(false) + end + + self.SkipToProperty = skipToProperty + self.SupportData = supportData + + if characterId then + self.CharacterId = characterId + self.SelectTabBtnIndex = XCharacterConfigs.IsIsomer(characterId) and TabBtnIndex.Isomer or TabBtnIndex.Normal + else + -- 切换账号后不满足感染体解锁条件将上次记录强转成构造体 + if LastSelectTabBtnIndex and LastSelectTabBtnIndex == TabBtnIndex.Isomer then + if not XFunctionManager.JudgeOpen(XFunctionManager.FunctionName.Isomer) + or XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.Isomer) then + LastSelectTabBtnIndex = TabBtnIndex.Normal + end + end + + self.SelectTabBtnIndex = LastSelectTabBtnIndex or TabBtnIndex.Normal + end + + self.IsAscendOrder = false --初始降序 + self:CheckBtnFilterActive() + + self.BtnTabShougezhe.gameObject:SetActiveEx(not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.Isomer)) + self.BtnTabShougezhe:SetDisable(not XFunctionManager.JudgeOpen(XFunctionManager.FunctionName.Isomer)) + local tabBtns = { self.BtnTabGouzaoti, self.BtnTabShougezhe } + self.PanelCharacterTypeBtns:Init(tabBtns, function(index) self:OnSelectCharacterType(index) end) + self.LastChacaterFashionSceneUrl = nil +end + +function XUiCharacter:OnEnable() + CS.XGraphicManager.UseUiLightDir = true + -- 父UI的OnEnable中无法正确检测子UI的打开关闭状态,故需自己维护一个变量 + if not self.ChildOpen then + self.PanelCharacterTypeBtns:SelectIndex(self.SelectTabBtnIndex) + else + self:UpdateCurCharacterInfo(self.CharacterId) + end +end + +function XUiCharacter:OnDisable() + CS.XGraphicManager.UseUiLightDir = false +end + +function XUiCharacter:OnDestroy() + LastSelectTabBtnIndex = self.SelectTabBtnIndex + XDataCenter.RoomCharFilterTipsManager.Reset() +end + +function XUiCharacter:OnGetEvents() + return { XEventId.EVENT_CHARACTER_SYN } +end + +function XUiCharacter:OnNotify(evt, ...) + local args = { ... } + local characterId = args[1] + + if evt == XEventId.EVENT_CHARACTER_SYN then + self:UpdateCharacterList(characterId) + end +end + +function XUiCharacter:InitSceneRoot() + local root = self.UiModelGo.transform + + -- if self.PanelRoleModel then + -- self.PanelRoleModel:DestroyChildren() + -- end + self.PanelRoleModel = root:FindTransform("PanelRoleModel") + self.ImgEffectHuanren = root:FindTransform("ImgEffectHuanren") + self.ImgEffectHuanren1 = root:FindTransform("ImgEffectHuanren1") + self.ImgEffectLogoGouzao = root:FindTransform("ImgEffectLogoGouzao") + self.ImgEffectLogoGanran = root:FindTransform("ImgEffectLogoGanran") + self.CameraFar = { + root:FindTransform("UiCamFarLv"), + root:FindTransform("UiCamFarGrade"), + root:FindTransform("UiCamFarQuality"), + root:FindTransform("UiCamFarSkill"), + root:FindTransform("UiCamFarrExchange"), + } + self.CameraNear = { + root:FindTransform("UiCamNearLv"), + root:FindTransform("UiCamNearGrade"), + root:FindTransform("UiCamNearQuality"), + root:FindTransform("UiCamNearSkill"), + root:FindTransform("UiCamNearrExchange"), + } + self.RoleModelPanel = XUiPanelRoleModel.New(self.PanelRoleModel, self.Name, nil, true, nil, true) +end + +function XUiCharacter:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.SViewCharacterList) + self.DynamicTable:SetProxy(XUiGridCharacterNew) + self.DynamicTable:SetDelegate(self) +end + +function XUiCharacter:OnSelectCharacterType(index) + if index == TabBtnIndex.Isomer and not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.Isomer) then + return + end + + self.SelectTabBtnIndex = index + if index == TabBtnIndex.Normal then + self.ImgEffectLogoGouzao.gameObject:SetActiveEx(true) + self.ImgEffectLogoGanran.gameObject:SetActiveEx(false) + self:UpdateCharacterList(self.LastSelectNormalCharacterId) + elseif index == TabBtnIndex.Isomer then + self.ImgEffectLogoGouzao.gameObject:SetActiveEx(false) + self.ImgEffectLogoGanran.gameObject:SetActiveEx(true) + self:UpdateCharacterList(self.LastSelectIsomerCharacterId) + end +end + +function XUiCharacter:UpdateCharacterList(characterId) + local characterType = CharacterTypeConvert[self.SelectTabBtnIndex] + if characterId then + --选中角色与当前类型页签不符时,强制选中对应角色类型页签 + self.CharacterId = characterId + local paramCharacterType = XCharacterConfigs.GetCharacterType(characterId) + if paramCharacterType ~= characterType then + if XCharacterConfigs.IsIsomer(characterId) then + self.LastSelectIsomerCharacterId = characterId + self.PanelCharacterTypeBtns:SelectIndex(TabBtnIndex.Isomer) + else + self.LastSelectNormalCharacterId = characterId + self.PanelCharacterTypeBtns:SelectIndex(TabBtnIndex.Normal) + end + return + end + end + + local index = 1 + local characterList = self.SupportData and self.SupportData.GetCharacters and self.SupportData.GetCharacters(characterType) or + XDataCenter.CharacterManager.GetCharacterList(characterType, false, self.IsAscendOrder, true) + local isSetCharacterId = true + if characterId then + for k, v in pairs(characterList) do + if v.Id == characterId then + index = k + isSetCharacterId = false + break + end + end + else + characterId = characterList[1].Id + end + if isSetCharacterId then + characterId = characterList[1].Id + self.CharacterId = characterId + end + + if self.SelectTabBtnIndex == TabBtnIndex.Normal then + self.LastSelectNormalCharacterId = characterId + elseif self.SelectTabBtnIndex == TabBtnIndex.Isomer then + self.LastSelectIsomerCharacterId = characterId + end + + self:UpdateCurCharacterInfo(characterId) + + self.CharacterList = characterList + self.InTeamCheckTable = XDataCenter.TeamManager.GetInTeamCheckTable() + self.DynamicTable:SetDataSource(characterList) + self.DynamicTable:ReloadDataASync(index) +end + +function XUiCharacter:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.CharacterList[index] + grid:Reset() + grid:UpdateGrid(data) + grid:SetInTeam(self.InTeamCheckTable[data.Id]) + grid:UpdateSupport(self.SupportData) + if self.CharacterId == data.Id then + self.CurSelectGrid = grid + end + grid:SetSelect(self.CharacterId == data.Id) + + if self.SupportData then + grid:HideRedPoint() + end + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + local characterId = self.CharacterList[index].Id + if XCharacterConfigs.IsCharacterForeShow(characterId) then + if self.CharacterId ~= characterId then + if self.CurSelectGrid then + self.CurSelectGrid:SetSelect(false) + end + grid:SetSelect(true) + self.CurSelectGrid = grid + self:UpdateCurCharacterInfo(characterId) + end + else + XUiManager.TipMsg(CSXTextManagerGetText("ComingSoon"), XUiManager.UiTipType.Tip) + end + end +end + +function XUiCharacter:UpdateCurCharacterInfo(characterId) + self.CharacterId = characterId + + if XCharacterConfigs.IsIsomer(characterId) then + self.LastSelectIsomerCharacterId = characterId + else + self.LastSelectNormalCharacterId = characterId + end + + self:UpdateSceneAndModel() + + if self.SkipToProperty and not self.ChildOpen then + self:OpenOneChildUi("UiPanelCharProperty", self) + self.ChildOpen = true + self.SkipToProperty = false + return + end + + if not self.ChildOpen then + local isOwn = XDataCenter.CharacterManager.IsOwnCharacter(characterId) + if isOwn then + local childUi = self:FindChildUiObj("UiCharacterOwnedInfo") + childUi:PreSetCharacterId(characterId) + if not XLuaUiManager.IsUiShow("UiCharacterOwnedInfo") then + self:OpenOneChildUi("UiCharacterOwnedInfo", self.ForbidGotoEquip, function() + self:OpenOneChildUi("UiPanelCharProperty", self) + self.ChildOpen = true + end, self.IsSupport, self.SupportData) + else + childUi:UpdateView(characterId) + childUi:PlayAnimation("AnimEnable") + end + else + local childUi = self:FindChildUiObj("UiCharacterUnOwnedInfo") + childUi:PreSetCharacterId(characterId) + if not XLuaUiManager.IsUiShow("UiCharacterUnOwnedInfo") then + self:OpenOneChildUi("UiCharacterUnOwnedInfo", characterId) + else + childUi:UpdateView(characterId) + childUi:PlayAnimation("AnimEnable") + end + end + end + + if self.TeamCharIdMap then + self:UpdateTeamBtn() + end +end + +function XUiCharacter:UpdateCamera(index) + self.CurCameraIndex = index + for i = 1, CAMERA_NUM do + if self.CurCameraIndex ~= i then + self.CameraFar[i].gameObject:SetActiveEx(false) + self.CameraNear[i].gameObject:SetActiveEx(false) + end + end + + if self.CameraFar[self.CurCameraIndex] then + self.CameraFar[self.CurCameraIndex].gameObject:SetActiveEx(true) + end + if self.CameraNear[self.CurCameraIndex] then + self.CameraNear[self.CurCameraIndex].gameObject:SetActiveEx(true) + end +end + +function XUiCharacter:LoadModelScene() + local sceneUrl = self:GetSceneUrl() + local modelUrl = self:GetDefaultUiModelUrl() + self:LoadUiScene(sceneUrl, modelUrl, self.OnUiSceneLoadedCB, false) +end + +function XUiCharacter:GetSceneUrl() + local sceneUrl = XDataCenter.CharacterManager.GetCharShowFashionSceneUrl(self.CharacterId) + if sceneUrl and sceneUrl ~= "" then + return sceneUrl + else + return self:GetDefaultSceneUrl() + end +end + +function XUiCharacter:OnUiSceneLoaded(lastSceneUrl) + if lastSceneUrl ~= self.LastChacaterFashionSceneUrl then + self:SetGameObject() + self:InitSceneRoot() + self.LastChacaterFashionSceneUrl = lastSceneUrl + end +end + +function XUiCharacter:UpdateSceneAndModel() + self:LoadModelScene() + self:UpdateRoleModel() +end + +--更新模型 +function XUiCharacter:UpdateRoleModel() + self.ImgEffectHuanren.gameObject:SetActiveEx(false) + self.ImgEffectHuanren1.gameObject:SetActiveEx(false) + + self.RoleModelPanel:UpdateCharacterModel(self.CharacterId, self.PanelRoleModel, XModelManager.MODEL_UINAME.XUiCharacter, function(model) + self.PanelDrag.Target = model.transform + if self.SelectTabBtnIndex == TabBtnIndex.Normal then + self.ImgEffectHuanren.gameObject:SetActiveEx(true) + elseif self.SelectTabBtnIndex == TabBtnIndex.Isomer then + self.ImgEffectHuanren1.gameObject:SetActiveEx(true) + end + end) +end + +function XUiCharacter:UpdateTeamBtn() + if not next(self.TeamCharIdMap) then + return + end + + local isInTeam = false + local characterId = self.CharacterId + for _, v in pairs(self.TeamCharIdMap) do + if characterId == v then + isInTeam = true + break + end + end + self.BtnQuitTeam.gameObject:SetActiveEx(isInTeam) + self.BtnJoinTeam.gameObject:SetActiveEx(not isInTeam) + self.ImgEnjoinTeam.gameObject:SetActiveEx(false) +end + +function XUiCharacter:AutoAddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:BindHelpBtn(self.BtnHelp, "Character") + self:RegisterClickEvent(self.BtnJoinTeam, self.OnBtnJoinTeamClick) + self:RegisterClickEvent(self.BtnQuitTeam, self.OnBtnQuitTeamClick) + self:RegisterClickEvent(self.BtnFashion, self.OnBtnFashionClick) + self:RegisterClickEvent(self.BtnOwnedDetail, self.OnBtnOwnedDetailClick) + self:RegisterClickEvent(self.BtnShaixuan, self.OnBtnShaixuanClick) + self:RegisterClickEvent(self.BtnShengxu, self.OnBtnOrderClick) + self:RegisterClickEvent(self.BtnJiangxu, self.OnBtnOrderClick) +end + +function XUiCharacter:OnBtnBackClick() + if XLuaUiManager.IsUiShow("UiPanelCharacterExchange") then + self:CloseChildUi("UiPanelCharacterExchange") + return + end + + if XLuaUiManager.IsUiShow("UiPanelCharProperty") then + local propertyChildUi = self:FindChildUiObj("UiPanelCharProperty") + if not propertyChildUi:RecoveryPanel() then + self:CloseChildUi("UiPanelCharProperty") + self.ChildOpen = false + self:UpdateCharacterList(self.CharacterId) + self:UpdateCamera(XCharacterConfigs.XUiCharacter_Camera.MAIN) + end + return + end + + self:Close() +end + +function XUiCharacter:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiCharacter:OnBtnJoinTeamClick() + local id = self.CharacterId + for k, v in pairs(self.TeamCharIdMap) do + if v == id then + self.TeamCharIdMap[k] = 0 + break + end + end + + self.TeamCharIdMap[self.TeamSelectPos] = id + if self.TeamResultCb then + self.TeamResultCb(self.TeamCharIdMap) + end + + self:Close() +end + +function XUiCharacter:OnBtnQuitTeamClick() + local count = 0 + for _, v in pairs(self.TeamCharIdMap) do + if v > 0 then + count = count + 1 + end + end + + local id = self.CharacterId + for k, v in pairs(self.TeamCharIdMap) do + if v == id then + self.TeamCharIdMap[k] = 0 + break + end + end + + if self.TeamResultCb then + self.TeamResultCb(self.TeamCharIdMap) + end + + self:Close() +end + +function XUiCharacter:OnBtnFashionClick() + XLuaUiManager.Open("UiFashion", self.CharacterId) +end + +function XUiCharacter:OnBtnOwnedDetailClick() + XLuaUiManager.Open("UiCharacterDetail", self.CharacterId) +end + +function XUiCharacter:OnBtnShaixuanClick() + local characterType = CharacterTypeConvert[self.SelectTabBtnIndex] + XLuaUiManager.Open("UiRoomCharacterFilterTips", + self, + XRoomCharFilterTipsConfigs.EnumFilterType.Common, + XRoomCharFilterTipsConfigs.EnumSortType.Common, + characterType) +end + +function XUiCharacter:OpenChangeCharacterView() + self:OpenOneChildUi("UiPanelCharacterExchange", self, function(characterId) + self:UpdateCharacterList(characterId) + self:OpenOneChildUi("UiPanelCharProperty", self) + self.ChildOpen = true + end) + + self:UpdateCamera(XCharacterConfigs.XUiCharacter_Camera.EXCHANGE) + self.SViewCharacterList.gameObject:SetActiveEx(false) + self.PanelCharacterTypeBtns.gameObject:SetActiveEx(false) + self.BtnFashion.gameObject:SetActiveEx(false) + self.BtnOwnedDetail.gameObject:SetActiveEx(false) +end + +function XUiCharacter:Filter(selectTagGroupDic, sortTagId, isThereFilterData) + local characterType = CharacterTypeConvert[self.SelectTabBtnIndex] + local characterList = XDataCenter.CharacterManager.GetCharacterList(characterType, true, nil, true) + if isThereFilterData and isThereFilterData(characterList) then + self:OnSelectCharacterType(self.SelectTabBtnIndex) + end +end + +function XUiCharacter:OnBtnOrderClick() + self.IsAscendOrder = not self.IsAscendOrder + self:CheckBtnFilterActive() + self:OnSelectCharacterType(self.SelectTabBtnIndex) +end + +function XUiCharacter:CheckBtnFilterActive() + if not XTool.IsTableEmpty(self.SupportData) then return end + + self.BtnShengxu.gameObject:SetActiveEx(self.IsAscendOrder) + self.BtnJiangxu.gameObject:SetActiveEx(not self.IsAscendOrder) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCharacter/XUiCharacterCarerrTips.lua b/Resources/Scripts/XUi/XUiCharacter/XUiCharacterCarerrTips.lua new file mode 100644 index 00000000..131d9eae --- /dev/null +++ b/Resources/Scripts/XUi/XUiCharacter/XUiCharacterCarerrTips.lua @@ -0,0 +1,26 @@ +local XUiGridCharacterCareer = require("XUi/XUiCharacter/XUiGridCharacterCareer") + +local ipairs = ipairs +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate + +local XUiCharacterCarerrTips = XLuaUiManager.Register(XLuaUi, "UiCharacterCarerrTips") + +function XUiCharacterCarerrTips:OnAwake() + self.BtnClose.CallBack = function() self:Close() end + self.GridCharacterCareer.gameObject:SetActiveEx(false) +end + +function XUiCharacterCarerrTips:OnStart() + self.CareerGrids = {} + local careerIds = XCharacterConfigs.GetAllCharacterCareerIds() + for index, careerId in ipairs(careerIds) do + local grid = self.CareerGrids[index] + if not grid then + local go = CSUnityEngineObjectInstantiate(self.GridCharacterCareer, self.PanelLayout) + grid = XUiGridCharacterCareer.New(go) + self.CareerGrids[index] = grid + end + grid:Refresh(careerId) + grid.GameObject:SetActiveEx(true) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCharacter/XUiCharacterElementDetail.lua b/Resources/Scripts/XUi/XUiCharacter/XUiCharacterElementDetail.lua new file mode 100644 index 00000000..6258201e --- /dev/null +++ b/Resources/Scripts/XUi/XUiCharacter/XUiCharacterElementDetail.lua @@ -0,0 +1,60 @@ +local XUiGridElementDetail = require("XUi/XUiCharacter/XUiGridElementDetail") + +local tableInsert = table.insert + +local XUiCharacterElementDetail = XLuaUiManager.Register(XLuaUi, "UiCharacterElementDetail") + +function XUiCharacterElementDetail:OnAwake() + self.GridElementDetail.gameObject:SetActiveEx(false) + self.BtnClose.CallBack = function() self:Close() end + self.BtnTanchuangClose.CallBack = function() self:Close() end + self:InitDynamicTable() +end + +function XUiCharacterElementDetail:OnStart(characterId) + self.CharacterId = characterId +end + +function XUiCharacterElementDetail:OnEnable() + self:UpdateDynamicTable() +end + +function XUiCharacterElementDetail:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelElementDetails) + self.DynamicTable:SetProxy(XUiGridElementDetail) + self.DynamicTable:SetDelegate(self) +end + +function XUiCharacterElementDetail:UpdateDynamicTable() + self.SortedElementIds = XUiCharacterElementDetail.ConstructSortedElementIds(self.CharacterId) + self.DynamicTable:SetDataSource(self.SortedElementIds) + self.DynamicTable:ReloadDataASync() +end + +function XUiCharacterElementDetail:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:Refresh(self.SortedElementIds[index]) + end +end + +function XUiCharacterElementDetail.ConstructSortedElementIds(characterId) + local sortedElementIds = {} + + local curElementIdsCheckDic = {} + local detailConfig = XCharacterConfigs.GetCharDetailTemplate(characterId) + local curElementList = detailConfig.ObtainElementList + for _, elementId in pairs(curElementList) do + curElementIdsCheckDic[elementId] = true + tableInsert(sortedElementIds, -elementId) + end + + local allElementIds = XCharacterConfigs.GetAllCharElments() + for _, element in pairs(allElementIds) do + local elementId = element.Id + if not curElementIdsCheckDic[elementId] then + tableInsert(sortedElementIds, elementId) + end + end + + return sortedElementIds +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCharacter/XUiCharacterOwnedInfo.lua b/Resources/Scripts/XUi/XUiCharacter/XUiCharacterOwnedInfo.lua new file mode 100644 index 00000000..a1222743 --- /dev/null +++ b/Resources/Scripts/XUi/XUiCharacter/XUiCharacterOwnedInfo.lua @@ -0,0 +1,212 @@ +local XUiGridEquip = require("XUi/XUiEquipAwarenessReplace/XUiGridEquip") + +local XUiCharacterOwnedInfo = XLuaUiManager.Register(XLuaUi, "UiCharacterOwnedInfo") + +function XUiCharacterOwnedInfo:OnAwake() + self:AddListener() +end + +function XUiCharacterOwnedInfo:OnStart(forbidGotoEquip, clickCb, isSupport, supportData) + self.ForbidGotoEquip = forbidGotoEquip + self.IsSupport = isSupport + self.ClickCb = clickCb + self.SupportData = supportData + + self.BtnLevelUp.gameObject:SetActiveEx(not forbidGotoEquip and not self.IsSupport) + self.BtnJoin.gameObject:SetActiveEx(forbidGotoEquip) + self.BtnSupport.gameObject:SetActiveEx(self.IsSupport) + self.BtnSupportCancel.gameObject:SetActiveEx(false) + + self:RegisterRedPointEvent() +end + +function XUiCharacterOwnedInfo:OnEnable() + self:UpdateView(self.CharacterId) +end + +function XUiCharacterOwnedInfo:PreSetCharacterId(characterId) + self.CharacterId = characterId +end + +function XUiCharacterOwnedInfo:RegisterRedPointEvent() + local characterId = self.CharacterId + self.RedPointId = XRedPointManager.AddRedPointEvent(self.ImgRedPoint, self.OnCheckCharacterRedPoint, self, { XRedPointConditions.Types.CONDITION_CHARACTER }, characterId) +end + +function XUiCharacterOwnedInfo:OnCheckCharacterRedPoint(count) + self.ImgRedPoint.gameObject:SetActiveEx(count >= 0) +end + +function XUiCharacterOwnedInfo:UpdateView(characterId) + self.CharacterId = characterId + + local charConfig = XCharacterConfigs.GetCharacterTemplate(characterId) + self.TxtName.text = charConfig.Name + self.TxtNameOther.text = charConfig.TradeName + + local character = XDataCenter.CharacterManager.GetCharacter(characterId) + self.RImgTypeIcon:SetRawImage(XCharacterConfigs.GetNpcTypeIcon(character.Type)) + self.TxtLv.text = math.floor(character.Ability) + + self.WeaponGrid = self.WeaponGrid or XUiGridEquip.New(self.GridWeapon, nil, self) + local usingWeaponId = XDataCenter.EquipManager.GetCharacterWearingWeaponId(characterId) + self.WeaponGrid:Refresh(usingWeaponId) + + local partner = XDataCenter.PartnerManager.GetCarryPartnerEntityByCarrierId(characterId) + if partner then + self.PartnerIcon:SetRawImage(partner:GetIcon()) + end + self.PartnerIcon.gameObject:SetActiveEx(partner) + + self.WearingAwarenessGrids = self.WearingAwarenessGrids or {} + for _, equipSite in pairs(XEquipConfig.EquipSite.Awareness) do + self.WearingAwarenessGrids[equipSite] = self.WearingAwarenessGrids[equipSite] or XUiGridEquip.New(CS.UnityEngine.Object.Instantiate(self.GridAwareness), nil, self) + self.WearingAwarenessGrids[equipSite].Transform:SetParent(self["PanelAwareness" .. equipSite], false) + + local equipId = XDataCenter.EquipManager.GetWearingEquipIdBySite(characterId, equipSite) + if not equipId then + self.WearingAwarenessGrids[equipSite].GameObject:SetActiveEx(false) + self["PanelNoAwareness" .. equipSite].gameObject:SetActiveEx(true) + else + self.WearingAwarenessGrids[equipSite].GameObject:SetActiveEx(true) + self["BtnAwarenessReplace" .. equipSite].transform:SetAsLastSibling() + self["PanelNoAwareness" .. equipSite].gameObject:SetActiveEx(false) + self.WearingAwarenessGrids[equipSite]:Refresh(equipId) + end + end + + local detailConfig = XCharacterConfigs.GetCharDetailTemplate(characterId) + local elementList = detailConfig.ObtainElementList + for i = 1, 3 do + local rImg = self["RImgCharElement" .. i] + if elementList[i] then + rImg.gameObject:SetActiveEx(true) + local elementConfig = XCharacterConfigs.GetCharElement(elementList[i]) + rImg:SetRawImage(elementConfig.Icon) + else + rImg.gameObject:SetActiveEx(false) + end + end + + XRedPointManager.Check(self.RedPointId, characterId) + + self:UpdateSupport(characterId) +end + +--------支援相关 begin--------- +function XUiCharacterOwnedInfo:UpdateSupport(characterId) + local supportData = self.SupportData + if XTool.IsTableEmpty(supportData) then return end + + self.BtnLevelUp.gameObject:SetActiveEx(false) + + local showSupport = not supportData.CheckInSupportCb(characterId) + self.BtnSupport.gameObject:SetActiveEx(showSupport) + + local showSupportCancel = supportData.CanSupportCancel and supportData.CheckInSupportCb(characterId) + self.BtnSupportCancel.gameObject:SetActiveEx(showSupportCancel) +end +--------支援相关 end--------- +function XUiCharacterOwnedInfo:AddListener() + self:RegisterClickEvent(self.BtnLevelUp, self.OnBtnLevelUpClick) + self:RegisterClickEvent(self.BtnAwarenessReplace6, self.OnBtnAwarenessReplace6Click) + self:RegisterClickEvent(self.BtnAwarenessReplace5, self.OnBtnAwarenessReplace5Click) + self:RegisterClickEvent(self.BtnAwarenessReplace4, self.OnBtnAwarenessReplace4Click) + self:RegisterClickEvent(self.BtnAwarenessReplace3, self.OnBtnAwarenessReplace3Click) + self:RegisterClickEvent(self.BtnAwarenessReplace2, self.OnBtnAwarenessReplace2Click) + self:RegisterClickEvent(self.BtnAwarenessReplace1, self.OnBtnAwarenessReplace1Click) + self:RegisterClickEvent(self.BtnWeaponReplace, self.OnBtnWeaponReplaceClick) + self:RegisterClickEvent(self.BtnJoin, self.OnBtnJoinClick) + self:RegisterClickEvent(self.BtnCareerTips, self.OnBtnCareerTipsClick) + self.BtnElementDetail.CallBack = function() self:OnBtnElementDetailClick() end + self.BtnSupport.CallBack = function() self:OnBtnSupportClick() end + self.BtnSupportCancel.CallBack = function() self:OnBtnSupportCancelClick() end + self.BtnCarryPartner.CallBack = function() self:OnCarryPartnerClick() end +end + +function XUiCharacterOwnedInfo:OnBtnAwarenessReplace5Click() + self:OnAwarenessClick(5) +end + +function XUiCharacterOwnedInfo:OnBtnAwarenessReplace4Click() + self:OnAwarenessClick(4) +end + +function XUiCharacterOwnedInfo:OnBtnAwarenessReplace3Click() + self:OnAwarenessClick(3) +end + +function XUiCharacterOwnedInfo:OnBtnAwarenessReplace2Click() + self:OnAwarenessClick(2) +end + +function XUiCharacterOwnedInfo:OnBtnAwarenessReplace1Click() + self:OnAwarenessClick(1) +end + +function XUiCharacterOwnedInfo:OnBtnAwarenessReplace6Click() + self:OnAwarenessClick(6) +end + +function XUiCharacterOwnedInfo:OnAwarenessClick(site) + if self.ForbidGotoEquip or self.IsSupport then return end + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.Equip) then + return + end + XLuaUiManager.Open("UiEquipAwarenessReplace", self.CharacterId, site) +end + +function XUiCharacterOwnedInfo:OnBtnCareerTipsClick() + XLuaUiManager.Open("UiCharacterCarerrTips") +end + +function XUiCharacterOwnedInfo:OnBtnWeaponReplaceClick() + if self.ForbidGotoEquip or self.IsSupport then return end + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.Equip) then + return + end + XLuaUiManager.Open("UiEquipReplaceNew", self.CharacterId) +end + +function XUiCharacterOwnedInfo:OnBtnLevelUpClick() + if self.ClickCb then self.ClickCb() end +end + +function XUiCharacterOwnedInfo:OnBtnJoinClick() + XDataCenter.AssistManager.ChangeAssistCharacterId(self.CharacterId, function(code) + if (code == XCode.Success) then + XLuaUiManager.Close("UiCharacter") + end + end) +end + +function XUiCharacterOwnedInfo:OnBtnElementDetailClick() + XLuaUiManager.Open("UiCharacterElementDetail", self.CharacterId) +end + +function XUiCharacterOwnedInfo:OnBtnSupportClick() + local characterId = self.CharacterId + XEventManager.DispatchEvent(XEventId.EVENT_CHARACTER_SUPPORT, characterId) + + if self.SupportData then + if self.SupportData.SetCharacterCb then + local cb = function() XLuaUiManager.Close("UiCharacter") end + if not self.SupportData.SetCharacterCb(characterId, cb, self.SupportData.OldCharacterId) then return end + end + else + XLuaUiManager.Close("UiCharacter") + end +end + +function XUiCharacterOwnedInfo:OnCarryPartnerClick() + XDataCenter.PartnerManager.GoPartnerCarry(self.CharacterId, true) +end + +function XUiCharacterOwnedInfo:OnBtnSupportCancelClick() + local characterId = self.CharacterId + if self.SupportData then + if self.SupportData.CancelCharacterCb then + self.SupportData.CancelCharacterCb(characterId) + end + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCharacter/XUiCharacterSkillSwich.lua b/Resources/Scripts/XUi/XUiCharacter/XUiCharacterSkillSwich.lua new file mode 100644 index 00000000..c9a30416 --- /dev/null +++ b/Resources/Scripts/XUi/XUiCharacter/XUiCharacterSkillSwich.lua @@ -0,0 +1,53 @@ +local XUiGridSwitchSkill = require("XUi/XUiCharacter/XUiGridSwitchSkill") + +local XUiCharacterSkillSwich = XLuaUiManager.Register(XLuaUi, "UiCharacterSkillSwich") + +function XUiCharacterSkillSwich:OnAwake() + self:AutoAddListener() + self.SkillItem.gameObject:SetActiveEx(false) +end + +function XUiCharacterSkillSwich:OnStart(skillId, skillLevel, switchCb) + self.SkillId = skillId + self.SkillLevel = skillLevel + self.SwitchCb = switchCb +end + +function XUiCharacterSkillSwich:OnEnable() + self:Refresh() +end + +function XUiCharacterSkillSwich:Refresh() + local curSkillId = self.SkillId + local groupSkillIds = XCharacterConfigs.GetGroupSkillIds(curSkillId) + + self.Grids = self.Grids or {} + for index, skillId in ipairs(groupSkillIds) do + local grid = self.Grids[index] + if not grid then + local go = CS.UnityEngine.Object.Instantiate(self.SkillItem, self.Content) + local switchCb = function() + self:Refresh() + self.SwitchCb() + end + grid = XUiGridSwitchSkill.New(go, switchCb) + self.Grids[index] = grid + end + + local isCurrent = XDataCenter.CharacterManager.IsSkillUsing(skillId) + grid:Refresh(skillId, self.SkillLevel, isCurrent) + grid.GameObject:SetActiveEx(true) + end + + for i = #groupSkillIds + 1, #self.Grids do + self.Grids[i].GameObject:SetActiveEx(false) + end +end + +function XUiCharacterSkillSwich:AutoAddListener() + self:RegisterClickEvent(self.BtnTanchuangCloseBig, self.OnBtnBackClick) +end + +function XUiCharacterSkillSwich:OnBtnBackClick() + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCharacter/XUiCharacterUnOwnedInfo.lua b/Resources/Scripts/XUi/XUiCharacter/XUiCharacterUnOwnedInfo.lua new file mode 100644 index 00000000..df00b9d1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiCharacter/XUiCharacterUnOwnedInfo.lua @@ -0,0 +1,78 @@ +local CSXTextManagerGetText = CS.XTextManager.GetText + +local XUiCharacterUnOwnedInfo = XLuaUiManager.Register(XLuaUi, "UiCharacterUnOwnedInfo") + +function XUiCharacterUnOwnedInfo:OnAwake() + self:AddListener() +end + +function XUiCharacterUnOwnedInfo:OnStart(characterId) + self.CharacterId = characterId +end + +function XUiCharacterUnOwnedInfo:OnEnable() + self:UpdateView(self.CharacterId) +end + +function XUiCharacterUnOwnedInfo:PreSetCharacterId(characterId) + self.CharacterId = characterId +end + +function XUiCharacterUnOwnedInfo:UpdateView(characterId) + self.CharacterId = characterId + + local curFragment = XDataCenter.CharacterManager.GetCharUnlockFragment(characterId) + local bornQuality = XCharacterConfigs.GetCharMinQuality(characterId) + local bornGrade = XCharacterConfigs.GetCharMinGrade(characterId) + local characterType = XCharacterConfigs.GetCharacterType(characterId) + local needFragment = XCharacterConfigs.GetComposeCount(characterType, bornQuality) + local npcId = XCharacterConfigs.GetCharNpcId(characterId, bornQuality) + local npc = CS.XNpcManager.GetNpcTemplate(npcId) + + self.TxtIntroduce.text = CSXTextManagerGetText("CharacterUnowenedIntroduce" + , XCharacterConfigs.GetCharacterName(characterId) + , XCharacterConfigs.GetCharacterTradeName(characterId) + , XCharacterConfigs.GetCharacterIntro(characterId)) + self.TxtOwnFragmentNumber.text = curFragment .. "" + self.TxtNeedFragmentNumber.text = "/" .. needFragment + self.ImgFill.fillAmount = curFragment / needFragment + + local isCanUnlock = curFragment >= needFragment + self.BtnUnlock:SetDisable(not isCanUnlock) + + self.RImgBornQuality:SetRawImage(XCharacterConfigs.GetCharQualityIcon(bornQuality)) + self.RImgBornGradeIcon:SetRawImage(XCharacterConfigs.GetCharGradeIcon(characterId, bornGrade)) + self.RImgUnownedTypeIcon:SetRawImage(XCharacterConfigs.GetNpcTypeIcon(npc.Type)) +end + +function XUiCharacterUnOwnedInfo:AddListener() + self:RegisterClickEvent(self.BtnGet, self.OnBtnGetClick) + self:RegisterClickEvent(self.BtnUnlock, self.OnBtnUnlockClick) +end + +function XUiCharacterUnOwnedInfo:OnBtnUnlockClick() + local characterId = self.CharacterId + local curFragment = XDataCenter.CharacterManager.GetCharUnlockFragment(characterId) + local bornQuality = XCharacterConfigs.GetCharMinQuality(characterId) + local characterType = XCharacterConfigs.GetCharacterType(characterId) + local needFragment = XCharacterConfigs.GetComposeCount(characterType, bornQuality) + if curFragment >= needFragment then + CS.XAudioManager.PlaySound(XSoundManager.UiBasicsMusic.UiCharacter_UnlockBegin) + XLuaUiManager.Open("UiUnlockShow", characterId, function() + local title = CSXTextManagerGetText("CharacterUnlockNewCharacter") + local content = XCharacterConfigs.GetCharacterFullNameStr(characterId) + XLuaUiManager.Open("UiLeftPopupTip", title, content) + CS.XAudioManager.PlaySound(XSoundManager.UiBasicsMusic.UiCharacter_UnlockEnd) + end) + end +end + +function XUiCharacterUnOwnedInfo:OnBtnGetClick() + local unionFightData = XDataCenter.FubenUnionKillRoomManager.GetUnionRoomData() + if unionFightData and unionFightData.Id then + return + end + + local useItemId = XCharacterConfigs.GetCharacterTemplate(self.CharacterId).ItemId + XLuaUiManager.Open("UiTip", XDataCenter.ItemManager.GetItem(useItemId)) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCharacter/XUiGridCharacter.lua b/Resources/Scripts/XUi/XUiCharacter/XUiGridCharacter.lua new file mode 100644 index 00000000..40668d1d --- /dev/null +++ b/Resources/Scripts/XUi/XUiCharacter/XUiGridCharacter.lua @@ -0,0 +1,362 @@ +XUiGridCharacter = XClass(nil, "XUiGridCharacter") + +function XUiGridCharacter:Ctor(ui, rootUi, character, clickCallback) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Character = character + self.ClickCallback = clickCallback + self.RectTransform = ui:GetComponent("RectTransform") + self:InitAutoScript() + XTool.InitUiObject(self) + + if self.PanelStaminaBar then + self.PanelStaminaBar.gameObject:SetActiveEx(false) + end + if self.PanelTeamBuff then + self.PanelTeamBuff.gameObject:SetActiveEx(false) + end + self:SetSelect(false) + self:SetInTeam(false) + self:UpdateGrid() +end + +function XUiGridCharacter:Init(rootUi) + self.RootUi = rootUi +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiGridCharacter:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiGridCharacter:AutoInitUi() + self.BtnCharacter = XUiHelper.TryGetComponent(self.Transform, "BtnCharacter", "Button") + self.PanelSelected = XUiHelper.TryGetComponent(self.Transform, "PanelSelected", nil) + self.ImgSelected = XUiHelper.TryGetComponent(self.Transform, "PanelSelected/ImgSelected", "Image") + self.PanelLevel = XUiHelper.TryGetComponent(self.Transform, "PanelLevel", nil) + self.TxtLevel = XUiHelper.TryGetComponent(self.Transform, "PanelLevel/TxtLevel", "Text") + self.TxtGradeLevel = XUiHelper.TryGetComponent(self.Transform, "TxtGradeLevel", "Text") + self.PanelGrade = XUiHelper.TryGetComponent(self.Transform, "PanelGrade", nil) + self.RImgGrade = XUiHelper.TryGetComponent(self.Transform, "PanelGrade/RImgGrade", "RawImage") + self.RImgQuality = XUiHelper.TryGetComponent(self.Transform, "RImgQuality", "RawImage") + self.ImgLock = XUiHelper.TryGetComponent(self.Transform, "ImgLock", "Image") + self.ImgLimited = XUiHelper.TryGetComponent(self.Transform, "ImgLimited", "Image") + self.PanelHead = XUiHelper.TryGetComponent(self.Transform, "PanelHead", nil) + self.RImgHeadIcon = XUiHelper.TryGetComponent(self.Transform, "PanelHead/RImgHeadIcon", "RawImage") + self.ImgHeadIconBg = XUiHelper.TryGetComponent(self.Transform, "PanelHead/ImgHeadIconBg", "Image") + self.PanelFragment = XUiHelper.TryGetComponent(self.Transform, "PanelFragment", nil) + self.TxtCurCount = XUiHelper.TryGetComponent(self.Transform, "PanelFragment/TxtCurCount", "Text") + self.TxtNeedCount = XUiHelper.TryGetComponent(self.Transform, "PanelFragment/TxtNeedCount", "Text") + self.ImgInTeam = XUiHelper.TryGetComponent(self.Transform, "ImgInTeam", "Image") + self.TxtInTeam = XUiHelper.TryGetComponent(self.Transform, "ImgInTeam/TxtInTeam", "Text") + self.ImgRedPoint = XUiHelper.TryGetComponent(self.Transform, "ImgRedPoint", "Image") + self.ImgStaminaExpFill = XUiHelper.TryGetComponent(self.Transform, "PanelStaminaBar/ImgStaminaExpFill", "Image") + self.PanelStaminaBar = XUiHelper.TryGetComponent(self.Transform, "PanelStaminaBar", nil) + self.PanelFight = XUiHelper.TryGetComponent(self.Transform, "PanelFight", nil) + self.TxtFight = XUiHelper.TryGetComponent(self.Transform, "PanelFight/TxtFight", "Text") + self.RogueLikeUp = XUiHelper.TryGetComponent(self.Transform, "PanelRogueLikeTheme", nil) +end + +function XUiGridCharacter:AutoAddListener() + self.AutoCreateListeners = {} + XUiHelper.RegisterClickEvent(self, self.BtnCharacter, self.OnBtnCharacterClick) +end +-- auto +function XUiGridCharacter:OnBtnCharacterClick() + if self.ClickCallback then + local characterId = 0 + if self.Character.IsRobot then + local robotTemplate = XRobotManager.GetRobotTemplate(self.Character.Id) + characterId = robotTemplate.CharacterId + else + characterId = self.Character.Id + end + if XCharacterConfigs.IsCharacterForeShow(characterId) then + self.ClickCallback(self.Character) + else + XUiManager.TipMsg(CS.XTextManager.GetText("ComingSoon"), XUiManager.UiTipType.Tip) + end + end +end + +function XUiGridCharacter:UpdateStamina(curStamina, maxStamina) + if self.PanelStaminaBar then + self.PanelStaminaBar.gameObject:SetActiveEx(true) + end + self.ImgStaminaExpFill.fillAmount = curStamina / maxStamina +end + +function XUiGridCharacter:UpdateStaminaByPercent(percent) + if self.PanelStaminaBar then + self.PanelStaminaBar.gameObject:SetActiveEx(true) + end + self.ImgStaminaExpFill.fillAmount = percent * 0.01 +end + +function XUiGridCharacter:UpdateGrid(character, selectCharacterId) + if character then + self.Character = character + end + if not self.Character then return end + + self:SetSelect(selectCharacterId == self.Character.Id) + + if self.Character.IsRobot then + self:UpdateRobotGrid() + else + self:UpdateNormalGrid() + end +end + +function XUiGridCharacter:UpdateRobotGrid() + local robotId = self.Character.Id + local robotTemplate = XRobotManager.GetRobotTemplate(robotId) + local level = robotTemplate.CharacterLevel + local quality = XCharacterConfigs.GetCharacterQualityIcon(robotTemplate.CharacterQuality) + local head = XDataCenter.CharacterManager.GetCharSmallHeadIcon(robotTemplate.CharacterId, robotTemplate.LiberateLv, true) + local grade = XCharacterConfigs.GetCharGradeIcon(robotTemplate.CharacterId, robotTemplate.CharacterGrade) + local ability = self.Character.Ability or XRobotManager.GetRobotAbility(robotId) + + if self.PanelLevel then + self.PanelLevel.gameObject:SetActiveEx(true) + self.TxtLevel.text = level + end + + if self.PanelGrade then + self.PanelGrade.gameObject:SetActiveEx(true) + self.RImgGrade:SetRawImage(grade) + end + + if self.RImgQuality then + self.RImgQuality.gameObject:SetActiveEx(true) + self.RImgQuality:SetRawImage(quality) + end + + if self.PanelHead then + self.PanelHead.gameObject:SetActiveEx(true) + self.RImgHeadIcon:SetRawImage(head) + end + + if self.PanelFight then + self.PanelFight.gameObject:SetActiveEx(true) + self.TxtFight.text = math.floor(ability) + end + + local detailConfig = XCharacterConfigs.GetCharDetailTemplate(robotTemplate.CharacterId) + local elementList = detailConfig.ObtainElementList + for i = 1, 3 do + local rImg = self["RImgCharElement" .. i] + if elementList[i] then + rImg.gameObject:SetActiveEx(true) + local elementConfig = XCharacterConfigs.GetCharElement(elementList[i]) + rImg:SetRawImage(elementConfig.Icon) + else + rImg.gameObject:SetActiveEx(false) + end + end + + if self.PanelTry then + self.PanelTry.gameObject:SetActiveEx(not self.Character.HideTryTag) + end + + if self.PanelCurrentLocation then + self.PanelCurrentLocation.gameObject:SetActiveEx(false) + end + + -- 样式与“编队中有相同构造体”提示相同,居中横幅 + if self.Character.ShowText then + self.PanelSameRole.gameObject:SetActiveEx(true) + self.TextSameRole.text = self.Character.ShowText + else + self:SetSameRoleTag(false) + end +end + +function XUiGridCharacter:UpdateNormalGrid() + local isOwn = XDataCenter.CharacterManager.IsOwnCharacter(self.Character.Id) + XRedPointManager.CheckOnce(self.OnCheckCharacterRedPoint, self, { XRedPointConditions.Types.CONDITION_CHARACTER }, self.Character.Id) + + if self.PanelLevel then + self.PanelLevel.gameObject:SetActiveEx(isOwn) + end + + if self.PanelGrade then + self.PanelGrade.gameObject:SetActiveEx(isOwn) + end + + if self.RImgQuality then + self.RImgQuality.gameObject:SetActiveEx(isOwn) + end + + if self.ImgLock then + self.ImgLock.gameObject:SetActiveEx(not isOwn) + end + + if self.PanelFragment then + self.PanelFragment.gameObject:SetActiveEx(not isOwn) + end + + if self.PanelFight then + self.TxtFight.text = math.floor(self.Character.Ability) + end + + if self.PanelCharElement then + local detailConfig = XCharacterConfigs.GetCharDetailTemplate(self.Character.Id) + local elementList = detailConfig.ObtainElementList + for i = 1, 3 do + local rImg = self["RImgCharElement" .. i] + if elementList[i] then + rImg.gameObject:SetActiveEx(true) + local elementConfig = XCharacterConfigs.GetCharElement(elementList[i]) + rImg:SetRawImage(elementConfig.Icon) + else + rImg.gameObject:SetActiveEx(false) + end + end + end + + if isOwn then + self:UpdateOwnInfo() + else + self:UpdateUnOwnInfo() + end + + if self.PanelTry then + self.PanelTry.gameObject:SetActiveEx(false) + end + + if self.PanelCurrentLocation then + self.PanelCurrentLocation.gameObject:SetActiveEx(false) + end + + self:SetSameRoleTag(false) +end + +function XUiGridCharacter:UpdateUnOwnInfo() + local characterId = self.Character.Id + + if self.TxtCurCount then + self.TxtCurCount.text = XDataCenter.CharacterManager.GetCharUnlockFragment(characterId) + end + + local bornQuality = XCharacterConfigs.GetCharMinQuality(characterId) + + if self.TxtNeedCount then + local characterType = XCharacterConfigs.GetCharacterType(characterId) + self.TxtNeedCount.text = XCharacterConfigs.GetComposeCount(characterType, bornQuality) + end + + if self.RImgHeadIcon then + self.RImgHeadIcon:SetRawImage(XDataCenter.CharacterManager.GetCharSmallHeadIcon(characterId)) + end +end + +function XUiGridCharacter:UpdateOwnInfo() + if self.TxtLevel then + self.TxtLevel.text = self.Character.Level + end + + if self.TxtGradeLevel then + self.TxtGradeLevel.text = XCharacterConfigs.GetCharGradeName(self.Character.Id, self.Character.Grade) + end + + if self.RImgGrade then + self.RImgGrade:SetRawImage(XCharacterConfigs.GetCharGradeIcon(self.Character.Id, self.Character.Grade)) + end + + if self.RImgQuality then + self.RImgQuality:SetRawImage(XCharacterConfigs.GetCharacterQualityIcon(self.Character.Quality)) + end + + if self.RImgHeadIcon then + self.RImgHeadIcon:SetRawImage(XDataCenter.CharacterManager.GetCharSmallHeadIcon(self.Character.Id)) + end + + if self.TxtTradeName then + self.TxtTradeName.text = XCharacterConfigs.GetCharacterTradeName(self.Character.Id) + end +end + +function XUiGridCharacter:SetTeamBuff(isShow) + if not self.PanelTeamBuff then + return + end + self.PanelTeamBuff.gameObject:SetActiveEx(isShow) +end + +function XUiGridCharacter:OnCheckCharacterRedPoint(count) + if self.ImgRedPoint then + self.ImgRedPoint.gameObject:SetActiveEx(count >= 0) + end +end + +function XUiGridCharacter:SetSelect(isSelect) + if self.ImgSelected then + self.ImgSelected.gameObject:SetActiveEx(isSelect) + end +end + +function XUiGridCharacter:SetInTeam(isInTeam, inTeamText, pos) + if self.ImgInTeam then + if isInTeam then + if inTeamText and self.TxtInTeam then + self.TxtInTeam.text = inTeamText + end + self.ImgInTeam.gameObject:SetActiveEx(true) + + if self.PanelCurrentLocation then + if XLuaUiManager.IsUiLoad("UiRoomTeamPrefab") and pos then + self.Image1.color = XDataCenter.TeamManager.GetTeamMemberColor(pos) + self.Image2.color = XDataCenter.TeamManager.GetTeamMemberColor(pos) + self.PanelCurrentLocation.gameObject:SetActiveEx(true) + end + end + else + self.ImgInTeam.gameObject:SetActiveEx(false) + end + end +end + +function XUiGridCharacter:SetIsLock(isLock) + if self.ImgLock then + self.ImgLock.gameObject:SetActiveEx(isLock) + end +end + +function XUiGridCharacter:SetLimited(isLimited) + if self.ImgLimited then + self.ImgLimited.gameObject:SetActiveEx(isLimited) + end +end + +function XUiGridCharacter:SetArrowUp(isUp) + if self.RogueLikeUp then + self.RogueLikeUp.gameObject:SetActiveEx(isUp) + end +end + +function XUiGridCharacter:Reset() + self.GameObject:SetActiveEx(false) + self:SetSelect(false) + self:SetInTeam(false) +end + +function XUiGridCharacter:SetPosition(x, y) + self.RectTransform.anchoredPosition = CS.UnityEngine.Vector2(x, y) +end + +function XUiGridCharacter:SetSameRoleTag(isShow) + if self.PanelSameRole then + self.PanelSameRole.gameObject:SetActiveEx(isShow) + end + if self.TextSameRole and isShow then + local characterId = self.Character.Id + local characterType = XCharacterConfigs.GetCharacterType(characterId) + local characterTypeName = characterType == XCharacterConfigs.CharacterType.Isomer and CS.XTextManager.GetText("TypeIsomer") or CS.XTextManager.GetText("TypeCharacter") + self.TextSameRole.text = CS.XTextManager.GetText("TeamGridSameRole", characterTypeName) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCharacter/XUiGridCharacterCareer.lua b/Resources/Scripts/XUi/XUiCharacter/XUiGridCharacterCareer.lua new file mode 100644 index 00000000..af5332fb --- /dev/null +++ b/Resources/Scripts/XUi/XUiCharacter/XUiGridCharacterCareer.lua @@ -0,0 +1,20 @@ +local XUiGridCharacterCareer = XClass(nil, "XUiGridCharacterCareer") + +function XUiGridCharacterCareer:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiGridCharacterCareer:Refresh(careerId) + local name = XCharacterConfigs.GetCareerName(careerId) + self.TxtTypeName.text = name + + local des = XCharacterConfigs.GetCareerDes(careerId) + self.TxtTypeDes.text = des + + local icon = XCharacterConfigs.GetNpcTypeIcon(careerId) + self.RImgCareerType:SetRawImage(icon) +end + +return XUiGridCharacterCareer \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCharacter/XUiGridCharacterNew.lua b/Resources/Scripts/XUi/XUiCharacter/XUiGridCharacterNew.lua new file mode 100644 index 00000000..1876bc13 --- /dev/null +++ b/Resources/Scripts/XUi/XUiCharacter/XUiGridCharacterNew.lua @@ -0,0 +1,150 @@ +local XUiGridCharacterNew = XClass(nil, "XUiGridCharacterNew") + +function XUiGridCharacterNew:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + + self.RectTransform = ui:GetComponent("RectTransform") + self:InitAutoScript() +end + +function XUiGridCharacterNew:Init(rootUi, isShowStamina) + self.RootUi = rootUi + self.IsShowStamina = isShowStamina +end +-- auto +-- Automatic generation of code, forbid to edit +function XUiGridCharacterNew:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() + + if self.PanelSupportLock then + self.PanelSupportLock.gameObject:SetActiveEx(false) + end + + if self.PanelSupportIn then + self.PanelSupportIn.gameObject:SetActiveEx(false) + end +end + +function XUiGridCharacterNew:AutoInitUi() + self.PanelHead = self.Transform:Find("PanelHead") + self.RImgHeadIcon = self.Transform:Find("PanelHead/RImgHeadIcon"):GetComponent("RawImage") + self.PanelLevel = self.Transform:Find("PanelLevel") + self.TxtLevel = self.Transform:Find("PanelLevel/TxtLevel"):GetComponent("Text") + self.PanelGrade = self.Transform:Find("PanelGrade") + self.RImgGrade = self.Transform:Find("PanelGrade/RImgGrade"):GetComponent("RawImage") + self.RImgQuality = self.Transform:Find("RImgQuality"):GetComponent("RawImage") + self.PanelFragment = self.Transform:Find("PanelFragment") + self.TxtCurCount = self.Transform:Find("PanelFragment/TxtCurCount"):GetComponent("Text") + self.TxtNeedCount = self.Transform:Find("PanelFragment/TxtNeedCount"):GetComponent("Text") + self.ImgLock = self.Transform:Find("ImgLock"):GetComponent("Image") + self.BtnCharacter = self.Transform:Find("BtnCharacter"):GetComponent("Button") + self.ImgInTeam = self.Transform:Find("ImgInTeam"):GetComponent("Image") + self.PanelSelected = self.Transform:Find("PanelSelected") + self.ImgSelected = self.Transform:Find("PanelSelected/ImgSelected"):GetComponent("Image") + self.ImgRedPoint = self.Transform:Find("ImgRedPoint"):GetComponent("Image") + self.TxtCur = self.Transform:Find("TxtCur"):GetComponent("Text") +end + +function XUiGridCharacterNew:AutoAddListener() + CsXUiHelper.RegisterClickEvent(self.BtnCharacter, function() self:OnBtnCharacterClick() end) +end + +function XUiGridCharacterNew:OnBtnCharacterClick() + +end + +function XUiGridCharacterNew:UpdateOwnInfo() + self.TxtLevel.text = self.Character.Level + self.RImgGrade:SetRawImage(XCharacterConfigs.GetCharGradeIcon(self.Character.Id, self.Character.Grade)) + self.RImgQuality:SetRawImage(XCharacterConfigs.GetCharacterQualityIcon(self.Character.Quality)) + self.RImgHeadIcon:SetRawImage(XDataCenter.CharacterManager.GetCharSmallHeadIcon(self.Character.Id)) +end + +function XUiGridCharacterNew:UpdateUnOwnInfo() + local characterId = self.Character.Id + self.TxtCurCount.text = XDataCenter.CharacterManager.GetCharUnlockFragment(characterId) + local bornQuality = XCharacterConfigs.GetCharMinQuality(characterId) + local characterType = XCharacterConfigs.GetCharacterType(characterId) + self.TxtNeedCount.text = XCharacterConfigs.GetComposeCount(characterType, bornQuality) + self.RImgHeadIcon:SetRawImage(XDataCenter.CharacterManager.GetCharSmallHeadIcon(characterId)) +end + +function XUiGridCharacterNew:UpdateGrid(character) + if character then + self.Character = character + end + + local isOwn = XDataCenter.CharacterManager.IsOwnCharacter(self.Character.Id) + XRedPointManager.CheckOnce(self.OnCheckCharacterRedPoint, self, { XRedPointConditions.Types.CONDITION_CHARACTER }, self.Character.Id) + self.PanelLevel.gameObject:SetActiveEx(isOwn) + self.PanelGrade.gameObject:SetActiveEx(isOwn) + self.RImgQuality.gameObject:SetActiveEx(isOwn) + self.ImgLock.gameObject:SetActiveEx(not isOwn) + self.PanelFragment.gameObject:SetActiveEx(not isOwn) + + if isOwn then + self:UpdateOwnInfo() + else + self:UpdateUnOwnInfo() + end +end + +function XUiGridCharacterNew:OnCheckCharacterRedPoint(count) + if self.ImgRedPoint then + self.ImgRedPoint.gameObject:SetActiveEx(count >= 0) + end +end + +function XUiGridCharacterNew:SetSelect(isSelect) + self.ImgSelected.gameObject:SetActiveEx(isSelect) +end + +function XUiGridCharacterNew:HideRedPoint() + if self.ImgRedPoint then + self.ImgRedPoint.gameObject:SetActiveEx(false) + end +end + +function XUiGridCharacterNew:SetInTeam(isInTeam) + if self.ImgInTeam then + self.ImgInTeam.gameObject:SetActiveEx(isInTeam) + end +end + +function XUiGridCharacterNew:UpdateSupport(supportData) + if XTool.IsTableEmpty(supportData) then return end + + self:SetInTeam(false) + + local characterId = self.Character.Id + + if self.PanelSupportLock then + local lockSupport = supportData.CheckLockSupportCb and supportData.CheckLockSupportCb(characterId) + self.PanelSupportLock.gameObject:SetActiveEx(lockSupport) + end + + if self.PanelSupportIn then + local showSupport = supportData.CheckInSupportCb(characterId) + self.PanelSupportIn.gameObject:SetActiveEx(showSupport) + end +end + +function XUiGridCharacterNew:SetCurSignState(state) + self.TxtCur.gameObject:SetActiveEx(state) +end + +function XUiGridCharacterNew:Reset() + self:SetSelect(false) + self:SetInTeam(false) + self.TxtCur.gameObject:SetActiveEx(false) +end + +function XUiGridCharacterNew:SetPosition(x, y) + self.RectTransform.anchoredPosition = CS.UnityEngine.Vector2(x, y) +end + +return XUiGridCharacterNew \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCharacter/XUiGridElementDetail.lua b/Resources/Scripts/XUi/XUiCharacter/XUiGridElementDetail.lua new file mode 100644 index 00000000..5b23cc7f --- /dev/null +++ b/Resources/Scripts/XUi/XUiCharacter/XUiGridElementDetail.lua @@ -0,0 +1,18 @@ +local XUiGridElementDetail = XClass(nil, "XUiGridElementDetail") + +function XUiGridElementDetail:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiGridElementDetail:Refresh(elementId) + self.PanelCur.gameObject:SetActiveEx(elementId < 0) + elementId = elementId > 0 and elementId or -elementId + local elementConfig = XCharacterConfigs.GetCharElement(elementId) + self.TxtName.text = elementConfig.ElementName + self.TxtContent.text = elementConfig.Description + self.RImgIcon:SetRawImage(elementConfig.Icon) +end + +return XUiGridElementDetail \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCharacter/XUiGridSkillInfo.lua b/Resources/Scripts/XUi/XUiCharacter/XUiGridSkillInfo.lua new file mode 100644 index 00000000..a71c071d --- /dev/null +++ b/Resources/Scripts/XUi/XUiCharacter/XUiGridSkillInfo.lua @@ -0,0 +1,119 @@ +XUiGridSkillInfo = XClass(nil, "XUiGridSkillInfo") + +function XUiGridSkillInfo:Ctor(ui, skill, detailClickCb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.BtnDetails.CallBack = function() detailClickCb(self.SkillId) end + self.BtnNounParsing.CallBack = handler(self, self.OnClickBtnNounParsing) + self:UpdateData(skill) +end + +function XUiGridSkillInfo:SetIndex(index) + self.Index = index +end + +function XUiGridSkillInfo:UpdateEntryBtn() + if not XTool.IsNumberValid(self.SubSkillId) then + self.BtnNounParsing.gameObject:SetActiveEx(false) + return + end + + self.EntryList = XCharacterConfigs.GetSkillGradeDesConfigEntryList(self.SubSkillId, self.SubSkillLevel) + if XTool.IsTableEmpty(self.EntryList) then + self.BtnNounParsing.gameObject:SetActiveEx(false) + return + end + + self.BtnNounParsing.gameObject:SetActiveEx(true) +end + +function XUiGridSkillInfo:OnClickBtnNounParsing() + if XTool.IsTableEmpty(self.EntryList) then return end + + if not XLuaUiManager.IsUiShow("UiCharSkillOtherParsing") then + XLuaUiManager.Open("UiCharSkillOtherParsing", self.EntryList) + end +end + +function XUiGridSkillInfo:UpdateData(skill) + self.Skill = skill + self.TxtSkillLevel.text = skill.totalLevel + self.TxtSkillName.text = skill.configDes.Name + self.TxtSkillDesc.text = skill.configDes.Intro +end + +function XUiGridSkillInfo:SetSubInfo(characterId, index, level, skillId) + self.SkillId = skillId + + local config = self.Skill.subSkills[index] + local levelStr = level + + local addLevel = 0 + local addLevelStr = "" + local resonanceLevel = XDataCenter.CharacterManager.GetResonanceSkillLevel(characterId, skillId) + local assignLevel = XDataCenter.FubenAssignManager.GetSkillLevel(characterId, skillId) + + if (resonanceLevel and resonanceLevel > 0) then + addLevel = addLevel + resonanceLevel + end + + if (assignLevel and assignLevel > 0) then + addLevel = addLevel + assignLevel + end + + if addLevel ~= 0 then + addLevelStr = addLevelStr .. CS.XTextManager.GetText("CharacterSkillLevelDetail", addLevel) + levelStr = level .. addLevelStr + self.BtnDetails.gameObject:SetActiveEx(true) + else + self.BtnDetails.gameObject:SetActiveEx(false) + end + + self.SubSkillId = config.SubSkillId + self.SubSkillLevel = level + addLevel + + local gradeConfig = XCharacterConfigs.GetSkillGradeDesConfig(self.SubSkillId, self.SubSkillLevel) + self.TxtSkillLevel.text = levelStr + self.TxtSkillDesc.text = gradeConfig.Intro + self.TxtSkillName.text = gradeConfig.Name + + self:UpdateEntryBtn() +end + +function XUiGridSkillInfo:SetSubInfoByCharacterData(npcData, index, level, skillId, assignChapterRecords) + self.SkillId = skillId + + local config = self.Skill.subSkills[index] + local levelStr = level + + local addLevel = 0 + local addLevelStr = "" + local resonanceSkillLevelMap = XMagicSkillManager.GetResonanceSkillLevelMap(npcData) + local resonanceLevel = resonanceSkillLevelMap[skillId] or 0 + + local assignLevel = XDataCenter.FubenAssignManager.GetSkillLevelByCharacterData(npcData.Character, skillId, assignChapterRecords) + + if (resonanceLevel and resonanceLevel > 0) then + addLevel = addLevel + resonanceLevel + end + + if (assignLevel and assignLevel > 0) then + addLevel = addLevel + assignLevel + end + + if addLevel ~= 0 then + addLevelStr = addLevelStr .. CS.XTextManager.GetText("CharacterSkillLevelDetail", addLevel) + levelStr = level .. addLevelStr + self.BtnDetails.gameObject:SetActiveEx(true) + else + self.BtnDetails.gameObject:SetActiveEx(false) + end + + local gradeConfig = XCharacterConfigs.GetSkillGradeDesConfig(config.SubSkillId, level + addLevel) + self.TxtSkillLevel.text = levelStr + self.TxtSkillDesc.text = gradeConfig.Intro + self.TxtSkillName.text = gradeConfig.Name + + self:UpdateEntryBtn() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCharacter/XUiGridSkillItem.lua b/Resources/Scripts/XUi/XUiCharacter/XUiGridSkillItem.lua new file mode 100644 index 00000000..668a0324 --- /dev/null +++ b/Resources/Scripts/XUi/XUiCharacter/XUiGridSkillItem.lua @@ -0,0 +1,111 @@ +XUiGridSkillItem = XClass(nil, "XUiGridSkillItem") + +function XUiGridSkillItem:Ctor(rootUi, ui, skill, characterId, cb) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.SkillInfo = skill + self.ClickCallback = cb + self:InitAutoScript() + + self:UpdateInfo(characterId, self.SkillInfo) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiGridSkillItem:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiGridSkillItem:AutoInitUi() + self.PanelIconTip = XUiHelper.TryGetComponent(self.Transform, "PanelIconTip", nil) + self.PanelLock = XUiHelper.TryGetComponent(self.Transform, "PanelIconTip/PanelLock", nil) + self.ImgUpgradeTip = XUiHelper.TryGetComponent(self.Transform, "PanelIconTip/ImgUpgradeTip", "Image") + self.TxtTotalPoint = XUiHelper.TryGetComponent(self.Transform, "TxtTotalPoint", "Text") + self.TxtSkillName = XUiHelper.TryGetComponent(self.Transform, "TxtSkillName", "Text") + self.RImgSkillIcon = XUiHelper.TryGetComponent(self.Transform, "RImgSkillIcon", "RawImage") + self.BtnIconBg = XUiHelper.TryGetComponent(self.Transform, "BtnIconBg", "Button") +end + +function XUiGridSkillItem:GetAutoKey(uiNode, eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiGridSkillItem:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiGridSkillItem:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiGridSkillItem:AutoAddListener() + self.AutoCreateListeners = {} + XUiHelper.RegisterClickEvent(self, self.BtnIconBg, self.OnBtnIconBgClick) +end +-- auto +function XUiGridSkillItem:OnBtnIconBgClick() + if self.ClickCallback then + self.ClickCallback(self.SkillInfo) + end +end + +function XUiGridSkillItem:SetClickCallback(cb) + self.ClickCallback = cb +end + +function XUiGridSkillItem:UpdateInfo(characterId, skill) + self.SkillInfo = skill + + self.TxtSkillName.text = skill.Name + self.RImgSkillIcon:SetRawImage(skill.Icon) + + local addLevel = 0 + for _, skillId in pairs(skill.SkillIdList) do + addLevel = addLevel + XDataCenter.CharacterManager.GetSkillPlusLevel(characterId, skillId) + end + + if addLevel > 0 then + self.TxtTotalPoint.text = CS.XTextManager.GetText("CharacterResonanceSkillDes", skill.TotalLevel, addLevel) + else + self.TxtTotalPoint.text = CS.XTextManager.GetText("HostelDeviceLevel") .. ':' .. skill.TotalLevel + end + + self.ImgUpgradeTip.gameObject:SetActive(false) + self.PanelLock.gameObject:SetActive(false) + + if (skill.TotalLevel <= 0) then + self.PanelLock.gameObject:SetActive(true) + return + end + + local canUpdate = false + for _, subSkill in ipairs(skill.subSkills) do + if (XDataCenter.CharacterManager.CheckCanUpdateSkill(characterId, subSkill.SubSkillId, subSkill.Level)) then + canUpdate = true + break + end + end + + if (canUpdate) then + self.ImgUpgradeTip.gameObject:SetActive(true) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCharacter/XUiGridSubSkill.lua b/Resources/Scripts/XUi/XUiCharacter/XUiGridSubSkill.lua new file mode 100644 index 00000000..18319f6f --- /dev/null +++ b/Resources/Scripts/XUi/XUiCharacter/XUiGridSubSkill.lua @@ -0,0 +1,118 @@ +local RESONANCED_GRID_TEXT_COLOR = { + [true] = XUiHelper.Hexcolor2Color("fee82aff"), + [false] = XUiHelper.Hexcolor2Color("ffffffff"), +} + +XUiGridSubSkill = XClass(nil, "XUiGridSubSkill") + +function XUiGridSubSkill:Ctor(ui, index, callback) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Index = index + self.ClickCallback = callback + self:InitAutoScript() + self:SetSelect(false) + self.PanelIconTip.gameObject:SetActive(true) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiGridSubSkill:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiGridSubSkill:AutoInitUi() + self.TxtSubSkillLevel = XUiHelper.TryGetComponent(self.Transform, "ImgLevelBg/TxtSubSkillLevel", "Text") + self.PanelIconTip = XUiHelper.TryGetComponent(self.Transform, "PanelIconTip", nil) + self.ImgUpgrade = XUiHelper.TryGetComponent(self.Transform, "PanelIconTip/ImgUpgrade", "Image") + self.ImgLock = XUiHelper.TryGetComponent(self.Transform, "PanelIconTip/ImgLock") + self.ImgBgSelected = XUiHelper.TryGetComponent(self.Transform, "ImgBgSelected", "Image") + self.RImgSubSkillIconSelected = XUiHelper.TryGetComponent(self.Transform, "ImgBgSelected/RImgSubSkillIconSelected", "RawImage") + self.RImgSubSkillIconNormal = XUiHelper.TryGetComponent(self.Transform, "RImgSubSkillIconNormal", "RawImage") + self.BtnSubSkillIconBg = XUiHelper.TryGetComponent(self.Transform, "BtnSubSkillIconBg", "Button") +end + +function XUiGridSubSkill:GetAutoKey(uiNode, eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiGridSubSkill:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiGridSubSkill:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiGridSubSkill:AutoAddListener() + self.AutoCreateListeners = {} + XUiHelper.RegisterClickEvent(self, self.BtnSubSkillIconBg, self.OnBtnSubSkillIconBgClick) +end +-- auto +function XUiGridSubSkill:OnBtnSubSkillIconBgClick() + if (self.ClickCallback) then + self.ClickCallback(self.SubSkillInfo, self.Index) + end +end + +function XUiGridSubSkill:UpdateGrid(characterId, subSkillInfo) + self.SubSkillInfo = subSkillInfo + + if subSkillInfo.configDes and (subSkillInfo.configDes.Icon and subSkillInfo.configDes.Icon ~= "") then + self.RImgSubSkillIconNormal:SetRawImage(subSkillInfo.configDes.Icon) + self.RImgSubSkillIconSelected:SetRawImage(subSkillInfo.configDes.Icon) + else + XLog.Warning("sub skill config icon is null. id = " .. subSkillInfo.SubSkillId) + end + + local addLevel = XDataCenter.CharacterManager.GetSkillPlusLevel(characterId, subSkillInfo.SubSkillId) + local totalLevel = subSkillInfo.Level + addLevel + local curLevel = totalLevel == 0 and '' or CS.XTextManager.GetText("HostelDeviceLevel") .. ':' .. totalLevel + self.TxtSubSkillLevel.color = RESONANCED_GRID_TEXT_COLOR[addLevel > 0] + self.TxtSubSkillLevel.text = curLevel + + local min_max = XCharacterConfigs.GetSubSkillMinMaxLevel(subSkillInfo.SubSkillId) + if (subSkillInfo.Level >= min_max.Max) then + self.ImgLock.gameObject:SetActive(false) + self.ImgUpgrade.gameObject:SetActive(false) + else + self.ImgLock.gameObject:SetActive(subSkillInfo.Level <= 0) + self.ImgUpgrade.gameObject:SetActive(XDataCenter.CharacterManager.CheckCanUpdateSkill(characterId, subSkillInfo.SubSkillId, subSkillInfo.Level)) + end + + self.GameObject:SetActive(true) +end + +function XUiGridSubSkill:SetSelect(isSelect) + if (self.ImgBgSelected) then + self.ImgBgSelected.gameObject:SetActive(isSelect) + end +end + +function XUiGridSubSkill:Reset() + self.SubSkillInfo = nil + self.GameObject:SetActive(false) + self:SetSelect(false) +end + +function XUiGridSubSkill:ResetSelect(subSkillId) + self:SetSelect(self.SubSkillInfo and self.SubSkillInfo.SubSkillId == subSkillId) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCharacter/XUiGridSwitchSkill.lua b/Resources/Scripts/XUi/XUiCharacter/XUiGridSwitchSkill.lua new file mode 100644 index 00000000..96ebf028 --- /dev/null +++ b/Resources/Scripts/XUi/XUiCharacter/XUiGridSwitchSkill.lua @@ -0,0 +1,28 @@ +local XUiGridSwitchSkill = XClass(nil, "XUiGridSwitchSkill") + +function XUiGridSwitchSkill:Ctor(ui, switchCb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.SwitchCb = switchCb + XTool.InitUiObject(self) + self.BtnSelect.CallBack = function() + self:OnClickBtnSelect() + end +end + +function XUiGridSwitchSkill:Refresh(skillId, skillLevel, isCurrent) + self.SkillId = skillId + + self.SelectIcon.gameObject:SetActiveEx(isCurrent) + self.BtnSelect.gameObject:SetActiveEx(not isCurrent) + + local name, intro = XCharacterConfigs.GetSkillGradeDesConfigSkillDes(skillId, skillLevel) + self.SkillTitle.text = name + self.SkillText.text = intro +end + +function XUiGridSwitchSkill:OnClickBtnSelect() + XDataCenter.CharacterManager.ReqSwitchSkill(self.SkillId, self.SwitchCb) +end + +return XUiGridSwitchSkill \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCharacter/XUiPanelCharGrade.lua b/Resources/Scripts/XUi/XUiCharacter/XUiPanelCharGrade.lua new file mode 100644 index 00000000..fd822467 --- /dev/null +++ b/Resources/Scripts/XUi/XUiCharacter/XUiPanelCharGrade.lua @@ -0,0 +1,477 @@ +XUiPanelCharGrade = XClass(nil, "XUiPanelCharGrade") + +local Show_Part = { + [1] = XNpcAttribType.Life, + [2] = XNpcAttribType.AttackNormal, + [3] = XNpcAttribType.DefenseNormal, + [4] = XNpcAttribType.Crit, +} + +local MAX_CONDITION_NUM = 5 + +function XUiPanelCharGrade:Ctor(ui, parent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Parent = parent + + self:InitAutoScript() + self.ConditionGrids = {} + self.CharGradeUpgradePanel = XUiPanelGradeUpgrade.New(self.PanelGradeUpgrade, self.Parent, self) + self.CharGradeUpgradePanel.GameObject:SetActive(false) + self.CanvasGroup = self.PanelGrades:GetComponent("CanvasGroup") + self.Star = { self.ImgStar1, self.ImgStar2, self.ImgStar3, self.ImgStar4 } + self.OnStar = { self.ImgOnStar1, self.ImgOnStar2, self.ImgOnStar3, self.ImgOnStar4 } + self.Grading = { + Recruit = 1, --新兵 + RecruitStar = 1, --新兵最大等级 + Picked = 2, --精锐 + PickedStar = 3, --精锐最大等级 + MainForce = 3, --主力 + MainForceStar = 6, --主力最大等级 + Ace = 3, --王牌 + AceStar = 9, --王牌最大等级 + TheChosen = 4, --天选 + TheChosenStar = 13, --天选最大等级 + } + + self.GradeStarCheck = { + [self.Grading.RecruitStar] = true, + [self.Grading.PickedStar] = true, + [self.Grading.MainForceStar] = true, + [self.Grading.AceStar] = true, + [self.Grading.TheChosenStar] = true, + } + + self.TxtAttrib = { + [1] = self.TxtAttrib1, + [2] = self.TxtAttrib2, + [3] = self.TxtAttrib3, + [4] = self.TxtAttrib4 + } + + self.TxtNormal = { + [1] = self.TxtNormal1A, + [2] = self.TxtNormal2A, + [3] = self.TxtNormal3A, + [4] = self.TxtNormal4A + } + + self.TxtLevel = { + [1] = self.TxtLevel1A, + [2] = self.TxtLevel2A, + [3] = self.TxtLevel3A, + [4] = self.TxtLevel4A + } + + self.PanelCondition = { + [1] = self.PanelCondition1, + [2] = self.PanelCondition2, + [3] = self.PanelCondition3, + [4] = self.PanelCondition4, + [5] = self.PanelCondition5, + } + + self.TxtOffSatisfy = { + [1] = self.TxtOffSatisfy1, + [2] = self.TxtOffSatisfy2, + [3] = self.TxtOffSatisfy3, + [4] = self.TxtOffSatisfy4, + [5] = self.TxtOffSatisfy5, + } + + self.TxtOnSatisfy = { + [1] = self.TxtOnSatisfy1, + [2] = self.TxtOnSatisfy2, + [3] = self.TxtOnSatisfy3, + [4] = self.TxtOnSatisfy4, + [5] = self.TxtOnSatisfy5, + } + + self.PanelOff = { + [1] = self.PanelOff1, + [2] = self.PanelOff2, + [3] = self.PanelOff3, + [4] = self.PanelOff4, + [5] = self.PanelOff5, + } + + self.PanelOn = { + [1] = self.PanelOn1, + [2] = self.PanelOn2, + [3] = self.PanelOn3, + [4] = self.PanelOn4, + [5] = self.PanelOn5, + } +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelCharGrade:InitAutoScript() + self:AutoInitUi() + XTool.InitUiObject(self) + self:AutoAddListener() +end + +function XUiPanelCharGrade:AutoInitUi() + self.PanelGrades = self.Transform:Find("PanelGrades") + self.PanelParts = self.Transform:Find("PanelGrades/PanelParts") + self.PanelPartsItems = self.Transform:Find("PanelGrades/PanelParts/PanelPartsItems") + self.GridPart1 = self.Transform:Find("PanelGrades/PanelParts/PanelPartsItems/GridPart1") + self.TxtAttrib1 = self.Transform:Find("PanelGrades/PanelParts/PanelPartsItems/GridPart1/Image/TxtAttrib1"):GetComponent("Text") + self.TxtNormal1A = self.Transform:Find("PanelGrades/PanelParts/PanelPartsItems/GridPart1/Image/TxtNormal1"):GetComponent("Text") + self.TxtLevel1A = self.Transform:Find("PanelGrades/PanelParts/PanelPartsItems/GridPart1/Image/TxtLevel1"):GetComponent("Text") + self.GridPart2 = self.Transform:Find("PanelGrades/PanelParts/PanelPartsItems/GridPart2") + self.TxtAttrib2 = self.Transform:Find("PanelGrades/PanelParts/PanelPartsItems/GridPart2/Image/TxtAttrib2"):GetComponent("Text") + self.TxtNormal2A = self.Transform:Find("PanelGrades/PanelParts/PanelPartsItems/GridPart2/Image/TxtNormal2"):GetComponent("Text") + self.TxtLevel2A = self.Transform:Find("PanelGrades/PanelParts/PanelPartsItems/GridPart2/Image/TxtLevel2"):GetComponent("Text") + self.GridPart3 = self.Transform:Find("PanelGrades/PanelParts/PanelPartsItems/GridPart3") + self.TxtAttrib3 = self.Transform:Find("PanelGrades/PanelParts/PanelPartsItems/GridPart3/Image/TxtAttrib3"):GetComponent("Text") + self.TxtNormal3A = self.Transform:Find("PanelGrades/PanelParts/PanelPartsItems/GridPart3/Image/TxtNormal3"):GetComponent("Text") + self.TxtLevel3A = self.Transform:Find("PanelGrades/PanelParts/PanelPartsItems/GridPart3/Image/TxtLevel3"):GetComponent("Text") + self.GridPart4 = self.Transform:Find("PanelGrades/PanelParts/PanelPartsItems/GridPart4") + self.TxtAttrib4 = self.Transform:Find("PanelGrades/PanelParts/PanelPartsItems/GridPart4/Image/TxtAttrib4"):GetComponent("Text") + self.TxtNormal4A = self.Transform:Find("PanelGrades/PanelParts/PanelPartsItems/GridPart4/Image/TxtNormal4"):GetComponent("Text") + self.TxtLevel4A = self.Transform:Find("PanelGrades/PanelParts/PanelPartsItems/GridPart4/Image/TxtLevel4"):GetComponent("Text") + self.PanelTitle = self.Transform:Find("PanelGrades/DetailPanel/PanelTitle") + self.PanelConditions = self.Transform:Find("PanelGrades/DetailPanel/PanelConditions") + self.PanelCondition5 = self.Transform:Find("PanelGrades/DetailPanel/PanelConditions/PanelCondition5") + self.PanelOff5 = self.Transform:Find("PanelGrades/DetailPanel/PanelConditions/PanelCondition5/PanelOff5") + self.TxtOffSatisfy5 = self.Transform:Find("PanelGrades/DetailPanel/PanelConditions/PanelCondition5/PanelOff5/TxtOffSatisfy5"):GetComponent("Text") + self.PanelOn5 = self.Transform:Find("PanelGrades/DetailPanel/PanelConditions/PanelCondition5/PanelOn5") + self.TxtOnSatisfy5 = self.Transform:Find("PanelGrades/DetailPanel/PanelConditions/PanelCondition5/PanelOn5/TxtOnSatisfy5"):GetComponent("Text") + self.PanelCondition4 = self.Transform:Find("PanelGrades/DetailPanel/PanelConditions/PanelCondition4") + self.PanelOff4 = self.Transform:Find("PanelGrades/DetailPanel/PanelConditions/PanelCondition4/PanelOff4") + self.TxtOffSatisfy4 = self.Transform:Find("PanelGrades/DetailPanel/PanelConditions/PanelCondition4/PanelOff4/TxtOffSatisfy4"):GetComponent("Text") + self.PanelOn4 = self.Transform:Find("PanelGrades/DetailPanel/PanelConditions/PanelCondition4/PanelOn4") + self.TxtOnSatisfy4 = self.Transform:Find("PanelGrades/DetailPanel/PanelConditions/PanelCondition4/PanelOn4/TxtOnSatisfy4"):GetComponent("Text") + self.PanelCondition3 = self.Transform:Find("PanelGrades/DetailPanel/PanelConditions/PanelCondition3") + self.PanelOff3 = self.Transform:Find("PanelGrades/DetailPanel/PanelConditions/PanelCondition3/PanelOff3") + self.TxtOffSatisfy3 = self.Transform:Find("PanelGrades/DetailPanel/PanelConditions/PanelCondition3/PanelOff3/TxtOffSatisfy3"):GetComponent("Text") + self.PanelOn3 = self.Transform:Find("PanelGrades/DetailPanel/PanelConditions/PanelCondition3/PanelOn3") + self.TxtOnSatisfy3 = self.Transform:Find("PanelGrades/DetailPanel/PanelConditions/PanelCondition3/PanelOn3/TxtOnSatisfy3"):GetComponent("Text") + self.PanelCondition2 = self.Transform:Find("PanelGrades/DetailPanel/PanelConditions/PanelCondition2") + self.PanelOff2 = self.Transform:Find("PanelGrades/DetailPanel/PanelConditions/PanelCondition2/PanelOff2") + self.TxtOffSatisfy2 = self.Transform:Find("PanelGrades/DetailPanel/PanelConditions/PanelCondition2/PanelOff2/TxtOffSatisfy2"):GetComponent("Text") + self.PanelOn2 = self.Transform:Find("PanelGrades/DetailPanel/PanelConditions/PanelCondition2/PanelOn2") + self.TxtOnSatisfy2 = self.Transform:Find("PanelGrades/DetailPanel/PanelConditions/PanelCondition2/PanelOn2/TxtOnSatisfy2"):GetComponent("Text") + self.PanelCondition1 = self.Transform:Find("PanelGrades/DetailPanel/PanelConditions/PanelCondition1") + self.PanelOff1 = self.Transform:Find("PanelGrades/DetailPanel/PanelConditions/PanelCondition1/PanelOff1") + self.TxtOffSatisfy1 = self.Transform:Find("PanelGrades/DetailPanel/PanelConditions/PanelCondition1/PanelOff1/TxtOffSatisfy1"):GetComponent("Text") + self.PanelOn1 = self.Transform:Find("PanelGrades/DetailPanel/PanelConditions/PanelCondition1/PanelOn1") + self.TxtOnSatisfy1 = self.Transform:Find("PanelGrades/DetailPanel/PanelConditions/PanelCondition1/PanelOn1/TxtOnSatisfy1"):GetComponent("Text") + self.ImgMax1 = self.Transform:Find("PanelGrades/ImgMax1"):GetComponent("Image") + self.ImgMaxPartGrade = self.Transform:Find("PanelGrades/DetailPanel/Advanced/ImgMaxPartGrade"):GetComponent("Image") + self.PanelGrade = self.Transform:Find("PanelGrades/PanelGrade") + self.RImgIconTitle = self.Transform:Find("PanelGrades/PanelGrade/RImgIconTitle"):GetComponent("RawImage") + self.PanelStarGoup = self.Transform:Find("PanelGrades/PanelGrade/PanelStarGoup") + self.ImgStar1 = self.Transform:Find("PanelGrades/PanelGrade/PanelStarGoup/Star1/ImgStar1"):GetComponent("Image") + self.ImgOnStar1 = self.Transform:Find("PanelGrades/PanelGrade/PanelStarGoup/Star1/ImgOnStar1"):GetComponent("Image") + self.ImgStar2 = self.Transform:Find("PanelGrades/PanelGrade/PanelStarGoup/Star2/ImgStar2"):GetComponent("Image") + self.ImgOnStar2 = self.Transform:Find("PanelGrades/PanelGrade/PanelStarGoup/Star2/ImgOnStar2"):GetComponent("Image") + self.ImgStar3 = self.Transform:Find("PanelGrades/PanelGrade/PanelStarGoup/Star3/ImgStar3"):GetComponent("Image") + self.ImgOnStar3 = self.Transform:Find("PanelGrades/PanelGrade/PanelStarGoup/Star3/ImgOnStar3"):GetComponent("Image") + self.ImgStar4 = self.Transform:Find("PanelGrades/PanelGrade/PanelStarGoup/Star4/ImgStar4"):GetComponent("Image") + self.ImgOnStar4 = self.Transform:Find("PanelGrades/PanelGrade/PanelStarGoup/Star4/ImgOnStar4"):GetComponent("Image") + self.BtnWisdom = self.Transform:Find("PanelGrades/DetailPanel/Advanced/BtnWisdom"):GetComponent("Button") + self.TxtCosume = self.Transform:Find("PanelGrades/DetailPanel/TxtCosume"):GetComponent("Text") + self.TxtCosumeOn = self.Transform:Find("PanelGrades/DetailPanel/TxtCosumeOn"):GetComponent("Text") + self.PanelMaxLevelShow = self.Transform:Find("PanelGrades/DetailPanel/PanelMaxLevelShow") + self.PanelGradeUpgrade = self.Transform:Find("PanelGradeUpgrade") +end + +function XUiPanelCharGrade:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelCharGrade:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelCharGrade:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelCharGrade:AutoAddListener() + self:RegisterClickEvent(self.BtnWisdom, self.OnBtnWisdomClick) +end +-- auto +function XUiPanelCharGrade:OnBtnCancelClick() + +end + +function XUiPanelCharGrade:OnBtnConfirmClick() + +end +function XUiPanelCharGrade:OnBtnWisdomClick() + self:UpgradePart() +end + +function XUiPanelCharGrade:ShowPanel(characterId) + self.GameObject:SetActive(true) + self.CharacterId = characterId or self.CharacterId + self.IsShow = true + self.PanelGrades.gameObject:SetActive(true) + self.GradeQiehuan:PlayTimelineAnimation() + self.PanelPartsItems.gameObject:SetActive(true) + self.CharGradeUpgradePanel.GameObject:SetActive(false) + self:UpdateGradeData() + self.CanvasGroup.alpha = 1 +end + +function XUiPanelCharGrade:HidePanel() + self.IsShow = false + self.CurPartPos = nil + if (self.GridParts) then + for _, grid in pairs(self.GridParts) do + grid:SetSelect(false) + end + end + self.GameObject:SetActive(false) + self.PanelGrades.gameObject:SetActive(false) +end + +-- 重新刷新级别数据 +function XUiPanelCharGrade:UpdateGradeData() + local character = XDataCenter.CharacterManager.GetCharacter(self.CharacterId) + local isMaxGrade = XDataCenter.CharacterManager.IsMaxCharGrade(character) + if isMaxGrade then + self:UpdateAttribMax() + self:UpdateGradeInfo() + else + self.PanelMaxLevelShow.gameObject:SetActive(false) + self.PanelTitle.gameObject:SetActive(true) + self.PanelConditions.gameObject:SetActive(true) + self.BtnWisdom.gameObject:SetActive(true) + self.ImgMaxPartGrade.gameObject:SetActive(false) + self.TxtCosumeOn.gameObject:SetActive(true) + self.TxtCosume.gameObject:SetActive(true) + + self:UpdateGradeInfo() + self:UpdateAttribs() + self:UpdateConditions() + self:UpdateUseItemView() + end +end + +-- 刷新主面板信息 +function XUiPanelCharGrade:UpdateGradeInfo() + local characterId = self.CharacterId + local character = XDataCenter.CharacterManager.GetCharacter(characterId) + + local charGradeTemplates = XCharacterConfigs.GetGradeTemplates(characterId, character.Grade) + self.RImgIconTitle:SetRawImage(charGradeTemplates.GradeBigIcon) + self:UpdateStarSprite(charGradeTemplates.NoStar, charGradeTemplates.Star) + + if character.Grade > self.Grading.TheChosenStar then + self:UpdateStarInfo(self.Grading.TheChosen, character.Grade - self.Grading.AceStar) + return + end + + if character.Grade > self.Grading.AceStar then + self:UpdateStarInfo(self.Grading.TheChosen, character.Grade - self.Grading.AceStar) + return + end + + if character.Grade > self.Grading.MainForceStar then + self:UpdateStarInfo(self.Grading.Ace, character.Grade - self.Grading.MainForceStar) + return + end + + if character.Grade > self.Grading.PickedStar then + self:UpdateStarInfo(self.Grading.MainForce, character.Grade - self.Grading.PickedStar) + return + end + + if character.Grade > self.Grading.RecruitStar then + self:UpdateStarInfo(self.Grading.Picked, character.Grade - self.Grading.RecruitStar) + return + end + + if character.Grade <= self.Grading.RecruitStar then + self:UpdateStarInfo(self.Grading.Recruit, character.Grade) + return + end +end + +function XUiPanelCharGrade:UpdateStarSprite(starSprite, onStarSprite) + for i = 1, #self.Star do + self.Parent:SetUiSprite(self.Star[i], starSprite) + self.Parent:SetUiSprite(self.OnStar[i], onStarSprite) + end +end + +-- 刷新星星界面 +function XUiPanelCharGrade:UpdateStarInfo(index, onIndex) + for i = 1, #self.Star do + self.Star[i].gameObject:SetActive(false) + self.OnStar[i].gameObject:SetActive(false) + end + + if onIndex > #self.Star then + for i = 1, #self.Star do + self.Star[i].gameObject:SetActive(false) + self.OnStar[i].gameObject:SetActive(true) + end + return + end + + for i = 1, index do + self.Star[i].gameObject:SetActive(true) + end + + for i = 1, onIndex do + self.OnStar[i].gameObject:SetActive(true) + end +end + +function XUiPanelCharGrade:UpdateAttribs() + local characterId = self.CharacterId + local character = XDataCenter.CharacterManager.GetCharacter(characterId) + + local curGradeConfig = XCharacterConfigs.GetGradeTemplates(characterId, character.Grade) + local nextGradeConfig = XCharacterConfigs.GetGradeTemplates(characterId, character.Grade + 1) + local nextAttrib = XAttribManager.GetBaseAttribs(nextGradeConfig.AttrId) + local curAttrib = XAttribManager.GetBaseAttribs(curGradeConfig.AttrId) + + for i = 1, 4 do + local name = XAttribManager.GetAttribNameByIndex(Show_Part[i]) + local attribType = Show_Part[i] + self.TxtAttrib[i].text = name + self.TxtNormal[i].text = XMath.ToMinInt(FixToDouble(curAttrib[attribType])) + self.TxtLevel[i].text = string.format("(%s)", XMath.ToMinInt(FixToDouble(nextAttrib[attribType]))) + end +end + +function XUiPanelCharGrade:UpdateAttribMax() + local characterId = self.CharacterId + local character = XDataCenter.CharacterManager.GetCharacter(characterId) + + self.PanelTitle.gameObject:SetActive(false) + self.PanelConditions.gameObject:SetActive(false) + self.PanelMaxLevelShow.gameObject:SetActive(true) + self.ImgMaxPartGrade.gameObject:SetActive(true) + self.BtnWisdom.gameObject:SetActive(false) + self.TxtCosumeOn.gameObject:SetActive(false) + self.TxtCosume.gameObject:SetActive(false) + + local curGradeConfig = XCharacterConfigs.GetGradeTemplates(characterId, character.Grade) + local curAttrib = XAttribManager.GetBaseAttribs(curGradeConfig.AttrId) + for i = 1, 4 do + local name = XAttribManager.GetAttribNameByIndex(Show_Part[i]) + local attribType = Show_Part[i] + self.TxtAttrib[i].text = name + self.TxtNormal[i].text = XMath.ToMinInt(FixToDouble(curAttrib[attribType])) + self.TxtLevel[i].text = "" + end +end + +function XUiPanelCharGrade:UpdateConditions() + local characterId = self.CharacterId + local character = XDataCenter.CharacterManager.GetCharacter(characterId) + + local gradeTemplate = XCharacterConfigs.GetGradeTemplates(characterId, character.Grade) + local conditions = gradeTemplate.ConditionId + + if not conditions then + return + end + + for i = 1, MAX_CONDITION_NUM do + if conditions[i] then + local config = XConditionManager.GetConditionTemplate(conditions[i]) + if config then + self.PanelCondition[i].gameObject:SetActive(true) + self.TxtOnSatisfy[i].text = config.Desc + self.TxtOffSatisfy[i].text = config.Desc + + local isCompleted = XConditionManager.CheckCondition(conditions[i], characterId) + self.PanelOn[i].gameObject:SetActive(isCompleted) + self.PanelOff[i].gameObject:SetActive(not isCompleted) + end + else + self.PanelCondition[i].gameObject:SetActive(false) + end + end +end + +function XUiPanelCharGrade:UpdateUseItemView() + local characterId = self.CharacterId + if not characterId then return end + local character = XDataCenter.CharacterManager.GetCharacter(characterId) + + local gradeConfig = XCharacterConfigs.GetGradeTemplates(characterId, character.Grade) + local itemCode = gradeConfig.UseItemKey + if not XTool.IsNumberValid(itemCode) then return end + + local itemNum = gradeConfig.UseItemCount + local item = XDataCenter.ItemManager.GetItemTemplate(itemCode) + local consumeText = CS.XTextManager.GetText("CharGradeUseItem", item.Name, itemNum) + self.TxtCosume.text = consumeText + self.TxtCosumeOn.text = consumeText + + local isCoinEnough = XDataCenter.CharacterManager.IsUseItemEnough(itemCode, itemNum) + if isCoinEnough then + self.TxtCosumeOn.gameObject:SetActive(true) + self.TxtCosume.gameObject:SetActive(false) + else + self.TxtCosumeOn.gameObject:SetActive(false) + self.TxtCosume.gameObject:SetActive(true) + end +end + +function XUiPanelCharGrade:CloseBtn() + self.BtnWisdom.gameObject:SetActive(false) +end + +function XUiPanelCharGrade:UpgradePart() + local characterId = self.CharacterId + local character = XDataCenter.CharacterManager.GetCharacter(characterId) + + local isMaxGrade = XDataCenter.CharacterManager.IsMaxCharGrade(character) + if isMaxGrade then + return + end + + local gradeConfig = XCharacterConfigs.GetGradeTemplates(characterId, character.Grade) + local conditions = gradeConfig.ConditionId + + for i = 1, MAX_CONDITION_NUM do + if conditions[i] then + local isConditionEnough = XConditionManager.CheckCondition(conditions[i], characterId) + if (not isConditionEnough) then + XUiManager.TipText("CharacterPromotePartItemLimit") + return + end + end + end + + if not XDataCenter.ItemManager.DoNotEnoughBuyAsset(gradeConfig.UseItemKey, + gradeConfig.UseItemCount, + 1, + function() + self:UpgradePart() + end, + "CharacterPromotePartCoinLimit") then + return + end + + self.CharGradeUpgradePanel:OldCharUpgradeInfo(character) + XDataCenter.CharacterManager.PromoteGrade(characterId, function(oldGrade) + CS.XAudioManager.PlaySound(XSoundManager.UiBasicsMusic.UiCharacter_GradeUp) + + self:UpdateGradeData() + self.GradeUpgradeEnable:PlayTimelineAnimation() + + if self.GradeStarCheck[oldGrade] then + self.CharGradeUpgradePanel:ShowLevelInfo(characterId) + else + XEventManager.DispatchEvent(XEventId.EVENT_CHARACTER_INCREASE_TIP, CS.XTextManager.GetText("CharacterUpgradeComplete")) + end + end) + +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCharacter/XUiPanelCharLevel.lua b/Resources/Scripts/XUi/XUiCharacter/XUiPanelCharLevel.lua new file mode 100644 index 00000000..1d0e16a0 --- /dev/null +++ b/Resources/Scripts/XUi/XUiCharacter/XUiPanelCharLevel.lua @@ -0,0 +1,87 @@ +XUiPanelCharLevel = XClass(nil, "XUiPanelCharLevel") + +function XUiPanelCharLevel:Ctor(ui, parent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Parent = parent + XTool.InitUiObject(self) + self:AutoAddListener() + self.SelectLevelItems = XUiPanelSelectLevelItems.New(self.PanelSelectLevelItems, self.Parent, self) +end + +function XUiPanelCharLevel:AutoAddListener() + self.BtnLevelUpButton.CallBack = function () + self:OnBtnLevelUpButtonClick() + end + self.BtnLiberation.CallBack = function () + self:OnBtnLiberationClick() + end +end + +function XUiPanelCharLevel:OnBtnLevelUpButtonClick() + self.SelectLevelItems:ShowPanel(self.CharacterId) + self.SelectLevelItemsEnable:PlayTimelineAnimation() + self.PanelLeveInfo.gameObject:SetActive(false) +end + +function XUiPanelCharLevel:OnBtnLiberationClick() + local characterId = self.CharacterId + XLuaUiManager.Open("UiExhibitionInfo", characterId) +end + +function XUiPanelCharLevel:OnCheckExhibitionRedPoint(count) + self.BtnLiberation:ShowReddot(count >= 0) +end + +function XUiPanelCharLevel:ShowPanel(characterId) + self.CharacterId = characterId or self.CharacterId + self.IsShow = true + self.GameObject:SetActive(true) + self.PanelLeveInfo.gameObject:SetActive(true) + self.LeveInfoQiehuan:PlayTimelineAnimation() + self:HideSelectLevelItems() + self:UpdatePanel() + self:CheckMaxLevel() + self:UpdateLiberationProgress() + XRedPointManager.AddRedPointEvent(self.BtnLiberation, self.OnCheckExhibitionRedPoint, self, { XRedPointConditions.Types.CONDITION_EXHIBITION_NEW }, characterId) +end + +function XUiPanelCharLevel:HidePanel() + self.IsShow = false + self.GameObject:SetActive(false) + self:HideSelectLevelItems() +end + +function XUiPanelCharLevel:HideSelectLevelItems() + if self.GameObject.activeSelf then + self.SelectLevelItemsDisable:PlayTimelineAnimation() + end + self.SelectLevelItems:HidePanel() +end + +function XUiPanelCharLevel:CheckMaxLevel() + local isMaxLevel = XDataCenter.CharacterManager.IsMaxLevel(self.CharacterId) + self.BtnLevelUpButton.gameObject:SetActive(not isMaxLevel) + self.ImgMaxLevel.gameObject:SetActive(isMaxLevel) +end + +function XUiPanelCharLevel:UpdatePanel() + local characterId = self.CharacterId + local character = XDataCenter.CharacterManager.GetCharacter(characterId) + local nextLeveExp = XCharacterConfigs.GetNextLevelExp(characterId, character.Level) + self.TxtCurLevel.text = character.Level + self.TxtMaxLevel.text = "/" .. XCharacterConfigs.GetCharMaxLevel(characterId) + self.TxtExp.text = character.Exp .. "/" .. nextLeveExp + self.ImgFill.fillAmount = character.Exp / nextLeveExp + self.TxtAttack.text = FixToInt(character.Attribs[XNpcAttribType.AttackNormal]) + self.TxtLife.text = FixToInt(character.Attribs[XNpcAttribType.Life]) + self.TxtDefense.text = FixToInt(character.Attribs[XNpcAttribType.DefenseNormal]) + self.TxtCrit.text = FixToInt(character.Attribs[XNpcAttribType.Crit]) +end + +function XUiPanelCharLevel:UpdateLiberationProgress() + local characterId = self.CharacterId + local growUpLevel = XDataCenter.ExhibitionManager.GetCharacterGrowUpLevel(characterId) + local progress = (growUpLevel - 1) / (XCharacterConfigs.GrowUpLevel.End - 1) + self.ImgLiberationProgress.fillAmount = progress +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCharacter/XUiPanelCharProperty.lua b/Resources/Scripts/XUi/XUiCharacter/XUiPanelCharProperty.lua new file mode 100644 index 00000000..fbd8967b --- /dev/null +++ b/Resources/Scripts/XUi/XUiCharacter/XUiPanelCharProperty.lua @@ -0,0 +1,228 @@ +local PANEL_INDEX = { + Level = 1, + Grade = 2, + Quality = 3, + Skill = 4, +} + +local XUiPanelCharProperty = XLuaUiManager.Register(XLuaUi, "UiPanelCharProperty") + +function XUiPanelCharProperty:OnAwake() + self:AddListener() +end + +function XUiPanelCharProperty:OnStart(parent, defaultIdx) + self.Parent = parent + self.DefaultIdx = defaultIdx + + self:InitChildUiInfos() + self:InitBtnTabGroup() + self:RegisterOtherEvent() + self:RegisterRedPointEvent() +end + +function XUiPanelCharProperty:OnEnable(parent, defaultIdx) + self.CharacterId = self.Parent.CharacterId + self.Parent.PanelCharacterTypeBtns.gameObject:SetActiveEx(false) + self.Parent.SViewCharacterList.gameObject:SetActiveEx(false) + self.Parent.BtnFashion.gameObject:SetActiveEx(false) + self.Parent.BtnOwnedDetail.gameObject:SetActiveEx(false) + self.PanelPropertyButtons:SelectIndex(self.DefaultIdx or self.SelectedIndex or PANEL_INDEX.Level) +end + +function XUiPanelCharProperty:OnDisable() + self.Parent.PanelCharacterTypeBtns.gameObject:SetActiveEx(true) + self.Parent.SViewCharacterList.gameObject:SetActiveEx(true) + self.Parent.BtnFashion.gameObject:SetActiveEx(true) + self.Parent.BtnOwnedDetail.gameObject:SetActiveEx(true) +end + +function XUiPanelCharProperty:OnDestroy() + self:RemoveOtherEvent() +end + +function XUiPanelCharProperty:InitChildUiInfos() + self.PanelsMap = {} + self.ChildUiInitInfos = { + [PANEL_INDEX.Level] = { + ChildClass = XUiPanelCharLevel, + UiParent = self.PanelCharLevel, + AssetPath = XUiConfigs.GetComponentUrl(self.Name .. PANEL_INDEX.Level), + }, + [PANEL_INDEX.Skill] = { + ChildClass = XUiPanelCharSkill, + UiParent = self.PanelCharSkill, + AssetPath = XUiConfigs.GetComponentUrl(self.Name .. PANEL_INDEX.Skill), + }, + [PANEL_INDEX.Quality] = { + ChildClass = XUiPanelCharQuality, + UiParent = self.PanelCharQuality, + AssetPath = XUiConfigs.GetComponentUrl(self.Name .. PANEL_INDEX.Quality), + }, + [PANEL_INDEX.Grade] = { + ChildClass = XUiPanelCharGrade, + UiParent = self.PanelCharGrade, + AssetPath = XUiConfigs.GetComponentUrl(self.Name .. PANEL_INDEX.Grade), + }, + } +end + +function XUiPanelCharProperty:InitBtnTabGroup() + self.BtnTabGrade.gameObject:SetActiveEx(not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.CharacterGrade)) + self.BtnTabQuality.gameObject:SetActiveEx(not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.CharacterQuality)) + self.BtnTabSkill.gameObject:SetActiveEx(not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.CharacterSkill)) + self.BtnTabLevel.gameObject:SetActiveEx(not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.CharacterLevelUp)) + + self.BtnTabGrade:SetDisable(not XFunctionManager.JudgeOpen(XFunctionManager.FunctionName.CharacterGrade)) + self.BtnTabQuality:SetDisable(not XFunctionManager.JudgeOpen(XFunctionManager.FunctionName.CharacterQuality)) + self.BtnTabSkill:SetDisable(not XFunctionManager.JudgeOpen(XFunctionManager.FunctionName.CharacterSkill)) + + local tabGroup = { + [PANEL_INDEX.Level] = self.BtnTabLevel, + [PANEL_INDEX.Grade] = self.BtnTabGrade, + [PANEL_INDEX.Quality] = self.BtnTabQuality, + [PANEL_INDEX.Skill] = self.BtnTabSkill, + } + self.PanelPropertyButtons:Init(tabGroup, function(tabIndex) self:OnClickTabCallBack(tabIndex) end) +end + +function XUiPanelCharProperty:OnClickTabCallBack(tabIndex) + if tabIndex == PANEL_INDEX.Level then + self.Parent:PlayAnimation("LevelBegan") + self.PreCameraType = XCharacterConfigs.XUiCharacter_Camera.LEVEL + elseif tabIndex == PANEL_INDEX.Grade then + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.CharacterGrade) then + return + end + self.Parent:PlayAnimation("AniPanelGradesBegin") + self.PreCameraType = XCharacterConfigs.XUiCharacter_Camera.GRADE + elseif tabIndex == PANEL_INDEX.Quality then + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.CharacterQuality) then + return + end + self.Parent:PlayAnimation("AniPanelQualityBegin") + self.PreCameraType = XCharacterConfigs.XUiCharacter_Camera.QULITY + elseif tabIndex == PANEL_INDEX.Skill then + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.CharacterSkill) then + return + end + self.PreCameraType = XCharacterConfigs.XUiCharacter_Camera.SKILL + self.Parent:PlayAnimation("SkillBegan") + end + + self.SelectedIndex = tabIndex + self:UpdateShowPanel() +end + +function XUiPanelCharProperty:UpdateShowPanel() + self.Parent:UpdateCamera(self.PreCameraType) + + local index = self.SelectedIndex + for k, panel in pairs(self.PanelsMap) do + if k ~= index then + panel:HidePanel() + end + end + + local panel = self.PanelsMap[index] + if not panel then + local childUiInfo = self.ChildUiInitInfos[index] + local ui = childUiInfo.UiParent:LoadPrefab(childUiInfo.AssetPath) + panel = childUiInfo.ChildClass.New(ui, self) + self.PanelsMap[index] = panel + end + panel:ShowPanel(self.CharacterId) + + self:OnCheckRedPoint() +end + +function XUiPanelCharProperty:OnCheckRedPoint() + local characterId = self.CharacterId + XRedPointManager.CheckByNode(self.BtnTabGrade, characterId) + XRedPointManager.CheckByNode(self.BtnTabQuality, characterId) + XRedPointManager.CheckByNode(self.BtnTabSkill, characterId) + XRedPointManager.CheckByNode(self.BtnTabLevel, characterId) +end + +function XUiPanelCharProperty:RegisterOtherEvent() + XEventManager.AddEventListener(XEventId.EVENT_ITEM_BUYASSET, self.UpdateCondition, self) + XEventManager.AddEventListener(XEventId.EVENT_CHARACTER_INCREASE_TIP, self.ShowTip, self) +end + +function XUiPanelCharProperty:RegisterRedPointEvent() + local characterId = self.CharacterId + XRedPointManager.AddRedPointEvent(self.BtnTabGrade, self.OnCheckCharacterGradeRedPoint, self, { XRedPointConditions.Types.CONDITION_CHARACTER_GRADE }, characterId) + XRedPointManager.AddRedPointEvent(self.BtnTabQuality, self.OnCheckCharacterQualityRedPoint, self, { XRedPointConditions.Types.CONDITION_CHARACTER_QUALITY }, characterId) + XRedPointManager.AddRedPointEvent(self.BtnTabSkill, self.OnCheckCharacterSkillRedPoint, self, { XRedPointConditions.Types.CONDITION_CHARACTER_SKILL }, characterId) + XRedPointManager.AddRedPointEvent(self.BtnTabLevel, self.OnCheckCharacterLevelRedPoint, self, { XRedPointConditions.Types.CONDITION_CHARACTER_LEVEL, XRedPointConditions.Types.CONDITION_EXHIBITION_NEW}, characterId) +end + +function XUiPanelCharProperty:RemoveOtherEvent() + XEventManager.RemoveEventListener(XEventId.EVENT_ITEM_BUYASSET, self.UpdateCondition, self) + XEventManager.RemoveEventListener(XEventId.EVENT_CHARACTER_INCREASE_TIP, self.ShowTip, self) +end + +function XUiPanelCharProperty:UpdateCondition() + local gradePanel = self.PanelsMap[PANEL_INDEX.Grade] + local character = XDataCenter.CharacterManager.GetCharacter(self.CharacterId) + local isMaxGrade = XDataCenter.CharacterManager.IsMaxCharGrade(character) + if gradePanel and not isMaxGrade then + gradePanel:UpdateUseItemView() + end +end + +function XUiPanelCharProperty:OnCheckCharacterGradeRedPoint(count) + self.BtnTabGrade:ShowReddot(count >= 0) +end + +function XUiPanelCharProperty:OnCheckCharacterQualityRedPoint(count) + self.BtnTabQuality:ShowReddot(count >= 0) +end + +function XUiPanelCharProperty:OnCheckCharacterSkillRedPoint(count) + self.BtnTabSkill:ShowReddot(count >= 0) +end + +function XUiPanelCharProperty:OnCheckCharacterLevelRedPoint(count) + self.BtnTabLevel:ShowReddot(count >= 0) +end + +function XUiPanelCharProperty:AddListener() + self:RegisterClickEvent(self.BtnExchange, self.OnBtnExchangeClick) +end + +function XUiPanelCharProperty:OnBtnExchangeClick() + self.Parent:OpenChangeCharacterView() +end + +function XUiPanelCharProperty:RecoveryPanel() + local levelPanel = self.PanelsMap[PANEL_INDEX.Level] + if levelPanel and levelPanel.SelectLevelItems.IsShow then + levelPanel.SelectLevelItems:HidePanel() + levelPanel:ShowPanel() + self.Parent:PlayAnimation("LevelBegan") + return true + end + + local skillPanel = self.PanelsMap[PANEL_INDEX.Skill] + if skillPanel and skillPanel.SkillInfoPanel.IsShow then + skillPanel.SkillInfoPanel:HidePanel() + skillPanel:ShowPanel() + self.Parent:PlayAnimation("SkillBegan") + return true + end + + return false +end + +function XUiPanelCharProperty:ShowTip(stringDescribe, attrib, oldLevel) + local character = XDataCenter.CharacterManager.GetCharacter(self.CharacterId) + if oldLevel and oldLevel < character.Level then + CS.XAudioManager.PlaySound(XSoundManager.UiBasicsMusic.UiCharacter_LevelUp) + return + end + + stringDescribe = stringDescribe or "" + attrib = attrib or "" + XLuaUiManager.Open("UiLeftPopupTip", stringDescribe, attrib) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCharacter/XUiPanelCharQuality.lua b/Resources/Scripts/XUi/XUiCharacter/XUiPanelCharQuality.lua new file mode 100644 index 00000000..252d5f71 --- /dev/null +++ b/Resources/Scripts/XUi/XUiCharacter/XUiPanelCharQuality.lua @@ -0,0 +1,443 @@ +XUiPanelCharQuality = XClass(nil, "XUiPanelCharQuality") + +local INTERAL = 100 +local LOOP_NUM = 20 + +function XUiPanelCharQuality:Ctor(ui, parent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Parent = parent + self:InitAutoScript() + self:InitIcon() + self.CharQualityUpgrade = XUiPanelQualityUpgrade.New(self.PanelQualityUpgrade, self) + self.ChangeTime = 0.01 + self.ShowIndex = 0 + self.IsShow = true + self.FxUiKeJinHua = CS.XGame.ClientConfig:GetString("FxUiKeJinHua") + self.FxUiJihuo = CS.XGame.ClientConfig:GetString("FxUiJihuo") + + self.ImgClick = { + [1] = self.ImgClick1, + [2] = self.ImgClick2, + [3] = self.ImgClick3, + [4] = self.ImgClick4, + [5] = self.ImgClick5, + [6] = self.ImgClick6, + [7] = self.ImgClick7, + [8] = self.ImgClick8, + [9] = self.ImgClick9, + [10] = self.ImgClick10 + } + + self.TxtWaferName = { + [1] = self.TxtWaferName1, + [2] = self.TxtWaferName2, + [3] = self.TxtWaferName3, + [4] = self.TxtWaferName4, + [5] = self.TxtWaferName5, + [6] = self.TxtWaferName6, + [7] = self.TxtWaferName7, + [8] = self.TxtWaferName8, + [9] = self.TxtWaferName9, + [10] = self.TxtWaferName10 + } + + self.PanelHint = { + [1] = self.PanelHint1, + [2] = self.PanelHint2, + [3] = self.PanelHint3, + [4] = self.PanelHint4, + [5] = self.PanelHint5, + [6] = self.PanelHint6, + [7] = self.PanelHint7, + [8] = self.PanelHint8, + [9] = self.PanelHint9, + [10] = self.PanelHint10, + } + + self:InitClickEvent() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelCharQuality:InitAutoScript() + self:AutoInitUi() + XTool.InitUiObject(self) + self:AutoAddListener() +end + +function XUiPanelCharQuality:AutoInitUi() + self.PanelQualityUpgrade = self.Transform:Find("PanelQualityUpgrade") + self.PanelQuality = self.Transform:Find("PanelQuality") + self.PanelItems = self.Transform:Find("PanelQuality/PanelInfo/PanelItems") + self.ImgLine1 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/Bg/ImgLine1"):GetComponent("Image") + self.ImgLine2 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/Bg/ImgLine2"):GetComponent("Image") + self.ImgLine3 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/Bg/ImgLine3"):GetComponent("Image") + self.ImgLine4 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/Bg/ImgLine4"):GetComponent("Image") + self.ImgLine5 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/Bg/ImgLine5"):GetComponent("Image") + self.ImgLine6 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/Bg/ImgLine6"):GetComponent("Image") + self.ImgLine7 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/Bg/ImgLine7"):GetComponent("Image") + self.ImgLine8 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/Bg/ImgLine8"):GetComponent("Image") + self.ImgLine9 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/Bg/ImgLine9"):GetComponent("Image") + self.ImgLine10 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/Bg/ImgLine10"):GetComponent("Image") + self.PanelWaferIcon = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon") + self.ImgLine1A = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon1/ImgLine1"):GetComponent("Image") + self.ImgWaferColour1 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon1/ImgWaferColour1"):GetComponent("Image") + self.ImgSelect1 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon1/ImgSelect1"):GetComponent("Image") + self.ImgWaferon1 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon1/ImgWaferon1"):GetComponent("Image") + self.TxtWaferName1 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon1/TxtWaferName1"):GetComponent("Text") + self.ImgClick1 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon1/ImgClick1"):GetComponent("Image") + self.PanelHint1 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon1/PanelHint1") + self.ImgLine2A = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon2/ImgLine2"):GetComponent("Image") + self.ImgWaferColour2 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon2/ImgWaferColour2"):GetComponent("Image") + self.ImgSelect2 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon2/ImgSelect2"):GetComponent("Image") + self.ImgWaferon2 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon2/ImgWaferon2"):GetComponent("Image") + self.TxtWaferName2 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon2/TxtWaferName2"):GetComponent("Text") + self.ImgClick2 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon2/ImgClick2"):GetComponent("Image") + self.PanelHint2 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon2/PanelHint2") + self.ImgLine3A = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon3/ImgLine3"):GetComponent("Image") + self.ImgWaferColour3 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon3/ImgWaferColour3"):GetComponent("Image") + self.ImgSelect3 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon3/ImgSelect3"):GetComponent("Image") + self.ImgWaferon3 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon3/ImgWaferon3"):GetComponent("Image") + self.TxtWaferName3 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon3/TxtWaferName3"):GetComponent("Text") + self.ImgClick3 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon3/ImgClick3"):GetComponent("Image") + self.PanelHint3 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon3/PanelHint3") + self.ImgLine4A = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon4/ImgLine4"):GetComponent("Image") + self.ImgWaferColour4 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon4/ImgWaferColour4"):GetComponent("Image") + self.ImgSelect4 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon4/ImgSelect4"):GetComponent("Image") + self.ImgWaferon4 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon4/ImgWaferon4"):GetComponent("Image") + self.TxtWaferName4 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon4/TxtWaferName4"):GetComponent("Text") + self.ImgClick4 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon4/ImgClick4"):GetComponent("Image") + self.PanelHint4 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon4/PanelHint4") + self.ImgLine5A = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon5/ImgLine5"):GetComponent("Image") + self.ImgWaferColour5 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon5/ImgWaferColour5"):GetComponent("Image") + self.ImgSelect5 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon5/ImgSelect5"):GetComponent("Image") + self.ImgWaferon5 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon5/ImgWaferon5"):GetComponent("Image") + self.TxtWaferName5 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon5/TxtWaferName5"):GetComponent("Text") + self.ImgClick5 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon5/ImgClick5"):GetComponent("Image") + self.PanelHint5 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon5/PanelHint5") + self.ImgLine6A = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon6/ImgLine6"):GetComponent("Image") + self.ImgWaferColour6 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon6/ImgWaferColour6"):GetComponent("Image") + self.ImgSelect6 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon6/ImgSelect6"):GetComponent("Image") + self.ImgWaferon6 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon6/ImgWaferon6"):GetComponent("Image") + self.TxtWaferName6 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon6/TxtWaferName6"):GetComponent("Text") + self.ImgClick6 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon6/ImgClick6"):GetComponent("Image") + self.PanelHint6 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon6/PanelHint6") + self.ImgLine7A = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon7/ImgLine7"):GetComponent("Image") + self.ImgWaferColour7 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon7/ImgWaferColour7"):GetComponent("Image") + self.ImgSelect7 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon7/ImgSelect7"):GetComponent("Image") + self.ImgWaferon7 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon7/ImgWaferon7"):GetComponent("Image") + self.TxtWaferName7 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon7/TxtWaferName7"):GetComponent("Text") + self.ImgClick7 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon7/ImgClick7"):GetComponent("Image") + self.PanelHint7 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon7/PanelHint7") + self.ImgLine8A = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon8/ImgLine8"):GetComponent("Image") + self.ImgWaferColour8 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon8/ImgWaferColour8"):GetComponent("Image") + self.ImgSelect8 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon8/ImgSelect8"):GetComponent("Image") + self.ImgWaferon8 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon8/ImgWaferon8"):GetComponent("Image") + self.TxtWaferName8 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon8/TxtWaferName8"):GetComponent("Text") + self.ImgClick8 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon8/ImgClick8"):GetComponent("Image") + self.PanelHint8 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon8/PanelHint8") + self.ImgLine9A = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon9/ImgLine9"):GetComponent("Image") + self.ImgWaferColour9 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon9/ImgWaferColour9"):GetComponent("Image") + self.ImgSelect9 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon9/ImgSelect9"):GetComponent("Image") + self.ImgWaferon9 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon9/ImgWaferon9"):GetComponent("Image") + self.TxtWaferName9 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon9/TxtWaferName9"):GetComponent("Text") + self.ImgClick9 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon9/ImgClick9"):GetComponent("Image") + self.PanelHint9 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon9/PanelHint9") + self.ImgLine10A = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon10/ImgLine10"):GetComponent("Image") + self.ImgWaferColour10 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon10/ImgWaferColour10"):GetComponent("Image") + self.ImgSelect10 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon10/ImgSelect10"):GetComponent("Image") + self.ImgWaferon10 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon10/ImgWaferon10"):GetComponent("Image") + self.TxtWaferName10 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon10/TxtWaferName10"):GetComponent("Text") + self.ImgClick10 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon10/ImgClick10"):GetComponent("Image") + self.PanelHint10 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon10/PanelHint10") + self.BtnPreview = self.Transform:Find("PanelQuality/PanelInfo/BtnPreview"):GetComponent("Button") + self.RImgQuality = self.Transform:Find("PanelQuality/PanelInfo/WaferCircuit/RImgQuality"):GetComponent("RawImage") + self.RImgQualityMax = self.Transform:Find("PanelQuality/PanelInfo/WaferCircuit/RImgQualityMax"):GetComponent("RawImage") + self.BtnAdvanced = self.Transform:Find("PanelQuality/PanelInfo/BtnAdvanced"):GetComponent("Button") + self.RImgQualityBefore = self.Transform:Find("PanelQuality/PanelInfo/BtnAdvanced/RImgQualityBefore"):GetComponent("RawImage") + self.RImgQualityAfter = self.Transform:Find("PanelQuality/PanelInfo/BtnAdvanced/RImgQualityAfter"):GetComponent("RawImage") + self.PanelCountMoney = self.Transform:Find("PanelQuality/PanelInfo/BtnAdvanced/PanelCountMoney") + self.TxtConditionCountMoney = self.Transform:Find("PanelQuality/PanelInfo/BtnAdvanced/PanelCountMoney/TxtConditionCountMoney"):GetComponent("Text") + self.BtnMoneyTip = self.Transform:Find("PanelQuality/PanelInfo/BtnAdvanced/PanelCountMoney/BtnMoneyTip"):GetComponent("Button") + self.PanelCondition = self.Transform:Find("PanelQuality/PanelCondition") + self.ImgPromoteQulityMax = self.Transform:Find("PanelQuality/PanelCondition/ImgPromoteQulityMax"):GetComponent("Image") + self.TxtConditionCountMoneyA = self.Transform:Find("PanelQuality/PanelCondition/ImgPromoteQulityMax/TxtConditionCountMoney"):GetComponent("Text") + self.PanelCountIten = self.Transform:Find("PanelQuality/PanelCondition/PanelCountIten") + self.RImgIconSuipian = self.Transform:Find("PanelQuality/PanelCondition/PanelCountIten/RImgIconSuipian"):GetComponent("RawImage") + self.TxtConditionCountItem = self.Transform:Find("PanelQuality/PanelCondition/PanelCountIten/TxtConditionCountItem"):GetComponent("Text") + self.BtnItemTip = self.Transform:Find("PanelQuality/PanelCondition/PanelCountIten/BtnItemTip"):GetComponent("Button") + self.BtnActive = self.Transform:Find("PanelQuality/PanelCondition/BtnActive"):GetComponent("Button") +end + +function XUiPanelCharQuality:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelCharQuality:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelCharQuality:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelCharQuality:AutoAddListener() + self:RegisterClickEvent(self.BtnPreview, self.OnBtnPreviewClick) + self:RegisterClickEvent(self.BtnAdvanced, self.OnBtnAdvancedClick) + self:RegisterClickEvent(self.BtnMoneyTip, self.OnBtnMoneyTipClick) + self:RegisterClickEvent(self.BtnItemTip, self.OnBtnItemTipClick) + self:RegisterClickEvent(self.BtnActive, self.OnBtnActiveClick) +end +-- auto +function XUiPanelCharQuality:OnBtnPreviewClick() + local characterId = self.CharacterId + if XDataCenter.CharacterManager.IsMaxQualityById(characterId) then + return + end + XLuaUiManager.Open("UiPanelQualityPreview", characterId) +end + +function XUiPanelCharQuality:OnBtnItemTipClick() + XLuaUiManager.Open("UiTip", XDataCenter.ItemManager.GetItem(XCharacterConfigs.GetCharacterItemId(self.CharacterId))) +end + +function XUiPanelCharQuality:OnBtnMoneyTipClick() + local character = XDataCenter.CharacterManager.GetCharacter(self.CharacterId) + local characterType = XCharacterConfigs.GetCharacterType(self.CharacterId) + XLuaUiManager.Open("UiTip", XDataCenter.ItemManager.GetItem(XCharacterConfigs.GetPromoteItemId(characterType, character.Quality))) +end + +function XUiPanelCharQuality:OnBtnActiveClick() + self:UpdateStarCount() +end + +function XUiPanelCharQuality:OnBtnAdvancedClick() + local characterId = self.CharacterId + local character = XDataCenter.CharacterManager.GetCharacter(characterId) + self.CharQualityUpgrade:OldCharUpgradeInfo(character) + if character.Star == XCharacterConfigs.MAX_QUALITY_STAR then + XDataCenter.CharacterManager.PromoteQuality(character, function() + CS.XAudioManager.PlaySound(XSoundManager.UiBasicsMusic.UiCharacter_QualityUp) + self.QualityUpgradeEnable:PlayTimelineAnimation() + self.CharQualityUpgrade:ShowLevelInfo(characterId) + self:InitStarAttrInfo() + self:UpdateStar() + end) + end +end + +function XUiPanelCharQuality:InitClickEvent() + local characterId = self.CharacterId + local character = XDataCenter.CharacterManager.GetCharacter(characterId) + + self.AnimationState = {} + for i = 1, 10 do + self:RegisterClickEvent(self.ImgClick[i], + function() + self.TxtWaferName[i].gameObject:SetActive(true) + local attribs = XCharacterConfigs.GetCharStarAttribs(characterId, character.Quality, i - 1) + + for k, v in pairs(attribs) do + local value = FixToDouble(v) + if value > 0 then + self.TxtWaferName[i].text = string.format("%s+%s", XAttribManager.GetAttribNameByIndex(k), string.format("%.2f", value)) + break + end + end + + CS.XTimerManager.Add( + function(timer) + if not self.GameObject:Exist() then + CS.XTimerManager.Remove(timer.Id) + return + end + + -- if timer.Count < 10 then + -- self.TxtWaferName[i].color.a = timer.Count*25 + -- else + -- self.TxtWaferName[i].color.a = (20-timer.Count)*25 + -- end + if timer.Count == 20 then + self.TxtWaferName[i].gameObject:SetActive(false) + CS.XTimerManager.Remove(timer.Id) + end + end, + INTERAL, + LOOP_NUM + ) + end + ) + end +end + +function XUiPanelCharQuality:ShowPanel(characterId) + self.IsShow = true + self.GameObject:SetActive(true) + self.QualityQiehuan:PlayTimelineAnimation() + self.CharacterId = characterId or self.CharacterId + self.CharQualityUpgrade:HideLevelInfo() + self:InitStarAttrInfo() + self:UpdateStar() +end + +function XUiPanelCharQuality:HidePanel() + self.IsShow = false + self.GameObject:SetActive(false) +end + +function XUiPanelCharQuality:InitIcon() + self.StarIcon = {} + self.StarAttr = {} + self.SelectIcon = {} + self.Line = {} + self.StarColour = {} + for i = 1, XCharacterConfigs.MAX_QUALITY_STAR do + self.StarColour[i] = self["ImgWaferColour" .. i] + self.StarIcon[i] = self["ImgWaferon" .. i] + self.StarAttr[i] = self["TxtWaferName" .. i] + self.SelectIcon[i] = self["ImgSelect" .. i] + self.Line[i] = self["ImgLine" .. i] + end +end + +function XUiPanelCharQuality:ClearAttrs() + for i = 1, XCharacterConfigs.MAX_QUALITY_STAR do + self.StarAttr[i].text = "" + end +end + +function XUiPanelCharQuality:UpdateStar() + local character = XDataCenter.CharacterManager.GetCharacter(self.CharacterId) + local maxStar = XCharacterConfigs.MAX_QUALITY_STAR + local isMaxStar = character.Star == maxStar + local isMaxQuality = XDataCenter.CharacterManager.IsMaxQuality(character) + local qualityIcon = XCharacterConfigs.GetCharQualityIcon(character.Quality) + + self.ImgPromoteQulityMax.gameObject:SetActive(isMaxQuality) + self.RImgQuality.gameObject:SetActive(not isMaxQuality and not isMaxStar) + self.RImgQualityMax.gameObject:SetActive(isMaxQuality) + if isMaxQuality then + self:ClearAttrs() + self.BtnAdvanced.gameObject:SetActive(false) + self.PanelCondition.gameObject:SetActive(false) + self.PanelWaferIcon.gameObject:SetActive(false) + self.RImgQualityMax:SetRawImage(qualityIcon) + return + else + self.RImgQuality:SetRawImage(qualityIcon) + self.PanelWaferIcon.gameObject:SetActive(true) + end + + self:UpdateStarAttrInfo(character.Star) + for i = 1, character.Star do + self.StarIcon[i].gameObject:SetActive(true) + self.Line[i].gameObject:SetActive(true) + self.StarColour[i].gameObject:SetActive(false) + end + + for i = maxStar, character.Star + 1, -1 do + self.StarIcon[i].gameObject:SetActive(false) + self.Line[i].gameObject:SetActive(false) + self.StarColour[i].gameObject:SetActive(true) + end + + local characterType = XCharacterConfigs.GetCharacterType(self.CharacterId) + if isMaxStar then + self.PanelCountIten.gameObject:SetActive(false) + self.PanelCountMoney.gameObject:SetActive(true) + self.BtnAdvanced.gameObject:SetActive(true) + self.PanelCondition.gameObject:SetActive(true) + + self.RImgQualityBefore:SetRawImage(XCharacterConfigs.GetCharQualityIcon(character.Quality)) + self.RImgQualityAfter:SetRawImage(XCharacterConfigs.GetCharQualityIcon(character.Quality + 1)) + self.BtnActive.gameObject:SetActive(false) + self.ImgPromoteQulityMax.gameObject:SetActive(true) + self.PanelWaferIcon.gameObject:SetActive(false) + + local itemId = XCharacterConfigs.GetPromoteItemId(characterType, character.Quality) + local useCoin = XCharacterConfigs.GetPromoteUseCoin(characterType, character.Quality) + -- self.TxtConditionCountMoney.text = XDataCenter.ItemManager.GetItemName(itemId) .. useCoin + -- 运营要求 数字在前 单位在后 + self.TxtConditionCountMoney.text = useCoin .. " " .. XDataCenter.ItemManager.GetItemName(itemId) + else + self.PanelCountIten.gameObject:SetActive(true) + self.PanelCountMoney.gameObject:SetActive(false) + self.BtnActive.gameObject:SetActive(true) + self.BtnAdvanced.gameObject:SetActive(false) + self.PanelCondition.gameObject:SetActive(true) + self.RImgIconSuipian:SetRawImage(XDataCenter.ItemManager.GetItemIcon(XCharacterConfigs.GetCharacterItemId(self.CharacterId))) + self.PanelWaferIcon.gameObject:SetActive(true) + + local curItem = XDataCenter.ItemManager.GetItem(XCharacterConfigs.GetCharacterItemId(self.CharacterId)) + local itemCount = 0 + + if curItem ~= nil then + itemCount = curItem.Count + end + + self.TxtConditionCountItem.text = itemCount .. "/" .. XCharacterConfigs.GetStarUseCount(characterType, character.Quality, character.Star + 1) + self.ImgPromoteQulityMax.gameObject:SetActive(false) + end + + for _, hint in pairs(self.PanelHint) do + hint.gameObject:SetActiveEx(false) + end +end + +function XUiPanelCharQuality:UpdateStarCount() + local character = XDataCenter.CharacterManager.GetCharacter(self.CharacterId) + self.CharQualityUpgrade:OldCharUpgradeInfo(character) + local nextActiveStar = character.Star + 1 + XDataCenter.CharacterManager.ActivateStar(character, function() + self.StarAttr[nextActiveStar].gameObject:SetActive(false) + self.SelectIcon[nextActiveStar].gameObject:SetActive(false) + self:UpdateStar() + + local hint = self.PanelHint[nextActiveStar + 1] + if hint then + hint.gameObject:SetActiveEx(true) + end + + CS.XAudioManager.PlaySound(XSoundManager.UiBasicsMusic.UiCharacter_QualityFragments) + end) +end + +function XUiPanelCharQuality:UpdateStarAttrInfo(star) + local character = XDataCenter.CharacterManager.GetCharacter(self.CharacterId) + if star < XCharacterConfigs.MAX_QUALITY_STAR then + self.StarAttr[star + 1].gameObject:SetActive(true) + self.SelectIcon[star + 1].gameObject:SetActive(true) + + if star ~= 0 then + self.StarAttr[star].gameObject:SetActive(false) + self.SelectIcon[star].gameObject:SetActive(false) + end + + local attribs = XCharacterConfigs.GetCharStarAttribs(character.Id, character.Quality, character.Star) + for k, v in pairs(attribs) do + local value = FixToDouble(v) + if value > 0 then + self.StarAttr[star + 1].text = XAttribManager.GetAttribNameByIndex(k) .. "+" .. string.format("%.2f", value) + break + end + end + end +end + +function XUiPanelCharQuality:InitStarAttrInfo() + local character = XDataCenter.CharacterManager.GetCharacter(self.CharacterId) + for i = 1, #self.StarAttr do + self.StarAttr[i].gameObject:SetActive(false) + self.SelectIcon[i].gameObject:SetActive(false) + end + local star = character.Star + 1 + if self.TxtWaferName[star] then + self.TxtWaferName[star].gameObject:SetActive(true) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCharacter/XUiPanelCharSkill.lua b/Resources/Scripts/XUi/XUiCharacter/XUiPanelCharSkill.lua new file mode 100644 index 00000000..e080baea --- /dev/null +++ b/Resources/Scripts/XUi/XUiCharacter/XUiPanelCharSkill.lua @@ -0,0 +1,133 @@ +local XUiPanelSkillLevelDetail = require("XUi/XUiCharacter/XUiPanelSkillLevelDetail") + +XUiPanelCharSkill = XClass(nil, "XUiPanelCharSkill") + +local MAX_SKILL_COUNT = 5 +function XUiPanelCharSkill:Ctor(ui, parent) + self.Parent = parent + self.GameObject = ui.gameObject + self.Transform = ui.transform + self:InitAutoScript() + + self.SkillInfoPanel = XUiPanelSkillInfo.New(self.PanelSkillInfo, self, self.Parent) + self.SkillInfoPanel.GameObject:SetActive(false) + + self.LevelDetailPanel = XUiPanelSkillLevelDetail.New(self.PanelSkillDetails) + self.LevelDetailPanel.GameObject:SetActive(false) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelCharSkill:InitAutoScript() + self:AutoInitUi() + XTool.InitUiObject(self) + self:AutoAddListener() +end + +function XUiPanelCharSkill:AutoInitUi() + self.PanelSkillItems = self.Transform:Find("PanelSkillItems") + self.GridSkillItem5 = self.Transform:Find("PanelSkillItems/GridSkillItem5") + self.GridSkillItem4 = self.Transform:Find("PanelSkillItems/GridSkillItem4") + self.GridSkillItem3 = self.Transform:Find("PanelSkillItems/GridSkillItem3") + self.GridSkillItem2 = self.Transform:Find("PanelSkillItems/GridSkillItem2") + self.GridSkillItem1 = self.Transform:Find("PanelSkillItems/GridSkillItem1") + self.BtnSkillTeach = self.Transform:Find("PanelSkillItems/SkillTeach/BtnSkillTeach"):GetComponent("Button") + self.PanelSkillInfo = self.Transform:Find("PanelSkillInfo") +end + +function XUiPanelCharSkill:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelCharSkill:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelCharSkill:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelCharSkill:AutoAddListener() + self:RegisterClickEvent(self.BtnSkillTeach, self.OnBtnSkillTeachClick) +end +-- auto +function XUiPanelCharSkill:OnBtnSkillTeachClick() + XLuaUiManager.Open("UiPanelSkillTeach", self.Parent.CharacterId) +end + +function XUiPanelCharSkill:ShowPanel(characterId) + self.CharacterId = characterId or self.CharacterId + self.BtnSkillTeach.gameObject:SetActive(true) + self.SkillInfoPanel:HidePanel() + self.IsShow = true + self.GameObject:SetActive(true) + self:ShowSkillItemPanel() + self:UpdateSkill() +end + +function XUiPanelCharSkill:UpdateSkill() + local characterId = self.CharacterId + + -- local character = XDataCenter.CharacterManager.GetCharacter(characterId) + local skills = XCharacterConfigs.GetCharacterSkills(characterId) + if (self.SkillGrids and #self.SkillGrids > 0) then + for i = 1, MAX_SKILL_COUNT do + self.SkillGrids[i]:SetClickCallback( + function() + self:HideSkillItemPanel() + self.BtnSkillTeach.gameObject:SetActive(false) + self.SkillInfoPanel:ShowPanel(characterId, skills, i) + end) + self.SkillGrids[i]:UpdateInfo(characterId, skills[i]) + end + else + self.SkillGrids = {} + for i = 1, MAX_SKILL_COUNT do + self.SkillGrids[i] = XUiGridSkillItem.New(self.Parent, self["GridSkillItem" .. i], skills[i], characterId, + function() + self:HideSkillItemPanel() + self.BtnSkillTeach.gameObject:SetActive(false) + self.SkillInfoPanel:ShowPanel(characterId, skills, i) + end + ) + end + end +end + +function XUiPanelCharSkill:OnSelectSkill(i) + local characterId = self.CharacterId + local skills = XCharacterConfigs.GetCharacterSkills(characterId) + self:HideSkillItemPanel() + self.BtnSkillTeach.gameObject:SetActive(false) + self.SkillInfoPanel:ShowPanel(characterId, skills, i) +end + +function XUiPanelCharSkill:HidePanel() + self.BtnSkillTeach.gameObject:SetActive(true) + self.SkillInfoPanel:HidePanel() + self.IsShow = false + self.GameObject:SetActive(false) + self:HideSkillItemPanel() +end + +function XUiPanelCharSkill:HideSkillItemPanel() + self.PanelSkillItems.gameObject:SetActive(false) +end + +function XUiPanelCharSkill:ShowSkillItemPanel() + self.PanelSkillItems.gameObject:SetActive(true) + self.PanelSkillInfo.gameObject:SetActive(false) + self.BtnSkillTeach.gameObject:SetActive(true) + self.SkillItemsQiehuan:PlayTimelineAnimation() +end + +function XUiPanelCharSkill:ShowLevelDetail(skillId) + local characterId = self.CharacterId + self.LevelDetailPanel:Refresh(characterId, skillId) + self.LevelDetailPanel.GameObject:SetActiveEx(true) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCharacter/XUiPanelCharacterExchange.lua b/Resources/Scripts/XUi/XUiCharacter/XUiPanelCharacterExchange.lua new file mode 100644 index 00000000..234a00f8 --- /dev/null +++ b/Resources/Scripts/XUi/XUiCharacter/XUiPanelCharacterExchange.lua @@ -0,0 +1,153 @@ +local XUiGridCharacterNew = require("XUi/XUiCharacter/XUiGridCharacterNew") + +local TabBtnIndex = { + Normal = 1, + Isomer = 2, +} +local CharacterTypeConvert = { + [TabBtnIndex.Normal] = XCharacterConfigs.CharacterType.Normal, + [TabBtnIndex.Isomer] = XCharacterConfigs.CharacterType.Isomer, +} +local CSXTextManagerGetText = CS.XTextManager.GetText +local BtnGouzaotiName = CSXTextManagerGetText("UiPanelCharacterExchangeBtnNameGouzaoti") +local BtnGanrantiName = CSXTextManagerGetText("UiPanelCharacterExchangeBtnNameGanranti") + +local XUiPanelCharacterExchange = XLuaUiManager.Register(XLuaUi, "UiPanelCharacterExchange") + +function XUiPanelCharacterExchange:OnAwake() + self:AutoAddListener() + self.GridCharacterNew.gameObject:SetActiveEx(false) + + local isIsomerOpen = XFunctionManager.JudgeOpen(XFunctionManager.FunctionName.Isomer) and not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.Isomer) + self.BtnGouzaoti.gameObject:SetActiveEx(isIsomerOpen) + self.BtnGouzaoti.CallBack = function() + local btnIndex = self.SelectTabBtnIndex == TabBtnIndex.Isomer and TabBtnIndex.Normal or TabBtnIndex.Isomer + self:OnSelectCharacterType(btnIndex) + end +end + +function XUiPanelCharacterExchange:OnStart(parent, closeCb) + self.DynamicTable = XDynamicTableNormal.New(self.PanelScrollView) + self.DynamicTable:SetProxy(XUiGridCharacterNew) + self.DynamicTable:SetDelegate(self) + + self.Parent = parent + self.CloseCb = closeCb +end + +function XUiPanelCharacterExchange:OnEnable() + local characterId = self.Parent.CharacterId + self.CharacterId = characterId + + local characterType = CharacterTypeConvert[self.SelectTabBtnIndex] + local paramCharacterType = XCharacterConfigs.GetCharacterType(characterId) + if paramCharacterType ~= characterType then + --选中角色与当前类型页签不符时,强制选中对应角色类型页签 + if XCharacterConfigs.IsIsomer(characterId) then + self.LastSelectIsomerCharacterId = characterId + -- self.PanelCharacterTypeBtns:SelectIndex(TabBtnIndex.Isomer) + self:OnSelectCharacterType(TabBtnIndex.Isomer) + else + self.LastSelectNormalCharacterId = characterId + -- self.PanelCharacterTypeBtns:SelectIndex(TabBtnIndex.Normal) + self:OnSelectCharacterType(TabBtnIndex.Normal) + end + else + self:OnSelectCharacterType(self.SelectTabBtnIndex) + -- self.PanelCharacterTypeBtns:SelectIndex(self.SelectTabBtnIndex) + end +end + +function XUiPanelCharacterExchange:OnSelectCharacterType(index) + self.SelectTabBtnIndex = index + + if index == TabBtnIndex.Isomer then + self.BtnGouzaoti:SetNameByGroup(0, BtnGanrantiName) + elseif index == TabBtnIndex.Normal then + self.BtnGouzaoti:SetNameByGroup(0, BtnGouzaotiName) + end + + self:SetupDynamicTable() +end + +function XUiPanelCharacterExchange:SetupDynamicTable() + local characterType = CharacterTypeConvert[self.SelectTabBtnIndex] + self.CharList = XDataCenter.CharacterManager.GetOwnCharacterList(characterType, true) + if not self.CharList then + return + end + + local len = #self.CharList + local index = 1 + + for i = 1, len do + if self.CharList[i].Id == self.CharacterId then + index = i + break + end + end + + self.DynamicTable:SetDataSource(self.CharList) + self.DynamicTable:ReloadDataASync(index) +end + +function XUiPanelCharacterExchange:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.CharList[index] + grid:Reset() + grid:UpdateGrid(data) + + if self.CharacterId == data.Id then + self.CurSelectGrid = grid + end + + grid:SetSelect(self.CharacterId == data.Id) + grid:SetCurSignState(self.CharacterId == data.Id) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + local charData = self.CharList[index] + + if not XCharacterConfigs.IsCharacterForeShow(charData.Id) then + XUiManager.TipMsg(CS.XTextManager.GetText("ComingSoon"), XUiManager.UiTipType.Tip) + return + end + + if self.CharacterId ~= charData.Id then + self.CharacterId = charData.Id + + if self.CurSelectGrid then + self.CurSelectGrid:SetSelect(false) + self.CurSelectGrid:SetCurSignState(false) + end + + grid:SetSelect(true) + grid:SetCurSignState(true) + self.CurSelectGrid = grid + end + + self:OnSelectCharacter() + end +end + +function XUiPanelCharacterExchange:AutoAddListener() + self:RegisterClickEvent(self.BtnCancel, self.OnBtnCancelClick) + self:RegisterClickEvent(self.BtnAllCategory, self.OnBtnAllCategory) +end + +function XUiPanelCharacterExchange:OnBtnCancelClick() + self:OnSelectCharacter() +end + +function XUiPanelCharacterExchange:OnBtnAllCategory() + XDataCenter.RoomCharFilterTipsManager.Reset() + self:SetupDynamicTable() +end + +function XUiPanelCharacterExchange:OnSelectCharacter() + if self.CloseCb then + self.CloseCb(self.CharacterId) + end +end + +return XUiPanelCharacterExchange \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCharacter/XUiPanelCodition.lua b/Resources/Scripts/XUi/XUiCharacter/XUiPanelCodition.lua new file mode 100644 index 00000000..ab8d178d --- /dev/null +++ b/Resources/Scripts/XUi/XUiCharacter/XUiPanelCodition.lua @@ -0,0 +1,67 @@ +XUiPanelCodition = XClass(nil, "XUiPanelCodition") + +function XUiPanelCodition:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self:InitAutoScript() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelCodition:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiPanelCodition:AutoInitUi() + self.TxtSatisfy = self.Transform:Find("TxtSatisfy"):GetComponent("Text") + self.TxtDissatisfy = self.Transform:Find("TxtDissatisfy"):GetComponent("Text") +end + +function XUiPanelCodition:GetAutoKey(uiNode,eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiPanelCodition:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiPanelCodition:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key],eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiPanelCodition:AutoAddListener() + self.AutoCreateListeners = {} +end +-- auto +function XUiPanelCodition:Refresh(data) + local ret, desc = XConditionManager.CheckCondition(data.conditionId, data.charId) + self.TxtSatisfy.text = desc + self.TxtDissatisfy.text = desc + self.TxtSatisfy.gameObject:SetActive(not ret) + self.TxtDissatisfy.gameObject:SetActive( ret) +end + +function XUiPanelCodition:RefreshCoin(data) + self.TxtSatisfy.text = data.Desc + self.TxtDissatisfy.text = data.Desc + self.TxtSatisfy.gameObject:SetActive(not data.isEnough) + self.TxtDissatisfy.gameObject:SetActive( data.isEnough) +end diff --git a/Resources/Scripts/XUi/XUiCharacter/XUiPanelGradeUpgrade.lua b/Resources/Scripts/XUi/XUiCharacter/XUiPanelGradeUpgrade.lua new file mode 100644 index 00000000..49b89ef6 --- /dev/null +++ b/Resources/Scripts/XUi/XUiCharacter/XUiPanelGradeUpgrade.lua @@ -0,0 +1,204 @@ +XUiPanelGradeUpgrade = XClass(nil, "XUiPanelGradeUpgrade") + +function XUiPanelGradeUpgrade:Ctor(ui, rootUi, parent) + self.RootUi = rootUi + self.Parent = parent + self.GameObject = ui.gameObject + self.Transform = ui.transform + self:InitAutoScript() + self.Grading = { + Recruit = 1, --新兵 + RecruitStar = 1, --新兵最大等级 + Picked = 2, --精锐 + PickedStar = 3, --精锐最大等级 + MainForce = 3, --主力 + MainForceStar = 6, --主力最大等级 + Ace = 3, --王牌 + AceStar = 9, --王牌最大等级 + TheChosen = 4, --天选 + TheChosenStar = 13, --天选最大等级 + } + self.OldStar = { self.ImgOldStar1A, self.ImgOldStar2A, self.ImgOldStar3A, self.ImgOldStar4A } + self.OldOnStar = { self.ImgOldOnStar1A, self.ImgOldOnStar2A, self.ImgOldOnStar3A, self.ImgOldOnStar4A } + self.CurStar = { self.ImgCurStar1A, self.ImgCurStar2A, self.ImgCurStar3A, self.ImgCurStar4A } + self.CurOnStar = { self.ImgCurOnStar1A, self.ImgCurOnStar2A, self.ImgCurOnStar3A, self.ImgCurOnStar4A } +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelGradeUpgrade:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiPanelGradeUpgrade:AutoInitUi() + self.RImgCharacterIcon = self.Transform:Find("BgImage/RImgCharacterIcon"):GetComponent("RawImage") + self.TxtName = self.Transform:Find("BgImage/RImgCharacterIcon/TxtName"):GetComponent("Text") + self.BtnDarkBg = self.Transform:Find("BtnDarkBg"):GetComponent("Button") + self.PanelCharAttack = self.Transform:Find("BgImage/Properties/PanelCharAttack") + self.TxtOldAttack = self.Transform:Find("BgImage/Properties/PanelCharAttack/TxtOldAttack"):GetComponent("Text") + self.TxtCurAttack = self.Transform:Find("BgImage/Properties/PanelCharAttack/TxtCurAttack"):GetComponent("Text") + self.PanelCharLife = self.Transform:Find("BgImage/Properties/PanelCharLife") + self.TxtOldLife = self.Transform:Find("BgImage/Properties/PanelCharLife/TxtOldLife"):GetComponent("Text") + self.TxtCurLife = self.Transform:Find("BgImage/Properties/PanelCharLife/TxtCurLife"):GetComponent("Text") + self.PanelCharDefense = self.Transform:Find("BgImage/Properties/PanelCharDefense") + self.TxtOldDefense = self.Transform:Find("BgImage/Properties/PanelCharDefense/TxtOldDefense"):GetComponent("Text") + self.TxtCurDefense = self.Transform:Find("BgImage/Properties/PanelCharDefense/TxtCurDefense"):GetComponent("Text") + self.PanelCharCrit = self.Transform:Find("BgImage/Properties/PanelCharCrit") + self.TxtOldCrit = self.Transform:Find("BgImage/Properties/PanelCharCrit/TxtOldCrit"):GetComponent("Text") + self.TxtCurCrit = self.Transform:Find("BgImage/Properties/PanelCharCrit/TxtCurCrit"):GetComponent("Text") + self.PanelGradeB = self.Transform:Find("BgImage/PanelGrade") + self.RImgOldIconTitleA = self.Transform:Find("BgImage/PanelGrade/RImgOldIconTitle"):GetComponent("RawImage") + self.RImgCurIconTitleA = self.Transform:Find("BgImage/PanelGrade/RImgCurIconTitle"):GetComponent("RawImage") + self.PanelOldStarGoupA = self.Transform:Find("BgImage/PanelGrade/PanelOldStarGoup") + self.ImgOldStar1A = self.Transform:Find("BgImage/PanelGrade/PanelOldStarGoup/Star1/ImgOldStar1"):GetComponent("Image") + self.ImgOldOnStar1A = self.Transform:Find("BgImage/PanelGrade/PanelOldStarGoup/Star1/ImgOldOnStar1"):GetComponent("Image") + self.ImgOldStar2A = self.Transform:Find("BgImage/PanelGrade/PanelOldStarGoup/Star2/ImgOldStar2"):GetComponent("Image") + self.ImgOldOnStar2A = self.Transform:Find("BgImage/PanelGrade/PanelOldStarGoup/Star2/ImgOldOnStar2"):GetComponent("Image") + self.ImgOldStar3A = self.Transform:Find("BgImage/PanelGrade/PanelOldStarGoup/Star3/ImgOldStar3"):GetComponent("Image") + self.ImgOldOnStar3A = self.Transform:Find("BgImage/PanelGrade/PanelOldStarGoup/Star3/ImgOldOnStar3"):GetComponent("Image") + self.ImgOldStar4A = self.Transform:Find("BgImage/PanelGrade/PanelOldStarGoup/Star4/ImgOldStar4"):GetComponent("Image") + self.ImgOldOnStar4A = self.Transform:Find("BgImage/PanelGrade/PanelOldStarGoup/Star4/ImgOldOnStar4"):GetComponent("Image") + self.PanelCurStarGoupA = self.Transform:Find("BgImage/PanelGrade/PanelCurStarGoup") + self.ImgCurStar1A = self.Transform:Find("BgImage/PanelGrade/PanelCurStarGoup/Star1/ImgCurStar1"):GetComponent("Image") + self.ImgCurOnStar1A = self.Transform:Find("BgImage/PanelGrade/PanelCurStarGoup/Star1/ImgCurOnStar1"):GetComponent("Image") + self.ImgCurStar2A = self.Transform:Find("BgImage/PanelGrade/PanelCurStarGoup/Star2/ImgCurStar2"):GetComponent("Image") + self.ImgCurOnStar2A = self.Transform:Find("BgImage/PanelGrade/PanelCurStarGoup/Star2/ImgCurOnStar2"):GetComponent("Image") + self.ImgCurStar3A = self.Transform:Find("BgImage/PanelGrade/PanelCurStarGoup/Star3/ImgCurStar3"):GetComponent("Image") + self.ImgCurOnStar3A = self.Transform:Find("BgImage/PanelGrade/PanelCurStarGoup/Star3/ImgCurOnStar3"):GetComponent("Image") + self.ImgCurStar4A = self.Transform:Find("BgImage/PanelGrade/PanelCurStarGoup/Star4/ImgCurStar4"):GetComponent("Image") + self.ImgCurOnStar4A = self.Transform:Find("BgImage/PanelGrade/PanelCurStarGoup/Star4/ImgCurOnStar4"):GetComponent("Image") +end + +function XUiPanelGradeUpgrade:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelGradeUpgrade:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelGradeUpgrade:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelGradeUpgrade:AutoAddListener() + self:RegisterClickEvent(self.BtnDarkBg, self.OnBtnDarkBgClick) +end +-- auto +function XUiPanelGradeUpgrade:OnBtnDarkBgClick() + self.Parent.GradeUpgradeDisable:PlayTimelineAnimation(function() + self:HideLevelInfo() + end) +end + +function XUiPanelGradeUpgrade:ShowLevelInfo(characterId) + local character = XDataCenter.CharacterManager.GetCharacter(characterId) + self.IsShow = true + self.GameObject:SetActive(true) + self:CurCharUpgradeInfo(character) + CS.XAudioManager.PlaySound(XSoundManager.UiBasicsMusic.Success) -- 成功 +end + +function XUiPanelGradeUpgrade:HideLevelInfo() + self.IsShow = false + if self.GameObject:Exist() then + self.GameObject:SetActive(false) + end +end + +function XUiPanelGradeUpgrade:OldCharUpgradeInfo(character) + self.TxtOldAttack.text = XMath.ToMinInt(FixToDouble(character.Attribs[XNpcAttribType.AttackNormal]) or 0) + self.TxtOldLife.text = XMath.ToMinInt(FixToDouble(character.Attribs[XNpcAttribType.Life]) or 0) + self.TxtOldDefense.text = XMath.ToMinInt(FixToDouble(character.Attribs[XNpcAttribType.DefenseNormal]) or 0) + self.TxtOldCrit.text = XMath.ToMinInt(FixToDouble(character.Attribs[XNpcAttribType.Crit]) or 0) + self:UpdateGradeIcon(character, self.OldStar, self.OldOnStar, self.RImgOldIconTitleA, true) +end + +function XUiPanelGradeUpgrade:CurCharUpgradeInfo(character) + self.TxtCurAttack.text = XMath.ToMinInt(FixToDouble(character.Attribs[XNpcAttribType.AttackNormal]) or 0) + self.TxtCurLife.text = XMath.ToMinInt(FixToDouble(character.Attribs[XNpcAttribType.Life]) or 0) + self.TxtCurDefense.text = XMath.ToMinInt(FixToDouble(character.Attribs[XNpcAttribType.DefenseNormal]) or 0) + self.TxtCurCrit.text = XMath.ToMinInt(FixToDouble(character.Attribs[XNpcAttribType.Crit]) or 0) + self.TxtName.text = character.Name + self.RImgCharacterIcon:SetRawImage(XDataCenter.CharacterManager.GetCharBigHeadIcon(character.Id)) + self:UpdateGradeIcon(character, self.CurStar, self.CurOnStar, self.RImgCurIconTitleA, false) +end +-- 刷新星星界面 +function XUiPanelGradeUpgrade:UpdateStarInfo(index, onIndex, starGoup, starOnGoup) + for i = 1, 4 do + starGoup[i].transform.parent.gameObject:SetActive(true) + starGoup[i].gameObject:SetActive(false) + starOnGoup[i].gameObject:SetActive(false) + end + + if onIndex > 4 then --封号特殊处理 + for i = 1, #starOnGoup do + starOnGoup[i].gameObject:SetActive(true) + end + return + end + + if index < 4 then + for i = index + 1, 4 do + starGoup[i].transform.parent.gameObject:SetActive(false) + end + end + + for i = 1, index do + starGoup[i].gameObject:SetActive(true) + end + for i = 1, onIndex do + starOnGoup[i].gameObject:SetActive(true) + end +end + +-- 判断当前显示界面信息 +function XUiPanelGradeUpgrade:UpdateGradeIcon(character, starGoup, starOnGoup, rImgIcon, isOld) + local charGradeTemplates = XCharacterConfigs.GetGradeTemplates(character.Id, character.Grade) + rImgIcon:SetRawImage(charGradeTemplates.GradeBigIcon) + self:UpdateStarSprite(charGradeTemplates.NoStar, charGradeTemplates.Star, isOld) + if character.Grade == self.Grading.TheChosenStar then + self:UpdateStarInfo(self.Grading.TheChosen, character.Grade - self.Grading.AceStar, starGoup, starOnGoup) + return + end + if character.Grade > self.Grading.AceStar then + self:UpdateStarInfo(self.Grading.TheChosen, character.Grade - self.Grading.AceStar, starGoup, starOnGoup) + return + end + if character.Grade > self.Grading.MainForceStar then + self:UpdateStarInfo(self.Grading.Ace, character.Grade - self.Grading.MainForceStar, starGoup, starOnGoup) + return + end + if character.Grade > self.Grading.PickedStar then + self:UpdateStarInfo(self.Grading.MainForce, character.Grade - self.Grading.PickedStar, starGoup, starOnGoup) + return + end + if character.Grade > self.Grading.RecruitStar then + self:UpdateStarInfo(self.Grading.Picked, character.Grade - self.Grading.RecruitStar, starGoup, starOnGoup) + return + end + if character.Grade <= self.Grading.RecruitStar then + self:UpdateStarInfo(self.Grading.Recruit, character.Grade, starGoup, starOnGoup) + return + end +end + +function XUiPanelGradeUpgrade:UpdateStarSprite(starSprite, onStarSprite, isOld) + if isOld then + for i = 1, #self.OldStar do + self.RootUi:SetUiSprite(self.OldStar[i], starSprite) + self.RootUi:SetUiSprite(self.OldOnStar[i], onStarSprite) + end + else + for i = 1, #self.CurStar do + self.RootUi:SetUiSprite(self.CurStar[i], starSprite) + self.RootUi:SetUiSprite(self.CurOnStar[i], onStarSprite) + end + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCharacter/XUiPanelLevelUpgrade.lua b/Resources/Scripts/XUi/XUiCharacter/XUiPanelLevelUpgrade.lua new file mode 100644 index 00000000..433fa40a --- /dev/null +++ b/Resources/Scripts/XUi/XUiCharacter/XUiPanelLevelUpgrade.lua @@ -0,0 +1,97 @@ +XUiPanelLevelUpgrade = XClass(nil, "XUiPanelLevelUpgrade") + +function XUiPanelLevelUpgrade:Ctor(ui, parent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Parent = parent + self:InitAutoScript() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelLevelUpgrade:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiPanelLevelUpgrade:AutoInitUi() + self.BtnBg = self.Transform:Find("BtnBg"):GetComponent("Button") + self.RImgRoleUpgradeMsg = self.Transform:Find("BtnBg/RImgRoleUpgradeMsg"):GetComponent("RawImage") + self.PanelCharAttack = self.Transform:Find("BtnBg/Properties/PanelCharAttack") + self.TxtOldAttack = self.Transform:Find("BtnBg/Properties/PanelCharAttack/TxtOldAttack"):GetComponent("Text") + self.TxtCurAttack = self.Transform:Find("BtnBg/Properties/PanelCharAttack/TxtCurAttack"):GetComponent("Text") + self.PanelCharLife = self.Transform:Find("BtnBg/Properties/PanelCharLife") + self.TxtOldLife = self.Transform:Find("BtnBg/Properties/PanelCharLife/TxtOldLife"):GetComponent("Text") + self.TxtCurLife = self.Transform:Find("BtnBg/Properties/PanelCharLife/TxtCurLife"):GetComponent("Text") + self.PanelCharDefense = self.Transform:Find("BtnBg/Properties/PanelCharDefense") + self.TxtOldDefense = self.Transform:Find("BtnBg/Properties/PanelCharDefense/TxtOldDefense"):GetComponent("Text") + self.TxtCurDefense = self.Transform:Find("BtnBg/Properties/PanelCharDefense/TxtCurDefense"):GetComponent("Text") + self.PanelCharCrit = self.Transform:Find("BtnBg/Properties/PanelCharCrit") + self.TxtOldCrit = self.Transform:Find("BtnBg/Properties/PanelCharCrit/TxtOldCrit"):GetComponent("Text") + self.TxtCurCrit = self.Transform:Find("BtnBg/Properties/PanelCharCrit/TxtCurCrit"):GetComponent("Text") + self.PanelTxtLevel = self.Transform:Find("BtnBg/PanelTxtLevel") + self.TxtCurLevelA = self.Transform:Find("BtnBg/PanelTxtLevel/TxtCurLevel"):GetComponent("Text") + self.TxtOldLevel = self.Transform:Find("BtnBg/PanelTxtLevel/TxtOldLevel"):GetComponent("Text") + self.BtnDarkBg = self.Transform:Find("BtnDarkBg"):GetComponent("Button") +end + +function XUiPanelLevelUpgrade:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelLevelUpgrade:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelLevelUpgrade:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelLevelUpgrade:AutoAddListener() + self:RegisterClickEvent(self.BtnDarkBg, self.OnBtnDarkBgClick) +end +-- auto +function XUiPanelLevelUpgrade:OnBtnDarkBgClick() + self.Parent.LevelUpgradeDisable:PlayTimelineAnimation(function() + self:HideLevelInfo() + end) +end + +function XUiPanelLevelUpgrade:ShowLevelInfo(character) + self.IsShow = true + self.GameObject:SetActive(true) + self:CurCharUpgradeInfo(character) + CS.XAudioManager.PlaySound(XSoundManager.UiBasicsMusic.Success) -- 成功 +end + +function XUiPanelLevelUpgrade:HideLevelInfo() + self.IsShow = false + + if self.GameObject:Exist() then + self.GameObject:SetActive(false) + end + + -- XDataCenter.GuideManager.OpenSubPanel(self.Parent.Parent.Parent.Parent.Name, "PanelLevelUpgrade", false) +end + +function XUiPanelLevelUpgrade:OldCharUpgradeInfo(character) + self.TxtOldAttack.text = XMath.ToMinInt(FixToDouble(character.Attribs[XNpcAttribType.AttackNormal]) or 0) + self.TxtOldLife.text = XMath.ToMinInt(FixToDouble(character.Attribs[XNpcAttribType.Life]) or 0) + self.TxtOldDefense.text = XMath.ToMinInt(FixToDouble(character.Attribs[XNpcAttribType.DefenseNormal]) or 0) + self.TxtOldCrit.text = XMath.ToMinInt(FixToDouble(character.Attribs[XNpcAttribType.Crit]) or 0) + self.TxtOldLevel.text = "LV." .. character.Level +end + +function XUiPanelLevelUpgrade:CurCharUpgradeInfo(character) + self.TxtCurAttack.text = XMath.ToMinInt(FixToDouble(character.Attribs[XNpcAttribType.AttackNormal]) or 0) + self.TxtCurLife.text = XMath.ToMinInt(FixToDouble(character.Attribs[XNpcAttribType.Life]) or 0) + self.TxtCurDefense.text = XMath.ToMinInt(FixToDouble(character.Attribs[XNpcAttribType.DefenseNormal]) or 0) + self.TxtCurCrit.text = XMath.ToMinInt(FixToDouble(character.Attribs[XNpcAttribType.Crit]) or 0) + self.TxtCurLevelA.text = "LV." .. character.Level + self.RImgRoleUpgradeMsg:SetRawImage(XDataCenter.CharacterManager.GetCharBigHeadIcon(character.Id)) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCharacter/XUiPanelQualityPreview.lua b/Resources/Scripts/XUi/XUiCharacter/XUiPanelQualityPreview.lua new file mode 100644 index 00000000..2e986922 --- /dev/null +++ b/Resources/Scripts/XUi/XUiCharacter/XUiPanelQualityPreview.lua @@ -0,0 +1,49 @@ +local stringFormat = string.format + +local XUiPanelQualityPreview = XLuaUiManager.Register(XLuaUi, "UiPanelQualityPreview") + +local Show_Part = { + [1] = XNpcAttribType.Life, + [2] = XNpcAttribType.AttackNormal, + [3] = XNpcAttribType.DefenseNormal, + [4] = XNpcAttribType.Crit, +} + +function XUiPanelQualityPreview:OnAwake() + self:AutoAddListener() +end + +function XUiPanelQualityPreview:OnStart(characterId) + self.CharacterId = characterId +end + +function XUiPanelQualityPreview:OnEnable() + self:RefreshAttrib() +end + +function XUiPanelQualityPreview:AutoAddListener() + self:RegisterClickEvent(self.BtnDarkBg, self.OnBtnDarkBgClick) +end + +function XUiPanelQualityPreview:RefreshAttrib() + local characterId = self.CharacterId + local curCharacter = XDataCenter.CharacterManager.GetCharacter(self.CharacterId) + local quality = curCharacter.Quality + local nextQulity = curCharacter.Quality + 1 + local curAttrib = XCharacterConfigs.GetNpcPromotedAttribByQuality(characterId, quality) + local nextAttrib = XCharacterConfigs.GetNpcPromotedAttribByQuality(characterId, nextQulity) + + for i = 1, 4 do + local attribType = Show_Part[i] + local name = XAttribManager.GetAttribNameByIndex(attribType) + self["TxtInfoName" .. i].text = CS.XTextManager.GetText("CharQuiltyLevelUp", name) + self["TxtNormal" .. i].text = stringFormat("%.2f", FixToDouble(curAttrib[attribType])) + self["TxtLevel" .. i].text = stringFormat("%.2f", FixToDouble(nextAttrib[attribType])) + end + self.RImgQuality:SetRawImage(XCharacterConfigs.GetCharQualityIcon(quality)) + self.RImgQuality1:SetRawImage(XCharacterConfigs.GetCharQualityIcon(quality + 1)) +end + +function XUiPanelQualityPreview:OnBtnDarkBgClick() + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCharacter/XUiPanelQualityUpgrade.lua b/Resources/Scripts/XUi/XUiCharacter/XUiPanelQualityUpgrade.lua new file mode 100644 index 00000000..414d788d --- /dev/null +++ b/Resources/Scripts/XUi/XUiCharacter/XUiPanelQualityUpgrade.lua @@ -0,0 +1,96 @@ +local stringFormat = string.format + +XUiPanelQualityUpgrade = XClass(nil, "XUiPanelQualityUpgrade") + +function XUiPanelQualityUpgrade:Ctor(ui, parent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Parent = parent + self:InitAutoScript() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelQualityUpgrade:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiPanelQualityUpgrade:AutoInitUi() + self.BtnDarkBg = self.Transform:Find("BtnDarkBg"):GetComponent("Button") + self.BtnBgImage = self.Transform:Find("BtnBgImage"):GetComponent("Button") + self.PanelCharLife = self.Transform:Find("BtnBgImage/Properties/PanelCharLife") + self.TxtOldLife = self.Transform:Find("BtnBgImage/Properties/PanelCharLife/TxtOldLife"):GetComponent("Text") + self.TxtCurLife = self.Transform:Find("BtnBgImage/Properties/PanelCharLife/TxtCurLife"):GetComponent("Text") + self.PanelCharAttack = self.Transform:Find("BtnBgImage/Properties/PanelCharAttack") + self.TxtOldAttack = self.Transform:Find("BtnBgImage/Properties/PanelCharAttack/TxtOldAttack"):GetComponent("Text") + self.TxtCurAttack = self.Transform:Find("BtnBgImage/Properties/PanelCharAttack/TxtCurAttack"):GetComponent("Text") + self.PanelCharDefense = self.Transform:Find("BtnBgImage/Properties/PanelCharDefense") + self.TxtOldDefense = self.Transform:Find("BtnBgImage/Properties/PanelCharDefense/TxtOldDefense"):GetComponent("Text") + self.TxtCurDefense = self.Transform:Find("BtnBgImage/Properties/PanelCharDefense/TxtCurDefense"):GetComponent("Text") + self.PanelCharCrit = self.Transform:Find("BtnBgImage/Properties/PanelCharCrit") + self.TxtOldCrit = self.Transform:Find("BtnBgImage/Properties/PanelCharCrit/TxtOldCrit"):GetComponent("Text") + self.TxtCurCrit = self.Transform:Find("BtnBgImage/Properties/PanelCharCrit/TxtCurCrit"):GetComponent("Text") + self.PanelTxt = self.Transform:Find("BtnBgImage/PanelTxt") + self.RImgQuality = self.Transform:Find("BtnBgImage/PanelTxt/RImgQuality"):GetComponent("RawImage") + self.RImgQuality1 = self.Transform:Find("BtnBgImage/PanelTxt/RImgQuality1"):GetComponent("RawImage") +end + +function XUiPanelQualityUpgrade:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelQualityUpgrade:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelQualityUpgrade:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelQualityUpgrade:AutoAddListener() + self:RegisterClickEvent(self.BtnDarkBg, self.OnBtnDarkBgClick) +end + +function XUiPanelQualityUpgrade:OnBtnDarkBgClick() + self.Parent.QualityUpgradeDisable:PlayTimelineAnimation(function() + self:HideLevelInfo() + end) +end +function XUiPanelQualityUpgrade:ShowLevelInfo(characterId) + self.GameObject:SetActive(true) + self.IsShow = true + local character = XDataCenter.CharacterManager.GetCharacter(characterId) + self:CurCharUpgradeInfo(character) + CS.XAudioManager.PlaySound(XSoundManager.UiBasicsMusic.Success) -- 成功 +end + +function XUiPanelQualityUpgrade:HideLevelInfo() + self.IsShow = false + if self.GameObject:Exist() then + self.GameObject:SetActive(false) + end +end + +function XUiPanelQualityUpgrade:OldCharUpgradeInfo(character) + local attrbis = XCharacterConfigs.GetNpcPromotedAttribByQuality(character.Id, character.Quality) + self.TxtOldAttack.text = stringFormat("%.2f", FixToDouble(attrbis[XNpcAttribType.AttackNormal])) + self.TxtOldLife.text = stringFormat("%.2f", FixToDouble(attrbis[XNpcAttribType.Life])) + self.TxtOldDefense.text = stringFormat("%.2f", FixToDouble(attrbis[XNpcAttribType.DefenseNormal])) + self.TxtOldCrit.text = stringFormat("%.2f", FixToDouble(attrbis[XNpcAttribType.Crit])) + self.RImgQuality:SetRawImage(XCharacterConfigs.GetCharQualityIcon(character.Quality)) +end + +function XUiPanelQualityUpgrade:CurCharUpgradeInfo(character) + local attrbis = XCharacterConfigs.GetNpcPromotedAttribByQuality(character.Id, character.Quality or 0) + self.TxtCurAttack.text = stringFormat("%.2f", FixToDouble(attrbis[XNpcAttribType.AttackNormal])) + self.TxtCurLife.text = stringFormat("%.2f", FixToDouble(attrbis[XNpcAttribType.Life])) + self.TxtCurDefense.text = stringFormat("%.2f", FixToDouble(attrbis[XNpcAttribType.DefenseNormal])) + self.TxtCurCrit.text = stringFormat("%.2f", FixToDouble(attrbis[XNpcAttribType.Crit])) + self.RImgQuality1:SetRawImage(XCharacterConfigs.GetCharQualityIcon(character.Quality)) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCharacter/XUiPanelRoleModel.lua b/Resources/Scripts/XUi/XUiCharacter/XUiPanelRoleModel.lua new file mode 100644 index 00000000..9bdf0924 --- /dev/null +++ b/Resources/Scripts/XUi/XUiCharacter/XUiPanelRoleModel.lua @@ -0,0 +1,958 @@ +XUiPanelRoleModel = XClass(nil, "XUiPanelRoleModel") + +--==============================-- +-- RoleModelPool = {["model"] = model, ["weaponList"] = list, ["characterId"] = characterId} +--==============================-- +function XUiPanelRoleModel:Ctor(ui, refName, hideWeapon, showShadow, loadClip, setFocus, fixLight, playEffectFunc, clearUiChildren) + self.RefName = refName or "DefaultName" + self.GameObject = ui.gameObject + self.Transform = ui.transform + if clearUiChildren then -- 初始化时是否清空model挂点下所有物体 + XTool.DestroyChildren(ui.gameObject) + end + self.RoleModelPool = {} + self.HideWeapon = hideWeapon and true or false + self.ShowShadow = showShadow + self.SetFocus = setFocus + self.FixLight = fixLight + self.PlayEffectFunc = playEffectFunc + if loadClip == nil then + self.InitLoadClip = true + else + self.InitLoadClip = loadClip and true + end + self.LoadClip = self.InitLoadClip +end + +--设置默认动画 +function XUiPanelRoleModel:SetDefaultAnimation(animationName) + self.DefaultAnimation = animationName +end + +function XUiPanelRoleModel:UpdateRoleModel(roleName, targetPanelRole, targetUiName, cb, IsReLoadAnime, needController, IsReLoadController) + if not roleName then + XLog.Error("XUiPanelCharRole:UpdateRoleModel 函数错误: 参数roleName不能为空") + return + end + + local defaultAnimation = self.DefaultAnimation or XModelManager.GetUiDefaultAnimationPath(roleName) + self.DefaultAnimation = nil + + local modelPool = self.RoleModelPool + local curRoleName = self.CurRoleName + local curModelInfo = modelPool[curRoleName] + if curModelInfo then + curModelInfo.Model.gameObject:SetActiveEx(false) + curModelInfo.time = XTime.GetServerNowTimestamp() + end + if curRoleName ~= roleName then + self.CurRoleName = roleName + end + + local runtimeControllerName + --特殊时装只加载配置的动画状态机Controller + runtimeControllerName = XModelManager.GetUiFashionControllerPath(roleName) + if not runtimeControllerName then + --如果没有配置,再加载配置展示用的动画状态机Controller + if needController then + runtimeControllerName = XModelManager.GetUiDisplayControllerPath(roleName) + end + end + + --如果用状态机就不需要手动加载animclip了 + if runtimeControllerName then + self.LoadClip = nil + else + self.LoadClip = self.InitLoadClip --复原成一开始传入的参数 + end + + local needRemove = nil + local nowTime = XTime.GetServerNowTimestamp() + for k, v in pairs(modelPool) do + --不等于当前要显示的模型且时间超出5秒的都要删掉 + if k ~= roleName and v and v.time then + local diff = nowTime - v.time + if diff >= 5 then + if needRemove == nil then + needRemove = {} + end + table.insert(needRemove, k) + end + end + end + + --删除超时的模型 + if needRemove then + for i = 1, #needRemove do + local tempRoleName = needRemove[i] + local modelInfo = modelPool[tempRoleName] + if modelInfo.Model and modelInfo.Model:Exist() then + CS.UnityEngine.Object.Destroy(modelInfo.Model.gameObject) + end + modelPool[tempRoleName] = nil + end + end + + local modelInfo = modelPool[roleName] + if IsReLoadAnime then + self:LoadModelAndReLoadAnime(modelInfo, targetUiName, roleName, defaultAnimation, cb, runtimeControllerName, IsReLoadController) + else + self:LoadModelAndNotReLoadAnime(modelInfo, targetUiName, roleName, defaultAnimation, cb, runtimeControllerName, IsReLoadController) + end + +end + +function XUiPanelRoleModel:LoadModelAndNotReLoadAnime(modelInfo, targetUiName, roleName, defaultAnimation, cb, runtimeControllerName, IsReLoadController)--更新加载同一个模型时不重新加载动画 + if modelInfo then + modelInfo.Model.gameObject:SetActiveEx(true) + if IsReLoadController then + self:RoleModelLoaded(roleName, targetUiName, cb, runtimeControllerName) + else + self:RoleModelLoaded(roleName, targetUiName, cb) + end + else + XModelManager.LoadRoleModel(self.CurRoleName, self.Transform, self.RefName, function(model) + local tmpModelInfo = {} + tmpModelInfo.Model = model + tmpModelInfo.RenderingProxy = CS.XNPCRendingUIProxy.GetNPCRendingUIProxy(model) + + self.RoleModelPool[roleName] = tmpModelInfo + + if self.LoadClip then + self:LoadAnimationClips(model.gameObject, defaultAnimation, function() + self:RoleModelLoaded(roleName, targetUiName, cb, runtimeControllerName) + end) + else + self:RoleModelLoaded(roleName, targetUiName, cb, runtimeControllerName) + end + end) + end +end + +function XUiPanelRoleModel:LoadModelAndReLoadAnime(modelInfo, targetUiName, roleName, defaultAnimation, cb, runtimeControllerName, IsReLoadController)--更新加载同一个模型时重新加载动画 + if modelInfo then + modelInfo.Model.gameObject:SetActiveEx(true) + self:LoadSingleAnimationClip(modelInfo.Model.gameObject, defaultAnimation, function() + self:RoleModelLoaded(roleName, targetUiName, cb) + end) + else + XModelManager.LoadRoleModel(self.CurRoleName, self.Transform, self.RefName, function(model) + local tmpModelInfo = {} + tmpModelInfo.Model = model + tmpModelInfo.RenderingProxy = CS.XNPCRendingUIProxy.GetNPCRendingUIProxy(model) + self.RoleModelPool[roleName] = tmpModelInfo + + self:LoadSingleAnimationClip(model.gameObject, defaultAnimation, function() + self:RoleModelLoaded(roleName, targetUiName, cb) + end) + end) + end +end + +function XUiPanelRoleModel:LoadAnimationClips(model, defaultAnimation, cb) + if model == nil or not model:Exist() then + XLog.Error("XUiPanelRoleModel.LoadAnimation 函数错误,参数model不能为空") + return + end + + local loadAnimationClip = model.gameObject:GetComponent(typeof(CS.XLoadAnimationClip)) + if loadAnimationClip == nil or not loadAnimationClip:Exist() then + loadAnimationClip = model.gameObject:AddComponent(typeof(CS.XLoadAnimationClip)) + local clips = {} + table.insert(clips, defaultAnimation) + + if not next(clips) or not loadAnimationClip:Exist() then + XLog.Error("XUiPanelRoleModel.LoadAnimation playRoleAnimation = nil ") + return + end + + local activeState = model.gameObject.activeSelf + model.gameObject:SetActiveEx(false) + loadAnimationClip:LoadAnimationClips(clips, function() + model.gameObject:SetActiveEx(activeState) + if cb then cb() end + end) + else + if cb then cb() end + end +end + +function XUiPanelRoleModel:LoadSingleAnimationClip(model, defaultAnimation, cb) + if model == nil or not model:Exist() then + local modelPool = self.RoleModelPool + local curRoleName = self.CurRoleName + local curModelInfo = modelPool[curRoleName] + if curModelInfo then + model = curModelInfo.Model.gameObject + else + XLog.Error("XUiPanelRoleModel.LoadAnimation model = nil ") + return + end + end + + local loadAnimationClip = model.gameObject:GetComponent(typeof(CS.XLoadAnimationClip)) + + if loadAnimationClip == nil or not loadAnimationClip:Exist() then + loadAnimationClip = model.gameObject:AddComponent(typeof(CS.XLoadAnimationClip)) + end + + local activeState = model.gameObject.activeSelf + model.gameObject:SetActiveEx(false) + loadAnimationClip:LoadSingleAnimationClip(defaultAnimation, function() + model.gameObject:SetActiveEx(activeState) + if cb then cb() end + end) +end + +function XUiPanelRoleModel:RoleModelLoaded(name, uiName, cb, runtimeControllerName) + if not self.CurRoleName then return end + local modelInfo = self.RoleModelPool[self.CurRoleName] + if not modelInfo then return end + local model = modelInfo.Model + + XModelManager.SetRoleTransform(name, model, uiName) + + -- 阴影要放在武器模型加载完之后 + if self.ShowShadow then + CS.XShadowHelper.AddShadow(self.GameObject) + end + + -- 只有不是三个模型同时出现的界面调用此接口 + if not self.FixLight then + CS.XShadowHelper.SetCharRealtimeShadow(self.GameObject, true) + end + + if runtimeControllerName then + local animator = model:GetComponent("Animator") + local runtimeController = CS.LoadHelper.LoadUiController(runtimeControllerName, self.RefName) + animator.runtimeAnimatorController = runtimeController + end + + if self.SetFocus then + CS.XGraphicManager.Focus = model.transform + end + + if cb then + cb(model) + end +end + +function XUiPanelRoleModel:GetModelName(characterId) + local quality + local character = XDataCenter.CharacterManager.GetCharacter(characterId) + if character then + quality = character.Quality + end + + return XDataCenter.CharacterManager.GetCharModel(characterId, quality) +end +-----------------------------------加载Ui角色动作特效start--------------------------- +--==============================-- +--desc: (外部接口)加载当前Ui角色动作特效 +--@characterId: 角色id +--@actionId: 动作Id +--==============================-- +function XUiPanelRoleModel:LoadCharacterUiEffect(characterId, actionId) + if not characterId then return end + local fashionId = XDataCenter.CharacterManager.GetShowFashionId(characterId) + local id, rootName, effectPath = XCharacterUiEffectConfig.GetEffectInfo(characterId, fashionId, actionId) + local model = self.RoleModelPool[self.CurRoleName] + if not model.CharacterId then model.CharacterId = characterId end + if model.CurrentUiEffect then + model.CurrentUiEffect.gameObject:SetActiveEx(false) + end + if not model.NotUiStand1 then + local playRoleAnimation = model.Model.gameObject:GetComponent("XPlayRoleAnimation") + if playRoleAnimation then + local defaultAnimeName = playRoleAnimation.DefaultClip + model.NotUiStand1 = defaultAnimeName ~= "UiStand1" + else + model.NotUiStand1 = true + return + end + end + if not actionId and model.NotUiStand1 then return end + if not id or not effectPath then + return + end + if not actionId then model.UiDefaultId = id end + self:PlayCharacterUiEffect(model, id, rootName, effectPath) +end +--==============================-- +--desc: (外部接口)加载时装展示Ui角色动作特效 +--@characterId: 角色id +--@fashionId: 时装Id +--==============================-- +function XUiPanelRoleModel:LoadResCharacterUiEffect(characterId, fashionId) + if not characterId then return end + local id, rootName, effectPath = XCharacterUiEffectConfig.GetEffectInfo(characterId, fashionId) + if not id or not effectPath then + return + end + local model = self.RoleModelPool[self.CurRoleName] + if not model.CharacterId then model.CharacterId = characterId end + if model.CurrentUiEffect then + model.CurrentUiEffect.gameObject:SetActiveEx(false) + end + local playRoleAnimation = model.Model.gameObject:GetComponent("XPlayRoleAnimation") + if playRoleAnimation then + local defaultAnimeName = playRoleAnimation.DefaultClip + model.NotUiStand1 = defaultAnimeName ~= "UiStand1" + if model.NotUiStand1 then return end + else + model.NotUiStand1 = true + return + end + self:PlayCharacterUiEffect(model, id, rootName, effectPath) +end +--==============================-- +--desc: (外部接口)加载Ui角色默认动作特效 +--==============================-- +function XUiPanelRoleModel:LoadCurrentCharacterDefaultUiEffect() + local model = self.RoleModelPool[self.CurRoleName] + if model.NotUiStand1 or not model.UiDefaultId then return end + if model.CurrentUiEffect then + model.CurrentUiEffect.gameObject:SetActiveEx(false) + end + local fashionId = XDataCenter.CharacterManager.GetShowFashionId(model.CharacterId) + local _, rootName, effectPath = XCharacterUiEffectConfig.GetEffectInfo(model.CharacterId, fashionId) + self:PlayCharacterUiEffect(model, model.UiDefaultId, rootName, effectPath) +end +--==============================-- +--desc: 播放Ui角色动作特效 +--==============================-- +function XUiPanelRoleModel:PlayCharacterUiEffect(model, id, rootName, effectPath) + local fx = self:GetModelUiEffect(model, id, rootName, effectPath) + if not fx then return end + fx.gameObject:SetActiveEx(true) + model.CurrentUiEffect = fx +end +--==============================-- +--desc: 获取Ui角色动作特效 +--==============================-- +function XUiPanelRoleModel:GetModelUiEffect(model, id, rootName, effectPath) + if not model.UiEffect then model.UiEffect = {} end + if not model.UiEffectParent then model.UiEffectParent = {} end + if not model.UiEffect[id] then + model.UiEffect[id] = self:CreateUiEffect(model, id, rootName, effectPath) + end + return model.UiEffect[id] +end +--==============================-- +--desc: 生成Ui角色动作特效 +--==============================-- +function XUiPanelRoleModel:CreateUiEffect(model, id, rootName, effectPath) + local parent -- 搜挂点 + if not rootName then + parent = model.Model.gameObject + else + parent = model.Model.gameObject:FindGameObject(rootName) + if not parent then parent = model.Model.gameObject end + end + local fx = parent:LoadPrefab(effectPath, false) + -- XUiLoadPrefab组件同一个挂点只会生成一个Prefab,旧的会自动销毁,这里为每个挂点存储已生成的Id作比对 + if model.UiEffectParent[parent.name] then + model.UiEffect[model.UiEffectParent[parent.name]] = nil + end + model.UiEffectParent[parent.name] = id + return fx +end +--------------------------------------加载Ui角色动作特效end--------------------------- +--==============================-- +--desc: 更新角色模型 +--@characterId: 角色id +--@targetPanelRole: 目标面板 +--@targetUiName: 目标ui名 +--==============================-- +function XUiPanelRoleModel:UpdateCharacterModel(characterId, targetPanelRole, targetUiName, cb, weaponCb, fashionId, growUpLevel, hideEffect) + local weaponFashionId + + if XRobotManager.CheckIsRobotId(characterId) then + local robotId = characterId + characterId = XRobotManager.GetRobotTemplate(characterId).CharacterId + weaponFashionId = XRobotManager.GetRobotWeaponFashionId(robotId) + end + + local resourcesId + if XTool.IsNumberValid(fashionId) then + resourcesId = XDataCenter.FashionManager.GetResourcesId(fashionId) + else + resourcesId = XDataCenter.FashionManager.GetFashionResourceIdByCharId(characterId) + end + + local modelName + if resourcesId then + modelName = XDataCenter.CharacterManager.GetCharResModel(resourcesId) + else + modelName = self:GetModelName(characterId) + end + if not modelName then + return + end + + self:UpdateRoleModel(modelName, targetPanelRole, targetUiName, function(model) + if not self.HideWeapon then + self:UpdateCharacterWeaponModels(characterId, modelName, weaponCb, hideEffect, nil, weaponFashionId) --- todo cur equip + end + + if not hideEffect then + self:UpdateCharacterLiberationLevelEffect(modelName, characterId, growUpLevel, fashionId) + end + + if cb then + cb(model) + end + + if self.FixLight then + CS.XGraphicManager.FixUICharacterLightDir(model.gameObject) + end + end) + self:LoadCharacterUiEffect(tonumber(characterId)) +end + +--==============================-- +--desc: 在查看其他玩家信息时,更新角色模型 +--==============================-- +function XUiPanelRoleModel:UpdateCharacterModelOther(character, weapon, weaponFashionId, targetPanelRole, targetUiName, cb) + + local characterId = character.Id + if XRobotManager.CheckIsRobotId(characterId) then + local robotId = characterId + characterId = XRobotManager.GetRobotTemplate(characterId).CharacterId + weaponFashionId = XRobotManager.GetRobotWeaponFashionId(robotId) + end + + local template = XDataCenter.FashionManager.GetFashionTemplate(character.FashionId) + local resourcesId = template.ResourcesId + + local modelName + if resourcesId then + modelName = XDataCenter.CharacterManager.GetCharResModel(resourcesId) + else + local quality + if character then + quality = character.Quality + end + + modelName = XDataCenter.CharacterManager.GetCharModel(characterId, quality) + end + if not modelName then + return + end + + self:UpdateRoleModel(modelName, targetPanelRole, targetUiName, function(model) + if not self.HideWeapon then + self:UpdateCharacterWeaponModelsOther(character, weapon, weaponFashionId, modelName) + end + + if cb then + cb(model) + end + + if self.FixLight then + CS.XGraphicManager.FixUICharacterLightDir(model.gameObject) + end + end) + self:LoadCharacterUiEffectOther(character) +end + +function XUiPanelRoleModel:LoadCharacterUiEffectOther(character, actionId) + if character then return end + local fashionId = character.FashionId or XCharacterConfigs.GetCharacterTemplate(character.Id).DefaultNpcFashtionId + local id, rootName, effectPath = XCharacterUiEffectConfig.GetEffectInfo(character.Id, fashionId, actionId) + local model = self.RoleModelPool[self.CurRoleName] + + if not model.CharacterId then model.CharacterId = character.Id end + if model.CurrentUiEffect then + model.CurrentUiEffect.gameObject:SetActiveEx(false) + end + if not model.NotUiStand1 then + local playRoleAnimation = model.Model.gameObject:GetComponent("XPlayRoleAnimation") + if playRoleAnimation then + local defaultAnimeName = playRoleAnimation.DefaultClip + model.NotUiStand1 = defaultAnimeName ~= "UiStand1" + else + model.NotUiStand1 = true + return + end + end + if not actionId and model.NotUiStand1 then return end + if not id or not effectPath then + return + end + if not actionId then model.UiDefaultId = id end + self:PlayCharacterUiEffect(model, id, rootName, effectPath) +end + + +--==============================-- +--desc: 更新机器人角色模型 +--==============================-- +function XUiPanelRoleModel:UpdateRobotModel(robotId, characterId, weaponCb, fashionId, equipTemplateId, modelCb) + local resourcesId + if fashionId then + resourcesId = XDataCenter.FashionManager.GetResourcesId(fashionId) + else + resourcesId = XDataCenter.FashionManager.GetFashionResourceIdByCharId(characterId) + end + + local modelName + if resourcesId then + modelName = XDataCenter.CharacterManager.GetCharResModel(resourcesId) + else + modelName = self:GetModelName(characterId) + end + if not modelName then + return + end + + self:UpdateRoleModel(modelName, nil, nil, function(model) + if not self.HideWeapon then + local weaponFashionId = XRobotManager.GetRobotWeaponFashionId(robotId) + self:UpdateCharacterWeaponModels(characterId, modelName, weaponCb, true, equipTemplateId, weaponFashionId) + end + if modelCb then modelCb(model) end + if self.FixLight then + CS.XGraphicManager.FixUICharacterLightDir(model.gameObject) + end + end) + self:LoadResCharacterUiEffect(characterId, fashionId) +end + +function XUiPanelRoleModel:UpdateCharacterResModel(resId, characterId, targetUiName, cb, growUpLevel, weaponFashionId) + local modelName = XDataCenter.CharacterManager.GetCharResModel(resId) + local fashionId = XDataCenter.FashionManager.GetFashionIdByResId(resId) + + if modelName then + self:UpdateRoleModel(modelName, nil, targetUiName, function(model) + if not self.HideWeapon then + self:UpdateCharacterWeaponModels(characterId, modelName, nil, nil, nil, weaponFashionId) + end + + self:UpdateCharacterLiberationLevelEffect(modelName, characterId, growUpLevel, fashionId) + + if cb then + cb(model) + end + end) + end + if fashionId then self:LoadResCharacterUiEffect(characterId, fashionId) end +end + +function XUiPanelRoleModel:UpdateCharacterModelByModelId(modelId, characterId, targetPanelRole, targetUiName, cb, growUpLevel, showDefaultFx) + if not modelId then return end + + self:UpdateRoleModel(modelId, targetPanelRole, targetUiName, function(model) + if not self.HideWeapon then + self:UpdateCharacterWeaponModels(characterId, modelId) + end + + self:UpdateCharacterLiberationLevelEffect(modelId, characterId, growUpLevel, nil, showDefaultFx) + + if cb then + cb(model) + end + end) + local defaultFashionId = XCharacterConfigs.GetCharacterTemplate(characterId).DefaultNpcFashtionId + local fashionId + if growUpLevel == 2 then --growUpLevel 2为第一套解放衣服 3,4为第二套解放衣服,解放的时装Id跟默认时装Id紧挨且按顺序+1 + fashionId = defaultFashionId + 1 + elseif growUpLevel >= 3 then + fashionId = defaultFashionId + 2 + else + fashionId = defaultFashionId + end + if fashionId then + self:LoadResCharacterUiEffect(characterId, fashionId) + end +end + +function XUiPanelRoleModel:UpdateBossModel(modelName, targetUiName, targetPanelRole, cb, isReLoad) + if modelName then + self:UpdateRoleModel(modelName, targetPanelRole, targetUiName, function(model) + if cb then + cb(model) + end + end, true) + end +end + +function XUiPanelRoleModel:UpdateArchiveMonsterModel(modelName, targetUiName, targetPanelRole, cb) + if modelName then + self:UpdateRoleModel(modelName, targetPanelRole, targetUiName, function(model) + if cb then + cb(model) + end + end, true) + end +end + +function XUiPanelRoleModel:UpdatePartnerModel(modelName, targetUiName, targetPanelRole, cb, isReLoad, needController, IsReLoadController) + if modelName then + self:UpdateRoleModel(modelName, targetPanelRole, targetUiName, function(model) + if cb then + cb(model) + end + end, isReLoad, needController, IsReLoadController) + end +end + +function XUiPanelRoleModel:UpdateCharacterModelByFightNpcData(fightNpcData, cb) + local char = fightNpcData.Character + if char then + local modelName + local fashionId = char.FashionId + + if fashionId then + local fashion = XDataCenter.FashionManager.GetFashionTemplate(fashionId) + modelName = XDataCenter.CharacterManager.GetCharResModel(fashion.ResourcesId) + else + -- modelName = XDataCenter.CharacterManager.GetCharModel(char.Id, char.Quality) + modelName = self:GetModelName(char.Id) + end + + + + if modelName then + self:UpdateRoleModel(modelName, nil, nil, function(model) + self:UpdateEquipsModelsByFightNpcData(model, fightNpcData, modelName) + self:UpdateCharacterLiberationLevelEffect(modelName, char.Id, char.LiberateLv, fashionId) + if cb then + cb(model) + end + end) + end + self:LoadResCharacterUiEffect(char.Id, fashionId) + end +end + +function XUiPanelRoleModel:UpdateEquipsModelsByFightNpcData(charModel, fightNpcData, modelName) + XModelManager.LoadRoleWeaponModelByFight(charModel, fightNpcData, self.RefName, self.GameObject, modelName) +end + +--==============================-- +--desc: 更新角色武器模型 +--@characterId: 角色id +--==============================-- +function XUiPanelRoleModel:UpdateCharacterWeaponModels(characterId, modelName, weaponCb, hideEffect, equipTemplateId, weaponFashionId) + local equipModelIdList = {} + + if equipTemplateId then + local equip = { TemplateId = equipTemplateId } + equipModelIdList = XDataCenter.EquipManager.GetEquipModelIdListByEquipData(equip, weaponFashionId) + else + equipModelIdList = XDataCenter.EquipManager.GetEquipModelIdListByCharacterId(characterId, hideEffect, weaponFashionId) + end + + if not equipModelIdList or not next(equipModelIdList) then + return + end + + if not modelName then + modelName = self:GetModelName(characterId) + end + + local roleModel = self.RoleModelPool[modelName] + if not roleModel then + return + end + + XModelManager.LoadRoleWeaponModel(roleModel.Model, equipModelIdList, self.RefName, weaponCb, hideEffect, self.GameObject, modelName) +end + +--==============================-- +--desc: 查看其他玩家角色信息时,更新角色武器模型 +--==============================-- +function XUiPanelRoleModel:UpdateCharacterWeaponModelsOther(characterId, equip, weaponFashionId, modelName, weaponCb, hideEffect) + local equipModelIdList = {} + if weaponFashionId and weaponFashionId ~= 0 then + equipModelIdList = XDataCenter.EquipManager.GetEquipModelIdListByEquipData(equip, weaponFashionId) + else + equipModelIdList = XDataCenter.EquipManager.GetEquipModelIdListByEquipData(equip) + end + + if not equipModelIdList or not next(equipModelIdList) then + return + end + + if not modelName then + modelName = self:GetModelName(characterId) + end + + local roleModel = self.RoleModelPool[modelName] + if not roleModel then + return + end + XModelManager.LoadRoleWeaponModel(roleModel.Model, equipModelIdList, self.RefName, weaponCb, hideEffect, self.GameObject) +end + + +---================================================= +--- 在当前播放中的动画播放完后执行回调 +---@overload fun(callBack:function) +---@param callBack function +---================================================= +local CheckAnimeFinish = function(animator, behaviour, animaName, callBack)--如果动画被打断或是停止都会调用回调 + local animatorInfo = animator:GetCurrentAnimatorStateInfo(0); + if (animatorInfo:IsName(animaName) and animatorInfo.normalizedTime >= 1) or not animatorInfo:IsName(animaName) then--normalizedTime的值为0~1,0为开始,1为结束。 + if callBack then callBack() end + behaviour.enabled = false + end +end + +local AddPlayingAnimCallBack = function(obj, animator, animaName, callBack) + local animatorInfo = animator:GetCurrentAnimatorStateInfo(0); + + if not animatorInfo:IsName(animaName) or animatorInfo.normalizedTime >= 1 then--normalizedTime的值为0~1,0为开始,1为结束。 + return + end + + local behaviour = obj.Transform:GetComponent(typeof(CS.XLuaBehaviour)) + if not behaviour then + behaviour = obj.GameObject:AddComponent(typeof(CS.XLuaBehaviour)) + else + behaviour.enabled = true + end + + behaviour.LuaUpdate = function() + CheckAnimeFinish(animator, behaviour, animaName, callBack) + end +end +---================================================= +--- 播放'AnimaName'动画,‘fromBegin’决定动画是否需要调整到从0开始播放,默认值为false +---@overload fun(AnimaName:string) +---@param AnimaName string +---@param fromBegin boolean +---@param callBack function 成功之后的回调 +---@param errorCb function 失败之后的回调 +---================================================= +function XUiPanelRoleModel:PlayAnima(AnimaName, fromBegin, callBack, errorCb) + local IsCanPlay, animator = self:CheckAnimaCanPlay(AnimaName) + if IsCanPlay and animator then + if fromBegin then + animator:Play(AnimaName, 0, 0); + else + animator:Play(AnimaName) + end + if callBack then + XScheduleManager.ScheduleOnce(function() + AddPlayingAnimCallBack(self, animator, AnimaName, callBack) + end, 1) + end + else + if errorCb then + errorCb() + end + end + return IsCanPlay +end +---================================================= +--- 检查'AnimaName'动画,是否能够播放 +---@overload fun(AnimaName:string) +---@param AnimaName string +---================================================= +function XUiPanelRoleModel:CheckAnimaCanPlay(AnimaName) + local IsCanPlay = false + local animator + if self.CurRoleName and self.RoleModelPool[self.CurRoleName] and self.RoleModelPool[self.CurRoleName].Model then + animator = self.RoleModelPool[self.CurRoleName].Model:GetComponent("Animator") + if XModelManager.CheckAnimatorAction(animator, AnimaName) then + IsCanPlay = true + end + end + return IsCanPlay, animator +end + +---================================================= +--- 无参数时,结束播放当前动画,恢复成站立动画 +--- +--- 有参数时,只有当前动画为'oriAnima',才结束播放动画 +---@overload fun() +---@param oriAnima string +---================================================= +function XUiPanelRoleModel:StopAnima(oriAnima) + local animator = self.RoleModelPool[self.CurRoleName].Model:GetComponent("Animator") + local clip = animator:GetCurrentAnimatorClipInfo(0)[0].clip + + -- 是否需要播放动作打断特效 + if self.PlayEffectFunc then + self.PlayEffectFunc() + end + + if oriAnima == nil or clip.name == oriAnima then + -- 停止UI特效 + local model = self.RoleModelPool[self.CurRoleName] + if model.CurrentUiEffect then + model.CurrentUiEffect.gameObject:SetActiveEx(false) + end + + animator:Play(clip.name, 0, 0.999); + end +end + +function XUiPanelRoleModel:GetAnimator() + if self.RoleModelPool[self.CurRoleName] then + return self.RoleModelPool[self.CurRoleName].Model:GetComponent("Animator") + else + return nil + end +end + +function XUiPanelRoleModel:ShowRoleModel() + if not XTool.UObjIsNil(self.GameObject) then + self.GameObject:SetActiveEx(true) + end +end + +function XUiPanelRoleModel:HideRoleModel() + if not XTool.UObjIsNil(self.GameObject) then + self.GameObject:SetActiveEx(false) + end +end + +--==============================-- +--desc: 更新角色解放特效 +--@characterId: 角色id +--==============================-- +function XUiPanelRoleModel:UpdateCharacterLiberationLevelEffect(modelName, characterId, growUpLevel, fashionId, showDefaultFx) + local modelInfo = self.RoleModelPool[modelName] + local model = modelInfo and modelInfo.Model + if not model then return end + + local liberationFx = modelInfo.LiberationFx + + local rootName, fxPath + if showDefaultFx then + --通过解放等级获取默认解放特效配置 + rootName, fxPath = XDataCenter.CharacterManager.GetCharLiberationLevelEffectRootAndPath(characterId, growUpLevel) + else + --通过角色Id获取时装对应解放特效配置 + rootName, fxPath = XDataCenter.CharacterManager.GetCharFashionLiberationEffectRootAndPath(characterId, growUpLevel, fashionId) + end + + if not rootName or not fxPath then + if liberationFx then + liberationFx:SetActiveEx(false) + end + return + end + + if not liberationFx then + local rootTransform = model.transform:FindTransform(rootName) + if XTool.UObjIsNil(rootTransform) then + XLog.Error("XUiPanelRoleModel:UpdateCharacterLiberationLevelEffect Error:can Not find rootTransform in this model, rootName is:" .. rootName) + return + end + modelInfo.LiberationFx = rootTransform.gameObject:LoadPrefab(fxPath, false) + else + liberationFx:SetActiveEx(true) + end +end + + +---================================================= +--- 材质控制器相关特效需要跟模型绑定 +---@param effect GameObject +---================================================= +function XUiPanelRoleModel:BindEffect(effect) + XLog.Debug("bind effect " .. self.CurRoleName) + if self.CurRoleName and self.RoleModelPool[self.CurRoleName] and self.RoleModelPool[self.CurRoleName].RenderingProxy then + self.RoleModelPool[self.CurRoleName].RenderingProxy:BindEffect(effect) + end +end + +---================================================= +--- 设置LoadEffect接口最大加载特效数量,默认最大是1 +---================================================= +function XUiPanelRoleModel:SetEffectMaxCount(value) + self.EffectMaxCount = value +end + +---================================================= +--- 加载特效,可支持多次加载特效,需要提前设置EffectMaxCount +---@param effectPath 特效路径 +---@param isBindEffect 材质控制器相关特效和模型绑定 +---================================================= +function XUiPanelRoleModel:LoopLoadEffect(effectPath, isBindEffect) + if not effectPath then return end + if isBindEffect == nil then isBindEffect = false end + if self.EffectMaxCount == nil then self.EffectMaxCount = 1 end + if self.EffectingIndex == nil then self.EffectingIndex = 0 end + + local effectParentKey = self.EffectingIndex % self.EffectMaxCount + self:LoadEffect(effectPath, effectParentKey, isBindEffect, false) + self.EffectingIndex = self.EffectingIndex + 1 +end + +---================================================= +---生成指定名称的父节点并在其下加载特效 +---@param effectPath 特效路径 +---@param effectParentName 生成一个前缀Customize_+ effectParentName的节点,特效将挂载在其下。不指定时默认生成一个Default_EffectParent节点供挂载 +---@param isBindEffect 材质控制器相关特效和模型绑定 +---@param isDisableOldEffect 为true时UnActive指定节点名下挂载的特效 +---================================================= +local CreateEffectParentName = function(name) + return name and string.format("Customize_%s", name) or "Default_EffectParent" +end + +function XUiPanelRoleModel:LoadEffect(effectPath, effectParentName, isBindEffect, isDisableOldEffect) + if isDisableOldEffect then + self:HideEffectByParentName(effectParentName) + end + + if not effectPath then return end + if isBindEffect == nil then isBindEffect = false end + + self.EffectParentDic = self.EffectParentDic or {} + self.EffectDic = self.EffectDic or {} + + local parentName = CreateEffectParentName(effectParentName) + local effectParent = self.EffectParentDic[parentName] + + if effectParent == nil then + effectParent = CS.UnityEngine.GameObject(tostring(parentName)) + effectParent.transform:SetParent(self.Transform, false) + self.EffectParentDic[parentName] = effectParent + end + local effect = effectParent:LoadPrefab(effectPath) + + self.EffectDic[parentName] = self.EffectDic[parentName] or {} + self.EffectDic[parentName][effectPath] = effect + + + if effect == nil or XTool.UObjIsNil(effect) then + XLog.Error(string.format("特效路径%s加载的特效为空", effectPath)) + return + end + + if isBindEffect then + self:BindEffect(effect) + end + + effect.gameObject:SetActiveEx(false) + effect.gameObject:SetActiveEx(true) +end + +function XUiPanelRoleModel:HideEffectByParentName(effectParentName) + if self.EffectDic == nil then return end + local parentName = CreateEffectParentName(effectParentName) + for _, effect in pairs(self.EffectDic[parentName] or {}) do + if effect and not XTool.UObjIsNil(effect) then + effect.gameObject:SetActiveEx(false) + end + end +end + +function XUiPanelRoleModel:HideAllEffects() + for _, effectGroup in pairs(self.EffectDic or {}) do + for _, effect in pairs(effectGroup or {}) do + if effect and not XTool.UObjIsNil(effect) then + effect.gameObject:SetActiveEx(false) + end + end + end +end + +function XUiPanelRoleModel:GetModelInfoByName(name) + return self.RoleModelPool[name] +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCharacter/XUiPanelSelectLevelItems.lua b/Resources/Scripts/XUi/XUiCharacter/XUiPanelSelectLevelItems.lua new file mode 100644 index 00000000..de95641d --- /dev/null +++ b/Resources/Scripts/XUi/XUiCharacter/XUiPanelSelectLevelItems.lua @@ -0,0 +1,319 @@ +require("XManager/XModelManager") + +XUiPanelSelectLevelItems = XClass(nil, "XUiPanelSelectLevelItems") + +function XUiPanelSelectLevelItems:Ctor(ui, rootUi, parent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self.Parent = parent + self:InitAutoScript() + self.ExpItems = {} + self.TotalExp = {} + self.CharUpgradeInfoPanel = XUiPanelLevelUpgrade.New(self.PanelLevelUpgrade, self.Parent) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelSelectLevelItems:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiPanelSelectLevelItems:AutoInitUi() + self.PanelItems = self.Transform:Find("PanelItems") + self.PanelLvInfo = self.Transform:Find("PanelItems/PanelLvInfo") + self.PanelRole = self.Transform:Find("PanelItems/PanelLvInfo/PanelRole") + self.PanelContent = self.Transform:Find("PanelItems/PanelLvInfo/SffViewItem/AVSDiewport/PanelContent") + self.PanelExpItem = self.Transform:Find("PanelItems/PanelLvInfo/SffViewItem/AVSDiewport/PanelContent/PanelExpItem") + self.ScrollbarVertical = self.Transform:Find("PanelItems/PanelLvInfo/SffViewItem/ScrollbarVertical"):GetComponent("Scrollbar") + self.BtnUpgrade = self.Transform:Find("PanelItems/PanelLvInfo/BtnUpgrade"):GetComponent("Button") + self.ImgMaxLevel = self.Transform:Find("PanelItems/PanelLvInfo/ImgMaxLevel"):GetComponent("Image") + self.PanelLevel = self.Transform:Find("PanelItems/PanelLevel") + self.TxtExpCompare = self.Transform:Find("PanelItems/PanelLevel/LevelBarInfo/TxtExpCompare"):GetComponent("Text") + self.TxtAddExp = self.Transform:Find("PanelItems/PanelLevel/LevelBarInfo/TxtAddExp"):GetComponent("Text") + self.TxtShowLevel = self.Transform:Find("PanelItems/PanelLevel/LevelBarInfo/TxtShowLevel"):GetComponent("Text") + self.TxtCharCurLevel = self.Transform:Find("PanelItems/PanelLevel/LevelBarInfo/TxtCharCurLevel"):GetComponent("Text") + self.ImgExpBar = self.Transform:Find("PanelItems/PanelLevel/LevelBarInfo/ImgExpBar"):GetComponent("Image") + self.ImgExpAddBar = self.Transform:Find("PanelItems/PanelLevel/LevelBarInfo/ImgExpAddBar"):GetComponent("Image") + self.PanelLevelUpgrade = self.Transform:Find("PanelLevelUpgrade") +end + +function XUiPanelSelectLevelItems:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelSelectLevelItems:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelSelectLevelItems:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelSelectLevelItems:AutoAddListener() + self:RegisterClickEvent(self.BtnUpgrade, self.OnBtnUpgradeClick) +end +-- auto + +function XUiPanelSelectLevelItems:OnBtnUpgradeClick() + self:SendLevelExpItems() +end + +function XUiPanelSelectLevelItems:ResetData() + local characterId = self.CharacterId + local character = XDataCenter.CharacterManager.GetCharacter(characterId) + + self.MaxLevelNeedExp = 0 + self.ShowNextLevel = character.Level + + for start = character.Level, self.MaxLevel - 1 do + self.MaxLevelNeedExp = self.MaxLevelNeedExp + XCharacterConfigs.GetNextLevelExp(characterId, start) + end + + self.ShowCurExp = character.Exp + self.CurCharacterExp = character.Exp + self.CharacterTempExp = character.Exp + if character.Exp > XCharacterConfigs.GetNextLevelExp(characterId, character.Level) then + self.CharacterTempExp = 0 + end + self.MaxLevelNeedExp = self.MaxLevelNeedExp - self.CharacterTempExp + self.RedundantExp = character.Exp - self.CharacterTempExp + + self.AddExp = 0 +end + +function XUiPanelSelectLevelItems:ShowPanel(characterId) + self.ItemId = nil + self.CharacterId = characterId + self.MaxLevel = XDataCenter.CharacterManager.GetMaxAvailableLevel(characterId) + self.IsShow = true + self.ScrollbarVertical.value = 1 + self.CharUpgradeInfoPanel.GameObject:SetActive(false) + self:ResetData() + self:UpdateItems() + self:UpdateUi() + self:CheckMaxLevel() + local character = XDataCenter.CharacterManager.GetCharacter(characterId) + self.TxtShowLevel.text = CS.XTextManager.GetText("CharacterShowLevel", character.Level, self.MaxLevel) + self.PanelItems.gameObject:SetActive(true) + self.GameObject:SetActive(true) +end + +function XUiPanelSelectLevelItems:HidePanel() + self.IsShow = false + self.GameObject:SetActive(false) + self.PanelRole.gameObject:SetActive(false) +end + +function XUiPanelSelectLevelItems:CheckMaxLevel() + local character = XDataCenter.CharacterManager.GetCharacter(self.CharacterId) + local isMaxLevel = character.Level >= self.MaxLevel or self.AddExp <= 0 + self.BtnUpgrade.gameObject:SetActive(not isMaxLevel) + self.ImgMaxLevel.gameObject:SetActive(isMaxLevel) +end + +function XUiPanelSelectLevelItems:UpdateUi() + local characterId = self.CharacterId + local character = XDataCenter.CharacterManager.GetCharacter(self.CharacterId) + + self.ImgExpAddBar.gameObject:SetActive(false) + local isMaxLevel = self.ShowNextLevel >= self.MaxLevel + self.ImgExpBar.fillAmount = isMaxLevel and 0 or self.CharacterTempExp / XCharacterConfigs.GetNextLevelExp(characterId, self.ShowNextLevel) + self.TxtExpCompare.text = math.floor(self.ShowCurExp) .. "/" .. XCharacterConfigs.GetNextLevelExp(characterId, self.ShowNextLevel) + self.TxtCharCurLevel.text = character.Level + self.TxtAddExp.text = self.AddExp > 0 and "+" .. math.floor(self.AddExp) or "" + + for i = 1, #self.ExpItems do + self.ExpItems[i].Btn2.gameObject:SetActive(not isMaxLevel and self.ExpItems[i].SelectCount > 0) + end +end + +function XUiPanelSelectLevelItems:UpdateUiAdd(index) + local characterId = self.CharacterId + local character = XDataCenter.CharacterManager.GetCharacter(characterId) + + local isMaxLevel = self.ShowNextLevel >= self.MaxLevel + local nextLevelExp = XCharacterConfigs.GetNextLevelExp(characterId, self.ShowNextLevel) + + self.ImgExpAddBar.gameObject:SetActive(true) + + if self.AddExp == 0 then + self.ImgExpAddBar.fillAmount = character.Exp / nextLevelExp + else + self.ImgExpAddBar.fillAmount = isMaxLevel and 0 or (self.AddExp + self.CurCharacterExp) / nextLevelExp + end + + if character.Level < self.ShowNextLevel then + self.ImgExpAddBar.fillAmount = 1 + end + + self.TxtCharCurLevel.text = character.Level + self.TxtAddExp.text = self.AddExp > 0 and "+" .. math.floor(self.AddExp) or "" + self.ExpItems[index].Btn2.gameObject:SetActive(self.ExpItems[index].SelectCount > 0) +end + +function XUiPanelSelectLevelItems:CalcMaxCount(expItem) + local character = XDataCenter.CharacterManager.GetCharacter(self.CharacterId) + + local count = expItem.SelectCount + local itemId = expItem.Data.Id + local itemexp = XDataCenter.ItemManager.GetCharExp(itemId, character.Type) + local sumExp = 0 + + for _, item in pairs(self.ExpItems) do + local compareItemId = item.Data.Id + if compareItemId ~= itemId then + sumExp = sumExp + XDataCenter.ItemManager.GetCharExp(compareItemId, character.Type) * item.SelectCount + end + end + + if (self.MaxLevelNeedExp - sumExp) > 0 then + count = (self.MaxLevelNeedExp - sumExp) / itemexp + count = math.ceil(count) + end + + return count +end + +function XUiPanelSelectLevelItems:UpdateItems() + local character = XDataCenter.CharacterManager.GetCharacter(self.CharacterId) + + local expItemsInfo = XDataCenter.ItemManager.GetCardExpItems() + local index = 1 + + for i = 1, #expItemsInfo do + if expItemsInfo[i].Template.UpType == character.Type then + local a = expItemsInfo[i] + table.insert(expItemsInfo, index, a) + table.remove(expItemsInfo, i + 1) + index = index + 1 + end + end + + XUiHelper.CreateTemplates(self.RootUi, self.ExpItems, expItemsInfo, XUiBagItem.New, self.PanelExpItem.gameObject, self.PanelContent) + self.PanelExpItem.gameObject:SetActive(false) + + local itemCount = #expItemsInfo + for i = 1, itemCount do + local info = expItemsInfo[i] + local expItem = self.ExpItems[i] + + expItem.GameObject.name = info.Id + XEventManager.DispatchEvent(XEventId.EVENT_GUIDE_STEP_OPEN_EVENT,expItem.GameObject.name) + + expItem:Refresh(info, true, true) + expItem:SetSelectCount(0) + expItem.Btn2.gameObject:SetActive(false) + expItem:SetClickCallback2(function() + expItem:UpdateSelectCount(self:CalcMaxCount(expItem)) + + local selectCount = expItem.SelectCount + if selectCount > 0 then + expItem.TxtSelectHide.text = string.format("%s%s", "x", selectCount) + expItem.TxtSelectHide.gameObject:SetActive(true) + expItem.ImgSelectBg.gameObject:SetActive(true) + else + expItem.TxtSelectHide.gameObject:SetActive(false) + expItem.ImgSelectBg.gameObject:SetActive(false) + end + end) + expItem:SetChangeSelectCountCondition(function(newCount) + return self:DealSelectItem(i, newCount) + end) + end + + --多出来被消耗的格子要清掉数据 + for i = itemCount + 1, #self.ExpItems do + self.ExpItems[i] = nil + end +end + +function XUiPanelSelectLevelItems:UpdateAddExp(index, changeCount) + local character = XDataCenter.CharacterManager.GetCharacter(self.CharacterId) + + local exp = XDataCenter.ItemManager.GetCharExp(self.ExpItems[index].Data.Id, character.Type) + self.AddExp = self.AddExp + exp * changeCount + character.Exp = self.CharacterTempExp + local preExp = self.AddExp ~= 0 and self.AddExp + self.RedundantExp or 0 + self.ShowNextLevel, self.ShowCurExp = XDataCenter.CharacterManager.CalLevelAndExp(character, preExp) + + if self.ShowNextLevel > self.MaxLevel then + self.ShowNextLevel = self.MaxLevel + end + + self.TxtShowLevel.text = CS.XTextManager.GetText("CharacterShowLevel", self.ShowNextLevel, self.MaxLevel) + + if self.AddExp < self.AddExp + exp * changeCount then + CS.XAudioManager.PlaySound(XSoundManager.UiBasicsMusic.Promotion) --杝均 + end + + +end + +function XUiPanelSelectLevelItems:DealSelectItem(index, newCount) + local character = XDataCenter.CharacterManager.GetCharacter(self.CharacterId) + + if newCount < 0 then + return + end + + local expItem = self.ExpItems[index] + local selectCount = self.ExpItems[index].SelectCount + + if self.ShowNextLevel >= self.MaxLevel and newCount > selectCount then + XUiManager.TipText("CharacterNotMoreLevel") + return + end + + local diffCount = newCount - selectCount + self:UpdateAddExp(index, diffCount) + expItem:SetSelectCount(newCount) + self:UpdateUiAdd(index) + character.Exp = self.CurCharacterExp + self:CheckMaxLevel() + + if self.AddExp > 0 and self.AddExp + self.RedundantExp >= self.MaxLevelNeedExp then + return true + end + return false +end + +function XUiPanelSelectLevelItems:SendLevelExpItems() + local character = XDataCenter.CharacterManager.GetCharacter(self.CharacterId) + + local curLevel = XPlayer.Level + if curLevel < self.ShowNextLevel then + local text = CS.XTextManager.GetText('CharacterLevelFull') + XUiManager.TipMsg(text, XUiManager.UiTipType.Tip) + return + end + + local items = {} + for i = 1, #self.ExpItems do + local item = self.ExpItems[i] + if item.GameObject.activeSelf and item.SelectCount ~= 0 then + items[item.Data.Id] = item.SelectCount + end + end + + local oldCharLevel = character.Level + self.CharUpgradeInfoPanel:OldCharUpgradeInfo(character) + if next(items) then + XDataCenter.CharacterManager.AddExp(character, items, function() + self:ResetData() + self:UpdateItems() + self:UpdateUi() + self:CheckMaxLevel() + if character.Level > oldCharLevel then + self.Parent.LevelUpgradeEnable:PlayTimelineAnimation() + self.CharUpgradeInfoPanel:ShowLevelInfo(character) + end + end) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCharacter/XUiPanelSkillInfo.lua b/Resources/Scripts/XUi/XUiCharacter/XUiPanelSkillInfo.lua new file mode 100644 index 00000000..6499b27e --- /dev/null +++ b/Resources/Scripts/XUi/XUiCharacter/XUiPanelSkillInfo.lua @@ -0,0 +1,446 @@ +XUiPanelSkillInfo = XClass(nil, "XUiPanelSkillInfo") + +local MAX_SUB_SKILL_GRID_COUNT = 6 +local MAX_MAIN_SKILL_GRID_COUNT = 5 + +function XUiPanelSkillInfo:Ctor(ui, parent, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Parent = parent + self.RootUi = rootUi + self:InitAutoScript() + self.GridSkillInfo.gameObject:SetActiveEx(false) + self.GridSubSkill.gameObject:SetActiveEx(false) + self.SkillInfoGo = {} + table.insert(self.SkillInfoGo, self.GridSkillInfo) + self.SkillInfoGrids = {} + self:Refresh() + self:InitSubSkillGrids() +end + +function XUiPanelSkillInfo:InitSubSkillGrids() + self.SubSkillGrids = {} + for i = 1, MAX_SUB_SKILL_GRID_COUNT do + local item = CS.UnityEngine.Object.Instantiate(self.GridSubSkill) + local grid = XUiGridSubSkill.New(item, i, function(subSkill, index) + self:UpdateSubSkillInfoPanel(subSkill, index) + end) + grid.GameObject:SetActiveEx(false) + grid.Transform:SetParent(self.PanelSubSkillList, false) + table.insert(self.SubSkillGrids, grid) + end +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelSkillInfo:InitAutoScript() + self:AutoInitUi() + XTool.InitUiObject(self) + self:AutoAddListener() +end + +function XUiPanelSkillInfo:AutoInitUi() + self.PanelSkillBig = self.Transform:Find("PaneSkillInfo/PanelSkillBig") + self.ImgSkillPointIcon = self.Transform:Find("PaneSkillInfo/PanelSkillBig/ImgSkillPointIcon"):GetComponent("Image") + self.TxtSkillType = self.Transform:Find("PaneSkillInfo/PanelSkillBig/TxtSkillType"):GetComponent("Text") + self.TxtSkillName = self.Transform:Find("PaneSkillInfo/PanelSkillBig/TxtSkillName"):GetComponent("Text") + self.TxtSkillLevel = self.Transform:Find("PaneSkillInfo/PanelSkillBig/TxtSkillLevel"):GetComponent("Text") + self.BtnSkillpointAdd = self.Transform:Find("SkillPoint/BtnSkillpointAdd"):GetComponent("Button") + self.TxtSkillNumber = self.Transform:Find("SkillPoint/TxtSkillNumber"):GetComponent("Text") + self.RImgSkillIcon = self.Transform:Find("SkillPoint/RImgSkillIcon"):GetComponent("RawImage") + self.PanelSubSkillList = self.Transform:Find("PaneSkillInfo/PanelSubSkillList") + self.GridSubSkill = self.Transform:Find("PaneSkillInfo/PanelSubSkillList/GridSubSkill") + self.PanelScroll = self.Transform:Find("PaneSkillInfo/PanelScroll") + self.GridSkillInfo = self.Transform:Find("PaneSkillInfo/PanelScroll/GridSkillInfo") + self.BtnHuadong = self.Transform:Find("PaneSkillInfo/BtnHuadong"):GetComponent("Button") + self.BtnHuadong1 = self.Transform:Find("PaneSkillInfo/BtnHuadong1"):GetComponent("Button") + self.PanelCondition = self.Transform:Find("PaneSkillInfo/SubSkillInfo/PanelCondition") + self.TxtConditionBad = self.Transform:Find("PaneSkillInfo/SubSkillInfo/PanelCondition/TxtConditionBad"):GetComponent("Text") + self.TxtConditionOk = self.Transform:Find("PaneSkillInfo/SubSkillInfo/PanelCondition/TxtConditionOk"):GetComponent("Text") + self.PanelConsume = self.Transform:Find("PaneSkillInfo/SubSkillInfo/PanelConsume") + self.PanelSkillPoint = self.Transform:Find("PaneSkillInfo/SubSkillInfo/PanelConsume/PanelSkillPoint") + self.PanelSkillPointBad = self.Transform:Find("PaneSkillInfo/SubSkillInfo/PanelConsume/PanelSkillPoint/PanelSkillPointBad") + self.TxtSkillPointBad = self.Transform:Find("PaneSkillInfo/SubSkillInfo/PanelConsume/PanelSkillPoint/PanelSkillPointBad/TxtSkillPointBad"):GetComponent("Text") + self.PanelSkillPointOk = self.Transform:Find("PaneSkillInfo/SubSkillInfo/PanelConsume/PanelSkillPoint/PanelSkillPointOk") + self.TxtSkillPointOk = self.Transform:Find("PaneSkillInfo/SubSkillInfo/PanelConsume/PanelSkillPoint/PanelSkillPointOk/TxtSkillPointOk"):GetComponent("Text") + self.PanelCoin = self.Transform:Find("PaneSkillInfo/SubSkillInfo/PanelConsume/PanelCoin") + self.PanelCoinBad = self.Transform:Find("PaneSkillInfo/SubSkillInfo/PanelConsume/PanelCoin/PanelCoinBad") + self.TxtCoinBad = self.Transform:Find("PaneSkillInfo/SubSkillInfo/PanelConsume/PanelCoin/PanelCoinBad/TxtCoinBad"):GetComponent("Text") + self.PanelCoinOk = self.Transform:Find("PaneSkillInfo/SubSkillInfo/PanelConsume/PanelCoin/PanelCoinOk") + self.TxtCoinOk = self.Transform:Find("PaneSkillInfo/SubSkillInfo/PanelConsume/PanelCoin/PanelCoinOk/TxtCoinOk"):GetComponent("Text") +end + +function XUiPanelSkillInfo:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelSkillInfo:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelSkillInfo:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelSkillInfo:AutoAddListener() + self:RegisterClickEvent(self.BtnSkillpointAdd, self.OnBtnSkillpointAddClick) + self:RegisterClickEvent(self.BtnHuadong, self.OnBtnHuadongClick) + self:RegisterClickEvent(self.BtnHuadong1, self.OnBtnHuadong1Click) + self:RegisterClickEvent(self.BtnUpgrade, self.OnBtnUpgradeClick) + self:RegisterClickEvent(self.BtnUnlock, self.OnBtnUnlockClick) + self:RegisterClickEvent(self.BtnSwitch, self.OnBtnSwitchClick) +end +-- auto +function XUiPanelSkillInfo:OnBtnUpgradeClick() + if (not self:CheckUpgradeSubSkill()) then + return + end + + if not XDataCenter.ItemManager.DoNotEnoughBuyAsset(XDataCenter.ItemManager.ItemId.Coin, + self.CurSubSkill.config.UseCoin, + 1, + function() + self:OnBtnUpgradeClick() + end, + "CharacterUngradeSkillCoinNotEnough") then + return + end + + XDataCenter.CharacterManager.UpgradeSubSkillLevel(self.CharacterId, self.CurSubSkill.SubSkillId, function() + XEventManager.DispatchEvent(XEventId.EVENT_CHARACTER_INCREASE_TIP, CS.XTextManager.GetText("CharacterUngradeSkillComplete")) + self:RefreshData() + self:Refresh() + end) +end + +function XUiPanelSkillInfo:OnBtnSwitchClick() + local subSkillInfo = self.CurSubSkill + local addLevel = XDataCenter.CharacterManager.GetSkillPlusLevel(self.CharacterId, subSkillInfo.SubSkillId) + local totalLevel = subSkillInfo.Level + addLevel + XLuaUiManager.Open("UiCharacterSkillSwich", subSkillInfo.SubSkillId, totalLevel, function() + self:RefreshData() + self:Refresh() + end) +end + +function XUiPanelSkillInfo:OnBtnUnlockClick() + if (not self:CheckUpgradeSubSkill()) then + return + end + + if not XDataCenter.ItemManager.DoNotEnoughBuyAsset(XDataCenter.ItemManager.ItemId.Coin, + self.CurSubSkill.config.UseCoin, + 1, + function() + self:OnBtnUnlockClick() + end, + "CharacterUngradeSkillCoinNotEnough") then + return + end + + XDataCenter.CharacterManager.UnlockSubSkill(self.CurSubSkill.SubSkillId, self.CharacterId, function() + XEventManager.DispatchEvent(XEventId.EVENT_CHARACTER_INCREASE_TIP, CS.XTextManager.GetText("CharacterUnlockSkillComplete")) + self:RefreshData() + self:Refresh() + end) +end + +function XUiPanelSkillInfo:OnBtnSkillpointAddClick() + local id = XDataCenter.ItemManager.ItemId.SkillPoint + XLuaUiManager.Open("UiTip", XDataCenter.ItemManager.GetItem(id)) +end + +function XUiPanelSkillInfo:OnBtnHuadongClick() + if self.Pos then + self:GotoSkill(self.Pos + 1) + end +end + +function XUiPanelSkillInfo:OnBtnHuadong1Click() + if self.Pos then + self:GotoSkill(self.Pos - 1) + end +end + +function XUiPanelSkillInfo:GotoSkill(index) + if self.Parent.SkillGrids[index] then + self.Parent.SkillGrids[index]:OnBtnIconBgClick() + end + self:UpdateArrowView() +end + +function XUiPanelSkillInfo:UpdateArrowView() + self.BtnHuadong.gameObject:SetActiveEx(not (self.Pos == MAX_MAIN_SKILL_GRID_COUNT)) + self.BtnHuadong1.gameObject:SetActiveEx(not (self.Pos == 1)) +end + +function XUiPanelSkillInfo:CheckUpgradeSubSkill() + local subSkill = self.CurSubSkill + local conditions = subSkill.config.ConditionId + if not conditions then + return true + end + + for _, conditionId in pairs(conditions) do + local passCondition + local conditionDes + if conditionId ~= 0 then + passCondition, conditionDes = XConditionManager.CheckCondition(conditionId, self.CharacterId) + if not passCondition then + XUiManager.TipMsg(conditionDes) + return false + end + end + end + + if (not XDataCenter.CharacterManager.IsUseItemEnough(XDataCenter.ItemManager.ItemId.SkillPoint, self.CurSubSkill.config.UseSkillPoint)) then + XUiManager.TipText("CharacterUngradeSkillSkillPointNotEnough") + return false + end + + return true +end + +function XUiPanelSkillInfo:ShowPanel(characterId, skills, pos) + self.CharacterId = characterId or self.CharacterId + self.Skills = skills + self.Pos = pos + self.Skill = skills[pos] + self.IsShow = true + self.GameObject:SetActiveEx(true) + + for i, skill in pairs(skills) do + local grid = self.SkillInfoGrids[i] + if (grid == nil) then + local ui_item = self.SkillInfoGo[i] + if (ui_item == nil) then + ui_item = CS.UnityEngine.Object.Instantiate(self.GridSkillInfo, self.PanelScroll) + ui_item.transform:SetAsFirstSibling() + table.insert(self.SkillInfoGo, ui_item) + end + grid = XUiGridSkillInfo.New(ui_item, skill, function(skillId) + self.Parent:ShowLevelDetail(skillId) + end) + table.insert(self.SkillInfoGrids, grid) + else + grid:UpdateData(skill) + end + + grid.CurveValue = 0 + grid.GameObject:SetActiveEx(true) + end + + self:RefreshPanel(characterId, self.Skill) + self:RefreshData() + -- 默认点击 + if self.SubSkillGrids[1] then + self.SubSkillGrids[1]:OnBtnSubSkillIconBgClick() + end + + self:UpdateArrowView() + self.Parent.SkillInfoQiehuan:PlayTimelineAnimation() +end + +function XUiPanelSkillInfo:RefreshData() + local characterId = self.CharacterId + if not characterId then return end + + self.Skills = XCharacterConfigs.GetCharacterSkills(characterId) + local skill = self.Skills[self.Skill.config.Pos] + local grid = self.SkillInfoGrids[self.Pos] + for i = 1, #self.SkillInfoGrids do + self.SkillInfoGrids[i].GameObject:SetActiveEx(self.Pos == i) + end + if (grid) then + grid:UpdateData(skill) + end + self.Parent:UpdateSkill() + self:RefreshPanel(self.CharacterId, skill) + self:RefreshBigSkill(skill) +end + +function XUiPanelSkillInfo:RefreshBigSkill(skill) + self.RootUi:SetUiSprite(self.ImgSkillPointIcon, skill.Icon) + self.TxtSkillType.text = skill.TypeDes + self.TxtSkillName.text = skill.Name + + local addLevel = 0 + for _, skillId in pairs(skill.SkillIdList) do + addLevel = addLevel + XDataCenter.CharacterManager.GetSkillPlusLevel(self.CharacterId, skillId) + end + + local totalLevel = skill.TotalLevel + addLevel + self.TxtSkillLevel.text = totalLevel +end + +function XUiPanelSkillInfo:RefreshPanel(characterId, skill) + self.CharacterId = characterId or self.CharacterId + + self.Skill = skill + self:UpdateSubSkillList(skill.subSkills) + + for i, sub_skill in ipairs(skill.subSkills) do + if (i == self.CurSubSkillIndex) then + self:UpdateSubSkillInfoPanel(sub_skill, self.CurSubSkillIndex) + break + end + end +end + +function XUiPanelSkillInfo:UpdateSubSkillList(subSkillList, cb) + for _, grid in pairs(self.SubSkillGrids) do + grid:Reset() + end + + local count = #subSkillList + + if count > MAX_SUB_SKILL_GRID_COUNT then + XLog.Warning("max subskill grid count is " .. MAX_SUB_SKILL_GRID_COUNT) + count = MAX_SUB_SKILL_GRID_COUNT + end + + for i = 1, count do + local sub_skill = subSkillList[i] + local grid = self.SubSkillGrids[i] + grid:UpdateGrid(self.CharacterId, sub_skill) + grid.GameObject.name = sub_skill.SubSkillId + + if i == 1 then + grid:SetSelect(true) + end + end + + XEventManager.DispatchEvent(XEventId.EVENT_GUIDE_STEP_OPEN_EVENT) + + + if (cb) then + cb() + end +end + +function XUiPanelSkillInfo:UpdateSubSkillInfoPanel(subSkill, index) + if not subSkill then return end + + local showSwithBtn = subSkill.Level > 0 and XCharacterConfigs.CanSkillSwith(subSkill.SubSkillId) + self.BtnSwitch.gameObject:SetActiveEx(showSwithBtn) + + if self.CurSubSkillIndex then + self.SubSkillGrids[self.CurSubSkillIndex]:SetSelect(false) + end + + local grid = self.SkillInfoGrids[self.Pos] + if grid then + grid:SetSubInfo(self.CharacterId, index, subSkill.Level, subSkill.SubSkillId) + end + + self.CurSubSkillIndex = index + self.SubSkillGrids[self.CurSubSkillIndex]:SetSelect(true) + self.CurSubSkill = subSkill + + for _, tmpGrid in pairs(self.SubSkillGrids) do + tmpGrid:ResetSelect(subSkill.SubSkillId) + end + + local min_max = XCharacterConfigs.GetSubSkillMinMaxLevel(subSkill.SubSkillId) + if (subSkill.Level >= min_max.Max) then + self.PanelCondition.gameObject:SetActiveEx(false) + self.PanelConsume.gameObject:SetActiveEx(false) + self.BtnUpgrade.gameObject:SetActiveEx(false) + self.BtnUnlock.gameObject:SetActiveEx(false) + self.PanelMaxLevel.gameObject:SetActiveEx(true) + return + else + self.PanelMaxLevel.gameObject:SetActiveEx(false) + end + + local passCondition = true + local conditionDes = "" + local conditions = subSkill.config.ConditionId + if conditions then + for _, conditionId in pairs(conditions) do + if conditionId ~= 0 then + passCondition, conditionDes = XConditionManager.CheckCondition(conditionId, self.CharacterId) + if not passCondition then + break + end + end + end + end + + self.PanelConsume.gameObject:SetActiveEx(passCondition) + self.PanelCondition.gameObject:SetActiveEx(not passCondition) + self.TxtConditionOk.gameObject:SetActiveEx(passCondition) + self.TxtConditionBad.gameObject:SetActiveEx(not passCondition) + + if passCondition then + self.TxtConditionOk.text = conditionDes + --消耗技能点 + local showSkillPoint = subSkill.config.UseSkillPoint > 0 + self.PanelSkillPoint.gameObject:SetActiveEx(showSkillPoint) + if showSkillPoint then + local isSkillPointMeet = XDataCenter.CharacterManager.IsUseItemEnough({ XDataCenter.ItemManager.ItemId.SkillPoint }, { subSkill.config.UseSkillPoint }) + if isSkillPointMeet then + self.TxtSkillPointOk.text = subSkill.config.UseSkillPoint + else + self.TxtSkillPointBad.text = subSkill.config.UseSkillPoint + end + self.PanelSkillPointBad.gameObject:SetActiveEx(not isSkillPointMeet) + self.PanelSkillPointOk.gameObject:SetActiveEx(isSkillPointMeet) + end + + --消耗螺母 + local showCoin = subSkill.config.UseCoin > 0 + self.PanelCoin.gameObject:SetActiveEx(showCoin) + if showCoin then + local isUseCoinMeet = XDataCenter.CharacterManager.IsUseItemEnough({ XDataCenter.ItemManager.ItemId.Coin }, { subSkill.config.UseCoin }) + if isUseCoinMeet then + self.TxtCoinOk.text = subSkill.config.UseCoin + else + self.TxtCoinBad.text = subSkill.config.UseCoin + end + self.PanelCoinBad.gameObject:SetActiveEx(not isUseCoinMeet) + self.PanelCoinOk.gameObject:SetActiveEx(isUseCoinMeet) + end + + if not showCoin and not showSkillPoint then + self.PanelConsume.gameObject:SetActiveEx(false) + end + else + self.TxtConditionBad.text = conditionDes + end + + if (subSkill.Level <= 0) then + self.BtnUnlock:SetDisable(not passCondition) + self.BtnUnlock.gameObject:SetActiveEx(true) + self.BtnUpgrade.gameObject:SetActiveEx(false) + elseif (subSkill.Level < min_max.Max and subSkill.Level > 0) then + local canUpdate = XDataCenter.CharacterManager.CheckCanUpdateSkill(self.CharacterId, subSkill.SubSkillId, subSkill.Level) + self.BtnUpgrade:SetDisable(not canUpdate) + self.BtnUpgrade.gameObject:SetActiveEx(true) + self.BtnUnlock.gameObject:SetActiveEx(false) + end +end + +function XUiPanelSkillInfo:HidePanel() + self.IsShow = false + self.GameObject:SetActiveEx(false) + if (self.ScrollFlow) then + self.ScrollFlow:Dispose() + end + self.CurSubSkillIndex = nil + self.CurSubSkill = nil + self.Parent.BtnSkillTeach.gameObject:SetActiveEx(true) +end + +function XUiPanelSkillInfo:Refresh() --读取数据 + local item = XDataCenter.ItemManager.GetItem(XDataCenter.ItemManager.ItemId.SkillPoint) + local count = item ~= nil and tostring(item.Count) or "0" + local icon = XDataCenter.ItemManager.GetItemIcon(XDataCenter.ItemManager.ItemId.SkillPoint) + self.TxtSkillNumber.text = count + self.RImgSkillIcon:SetRawImage(icon) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCharacter/XUiPanelSkillLevelDetail.lua b/Resources/Scripts/XUi/XUiCharacter/XUiPanelSkillLevelDetail.lua new file mode 100644 index 00000000..485d764f --- /dev/null +++ b/Resources/Scripts/XUi/XUiCharacter/XUiPanelSkillLevelDetail.lua @@ -0,0 +1,97 @@ +local LEVEL_PREFIX_FORMAT = "+%s" +local stringFormat = string.format +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate +local CSXTextManagerGetText = CS.XTextManager.GetText + +local XUiPanelSkillLevelDetail = XClass(nil, "XUiPanelSkillLevelDetail") + +function XUiPanelSkillLevelDetail:Ctor(ui) + self.DetailGrids = {} + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.GridDetails.gameObject:SetActiveEx(false) + self.BtnClose.CallBack = function() self.GameObject:SetActiveEx(false) end +end + +function XUiPanelSkillLevelDetail:Refresh(characterId, skillId) + local detailGrids = self.DetailGrids + + local grid = detailGrids.ResonanceLevel + local resonanceLevel = XDataCenter.CharacterManager.GetResonanceSkillLevel(characterId, skillId) + if resonanceLevel and resonanceLevel > 0 then + if not grid then + grid = self:NewGrid() + detailGrids.ResonanceLevel = grid + end + + grid.TxtName.text = CSXTextManagerGetText("CharacterSkillLevelDetailResonanace") + grid.TxtLv.text = stringFormat(LEVEL_PREFIX_FORMAT, resonanceLevel) + grid.GameObject:SetActiveEx(true) + elseif grid then + grid.GameObject:SetActiveEx(false) + end + + local grid2 = detailGrids.AssignLevel + local assignLevel = XDataCenter.FubenAssignManager.GetSkillLevel(characterId, skillId) + if resonanceLevel and assignLevel > 0 then + if not grid2 then + grid2 = self:NewGrid() + detailGrids.AssignLevel = grid2 + end + + grid2.TxtName.text = CSXTextManagerGetText("CharacterSkillLevelDetailAssign") + grid2.TxtLv.text = stringFormat(LEVEL_PREFIX_FORMAT, assignLevel) + grid2.GameObject:SetActiveEx(true) + elseif grid2 then + grid2.GameObject:SetActiveEx(false) + end +end + +function XUiPanelSkillLevelDetail:RefreshByNpcData(npcData, skillId, assignChapterRecords) + local detailGrids = self.DetailGrids + + local grid = detailGrids.ResonanceLevel + local resonanceSkillLevelMap = XMagicSkillManager.GetResonanceSkillLevelMap(npcData) + local resonanceLevel = resonanceSkillLevelMap[skillId] or 0 + + if resonanceLevel and resonanceLevel > 0 then + if not grid then + grid = self:NewGrid() + detailGrids.ResonanceLevel = grid + end + + grid.TxtName.text = CSXTextManagerGetText("CharacterSkillLevelDetailResonanace") + grid.TxtLv.text = stringFormat(LEVEL_PREFIX_FORMAT, resonanceLevel) + grid.GameObject:SetActiveEx(true) + elseif grid then + grid.GameObject:SetActiveEx(false) + end + + local grid2 = detailGrids.AssignLevel + local assignLevel = XDataCenter.FubenAssignManager.GetSkillLevelByCharacterData(npcData.Character, skillId, assignChapterRecords) + if resonanceLevel and assignLevel > 0 then + if not grid2 then + grid2 = self:NewGrid() + detailGrids.AssignLevel = grid2 + end + + grid2.TxtName.text = CSXTextManagerGetText("CharacterSkillLevelDetailAssign") + grid2.TxtLv.text = stringFormat(LEVEL_PREFIX_FORMAT, assignLevel) + grid2.GameObject:SetActiveEx(true) + elseif grid2 then + grid2.GameObject:SetActiveEx(false) + end +end + +function XUiPanelSkillLevelDetail:NewGrid() + local grid = {} + local go = CSUnityEngineObjectInstantiate(self.GridDetails, self.PanelDetails) + grid.GameObject = go.gameObject + grid.Transform = go.transform + XTool.InitUiObject(grid) + grid.GameObject:SetActiveEx(true) + return grid +end + +return XUiPanelSkillLevelDetail \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCharacter/XUiPanelSkillTeach.lua b/Resources/Scripts/XUi/XUiCharacter/XUiPanelSkillTeach.lua new file mode 100644 index 00000000..d75bba44 --- /dev/null +++ b/Resources/Scripts/XUi/XUiCharacter/XUiPanelSkillTeach.lua @@ -0,0 +1,63 @@ +local XUiPanelSkillTeach = XLuaUiManager.Register(XLuaUi, "UiPanelSkillTeach") + +function XUiPanelSkillTeach:OnAwake() + self:AutoAddListener() + self.BtnTeach.gameObject:SetActiveEx(false) +end + +function XUiPanelSkillTeach:OnStart(characterId) + self.CharacterId = characterId +end + +function XUiPanelSkillTeach:OnEnable() + self:UpdateView() +end + +function XUiPanelSkillTeach:AutoAddListener() + self:RegisterClickEvent(self.BtnTanchuangClose, self.OnBtnTanchuangCloseClick) + self:RegisterClickEvent(self.BtnTeach, self.OnBtnTeachClick) + self:RegisterClickEvent(self.BtnFight, self.OnBtnFightClick) +end + +function XUiPanelSkillTeach:OnBtnTanchuangCloseClick() + self:Close() +end + +function XUiPanelSkillTeach:OnBtnTeachClick() + local characterId = self.CharacterId + local url = XCharacterConfigs.GetCharTeachWebUrlById(characterId) + self:UpdateWebView(url) +end + +function XUiPanelSkillTeach:OnBtnFightClick() + local characterId = self.CharacterId + XDataCenter.FubenManager.EnterSkillTeachFight(characterId) +end + +function XUiPanelSkillTeach:UpdateView() + local characterId = self.CharacterId + + local data = XCharacterConfigs.GetCharTeachById(characterId) + if not data then return end + + self:SetUiSprite(self.ImgSkill, data.TeachIcon) + self.TxtSkillName.text = data.Title + self.TxtSkillDesc.text = string.format("%s%s", " ", data.Description) +end + +function XUiPanelSkillTeach:UpdateWebView(url) + if self.CurUrl and self.CurUrl == url then + return + end + self.CurUrl = url + + if self.WebViewPanel then + CS.UnityEngine.Object.Destroy(self.WebViewPanel.gameObject) + self.WebViewPanel = nil + end + + CS.XTool.WaitNativeCoroutine(CS.UnityEngine.WaitForEndOfFrame(), function () + self.WebViewPanel = CS.UnityEngine.Object.Instantiate(self.PanelWebView, self.PanelWebView.parent) + CS.XWebView.Load(self.WebViewPanel.gameObject, self.CurUrl) + end) +end diff --git a/Resources/Scripts/XUi/XUiCharacterDetail/XUiCharacterDetail.lua b/Resources/Scripts/XUi/XUiCharacterDetail/XUiCharacterDetail.lua new file mode 100644 index 00000000..ea88836a --- /dev/null +++ b/Resources/Scripts/XUi/XUiCharacterDetail/XUiCharacterDetail.lua @@ -0,0 +1,289 @@ +local XUiCharacterDetail = XLuaUiManager.Register(XLuaUi, "UiCharacterDetail") + +local CharDetailUiType = { + Detail = 1, --详细信息 + Parner = 2, --推荐角色 + Equip = 3, --推荐装备 +} + +local CHILD_UI_EQUIP = "UiPanelEquipInfo" +local CHILD_UI_TEAM = "UiPanelTeamInfo" + +-- auto +-- Automatic generation of code, forbid to edit +function XUiCharacterDetail:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiCharacterDetail:AutoInitUi() + self.BtnBack = self.Transform:Find("SafeAreaContentPane/CharTopButton/BtnBack"):GetComponent("Button") + self.PanelDetailInfo = self.Transform:Find("SafeAreaContentPane/PanelDetailInfo") + self.PanelContent = self.Transform:Find("SafeAreaContentPane/PanelDetailInfo/PanelContent") + self.RImgRoleIcon = self.Transform:Find("SafeAreaContentPane/PanelDetailInfo/PanelContent/Left/RImgRoleIcon"):GetComponent("RawImage") + self.PanelLeftInfo = self.Transform:Find("SafeAreaContentPane/PanelDetailInfo/PanelContent/Left/PanelLeftInfo") + self.RImgQuality = self.Transform:Find("SafeAreaContentPane/PanelDetailInfo/PanelContent/Left/PanelLeftInfo/RImgQuality"):GetComponent("RawImage") + self.BtnArchive = self.Transform:Find("SafeAreaContentPane/PanelDetailInfo/PanelContent/Left/PanelLeftInfo/BtnArchive"):GetComponent("Button") + self.BtnDetial = self.Transform:Find("SafeAreaContentPane/PanelDetailInfo/PanelContent/Left/PanelLeftInfo/BtnDetial"):GetComponent("Button") + self.PanelRight = self.Transform:Find("SafeAreaContentPane/PanelDetailInfo/PanelContent/PanelRight") + self.PanelRightInfo = self.Transform:Find("SafeAreaContentPane/PanelDetailInfo/PanelContent/PanelRight/PanelRightInfo") + self.TxtElementDes2 = self.Transform:Find("SafeAreaContentPane/PanelDetailInfo/PanelContent/PanelRight/PanelRightInfo/RootPanel2/layout/RootTxtPanel2/TxtElementDes2"):GetComponent("Text") + self.TxtElementValue1 = self.Transform:Find("SafeAreaContentPane/PanelDetailInfo/PanelContent/PanelRight/PanelRightInfo/RootPanel2/layout/RootTxtPanel1/TxtElementValue1"):GetComponent("Text") + self.TxtCareerName = self.Transform:Find("SafeAreaContentPane/PanelDetailInfo/PanelContent/PanelRight/PanelRightInfo/RootPanel1/TxtCareerName"):GetComponent("Text") + self.ImgCareerIcon = self.Transform:Find("SafeAreaContentPane/PanelDetailInfo/PanelContent/PanelRight/PanelRightInfo/RootPanel1/ImgCareerIcon"):GetComponent("Image") + self.TxtElementDes1 = self.Transform:Find("SafeAreaContentPane/PanelDetailInfo/PanelContent/PanelRight/PanelRightInfo/RootPanel2/layout/RootTxtPanel1/TxtElementDes1"):GetComponent("Text") + self.TxtSpecialDes2 = self.Transform:Find("SafeAreaContentPane/PanelDetailInfo/PanelContent/PanelRight/PanelRightInfo/RootPanel3/layout/RootTxtPanel2/TxtSpecialDes2"):GetComponent("Text") + self.Txt1 = self.Transform:Find("SafeAreaContentPane/PanelDetailInfo/PanelContent/PanelRight/PanelRightInfo/RootPanel3/layout/RootTxtPanel1/Txt1"):GetComponent("Text") + self.TxtSpecialDes1 = self.Transform:Find("SafeAreaContentPane/PanelDetailInfo/PanelContent/PanelRight/PanelRightInfo/RootPanel3/layout/RootTxtPanel1/TxtSpecialDes1"):GetComponent("Text") + self.PanelEdgeRoot = self.Transform:Find("SafeAreaContentPane/PanelDetailInfo/PanelContent/PanelRight/PanelRightInfo/RootPanel4/Graph/PanelEdgeRoot") + self.PanelPointRoot = self.Transform:Find("SafeAreaContentPane/PanelDetailInfo/PanelContent/PanelRight/PanelRightInfo/RootPanel4/Graph/PanelPointRoot") + self.TxtElementValue2 = self.Transform:Find("SafeAreaContentPane/PanelDetailInfo/PanelContent/PanelRight/PanelRightInfo/RootPanel2/layout/RootTxtPanel2/TxtElementValue2"):GetComponent("Text") + self.TxtElementDes3 = self.Transform:Find("SafeAreaContentPane/PanelDetailInfo/PanelContent/PanelRight/PanelRightInfo/RootPanel2/layout/RootTxtPanel3/TxtElementDes3"):GetComponent("Text") + self.TxtElementValue3 = self.Transform:Find("SafeAreaContentPane/PanelDetailInfo/PanelContent/PanelRight/PanelRightInfo/RootPanel2/layout/RootTxtPanel3/TxtElementValue3"):GetComponent("Text") + self.Txt2 = self.Transform:Find("SafeAreaContentPane/PanelDetailInfo/PanelContent/PanelRight/PanelRightInfo/RootPanel3/layout/RootTxtPanel2/Txt2"):GetComponent("Text") + self.TxtSpecialDes3 = self.Transform:Find("SafeAreaContentPane/PanelDetailInfo/PanelContent/PanelRight/PanelRightInfo/RootPanel3/layout/RootTxtPanel3/TxtSpecialDes3"):GetComponent("Text") + self.Txt3 = self.Transform:Find("SafeAreaContentPane/PanelDetailInfo/PanelContent/PanelRight/PanelRightInfo/RootPanel3/layout/RootTxtPanel3/Txt3"):GetComponent("Text") + self.TxtGraphName1 = self.Transform:Find("SafeAreaContentPane/PanelDetailInfo/PanelContent/PanelRight/PanelRightInfo/RootPanel4/Graph/RootGraphName/TxtGraphName1"):GetComponent("Text") + self.TxtGraphName2 = self.Transform:Find("SafeAreaContentPane/PanelDetailInfo/PanelContent/PanelRight/PanelRightInfo/RootPanel4/Graph/RootGraphName/TxtGraphName2"):GetComponent("Text") + self.TxtGraphName3 = self.Transform:Find("SafeAreaContentPane/PanelDetailInfo/PanelContent/PanelRight/PanelRightInfo/RootPanel4/Graph/RootGraphName/TxtGraphName3"):GetComponent("Text") + self.TxtGraphName4 = self.Transform:Find("SafeAreaContentPane/PanelDetailInfo/PanelContent/PanelRight/PanelRightInfo/RootPanel4/Graph/RootGraphName/TxtGraphName4"):GetComponent("Text") + self.TxtGraphName5 = self.Transform:Find("SafeAreaContentPane/PanelDetailInfo/PanelContent/PanelRight/PanelRightInfo/RootPanel4/Graph/RootGraphName/TxtGraphName5"):GetComponent("Text") + self.TxtGraphName6 = self.Transform:Find("SafeAreaContentPane/PanelDetailInfo/PanelContent/PanelRight/PanelRightInfo/RootPanel4/Graph/RootGraphName/TxtGraphName6"):GetComponent("Text") + self.BtnTeamRecomend = self.Transform:Find("SafeAreaContentPane/PanelDetailInfo/PanelContent/PanelRight/BtnTeamRecomend"):GetComponent("Button") + self.BtnEquipRecomend = self.Transform:Find("SafeAreaContentPane/PanelDetailInfo/PanelContent/PanelRight/BtnEquipRecomend"):GetComponent("Button") + self.TxtCharacterDesName = self.Transform:Find("SafeAreaContentPane/PanelDetailInfo/PanelContent/Left/RootTxtPanel2/TxtCharacterDesName"):GetComponent("Text") + self.TxtCharacterName = self.Transform:Find("SafeAreaContentPane/PanelDetailInfo/PanelContent/Left/RootTxtPanel1/TxtCharacterName"):GetComponent("Text") + self.PanelArchiveTips = self.Transform:Find("SafeAreaContentPane/PanelDetailInfo/PanelContent/PanelArchiveTips") + self.TxtArchiveTitle = self.Transform:Find("SafeAreaContentPane/PanelDetailInfo/PanelContent/PanelArchiveTips/TxtArchiveTitle"):GetComponent("Text") + self.TxtArchIvesDes = self.Transform:Find("SafeAreaContentPane/PanelDetailInfo/PanelContent/PanelArchiveTips/TxtArchIvesDes"):GetComponent("Text") + self.PanelAsset = self.Transform:Find("SafeAreaContentPane/PanelAsset") + self.BtnMainUi = self.Transform:Find("SafeAreaContentPane/CharTopButton/BtnMainUi"):GetComponent("Button") + self.TxtCV = self.Transform:Find("SafeAreaContentPane/PanelDetailInfo/PanelContent/Left/RootTxtPanel3/TxtCV"):GetComponent("Text") +end + +function XUiCharacterDetail:AutoAddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnArchive, self.OnBtnArchiveClick) + self:RegisterClickEvent(self.BtnDetial, self.OnBtnDetialClick) + self:RegisterClickEvent(self.BtnTeamRecomend, self.OnBtnTeamRecomendClick) + self:RegisterClickEvent(self.BtnEquipRecomend, self.OnBtnEquipRecomendClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) +end +-- auto +function XUiCharacterDetail:OnBtnTeamRecomendClick() + self:SwitchView(CharDetailUiType.Parner) +end + +function XUiCharacterDetail:OnBtnEquipRecomendClick() + self:SwitchView(CharDetailUiType.Equip) +end + +function XUiCharacterDetail:OnBtnDetialClick() + XUiHelper.StopAnimation() + self:PlayAnimation("QieHuanDisable") + self.BtnArchive.gameObject:SetActiveEx(true) + self.BtnDetial.gameObject:SetActiveEx(false) +end + +function XUiCharacterDetail:OnBtnArchiveClick() + XUiHelper.StopAnimation() + self:PlayAnimation("QieHuan") + self.BtnArchive.gameObject:SetActiveEx(false) + self.BtnDetial.gameObject:SetActiveEx(true) +end + +function XUiCharacterDetail:OnAwake() + self:InitAutoScript() + + self.TxtElementDes = { + [1] = self.TxtElementDes1, + [2] = self.TxtElementDes2, + [3] = self.TxtElementDes3 + } + + self.TxtElementValue = { + [1] = self.TxtElementValue1, + [2] = self.TxtElementValue2, + [3] = self.TxtElementValue3 + } + + self.TxtSpecialDes = { + [1] = self.TxtSpecialDes1, + [2] = self.TxtSpecialDes2, + [3] = self.TxtSpecialDes3 + } + + self.Txt = { + [1] = self.Txt1, + [2] = self.Txt2, + [3] = self.Txt3 + } + + self.TxtGraphName = { + [1] = self.TxtGraphName1, + [2] = self.TxtGraphName2, + [3] = self.TxtGraphName3, + [4] = self.TxtGraphName4, + [5] = self.TxtGraphName5, + [6] = self.TxtGraphName6 + } +end + +function XUiCharacterDetail:OnStart(CharacterId) + local detailConfig = XCharacterConfigs.GetCharDetailTemplate(CharacterId) + if not detailConfig then + return + end + + self.CharacterId = CharacterId + + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + + self.PanelContentRtf = self.PanelContent:GetComponent("RectTransform") + self.BtnArchive.gameObject:SetActiveEx(true) + self.BtnDetial.gameObject:SetActiveEx(false) + self.PanelAsset.gameObject:SetActiveEx(false) + + local isIsomer = XCharacterConfigs.IsIsomer(CharacterId) + self.BtnTeamRecomend.gameObject:SetActiveEx(not isIsomer) + self.BtnEquipRecomend.gameObject:SetActiveEx(not isIsomer) + + self:SwitchView(CharDetailUiType.Detail) + +end + +function XUiCharacterDetail:SwitchView(uiType) + self.CurUiType = uiType + self:UpdateStateView() +end + + +function XUiCharacterDetail:UpdateStateView() + if self.CurUiType == CharDetailUiType.Detail then + self.PanelAsset.gameObject:SetActiveEx(false) + self.PanelDetailInfo.gameObject:SetActiveEx(true) + self:UpdateRightElementView() + self:CloseChildUi(CHILD_UI_EQUIP) + self:CloseChildUi(CHILD_UI_TEAM) + elseif self.CurUiType == CharDetailUiType.Equip then + self.PanelAsset.gameObject:SetActiveEx(true) + self.PanelDetailInfo.gameObject:SetActiveEx(false) + self:OpenChildUi(CHILD_UI_EQUIP, self.CharacterId, self) + self:CloseChildUi(CHILD_UI_TEAM) + elseif self.CurUiType == CharDetailUiType.Parner then + self.PanelAsset.gameObject:SetActiveEx(true) + self.PanelDetailInfo.gameObject:SetActiveEx(false) + self:CloseChildUi(CHILD_UI_EQUIP) + self:OpenChildUi(CHILD_UI_TEAM, self.CharacterId, self) + end +end + +function XUiCharacterDetail:UpdateRightElementView() + local detailConfig = XCharacterConfigs.GetCharDetailTemplate(self.CharacterId) + local charConfig = XCharacterConfigs.GetCharacterTemplate(self.CharacterId) + if not detailConfig or not charConfig then + return + end + + --描述 + self.TxtArchiveTitle.text = charConfig.Name + self.TxtArchIvesDes.text = detailConfig.DetailDes + + --职业 + local careerConfig = XCharacterConfigs.GetNpcTypeTemplate(detailConfig.Career) + if not careerConfig then + return + end + self.TxtCareerName.text = careerConfig.Name + self:SetUiSprite(self.ImgCareerIcon, careerConfig.Icon) + + --元素 + local elementValueList = detailConfig.ObtainElementValueList + local elementList = detailConfig.ObtainElementList + for i = 1, 3 do + if elementList[i] then + self.TxtElementDes[i].gameObject:SetActiveEx(true) + self.TxtElementValue[i].gameObject:SetActiveEx(true) + self.TxtElementValue[i].text = string.format("%s%s", elementValueList[i], "%") + + local config = XCharacterConfigs.GetCharElement(elementList[i]) + if config then + self.TxtElementDes[i].text = config.ElementName + end + else + self.TxtElementDes[i].gameObject:SetActiveEx(false) + self.TxtElementValue[i].gameObject:SetActiveEx(false) + end + end + + --特点 + local specialTitleList = detailConfig.ObtainSpeicalTitle + local specialDesList = detailConfig.ObtainSpeicalDes + for i = 1, 3 do + if specialTitleList[i] then + self.TxtSpecialDes[i].text = specialTitleList[i] + self.Txt[i].text = specialDesList[i] + self.TxtSpecialDes[i].gameObject:SetActiveEx(true) + self.Txt[i].gameObject:SetActiveEx(true) + else + self.TxtSpecialDes[i].gameObject:SetActiveEx(false) + self.Txt[i].gameObject:SetActiveEx(false) + end + end + + --类型 + local graphValueList = detailConfig.AttribGraphNum + local len = #graphValueList + for i = 1, len do + local pointTrans = self.PanelPointRoot:GetChild(i - 1) + local edgePos = self.PanelEdgeRoot:GetChild(i - 1).localPosition + local ratio = graphValueList[i] / 100 + pointTrans.localPosition = CS.UnityEngine.Vector3(edgePos.x * ratio, edgePos.y * ratio, 0) + end + self.PanelPointRoot.parent:GetComponent(typeof(CS.XUiPolygon)):Refresh() + + --类型名字 + for i = 1, 6 do + local config = XCharacterConfigs.GetCharGraphTemplate(i) + if config then + self.TxtGraphName[i].text = config.GraphName + end + end + + --人物名字,名称,icon等 + local quality = XCharacterConfigs.GetCharMinQuality(self.CharacterId) + local npcId = XCharacterConfigs.GetCharNpcId(self.CharacterId, quality) + local npc = CS.XNpcManager.GetNpcTemplate(npcId) + + if not npc then + return + end + + self.RImgQuality:SetRawImage(XCharacterConfigs.GetCharQualityIcon(quality)) + self.RImgRoleIcon:SetRawImage(XDataCenter.CharacterManager.GetCharHalfBodyImage(self.CharacterId)) + self.TxtCharacterName.text = charConfig.Name + self.TxtCharacterDesName.text = charConfig.TradeName + + local castName = XFavorabilityConfigs.GetCharacterCvById(self.CharacterId) + local cast = (castName ~= "") and CS.XTextManager.GetText("FavorabilityCast", tostring(castName)) or "" + self.TxtCV.text = cast +end + +function XUiCharacterDetail:OnBtnBackClick() + if self.CurUiType == CharDetailUiType.Parner or self.CurUiType == CharDetailUiType.Equip then + self:SwitchView(CharDetailUiType.Detail) + else + local tPos = self.PanelContentRtf.anchoredPosition + if tPos.x > -400 then + self.PanelContentRtf.anchoredPosition = CS.UnityEngine.Vector2(-450, tPos.y) + self.BtnArchive.gameObject:SetActiveEx(true) + self.BtnDetial.gameObject:SetActiveEx(false) + else + self:Close() + end + end +end + +function XUiCharacterDetail:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCharacterDetail/XUiPanelDetailEquipItem.lua b/Resources/Scripts/XUi/XUiCharacterDetail/XUiPanelDetailEquipItem.lua new file mode 100644 index 00000000..347f0398 --- /dev/null +++ b/Resources/Scripts/XUi/XUiCharacterDetail/XUiPanelDetailEquipItem.lua @@ -0,0 +1,114 @@ +XUiPanelDetailEquipItem = XClass(nil, "XUiPanelDetailEquipItem") + +function XUiPanelDetailEquipItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self:InitAutoScript() + + self.GridItem = { + [1] = self.GridItem1, + [2] = self.GridItem2, + [3] = self.GridItem3, + [4] = self.GridItem4, + [5] = self.GridItem5, + [6] = self.GridItem6, + } + + self.voteId = nil + + self.GridItems = {} +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelDetailEquipItem:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiPanelDetailEquipItem:AutoInitUi() + self.TxtVoteNum = self.Transform:Find("TxtVoteNum"):GetComponent("Text") + self.GridItem3 = self.Transform:Find("RootPanelLayout/GridItem3") + self.GridItem2 = self.Transform:Find("RootPanelLayout/GridItem2") + self.GridItem1 = self.Transform:Find("RootPanelLayout/GridItem1") + self.Panel = self.Transform:Find("RootPanelWeapon/Panel") + self.GridEquipItem = self.Transform:Find("RootPanelWeapon/Panel/GridEquipItem") + self.TxtRank = self.Transform:Find("RootPanelRank/TxtRank"):GetComponent("Text") + self.GridItem4 = self.Transform:Find("RootPanelLayout/GridItem4") + self.GridItem5 = self.Transform:Find("RootPanelLayout/GridItem5") + self.GridItem6 = self.Transform:Find("RootPanelLayout/GridItem6") + self.BtnVote = self.Transform:Find("RootPanelBtn/BtnVote"):GetComponent("Button") + self.PanelImgVoted = self.Transform:Find("RootPanelBtn/PanelImgVoted") +end + +function XUiPanelDetailEquipItem:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelDetailEquipItem:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelDetailEquipItem:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelDetailEquipItem:AutoAddListener() + self:RegisterClickEvent(self.BtnVote, self.OnBtnVoteClick) +end +-- auto +function XUiPanelDetailEquipItem:Init(rootUi) + self.RootUi = rootUi +end + +function XUiPanelDetailEquipItem:UpdateView(recommendConfig, rank) + self.VoteId = recommendConfig.Id + self.TxtRank.text = rank + + local template = XCharacterConfigs.GetCharDetailEquipTemplate(self.VoteId) + if not template then + return + end + + --刷新装备 + self.GridEquip = self.GridEquip or XUiGridCommon.New(self.RootUi, self.GridEquipItem) + self.GridEquip:Refresh(template.EquipRecomend) + + --刷新意识 + local chipList = template.ChipRecomend + + for i = 1, 6 do + if self.GridItem[i] then + local gridItem = self.GridItems[i] + if not gridItem then + gridItem = XUiGridCommon.New(self.RootUi, self.GridItem[i]) + self.GridItems[i] = gridItem + end + gridItem:Refresh(chipList[i]) + end + end + + self:UpdateVoteView() +end + +function XUiPanelDetailEquipItem:UpdateVoteView() + local voteMo = XDataCenter.VoteManager.GetVote(self.VoteId) + local isGroupVoted = XDataCenter.VoteManager.IsGroupVoted(voteMo.GroupId) + local isVoteSelected = XDataCenter.VoteManager.IsVoteSelected(voteMo.GroupId, self.VoteId) + + self.BtnVote.gameObject:SetActive(not isGroupVoted) + self.PanelImgVoted.gameObject:SetActive(isGroupVoted and isVoteSelected) + self.TxtVoteNum.text = tostring(voteMo.VoteNum) +end + +function XUiPanelDetailEquipItem:OnBtnVoteClick() + XUiHelper.StopAnimation() + XDataCenter.VoteManager.AddVote(self.VoteId) +end + +return XUiPanelDetailEquipItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCharacterDetail/XUiPanelDetailTeamItem.lua b/Resources/Scripts/XUi/XUiCharacterDetail/XUiPanelDetailTeamItem.lua new file mode 100644 index 00000000..ed53829b --- /dev/null +++ b/Resources/Scripts/XUi/XUiCharacterDetail/XUiPanelDetailTeamItem.lua @@ -0,0 +1,106 @@ +XUiPanelDetailTeamItem = XClass(nil, "XUiPanelDetailTeamItem") + +function XUiPanelDetailTeamItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self:InitAutoScript() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelDetailTeamItem:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiPanelDetailTeamItem:AutoInitUi() + self.TxtVoteNum = self.Transform:Find("TxtVoteNum"):GetComponent("Text") + self.BtnVote = self.Transform:Find("RootPanelBtn/BtnVote"):GetComponent("Button") + self.PanelCharItem1 = self.Transform:Find("layout/PanelCharItem1") + self.TxtName1 = self.Transform:Find("layout/PanelCharItem1/TxtName1"):GetComponent("Text") + self.RImgQuality1 = self.Transform:Find("layout/PanelCharItem1/RImgQuality1"):GetComponent("RawImage") + self.PanelCharItem2 = self.Transform:Find("layout/PanelCharItem2") + self.TxtName2 = self.Transform:Find("layout/PanelCharItem2/TxtName2"):GetComponent("Text") + self.RImgQuality2 = self.Transform:Find("layout/PanelCharItem2/RImgQuality2"):GetComponent("RawImage") + self.PanelCharItem3 = self.Transform:Find("layout/PanelCharItem3") + self.TxtName3 = self.Transform:Find("layout/PanelCharItem3/TxtName3"):GetComponent("Text") + self.RImgQuality3 = self.Transform:Find("layout/PanelCharItem3/RImgQuality3"):GetComponent("RawImage") + self.TxtRank = self.Transform:Find("RootPanelRank/TxtRank"):GetComponent("Text") + self.PanelImgVoted = self.Transform:Find("RootPanelBtn/PanelImgVoted") +end + +function XUiPanelDetailTeamItem:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelDetailTeamItem:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelDetailTeamItem:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelDetailTeamItem:AutoAddListener() + self:RegisterClickEvent(self.BtnVote, self.OnBtnVoteClick) +end +-- auto +function XUiPanelDetailTeamItem:Init(rootUi) + self.RootUi = rootUi +end + +function XUiPanelDetailTeamItem:UpdateView(recommendConfig, rank, curCharacterId) + self.VoteId = recommendConfig.Id + self.CurCharacterId = curCharacterId + + self.TxtRank.text = rank + + local template = XCharacterConfigs.GetCharDetailParnerTemplate(self.VoteId) + local charList = template.CharacterRecomend + + for i = 1, 3 do + local templateId + if i == 1 then + templateId = self.CurCharacterId + else + templateId = charList[i - 1] + end + + local indexKey = string.format("CharGrid%s", i) + local itemKey = string.format("PanelCharItem%s", i) + local grid = self[indexKey] + if not grid then + grid = XUiGridCommon.New(self.RootUi, self[itemKey]) + self[indexKey] = grid + end + grid:Refresh(templateId) + + local quality = XCharacterConfigs.GetCharMinQuality(templateId) + self["RImgQuality" .. i]:SetRawImage(XCharacterConfigs.GetCharacterQualityIcon(quality)) + self["TxtName" .. i].text = XCharacterConfigs.GetCharacterFullNameStr(templateId) + end + + self:UpdateVoteView() +end + +function XUiPanelDetailTeamItem:UpdateVoteView() + local voteMo = XDataCenter.VoteManager.GetVote(self.VoteId) + local isGroupVoted = XDataCenter.VoteManager.IsGroupVoted(voteMo.GroupId) + local isVoteSelected = XDataCenter.VoteManager.IsVoteSelected(voteMo.GroupId, self.VoteId) + + self.BtnVote.gameObject:SetActive(not isGroupVoted) + self.PanelImgVoted.gameObject:SetActive(isGroupVoted and isVoteSelected) + self.TxtVoteNum.text = tostring(voteMo.VoteNum) +end + +function XUiPanelDetailTeamItem:OnBtnVoteClick() + XUiHelper.StopAnimation() + XDataCenter.VoteManager.AddVote(self.VoteId) +end + +return XUiPanelDetailTeamItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCharacterDetail/XUiPanelEquipInfo.lua b/Resources/Scripts/XUi/XUiCharacterDetail/XUiPanelEquipInfo.lua new file mode 100644 index 00000000..77a8283f --- /dev/null +++ b/Resources/Scripts/XUi/XUiCharacterDetail/XUiPanelEquipInfo.lua @@ -0,0 +1,109 @@ +local XUiPanelEquipInfo = XLuaUiManager.Register(XLuaUi, "UiPanelEquipInfo") + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelEquipInfo:InitAutoScript() + self:AutoInitUi() + XTool.InitUiObject(self) + self:AutoAddListener() +end + +function XUiPanelEquipInfo:AutoInitUi() + self.PanelTaskList = self.Transform:Find("PanelTaskList") + self.PanelDetailEquipItem = self.Transform:Find("PanelTaskList/Viewport/PanelDetailEquipItem") +end + +function XUiPanelEquipInfo:AutoAddListener() +end +-- auto +function XUiPanelEquipInfo:OnAwake() + self:InitAutoScript() +end + +function XUiPanelEquipInfo:OnStart(CharacterId, rootUi) + self.RootUi = rootUi + self.CharacterId = CharacterId + self.DynamicTable = XDynamicTableNormal.New(self.PanelTaskList) + self.DynamicTable:SetProxy(XUiPanelDetailEquipItem) + self.DynamicTable:SetDelegate(self) + self.PanelDetailEquipItem.gameObject:SetActive(false) + self:InitTabBtnGroup() + + if not XDataCenter.VoteManager.IsInit() then + XDataCenter.VoteManager.GetVoteGroupListRequest() + end +end + +function XUiPanelEquipInfo:OnEnable() + self:SetupDynamicTable() + XEventManager.AddEventListener(XEventId.EVENT_VOTE_REFRESH, self.SetupDynamicTable, self) + self.RootUi:PlayAnimation("EquipInfoEnable") +end + +function XUiPanelEquipInfo:OnDisable() + XEventManager.RemoveEventListener(XEventId.EVENT_VOTE_REFRESH, self.SetupDynamicTable, self) + self.DynamicTable:Clear() +end + +function XUiPanelEquipInfo:InitTabBtnGroup() + local tabIdList = XCharacterConfigs.GetRecommendTabList(self.CharacterId, XCharacterConfigs.RecommendType.Equip) + if not tabIdList then + return + end + + local tabGroup = {} + for i = 1, #tabIdList do + local uiButton + if i == 1 then + uiButton = self.BtnTabMatch + else + local itemGo = CS.UnityEngine.Object.Instantiate(self.BtnTabMatch.gameObject) + itemGo.transform:SetParent(self.PanelTagsLayoutRT, false) + uiButton = itemGo.transform:GetComponent("XUiButton") + end + + local config = XCharacterConfigs.GetRecommendTabTemplate(self.CharacterId, tabIdList[i], XCharacterConfigs.RecommendType.Equip) + uiButton:SetName(config.TabName) + + table.insert(tabGroup, uiButton) + end + + self.PanelTagsLayout:Init(tabGroup, function(tabIndex) self:OnClickTabCallBack(tabIndex) end) + self.PanelTagsLayout:SelectIndex(1) +end + +function XUiPanelEquipInfo:OnClickTabCallBack(tabIndex) + if self.CurTabId and self.CurTabId == tabIndex then + return + end + self.CurTabId = tabIndex + self.RootUi:PlayAnimation("TaskListQiehuan") + self:SetupDynamicTable() +end + +function XUiPanelEquipInfo:SetupDynamicTable() + if not XDataCenter.VoteManager.IsInit() then + return + end + + local recommendEquipGroupId = XCharacterConfigs.GetRecommendGroupId(self.CharacterId, self.CurTabId, XCharacterConfigs.RecommendType.Equip) + local voteIds = XDataCenter.VoteManager.GetVoteIdListByGroupId(recommendEquipGroupId) + self.PageDatas = XCharacterConfigs.GetEquipRecommendListByIds(voteIds) + + if not self.PageDatas then + self.PageDatas = {} + end + + self.DynamicTable:SetDataSource(self.PageDatas) + self.DynamicTable:ReloadDataASync() +end + +function XUiPanelEquipInfo:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self.UiProxy) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:UpdateView(self.PageDatas[index], index) + end +end + +return XUiPanelEquipInfo \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCharacterDetail/XUiPanelTeamInfo.lua b/Resources/Scripts/XUi/XUiCharacterDetail/XUiPanelTeamInfo.lua new file mode 100644 index 00000000..32b6596f --- /dev/null +++ b/Resources/Scripts/XUi/XUiCharacterDetail/XUiPanelTeamInfo.lua @@ -0,0 +1,103 @@ +local XUiPanelTeamInfo = XLuaUiManager.Register(XLuaUi, "UiPanelTeamInfo") + +function XUiPanelTeamInfo:InitAutoScript() + self:AutoInitUi() + XTool.InitUiObject(self) +end + +function XUiPanelTeamInfo:AutoInitUi() + self.PanelDynamicLayout = self.Transform:Find("PanelDynamicLayout") + self.PanelDetailTeamItem = self.Transform:Find("PanelDynamicLayout/Viewport/PanelDetailTeamItem") +end + +function XUiPanelTeamInfo:OnAwake() + self:InitAutoScript() +end + +function XUiPanelTeamInfo:OnStart(CharacterId, rootUi) + self.RootUi = rootUi + self.CharacterId = CharacterId + self.DynamicTable = XDynamicTableNormal.New(self.PanelDynamicLayout) + self.DynamicTable:SetProxy(XUiPanelDetailTeamItem) + self.DynamicTable:SetDelegate(self) + self.PanelDetailTeamItem.gameObject:SetActive(false) + self:InitTabBtnGroup() + + if not XDataCenter.VoteManager.IsInit() then + XDataCenter.VoteManager.GetVoteGroupListRequest() + end +end + +function XUiPanelTeamInfo:OnEnable() + self:SetupDynamicTable() + XEventManager.AddEventListener(XEventId.EVENT_VOTE_REFRESH, self.SetupDynamicTable, self) + self.RootUi:PlayAnimation("TeamInfoEnable") +end + +function XUiPanelTeamInfo:OnDisable() + XEventManager.RemoveEventListener(XEventId.EVENT_VOTE_REFRESH, self.SetupDynamicTable, self) + self.DynamicTable:Clear() +end + +function XUiPanelTeamInfo:InitTabBtnGroup() + local tabIdList = XCharacterConfigs.GetRecommendTabList(self.CharacterId, XCharacterConfigs.RecommendType.Character) + if not tabIdList then + return + end + + local tabGroup = {} + for i = 1, #tabIdList do + local uiButton + if i == 1 then + uiButton = self.BtnTabMatch + else + local itemGo = CS.UnityEngine.Object.Instantiate(self.BtnTabMatch.gameObject) + itemGo.transform:SetParent(self.PanelTagsLayoutRT, false) + uiButton = itemGo.transform:GetComponent("XUiButton") + end + + local config = XCharacterConfigs.GetRecommendTabTemplate(self.CharacterId, tabIdList[i], XCharacterConfigs.RecommendType.Character) + uiButton:SetName(config.TabName) + + table.insert(tabGroup, uiButton) + end + + self.PanelTagsLayout:Init(tabGroup, function(tabIndex) self:OnClickTabCallBack(tabIndex) end) + self.PanelTagsLayout:SelectIndex(1) +end + +function XUiPanelTeamInfo:OnClickTabCallBack(tabIndex) + if self.CurTabId and self.CurTabId == tabIndex then + return + end + self.CurTabId = tabIndex + self.RootUi:PlayAnimation("DynamicLayoutQiehuan") + self:SetupDynamicTable() +end + +function XUiPanelTeamInfo:SetupDynamicTable() + if not XDataCenter.VoteManager.IsInit() then + return + end + + local groupId = XCharacterConfigs.GetRecommendGroupId(self.CharacterId, self.CurTabId, XCharacterConfigs.RecommendType.Character) + local Ids = XDataCenter.VoteManager.GetVoteIdListByGroupId(groupId) + self.PageDatas = XCharacterConfigs.GetCharacterRecommendListByIds(Ids) + + if not self.PageDatas then + self.PageDatas = {} + end + + self.DynamicTable:SetDataSource(self.PageDatas) + self.DynamicTable:ReloadDataASync() +end + +function XUiPanelTeamInfo:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self.UiProxy) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:UpdateView(self.PageDatas[index], index, self.CharacterId) + end +end + +return XUiPanelTeamInfo \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChatServe/ChatModel/EmojiModel/XUiEmojiItem.lua b/Resources/Scripts/XUi/XUiChatServe/ChatModel/EmojiModel/XUiEmojiItem.lua new file mode 100644 index 00000000..8d303506 --- /dev/null +++ b/Resources/Scripts/XUi/XUiChatServe/ChatModel/EmojiModel/XUiEmojiItem.lua @@ -0,0 +1,70 @@ +local XUiEmojiItem = XClass(nil, "XUiEmojiItem")--表情面板里面的item + +function XUiEmojiItem:Ctor(rootUi, ui) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + self:InitAutoScript() + + self.ClickCallBack = nil +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiEmojiItem:InitAutoScript() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + + +function XUiEmojiItem:AutoAddListener() + self.AutoCreateListeners = {} + XUiHelper.RegisterClickEvent(self, self.BtnEmoji, self.OnBtnEmojiClick) +end +-- auto +function XUiEmojiItem:OnBtnEmojiClick()--发送表情 + if self.ClickCallBack then + local content = tostring(self.EmojiId) + self.ClickCallBack(content) + end +end + +function XUiEmojiItem:Refresh(emojiData) + self.EmojiData = emojiData + self.EmojiId = self.EmojiData:GetEmojiId() + local icon = emojiData:GetEmojiIcon() + if icon ~= nil then + self.RImgEmojiD:SetRawImage(icon) + end +end + +function XUiEmojiItem:SetClickCallBack(cb) + self.ClickCallBack = cb +end + +function XUiEmojiItem:Show() + if self.GameObject:Exist() and self.GameObject.activeSelf == false then + self.GameObject:SetActive(true) + end +end + +function XUiEmojiItem:Hide() + if self.GameObject:Exist() and self.GameObject.activeSelf then + self.GameObject:SetActive(false) + self.TimeObj.gameObject:SetActive(false) + end +end + +function XUiEmojiItem:ShowTimeLabel(showStr) + if showStr and showStr ~= "" then + self.TimeObj.gameObject:SetActive(true) + self.TimeLable.text = showStr + else + self.TimeObj.gameObject:SetActive(false) + end + +end + +return XUiEmojiItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChatServe/ChatModel/EmojiModel/XUiPanelEmoji.lua b/Resources/Scripts/XUi/XUiChatServe/ChatModel/EmojiModel/XUiPanelEmoji.lua new file mode 100644 index 00000000..10519500 --- /dev/null +++ b/Resources/Scripts/XUi/XUiChatServe/ChatModel/EmojiModel/XUiPanelEmoji.lua @@ -0,0 +1,186 @@ +XUiPanelEmoji = XClass(nil, "XUiPanelEmoji") +local STR_RESIDUE = CS.XTextManager.GetText("Residue") +local interval = 1000 +local XUiEmojiItem = require("XUi/XUiChatServe/ChatModel/EmojiModel/XUiEmojiItem") + +function XUiPanelEmoji:Ctor(rootUi, ui) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.GameObject.gameObject:SetActive(false) + self.Transform = ui.transform + XTool.InitUiObject(self) + self:InitAutoScript() + + self.BtnBack.CallBack = function() self:Hide() end + + self.EmojiPrefab = self.EmojiItem.gameObject + self.EmojiList = {} + self.EmojiTimeLimitDic = {} + self.NeedTimeCountDown = false + self.EmojiScheduleTimer = false + + self:Init() +end + +function XUiPanelEmoji:Init() + self.EmojiPrefab:SetActive(false) + if self.EmojiPrefab == nil then + return + end + + local templates = XDataCenter.ChatManager.GetEmojiTemplates() + + self.EmojiTimeLimitDic = {} + local serverTime = XTime.GetServerNowTimestamp() + for _, emojiData in ipairs(templates) do + local luaObj = self:CreateEmoji() + if luaObj ~= nil then + luaObj:Refresh(emojiData) + luaObj:Show() + table.insert(self.EmojiList, luaObj) + + if emojiData:IsLimitEmoji() then + self.EmojiTimeLimitDic[emojiData:GetEmojiId()] = {luaObjT = luaObj, emojiDataT = emojiData} + end + end + end +end + +function XUiPanelEmoji:EmojiStartScheduleTime() + + local function CountDownFunc() + local UnNeedTimerList = {} + local serverTime = XTime.GetServerNowTimestamp() + self.NeedTimeCountDown = false + + for emojiId, template in pairs(self.EmojiTimeLimitDic) do + local luaObj = template.luaObjT + local data = template.emojiDataT + local lastTime = data:GetEmojiEndTime() - serverTime + if lastTime > 0 then + self.NeedTimeCountDown = true + luaObj:ShowTimeLabel(STR_RESIDUE .. XUiHelper.GetTime(lastTime, XUiHelper.TimeFormatType.CHATEMOJITIMER)) + else + luaObj:Hide() + table.insert(UnNeedTimerList, emojiId) + end + end + + for _ , tempId in ipairs(UnNeedTimerList) do + self.EmojiTimeLimitDic[tempId] = nil + end + end + + CountDownFunc() + + if self.NeedTimeCountDown and not self.EmojiScheduleTimer then + + self.EmojiScheduleTimer = XScheduleManager.ScheduleForever(function() + CountDownFunc() + if not self.NeedTimeCountDown then + self:EmojiUnScheduleTime() + end + end, interval ) + + end +end + +function XUiPanelEmoji:EmojiUnScheduleTime() + if self.EmojiScheduleTimer then + XScheduleManager.UnSchedule(self.EmojiScheduleTimer) + self.EmojiScheduleTimer = false + end +end + +function XUiPanelEmoji:SetClickCallBack(cb) + for index = 1, #self.EmojiList do + local emoji = self.EmojiList[index] + if emoji ~= nil then + emoji:SetClickCallBack(cb) + end + end +end + +function XUiPanelEmoji:CreateEmoji() + local parent = self.EmojiPrefab.transform.parent + if parent ~= nil and self.EmojiPrefab ~= nil then + local gameObject = CS.UnityEngine.GameObject.Instantiate(self.EmojiPrefab) + if gameObject ~= nil then + gameObject.transform:SetParent(parent, false) + local luaObj = XUiEmojiItem.New(self.RootUi, gameObject) + return luaObj + end + end + return nil +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelEmoji:InitAutoScript() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiPanelEmoji:GetAutoKey(uiNode, eventName) + if not uiNode then + return + end + return eventName .. uiNode:GetHashCode() +end + +function XUiPanelEmoji:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then + return + end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiPanelEmoji:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiPanelEmoji:AutoAddListener() + self.AutoCreateListeners = {} +end +-- auto + +function XUiPanelEmoji:Show() + if not XTool.UObjIsNil(self.GameObject) and self.GameObject.activeSelf == false then + self.GameObject:SetActive(true) + self:EmojiStartScheduleTime() + end +end + +function XUiPanelEmoji:Hide() + if not XTool.UObjIsNil(self.GameObject) and self.GameObject.activeSelf then + self.GameObject:SetActive(false) + self:EmojiUnScheduleTime() + end +end + +function XUiPanelEmoji:OpenOrClosePanel() + if self.GameObject == nil then + return + end + if not XTool.UObjIsNil(self.GameObject) then + if not self.GameObject.activeSelf then + self:Show() + else + self:Hide() + end + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChatServe/ChatModel/XUiBtnTitleItem.lua b/Resources/Scripts/XUi/XUiChatServe/ChatModel/XUiBtnTitleItem.lua new file mode 100644 index 00000000..1f5653d2 --- /dev/null +++ b/Resources/Scripts/XUi/XUiChatServe/ChatModel/XUiBtnTitleItem.lua @@ -0,0 +1,102 @@ +XUiBtnTitleItem = XClass(nil, "XUiBtnTitleItem") + +function XUiBtnTitleItem:Ctor(ui,panelChatContent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.PanelChatContent = panelChatContent + self:InitAutoScript() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiBtnTitleItem:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiBtnTitleItem:AutoInitUi() + self.TxtTitle = self.Transform:Find("TxtTitle"):GetComponent("Text") + self.TxtTitleDis = self.Transform:Find("TxtTitleDis"):GetComponent("Text") + self.BtnToggle = self.Transform:GetComponent("Toggle") + self.BgSel = self.Transform:Find("BgSel") + self.BgDis = self.Transform:Find("BgDis") + self.BgNol = self.Transform:Find("BgNol") +end + +function XUiBtnTitleItem:GetAutoKey(uiNode,eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiBtnTitleItem:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiBtnTitleItem:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key],eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiBtnTitleItem:AutoAddListener() + self.AutoCreateListeners = {} + self:RegisterListener(self.BtnToggle, "onValueChanged", self.OnToggleClick) +end +-- auto +function XUiBtnTitleItem:OnToggleClick() + if self.index == 2 or self.index == 3 then + return + end + -- if code then + -- self.PanelChatContent:RefreshChatList(self.index) + -- end +end + +function XUiBtnTitleItem:SetData( title,index,panel ) + self.title = title + self.index = index + self.panel = panel + if index == 1 then + if self.BtnToggle.isOn then + self:OnToggleClick(true) + else + self.BtnToggle.isOn = true + end + else + if self.BtnToggle.isOn then + self.BtnToggle.isOn = false + else + self:OnToggleClick(false) + end + end + if self.index == 2 or self.index == 3 then + self.TxtTitleDis.text = title + self.TxtTitle.gameObject:SetActive(false) + self.TxtTitleDis.gameObject:SetActive(true) + self.BgSel.gameObject:SetActive(false) + self.BgDis.gameObject:SetActive(true) + self.BgNol.gameObject:SetActive(false) + else + self.TxtTitle.text = title + self.TxtTitle.gameObject:SetActive(true) + self.TxtTitleDis.gameObject:SetActive(false) + self.BgSel.gameObject:SetActive(true) + self.BgDis.gameObject:SetActive(false) + self.BgNol.gameObject:SetActive(false) + end +end +return XUiBtnTitleItem diff --git a/Resources/Scripts/XUi/XUiChatServe/Item/XUiGridChatChannelItem.lua b/Resources/Scripts/XUi/XUiChatServe/Item/XUiGridChatChannelItem.lua new file mode 100644 index 00000000..5b39a5d2 --- /dev/null +++ b/Resources/Scripts/XUi/XUiChatServe/Item/XUiGridChatChannelItem.lua @@ -0,0 +1,36 @@ +local XUiGridChatChannelItem = XClass(nil, "XUiGridChatChannelItem") +local XUiButtonState = CS.UiButtonState +local isShowChannelNumber = CS.XGame.ClientConfig:GetInt("IsShowChannelNumber") + +function XUiGridChatChannelItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) +end + +function XUiGridChatChannelItem:Init(uiRoot) + self.UiRoot = uiRoot +end + +function XUiGridChatChannelItem:SetItemData(itemData) + self.GridChannelItem:SetNameByGroup(0, CS.XTextManager.GetText(itemData.IsRecruitChannel and "ChannelRecruit" or "ChannelLabel")) + self.GridChannelItem:SetNameByGroup(1, itemData.IsRecruitChannel and "" or tostring(itemData.ChannelId)) + + if isShowChannelNumber == 1 then + self.GridChannelItem:SetNameByGroup(2, CS.XTextManager.GetText("ChannelNumberLabel", itemData.PlayerNum)) + else + self.GridChannelItem:SetNameByGroup(2, "") + end + + local isSelectChannel = itemData.ChannelId == XDataCenter.ChatManager.GetCurrentChatChannelId() + self.GridChannelItem:ShowTag(isSelectChannel) + self:SetChannelSelected(itemData.IsSelected) +end + +function XUiGridChatChannelItem:SetChannelSelected(isSelected) + local btnState = isSelected and XUiButtonState.Select or XUiButtonState.Normal + self.GridChannelItem:SetButtonState(btnState) +end + +return XUiGridChatChannelItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChatServe/Item/XUiPanelWorldChatMyHelp.lua b/Resources/Scripts/XUi/XUiChatServe/Item/XUiPanelWorldChatMyHelp.lua new file mode 100644 index 00000000..73b3afc0 --- /dev/null +++ b/Resources/Scripts/XUi/XUiChatServe/Item/XUiPanelWorldChatMyHelp.lua @@ -0,0 +1,68 @@ +XUiPanelWorldChatMyHelp = XClass(nil, "XUiPanelWorldChatMyHelp") +local XUiPanelNameplate = require("XUi/XUiNameplate/XUiPanelNameplate") +function XUiPanelWorldChatMyHelp:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + if self.BtnGive then + self.BtnGive.CallBack = function() + self:OnClickBtnGive() + end + end + if self.BtnView then + XUiHelper.RegisterClickEvent(self, self.BtnView, self.OnBtnViewClick) + end + + self.UiPanelNameplate = XUiPanelNameplate.New(self.PanelNameplate, self) +end + +function XUiPanelWorldChatMyHelp:OnClickBtnGive() + if self.SenderId and self.WordId then + XDataCenter.SpringFestivalActivityManager.CollectWordsGiveWordToOthersRequest(self.WordId,self.SenderId,true,function(rewards) + XUiManager.TipText("SpringFestivalSendWordSuccess") + if not rewards then return end + XUiManager.OpenUiTipReward(rewards) + end) + end +end + +function XUiPanelWorldChatMyHelp:Refresh(chatData) + self.ChatContent = chatData + self.CreateTime = chatData.CreateTime + self.SenderId = chatData.SenderId + self.WordId = chatData.CollectWordId + self.TxtWord.text = chatData.Content + if self.TxtName then + self.TxtName.text = chatData.NickName + end + if self.TxtNameGuild then + self.TxtNameGuild.text = chatData.GuildName + end + local medalConfig = XMedalConfigs.GetMeadalConfigById(chatData.CurrMedalId) + local medalIcon = nil + if medalConfig then + medalIcon = medalConfig.MedalIcon + end + if medalIcon ~= nil then + self.ImgMedalIcon:SetRawImage(medalIcon) + self.ImgMedalIcon.gameObject:SetActiveEx(true) + else + self.ImgMedalIcon.gameObject:SetActiveEx(false) + end + XUiPLayerHead.InitPortrait(chatData.Icon, chatData.HeadFrameId, self.Head) + + if XTool.IsNumberValid(chatData.NameplateId) then + self.UiPanelNameplate:UpdateDataById(chatData.NameplateId) + self.UiPanelNameplate.GameObject:SetActiveEx(true) + else + self.UiPanelNameplate.GameObject:SetActiveEx(false) + end +end + +function XUiPanelWorldChatMyHelp:OnBtnViewClick() + if XDataCenter.RoomManager.RoomData and self.playerId == XPlayer.Id then + --在房间中不能在聊天打开自己详情面板 + return + end + XDataCenter.PersonalInfoManager.ReqShowInfoPanel(self.SenderId, nil, nil, self.ChatContent) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChatServe/Item/XUiPanelWorldChatMyMsgEmoji.lua b/Resources/Scripts/XUi/XUiChatServe/Item/XUiPanelWorldChatMyMsgEmoji.lua new file mode 100644 index 00000000..9e346dab --- /dev/null +++ b/Resources/Scripts/XUi/XUiChatServe/Item/XUiPanelWorldChatMyMsgEmoji.lua @@ -0,0 +1,126 @@ +XUiPanelWorldChatMyMsgEmoji = XClass(nil, "XUiPanelWorldChatMyMsgEmoji") +local XUiPanelNameplate = require("XUi/XUiNameplate/XUiPanelNameplate") +function XUiPanelWorldChatMyMsgEmoji:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:InitAutoScript() + + self.UiPanelNameplate = XUiPanelNameplate.New(self.PanelNameplate, self) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelWorldChatMyMsgEmoji:InitAutoScript() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiPanelWorldChatMyMsgEmoji:GetAutoKey(uiNode, eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiPanelWorldChatMyMsgEmoji:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiPanelWorldChatMyMsgEmoji:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiPanelWorldChatMyMsgEmoji:AutoAddListener() + self.AutoCreateListeners = {} + XUiHelper.RegisterClickEvent(self, self.BtnView, self.OnBtnViewClick) +end +-- auto +function XUiPanelWorldChatMyMsgEmoji:OnBtnViewClick() + if XDataCenter.RoomManager.RoomData and self.playerId == XPlayer.Id then + --在房间中不能在聊天打开自己详情面板 + return + end + XDataCenter.PersonalInfoManager.ReqShowInfoPanel(self.playerId) +end + +function XUiPanelWorldChatMyMsgEmoji:RefreshBabelTowerLevel(chatData) + local babelTowerIcon = XDataCenter.MedalManager.GetScoreTitleIconById(chatData.BabelTowerTitleId) + local babelTowerLevel = chatData.BabelTowerLevel + + if babelTowerIcon then + self.ImgBabelTowerLv:SetRawImage(babelTowerIcon) + self.TxtBabelTowerLv.text = babelTowerLevel + self.ImgBabelTowerLv.gameObject:SetActiveEx(true) + else + self.ImgBabelTowerLv.gameObject:SetActiveEx(false) + end + +end + +function XUiPanelWorldChatMyMsgEmoji:RefreshGuildRankLevel(chatData) + local rankLevel = chatData.GuildRankLevel + local isJoin = XDataCenter.GuildManager.IsJoinGuild() + + if isJoin and chatData.ChannelType == ChatChannelType.Guild and rankLevel > 0 then + self.TxtGuildPosition.text = XDataCenter.GuildManager.GetRankNameByLevel(rankLevel) + self.RImgGuildPosition.gameObject:SetActiveEx(true) + -- self.RImgGuildPosition:SetRawImage(XGuildConfig.GUildRankIcon[rankLevel]) + else + self.RImgGuildPosition.gameObject:SetActiveEx(false) + end + local guildName = chatData.GuildName + if chatData.ChannelType ~= ChatChannelType.Guild and guildName and guildName ~= "" then + self.TxtNameGuild.gameObject:SetActiveEx(true) + self.TxtNameGuild.text = string.format("[%s]", guildName) + else + self.TxtNameGuild.gameObject:SetActiveEx(false) + end +end + +function XUiPanelWorldChatMyMsgEmoji:Refresh(chatData) + self.playerId = chatData.SenderId + self.TxtName.text = XDataCenter.SocialManager.GetPlayerRemark(chatData.SenderId, chatData.NickName) + XUiPLayerHead.InitPortrait(chatData.Icon, chatData.HeadFrameId, self.Head) + + self:RefreshBabelTowerLevel(chatData) + self:RefreshGuildRankLevel(chatData) + + local icon = XDataCenter.ChatManager.GetEmojiIcon(chatData.Content) + local medalConfig = XMedalConfigs.GetMeadalConfigById(chatData.CurrMedalId) + local medalIcon = nil + + if medalConfig then + medalIcon = medalConfig.MedalIcon + end + + if icon ~= nil then + self.RImgEmoji:SetRawImage(icon) + end + if medalIcon ~= nil then + self.ImgMedalIcon:SetRawImage(medalIcon) + self.ImgMedalIcon.gameObject:SetActiveEx(true) + else + self.ImgMedalIcon.gameObject:SetActiveEx(false) + end + + if XTool.IsNumberValid(chatData.NameplateId) then + self.UiPanelNameplate:UpdateDataById(chatData.NameplateId) + self.UiPanelNameplate.GameObject:SetActiveEx(true) + else + self.UiPanelNameplate.GameObject:SetActiveEx(false) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChatServe/Item/XUiPanelWorldChatMyMsgItem.lua b/Resources/Scripts/XUi/XUiChatServe/Item/XUiPanelWorldChatMyMsgItem.lua new file mode 100644 index 00000000..f71d4815 --- /dev/null +++ b/Resources/Scripts/XUi/XUiChatServe/Item/XUiPanelWorldChatMyMsgItem.lua @@ -0,0 +1,141 @@ +XUiPanelWorldChatMyMsgItem = XClass(nil, "XUiPanelWorldChatMyMsgItem") +local XUiPanelNameplate = require("XUi/XUiNameplate/XUiPanelNameplate") +function XUiPanelWorldChatMyMsgItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:InitAutoScript() + + self.UiPanelNameplate = XUiPanelNameplate.New(self.PanelNameplate, self) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelWorldChatMyMsgItem:InitAutoScript() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiPanelWorldChatMyMsgItem:GetAutoKey(uiNode, eventName) + if not uiNode then + return + end + return eventName .. uiNode:GetHashCode() +end + +function XUiPanelWorldChatMyMsgItem:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then + return + end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiPanelWorldChatMyMsgItem:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiPanelWorldChatMyMsgItem:AutoAddListener() + self.AutoCreateListeners = {} + XUiHelper.RegisterClickEvent(self, self.BtnView, self.OnBtnViewClick) + self:RegisterListener(self.TxtWord, "onHrefClick", self.OnBtnHrefClick) +end +-- auto +function XUiPanelWorldChatMyMsgItem:OnBtnViewClick() + if XDataCenter.RoomManager.RoomData and self.playerId == XPlayer.Id then + --在房间中不能在聊天打开自己详情面板 + return + end + XDataCenter.PersonalInfoManager.ReqShowInfoPanel(self.playerId, nil, nil, self.ChatContent) +end + +function XUiPanelWorldChatMyMsgItem:OnBtnHrefClick(param) + XDataCenter.RoomManager.ClickEnterRoomHref(param, self.CreateTime) +end + +function XUiPanelWorldChatMyMsgItem:RefreshBabelTowerLevel(chatData) + local babelTowerIcon = XDataCenter.MedalManager.GetScoreTitleIconById(chatData.BabelTowerTitleId) + local babelTowerLevel = chatData.BabelTowerLevel + + if babelTowerIcon then + self.ImgBabelTowerLv:SetRawImage(babelTowerIcon) + self.TxtBabelTowerLv.text = babelTowerLevel + self.ImgBabelTowerLv.gameObject:SetActiveEx(true) + else + self.ImgBabelTowerLv.gameObject:SetActiveEx(false) + end + +end + +function XUiPanelWorldChatMyMsgItem:RefreshGuildRankLevel(chatData) + local rankLevel = chatData.GuildRankLevel + local isJoin = XDataCenter.GuildManager.IsJoinGuild() + if isJoin and chatData.ChannelType == ChatChannelType.Guild and rankLevel > 0 then + self.TxtGuildPosition.text = XDataCenter.GuildManager.GetRankNameByLevel(rankLevel) + self.RImgGuildPosition.gameObject:SetActiveEx(true) + -- self.RImgGuildPosition:SetRawImage(XGuildConfig.GUildRankIcon[rankLevel]) + else + self.RImgGuildPosition.gameObject:SetActiveEx(false) + end + local guildName = chatData.GuildName + if chatData.ChannelType ~= ChatChannelType.Guild and guildName and guildName ~= "" then + self.TxtNameGuild.gameObject:SetActiveEx(true) + self.TxtNameGuild.text = string.format("[%s]", guildName) + else + self.TxtNameGuild.gameObject:SetActiveEx(false) + end +end + +function XUiPanelWorldChatMyMsgItem:Refresh(chatData) + self.CreateTime = chatData.CreateTime + self.playerId = chatData.SenderId + self.ChatContent = chatData.Content + local playerName = XDataCenter.SocialManager.GetPlayerRemark(chatData.SenderId, chatData.NickName) + self.TxtName.text = playerName + + self:RefreshBabelTowerLevel(chatData) + self:RefreshGuildRankLevel(chatData) + self.TxtWord.text = chatData.Content + + if not string.IsNilOrEmpty(chatData.CustomContent) then + self.TxtWord.supportRichText = true + else + self.TxtWord.supportRichText = false + end + + local medalConfig = XMedalConfigs.GetMeadalConfigById(chatData.CurrMedalId) + local medalIcon = nil + + if medalConfig then + medalIcon = medalConfig.MedalIcon + end + + XUiPLayerHead.InitPortrait(chatData.Icon, chatData.HeadFrameId, self.Head) + + if medalIcon ~= nil then + self.ImgMedalIcon:SetRawImage(medalIcon) + self.ImgMedalIcon.gameObject:SetActiveEx(true) + else + self.ImgMedalIcon.gameObject:SetActiveEx(false) + end + + if XTool.IsNumberValid(chatData.NameplateId) then + self.UiPanelNameplate:UpdateDataById(chatData.NameplateId) + self.UiPanelNameplate.GameObject:SetActiveEx(true) + else + self.UiPanelNameplate.GameObject:SetActiveEx(false) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChatServe/Item/XUiPanelWorldChatSystemItem.lua b/Resources/Scripts/XUi/XUiChatServe/Item/XUiPanelWorldChatSystemItem.lua new file mode 100644 index 00000000..718f1374 --- /dev/null +++ b/Resources/Scripts/XUi/XUiChatServe/Item/XUiPanelWorldChatSystemItem.lua @@ -0,0 +1,11 @@ +XUiPanelWorldChatSystemItem = XClass(nil, "XUiPanelWorldChatSystemItem") + +function XUiPanelWorldChatSystemItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiPanelWorldChatSystemItem:Refresh(chatData) + self.TxtWord.text = string.format("%s%s", CS.XTextManager.GetText("GuildChannelTypeAll"), chatData.Content) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChatServe/XUiChatServeMain.lua b/Resources/Scripts/XUi/XUiChatServe/XUiChatServeMain.lua new file mode 100644 index 00000000..1c47e6ee --- /dev/null +++ b/Resources/Scripts/XUi/XUiChatServe/XUiChatServeMain.lua @@ -0,0 +1,592 @@ +local XUiChatServeMain = XLuaUiManager.Register(XLuaUi, "UiChatServeMain") +local ToggleName = { + CS.XTextManager.GetText("World"), + CS.XTextManager.GetText("Team"), + CS.XTextManager.GetText("Guild"), + CS.XTextManager.GetText("Mentor"), + -- CS.XTextManager.GetText("System"), +} + +local ToggleType = { + ChatChannelType.World, + ChatChannelType.Room, + ChatChannelType.Guild, + ChatChannelType.Mentor, + -- ChatChannelType.System, +} + +local DefaultType = ChatChannelType.World +local ChannelRefreshTime = CS.XGame.ClientConfig:GetInt("ChannelInfoRefreshMin") +local FadeTime = CS.XGame.ClientConfig:GetInt("ChannelChangeFadeTime") +local XUiGridChatChannelItem = require("XUi/XUiChatServe/Item/XUiGridChatChannelItem") + +local ChatRoomChannelNotOpen = CS.XTextManager.GetText("ChatRoomChannelNotOpen") +local IsMessageTipShow = false +function XUiChatServeMain:OnAwake() + self:InitAutoScript() + self.BtnRoom.CallBack = function() self:OnBtnRoomClick() end + self.BtnChannelSure.CallBack = function() self:OnBtnChannelSureClick() end + self.BtnChannelMask.CallBack = function() self:OnBtnChannelMaskClick() end + + self.DynamicTableChannels = XDynamicTableNormal.New(self.ChannelList.gameObject) + self.DynamicTableChannels:SetProxy(XUiGridChatChannelItem) + self.DynamicTableChannels:SetDelegate(self) +end + +function XUiChatServeMain:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self.UiRoot) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local curChannelData = self.ChannelInfos[index] + if curChannelData then + grid:SetItemData(curChannelData) + end + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + self:OnChannelInfoClick(index) + end +end + +function XUiChatServeMain:OnStart(isMain, ...) + local args = { ... } + self.SelType = args[1] or DefaultType + self.Inited = true + self.InputField.characterLimit = XDataCenter.ChatManager.GetWorldChatMaxCount() + self:CreateObject() + self.timerId = -1 + + self.ChannelSet = {} + for _, v in pairs(args) do + self.ChannelSet[v] = true + end + + if XDataCenter.GuildManager.IsJoinGuild() and not self.ChannelSet[ChatChannelType.Guild] then + self.ChannelSet[ChatChannelType.Guild] = true + end + XDataCenter.GuildManager.RequestGuildData() + + local mentorData = XDataCenter.MentorSystemManager.GetMentorData() + if mentorData:CheckCanUseChat(false) and not self.ChannelSet[ChatChannelType.Mentor] then + self.ChannelSet[ChatChannelType.Mentor] = true + end + + self.CurrentSelectedChannel = XDataCenter.ChatManager.GetCurrentChatChannelId() + + if isMain then + self.ImgBgMain:SetActive(true) + self.ImgBgCommon:SetActive(false) + else + self.ImgBgMain:SetActive(false) + self.ImgBgCommon:SetActive(true) + end + XRedPointManager.AddRedPointEvent(self.Content, self.OnCheckRedPoint, self, { XRedPointConditions.Types.CONDITION_RECEIVE_CHAT }, nil, false) +end + +function XUiChatServeMain:OnEnable() + self:Refresh() +end + +function XUiChatServeMain:OnDisable() + self:StopChannelTimer() + self:StopMsgTipsTimer() + self:RemoveTimer() + self:StopPanelEmojiTimer() +end + +function XUiChatServeMain:OnDestroy() + self:StopChannelTimer() + self:StopMsgTipsTimer() + self:RemoveTimer() + self:StopPanelEmojiTimer() + -- 重置特效冷却时间 + XDataCenter.ChatManager.SetEffectEnd(0) +end + +function XUiChatServeMain:CreateObject() + self.UiPanelChatContent = XUiPanelChatContent.New(self, self.PanelChatContent, self) + self.UiPanelEmoji = XUiPanelEmoji.New(self, self.PanelEmoji, self) + local clickCallBack = function(content) + self.UiPanelEmoji:Hide() + self:OnClickEmoji(content) + end + self.UiPanelEmoji:SetClickCallBack(clickCallBack) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiChatServeMain:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiChatServeMain:AutoInitUi() + self.PanelChatServe = self.Transform:Find("SafeAreaContentPane/PanelChatServe") + self.ImgBgleft = self.Transform:Find("SafeAreaContentPane/PanelChatServe/ImgBg/ImgBgleft") + self.PanelChatContent = self.Transform:Find("SafeAreaContentPane/PanelChatServe/PanelChatContent") + self.GridChatItem = self.Transform:Find("SafeAreaContentPane/PanelChatServe/PanelLeftToggle/Viewport/Content/GridChatItem") + self.PanelMsgTips = self.Transform:Find("SafeAreaContentPane/PanelChatServe/PanelMsgTips") + self.BtnPanelMsgTips = self.Transform:Find("SafeAreaContentPane/PanelChatServe/PanelMsgTips/BtnImgBg"):GetComponent("Button") + self.TxtMsgCount = self.Transform:Find("SafeAreaContentPane/PanelChatServe/PanelMsgTips/TxtMsgCount"):GetComponent("Text") + self.BtnSend = self.Transform:Find("SafeAreaContentPane/PanelChatServe/BtnContent/BtnSend"):GetComponent("Button") + self.BtnAdd = self.Transform:Find("SafeAreaContentPane/PanelChatServe/BtnContent/BtnAdd"):GetComponent("Button") + self.InputField = self.Transform:Find("SafeAreaContentPane/PanelChatServe/BtnContent/InF_Content"):GetComponent("InputField") + self.TxtEnter = self.Transform:Find("SafeAreaContentPane/PanelChatServe/BtnContent/InF_Content/TxtEnter"):GetComponent("Text") + self.PanelEmoji = self.Transform:Find("SafeAreaContentPane/PanelChatServe/BtnContent/PanelEmoji") + self.BtnBack = self.Transform:Find("SafeAreaContentPane/PanelChatServe/BtnContent/BtnBack"):GetComponent("Button") + self.BtnChat = self.Transform:Find("SafeAreaContentPane/PanelChatServe/BtnChat"):GetComponent("Button") + self.ImgBgMain = self.Transform:Find("SafeAreaContentPane/PanelChatServe/ImgBg/ImgBgMain").gameObject + self.ImgBgCommon = self.Transform:Find("SafeAreaContentPane/PanelChatServe/ImgBg/ImgBgCommon").gameObject +end + +function XUiChatServeMain:AutoAddListener() + self:RegisterClickEvent(self.BtnPanelMsgTips, self.OnBtnPanelMsgTipsClick) + self:RegisterClickEvent(self.BtnSend, self.OnBtnSendClick) + self:RegisterClickEvent(self.BtnAdd, self.OnBtnAddClick) + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnChat, self.OnBtnChatClick) +end +-- auto +-------------------------------Event beg------------------------------- +function XUiChatServeMain:OnGetEvents() + return { XEventId.EVENT_CHAT_RECEIVE_WORLD_MSG, XEventId.EVENT_CHAT_RECEIVE_ROOM_MSG, + XEventId.EVENT_PULL_SCROLLVIEW_END, XEventId.EVENT_CHAT_CHANNEL_CHANGED, + XEventId.EVENT_CHAT_SERVER_CHANNEL_CHANGED, XEventId.EVENT_GUILD_RECEIVE_CHAT, + XEventId.EVENT_CHAT_RECEIVE_MENTOR_MSG, XEventId.EVENT_CHAT_MATCH_EFFECT} +end + +function XUiChatServeMain:OnNotify(evt, ...) + if evt == XEventId.EVENT_CHAT_RECEIVE_WORLD_MSG then + self.UiPanelChatContent:ReceiveChatHandler(...) + elseif evt == XEventId.EVENT_CHAT_RECEIVE_ROOM_MSG then + self.UiPanelChatContent:ReceiveChatHandler(...) + elseif evt == XEventId.EVENT_GUILD_RECEIVE_CHAT then + self.UiPanelChatContent:ReceiveChatHandler(...) + elseif evt == XEventId.EVENT_CHAT_RECEIVE_MENTOR_MSG then + self.UiPanelChatContent:ReceiveChatHandler(...) + elseif evt == XEventId.EVENT_PULL_SCROLLVIEW_END then + self:ShowUnreadMsgCount(...) + elseif evt == XEventId.EVENT_CHAT_CHANNEL_CHANGED then + self:UpdateCurrentChannel() + elseif evt == XEventId.EVENT_CHAT_SERVER_CHANNEL_CHANGED then + -- 服务端分配聊天渠道 + if self.SelType == ChatChannelType.World then + local args = { ... } + local currentChannelId = args[1] + self:ShowChangeChatChannel(currentChannelId) + self:UpdateCurrentChannel() + + self:OnBtnChannelMaskClick() + end + elseif evt == XEventId.EVENT_CHAT_MATCH_EFFECT then + self:ShowKeywordEffect(...) + end +end +-------------------------------Event end------------------------------- +--------------------------------Btn Event beg----------------------------------- +function XUiChatServeMain:OnBtnPanelMsgTipsClick() + self.UiPanelChatContent.UnreadMsgCount = 0 + if IsMessageTipShow then + self.UiPanelChatContent:RefreshChatList(self.SelType) + end +end + +function XUiChatServeMain:OnBtnAddClick() + self.UiPanelEmoji:OpenOrClosePanel() +end + +function XUiChatServeMain:OnBtnChatClick(eventData) + self:OnBtnBackClick(eventData) +end + +function XUiChatServeMain:OnBtnSendClick() + if self.SelType == ChatChannelType.World and not XDataCenter.ChatManager.CheckCd() then + return + end + + if self.SelType == ChatChannelType.Guild and XDataCenter.GuildManager.IsJoinGuild() then + if XDataCenter.GuildManager.IsGuildTourist() then + XUiManager.TipMsg(CS.XTextManager.GetText("GuildTourstAccess")) + return + end + end + + local mentorData = XDataCenter.MentorSystemManager.GetMentorData() + if self.SelType == ChatChannelType.Mentor then + if not mentorData:CheckCanUseChat(true) then + return + end + end + local content = self.InputField.text + if string.IsNilOrEmpty(content) then + self.InputField.text = '' + return + end + + local sendChat = {} + sendChat.ChannelType = self.SelType + sendChat.MsgType = ChatMsgType.Normal + sendChat.Content = content + sendChat.TargetIds = { XPlayer.Id } + self.InputField.text = '' + + self:SendChat(sendChat) +end + +function XUiChatServeMain:OnClickEmoji(content) + local mentorData = XDataCenter.MentorSystemManager.GetMentorData() + if self.SelType == ChatChannelType.Mentor then + if not mentorData:CheckCanUseChat(true) then + return + end + end + + local sendChat = {} + sendChat.ChannelType = self.SelType + sendChat.MsgType = ChatMsgType.Emoji + sendChat.Content = content + sendChat.TargetIds = { XPlayer.Id } + XDataCenter.ChatManager.SendChat(sendChat) +end + +function XUiChatServeMain:SendChat(sendChat) + if not sendChat then + return + end + + --发送聊天信息 + local callBack = function(refreshCoolingTime) + self:RefreshCoolTime(refreshCoolingTime) + end + XDataCenter.ChatManager.SendChat(sendChat, callBack, true) +end + +function XUiChatServeMain:OnBtnBackClick() + --关闭聊天 + XLuaUiManager.SetMask(true) + self:PlayAnimation("AnimChatOut", function() + XLuaUiManager.SetMask(false) + self:Close() + XEventManager.DispatchEvent(XEventId.EVENT_CARD_REFRESH_WELFARE_BTN) + end) + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_CHAT_CLOSE) +end +--------------------------------Btn Event end----------------------------------- +function XUiChatServeMain:Refresh() + self:InitializationView() + self:InitTabBtnGroup() + self:RefreshMsgPanel() + self:UpdateCurrentChannel() +end + +function XUiChatServeMain:InitializationView() + --初始化界面 + self.PanelMsgTips.gameObject:SetActive(false) + + XLuaUiManager.SetMask(true) + self:PlayAnimation("AnimChatEnter", function() + XLuaUiManager.SetMask(false) + + if self.SelType == ChatChannelType.World then + self:ShowChangeChatChannel(self.CurrentSelectedChannel) + end + end) + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_CHAT_OPEN) +end + +function XUiChatServeMain:InitTabBtnGroup() + if self.TabGroup then + return + end + + self.TabGroup = {} + for i = 1, #ToggleType do + local uiButton + if i == 1 then + uiButton = self.BtnTabMatch + else + local itemGo = CS.UnityEngine.Object.Instantiate(self.BtnTabMatch.gameObject) + itemGo.transform:SetParent(self.ContentRT, false) + uiButton = itemGo.transform:GetComponent("XUiButton") + end + + local title = ToggleName[i] + local type = ToggleType[i] + local unlock = self.ChannelSet[type] + uiButton:SetName(title) + uiButton:SetDisable(not unlock) + -- 如果其他频道需要红点显示,更换判断条件即可 + if (type == ChatChannelType.Guild or type == ChatChannelType.Mentor) then + local needRedPoint = XDataCenter.ChatManager.CheckRedPointByType(type) + if type == ChatChannelType.Mentor then + local mentorData = XDataCenter.MentorSystemManager.GetMentorData() + needRedPoint = needRedPoint and mentorData:CheckCanUseChat(false) + end + uiButton:ShowReddot(needRedPoint) + end + table.insert(self.TabGroup, uiButton) + end + + self.Content:Init(self.TabGroup, function(tabIndex) self:OnClickTabCallBack(tabIndex) end) + self.Content:SelectIndex(self:TypeToTabIndex(self.SelType)) +end + +function XUiChatServeMain:TypeToTabIndex(type) + for i = 1, #ToggleType do + if ToggleType[i] == type then + return i + end + end + return 0 +end + +function XUiChatServeMain:OnClickTabCallBack(tabIndex) + local type = ToggleType[tabIndex] + if not type or not self.ChannelSet[type] then + if type == ChatChannelType.Room then + XUiManager.TipMsg(ChatRoomChannelNotOpen) + elseif type == ChatChannelType.Mentor then + local mentorData = XDataCenter.MentorSystemManager.GetMentorData() + mentorData:CheckCanUseChat(true) + end + return + end + -- 如果其他频道需要红点显示,更换判断条件即可 + if (type == ChatChannelType.Guild or type == ChatChannelType.Mentor) then + XDataCenter.ChatManager.SetChatRead(type) + local needRedPoint = XDataCenter.ChatManager.CheckRedPointByType(type) + self.TabGroup[tabIndex]:ShowReddot(needRedPoint) + end + self.SelType = type + self.UiPanelChatContent:RefreshChatList(type) + self.PanelChannelLabel.gameObject:SetActiveEx(self.SelType == ChatChannelType.World) + -- 部队频道清除cd + if self.SelType == ChatChannelType.Room then + self:SetInputFieldText() + self:SetInputInteractable(true) + self:RemoveTimer() + end +end + +function XUiChatServeMain:RefreshMsgPanel() + self.UiPanelChatContent:RefreshChatList(self.SelType) +end + +function XUiChatServeMain:RefreshCoolTime(refreshCoolingTime) + if refreshCoolingTime <= 0 then + return + end + + -- 部队不走冷却时间逻辑 + if self.SelType == ChatChannelType.Room then return end + + self:SetInputInteractable(false) + self:SetInputFieldText(CS.XTextManager.GetText("CountDownTips", refreshCoolingTime)) + + self:RemoveTimer() + + local refresh = function() + refreshCoolingTime = refreshCoolingTime - 1 + local stop = refreshCoolingTime <= 0 or XTool.UObjIsNil(self.InputField) + if stop then + self:SetInputFieldText() + self:SetInputInteractable(true) + self:RemoveTimer() + else + self:SetInputFieldText(CS.XTextManager.GetText("CountDownTips", refreshCoolingTime)) + end + end + self.timerId = XScheduleManager.ScheduleForever(refresh, XScheduleManager.SECOND) +end + +function XUiChatServeMain:SetInputInteractable(flag) + self.InputField.interactable = flag + self.BtnSend.interactable = flag + self.BtnAdd.interactable = flag +end + +function XUiChatServeMain:SetInputFieldText(text) + if not XTool.UObjIsNil(self.InputField) then + self.InputField.text = text or "" + end +end + +function XUiChatServeMain:RemoveTimer() + if self.timerId ~= -1 then + XScheduleManager.UnSchedule(self.timerId) + self.timerId = -1 + end +end + +function XUiChatServeMain:ShowUnreadMsgCount(count) + if XTool.UObjIsNil(self.GameObject) then + return + end + + if count <= 0 then + -- 如果计时器开着,直接return + self.UiPanelChatContent.UnreadMsgCount = 0 + if self.showMsgTimer and self.showMsgTimer ~= -1 then return end + self.PanelMsgTips.gameObject:SetActive(false) + else + -- 关计时器如果有 + self:StopMsgTipsTimer() + self.PanelMsgTips.gameObject:SetActive(true) + self.TxtMsgCount.text = CS.XTextManager.GetText("ChatWorldNewMsg", count) + IsMessageTipShow = true + end +end + +function XUiChatServeMain:ShowKeywordEffect(effectInfo) + local index = XDataCenter.ChatManager.WeightRandomSelect(effectInfo.Weight) + local path = effectInfo.Path[index] + self.BgEffect.gameObject:SetActiveEx(false) + if not string.IsNilOrEmpty(path) then + self.BgEffect.gameObject:SetActiveEx(true) + self.BgEffect.gameObject:LoadUiEffect(path) + end + -- 播放完特效后调用 + XDataCenter.ChatManager.SetEffectEnd() +end + +function XUiChatServeMain:ShowChangeChatChannel(channelId) + if XTool.UObjIsNil(self.GameObject) then + return + end + + self.PanelMsgTips.gameObject:SetActive(true) + self.TxtMsgCount.text = CS.XTextManager.GetText("ChannelChanged", channelId ~= XDataCenter.ChatManager.GetRecruitChannelId() and tostring(channelId) or CS.XTextManager.GetText("ChannelRecruitIdStr")) + -- 开计时器关闭 + self:StartMsgTipsTimer() +end + +-- 只刷新tog红点不刷新界面 +function XUiChatServeMain:OnCheckRedPoint() + for index, uiButton in ipairs(self.TabGroup) do + local type = ToggleType[index] + -- 如果其他频道需要红点显示,更换判断条件即可 + if self.SelType ~= type and (type == ChatChannelType.Guild or type == ChatChannelType.Mentor) then + local needRedPoint = XDataCenter.ChatManager.CheckRedPointByType(type) + uiButton:ShowReddot(needRedPoint) + end + end +end + +function XUiChatServeMain:StartMsgTipsTimer() + self:StopMsgTipsTimer() + self.showMsgTimer = XScheduleManager.ScheduleOnce(function() + self.PanelMsgTips.gameObject:SetActive(false) + IsMessageTipShow = false + end, FadeTime * 1000) +end + +function XUiChatServeMain:StopMsgTipsTimer() + if self.showMsgTimer and self.showMsgTimer ~= -1 then + XScheduleManager.UnSchedule(self.showMsgTimer) + self.showMsgTimer = -1 + end +end + +function XUiChatServeMain:SetChannelData() + XDataCenter.ChatManager.GetWorldChannelInfos(function(channelInfos) + -- 加载频道数据 + self.ChannelInfos = channelInfos + self:InitChannelInfos(self.ChannelInfos) + self.DynamicTableChannels:SetDataSource(self.ChannelInfos) + self.DynamicTableChannels:ReloadDataASync() + self:UpdateChannelTotalCount() + end) +end + +function XUiChatServeMain:InitChannelInfos(channelInfos) + local currentChannelId = XDataCenter.ChatManager.GetCurrentChatChannelId() + for _, info in pairs(channelInfos) do + info.IsSelected = currentChannelId == info.ChannelId + end +end + +function XUiChatServeMain:OnChannelInfoClick(index) + if self.ChannelInfos[index] then + self.CurrentSelectedChannel = self.ChannelInfos[index].ChannelId + end + for i = 1, #self.ChannelInfos do + local grid = self.DynamicTableChannels:GetGridByIndex(i) + local info = self.ChannelInfos[i] + info.IsSelected = i == index + if grid then + grid:SetChannelSelected(i == index) + end + end +end + +function XUiChatServeMain:OnBtnRoomClick() + self.PanelChannel.gameObject:SetActive(true) + + -- 1分钟之内不重复请求 + local now = XTime.GetServerNowTimestamp() + if now - XDataCenter.ChatManager.GetLastRequestChannelTime() <= 60 then + self.ChannelInfos = XDataCenter.ChatManager.GetAllChannelInfos() + self:InitChannelInfos(self.ChannelInfos) + self.DynamicTableChannels:SetDataSource(self.ChannelInfos) + self.DynamicTableChannels:ReloadDataASync() + self:UpdateChannelTotalCount() + else + self:SetChannelData() + XDataCenter.ChatManager.SetLastRequestChannelTime(now) + end + + self:StartChannelTimer() +end + +function XUiChatServeMain:StartChannelTimer() + self:StopChannelTimer() + self.channelTimer = XScheduleManager.ScheduleForever(function() + self:SetChannelData() + end, ChannelRefreshTime * 60 * 1000) +end + +function XUiChatServeMain:StopChannelTimer() + if self.channelTimer and self.channelTimer ~= -1 then + XScheduleManager.UnSchedule(self.channelTimer) + self.channelTimer = -1 + end +end + +-- 切换窗口 +function XUiChatServeMain:OnBtnChannelMaskClick() + self:StopChannelTimer() + self.PanelChannel.gameObject:SetActive(false) + +end + +function XUiChatServeMain:OnBtnChannelSureClick() + self:StopChannelTimer() + self.PanelChannel.gameObject:SetActive(false) + + if self.CurrentSelectedChannel then + XDataCenter.ChatManager.SelectChatChannel(self.CurrentSelectedChannel, function() + self:ShowChangeChatChannel(self.CurrentSelectedChannel) + self:UpdateCurrentChannel() + end, function() + -- 发生服务端房间数量变化(例如当前房间不存在了)重新请求 + self:SetChannelData() + end) + end +end + +function XUiChatServeMain:UpdateCurrentChannel() + local currentChannelId = XDataCenter.ChatManager.GetCurrentChatChannelId() + self.TxtRoomNumber.text = XDataCenter.ChatManager.GetRecruitChannelId() ~= currentChannelId and currentChannelId or CS.XTextManager.GetText("ChannelRecruitIdStr") +end + +function XUiChatServeMain:UpdateChannelTotalCount() + self.TextTotalCount.text = #XDataCenter.ChatManager.GetAllChannelInfos() +end + +function XUiChatServeMain:StopPanelEmojiTimer() + if self.UiPanelEmoji then + self.UiPanelEmoji:EmojiUnScheduleTime() + end +end + +return XUiChatServeMain \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChatServe/XUiPanelChatContent.lua b/Resources/Scripts/XUi/XUiChatServe/XUiPanelChatContent.lua new file mode 100644 index 00000000..829e4c7a --- /dev/null +++ b/Resources/Scripts/XUi/XUiChatServe/XUiPanelChatContent.lua @@ -0,0 +1,145 @@ +XUiPanelChatContent = XClass(nil, "XUiPanelChatContent") + +XUiPanelChatContent.WorldChatBoxType = { + OtherChatBox = 1, + OtherChatBoxEmoji = 2, + SelfChatBox = 3, + SelfChatBoxEmoji = 4 +} + +function XUiPanelChatContent:Ctor(rootUi, ui, parent) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Parent = parent + self:InitAutoScript() + self.DynamicListManager = XDynamicList.New(self.PanelChatView.transform, self) + self.DynamicListManager:SetReverse(true) + + self.PanelChatPools = XUiPanelChatPools.New(self.PanelChatPools) + self.PanelChatPools:InitData(self.DynamicListManager) + + self.UnreadMsgCount = 0 +end + + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelChatContent:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiPanelChatContent:AutoInitUi() + self.PanelChatView = self.Transform:Find("PanelChatView") + self.PanelChatPools = self.Transform:Find("PanelChatView/PanelChatPools") +end + +function XUiPanelChatContent:GetAutoKey(uiNode, eventName) + if not uiNode then + return + end + return eventName .. uiNode:GetHashCode() +end + +function XUiPanelChatContent:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then + return + end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiPanelChatContent:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiPanelChatContent:AutoAddListener() + self.AutoCreateListeners = {} +end +-- auto +--初始化聊天纪录 +function XUiPanelChatContent:RefreshChatList(channelType) + self.ChannelType = channelType + local msgData = XDataCenter.ChatManager.GetChatList(channelType) + self:InitWorldChatDynamicList(msgData) +end + +function XUiPanelChatContent:ReceiveChatHandler(chatData) + if XTool.UObjIsNil(self.GameObject) then + return + end + + --接收到消息 + if chatData == nil then + return + end + if self.ChannelType ~= chatData.ChannelType then + return + end + local tempTable = {} + table.insert(tempTable, chatData) + if self.DynamicListManager:GetBarValue() > 0.1 and chatData.SenderId ~= XPlayer.Id then + self.UnreadMsgCount = self.UnreadMsgCount + 1 + self.DynamicListManager:InsertData(tempTable, DLInsertDataDir.Head, false) + else + self.UnreadMsgCount = 0 + local msgData = XDataCenter.ChatManager.GetChatList(self.ChannelType) + self:InitWorldChatDynamicList(msgData) + end + XDataCenter.ChatManager.SetChatRead(self.ChannelType) + XDataCenter.ChatManager.KeywordMatch(self.ChannelType, chatData) + self.RootUi:ShowUnreadMsgCount(self.UnreadMsgCount) +end + +function XUiPanelChatContent:InitWorldChatDynamicList(msgData) + --初始化私聊动态列表数据 + msgData = msgData or {} + self.DynamicListManager:SetData(msgData, function(data, cb) + local poolName = nil + local ctor = nil + if data.MsgType == ChatMsgType.Normal and data.SenderId == XPlayer.Id then + poolName = "myMsg" + ctor = XUiPanelWorldChatMyMsgItem.New + elseif data.MsgType == ChatMsgType.Normal and data.SenderId ~= XPlayer.Id then + poolName = "ohterMsg" + ctor = XUiPanelWorldChatMyMsgItem.New + elseif data.MsgType == ChatMsgType.Emoji and data.SenderId == XPlayer.Id then + poolName = "myEmoji" + ctor = XUiPanelWorldChatMyMsgEmoji.New + elseif data.MsgType == ChatMsgType.Emoji and data.SenderId ~= XPlayer.Id then + poolName = "otherEmoji" + ctor = XUiPanelWorldChatMyMsgEmoji.New + elseif data.MsgType == ChatMsgType.System then + poolName = "system" + ctor = XUiPanelWorldChatSystemItem.New + elseif data.MsgType == ChatMsgType.SpringFestival and data.SenderId ~= XPlayer.Id then + poolName = "otherHelp" + ctor = XUiPanelWorldChatMyHelp.New + elseif data.MsgType == ChatMsgType.SpringFestival and data.SenderId == XPlayer.Id then + poolName = "myHelp" + ctor = XUiPanelWorldChatMyHelp.New + end + if cb and poolName and ctor then + local item = cb(poolName, ctor) + item.RootUi = self.RootUi + item:Refresh(data) + else + XLog.Error("------Init social worldChatData item is error!------") + end + end) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChatServe/XUiPanelChatPools.lua b/Resources/Scripts/XUi/XUiChatServe/XUiPanelChatPools.lua new file mode 100644 index 00000000..09a52a00 --- /dev/null +++ b/Resources/Scripts/XUi/XUiChatServe/XUiPanelChatPools.lua @@ -0,0 +1,68 @@ +XUiPanelChatPools = XClass(nil, "XUiPanelChatPools") + +function XUiPanelChatPools:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self:InitAutoScript() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelChatPools:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiPanelChatPools:AutoInitUi() + self.PanelWorldChatOhterMsgItem = self.Transform:Find("PanelWorldChatOhterMsgItem") + self.PanelWorldChatOhterEmojiItem = self.Transform:Find("PanelWorldChatOhterEmojiItem") + self.PanelWorldChatMyMsgItem = self.Transform:Find("PanelWorldChatMyMsgItem") + self.PanelWorldChatMyMsgEmoji = self.Transform:Find("PanelWorldChatMyMsgEmoji") + self.PanelWorldChatSystemItem = self.Transform:Find("PanelWorldChatPublic") + self.PanelWorldChatMyHelp = self.Transform:Find("PanelWorldChatMyHelp") + self.PanelWorldChatOtherHelp = self.Transform:Find("PanelWorldChatOtherHelp") +end + +function XUiPanelChatPools:GetAutoKey(uiNode,eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiPanelChatPools:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiPanelChatPools:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key],eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiPanelChatPools:AutoAddListener() + self.AutoCreateListeners = {} +end + +function XUiPanelChatPools:InitData(dynamicList) + self.GameObject:SetActive(false) + dynamicList:AddObjectPools("myMsg",self.PanelWorldChatMyMsgItem.gameObject) + dynamicList:AddObjectPools("ohterMsg",self.PanelWorldChatOhterMsgItem.gameObject) + dynamicList:AddObjectPools("myEmoji",self.PanelWorldChatMyMsgEmoji.gameObject) + dynamicList:AddObjectPools("otherEmoji",self.PanelWorldChatOhterEmojiItem.gameObject) + dynamicList:AddObjectPools("system", self.PanelWorldChatSystemItem.gameObject) + dynamicList:AddObjectPools("myHelp",self.PanelWorldChatMyHelp.gameObject) + dynamicList:AddObjectPools("otherHelp",self.PanelWorldChatOtherHelp.gameObject) +end diff --git a/Resources/Scripts/XUi/XUiChessPursuit/XChessPursuitCtrl.lua b/Resources/Scripts/XUi/XUiChessPursuit/XChessPursuitCtrl.lua new file mode 100644 index 00000000..a2cfb5a7 --- /dev/null +++ b/Resources/Scripts/XUi/XUiChessPursuit/XChessPursuitCtrl.lua @@ -0,0 +1,126 @@ +XChessPursuitCtrl = XChessPursuitCtrl or {} +local XChessPursuitSceneManager = require("XUi/XUiChessPursuit/XScene/XChessPursuitSceneManager") +local XChessPursuitCube = require("XUi/XUiChessPursuit/XScene/XChessPursuitCube") +local CSXChessPursuitDirection = CS.XChessPursuitDirection + +local CSXChessPursuitCtrlCom = nil +local ChessPursuitCubes = {} + +XChessPursuitCtrl.MAIN_UI_TYPE = { + STABLE = 1, --安稳期 + FIGHT_DEFAULT = 2, --斗争期-普通模式 + FIGHT_HARD = 3, --斗争期-炼狱模式 + SCENE = 4, --玩法场景 +} + +--场景UI的玩法阶段 +XChessPursuitCtrl.SCENE_UI_TYPE = { + BUZHEN = 1, --布阵阶段 + MY_ROUND = 2, --我的回合 + BOSS_ROUND = 3, --BOSS回合 +} + +--场景UI可选择的目标 +XChessPursuitCtrl.SCENE_SELECT_TARGET = { + NONE = 1, --什么都不可选 + TEAM = 2, --角色 + BOSS = 3, --怪物 + CUBE = 4, --方块 + DEFAULT = 5, --可任意选 +} + +--一场最多有几张卡 +XChessPursuitCtrl.CARD_MAX_COUNT = 3 + +--@region 场景相关 + +local function OnLoadCompleteCb(gameObject) + CSXChessPursuitCtrlCom = gameObject.transform:Find("Playmaker"):GetComponent("XChessPursuitCtrl") + assert(CSXChessPursuitCtrlCom, "节点Playmaker没有找到XChessPursuitCtrl组件") + + XChessPursuitCtrl.Init() +end + +local function OnLeaveCb() + CSXChessPursuitCtrlCom = nil + for i,v in ipairs(ChessPursuitCubes) do + v:Dispose() + end + ChessPursuitCubes = {} + XDataCenter.ChessPursuitManager.Clear() +end + +function XChessPursuitCtrl.Enter(mapId) + return XChessPursuitSceneManager.EnterScene(mapId, function(gameObject) + OnLoadCompleteCb(gameObject) + end, OnLeaveCb) +end + +function XChessPursuitCtrl.LeaveScene() + XChessPursuitSceneManager.LeaveScene() +end + +function XChessPursuitCtrl.PlayAnimationForScene(animName, cbFunc) + if CSXChessPursuitCtrlCom then + CSXChessPursuitCtrlCom:PlayAnimationForScene(animName, cbFunc) + end +end + +--@endregion + +function XChessPursuitCtrl.Init() + for i=0,CSXChessPursuitCtrlCom.Cubes.Count-1 do + local cube = CSXChessPursuitCtrlCom.Cubes[i] + table.insert(ChessPursuitCubes, XChessPursuitCube.New(cube)) + end +end + +function XChessPursuitCtrl.GetCSXChessPursuitCtrlCom() + return CSXChessPursuitCtrlCom +end + +function XChessPursuitCtrl.GetChessPursuitCubes() + return ChessPursuitCubes +end + +function XChessPursuitCtrl.SetSceneActive(isShow) + return XChessPursuitSceneManager.SetActive(isShow) +end + +--视点坐标-> UGUI坐标 (更准确但需要另外进行缩放) +function XChessPursuitCtrl.WorldToUIPosition(modelPosotion) + local sceneCamera = CSXChessPursuitCtrlCom.SceneCamera + local viewportPos = sceneCamera:WorldToViewportPoint(modelPosotion) + local position = CS.XUiManager.Instance.UiCamera:ViewportToWorldPoint(viewportPos) + + return position +end + +--视点坐标-> UGUI坐标 +function XChessPursuitCtrl.WorldToUILocaPosition(modelPosotion) + local sceneCamera = CSXChessPursuitCtrlCom.SceneCamera + local viewportPos = sceneCamera:WorldToViewportPoint(modelPosotion) + local uiDesignSize = XGlobalVar.UiDesignSize + + return CS.UnityEngine.Vector2((viewportPos.x - 0.5) * uiDesignSize.Width, (viewportPos.y - 0.5) * uiDesignSize.Height) +end + +--获取移动方向 +function XChessPursuitCtrl.GetMoveDirection(currentPos, nextPos) + local step = nextPos - currentPos + + -- STEP绝对值 > 1说明是从首走到尾或从尾走到首(前提是每次只走一步) + if step > 0 then + if math.abs(step) > 1 then + return CSXChessPursuitDirection.Back + else + return CSXChessPursuitDirection.Forward + end + elseif step < 0 then + if math.abs(step) > 1 then + return CSXChessPursuitDirection.Forward + else + return CSXChessPursuitDirection.Back + end + end +end diff --git a/Resources/Scripts/XUi/XUiChessPursuit/XData/XChessPursuitMapBoss.lua b/Resources/Scripts/XUi/XUiChessPursuit/XData/XChessPursuitMapBoss.lua new file mode 100644 index 00000000..5a0d01c6 --- /dev/null +++ b/Resources/Scripts/XUi/XUiChessPursuit/XData/XChessPursuitMapBoss.lua @@ -0,0 +1,53 @@ +--- 管理ChessPursuitMapBoss的服务端数据,只能通过Get方法获取内部数据 + +local XChessPursuitMapBoss = XClass(nil, "XChessPursuitMapBoss") +local CSXChessPursuitDirection = CS.XChessPursuitDirection + +function XChessPursuitMapBoss:Ctor(MapBoss) + self.ChessPursuitMapBoss = MapBoss + self.ChessPursuitBossTemplate = XChessPursuitConfig.GetChessPursuitBossTemplate(MapBoss.Id) +end + +function XChessPursuitMapBoss:GetId() + return self.ChessPursuitMapBoss.Id +end + +function XChessPursuitMapBoss:GetInitHp() + return self.ChessPursuitMapBoss.InitHp +end + +function XChessPursuitMapBoss:GetChessPursuitBossTemplate() + return self.ChessPursuitBossTemplate +end + +--战斗结束打BOSS最高可获得的分数 +function XChessPursuitMapBoss:GetBattleHurtMax() + return self.ChessPursuitMapBoss.BattleHurtMax +end + +--战斗结束我方血量最高可获得的分数 +function XChessPursuitMapBoss:GetSelfHpMax() + return self.ChessPursuitMapBoss.SelfHpMax +end + +--策划配置的最大血量 +function XChessPursuitMapBoss:GetMaxHpRatio() + return self.ChessPursuitMapBoss.SubBossMaxHp / self.ChessPursuitMapBoss.InitHp +end + +--策划配置的最小击杀次数 +function XChessPursuitMapBoss:GetMinBossBattleCount() + return self.ChessPursuitMapBoss.InitHp / self.ChessPursuitMapBoss.SubBossMaxHp +end + +--BOSS随机移动的最小步 +function XChessPursuitMapBoss:GetBossStepMin() + return self.ChessPursuitMapBoss.BossStepMin +end + +--BOSS随机移动的最小步 +function XChessPursuitMapBoss:GetBossStepMax() + return self.ChessPursuitMapBoss.BossStepMax +end + +return XChessPursuitMapBoss \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChessPursuit/XData/XChessPursuitMapDb.lua b/Resources/Scripts/XUi/XUiChessPursuit/XData/XChessPursuitMapDb.lua new file mode 100644 index 00000000..66f50d30 --- /dev/null +++ b/Resources/Scripts/XUi/XUiChessPursuit/XData/XChessPursuitMapDb.lua @@ -0,0 +1,397 @@ +--- 管理ChessPursuitMapDb的服务端数据,只能通过Get方法获取内部数据 + +local XChessPursuitMapDb = XClass(nil, "XChessPursuitMapDb") +local CSXChessPursuitDirection = CS.XChessPursuitDirection + +-- 服务端没发mapDb的情况发,可传mapId会创建一个虚拟对象 +function XChessPursuitMapDb:Ctor(mapDbOrMapId) + local mapDb + if (type(mapDbOrMapId) == "number") then + self.Virtual = true + local chessPursuitMapTemplate = XChessPursuitConfig.GetChessPursuitMapTemplate(mapDbOrMapId) + local chessPursuitMapBoss = XDataCenter.ChessPursuitManager.GetChessPursuitMapBoss(chessPursuitMapTemplate.BossId) + mapDb = { + Id = mapDbOrMapId, + WinForBattleCount = 0, + BossBattleCount = 0, + IsTakeReward = false, + BossHp = chessPursuitMapBoss and chessPursuitMapBoss:GetInitHp() or 0, + Coin = 0, + BuyedCardId = {}, + } + else + self.Virtual = false + mapDb = mapDbOrMapId + end + + self.ChessPursuitMapDb = mapDb + self.ChessPursuitMapTemplate = XChessPursuitConfig.GetChessPursuitMapTemplate(self.ChessPursuitMapDb.Id) + + self:InitBuyedCardIdDic() +end + +function XChessPursuitMapDb:InitBuyedCardIdDic() + self.BuyedCardIdDic = {} + for _, buyedCardId in ipairs(self.ChessPursuitMapDb.BuyedCardId) do + self.BuyedCardIdDic[buyedCardId] = true + end +end + +function XChessPursuitMapDb:GetMapId() + return self.ChessPursuitMapDb.Id +end + +function XChessPursuitMapDb:GetVirtual() + return self.Virtual +end + +-- BOSS当前的位置 +function XChessPursuitMapDb:GetBossPos() + return self.ChessPursuitMapDb.BossPos +end + +function XChessPursuitMapDb:GetBossMoveDirection() + if self.ChessPursuitMapDb.BossMoveDirection == 1 then + return CSXChessPursuitDirection.Forward + elseif self.ChessPursuitMapDb.BossMoveDirection == -1 then + return CSXChessPursuitDirection.Back + end +end + +function XChessPursuitMapDb:GetChessPursuitMapTemplate() + return self.ChessPursuitMapTemplate +end + +--需要先布阵 +function XChessPursuitMapDb:NeedBuZhen() + if XTool.IsTableEmpty(self.ChessPursuitMapDb.GridTeamDb) then + return true + end + + if #self.ChessPursuitMapDb.GridTeamDb < 1 then + return true + else + return false + end +end + +--排行榜奖励可领取 +function XChessPursuitMapDb:IsTakeReward() + return self.ChessPursuitMapDb.IsTakeReward +end + +--击杀BOSS历史最少的战斗次数 +function XChessPursuitMapDb:GetWinForBattleCount() + return self.ChessPursuitMapDb.WinForBattleCount +end + +--当前与BOSS战斗的次数 +function XChessPursuitMapDb:GetBossBattleCount() + return self.ChessPursuitMapDb.BossBattleCount +end + +--货币 +function XChessPursuitMapDb:GetCoin() + return self.ChessPursuitMapDb.Coin +end + +--BOSS当前状态是否被击杀 +function XChessPursuitMapDb:IsClear() + return self.ChessPursuitMapDb.BossHp <= 0 +end + +--BOSS曾经被击杀过,不管当前状态 +function XChessPursuitMapDb:IsKill() + return self.ChessPursuitMapDb.WinForBattleCount > 0 +end + +function XChessPursuitMapDb:GetGridTeamDb() + return self.ChessPursuitMapDb.GridTeamDb +end + +function XChessPursuitMapDb:SetGridTeamDb(gridTeamDb) + self.ChessPursuitMapDb.GridTeamDb = gridTeamDb +end + +function XChessPursuitMapDb:GetBossHp() + return self.ChessPursuitMapDb.BossHp +end + +function XChessPursuitMapDb:ChangeGridTeamDb(data) + for i, gridTeamDb in ipairs(self.ChessPursuitMapDb.GridTeamDb) do + if gridTeamDb.Id == data.GridId then + gridTeamDb.FirstFightPos = data.FirstFightPos + gridTeamDb.CaptainPos = data.CaptainPos + gridTeamDb.CardIds = data.CardIds + gridTeamDb.RobotIds = data.RobotIds + return + end + end +end + +function XChessPursuitMapDb:GetGridTeamDbByGridId(teamGridIndex) + local gridId = self.ChessPursuitMapTemplate.TeamGrid[teamGridIndex] + + for i,gridTeamDb in ipairs(self.ChessPursuitMapDb.GridTeamDb) do + if gridTeamDb.Id == gridId then + return gridTeamDb + end + end +end + +--对boss造成最高伤害记录 +function XChessPursuitMapDb:GetHurtBossByGridId(teamGridIndex) + local gridTeamDb = self:GetGridTeamDbByGridId(teamGridIndex) + + if gridTeamDb then + return gridTeamDb.HurtBoss or 0 + else + return 0 + end +end + +function XChessPursuitMapDb:GetGridTeamCaptainCharacterIdIdByGridId(teamGridIndex) + local teamCharacterIds = self:GetTeamCharacterIds(teamGridIndex) + + if next(teamCharacterIds) then + local gridTeamDb = self:GetGridTeamDbByGridId(teamGridIndex) + return teamCharacterIds[gridTeamDb.CaptainPos] + end +end + +function XChessPursuitMapDb:GetTeamCharacterIds(teamGridIndex, isNotConverRobotId) + local gridTeamDb = self:GetGridTeamDbByGridId(teamGridIndex) + local tl = {} + if not gridTeamDb then + return tl + end + + for i, characterId in ipairs(gridTeamDb.CardIds) do + -- 0即可能没有上阵或在RobotIds + if characterId ~= 0 then + tl[i] = characterId + else + local robotId = gridTeamDb.RobotIds[i] + tl[i] = isNotConverRobotId and robotId or XRobotManager.GetCharacterId(robotId) + end + end + + return tl +end + +function XChessPursuitMapDb:GetRewardState() + local taskId = self.ChessPursuitMapTemplate.TaskId + local taskData = XDataCenter.TaskManager.GetTaskDataById(taskId) + if taskData then + if taskData.State then + if taskData.State == XDataCenter.TaskManager.TaskState.Achieved then --未领奖励 + return XDataCenter.TaskManager.TaskState.Achieved + elseif taskData.State == XDataCenter.TaskManager.TaskState.Finish then --已领取奖励 + return XDataCenter.TaskManager.TaskState.Finish + else + return XDataCenter.TaskManager.TaskState.InActive --不显示按钮 + end + else + return XDataCenter.TaskManager.TaskState.InActive --不显示按钮 + end + end +end + +--手上有的卡 +function XChessPursuitMapDb:GetBuyedCards() + -- int Id; + -- int CardCfgId; + -- int KeepCount; + return self.ChessPursuitMapDb.BuyedCards +end + +function XChessPursuitMapDb:GetGridCardDb() + return self.ChessPursuitMapDb.GridCardDb +end + +function XChessPursuitMapDb:GetBossCardDb() + return self.ChessPursuitMapDb.BossCardDb +end + + +function XChessPursuitMapDb:GetHaveCardsCount() + local buyedCards = self:GetBuyedCards() + return buyedCards and #buyedCards or 0 +end + +--卡牌是否已购买过 +function XChessPursuitMapDb:IsBuyedCard(id) + if id and self.BuyedCardIdDic[id] then + return true + end + return false +end + +--是否可以领取奖励 +function XChessPursuitMapDb:IsCanTakeReward() + local taskState = self:GetRewardState() + + if self:IsKill() then + if taskState == XDataCenter.TaskManager.TaskState.Achieved then + return true + else + return false + end + else + return false + end +end + +--@region !!!以下函数只可以由XChessPursuitManager里的函数调用 +function XChessPursuitMapDb:SetGridTeamDbHurtBoss(teamGridIndex, value) + local gridTeamDb = self:GetGridTeamDbByGridId(teamGridIndex) + if gridTeamDb then + gridTeamDb.HurtBoss = value + end +end + +function XChessPursuitMapDb:SetBossPos(value) + self.ChessPursuitMapDb.BossPos = value +end + +function XChessPursuitMapDb:SubBossHp(value) + self:SetBossHp(self.ChessPursuitMapDb.BossHp - value) +end + +function XChessPursuitMapDb:SetBossHp(value) + self.ChessPursuitMapDb.BossHp = value + if self:GetBossHp() <= 0 then + if self.ChessPursuitMapDb.WinForBattleCount == 0 or self.ChessPursuitMapDb.WinForBattleCount > self.ChessPursuitMapDb.BossBattleCount then + self.ChessPursuitMapDb.WinForBattleCount = self.ChessPursuitMapDb.BossBattleCount + end + end +end + +function XChessPursuitMapDb:AddBuyedCards(values) + for i,v in ipairs(values) do + table.insert(self.ChessPursuitMapDb.BuyedCards, v) + end +end + +function XChessPursuitMapDb:SetCoin(value) + self.ChessPursuitMapDb.Coin = value +end + +--减掉消耗了的货币 +function XChessPursuitMapDb:SubCoin(subCoin) + self.ChessPursuitMapDb.Coin = self.ChessPursuitMapDb.Coin - subCoin +end + +function XChessPursuitMapDb:RemoveCardsByUsedToGrid(usedToGrid) + for gridId, xChessPursuitCardDbList in pairs(usedToGrid) do + for _,xChessPursuitCardDb in ipairs(xChessPursuitCardDbList) do + for i=#self.ChessPursuitMapDb.BuyedCards, 1, -1 do + if xChessPursuitCardDb.Id == self.ChessPursuitMapDb.BuyedCards[i].Id then + table.remove(self.ChessPursuitMapDb.BuyedCards, i) + break + end + end + end + end +end + +function XChessPursuitMapDb:RemoveCardsByUesdToBoss(uesdToBoss) + for gridId, xChessPursuitCardDb in pairs(uesdToBoss) do + for i=#self.ChessPursuitMapDb.BuyedCards, 1, -1 do + if xChessPursuitCardDb.Id == self.ChessPursuitMapDb.BuyedCards[i].Id then + table.remove(self.ChessPursuitMapDb.BuyedCards, i) + break + end + end + end +end + +function XChessPursuitMapDb:AddGridCardDb(usedToGrid) + for gridId, xChessPursuitCardDbList in pairs(usedToGrid) do + for _,xChessPursuitCardDb in ipairs(xChessPursuitCardDbList) do + local isInsert = false + for i,v in ipairs(self.ChessPursuitMapDb.GridCardDb) do + if v.Id == gridId then + table.insert(v.Cards, xChessPursuitCardDb) + isInsert = true + break + end + end + if not isInsert then + table.insert(self.ChessPursuitMapDb.GridCardDb, { + Id = gridId, + Cards = {xChessPursuitCardDb} + }) + end + end + end +end + +function XChessPursuitMapDb:AddBossCardDb(uesdToBoss) + for i,v in ipairs(uesdToBoss) do + table.insert(self.ChessPursuitMapDb.BossCardDb, v) + end +end + +function XChessPursuitMapDb:RefreshKeepCount(cardId, keepCount) + for i,v in ipairs(self.ChessPursuitMapDb.GridCardDb) do + for i,xChessPursuitCardDb in ipairs(v.Cards) do + if xChessPursuitCardDb.Id == cardId then + if keepCount == 0 then + local cfg = XChessPursuitConfig.GetChessPursuitCardTemplate(xChessPursuitCardDb.CardCfgId) + local cfgEffect = XChessPursuitConfig.GetChessPursuitCardEffectTemplate(cfg.EffectId) + --keepType 0 是永久效果 + if cfgEffect.KeepType ~= 0 then + table.remove(v.Cards, i) + end + else + xChessPursuitCardDb.KeepCount = keepCount + end + break + end + end + end + + for i,xChessPursuitCardDb in ipairs(self.ChessPursuitMapDb.BossCardDb) do + if xChessPursuitCardDb.Id == cardId then + if keepCount == 0 then + local cfg = XChessPursuitConfig.GetChessPursuitCardTemplate(xChessPursuitCardDb.CardCfgId) + local cfgEffect = XChessPursuitConfig.GetChessPursuitCardEffectTemplate(cfg.EffectId) + --keepType 0 是永久效果 + if cfgEffect.KeepType ~= 0 then + table.remove(self.ChessPursuitMapDb.BossCardDb, i) + end + else + xChessPursuitCardDb.KeepCount = keepCount + end + break + end + end +end + +function XChessPursuitMapDb:SetBossMoveDirection(value) + if value and value ~= 0 then + self.ChessPursuitMapDb.BossMoveDirection = value + end +end + +function XChessPursuitMapDb:AddBossBattleCount(value) + self.ChessPursuitMapDb.BossBattleCount = self.ChessPursuitMapDb.BossBattleCount + value +end + +--保存已购买的卡牌id +function XChessPursuitMapDb:AddBuyedCardId(cardIds) + for _, v in ipairs(cardIds) do + self.BuyedCardIdDic[v.CardCfgId] = true + end +end + +--保存已购买的卡牌id +function XChessPursuitMapDb:AddBuyedCardId(cardIds) + for _, v in ipairs(cardIds) do + self.BuyedCardIdDic[v.CardCfgId] = true + end +end +--@endregion + +return XChessPursuitMapDb \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChessPursuit/XData/XChessPursuitRank.lua b/Resources/Scripts/XUi/XUiChessPursuit/XData/XChessPursuitRank.lua new file mode 100644 index 00000000..2fed41e0 --- /dev/null +++ b/Resources/Scripts/XUi/XUiChessPursuit/XData/XChessPursuitRank.lua @@ -0,0 +1,51 @@ +local XChessPursuitRankPlayer = require("XUi/XUiChessPursuit/XData/XChessPursuitRankPlayer") +local XChessPursuitRankScore = require("XUi/XUiChessPursuit/XData/XChessPursuitRankScore") + +local type = type +local Default = { + PlayerList = {}, + ScoreList = {}, +} + +local XChessPursuitRank = XClass(nil, "XChessPursuitRank") + +function XChessPursuitRank:Ctor(groupId) + for key, value in pairs(Default) do + if type(value) == "table" then + self[key] = {} + else + self[key] = value + end + end + self.GroupId = groupId +end + +function XChessPursuitRank:UpdateData(data) + if not data then return end + self:UpdatePlayerList(data.PlayerList) + self:UpdateScoreList(data.ScoreList) +end + +function XChessPursuitRank:UpdatePlayerList(playerList) + self.PlayerList = {} + for i, v in ipairs(playerList) do + self.PlayerList[i] = XChessPursuitRankPlayer.New(v) + end +end + +function XChessPursuitRank:UpdateScoreList(scoreList) + self.ScoreList = {} + for i, v in ipairs(scoreList) do + self.ScoreList[i] = XChessPursuitRankScore.New(v) + end +end + +function XChessPursuitRank:GetPlayerList() + return self.PlayerList +end + +function XChessPursuitRank:ScoreList() + return self.ScoreList +end + +return XChessPursuitRank \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChessPursuit/XData/XChessPursuitRankGrid.lua b/Resources/Scripts/XUi/XUiChessPursuit/XData/XChessPursuitRankGrid.lua new file mode 100644 index 00000000..ba3de867 --- /dev/null +++ b/Resources/Scripts/XUi/XUiChessPursuit/XData/XChessPursuitRankGrid.lua @@ -0,0 +1,92 @@ +local type = type +local tableInsert = table.insert +local tableSort = table.sort + +local Default = { + Grid = 0, --布阵格id + Hurt = 0, + CharacterIds = {}, + CharacterLiberateLvs = {}, + RobotIds = {}, + UsedCardIds = {}, +} + +local XChessPursuitRankGrid = XClass(nil, "XChessPursuitRankGrid") + +function XChessPursuitRankGrid:Ctor(data) + for key, value in pairs(Default) do + if type(value) == "table" then + self[key] = {} + else + self[key] = value + end + end + self:UpdateData(data) +end + +function XChessPursuitRankGrid:UpdateData(data) + if not data then + return + end + self.Hurt = data.Hurt + self.Grid = data.Grid + self.CharacterIds = data.CharacterIds + self.CharacterLiberateLvs = data.CharacterLiberateLvs + self.RobotIds = data.RobotIds + self.UsedCardIds = data.UsedCardIds + + self:UpdateCharacterIdToLiberateLvDic() +end + +function XChessPursuitRankGrid:UpdateCharacterIdToLiberateLvDic() + self.CharacterIdToLiberateLvsDic = {} + for index, characterId in ipairs(self.CharacterIds) do + if self.CharacterLiberateLvs[index] then + self.CharacterIdToLiberateLvsDic[characterId] = self.CharacterLiberateLvs[index] + end + end +end + +function XChessPursuitRankGrid:GetCharacterIdList(gridTeamIndex, playerId) + local characterIdList = {} + local isHaveCaptain = false + for _, characterId in ipairs(self.CharacterIds) do + if characterId > 0 then + if not isHaveCaptain and XDataCenter.ChessPursuitManager.IsRankCaptain(characterId) then + isHaveCaptain = true + tableInsert(characterIdList, characterId, 1) + else + tableInsert(characterIdList, characterId) + end + end + end + for _, robotId in ipairs(self.RobotIds) do + if robotId > 0 then + if not isHaveCaptain and XDataCenter.ChessPursuitManager.IsRankCaptain(characterId) then + isHaveCaptain = true + tableInsert(characterIdList, robotId, 1) + else + tableInsert(characterIdList, robotId) + end + end + end + return characterIdList +end + +function XChessPursuitRankGrid:GetHurt() + return self.Hurt +end + +function XChessPursuitRankGrid:GetUsedCardIds() + return self.UsedCardIds +end + +function XChessPursuitRankGrid:GetGrid() + return self.Grid +end + +function XChessPursuitRankGrid:GetCharacterLiberateLv(characterId) + return characterId and self.CharacterIdToLiberateLvsDic[characterId] or 0 +end + +return XChessPursuitRankGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChessPursuit/XData/XChessPursuitRankPlayer.lua b/Resources/Scripts/XUi/XUiChessPursuit/XData/XChessPursuitRankPlayer.lua new file mode 100644 index 00000000..2cbf566b --- /dev/null +++ b/Resources/Scripts/XUi/XUiChessPursuit/XData/XChessPursuitRankPlayer.lua @@ -0,0 +1,80 @@ +local type = type + +local Default = { + PlayerId = 0, + Name = "", + Head = 0, --头像 + Frame = 0, --头像框 + Level = 0, + Sign = "", --签名 + Score = 0, + CaptainIdList = {}, +} + +local XChessPursuitRankPlayer = XClass(nil, "XChessPursuitRankPlayer") + +function XChessPursuitRankPlayer:Ctor() + for key, value in pairs(Default) do + if type(value) == "table" then + self[key] = {} + else + self[key] = value + end + end +end + +function XChessPursuitRankPlayer:UpdateData(data) + if not data then + return + end + self.PlayerId = data.PlayerId + self.Name = data.Name + self.Head = data.Head + self.Frame = data.Frame + self.Level = data.Level + self.Sign = data.Sign + self.Score = data.Score + self.CaptainIdList = data.CaptainIdList +end + +function XChessPursuitRankPlayer:GetPlayerId() + return self.PlayerId +end + +function XChessPursuitRankPlayer:GetScore() + return self.Score +end + +function XChessPursuitRankPlayer:GetCaptainIdList() + return self.CaptainIdList +end + +function XChessPursuitRankPlayer:GetName() + return self.Name +end + +function XChessPursuitRankPlayer:GetHead() + return self.Head +end + +function XChessPursuitRankPlayer:GetFrame() + return self.Frame +end + +function XChessPursuitRankPlayer:GetLevel() + return self.Level +end + +function XChessPursuitRankPlayer:GetSign() + return self.Sign +end + +function XChessPursuitRankPlayer:IsCurPlayer(playerId) + return self.PlayerId == playerId +end + +function XChessPursuitRankPlayer:IsCaptain(index, characterId) + return self.CaptainIdList and self.CaptainIdList[index] == characterId +end + +return XChessPursuitRankPlayer \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChessPursuit/XData/XChessPursuitRankScore.lua b/Resources/Scripts/XUi/XUiChessPursuit/XData/XChessPursuitRankScore.lua new file mode 100644 index 00000000..43a8f2ad --- /dev/null +++ b/Resources/Scripts/XUi/XUiChessPursuit/XData/XChessPursuitRankScore.lua @@ -0,0 +1,37 @@ +local type = type + +local Default = { + Score = 0, + Count = 0, +} + +local XChessPursuitRankScore = XClass(nil, "XChessPursuitRankScore") + +function XChessPursuitRankScore:Ctor(data) + for key, value in pairs(Default) do + if type(value) == "table" then + self[key] = {} + else + self[key] = value + end + end + self:UpdateData(data) +end + +function XChessPursuitRankScore:UpdateData(data) + if not data then + return + end + self.Score = data.Score + self.Count = data.Count +end + +function XChessPursuitRankScore:GetScore() + return self.Score +end + +function XChessPursuitRankScore:GetCount() + return self.Count +end + +return XChessPursuitRankScore \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChessPursuit/XData/XChessPursuitSyncAction.lua b/Resources/Scripts/XUi/XUiChessPursuit/XData/XChessPursuitSyncAction.lua new file mode 100644 index 00000000..e4287e99 --- /dev/null +++ b/Resources/Scripts/XUi/XUiChessPursuit/XData/XChessPursuitSyncAction.lua @@ -0,0 +1,98 @@ +local XChessPursuitSyncAction = XClass(nil, "XChessPursuitSyncAction") + +function XChessPursuitSyncAction:Ctor(activeData) + self.ActiveData = activeData +end + +function XChessPursuitSyncAction:GetType() + return self.ActiveData.Type +end + +function XChessPursuitSyncAction:GetCardId() + return self.ActiveData.CardId +end + +function XChessPursuitSyncAction:GetCardEffectId() + return self.ActiveData.CardEffectId +end + +function XChessPursuitSyncAction:GetCoin() + return self.ActiveData.Coin +end + +--剩余持续次数 +function XChessPursuitSyncAction:GetKeepCount() + return self.ActiveData.KeepCount +end + +--Boss需要移动到的位置 +function XChessPursuitSyncAction:GetBoosPos() + return self.ActiveData.BoosPos +end + +--战斗完对Boss造成的伤害 +function XChessPursuitSyncAction:GetBattleHurt() + return self.ActiveData.BattleHurt +end + +--战斗完对Boss造成的伤害积分 +function XChessPursuitSyncAction:GetBattleScore() + return self.ActiveData.BattleScore +end + +--战斗完我方血量的积分 +function XChessPursuitSyncAction:GetSelfScore() + return self.ActiveData.SelfScore +end + +--战斗完我方血量的百分比(整数) +function XChessPursuitSyncAction:GetSelfHp() + return self.ActiveData.SelfHp +end + +--战斗完的总积分 +function XChessPursuitSyncAction:GetSumScore() + return self.ActiveData.BattleScore + self.ActiveData.SelfScore +end + +--卡牌播放完效果之后,BossHP +function XChessPursuitSyncAction:GetBossHp() + return self.ActiveData.BossHp +end + +--产生的FightEvent +function XChessPursuitSyncAction:GetFightEvents() + return self.ActiveData.FightEvents +end + +--boss身上加卡 +function XChessPursuitSyncAction:GetAddBossCard() + return self.ActiveData.AddBossCard +end + +--战斗的持续时间 +function XChessPursuitSyncAction:GetLeftTime() + return math.abs(self.ActiveData.LeftTime) +end + +--Boss朝向 +function XChessPursuitSyncAction:GetBossMoveDirection() + return self.ActiveData.BossMoveDirection +end + +--战斗是否胜利 +function XChessPursuitSyncAction:GetIsWin() + return self.ActiveData.IsWin +end + +--Boss伤害记录 +function XChessPursuitSyncAction:GetHurtBoss() + return self.ActiveData.HurtBoss +end + +--强退 +function XChessPursuitSyncAction:GetIsForceExit() + return self.ActiveData.IsForceExit +end + +return XChessPursuitSyncAction \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChessPursuit/XData/XChessPursuitSyncActionQueue.lua b/Resources/Scripts/XUi/XUiChessPursuit/XData/XChessPursuitSyncActionQueue.lua new file mode 100644 index 00000000..a91668b1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiChessPursuit/XData/XChessPursuitSyncActionQueue.lua @@ -0,0 +1,43 @@ +--- 管理ChessPursuitSyncActionQueue 玩法的事件处理函数的服务端数据,只能通过Get方法获取内部数据 + +local XChessPursuitSyncActionQueue = XClass(nil, "XChessPursuitSyncActionQueue") +local XChessPursuitSyncAction = require("XUi/XUiChessPursuit/XData/XChessPursuitSyncAction") +local CSXChessPursuitDirection = CS.XChessPursuitDirection + +function XChessPursuitSyncActionQueue:Ctor() + self.Actions = {} +end + +function XChessPursuitSyncActionQueue:Push(actions) + if actions then + for i,v in ipairs(actions) do + table.insert(self.Actions, XChessPursuitSyncAction.New(v)) + XLog.Debug(">>>>>>>>>>>>>>>>>>>>>>>>>> 队列新增行动类型:" .. v.Type) + end + end +end + +function XChessPursuitSyncActionQueue:Pop() + if next(self.Actions) then + local action = self.Actions[1] + table.remove(self.Actions, 1) + + --弹出时,更新服务端的缓存数据 + XDataCenter.ChessPursuitManager.RefreshDataByAction(action) + return action + end +end + +function XChessPursuitSyncActionQueue:Clear() + self.Actions = {} +end + +function XChessPursuitSyncActionQueue:GetCount() + return #self.Actions +end + +function XChessPursuitSyncActionQueue:GetTopActions() + return self.Actions[1] +end + +return XChessPursuitSyncActionQueue \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChessPursuit/XScene/XChessPursuitBoss.lua b/Resources/Scripts/XUi/XUiChessPursuit/XScene/XChessPursuitBoss.lua new file mode 100644 index 00000000..54ad3902 --- /dev/null +++ b/Resources/Scripts/XUi/XUiChessPursuit/XScene/XChessPursuitBoss.lua @@ -0,0 +1,44 @@ +local XChessPursuitModel = require("XUi/XUiChessPursuit/XScene/XChessPursuitModel") +local XChessPursuitBoss = XClass(XChessPursuitModel, "XChessPursuitBoss") + +function XChessPursuitBoss:Ctor() +end + +function XChessPursuitBoss:LoadBoss(id, parent, cb) + if self.GameObject then + return + end + + local config = XChessPursuitConfig.GetChessPursuitBossTemplate(id) + + self.Resource = CS.XResourceManager.Load(config.Perfab) + if not self.Resource.Asset then + XLog.Error("XChessPursuitBoss LoadBoss error, instantiate error, name: " .. config.Perfab) + return + end + + self.GameObject = CS.UnityEngine.Object.Instantiate(self.Resource.Asset, parent) + self.Transform = self.GameObject.transform + self.CSXChessPursuitModel = self.GameObject:AddComponent(typeof(CS.XChessPursuitBoss)) + self.CSXChessPursuitModel:SetXChessPursuitCtrl(XChessPursuitCtrl.GetCSXChessPursuitCtrlCom()) + + self.Collider = self.GameObject:GetComponent(typeof(CS.UnityEngine.Collider)) +end + +function XChessPursuitBoss:Dispose() + if self.GameObject then + self.CSXChessPursuitModel:Dispose() + CS.UnityEngine.GameObject.Destroy(self.GameObject) + self.GameObject = nil + end + + self.Func = nil +end + +function XChessPursuitBoss:SetColliderActive(isActive) + if self.Collider then + self.Collider.enabled = isActive + end +end + +return XChessPursuitBoss \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChessPursuit/XScene/XChessPursuitCube.lua b/Resources/Scripts/XUi/XUiChessPursuit/XScene/XChessPursuitCube.lua new file mode 100644 index 00000000..ff9abef9 --- /dev/null +++ b/Resources/Scripts/XUi/XUiChessPursuit/XScene/XChessPursuitCube.lua @@ -0,0 +1,16 @@ +local XChessPursuitModel = require("XUi/XUiChessPursuit/XScene/XChessPursuitModel") +local XChessPursuitCube = XClass(XChessPursuitModel, "XChessPursuitCube") + +function XChessPursuitCube:Ctor(gameObject) + self.GameObject = gameObject + self.Transform = gameObject.transform + self.CSXChessPursuitModel = gameObject:GetComponent(typeof(CS.XChessPursuitCube)) + self.CSXChessPursuitModel:SetXChessPursuitCtrl(XChessPursuitCtrl.GetCSXChessPursuitCtrlCom()) +end + +function XChessPursuitCube:Dispose() + self.Func = nil + self.CSXChessPursuitModel:Dispose() +end + +return XChessPursuitCube \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChessPursuit/XScene/XChessPursuitModel.lua b/Resources/Scripts/XUi/XUiChessPursuit/XScene/XChessPursuitModel.lua new file mode 100644 index 00000000..51241066 --- /dev/null +++ b/Resources/Scripts/XUi/XUiChessPursuit/XScene/XChessPursuitModel.lua @@ -0,0 +1,55 @@ +local XChessPursuitModel = XClass(nil, "XChessPursuitModel") + +function XChessPursuitModel:AddClick(func) + --避免重复注册 + if self.Func then + return + end + + self.Func = func + self.CSXChessPursuitModel:AddPointerClickListener(function() + func() + end) +end + +function XChessPursuitModel:GetCSXChessPursuitModel() + return self.CSXChessPursuitModel +end + +-- 设置半透明+高亮,并且不可点击 +function XChessPursuitModel:SetTransparent() + if self.GameObject then + self.CSXChessPursuitModel:SetTransparent(0.5) + self.CSXChessPursuitModel:EnableClick(false) + end +end + +function XChessPursuitModel:HighLight() + if self.GameObject then + self.CSXChessPursuitModel:HighLight() + self.CSXChessPursuitModel:EnableClick(true) + end +end + +function XChessPursuitModel:EnableClick() + if self.GameObject then + self.CSXChessPursuitModel:Revert() + self.CSXChessPursuitModel:EnableClick(true) + end +end + +function XChessPursuitModel:None() + if self.GameObject then + self.CSXChessPursuitModel:Revert() + self.CSXChessPursuitModel:EnableClick(false) + end +end + +function XChessPursuitModel:Default() + if self.GameObject then + self.CSXChessPursuitModel:Revert() + self.CSXChessPursuitModel:EnableClick(true) + end +end + +return XChessPursuitModel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChessPursuit/XScene/XChessPursuitScene.lua b/Resources/Scripts/XUi/XUiChessPursuit/XScene/XChessPursuitScene.lua new file mode 100644 index 00000000..e94ac8cc --- /dev/null +++ b/Resources/Scripts/XUi/XUiChessPursuit/XScene/XChessPursuitScene.lua @@ -0,0 +1,55 @@ +local XChessPursuitScene = XClass(nil, "XChessPursuitScene") + +function XChessPursuitScene:Ctor(mapId, onLoadCompleteCb, onLeaveCb) + self.OnLoadCompleteCb = onLoadCompleteCb + self.OnLeaveCb = onLeaveCb + + self.MapId = mapId +end + +function XChessPursuitScene:OnEnterScene() + if self.GameObject then + return + end + + local config = XChessPursuitConfig.GetChessPursuitMapTemplate(self.MapId) + local sceneAssetUrl = config.Perfab + self.Resource = CS.XResourceManager.Load(sceneAssetUrl) + if not self.Resource.Asset then + XLog.Error("XChessPursuitScene LoadScene error, instantiate error, name: " .. sceneAssetUrl) + return + end + + self.GameObject = CS.UnityEngine.Object.Instantiate(self.Resource.Asset) + self.Transform = self.GameObject.transform + self:OnLoadComplete(self.GameObject) +end + +function XChessPursuitScene:OnLeaveScene() + if self.OnLeaveCb then + self.OnLeaveCb() + end + + CS.UnityEngine.GameObject.Destroy(self.GameObject) + self.GameObject = nil + + if self.Resource then + self.Resource:Release() + end +end + +function XChessPursuitScene:OnLoadComplete() + if self.OnLoadCompleteCb then + self.OnLoadCompleteCb(self.GameObject) + end +end + +function XChessPursuitScene:GetSceneGameObject() + return self.GameObject +end + +function XChessPursuitScene:SetOnLeaveCb(cb) + self.OnLeaveCb = cb +end + +return XChessPursuitScene \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChessPursuit/XScene/XChessPursuitSceneManager.lua b/Resources/Scripts/XUi/XUiChessPursuit/XScene/XChessPursuitSceneManager.lua new file mode 100644 index 00000000..677619cc --- /dev/null +++ b/Resources/Scripts/XUi/XUiChessPursuit/XScene/XChessPursuitSceneManager.lua @@ -0,0 +1,44 @@ +local XChessPursuitSceneManager = {} +local XChessPursuitScene = require("XUi/XUiChessPursuit/XScene/XChessPursuitScene") +local CurrentScene = nil + +--返回值:是否重新加载 +function XChessPursuitSceneManager.EnterScene(mapId, onLoadCompleteCb, onLeaveCb) + if CurrentScene then + local oldConfig = XChessPursuitConfig.GetChessPursuitMapTemplate(CurrentScene.MapId) + local newConfig = XChessPursuitConfig.GetChessPursuitMapTemplate(mapId) + + if oldConfig.Perfab == newConfig.Perfab then + CurrentScene:SetOnLeaveCb(onLeaveCb) + return false + else + XChessPursuitSceneManager.LeaveScene() + end + end + + local scene = XChessPursuitScene.New(mapId, onLoadCompleteCb, onLeaveCb) + + CurrentScene = scene + CurrentScene:OnEnterScene() + + return true +end + +function XChessPursuitSceneManager.LeaveScene() + if CurrentScene then + CurrentScene:OnLeaveScene() + CurrentScene = nil + end +end + +function XChessPursuitSceneManager.GetCurrentScene() + return CurrentScene +end + +function XChessPursuitSceneManager.SetActive(isShow) + if CurrentScene then + CurrentScene.GameObject:SetActiveEx(isShow) + end +end + +return XChessPursuitSceneManager \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChessPursuit/XScene/XChessPursuitTeam.lua b/Resources/Scripts/XUi/XUiChessPursuit/XScene/XChessPursuitTeam.lua new file mode 100644 index 00000000..89e145df --- /dev/null +++ b/Resources/Scripts/XUi/XUiChessPursuit/XScene/XChessPursuitTeam.lua @@ -0,0 +1,67 @@ +local XChessPursuitModel = require("XUi/XUiChessPursuit/XScene/XChessPursuitModel") +local XChessPursuitTeam = XClass(XChessPursuitModel, "XChessPursuitTeam") +local XChessPursuitSceneManager = require("XUi/XUiChessPursuit/XScene/XChessPursuitSceneManager") + +function XChessPursuitTeam:Ctor(cubeIndex, teamGridIndex, mapId) + self.TeamGridIndex = teamGridIndex + self.CubeIndex = cubeIndex + self.MapId = mapId +end + +function XChessPursuitTeam:LoadCaptainCharacter(captainCharacterId) + if captainCharacterId == self.CaptainCharacterId then + return + end + + self:Dispose() + self.CaptainCharacterId = captainCharacterId + + if self.CaptainCharacterId then + local chessPursuitScene = XChessPursuitSceneManager.GetCurrentScene() + local sceneGameObject = chessPursuitScene:GetSceneGameObject() + local config = XDormConfig.GetCharacterStyleConfigById(self.CaptainCharacterId) + local parent = sceneGameObject.transform:Find("Playmaker/Character") + self.Resource = CS.XResourceManager.Load(config.Model) + + if not self.Resource.Asset then + XLog.Error("XChessPursuitTeam LoadBoss error, instantiate error, name: " .. config.Model) + return + end + + self.GameObject = CS.UnityEngine.Object.Instantiate(self.Resource.Asset, parent) + self.CSXChessPursuitModel = self.GameObject:AddComponent(typeof(CS.XChessPursuitTeam)) + self.Transform = self.GameObject.transform + self.Transform.localScale = CS.UnityEngine.Vector3(1.3, 1.3, 1.3) + + local chessPursuitCubes = XChessPursuitCtrl.GetChessPursuitCubes() + local cubeGo = chessPursuitCubes[self.CubeIndex].GameObject + self.CSXChessPursuitModel:Init() + self.CSXChessPursuitModel:SetPosition(cubeGo) + self.CSXChessPursuitModel:SetXChessPursuitCtrl(XChessPursuitCtrl.GetCSXChessPursuitCtrlCom()) + end +end + +function XChessPursuitTeam:Dispose() + if self.GameObject then + self.CSXChessPursuitModel:Dispose() + CS.UnityEngine.GameObject.Destroy(self.GameObject) + end + + self.Func = nil + self.GameObject = nil + self.Transform = nil + self.CSXChessPursuitModel = nil + self.CaptainCharacterId = nil +end + +function XChessPursuitTeam:GetCubeIndex() + return self.CubeIndex +end + +function XChessPursuitTeam:SetActive(active) + if self.GameObject then + self.GameObject:SetActiveEx(active) + end +end + +return XChessPursuitTeam \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChessPursuit/XUi/QuickDeploy/XUiChessPursuitGridQuickDeployMember.lua b/Resources/Scripts/XUi/XUiChessPursuit/XUi/QuickDeploy/XUiChessPursuitGridQuickDeployMember.lua new file mode 100644 index 00000000..5c6128e5 --- /dev/null +++ b/Resources/Scripts/XUi/XUiChessPursuit/XUi/QuickDeploy/XUiChessPursuitGridQuickDeployMember.lua @@ -0,0 +1,70 @@ +local XUiChessPursuitGridQuickDeployMember = XClass(nil, "XUiChessPursuitGridQuickDeployMember") + +function XUiChessPursuitGridQuickDeployMember:Ctor(ui, pos, clickCb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Pos = pos + self.ClickCb = clickCb + + XTool.InitUiObject(self) + self:InitComponent() +end + +function XUiChessPursuitGridQuickDeployMember:InitComponent() + self.RImgRole.gameObject:SetActiveEx(false) + self.ImgLeader.gameObject:SetActiveEx(false) + self.ImgFirstRole.gameObject:SetActiveEx(false) + self.ImgAbility.gameObject:SetActiveEx(false) + self.ImgSelect.gameObject:SetActiveEx(false) + self.PanelEffect.gameObject:SetActiveEx(false) + self.BtnMember.CallBack = function() self:OnMemberClick() end + + local color = XUiHelper.Hexcolor2Color(XChessPursuitConfig.MEMBER_POS_COLOR[self.Pos]) + self.ImgLeftSkill.color = color + self.ImgRightSkill.color = color +end + +function XUiChessPursuitGridQuickDeployMember:Refresh(characterId, team, characterLimitType, teamGridIndex) + self.CharacterId = characterId + self.Team = team + self.CharacterLimitType = characterLimitType + self.TeamGridIndex = teamGridIndex + + if characterId and characterId ~= 0 then + local isRobot = XRobotManager.CheckIsRobotId(characterId) + local id = XRobotManager.CheckIdToCharacterId(characterId) + self.RImgRole.gameObject:SetActiveEx(true) + self.RImgRole:SetRawImage(XDataCenter.CharacterManager.GetCharSmallHeadIcon(id)) + self.TryTag.gameObject:SetActiveEx(isRobot) + else + self.RImgRole.gameObject:SetActiveEx(false) + self.TryTag.gameObject:SetActiveEx(false) + end + + self.PanelEffect.gameObject:SetActiveEx(false) +end + +function XUiChessPursuitGridQuickDeployMember:OnMemberClick() + if self.ClickCb then + self.ClickCb(self.CharacterId, self, self.Pos, self.Team, self.CharacterLimitType, self.TeamGridIndex) + end +end + +function XUiChessPursuitGridQuickDeployMember:ShowEffect() + self.PanelEffect.gameObject:SetActiveEx(false) + self.PanelEffect.gameObject:SetActiveEx(true) +end + +function XUiChessPursuitGridQuickDeployMember:SetSelect(value) + self.ImgSelect.gameObject:SetActiveEx(value) +end + +function XUiChessPursuitGridQuickDeployMember:RefreshCaptainPos(captainPos) + self.ImgLeader.gameObject:SetActiveEx(self.Pos == captainPos) +end + +function XUiChessPursuitGridQuickDeployMember:RefreshFirstFightPos(firstFightPos) + self.ImgFirstRole.gameObject:SetActiveEx(self.Pos == firstFightPos) +end + +return XUiChessPursuitGridQuickDeployMember \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChessPursuit/XUi/QuickDeploy/XUiChessPursuitGridQuickDeployTeam.lua b/Resources/Scripts/XUi/XUiChessPursuit/XUi/QuickDeploy/XUiChessPursuitGridQuickDeployTeam.lua new file mode 100644 index 00000000..01c59696 --- /dev/null +++ b/Resources/Scripts/XUi/XUiChessPursuit/XUi/QuickDeploy/XUiChessPursuitGridQuickDeployTeam.lua @@ -0,0 +1,132 @@ +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate + +local MAX_GRID_NUM = 3 + +local XUiChessPursuitGridQuickDeployMember = require("XUi/XUiChessPursuit/XUi/QuickDeploy/XUiChessPursuitGridQuickDeployMember") + +local XUiChessPursuitGridQuickDeployTeam = XClass(nil, "XUiChessPursuitGridQuickDeployTeam") + +function XUiChessPursuitGridQuickDeployTeam:Ctor(ui, memberClickCb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.MemberGridList = {} + self.Team = {} + self.MemberClickCb = memberClickCb + + XTool.InitUiObject(self) + self.TabGroup = { + self.BtnRed, + self.BtnBlue, + self.BtnYellow, + } + self.TagCaptainGroup = { + self.BtnCaptainRed, + self.BtnCaptainBlue, + self.BtnCaptainYellow + } + self.PanelTabFirst:Init(self.TabGroup, function(tabIndex) self:OnClickTabCallBack(tabIndex) end) + self.PanelTabCaptain:Init(self.TagCaptainGroup, function(tabIndex) self:OnClickCaptainTabCallBack(tabIndex) end) + self.GridTeamMember.gameObject:SetActiveEx(false) +end + +function XUiChessPursuitGridQuickDeployTeam:Refresh(teamGridIndex, mapId, team) + self.Team = team + self.TeamGridIndex = teamGridIndex + self.TextTitle.text = CS.XTextManager.GetText("ChessPursuitQuickDeployTeamTitle", teamGridIndex) + + local stageId = XChessPursuitConfig.GetChessPursuitBossStageIdByMapId(mapId) + local characterLimitType = XFubenConfigs.GetStageCharacterLimitType(stageId) + local captainPos = XDataCenter.ChessPursuitManager.GetCaptainPosInTempTeamData(mapId, teamGridIndex) + local firstFightPos = XDataCenter.ChessPursuitManager.GetFirstFightPosInTempTeamData(mapId, teamGridIndex) + + for index = 1, MAX_GRID_NUM do + local pos = XDataCenter.ChessPursuitManager.TeamPosConvert(index) + local grid = self.MemberGridList[index] + local characterId = team.TeamData[pos] + + if not grid then + local go = CSUnityEngineObjectInstantiate(self.GridTeamMember, self.PanelRole) + local clickCb = function(paramCharacterId, paramGrid, paramPos, cacheTeam, cacheCharacterLimitType, teamGridIndex) + self.MemberClickCb(paramCharacterId, paramGrid, paramPos, cacheTeam, cacheCharacterLimitType, teamGridIndex) + end + + grid = XUiChessPursuitGridQuickDeployMember.New(go, pos, clickCb) + grid.GameObject:SetActiveEx(true) + self.MemberGridList[index] = grid + end + + + grid:Refresh(characterId, self.Team, characterLimitType, teamGridIndex) + grid:RefreshCaptainPos(captainPos) + grid:RefreshFirstFightPos(firstFightPos) + + self.TabGroup[pos].gameObject:SetActiveEx(true) + end + + if not self.SelectedFirstPos then + self.PanelTabFirst:SelectIndex(firstFightPos) + end + + if not self.SelectedCaptainPos then + self.PanelTabCaptain:SelectIndex(captainPos) + end + + if not XFubenConfigs.IsStageCharacterLimitConfigExist(characterLimitType) then + self.PanelRequireCharacter.gameObject:SetActiveEx(false) + return + else + self.PanelRequireCharacter.gameObject:SetActiveEx(true) + end + + local icon = XFubenConfigs.GetStageCharacterLimitImageTeamEdit(characterLimitType) + self.ImgRequireCharacter:SetSprite(icon) + + local name = XFubenConfigs.GetStageCharacterLimitName(characterLimitType) + self.TxtRequireCharacter.text = name +end + +function XUiChessPursuitGridQuickDeployTeam:OnClickTabCallBack(firstFightPos) + if self.SelectedFirstPos and self.SelectedFirstPos == firstFightPos then + return + end + self.SelectedFirstPos = firstFightPos + + if self.Team then + self.Team.FirstFightPos = firstFightPos + end + + local gridList = self.MemberGridList + local gridNum = #gridList + for index = 1, gridNum do + local grid = gridList[index] + grid:RefreshFirstFightPos(firstFightPos) + end + + XDataCenter.ChessPursuitManager.SetPlayerTeamDataFirstFightPos(firstFightPos, self.TeamGridIndex) +end + +function XUiChessPursuitGridQuickDeployTeam:OnClickCaptainTabCallBack(captainPos) + if self.SelectedCaptainPos and self.SelectedCaptainPos == captainPos then + return + end + self.SelectedCaptainPos = captainPos + + if self.Team then + self.Team.CaptainPos = captainPos + end + + local gridList = self.MemberGridList + local gridNum = #gridList + for index = 1, gridNum do + local grid = gridList[index] + grid:RefreshCaptainPos(captainPos) + end + + XDataCenter.ChessPursuitManager.SetPlayerTeamDataCaptainPos(captainPos, self.TeamGridIndex) +end + +function XUiChessPursuitGridQuickDeployTeam:GetTeam() + return self.Team +end + +return XUiChessPursuitGridQuickDeployTeam \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChessPursuit/XUi/QuickDeploy/XUiChessPursuitQuickDeploy.lua b/Resources/Scripts/XUi/XUiChessPursuit/XUi/QuickDeploy/XUiChessPursuitQuickDeploy.lua new file mode 100644 index 00000000..91ffb907 --- /dev/null +++ b/Resources/Scripts/XUi/XUiChessPursuit/XUi/QuickDeploy/XUiChessPursuitQuickDeploy.lua @@ -0,0 +1,182 @@ +local XUiChessPursuitGridQuickDeployTeam = require("XUi/XUiChessPursuit/XUi/QuickDeploy/XUiChessPursuitGridQuickDeployTeam") + +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate +local CSXTextManagerGetText = CS.XTextManager.GetText + +local XUiChessPursuitQuickDeploy = XLuaUiManager.Register(XLuaUi, "UiChessPursuitQuickDeploy") + +function XUiChessPursuitQuickDeploy:OnAwake() + self.GridQuickDeployTeam.gameObject:SetActiveEx(false) + self:AutoAddListener() +end + +function XUiChessPursuitQuickDeploy:OnStart(mapId, saveCb) + self.MapId = mapId + self.SaveCb = saveCb + self.MapTeamGridList = XChessPursuitConfig.GetChessPursuitMapTeamGridList(mapId) + self.TeamGridList = {} + self.TeamDataList = {} +end + +function XUiChessPursuitQuickDeploy:OnEnable() + self:UpdateView() +end + +function XUiChessPursuitQuickDeploy:OnDisable() + self.OldSelectCharacterId = nil + self.OldTeam = nil + self.OldPos = nil + + if self.LastSelectGrid then + self.LastSelectGrid:SetSelect(false) + self.LastSelectGrid = nil + end +end + +function XUiChessPursuitQuickDeploy:OnDestroy() + XDataCenter.ChessPursuitManager.ClearTempTeam() +end + +function XUiChessPursuitQuickDeploy:GetTeamCharacterType(team) + local id + for _, characterId in pairs(team.TeamData or {}) do + if characterId ~= 0 then + id = XRobotManager.CheckIdToCharacterId(characterId) + return XCharacterConfigs.GetCharacterType(id) + end + end +end + +function XUiChessPursuitQuickDeploy:UpdateView() + local memberClickCb = function(characterId, grid, pos, team, characterLimitType, teamGridIndex) + local oldSelectCharacterId = self.OldSelectCharacterId + if oldSelectCharacterId then + if not (characterId == 0 and oldSelectCharacterId == 0) + and characterId ~= oldSelectCharacterId then + local swapFunc = function(isReset) + self:SwapTeamPos(self.OldTeam, self.OldPos, team, pos, isReset, teamGridIndex) + self:UpdateView() + + grid:ShowEffect() + self.LastSelectGrid:ShowEffect() + self.LastSelectGrid:SetSelect(false) + self.LastSelectGrid = nil + + self.OldSelectCharacterId = nil + self.OldTeam = nil + self.OldPos = nil + self.OldTeamGridIndex = nil + end + + local oldCharacterType = self:GetTeamCharacterType(self.OldTeam) + local newCharacterType = self:GetTeamCharacterType(team) + + --仅当副本限制类型为构造体/感染体强制要求时赋值 + local oldForceCharacterType = XDataCenter.FubenManager.GetForceCharacterTypeByCharacterLimitType(self.OldCharacterLimitType) + local newForceCharacterType = XDataCenter.FubenManager.GetForceCharacterTypeByCharacterLimitType(characterLimitType) + + --角色类型不符合副本限制类型 + if oldForceCharacterType and newCharacterType and oldForceCharacterType ~= newCharacterType + or newForceCharacterType and oldCharacterType and newForceCharacterType ~= oldCharacterType then + XUiManager.TipText("SwapCharacterTypeIsNotMatch") + return + end + + --角色类型不一致 + if newCharacterType and oldCharacterType and oldCharacterType ~= newCharacterType then + local content = CSXTextManagerGetText("SwapCharacterTypeIsDiffirent") + local sureCallBack = function() swapFunc(true) end + XUiManager.DialogTip(nil, content, XUiManager.DialogType.Normal, nil, sureCallBack) + return + end + + if not XDataCenter.ChessPursuitManager.CheckIsSwapTeamPos(self.OldTeamGridIndex, self.OldPos, teamGridIndex, pos) then + XUiManager.TipText("ChessPursuitNotSwitchCharacter") + return + end + + swapFunc() + return + end + end + + if self.LastSelectGrid then + self.LastSelectGrid:SetSelect(false) + end + self.LastSelectGrid = grid + self.LastSelectGrid:SetSelect(true) + self.LastSelectGrid:ShowEffect() + + self.OldSelectCharacterId = characterId + self.OldTeam = team + self.OldPos = pos + self.OldCharacterLimitType = characterLimitType + self.OldTeamGridIndex = teamGridIndex + end + + --表的index从0开始 + for teamGridIndex, cubeIndex in ipairs(self.MapTeamGridList) do + if not self.TeamDataList[teamGridIndex] then + local teamData = XDataCenter.ChessPursuitManager.GetSaveTempTeamData(self.MapId, teamGridIndex) or {TeamData = {0,0,0}, CaptainPos = 1, FirstFightPos = 1} + self.TeamDataList[teamGridIndex] = teamData + end + + local teamGrid = self.TeamGridList[teamGridIndex] + if not teamGrid then + local go = CSUnityEngineObjectInstantiate(self.GridQuickDeployTeam, self.PanelFormationTeamContent) + teamGrid = XUiChessPursuitGridQuickDeployTeam.New(go, memberClickCb) + self.TeamGridList[teamGridIndex] = teamGrid + end + local team = self.TeamDataList[teamGridIndex] + teamGrid:Refresh(teamGridIndex, self.MapId, team) + teamGrid.GameObject:SetActiveEx(true) + end + + for i = #self.MapTeamGridList + 1, #self.TeamGridList do + self.TeamGridList[i].GameObject:SetActiveEx(false) + end +end + +function XUiChessPursuitQuickDeploy:AutoAddListener() + self.BtnConfirm.CallBack = function() self:OnClickBtnConfirm() end +end + +function XUiChessPursuitQuickDeploy:OnClickBtnConfirm() + self:SaveTeam() + if self.SaveCb then + self.SaveCb() + end + self:Close() +end + +function XUiChessPursuitQuickDeploy:SaveTeam() + XDataCenter.ChessPursuitManager.SaveTempTeamData(self.MapId) +end + +function XUiChessPursuitQuickDeploy:SwapTeamPos(oldTeam, oldCharacterPos, newTeam, newCharacterPos, isReset, teamGridIndex) + if not oldTeam or not oldTeam.TeamData or not oldCharacterPos or not newTeam or not newTeam.TeamData or not newCharacterPos then + return + end + local oldCharacterId = oldTeam.TeamData[oldCharacterPos] + local newCharacterId = newTeam.TeamData[newCharacterPos] + + if oldTeam and oldCharacterPos then + if isReset then + for k in pairs(oldTeam.TeamData) do + oldTeam.TeamData[k] = 0 + end + end + oldTeam.TeamData[oldCharacterPos] = newCharacterId + end + + if newTeam and newCharacterPos then + if isReset then + for k in pairs(newTeam.TeamData) do + newTeam.TeamData[k] = 0 + end + end + newTeam.TeamData[newCharacterPos] = oldCharacterId + end + + XDataCenter.ChessPursuitManager.QuickDeploySetPlayerTeamData(self.TeamDataList) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChessPursuit/XUi/Rank/XUiChessPursuitMyRankGrid.lua b/Resources/Scripts/XUi/XUiChessPursuit/XUi/Rank/XUiChessPursuitMyRankGrid.lua new file mode 100644 index 00000000..b00d1579 --- /dev/null +++ b/Resources/Scripts/XUi/XUiChessPursuit/XUi/Rank/XUiChessPursuitMyRankGrid.lua @@ -0,0 +1,46 @@ +local XUiChessPursuitMyRankGrid = XClass(nil, "XUiChessPursuitMyRankGrid") + +local MAX_SPECIAL_NUM = 3 +local NOT_PERCENT_NUM = 100 + +function XUiChessPursuitMyRankGrid:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + self.TxtPlayerRankHistory.gameObject:SetActiveEx(false) +end + +function XUiChessPursuitMyRankGrid:Refresh() + local isHasMyRank = XDataCenter.ChessPursuitManager.IsHasMyRank() + if not isHasMyRank then + self.ImgRankSpecial.gameObject:SetActive(false) + self.TxtRankNormal.text = CS.XTextManager.GetText("None") + else + local myRankNum = XDataCenter.ChessPursuitManager.GetChessPursuitMyRank() + if myRankNum then + self.ImgRankSpecial.gameObject:SetActive(myRankNum <= MAX_SPECIAL_NUM) + if myRankNum <= MAX_SPECIAL_NUM then + self.TxtRankNormal.text = "" + local icon = XChessPursuitConfig.GetBabelRankIcon(math.floor(myRankNum)) + self.RootUi:SetUiSprite(self.ImgRankSpecial, icon) + elseif myRankNum <= NOT_PERCENT_NUM then + self.TxtRankNormal.text = myRankNum + end + else + myRankNum = XDataCenter.ChessPursuitManager.GetChessPursuitMyRankPercent() + if myRankNum < 1 then + myRankNum = 1 + end + self.TxtRankNormal.text = myRankNum .. "%" + end + end + + self.TxtPlayerName.text = XPlayer.Name + XUiPLayerHead.InitPortrait(XPlayer.CurrHeadPortraitId, XPlayer.CurrHeadFrameId, self.Head) + + local score = XDataCenter.ChessPursuitManager.GetChessPursuitMyScore() + self.TxtRankScore.text = score +end + +return XUiChessPursuitMyRankGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChessPursuit/XUi/Rank/XUiChessPursuitPanelRankReward.lua b/Resources/Scripts/XUi/XUiChessPursuit/XUi/Rank/XUiChessPursuitPanelRankReward.lua new file mode 100644 index 00000000..6772a362 --- /dev/null +++ b/Resources/Scripts/XUi/XUiChessPursuit/XUi/Rank/XUiChessPursuitPanelRankReward.lua @@ -0,0 +1,74 @@ +local XUiChessPursuitPanelRankRewardGrid = require("XUi/XUiChessPursuit/XUi/Rank/XUiChessPursuitPanelRankRewardGrid") + +local XUiChessPursuitPanelRankReward = XClass(nil, "XUiChessPursuitPanelRankReward") + +function XUiChessPursuitPanelRankReward:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self.GridRankList = {} + XTool.InitUiObject(self) + self:AutoAddListener() + self.GridBossRankReward.gameObject:SetActiveEx(false) +end + +function XUiChessPursuitPanelRankReward:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiChessPursuitPanelRankReward:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiChessPursuitPanelRankReward:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiChessPursuitPanelRankReward:AutoAddListener() + self:RegisterClickEvent(self.BtnBlock, self.OnBtnBlockClick) +end + +function XUiChessPursuitPanelRankReward:ShowPanel() + local groupId = XChessPursuitConfig.GetCurrentGroupId() + local idList = XChessPursuitConfig.GetMapGroupRewardByGroupIdToIdDic(groupId) + if not idList then + XUiManager.TipText("ChessPursuitNotRankReward") + return + end + for _, gridRank in ipairs(self.GridRankList) do + gridRank.GameObject:SetActiveEx(false) + end + + for i, mapGroupRewardId in ipairs(idList) do + local grid = self.GridRankList[i] + if not grid then + local ui = CS.UnityEngine.Object.Instantiate(self.GridBossRankReward) + grid = XUiChessPursuitPanelRankRewardGrid.New(self.RootUi, ui) + grid.Transform:SetParent(self.PanelRankContent, false) + self.GridRankList[i] = grid + end + grid:Refresh(groupId, mapGroupRewardId) + grid.GameObject:SetActiveEx(true) + end + + self.GameObject:SetActiveEx(true) + -- self.RootUi:PlayAnimation("AnimRankRewardEnable") +end + +function XUiChessPursuitPanelRankReward:OnBtnBlockClick() + self:HidePanel() +end + +function XUiChessPursuitPanelRankReward:HidePanel() + -- self.RootUi:PlayAnimation("AnimRankRewardDisable", function() + self.GameObject:SetActiveEx(false) + -- end) +end + +return XUiChessPursuitPanelRankReward + diff --git a/Resources/Scripts/XUi/XUiChessPursuit/XUi/Rank/XUiChessPursuitPanelRankRewardGrid.lua b/Resources/Scripts/XUi/XUiChessPursuit/XUi/Rank/XUiChessPursuitPanelRankRewardGrid.lua new file mode 100644 index 00000000..9e84e5a3 --- /dev/null +++ b/Resources/Scripts/XUi/XUiChessPursuit/XUi/Rank/XUiChessPursuitPanelRankRewardGrid.lua @@ -0,0 +1,43 @@ +local XUiChessPursuitPanelRankRewardGrid = XClass(nil, "XUiChessPursuitPanelRankRewardGrid") + +function XUiChessPursuitPanelRankRewardGrid:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self.GridRewardList = {} + XTool.InitUiObject(self) + self.GridReward.gameObject:SetActive(false) +end + +function XUiChessPursuitPanelRankRewardGrid:Refresh(groupId, mapGroupRewardId) + local rewardShowId = XChessPursuitConfig.GetMapGroupRewardRewardShowId(mapGroupRewardId) + local rewardList = XRewardManager.GetRewardList(rewardShowId) + local myScore = XDataCenter.ChessPursuitManager.GetChessPursuitMyScore() + + for i = 1, #rewardList do + local grid = self.GridRewardList[i] + if not grid then + local ui = CS.UnityEngine.Object.Instantiate(self.GridReward) + grid = XUiGridCommon.New(self.RootUi, ui) + grid.Transform:SetParent(self.PanelRewardContent, false) + self.GridRewardList[i] = grid + end + + grid:Refresh(rewardList[i]) + grid.GameObject:SetActiveEx(true) + end + + for i = #rewardList + 1, #self.GridRewardList do + self.GridRewardList[i].GameObject:SetActiveEx(false) + end + + local startRange = XChessPursuitConfig.GetMapGroupRewardStartRange(mapGroupRewardId) + local endRange = XChessPursuitConfig.GetMapGroupRewardEndRange(mapGroupRewardId) + self.TxtScore.text = startRange .. "-" .. endRange + + local isCur = myScore >= startRange and myScore <= endRange + self.PanelCurRank.gameObject:SetActive(isCur) +end + +return XUiChessPursuitPanelRankRewardGrid + diff --git a/Resources/Scripts/XUi/XUiChessPursuit/XUi/Rank/XUiChessPursuitRank.lua b/Resources/Scripts/XUi/XUiChessPursuit/XUi/Rank/XUiChessPursuitRank.lua new file mode 100644 index 00000000..7561ff8d --- /dev/null +++ b/Resources/Scripts/XUi/XUiChessPursuit/XUi/Rank/XUiChessPursuitRank.lua @@ -0,0 +1,103 @@ +local XUiChessPursuitRankGrid = require("XUi/XUiChessPursuit/XUi/Rank/XUiChessPursuitRankGrid") +local XUiChessPursuitMyRankGrid = require("XUi/XUiChessPursuit/XUi/Rank/XUiChessPursuitMyRankGrid") +local XUiPanelRankReward = require("XUi/XUiChessPursuit/XUi/Rank/XUiChessPursuitPanelRankReward") + +local XUiChessPursuitRank = XLuaUiManager.Register(XLuaUi, "UiChessPursuitRank") + +function XUiChessPursuitRank:OnAwake() + self.PanelRankReward.gameObject:SetActiveEx(false) + self.PlayerRank.gameObject:SetActiveEx(false) + self.RankReward = XUiPanelRankReward.New(self, self.PanelRankReward) + + self.MyRankGrid = XUiChessPursuitMyRankGrid.New(self.PanelMyRank, self) + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self:AutoAddListener() + self:InitDynamicTable() +end + +function XUiChessPursuitRank:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PlayerRankList) + self.DynamicTable:SetDelegate(self) + self.DynamicTable:SetProxy(XUiChessPursuitRankGrid, self) +end + +function XUiChessPursuitRank:AutoAddListener() + self:RegisterClickEvent(self.BtnBack, self.Close) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:RegisterClickEvent(self.BtnRankReward, self.OnBtnRankRewardClick) + self:BindHelpBtn(self.BtnHelp, "ChessPursuit") +end + +function XUiChessPursuitRank:OnStart(groupId) + self.GroupId = groupId +end + +function XUiChessPursuitRank:OnEnable() + self:Refresh() + self:SetRefreshTimer() +end + +function XUiChessPursuitRank:OnDisable() + self:RemoveTimer() +end + +function XUiChessPursuitRank:Refresh() + self:RefreshDynamicTable() + self:RefreshMyRank() +end + +function XUiChessPursuitRank:RefreshMyRank() + self.MyRankGrid:Refresh() +end + +function XUiChessPursuitRank:RefreshDynamicTable() + self.RankDataList = XDataCenter.ChessPursuitManager.GetRankDataList() + if XTool.IsTableEmpty(self.RankDataList) then + self.PlayerRankList.gameObject:SetActiveEx(false) + self.PanelNoRank.gameObject:SetActiveEx(true) + else + self.PanelNoRank.gameObject:SetActiveEx(false) + self.DynamicTable:SetDataSource(self.RankDataList) + self.DynamicTable:ReloadDataASync() + self.PlayerRankList.gameObject:SetActiveEx(true) + end +end + +function XUiChessPursuitRank:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local rankDataTemplate = self.RankDataList[index] + grid:Refresh(rankDataTemplate, index, self.GroupId) + end +end + +function XUiChessPursuitRank:OnBtnRankRewardClick() + self.RankReward:ShowPanel() +end + +function XUiChessPursuitRank:SetRefreshTimer() + self:RemoveTimer() + self.Timer = XScheduleManager.ScheduleForever(function() + self:CheckIsClose() + end, 1000) +end + +function XUiChessPursuitRank:RemoveTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end + +function XUiChessPursuitRank:CheckIsClose() + local isOpen = XChessPursuitConfig.IsChessPursuitMapGroupOpen(self.GroupId) + if not isOpen then + XUiManager.TipText("ActivityAlreadyOver") + self:RemoveTimer() + XLuaUiManager.Close("UiChessPursuitRankLineup") + self:Close() + end +end + +function XUiChessPursuitRank:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChessPursuit/XUi/Rank/XUiChessPursuitRankGrid.lua b/Resources/Scripts/XUi/XUiChessPursuit/XUi/Rank/XUiChessPursuitRankGrid.lua new file mode 100644 index 00000000..70c753b3 --- /dev/null +++ b/Resources/Scripts/XUi/XUiChessPursuit/XUi/Rank/XUiChessPursuitRankGrid.lua @@ -0,0 +1,49 @@ +local XUiChessPursuitRankGrid = XClass(nil, "XUiChessPursuitRankGrid") + +local MAX_SPECIAL_NUM = 3 + +function XUiChessPursuitRankGrid:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + + self.BtnTcanchaungBlue.CallBack = function() self:OnBtnTcanchaungBlueClick() end + self.BtnDetail.CallBack = function() self:OnBtnDetailClick() end +end + +function XUiChessPursuitRankGrid:Refresh(rankDataTemplate, rankNum, groupId) + if not rankDataTemplate then return end + self.RankDataTemplate = rankDataTemplate + self.GroupId = groupId + + self.TxtRankNormal.gameObject:SetActive(rankNum > MAX_SPECIAL_NUM) + self.ImgRankSpecial.gameObject:SetActive(rankNum <= MAX_SPECIAL_NUM) + if rankNum <= MAX_SPECIAL_NUM then + local icon = XChessPursuitConfig.GetBabelRankIcon(rankNum) + self.RootUi:SetUiSprite(self.ImgRankSpecial, icon) + else + self.TxtRankNormal.text = rankNum + end + + self.TxtPlayerName.text = rankDataTemplate:GetName() + local headPortraitId = rankDataTemplate:GetHead() + local headFrameId = rankDataTemplate:GetFrame() + XUiPLayerHead.InitPortrait(headPortraitId, headFrameId, self.Head) + + self.TxtRankScore.text = rankDataTemplate:GetScore() +end + +function XUiChessPursuitRankGrid:OnBtnTcanchaungBlueClick() + local playerId = self.RankDataTemplate:GetPlayerId() + XDataCenter.ChessPursuitManager.ChessPursuitGetRankPlayerDetailRequest(playerId, self.GroupId) +end + +function XUiChessPursuitRankGrid:OnBtnDetailClick() + local playerId = self.RankDataTemplate:GetPlayerId() + if playerId and playerId ~= XPlayer.Id then + XDataCenter.PersonalInfoManager.ReqShowInfoPanel(playerId) + end +end + +return XUiChessPursuitRankGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChessPursuit/XUi/Rank/XUiChessPursuitRankLineup.lua b/Resources/Scripts/XUi/XUiChessPursuit/XUi/Rank/XUiChessPursuitRankLineup.lua new file mode 100644 index 00000000..e4559631 --- /dev/null +++ b/Resources/Scripts/XUi/XUiChessPursuit/XUi/Rank/XUiChessPursuitRankLineup.lua @@ -0,0 +1,71 @@ +local XUiChessPursuitRankLineupGrid = require("XUi/XUiChessPursuit/XUi/Rank/XUiChessPursuitRankLineupGrid") + +--排行榜某个玩家的详细界面 +local XUiChessPursuitRankLineup = XLuaUiManager.Register(XLuaUi, "UiChessPursuitRankLineup") + +function XUiChessPursuitRankLineup:OnAwake() + self.GridBossRankReward.gameObject:SetActiveEx(false) + self:AutoAddListener() + self:InitDynamicTable() +end + +function XUiChessPursuitRankLineup:OnStart(playerId, chessPursuitRankGridList) + self.RankPlayerTemplate = XDataCenter.ChessPursuitManager.GetPursuitRankData(playerId) + self.ChessPursuitRankGridList = chessPursuitRankGridList +end + +function XUiChessPursuitRankLineup:OnEnable() + self:Refresh() +end + +function XUiChessPursuitRankLineup:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.List) + self.DynamicTable:SetDelegate(self) + self.DynamicTable:SetProxy(XUiChessPursuitRankLineupGrid, self) +end + +function XUiChessPursuitRankLineup:AutoAddListener() + self:RegisterClickEvent(self.BtnClose, self.Close) + self:RegisterClickEvent(self.BtnCopy, self.OnBtnCopy) +end + +function XUiChessPursuitRankLineup:Refresh() + self:RefreshDynamicTable() + self:RefreshPlayerInfo() +end + +function XUiChessPursuitRankLineup:RefreshPlayerInfo() + if not self.RankPlayerTemplate then + return + end + local headPortraitId = self.RankPlayerTemplate:GetHead() + local headFrameId = self.RankPlayerTemplate:GetFrame() + XUiPLayerHead.InitPortrait(headPortraitId, headFrameId, self.Head) + + local name = self.RankPlayerTemplate:GetName() + self.PlayerId = self.RankPlayerTemplate:GetPlayerId() + local level = self.RankPlayerTemplate:GetLevel() + self.TxtName.text = XDataCenter.SocialManager.GetPlayerRemark(self.PlayerId, name) + XUiPlayerLevel.UpdateLevel(level, self.level) + self.TxtId.text = self.PlayerId +end + +function XUiChessPursuitRankLineup:RefreshDynamicTable() + if not self.ChessPursuitRankGridList then + return + end + self.DynamicTable:SetDataSource(self.ChessPursuitRankGridList) + self.DynamicTable:ReloadDataSync() +end + +function XUiChessPursuitRankLineup:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local rankGridTemplate = self.ChessPursuitRankGridList[index] + grid:Refresh(rankGridTemplate, self.PlayerId, index) + end +end + +function XUiChessPursuitRankLineup:OnBtnCopy() + CS.XAppPlatBridge.CopyStringToClipboard(tostring(self.TxtId.text)) + XUiManager.TipText("Clipboard", XUiManager.UiTipType.Tip) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChessPursuit/XUi/Rank/XUiChessPursuitRankLineupCardGrid.lua b/Resources/Scripts/XUi/XUiChessPursuit/XUi/Rank/XUiChessPursuitRankLineupCardGrid.lua new file mode 100644 index 00000000..bbd7e801 --- /dev/null +++ b/Resources/Scripts/XUi/XUiChessPursuit/XUi/Rank/XUiChessPursuitRankLineupCardGrid.lua @@ -0,0 +1,30 @@ +local XUiChessPursuitRankLineupCardGrid = XClass(nil, "XUiChessPursuitRankLineupCardGrid") + +function XUiChessPursuitRankLineupCardGrid:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + + self.BtnClickCard.CallBack = function() self:OnClickCard() end +end + +function XUiChessPursuitRankLineupCardGrid:Refresh(cardId) + if not cardId then return end + + self.CardId = cardId + if self.RootUi then + local cardQualityIcon = XChessPursuitConfig.GetCardTipsQualityIconBg(cardId) + self.RootUi:SetUiSprite(self.ImgTipsCards, cardQualityIcon) + end + if self.RImgIcon then + local cardIcon = XChessPursuitConfig.GetCardIcon(cardId) + self.RImgIcon:SetRawImage(cardIcon) + end +end + +function XUiChessPursuitRankLineupCardGrid:OnClickCard() + XLuaUiManager.Open("UiChessPursuitCardsTip", self.CardId) +end + +return XUiChessPursuitRankLineupCardGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChessPursuit/XUi/Rank/XUiChessPursuitRankLineupGrid.lua b/Resources/Scripts/XUi/XUiChessPursuit/XUi/Rank/XUiChessPursuitRankLineupGrid.lua new file mode 100644 index 00000000..9a03e95d --- /dev/null +++ b/Resources/Scripts/XUi/XUiChessPursuit/XUi/Rank/XUiChessPursuitRankLineupGrid.lua @@ -0,0 +1,80 @@ +local XUiChessPursuitRankLineupCardGrid = require("XUi/XUiChessPursuit/XUi/Rank/XUiChessPursuitRankLineupCardGrid") +local XUiChessPursuitRankLineupRoleGrid = require("XUi/XUiChessPursuit/XUi/Rank/XUiChessPursuitRankLineupRoleGrid") + +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate + +local XUiChessPursuitRankLineupGrid = XClass(nil, "XUiChessPursuitRankLineupGrid") + +function XUiChessPursuitRankLineupGrid:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + + self.RoleGridList = {} + self.CardGridList = {} + self.GridBuff.gameObject:SetActiveEx(false) +end + +function XUiChessPursuitRankLineupGrid:Refresh(rankGridTemplate, playerId, index) + if not rankGridTemplate then return end + self.PlayerId = playerId + self.RankGridTemplate = rankGridTemplate + + self.TxtCheck.text = CS.XTextManager.GetText("ChessPursuitMapGridNumText", index) + + local bossHp = XDataCenter.ChessPursuitManager.GetChessPursuitRankDetailBossHp() + local hurt = rankGridTemplate:GetHurt() + if hurt < 0 then + self.TxtRecord.text = CS.XTextManager.GetText("ChessPursuitRankNotRecord") + elseif bossHp and bossHp > 0 then + local percent = string.format("%.2f%%", hurt / bossHp * 100) + self.TxtRecord.text = CS.XTextManager.GetText("ChessPursuitMaxDamageHistory", percent) + else + self.TxtRecord.text = CS.XTextManager.GetText("ChessPursuitMaxDamageHistory", hurt) + end + + self:RefreshRoleGrid() + self:RefreshCardGrid() +end + +function XUiChessPursuitRankLineupGrid:RefreshRoleGrid() + for _, roleGrid in ipairs(self.RoleGridList) do + roleGrid.gameObject:SetActiveEx(false) + end + + local characterIdList = self.RankGridTemplate:GetCharacterIdList(self.Index, self.PlayerId) + for i, characterId in ipairs(characterIdList) do + if not self.RoleGridList[i] then + if i == 1 then + self.RoleGridList[i] = XUiChessPursuitRankLineupRoleGrid.New(self.GridRole) + else + local grid = CSUnityEngineObjectInstantiate(self.GridRole, self.PanelRole.transform) + self.RoleGridList[i] = XUiChessPursuitRankLineupRoleGrid.New(grid) + end + end + self.RoleGridList[i]:Refresh(characterId, i) + end +end + +function XUiChessPursuitRankLineupGrid:RefreshCardGrid() + for _, cardGrid in ipairs(self.CardGridList) do + cardGrid.gameObject:SetActiveEx(false) + end + + local usedCardIds = self.RankGridTemplate:GetUsedCardIds() + for i, usedCardId in ipairs(usedCardIds) do + if not self.CardGridList[i] then + if i == 1 then + self.CardGridList[i] = XUiChessPursuitRankLineupCardGrid.New(self.GridBuff, self.RootUi) + else + local grid = CSUnityEngineObjectInstantiate(self.GridBuff, self.Content.transform) + self.CardGridList[i] = XUiChessPursuitRankLineupCardGrid.New(grid, self.RootUi) + end + end + self.CardGridList[i]:Refresh(usedCardId) + self.CardGridList[i].GameObject:SetActiveEx(true) + end +end + +return XUiChessPursuitRankLineupGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChessPursuit/XUi/Rank/XUiChessPursuitRankLineupRoleGrid.lua b/Resources/Scripts/XUi/XUiChessPursuit/XUi/Rank/XUiChessPursuitRankLineupRoleGrid.lua new file mode 100644 index 00000000..c6fef4bf --- /dev/null +++ b/Resources/Scripts/XUi/XUiChessPursuit/XUi/Rank/XUiChessPursuitRankLineupRoleGrid.lua @@ -0,0 +1,23 @@ +local XUiChessPursuitRankLineupRoleGrid = XClass(nil, "XUiChessPursuitRankLineupRoleGrid") + +function XUiChessPursuitRankLineupRoleGrid:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiChessPursuitRankLineupRoleGrid:Refresh(characterId, index) + if not characterId then return end + + local id = XRobotManager.CheckIdToCharacterId(characterId) + if XCharacterConfigs.GetCharacterTemplate(id) then + local liberateLv = XDataCenter.ChessPursuitManager.GetRankDetailCharacterLiberateLv(index, characterId) + local charIcon = XDataCenter.CharacterManager.GetCharSmallHeadIcon(id, liberateLv) + self.RawImage:SetRawImage(charIcon) + end + + local isRobot = XRobotManager.CheckIsRobotId(characterId) + self.PanelTry.gameObject:SetActiveEx(isRobot) +end + +return XUiChessPursuitRankLineupRoleGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XCPFSM/XUiCPActionBase.lua b/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XCPFSM/XUiCPActionBase.lua new file mode 100644 index 00000000..29325227 --- /dev/null +++ b/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XCPFSM/XUiCPActionBase.lua @@ -0,0 +1,91 @@ +local XUiCPActionBase = XClass(nil, "XUiCPActionBase") + +function XUiCPActionBase:Ctor(actionType, params) + self.Params = params + self.State = "idle" + self.IsFinish = false + self.ActionType = actionType +end + +function XUiCPActionBase:Update() + if self.State == "idle" then + if self:GetIsFinish() then + self:Exit() + return + end + + self.State = "enter" + self:OnEnter() + end + + if self.State == "enter" then + if self:GetIsFinish() then + self:Exit() + return + end + + self.State = "stay" + self:OnStay() + end + + if self.State == "stay" then + if self:GetIsFinish() then + self:Exit() + end + end + + if self.State == "finish" then + return true + end +end + +function XUiCPActionBase:Dispose() + self:Exit() +end + +function XUiCPActionBase:Exit() + self.State = "finish" +end + +--强制中断 +function XUiCPActionBase:Interrupt() + self:OnExit() + self:Dispose() +end + +function XUiCPActionBase:GetState() + return self.State +end + +function XUiCPActionBase:GetIsFinish() + return self.IsFinish +end + +function XUiCPActionBase:SetIsFinish(isFinish) + self.IsFinish = isFinish +end + +function XUiCPActionBase:GetActionType() + return self.ActionType +end +--@endregion + + +--@region 子类重写这几个方法 即可 +--初始化调用 +function XUiCPActionBase:OnEnter() + XLog.Error("OnEnter 方法未重写") +end + +--会一直调用 +function XUiCPActionBase:OnStay() + XLog.Error("OnStay 方法未重写") +end + +--结束时调用 +function XUiCPActionBase:OnExit() + self.IsFinish = true +end +--@endregion + +return XUiCPActionBase \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XCPFSM/XUiCPActionBeginBattle.lua b/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XCPFSM/XUiCPActionBeginBattle.lua new file mode 100644 index 00000000..b09b4173 --- /dev/null +++ b/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XCPFSM/XUiCPActionBeginBattle.lua @@ -0,0 +1,43 @@ +local XUiCPActionBase = require("XUi/XUiChessPursuit/XUi/XUiCPMain/XCPFSM/XUiCPActionBase") +local XUiCPActionBeginBattle = XClass(XUiCPActionBase, "XUiCPActionBeginBattle") +local CSXChessPursuitDirection = CS.XChessPursuitDirection + +function XUiCPActionBeginBattle:OnEnter() + self:SetIsFinish(false) + local CSXChessPursuitBoss = self.Params.UiRoot.ChessPursuitBoss:GetCSXChessPursuitModel() + + local chessPursuitMapDb = XDataCenter.ChessPursuitManager.GetChessPursuitMapDb(self.Params.MapId) + local bossPos = chessPursuitMapDb:GetBossPos() + local teamGridIndex = XChessPursuitConfig.GetTeamGridIndexByPos(self.Params.MapId, bossPos) + + if not teamGridIndex then + XLog.Error(string.format("触发战斗失败,MapId:%s ChessPursuitMap.tab的TeamGrid没有找到位置:%s", self.Params.MapId, bossPos)) + self:OnExit() + return + end + + self.Params.UiRoot.PanelTipsfighting.gameObject:SetActiveEx(true) + + self.Params.ParentUiRoot:PlayAnimationWithMask("PanelTipsfightingEnable", function() + self.Params.UiRoot.PanelTipsfighting.gameObject:SetActiveEx(false) + + local csXChessPursuitCtrlCom = XChessPursuitCtrl.GetCSXChessPursuitCtrlCom() + local chessPursuitDrawCamera = csXChessPursuitCtrlCom and csXChessPursuitCtrlCom:GetChessPursuitDrawCamera() + XLuaUiManager.Open("UiChessPursuitFightTips", self.Params.MapId, teamGridIndex, function () + XChessPursuitCtrl.SetSceneActive(false) + self:OnExit() + end, self.Params.ParentUiRoot, chessPursuitDrawCamera) + end) + + CS.XAudioManager.PlaySound(XSoundManager.UiBasicsMusic.ChessPursuit_FightWarning) +end + +function XUiCPActionBeginBattle:OnStay() + +end + +function XUiCPActionBeginBattle:OnExit() + self:SetIsFinish(true) +end + +return XUiCPActionBeginBattle \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XCPFSM/XUiCPActionCardEffect.lua b/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XCPFSM/XUiCPActionCardEffect.lua new file mode 100644 index 00000000..9808e2e7 --- /dev/null +++ b/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XCPFSM/XUiCPActionCardEffect.lua @@ -0,0 +1,41 @@ +local XUiCPActionBase = require("XUi/XUiChessPursuit/XUi/XUiCPMain/XCPFSM/XUiCPActionBase") +local XUiCPActionCardEffect = XClass(XUiCPActionBase, "XUiCPActionCardEffect") + +function XUiCPActionCardEffect:OnEnter() + self:SetIsFinish(false) + + --CardEffectId对应STEP表的ID + if self.Params.ChessPursuitSyncAction:GetCardEffectId() then + local stepId = self.Params.ChessPursuitSyncAction:GetCardEffectId() + self.Params.UiRoot:RefreshBloodAndCount() + if XChessPursuitConfig.CheckIsHaveStepCfgByCardEffectId(stepId) then + local cfg = XChessPursuitConfig.GetChessPursuitStepTemplate(stepId) + if cfg then + self.Params.UiRoot:PlayStep(cfg.Id, function() + self:OnExit() + end) + end + else + local chessPursuitMapDb = XDataCenter.ChessPursuitManager.GetChessPursuitMapDb(self.Params.MapId) + if chessPursuitMapDb:IsClear() then + self.Params.UiRoot:PlayBossKillerAnimation(function () + self:OnExit() + end) + else + self:OnExit() + end + end + else + self:OnExit() + end +end + +function XUiCPActionCardEffect:OnStay() + +end + +function XUiCPActionCardEffect:OnExit() + self:SetIsFinish(true) +end + +return XUiCPActionCardEffect \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XCPFSM/XUiCPActionEndBattle.lua b/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XCPFSM/XUiCPActionEndBattle.lua new file mode 100644 index 00000000..0977e439 --- /dev/null +++ b/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XCPFSM/XUiCPActionEndBattle.lua @@ -0,0 +1,25 @@ +local XUiCPActionBase = require("XUi/XUiChessPursuit/XUi/XUiCPMain/XCPFSM/XUiCPActionBase") +local XUiCPActionEndBattle = XClass(XUiCPActionBase, "XUiCPActionEndBattle") +local CSXChessPursuitDirection = CS.XChessPursuitDirection + +function XUiCPActionEndBattle:OnEnter() + self:SetIsFinish(false) + + XEventManager.AddEventListener(XEventId.EVENT_CHESSPURSUIT_FIGHT_FINISH_WIN, self.FightFinishWin, self) +end + +function XUiCPActionEndBattle:OnStay() + +end + +function XUiCPActionEndBattle:FightFinishWin() + self:OnExit() +end + +function XUiCPActionEndBattle:OnExit() + XEventManager.RemoveEventListener(XEventId.EVENT_CHESSPURSUIT_FIGHT_FINISH_WIN, self.FightFinishWin, self) + + self:SetIsFinish(true) +end + +return XUiCPActionEndBattle \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XCPFSM/XUiCPActionEndBattleHurt.lua b/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XCPFSM/XUiCPActionEndBattleHurt.lua new file mode 100644 index 00000000..b310c9e9 --- /dev/null +++ b/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XCPFSM/XUiCPActionEndBattleHurt.lua @@ -0,0 +1,27 @@ +local XUiCPActionBase = require("XUi/XUiChessPursuit/XUi/XUiCPMain/XCPFSM/XUiCPActionBase") +local XUiCPActionEndBattleHurt = XClass(XUiCPActionBase, "XUiCPActionEndBattleHurt") + +function XUiCPActionEndBattleHurt:OnEnter() + self:SetIsFinish(false) + + XChessPursuitCtrl.SetSceneActive(true) + + local chessPursuitMapDb = XDataCenter.ChessPursuitManager.GetChessPursuitMapDb(self.Params.MapId) + if chessPursuitMapDb:IsClear() then + self.Params.UiRoot:PlayBossKillerAnimation(function () + self:OnExit() + end) + else + self:OnExit() + end +end + +function XUiCPActionEndBattleHurt:OnStay() + +end + +function XUiCPActionEndBattleHurt:OnExit() + self:SetIsFinish(true) +end + +return XUiCPActionEndBattleHurt \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XCPFSM/XUiCPActionEndRound.lua b/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XCPFSM/XUiCPActionEndRound.lua new file mode 100644 index 00000000..aac299b7 --- /dev/null +++ b/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XCPFSM/XUiCPActionEndRound.lua @@ -0,0 +1,32 @@ +local XUiCPActionBase = require("XUi/XUiChessPursuit/XUi/XUiCPMain/XCPFSM/XUiCPActionBase") +local XUiCPActionEndRound = XClass(XUiCPActionBase, "XUiCPActionEndRound") +local CSXChessPursuitState = CS.XChessPursuitState + +function XUiCPActionEndRound:OnEnter() + self:SetIsFinish(false) + + local CSXChessPursuitCtrlCom = XChessPursuitCtrl.GetCSXChessPursuitCtrlCom() + local chessPursuitMapDb = XDataCenter.ChessPursuitManager.GetChessPursuitMapDb(self.Params.MapId) + self.CSXChessPursuitBoss = self.Params.UiRoot.ChessPursuitBoss:GetCSXChessPursuitModel() + + --回合结束前检测朝向是否与服务端的一致 + if CSXChessPursuitCtrlCom:GetChessPursuitDirection() ~= chessPursuitMapDb:GetBossMoveDirection() then + self.CSXChessPursuitBoss:SwitchState(CSXChessPursuitState.TurnBack, function () + self:OnExit() + end, chessPursuitMapDb:GetBossMoveDirection()) + else + self:OnExit() + end +end + +function XUiCPActionEndRound:OnStay() + +end + +function XUiCPActionEndRound:OnExit() + --EndRound必定到自己的回合 + self.Params.UiRoot:SetEndRound(true) + self:SetIsFinish(true) +end + +return XUiCPActionEndRound \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XCPFSM/XUiCPActionMachine.lua b/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XCPFSM/XUiCPActionMachine.lua new file mode 100644 index 00000000..8957a728 --- /dev/null +++ b/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XCPFSM/XUiCPActionMachine.lua @@ -0,0 +1,24 @@ +local XUiCPActionMachine = XClass(nil, "XUiCPActionMachine") +local XUiCPActionMove = require("XUi/XUiChessPursuit/XUi/XUiCPMain/XCPFSM/XUiCPActionMove") +local XUiCPActionBeginBattle = require("XUi/XUiChessPursuit/XUi/XUiCPMain/XCPFSM/XUiCPActionBeginBattle") +local XUiCPActionEndBattle = require("XUi/XUiChessPursuit/XUi/XUiCPMain/XCPFSM/XUiCPActionEndBattle") +local XUiCPActionEndBattleHurt = require("XUi/XUiChessPursuit/XUi/XUiCPMain/XCPFSM/XUiCPActionEndBattleHurt") +local XUiCPActionCardEffect = require("XUi/XUiChessPursuit/XUi/XUiCPMain/XCPFSM/XUiCPActionCardEffect") +local XUiCPActionEndRound = require("XUi/XUiChessPursuit/XUi/XUiCPMain/XCPFSM/XUiCPActionEndRound") + +function XUiCPActionMachine.Create(actionType, params) + local ActionMachine = { + [XDataCenter.ChessPursuitManager.ChessPursuitSyncActionType.Move] = XUiCPActionMove, + [XDataCenter.ChessPursuitManager.ChessPursuitSyncActionType.BeginBattle] = XUiCPActionBeginBattle, + [XDataCenter.ChessPursuitManager.ChessPursuitSyncActionType.EndBattle] = XUiCPActionEndBattle, + [XDataCenter.ChessPursuitManager.ChessPursuitSyncActionType.EndBattleHurt] = XUiCPActionEndBattleHurt, + [XDataCenter.ChessPursuitManager.ChessPursuitSyncActionType.CardEffect] = XUiCPActionCardEffect, + [XDataCenter.ChessPursuitManager.ChessPursuitSyncActionType.EndRound] = XUiCPActionEndRound, + } + + if ActionMachine[actionType] then + return ActionMachine[actionType].New(actionType, params) + end +end + +return XUiCPActionMachine \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XCPFSM/XUiCPActionMove.lua b/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XCPFSM/XUiCPActionMove.lua new file mode 100644 index 00000000..5a5dcb6a --- /dev/null +++ b/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XCPFSM/XUiCPActionMove.lua @@ -0,0 +1,56 @@ +local XUiCPActionBase = require("XUi/XUiChessPursuit/XUi/XUiCPMain/XCPFSM/XUiCPActionBase") +local XUiCPActionMove = XClass(XUiCPActionBase, "XUiCPActionMove") +local CSXChessPursuitState = CS.XChessPursuitState +local CSXChessPursuitDirection = CS.XChessPursuitDirection + +function XUiCPActionMove:OnEnter() + self:SetIsFinish(false) + + self.CSXChessPursuitBoss = self.Params.UiRoot.ChessPursuitBoss:GetCSXChessPursuitModel() + local CSXChessPursuitCtrlCom = XChessPursuitCtrl.GetCSXChessPursuitCtrlCom() + --要到达的位置 + local bossPos = self.Params.ChessPursuitSyncAction:GetBoosPos() + --场景中BOSS的位置 + local currentPos = self.CSXChessPursuitBoss:GetCurrentIndex() + local direction = XChessPursuitCtrl.GetMoveDirection(currentPos, bossPos) + + if currentPos == bossPos then + local chessPursuitMapDb = XDataCenter.ChessPursuitManager.GetChessPursuitMapDb(self.Params.MapId) + --服务器最新的方向 + local serverDir = chessPursuitMapDb:GetBossMoveDirection() + --本地客户端的方向 + local localDir = CSXChessPursuitCtrlCom:GetChessPursuitDirection() + if serverDir ~= localDir then + self.CSXChessPursuitBoss:SwitchState(CSXChessPursuitState.TurnBack, function () + self:OnExit() + end, serverDir) + else + self:OnExit() + end + elseif direction then + self.CSXChessPursuitBoss:SwitchState(CSXChessPursuitState.TurnBack, function () + self:Move() + end, direction) + else + self:Move() + end +end + +function XUiCPActionMove:Move() + CS.XAudioManager.PlaySound(XSoundManager.UiBasicsMusic.ChessPursuit_BossJump) + --一步一步走 + self.CSXChessPursuitBoss:SwitchState(CSXChessPursuitState.Move, function () + self:OnExit() + self.Params.UiRoot:RefreshTeamActive() + end, 1) +end + +function XUiCPActionMove:OnStay() + +end + +function XUiCPActionMove:OnExit() + self:SetIsFinish(true) +end + +return XUiCPActionMove \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitBuzhenGrid.lua b/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitBuzhenGrid.lua new file mode 100644 index 00000000..13838a2e --- /dev/null +++ b/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitBuzhenGrid.lua @@ -0,0 +1,236 @@ +local XUiChessPursuitBuzhenGrid = XClass(nil, "XUiChessPursuitBuzhenGrid") +local CSXTextManagerGetText = CS.XTextManager.GetText +local CSUnityEngineVector3 = CS.UnityEngine.Vector3 + +local ACTIVE_UI_TYPE = { + NONE = 0, + SELECT = 1, + TEAM = 2, + HURT_TXT = 3, +} + +function XUiChessPursuitBuzhenGrid:Ctor(ui, uiRoot, cubeIndex, teamGridIndex, mapId) + self.UiRoot = uiRoot + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.CubeIndex = cubeIndex + self.TeamGridIndex = teamGridIndex + self.MapId = mapId + + self.GameObject:SetActive(true) + XTool.InitUiObject(self) + self:AutoAddListener() + + self:SwitchUiType(ACTIVE_UI_TYPE.NONE) + + self.IsSetScale = false +end + +function XUiChessPursuitBuzhenGrid:Dispose() + if self.GameObject then + CS.UnityEngine.GameObject.Destroy(self.GameObject) + end + + self.GameObject = nil +end + +--@region 点击事件 + +function XUiChessPursuitBuzhenGrid:AutoAddListener() + XUiHelper.RegisterClickEvent(self, self.BtnBuzhen01, self.OnBtnBuzhen01Click) + XUiHelper.RegisterClickEvent(self, self.BtnBuzhen02, self.OnBtnBuzhen01Click) +end + +function XUiChessPursuitBuzhenGrid:OnBtnBuzhen01Click() + local chessPursuitMapDb = XDataCenter.ChessPursuitManager.GetChessPursuitMapDb(self.MapId) + local chessPursuitMapTemplate = chessPursuitMapDb:GetChessPursuitMapTemplate() + local chessPursuitBoss = XChessPursuitConfig.GetChessPursuitBossTemplate(chessPursuitMapTemplate.BossId) + local stageId = chessPursuitBoss.StageId + local robotList = XChessPursuitConfig.GetChessPursuitTestRoleRoleIds(chessPursuitMapTemplate.TestRoleGroup[self.TeamGridIndex]) + local curTeam = XDataCenter.ChessPursuitManager.GetSaveTempTeamData(self.MapId, self.TeamGridIndex) + if not curTeam then + curTeam = {TeamData = {0,0,0}, CaptainPos = 1, FirstFightPos = 1} + end + XLuaUiManager.Open("UiNewRoomSingle", stageId, { + ChessPursuitData = { + RobotList = robotList, + TeamGridIndex = self.TeamGridIndex, + MapId = self.MapId, + CurTeam = curTeam, + SceneUiType = XChessPursuitCtrl.SCENE_UI_TYPE.BUZHEN, + } + }) + +end + +function XUiChessPursuitBuzhenGrid:OnBtnBuzhen02Click() + XLog.Debug(">>>>>>>>>>>>>>>> OnBtnBuzhen02Click") +end + +--@endregion + +function XUiChessPursuitBuzhenGrid:Init() + self.BtnBuzhen01:SetName("0" .. self.TeamGridIndex) + self.BtnBuzhen02:SetName("0" .. self.TeamGridIndex) +end + +function XUiChessPursuitBuzhenGrid:RefreshPos() + local chessPursuitCubes = XChessPursuitCtrl.GetChessPursuitCubes() + local cubeTs = chessPursuitCubes[self.CubeIndex].Transform + if self.UiType == ACTIVE_UI_TYPE.SELECT then + local offzetY = 1.7 + self.Transform.position = XChessPursuitCtrl.WorldToUIPosition(CSUnityEngineVector3(cubeTs.position.x, cubeTs.position.y + offzetY, cubeTs.position.z)) + elseif self.UiType == ACTIVE_UI_TYPE.TEAM then + local isCaptainCharacterId = XDataCenter.ChessPursuitManager.IsCaptainCharacterIdInTempTeamData(self.MapId, self.TeamGridIndex) + local offzetY = isCaptainCharacterId and 1.5 or 0.5 + self.Transform.position = XChessPursuitCtrl.WorldToUIPosition(CSUnityEngineVector3(cubeTs.position.x, cubeTs.position.y + offzetY, cubeTs.position.z)) + elseif self.UiType == ACTIVE_UI_TYPE.HURT_TXT then + local offzetY = 0.5 + self.Transform.position = XChessPursuitCtrl.WorldToUIPosition(CSUnityEngineVector3(cubeTs.position.x, cubeTs.position.y + offzetY, cubeTs.position.z)) + end + + if not self.IsSetScale then + self.Transform.localScale = CSUnityEngineVector3(5,5,5) + self.IsSetScale = true + end +end + +function XUiChessPursuitBuzhenGrid:UpdateTeamHeadIconByMapDb(sceneType) + local chessPursuitMapDb = XDataCenter.ChessPursuitManager.GetChessPursuitMapDb(self.MapId) + local teamCharacterIds = chessPursuitMapDb:GetTeamCharacterIds(self.TeamGridIndex) + + if sceneType == XChessPursuitCtrl.SCENE_UI_TYPE.BUZHEN then + if next(teamCharacterIds) then + self:SwitchUiType(ACTIVE_UI_TYPE.TEAM) + else + self:SwitchUiType(ACTIVE_UI_TYPE.SELECT) + end + end + + if next(teamCharacterIds) then + self:UpdateTeamHeadIcon(teamCharacterIds) + end +end + +function XUiChessPursuitBuzhenGrid:UpdateTeamHeadIconByTempTeam(sceneType) + local tempTeamData = XDataCenter.ChessPursuitManager.GetSaveTempTeamData(self.MapId, self.TeamGridIndex) + local isTeamDataHasChar = self:IsTeamDataHasChar(tempTeamData and tempTeamData.TeamData) + + if sceneType == XChessPursuitCtrl.SCENE_UI_TYPE.BUZHEN then + if isTeamDataHasChar then + self:SwitchUiType(ACTIVE_UI_TYPE.TEAM) + else + self:SwitchUiType(ACTIVE_UI_TYPE.SELECT) + end + end + + if isTeamDataHasChar then + self:UpdateTeamHeadIcon(tempTeamData.TeamData, tempTeamData.CaptainPos) + end +end + +--队伍里是否有角色 +function XUiChessPursuitBuzhenGrid:IsTeamDataHasChar(teamData) + for _, charId in pairs(teamData or {}) do + if charId and charId > 0 then + return true + end + end + return false +end + +function XUiChessPursuitBuzhenGrid:UpdateTeamHeadIcon(characterIds, captainPos) + --同步编队位置,ui上1号位中间2左边3右边 + for i, characterId in ipairs(characterIds) do + local rawImage = self["RawImage" .. i] + local imageAdd = self["ImageAdd" .. i] + local labelLeader = self["LabelLeader" .. i] + if characterId ~= 0 then + rawImage.gameObject:SetActive(true) + imageAdd.gameObject:SetActive(false) + local iconpath = self:GetHeadIconUrl(characterId) + rawImage:SetRawImage(iconpath) + self:SetPressRImgHeadIcon(i, iconpath) + self:SetPressImageAddActive(i, false) + else + rawImage.gameObject:SetActive(false) + imageAdd.gameObject:SetActive(true) + self:SetPressRImgHeadIcon(i) + self:SetPressImageAddActive(i, true) + end + + if labelLeader then + labelLeader.gameObject:SetActiveEx(i == captainPos) + end + end +end + +function XUiChessPursuitBuzhenGrid:SetPressImageAddActive(index, isActive) + local pressImageAdd = self["PressImageAdd" .. index] + if pressImageAdd then + pressImageAdd.gameObject:SetActiveEx(isActive) + end +end + +function XUiChessPursuitBuzhenGrid:SetPressRImgHeadIcon(index, iconpath) + local pressRImgHeadIcon = self["PressRImgHeadIcon" .. index] + if pressRImgHeadIcon then + if iconpath then + pressRImgHeadIcon:SetRawImage(iconpath) + pressRImgHeadIcon.gameObject:SetActiveEx(true) + else + pressRImgHeadIcon.gameObject:SetActiveEx(false) + end + end +end + +function XUiChessPursuitBuzhenGrid:UpdateBossHurMax() + local hurtBoss = self:GetBossHurMax() + if hurtBoss > 0 then + self:SwitchUiType(ACTIVE_UI_TYPE.HURT_TXT) + self.TxtBossHurMax.text = CSXTextManagerGetText("ChessPursuitBossHurMax", string.format("%.2f%%", hurtBoss * 100)) + else + self:SwitchUiType(ACTIVE_UI_TYPE.NONE) + end +end + +function XUiChessPursuitBuzhenGrid:GetBossHurMax() + return XDataCenter.ChessPursuitManager.GetBossHurMax(self.MapId, self.TeamGridIndex) +end + +function XUiChessPursuitBuzhenGrid:ShowSelectTeam() + self:SwitchUiType(ACTIVE_UI_TYPE.SELECT) +end + +function XUiChessPursuitBuzhenGrid:GetHeadIconUrl(characterId) + if XRobotManager.CheckIsRobotId(characterId) then + characterId = XRobotManager.GetCharacterId(characterId) + end + + local iconpath = XDormConfig.GetCharacterStyleConfigQSIconById(characterId) + return iconpath +end + +function XUiChessPursuitBuzhenGrid:SetActive(sceneType) + if sceneType ~= XChessPursuitCtrl.SCENE_UI_TYPE.BUZHEN then + self:SwitchUiType(ACTIVE_UI_TYPE.HURT_TXT) + elseif sceneType == XChessPursuitCtrl.SCENE_UI_TYPE.BUZHEN then + self:SwitchUiType(ACTIVE_UI_TYPE.TEAM) + else + self:SwitchUiType(ACTIVE_UI_TYPE.NONE) + end +end + +function XUiChessPursuitBuzhenGrid:GetCubeIndex() + return self.CubeIndex +end + +function XUiChessPursuitBuzhenGrid:SwitchUiType(uiType) + self.UiType = uiType + + self.BtnBuzhen01.gameObject:SetActive(uiType == ACTIVE_UI_TYPE.SELECT) + self.BtnBuzhen02.gameObject:SetActive(uiType == ACTIVE_UI_TYPE.TEAM) + self.HighestHistory.gameObject:SetActive(uiType == ACTIVE_UI_TYPE.HURT_TXT) +end + +return XUiChessPursuitBuzhenGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitCardGrid.lua b/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitCardGrid.lua new file mode 100644 index 00000000..cbd3fb90 --- /dev/null +++ b/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitCardGrid.lua @@ -0,0 +1,98 @@ +local XUiChessPursuitCardGrid = XClass(nil, "XUiChessPursuitCardGrid") + +local QUALITY_COUNT = 3 + +function XUiChessPursuitCardGrid:Ctor(ui, uiRoot, cardIndex, mapId) + self.UiRoot = uiRoot + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.CardIndex = cardIndex + self.MapId = mapId + XTool.InitUiObject(self) +end + +function XUiChessPursuitCardGrid:Dispose() + +end + +function XUiChessPursuitCardGrid:Refresh(usedToGrid, usedToBoss, sceneType) + local chessPursuitMapDb = XDataCenter.ChessPursuitManager.GetChessPursuitMapDb(self.MapId) + local bossIsClear = chessPursuitMapDb:IsClear() + local cards = chessPursuitMapDb:GetBuyedCards() + local card = cards[self.CardIndex] + if card then + local isUse = self:CheckIsUse(card.Id, usedToGrid, usedToBoss) + local disable = isUse or bossIsClear or sceneType == XChessPursuitCtrl.SCENE_UI_TYPE.BOSS_ROUND + self.CardCfg = XChessPursuitConfig.GetChessPursuitCardTemplate(card.CardCfgId) + self:SetInfo() + self:SetDisable(disable) + else + self.CardCfg = nil + end + + self:SetActive(card and true or false) +end + +function XUiChessPursuitCardGrid:CheckIsUse(myCardId, usedToGrid, usedToBoss) + for gridIndex, list in pairs(usedToGrid) do + for i, cardId in ipairs(list) do + if cardId == myCardId then + return true + end + end + end + + for i, cardId in pairs(usedToBoss) do + if cardId == myCardId then + return true + end + end + + return false +end + +function XUiChessPursuitCardGrid:SetInfo() + local typeNames = { + "Normal", + "Press", + "Select", + "Disable", + } + + for i, v in ipairs(typeNames) do + self["RawImageIcon_" .. v]:SetRawImage(self.CardCfg.Icon) + end + + for i, v in ipairs(typeNames) do + self["RawImageKuang_" .. v]:SetRawImage(self.CardCfg.QualityIcon) + end + + for i, v in ipairs(typeNames) do + self["TxtCardNum_" .. v].text = "" + end + + self.BtnCards:SetName(self.CardCfg.Name) +end + +function XUiChessPursuitCardGrid:SetDisable(isDisable) + self.RawImageDisable.gameObject:SetActiveEx(isDisable) + self.BtnCards:SetDisable(isDisable) + + for i = 1, QUALITY_COUNT do + if not isDisable and self.CardCfg then + self["Effect" .. i].gameObject:SetActiveEx(i == self.CardCfg.Quality) + else + self["Effect" .. i].gameObject:SetActiveEx(false) + end + end +end + +function XUiChessPursuitCardGrid:GetCardIndex() + return self.CardIndex +end + +function XUiChessPursuitCardGrid:SetActive(isActive) + self.GameObject:SetActiveEx(isActive) +end + +return XUiChessPursuitCardGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitGridFight.lua b/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitGridFight.lua new file mode 100644 index 00000000..5d277d37 --- /dev/null +++ b/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitGridFight.lua @@ -0,0 +1,38 @@ +local XUiChessPursuitGridFight = XClass(nil, "XUiChessPursuitGridFight") +local CSUnityEngineVector3 = CS.UnityEngine.Vector3 + +function XUiChessPursuitGridFight:Ctor(ui, uiRoot, mapId) + self.UiRoot = uiRoot + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.MapId = mapId + + XTool.InitUiObject(self) + + self.Transform.localScale = CSUnityEngineVector3(5,5,5) +end + +function XUiChessPursuitGridFight:Dispose() + if self.GameObject then + CS.UnityEngine.GameObject.Destroy(self.GameObject) + end + + self.GameObject = nil +end + +function XUiChessPursuitGridFight:SetActiveEx(isShow) + self.GameObject:SetActiveEx(isShow) +end + +function XUiChessPursuitGridFight:RefreshPos() + if not self.GameObject.activeSelf then + return + end + + local ts= self.UiRoot.ChessPursuitBoss.Transform + local offzetY = 0.35 + self.Transform.position = XChessPursuitCtrl.WorldToUIPosition(CSUnityEngineVector3(ts.position.x, ts.position.y + offzetY, ts.position.z)) +end + + +return XUiChessPursuitGridFight \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitGuideGrid.lua b/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitGuideGrid.lua new file mode 100644 index 00000000..d19e974c --- /dev/null +++ b/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitGuideGrid.lua @@ -0,0 +1,36 @@ +local XUiChessPursuitGuideGrid = XClass(nil, "XUiChessPursuitGuideGrid") +local CSUnityEngineVector2 = CS.UnityEngine.Vector2 + +function XUiChessPursuitGuideGrid:Ctor(ui, uiRoot, modelTransform) + self.UiRoot = uiRoot + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.ModelTransform = modelTransform + + XTool.InitUiObject(self) +end + +function XUiChessPursuitGuideGrid:Dispose() + if self.GameObject then + CS.UnityEngine.GameObject.Destroy(self.GameObject) + end + + self.GameObject = nil +end + +function XUiChessPursuitGuideGrid:SetActiveEx(isShow) + self.GameObject:SetActiveEx(isShow) +end + +function XUiChessPursuitGuideGrid:RefreshPos() + local ts = self.ModelTransform + local localPosition = XChessPursuitCtrl.WorldToUILocaPosition(ts.position) + + self.Transform.anchoredPosition = CSUnityEngineVector2(localPosition.x, localPosition.y+95) +end + +function XUiChessPursuitGuideGrid:AddClick(callBack) + XUiHelper.RegisterClickEvent(self, self.Transform, callBack) +end + +return XUiChessPursuitGuideGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitMain.lua b/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitMain.lua new file mode 100644 index 00000000..3dd0a9de --- /dev/null +++ b/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitMain.lua @@ -0,0 +1,234 @@ +local XUiChessPursuitMain = XLuaUiManager.Register(XLuaUi, "UiChessPursuitMain") +local XUiChessPursuitMainScene = require("XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitMainScene") +local XUiChessPursuitMainStage = require("XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitMainStage") +local XChessPursuitSceneManager = require("XUi/XUiChessPursuit/XScene/XChessPursuitSceneManager") + +function XUiChessPursuitMain:OnAwake() + self.UiChessPursuitMainBase = nil + self.Switching = false + self.EndTime = XChessPursuitConfig.GetActivityEndTime() + + self:AutoAddListener() + self:Init() + + self.UpdateTimer = XScheduleManager.ScheduleForever(function() + self:IsTimeToFinish() + end, 1) + + --引导开启 + CsXGameEventManager.Instance:RegisterEvent(XEventId.EVENT_GUIDE_START, handler(self, self.OnGuideStart)) +end + +function XUiChessPursuitMain:OnStart() + XDataCenter.ChessPursuitManager.CheckIsAutoPlayStory() +end + +function XUiChessPursuitMain:OnDisable() + if self.UiChessPursuitMainBase and self.UiChessPursuitMainBase.Disable then + self.UiChessPursuitMainBase:Disable() + end +end + +function XUiChessPursuitMain:OnDestroy() + CsXGameEventManager.Instance:RemoveEvent(XEventId.EVENT_GUIDE_START, handler(self, self.OnGuideStart)) + + if self.UiChessPursuitMainBase then + self.UiChessPursuitMainBase:Dispose() + self.UiChessPursuitMainBase = nil + end + + if self.UpdateTimer then + XScheduleManager.UnSchedule(self.UpdateTimer) + self.UpdateTimer = nil + end + + --等dispose的完了再清场景 + XChessPursuitCtrl.LeaveScene() +end + +--@region 点击事件 + +function XUiChessPursuitMain:AutoAddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:RegisterClickEvent(self.BtnHelp, function() XDataCenter.ChessPursuitManager.OpenHelpTip() end) +end + +function XUiChessPursuitMain:OnBtnBackClick() + if self.Switching then + return + end + if self.UiType == XChessPursuitCtrl.MAIN_UI_TYPE.SCENE then + local defaultUiType = self:GetDefaultUiType() + self:SwtichUI(defaultUiType, { + MapId = self:GetDefaultMapId() + }) + else + self:Close() + end +end + +function XUiChessPursuitMain:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +--@endregion + +--@region 主逻辑 + +function XUiChessPursuitMain:Init() + local defaultUiType = self:GetDefaultUiType() + self:SwtichUI(defaultUiType, { + MapId = self:GetDefaultMapId() + }) +end + +--isReset:强制切换场景 +function XUiChessPursuitMain:SwtichUI(uiType, params, isReset) + if self.Switching or self.UiType == uiType and not isReset then + return + end + + local disposeMainBase = function () + if self.UiChessPursuitMainBase then + self.UiChessPursuitMainBase:Dispose() + self.UiChessPursuitMainBase = nil + end + end + + self.Switching = true + self.IsReload = XChessPursuitCtrl.Enter(params.MapId) + + if params.CallBack then + params.CallBack() + end + + self.PanelStage.gameObject:SetActiveEx(false) + self.PanelScene.gameObject:SetActiveEx(false) + + if uiType == XChessPursuitCtrl.MAIN_UI_TYPE.SCENE then + disposeMainBase() + self.UiChessPursuitMainBase = XUiChessPursuitMainScene.New(self.PanelScene, self, params.MapId) + else + if self.UiChessPursuitMainBase then + if self.UiChessPursuitMainBase:GetUiType() == XChessPursuitCtrl.MAIN_UI_TYPE.SCENE then + disposeMainBase() + self.UiChessPursuitMainBase = XUiChessPursuitMainStage.New(self.PanelStage, self) + end + else + self.UiChessPursuitMainBase = XUiChessPursuitMainStage.New(self.PanelStage, self) + end + end + + self:PlayAnimationForScene(uiType, function () + self.UiType = uiType + coroutine.wrap(function() + local co = coroutine.running() + + --有可能播动画的时候, 界面被关闭 + if not self.UiChessPursuitMainBase then + return + end + + self.UiChessPursuitMainBase:Init({ + UiType = self.UiType, + }, function () + coroutine.resume(co) + self.Switching = false + end) + coroutine.yield() + end)() + end) +end + +--@endregion + +function XUiChessPursuitMain:GetDefaultMapId() + local groupId = XChessPursuitConfig.GetCurrentGroupId() + local mapsCfg = XChessPursuitConfig.GetChessPursuitMapsByGroupId(groupId) + + local mapId + for i, cfg in ipairs(mapsCfg) do + local isOpen = XChessPursuitConfig.CheckChessPursuitMapIsOpen(cfg.Id) + + if isOpen then + if XSaveTool.GetData(self:GetSaveToolKey()) == cfg.Id then + return cfg.Id + else + mapId = cfg.Id + end + end + end + + return mapId +end + +function XUiChessPursuitMain:GetDefaultUiType() + local groupId = XChessPursuitConfig.GetCurrentGroupId() + local mapId = self:GetDefaultMapId() + local mapCfg = XChessPursuitConfig.GetChessPursuitMapTemplate(mapId) + + --Stage 对应UiType + return mapCfg.Stage +end + +function XUiChessPursuitMain:GetSaveToolKey() + local time = XTime.GetServerNowTimestamp() + local weekBeginDesc = XTime.TimestampToGameDateTimeString(time, "yyyy-MM") + + return string.format("ChessPursuitMapId_%s_", weekBeginDesc) +end + +function XUiChessPursuitMain:PlayAnimationForScene(uiType, cbFunc) + if uiType == XChessPursuitCtrl.MAIN_UI_TYPE.SCENE then + XChessPursuitCtrl.PlayAnimationForScene("AnimEnable2", function () + cbFunc() + end) + else + if self.IsReload then + XChessPursuitCtrl.PlayAnimationForScene("AnimEnable", cbFunc) + return + end + + --之前不是从场景状态切换过来的 + if self.UiType ~= XChessPursuitCtrl.MAIN_UI_TYPE.SCENE then + if cbFunc then + cbFunc() + end + return + end + + local csXChessPursuitCtrlCom = XChessPursuitCtrl.GetCSXChessPursuitCtrlCom() + local chessPursuitDrawCamera = csXChessPursuitCtrlCom:GetChessPursuitDrawCamera() + chessPursuitDrawCamera:SwitchChessPursuitCameraState(CS.XChessPursuitCameraState.None) + chessPursuitDrawCamera:SwitchFieldOfViewState(CS.XFieldOfView.Far, function () + chessPursuitDrawCamera:SwitchFieldOfViewState(CS.XFieldOfView.None) + XChessPursuitCtrl.PlayAnimationForScene("AnimEnable3", cbFunc) + end) + end +end + +function XUiChessPursuitMain:IsTimeToFinish() + if CS.XFight.IsRunning or XLuaUiManager.IsUiLoad("UiLoading") then + return + end + + local nowTime = XTime.GetServerNowTimestamp() + + if nowTime >= self.EndTime and self.GameObject.activeSelf then + XUiManager.TipText("ChessPursuitFinishDesc") + XLuaUiManager.RunMain() + end +end + +function XUiChessPursuitMain:OnGuideStart() + local csXChessPursuitCtrlCom = XChessPursuitCtrl.GetCSXChessPursuitCtrlCom() + if csXChessPursuitCtrlCom then + local chessPursuitDrawCamera = csXChessPursuitCtrlCom:GetChessPursuitDrawCamera() + chessPursuitDrawCamera:SwitchChessPursuitCameraState(CS.XChessPursuitCameraState.None) + end +end + +function XUiChessPursuitMain:SetBtnHelpIsHide(isHide) + self.BtnHelp.gameObject:SetActiveEx(isHide) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitMainAnimQueue.lua b/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitMainAnimQueue.lua new file mode 100644 index 00000000..2712484b --- /dev/null +++ b/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitMainAnimQueue.lua @@ -0,0 +1,76 @@ +local XUiChessPursuitMainAnimQueue = XClass(nil, "XUiChessPursuitMainAnimQueue") + +--动画的播放队列 +function XUiChessPursuitMainAnimQueue:Ctor(rootUi) + self.RootUi = rootUi + + self.AnimationList = {} + self.IsPlay = false +end + +function XUiChessPursuitMainAnimQueue:Push(aniName, beginCallBack, finishCallBack) + table.insert(self.AnimationList, { + aniName = aniName, + BeginCallBack = beginCallBack, + FinishCallBack = finishCallBack, + }) +end + +function XUiChessPursuitMainAnimQueue:Pop() + local animationList = self.AnimationList[1] + + if not animationList then + return + end + + table.remove(self.AnimationList, 1) +end + +function XUiChessPursuitMainAnimQueue:PopAndPlay() + if self.IsPlay then + return + end + + if not self.RootUi.GameObject.activeSelf then + local animationList = self.AnimationList[1] + + if animationList.BeginCallBack then + animationList.BeginCallBack() + end + + self:Pop() + + if animationList.FinishCallBack then + animationList.FinishCallBack() + end + return + end + + if next(self.AnimationList) then + local animationList = self.AnimationList[1] + + self.IsPlay = true + + if animationList.BeginCallBack then + animationList.BeginCallBack() + end + + self.RootUi:PlayAnimationWithMask(animationList.aniName, function () + self.IsPlay = false + self:Pop() + if animationList.FinishCallBack then + animationList.FinishCallBack() + end + end) + end +end + +function XUiChessPursuitMainAnimQueue:Clear() + self.AnimationList = {} +end + +function XUiChessPursuitMainAnimQueue:GetCount() + return #self.AnimationList +end + +return XUiChessPursuitMainAnimQueue diff --git a/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitMainBase.lua b/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitMainBase.lua new file mode 100644 index 00000000..e17f4014 --- /dev/null +++ b/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitMainBase.lua @@ -0,0 +1,19 @@ +local XUiChessPursuitMainBase = XClass(nil, "XUiChessPursuitMainBase") + +function XUiChessPursuitMainBase:Init(params) + self.UiType = params.UiType +end + +function XUiChessPursuitMainBase:Update() + XLog.Error("此接口需要被重写") +end + +function XUiChessPursuitMainBase:Dispose() + XLog.Error("此接口需要被重写") +end + +function XUiChessPursuitMainBase:GetUiType() + return self.UiType +end + +return XUiChessPursuitMainBase \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitMainScene.lua b/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitMainScene.lua new file mode 100644 index 00000000..011bbce3 --- /dev/null +++ b/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitMainScene.lua @@ -0,0 +1,1417 @@ +local XUiChessPursuitMainBase = require("XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitMainBase") +local XUiChessPursuitMainScene = XClass(XUiChessPursuitMainBase, "XUiChessPursuitMainScene") +local XChessPursuitSceneManager = require("XUi/XUiChessPursuit/XScene/XChessPursuitSceneManager") +local XChessPursuitTeam = require("XUi/XUiChessPursuit/XScene/XChessPursuitTeam") +local XUiChessPursuitBuzhenGrid = require("XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitBuzhenGrid") +local XChessPursuitBoss = require("XUi/XUiChessPursuit/XScene/XChessPursuitBoss") +local XUiCPActionMachine = require("XUi/XUiChessPursuit/XUi/XUiCPMain/XCPFSM/XUiCPActionMachine") +local XUiChessPursuitCardGrid = require("XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitCardGrid") +local XUiChessPursuitSkillGrid = require("XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitSkillGrid") +local XUiChessPursuitSelectTipGrid = require("XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitSelectTipGrid") +local XUiChessPursuitGridFight = require("XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitGridFight") +local XUiChessPursuitSkillEffectGrid = require("XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitSkillEffectGrid") +local XUiChessPursuitGuideGrid = require("XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitGuideGrid") +local XUiChessPursuitMainAnimQueue = require("XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitMainAnimQueue") + +local CSUnityEngineWaitForSeconds = CS.UnityEngine.WaitForSeconds +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate +local CSXTextManagerGetText = CS.XTextManager.GetText + +local CANCEL_SELECT_INDEX = -1 +local DelayDestroyArrowEffectMilliSecond = 1500 +local TxtNumberBattlesDefaultFontSize = 36 + +function XUiChessPursuitMainScene:Ctor(ui, rootUi, mapId) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self.MapId = mapId + self:SetEndRound(true) + + XTool.InitUiObject(self) + self:AutoAddListener() + self:AddEventListener() + XEventManager.AddEventListener(XEventId.EVENT_FIGHT_FINISH_LOSEUI_CLOSE, self.FinishLoseuiClose, self) +end + +function XUiChessPursuitMainScene:Disable() + if self.UiChessPursuitSkillEffectGrids then + for i, v in ipairs(self.UiChessPursuitSkillEffectGrids) do + v:Disable() + end + end +end + +function XUiChessPursuitMainScene:Dispose() + self.UsedToGrid = {} + self.UsedToBoss = {} + + self:StopUpdateTimer() + self:StopDestroyArrowEffectUpdateTimer() + self:StopBossEffectBloodUpdateTimer() + if self.CurrentActionMachine then + self.CurrentActionMachine:Interrupt() + self.CurrentActionMachine = nil + end + if self.ChessPursuitBoss then + self.ChessPursuitBoss:Dispose() + self.ChessPursuitBoss = nil + end + + if self.UiChessPursuitBuzhenGrids then + for i,uiChessPursuitBuzhenGrid in ipairs(self.UiChessPursuitBuzhenGrids) do + uiChessPursuitBuzhenGrid:Dispose() + end + end + + if self.ChessPursuitTeams then + for i,chessPursuitTeam in ipairs(self.ChessPursuitTeams) do + chessPursuitTeam:Dispose() + end + end + + if self.ChessPursuitCubes then + for i,chessPursuitCubes in ipairs(self.ChessPursuitCubes) do + chessPursuitCubes:Dispose() + end + end + + if self.UiChessPursuitCardGrids then + for i,uiChessPursuitCardGrid in ipairs(self.UiChessPursuitCardGrids) do + uiChessPursuitCardGrid:Dispose() + end + end + + if self.CSXChessPursuitCtrlCom then + self.CSXChessPursuitCtrlCom:SetCameraMask(false) + end + + if self.ChessPursuitCubes then + for i,chessPursuitCube in ipairs(self.ChessPursuitCubes) do + chessPursuitCube:Default() + chessPursuitCube:Dispose() + end + end + + if self.UiChessPursuitSkillGrids then + for i,v in ipairs(self.UiChessPursuitSkillGrids) do + v:Dispose() + end + end + + if self.UiChessPursuitSkillGridBoss then + self.UiChessPursuitSkillGridBoss:Dispose() + end + + if self.UiChessPursuitSelectTipGrids then + for i,v in ipairs(self.UiChessPursuitSelectTipGrids) do + v:Dispose() + end + + self.UiChessPursuitSelectTipGridBoss:Dispose() + end + + if self.UiChessPursuitSkillEffectGrids then + for i,v in ipairs(self.UiChessPursuitSkillEffectGrids) do + v:Dispose() + end + end + + if self.UiChessPursuitGridFight then + self.UiChessPursuitGridFight:Dispose() + end + + if self.UiChessPursuitGuideGrid then + self.UiChessPursuitGuideGrid:Dispose() + end + + if self.UiChessPursuitMainAnimQueue then + self.UiChessPursuitMainAnimQueue:Clear() + end + + self:RemoveEventListener() + self.GameObject:SetActiveEx(false) + self:CheckOnClickCardHidePanel(CANCEL_SELECT_INDEX) + + XEventManager.RemoveEventListener(XEventId.EVENT_CHESSPURSUIT_BUY_CARD, self.RefreshBuyCard, self) + XEventManager.RemoveEventListener(XEventId.EVENT_FIGHT_FINISH_LOSEUI_CLOSE, self.FinishLoseuiClose, self) +end + +function XUiChessPursuitMainScene:StopUpdateTimer() + if self.UpdateTimer then + XScheduleManager.UnSchedule(self.UpdateTimer) + self.UpdateTimer = nil + end +end + +function XUiChessPursuitMainScene:StopDestroyArrowEffectUpdateTimer() + if self.DestroyArrowEffectUpdateTimer then + XScheduleManager.UnSchedule(self.DestroyArrowEffectUpdateTimer) + self.DestroyArrowEffectUpdateTimer = nil + self:DestroyArrowEffect() + end +end + +function XUiChessPursuitMainScene:StopBossEffectBloodUpdateTimer() + if self.BossEffectBloodUpdateTimer then + XScheduleManager.UnSchedule(self.BossEffectBloodUpdateTimer) + self.BossEffectBloodUpdateTimer = nil + self.EffectBloodVolume.gameObject:SetActiveEx(false) + end +end + +function XUiChessPursuitMainScene:FinishLoseuiClose() + if self.CurrentActionMachine and self.CurrentActionMachine:GetActionType() == XDataCenter.ChessPursuitManager.ChessPursuitSyncActionType.EndBattle then + self.CurrentActionMachine:OnExit() + end + + local chessPursuitMapDb = XDataCenter.ChessPursuitManager.GetChessPursuitMapDb(self.MapId) + local bossPos = chessPursuitMapDb:GetBossPos() + XChessPursuitCtrl.SetSceneActive(true) + local teamGridIndex = XChessPursuitConfig.GetTeamGridIndexByPos(self.MapId, bossPos) + XLuaUiManager.Open("UiChessPursuitFightTips", self.MapId, teamGridIndex, function () + XChessPursuitCtrl.SetSceneActive(false) + end, self.RootUi, self.CSXChessPursuitCtrlCom:GetChessPursuitDrawCamera()) +end + +--@region 主要的逻辑接口 + +function XUiChessPursuitMainScene:Init(params, callBack) + XUiChessPursuitMainScene.Super.Init(self, params) + + self:RequestChessPursuitEnterMapData(self.MapId, function () + self.GameObject:SetActiveEx(true) + self.UiChessPursuitMainAnimQueue = XUiChessPursuitMainAnimQueue.New(self.RootUi) + self.CSXChessPursuitCtrlCom = XChessPursuitCtrl.GetCSXChessPursuitCtrlCom() + self.CSXChessPursuitCtrlCom:Init(self.ChessPursuitMapDb:GetBossPos() , self.ChessPursuitMapDb:GetBossMoveDirection()) + self.UiChessPursuitBuzhenGrids = {} + self.ChessPursuitTeams = {} + self.UiChessPursuitCardGrids = {} + self.UsedToGrid = {} + self.UsedToBoss = {} + + --初始化BOSS、队伍、格子... + self:InitCubes() + self:InitBoss() + self:InitTeam() + self:InitCards() + self:InitSkills() + self:InitSelectTips() + self:InitSkillEffects() + self:InitGridFight() + self:PlayEnableAnimation() + self:StopUpdateTimer() + self:Update() + + self.UpdateTimer = XScheduleManager.ScheduleForever(function() + self:Update() + end, 0.1) + + if callBack then + callBack() + end + end) +end + +function XUiChessPursuitMainScene:Update() + local sceneType = self:GetSceneType() + if sceneType == XChessPursuitCtrl.SCENE_UI_TYPE.BOSS_ROUND then + self:UpdateBossRound() + elseif sceneType == XChessPursuitCtrl.SCENE_UI_TYPE.MY_ROUND then + self:UpdateMyRound() + elseif sceneType == XChessPursuitCtrl.SCENE_UI_TYPE.BUZHEN then + self:UpdateBuZhen() + end + + --放在最后 + self.SceneType = sceneType +end + +--@endregion + +--@region 点击事件 + +function XUiChessPursuitMainScene:AutoAddListener() + self.BtnTongBlue.CallBack = function() self:OnBtnTongBlueClick() end + self.BtnBuChongzhi.CallBack = function() self:OnBtnBuChongzhi() end + self.BtnBuSaodang.CallBack = function() self:OnBtnBuSaodang() end + self.BtnBuJieshu.CallBack = function() self:OnBtnBuJieshu() end + self.BtnShop.CallBack = function() self:OnBtnShop() end + self.BtnAccelerate.CallBack = function() self:OnBtnAccelerate() end + if self.BtnQuickDeploy then + self.BtnQuickDeploy.CallBack = function() self:OnBtnQuickDeploy() end + end + + XEventManager.AddEventListener(XEventId.EVENT_CHESSPURSUIT_BUY_CARD, self.RefreshBuyCard, self) +end + +function XUiChessPursuitMainScene:OnBtnTongBlueClick() + local title = CS.XTextManager.GetText("BfrtDeployTipTitle") + XUiManager.DialogTip(title, CS.XTextManager.GetText("ChessPursuitBuZhenEnterTip"), XUiManager.DialogType.Normal, nil, function() + local ret, msg = XDataCenter.ChessPursuitManager.RequestChessPursuitSetGridTeamData(self.MapId, function () + self:LoadJianTouEffect() + XDataCenter.GuideManager.CheckGuideOpen() + end) + + if not ret then + XUiManager.TipError(msg) + end + end) +end + +function XUiChessPursuitMainScene:OnBtnShop() + if self.SceneType == XChessPursuitCtrl.SCENE_UI_TYPE.MY_ROUND then + --进入商店时设置不可拖动 + local chessPursuitDrawCamera = self.CSXChessPursuitCtrlCom:GetChessPursuitDrawCamera() + chessPursuitDrawCamera:SwitchChessPursuitCameraState(CS.XChessPursuitCameraState.None) + XLuaUiManager.Open("UiChessPursuitShop", self.MapId, function (oldBuyedCards) + chessPursuitDrawCamera:SwitchChessPursuitCameraState(CS.XChessPursuitCameraState.Draw); + self:CheckPlayNewCardsAnima(oldBuyedCards) + end) + else + XLuaUiManager.Open("UiChessPursuitShop", self.MapId, function (oldBuyedCards) + self:CheckPlayNewCardsAnima(oldBuyedCards) + end) + end +end + +function XUiChessPursuitMainScene:CheckPlayNewCardsAnima(oldBuyedCards) + if XTool.IsTableEmpty(oldBuyedCards) then + self.RootUi:PlayAnimation("CardsEnable") + return + end + local chessPursuitMapDb = XDataCenter.ChessPursuitManager.GetChessPursuitMapDb(self.MapId) + local curBuyedCards = chessPursuitMapDb:GetBuyedCards() + if XTool.IsTableEmpty(curBuyedCards) then + return + end + if #oldBuyedCards ~= #curBuyedCards then + self.RootUi:PlayAnimation("CardsEnable") + end +end + +function XUiChessPursuitMainScene:OnBtnQuickDeploy() + XLuaUiManager.Open("UiChessPursuitQuickDeploy", self.MapId) +end + +function XUiChessPursuitMainScene:OnBtnAccelerate() + if self.SceneType ~= XChessPursuitCtrl.SCENE_UI_TYPE.BOSS_ROUND then + return + end + + if self.CurrentActionMachine and self.CurrentActionMachine:GetActionType() == XDataCenter.ChessPursuitManager.ChessPursuitSyncActionType.BeginBattle then + self.IsSkip = false + return + end + + if self.IsSkip then + return + end + + self.IsSkip = true + self.ChessPursuitSyncActionQueue:Clear() +end + +function XUiChessPursuitMainScene:OnBtnBuChongzhi() + if self.SceneType ~= XChessPursuitCtrl.SCENE_UI_TYPE.MY_ROUND then + return + end + XUiManager.DialogTip(CSXTextManagerGetText("TipTitle"), CSXTextManagerGetText("ChessPursuitResetTipContent"), XUiManager.DialogType.Normal, nil, function() + XDataCenter.ChessPursuitManager.RequestChessPursuitResetMapData(function () + self.RootUi:SwtichUI(XChessPursuitCtrl.MAIN_UI_TYPE.SCENE, { + MapId = self.MapId + }, true) + end, self.MapId) + end) +end + +function XUiChessPursuitMainScene:OnBtnBuSaodang(isAutoOpen) + local sceneType = self:GetSceneType() + if sceneType ~= XChessPursuitCtrl.SCENE_UI_TYPE.MY_ROUND then + return + end + + if not self:IsCanSaoDang() then + XUiManager.TipText("ChessPursuitCantAuto") + return + end + + if isAutoOpen then + XDataCenter.ChessPursuitManager.SaveSaoDangIsAlreadyAutoOpen(self.MapId) + end + + XUiManager.DialogTip(CSXTextManagerGetText("TipTitle"), CSXTextManagerGetText("ChessPursuitSaoDangIsFistOpen"), XUiManager.DialogType.Normal, nil, function() + XDataCenter.ChessPursuitManager.RequestChessPursuitAutoClearData(function () + self:RefreshBloodAndCount() + self:PlayBossKillerAnimation() + end) + end) +end + +function XUiChessPursuitMainScene:OnBtnBuJieshu() + if self.SceneType ~= XChessPursuitCtrl.SCENE_UI_TYPE.MY_ROUND then + return + end + + self.BtnCardsGroup:CancelSelect() + + XDataCenter.ChessPursuitManager.RequestChessPursuitEndRoundData(self.UsedToGrid, self.UsedToBoss, function (bossRandomStep) + self.UsedToGrid = {} + self.UsedToBoss = {} + + self:Update() + local cfg = XChessPursuitConfig.GetChessPursuitStepTemplateByStep(bossRandomStep) + if cfg then + self:PlayStep(cfg.Id) + end + end) +end + +--index点击了第几张卡 +function XUiChessPursuitMainScene:OnCardClick(index, btn) + if self.ChessPursuitMapDb:IsClear() then + return + end + + --选中 + self.UiChessPursuitCardGrids[index]:SetDisable(false) + + if self.BtnCardsGroup.CurSelectId ~= CANCEL_SELECT_INDEX then + local cards = self.ChessPursuitMapDb:GetBuyedCards() + local card = cards[index] + local cardCfg = XChessPursuitConfig.GetChessPursuitCardTemplate(card.CardCfgId) + local selectTarge + if cardCfg.TargetType == 0 then + selectTarge = XChessPursuitCtrl.SCENE_SELECT_TARGET.BOSS + elseif cardCfg.TargetType == 1 then + selectTarge = XChessPursuitCtrl.SCENE_SELECT_TARGET.CUBE + elseif cardCfg.TargetType == 2 then + selectTarge = XChessPursuitCtrl.SCENE_SELECT_TARGET.TEAM + end + + self:SwitchSelectTarge(selectTarge) + self.CardDetails.gameObject:SetActiveEx(true) + self.TxtCardDetails.text = cardCfg.Describe + + self:RemoveSelectCard(card) + self:RefreshSkillGridsByTeamp() + self:RefreshSelectTipGrids(selectTarge) + self:CheckChessPursuitBossColliderIsActive(selectTarge) + else + --取消选中 + self:RefreshSelectTipGrids(XChessPursuitCtrl.SCENE_SELECT_TARGET.NONE) + self:SwitchSelectTarge(XChessPursuitCtrl.SCENE_SELECT_TARGET.DEFAULT) + self.CardDetails.gameObject:SetActiveEx(false) + self:CheckChessPursuitBossColliderIsActive() + end + self:CheckOnClickCardHidePanel(self.BtnCardsGroup.CurSelectId, index) +end + +function XUiChessPursuitMainScene:OnCubeClick(gridIndex) + if self.BtnCardsGroup.CurSelectId == CANCEL_SELECT_INDEX then + local targetType = XChessPursuitCtrl.SCENE_SELECT_TARGET.CUBE + local cubeIndex = gridIndex + if self:CanOpenUiChessPursuitBuffTips(targetType, cubeIndex) then + XLuaUiManager.Open("UiChessPursuitBuffTips", self.MapId, targetType, cubeIndex) + end + else + local cards = self.ChessPursuitMapDb:GetBuyedCards() + local card = cards[self.BtnCardsGroup.CurSelectId] + + self:RemoveSelectCard(card) + self:AddSelectCard(card, XChessPursuitCtrl.SCENE_SELECT_TARGET.CUBE, gridIndex) + self:RefreshSkillGridsByTeamp() + self:SwitchSelectTarge(XChessPursuitCtrl.SCENE_SELECT_TARGET.DEFAULT) + self.BtnCardsGroup:CancelSelect() + self:RefreshSelectTipGrids(XChessPursuitCtrl.SCENE_SELECT_TARGET.NONE) + self.CardDetails.gameObject:SetActiveEx(false) + self:CheckOnClickCardHidePanel(CANCEL_SELECT_INDEX) + end +end + +function XUiChessPursuitMainScene:OnCaptainClick(gridIndex) + if self.BtnCardsGroup.CurSelectId == CANCEL_SELECT_INDEX then + --此处 队伍即等于格子类型 + local targetType = XChessPursuitCtrl.SCENE_SELECT_TARGET.CUBE + local cubeIndex = self.UiChessPursuitBuzhenGrids[gridIndex]:GetCubeIndex() + if self:CanOpenUiChessPursuitBuffTips(targetType, cubeIndex) then + XLuaUiManager.Open("UiChessPursuitBuffTips", self.MapId, targetType, cubeIndex) + end + else + local cards = self.ChessPursuitMapDb:GetBuyedCards() + local card = cards[self.BtnCardsGroup.CurSelectId] + + self:RemoveSelectCard(card) + self:AddSelectCard(card, XChessPursuitCtrl.SCENE_SELECT_TARGET.CUBE, self.UiChessPursuitBuzhenGrids[gridIndex]:GetCubeIndex()) + self:RefreshSkillGridsByTeamp() + self:SwitchSelectTarge(XChessPursuitCtrl.SCENE_SELECT_TARGET.DEFAULT) + self.BtnCardsGroup:CancelSelect() + self:RefreshSelectTipGrids(XChessPursuitCtrl.SCENE_SELECT_TARGET.NONE) + self.CardDetails.gameObject:SetActiveEx(false) + self:CheckOnClickCardHidePanel(CANCEL_SELECT_INDEX) + end +end + +function XUiChessPursuitMainScene:OnBossClick() + if self.BtnCardsGroup.CurSelectId == CANCEL_SELECT_INDEX then + local targetType = XChessPursuitCtrl.SCENE_SELECT_TARGET.BOSS + if self:CanOpenUiChessPursuitBuffTips(targetType) then + XLuaUiManager.Open("UiChessPursuitBuffTips", self.MapId, targetType) + end + else + local cards = self.ChessPursuitMapDb:GetBuyedCards() + local card = cards[self.BtnCardsGroup.CurSelectId] + + self:RemoveSelectCard(card) + self:AddSelectCard(card, XChessPursuitCtrl.SCENE_SELECT_TARGET.BOSS) + self:RefreshSkillGridsByTeamp() + self:SwitchSelectTarge(XChessPursuitCtrl.SCENE_SELECT_TARGET.DEFAULT) + self.BtnCardsGroup:CancelSelect() + self:RefreshSelectTipGrids(XChessPursuitCtrl.SCENE_SELECT_TARGET.NONE) + self.CardDetails.gameObject:SetActiveEx(false) + self:CheckChessPursuitBossColliderIsActive() + self:CheckOnClickCardHidePanel(CANCEL_SELECT_INDEX) + end +end + +--选择卡牌中隐藏布局和按钮 +function XUiChessPursuitMainScene:CheckOnClickCardHidePanel(selectedCardId, btnCardsIndex) + if not self.ChessPursuitMapDb then + return + end + + local isHide = selectedCardId ~= CANCEL_SELECT_INDEX + self.RightButtonGroup.gameObject:SetActiveEx(not isHide) + self.Shop.gameObject:SetActiveEx(not isHide) + self.RootUi:SetBtnHelpIsHide(not isHide) + + local cards = self.ChessPursuitMapDb:GetBuyedCards() + for i = 1, XChessPursuitCtrl.CARD_MAX_COUNT do + local cardGrid = self.UiChessPursuitCardGrids[i] + if cardGrid then + local card = cards[i] + if isHide and btnCardsIndex ~= i then + cardGrid:SetActive(false) + else + cardGrid:SetActive(card and true or false) + end + end + end +end + +function XUiChessPursuitMainScene:AddEventListener() + XEventManager.AddEventListener(XEventId.EVENT_CHESSPURSUIT_SAVETEAM, self.RefreshTeam, self) +end + +function XUiChessPursuitMainScene:RemoveEventListener() + XEventManager.RemoveEventListener(XEventId.EVENT_CHESSPURSUIT_SAVETEAM, self.RefreshTeam, self) +end +--@endregion + +--@region 初始化 + +function XUiChessPursuitMainScene:InitBoss() + self.ChessPursuitBoss = XChessPursuitBoss.New() + local chessPursuitScene = XChessPursuitSceneManager.GetCurrentScene() + local sceneGameObject = chessPursuitScene:GetSceneGameObject() + + self.ChessPursuitBoss:LoadBoss(self.ChessPursuitMapBoss:GetId(), sceneGameObject.transform:Find("Playmaker/ChessPieces")) + self.ChessPursuitBoss:AddClick(function () + self:OnBossClick() + end) + + if self.ChessPursuitMapDb:IsClear() then + self.ChessPursuitBoss.GameObject:SetActiveEx(false) + end +end + +function XUiChessPursuitMainScene:InitTeam() + self.TeamHeadNode.gameObject:SetActiveEx(false) + local config = XChessPursuitConfig.GetChessPursuitMapTemplate(self.MapId) + + --表的index从0开始 + for teamGridIndex,cubeIndex in ipairs(config.TeamGrid) do + local grid = CSUnityEngineObjectInstantiate(self.TeamHeadNode, self.PanelArrangment.transform) + local uiChessPursuitBuzhenGrid = XUiChessPursuitBuzhenGrid.New(grid, self, cubeIndex+1, teamGridIndex, self.MapId) + table.insert(self.UiChessPursuitBuzhenGrids, uiChessPursuitBuzhenGrid) + table.insert(self.ChessPursuitTeams, XChessPursuitTeam.New(cubeIndex+1, teamGridIndex, self.MapId)) + + uiChessPursuitBuzhenGrid:Init() + end + + self:RefreshTeam() +end + +function XUiChessPursuitMainScene:InitCubes() + self.ChessPursuitCubes = XChessPursuitCtrl.GetChessPursuitCubes() + + for i,chessPursuitCube in ipairs(self.ChessPursuitCubes) do + chessPursuitCube:AddClick(function () + self:OnCubeClick(i) + end) + end +end + +function XUiChessPursuitMainScene:InitSelectTips() + self.UiChessPursuitSelectTipGrids = {} + local config = XChessPursuitConfig.GetChessPursuitMapTemplate(self.MapId) + + --表的index从0开始 + for teamGridIndex,cubeIndex in ipairs(config.TeamGrid) do + local grid = CSUnityEngineObjectInstantiate(self.SelectTips, self.PanelArrangment.transform) + local uiChessPursuitSelectTipGrid = XUiChessPursuitSelectTipGrid.New(grid, self, cubeIndex+1, self.MapId, XChessPursuitCtrl.SCENE_SELECT_TARGET.CUBE) + table.insert(self.UiChessPursuitSelectTipGrids, uiChessPursuitSelectTipGrid) + end + + local grid = CSUnityEngineObjectInstantiate(self.SelectTips, self.PanelArrangment.transform) + local uiChessPursuitSelectTipGrid = XUiChessPursuitSelectTipGrid.New(grid, self, nil, self.MapId, XChessPursuitCtrl.SCENE_SELECT_TARGET.BOSS) + self.UiChessPursuitSelectTipGridBoss = uiChessPursuitSelectTipGrid +end + +function XUiChessPursuitMainScene:InitGridFight() + local grid = CSUnityEngineObjectInstantiate(self.GridFight, self.PanelArrangment.transform) + local uiChessPursuitGridFight = XUiChessPursuitGridFight.New(grid, self, self.MapId) + self.UiChessPursuitGridFight = uiChessPursuitGridFight +end + +function XUiChessPursuitMainScene:InitSkills() + self.UiChessPursuitSkillGrids = {} + + for cubeIndex,chessPursuitCube in ipairs(self.ChessPursuitCubes) do + local grid = CSUnityEngineObjectInstantiate(self.SkillsNode, self.PanelArrangment.transform) + local uiChessPursuitSkillGrid = XUiChessPursuitSkillGrid.New(grid, self, cubeIndex, self.MapId, XChessPursuitCtrl.SCENE_SELECT_TARGET.CUBE) + table.insert(self.UiChessPursuitSkillGrids, uiChessPursuitSkillGrid) + end + + local grid = CSUnityEngineObjectInstantiate(self.SkillsNode, self.PanelArrangment.transform) + local uiChessPursuitSkillGrid = XUiChessPursuitSkillGrid.New(grid, self, nil, self.MapId, XChessPursuitCtrl.SCENE_SELECT_TARGET.BOSS) + self.UiChessPursuitSkillGridBoss = uiChessPursuitSkillGrid +end + +function XUiChessPursuitMainScene:InitSkillEffects() + local config = XChessPursuitConfig.GetChessPursuitMapTemplate(self.MapId) + self.UiChessPursuitSkillEffectGrids = {} + + for cubeIndex,chessPursuitCube in ipairs(self.ChessPursuitCubes) do + local uiChessPursuitSkillEffectGrid = XUiChessPursuitSkillEffectGrid.New(self, cubeIndex, XChessPursuitCtrl.SCENE_SELECT_TARGET.CUBE, self.MapId) + table.insert(self.UiChessPursuitSkillEffectGrids, uiChessPursuitSkillEffectGrid) + end + + local uiChessPursuitSkillEffectGrid = XUiChessPursuitSkillEffectGrid.New(self, nil, XChessPursuitCtrl.SCENE_SELECT_TARGET.BOSS, self.MapId) + table.insert(self.UiChessPursuitSkillEffectGrids, uiChessPursuitSkillEffectGrid) +end + +function XUiChessPursuitMainScene:InitGuideGrid() + local teamGridIndex = 1 + + if self.ChessPursuitTeams[teamGridIndex].Transform then + local grid = CSUnityEngineObjectInstantiate(self.GuideTeamClick, self.PanelArrangment.transform) + self.UiChessPursuitGuideGrid = XUiChessPursuitGuideGrid.New(grid, self, self.ChessPursuitTeams[teamGridIndex].Transform) + self.UiChessPursuitGuideGrid:AddClick(function () + self:OnCaptainClick(teamGridIndex) + end) + end +end + +function XUiChessPursuitMainScene:InitCards() + local btns = {} + for i=1, XChessPursuitCtrl.CARD_MAX_COUNT do + local uiChessPursuitCardGrid = XUiChessPursuitCardGrid.New(self["BtnCards" .. i], self, i, self.MapId) + table.insert(self.UiChessPursuitCardGrids, uiChessPursuitCardGrid) + table.insert(btns, self["BtnCards" .. i]) + end + + self.BtnCardsGroup:Init(btns, function(index) + self:OnCardClick(index, btns[index]) + end) + + --一开始什么都不选 + self.BtnCardsGroup:CancelSelect() + self.BtnCardsGroup.CurSelectId = CANCEL_SELECT_INDEX +end + +--@endregion + +--@region XUiChessPursuitAction状态机 + +function XUiChessPursuitMainScene:UpdateActionMachine() + self:UpdateCurrentActionMachine() + + if not self.CurrentActionMachine then + return + end + + self.CurrentActionMachine:Update() + + if self.CurrentActionMachine:GetState() == "finish" then + self.CurrentActionMachine:Dispose() + self.CurrentActionMachine = nil + end +end + +function XUiChessPursuitMainScene:UpdateCurrentActionMachine() + if self.CurrentActionMachine then + if self.IsSkip and self.CurrentActionMachine:GetActionType() == XDataCenter.ChessPursuitManager.ChessPursuitSyncActionType.BeginBattle then + self.IsSkip = false + end + return + end + + if self.IsSkiping then + return + end + + --正在跳转 + if self.IsSkip then + self.IsSkiping = true + self:RequestChessPursuitEnterMapData(self.MapId, function () + self.CSXChessPursuitCtrlCom:Init(self.ChessPursuitMapDb:GetBossPos() , self.ChessPursuitMapDb:GetBossMoveDirection()) + self:RefreshTeamActive() + self.IsSkip = false + self.IsSkiping = false + end) + return + end + + local chessPursuitSyncAction = self.ChessPursuitSyncActionQueue:Pop() + if chessPursuitSyncAction then + self.CurrentActionMachine = XUiCPActionMachine.Create(chessPursuitSyncAction:GetType(), { + UiRoot = self, + ParentUiRoot = self.RootUi, + ChessPursuitSyncAction = chessPursuitSyncAction, + MapId = self.MapId, + BossId = self.ChessPursuitMapBoss:GetId() + }) + end +end + +--@endregion + +--@region 各回合的主要刷新逻辑 + +function XUiChessPursuitMainScene:UpdateBossRound() + if self.SceneType == XChessPursuitCtrl.SCENE_UI_TYPE.BOSS_ROUND then + --等待动画结束再执行下一个动作 + if self.UiChessPursuitMainAnimQueue:GetCount() > 0 then + self.UiChessPursuitMainAnimQueue:PopAndPlay() + else + self:UpdateActionMachine() + end + + self.UiChessPursuitGridFight:RefreshPos() + self:RefreshSkillGridsPos() + self:RefreshBuzhenGridsPos() + return + else + self.UiChessPursuitMainAnimQueue:Push("PanelTipsEnemyRoundEnable", function() + self.PanelTipsEnemyRound.gameObject:SetActiveEx(true) + end,function () + self.PanelTipsEnemyRound.gameObject:SetActiveEx(false) + end) + + self:RefreshUiActive(XChessPursuitCtrl.SCENE_UI_TYPE.BOSS_ROUND) + self:SwitchSelectTarge(XChessPursuitCtrl.SCENE_SELECT_TARGET.DEFAULT) + self:RefreshSkillGrids(true) + self:RefreshCard(XChessPursuitCtrl.SCENE_UI_TYPE.BOSS_ROUND) + self:RefreshBloodAndCount() + + local chessPursuitDrawCamera = self.CSXChessPursuitCtrlCom:GetChessPursuitDrawCamera() + chessPursuitDrawCamera:SwitchChessPursuitCameraState(CS.XChessPursuitCameraState.Follow); + chessPursuitDrawCamera:SwitchFieldOfViewState(CS.XFieldOfView.Near) + + for i,uiChessPursuitBuzhenGrid in ipairs(self.UiChessPursuitBuzhenGrids) do + uiChessPursuitBuzhenGrid:UpdateBossHurMax() + end + + self:RefreshSkillEffect() + self:RefreshSelectTipGrids(XChessPursuitCtrl.SCENE_SELECT_TARGET.NONE) + end +end + +--自己回合界面刷新 +function XUiChessPursuitMainScene:UpdateMyRound() + if self.SceneType == XChessPursuitCtrl.SCENE_UI_TYPE.MY_ROUND then + self.UiChessPursuitGridFight:RefreshPos() + self:RefreshSelectTipGridsPos() + self:RefreshSkillGridsPos() + self:RefreshBuzhenGridsPos() + if self.UiChessPursuitGuideGrid then + self.UiChessPursuitGuideGrid:RefreshPos() + end + return + else + self:RefreshTeamActive() + self:RefreshSkillEffect() + self.PanelTipsRound.gameObject:SetActiveEx(true) + self.RootUi:PlayAnimationWithMask("PanelMyRoundEnable", function () + self.PanelTipsRound.gameObject:SetActiveEx(false) + end) + + self.CardDetails.gameObject:SetActiveEx(false) + self:RefreshUiActive(XChessPursuitCtrl.SCENE_UI_TYPE.MY_ROUND) + self:SwitchSelectTarge(XChessPursuitCtrl.SCENE_SELECT_TARGET.DEFAULT) + self:RefreshSkillGrids(true) + self:RefreshBloodAndCount() + + local chessPursuitDrawCamera = self.CSXChessPursuitCtrlCom:GetChessPursuitDrawCamera() + chessPursuitDrawCamera:SwitchChessPursuitCameraState(CS.XChessPursuitCameraState.Draw); + chessPursuitDrawCamera:SwitchFieldOfViewState(CS.XFieldOfView.Near) + self:RefreshCard(XChessPursuitCtrl.SCENE_UI_TYPE.MY_ROUND) + + for i,uiChessPursuitBuzhenGrid in ipairs(self.UiChessPursuitBuzhenGrids) do + uiChessPursuitBuzhenGrid:UpdateBossHurMax() + end + + local isCanSaoDang = XChessPursuitConfig.IsChessPursuitMapCanAutoClear(self.MapId) + self.BtnBuSaodang.gameObject:SetActiveEx(isCanSaoDang) + if isCanSaoDang then + self:OpenSaoDangDangTips() + end + self:CheckChessPursuitBossColliderIsActive() + end +end + +--布阵回合界面刷新 +function XUiChessPursuitMainScene:UpdateBuZhen() + if self.SceneType == XChessPursuitCtrl.SCENE_UI_TYPE.BUZHEN then + self:RefreshBuzhenGridsPos() + return + else + self:RefreshUiActive(XChessPursuitCtrl.SCENE_UI_TYPE.BUZHEN) + self:RefreshTeam() + self:SwitchSelectTarge(XChessPursuitCtrl.SCENE_SELECT_TARGET.NONE) + self:RefreshSkillGrids(false) + + local chessPursuitDrawCamera = self.CSXChessPursuitCtrlCom:GetChessPursuitDrawCamera() + chessPursuitDrawCamera:SwitchChessPursuitCameraState(CS.XChessPursuitCameraState.None); + chessPursuitDrawCamera:SwitchFieldOfViewState(CS.XFieldOfView.Far) + end +end + +--@endregion + +--@region 各种子UI信息Refresh + +--控制各个回合的界面整体显隐 +function XUiChessPursuitMainScene:RefreshUiActive(sceneType) + if self.SceneType == sceneType then + return + end + + if sceneType == XChessPursuitCtrl.SCENE_UI_TYPE.BOSS_ROUND then + self.PanelBossRound.gameObject:SetActiveEx(true) + self.PanelMyRound.gameObject:SetActiveEx(false) + self.PanelBuzhen.gameObject:SetActiveEx(false) + self.PanelCare.gameObject:SetActiveEx(true) + elseif sceneType == XChessPursuitCtrl.SCENE_UI_TYPE.MY_ROUND then + self.PanelBossRound.gameObject:SetActiveEx(false) + self.PanelMyRound.gameObject:SetActiveEx(true) + self.PanelBuzhen.gameObject:SetActiveEx(false) + self.PanelCare.gameObject:SetActiveEx(true) + elseif sceneType == XChessPursuitCtrl.SCENE_UI_TYPE.BUZHEN then + self.PanelBossRound.gameObject:SetActiveEx(false) + self.PanelMyRound.gameObject:SetActiveEx(false) + self.PanelBuzhen.gameObject:SetActiveEx(true) + self.PanelCare.gameObject:SetActiveEx(false) + end + + local disable = sceneType ~= XChessPursuitCtrl.SCENE_UI_TYPE.MY_ROUND + local needCallBack = not disable + self.BtnBuChongzhi:SetDisable(disable, needCallBack) + + local bossIsClear = self.ChessPursuitMapDb:IsClear() + disable = sceneType ~= XChessPursuitCtrl.SCENE_UI_TYPE.MY_ROUND or bossIsClear + needCallBack = not disable + self.BtnBuJieshu:SetDisable(disable, needCallBack) + self.BtnBuSaodang:SetDisable(disable, needCallBack) + self.BtnShop:SetDisable(disable, needCallBack) + for _, cardGrid in ipairs(self.UiChessPursuitCardGrids) do + cardGrid:SetDisable(disable) + end + + self.CardMyRound.gameObject:SetActiveEx(sceneType == XChessPursuitCtrl.SCENE_UI_TYPE.MY_ROUND) + self.CardBossRound.gameObject:SetActiveEx(sceneType == XChessPursuitCtrl.SCENE_UI_TYPE.BOSS_ROUND) + + for i,uiChessPursuitBuzhenGrid in ipairs(self.UiChessPursuitBuzhenGrids) do + uiChessPursuitBuzhenGrid:SetActive(sceneType) + end +end + +function XUiChessPursuitMainScene:RefreshBloodAndCount() + local ration = self.ChessPursuitMapDb:GetBossHp() / self.ChessPursuitMapBoss:GetInitHp() + local itemIcon = XItemConfigs.GetItemIconById(XChessPursuitConfig.SHOP_COIN_ITEM_ID) + local mapCfg = XChessPursuitConfig.GetChessPursuitMapTemplate(self.MapId) + local bossCfg = XChessPursuitConfig.GetChessPursuitBossTemplate(mapCfg.BossId) + + self.HeadObject:SetRawImage(bossCfg.HeadIcon) + -- 如果BOSS发生扣血播放一下特效(abs防止浮点数误差) + if math.abs(self.ImgExpSlider.fillAmount - ration) > 0.0001 then + self:StopBossEffectBloodUpdateTimer() + self.EffectBloodVolume.gameObject:SetActiveEx(true) + self.BossEffectBloodUpdateTimer = XScheduleManager.ScheduleOnce(function() + self.EffectBloodVolume.gameObject:SetActiveEx(false) + end, 1500) + end + + self.ImgExpSlider.fillAmount = ration + + local bloodVolume = ration * 100 + if bloodVolume > 0 and bloodVolume < 0.01 then + bloodVolume = 0.01 + end + self.TxtBloodVolume.text = string.format("%.2f%%", bloodVolume) + + self:RefreshCoinCount() + self.RImgShopIcon:SetRawImage(itemIcon) + self.BossKilled.gameObject:SetActiveEx(self.ChessPursuitMapDb:IsClear()) + self.ImgBossDie.gameObject:SetActiveEx(self.ChessPursuitMapDb:IsClear()) + self:RefreshTxtNumberBattles(self.ChessPursuitMapDb:GetBossBattleCount()) + self.TxtBossRule1.text = CSXTextManagerGetText("ChessPursuitBossStep", self.ChessPursuitMapBoss:GetBossStepMin(), self.ChessPursuitMapBoss:GetBossStepMax()) + local mapsCfg = XChessPursuitConfig.GetChessPursuitMapTemplate(self.MapId) + if mapsCfg.Stage == XChessPursuitCtrl.MAIN_UI_TYPE.FIGHT_HARD then + self.TxtBossRule2.text = CSXTextManagerGetText("ChessPursuitBossMaxRatio", CSXTextManagerGetText("ChessPursuitInfinite")) + else + local maxRatio = self.ChessPursuitMapBoss:GetMaxHpRatio() + maxRatio = string.format("%.0f%%", maxRatio * 100) + self.TxtBossRule2.text = CSXTextManagerGetText("ChessPursuitBossMaxRatio", maxRatio) + end +end + +function XUiChessPursuitMainScene:RefreshTxtNumberBattles(battleCount) + local digits = self:GetIntDigits(battleCount) + local defaultFontSizeDigits = 3 --3位数以内的都用默认的字体大小 + local fontSize = digits <= defaultFontSizeDigits and TxtNumberBattlesDefaultFontSize or math.max(TxtNumberBattlesDefaultFontSize - ((digits - defaultFontSizeDigits) * 6), 1) + self.TxtNumberBattles.text = battleCount + self.TxtNumberBattles.fontSize = fontSize +end + +function XUiChessPursuitMainScene:GetIntDigits(number) + if not number then + return 0 + end + + local digits = 0 + local numberTemp = number + while numberTemp > 0 do + numberTemp = math.floor(numberTemp / 10) + digits = digits + 1 + end + + return digits +end + +function XUiChessPursuitMainScene:RefreshCoinCount() + self.TxtShopCoin.text = self.ChessPursuitMapDb:GetCoin() +end + +--先从服务端数据里拿,再去临时数据里拿 +function XUiChessPursuitMainScene:RefreshTeam() + local sceneType = self:GetSceneType() + for teamGridIndex,uiChessPursuitBuzhenGrids in ipairs(self.UiChessPursuitBuzhenGrids) do + local teamMapDb = self.ChessPursuitMapDb:GetTeamCharacterIds(teamGridIndex) + if next(teamMapDb) then + uiChessPursuitBuzhenGrids:UpdateTeamHeadIconByMapDb(sceneType) + local captainCharacterId = self.ChessPursuitMapDb:GetGridTeamCaptainCharacterIdIdByGridId(teamGridIndex) + self.ChessPursuitTeams[teamGridIndex]:LoadCaptainCharacter(captainCharacterId) + self.ChessPursuitTeams[teamGridIndex]:AddClick(function() + self:OnCaptainClick(teamGridIndex) + end) + else + local tempTeamData = XDataCenter.ChessPursuitManager.GetSaveTempTeamData(self.MapId, teamGridIndex) + local captainId = tempTeamData and tempTeamData.TeamData[tempTeamData.CaptainPos] or 0 + uiChessPursuitBuzhenGrids:UpdateTeamHeadIconByTempTeam(sceneType) + if captainId > 0 then + local captainCharacterId = XRobotManager.CheckIdToCharacterId(captainId) + self.ChessPursuitTeams[teamGridIndex]:LoadCaptainCharacter(captainCharacterId) + self.ChessPursuitTeams[teamGridIndex]:AddClick(function() + self:OnCaptainClick(teamGridIndex) + end) + else + self.ChessPursuitTeams[teamGridIndex]:Dispose() + end + end + end + + self:InitGuideGrid() +end + +function XUiChessPursuitMainScene:RefreshTeamActive(active) + if self.ChessPursuitMapDb:IsClear() then + return + end + + self.UiChessPursuitGridFight:SetActiveEx(false) + + for i,chessPursuitTeam in ipairs(self.ChessPursuitTeams) do + local tempActive = active or (chessPursuitTeam:GetCubeIndex() ~= (self.ChessPursuitMapDb:GetBossPos() + 1)) + chessPursuitTeam:SetActive(tempActive) + + if not tempActive then + self.UiChessPursuitGridFight:SetActiveEx(true) + end + end +end + +function XUiChessPursuitMainScene:CheckChessPursuitBossColliderIsActive(selectTarget) + if self.ChessPursuitMapDb:IsClear() then + return + end + + if selectTarget == XChessPursuitCtrl.SCENE_SELECT_TARGET.BOSS then + self.ChessPursuitBoss:SetColliderActive(true) + return + elseif selectTarget == XChessPursuitCtrl.SCENE_SELECT_TARGET.CUBE then + self.ChessPursuitBoss:SetColliderActive(false) + return + end + + local bossPos = self.ChessPursuitMapDb:GetBossPos() + 1 + for i, chessPursuitTeam in ipairs(self.ChessPursuitTeams) do + if chessPursuitTeam:GetCubeIndex() == bossPos then + self.ChessPursuitBoss:SetColliderActive(false) + return + end + end + self.ChessPursuitBoss:SetColliderActive(true) +end + +function XUiChessPursuitMainScene:RefreshBuyCard(sceneType) + self:RefreshCoinCount() + self:RefreshCard() +end + +function XUiChessPursuitMainScene:RefreshCard(sceneType) + sceneType = sceneType or self.SceneType + local cards = self.ChessPursuitMapDb:GetBuyedCards() + for i=1,XChessPursuitCtrl.CARD_MAX_COUNT do + self.UiChessPursuitCardGrids[i]:Refresh(self.UsedToGrid, self.UsedToBoss, sceneType) + end + + self:RefreshBtnCardsDi(sceneType) +end + +function XUiChessPursuitMainScene:RefreshSelectTipGrids(selectTarget) + for i,v in ipairs(self.UiChessPursuitSelectTipGrids) do + v:SetActiveEx(selectTarget == XChessPursuitCtrl.SCENE_SELECT_TARGET.TEAM) + end + + self.UiChessPursuitSelectTipGridBoss:SetActiveEx(selectTarget == XChessPursuitCtrl.SCENE_SELECT_TARGET.BOSS) + + self:RefreshTeamActive(selectTarget == XChessPursuitCtrl.SCENE_SELECT_TARGET.TEAM) +end + +function XUiChessPursuitMainScene:RefreshSkillEffect() + for i, v in ipairs(self.UiChessPursuitSkillEffectGrids) do + v:Refresh() + end +end + +function XUiChessPursuitMainScene:LoadJianTouEffect() + for i, v in ipairs(self.UiChessPursuitSkillEffectGrids) do + v:LoadJianTou() + end + self.DestroyArrowEffectUpdateTimer = CS.XScheduleManager.ScheduleOnce(function() + self:DestroyArrowEffect() + end, DelayDestroyArrowEffectMilliSecond) +end + +function XUiChessPursuitMainScene:DestroyArrowEffect() + for i, v in ipairs(self.UiChessPursuitSkillEffectGrids) do + v:DestroyArrow() + end +end + +function XUiChessPursuitMainScene:RefreshSkillGrids(isShow) + if isShow then + for i,v in ipairs(self.UiChessPursuitSkillGrids) do + v:Refresh() + end + + self.UiChessPursuitSkillGridBoss:Refresh() + else + for i,v in ipairs(self.UiChessPursuitSkillGrids) do + v:SetActiveEx(false) + end + + self.UiChessPursuitSkillGridBoss:SetActiveEx(false) + end +end + +function XUiChessPursuitMainScene:RefreshSkillGridsByTeamp() + local tmCards = {} + for i,v in ipairs(self.ChessPursuitMapDb:GetBuyedCards()) do + tmCards[v.Id] = v + end + + for i,v in ipairs(self.UiChessPursuitSkillGrids) do + local cardIds = self.UsedToGrid[i-1] + if cardIds then + local cards = {} + for k,cardId in pairs(cardIds) do + table.insert(cards, tmCards[cardId]) + end + v:RefreshByTemp(cards) + else + v:RefreshByTemp(nil) + end + end + + if next(self.UsedToBoss) then + local cards = {} + for i,cardId in ipairs(self.UsedToBoss) do + table.insert(cards, tmCards[cardId]) + end + self.UiChessPursuitSkillGridBoss:RefreshByTemp(cards) + else + self.UiChessPursuitSkillGridBoss:RefreshByTemp(nil) + end +end + +function XUiChessPursuitMainScene:RefreshSelectTipGridsPos() + for i,v in ipairs(self.UiChessPursuitSelectTipGrids) do + v:RefreshPos() + end + + self.UiChessPursuitSelectTipGridBoss:RefreshPos() +end + +function XUiChessPursuitMainScene:RefreshSkillGridsPos() + for i,v in ipairs(self.UiChessPursuitSkillGrids) do + v:RefreshPos() + end + + self.UiChessPursuitSkillGridBoss:RefreshPos() +end + +function XUiChessPursuitMainScene:RefreshBuzhenGridsPos() + if self.UiChessPursuitBuzhenGrids then + for i,uiChessPursuitBuzhenGrid in ipairs(self.UiChessPursuitBuzhenGrids) do + uiChessPursuitBuzhenGrid:RefreshPos() + end + end +end + +function XUiChessPursuitMainScene:RefreshBtnCardsDi(sceneType) + self.BtnCardsDi:SetDisable(sceneType == XChessPursuitCtrl.SCENE_UI_TYPE.BOSS_ROUND) + local cards = self.ChessPursuitMapDb:GetBuyedCards() + if sceneType == XChessPursuitCtrl.SCENE_UI_TYPE.BOSS_ROUND then + self.BtnCardsDi.gameObject:SetActiveEx(true) + self.CardsNone.gameObject:SetActiveEx(false) + else + self.BtnCardsDi.gameObject:SetActiveEx(next(cards)) + self.CardsNone.gameObject:SetActiveEx(not next(cards)) + end +end +--@endregion + +--@region 通用函数 + +function XUiChessPursuitMainScene:SwitchSelectTarge(selectTarge) + if selectTarge == XChessPursuitCtrl.SCENE_SELECT_TARGET.BOSS then + self.CSXChessPursuitCtrlCom:SetCameraMask(true) + + self.ChessPursuitBoss:HighLight() + for i,chessPursuitTeam in ipairs(self.ChessPursuitTeams) do + chessPursuitTeam:SetTransparent() + end + + for i,chessPursuitCube in ipairs(self.ChessPursuitCubes) do + chessPursuitCube:None() + end + + for i,uiChessPursuitBuzhenGrid in ipairs(self.UiChessPursuitBuzhenGrids) do + uiChessPursuitBuzhenGrid.GameObject:SetActiveEx(false) + end + elseif selectTarge == XChessPursuitCtrl.SCENE_SELECT_TARGET.TEAM then + self.CSXChessPursuitCtrlCom:SetCameraMask(true) + + self.ChessPursuitBoss:SetTransparent() + for i,chessPursuitTeam in ipairs(self.ChessPursuitTeams) do + chessPursuitTeam:HighLight() + end + + for i,chessPursuitCube in ipairs(self.ChessPursuitCubes) do + chessPursuitCube:None() + end + + for i,uiChessPursuitBuzhenGrid in ipairs(self.UiChessPursuitBuzhenGrids) do + uiChessPursuitBuzhenGrid.GameObject:SetActiveEx(false) + end + elseif selectTarge == XChessPursuitCtrl.SCENE_SELECT_TARGET.CUBE then + self.CSXChessPursuitCtrlCom:SetCameraMask(true) + + self.ChessPursuitBoss:SetTransparent() + for i,chessPursuitTeam in ipairs(self.ChessPursuitTeams) do + chessPursuitTeam:SetTransparent() + end + + for i,chessPursuitCube in ipairs(self.ChessPursuitCubes) do + chessPursuitCube:HighLight() + end + + for i,uiChessPursuitBuzhenGrid in ipairs(self.UiChessPursuitBuzhenGrids) do + uiChessPursuitBuzhenGrid.GameObject:SetActiveEx(false) + end + elseif selectTarge == XChessPursuitCtrl.SCENE_SELECT_TARGET.DEFAULT then + self.CSXChessPursuitCtrlCom:SetCameraMask(false) + + self.ChessPursuitBoss:Default() + for i,chessPursuitTeam in ipairs(self.ChessPursuitTeams) do + chessPursuitTeam:Default() + end + + for i,chessPursuitCube in ipairs(self.ChessPursuitCubes) do + chessPursuitCube:Default() + end + + for i,uiChessPursuitBuzhenGrid in ipairs(self.UiChessPursuitBuzhenGrids) do + uiChessPursuitBuzhenGrid.GameObject:SetActiveEx(true) + end + else + self.CSXChessPursuitCtrlCom:SetCameraMask(false) + + self.ChessPursuitBoss:None() + for i,chessPursuitTeam in ipairs(self.ChessPursuitTeams) do + chessPursuitTeam:None() + end + + for i,chessPursuitCube in ipairs(self.ChessPursuitCubes) do + chessPursuitCube:None() + end + + for i,uiChessPursuitBuzhenGrid in ipairs(self.UiChessPursuitBuzhenGrids) do + uiChessPursuitBuzhenGrid.GameObject:SetActiveEx(true) + end + end +end + +function XUiChessPursuitMainScene:GetSceneType() + --状态机未执行完即返回 + if self.CurrentActionMachine then + return self.SceneType + end + -- 当前是BOSS回合,需要等到EndRound才能切换到自己的回合 + if self.SceneType == XChessPursuitCtrl.SCENE_UI_TYPE.BOSS_ROUND then + if self.EndRound and self.ChessPursuitSyncActionQueue:GetCount() <= 0 then + return XChessPursuitCtrl.SCENE_UI_TYPE.MY_ROUND + else + return XChessPursuitCtrl.SCENE_UI_TYPE.BOSS_ROUND + end + else + --布阵阶段 + if self.ChessPursuitMapDb:NeedBuZhen() then + return XChessPursuitCtrl.SCENE_UI_TYPE.BUZHEN + end + + --BOSS的ACTION是否完了 + if self.ChessPursuitSyncActionQueue:GetCount() > 0 then + self:SetEndRound(false) + return XChessPursuitCtrl.SCENE_UI_TYPE.BOSS_ROUND + end + + return XChessPursuitCtrl.SCENE_UI_TYPE.MY_ROUND + end +end + +function XUiChessPursuitMainScene:PlayStep(stepId, callBack) + local cfg = XChessPursuitConfig.GetChessPursuitStepTemplate(stepId) + if not cfg then + return + end + self.RImgEffectSteps:SetRawImage(cfg.Icon) + self.UiChessPursuitMainAnimQueue:Push("RImgEffectEnable", function() + self.PanelSteps.gameObject:SetActiveEx(true) + end, function () + self.RootUi:PlayAnimation("RImgEffectDisable", function () + self.PanelSteps.gameObject:SetActiveEx(false) + if callBack then + callBack() + end + end) + end) +end + +function XUiChessPursuitMainScene:AddSelectCard(card, selectTarget, gridIndex) + if selectTarget == XChessPursuitCtrl.SCENE_SELECT_TARGET.BOSS then + table.insert(self.UsedToBoss, card.Id) + elseif selectTarget == XChessPursuitCtrl.SCENE_SELECT_TARGET.CUBE then + --服务端index从0开始 + local tempGridIndex = gridIndex - 1 + if not self.UsedToGrid[tempGridIndex] then + self.UsedToGrid[tempGridIndex] = {} + end + + table.insert(self.UsedToGrid[tempGridIndex], card.Id) + end + + for i,uiChessPursuitSkillEffectGrids in ipairs(self.UiChessPursuitSkillEffectGrids) do + if selectTarget == uiChessPursuitSkillEffectGrids:GetTargetType() then + if uiChessPursuitSkillEffectGrids:GetTargetType() == XChessPursuitCtrl.SCENE_SELECT_TARGET.BOSS then + uiChessPursuitSkillEffectGrids:LoadUseCardEffect() + break + else + if gridIndex == i then + uiChessPursuitSkillEffectGrids:LoadUseCardEffect() + break + end + end + end + end + + for i,v in ipairs(self.ChessPursuitMapDb:GetBuyedCards()) do + if card.Id == v.Id then + self.UiChessPursuitCardGrids[i]:SetDisable(true) + break + end + end +end + +function XUiChessPursuitMainScene:RemoveSelectCard(card) + if not card then + return + end + for gridIndex,list in pairs(self.UsedToGrid) do + for i, cardId in ipairs(list) do + if cardId == card.Id then + table.remove(list, i) + break + end + end + end + + for i,cardId in pairs(self.UsedToBoss) do + if cardId == card.Id then + table.remove(self.UsedToBoss, i) + break + end + end +end + +function XUiChessPursuitMainScene:SetEndRound(vlaue) + self.EndRound = vlaue +end + +--能否扫荡:只要每个点有打过即可 +function XUiChessPursuitMainScene:IsCanSaoDang() + local mapsCfg = XChessPursuitConfig.GetChessPursuitMapTemplate(self.MapId) + if mapsCfg.Stage ~= XChessPursuitCtrl.MAIN_UI_TYPE.FIGHT_HARD then + for i,uiChessPursuitBuzhenGrid in ipairs(self.UiChessPursuitBuzhenGrids) do + if uiChessPursuitBuzhenGrid:GetBossHurMax() <= 0 then + return false + end + end + + return true + else + return false + end +end + +--能扫荡而且造成的伤害达到最大,弹出提示窗 +function XUiChessPursuitMainScene:OpenSaoDangDangTips() + if self.ChessPursuitMapDb:IsClear() then + return + end + + local maxRatio = self.ChessPursuitMapBoss:GetMaxHpRatio() + for i,uiChessPursuitBuzhenGrid in ipairs(self.UiChessPursuitBuzhenGrids) do + if uiChessPursuitBuzhenGrid:GetBossHurMax() < maxRatio then + XDataCenter.ChessPursuitManager.RemoveSaoDangIsAlreadyAutoOpen(self.MapId) + return + end + end + + if XDataCenter.ChessPursuitManager.IsSaoDangAlreadyAutoOpen(self.MapId) then + return + end + + self:OnBtnBuSaodang(true) +end + +function XUiChessPursuitMainScene:PlayEnableAnimation() + local sceneType = self:GetSceneType() + local aniName + if sceneType == XChessPursuitCtrl.SCENE_UI_TYPE.BUZHEN or sceneType == XChessPursuitCtrl.SCENE_UI_TYPE.BOSS_ROUND then + aniName = "PanelBuzhenEnable" + else + aniName = "PanelCareEnable" + end + self.RootUi:PlayAnimationWithMask(aniName) +end + +function XUiChessPursuitMainScene:CanOpenUiChessPursuitBuffTips(targetType, cubeIndex) + local sceneType = self:GetSceneType() + if sceneType == XChessPursuitCtrl.SCENE_UI_TYPE.BUZHEN then + return false + end + + if targetType == XChessPursuitCtrl.SCENE_SELECT_TARGET.BOSS then + local xChessPursuitCardDbList = self.ChessPursuitMapDb:GetBossCardDb() + + if next(xChessPursuitCardDbList) then + return true + else + return false + end + else + local xChessPursuitMapGridCardDb = self.ChessPursuitMapDb:GetGridCardDb() + + for _,v in ipairs(xChessPursuitMapGridCardDb) do + if v.Id == cubeIndex-1 then + local xChessPursuitCardDbList = v.Cards + if next(xChessPursuitCardDbList) then + return true + else + return false + end + end + end + end + + return false +end + +function XUiChessPursuitMainScene:PlayBossKillerAnimation(callBack) + if self.ChessPursuitMapDb:IsClear() then + self.PanelFull.gameObject:SetActiveEx(true) + self.ChessPursuitBoss.GameObject:SetActiveEx(false) + self.RootUi:PlayAnimationWithMask("PanelFullEnable", function () + self.RootUi:PlayAnimationWithMask("PanelFullDisable", function () + self.PanelFull.gameObject:SetActiveEx(false) + if callBack then + callBack() + end + + self.RootUi:OnBtnBackClick() + + local mapsCfg = XChessPursuitConfig.GetChessPursuitMapTemplate(self.MapId) + if mapsCfg.Stage == XChessPursuitCtrl.MAIN_UI_TYPE.FIGHT_DEFAULT then + if XDataCenter.ChessPursuitManager.IsOpenFightHeard() then + XUiManager.TipMsg(CS.XTextManager.GetText("ChessPursuitHardOpen")) + end + end + end) + end) + end +end + +function XUiChessPursuitMainScene:RequestChessPursuitEnterMapData(mapId, callBack) + XDataCenter.ChessPursuitManager.RequestChessPursuitEnterMapData(mapId, function () + local config = XChessPursuitConfig.GetChessPursuitMapTemplate(mapId) + self.ChessPursuitMapDb = XDataCenter.ChessPursuitManager.GetChessPursuitMapDb(mapId) + self.ChessPursuitMapBoss = XDataCenter.ChessPursuitManager.GetChessPursuitMapBoss(config.BossId) + self.ChessPursuitSyncActionQueue = XDataCenter.ChessPursuitManager.GetChessPursuitSyncActionQueue() + + if self.ChessPursuitSyncActionQueue:GetCount() <= 0 then + self:SetEndRound(true) + end + + if callBack then + callBack() + end + end) +end + +--@endregion + +return XUiChessPursuitMainScene \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitMainStage.lua b/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitMainStage.lua new file mode 100644 index 00000000..81c3b166 --- /dev/null +++ b/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitMainStage.lua @@ -0,0 +1,232 @@ +local XUiChessPursuitMainBase = require("XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitMainBase") +local XUiChessPursuitMainStage = XClass(XUiChessPursuitMainBase, "XUiChessPursuitMainStage") +local XUiChessPursuitStageGrid = require("XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitStageGrid") +local XUiChessPursuitPanelFightStage = require("XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitPanelFightStage") +local CSXTextManagerGetText = CS.XTextManager.GetText +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate + +function XUiChessPursuitMainStage:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self.UiChessPursuitStageGrid = {} + + XTool.InitUiObject(self) + self:AutoAddListener() + XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) +end + +function XUiChessPursuitMainStage:Dispose() + self.GameObject:SetActiveEx(false) + for i,uiChessPursuitStageGrid in pairs(self.UiChessPursuitStageGrid) do + uiChessPursuitStageGrid:Dispose() + end + + self.UiChessPursuitStageGrid = {} +end + +function XUiChessPursuitMainStage:Init(params, callBack) + XUiChessPursuitMainStage.Super.Init(self, params) + self.GameObject:SetActiveEx(true) + self.RootUi:PlayAnimationWithMask("PanelStage") + + self:Update() + if callBack then + callBack() + end +end + +--@region 事件绑定 + +function XUiChessPursuitMainStage:AutoAddListener() + XUiHelper.RegisterClickEvent(self, self.BtnRank, self.OnBtnRankClick) + XUiHelper.RegisterClickEvent(self, self.BtnChessPursuitItem, self.OnBtnChessPursuitItemClick) + XUiHelper.RegisterClickEvent(self, self.BtnStage2, self.OnBtnBtnStage2Click) + XUiHelper.RegisterClickEvent(self, self.BtnHard, self.OnBtnHardClick) + XUiHelper.RegisterClickEvent(self, self.BtnDefault, self.OnBtnDefaultClick) + XUiHelper.RegisterClickEvent(self, self.BtnStage3, self.OnBtnBtnStage3Click) +end + +function XUiChessPursuitMainStage:OnBtnBtnStage2Click() + local cfg = XChessPursuitConfig.GetChessPursuitMapByUiType(XChessPursuitCtrl.MAIN_UI_TYPE.FIGHT_DEFAULT) + if not cfg then + return + end + XSaveTool.SaveData(self.RootUi:GetSaveToolKey(), cfg.Id) + + self.RootUi:SwtichUI(XChessPursuitCtrl.MAIN_UI_TYPE.SCENE, { + MapId = cfg.Id + }) +end + +function XUiChessPursuitMainStage:OnBtnBtnStage3Click() + local cfg = XChessPursuitConfig.GetChessPursuitMapByUiType(XChessPursuitCtrl.MAIN_UI_TYPE.FIGHT_HARD) + if not cfg then + return + end + XSaveTool.SaveData(self.RootUi:GetSaveToolKey(), cfg.Id) + + self.RootUi:SwtichUI(XChessPursuitCtrl.MAIN_UI_TYPE.SCENE, { + MapId = cfg.Id + }) +end + +function XUiChessPursuitMainStage:OnBtnHardClick() + local cfg = XChessPursuitConfig.GetChessPursuitMapByUiType(XChessPursuitCtrl.MAIN_UI_TYPE.FIGHT_HARD) + + self.RootUi.PanelMaskHeard.gameObject:SetActiveEx(true) + self.RootUi:PlayAnimationWithMask("YellowQieHuan1", function () + self.RootUi:SwtichUI(XChessPursuitCtrl.MAIN_UI_TYPE.FIGHT_HARD, { + MapId = cfg.Id, + CallBack = function () + self.RootUi:PlayAnimationWithMask("YellowQieHuan2", function () + self.RootUi.PanelMaskHeard.gameObject:SetActiveEx(false) + end) + end, + }) + end) +end + +function XUiChessPursuitMainStage:OnBtnDefaultClick() + local cfg = XChessPursuitConfig.GetChessPursuitMapByUiType(XChessPursuitCtrl.MAIN_UI_TYPE.FIGHT_DEFAULT) + + self.RootUi.PanelMaskNormal.gameObject:SetActiveEx(true) + self.RootUi:PlayAnimationWithMask("RedQieHuan1", function () + self.RootUi:SwtichUI(XChessPursuitCtrl.MAIN_UI_TYPE.FIGHT_DEFAULT, { + MapId = cfg.Id, + CallBack = function () + self.RootUi:PlayAnimationWithMask("RedQieHuan2", function () + self.RootUi.PanelMaskNormal.gameObject:SetActiveEx(false) + end) + end, + }) + end) +end + +function XUiChessPursuitMainStage:OnBtnRankClick() + XDataCenter.ChessPursuitManager.ChessPursuitGetRankRequest(function(groupId) + XLuaUiManager.Open("UiChessPursuitRank", groupId) + end) +end + +function XUiChessPursuitMainStage:OnBtnChessPursuitItemClick() + XDataCenter.ChessPursuitManager.OpenCoinTip() +end +--@endregion + +function XUiChessPursuitMainStage:Update() + self:UpdateActive() + self:UpdateTitle() + self:UpdateInfo() + + if self.UiType == XChessPursuitCtrl.MAIN_UI_TYPE.STABLE then + self:UpdateStable() + elseif self.UiType == XChessPursuitCtrl.MAIN_UI_TYPE.FIGHT_DEFAULT then + self:UpdateFightDefault() + elseif self.UiType == XChessPursuitCtrl.MAIN_UI_TYPE.FIGHT_HARD then + self:UpdateFightHeard() + end +end + +function XUiChessPursuitMainStage:UpdateTitle() + if self.UiType == XChessPursuitCtrl.MAIN_UI_TYPE.STABLE then + self.TxtStageName.text = CSXTextManagerGetText("ChessPursuitStable") + else + self.TxtStageName.text = CSXTextManagerGetText("ChessPursuitFight") + end + + local beginTime = XChessPursuitConfig.GetActivityBeginTime() + local endTime = XChessPursuitConfig.GetActivityEndTime() + local weekBeginDesc = XTime.TimestampToGameDateTimeString(beginTime, "HH:mm") + local weekEndDesc = XTime.TimestampToGameDateTimeString(endTime, "HH:mm") + local beginDay = self:GetWeekDayDesc(beginTime) + local endDay = self:GetWeekDayDesc(endTime) + + self.TxtStageTime.text = CSXTextManagerGetText("ChessPursuitTimeDesc", beginDay..weekBeginDesc, endDay..weekEndDesc) +end + +function XUiChessPursuitMainStage:UpdateInfo() + local sum = XDataCenter.ChessPursuitManager.GetSumCoinCount() + local itemName = XItemConfigs.GetItemNameById(XChessPursuitConfig.SHOP_COIN_ITEM_ID) + local itemIcon = XItemConfigs.GetItemIconById(XChessPursuitConfig.SHOP_COIN_ITEM_ID) + + if self.UiType == XChessPursuitCtrl.MAIN_UI_TYPE.STABLE then + self.TxtDescribe.text = CSXTextManagerGetText("ChessPursuitDrillItemCoinDesc", itemName) + else + self.TxtDescribe.text = CSXTextManagerGetText("ChessPursuitActualCombatItemCoinDesc", itemName) + end + self.TxtNumber.text = sum + self.RImgIconCoin:SetRawImage(itemIcon) +end + +function XUiChessPursuitMainStage:UpdateActive() + self.PanelStage1.gameObject:SetActiveEx(self.UiType == XChessPursuitCtrl.MAIN_UI_TYPE.STABLE) + self.PanelStage2.gameObject:SetActiveEx(self.UiType == XChessPursuitCtrl.MAIN_UI_TYPE.FIGHT_DEFAULT) + self.PanelStage3.gameObject:SetActiveEx(self.UiType == XChessPursuitCtrl.MAIN_UI_TYPE.FIGHT_HARD) + self.BtnRank.gameObject:SetActiveEx(self.UiType == XChessPursuitCtrl.MAIN_UI_TYPE.FIGHT_HARD or self.UiType == XChessPursuitCtrl.MAIN_UI_TYPE.FIGHT_DEFAULT) + self.HistoryKillDetails.gameObject:SetActiveEx(self.UiType == XChessPursuitCtrl.MAIN_UI_TYPE.FIGHT_HARD or self.UiType == XChessPursuitCtrl.MAIN_UI_TYPE.FIGHT_DEFAULT) +end + +function XUiChessPursuitMainStage:UpdateStable() + local groupId = XChessPursuitConfig.GetCurrentGroupId() + local mapsCfg = XChessPursuitConfig.GetChessPursuitMapsByGroupId(groupId) + + self.GridStage.gameObject:SetActiveEx(false) + for _,cfg in ipairs(mapsCfg) do + if not self.UiChessPursuitStageGrid[cfg.Id] then + local grid = CSUnityEngineObjectInstantiate(self.GridStage, self.Content) + self.UiChessPursuitStageGrid[cfg.Id] = XUiChessPursuitStageGrid.New(grid, self.RootUi, cfg.Id) + end + + self.UiChessPursuitStageGrid[cfg.Id]:Refresh() + end +end + +function XUiChessPursuitMainStage:UpdateFightDefault() + local cfg = XChessPursuitConfig.GetChessPursuitMapByUiType(XChessPursuitCtrl.MAIN_UI_TYPE.FIGHT_DEFAULT) + local xUiChessPursuitPanelFightStage = XUiChessPursuitPanelFightStage.New(self.PanelStage2, self.RootUi, cfg.Id) + local mapDb = XDataCenter.ChessPursuitManager.GetChessPursuitMapDb(cfg.Id) + + if mapDb:IsKill() then + self.BtnHard.gameObject:SetActiveEx(self:IsOpenFightHeard()) + self.HistoryKillDetails.gameObject:SetActiveEx(true) + local count = mapDb:GetWinForBattleCount() + self.TxtHistoryKilDetailsCount.text = count + else + self.BtnHard.gameObject:SetActiveEx(false) + self.HistoryKillDetails.gameObject:SetActiveEx(false) + end + xUiChessPursuitPanelFightStage:Refresh() +end + +function XUiChessPursuitMainStage:UpdateFightHeard() + local cfg = XChessPursuitConfig.GetChessPursuitMapByUiType(XChessPursuitCtrl.MAIN_UI_TYPE.FIGHT_HARD) + local xUiChessPursuitPanelFightStage = XUiChessPursuitPanelFightStage.New(self.PanelStage3, self.RootUi, cfg.Id) + + xUiChessPursuitPanelFightStage:Refresh() +end + +function XUiChessPursuitMainStage:IsOpenFightHeard() + return XDataCenter.ChessPursuitManager.IsOpenFightHeard() +end + +function XUiChessPursuitMainStage:GetWeekDayDesc(time) + local weekDay = XTime.GetWeekDay(time, true) + if weekDay == 1 then + return CSXTextManagerGetText("Monday") + elseif weekDay == 2 then + return CSXTextManagerGetText("Tuesday") + elseif weekDay == 3 then + return CSXTextManagerGetText("Wednesday") + elseif weekDay == 4 then + return CSXTextManagerGetText("Thursday") + elseif weekDay == 5 then + return CSXTextManagerGetText("Friday") + elseif weekDay == 6 then + return CSXTextManagerGetText("Saturday") + elseif weekDay == 7 then + return CSXTextManagerGetText("Sunday") + end +end + +return XUiChessPursuitMainStage diff --git a/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitPanelFightStage.lua b/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitPanelFightStage.lua new file mode 100644 index 00000000..708e3153 --- /dev/null +++ b/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitPanelFightStage.lua @@ -0,0 +1,38 @@ +local XUiChessPursuitPanelFightStage = XClass(nil, "XUiChessPursuitPanelFightStage") +local CSXTextManagerGetText = CS.XTextManager.GetText + +function XUiChessPursuitPanelFightStage:Ctor(ui, uiRoot, mapId) + self.UiRoot = uiRoot + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.MapId = mapId + + XTool.InitUiObject(self) +end + +function XUiChessPursuitPanelFightStage:Refresh() + local mapDb = XDataCenter.ChessPursuitManager.GetChessPursuitMapDb(self.MapId) + local config = XChessPursuitConfig.GetChessPursuitMapTemplate(self.MapId) + local mapBoss = XDataCenter.ChessPursuitManager.GetChessPursuitMapBoss(config.BossId) + + if mapDb:IsClear() then + self.PanelEnd.gameObject:SetActiveEx(true) + self.PanelJd.gameObject:SetActiveEx(false) + + self.TxtNumber.text = mapDb:GetBossBattleCount() + else + self.PanelJd.gameObject:SetActiveEx(true) + self.PanelEnd.gameObject:SetActiveEx(false) + + local ration = mapDb:GetBossHp() / mapBoss:GetInitHp() + local bloodVolume = ration * 100 + if bloodVolume > 0 and bloodVolume < 0.01 then + bloodVolume = 0.01 + end + + self.ImgJd.fillAmount = ration + self.TxtJd.text = CSXTextManagerGetText("ChessPursuitBloodCount", string.format("%.2f", bloodVolume)) + end +end + +return XUiChessPursuitPanelFightStage \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitSelectTipGrid.lua b/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitSelectTipGrid.lua new file mode 100644 index 00000000..d6e496ad --- /dev/null +++ b/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitSelectTipGrid.lua @@ -0,0 +1,49 @@ +local XUiChessPursuitSelectTipGrid = XClass(nil, "XUiChessPursuitSelectTipGrid") +local CSUnityEngineVector3 = CS.UnityEngine.Vector3 + +function XUiChessPursuitSelectTipGrid:Ctor(ui, uiRoot, cubeIndex, mapId, targetType) + self.UiRoot = uiRoot + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.CubeIndex = cubeIndex + self.MapId = mapId + self.TargetType = targetType + + XTool.InitUiObject(self) + + self.Transform.localScale = CSUnityEngineVector3(5,5,5) +end + +function XUiChessPursuitSelectTipGrid:Dispose() + if self.GameObject then + CS.UnityEngine.GameObject.Destroy(self.GameObject) + end + + self.GameObject = nil +end + +function XUiChessPursuitSelectTipGrid:SetActiveEx(isShow) + self.GameObject:SetActiveEx(isShow) +end + +function XUiChessPursuitSelectTipGrid:RefreshPos() + if not self.GameObject.activeSelf then + return + end + + local ts + local offzetY + if self.TargetType == XChessPursuitCtrl.SCENE_SELECT_TARGET.BOSS then + ts = self.UiRoot.ChessPursuitBoss.Transform + offzetY = -1 + elseif self.TargetType == XChessPursuitCtrl.SCENE_SELECT_TARGET.CUBE then + local chessPursuitCube = XChessPursuitCtrl.GetChessPursuitCubes() + ts = chessPursuitCube[self.CubeIndex].Transform + offzetY = 0.2 + end + + self.Transform.position = XChessPursuitCtrl.WorldToUIPosition(CSUnityEngineVector3(ts.position.x, ts.position.y + offzetY, ts.position.z)) +end + + +return XUiChessPursuitSelectTipGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitSkillEffectGrid.lua b/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitSkillEffectGrid.lua new file mode 100644 index 00000000..74d8baa2 --- /dev/null +++ b/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitSkillEffectGrid.lua @@ -0,0 +1,212 @@ +local XUiChessPursuitSkillEffectGrid = XClass(nil, "XUiChessPursuitSkillEffectGrid") +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate +local CSXResourceManagerLoad = CS.XResourceManager.Load +local CSUnityEngineGameObjectDestroy = CS.UnityEngine.GameObject.Destroy +local ChessPursuitBuffStartEffectTime = CS.XGame.ClientConfig:GetFloat("ChessPursuitBuffStartEffectTime") +local ChessPursuitBuffStartEffect = CS.XGame.ClientConfig:GetString("ChessPursuitBuffStartEffect") +local ChessPursuitArrowEffect = CS.XGame.ClientConfig:GetString("ChessPursuitArrowEffect") +local ChessPursuitUseCardEffect = CS.XGame.ClientConfig:GetString("ChessPursuitUseCardEffect") +local CSUnityEngineVector3 = CS.UnityEngine.Vector3 + +local CARD_EFFECT_Y = { + [XChessPursuitCtrl.SCENE_SELECT_TARGET.CUBE] = 0.503, + [XChessPursuitCtrl.SCENE_SELECT_TARGET.TEAM] = 0, + [XChessPursuitCtrl.SCENE_SELECT_TARGET.BOSS] = 0, +} + +local USE_CARD_EFFECT_Y = { + [XChessPursuitCtrl.SCENE_SELECT_TARGET.CUBE] = 0.92, + [XChessPursuitCtrl.SCENE_SELECT_TARGET.TEAM] = 0.92, + [XChessPursuitCtrl.SCENE_SELECT_TARGET.BOSS] = 0.436, +} + +local EffectMaxCount = 3 + +function XUiChessPursuitSkillEffectGrid:Ctor(uiRoot, cubeIndex, targetType, mapId) + self.UiRoot = uiRoot + self.CubeIndex = cubeIndex + self.TargetType = targetType + self.TmEffectGo = {} + self.IsDispose = false + self.MapId = mapId +end + +function XUiChessPursuitSkillEffectGrid:Disable() + self.IsCheckRePlayEffect = true +end + +function XUiChessPursuitSkillEffectGrid:Dispose() + for cardId, go in pairs(self.TmEffectGo) do + CSUnityEngineGameObjectDestroy(go) + end + + self.TmEffectGo = nil + self.IsDispose = true +end + +function XUiChessPursuitSkillEffectGrid:Refresh() + if self.IsCheckRePlayEffect then + self:CheckRePlayEffect() + end + + local chessPursuitMapDb = XDataCenter.ChessPursuitManager.GetChessPursuitMapDb(self.MapId) + local xChessPursuitCardDbList + if self.TargetType == XChessPursuitCtrl.SCENE_SELECT_TARGET.BOSS then + xChessPursuitCardDbList = chessPursuitMapDb:GetBossCardDb() or {} + self:RefreshEffect(xChessPursuitCardDbList) + else + local xChessPursuitMapGridCardDb = chessPursuitMapDb:GetGridCardDb() + xChessPursuitCardDbList = {} + for _,v in ipairs(xChessPursuitMapGridCardDb) do + if v.Id == self.CubeIndex-1 then + xChessPursuitCardDbList = v.Cards or {} + break + end + end + + self:RefreshEffect(xChessPursuitCardDbList) + end +end + +function XUiChessPursuitSkillEffectGrid:RefreshEffect(xChessPursuitCardDbList) + local isPlayEffectAnima = false + + --去除已经过期的 + for cardId, go in pairs(self.TmEffectGo) do + local isExist = false + for i,card in ipairs(xChessPursuitCardDbList) do + if card.Id == cardId then + isExist = true + break + end + end + + if not isExist then + CSUnityEngineGameObjectDestroy(go) + self.TmEffectGo[cardId] = nil + isPlayEffectAnima = true + end + end + + for k, card in ipairs(xChessPursuitCardDbList) do + if not self.TmEffectGo[card.Id] then + local parent = self:GetTargetGo() + local effect = XChessPursuitConfig.GetCardEffect(card.CardCfgId) + if parent and effect then + local resource = CSXResourceManagerLoad(effect) + self.TmEffectGo[card.Id] = CSUnityEngineObjectInstantiate(resource.Asset, parent) + self.TmEffectGo[card.Id].gameObject:SetActiveEx(false) + self.TmEffectGo[card.Id].gameObject.transform.localPosition = CSUnityEngineVector3(0, CARD_EFFECT_Y[self.TargetType], 0) + isPlayEffectAnima = true + end + end + end + + if isPlayEffectAnima then + self:RePlayEffectAnima() + end +end + +function XUiChessPursuitSkillEffectGrid:CheckRePlayEffect() + self.IsCheckRePlayEffect = false + if not XTool.IsTableEmpty(self.TmEffectGo) then + local effectTotalNum = 0 + for _ in pairs(self.TmEffectGo) do + effectTotalNum = effectTotalNum + 1 + end + if effectTotalNum > 1 then + self:RePlayEffectAnima() + end + end +end + +function XUiChessPursuitSkillEffectGrid:RePlayEffectAnima() + local parent = self:GetTargetGo() + if not parent then + return + end + + local effectTotalNum = 0 + for _, go in pairs(self.TmEffectGo) do + go.gameObject:SetActiveEx(false) + effectTotalNum = effectTotalNum + 1 + end + + local effectNum = 1 + local delayTime = effectTotalNum > 1 and EffectMaxCount / effectTotalNum * 1000 or 1000 + for k, go in pairs(self.TmEffectGo) do + local onStartResource = CSXResourceManagerLoad(ChessPursuitBuffStartEffect) + local onStartEffect = CSUnityEngineObjectInstantiate(onStartResource.Asset, parent) + CS.XScheduleManager.ScheduleOnce(function() + if not XTool.UObjIsNil(onStartEffect) then + CSUnityEngineGameObjectDestroy(onStartEffect) + end + if self.IsDispose then + return + end + if not XTool.UObjIsNil(go) then + go.gameObject:SetActiveEx(true) + end + end, math.floor(ChessPursuitBuffStartEffectTime + effectNum * delayTime)) + effectNum = effectNum + 1 + end +end + +function XUiChessPursuitSkillEffectGrid:GetTargetGo() + if self.TargetType == XChessPursuitCtrl.SCENE_SELECT_TARGET.BOSS then + return self.UiRoot.ChessPursuitBoss.Transform + else + local chessPursuitCubes = XChessPursuitCtrl.GetChessPursuitCubes() + return chessPursuitCubes[self.CubeIndex].Transform + end +end + +function XUiChessPursuitSkillEffectGrid:GetTargetType() + return self.TargetType +end + +--@region 布阵阶段的箭头特效 +function XUiChessPursuitSkillEffectGrid:LoadJianTou() + if self.TargetType == XChessPursuitCtrl.SCENE_SELECT_TARGET.CUBE then + local parent = self:GetTargetGo() + local resource = CSXResourceManagerLoad(ChessPursuitArrowEffect) + local cubes = XChessPursuitCtrl.GetCSXChessPursuitCtrlCom().Cubes + local localPos = parent.transform.position + local nextPos = self:GetNextIndexPos() + local q = CS.UnityEngine.Quaternion.LookRotation(CS.UnityEngine.Vector3(nextPos.x - localPos.x, 0, nextPos.z - localPos.z)) + + self.jianTouGo = CSUnityEngineObjectInstantiate(resource.Asset, parent) + self.jianTouGo.transform.localPosition = CSUnityEngineVector3(0, CARD_EFFECT_Y[XChessPursuitCtrl.SCENE_SELECT_TARGET.CUBE], 0) + self.jianTouGo.transform.localScale = CS.UnityEngine.Vector3(0.6, 0.6, 0.6) + self.jianTouGo.transform.rotation = q + end +end + +function XUiChessPursuitSkillEffectGrid:GetNextIndexPos() + local cubes = XChessPursuitCtrl.GetCSXChessPursuitCtrlCom().Cubes + if self.CubeIndex >= cubes.Count then + return cubes[0].transform.position + else + return cubes[self.CubeIndex].transform.position + end +end + +function XUiChessPursuitSkillEffectGrid:DestroyArrow() + if not XTool.UObjIsNil(self.jianTouGo) then + CSUnityEngineGameObjectDestroy(self.jianTouGo, 1) + end +end +--@endregion + +--使用卡时候播放的特效 +function XUiChessPursuitSkillEffectGrid:LoadUseCardEffect() + local parent = self:GetTargetGo() + local resource = CSXResourceManagerLoad(ChessPursuitUseCardEffect) + local effectGo = CSUnityEngineObjectInstantiate(resource.Asset, parent) + effectGo.transform.localPosition = CSUnityEngineVector3(0, USE_CARD_EFFECT_Y[self.TargetType], 0) + effectGo.transform.localScale = CS.UnityEngine.Vector3(0.4, 0.4, 0.4) + + CSUnityEngineGameObjectDestroy(effectGo, 1) +end + +return XUiChessPursuitSkillEffectGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitSkillGrid.lua b/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitSkillGrid.lua new file mode 100644 index 00000000..fbe1e201 --- /dev/null +++ b/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitSkillGrid.lua @@ -0,0 +1,135 @@ +local XUiChessPursuitSkillGrid = XClass(nil, "XUiChessPursuitSkillGrid") +local CSUnityEngineVector3 = CS.UnityEngine.Vector3 + +function XUiChessPursuitSkillGrid:Ctor(ui, uiRoot, cubeIndex, mapId, targetType) + self.UiRoot = uiRoot + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.CubeIndex = cubeIndex + self.MapId = mapId + self.TargetType = targetType + + XTool.InitUiObject(self) + + self.Transform.localScale = CSUnityEngineVector3(5,5,5) +end + +function XUiChessPursuitSkillGrid:Dispose() + if self.GameObject then + CS.UnityEngine.GameObject.Destroy(self.GameObject) + end + + self.GameObject = nil +end + +function XUiChessPursuitSkillGrid:SetActiveEx(isShow) + self.GameObject:SetActiveEx(isShow) +end + +function XUiChessPursuitSkillGrid:Refresh() + local chessPursuitMapDb = XDataCenter.ChessPursuitManager.GetChessPursuitMapDb(self.MapId) + if self.TargetType == XChessPursuitCtrl.SCENE_SELECT_TARGET.BOSS then + local xChessPursuitCardDbList = chessPursuitMapDb:GetBossCardDb() + + if next(xChessPursuitCardDbList) then + self.GameObject:SetActiveEx(true) + self:RefreshIcon(xChessPursuitCardDbList) + else + self.GameObject:SetActiveEx(false) + end + elseif self.TargetType == XChessPursuitCtrl.SCENE_SELECT_TARGET.CUBE then + local xChessPursuitMapGridCardDb = chessPursuitMapDb:GetGridCardDb() + local isActive = false + + for _,v in ipairs(xChessPursuitMapGridCardDb) do + if v.Id == self.CubeIndex-1 then + local xChessPursuitCardDbList = v.Cards + if next(xChessPursuitCardDbList) then + isActive = true + self:RefreshIcon(xChessPursuitCardDbList) + end + break + end + end + + self.GameObject:SetActiveEx(isActive) + end +end + +--更新来自临时数据的 +function XUiChessPursuitSkillGrid:RefreshByTemp(cards) + local index = 0 + local chessPursuitMapDb = XDataCenter.ChessPursuitManager.GetChessPursuitMapDb(self.MapId) + if self.TargetType == XChessPursuitCtrl.SCENE_SELECT_TARGET.BOSS then + local xChessPursuitCardDbList = chessPursuitMapDb:GetBossCardDb() + if next(xChessPursuitCardDbList) then + index = #xChessPursuitCardDbList + end + elseif self.TargetType == XChessPursuitCtrl.SCENE_SELECT_TARGET.CUBE then + local xChessPursuitMapGridCardDb = chessPursuitMapDb:GetGridCardDb() + for _,v in ipairs(xChessPursuitMapGridCardDb) do + if v.Id == self.CubeIndex-1 then + local xChessPursuitCardDbList = v.Cards + if next(xChessPursuitCardDbList) then + index = #xChessPursuitCardDbList + end + break + end + end + end + + if index == 0 and (not cards or not next(cards)) then + self.GameObject:SetActiveEx(false) + else + self.GameObject:SetActiveEx(true) + end + + local cardIndex = 1 + for i=index + 1,XChessPursuitCtrl.CARD_MAX_COUNT do + if cards and cards[cardIndex] then + self["Skill"..i].gameObject:SetActiveEx(true) + local cardCfg = XChessPursuitConfig.GetChessPursuitCardTemplate(cards[cardIndex].CardCfgId) + self["RawImageIcon" .. i]:SetRawImage(cardCfg.Icon) + self["RawImageKuang" .. i]:SetRawImage(cardCfg.QualityIconSmall) + cardIndex = cardIndex + 1 + else + self["Skill"..i].gameObject:SetActiveEx(false) + end + end +end + +function XUiChessPursuitSkillGrid:RefreshIcon(xChessPursuitCardDbList) + for i=1,XChessPursuitCtrl.CARD_MAX_COUNT do + local card = xChessPursuitCardDbList[i] + if card then + self["Skill"..i].gameObject:SetActiveEx(true) + local cardCfg = XChessPursuitConfig.GetChessPursuitCardTemplate(card.CardCfgId) + self["RawImageIcon" .. i]:SetRawImage(cardCfg.Icon) + self["RawImageKuang" .. i]:SetRawImage(cardCfg.QualityIconSmall) + else + self["Skill"..i].gameObject:SetActiveEx(false) + end + end +end + +function XUiChessPursuitSkillGrid:RefreshPos() + if not self.GameObject.activeSelf then + return + end + + local ts + local offzetY + + if self.TargetType == XChessPursuitCtrl.SCENE_SELECT_TARGET.BOSS then + ts = self.UiRoot.ChessPursuitBoss.Transform + offzetY = -0.55 + elseif self.TargetType == XChessPursuitCtrl.SCENE_SELECT_TARGET.CUBE then + local chessPursuitCube = XChessPursuitCtrl.GetChessPursuitCubes() + ts = chessPursuitCube[self.CubeIndex].Transform + offzetY = 0.5 + end + + self.Transform.position = XChessPursuitCtrl.WorldToUIPosition(CSUnityEngineVector3(ts.position.x, ts.position.y + offzetY, ts.position.z)) +end + +return XUiChessPursuitSkillGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitStageGrid.lua b/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitStageGrid.lua new file mode 100644 index 00000000..6d7d3bb0 --- /dev/null +++ b/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiCPMain/XUiChessPursuitStageGrid.lua @@ -0,0 +1,152 @@ +local XUiChessPursuitStageGrid = XClass(nil, "XUiChessPursuitStageGrid") +local CSXTextManagerGetText = CS.XTextManager.GetText +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate + +local UI_TYPE = { + OPEN = 1, --开放 + CLOSE = 2, -- 未开放 + FINISH = 3, -- 通关 +} + +function XUiChessPursuitStageGrid:Ctor(ui, uiRoot, mapId) + self.UiRoot = uiRoot + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.MapId = mapId + self.RewardPanelList = {} + self.GameObject:SetActiveEx(true) + XTool.InitUiObject(self) + self:AutoAddListener() +end + +function XUiChessPursuitStageGrid:Dispose() + if self.GameObject then + CS.UnityEngine.GameObject.Destroy(self.GameObject) + end +end +--@region 点击事件 + +function XUiChessPursuitStageGrid:AutoAddListener() + self.BtnReceive.CallBack = function() self:OnBtnBtnReceiveClick() end + XUiHelper.RegisterClickEvent(self, self.GridStage, self.OnGridStageClick) +end + +function XUiChessPursuitStageGrid:OnBtnBtnReceiveClick() + local mapCfg = XChessPursuitConfig.GetChessPursuitMapTemplate(self.MapId) + + XDataCenter.TaskManager.FinishTask(mapCfg.TaskId, function(rewards) + XUiManager.OpenUiObtain(rewards, nil, function() + self:Refresh() + end, nil) + end) +end + +function XUiChessPursuitStageGrid:OnGridStageClick() + local uiType = self:GetUIType() + if uiType == UI_TYPE.OPEN or uiType == UI_TYPE.FINISH then + XSaveTool.SaveData(self.UiRoot:GetSaveToolKey(), self.MapId) + + self.UiRoot:SwtichUI(XChessPursuitCtrl.MAIN_UI_TYPE.SCENE, { + MapId = self.MapId + }) + else + XUiManager.TipText("ChessPursuitStageNotOpen") + end +end + +--@endregion + +function XUiChessPursuitStageGrid:Refresh() + local chessPursuitMapDb = XDataCenter.ChessPursuitManager.GetChessPursuitMapDb(self.MapId) + local bossId = XChessPursuitConfig.GetChessPursuitMapTemplate(self.MapId).BossId + local chessPursuitMapBoss = XDataCenter.ChessPursuitManager.GetChessPursuitMapBoss(bossId) + local uiType = self:GetUIType() + if uiType == UI_TYPE.OPEN then + local mapCfg = XChessPursuitConfig.GetChessPursuitMapTemplate(self.MapId) + local bossCfg = XChessPursuitConfig.GetChessPursuitBossTemplate(mapCfg.BossId) + + self:RefreshActive(uiType) + self:RefreshReward() + self.BtnReceive.gameObject:SetActiveEx(false) + + self.TxtBossName.text = bossCfg.Name + self.TxtStageName.text = mapCfg.StageName + self.GridStage:SetRawImage(bossCfg.BossBg) + local ration = chessPursuitMapDb:GetBossHp() / chessPursuitMapBoss:GetInitHp() + self.ImgJd.fillAmount = ration + local bloodVolume = ration * 100 + if bloodVolume > 0 and bloodVolume < 0.01 then + bloodVolume = 0.01 + end + self.TxtJd.text = CSXTextManagerGetText("ChessPursuitBloodCount", string.format("%.2f", bloodVolume)) + self.GridStage:SetDisable(false) + elseif uiType == UI_TYPE.FINISH then + local mapCfg = XChessPursuitConfig.GetChessPursuitMapTemplate(self.MapId) + local bossCfg = XChessPursuitConfig.GetChessPursuitBossTemplate(mapCfg.BossId) + + self:RefreshActive(uiType) + self:RefreshReward() + self.BtnReceive.gameObject:SetActiveEx(true) + + if chessPursuitMapDb:IsCanTakeReward() then + self.BtnReceive:SetDisable(false) + else + self.BtnReceive:SetDisable(true, false) + end + + self.TxtBossName.text = bossCfg.Name + self.TxtStageName.text = mapCfg.StageName + self.GridStage:SetRawImage(bossCfg.BossBg) + self.ImgJd.fillAmount = 0 + self.TxtJd.text = CSXTextManagerGetText("ChessPursuitBloodCount", 0) + self.GridStage:SetDisable(false) + elseif uiType == UI_TYPE.CLOSE then + self.GridStage:SetDisable(true) + self:RefreshActive(uiType) + end +end + +function XUiChessPursuitStageGrid:RefreshActive(uiType) + self.ImgFubenEnd.gameObject:SetActiveEx(uiType == UI_TYPE.FINISH) + self.PanelJd.gameObject:SetActiveEx(not (uiType == UI_TYPE.CLOSE)) + self.PanelName.gameObject:SetActiveEx(not (uiType == UI_TYPE.CLOSE)) + self.PanelReward.gameObject:SetActiveEx(not (uiType == UI_TYPE.CLOSE)) +end + +function XUiChessPursuitStageGrid:RefreshReward() + local mapCfg = XChessPursuitConfig.GetChessPursuitMapTemplate(self.MapId) + local rewards = XRewardManager.GetRewardList(mapCfg.RewardShow) or {} + + for i = 1, #rewards do + local gridReward = self.RewardPanelList[i] + if not gridReward then + local ui = CSUnityEngineObjectInstantiate(self.GridReward, self.PanelRewardList) + ui.gameObject:SetActiveEx(true) + ui.gameObject.name = string.format("GridReward%d", i) + gridReward = XUiGridCommon.New(self.UiRoot, ui) + table.insert(self.RewardPanelList, i, gridReward) + end + + self.RewardPanelList[i].GameObject:SetActiveEx(true) + self.RewardPanelList[i]:Refresh(rewards[i]) + end + + for i = #rewards + 1, #self.RewardPanelList do + self.RewardPanelList[i].GameObject:SetActiveEx(false) + end +end + +function XUiChessPursuitStageGrid:GetUIType() + if XChessPursuitConfig.CheckChessPursuitMapIsOpen(self.MapId) then + local chessPursuitMapDb = XDataCenter.ChessPursuitManager.GetChessPursuitMapDb(self.MapId) + if chessPursuitMapDb:IsKill() then + return UI_TYPE.FINISH + else + return UI_TYPE.OPEN + end + else + return UI_TYPE.CLOSE + end +end + +return XUiChessPursuitStageGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiChessPursuitBuffTips.lua b/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiChessPursuitBuffTips.lua new file mode 100644 index 00000000..82059f38 --- /dev/null +++ b/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiChessPursuitBuffTips.lua @@ -0,0 +1,60 @@ +local XUiChessPursuitBuffTips = XLuaUiManager.Register(XLuaUi, "UiChessPursuitBuffTips") +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate +local XUiChessPursuitBuffTipsGrid = require("XUi/XUiChessPursuit/XUi/XUiChessPursuitBuffTipsGrid") + +function XUiChessPursuitBuffTips:OnAwake() + self:AutoAddListener() +end + +function XUiChessPursuitBuffTips:OnStart(mapId, targetType, cubeIndex) + self.MapId = mapId + self.TargetType = targetType + self.CubeIndex = cubeIndex + self:UpdateInfo() +end + +--@region 点击事件 + +function XUiChessPursuitBuffTips:AutoAddListener() + self:RegisterClickEvent(self.BtnClose, self.OnBtnCloseClick) +end + +function XUiChessPursuitBuffTips:OnBtnCloseClick() + self:Close() +end + +--@endregion + +function XUiChessPursuitBuffTips:UpdateInfo() + local chessPursuitMapDb = XDataCenter.ChessPursuitManager.GetChessPursuitMapDb(self.MapId) + if self.TargetType == XChessPursuitCtrl.SCENE_SELECT_TARGET.BOSS then + local xChessPursuitCardDbList = chessPursuitMapDb:GetBossCardDb() + + if next(xChessPursuitCardDbList) then + self:RefresGrid(xChessPursuitCardDbList) + end + elseif self.TargetType == XChessPursuitCtrl.SCENE_SELECT_TARGET.CUBE then + local xChessPursuitMapGridCardDb = chessPursuitMapDb:GetGridCardDb() + + for _,v in ipairs(xChessPursuitMapGridCardDb) do + if v.Id == self.CubeIndex-1 then + local xChessPursuitCardDbList = v.Cards + if next(xChessPursuitCardDbList) then + self:RefresGrid(xChessPursuitCardDbList) + end + break + end + end + end +end + +function XUiChessPursuitBuffTips:RefresGrid(xChessPursuitCardDbList) + self.GridBuff.gameObject:SetActiveEx(false) + + for _,card in ipairs(xChessPursuitCardDbList) do + local grid = CSUnityEngineObjectInstantiate(self.GridBuff, self.PanelContent.transform) + grid.gameObject:SetActiveEx(true) + local uiChessPursuitBuffTipsGrid = XUiChessPursuitBuffTipsGrid.New(grid, self, card) + uiChessPursuitBuffTipsGrid:Refresh() + end +end diff --git a/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiChessPursuitBuffTipsGrid.lua b/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiChessPursuitBuffTipsGrid.lua new file mode 100644 index 00000000..c71073ac --- /dev/null +++ b/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiChessPursuitBuffTipsGrid.lua @@ -0,0 +1,31 @@ +local XUiChessPursuitBuffTipsGrid = XClass(nil, "XUiChessPursuitBuffTipsGrid") +local CSXTextManagerFormatString = CS.XTextManager.FormatString + +function XUiChessPursuitBuffTipsGrid:Ctor(ui, rootUi, card) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Card = card + + XTool.InitUiObject(self) +end + +function XUiChessPursuitBuffTipsGrid:Refresh() + local cardCfg = XChessPursuitConfig.GetChessPursuitCardTemplate(self.Card.CardCfgId) + local cfgEffect = XChessPursuitConfig.GetChessPursuitCardEffectTemplate(cardCfg.EffectId) + + self.RootUi:SetUiSprite(self.RImgIconKuang, cardCfg.QualityIconTips) + self.RImgIcon:SetRawImage(cardCfg.Icon) + self.TxtName.text = cardCfg.Name + self.TxtDesc.text = cardCfg.Describe + + local countDesc + if cfgEffect.KeepType == 0 then + countDesc = cfgEffect.KeepTypeDesc + else + countDesc = CSXTextManagerFormatString(cfgEffect.KeepTypeDesc, self.Card.KeepCount) + end + self.TxtKeepCount.text = countDesc +end + +return XUiChessPursuitBuffTipsGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiChessPursuitCardsTip.lua b/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiChessPursuitCardsTip.lua new file mode 100644 index 00000000..f91e52ac --- /dev/null +++ b/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiChessPursuitCardsTip.lua @@ -0,0 +1,19 @@ +local XUiChessPursuitCardsTip = XLuaUiManager.Register(XLuaUi, "UiChessPursuitCardsTip") +function XUiChessPursuitCardsTip:OnAwake() + self:AutoAddListener() +end + +function XUiChessPursuitCardsTip:OnStart(cardId) + self.TxtName.text = XChessPursuitConfig.GetCardName(cardId) + self.TxtWorldDesc.text = XChessPursuitConfig.GetCardDescribe(cardId) + local cardQualityIcon = XChessPursuitConfig.GetCardTipsQualityIconBg(cardId) + self:SetUiSprite(self.ImgTipsCards, cardQualityIcon) --图片背景 + local cardIcon = XChessPursuitConfig.GetCardIcon(cardId) + self.RImgIcon:SetRawImage(cardIcon) +end + +function XUiChessPursuitCardsTip:AutoAddListener() + self:RegisterClickEvent(self.BtnBack, self.Close) + self:RegisterClickEvent(self.BtnOk, self.Close) + self:RegisterClickEvent(self.BtnTcanchaungBlack, self.Close) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiChessPursuitFightResult.lua b/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiChessPursuitFightResult.lua new file mode 100644 index 00000000..7a4554ce --- /dev/null +++ b/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiChessPursuitFightResult.lua @@ -0,0 +1,141 @@ +local XUiChessPursuitFightResult = XLuaUiManager.Register(XLuaUi, "UiChessPursuitFightResult") +local CSXTextManagerGetText = CS.XTextManager.GetText + +function XUiChessPursuitFightResult:OnAwake() + self:AutoAddListener() +end + +function XUiChessPursuitFightResult:OnStart(params, callBack) + self.MapId = params.MapId + self.ChessPursuitSyncAction = params.ChessPursuitSyncAction + self.Settle = params.Settle + self.TeamGridIndex = params.TeamGridIndex + self.ChessPursuitMapBoss = XDataCenter.ChessPursuitManager.GetChessPursuitMapBoss(params.BossId) + self.CallBack = callBack + self.ChessPursuitMapDb = XDataCenter.ChessPursuitManager.GetChessPursuitMapDb(self.MapId) + self.TxtTile.text = XChessPursuitConfig.GetChessPursuitActivityNameByMapId(self.MapId) + + self:UpdateInfo() +end + +function XUiChessPursuitFightResult:OnEnable() + XDataCenter.FunctionEventManager.UnLockFunctionEvent() + self:OnActivityEnd() +end + +function XUiChessPursuitFightResult:OnDestroy() + self:StopAudio() + if self.CallBack then + self.CallBack() + end + + XEventManager.DispatchEvent(XEventId.EVENT_CHESSPURSUIT_FIGHT_FINISH_WIN) +end + +function XUiChessPursuitFightResult:OnActivityEnd() + XDataCenter.FubenBossSingleManager.OnActivityEnd() +end + +--@region 点击事件 + +function XUiChessPursuitFightResult:AutoAddListener() + self:RegisterClickEvent(self.BtnExitFight, self.OnBtnExitFightClick) + self:RegisterClickEvent(self.BtnReFight, self.OnBtnReFightClick) +end + +function XUiChessPursuitFightResult:OnBtnExitFightClick() + XDataCenter.ChessPursuitManager.RequestChessPursuitEndBattleRequest(function () + self:Close() + end) +end + +function XUiChessPursuitFightResult:OnBtnReFightClick() + local chessPursuitMapTemplate = self.ChessPursuitMapDb:GetChessPursuitMapTemplate() + local chessPursuitBoss = XChessPursuitConfig.GetChessPursuitBossTemplate(chessPursuitMapTemplate.BossId) + local stageId = chessPursuitBoss.StageId + local stage = XDataCenter.FubenManager.GetStageCfg(stageId) + local gridTeamDb = self.ChessPursuitMapDb:GetGridTeamDbByGridId(self.TeamGridIndex) + + XDataCenter.FubenManager.EnterChessPursuitFight(stage, { + CardIds = gridTeamDb.CardIds, + CaptainPos = gridTeamDb.CaptainPos, + FirstFightPos = gridTeamDb.FirstFightPos, + RobotIds = gridTeamDb.RobotIds, + StageId = stage.StageId, + }, function() + self:Close() + end) +end + +--@endregion + + +function XUiChessPursuitFightResult:StopAudio() + if self.AudioInfo then + self.AudioInfo:Stop() + self.AudioInfo = nil + end +end + +function XUiChessPursuitFightResult:UpdateInfo(settleData) + local mapsCfg = XChessPursuitConfig.GetChessPursuitMapTemplate(self.MapId) + --通关时间 + local leftTime = self.ChessPursuitSyncAction:GetLeftTime() + --战斗结束打BOSS最高可获得的分数 + local battleHurtMax = self.ChessPursuitMapBoss:GetBattleHurtMax() + --战斗结束我方血量最高可获得的分数 + local selfHpMax = self.ChessPursuitMapBoss:GetSelfHpMax() + --战斗完我方血量的百分比(整数) + local selfHp = self.ChessPursuitSyncAction:GetSelfHp() + --战斗完我方血量的积分 + local selfScore = self.ChessPursuitSyncAction:GetSelfScore() + --战斗完对Boss造成的伤害积分 + local battleScore = self.ChessPursuitSyncAction:GetBattleScore() + --战斗完对Boss造成的伤害 + local battleHurt = self.ChessPursuitSyncAction:GetBattleHurt() + --战斗完的总积分 + local sumScore = self.ChessPursuitSyncAction:GetSumScore() + --扣除BOSS的血量百分比 + local maxHp = self.ChessPursuitMapBoss:GetInitHp() + local ration = sumScore / maxHp + --历史百分比 + local oldRation = self.ChessPursuitMapDb:GetHurtBossByGridId(self.TeamGridIndex) / maxHp + + if oldRation < 0 then + oldRation = 0 + end + + --扣的血不可超过配置的最大血量 + local maxHpRatio = self.ChessPursuitMapBoss:GetMaxHpRatio() + if ration > maxHpRatio and maxHpRatio > 0 then + ration = maxHpRatio + end + + self.AudioInfo = CS.XAudioManager.PlaySound(XSoundManager.UiBasicsMusic.UiSettle_Win_Number) + + self.TxtHighScore.text = string.format("%.2f%%", oldRation * 100) + self.TxtRemainHpScoreMax.text = CSXTextManagerGetText("ChessPursuitMaxScore", selfHpMax) + self.TxtRemainHp.text = selfHp .. "%" + + if mapsCfg.Stage == XChessPursuitCtrl.MAIN_UI_TYPE.FIGHT_HARD then + self.TxtHitSocreMax.text = CSXTextManagerGetText("ArenaMaxSingleNoScore") + else + self.TxtHitSocreMax.text = CSXTextManagerGetText("ChessPursuitMaxScore", battleHurtMax) + end + self.TxtHitCombo.text = battleHurt + self.PanelNewRecord.gameObject:SetActiveEx(oldRation < ration) + + XUiHelper.Tween(CS.XGame.ClientConfig:GetFloat("BossSingleAnimaTime"), function(f) + if XTool.UObjIsNil(self.Transform) then + return + end + + self.TxtCostTime.text = XUiHelper.GetTime(math.floor(f * leftTime)) + self.TxtHitScore.text = "+" .. math.floor(f * battleScore) + self.TxtRemainHpScore.text = "+" .. math.floor(f * selfScore) + self.TxtTotalPointNumber.text = math.floor(f * sumScore) + self.TxtDeductionProportion.text = string.format("%.2f%%", f * ration * 100) + end, function() + self:StopAudio() + end) +end diff --git a/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiChessPursuitFightTips.lua b/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiChessPursuitFightTips.lua new file mode 100644 index 00000000..0ccfa1d3 --- /dev/null +++ b/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiChessPursuitFightTips.lua @@ -0,0 +1,190 @@ +local XUiChessPursuitFightTips = XLuaUiManager.Register(XLuaUi, "UiChessPursuitFightTips") +local CSXTextManagerGetText = CS.XTextManager.GetText + +function XUiChessPursuitFightTips:OnAwake() + self:AutoAddListener() +end + +function XUiChessPursuitFightTips:OnStart(mapId, teamGridIndex, callBack, rootUi, drawCamera) + self.MapId = mapId + self.TeamGridIndex = teamGridIndex + self.CallBack = callBack + self.RootUi = rootUi + self.DrawCamera = drawCamera + self.ChessPursuitMapDb = XDataCenter.ChessPursuitManager.GetChessPursuitMapDb(self.MapId) + + self:LockCamera() + self:UpdateInfo() + + self.UpdateTimer = XScheduleManager.ScheduleForever(function() + if XChessPursuitConfig.IsTimeOutByMapId(mapId) then + self:Close() + end + end, 1) +end + +function XUiChessPursuitFightTips:OnDestroy() + self:UnLockCamera() + if self.UpdateTimer then + XScheduleManager.UnSchedule(self.UpdateTimer) + self.UpdateTimer = nil + end +end + +function XUiChessPursuitFightTips:LockCamera() + if not self.DrawCamera then + return + end + self.CurrCameraState = self.DrawCamera:GetChessPursuitCameraState() + self.DrawCamera:SwitchChessPursuitCameraState(CS.XChessPursuitCameraState.None) +end + +function XUiChessPursuitFightTips:UnLockCamera() + if not self.DrawCamera then + return + end + self.DrawCamera:SwitchChessPursuitCameraState(self.CurrCameraState) +end + +--@region 点击事件 + +function XUiChessPursuitFightTips:AutoAddListener() + self.BtnAutoFight.CallBack = function() self:OnBtnAutoFightClick() end + self:RegisterClickEvent(self.BtnEnterFight, self.OnBtnEnterFightClick) + if self.BtnTeamChange then + self:RegisterClickEvent(self.BtnTeamChange, self.OnBtnTeamChangeClick) + end + if self.BtnReset then + self:RegisterClickEvent(self.BtnReset, self.OnBtnResetClick) + end +end + +function XUiChessPursuitFightTips:OnBtnTeamChangeClick() + local curTeamData = self.ChessPursuitMapDb:GetGridTeamDbByGridId(self.TeamGridIndex) + local chessPursuitMapTemplate = self.ChessPursuitMapDb:GetChessPursuitMapTemplate() + local chessPursuitBoss = XChessPursuitConfig.GetChessPursuitBossTemplate(chessPursuitMapTemplate.BossId) + local stageId = chessPursuitBoss.StageId + local teamData = self.ChessPursuitMapDb:GetTeamCharacterIds(self.TeamGridIndex, true) + local robotList = XChessPursuitConfig.GetChessPursuitTestRoleRoleIds(chessPursuitMapTemplate.TestRoleGroup[self.TeamGridIndex]) + local curTeam = { + TeamData = teamData, + CaptainPos = curTeamData.CaptainPos, + FirstFightPos = curTeamData.FirstFightPos, + } + XLuaUiManager.Open("UiNewRoomSingle", stageId, { + ChessPursuitData = { + RobotList = robotList, + TeamGridIndex = self.TeamGridIndex, + MapId = self.MapId, + CurTeam = curTeam, + SceneUiType = XChessPursuitCtrl.SCENE_UI_TYPE.BOSS_ROUND + } + }) +end + +function XUiChessPursuitFightTips:OnBtnResetClick() + XUiManager.DialogTip(CSXTextManagerGetText("TipTitle"), CSXTextManagerGetText("ChessPursuitResetTipContent"), XUiManager.DialogType.Normal, nil, function() + XDataCenter.ChessPursuitManager.RequestChessPursuitResetMapData(function () + self:Close() + self.RootUi:SwtichUI(XChessPursuitCtrl.MAIN_UI_TYPE.SCENE, { + MapId = self.MapId + }, true) + end, self.MapId) + end) +end + +function XUiChessPursuitFightTips:OnBtnAutoFightClick() + local maxRatio = XDataCenter.ChessPursuitManager.GetBossHurMax(self.MapId, self.TeamGridIndex) + maxRatio = string.format("%.2f", maxRatio * 100) + + XUiManager.DialogTip(CSXTextManagerGetText("TipTitle"), CSXTextManagerGetText("ChessPursuitAutoTipContent", maxRatio), XUiManager.DialogType.Normal, nil, function() + if self.CallBack then + self.CallBack() + end + XDataCenter.ChessPursuitManager.RequestChessPursuitAutoFightData(function () + self:Close() + end) + end) +end + +function XUiChessPursuitFightTips:OnBtnEnterFightClick() + local chessPursuitMapTemplate = self.ChessPursuitMapDb:GetChessPursuitMapTemplate() + local chessPursuitBoss = XChessPursuitConfig.GetChessPursuitBossTemplate(chessPursuitMapTemplate.BossId) + local stageId = chessPursuitBoss.StageId + local stage = XDataCenter.FubenManager.GetStageCfg(stageId) + local gridTeamDb = self.ChessPursuitMapDb:GetGridTeamDbByGridId(self.TeamGridIndex) + + local curTeam = XDataCenter.ChessPursuitManager.GetSaveTempTeamData(self.MapId, self.TeamGridIndex) + local preFight = curTeam and {} or gridTeamDb + if curTeam then + local cardIds, robotIds = XDataCenter.ChessPursuitManager.ClientTeamDataChangeServer(curTeam.TeamData) + preFight.CardIds = cardIds + preFight.CaptainPos = curTeam.CaptainPos + preFight.FirstFightPos = curTeam.FirstFightPos + preFight.RobotIds = robotIds + end + + if XDataCenter.FubenManager.CheckPreFight(stage) then + XDataCenter.FubenManager.EnterChessPursuitFight(stage, { + CardIds = preFight.CardIds, + CaptainPos = preFight.CaptainPos, + FirstFightPos = preFight.FirstFightPos, + RobotIds = preFight.RobotIds, + StageId = stage.StageId, + }, function() + if self.CallBack then + self.CallBack() + end + self:Close() + end) + end +end + +--@endregion + +function XUiChessPursuitFightTips:UpdateInfo() + local teamCharacterIds = self.ChessPursuitMapDb:GetTeamCharacterIds(self.TeamGridIndex) + local hurtBoss = self.ChessPursuitMapDb:GetHurtBossByGridId(self.TeamGridIndex) + local chessPursuitMapTemplate = XChessPursuitConfig.GetChessPursuitMapTemplate(self.MapId) + local chessPursuitMapBoss = XDataCenter.ChessPursuitManager.GetChessPursuitMapBoss(chessPursuitMapTemplate.BossId) + + for i, characterId in ipairs(teamCharacterIds) do + local gridBossAutoFight = self["GridBossAutoFight" .. i] + if characterId ~= 0 then + gridBossAutoFight.gameObject:SetActive(true) + local iconpath = self:GetHeadIconUrl(characterId) + self["RImgHead" .. i]:SetRawImage(iconpath) + self["TxtNickName" .. i].text = XCharacterConfigs.GetCharacterFullNameStr(characterId) + else + gridBossAutoFight.gameObject:SetActive(false) + end + end + + local ration = hurtBoss / chessPursuitMapBoss:GetInitHp() + self.TxtScore.text = string.format("%.2f%%", ration * 100) + + if hurtBoss >= 0 then + self.BtnAutoFight:SetDisable(false, true) + self:SetScoreDataIsActive(true) + else + self.BtnAutoFight:SetDisable(true, false) + self:SetScoreDataIsActive(false) + end +end + +function XUiChessPursuitFightTips:SetScoreDataIsActive(isActive) + if self.ScoreDate then + self.ScoreDate.gameObject:SetActiveEx(isActive) + end +end + +function XUiChessPursuitFightTips:GetHeadIconUrl(characterId) + if XRobotManager.CheckIsRobotId(characterId) then + characterId = XRobotManager.GetCharacterId(characterId) + end + + local fashionId = XCharacterConfigs.GetCharacterTemplate(characterId).DefaultNpcFashtionId + local headIcon = XDataCenter.FashionManager.GetFashionRoundnessNotItemHeadIcon(fashionId) + + return headIcon +end diff --git a/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiChessPursuitNewRoomSingle.lua b/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiChessPursuitNewRoomSingle.lua new file mode 100644 index 00000000..10e4550b --- /dev/null +++ b/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiChessPursuitNewRoomSingle.lua @@ -0,0 +1,15 @@ +-- 追击玩法出战界面代理 +local XUiChessPursuitNewRoomSingle = {} + +function XUiChessPursuitNewRoomSingle.LimitCharacter() +end + +function XUiChessPursuitNewRoomSingle.SetEditBattleUiTeam(newRoomSingle) + XDataCenter.ChessPursuitManager.SetPlayerTeamData(newRoomSingle.CurTeam, newRoomSingle.ChessPursuitData.MapId, newRoomSingle.ChessPursuitData.TeamGridIndex) +end + +function XUiChessPursuitNewRoomSingle.DestroyNewRoomSingle() + XDataCenter.ChessPursuitManager.ClearTempTeam() +end + +return XUiChessPursuitNewRoomSingle \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiChessPursuitShop/XUiChessPursuitShop.lua b/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiChessPursuitShop/XUiChessPursuitShop.lua new file mode 100644 index 00000000..8719e20e --- /dev/null +++ b/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiChessPursuitShop/XUiChessPursuitShop.lua @@ -0,0 +1,120 @@ +local CSXTextManagerGetText = CS.XTextManager.GetText +local XUiChessPursuitShopGrid = require("XUi/XUiChessPursuit/XUi/XUiChessPursuitShop/XUiChessPursuitShopGrid") +local XUiChessPursuitShop = XLuaUiManager.Register(XLuaUi, "UiChessPursuitShop") + +function XUiChessPursuitShop:OnAwake() + self.GridShop.gameObject:SetActiveEx(false) + self:AutoAddListener() + self:InitDynamicTable() +end + +function XUiChessPursuitShop:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelItemList) + self.DynamicTable:SetDelegate(self) + self.DynamicTable:SetProxy(XUiChessPursuitShopGrid, self) +end + +function XUiChessPursuitShop:AutoAddListener() + self:RegisterClickEvent(self.BtnTanchuangClose, self.Close) + self:RegisterClickEvent(self.BtnRImgIconCost, self.OnBtnRImgIconCostClick) + self:RegisterClickEvent(self.BtnBuy, self.OnBtnBuyClick) +end + +function XUiChessPursuitShop:OnStart(chessPursuitMapId, cb) + self.ChessPursuitMapId = chessPursuitMapId + self.Cb = cb + + self.CardMaxCount = XChessPursuitConfig.GetChessPursuitMapCardMaxCount(chessPursuitMapId) + self:SetTempHaveCards() + + local addCoin = XChessPursuitConfig.GetChessPursuitMapAddCoin(chessPursuitMapId) + self.TxtAdd.text = CSXTextManagerGetText("ChessPursuitEveryRoundAddCoinTips", addCoin) + + local coinId = XChessPursuitConfig.GetChessPursuitMapCoinId(chessPursuitMapId) + local coinIcon = XDataCenter.ItemManager.GetItemIcon(coinId) + self.RImgIconCost:SetRawImage(coinIcon) +end + +function XUiChessPursuitShop:SetTempHaveCards() + local chessPursuitMapDb = XDataCenter.ChessPursuitManager.GetChessPursuitMapDb(self.ChessPursuitMapId) + self.TempHaveCards = XTool.Clone(chessPursuitMapDb:GetBuyedCards()) +end + +function XUiChessPursuitShop:OnEnable() + self:Refresh() +end + +function XUiChessPursuitShop:OnDestroy() + if self.Cb then + self.Cb(self.TempHaveCards) + end +end + +function XUiChessPursuitShop:Refresh() + self:ClearCurSelectCard() + self:RefreshCardMaxCount() + self:RefreshDynamicTable() + self:RefreshSelectCardTips() + self.TxtRefreshCost.text = XDataCenter.ChessPursuitManager.GetCoinCount(self.ChessPursuitMapId) +end + +function XUiChessPursuitShop:RefreshCardMaxCount() + local chessPursuitMapDb = XDataCenter.ChessPursuitManager.GetChessPursuitMapDb(self.ChessPursuitMapId) + local currCardCount = chessPursuitMapDb:GetHaveCardsCount() + self.TxtCards.text = CSXTextManagerGetText("ChessPursuitCardMaxCount", currCardCount, self.CardMaxCount) +end + +function XUiChessPursuitShop:RefreshDynamicTable() + self.CardIdList = XDataCenter.ChessPursuitManager.GetShopCardIdList(self.ChessPursuitMapId) + self.DynamicTable:SetDataSource(self.CardIdList) + self.DynamicTable:ReloadDataSync() +end + +function XUiChessPursuitShop:RefreshSelectCardTips() + local curSelectCardId = self.CardIdList and self.CardIdList[self.CurSelectCardIndex] + if not curSelectCardId then + self:ClearCurSelectCard() + return + end + local coin = XChessPursuitConfig.GetCardSubCoin(curSelectCardId) + local coinId = XChessPursuitConfig.GetChessPursuitMapCoinId(self.ChessPursuitMapId) + local coinName = XDataCenter.ItemManager.GetItemName(coinId) + local name = XChessPursuitConfig.GetCardName(curSelectCardId) + self.TxtTips.text = CSXTextManagerGetText("ChessPursuitShopBuyTips", coin, coinName, name) + self.BtnBuy.gameObject:SetActiveEx(true) +end + +function XUiChessPursuitShop:RefreshCurSelectCardGrid(grid) + if self.CurSelectCardGrid then + self.CurSelectCardGrid:ShowImgSelect(self.CurSelectCardIndex) + end + self.CurSelectCardGrid = grid +end + +function XUiChessPursuitShop:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local cardId = self.CardIdList[index] + grid:Refresh(cardId, self.CurSelectCardIndex, self.ChessPursuitMapId, index) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + self.CurSelectCardIndex = index + grid:ShowImgSelect(self.CurSelectCardIndex) + self:RefreshCurSelectCardGrid(grid) + self:RefreshSelectCardTips() + end +end + +function XUiChessPursuitShop:OnBtnRImgIconCostClick() + XDataCenter.ChessPursuitManager.OpenCoinTip() +end + +function XUiChessPursuitShop:OnBtnBuyClick() + local curSelectCardId = self.CardIdList[self.CurSelectCardIndex] + XDataCenter.ChessPursuitManager.RequestChessPursuitBuyCardData({curSelectCardId}, handler(self, self.Refresh)) +end + +function XUiChessPursuitShop:ClearCurSelectCard() + self.CurSelectCardIndex = -1 + self.CurSelectCardGrid = nil + self.BtnBuy.gameObject:SetActiveEx(false) + self.TxtTips.text = "" +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiChessPursuitShop/XUiChessPursuitShopGrid.lua b/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiChessPursuitShop/XUiChessPursuitShopGrid.lua new file mode 100644 index 00000000..c8fc6375 --- /dev/null +++ b/Resources/Scripts/XUi/XUiChessPursuit/XUi/XUiChessPursuitShop/XUiChessPursuitShopGrid.lua @@ -0,0 +1,45 @@ +local CONDITION_COLOR = { + [true] = CS.UnityEngine.Color.white, + [false] = CS.UnityEngine.Color.red, +} + +local XUiChessPursuitShopGrid = XClass(nil, "XUiChessPursuitShopGrid") + +function XUiChessPursuitShopGrid:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiChessPursuitShopGrid:Refresh(cardId, curSelectCardIndex, chessPursuitMapId, gridIndex) + self.CardId = cardId + self.GridIndex = gridIndex + self.TxtName.text = XChessPursuitConfig.GetCardName(cardId) + self.TxtDes.text = XChessPursuitConfig.GetCardDescribe(cardId) + + local haveCoinCount = XDataCenter.ChessPursuitManager.GetCoinCount(chessPursuitMapId) + local sellCardCoin = XChessPursuitConfig.GetCardSubCoin(cardId) + self.TxtPrice.text = sellCardCoin + self.TxtPrice.color = CONDITION_COLOR[haveCoinCount >= sellCardCoin] + + local coinId = XChessPursuitConfig.GetChessPursuitMapCoinId(chessPursuitMapId) + local coinIcon = XDataCenter.ItemManager.GetItemIcon(coinId) + self.RImgPrice:SetRawImage(coinIcon) + + local qualityIcon = XChessPursuitConfig.GetShopBgQualityIcon(cardId) + self.Bg:SetRawImage(qualityIcon) + + local icon = XChessPursuitConfig.GetCardIcon(cardId) + self.RImgIcon:SetRawImage(icon) + + local isBuyedCard = XDataCenter.ChessPursuitManager.IsBuyedCard(chessPursuitMapId, cardId) + self.ImgSellOut.gameObject:SetActiveEx(isBuyedCard) + + self:ShowImgSelect(curSelectCardIndex) +end + +function XUiChessPursuitShopGrid:ShowImgSelect(curSelectCardIndex) + self.ImgSelect.gameObject:SetActiveEx(self.GridIndex == curSelectCardIndex) +end + +return XUiChessPursuitShopGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChristmasTree/XUiChristmasTree.lua b/Resources/Scripts/XUi/XUiChristmasTree/XUiChristmasTree.lua new file mode 100644 index 00000000..a299c9e7 --- /dev/null +++ b/Resources/Scripts/XUi/XUiChristmasTree/XUiChristmasTree.lua @@ -0,0 +1,742 @@ +local XUiChristmasTree = XLuaUiManager.Register(XLuaUi, "UiChristmasTreeMain") + +local AttrCount = 0 +local LocalStateCount = 0 +-- 全局的index设定为局部状态总数+1 +local OverallIndex = LocalStateCount + 1 +-- 触发拖拽前的延时 +local LongClickOffset = 200 +-- 计算最近挂点的范围 +local MaxDistance = 0.3 +local CSXTextManagerGetText = CS.XTextManager.GetText + +function XUiChristmasTree:OnAwake() + self:AddListener() + self.DynamicTable = XDynamicTableNormal.New(self.PanelGiftList.gameObject) + self.DynamicTable:SetProxy(XUiOrnamentGrid) + self.DynamicTable:SetDelegate(self) + self.Camera = CS.XUiManager.Instance.UiCamera + self.RectTransform = self.Transform:GetComponent("RectTransform") +end + +function XUiChristmasTree:OnEnable() +end + +function XUiChristmasTree:OnStart(actId) + self.ActTemplate = XDataCenter.ChristmasTreeManager.Reset(actId) + self.ActId = actId + + self.GridTreasureList = {} -- 任务格子 + self.BtnFilterList = {} -- 筛选排序页签 + self.AttrViewList = {} -- 首页评分 + self.BtnChangeList = {} -- 编辑模式普通状态切换按钮 + self.AttrViewEditList = {} -- 编辑模式评分 + self.BtnChangeEditList = {} -- 编辑模式预览状态切换按钮 + self.TreePartList = {} -- 预制体上的各个挂点 + self.PlacePoint = {} -- XUiPlacedOrnamentGrid + self.CurrentGroup = 0 -- 当前的状态index + self.LongClick = {} + + self.AutoLayout = self.Transform:Find("SafeAreaContentPane/PanelView/PanelScore/panelScoreDetail") + + OverallIndex, LocalStateCount = XChristmasTreeConfig.GetTreePartCount() + OverallIndex = LocalStateCount + 1 + AttrCount = #self.ActTemplate.AttrName + MaxDistance = self.ActTemplate.MaxDistance or MaxDistance + LongClickOffset = self.ActTemplate.LongClickOffset or LongClickOffset + self:InitUiView() + self.PanelDress.gameObject:SetActiveEx(false) + self.PanelView.gameObject:SetActiveEx(true) + self.InDressMode = false + self:SwitchView(OverallIndex) + self:UpdateTaskProgress() + self:UpdateOrnamentRedPoint() + self:CheckFirstOpen() + CS.UnityEngine.UI.LayoutRebuilder.ForceRebuildLayoutImmediate(self.AutoLayout) +end + +function XUiChristmasTree:OnDestroy() + self.IsOpenDetails = nil + self:StopActivityTimer() +end + +function XUiChristmasTree:CheckFirstOpen() + local firstOpen, openIndex, storyId = XDataCenter.ChristmasTreeManager.CheckFirstOpen() + if firstOpen then + XDataCenter.MovieManager.PlayMovie(storyId, function() + XDataCenter.ChristmasTreeManager.SetOpen(openIndex) + -- XSoundManager.PauseMusic() + end) + end +end + +function XUiChristmasTree:InitUiView() + local now = XTime.GetServerNowTimestamp() + local _, endTimeSecond = XFunctionManager.GetTimeByTimeId(self.ActTemplate.TimeId) + if endTimeSecond then + self.TxtDay.text = XUiHelper.GetTime(endTimeSecond - now, XUiHelper.TimeFormatType.ACTIVITY) + self:CreateActivityTimer(now, endTimeSecond) + end + self.TxtTitle.text = self.ActTemplate.Name + + for i, name in ipairs(self.ActTemplate.AttrName) do + local scoreDetail = self.PanelScore:Find("panelScoreDetail/Score".. i) + self.AttrViewList[i] = scoreDetail + scoreDetail:Find("TxtTitle"):GetComponent("Text").text = name + + scoreDetail = self.PanelScoreEdit:Find("panelScoreDetail/Score".. i) + self.AttrViewEditList[i] = scoreDetail + scoreDetail:Find("TxtTitle"):GetComponent("Text").text = name + + local btnFilter = self.PanelFilter.transform:Find("BtnAttr".. i):GetComponent("XUiButton") + self.BtnFilterList[i] = btnFilter + btnFilter:SetNameByGroup(0, name) + end + self.AttrViewList[#self.AttrViewList + 1] = self.PanelScore:Find("ScoreTotal") + self.AttrViewEditList[#self.AttrViewEditList + 1] = self.PanelScoreEdit:Find("ScoreTotal") + self.BtnFilterList[#self.BtnFilterList + 1] = self.PanelFilter.transform:Find("BtnDefault"):GetComponent("XUiButton") + for i = 1, LocalStateCount do + local btnChange = self.PanelChangeOver.transform:Find("BtnChange".. i):GetComponent("XUiButton") + self.BtnChangeList[i] = btnChange + btnChange = self.PanelChangeOverEdit.transform:Find("BtnChange".. i):GetComponent("XUiButton") + self.BtnChangeEditList[i] = btnChange + end + + self.PanelChangeOver:Init(self.BtnChangeList, function(index) + self:SwitchView(index) + self.PanelChangeOverEdit:SelectIndex(index, false) + end, -1) + self.PanelChangeOverEdit:Init(self.BtnChangeEditList, function(index) self:SwitchView(index) end, -1) + -- 默认页签的index设为属性总数+1 + self.PanelFilter:Init(self.BtnFilterList, function(index) self:OnBtnFilter(index) end, AttrCount + 1 ) + self.PanelTreasure.gameObject:SetActiveEx(false) +end + +function XUiChristmasTree:AddListener() + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + self.BtnHelp.CallBack = function() self:OnBtnHelpClick() end + self.BtnDress.CallBack = function() self:OnBtnDressClick() end + self.BtnSave.CallBack = function() self:OnBtnSaveClick() end + self.BtnPreview.CallBack = function() self:SwitchView() end + self.BtnActiveOrnament.CallBack = function() self:OnBtnActiveOrnament() end + self.BtnClear.CallBack = function() self:OnBtnClear() end + self.BtnSubItem.CallBack = function() self:OnBtnSubItem() end + + self:RegisterClickEvent(self.BtnTreasureBg, self.OnBtnTreasureBgClick) + self:RegisterClickEvent(self.BtnTreasure, self.OnBtnTreasureClick) + + self.RedPointActive = XRedPointManager.AddRedPointEvent(self.BtnActiveOrnament, self.OnCheckActive, self, { XRedPointConditions.Types.CONDITION_CHRISTMAS_TREE_ORNAMENT_ACTIVE }, nil, true) + self.RedPointReward = XRedPointManager.AddRedPointEvent(self.ImgRedProgress, self.OnCheckRewards, self, { XRedPointConditions.Types.CONDITION_CHRISTMAS_TREE_AWARD }, nil, true) + self.RedPointUnread = XRedPointManager.AddRedPointEvent(self.BtnDress, self.OnCheckUnread, self, { XRedPointConditions.Types.CONDITION_CHRISTMAS_TREE_ORNAMENT_READ }, nil, true) +end + +-- 是否显示红点 +function XUiChristmasTree:OnCheckActive(count) + self.BtnActiveOrnament:ShowReddot(count >= 0) +end + +function XUiChristmasTree:OnCheckRewards(count) + self.ImgRedProgress.gameObject:SetActiveEx(count >= 0) +end + +function XUiChristmasTree:OnCheckUnread(count) + self.BtnDress:ShowReddot(count >= 0) + self:UpdateOrnamentRedPoint() +end + +function XUiChristmasTree:UpdateOrnamentRedPoint() + if not self.DynamicTable then return end + self.DynamicTable:ReloadDataASync() + for i = 1, LocalStateCount do + local isUnread = XDataCenter.ChristmasTreeManager.CheckOrnamentGrpUnread(i) + self.BtnChangeList[i]:ShowReddot(isUnread) + self.BtnChangeEditList[i]:ShowReddot(isUnread) + end +end + +function XUiChristmasTree:OnBtnBackClick() + if self.InDressMode then + self:OnBtnQuitDressClick() + else + self:Close() + end +end + +function XUiChristmasTree:OnBtnMainUiClick() + if XDataCenter.ChristmasTreeManager.CheckChange() then + local title = CSXTextManagerGetText("TipTitle") + local content = CSXTextManagerGetText("ChristmasTreeRestoreHint") + XUiManager.DialogTip(title, content, XUiManager.DialogType.Normal,nil, XLuaUiManager.RunMain) + return + end + XLuaUiManager.RunMain() +end + +-- 搬运function XUiManager.ShowHelpTip(helpDataKey, cb)接口 +function XUiChristmasTree:OnBtnHelpClick() + local config = XHelpCourseConfig.GetHelpCourseTemplateByFunction("ChristmasTree") + if not config then + return + end + + if config.IsShowCourse == 1 then + XLuaUiManager.Open("UiHelp", config, nil) + else + XUiManager.UiFubenDialogTip(config.Name, config.Describe) + end +end + +function XUiChristmasTree:OnBtnTreasureClick() + self:InitTreasureGrade() + self.PanelTreasure.gameObject:SetActiveEx(true) + self:PlayAnimation("TreasureEnable") +end + +function XUiChristmasTree:OnBtnTreasureBgClick() + self:PlayAnimation("TreasureDisable", function() + self.PanelTreasure.gameObject:SetActiveEx(false) + self:UpdateTaskProgress() + end) +end + +function XUiChristmasTree:OnBtnQuitDressClick() + if XDataCenter.ChristmasTreeManager.CheckChange() then + local title = CSXTextManagerGetText("TipTitle") + local content = CSXTextManagerGetText("ChristmasTreeRestoreHint") + XUiManager.DialogTip(title, content, XUiManager.DialogType.Normal,nil, function() self:QuitDressMode() end) + else + self:QuitDressMode() + end +end + +function XUiChristmasTree:QuitDressMode() + XDataCenter.ChristmasTreeManager.ResetChange() + self.PanelView.gameObject:SetActiveEx(true) + self:PlayAnimation("QieHuan2", function () + self.PanelDress.gameObject:SetActiveEx(false) + end) + self.InDressMode = false + self:SwitchView(OverallIndex) + self:UpdateTaskProgress() +end + +function XUiChristmasTree:OnBtnDressClick() + self.PanelDress.gameObject:SetActiveEx(true) + self:PlayAnimation("QieHuan1", function () + self.PanelView.gameObject:SetActiveEx(false) + end) + self.InDressMode = true + self.PanelChangeOverEdit:SelectIndex(1) + self.PanelFilter:SelectIndex(AttrCount + 1) +end + +function XUiChristmasTree:OnBtnSaveClick() + XDataCenter.ChristmasTreeManager.SubmitChange(function() + XUiManager.TipText("ChristmasTreeSaveAppearanceSuccess") + self:OnBtnQuitDressClick() + end) +end + +function XUiChristmasTree:UnselectAllItem(exceptIndex) + for index in pairs(self.TreePartList) do + local item = self.PlacePoint[index] + if exceptIndex then + item:SetSelect(item.Index == exceptIndex and self.CurrentGroup ~= OverallIndex) + else + item:SetSelect(false) + item:SetLight(self.CurrentGroup ~= OverallIndex) + end + end + + if exceptIndex then + self.CurSelectGridIndex = exceptIndex + else + self.BtnRemove.gameObject:SetActiveEx(false) + end + + if self.CloseBg then + self.CloseBg.raycastTarget = false + end +end + +function XUiChristmasTree:OnBtnRemove() + XDataCenter.ChristmasTreeManager.RemoveOrnament(self.CurSelectGridIndex) + self:RefreshView() +end + +function XUiChristmasTree:OnBtnFilter(index) + self.CurrentFilterIndex = index or self.LastFilterIndex + self.SRComponent.enabled = true + if self.InDressMode and self.CurrentGroup == OverallIndex then + self.GiftList = XDataCenter.ChristmasTreeManager.GetAvailableOrnaments(self.LastGroup, self.CurrentFilterIndex) or {} + else + self.GiftList = XDataCenter.ChristmasTreeManager.GetAvailableOrnaments(self.CurrentGroup, self.CurrentFilterIndex) + end + + if self.LastGroup ~= self.CurrentGroup then + self:PlayAnimation("PanelGiftListEnable") + elseif self.LastFilterIndex ~= self.CurrentFilterIndex then + self:PlayAnimation("PanelGiftListEnable") + end + + self.DynamicTable:SetDataSource(self.GiftList) + self.DynamicTable:ReloadDataSync() + + self.SRComponent.enabled = false + self.LastFilterIndex = self.CurrentFilterIndex +end + +function XUiChristmasTree:OnBtnClear() + if XDataCenter.ChristmasTreeManager.CheckPartGrpEmpty(self.CurrentGroup) then return end + local title = CSXTextManagerGetText("TipTitle") + local content = CSXTextManagerGetText("ChristmasTreeRemoveOrnamentHint") + XUiManager.DialogTip(title, content, XUiManager.DialogType.Normal,nil, function () + XDataCenter.ChristmasTreeManager.RemoveOrnamentGrp(self.CurrentGroup) + self:RefreshView() + end) +end + +function XUiChristmasTree:OnBtnActiveOrnament() + local result, minItemId, minItemCount = XDataCenter.ChristmasTreeManager.CheckCanGetOrnament() + if not result then + if minItemCount > 0 then + XUiManager.TipMsg(CSXTextManagerGetText("ChristmasTreeSubItemInsufficientQuantity", XDataCenter.ItemManager.GetItemName(minItemId))) + else + XUiManager.TipMsg(CSXTextManagerGetText("ChristmasTreeOrnamentFull")) + end + else + XDataCenter.ChristmasTreeManager.ActiveOrnament(0, function () + self:RefreshView() + if self.InDressMode then + self:OnBtnFilter() + end + end) + end +end + +function XUiChristmasTree:OnBtnSubItem() + local _, id = XDataCenter.ChristmasTreeManager.CheckCanGetOrnament() + XLuaUiManager.Open("UiTip", id) +end + +function XUiChristmasTree:OnCancelRemoveBtn() + self:UnselectAllItem() + self.CurSelectGridIndex = nil +end + +-- 更新左下角的奖励按钮的状态 +function XUiChristmasTree:UpdateTaskProgress() + -- self.TxtDesc.gameObject:SetActiveEx(false) + self.ImgStarIcon.gameObject:SetActiveEx(false) + local curStars, totalStars = XDataCenter.ChristmasTreeManager.GetTaskProgress() + local received = XDataCenter.ChristmasTreeManager.CheckTaskAllFinish() + + XRedPointManager.Check(self.RedPointReward) + + self.ImgJindu.fillAmount = totalStars > 0 and curStars / totalStars or 0 + self.ImgJindu.gameObject:SetActiveEx(true) + self.TxtStarNum.text = CSXTextManagerGetText("Fract", curStars, totalStars) + self.ImgLingqu.gameObject:SetActiveEx(received) +end + +function XUiChristmasTree:InitTreasureGrade() + self.GridTreasureGrade.gameObject:SetActiveEx(false) + -- 先把所有的格子隐藏 + for j = 1, #self.GridTreasureList do + self.GridTreasureList[j].GameObject:SetActiveEx(false) + end + + local targetList = self.ActTemplate.TaskId + if not targetList then + return + end + + local offsetValue = 260 + local gridCount = #targetList + + for i = 1, gridCount do + local offerY = (1 - i) * offsetValue + local grid = self.GridTreasureList[i] + + if not grid then + local item = CS.UnityEngine.Object.Instantiate(self.GridTreasureGrade) -- 复制一个item + grid = XUiGridTreasureTask.New(self, item) + grid.Transform:SetParent(self.PanelGradeContent, false) + grid.Transform.localPosition = CS.UnityEngine.Vector3(item.transform.localPosition.x, item.transform.localPosition.y + offerY, item.transform.localPosition.z) + self.GridTreasureList[i] = grid + end + + grid:UpdateGradeGridTask(targetList[i]) + + grid:InitTreasureList() + grid.GameObject:SetActiveEx(true) + end +end + +function XUiChristmasTree:SwitchView(nextView) + --XLog.Warning("last", self.LastGroup, self.CurrentGroup ) + local lastGroup = self.CurrentGroup or 0 + if nextView then + self.CurrentGroup = nextView + elseif self.CurrentGroup == OverallIndex then + self.PanelChangeOver:SelectIndex(self.LastGroup, false) + self.CurrentGroup = self.LastGroup + else + self.CurrentGroup = OverallIndex + end + self:RefreshView(lastGroup) +end + +function XUiChristmasTree:RefreshView(lastGroup) + local AttrValue = XDataCenter.ChristmasTreeManager.GetAttrValue() + local AttrDelta = XDataCenter.ChristmasTreeManager.GetAttrDeltaValue() + for i, attrScore in ipairs(self.InDressMode and self.AttrViewEditList or self.AttrViewList) do + local txtScore = attrScore:Find("TxtScore"):GetComponent("Text") + txtScore.text = AttrValue[i] + -- 仅显示子属性差值 + if i < #self.AttrViewList then + local txtDelta = attrScore:Find("TxtScorePlus"):GetComponent("Text") + local value = AttrDelta[i] + if value > 0 then + txtDelta.text = CSXTextManagerGetText("ChristmasTreeAttrDeltaPlus", value) + elseif value < 0 then + txtDelta.text = CSXTextManagerGetText("ChristmasTreeAttrDeltaMinus", value) + else + txtDelta.text = "" + end + end + end + + if self.InDressMode then + local own, count = XDataCenter.ChristmasTreeManager.GetOrnamentCount() + self.TxtGiftCount.text = string.format("%d/%d", own, count) + if self.CurrentGroup ~= OverallIndex then + local isEmpty = XDataCenter.ChristmasTreeManager.CheckPartGrpEmpty(self.CurrentGroup) + self.BtnClear:SetButtonState(not isEmpty and XUiButtonState.Normal or XUiButtonState.Disable) + end + else + local canGet, minItemId, minItemCount = XDataCenter.ChristmasTreeManager.CheckCanGetOrnament() + local own = XDataCenter.ItemManager.GetCount(minItemId) + + self.TxtConsume.text = string.format("%d/%d", own, minItemCount) + self.RImgSubItem:SetRawImage(XDataCenter.ItemManager.GetItemIcon(minItemId)) + self.BtnActiveOrnament:SetButtonState(canGet and XUiButtonState.Normal or XUiButtonState.Disable) + end + + self.LastGroup = lastGroup or self.CurrentGroup + if self.LastGroup ~= self.CurrentGroup then + local isLoad = self.Tree.gameObject:GetComponent(typeof(CS.XUiLoadPrefab)) + if isLoad then + self:PlayAnimation("TreeDisable",function () + self:RefreshTree(self.CurrentGroup) + self:PlayAnimation("TreeEnable") + end) + return + end + end + + self:RefreshTree(self.CurrentGroup) +end + +function XUiChristmasTree:ResetLongClicker() + --for i,v in pairs(self.LongClick) do + -- if self.PlacePoint[i].IsPointChange then + -- v:Destroy() + -- self.LongClick[i] = nil + -- end + --end + + for i in pairs(self.TreePartList) do + if self.PlacePoint[i].IsPointChange then + self.LongClick[i] = XUiButtonLongClick.New(self.TreePartList[i]:GetComponent("XUiPointer") , 15, self, nil, self.OnDrag, function()self:OnEndDrag(true) end, false, self.PlacePoint[i]) + self.LongClick[i]:SetTriggerOffset(LongClickOffset) + end + end +end + +function XUiChristmasTree:RefreshTree(index) + local path + if index == OverallIndex then + path = self.ActTemplate.OverallPrefab + else + path = self.ActTemplate.PartPrefab[index] + end + self.TreeGroup = self.Tree.gameObject:LoadPrefab(path).transform + self:SwitchBtnChange() + -- 加载挂点 + self.IsPartGroupFull = true + self.PosInfo = XDataCenter.ChristmasTreeManager.GetCurrentOrnamentPos() + self.TreePartList = {} + for i = 1, XChristmasTreeConfig.GetTreePartCount() do + local part = self.TreeGroup:Find("Point"..i) + if part then + local itemInfo + if self.PosInfo[i] and self.PosInfo[i] ~= 0 then + itemInfo = XChristmasTreeConfig.GetOrnamentById(self.PosInfo[i]) + else + self.IsPartGroupFull = false + end + if not self.PlacePoint[i] then + self.PlacePoint[i] = XUiPlacedOrnamentGrid.New(self) + end + self.PlacePoint[i]:Refresh(part, itemInfo, i) + self.TreePartList[i] = self.PlacePoint[i].RImgIcon.transform + end + end + + self:UnselectAllItem() + self:SetAllItemLight(true) + if self.InDressMode then + self:OnBtnFilter() + end + self:ResetLongClicker() +end + +function XUiChristmasTree:SelectItem(index) + if not index or self.CurrentGroup == OverallIndex then return end + if self.DragItem then + return + end + self.CloseBg = self.TreeGroup:Find("RawImage"):GetComponent("RawImage") + local item = self.PlacePoint[index] + if self.CurSelectGridIndex == index then + self:OnCancelRemoveBtn() + elseif self.PosInfo[index] then + self.BtnRemove.gameObject:SetActiveEx(true) + self.BtnRemove.transform.localPosition = item.Transform.localPosition + self.BtnRemove.CallBack = function() self:OnBtnRemove() end + self:UnselectAllItem(index) + self.CloseBg.raycastTarget = true + self:RegisterClickEvent(self.CloseBg, function () self:OnCancelRemoveBtn() end) + + self.CurSelectGridIndex = index + else + self:UnselectAllItem() + end +end + +function XUiChristmasTree:SetAllItemLight(isLight) + for index in pairs(self.TreePartList) do + local item = self.PlacePoint[index] + item:SetLight(self.CurrentGroup ~= OverallIndex and isLight) + end +end + +-- 切换显示按钮 +function XUiChristmasTree:SwitchBtnChange() + if not self.InDressMode then + self.PanelChangeOver.gameObject:SetActiveEx(false) + self.PanelChangeOverEdit.gameObject:SetActiveEx(false) + elseif self.CurrentGroup == OverallIndex then + self.PanelChangeOver.gameObject:SetActiveEx(true) + self.PanelChangeOverEdit.gameObject:SetActiveEx(false) + for i = 1, AttrCount do + self.BtnChangeList[i]:SetButtonState(XUiButtonState.Normal) + end + self.BtnClear.gameObject:SetActiveEx(false) + else + self.PanelChangeOver.gameObject:SetActiveEx(false) + self.PanelChangeOverEdit.gameObject:SetActiveEx(true) + self.BtnClear.gameObject:SetActiveEx(true) + end + + for i = 1, LocalStateCount do + self.BtnChangeList[i].gameObject:SetActiveEx(true) + self.BtnChangeEditList[i].gameObject:SetActiveEx(true) + end +end + +--动态列表事件 +function XUiChristmasTree:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + local clicker = XUiButtonLongClick.New(grid.GridPointer, 15, self, nil, self.OnDrag, function()self:OnEndDrag(false) end, false, grid) + clicker:SetTriggerOffset(LongClickOffset) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.GiftList[index] + if not data then + return + end + grid:Refresh(data, index) + if self.CurrentFilterIndex <= AttrCount then + grid:ShowAttr(self.CurrentFilterIndex) + end + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + --grid:OpenDetail() + end +end + +-- 计时器 +function XUiChristmasTree:CreateActivityTimer(startTime, endTime) + local time = XTime.GetServerNowTimestamp() + self:StopActivityTimer() + self.ActivityTimer = XScheduleManager.ScheduleForever(function() + time = XTime.GetServerNowTimestamp() + if time > endTime then + self:Close() + XUiManager.TipError(CSXTextManagerGetText("ActivityMainLineEnd")) + self:StopActivityTimer() + return + end + self.TxtDay.text = XUiHelper.GetTime(endTime - time, XUiHelper.TimeFormatType.ACTIVITY) + end, XScheduleManager.SECOND, 0) +end + +function XUiChristmasTree:StopActivityTimer() + if self.ActivityTimer then + XScheduleManager.UnSchedule(self.ActivityTimer) + self.ActivityTimer = nil + end + if self.AnimTimer then + XScheduleManager.UnSchedule(self.AnimTimer) + self.AnimTimer = nil + end +end + +function XUiChristmasTree:CalculateNearestBlockIndex(ignorePlaced) + local nearestIndex = nil + local nearestDistance = 0 + for index, block in pairs(self.TreePartList) do + local ornamentId = self.PosInfo[index] or 0 + if block and (ignorePlaced or ornamentId == 0) then + local x1 = self.DragItem.gameObject.transform.position.x + local y1 = self.DragItem.gameObject.transform.position.y + local x2 = block.position.x + local y2 = block.position.y + local distance = (y2-y1)^2 + (x2-x1)^2 + if nearestDistance == 0 then + nearestIndex = index + nearestDistance = distance + else + if distance < nearestDistance then + nearestIndex = index + nearestDistance = distance + end + end + end + end + if nearestDistance <= MaxDistance then + return nearestIndex + end +end + +function XUiChristmasTree:OnDrag(time, caller, item) -- 拖拽 + local data, index, isPlaced, isOwn = item:GetInfo() + + if not self.DragItem then -- 第一次进入拖拽 没有拖拽的碎片 + self.IsDraging = true + if self.CurrentGroup == OverallIndex then + caller:Reset() + if self.InDressMode then + XUiManager.TipText("ChristmasTreeInPreviewMode") + end + return + end + + if not isOwn then + caller:Reset() + XUiManager.TipText("ChristmasTreeOrnamentNotOwn") + return + end + if self.IsPartGroupFull and not isPlaced then + caller:Reset() + XUiManager.TipText("ChristmasTreePartGroupFull") + return + end + -- 锁定中 退出 + if self.ClickLock then + caller:Reset() + return + end + + if data then + self.CurDragItemId = data.Id + self.NearestIndex = nil + self.DragItem = self.OrnamentDragItem + self.DragItem.gameObject:SetActiveEx(true) + self.DragItem:SetRawImage(data.ResPath) + self.DragItem.rectTransform.sizeDelta = CS.UnityEngine.Vector2(data.Width, data.Height) + self.DragItem.rectTransform.localPosition = self:GetPoint() + end + if isPlaced then + item.RImgIcon:CrossFadeAlpha(0.2, 0.2, false); + end + self.LastClickIndex = index + self:UnselectAllItem() + elseif self.IsDraging then-- 持续更新拖拽的碎片位置 + self.DragItem.gameObject.transform.localPosition = self:GetPoint() + local nearestIndex = self:CalculateNearestBlockIndex(isPlaced) + -- XLog.Warning(nearestIndex, nearestDistance) + if nearestIndex then + if not self.NearestIndex then + self.NearestIndex = nearestIndex + self.PlacePoint[nearestIndex]:SetSelect(true) + elseif self.NearestIndex ~= nearestIndex then + self.PlacePoint[self.NearestIndex]:SetSelect(false) + self.NearestIndex = nearestIndex + self.PlacePoint[nearestIndex]:SetSelect(true) + end + elseif self.NearestIndex then + self.PlacePoint[self.NearestIndex]:SetSelect(false) + self.NearestIndex = nil + end + end +end + +function XUiChristmasTree:OnEndDrag(isChangePiece) -- 抬起 + if not self.IsDraging then return end + if not self.NearestIndex then -- 点击抬起过快可能导致NearestIndex为空 或者 周围无可用挂点 + if self.DragItem then + if isChangePiece then + self.PlacePoint[self.LastClickIndex].RImgIcon:CrossFadeAlpha(1, 0.2, false); + end + self.DragItem.gameObject:SetActiveEx(false) + self.DragItem = nil + self.LastClickIndex = nil + end + self:UnselectAllItem() + elseif self.DragItem then + self.DragItem.gameObject:SetActiveEx(false) + self.DragItem = nil + self.PlacePoint[self.NearestIndex]:SetSelect(false) + if isChangePiece then + XDataCenter.ChristmasTreeManager.SwapOrnamentPos(self.NearestIndex ,self.LastClickIndex) + self.CurDragItemId = nil + -- self:SelectItem(self.LastClickIndex, ture) + self.PlacePoint[self.LastClickIndex].RImgIcon:CrossFadeAlpha(1, 0.2, false); + else + XDataCenter.ChristmasTreeManager.PutOrnament(self.NearestIndex ,self.CurDragItemId) + end + self.LastClickIndex = nil + self.NearestIndex = nil + self:RefreshView() + end + self.CurSelectGridIndex = nil + self.IsDraging = false + self.ClickLock = true + XScheduleManager.ScheduleOnce(function() + self.ClickLock = false + end, 100) +end + +function XUiChristmasTree:GetPoint() + local screenPoint + if CS.UnityEngine.Application.platform == CS.UnityEngine.RuntimePlatform.WindowsEditor or CS.UnityEngine.Application.platform == CS.UnityEngine.RuntimePlatform.WindowsPlayer then + screenPoint = CS.UnityEngine.Vector2(CS.UnityEngine.Input.mousePosition.x, CS.UnityEngine.Input.mousePosition.y) + else + screenPoint = CS.UnityEngine.Input.GetTouch(0).position + end + + -- 设置拖拽 + local hasValue, v2 = CS.UnityEngine.RectTransformUtility.ScreenPointToLocalPointInRectangle(self.RectTransform, screenPoint, self.Camera) + if hasValue then + local x = v2.x + local y = v2.y + --if x < -self.PieceMoveLimitX then x = -self.PieceMoveLimitX elseif x > self.PieceMoveLimitX then x = self.PieceMoveLimitX end + --if y < -self.PieceMoveLimitY then y = -self.PieceMoveLimitY elseif y > self.PieceMoveLimitY then y = self.PieceMoveLimitY end + return CS.UnityEngine.Vector3(x, y, 0) + else + return CS.UnityEngine.Vector3.zero + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChristmasTree/XUiGridTreasureTask.lua b/Resources/Scripts/XUi/XUiChristmasTree/XUiGridTreasureTask.lua new file mode 100644 index 00000000..4d9f24b2 --- /dev/null +++ b/Resources/Scripts/XUi/XUiChristmasTree/XUiGridTreasureTask.lua @@ -0,0 +1,150 @@ +XUiGridTreasureTask = XClass(nil, "XUiGridTreasureTask") + +function XUiGridTreasureTask:Ctor(rootUi, ui, treasureType) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.TreasureType = treasureType or XDataCenter.FubenManager.StageType.Mainline + self:InitAutoScript() + self.GridCommonItem = self.Transform:Find("PanelTreasureList/Viewport/PanelTreasureContent/GridCommon") + self.GridCommonItem.gameObject:SetActive(false) + self.PanelProgress.gameObject:SetActiveEx(false) + self.GridList = {} +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiGridTreasureTask:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiGridTreasureTask:AutoInitUi() + self.ImgGradeLine = self.Transform:Find("ImgGradeLine"):GetComponent("Image") + self.TxtGrade = self.Transform:Find("TxtGrade"):GetComponent("Text") + self.TxtGradeStarNums = self.Transform:Find("TxtGradeStarNums"):GetComponent("Text") + self.ImgGradeStarActive = self.Transform:Find("ImgGradeStarActive"):GetComponent("Image") + self.ImgGradeStarUnactive = self.Transform:Find("ImgGradeStarUnactive"):GetComponent("Image") + self.BtnReceive = self.Transform:Find("BtnReceive"):GetComponent("Button") + self.ImgCannotReceive = self.Transform:Find("ImgCannotReceive"):GetComponent("Image") + self.ImgAlreadyReceived = self.Transform:Find("ImgAlreadyReceived"):GetComponent("Image") + self.PanelTreasureList = self.Transform:Find("PanelTreasureList") + self.PanelTreasureContent = self.Transform:Find("PanelTreasureList/Viewport/PanelTreasureContent") + self.GridCommon = self.Transform:Find("PanelTreasureList/Viewport/PanelTreasureContent/GridCommon") + self.RImgIcon = self.Transform:Find("PanelTreasureList/Viewport/PanelTreasureContent/GridCommon/RImgIcon"):GetComponent("RawImage") + self.ImgQuality = self.Transform:Find("PanelTreasureList/Viewport/PanelTreasureContent/GridCommon/ImgQuality"):GetComponent("Image") + self.BtnClick = self.Transform:Find("PanelTreasureList/Viewport/PanelTreasureContent/GridCommon/BtnClick"):GetComponent("Button") + self.TxtCount = self.Transform:Find("PanelTreasureList/Viewport/PanelTreasureContent/GridCommon/TxtCount"):GetComponent("Text") + self.PanelProgress = self.Transform:Find("PanelProgress") + self.TxtTaskDescribe = self.Transform:Find("PanelProgress/TxtTaskDescribe"):GetComponent("Text") + self.TxtTaskNumQian = self.Transform:Find("PanelProgress/TxtTaskNumQian"):GetComponent("Text") + self.ProgressBg = self.Transform:Find("PanelProgress/ProgressBg") + self.ImgProgress = self.Transform:Find("PanelProgress/ProgressBg/ImgProgress"):GetComponent("Image") + + --保存初始颜色 + self.OriginalColors = { + starColor = self.ImgGradeStarActive.color, + starDisColor = self.ImgGradeStarUnactive.color + } +end + +function XUiGridTreasureTask:AutoAddListener() + CsXUiHelper.RegisterClickEvent(self.BtnReceive, function () self:OnBtnReceiveClick() end) +end +-- auto +function XUiGridTreasureTask:OnBtnReceiveClick() + local TaskData = XDataCenter.TaskManager.GetTaskDataById(self.TaskId) + + XDataCenter.TaskManager.FinishTask(TaskData.Id, function(rewardGoodsList) + XUiManager.OpenUiObtain(rewardGoodsList) + self:Refresh() + XEventManager.DispatchEvent(EVENT_CHRISTMAS_TREE_GOT_REWARD) + end) +end + +-- 显示挑战任务 +function XUiGridTreasureTask:UpdateGradeGridTask(taskId) + self.TaskId = taskId + self:Refresh() +end + +function XUiGridTreasureTask:Refresh() + self.ImgGradeStarActive.gameObject:SetActiveEx(false) + self.ImgGradeStarUnactive.gameObject:SetActiveEx(false) + self.TxtGradeStarNums.gameObject:SetActiveEx(false) + self.PanelProgress.gameObject:SetActiveEx(true) + self.ProgressBg.gameObject:SetActive(false) + + local config = XDataCenter.TaskManager.GetTaskTemplate(self.TaskId) + local TaskData = XDataCenter.TaskManager.GetTaskDataById(self.TaskId) + + if #config.Condition < 2 then--显示进度 + self.ProgressBg.gameObject:SetActive(true) + self.TxtTaskNumQian.gameObject:SetActive(true) + + local result = config.Result > 0 and config.Result or 1 + self.TxtTaskDescribe.text = config.Desc + + XTool.LoopMap(TaskData.Schedule, function(_, pair) + self.ImgProgress.fillAmount = pair.Value / result + pair.Value = (pair.Value >= result) and result or pair.Value + self.TxtTaskNumQian.text = CS.XTextManager.GetText("AlreadyobtainedCount", pair.Value, result) + end) + end + + if TaskData.State == XDataCenter.TaskManager.TaskState.Achieved then + self:SetBtnActive() + elseif TaskData.State == XDataCenter.TaskManager.TaskState.Finish then + self:SetBtnAlreadyReceive() + else + self:SetBtnCannotReceive() + end +end + +function XUiGridTreasureTask:SetBtnActive() + self.BtnReceive.gameObject:SetActive(true) + self.ImgAlreadyReceived.gameObject:SetActive(false) + self.ImgCannotReceive.gameObject:SetActive(false) +end + +function XUiGridTreasureTask:SetBtnCannotReceive() + self.BtnReceive.gameObject:SetActive(false) + self.ImgAlreadyReceived.gameObject:SetActive(false) + self.ImgCannotReceive.gameObject:SetActive(true) +end + +function XUiGridTreasureTask:SetBtnAlreadyReceive() + self.BtnReceive.gameObject:SetActive(false) + self.ImgAlreadyReceived.gameObject:SetActive(true) + self.ImgCannotReceive.gameObject:SetActive(false) +end + +function XUiGridTreasureTask:SetStarsActive(flag) + self.ImgGradeStarActive.gameObject:SetActiveEx(flag) + self.ImgGradeStarUnactive.gameObject:SetActiveEx(not flag) +end + +-- 初始化 treasure grid panel,填充数据 +function XUiGridTreasureTask:InitTreasureList() + local config = XDataCenter.TaskManager.GetTaskTemplate(self.TaskId) + local rewards = XRewardManager.GetRewardList(config.RewardId) + + for i, item in ipairs(rewards) do + local grid = self.GridList[i] + if not grid then + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommonItem) + grid = XUiGridCommon.New(self.RootUi, ui) + grid.Transform:SetParent(self.PanelTreasureContent, false) + self.GridList[i] = grid + end + grid:Refresh(item) + grid.GameObject:SetActive(true) + -- i = i + 1 + end + + for j = 1, #self.GridList do + if j > #rewards then + self.GridList[j].GameObject:SetActive(false) + end + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChristmasTree/XUiOrnamentGrid.lua b/Resources/Scripts/XUi/XUiChristmasTree/XUiOrnamentGrid.lua new file mode 100644 index 00000000..17291b0a --- /dev/null +++ b/Resources/Scripts/XUi/XUiChristmasTree/XUiOrnamentGrid.lua @@ -0,0 +1,54 @@ +XUiOrnamentGrid = XClass(nil, "XUiOrnamentGrid") + +function XUiOrnamentGrid:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.GiftNone = self.Transform:Find("GiftNone") +end + +function XUiOrnamentGrid:Init(uiRoot) + self.UiRoot = uiRoot +end + +function XUiOrnamentGrid:Refresh(data, index) + self.Index = index + self.Data = data + self.IsOwn = XDataCenter.ChristmasTreeManager.CheckOrnamentOwn(data.Id) + local iconPath = XItemConfigs.GetItemIconById(data.ItemId) + if self.IsOwn then + self.RImgIcon.gameObject:SetActiveEx(true) + self.RImgIcon:SetRawImage(iconPath) + self.RImgLock.gameObject:SetActiveEx(false) + self.GiftNone.gameObject:SetActiveEx(false) + else + self.RImgIcon.gameObject:SetActiveEx(false) + self.RImgLock.gameObject:SetActiveEx(true) + self.RImgLock:SetRawImage(iconPath) + self.GiftNone.gameObject:SetActiveEx(true) + end + -- self.RImgIcon:CrossFadeAlpha( and 1 or 0.5, 0, false); + self.TxtName.text = data.Name + local isUnread = XDataCenter.ChristmasTreeManager.CheckOrnamentUnread(data.Id) + --XLog.Warning("isUnread", isUnread, data.Id) + self.RedPoint.gameObject:SetActiveEx(isUnread) + CsXUiHelper.RegisterClickEvent(self.RImgBg, function() self:OpenDetail() end) +end + +function XUiOrnamentGrid:ShowAttr(index) + self.TxtName.text = string.format("%s:%d", XDataCenter.ChristmasTreeManager.GetAttrName(index), self.Data.Attr[index]) +end + +function XUiOrnamentGrid:OpenDetail() + if self.UiRoot.ClickLock then return end + XDataCenter.ChristmasTreeManager.SetOrnamentRead(self.Data.Id) + local data = XDataCenter.ChristmasTreeManager.GetTempItemData(self.Data.Id) + XLuaUiManager.Open("UiTip", data) +end + +function XUiOrnamentGrid:GetInfo() + -- 第三个参数是 isPlaced + return self.Data, self.Index, false, self.IsOwn +end + +return XUiOrnamentGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiChristmasTree/XUiPlacedOrnamentGrid.lua b/Resources/Scripts/XUi/XUiChristmasTree/XUiPlacedOrnamentGrid.lua new file mode 100644 index 00000000..8e80610f --- /dev/null +++ b/Resources/Scripts/XUi/XUiChristmasTree/XUiPlacedOrnamentGrid.lua @@ -0,0 +1,100 @@ +XUiPlacedOrnamentGrid = XClass(nil, "XUiPlacedOrnamentGrid") +local MAX_TYPE_NUM = 99 --最大挂点类型序号 + +function XUiPlacedOrnamentGrid:Ctor(uiRoot) + self.UiRoot = uiRoot +end + +function XUiPlacedOrnamentGrid:Refresh(ui, data, index) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Index = index + self.Data = data + self:AutoRegister() + if data then + self.RImgIcon:SetRawImage(data.ResPath) + self.RImgIcon.gameObject:SetActiveEx(true) + self.RImgIcon.rectTransform.sizeDelta = CS.UnityEngine.Vector2(data.Width * data.PlaceScale, data.Height * data.PlaceScale) + self.HaveItem = true + else + self.RImgIcon.gameObject:SetActiveEx(false) + self.HaveItem = false + end + XTool.InitUiObject(self) +end + +function XUiPlacedOrnamentGrid:AutoRegister() + local type = 1 + if self.Data then + for k, v in ipairs(self.Data.PartId) do + if v == self.Index then + type = self.Data.PosType[k] + break; + end + end + end + + self.Type = type + local point = self.Transform:Find("type1") + local isMatch = false + for i = 1, MAX_TYPE_NUM do + local temp = self.Transform:Find("type"..i) + if temp then + temp.gameObject:SetActiveEx(i == type) + if i == type then + point = temp + isMatch = true + end + else + break + end + end + + if not isMatch then + XLog.Warning("Can not find correct type in this Point...", "Point:", self.Index, "type:", type) + end + + self.IsPointChange = self.LastPoint ~= point + if self.IsPointChange then + self.RImgIcon = point:Find("RawImage"):GetComponent("RawImage") + self.RedNormal = point:Find("Red").gameObject + self.RedSelect = point:Find("RedSelect").gameObject + XUiHelper.RegisterClickEvent(self, self.RImgIcon, self.OnBtnClick) + self.UiPointer = point:Find("RawImage"):GetComponent("XUiPointer") + if not self.UiPointer then + self.RImgIcon.gameObject:AddComponent(typeof(CS.XUiPointer)) + end + end + + self.LastPoint = point +end + +function XUiPlacedOrnamentGrid:SetLight(isLight) + self.IsLight = isLight + if self.IsSelect and not isLight then + self:SetSelect(false) + self.RedNormal:SetActiveEx(false) + return + end + self.RedSelect:SetActiveEx(false) + self.RedNormal:SetActiveEx(isLight) +end + +function XUiPlacedOrnamentGrid:SetSelect(isSelect) + self.IsSelect = isSelect + self.IsLight = isSelect or self.IsLight + self.RedNormal:SetActiveEx(not isSelect) + self.RedSelect:SetActiveEx(isSelect) +end + +function XUiPlacedOrnamentGrid:OnBtnClick() + CS.XAudioManager.PlaySound(XSoundManager.UiBasicsMusic.Main_huge) + self.UiRoot:SelectItem(self.Index) +end + +function XUiPlacedOrnamentGrid:GetInfo() + -- 第三、四个参数是 isPlaced、isOwn + return self.Data, self.Index, true, true +end + +return XUiPlacedOrnamentGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiClickClearGame/XUiClickClearGame.lua b/Resources/Scripts/XUi/XUiClickClearGame/XUiClickClearGame.lua new file mode 100644 index 00000000..cafdf489 --- /dev/null +++ b/Resources/Scripts/XUi/XUiClickClearGame/XUiClickClearGame.lua @@ -0,0 +1,265 @@ +local CSXTextManagerGetText = CS.XTextManager.GetText + +local XUiClickClearPanelGeneral = require("XUi/XUiClickClearGame/XUiClickClearPanelGeneral") +local XUiClickClearPanelGame = require("XUi/XUiClickClearGame/XUiClickClearPanelGame") +local XUiClickClearPanelCountdown = require("XUi/XUiClickClearGame/XUiClickClearPanelCountdown") + +local FirstInGameStage = { + First = 1, + NotFirst = 2, +} + +local XUiClickClearGame = XLuaUiManager.Register(XLuaUi, "UiClickClearGame") + +function XUiClickClearGame:OnAwake() + self.GeneralPanel = XUiClickClearPanelGeneral.New(self.PanelGeneral.gameObject, self) + self.GamePanel = XUiClickClearPanelGame.New(self.PanelGame.gameObject, self) + self.CountdownPanel = XUiClickClearPanelCountdown.New(self.PanelCountdown.gameObject, self) +end + +function XUiClickClearGame:OnStart() + self:AutoRegisterBtnListener() + self:InitBtnGroup() +end + +function XUiClickClearGame:OnEnable() + local bool, remineDaysStr = XDataCenter.XClickClearGameManager.GetRemainDaysStr() + if bool then + self.TextRemainDays.text = remineDaysStr + else + self.TextRemainDays.text = CSXTextManagerGetText("EquipFunctionNotOpen") + end + + XDataCenter.XClickClearGameManager.ResetGame() + self:ResetUi() + self:CheckHitFace() + + XRedPointManager.AddRedPointEvent(self.BtnTabSimple, self.OnCheckSimpleOpen, self, { XRedPointConditions.Types.CONDITION_CLICKCLEARGAME_DIFFICULT_UNLOCK }, XDataCenter.XClickClearGameManager.GameDifficultys.Simple, true) + XRedPointManager.AddRedPointEvent(self.BtnTabComplex, self.OnCheckComplexOpen, self, { XRedPointConditions.Types.CONDITION_CLICKCLEARGAME_DIFFICULT_UNLOCK }, XDataCenter.XClickClearGameManager.GameDifficultys.Complex, true) + XRedPointManager.AddRedPointEvent(self.BtnTabDifficult, self.OnCheckDifficultOpen, self, { XRedPointConditions.Types.CONDITION_CLICKCLEARGAME_DIFFICULT_UNLOCK }, XDataCenter.XClickClearGameManager.GameDifficultys.Difficult, true) + XRedPointManager.AddRedPointEvent(self.BtnTabHell, self.OnCheckHellOpen, self, { XRedPointConditions.Types.CONDITION_CLICKCLEARGAME_DIFFICULT_UNLOCK }, XDataCenter.XClickClearGameManager.GameDifficultys.Hell, true) + XRedPointManager.AddRedPointEvent(self.BtnTreasure, self.OnCheckRewardRedPoint, self, { XRedPointConditions.Types.CONDITION_CLICKCLEARGAME_REWARD }, nil, true) +end + +function XUiClickClearGame:OnDisable() + +end + +function XUiClickClearGame:OnDestroy() + +end + +function XUiClickClearGame:OnGetEvents() + return { + XEventId.EVENT_CLICKCLEARGAME_INIT_COMPLETE, + XEventId.EVENT_CLICKCLEARGAME_GAME_ACCOUNT, + XEventId.EVENT_CLICKCLEARGAME_HEAD_COUNT_CHANGED, + XEventId.EVENT_CLICKCLEARGAME_GAME_PLAYING, + XEventId.EVENT_CLICKCLEARGAME_GAME_PAUSE, + XEventId.EVENT_CLICKCLEARGAME_GAME_RESET, + XEventId.EVENT_CLICKCLEARGAME_GAME_PAGE_CHANGED, + XEventId.EVENT_CLICKCLEARGAME_TAKED_REWARD, + } +end + +function XUiClickClearGame:OnNotify(evt, ...) + if evt == XEventId.EVENT_CLICKCLEARGAME_INIT_COMPLETE then + self:GameInitCompleteCallBack() + elseif evt == XEventId.EVENT_CLICKCLEARGAME_GAME_ACCOUNT then + self:GameAccountCallBack(...) + elseif evt == XEventId.EVENT_CLICKCLEARGAME_HEAD_COUNT_CHANGED then + self.GamePanel.TaskPanel:HeadDataHasChanged() + elseif evt == XEventId.EVENT_CLICKCLEARGAME_GAME_PLAYING then + self.CountdownPanel:OnGamePlaying() + elseif evt == XEventId.EVENT_CLICKCLEARGAME_GAME_PAUSE then + self.CountdownPanel:OnGamePause(...) + elseif evt == XEventId.EVENT_CLICKCLEARGAME_GAME_RESET then + self:GameResetCallBack() + elseif evt == XEventId.EVENT_CLICKCLEARGAME_GAME_PAGE_CHANGED then + self.GamePanel.BookMarkPanel:RefreshBookMark() + elseif evt == XEventId.EVENT_CLICKCLEARGAME_TAKED_REWARD then + self:RefreshUiReward() + end +end + +function XUiClickClearGame:OnCheckSimpleOpen(count) + self.BtnTabSimple:ShowReddot(count>=0) +end + +function XUiClickClearGame:OnCheckComplexOpen(count) + self.BtnTabComplex:ShowReddot(count>=0) +end + +function XUiClickClearGame:OnCheckDifficultOpen(count) + self.BtnTabDifficult:ShowReddot(count>=0) +end + +function XUiClickClearGame:OnCheckHellOpen(count) + self.BtnTabHell:ShowReddot(count>=0) +end + +function XUiClickClearGame:OnCheckRewardRedPoint(count) + self.BtnTreasure:ShowReddot(count>=0) +end + +function XUiClickClearGame:AutoRegisterBtnListener() + self.BtnBack.CallBack = function () self.OnBtnBackClick() end + self.BtnMainUi.CallBack = function () self.OnBtnMainClick() end + self.BtnHelp.CallBack = function () self.OnBtnHelpClick() end + self:BindHelpBtnOnly(self.BtnHelp) + self.BtnTreasure.CallBack = function () self:OnBtnTreasureClick() end +end + +function XUiClickClearGame.OnBtnBackClick() + local gameInfo = XDataCenter.XClickClearGameManager.GetGameInfo() + if gameInfo.CurGameState ~= XDataCenter.XClickClearGameManager.GameState.Playing then + XLuaUiManager.Close("UiClickClearGame") + return + end + + XDataCenter.XClickClearGameManager.SetGameStatePause() + XLuaUiManager.Open("UiDialog", "", CSXTextManagerGetText("ClickClearGameOutHint"), XUiManager.DialogType.Normal, function() + XDataCenter.XClickClearGameManager.SetGameStatePlaying() end, function() + XLuaUiManager.Close("UiClickClearGame") end) +end + +function XUiClickClearGame.OnBtnMainClick() + local gameInfo = XDataCenter.XClickClearGameManager.GetGameInfo() + if gameInfo.CurGameState ~= XDataCenter.XClickClearGameManager.GameState.Playing then + XLuaUiManager.RunMain() + return + end + + XDataCenter.XClickClearGameManager.SetGameStatePause() + XLuaUiManager.Open("UiDialog", "", CSXTextManagerGetText("ClickClearGameOutHint"), XUiManager.DialogType.Normal, function() + XDataCenter.XClickClearGameManager.SetGameStatePlaying() end, function() + XLuaUiManager.RunMain() end) +end + +function XUiClickClearGame.OnBtnHelpClick() + local helpId = XDataCenter.XClickClearGameManager.GetHelpId() + local template = XHelpCourseConfig.GetHelpCourseTemplateById(helpId) + + local gameInfo = XDataCenter.XClickClearGameManager.GetGameInfo() + if gameInfo.CurGameState == XDataCenter.XClickClearGameManager.GameState.Playing then + XDataCenter.XClickClearGameManager.SetGameStatePause() + XUiManager.ShowHelpTip(template.Function, function () XDataCenter.XClickClearGameManager.SetGameStatePlaying() end) + return + end + + XUiManager.ShowHelpTip(template.Function) +end + +function XUiClickClearGame:OnBtnTreasureClick() + self:OpenOneChildUi("UiClickClearReward", self) +end + +function XUiClickClearGame:ResetUi() + self.GamePanel:Hide() + self.GeneralPanel:Hide() + self.CountdownPanel:Hide() + self.CoverAllPanel.gameObject:SetActiveEx(false) + + local curDifficulty = XDataCenter.XClickClearGameManager.GetCurGameDifficulty() + if curDifficulty then + self.DifficultyBtnGroup:SelectIndex(curDifficulty) + else + self.DifficultyBtnGroup:SelectIndex(XDataCenter.XClickClearGameManager.GameDifficultys.Simple) + end + self:RefreshBtnGroup() + self:RefreshUiReward() +end + +function XUiClickClearGame:RefreshUiReward() + local rewardCount = XDataCenter.XClickClearGameManager.GetRewardCount() + local rewardCanTakedCount = XDataCenter.XClickClearGameManager.GetRewardCanTakeCount() + local rewardTakedCount = XDataCenter.XClickClearGameManager.GetRewardTakedCount() + self.ImgJindu.fillAmount = rewardCanTakedCount/rewardCount + self.TxtSinglePlayerFinishNum.text = CSXTextManagerGetText("ClickClearGameRewardProcess", rewardCanTakedCount, rewardCount) + if rewardTakedCount == rewardCount then + self.ImgLingqu.gameObject:SetActiveEx(true) + else + self.ImgLingqu.gameObject:SetActiveEx(false) + end +end + +function XUiClickClearGame:GameInitCompleteCallBack() + self:ChangeCover(true) -- 打开难度按钮遮罩 + self.CoverAllPanel.gameObject:SetActiveEx(false) + self.GeneralPanel:Hide() + self.GamePanel:Show() + self.CountdownPanel:Show() + + XDataCenter.XClickClearGameManager.SetGameStatePlaying() +end + +function XUiClickClearGame:GameAccountCallBack(isWin) + self.CountdownPanel:Hide() + if isWin then + self.GeneralPanel:Show(XDataCenter.XClickClearGameManager.GeneralPanelStates.Clearance) + else + self.GeneralPanel:Show(XDataCenter.XClickClearGameManager.GeneralPanelStates.Failure) + end + self.CoverAllPanel.gameObject:SetActiveEx(true) + self:ChangeCover(false) + self:RefreshBtnGroup() + self:RefreshUiReward() +end + +function XUiClickClearGame:GameResetCallBack() + self:ChangeCover(false) + self:ResetUi() +end + +function XUiClickClearGame:InitBtnGroup() + self.TabList = { + self.BtnTabSimple, + self.BtnTabComplex, + self.BtnTabDifficult, + self.BtnTabHell, + } + self.DifficultyBtnGroup:Init(self.TabList, function(index) self:OnSelectTabBtn(index) end) + self:RefreshBtnGroup() +end + +function XUiClickClearGame:RefreshBtnGroup() + for i,v in ipairs(self.TabList) do + local btnName, btnNameEn = XDataCenter.XClickClearGameManager.GetStageTagNameAndNameEnById(i) + v:SetNameByGroup(0, btnName) + v:SetNameByGroup(1, btnNameEn) + local isOpen = XDataCenter.XClickClearGameManager.CheckTabBtnByLastDifficult(i) + v:SetDisable(not isOpen) + end +end + +function XUiClickClearGame:OnSelectTabBtn(index) + self.TabList[index]:ShowReddot(false) -- 取消红点显示 + XDataCenter.XClickClearGameManager.SetTakeDifficultyBtnRedPoint(index, true) + + self.GamePanel:Hide() + self.CountdownPanel:Hide() + local isOpen = XDataCenter.XClickClearGameManager.CheckTabBtnByLastDifficult(index) + if isOpen then + XDataCenter.XClickClearGameManager.ResetData() + XDataCenter.XClickClearGameManager.SetCurGameDifficulty(index) + self.CoverAllPanel.gameObject:SetActiveEx(false) + self.GeneralPanel:Show(XDataCenter.XClickClearGameManager.GeneralPanelStates.Default) + else + local tipText = CSXTextManagerGetText("ClickClearGameUnlock"..(index-1)) + XUiManager.TipError(tipText) + end +end + +function XUiClickClearGame:ChangeCover(isCover) + self.CoverPanel.gameObject:SetActiveEx(isCover) +end + +function XUiClickClearGame:CheckHitFace() + local firstInGameStage = XSaveTool.GetData(string.format("%d%s", XPlayer.Id, "IsFirstInClickClearGame")) + if firstInGameStage and firstInGameStage == FirstInGameStage.NotFirst then + return + end + + XSaveTool.SaveData(string.format("%d%s", XPlayer.Id, "IsFirstInClickClearGame"), FirstInGameStage.NotFirst) + self.OnBtnHelpClick() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiClickClearGame/XUiClickClearPanelCountdown.lua b/Resources/Scripts/XUi/XUiClickClearGame/XUiClickClearPanelCountdown.lua new file mode 100644 index 00000000..59e1b28f --- /dev/null +++ b/Resources/Scripts/XUi/XUiClickClearGame/XUiClickClearPanelCountdown.lua @@ -0,0 +1,90 @@ +local textManager = CS.XTextManager + +local PanelStage = { + Playing = 1, + Pause = 2, +} + +local XUiClickClearPanelCountdown = XClass(nil, "XUiClickClearPanelCountdown") + +function XUiClickClearPanelCountdown:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) +end + +function XUiClickClearPanelCountdown:Show() + self.GameObject:SetActiveEx(true) + self:RefreshUi() + self.Stage = PanelStage.Pause +end + +function XUiClickClearPanelCountdown:Hide() + self.GameObject:SetActiveEx(false) +end + +function XUiClickClearPanelCountdown:RefreshUi() + local gameInfo = XDataCenter.XClickClearGameManager.GetGameInfo() + self.TextCountdown.text = string.format("%.2f", gameInfo.RemainTime) +end + +function XUiClickClearPanelCountdown:OnGamePlaying() + local gameInfo = XDataCenter.XClickClearGameManager.GetGameInfo() + self.FullTime = gameInfo.RemainTime + if self.FullTime <= 0 then + XDataCenter.XClickClearGameManager.SetGameStateAccount(false) + self.Stage = PanelStage.Pause + return + end + self.AnimaTimer = XUiHelper.Tween(self.FullTime, function(f) return self:OnUpdate(f) end, function() self:TimeOverCallBack() end) + self.Stage = PanelStage.Playing +end + +function XUiClickClearPanelCountdown:OnGamePause(isCostTime) + if isCostTime then + self.IsInCostTime = isCostTime + XUiManager.TipError(textManager.GetText("ClickClearGameTouchWrongHeadTip")) + end + self.Stage = PanelStage.Pause +end + +function XUiClickClearPanelCountdown:OnUpdate(f) + if self.Stage == PanelStage.Pause then + return true + end + + local remainTime = self.FullTime - f * self.FullTime + if remainTime < 0 then + remainTime = 0 + end + XDataCenter.XClickClearGameManager.SetRemainTime(remainTime) + local timeStr = string.format("%.2f", remainTime) + self.TextCountdown.text = timeStr +end + +function XUiClickClearPanelCountdown:TimeOverCallBack() + if self.Stage == PanelStage.Pause then + if self.FullTime <= 0 then + XDataCenter.XClickClearGameManager.SetGameStateAccount(false) + return + end + + if self.IsInCostTime then + self:OnGamePlaying() + self.IsInCostTime = false + return + end + + return + end + + XDataCenter.XClickClearGameManager.SetGameStateAccount(false) + self.Stage = PanelStage.Pause +end + +function function_name() + +end + +return XUiClickClearPanelCountdown \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiClickClearGame/XUiClickClearPanelGame.lua b/Resources/Scripts/XUi/XUiClickClearGame/XUiClickClearPanelGame.lua new file mode 100644 index 00000000..1c182ebe --- /dev/null +++ b/Resources/Scripts/XUi/XUiClickClearGame/XUiClickClearPanelGame.lua @@ -0,0 +1,88 @@ +local textManager = CS.XTextManager +local tableInsert = table.insert +local XUiGridClickClearGamePage = require("XUi/XUiClickClearGame/XUiGridClickClearGamePage") +local XUiClickClearPanelGameTask = require("XUi/XUiClickClearGame/XUiClickClearPanelGameTask") +local XUiClickClearPanelGameBookMark = require("XUi/XUiClickClearGame/XUiClickClearPanelGameBookMark") + +local XUiClickClearPanelGame = XClass(nil, "XUiClickClearPanelGame") + +function XUiClickClearPanelGame:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + + self:Init() +end + +function XUiClickClearPanelGame:Init() + self.TaskPanel = XUiClickClearPanelGameTask.New(self.PanelTask, self) + self.BookMarkPanel = XUiClickClearPanelGameBookMark.New(self.PanelBookMark, self) + + self:AutoAddBtnListener() + self:InitDynamicTable() +end + +function XUiClickClearPanelGame:Show() + self.GameObject:SetActiveEx(true) + self.DynamicTableCurve:Clear() + local gameInfo = XDataCenter.XClickClearGameManager.GetGameInfo() + self.TaskPanel:Show() + self.BookMarkPanel:Show() + self.DynamicTableCurve:SetDataSource(gameInfo.HeadInfoPageList) + self.DynamicTableCurve:ReloadData(0) +end + +function XUiClickClearPanelGame:Hide() + self.GameObject:SetActiveEx(false) +end + +function XUiClickClearPanelGame:AutoAddBtnListener() + self:RegisterClickEvent(self.BtnLast, function () self:OnClickLastBtn() end) + self:RegisterClickEvent(self.BtnNext, function () self:OnClickNextBtn() end) +end + +function XUiClickClearPanelGame:OnClickLastBtn() + local nextIndex = XDataCenter.XClickClearGameManager.GetLastPageIndex() + self.DynamicTableCurve:TweenToIndex(nextIndex) + +end + +function XUiClickClearPanelGame:OnClickNextBtn() + local lastIndex = XDataCenter.XClickClearGameManager.GetNextPageIndex() + self.DynamicTableCurve:TweenToIndex(lastIndex) + +end + +function XUiClickClearPanelGame:InitDynamicTable() + self.DynamicTableCurve = XDynamicTableCurve.New(self.PageParent) + self.DynamicTableCurve:SetProxy(XUiGridClickClearGamePage) + self.DynamicTableCurve:SetDelegate(self) +end + +function XUiClickClearPanelGame:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:Refresh(index) + end +end + +function XUiClickClearPanelGame:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelActive:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelActive:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +return XUiClickClearPanelGame \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiClickClearGame/XUiClickClearPanelGameBookMark.lua b/Resources/Scripts/XUi/XUiClickClearGame/XUiClickClearPanelGameBookMark.lua new file mode 100644 index 00000000..85ee8717 --- /dev/null +++ b/Resources/Scripts/XUi/XUiClickClearGame/XUiClickClearPanelGameBookMark.lua @@ -0,0 +1,52 @@ +local textManager = CS.XTextManager + +local XUiClickClearPanelGameBookMark = XClass(nil, "XUiClickClearPanelGameBookMark") + +function XUiClickClearPanelGameBookMark:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + + self:Init() +end + +function XUiClickClearPanelGameBookMark:Init() + self.PressPoints = { + self.Pressed1, + self.Pressed2, + self.Pressed3, + self.Pressed4, + self.Pressed5, + self.Pressed6, + self.Pressed7, + self.Pressed8, + self.Pressed9, + } +end + +function XUiClickClearPanelGameBookMark:Show() + local gameInfo = XDataCenter.XClickClearGameManager.GetGameInfo() + local pageCount = gameInfo.HeadInfoPageCount + for i,v in ipairs(self.PressPoints) do + if i < pageCount then + v.gameObject:SetActiveEx(true) + else + v.gameObject:SetActiveEx(false) + end + end + self.GameObject:SetActiveEx(true) + self:RefreshBookMark() +end + +function XUiClickClearPanelGameBookMark:RefreshBookMark() + local gameInfo = XDataCenter.XClickClearGameManager.GetGameInfo() + local pageIndex = gameInfo.CurrentHeadRealPageIndex + self.CurPoint.transform:SetSiblingIndex(pageIndex-1) +end + +function XUiClickClearPanelGameBookMark:Hide() + self.GameObject:SetActiveEx(false) +end + +return XUiClickClearPanelGameBookMark \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiClickClearGame/XUiClickClearPanelGameRewardData.lua b/Resources/Scripts/XUi/XUiClickClearGame/XUiClickClearPanelGameRewardData.lua new file mode 100644 index 00000000..fde4a3e8 --- /dev/null +++ b/Resources/Scripts/XUi/XUiClickClearGame/XUiClickClearPanelGameRewardData.lua @@ -0,0 +1,39 @@ +XUiClickClearPanelGameRewardData = XClass(nil, "XUiClickClearPanelGameRewardData") + +function XUiClickClearPanelGameRewardData:Ctor(gameStageId, rewardId, rewardConditionDesc) + self.GameStageId = gameStageId + self.RewardId = rewardId + self.ConditionDesc = rewardConditionDesc + self.IsTaked = false + self.IsCanTake = false +end + +function XUiClickClearPanelGameRewardData:GetGameStageId() + return self.GameStageId +end + +function XUiClickClearPanelGameRewardData:GetRewardId() + return self.RewardId +end + +function XUiClickClearPanelGameRewardData:GetConditionDesc() + return self.ConditionDesc +end + +function XUiClickClearPanelGameRewardData:CheckIsTaked() + return self.IsTaked +end + +function XUiClickClearPanelGameRewardData:SetIsTaked(isTaked) + self.IsTaked = isTaked +end + +function XUiClickClearPanelGameRewardData:CheckCanTake() + return self.IsCanTake +end + +function XUiClickClearPanelGameRewardData:SetCanTake(canTake) + self.IsCanTake = canTake +end + +return XUiClickClearPanelGameRewardData \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiClickClearGame/XUiClickClearPanelGameTask.lua b/Resources/Scripts/XUi/XUiClickClearGame/XUiClickClearPanelGameTask.lua new file mode 100644 index 00000000..9b68ad82 --- /dev/null +++ b/Resources/Scripts/XUi/XUiClickClearGame/XUiClickClearPanelGameTask.lua @@ -0,0 +1,53 @@ +local textManager = CS.XTextManager + +local XUiClickClearPanelGameTask = XClass(nil, "XUiClickClearPanelGameTask") + +function XUiClickClearPanelGameTask:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) +end + +function XUiClickClearPanelGameTask:Show() + self.GameObject:SetActiveEx(true) + self:Refresh() +end + +function XUiClickClearPanelGameTask:Hide() + self.GameObject:SetActiveEx(false) +end + +function XUiClickClearPanelGameTask:HeadDataHasChanged() + self:RefreshData() +end + +function XUiClickClearPanelGameTask:Refresh() + local gameInfo = XDataCenter.XClickClearGameManager.GetGameInfo() + + local normalTaskDesc = gameInfo.HeadNormalDesc + local specialTaskDesc = gameInfo.HeadSpecialDesc + + self.TextNormalDesc.text = normalTaskDesc + self.TextSpecialDesc.text = specialTaskDesc + + self:RefreshData() +end + +function XUiClickClearPanelGameTask:RefreshData() + local gameInfo = XDataCenter.XClickClearGameManager.GetGameInfo() + local normalHeadCount = gameInfo.HeadNormalCurCount + local normalHeadTarCount = gameInfo.HeadNormalTargetCount + local specialHeadCount = gameInfo.HeadSpecialCurCount + local specialHeadTarCount = gameInfo.HeadSpecialTargetCount + + local normalProcess = normalHeadCount/normalHeadTarCount + local specialProcess = specialHeadCount/specialHeadTarCount + + self.SliderNormalProcess.fillAmount = normalProcess + self.SliderSpecialProcess.fillAmount = specialProcess + self.TextNormalProcess.text = textManager.GetText("ClickClearGameTaskProcess", normalHeadCount, normalHeadTarCount) + self.TextSpecialProcess.text = textManager.GetText("ClickClearGameTaskProcess", specialHeadCount, specialHeadTarCount) +end + +return XUiClickClearPanelGameTask \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiClickClearGame/XUiClickClearPanelGeneral.lua b/Resources/Scripts/XUi/XUiClickClearGame/XUiClickClearPanelGeneral.lua new file mode 100644 index 00000000..1ffa145d --- /dev/null +++ b/Resources/Scripts/XUi/XUiClickClearGame/XUiClickClearPanelGeneral.lua @@ -0,0 +1,75 @@ +local textManager = CS.XTextManager +local tableInsert = table.insert + +local XUiClickClearPanelGeneralDefault = require("XUi/XUiClickClearGame/XUiClickClearPanelGeneralDefault") +local XUiClickClearPanelGeneralClearance = require("XUi/XUiClickClearGame/XUiClickClearPanelGeneralClearance") +local XUiClickClearPanelGeneralFailure = require("XUi/XUiClickClearGame/XUiClickClearPanelGeneralFailure") + +local ConfirmBtnNames = { + textManager.GetText("StartGame"), + textManager.GetText("ConfirmText"), + textManager.GetText("ConfirmText"), +} + +local XUiClickClearPanelGeneral = XClass(nil, "XUiClickClearPanelGeneral") + +function XUiClickClearPanelGeneral:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + + self:Init() + self:InitChildrenPanel() +end + +function XUiClickClearPanelGeneral:Init() + self.BtnTongBlack.CallBack = function () self:OnClickBtnConfirm() end +end + +function XUiClickClearPanelGeneral:InitChildrenPanel() + self.DefaultPanel = XUiClickClearPanelGeneralDefault.New(self.PanelDefault.gameObject, self) + self.ClearancePanel = XUiClickClearPanelGeneralClearance.New(self.PanelClearance.gameObject, self) + self.FailurePanel = XUiClickClearPanelGeneralFailure.New(self.PanelFailure.gameObject, self) + self.PanelChildren = {} + self.PanelChildren = { + self.DefaultPanel, + self.ClearancePanel, + self.FailurePanel, + } +end + +function XUiClickClearPanelGeneral:Show(panelState) + self.GameObject:SetActiveEx(true) + self:ChangeState(panelState) + +end + +function XUiClickClearPanelGeneral:Hide() + self.GameObject:SetActiveEx(false) +end + +function XUiClickClearPanelGeneral:HideAllChildrenPanel() + for _,v in ipairs(self.PanelChildren) do + v:Hide() + end +end + +function XUiClickClearPanelGeneral:ChangeState(panelState) + self:HideAllChildrenPanel() + self.PanelChildren[panelState]:Show() + self.BtnTongBlack:SetName(ConfirmBtnNames[panelState]) + self.CurPanelState = panelState +end + +function XUiClickClearPanelGeneral:OnClickBtnConfirm() + if self.CurPanelState == XDataCenter.XClickClearGameManager.GeneralPanelStates.Default then + XDataCenter.XClickClearGameManager.StartGame() + elseif self.CurPanelState == XDataCenter.XClickClearGameManager.GeneralPanelStates.Clearance then + XDataCenter.XClickClearGameManager.ResetGame() + elseif self.CurPanelState == XDataCenter.XClickClearGameManager.GeneralPanelStates.Failure then + XDataCenter.XClickClearGameManager.ResetGame() + end +end + +return XUiClickClearPanelGeneral \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiClickClearGame/XUiClickClearPanelGeneralClearance.lua b/Resources/Scripts/XUi/XUiClickClearGame/XUiClickClearPanelGeneralClearance.lua new file mode 100644 index 00000000..dc23fd54 --- /dev/null +++ b/Resources/Scripts/XUi/XUiClickClearGame/XUiClickClearPanelGeneralClearance.lua @@ -0,0 +1,25 @@ +local textManager = CS.XTextManager + +local XUiClickClearPanelGeneralClearance = XClass(nil, "XUiClickClearPanelGeneralClearance") + +function XUiClickClearPanelGeneralClearance:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) +end + +function XUiClickClearPanelGeneralClearance:Show() + local gameInfo = XDataCenter.XClickClearGameManager.GetGameInfo() + if gameInfo.CurGameState == XDataCenter.XClickClearGameManager.GameState.Account then + self.TextPassTime.text = string.format( "%.2f", gameInfo.UseTime) + self.ItemNewRecord.gameObject:SetActiveEx(gameInfo.IsNewRecord) + self.GameObject:SetActiveEx(true) + end +end + +function XUiClickClearPanelGeneralClearance:Hide() + self.GameObject:SetActiveEx(false) +end + +return XUiClickClearPanelGeneralClearance \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiClickClearGame/XUiClickClearPanelGeneralDefault.lua b/Resources/Scripts/XUi/XUiClickClearGame/XUiClickClearPanelGeneralDefault.lua new file mode 100644 index 00000000..857c666b --- /dev/null +++ b/Resources/Scripts/XUi/XUiClickClearGame/XUiClickClearPanelGeneralDefault.lua @@ -0,0 +1,31 @@ +local textManager = CS.XTextManager + +local XUiClickClearPanelGeneralDefault = XClass(nil, "XUiClickClearPanelGeneralDefault") + +function XUiClickClearPanelGeneralDefault:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) +end + +function XUiClickClearPanelGeneralDefault:Show() + local curDifficulty = XDataCenter.XClickClearGameManager.GetCurGameDifficulty() + local isPass, passRecord = XDataCenter.XClickClearGameManager.CheckPass(curDifficulty) + if isPass then + self.PassTimePanel.gameObject:SetActiveEx(true) + self.TextNotPass.gameObject:SetActiveEx(false) + self.TextPassTime.text = string.format( "%.2f", passRecord) + else + self.PassTimePanel.gameObject:SetActiveEx(false) + self.TextNotPass.gameObject:SetActiveEx(true) + end + + self.GameObject:SetActiveEx(true) +end + +function XUiClickClearPanelGeneralDefault:Hide() + self.GameObject:SetActiveEx(false) +end + +return XUiClickClearPanelGeneralDefault \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiClickClearGame/XUiClickClearPanelGeneralFailure.lua b/Resources/Scripts/XUi/XUiClickClearGame/XUiClickClearPanelGeneralFailure.lua new file mode 100644 index 00000000..93eb1a27 --- /dev/null +++ b/Resources/Scripts/XUi/XUiClickClearGame/XUiClickClearPanelGeneralFailure.lua @@ -0,0 +1,20 @@ +local textManager = CS.XTextManager + +local XUiClickClearPanelGeneralFailure = XClass(nil, "XUiClickClearPanelGeneralFailure") + +function XUiClickClearPanelGeneralFailure:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) +end + +function XUiClickClearPanelGeneralFailure:Show() + self.GameObject:SetActiveEx(true) +end + +function XUiClickClearPanelGeneralFailure:Hide() + self.GameObject:SetActiveEx(false) +end + +return XUiClickClearPanelGeneralFailure \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiClickClearGame/XUiClickClearReward.lua b/Resources/Scripts/XUi/XUiClickClearGame/XUiClickClearReward.lua new file mode 100644 index 00000000..bbb2b212 --- /dev/null +++ b/Resources/Scripts/XUi/XUiClickClearGame/XUiClickClearReward.lua @@ -0,0 +1,56 @@ +local XUiClickClearReward = XLuaUiManager.Register(XLuaUi, "UiClickClearReward") + +local XUiGridClickClearReward = require("XUi/XUiClickClearGame/XUiGridClickClearReward") +function XUiClickClearReward:OnAwake() + self.GridTreasureGrade.gameObject:SetActive(false) + + self.DynamicTable = XDynamicTableNormal.New(self.PanelTreasureGrade) + self.DynamicTable:SetDelegate(self) + self.DynamicTable:SetProxy(XUiGridClickClearReward) + + CsXUiHelper.RegisterClickEvent(self.BtnTreasureBg, handler(self, self.Close)) + self.BtnTanchuangClose.CallBack = function() self:Close() end +end + +function XUiClickClearReward:OnStart(rootUi) + self.RootUi = rootUi +end + +function XUiClickClearReward:SetupStarReward() + local rewardList = XDataCenter.XClickClearGameManager.GetSortRewardList() + if not rewardList then + return + end + + self.RewardList = rewardList + + self.DynamicTable:SetDataSource(rewardList) + self.DynamicTable:ReloadDataSync() +end + +function XUiClickClearReward:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid.RootUi = self + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.RewardList[index] + if not data then return end + grid:Refresh(data) + end +end + +function XUiClickClearReward:OnEnable() + self:SetupStarReward() +end + + +function XUiClickClearReward:OnNotify(evt, ...) + if evt == XEventId.EVENT_CLICKCLEARGAME_TAKED_REWARD then + self:SetupStarReward() + end +end + +function XUiClickClearReward:OnGetEvents() + return { + XEventId.EVENT_CLICKCLEARGAME_TAKED_REWARD, + } +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiClickClearGame/XUiGridClickClearGameHead.lua b/Resources/Scripts/XUi/XUiClickClearGame/XUiGridClickClearGameHead.lua new file mode 100644 index 00000000..cbd136ba --- /dev/null +++ b/Resources/Scripts/XUi/XUiClickClearGame/XUiGridClickClearGameHead.lua @@ -0,0 +1,82 @@ +local textManager = CS.XTextManager +local tableInsert = table.insert + +local XUiGridClickClearGameHead = XClass(nil, "XUiGridClickClearGameHead") + +local PathHeadLine = "Head/EffectLine" +local PathHeadLine1 = "Head/EffectLine1" +local PathHeadLine2 = "Head/EffectLine2" + +function XUiGridClickClearGameHead:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + self.Head = self.Transform:Find("Head") + self.CanvasGroup = self.Head.transform:GetComponent("CanvasGroup") + self.Image = self.Transform:Find("Head/Image") + + self.ImageGO = self.Image.gameObject + self.ImageRT = self.Image:GetComponent("RectTransform") + self.ImageSizeDelta = self.ImageRT.sizeDelta + + self.AvatarRT = self.Transform:Find("Head/Avatar"):GetComponent("RectTransform") + self.AvatarY = self.AvatarRT.localPosition.y + self.AvatarSizeDelta = self.AvatarRT.sizeDelta + + self.RectTransformDict = {} + self.OriginYDict = {} + -- self.SizeDeltaDict = {} + self:InitY(PathHeadLine) + self:InitY(PathHeadLine1) + self:InitY(PathHeadLine2) +end + +function XUiGridClickClearGameHead:Init(rootUi) + self.rootUi = rootUi +end + +function XUiGridClickClearGameHead:Refresh(headInfo, realIndex, index) + local isBeCatched = XDataCenter.XClickClearGameManager.CheckHeadIsCatch(realIndex, index) + if isBeCatched then + self.HeadIcon.gameObject:SetActiveEx(false) + return + end + local iconPath = headInfo.Url + self.RawImageAvatar:SetRawImage(iconPath) + self.HeadIcon.gameObject:SetActiveEx(true) +end + +function XUiGridClickClearGameHead:OnRecycle() + if self.CanvasGroup.alpha < 1 then + self.CanvasGroup.alpha = 1 + -- self.ImageGO:SetActiveEx(false) + self.ImageRT.sizeDelta = CS.UnityEngine.Vector2(self.ImageSizeDelta.x, self.ImageSizeDelta.y) + + self.AvatarRT.localPosition = CS.UnityEngine.Vector3(self.AvatarRT.localPosition.x, self.AvatarY, 0) + self.AvatarRT.sizeDelta = CS.UnityEngine.Vector2(self.AvatarSizeDelta.x, self.AvatarSizeDelta.y) + + self:ResetY(PathHeadLine) + self:ResetY(PathHeadLine1) + self:ResetY(PathHeadLine2) + end +end + +function XUiGridClickClearGameHead:OnClick(index) + XDataCenter.XClickClearGameManager.OnTouchedHead(index, self) +end + +function XUiGridClickClearGameHead:InitY(path) + local rt = self.Transform:Find(path):GetComponent("RectTransform") + self.RectTransformDict[path] = rt + self.OriginYDict[path] = rt.localPosition.y + -- self.SizeDeltaDict[path] = rt.sizeDelta +end + +function XUiGridClickClearGameHead:ResetY(path) + local rt = self.RectTransformDict[path] + rt.localPosition = CS.UnityEngine.Vector3(rt.localPosition.x, self.OriginYDict[path], 0) + -- rt.sizeDelta = CS.UnityEngine.Vector2(self.AvatarSizeDelta.x, self.AvatarSizeDelta.y) +end + +return XUiGridClickClearGameHead \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiClickClearGame/XUiGridClickClearGamePage.lua b/Resources/Scripts/XUi/XUiClickClearGame/XUiGridClickClearGamePage.lua new file mode 100644 index 00000000..b458e7cb --- /dev/null +++ b/Resources/Scripts/XUi/XUiClickClearGame/XUiGridClickClearGamePage.lua @@ -0,0 +1,47 @@ +local textManager = CS.XTextManager +local tableInsert = table.insert + +local XUiGridClickClearGameHead = require("XUi/XUiClickClearGame/XUiGridClickClearGameHead") + +local XUiGridClickClearGamePage = XClass(nil, "XUiGridClickClearGamePage") + +function XUiGridClickClearGamePage:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiGridClickClearGamePage:Init(rootUi) + self.rootUi = rootUi + self:InitDynamicTable() +end + +function XUiGridClickClearGamePage:Refresh(index) + self.RealIndex = XDataCenter.XClickClearGameManager.CalcRealIndex(index) + local gameInfo = XDataCenter.XClickClearGameManager.GetGameInfo() + self.HeadList = gameInfo.HeadInfoPageList[self.RealIndex] + self.DynamicTable:SetDataSource(self.HeadList) + self.DynamicTable:ReloadDataASync() +end + +function XUiGridClickClearGamePage:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.GameObject) + self.DynamicTable:SetProxy(XUiGridClickClearGameHead) + self.DynamicTable:SetDelegate(self) +end + +function XUiGridClickClearGamePage:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.HeadList[index] + local realIndex = self.RealIndex + grid:Refresh(data, realIndex, index) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + grid:OnClick(index) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_RECYCLE then + grid:OnRecycle() + end +end + +return XUiGridClickClearGamePage \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiClickClearGame/XUiGridClickClearReward.lua b/Resources/Scripts/XUi/XUiClickClearGame/XUiGridClickClearReward.lua new file mode 100644 index 00000000..fa09010f --- /dev/null +++ b/Resources/Scripts/XUi/XUiClickClearGame/XUiGridClickClearReward.lua @@ -0,0 +1,89 @@ +local XUiGridClickClearReward = XClass(nil, "XUiGridClickClearReward") + +function XUiGridClickClearReward:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + self.GridCommon.gameObject:SetActive(false) + + self.GridList = {} + + self.BtnReceive.CallBack = function() self:OnBtnReceiveClick() end +end + +function XUiGridClickClearReward:OnBtnReceiveClick() + + if not self.Data:CheckCanTake() then + return + end + + XDataCenter.XClickClearGameManager.GetRewardRequest(self.Data:GetGameStageId(), function(reward) + XUiManager.OpenUiObtain(reward, CS.XTextManager.GetText("Award")) + local gameStageId = self.Data:GetGameStageId() + self.Data = XDataCenter.XClickClearGameManager.GetRewardData(gameStageId) + -- self:Refresh(self.Data) + end) +end + +function XUiGridClickClearReward:Refresh(data) + self.Data = data + local conditionDesc = self.Data:GetConditionDesc() + self.TxtGradeCondition.text = conditionDesc + if self.Data:CheckIsTaked() then + self:SetBtnAlreadyReceive() + else + if self.Data:CheckCanTake() then + self:SetBtnActive() + else + self:SetBtnCannotReceive() + end + end + self:SetupTreasureList() +end + +function XUiGridClickClearReward:SetBtnActive() + self.BtnReceive.gameObject:SetActive(true) + self.ImgAlreadyReceived.gameObject:SetActive(false) + self.ImgCannotReceive.gameObject:SetActive(false) +end + +function XUiGridClickClearReward:SetBtnCannotReceive() + self.BtnReceive.gameObject:SetActive(false) + self.ImgAlreadyReceived.gameObject:SetActive(false) + self.ImgCannotReceive.gameObject:SetActive(true) +end + +function XUiGridClickClearReward:SetBtnAlreadyReceive() + self.BtnReceive.gameObject:SetActive(false) + self.ImgAlreadyReceived.gameObject:SetActive(true) + self.ImgCannotReceive.gameObject:SetActive(false) +end + +function XUiGridClickClearReward:SetupTreasureList() + if self.Data == nil or self.Data:GetRewardId() == nil then + XLog.Error("treasure have no RewardId ") + return + end + + local rewards = XRewardManager.GetRewardList(self.Data:GetRewardId()) + for i, item in ipairs(rewards) do + local grid = self.GridList[i] + if not grid then + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommon) + grid = XUiGridCommon.New(self.RootUi, ui) + grid.Transform:SetParent(self.PanelTreasureContent, false) + self.GridList[i] = grid + end + grid:Refresh(item) + grid.GameObject:SetActive(true) + end + + for j = 1, #self.GridList do + if j > #rewards then + self.GridList[j].GameObject:SetActive(false) + end + end +end + +return XUiGridClickClearReward \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCollectionWall/XUiCollectionWall.lua b/Resources/Scripts/XUi/XUiCollectionWall/XUiCollectionWall.lua new file mode 100644 index 00000000..360633f5 --- /dev/null +++ b/Resources/Scripts/XUi/XUiCollectionWall/XUiCollectionWall.lua @@ -0,0 +1,76 @@ +local XUiCollectionWall = XLuaUiManager.Register(XLuaUi, "UiCollectionWall") + +local XUiGridCollectionWall = require("XUi/XUiCollectionWall/XUiCollectionWallGrid/XUiGridCollectionWall") + +function XUiCollectionWall:OnStart() + self:InitComponent() + self:AddListener() +end + +function XUiCollectionWall:OnEnable() + self:Refresh() +end + +function XUiCollectionWall:Refresh() + self:SetupDynamicTable() +end + +function XUiCollectionWall:InitComponent() + self.AssetPanel = XUiPanelAsset.New( + self, + self.PanelAsset, + XDataCenter.ItemManager.ItemId.FreeGem, + XDataCenter.ItemManager.ItemId.ActionPoint, + XDataCenter.ItemManager.ItemId.Coin + ) + + self.PanelNoneTemplate.gameObject:SetActiveEx(false) + self.GridCollectionWall.gameObject:SetActiveEx(false) + self:InitDynamicTable() +end + +function XUiCollectionWall:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelDynamicTable) + self.DynamicTable:SetProxy(XUiGridCollectionWall, self, XCollectionWallConfigs.EnumWallGridOpenType.Overview) + self.DynamicTable:SetDelegate(self) +end + +function XUiCollectionWall:SetupDynamicTable() + self.PageDatas = XDataCenter.CollectionWallManager.GetWallEntityList() + self.DynamicTable:SetDataSource(self.PageDatas) + self.DynamicTable:ReloadDataSync(#self.PageDatas) +end + +function XUiCollectionWall:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:UpdateGrid(self.PageDatas[index]) + end +end + +function XUiCollectionWall:AddListener() + self.BtnDisplySetting.CallBack = function() + self:OnBtnDisplaySettingClick() + end + self.BtnBack.CallBack = function() + self:OnBtnBackClick() + end + self.BtnMainUi.CallBack = function() + self:OnBtnMainUiClick() + end + self:BindHelpBtn(self.BtnHelp, "CollectionWall") +end + +function XUiCollectionWall:OnBtnDisplaySettingClick() + self:Close() + XEventManager.DispatchEvent(XEventId.EVENT_PLAYER_SETTING) +end + +function XUiCollectionWall:OnBtnBackClick() + self:Close() + XDataCenter.CollectionWallManager.ClearLocalCaptureCache() +end + +function XUiCollectionWall:OnBtnMainUiClick() + XLuaUiManager.RunMain() + XDataCenter.CollectionWallManager.ClearLocalCaptureCache() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCollectionWall/XUiCollectionWallEdit.lua b/Resources/Scripts/XUi/XUiCollectionWall/XUiCollectionWallEdit.lua new file mode 100644 index 00000000..f2348962 --- /dev/null +++ b/Resources/Scripts/XUi/XUiCollectionWall/XUiCollectionWallEdit.lua @@ -0,0 +1,588 @@ +local XUiCollectionWallEdit = XLuaUiManager.Register(XLuaUi, "UiCollectionWallEdit") + +local XUiGridSelectItem = require("XUi/XUiCollectionWall/XUiCollectionWallGrid/XUiGridSelectItem") +local XUiGridPlacedCollection = require("XUi/XUiCollectionWall/XUiCollectionWallGrid/XUiGridPlacedCollection") + +function XUiCollectionWallEdit:OnStart(wallData) + self.IsEditMode = false + self.WallData = wallData + self.CurSelectCollection = nil -- 摆放模式中选择的收藏品 + self.IsPanelSelectItemDraging = false -- 底部的Item选择界面是否在拖动中 + + self.RedHorPool = {} -- 水平红格子条 + self.RedVerPool = {} -- 垂直红格子条 + + self.BlueHorPool = {} -- 水平蓝格子条 + self.BlueVerPool = {} -- 垂直蓝格子条 + + self.GridOccupy = {} -- 记录被占用中的格子,索引:xy坐标,如01,22,x为十位数,y为个位数,值:占用这个格子的收藏品Id + self.CollectionDic = {} -- 墙面上的收藏品字典,id做索引 + + self:InitComponent() + self:AddListener() + + -- 默认中心位置 + self.DefaultLocalPos = {} + self.DefaultLocalPos.x = self.PanelWall.rect.width / 2 + self.DefaultLocalPos.y = self.PanelWall.rect.height / 2 + + self:Refresh() +end + +function XUiCollectionWallEdit:OnEnable() + if self.IsEditMode then + -- 处于编辑模式,释放编辑模式开启动画 + self:PlayAnimation("PanelCenterEnable") + end +end + +function XUiCollectionWallEdit:OnDisable() + if self.CurSelectCollection then + -- 处于摆放模式,返回到编辑模式 + self:OnBtnCancelClick() + end +end + +--- +--- 根据Manager中存放的WallData来生成墙面 +function XUiCollectionWallEdit:Refresh() + self.PedestalId = self.WallData:GetPedestalId() + self.BackgroundId = self.WallData:GetBackgroundId() + self:RefreshBackground() + self:GenerateCollection(self.WallData:GetCollectionSetInfos()) + self:UpdateGridOccupy() + + if self.IsEditMode then + self:RefreshSelectItemList() + end +end + +function XUiCollectionWallEdit:InitComponent() + self.RImgFrame.gameObject:SetActiveEx(false) + self.PanelTag.gameObject:SetActiveEx(false) + self.PanelConfirmMenu.gameObject:SetActiveEx(false) + self.PanelSelectItem.gameObject:SetActiveEx(false) + self.GridDecorationItem.gameObject:SetActiveEx(false) + self.ImgEmpty.gameObject:SetActiveEx(false) + + self.BlueHorItem.gameObject:SetActiveEx(false) + self.BlueVerItem.gameObject:SetActiveEx(false) + self.RedHorItem.gameObject:SetActiveEx(false) + self.RedVerItem.gameObject:SetActiveEx(false) + + self.BtnEdit.gameObject:SetActiveEx(true) + + self:InitTagGroup() + self:InitDynamicTable() +end + +function XUiCollectionWallEdit:InitTagGroup() + self.Tag = { + self.TagBackground, + self.TagPedestal, + self.TagLittle, + self.TagMiddle, + self.TagBig, + } + self.TagGroup:Init(self.Tag, function(tagIndex) + self:OnClickTagCallBack(tagIndex) + end) +end + +function XUiCollectionWallEdit:OnPanelItemListDrag(eventData) + if self.PanelItemListScorllRect then + self.PanelItemListScorllRect:OnDrag(eventData); + end +end + +function XUiCollectionWallEdit:OnPanelItemListBeginDrag(eventData) + if self.PanelItemListScorllRect then + self.PanelItemListScorllRect:OnBeginDrag(eventData); + end +end + +function XUiCollectionWallEdit:OnPanelItemListEndDrag(eventData) + if self.PanelItemListScorllRect then + self.PanelItemListScorllRect:OnEndDrag(eventData); + end +end + +--- +--- 设置摆放模式时,操作菜单的位置 +function XUiCollectionWallEdit:SetPanelConfirmMenuPos() + -- 如果操作菜单显示在界面上,则更新位置 + if self.PanelConfirmMenu.gameObject.activeSelf or self.PanelConfirmMenu.gameObject.activeInHierarchy then + if not self.CurSelectCollection then + XLog.Error("XUiCollectionWallEdit:SetPanelConfirmMenuPos函数错误,CurSelectCollection为 nil") + else + self.PanelConfirmMenu.localPosition = self.CurSelectCollection:GetPos() + end + end +end + +--- +--- 'index'与XCollectionWallConfigs.EnumSelectType一致 +function XUiCollectionWallEdit:OnClickTagCallBack(index) + self.SelectType = index + self:SetupDynamicTable(index) + self:PlayAnimation("ViewportQieHuan") + self.PanelSelectItem.gameObject:SetActiveEx(true) +end + +function XUiCollectionWallEdit:RefreshSelectItemList() + if self.IsEditMode then + self:SetupDynamicTable(self.SelectType) + end +end + +function XUiCollectionWallEdit:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelItemList) + self.DynamicTable:SetProxy(XUiGridSelectItem, self) + self.DynamicTable:SetDelegate(self) +end + +function XUiCollectionWallEdit:SetupDynamicTable(type) + local curWallData = self:GenerateCurWallData() + self.PageDatas = XDataCenter.CollectionWallManager.GetItemList(curWallData, type) + self.DynamicTable:SetDataSource(self.PageDatas) + self.DynamicTable:ReloadDataASync() + self.ImgEmpty.gameObject:SetActiveEx(#self.PageDatas <= 0) +end + +function XUiCollectionWallEdit:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:UpdateGrid(self.PageDatas[index], self.SelectType) + end +end + +--- +--- 根据'collectionId'收藏品Id在'localPos'上创建收藏品 +--- 'localPos'为空,则使用中心位置 +---@param collectionId number +---@param isNew boolean +---@param localPos table +---@param sizeId number +---@return table +function XUiCollectionWallEdit:CreatePlacedCollection(collectionId, isNew, localPos, sizeId) + if not collectionId then + XLog.Error("XUiCollectionWallEdit.CreatePlacedCollection函数错误,参数collectionId为 nil") + return + end + + local baseItemPath = XCollectionWallConfigs.GetColDecPath(self.PedestalId) + local baseItem = self.WallContent:LoadPrefab(baseItemPath) + if baseItem == nil or not baseItem:Exist() then + return + end + baseItem.gameObject:SetActiveEx(false) + + local obj = CS.UnityEngine.Object.Instantiate(baseItem) + local scale = XCollectionWallConfigs.GetCollectionScale(sizeId) + + obj.transform:SetParent(self.WallContent, false) + obj.transform.localScale = CS.UnityEngine.Vector3(scale, scale, scale) + obj.gameObject:SetActiveEx(true) + + local data = {} + data.Id = collectionId + data.LocalPos = localPos or self.DefaultLocalPos + data.SizeId = sizeId + data.IsNew = isNew + + local placedCollection = XUiGridPlacedCollection.New(obj, self, self.WallContent, data) + self.CollectionDic[collectionId] = placedCollection + + return placedCollection +end + +--- +--- 收纳收藏品时,清理对应的脚本引用 +function XUiCollectionWallEdit:StorageCollection(collectionId) + CS.UnityEngine.GameObject.Destroy(self.CollectionDic[collectionId].GameObject) + self.CollectionDic[collectionId] = nil +end + +--- +--- 根据CollectionDic中存放的收藏品脚本来生成当前收藏品墙的数据 +function XUiCollectionWallEdit:GenerateCurWallData() + local data = {} + data.Id = self.WallData:GetId() + data.BackgroundId = self.BackgroundId + data.PedestalId = self.PedestalId + data.CollectionSetInfos = {} + for id, placedCollection in pairs(self.CollectionDic) do + local temp = {} + local gridPos = placedCollection:GetGridPos() + + temp.Id = id + temp.X = gridPos.x + temp.Y = gridPos.y + temp.SizeId = placedCollection:GetSizeId() + table.insert(data.CollectionSetInfos, temp) + end + return data +end + +--- +--- 是否进入摆放模式 +--- 进入摆放模式需要参数'placedCollection'(XUiGridPlacedCollection) +--- 如果'placedCollection'为空,则视为退出摆放模式 +--- 'isFollowMouse':摆放的物体是否跟随鼠标 +--- 'isNew':是新摆放的物体,还是点击旧的物体 +---@param placedCollection table +function XUiCollectionWallEdit:EnterPutModel(placedCollection) + self.CurSelectCollection = placedCollection + local isEnter = placedCollection and true or false + if isEnter then + self:PlayAnimation("PanelCenterDisable",function() + self.PanelTag.gameObject:SetActiveEx(not isEnter) + self.PanelSelectItem.gameObject:SetActiveEx(not isEnter) + end) + else + self:PlayAnimation("PanelCenterEnable") + self.PanelTag.gameObject:SetActiveEx(not isEnter) + self.PanelSelectItem.gameObject:SetActiveEx(not isEnter) + end + self.PanelTop.gameObject:SetActiveEx(not isEnter) + self.PanelConfirmMenu.gameObject:SetActiveEx(isEnter) + self.RImgFrame.gameObject:SetActiveEx(isEnter) + + if placedCollection then + local count = self.WallContent.childCount + placedCollection.Transform:SetSiblingIndex(count - 1) + + self.IsPanelSelectItemDraging = false + placedCollection:SetSelect(true) + self:SetPanelConfirmMenuPos() + self:CheckConflict(placedCollection:GetId(), placedCollection:GetOccupyGridsList(), false) + self:SetAcross() + end +end + +--- +--- 设置摆放模式时的蓝色与红色格子条 +function XUiCollectionWallEdit:SetAcross() + if self.CurSelectCollection then + local gridNum = XCollectionWallConfigs.GetCollectionGridNum(self.CurSelectCollection:GetSizeId()) + self:RecoverAcross(gridNum) + + if self.HasConflict then + self:GenerateAcross(self.RedHorPool, self.RedHorItem, gridNum) + self:GenerateAcross(self.RedVerPool, self.RedVerItem, gridNum) + else + self:GenerateAcross(self.BlueHorPool, self.BlueHorItem, gridNum) + self:GenerateAcross(self.BlueVerPool, self.BlueVerItem, gridNum) + end + self:UpdateAcrossPos(gridNum) + end +end + +function XUiCollectionWallEdit:GenerateAcross(pool, baseItem, gridNum) + for i = 1, gridNum do + local grid = pool[i] + if not grid then + grid = CS.UnityEngine.Object.Instantiate(baseItem) + grid.transform:SetParent(self.PanelAcross, false) + table.insert(pool, grid) + end + grid.gameObject:SetActiveEx(true) + end +end + +function XUiCollectionWallEdit:RecoverAcross(gridNum) + for i = 1, gridNum do + -- 蓝条 + if self.RedHorPool[i] then + self.RedHorPool[i].gameObject:SetActiveEx(false) + end + if self.RedVerPool[i] then + self.RedVerPool[i].gameObject:SetActiveEx(false) + end + + -- 红条 + if self.BlueHorPool[i] then + self.BlueHorPool[i].gameObject:SetActiveEx(false) + end + if self.BlueVerPool[i] then + self.BlueVerPool[i].gameObject:SetActiveEx(false) + end + end +end + +--- +--- 设置格子条的位置 +function XUiCollectionWallEdit:UpdateAcrossPos(gridNum) + if not self.CurSelectCollection then + return + end + + local gridPos = self.CurSelectCollection:GetGridPos() + if self.HasConflict then + for i = 1, gridNum do + -- 水平 + self.RedHorPool[i].transform.localPosition = CS.UnityEngine.Vector3( + self.RedHorPool[i].transform.localPosition.x, + (gridPos.y + i - 1) * XCollectionWallConfigs.CellSize, + 0) + -- 垂直 + self.RedVerPool[i].transform.localPosition = CS.UnityEngine.Vector3( + (gridPos.x + i - 1) * XCollectionWallConfigs.CellSize, + self.RedVerPool[i].transform.localPosition.y, + 0) + end + else + for i = 1, gridNum do + -- 水平 + self.BlueHorPool[i].transform.localPosition = CS.UnityEngine.Vector3( + self.BlueHorPool[i].transform.localPosition.x, + (gridPos.y + i - 1) * XCollectionWallConfigs.CellSize, + 0) + -- 垂直 + self.BlueVerPool[i].transform.localPosition = CS.UnityEngine.Vector3( + (gridPos.x + i - 1) * XCollectionWallConfigs.CellSize, + self.BlueVerPool[i].transform.localPosition.y, + 0) + end + end +end + +--- +--- 更新格子占用情况 +function XUiCollectionWallEdit:UpdateGridOccupy() + self.GridOccupy = {} + for _, placedCollection in pairs(self.CollectionDic) do + local occupyGridList = placedCollection:GetOccupyGridsList() + for _,gridPos in pairs(occupyGridList) do + local gridId = gridPos.x * 10 + gridPos.y + self.GridOccupy[gridId] = placedCollection:GetId() + end + end +end + +--- +--- 检查冲突,设置标志位 +--- 'isSetAcross'是否需要设置格子条 +--- @param collectionId number +--- @param occupyGridList table +--- @param isSetAcross boolean +function XUiCollectionWallEdit:CheckConflict(collectionId, occupyGridList, isSetAcross) + if self.CurSelectCollection then + for _, gridPos in pairs(occupyGridList) do + local gridId = gridPos.x * 10 + gridPos.y + if self.GridOccupy[gridId] and self.GridOccupy[gridId] ~= collectionId then + local oriConflict = self.HasConflict + self.HasConflict = true + + if oriConflict == false and isSetAcross then + self:SetAcross() + end + return + else + local oriConflict = self.HasConflict + self.HasConflict = false + + if oriConflict == true and isSetAcross then + self:SetAcross() + end + end + end + end +end + +--- +--- 设置冲突标志 +function XUiCollectionWallEdit:SetConflict(isConflict) + self.HasConflict = isConflict +end + +--- +--- 是否冲突 +function XUiCollectionWallEdit:IsConflict() + return self.HasConflict +end + +--- +--- 更改墙面 +---@param data table +function XUiCollectionWallEdit:ChangeBackgroundId(backgroundId) + if self.BackgroundId == backgroundId then + return + end + self.BackgroundId = backgroundId + self:RefreshBackground() + self.DynamicTable:ReloadDataASync() +end + +function XUiCollectionWallEdit:RefreshBackground() + self:PlayAnimation("RImgWallBgQieHuan") + local bgPath = XCollectionWallConfigs.GetColDecPath(self.BackgroundId) + self.RImgWallBg:SetRawImage(bgPath) +end + +--- +--- 更改底座 +---@param pedestalId table +function XUiCollectionWallEdit:ChangePedestalId(pedestalId) + if self.PedestalId == pedestalId then + return + end + self.PedestalId = pedestalId + + local data = self:GenerateCurWallData() + self:ClearAllCollection() + self:GenerateCollection(data.CollectionSetInfos) + self.DynamicTable:ReloadDataASync() +end + +function XUiCollectionWallEdit:GenerateCollection(collectionSetInfos) + for _, info in pairs(collectionSetInfos) do + local gridPos = {} + gridPos.x = info.X + gridPos.y = info.Y + + local size = XCollectionWallConfigs.GetCollectionSize(info.SizeId) + local localPos = XDataCenter.CollectionWallManager.GetLocalPosByGridPos(gridPos, size) + + self:CreatePlacedCollection(info.Id, false, localPos, info.SizeId) + end +end + +function XUiCollectionWallEdit:ClearAllCollection() + for _, placedCollection in pairs(self.CollectionDic) do + CS.UnityEngine.GameObject.Destroy(placedCollection.GameObject) + end + self.CollectionDic = {} +end + +function XUiCollectionWallEdit:QuitEditMode() + self:PlayAnimation("PanelCenterDisable", function() + self.RImgFrame.gameObject:SetActiveEx(false) + self.PanelTag.gameObject:SetActiveEx(false) + self.PanelConfirmMenu.gameObject:SetActiveEx(false) + self.BtnEdit.gameObject:SetActiveEx(true) + self.PanelSelectItem.gameObject:SetActiveEx(false) + end) + self.IsEditMode = false + self.CurSelectCollection = nil +end + +function XUiCollectionWallEdit:AddListener() + self.BtnBack.CallBack = function() + self:OnBtnBackClick() + end + self:BindHelpBtn(self.BtnExplain, "CollectionWall") + + self.BtnEdit.CallBack = function() + self:OnBtnEditClick() + end + self.BtnUndo.CallBack = function() + self:OnBtnUndoClick() + end + self.BtnSave.CallBack = function() + self:OnBtnSaveClick() + end + + self.BtnOk.CallBack = function() + self:OnBtnOkClick() + end + self.BtnCancel.CallBack = function() + self:OnBtnCancelClick() + end + self.BtnStorage.CallBack = function() + self:OnBtnStorageClick() + end +end + +function XUiCollectionWallEdit:OnBtnUndoClick() + XUiManager.DialogTip(CS.XTextManager.GetText("TipTitle"), CS.XTextManager.GetText("CollectionWallUndo"), + XUiManager.DialogType.Normal, nil, function() + self:ClearAllCollection() + self:Refresh() + end) +end + +function XUiCollectionWallEdit:OnBtnSaveClick() + -- 构造发送请求需要的数据 + local wallId = self.WallData:GetId() + local setInfo = self:GenerateCurWallData() + local pedestalId = setInfo.PedestalId + local backgroundId = setInfo.BackgroundId + + XDataCenter.CollectionWallManager.RequestEditCollectionWall(wallId, pedestalId, backgroundId, setInfo.CollectionSetInfos, function() + -- 截图保存 + self.PanelTop.gameObject:SetActiveEx(false) + self.ImgWire.gameObject:SetActiveEx(false) + + self.BtnEdit.gameObject:SetActiveEx(false) + self.PanelSelectItem.gameObject:SetActiveEx(false) + self.PanelTag.gameObject:SetActiveEx(false) + local imgName = XDataCenter.CollectionWallManager.GetCaptureImgName(wallId) + + XDataCenter.CollectionWallManager.CaptureCamera(imgName, function() + -- 截图完成后重新设置Ui + self.PanelTop.gameObject:SetActiveEx(true) + self.ImgWire.gameObject:SetActiveEx(true) + + self.BtnEdit.gameObject:SetActiveEx(not self.IsEditMode) + self.PanelSelectItem.gameObject:SetActiveEx(self.IsEditMode) + self.PanelTag.gameObject:SetActiveEx(self.IsEditMode) + XUiManager.TipSuccess(CS.XTextManager.GetText("SetAppearanceSuccess")) + end) + end) +end + +function XUiCollectionWallEdit:OnBtnOkClick() + if self.HasConflict then + XUiManager.TipError(CS.XTextManager.GetText("CollectionWallPlaceNotCorrect")) + return + else + local gridNum = XCollectionWallConfigs.GetCollectionGridNum(self.CurSelectCollection:GetSizeId()) + self:RecoverAcross(gridNum) + self.CurSelectCollection:Confirm() + self:EnterPutModel(nil) + end +end + +function XUiCollectionWallEdit:OnBtnCancelClick() + local gridNum = XCollectionWallConfigs.GetCollectionGridNum(self.CurSelectCollection:GetSizeId()) + self:RecoverAcross(gridNum) + self.CurSelectCollection:Cancel() + self:EnterPutModel(nil) +end + +function XUiCollectionWallEdit:OnBtnStorageClick() + local gridNum = XCollectionWallConfigs.GetCollectionGridNum(self.CurSelectCollection:GetSizeId()) + self:RecoverAcross(gridNum) + self.CurSelectCollection:Storage() + self:EnterPutModel(nil) +end + +function XUiCollectionWallEdit:OnBtnEditClick() + self.BtnEdit.gameObject:SetActiveEx(false) + self.PanelTag.gameObject:SetActiveEx(true) + self.DynamicTable:Clear() + self.TagGroup:SelectIndex(1) + self:PlayAnimation("PanelCenterEnable") + self.IsEditMode = true +end + +function XUiCollectionWallEdit:OnBtnBackClick() + if self.IsEditMode then + local curWallData = self:GenerateCurWallData() + if XDataCenter.CollectionWallManager.IsNeedSave(self.WallData:GetId(), curWallData) then + XUiManager.DialogTip(CS.XTextManager.GetText("FurnitureTips"), CS.XTextManager.GetText("FurnitureIsSave"), + XUiManager.DialogType.Normal, function() + self:ClearAllCollection() + self:Refresh() + self:QuitEditMode() + end, function() + self:QuitEditMode() + self:OnBtnSaveClick() + end) + else + self:QuitEditMode() + end + else + self:Close() + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCollectionWall/XUiCollectionWallGrid/XUiGridCollectionWall.lua b/Resources/Scripts/XUi/XUiCollectionWall/XUiCollectionWallGrid/XUiGridCollectionWall.lua new file mode 100644 index 00000000..01001568 --- /dev/null +++ b/Resources/Scripts/XUi/XUiCollectionWall/XUiCollectionWallGrid/XUiGridCollectionWall.lua @@ -0,0 +1,122 @@ +local XUiGridCollectionWall = XClass(nil, "XUiGridCollectionWall") + +local DefaultConditionDesc + +function XUiGridCollectionWall:Ctor(ui, rootUi, openType) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self.OpenType = openType + XTool.InitUiObject(self) + + if self.OpenType == XCollectionWallConfigs.EnumWallGridOpenType.Overview then + DefaultConditionDesc = self.TxtUnLockCondition.text + self.BtnNoneState.CallBack = function() self:OnOverviewClick() end + self.BtnLockState.CallBack = function() self:OnOverviewClick() end + self.BtnNormalState.CallBack = function() self:OnOverviewClick() end + elseif self.OpenType == XCollectionWallConfigs.EnumWallGridOpenType.Setting then + self.BtnChoice.CallBack = function() self:OnSettingToggleClick() end + self.BtnPanelWall.CallBack = function() self:BtnPanelWallClick() end + end +end + +--- +--- 'wallData'的结构为XCollectionWall数据实体 +function XUiGridCollectionWall:UpdateGrid(wallData) + self.WallData = wallData + + if self.OpenType == XCollectionWallConfigs.EnumWallGridOpenType.Overview then + -- 总览界面调用 + self.BtnNormalState.gameObject:SetActiveEx(false) + self.BtnNoneState.gameObject:SetActiveEx(false) + self.BtnLockState.gameObject:SetActiveEx(false) + local state = wallData:GetState() + + if state == XCollectionWallConfigs.EnumWallState.Normal then + -- 正常 + self.BtnNormalState.gameObject:SetActiveEx(true) + self:SetImg() + self.TxtWallName.text = wallData:GetName() + elseif state == XCollectionWallConfigs.EnumWallState.None then + -- 空白 + self.BtnNoneState.gameObject:SetActiveEx(true) + else + --未解锁 + self.BtnLockState.gameObject:SetActiveEx(true) + local conditionId = wallData:GetCondition() + local conditionDesc = XConditionManager.GetConditionDescById(conditionId) + self.TxtUnLockCondition.text = conditionDesc or DefaultConditionDesc + end + + elseif self.OpenType == XCollectionWallConfigs.EnumWallGridOpenType.Setting then + -- 设置界面调用 + self:SetImg() + self.TxtWallName.text = wallData:GetName() + self.BtnChoice:SetButtonState(wallData:GetIsShow() + and XUiButtonState.Select + or XUiButtonState.Normal) + else + XLog.Error("XUiGridCollectionWall:UpdateGrid函数错误:没有设置OpenType") + end +end + +function XUiGridCollectionWall:SetImg() + self.WallData:GetWallPicture(function(texture) + local result = texture + + if not result then + local resource = CS.XResourceManager.Load(CS.XGame.ClientConfig:GetString("CollectionWallDefaultIcon")) + result = resource.Asset + end + + local rect = CS.UnityEngine.Rect(0, 0, result.width, result.height) + local sprite = CS.UnityEngine.Sprite.Create(result, rect, CS.UnityEngine.Vector2.zero) + self.ImgTemplate.sprite = sprite + end) +end + +function XUiGridCollectionWall:OnRecycle() + local defaultIconPath = CS.XGame.ClientConfig:GetString("CollectionWallDefaultIcon") + self.ImgTemplate:SetSprite(defaultIconPath) +end + +--- +--- 总览界面(XUiCollectionWall)调用的点击函数 +function XUiGridCollectionWall:OnOverviewClick() + local state = self.WallData:GetState() + + if state == XCollectionWallConfigs.EnumWallState.Normal + or state == XCollectionWallConfigs.EnumWallState.None then + XLuaUiManager.Open("UiCollectionWallEdit", self.WallData) + else + XUiManager.TipMsg(self.TxtUnLockCondition.text) + end +end + +function XUiGridCollectionWall:OnSettingToggleClick() + self.RootUi:ChangeCurShowSetting(self.WallData:GetId(), self.BtnChoice.ButtonState == CS.UiButtonState.Select) +end + +function XUiGridCollectionWall:BtnPanelWallClick() + if self.BtnChoice.ButtonState == CS.UiButtonState.Select then + self.BtnChoice:SetButtonState(CS.UiButtonState.Normal) + else + self.BtnChoice:SetButtonState(CS.UiButtonState.Select) + end + self:OnSettingToggleClick() +end + +--- +--- 父UI调用,设置当前格子是否被选中 +function XUiGridCollectionWall:SetIsSelect(isSelect) + if isSelect then + self.BtnChoice:SetButtonState(CS.UiButtonState.Select) + else + self.BtnChoice:SetButtonState(CS.UiButtonState.Normal) + end + + self:OnSettingToggleClick() +end + + +return XUiGridCollectionWall \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCollectionWall/XUiCollectionWallGrid/XUiGridPlacedCollection.lua b/Resources/Scripts/XUi/XUiCollectionWall/XUiCollectionWallGrid/XUiGridPlacedCollection.lua new file mode 100644 index 00000000..32aeebfb --- /dev/null +++ b/Resources/Scripts/XUi/XUiCollectionWall/XUiCollectionWallGrid/XUiGridPlacedCollection.lua @@ -0,0 +1,220 @@ +local XUiGridPlacedCollection = XClass(nil, "XUiGridPlacedCollection") + +local XUiCollectionStyle = require("XUi/XUiMedal/XUiCollectionStyle") +local Vector3 = CS.UnityEngine.Vector3 + + +--- +--- 'collectionData'的结构为{ Id, LocalPos, PedestalId } +function XUiGridPlacedCollection:Ctor(ui, rootUi, parentUi, collectionData) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self.ParentRectTransform = parentUi + + self.IsNew = collectionData.IsNew + self.Id = collectionData.Id + self.SizeId = collectionData.SizeId -- 尺寸Id + self.CollectionStyleDic = {} -- Key:收藏品Id Value:XUiCollectionStyle脚本 + + -- 可移动的范围边界 + self.Size = XCollectionWallConfigs.GetCollectionSize(collectionData.SizeId) + self.OriGridPos = XDataCenter.CollectionWallManager.GetGridPosByLocalPos(collectionData.LocalPos, self.Size) + + self.MinXY = self.Size / 2 + self.MaxX = self.ParentRectTransform.rect.width - (self.Size / 2) + self.MaxY = self.ParentRectTransform.rect.height - (self.Size / 2) + + self.Camera = CS.XUiManager.Instance.UiCamera + XTool.InitUiObject(self) + + -- 监听点击 + self.GoInputHandler = self.Transform:GetComponent(typeof(CS.XGoInputHandler)) + if XTool.UObjIsNil(self.GoInputHandler) then + self.GoInputHandler = self.GameObject:AddComponent(typeof(CS.XGoInputHandler)) + end + if not XTool.UObjIsNil(self.GoInputHandler) then + self.GoInputHandler:AddPointerClickListener(function(eventData) + self:OnClick(eventData) + end) + self.GoInputHandler:AddDragListener(function(eventData) + self:OnDrag(eventData) + end) + end + self:InitComponent() + self:SetPos(self.OriGridPos, true) +end + +function XUiGridPlacedCollection:InitComponent() + self.TxtName.text = XMedalConfigs.GetCollectionNameById(self.Id) + + local prefabPath = XMedalConfigs.GetCollectionPrefabPath(self.Id) + local styleObj = self.CollectionStyleNode.gameObject:LoadPrefab(prefabPath) + local collectionData = XDataCenter.MedalManager.GetScoreTitleById(self.Id) + self.CollectionStyleDic[self.Id] = XUiCollectionStyle.New(styleObj, collectionData) + + self:SetSelect(false) +end + +function XUiGridPlacedCollection:SetSelect(isSelect) + self.IsSelected = isSelect + self.RImBlack.gameObject:SetActiveEx(isSelect) +end + +--- +--- 取消 +function XUiGridPlacedCollection:Cancel() + if self.IsNew then + -- 删除物体和字典中的脚本引用 + self.RootUi:StorageCollection(self.Id) + self.RootUi:SetConflict(false) + else + -- 恢复位置 + self:SetPos(self.OriGridPos, false) + end + self:SetSelect(false) + self.RootUi:UpdateGridOccupy() +end + +--- +--- 确认 +function XUiGridPlacedCollection:Confirm() + if self.IsNew then + -- 刷新选择列表 + self.RootUi:RefreshSelectItemList() + self.IsNew = false + end + self:SetSelect(false) + self.OriGridPos = self.GridPos + self.RootUi:UpdateGridOccupy() +end + +--- +--- 收纳 +function XUiGridPlacedCollection:Storage() + -- 删除物体和字典中的脚本引用 + self.RootUi:StorageCollection(self.Id) + -- 更新格子占用情况 + self.RootUi:UpdateGridOccupy() + -- 设置冲突 + self.RootUi:SetConflict(false) + if not self.IsNew then + -- 刷新选择列表 + self.RootUi:RefreshSelectItemList() + end +end + +--- +--- 调整位置,把Screen坐标换算成Canvas坐标 +--- 然后再转成对应的格子行列坐标 +function XUiGridPlacedCollection:AdjustPosition(screenPos) + -- 设置拖拽 + local hasValue, pos = CS.UnityEngine.RectTransformUtility.ScreenPointToLocalPointInRectangle(self.ParentRectTransform, screenPos, self.Camera) + if hasValue then + local localPos = {} + localPos.x = pos.x + localPos.y = pos.y + + if localPos.x < self.MinXY then + localPos.x = self.MinXY + elseif localPos.x > self.MaxX then + localPos.x = self.MaxX + end + + if localPos.y < self.MinXY then + localPos.y = self.MinXY + elseif localPos.y > self.MaxY then + localPos.y = self.MaxY + end + local gridPos = XDataCenter.CollectionWallManager.GetGridPosByLocalPos(localPos, self.Size) + self:SetPos(gridPos, true) + end +end + +--- +--- 设置本地 +function XUiGridPlacedCollection:SetPos(gridPos, isSetAcross) + if XTool.UObjIsNil(self.Transform) then + return + end + self.GridPos = {} + self.GridPos.x = gridPos.x + self.GridPos.y = gridPos.y + + local posVector2 = XDataCenter.CollectionWallManager.GetLocalPosByGridPos(gridPos, self.Size) + + self.Transform.localPosition = Vector3(posVector2.x, posVector2.y, 0) + self.RootUi:SetPanelConfirmMenuPos() + self.RootUi:CheckConflict(self.Id, self:GetOccupyGridsList(), isSetAcross) + self.RootUi:UpdateAcrossPos(XCollectionWallConfigs.GetCollectionGridNum(self.SizeId)) +end + +--- +--- 获取本地坐标 +function XUiGridPlacedCollection:GetPos() + if XTool.UObjIsNil(self.Transform) then + return + end + return self.Transform.localPosition +end + +--- +--- 设获取格子坐标 +function XUiGridPlacedCollection:GetGridPos() + return self.GridPos +end + +function XUiGridPlacedCollection:GetOccupyGridsList() + local result = {} + local gridNum = XCollectionWallConfigs.GetCollectionGridNum(self.SizeId) + for i = 1,gridNum do + for j =1,gridNum do + local temp = {} + temp.x = self.GridPos.x + (i - 1) + temp.y = self.GridPos.y + (j - 1) + table.insert(result,temp) + end + end + + return result +end + +--- +--- 获取尺寸Id +function XUiGridPlacedCollection:GetSizeId() + return self.SizeId +end + +function XUiGridPlacedCollection:GetId() + return self.Id +end + +--- +--- 点击 +function XUiGridPlacedCollection:OnClick() + if self.RootUi.IsEditMode then + if self.RootUi.CurSelectCollection then + return + end + + -- 进入摆放模式 + self.RootUi:EnterPutModel(self) + end +end + +--- +--- 拖动 +function XUiGridPlacedCollection:OnDrag(eventData) + if not self.IsSelected then + return + end + + local pos = eventData.position + return self:AdjustPosition(pos) +end + +function XUiGridPlacedCollection:Destroy() + self.GoInputHandler:RemoveAllListeners() +end + +return XUiGridPlacedCollection \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCollectionWall/XUiCollectionWallGrid/XUiGridPlacedCollectionOther.lua b/Resources/Scripts/XUi/XUiCollectionWall/XUiCollectionWallGrid/XUiGridPlacedCollectionOther.lua new file mode 100644 index 00000000..192c3fca --- /dev/null +++ b/Resources/Scripts/XUi/XUiCollectionWall/XUiCollectionWallGrid/XUiGridPlacedCollectionOther.lua @@ -0,0 +1,85 @@ +local XUiGridPlacedCollectionOther = XClass(nil, "XUiGridPlacedCollectionOther") + +local XUiCollectionStyle = require("XUi/XUiMedal/XUiCollectionStyle") +local Vector3 = CS.UnityEngine.Vector3 + +--- +--- 'collectionData'的结构为{ Id, LocalPos, PedestalId } +--- 'scoreTitle'为其他玩家的收藏品数据,如分数、等级 +function XUiGridPlacedCollectionOther:Ctor(ui, rootUi, parentUi, collectionData, scoreTitle) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self.ParentRectTransform = parentUi + self.ScoreTitle = scoreTitle + + self.IsNew = collectionData.IsNew + self.Id = collectionData.Id + self.SizeId = collectionData.SizeId -- 尺寸Id + + self.CollectionStyleDic = {} -- Key:收藏品Id Value:XUiCollectionStyle脚本 + + self.Size = XCollectionWallConfigs.GetCollectionSize(collectionData.SizeId) + self.OriGridPos = XDataCenter.CollectionWallManager.GetGridPosByLocalPos(collectionData.LocalPos, self.Size) + + XTool.InitUiObject(self) + + self:InitComponent() + self:SetPos(self.OriGridPos, true) +end + +function XUiGridPlacedCollectionOther:InitComponent() + self.TxtName.text = self.ScoreTitle.Name + + local styleObj = self.CollectionStyleNode.gameObject:LoadPrefab(self.ScoreTitle.PrefabPath) + self.CollectionStyleDic[self.Id] = XUiCollectionStyle.New(styleObj, self.ScoreTitle) + + self:SetSelect(false) +end + +function XUiGridPlacedCollectionOther:SetSelect(isSelect) + self.IsSelected = isSelect + self.RImBlack.gameObject:SetActiveEx(isSelect) +end + +--- +--- 设置本地 +function XUiGridPlacedCollectionOther:SetPos(gridPos) + if XTool.UObjIsNil(self.Transform) then + return + end + self.GridPos = {} + self.GridPos.x = gridPos.x + self.GridPos.y = gridPos.y + + local posVector2 = XDataCenter.CollectionWallManager.GetLocalPosByGridPos(gridPos, self.Size) + + self.Transform.localPosition = Vector3(posVector2.x, posVector2.y, 0) +end + +--- +--- 获取本地坐标 +function XUiGridPlacedCollectionOther:GetPos() + if XTool.UObjIsNil(self.Transform) then + return + end + return self.Transform.localPosition +end + +--- +--- 设获取格子坐标 +function XUiGridPlacedCollectionOther:GetGridPos() + return self.GridPos +end + +--- +--- 获取尺寸Id +function XUiGridPlacedCollectionOther:GetSizeId() + return self.SizeId +end + +function XUiGridPlacedCollectionOther:GetId() + return self.Id +end + +return XUiGridPlacedCollectionOther \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCollectionWall/XUiCollectionWallGrid/XUiGridSelectItem.lua b/Resources/Scripts/XUi/XUiCollectionWall/XUiCollectionWallGrid/XUiGridSelectItem.lua new file mode 100644 index 00000000..47f55797 --- /dev/null +++ b/Resources/Scripts/XUi/XUiCollectionWall/XUiCollectionWallGrid/XUiGridSelectItem.lua @@ -0,0 +1,161 @@ +local XUiGridSelectItem = XClass(nil, "XUiGridSelectItem") + +local XUiCollectionStyle = require("XUi/XUiMedal/XUiCollectionStyle") + +function XUiGridSelectItem:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self.PointerDownPosition = nil + self.CollectionStyleDic = {} -- Key:收藏品Id Value:XUiCollectionStyle脚本 + + XTool.InitUiObject(self) + self.PanelTip.gameObject:SetActiveEx(false) + + self.BtnItemWidget:AddPointerDownListener(function(data) self:OnBtnItemPointerDown(data) end) + self.BtnItemWidget:AddDragListener(function(data) self:OnBtnItemOnDrag(data) end) + self.BtnItemWidget:AddPointerClickListener(function(data) self:OnBtnItemClick(data) end) + + self.BtnItemWidget:AddBeginDragListener(function(data) self:OnBtnItemOnBeginDrag(data) end) + self.BtnItemWidget:AddEndDragListener(function(data) self:OnBtnItemOnEndDrag(data) end) +end + +--- +--- 'data'的结构根据种类有不同的结构(XCollectionWallManager.GetItemList函数构建) +--- 装饰品:{ Id, IsUnlock } +--- 收藏品:Id +--- +--- 'selectType'选择的种类,类型为XCollectionWallConfigs.EnumSelectType +---@param data table +---@param selectType number +function XUiGridSelectItem:UpdateGrid(data, selectType) + self.Data = data + self.SelectType = selectType + + -- 根据选择种类分成收藏品(大中小)和装饰品(底座、墙面) + if selectType == XCollectionWallConfigs.EnumSelectType.BACKGROUND + or selectType == XCollectionWallConfigs.EnumSelectType.PEDESTAL then + self.IsDecoration = true + elseif selectType == XCollectionWallConfigs.EnumSelectType.LITTL + or selectType == XCollectionWallConfigs.EnumSelectType.MIDDLE + or selectType == XCollectionWallConfigs.EnumSelectType.BIG then + self.IsDecoration = false + else + XLog.Error("XUiGridSelectItem:UpdateGrid函数错误,selectType不是XCollectionWallConfigs.EnumSelectType类型的值") + return + end + + if self.IsDecoration then + self.TxtName.text = XCollectionWallConfigs.GetColDecName(data.Id) + self.ImgDecorationIcon:SetRawImage(XCollectionWallConfigs.GetColDecIcon(data.Id)) + + self.CollectionStyleNode.gameObject:SetActiveEx(false) + self.ImgDecorationIcon.gameObject:SetActiveEx(true) + self.PanelTip.gameObject:SetActiveEx(not data.IsUnlock) + self.ImgIconController.enabled = not data.IsUnlock + + if selectType == XCollectionWallConfigs.EnumSelectType.BACKGROUND then + self.PanelChoice.gameObject:SetActiveEx(data.Id == self.RootUi.BackgroundId) + else + self.PanelChoice.gameObject:SetActiveEx(data.Id == self.RootUi.PedestalId) + end + else + self.TxtName.text = XMedalConfigs.GetCollectionNameById(data) + + local prefabPath = XMedalConfigs.GetCollectionPrefabPath(data) + local styleObj = self.CollectionStyleNode.gameObject:LoadPrefab(prefabPath) + local collectionData = XDataCenter.MedalManager.GetScoreTitleById(data) + self.CollectionStyleDic[data] = XUiCollectionStyle.New(styleObj, collectionData) + + self.CollectionStyleNode.gameObject:SetActiveEx(true) + self.ImgDecorationIcon.gameObject:SetActiveEx(false) + self.PanelTip.gameObject:SetActiveEx(false) + self.ImgIconController.enabled = false + self.PanelChoice.gameObject:SetActiveEx(false) + end +end + +--- +--- 按下事件 +function XUiGridSelectItem:OnBtnItemPointerDown(data) + self.PointerDownPosition = data.position.y +end + +--- +--- 点击 +function XUiGridSelectItem:OnBtnItemClick(data) + if self.RootUi.IsPanelSelectItemDraging then + return + end + + if not data then + return + end + + if self.SelectType == nil then + XLog.Error("XUiGridSelectItem:OnBtnItemClick函数错误,self.SelectType为 nil") + return + end + + if self.IsDecoration then + -- 装饰品 + if self.Data.IsUnlock then + -- 已解锁 + if self.SelectType == XCollectionWallConfigs.EnumSelectType.BACKGROUND then + self.RootUi:ChangeBackgroundId(self.Data.Id) + elseif self.SelectType == XCollectionWallConfigs.EnumSelectType.PEDESTAL then + self.RootUi:ChangePedestalId(self.Data.Id) + else + XLog.Error("XUiGridSelectItem:OnBtnItemClick函数错误,SelectType的值不是装饰品") + return + end + else + -- 未解锁 + local unlockType = XCollectionWallConfigs.GetColDecUnlockType(self.Data.Id) + local txtTip + if unlockType == XCollectionWallConfigs.EnumDecorationUnlockType.Condition then + local conditionId = XCollectionWallConfigs.GetColDecCondition(self.Data.Id) + txtTip = XConditionManager.GetConditionDescById(conditionId) + else + txtTip = XCollectionWallConfigs.GetColDecLockDesc(self.Data.Id) + end + XUiManager.TipError(txtTip) + end + else + -- 收藏品 + if self.RootUi.CurSelectCollection then + -- 已经处于摆放模式(防止多次点击) + return + end + + -- 进入摆放模式 + local sizeId = XDataCenter.MedalManager.GetQuality(self.Data) + local placedCollection = self.RootUi:CreatePlacedCollection(self.Data, true, nil, sizeId) + self.RootUi:EnterPutModel(placedCollection) + end +end + +--- +--- 拖拽 +function XUiGridSelectItem:OnBtnItemOnDrag(data) + if not self.PointerDownPosition then + return + end + self.RootUi:OnPanelItemListDrag(data) +end + +function XUiGridSelectItem:OnBtnItemOnBeginDrag(data) + self.RootUi.IsPanelSelectItemDraging = true + self.RootUi:OnPanelItemListBeginDrag(data) +end + +function XUiGridSelectItem:OnBtnItemOnEndDrag(data) + self.RootUi.IsPanelSelectItemDraging = false + self.RootUi:OnPanelItemListEndDrag(data) +end + +function XUiGridSelectItem:Destroy() + self.BtnItemWidget:RemoveAllListeners() +end + +return XUiGridSelectItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCollectionWall/XUiCollectionWallGrid/XUiGridViewCollection.lua b/Resources/Scripts/XUi/XUiCollectionWall/XUiCollectionWallGrid/XUiGridViewCollection.lua new file mode 100644 index 00000000..6028819d --- /dev/null +++ b/Resources/Scripts/XUi/XUiCollectionWall/XUiCollectionWallGrid/XUiGridViewCollection.lua @@ -0,0 +1,87 @@ +local XUiGridViewCollection = XClass(nil, "XUiGridViewCollection") + +local XUiCollectionStyle = require("XUi/XUiMedal/XUiCollectionStyle") +local Vector3 = CS.UnityEngine.Vector3 + +function XUiGridViewCollection:Ctor(ui, collectionData, inType, otherPlayerCollection) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.OtherPlayerCollection = otherPlayerCollection + self.Id = collectionData.Id + self.InType = inType + self.CollectionStyleDic = {} -- Key:收藏品Id Value:XUiCollectionStyle脚本 + + XTool.InitUiObject(self) + + -- 监听点击 + self.GoInputHandler = self.Transform:GetComponent(typeof(CS.XGoInputHandler)) + if XTool.UObjIsNil(self.GoInputHandler) then + self.GoInputHandler = self.GameObject:AddComponent(typeof(CS.XGoInputHandler)) + end + + if not XTool.UObjIsNil(self.GoInputHandler) then + self.GoInputHandler:AddPointerClickListener(function(eventData) + self:OnClick(eventData) + end) + end + + self:InitComponent() + self:Refresh(collectionData) +end + +function XUiGridViewCollection:InitComponent() + local data + if self.InType == XDataCenter.MedalManager.InType.OtherPlayer then + data = self.OtherPlayerCollection + elseif self.InType == XDataCenter.MedalManager.InType.Normal then + -- 查看自己 + data = XDataCenter.MedalManager.GetScoreTitleById(self.Id) + end + local styleObj = self.CollectionStyleNode.gameObject:LoadPrefab(data.PrefabPath) + self.CollectionStyleDic[data] = XUiCollectionStyle.New(styleObj, data) + self.RImBlack.gameObject:SetActiveEx(false) +end + +function XUiGridViewCollection:Refresh(collectionData) + local gridSize = XCollectionWallConfigs.GetCollectionSize(collectionData.SizeId) + local gridPos = {} + gridPos.x = collectionData.X + gridPos.y = collectionData.Y + + self:SetPos(gridPos, gridSize) + self.TxtName.text = XMedalConfigs.GetCollectionNameById(collectionData.Id) +end + +function XUiGridViewCollection:SetPos(gridPos, gridSize) + if XTool.UObjIsNil(self.Transform) then + return + end + + local posVector2 = XDataCenter.CollectionWallManager.GetLocalPosByGridPos(gridPos, gridSize) + self.Transform.localPosition = Vector3(posVector2.x, posVector2.y, 0) +end + +--- +--- 点击 +function XUiGridViewCollection:OnClick() + local data + if self.InType == XDataCenter.MedalManager.InType.OtherPlayer then + data = self.OtherPlayerCollection + elseif self.InType == XDataCenter.MedalManager.InType.Normal then + -- 查看自己 + data = XDataCenter.MedalManager.GetScoreTitleById(self.Id) + end + + if not data then + XLog.Error("XUiGridViewCollection:OnClick函数错误,找不到对应的收藏品数据") + return + end + + XLuaUiManager.Open("UiCollectionTip", data, XDataCenter.MedalManager.InType.Normal) +end + +function XUiGridViewCollection:Destroy() + self.GoInputHandler:RemoveAllListeners() +end + +return XUiGridViewCollection \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCollectionWall/XUiCollectionWallOther.lua b/Resources/Scripts/XUi/XUiCollectionWall/XUiCollectionWallOther.lua new file mode 100644 index 00000000..4005ae26 --- /dev/null +++ b/Resources/Scripts/XUi/XUiCollectionWall/XUiCollectionWallOther.lua @@ -0,0 +1,78 @@ +local XUiCollectionWallOther = XClass(nil, "XUiCollectionWallOther") +local XUiGridPlacedCollectionOther = require("XUi/XUiCollectionWall/XUiCollectionWallGrid/XUiGridPlacedCollectionOther") + +function XUiCollectionWallOther:Ctor(ui, pedestalId, backgroundId, collectionInfo, scoreTitleDic) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + self.PedestalId = pedestalId + self.BackgroundId = backgroundId + self.CollectionInfo = collectionInfo + self.ScoreTitleDic = scoreTitleDic + self.CollectionDic = {} + + self:Refresh() +end + +function XUiCollectionWallOther:Refresh() + self:RefreshBackground() + self:GenerateCollection(self.CollectionInfo) +end + +function XUiCollectionWallOther:RefreshBackground() + local bgPath = XCollectionWallConfigs.GetColDecPath(self.BackgroundId) + self.RImgWallBg:SetRawImage(bgPath) +end + +function XUiCollectionWallOther:GenerateCollection(collectionSetInfos) + for _, info in pairs(collectionSetInfos) do + local gridPos = {} + gridPos.x = info.X + gridPos.y = info.Y + + local size = XCollectionWallConfigs.GetCollectionSize(info.SizeId) + local localPos = XDataCenter.CollectionWallManager.GetLocalPosByGridPos(gridPos, size) + + self:CreatePlacedCollection(info.Id, false, localPos, info.SizeId) + end +end + +function XUiCollectionWallOther:CreatePlacedCollection(collectionId, isNew, localPos, sizeId) + if not collectionId then + XLog.Error("XUiCollectionWallEdit.CreatePlacedCollection函数错误,参数collectionId为 nil") + return + end + + local scoreTitle = self.ScoreTitleDic[collectionId] + if not scoreTitle then + XLog.Error(string.format("XUiCollectionWallEdit.CreatePlacedCollection函数错误,没有收藏品Id:%s的数据信息", collectionId)) + return + end + local baseItemPath = XCollectionWallConfigs.GetColDecPath(self.PedestalId) + local baseItem = self.WallContent:LoadPrefab(baseItemPath) + if baseItem == nil or not baseItem:Exist() then + return + end + baseItem.gameObject:SetActiveEx(false) + + local obj = CS.UnityEngine.Object.Instantiate(baseItem) + local scale = XCollectionWallConfigs.GetCollectionScale(sizeId) + + obj.transform:SetParent(self.WallContent, false) + obj.transform.localScale = CS.UnityEngine.Vector3(scale, scale, scale) + obj.gameObject:SetActiveEx(true) + + local data = {} + data.Id = collectionId + data.LocalPos = localPos or self.DefaultLocalPos + data.SizeId = sizeId + data.IsNew = isNew + + local placedCollection = XUiGridPlacedCollectionOther.New(obj, self, self.WallContent, data, scoreTitle) + self.CollectionDic[collectionId] = placedCollection + + return placedCollection +end + +return XUiCollectionWallOther \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCollectionWall/XUiCollectionWallSetting.lua b/Resources/Scripts/XUi/XUiCollectionWall/XUiCollectionWallSetting.lua new file mode 100644 index 00000000..de024676 --- /dev/null +++ b/Resources/Scripts/XUi/XUiCollectionWall/XUiCollectionWallSetting.lua @@ -0,0 +1,175 @@ +local XUiCollectionWallSetting = XLuaUiManager.Register(XLuaUi, "UiCollectionWallSetting") + +local XUiGridCollectionWall = require("XUi/XUiCollectionWall/XUiCollectionWallGrid/XUiGridCollectionWall") + +function XUiCollectionWallSetting:OnStart() + -- 新旧设置缓存,用来检查是否作出了更改 + self.OldShowSetting = {} + self.CurShowSetting = {} + + self:InitComponent() + self:AddListener() + self:SetupDynamicTable() +end + +function XUiCollectionWallSetting:InitComponent() + self.AssetPanel = XUiPanelAsset.New( + self, + self.PanelAsset, + XDataCenter.ItemManager.ItemId.FreeGem, + XDataCenter.ItemManager.ItemId.ActionPoint, + XDataCenter.ItemManager.ItemId.Coin + ) + + self.PanelNoneTemplate.gameObject:SetActiveEx(false) + self.GridCollectionWall.gameObject:SetActiveEx(false) + self:InitDynamicTable() +end + +function XUiCollectionWallSetting:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelDynamicTable) + self.DynamicTable:SetProxy(XUiGridCollectionWall, self, XCollectionWallConfigs.EnumWallGridOpenType.Setting) + self.DynamicTable:SetDelegate(self) +end + +function XUiCollectionWallSetting:SetupDynamicTable() + self.PageDatas = XDataCenter.CollectionWallManager.GetNormalWallEntityList() + --self.PageDatas = XDataCenter.CollectionWallManager.GetWallEntityList() + + for _, wallData in ipairs(self.PageDatas) do + self.OldShowSetting[wallData:GetId()] = wallData:GetIsShow() + self.CurShowSetting[wallData:GetId()] = wallData:GetIsShow() + end + + self.PanelNoneTemplate.gameObject:SetActiveEx(#self.PageDatas <= 0) + self.DynamicTable:SetDataSource(self.PageDatas) + self.DynamicTable:ReloadDataSync(#self.PageDatas) +end + +function XUiCollectionWallSetting:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:UpdateGrid(self.PageDatas[index]) + end +end + +--- +--- 更改'wallDataId'的墙的展示设置缓存为'isShow' +---@param wallDataId number +---@param isShow boolean +function XUiCollectionWallSetting:ChangeCurShowSetting(wallDataId, isShow) + self.CurShowSetting[wallDataId] = isShow +end + +--- +--- 检查是否有更改需要保存 +function XUiCollectionWallSetting:CheckSave() + local needSave = false + + for wallDataId, isShow in pairs(self.OldShowSetting) do + if self.CurShowSetting[wallDataId] ~= isShow then + needSave = true + break + end + end + + return needSave +end + +function XUiCollectionWallSetting:AddListener() + self.BtnBack.CallBack = function() + self:OnBtnBackClick() + end + self.BtnMainUi.CallBack = function() + self:OnBtnMainUiClick() + end + self:BindHelpBtn(self.BtnHelp, "CollectionWall") + self.BtnSave.CallBack = function() + self:OnBtnSaveClick() + end + self.BtnPreview.CallBack = function() + self:OnBtnPreviewClick() + end +end + +--- +--- 保存收藏品墙展示设置 +--- 在发送协议后更新收藏品墙数据实体(XCollectionWall)IsShow属性 +--- 然后在回调中更新设置缓存 +function XUiCollectionWallSetting:OnBtnSaveClick() + if #self.PageDatas <= 0 then + -- 没有对外展示的墙 + XUiManager.TipMsg(CS.XTextManager.GetText("CollectionWallNoneShow")) + return + end + + -- 构造发送请求需要的数据 + local showInfoList = {} + for id, isShow in pairs(self.CurShowSetting) do + local showInfo = {} + showInfo.Id = id + showInfo.IsShow = isShow + table.insert(showInfoList, showInfo) + end + + XDataCenter.CollectionWallManager.RequestEditCollectionWallIsShow(showInfoList, function() + -- 保存后更新新旧设置缓存 + for _, wallData in ipairs(self.PageDatas) do + self.OldShowSetting[wallData:GetId()] = wallData:GetIsShow() + self.CurShowSetting[wallData:GetId()] = wallData:GetIsShow() + end + XUiManager.TipText("SetAppearanceSuccess") + end) +end + +--- +--- 打开收藏品墙的展示界面,showWallList为需要展示的收藏品墙的数据实体数组 +function XUiCollectionWallSetting:OnBtnPreviewClick() + local showWallList = {} + + for id, isShow in pairs(self.CurShowSetting) do + if isShow then + table.insert(showWallList, XDataCenter.CollectionWallManager.GetWallEntityData(id)) + end + end + + if next(showWallList) == nil then + -- 没有对外展示的墙 + XUiManager.TipMsg(CS.XTextManager.GetText("CollectionWallNoneShow")) + else + XLuaUiManager.Open("UiCollectionWallView", showWallList, XDataCenter.MedalManager.InType.Normal) + end +end + +function XUiCollectionWallSetting:OnBtnBackClick() + if self:CheckSave() then + XUiManager.DialogTip(CS.XTextManager.GetText("TipTitle"), CS.XTextManager.GetText("SaveShowSetting"), + XUiManager.DialogType.Normal, + function() + self:Close() + end, + function() + self:OnBtnSaveClick() + self:Close() + end) + return + end + self:Close() +end + +function XUiCollectionWallSetting:OnBtnMainUiClick() + if self:CheckSave() then + XUiManager.DialogTip(CS.XTextManager.GetText("TipTitle"), CS.XTextManager.GetText("SaveShowSetting"), + XUiManager.DialogType.Normal, + function() + XLuaUiManager.RunMain() + end, + function() + self:OnBtnSaveClick() + XLuaUiManager.RunMain() + XDataCenter.CollectionWallManager.ClearLocalCaptureCache() + end) + return + end + XLuaUiManager.RunMain() + XDataCenter.CollectionWallManager.ClearLocalCaptureCache() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCollectionWall/XUiCollectionWallView.lua b/Resources/Scripts/XUi/XUiCollectionWall/XUiCollectionWallView.lua new file mode 100644 index 00000000..075e0541 --- /dev/null +++ b/Resources/Scripts/XUi/XUiCollectionWall/XUiCollectionWallView.lua @@ -0,0 +1,162 @@ +local XUiCollectionWallView = XLuaUiManager.Register(XLuaUi, "UiCollectionWallView") +local XUiGridViewCollection = require("XUi/XUiCollectionWall/XUiCollectionWallGrid/XUiGridViewCollection") + +local DEFAULT_INDEX = 1 + +function XUiCollectionWallView:OnStart(wallDataList, inType, otherPlayerCollectionList) + if wallDataList == nil or next(wallDataList) == nil then + XLog.Error("XUiCollectionWallView:OnStart函数错误,wallDataList参数没有数据") + return + end + + self.InType = inType + self.WallDataList = wallDataList + self.OtherPlayerCollectionList = otherPlayerCollectionList + + XDataCenter.CollectionWallManager.SortWallEntityByRank(self.WallDataList) + + self.CollectionPool = {} -- 收藏品GameObject + self.CurrentCollection = {} -- 当前墙面的收藏品格子脚本 + + self.Min = 1 + self.Max = #wallDataList + self.Index = DEFAULT_INDEX + + self.BaseItem = {} -- 底座Id做索引,保存对应的ui物体模板 + + self:AddListener() +end + +function XUiCollectionWallView:OnEnable() + self:Refresh() +end + +function XUiCollectionWallView:Refresh() + self:RecoverCollection() + + self.BtnLeft.gameObject:SetActiveEx(self.Index ~= self.Min) + self.BtnRight.gameObject:SetActiveEx(self.Index ~= self.Max) + + local wallData = self.WallDataList[self.Index] + if wallData then + local pedestalId = wallData:GetPedestalId() + + for i, collectionInfo in pairs(wallData:GetCollectionSetInfos()) do + self.CollectionPool[pedestalId] = self.CollectionPool[pedestalId] or {} + + local grid = self.CollectionPool[pedestalId][i] + if not grid then + grid = self:GenerateCollection(collectionInfo,pedestalId) + table.insert(self.CollectionPool[pedestalId], grid) + else + local scale = XCollectionWallConfigs.GetCollectionScale(collectionInfo.SizeId) + grid.transform.localScale = CS.UnityEngine.Vector3(scale, scale, scale) + end + + grid.gameObject:SetActiveEx(true) + if self.InType == XDataCenter.MedalManager.InType.Normal then + self.CurrentCollection[collectionInfo.Id] = XUiGridViewCollection.New(grid, collectionInfo, self.InType) + else + if not self.OtherPlayerCollectionList then + XLog.Error("XUiCollectionWallView:Refresh函数错误,查看他人信息时,没有OtherPlayerCollectionList数据") + return + end + + -- 找到对应收藏品的数据 + local hasCollection = false + + for _, otherCollection in pairs(self.OtherPlayerCollectionList) do + if otherCollection.Id == collectionInfo.Id then + hasCollection = true + self.CurrentCollection[collectionInfo.Id] = XUiGridViewCollection.New(grid, collectionInfo, self.InType, otherCollection) + end + end + + if not hasCollection then + XLog.Error(string.format("XUiCollectionWallView:Refresh函数错误,未其他玩家信息中没有Id:%s的收藏品数据", collectionInfo.Id)) + grid.gameObject:SetActiveEx(false) + end + end + end + + local bgPath = XCollectionWallConfigs.GetColDecPath(wallData:GetBackgroundId()) + self.RImgWallBg:SetRawImage(bgPath) + else + XLog.Error("XUiCollectionWallView:Refresh函数错误,wallData为 nil") + end +end + +function XUiCollectionWallView:GenerateCollection(collectionInfo, pedestalId) + if not collectionInfo then + XLog.Error("XUiCollectionWallView:GenerateCollection函数错误,参数collectionInfo为 nil") + return + end + + if not self.BaseItem[pedestalId] then + local baseItemPath = XCollectionWallConfigs.GetColDecPath(pedestalId) + + self.Resource = CS.XResourceManager.Load(baseItemPath) + local baseItem = CS.UnityEngine.Object.Instantiate(self.Resource.Asset) + if baseItem == nil or not baseItem:Exist() then + return + end + baseItem.transform:SetParent(self.PanelWall, false) + baseItem.gameObject:SetLayerRecursively(self.PanelWall.gameObject.layer) + baseItem.gameObject:SetActiveEx(false) + + self.BaseItem[pedestalId] = baseItem + end + + local obj = CS.UnityEngine.Object.Instantiate(self.BaseItem[pedestalId]) + local scale = XCollectionWallConfigs.GetCollectionScale(collectionInfo.SizeId) + + obj.transform:SetParent(self.PanelWall, false) + obj.transform.localScale = CS.UnityEngine.Vector3(scale, scale, scale) + obj.gameObject:SetActiveEx(true) + + return obj +end + +function XUiCollectionWallView:RecoverCollection() + for _, collection in pairs(self.CurrentCollection) do + collection.GameObject:SetActiveEx(false) + collection:Destroy() + end + self.CurrentCollection = {} +end + +function XUiCollectionWallView:AddListener() + self.BtnBack.CallBack = function() + self:OnBtnBackClick() + end + self.BtnRight.CallBack = function() + self:OnBtnRightClick() + end + self.BtnLeft.CallBack = function() + self:OnBtnLeftClick() + end +end + +function XUiCollectionWallView:OnBtnRightClick() + self.Index = self.Index + 1 + if self.Index > self.Max then + XLog.Error("XUiCollectionWallView:OnRightClick函数错误,Index大于最大值") + self.Index = self.Max + end + self:PlayAnimation("QieHuan") + self:Refresh() +end + +function XUiCollectionWallView:OnBtnLeftClick() + self.Index = self.Index - 1 + if self.Index < self.Min then + XLog.Error("XUiCollectionWallView:OnBtnLeftClick,Index小于最小值") + self.Index = self.Min + end + self:PlayAnimation("QieHuan") + self:Refresh() +end + +function XUiCollectionWallView:OnBtnBackClick() + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiComeAcross/ComeAcrossClickGamePlayer.lua b/Resources/Scripts/XUi/XUiComeAcross/ComeAcrossClickGamePlayer.lua new file mode 100644 index 00000000..6f0e9b57 --- /dev/null +++ b/Resources/Scripts/XUi/XUiComeAcross/ComeAcrossClickGamePlayer.lua @@ -0,0 +1,163 @@ +local ComeAcrossGamePlayer = require("XUi/XUiComeAcross/ComeAcrossGamePlayer") +local ComeAcrossClickGamePlayer = XClass(ComeAcrossGamePlayer, "ComeAcrossClickGamePlayer") + +------------------需要重写的方法-------------------------------- +--初始化 +function ComeAcrossClickGamePlayer:OnPlayerInit() + self.TotalTimeLimit = 0 --游戏时间限制 + ComeAcrossClickGamePlayer.Super.OnPlayerInit(self) +end + +--播放下一关 +function ComeAcrossClickGamePlayer:OnPlayerNextLevel() + self.TotalTimeLimit = self.GameData.Time + ComeAcrossClickGamePlayer.Super.OnPlayerNextLevel(self) +end + +--开始游戏 +function ComeAcrossClickGamePlayer:OnPlayerStart() + self.TotalTimeLimit = 0 +end + +--等待开始 +function ComeAcrossClickGamePlayer:OnPlayerReadyDelay(isReadyDelay, delayTime) + if self.OnPlayReadyDelay then + self.OnPlayReadyDelay(isReadyDelay, delayTime) + end +end + +--等待下关 +function ComeAcrossClickGamePlayer:OnPlayerWaitForNext(isWaiting, waitTime) + if self.OnPlayWaitForNext then + self.OnPlayWaitForNext(isWaiting, waitTime) + end +end + +--等待结束 +function ComeAcrossClickGamePlayer:OnPlayerWaitForEnding(isEnding, delayTime) + if self.OnPlayEndingDelay then + self.OnPlayEndingDelay(isEnding, delayTime) + end +end + +--更新 +function ComeAcrossClickGamePlayer:OnPlayerUpdate() + if self.OnPlayUpdate then + self.OnPlayUpdate(self.Time, self.TotalTimeLimit) + end + + if self.Time >= self.TotalTimeLimit then + self.State = ComeAcrossGamePlayer.PlayerState.WAIT + self:TimeOut() + end +end + +--停止回调 +function ComeAcrossClickGamePlayer:OnPlayerStop() + +end + +--完成回调 +function ComeAcrossClickGamePlayer:OnPlayerFinish() + if self.OnPlayFinish then + self.OnPlayFinish(self.PlayResult) + end +end + + +--处理消除的元素 +function ComeAcrossClickGamePlayer:OnPlayerDealClick(id) + + local target = nil + local targetIndex = -1 + for i, v in ipairs(self.GameData.Answer) do + if v.Index == id then + target = v + targetIndex = i + break + end + end + + if not target then + XLog.Error("ComeAcrossClickGamePlayer:OnClick 找不到Id", id) + return + end + + local removeList = {} + local last = target.Last + local next = target.Next + + table.insert(removeList, target) + removeList, last, next, targetIndex = self:FindNeighborRecursion(removeList, target.Type, targetIndex, last, next, true) + + if removeList and #removeList >= targetIndex then + for _ = 1,#removeList,1 do + table.remove(self.GameData.Answer,targetIndex) + end + end + + if last then + last.Next = next + end + + if next then + next.Last = last + end + + --如果条件不符合 + local success = false + local question = self.GameData.Question[self.Step] + if #question == #removeList and question[1] == target.Type then + success = true + end + + + if self.OnPlayClick then + self.OnPlayClick(success, removeList,self.Step) + end + + if success then + self.State = ComeAcrossGamePlayer.PlayerState.ELIMINATE + self.LastEliminate = self.Time + self.Step = self.Step + 1 + self:OnPlayerCheckLevelFinish() + else + self.PlayResult[self.LevelIndex] = 0 + self:OnPlayerStepChanged() + self.State = ComeAcrossGamePlayer.PlayerState.WAIT + self.LevelChangeWaitTime = CS.XGame.Config:GetInt("TrustGameWaitForNextSecond") + end + +end + +--检测当前关卡是否完成 +function ComeAcrossClickGamePlayer:OnPlayerCheckLevelFinish() + if self.Step > #self.GameData.Question then + self.PlayResult[self.LevelIndex] = 1 + self:OnPlayerStepChanged() + self.State = ComeAcrossGamePlayer.PlayerState.WAIT + self.LevelChangeWaitTime = CS.XGame.Config:GetInt("TrustGameWaitForNextSecond") + end +end + + +--每一步骤回调 +function ComeAcrossGamePlayer:OnPlayerStepChanged(isTimeOut) + if self.OnPlayStepChange then + self.OnPlayStepChange(self.LevelIndex,self.PlayResult,isTimeOut) + end +end + + +------------------------------------------ +--超时 +function ComeAcrossClickGamePlayer:TimeOut() + self.PlayResult[self.LevelIndex] = 0 + self:OnPlayerStepChanged(true) + self.State = ComeAcrossGamePlayer.PlayerState.WAIT + self.LevelChangeWaitTime = CS.XGame.Config:GetInt("TrustGameWaitForNextSecond") +end + + + +return ComeAcrossClickGamePlayer \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiComeAcross/ComeAcrossEliminateGamePlayer.lua b/Resources/Scripts/XUi/XUiComeAcross/ComeAcrossEliminateGamePlayer.lua new file mode 100644 index 00000000..a99ccaa4 --- /dev/null +++ b/Resources/Scripts/XUi/XUiComeAcross/ComeAcrossEliminateGamePlayer.lua @@ -0,0 +1,200 @@ + +local ComeAcrossGamePlayer = require("XUi/XUiComeAcross/ComeAcrossGamePlayer") +local ComeAcrossEliminateGamePlayer = XClass(ComeAcrossGamePlayer, "ComeAcrossEliminateGamePlayer") + +local TOTALGRID_LIMIT = 8 + +------------------需要重写的方法-------------------------------- +--初始化 +function ComeAcrossEliminateGamePlayer:OnPlayerInit() + self.TotalClickTimesLimit = 0 --游戏次数 + self.AnswerIndex = 0 + self.OnPlayAddAnswer = nil + ComeAcrossEliminateGamePlayer.Super.OnPlayerInit(self) +end + +--播放下一关 +function ComeAcrossEliminateGamePlayer:OnPlayerNextLevel() + self.CurAnswer = self:GetCurLevelData() + self.TotalClickTimesLimit = self.GameData.LimitTimes + + if self.OnPlayNext then + self.OnPlayNext(self.GameData, self.CurAnswer) + end +end + +--开始游戏 +function ComeAcrossEliminateGamePlayer:OnPlayerStart() + self.TotalClickTimesLimit = 0 + self.AnswerIndex = 0 + +end + +--等待开始 +function ComeAcrossEliminateGamePlayer:OnPlayerReadyDelay(isReadyDelay, delayTime) + if self.OnPlayReadyDelay then + self.OnPlayReadyDelay(isReadyDelay, delayTime) + end +end + +--等待下关 +function ComeAcrossEliminateGamePlayer:OnPlayerWaitForNext(isWaiting, waitTime) + if self.OnPlayWaitForNext then + self.OnPlayWaitForNext(isWaiting, waitTime) + end +end + +--等待结束 +function ComeAcrossEliminateGamePlayer:OnPlayerWaitForEnding(isEnding, delayTime) + if self.OnPlayEndingDelay then + self.OnPlayEndingDelay(isEnding, delayTime) + end +end + + +--停止回调 +function ComeAcrossEliminateGamePlayer:OnPlayerStop() + +end + +--完成回调 +function ComeAcrossEliminateGamePlayer:OnPlayerFinish() + if self.OnPlayFinish then + self.OnPlayFinish(self.PlayResult) + end +end + + +--处理消除的元素 +function ComeAcrossEliminateGamePlayer:OnPlayerDealClick(id) + + local target = nil + local targetIndex = -1 + for i, v in ipairs(self.CurAnswer) do + if v.Index == id then + target = v + targetIndex = i + break + end + end + + if not target then + XLog.Error("ComeAcrossEliminateGamePlayer:OnClick 找不到Id", id) + return + end + + local removeList = {} + local last = target.Last + local next = target.Next + + table.insert(removeList, target) + removeList, last, next, targetIndex = self:FindNeighborRecursion(removeList, target.Type, targetIndex, last, next, true) + + if removeList and #removeList >= targetIndex then + for _ = 1,#removeList,1 do + table.remove(self.GameData.Answer,targetIndex) + end + end + + if last then + last.Next = next + end + + if next then + next.Last = last + end + + + local removeCount = #removeList + --补充元素 + for _ = 1, removeCount, 1 do + self.AnswerIndex = self.AnswerIndex + 1 + local answer = self.GameData.Answer[self.AnswerIndex] + if answer then + local lastIndex = #self.CurAnswer + local lastAnswer = self.CurAnswer[lastIndex] + table.insert(self.CurAnswer,answer) + lastAnswer.Next = answer + answer.Last = lastAnswer + if self.OnPlayAddAnswer then + self.OnPlayAddAnswer(answer) + end + end + end + + --如果条件不符合 + local success = false + local question = self.GameData.Question + if #question <= #removeList and question[1] == target.Type then + success = true + end + + if success then + self.State = ComeAcrossGamePlayer.PlayerState.ELIMINATE + self.LastEliminate = self.Time + self.Step = self.Step + 1 + self.TotalClickTimesLimit = self.TotalClickTimesLimit - 1 + else + self.TotalClickTimesLimit = self.TotalClickTimesLimit - 1 + end + + if self.OnPlayClick then + self.OnPlayClick(success, removeList) + end + + self:OnPlayerCheckLevelFinish() +end + +--检测当前关卡是否完成 +function ComeAcrossEliminateGamePlayer:OnPlayerCheckLevelFinish() + if self.Step > self.GameData.Times then + self.PlayResult[self.LevelIndex] = 1 + elseif self.TotalClickTimesLimit == 0 then + self.PlayResult[self.LevelIndex] = 0 + end + + self:OnPlayerStepChanged() + + if self.TotalClickTimesLimit == 0 or self.Step > self.GameData.Times then + self.State = ComeAcrossGamePlayer.PlayerState.WAIT + self.LevelChangeWaitTime = CS.XGame.Config:GetInt("TrustGameWaitForNextSecond") + end +end + + +--每一步骤回调 +function ComeAcrossEliminateGamePlayer:OnPlayerStepChanged() + if self.OnPlayStepChange then + self.OnPlayStepChange(self.LevelIndex,self.PlayResult,self.Step - 1,self.GameData.Times,self.TotalClickTimesLimit) + end +end + + +------------------------------------------ + +--获取当前关卡数据 +function ComeAcrossEliminateGamePlayer:GetCurLevelData() + local gameData = self.PlayData[self.LevelIndex] + + if not gameData or #gameData.Answer < TOTALGRID_LIMIT then + return + end + + local curData = {} + local lastData = nil + for i = 1, TOTALGRID_LIMIT, 1 do + local data = gameData.Answer[i] + table.insert(curData, data) + if lastData then + data.Last = lastData + lastData.Next = data + end + lastData = data + end + + self.AnswerIndex = TOTALGRID_LIMIT + return curData +end + + +return ComeAcrossEliminateGamePlayer \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiComeAcross/ComeAcrossGamePlayer.lua b/Resources/Scripts/XUi/XUiComeAcross/ComeAcrossGamePlayer.lua new file mode 100644 index 00000000..a12e5571 --- /dev/null +++ b/Resources/Scripts/XUi/XUiComeAcross/ComeAcrossGamePlayer.lua @@ -0,0 +1,334 @@ +local ComeAcrossGamePlayer = XClass(nil, "ComeAcrossGamePlayer") + +ComeAcrossGamePlayer.PlayerState = { + STOP = 0, + READY = 1, + WAIT = 2, + PLAYING = 3, + CHANGING = 4, + PAUSE = 5, + ELIMINATE = 6, + ENDING = 7, + END = 8 + +} + +local ELIMINATE_TIME = 0.3 + +function ComeAcrossGamePlayer:Ctor() + + -- -----Ui回调 + -- self.OnPlayInit = onPlayInit -- 初始化回调 + -- self.OnPlayNext = onPlayNext -- 下一关回调 + -- self.OnPlayWaitForNext = onPlayWaitForNext -- 等待下一关回调 + -- self.OnPlayUpdate = onPlayUpdate -- 等待下一关回调 + -- self.OnPlayFinish = onPlayFinish -- 完成回调 + -- self.OnPlayStepChange = onPlayStepChange -- 完成一步骤回调 + -- self.OnPlayClick = onPlayClick -- 点击回调 + -- self.OnPlayReadyDelay = onPlayReadyDelay -- 准备步骤回调 + -- self.OnPlayEndingDelay = onPlayEndingDelay -- 结束步骤回调 + + self:Init() +end + +function ComeAcrossGamePlayer:Init() + self.Time = 0 --时间线 + self.LevelIndex = 0 --当前关卡 + self.Step = 0 --当前关卡步数 + self.PlayResult = {} --关卡结果 + self.ReadyDelay = -1 --准备延迟 + self.State = ComeAcrossGamePlayer.PlayerState.STOP --状态 + self.PlayData = nil -- 游戏数据 + self.LevelChangeWaitTime = 0 --关卡变更的等待时间 + self.LastEliminate = 0 -- 上次消除的时间 + + self:OnPlayerInit() +end + +------------------需要重写的方法-------------------------------- +--初始化 +function ComeAcrossGamePlayer:OnPlayerInit() + if self.OnPlayInit then + self.OnPlayInit() + end +end + +--播放下一关 +function ComeAcrossGamePlayer:OnPlayerNextLevel() + if self.OnPlayNext then + self.OnPlayNext(self.GameData) + end +end + +--等待开始 +function ComeAcrossGamePlayer:OnPlayerReadyDelay(isReadyDelay, delayTime) + if self.OnPlayReadyDelay then + self.OnPlayReadyDelay(isReadyDelay, delayTime) + end +end + +--等待下关 +function ComeAcrossGamePlayer:OnPlayerWaitForNext(isWaiting, waitTime) + if self.OnPlayWaitForNext then + self.OnPlayWaitForNext(isWaiting, waitTime,self.PlayResult[self.LevelIndex]) + end +end + +--等待结束 +function ComeAcrossGamePlayer:OnPlayerWaitForEnding(isEnding, delayTime) + if self.OnPlayEndingDelay then + self.OnPlayEndingDelay(isEnding, delayTime) + end +end + +--更新 +function ComeAcrossGamePlayer:OnPlayerUpdate(dt, time) + if self.OnPlayUpdate then + self.OnPlayUpdate(dt, time) + end +end + +--开始游戏 +function ComeAcrossGamePlayer:OnPlayerStart() + +end + +--停止回调 +function ComeAcrossGamePlayer:OnPlayerStop() + +end + +--完成回调 +function ComeAcrossGamePlayer:OnPlayerFinish() + if self.OnPlayFinish then + self.OnPlayFinish(self.PlayResult) + end +end + +--每一步骤回调 +function ComeAcrossGamePlayer:OnPlayerStepChanged() + if self.OnPlayStepChange then + self.OnPlayStepChange(self.LevelIndex,self.PlayResult) + end +end + + +--处理消除的元素 +function ComeAcrossGamePlayer:OnPlayerDealClick(id) + + local target = nil + local targetIndex = -1 + for i, v in ipairs(self.GameData.Answer) do + if v.Index == id then + target = v + targetIndex = i + break + end + end + + if not target then + XLog.Error("ComeAcrossClickGamePlayer:OnClick 找不到Id", id) + return + end + + local removeList = {} + local last = target.Last + local next = target.Next + + table.insert(removeList, target) + removeList = self:FindNeighborRecursion(removeList, target.Type, targetIndex, last, next, true) + local success = false + + if self.OnPlayClick then + self.OnPlayClick(success, removeList) + end +end + +--检测当前关卡是否完成 +function ComeAcrossGamePlayer:OnPlayerCheckLevelFinish() + return true +end + +------------------------------------------------------- +--设置数据 +function ComeAcrossGamePlayer:SetPlayerData(playData) + self.PlayData = playData +end + +--开始 +function ComeAcrossGamePlayer:Play() + self.Time = 0 + self.LevelIndex = 0 + self.Step = 0 + self.LastEliminate = 0 + self.PlayResult = {} + self.ReadyDelay = CS.XGame.Config:GetInt("TrustGameReadySecond") + self.LevelChangeWaitTime = CS.XGame.Config:GetInt("TrustGameWaitForNextSecond") + self.EndingDelay = CS.XGame.Config:GetInt("TrustGameWaitForEnding") + self.State = ComeAcrossGamePlayer.PlayerState.READY + + self:OnPlayerStart() +end + +--开始下一关 +function ComeAcrossGamePlayer:PlayNextLevel() + if not self.PlayData or #self.PlayData <= 0 then + return + end + + if self:CheckGameFinish() then + self:Finish() + return + end + + self.LevelIndex = self.LevelIndex + 1 + self.Step = 1 + + self.GameData = self.PlayData[self.LevelIndex] + self.Time = 0 + self:OnPlayerNextLevel() + + if self.State ~= ComeAcrossGamePlayer.PlayerState.READY then + self.State = ComeAcrossGamePlayer.PlayerState.PLAYING + end +end + +--等待下一关开启 +function ComeAcrossGamePlayer:WaitForNext(dt) + if self.LevelChangeWaitTime > 0 then + self:OnPlayerWaitForNext(true, math.ceil(self.LevelChangeWaitTime)) + self.LevelChangeWaitTime = self.LevelChangeWaitTime - dt + else + self.LevelChangeWaitTime = 0 + self:OnPlayerWaitForNext(false, math.ceil(self.LevelChangeWaitTime)) + self.State = ComeAcrossGamePlayer.PlayerState.PLAYING + self:PlayNextLevel() + end +end + +--等待开始 +function ComeAcrossGamePlayer:WaitForStart(dt) + if self.ReadyDelay > 0 then + self:OnPlayerReadyDelay(true, math.ceil(self.ReadyDelay)) + self.ReadyDelay = self.ReadyDelay - dt + else + self.ReadyDelay = 0 + self.State = ComeAcrossGamePlayer.PlayerState.PLAYING + self:OnPlayerReadyDelay(false, math.ceil(self.ReadyDelay)) + self:PlayNextLevel() + end +end + +--等待结束 +function ComeAcrossGamePlayer:WaitForEnding(dt) + if self.EndingDelay > 0 then + self:OnPlayerWaitForEnding(true, math.ceil(self.EndingDelay)) + self.EndingDelay = self.EndingDelay - dt + else + self.EndingDelay = 0 + self.State = ComeAcrossGamePlayer.PlayerState.END + self:OnPlayerWaitForEnding(false, math.ceil(self.EndingDelay)) + self:OnPlayerFinish() + self:Stop() + end +end + +--更新 +function ComeAcrossGamePlayer:Update(dt) + if self.State == ComeAcrossGamePlayer.PlayerState.STOP or self.State == ComeAcrossGamePlayer.PlayerState.END then + return + end + + + if self.State == ComeAcrossGamePlayer.PlayerState.ENDING then + self:WaitForEnding(dt) + return + end + + if self:CheckGameFinish() and self.State ~= ComeAcrossGamePlayer.PlayerState.ENDING then + self:Finish() + return + end + + if self.State == ComeAcrossGamePlayer.PlayerState.WAIT then + self:WaitForNext(dt) + return + end + + if self.State == ComeAcrossGamePlayer.PlayerState.READY then + self:WaitForStart(dt) + return + end + + if self.State ~= ComeAcrossGamePlayer.PlayerState.PLAYING and self.State ~= ComeAcrossGamePlayer.PlayerState.ELIMINATE then + return + end + + --消除的时间 + if self.State == ComeAcrossGamePlayer.PlayerState.ELIMINATE and self.LastEliminate + ELIMINATE_TIME <= self.Time then + self.State = ComeAcrossGamePlayer.PlayerState.PLAYING + end + + self.Time = self.Time + dt + self:OnPlayerUpdate(dt, self.Time) +end + +--完成 +function ComeAcrossGamePlayer:Finish() + self.State = ComeAcrossGamePlayer.PlayerState.ENDING +end + +--停止 +function ComeAcrossGamePlayer:Stop() + self.Time = 0 + self.LevelIndex = 0 + self.Step = 0 + self.PlayResult = {} + self.State = ComeAcrossGamePlayer.PlayerState.STOP + + self:OnPlayerStop() +end + +--点击到消除 +function ComeAcrossGamePlayer:OnClick(id) + if not self.GameData then + return + end + + if self.State ~= ComeAcrossGamePlayer.PlayerState.PLAYING then + return + end + + self:OnPlayerDealClick(id) +end + +--检测完成 +function ComeAcrossGamePlayer:CheckGameFinish() + return #self.PlayData == #self.PlayResult +end + +--消球规则 +function ComeAcrossGamePlayer:FindNeighborRecursion(removeList, type, targetIndex, left, right, isNext) + if #removeList >= 3 then + return removeList, left, right, targetIndex + end + + if (not right or right.Type ~= type) and (not left or left.Type ~= type) then + return removeList, left, right, targetIndex + end + + + if isNext and right and right.Type == type then + table.insert(removeList, right) + right = right.Next + elseif left and left.Type == type then + table.insert(removeList, left) + left = left.Last + targetIndex = targetIndex - 1 + end + + return self:FindNeighborRecursion(removeList, type, targetIndex, left, right, not isNext) +end + + +return ComeAcrossGamePlayer \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiComeAcross/XUiComeAcross.lua b/Resources/Scripts/XUi/XUiComeAcross/XUiComeAcross.lua new file mode 100644 index 00000000..4733e8b2 --- /dev/null +++ b/Resources/Scripts/XUi/XUiComeAcross/XUiComeAcross.lua @@ -0,0 +1,104 @@ +local XUiComeAcross = XLuaUiManager.Register(XLuaUi, "UiComeAcross") +local XUiGridLevel = require("XUi/XUiComeAcross/XUiGridLevel") + +function XUiComeAcross:OnAwake() + self:InitAutoScript() + self:Init() +end + +function XUiComeAcross:Init() + self.GridLevel = {} + for i = 1, 5, 1 do + self.GridLevel[i] = XUiGridLevel.New(self["GridLevel_" .. i], self, i) + end +end + +function XUiComeAcross:OnStart() + self:SetupContent() + +end + +function XUiComeAcross:SetupContent() + local games = XDataCenter.ComeAcrossManager.GetComeAcrossGames() + for i = 1, 5, 1 do + if games[i] then + self.GridLevel[i]:SetGridLevelContent(games[i]) + self.GridLevel[i].GameObject:SetActive(true) + else + self.GridLevel[i].GameObject:SetActive(false) + end + end + + self:SetPlayTimes() +end + + + +function XUiComeAcross:SetPlayTimes() + local playTimes = XDataCenter.ComeAcrossManager.GetPlayCount() + local totalTimes = CS.XGame.Config:GetInt("TrustGameCount") + self.TxtTime.text = string.format("%s/%s", totalTimes - playTimes, totalTimes) +end + + +function XUiComeAcross:OnEnable() + self:SetPlayTimes() +end + +function XUiComeAcross:OnDisable() +end + + +function XUiComeAcross:OnDestroy() +end + + +function XUiComeAcross:OnGetEvents() + return { + XEventId.EVENT_COMEACROSS_PLAY, + XEventId.EVENT_COMEACROSS_PLAYRESULT, + } +end + + +function XUiComeAcross:OnNotify() + self:SetupContent() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiComeAcross:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiComeAcross:AutoInitUi() + self.TxtTime = self.Transform:Find("Animator/SafeAreaContentPane/Text/TxtTime"):GetComponent("Text") + self.BtnHelp = self.Transform:Find("Animator/SafeAreaContentPane/BtnHelp"):GetComponent("Button") + self.PanelLevel = self.Transform:Find("Animator/SafeAreaContentPane/PanelLevel") + self.GridLevel_1 = self.Transform:Find("Animator/SafeAreaContentPane/PanelLevel/GridLevel_1") + self.GridLevel_2 = self.Transform:Find("Animator/SafeAreaContentPane/PanelLevel/GridLevel_2") + self.GridLevel_3 = self.Transform:Find("Animator/SafeAreaContentPane/PanelLevel/GridLevel_3") + self.GridLevel_4 = self.Transform:Find("Animator/SafeAreaContentPane/PanelLevel/GridLevel_4") + self.GridLevel_5 = self.Transform:Find("Animator/SafeAreaContentPane/PanelLevel/GridLevel_5") + self.BtnMainUi = self.Transform:Find("Animator/SafeAreaContentPane/Top/BtnMainUi"):GetComponent("Button") + self.BtnBack = self.Transform:Find("Animator/SafeAreaContentPane/Top/BtnBack"):GetComponent("Button") +end + +function XUiComeAcross:AutoAddListener() + self:RegisterClickEvent(self.BtnHelp, self.OnBtnHelpClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) +end +-- auto +function XUiComeAcross:OnBtnHelpClick() + XUiManager.DialogTip("", CS.XTextManager.GetText("ComeAcrossTips"), XUiManager.DialogType.OnlyClose) +end + +function XUiComeAcross:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiComeAcross:OnBtnBackClick() + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiComeAcross/XUiComeAcrossGame.lua b/Resources/Scripts/XUi/XUiComeAcross/XUiComeAcrossGame.lua new file mode 100644 index 00000000..ccb4013b --- /dev/null +++ b/Resources/Scripts/XUi/XUiComeAcross/XUiComeAcrossGame.lua @@ -0,0 +1,143 @@ +local XUiComeAcrossGame = XLuaUiManager.Register(XLuaUi, "UiComeAcrossGame") +local XUiPanelGame = require("XUi/XUiComeAcross/XUiPanelGame") +local XUiPanelEliminateGame = require("XUi/XUiComeAcross/XUiPanelEliminateGame") +local XUiPanelComeAcrossReward = require("XUi/XUiComeAcross/XUiPanelComeAcrossReward") +local XUiPanelStart = require("XUi/XUiComeAcross/XUiPanelStart") + +function XUiComeAcrossGame:OnAwake() + self:InitAutoScript() + self:Init() +end + +function XUiComeAcrossGame:Init() + self.ComeAcrossClickGame = XUiPanelGame.New(self.PanelGame, self) + self.ComeAcrossEliminateGame = XUiPanelEliminateGame.New(self.PanelEliminateGame, self) + self.ComeAcrossRewardPanel = XUiPanelComeAcrossReward.New(self.PanelComeAcrossReward, self) + self.StartPanel = XUiPanelStart.New(self.PanelStart, self) + + self.CurGame = nil + self.PanelStart.gameObject:SetActive(true) + self.PanelComeAcrossReward.gameObject:SetActive(false) + self.PanelGame.gameObject:SetActive(false) + self.PanelEliminateGame.gameObject:SetActive(false) + + self.PanelMask.gameObject:SetActive(false) + + self.Timer = XScheduleManager.ScheduleForever(function() + self:Update() + end, 0) +end + + +function XUiComeAcrossGame:OnStart(gameData) + self.GameData = gameData + local gameType = gameData.GameConfig.Type + if gameType == ComeAcrossGameType.GAME_CLICK then + self.CurGame = self.ComeAcrossClickGame + else + self.CurGame = self.ComeAcrossEliminateGame + end + + local position = self.GameData.Position + + self.StartPanel:SetupContent(self.GameData) + self:SetUiSprite(self.ImgBg, position.BgIcon) + self:PlayAnimation("UiComeAcrossGameStartBegin") + + +end + +function XUiComeAcrossGame:OnFinish(result) + + if not self.GameData then + return + end + + local finitshNum = 0 + for _, v in ipairs(result) do + if v == 1 then + finitshNum = finitshNum + 1 + end + end + + XDataCenter.ComeAcrossManager.ReqTrustGameResultRequest(self.GameData.Character.Id, self.GameData.GameConfig.Id, finitshNum, function() + self.PanelStart.gameObject:SetActive(true) + self.PanelMask.gameObject:SetActive(false) + self.CurGame.GameObject:SetActive(false) + + self.StartPanel:SetupResult() + end) +end + + +function XUiComeAcrossGame:SetupReward() + local result = XDataCenter.ComeAcrossManager.GetLastResult() + if result then + self.PanelComeAcrossReward.gameObject:SetActive(true) + self.ComeAcrossRewardPanel:SetupReward(self.GameData, result) + end +end + +function XUiComeAcrossGame:OnEnable() +end + + +function XUiComeAcrossGame:OnDisable() +end + + +function XUiComeAcrossGame:OnDestroy() + if self.Timer ~= nil then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end + + +function XUiComeAcrossGame:OnNotify() +end + + +function XUiComeAcrossGame:Update() + local dt = CS.UnityEngine.Time.deltaTime + if self.CurGame then + self.CurGame:Update(dt) + end +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiComeAcrossGame:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiComeAcrossGame:AutoInitUi() + self.PanelStart = self.Transform:Find("Animator/FullScreenBackground/PanelStart") + self.PanelGame = self.Transform:Find("Animator/FullScreenBackground/PanelGame") + self.PanelComeAcrossReward = self.Transform:Find("Animator/FullScreenBackground/PanelComeAcrossReward") + self.PanelMask = self.Transform:Find("Animator/FullScreenBackground/PanelMask") + self.PanelEliminateGame = self.Transform:Find("Animator/FullScreenBackground/PanelEliminateGame") + self.ImgBg = self.Transform:Find("Animator/FullScreenBackground/ImgBg"):GetComponent("Image") +end + +function XUiComeAcrossGame:AutoAddListener() +end +-- auto +function XUiComeAcrossGame:OnBtnSelectClick() + if not self.CurGame then + return + end + + self.PanelStart.gameObject:SetActive(false) + self.PanelMask.gameObject:SetActive(true) + self.CurGame.GameObject:SetActive(true) + + self.CurGame:SetupGameData(self.GameData) + self.CurGame:Play() + +end + +function XUiComeAcrossGame:OnSliderFavorClick() + +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiComeAcross/XUiGridElement.lua b/Resources/Scripts/XUi/XUiComeAcross/XUiGridElement.lua new file mode 100644 index 00000000..67d15c5b --- /dev/null +++ b/Resources/Scripts/XUi/XUiComeAcross/XUiGridElement.lua @@ -0,0 +1,113 @@ +local XUiGridElement = XClass(nil, "XUiGridElement") + +function XUiGridElement:Ctor(ui,parent,rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Parent = parent + self.RootUi = rootUi + self.IsClick = false + + self:InitAutoScript() +end + +function XUiGridElement:SetSmallGridContent(gridType) + local tab = XComeAcrossConfig.GetComeAcrossGridConfigById(gridType) + + + self.ImgGray.gameObject:SetActive(false) + self.ImgNormal.gameObject:SetActive(true) + self.ImgError.gameObject:SetActive(false) + + self.RootUi:SetUiSprite(self.ImgNormal,tab.SmallIcon) + self.RootUi:SetUiSprite(self.ImgGray,tab.SmallIcon) + self.RootUi:SetUiSprite(self.ImgError,tab.SmallIcon) + self.BtnElement.gameObject:SetActive(false) + self.GridType = gridType + +end + + +function XUiGridElement:SetBigGridContent(answer) + local tab = XComeAcrossConfig.GetComeAcrossGridConfigById(answer.Type) + if not tab then + return + end + + self.ImgGray.gameObject:SetActive(false) + self.ImgNormal.gameObject:SetActive(true) + self.ImgError.gameObject:SetActive(false) + + self.RootUi:SetUiSprite(self.ImgNormal,tab.BigIcon) + self.RootUi:SetUiSprite(self.ImgGray,tab.BigIcon) + self.RootUi:SetUiSprite(self.ImgError,tab.BigIcon) + self.ImgNormal.gameObject:SetActive(true) + self.GridType = answer.Type + self.Index = answer.Index +end + + +function XUiGridElement:SetGray() + self.ImgGray.gameObject:SetActive(true) + self.ImgNormal.gameObject:SetActive(false) + self.ImgError.gameObject:SetActive(false) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiGridElement:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiGridElement:AutoInitUi() + self.ImgNormal = XUiHelper.TryGetComponent(self.Transform, "ImgNormal", "Image") + self.ImgGray = XUiHelper.TryGetComponent(self.Transform, "ImgGray", "Image") + self.ImgError = XUiHelper.TryGetComponent(self.Transform, "ImgError", "Image") + self.BtnElement = XUiHelper.TryGetComponent(self.Transform, "BtnElement", "Button") + self.PanelEffect = XUiHelper.TryGetComponent(self.Transform, "PanelEffect", nil) +end + +function XUiGridElement:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiGridElement:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiGridElement:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiGridElement:AutoAddListener() + self:RegisterClickEvent(self.BtnElement, self.OnBtnElementClick) +end +-- auto + +function XUiGridElement:OnBtnElementClick() + self.Parent.GamePlayer:OnClick(self.Index) +end + +function XUiGridElement:OnEliminate(callback) + if self.IsClick then + return + end + + self.PanelEffect.gameObject:SetActive(true) + self.IsClick = true + self.Timer = XScheduleManager.ScheduleOnce(function() + self.PanelEffect.gameObject:SetActive(false) + + if callback then + callback() + end + end, 300) + +end + +return XUiGridElement diff --git a/Resources/Scripts/XUi/XUiComeAcross/XUiGridLevel.lua b/Resources/Scripts/XUi/XUiComeAcross/XUiGridLevel.lua new file mode 100644 index 00000000..2192e113 --- /dev/null +++ b/Resources/Scripts/XUi/XUiComeAcross/XUiGridLevel.lua @@ -0,0 +1,79 @@ +local XUiGridLevel = XClass(nil, "XUiGridLevel") + +function XUiGridLevel:Ctor(ui,parent,index) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self:InitAutoScript() + self.Parent = parent + self.Index = index + + self.StarPool = self.PanelStar:GetComponent("XUnityPoolSingle") + +end + +function XUiGridLevel:SetGridLevelContent(data) + self.Data = data + + local position = data.Position + self.TxtName.text = position.Name + + local game = data.GameConfig + local gameType = game.Type + local star = game.Difficult + + self.StarPool:DespawnAll() + for _ = 1,star,1 do + self.StarPool:Spawn() + end + + local gameTypeCfg = XComeAcrossConfig.GetComeAcrossTypeConfigById(gameType) + self.Parent:SetUiSprite(self.ImgType,gameTypeCfg.Icon) + self.Parent:SetUiSprite(self.ImgHead, XDataCenter.CharacterManager.GetCharRoundnessHeadIcon(data.Character.Id)) + +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiGridLevel:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiGridLevel:AutoInitUi() + self.PanelStar = XUiHelper.TryGetComponent(self.Transform, "PanelStar", nil) + self.ImgStar = XUiHelper.TryGetComponent(self.Transform, "PanelStar/ImgStar", "Image") + self.TxtName = XUiHelper.TryGetComponent(self.Transform, "Image/TxtName", "Text") + self.ImgType = XUiHelper.TryGetComponent(self.Transform, "Image/ImgType", "Image") + self.ImgHead = XUiHelper.TryGetComponent(self.Transform, "ImgHead", "Image") + self.BtnEnter = XUiHelper.TryGetComponent(self.Transform, "BtnEnter", "Button") +end + +function XUiGridLevel:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiGridLevel:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiGridLevel:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiGridLevel:AutoAddListener() + self:RegisterClickEvent(self.BtnEnter, self.OnBtnEnterClick) +end +-- auto + +function XUiGridLevel:OnBtnEnterClick() + XDataCenter.ComeAcrossManager.ReqTrustGamePlayRequest(function() + CsXUiManager.Instance:Open("UiComeAcrossGame",self.Data) + end) +end + +return XUiGridLevel diff --git a/Resources/Scripts/XUi/XUiComeAcross/XUiPanelComeAcrossReward.lua b/Resources/Scripts/XUi/XUiComeAcross/XUiPanelComeAcrossReward.lua new file mode 100644 index 00000000..c233d492 --- /dev/null +++ b/Resources/Scripts/XUi/XUiComeAcross/XUiPanelComeAcrossReward.lua @@ -0,0 +1,73 @@ +local XUiPanelComeAcrossReward = XClass(nil, "XUiPanelComeAcrossReward") + +function XUiPanelComeAcrossReward:Ctor(ui, parent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Parent = parent + self:InitAutoScript() + self.RewardPool = self.PanelRewardBig:GetComponent("XUnityPoolSingle") + +end + +function XUiPanelComeAcrossReward:SetupReward(gameData, result) + self.TxtFavorAdd.text = "+" .. result.TrustExp + self.Parent:SetUiSprite(self.ImgRoleA, XDataCenter.CharacterManager.GetCharHalfBodyBigImage(gameData.Character.Id)) + local rewards = result.RewardGoodsList + + self.RewardPool:DespawnAll() + for i = 1, #rewards, 1 do + local ui = self.RewardPool:Spawn() + local grid = XUiGridCommon.New(self.Parent, ui) + grid:Refresh(rewards[i]) + end + + local favor = XDataCenter.FavorabilityManager.GetCharacterTrustExpById(gameData.Character.Id) + local curFavorabilityTableData = XDataCenter.FavorabilityManager.GetFavorabilityTableData(gameData.Character.Id) + self.SliderFavor.value = favor/curFavorabilityTableData.Exp +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelComeAcrossReward:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiPanelComeAcrossReward:AutoInitUi() + self.BtnRewardBg = self.Transform:Find("BtnRewardBg"):GetComponent("Button") + self.PanelRewardInfo = self.Transform:Find("GameObject/PanelRewardInfo") + self.PanelRole = self.Transform:Find("GameObject/PanelRewardInfo/PanelRole") + self.ImgRoleA = self.Transform:Find("GameObject/PanelRewardInfo/PanelRole/ImgRole"):GetComponent("Image") + self.PanelFavor = self.Transform:Find("GameObject/PanelRewardInfo/PanelFavor") + self.TxtFavorAdd = self.Transform:Find("GameObject/PanelRewardInfo/PanelFavor/TxtFavorAdd"):GetComponent("Text") + self.SliderFavor = self.Transform:Find("GameObject/PanelRewardInfo/PanelFavor/SliderFavor"):GetComponent("Slider") + self.PanelRewardBig = self.Transform:Find("GameObject/PanelRewardInfo/PanelRewardBig") + self.PanelMaskA = self.Transform:Find("PanelMask") +end + +function XUiPanelComeAcrossReward:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelComeAcrossReward:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelComeAcrossReward:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelComeAcrossReward:AutoAddListener() + self:RegisterClickEvent(self.BtnRewardBg, self.OnBtnRewardBgClick) +end +-- auto +function XUiPanelComeAcrossReward:OnBtnRewardBgClick() + self.Parent:Close() +end + +return XUiPanelComeAcrossReward \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiComeAcross/XUiPanelEliminateGame.lua b/Resources/Scripts/XUi/XUiComeAcross/XUiPanelEliminateGame.lua new file mode 100644 index 00000000..74d34046 --- /dev/null +++ b/Resources/Scripts/XUi/XUiComeAcross/XUiPanelEliminateGame.lua @@ -0,0 +1,322 @@ +local XUiPanelEliminateGame = XClass(nil, "XUiPanelEliminateGame") +local XUiGridElement = require("XUi/XUiComeAcross/XUiGridElement") + +function XUiPanelEliminateGame:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self:InitAutoScript() + self:Init() +end + +function XUiPanelEliminateGame:Init() + self.SmallPool = self.PanelPoolSmall:GetComponent("XUnityPoolSingle") + self.BigPool = self.PanelAnsPool:GetComponent("XUnityPoolSingle") + self.QuePanel = {} + self.AddingList = {} + + self.TickPanel = {} + local XUiPanelTick = require("XUi/XUiComeAcross/XUiPanelTick") + self.TickPanel[1] = XUiPanelTick.New(self.PanelTick_1) + self.TickPanel[2] = XUiPanelTick.New(self.PanelTick_2) + self.TickPanel[3] = XUiPanelTick.New(self.PanelTick_3) + + self.PanelTimes.gameObject:SetActive(false) + self.PanelReady.gameObject:SetActive(false) + self.PanelQuestion.gameObject:SetActive(false) + self.PanelAnswer.gameObject:SetActive(false) + self.PanelResult.gameObject:SetActive(false) + self.PanelScore.gameObject:SetActive(false) + + local gamePlayer = require("XUi/XUiComeAcross/ComeAcrossEliminateGamePlayer").New() + + gamePlayer.OnPlayNext = handler(self, self.OnPlayNext) -- 下一关回调 + gamePlayer.OnPlayWaitForNext = handler(self, self.OnPlayWaitForNext) -- 等待下一关回调 + gamePlayer.OnPlayAddAnswer = handler(self, self.OnPlayAddAnswer) -- 添加元素 + gamePlayer.OnPlayFinish = handler(self, self.OnPlayFinish) -- 完成回调 + gamePlayer.OnPlayStepChange = handler(self, self.OnPlayStepChange) -- 完成一步骤回调 + gamePlayer.OnPlayClick = handler(self, self.OnPlayClick) -- 点击回调 + gamePlayer.OnPlayReadyDelay = handler(self, self.OnPlayReadyDelay) -- 准备步骤回调 + gamePlayer.OnPlayEndingDelay = handler(self, self.OnPlayEndingDelay) -- 结束步骤回调 + + + self.GamePlayer = gamePlayer + self.CountDown = -1 +end + + +--准备倒计时 +function XUiPanelEliminateGame:OnPlayReadyDelay(IsReady, countDown) + if self.CountDown == countDown then + return + end + + self.CountDown = countDown + + if not IsReady then + self.PanelTimes.gameObject:SetActive(not IsReady) + self.PanelQuestion.gameObject:SetActive(not IsReady) + self.PanelAnswer.gameObject:SetActive(not IsReady) + self.PanelScore.gameObject:SetActive(not IsReady) + end + + self.PanelReady.gameObject:SetActive(IsReady) + + if self.CountDown > 1 then + self.TxtCountDown.text = tostring(countDown - 1) + else + self.TxtCountDown.text = CS.XTextManager.GetText("ComeAcrossStart") + end +end + +--等待下一关 +function XUiPanelEliminateGame:OnPlayWaitForNext(IsWait, countDown) + if self.CountDown == countDown then + return + end + + self.CountDown = countDown + + self.PanelResult.gameObject:SetActive(IsWait) + self.TxtResultDesc.text = string.format(CS.XTextManager.GetText("ComeAcrossNext"), countDown) +end + + +--设置Ui +function XUiPanelEliminateGame:OnPlayNext(gameData, answer) + self.SmallPool:DespawnAll() + self.BigPool:DespawnAll() + self.AnswerGirds = {} + self.QuestionGirds = {} + + local question = gameData.Question + local questionGirds = {} + if question then + for _, var in ipairs(question) do + local grid = self.SmallPool:Spawn() + grid.transform:SetParent(self.Panel, false) + grid:SetActive(true) + local gridElement = XUiGridElement.New(grid, self, self.RootUi) + gridElement:SetSmallGridContent(var) + table.insert(questionGirds, gridElement) + end + end + + + local answerGirds = {} + + if answer then + for _, var in ipairs(answer) do + local grid = self.BigPool:Spawn() + grid.transform:SetParent(self.PanelLayout, false) + grid:SetActive(true) + + local gridElement = XUiGridElement.New(grid, self, self.RootUi) + gridElement:SetBigGridContent(var) + answerGirds[var.Index] = gridElement + end + end + + + self.TxtTimes.text = string.format("%s/%s", 0, gameData.Times) + self.TxtTimesLeft.text = gameData.LimitTimes + + + self.AnswerGirds = answerGirds + self.QuestionGirds = questionGirds +end + +--追加 +function XUiPanelEliminateGame:OnPlayAddAnswer(answer) + local grid = self.BigPool:Spawn() + grid.transform:SetParent(self.PanelLayout, false) + grid:SetActive(false) + + local gridElement = XUiGridElement.New(grid, self, self.RootUi) + gridElement:SetBigGridContent(answer) + self.AddingList[answer.Index] = gridElement + self.AnswerGirds[answer.Index] = gridElement +end + +--点击回调 +function XUiPanelEliminateGame:OnPlayClick(success, removeList) + if not removeList then + return + end + + for _, v in ipairs(removeList) do + local grid = self.AnswerGirds[v.Index] + if grid then + grid:OnEliminate(function() + self.AnswerGirds[v.Index] = nil + self.BigPool:Despawn(grid.GameObject) + + for _, v2 in pairs(self.AddingList) do + v2.GameObject:SetActive(true) + end + + self.AddingList = {} + end) + end + end +end + + +--完成一个关卡 +function XUiPanelEliminateGame:OnPlayStepChange(idx, results, step, totalStep, times) + if not results then + return + end + + local result = results[idx] + if self.TickPanel[idx] then + self.TickPanel[idx]:SetResult(result) + end + + self.TxtTimes.text = string.format("%s/%s", step, totalStep) + self.TxtTimesLeft.text = times + + self.TxtResult.text = result == 1 and CS.XTextManager.GetText("ComeAcrossRight") or CS.XTextManager.GetText("ComeAcrossWrong") +end + + +--结束步骤回调 +function XUiPanelEliminateGame:OnPlayEndingDelay(isEnding, countDown) + if self.CountDown == countDown then + return + end + + self.CountDown = countDown + + self.PanelResult.gameObject:SetActive(isEnding) + + self.TxtResult.text = CS.XTextManager.GetText("ComeAcrossGameEnd") + self.TxtResultDesc.text = string.format(CS.XTextManager.GetText("ComeAcrossEnd"), countDown) +end + +--完成 +function XUiPanelEliminateGame:OnPlayFinish(result) + self.RootUi:OnFinish(result) +end + + +-------------------------------------------------------- +--解释表数据 +function XUiPanelEliminateGame:ParserGameData(data) + local gameLevels = data.TypeOfGames + + local curGamelevel = {} + for _, v in ipairs(gameLevels) do + local game = {} + game.Question = {} + local question = v.Question + for i = 1, #question, 1 do + local idx = tonumber(string.sub(question, i, i)) + table.insert(game.Question, idx) + end + + game.Answer = {} + for i = 1, #v.Answer, 1 do + local idx = tonumber(string.sub(v.Answer, i, i)) + local answer = {} + answer.Index = i + answer.Type = idx + + table.insert(game.Answer, answer) + end + + game.Tab = v + game.Times = v.Times + game.LimitTimes = v.LimitTimes + table.insert(curGamelevel, game) + end + + return curGamelevel +end + + +--开始 +function XUiPanelEliminateGame:Play() + self.GameData = self:ParserGameData(self.CurData) + self.GamePlayer:SetPlayerData(self.GameData) + self:Reset() + + self.RootUi:PlayAnimation("UiComeAcrossGame2Begin", function() + self.GamePlayer:Play() + end) +end + +--更新 +function XUiPanelEliminateGame:Update(dt) + if self.GamePlayer then + self.GamePlayer:Update(dt) + end +end + +--重置 +function XUiPanelEliminateGame:Reset() + for i, v in ipairs(self.TickPanel) do + v.GameObject:SetActive(i <= self.CurData.GameConfig.Count) + v:Reset() + end +end + +--设置游戏数据 +function XUiPanelEliminateGame:SetupGameData(data) + if not data then + return + end + + self.CurData = data +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelEliminateGame:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiPanelEliminateGame:AutoInitUi() + self.PanelScore = self.Transform:Find("PanelScore") + self.Panel = self.Transform:Find("PanelScore/Panel") + self.PanelTick_1 = self.Transform:Find("PanelScore/Panel/PanelTick_1") + self.PanelTick_2 = self.Transform:Find("PanelScore/Panel/PanelTick_2") + self.PanelTick_3 = self.Transform:Find("PanelScore/Panel/PanelTick_3") + self.TxtTimes = self.Transform:Find("PanelScore/Text/TxtTimes"):GetComponent("Text") + self.PanelResult = self.Transform:Find("PanelScore/PanelResult") + self.TxtResult = self.Transform:Find("PanelScore/PanelResult/TxtResult"):GetComponent("Text") + self.TxtResultDesc = self.Transform:Find("PanelScore/PanelResult/TxtResultDesc"):GetComponent("Text") + self.PanelQuestion = self.Transform:Find("PanelQuestion") + self.Panel = self.Transform:Find("PanelQuestion/Panel") + self.PanelPoolSmall = self.Transform:Find("PanelQuestion/PanelPoolSmall") + self.PanelAnswer = self.Transform:Find("PanelAnswer") + self.PanelLayout = self.Transform:Find("PanelAnswer/PanelLayout") + self.PanelAnsPool = self.Transform:Find("PanelAnswer/PanelAnsPool") + self.PanelTimes = self.Transform:Find("PanelTimes") + self.TxtTimesLeft = self.Transform:Find("PanelTimes/TxtTimesLeft"):GetComponent("Text") + self.PanelReady = self.Transform:Find("PanelReady") + self.TxtCountDown = self.Transform:Find("PanelReady/TxtCountDown"):GetComponent("Text") +end + +function XUiPanelEliminateGame:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelEliminateGame:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelEliminateGame:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelEliminateGame:AutoAddListener() +end +-- auto +return XUiPanelEliminateGame \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiComeAcross/XUiPanelGame.lua b/Resources/Scripts/XUi/XUiComeAcross/XUiPanelGame.lua new file mode 100644 index 00000000..bb27e03b --- /dev/null +++ b/Resources/Scripts/XUi/XUiComeAcross/XUiPanelGame.lua @@ -0,0 +1,352 @@ +local XUiPanelGame = XClass(nil, "XUiPanelGame") +local XUiGridElement = require("XUi/XUiComeAcross/XUiGridElement") + +function XUiPanelGame:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self:InitAutoScript() + self:Init() +end + +function XUiPanelGame:Init() + self.SmallPool = self.PanelPoolSmall:GetComponent("XUnityPoolSingle") + self.BigPool = self.PanelAnsPool:GetComponent("XUnityPoolSingle") + self.QuePanel = {} + self.QuePanel[1] = self.PanelQue_1 + self.QuePanel[2] = self.PanelQue_2 + self.QuePanel[3] = self.PanelQue_3 + + self.TickPanel = {} + local XUiPanelTick = require("XUi/XUiComeAcross/XUiPanelTick") + self.TickPanel[1] = XUiPanelTick.New(self.PanelTick_1) + self.TickPanel[2] = XUiPanelTick.New(self.PanelTick_2) + self.TickPanel[3] = XUiPanelTick.New(self.PanelTick_3) + + self.PanelTime.gameObject:SetActive(false) + self.PanelReady.gameObject:SetActive(false) + self.PanelQuestion.gameObject:SetActive(false) + self.PanelAnswer.gameObject:SetActive(false) + self.PanelResult.gameObject:SetActive(false) + self.PanelScore.gameObject:SetActive(false) + + local gamePlayer = require("XUi/XUiComeAcross/ComeAcrossClickGamePlayer").New() + + --gamePlayer.OnPlayInit = onPlayInit -- 初始化回调 + gamePlayer.OnPlayNext = handler(self, self.OnPlayNext) -- 下一关回调 + gamePlayer.OnPlayWaitForNext = handler(self, self.OnPlayWaitForNext) -- 等待下一关回调 + gamePlayer.OnPlayUpdate = handler(self, self.OnPlayUpdate) -- 等待下一关回调 + gamePlayer.OnPlayFinish = handler(self, self.OnPlayFinish) -- 完成回调 + gamePlayer.OnPlayStepChange = handler(self, self.OnPlayStepChange) -- 完成一步骤回调 + gamePlayer.OnPlayClick = handler(self, self.OnPlayClick) -- 点击回调 + gamePlayer.OnPlayReadyDelay = handler(self, self.OnPlayReadyDelay) -- 准备步骤回调 + gamePlayer.OnPlayEndingDelay = handler(self, self.OnPlayEndingDelay) -- 结束步骤回调 + + self.GamePlayer = gamePlayer + + self.CountDown = -1 +end + +--设置游戏数据 +function XUiPanelGame:SetupGameData(data) + if not data then + return + end + + self.CurData = data +end + +--解释表数据 +function XUiPanelGame:ParserGameData(data) + local gameLevels = data.TypeOfGames + + local curGamelevel = {} + for _, v in ipairs(gameLevels) do + local game = {} + game.Question = {} + local question = v.Question + local group = string.Split(question, "|") + if group and #group >= 0 then + for index, var in ipairs(group) do + game.Question[index] = {} + for i = 1, #var, 1 do + local idx = tonumber(string.sub(var, i, i)) + table.insert(game.Question[index], idx) + end + end + end + + game.Answer = {} + local lastAnswer = nil + for i = 1, #v.Answer, 1 do + local idx = tonumber(string.sub(v.Answer, i, i)) + local answer = {} + answer.Index = i + answer.Type = idx + if lastAnswer then + answer.Last = lastAnswer + lastAnswer.Next = answer + end + + lastAnswer = answer + table.insert(game.Answer, answer) + end + + game.Tab = v + game.Time = v.Time + table.insert(curGamelevel, game) + end + + return curGamelevel +end +------------------------------------------- +--准备阶段 +function XUiPanelGame:OnPlayReadyDelay(IsReady, countDown) + + if self.CountDown == countDown then + return + end + + self.CountDown = countDown + + if not IsReady then + self.PanelTime.gameObject:SetActive(not IsReady) + self.PanelQuestion.gameObject:SetActive(not IsReady) + self.PanelAnswer.gameObject:SetActive(not IsReady) + self.PanelScore.gameObject:SetActive(not IsReady) + end + + self.PanelReady.gameObject:SetActive(IsReady) + if self.CountDown > 1 then + self.TxtCountDown.text = tostring(countDown - 1) + else + self.TxtCountDown.text = CS.XTextManager.GetText("ComeAcrossStart") + end + + --XUiHelper.PlayAnimation(self.RootUi, "UiComeAcrossGame1ReadyBegin") +end + + +--结束步骤回调 +function XUiPanelGame:OnPlayEndingDelay(isEnding, countDown) + if self.CountDown == countDown then + return + end + + self.CountDown = countDown + + self.PanelResult.gameObject:SetActive(isEnding) + + self.TxtResult.text = CS.XTextManager.GetText("ComeAcrossGameEnd") + self.TxtResultDesc.text = string.format(CS.XTextManager.GetText("ComeAcrossEnd"), countDown) + + --XUiHelper.PlayAnimation(self.RootUi, "UiComeAcrossGame1ResultBegin") +end + + +--设置Ui +function XUiPanelGame:OnPlayNext(gameData) + self.SliderTime.value = 1 + self.SmallPool:DespawnAll() + self.BigPool:DespawnAll() + self.AnswerGirds = {} + self.QuestionGirds = {} + + local question = gameData.Question + local questionGirds = {} + if question then + for i, v in ipairs(question) do + if not v or #v <= 0 then + break + end + + questionGirds[i] = {} + + for _, var in ipairs(v) do + local grid = self.SmallPool:Spawn() + grid.transform:SetParent(self.QuePanel[i], false) + grid:SetActive(true) + local gridElement = XUiGridElement.New(grid, self, self.RootUi) + gridElement:SetSmallGridContent(var) + table.insert(questionGirds[i], gridElement) + end + end + end + + + local answer = gameData.Answer + local answerGirds = {} + + if answer then + for _, var in ipairs(answer) do + local grid = self.BigPool:Spawn() + grid.transform:SetParent(self.PanelLayout, false) + grid:SetActive(true) + + local gridElement = XUiGridElement.New(grid, self, self.RootUi) + gridElement:SetBigGridContent(var) + answerGirds[var.Index] = gridElement + end + end + + self.AnswerGirds = answerGirds + self.QuestionGirds = questionGirds + +end + +--更新进度条 +function XUiPanelGame:OnPlayUpdate(curtime, timeLimit) + if curtime >= timeLimit then + curtime = timeLimit + end + + self.SliderTime.value = 1 - curtime / timeLimit +end + +--完成 +function XUiPanelGame:OnPlayFinish(result) + self.RootUi:OnFinish(result) +end + +--等待下一关 +function XUiPanelGame:OnPlayWaitForNext(IsWait, countDown) + + if self.CountDown == countDown then + return + end + + self.CountDown = countDown + + + self.PanelResult.gameObject:SetActive(IsWait) + self.TxtResultDesc.text = string.format(CS.XTextManager.GetText("ComeAcrossNext"), countDown) + +end + + +--完成一个关卡 +function XUiPanelGame:OnPlayStepChange(idx, results, isTimeOut) + if not results then + return + end + + local result = results[idx] + if self.TickPanel[idx] then + self.TickPanel[idx]:SetResult(result) + end + + if isTimeOut then + self.TxtResult.text = CS.XTextManager.GetText("ComeAcrossTimeout") + else + self.TxtResult.text = result == 1 and CS.XTextManager.GetText("ComeAcrossRight") or CS.XTextManager.GetText("ComeAcrossWrong") + end + + --XUiHelper.PlayAnimation(self.RootUi, "UiComeAcrossGame1ResultBegin") +end + + +--点击回调 +function XUiPanelGame:OnPlayClick(success, removeList, step) + if not removeList then + return + end + + for _, v in ipairs(removeList) do + local grid = self.AnswerGirds[v.Index] + if grid then + grid:OnEliminate(function() + self.AnswerGirds[v.Index] = nil + self.BigPool:Despawn(grid.GameObject) + end) + end + end + + + for i = 1, step, 1 do + if self.QuestionGirds[i] then + for _, var in ipairs(self.QuestionGirds[i]) do + var:SetGray() + end + end + end +end + +---------------------------------------------------- +--开始 +function XUiPanelGame:Play() + self.GameData = self:ParserGameData(self.CurData) + self.GamePlayer:SetPlayerData(self.GameData) + self:Reset() + + self.RootUi:PlayAnimation("UiComeAcrossGame1Begin", function() + self.GamePlayer:Play() + end) +end + +--更新 +function XUiPanelGame:Update(dt) + if self.GamePlayer then + self.GamePlayer:Update(dt) + end +end + +--重置 +function XUiPanelGame:Reset() + for i, v in ipairs(self.TickPanel) do + v.GameObject:SetActive(i <= self.CurData.GameConfig.Count) + v:Reset() + end +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelGame:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiPanelGame:AutoInitUi() + self.PanelScore = self.Transform:Find("PanelScore") + self.Panel = self.Transform:Find("PanelScore/Panel") + self.PanelTick_1 = self.Transform:Find("PanelScore/Panel/PanelTick_1") + self.PanelTick_2 = self.Transform:Find("PanelScore/Panel/PanelTick_2") + self.PanelTick_3 = self.Transform:Find("PanelScore/Panel/PanelTick_3") + self.PanelResult = self.Transform:Find("PanelScore/PanelResult") + self.TxtResult = self.Transform:Find("PanelScore/PanelResult/TxtResult"):GetComponent("Text") + self.TxtResultDesc = self.Transform:Find("PanelScore/PanelResult/TxtResultDesc"):GetComponent("Text") + self.PanelQuestion = self.Transform:Find("PanelQuestion") + self.PanelA = self.Transform:Find("PanelQuestion/Panel") + self.PanelQue_1 = self.Transform:Find("PanelQuestion/Panel/PanelQue_1") + self.PanelQue_2 = self.Transform:Find("PanelQuestion/Panel/PanelQue_2") + self.PanelQue_3 = self.Transform:Find("PanelQuestion/Panel/PanelQue_3") + self.PanelPoolSmall = self.Transform:Find("PanelQuestion/PanelPoolSmall") + self.PanelAnswer = self.Transform:Find("PanelAnswer") + self.PanelLayout = self.Transform:Find("PanelAnswer/PanelLayout") + self.PanelAnsPool = self.Transform:Find("PanelAnswer/PanelAnsPool") + self.PanelTime = self.Transform:Find("PanelTime") + self.SliderTime = self.Transform:Find("PanelTime/SliderTime"):GetComponent("Slider") + self.PanelReady = self.Transform:Find("PanelReady") + self.TxtCountDown = self.Transform:Find("PanelReady/TxtCountDown"):GetComponent("Text") +end + +function XUiPanelGame:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelGame:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelGame:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelGame:AutoAddListener() +end +-- auto +return XUiPanelGame \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiComeAcross/XUiPanelStart.lua b/Resources/Scripts/XUi/XUiComeAcross/XUiPanelStart.lua new file mode 100644 index 00000000..9f1011c4 --- /dev/null +++ b/Resources/Scripts/XUi/XUiComeAcross/XUiPanelStart.lua @@ -0,0 +1,96 @@ +local XUiPanelStart = XClass(nil, "XUiPanelStart") + +local PanelState = { + START = 1, + END = 2 +} + +function XUiPanelStart:Ctor(ui, parent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Parent = parent + self:InitAutoScript() + self.State = PanelState.START +end + +function XUiPanelStart:SetupContent(data) + if not data then + return + end + self.State = PanelState.START + + self.Data = data + local character = data.Character + local gameType = data.GameConfig.Type + local gameTypeCfg = XComeAcrossConfig.GetComeAcrossTypeConfigById(gameType) + self.TxtSelect.text = gameTypeCfg.Title + self.TxtWords.text = gameTypeCfg.Desc + self.TxtName.text = XCharacterConfigs.GetCharacterName(character.Id) + self.Parent:SetUiSprite(self.ImgRole, XDataCenter.CharacterManager.GetCharHalfBodyBigImage(character.Id)) +end + + +function XUiPanelStart:SetupResult() + if not self.Data then + return + end + + self.State = PanelState.END + + local gameType = self.Data.GameConfig.Type + local gameTypeCfg = XComeAcrossConfig.GetComeAcrossTypeConfigById(gameType) + self.TxtSelect.text = gameTypeCfg.ResultTitle + self.TxtWords.text = gameTypeCfg.ResultDesc +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelStart:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiPanelStart:AutoInitUi() + self.ImgRole = self.Transform:Find("ImgRole"):GetComponent("Image") + self.Panelselectoption = self.Transform:Find("Panelselectoption") + self.BtnSelect = self.Transform:Find("Panelselectoption/GameObject/BtnSelect"):GetComponent("Button") + self.TxtSelect = self.Transform:Find("Panelselectoption/GameObject/BtnSelect/TxtSelect"):GetComponent("Text") + self.PanelDialog = self.Transform:Find("PanelDialog") + self.PanelText = self.Transform:Find("PanelDialog/PanelText") + self.ImgTxtWordBg = self.Transform:Find("PanelDialog/PanelText/ImgTxtWordBg"):GetComponent("Image") + self.TxtName = self.Transform:Find("PanelDialog/PanelText/TxtName"):GetComponent("Text") + self.TxtWords = self.Transform:Find("PanelDialog/PanelText/TxtWords"):GetComponent("Text") +end + +function XUiPanelStart:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelStart:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelStart:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelStart:AutoAddListener() + self:RegisterClickEvent(self.BtnSelect, self.OnBtnSelectClick) +end +-- auto +function XUiPanelStart:OnBtnSelectClick() + if self.State == PanelState.START then + self.Parent:OnBtnSelectClick() + elseif self.State == PanelState.END then + self.Parent:SetupReward() + end + + self.State = PanelState.START +end + +return XUiPanelStart \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiComeAcross/XUiPanelTick.lua b/Resources/Scripts/XUi/XUiComeAcross/XUiPanelTick.lua new file mode 100644 index 00000000..bbcebba1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiComeAcross/XUiPanelTick.lua @@ -0,0 +1,54 @@ +local XUiPanelTick = XClass(nil, "XUiPanelTick") + +function XUiPanelTick:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self:InitAutoScript() + self.ImgRight.gameObject:SetActive(false) + self.ImgWrong.gameObject:SetActive(false) +end + +function XUiPanelTick:SetResult(result) + self.ImgRight.gameObject:SetActive(result == 1) + self.ImgWrong.gameObject:SetActive(result == 0) +end + +function XUiPanelTick:Reset() + self.ImgRight.gameObject:SetActive(false) + self.ImgWrong.gameObject:SetActive(false) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelTick:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiPanelTick:AutoInitUi() + self.ImgRight = self.Transform:Find("ImgRight"):GetComponent("Image") + self.ImgWrong = self.Transform:Find("ImgWrong"):GetComponent("Image") +end + +function XUiPanelTick:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelTick:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelTick:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelTick:AutoAddListener() +end +-- auto + +return XUiPanelTick diff --git a/Resources/Scripts/XUi/XUiCommon/XScrollView/XScrollConfig.lua b/Resources/Scripts/XUi/XUiCommon/XScrollView/XScrollConfig.lua new file mode 100644 index 00000000..94d7c4e8 --- /dev/null +++ b/Resources/Scripts/XUi/XUiCommon/XScrollView/XScrollConfig.lua @@ -0,0 +1,29 @@ +XScrollConfig = XScrollConfig or {} + +XScrollConfig.HORIZONTAL = 0 +XScrollConfig.VERTICAL = 1 + +-- 位置曲线关键帧 +XScrollConfig.POSITION_KEY_FRAMES = { + {time = 0, value = 0, tangentMode = 34, inTangent = 0, outTangent = 0}, + {time = 0.1, value = 0, tangentMode = 34, inTangent = 0.625, outTangent = 0.625}, + {time = 0.5, value = 0.5, tangentMode = 34, inTangent = 1.25, outTangent = 1.25}, + {time = 0.9, value = 1, tangentMode = 34, inTangent = 0.625, outTangent = 0.625}, + {time = 1, value = 1, tangentMode = 34, inTangent = 0, outTangent = 0}, +} + +XScrollConfig.SCALE_KEY_FRAMES = { + {time = 0, value = 0, tangentMode = 34, inTangent = 1.8, outTangent = 1.8}, + {time = 0.5, value = 1, tangentMode = 34, inTangent = 0, outTangent = 0}, + {time = 1, value = 0, tangentMode = 34, inTangent = -1.8, outTangent = -1.8}, +} + +XScrollConfig.ALPHA_KEY_FRAMES = { + {time = 0, value = 0, tangentMode = 0, inTangent = 0, outTangent = 0}, + {time = 0.1, value = 0.3, tangentMode = 0, inTangent = 2.536, outTangent = 2.536}, + {time = 0.3, value = 0.6, tangentMode = 0, inTangent = 2.877, outTangent = 2.877}, + {time = 0.5, value = 1, tangentMode = 0, inTangent = 0.104, outTangent = 0.104}, + {time = 0.7, value = 0.6, tangentMode = 0, inTangent = -3.06, outTangent = -3.06}, + {time = 0.9, value = 0.3, tangentMode = 0, inTangent = -2.547, outTangent = -2.547}, + {time = 1, value = 0, tangentMode = 0, inTangent = 0, outTangent = 0}, +} \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCommon/XScrollView/XScrollFlow.lua b/Resources/Scripts/XUi/XUiCommon/XScrollView/XScrollFlow.lua new file mode 100644 index 00000000..873195f2 --- /dev/null +++ b/Resources/Scripts/XUi/XUiCommon/XScrollView/XScrollFlow.lua @@ -0,0 +1,93 @@ +XScrollFlowHelper = {} + +local EDGE_SCALE = 0.35 + +local ScrollFlowList = {} + +function XScrollFlowHelper.GetScrollFlow(uiName) + return ScrollFlowList[uiName] +end + +XScrollFlow = XClass(XScrollView, "XScrollFlow") + +function XScrollFlow:Ctor(rootUi, ui, scrollItems, paramsObj) + self.paramsObj = paramsObj + + ScrollFlowList[ui.name] = self +end + +function XScrollFlow:AddKeys(animationCurve, keys) + for i = 1, #keys do + local key = keys[i] + local keyframe = CS.UnityEngine.Keyframe() + for k, v in pairs(key) do + keyframe[k] = v + end + animationCurve:AddKey(keyframe) + end +end + +function XScrollFlow:InitAnimationCurve() + local AnimationCurve = CS.UnityEngine.AnimationCurve + self.PositionCurve = AnimationCurve() + self.ScaleCurve = AnimationCurve() + self.AlphaCurve = AnimationCurve() + + self:AddKeys(self.PositionCurve, XScrollConfig.POSITION_KEY_FRAMES) + self:AddKeys(self.ScaleCurve, XScrollConfig.SCALE_KEY_FRAMES) + self:AddKeys(self.AlphaCurve, XScrollConfig.ALPHA_KEY_FRAMES) +end + +function XScrollFlow:OnDrag(eventData) + self.AddVector = eventData.position - self.StartPoint + local addValue = eventData.delta.x * 1 / self.ContentSize.x + + if self.Direction == XScrollConfig.VERTICAL then + addValue = eventData.delta.y * 1 / self.ContentSize.y + end + + local count = #self.ScrollItems + if self.ScrollItems[1].CurveValue > (1 - EDGE_SCALE) or self.ScrollItems[count].CurveValue < EDGE_SCALE then + addValue = 0 + end + + for i = 1, #self.ScrollItems do + self.ScrollItems[i]:OnDrag(addValue) + end + -- self:AdjustScrollItems(addValue) +end + +function XScrollFlow:OnEndDrag() + local offset = 0 + local count = #self.ScrollItems + + if self.ScrollItems[1].CurveValue > 0.5 then + offset = 0.5 - self.ScrollItems[1].CurveValue + elseif self.ScrollItems[count].CurveValue < 0.5 then + offset = 0.5 - self.ScrollItems[count].CurveValue + else + for i = 1, count do + if self.ScrollItems[i].CurveValue >= self.MinBorder then -- 获取偏移量 + offset = self.OffsetValue / 2 + self.ScrollItems[i].CurveValue + offset = self.OffsetValue / 2 - (offset + self.OffsetValue / 2) % self.OffsetValue + break + end + end + end + self.AddVector = CS.UnityEngine.Vector3.zero + self:Anim2End(offset) +end + +function XScrollFlow:Evaluate(curveValue, transform) + local position = transform and transform.localPosition or CS.UnityEngine.Vector3.zero + if self.Direction == XScrollConfig.HORIZONTAL then + position.x = self.PositionCurve:Evaluate(curveValue) * self.ContentSize.x - self.ContentSize.x / 2 + else + position.y = self.PositionCurve:Evaluate(curveValue) * self.ContentSize.y - self.ContentSize.y / 2 + end + + local alpha = self.AlphaCurve:Evaluate(curveValue) + local scale = self.ScaleCurve:Evaluate(curveValue) + + return position, alpha, scale +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCommon/XScrollView/XScrollFlowGrid.lua b/Resources/Scripts/XUi/XUiCommon/XScrollView/XScrollFlowGrid.lua new file mode 100644 index 00000000..d7a6cf86 --- /dev/null +++ b/Resources/Scripts/XUi/XUiCommon/XScrollView/XScrollFlowGrid.lua @@ -0,0 +1,25 @@ +XScrollFlowGrid = XClass(XScrollGrid, "XScrollFlowGrid") + +function XScrollFlowGrid:Ctor() + self.CurveValue = 0 + self.Img = self.Transform:GetComponent("Image") +end + +function XScrollFlowGrid:OnDrag(addValue) + self.CurveValue = self.CurveValue + addValue + local position, alpha, scale = self.Parent:Evaluate(self.CurveValue, self.Transform) + local trans = self.Transform + + trans.localPosition = position + + if self.Img then + local color = self.Img.color + color.a = alpha + self.Img.color = color + end + + local localScale = trans.localScale + localScale.x = scale + localScale.y = scale + trans.localScale = localScale +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCommon/XUiBaseComponent.lua b/Resources/Scripts/XUi/XUiCommon/XUiBaseComponent.lua new file mode 100644 index 00000000..b6bdb1ca --- /dev/null +++ b/Resources/Scripts/XUi/XUiCommon/XUiBaseComponent.lua @@ -0,0 +1,20 @@ +XUiBaseComponent = XClass(nil, "XUiBaseComponent") + +function XUiBaseComponent:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) +end + +-- for override +function XUiBaseComponent:Refresh() +end + +function XUiBaseComponent:GetGameObject() + return self.GameObject +end + +function XUiBaseComponent:GetTransform() + return self.Transform +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCommon/XUiBaseView.lua b/Resources/Scripts/XUi/XUiCommon/XUiBaseView.lua new file mode 100644 index 00000000..bab84731 --- /dev/null +++ b/Resources/Scripts/XUi/XUiCommon/XUiBaseView.lua @@ -0,0 +1,86 @@ +XUiBaseView = XClass(XUiBaseComponent, "XUiBaseView") + +-- function XUiBaseView:Ctor(rootUi, ui) +-- end + +-- for override +function XUiBaseView:Show() + self.GameObject:SetActiveEx(true) + self:Refresh() +end + +-- for override +function XUiBaseView:Close() + self.GameObject:SetActiveEx(false) +end + +-- for override +function XUiBaseView:Refresh() +end + + +-- self:AddTemplate(self.GridCommon, self.PanelReward, XUiGridCommon) -- 封装继承XUiBaseComponent +-- self:UpdateTemplateList(self.GridCommon, datas) +--==== 创建模板列表 begin + +-- 设置模板对象 +function XUiBaseComponent:AddTemplate(templateGO, parent, component) + if XTool.UObjIsNil(templateGO) then + XLog.Error("模板对象设置失败,为nil") + return + end + self:_TryInitData() + if not self._TemplateComponentMap[templateGO] then + templateGO.gameObject:SetActiveEx(false) + self._TemplateComponentMap[templateGO] = component + self._TemplateParentMap[templateGO] = parent + self._TemplateList[templateGO] = {} + end +end + +-- 刷新模板对象列表 +function XUiBaseComponent:UpdateTemplateList(templateGO, dataList) + if not self._TemplateList[templateGO] or not self._TemplateParentMap[templateGO] then + XLog.Error("模板对象列表刷新失败,未初始化go或parent") + return + end + + -- 隐藏多余对象 + local list = self._TemplateList[templateGO] + local len = #dataList + if #list > len then + for i = len + 1, #list do + list[i].GameObject:SetActiveEx(false) + end + end + + -- 刷新列表对象 + for i, data in ipairs(dataList) do + local comp = self:_GetTemplateComponent(templateGO, i) + comp.GameObject:SetActiveEx(true) + comp:Refresh(data) + end +end + +function XUiBaseComponent:_TryInitData() + if not self._TemplateComponentMap then + self._TemplateComponentMap = {} + self._TemplateParentMap = {} + self._TemplateList = {} + end +end + +function XUiBaseComponent:_GetTemplateComponent(templateGO, index) + local list = self._TemplateList[templateGO] + local comp = list[index] + if not comp then + local parent = self._TemplateParentMap[templateGO] + local component = self._TemplateComponentMap[templateGO] + local go = CS.UnityEngine.Object.Instantiate(templateGO) + go.transform:SetParent(parent, false) + comp = component.New(go) + list[index] = comp + end + return comp +end +--==== 创建模板列表 end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCommon/XUiButtonLongClick.lua b/Resources/Scripts/XUi/XUiCommon/XUiButtonLongClick.lua new file mode 100644 index 00000000..f0462c21 --- /dev/null +++ b/Resources/Scripts/XUi/XUiCommon/XUiButtonLongClick.lua @@ -0,0 +1,150 @@ +XUiButtonLongClick = XClass(nil, "XUiButtonLongClick") + +-- AddPointerDownListener +-- AddPointerUpListener +-- AddPointerExitListener +-- AddPointerClickListener +-- AddDragListener +-- RemoveAllListeners +local LONG_CLICK_START_OFFSET = 0.5 + +function XUiButtonLongClick:Ctor(widget, interval, caller, clickCallback, longClickCallback, longClickUpCallback, isCanExit, proxy) + self.GameObject = widget.gameObject + self.Transform = widget.transform + self:SetInterval(interval) + self:SetTriggerOffset() + self.Caller = caller + self.Proxy = proxy + + if XTool.UObjIsNil(widget) then + XLog.Error("XUiButtonLongClick:Ctor error: widget is nil!") + return + end + + self.Widget = widget.gameObject:GetComponent("XUiPointer") + if not self.Widget then + widget.gameObject:AddComponent(typeof(CS.XUiPointer)) + self.Widget = widget.gameObject:GetComponent("XUiPointer") + end + + self.ClickCallbacks = {} + if clickCallback then + table.insert(self.ClickCallbacks, clickCallback) + end + self.LongClickCallback = {} + if longClickCallback then + table.insert(self.LongClickCallback, longClickCallback) + end + self.longClickUpCallbacks = {} + if longClickUpCallback then + table.insert(self.longClickUpCallbacks, longClickUpCallback) + end + self.Widget:AddPointerDownListener( + function(eventData) + self:OnDown(eventData) + end + ) + self.Widget:AddPointerExitListener( + function(eventData) + if isCanExit then + self:OnUp(eventData) + end + end + ) + self.Widget:AddPointerUpListener( + function(eventData) + self:OnUp(eventData) + end + ) +end + +function XUiButtonLongClick:OnDown(eventData) + if self.IsPressing then + return + end + self.PointerId = eventData.pointerId + self.IsPressing = true + self.frameCount = 0 + self.PressTime = 0 + self:RemoveTimer() + self.Timer = XScheduleManager.ScheduleForever( + function() self:Tick() end, + self.Interval + ) + self.DownTime = CS.UnityEngine.Time.time +end + +function XUiButtonLongClick:OnUp(eventData) + if eventData and eventData.pointerId ~= self.PointerId then + return + end + self.PointerId = -1 + self.IsPressing = false + self:RemoveTimer() + if self.DownTime and CS.UnityEngine.Time.time - self.DownTime < self.Offset then + for i = 1, #self.ClickCallbacks do + local callback = self.ClickCallbacks[i] + if callback then + callback(self.Caller) + end + end + end + + for i = 1, #self.longClickUpCallbacks do + local callback = self.longClickUpCallbacks[i] + if callback then + callback(self.Caller) + end + end +end + +function XUiButtonLongClick:SetInterval(interval) + if interval == nil or interval < 0 then + self.Interval = 100 + else + self.Interval = interval + end +end + +function XUiButtonLongClick:SetTriggerOffset(offset) + if offset == nil or offset < 0 then + self.Offset = LONG_CLICK_START_OFFSET + else + self.Offset = offset + end +end + +function XUiButtonLongClick:Tick() + if not self.GameObject:Exist() or not self.GameObject.activeSelf or not self.GameObject.activeInHierarchy then + self:OnUp() + return + end + self.PressTime = self.PressTime + self.Interval + local pressingTime = self.PressTime - self.Offset + if pressingTime > 0 then + for i = 1, #self.LongClickCallback do + local callback = self.LongClickCallback[i] + if callback then + callback(self.Caller, pressingTime, self, self.Proxy) + end + end + end +end + +function XUiButtonLongClick:Reset() + self.PointerId = -1 + self.IsPressing = false + self:RemoveTimer() +end + +function XUiButtonLongClick:RemoveTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end + +function XUiButtonLongClick:Destroy() + self:Reset() + self.Widget:RemoveAllListeners() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCommon/XUiCommonAsset.lua b/Resources/Scripts/XUi/XUiCommon/XUiCommonAsset.lua new file mode 100644 index 00000000..69a4f993 --- /dev/null +++ b/Resources/Scripts/XUi/XUiCommon/XUiCommonAsset.lua @@ -0,0 +1,88 @@ +-- 通用道具显示按钮控件 +local XUiCommonAsset = XClass(nil, "XUiCommonAsset") + +XUiCommonAsset.ShowType = { + BagItem = 1, -- 填入Item表的道具 + BagPoint = 2, -- 填入Item表的数值道具(如体力),显示格式为 "当前值/最大值" + RecoverPoint = 3, -- 不填入Item表的数值道具(如体力),显示格式为 "当前值/最大值" + UniqueItem = 4, -- 不填入Item表的道具,各个功能使用自己专有的道具时可使用 + } + +local TypeName = { + [1] = "BagItem", + [2] = "BagPoint", + [3] = "RecoverPoint", + [4] = "UniqueItem" + } + +function XUiCommonAsset:Ctor(ui, assetData) + XTool.InitUiObjectByUi(self, ui) + self:SetData(assetData) +end + +function XUiCommonAsset:SetData(assetData) + if not assetData then + self.GameObject:SetActiveEx(false) + return + end + self.AssetData = assetData + self.GameObject:SetActiveEx(true) + local typeName = TypeName[self.AssetData.ShowType] + if typeName and self["Set" .. typeName .. "Data"] then + self["Set" .. typeName .. "Data"](self) + end +end + +function XUiCommonAsset:SetBagItemData() + local item = XDataCenter.ItemManager.GetItem(self.AssetData.ItemId) + self.ImgIcon:SetRawImage(item.Template.Icon) + self:RefreshTextByItemCount(XDataCenter.ItemManager.GetCount(self.AssetData.ItemId)) + XDataCenter.ItemManager.AddCountUpdateListener( + self.AssetData.ItemId, + function() + self:RefreshTextByItemCount(XDataCenter.ItemManager.GetCount(self.AssetData.ItemId)) + end, + self + ) + self.BtnDetail.gameObject:SetActiveEx(true) + self.BtnDetail.CallBack = function() self:OnBtnDetailClickByBagItem() end +end + +function XUiCommonAsset:SetRecoverPointData() + if self.AssetData.Icon then + self.ImgIcon:SetRawImage(self.AssetData.Icon) + self.ImgIcon.gameObject:SetActiveEx(true) + else + self.ImgIcon.gameObject:SetActiveEx(false) + end + self:RefreshTextByPoint(self.AssetData.GetCountFunc(), self.AssetData.GetMaxCountFunc()) + XEventManager.BindEvent(self.GameObject, self.AssetData.ChangeEventId, + function() + self:RefreshTextByPoint(self.AssetData.GetCountFunc(), self.AssetData.GetMaxCountFunc()) + end + ) + self.BtnDetail.gameObject:SetActiveEx(self.AssetData.OnClick ~= nil) + self.BtnDetail.CallBack = function() self:OnBtnDetailClickByUniqueItem() end +end + +function XUiCommonAsset:RefreshTextByItemCount(itemCount) + self.TxtCount.text = itemCount +end + +function XUiCommonAsset:RefreshTextByPoint(itemCount, maxCount) + self.TxtCount.text = itemCount .. "/" .. maxCount +end + +function XUiCommonAsset:OnBtnDetailClickByBagItem() + XLuaUiManager.Open("UiTip", self.AssetData.ItemId, true, nil) +end + +function XUiCommonAsset:OnBtnDetailClickByUniqueItem() + if self.AssetData.OnClick then + self.AssetData.OnClick() + else + return + end +end + +return XUiCommonAsset \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCommon/XUiCommonAssetPanel.lua b/Resources/Scripts/XUi/XUiCommon/XUiCommonAssetPanel.lua new file mode 100644 index 00000000..27b16601 --- /dev/null +++ b/Resources/Scripts/XUi/XUiCommon/XUiCommonAssetPanel.lua @@ -0,0 +1,19 @@ +-- 通用道具显示按钮面板控件 +local XUiCommonAssetPanel = XClass(nil, "XUiCommonAsset") +local CommonAsset = require("XUi/XUiCommon/XUiCommonAsset") +local InitAssetsList = function(panel, assetDataList) + local i = 1 + while true do + local assetUi = panel["PanelTool" .. i] + if not assetUi then + break + end + CommonAsset.New(assetUi, assetDataList[i]) + i = i + 1 + end +end +function XUiCommonAssetPanel:Ctor(ui, assetDataList) + XTool.InitUiObjectByUi(self, ui) + InitAssetsList(self, assetDataList) +end +return XUiCommonAssetPanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCommon/XUiCommonEnum.lua b/Resources/Scripts/XUi/XUiCommon/XUiCommonEnum.lua new file mode 100644 index 00000000..816041c8 --- /dev/null +++ b/Resources/Scripts/XUi/XUiCommon/XUiCommonEnum.lua @@ -0,0 +1,35 @@ +XUiButtonState = { + Normal = 0, + Press = 1, + Select = 2, + Disable = 3, +} + +XUiFightControlState = { + Normal = 0, + Hard = 1, + Ex = 2, +} + +XUiAppearanceShowType = { + ToAll = 1, + ToFriend = 2, + ToSelf = 3, +} + +XUiToggleState = { + Off = 0, + On = 1, +} + +XUiCompareType = { + Equal = 1, --等于 + NoLess = 2, --大于等于 +} + +XUiMainChargeState = { + None = 0, --初始状态 + Enough = 1, --电量充足 + LowPower = 2, --电量不足 + Charge = 3, --充电中 +} \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCommon/XUiDynamicTable/XDynamicTableCurve.lua b/Resources/Scripts/XUi/XUiCommon/XUiDynamicTable/XDynamicTableCurve.lua new file mode 100644 index 00000000..6e2e92ce --- /dev/null +++ b/Resources/Scripts/XUi/XUiCommon/XUiDynamicTable/XDynamicTableCurve.lua @@ -0,0 +1,218 @@ +XDynamicTableCurve = {} + +function XDynamicTableCurve.New(gameObject) + if gameObject == nil then + return nil + end + + local dynamicTable = {} + setmetatable(dynamicTable, { __index = XDynamicTableCurve }) + + local imp = dynamicTable:Init(gameObject) + + if not imp then + return nil + end + + return dynamicTable +end + +--初始化 +function XDynamicTableCurve:Init(gameObject) + local imp = gameObject:GetComponent(typeof(CS.XDynamicTableCurve)) + if not imp then + return false + end + + self.Proxy = nil + self.ProxyMap = {} + self.ProxyImpMap = {} + self.DataSource = {} + self.DynamicEventDelegate = nil + + self.Imp = imp + self.Imp.DynamicTableGridDelegate = function(event, index, grid) + self:OnDynamicTableEvent(event, index, grid) + end + + return true +end + +--获取实体组件 +function XDynamicTableCurve:GetImpl() + return self.Imp +end + + +--设置回调主体 +function XDynamicTableCurve:SetDelegate(delegate) + if not self.Imp then + return + end + + -- self.Imp:SetDelegate(self) + self.Delegate = delegate +end + + +--事件回调 +function XDynamicTableCurve:OnDynamicTableEvent(event, index, grid) + + if not self.Proxy then + XLog.Warning("XDynamicTableCurve Proxy is nil,Please Setup First!!") + return + end + + if not self.Delegate then + XLog.Warning("XDynamicTableCurve Delegate is nil,Please Setup First!!") + return + end + + if not self.Delegate.OnDynamicTableEvent then + XLog.Warning("XDynamicTableCurve Delegate func OnDynamicTableEvent is nil,Please Setup First!!") + return + end + + --使用代理器,Lua代理器是一个 Table,IL使用C#脚本 + local proxy = nil + if grid ~= nil then + proxy = self.ProxyMap[grid] + if not proxy then + proxy = self.Proxy.New(grid) + self.ProxyMap[grid] = proxy + --初始化只调动一次 + proxy.Index = index + proxy.DynamicGrid = grid + + if self.DynamicEventDelegate then + self.DynamicEventDelegate(DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT, index, proxy) + else + self.Delegate.OnDynamicTableEvent(self.Delegate, DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT, index, proxy) + end + + end + end + + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + proxy.Index = index + proxy.DynamicGrid = grid + self.ProxyImpMap[index] = proxy + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_RECYCLE then + proxy.Index = -1 + proxy.DynamicGrid = nil + self.ProxyImpMap[index] = nil + end + + if self.DynamicEventDelegate then + self.DynamicEventDelegate(event, index, proxy) + else + self.Delegate.OnDynamicTableEvent(self.Delegate, event, index, proxy) + end +end + + +--设置事件回调 +function XDynamicTableCurve:SetDynamicEventDelegate(fun) + self.DynamicEventDelegate = fun +end + +--设置代理器 +function XDynamicTableCurve:SetProxy(proxy) + self.ProxyMap = {} + self.ProxyImpMap = {} + self.Proxy = proxy +end + +--设置总数 +function XDynamicTableCurve:SetTotalCount(totalCout) + if not self.Imp then + return + end + + self.Imp.TotalCount = totalCout +end + +--设置总数 +function XDynamicTableCurve:SetDataSource(datas) + if not datas or not self.Imp then + return + end + + self.DataSource = datas + self.Imp.TotalCount = #self.DataSource +end + +--获取代理器 +function XDynamicTableCurve:GetGridByIndex(index) + return self.ProxyImpMap[index] +end + +--获取所有代理器 +function XDynamicTableCurve:GetGrids() + return self.ProxyImpMap +end + +--设置可视区域 +function XDynamicTableCurve:SetViewSize(viewSize) + if not self.Imp then + return + end + + self.Imp:SetViewSize(viewSize) +end + + +--重载数据 +function XDynamicTableCurve:ReloadData(startIndex) + startIndex = startIndex or -1 + if not self.Imp then + return + end + + + self.Imp:ReloadData(startIndex) +end + + +--回收所有节点 +function XDynamicTableCurve:RecycleAllTableGrid() + if not self.Imp then + return + end + + self.Imp:RecycleAllTableGrid() +end + +--清空节点 +function XDynamicTableCurve:Clear() + if not self.Imp then + return + end + + self.Imp:Clear() +end + +--设置节点大小 +function XDynamicTableCurve:SetGridSize(GridSize) + if not self.Imp then + return + end + + self.Imp.OriginGridSize = GridSize +end + +function XDynamicTableCurve:GetGridSize() + return self.Imp and self.Imp.GridSize +end + +-- 跳转到指定节点 +function XDynamicTableCurve:TweenToIndex(index) + if not self.Imp then + return + end + + self.Imp:TweenToIndex(index) +end + +--todo 其他布局接口这里暂时不一一实现,因为布局属性在编辑阶段已经设置过 +return XDynamicTableCurve \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCommon/XUiDynamicTable/XDynamicTableIrregular.lua b/Resources/Scripts/XUi/XUiCommon/XUiDynamicTable/XDynamicTableIrregular.lua new file mode 100644 index 00000000..9e06b6b1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiCommon/XUiDynamicTable/XDynamicTableIrregular.lua @@ -0,0 +1,229 @@ +XDynamicTableIrregular = {} + +function XDynamicTableIrregular.New(gameObject) + if gameObject == nil then + XLog.Error("XDynamicTableIrregular.New->gameObject == nil, Please check the object is instancing") + return nil + end + + local dynamicTable = {} + setmetatable(dynamicTable, { __index = XDynamicTableIrregular }) + + local imp = dynamicTable:Init(gameObject) + + if not imp then + XLog.Error("XDynamicTableIrregular.New->can not find the object imp, Please check the Component type is right!") + return nil + end + + return dynamicTable +end + +--初始化 +function XDynamicTableIrregular:Init(gameObject) + local imp = gameObject:GetComponent(typeof(CS.XDynamicTableIrregular)) + if not imp then + return false + end + + self.Proxy = nil + self.ProxyMap = {} + self.ProxyImpMap = {} + self.DataSource = {} + self.DynamicEventDelegate = nil + + self.Imp = imp + self.Imp:SetViewSize(imp.rectTransform.rect.size) + self.Imp.DynamicTableGridDelegate = function(event, index, grid) + self:OnDynamicTableEvent(event, index, grid) + end + + return true +end + +--事件回调 +function XDynamicTableIrregular:OnDynamicTableEvent(event, index) + + if not self.Proxy then + XLog.Warning("XDynamicTableIrregular Proxy is nil,Please Setup First!!") + return + end + + if not self.Delegate then + XLog.Warning("XDynamicTableIrregular Delegate is nil,Please Setup First!!") + return + end + + if not self.Delegate.OnDynamicTableEvent and not self.DynamicEventDelegate then + XLog.Warning("XDynamicTableIrregular Delegate func OnDynamicTableEvent is nil,Please Setup First!!") + return + end + + if not self.Delegate.GetProxyType then + XLog.Warning("XDynamicTableIrregular Delegate func GetProxyType is nil,Please Setup First!!") + return + end + + --获取当前代理的类型 + local proxy = self:GetGridByIndex(index) + + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + + local proxyType = self.Delegate:GetProxyType(index) + local grid = self.Imp:PreDequeueGrid(proxyType, index) + + if not self.Proxy[proxyType] then + XLog.Error(string.format("XDynamicTableIrregular Proxy Type: %s not exist,Please Setup First!!", proxyType)) + return + end + + --使用代理器,Lua代理器是一个 Table,IL使用C#脚本 + if grid ~= nil then + proxy = self.ProxyMap[grid] + if not proxy then + proxy = self.Proxy[proxyType].New(grid) + self.ProxyMap[grid] = proxy + --初始化只调动一次 + proxy.Index = index + proxy.DynamicGrid = grid + + if self.DynamicEventDelegate then + self.DynamicEventDelegate(DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT, index, proxy) + else + self.Delegate:OnDynamicTableEvent(DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT, index, proxy) + end + + end + end + + proxy.Index = index + proxy.DynamicGrid = grid + self.ProxyImpMap[index] = proxy + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_RECYCLE then + proxy.Index = -1 + proxy.DynamicGrid = nil + self.ProxyImpMap[index] = nil + end + if self.DynamicEventDelegate then + self.DynamicEventDelegate(event, index, proxy) + else + self.Delegate:OnDynamicTableEvent(event, index, proxy) + end + +end + +--回收所有节点 +function XDynamicTableIrregular:RecycleAllTableGrid() + if not self.Imp then + return + end + + self.Imp:RecycleAllGrids() +end + + +--获取实体组件 +function XDynamicTableIrregular:GetImpl() + return self.Imp +end + + +--设置回调主体 +function XDynamicTableIrregular:SetDelegate(delegate) + if not self.Imp then + return + end + + self.Delegate = delegate +end + +--设置事件回调 +function XDynamicTableIrregular:SetDynamicEventDelegate(fun) + self.DynamicEventDelegate = fun +end + +--设置代理器 +function XDynamicTableIrregular:SetProxy(proxyType, proxy, prefab) + if not self.Imp or not self.Imp.ObjectPool then + return + end + + self.Proxy = self.Proxy or {} + self.Proxy[proxyType] = proxy + self.Imp.ObjectPool:Add(proxyType, prefab) +end + +--设置总数 +function XDynamicTableIrregular:SetTotalCount(totalCout) + if not self.Imp then + return + end + + self.Imp.TotalCount = totalCout +end + +--设置总数 +function XDynamicTableIrregular:SetDataSource(datas) + if not datas or not self.Imp then + return + end + + self.DataSource = datas + local count = #self.DataSource + self.IndexForceReset = self.TotalCount and count < self.TotalCount + self.TotalCount = count + self.Imp.TotalCount = count +end + +--获取代理器 +function XDynamicTableIrregular:GetGridByIndex(index) + return self.ProxyImpMap[index] +end + +--设置可视区域 +function XDynamicTableIrregular:SetViewSize(viewSize) + if not self.Imp then + return + end + + self.Imp:SetViewSize(viewSize) +end + +--同步重载数据 +function XDynamicTableIrregular:ReloadDataSync(startIndex) + startIndex = startIndex or -1 + -- 当更换数据源并且总数更少时,将startIndex置为1,避免触发越界atindex的事件 + startIndex = self.IndexForceReset and 1 or startIndex + self.IndexForceReset = false + if not self.Imp then + return + end + + self.Imp:ReloadDataSync(startIndex) +end + +--异步重载数据 +function XDynamicTableIrregular:ReloadDataASync(startIndex) + startIndex = startIndex or -1 + -- 当更换数据源并且总数更少时,将startIndex置为1,避免触发越界atindex的事件 + startIndex = self.IndexForceReset and 1 or startIndex + self.IndexForceReset = false + if not self.Imp then + return + end + + self.Imp:ReloadDataAsync(startIndex) +end + + +--清空节点 +function XDynamicTableIrregular:Clear() + if not self.Imp then + return + end + + self.Imp:Clear() +end + +--todo 其他布局接口这里暂时不一一实现,因为布局属性在编辑阶段已经设置过 +return XDynamicTableIrregular \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCommon/XUiDynamicTable/XDynamicTableNormal.lua b/Resources/Scripts/XUi/XUiCommon/XUiDynamicTable/XDynamicTableNormal.lua new file mode 100644 index 00000000..c39c86b0 --- /dev/null +++ b/Resources/Scripts/XUi/XUiCommon/XUiDynamicTable/XDynamicTableNormal.lua @@ -0,0 +1,305 @@ +XDynamicTableNormal = {} + +DYNAMIC_DELEGATE_EVENT = { + DYNAMIC_GRID_RELOAD_COMPLETED = 1,--加载完成 + DYNAMIC_GRID_TOUCHED = 2,--点击 + DYNAMIC_GRID_ATINDEX = 3,--更新 + DYNAMIC_GRID_RECYCLE = 4,--回收 + DYNAMIC_TWEEN_OVER = 5, + DYNAMIC_BEGIN_DRAG = 6, + + DYNAMIC_GRID_INIT = 100 +} + +function XDynamicTableNormal.New(gameObject) + if gameObject == nil then + XLog.Error("XDynamicTableNormal.New->gameObject == nil, Please check the object is instancing") + return nil + end + + local dynamicTable = {} + setmetatable(dynamicTable, { __index = XDynamicTableNormal }) + + local imp = dynamicTable:Init(gameObject) + + if not imp then + XLog.Error("XDynamicTableIrregular.New->can not find the object imp, Please check the Component type is right!") + return nil + end + + return dynamicTable +end + +--初始化 +function XDynamicTableNormal:Init(gameObject) + local imp = gameObject:GetComponent(typeof(CS.XDynamicTableNormal)) + if not imp then + return false + end + + self.Proxy = nil + self.ProxyMap = {} + self.ProxyImpMap = {} + self.DataSource = {} + self.DynamicEventDelegate = nil + + self.Imp = imp + self.Imp:SetViewSize(imp.ScrRect.viewport.rect.size) + self.Imp.DynamicTableGridDelegate = function(event, index, grid) + self:OnDynamicTableEvent(event, index, grid) + end + + return true +end + +--获取实体组件 +function XDynamicTableNormal:GetImpl() + return self.Imp +end + + +--设置回调主体 +function XDynamicTableNormal:SetDelegate(delegate) + if not self.Imp then + return + end + + self.Imp:SetDelegate(self) + self.Delegate = delegate +end + + +--事件回调 +function XDynamicTableNormal:OnDynamicTableEvent(event, index, grid) + + if not self.Proxy then + XLog.Warning("XDynamicTableNormal Proxy is nil,Please Setup First!!") + return + end + + if not self.Delegate then + XLog.Warning("XDynamicTableNormal Delegate is nil,Please Setup First!!") + return + end + + if not self.Delegate.OnDynamicTableEvent and not self.DynamicEventDelegate then + XLog.Warning("XDynamicTableNormal Delegate func OnDynamicTableEvent is nil,Please Setup First!!") + return + end + + --使用代理器,Lua代理器是一个 Table,IL使用C#脚本 + local proxy = nil + if grid ~= nil then + proxy = self.ProxyMap[grid] + if not proxy then + proxy = self.Proxy.New(grid, table.unpack(self.ProxyArgs)) + self.ProxyMap[grid] = proxy + --初始化只调动一次 + proxy.Index = index + proxy.DynamicGrid = grid + + if self.DynamicEventDelegate then + self.DynamicEventDelegate(DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT, index, proxy) + else + self.Delegate.OnDynamicTableEvent(self.Delegate, DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT, index, proxy) + end + + end + end + + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + proxy.Index = index + proxy.DynamicGrid = grid + self.ProxyImpMap[index] = proxy + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_RECYCLE then + proxy.Index = -1 + proxy.DynamicGrid = nil + self.ProxyImpMap[index] = nil + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_RELOAD_COMPLETED then + XEventManager.DispatchEvent(XEventId.EVENT_GUIDE_STEP_OPEN_EVENT, self.Imp.name) + end + + if self.DynamicEventDelegate then + self.DynamicEventDelegate(event, index, proxy) + else + self.Delegate.OnDynamicTableEvent(self.Delegate, event, index, proxy) + end +end + + +--设置事件回调 +function XDynamicTableNormal:SetDynamicEventDelegate(fun) + self.DynamicEventDelegate = fun +end + +--设置代理器 +function XDynamicTableNormal:SetProxy(proxy, ...) + self.ProxyMap = {} + self.ProxyImpMap = {} + self.Proxy = proxy + self.ProxyArgs = {...} +end + +--设置总数 +function XDynamicTableNormal:SetTotalCount(totalCout) + if not self.Imp then + return + end + + self.Imp:SetTotalCount(totalCout) +end + +--设置总数 +function XDynamicTableNormal:SetDataSource(datas) + if not datas or not self.Imp then + return + end + + self.DataSource = datas + self.Imp:SetTotalCount(#self.DataSource) +end + +--获取代理器 +function XDynamicTableNormal:GetGridByIndex(index) + return self.ProxyImpMap[index] +end + +--获取所有代理器 +function XDynamicTableNormal:GetGrids() + return self.ProxyImpMap +end + +--设置可视区域 +function XDynamicTableNormal:SetViewSize(viewSize) + if not self.Imp then + return + end + + self.Imp:SetViewSize(viewSize) +end + +--刷新可视区域 +function XDynamicTableNormal:UpdateViewSize() + if not self.Imp then + return + end + + self.Imp:SetViewSize(self.Imp.rectTransform.rect.size) +end + +--同步重载数据 +function XDynamicTableNormal:ReloadDataSync(startIndex, forceReload) + startIndex = startIndex or -1 + if not self.Imp then + return + end + + if forceReload == nil then + forceReload = true + end + + self.Imp:ReloadDataSync(startIndex, forceReload) +end + +--异步重载数据 +function XDynamicTableNormal:ReloadDataASync(startIndex, forceReload) + startIndex = startIndex or -1 + if not self.Imp then + return + end + + if forceReload == nil then + forceReload = true + end + + self.Imp:ReloadDataAsync(startIndex, forceReload) +end + +--是否异步加载中 +function XDynamicTableNormal:IsAsyncLoading() + return self.Imp.IsAsyncLoading and true or false +end + +--回收所有节点 +function XDynamicTableNormal:RecycleAllTableGrid() + if not self.Imp then + return + end + + self.Imp:RecycleAllTableGrid() +end + +--清空节点 +function XDynamicTableNormal:Clear() + if not self.Imp then + return + end + + self.Imp:Clear() +end + +--设置节点大小 +function XDynamicTableNormal:SetGridSize(GridSize) + if not self.Imp then + return + end + + self.Imp.OriginGridSize = GridSize +end + +function XDynamicTableNormal:GetGridSize() + return self.Imp and self.Imp.GridSize +end + +function XDynamicTableNormal:CenterToSelected(gameObject,time,cb) + if not self.Imp then + return + end + self.Imp:CenterToSelected(gameObject,time,cb) +end + +function XDynamicTableNormal:GuideGetDynamicTableIndex(key, id) + if not self.DataSource then + return -1 + end + + if (not key or key == "") then + return self.Delegate:GuideGetDynamicTableIndex(id) + end + + + for i, v in ipairs(self.DataSource) do + if (type(v) ~= "table" and tostring(v) == id) or (type(v) == "table" and tostring(v[key]) == id) then + return i + end + end + + + XLog.Error("Can not find key:" .. key .. " Value:" .. tostring(id) .. " in DataSource ") + + return -1 +end + +function XDynamicTableNormal:SetPadding(left,right,top,bottom) + if not self.Imp then + return + end + self.Imp.Padding.left = left or self.Imp.Padding.left + self.Imp.Padding.right = right or self.Imp.Padding.right + self.Imp.Padding.top = top or self.Imp.Padding.top + self.Imp.Padding.bottom = bottom or self.Imp.Padding.bottom +end + +function XDynamicTableNormal:Freeze() + if not self.Imp then + return + end + self.Imp:Freeze() +end + +function XDynamicTableNormal:SetGrid(grid) + self.Imp.Grid = grid +end + +--todo 其他布局接口这里暂时不一一实现,因为布局属性在编辑阶段已经设置过 +return XDynamicTableNormal \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCommon/XUiMultClickHelper.lua b/Resources/Scripts/XUi/XUiCommon/XUiMultClickHelper.lua new file mode 100644 index 00000000..dd7241d2 --- /dev/null +++ b/Resources/Scripts/XUi/XUiCommon/XUiMultClickHelper.lua @@ -0,0 +1,113 @@ +local XUiMultClickHelper = {} + +local MultClickState = { + NORMAL = 0, + CLICKING = 1, + COOLING = 2 +} + +function XUiMultClickHelper.New(delegate, interval, maxClickLimit) + local helper = {} + + --初始化 + function helper:Init(tmpDelegate, tmpInterval, tmpMaxClickLimit) + self.Delegate = tmpDelegate + self.Interval = tmpInterval --点击间隔 + self.LastClickTime = -1 -- 上次的点击时间 + self.LastFinishTime = -1 + self.ClickTimes = 0 --当前点击次数 + self.ClickTimesLimit = tmpMaxClickLimit --点击次数限制 + self.CoolTime = 0 --冷却时间秒 + self.Status = MultClickState.NORMAL + self.Time = 0 + end + + --点击 + function helper:Click() + if self.Status == MultClickState.COOLING then + return + end + + if self.ClickTimesLimit <= self.ClickTimes then + return + end + + self.LastClickTime = self.Time + self.ClickTimes = self.ClickTimes + 1 + + self.Status = MultClickState.CLICKING + end + + --更新 + function helper:Update(deltaTime) + self.Time = self.Time + deltaTime + + if not self:IsActive() then + return + end + + if self.Status == MultClickState.NORMAL then + return + end + + + --如果是CD中 + if self.Status == MultClickState.COOLING and self.Time < self.LastFinishTime + self.CoolTime then + return + end + + --CD完 + if self.Status ~= MultClickState.CLICKING then + self:Reset() + end + + if self.Status == MultClickState.CLICKING and self.Time >= self.LastClickTime + self.Interval then + self:OnFinishMultClick() + end + + end + + --完成回调 + function helper:OnFinishMultClick() + if self.Delegate and self.ClickTimes > 0 then + self.Delegate:OnMultClick(self.ClickTimes) + end + + self.LastClickTime = -1 -- 上次的点击时间 + self.ClickTimes = 0 + self.Status = MultClickState.COOLING + + self.LastFinishTime = self.Time + end + + --重置 + function helper:Reset() + self.LastClickTime = -1 -- 上次的点击时间 + self.ClickTimes = 0 + self.Status = MultClickState.NORMAL + end + + + ---生命周期---------------------------------------------- + function helper:IsActive() + return self.Active + end + + function helper:OnEnable() + self.Active = true + end + + function helper:OnDisable() + self.Active = false + end + + function helper:OnDestroy() + self.Delegate = nil + end + + helper:Init(delegate, interval, maxClickLimit) + + return helper +end + +return XUiMultClickHelper \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCommon/XUiNewRoomFightControl.lua b/Resources/Scripts/XUi/XUiCommon/XUiNewRoomFightControl.lua new file mode 100644 index 00000000..9f1429a8 --- /dev/null +++ b/Resources/Scripts/XUi/XUiCommon/XUiNewRoomFightControl.lua @@ -0,0 +1,171 @@ +XUiNewRoomFightControl = XClass(nil, "XUiNewRoomFightControl") + +local WarningLevel = { + NoWarning = 1, -- 没有警告 + Warning = 2, -- 困难 + Danger = 3 -- 极度危险 + } +--战力限制组件 +function XUiNewRoomFightControl:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiNewRoomFightControl:UpdateByTextAndWarningLevel(warningLevel, controlName, recommendNum, curNumText) + self.BtnTishen.gameObject:SetActiveEx(false) + if warningLevel == WarningLevel.NoWarning then + self.GameObject:SetActiveEx(false) + return + end + self.GameObject:SetActiveEx(true) + self.Normal.gameObject:SetActiveEx(false) + self.Ex.gameObject:SetActiveEx(warningLevel == WarningLevel.Danger) + self.Hard.gameObject:SetActiveEx(warningLevel == WarningLevel.Warning) + if warningLevel == WarningLevel.Warning then + self.TxtHardControlName.text = controlName + self.TxtHardMaxFight.text = recommendNum + self.TxtHardCurFight.text = curNumText + elseif warningLevel == WarningLevel.Danger then + self.TxtExControlName.text = controlName + self.TxtExMaxFight.text = recommendNum + self.TxtExCurFight.text = curNumText + end + return +end + +function XUiNewRoomFightControl:UpdateInfo(stageFightControlId, teamAbility, condition, stageId, teamData) + self.TeamData = teamData + self.StageId = stageId + self.StageFightControlId = stageFightControlId + self.TeamAbility = teamAbility + self.GameObject:SetActiveEx(true) + self.Ex.gameObject:SetActiveEx(false) + self.Hard.gameObject:SetActiveEx(false) + self.Normal.gameObject:SetActiveEx(false) + self.BtnTishen.gameObject:SetActiveEx(false) + self.BtnTishen.CallBack = function() self:OnBtnTishen() end + self.Result = XUiFightControlState.Normal + local data = XFubenConfigs.GetStageFightControl(self.StageFightControlId) + if data == nil then + return + end + local showAbility = 0 + local charlist = XDataCenter.CharacterManager.GetCharacterList() + local dis + local recommendFight + local showFight + --平均战力有几个人不满足 + local avgCount + --上阵了几个人(用于判断一个人都没上的情况) + local teamCount = 0 + for _, v in pairs(self.TeamAbility) do + if v > 0 then + teamCount = teamCount + 1 + end + end + --最高战力,找出战力最高的 + if data.MaxRecommendFight > 0 then + dis = CS.XTextManager.GetText("MaxRecommendFight") + for _, v in pairs(self.TeamAbility) do + if v and v > showAbility then + showAbility = v + end + end + showAbility = math.floor(showAbility) + recommendFight = data.MaxRecommendFight + showFight = data.MaxShowFight + --平均战力(找出有几个低于AvgShowFight,找出最低的那个计算危险程度) + elseif data.AvgRecommendFight > 0 then + dis = CS.XTextManager.GetText("AvgRecommendFight") + local count = 0 + local noPlayer = true + local minAbility = 99999 + for _, v in pairs(self.TeamAbility) do + if v > 0 then + noPlayer = false + if v < data.AvgShowFight then + count = count + 1 + end + if v < minAbility then + minAbility = v + end + end + end + avgCount = count + if noPlayer then + showAbility = 0 + elseif count == 0 then + showAbility = data.AvgShowFight + else + showAbility = minAbility + end + recommendFight = data.AvgRecommendFight + showFight = data.AvgShowFight + --显示推荐战力,找出最高战力 + elseif data.RecommendFight > 0 then + dis = CS.XTextManager.GetText("RecommendFight") + for _, v in pairs(charlist) do + if v.Ability and v.Ability > showAbility then + showAbility = v.Ability + end + end + showAbility = math.floor(showAbility) + recommendFight = data.RecommendFight + showFight = data.ShowFight + end + + self.TxtNormalControlName.text = dis + self.TxtHardControlName.text = dis + self.TxtExControlName.text = dis + if condition then--不满足条件直接极度困难 + --极度困难 + if showAbility < recommendFight then + self.Ex.gameObject:SetActiveEx(true) + self.BtnTishen.gameObject:SetActiveEx(teamCount > 0) + if data.MaxRecommendFight > 0 then + self.TxtExCurFight.text = CS.XTextManager.GetText("MaxCurRecommendFight", showAbility) + elseif data.AvgRecommendFight > 0 then + if teamCount > 0 then + self.TxtExCurFight.text = CS.XTextManager.GetText("AvgCurRecommendFight", avgCount) + else + self.TxtExCurFight.text = CS.XTextManager.GetText("FightConditionError") + end + elseif data.RecommendFight > 0 then + self.TxtExCurFight.text = CS.XTextManager.GetText("MaxCurRecommendFight", showAbility) + end + self.TxtExMaxFight.text = showFight + self.Result = XUiFightControlState.Ex + --困难 + elseif showAbility >= recommendFight and showAbility < showFight then + self.Hard.gameObject:SetActiveEx(true) + self.BtnTishen.gameObject:SetActiveEx(teamCount > 0) + if data.MaxRecommendFight > 0 then + self.TxtHardCurFight.text = CS.XTextManager.GetText("MaxCurRecommendFight", showAbility) + elseif data.AvgRecommendFight > 0 then + if teamCount > 0 then + self.TxtHardCurFight.text = CS.XTextManager.GetText("AvgCurRecommendFight", avgCount) + else + self.TxtHardCurFight.text = CS.XTextManager.GetText("FightConditionError") + end + elseif data.RecommendFight > 0 then + self.TxtHardCurFight.text = CS.XTextManager.GetText("MaxCurRecommendFight", showAbility) + end + self.TxtHardMaxFight.text = showFight + self.Result = XUiFightControlState.Hard + --普通(不显示) + -- elseif showAbility >= showFight then + end + else + self.Ex.gameObject:SetActiveEx(true) + self.TxtExCurFight.text = CS.XTextManager.GetText("FightConditionError") + self.TxtExMaxFight.text = showFight + self.Result = XUiFightControlState.Ex + end + self.ShowAbility = showAbility + return self.Result +end + +function XUiNewRoomFightControl:OnBtnTishen() + XLuaUiManager.Open("UiPromotionWay", self.ShowAbility, self.TeamData, self.StageFightControlId, self.StageId) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCommon/XUiPanelAsset.lua b/Resources/Scripts/XUi/XUiCommon/XUiPanelAsset.lua new file mode 100644 index 00000000..2e3ed4ad --- /dev/null +++ b/Resources/Scripts/XUi/XUiCommon/XUiPanelAsset.lua @@ -0,0 +1,186 @@ +XUiPanelAsset = XClass(nil, "XUiPanelAssetCommon") +local insert = table.insert +local min = math.min + +function XUiPanelAsset:Ctor(rootUi, ui, ...) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.ItemIds = { ... } + self.EventListener = {} + self:InitAutoScript() + + self:InitBtnSound() + self:InitAssert(self.ItemIds) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelAsset:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiPanelAsset:AutoInitUi() + self.PanelTool3 = XUiHelper.TryGetComponent(self.Transform, "PanelTool3", nil) + self.RImgTool3 = XUiHelper.TryGetComponent(self.Transform, "PanelTool3/RImgTool3", "RawImage") + self.TxtTool3 = XUiHelper.TryGetComponent(self.Transform, "PanelTool3/TxtTool3", "Text") + self.BtnBuyJump3 = XUiHelper.TryGetComponent(self.Transform, "PanelTool3/BtnBuyJump3", "Button") + self.PanelTool2 = XUiHelper.TryGetComponent(self.Transform, "PanelTool2", nil) + self.RImgTool2 = XUiHelper.TryGetComponent(self.Transform, "PanelTool2/RImgTool2", "RawImage") + self.TxtTool2 = XUiHelper.TryGetComponent(self.Transform, "PanelTool2/TxtTool2", "Text") + self.BtnBuyJump2 = XUiHelper.TryGetComponent(self.Transform, "PanelTool2/BtnBuyJump2", "Button") + self.PanelTool1 = XUiHelper.TryGetComponent(self.Transform, "PanelTool1", nil) + self.RImgTool1 = XUiHelper.TryGetComponent(self.Transform, "PanelTool1/RImgTool1", "RawImage") + self.TxtTool1 = XUiHelper.TryGetComponent(self.Transform, "PanelTool1/TxtTool1", "Text") + self.BtnBuyJump1 = XUiHelper.TryGetComponent(self.Transform, "PanelTool1/BtnBuyJump1", "Button") +end + +function XUiPanelAsset:RegisterJumpCallList(callList) + self.JumpCallList = callList +end + +function XUiPanelAsset:GetAutoKey(uiNode, eventName) + if not uiNode then + return + end + return eventName .. uiNode:GetHashCode() +end + +function XUiPanelAsset:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then + return + end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiPanelAsset:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiPanelAsset:AutoAddListener() + self.AutoCreateListeners = {} + XUiHelper.RegisterClickEvent(self, self.BtnBuyJump3, self.OnBtnBuyJump3Click) + XUiHelper.RegisterClickEvent(self, self.BtnBuyJump2, self.OnBtnBuyJump2Click) + XUiHelper.RegisterClickEvent(self, self.BtnBuyJump1, self.OnBtnBuyJump1Click) +end +-- auto +function XUiPanelAsset:InitBtnSound() + if self.BtnBuyJump3 then + self.SpecialSoundMap[self:GetAutoKey(self.BtnBuyJump3, "onClick")] = 1013 + end + + if self.BtnBuyJump2 then + self.SpecialSoundMap[self:GetAutoKey(self.BtnBuyJump2, "onClick")] = 1013 + end + + if self.BtnBuyJump1 then + self.SpecialSoundMap[self:GetAutoKey(self.BtnBuyJump1, "onClick")] = 1013 + end +end + +function XUiPanelAsset:OnBtnBuyJump1Click() + self:BuyJump(1) +end + +function XUiPanelAsset:OnBtnBuyJump2Click() + self:BuyJump(2) +end + +function XUiPanelAsset:OnBtnBuyJump3Click() + self:BuyJump(3) +end + +function XUiPanelAsset:BuyJump(index) + -- 联机中不给跳转,防止跳出联机房间 + local unionFightData = XDataCenter.FubenUnionKillRoomManager.GetUnionRoomData() + if unionFightData and unionFightData.Id then + XUiManager.TipMsg(CS.XTextManager.GetText("UnionCantLeaveRoom")) + return + end + if XDataCenter.FubenUnionKillRoomManager.IsMatching() then + XUiManager.TipMsg(CS.XTextManager.GetText("UnionInMatching")) + return + end + if self.JumpCallList and self.JumpCallList[index] and type(self.JumpCallList[index]) == "function" then + self.JumpCallList[index]() + return + end + + if self.ItemIds[index] == XDataCenter.ItemManager.ItemId.FreeGem then + XLuaUiManager.Open("UiPurchase", XPurchaseConfigs.TabsConfig.HK) + elseif self.ItemIds[index] == XDataCenter.ItemManager.ItemId.HongKa then + XLuaUiManager.Open("UiPurchase", XPurchaseConfigs.TabsConfig.Pay) + else + XUiManager.OpenBuyAssetPanel(self.ItemIds[index]) + end +end + +function XUiPanelAsset:InitAssert() + if XTool.UObjIsNil(self.GameObject) then + return + end + + local panels = {} + if self.PanelTool1 then + insert(panels, self.PanelTool1) + self.PanelTool1.gameObject:SetActive(false) + end + + if self.PanelTool2 then + insert(panels, self.PanelTool2) + self.PanelTool2.gameObject:SetActive(false) + end + + if self.PanelTool3 then + insert(panels, self.PanelTool3) + self.PanelTool3.gameObject:SetActive(false) + end + + local itemIds = self.ItemIds + + if #itemIds > #panels then + XLog.Warning("XUiPanelAsset:InitAssert Warning: use item id morn than panel count, panel count is " .. #panels .. "use item id is ", itemIds) + end + local panelCount = min(#itemIds, #panels) + + local func = function(textTool, id) + local itemCount = XDataCenter.ItemManager.GetCount(id) + if id == XDataCenter.ItemManager.ItemId.ActionPoint then + textTool.text = itemCount .. "/" .. XDataCenter.ItemManager.GetMaxActionPoints() + else + textTool.text = itemCount + end + end + + for i = 1, panelCount do + local panel = panels[i] + local item = XDataCenter.ItemManager.GetItem(itemIds[i]) + local rawImageIcon = self["RImgTool" .. i]; + if rawImageIcon ~= nil and rawImageIcon:Exist() then + --self.RootUi:SetUiSprite(self["ImgTool" .. i], item.Template.Icon) + rawImageIcon:SetRawImage(item.Template.Icon, nil, false) + end + local f = function() + func(self["TxtTool" .. i], itemIds[i]) + end + XDataCenter.ItemManager.AddCountUpdateListener(itemIds[i], f, self["TxtTool" .. i]) + func(self["TxtTool" .. i], itemIds[i]) + panel.gameObject:SetActive(true) + end +end diff --git a/Resources/Scripts/XUi/XUiCommon/XUiPlayerHead.lua b/Resources/Scripts/XUi/XUiCommon/XUiPlayerHead.lua new file mode 100644 index 00000000..227fedec --- /dev/null +++ b/Resources/Scripts/XUi/XUiCommon/XUiPlayerHead.lua @@ -0,0 +1,108 @@ +XUiPLayerHead = XUiPLayerHead or {} + +XUiPLayerHead.InitPortrait = function(HeadPortraitId, HeadFrameId, Object)--为通用头像组件调用这个接口 + if XTool.UObjIsNil(Object) then return end + + local uiObject,imgColor = XUiPLayerHead.Create(Object, false) + if not uiObject then return end + + uiObject.gameObject:SetActiveEx(true) + + if HeadPortraitId then + XUiPLayerHead.SetHeadPortrait(HeadPortraitId, uiObject:GetObject("ImgIcon"), uiObject:GetObject("EffectIcon"),imgColor) + end + if HeadFrameId then + XUiPLayerHead.SetHeadFrame(HeadFrameId, uiObject:GetObject("ImgIconKuang"), uiObject:GetObject("EffectKuang"),imgColor) + end +end + +XUiPLayerHead.Hide = function(Object) + if XTool.UObjIsNil(Object) then return end + + local uiObject,_ = XUiPLayerHead.Create(Object, true) + if not uiObject then return end + + uiObject.gameObject:SetActiveEx(false) +end + +XUiPLayerHead.Create = function(Object, IsHide) + local uiObject = Object.transform:GetComponent("UiObject") + if not uiObject then return end + + local headObject = Object.gameObject:FindTransform("HeadObject") + + local standIcon = uiObject:GetObject("StandIcon") + standIcon.gameObject:SetActiveEx(false) + + if XTool.UObjIsNil(headObject) and not IsHide then + headObject = CS.UnityEngine.Object.Instantiate(uiObject:GetObject("HeadObject")) + headObject.gameObject.name = "HeadObject" + headObject.transform:SetParent(Object.transform, false) + end + + return ((not XTool.UObjIsNil(headObject)) and headObject.transform:GetComponent("UiObject") or nil) , standIcon.color +end + +XUiPLayerHead.SetHeadPortrait = function(HeadPortraitId,iconRawImageNode,effectNode,imgColor) + local headPortraitInfo = XPlayerManager.GetHeadPortraitInfoById(HeadPortraitId) + if headPortraitInfo ~= nil then + if iconRawImageNode then + if headPortraitInfo.ImgSrc then + iconRawImageNode:SetRawImage(headPortraitInfo.ImgSrc) + iconRawImageNode.color = imgColor + iconRawImageNode.gameObject:SetActiveEx(true) + else + iconRawImageNode.gameObject:SetActiveEx(false) + end + end + + if effectNode then + if headPortraitInfo.Effect then + effectNode.gameObject:LoadPrefab(headPortraitInfo.Effect) + effectNode.gameObject:SetActiveEx(true) + else + effectNode.gameObject:SetActiveEx(false) + end + end + else + if iconRawImageNode then + iconRawImageNode.gameObject:SetActiveEx(false) + end + + if effectNode then + effectNode.gameObject:SetActiveEx(false) + end + end +end + +XUiPLayerHead.SetHeadFrame = function(HeadFrameId,iconRawImageNode,effectNode,imgColor) + local headPortraitInfo = XPlayerManager.GetHeadPortraitInfoById(HeadFrameId) + if headPortraitInfo ~= nil then + if iconRawImageNode then + if headPortraitInfo.ImgSrc then + iconRawImageNode.color = imgColor + iconRawImageNode:SetRawImage(headPortraitInfo.ImgSrc) + iconRawImageNode.gameObject:SetActiveEx(true) + else + iconRawImageNode.gameObject:SetActiveEx(false) + end + end + + if effectNode then + if headPortraitInfo.Effect then + effectNode.gameObject:LoadPrefab(headPortraitInfo.Effect) + effectNode.gameObject:SetActiveEx(true) + else + effectNode.gameObject:SetActiveEx(false) + end + end + else + if iconRawImageNode then + iconRawImageNode.gameObject:SetActiveEx(false) + end + + if effectNode then + effectNode.gameObject:SetActiveEx(false) + end + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCommon/XUiPlayerLevel.lua b/Resources/Scripts/XUi/XUiCommon/XUiPlayerLevel.lua new file mode 100644 index 00000000..c0924358 --- /dev/null +++ b/Resources/Scripts/XUi/XUiCommon/XUiPlayerLevel.lua @@ -0,0 +1,34 @@ +---通用等级处理接口,人物等级达到满级后将会显示荣耀的icon + +XUiPlayerLevel = XUiPlayerLevel or {} + +local Update = function(level, uiObject, desc) + local txtLevel = uiObject:GetObject("TxtLevel") + if not XTool.UObjIsNil(txtLevel) then + if not desc or desc == "" then + desc = level + end + txtLevel.text = desc + end + + local gloryIcon = uiObject:GetObject("GloryIcon") + if not XTool.UObjIsNil(gloryIcon) then + gloryIcon.gameObject:SetActiveEx(XPlayer.CheckIsMaxLevel(level)) + end +end + +--[[ + --@level: 只能传原始的等级(0~120),不要传荣耀等级 + --@Object: UiObject组件,必须要有TxtLevel(等级)和GloryIcon(荣耀等级图标,level==120时候会显示) + --@desc: TxtLevel的text显示文本,会替代level,可不传 +]] +XUiPlayerLevel.UpdateLevel = function(level, Object, desc) + if XTool.UObjIsNil(Object) then + return + end + + local uiObject = Object.transform:GetComponent("UiObject") + if not uiObject then return end + + Update(level, uiObject, desc) +end diff --git a/Resources/Scripts/XUi/XUiCommon/XUiSkipTip.lua b/Resources/Scripts/XUi/XUiCommon/XUiSkipTip.lua new file mode 100644 index 00000000..6bacede6 --- /dev/null +++ b/Resources/Scripts/XUi/XUiCommon/XUiSkipTip.lua @@ -0,0 +1,33 @@ +local XUiSkipTip = XLuaUiManager.Register(XLuaUi, "UiSkipTip") + +function XUiSkipTip:OnAwake() + self:InitAutoScript() + self.PanelGridSkip.gameObject:SetActive(false) +end + +function XUiSkipTip:OnStart(skipIds) + self.GridPool = {} + self:Refresh(skipIds) +end + +function XUiSkipTip:Refresh(skipIds) + XUiHelper.CreateTemplates(self, self.GridPool, skipIds, XUiGridSkip.New, self.PanelGridSkip, self.PanelContent, function(grid, data) + grid:Refresh(data) + end) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiSkipTip:InitAutoScript() + self:AutoAddListener() +end + +function XUiSkipTip:AutoAddListener() + self:RegisterClickEvent(self.BtnClose, self.OnBtnCloseClick) + self:RegisterClickEvent(self.BtnTanchuangClose, self.OnBtnCloseClick) +end + +-- auto +function XUiSkipTip:OnBtnCloseClick() + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCommon/XUiStageFightControl.lua b/Resources/Scripts/XUi/XUiCommon/XUiStageFightControl.lua new file mode 100644 index 00000000..85ae3d2a --- /dev/null +++ b/Resources/Scripts/XUi/XUiCommon/XUiStageFightControl.lua @@ -0,0 +1,45 @@ +XUiStageFightControl = XClass(nil, "XUiStageFightControl") +--战力限制组件 +function XUiStageFightControl:Ctor(ui, stageFightControlId) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:UpdateInfo(stageFightControlId) +end + +function XUiStageFightControl:UpdateInfo(stageFightControlId) + self.StageFightControlId = stageFightControlId + self.Extremely.gameObject:SetActive(false) + self.Hard.gameObject:SetActive(false) + self.Normal.gameObject:SetActive(false) + self.GameObject:SetActiveEx(false) + local data = XFubenConfigs.GetStageFightControl(self.StageFightControlId) + if not data or data.RecommendFight <= 0 then + return + end + local charlist = XDataCenter.CharacterManager.GetCharacterList() + local maxAbility = 0 + for _, v in pairs(charlist) do + if v.Ability and v.Ability > maxAbility then + maxAbility = v.Ability + end + end + maxAbility = math.floor(maxAbility) + if data ~= nil then + --极度困难 + if maxAbility < data.RecommendFight then + self.Extremely.gameObject:SetActive(true) + self.TxtExCurNum.text = maxAbility + self.TxtExMaxNum.text = data.ShowFight + self.GameObject:SetActiveEx(true) + --困难 + elseif maxAbility >= data.RecommendFight and maxAbility < data.ShowFight then + self.Hard.gameObject:SetActive(true) + self.TxtHardCurNum.text = maxAbility + self.TxtHardMaxNum.text = data.ShowFight + self.GameObject:SetActiveEx(true) + --普通(不显示) + -- elseif maxAbility >= data.ShowFight then + end + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCommon/XUiStageFightEvent.lua b/Resources/Scripts/XUi/XUiCommon/XUiStageFightEvent.lua new file mode 100644 index 00000000..6725c4d1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiCommon/XUiStageFightEvent.lua @@ -0,0 +1,27 @@ +-- 通用关卡词缀列表详细页面 +local XUiStageFightEvent = XLuaUiManager.Register(XLuaUi, "UiCommonStageEvent") +local XUiStageFightEventItem = require("XUi/XUiCommon/XUiStageFightEventItem") +function XUiStageFightEvent:OnAwake() + XTool.InitUiObject(self) + self.GridBuff.gameObject:SetActiveEx(false) + self:RegisterUiButtonEvent() +end + +function XUiStageFightEvent:RegisterUiButtonEvent() + self.BtnClose.CallBack = function() self:OnBtnCloseClick() end +end + +function XUiStageFightEvent:OnBtnCloseClick() + self:Close() +end + +function XUiStageFightEvent:OnStart(dataList) + self.DataList = dataList + for _, eventCfg in pairs(self.DataList) do + local prefab = CS.UnityEngine.Object.Instantiate(self.GridBuff.gameObject) + prefab.transform:SetParent(self.PanelContent.transform, false) + local tipItem = XUiStageFightEventItem.New(prefab, self) + tipItem:RefreshData(eventCfg) + tipItem.GameObject:SetActiveEx(true) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCommon/XUiStageFightEventItem.lua b/Resources/Scripts/XUi/XUiCommon/XUiStageFightEventItem.lua new file mode 100644 index 00000000..c149721c --- /dev/null +++ b/Resources/Scripts/XUi/XUiCommon/XUiStageFightEventItem.lua @@ -0,0 +1,13 @@ +-- 通用关卡词缀列表项控件 +local XUiStageFightEventItem = XClass(nil, "XUiStageFightEventItem") +function XUiStageFightEventItem:Ctor(ui) + XTool.InitUiObjectByUi(self, ui) +end + +function XUiStageFightEventItem:RefreshData(data) + self.Cfg = data + self.RImgIcon:SetRawImage(self.Cfg.Icon) + self.TxtName.text = self.Cfg.Name + self.TxtDesc.text = self.Cfg.Description +end +return XUiStageFightEventItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCommon/XUiTipLayer.lua b/Resources/Scripts/XUi/XUiCommon/XUiTipLayer.lua new file mode 100644 index 00000000..f894c9b8 --- /dev/null +++ b/Resources/Scripts/XUi/XUiCommon/XUiTipLayer.lua @@ -0,0 +1,159 @@ +local XUiTipLayer = XLuaUiManager.Register(XLuaUi, "UiTipLayer") + +local TIP_MSG_SHOW_TIME = 2000 + +function XUiTipLayer:OnAwake() + self:InitAutoScript() +end + +function XUiTipLayer:OnStart(msg, type, cb, hideCloseMark) + self.Cb = cb + self.closeState = false + self:HideTipLayer() + self.BtnClose.interactable = true + self.BtnClose.gameObject:SetActive(not hideCloseMark) + XUiHelper.StopAnimation() + if type == XUiManager.UiTipType.Tip then + self.PanelTip.gameObject:SetActive(true) + self:PlayAnimation("PanelTip") + self.TxtInfo.text = msg + elseif type == XUiManager.UiTipType.Success then + CS.XAudioManager.PlaySound(XSoundManager.UiBasicsMusic.Success) -- 成功 + self.PanelSuccess.gameObject:SetActive(true) + self:PlayAnimation("PaneSuccess") + self.TxtInfoSuccess.text = msg + elseif type == XUiManager.UiTipType.Wrong then + CS.XAudioManager.PlaySound(XSoundManager.UiBasicsMusic.Intercept) -- 拦截 + self.PanelError.gameObject:SetActive(true) + self:PlayAnimation("PanelError") + self.TxtInfoError.text = msg + end + + local pop = function() + self:Close() + end + + local closeFunc + if type == XUiManager.UiTipType.Tip then + closeFunc = function() + if not XTool.UObjIsNil(self.GameObject) then + self:PlayAnimation("PanelTipEnd", pop) + end + end + elseif type == XUiManager.UiTipType.Success then + closeFunc = function() + if not XTool.UObjIsNil(self.GameObject) then + self:PlayAnimation("PaneSuccessEnd", pop) + end + end + elseif type == XUiManager.UiTipType.Wrong then + closeFunc = function() + if not XTool.UObjIsNil(self.GameObject) then + self:PlayAnimation("PanelErrorEnd", pop) + end + end + end + self.CloseFunc = closeFunc + self.Timer = XScheduleManager.ScheduleOnce(function() + if not self.closeState then + self.closeState = true + closeFunc() + end + end, TIP_MSG_SHOW_TIME) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiTipLayer:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiTipLayer:AutoInitUi() + self.BtnClose = self.Transform:Find("SafeAreaContentPane/BtnClose"):GetComponent("Button") + self.PanelSuccess = self.Transform:Find("SafeAreaContentPane/PanelSuccess") + self.TxtInfoSuccess = self.Transform:Find("SafeAreaContentPane/PanelSuccess/TxtInfo"):GetComponent("Text") + self.PanelError = self.Transform:Find("SafeAreaContentPane/PanelError") + self.TxtInfoError = self.Transform:Find("SafeAreaContentPane/PanelError/TxtInfo"):GetComponent("Text") + self.PanelTip = self.Transform:Find("SafeAreaContentPane/PanelTip") + self.TxtInfo = self.Transform:Find("SafeAreaContentPane/PanelTip/TxtInfo"):GetComponent("Text") +end + +function XUiTipLayer:GetAutoKey(uiNode, eventName) + if not uiNode then + return + end + return eventName .. uiNode:GetHashCode() +end + +function XUiTipLayer:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then + return + end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiTipLayer:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiTipLayer:AutoAddListener() + self.AutoCreateListeners = {} + self:RegisterClickEvent(self.BtnClose, self.OnBtnCloseClick) +end +-- auto +function XUiTipLayer:OnBtnCloseClick() + + if self.closeState then + return + end + + self.closeState = true + XScheduleManager.UnSchedule(self.Timer) + self.BtnClose.interactable = false + if self.CloseFunc then + self:CloseFunc() + else + --CS.XUiManager.TipsManager:Pop() + self:Close() + end +end + +function XUiTipLayer:HideTipLayer() + self.PanelTip.gameObject:SetActive(false) + self.PanelError.gameObject:SetActive(false) + self.PanelSuccess.gameObject:SetActive(false) +end + +function XUiTipLayer:OnDestroy() + local key = self:GetAutoKey(self.BtnClose, "onClick") + if not key then + return + end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + self.BtnClose["onClick"]:RemoveListener(listener) + end + if self.Cb then + self.Cb() + end + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCommonWindow/XUiSelectCharacterGrid.lua b/Resources/Scripts/XUi/XUiCommonWindow/XUiSelectCharacterGrid.lua new file mode 100644 index 00000000..468d4502 --- /dev/null +++ b/Resources/Scripts/XUi/XUiCommonWindow/XUiSelectCharacterGrid.lua @@ -0,0 +1,129 @@ +--选择角色页面中角色列表Gird组件 +local XUiSelectCharacterGrid = XClass(nil, "XUiSelectCharacterGrid") + +UiCharacterGridType = { + Normal = 1, --我拥有的角色 + Try = 2, --试玩角色(robot) +} + +function XUiSelectCharacterGrid:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiSelectCharacterGrid:UpdateInfo(data, teamData, editPos, rootUi) + self:Reset() + self.Data = data + self.TeamData = teamData + self.EditPos = editPos + self.RootUi = rootUi + if self.Data.Type == UiCharacterGridType.Normal then + self:UpdateNormalInfo() + elseif self.Data.Type == UiCharacterGridType.Try then + self:UpdateTryInfo() + end +end + +function XUiSelectCharacterGrid:Reset() + self.PanelTry.gameObject:SetActiveEx(false) + self.PanelSelected.gameObject:SetActiveEx(false) + self.RImgTonngDiao.gameObject:SetActiveEx(false) + self.PanelRogueLikeTheme.gameObject:SetActiveEx(false) + self.PanelStaminaBar.gameObject:SetActiveEx(false) + self.PanelTeamSupport.gameObject:SetActiveEx(false) + self.PanelInTeam.gameObject:SetActiveEx(false) + self.PanelSame.gameObject:SetActiveEx(false) + + self.PanelFight.gameObject:SetActiveEx(true) +end + +function XUiSelectCharacterGrid:UpdateNormalInfo() + local characterData = XDataCenter.CharacterManager.GetCharacter(self.Data.Id) + self.Data.CharacterData = characterData + self.TxtLevel.text = characterData.Level + self.RImgQuality:SetRawImage(XCharacterConfigs.GetCharacterQualityIcon(characterData.Quality)) + self.RImgHeadIcon:SetRawImage(XDataCenter.CharacterManager.GetCharSmallHeadIcon(characterData.Id)) + self.TxtFight.text = characterData.Ability + + local detailConfig = XCharacterConfigs.GetCharDetailTemplate(characterData.Id) + local elementList = detailConfig.ObtainElementList + for i = 1, 3 do + local rImg = self["RImgCharElement" .. i] + if elementList[i] then + rImg.gameObject:SetActiveEx(true) + local elementConfig = XCharacterConfigs.GetCharElement(elementList[i]) + rImg:SetRawImage(elementConfig.Icon) + else + rImg.gameObject:SetActiveEx(false) + end + end + + --是否在队里,是否是同类角色 + for i = 1, #self.TeamData do + if self.TeamData[i] == self.Data.Id then + self.PanelInTeam.gameObject:SetActiveEx(true) + break + else + if self.TeamData[i] < 1000000 and self.TeamData[i] > 0 then + local robotTemplate = XRobotManager.GetRobotTemplate(self.TeamData[i]) + if robotTemplate.CharacterId == self.Data.Id then + self.PanelSame.gameObject:SetActiveEx(true) + end + end + end + end +end + +--试玩角色Data.Id ->robotId +function XUiSelectCharacterGrid:UpdateTryInfo() + self.PanelTry.gameObject:SetActiveEx(true) + local robotTemplate = XRobotManager.GetRobotTemplate(self.Data.Id) + self.Data.RobotData = robotTemplate + self.TxtLevel.text = robotTemplate.CharacterLevel + self.RImgQuality:SetRawImage(XCharacterConfigs.GetCharacterQualityIcon(robotTemplate.CharacterQuality)) + self.RImgHeadIcon:SetRawImage(XDataCenter.CharacterManager.GetCharSmallHeadIcon(robotTemplate.CharacterId, robotTemplate.LiberateLv, true)) + + + local detailConfig = XCharacterConfigs.GetCharDetailTemplate(robotTemplate.CharacterId) + local elementList = detailConfig.ObtainElementList + for i = 1, 3 do + local rImg = self["RImgCharElement" .. i] + if elementList[i] then + rImg.gameObject:SetActiveEx(true) + local elementConfig = XCharacterConfigs.GetCharElement(elementList[i]) + rImg:SetRawImage(elementConfig.Icon) + else + rImg.gameObject:SetActiveEx(false) + end + end + + --是否在队里,是否是同类角色 + for i = 1, #self.TeamData do + if self.TeamData[i] == robotTemplate.Id then + self.PanelInTeam.gameObject:SetActiveEx(true) + break + else + if self.TeamData[i] == robotTemplate.CharacterId then + self.PanelSame.gameObject:SetActiveEx(true) + end + end + end + + if self.Data.NieRCharacterId and self.Data.NieRCharacterId ~= 0 then + self.TxtFight.text = XDataCenter.NieRManager.GetNieRCharacterByCharacterId(self.Data.NieRCharacterId):GetAbilityNum() + else + if self.RootUi and self.RootUi.Type and self.RootUi.Type == UiSelectCharacterType.NieROnlyRobot then + self.TxtFight.text = XRobotManager.GetRobotAbility(self.Data.Id) + else + local ability = XRobotManager.GetRobotAbility(self.Data.Id) + self.TxtFight.text = ability + end + end +end + +function XUiSelectCharacterGrid:SetSelectMark(isSelect) + self.PanelSelected.gameObject:SetActiveEx(isSelect) +end + +return XUiSelectCharacterGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCommonWindow/XUiSelectCharacterWin.lua b/Resources/Scripts/XUi/XUiCommonWindow/XUiSelectCharacterWin.lua new file mode 100644 index 00000000..4894d031 --- /dev/null +++ b/Resources/Scripts/XUi/XUiCommonWindow/XUiSelectCharacterWin.lua @@ -0,0 +1,394 @@ +--选取角色页面 +local XUiSelectCharacterWin = XLuaUiManager.Register(XLuaUi, "UiSelectCharacterWin") +local XUiSelectCharacterGrid = require("XUi/XUiCommonWindow/XUiSelectCharacterGrid") + +--自定义选择种类 +UiSelectCharacterType = { + Normal = 1, --选取我所拥有的角色 + LimitedByCharacterAndRobot = 2, --在给定的限制范围(robotId,以及这些robot对应的characterid)内选取角色 工会boss使用 + WorldBoss = 3, --选取我所拥有的角色和开放的机器人(世界Boss用) + NieROnlyRobot = 4, --仅使用开放的机器人(尼尔玩法用) +} + +function XUiSelectCharacterWin:OnAwake() + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + self.BtnJoinTeam.CallBack = function() self:OnBtnJoinTeamClick() end + self.BtnQuitTeam.CallBack = function() self:OnBtnQuitTeamClick() end + self.BtnFashion.CallBack = function() self:OnBtnFashionClick() end + self.BtnFashion2.CallBack = function() self:OnBtnFashionClick() end + self.BtnConsciousness.CallBack = function() self:OnBtnConsciousnessClick() end + self.BtnWeapon.CallBack = function() self:OnBtnWeaponClick() end + self:RegisterClickEvent(self.BtnPartner, self.OnCarryPartnerClick) + + self.GridCharacterObj.gameObject:SetActiveEx(false) + self.BtnFashion2.gameObject:SetActiveEx(false) + self.DynamicTable = XDynamicTableNormal.New(self.PanelCharacterList) + self.DynamicTable:SetProxy(XUiSelectCharacterGrid) + self.DynamicTable:SetDelegate(self) + + local root = self.UiModelGo + self.PanelRoleModel = root:FindTransform("PanelRoleModel") + self.ImgEffectHuanren = root:FindTransform("ImgEffectHuanren") + self.RoleModelPanel = XUiPanelRoleModel.New(self.PanelRoleModel, self.Name, nil, true) + self.XDrag = self.PanelDrag:GetComponent("XDrag") + + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + + self.CharacterGrids = {} + self.CurSelectData = nil + self.SelectIndex = 1 + + self.NeedUpdate = false +end + +function XUiSelectCharacterWin:OnStart(cb, type, teamData, editPos, ...) + self.Cb = cb --选择回调 + self.Type = type --选择类型 + self.TeamData = teamData --当前队伍情况 + self.EditPos = editPos --当前编辑的位置 + self.Args = (...) +end + +function XUiSelectCharacterWin:UpdateByType() + if self.Type == UiSelectCharacterType.Normal then + self:NormalTypeUpdate(self.Args) + elseif self.Type == UiSelectCharacterType.LimitedByCharacterAndRobot then + self:LimitedByCharacterAndRobotTypeUpdate(self.Args) + elseif self.Type == UiSelectCharacterType.WorldBoss then + self:WorldBossUpdate(self.Args) + elseif self.Type == UiSelectCharacterType.NieROnlyRobot then + self:NieRUpdate(self.Args) + end +end + +function XUiSelectCharacterWin:OnEnable() + self:UpdateByType() + if self.NeedUpdate then + self:OnSelect(self.CurSelectData) + end + self.NeedUpdate = true +end + +function XUiSelectCharacterWin:NormalTypeUpdate() + +end + + +--LimitedByCharacterAndRobot规则的构造列表 参数:(机器人id列表,角色原型Id列表) +function XUiSelectCharacterWin:LimitedByCharacterAndRobotTypeUpdate(robotTab) + local list = XTool.Clone(robotTab) + --拥有对应的character才加入可选列表 + for i = 1, #robotTab do + local characterId = XRobotManager.GetRobotTemplate(robotTab[i]).CharacterId + if XDataCenter.CharacterManager.IsOwnCharacter(characterId) then + table.insert(list, characterId) + end + end + self.GridData = {} + for i = 1, #list do + if i <= #robotTab then + table.insert(self.GridData, { Type = UiCharacterGridType.Try, Id = list[i] }) + else + table.insert(self.GridData, { Type = UiCharacterGridType.Normal, Id = list[i] }) + end + end + + --排序 + local function sortByAbility(a, b) + return self:GetAbility(a) > self:GetAbility(b) + end + table.sort(self.GridData, sortByAbility) + + self:DefaultSelect() + self.DynamicTable:SetDataSource(self.GridData) + self.DynamicTable:ReloadDataASync(self.SelectIndex) +end + +function XUiSelectCharacterWin:WorldBossUpdate(robotTab) + local list = XTool.Clone(robotTab) + local charlist = XDataCenter.CharacterManager.GetCharacterListInTeam(XCharacterConfigs.CharacterType.Normal) + for _, char in pairs(charlist) do + table.insert(list, char.Id) + end + + + self.GridData = {} + for i = 1, #list do + if i <= #robotTab then + table.insert(self.GridData, { Type = UiCharacterGridType.Try, Id = list[i] }) + else + table.insert(self.GridData, { Type = UiCharacterGridType.Normal, Id = list[i] }) + end + end + + --排序 + local function sortByAbility(a, b) + if a.Type == b.Type then + return self:GetAbility(a) > self:GetAbility(b) + else + return a.Type == UiCharacterGridType.Try + end + + end + table.sort(self.GridData, sortByAbility) + + self:DefaultSelect() + self.DynamicTable:SetDataSource(self.GridData) + self.DynamicTable:ReloadDataASync(self.SelectIndex) +end + +function XUiSelectCharacterWin:NieRUpdate(robotTab) + local list = XTool.Clone(robotTab) + + self.GridData = {} + for i = 1, #list do + table.insert(self.GridData, { Type = UiCharacterGridType.Try, Id = list[i], NieRCharacterId = XDataCenter.NieRManager.GetCharacterIdByNieRRobotId(list[i]) }) + end + + --排序 + local function sortByAbility(a, b) + if a.Type == b.Type then + local aCharacterId = a.NieRCharacterId + local bCharacterId = b.NieRCharacterId + if aCharacterId == 0 and 0 ~= bCharacterId then + return true + elseif aCharacterId ~= 0 and bCharacterId ~= 0 then + return XDataCenter.NieRManager.GetNieRCharacterByCharacterId(aCharacterId):GetAbilityNum() > XDataCenter.NieRManager.GetNieRCharacterByCharacterId(bCharacterId):GetAbilityNum() + elseif 0 == aCharacterId and 0 == bCharacterId then + return self:GetAbility(a) > self:GetAbility(b) + end + return false + else + return a.Type == UiCharacterGridType.Try + end + + end + table.sort(self.GridData, sortByAbility) + + self:DefaultSelect() + self.DynamicTable:SetDataSource(self.GridData) + self.DynamicTable:ReloadDataASync(self.SelectIndex) +end + +--获取战力 +function XUiSelectCharacterWin:GetAbility(data) + if data.Type == UiCharacterGridType.Try then + return XRobotManager.GetRobotAbility(data.Id) + elseif data.Type == UiCharacterGridType.Normal then + return XDataCenter.CharacterManager.GetCharacter(data.Id).Ability + end +end + +--每种情况下的默认选择 +function XUiSelectCharacterWin:DefaultSelect() + if self.Type == UiSelectCharacterType.Normal then + + elseif self.Type == UiSelectCharacterType.LimitedByCharacterAndRobot then + if self.TeamData[self.EditPos] ~= 0 then + for i = 1, #self.GridData do + if self.TeamData[self.EditPos] == self.GridData[i].Id then + self.SelectIndex = i + break + end + end + end + elseif self.Type == UiSelectCharacterType.WorldBoss then + if self.TeamData[self.EditPos] ~= 0 then + for i = 1, #self.GridData do + if self.TeamData[self.EditPos] == self.GridData[i].Id then + self.SelectIndex = i + break + end + end + end + elseif self.Type == UiSelectCharacterType.NieROnlyRobot then + if self.TeamData[self.EditPos] ~= 0 then + for i = 1, #self.GridData do + if self.TeamData[self.EditPos] == self.GridData[i].Id then + self.SelectIndex = i + break + end + end + end + end +end + +--每种类型的功能按钮需求 +function XUiSelectCharacterWin:UpdateFunctionBtn() + local isSame = self.TeamData[self.EditPos] == self.CurSelectData.Id + self.BtnJoinTeam.gameObject:SetActiveEx(not isSame) + self.BtnQuitTeam.gameObject:SetActiveEx(isSame) + self.BtnFashion2.gameObject:SetActiveEx(false) + + if self.Type == UiSelectCharacterType.NieROnlyRobot then + local nierChId = XDataCenter.NieRManager.GetCharacterIdByNieRRobotId(self.CurSelectData.Id) + if nierChId ~= 0 then + self.BtnFashion2.gameObject:SetActiveEx(true) + end + end + if self.CurSelectData.Type == UiCharacterGridType.Normal then + self.BtnFashion.gameObject:SetActiveEx(true) + self.BtnConsciousness.gameObject:SetActiveEx(true) + self.BtnWeapon.gameObject:SetActiveEx(true) + self.BtnPartner.gameObject:SetActiveEx(true) + elseif self.CurSelectData.Type == UiCharacterGridType.Try then + self.BtnFashion.gameObject:SetActiveEx(false) + self.BtnConsciousness.gameObject:SetActiveEx(false) + self.BtnWeapon.gameObject:SetActiveEx(false) + self.BtnPartner.gameObject:SetActiveEx(false) + end +end + +--每种情况下获取选中的characterId +function XUiSelectCharacterWin:GetCharacterId() + if self.CurSelectData.Type == UiCharacterGridType.Normal then + return self.CurSelectData.CharacterData.Id + elseif self.CurSelectData.Type == UiCharacterGridType.Try then + return self.CurSelectData.RobotData.CharacterId + end +end + +--把id转换成characterId +function XUiSelectCharacterWin:GetCharacterIdById(id) + if not XRobotManager.CheckIsRobotId(id) then + return id + elseif id > 0 then + return XRobotManager.GetRobotTemplate(id).CharacterId + end +end + +function XUiSelectCharacterWin:UpdateRoleModel(targetUiName) + local loadModeCb = function(model) + if not model then + return + end + self.XDrag.Target = model.transform + self.ImgEffectHuanren.gameObject:SetActive(false) + self.ImgEffectHuanren.gameObject:SetActive(true) + end + if self.CurSelectData.Type == UiCharacterGridType.Try then + local robotId = self.CurSelectData.Id + local robotCfg = XRobotManager.GetRobotTemplate(robotId) + if self.Type == UiSelectCharacterType.NieROnlyRobot then + local fashionId = robotCfg.FashionId + local weaponId = robotCfg.WeaponId + local nierChId = XDataCenter.NieRManager.GetCharacterIdByNieRRobotId(robotId) + if nierChId ~= 0 then + local nierCharacter = XDataCenter.NieRManager.GetNieRCharacterByCharacterId(nierChId) + weaponId = nierCharacter:GetNieRWeaponId() + fashionId = nierCharacter:GetNieRFashionId() + end + self.RoleModelPanel:UpdateRobotModel(robotId, self:GetCharacterId(), nil, fashionId, weaponId, loadModeCb) + else + self.RoleModelPanel:UpdateRobotModel(robotId, self:GetCharacterId(), nil, robotCfg.FashionId, robotCfg.WeaponId, loadModeCb) + end + + else + self.RoleModelPanel:UpdateCharacterModel(self:GetCharacterId(), nil, targetUiName, loadModeCb) + end +end + + + +--On Event +function XUiSelectCharacterWin:OnSelect(data) + self.CurSelectData = data + self:UpdateRoleModel(self.Name) + self:UpdateFunctionBtn() + if self.Type == UiSelectCharacterType.NieROnlyRobot then + local nierChId = XDataCenter.NieRManager.GetCharacterIdByNieRRobotId(self.CurSelectData.Id) + if nierChId ~= 0 then + XDataCenter.NieRManager.SetSelCharacterId(nierChId) + end + end +end + +function XUiSelectCharacterWin:OnBtnCloseClick() + self:Close() + if self.CloseFinishCallBack then + self.CloseFinishCallBack() + end +end + +function XUiSelectCharacterWin:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:UpdateInfo(self.GridData[index], self.TeamData, self.EditPos, self) + grid:SetSelectMark(index == self.SelectIndex) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + local lastGrid = self.DynamicTable:GetGridByIndex(self.SelectIndex) + if lastGrid then + self.DynamicTable:GetGridByIndex(self.SelectIndex):SetSelectMark(false) + end + self.SelectIndex = index + grid:SetSelectMark(true) + self:OnSelect(self.GridData[index]) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_RELOAD_COMPLETED then + self:OnSelect(self.GridData[self.SelectIndex]) + end +end + +function XUiSelectCharacterWin:OnBtnBackClick() + if self.Cb then + self.Cb(self.TeamData) + end + self:Close() +end + +function XUiSelectCharacterWin:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiSelectCharacterWin:OnBtnJoinTeamClick() + --如果该角色已经在队伍中 + for i = 1, #self.TeamData do + if i ~= self.EditPos and self:GetCharacterIdById(self.TeamData[i]) == self:GetCharacterIdById(self.CurSelectData.Id) then + self.TeamData[i] = 0 + end + end + if self.Cb then + self.TeamData[self.EditPos] = self.CurSelectData.Id + self.Cb(self.TeamData) + end + self:Close() +end + +function XUiSelectCharacterWin:OnBtnQuitTeamClick() + local id = self.CurSelectData.Id + for k, v in pairs(self.TeamData) do + if v == id then + self.TeamData[k] = 0 + break + end + end + + if self.Cb then + self.Cb(self.TeamData) + end + self:Close() +end + +function XUiSelectCharacterWin:OnCarryPartnerClick() + XDataCenter.PartnerManager.GoPartnerCarry(self.CurSelectData.Id, false) +end + +function XUiSelectCharacterWin:OnBtnFashionClick() + XLuaUiManager.Open("UiFashion", self.CurSelectData.Id) +end + +function XUiSelectCharacterWin:OnBtnFashionClick() + if self.Type == UiSelectCharacterType.NieROnlyRobot then + XLuaUiManager.Open("UiFashion", self.CurSelectData.Id, true, true, XUiConfigs.OpenUiType.NieRCharacterUI) + else + XLuaUiManager.Open("UiFashion", self.CurSelectData.Id, true, true) + end +end + +function XUiSelectCharacterWin:OnBtnConsciousnessClick() + XLuaUiManager.Open("UiEquipAwarenessReplace", self.CurSelectData.Id, nil, true) +end + +function XUiSelectCharacterWin:OnBtnWeaponClick() + XLuaUiManager.Open("UiEquipReplaceNew", self.CurSelectData.Id, nil, true) +end +--On Event end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCoupletGame/XUiCoupletAward.lua b/Resources/Scripts/XUi/XUiCoupletGame/XUiCoupletAward.lua new file mode 100644 index 00000000..a2080ac6 --- /dev/null +++ b/Resources/Scripts/XUi/XUiCoupletGame/XUiCoupletAward.lua @@ -0,0 +1,61 @@ +local XUiCoupletAward = XLuaUiManager.Register(XLuaUi, "UiCoupletAward") + +local XUiGridCoupletTask = require("XUi/XUiCoupletGame/XUiGridCoupletTask") + +function XUiCoupletAward:OnAwake() + +end + +function XUiCoupletAward:OnStart() + self:AutoRegisterBtn() + self:InitDynamicTable() +end + +function XUiCoupletAward:OnEnable() + self:UpdateDynamicTable() +end + +function XUiCoupletAward:OnDisable() + +end + +function XUiCoupletAward:OnDestroy() + +end + +function XUiCoupletAward:OnGetEvents() + return { + XEventId.EVENT_COUPLET_GAME_FINISH_TASK + } +end + +function XUiCoupletAward:OnNotify(evt, ...) + if evt == XEventId.EVENT_COUPLET_GAME_FINISH_TASK then + self:UpdateDynamicTable() + end +end + +function XUiCoupletAward:AutoRegisterBtn() + self.BtnTanchuangClose.CallBack = function() self:Close() end + self.BtnTreasureBg.CallBack = function() self:Close() end +end + +function XUiCoupletAward:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelTreasureGrade) + self.DynamicTable:SetProxy(XUiGridCoupletTask) + self.DynamicTable:SetDelegate(self) +end + +function XUiCoupletAward:UpdateDynamicTable() + self.TaskList = XDataCenter.CoupletGameManager.GetRewardTaskDatas() + self.DynamicTable:SetDataSource(self.TaskList) + self.DynamicTable:ReloadDataSync() +end + +function XUiCoupletAward:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:UpdateGrid(self.TaskList[index]) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCoupletGame/XUiCoupletGame.lua b/Resources/Scripts/XUi/XUiCoupletGame/XUiCoupletGame.lua new file mode 100644 index 00000000..4f321532 --- /dev/null +++ b/Resources/Scripts/XUi/XUiCoupletGame/XUiCoupletGame.lua @@ -0,0 +1,216 @@ +local tableInsert = table.insert +local CSXTextManagerGetText = CS.XTextManager.GetText + +local XUiCoupletGame = XLuaUiManager.Register(XLuaUi, "UiCoupletGame") + +local XUiCoupletStageCtrlPanel = require("XUi/XUiCoupletGame/XUiCoupletStageCtrlPanel") +local XUiCoupletRollPanel = require("XUi/XUiCoupletGame/XUiCoupletRollPanel") + +function XUiCoupletGame:OnAwake() + if not XDataCenter.CoupletGameManager.CheckHasServerData() then + self:Close() + end + self.PanelCoupletStageCtrl = XUiCoupletStageCtrlPanel.New(self, self.PanelStageCtrl) + self.PanelCoupletRoll = XUiCoupletRollPanel.New(self, self.PanelRoll) +end + +function XUiCoupletGame:OnStart() + self:AutoRegisterBtn() + self.AssetPanel = XUiPanelActivityAsset.New(self.PanelAsset, true) + self.AssetPanel:Refresh({ XDataCenter.CoupletGameManager.GetConsumeItemId() }) + self:InitBtnGroup() + self:InitRedPoint() +end + +function XUiCoupletGame:OnEnable() + self:RefreshBtnTab() + self:StartActivityTimer() + self:RefreshTitle() + self:RefreshRewardProcess() + local defaultTabIndex = XDataCenter.CoupletGameManager.FindDefaultSelectTabIndex() + self.PanelLamp:SelectIndex(defaultTabIndex) + self.CurrentSelectIndex = defaultTabIndex + if self.CurrentSelectIndex and self.CurrentSelectIndex ~= 0 then + self.PanelLamp:SelectIndex(self.CurrentSelectIndex) + end + + self:CheckHitFaceVideo() +end + +function XUiCoupletGame:OnDisable() + self:StopActivityTimer() +end + +function XUiCoupletGame:OnDestroy() + +end + +function XUiCoupletGame:OnGetEvents() + return { + XEventId.EVENT_COUPLET_GAME_GET_WORD, + XEventId.EVENT_COUPLET_GAME_COMPLETE, + XEventId.EVENT_COUPLET_GAME_CHANGE_WORD, + XEventId.EVENT_COUPLET_GAME_FINISH_TASK, + XEventId.EVENT_COUPLET_GAME_PLAYED_VIDEO, + XEventId.EVENT_COUPLET_GAME_SENTENCE_ERROR, + } +end + +function XUiCoupletGame:OnNotify(evt, ...) + local coupletId = XDataCenter.CoupletGameManager.GetCoupletTemplateByIndex(self.CurrentSelectIndex).Id + if evt == XEventId.EVENT_COUPLET_GAME_COMPLETE then + self:RefreshBtnTab() + self.PanelCoupletStageCtrl:Refresh(coupletId, true) + self.PanelCoupletRoll:Refresh(coupletId, true) + elseif evt == XEventId.EVENT_COUPLET_GAME_GET_WORD then + self.PanelCoupletStageCtrl:Refresh(coupletId, true) + self.PanelCoupletRoll:RefreshDownWords(coupletId, false, ...) + self.AssetPanel:Refresh({ XDataCenter.CoupletGameManager.GetConsumeItemId() }) + elseif evt == XEventId.EVENT_COUPLET_GAME_CHANGE_WORD then + self.PanelCoupletRoll:RefreshDownWords(coupletId) + elseif evt == XEventId.EVENT_COUPLET_GAME_FINISH_TASK then + self:RefreshRewardProcess() + elseif evt == XEventId.EVENT_COUPLET_GAME_PLAYED_VIDEO then + self:RefreshBtnTab() + elseif evt == XEventId.EVENT_COUPLET_GAME_SENTENCE_ERROR then + self.PanelCoupletRoll:ShowWordEffectError() + end +end + +function XUiCoupletGame:AutoRegisterBtn() + self.BtnBack.CallBack = function () self:Close() end + self.BtnMainUi.CallBack = function () XLuaUiManager.RunMain() end + self.BtnBox.CallBack = function () self:OnBtnRewardClick() end + self:RegisterHelpBtn() +end + +function XUiCoupletGame:RegisterHelpBtn() + local helpId = XDataCenter.CoupletGameManager.GetHelpId() + local template = XHelpCourseConfig.GetHelpCourseTemplateById(helpId) + self:BindHelpBtn(self.BtnHelp, template.Function) +end + +function XUiCoupletGame:InitBtnGroup() + local tmpBtnTabs = {self.BtnLamp1, self.BtnLamp2, self.BtnLamp3, self.BtnLamp4, self.BtnLamp5} + self.BtnTabs = {} + local coupletTemplates = XDataCenter.CoupletGameManager.GetCoupletTemplates() + for i=1, #tmpBtnTabs, 1 do + if i <= #coupletTemplates then + tmpBtnTabs[i].gameObject:SetActiveEx(true) + tableInsert(self.BtnTabs, tmpBtnTabs[i]) + else + tmpBtnTabs[i].gameObject:SetActiveEx(false) + end + end + self.PanelLamp:Init(self.BtnTabs, function (index) self:OnBtnTabClick(index) end) +end + +function XUiCoupletGame:OnBtnTabClick(index) + if index == self.CurrentSelectIndex then + return + end + + if XDataCenter.CoupletGameManager.CheckCoupletIsOpen(index) then + local coupletTemplate = XDataCenter.CoupletGameManager.GetCoupletTemplateByIndex(index) + self.PanelCoupletStageCtrl:Refresh(coupletTemplate.Id) + self.PanelCoupletRoll:Refresh(coupletTemplate.Id) + self.CurrentSelectIndex = index + self:PlayAnimation("QieHuan") + else + local lastCoupletName = XDataCenter.CoupletGameManager.GetLastCoupletName(index) + XUiManager.TipError(CSXTextManagerGetText("CoupletGameNotOpen", lastCoupletName)) + end +end + +function XUiCoupletGame:RefreshBtnTab() + local coupletTemplates = XDataCenter.CoupletGameManager.GetCoupletTemplates() + + for index, btnTab in pairs(self.BtnTabs) do + btnTab:SetNameByGroup(0, coupletTemplates[index].TitleName) + local isOpen = XDataCenter.CoupletGameManager.CheckCoupletIsOpen(index) + btnTab:SetDisable(not isOpen) + + local isNeedRedPoint = XDataCenter.CoupletGameManager.CheckPlayVideoRedPoint(coupletTemplates[index].Id) + btnTab:ShowReddot(isNeedRedPoint) + + if self.CurrentSelectIndex and self.CurrentSelectIndex == index then + btnTab:SetButtonState(XUiButtonState.Select) + end + end +end + +function XUiCoupletGame:RefreshTitle() + local title, titleEn = XDataCenter.CoupletGameManager.GetActivityTitle() + self.TxtTitle.text = title + self.TxtTitleEn.text = titleEn +end + +function XUiCoupletGame:OnBtnRewardClick() + self:OpenChildUi("UiCoupletAward") +end + +function XUiCoupletGame:RefreshRewardProcess() + local takeNum, count = XDataCenter.CoupletGameManager.GetRewardProcess() + self.TxtRewardPorcess.text = string.format("%s%s%s", takeNum, "/", count) +end + +function XUiCoupletGame:CheckHitFaceHelp() + local hitFaceData = XSaveTool.GetData(string.format( "%s%s", XCoupletGameConfigs.COUPLET_GAME_HELP_HIT_KEY, XPlayer.Id)) + if not hitFaceData or hitFaceData == XCoupletGameConfigs.HitFaceHelpState.NotHit then + local helpId = XDataCenter.CoupletGameManager.GetHelpId() + local template = XHelpCourseConfig.GetHelpCourseTemplateById(helpId) + XUiManager.ShowHelpTip(template.Function) + XSaveTool.SaveData(string.format( "%s%s", XCoupletGameConfigs.COUPLET_GAME_HELP_HIT_KEY, XPlayer.Id), XCoupletGameConfigs.HitFaceHelpState.Hited) + end +end + +function XUiCoupletGame:CheckHitFaceVideo() + local hitFaceVideoData = XSaveTool.GetData(string.format( "%s%s", XCoupletGameConfigs.COUPLET_GAME_VIDEO_HIT_KEY, XPlayer.Id)) + if not hitFaceVideoData or hitFaceVideoData == XCoupletGameConfigs.HitFaceVideoState.UnPlay then + local hitFaceStoryId = XDataCenter.CoupletGameManager.GetHitFaceStoryId() + if hitFaceStoryId and hitFaceStoryId ~= "" then + XDataCenter.MovieManager.PlayMovie(hitFaceStoryId, function () + XSaveTool.SaveData(string.format( "%s%s", XCoupletGameConfigs.COUPLET_GAME_VIDEO_HIT_KEY, XPlayer.Id), XCoupletGameConfigs.HitFaceVideoState.Played) + self:CheckHitFaceHelp() + end) + end + end +end + +function XUiCoupletGame:InitRedPoint() + self.RewardRedPointId = XRedPointManager.AddRedPointEvent(self.BtnBox, self.OnCheckBtnBoxRedPoint, self, { XRedPointConditions.Types.CONDITION_COUPLET_GAME_REWARD_TASK }, nil, true) +end + +function XUiCoupletGame:OnCheckBtnBoxRedPoint(count) + self.BtnBox:ShowReddot(count >= 0) +end + +function XUiCoupletGame:StartActivityTimer() + local timeId = XDataCenter.CoupletGameManager.GetActivityTimeId() + local startTime, endTime = XFunctionManager.GetTimeByTimeId(timeId) + local nowTime = XTime.GetServerNowTimestamp() + self.TxtTime.text = XUiHelper.GetTime(endTime - nowTime, XUiHelper.TimeFormatType.ACTIVITY) + if nowTime < startTime then + self.TxtTime.text = CSXTextManagerGetText("CoupletGameActivityNotOpen") + elseif nowTime > endTime then + self.TxtTime.text = CSXTextManagerGetText("CoupletGameActivityEnd") + else + self.ActivityTimer = XScheduleManager.ScheduleForever(function() + local time = XTime.GetServerNowTimestamp() + if time > endTime then + XUiManager.TipError(CSXTextManagerGetText("CoupletGameActivityEnd")) + self:StopActivityTimer() + XLuaUiManager.RunMain() + return + end + self.TxtTime.text = XUiHelper.GetTime(endTime - time, XUiHelper.TimeFormatType.ACTIVITY) + end, XScheduleManager.SECOND, 0) + end +end + +function XUiCoupletGame:StopActivityTimer() + if self.ActivityTimer then + XScheduleManager.UnSchedule(self.ActivityTimer) + self.ActivityTimer = nil + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCoupletGame/XUiCoupletRollPanel.lua b/Resources/Scripts/XUi/XUiCoupletGame/XUiCoupletRollPanel.lua new file mode 100644 index 00000000..b1339c8b --- /dev/null +++ b/Resources/Scripts/XUi/XUiCoupletGame/XUiCoupletRollPanel.lua @@ -0,0 +1,233 @@ +local tableInsert = table.insert +local UICamera = CS.XUiManager.Instance.UiCamera + +local XUiCoupletRollPanel = XClass(nil, "XUiCoupletRollPanel") + +-- local XUiGridWordImage = require("XUi/XUiCoupletGame/XUiGridWordImage") +local XUiGridWordItem = require("XUi/XUiCoupletGame/XUiGridWordItem") + +function XUiCoupletRollPanel:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RectTransform = ui + self.RootUi = rootUi + XTool.InitUiObject(self) + self:Init() +end + +function XUiCoupletRollPanel:Init() + self.WordMoveLimitX = (self.PanelRightRoll.rect.width - self.DragWordItem.transform.rect.width)/2 + self.WordMoveLimitY = (self.PanelRightRoll.rect.height - self.DragWordItem.transform.rect.height)/2 + + self.CoupletWords = {} + self.TopWordImagePool = {} + self.DownWordImagePool = {} + self.TopWordItemPool = {} + self.DownWordItemPool = {} + self.DragItem = nil + self.CurDragWordIndex = 0 +end + +function XUiCoupletRollPanel:Refresh(coupletId, isSelfChanged) + self.CurCoupletId = coupletId + self:RefreshUpWords(coupletId) + self:RefreshDownWords(coupletId, isSelfChanged) +end + +function XUiCoupletRollPanel:RefreshUpWords(coupletId) + -- local upWords = XCoupletGameConfigs.GetCoupletUpWordsId(coupletId) + -- local halfCount = #upWords / 2 + -- local _, remainder = math.modf(halfCount) + -- if remainder > 0 then + -- halfCount = math.ceil(halfCount) + -- end + + -- local topDatas = {} + -- local downDatas = {} + -- for index, wordId in ipairs(upWords) do + -- if index <= halfCount then + -- tableInsert(topDatas, wordId) + -- else + -- tableInsert(downDatas, wordId) + -- end + -- end + -- local onCreate = function(item, data) + -- item:SetActiveEx(true) + -- item:SetData(data) + -- end + + -- XUiHelper.CreateTemplates(self, self.TopWordImagePool, topDatas, XUiGridWordImage.New, self.WordImageItem.gameObject, self.PanelLeftRollTop, onCreate) + -- XUiHelper.CreateTemplates(self, self.DownWordImagePool, downDatas, XUiGridWordImage.New, self.WordImageItem.gameObject, self.PanelLeftRollDown, onCreate) + self.RImgUp.gameObject:SetActiveEx(true) + self.RImgUp:SetRawImage(XCoupletGameConfigs.GetCoupletUpImgUrl(coupletId)) +end + +function XUiCoupletRollPanel:RefreshDownWords(coupletId, isSelfChanged, getWordIndex) + if XDataCenter.CoupletGameManager.GetCoupletGameStatus(coupletId) == XCoupletGameConfigs.CouPletStatus.Complete then -- 已经完成 + self.PanelRightRollTop.gameObject:SetActiveEx(false) + self.PanelRightRollDown.gameObject:SetActiveEx(false) + self.RImgDown.gameObject:SetActiveEx(true) + self.RImgDown:SetRawImage(XCoupletGameConfigs.GetCoupletDownImgUrl(coupletId)) + if isSelfChanged then + self.RootUi:PlayAnimation("RImgDownEnable") + end + else + self.PanelRightRollTop.gameObject:SetActiveEx(true) + self.PanelRightRollDown.gameObject:SetActiveEx(true) + self.RImgDown.gameObject:SetActiveEx(false) + local downWords = XDataCenter.CoupletGameManager.GetDownWordsDataById(coupletId) + local halfCount = #downWords / 2 + local _, remainder = math.modf(halfCount) + if remainder > 0 then + halfCount = math.ceil(halfCount) + end + + local topDatas = {} + local downDatas = {} + for index, wordId in ipairs(downWords) do + if index <= halfCount then + tableInsert(topDatas, {Id = wordId, Index = index}) + else + tableInsert(downDatas, {Id = wordId, Index = index}) + end + end + local onCreate = function(item, data) + item:SetActiveEx(true) + item:OnCreate(data) + item:SetOnDragCallBack(function() self:OnWordDrag(data) end) + item:SetOnDragUpCallBack(function () self:OnWordUp() end) + self.CoupletWords[data.Index] = item + if getWordIndex and getWordIndex == data.Index then + item:PlayGetWordAnimation() + end + end + + XUiHelper.CreateTemplates(self, self.TopWordItemPool, topDatas, XUiGridWordItem.New, self.WordItem.gameObject, self.PanelRightRollTop, onCreate) + XUiHelper.CreateTemplates(self, self.DownWordItemPool, downDatas, XUiGridWordItem.New, self.WordItem.gameObject, self.PanelRightRollDown, onCreate) + end +end + +function XUiCoupletRollPanel:ShowWordEffectError() + for _, item in pairs(self.CoupletWords) do + if not XDataCenter.CoupletGameManager.CheckWordIsCorrect(self.CurCoupletId, item.Data.Index, item.Data.Id) then + item:SetEffectErrorActiveEx(false) + item:SetEffectErrorActiveEx(true) + end + end +end + +function XUiCoupletRollPanel:OnWordDrag(data) + if XDataCenter.CoupletGameManager.GetCoupletGameStatus(self.CurCoupletId) == XCoupletGameConfigs.CouPletStatus.Complete + or not XDataCenter.CoupletGameManager.CheckCoupletIsCheckComplete(self.CurCoupletId) then + return + end + + local wordIndex = data.Index + if self.LastClickIndex and self.LastClickIndex ~= wordIndex then + self.CoupletWords[self.LastClickIndex].LongClickHandle:Reset() + self:RefreshDownWords(self.CurCoupletId) + self.LastClickIndex = nil + end + + if not data then + return + end + + if not self.DragItem then -- 第一次进入拖拽 没有拖拽的文字 + self.CurDragIndex = wordIndex + self.NearestIndex = nil + self.CoupletWords[wordIndex]:DontShow(false) -- 隐藏该文字 + self.DragItem = self.DragWordItem + self.DragItem.gameObject:SetActiveEx(true) + self.DragItem:SetRawImage(XCoupletGameConfigs.GetCoupletWordImageById(self.CoupletWords[wordIndex].Data.Id)) + self.DragItem.gameObject.transform.localPosition = self:GetPosition() + self.LastClickIndex = wordIndex + else -- 持续更新拖拽的碎片位置 + self.DragItem.gameObject.transform.localPosition = self:GetPosition() + local nearestIndex = 0 + nearestIndex = self:CalculateNearestWordIndex() + if not self.NearestIndex then + self.NearestIndex = nearestIndex + self.CoupletWords[nearestIndex]:SetLight(true) + else + if self.NearestIndex ~= nearestIndex then + self.CoupletWords[self.NearestIndex]:SetLight(false) + self.NearestIndex = nearestIndex + self.CoupletWords[nearestIndex]:SetLight(true) + end + end + end +end + +function XUiCoupletRollPanel:GetPosition() + local screenPoint + if CS.UnityEngine.Application.platform == CS.UnityEngine.RuntimePlatform.WindowsEditor or CS.UnityEngine.Application.platform == CS.UnityEngine.RuntimePlatform.WindowsPlayer then + screenPoint = CS.UnityEngine.Vector2(CS.UnityEngine.Input.mousePosition.x, CS.UnityEngine.Input.mousePosition.y) + else + screenPoint = CS.UnityEngine.Input.GetTouch(0).position + end + + -- 设置拖拽 + local hasValue, v2 = CS.UnityEngine.RectTransformUtility.ScreenPointToLocalPointInRectangle(self.PanelRightRoll, screenPoint, UICamera) + if hasValue then + local x = v2.x + local y = v2.y + if x < -self.WordMoveLimitX then x = -self.WordMoveLimitX elseif x > self.WordMoveLimitX then x = self.WordMoveLimitX end + if y < -self.WordMoveLimitY then y = -self.WordMoveLimitY elseif y > self.WordMoveLimitY then y = self.WordMoveLimitY end + return CS.UnityEngine.Vector3(x, y, 0) + else + return CS.UnityEngine.Vector3.zero + end +end + +function XUiCoupletRollPanel:OnWordUp() + if XDataCenter.CoupletGameManager.GetCoupletGameStatus(self.CurCoupletId) == XCoupletGameConfigs.CouPletStatus.Complete + or not XDataCenter.CoupletGameManager.CheckCoupletIsCheckComplete(self.CurCoupletId) then + return + end + + if not self.NearestIndex then -- 点击抬起过快可能导致NearestIndex为空 + self:RefreshDownWords(self.CurCoupletId) + if self.DragItem then + self.DragItem.gameObject:SetActiveEx(false) + self.DragItem = nil + self.LastClickIndex = nil + end + return + end + + if self.DragItem then + self.DragItem.gameObject:SetActiveEx(false) + self.DragItem = nil + self.LastClickIndex = nil + self.CoupletWords[self.NearestIndex]:SetLight(false) + XDataCenter.CoupletGameManager.ChangeWord(self.CurDragIndex, self.NearestIndex) + self.CurDragIndex = nil + self.NearestIndex = nil + end +end + +function XUiCoupletRollPanel:CalculateNearestWordIndex() + local nearestIndex = 0 + local nearestDistance = 0 + for index, wordItem in ipairs(self.CoupletWords) do + local x1 = self.DragItem.gameObject.transform.position.x + local y1 = self.DragItem.gameObject.transform.position.y + local x2 = wordItem.Transform.position.x + local y2 = wordItem.Transform.position.y + local distance = (y2-y1)^2 + (x2-x1)^2 + if nearestDistance == 0 then + nearestIndex = index + nearestDistance = distance + else + if distance < nearestDistance then + nearestIndex = index + nearestDistance = distance + end + end + end + + return nearestIndex +end + +return XUiCoupletRollPanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCoupletGame/XUiCoupletStageCtrlPanel.lua b/Resources/Scripts/XUi/XUiCoupletGame/XUiCoupletStageCtrlPanel.lua new file mode 100644 index 00000000..67835721 --- /dev/null +++ b/Resources/Scripts/XUi/XUiCoupletGame/XUiCoupletStageCtrlPanel.lua @@ -0,0 +1,109 @@ +local XUiCoupletStageCtrlPanel = XClass(nil, "XUiCoupletStageCtrlPanel") + +local CoupleteStatus = { + GetWord = 1, + CheckComplete = 2, + Complete = 3, +} + +function XUiCoupletStageCtrlPanel:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RectTransform = ui + self.RootUi = rootUi + XTool.InitUiObject(self) + self:Init() +end + +function XUiCoupletStageCtrlPanel:Init() + self:AutoRegisterBtn() + local cousumeItemId = XDataCenter.CoupletGameManager.GetConsumeItemId() + local itemIcon = XDataCenter.ItemManager.GetItemIcon(cousumeItemId) + self.ImgItem:SetRawImage(itemIcon) +end + +function XUiCoupletStageCtrlPanel:Refresh(coupletId, isSelfChanged) + self.CurCoupletId = coupletId + if XDataCenter.CoupletGameManager.GetCoupletGameStatus(coupletId) == XCoupletGameConfigs.CouPletStatus.Complete then + self:SetStatus(CoupleteStatus.Complete) + self:SetBatchImage(false) + if isSelfChanged then self.RootUi:PlayAnimation("UiQieHuan") end + else + if XDataCenter.CoupletGameManager.CheckCoupletIsCheckComplete(coupletId) then + self:SetStatus(CoupleteStatus.CheckComplete) + if isSelfChanged then self.RootUi:PlayAnimation("UiQieHuan") end + else + self:SetStatus(CoupleteStatus.GetWord) + if XDataCenter.CoupletGameManager.CheckCanExchangeWord() then + self.TxtConsumeNum.text = XCoupletGameConfigs.GetCoupletTemplateById(coupletId).ItemConsumeCount + else + self.TxtConsumeNum.text = CsXTextManagerGetText("CoupletGameConsumeCount", XCoupletGameConfigs.GetCoupletTemplateById(coupletId).ItemConsumeCount) + end + end + self:SetBatchImage(true) + end + self.BtnPlayVideo:ShowReddot(XDataCenter.CoupletGameManager.CheckPlayVideoRedPoint(self.CurCoupletId)) +end + +function XUiCoupletStageCtrlPanel:AutoRegisterBtn() + self.BtnComplete.CallBack = function () self:OnBtnCompleteClick() end + self.BtnPlayVideo.CallBack = function () self:OnBtnPlayVideo() end +end + +function XUiCoupletStageCtrlPanel:SetStatus(status) + if status == CoupleteStatus.GetWord then + self.PanelStageOne.gameObject:SetActiveEx(true) + self.PanelStageTwo.gameObject:SetActiveEx(false) + self.PanelStageThree.gameObject:SetActiveEx(false) + self.PanelPhaseOne.gameObject:SetActiveEx(true) + self.PanelPhaseTwo.gameObject:SetActiveEx(false) + self.PanelPhaseThree.gameObject:SetActiveEx(false) + elseif status == CoupleteStatus.CheckComplete then + self.PanelStageOne.gameObject:SetActiveEx(false) + self.PanelStageTwo.gameObject:SetActiveEx(true) + self.PanelStageThree.gameObject:SetActiveEx(false) + self.PanelPhaseOne.gameObject:SetActiveEx(false) + self.PanelPhaseTwo.gameObject:SetActiveEx(true) + self.PanelPhaseThree.gameObject:SetActiveEx(false) + elseif status == CoupleteStatus.Complete then + self.PanelStageOne.gameObject:SetActiveEx(false) + self.PanelStageTwo.gameObject:SetActiveEx(false) + self.PanelStageThree.gameObject:SetActiveEx(true) + self.PanelPhaseOne.gameObject:SetActiveEx(false) + self.PanelPhaseTwo.gameObject:SetActiveEx(false) + self.PanelPhaseThree.gameObject:SetActiveEx(true) + end +end + +function XUiCoupletStageCtrlPanel:OnBtnCompleteClick() + if not self.CurCoupletId then + return + end + + XDataCenter.CoupletGameManager.CompleteCoupletSentence() +end + +function XUiCoupletStageCtrlPanel:OnBtnPlayVideo() + if not self.CurCoupletId then + return + end + + local coupletTemplate = XCoupletGameConfigs.GetCoupletTemplateById(self.CurCoupletId) + XDataCenter.MovieManager.PlayMovie(coupletTemplate.StoryStr) + XSaveTool.SaveData(string.format("%s%s%s", XCoupletGameConfigs.PLAY_VIDEO_STATE_KEY, XPlayer.Id, self.CurCoupletId), XCoupletGameConfigs.PlayVideoState.Played) + self.BtnPlayVideo:ShowReddot(false) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_COUPLET_GAME_PLAYED_VIDEO) + XEventManager.DispatchEvent(XEventId.EVENT_COUPLET_GAME_PLAYED_VIDEO) +end + +function XUiCoupletStageCtrlPanel:SetBatchImage(isDefault) + if isDefault then + local defaultBatch = XCoupletGameConfigs.GetCoupletDefaultBatch(self.CurCoupletId) + self.ImgBatch:SetRawImage(defaultBatch) + else + local batchImage = XCoupletGameConfigs.GetCoupletBatch(self.CurCoupletId) + self.ImgBatch:SetRawImage(batchImage) + end +end + +return XUiCoupletStageCtrlPanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCoupletGame/XUiGridCoupletTask.lua b/Resources/Scripts/XUi/XUiCoupletGame/XUiGridCoupletTask.lua new file mode 100644 index 00000000..15fdcb40 --- /dev/null +++ b/Resources/Scripts/XUi/XUiCoupletGame/XUiGridCoupletTask.lua @@ -0,0 +1,73 @@ +local CSXTextManagerGetText = CS.XTextManager.GetText + +local XUiGridCoupletTask = XClass(nil, "XUiGridCoupletTask") + +function XUiGridCoupletTask:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RectTransform = ui + XTool.InitUiObject(self) +end + +function XUiGridCoupletTask:Init(rootUi) + self.RootUi = rootUi + self:AutoRegisterBtn() + self.RewardPanelList = {} +end + +function XUiGridCoupletTask:UpdateGrid(data) + self.Data = data + self.TaskConfig = XTaskConfig.GetTaskCfgById(data.Id) + self.TxtGrade.text = self.TaskConfig.Title + self.TxtTaskDescribe.text = self.TaskConfig.Desc + self.TxtTaskNumQian.text = CSXTextManagerGetText("CoupletGameTaskNumProcess", data.Schedule[1].Value, self.TaskConfig.Result) + self.ImgProgress.fillAmount = data.Schedule[1].Value / self.TaskConfig.Result + + local rewards = XRewardManager.GetRewardList(self.TaskConfig.RewardId) + for i = 1, #rewards do + local panel = self.RewardPanelList[i] + if not panel then + if #self.RewardPanelList == 0 then + panel = XUiGridCommon.New(self.RootUi, self.GridCommon) + else + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommon) + ui.transform:SetParent(self.GridCommon.parent, false) + panel = XUiGridCommon.New(self.RootUi, ui) + end + table.insert(self.RewardPanelList, panel) + end + panel:Refresh(rewards[i]) + end + + self:SetState(data.State) +end + +function XUiGridCoupletTask:SetState(state) + if state == XDataCenter.TaskManager.TaskState.Active then + self.ImgCannotReceive.gameObject:SetActiveEx(true) + self.ImgAlreadyReceived.gameObject:SetActiveEx(false) + self.BtnReceive.gameObject:SetActiveEx(false) + elseif state == XDataCenter.TaskManager.TaskState.Achieved then + self.ImgCannotReceive.gameObject:SetActiveEx(false) + self.ImgAlreadyReceived.gameObject:SetActiveEx(false) + self.BtnReceive.gameObject:SetActiveEx(true) + elseif state == XDataCenter.TaskManager.TaskState.Finish then + self.ImgCannotReceive.gameObject:SetActiveEx(false) + self.ImgAlreadyReceived.gameObject:SetActiveEx(true) + self.BtnReceive.gameObject:SetActiveEx(false) + end +end + +function XUiGridCoupletTask:AutoRegisterBtn() + self.BtnReceive.CallBack = function () self:OnClickBtnReceive() end +end + +function XUiGridCoupletTask:OnClickBtnReceive() + if not self.Data then + return + end + + XDataCenter.CoupletGameManager.FinishTask(self.Data.Id) +end + +return XUiGridCoupletTask \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCoupletGame/XUiGridWordImage.lua b/Resources/Scripts/XUi/XUiCoupletGame/XUiGridWordImage.lua new file mode 100644 index 00000000..9d19ed3c --- /dev/null +++ b/Resources/Scripts/XUi/XUiCoupletGame/XUiGridWordImage.lua @@ -0,0 +1,25 @@ +local XUiGridWordImage = XClass(nil, "XUiGridWordImage") + +function XUiGridWordImage:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RectTransform = ui + self.RootUi = rootUi + XTool.InitUiObject(self) + self:Init() +end + +function XUiGridWordImage:Init() + +end + +function XUiGridWordImage:SetData(data) + local imageWord = XCoupletGameConfigs.GetCoupletWordImageById(data) + self.ImgOpen:SetRawImage(imageWord) +end + +function XUiGridWordImage:SetActiveEx(bool) + self.GameObject:SetActiveEx(bool) +end + +return XUiGridWordImage \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiCoupletGame/XUiGridWordItem.lua b/Resources/Scripts/XUi/XUiCoupletGame/XUiGridWordItem.lua new file mode 100644 index 00000000..2c14cb8f --- /dev/null +++ b/Resources/Scripts/XUi/XUiCoupletGame/XUiGridWordItem.lua @@ -0,0 +1,98 @@ +local XUiGridWordItem = XClass(nil, "XUiGridWordItem") + +function XUiGridWordItem:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RectTransform = ui + self.RootUi = rootUi + XTool.InitUiObject(self) + self:Init() +end + +function XUiGridWordItem:Init() + self:AutoRegisterBtn() + XUiButtonLongClick.New(self.Pointer, 5, self, nil, function() + if self.OnDragCallBack then self.OnDragCallBack() end + end, function() + if self.OnDragUpCallBack then self.OnDragUpCallBack() end + end, false) + self.ImgChoce.gameObject:SetActiveEx(false) + self.EffectOpen.gameObject:SetActiveEx(false) + self:SetEffectPromptActiveEx(false) + self:SetEffectErrorActiveEx(false) + self.OnDragCallBack = nil + self.OnDragUpCallBack = nil + self.EffectDelayTime = XDataCenter.CoupletGameManager.GetEffectOpenDelay() +end + +function XUiGridWordItem:OnCreate(data) + self.ImgChoce.gameObject:SetActiveEx(false) + self:SetEffectErrorActiveEx(false) + self.Data = data + if data.Id == 0 then + self.ImgUnder.gameObject:SetActiveEx(false) + self.RawImage.gameObject:SetActiveEx(false) + self.BtnChars.gameObject:SetActiveEx(true) + self:SetEffectPromptActiveEx(XDataCenter.CoupletGameManager.CheckCanExchangeWord()) + else + self.ImgUnder.gameObject:SetActiveEx(true) + self.RawImage.gameObject:SetActiveEx(true) + self.BtnChars.gameObject:SetActiveEx(false) + local imageWord = XCoupletGameConfigs.GetCoupletWordImageById(data.Id) + self.RawImage:SetRawImage(imageWord) + self:SetEffectPromptActiveEx(false) + end +end + +function XUiGridWordItem:SetOnDragCallBack(cb) + self.OnDragCallBack = cb +end + +function XUiGridWordItem:SetOnDragUpCallBack(cb) + self.OnDragUpCallBack = cb +end + +function XUiGridWordItem:SetActiveEx(bool) + self.GameObject:SetActiveEx(bool) +end + +function XUiGridWordItem:DontShow() + self.RawImage.gameObject:SetActiveEx(false) + self.BtnChars.gameObject:SetActiveEx(false) +end + +function XUiGridWordItem:SetLight(bool) + self.ImgChoce.gameObject:SetActiveEx(bool) +end + +function XUiGridWordItem:SetEffectPromptActiveEx(bool) + self.EffectPrompt.gameObject:SetActiveEx(bool) +end + +function XUiGridWordItem:SetEffectErrorActiveEx(bool) + self.EffectError.gameObject:SetActiveEx(bool) +end + +function XUiGridWordItem:PlayGetWordAnimation() + self.RawImageEnable.gameObject:PlayTimelineAnimation() +end + +function XUiGridWordItem:AutoRegisterBtn() + self.BtnChars.CallBack = function () self:OnBtnChatsClick() end +end + +function XUiGridWordItem:OnBtnChatsClick() + if not self.Data then + return + end + + XDataCenter.CoupletGameManager.GetCoupletWord(self.Data.Index, function () + self.EffectOpen.gameObject:SetActiveEx(true) + XScheduleManager.ScheduleOnce(function () + XScheduleManager.ScheduleOnce(function () self.EffectOpen.gameObject:SetActiveEx(false) end, 500) -- 延迟关闭特效 + CsXGameEventManager.Instance:Notify(XEventId.EVENT_COUPLET_GAME_GET_WORD, self.Data.Index) + end, self.EffectDelayTime) + end) +end + +return XUiGridWordItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDialog/UiDialogDrag.lua b/Resources/Scripts/XUi/XUiDialog/UiDialogDrag.lua new file mode 100644 index 00000000..21f2ccfe --- /dev/null +++ b/Resources/Scripts/XUi/XUiDialog/UiDialogDrag.lua @@ -0,0 +1,134 @@ +local XUiDialogDrag = XLuaUiManager.Register(XLuaUi, "UiDialogDrag") + +function XUiDialogDrag:OnAwake() + self:AutoAddListener() +end + +function XUiDialogDrag:OnStart(title, content, dialogType, closeCallback, sureCallback, data) + ---- 处理额外参数 ----- + local ItemIds, sureText, closeText + if data then + ItemIds = {data.ItemId1, data.ItemId2, data.ItemId3} + sureText = data.sureText + closeText = data.closeText + end + + if ItemIds and #ItemIds > 0 then + self.PanelActivityAsset.gameObject:SetActive(true) + XUiPanelAsset.New(self, self.PanelActivityAsset, ItemIds[1], ItemIds[2], ItemIds[3]) + else + self.PanelActivityAsset.gameObject:SetActive(false) + end + + if sureText then + self.BtnConfirm:SetNameByGroup(0, sureText) + self.BtnConfirmB:SetNameByGroup(0, sureText) + end + + if closeText then + self.BtnClose:SetNameByGroup(0, closeText) + self.BtnCloseA:SetNameByGroup(0, closeText) + end + ---- end ----- + + self:HideDialogLayer() + if title then + self.TxtTitle.text = title + end + + if dialogType == XUiManager.DialogType.Normal then + self.PanelDialog.gameObject:SetActive(true) + self.TxtInfoNormal.text = string.gsub(content, "\\n", "\n") + self:PlayAnimation("DialogEnable") + elseif dialogType == XUiManager.DialogType.OnlySure then + self.PanelSureDialog.gameObject:SetActive(true) + self.TxtInfoSure.text = string.gsub(content, "\\n", "\n") + self:PlayAnimation("SureDialogEnable") + elseif dialogType == XUiManager.DialogType.OnlyClose then + self.PanelCloseDialog.gameObject:SetActive(true) + self.TxtInfoClose.text = string.gsub(content, "\\n", "\n") + self:PlayAnimation("CloseDialogEnable") + elseif dialogType == XUiManager.DialogType.NoBtn then + self.PanelDialog.gameObject:SetActive(true) + self.BtnConfirm.gameObject:SetActive(false) + self.BtnClose.gameObject:SetActive(false) + self.TxtInfoNormal.text = string.gsub(content, "\\n", "\n") + self:PlayAnimation("DialogEnable") + elseif dialogType == XUiManager.DialogType.NormalAndNoBtnTanchuangClose then + self.BtnTanchuangClose.gameObject:SetActive(false) + self.PanelDialog.gameObject:SetActive(true) + self.TxtInfoNormal.text = string.gsub(content, "\\n", "\n") + self:PlayAnimation("DialogEnable") + end + self.OkCallBack = sureCallback + self.CancelCallBack = closeCallback +end + +function XUiDialogDrag:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiGridArenaStage:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiGridArenaStage:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiDialogDrag:AutoAddListener() + self:RegisterClickEvent(self.BtnConfirmB, self.OnBtnConfirmBClick) + self:RegisterClickEvent(self.BtnCloseA, self.OnBtnCloseAClick) + self:RegisterClickEvent(self.BtnConfirm, self.OnBtnConfirmClick) + self:RegisterClickEvent(self.BtnClose, self.OnBtnCloseClick) + self:RegisterClickEvent(self.BtnTanchuangClose, self.OnBtnCloseClick) +end + +function XUiDialogDrag:HideDialogLayer() + self.PanelDialog.gameObject:SetActive(false) + self.PanelCloseDialog.gameObject:SetActive(false) + self.PanelSureDialog.gameObject:SetActive(false) +end + +function XUiDialogDrag:OnBtnCloseAClick() + self:CancelBtnClick() +end + +function XUiDialogDrag:OnBtnConfirmBClick() + self:OkBtnClick() +end + +function XUiDialogDrag:OnBtnConfirmClick() + self:OkBtnClick() +end + +function XUiDialogDrag:OnBtnCloseClick() + self:CancelBtnClick() +end + +function XUiDialogDrag:OkBtnClick() + CsXUiManager.Instance:Close("UiDialogDrag") + if self.OkCallBack then + self.OkCallBack() + end + + self.OkCallBack = nil + self.CancelCallBack = nil +end + +function XUiDialogDrag:CancelBtnClick() + CsXUiManager.Instance:Close("UiDialogDrag") + if self.CancelCallBack then + self.CancelCallBack() + end + + self.OkCallBack = nil + self.CancelCallBack = nil +end + +return XUiDialogDrag diff --git a/Resources/Scripts/XUi/XUiDialog/XUiAssertDialog.lua b/Resources/Scripts/XUi/XUiDialog/XUiAssertDialog.lua new file mode 100644 index 00000000..1c125c76 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDialog/XUiAssertDialog.lua @@ -0,0 +1,28 @@ +local XUiAssertDialog = XLuaUiManager.Register(XLuaUi, "UiAssertDialog") + +function XUiAssertDialog:OnAwake() + self:AutoAddListener() +end + +function XUiAssertDialog:OnStart(title, content, dialogType, closeCallback, sureCallback) + self.TxtInfo.text = content + self.OkCallBack = sureCallback + self.CancelCallBack = closeCallback +end + +function XUiAssertDialog:AutoAddListener() + self.BtnConfirm.CallBack = function() + self:OnBtnConfirmClick() + end +end + +function XUiAssertDialog:OnBtnConfirmClick() + self:Close() + + if self.OkCallBack then + self.OkCallBack() + end + + self.OkCallBack = nil + self.CancelCallBack = nil +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDialog/XUiCueMark.lua b/Resources/Scripts/XUi/XUiDialog/XUiCueMark.lua new file mode 100644 index 00000000..99e8e9be --- /dev/null +++ b/Resources/Scripts/XUi/XUiDialog/XUiCueMark.lua @@ -0,0 +1,68 @@ +local stringGsub = string.gsub + +local XUiCueMark = XLuaUiManager.Register(XLuaUi, "UiCueMark") + +function XUiCueMark:OnAwake() + self:AutoAddListener() +end + +function XUiCueMark:OnStart(title, content, content2, closeCallback, sureCallback, hintInfo) + if title then + self.TxtTitle.text = title + self.TxtTitle.gameObject:SetActiveEx(true) + else + self.TxtTitle.gameObject:SetActiveEx(false) + end + + if content then + self.TxtContent.text = content + self.TxtContent.gameObject:SetActiveEx(true) + else + self.TxtContent.gameObject:SetActiveEx(false) + end + + if content2 then + self.TxtContent2.text = content2 + self.TxtContent2.gameObject:SetActiveEx(true) + else + self.TxtContent2.gameObject:SetActiveEx(false) + end + + self.OkCallBack = sureCallback + self.CancelCallBack = closeCallback + + if hintInfo then + self.SetHintCb = hintInfo.SetHintCb + + local isSelect = hintInfo.Status == true + self.BtnHint:SetButtonState(isSelect and CS.UiButtonState.Select or CS.UiButtonState.Normal) + self.BtnHint.gameObject:SetActiveEx(true) + else + self.BtnHint.gameObject:SetActiveEx(false) + end +end + +function XUiCueMark:AutoAddListener() + self:RegisterClickEvent(self.BtnTcanchaungBlue, self.OnBtnConfirmClick) + self:RegisterClickEvent(self.BtnTcanchaungBlack, self.OnBtnCloseClick) + self:RegisterClickEvent(self.BtnTanchuangClose, self.OnBtnCloseClick) + self:RegisterClickEvent(self.BtnHint, self.OnBtnHintClick) +end + +function XUiCueMark:OnBtnConfirmClick() + self:Close() + if self.OkCallBack then + self.OkCallBack() + end +end + +function XUiCueMark:OnBtnCloseClick() + self:Close() +end + +function XUiCueMark:OnBtnHintClick() + local isSelect = self.BtnHint.ButtonState == CS.UiButtonState.Select + if self.SetHintCb then + self.SetHintCb(isSelect) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDialog/XUiDialog.lua b/Resources/Scripts/XUi/XUiDialog/XUiDialog.lua new file mode 100644 index 00000000..b38f4c59 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDialog/XUiDialog.lua @@ -0,0 +1,134 @@ +local XUiDialog = XLuaUiManager.Register(XLuaUi, "UiDialog") + +function XUiDialog:OnAwake() + self:AutoAddListener() +end + +function XUiDialog:OnStart(title, content, dialogType, closeCallback, sureCallback, data) + ---- 处理额外参数 ----- + local ItemIds, sureText, closeText + if data then + ItemIds = {data.ItemId1, data.ItemId2, data.ItemId3} + sureText = data.sureText + closeText = data.closeText + end + + if ItemIds and #ItemIds > 0 then + self.PanelActivityAsset.gameObject:SetActive(true) + XUiPanelAsset.New(self, self.PanelActivityAsset, ItemIds[1], ItemIds[2], ItemIds[3]) + else + self.PanelActivityAsset.gameObject:SetActive(false) + end + + if sureText then + self.BtnConfirm:SetNameByGroup(0, sureText) + self.BtnConfirmB:SetNameByGroup(0, sureText) + end + + if closeText then + self.BtnClose:SetNameByGroup(0, closeText) + self.BtnCloseA:SetNameByGroup(0, closeText) + end + ---- end ----- + + self:HideDialogLayer() + if title then + self.TxtTitle.text = title + end + + if dialogType == XUiManager.DialogType.Normal then + self.PanelDialog.gameObject:SetActive(true) + self.TxtInfoNormal.text = string.gsub(content, "\\n", "\n") + self:PlayAnimation("DialogEnable") + elseif dialogType == XUiManager.DialogType.OnlySure then + self.PanelSureDialog.gameObject:SetActive(true) + self.TxtInfoSure.text = string.gsub(content, "\\n", "\n") + self:PlayAnimation("SureDialogEnable") + elseif dialogType == XUiManager.DialogType.OnlyClose then + self.PanelCloseDialog.gameObject:SetActive(true) + self.TxtInfoClose.text = string.gsub(content, "\\n", "\n") + self:PlayAnimation("CloseDialogEnable") + elseif dialogType == XUiManager.DialogType.NoBtn then + self.PanelDialog.gameObject:SetActive(true) + self.BtnConfirm.gameObject:SetActive(false) + self.BtnClose.gameObject:SetActive(false) + self.TxtInfoNormal.text = string.gsub(content, "\\n", "\n") + self:PlayAnimation("DialogEnable") + elseif dialogType == XUiManager.DialogType.NormalAndNoBtnTanchuangClose then + self.BtnTanchuangClose.gameObject:SetActive(false) + self.PanelDialog.gameObject:SetActive(true) + self.TxtInfoNormal.text = string.gsub(content, "\\n", "\n") + self:PlayAnimation("DialogEnable") + end + self.OkCallBack = sureCallback + self.CancelCallBack = closeCallback +end + +function XUiDialog:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiGridArenaStage:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiGridArenaStage:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiDialog:AutoAddListener() + self:RegisterClickEvent(self.BtnConfirmB, self.OnBtnConfirmBClick) + self:RegisterClickEvent(self.BtnCloseA, self.OnBtnCloseAClick) + self:RegisterClickEvent(self.BtnConfirm, self.OnBtnConfirmClick) + self:RegisterClickEvent(self.BtnClose, self.OnBtnCloseClick) + self:RegisterClickEvent(self.BtnTanchuangClose, self.OnBtnCloseClick) +end + +function XUiDialog:HideDialogLayer() + self.PanelDialog.gameObject:SetActive(false) + self.PanelCloseDialog.gameObject:SetActive(false) + self.PanelSureDialog.gameObject:SetActive(false) +end + +function XUiDialog:OnBtnCloseAClick() + self:CancelBtnClick() +end + +function XUiDialog:OnBtnConfirmBClick() + self:OkBtnClick() +end + +function XUiDialog:OnBtnConfirmClick() + self:OkBtnClick() +end + +function XUiDialog:OnBtnCloseClick() + self:CancelBtnClick() +end + +function XUiDialog:OkBtnClick() + CsXUiManager.Instance:Close("UiDialog") + if self.OkCallBack then + self.OkCallBack() + end + + self.OkCallBack = nil + self.CancelCallBack = nil +end + +function XUiDialog:CancelBtnClick() + CsXUiManager.Instance:Close("UiDialog") + if self.CancelCallBack then + self.CancelCallBack() + end + + self.OkCallBack = nil + self.CancelCallBack = nil +end + +return XUiDialog diff --git a/Resources/Scripts/XUi/XUiDialog/XUiSystemDialog.lua b/Resources/Scripts/XUi/XUiDialog/XUiSystemDialog.lua new file mode 100644 index 00000000..89a23613 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDialog/XUiSystemDialog.lua @@ -0,0 +1,24 @@ + +local XUiDialog = require("XUi/XUiDialog/XUiDialog") + +local XUiSystemDialog = XLuaUiManager.Register(XUiDialog, "UiSystemDialog") + +function XUiSystemDialog:OkBtnClick() + self:Close() + if self.OkCallBack then + self.OkCallBack() + end + + self.OkCallBack = nil + self.CancelCallBack = nil +end + +function XUiSystemDialog:CancelBtnClick() + self:Close() + if self.CancelCallBack then + self.CancelCallBack() + end + + self.OkCallBack = nil + self.CancelCallBack = nil +end diff --git a/Resources/Scripts/XUi/XUiDorm/XUiBlackScreen/XUiBlackScreen.lua b/Resources/Scripts/XUi/XUiDorm/XUiBlackScreen/XUiBlackScreen.lua new file mode 100644 index 00000000..897e6444 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDorm/XUiBlackScreen/XUiBlackScreen.lua @@ -0,0 +1,39 @@ +-- 镜头黑幕界面 +local XUiBlackScreen = XLuaUiManager.Register(XLuaUi, "UiBlackScreen") + +local ADJUST_DISTANCE = 0.2 +local FADE_TIME = 0.1 +local DURATION_TIME = 0.25 + +function XUiBlackScreen:OnStart(targetTrans, isTweenCanmera, paramName, cb) + local distance + local cameraController = XHomeSceneManager.GetSceneCameraController() + + self.ImgBackground:DOFade(1, FADE_TIME):OnComplete(function() + if not XTool.UObjIsNil(cameraController) then + cameraController.IsTweenCamera = false + if paramName and string.len(paramName) > 0 then + cameraController:SetParam(paramName) + distance = cameraController.Distance + end + XCameraHelper.SetCameraTarget(cameraController, targetTrans, distance * (ADJUST_DISTANCE + 1)) + end + + if cb then + cb() + end + + local isCalled = false + self.ImgBackground:DOFade(0, FADE_TIME):SetDelay(DURATION_TIME):OnUpdate(function() + if not isCalled then + if not XTool.UObjIsNil(cameraController) then + cameraController.IsTweenCamera = isTweenCanmera + XCameraHelper.SetCameraTarget(cameraController, targetTrans, distance) + end + isCalled = true + end + end):OnComplete(function() + self:Close() + end) + end) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDorm/XUiDormCommom/XUiFurnitureScore.lua b/Resources/Scripts/XUi/XUiDorm/XUiDormCommom/XUiFurnitureScore.lua new file mode 100644 index 00000000..a316f222 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDorm/XUiDormCommom/XUiFurnitureScore.lua @@ -0,0 +1,34 @@ +-- 家具分数控件 +XUiFurnitureScore = XClass(nil, "XUiFurnitureScore") + +function XUiFurnitureScore:Ctor(rootUi, ui) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.GridAttributePool = {} + self.GridAttribute.gameObject:SetActive(false) +end + + +--设置分数 +function XUiFurnitureScore:SetScore(data) + if not data then + return + end + + local attributes = {} + for k, v in pairs(data) do + attributes[k] = { + Id = k, + Val = v + } + end + + XUiHelper.CreateTemplates(self.RootUi, self.GridAttributePool, attributes, XUiGridAttribute.New, self.GridAttribute, self.Transform, XUiGridAttribute.Init) + for i = 1, #attributes do + self.GridAttributePool[i].GameObject:SetActive(true) + end +end + +return XUiFurnitureScore \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDorm/XUiDormCommom/XUiGridAttribute.lua b/Resources/Scripts/XUi/XUiDorm/XUiDormCommom/XUiGridAttribute.lua new file mode 100644 index 00000000..9f428ca7 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDorm/XUiDormCommom/XUiGridAttribute.lua @@ -0,0 +1,84 @@ +XUiGridAttribute = XClass(nil, "XUiGridAttribute") +local attrColors = { + [1] = CS.XTextManager.GetText("FurnitureColorAttrA"), + [2] = CS.XTextManager.GetText("FurnitureColorAttrB"), + [3] = CS.XTextManager.GetText("FurnitureColorAttrC"), + +} + +function XUiGridAttribute:Ctor(rootUi, ui) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + self:InitAutoScript() +end + +function XUiGridAttribute:Init(data) + self:UpdateData(data) +end + +function XUiGridAttribute:UpdateData(data) + local attrTemplates = XFurnitureConfigs.GetDormFurnitureType(data.Id) + if attrTemplates == nil then return end + local score + if data.Id == XFurnitureConfigs.AttrType.AttrA then + score = XDataCenter.FurnitureManager.GetFurnitureRedScore(data.FurnitureId) + elseif data.Id == XFurnitureConfigs.AttrType.AttrB then + score = XDataCenter.FurnitureManager.GetFurnitureYellowScore(data.FurnitureId) + else + score = XDataCenter.FurnitureManager.GetFurnitureBlueScore(data.FurnitureId) + end + + self.TxtAttributeScore.text = score + if self.TxtAttributeName then + self.TxtAttributeName.text = string.format("%s", attrColors[data.Id], attrTemplates.TypeName) + end +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiGridAttribute:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiGridAttribute:AutoInitUi() + self.ImgAttributeIcon = self.Transform:Find("ImgAttributeIcon"):GetComponent("Image") + self.TxtAttributeName = self.Transform:Find("TxtAttributeName"):GetComponent("Text") + self.TxtAttributeScore = self.Transform:Find("TxtAttributeScore"):GetComponent("Text") +end + +function XUiGridAttribute:GetAutoKey(uiNode, eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiGridAttribute:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiGridAttribute:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiGridAttribute:AutoAddListener() + self.AutoCreateListeners = {} +end +-- auto +return XUiGridAttribute \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDorm/XUiDormCommom/XUiGridAttributeComparable.lua b/Resources/Scripts/XUi/XUiDorm/XUiDormCommom/XUiGridAttributeComparable.lua new file mode 100644 index 00000000..93b0dfda --- /dev/null +++ b/Resources/Scripts/XUi/XUiDorm/XUiDormCommom/XUiGridAttributeComparable.lua @@ -0,0 +1,26 @@ +XUiGridAttributeComparable = XClass(nil, "XUiGridAttributeComparable") + +function XUiGridAttributeComparable:Ctor(rootUi, ui) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) +end + +function XUiGridAttributeComparable:Init(data) + self:UpdateData(data) +end + + +function XUiGridAttributeComparable:UpdateData(data) + local attrTemplates = XFurnitureConfigs.GetDormFurnitureType(data.AttrKey) + if attrTemplates == nil then return end + self.RootUi:SetUiSprite(self.ImgAttributeIcon, attrTemplates.TypeIcon) + self.TxtAttributeScore.text = data.AttrNewVal + + self.ImgScoreDown.gameObject:SetActive(data.AttrOldVal > data.AttrNewVal) + self.ImgScoreUp.gameObject:SetActive(data.AttrOldVal < data.AttrNewVal) +end + +return XUiGridAttributeComparable \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDorm/XUiDormCommom/XUiRoomScore.lua b/Resources/Scripts/XUi/XUiDorm/XUiDormCommom/XUiRoomScore.lua new file mode 100644 index 00000000..909919c4 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDorm/XUiDormCommom/XUiRoomScore.lua @@ -0,0 +1,39 @@ +-- 房间分数控件 +XUiRoomScore = XClass(nil, "XUiRoomScore") + +function XUiRoomScore:Ctor(rootUi, ui) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.GridTypePool = {} + + XTool.InitUiObject(self) + +end + +function XUiRoomScore:SetScore(oldFurnitureAttrs, newFurnitureAttrs) + + local oldScores = oldFurnitureAttrs.TotalScore + local newScores = newFurnitureAttrs.TotalScore + + self.TxtTotalScore.text = newScores + + self.ImgScoreDown.gameObject:SetActive(newScores < oldScores) + self.ImgScoreUp.gameObject:SetActive(newScores > oldScores) + + local compareAttrs = {} + for i = 1, #oldFurnitureAttrs.AttrList do + compareAttrs[i] = { + AttrKey = i, + AttrOldVal = oldFurnitureAttrs.AttrList[i], + AttrNewVal = newFurnitureAttrs.AttrList[i] + } + end + + + XUiHelper.CreateTemplates(self.RootUi, self.GridTypePool, compareAttrs, XUiGridAttributeComparable.New, self.GridAttribute, self.PanelTxtGroup, XUiGridAttributeComparable.Init) + self.GridAttribute.gameObject:SetActive(false) +end + + +return XUiRoomScore \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDorm/XUiFurnitureBuild/XUiFurnitureBuild.lua b/Resources/Scripts/XUi/XUiDorm/XUiFurnitureBuild/XUiFurnitureBuild.lua new file mode 100644 index 00000000..ae4fe928 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDorm/XUiFurnitureBuild/XUiFurnitureBuild.lua @@ -0,0 +1,96 @@ +-- 家具建造主界面 +local XUiFurnitureBuild = XLuaUiManager.Register(XLuaUi, "UiFurnitureBuild") + +local TAB_TYPE_CREATE = 1--创造 +local TAB_TYPE_REFORM = 2--改装 + + +function XUiFurnitureBuild:OnAwake() + self.FurnitureCreateList = {} + local createNum = CS.XGame.Config:GetInt("DormFurnitureCreateNum") + for i = 1, createNum do + table.insert(self.FurnitureCreateList, i, { + Id = i, + Pos = i - 1 + }) + end + self:AddBtnsListeners() + self:BindHelpBtn(self.BtnHelp, "Dorm") +end + +function XUiFurnitureBuild:AddBtnsListeners() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) +end + +function XUiFurnitureBuild:OnStart(tabType, drawingId, furnitureTypeId) + self.PanelAsset = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.DormCoin, XDataCenter.ItemManager.ItemId.FurnitureCoin) + self.PanelCreate = XUiPanelCreate.New(self, self.PanelCreate) + self.PanelRefit = XUiPanelRefit.New(self, self.PanelRefit) + self.BtnTabList = {} + table.insert(self.BtnTabList, self.BtnCreate) + table.insert(self.BtnTabList, self.BtnRefit) + self.BtnGroup:Init(self.BtnTabList, function(index) self:SelectPanel(index) end) + + self.BtnCreate:SetNameByGroup(0, CS.XTextManager.GetText("FurntiureBuildCreateCH")) + self.BtnCreate:SetNameByGroup(1, CS.XTextManager.GetText("FurntiureBuildCreateEN")) + self.BtnRefit:SetNameByGroup(0, CS.XTextManager.GetText("FurnitureBuildRefitCH")) + self.BtnRefit:SetNameByGroup(1, CS.XTextManager.GetText("FurnitureBuildRefitEN")) + + self:Init(tabType or TAB_TYPE_CREATE, drawingId, furnitureTypeId) + + self.AnimBuildEnable:PlayTimelineAnimation() + self.BuildPointId = XRedPointManager.AddRedPointEvent(self.FurnitureBuildRedPoint, self.OnCheckBuildFurniture, self, { XRedPointConditions.Types.CONDITION_FURNITURE_CREATE }) +end + +function XUiFurnitureBuild:OnCheckBuildFurniture(count) + self.FurnitureBuildRedPoint.gameObject:SetActive(count >= 0) +end + +function XUiFurnitureBuild:OnDestroy() +end + +function XUiFurnitureBuild:Init(tabType, drawingId, furnitureTypeId) + self.PanelCreate:Init(self.FurnitureCreateList) + self.PanelRefit:Init(drawingId, furnitureTypeId) + self.BtnGroup:SelectIndex(tabType) +end + +function XUiFurnitureBuild:OnBtnBackClick() + self:Close() +end + +function XUiFurnitureBuild:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiFurnitureBuild:SelectPanel(index) + self.PanelCreate:SetPanelActive(index == TAB_TYPE_CREATE) + self.PanelRefit:SetPanelActive(index == TAB_TYPE_REFORM) +end + +function XUiFurnitureBuild:PlayAnimRefitEnable() + self.AnimRefitEnable:PlayTimelineAnimation() +end + +function XUiFurnitureBuild:PlayAnimInvestmentEnable() + self.AnimInvestmentEnable:PlayTimelineAnimation() +end + +function XUiFurnitureBuild:PlayAnimCreationDetailEnable() + self.AnimCreationDetailEnable:PlayTimelineAnimation() +end + +function XUiFurnitureBuild:PlayAnimCreationDetailDisable(callback) + self.AnimCreationDetailDisable:PlayTimelineAnimation(function() + if callback then callback() end + end) +end + +function XUiFurnitureBuild:OnEnable() + XDataCenter.DormManager.StartDormRedTimer() +end + +function XUiFurnitureBuild:OnDisable() + XDataCenter.DormManager.StopDormRedTimer() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDorm/XUiFurnitureBuild/XUiFurnitureCreate.lua b/Resources/Scripts/XUi/XUiDorm/XUiFurnitureBuild/XUiFurnitureCreate.lua new file mode 100644 index 00000000..bfc40071 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDorm/XUiFurnitureBuild/XUiFurnitureCreate.lua @@ -0,0 +1,419 @@ +-- 家具建造子界面 +local XUiFurnitureCreate = XLuaUiManager.Register(XLuaUi, "UiFurnitureCreate") + +function XUiFurnitureCreate:OnAwake() + self.GridInvestmentPool = {} + self.SelectTypeIds = nil + self.FurnitrueCreateCount = 0 +end + +function XUiFurnitureCreate:OnBtnCancelClick() + self:Close() +end + +function XUiFurnitureCreate:OnBtnStartClick() + if not self.SelectTypeIds or #self.SelectTypeIds <= 0 then + XUiManager.TipMsg(CS.XTextManager.GetText("FurnitureChooseAType")) + return + end + + local textNum = tonumber(self.InputFunitueCount.text) + if not textNum or textNum <= 0 then + XUiManager.TipMsg(CS.XTextManager.GetText("DormBuildNotCount")) + return + end + + local _, isEnough = self:GetCostFurnitureCoin() + if not isEnough then + XUiManager.TipMsg(CS.XTextManager.GetText("FurnitureZeroCoin")) + return + end + + local isModifyTips = false --是否要提示地板天花板等数量多于1的提示 + for _, id in ipairs(self.SelectTypeIds) do + local cfg = XFurnitureConfigs.GetFurnitureTypeById(id) + if cfg.MajorType == XFurnitureConfigs.MajorType.Refit then + isModifyTips = textNum > 1 + break + end + end + if isModifyTips then + CsXUiManager.Instance:Open("UiDialog", nil, CS.XTextManager.GetText("DormBuildNotChangeCount"), XUiManager.DialogType.Normal, nil, function() self:CreateFurniture() end) + else + self:CreateFurniture() + end +end + +function XUiFurnitureCreate:CreateFurniture() + local costA = 0 + local costB = 0 + local costC = 0 + for i = 1, #self.InvestmentCfg do + local investmentItem = self.GridInvestmentPool[i] + local cfg, sum = investmentItem:GetCostDatas() + if cfg.Id == XFurnitureConfigs.AttrType.AttrA then + costA = sum + elseif cfg.Id == XFurnitureConfigs.AttrType.AttrB then + costB = sum + elseif cfg.Id == XFurnitureConfigs.AttrType.AttrC then + costC = sum + end + end + -- update界面,关闭界面 + XDataCenter.FurnitureManager.CreateFurniture(self.SelectPos, self.SelectTypeIds, self.FurnitrueCreateCount, costA, costB, costC, function() + XUiManager.TipText("FurnitureBuildStart") + if self.CallBack then + self.CallBack(self.SelectPos) + end + if XTool.UObjIsNil(self.GameObject) then return end + self:Close() + end) +end + +function XUiFurnitureCreate:OnStart(typeId, createCount, pos, callBack) + self.BtnTanchuangClose.CallBack = function() self:OnBtnCancelClick() end + self.BtnStart.CallBack = function() self:OnBtnStartClick() end + self.BtnSelect.CallBack = function() self:OnBtnSelectClick() end + self.BtnReduce.CallBack = function() self:OnBtnReduceClick() end + self.BtnAdd.CallBack = function() self:OnBtnAddClick() end + self.BtnMax.CallBack = function() self:OnBtnMaxClick() end + self.InputFunitueCount.onValueChanged:AddListener(function() + self:OnInputValueChanged() + end) + self.CallBack = callBack + self:ShowPanelCreationDetail() + + if typeId then + self:SetSelectType({ typeId }, nil, createCount) + end +end + +function XUiFurnitureCreate:OnInputValueChanged() + if not self.SelectTypeIds then + return + end + + if not self.InputFunitueCount.text or self.InputFunitueCount.text == "" then + self.InputFunitueCount.text = tostring(self.FurnitrueCreateCount) + return + end + + local textNum = tonumber(self.InputFunitueCount.text) + if not self:CheckCanChangeNum() then + XUiManager.TipMsg(CS.XTextManager.GetText("DormBuildNotChangeCount")) + self.InputFunitueCount.text = tostring(self.FurnitrueCreateCount) + return + end + + if textNum < 1 then + XUiManager.TipMsg(CS.XTextManager.GetText("DormBuildMinCount")) + self.InputFunitueCount.text = tostring(self.FurnitrueCreateCount) + return + end + + local typeCount = (self.SelectTypeIds and #self.SelectTypeIds > 0) and #self.SelectTypeIds or 1 + if (textNum * typeCount) > XFurnitureConfigs.MaxCreateCount then + self.InputFunitueCount.text = tostring(self.FurnitrueCreateCount) + XUiManager.TipMsg(CS.XTextManager.GetText("DormBuildMaxCount", XFurnitureConfigs.MaxCreateCount)) + return + end + + self.FurnitrueCreateCount = textNum + self:UpdateTotalNum() +end + +function XUiFurnitureCreate:OnBtnReduceClick() + if self.BtnReduceDisable then + return + end + + if self.FurnitrueCreateCount <= 1 then + XUiManager.TipMsg(CS.XTextManager.GetText("DormBuildMinCount")) + return + end + + self.FurnitrueCreateCount = self.FurnitrueCreateCount - 1 + self:UpdateTotalNum() +end + +function XUiFurnitureCreate:OnBtnAddClick() + if self.BtnAddDisable then + return + end + + if not self:CheckCanChangeNum() then + XUiManager.TipMsg(CS.XTextManager.GetText("DormBuildNotChangeCount")) + return + end + + local textNum = tonumber(self.InputFunitueCount.text) + self.FurnitrueCreateCount = textNum > 0 and self.FurnitrueCreateCount + 1 or 1 + local typeCount = (self.SelectTypeIds and #self.SelectTypeIds > 0) and #self.SelectTypeIds or 1 + + if (self.FurnitrueCreateCount * typeCount) > XFurnitureConfigs.MaxCreateCount then + self.FurnitrueCreateCount = math.floor(XFurnitureConfigs.MaxCreateCount / typeCount) + XUiManager.TipMsg(CS.XTextManager.GetText("DormBuildMaxCount", XFurnitureConfigs.MaxCreateCount)) + return + end + + self:UpdateTotalNum() +end + +function XUiFurnitureCreate:OnBtnMaxClick() + if self.BtnMaxDisable then + return + end + + if not self:CheckCanChangeNum() then + XUiManager.TipMsg(CS.XTextManager.GetText("DormBuildNotChangeCount")) + return + end + + local max = self:GetMaxBuildCount() + self.FurnitrueCreateCount = max > 0 and max or 1 + self:UpdateTotalNum(max <= 0) +end + +function XUiFurnitureCreate:CheckCanChangeNum() + --[[ + for _, id in ipairs(self.SelectTypeIds) do + local cfg = XFurnitureConfigs.GetFurnitureTypeById(id) + if cfg.MajorType == XFurnitureConfigs.MajorType.Refit then + return false + end + end + ]] + return true +end + +function XUiFurnitureCreate:SetPanelActive(value) + self.GameObject:SetActive(value) +end + +--显示制造家具详情UI +function XUiFurnitureCreate:ShowPanelCreationDetail(pos) + self.SelectPos = pos or 0 + + local maxCreateNum = CS.XGame.Config:GetInt("DormFurnitureCreateNum") + for i = 0, maxCreateNum, 1 do + local furnitureCreateData = XDataCenter.FurnitureManager.GetFurnitureCreateItemByPos(i) + if not furnitureCreateData then + self.SelectPos = i + break + end + end + + --清除上一个状态 + self.SelectTypeIds = nil + self.FurnitrueCreateCount = 0 + + self.PanelCreationDetail.gameObject:SetActive(true) + self.ImgAdd.gameObject:SetActive(true) + self:UpdateCreationDetail() + local icon = XDataCenter.ItemManager.GetItemIcon(XDataCenter.ItemManager.ItemId.FurnitureCoin) + self.RImgFurnitureCoinIcon:SetRawImage(icon) + + self.BtnSelect:SetNameByGroup(0, CS.XTextManager.GetText("FurnitureAddType")) +end + +-- 制造家具详情ui界面设置 +function XUiFurnitureCreate:UpdateCreationDetail(isIgnoreUpdateInvesment, createCount) + if not isIgnoreUpdateInvesment then + self.InvestmentCfg = XFurnitureConfigs.GetFurnitureAttrType() + local onCreate = function(grid, data) + grid:Init(data, self) + end + XUiHelper.CreateTemplates(self, self.GridInvestmentPool, self.InvestmentCfg, + XUiGridInvestment.New, self.GridInvestment, self.PanelInvestment, onCreate) + self.GridInvestment.gameObject:SetActive(false) + end + + self:UpdateCostCount() + local typeName = "" + local icon + self.HeadIcon.gameObject:SetActive(self.SelectTypeIds ~= nil) + self.ImgItemIcon.gameObject:SetActive(self.SelectTypeIds ~= nil) + if self.SelectTypeIds then + if #self.SelectTypeIds <= 1 then + local furnitureTypeTemplate = XFurnitureConfigs.GetFurnitureTypeById(self.SelectTypeIds[1]) + typeName = furnitureTypeTemplate.CategoryName + icon = furnitureTypeTemplate.TypeIcon + else + typeName = XFurnitureConfigs.DefaultName + icon = XFurnitureConfigs.DefaultIcon + end + + self.ImgItemIcon:SetRawImage(icon) + self:SetInvestBtnsState(true) + else + self:SetInvestBtnsState(false) + end + self.TxtTypeName.text = typeName + self:UpdateTotalNum(nil, createCount) +end + +function XUiFurnitureCreate:UpdateCostCount(isMaxZero) + local costCount, isEnough = self:GetCostFurnitureCoin(isMaxZero) + local textManager = CS.XTextManager + self.TxtFurnitureCoinCount.text = isEnough and textManager.GetText("DormBuildEnoughCount", costCount) + or textManager.GetText("DormBuildNoEnoughCount", costCount) +end + +function XUiFurnitureCreate:SetInvestBtnsState(state) + for _, v in pairs(self.GridInvestmentPool) do + if v then + v:SetBtnState(state) + end + end +end + +-- 获得所有家具币-建造加多少币有么有限制 +function XUiFurnitureCreate:GetTotalFurnitureCoin() + local _, maxConsume = XFurnitureConfigs.GetFurnitureCreateMinAndMax() + local currentOwn = XDataCenter.ItemManager.GetCount(XDataCenter.ItemManager.ItemId.FurnitureCoin) + + return (currentOwn >= maxConsume) and maxConsume or currentOwn +end + +-- 获得当前消耗家具币数量 +function XUiFurnitureCreate:GetCostFurnitureCoin(isMaxZero) + local currentSum = 0 + for _, v in pairs(self.GridInvestmentPool) do + currentSum = currentSum + v:GetCurrentSum() + end + + local typeCount = self.SelectTypeIds and #self.SelectTypeIds or 0 + local createCount = isMaxZero and 0 or self.FurnitrueCreateCount + local costCount = currentSum * typeCount * createCount + local currentOwn = XDataCenter.ItemManager.GetCount(XDataCenter.ItemManager.ItemId.FurnitureCoin) + + local isEnough = currentOwn >= costCount + return costCount, isEnough +end + +-- 获取最大建造数量 +function XUiFurnitureCreate:GetMaxBuildCount() + if not self.SelectTypeIds or #self.SelectTypeIds <= 0 then + return 0 + end + + local currentSum = 0 + for _, v in pairs(self.GridInvestmentPool) do + currentSum = currentSum + v:GetCurrentSum() + end + + local currentOwn = XDataCenter.ItemManager.GetCount(XDataCenter.ItemManager.ItemId.FurnitureCoin) + local count = math.floor(currentOwn / (#self.SelectTypeIds * currentSum)) + local maxCount = math.floor(XFurnitureConfigs.MaxCreateCount / #self.SelectTypeIds) + if count > maxCount then + count = maxCount + end + + return count +end + +-- 检查是否可以投入 +function XUiFurnitureCreate:CheckCanAddSum() + local totalNum = self:GetTotalFurnitureCoin() + local currentSum = 0 + for _, v in pairs(self.GridInvestmentPool) do + currentSum = currentSum + v:GetCurrentSum() + end + currentSum = currentSum + + local incresment = XFurnitureConfigs.Incresment + return totalNum >= currentSum + incresment +end + +-- 可以投入的最大数量 +function XUiFurnitureCreate:GetPassableSum() + local totalNum = self:GetTotalFurnitureCoin() + local currentSum = 0 + for _, v in pairs(self.GridInvestmentPool) do + currentSum = currentSum + v:GetCurrentSum() + end + if totalNum > currentSum then + return totalNum - currentSum + end + return 0 +end + +function XUiFurnitureCreate:CheckInverstNum() + local currentSum = 0 + for _, v in pairs(self.GridInvestmentPool) do + currentSum = currentSum + v:GetCurrentSum() + end + + local currentOwn = XDataCenter.ItemManager.GetCount(XDataCenter.ItemManager.ItemId.FurnitureCoin) + local _, maxConsume = XFurnitureConfigs.GetFurnitureCreateMinAndMax() + return currentOwn - currentSum >= 0 and currentSum >= maxConsume +end + +function XUiFurnitureCreate:UpdateTotalNum(isMaxZero) + local currentSum = 0 + for _, v in pairs(self.GridInvestmentPool) do + currentSum = currentSum + v:GetCurrentSum() + v:UpdateInfos() + end + + self:UpdateCostCount(isMaxZero) + local minConsume, _ = XFurnitureConfigs.GetFurnitureCreateMinAndMax() + local typeCount = (self.SelectTypeIds and #self.SelectTypeIds > 0) and #self.SelectTypeIds or 1 + local createCount = self.FurnitrueCreateCount > 0 and self.FurnitrueCreateCount or 1 + minConsume = typeCount * createCount * minConsume + currentSum = currentSum * typeCount * createCount + + local notEnought = minConsume > currentSum + local desc = notEnought and CS.XTextManager.GetText("DormBuildNoEnoughDesc") or CS.XTextManager.GetText("DormBuildEnoughDesc") + self.TxtDesc.text = desc + self.BtnStart:SetDisable(notEnought, not notEnought) + self:UpdateCountEdit(notEnought, isMaxZero, createCount) +end + +function XUiFurnitureCreate:UpdateCountEdit(notEnought, isMaxZero, createCount) + if notEnought then + self.BtnMaxDisable = notEnought + self.BtnAddDisable = notEnought + self.BtnReduceDisable = notEnought + self.BtnReduce:SetDisable(notEnought) + self.BtnAdd:SetDisable(notEnought) + self.BtnMax:SetDisable(notEnought) + self.InputFunitueCount.interactable = not notEnought + local count = createCount and createCount or 0 + self.InputFunitueCount.text = count + return + end + + self.BtnReduce:SetDisable(self.FurnitrueCreateCount <= 1) + self.BtnAdd:SetDisable(false) + self.BtnMax:SetDisable(false) + self.BtnMaxDisable = false + self.BtnAddDisable = false + self.BtnReduceDisable = self.FurnitrueCreateCount <= 1 + self.InputFunitueCount.interactable = true + self.InputFunitueCount.text = isMaxZero and 0 or self.FurnitrueCreateCount +end + +-- 选择TypeId +function XUiFurnitureCreate:OnBtnSelectClick() + local selectTypeIds = self.SelectTypeIds or {} + XLuaUiManager.Open("UiFurnitureTypeSelect", selectTypeIds, nil, true, handler(self, self.SetSelectType)) +end + +function XUiFurnitureCreate:SetSelectType(typeIds, suitId, createCount) + self.SelectTypeIds = typeIds + self.BtnSelect:SetNameByGroup(0, "") + local count = 1 + if createCount and createCount > 1 then + count = createCount + end + self.FurnitrueCreateCount = count + self.ImgAdd.gameObject:SetActive(false) + self:UpdateCreationDetail(true, createCount) +end + +function XUiFurnitureCreate:HasSelectType() + return self.SelectTypeIds ~= nil +end + +return XUiFurnitureCreate \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDorm/XUiFurnitureBuild/XUiGridCreate.lua b/Resources/Scripts/XUi/XUiDorm/XUiFurnitureBuild/XUiGridCreate.lua new file mode 100644 index 00000000..d9dcfa6a --- /dev/null +++ b/Resources/Scripts/XUi/XUiDorm/XUiFurnitureBuild/XUiGridCreate.lua @@ -0,0 +1,235 @@ +-- 家具建造节点 +XUiGridCreate = XClass(nil, "XUiGridCreate") + +local CREATE_STATE = { + AVALIABLE = 0, + CREATING = 1, + COMPLETE = 2, +} + +function XUiGridCreate:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + self.CurrentState = nil + self.WorkingTimer = nil + self.CreateState = CREATE_STATE.AVALIABLE + self.RemainingTime = 0 + + XTool.InitUiObject(self) + + self:AddBtnsListeners() + self.BtnStart.CallBack = function() + if not self.Cfg then return end + + XLuaUiManager.Open("UiFurnitureCreate", nil, nil, self.Cfg.Pos, function(pos) + self.Parent:UpdateCreateGridByPos(pos) + end) + + end +end + +function XUiGridCreate:Rename(index) + self.GameObject.name = string.format("GridCreate%d", index) +end + +function XUiGridCreate:AddBtnsListeners() + self.AutoCreateListeners = {} + XUiHelper.RegisterClickEvent(self, self.BtnCheck, self.OnBtnCheckClick) +end + +function XUiGridCreate:RegisterListener(uiNode, eventName, func) + if not uiNode then return end + local key = eventName .. uiNode:GetHashCode() + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiBtnTab:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiGridCreate:Init(cfg, parent) + self.Parent = parent + self.Cfg = cfg + + self:UpdateCreate() +end + +function XUiGridCreate:OnClose() + self:RemoveWorkingTimer() +end + +function XUiGridCreate:UpdateCreate() + if not self.Cfg then return end + local createDatas = XDataCenter.FurnitureManager.GetFurnitureCreateItemByPos(self.Cfg.Pos) + local now = XTime.GetServerNowTimestamp() + + if createDatas then + --这个坑位正在创造或者已经创造完成 + local furnitureTemplates, furnitureBaseTemplates + if createDatas.Count <= 1 then + local configId = createDatas.Furniture.ConfigId + furnitureTemplates = XFurnitureConfigs.GetFurnitureTemplateById(configId) + furnitureBaseTemplates = XFurnitureConfigs.GetFurnitureBaseTemplatesById(configId) + if (not furnitureTemplates) or (not furnitureBaseTemplates) then + return + end + end + + local finishTime = createDatas.EndTime + self.RemainingTime = finishTime - now + self.RemainingTime = (self.RemainingTime < 0) and 0 or self.RemainingTime + if finishTime > now then + --坑位正在制作家具 + self.PanelAttris.gameObject:SetActive(createDatas.Count <= 1) + self.PanelMany.gameObject:SetActive(createDatas.Count > 1) + + if createDatas.Count > 1 then + self.TxtWorkingFurnitureName.text = XFurnitureConfigs.DefaultName + self.ImgWorkingItemIcon:SetRawImage(XFurnitureConfigs.DefaultIcon) + self.TxtWorkKey.text = XFurnitureConfigs.DefaultName .. CS.XTextManager.GetText("DormBuildCountDesc") + self.TxtWorkValue.text = "x" .. tostring(createDatas.Count) + else + local typeDatas = XFurnitureConfigs.GetFurnitureTypeById(furnitureTemplates.TypeId) + if not typeDatas then return end + self.ImgWorkingItemIcon:SetRawImage(typeDatas.TypeIcon) + self.TxtWorkingFurnitureName.text = typeDatas.CategoryName + end + + self.CreateState = CREATE_STATE.CREATING + else + --坑位家具制作完成,可以领取 + self.PanelComAttris.gameObject:SetActive(createDatas.Count <= 1) + self.PanelComMany.gameObject:SetActive(createDatas.Count > 1) + + if createDatas.Count > 1 then + self.TxtCompleteFurnitureName.text = XFurnitureConfigs.DefaultName + self.ImgCompleteItemIcon:SetRawImage(XFurnitureConfigs.DefaultIcon) + self.TxtCompleteKey.text = XFurnitureConfigs.DefaultName .. CS.XTextManager.GetText("DormBuildCountDesc") + self.TxtCompleteValue.text = "x" .. tostring(createDatas.Count) + else + self.ImgCompleteItemIcon:SetRawImage(XDataCenter.FurnitureManager.GetIconByFurniture(createDatas.Furniture)) + self.TxtCompleteFurnitureName.text = furnitureBaseTemplates.Name + self:UpdateFurnitureCompleteAttris(createDatas.Furniture, furnitureTemplates) + end + + self.CreateState = CREATE_STATE.COMPLETE + end + else + --这个坑位空闲 + self.CreateState = CREATE_STATE.AVALIABLE + end + + local serialNumber = string.format("0%d", self.Cfg.Pos + 1) + self.TxtStartLabel.text = serialNumber + self.TxtWorkingLabel.text = serialNumber + self.TxtCompleteLabel.text = serialNumber + + if self.CreateState == CREATE_STATE.CREATING then--剩余时间 + self:AddWorkingTimer() + end + + self:UpdateCreateView(self.CreateState) +end + +function XUiGridCreate:UpdateCreateView(currentState) + self.PanelStart.gameObject:SetActive(currentState == CREATE_STATE.AVALIABLE) + self.PanelWorking.gameObject:SetActive(currentState == CREATE_STATE.CREATING) + self.PanelComplete.gameObject:SetActive(currentState == CREATE_STATE.COMPLETE) +end + +function XUiGridCreate:UpdateFurnitureWorkingAttris(furniture, furnitureTemplates) + if not furniture then return end + for i = 1, #furniture.AttrList do + local attrScore = furniture.AttrList[i] or 0 + self[string.format("TxtWorkingValue%d", i)].text = XFurnitureConfigs.GetFurnitureAttrLevelDescription(furnitureTemplates.TypeId, i, attrScore) + end +end +function XUiGridCreate:UpdateFurnitureCompleteAttris(furniture, furnitureTemplates) + if not furniture then return end + for i = 1, #furniture.AttrList do + local attrScore = furniture.AttrList[i] or 0 + self[string.format("TxtCompleteValue%d", i)].text = XFurnitureConfigs.GetFurnitureAttrLevelDescription(furnitureTemplates.TypeId, i, attrScore) + end +end + +function XUiGridCreate:AddWorkingTimer() + self:RemoveWorkingTimer() + local dataTime = XUiHelper.GetTime(self.RemainingTime, XUiHelper.TimeFormatType.HOSTEL) + self.TxtRemaining.text = dataTime + self.WorkingTimer = XScheduleManager.ScheduleForever(function() + if XTool.UObjIsNil(self.Transform) then + self:RemoveWorkingTimer() + return + end + local dataTimeNew + self.RemainingTime = self.RemainingTime - 1 + if self.RemainingTime <= 0 then + dataTimeNew = XUiHelper.GetTime(0, XUiHelper.TimeFormatType.HOSTEL) + self.TxtRemaining.text = dataTimeNew + self:RemoveWorkingTimer() + self:UpdateCreate() + else + dataTimeNew = XUiHelper.GetTime(self.RemainingTime, XUiHelper.TimeFormatType.HOSTEL) + self.TxtRemaining.text = dataTimeNew + end + end, 1000) +end + +function XUiGridCreate:GetProgress() + if not self.Cfg then return 0 end + local createDatas = XDataCenter.FurnitureManager.GetFurnitureCreateItemByPos(self.Cfg.Pos) + local now = XTime.GetServerNowTimestamp() + if not createDatas then return 0 end + + local configId = createDatas.Furniture.ConfigId + local furnitureTemplates = XFurnitureConfigs.GetFurnitureTemplateById(configId) + local progress = (now - createDatas.EndTime + furnitureTemplates.CreateTime) / furnitureTemplates.CreateTime + return (progress > 1) and 1 or progress +end + +function XUiGridCreate:RemoveWorkingTimer() + if self.WorkingTimer then + XScheduleManager.UnSchedule(self.WorkingTimer) + self.WorkingTimer = nil + end +end + +function XUiGridCreate:OnBtnStartClick() + self.Parent:ShowPanelCreationDetail(self.Cfg.Pos) +end + +function XUiGridCreate:OnBtnCheckClick() + -- 领取 + if self.CreateState and self.CreateState == CREATE_STATE.COMPLETE and self.Cfg then + XDataCenter.FurnitureManager.CheckCreateFurniture(self.Cfg.Pos, function(furnitureList, createCoinCount) + self:RemoveWorkingTimer() + self:UpdateCreate() + + if #furnitureList > 1 then + local gainType = XFurnitureConfigs.GainType.Create + XLuaUiManager.Open("UiFurnitureObtain", gainType, furnitureList, nil, createCoinCount, self.Cfg.Pos, function(pos) + self.Parent:UpdateCreateGridByPos(pos) + end) + + return + end + XLuaUiManager.Open("UiFurnitureDetail", furnitureList[1].Id, furnitureList[1].ConfigId) + + end) + end +end + +return XUiGridCreate \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDorm/XUiFurnitureBuild/XUiGridInvestment.lua b/Resources/Scripts/XUi/XUiDorm/XUiFurnitureBuild/XUiGridInvestment.lua new file mode 100644 index 00000000..857f7eed --- /dev/null +++ b/Resources/Scripts/XUi/XUiDorm/XUiFurnitureBuild/XUiGridInvestment.lua @@ -0,0 +1,153 @@ +-- 建造家具,家具币选择 +XUiGridInvestment = XClass(nil, "XUiGridInvestment") + +local incresment = CS.XGame.ClientConfig:GetInt("FurnitureInvestmentIncreaseStep") + +function XUiGridInvestment:Ctor(rootUi, ui) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.CurrentSum = 0 + XTool.InitUiObject(self) + + self:AddBtnsListeners() +end + +function XUiGridInvestment:AddBtnsListeners() + self.AutoCreateListeners = {} + XUiHelper.RegisterClickEvent(self, self.BtnReduce, self.OnBtnReduceClick) + XUiHelper.RegisterClickEvent(self, self.BtnAdd, self.OnBtnAddClick) + XUiHelper.RegisterClickEvent(self, self.BtnMax, self.OnBtnMaxClick) +end + +function XUiGridInvestment:OnBtnReduceClick() + if not self.Parent then return end + if not self.Parent:HasSelectType() then + XUiManager.TipMsg(CS.XTextManager.GetText("FurnitureSelectAType")) + return + end + + if self.CurrentSum - incresment <= 0 then + self.CurrentSum = 0 + else + self.CurrentSum = self.CurrentSum - incresment + end + + self:SetSumText(self.CurrentSum) + self.Parent:UpdateTotalNum() +end + +function XUiGridInvestment:OnBtnAddClick() + if not self.Parent then return end + if not self.Parent:HasSelectType() then + XUiManager.TipMsg(CS.XTextManager.GetText("FurnitureSelectAType")) + return + end + + if self.Parent:CheckCanAddSum() then + self.CurrentSum = self.CurrentSum + incresment + self:SetSumText(self.CurrentSum) + self.Parent:UpdateTotalNum() + else + local isEngouth = self.Parent:CheckInverstNum() + if isEngouth then + XUiManager.TipMsg(CS.XTextManager.GetText("FurnitureMaxCoin")) + else + XUiManager.TipMsg(CS.XTextManager.GetText("FurnitureZeroCoin")) + end + end +end + +function XUiGridInvestment:OnBtnMaxClick() + if not self.Parent then return end + if not self.Parent:HasSelectType() then + XUiManager.TipMsg(CS.XTextManager.GetText("FurnitureSelectAType")) + return + end + + if self.Parent:CheckCanAddSum() then + local extraNum = self.Parent:GetPassableSum() + self.CurrentSum = self.CurrentSum + extraNum + self:SetSumText(self.CurrentSum) + self.Parent:UpdateTotalNum() + else + local isEngouth = self.Parent:CheckInverstNum() + if isEngouth then + XUiManager.TipMsg(CS.XTextManager.GetText("FurnitureMaxCoin")) + else + XUiManager.TipMsg(CS.XTextManager.GetText("FurnitureZeroCoin")) + end + end +end + +function XUiGridInvestment:RegisterListener(uiNode, eventName, func) + if not uiNode then return end + local key = eventName .. uiNode:GetHashCode() + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiBtnTab:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiGridInvestment:GetCurrentSum() + return self.CurrentSum or 0 +end + +function XUiGridInvestment:Init(cfg, parent) + self.Parent = parent + self.Cfg = cfg + + self.CurrentSum = 0 + self:SetSumText(self.CurrentSum) + self.RootUi:SetUiSprite(self.ImgAttributeIcon, self.Cfg.TypeIcon) + self.TxtAttributeName.text = self.Cfg.TypeName + + self:UpdateInfos() + +end + +function XUiGridInvestment:UpdateInfos() + if not self.Parent then return end + + self.BtnReduce.interactable = not (self.CurrentSum <= 0) +end + +function XUiGridInvestment:SetBtnState(state) + self.BtnAdd.interactable = state + self.BtnMax.interactable = state +end + +function XUiGridInvestment:GetCostDatas() + return self.Cfg, self.CurrentSum +end + +function XUiGridInvestment:SetSumText(num) + + if self.Parent:HasSelectType() and num > 0 then + self.TxtSum.text = "" + self.TxtSumOn.text = num + self.TxtAttributeName.text = "" + self.TxtAttributeNameOn.text = self.Cfg and self.Cfg.TypeName or "" + else + self.TxtSum.text = num + self.TxtSumOn.text = "" + self.TxtAttributeName.text = self.Cfg and self.Cfg.TypeName or "" + self.TxtAttributeNameOn.text = "" + end + +end + +return XUiGridInvestment \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDorm/XUiFurnitureBuild/XUiPanelCreate.lua b/Resources/Scripts/XUi/XUiDorm/XUiFurnitureBuild/XUiPanelCreate.lua new file mode 100644 index 00000000..a64218f2 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDorm/XUiFurnitureBuild/XUiPanelCreate.lua @@ -0,0 +1,79 @@ +-- 家具建造子界面 +XUiPanelCreate = XClass(nil, "XUiPanelCreate") + +function XUiPanelCreate:Ctor(rootUi, ui) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiPanelCreate:Init(cfg) + self.CreateGridDatas = cfg + self.GridCreate.gameObject:SetActive(false) + + if not self.CreateGridDatas then + XLog.Warning("XUiPanelCreate:Init error: cfg is nil") + end + + if not self.DynamicTableCreate then + self.DynamicTableCreate = XDynamicTableNormal.New(self.ScrCreate.gameObject) + self.DynamicTableCreate:SetProxy(XUiGridCreate) + self.DynamicTableCreate:SetDelegate(self) + end + + self.DynamicTableCreate:SetDataSource(self.CreateGridDatas) + self.DynamicTableCreate:ReloadDataASync() +end + +-- [列表事件] +function XUiPanelCreate:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Rename(index) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + self:OnRefreshCreate(index, grid) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_RECYCLE then + grid:OnClose() + end +end + +function XUiPanelCreate:OnRefreshCreate(index, grid) + local data = self.CreateGridDatas[index] + if not data then return end + grid:Init(data, self) +end + +function XUiPanelCreate:UpdateCreateGridByPos(pos) + if not self.CreateGridDatas then return end + + local index = 1 + for k, v in pairs(self.CreateGridDatas) do + if v.Pos == pos then + index = k + break + end + end + + if not self.DynamicTableCreate then return end + local grid = self.DynamicTableCreate:GetGridByIndex(index) + if grid then + grid:Init(self.CreateGridDatas[index], self) + end +end + +function XUiPanelCreate:SetPanelActive(value) + self.GameObject:SetActive(value) +end + +function XUiPanelCreate:CheckInverstNum() + local currentSum = 0 + for _, v in pairs(self.GridInvestmentPool) do + currentSum = currentSum + v:GetCurrentSum() + end + + local currentOwn = XDataCenter.ItemManager.GetCount(XDataCenter.ItemManager.ItemId.FurnitureCoin) + local _, maxConsume = XFurnitureConfigs.GetFurnitureCreateMinAndMax() + return currentOwn - currentSum >= 0 and currentSum >= maxConsume +end + +return XUiPanelCreate \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDorm/XUiFurnitureBuild/XUiPanelRefit.lua b/Resources/Scripts/XUi/XUiDorm/XUiFurnitureBuild/XUiPanelRefit.lua new file mode 100644 index 00000000..390d085c --- /dev/null +++ b/Resources/Scripts/XUi/XUiDorm/XUiFurnitureBuild/XUiPanelRefit.lua @@ -0,0 +1,438 @@ +-- 家具改造子界面 +XUiPanelRefit = XClass(nil, "XUiPanelRefit") + +local DEFAULT_STRING1 = "?" +local DEFAULT_STRING2 = CS.XTextManager.GetText("None") +local DEFAULT_STRING3 = CS.XTextManager.GetText("SelectFurniture") +-- local DEFAULT_DATA = {[1] = DEFAULT_STRING1, [2] = DEFAULT_STRING1, [3] = DEFAULT_STRING1 } + +local EnoughColor = CS.UnityEngine.Color(0, 0, 0) +local NotEnoughColor = CS.UnityEngine.Color(1, 0, 0) + +-- local CFG = { +-- ConsumeCount = 3 +-- } + +function XUiPanelRefit:Ctor(rootUi, ui) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + self.SelectedFurnitureIds = nil + self.SelectedDrawingId = nil + + self.BtnSelectFurniture.CallBack = function() self:OnBtnSelectFurnitureClick() end + self.BtnSelectDrawing.CallBack = function() self:OnBtnSelectDrawingClick() end + self.BtnRefit.CallBack = function() self:OnBtnRefitClick() end +end + +function XUiPanelRefit:Init(drawingId, furnitureTypeId) + self:SelectFurniture() + self:SelectDrawing() + self.TxtConsume.text = CS.XTextManager.GetText("UiPanelRefitConsume") + self.TxtSelectDrawing.text = CS.XTextManager.GetText("UiPanelRefitSelectDrawing") + + self.SelectedDrawingId = drawingId + self.FrunitureTypeId = furnitureTypeId + + if self.SelectedDrawingId then + self:SelectDrawing(self.SelectedDrawingId) + self:OnBtnSelectFurnitureClick() + end +end + +function XUiPanelRefit:SetPanelActive(value) + self.GameObject:SetActiveEx(value) + if not value then + if self.SelectedFurnitureIds then + self:SelectFurniture() + end + + if self.SelectedDrawingId then + self:SelectDrawing() + end + else + self.RootUi:PlayAnimRefitEnable() + end +end + +function XUiPanelRefit:CheckClearDrawing(furnitureIds) + if self.SelectedDrawingId then + local id = type(furnitureIds) == "table" and furnitureIds[1] or furnitureIds + local selectedFurnitureDatas = XDataCenter.FurnitureManager.GetFurnitureById(id) + local selectedFurnitureTemplate = XFurnitureConfigs.GetFurnitureTemplateById(selectedFurnitureDatas.ConfigId) + + local previewFurnitureId = XFurnitureConfigs.GetPreviewFurnitureByDrawingId(self.SelectedDrawingId) + if not previewFurnitureId then + self.SelectedDrawingId = nil + self:SelectDrawing() + return + end + + local previewFurnitureTemplate = XFurnitureConfigs.GetFurnitureTemplateById(previewFurnitureId) + if not previewFurnitureTemplate then + self.SelectedDrawingId = nil + self:SelectDrawing() + return + end + + if selectedFurnitureTemplate.TypeId ~= previewFurnitureTemplate.TypeId then + self.SelectedDrawingId = nil + self:SelectDrawing() + end + end +end + +--显示选择的家具信息 +function XUiPanelRefit:SelectFurniture(furnitureIds) + if furnitureIds then + local furnitureDatas = XDataCenter.FurnitureManager.GetFurnitureById(furnitureIds) + if not furnitureDatas then + self:SelectFurniture() + return + end + + -- 新增一个处理,如果已经选择了图纸,并且该图纸不能匹配当前的家具,清空 + self:CheckClearDrawing(furnitureIds) + self.SelectedFurnitureIds = furnitureIds + + -- 多选还是单选状态 + local isList = type(furnitureIds) == "table" + + local data = XDataCenter.FurnitureManager.GetFurnitureById(isList and furnitureIds[1] or furnitureIds) + local cfg = XFurnitureConfigs.GetFurnitureTemplateById(data.ConfigId) + self.FrunitureTypeId = cfg.TypeId + + if isList then + local typeCfg = XFurnitureConfigs.GetFurnitureTypeById(cfg.TypeId) + self.TxtSelectName.text = typeCfg.CategoryName + self.TxtSelectNum.text = CS.XTextManager.GetText("DormRefitEnoughCount", #furnitureIds) + self.ImgBtnSelectFurniture:SetRawImage(typeCfg.TypeIcon) + else + self.TxtSelectFurniture.text = "" + local totalScore = 0 + for _, v in pairs(furnitureDatas.AttrList or {}) do + totalScore = totalScore + v + end + + local addition = furnitureDatas.Addition or 0 + local introduce = DEFAULT_STRING2 + if addition > 0 then + totalScore = totalScore + XFurnitureConfigs.GetAdditionalAddScore(addition) + local str = XFurnitureConfigs.GetAdditionalRandomEntry(addition) + introduce = string.format("%s\n%s", str,XFurnitureConfigs.GetAdditionalRandomIntroduce(addition)) + end + + self.TxtSelectScore.text = CS.XTextManager.GetText("FurnitureRefitScore", totalScore) + self.TxtSelectSpecial.text = introduce + self.ImgBtnSelectFurniture:SetRawImage(XDataCenter.FurnitureManager.GetFurnitureIconById(furnitureIds, XDormConfig.DormDataType.Self)) + end + + self.PanelSelectFrunitureInfo.gameObject:SetActiveEx(not isList) + self.PanelSelectFrunitureInfos.gameObject:SetActiveEx(isList) + self.TxtSelectScore.gameObject:SetActiveEx(not isList) + self.TxtSelectSpecial.gameObject:SetActiveEx(not isList) + self.BtnSelectFurnitureCanvasGroup.alpha = 0 + self.ImgBtnSelectFurniture.gameObject:SetActiveEx(true) + else + self.SelectedFurnitureIds = nil + self.FrunitureTypeId = nil + self.TxtSelectFurniture.text = DEFAULT_STRING3 + self.TxtSelectScore.gameObject:SetActiveEx(false) + self.TxtSelectSpecial.gameObject:SetActiveEx(false) + self.PanelSelectFrunitureInfo.gameObject:SetActiveEx(false) + self.PanelSelectFrunitureInfos.gameObject:SetActiveEx(false) + self.ImgBtnSelectFurniture.gameObject:SetActiveEx(false) + self.BtnSelectFurnitureCanvasGroup.alpha = 1 + end + + -- 计算消耗材料 + local ownFurnitureNum = XDataCenter.ItemManager.GetCount(XDataCenter.ItemManager.ItemId.FurnitureCoin) + local needFurnitureNum = self:GetRefitNeedMoney(self.SelectedFurnitureIds) + self.TxtConsumeCount.text = needFurnitureNum + self.ImgDrawingIcon:SetRawImage(XDataCenter.ItemManager.GetItemIcon(XDataCenter.ItemManager.ItemId.FurnitureCoin)) + if ownFurnitureNum >= needFurnitureNum then + self.TxtConsumeCount.color = EnoughColor + self.IsCoinEnough = true + else + self.TxtConsumeCount.color = NotEnoughColor + self.IsCoinEnough = false + end + + self:RefrshDrwaingCount() + self:CheckPreview() +end + +--显示选择的图纸信息 +function XUiPanelRefit:SelectDrawing(DraftId) + if DraftId then + self.SelectedDrawingId = DraftId + local icon = XDataCenter.ItemManager.GetItemIcon(DraftId) + local name = XDataCenter.ItemManager.GetItemName(DraftId) + self.PanelSelectDrawingInfo.gameObject:SetActiveEx(true) + self.ImgSelectDrawing:SetRawImage(icon) + self.TxtSelectDrawing.text = "" + self.BtnSelectDrawingCanvasGroup.alpha = 0 + + -- 检查是否批量建造 + self:RefrshDrwaingCount() + self.TxtSelectDrawName.text = name + else + self.SelectedDrawingId = nil + self.PanelSelectDrawingInfo.gameObject:SetActiveEx(false) + self.TxtSelectDrawing.text = CS.XTextManager.GetText("UiPanelRefitSelectDrawing") + self.BtnSelectDrawingCanvasGroup.alpha = 1 + end + self:CheckPreview() +end + +-- 刷新图纸数量 +function XUiPanelRefit:RefrshDrwaingCount() + if not self.SelectedDrawingId then + self.TxtSelectDrawNum.text = CS.XTextManager.GetText("DormRefitEnoughCount", 0) + return + end + + local draftCount = XDataCenter.ItemManager.GetCount(self.SelectedDrawingId) + local furnitrueCount = self:IsFurnitureTable() and #self.SelectedFurnitureIds or 1 + local content = furnitrueCount > draftCount and CS.XTextManager.GetText("DormRefitNoEnoughCount", furnitrueCount) + or CS.XTextManager.GetText("DormRefitEnoughCount", furnitrueCount) + self.TxtSelectDrawNum.text = content +end + +--显示预览信息 +function XUiPanelRefit:CheckPreview() + + self.TxtPreviewScore.text = CS.XTextManager.GetText("FurnitureRefitScore", DEFAULT_STRING1) + self.BtnSelectDrawing:SetDisable(false, true) + self.PreviewKuangDisable.gameObject:SetActiveEx(false) + self.previewArrowDisable.gameObject:SetActiveEx(false) + self.previewArrowEnable.gameObject:SetActiveEx(true) + + if self.SelectedFurnitureIds and self.SelectedDrawingId then + -- 通过图纸拿到要生成的家具ID,通过判断类型是否一致决定是否显示 + local previewFurnitureId = XFurnitureConfigs.GetPreviewFurnitureByDrawingId(self.SelectedDrawingId) + if not previewFurnitureId then + self.ImgPreviewItemIcon.gameObject:SetActiveEx(false) + return + end + + -- -- 检查预览的家具,改装的家具类型是否一致 + local id = self:IsFurnitureTable() and self.SelectedFurnitureIds[1] or self.SelectedFurnitureIds + local furnitureDatas = XDataCenter.FurnitureManager.GetFurnitureById(id) + local furnitureTemplates = XFurnitureConfigs.GetFurnitureTemplateById(furnitureDatas.ConfigId) + local previewDatas = XFurnitureConfigs.GetFurnitureTemplateById(previewFurnitureId) + + if furnitureTemplates.TypeId ~= previewDatas.TypeId then + self.ImgPreviewItemIcon.gameObject:SetActiveEx(false) + self.ImageAdd.gameObject:SetActiveEx(false) + else + local furnitureBaseTemplates = XFurnitureConfigs.GetFurnitureBaseTemplatesById(previewFurnitureId) + self.ImgPreviewItemIcon.gameObject:SetActiveEx(true) + self.ImgPreviewItemIcon:SetRawImage(furnitureBaseTemplates.Icon) + self.ImageAdd.gameObject:SetActiveEx(true) + end + + -- 查询组随机属性 + local hasRandomGroup = previewDatas.RandomGroupId > 0 + self.PanelIcon.gameObject:SetActiveEx(hasRandomGroup) + if hasRandomGroup then + local groupIntroduce = XFurnitureConfigs.GetGroupRandomIntroduce(previewDatas.RandomGroupId) + local introduceBuffer = "" + local a = {} + for _, v in pairs(groupIntroduce) do + for _,v1 in pairs(v) do + local key = XFurnitureConfigs.GetAdditionalRandomEntry(v1.Id,true) + if not a[key] then + a[key] = "" + end + a[key] = a[key] .. string.format("%s\n",v1.Introduce) + end + end + for k,str in pairs(a)do + local des = string.format("%s\n%s\n", k, str) + introduceBuffer = introduceBuffer .. des + end + self.TxtPreviewSpecial.text = introduceBuffer + self:ResizeRandomGroupContent() + end + + else + if self.SelectedFurnitureIds == nil then + -- 未选中家具,不能选择图纸 + self.BtnSelectDrawing:SetDisable(true, false) + self.PreviewKuangDisable.gameObject:SetActiveEx(true) + self.previewArrowDisable.gameObject:SetActiveEx(true) + self.previewArrowEnable.gameObject:SetActiveEx(false) + end + + self.ImgPreviewItemIcon.gameObject:SetActiveEx(false) + self.PanelIcon.gameObject:SetActiveEx(false) + self.ImageAdd.gameObject:SetActiveEx(false) + end +end + +function XUiPanelRefit:ResizeRandomGroupContent() + local rectTransform = self.TxtPreviewSpecial.transform:GetComponent("RectTransform") + local adjustHeight = self.TxtPreviewSpecial.preferredHeight + local sizeDelta = rectTransform.sizeDelta + rectTransform.sizeDelta = CS.UnityEngine.Vector2(sizeDelta.x, adjustHeight) +end + +function XUiPanelRefit:GetRefitNeedMoney(ids) + if not ids then + return 0 + end + + local func = function(id) + local furnitureDatas = XDataCenter.FurnitureManager.GetFurnitureById(id) + if not furnitureDatas then + return 0 + else + local configId = furnitureDatas.ConfigId + local furnitureTemplates = XFurnitureConfigs.GetFurnitureTemplateById(configId) + return furnitureTemplates.MoneyNum + end + end + + if type(ids) == "table" then + local count = 0 + for _, id in pairs(ids) do + local curCount = func(id) + count = count + curCount + end + return count + else + return func(ids) + end +end + +function XUiPanelRefit:OnBtnSelectFurnitureClick() + --TODO + --跳转到仓库选择一个家具 + local pageRecord = XDormConfig.DORM_BAG_PANEL_INDEX.FURITURE + local furnitureState = XFurnitureConfigs.FURNITURE_STATE.SELECT + local func = function(furnitureIds) + local ids = #furnitureIds > 1 and furnitureIds or furnitureIds[1] + self:SelectFurniture(ids) + end + local filter = function(furnitureId) + return not XDataCenter.FurnitureManager.GetFurnitureIsLocked(furnitureId) + end + XLuaUiManager.Open("UiDormBag", pageRecord, furnitureState, func, filter, nil, self.FrunitureTypeId) +end + +function XUiPanelRefit:OnBtnSelectDrawingClick() + --TODO + --跳转到仓库选择一个图纸 + local pageRecord = XDormConfig.DORM_BAG_PANEL_INDEX.DRAFT + local furnitureState = XFurnitureConfigs.FURNITURE_STATE.SELECTSINGLE + local func = function(draftId) + self:SelectDrawing(draftId) + end + local filter = function(drawingId) + if self.SelectedFurnitureIds then + local id = self:IsFurnitureTable() and self.SelectedFurnitureIds[1] or self.SelectedFurnitureIds + local selectedFurnitureDatas = XDataCenter.FurnitureManager.GetFurnitureById(id) + local selectedFurnitureTemplate = XFurnitureConfigs.GetFurnitureTemplateById(selectedFurnitureDatas.ConfigId) + + local typeDatas = XFurnitureConfigs.GetRefitTypeDatas(selectedFurnitureTemplate.TypeId) or {} + for _, v in pairs(typeDatas) do + if v.PicId == drawingId and v.GainType == XFurnitureConfigs.GainType.Refit then + return true + end + end + return false + + end + return true + end + local count = self:IsFurnitureTable() and #self.SelectedFurnitureIds or 1 + XLuaUiManager.Open("UiDormBag", pageRecord, furnitureState, func, filter, count) +end + +function XUiPanelRefit:OnBtnRefitClick() + if not self.SelectedFurnitureIds then + XUiManager.TipMsg(CS.XTextManager.GetText("FurnitureChooseFurniture")) + return + end + + if not self.SelectedDrawingId then + XUiManager.TipMsg(CS.XTextManager.GetText("FurnitureChooseDraft")) + return + end + + if not self.IsCoinEnough then + XUiManager.TipMsg(CS.XTextManager.GetText("FurnitureZeroCoin")) + return + end + + -- 检查图纸是否足够 + local draftCount = XDataCenter.ItemManager.GetCount(self.SelectedDrawingId) + local furnitrueCount = self:IsFurnitureTable() and #self.SelectedFurnitureIds or 1 + if furnitrueCount > draftCount then + -- local buyCount = furnitrueCount - draftCount + -- local configId = self.SelectedDrawingId + --TODO::: 进入快捷购买界面 + XUiManager.TipMsg(CS.XTextManager.GetText("DormNotEnoughDraft"), XUiManager.UiTipType.Tip) + return + end + + -- 图纸是否可以改装家具,通过图纸找到改装之后的家具,然后判断:改装之后生成的家具、用于改装的家具两者类型是否一致。 + local previewFurnitureId = XFurnitureConfigs.GetPreviewFurnitureByDrawingId(self.SelectedDrawingId) + if not previewFurnitureId then + XUiManager.TipMsg(CS.XTextManager.GetText("FunitureCannotCompound")) + return + end + + local check = function(id) + local furnitureDatas = XDataCenter.FurnitureManager.GetFurnitureById(id) + local previewTypeId = XFurnitureConfigs.GetFurnitureTemplateById(previewFurnitureId).TypeId + local selectTypeId = XFurnitureConfigs.GetFurnitureTemplateById(furnitureDatas.ConfigId).TypeId + if previewTypeId ~= selectTypeId then + XUiManager.TipMsg(CS.XTextManager.GetText("FurnitureNotMatchDraft")) + return false + end + + return true + end + + -- 检查预览的家具,改装的家具类型是否一致 + if self:IsFurnitureTable() then + for _, id in ipairs(self.SelectedFurnitureIds) do + if not check(id) then + return + end + end + else + if not check(self.SelectedFurnitureIds) then + return + end + end + + local ids = self:IsFurnitureTable() and self.SelectedFurnitureIds or {self.SelectedFurnitureIds} + XDataCenter.FurnitureManager.RemouldFurniture(ids, self.SelectedDrawingId, function(furnitureList) + self:Init() + if furnitureList then + XUiManager.TipMsg(CS.XTextManager.GetText("FurnitureRefitSuccess"), XUiManager.UiTipType.Tip, function() + if #furnitureList > 1 then + local gainType = XFurnitureConfigs.GainType.Refit + XLuaUiManager.Open("UiFurnitureObtain", gainType, furnitureList, function(furnitureIds) + self:SelectFurniture(furnitureIds) + self:SelectDrawing() + end) + + return + end + XLuaUiManager.Open("UiFurnitureDetail", furnitureList[1].Id, furnitureList[1].ConfigId) + end) + end + end) +end + +function XUiPanelRefit:IsFurnitureTable() + return type(self.SelectedFurnitureIds) == "table" +end + +return XUiPanelRefit \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDorm/XUiFurnitureReform/XUiFurnitureAttrGrid.lua b/Resources/Scripts/XUi/XUiDorm/XUiFurnitureReform/XUiFurnitureAttrGrid.lua new file mode 100644 index 00000000..dbaaee41 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDorm/XUiFurnitureReform/XUiFurnitureAttrGrid.lua @@ -0,0 +1,22 @@ + +local XUiFurnitureAttrGrid = XClass(nil, "XUiFurnitureAttrGrid") + +function XUiFurnitureAttrGrid:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + + +function XUiFurnitureAttrGrid:SetContent(content) + self.NormalItemLabel.text = content.TagName + self.PressItemLabel.text = content.TagName + self.SelectItemLabel.text = content.TagName +end + +function XUiFurnitureAttrGrid:SetSelect(isSelect) + self.Normal.gameObject:SetActiveEx(not isSelect) + self.Select.gameObject:SetActiveEx(isSelect) +end + +return XUiFurnitureAttrGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDorm/XUiFurnitureReform/XUiFurnitureReform.lua b/Resources/Scripts/XUi/XUiDorm/XUiFurnitureReform/XUiFurnitureReform.lua new file mode 100644 index 00000000..9fcb4b9c --- /dev/null +++ b/Resources/Scripts/XUi/XUiDorm/XUiFurnitureReform/XUiFurnitureReform.lua @@ -0,0 +1,815 @@ +-- 家具摆放界面 +local XUiFurnitureReform = XLuaUiManager.Register(XLuaUi, "UiFurnitureReform") + +local XUiPanelMenu = require("XUi/XUiDorm/XUiFurnitureReform/XUiPanelMenu") +local XUiFurnitureAttrGrid = require("XUi/XUiDorm/XUiFurnitureReform/XUiFurnitureAttrGrid") + +local FurnitureCache = {} +local delayRefreshTimer = nil +local delayUpdateScoresTimer = nil + +function XUiFurnitureReform:OnAwake() + self.SuitCFG = XFurnitureConfigs.GetFurnitureSuitTemplates() + self.RefreshFurnitureList = function() self:RefreshFurntiureReform() end + XEventManager.AddEventListener(XEventId.EVENT_FURNITURE_ON_MODIFY, self.RefreshFurnitureList, self) + + self.BtnFilter.CallBack = function() self:OnBtnFilterClick() end + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnRecover.CallBack = function() self:OnBtnRecoverClick() end + self.BtnUndo.CallBack = function() self:OnBtnUndoClick() end + self.BtnSaveAndQuit.CallBack = function() self:OnBtnSaveClick() end + self.BtnExplain.CallBack = function() self:OnBtnExplainClick() end + self.BtnFilterBack.CallBack = function() self:OnBtnFilterBackClick() end + self:RegisterClickEvent(self.BtnDrdSort, self.OnBtnShowDormAttr) +end + +function XUiFurnitureReform:OnStart(roomId, roomType) + self.PanelMenu.gameObject:SetActive(false) + + self.MenuPanel = XUiPanelMenu.New(self, self.PanelMenu) + self.MainPanelGo = self.Transform:Find("SafeAreaContentPane").gameObject + + XHomeDormManager.SetClickFurnitureCallback(function(furniture) self:ShowFurnitureMenu(furniture, false, false) end) + XHomeDormManager.ReformRoom(roomId, true) + XHomeCharManager.HideAllCharacter() + + self.CameraController = XHomeSceneManager.GetSceneCameraController() + if not XTool.UObjIsNil(self.CameraController) then + self.OldCameraDistance = self.CameraController.Distance + self.OldCameraTarget = self.CameraController.TargetObj + self.TargetAngleX = self.CameraController.TargetAngleX + self.TargetAngleY = self.CameraController.TargetAngleY + XCameraHelper.SetCameraTarget(self.CameraController, self.OldCameraTarget, 13) + end + + self.RoomId = roomId + self.RoomType = roomType + self.IsMyRoom = roomType == XDormConfig.DormDataType.Self + self.GridSuitPool = {} + self.GridBaseTypePool = {} + self.GridSubTypePool = {} + self.BtnTabGoList = {} + self.PanelFilterGameObject = self.PanelFilter.gameObject + self.CurrentBaseTypeId = nil + self.CurrentSubTypeId = nil + self.CurrentSuitId = 1--by default + self.DefaultBaseType = CS.XGame.ClientConfig:GetInt("UiFurnitureReformDefaultBaseType") + self:Init() +end + +function XUiFurnitureReform:OnEnable() + XDataCenter.FurnitureManager.SetInRefeform(true) +end + +function XUiFurnitureReform:OnDisable() + XHomeDormManager.SetClickFurnitureCallback(nil) + XHomeDormManager.AttachSurfaceToRoom() + XHomeDormManager.ReformRoom(self.RoomId, false) + XDataCenter.FurnitureManager.SetInRefeform(false) +end + +function XUiFurnitureReform:OnHideBlockGrids() + if self.CurFurniture then + XHomeDormManager.OnHideBlockGrids(self.CurFurniture.HomePlatType, self.CurFurniture.RotateAngle) + end +end +function XUiFurnitureReform:OnBtnCancelClick() + if self.RoomId then + XHomeDormManager.RevertRoom(self.RoomId) + self:CloseFurnitureReform() + end +end + +function XUiFurnitureReform:OnBtnBackClick() + if self.RoomId and XHomeDormManager.IsNeedSave(self.RoomId, self.RoomType) then + XUiManager.DialogTip(CS.XTextManager.GetText("FurnitureTips"), CS.XTextManager.GetText("FurnitureIsSave"), XUiManager.DialogType.Normal, function() + XHomeDormManager.RevertRoom(self.RoomId) + self:CloseFurnitureReform() + end, function() + XHomeDormManager.SaveRoomModification(self.RoomId, false, function() + self:CloseFurnitureReform() + end) + end) + else + self:CloseFurnitureReform() + end +end + +function XUiFurnitureReform:CloseFurnitureReform() + self:RestoreViewAngles() + self:Close() +end + +function XUiFurnitureReform:OnBtnShowDormAttr() + + if self.FurnitureTagTypeShow then + self.Template.gameObject:SetActiveEx(false) + self.FurnitureTagTypeShow = false + return + end + + self.FurnitureTagTypeShow = true + self.Template.gameObject:SetActiveEx(true) + self.DynamicTable:SetTotalCount(#self.FurnitureTagType) + self.DynamicTable:ReloadDataSync() +end + +function XUiFurnitureReform:OnBtnFilterClick() + self:ShowPanelFilter() +end + +function XUiFurnitureReform:OnBtnFilterBackClick() + self:HidePanelFilter() +end + +-- 全部收起 +function XUiFurnitureReform:OnBtnRecoverClick() + XUiManager.DialogTip(CS.XTextManager.GetText("FurnitureTips"), CS.XTextManager.GetText("FurnitureCleanRoom"), XUiManager.DialogType.Normal, nil, function() + XHomeDormManager.CleanRoom(self.RoomId) + end) +end + +-- 重置房间 +function XUiFurnitureReform:OnBtnUndoClick() + XUiManager.DialogTip(CS.XTextManager.GetText("FurnitureTips"), CS.XTextManager.GetText("FurnitureRevertRoom"), XUiManager.DialogType.Normal, nil, function() + XHomeDormManager.RevertRoom(self.RoomId) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_DORM_FURNITURE_ATTR_TAG, self.FurnitureTagType[self.SelectIndex].AttrIndex) + end) +end + +-- 保存房间 +function XUiFurnitureReform:OnBtnSaveClick() + XHomeDormManager.SaveRoomModification(self.RoomId) +end + +function XUiFurnitureReform:OnBtnExplainClick() + XUiManager.UiFubenDialogTip(CS.XTextManager.GetText("DormDes"), CS.XTextManager.GetText("FurnitureDescription") or "") +end + +-- 显示家具菜单 +function XUiFurnitureReform:ShowFurnitureMenu(furniture, isFollowMouse, isNew) + self.MainPanelGo:SetActive(not furniture) + local isOutOfLimit = false + if furniture and (not XDataCenter.FurnitureManager.CheckFurnitureUsing(furniture.Data.Id)) then + local minorType = XFurnitureConfigs.GetFurnitureTypeCfgByConfigId(furniture.Data.CfgId).MinorType + local curLength = XHomeDormManager.GetFurnitureNumsByRoomAndMinor(self.RoomId, minorType) + local curCapacity = XHomeDormManager.GetFurnitureCapacityByRoomANdMinor(self.RoomId, minorType, self.RoomType) + isOutOfLimit = (curCapacity > 0) and (curLength >= curCapacity) or false + end + self.MenuPanel:SetFurniture(furniture, isFollowMouse, isNew, isOutOfLimit) + + self.CurFurniture = furniture + self:OnShowBlockGrids() +end + +function XUiFurnitureReform:OnShowBlockGrids() + if self.CurFurniture then + XHomeDormManager.OnShowBlockGrids(self.CurFurniture.HomePlatType, self.CurFurniture.GridOffset, self.CurFurniture.RotateAngle) + end +end + +--初始化begin +function XUiFurnitureReform:Init() + self:InitType() + self:RestoreCache() + local roomFurnitureCount = XDataCenter.DormManager.GetRoomDataByRoomId(self.RoomId, self.RoomType).FurnitureCount + self.SViewFurniture = XUiPanelSViewFurniture.New(self.PanelSViewFurniture, self, roomFurnitureCount, self.RoomType) + --初始化家具类型 + self.TypeList = XFurnitureConfigs.GetFurnitureTypeGroupList() + self.FurnitureGroupList = self:GenerateFurnitureGroupList(self.TypeList) + self:InitFurnitureTabGroup() + + self.GridOption.gameObject:SetActive(false) + if not self.SuitCFG then + XLog.Warning("XUiFurnitureReform:Init error: self.SuitCFG is nil") + end + + self:InitFurnitureAttrTag() + + if not self.DynamicTableSuit then + self.DynamicTableSuit = XDynamicTableNormal.New(self.SViewFilter.gameObject) + self.DynamicTableSuit:SetProxy(XUiGridOption) + self.DynamicTableSuit:SetDelegate(self) + end + self:UpdateScores() + self:SwitchSuitFilter(self.CurrentSuitId or 1) +end + +function XUiFurnitureReform:InitType() + self.BtnDrdSort.gameObject:SetActiveEx(self.IsMyRoom) + self.PanelTool.gameObject:SetActiveEx(self.IsMyRoom) +end + +function XUiFurnitureReform:InitFurnitureAttrTag() + + self.FurnitureTagType = XFurnitureConfigs.GetFurnitureTagTypeTemplates() + self.FurnitureTagTypeShow = false + + + --local key = tostring(XPlayer.Id) .. "FurnitureAttr" + self.SelectIndex = 1 + XHomeDormManager.FurnitureShowAttrType = -1 + + + self.BtnDrdSortLabel.text = self.FurnitureTagType[self.SelectIndex].TagName + + --家具属性tips + self.DynamicTable = XDynamicTableNormal.New(self.Template) + self.DynamicTable:SetProxy(XUiFurnitureAttrGrid) + self.DynamicTable:SetDelegate(self) + self.DynamicTable:SetDynamicEventDelegate(function(...) + self:OnFurnitureAttrDynamicTableEvent(...) + end) + + + self.SelectGrid = nil + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_DORM_FURNITURE_ATTR_TAG, self.FurnitureTagType[self.SelectIndex].AttrIndex) + +end + +function XUiFurnitureReform:GenerateFurnitureGroupList() + local groupList = {} + + for i = 1, #self.TypeList do + local typeList = self.TypeList[i] + table.insert(groupList, { + MinorType = typeList.MinorType, + MinorName = typeList.MinorName, + isBaseType = true + }) + local subIndex = #groupList + for index = 1, #typeList.CategoryList do + local categoryData = typeList.CategoryList[index] + table.insert(groupList, { + MinorType = typeList.MinorType, + MinorName = typeList.MinorName, + SubIndex = subIndex, + CategoryType = categoryData.Category, + CategoryName = categoryData.CategoryName, + }) + end + end + return groupList +end + +function XUiFurnitureReform:InitFurnitureTabGroup() + for i = 1, #self.FurnitureGroupList do + local tempGroup = self.FurnitureGroupList[i] + if not self.BtnTabGoList[i] then + local tempBtnTab + if tempGroup.SubIndex and tempGroup.SubIndex > 0 then + tempBtnTab = CS.UnityEngine.Object.Instantiate(self.Obj:GetPrefab("BtnTabFurnitureSubType")) + else + tempBtnTab = CS.UnityEngine.Object.Instantiate(self.Obj:GetPrefab("BtnTabFurnitureBaseType")) + end + tempBtnTab.transform:SetParent(self.TabGroupContent.transform, false) + local uiButton = tempBtnTab:GetComponent("XUiButton") + uiButton.SubGroupIndex = tempGroup.SubIndex + table.insert(self.BtnTabGoList, uiButton) + end + self.BtnTabGoList[i].gameObject:SetActive(true) + end + + for i = #self.FurnitureGroupList + 1, #self.BtnTabGoList do + self.BtnTabGoList[i].gameObject:SetActive(false) + end + self.TabFurnitureGroup:Init(self.BtnTabGoList, function(index) self:OnSelectFurnitureType(index) end) + + for i = 0, #self.FurnitureGroupList - 1 do + local furnitureGroup = self.FurnitureGroupList[i + 1] + if furnitureGroup then + if furnitureGroup.SubIndex and furnitureGroup.SubIndex > 0 then + self.TabFurnitureGroup.TabBtnList[i]:SetNameByGroup(0, furnitureGroup.CategoryName) + + local count + local categoryList = self:GetCategoryListByMinorType(furnitureGroup.MinorType) + if #categoryList <= 0 then + count = self:GetBaseTypeCount(furnitureGroup.MinorType) + else + if furnitureGroup.CategoryType == 0 then + count = self:GetBaseTypeCount(furnitureGroup.MinorType) + else + count = self:GetSubTypeCount(furnitureGroup.MinorType, furnitureGroup.CategoryType) + end + end + self.TabFurnitureGroup.TabBtnList[i]:SetNameByGroup(1, count) + else + self.TabFurnitureGroup.TabBtnList[i]:SetNameByGroup(0, furnitureGroup.MinorName) + end + end + end + + self.TabFurnitureGroup:SelectIndex(1) + +end + +function XUiFurnitureReform:OnSelectFurnitureType(index) + local furnitureGroup = self.FurnitureGroupList[index] + self.LastSelectGroupIndex = index + if furnitureGroup then + self.LastBaseTypeId = self.CurrentBaseTypeId + self.CurrentBaseTypeId = furnitureGroup.MinorType + + --选中二级菜单 + local categoryList = self:GetCategoryListByMinorType(self.CurrentBaseTypeId) + if #categoryList <= 0 then + self:SwitchSubType(0) + else + self:SwitchSubType(furnitureGroup.CategoryType) + end + end +end + +function XUiFurnitureReform:SelectTypeByFurniture(furnitureId) + if not furnitureId or furnitureId <= 0 then return end + + local furntiureDatas = XDataCenter.FurnitureManager.GetFurnitureById(furnitureId) + if not furntiureDatas then return end + + local furnitureTemplates = XFurnitureConfigs.GetFurnitureTemplateById(furntiureDatas.ConfigId) + if not furnitureTemplates then return end + + local furnitureTypeTemplates = XFurnitureConfigs.GetFurnitureTypeById(furnitureTemplates.TypeId) + if not furnitureTypeTemplates then return end + + local index = 0 + local subIndex = 0 + for tabKey, tabValue in ipairs(self.FurnitureGroupList) do + if furnitureTypeTemplates.MinorType == tabValue.MinorType and tabValue.CategoryType and tabValue.CategoryType == furnitureTypeTemplates.Category then + index = tabKey + end + if furnitureTypeTemplates.MinorType == tabValue.MinorType and tabValue.CategoryType == nil then + subIndex = tabKey + end + end + + if index == 0 or (self.LastSelectGroupIndex and self.LastSelectGroupIndex == index) then return end + + local furnitureGroup = self.FurnitureGroupList[self.LastSelectGroupIndex] + if subIndex > 0 and furnitureGroup and furnitureGroup.MinorType ~= furnitureTypeTemplates.MinorType then + self.TabFurnitureGroup:SelectIndex(subIndex) + end + self.TabFurnitureGroup:SelectIndex(index) +end + +function XUiFurnitureReform:GetCategoryListByMinorType(minor) + local typeList = XFurnitureConfigs.GetFurnitureTypeList() + for _, v in pairs(typeList) do + if v.MinorType == minor then + return v.CategoryList + end + end + return {} +end + +function XUiFurnitureReform:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + self:OnRefreshSuit(index, grid) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + self:OnRefreshSuit(index, grid) + end +end + +function XUiFurnitureReform:OnRefreshSuit(index, grid) + local data = self.SuitCFG[index] + if not data then return end + grid:Init(data, self) +end + +--切换选择家具基础类型 +function XUiFurnitureReform:SwitchBaseType(baseTypeId) + if not baseTypeId then return end + self.CurrentBaseTypeId = baseTypeId + self.CurrentSubTypeId = nil + + self:UpdateItemsByFilter() + self:UpdatePanelLimit() + self:SwitchViewAngle(baseTypeId) +end + +function XUiFurnitureReform:SwitchViewAngle(minor) + local viewAngles = XFurnitureConfigs.GetFurnitureViewAngleByMinor(minor) + if not viewAngles then return end + if self.LastBaseTypeId then + local lastViewAngles = XFurnitureConfigs.GetFurnitureViewAngleByMinor(self.LastBaseTypeId) + if lastViewAngles and lastViewAngles.GroupId == viewAngles.GroupId then return end + end + + XHomeSceneManager.ChangeAngleYAndYAxis(viewAngles.TargetAngleY, viewAngles.AllowYAxis == 1) +end + +function XUiFurnitureReform:RestoreViewAngles() + local defaultTargetAngle = CS.XGame.ClientConfig:GetInt("DefaultDormTargetAngle") + local defaultAllowYAxis = CS.XGame.ClientConfig:GetInt("DefaultAllowYAxis") + XHomeSceneManager.ChangeAngleYAndYAxis(defaultTargetAngle, defaultAllowYAxis == 1) +end + +--切换选择家具二级类型 +function XUiFurnitureReform:SwitchSubType(subTypeId) + if not subTypeId then return end + if subTypeId == 0 then + self:SwitchBaseType(self.CurrentBaseTypeId) + return + end + self.CurrentSubTypeId = subTypeId + self:UpdateItemsByFilter() + self:UpdatePanelLimit() +end + +--隐藏二级类型 +function XUiFurnitureReform:HideSubTypePanel() + if self.PanelSubType.gameObject.activeSelf then + self.PanelSubType.gameObject:SetActive(false) + end +end + +--显示套装过滤面板 +function XUiFurnitureReform:ShowPanelFilter() + self.PanelFilterGameObject:SetActive(true) + + if not self.DynamicTableSuit then return end + self.DynamicTableSuit:SetDataSource(self.SuitCFG) + self.DynamicTableSuit:ReloadDataASync(1) + + self.FilterEnable:PlayTimelineAnimation() +end + +--隐藏套装过滤面板 +function XUiFurnitureReform:HidePanelFilter() + self.FilterDisable:PlayTimelineAnimation(function() + self.PanelFilterGameObject:SetActive(false) + end) +end + +--选择套装过滤 +function XUiFurnitureReform:SwitchSuitFilter(suitId) + self:HidePanelFilter() + self.CurrentSuitId = suitId + self.BtnFilter:SetNameByGroup(0, self.SuitCFG[suitId].SuitName) + + self:UpdateItemsByFilter() + self:UpdateCountOnChanged() + self:UpdatePanelLimit() +end + +function XUiFurnitureReform:UpdateCountOnChanged() + -- 切换了套装,数量要重新结算 + self:UpdateSubTypeCount() + -- 获得套装数量 + if self.CurrentSuitId then + self.BtnFilter:SetNameByGroup(1, self:CalcFurnitureNumsBySuitId(self.CurrentSuitId)) + end +end + +function XUiFurnitureReform:CalcFurnitureNumsBySuitId(suitId) + if not self.RoomId then return 0 end + if self.IsMyRoom then + return XDataCenter.FurnitureManager.GetFurnitureCountBySuitId(self.RoomId, FurnitureCache, suitId) + end + + return XFurnitureConfigs.GetSuitCount(suitId) +end + +--根据条件过滤家具 +function XUiFurnitureReform:UpdateItemsByFilter() + if delayRefreshTimer then + XScheduleManager.UnSchedule(delayRefreshTimer) + delayRefreshTimer = nil + end + + delayRefreshTimer = XScheduleManager.ScheduleOnce(function() + local cacheKey = self:GetCacheKey(self.CurrentBaseTypeId, self.CurrentSubTypeId) + self:SortFurnitureCache(FurnitureCache[cacheKey]) + + local filterSuitCache + if self.IsMyRoom then + filterSuitCache = self:FilterCacheBySuitId(FurnitureCache[cacheKey] or {}) + else + filterSuitCache = XFurnitureConfigs.GetFurnitureCfgList(self.CurrentBaseTypeId, self.CurrentSubTypeId, self.CurrentSuitId) + end + + if self.SViewFurniture then + self.SViewFurniture:UpdateItems(filterSuitCache) + self.AnimFurnitureList:PlayTimelineAnimation() + end + end, 100) + +end + +function XUiFurnitureReform:FilterCacheBySuitId(cache) + local suitCache = {} + + if (not self.CurrentSuitId) or (not cache) or self.CurrentSuitId == 1 then return cache end + + for _, v in ipairs(cache) do + local furntiureTemplate = XFurnitureConfigs.GetFurnitureTemplateById(v.ConfigId) + if furntiureTemplate.SuitId == self.CurrentSuitId then + table.insert(suitCache, v) + end + end + return suitCache +end + +function XUiFurnitureReform:SortFurnitureCache(cache) + + if not cache then return end + + local j + + for i = 2, #cache do + local temp = cache[i] + j = i - 1 + while (j > 0) do + local totalJScores = XDataCenter.FurnitureManager.GetFurnitureScore(cache[j].Id) + local totalIScores = XDataCenter.FurnitureManager.GetFurnitureScore(temp.Id) + if totalIScores <= totalJScores then + break + end + cache[j + 1] = cache[j] + j = j - 1 + end + cache[j + 1] = temp + end + +end + +-- 更新家具的数量 +function XUiFurnitureReform:UpdateSubTypeCount() + if not self.FurnitureGroupList then return end + for i = 0, #self.FurnitureGroupList - 1 do + local furnitureGroup = self.FurnitureGroupList[i + 1] + if furnitureGroup then + local categoryList = self:GetCategoryListByMinorType(furnitureGroup.MinorType) + + local count + if #categoryList <= 0 then + count = self:GetBaseTypeCount(furnitureGroup.MinorType) + else + if furnitureGroup.CategoryType == nil or furnitureGroup.CategoryType == 0 then + count = self:GetBaseTypeCount(furnitureGroup.MinorType) + else + count = self:GetSubTypeCount(furnitureGroup.MinorType, furnitureGroup.CategoryType) + end + end + + self.TabFurnitureGroup.TabBtnList[i]:SetNameByGroup(1, count) + end + end +end + +function XUiFurnitureReform:GetBaseTypeCount(minor) + if self.IsMyRoom then + local cacheKey = self:GetCacheKey(minor, nil) + return XDataCenter.FurnitureManager.GetFurnitureCountByMinorTypeAndSuitId(self.RoomId, FurnitureCache[cacheKey], self.CurrentSuitId, minor) + end + + return XFurnitureConfigs.GetCountByMinor(minor, self.CurrentSuitId) +end + +function XUiFurnitureReform:GetSubTypeCount(minor, category) + if self.IsMyRoom then + local cacheKey = self:GetCacheKey(minor, category) + return XDataCenter.FurnitureManager.GetFurnitureCountByMinorAndCategoryAndSuitId(self.RoomId, FurnitureCache[cacheKey], self.CurrentSuitId, minor, category) + end + + return XFurnitureConfigs.GetCountByCategory(minor, category, self.CurrentSuitId) +end + +function XUiFurnitureReform:GetCurrentSuitId() + return self.CurrentSuitId or 1 +end + +--更新放置限制面板 +function XUiFurnitureReform:UpdatePanelLimit() + if not self.CurrentBaseTypeId then return end + local typeList = XFurnitureConfigs.GetFurnitureTypeList() + for _, v in pairs(typeList) do + if self.CurrentBaseTypeId == v.MinorType then + self.TxtLimit.text = v.MinorName + if self.CurrentSubTypeId ~= nil and #v.CategoryList > 0 then + for _, category in pairs(v.CategoryList) do + if self.CurrentSubTypeId == category.Category then + self.TxtLimit.text = string.format("%s-%s", v.MinorName, category.CategoryName) + break + end + end + end + break + end + end +end + + +function XUiFurnitureReform:UpdateScores() + if self.RoomType ~= XDormConfig.DormDataType.Self then + return + end + + if delayUpdateScoresTimer then + XScheduleManager.UnSchedule(delayUpdateScoresTimer) + delayUpdateScoresTimer = nil + end + delayUpdateScoresTimer = XScheduleManager.ScheduleOnce(function() + if self.RoomId then + local newFurnitureAttrs = XHomeDormManager.GetFurnitureScoresByRoomId(self.RoomId) + local oldFurnitureAttrs = XHomeDormManager.GetFurnitureScoresByUnsaveRoom(self.RoomId) + + -- 总评分 + local oldScores = oldFurnitureAttrs.TotalScore + local newScores = newFurnitureAttrs.TotalScore + self.TxtTotalScore.text = XFurnitureConfigs.GetFurnitureTotalAttrLevelNewColorDescription(1, newScores) + self.ImgTotalScoreDown.gameObject:SetActive(newScores < oldScores) + self.ImgTotalScoreUp.gameObject:SetActive(newScores > oldScores) + + -- 三个属性分 + for i = 1, #newFurnitureAttrs.AttrList do + local attrOldVal = oldFurnitureAttrs.AttrList[i] + local attrNewVal = newFurnitureAttrs.AttrList[i] + local typeDatas = XFurnitureConfigs.GetDormFurnitureType(i) + self:SetUiSprite(self[string.format("ImgTool%d", i)], typeDatas.TypeIcon) + self[string.format("TxtAttrTool%d", i)].text = XFurnitureConfigs.GetFurnitureAttrLevelNewDescription(1, i, attrNewVal) + self[string.format("ImgScoreUp%d", i)].gameObject:SetActive(attrOldVal < attrNewVal) + self[string.format("ImgScoreDown%d", i)].gameObject:SetActive(attrOldVal > attrNewVal) + end + end + end, 50) +end + +function XUiFurnitureReform:GetCacheKey(baseType, subType) + return XDataCenter.FurnitureManager.GenerateCacheKey(baseType, subType) +end + +function XUiFurnitureReform:ResetCache() + FurnitureCache = {} +end + +function XUiFurnitureReform:RestoreCache() + local typeList = XFurnitureConfigs.GetFurnitureTypeList() + for _, typeDatas in pairs(typeList) do + local baseType = typeDatas.MinorType + local cacheBaseKey = self:GetCacheKey(baseType, nil) + FurnitureCache[cacheBaseKey] = XDataCenter.FurnitureManager.FilterDisplayFurnitures(self.RoomId, 1, baseType, nil) + + for _, categoryList in pairs(typeDatas.CategoryList) do + local subType = categoryList.Category + if subType ~= 0 then + local cacheSubKey = self:GetCacheKey(baseType, subType) + FurnitureCache[cacheSubKey] = XDataCenter.FurnitureManager.FilterDisplayFurnitures(self.RoomId, 1, baseType, subType) + end + end + end +end + +function XUiFurnitureReform:UpdateCacheFurniture(isRemove, furntiureId) + + local furnitureDatas = XDataCenter.FurnitureManager.GetFurnitureById(furntiureId) + if not furnitureDatas then return end + local furnitureTemplates = XFurnitureConfigs.GetFurnitureTemplateById(furnitureDatas.ConfigId) + local furntiureTypeTemplates = XFurnitureConfigs.GetFurnitureTypeById(furnitureTemplates.TypeId) + + local baseCacheKey = self:GetCacheKey(furntiureTypeTemplates.MinorType, nil) + local baseSubCacheKey = self:GetCacheKey(furntiureTypeTemplates.MinorType, furntiureTypeTemplates.Category) + if isRemove then--收纳家具 + self:AddCacheToList(FurnitureCache[baseCacheKey], furnitureDatas) + if FurnitureCache[baseSubCacheKey] then + self:AddCacheToList(FurnitureCache[baseSubCacheKey], furnitureDatas) + end + else--摆放家具 + self:RemoveCacheFromList(FurnitureCache[baseCacheKey], furntiureId) + if FurnitureCache[baseSubCacheKey] then + self:RemoveCacheFromList(FurnitureCache[baseSubCacheKey], furntiureId) + end + end + + self:UpdateItemsByFilter() + +end + +function XUiFurnitureReform:AddCacheToList(cache, furnitureDatas) + for _, v in pairs(cache) do + if v.Id == furnitureDatas.Id then + return + end + end + + table.insert(cache, furnitureDatas) +end + +function XUiFurnitureReform:RemoveCacheFromList(cache, furnitureId) + local index = 0 + local length = #cache + for k, v in pairs(cache) do + if v.Id == furnitureId then + index = k + break + end + end + if index == 0 then return end + cache[index] = nil + for i = index, length - 1 do + cache[i] = cache[i + 1] + end + cache[length] = nil + +end + +function XUiFurnitureReform:OnGetEvents() + return { XEventId.EVENT_FURNITURE_ONDRAGITEM_CHANGED, XEventId.EVENT_FURNITURE_REFRESH, XEventId.EVENT_FURNITURE_CLEANROOM, XEventId.EVENT_CLICKFURNITURE_ONROOM } +end + +function XUiFurnitureReform:OnNotify(evt, ...) + if evt == XEventId.EVENT_FURNITURE_ONDRAGITEM_CHANGED then + local args = { ... } + if not args then return end + self:UpdateCacheFurniture(args[1], args[2]) + self:UpdateCountOnChanged() + self:UpdatePanelLimit() + self:UpdateScores() + + elseif evt == XEventId.EVENT_FURNITURE_REFRESH then + self:RefreshFurntiureReform() + elseif evt == XEventId.EVENT_FURNITURE_CLEANROOM then + + self:UpdatePanelLimit() + self:UpdateScores() + + elseif evt == XEventId.EVENT_CLICKFURNITURE_ONROOM then + + local args = { ... } + if not args then return end + self:SelectTypeByFurniture(args[1]) + end +end + +function XUiFurnitureReform:RefreshFurntiureReform() + self:RestoreCache() + self:UpdateItemsByFilter() + + self:UpdateCountOnChanged() + self:UpdatePanelLimit() + self:UpdateScores() +end + +function XUiFurnitureReform:OnDestroy() + if delayRefreshTimer then + XScheduleManager.UnSchedule(delayRefreshTimer) + delayRefreshTimer = nil + end + + if delayUpdateScoresTimer then + XScheduleManager.UnSchedule(delayUpdateScoresTimer) + delayUpdateScoresTimer = nil + end + XEventManager.RemoveEventListener(XEventId.EVENT_FURNITURE_ON_MODIFY, self.RefreshFurnitureList, self) + local isResetPosition = true + XHomeCharManager.ShowAllCharacter(isResetPosition) + + if not XTool.UObjIsNil(self.CameraController) then + self.CameraController:SetTartAngle(CS.UnityEngine.Vector2(self.TargetAngleX, self.TargetAngleY)) + XCameraHelper.SetCameraTarget(self.CameraController, self.OldCameraTarget, self.OldCameraDistance) + end + self.CameraController = nil + self.OldCameraTarget = nil + self.OldCameraDistance = nil + self.TargetAngleX = nil + self.TargetAngleY = nil + XDataCenter.FurnitureManager.SetInRefeform(false) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_DORM_FURNITURE_HIDE_ALL_ATTR_TAG_DETAIL) +end + + +function XUiFurnitureReform:OnFurnitureAttrDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + + local isSelect = false + if self.SelectIndex == index then + self.SelectGrid = grid + isSelect = true + end + grid:SetSelect(isSelect) + grid:SetContent(self.FurnitureTagType[index]) + + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + + if self.SelectIndex == index then + return + end + + if self.SelectGrid then + self.SelectGrid:SetSelect(false) + end + + self.SelectGrid = grid + self.SelectIndex = index + grid:SetSelect(true) + + local cfg = self.FurnitureTagType[index] + self.BtnDrdSortLabel.text = cfg.TagName + + XHomeDormManager.FurnitureShowAttrType = cfg.AttrIndex + --CS.UnityEngine.PlayerPrefs.SetInt(tostring(XPlayer.Id) .. "FurnitureAttr", cfg.AttrIndex) + --CS.UnityEngine.PlayerPrefs.Save() + CsXGameEventManager.Instance:Notify(XEventId.EVENT_DORM_FURNITURE_ATTR_TAG, cfg.AttrIndex) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDorm/XUiFurnitureReform/XUiGridFurniture.lua b/Resources/Scripts/XUi/XUiDorm/XUiFurnitureReform/XUiGridFurniture.lua new file mode 100644 index 00000000..42433288 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDorm/XUiFurnitureReform/XUiGridFurniture.lua @@ -0,0 +1,227 @@ +XUiGridFurniture = XClass(nil, "XUiGridFurniture") + +function XUiGridFurniture:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + self.GridAttributePool = {} + self.GridAttribute.gameObject:SetActiveEx(false) +end + +function XUiGridFurniture:Init(rootUi, parent, roomFurniureCount) + self.RootUi = rootUi + self.Parent = parent + self.RoomFurnitureCount = roomFurniureCount + --初始化家具属性 + self.PointerDownPosition = nil + self.UiFurnitureScore = XUiFurnitureScore.New(self.RootUi, self.PanelFurnitureScore) + + self.BtnItemWidget = self.BtnItem:GetComponent("XUiWidget") + self.BtnItemWidget:AddPointerDownListener(function(data) self:OnBtnItemPointerDown(data) end) + self.BtnItemWidget:AddDragListener(function(data) self:OnBtnItemOnDrag(data) end) + self.BtnItemWidget:AddPointerClickListener(function(data) self:OnBtnItemClick(data) end) + + self.BtnItemWidget:AddBeginDragListener(function(data) self:OnBtnItemOnBeginDrag(data) end) + self.BtnItemWidget:AddEndDragListener(function(data) self:OnBtnItemOnEndDrag(data) end) +end + +-- 按下家具item +function XUiGridFurniture:OnBtnItemPointerDown(data) + self.PointerDownPosition = data.position.y + + XHomeDormManager.AttachSurfaceToRoom(self.RootUi.RoomId) + + if not self.Data then + return + end + + local cfg = XFurnitureConfigs.GetFurnitureTemplateById(self.Data.ConfigId) + if not cfg then + return + end + + local type = XFurnitureConfigs.LocateTypeToXHomePlatType(cfg.LocateType) + XHomeDormManager.ShowSurface(type) +end + +function XUiGridFurniture:OnBtnItemOnBeginDrag(data) + self.IsDraging = true + self.Parent:OnBeginDrag(data) +end + +function XUiGridFurniture:OnBtnItemOnEndDrag(data) + self.IsDraging = false + self.Parent:OnEndDrag(data) +end + +-- 拖动家具item +function XUiGridFurniture:OnBtnItemOnDrag(data) + if not self.Data then + return + end + + local cfg = XFurnitureConfigs.GetFurnitureTemplateById(self.Data.ConfigId) + if not cfg then + return + end + + if XHomeDormManager.CheckFurnitureCountReachLimitByPutNumType(self.RootUi.RoomId, cfg.PutNumType) and cfg.LocateType ~= XFurnitureConfigs.HomeLocateType.Replace then + XUiManager.TipError(CS.XTextManager.GetText("FurnitureOutOfLimit")) + return + end + + local room = XHomeDormManager.GetRoom(self.RootUi.RoomId) + local furnitures = room:GetAllFurnitureConfig() + if #furnitures >= XFurnitureConfigs.MaxPutFurnitureCount then + if cfg.LocateType ~= XFurnitureConfigs.HomeLocateType.Replace then + XUiManager.TipText("DormMaxPutFurnitureCountHit", XUiManager.UiTipType.Tip) + return + end + end + + if not self.PointerDownPosition then + return + end + self.Parent:OnDrag(data) + if data.position.y - self.PointerDownPosition < self.Parent.ControlLimit then + return + end + + + if cfg.LocateType ~= XFurnitureConfigs.HomeLocateType.Replace then + -- 家具 + local camera = XHomeSceneManager.GetSceneCamera() + if not XTool.UObjIsNil(camera) then + local ray = camera:ScreenPointToRay(CS.UnityEngine.Vector3(data.position.x, data.position.y, 0)) + local layerMask = CS.UnityEngine.LayerMask.GetMask("HomeSurface") + if (layerMask) then + local ret, hit = ray:RayCast(layerMask) + if ret then + self.PointerDownPosition = nil + local gridPos, rotate = XHomeDormManager.GetGridPosByWorldPos(hit.point, hit.transform, cfg.Width, cfg.Height) + self.Furniture = XHomeDormManager.CreateFurniture(self.RootUi.RoomId, self.Data, gridPos, rotate) + if not self.Furniture then + return + end + self.RootUi:ShowFurnitureMenu(self.Furniture, true, true) + end + end + end + -- else + -- 改造 + end +end + +function XUiGridFurniture:GetWallWidthAndHeightByRotate(rotateAngle) + local mapWidth, mapHeight + local rot = rotateAngle % 2 + if rot == 0 then + mapWidth = XHomeDormManager.GetMapWidth() + mapHeight = XHomeDormManager.GetMapTall() + else + mapWidth = XHomeDormManager.GetMapHeight() + mapHeight = XHomeDormManager.GetMapTall() + end + return mapWidth, mapHeight +end + +-- 点击家具item +function XUiGridFurniture:OnBtnItemClick(data) + if self.IsDraging then + return + end + + if not data then + return + end + + local cfg = XFurnitureConfigs.GetFurnitureTemplateById(self.Data.ConfigId) + if not cfg then + return + end + + if XHomeDormManager.CheckFurnitureCountReachLimitByPutNumType(self.RootUi.RoomId, cfg.PutNumType) and cfg.LocateType ~= XFurnitureConfigs.HomeLocateType.Replace then + XUiManager.TipError(CS.XTextManager.GetText("FurnitureOutOfLimit")) + return + end + + local room = XHomeDormManager.GetRoom(self.RootUi.RoomId) + local furnitures = room:GetAllFurnitureConfig() + if #furnitures >= XFurnitureConfigs.MaxPutFurnitureCount then + if cfg.LocateType ~= XFurnitureConfigs.HomeLocateType.Replace then + XUiManager.TipText("DormMaxPutFurnitureCountHit", XUiManager.UiTipType.Tip) + return + end + end + + -- 墙上的,初始化墙上位置数据 + local pos = {} + pos.x = 15 + pos.y = 15 + local rotate = 0 + if cfg.LocateType == XFurnitureConfigs.HomeLocateType.LocateWall then + rotate = XHomeDormManager.DormistoryGetFarestWall(self.RootUi.RoomId) - 1 + local wallWidth, wallHeight = self:GetWallWidthAndHeightByRotate(rotate) + pos.x = math.floor(wallWidth / 2 - cfg.Width / 2) + pos.y = math.floor(wallHeight / 2 - cfg.Height / 2) + end + + self.Furniture = XHomeDormManager.CreateFurniture(self.RootUi.RoomId, self.Data, pos, rotate) + if not self.Furniture then + return + end + + self.Furniture:SetInteractInfoGo() + if cfg.LocateType == XFurnitureConfigs.HomeLocateType.Replace then + -- 改造 + XHomeDormManager.ReplaceSurface(self.RootUi.RoomId, self.Furniture) + else + -- 家具 + self.RootUi:ShowFurnitureMenu(self.Furniture, false, true) + self.Furniture:ShowSelectGrid() + end +end + +--更新表现 +function XUiGridFurniture:UpdateData(data, roomType) + if not data then + return + end + + local isMyRoom = roomType == XDormConfig.DormDataType.Self + local baseData = XFurnitureConfigs.GetFurnitureBaseTemplatesById(data.ConfigId) + self.TxtName.text = baseData.Name + if isMyRoom then + self.ImgIcon:SetRawImage(XDataCenter.FurnitureManager.GetFurnitureIconById(data.Id, XDormConfig.DormDataType.Self)) + else + local cfg = XFurnitureConfigs.GetFurnitureBaseTemplatesById(data.ConfigId) + local icon = cfg and cfg.Icon or "" + self.ImgIcon:SetRawImage(icon) + end + + self.Data = data + + self.PanelFurnitureScore.gameObject:SetActiveEx(isMyRoom) + if isMyRoom then + self:UpdateAttributeItems() + end +end + +function XUiGridFurniture:UpdateAttributeItems() + local attributes = {} + for k, v in pairs(self.Data.AttrList) do + attributes[k] = { + Id = k, + Val = v, + FurnitureId = self.Data.Id + } + end + + XUiHelper.CreateTemplates(self.RootUi, self.GridAttributePool, attributes, XUiGridAttribute.New, self.GridAttribute, self.PanelFurnitureScore, XUiGridAttribute.Init) + for i = 1, #attributes do + self.GridAttributePool[i].GameObject:SetActiveEx(true) + end +end + +return XUiGridFurniture \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDorm/XUiFurnitureReform/XUiGridOption.lua b/Resources/Scripts/XUi/XUiDorm/XUiFurnitureReform/XUiGridOption.lua new file mode 100644 index 00000000..8c660040 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDorm/XUiFurnitureReform/XUiGridOption.lua @@ -0,0 +1,60 @@ +-- 家具套装筛选节点 +XUiGridOption = XClass(nil, "XUiGridOption") + +function XUiGridOption:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + self:AddBtnsListeners() +end + +function XUiGridOption:AddBtnsListeners() + self.AutoCreateListeners = {} + XUiHelper.RegisterClickEvent(self, self.BtnOption, self.OnBtnOptionClick) +end + +function XUiGridOption:RegisterListener(uiNode, eventName, func) + if not uiNode then return end + local key = eventName .. uiNode:GetHashCode() + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiBtnTab:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiGridOption:OnBtnOptionClick() + if self.SuitId then + self.RootUi:SwitchSuitFilter(self.SuitId) + end +end + +function XUiGridOption:Init(cfg, rootUi) + self.RootUi = rootUi + + self:UpdateOption(cfg) + + self.ImgBackGround.gameObject:SetActive(self.RootUi:GetCurrentSuitId() == self.SuitId) +end + +function XUiGridOption:UpdateOption(cfg) + self.SuitId = cfg.Id + self.TxtOption.text = cfg.SuitName + self.ImgIcon:SetRawImage(cfg.SuitIcon) + self.TxtCount.text = self.RootUi:CalcFurnitureNumsBySuitId(self.SuitId) +end + +return XUiGridOption \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDorm/XUiFurnitureReform/XUiPanelMenu.lua b/Resources/Scripts/XUi/XUiDorm/XUiFurnitureReform/XUiPanelMenu.lua new file mode 100644 index 00000000..6d623187 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDorm/XUiFurnitureReform/XUiPanelMenu.lua @@ -0,0 +1,196 @@ +local XUiPanelMenu = XClass(XLuaBehaviour, "XUiPanelMenu") + +function XUiPanelMenu:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + + self.IsNew = false + self.IsFollowMouse = false + self.IsShow = false + self.Furniture = nil + + XTool.InitUiObject(self) + self.BtnCancel.CallBack = function() self:OnBtnCancelClick() end + self.BtnStorage.CallBack = function() self:OnBtnStorageClick() end + self.BtnRotate.CallBack = function() self:OnBtnRotateClick() end + self.BtnOk.CallBack = function() self:OnBtnOkClick() end + self.BtnBuild.CallBack = function() self:OnBtnBuildClick() end +end + +function XUiPanelMenu:Update() + if not self.Furniture then + self:ShowButtons(false) + return + end + + if XTool.UObjIsNil(self.Furniture.GameObject) then + self:ShowButtons(false) + return + end + + local camera = XHomeSceneManager.GetSceneCamera() + if XTool.UObjIsNil(camera) then + self:ShowButtons(false) + return + end + + self:ShowButtons(true) + if self.IsFollowMouse then + local screenPoint + if CS.UnityEngine.Application.platform == CS.UnityEngine.RuntimePlatform.WindowsEditor or + CS.UnityEngine.Application.platform == CS.UnityEngine.RuntimePlatform.WindowsPlayer then + if CS.UnityEngine.Input.GetMouseButtonUp(0) then + self.IsFollowMouse = false + end + screenPoint = CS.UnityEngine.Vector2(CS.UnityEngine.Input.mousePosition.x, CS.UnityEngine.Input.mousePosition.y) + else + if CS.UnityEngine.Input.touches.Length > 0 then + screenPoint = CS.UnityEngine.Input.GetTouch(0).position + else + self.IsFollowMouse = false + end + end + if screenPoint then + self.Furniture:AdjustPosition(screenPoint) + end + end + + local viewportPos = camera:WorldToViewportPoint(self.Furniture:GetCenterPosition()) + local uiDesignSize = XGlobalVar.UiDesignSize + self.Transform.anchoredPosition = CS.UnityEngine.Vector2((viewportPos.x - 0.5) * uiDesignSize.Width, (viewportPos.y - 0.5) * uiDesignSize.Height) + +end + +-- 显示该面板 +function XUiPanelMenu:Show(show) + if self.IsShow == show then + return + end + + XHomeDormManager.SetSelectedFurniture(show) + self.IsShow = show + self.GameObject:SetActive(show) + if show then + XHomeDormManager.SetRoomInteractInfo(self.RootUi.RoomId) + self.RootUi:OnShowBlockGrids() + else + XHomeDormManager.HideRoomInteractInfo(self.RootUi.RoomId) + self.RootUi:OnHideBlockGrids() + end +end + +-- 显示菜单按钮 +function XUiPanelMenu:ShowButtons(show) + self.BtnCancel.gameObject:SetActive(show) + self.BtnStorage.gameObject:SetActive(show) + self.BtnRotate.gameObject:SetActive(show) + self.BtnOk.gameObject:SetActive(show) +end + +-- 设置该面板的家具对象 +function XUiPanelMenu:SetFurniture(furniture, isFollowMouse, isNew, isOutOfLimit) + if furniture then + furniture.IsSelected = true + self.IsFollowMouse = isFollowMouse + local _, _, rotate = furniture:GetPos() + local type = furniture:GetXHomePlatType() + XHomeDormManager.LockCollider(rotate) + if furniture.PlaceType == XFurniturePlaceType.OnWall then + furniture.Room.Wall:ShowFixGrid(true, rotate) + elseif furniture.PlaceType == XFurniturePlaceType.OnGround then + furniture.Room.Ground:ShowFixGrid(true) + end + + --TODO Test + XHomeDormManager.AttachSurfaceToRoom(furniture.Room.Data.Id) + XHomeDormManager.ShowSurface(type) + else + if self.Furniture then + self.Furniture.IsSelected = false + end + -- local type = self.Furniture:GetXHomePlatType() + end + + self.IsNew = isNew + self.Furniture = furniture + self.IsOutOfLimit = isOutOfLimit + self:Show(furniture ~= nil) +end + +-- 取消 +function XUiPanelMenu:OnBtnCancelClick() + if self.Furniture.PlaceType == XFurniturePlaceType.OnWall then + self.Furniture.Room.Wall:ShowFixGrid(false) + elseif self.Furniture.PlaceType == XFurniturePlaceType.OnGround then + self.Furniture.Room.Ground:ShowFixGrid(false) + end + + if self.IsNew then + self.Furniture:Storage() + else + self.Furniture:RevertPosition() + end + + self.RootUi:ShowFurnitureMenu(nil) + XHomeDormManager.UnlockCollider() +end + +-- 收纳 +function XUiPanelMenu:OnBtnStorageClick() + if self.Furniture.PlaceType == XFurniturePlaceType.OnWall then + self.Furniture.Room.Wall:ShowFixGrid(false) + elseif self.Furniture.PlaceType == XFurniturePlaceType.OnGround then + self.Furniture.Room.Ground:ShowFixGrid(false) + end + self.Furniture:Storage() + self.RootUi:ShowFurnitureMenu(nil) + XHomeDormManager.UnlockCollider() +end + +-- 旋转 +function XUiPanelMenu:OnBtnRotateClick() + if self.Furniture.PlaceType == XFurniturePlaceType.OnGround then + local x, y, rotate = self.Furniture:GetPos() + rotate = rotate + 1 + rotate = rotate % 4 + self.Furniture:SetPos(x, y, rotate) + end +end + +-- 创建 +function XUiPanelMenu:OnBtnBuildClick() + if XDataCenter.FurnitureManager.IsFurnitureCreatePosFull() then + XUiManager.TipText("FurnitureBuildingListFull") + return + end + + XLuaUiManager.Open("UiFurnitureCreate", self.Furniture.Cfg.TypeId) +end + +-- 确定 +function XUiPanelMenu:OnBtnOkClick() + if not self.Furniture:CheckCanLocate() then + XUiManager.TipError(CS.XTextManager.GetText("FurniturePlaceNotCorrect")) + return + end + if self.IsOutOfLimit then + XUiManager.TipError(CS.XTextManager.GetText("FurnitureOutOfLimit")) + return + end + -- if self.Furniture:CheckPutTypeCountReachLimit() then + -- XUiManager.TipError(CS.XTextManager.GetText("FurnitureOutOfLimit")) + -- return + -- end + if self.Furniture.PlaceType == XFurniturePlaceType.OnWall then + self.Furniture.Room.Wall:ShowFixGrid(false) + elseif self.Furniture.PlaceType == XFurniturePlaceType.OnGround then + self.Furniture.Room.Ground:ShowFixGrid(false) + end + self.Furniture:LocateFurniture() + self.RootUi:ShowFurnitureMenu(nil) + + XHomeDormManager.UnlockCollider() +end + +return XUiPanelMenu \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDorm/XUiFurnitureReform/XUiPanelSViewFurniture.lua b/Resources/Scripts/XUi/XUiDorm/XUiFurnitureReform/XUiPanelSViewFurniture.lua new file mode 100644 index 00000000..bd555ebc --- /dev/null +++ b/Resources/Scripts/XUi/XUiDorm/XUiFurnitureReform/XUiPanelSViewFurniture.lua @@ -0,0 +1,134 @@ +XUiPanelSViewFurniture = XClass(nil, "XUiPanelSViewFurniture") + +function XUiPanelSViewFurniture:Ctor(ui, rootUi, roomFurnitrueCount, roomType) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self.IsActive = true + self.RoomType = roomType + self.RoomFurnitureCount = roomFurnitrueCount + self.Items = {} + self.ControlLimit = CS.XGame.ClientConfig:GetInt("UiGridFurnitureControlLimit") + self:InitAutoScript() + self:Init() +end + +function XUiPanelSViewFurniture:Init() + self.ScrollRect = self.Transform:GetComponent("ScrollRect") + self.DynamicTable = XDynamicTableNormal.New(self.Transform) + self.DynamicTable:SetProxy(XUiGridFurniture) + self.DynamicTable:SetDelegate(self) +end + +function XUiPanelSViewFurniture:OnDrag(eventData) + if self.ScrollRect then + self.ScrollRect:OnDrag(eventData); + end +end + +function XUiPanelSViewFurniture:OnBeginDrag(eventData) + if self.ScrollRect then + self.ScrollRect:OnBeginDrag(eventData); + end +end + +function XUiPanelSViewFurniture:OnEndDrag(eventData) + if self.ScrollRect then + self.ScrollRect:OnEndDrag(eventData); + end +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelSViewFurniture:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiPanelSViewFurniture:AutoInitUi() + self.GridFurniture = self.Transform:Find("Viewport/Content/GridFurniture") +end + +function XUiPanelSViewFurniture:GetAutoKey(uiNode, eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiPanelSViewFurniture:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiPanelSViewFurniture:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiPanelSViewFurniture:AutoAddListener() + self.AutoCreateListeners = {} +end +-- auto +function XUiPanelSViewFurniture:HidePanel() + if not self.IsActive then return end + + self.GameObject:SetActive(false) + self.IsActive = false + +end + +function XUiPanelSViewFurniture:ShowPanel() + if self.IsActive then return end + + self.GameObject:SetActive(true) + self.IsActive = true + +end + +--重载数据 +function XUiPanelSViewFurniture:UpdateItems(datas) + if #datas > 0 then + self:ShowPanel() + self.Items = datas + self.DynamicTable:SetDataSource(self.Items) + self.DynamicTable:ReloadDataASync() + else + self:HidePanel() + end +end + +--动态列表事件 +function XUiPanelSViewFurniture:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self.RootUi, self, self.RoomFurnitureCount) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.Items[index] + if data == nil then return end + grid:UpdateData(data, self.RoomType) + end +end + +--更新家具信息 +function XUiPanelSViewFurniture:UpdateGoods(itemId) + for k, v in pairs(self.Items) do + if v.Id == itemId then + local grid = self.DynamicTable:GetGridByIndex(k) + grid:UpdateData(v, self.RoomType) + end + end +end + +return XUiPanelSViewFurniture \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormBag/XUiDormBag.lua b/Resources/Scripts/XUi/XUiDormBag/XUiDormBag.lua new file mode 100644 index 00000000..2c15f58c --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormBag/XUiDormBag.lua @@ -0,0 +1,799 @@ +local DormBagItem = require("XUi/XUiDormBag/XUiPanelDormBagItem") +local XUiRecyclePreview = require("XUi/XUiDormBag/XUiRecyclePreview") +local XUiDormBag = XLuaUiManager.Register(XLuaUi, "UiDormBag") + +local SELECT_OFFSET_MIN = CS.UnityEngine.Vector2(32, 155) +local SELECT_OFFSET_MAX = CS.UnityEngine.Vector2(-59, -216) +local SELECT_TYPE_ALL = 0 + +function XUiDormBag:OnAwake() + self:AddListener() +end + +function XUiDormBag:OnStart(pageRecord, furnitureState, selectCb, filter, needDaftCount, furnitureTypeId) + self.SelectIds = {} -- 记录筛选的ConfigId + self.SelectSuitIds = {} -- 记录套装筛选的ConfigId + self.NeedDraftCount = needDaftCount or 0 -- 需要图纸数量 + self.PriorSortType = XFurnitureConfigs.PriorSortType.All + + self:InitFurniturePart() + self:InitRecyclePreview() + self:InitPrivateVariable(pageRecord, furnitureState, selectCb, filter) + self:InitDynamicTable() + self:InitTabGroup(furnitureTypeId) + self:SetAscendBtn() + + self.AssetPanel = XUiPanelAsset.New(self, self.PanelHostelAsset, XDataCenter.ItemManager.ItemId.DormCoin, XDataCenter.ItemManager.ItemId.FurnitureCoin) +end + +function XUiDormBag:OnDestroy() + self.SelectIds = nil + self.SelectSuitIds = nil + self.PageRecord = 0 + self.CharPageRecord = 0 + self.FurnitureState = 0 + self.AscendSort = false +end + +function XUiDormBag:OnEnable() + self:RefreshSelectedPanel(self.PageRecord, true) + XEventManager.AddEventListener(XEventId.EVENT_CLICKFURNITURE_GRID, self.OnFurnitureGridClick, self) + XEventManager.AddEventListener(XEventId.EVENT_CLICKDRAFT_GRID, self.OnDraftGridClick, self) + XEventManager.AddEventListener(XEventId.EVENT_DORM_BAG_REFRESH, self.UpdateDynamicTable, self) +end + +function XUiDormBag:OnDisable() + XEventManager.RemoveEventListener(XEventId.EVENT_CLICKFURNITURE_GRID, self.OnFurnitureGridClick, self) + XEventManager.RemoveEventListener(XEventId.EVENT_CLICKDRAFT_GRID, self.OnDraftGridClick, self) + XEventManager.RemoveEventListener(XEventId.EVENT_DORM_BAG_REFRESH, self.UpdateDynamicTable, self) +end + +function XUiDormBag:InitRecyclePreview() + self.RecyclePreview = XUiRecyclePreview.New(self.PanelRecyclePreview, self) + self.RecyclePreview:Hide() +end + +function XUiDormBag:InitPrivateVariable(pageRecord, furnitureState, selectCb, filter) + self.SelectCb = selectCb + + if pageRecord then + self.PageRecord = pageRecord + else + self.PageRecord = XDormConfig.DORM_BAG_PANEL_INDEX.FURNITURE + end + + self.CharPageRecord = XDormConfig.DORM_CHAR_INDEX.CHARACTER + + if furnitureState then + self.FurnitureState = furnitureState + else + self.FurnitureState = XFurnitureConfigs.FURNITURE_STATE.DETAILS + end + + -- 过滤家具或者图纸 + self.Filter = filter +end + +function XUiDormBag:InitTabGroup(furnitureTypeId) + self.BtnList = {} + table.insert(self.BtnList, self.BtnTogFurniture) + table.insert(self.BtnList, self.BtnTogCharacter) + table.insert(self.BtnList, self.BtnTogDraft) + + self.PanelTogs:Init(self.BtnList, function(index) + self:RefreshSelectedPanel(index, true) + end) + + -- 处理构造体/感染体 + self.BtnCharList = {} + table.insert(self.BtnCharList, self.BtnTogChar) + table.insert(self.BtnCharList, self.BtnTogEmney) + -- table.insert(self.BtnCharList, self.BtnTogHuman) + table.insert(self.BtnCharList, self.BtnTogInfestor) + table.insert(self.BtnCharList, self.BtnTogNier) + self.PanelCharacterBtn:Init(self.BtnCharList, function(index) + self:RefreshSelectedCharPanel(index) + end) + + -- 选择家具状态处理 + if self.FurnitureState == XFurnitureConfigs.FURNITURE_STATE.SELECT or + self.FurnitureState == XFurnitureConfigs.FURNITURE_STATE.SELECTSINGLE then + + self.FurnitureSelectList = {} + if self.PageRecord == XDormConfig.DORM_BAG_PANEL_INDEX.FURNITURE then + self.BtnTogFurniture.gameObject:SetActiveEx(true) + self.BtnTogCharacter.gameObject:SetActiveEx(false) + self.BtnTogDraft.gameObject:SetActiveEx(false) + self.TxtSelectTip.gameObject:SetActiveEx(true) + elseif self.PageRecord == XDormConfig.DORM_BAG_PANEL_INDEX.DRAFT then + self.BtnTogFurniture.gameObject:SetActiveEx(false) + self.BtnTogCharacter.gameObject:SetActiveEx(false) + self.BtnTogDraft.gameObject:SetActiveEx(true) + self.TxtSelectTip.gameObject:SetActiveEx(false) + end + self:InitDrdSort(furnitureTypeId) + + self.PanelSelect.gameObject:SetActiveEx(true) + self.BtnRecycle.gameObject:SetActiveEx(false) + self.PanelNormlBt.gameObject:SetActiveEx(false) + self.BtnBuild.gameObject:SetActiveEx(false) + self.PanelTogs.gameObject:SetActiveEx(false) + self.BtnShop.gameObject:SetActiveEx(false) + self.TxtPartDesc.gameObject:SetActiveEx(false) + self.TxtSelectCount.gameObject:SetActiveEx(false) + self.DrdSort.gameObject:SetActiveEx(false) + self.PanelDordPart.gameObject:SetActiveEx(true) + self.BtnOrder.gameObject:SetActiveEx(false) + self.BtnPart.gameObject:SetActiveEx(false) + + self.PanelDynamicTableRct.offsetMin = SELECT_OFFSET_MIN + self.PanelDynamicTableRct.offsetMax = SELECT_OFFSET_MAX + + self.AscendSort = true + else + self.PanelSelect.gameObject:SetActiveEx(false) + self.BtnRecycle.gameObject:SetActiveEx(true) + self.PanelNormlBt.gameObject:SetActiveEx(true) + self.BtnBuild.gameObject:SetActiveEx(true) + self.PanelTogs.gameObject:SetActiveEx(true) + self.BtnShop.gameObject:SetActiveEx(true) + self.TxtPartDesc.gameObject:SetActiveEx(true) + self.TxtSelectCount.gameObject:SetActiveEx(false) + self.DrdSort.gameObject:SetActiveEx(true) + self.BtnOrder.gameObject:SetActiveEx(true) + self.PanelDordPart.gameObject:SetActiveEx(false) + self.BtnPart.gameObject:SetActiveEx(true) + + self.AscendSort = false + end + + -- 设置默认开启 + self.PanelTogs:SelectIndex(self.PageRecord) + + -- 设置默认开启 + self.PanelCharacterBtn:SelectIndex(self.CharPageRecord) +end + +function XUiDormBag:InitDynamicTable() + self.PanelDormBagItem.gameObject:SetActiveEx(false) + self.DynamicTable = XDynamicTableNormal.New(self.PanelDynamicTable) + self.DynamicTable:SetProxy(DormBagItem) + self.DynamicTable:SetDelegate(self) +end + +function XUiDormBag:InitFurniturePart() + local typeList = XFurnitureConfigs.GetFurnitureTemplateTypeList() + for _, furnitureType in ipairs(typeList) do + table.insert(self.SelectIds, furnitureType.Id) + end + + local typeSuitList = XFurnitureConfigs.GetFurnitureSuitTemplates() + for _, suit in ipairs(typeSuitList) do + if suit.Id ~= XFurnitureConfigs.FURNITURE_SUIT_CATEGORY_ALL_ID then + table.insert(self.SelectSuitIds, suit.Id) + end + end +end + +function XUiDormBag:SetAscendBtn() + self.ImgAscend.gameObject:SetActiveEx(self.AscendSort) + self.ImgDescend.gameObject:SetActiveEx(not self.AscendSort) +end + +--动态列表事件 +function XUiDormBag:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.PageDatas[index] + if self.PageRecord == XDormConfig.DORM_BAG_PANEL_INDEX.FURNITURE then + local isSelect = self.FurnitureState == XFurnitureConfigs.FURNITURE_STATE.SELECT + grid:SetupFurniture(data, isSelect) + elseif self.PageRecord == XDormConfig.DORM_BAG_PANEL_INDEX.CHARACTER then + grid:SetupCharacter(data) + elseif self.PageRecord == XDormConfig.DORM_BAG_PANEL_INDEX.DRAFT then + grid:SetupDraft(data, self.NeedDraftCount) + end + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_RELOAD_COMPLETED then + if self.DOAnchor_PosY then + self.Content:DOAnchorPosY(self.DOAnchor_PosY, 0.1) + self.DOAnchor_PosY = nil + end + end +end + +function XUiDormBag:AddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:RegisterClickEvent(self.BtnBuild, self.OnBtnBuildClick) + self:RegisterClickEvent(self.BtnRecycle, self.OnBtnRecycleClick) + self:RegisterClickEvent(self.BtnRecycle_Draft, self.OnBtnRecycleClick) + self:RegisterClickEvent(self.BtnPart, self.OnBtnPartClick) + self:RegisterClickEvent(self.BtnShop, self.OnBtnShopClick) + self:RegisterClickEvent(self.BtnSelect, self.OnBtnSelectClick) + self:RegisterClickEvent(self.BtnOrder, self.OnBtnOrderClick) + self.DrdSort.onValueChanged:AddListener(function() + self.PriorSortType = self.DrdSort.value + self:RefreshSelectedPanel(self.PageRecord, true) + end) + + self.DrodPart.onValueChanged:AddListener(function() + self:OnDrodPartValueChanged() + end) +end + +function XUiDormBag:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiDormBag:OnBtnBackClick() + if self.RecyclePreview:IsShow() then + self:PlayAnimation("RecyclePreviewDisable", function() + self:OnRecycleCancel() + self.RecyclePreview:Hide() + end) + return + end + + self:Close() +end + +function XUiDormBag:OnBtnBuildClick() + XLuaUiManager.Open("UiFurnitureBuild") +end + +-- 点击筛选 +function XUiDormBag:OnBtnPartClick() + XLuaUiManager.Open("UiFurnitureTypeSelect", self.SelectIds, self.SelectSuitIds, false, function(selectIds, selectSuitIds) + if #selectIds <= 0 or #selectSuitIds <= 0 then + return + end + + -- 如果再单选情况下 重新选择家具 + if self.FurnitureState == XFurnitureConfigs.FURNITURE_STATE.SELECTSINGLE then + if self.FurnitureSelectGrid then + self.FurnitureSelectGrid:SetSelected(false) + self.FurnitureSelectGrid = nil + end + self.FurnitureSelectId = nil + end + + self.SelectIds = selectIds + self.SelectSuitIds = selectSuitIds + self:RefreshSelectedPanel(self.PageRecord, true) + end) +end + +function XUiDormBag:SetPartCount(count) + local allTypeId = XFurnitureConfigs.FURNITURE_CATEGORY_ALL_ID + local allSuitTypeId = XFurnitureConfigs.FURNITURE_SUIT_CATEGORY_ALL_ID + + if #self.SelectIds == 1 and self.SelectIds[1] == allTypeId and + self.PriorSortType == XFurnitureConfigs.PriorSortType.All and + #self.SelectSuitIds == 1 and self.SelectSuitIds[1] == allSuitTypeId then + self.TxtPartDesc.text = CS.XTextManager.GetText("DormSelectAllCount", count) + else + self.TxtPartDesc.text = CS.XTextManager.GetText("DormSelectCount", count) + end +end + +function XUiDormBag:OnBtnShopClick() + XLuaUiManager.Open("UiShop", XShopManager.ShopType.Dorm) +end + +-- 排序按钮 +function XUiDormBag:OnBtnOrderClick() + self.AscendSort = not self.AscendSort + self:SetAscendBtn() + self:RefreshSelectedPanel(self.PageRecord, true) +end + +--家具、图纸回收 +function XUiDormBag:OnBtnRecycleClick() + self.AscendSort = true + self:SetAscendBtn() + self.DrdSort.gameObject:SetActiveEx(false) + + self.PanelFurnitureBtn.gameObject:SetActiveEx(false) + self.RecyclePreview:Show(self.PageRecord) + self:PlayAnimation("RecyclePreviewEnable") + self.FurnitureSelectList = {} + self.FurnitureState = XFurnitureConfigs.FURNITURE_STATE.RECYCLE + self:RefreshSelectedPanel(self.PageRecord, true) +end + +--@region 确认回收 +function XUiDormBag:OnRecycleConfirm(count) + if self.PageRecord == XDormConfig.DORM_BAG_PANEL_INDEX.DRAFT then + self:DecomposeDraft(count) + elseif self.PageRecord == XDormConfig.DORM_BAG_PANEL_INDEX.FURNITURE then + self:DecomposeFurniture() + end +end + +--图纸回收 +function XUiDormBag:DecomposeDraft(count) + local tm = {} + for i,v in ipairs(self.FurnitureSelectList) do + tm[v] = count + end + XDataCenter.ItemManager.Sell(tm, function(rewardGoodDic) + local rewards = {} + for key, value in pairs(rewardGoodDic) do + table.insert(rewards, { TemplateId = key, Count = value }) + end + XUiManager.OpenUiObtain(rewards) + + -- 清理数据后重新进入 + self:OnRecycleCancel() + self:OnBtnRecycleClick() + end) +end + +--家具回收 +function XUiDormBag:DecomposeFurniture() + XDataCenter.FurnitureManager.DecomposeFurniture(self.FurnitureSelectList, function(rewardItems, successIds) + -- 先打开回收界面 + XLuaUiManager.Open("UiDormBagRecycle", self.FurnitureSelectList, rewardItems) + + -- 将分解成功的家具从缓存中移除 + for _, id in ipairs(successIds) do + XDataCenter.FurnitureManager.RemoveFurniture(id) + end + + -- 删除红点 + XDataCenter.FurnitureManager.DeleteNewHint(successIds) + + -- 清理数据 + self:OnRecycleCancel() + end) +end +--@endregion + +-- 取消回收 +function XUiDormBag:OnRecycleCancel() + -- 设置排序 + self.AscendSort = false + self:SetAscendBtn() + self.DrdSort.gameObject:SetActiveEx(true) + + self.FurnitureSelectList = {} + self.FurnitureSelectId = nil + self.FurnitureSelectGrid = nil + self.FurnitureState = XFurnitureConfigs.FURNITURE_STATE.DETAILS + self:RefreshSelectedPanel(self.PageRecord, true) + if self.PageRecord ~= XDormConfig.DORM_BAG_PANEL_INDEX.DRAFT then + self.PanelFurnitureBtn.gameObject:SetActiveEx(true) + end +end + +-- 确认选择 +function XUiDormBag:OnBtnSelectClick() + if self.FurnitureState == XFurnitureConfigs.FURNITURE_STATE.SELECT then + if not self.FurnitureSelectList or #self.FurnitureSelectList <= 0 then + XUiManager.TipMsg(CS.XTextManager.GetText("DormFurnitureSelectNull"), XUiManager.UiTipType.Tip) + return + end + + if self.SelectCb then + self.SelectCb(self.FurnitureSelectList) + end + + elseif self.FurnitureState == XFurnitureConfigs.FURNITURE_STATE.SELECTSINGLE then + if not self.FurnitureSelectId or self.FurnitureSelectId == nil then + XUiManager.TipMsg(CS.XTextManager.GetText("DormFurnitureSelectNull"), XUiManager.UiTipType.Tip) + return + end + + if self.SelectCb then + self.SelectCb(self.FurnitureSelectId) + end + end + + self:Close() +end + +function XUiDormBag:RefreshSelectedPanel(index, startIndex) + self.PageRecord = index + self:UpdateDynamicTable(startIndex) +end + +function XUiDormBag:RefreshSelectedCharPanel(index) + self.CharPageRecord = index + self:UpdateDynamicTable(true) +end + +--@region 点击grid的响应事件 +function XUiDormBag:OnFurnitureGridClick(furnitureId, furnitureConfigId, grid) + if self.FurnitureState == XFurnitureConfigs.FURNITURE_STATE.DETAILS then + grid:SetNewActive() + XLuaUiManager.Open("UiFurnitureDetail", furnitureId, furnitureConfigId, nil, function() + self:RefreshSelectedPanel(self.PageRecord, true) + end) + elseif self.FurnitureState == XFurnitureConfigs.FURNITURE_STATE.RECYCLE + or self.FurnitureState == XFurnitureConfigs.FURNITURE_STATE.SELECT then + self:RecycleFurniture(furnitureId, furnitureConfigId, grid) + elseif self.FurnitureState == XFurnitureConfigs.FURNITURE_STATE.SELECTSINGLE then + self:SetSelectSingleFurnitureSelectGrid(furnitureConfigId, grid) + end +end + +function XUiDormBag:OnDraftGridClick(templateId, count, grid) + if self.FurnitureState == XFurnitureConfigs.FURNITURE_STATE.DETAILS then + XLuaUiManager.Open("UiTip", { TemplateId = templateId, Count = count }) + elseif self.FurnitureState == XFurnitureConfigs.FURNITURE_STATE.RECYCLE then + self:RecycleDraft(templateId, grid) + elseif self.FurnitureState == XFurnitureConfigs.FURNITURE_STATE.SELECTSINGLE then + self:SelectSingleFurnitureSelectGrid(templateId, grid) + end +end + +function XUiDormBag:RecycleFurniture(furnitureId, furnitureConfigId, grid) + grid:SetSelected(not grid:IsSelected()) + for i = 1, #self.FurnitureSelectList do + if self.FurnitureSelectList[i] == furnitureId then + table.remove(self.FurnitureSelectList, i) + self.RecyclePreview:Refresh(self.FurnitureSelectList) + return + end + end + + table.insert(self.FurnitureSelectList, furnitureId) + self.RecyclePreview:Refresh(self.FurnitureSelectList) + self:IsSelectAllToRefreshSelectedPanel(furnitureConfigId) +end + +--图纸出售只能单选 +function XUiDormBag:RecycleDraft(templateId, grid) + if templateId == self.FurnitureSelectId then + self.FurnitureSelectList = {} + else + self.FurnitureSelectList = {templateId} + end + + self:SelectSingleFurnitureSelectGrid(templateId, grid) + + self.RecyclePreview:Refresh(self.FurnitureSelectList) +end + +--单选 +function XUiDormBag:SelectSingleFurnitureSelectGrid(selectId, grid) + grid:SetSelected(not grid:IsSelected()) + if selectId == self.FurnitureSelectId then + self.FurnitureSelectId = nil + self.FurnitureSelectGrid = nil + else + self.FurnitureSelectId = selectId + + if self.FurnitureSelectGrid then + self.FurnitureSelectGrid:SetSelected(false) + end + + --记录选择得Grid + self.FurnitureSelectGrid = grid + end +end +--@endregion + +function XUiDormBag:GetGridSelected(id) + -- 选择家具状态下 + if self.FurnitureState == XFurnitureConfigs.FURNITURE_STATE.SELECTSINGLE then + if not self.FurnitureSelectId then + return false + end + + return id == self.FurnitureSelectId + + -- 多选状态下 + elseif self.FurnitureState == XFurnitureConfigs.FURNITURE_STATE.RECYCLE or + self.FurnitureState == XFurnitureConfigs.FURNITURE_STATE.SELECT then + if not self.FurnitureSelectList then + return false + end + + for i = 1, #self.FurnitureSelectList do + if self.FurnitureSelectList[i] == id then + return true + end + end + + return false + end + + return false +end + +function XUiDormBag:UpdateDynamicTable(startIndex) + self.PageDatas = self:GetDataByPage() + + self.DynamicTable:SetDataSource(self.PageDatas) + self.DynamicTable:ReloadDataASync(startIndex and 1 or -1) + + -- 判断是否为空 + local isEmpty = #self.PageDatas <= 0 + self.PanelEmpty.gameObject:SetActiveEx(isEmpty) + + -- 刷新Btn的显示 + if self.PageRecord == XDormConfig.DORM_BAG_PANEL_INDEX.FURNITURE then + self.PanelFurnitureBtn.gameObject:SetActiveEx(true) + self.PanelDraftBtn.gameObject:SetActiveEx(false) + self.PanelCharacterBtn.gameObject:SetActiveEx(false) + if isEmpty then + self.TxtNull.text = CS.XTextManager.GetText("DormNullFurniture") + end + elseif self.PageRecord == XDormConfig.DORM_BAG_PANEL_INDEX.CHARACTER then + self.PanelFurnitureBtn.gameObject:SetActiveEx(false) + self.PanelDraftBtn.gameObject:SetActiveEx(false) + self.PanelCharacterBtn.gameObject:SetActiveEx(true) + if isEmpty then + if self.CharPageRecord == XDormConfig.DORM_CHAR_INDEX.CHARACTER then + self.TxtNull.text = CS.XTextManager.GetText("DormNullCharacter") + -- elseif self.CharPageRecord == XDormConfig.DORM_CHAR_INDEX.HUMAN then + -- self.TxtNull.text = CS.XTextManager.GetText("DormNullHumman") + elseif self.CharPageRecord == XDormConfig.DORM_CHAR_INDEX.INFESTOR then + self.TxtNull.text = CS.XTextManager.GetText("DormNullInfestor") + elseif self.CharPageRecord == XDormConfig.DORM_CHAR_INDEX.NIER then + self.TxtNull.text = CS.XTextManager.GetText("DormNullNiEr") + else + self.TxtNull.text = CS.XTextManager.GetText("DormNullEnmey") + end + end + elseif self.PageRecord == XDormConfig.DORM_BAG_PANEL_INDEX.DRAFT then + self.PanelFurnitureBtn.gameObject:SetActiveEx(false) + self.PanelDraftBtn.gameObject:SetActiveEx(true) + self.PanelCharacterBtn.gameObject:SetActiveEx(false) + if isEmpty then + self.TxtNull.text = CS.XTextManager.GetText("DormNullDraft") + end + end +end + +--获取数据 +function XUiDormBag:GetDataByPage() + -- 家具 + if self.PageRecord == XDormConfig.DORM_BAG_PANEL_INDEX.FURNITURE then + -- 是否过滤已经使用的家具 + local isRemoveUsed = self.FurnitureState == XFurnitureConfigs.FURNITURE_STATE.SELECT + or self.FurnitureState == XFurnitureConfigs.FURNITURE_STATE.RECYCLE + or self.PriorSortType == XFurnitureConfigs.PriorSortType.Unuse + or self.FurnitureState == XFurnitureConfigs.FURNITURE_STATE.SELECTSINGLE + + -- 是否过滤还未使用的家具 + local isRemoveUnuse = self.PriorSortType == XFurnitureConfigs.PriorSortType.Use and self.FurnitureState ~= XFurnitureConfigs.FURNITURE_STATE.RECYCLE + local isRemoveLock = self.FurnitureState == XFurnitureConfigs.FURNITURE_STATE.RECYCLE + local furnitureIds = XDataCenter.FurnitureManager.GetFurnitureCategoryIds(self.SelectIds, self.SelectSuitIds, isRemoveUsed, self.AscendSort, isRemoveUnuse, isRemoveLock) + local filterIds = {} + local filter = false + if self.Filter then + filter = true + for _, furnitureId in pairs(furnitureIds) do + if self.Filter(furnitureId) then + table.insert(filterIds, furnitureId) + end + end + end + local allCount = XDataCenter.FurnitureManager.GetAllFurnitureCount() + self.TxtCount.text = CS.XTextManager.GetText("DormBagFurnitureCount", allCount) + self.TxtSelectCount.text = CS.XTextManager.GetText("DormBagFurnitureCount", allCount) + self:SetPartCount(filter and #filterIds or #furnitureIds) + + return filter and filterIds or furnitureIds + end + + -- 构造体/感染体/人类 + if self.PageRecord == XDormConfig.DORM_BAG_PANEL_INDEX.CHARACTER then + local characterIds = XDataCenter.DormManager.GetDormCharacterIds(XDormConfig.GetDormCharacterType(self.CharPageRecord)) + local allCount = XDormConfig.GetDormCharacterTemplatesCountByType(XDormConfig.GetDormCharacterType(self.CharPageRecord)) + + if self.CharPageRecord == XDormConfig.DORM_CHAR_INDEX.CHARACTER then + self.TxtCount.text = CS.XTextManager.GetText("DormBagCharacterCount", #characterIds, allCount) + self.TxtSelectCount.text = CS.XTextManager.GetText("DormBagCharacterCount", #characterIds, allCount) + elseif self.CharPageRecord == XDormConfig.DORM_CHAR_INDEX.EMNEY then + self.TxtCount.text = CS.XTextManager.GetText("DormBagEmneyCount", #characterIds, allCount) + self.TxtSelectCount.text = CS.XTextManager.GetText("DormBagEmneyCount", #characterIds, allCount) + elseif self.CharPageRecord == XDormConfig.DORM_CHAR_INDEX.INFESTOR then + self.TxtCount.text = CS.XTextManager.GetText("DormBagInfestorCount", #characterIds, allCount) + self.TxtSelectCount.text = CS.XTextManager.GetText("DormBagInfestorCount", #characterIds, allCount) + elseif self.CharPageRecord == XDormConfig.DORM_CHAR_INDEX.NIER then + self.TxtCount.text = CS.XTextManager.GetText("DormBagNiErCount", #characterIds, allCount) + self.TxtSelectCount.text = CS.XTextManager.GetText("DormBagNiErCount", #characterIds, allCount) + -- else + -- self.TxtCount.text = CS.XTextManager.GetText("DormBagHumanrCount", #characterIds, allCount) + -- self.TxtSelectCount.text = CS.XTextManager.GetText("DormBagHumanrCount", #characterIds, allCount) + end + + return characterIds + end + + -- 图纸 + if self.PageRecord == XDormConfig.DORM_BAG_PANEL_INDEX.DRAFT then + local suitId = (self.SelectSuitIds and #self.SelectSuitIds == 1) and self.SelectSuitIds[1] or 0 + local itemDatas = XDataCenter.ItemManager.GetItemsByTypeAndSuitId(XItemConfigs.ItemType.FurnitureItem, suitId) + + -- 需要过滤 + local isSelectMode = self.FurnitureState == XFurnitureConfigs.FURNITURE_STATE.SELECTSINGLE + if isSelectMode and self.Filter then + local filterDatas = {} + for _, v in pairs(itemDatas) do + if self.Filter(v.Id) then + table.insert(filterDatas, v) + end + end + + local count = self:GetDraftItemsCount(filterDatas) + self.TxtCount.text = CS.XTextManager.GetText("DormBagDraftCount", count) + self.TxtSelectCount.text = CS.XTextManager.GetText("DormBagDraftCount", count) + return filterDatas + end + + local count = self:GetDraftItemsCount(itemDatas) + self.TxtCount.text = CS.XTextManager.GetText("DormBagDraftCount", count) + self.TxtSelectCount.text = CS.XTextManager.GetText("DormBagDraftCount", count) + return itemDatas + end +end + +function XUiDormBag:GuideGetDynamicTableIndex(id) + for i, v in ipairs(self.PageDatas) do + local furnitureConfig = XDataCenter.FurnitureManager.GetFurnitureConfigByUniqueId(v) + if not furnitureConfig then + return -1 + end + + if tostring(furnitureConfig.Id) == tostring(id) then + return i + end + end + + return -1 +end + +function XUiDormBag:GetDraftItemsCount(list) + local count = 0 + if not list or #list <= 0 then + return count + end + + for _, v in pairs(list) do + count = count + v.Count + end + + return count +end + +-- 处理进入选择家具和图纸 +function XUiDormBag:InitDrdSort(furnitureTypeId, notClearSelect) + self.DrodPart:ClearOptions() + + local drodIndex = self:SetDrdSortIndexToType(furnitureTypeId) + + self.DrodPart.captionText.text = self.DrdSortIndexToType[drodIndex].Name + + self:CreateDrodPart() + + self.notClearSelect = notClearSelect + local oldValue = self.DrodPart.value + local newValue = drodIndex - 1 + self.DrodPart.value = newValue + --强制触发OnDrodPartValueChanged + if newValue == oldValue then + self:OnDrodPartValueChanged() + end +end + +function XUiDormBag:SetDrdSortIndexToType(furnitureTypeId) + self.DrdSortIndexToType = {} + local drodIndex = 1 + + if self.PageRecord == XDormConfig.DORM_BAG_PANEL_INDEX.FURNITURE then + local typeList = XFurnitureConfigs.GetFurnitureTemplateTypeList() + for i, config in ipairs(typeList) do + if furnitureTypeId and furnitureTypeId == config.Id then + drodIndex = i + end + + local data = { + TypeId = config.Id, + Name = config.CategoryName, + } + table.insert(self.DrdSortIndexToType, data) + end + + --增加一个全选的选项 + if self.FurnitureState == XFurnitureConfigs.FURNITURE_STATE.SELECT then + table.insert(self.DrdSortIndexToType, { + TypeId = SELECT_TYPE_ALL, + Name = CS.XTextManager.GetText("ScreenAll"), + }) + end + elseif self.PageRecord == XDormConfig.DORM_BAG_PANEL_INDEX.DRAFT then + local typeList = XFurnitureConfigs.GetFurnitureSuitTemplatesList() + for i, config in ipairs(typeList) do + local data = { + TypeId = config.Id, + Name = config.SuitName, + } + table.insert(self.DrdSortIndexToType, data) + end + end + + return drodIndex +end + +function XUiDormBag:CreateDrodPart() + local CsDropdown = CS.UnityEngine.UI.Dropdown + for _, partType in ipairs(self.DrdSortIndexToType) do + local op = CsDropdown.OptionData() + op.text = partType.Name + self.DrodPart.options:Add(op) + end +end + +function XUiDormBag:OnDrodPartValueChanged() + local typeData = self.DrdSortIndexToType[self.DrodPart.value + 1] + if self.PageRecord == XDormConfig.DORM_BAG_PANEL_INDEX.FURNITURE then + if not self.notClearSelect then + self.FurnitureSelectList = {} + end + self.notClearSelect = false + self.SelectIds = self:GetSelectIdsByTypeId(typeData.TypeId) + elseif self.PageRecord == XDormConfig.DORM_BAG_PANEL_INDEX.DRAFT then + self.FurnitureSelectId = nil + self.FurnitureSelectGrid = nil + self.SelectSuitIds = { typeData.TypeId } + end + + self:RefreshSelectedPanel(self.PageRecord, true) +end + +-- 如果在全选状态,页签自动筛选为对应类型 +function XUiDormBag:IsSelectAllToRefreshSelectedPanel(furnitureConfigId) + if self.FurnitureState == XFurnitureConfigs.FURNITURE_STATE.SELECT then + local typeData = self.DrdSortIndexToType[self.DrodPart.value + 1] + if typeData.TypeId == SELECT_TYPE_ALL then + local furnitureConfig = XFurnitureConfigs.GetFurnitureTemplateById(furnitureConfigId) + self:InitDrdSort(furnitureConfig.TypeId, true) + self:DOAnchorPosY() + end + end +end + +function XUiDormBag:GetSelectIdsByTypeId(typeId) + local selectIds = {} + if self.PageRecord == XDormConfig.DORM_BAG_PANEL_INDEX.FURNITURE then + if typeId == SELECT_TYPE_ALL then + for i,v in ipairs(self.DrdSortIndexToType) do + if v.TypeId ~= SELECT_TYPE_ALL then + table.insert(selectIds, v.TypeId) + end + end + else + selectIds = { typeId } + end + end + + return selectIds +end + +function XUiDormBag:DOAnchorPosY() + self.DOAnchor_PosY = nil + --默认只取第一个 + local furnitureId = self.FurnitureSelectList[1] + if furnitureId then + local minRow = 3 + local dynamicTableNormal = self.PanelDynamicTable.gameObject:GetComponent(typeof(CS.XDynamicTableNormal)) + local index = 0 + for i,id in ipairs(self.PageDatas) do + if furnitureId == id then + index = i + break + end + end + + local row = math.floor(index / dynamicTableNormal.ConstraintCount) - 1 + if minRow <= row then + local posY = (dynamicTableNormal.GridSize.y + dynamicTableNormal.Spacing.y) * row + self.DOAnchor_PosY = posY + end + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormBag/XUiGridDormCharacter.lua b/Resources/Scripts/XUi/XUiDormBag/XUiGridDormCharacter.lua new file mode 100644 index 00000000..7b40e96b --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormBag/XUiGridDormCharacter.lua @@ -0,0 +1,71 @@ +local XUiGridDormCharacter = XClass(nil, "XUiGridDormCharacter") + +function XUiGridDormCharacter:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + self:AutoAddListener() +end + +function XUiGridDormCharacter:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiGridDormCharacter:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiGridDormCharacter:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiGridDormCharacter:AutoAddListener() + self:RegisterClickEvent(self.BtnClick, self.OnBtnClickClick) +end + +function XUiGridDormCharacter:OnBtnClickClick() + self.ImgNew.gameObject:SetActiveEx(false) + XLuaUiManager.Open("UiDormCharacterDetail", self.CharacterId) +end + +function XUiGridDormCharacter:Refresh(characterId) + self.CharacterId = characterId + + local charStyleConfig = XDormConfig.GetCharacterStyleConfigById(characterId) + if not charStyleConfig then + return + end + + self.RImgIcon:SetRawImage(charStyleConfig.HeadIcon, nil, true) + self.TxtCharacterName.text = charStyleConfig.Name + local loveTypeConfig = XFurnitureConfigs.GetDormFurnitureType(charStyleConfig.LoveType) + local likeTypeConfig = XFurnitureConfigs.GetDormFurnitureType(charStyleConfig.LikeType) + + self.RootUi:SetUiSprite(self.ImgLove, loveTypeConfig.TypeIcon) + self.RootUi:SetUiSprite(self.ImgLike, likeTypeConfig.TypeIcon) + + local showNew = XDataCenter.FurnitureManager.CheckNewHint(characterId) + self.ImgNew.gameObject:SetActiveEx(showNew) + if showNew then + local ids = {} + table.insert(ids, characterId) + XDataCenter.FurnitureManager.AddNewHint(ids) + end + + self.TxtLove.text = CS.XTextManager.GetText("DormHightDescription") + self.TxtLike.text = CS.XTextManager.GetText("DormMiddleDescription") + + local inRoomNumber = XDataCenter.DormManager.GetCharacterRoomNumber(characterId) + self.PanelInRoom.gameObject:SetActiveEx(inRoomNumber > 0) + if inRoomNumber > 0 then + self.TxtRoomNum.text = XDataCenter.DormManager.GetDormName(inRoomNumber) + end +end + +return XUiGridDormCharacter \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormBag/XUiGridDraft.lua b/Resources/Scripts/XUi/XUiDormBag/XUiGridDraft.lua new file mode 100644 index 00000000..9a4449ae --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormBag/XUiGridDraft.lua @@ -0,0 +1,66 @@ +local XUiGridDraft = XClass(nil, "XUiGridDraft") + +function XUiGridDraft:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + + XTool.InitUiObject(self) + self:AutoAddListener() + self:SetSelected(false) +end + +function XUiGridDraft:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiGridDraft:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiGridDraft:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiGridDraft:AutoAddListener() + self:RegisterClickEvent(self.BtnClick, self.OnBtnClickClick) +end + +function XUiGridDraft:OnBtnClickClick() + XEventManager.DispatchEvent(XEventId.EVENT_CLICKDRAFT_GRID, self.Data.Id, self.Data.Count, self) +end + +function XUiGridDraft:SetSelected(status) + if self.ImgSelect then + self.ImgSelect.gameObject:SetActive(status) + end +end + +function XUiGridDraft:IsSelected() + return self.ImgSelect and self.ImgSelect.gameObject.activeSelf +end + +function XUiGridDraft:Refresh(data, count) + self.Data = data + + self:SetSelected(self.RootUi:GetGridSelected(data.Id)) + + self.RImgIcon:SetRawImage(XDataCenter.ItemManager.GetItemIcon(data.Id), nil, true) + local quality = XDataCenter.ItemManager.GetItemQuality(data.Id) + self.RootUi:SetUiSprite(self.ImgQuality, XArrangeConfigs.GeQualityBgPath(quality)) + + self.TxtDraftName.text = XDataCenter.ItemManager.GetItemName(data.Id) + + if data.Count >= count then + self.TxtDraftCount.text = CS.XTextManager.GetText("DormBuildEnoughCount", data.Count) + else + self.TxtDraftCount.text = CS.XTextManager.GetText("DormBuildNoEnoughCount", data.Count) + end +end + +return XUiGridDraft \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormBag/XUiGridFurniture.lua b/Resources/Scripts/XUi/XUiDormBag/XUiGridFurniture.lua new file mode 100644 index 00000000..91a7aa59 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormBag/XUiGridFurniture.lua @@ -0,0 +1,143 @@ +local XUiGridFurniture = XClass(nil, "XUiGridFurniture") +local attrRed = XFurnitureConfigs.AttrType.AttrA +local attrYellow = XFurnitureConfigs.AttrType.AttrB +local attrBule = XFurnitureConfigs.AttrType.AttrC + +function XUiGridFurniture:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + self:AutoAddListener() + self:SetSelected(false) +end + +function XUiGridFurniture:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiGridFurniture:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiGridFurniture:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiGridFurniture:AutoAddListener() + if self.BtnClick then + self:RegisterClickEvent(self.BtnClick, self.OnBtnClickClick) + end +end + +function XUiGridFurniture:OnBtnClickClick() + local furnitureConfigId = XDataCenter.FurnitureManager.GetFurnitureConfigId(self.FurnitureId) + XEventManager.DispatchEvent(XEventId.EVENT_CLICKFURNITURE_GRID, self.FurnitureId, furnitureConfigId, self) +end + +function XUiGridFurniture:SetSelected(status) + if self.ImgSelect then + self.ImgSelect.gameObject:SetActiveEx(status) + end +end + +function XUiGridFurniture:IsSelected() + return self.ImgSelect and self.ImgSelect.gameObject.activeSelf +end + +function XUiGridFurniture:SetNewActive() + self.ImgNew.gameObject:SetActiveEx(false) +end + +-- 传入家具的唯一Id +function XUiGridFurniture:Refresh(furnitureId) + self.FurnitureId = furnitureId + + local furnitureConfig = XDataCenter.FurnitureManager.GetFurnitureConfigByUniqueId(furnitureId) + if not furnitureConfig then + return + end + + local quality = XDataCenter.FurnitureManager.GetLevelRewardQuality(furnitureId) + + if self.ImgSelect then + self:SetSelected(self.RootUi:GetGridSelected(furnitureId)) + end + + if self.RImgIcon then + local icon = XDataCenter.FurnitureManager.GetFurnitureIconById(furnitureId, XDormConfig.DormDataType.Self) + self.RImgIcon:SetRawImage(icon, nil, true) + end + + if self.ImgQuality then + self.RootUi:SetUiSprite(self.ImgQuality, XArrangeConfigs.GeQualityBgPath(quality)) + end + + if self.ImgIconQuality then + XUiHelper.SetQualityIcon(self.RootUi, self.ImgIconQuality, quality) + end + + if self.TxtFurnitureName then + self.TxtFurnitureName.text = furnitureConfig.Name + end + + local furnitureType = XDataCenter.FurnitureManager.GetFurnitureConfigByUniqueId(furnitureId).TypeId + if self.TxtFurnitureScore then + local totalScore = XDataCenter.FurnitureManager.GetFurnitureScore(furnitureId) + self.TxtFurnitureScore.text = XFurnitureConfigs.GetFurnitureTotalAttrLevelDescription(furnitureType, totalScore) + end + + if self.TxtRedScore then + local redScore = XDataCenter.FurnitureManager.GetFurnitureRedScore(furnitureId) + self.TxtRedScore.text = XFurnitureConfigs.GetFurnitureAttrLevelDescription(furnitureType, attrRed, redScore) + end + + if self.TxtYellowScore then + local yellowScore = XDataCenter.FurnitureManager.GetFurnitureYellowScore(furnitureId) + self.TxtYellowScore.text = XFurnitureConfigs.GetFurnitureAttrLevelDescription(furnitureType, attrYellow, yellowScore) + end + + if self.TxtBlueScore then + local blueScore = XDataCenter.FurnitureManager.GetFurnitureBlueScore(furnitureId) + self.TxtBlueScore.text = XFurnitureConfigs.GetFurnitureAttrLevelDescription(furnitureType, attrBule, blueScore) + end + + if self.ImgLock then + self.ImgLock.gameObject:SetActiveEx(XDataCenter.FurnitureManager.GetFurnitureIsLocked(furnitureId)) + end + + if self.ImgNew then + local showNew = XDataCenter.FurnitureManager.CheckNewHint(furnitureId) + self.ImgNew.gameObject:SetActiveEx(showNew) + + -- 记入已经查看过 new 标签 + if showNew then + local ids = {} + table.insert(ids, self.FurnitureId) + XDataCenter.FurnitureManager.AddNewHint(ids) + end + end + + if self.TxtCount then + self.TxtCount.gameObject:SetActiveEx(false) + end + + self:UpdateUsing(furnitureId) +end + +function XUiGridFurniture:UpdateUsing(furnitureId) + if furnitureId ~= self.FurnitureId then + return + end + + if self.PanelUsing then + self.PanelUsing.gameObject:SetActiveEx(XDataCenter.FurnitureManager.CheckFurnitureUsing(self.FurnitureId)) + end +end + +return XUiGridFurniture \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormBag/XUiPanelDormBagItem.lua b/Resources/Scripts/XUi/XUiDormBag/XUiPanelDormBagItem.lua new file mode 100644 index 00000000..46e9104f --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormBag/XUiPanelDormBagItem.lua @@ -0,0 +1,50 @@ +local XUiGridDraft = require("XUi/XUiDormBag/XUiGridDraft") +local XUiGridFurniture = require("XUi/XUiDormBag/XUiGridFurniture") +local XUiGridDormCharacter = require("XUi/XUiDormBag/XUiGridDormCharacter") + +local XUiPanelDormBagItem = XClass(nil, "XUiPanelDormBagItem") + +function XUiPanelDormBagItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiPanelDormBagItem:Init(rootUi) + self.Parent = rootUi + self.DraftGrid = XUiGridDraft.New(self.GridDraft, rootUi) + self.FurnitureGrid = XUiGridFurniture.New(rootUi, self.GridFurniture) + self.FurnitureWorkGrid = XUiGridFurniture.New(rootUi, self.GridFurnitureWork) + self.CharacterGrid = XUiGridDormCharacter.New(self.GridCharacter, rootUi) +end + +function XUiPanelDormBagItem:SetupFurniture(furnitureId, isSelect) + if isSelect then + self.FurnitureWorkGrid:Refresh(furnitureId) + else + self.FurnitureGrid:Refresh(furnitureId) + end + + self.FurnitureGrid.GameObject:SetActiveEx(not isSelect) + self.CharacterGrid.GameObject:SetActiveEx(false) + self.DraftGrid.GameObject:SetActiveEx(false) + self.FurnitureWorkGrid.GameObject:SetActiveEx(isSelect) +end + +function XUiPanelDormBagItem:SetupCharacter(characterId) + self.CharacterGrid:Refresh(characterId) + self.FurnitureGrid.GameObject:SetActiveEx(false) + self.CharacterGrid.GameObject:SetActiveEx(true) + self.DraftGrid.GameObject:SetActiveEx(false) + self.FurnitureWorkGrid.GameObject:SetActiveEx(false) +end + +function XUiPanelDormBagItem:SetupDraft(data, count) + self.DraftGrid:Refresh(data, count) + self.FurnitureGrid.GameObject:SetActiveEx(false) + self.CharacterGrid.GameObject:SetActiveEx(false) + self.DraftGrid.GameObject:SetActiveEx(true) + self.FurnitureWorkGrid.GameObject:SetActiveEx(false) +end + +return XUiPanelDormBagItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormBag/XUiRecyclePreview.lua b/Resources/Scripts/XUi/XUiDormBag/XUiRecyclePreview.lua new file mode 100644 index 00000000..9062a409 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormBag/XUiRecyclePreview.lua @@ -0,0 +1,203 @@ +local XUiRecyclePreview = XClass(nil, "XUiRecyclePreview") + +function XUiRecyclePreview:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self.SelectFurnitureIds = {} + self.Rewards = {} + XTool.InitUiObject(self) + + self:AutoAddListener() + self:InitDynamicTable() + + self.GridCommonPopUp.gameObject:SetActive(false) +end + +function XUiRecyclePreview:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiRecyclePreview:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiRecyclePreview:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiRecyclePreview:AutoAddListener() + self:RegisterClickEvent(self.BtnRecycleConfirm, self.OnBtnRecycleConfirmClick) + self:RegisterClickEvent(self.BtnRecycleCancel, self.OnBtnRecycleCancelClick) + self:RegisterClickEvent(self.BtnSub, self.OnBtnSubClick) + self:RegisterClickEvent(self.BtnAdd, self.OnBtnAddClick) + self:RegisterClickEvent(self.BtnMax, self.OnBtnMaxClick) +end + +--@region 事件处理 + +-- 确认回收 +function XUiRecyclePreview:OnBtnRecycleConfirmClick() + if not self.SelectFurnitureIds or #self.SelectFurnitureIds <= 0 then + XUiManager.TipMsg(CS.XTextManager.GetText("DormFurnitureRecycelNull"), XUiManager.UiTipType.Tip) + return + end + + local hintText = self:GetHintText() + + XUiManager.DialogTip("", hintText, XUiManager.DialogType.Normal, nil, function() + self:Hide() + self.RootUi:OnRecycleConfirm(self.SelectCount) + end) +end + +function XUiRecyclePreview:GetHintText() + local hintText + if self.pageRecord == XDormConfig.DORM_BAG_PANEL_INDEX.DRAFT then + hintText = CS.XTextManager.GetText("DormDraftRecycelComfirm") + else + hintText = CS.XTextManager.GetText("DormFurnitureRecycelComfirm") + for i = 1, #self.SelectFurnitureIds do + local isUseing = XDataCenter.FurnitureManager.CheckFurnitureUsing(self.SelectFurnitureIds[i]) + if isUseing then + hintText = CS.XTextManager.GetText("DormFurnitureRecycelUsingComfirm") + break + end + end + end + + return hintText +end + +-- 取消回收 +function XUiRecyclePreview:OnBtnRecycleCancelClick() + self.RootUi:PlayAnimation("RecyclePreviewDisable",function () + self:Hide() + self.RootUi:OnRecycleCancel() + end) +end + +function XUiRecyclePreview:OnBtnSubClick() + if self.SelectFurnitureIds then + self:Refresh(self.SelectFurnitureIds, self.SelectCount - 1) + end +end + +function XUiRecyclePreview:OnBtnAddClick() + if self.SelectFurnitureIds then + self:Refresh(self.SelectFurnitureIds, self.SelectCount + 1) + end +end + +function XUiRecyclePreview:OnBtnMaxClick() + if self.SelectFurnitureIds then + self:Refresh(self.SelectFurnitureIds, self:GetMaxCount()) + end +end + +--@endregion + +function XUiRecyclePreview:Refresh(selectFurnitureIds, count) + self.SelectFurnitureIds = selectFurnitureIds + + self:RefreshTxtNum(count) + + self.Rewards = self:GetRewards() + + self:UpdateDynamicTable() +end + +function XUiRecyclePreview:RefreshTxtNum(count) + if count then + self.SelectCount = count + else + if self.SelectFurnitureIds and next(self.SelectFurnitureIds) then + self.SelectCount = 1 + else + self.SelectCount = 0 + end + end + self.TxtNum.text = self.SelectCount + + self.BtnSub.gameObject:SetActive(self.SelectCount > 0) + self.ImgCantSub.gameObject:SetActive(not (self.SelectCount > 0)) + + self.BtnAdd.gameObject:SetActive(self.SelectCount < self:GetMaxCount()) + self.ImgCantAdd.gameObject:SetActive(not (self.SelectCount < self:GetMaxCount())) +end + +function XUiRecyclePreview:GetMaxCount() + if self.SelectFurnitureIds and next(self.SelectFurnitureIds) then + if self.pageRecord == XDormConfig.DORM_BAG_PANEL_INDEX.DRAFT then + return XDataCenter.ItemManager.GetCount(self.SelectFurnitureIds[1]) + end + end + + return 0 +end + +function XUiRecyclePreview:GetRewards() + if self.pageRecord == XDormConfig.DORM_BAG_PANEL_INDEX.DRAFT then + local rewards = {} + if next(self.SelectFurnitureIds) then + rewards = { + XDataCenter.ItemManager.GetSellReward(self.SelectFurnitureIds[1], self.SelectCount) + } + end + return rewards + else + return XDataCenter.FurnitureManager.GetRecycleRewards(self.SelectFurnitureIds) + end +end + +function XUiRecyclePreview:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelDynamicTablePopUp) + self.DynamicTable:SetProxy(XUiGridCommon) + self.DynamicTable:SetDelegate(self) +end + +function XUiRecyclePreview:UpdateDynamicTable(bReload) + self.TxtSelectNum.text = #self.SelectFurnitureIds + + self.DynamicTable:SetDataSource(self.Rewards) + self.DynamicTable:ReloadDataASync(bReload and 1 or -1) +end + +function XUiRecyclePreview:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self.RootUi) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:Refresh(self.Rewards[index]) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + XLuaUiManager.Open("UiTip", self.Rewards[index]) + end +end + +function XUiRecyclePreview:Hide() + self.GameObject:SetActive(false) +end + +function XUiRecyclePreview:Show(pageRecord) + self.SelectFurnitureIds = {} + self.Rewards = {} + self.pageRecord = pageRecord + + self.PanelNumBtn.gameObject:SetActiveEx(self.pageRecord == XDormConfig.DORM_BAG_PANEL_INDEX.DRAFT) + self.PanelSelectNum.gameObject:SetActiveEx(self.pageRecord ~= XDormConfig.DORM_BAG_PANEL_INDEX.DRAFT) + + self:RefreshTxtNum(0) + self:UpdateDynamicTable() + + self.GameObject:SetActive(true) +end + +function XUiRecyclePreview:IsShow() + return self.GameObject.activeSelf +end + +return XUiRecyclePreview \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormBagRecycle/XUiDormBagRecycle.lua b/Resources/Scripts/XUi/XUiDormBagRecycle/XUiDormBagRecycle.lua new file mode 100644 index 00000000..b8ff2fb0 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormBagRecycle/XUiDormBagRecycle.lua @@ -0,0 +1,53 @@ +local XUiDormBagRecycle = XLuaUiManager.Register(XLuaUi, "UiDormBagRecycle") +local XUiGridFurniture = require("XUi/XUiDormBag/XUiGridFurniture") + + +function XUiDormBagRecycle:OnAwake() + self:AddListener() +end + +function XUiDormBagRecycle:OnStart(recycleFurnitures, rewardItems, openFinishCallBack, closeFinishCallBack) + self.RecycleItems = {} + self.RewardItems = {} + self.OpenFinishCallBack = openFinishCallBack + self.CloseFinishCallBack = closeFinishCallBack + self:Refresh(recycleFurnitures, rewardItems) +end + +function XUiDormBagRecycle:Refresh(recycleFurnitures, rewardItems) + local rewardGridDatas = {} + local sortedRewardItems = XRewardManager.MergeAndSortRewardGoodsList(rewardItems) + + for index, data in pairs(sortedRewardItems) do + table.insert(rewardGridDatas, { Data = data, GridIndex = index }) + end + + local onCreate = function(item, data) + item:Refresh(data, false, true, true) + end + + local onFurnitureCreate = function(item, id) + item:Refresh(id) + end + + XUiHelper.CreateTemplates(self, self.RecycleItems, recycleFurnitures, XUiGridFurniture.New, self.GridFurnitureRecycle.gameObject, self.PanelRecycle, onFurnitureCreate) + XUiHelper.CreateTemplates(self, self.RewardItems, rewardGridDatas, XUiBagItem.New, self.GridFurnitureRecycle.gameObject, self.PanelReward, onCreate) + self.GridFurnitureRecycle.gameObject:SetActive(false) + + if self.OpenFinishCallBack then + self.OpenFinishCallBack() + end +end + +function XUiDormBagRecycle:AddListener() + self:RegisterClickEvent(self.BtnClose, self.OnBtnCloseClick) +end + +function XUiDormBagRecycle:OnBtnCloseClick() + self:Close() + if self.CloseFinishCallBack then + self.CloseFinishCallBack() + end +end + +return XUiDormBagRecycle \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormCharacterDetail/XUiDormCharacterDetail.lua b/Resources/Scripts/XUi/XUiDormCharacterDetail/XUiDormCharacterDetail.lua new file mode 100644 index 00000000..ee990864 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormCharacterDetail/XUiDormCharacterDetail.lua @@ -0,0 +1,156 @@ +local XUiGridDetailDormCharacter = require("XUi/XUiDormCharacterDetail/XUiGridDetailDormCharacter") +local XUiDormCharacterDetail = XLuaUiManager.Register(XLuaUi, "UiDormCharacterDetail") + +function XUiDormCharacterDetail:OnAwake() + self:AddListener() + + CS.XGlobalIllumination.SetSceneType(CS.XSceneType.Ui) + + XEventManager.AddEventListener(XEventId.EVENT_CHARACTER_MOOD_CHANGED, self.UpdateMoodInfo, self) + XEventManager.AddEventListener(XEventId.EVENT_CHARACTER_VITALITY_CHANGED, self.UpdateVitalityInfo, self) + + --这里处理一下场景类型 +end + +function XUiDormCharacterDetail:OnDisable() + XHomeDormManager.ShowOrHideBuilding(true) + CS.XGlobalIllumination.SetSceneType(CS.XSceneType.Dormitory) +end + + +function XUiDormCharacterDetail:OnDestroy() + XEventManager.RemoveEventListener(XEventId.EVENT_CHARACTER_MOOD_CHANGED, self.UpdateMoodInfo, self) + XEventManager.RemoveEventListener(XEventId.EVENT_CHARACTER_VITALITY_CHANGED, self.UpdateVitalityInfo, self) + + if self.Resource then + self.Resource:Release() + end + + if self.Model then + CS.UnityEngine.Object.Destroy(self.Model) + end +end + +function XUiDormCharacterDetail:OnStart(characterId) + XHomeDormManager.ShowOrHideBuilding(false) + self.CharacterId = characterId + XHomeCharManager.HideAllCharacter() + self:InitStyleInfo() + self:InitModelInfo() + self:InitExpInfo() + + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.DormCoin, XDataCenter.ItemManager.ItemId.FurnitureCoin) +end + +function XUiDormCharacterDetail:AddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:RegisterClickEvent(self.BtnLikeInfo, self.OnBtnLikeInfoClick) + self:RegisterClickEvent(self.BtnFriendInfo, self.OnBtnFriendInfoClick) +end + +function XUiDormCharacterDetail:OnBtnMainUiClick() + XHomeCharManager.ShowAllCharacter() + XHomeDormManager.SetIllumination() + XLuaUiManager.RunMain() +end + +function XUiDormCharacterDetail:OnBtnBackClick() + XHomeCharManager.ShowAllCharacter() + XHomeDormManager.SetIllumination() + self:Close() +end + +function XUiDormCharacterDetail:OnBtnLikeInfoClick() + XLuaUiManager.Open("UiDormCharacterLikeInfo", self.CharacterId) +end + +function XUiDormCharacterDetail:OnBtnFriendInfoClick() + -- 暂未开放 + XUiManager.TipMsg(CS.XTextManager.GetText("ComingSoon"), XUiManager.UiTipType.Tip) +end + +function XUiDormCharacterDetail:InitStyleInfo() + self.GridHostelCharacter.gameObject:SetActive(false) + local charStyleConfig = XDormConfig.GetCharacterStyleConfigById(self.CharacterId) + local loveTypeConfig = XFurnitureConfigs.GetDormFurnitureType(charStyleConfig.LoveType) + local likeTypeConfig = XFurnitureConfigs.GetDormFurnitureType(charStyleConfig.LikeType) + + self.TxtName.text = charStyleConfig.NameFrist + self.TxtLastName.text = charStyleConfig.NameLast + self:SetUiSprite(self.ImgLove, loveTypeConfig.TypeIcon) + self:SetUiSprite(self.ImgLike, likeTypeConfig.TypeIcon) + + self.TxtLove.text = CS.XTextManager.GetText("DormHight", loveTypeConfig.Color, loveTypeConfig.TypeName) + self.TxtLike.text = CS.XTextManager.GetText("DormMiddle", likeTypeConfig.Color, likeTypeConfig.TypeName) + + for i = 1, #charStyleConfig.LikeCharIds do + local grid = CS.UnityEngine.Object.Instantiate(self.GridHostelCharacter) + local gridDormCharacter = XUiGridDetailDormCharacter.New(grid) + gridDormCharacter:Refresh(charStyleConfig.LikeCharIds[i], true) + grid.transform:SetParent(self.PanelLikeConent, false) + gridDormCharacter.GameObject:SetActive(true) + end + + for i = 1, #charStyleConfig.HateCharIds do + local grid = CS.UnityEngine.Object.Instantiate(self.GridHostelCharacter) + local gridDormCharacter = XUiGridDetailDormCharacter.New(grid) + gridDormCharacter:Refresh(charStyleConfig.HateCharIds[i], false) + grid.transform:SetParent(self.PanelHateConent, false) + gridDormCharacter.GameObject:SetActive(true) + end +end + +function XUiDormCharacterDetail:InitModelInfo() + local charStyleConfig = XDormConfig.GetCharacterStyleConfigById(self.CharacterId) + local root = self.UiModelGo.transform + local target = root:FindTransform("PanelRoleModel") + + self.Resource = CS.XResourceManager.Load(charStyleConfig.Model) + self.Model = CS.UnityEngine.Object.Instantiate(self.Resource.Asset) + self.Model.transform:SetParent(target, false) + self.Model.gameObject:SetLayerRecursively(target.gameObject.layer) + self.PanelDrag.Target = self.Model.transform + + local animator = self.Model:GetComponent("Animator") + animator:SetInteger("State", 1) +end + +function XUiDormCharacterDetail:InitExpInfo() + local characterData = XDataCenter.DormManager.GetCharacterDataByCharId(self.CharacterId) + + self.ImgHpExp.fillAmount = characterData.Vitality / XDormConfig.DORM_VITALITY_MAX_VALUE + self.ImgMoodExp.fillAmount = characterData.Mood / XDormConfig.DORM_MOOD_MAX_VALUE + self.TxtHpCount.text = CS.XTextManager.GetText("DormCharacterHpLeft", characterData.Vitality, XDormConfig.DORM_VITALITY_MAX_VALUE) + + self.TxtMoodState.text = XDormConfig.GetMoodStateDesc(characterData.Mood) + self.ImgMoodExp.color = XDormConfig.GetMoodStateColor(characterData.Mood) + + XDataCenter.DormManager.GetDormitoryRecoverSpeed(self.CharacterId, function(moodSpeed, vitalitySpeed) + self.TxtMoodRecover.text = CS.XTextManager.GetText("DormCharacterMoodSpeed", moodSpeed) + self.TxtHpRecover.text = CS.XTextManager.GetText("DormCharacterHpSpeed", vitalitySpeed) + end) +end + +function XUiDormCharacterDetail:UpdateMoodInfo(characterId) + if not self.CharacterId or self.CharacterId ~= characterId then + return + end + + local characterData = XDataCenter.DormManager.GetCharacterDataByCharId(self.CharacterId) + + self.ImgMoodExp.fillAmount = characterData.Mood / XDormConfig.DORM_MOOD_MAX_VALUE + self.TxtMoodState.text = XDormConfig.GetMoodStateDesc(characterData.Mood) + self.ImgMoodExp.color = XDormConfig.GetMoodStateColor(characterData.Mood) +end + +function XUiDormCharacterDetail:UpdateVitalityInfo(characterId) + if not self.CharacterId or self.CharacterId ~= characterId then + return + end + + local characterData = XDataCenter.DormManager.GetCharacterDataByCharId(self.CharacterId) + + self.ImgHpExp.fillAmount = characterData.Vitality / XDormConfig.DORM_VITALITY_MAX_VALUE + self.TxtHpCount.text = CS.XTextManager.GetText("DormCharacterHpLeft", characterData.Vitality, XDormConfig.DORM_VITALITY_MAX_VALUE) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormCharacterDetail/XUiDormCharacterLikeInfo.lua b/Resources/Scripts/XUi/XUiDormCharacterDetail/XUiDormCharacterLikeInfo.lua new file mode 100644 index 00000000..51aee394 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormCharacterDetail/XUiDormCharacterLikeInfo.lua @@ -0,0 +1,41 @@ +local XUiGridLikeInfo = require("XUi/XUiDormCharacterDetail/XUiGridLikeInfo") + +local XUiDormCharacterLikeInfo = XLuaUiManager.Register(XLuaUi, "UiDormCharacterLikeInfo") + +function XUiDormCharacterLikeInfo:OnAwake() + self:AutoAddListener() +end + +function XUiDormCharacterLikeInfo:OnStart(characterId) + self.CharacterId = characterId + self:Init() +end + +function XUiDormCharacterLikeInfo:OnEnable() + self:PlayAnimation("LikeInfoEnable") +end + +function XUiDormCharacterLikeInfo:OnDisable() + self:PlayAnimation("LikeInfoDisable") +end + +function XUiDormCharacterLikeInfo:AutoAddListener() + self:RegisterClickEvent(self.BtnClose, self.OnBtnCloseClick) +end + +function XUiDormCharacterLikeInfo:OnBtnCloseClick() + self:Close() +end + +function XUiDormCharacterLikeInfo:Init() + local recoveryConfigs = XDormConfig.GetCharRecoveryConfig(self.CharacterId) + self.GridLikeInfo.gameObject:SetActive(false) + + for i = 1, #recoveryConfigs do + local grid = CS.UnityEngine.Object.Instantiate(self.GridLikeInfo) + local gridLikeInfo = XUiGridLikeInfo.New(grid, self) + gridLikeInfo:Refresh(recoveryConfigs[i]) + grid.transform:SetParent(self.PanelRecycle, false) + gridLikeInfo.GameObject:SetActive(true) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormCharacterDetail/XUiGridDetailDormCharacter.lua b/Resources/Scripts/XUi/XUiDormCharacterDetail/XUiGridDetailDormCharacter.lua new file mode 100644 index 00000000..7708bae7 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormCharacterDetail/XUiGridDetailDormCharacter.lua @@ -0,0 +1,21 @@ +local XUiGridDetailDormCharacter = XClass(nil, "XUiGridDetailDormCharacter") + +function XUiGridDetailDormCharacter:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiGridDetailDormCharacter:Refresh(characterId, isLike) + self.CharacterId = characterId + + local charStyleConfig = XDormConfig.GetCharacterStyleConfigById(characterId) + self.RImgHead:SetRawImage(charStyleConfig.HeadRoundIcon, nil, true) + + self.PanelLikeIcon.gameObject:SetActive(isLike) + self.PanelHateIcon.gameObject:SetActive(not isLike) + + self.TxtCharacterName.text = charStyleConfig.Name +end + +return XUiGridDetailDormCharacter \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormCharacterDetail/XUiGridLikeInfo.lua b/Resources/Scripts/XUi/XUiDormCharacterDetail/XUiGridLikeInfo.lua new file mode 100644 index 00000000..daf9ef09 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormCharacterDetail/XUiGridLikeInfo.lua @@ -0,0 +1,66 @@ +local XUiGridLikeInfo = XClass(nil, "XUiGridLikeInfo") + +function XUiGridLikeInfo:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) +end + +function XUiGridLikeInfo:Refresh(config) + if XDataCenter.DormManager.CheckCharInDorm(config.CharacterId) then + local charLevelConfig = XDataCenter.DormManager.GetCharRecoveryCurLevel(config.CharacterId) + local isCur = charLevelConfig and charLevelConfig.Pre == config.Pre + self.PanelCurLevel.gameObject:SetActive(isCur) + else + self.PanelCurLevel.gameObject:SetActive(false) + end + + local indexA = XFurnitureConfigs.AttrType.AttrA - 1 + local indexB = XFurnitureConfigs.AttrType.AttrB - 1 + local indexC = XFurnitureConfigs.AttrType.AttrC - 1 + + local vitalitySpeed = XFurnitureConfigs.GetRecoverSpeed(config.VitalityRecovery) + local moodSpeed = XFurnitureConfigs.GetRecoverSpeed(config.MoodRecovery) + + self.TxtLevel.text = "Lv." .. config.Pre + local vContext = config.VitalityRecoveryType > 0 and "DormVitalityRecovery1" or "DormVitalityRecovery" + local mContext = config.MoodRecoveryType > 0 and "DormMoodRecovery1" or "DormMoodRecovery" + + self.TxtVitality.text = CS.XTextManager.GetText(vContext, vitalitySpeed) + self.TxtMood.text = CS.XTextManager.GetText(mContext, moodSpeed) + + if config.AttrTotal > 0 then + local allConfig = XFurnitureConfigs.GetDormFurnitureType(XFurnitureConfigs.AttrType.AttrAll) + self.RootUi:SetUiSprite(self.ImgeAllIcon, allConfig.TypeIcon) + self.TxtAllDesc.text = allConfig.TypeName .. "≥" .. config.AttrTotal + else + self.ConditionsAll.gameObject:SetActive(false) + end + + if config.AttrCondition[indexA] > 0 then + local redConfig = XFurnitureConfigs.GetDormFurnitureType(XFurnitureConfigs.AttrType.AttrA) + self.RootUi:SetUiSprite(self.ImgeRedIcon, redConfig.TypeIcon) + self.TxtRedDesc.text = redConfig.TypeName .. "≥" .. config.AttrCondition[indexA] + else + self.ConditionsRed.gameObject:SetActive(false) + end + + if config.AttrCondition[indexB] > 0 then + local yellowConfig = XFurnitureConfigs.GetDormFurnitureType(XFurnitureConfigs.AttrType.AttrB) + self.RootUi:SetUiSprite(self.ImgeYellowIcon, yellowConfig.TypeIcon) + self.TxtYellowDesc.text = yellowConfig.TypeName .. "≥" .. config.AttrCondition[indexB] + else + self.ConditionsYellow.gameObject:SetActive(false) + end + + if config.AttrCondition[indexC] > 0 then + local blueConfig = XFurnitureConfigs.GetDormFurnitureType(XFurnitureConfigs.AttrType.AttrC) + self.RootUi:SetUiSprite(self.ImgeBlueIcon, blueConfig.TypeIcon) + self.TxtBlueDesc.text = blueConfig.TypeName .. "≥" .. config.AttrCondition[indexC] + else + self.ConditionsBlue.gameObject:SetActive(false) + end +end + +return XUiGridLikeInfo \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormCharacterDetail/XUiPanelCharacterLikeInfo.lua b/Resources/Scripts/XUi/XUiDormCharacterDetail/XUiPanelCharacterLikeInfo.lua new file mode 100644 index 00000000..dd1d6cdb --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormCharacterDetail/XUiPanelCharacterLikeInfo.lua @@ -0,0 +1,57 @@ +local XUiGridLikeInfo = require("XUi/XUiDormCharacterDetail/XUiGridLikeInfo") + +local XUiPanelCharacterLikeInfo = XClass(nil, "XUiPanelCharacterLikeInfo") + +function XUiPanelCharacterLikeInfo:Ctor(ui, characterId) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.CharacterId = characterId + XTool.InitUiObject(self) + self:AutoAddListener() + self:Init() + self.GameObject:SetActive(false) +end + +function XUiPanelCharacterLikeInfo:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelCharacterLikeInfo:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelCharacterLikeInfo:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelCharacterLikeInfo:AutoAddListener() + self:RegisterClickEvent(self.BtnClose, self.OnBtnCloseClick) +end + +function XUiPanelCharacterLikeInfo:OnBtnCloseClick() + self.GameObject:SetActive(false) +end + +function XUiPanelCharacterLikeInfo:Init() + local recoveryConfigs = XDormConfig.GetCharRecoveryConfig(self.CharacterId) + self.GridLikeInfo.gameObject:SetActive(false) + + for i = 1, #recoveryConfigs do + local grid = CS.UnityEngine.Object.Instantiate(self.GridLikeInfo) + local gridLikeInfo = XUiGridLikeInfo.New(grid) + gridLikeInfo:Refresh(recoveryConfigs[i]) + grid.transform:SetParent(self.PanelRecycle, false) + gridLikeInfo.GameObject:SetActive(true) + end +end + +function XUiPanelCharacterLikeInfo:Open() + self.GameObject:SetActive(true) +end + +return XUiPanelCharacterLikeInfo \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormComponent/XUiDormComponent.lua b/Resources/Scripts/XUi/XUiDormComponent/XUiDormComponent.lua new file mode 100644 index 00000000..4d17c0d0 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormComponent/XUiDormComponent.lua @@ -0,0 +1,338 @@ +local XUiDormComponent = XLuaUiManager.Register(XLuaUi, "UiDormComponent") +local XUiGrid3DObj = require("XUi/XUiDormComponent/XUiGrid3DObj") +local XUiGridDialogBox = require("XUi/XUiDormComponent/XUiGridDialogBox") +local XUiPanelExp = require("XUi/XUiDormComponent/XUiPanelExp") +local XUiPanelExpDetail = require("XUi/XUiDormComponent/XUiPanelExpDetail") +local XUiPanelPutOn = require("XUi/XUiDormComponent/XUiPanelPutOn") +local XUiPanelTouch = require("XUi/XUiDormComponent/XUiPanelTouch") +local XUiFurnitureAttrObj = require("XUi/XUiDormComponent/XUiFurnitureAttrObj") + +function XUiDormComponent:OnAwake() + self.CurDormSecond = true + XEventManager.AddEventListener(XEventId.EVENT_CHARACTER_MOOD_CHANGED, self.OnCharacterMoodChange, self) + XEventManager.AddEventListener(XEventId.EVENT_CHARACTER_VITALITY_CHANGED, self.OnCharacterVitaltyChange, self) + XEventManager.AddEventListener(XEventId.EVENT_CHARACTER_PUT_ON, self.OnCharacterPutOn, self) + XEventManager.AddEventListener(XEventId.EVENT_CHARACTER_PUT_DOWN, self.OnCharacterPutDown, self) + XEventManager.AddEventListener(XEventId.EVENT_CHARACTER_CATCH, self.OnCharacterCatch, self) + XEventManager.AddEventListener(XEventId.EVENT_CHARACTER_EXIT, self.OnCharacterExit, self) + XEventManager.AddEventListener(XEventId.EVENT_DORM_ROOM, self.OnEnterRoom, self) + XEventManager.AddEventListener(XEventId.EXIT_DORM_ROOM, self.CloseComponent, self) + XEventManager.AddEventListener(XEventId.EVENT_DORM_TOUCH_SHOW, self.OnTouchShow, self) + XEventManager.AddEventListener(XEventId.EVENT_DORM_TOUCH_SHOW_VIEW, self.OnTouchShow, self) + XEventManager.AddEventListener(XEventId.EVENT_DORM_TOUCH_HIDE, self.OnTouchHide, self) + XEventManager.AddEventListener(XEventId.EVENT_CHARACTER_SHOW_DIALOBOX, self.OnShowDialoBox, self) + XEventManager.AddEventListener(XEventId.EVENT_CHARACTER_HIDE_DIALOBOX, self.OnHideDialoBox, self) + XEventManager.AddEventListener(XEventId.EVENT_CHARACTER_SHOW_3DIOBJ, self.OnShow3DObj, self) + XEventManager.AddEventListener(XEventId.EVENT_CHARACTER_HIDE_3DIOBJ, self.OnHide3DObj, self) + XEventManager.AddEventListener(XEventId.EVENT_DORM_EXP_DETAIL_SHOW, self.OnExpDetailShow, self) + XEventManager.AddEventListener(XEventId.EVENT_DORM_EXP_DETAIL_HIDE, self.OnExpDetailHide, self) + XEventManager.AddEventListener(XEventId.EVENT_DORM_TOUCH_ENTER, self.OnExpShow, self) + XEventManager.AddEventListener(XEventId.EVENT_DORM_EXP_SHOW, self.OnExpShow, self) + XEventManager.AddEventListener(XEventId.EVENT_DORM_EXP_HIDE, self.OnExpHide, self) + + XEventManager.AddEventListener(XEventId.EVENT_DORM_HIDE_COMPONET, self.HieComponent, self) + XEventManager.AddEventListener(XEventId.EVENT_DORM_CLOSE_COMPONET, self.CloseComponent, self) + XEventManager.AddEventListener(XEventId.EVENT_DORM_SECOND_STATE, self.DormSecondState, self) + + CsXGameEventManager.Instance:RegisterEvent(XEventId.EVENT_DORM_FURNITURE_ATTR_TAG_DETAIL, handler(self, self.ShowFurnitureAttr)) + CsXGameEventManager.Instance:RegisterEvent(XEventId.EVENT_DORM_FURNITURE_HIDE_ATTR_TAG_DETAIL, handler(self, self.HideFurnitureAttr)) + CsXGameEventManager.Instance:RegisterEvent(XEventId.EVENT_DORM_FURNITURE_HIDE_ALL_ATTR_TAG_DETAIL, handler(self, self.HideAllFurnitureAttr)) + +end + +function XUiDormComponent:OnDestroy() + XEventManager.RemoveEventListener(XEventId.EVENT_CHARACTER_MOOD_CHANGED, self.OnCharacterMoodChange, self) + XEventManager.RemoveEventListener(XEventId.EVENT_CHARACTER_VITALITY_CHANGED, self.OnCharacterVitaltyChange, self) + XEventManager.RemoveEventListener(XEventId.EVENT_CHARACTER_PUT_ON, self.OnCharacterPutOn, self) + XEventManager.RemoveEventListener(XEventId.EVENT_CHARACTER_PUT_DOWN, self.OnCharacterPutDown, self) + XEventManager.RemoveEventListener(XEventId.EVENT_CHARACTER_CATCH, self.OnCharacterCatch, self) + XEventManager.RemoveEventListener(XEventId.EVENT_CHARACTER_EXIT, self.OnCharacterExit, self) + XEventManager.RemoveEventListener(XEventId.EVENT_DORM_ROOM, self.OnEnterRoom, self) + XEventManager.RemoveEventListener(XEventId.EXIT_DORM_ROOM, self.CloseComponent, self) + XEventManager.RemoveEventListener(XEventId.EVENT_DORM_TOUCH_SHOW, self.OnTouchShow, self) + XEventManager.RemoveEventListener(XEventId.EVENT_DORM_TOUCH_SHOW_VIEW, self.OnTouchShow, self) + XEventManager.RemoveEventListener(XEventId.EVENT_DORM_TOUCH_HIDE, self.OnTouchHide, self) + XEventManager.RemoveEventListener(XEventId.EVENT_CHARACTER_SHOW_DIALOBOX, self.OnShowDialoBox, self) + XEventManager.RemoveEventListener(XEventId.EVENT_CHARACTER_HIDE_DIALOBOX, self.OnHideDialoBox, self) + XEventManager.RemoveEventListener(XEventId.EVENT_CHARACTER_SHOW_3DIOBJ, self.OnShow3DObj, self) + XEventManager.RemoveEventListener(XEventId.EVENT_CHARACTER_HIDE_3DIOBJ, self.OnHide3DObj, self) + XEventManager.RemoveEventListener(XEventId.EVENT_DORM_EXP_DETAIL_SHOW, self.OnExpDetailShow, self) + XEventManager.RemoveEventListener(XEventId.EVENT_DORM_EXP_DETAIL_HIDE, self.OnExpDetailHide, self) + XEventManager.RemoveEventListener(XEventId.EVENT_DORM_TOUCH_ENTER, self.OnExpShow, self) + XEventManager.RemoveEventListener(XEventId.EVENT_DORM_EXP_SHOW, self.OnExpShow, self) + XEventManager.RemoveEventListener(XEventId.EVENT_DORM_EXP_HIDE, self.OnExpHide, self) + + XEventManager.RemoveEventListener(XEventId.EVENT_DORM_HIDE_COMPONET, self.HieComponent, self) + XEventManager.RemoveEventListener(XEventId.EVENT_DORM_CLOSE_COMPONET, self.CloseComponent, self) + XEventManager.RemoveEventListener(XEventId.EVENT_DORM_SECOND_STATE, self.DormSecondState, self) + + CsXGameEventManager.Instance:RemoveEvent(XEventId.EVENT_DORM_FURNITURE_ATTR_TAG_DETAIL, handler(self, self.ShowFurnitureAttr)) + CsXGameEventManager.Instance:RemoveEvent(XEventId.EVENT_DORM_FURNITURE_HIDE_ATTR_TAG_DETAIL, handler(self, self.HideFurnitureAttr)) + CsXGameEventManager.Instance:RemoveEvent(XEventId.EVENT_DORM_FURNITURE_HIDE_ALL_ATTR_TAG_DETAIL, handler(self, self.HideAllFurnitureAttr)) + +end + +function XUiDormComponent:DormSecondState(state) + self.CurDormSecond = state +end + +function XUiDormComponent:OnStart() + self.DialogGridsDir = {} + self.DialogGridsList = {} + + self.Obj3DGridsDir = {} + self.Obj3DGridsList = {} + + self.FurnitureScoreDic = {} + + self.UiPanelExp = XUiPanelExp.New(self, self.PanelExp) + self.UiPanelTouch = XUiPanelTouch.New(self, self.PanelTouch) + self.UiPanelExpDetail = XUiPanelExpDetail.New(self, self.PanelExpDetail) + self.UiPanelPutOn = XUiPanelPutOn.New(self, self.PanelPutOn) + + self.UiPanelExp.GameObject:SetActive(false) + self.UiPanelExpDetail.GameObject:SetActive(false) + self.UiPanelPutOn.GameObject:SetActive(false) + self.UiPanelTouch.GameObject:SetActive(false) + self.GridDialogBox.gameObject:SetActive(false) + self.Grid3DObj.gameObject:SetActive(false) +end + +function XUiDormComponent:OnEnterRoom(curRoomId) + self.CurRoomId = curRoomId + + self.UiPanelExp:InitRoomId(curRoomId) + self.UiPanelExpDetail:InitRoomId(curRoomId) + self.UiPanelPutOn:InitRoomId(curRoomId) + self.UiPanelTouch:InitRoomId(curRoomId) +end + +function XUiDormComponent:OnCharacterMoodChange(characterId, changeValue) + self.UiPanelExp:UpdateExpInfo(characterId, changeValue) + self.UiPanelExpDetail:UpdateExpInfo(characterId) +end + +function XUiDormComponent:OnCharacterVitaltyChange(characterId) + self.UiPanelExpDetail:UpdateInfo(characterId) +end + +----------------------- 外部调用 ------------------------------------ +-- 对话气泡显示 +function XUiDormComponent:OnShowDialoBox(characterId, contextId, transform, cb) + -- 处理已经在显示中 + if self.DialogGridsDir[characterId] then + self.DialogGridsDir[characterId]:RefreshContext(contextId) + return + end + + -- 处理缓存中的 + if #self.DialogGridsList > 0 then + local temp = table.remove(self.DialogGridsList, 1) + temp:Show(self.CurRoomId, characterId, contextId, transform, cb) + self.DialogGridsDir[characterId] = temp + return + end + + -- 重新实例一个 + local grid = CS.UnityEngine.Object.Instantiate(self.GridDialogBox) + local gridBox = XUiGridDialogBox.New(self, grid) + gridBox:Show(self.CurRoomId, characterId, contextId, transform, cb) + grid.transform:SetParent(self.DialogContainer, false) + self.DialogGridsDir[characterId] = gridBox +end + +-- 对话气泡隐藏 +function XUiDormComponent:OnHideDialoBox(characterId) + if not self.DialogGridsDir[characterId] then + return + end + + self.DialogGridsDir[characterId]:Hide() + table.insert(self.DialogGridsList, self.DialogGridsDir[characterId]) + self.DialogGridsDir[characterId] = nil +end + +-- 3DUI显示 +function XUiDormComponent:OnShow3DObj(characterId, effectId, transform, bindWorldPos) + -- 处理已经在显示中 + if self.Obj3DGridsDir[characterId] then + self.Obj3DGridsDir[characterId]:RefreshEffect(effectId, bindWorldPos) + return + end + + -- 处理缓存中的 + if #self.Obj3DGridsList > 0 then + local temp = table.remove(self.Obj3DGridsList, 1) + temp:Show(characterId, effectId, transform, bindWorldPos) + self.Obj3DGridsDir[characterId] = temp + return + end + + -- 重新实例一个 + local grid = CS.UnityEngine.Object.Instantiate(self.Grid3DObj) + local gridBox = XUiGrid3DObj.New(grid) + gridBox:Show(characterId, effectId, transform, bindWorldPos) + self.Obj3DGridsDir[characterId] = gridBox +end + +-- 3DUI隐藏 +function XUiDormComponent:OnHide3DObj(characterId) + if not self.Obj3DGridsDir[characterId] then + return + end + + self.Obj3DGridsDir[characterId]:Hide() + table.insert(self.Obj3DGridsList, self.Obj3DGridsDir[characterId]) + self.Obj3DGridsDir[characterId].Transform:SetParent(self.Obje3DContainer, false) + self.Obj3DGridsDir[characterId] = nil +end + +-- 抚摸显示 +function XUiDormComponent:OnTouchShow(touchState, characterId, point, propNum) + self.UiPanelTouch:Show(characterId, touchState, point, propNum) +end + +-- 抚摸隐藏 +function XUiDormComponent:OnTouchHide() + self.UiPanelTouch:Hide() + self.UiPanelExp:Hide(true) + self:OnExpDetailHide() +end + +-- 抓起构造体 +function XUiDormComponent:OnCharacterCatch() + self.UiPanelPutOn:Catch() +end + +-- 抓起构造体读条放下 +function XUiDormComponent:OnCharacterExit() + self.UiPanelPutOn:Close() +end + +-- 构造体抓起读条 +function XUiDormComponent:OnCharacterPutOn(id, transform, isCharacter) + self.UiPanelPutOn:Show(id, transform, isCharacter) +end + +-- 放下构造体 +function XUiDormComponent:OnCharacterPutDown() + self.UiPanelPutOn:Hide() +end + +-- 显示体力详情 +function XUiDormComponent:OnExpDetailShow(characterId, transform) + if not self.CurDormSecond then + return + end + self.CharacterId = characterId + self.Transform = transform + self.UiPanelExpDetail:Show(characterId, transform) +end + +-- 隐藏体力详情 +function XUiDormComponent:OnExpDetailHide() + self.UiPanelExpDetail:Hide() +end + +-- 显示心情条 +function XUiDormComponent:OnExpShow(characterId) + local trans = XHomeCharManager.GetSelectCharacter().Transform + self.UiPanelExp:Show(characterId, trans) +end + +-- 隐藏心情条 +function XUiDormComponent:OnExpHide() + self.UiPanelExp:Hide(false) +end + +-- 设置心情条是否再爱抚中 +function XUiDormComponent:SetExpOffset(isFondle) + self.UiPanelExp:UpdateOffset(isFondle) +end + +-- 隐藏所有组建 +function XUiDormComponent:HieComponent() + self.UiPanelExp:Hide(true) + self.UiPanelExpDetail:Hide() + self.UiPanelTouch:Hide() + self.UiPanelPutOn:Hide() + + for _, v in pairs(self.DialogGridsDir) do + v:Hide() + table.insert(self.DialogGridsList, v) + end + + for _, v in pairs(self.Obj3DGridsDir) do + v:Hide() + table.insert(self.Obj3DGridsList, v) + v.Transform:SetParent(self.Obje3DContainer, false) + end + + self.Obj3DGridsDir = {} + self.DialogGridsDir = {} +end + +--显示家具属性 +function XUiDormComponent:ShowFurnitureAttr(evt, args) + local furnitureAttrObj + local furnitureId = args[1] + + if not self.FurnitureScoreContainer or XTool.UObjIsNil(self.FurnitureScoreContainer) then + return + end + + if not self.FurnitureScoreDic[furnitureId] then + local obj = self.FurnitureScoreContainer:Spawn() + furnitureAttrObj = XUiFurnitureAttrObj.New(self, obj) + self.FurnitureScoreDic[furnitureId] = furnitureAttrObj + else + furnitureAttrObj = self.FurnitureScoreDic[furnitureId] + end + + self.FurnitureScoreContainer.gameObject:SetActiveEx(true) + + furnitureAttrObj:Show(args[0], args[1], args[2], args[3], args[4], args[5], args[6]) +end + +--隐藏家具属性 +function XUiDormComponent:HideFurnitureAttr(evt, args) + local furnitureId = args[0] + + if not self.FurnitureScoreContainer or XTool.UObjIsNil(self.FurnitureScoreContainer) then + return + end + + + if self.FurnitureScoreDic[furnitureId] then + local furnitureAttrObj = self.FurnitureScoreDic[furnitureId] + self.FurnitureScoreContainer:Despawn(furnitureAttrObj.GameObject) + furnitureAttrObj:Hide() + self.FurnitureScoreDic[furnitureId] = nil + end + +end + +--隐藏家具属性 +function XUiDormComponent:HideAllFurnitureAttr(evt) + + if not self.FurnitureScoreContainer or XTool.UObjIsNil(self.FurnitureScoreContainer) then + return + end + + if self.FurnitureScoreDic then + for _, v in pairs(self.FurnitureScoreDic) do + self.FurnitureScoreContainer:Despawn(v.GameObject) + v:Hide() + end + end + + XHomeDormManager.FurnitureShowAttrType = -1 + self.FurnitureScoreContainer.gameObject:SetActiveEx(false) + self.FurnitureScoreDic = {} +end + +-- 关闭 +function XUiDormComponent:CloseComponent() + self:HideAllFurnitureAttr() + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormComponent/XUiFurnitureAttrObj.lua b/Resources/Scripts/XUi/XUiDormComponent/XUiFurnitureAttrObj.lua new file mode 100644 index 00000000..1f295eaf --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormComponent/XUiFurnitureAttrObj.lua @@ -0,0 +1,49 @@ +local XUiFurnitureAttrObj = XClass(XLuaBehaviour, "XUiFurnitureAttrObj") + +function XUiFurnitureAttrObj:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) +end + + +function XUiFurnitureAttrObj:Show(roomId, furnitureId, transform, text, progress, color, offset) + self.FurnitureId = furnitureId + self.TargetTransform = transform + self.CurRoomId = roomId + + self.ScoreText.text = text + self.Scrollbar.value = 0 + self.Scrollbar.size = progress + color = string.sub(color, 2, string.len(color)) + self.Handle.color = XUiHelper.Hexcolor2Color(color) + + self.Offset = offset + +end + +function XUiFurnitureAttrObj:Hide() + self.TargetTransform = nil + self.GameObject:SetActiveEx(false) +end + +function XUiFurnitureAttrObj:Update() + if XTool.UObjIsNil(self.Transform) or not self.GameObject.activeSelf then + return + end + + if XTool.UObjIsNil(self.TargetTransform) then + return + end + + self:UpdateTransform(self.TargetTransform) +end + +function XUiFurnitureAttrObj:UpdateTransform(transform) + local pos = transform.position + CS.UnityEngine.Vector3(0, self.Offset, 0) + local viewPos = XHomeDormManager.GetWorldToViewPoint(self.CurRoomId, pos) + self.Transform.localPosition = viewPos +end + +return XUiFurnitureAttrObj \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormComponent/XUiGrid3DObj.lua b/Resources/Scripts/XUi/XUiDormComponent/XUiGrid3DObj.lua new file mode 100644 index 00000000..18be413f --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormComponent/XUiGrid3DObj.lua @@ -0,0 +1,47 @@ +local XUiGrid3DObj = XClass(nil, "XUiGrid3DObj") + +function XUiGrid3DObj:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) +end + +function XUiGrid3DObj:RefreshEffect(effectId, bindWorldPos) + if self.EffectId == effectId then + return + end + + self.EffectId = effectId + + local effectConfig = XDormConfig.GetMoodEffectConfig(effectId) + self.EffectObj = self.Transform:LoadPrefab(effectConfig.Path) + self.EffectObj.transform:SetParent(self.PanelEffectObj, false) + + if bindWorldPos then + self.PanelEffectObj.transform.position = bindWorldPos + else + local position = CS.UnityEngine.Vector3(0, effectConfig.Hight, 0) + self.PanelEffectObj.transform.localPosition = position + end +end + +function XUiGrid3DObj:Show(characterId, effectId, transform, bindWorldPos) + local styleConfig = XDormConfig.GetCharacterStyleConfigById(characterId) + local position = CS.UnityEngine.Vector3(0, styleConfig.EffectWidgetHight, 0) + self.Transform:SetParent(transform, false) + self.Transform.localPosition = position + self.GameObject:SetLayerRecursively(transform.gameObject.layer) + + self:RefreshEffect(effectId, bindWorldPos) + self.BtnClick.gameObject:SetActive(false) + self.GameObject:SetActive(true) +end + +function XUiGrid3DObj:Hide() + self.EffectObj = nil + self.EffectId = 0 + self.GameObject:SetActive(false) +end + +return XUiGrid3DObj \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormComponent/XUiGridDialogBox.lua b/Resources/Scripts/XUi/XUiDormComponent/XUiGridDialogBox.lua new file mode 100644 index 00000000..cadb9a0a --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormComponent/XUiGridDialogBox.lua @@ -0,0 +1,91 @@ +local XUiGridDialogBox = XClass(XLuaBehaviour, "XUiGridDialogBox") + +function XUiGridDialogBox:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) +end + +function XUiGridDialogBox:RefreshContext(contextId) + self.DailogConfig = XDormConfig.GetCharacterDialogConfig(contextId) + if not self.DailogConfig or #self.DailogConfig.Content <= 0 then + return + end + + self:PlayDialog(1) +end + +function XUiGridDialogBox:PlayDialog(index) + -- 播放完对话 + if index > #self.DailogConfig.Content then + if self.Cb then + self.Cb() + end + return + end + + local context = self.DailogConfig.Content[index] or "" + if XDataCenter.DormManager.CheckInTouch() then + self.TxtTouchDesc.text = string.gsub(context, "\\n", "\n") + else + self.TxtDesc.text = string.gsub(context, "\\n", "\n") + end + local time = self.DailogConfig.Time[index] or 0 + + XScheduleManager.ScheduleOnce(function() + if XTool.UObjIsNil(self.Transform) or not self.GameObject.activeSelf then + return + end + + index = index + 1 + self:PlayDialog(index) + end, time) +end + +function XUiGridDialogBox:UpdateTransform(transform) + local pos = transform.position + self.Offset + local viewPos = XHomeDormManager.GetWorldToViewPoint(self.CurRoomId, pos) + self.Transform.localPosition = viewPos +end + +function XUiGridDialogBox:Show(curRoomId, characterId, contextId, transform, cb) + self.CurRoomId = curRoomId + self.Cb = cb + + self.TargetTransform = transform + + local styleConfig = XDormConfig.GetCharacterStyleConfigById(characterId) + if XDataCenter.DormManager.CheckInTouch() then + self.PanelBoxNamorl.gameObject:SetActive(false) + self.PanelBoxTouch.gameObject:SetActive(true) + self.Offset = CS.UnityEngine.Vector3(0, styleConfig.DailogTouchHight, 0) + else + self.PanelBoxNamorl.gameObject:SetActive(true) + self.PanelBoxTouch.gameObject:SetActive(false) + self.Offset = CS.UnityEngine.Vector3(0, styleConfig.DailogWidgetHight, 0) + end + + self:RefreshContext(contextId) + self:UpdateTransform(self.TargetTransform) + self.GameObject:SetActive(true) +end + +function XUiGridDialogBox:Hide() + self.TargetTransform = nil + self.GameObject:SetActive(false) +end + +function XUiGridDialogBox:Update() + if XTool.UObjIsNil(self.Transform) or not self.GameObject.activeSelf then + return + end + + if XTool.UObjIsNil(self.TargetTransform) then + return + end + + self:UpdateTransform(self.TargetTransform) +end + +return XUiGridDialogBox \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormComponent/XUiPanelExp.lua b/Resources/Scripts/XUi/XUiDormComponent/XUiPanelExp.lua new file mode 100644 index 00000000..dfcc07c3 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormComponent/XUiPanelExp.lua @@ -0,0 +1,116 @@ +local XUiPanelExp = XClass(XLuaBehaviour, "XUiPanelExp") + +function XUiPanelExp:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + + XTool.InitUiObject(self) +end + +function XUiPanelExp:InitRoomId(curRoomId) + self.CurRoomId = curRoomId + self:Hide(true) +end + +function XUiPanelExp:RefreshExpInfo(changeValue) + self:RemoveTimer() + local characterData = XDataCenter.DormManager.GetCharacterDataByCharId(self.CharacterId) + local moodConfig = XDormConfig.GetMoodStateByMoodValue(characterData.Mood) + + self.ImgCurEnergy.fillAmount = characterData.Mood / XDormConfig.DORM_MOOD_MAX_VALUE + self.ImgCurEnergy.color = XDormConfig.GetMoodStateColor(characterData.Mood) + self.RootUi:SetUiSprite(self.ImgIcon, moodConfig.Icon) + self.TxtMoodAdd.gameObject:SetActive(false) + + XDataCenter.DormManager.GetDormitoryRecoverSpeed(self.CharacterId, function(moodSpeed, vitalitySpeed, data) + local vContext = data.VitalitySpeed > 0 and "DormRecovery1" or "DormRecovery2" + local mContext = data.MoodSpeed > 0 and "DormRecovery1" or "DormRecovery2" + + self.TxtResume.text = CS.XTextManager.GetText(vContext, vitalitySpeed) + self.TxtMoodResume.text = CS.XTextManager.GetText(mContext, moodSpeed) + end) + + local charLevelConfig = XDataCenter.DormManager.GetCharRecoveryCurLevel(self.CharacterId) + self.TxtLevel.text = "Lv." .. charLevelConfig.Pre + + -- 不展示心情值减少事件 + if changeValue and changeValue > 0 then + self.TxtMoodAdd.text = "+" .. changeValue + self.TxtMoodAdd.gameObject:SetActive(true) + + self.Timer = XScheduleManager.ScheduleOnce(function() + if XTool.UObjIsNil(self.Transform) or not self.GameObject.activeSelf then + return + end + + self.TxtMoodAdd.gameObject:SetActive(false) + end, XDormConfig.DISPPEAR_TIME) + end +end + +function XUiPanelExp:RemoveTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end + +function XUiPanelExp:UpdateExpInfo(characterId, changeValue) + if not self.CharacterId or self.CharacterId ~= characterId then + return + end + + self:RefreshExpInfo(changeValue) +end + +function XUiPanelExp:UpdateTransform(transform) + local pos = transform.position + self.Offset + local viewPos = XHomeDormManager.GetWorldToViewPoint(self.CurRoomId, pos) + self.Transform.localPosition = viewPos +end + +function XUiPanelExp:Show(characterId, transform) + if characterId and not self.CharacterId then + self.CharacterId = characterId + end + + if transform and not self.TargetTransform then + self.TargetTransform = transform + end + + self.StyleConfig = XDormConfig.GetCharacterStyleConfigById(self.CharacterId) + self:UpdateOffset() + + self:UpdateTransform(self.TargetTransform) + self:RefreshExpInfo() + self.GameObject:SetActive(true) +end + +function XUiPanelExp:UpdateOffset() + local offsetHight = self.StyleConfig.ExpFondleWidgetHeight + self.Offset = CS.UnityEngine.Vector3(0, offsetHight, 0) +end + +function XUiPanelExp:Hide(clearId) + self:RemoveTimer() + self.TargetTransform = nil + if clearId then + self.CharacterId = nil + end + self.GameObject:SetActive(false) +end + +function XUiPanelExp:Update() + if not self.GameObject.activeSelf or XTool.UObjIsNil(self.Transform) then + return + end + + if XTool.UObjIsNil(self.TargetTransform) then + return + end + + self:UpdateTransform(self.TargetTransform) +end + +return XUiPanelExp \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormComponent/XUiPanelExpDetail.lua b/Resources/Scripts/XUi/XUiDormComponent/XUiPanelExpDetail.lua new file mode 100644 index 00000000..b21b7a38 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormComponent/XUiPanelExpDetail.lua @@ -0,0 +1,199 @@ +local XUiPanelExpDetail = XClass(XLuaBehaviour, "XUiPanelExpDetail") + +function XUiPanelExpDetail:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = rootUi + XTool.InitUiObject(self) + + self.OnBtnTouchClickCb = function() self:OnBtnTouchClick() end + self:InitAddListen() +end + +function XUiPanelExpDetail:InitAddListen() + self.UiRoot:RegisterClickEvent(self.BtnTouch, self.OnBtnTouchClickCb) + + XEventManager.AddEventListener(XEventId.EVENT_DORM_HEAD_TOUCH, self.OnBtnTouchClickCb, self) +end + +function XUiPanelExpDetail:OnDestroy() + XEventManager.RemoveEventListener(XEventId.EVENT_DORM_HEAD_TOUCH, self.OnBtnTouchClickCb, self) +end + +function XUiPanelExpDetail:InitRoomId(curRoomId) + self.CurRoomId = curRoomId + self:Hide() +end + +function XUiPanelExpDetail:OnBtnTouchClick() + self:Hide() + XDataCenter.DormManager.SetInTouch(true) + XEventManager.DispatchEvent(XEventId.EVENT_DORM_TOUCH_ENTER, self.CharacterId) +end + +function XUiPanelExpDetail:RefreshInfo(isUpdateSpeed) + local characterData = XDataCenter.DormManager.GetCharacterDataByCharId(self.CharacterId) + self.TxtStamina.text = characterData.Vitality .. "/" .. XDormConfig.DORM_VITALITY_MAX_VALUE + + if isUpdateSpeed then + XDataCenter.DormManager.GetDormitoryRecoverSpeed(self.CharacterId, function(moodSpeed, vitalitySpeed, data) + local vContext = data.VitalitySpeed > 0 and "DormRecovery1" or "DormRecovery2" + local mContext = data.MoodSpeed > 0 and "DormRecovery1" or "DormRecovery2" + + self.TxtResume.text = CS.XTextManager.GetText(vContext, vitalitySpeed) + self.TxtMoodResume.text = CS.XTextManager.GetText(mContext, moodSpeed) + end) + end + + local charLevelConfig = XDataCenter.DormManager.GetCharRecoveryCurLevel(self.CharacterId) + self.TxtLevel.text = "Lv." .. charLevelConfig.Pre +end + +function XUiPanelExpDetail:UpdateInfo(characterId) + if not self.CharacterId or self.CharacterId ~= characterId then + return + end + + self:RefreshInfo(false) +end + +function XUiPanelExpDetail:UpdateExpInfo(characterId) + if not self.CharacterId or self.CharacterId ~= characterId then + return + end + + local characterData = XDataCenter.DormManager.GetCharacterDataByCharId(self.CharacterId) + local moodConfig = XDormConfig.GetMoodStateByMoodValue(characterData.Mood) + + self.ImgCurEnergy.fillAmount = characterData.Mood / XDormConfig.DORM_MOOD_MAX_VALUE + self.ImgCurEnergy.color = XDormConfig.GetMoodStateColor(characterData.Mood) + self.UiRoot:SetUiSprite(self.ImgIcon, moodConfig.Icon) +end + +function XUiPanelExpDetail:UpdateFurnitureInfo(characterId) + local charStyleConfig = XDormConfig.GetCharacterStyleConfigById(characterId) + if not charStyleConfig then + return + end + + local loveTypeConfig = XFurnitureConfigs.GetDormFurnitureType(charStyleConfig.LoveType) + local likeTypeConfig = XFurnitureConfigs.GetDormFurnitureType(charStyleConfig.LikeType) + + self.UiRoot:SetUiSprite(self.ImgLove, loveTypeConfig.TypeIcon) + self.UiRoot:SetUiSprite(self.ImgLike, likeTypeConfig.TypeIcon) + + local curRecoveryConfig, nextRecoveryConfig = XDataCenter.DormManager.GetCharRecoveryConfigs(characterId) + local isMax = curRecoveryConfig == nil and nextRecoveryConfig ~= nil + self.TxtNextDesc.text = isMax and CS.XTextManager.GetText("DormMaxRecovery") or CS.XTextManager.GetText("DormNextRecovery") + + local scoreA, scoreB, scoreC = XDataCenter.DormManager.GetDormitoryScore(self.CurRoomId) + local allFurnitureAttrs = XHomeDormManager.GetFurnitureScoresByUnsaveRoom(self.CurRoomId) + local allScores = allFurnitureAttrs.TotalScore + + local indexA = XFurnitureConfigs.AttrType.AttrA - 1 + local indexB = XFurnitureConfigs.AttrType.AttrB - 1 + local indexC = XFurnitureConfigs.AttrType.AttrC - 1 + + if nextRecoveryConfig then + if nextRecoveryConfig.AttrTotal > 0 then + self.PanelAll.gameObject:SetActive(true) + self.TxtAll.gameObject:SetActive(allScores < nextRecoveryConfig.AttrTotal) + self.TxtAll.text = nextRecoveryConfig.AttrTotal + + self.TxtAllDis.gameObject:SetActive(allScores >= nextRecoveryConfig.AttrTotal) + self.TxtAllDis.text = nextRecoveryConfig.AttrTotal + else + self.PanelAll.gameObject:SetActive(false) + end + + if nextRecoveryConfig.AttrCondition[indexA] > 0 then + self.PanelRed.gameObject:SetActive(true) + self.TxtRed.gameObject:SetActive(scoreA < nextRecoveryConfig.AttrCondition[indexA]) + self.TxtRed.text = nextRecoveryConfig.AttrCondition[indexA] + + self.TxtRedDis.gameObject:SetActive(scoreA >= nextRecoveryConfig.AttrCondition[indexA]) + self.TxtRedDis.text = nextRecoveryConfig.AttrCondition[indexA] + else + self.PanelRed.gameObject:SetActive(false) + end + + if nextRecoveryConfig.AttrCondition[indexB] > 0 then + self.PanelYellow.gameObject:SetActive(true) + self.TxtYellow.gameObject:SetActive(scoreB < nextRecoveryConfig.AttrCondition[indexB]) + self.TxtYellow.text = nextRecoveryConfig.AttrCondition[indexB] + + self.TxtYellowDis.gameObject:SetActive(scoreB >= nextRecoveryConfig.AttrCondition[indexB]) + self.TxtYellowDis.text = nextRecoveryConfig.AttrCondition[indexB] + else + self.PanelYellow.gameObject:SetActive(false) + end + + if nextRecoveryConfig.AttrCondition[indexC] > 0 then + self.PanelBlue.gameObject:SetActive(true) + self.TxtBlue.gameObject:SetActive(scoreC < nextRecoveryConfig.AttrCondition[indexC]) + self.TxtBlue.text = nextRecoveryConfig.AttrCondition[indexC] + + self.TxtBlueDis.gameObject:SetActive(scoreC >= nextRecoveryConfig.AttrCondition[indexC]) + self.TxtBlueDis.text = nextRecoveryConfig.AttrCondition[indexC] + else + self.PanelBlue.gameObject:SetActive(false) + end + end +end + +function XUiPanelExpDetail:UpdateTransform(transform) + local pos = transform.position + self.Offset + local viewPos = XHomeDormManager.GetWorldToViewPoint(self.CurRoomId, pos) + + self.Transform.localPosition = viewPos +end + +function XUiPanelExpDetail:Show(characterId, transform) + self:RemoveTimer() + self.CharacterId = characterId + self.TargetTransform = transform + + local styleConfig = XDormConfig.GetCharacterStyleConfigById(characterId) + self.Offset = CS.UnityEngine.Vector3(0, styleConfig.ExpDetailWidgetHeight, 0) + + self:UpdateTransform(self.TargetTransform) + self:RefreshInfo(self.CharacterId) + self:UpdateExpInfo(self.CharacterId) + self:UpdateFurnitureInfo(self.CharacterId) + self.GameObject:SetActive(true) + + self.Timer = XScheduleManager.ScheduleOnce(function() + if XTool.UObjIsNil(self.Transform) or not self.GameObject.activeSelf then + return + end + + self:Hide() + end, XDormConfig.DISPPEAR_TIME) +end + +function XUiPanelExpDetail:RemoveTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end + +function XUiPanelExpDetail:Hide() + self:RemoveTimer() + self.TargetTransform = nil + self.GameObject:SetActive(false) +end + +function XUiPanelExpDetail:Update() + if not self.GameObject.activeSelf or XTool.UObjIsNil(self.Transform) then + return + end + + if XTool.UObjIsNil(self.TargetTransform) then + return + end + + self:UpdateTransform(self.TargetTransform) +end + +return XUiPanelExpDetail \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormComponent/XUiPanelPutOn.lua b/Resources/Scripts/XUi/XUiDormComponent/XUiPanelPutOn.lua new file mode 100644 index 00000000..1e3ca97b --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormComponent/XUiPanelPutOn.lua @@ -0,0 +1,103 @@ +local XUiPanelPutOn = XClass(XLuaBehaviour, "XUiPanelPutOn") + +function XUiPanelPutOn:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) +end + +function XUiPanelPutOn:InitRoomId(curRoomId) + self.CurRoomId = curRoomId + self:Hide() +end + +function XUiPanelPutOn:PlayAnima() + self.PanelCountdown.gameObject:SetActive(true) + self.ImgPutDown.gameObject:SetActive(false) + self.ImgPutOn.gameObject:SetActive(false) + + self.ImgCountdown.fillAmount = 0 + local time = CS.XGame.ClientConfig:GetFloat("DormPutOnAnimaTime") + self.AnimaTimer = XUiHelper.Tween(time, function(f) + if not self.GameObject.activeSelf or XTool.UObjIsNil(self.Transform) then + return + end + + self.ImgCountdown.fillAmount = f + end) +end + +function XUiPanelPutOn:UpdateTransform(transform) + local pos = transform.position + self.Offset + local viewPos = XHomeDormManager.GetWorldToViewPoint(self.CurRoomId, pos) + + self.Transform.localPosition = viewPos +end + +function XUiPanelPutOn:Show(id, transform, isCharacter) + local hight + + if isCharacter then + local cfg = XDormConfig.GetCharacterStyleConfigById(id) + hight = cfg.PutOnWidgetHight + else + local cfg = XFurnitureConfigs.GetFurnitureTemplateById(id) + hight = cfg.PutOnWidgetHight + end + + self.Offset = CS.UnityEngine.Vector3(0, hight, 0) + self.TargetTransform = transform + self:UpdateTransform(self.TargetTransform) + + self.GameObject:SetActive(true) + self:PlayAnima() +end + +function XUiPanelPutOn:Catch() + self.PanelCountdown.gameObject:SetActive(false) + self.ImgPutDown.gameObject:SetActive(false) + self.ImgPutOn.gameObject:SetActive(false) +end + +function XUiPanelPutOn:Hide() + self.PanelCountdown.gameObject:SetActive(false) + self.ImgPutDown.gameObject:SetActive(false) + self.ImgPutOn.gameObject:SetActive(false) + + XScheduleManager.ScheduleOnce(function() + if not self.GameObject.activeSelf or XTool.UObjIsNil(self.Transform) then + return + end + + self:Close() + end, 100) +end + +function XUiPanelPutOn:Close() + self.PanelCountdown.gameObject:SetActive(false) + self.ImgPutDown.gameObject:SetActive(false) + self.ImgPutOn.gameObject:SetActive(false) + + if self.AnimaTimer ~= nil then + XScheduleManager.UnSchedule(self.AnimaTimer) + self.AnimaTimer = nil + end + + self.TargetTransform = nil + self.GameObject:SetActive(false) +end + +function XUiPanelPutOn:Update() + if not self.GameObject.activeSelf or XTool.UObjIsNil(self.Transform) then + return + end + + if XTool.UObjIsNil(self.TargetTransform) then + return + end + + self:UpdateTransform(self.TargetTransform) +end + +return XUiPanelPutOn \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormComponent/XUiPanelTouch.lua b/Resources/Scripts/XUi/XUiDormComponent/XUiPanelTouch.lua new file mode 100644 index 00000000..7698ca3b --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormComponent/XUiPanelTouch.lua @@ -0,0 +1,75 @@ +local XUiPanelTouch = XClass(nil, "XUiPanelTouch") + +function XUiPanelTouch:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self.Camera = rootUi.Transform:GetComponent("Canvas").worldCamera + XTool.InitUiObject(self) +end + +function XUiPanelTouch:InitRoomId(curRoomId) + self.CurRoomId = curRoomId + self:Hide() +end + +function XUiPanelTouch:RefreshTouchState(touchState) + if touchState == XDormConfig.TouchState.Touch or touchState == XDormConfig.TouchState.TouchHate then + self.ImgTouch.gameObject:SetActive(true) + self.ImgWaterGun.gameObject:SetActive(false) + self.ImgPlay.gameObject:SetActive(false) + elseif touchState == XDormConfig.TouchState.WaterGun then + self.ImgTouch.gameObject:SetActive(false) + self.ImgWaterGun.gameObject:SetActive(true) + self.ImgPlay.gameObject:SetActive(false) + elseif touchState == XDormConfig.TouchState.Play then + self.ImgTouch.gameObject:SetActive(false) + self.ImgWaterGun.gameObject:SetActive(false) + self.ImgPlay.gameObject:SetActive(true) + else + if self.LastState ~= XDormConfig.TouchState.WaterGun then + self.ImgTouch.gameObject:SetActive(false) + self.ImgWaterGun.gameObject:SetActive(false) + self.ImgPlay.gameObject:SetActive(false) + end + end + + self.LastState = touchState +end + +function XUiPanelTouch:UpdateTransform(screenPoint) + if not screenPoint then + return + end + + local screenPointV2 = CS.UnityEngine.Vector2(screenPoint.x, screenPoint.y) + local hasValue, v2 = CS.UnityEngine.RectTransformUtility.ScreenPointToLocalPointInRectangle(self.PanelTouchContainer, screenPointV2, self.Camera) + + if hasValue then + self.Transform.localPosition = CS.UnityEngine.Vector3(v2.x, v2.y, 0) + end +end + +function XUiPanelTouch:Show(characterId, touchState, screenPoint, propNum) + if touchState == XDormConfig.TouchState.Hate then + return + end + + if propNum and propNum > 0 and touchState == XDormConfig.TouchState.Touch then + self.PanelFilled.gameObject:SetActive(true) + self.ImgFilled.fillAmount = propNum + else + self.PanelFilled.gameObject:SetActive(false) + end + + self.CharacterId = characterId + self:UpdateTransform(screenPoint) + self:RefreshTouchState(touchState) + self.GameObject:SetActive(true) +end + +function XUiPanelTouch:Hide() + self.GameObject:SetActive(false) +end + +return XUiPanelTouch \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormFieldGuide/XUiDormFieldGuide.lua b/Resources/Scripts/XUi/XUiDormFieldGuide/XUiDormFieldGuide.lua new file mode 100644 index 00000000..3c5d9caf --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormFieldGuide/XUiDormFieldGuide.lua @@ -0,0 +1,195 @@ +local Object = CS.UnityEngine.Object +local Vector3 = CS.UnityEngine.Vector3 +local V3O = Vector3.one +local XUiDormFieldGuide = XLuaUiManager.Register(XLuaUi, "UiDormFieldGuide") +local XUiDormFieldGuideListItem = require("XUi/XUiDormFieldGuide/XUiDormFieldGuideListItem") +local XUiDormFieldGuideTab = require("XUi/XUiDormFieldGuide/XUiDormFieldGuideTab") + +local TextManager = CS.XTextManager +local Next = next + +function XUiDormFieldGuide:OnAwake() + XTool.InitUiObject(self) + self.TabDicIndex = {} + self.TabObs = {} + self.TabObs[1] = self.BtnTab1 + self:InitUI() +end + +function XUiDormFieldGuide:OnStart(suitId) + self.HaveFurIds = XDataCenter.DormManager.FurnitureUnlockList or {} + self.FileGuideData = XFurnitureConfigs.GetFieldGuideDatas() + self:InitEnterCfg() + local id = suitId + if not suitId and self.TabTypeCfg[1] then + id = self.TabTypeCfg[1].Id + end + local index = 1 + if id and self.TabDicIndex[id] then + index = self.TabDicIndex[id] + end + self.Tabgroup:SelectIndex(index) + self:CenterToGrid(index) +end + +function XUiDormFieldGuide:CenterToGrid(index) + local normalizedPosition + local count = self.ScrollView.content.transform.childCount + if index > count / 2 then + normalizedPosition = (index + 1) / count + else + normalizedPosition = (index - 1) / count + end + + self.ScrollView.verticalNormalizedPosition = math.max(0, math.min(1, (1 - normalizedPosition))) +end + +function XUiDormFieldGuide:InitEnterCfg() + self.TabTypeCfg = {} + + local cfg = XFurnitureConfigs.GetFurnitureSuitTemplates() + for k, v in pairs(cfg) do + if self.FileGuideData[k] then + table.insert(self.TabTypeCfg, v) + end + end + + self:CreateTypeItems(self.TabTypeCfg) +end + +function XUiDormFieldGuide:CreateTypeItems(tabTypeCfg) + if self.PanelTab then + local index = 1 + for k, v in pairs(tabTypeCfg) do + local obj = self.TabObs[k] + if not obj then + obj = Object.Instantiate(self.BtnTab1) + obj.transform:SetParent(self.PanelTab.transform, false) + obj.transform.localScale = V3O + table.insert(self.TabObs, obj) + end + self.TabDicIndex[v.Id] = index + index = index + 1 + obj.gameObject:SetActive(true) + + local uiTab = XUiDormFieldGuideTab.New(obj) + uiTab:SetName(v.SuitName) + local suitBgmInfo = XDormConfig.GetDormSuitBgmInfo(v.Id) + uiTab:SetSuitBgm(suitBgmInfo) + end + + self.Tabgroup = self.PanelTab:GetComponent("XUiButtonGroup") + self.Tabgroup:Init(self.TabObs, function(tab) self:TabSkip(tab) end) + end +end + +function XUiDormFieldGuide:TabSkip(tab) + if tab == self.PreSeleTab then + return + end + + self.PreSeleTab = tab + local cfg = self.TabTypeCfg[tab] + self:OnClickEnterSetListData(cfg.Id) + self:PlayAnimation("QieHuan") + local suitBgmInfo = XDormConfig.GetDormSuitBgmInfo(cfg.Id) + + self.MusicText.gameObject:SetActiveEx(suitBgmInfo ~= nil) + if suitBgmInfo then + self.MusicText.text = string.format(CS.XGame.ClientConfig:GetString("DormSuitBgmDesc"), suitBgmInfo.SuitNum, ",", suitBgmInfo.Name) + end +end + +function XUiDormFieldGuide:InitList() + self.DynamicTable = XDynamicTableNormal.New(self.PanelItemCommon.gameObject) + self.DynamicTable:SetProxy(XUiDormFieldGuideListItem) + self.DynamicTable:SetDelegate(self) +end + +-- [监听动态列表事件] +function XUiDormFieldGuide:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.ListData[index] + grid:OnRefresh(data, self.HaveFurIds) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + local data = self.ListData[index] + XLuaUiManager.Open("UiDormFieldGuideDes", data) + end +end + +function XUiDormFieldGuide:OnClickEnterSetListData(t) + if not t then + return + end + + if t == self.PreSeleId then + return + end + + self.PreSeleId = t + local data = self.FileGuideData[t] or {} + if Next(data) ~= nil then + table.sort(data, function(a, b) return self:Fielguildsortfun(a, b) end) + end + self:SetMaterials(data) + self.ListData = data + self.DynamicTable:SetDataSource(data) + self.DynamicTable:ReloadDataASync(1) +end + +function XUiDormFieldGuide:SetMaterials(data) + local totalcount = 0 + local havecount = 0 + local f = false + for _, v in pairs(data) do + totalcount = totalcount + 1 + if not f and self.HaveFurIds[v.Id] then + havecount = havecount + 1 + else + f = true + end + end + + if havecount ~= self.CurHaveCount or totalcount ~= self.CurTotalCount then + self.CurHaveCount = havecount + self.CurTotalCount = totalcount + self.TxtMaterials.text = TextManager.GetText("DormFieldGuildeCountText", havecount, totalcount) + end + +end + +function XUiDormFieldGuide:Fielguildsortfun(a, b) + if self.HaveFurIds[a.Id] and not self.HaveFurIds[b.Id] then + return true + end + + if not self.HaveFurIds[a.Id] and self.HaveFurIds[b.Id] then + return false + end + + return a.Id > b.Id +end + +function XUiDormFieldGuide:InitUI() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.DormCoin, XDataCenter.ItemManager.ItemId.FurnitureCoin) + self:InitList() + self:AddListener() +end + +function XUiDormFieldGuide:AddListener() + self.OnBtnMainUIClickCb = function() self:OnBtnMainUIClick() end + self.OnBtnReturnClickCb = function() self:OnBtnReturnClick() end + self.OnBtnHelpClickCb = function() self:OnBtnHelpClick() end + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUIClickCb) + self:RegisterClickEvent(self.BtnBack, self.OnBtnReturnClickCb) +end + +function XUiDormFieldGuide:OnBtnMainUIClick() + XLuaUiManager.RunMain() +end + +function XUiDormFieldGuide:OnBtnReturnClick() + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormFieldGuide/XUiDormFieldGuideDes.lua b/Resources/Scripts/XUi/XUiDormFieldGuide/XUiDormFieldGuideDes.lua new file mode 100644 index 00000000..1940b2c6 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormFieldGuide/XUiDormFieldGuideDes.lua @@ -0,0 +1,76 @@ +local XUiDormFieldGuideDesListItem = require("XUi/XUiDormFieldGuide/XUiDormFieldGuideDesListItem") +local XUiDormFieldGuideDes = XLuaUiManager.Register(XLuaUi, "UiDormFieldGuideDes") + +function XUiDormFieldGuideDes:OnAwake() + self:AddListener() + self:InitList() +end + +function XUiDormFieldGuideDes:AddListener() + self:RegisterClickEvent(self.BtnTanchuangClose, self.OnBtnClick) +end + +function XUiDormFieldGuideDes:OnBtnClick() + self:PlayAnimation("PanelDesDisable", function() + self:Close() + end) +end + +-- 更新数据 +function XUiDormFieldGuideDes:OnStart(furnitureCfg) + if not furnitureCfg then + return + end + self:PlayAnimation("PanelDesEnable") + self.TxtName.text = furnitureCfg.Name or "" + self.TxtSuit.text = XFurnitureConfigs.GetFurnitureSuitName(furnitureCfg.SuitId) or "" + self.TxtDes.text = furnitureCfg.Desc or "" + local iconpath = furnitureCfg.Icon + if iconpath then + self:SetUiSprite(self.ImgIcon, iconpath) + end + + local randomGroupId = furnitureCfg.RandomGroupId + if self.PrerandomGroupId ~= randomGroupId then + self.PrerandomGroupId = randomGroupId + local d = XFurnitureConfigs.GetGroupRandomIntroduce(randomGroupId, true) or {} + + local listdata = {} + + if furnitureCfg.SuitId > 0 then + local suitBgmInfo = XDormConfig.GetDormSuitBgmInfo(furnitureCfg.SuitId) + if suitBgmInfo then + table.insert(listdata, CS.XGame.ClientConfig:GetString("DormSuitBgmTitleDesc")) + local suitDesc = string.format(CS.XGame.ClientConfig:GetString("DormSuitBgmDesc"), suitBgmInfo.SuitNum, ",", suitBgmInfo.Name) + table.insert(listdata, suitDesc) + end + end + + for k1, v1 in pairs(d) do + table.insert(listdata, k1) + for _, v2 in pairs(v1) do + table.insert(listdata, v2.Introduce) + end + end + + self.ListData = listdata + self.DynamicTable:SetDataSource(listdata) + self.DynamicTable:ReloadDataASync(1) + end +end + +function XUiDormFieldGuideDes:InitList() + self.DynamicTable = XDynamicTableNormal.New(self.PanelDesList) + self.DynamicTable:SetProxy(XUiDormFieldGuideDesListItem) + self.DynamicTable:SetDelegate(self) +end + +-- [监听动态列表事件] +function XUiDormFieldGuideDes:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.ListData[index] + grid:OnRefresh(data) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormFieldGuide/XUiDormFieldGuideDesListItem.lua b/Resources/Scripts/XUi/XUiDormFieldGuide/XUiDormFieldGuideDesListItem.lua new file mode 100644 index 00000000..cd664da7 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormFieldGuide/XUiDormFieldGuideDesListItem.lua @@ -0,0 +1,22 @@ +local XUiDormFieldGuideDesListItem = XClass(nil, "XUiDormFieldGuideDesListItem") + +function XUiDormFieldGuideDesListItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiDormFieldGuideDesListItem:Init(parent) + self.Parent = parent +end + +-- 更新数据 +function XUiDormFieldGuideDesListItem:OnRefresh(itemData) + if not itemData then + return + end + + self.TxtDes.text = itemData +end + +return XUiDormFieldGuideDesListItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormFieldGuide/XUiDormFieldGuideGridItem.lua b/Resources/Scripts/XUi/XUiDormFieldGuide/XUiDormFieldGuideGridItem.lua new file mode 100644 index 00000000..1bd7eee8 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormFieldGuide/XUiDormFieldGuideGridItem.lua @@ -0,0 +1,40 @@ +local XUiDormFieldGuideGridItem = XClass(nil, "XUiDormFieldGuideGridItem") + +function XUiDormFieldGuideGridItem:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + self.Btnclickcb = function() self:OnBtnClick() end + XTool.InitUiObject(self) + self.UiRoot:RegisterClickEvent(self.Transform, self.Btnclickcb) +end + + +function XUiDormFieldGuideGridItem:OnBtnClick() + if not self.ItemData then + return + end + + self.UiRoot:OpenDesUI(self.ItemData) +end + +-- 更新数据 +function XUiDormFieldGuideGridItem:OnRefresh(itemData) + if not itemData then + return + end + + self.ItemData = itemData + + local curState = XDataCenter.FurnitureManager.IsFieldGuideHave(itemData.Id) + self.ItemNotGet.gameObject:SetActive(not curState) + + local iconpath = itemData.Icon + if iconpath then + self.UiRoot:SetUiSprite(self.ImgIcon, iconpath) + end + + self.TxtName.text = itemData.Name +end + +return XUiDormFieldGuideGridItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormFieldGuide/XUiDormFieldGuideListItem.lua b/Resources/Scripts/XUi/XUiDormFieldGuide/XUiDormFieldGuideListItem.lua new file mode 100644 index 00000000..7a279166 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormFieldGuide/XUiDormFieldGuideListItem.lua @@ -0,0 +1,37 @@ +local XUiDormFieldGuideListItem = XClass(nil, "XUiDormFieldGuideListItem") + +function XUiDormFieldGuideListItem:Ctor(ui) + self.ObjItems = {} + self.CurItems = {} + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiDormFieldGuideListItem:UpdateItems(itemData, haveids) + local curState = haveids[itemData.Id] ~= nil + self.ItemNotGet.gameObject:SetActive(not curState) + + local iconpath = itemData.Icon + if iconpath then + self.UiRoot:SetUiSprite(self.ImgIcon, iconpath) + end + + self.TxtName.text = itemData.Name +end + + +function XUiDormFieldGuideListItem:Init(uiRoot) + self.UiRoot = uiRoot +end + +-- 更新数据 +function XUiDormFieldGuideListItem:OnRefresh(itemData, haveids) + if not itemData then + return + end + + self:UpdateItems(itemData, haveids) +end + +return XUiDormFieldGuideListItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormFieldGuide/XUiDormFieldGuideSeleItem.lua b/Resources/Scripts/XUi/XUiDormFieldGuide/XUiDormFieldGuideSeleItem.lua new file mode 100644 index 00000000..590e35c1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormFieldGuide/XUiDormFieldGuideSeleItem.lua @@ -0,0 +1,51 @@ +local XUiDormFieldGuideSeleItem = XClass(nil, "XUiDormFieldGuideSeleItem") +local TabState = { + Normal = 0, + Press = 1, + Select = 2, + Disable = 3, +} + +function XUiDormFieldGuideSeleItem:Ctor(ui, uiRoot) + self.PoolObjs = {} + self.CurObjs = {} + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + self.OnEnterClickCb = function() self:OnClickEnterSetListData() end + self.UiRoot:RegisterClickEvent(self.Transform, self.OnEnterClickCb) + self.XUiBtn = self.Transform:GetComponent(typeof(CS.XUiComponent.XUiButton)) +end + +function XUiDormFieldGuideSeleItem:OnClickEnterSetListData() + if not self.UiRoot or not self.ItemData then + return + end + + self.UiRoot:OnClickEnterSetListData(self.ItemData.Id) +end + +-- 更新数据 +function XUiDormFieldGuideSeleItem:OnRefresh(itemData) + if not itemData then + return + end + + self.ItemData = itemData + local name = itemData.SuitName or "" + self.XUiBtn:SetName(name) +end + +-- 设置状态 +function XUiDormFieldGuideSeleItem:SetState(state) + if self.CurState ~= state then + self.CurState = state + if not state then + self.XUiBtn:SetButtonState(TabState.Select) + else + self.XUiBtn:SetButtonState(TabState.Normal) + end + end +end + +return XUiDormFieldGuideSeleItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormFieldGuide/XUiDormFieldGuideTab.lua b/Resources/Scripts/XUi/XUiDormFieldGuide/XUiDormFieldGuideTab.lua new file mode 100644 index 00000000..3e8ac32d --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormFieldGuide/XUiDormFieldGuideTab.lua @@ -0,0 +1,21 @@ +local XUiDormFieldGuideTab = XClass(nil, "XUiDormFieldGuideTab") + +function XUiDormFieldGuideTab:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiDormFieldGuideTab:SetName(name) + self.BtnTab:SetName(name) +end + + +function XUiDormFieldGuideTab:SetSuitBgm(bgm) + self.ImgSongNormal.gameObject:SetActiveEx(bgm ~= nil) + self.ImgSongPress.gameObject:SetActiveEx(bgm ~= nil) + self.ImgSongSelect.gameObject:SetActiveEx(bgm ~= nil) + self.ImgSongDisable.gameObject:SetActiveEx(bgm ~= nil) +end + +return XUiDormFieldGuideTab \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormMain/XUiDormMain.lua b/Resources/Scripts/XUi/XUiDormMain/XUiDormMain.lua new file mode 100644 index 00000000..44827416 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormMain/XUiDormMain.lua @@ -0,0 +1,370 @@ +local XUiDormMain = XLuaUiManager.Register(XLuaUi, "UiDormMain") +local XUiDormMainItem = require("XUi/XUiDormMain/XUiDormMainItem") +local TextManager = CS.XTextManager + +local DormDrawGroudId +local White = "#ffffff" +local Blue = "#34AFF8" + +function XUiDormMain:OnAwake() + self.DormItems = {} + self.Roomsputup = {} + DormDrawGroudId = CS.XGame.ClientConfig:GetInt("DormDrawGroudId") + self.DisplaySetType = XDormConfig.VisitDisplaySetType + self.DormActiveState = XDormConfig.DormActiveState + self.SenceId = XDormConfig.SenceType.One + XTool.InitUiObject(self) + self:InitFun() + self:InitEnter() + self:InitUI() +end + +function XUiDormMain:InitFun() + self.DormActiveRespCB = function() self:SetDormMainItem() end + self.DormCharEventCB = function(dormId) self:CharEventChange(dormId) end + self.OnBtnTaskTipsClickCb = function() self:OnBtnTaskTipsClick() end + self:BindHelpBtn(self.BtnHelp, "Dorm") + self.BtnTemplate.CallBack = function() self:OnBtnTemplateClick() end + self.BtnTabOne.CallBack = function() self:OnBtnTabOneClick() end + self.BtnTabTow.CallBack = function() self:OnBtnTabTowClick() end +end + +function XUiDormMain:InitEnter() + self:RegisterClickEvent(self.BtnWork, function() self:OpenWork() end) + self:RegisterClickEvent(self.BtnPerson, function() self:SetPersonList() end) + self:RegisterClickEvent(self.BtnTask, self.OnBtnTaskClick) + self:RegisterClickEvent(self.BtnShop, function() self:OpenShopUI() end) + self:RegisterClickEvent(self.BtnBuild, function() self:OpenBuildUI() end) + self:RegisterClickEvent(self.BtnWareHouse, function() self:OpenWareHpuseUI() end) + self.BtnWork:SetName(TextManager.GetText("DormWorkText")) + self.BtnPerson:SetName(TextManager.GetText("DormPersonText")) + self.BtnTask:SetName(TextManager.GetText("DormTaskText")) + self.BtnShop:SetName(TextManager.GetText("DormShopText")) + self.BtnWareHouse:SetName(TextManager.GetText("DormWareHouseText")) + self.BtnBuild:SetName(TextManager.GetText("DormBuidText")) +end + +-- 跳到仓库 +function XUiDormMain:OpenWareHpuseUI() + XLuaUiManager.Open("UiDormBag") + self.IsStatic = true +end + +-- 跳到建造 +function XUiDormMain:OpenBuildUI() + XLuaUiManager.Open("UiFurnitureBuild") + self.IsStatic = true +end + +function XUiDormMain:CharEventChange(dormId) + if self.DormItems[dormId] then + self.DormItems[dormId]:SetEvenIconState(true) + end +end + +-- 跳到商店 +function XUiDormMain:OpenShopUI() + XLuaUiManager.Open("UiShop", XShopManager.ShopType.Dorm) + self.IsStatic = true +end + +-- 跳到抽卡 +function XUiDormMain:OpenDrawUI() + -- 没有开启 + local isOpen = XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.DrawCard) + if not isOpen then + XUiManager.TipText("DormDrawNoOpenTips") + return + end + + XDataCenter.DrawManager.GetDrawGroupList( + function() + local info = XDataCenter.DrawManager.GetDrawGroupInfoByGroupId(DormDrawGroudId) + XDataCenter.DrawManager.GetDrawInfoList(DormDrawGroudId, function() + XLuaUiManager.Open("UiDraw", DormDrawGroudId, function() + XHomeSceneManager.ResetToCurrentGlobalIllumination() + end, info.UiBackGround) + end) + end + ) + self.IsStatic = true +end + +-- 跳到任务 +function XUiDormMain:OnBtnTaskTipsClick() + if self.CurTaskData and not self.CurTaskTagState then + self:OnTaskSkip() + return + end + + local tab + if self.CurTaskTagState then + if self.TaskType == XDataCenter.TaskManager.TaskType.DormNormal then + tab = XTaskConfig.PANELINDEX.Story + else + tab = XTaskConfig.PANELINDEX.Daily + end + end + self:OnOpenTask(tab) +end + +function XUiDormMain:OnBtnTemplateClick() + XLuaUiManager.Open("UiDormTemplate") +end + +function XUiDormMain:OnOpenTask(tab) + XLuaUiManager.Open("UiDormTask", tab) + self.IsStatic = true +end + +function XUiDormMain:OnBtnTaskClick() + self:OnOpenTask() +end + +function XUiDormMain:OnTaskSkip() + if XDataCenter.RoomManager.RoomData ~= nil then + local title = CS.XTextManager.GetText("TipTitle") + local cancelMatchMsg = CS.XTextManager.GetText("OnlineInstanceQuitRoom") + XUiManager.DialogTip(title, cancelMatchMsg, XUiManager.DialogType.Normal, nil, function() + XLuaUiManager.RunMain() + local skipId = XDataCenter.TaskManager.GetTaskTemplate(self.CurTaskData.Id).SkipId + XFunctionManager.SkipInterface(skipId) + end) + else + local skipId = XDataCenter.TaskManager.GetTaskTemplate(self.CurTaskData.Id).SkipId + XFunctionManager.SkipInterface(skipId) + end +end + +-- 跳到打工 +function XUiDormMain:OpenWork() + XLuaUiManager.Open("UiDormWork") + self.IsStatic = true +end + +-- 设置人员list +function XUiDormMain:SetPersonList() + XLuaUiManager.Open("UiDormPerson") + self.IsStatic = true +end + +-- [监听动态列表事件] +function XUiDormMain:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.ListData[index] + grid:OnRefresh(data) + end +end + +function XUiDormMain:SetSelectState(state) + if not self.PanelSelect then + return + end + + self.PanelSelect.gameObject:SetActiveEx(state) +end + +function XUiDormMain:OnStart() + XLuaUiManager.Close("UiLoading") +end + +function XUiDormMain:CreateDormMainItems() + --已经拥有的宿舍 + local dormDatas = XDataCenter.DormManager.GetDormitoryData() + for dormId, v in pairs(dormDatas) do + if v:WhetherRoomUnlock() then + if not self.DormItems[dormId] then + local item = self:GetItem(dormId) + self.DormItems[dormId] = item + end + self.DormItems[dormId].GameObject:SetActiveEx(true) + self.DormItems[dormId]:OnRefresh(v, self.DormActiveState.Active) + self.DormItems[dormId]:SetEvenIconState(XDataCenter.DormManager.IsHaveDormCharactersEvent(dormId)) + end + end +end + +function XUiDormMain:GetItem(dormId) + local obj = self:GetDormItemPos(dormId) + local item = XUiDormMainItem.New(obj, self) + return item +end + +function XUiDormMain:GetDormItemPos(id) + return self.Roomsputup[id] +end + +function XUiDormMain:OnEnable() + self.BtnPanelTask.CallBack = self.OnBtnTaskTipsClickCb + self:OnPlayAnimation() + XDataCenter.DormManager.StartDormRedTimer() + self.BtnWork:ShowReddot(XDataCenter.DormManager.DormWorkRedFun()) + self.BtnBuild:ShowReddot(XDataCenter.FurnitureManager.HasCollectableFurniture()) + local redPointTypes = XRedPointConditions.Types + XRedPointManager.AddRedPointEvent(self.BtnTask.ReddotObj, self.RefreshTaskTabRedDot, self, { redPointTypes.CONDITION_DORM_MAIN_TASK_RED }) + XRedPointManager.AddRedPointEvent(self.BtnBuild.ReddotObj, self.OnCheckBuildFurniture, self, { redPointTypes.CONDITION_FURNITURE_CREATE }) + + XEventManager.AddEventListener(XEventId.EVENT_CHARACTER_DORMMAIN_EVENT_NOTIFY, self.DormCharEventCB) + XEventManager.AddEventListener(XEventId.EVENT_DORM_ROOM_ACTIVE_SUCCESS, self.DormActiveRespCB, self) + local data, tasktype, state = XDataCenter.TaskManager.GetDormTaskTips() + if data and tasktype and state then + self.CurTaskData = data + self.TaskType = tasktype + self.PanelTask.gameObject:SetActiveEx(true) + local config = XDataCenter.TaskManager.GetTaskTemplate(data.Id) + self.CurTaskTagState = state == XDataCenter.TaskManager.TaskState.Achieved + if self.CurTaskTagState then + self.BtnPanelTask:SetName(string.format("%s", Blue, config.Desc)) + else + self.BtnPanelTask:SetName(string.format("%s", White, config.Desc)) + end + self.BtnPanelTask:ShowTag(not self.CurTaskTagState) + self.BtnPanelTask:ShowReddot(self.CurTaskTagState) + else + self.CurTaskData = nil + self.PanelTask.gameObject:SetActiveEx(false) + end +end + +function XUiDormMain:RefreshTaskTabRedDot(count) + self.BtnTask:ShowReddot(count >= 0) +end + +function XUiDormMain:OnCheckBuildFurniture(count) + self.BtnBuild:ShowReddot(count >= 0) +end + +function XUiDormMain:OnPlayAnimation() + local delay = XDormConfig.DormAnimationMoveTime + if self.IsStatic then + self.IsStatic = false + delay = XDormConfig.DormAnimationStaicTime + end + + self:InitSpcaeBtn() + if delay > 0 then + self.IsFirstAnimation = true + self.SafeAreaContentPane.gameObject:SetActiveEx(false) + self.DormMainLookTimer = XScheduleManager.ScheduleOnce(function() + self.SafeAreaContentPane.gameObject:SetActiveEx(true) + self:PlayAnimation("AnimStartEnable") + self:PlayAnimation("BgEnable") + self:PlayAnimation("LeftTapGroupEnable") + self:SetDormMainItem() + XScheduleManager.UnSchedule(self.DormMainLookTimer) + end, delay) + else + self:SetDormMainItem() + self:PlayAnimation("AnimStartEnable") + self:PlayAnimation("BgEnable") + self:PlayAnimation("LeftTapGroupEnable") + end +end + +function XUiDormMain:SetDormMainItem() + self:CreateDormMainItems() +end + +function XUiDormMain:OnDisable() + self.BtnPanelTask.CallBack = nil + XEventManager.RemoveEventListener(XEventId.EVENT_CHARACTER_DORMMAIN_EVENT_NOTIFY, self.DormCharEventCB) + XEventManager.RemoveEventListener(XEventId.EVENT_DORM_ROOM_ACTIVE_SUCCESS, self.DormActiveRespCB, self) + if self.DormMainLookTimer then + XScheduleManager.UnSchedule(self.DormMainLookTimer) + self.DormMainLookTimer = nil + end + + -- 进入房间应该隐藏Hud + for _, v in pairs(self.DormItems) do + v.GameObject:SetActiveEx(false) + v:SetEvenIconState(false) + end + XDataCenter.DormManager.StopDormRedTimer() +end + +function XUiDormMain:OnDestroy() + XHomeSceneManager.LeaveScene() + XEventManager.DispatchEvent(XEventId.EVENT_DORM_HIDE_COMPONET) +end + +function XUiDormMain:InitUI() + local itemId = XDataCenter.ItemManager.ItemId + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, itemId.DormCoin, itemId.FurnitureCoin, itemId.DormEnterIcon) + self:AddListener() + local cfg = XDormConfig.GetTotalDormitoryCfg() + local i = 1 + for _, v in pairs(cfg) do + self.Roomsputup[v.Id] = self["DormlMainItem" .. v.InitNumber] + i = i + 1 + end +end + +function XUiDormMain:AddListener() + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUIClick) + self:RegisterClickEvent(self.BtnBack, self.OnBtnReturnClick) +end + +function XUiDormMain:OnBtnMainUIClick() + XDataCenter.DormManager.RequestDormitoryExit() + XEventManager.DispatchEvent(XEventId.EVENT_DORM_CLOSE_COMPONET) + XLuaUiManager.RunMain() +end + +function XUiDormMain:OnBtnReturnClick() + XDataCenter.DormManager.RequestDormitoryExit() + XEventManager.DispatchEvent(XEventId.EVENT_DORM_CLOSE_COMPONET) + self:Close() +end + +-- 处理空间站选择 +function XUiDormMain:OnBtnTabOneClick() + if self.SenceId == XDormConfig.SenceType.One then + self.BtnTabOne:SetButtonState(CS.UiButtonState.Select) + return + end + self.SenceId = XDormConfig.SenceType.One + self.PanelScene1.gameObject:SetActiveEx(false) + self.PanelScene2.gameObject:SetActiveEx(false) + self.BtnTabOne:SetButtonState(CS.UiButtonState.Select) + self.BtnTabTow:SetButtonState(CS.UiButtonState.Normal) + + XHomeSceneManager.ChangeSceneView(self.SenceId, function() + self.PanelScene1.gameObject:SetActiveEx(true) + self.PanelScene2.gameObject:SetActiveEx(false) + + self:OnPlayAnimation() + end) +end + +function XUiDormMain:OnBtnTabTowClick() + if self.SenceId == XDormConfig.SenceType.Tow then + self.BtnTabTow:SetButtonState(CS.UiButtonState.Select) + return + end + self.SenceId = XDormConfig.SenceType.Tow + self.PanelScene1.gameObject:SetActiveEx(false) + self.PanelScene2.gameObject:SetActiveEx(false) + self.BtnTabOne:SetButtonState(CS.UiButtonState.Normal) + self.BtnTabTow:SetButtonState(CS.UiButtonState.Select) + + XHomeSceneManager.ChangeSceneView(self.SenceId, function() + self.PanelScene1.gameObject:SetActiveEx(false) + self.PanelScene2.gameObject:SetActiveEx(true) + + self:OnPlayAnimation() + end) + +end + +function XUiDormMain:InitSpcaeBtn() + if self.IsFirstAnimation then + return + end + + self.PanelScene1.gameObject:SetActiveEx(self.SenceId == XDormConfig.SenceType.One) + self.PanelScene2.gameObject:SetActiveEx(self.SenceId == XDormConfig.SenceType.Tow) + self.BtnTabOne:SetButtonState(CS.UiButtonState.Select) + self.BtnTabTow:SetButtonState(CS.UiButtonState.Normal) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormMain/XUiDormMainAttItem.lua b/Resources/Scripts/XUi/XUiDormMain/XUiDormMainAttItem.lua new file mode 100644 index 00000000..754d2279 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormMain/XUiDormMainAttItem.lua @@ -0,0 +1,20 @@ +local XUiDormMainAttItem = XClass(nil, "XUiDormMainAttItem") + +function XUiDormMainAttItem:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + XTool.InitUiObject(self) +end + +-- 更新数据 +function XUiDormMainAttItem:OnRefresh(itemdata) + if not itemdata then + return + end + + self.UiRoot:SetUiSprite(self.ImgDes, itemdata[1]) + self.TxtNum.text = itemdata[2] +end + +return XUiDormMainAttItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormMain/XUiDormMainItem.lua b/Resources/Scripts/XUi/XUiDormMain/XUiDormMainItem.lua new file mode 100644 index 00000000..80f67e3b --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormMain/XUiDormMainItem.lua @@ -0,0 +1,115 @@ +local XUiDormMainItem = XClass(nil, "XUiDormMainItem") +local TextManager = CS.XTextManager +local DormMaxCount = 3 +local Next = next + +function XUiDormMainItem:Ctor(ui, uiRoot) + + self.CurState = false + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + XTool.InitUiObject(self) + + self.ImgDormlMainIcons = {} + self.ImgDormlMainIcons[1] = self.ImgDormlMainIcon0 + self.ImgDormlMainIcons[2] = self.ImgDormlMainIcon1 + self.ImgDormlMainIcons[3] = self.ImgDormlMainIcon2 + + self.ImgHeads = {} + self.ImgHeads[1] = self.Head0 + self.ImgHeads[2] = self.Head1 + self.ImgHeads[3] = self.Head2 + + self.ImgHeadsMask = {} + self.ImgHeadsMask[1] = self.HeadMask0 + self.ImgHeadsMask[2] = self.HeadMask1 + self.ImgHeadsMask[3] = self.HeadMask2 + +end + +-- 更新数据 +function XUiDormMainItem:OnRefresh(itemdata, state) + if not itemdata then + return + end + + self.CurDormState = state + self.ItemData = itemdata + self.HudEnable:Play() + local gender = XDormConfig.DormCharGender.Max + if state == XDormConfig.DormActiveState.Active then + self.CurDormId = self.ItemData:GetRoomId() + self.Attdatas = XDataCenter.DormManager.GetDormitoryScoreIcons(self.CurDormId) + local maxatt = self.Attdatas[1] + self.UiRoot:SetUiSprite(self.ImgDes, maxatt[1]) + self.TxtNum.text = TextManager.GetText(XDormConfig.DormAttDesIndex[maxatt[3]], maxatt[2] or 0) + self.DormName = itemdata:GetRoomName() + self.TxtName.text = self.DormName + + local characters = self.ItemData:GetCharacter() or {} + if Next(characters) == nil then + self.IconsList.gameObject:SetActive(false) + self.DormManIcon.gameObject:SetActiveEx(false) + self.DormWomanIcon.gameObject:SetActiveEx(false) + return + end + + self.IconsList.gameObject:SetActive(true) + for i = 1, DormMaxCount do + local d = characters[i] + if d then + local g = XDormConfig.DormCharSexTypeToGender(XDormConfig.GetCharacterStyleConfigSexById(d.CharacterId)) + if gender ~= g then + if gender == XDormConfig.DormCharGender.Max then + gender = g + elseif gender ~= XDormConfig.DormCharGender.None then + gender = XDormConfig.DormCharGender.None + end + end + + local path = XDormConfig.GetCharacterStyleConfigQIconById(d.CharacterId) + local img = self.ImgDormlMainIcons[i] + local headgo = self.ImgHeads[i] + headgo.gameObject:SetActive(true) + img.gameObject:SetActive(true) + img:SetRawImage(path, nil, true) + local isworking = XDataCenter.DormManager.IsWorking(d.CharacterId) + self.ImgHeadsMask[i].gameObject:SetActive(isworking) + else + local headgo = self.ImgHeads[i] + headgo.gameObject:SetActive(false) + local img = self.ImgDormlMainIcons[i] + img.gameObject:SetActive(false) + self.ImgHeadsMask[i].gameObject:SetActive(false) + end + end + end + + if gender == XDormConfig.DormCharGender.Male then + self.DormManIcon.gameObject:SetActiveEx(true) + self.DormWomanIcon.gameObject:SetActiveEx(false) + self.DormGanIcon.gameObject:SetActiveEx(false) + elseif gender == XDormConfig.DormCharGender.Female then + self.DormManIcon.gameObject:SetActiveEx(false) + self.DormWomanIcon.gameObject:SetActiveEx(true) + self.DormGanIcon.gameObject:SetActiveEx(false) + elseif gender == XDormConfig.DormCharGender.Gan then + self.DormManIcon.gameObject:SetActiveEx(false) + self.DormWomanIcon.gameObject:SetActiveEx(false) + self.DormGanIcon.gameObject:SetActiveEx(true) + else + self.DormManIcon.gameObject:SetActiveEx(false) + self.DormWomanIcon.gameObject:SetActiveEx(false) + self.DormGanIcon.gameObject:SetActiveEx(false) + end +end + +function XUiDormMainItem:SetEvenIconState(state) + if self.CurState ~= state then + self.CurState = state + self.EventIcon.gameObject:SetActive(state) + end +end + +return XUiDormMainItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormPerson/XUiDormPerson.lua b/Resources/Scripts/XUi/XUiDormPerson/XUiDormPerson.lua new file mode 100644 index 00000000..d0d20c82 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormPerson/XUiDormPerson.lua @@ -0,0 +1,112 @@ +local Next = next +local XUiDormPerson = XLuaUiManager.Register(XLuaUi, "UiDormPerson") +local XUiDormPersonListItem = require("XUi/XUiDormPerson/XUiDormPersonListItem") +local XUiDormPersonSelect = require("XUi/XUiDormPerson/XUiDormPersonSelect") + +function XUiDormPerson:OnAwake() + XTool.InitUiObject(self) + self:InitUI() + self:InitList() +end + +function XUiDormPerson:InitList() + self.DynamicPersonTable = XDynamicTableNormal.New(self.PersonList) + self.DynamicPersonTable:SetProxy(XUiDormPersonListItem) + self.DynamicPersonTable:SetDelegate(self) +end + +-- 设置人员list +local personlistsortfun = function(a, b) + return a.DormitoryId < b.DormitoryId +end + +function XUiDormPerson:SetPersonList() + local data = {} + local dormdatas = XDataCenter.DormManager.GetDormitoryData() + if Next(dormdatas) == nil then + data[1] = { + DormitoryId = -1, + DormitoryName = "", + CharacterIdList = { + [1] = -1, + }, + } + else + for _, v in pairs(dormdatas) do + if v:WhetherRoomUnlock() then + local singledorm = v + local ids = {} + local list = singledorm:GetCharacter() + for _, var in ipairs(list) do + table.insert(ids, var.CharacterId) + end + table.insert(data, { + DormitoryId = singledorm:GetRoomId(), + DormitoryName = singledorm:GetRoomName(), + CharacterIdList = ids, + }) + end + end + end + table.sort(data, personlistsortfun) + self.ListData = data +end + +function XUiDormPerson:UpdatePersonList() + self:SetPersonList() + if self.ListData and Next(self.ListData) then + for index, itemData in pairs(self.ListData) do + local item = self.DynamicPersonTable:GetGridByIndex(index) + if item then + item:OnRefresh(itemData, self.CurDormId) + end + end + end +end + +function XUiDormPerson:InitPersonList() + self:SetPersonList() + self.DynamicPersonTable:SetDataSource(self.ListData) + self.DynamicPersonTable:ReloadDataASync(1) +end + +function XUiDormPerson:SetSelectList(dormId) + self.SelePanel:SetList(dormId) + self.SelePanel.GameObject:SetActive(true) + self:PlayAnimation("SelectEnable") +end + +-- [监听动态列表事件] +function XUiDormPerson:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.ListData[index] + grid:OnRefresh(data, self.CurDormId) + end +end + +function XUiDormPerson:OnStart(curdormId) + self.CurDormId = curdormId + self:InitPersonList() +end + +function XUiDormPerson:OnEnable() + self:PlayAnimation("AnimStartEnable", function() + self.AnimGo.extrapolationMode = 2 + end) +end + +function XUiDormPerson:InitUI() + self.SelePanel = XUiDormPersonSelect.New(self.PanelSelect, self) + self.SelePanel.GameObject:SetActive(false) + self:AddListener() +end + +function XUiDormPerson:AddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnReturnClick) +end + +function XUiDormPerson:OnBtnReturnClick() + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormPerson/XUiDormPersonAttDesItem.lua b/Resources/Scripts/XUi/XUiDormPerson/XUiDormPersonAttDesItem.lua new file mode 100644 index 00000000..ae54ebec --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormPerson/XUiDormPersonAttDesItem.lua @@ -0,0 +1,28 @@ +local XUiDormPersonAttDesItem = XClass(nil, "XUiDormPersonAttDesItem") + +function XUiDormPersonAttDesItem:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + XTool.InitUiObject(self) +end + +-- 更新数据 +function XUiDormPersonAttDesItem:OnRefresh(txt, icon) + self.TxtDes.text = txt + if not icon or not self.UiRoot then + return + end + + self.UiRoot:SetUiSprite(self.ImgDes, icon) +end + +function XUiDormPersonAttDesItem:SetState(state) + if not self.GameObject then + return + end + + self.GameObject:SetActive(state) +end + +return XUiDormPersonAttDesItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormPerson/XUiDormPersonListItem.lua b/Resources/Scripts/XUi/XUiDormPerson/XUiDormPersonListItem.lua new file mode 100644 index 00000000..d7409fd9 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormPerson/XUiDormPersonListItem.lua @@ -0,0 +1,85 @@ +local Object = CS.UnityEngine.Object +local V3O = CS.UnityEngine.Vector3.one +local XUiDormPersonSingleItem = require("XUi/XUiDormPerson/XUiDormPersonSingleItem") +local XUiDormPersonListItem = XClass(nil, "XUiDormPersonListItem") +local DormPersonMaxCount = 3 + +function XUiDormPersonListItem:Ctor(ui) + self.PoolObjs = {} + self.CurObjs = {} + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiDormPersonListItem:Init(uiRoot) + self.UiRoot = uiRoot +end + +-- 更新数据 +function XUiDormPersonListItem:OnRefresh(itemData, curDormId) + if not itemData then + return + end + + self.ItemData = itemData + if curDormId ~= itemData.DormitoryId then + self.PanelName.gameObject:SetActive(true) + self.TxtName.text = itemData.DormitoryName + self.PanelNameAtPresent.gameObject:SetActive(false) + else + self.PanelName.gameObject:SetActive(false) + self.TxtNameAtPresent.text = itemData.DormitoryName + self.PanelNameAtPresent.gameObject:SetActive(true) + end + + self.CharacterIds = XTool.Clone(itemData.CharacterIdList or {}) + + local len = #self.CharacterIds + for _ = 1, DormPersonMaxCount - len do + table.insert(self.CharacterIds, -1) + end + + local index = 0 + for k, v in ipairs(self.CharacterIds) do + if not self.CurObjs[k] then + local item = self:GetItem(index) + self.CurObjs[k] = item + end + index = index + 1 + self.CurObjs[k]:SetState(true) + self.CurObjs[k]:OnRefresh(v, itemData.DormitoryId) + end + + if self.PreLen and self.PreLen > index then + for _ = index + 1, self.PreLen do + self:RecycleItem(table.remove(self.CurObjs)) + end + end + self.PreLen = index +end + +function XUiDormPersonListItem:GetItem(index) + if #self.PoolObjs > 0 then + return table.remove(self.PoolObjs) + end + + local obj = Object.Instantiate(self.PersonSingleItem) + obj.transform:SetParent(self.PersonList, false) + obj.transform.localScale = V3O + obj.gameObject.name = index + local item = XUiDormPersonSingleItem.New(obj, self.UiRoot) + item:SetState(true) + return item +end + +function XUiDormPersonListItem:RecycleItem(item) + if not item then + return + end + + item:SetState(false) + table.insert(self.PoolObjs, item) +end + +return XUiDormPersonListItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormPerson/XUiDormPersonSelect.lua b/Resources/Scripts/XUi/XUiDormPerson/XUiDormPersonSelect.lua new file mode 100644 index 00000000..2d82da95 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormPerson/XUiDormPersonSelect.lua @@ -0,0 +1,217 @@ +local XUiDormPersonSelect = XClass(nil, "XUiDormPersonSelect") +local XUiDormPersonSelectListItem = require("XUi/XUiDormPerson/XUiDormPersonSelectListItem") +local Next = next +local TextManager = CS.XTextManager + +function XUiDormPersonSelect:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + XTool.InitUiObject(self) + self:AddListener() + self:InitList() +end + +function XUiDormPersonSelect:InitList() + self.DynamicSelectTable = XDynamicTableNormal.New(self.PanelSelectList) + self.DynamicSelectTable:SetProxy(XUiDormPersonSelectListItem) + self.DynamicSelectTable:SetDelegate(self) +end + +function XUiDormPersonSelect:SetList(dormId) + self.DormId = dormId + + local rawdata = XDataCenter.DormManager.GetCharactersSortedCheckInByDormId(dormId) + self.RawListData = rawdata + if not rawdata or not Next(rawdata) then + self.ImgNonePerson.gameObject:SetActive(true) + else + self.ImgNonePerson.gameObject:SetActive(false) + end + self.Count = 0 + self.SeleCharactList = {} + self.SeleDormIdList = {} + self.ListData = rawdata + self.TxtSelectCount.text = string.format("%s/%s", self.Count, XDormConfig.GetDormPersonCount(self.DormId)) + self.DynamicSelectTable:SetDataSource(rawdata) + self.DynamicSelectTable:ReloadDataASync(1) + self.DrdSort.value = 0 +end + +-- [监听动态列表事件] +function XUiDormPersonSelect:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self, self.UiRoot, self.DormId) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.ListData[index] + grid:OnRefresh(data) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + grid:SetSelectState() + end +end + + +function XUiDormPersonSelect:PutAndRemoveCharacterResp() + self.UiRoot:UpdatePersonList() +end + +-- 更新选中角色 +function XUiDormPersonSelect:UpdateSeleCharacter(itemData, state) + if not itemData then + return + end + + local characterid = itemData.CharacterId + local dormId = itemData.DormitoryId + if state then + if not self.SeleDormIdList[characterid] and not self.SeleCharactList[characterid] then + self.Count = self.Count + 1 + end + self.SeleDormIdList[characterid] = dormId + self.SeleCharactList[characterid] = characterid + else + if self.SeleDormIdList[characterid] and self.SeleCharactList[characterid] then + self.Count = self.Count - 1 + end + self.SeleDormIdList[characterid] = nil + self.SeleCharactList[characterid] = nil + end + + if self.Count < 0 then + self.Count = 0 + end + + self.TxtSelectCount.text = string.format("%s/%s", self.Count, XDormConfig.GetDormPersonCount(self.DormId)) +end + +function XUiDormPersonSelect:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiDormPersonSelect:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiDormPersonSelect:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiDormPersonSelect:AddListener() + self:RegisterClickEvent(self.BtnCancel, self.BtnCancelClick) + self:RegisterClickEvent(self.BtnTanchuangClose, self.BtnCancelClick) + self:RegisterClickEvent(self.BtnClose, self.BtnCancelClick) + self:RegisterClickEvent(self.BtnConfirm, self.OnBtnConfirmClick) + self.PutAndRemoveCharacterRespCb = function() self:PutAndRemoveCharacterResp() end + self.DrdSort.onValueChanged:AddListener(function() + self.PriorSortType = self.DrdSort.value + if self.PrePrior == self.PriorSortType then + return + end + + self.PrePrior = self.PriorSortType + self:RefreshSelectedPanel(self.PriorSortType) + end) + self.BtnCancel:SetName(TextManager.GetText("CancelText")) + self.BtnConfirm:SetName(TextManager.GetText("ConfirmText")) + self.TxtNonePerson.text = TextManager.GetText("DormNoPerson") +end + +function XUiDormPersonSelect:RefreshSelectedPanel(index) + local d = self.RawListData + if index == 0 then + self.ListData = d + self.DynamicSelectTable:SetDataSource(d) + self.DynamicSelectTable:ReloadDataASync(1) + return + end + self.ListData = {} + local conditions = {XDormConfig.GetDormCharacterType(index)} + for _, v in pairs(d) do + if v and v.CharacterId then + local t = XDormConfig.GetCharacterStyleConfigSexById(v.CharacterId) + for _, char_type in ipairs(conditions) do + if t == char_type then + table.insert(self.ListData, v) + goto FILTER_CHAR_BREAK + end + end + ::FILTER_CHAR_BREAK:: + end + end + + self.DynamicSelectTable:SetDataSource(self.ListData) + self.DynamicSelectTable:ReloadDataASync(1) +end + +function XUiDormPersonSelect:BtnCancelClick() + for k, _ in pairs(self.ListData) do + local grid = self.DynamicSelectTable:GetGridByIndex(k) + if grid then + grid:SelectState(false) + end + end + + self.DynamicSelectTable:Clear() + self.UiRoot:PlayAnimation("SelectDisable") + self.GameObject:SetActive(false) +end + +function XUiDormPersonSelect:GetCurSeleDormId() + return self.DormId +end + +function XUiDormPersonSelect:OnBtnConfirmClick() + if self.DormId then + local d0, d1 = self:HandleSeleCharIds() + if Next(d1) and not Next(d0) then + XDataCenter.DormManager.RequestDormitoryRemoveCharacter(d1, self.PutAndRemoveCharacterRespCb) + elseif Next(d0) and not Next(d1) then + XDataCenter.DormManager.RequestDormitoryPutCharacter(self.DormId, d0, self.PutAndRemoveCharacterRespCb) + elseif Next(d0) and Next(d1) then + XDataCenter.DormManager.RequestDormitoryRemoveCharacter(d1, function() + XDataCenter.DormManager.RequestDormitoryPutCharacter(self.DormId, d0, self.PutAndRemoveCharacterRespCb) + end) + end + end + + self:BtnCancelClick() +end + +function XUiDormPersonSelect:HandleSeleCharIds() + local data0 = {} --放进去的 + local data1 = {} --扔出来的 + local ids = XDataCenter.DormManager.GetDormCharactersIds(self.DormId) + + for _, id in pairs(self.SeleCharactList) do + if not ids[id] then + if XDataCenter.DormManager.CheckCharInDorm(id) then + table.insert(data1, id) + end + table.insert(data0, id) + end + end + + for _, id in pairs(ids) do + if not self.SeleCharactList[id] then + table.insert(data1, id) + end + end + + return data0, data1 +end + +function XUiDormPersonSelect:GetTotalSeleCharacter() + local data = {} + + for _, v in pairs(self.SeleCharactList) do + table.insert(data, v) + end + + return data +end +return XUiDormPersonSelect \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormPerson/XUiDormPersonSelectListItem.lua b/Resources/Scripts/XUi/XUiDormPerson/XUiDormPersonSelectListItem.lua new file mode 100644 index 00000000..e33e5a86 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormPerson/XUiDormPersonSelectListItem.lua @@ -0,0 +1,141 @@ +local Object = CS.UnityEngine.Object +local Vector3 = CS.UnityEngine.Vector3 +local V3O = Vector3.one +local XUiDormPersonSelectListItem = XClass(nil, "XUiDormPersonSelectListItem") +local TextManager = CS.XTextManager +local XUiDormPersonAttDesItem = require("XUi/XUiDormPerson/XUiDormPersonAttDesItem") + +function XUiDormPersonSelectListItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.PreSeleState = false + self.BtnClickCb = function() self:OnBtnClick() end + self.Lovetxt = TextManager.GetText("DormLove") or "" + self.Liketxt = TextManager.GetText("DormLike") or "" + XTool.InitUiObject(self) + self.WorkingText.text = TextManager.GetText("DormWorkingText") +end + +function XUiDormPersonSelectListItem:Init(ui, uiRoot, dormId) + self.Parent = ui + self.UiRoot = uiRoot + self.DormId = dormId +end + +function XUiDormPersonSelectListItem:SetSelectState() + local dormId = self.Parent:GetCurSeleDormId() + local cfg = XDormConfig.GetDormitoryCfgById(dormId) + if not cfg then + return + end + + if self.IsWorking then + self.CurSeleState = false + XUiManager.TipText("DormWorkingText") + return + end + + self.CurSeleState = not self.CurSeleState + if self.CurSeleState then + local d = self.Parent:GetTotalSeleCharacter() + local selecount = #d + if selecount ~= 0 and selecount >= cfg.CharCapacity then + self.CurSeleState = false + XUiManager.TipText("DormFullPersonTips") + return + end + end + + self:SelectState(self.CurSeleState) +end + +function XUiDormPersonSelectListItem:SelectState(state) + self.ImgSelect.gameObject:SetActive(state) + self.Parent:UpdateSeleCharacter(self.ItemData, state) + self.ItemData.CurSeleState = state +end + +-- 更新数据 +function XUiDormPersonSelectListItem:OnRefresh(itemData) + if not itemData then + return + end + + self.ItemData = itemData + self.Dormid = itemData.DormitoryId + local characterid = itemData.CharacterId + + if self.Dormid == -1 then + if itemData.CurSeleState == nil then + self.CurSeleState = false + else + self.CurSeleState = itemData.CurSeleState + end + self.ImgDorm.gameObject:SetActive(false) + self.ImgSelect.gameObject:SetActive(self.CurSeleState) + if self.CurSeleState then + self.Parent:UpdateSeleCharacter(self.ItemData, self.CurSeleState) + end + else + local curseleDormId = self.Parent:GetCurSeleDormId() + self.ImgDorm.gameObject:SetActive(true) + self.TxtHostelName.text = XDataCenter.DormManager.GetDormName(self.Dormid) or "" + if itemData.CurSeleState == nil then + local state = curseleDormId == self.Dormid + itemData.CurSeleState = state + self.CurSeleState = state + else + self.CurSeleState = itemData.CurSeleState + end + self.ImgSelect.gameObject:SetActive(self.CurSeleState) + if self.CurSeleState then + self.Parent:UpdateSeleCharacter(self.ItemData, self.CurSeleState) + end + end + local charStyleConfig = XDormConfig.GetCharacterStyleConfigById(characterid) + if not charStyleConfig then + return + end + if charStyleConfig then + self.TxtName.text = charStyleConfig.Name + end + + if XDataCenter.DormManager.IsWorking(characterid) then + self.ImgWorking.gameObject:SetActive(true) + self.IsWorking = true + else + self.ImgWorking.gameObject:SetActive(false) + self.IsWorking = false + end + + local loveicon = XDataCenter.DormManager.GetCharacterLikeIconById(characterid, XDormConfig.CharacterLikeType.LoveType) + local likeicon = XDataCenter.DormManager.GetCharacterLikeIconById(characterid, XDormConfig.CharacterLikeType.LikeType) + + if not self.loveitem then + self.loveitem = self:GetItem() + self.loveitem:SetState(true) + end + self.loveitem:OnRefresh(self.Lovetxt, loveicon) + + if not self.likeitem then + self.likeitem = self:GetItem() + self.likeitem:SetState(true) + end + self.likeitem:OnRefresh(self.Liketxt, likeicon) + + local iconpath = XDormConfig.GetCharacterStyleConfigQIconById(characterid) + if iconpath then + self.ImgIcon:SetRawImage(iconpath, nil, true) + end + self.GameObject.name = characterid +end + +function XUiDormPersonSelectListItem:GetItem() + local obj = Object.Instantiate(self.Item) + obj.transform:SetParent(self.DesItems, false) + obj.transform.localScale = V3O + local item = XUiDormPersonAttDesItem.New(obj, self.UiRoot) + return item +end + +return XUiDormPersonSelectListItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormPerson/XUiDormPersonSingleItem.lua b/Resources/Scripts/XUi/XUiDormPerson/XUiDormPersonSingleItem.lua new file mode 100644 index 00000000..a0f67711 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormPerson/XUiDormPersonSingleItem.lua @@ -0,0 +1,102 @@ +local Object = CS.UnityEngine.Object +local Vector3 = CS.UnityEngine.Vector3 +local V3O = Vector3.one +local ItemType = { + Normal = 1, + Add = 2 +} +local XUiDormPersonAttDesItem = require("XUi/XUiDormPerson/XUiDormPersonAttDesItem") +local XUiDormPersonSingleItem = XClass(nil, "XUiDormPersonSingleItem") +local TextManager = CS.XTextManager +local MaxVitalValue = 100 +local MaxMoodValue = 100 + +function XUiDormPersonSingleItem:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + MaxVitalValue = XDormConfig.DORM_VITALITY_MAX_VALUE + MaxMoodValue = XDormConfig.DORM_MOOD_MAX_VALUE + self.UiRoot = uiRoot + self.PoolObjs = {} + self.CurObjs = {} + XTool.InitUiObject(self) + local btnclick = function() self:OnBtnClick() end + self.UiRoot:RegisterClickEvent(self.Transform, btnclick) + self.Lovetxt = TextManager.GetText("DormLove") or "" + self.Liketxt = TextManager.GetText("DormLike") or "" + self.WorkingText.text = TextManager.GetText("DormWorkingText") +end + +function XUiDormPersonSingleItem:OnBtnClick() + self.UiRoot:SetSelectList(self.DormId) +end + +function XUiDormPersonSingleItem:SetState(state) + if not self.GameObject then + return + end + + self.GameObject:SetActive(state) +end + +-- 更新数据 +function XUiDormPersonSingleItem:OnRefresh(characterId, dormId) + if not characterId or not dormId then + return + end + + self.DormId = dormId + if characterId == -1 then + self.ItemType = ItemType.Add + self.ItemAdd.gameObject:SetActive(true) + self.ItemNormal.gameObject:SetActive(false) + return + end + + local iconpath = XDormConfig.GetCharacterStyleConfigQIconById(characterId) + if iconpath then + self.ImgIcon:SetRawImage(iconpath, nil, true) + end + self.ItemType = ItemType.Normal + self.ItemAdd.gameObject:SetActive(false) + self.ItemNormal.gameObject:SetActive(true) + + if XDataCenter.DormManager.IsWorking(characterId) then + self.ImgWorking.gameObject:SetActive(true) + else + self.ImgWorking.gameObject:SetActive(false) + end + + local curvital = XDataCenter.DormManager.GetVitalityById(characterId) + self.TxtCount.text = TextManager.GetText("DormVilityTxt", curvital, MaxVitalValue) + local curmood = XDataCenter.DormManager.GetMoodById(characterId) + self.ImgProgress.fillAmount = curmood / MaxMoodValue + self.ImgProgress.color = XDormConfig.GetMoodStateColor(curmood) + local moodConfig = XDormConfig.GetMoodStateByMoodValue(curmood) + self.UiRoot:SetUiSprite(self.ImgMood, moodConfig.Icon) + + local loveicon = XDataCenter.DormManager.GetCharacterLikeIconById(characterId, XDormConfig.CharacterLikeType.LoveType) + local likeicon = XDataCenter.DormManager.GetCharacterLikeIconById(characterId, XDormConfig.CharacterLikeType.LikeType) + + if not self.Loveitem then + self.Loveitem = self:GetItem() + self.Loveitem:SetState(true) + end + self.Loveitem:OnRefresh(self.Lovetxt, loveicon) + + if not self.Likeitem then + self.Likeitem = self:GetItem() + self.Likeitem:SetState(true) + end + self.Likeitem:OnRefresh(self.Liketxt, likeicon) +end + +function XUiDormPersonSingleItem:GetItem() + local obj = Object.Instantiate(self.DesSingleItem) + obj.transform:SetParent(self.DesItems.transform, false) + obj.transform.localScale = V3O + local item = XUiDormPersonAttDesItem.New(obj, self.UiRoot) + return item +end + +return XUiDormPersonSingleItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormSecond/XUiDormBgm.lua b/Resources/Scripts/XUi/XUiDormSecond/XUiDormBgm.lua new file mode 100644 index 00000000..9f97b518 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormSecond/XUiDormBgm.lua @@ -0,0 +1,226 @@ +local XUiDormBgm = XClass(nil, "XUiDormBgm") +local XUiDormBgmGrid = require("XUi/XUiDormSecond/XUiDormBgmGrid") + +function XUiDormBgm:Ctor(uiRoot, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + self.PlayingIndex = -1 + self.PlayingId = -1 + self.PlayRecordId = -1 + self.IsSelfRoom = false + self.ShowList = false + XTool.InitUiObject(self) + self:InitBgmList() + + self.UiRoot:RegisterClickEvent(self.BtnClick, function() self:OnBtnClick() + end) + + self.BtnNext.CallBack = function() self:PlayNext() end +end + +function XUiDormBgm:InitBgmList() + self.DynamicTable = XDynamicTableNormal.New(self.ViewSongList.gameObject) + self.DynamicTable:SetProxy(XUiDormBgmGrid) + self.DynamicTable:SetDelegate(self) +end + +function XUiDormBgm:UpdateBgmList(dormId, isSelf) + self.IsSelfRoom = isSelf + local room = XHomeDormManager.GetRoom(dormId) + local configs = room:GetAllFurnitureConfig() + + local result, musicList = XDormConfig.GetDormBgm(configs) + self.Data = musicList + + + self.ShowList = false + if not result then + self.PlayingIndex = 1 + self:Play(result, musicList[self.PlayingIndex]) + self.ShowList = false + self.ViewSongList.gameObject:SetActiveEx(self.ShowList) + self.GameObject:SetActiveEx(false) + return + end + + if not musicList then + return + end + + self.GameObject:SetActiveEx(isSelf) + + self.BtnNext.gameObject:SetActiveEx(#musicList > 1) + self.BtnClick.gameObject:SetActiveEx(#musicList > 1) + + self.PlayingIndex = 1 + self.PlayRecordId = isSelf and CS.UnityEngine.PlayerPrefs.GetInt(tostring(dormId), -1) or -1 + + for i, v in ipairs(musicList) do + if self.PlayRecordId == v.BgmId then + self.PlayingIndex = i + end + end + + self:Play(result, musicList[self.PlayingIndex]) + self.ViewSongList.gameObject:SetActiveEx(self.ShowList and #musicList > 1) + + + if self.ShowList then + self:ReloadBgmList() + end +end + +function XUiDormBgm:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:Refresh(index, self.Data[index]) + grid:SetSelect(self.PlayingIndex == index) + if self.PlayingIndex == index then + self.SelectGrid = grid + end + end +end + +function XUiDormBgm:SelectBgm(index, bgmConfig) + self.ShowList = false + self.ViewSongList.gameObject:SetActiveEx(self.ShowList) + + if self.PlayingIndex == index then + return + end + + if self.SelectGrid then + self.SelectGrid:SetSelect(false) + end + + self.SelectGrid = self.DynamicTable:GetGridByIndex(index) + if self.SelectGrid then + self.SelectGrid:SetSelect(true) + end + + self.PlayingIndex = index + self:Play(true, bgmConfig) +end + +function XUiDormBgm:ReloadBgmList() + self.DynamicTable:SetDataSource(self.Data) + self.DynamicTable:ReloadDataSync() +end + +function XUiDormBgm:PlayNext() + local index = self.PlayingIndex + 1 + if index > #self.Data then + index = 1 + end + + self:SelectBgm(index, self.Data[index]) +end + +function XUiDormBgm:Play(result, bgmConfig) + self.TxtSong.text = bgmConfig.Name + + if self.PlayingId == bgmConfig.BgmId then + return + end + + self.PlayingId = bgmConfig.BgmId + self.UiRoot:PlayBgmMusic(result, bgmConfig) +end + +function XUiDormBgm:OnBtnClick() + self.ShowList = not self.ShowList + self.ViewSongList.gameObject:SetActiveEx(self.ShowList) + self:ReloadBgmList() +end + +function XUiDormBgm:OnEnable(dormId) + self:ResetBgmList(dormId, self.IsSelfRoom) +end + +function XUiDormBgm:IsMusicListChange(newList) + + if not newList or not self.Data then + return true + end + + if #newList ~= #self.Data then + return true + end + + + for _, v in ipairs(newList) do + local isChanged = true + for _, var in ipairs(self.Data) do + if v.BgmId == var.BgmId then + isChanged = false + end + end + + + if isChanged then + return true + end + end + + return false +end + +function XUiDormBgm:ResetBgmList(dormId, isSelf) + local room = XHomeDormManager.GetRoom(dormId) + local configs = room:GetAllFurnitureConfig() + local result, musicList = XDormConfig.GetDormBgm(configs) + + local isChanged = self:IsMusicListChange(musicList) + + self.Data = musicList + self.PlayRecordId = isSelf and CS.UnityEngine.PlayerPrefs.GetInt(tostring(dormId), -1) or -1 + + if isChanged then + self.PlayRecordId = -1 + end + + if not result then + self.PlayingIndex = 1 + self:Play(result, musicList[self.PlayingIndex]) + self.ShowList = false + self.ViewSongList.gameObject:SetActiveEx(self.ShowList) + self.GameObject:SetActiveEx(false) + return + end + + + if not musicList then + return + end + self.GameObject:SetActiveEx(isSelf) + + self.BtnNext.gameObject:SetActiveEx(#musicList > 1) + self.BtnClick.gameObject:SetActiveEx(#musicList > 1) + + self.ViewSongList.gameObject:SetActiveEx(self.ShowList and #musicList > 1) + if self.ShowList then + self:ReloadBgmList() + end + + local isExist = false + for i, v in ipairs(self.Data) do + if self.PlayRecordId == v.BgmId then + self.PlayingIndex = i + isExist = true + end + end + + + if not isExist then + self.PlayingIndex = 1 + self:Play(result, musicList[self.PlayingIndex]) + end +end + +function XUiDormBgm:OnDisable() + self.ViewSongList.gameObject:SetActiveEx(self.ShowList) +end + +return XUiDormBgm \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormSecond/XUiDormBgmGrid.lua b/Resources/Scripts/XUi/XUiDormSecond/XUiDormBgmGrid.lua new file mode 100644 index 00000000..607a0b4e --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormSecond/XUiDormBgmGrid.lua @@ -0,0 +1,43 @@ +local XUiDormBgmGrid = XClass(nil, "XUiDormBgmGrid") + +function XUiDormBgmGrid:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.GridNameItem.CallBack = function() self:OnBgmSelect() end +end + +function XUiDormBgmGrid:Init(parent) + self.Parent = parent +end + +-- 更新数据 +function XUiDormBgmGrid:Refresh(index, data) + if not data then + return + end + + self.Data = data + self.Index = index + + self.TxtNormalName.text = data.Name + self.TxtPressName.text = data.Name + self.TxtSelectName.text = data.Name +end + +function XUiDormBgmGrid:OnBgmSelect() + if not self.Parent then + return + end + + self:SetSelect(true) + self.Parent:SelectBgm(self.Index, self.Data) +end + + +function XUiDormBgmGrid:SetSelect(bSelect) + local btnState = bSelect and XUiButtonState.Select or XUiButtonState.Normal + self.GridNameItem:SetButtonState(btnState) +end + +return XUiDormBgmGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormSecond/XUiDormCaress.lua b/Resources/Scripts/XUi/XUiDormSecond/XUiDormCaress.lua new file mode 100644 index 00000000..d9ec6ce8 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormSecond/XUiDormCaress.lua @@ -0,0 +1,334 @@ +local XUiPanelFurnitureLike = require("XUi/XUiDormSecond/XUiPanelFurnitureLike") +local XUiDormCaress = XClass(XLuaBehaviour, "XUiDormCaress") + +function XUiDormCaress:Ctor(uiRoot, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + self.OnBtnBackClickCb = function() self:OnBtnBackClick() end + + XTool.InitUiObject(self) + self:RefreshData() + self:InitAddListen() + self:InitTabGroup() + + self.FurnitureLike = XUiPanelFurnitureLike.New(uiRoot, self.PanelFurnitureLike) +end + +function XUiDormCaress:InitAddListen() + self.UiRoot:RegisterClickEvent(self.BtnBack, self.OnBtnBackClickCb) +end + +function XUiDormCaress:OnBtnBackClick() + self.UiRoot:OnCloseedCaress() + XEventManager.DispatchEvent(XEventId.EVENT_DORM_TOUCH_HIDE) + XDataCenter.DormManager.SetInTouch(false) + XDataCenter.DormManager.GetNextShowEvent() +end + +function XUiDormCaress:InitTabGroup() + self.BtnList = {} + table.insert(self.BtnList, self.BtnCaress) + table.insert(self.BtnList, self.BtnGun) + table.insert(self.BtnList, self.BtnPlay) + + self.PanelParticularCaressGroup:Init(self.BtnList, function(index) + self.CurTouchState = index + end) +end + +function XUiDormCaress:Show(characterId, curRoomId) + self.IsTouchCD = false + self:RefreshData() + self.TxtTouchDesc.text = CS.XTextManager.GetText("DormTouchDesc") + + self.CharacterId = characterId + self.Camera = XHomeSceneManager.GetSceneCamera() + self.CurSelectCharacter = XHomeCharManager.GetSelectCharacter() + self.FurnitureLike:Refresh(characterId, curRoomId) + self.FurnitureLike.GameObject:SetActiveEx(true) + + -- 设置默认开启 + self.PanelParticularCaressGroup:SelectIndex(XDormConfig.TouchState.Touch) + -- 拉近摄像头 + local cameraController = XHomeSceneManager.GetSceneCameraController() + self.TargetAngleX = cameraController.TargetAngleX + self.TargetAngleY = cameraController.TargetAngleY + self.MinDistance = cameraController.MinDistance + self.Distance = cameraController.Distance + self.AllowZoom = cameraController.AllowZoom + + if not XTool.UObjIsNil(cameraController) then + cameraController:SetWorldOffset(CS.UnityEngine.Vector2(0, -0.39)) + cameraController:SetTartAngle(CS.UnityEngine.Vector2(self.CurSelectCharacter.Transform.eulerAngles.y - 180, 10)) + cameraController:SetMinDistance(XDormConfig.DRAFT_DIS) + XCameraHelper.SetCameraTarget(cameraController, self.CurSelectCharacter.Transform, XDormConfig.DRAFT_DIS) + CS.XDofManager.Instance:SetDormitoryDof(self.CurSelectCharacter.Transform) + cameraController.AllowZoom = false + end + + self:ReqFondleData() + XEventManager.DispatchEvent(XEventId.EVENT_CARESS_SHOW) +end + +function XUiDormCaress:ReqFondleData() + self:RemoveTimer() + + XDataCenter.DormManager.GetDormFondleData(self.CharacterId, function(fondleData) + self.FondleConfig = XDormConfig.GetCharacterFondleByCharId(self.CharacterId) + self.FondleData = fondleData + + self:SetRecoveryInfo(fondleData.LeftCount, fondleData.LastRecoveryTime) + self.PanelParticularCaress.gameObject:SetActiveEx(true) + end) +end + +function XUiDormCaress:SetRecoveryInfo(leftCount, recoveryTime) + self.PanelTimeOut.gameObject:SetActiveEx(leftCount < self.FondleConfig.MaxCount) + self.TxtTouchCount.text = CS.XTextManager.GetText("DormFondleCount", leftCount, self.FondleConfig.MaxCount) + + if leftCount >= self.FondleConfig.MaxCount then + return + end + + local now = XTime.GetServerNowTimestamp() + local leftTime = recoveryTime + self.FondleConfig.RecoveryTime - now + local timeString = XUiHelper.GetTime(leftTime, XUiHelper.TimeFormatType.CHALLENGE) + self.TxtTimeOut.text = CS.XTextManager.GetText("DormFondleRecovey", timeString) + self:RemoveTimer()--临时处理防止定时器注销失败问题 + self.TimerId = XScheduleManager.ScheduleForever(function() + if XTool.UObjIsNil(self.Transform) or not self.GameObject.activeSelf then + return + end + + leftTime = leftTime - 1 + if leftTime <= 0 then + self:ReqFondleData() + return + end + + timeString = XUiHelper.GetTime(leftTime, XUiHelper.TimeFormatType.CHALLENGE) + self.TxtTimeOut.text = CS.XTextManager.GetText("DormFondleRecovey", timeString) + end, 1000) +end + +function XUiDormCaress:RemoveTimer() + if self.TimerId then + XScheduleManager.UnSchedule(self.TimerId) + self.TimerId = nil + end +end + +function XUiDormCaress:RemoveAnimaTimer() + if self.AnimaTimer then + XScheduleManager.UnSchedule(self.AnimaTimer) + self.AnimaTimer = nil + end +end + +function XUiDormCaress:OnClose(curDormId) + self.FondleData = {} + self:RemoveTimer() + self:RemoveAnimaTimer() + self:RefreshData() + self.PanelParticularCaress.gameObject:SetActiveEx(false) + + -- 拉远摄像头 + local cameraController = XHomeSceneManager.GetSceneCameraController() + if not XTool.UObjIsNil(cameraController) then + cameraController:SetWorldOffset(CS.UnityEngine.Vector2(0, 0)) + cameraController:SetTartAngle(CS.UnityEngine.Vector2(self.TargetAngleX, self.TargetAngleY)) + local curDormTransform = XHomeDormManager.GetRoom(curDormId).Transform + cameraController:SetMinDistance(self.MinDistance) + XCameraHelper.SetCameraTarget(cameraController, curDormTransform, self.Distance) + CS.XDofManager.Instance:SetDormitoryDof(nil) + cameraController.AllowZoom = self.AllowZoom + end +end + +function XUiDormCaress:Update() + if XTool.UObjIsNil(self.Transform) or not self.GameObject.activeSelf then + return + end + + local point = self:GetPisont() + if not XTool.UObjIsNil(self.Camera) and point then + local ray = self.Camera:ScreenPointToRay(point) + local layerMask = CS.UnityEngine.LayerMask.GetMask("HomeCharacter") + if layerMask then + local rect, hit = ray:RayCast(layerMask) + if rect and hit and self.CurSelectCharacter.Transform == hit.transform.parent.transform then + if not self:JudgeLeftCount() then + XEventManager.DispatchEvent(XEventId.EVENT_DORM_TOUCH_SHOW, XDormConfig.TouchState.Hate, self.CharacterId, nil) + end + + self:UpdateFondleInfo(point) + end + end + end +end + +function XUiDormCaress:GetPisont() + local screenPoint + + local platform = CS.UnityEngine.Application.platform + local runtimePlatform = CS.UnityEngine.RuntimePlatform + + if platform == runtimePlatform.WindowsEditor or platform == runtimePlatform.WindowsPlayer then + if self.CurTouchState == XDormConfig.TouchState.WaterGun then + if CS.UnityEngine.Input.GetMouseButtonDown(0) then + screenPoint = CS.UnityEngine.Vector3(CS.UnityEngine.Input.mousePosition.x, CS.UnityEngine.Input.mousePosition.y, 0) + elseif CS.UnityEngine.Input.GetMouseButtonUp(0) then + XEventManager.DispatchEvent(XEventId.EVENT_DORM_TOUCH_SHOW, XDormConfig.TouchState.Hide, self.CharacterId, nil) + end + else + if CS.UnityEngine.Input.GetMouseButtonDown(0) then + self:RefreshData() + elseif CS.UnityEngine.Input.GetMouseButtonUp(0) then + XEventManager.DispatchEvent(XEventId.EVENT_DORM_TOUCH_SHOW, XDormConfig.TouchState.Hide, self.CharacterId, nil) + end + + if CS.UnityEngine.Input.GetMouseButton(0) then + screenPoint = CS.UnityEngine.Vector3(CS.UnityEngine.Input.mousePosition.x, CS.UnityEngine.Input.mousePosition.y, 0) + end + end + else + if CS.UnityEngine.Input.touchCount > 0 then + if self.CurTouchState == XDormConfig.TouchState.WaterGun then + if CS.UnityEngine.Input.GetTouch(0).phase == CS.UnityEngine.TouchPhase.Began then + local p = CS.UnityEngine.Input.GetTouch(0).position + screenPoint = CS.UnityEngine.Vector3(p.x, p.y, 0) + elseif CS.UnityEngine.Input.GetTouch(0).phase == CS.UnityEngine.TouchPhase.Ended then + XEventManager.DispatchEvent(XEventId.EVENT_DORM_TOUCH_SHOW, XDormConfig.TouchState.Hide, self.CharacterId, nil) + end + else + if CS.UnityEngine.Input.GetTouch(0).phase == CS.UnityEngine.TouchPhase.Began then + self:RefreshData() + elseif CS.UnityEngine.Input.GetTouch(0).phase == CS.UnityEngine.TouchPhase.Ended then + XEventManager.DispatchEvent(XEventId.EVENT_DORM_TOUCH_SHOW, XDormConfig.TouchState.Hide, self.CharacterId, nil) + end + + if CS.UnityEngine.Input.GetTouch(0).phase == CS.UnityEngine.TouchPhase.Stationary or + CS.UnityEngine.Input.GetTouch(0).phase == CS.UnityEngine.TouchPhase.Moved then + local p = CS.UnityEngine.Input.GetTouch(0).position + screenPoint = CS.UnityEngine.Vector3(p.x, p.y, 0) + end + end + end + end + + return screenPoint +end + +function XUiDormCaress:RefreshData() + self.TouchLength = 0 + self.PlayTime = 0 + self.LastPoint = nil + self.PlayTimer = 0 +end + +-- 每帧更新爱抚滑动详情 +function XUiDormCaress:UpdateFondleInfo(point) + if self.CurTouchState == XDormConfig.TouchState.Touch then + -- 判断是否还有次数 + if not self:JudgeLeftCount() then + XEventManager.DispatchEvent(XEventId.EVENT_DORM_TOUCH_SHOW_VIEW, XDormConfig.TouchState.TouchHate, self.CharacterId, point) + return + end + + -- 判断是否在CD中 + if self.IsTouchCD then + XEventManager.DispatchEvent(XEventId.EVENT_DORM_TOUCH_SHOW_VIEW, XDormConfig.TouchState.Touch, self.CharacterId, point) + return + end + + if self.LastPoint then + local dis = (self.LastPoint - point).sqrMagnitude + self.TouchLength = self.TouchLength + dis + end + self.LastPoint = point + + -- 判断前置长度 + local propLength = XDormConfig.TOUCH_LENGTH * XDormConfig.TOUCH_PROP + local propNum = self.TouchLength / XDormConfig.TOUCH_LENGTH + if propNum < 0 then + propNum = 0 + elseif propNum > 1 then + propNum = 1 + end + + if self.TouchLength < propLength then + XEventManager.DispatchEvent(XEventId.EVENT_DORM_TOUCH_SHOW_VIEW, XDormConfig.TouchState.Touch, self.CharacterId, point, propNum) + return + end + + -- 达到长度请求抚摸 + if self.TouchLength >= XDormConfig.TOUCH_LENGTH then + self:RefreshData() + self:ReqFondle() + end + + XEventManager.DispatchEvent(XEventId.EVENT_DORM_TOUCH_SHOW, XDormConfig.TouchState.Touch, self.CharacterId, point, propNum) + elseif self.CurTouchState == XDormConfig.TouchState.WaterGun then + self:ReqFondle() + XEventManager.DispatchEvent(XEventId.EVENT_DORM_TOUCH_SHOW, XDormConfig.TouchState.WaterGun, self.CharacterId, point) + elseif self.CurTouchState == XDormConfig.TouchState.Play then + self.PlayTimer = self.PlayTimer + CS.UnityEngine.Time.deltaTime + if self.PlayTimer >= XDormConfig.PLAY_TIME then + self:RefreshData() + self:ReqFondle() + end + XEventManager.DispatchEvent(XEventId.EVENT_DORM_TOUCH_SHOW, XDormConfig.TouchState.Play, self.CharacterId, point) + end +end + +-- 请求爱抚 +function XUiDormCaress:ReqFondle() + -- 次数不足 + if self.FondleData.LeftCount <= 0 then + return + end + + XDataCenter.DormManager.DoFondleReq(self.CharacterId, self.CurTouchState, function() + local state = XDormConfig.TouchState.Hide + if self.CurTouchState == XDormConfig.TouchState.Touch then + state = XDormConfig.TouchState.TouchSuccess + elseif self.CurTouchState == XDormConfig.TouchState.WaterGun then + state = XDormConfig.TouchState.WaterGunSuccess + elseif self.CurTouchState == XDormConfig.TouchState.Play then + state = XDormConfig.TouchState.PlaySuccess + end + + if self.CurTouchState == XDormConfig.TouchState.Touch then + self.IsTouchCD = true + local time = XDormConfig.TOUCH_CD + + self.AnimaTimer = XUiHelper.Tween(time, function(f) + if not self.GameObject.activeSelf or XTool.UObjIsNil(self.Transform) then + return + end + + local timeStr = string.format("%.1f", time - f * time) + self.TxtTouchDesc.text = CS.XTextManager.GetText("DormTouchTimeOut", timeStr) + end, function() + self:RemoveAnimaTimer() + self.IsTouchCD = false + self.TxtTouchDesc.text = CS.XTextManager.GetText("DormTouchDesc") + end) + end + + XEventManager.DispatchEvent(XEventId.EVENT_DORM_TOUCH_SHOW, state, self.CharacterId, nil) + self:ReqFondleData() + end) +end + +-- 判断是否还有次数 +function XUiDormCaress:JudgeLeftCount() + if self.FondleData and self.FondleData.LeftCount then + return self.FondleData.LeftCount > 0 + end + + return false +end + +return XUiDormCaress \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormSecond/XUiDormNameGridItem.lua b/Resources/Scripts/XUi/XUiDormSecond/XUiDormNameGridItem.lua new file mode 100644 index 00000000..1e003ff0 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormSecond/XUiDormNameGridItem.lua @@ -0,0 +1,22 @@ +local XUiDormNameGridItem = XClass(nil, "XUiDormNameGridItem") + +function XUiDormNameGridItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiDormNameGridItem:Init(parent) + self.Parent = parent +end + +-- 更新数据 +function XUiDormNameGridItem:OnRefresh(itemData) + if not itemData then + return + end + + self.TxtName.text = itemData[1] +end + +return XUiDormNameGridItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormSecond/XUiDormReName.lua b/Resources/Scripts/XUi/XUiDormSecond/XUiDormReName.lua new file mode 100644 index 00000000..89f15f20 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormSecond/XUiDormReName.lua @@ -0,0 +1,81 @@ +local XUiDormReName = XClass(nil, "XUiDormReName") +local TextManager = CS.XTextManager +local NameLenLimit + +function XUiDormReName:Ctor(ui, uiRoot) + NameLenLimit = CS.XGame.Config:GetInt("DormReNameLen") + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.OnBtnCancelClickCb = function() self:OnBtnCancelClick() end + self.OnBtnConfirmClickCb = function() self:OnBtnConfirmClick() end + self.OnReNameRespCb = function() self:OnReNameResp() end + self.Msg = TextManager.GetText("DormReNameSuccess") + XTool.InitUiObject(self) + self:Init(uiRoot) + self.InputField.characterLimit = 0 +end + +function XUiDormReName:Init(uiRoot) + self.UiRoot = uiRoot + self.BtnReNameCancel.CallBack = self.OnBtnCancelClickCb + self.BtnTanchuangClose.CallBack = self.OnBtnCancelClickCb + self.TanchuangBgCloseBtn.CallBack = self.OnBtnCancelClickCb + self.BtnReNameConfirm.CallBack = self.OnBtnConfirmClickCb + self.BtnReNameCancel:SetName(TextManager.GetText("CancelText")) + self.BtnReNameConfirm:SetName(TextManager.GetText("ConfirmText")) +end + +function XUiDormReName:OnBtnCancelClick() + self.GameObject:SetActive(false) +end + +function XUiDormReName:OnBtnConfirmClick() + if not self.InputField or not self.InputField.textComponent then + return + end + + local newname = self.InputField.text + local utf8Count = self.InputField.textComponent.cachedTextGenerator.characterCount - 1 + if utf8Count > NameLenLimit then + local text = CS.XTextManager.GetText("DormNameMaxNameLengthTips", NameLenLimit) + XUiManager.TipMsg(text, XUiManager.UiTipType.Wrong) + return + end + if newname == self.Curname then + XUiManager.TipText("DormReNameErrorNoChange", XUiManager.UiTipType.Wrong) + return + end + + if newname == "" then + XUiManager.TipText("DormReNameErrorText", XUiManager.UiTipType.Wrong) + return + end + + if string.match(newname, "%s") then + XUiManager.TipText("DormReNameTips", XUiManager.UiTipType.Wrong) + return + end + + self.Curname = newname + XDataCenter.DormManager.RequestDormitoryRename(self.ItemData, newname, self.OnReNameRespCb) + self:OnBtnCancelClick() +end + +function XUiDormReName:OnReNameResp() + XUiManager.TipMsg(self.Msg, XUiManager.UiTipType.Success) + self.UiRoot:SetHostelName(self.Curname) +end + +-- 更新数据 +function XUiDormReName:OnRefresh(itemData) + if not itemData then + return + end + + self.ItemData = itemData + self.Curname = XDataCenter.DormManager.GetDormName(itemData) + self.TxtCurName.text = self.Curname +end + + +return XUiDormReName \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormSecond/XUiDormSecond.lua b/Resources/Scripts/XUi/XUiDormSecond/XUiDormSecond.lua new file mode 100644 index 00000000..8fe1e2ea --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormSecond/XUiDormSecond.lua @@ -0,0 +1,1003 @@ +local Object = CS.UnityEngine.Object +local Vector3 = CS.UnityEngine.Vector3 +local V3O = Vector3.one + +local XUiDormSecond = XLuaUiManager.Register(XLuaUi, "UiDormSecond") +local XUiDormNameGridItem = require("XUi/XUiDormSecond/XUiDormNameGridItem") +local XUiDormSecondHead = require("XUi/XUiDormSecond/XUiDormSecondHead") +local XUiDormReName = require("XUi/XUiDormSecond/XUiDormReName") +local XUiDormCaress = require("XUi/XUiDormSecond/XUiDormCaress") +local XUiPanelEventShow = require("XUi/XUiDormSecond/XUiPanelEventShow") +local XUiDormBgm = require("XUi/XUiDormSecond/XUiDormBgm") + +local TextManager = CS.XTextManager +local SelfPreDormId = -1 --在访问其他人时,记录当前自己的宿舍Id。在访问返回时使用 +local CurrentSchedule = nil +local V3OP +local DisplaySetType +local DormSecondEnter +local AttrType +local White = "#ffffff" +local Blue = "#34AFF8" + +function XUiDormSecond:OnAwake() + DisplaySetType = XDormConfig.VisitDisplaySetType + DormSecondEnter = XDormConfig.DormSecondEnter + AttrType = XFurnitureConfigs.AttrType + V3OP = Vector3(-1, 1, 1) + self.EnterBtns = {} + XTool.InitUiObject(self) + self:InitFun() + self:InitUI() + self:InitEnterCfg() + self.PanelCaress.gameObject:SetActiveEx(false) + self.LastMusicId = CS.XAudioManager.CurrentMusicId + self.BgmShowState = false + self.IsChangeOverView = true + self.DormBgm = XUiDormBgm.New(self, self.MusicPlayer) +end + +function XUiDormSecond:InitFun() + self.OnBtnTaskTipsClickCb = function() self:OnBtnTaskTipsClick() end + self.BtnClickTips.CallBack = function() self:ComfortTips() end + self.BtnExpand.CallBack = function() self:OnBtnExpand() end + self.BtnRename.CallBack = function() self:OpenRenameUI() end + self:BindHelpBtn(self.BtnHelp, "Dorm") + self.BtnDormTemplate.CallBack = function() self:OnBtnDormTemplateClick() end + self.BtnNext.CallBack = function() self:OnBtnNextClick() end + self.BtnCollect.CallBack = function() self:OnBtnCollectClick() end + self.BtnDormShare.CallBack = function() self:OnBtnDormShareClick() end +end + +function XUiDormSecond:OnBtnDormTemplateClick() + local roomData = XDataCenter.DormManager.GetRoomDataByRoomId(self.CurDormId) + local connectId = roomData:GetConnectDormId() + local indexId = XDormConfig.GetDormTemplateSelecIndex(connectId) + XLuaUiManager.Open("UiDormTemplate", indexId, function() + if XLuaUiManager.IsUiLoad("UiDormSecond") then + self.IsChangeOverView = false + self:Remove() + end + end, self.CurDormId) +end + +function XUiDormSecond:OnBtnCollectClick() + XLuaUiManager.Open("UiDormTemplateScene", self.CurDormId, XDormConfig.DormDataType.Target, self.CurDisplayState) +end + +function XUiDormSecond:OnBtnDormShareClick() + local dormDataType = XDormConfig.DormDataType.Self + if self.CurDisplayState ~= DisplaySetType.MySelf then + dormDataType = XDormConfig.DormDataType.Target + end + local roomData = XDataCenter.DormManager.GetRoomDataByRoomId(self.CurDormId, dormDataType) + + local furnitureDatas = roomData:GetFurnitureDic() + local furnitureList = {} + + for _, v in pairs(furnitureDatas) do + local data = { + ConfigId = v.ConfigId, + X = v.GridX, + Y = v.GridY, + Angle = v.RotateAngle, + } + table.insert(furnitureList, data) + end + XDataCenter.DormManager.RequestDormSnapshotLayout(furnitureList, function(shareId) + roomData:SetShareId(shareId) + XHomeSceneManager.EnterShare(roomData) + end) +end + +function XUiDormSecond:OnDestroy() + if self.EventShow then + self.EventShow:OnEventShowDestroy() + end + if XLuaUiManager.IsUiLoad("UiDormMain") and self.IsChangeOverView then + XHomeSceneManager.ChangeBackToOverView() + end + + if self.LastMusicId and self.LastMusicId > 0 then + CS.XAudioManager.PlayMusic(self.LastMusicId) + end + DisplaySetType = nil + DormSecondEnter = nil +end + +function XUiDormSecond:InitUI() + self.CurScoreState = false + self.CurInfoState = true + self.TxtPerson.text = TextManager.GetText("DormPersonTxt") + self.TxtRemould.text = TextManager.GetText("DormRemouldTxt") + self.TxtMenu.text = TextManager.GetText("DormMenTxt") + self.TxtScoreDes.text = TextManager.GetText("DormTotalScore") + self.TxtTool.text = TextManager.GetText("DormComfortLevelTips") + self.BtnRemould:SetName(TextManager.GetText("DormRemouldTxt")) + self.BtnVisitor:ShowReddot(false) + local a, b, c = XDataCenter.DormManager.GetDormitoryScoreNames() + self.TxtBeautiful.text = a + self.TxtComfort.text = b + self.TxtPractical.text = c + self:AddListener() + self:InitList() + + local indexA = AttrType.AttrA + local indexB = AttrType.AttrB + local indexC = AttrType.AttrC + local iconA = XFurnitureConfigs.GetDormFurnitureTypeIcon(indexA) + local iconB = XFurnitureConfigs.GetDormFurnitureTypeIcon(indexB) + local iconC = XFurnitureConfigs.GetDormFurnitureTypeIcon(indexC) + self:SetUiSprite(self.ImgTool1, iconA) + self:SetUiSprite(self.ImgTool2, iconB) + self:SetUiSprite(self.ImgTool3, iconC) +end + +function XUiDormSecond:InitList() + self.DynamicTable = XDynamicTableNormal.New(self.ViewNameList.gameObject) + self.DynamicTable:SetProxy(XUiDormNameGridItem) + self.DynamicTable:SetDelegate(self) +end + +function XUiDormSecond:InitEnterCfg() + self.EnterCfg = {} + self.EnterCfg[DormSecondEnter.Des] = {["Name"] = TextManager.GetText("DormDes"), + ["Skip"] = function() self:OpenDesUI() end, + ["IconPath"] = CS.XGame.ClientConfig:GetString("FurnitureImgS20") + } + self.EnterCfg[DormSecondEnter.WareHouse] = {["Name"] = TextManager.GetText("DormWareHouse"), + ["Skip"] = function() self:OpenWarehouse() end, + ["IconPath"] = CS.XGame.ClientConfig:GetString("FurnitureImgS5") + } + self.EnterCfg[DormSecondEnter.Person] = {["Name"] = TextManager.GetText("DormPersonText"), + ["Skip"] = function() self:OnBtnPersonClick() end, + ["IconPath"] = CS.XGame.ClientConfig:GetString("FurnitureImgS11") + } + self.EnterCfg[DormSecondEnter.FieldGuilde] = {["Name"] = TextManager.GetText("DormFieldGuilde"), + ["Skip"] = function() self:OpenFieldGuid() end, + ["IconPath"] = CS.XGame.ClientConfig:GetString("FurnitureImgS22") + } + self.EnterCfg[DormSecondEnter.Build] = {["Name"] = TextManager.GetText("DormBuild"), + ["Skip"] = function() self:OpenBuildUI() end, + ["IconPath"] = CS.XGame.ClientConfig:GetString("FurnitureImgS6") + } + self.EnterCfg[DormSecondEnter.Shop] = {["Name"] = TextManager.GetText("DormShopText"), + ["Skip"] = function() self:OpenShopUI() end, + ["IconPath"] = CS.XGame.ClientConfig:GetString("FurnitureImgS8") + } +end + +-- 跳到商店 +function XUiDormSecond:OpenShopUI() + XLuaUiManager.Open("UiShop", XShopManager.ShopType.Dorm) + self.IsStatic = true +end + +-- [监听动态列表事件] +function XUiDormSecond:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.HostelNameDataList[index] + grid:OnRefresh(data) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + self.CurIndex = index + local d = self.HostelNameDataList[index] + if self.CurDormId == d[2] then + self.CurHostelNamesState = false + self:SetDormListNameV(false) + return + end + + self.CurDormId = d[2] + self:SetHostelNameClick() + self:OnBtnHostelNamesClick() + self:UpdateData(self.CurDisplayState, self.CurDormId) + XHomeDormManager.CharacterExit(self.CurDormId) + XHomeDormManager.SetSelectedRoom(self.CurDormId, true) + end +end + +-- 可以访问宿舍lsit +function XUiDormSecond:SetCurHostelList() + local len = 0 + local data = {} + local dormdatas + + if DisplaySetType.MySelf == self.CurDisplayState then + dormdatas = XDataCenter.DormManager.GetDormitoryData() or {} + else + dormdatas = XDataCenter.DormManager.GetDormitoryData(XDormConfig.DormDataType.Target) or {} + end + + for _, v in pairs(dormdatas) do + if v:WhetherRoomUnlock() then + len = len + 1 + table.insert(data, { v:GetRoomName(), v:GetRoomId() }) + end + end + + table.sort(data, function(a, b) + local cfg1 = XDormConfig.GetDormitoryCfgById(a[2]) + local cfg2 = XDormConfig.GetDormitoryCfgById(b[2]) + return cfg1.InitNumber < cfg2.InitNumber + end) + self.HostelNameDataList = data + self.DynamicTable:Clear() + self.DynamicTable:SetDataSource(data) + self.DynamicTable:ReloadDataASync(1) + self.ImgDownUp.gameObject:SetActiveEx(len > 1) + self.ImgArrowDown.gameObject:SetActiveEx(len > 1) + self.ImgArrowUp.gameObject:SetActiveEx(len < 1) +end + +-- 设置模板宿舍 +function XUiDormSecond:SetTemplateInfo() + local dormDataType = XDormConfig.DormDataType.Self + if self.CurDisplayState ~= DisplaySetType.MySelf then + dormDataType = XDormConfig.DormDataType.Target + end + local roomData = XDataCenter.DormManager.GetRoomDataByRoomId(self.CurDormId, dormDataType) + local connectId = roomData:GetConnectDormId() + local isConect = connectId > 0 + self.BtnDormTemplate.gameObject:SetActiveEx(self.CurDisplayState == DisplaySetType.MySelf) + --self.BtnDormShare.gameObject:SetActiveEx(true) + self.BtnDormShare.gameObject:SetActiveEx(false)--海外特供屏蔽宿舍分享按钮 + if not isConect then + self.SliderTemplate.fillAmount = 0 + return + end + + local prrcent = XDataCenter.DormManager.GetDormTemplatePercent(connectId, self.CurDormId) + self.SliderTemplate.fillAmount = prrcent / 100 +end + +-- 设置当前宿舍名(ClickOrInit) +function XUiDormSecond:SetHostelNameClick() + local dormdatas + if DisplaySetType.MySelf == self.CurDisplayState then + dormdatas = XDataCenter.DormManager.GetDormitoryData() or {} + else + dormdatas = XDataCenter.DormManager.GetDormitoryData(XDormConfig.DormDataType.Target) or {} + end + + local d = dormdatas[self.CurDormId] + if not d then + return + end + local name = d:GetRoomName() or "" + self.TxtTitle.text = name +end + +-- 设置当前宿舍名(改名成功) +function XUiDormSecond:SetHostelName(name) + self.TxtTitle.text = name or "" + self:SetCurHostelList() +end + +-- 设置宿舍list显示与隐藏 +function XUiDormSecond:SetDormListNameV(state) + self.ListContent.gameObject:SetActiveEx(state) + self.ImgArrowUp.gameObject:SetActiveEx(state) + self.ImgArrowDown.gameObject:SetActiveEx(not state) +end + + +function XUiDormSecond:SetSelectState(state) + if not self.PanelSelect then + return + end + + self.PanelSelect.gameObject:SetActiveEx(state) +end + +-- 人员 +function XUiDormSecond:OnBtnPersonClick() + XLuaUiManager.Open("UiDormPerson", self.CurDormId) +end + +function XUiDormSecond:CreateDormMainItems() +end + +-- 任务 +function XUiDormSecond:OpenTaskUI() + self.CurMenState = false + self:SetEnterState(self.CurMenState) + XLuaUiManager.Open("UiDormTask") +end + +-- 建造 +function XUiDormSecond:OpenBuildUI() + self.CurMenState = false + self:SetEnterState(self.CurMenState) + XLuaUiManager.Open("UiFurnitureBuild") +end + +-- 说明 +function XUiDormSecond:OpenDesUI() + self.CurMenState = false + self:SetEnterState(self.CurMenState) + XUiManager.UiFubenDialogTip("", CS.XTextManager.GetText("DormDesSecond") or "") +end + +-- 仓库 +function XUiDormSecond:OpenWarehouse() + self.CurMenState = false + self:SetEnterState(self.CurMenState) + XLuaUiManager.Open("UiDormBag") +end + +-- 改名 +function XUiDormSecond:OpenRenameUI() + self.CurMenState = false + self:SetEnterState(self.CurMenState) + if not self.RenameInit then + self.RenameInit = true + self.PanelRenameUI = XUiDormReName.New(self.PanelRename, self) + end + self.PanelRename.gameObject:SetActiveEx(true) + self:PlayAnimation("PanelRenameEnable") + self.PanelRenameUI:OnRefresh(self.CurDormId) +end + +function XUiDormSecond:InitEventShow() + if not self.EventShow then + self.EventShow = XUiPanelEventShow.New(self, self.PanelEventShow) + end +end + +function XUiDormSecond:InitHead() + if not self.XUiDormSecondHead then + self.XUiDormSecondHead = XUiDormSecondHead.New(self, self.PanelHead) + self.XUiDormSecondHead:Init() + end +end + +-- 访问 +function XUiDormSecond:OnBtnVistorClick() + self.CurMenState = false + self:SetEnterState(self.CurMenState) + self.GameObject:SetActiveEx(false) + XLuaUiManager.Open("UiDormVisit", self) +end + +-- 图鉴 +function XUiDormSecond:OpenFieldGuid() + self.CurMenState = false + self:SetEnterState(self.CurMenState) + XLuaUiManager.Open("UiDormFieldGuide") +end + +-- 设置评分 +function XUiDormSecond:SetScore() + local scoreA, scoreB, scoreC + if DisplaySetType.MySelf == self.CurDisplayState then + scoreA, scoreB, scoreC = XDataCenter.DormManager.GetDormitoryScore(self.CurDormId) + else + scoreA, scoreB, scoreC = XDataCenter.DormManager.GetDormitoryScore(self.CurDormId, XDormConfig.DormDataType.Target) + end + + local indexA = AttrType.AttrA + local indexB = AttrType.AttrB + local indexC = AttrType.AttrC + local a = XFurnitureConfigs.GetFurnitureAttrLevelNewDescription(1, indexA, scoreA) + local b = XFurnitureConfigs.GetFurnitureAttrLevelNewDescription(1, indexB, scoreB) + local c = XFurnitureConfigs.GetFurnitureAttrLevelNewDescription(1, indexC, scoreC) + local totalScore = 0 + if DisplaySetType.MySelf == self.CurDisplayState then + local newFurnitureAttrs = XHomeDormManager.GetFurnitureScoresByRoomId(self.CurDormId) + totalScore = newFurnitureAttrs.TotalScore + else + local newFurnitureAttrs = XDataCenter.DormManager.GetDormitoryTargetScore(self.CurDormId) + if newFurnitureAttrs then + totalScore = newFurnitureAttrs.TotalScore + end + end + self.TxtScore.text = XFurnitureConfigs.GetFurnitureTotalAttrLevelNewColorDescription(1, totalScore) + self.TxtBeautifulNum.text = a + self.TxtComfortNum.text = b + self.TxtPracticalNum.text = c +end + +function XUiDormSecond:SetVisitState() + if DisplaySetType.MySelf == self.CurDisplayState then + self.PanelHomeSelf.gameObject:SetActiveEx(true) + self.PanelHomeOthers.gameObject:SetActiveEx(false) + self.BtnMenu.gameObject:SetActiveEx(true) + self.BtnVisitor.gameObject:SetActiveEx(true) + self.BtnAdd.gameObject:SetActiveEx(false) + self.BtnRemould.gameObject:SetActiveEx(true) + self.DormRename.gameObject:SetActiveEx(true) + return + end + + self.PanelHomeSelf.gameObject:SetActiveEx(false) + self.PanelHomeOthers.gameObject:SetActiveEx(true) + self.BtnRemould.gameObject:SetActiveEx(false) + self.BtnVisitor.gameObject:SetActiveEx(false) + self.BtnMenu.gameObject:SetActiveEx(false) + self.DormRename.gameObject:SetActiveEx(false) + if DisplaySetType.MyFriend == self.CurDisplayState then + self.BtnAdd.gameObject:SetActiveEx(false) + else + self.BtnAdd.gameObject:SetActiveEx(true) + end +end + +function XUiDormSecond:OnStart(displaytype, dormId, playerId) + self:InitHead() + self:UpdateData(displaytype, dormId) + self:InitEventShow() + self.IsStatic = false + self.CurPlayerId = playerId + self.PanelBtn.gameObject:SetActiveEx(false) +end + +function XUiDormSecond:GetCurIndex(dormId) + if self.HostelNameDataList then + for index, v in pairs(self.HostelNameDataList) do + if v[2] == dormId then + return index + end + end + end + return 1 +end + +function XUiDormSecond:UpdateData(displaytype, dormId, playerId) + self.CurDisplayState = displaytype + self.CurDormId = dormId + self.CurPlayerId = playerId + self:SetScore() + self:SetVisitState() + self:SetHostelNameClick() + self:SetCurHostelList() + self:SetTemplateInfo() + + self.XUiDormSecondHead:Refresh(self.CurDormId) + self:ShowPanelHead(true) + + self.CurIndex = self:GetCurIndex(dormId) + + if DisplaySetType.MySelf ~= self.CurDisplayState then + self.BgmShowState = false + self.MusicPlayer.gameObject:SetActiveEx(self.BgmShowState) + end + + self.DormBgm:UpdateBgmList(dormId, self.CurDisplayState == DisplaySetType.MySelf) +end + +function XUiDormSecond:SkipDormUpdateData(dormId) + self:UpdateData(DisplaySetType.MySelf, dormId) +end + +function XUiDormSecond:OnRecordSelfDormId() + SelfPreDormId = self.CurDormId +end + +function XUiDormSecond:OnEnable() + self.BtnPanelTask.CallBack = self.OnBtnTaskTipsClickCb + self:SetScore() + XDataCenter.DormManager.GetNextShowEvent() + self:OnPlayAnimation() + XDataCenter.DormManager.StartDormRedTimer() + + local types = XRedPointConditions.Types + XRedPointManager.AddRedPointEvent(self.BtnTask.ReddotObj, self.RefreshTaskTabRedDot, self, { types.CONDITION_DORM_MAIN_TASK_RED }) + XRedPointManager.AddRedPointEvent(self.BtnMenu.ReddotObj, self.OnCheckBuildFurniture, self, { types.CONDITION_FURNITURE_CREATE }) + + self:RefreshTaskInfo() + self.SkipFun = self.SkipDormUpdateData + XEventManager.AddEventListener(XEventId.EVENT_DORM_SKIP, self.SkipFun, self) + XEventManager.AddEventListener(XEventId.EVENT_CARESS_SHOW, self.OnCaressShow, self) + XEventManager.AddEventListener(XEventId.EVENT_DORM_TOUCH_HIDE, self.OnCaressHide, self) + XEventManager.AddEventListener(XEventId.EVENT_DORM_TOUCH_ENTER, self.OnOpenedCaress, self) + XEventManager.AddEventListener(XEventId.EVENT_DORM_SHOW_EVENT_CHANGE, self.OnOpenEventShow, self) + self.DormBgm:ResetBgmList(self.CurDormId, DisplaySetType.MySelf == self.CurDisplayState) + self:SetTemplateInfo() + self:PlayAnimation("MusicPlayerQieHuan") +end + +function XUiDormSecond:OnCaressHide() + if self.CurInfoState then + self:BtnHideCb() + else + self:BtnScreenShotCb() + end +end + +function XUiDormSecond:RefreshTaskTabRedDot(count) + self.BtnTask:ShowReddot(count >= 0) + self:RefreshTaskInfo() +end + +function XUiDormSecond:RefreshTaskInfo() + local data, tasktype, state = XDataCenter.TaskManager.GetDormTaskTips() + if data and tasktype and state then + self.CurTaskData = data + self.TaskType = tasktype + local config = XDataCenter.TaskManager.GetTaskTemplate(data.Id) + self.CurTaskTagState = state == XDataCenter.TaskManager.TaskState.Achieved + if self.CurTaskTagState then + self.BtnPanelTask:SetName(string.format("%s", Blue, config.Desc)) + else + self.BtnPanelTask:SetName(string.format("%s", White, config.Desc)) + end + self.BtnPanelTask:ShowTag(not self.CurTaskTagState) + self.BtnPanelTask:ShowReddot(self.CurTaskTagState) + else + self.CurTaskData = nil + self.PanelTask.gameObject:SetActiveEx(false) + end +end + +function XUiDormSecond:PlayBgmMusic(show, bgmConfig) + self.BgmShowState = show + + if DisplaySetType.MySelf ~= self.CurDisplayState then + self.BgmShowState = false + else + CS.UnityEngine.PlayerPrefs.SetInt(tostring(self.CurDormId), bgmConfig.BgmId) + end + + self:PlayAnimation("MusicPlayerQieHuan") + self.MusicPlayer.gameObject:SetActiveEx(self.BgmShowState) + CS.XAudioManager.PlayMusic(bgmConfig.BgmId) + + XHomeDormManager.DormBgm[self.CurDormId] = bgmConfig +end + + +function XUiDormSecond:OnCheckBuildFurniture(count) + local red = count >= 0 + self.BtnMenu:ShowReddot(red) + if self.EnterBtns[DormSecondEnter.Build] then + self.EnterBtns[DormSecondEnter.Build]:ShowReddot(red) + end +end + +function XUiDormSecond:OnDisable() + self.BtnPanelTask.CallBack = nil + XDataCenter.DormManager.StopDormRedTimer() + self.CurHostelNamesState = false + self:SetDormListNameV(self.CurHostelNamesState) + XEventManager.RemoveEventListener(XEventId.EVENT_DORM_SKIP, self.SkipFun, self) + XEventManager.RemoveEventListener(XEventId.EVENT_CARESS_SHOW, self.OnCaressShow, self) + XEventManager.RemoveEventListener(XEventId.EVENT_DORM_TOUCH_HIDE, self.OnCaressHide, self) + XEventManager.RemoveEventListener(XEventId.EVENT_DORM_TOUCH_ENTER, self.OnOpenedCaress, self) + XEventManager.RemoveEventListener(XEventId.EVENT_DORM_SHOW_EVENT_CHANGE, self.OnOpenEventShow, self) + self.DormBgm:OnDisable() + +end + +function XUiDormSecond:OnCaressShow() + self.BtnScreenShot.gameObject:SetActiveEx(true) + self.BtnHide.gameObject:SetActiveEx(false) +end + +-- 爱抚(打开) +function XUiDormSecond:OnOpenedCaress(characterId) + self.PanelHostelName.gameObject:SetActiveEx(false) + self.PanelCaress.gameObject:SetActiveEx(true) + self.BtnRemould.gameObject:SetActiveEx(false) + self.BtnVisitor.gameObject:SetActiveEx(false) + self.PanelMenu.gameObject:SetActiveEx(false) + self.BtnTask.gameObject:SetActiveEx(false) + self.BtnRename.gameObject:SetActiveEx(false) + self.BtnBack.gameObject:SetActiveEx(false) + self.DormBgm.GameObject:SetActiveEx(false) + self.BtnHelp.gameObject:SetActiveEx(false) + self.TopInfos.gameObject:SetActiveEx(false) + self.BtnCollect.gameObject:SetActiveEx(false) + self.BtnDormShare.gameObject:SetActiveEx(false) + self.BtnDormTemplate.gameObject:SetActiveEx(false) + + if not self.InitCaress then + self.InitCaress = true + self.PanelCaressUI = XUiDormCaress.New(self, self.PanelCaress) + end + self:PlayAnimation("PanelCaressEnable") + self.PanelCaressUI:Show(characterId, self.CurDormId) +end + +-- 爱抚(关闭) +function XUiDormSecond:OnCloseedCaress() + self:PlayAnimation("PanelCaressDisable", function() + self.PanelCaressDisable.extrapolationMode = 2 + end) + self.PanelHostelName.gameObject:SetActiveEx(true) + self.PanelCaress.gameObject:SetActiveEx(false) + self.BtnRemould.gameObject:SetActiveEx(true) + self.BtnVisitor.gameObject:SetActiveEx(true) + self.PanelMenu.gameObject:SetActiveEx(true) + self.BtnTask.gameObject:SetActiveEx(true) + self.BtnRename.gameObject:SetActiveEx(true) + self.BtnBack.gameObject:SetActiveEx(true) + self.DormBgm.GameObject:SetActiveEx(true) + self.BtnHelp.gameObject:SetActiveEx(true) + self.TopInfos.gameObject:SetActiveEx(true) + self.BtnCollect.gameObject:SetActiveEx(true) + self.BtnDormShare.gameObject:SetActiveEx(false)--海外特供屏蔽宿舍分享按钮 + self.BtnDormTemplate.gameObject:SetActiveEx(true) + self.PanelCaressUI:OnClose(self.CurDormId) +end + +function XUiDormSecond:OnOpenEventShow(data) + self.EventShow:Show(data) +end + +function XUiDormSecond:OnBtnTaskTipsClick() + if self.CurTaskData and not self.CurTaskTagState then + self:OnTaskSkip() + return + end + + local tab + if self.CurTaskTagState then + if self.TaskType == XDataCenter.TaskManager.TaskType.DormNormal then + tab = XTaskConfig.PANELINDEX.Story + else + tab = XTaskConfig.PANELINDEX.Daily + end + end + self:OnOpenTask(tab) +end + +function XUiDormSecond:OnOpenTask(tab) + XLuaUiManager.Open("UiDormTask", tab) + self.IsStatic = true +end + +function XUiDormSecond:OnBtnTaskClick() + self:OnOpenTask() +end + +function XUiDormSecond:OnTaskSkip() + if XDataCenter.RoomManager.RoomData ~= nil then + local title = CS.XTextManager.GetText("TipTitle") + local cancelMatchMsg = CS.XTextManager.GetText("OnlineInstanceQuitRoom") + XUiManager.DialogTip(title, cancelMatchMsg, XUiManager.DialogType.Normal, nil, function() + XLuaUiManager.RunMain() + local skipId = XDataCenter.TaskManager.GetTaskTemplate(self.CurTaskData.Id).SkipId + XFunctionManager.SkipInterface(skipId) + end) + else + local skipId = XDataCenter.TaskManager.GetTaskTemplate(self.CurTaskData.Id).SkipId + XFunctionManager.SkipInterface(skipId) + end +end + +function XUiDormSecond:AddListener() + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUIClick) + self:RegisterClickEvent(self.BtnBack, self.OnBtnReturnClick) + self:RegisterClickEvent(self.BtnMenu, self.OnBtnMenuClick) + self:RegisterClickEvent(self.BtnVisitor, self.OnBtnVistorClick) + self:RegisterClickEvent(self.BtnClick, self.OnBtnHostelNamesClick) + self:RegisterClickEvent(self.BtnSkipClick, self.OnBtnMenuHide) + self:RegisterClickEvent(self.BtnRemould, self.OnBtnRemouldClick) + self:RegisterClickEvent(self.BtnAdd, self.OnBtnAddClick) + self:RegisterClickEvent(self.BtnRight, self.OnBtnRightClick) + self:RegisterClickEvent(self.BtnLeft, self.OnBtnLeftClick) + self:RegisterClickEvent(self.BtnTask, self.OnBtnTaskClick) + self.BtnScreenShot.CallBack = function() self:BtnScreenShotCb() end + self.BtnHide.CallBack = function() self:BtnHideCb() end + self.BtnExpandNormalTran = self.BtnExpand.NormalObj.transform +end + +function XUiDormSecond:BtnHideCb() + self.BtnHide.gameObject:SetActiveEx(false) + self.BtnScreenShot.gameObject:SetActiveEx(true) + self.MusicPlayer.gameObject:SetActiveEx(self.BgmShowState) + if self.PanelCaress.gameObject.activeSelf then + self.PanelCaressUI.BtnBack.gameObject:SetActiveEx(true) + self:PlayAnimation("CaressBtnEnable", function() + if DisplaySetType.MySelf == self.CurDisplayState then + self.PanelHomeSelf.gameObject:SetActiveEx(true) + self.PanelHomeOthers.gameObject:SetActiveEx(false) + else + self.PanelHomeSelf.gameObject:SetActiveEx(false) + self.PanelHomeOthers.gameObject:SetActiveEx(true) + end + + XEventManager.DispatchEvent(XEventId.EVENT_DORM_EXP_SHOW) + end) + else + self:PlayAnimation("BtnEnable", function() + if DisplaySetType.MySelf == self.CurDisplayState then + self.PanelHomeSelf.gameObject:SetActiveEx(true) + self.PanelHomeOthers.gameObject:SetActiveEx(false) + self.BtnRename.gameObject:SetActiveEx(true) + else + self.PanelHomeSelf.gameObject:SetActiveEx(false) + self.PanelHomeOthers.gameObject:SetActiveEx(true) + self.BtnRename.gameObject:SetActiveEx(false) + end + self.CurInfoState = true + self.BtnHelp.gameObject:SetActiveEx(true) + self.BtnBack.gameObject:SetActiveEx(true) + self.TopInfos.gameObject:SetActiveEx(true) + self.PanelHostelName.gameObject:SetActiveEx(true) + self:ShowPanelHead(true) + + XEventManager.DispatchEvent(XEventId.EVENT_DORM_SECOND_STATE, true) + end) + end +end + +function XUiDormSecond:BtnScreenShotCb() + self.BtnHide.gameObject:SetActiveEx(true) + self.BtnScreenShot.gameObject:SetActiveEx(false) + if self.PanelCaress.gameObject.activeSelf then + self.PanelCaressUI.BtnBack.gameObject:SetActiveEx(false) + self:PlayAnimation("CaressBtnDisable", function() + self.PanelHomeSelf.gameObject:SetActiveEx(false) + self.PanelHomeOthers.gameObject:SetActiveEx(false) + self.BtnBack.gameObject:SetActiveEx(false) + self.BtnHelp.gameObject:SetActiveEx(false) + self.BtnRename.gameObject:SetActiveEx(false) + self.PanelHostelName.gameObject:SetActiveEx(false) + self.TopInfos.gameObject:SetActiveEx(false) + self.MusicPlayer.gameObject:SetActiveEx(false) + + XEventManager.DispatchEvent(XEventId.EVENT_DORM_EXP_HIDE) + end) + else + self:PlayAnimation("BtnDisable", function() + self.PanelHomeSelf.gameObject:SetActiveEx(false) + self.PanelHomeOthers.gameObject:SetActiveEx(false) + self.BtnBack.gameObject:SetActiveEx(false) + self.BtnHelp.gameObject:SetActiveEx(false) + self.BtnRename.gameObject:SetActiveEx(false) + self.PanelHostelName.gameObject:SetActiveEx(false) + self.TopInfos.gameObject:SetActiveEx(false) + self.MusicPlayer.gameObject:SetActiveEx(false) + self.CurInfoState = false + + self:ShowPanelHead(false) + end) + XEventManager.DispatchEvent(XEventId.EVENT_DORM_SECOND_STATE, false) + end +end + +function XUiDormSecond:OnBtnExpand() + self.CurScoreState = not self.CurScoreState + self.PanelScore.gameObject:SetActiveEx(self.CurScoreState) + self.PanelTool1.gameObject:SetActiveEx(not self.CurScoreState) + self.PanelTool2.gameObject:SetActiveEx(not self.CurScoreState) + self.PanelTool3.gameObject:SetActiveEx(not self.CurScoreState) + if self.CurScoreState then + self.BtnExpandNormalTran.localScale = V3OP + self.BtnClickTips.gameObject:SetActiveEx(false) + else + self.BtnExpandNormalTran.localScale = V3O + self.BtnClickTips.gameObject:SetActiveEx(true) + end +end + +function XUiDormSecond:ComfortTips() + if not CurrentSchedule then + self.TopTips.gameObject:SetActiveEx(true) + CurrentSchedule = XScheduleManager.ScheduleForever(function() self:ComfortTipsTimerCb() end, XDormConfig.DormComfortTime) + end +end + +function XUiDormSecond:ComfortTipsTimerCb() + self.TopTips.gameObject:SetActiveEx(false) + XScheduleManager.UnSchedule(CurrentSchedule) + CurrentSchedule = nil +end + +function XUiDormSecond:RemoveTimer()--退出时关闭定时器,防止访问不存在的物体 + if CurrentSchedule then + CS.XScheduleManager.UnSchedule(CurrentSchedule) + CurrentSchedule = nil + end +end + +function XUiDormSecond:OnBtnMenuHide() + if self.HostSecondSkipGo and self.CurMenState == true then + self.CurMenState = false + self:SetEnterState(self.CurMenState) + end +end + +function XUiDormSecond:OnBtnRightClick() + if self.HostelNameDataList and #self.HostelNameDataList <= 1 then + XUiManager.TipText("DormNoRoomsTips") + return + end + + local d = self.HostelNameDataList[self.CurIndex + 1] + if not d then + --到末了,从头开始 + self.CurIndex = 1 + d = self.HostelNameDataList[self.CurIndex] + self:UpdateData(self.CurDisplayState, d[2]) + XHomeDormManager.CharacterExit(self.CurDormId) + XHomeDormManager.SetSelectedRoom(self.CurDormId, true) + return + end + + if self.CurDormId == d[2] then + return + end + + self.CurIndex = self.CurIndex + 1 + self:UpdateData(self.CurDisplayState, d[2]) + XHomeDormManager.CharacterExit(self.CurDormId) + XHomeDormManager.SetSelectedRoom(self.CurDormId, true) +end + +function XUiDormSecond:OnBtnLeftClick() + if self.HostelNameDataList and #self.HostelNameDataList <= 1 then + XUiManager.TipText("DormNoRoomsTips") + return + end + + local d = self.HostelNameDataList[self.CurIndex - 1] + if not d then + --到末了,从头开始 + self.CurIndex = #self.HostelNameDataList + d = self.HostelNameDataList[self.CurIndex] + self:UpdateData(self.CurDisplayState, d[2]) + XHomeDormManager.CharacterExit(self.CurDormId) + XHomeDormManager.SetSelectedRoom(self.CurDormId, true) + return + end + + if self.CurDormId == d[2] then + return + end + + self.CurIndex = self.CurIndex - 1 + self:UpdateData(self.CurDisplayState, d[2]) + XHomeDormManager.CharacterExit(self.CurDormId) + XHomeDormManager.SetSelectedRoom(self.CurDormId, true) +end + +function XUiDormSecond:OnBtnNextClick() + if self.CurNextState then + local nextDormId, flag = XDataCenter.DormManager.GetDormitoryRecommendDataForNext(self.CurDormId) + self.CurNextState = not flag + self:UpdateData(DisplaySetType.Stranger, nextDormId) + return + end + + local preDormId, flag = XDataCenter.DormManager.GetDormitoryRecommendDataForPre(self.CurDormId) + self.CurNextState = flag + self:UpdateData(DisplaySetType.Stranger, preDormId) +end + +function XUiDormSecond:OnBtnAddClick() + local data = XDataCenter.DormManager.GetDormitoryData(XDormConfig.DormDataType.Target) + + if not data then + return + end + + local dormdata = data[self.CurDormId] + local title = CS.XTextManager.GetText("TipTitle") + local des = CS.XTextManager.GetText("DormVisitorFirend", dormdata.PlayerName) + XUiManager.DialogTip(title, des, XUiManager.DialogType.Normal, nil, function() + XDataCenter.SocialManager.ApplyFriend(dormdata.PlayerId) + end) +end + +function XUiDormSecond:OnBtnHostelNamesClick() + if self.HostelNameDataList and #self.HostelNameDataList <= 1 then + return + end + + self.CurHostelNamesState = not self.CurHostelNamesState + self:SetDormListNameV(self.CurHostelNamesState) +end + +function XUiDormSecond:OnBtnRemouldClick() + XLuaUiManager.Open("UiFurnitureReform", self.CurDormId, XDormConfig.DormDataType.Self) +end + +function XUiDormSecond:OnBtnMainUIClick() + XEventManager.DispatchEvent(XEventId.EVENT_DORM_CLOSE_COMPONET) + self:RemoveTimer() + XLuaUiManager.RunMain() + XHomeSceneManager.LeaveScene() +end + +function XUiDormSecond:OnBtnReturnClick() + self:RemoveTimer() + if not XLuaUiManager.IsUiLoad("UiDormMain") then + XHomeSceneManager.LeaveScene() + XEventManager.DispatchEvent(XEventId.EVENT_DORM_CLOSE_COMPONET) + self:Close() + return + end + + if self.CurDisplayState == DisplaySetType.MySelf then + XHomeDormManager.SetSelectedRoom(self.CurDormId, false) + self:Close() + else + --从其他人宿舍返回自己宿舍,把自己的数据切回来。 + if SelfPreDormId == -1 then + local data = XDataCenter.DormManager.GetDormitoryData(XDormConfig.DormDataType.Self) + if data then + for _, v in pairs(data) do + if v and v.Id then + SelfPreDormId = v.Id + break + end + end + end + end + XDataCenter.DormManager.VisitDormitory(DisplaySetType.MySelf, SelfPreDormId) + self:UpdateData(DisplaySetType.MySelf, SelfPreDormId) + self.CurHostelNamesState = false + self:SetDormListNameV(self.CurHostelNamesState) + end + + XEventManager.DispatchEvent(XEventId.EVENT_DORM_HIDE_COMPONET) +end + +function XUiDormSecond:OnBtnMenuClick() + if self.HostSecondSkipGo then + self.CurMenState = not self.CurMenState + self:SetEnterState(self.CurMenState) + end +end + +function XUiDormSecond:SetEnterState(state) + if self.HostSecondSkipGo then + self.HostSecondSkipGo.gameObject:SetActiveEx(state) + if state then + self:PlayAnimation("CaiDanEnable") + else + self:PlayAnimation("CaiDanDisable") + end + if not state or self.InitEnter then + return + end + self.InitEnter = true + for k, _ in pairs(self.EnterCfg) do + local obj = Object.Instantiate(self.HostSecondSkipItem.gameObject) + obj.transform:SetParent(self.HostSecondSkipList, false) + obj.transform.localScale = V3O + obj.gameObject:SetActiveEx(true) + obj.gameObject.name = self.EnterCfg[k].Name + local btn = obj:GetComponent("XUiButton") + btn:SetName(self.EnterCfg[k].Name) + btn:SetSprite(self.EnterCfg[k].IconPath) + self:RegisterClickEvent(obj, self.EnterCfg[k].Skip) + self.EnterBtns[k] = btn + end + end +end + +function XUiDormSecond:OnPlayAnimation() + local delay = 0 + if not self.IsStatic then + self.IsStatic = true + delay = XDormConfig.DormSecondAnimationDelayTime + end + + if delay > 0 then + self.DormWorkTimer = XScheduleManager.ScheduleOnce(function() + if self.PanelBtn then + self.PanelBtn.gameObject:SetActiveEx(true) + end + if XLuaUiManager.IsUiShow("UiDormSecond") then + self:PlayAnimation("AnimStartEnable") + end + XScheduleManager.UnSchedule(self.DormWorkTimer) + end, delay) + else + self:PlayAnimation("AnimStartEnable") + end +end + +function XUiDormSecond:ShowPanelHead(isShow) + --如果不是进入自己的宿舍不显示 + if DisplaySetType.MySelf ~= self.CurDisplayState then + self.PanelHead.gameObject:SetActiveEx(false) + else + self.PanelHead.gameObject:SetActiveEx(isShow) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormSecond/XUiDormSecondHead.lua b/Resources/Scripts/XUi/XUiDormSecond/XUiDormSecondHead.lua new file mode 100644 index 00000000..209f821e --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormSecond/XUiDormSecondHead.lua @@ -0,0 +1,175 @@ +local XUiDormSecondHead = XClass(XLuaBehaviour, "XUiDormSecondHead") +local MAXPERSON = 3 + +function XUiDormSecondHead:Ctor(uiRoot, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + + self.characterData = {} + + XTool.InitUiObject(self) +end + +function XUiDormSecondHead:Init() + XEventManager.AddEventListener(XEventId.EVENT_DORM_EXP_DETAIL_SHOW, self.OnExpDetailShow, self) + XEventManager.AddEventListener(XEventId.EVENT_DORM_TOUCH_ENTER, self.OnTouchEnter, self) + XEventManager.AddEventListener(XEventId.EVENT_DORM_TOUCH_HIDE, self.OnTouchHide, self) + XEventManager.AddEventListener(XEventId.EVENT_CHARACTER_CHANGE_ROOM_CHARACTER, self.OnChangeRoomCharacter, self) + CsXGameEventManager.Instance:RegisterEvent(XEventId.EVENT_HOME_CHARACTER_STATUS_CHANGE, handler(self, self.OnChangeState)) + + for i=1,MAXPERSON do + self.UiRoot:RegisterClickEvent(self["Head" .. i], function() + self:OnBtnHeadClick(i) + end) + end + + for i=1,MAXPERSON do + self.UiRoot:RegisterClickEvent(self["BtnTouch" .. i], function() + self:OnBtnTouchClick(i) + end) + end +end + +function XUiDormSecondHead:OnDestroy() + XEventManager.RemoveEventListener(XEventId.EVENT_DORM_EXP_DETAIL_SHOW, self.OnExpDetailShow, self) + XEventManager.RemoveEventListener(XEventId.EVENT_DORM_TOUCH_ENTER, self.OnTouchEnter, self) + XEventManager.RemoveEventListener(XEventId.EVENT_DORM_TOUCH_HIDE, self.OnTouchHide, self) + XEventManager.RemoveEventListener(XEventId.EVENT_CHARACTER_CHANGE_ROOM_CHARACTER, self.OnChangeRoomCharacter, self) + CsXGameEventManager.Instance:RemoveEvent(XEventId.EVENT_HOME_CHARACTER_STATUS_CHANGE, handler(self, self.OnChangeState)) + + self:RemoveTimer() +end + +--@region 事件处理相关 + +function XUiDormSecondHead:OnBtnHeadClick(i) + local character = self.characterData[i] + if character then + if not XDataCenter.DormManager.IsWorking(character.CharacterId) then + local activeCharacter = XHomeCharManager.GetActiveCharacter(character.CharacterId) + if activeCharacter then + --角色被点击时先处理OnPointerDown,再处理OnClick,跳过PointerDown可能会导致角色行为状态不能成功改变 + activeCharacter:OnPointerDown() + activeCharacter:OnClick() + --点击先默认将红点消掉 + self["Head" .. i]:ShowReddot(false) + end + end + end +end + +function XUiDormSecondHead:OnBtnTouchClick(i) + local character = self.characterData[i] + XEventManager.DispatchEvent(XEventId.EVENT_DORM_HEAD_TOUCH, self.CharacterId) +end + +--通过监听来显示抚摸按钮,因为不一定总是能抚摸 +function XUiDormSecondHead:OnExpDetailShow(characterId, transform) + local index = self:GetIndexByCharacterId(characterId) + if index then + --保证只出现一个抚摸按钮 + for i=1,MAXPERSON do + self["BtnTouch" .. i].gameObject:SetActiveEx(index == i) + end + + self:RemoveTimer() + self.Timer = XScheduleManager.ScheduleOnce(function() + self["BtnTouch" .. index].gameObject:SetActiveEx(false) + end, XDormConfig.DISPPEAR_TIME) + end +end + +function XUiDormSecondHead:OnTouchEnter(characterId) + local index = self:GetIndexByCharacterId(characterId) + if index then + self["BtnTouch" .. index].gameObject:SetActiveEx(false) + end + + self.GameObject:SetActive(false) +end + +function XUiDormSecondHead:OnTouchHide() + self.GameObject:SetActive(true) +end + +function XUiDormSecondHead:OnChangeState(_, args) + local characterId = args[0] + local index = self:GetIndexByCharacterId(characterId) + if index then + self["Head" .. index]:ShowReddot(self:IsHaveCharacterEvent(characterId)) + end +end + +function XUiDormSecondHead:OnChangeRoomCharacter(characterIds) + if self.dormId then + self:Refresh(self.dormId) + end +end + +--@endregion + +--@region 逻辑处理 + +function XUiDormSecondHead:Refresh(dormId) + self.dormId = dormId + self.characterData = self:GetCharacterData(dormId) + + for i=1,MAXPERSON do + local character = self.characterData[i] + local btn = self["Head" .. i] + if character then + btn.gameObject:SetActiveEx(true) + + local iconpath = XDormConfig.GetCharacterStyleConfigQSIconById(character.CharacterId) + if iconpath then + self.UiRoot:SetUiSprite(self["ImgHead" .. i], iconpath) + end + + btn:ShowReddot(self:IsHaveCharacterEvent(character.CharacterId)) + + self["PanelWorking" .. i].gameObject:SetActiveEx(XDataCenter.DormManager.IsWorking(character.CharacterId)) + else + btn.gameObject:SetActiveEx(false) + end + end +end + +function XUiDormSecondHead:GetCharacterData(dormId) + local data = XDataCenter.DormManager.GetRoomDataByRoomId(self.dormId) + if data then + return data:GetCharacter() or {} + end +end + +function XUiDormSecondHead:GetIndexByCharacterId(characterId) + for i,v in ipairs(self.characterData) do + if v.CharacterId == characterId then + return i + end + end +end + +function XUiDormSecondHead:RemoveTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end + +function XUiDormSecondHead:IsHaveCharacterEvent(characterId) + local eventTemp = XHomeCharManager.GetCharacterEvent(characterId, true) + if eventTemp then + if eventTemp.BehaviorId == XHomeBehaviorStatus.REWAWRD + or eventTemp.BehaviorId == XHomeBehaviorStatus.BORING + or eventTemp.BehaviorId == XHomeBehaviorStatus.WANTTOUCH then + return true + end + end + + return false +end + +--@endregion + +return XUiDormSecondHead \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormSecond/XUiGridLikeInfo.lua b/Resources/Scripts/XUi/XUiDormSecond/XUiGridLikeInfo.lua new file mode 100644 index 00000000..39b7ce83 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormSecond/XUiGridLikeInfo.lua @@ -0,0 +1,17 @@ +local XUiGridLikeInfo = XClass(nil, "XUiGridLikeInfo") + +function XUiGridLikeInfo:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiGridLikeInfo:Refresh(config) + local charLevelConfig = XDataCenter.DormManager.GetCharRecoveryCurLevel(config.CharacterId) + local isCur = charLevelConfig and charLevelConfig.Pre == config.Pre + self.ImgNormal.gameObject:SetActive(not isCur) + self.ImgCurrent.gameObject:SetActive(isCur) + self.TxtDesc.text = config.Description +end + +return XUiGridLikeInfo \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormSecond/XUiPanelEventShow.lua b/Resources/Scripts/XUi/XUiDormSecond/XUiPanelEventShow.lua new file mode 100644 index 00000000..3900dd23 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormSecond/XUiPanelEventShow.lua @@ -0,0 +1,102 @@ +local XUiPanelEventShow = XClass(nil, "XUiPanelEventShow") + +local XScheduleManager = XScheduleManager +local WaitSecond = 3 +local SimpleFadeTimer = nil +local ComplexFadeTimer = nil + +function XUiPanelEventShow:Ctor(uiRoot, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + + XTool.InitUiObject(self) +end + +function XUiPanelEventShow:SetDefaultPoint() + local pos = self.Transform.localPosition + local targetPos = self.PanelTarget.localPosition + self.Transform.localPosition = CS.UnityEngine.Vector3(targetPos.x, pos.y, 0) +end + +function XUiPanelEventShow:Show(data) + self.ShowConfig = XDormConfig.GetCharacterShowEvent(data.EventId) + if self.ShowConfig.ShowType <= 0 then + self:GetNextShowEvent() + return + end + + if self.ShowConfig.ShowType == XDormConfig.ShowEffectType.Simple then + self:ShowSimple(data) + elseif self.ShowConfig.ShowType == XDormConfig.ShowEffectType.Complex then + self:ShowComplex(data) + end + + self.PanelEvenetShowSimple.gameObject:SetActive(self.ShowConfig.ShowType == XDormConfig.ShowEffectType.Simple) + self.PanelEvenetShowComplex.gameObject:SetActive(self.ShowConfig.ShowType == XDormConfig.ShowEffectType.Complex) + + if self.ShowConfig.ShowType == XDormConfig.ShowEffectType.Simple then + + self.UiRoot:PlayAnimation("EvenetShowSimpleEnable", function() + self:StopSimpleTimer() + SimpleFadeTimer = XScheduleManager.ScheduleOnce(function() + self.UiRoot:PlayAnimation("EvenetShowSimpleDisable", function() + self:GetNextShowEvent() + end) + end, 1000 * WaitSecond) + end) + + elseif self.ShowConfig.ShowType == XDormConfig.ShowEffectType.Complex then + + self.UiRoot:PlayAnimation("EvenetShowComplexEnable", function() + self:StopComplexTimer() + SimpleFadeTimer = XScheduleManager.ScheduleOnce(function() + self.UiRoot:PlayAnimation("EvenetShowComplexDisable", function() + self:GetNextShowEvent() + end) + end, 1000 * WaitSecond) + end) + end +end + +function XUiPanelEventShow:StopSimpleTimer() + if SimpleFadeTimer then + XScheduleManager.UnSchedule(SimpleFadeTimer) + SimpleFadeTimer = nil + end +end + +function XUiPanelEventShow:StopComplexTimer() + if ComplexFadeTimer then + XScheduleManager.UnSchedule(ComplexFadeTimer) + ComplexFadeTimer = nil + end +end + +function XUiPanelEventShow:OnEventShowDestroy() + self:StopSimpleTimer() + self:StopComplexTimer() +end + +function XUiPanelEventShow:ShowSimple(data) + self.TextDesc.text = CS.XTextManager.FormatString(self.ShowConfig.Description[1], math.abs(data.ChangeValue)) + local charStyleConfig = XDormConfig.GetCharacterStyleConfigById(data.CharacterId) + self.RawImage:SetRawImage(charStyleConfig.HeadIcon, nil, true) +end + +function XUiPanelEventShow:ShowComplex(data) + self.TextComplexDesc.text = CS.XTextManager.FormatString(self.ShowConfig.Description[1], math.abs(data.ChangeValue)) + self.TextComplexDesc2.text = self.ShowConfig.Description[2] + local charStyleConfig = XDormConfig.GetCharacterStyleConfigById(data.CharacterId) + self.RawComplexImage:SetRawImage(charStyleConfig.HeadIcon, nil, true) +end + +function XUiPanelEventShow:GetNextShowEvent() + XDataCenter.DormManager.GetNextShowEvent() +end + +function XUiPanelEventShow:EventShowAnimaStart(cb) + self.PanelEventShowTimeLine.gameObject:PlayTimelineAnimation(cb) +end + +return XUiPanelEventShow \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormSecond/XUiPanelFurnitureLike.lua b/Resources/Scripts/XUi/XUiDormSecond/XUiPanelFurnitureLike.lua new file mode 100644 index 00000000..816f91d0 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormSecond/XUiPanelFurnitureLike.lua @@ -0,0 +1,92 @@ +local XUiPanelFurnitureLike = XClass(nil, "XUiPanelFurnitureLike") + +function XUiPanelFurnitureLike:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + + self.OnBtnDetailClickCb = function() self:OnBtnDetailClick() end + self:InitAddListen() +end + +function XUiPanelFurnitureLike:InitAddListen() + self.RootUi:RegisterClickEvent(self.BtnDetail, self.OnBtnDetailClickCb) +end + +function XUiPanelFurnitureLike:OnBtnDetailClick() + XLuaUiManager.Open("UiDormCharacterLikeInfo", self.CharacterId) +end + +function XUiPanelFurnitureLike:Refresh(characterId, curRoomId) + self.CharacterId = characterId + + local curRecoveryConfig, nextRecoveryConfig = XDataCenter.DormManager.GetCharRecoveryConfigs(characterId) + local isMax = curRecoveryConfig == nil and nextRecoveryConfig ~= nil + self.TxtNextDesc.text = isMax and CS.XTextManager.GetText("DormMaxRecovery") or CS.XTextManager.GetText("DormNextRecovery2") + + local scoreA, scoreB, scoreC = XDataCenter.DormManager.GetDormitoryScore(curRoomId) + local allFurnitureAttrs = XHomeDormManager.GetFurnitureScoresByUnsaveRoom(curRoomId) + local allScores = allFurnitureAttrs.TotalScore + + local indexA = XFurnitureConfigs.AttrType.AttrA - 1 + local indexB = XFurnitureConfigs.AttrType.AttrB - 1 + local indexC = XFurnitureConfigs.AttrType.AttrC - 1 + + if nextRecoveryConfig then + local vitalitySpeed = XFurnitureConfigs.GetRecoverSpeed(nextRecoveryConfig.VitalityRecovery) + local moodSpeed = XFurnitureConfigs.GetRecoverSpeed(nextRecoveryConfig.MoodRecovery) + + local vContext = nextRecoveryConfig.VitalityRecoveryType > 0 and "DormVitalityRecovery1" or "DormVitalityRecovery" + local mContext = nextRecoveryConfig.MoodRecoveryType > 0 and "DormMoodRecovery1" or "DormMoodRecovery" + + self.TxtResume.text = CS.XTextManager.GetText(vContext, vitalitySpeed) + self.TxtMoodResume.text = CS.XTextManager.GetText(mContext, moodSpeed) + + if nextRecoveryConfig.AttrTotal > 0 then + self.PanelAll.gameObject:SetActive(true) + self.TxtAllScore.gameObject:SetActive(allScores >= nextRecoveryConfig.AttrTotal) + self.TxtAllScore.text = "≥" .. nextRecoveryConfig.AttrTotal + + self.TxtAllDisScore.gameObject:SetActive(allScores < nextRecoveryConfig.AttrTotal) + self.TxtAllDisScore.text = "≥" .. nextRecoveryConfig.AttrTotal + else + self.PanelAll.gameObject:SetActive(false) + end + + if nextRecoveryConfig.AttrCondition[indexA] > 0 then + self.PanelRed.gameObject:SetActive(true) + self.TxtRedScore.gameObject:SetActive(scoreA >= nextRecoveryConfig.AttrCondition[indexA]) + self.TxtRedScore.text = "≥" .. nextRecoveryConfig.AttrCondition[indexA] + + self.TxtRedDisScore.gameObject:SetActive(scoreA < nextRecoveryConfig.AttrCondition[indexA]) + self.TxtRedDisScore.text = "≥" .. nextRecoveryConfig.AttrCondition[indexA] + else + self.PanelRed.gameObject:SetActive(false) + end + + if nextRecoveryConfig.AttrCondition[indexB] > 0 then + self.PanelYellow.gameObject:SetActive(true) + self.TxtYellowScore.gameObject:SetActive(scoreB >= nextRecoveryConfig.AttrCondition[indexB]) + self.TxtYellowScore.text = "≥" .. nextRecoveryConfig.AttrCondition[indexB] + + self.TxtYellowDisScore.gameObject:SetActive(scoreB < nextRecoveryConfig.AttrCondition[indexB]) + self.TxtYellowDisScore.text = "≥" .. nextRecoveryConfig.AttrCondition[indexB] + else + self.PanelYellow.gameObject:SetActive(false) + end + + if nextRecoveryConfig.AttrCondition[indexC] > 0 then + self.PanelBlue.gameObject:SetActive(true) + self.TxtBlueScore.gameObject:SetActive(scoreC >= nextRecoveryConfig.AttrCondition[indexC]) + self.TxtBlueScore.text = "≥" .. nextRecoveryConfig.AttrCondition[indexC] + + self.TxtBlueDisScore.gameObject:SetActive(scoreC < nextRecoveryConfig.AttrCondition[indexC]) + self.TxtBlueDisScore.text = "≥" .. nextRecoveryConfig.AttrCondition[indexC] + else + self.PanelBlue.gameObject:SetActive(false) + end + end +end + +return XUiPanelFurnitureLike \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormTask/XUiDormTask.lua b/Resources/Scripts/XUi/XUiDormTask/XUiDormTask.lua new file mode 100644 index 00000000..68d1d5bb --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormTask/XUiDormTask.lua @@ -0,0 +1,129 @@ +local XUiDormTask = XLuaUiManager.Register(XLuaUi, "UiDormTask") +local TextManager = CS.XTextManager +local PANEL_INDEX + +function XUiDormTask:OnAwake() + PANEL_INDEX = XTaskConfig.PANELINDEX + self:InitBtnSound() +end + +function XUiDormTask:OnStart(toggleType) + local lastSelectTab = XDataCenter.TaskManager.GetNewPlayerHint(XDataCenter.TaskManager.DormTaskLastSelectTab, PANEL_INDEX.Story) + self.CurToggleType = toggleType or lastSelectTab + self:Init() +end + +function XUiDormTask:OnEnable() + self:CheckTogLockStatus() + self.TabPanelGroup:SelectIndex(self.CurToggleType) + XEventManager.AddEventListener(XEventId.EVENT_TASK_SYNC, self.OnTaskChangeSync, self) +end + +function XUiDormTask:Init() + local itemId = XDataCenter.ItemManager.ItemId + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, itemId.FreeGem, itemId.ActionPoint, itemId.Coin) + self.BtnBack.CallBack = function() self:Close() end + self.BtnMainUi.CallBack = function() XLuaUiManager.RunMain() end + + self.BtnMoneyReward.gameObject:SetActiveEx(false) + + self.TogStory:SetNameByGroup(1, TextManager.GetText("DormTaskNText")) + self.TogDaily:SetNameByGroup(1, TextManager.GetText("DormTaskDText")) + + self.TaskStoryModule = XUiPanelDormTaskStory.New(self.PanelTaskStory, self) + self.TaskDailyModule = XUiPanelDormTaskDaily.New(self.PanelTaskDaily, self) + + self.TabList = {} + table.insert(self.TabList, self.TogStory) + table.insert(self.TabList, self.TogDaily) + self.TabPanelGroup:Init(self.TabList, function(index) self:OnTaskPanelSelect(index) end) + self:CheckTogLockStatus() + local lastSelectTab = XDataCenter.TaskManager.GetNewPlayerHint(XDataCenter.TaskManager.DormTaskLastSelectTab, PANEL_INDEX.Story) + self.CurToggleType = self.CurToggleType or lastSelectTab + -- 红点 + self:AddRedPointEvent() +end + +function XUiDormTask:CheckTogLockStatus() + + local uiButtonState = CS.UiButtonState + local functionName = XFunctionManager.FunctionName + local dailyBtnStatus = XFunctionManager.JudgeCanOpen(functionName.TaskDay) and uiButtonState.Normal or uiButtonState.Disable + self.TogDaily:SetButtonState(dailyBtnStatus) + + local activityBtnStatus = XFunctionManager.JudgeCanOpen(functionName.TaskActivity) and uiButtonState.Normal or uiButtonState.Disable + self.TogActivity:SetButtonState(activityBtnStatus) + +end + +function XUiDormTask:OnTaskChangeSync() + if self.CurToggleType == PANEL_INDEX.Story then + self.TaskStoryModule:Refresh() + elseif self.CurToggleType == PANEL_INDEX.Daily then + self.TaskDailyModule:Refresh() + end +end + +function XUiDormTask:OnDisable() + XEventManager.RemoveEventListener(XEventId.EVENT_TASK_SYNC, self.OnTaskChangeSync, self) +end + +function XUiDormTask:OnDestroy() + XDataCenter.TaskManager.UpdateViewCallback = nil + self.TaskDailyModule:StopSchedule() +end + +--添加点事件 +function XUiDormTask:AddRedPointEvent() + XRedPointManager.AddRedPointEvent(self.ImgStoryNewTag, self.RefreshStoryTabRedDot, self, { XRedPointConditions.Types.CONDITION_DORM_TASK }, XDataCenter.TaskManager.TaskType.DormNormal) + self.DailyPointId = XRedPointManager.AddRedPointEvent(self.ImgDailyNewTag, self.RefreshDailyTabRedDot, self, { XRedPointConditions.Types.CONDITION_DORM_TASK }, XDataCenter.TaskManager.TaskType.DormDaily) +end + +function XUiDormTask:CheckDailyTask() + if self.DailyPointId then + XRedPointManager.Check(self.DailyPointId, XDataCenter.TaskManager.TaskType.DormDaily) + end +end + +--剧情标签红点 +function XUiDormTask:RefreshStoryTabRedDot(count) + self.ImgStoryNewTag.gameObject:SetActive(count >= 0) +end + +--日常标签红点 +function XUiDormTask:RefreshDailyTabRedDot(count) + self.ImgDailyNewTag.gameObject:SetActive(count >= 0) +end + +function XUiDormTask:GetAutoKey(uiNode, eventName) + if not uiNode then + return + end + return eventName .. uiNode:GetHashCode() +end + +function XUiDormTask:InitBtnSound() + self.SpecialSoundMap = {} + self.SpecialSoundMap[self:GetAutoKey(self.BtnBack, "onClick")] = XSoundManager.UiBasicsMusic.Return + self.SpecialSoundMap[self:GetAutoKey(self.BtnMainUi, "onClick")] = XSoundManager.UiBasicsMusic.Return +end + +function XUiDormTask:OnTaskPanelSelect(index) + self.CurToggleType = index + if index == PANEL_INDEX.Story then + self.TaskDailyModule:HidePanel() + self.TaskStoryModule:ShowPanel() + XDataCenter.TaskManager.SaveNewPlayerHint(XDataCenter.TaskManager.DormTaskLastSelectTab, index) + self:PlayAnimation("StoryQieHuan") + + elseif index == PANEL_INDEX.Daily then + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.TaskDay) then + return + end + + self.TaskStoryModule:HidePanel() + self.TaskDailyModule:ShowPanel() + XDataCenter.TaskManager.SaveNewPlayerHint(XDataCenter.TaskManager.DormTaskLastSelectTab, index) + self:PlayAnimation("DailyQieHuan") + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormTask/XUiPanelDormTaskActivity.lua b/Resources/Scripts/XUi/XUiDormTask/XUiPanelDormTaskActivity.lua new file mode 100644 index 00000000..72299bfd --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormTask/XUiPanelDormTaskActivity.lua @@ -0,0 +1,42 @@ +XUiPanelDormTaskActivity = XClass(nil, "XUiPanelDormTaskActivity") + +function XUiPanelDormTaskActivity:Ctor(ui, parent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Parent = parent + XTool.InitUiObject(self) + + self.DynamicTable = XDynamicTableNormal.New(self.PanelTaskActivityList) + self.DynamicTable:SetProxy(XDynamicGridTask) + self.DynamicTable:SetDelegate(self) +end + +function XUiPanelDormTaskActivity:ShowPanel() + self.GameObject:SetActive(true) + + self.ActivityTasks = XDataCenter.TaskManager.GetActivityTaskList() + self.PanelNoneActivityTask.gameObject:SetActive(#self.ActivityTasks <= 0) + self.DynamicTable:SetDataSource(self.ActivityTasks) + self.DynamicTable:ReloadDataASync(1) +end + +function XUiPanelDormTaskActivity:HidePanel() + self.GameObject:SetActive(false) +end + +function XUiPanelDormTaskActivity:Refresh() + self.ActivityTasks = XDataCenter.TaskManager.GetActivityTaskList() + self.PanelNoneActivityTask.gameObject:SetActive(#self.ActivityTasks <= 0) + self.DynamicTable:SetDataSource(self.ActivityTasks) + self.DynamicTable:ReloadDataASync() +end + + +--动态列表事件 +function XUiPanelDormTaskActivity:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.ActivityTasks[index] + grid.RootUi = self.Parent + grid:ResetData(data) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormTask/XUiPanelDormTaskDaily.lua b/Resources/Scripts/XUi/XUiDormTask/XUiPanelDormTaskDaily.lua new file mode 100644 index 00000000..cf2584fd --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormTask/XUiPanelDormTaskDaily.lua @@ -0,0 +1,145 @@ +XUiPanelDormTaskDaily = XClass(nil, "XUiPanelDormTaskDaily") + +local DailyTimeSchedule = nil + +function XUiPanelDormTaskDaily:Ctor(ui, parent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Parent = parent + + XTool.InitUiObject(self) + self.BtnWeekActive.CallBack = function() self:OnBtnBackClick() end + + self:InitPanelActiveGrid() + self.ItemObjList = {} + + -- 自适应调整 + self.OriginPosition = self.PanelActiveGrids[1].Transform.localPosition + self.ActiveProgressRect = self.ImgDaylyActiveProgress:GetComponent("RectTransform") + self.ActiveProgressPosition = self.ImgDaylyActiveProgress.transform.localPosition + self.OffsetPanelPosition = self.PanelContent.localPosition + self.PanelDailyListRect = self.PanelTaskDailyList + + self:UpdateActiveness() + self:ShowDailyPanel() + + self.DynamicTable = XDynamicTableNormal.New(self.PanelTaskDailyList.gameObject) + self.DynamicTable:SetProxy(XDynamicDailyTask) + self.DynamicTable:SetDelegate(self) + + XRedPointManager.AddRedPointEvent(self.ImgWeek, self.CheckWeeKActiveRedDot, self, { XRedPointConditions.Types.CONDITION_TASK_WEEK_ACTIVE }) + XDataCenter.ItemManager.AddCountUpdateListener(XDataCenter.ItemManager.ItemId.DailyActiveness, function() + self:UpdateActiveness() + self.Parent:CheckDailyTask() + end, self.TxtDailyActive) +end + +--动态列表事件 +function XUiPanelDormTaskDaily:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.DailyTasks[index] + if data == nil then return end + grid.RootUi = self.Parent + grid:ResetData(data) + end +end + +-- +function XUiPanelDormTaskDaily:CheckWeeKActiveRedDot(count) + self.ImgWeek.gameObject:SetActive(count >= 0) +end + +function XUiPanelDormTaskDaily:InitPanelActiveGrid() + self.PanelActiveGrids = {} + self.PanelActiveGridRects = {} + for i = 1, 5, 1 do + local grid = self.PanelActiveGrids[i] + if not grid then + if i == 1 then + grid = XUiPanelActive.New(self.PanelActive, self.Parent, i, self) + else + local activeGO = CS.UnityEngine.Object.Instantiate(self.PanelActive) + activeGO.transform:SetParent(self.PanelContent, false) + grid = XUiPanelActive.New(activeGO, self.Parent, i, self) + end + self.PanelActiveGrids[i] = grid + self.PanelActiveGridRects[i] = grid.Transform:GetComponent("RectTransform") + end + end +end + +function XUiPanelDormTaskDaily:UpdateActiveness() + local dActiveness = XDataCenter.ItemManager.GetDailyActiveness().Count + local dailyActiveness = XTaskConfig.GetDailyActiveness() + self.ImgDaylyActiveProgress.fillAmount = dActiveness / XTaskConfig.GetDailyActivenessTotal() + self.TxtDailyActive.text = dActiveness + for i = 1, 5 do + self.PanelActiveGrids[i]:UpdateActiveness(dailyActiveness[i], dActiveness) + end + + -- 自适应 + local activeProgressRectSize = self.ActiveProgressRect.rect.size + local offsetWidth = self.OffsetPanelPosition.x - self.ActiveProgressPosition.x + local itemOffset = activeProgressRectSize.x / #self.PanelActiveGrids + for i = 1, #self.PanelActiveGrids do + local itemWidth = self.PanelActiveGridRects[i].sizeDelta.x / 2 + local x = self.ActiveProgressPosition.x + i * itemOffset - offsetWidth - itemWidth + local adjustPosition = CS.UnityEngine.Vector3(x, self.OriginPosition.y, self.OriginPosition.z) + self.PanelActiveGridRects[i].anchoredPosition3D = adjustPosition + end +end + +function XUiPanelDormTaskDaily:OnBtnBackClick() + self:ShowDailyPanel() +end + +function XUiPanelDormTaskDaily:ShowDailyPanel() + self.PanelDaily.gameObject:SetActive(true) +end + +function XUiPanelDormTaskDaily:ShowPanel() + self:StartSchedule() + self:UpdateActiveness() + self.GameObject:SetActive(true) + + local tasks = XDataCenter.TaskManager.GetDormTaskDailyListData() + self.DailyTasks = tasks + self.PanelNoneDailyTask.gameObject:SetActive(#self.DailyTasks <= 0) + self.DynamicTable:SetDataSource(tasks) + self.DynamicTable:ReloadDataASync() +end + +function XUiPanelDormTaskDaily:HidePanel() + self:StopSchedule() + self.GameObject:SetActive(false) +end + +function XUiPanelDormTaskDaily:Refresh() + self:UpdateActiveness() + local tasks = XDataCenter.TaskManager.GetDormTaskDailyListData() + self.DailyTasks = tasks + self.PanelNoneDailyTask.gameObject:SetActive(#self.DailyTasks <= 0) + self.DynamicTable:SetDataSource(tasks) + self.DynamicTable:ReloadDataASync() +end + +function XUiPanelDormTaskDaily:StartSchedule() + self:StopSchedule() + DailyTimeSchedule = XScheduleManager.ScheduleForever(function() + if self.DynamicTable then + for i = 1, #self.DailyTasks do + local grid = self.DynamicTable:GetGridByIndex(i) + if grid then + grid:UpdateTimes() + end + end + end + end, 1000 * 60) +end + +function XUiPanelDormTaskDaily:StopSchedule() + if DailyTimeSchedule then + XScheduleManager.UnSchedule(DailyTimeSchedule) + DailyTimeSchedule = nil + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormTask/XUiPanelDormTaskStory.lua b/Resources/Scripts/XUi/XUiDormTask/XUiPanelDormTaskStory.lua new file mode 100644 index 00000000..50143d29 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormTask/XUiPanelDormTaskStory.lua @@ -0,0 +1,43 @@ +XUiPanelDormTaskStory = XClass(nil, "XUiPanelDormTaskStory") + +function XUiPanelDormTaskStory:Ctor(ui, parent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Parent = parent + XTool.InitUiObject(self) + self.DynamicTable = XDynamicTableNormal.New(self.PanelTaskStoryList.gameObject) + self.DynamicTable:SetProxy(XDynamicGridTask) + self.DynamicTable:SetDelegate(self) +end + +--动态列表事件 +function XUiPanelDormTaskStory:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.StoryTasks[index] + grid.RootUi = self.Parent + grid:ResetData(data) + end +end + +function XUiPanelDormTaskStory:ShowPanel() + self.GameObject:SetActive(true) + self.PanelTaskStoryList.gameObject:SetActive(true) + + self.StoryTasks = XDataCenter.TaskManager.GetDormTaskStoryListData() + local len = #self.StoryTasks + self.PanelNoneStoryTask.gameObject:SetActive(len <= 0) + self.DynamicTable:SetDataSource(self.StoryTasks) + self.DynamicTable:ReloadDataSync() +end + +function XUiPanelDormTaskStory:HidePanel() + self.GameObject:SetActive(false) +end + +function XUiPanelDormTaskStory:Refresh() + self.StoryTasks = XDataCenter.TaskManager.GetDormTaskStoryListData() + local len = #self.StoryTasks + self.PanelNoneStoryTask.gameObject:SetActive(len <= 0) + self.DynamicTable:SetDataSource(self.StoryTasks) + self.DynamicTable:ReloadDataSync() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormTemplate/XUiDormTemplate.lua b/Resources/Scripts/XUi/XUiDormTemplate/XUiDormTemplate.lua new file mode 100644 index 00000000..2fae6722 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormTemplate/XUiDormTemplate.lua @@ -0,0 +1,139 @@ +local XUiDormTemplate = XLuaUiManager.Register(XLuaUi, "UiDormTemplate") +local XUiGridDormTemplate = require("XUi/XUiDormTemplate/XUiGridDormTemplate") +local DEFLUAT_INDEX = 1 + +function XUiDormTemplate:OnAwake() + self:AddListener() + self:BtnTableDisable() +end + +function XUiDormTemplate:OnStart(selectIndex, enterSenceCb, curDormId) + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, + XDataCenter.ItemManager.ItemId.DormCoin, + XDataCenter.ItemManager.ItemId.FurnitureCoin, + XDataCenter.ItemManager.ItemId.DormEnterIcon) + + self.EnterSenceCb = enterSenceCb + self.CurSelectIndex = selectIndex or DEFLUAT_INDEX + self.CurDormId = curDormId + self:InitDynamicTable() + self:SetTog() +end + +function XUiDormTemplate:OnEnable() + self:OnSelectedTog(self.CurSelectIndex) +end + +function XUiDormTemplate:AddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:BindHelpBtn(self.BtnHelp, "DormTemplate") +end + +function XUiDormTemplate:BtnTableDisable() + self.BtnFirst.gameObject:SetActiveEx(false) + self.BtnFirstHasSnd.gameObject:SetActiveEx(false) + self.BtnSecondTop.gameObject:SetActiveEx(false) + self.BtnSecond.gameObject:SetActiveEx(false) + self.BtnSecondBottom.gameObject:SetActiveEx(false) + self.BtnSecondAll.gameObject:SetActiveEx(false) +end + +function XUiDormTemplate:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiDormTemplate:OnBtnBackClick() + self:Close() +end + +function XUiDormTemplate:SetTog() + self.InfoList = XDormConfig.GetDormTemplateGroupList() + self.BtnGoList = {} + for _, info in ipairs(self.InfoList) do + local btn + if info.SecondIndex <= 0 then + if info.HasScond then + btn = CS.UnityEngine.Object.Instantiate(self.BtnFirstHasSnd.gameObject) + else + btn = CS.UnityEngine.Object.Instantiate(self.BtnFirst.gameObject) + end + else + if info.SecondTagType == XShopManager.SecondTagType.Top then + btn = CS.UnityEngine.Object.Instantiate(self.BtnSecondTop.gameObject) + elseif info.SecondTagType == XShopManager.SecondTagType.Mid then + btn = CS.UnityEngine.Object.Instantiate(self.BtnSecond.gameObject) + elseif info.SecondTagType == XShopManager.SecondTagType.Btm then + btn = CS.UnityEngine.Object.Instantiate(self.BtnSecondBottom.gameObject) + else + btn = CS.UnityEngine.Object.Instantiate(self.BtnSecondAll.gameObject) + end + end + + btn.gameObject.transform:SetParent(self.BtnTogs.gameObject.transform, false) + local uiButton = btn:GetComponent("XUiButton") + uiButton.SubGroupIndex = info.SecondIndex + uiButton:SetName(info.Name) + table.insert(self.BtnGoList, uiButton) + btn.gameObject:SetActiveEx(true) + end + + self.BtnTogs:Init(self.BtnGoList, function(index) + self:OnSelectedTog(index) + end) + + self.BtnTogs:SelectIndex(self.CurSelectIndex) +end + +function XUiDormTemplate:OnSelectedTog(index) + self:PlayAnimation("QieHuan") + + self.CurSelectIndex = index + local teamplateInfo = self.InfoList[index] + self.PageDatas = {} + self.RoomType = teamplateInfo.DormType + + if self.RoomType == XDormConfig.DormDataType.Template then + self.PageDatas = XDataCenter.DormManager.GetTemplateDormitoryData(XDormConfig.DormDataType.Template, teamplateInfo.DormId) + elseif self.RoomType == XDormConfig.DormDataType.Collect then + local datas = XDataCenter.DormManager.GetTemplateDormitoryData(XDormConfig.DormDataType.Collect) + local collectCfgs = XDormConfig.GetDormTemplateCollectList() + + for i = 1, #collectCfgs do + local tempDate = {} + if i > #datas then + tempDate.HomeRoomData = nil + else + tempDate.HomeRoomData = datas[i] + end + tempDate.CollectCfg = collectCfgs[i] + table.insert(self.PageDatas, tempDate) + end + end + + self:SetupDynamicTable() +end + +function XUiDormTemplate:InitDynamicTable() + self.GridDormTemplate.gameObject:SetActiveEx(false) + self.DynamicTable = XDynamicTableNormal.New(self.PanelDynamicTable) + self.DynamicTable:SetProxy(XUiGridDormTemplate) + self.DynamicTable:SetDelegate(self) +end + +function XUiDormTemplate:SetupDynamicTable() + self.DynamicTable:SetDataSource(self.PageDatas) + self.DynamicTable:ReloadDataSync(1) +end + +-- 动态列表事件 +function XUiDormTemplate:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + if self.RoomType == XDormConfig.DormDataType.Template then + grid:Refresh(self.PageDatas[index], self.RoomType, nil, self.EnterSenceCb, self.CurDormId) + elseif self.RoomType == XDormConfig.DormDataType.Collect then + local d = self.PageDatas[index] + grid:Refresh(d.HomeRoomData, self.RoomType, d.CollectCfg, self.EnterSenceCb) + end + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormTemplate/XUiDormTemplateDetail.lua b/Resources/Scripts/XUi/XUiDormTemplate/XUiDormTemplateDetail.lua new file mode 100644 index 00000000..d28035f4 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormTemplate/XUiDormTemplateDetail.lua @@ -0,0 +1,169 @@ +local XUiDormTemplateDetail = XLuaUiManager.Register(XLuaUi, "UiDormTemplateDetail") +local XUiGridTemplateDetail = require("XUi/XUiDormTemplate/XUiGridTemplateDetail") +local XUiPanelTemlateSelectRoom = require("XUi/XUiDormTemplate/XUiPanelTemlateSelectRoom") +local XUiPanelRefitQuick = require("XUi/XUiDormTemplate/XUiPanelRefitQuick") + +local SELECT_TYPE = { + All = 0, -- 全选 + Enought = 1, -- 已经达成 + NotEnought = 2 -- 未达成 +} + +function XUiDormTemplateDetail:OnAwake() + self:AddListener() +end + +function XUiDormTemplateDetail:OnStart(homeRoomData, enterSenceCb, curDormId) + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, + XDataCenter.ItemManager.ItemId.DormCoin, + XDataCenter.ItemManager.ItemId.FurnitureCoin, + XDataCenter.ItemManager.ItemId.DormEnterIcon) + self.SelectRoomPanel = XUiPanelTemlateSelectRoom.New(self.PanelSelectRoom, self, function(freshHomeRoomData) + self:Refresh(freshHomeRoomData) + end) + self.RefitPanel = XUiPanelRefitQuick.New(self.PanelRefitQuick, self) + self.EnterSenceCb = enterSenceCb + self.PageDatas = {} + self.SortType = SELECT_TYPE.All + self.CurDormId = curDormId + self:InitDynamicTable() + self:Refresh(homeRoomData) +end + +function XUiDormTemplateDetail:OnEnable() + XEventManager.AddEventListener(XEventId.EVENT_ITEM_BUYASSET, self.RefitPanel.UpdateTxtDrawingCount, self.RefitPanel) + XEventManager.AddEventListener(XEventId.EVENT_FURNITURE_Get_Furniture, self.RefitPanel.OnGetFurniture, self.RefitPanel) + self:Refresh() +end + +function XUiDormTemplateDetail:AddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:RegisterClickEvent(self.BtnPreview, self.OnBtnPreviewClick) + self:RegisterClickEvent(self.BtnTarget, self.OnBtnTargetClick) + self:RegisterClickEvent(self.BtnPut, self.OnBtnPutClick) + self.DrdSort.onValueChanged:AddListener(function() + self.SortType = self.DrdSort.value + self:RefreshSelectedPanel() + end) +end + +function XUiDormTemplateDetail:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiDormTemplateDetail:OnBtnBackClick() + self:Close() +end + +function XUiDormTemplateDetail:OnBtnPreviewClick() + if self.EnterSenceCb then + self.EnterSenceCb() + end + + XDataCenter.DormManager.EnterTeamplateDormitory(self.RoomId, self.RoomType) +end + +-- 选择宿舍 +function XUiDormTemplateDetail:OnBtnTargetClick() + self:PlayAnimation("SelectRoomEnable") + self.SelectRoomPanel:Open(self.HomeRoomData, self.CurDormId) +end + +-- 打开快捷建造界面 +function XUiDormTemplateDetail:OpenRefitQuick(furnitureData) + self:PlayAnimation("RefitQuickEnable") + self.RefitPanel:Open(furnitureData) +end + +-- 一键摆放 +function XUiDormTemplateDetail:OnBtnPutClick() + local connectRoom = XDataCenter.DormManager.GetRoomDataByRoomId(self.ConnectId) + local titletext = CS.XTextManager.GetText("TipTitle") + local contenttext = CS.XTextManager.GetText("DormTemplateOneKeyTip", connectRoom:GetRoomName()) + + XUiManager.DialogTip(titletext, contenttext, XUiManager.DialogType.Normal, nil, function() + XDataCenter.DormManager.CopyTemplateDorm(self.ConnectId, self.RoomId, self.RoomType, function() + XUiManager.TipSuccess(CS.XTextManager.GetText("DormTemplateOneKeySuccesss")) + self:Refresh() + if self.EnterSenceCb then + local roomData = XDataCenter.DormManager.GetRoomDataByRoomId(self.ConnectId) + local characterIds = roomData:GetCharacterIds() + XDataCenter.DormManager.ResetPutCharacter(self.ConnectId, characterIds) + end + end) + end) +end + +function XUiDormTemplateDetail:Refresh(homeRoomData) + if homeRoomData then + self.HomeRoomData = homeRoomData + end + + self.ConnectId = self.HomeRoomData:GetConnectDormId() + self.IsConnect = self.ConnectId > 0 + self.RoomId = self.HomeRoomData:GetRoomId() + self.RoomType = self.HomeRoomData:GetRoomDataType() + self:RefreshTitle() + self:RefreshButtons() + self:RefreshSelectedPanel() +end + +function XUiDormTemplateDetail:RefreshTitle() + if self.IsConnect then + local prrcent = XDataCenter.DormManager.GetDormTemplatePercent(self.RoomId, self.ConnectId) + self.TextTitle.text = CS.XTextManager.GetText("DormTemplateTitlePrecnt", prrcent) + return + end + self.TextTitle.text = CS.XTextManager.GetText("DormTemplateTitle") +end + +function XUiDormTemplateDetail:RefreshButtons() + self.DrdSort.gameObject:SetActiveEx(self.IsConnect) + self.BtnPut.gameObject:SetActiveEx(self.IsConnect) + if self.IsConnect then + local name = XDataCenter.DormManager.GetRoomDataByRoomId(self.ConnectId):GetRoomName() + self.BtnTarget:SetName(name) + else + self.BtnTarget:SetName(CS.XTextManager.GetText("DormTemplateTarget")) + end +end + +function XUiDormTemplateDetail:RefreshSelectedPanel() + if self.SortType == SELECT_TYPE.All then + self.PageDatas = self.HomeRoomData:GetAllFurnitures() + elseif self.SortType == SELECT_TYPE.Enought then + self.PageDatas = self.HomeRoomData:GetEnoughFurnitures() + elseif self.SortType == SELECT_TYPE.NotEnought then + self.PageDatas = self.HomeRoomData:GetNotEnoughFurnitures() + end + + self:SetupDynamicTable() +end + +function XUiDormTemplateDetail:InitDynamicTable() + self.GridTemplateDetail.gameObject:SetActiveEx(false) + self.DynamicTable = XDynamicTableNormal.New(self.PanelDynamicTable) + self.DynamicTable:SetProxy(XUiGridTemplateDetail) + self.DynamicTable:SetDelegate(self) +end + +function XUiDormTemplateDetail:SetupDynamicTable() + self.DynamicTable:SetDataSource(self.PageDatas) + self.DynamicTable:ReloadDataSync(1) +end + +-- 动态列表事件 +function XUiDormTemplateDetail:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.PageDatas[index] + grid:Refresh(data) + end +end + +function XUiDormTemplateDetail:OnDestroy() + XEventManager.RemoveEventListener(XEventId.EVENT_ITEM_BUYASSET, self.RefitPanel.UpdateTxtDrawingCount, self.RefitPanel) + XEventManager.RemoveEventListener(XEventId.EVENT_FURNITURE_Get_Furniture, self.RefitPanel.OnGetFurniture, self.RefitPanel) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormTemplate/XUiDormTemplateScene.lua b/Resources/Scripts/XUi/XUiDormTemplate/XUiDormTemplateScene.lua new file mode 100644 index 00000000..b3d9e2dc --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormTemplate/XUiDormTemplateScene.lua @@ -0,0 +1,200 @@ +local XUiDormTemplateScene = XLuaUiManager.Register(XLuaUi, "UiDormTemplateScene") +local XUiPanelFunitureList = require("XUi/XUiDormTemplate/XUiPanelFunitureList") +local XUiPanelSave = require("XUi/XUiDormTemplate/XUiPanelSave") +local XUiPanelEncoding = require("XUi/XUiDormTemplate/XUiPanelEncoding") + +function XUiDormTemplateScene:OnAwake() + self.IsHide = false + self.BtnShow.gameObject:SetActiveEx(self.IsHide) + self:AddListener() +end + +function XUiDormTemplateScene:OnStart(dormitoryId, roomDataType, displaytype) + XLuaUiManager.Close("UiLoading") + self.FunitureListPanel = XUiPanelFunitureList.New(self.PanelFurnitureList, self) + self.SavePanel = XUiPanelSave.New(self.PanelSave, self) + self.EncodingPanel = XUiPanelEncoding.New(self.PanelEncoding, self) + self:Refresh(dormitoryId, roomDataType, displaytype) +end + +function XUiDormTemplateScene:Refresh(dormitoryId, roomDataType, displaytype) + local roomType = roomDataType + if roomDataType == XDormConfig.DormDataType.CollectNone then + roomType = XDormConfig.DormDataType.Template + end + + self.OldRoomDataType = roomDataType + self.HomeRoomData = XDataCenter.DormManager.GetRoomDataByRoomId(dormitoryId, roomType) + self.RoomDataType = self.HomeRoomData:GetRoomDataType() + self.Displaytype = displaytype + self.RoomId = self.HomeRoomData:GetRoomId() + + self:SetCollectNoneSence(dormitoryId, roomDataType) + self:SetBtnStatus() +end + +function XUiDormTemplateScene:AddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:RegisterClickEvent(self.BtnHide, self.OnBtnHideOrShowClick) + self:RegisterClickEvent(self.BtnShow, self.OnBtnHideOrShowClick) + self:RegisterClickEvent(self.BtnShare, self.OnBtnShareClick) + self:RegisterClickEvent(self.BtnDown, self.OnBtnDownClick) + self:RegisterClickEvent(self.BtnSet, self.OnBtnSetClick) + self:RegisterClickEvent(self.BtnSave, self.OnBtnSaveClick) + self:RegisterClickEvent(self.BtnFurnitureList, self.OnBtnFurnitureListClick) +end + +function XUiDormTemplateScene:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiDormTemplateScene:OnBtnBackClick() + -- 退出模板场景 + if self.RoomDataType == XDormConfig.DormDataType.Template then + if self.OldRoomDataType == XDormConfig.DormDataType.CollectNone then + local titletext = CS.XTextManager.GetText("TipTitle") + local contenttext = CS.XTextManager.GetText("DormTemplateNoneTip") + + XUiManager.DialogTip(titletext, contenttext, XUiManager.DialogType.Normal, function() + self:BackToDormMain() + self:Close() + end, function() + self:OnBtnSaveClick() + end) + else + self:BackToDormMain() + end + elseif self.RoomDataType == XDormConfig.DormDataType.Collect then + self:BackToDormMain() + elseif self.RoomDataType == XDormConfig.DormDataType.Provisional then + local lastProvisionalRoom = XDataCenter.DormManager.GetLastDormProvisionalData() + if lastProvisionalRoom then + local lastRoomId = lastProvisionalRoom:GetRoomId() + XDataCenter.DormManager.EnterTeamplateDormitory(lastRoomId, XDormConfig.DormDataType.Provisional) + else + self:BackToDormMain() + end + end + + self:Close() +end + +function XUiDormTemplateScene:BackToDormMain() + XHomeDormManager.SetSelectedRoom(self.RoomId, false, true) + XHomeSceneManager.ChangeBackToOverView() + XHomeSceneManager.SetGlobalIllumSO(CS.XGame.ClientConfig:GetString("HomeSceneSoAssetUrl")) +end + +-- 隐藏UI +function XUiDormTemplateScene:OnBtnHideOrShowClick() + self.IsHide = not self.IsHide + --self.BtnShare.gameObject:SetActiveEx(not self.IsHide) + --self.BtnDown.gameObject:SetActiveEx(not self.IsHide) + self.BtnShare.gameObject:SetActiveEx(false)--海外特供屏蔽宿舍分享按钮 + self.BtnDown.gameObject:SetActiveEx(false) + + self.BtnSet.gameObject:SetActiveEx(not self.IsHide) + self.BtnSave.gameObject:SetActiveEx(not self.IsHide) + self.BtnBack.gameObject:SetActiveEx(not self.IsHide) + self.BtnFurnitureList.gameObject:SetActiveEx(not self.IsHide) + self.BtnHide.gameObject:SetActiveEx(not self.IsHide) + self.BtnShow.gameObject:SetActiveEx(self.IsHide) + + if not self.IsHide then + self:SetBtnStatus() + end +end + +-- 分享场景 +function XUiDormTemplateScene:OnBtnShareClick() + local furnitureList = {} + local furnitureDatas = self.HomeRoomData:GetFurnitureDic() + + for _, v in pairs(furnitureDatas) do + local temData = {} + temData.ConfigId = v.ConfigId + temData.X = v.GridX + temData.Y = v.GridY + temData.Angle = v.RotateAngle + table.insert(furnitureList, temData) + end + + XDataCenter.DormManager.RequestDormSnapshotLayout(furnitureList, function(shareId) + self.HomeRoomData:SetShareId(shareId) + XHomeSceneManager.EnterShare(self.HomeRoomData) + end) +end + +-- 导入场景 +function XUiDormTemplateScene:OnBtnDownClick() + self:PlayAnimation("EncodingAnimEnable") + self.EncodingPanel:Open() +end + +-- 设置场景 +function XUiDormTemplateScene:OnBtnSetClick() + XLuaUiManager.Open("UiFurnitureReform", self.RoomId, self.RoomDataType) +end + +-- 打开保存到收藏 +function XUiDormTemplateScene:OnBtnSaveClick() + self:PlayAnimation("SaveAnimEnable") + self.SavePanel:Open(self.HomeRoomData) +end + +-- 家具列表 +function XUiDormTemplateScene:OnBtnFurnitureListClick() + self:PlayAnimation("FurnitureListAnimEnable") + self.FunitureListPanel:Open(self.HomeRoomData) +end + +function XUiDormTemplateScene:SetCollectNoneSence(dormitoryId, roomDataType) + local isCollectNone = roomDataType == XDormConfig.DormDataType.CollectNone + if not isCollectNone then + return + end + + if XDataCenter.FurnitureManager.CheckCollectNoneFurnitrue(dormitoryId) then + return + end + + -- 处理空收藏场景 + local roomData = XHomeRoomData.New(dormitoryId) + local furnitureList = self.HomeRoomData:GetFurnitureDic() + for _, v in pairs(furnitureList) do + roomData:AddFurniture(v.Id, v.ConfigId, v.GridX, v.GridY, v.RotateAngle) + end + XDataCenter.FurnitureManager.SetCollectNoneFurnitrue(dormitoryId, roomData:GetFurnitureDic()) +end + +function XUiDormTemplateScene:SetBtnStatus() + if self.OldRoomDataType == XDormConfig.DormDataType.Target then + self.BtnShare.gameObject:SetActiveEx(true) + self.BtnDown.gameObject:SetActiveEx(false) + + self.BtnSet.gameObject:SetActiveEx(false) + self.BtnSave.gameObject:SetActiveEx(true) + elseif self.OldRoomDataType == XDormConfig.DormDataType.Template then + self.BtnShare.gameObject:SetActiveEx(false) + self.BtnDown.gameObject:SetActiveEx(false) + self.BtnSet.gameObject:SetActiveEx(false) + self.BtnSave.gameObject:SetActiveEx(false) + elseif self.OldRoomDataType == XDormConfig.DormDataType.Collect or + self.OldRoomDataType == XDormConfig.DormDataType.CollectNone then + self.BtnShare.gameObject:SetActiveEx(self.OldRoomDataType == XDormConfig.DormDataType.Collect) + self.BtnDown.gameObject:SetActiveEx(true) + + self.BtnSet.gameObject:SetActiveEx(true) + self.BtnSave.gameObject:SetActiveEx(true) + elseif self.OldRoomDataType == XDormConfig.DormDataType.Provisional then + self.BtnShare.gameObject:SetActiveEx(true) + self.BtnDown.gameObject:SetActiveEx(true) + + self.BtnSet.gameObject:SetActiveEx(true) + self.BtnSave.gameObject:SetActiveEx(true) + end + --海外特供屏蔽宿舍分享按钮 + self.BtnShare.gameObject:SetActiveEx(false) + self.BtnDown.gameObject:SetActiveEx(false) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormTemplate/XUiDormTemplateShare.lua b/Resources/Scripts/XUi/XUiDormTemplate/XUiDormTemplateShare.lua new file mode 100644 index 00000000..0f7f3702 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormTemplate/XUiDormTemplateShare.lua @@ -0,0 +1,68 @@ +local XUiDormTemplateShare = XLuaUiManager.Register(XLuaUi, "UiDormTemplateShare") + +function XUiDormTemplateShare:OnAwake() + self:AddListener() +end + +function XUiDormTemplateShare:OnStart(homeRoomData, texture) + self:Init(homeRoomData, texture) +end + +function XUiDormTemplateShare:AddListener() + self:RegisterClickEvent(self.BtnClose, self.OnBtnCloseClick) + self:RegisterClickEvent(self.BtnSave, self.OnBtnSaveClick) +end + +function XUiDormTemplateShare:Init(homeRoomData, texture) + self.HomeRoomData = homeRoomData + self.ShareId = tostring(self.HomeRoomData:GetShareId()) + + self.TxtEncod.text = self.ShareId + self.TxtEncodCupture.text = self.ShareId + self.RImgBg.texture = texture + self.RImgBgCuptrue.texture = texture + + -- 复制ShareId 到粘贴板 + CS.XAppPlatBridge.CopyStringToClipboard(self.ShareId) + local leftShareTime = XDormConfig.MAX_SHARE_COUNT - XDataCenter.DormManager.GetSnapshotTimes() + local tip = CS.XTextManager.GetText("DormTemplateShareTip", leftShareTime) + XUiManager.TipMsg(tip,XUiManager.UiTipType.Tip) +end + +function XUiDormTemplateShare:OnBtnCloseClick() + self:Close() +end + +function XUiDormTemplateShare:OnBtnSaveClick() + local camerDesc = CS.XTextManager.GetText("PremissionCameraDesc") + local readDesc = CS.XTextManager.GetText("PremissionReadDesc") + XPermissionManager.TryGetPermission(CS.XPermissionEnum.CAMERA, camerDesc, function(isCameraGranted, dontTip) + if not isCameraGranted then + XUiManager.TipText("PremissionDesc", XUiManager.UiTipType.Tip) + return + end + + XPermissionManager.TryGetPermission(CS.XPermissionEnum.WRITE_EXTERNAL_STORAGE, readDesc, function(isWriteGranted, dontTip) + if not isWriteGranted then + XUiManager.TipText("PremissionDesc", XUiManager.UiTipType.Tip) + return + end + + CsXUiManager.Instance:ChangeCanvasTypeCamera(CsXUiType.Normal, self.CameraCuptrue) + local cameraController = self.CameraCuptrue.gameObject:GetComponent(typeof(CS.XCameraController)) + local imgName = tostring(XPlayer.Id) .. self.ShareId .. XDormConfig.ShareName + local texture = cameraController:CaptureCamera(imgName, true) + XDataCenter.DormManager.SetLocalCaptureCache(imgName, texture) + CS.XTool.SavePhotoAlbumImg(imgName, texture, function(errorCode) + CsXUiManager.Instance:ChangeCanvasTypeCamera(CsXUiType.Normal, CS.XUiManager.Instance.UiCamera) + if errorCode > 0 then + XUiManager.TipText("PremissionDesc", XUiManager.UiTipType.Tip) + else + self:PlayAnimation("ShanShuo", function() + XUiManager.TipText("DormTemplateShareCuptrue", XUiManager.UiTipType.Tip) + end) + end + end) + end) + end) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormTemplate/XUiGridDormTemplate.lua b/Resources/Scripts/XUi/XUiDormTemplate/XUiGridDormTemplate.lua new file mode 100644 index 00000000..1b011c50 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormTemplate/XUiGridDormTemplate.lua @@ -0,0 +1,95 @@ +local XUiGridDormTemplate = XClass(nil, "XUiGridDormTemplate") + +function XUiGridDormTemplate:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + self:AutoAddListener() +end + +function XUiGridDormTemplate:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiGridDormTemplate:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiGridDormTemplate:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiGridDormTemplate:AutoAddListener() + self:RegisterClickEvent(self.BtnTemplate, self.OnBtnTemplate) + self:RegisterClickEvent(self.BtnNone, self.OnBtnNone) +end + +function XUiGridDormTemplate:SetPanelActive(isHave) + self.PanelTemplate.gameObject:SetActiveEx(isHave) + self.PanelTemplateNone.gameObject:SetActiveEx(not isHave) +end + +function XUiGridDormTemplate:OnBtnTemplate() + XLuaUiManager.Open("UiDormTemplateDetail", self.HomeRoomData, self.EnterSenceCb, self.CurDormId) +end + +function XUiGridDormTemplate:OnBtnNone() + if self.EnterSenceCb then self.EnterSenceCb() end + local enterRoomId = self.CollectCfg.SkipTemplateId + XDataCenter.DormManager.EnterTeamplateDormitory(enterRoomId, XDormConfig.DormDataType.CollectNone) +end + +function XUiGridDormTemplate:Refresh(homeRoomData, roomType, collectCfg, enterSenceCb, curDormId) + self.HomeRoomData = homeRoomData + self.RoomType = roomType + self.CollectCfg = collectCfg + self.EnterSenceCb = enterSenceCb + self.CurDormId = curDormId + + if homeRoomData then + self:SetPanelHave() + return + end + + self:SetPanelNone() +end + +function XUiGridDormTemplate:SetPanelHave() + self:SetPanelActive(true) + local imgPath = self.HomeRoomData:GetRoomPicturePath() + if self.RoomType == XDormConfig.DormDataType.Template then + self.RImgIcon:SetRawImage(imgPath, nil, false) + elseif self.RoomType == XDormConfig.DormDataType.Collect then + self.HomeRoomData:GetRoomPicture(function(texture) + if not texture then + imgPath = self.CollectCfg.DefaultIcon + self.RImgIcon:SetRawImage(imgPath, nil, false) + else + self.RImgIcon:SetRawImageTexture(texture, nil) + end + end) + end + + self.TxtName.text = self.HomeRoomData:GetRoomName() + local connectDormId = self.HomeRoomData:GetConnectDormId() + self.PanelConnect.gameObject:SetActiveEx(connectDormId > 0) + if connectDormId > 0 then + local id = self.HomeRoomData:GetRoomId() + local prrcent = XDataCenter.DormManager.GetDormTemplatePercent(id, connectDormId) + local name = XDataCenter.DormManager.GetRoomDataByRoomId(connectDormId):GetRoomName() + self.TxtPercent.text = prrcent .. "%" + self.TxtConnectDorm.text = name + end +end + +function XUiGridDormTemplate:SetPanelNone() + self:SetPanelActive(false) +end + +return XUiGridDormTemplate \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormTemplate/XUiGridFurnitreTemplate.lua b/Resources/Scripts/XUi/XUiDormTemplate/XUiGridFurnitreTemplate.lua new file mode 100644 index 00000000..8491c55a --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormTemplate/XUiGridFurnitreTemplate.lua @@ -0,0 +1,34 @@ +local XUiGridFurnitreTemplate = XClass(nil, "XUiGridFurnitreTemplate") + +function XUiGridFurnitreTemplate:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) +end + +function XUiGridFurnitreTemplate:Init(rootUi) + self.RootUi = rootUi +end + +function XUiGridFurnitreTemplate:Refresh(frunitrue) + self.Frunitrue = frunitrue + local furnitureCfg = XFurnitureConfigs.GetFurnitureTemplateById(self.Frunitrue.ConfigId) + self.TxtName.text = furnitureCfg.Name + self.RImgIcon:SetRawImage(furnitureCfg.Icon) + + if frunitrue.ConnectDormId > 0 then + if self.Frunitrue.Count > self.Frunitrue.TargetCount then + self.TxtNum.text = CS.XTextManager.GetText("DormTemplateCountNotEnough", self.Frunitrue.TargetCount, self.Frunitrue.Count) + else + self.TxtNum.text = CS.XTextManager.GetText("DormTemplateCountEnough", self.Frunitrue.TargetCount, self.Frunitrue.Count) + end + + self.PanelComplete.gameObject:SetActiveEx(self.Frunitrue.Count <= self.Frunitrue.TargetCount) + else + self.TxtNum.text = tostring(self.Frunitrue.Count) + self.PanelComplete.gameObject:SetActiveEx(false) + end +end + +return XUiGridFurnitreTemplate \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormTemplate/XUiGridTemplateDetail.lua b/Resources/Scripts/XUi/XUiDormTemplate/XUiGridTemplateDetail.lua new file mode 100644 index 00000000..20028ff3 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormTemplate/XUiGridTemplateDetail.lua @@ -0,0 +1,60 @@ +local XUiGridTemplateDetail = XClass(nil, "XUiGridTemplateDetail") + +function XUiGridTemplateDetail:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + self:AutoAddListener() +end + +function XUiGridTemplateDetail:Init(rootUi) + self.RootUi = rootUi +end + +function XUiGridTemplateDetail:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiGridTemplateDetail:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiGridTemplateDetail:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiGridTemplateDetail:AutoAddListener() + self:RegisterClickEvent(self.BtnClick, self.OnBtnClick) +end + +function XUiGridTemplateDetail:OnBtnClick() + self.RootUi:OpenRefitQuick(self.Frunitrue) +end + +function XUiGridTemplateDetail:Refresh(frunitrue) + self.Frunitrue = frunitrue + local furnitureCfg = XFurnitureConfigs.GetFurnitureTemplateById(self.Frunitrue.ConfigId) + self.TxtName.text = furnitureCfg.Name + self.RImgIcon:SetRawImage(furnitureCfg.Icon) + + if frunitrue.ConnectDormId > 0 then + if self.Frunitrue.Count > self.Frunitrue.TargetCount then + self.TxtNum.text = CS.XTextManager.GetText("DormTemplateCountNotEnough", self.Frunitrue.TargetCount, self.Frunitrue.Count) + else + self.TxtNum.text = CS.XTextManager.GetText("DormTemplateCountEnough", self.Frunitrue.TargetCount, self.Frunitrue.Count) + end + + self.PanelComplete.gameObject:SetActiveEx(self.Frunitrue.Count <= self.Frunitrue.TargetCount) + else + self.TxtNum.text = tostring(self.Frunitrue.Count) + self.PanelComplete.gameObject:SetActiveEx(false) + end +end + +return XUiGridTemplateDetail \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormTemplate/XUiGridTemplateSave.lua b/Resources/Scripts/XUi/XUiDormTemplate/XUiGridTemplateSave.lua new file mode 100644 index 00000000..b3245c29 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormTemplate/XUiGridTemplateSave.lua @@ -0,0 +1,81 @@ +local XUiGridTemplateSave = XClass(nil, "XUiGridTemplateSave") + +function XUiGridTemplateSave:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + self:AutoAddListener() +end + +function XUiGridTemplateSave:Init(parent) + self.Parent = parent + self:SetSelect(false) +end + +function XUiGridTemplateSave:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiGridTemplateSave:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiGridTemplateSave:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiGridTemplateSave:AutoAddListener() + self:RegisterClickEvent(self.BtnClick, self.OnBtnClick) +end + +function XUiGridTemplateSave:OnBtnClick() + self.Parent:OnGridClick(self, self.Name, false, self.Index) +end + +function XUiGridTemplateSave:SetSelect(status) + self.PanelSelect.gameObject:SetActiveEx(status) +end + +function XUiGridTemplateSave:CheckCoverSave() + return self.HomeRoomData ~= nil +end + +function XUiGridTemplateSave:Refresh(homeRoomData, collectCfg, isDefaultSelect, index) + self:SetSelect(false) + self.HomeRoomData = homeRoomData + self.CollectCfg = collectCfg + self.Index = index + + local isHave = homeRoomData ~= nil + self.Name = isHave and self.HomeRoomData:GetRoomName() or collectCfg.DefaultName + self.PanelTemplate.gameObject:SetActiveEx(homeRoomData ~= nil) + self.PanelTemplateNone.gameObject:SetActiveEx(homeRoomData == nil) + + self.TxtName.text = self.Name + if isDefaultSelect then + self.Parent:OnGridClick(self, self.Name, true, self.Index) + end + + if not isHave then + return + end + + self.HomeRoomData:GetRoomPicture(function(texture) + if texture then + self.RImgIcon.texture = texture + else + if isHave then + local imgPath = self.CollectCfg.DefaultIcon + self.RImgIcon:SetRawImage(imgPath, nil, false) + end + end + end) +end + +return XUiGridTemplateSave \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormTemplate/XUiGridTemplateSelectRoom.lua b/Resources/Scripts/XUi/XUiDormTemplate/XUiGridTemplateSelectRoom.lua new file mode 100644 index 00000000..18c44839 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormTemplate/XUiGridTemplateSelectRoom.lua @@ -0,0 +1,53 @@ +local XUiGridTemplateSelectRoom = XClass(nil, "XUiGridTemplateSelectRoom") + +function XUiGridTemplateSelectRoom:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:AutoAddListener() +end + +function XUiGridTemplateSelectRoom:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiGridTemplateSelectRoom:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiGridTemplateSelectRoom:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiGridTemplateSelectRoom:AutoAddListener() + self:RegisterClickEvent(self.BtnClick, self.OnBtnClickClick) +end + +function XUiGridTemplateSelectRoom:OnBtnClickClick() + if self.SelectCb then + self.SelectCb(self.RoomId) + end +end + +function XUiGridTemplateSelectRoom:SetSelected(status) + self.PanelSelect.gameObject:SetActiveEx(status) +end + +function XUiGridTemplateSelectRoom:Refresh(roomData, connectId, selectCb, curDormId) + self.RoomData = roomData + self.SelectCb = selectCb + self.RoomId = roomData:GetRoomId() + self:SetSelected(connectId == self.RoomId) + + local name = roomData:GetRoomName() + self.TxtCategoryName.text = name + self.TxtCategoryNameSelect.text = name + self.TxtTag.gameObject:SetActiveEx(curDormId == self.RoomId) +end + +return XUiGridTemplateSelectRoom \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormTemplate/XUiPanelEncoding.lua b/Resources/Scripts/XUi/XUiDormTemplate/XUiPanelEncoding.lua new file mode 100644 index 00000000..dab49b5a --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormTemplate/XUiPanelEncoding.lua @@ -0,0 +1,68 @@ +local XUiPanelEncoding = XClass(nil, "XUiPanelEncoding") + +function XUiPanelEncoding:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + + XTool.InitUiObject(self) + self:AddListener() +end + +function XUiPanelEncoding:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelEncoding:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelEncoding:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelEncoding:AddListener() + self:RegisterClickEvent(self.BtnAllClose, self.OnBtnCloseClick) + self:RegisterClickEvent(self.BtnClose, self.OnBtnCloseClick) + self:RegisterClickEvent(self.BtnCancel, self.OnBtnCloseClick) + self:RegisterClickEvent(self.BtnSure, self.OnBtnSureClick) +end + +function XUiPanelEncoding:OnBtnCloseClick() + self:Close() +end + +function XUiPanelEncoding:OnBtnSureClick() + local shareId = string.gsub(self.InFSigm.text, "^%s*(.-)%s*$", "%1") + if string.len(shareId) < 0 then + XUiManager.TipError(CS.XTextManager.GetText("DormTemplateEncondeNoneID")) + return + end + + local titletext = CS.XTextManager.GetText("TipTitle") + local contenttext = CS.XTextManager.GetText("DormTemplateEncondeTip") + + XUiManager.DialogTip(titletext, contenttext, XUiManager.DialogType.Normal, nil, function() + XDataCenter.DormManager.DormGetPlayerLayoutReq(shareId, function() + self:Close() + self.RootUi:Close() + XDataCenter.DormManager.EnterTeamplateDormitory(shareId, XDormConfig.DormDataType.Provisional) + end) + end) +end + +function XUiPanelEncoding:Close() + self.GameObject:SetActiveEx(false) +end + +function XUiPanelEncoding:Open() + self.InFSigm.text = "" + self.GameObject:SetActiveEx(true) +end + +return XUiPanelEncoding \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormTemplate/XUiPanelFunitureList.lua b/Resources/Scripts/XUi/XUiDormTemplate/XUiPanelFunitureList.lua new file mode 100644 index 00000000..5f9b13ab --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormTemplate/XUiPanelFunitureList.lua @@ -0,0 +1,68 @@ +local XUiPanelFunitureList = XClass(nil, "XUiPanelFunitureList") +local XUiGridFurnitreTemplate = require("XUi/XUiDormTemplate/XUiGridFurnitreTemplate") + +function XUiPanelFunitureList:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + + XTool.InitUiObject(self) + self:AddListener() + self:InitDynamicTable() +end + +function XUiPanelFunitureList:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelFunitureList:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelFunitureList:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelFunitureList:AddListener() + self:RegisterClickEvent(self.BtnFurnitureListBack, self.OnBtnCloseClick) +end + +function XUiPanelFunitureList:OnBtnCloseClick() + self:Close() +end + +function XUiPanelFunitureList:Close() + self.GameObject:SetActiveEx(false) +end + +function XUiPanelFunitureList:Open(homeRoomData) + self.HomeRoomData = homeRoomData + self.PageDatas = self.HomeRoomData:GetAllFurnitures() + self.DynamicTable:SetDataSource(self.PageDatas) + self.DynamicTable:ReloadDataSync(1) + self.GameObject:SetActiveEx(true) +end + +function XUiPanelFunitureList:InitDynamicTable() + self.GridFurnitureTemplate.gameObject:SetActiveEx(false) + self.DynamicTable = XDynamicTableNormal.New(self.PanelDynamicTable) + self.DynamicTable:SetProxy(XUiGridFurnitreTemplate) + self.DynamicTable:SetDelegate(self) +end + +-- 动态列表事件 +function XUiPanelFunitureList:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.PageDatas[index] + grid:Refresh(data) + end +end + +return XUiPanelFunitureList \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormTemplate/XUiPanelRefitQuick.lua b/Resources/Scripts/XUi/XUiDormTemplate/XUiPanelRefitQuick.lua new file mode 100644 index 00000000..cf3b44c4 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormTemplate/XUiPanelRefitQuick.lua @@ -0,0 +1,207 @@ +local XUiPanelRefitQuick = XClass(nil, "XUiPanelRefitQuick") + +function XUiPanelRefitQuick:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self.GridRoomList = {} + self.CreateCount = 0 + + XTool.InitUiObject(self) + self:AddListener() + self:Init() +end + +function XUiPanelRefitQuick:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelRefitQuick:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelRefitQuick:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelRefitQuick:AddListener() + self:RegisterClickEvent(self.BtnClose, self.OnBtnCloseClick) + self:RegisterClickEvent(self.BtnRefit, self.OnBtnRefitClick) + self:RegisterClickEvent(self.BtnSingleCreate, self.OnBtnCreateClick) + self:RegisterClickEvent(self.BtnCreate, self.OnBtnCreateClick) + self:RegisterClickEvent(self.BtnBuy, self.OnBtnBuyClick) + self:RegisterClickEvent(self.BtnDraw, self.OnBtnDrawClick) + self:RegisterClickEvent(self.BtnPreview, self.OnBtnPreviewClick) + self:RegisterClickEvent(self.BtnPreviewSingle, self.OnBtnPreviewClick) +end + +function XUiPanelRefitQuick:Init() + self.GameObject:SetActiveEx(false) +end + +function XUiPanelRefitQuick:Close() + self.GameObject:SetActiveEx(false) +end + +function XUiPanelRefitQuick:Refresh(furnitur) + self:Open(furnitur) +end + +function XUiPanelRefitQuick:UpdateTxtDrawingCount(TargetId) + if not TargetId then + return + elseif TargetId == self.Config.PicId then + self:Refresh(self.Furnitur) + end +end + +function XUiPanelRefitQuick:OnGetFurniture() + self:Refresh(self.Furnitur) +end + +function XUiPanelRefitQuick:Open(furnitur) + self.Furnitur = furnitur + self.Config = XFurnitureConfigs.GetFurnitureTemplateById(furnitur.ConfigId) + self.PanelRefit.gameObject:SetActiveEx(self.Config.PicId > 0) + self.PanelRefitSingle.gameObject:SetActiveEx(self.Config.PicId <= 0) + + self:SetTitle() + if self.Config.PicId > 0 then + self:SetRefit() + else + self:SetRefitSingle() + end + + self.GameObject:SetActiveEx(true) +end + +function XUiPanelRefitQuick:SetTitle() + self.TxtTile.text = self.Config.Name +end + +function XUiPanelRefitQuick:SetRefit() + local isBindDorm = self.Furnitur.ConnectDormId > 0 + -- 基础类型 + local typeCfg = XFurnitureConfigs.GetFurnitureTypeById(self.Config.TypeId) + self.RImgFurnitureType:SetRawImage(typeCfg.TypeIcon) + self.TxtFurnitureTypeName.text = typeCfg.CategoryName + self.TxtFurnitureTypeCount.gameObject:SetActiveEx(isBindDorm) + + -- 图纸 + local draftId = self.Config.PicId + local icon = XDataCenter.ItemManager.GetItemIcon(draftId) + local name = XDataCenter.ItemManager.GetItemName(draftId) + self.RImgDrawing:SetRawImage(icon) + self.TxtDrawingName.text = name + self.TxtDrawingCount.gameObject:SetActiveEx(isBindDorm) + + -- 目标 + self.RImgPreview:SetRawImage(self.Config.Icon) + self.TxtPreviewName.text = self.Config.Name + self.TxtPreviewCount.gameObject:SetActiveEx(isBindDorm) + + -- 处理绑定了宿舍 + if isBindDorm then + -- 基础类型 + local baseAllCount = self.Furnitur.Count + local typeId = self.Config.TypeId + local baseCurList = XDataCenter.FurnitureManager.GetFurnitureCategoryIds({ typeId }, nil, true, nil, nil, true) + local baseCurCount = #baseCurList + self:SetCountText(self.TxtFurnitureTypeCount, baseCurCount, baseAllCount) + self.CreateCount = baseAllCount > baseCurCount and baseAllCount - baseCurCount or 0 + + -- 图纸 + local draftAllcount = self.Furnitur.Count * self.Config.PicNum + local draftCurCount = XDataCenter.ItemManager.GetCount(draftId) + self:SetCountText(self.TxtDrawingCount, draftCurCount, draftAllcount) + + -- 目标 + self:SetCountText(self.TxtPreviewCount, self.Furnitur.TargetCount, self.Furnitur.Count) + end +end + +function XUiPanelRefitQuick:SetRefitSingle() + local isBindDorm = self.Furnitur.ConnectDormId > 0 + self.RImgPreviewSingle:SetRawImage(self.Config.Icon) + self.TxtPreviewSingleName.text = self.Config.Name + self.TxtPreviewSingleCount.gameObject:SetActiveEx(isBindDorm) + + if isBindDorm then + self:SetCountText(self.TxtPreviewSingleCount, self.Furnitur.TargetCount, self.Furnitur.Count) + self.CreateCount = self.Furnitur.Count > self.Furnitur.TargetCount and self.Furnitur.Count - self.Furnitur.TargetCount or 0 + end +end + +function XUiPanelRefitQuick:SetCountText(text, curCount, allCount) + if allCount > curCount then + text.text = CS.XTextManager.GetText("DormRefitCountNotEnough", curCount, allCount) + else + text.text = CS.XTextManager.GetText("DormRefitCountEnough", curCount, allCount) + end +end + +--------------------------------- 点击事件相关(Start) --------------------------------- +function XUiPanelRefitQuick:OnBtnCloseClick() + self:Close() +end + +-- 快捷改造 +function XUiPanelRefitQuick:OnBtnRefitClick() + local gainType = XFurnitureConfigs.GainType.Refit + local draftId = self.Config.PicId + local furnitureTypeId = self.Config.TypeId + self:Close() + XLuaUiManager.Open("UiFurnitureBuild", gainType, draftId, furnitureTypeId) +end + +-- 快捷建造 +function XUiPanelRefitQuick:OnBtnCreateClick() + if XDataCenter.FurnitureManager.IsFurnitureCreatePosFull() then + XUiManager.TipText("FurnitureBuildingListFull") + return + end + + local minConsume, _ = XFurnitureConfigs.GetFurnitureCreateMinAndMax() + local currentOwn = XDataCenter.ItemManager.GetCount(XDataCenter.ItemManager.ItemId.FurnitureCoin) + local costCoin = self.CreateCount * minConsume + if costCoin > currentOwn then + XUiManager.TipMsg(CS.XTextManager.GetText("FurnitureZeroCoin")) + return + end + + XLuaUiManager.Open("UiFurnitureCreate", self.Config.TypeId, self.CreateCount, nil, function() + XLuaUiManager.PopThenOpen("UiFurnitureBuild") + end) +end + +-- 快捷购买 +function XUiPanelRefitQuick:OnBtnBuyClick() + local configId = self.Config.PicId + local data = XDataCenter.ItemManager.GetAllBuyAssetTemplate() + + -- 判断配置表是否存在该图纸快捷购买数据 + if not data[configId] then + XUiManager.TipMsg(CS.XTextManager.GetText("ShopNoGoodsDesc"), XUiManager.UiTipType.Tip) + else + XLuaUiManager.Open("UiBuyAsset", configId) + end +end + +-- 点击图纸详情 +function XUiPanelRefitQuick:OnBtnDrawClick() + local data = XDataCenter.ItemManager.GetItem(self.Config.PicId) + local hideSkipBtn = true + XLuaUiManager.Open("UiTip", data, hideSkipBtn) +end + +-- 改造目标点击详情 +function XUiPanelRefitQuick:OnBtnPreviewClick() + XLuaUiManager.Open("UiDormFieldGuideDes", self.Config) +end +--------------------------------- 点击事件相关(End) --------------------------------- +return XUiPanelRefitQuick \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormTemplate/XUiPanelSave.lua b/Resources/Scripts/XUi/XUiDormTemplate/XUiPanelSave.lua new file mode 100644 index 00000000..c72bdc77 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormTemplate/XUiPanelSave.lua @@ -0,0 +1,187 @@ + +local XUiPanelSave = XClass(nil, "XUiPanelSave") +local XUiGridTemplateSave = require("XUi/XUiDormTemplate/XUiGridTemplateSave") +local MaxNameLength = CS.XGame.Config:GetInt("DormReNameLen") + +function XUiPanelSave:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + + XTool.InitUiObject(self) + self:AddListener() + self:InitDynamicTable() +end + +function XUiPanelSave:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelSave:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelSave:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelSave:AddListener() + self:RegisterClickEvent(self.BtnAllClose, self.OnBtnCloseClick) + self:RegisterClickEvent(self.BtnClose, self.OnBtnCloseClick) + self:RegisterClickEvent(self.BtnSave, self.OnBtnSaveClick) +end + +function XUiPanelSave:OnBtnCloseClick() + self:Close() +end + +function XUiPanelSave:OnBtnSaveClick() + if not self.SelectGrid then + XUiManager.TipError(CS.XTextManager.GetText("DormTemplateSaveNoneTip")) + return + end + + local editName = string.gsub(self.InFSigm.text, "^%s*(.-)%s*$", "%1") + if string.len(editName) > 0 then + local utf8Count = self.InFSigm.textComponent.cachedTextGenerator.characterCount - 1 + if utf8Count > MaxNameLength then + XUiManager.TipError(CS.XTextManager.GetText("MaxNameLengthTips", MaxNameLength)) + return + end + else + XUiManager.TipError(CS.XTextManager.GetText("DormTemplateSaveTipName")) + return + end + + local isCover = self.SelectGrid:CheckCoverSave() + if isCover then -- 覆盖存储 + local titletext = CS.XTextManager.GetText("TipTitle") + local contenttext = CS.XTextManager.GetText("DormTemplateSaveTip") + + XUiManager.DialogTip(titletext, contenttext, XUiManager.DialogType.Normal, nil, function() + self:DormCollectLayoutReq(isCover, editName) + end) + return + end + self:DormCollectLayoutReq(isCover, editName) +end + +function XUiPanelSave:DormCollectLayoutReq(isCover, name) + local id = isCover and self.SelectGrid.HomeRoomData:GetRoomId() or -1 + local homeFurnitrueDic = self.SceneHomeRoomData:GetFurnitureDic() + local furnitrueList = {} + + for _, v in pairs(homeFurnitrueDic) do + local data = { + ConfigId = v.ConfigId, + X = v.GridX, + Y = v.GridY, + Angle = v.RotateAngle, + } + table.insert(furnitrueList, data) + end + + XDataCenter.DormManager.DormCollectLayoutReq(id, name, furnitrueList, function(roomId) + -- 更换相机截屏 + local imgName = tostring(XPlayer.Id) .. tostring(roomId) + local texture = XHomeSceneManager.CaptureCamera(imgName, false) + XDataCenter.DormManager.SetLocalCaptureCache(imgName, texture) + XUiManager.TipSuccess(CS.XTextManager.GetText("DormTemplateSaveSuccess")) + self:Close() + end) +end + +function XUiPanelSave:OnGridClick(grid, name, isAutoClick, index) + -- 取消选择 + if self.SelectGrid == grid and not isAutoClick then + self.SelectGrid:SetSelect(false) + self.SelectGrid = nil + self.InFSigm.text = nil + self.PageDatas[self.SelectIndex].IsDefaultSelect = false + self.SelectIndex = 0 + return + end + + if self.SelectGrid then + self.SelectGrid:SetSelect(false) + end + + grid:SetSelect(true) + self.InFSigm.text = name + if self.SelectIndex > 0 then + self.PageDatas[self.SelectIndex].IsDefaultSelect = false + end + self.PageDatas[index].IsDefaultSelect = true + self.SelectGrid = grid + self.SelectIndex = index +end + +function XUiPanelSave:Close() + self.GameObject:SetActiveEx(false) +end + +function XUiPanelSave:Open(sceneHomeRoomData) + self.PageDatas = {} + self.SelectIndex = 1 + self.SceneHomeRoomData = sceneHomeRoomData + + local datas = XDataCenter.DormManager.GetTemplateDormitoryData(XDormConfig.DormDataType.Collect) + local collectCfgs = XDormConfig.GetDormTemplateCollectList() + local sceneHomeRoomId = sceneHomeRoomData:GetRoomId() + local noRoonIndex = true + + for i = 1, #collectCfgs do + local tempDate = {} + if i > #datas then + if i == #datas + 1 and noRoonIndex then + self.SelectIndex = i + end + tempDate.HomeRoomData = nil + else + tempDate.HomeRoomData = datas[i] + local dataRoomId = datas[i]:GetRoomId() + if dataRoomId == sceneHomeRoomId then + self.SelectIndex = i + tempDate.IsDefaultSelect = true + noRoonIndex = false + end + end + + tempDate.Index = i + tempDate.CollectCfg = collectCfgs[i] + table.insert(self.PageDatas, tempDate) + end + + if noRoonIndex then + self.PageDatas[self.SelectIndex].IsDefaultSelect = true + end + + self.DynamicTable:SetDataSource(self.PageDatas) + self.DynamicTable:ReloadDataSync(self.SelectIndex) + self.GameObject:SetActiveEx(true) +end + +function XUiPanelSave:InitDynamicTable() + self.GridDormTemplate.gameObject:SetActiveEx(false) + self.GameObject:SetActiveEx(false) + self.DynamicTable = XDynamicTableNormal.New(self.PanelDynamicTable) + self.DynamicTable:SetProxy(XUiGridTemplateSave) + self.DynamicTable:SetDelegate(self) +end + +-- 动态列表事件 +function XUiPanelSave:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local d = self.PageDatas[index] + grid:Refresh(d.HomeRoomData, d.CollectCfg, d.IsDefaultSelect, d.Index) + end +end + +return XUiPanelSave \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormTemplate/XUiPanelTemlateSelectRoom.lua b/Resources/Scripts/XUi/XUiDormTemplate/XUiPanelTemlateSelectRoom.lua new file mode 100644 index 00000000..2ef16185 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormTemplate/XUiPanelTemlateSelectRoom.lua @@ -0,0 +1,231 @@ +local XUiGridTemplateSelectRoom = require("XUi/XUiDormTemplate/XUiGridTemplateSelectRoom") +local XUiPanelTemlateSelectRoom = XClass(nil, "XUiPanelTemlateSelectRoom") + +function XUiPanelTemlateSelectRoom:Ctor(ui, rootUi, sureCb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self.SureCb = sureCb + self.GridRoomList = {} + + XTool.InitUiObject(self) + self:AddListener() + self:Init() +end + +function XUiPanelTemlateSelectRoom:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelTemlateSelectRoom:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelTemlateSelectRoom:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelTemlateSelectRoom:AddListener() + self:RegisterClickEvent(self.BtnClose, self.OnBtnCloseClick) + self:RegisterClickEvent(self.BtnAllClose, self.OnBtnCloseClick) + self:RegisterClickEvent(self.BtnCancel, self.OnBtnCloseClick) + self:RegisterClickEvent(self.BtnSure, self.OnBtnSureClick) +end + +function XUiPanelTemlateSelectRoom:Init() + self.GridTemplateSelectRoom.gameObject:SetActiveEx(false) + self.GameObject:SetActiveEx(false) +end + +function XUiPanelTemlateSelectRoom:OnBtnCloseClick() + self:Close() +end + +function XUiPanelTemlateSelectRoom:OnBtnSureClick() + -- 重复绑定同一个宿舍 + if self.ConnectId > 0 and self.ConnectId == self.SelectId then + XUiManager.TipMsg(CS.XTextManager.GetText("DormTemplateSelectTip")) + return + end + + -- 没有选择宿舍 + if self.ConnectId <= 0 and self.SelectId <= 0 then + XUiManager.TipMsg(CS.XTextManager.GetText("DormTemplateSelectNoneTip")) + return + end + + -- 取消绑定当前宿舍 + if self.ConnectId > 0 and self.SelectId <= 0 then + local titletext = CS.XTextManager.GetText("TipTitle") + local contenttext = CS.XTextManager.GetText("DormTemplateSelectCancelTip") + + local cancelConectFunc = function() + local conectRoom = XDataCenter.DormManager.GetRoomDataByRoomId(self.ConnectId) + self.HomeRoomData:SetConnectDormId(0) + conectRoom:SetConnectDormId(0) + local isUnBind = true + self:CallBackHandle(isUnBind) + end + + XUiManager.DialogTip(titletext, contenttext, XUiManager.DialogType.Normal, nil, function() + XDataCenter.DormManager.DormUnBindLayoutReq(self.HomeRoomData:GetRoomId(), cancelConectFunc) + end) + + return + end + + local selectRoom = XDataCenter.DormManager.GetRoomDataByRoomId(self.SelectId) + + -- 正常绑定宿舍 + if self.ConnectId <= 0 and self.SelectId > 0 and selectRoom:GetConnectDormId() <= 0 then + XDataCenter.DormManager.DormBindLayoutReq(self.SelectId, self.HomeRoomData:GetRoomId(), function() + self.HomeRoomData:SetConnectDormId(self.SelectId) + selectRoom:SetConnectDormId(self.HomeRoomData:GetRoomId()) + self:CallBackHandle() + end) + return + end + + -- 当前没有绑定宿舍 并且绑定了一个有绑定关系的宿舍 + if self.ConnectId <= 0 and self.SelectId > 0 and selectRoom:GetConnectDormId() > 0 then + local titletext = CS.XTextManager.GetText("TipTitle") + local contenttext = CS.XTextManager.GetText("DormTemplateSelectHaveTip1", selectRoom:GetRoomName()) + + local conectFunc = function() + local unbingRoom = XDataCenter.DormManager.GetRoomDataByRoomId(selectRoom:GetConnectDormId(), XDormConfig.DormDataType.Template) + unbingRoom:SetConnectDormId(0) + + selectRoom:SetConnectDormId(self.HomeRoomData:GetRoomId()) + self.HomeRoomData:SetConnectDormId(self.SelectId) + self:CallBackHandle() + end + + XUiManager.DialogTip(titletext, contenttext, XUiManager.DialogType.Normal, nil, function() + XDataCenter.DormManager.DormBindLayoutReq(self.SelectId, self.HomeRoomData:GetRoomId(), conectFunc) + end) + return + end + + -- 当前有绑定宿舍 并且绑定了一个没有有绑定关系的宿舍 + if self.ConnectId > 0 and self.SelectId > 0 and selectRoom:GetConnectDormId() <= 0 then + local titletext = CS.XTextManager.GetText("TipTitle") + local conectRoom = XDataCenter.DormManager.GetRoomDataByRoomId(self.ConnectId) + local contenttext = CS.XTextManager.GetText("DormTemplateSelectHaveTip1", conectRoom:GetRoomName()) + + local conectFunc = function() + local conectCurRoom = XDataCenter.DormManager.GetRoomDataByRoomId(self.ConnectId) + conectCurRoom:SetConnectDormId(0) + + selectRoom:SetConnectDormId(self.HomeRoomData:GetRoomId()) + self.HomeRoomData:SetConnectDormId(self.SelectId) + self:CallBackHandle() + end + + XUiManager.DialogTip(titletext, contenttext, XUiManager.DialogType.Normal, nil, function() + XDataCenter.DormManager.DormBindLayoutReq(self.SelectId, self.HomeRoomData:GetRoomId(), conectFunc) + end) + return + end + + -- 当前有绑定宿舍 并且又绑定了一个有绑定关系的宿舍 + if self.ConnectId > 0 and self.SelectId > 0 and selectRoom:GetConnectDormId() > 0 then + local titletext = CS.XTextManager.GetText("TipTitle") + local contenttext = CS.XTextManager.GetText("DormTemplateSelectHaveTip2", selectRoom:GetRoomName()) + + local conectFunc = function() + local conectRoom = XDataCenter.DormManager.GetRoomDataByRoomId(self.ConnectId) + conectRoom:SetConnectDormId(0) + local unbingRoom = XDataCenter.DormManager.GetRoomDataByRoomId(selectRoom:GetConnectDormId(), XDormConfig.DormDataType.Template) + unbingRoom:SetConnectDormId(0) + + selectRoom:SetConnectDormId(self.HomeRoomData:GetRoomId()) + self.HomeRoomData:SetConnectDormId(self.SelectId) + self:CallBackHandle() + end + + XUiManager.DialogTip(titletext, contenttext, XUiManager.DialogType.Normal, nil, function() + XDataCenter.DormManager.DormBindLayoutReq(self.SelectId, self.HomeRoomData:GetRoomId(), conectFunc) + end) + return + end +end + +function XUiPanelTemlateSelectRoom:CallBackHandle(isUnBind) + local content = isUnBind and "DormTemplateUnSelectSuccess" or "DormTemplateSelectSuccess" + XUiManager.TipSuccess(CS.XTextManager.GetText(content)) + + if self.SureCb then + self.SureCb(self.HomeRoomData) + end + + self:Close() +end + +function XUiPanelTemlateSelectRoom:Open(homeRoomData, curDormId) + self.HomeRoomData = homeRoomData + self.ConnectId = self.HomeRoomData:GetConnectDormId() + self.SelectId = self.ConnectId + self.CurDormId = curDormId + + local dormDatas = XDataCenter.DormManager.GetDormitoryData() + local dataList = {} + for _, v in pairs(dormDatas) do + if v:WhetherRoomUnlock() then + table.insert(dataList, v) + end + end + + table.sort(dataList, function(a, b) + local sortA = XDormConfig.GetDormitoryCfgById(a.Id).InitNumber + local sortB = XDormConfig.GetDormitoryCfgById(b.Id).InitNumber + + return sortA < sortB + end) + + for _, v in ipairs(self.GridRoomList) do + v.GameObject:SetActiveEx(false) + end + + for i, data in ipairs(dataList) do + local roomGrid = self.GridRoomList[i] + if not roomGrid then + local grid = CS.UnityEngine.GameObject.Instantiate(self.GridTemplateSelectRoom) + grid.transform:SetParent(self.PanelDormContent, false) + roomGrid = XUiGridTemplateSelectRoom.New(grid) + table.insert(self.GridRoomList, roomGrid) + end + + roomGrid:Refresh(data, self.ConnectId, function(roomId) + -- 取消选择 + if self.SelectId == roomId then + self.SelectId = 0 + self:SetGridSelected(self.SelectId) + return + end + + self.SelectId = roomId + self:SetGridSelected(roomId) + end, self.CurDormId) + roomGrid.GameObject:SetActiveEx(true) + end + + self.GameObject:SetActiveEx(true) +end + +function XUiPanelTemlateSelectRoom:SetGridSelected(roomId) + for _, v in ipairs(self.GridRoomList) do + local id = v.RoomData:GetRoomId() + v:SetSelected(id == roomId) + end +end + +function XUiPanelTemlateSelectRoom:Close() + self.GameObject:SetActiveEx(false) +end + +return XUiPanelTemlateSelectRoom \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormVisit/XUiDormVisit.lua b/Resources/Scripts/XUi/XUiDormVisit/XUiDormVisit.lua new file mode 100644 index 00000000..98c5ec72 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormVisit/XUiDormVisit.lua @@ -0,0 +1,305 @@ +local Vector3 = CS.UnityEngine.Vector3 +local V3O = Vector3.one +local XUiDormVisit = XLuaUiManager.Register(XLuaUi, "UiDormVisit") +local XUiDormVisitGridItem = require("XUi/XUiDormVisit/XUiDormVisitGridItem") +local TextManager = CS.XTextManager +local Next = next +local TIME_LIMIT = 10 + +function XUiDormVisit:OnAwake() + XTool.InitUiObject(self) + self.TabObjs = {} + self.TabObjs[1] = self.BtnTab1 + self.TabObjs[2] = self.BtnTab2 + self.DormVisitFriendEmptyTips = TextManager.GetText("DormVisitFriendEmptyTips") + self.DormVisitStrangeEmptyTips = TextManager.GetText("DormVisitStrangeEmptyTips") + self.DormVistorFriend = TextManager.GetText("DormVistorFriend") + self.DormVistorStranger = TextManager.GetText("DormVistorStranger") + self:InitUI() + self:InitTypeCfg() + self.PreVistorReqTime = XTime.GetServerNowTimestamp() +end + +--- +--- ButtonGroup中的按钮名称与对应的响应函数 +function XUiDormVisit:InitTypeCfg() + self.TabObs = {} + self.TypeListDataCfg = {} + self.TypeListDataCfg[XDormConfig.VisitTabTypeCfg.MyFriend] = {["Name"] = TextManager.GetText("DormMyFriend"), ["Skip"] = function() self:OnReqFriendData() end } + self.TypeListDataCfg[XDormConfig.VisitTabTypeCfg.Visitor] = {["Name"] = TextManager.GetText("DormStranger"), ["Skip"] = function() self:OnReqVisitorData() end } + self:CreateTypeItems() +end + +--- +--- 初始化ButtonGroup +function XUiDormVisit:CreateTypeItems() + if self.PanelTab then + for k, v in pairs(self.TypeListDataCfg) do + local obj = self.TabObjs[k] + obj.gameObject:SetActive(true) + obj.transform:SetParent(self.PanelTab.transform, false) + obj.transform.localScale = V3O + self.TabObs[k] = obj + local cs = obj:GetComponent("XUiButton") + cs:SetName(v.Name) + end + self.Tabgroup = self.PanelTab:GetComponent("XUiButtonGroup") + self.Tabgroup:Init(self.TabObs, function(tab) self:TabSkip(tab) end) + end +end + +--- +--- ButtonGroup响应函数 +function XUiDormVisit:TabSkip(tab) + self.CuTabType = tab + local cfg = self.TypeListDataCfg[tab] + local skip = cfg.Skip + if skip then + skip() + end +end + +--- +--- 初始化动态列表 +function XUiDormVisit:InitList() + self.DynamicTable = XDynamicTableNormal.New(self.PanelItemCommon.gameObject) + self.DynamicTable:SetProxy(XUiDormVisitGridItem) + self.DynamicTable:SetDelegate(self) +end + +-- 未知访客 +function XUiDormVisit:SetVisitorListData(data) + local dataDt = data.Details or {} + self:SetVisitorData(dataDt) +end + +--- +--- 设置未知访客动态列表DataSource +function XUiDormVisit:SetVisitorData(data) + self.ListData = data or {} + if Next(self.ListData) ~= nil then + self.VisitTips.gameObject:SetActive(false) + self.BtnRandomVisit.gameObject:SetActive(true) + else + self.VisitTips.gameObject:SetActive(true) + self.TxtEmptyTips.text = self.DormVisitStrangeEmptyTips + self.BtnRandomVisit.gameObject:SetActive(false) + end + + self.TxtType.text = self.DormVistorStranger + self.DynamicTable:SetDataSource(self.ListData) + self.DynamicTable:ReloadDataASync(1) +end + +--- +--- 设置好友动态列表DataSource +function XUiDormVisit:SetFriendListData(data) + if data and Next(data) ~= nil then + self.VisitTips.gameObject:SetActive(false) + else + self.VisitTips.gameObject:SetActive(true) + self.TxtEmptyTips.text = self.DormVisitFriendEmptyTips + end + self.TxtType.text = self.DormVistorFriend + self.ListData = data or {} + self.DynamicTable:SetDataSource(self.ListData) + self.DynamicTable:ReloadDataASync(1) + self.BtnRandomVisit.gameObject:SetActive(false) +end + +function XUiDormVisit:UpdateFriendList() + local data = XDataCenter.DormManager.GetVisFriendData() + self.ListData = {} + if Next(data) ~= nil then + for _, v in pairs(data) do + table.insert(self.ListData, v) + end + end + self:SetFriendListData(self.ListData) +end + +-- [监听动态列表事件] +function XUiDormVisit:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.ListData[index] + grid:OnRefresh(data) + end +end + +--- +--- 初始化ButtonGroup的Index +function XUiDormVisit:OnStart(ui, tab) + self.HostelSecond = ui + local t = tab or XDormConfig.VisitTabTypeCfg.MyFriend + self.Tabgroup:SelectIndex(t) + if t == XDormConfig.VisitTabTypeCfg.MyFriend then + self:OnReqFriendData() + else + self:OnReqVisitorData() + end +end + +--- +--- 请求好友宿舍数据 +--- ButtonGroup的按钮响应函数,切换标签的时候调用 +function XUiDormVisit:OnReqFriendData() + self.ListData = {} + local ids = XDataCenter.SocialManager.GetFriendIds() + if not Next(ids) then + self:SetFriendListData() + return + end + + local sendids = {} + local data = XDataCenter.DormManager.GetVisFriendData() + if Next(data) ~= nil then + local curtime = XTime.GetServerNowTimestamp() + for _, id in pairs(ids) do + local v = data[id] + if v then + if curtime - v.DataTime < TIME_LIMIT then + table.insert(self.ListData, v) + else + table.insert(sendids, id) + end + else + table.insert(sendids, id) + end + end + + if Next(sendids) then + if Next(self.ListData) then + self:SetFriendListData(self.ListData) + XDataCenter.DormManager.RequestDormitoryDetails(sendids) + else + XDataCenter.DormManager.RequestDormitoryDetails(sendids, self.UpdateFriendCb) + end + else + self:SetFriendListData(self.ListData) + end + else + XDataCenter.DormManager.RequestDormitoryDetails(ids, self.UpdateFriendCb) + end +end + +--- +--- 请求访客宿舍数据 +--- ButtonGroup的按钮响应函数,切换标签时调用 +function XUiDormVisit:OnReqVisitorData() + local data = XDataCenter.DormManager.GetDormitoryRecommendTotalData() + self.ListData = {} + if Next(data) ~= nil then + local curtime = XTime.GetServerNowTimestamp() + if curtime - self.PreVistorReqTime < TIME_LIMIT then + for _, v in pairs(data) do + table.insert(self.ListData, v) + end + self:SetVisitorData(self.ListData) + return + end + end + + self.PreVistorReqTime = XTime.GetServerNowTimestamp() + XDataCenter.DormManager.RequestDormitoryRecommend(self.SetVisitorCb) +end + +function XUiDormVisit:OnEnable() + XEventManager.AddEventListener(XEventId.EVENT_DORM_VISTOR_SKIP, self.OnVisit, self) +end + +function XUiDormVisit:OnDisable() +end + +--- +--- 查看玩家信息时,点击查看宿舍会派发EVENT_DORM_VISTOR_SKIP,调用此函数 +function XUiDormVisit:OnVisit(playid, dormId) + local charId = XDataCenter.DormManager.GetVisitorDormitoryCharacterId() + XLuaUiManager.CloseWithCallback("UiDormVisit", function() + XDataCenter.DormManager.RequestDormitoryVisit(playid, dormId, charId, function() + self:DoDormVisitor(playid, dormId) + end) + end) +end + +function XUiDormVisit:OnDestroy() + XEventManager.RemoveEventListener(XEventId.EVENT_DORM_VISTOR_SKIP, self.OnVisit, self) +end + +function XUiDormVisit:InitUI() + self.TxtScoreDes.text = TextManager.GetText("DormTotalScore") + self.BtnRandomVisit:SetName(TextManager.GetText("DormVisitBtn")) + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.DormCoin, XDataCenter.ItemManager.ItemId.FurnitureCoin) + self.UpdateFriendCb = function() self:UpdateFriendList() end + self.SetVisitorCb = function(data) self:SetVisitorListData(data) end + self.OnClickEmptyVisitorCb = function() self:OnClickEmptyVisitor() end + self:AddListener() + self:InitList() +end + +function XUiDormVisit:OnClickEmptyVisitor() + XLuaUiManager.Open("UiSocial") +end + +function XUiDormVisit:AddListener() + self.OnBtnRandomVisitCb = function() self:OnBtnRandomVisit() end + self.OnBtnMainUIClickCb = function() self:OnBtnMainUIClick() end + self.OnBtnReturnClickCb = function() self:OnBtnReturnClick() end + self.OnEnterDormcb = function() self:EnterDormVisitor() end + self:RegisterClickEvent(self.BtnRandomVisit, self.OnBtnRandomVisitCb) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUIClickCb) + self:RegisterClickEvent(self.BtnBack, self.OnBtnReturnClickCb) + self:RegisterClickEvent(self.VisitTips, self.OnClickEmptyVisitorCb) +end + +function XUiDormVisit:OnBtnMainUIClick() + XLuaUiManager.RunMain() +end + +function XUiDormVisit:OnBtnReturnClick() + XLuaUiManager.Close("UiDormVisit") +end + +function XUiDormVisit:OnBtnRandomVisit() + local d = self.ListData or {} + local len = #d + if len == 0 then + return + end + + local index = math.random(1, len) + self.DormData = d[index] + + if self.DormData then + local dormId = self.DormData.DormitoryId + local charId = XDataCenter.DormManager.GetVisitorDormitoryCharacterId() + XLuaUiManager.CloseWithCallback("UiDormVisit", function() + XDataCenter.DormManager.RequestDormitoryVisit(self.DormData.PlayerId, dormId, charId, self.OnEnterDormcb) + end) + end +end + +function XUiDormVisit:EnterDormVisitor() + if self.DormData and self.DormData.PlayerId and self.DormData.DormitoryId then + self:DoDormVisitor(self.DormData.PlayerId, self.DormData.DormitoryId) + end +end + +--- +--- 访问玩家'playerId'的'dormitoryId'宿舍 +function XUiDormVisit:DoDormVisitor(playerId, dormitoryId) + local t = XDormConfig.VisitDisplaySetType.Stranger + if self.CuTabType == XDormConfig.VisitTabTypeCfg.MyFriend then + t = XDormConfig.VisitDisplaySetType.MyFriend + end + if self.HostelSecond and (not XTool.UObjIsNil(self.HostelSecond.GameObject)) then + self.HostelSecond.GameObject:SetActive(true) + self.HostelSecond:OnRecordSelfDormId() + XDataCenter.DormManager.VisitDormitory(t, dormitoryId) + self.HostelSecond:UpdateData(t, dormitoryId, playerId) + else + XLuaUiManager.Open("UiDormSecond", t, dormitoryId, playerId) + XDataCenter.DormManager.VisitDormitory(t, dormitoryId) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormVisit/XUiDormVisitGridItem.lua b/Resources/Scripts/XUi/XUiDormVisit/XUiDormVisitGridItem.lua new file mode 100644 index 00000000..9a3b49e2 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormVisit/XUiDormVisitGridItem.lua @@ -0,0 +1,123 @@ +local XUiDormVisitGridItem = XClass(nil, "XUiDormVisitGridItem") +local TextManager = CS.XTextManager + +function XUiDormVisitGridItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.OnBtnClickcb = function() self:OnBtnClick() end + self.OnEnterDormcb = function() self:EnterDormVisitor() end + self.TextOnline = TextManager.GetText("DormOnline") + self.TextOffline = TextManager.GetText("DormOffline") + XTool.InitUiObject(self) +end + +function XUiDormVisitGridItem:OnBtnClick() + if self.BtnVisit.ButtonState == CS.UiButtonState.Disable then + return + end + + if self.ItemData.DormitoryId == 0 then + return + end + + local charId = XDataCenter.DormManager.GetVisitorDormitoryCharacterId() + XDataCenter.DormManager.RequestDormitoryVisit(self.ItemData.PlayerId, self.ItemData.DormitoryId, charId, self.OnEnterDormcb) +end + +function XUiDormVisitGridItem:EnterDormVisitor() + if XLuaUiManager.IsUiShow("UiDormVisit") then + XLuaUiManager.Close("UiDormVisit") + end + local displaytype = XDormConfig.VisitDisplaySetType.MyFriend + if self.UiRoot.CuTabType == XDormConfig.VisitTabTypeCfg.Visitor then + displaytype = XDormConfig.VisitDisplaySetType.Stranger + end + + if self.HostelSecond then + self.HostelSecond.GameObject:SetActive(true) + self.HostelSecond:OnRecordSelfDormId() + XDataCenter.DormManager.VisitDormitory(displaytype, self.ItemData.DormitoryId) + self.HostelSecond:UpdateData(displaytype, self.ItemData.DormitoryId, self.ItemData.PlayerId) + else + XLuaUiManager.Open("UiDormSecond", displaytype, self.ItemData.DormitoryId, self.ItemData.PlayerId) + XDataCenter.DormManager.VisitDormitory(displaytype, self.ItemData.DormitoryId) + end +end + +function XUiDormVisitGridItem:Init(uiRoot) + self.UiRoot = uiRoot + self.HostelSecond = uiRoot.HostelSecond + self.UiRoot:RegisterClickEvent(self.BtnVisit, self.OnBtnClickcb) + self.BtnView.CallBack = function() self:OnBtnViewClick() end +end + +function XUiDormVisitGridItem:GetMaxScore(atts) + local score = 0 + local index = 1 + for i, v in pairs(atts) do + if v > score then + index = i + score = v + end + end + + return index, score +end + +-- 更新数据 +function XUiDormVisitGridItem:OnRefresh(itemData) + if not itemData then + return + end + + self.ItemData = itemData + local dormitoryName = itemData.DormitoryName + + if dormitoryName ~= "" then + if self.UiRoot.CuTabType == XDormConfig.VisitTabTypeCfg.MyFriend then + local name = XDataCenter.SocialManager.GetPlayerRemark(itemData.PlayerId, itemData.PlayerName) + self.TxtName.text = TextManager.GetText("DormVisitNameStyle", name, dormitoryName) + else + self.TxtName.text = TextManager.GetText("DormVisitNameStyle", itemData.PlayerName, dormitoryName) + end + local index, score = self:GetMaxScore(itemData.DormitoryAttr) + self.TxtFeelDes.text = XFurnitureConfigs.GetDormFurnitureTypeName(index) + self.TxtFeelCount.text = score + else + self.TxtName.text = TextManager.GetText("DormNoCount") + self.TxtFeelDes.text = "" + self.TxtFeelCount.text = "" + end + + self.TxtTotalCount.text = itemData.FurnitureScore + self.TxtFurnitureCount.text = itemData.FurnitureCount or 0 + + XUiPLayerHead.InitPortrait(itemData.PlayerHead, itemData.PlayerHeadFrame, self.Head) + + if itemData.IsOnline then + self.TxtOnline.text = self.TextOnline + else + self.TxtOnline.text = self.TextOffline + end + + local playerId = self.ItemData.PlayerId + local appearanceShowType = self.ItemData.DormitoryType + local hasPermission = XDataCenter.DormManager.HasDormPermission(playerId, appearanceShowType) + + if hasPermission then + self.BtnVisit:SetButtonState(XUiButtonState.Normal) + else + self.BtnVisit:SetButtonState(XUiButtonState.Disable) + end +end + +function XUiDormVisitGridItem:OnBtnViewClick() + if not self.ItemData or not self.ItemData.PlayerId then + return + end + + --个人信息 + XDataCenter.PersonalInfoManager.ReqShowInfoPanel(self.ItemData.PlayerId) +end + +return XUiDormVisitGridItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormVisit/XUiDormVisitTypeListItem.lua b/Resources/Scripts/XUi/XUiDormVisit/XUiDormVisitTypeListItem.lua new file mode 100644 index 00000000..0294d083 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormVisit/XUiDormVisitTypeListItem.lua @@ -0,0 +1,41 @@ +local XUiDormVisitTypeListItem = XClass(nil, "XUiDormVisitTypeListItem") +local TabState = { + Normal = 0, + Press = 1, + Select = 2, + Disable = 3, +} +function XUiDormVisitTypeListItem:Ctor(ui) + self.PoolObjs = {} + self.CurObjs = {} + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.XUiBtn = self.Transform:GetComponent(typeof(CS.XUiComponent.XUiButton)) +end + +function XUiDormVisitTypeListItem:Init(ui, uiRoot) + self.Parent = ui + self.UiRoot = uiRoot +end + +-- 更新数据 +function XUiDormVisitTypeListItem:OnRefresh(itemData) + if not itemData then + return + end + + self.XUiBtn:SetName(itemData) +end + +-- 设置状态 +function XUiDormVisitTypeListItem:SetState(state) + if self.CurState ~= state then + self.CurState = state + if not state then + self.XUiBtn:SetButtonState(TabState.Select) + else + self.XUiBtn:SetButtonState(TabState.Normal) + end + end +end +return XUiDormVisitTypeListItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormWork/XUiDormFoundryDetail.lua b/Resources/Scripts/XUi/XUiDormWork/XUiDormFoundryDetail.lua new file mode 100644 index 00000000..f9e5677f --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormWork/XUiDormFoundryDetail.lua @@ -0,0 +1,120 @@ +local Object = CS.UnityEngine.Object +local XUiDormFoundryDetail = XLuaUiManager.Register(XLuaUi, "UiDormFoundryDetail") +local XUiDormFoundryDetailItem = require("XUi/XUiDormWork/XUiDormFoundryDetailItem") +local XUiDormFoundryDetailRewardItem = require("XUi/XUiDormWork/XUiDormFoundryDetailRewardItem") + +function XUiDormFoundryDetail:OnAwake() + self.RewardGoPool = {} + XTool.InitUiObject(self) + self:Initfun() + self:InitList() +end + +function XUiDormFoundryDetail:InitList() + self.DynamicTable = XDynamicTableNormal.New(self.PanelExpendContent.gameObject) + self.DynamicTable:SetProxy(XUiDormFoundryDetailItem) + self.DynamicTable:SetDelegate(self) +end + +-- [监听动态列表事件] +function XUiDormFoundryDetail:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self, self.UiRoot) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.ListData[index] + grid:OnRefresh(data) + end +end + +function XUiDormFoundryDetail:OnStart(uiRoot, datalist) + self.UiRoot = uiRoot + self.ListData = datalist + self:OnRefresh() +end + +function XUiDormFoundryDetail:OnEnable() + self:OnRefresh() +end + +function XUiDormFoundryDetail:OnDisable() + for _, v in pairs(self.RewardGoPool) do + if v then + v.GameObject:SetActiveEx(false) + end + end + self.UiRoot.PanelWork.gameObject:SetActiveEx(true) +end + +function XUiDormFoundryDetail:OnDestroy() +end + +function XUiDormFoundryDetail:OnRefreshData(datalist) + self.ListData = datalist + self:OnRefresh() +end + +function XUiDormFoundryDetail:OnRefresh() + self.DynamicTable:SetDataSource(self.ListData) + self.DynamicTable:ReloadDataSync(1) + self.WorkposList = {} + self.WorkRewardCount = {} + self.TotalWorkRewCount = 0 + for _, v in pairs(self.ListData) do + table.insert(self.WorkposList, v.WorkPos) + local c = XDataCenter.DormManager.GetDormWorkRewCounrByPos(v.WorkPos) + self.TotalWorkRewCount = self.TotalWorkRewCount + c + end + + local count = #self.ListData + local dormcount = XDataCenter.DormManager.GetDormitoryCount() + local daiGongData = XDormConfig.GetDormCharacterWorkById(dormcount) + local index = 1 + if daiGongData then + local cfg = XDataCenter.ItemManager.GetItemTemplate(daiGongData.ItemId) + local item = self:GetGride(index) + item:OnRefresh(cfg, self.TotalWorkRewCount, false) + --local extracount = 0 + local rewardList = XRewardManager.GetRewardList(daiGongData.ExtraReward) + if rewardList then + for _, v in pairs(rewardList) do + -- if v.TemplateId == cfg.Id then + -- extracount = extracount + v.Count + -- else + index = index + 1 + local itemNext = self:GetGride(index) + itemNext:OnRefresh(v, count * v.Count, true) + -- end + end + end + -- item:RefreshExCount(extracount) + end +end + +function XUiDormFoundryDetail:GetGride(index) + if self.RewardGoPool[index] then + self.RewardGoPool[index].GameObject:SetActiveEx(true) + return self.RewardGoPool[index] + end + + local obj = Object.Instantiate(self.RewardGrid, self.Rewards) + obj.gameObject:SetActive(true) + local item = XUiDormFoundryDetailRewardItem.New(obj) + item:Init(self.UiRoot) + table.insert(self.RewardGoPool, item) + return item +end + +function XUiDormFoundryDetail:Initfun() + self.BtnCloseFun = function() self:Close() end + self.OnCompleteFun = function() self:OnComplete() end + self.BtnComplete.CallBack = self.OnCompleteFun + self.BtncCancel.CallBack = self.BtnCloseFun + self.BtnClose.CallBack = self.BtnCloseFun + self.BtnBg.CallBack = self.BtnCloseFun +end + +function XUiDormFoundryDetail:OnComplete() + XDataCenter.DormManager.DormWordDoneReq(self.WorkposList, function() + XDataCenter.DormManager.QuickDormDoneCallBack(self.WorkposList) + end) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormWork/XUiDormFoundryDetailItem.lua b/Resources/Scripts/XUi/XUiDormWork/XUiDormFoundryDetailItem.lua new file mode 100644 index 00000000..ff681276 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormWork/XUiDormFoundryDetailItem.lua @@ -0,0 +1,28 @@ +local XUiDormFoundryDetailItem = XClass(nil, "XUiDormFoundryDetailItem") + +function XUiDormFoundryDetailItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +-- 更新数据 +function XUiDormFoundryDetailItem:OnRefresh(itemData) + if not itemData then + return + end + + local iconpath = itemData.CurIconpath + if iconpath and self.CurIconpath ~= iconpath then + self.CurIconpath = iconpath + self.UiRoot:SetUiSprite(self.ImgIcon, iconpath) + end + + self.MoodValue.text = string.format("-%s", math.floor(itemData.DaiGongData.Mood / 100)) +end + +function XUiDormFoundryDetailItem:Init(parent, uiRoot) + self.Parent = parent + self.UiRoot = uiRoot +end +return XUiDormFoundryDetailItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormWork/XUiDormFoundryDetailRewardItem.lua b/Resources/Scripts/XUi/XUiDormWork/XUiDormFoundryDetailRewardItem.lua new file mode 100644 index 00000000..44cd68ce --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormWork/XUiDormFoundryDetailRewardItem.lua @@ -0,0 +1,44 @@ +local XUiDormFoundryDetailRewardItem = XClass(nil, "XUiDormFoundryDetailRewardItem") + +function XUiDormFoundryDetailRewardItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +-- 更新数据 +function XUiDormFoundryDetailRewardItem:OnRefresh(itemData, dircount, flag) + if not itemData then + return + end + + self.ExtraAwardText.text = "" + self.GridItemUI:Refresh(itemData) + self:RefreshCount(dircount) + self:MarkFlag(flag) +end + +function XUiDormFoundryDetailRewardItem:Init(root) + self.GridItemUI = XUiGridCommon.New(root, self.GridIcon) +end + +function XUiDormFoundryDetailRewardItem:RefreshCount(count) + if self.GridItemUI and self.GridItemUI.TxtCount then + self.GridItemUI.TxtCount.text = CS.XTextManager.GetText("ShopGridCommonCount", count) + self.GridItemUI:ShowCount(true) + end +end + +function XUiDormFoundryDetailRewardItem:RefreshExCount(count) + if count == 0 then + return + end + + self.ExtraAwardText.text = string.format("(+%d)", count) +end + +function XUiDormFoundryDetailRewardItem:MarkFlag(flag) + self.ExtraAward.gameObject:SetActiveEx(flag) +end + +return XUiDormFoundryDetailRewardItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormWork/XUiDormWork.lua b/Resources/Scripts/XUi/XUiDormWork/XUiDormWork.lua new file mode 100644 index 00000000..b7eb0e35 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormWork/XUiDormWork.lua @@ -0,0 +1,383 @@ +local XUiDormWork = XLuaUiManager.Register(XLuaUi, "UiDormWork") +local XUiDormWorkListItem = require("XUi/XUiDormWork/XUiDormWorkListItem") +local XUiDormWorkMember = require("XUi/XUiDormWork/XUiDormWorkMember") +local DormWorkMaxCount = 0 +local Next = next +local RowMax = 3 +local TextManager = CS.XTextManager +local MathFmod = math.fmod + +function XUiDormWork:OnAwake() + self.TimerWorkDic = {} + self.DaiGongDataCache = {} + XTool.InitUiObject(self) + self:InitMaxCount() + self:InitUI() + self:InitList() +end + +function XUiDormWork:InitMaxCount() + DormWorkMaxCount = 0 + local cfgWork = XDormConfig.GetDormCharacterWorkData() or {} + local count = XDataCenter.DormManager.GetDormitoryCount() + local index = count + local temple = #cfgWork + self.IsFullWorkPos = false --是否所有工位都开了 + if count > temple then + index = temple + self.IsFullWorkPos = true + end + + local totalcount = XDormConfig.GetTotalDormitortCountCfg() + self.IsLastSecond = count + 1 == totalcount -- 倒数第二个 + self.CurWorkIndex = index + local data = XDormConfig.GetDormCharacterWorkById(index) + local finishcfg = XDormConfig.GetDormCharacterWorkById(totalcount) or {} + self.LastDormSeatCount = finishcfg.Seat or 0 + if data then + DormWorkMaxCount = data.Seat or 0 + end +end + +function XUiDormWork:InitList() + self.DynamicTable = XDynamicTableNormal.New(self.PanelItemCommon.gameObject) + self.DynamicTable:SetProxy(XUiDormWorkListItem) + self.DynamicTable:SetDelegate(self) +end + +-- [监听动态列表事件] +function XUiDormWork:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.ListData[index] + local i = (index - 1) * RowMax + 1 + grid:OnRefresh(data, i) + end +end + +-- 从上到下从左到右排序。每一列最多排3个,排满DormWorkMaxCount为止。 +function XUiDormWork:SetListData() + local data = XDataCenter.DormManager.GetDormWorkData() + if Next(data) == nil then--所有工位都是空的,自己填充数据 + self.CurWorkCount = 0 + local havecount = XDataCenter.DormManager.GetDormitoryCount() + if havecount > self.LastDormSeatCount then + havecount = self.LastDormSeatCount + end + for _ = 1, havecount do + table.insert(data, XDormConfig.WorkPosState.Empty) + end + + self.ListData = self:GetListMemberListDatas(data) + + if self.WorkTimer then + XScheduleManager.UnSchedule(self.WorkTimer) + self.WorkTimer = nil + end + else + self.ListData = self:GetListMemberListDatas(data) + if not self.WorkTimer then + self.WorkTimer = XScheduleManager.ScheduleForever(self.UpdateWorkTimerCb, 1000) + end + end + + self.DynamicTable:SetDataSource(self.ListData) + self.DynamicTable:ReloadDataASync(1) + self.RefreshTime = XDataCenter.DormManager.GetDormWorkRefreshTime() + self.TextCount.text = TextManager.GetText("DormWorkRefreshTime", XTime.TimestampToGameDateTimeString(self.RefreshTime, "HH:mm")) + self.TxtWorkCount.text = CS.XTextManager.GetText("DormWorkCount", self.CurWorkCount, DormWorkMaxCount) +end + +function XUiDormWork:UpdateWorkList() + local data = XDataCenter.DormManager.GetDormWorkData() + self.ListData = self:GetListMemberListDatas(data) + for index, itemData in pairs(self.ListData) do + local item = self.DynamicTable:GetGridByIndex(index) + local i = (index - 1) * RowMax + 1 + if item then + item:OnRefresh(itemData, i) + end + end + if not self.WorkTimer then + self.WorkTimer = XScheduleManager.ScheduleForever(self.UpdateWorkTimerCb, 1000) + end + + self.TxtWorkCount.text = CS.XTextManager.GetText("DormWorkCount", self.CurWorkCount, DormWorkMaxCount) +end + +function XUiDormWork:UpdateDaiGong() + self:UpdateWorkList() + self:CloseChildUi("UiDormFoundryDetail") +end + +-- 通知打工刷新时间 +function XUiDormWork:DormWorkRefresh() + local WorkRefreshTime = XDataCenter.DormManager.GetDormWorkRefreshTime() + local t = (WorkRefreshTime - XTime.GetServerNowTimestamp()) * 1000 + if t <= 0 or XDataCenter.DormManager.NotifyDormWorkRefreshFlag == true then + XDataCenter.DormManager.NotifyDormWorkRefreshFlag = false + self:DormWorkRefreshReq() + else + self.DormWorkTimer = XScheduleManager.ScheduleOnce(self.DormWorkRefreshReqCb, t) + end +end + +-- 更新打工倒计时 +function XUiDormWork:UpdateWorkTimer() + for _, v in pairs(self.TimerWorkDic) do + if v then + v() + end + end +end + +function XUiDormWork:RegisterWorkTimer(cb, index) + if not cb or not index then + return + end + + self.TimerWorkDic[index] = cb +end + +function XUiDormWork:RemoveWorkTimer(index) + self.TimerWorkDic[index] = nil +end + +function XUiDormWork:DormWorkRefreshReq() + if self.DormWorkTimer ~= nil then + XScheduleManager.UnSchedule(self.DormWorkTimer) + self.DormWorkTimer = nil + end + self.CurWorkCount = 0 + local data = {} + for _, itemDatas in pairs(self.ListData) do + local d = {} + for _, itemData in pairs(itemDatas) do + if itemData ~= XDormConfig.WorkPosState.Empty and itemData ~= XDormConfig.WorkPosState.Lock then + if itemData.WorkEndTime and itemData.WorkEndTime == 0 then + table.insert(d, XDormConfig.WorkPosState.Empty) + else + self.CurWorkCount = self.CurWorkCount + 1 + table.insert(d, itemData) + end + else + table.insert(d, itemData) + end + end + if Next(d) then + table.insert(data, d) + else + table.insert(data, itemDatas) + end + end + + self.TxtWorkCount.text = CS.XTextManager.GetText("DormWorkCount", self.CurWorkCount, DormWorkMaxCount) + self.ListData = data + for index, itemData in pairs(self.ListData) do + local item = self.DynamicTable:GetGridByIndex(index) + if item then + local i = (index - 1) * RowMax + 1 + item:OnRefresh(itemData, i) + end + end + XDataCenter.DormManager.ResetDormWorkPos() +end + +function XUiDormWork:GetListMemberListDatas(data) + self:FillListData(data) + local listitems = {} + local itemdatas = {} + local count = 0 + + for index, v in pairs(data) do + local mod = MathFmod(index, RowMax) + table.insert(itemdatas, v) + if mod == 0 then + table.insert(listitems, itemdatas) + itemdatas = {} + end + if v ~= XDormConfig.WorkPosState.Lock and v ~= XDormConfig.WorkPosState.Empty then + count = count + 1 + end + end + + if Next(itemdatas) ~= nil then + table.insert(listitems, itemdatas) + end + self.CurWorkCount = count + return listitems +end + +-- 填充数据 +function XUiDormWork:FillListData(listitems) + -- 填空工位 + local totallen = #listitems + if DormWorkMaxCount > totallen then + local rowcount = DormWorkMaxCount - totallen + for _ = 1, rowcount do + table.insert(listitems, XDormConfig.WorkPosState.Empty) + end + end + + -- 填充lock数据 + if self.IsFullWorkPos then + return + end + + local lockcount = RowMax -- 正常填3个 + local residue = MathFmod(DormWorkMaxCount, RowMax) + if residue > 0 then + lockcount = RowMax + (RowMax - residue) + end + + if self.IsLastSecond then -- 倒数第二个填与最后一个的差值 + local cfg = XDormConfig.GetDormCharacterWorkById(self.CurWorkIndex + 1) + if cfg then + lockcount = cfg.Seat - DormWorkMaxCount + else + lockcount = 0 + end + else + local cfg = XDormConfig.GetDormCharacterWorkById(self.CurWorkIndex + 1) + if not cfg then + lockcount = 0 + end + end + if DormWorkMaxCount + lockcount > self.LastDormSeatCount then + lockcount = self.LastDormSeatCount - DormWorkMaxCount + end + for _ = 1, lockcount do + table.insert(listitems, XDormConfig.WorkPosState.Lock) + end +end + +-- 打开人员列表 +function XUiDormWork:OpenMemeberList() + self.PanelMember.gameObject:SetActive(true) + if not self.InitMember then + self.InitMember = true + self.MemberUI = XUiDormWorkMember.New(self.PanelMember, self) + end + self.MemberUI:OnRefresh(self.CurWorkCount) +end + +function XUiDormWork:OnStart() + self:SetListData() +end + +function XUiDormWork:OnEnable() + self:DormWorkRefresh() + XEventManager.AddEventListener(XEventId.EVENT_DORM_WORK_RESET, self.DormWorkRefreshReq, self) + XEventManager.AddEventListener(XEventId.EVENT_DORM_DAI_GONE_REWARD, self.UpdateDaiGong, self) + -- XEventManager.AddEventListener(XEventId.EVENT_DORM_SKIP, self.SkipFun, self) +end + +-- function XUiDormWork:SkipFun() +-- -- XLuaUiManager.Close("UiSkip") +-- -- XLuaUiManager.Close("UiTip") +-- end +function XUiDormWork:OnDisable() + if self.DormWorkTimer then + XScheduleManager.UnSchedule(self.DormWorkTimer) + self.DormWorkTimer = nil + end + if self.WorkTimer then + XScheduleManager.UnSchedule(self.WorkTimer) + self.WorkTimer = nil + end + XEventManager.RemoveEventListener(XEventId.EVENT_DORM_WORK_RESET, self.DormWorkRefreshReq, self) + XEventManager.RemoveEventListener(XEventId.EVENT_DORM_DAI_GONE_REWARD, self.UpdateDaiGong, self) + -- XEventManager.RemoveEventListener(XEventId.EVENT_DORM_SKIP, self.SkipFun, self) +end + +function XUiDormWork:InitUI() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.DormCoin, XDataCenter.ItemManager.ItemId.FurnitureCoin) + self.TxtDaigong.text = TextManager.GetText("DormTxtDaigongDes") + self:Initfun() +end + +function XUiDormWork:Initfun() + self.OnBtnMainUIClickCb = function() self:OnBtnMainUIClick() end + self.OnBtnReturnClickCb = function() self:OnBtnReturnClick() end + self.OnBtnHelpClickCb = function() self:OnBtnHelpClick() end + self.DormWorkRefreshReqCb = function() self:DormWorkRefreshReq() end + self.UpdateWorkTimerCb = function() self:UpdateWorkTimer() end + self.OnBtnTotalGetCb = function() self:OnBtnTotalGet() end + self.OnUpdateListDataCb = function() self:SetListData() end + self.OnUpdateWorkListDataCb = function() self:UpdateWorkList() end + + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUIClickCb) + self:RegisterClickEvent(self.BtnBack, self.OnBtnReturnClickCb) + self:RegisterClickEvent(self.BtnHelp, self.OnBtnHelpClickCb) + self:RegisterClickEvent(self.BtnTotalGet, self.OnBtnTotalGetCb) + self.BtnDaigong.CallBack = function() self:OnBtnDaigong() end +end + +function XUiDormWork:OnBtnDaigong() + local count = XDataCenter.DormManager.GetDormitoryCount() + local daiGongData = XDormConfig.GetDormCharacterWorkById(count) + local data = XDataCenter.DormManager.GetDormWorkData() + local daigongList = {} + for _, v in pairs(data) do + if v.WorkEndTime > 0 and v.WorkEndTime > XTime.GetServerNowTimestamp() then + local mood = XDataCenter.DormManager.GetMoodById(v.CharacterId) + if math.floor(daiGongData.Mood / 100) <= mood then + if not self.DaiGongDataCache[v.CharacterId] then + local d = {} + d.DaiGongData = daiGongData + d.WorkPos = v.WorkPos + d.CurIconpath = XDormConfig.GetCharacterStyleConfigQIconById(v.CharacterId) + self.DaiGongDataCache[v.CharacterId] = d + end + if self.PreDormCount ~= count then + self.PreDormCount = count + self.DaiGongDataCache[v.CharacterId].DaiGongData = daiGongData + end + table.insert(daigongList, self.DaiGongDataCache[v.CharacterId]) + end + end + end + + if not Next(daigongList) then + XUiManager.TipText("DormDaiGongWarnTips") + return + end + + self:OpenOneChildUi("UiDormFoundryDetail", self, daigongList) + if not self.FundryDetail then + self.FundryDetail = self:FindChildUiObj("UiDormFoundryDetail") + end + self.FundryDetail:OnRefreshData(daigongList) + self.PanelWork.gameObject:SetActiveEx(false) +end + +function XUiDormWork:OnBtnHelpClick() + XUiManager.UiFubenDialogTip("", TextManager.GetText("DormDesWork") or "") +end + +function XUiDormWork:OnBtnTotalGet() + local poslist = {} + local data = XDataCenter.DormManager.GetDormWorkData() + + for _, v in pairs(data) do + if v.WorkEndTime > 0 and v.WorkEndTime - XTime.GetServerNowTimestamp() < 0 then + table.insert(poslist, v.WorkPos) + end + end + + if Next(poslist) == nil then + XUiManager.TipMsg(TextManager.GetText("DormWorkNoRewardTips")) + return + end + + XDataCenter.DormManager.RequestDormitoryWorkReward(poslist, self.OnUpdateWorkListDataCb) +end + +function XUiDormWork:OnBtnMainUIClick() + XLuaUiManager.RunMain() +end + +function XUiDormWork:OnBtnReturnClick() + XLuaUiManager.Close("UiDormWork") +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormWork/XUiDormWorkGridItem.lua b/Resources/Scripts/XUi/XUiDormWork/XUiDormWorkGridItem.lua new file mode 100644 index 00000000..bdfc4667 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormWork/XUiDormWorkGridItem.lua @@ -0,0 +1,178 @@ +local XUiDormWorkGridItem = XClass(nil, "XUiDormWorkGridItem") +local TextManager = CS.XTextManager + +function XUiDormWorkGridItem:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + XTool.InitUiObject(self) + self:InitFun() + self:InitText() +end + +function XUiDormWorkGridItem:InitText() + self.TextDormWorked = TextManager.GetText("DormWorked") + self.TextDormWorking = TextManager.GetText("DormWorking") + self.TextDormReward = TextManager.GetText("DormRewardText") + self.TextDormNoRewardGet = TextManager.GetText("DormWorkNoRewardTips") + self.TextDormNoMood = TextManager.GetText("DormWorkNoMoodTips") +end + +function XUiDormWorkGridItem:InitFun() + self.Btnclickcb = function() self:OnBtnClick() end + self.TimerFunCb = function() self:UpdateTimer() end + self.GetRewardCb = function() self.UiRoot:SetListData() end + self.UiRoot:RegisterClickEvent(self.Transform, self.Btnclickcb) +end + +function XUiDormWorkGridItem:OnBtnClick() + if not self.ItemData then + return + end + + if self.CurState == XDormConfig.WorkPosState.RewardEd then + XUiManager.TipMsg(self.TextDormNoRewardGet) + return + end + + if self.CurState == XDormConfig.WorkPosState.Empty then + self.UiRoot:OpenMemeberList() + elseif self.CurState == XDormConfig.WorkPosState.Worked then + self.UiRoot:OnBtnTotalGet() + elseif self.CurState == XDormConfig.WorkPosState.Working then + if self.CurDaigonState == XUiButtonState.Disable then + XUiManager.TipMsg(self.TextDormNoMood) + else + local d = {} + d.DaiGongData = self.DaiGongData + d.WorkPos = self.ItemData.WorkPos + d.CurIconpath = XDormConfig.GetCharacterStyleConfigQIconById(self.ItemData.CharacterId) + self.UiRoot:OpenOneChildUi("UiDormFoundryDetail", self.UiRoot, { d }) + if not self.FundryDetail then + self.FundryDetail = self.UiRoot:FindChildUiObj("UiDormFoundryDetail") + end + self.FundryDetail:OnRefreshData({ d }) + self.UiRoot.PanelWork.gameObject:SetActiveEx(false) + end + else + XUiManager.TipText("DormWorkPosUnLockTips") + end +end + +-- 更新数据 +function XUiDormWorkGridItem:OnRefresh(itemData, index) + if not itemData then + return + end + + index = string.format("%02d", index) + self.CurIndex = index + self.ItemData = itemData + if itemData == XDormConfig.WorkPosState.Empty then + self.TxtEmptyCount.text = index + self.CurState = XDormConfig.WorkPosState.Empty + self.ContainerEmpty.gameObject:SetActive(true) + self.ContainerItem.gameObject:SetActive(false) + self.ContainerFinish.gameObject:SetActive(false) + self.ContainerFinishEd.gameObject:SetActive(false) + self.ContainerLock.gameObject:SetActive(false) + return + elseif itemData == XDormConfig.WorkPosState.Lock then + self.TxtLockCount.text = index + self.CurState = XDormConfig.WorkPosState.Lock + self.ContainerEmpty.gameObject:SetActive(false) + self.ContainerItem.gameObject:SetActive(false) + self.ContainerFinish.gameObject:SetActive(false) + self.ContainerFinishEd.gameObject:SetActive(false) + self.ContainerLock.gameObject:SetActive(true) + return + end + + self.ContainerEmpty.gameObject:SetActive(false) + self.ContainerLock.gameObject:SetActive(false) + + local iconpath = XDormConfig.GetCharacterStyleConfigQSIconById(itemData.CharacterId) + self.CurIconpath = iconpath + if iconpath then + self.UiRoot:SetUiSprite(self.ImgIcon, iconpath) + end + + local workendtime = itemData.WorkEndTime + if workendtime == 0 then + self.TxtState.text = self.TextDormReward + self.TxtTimer.text = "" + self.TxtFinishedCount.text = index + self.CurState = XDormConfig.WorkPosState.RewardEd + self.ContainerFinishEd.gameObject:SetActive(true) + self.ContainerFinish.gameObject:SetActive(false) + self.ContainerItem.gameObject:SetActive(false) + self.UiRoot:RemoveWorkTimer(self.ItemData.WorkPos) + return + end + + self.RetimeSec = workendtime - XTime.GetServerNowTimestamp() + if self.RetimeSec <= 0 then + self.TxtState.text = self.TextDormWorked + self.CurState = XDormConfig.WorkPosState.Worked + self.TxtTimer.text = "" + self.TxtFinishCount.text = index + self.ContainerFinish.gameObject:SetActive(true) + self.ContainerFinishEd.gameObject:SetActive(false) + self.ContainerItem.gameObject:SetActive(false) + local mood = XDataCenter.DormManager.GetMoodById(itemData.CharacterId) + self.MoodFinsihTxtValues.text = mood + local moodConfig = XDormConfig.GetMoodStateByMoodValue(mood) + self.UiRoot:SetUiSprite(self.MoodFinishIcon, moodConfig.Icon) + else + self.TxtTimer.text = XUiHelper.GetTime(self.RetimeSec, XUiHelper.TimeFormatType.HOSTEL) + self.TxtState.text = self.TextDormWorking + self.CurState = XDormConfig.WorkPosState.Working + self.UiRoot:RegisterWorkTimer(self.TimerFunCb, itemData.WorkPos) + self.TxtItemCount.text = index + self.ContainerItem.gameObject:SetActive(true) + self.ContainerFinish.gameObject:SetActive(false) + self.ContainerFinishEd.gameObject:SetActive(false) + local count = XDataCenter.DormManager.GetDormitoryCount() + self.DaiGongData = XDormConfig.GetDormCharacterWorkById(count) + local mood = XDataCenter.DormManager.GetMoodById(itemData.CharacterId) + if self.DaiGongData and self.DaiGongData.Mood then + local v = math.floor(self.DaiGongData.Mood / 100) + if v <= mood then + self.CurDaigonState = XUiButtonState.Normal + self.BtnDaigong:SetButtonState(XUiButtonState.Normal) + else + self.CurDaigonState = XUiButtonState.Disable + self.BtnDaigong:SetButtonState(XUiButtonState.Disable) + end + end + self.MoodTxtValues.text = mood + local moodConfig = XDormConfig.GetMoodStateByMoodValue(mood) + self.UiRoot:SetUiSprite(self.MoodIcon, moodConfig.Icon) + end +end + +-- 更新倒计时 +function XUiDormWorkGridItem:UpdateTimer() + if self.RetimeSec <= 0 then + self.TxtState.text = self.TextDormWorked + self.CurState = XDormConfig.WorkPosState.Worked + self.TxtTimer.text = "" + self.ContainerFinish.gameObject:SetActive(true) + self.ContainerFinishEd.gameObject:SetActive(false) + self.ContainerItem.gameObject:SetActive(false) + self.TxtFinishCount.text = self.CurIndex + if self.ItemData and self.ItemData.WorkPos then + self.UiRoot:RemoveWorkTimer(self.ItemData.WorkPos) + local mood = XDataCenter.DormManager.GetMoodById(self.ItemData.CharacterId) + self.MoodFinsihTxtValues.text = mood + local moodConfig = XDormConfig.GetMoodStateByMoodValue(mood) + self.UiRoot:SetUiSprite(self.MoodFinishIcon, moodConfig.Icon) + end + return + end + + self.RetimeSec = self.RetimeSec - 1 + self.TxtTimer.text = XUiHelper.GetTime(self.RetimeSec, XUiHelper.TimeFormatType.HOSTEL) +end + +return XUiDormWorkGridItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormWork/XUiDormWorkListItem.lua b/Resources/Scripts/XUi/XUiDormWork/XUiDormWorkListItem.lua new file mode 100644 index 00000000..29ce75fb --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormWork/XUiDormWorkListItem.lua @@ -0,0 +1,51 @@ +local XUiDormWorkGridItem = require("XUi/XUiDormWork/XUiDormWorkGridItem") +local XUiDormWorkListItem = XClass(nil, "XUiDormWorkListItem") + +function XUiDormWorkListItem:Ctor(ui) + self.WordItemStates = {} + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + +end + +function XUiDormWorkListItem:CreateItem() + self.items = {} + local item0 = XUiDormWorkGridItem.New(self.WordItemState0, self.Parent) + local item1 = XUiDormWorkGridItem.New(self.WordItemState1, self.Parent) + local item2 = XUiDormWorkGridItem.New(self.WordItemState2, self.Parent) + item0.GameObject:SetActive(false) + item1.GameObject:SetActive(false) + item2.GameObject:SetActive(false) + self.items[1] = item0 + self.items[2] = item1 + self.items[3] = item2 +end + +function XUiDormWorkListItem:Init(parent) + self.Parent = parent + self:CreateItem() +end + +-- 更新数据 +function XUiDormWorkListItem:OnRefresh(itemData, index) + if not itemData then + return + end + + local count = 0 + for i, v in pairs(itemData) do + local item = self.items[i] + if item then + item.GameObject:SetActive(true) + item:OnRefresh(v, index + count) + count = count + 1 + end + end + + for i = count + 1, 3 do + self.items[i].GameObject:SetActive(false) + end +end + +return XUiDormWorkListItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormWork/XUiDormWorkMember.lua b/Resources/Scripts/XUi/XUiDormWork/XUiDormWorkMember.lua new file mode 100644 index 00000000..14b3e4ee --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormWork/XUiDormWorkMember.lua @@ -0,0 +1,162 @@ +local XUiDormWorkMemberListItem = require("XUi/XUiDormWork/XUiDormWorkMemberListItem") +local XUiDormWorkMember = XClass(nil, "XUiDormWorkMember") +local Next = next +local DormWorkMaxCount = 0 +local TextManager = CS.XTextManager + +function XUiDormWorkMember:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + self.CurWorkCount = 0 + self.RawWorkCount = 0 + self.CurWorkMoney = 0 + self.CurSeleWorkCharIds = {} + XTool.InitUiObject(self) + self:Init() +end + +function XUiDormWorkMember:InitMaxCount() + DormWorkMaxCount = 0 + local data = XDataCenter.DormManager.GetWorkCfg() + + if data then + DormWorkMaxCount = data.Seat or 0 + end +end + +function XUiDormWorkMember:InitList() + self.DynamicTable = XDynamicTableNormal.New(self.MemberList) + self.DynamicTable:SetProxy(XUiDormWorkMemberListItem) + self.DynamicTable:SetDelegate(self) +end + +-- [监听动态列表事件] +function XUiDormWorkMember:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self.UiRoot, self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.ListData[index] + grid:OnRefresh(data) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + grid:OnBtnClick() + end +end + +function XUiDormWorkMember:RecordWorkIds(characterid) + self.CurSeleWorkCharIds[characterid] = characterid +end + +function XUiDormWorkMember:RemoveWorkIds(characterid) + self.CurSeleWorkCharIds[characterid] = nil +end + +function XUiDormWorkMember:IsExistWorkId(characterid) + return self.CurSeleWorkCharIds[characterid] ~= nil +end + +function XUiDormWorkMember:OnBtnStartWorkClick() + local emptypos = self:GetEmptyWorkPosList() + + if Next(emptypos) == nil then + return + end + + local dormworklist = {} + for _, id in pairs(self.CurSeleWorkCharIds) do + local itemdata = {} + itemdata.CharacterId = id + itemdata.WorkPos = table.remove(emptypos) + table.insert(dormworklist, itemdata) + end + if Next(dormworklist) == nil then + if Next(self.ListData) ~= nil then + XUiManager.TipText("DormWorkNoPerson", XUiManager.UiTipType.Wrong) + else + XUiManager.TipText("DormWorkNoPerson1", XUiManager.UiTipType.Wrong) + end + return + end + + XDataCenter.DormManager.RequestDormitoryWork(dormworklist, self.OnWorkListUpdate) + self.CurSeleWorkCharIds = {} + self.GameObject:SetActive(false) +end + +-- 返回当前所有空的工位 +function XUiDormWorkMember:GetEmptyWorkPosList() + local emptypos = {} + local poslist = XDataCenter.DormManager.GetDormWorkPosData() + for index = DormWorkMaxCount, 1, -1 do + local pos = poslist[index] + if not pos then + table.insert(emptypos, index) + end + end + return emptypos +end + +function XUiDormWorkMember:OnBtnBgClick() + self:ClearListData() + self.UiRoot:PlayAnimation("MemberDisable") + self.GameObject:SetActive(false) +end + +function XUiDormWorkMember:ClearListData() + self.ListData = {} + self.CurSeleWorkCharIds = {} + self.DynamicTable:Clear() +end +function XUiDormWorkMember:Init() + self:InitList() + self:InitMaxCount() + self.OnBtnBgClickCb = function() self:OnBtnBgClick() end + self.OnBtnStartWorkClickCb = function() self:OnBtnStartWorkClick() end + self.OnWorkListUpdate = function() self.UiRoot:UpdateWorkList() end + -- self.OnWorkListUpdate = function() self.UiRoot:SetListData() end + self.BtnCancel.CallBack = self.OnBtnBgClickCb + self.BtnTanchuangClose.CallBack = self.OnBtnBgClickCb + self.BtnStartWork.CallBack = self.OnBtnStartWorkClickCb + self.XUiBtnCancel = self.BtnCancel:GetComponent("XUiButton") + self.XUiBtnStartWork = self.BtnStartWork:GetComponent("XUiButton") + self.XUiBtnCancel:SetName(TextManager.GetText("CancelText")) + self.XUiBtnStartWork:SetName(TextManager.GetText("DormWorkStart")) + self.TxtNonePerson.text = TextManager.GetText("DormWorkNoPerson1") +end + +-- 更新数据 +function XUiDormWorkMember:OnRefresh(count) + self.RawWorkCount = count + self.CurWorkCount = count + self.CurWorkMoney = 0 + local data = XDataCenter.DormManager.GetDormNotWorkData() + self.ListData = data + if not data or not Next(data) then + self.ImgNonePerson.gameObject:SetActive(true) + else + self.ImgNonePerson.gameObject:SetActive(false) + end + self.DynamicTable:SetDataSource(data) + self.DynamicTable:ReloadDataASync(1) + self.TxtWorkCount.text = TextManager.GetText("DormWorkSeleCount", self.RawWorkCount, DormWorkMaxCount) + self.TxtMoneyCount.text = 0 + self.UiRoot:PlayAnimation("MemberEnable") +end + +-- 更新工位数量和产出 +function XUiDormWorkMember:UpdateWorkCountAndMoney(count, money, flag) + self.CurWorkCount = self.CurWorkCount + count * flag + if self.CurWorkCount < self.RawWorkCount then + self.CurWorkCount = self.RawWorkCount + end + + self.CurWorkMoney = self.CurWorkMoney + money * flag + self.TxtWorkCount.text = TextManager.GetText("DormWorkSeleCount", self.CurWorkCount, DormWorkMaxCount) + self.TxtMoneyCount.text = self.CurWorkMoney +end + +function XUiDormWorkMember:IsFullMaxWorkCount() + return self.CurWorkCount >= DormWorkMaxCount +end + +return XUiDormWorkMember \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormWork/XUiDormWorkMemberGridItem.lua b/Resources/Scripts/XUi/XUiDormWork/XUiDormWorkMemberGridItem.lua new file mode 100644 index 00000000..a7772f1d --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormWork/XUiDormWorkMemberGridItem.lua @@ -0,0 +1,76 @@ +local XUiDormWorkMemberGridItem = XClass(nil, "XUiDormWorkMemberGridItem") +local Mathf = math.floor +local MaxVitality = 100 +local SelectOne = 1 +local SelectStates = { + Add = 1, + Reduce = -1 +} +local TextManager = CS.XTextManager + +function XUiDormWorkMemberGridItem:Ctor(ui, uiRoot, parent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + self.Parent = parent + self.btnClickCb = function() self:OnBtnClick() end + XTool.InitUiObject(self) + self.UiRoot:RegisterClickEvent(self.Transform, self.btnClickCb) +end + +function XUiDormWorkMemberGridItem:OnBtnClick() + self.CurStata = not self.CurStata + self:OnSetState(self.CurStata) + + local cfg = XDataCenter.DormManager.GetWorkCfg() + if not cfg then + return + end + + local vitaly = Mathf(cfg.Vitality / 100) + + local money = Mathf(self.Vitality / vitaly) + + if self.CurStata then + self.TxtTime.text = XUiHelper.GetTime(Mathf(self.Vitality * vitaly / cfg.Time), XUiHelper.TimeFormatType.HOSTEL) + self.TxtVit.text = Mathf(self.Vitality / vitaly) * cfg.Time * vitaly + if self.Parent:IsFullMaxWorkCount() then + XUiManager.TipText("DormWorkTips") + self.CurStata = false + self:OnSetState(false) + return + end + self.Parent:UpdateWorkCountAndMoney(SelectOne, money, SelectStates.Add) + self.Parent:RecordWorkIds(self.ItemData) + else + self.Parent:UpdateWorkCountAndMoney(SelectOne, money, SelectStates.Reduce) + self.Parent:RemoveWorkIds(self.ItemData) + end +end + +-- 更新数据 +function XUiDormWorkMemberGridItem:OnRefresh(itemData) + if not itemData then + return + end + + self.CurStata = false + self:OnSetState(false) + self.ItemData = itemData + local eventtemp = XHomeCharManager.GetCharacterEvent(itemData.CharacterId, true) + local icon = XDataCenter.DormManager.GetCharSmallHeadIcon(itemData) + if icon then + self.UiRoot:SetUiSprite(self.ImgIcon, icon) + end + self.Events.gameObject:SetActiveEx(eventtemp) + self.Vitality = XDataCenter.DormManager.GetVitalityById(self.ItemData) or 0 + + self.TxtVitCount.text = TextManager.GetText("DormWorkVitTxt", self.Vitality, MaxVitality) +end + +function XUiDormWorkMemberGridItem:OnSetState(state) + self.ImgSele.gameObject:SetActive(state) + self.ItemSele.gameObject:SetActive(state) +end + +return XUiDormWorkMemberGridItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDormWork/XUiDormWorkMemberListItem.lua b/Resources/Scripts/XUi/XUiDormWork/XUiDormWorkMemberListItem.lua new file mode 100644 index 00000000..64fe1edf --- /dev/null +++ b/Resources/Scripts/XUi/XUiDormWork/XUiDormWorkMemberListItem.lua @@ -0,0 +1,90 @@ +local XUiDormWorkMemberListItem = XClass(nil, "XUiDormWorkMemberListItem") +local Mathf = math.floor +local MaxVitality = XDormConfig.DORM_VITALITY_MAX_VALUE +local SelectOne = 1 +local SelectStates = { + Add = 1, + Reduce = -1 +} +local TextManager = CS.XTextManager + +function XUiDormWorkMemberListItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) +end + +function XUiDormWorkMemberListItem:Init(uiRoot, parent) + self.UiRoot = uiRoot + self.Parent = parent +end + +-- 更新数据 +function XUiDormWorkMemberListItem:OnRefresh(characterId) + if not characterId then + return + end + + self.CurStata = self.Parent:IsExistWorkId(characterId) + self:OnSetState(self.CurStata) + self.CharacterId = characterId + local icon = XDormConfig.GetCharacterStyleConfigQIconById(characterId) + if icon then + self.ImgIcon:SetRawImage(icon) + end + + local eventtemp = XHomeCharManager.GetCharacterEvent(characterId, true) + self.Events.gameObject:SetActiveEx(eventtemp) + self.Vitality = XDataCenter.DormManager.GetVitalityById(characterId) or 0 + self.TxtVitCount.text = TextManager.GetText("DormWorkVitTxt", self.Vitality, MaxVitality) + + local mood = XDataCenter.DormManager.GetMoodById(characterId) + local moodConfig = XDormConfig.GetMoodStateByMoodValue(mood) + self.TxtValues.text = mood + self.UiRoot:SetUiSprite(self.ImgMood, moodConfig.Icon) +end + +function XUiDormWorkMemberListItem:OnBtnClick() + self.CurStata = not self.CurStata + self:OnSetState(self.CurStata) + + local cfg = XDataCenter.DormManager.GetWorkCfg() + if not cfg then + return + end + + local vitaly = Mathf(cfg.Vitality / 100) + + local money = Mathf(self.Vitality / vitaly) + + if self.CurStata then + if self.Vitality < 1 or money < 1 then + self.CurStata = false + self:OnSetState(false) + XUiManager.TipText("DormWorkVitNotEn") + return + end + + self.TxtTime.text = XUiHelper.GetTime(Mathf(self.Vitality / vitaly) * cfg.Time, XUiHelper.TimeFormatType.HOSTEL) + self.TxtVit.text = Mathf(self.Vitality / vitaly) * vitaly + if self.Parent:IsFullMaxWorkCount() then + XUiManager.TipText("DormWorkTips") + self.CurStata = false + self:OnSetState(false) + return + end + + self.Parent:UpdateWorkCountAndMoney(SelectOne, money, SelectStates.Add) + self.Parent:RecordWorkIds(self.CharacterId) + else + self.Parent:UpdateWorkCountAndMoney(SelectOne, money, SelectStates.Reduce) + self.Parent:RemoveWorkIds(self.CharacterId) + end +end + +function XUiDormWorkMemberListItem:OnSetState(state) + self.ItemSele.gameObject:SetActive(state) +end + +return XUiDormWorkMemberListItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDraw/UiDrawPurchaseLB.lua b/Resources/Scripts/XUi/XUiDraw/UiDrawPurchaseLB.lua new file mode 100644 index 00000000..7a753d1a --- /dev/null +++ b/Resources/Scripts/XUi/XUiDraw/UiDrawPurchaseLB.lua @@ -0,0 +1,256 @@ +local CSXTextManagerGetText = CS.XTextManager.GetText +local TableInsert = table.insert +local Next = _G.next +local XUiDrawPurchaseLB = XLuaUiManager.Register(XLuaUi, "UiDrawPurchaseLB") +local XUiPurchaseLBListItem = require("XUi/XUiPurchase/XUiPurchaseLBListItem") +local CurrentSchedule = nil + +function XUiDrawPurchaseLB:OnAwake() + self:AutoRegisterListener() + self:InitDynamicTable() +end + +function XUiDrawPurchaseLB:OnStart(parent) + self.Parent = parent + self.CheckBuyFun = function(count, disCountCouponIndex) return self:CheckBuy(count, disCountCouponIndex) end + -- self.BeforeBuyReqFun = function(successCb) self:CheckIsOpenBuyTips(successCb) end + self.UpdateCb = function(rewardList) self:OnUpdate(rewardList) end +end + +function XUiDrawPurchaseLB:OnEnable() + self.DrawInfo = self.Parent.DrawInfo + self.TimeFuns = {} + self:OnRefresh() + self:StartLBTimer() + XEventManager.AddEventListener(XEventId.EVENT_PURCAHSE_BUYUSERIYUAN, self.OnUpdate, self) -- 海外修改 +end + +function XUiDrawPurchaseLB:OnDisable() + self:DestroyTimer() + XEventManager.RemoveEventListener(XEventId.EVENT_PURCAHSE_BUYUSERIYUAN, self.OnUpdate, self) -- 海外修改 +end + +function XUiDrawPurchaseLB:OnRefresh() + local drawPurchaseList = XDataCenter.DrawManager.GetDrawPurchase(self.DrawInfo.Id) + self.PurchaseDatas = self:OnSortFun(drawPurchaseList) + if not self.PurchaseDatas or not next(self.PurchaseDatas) then + self.PanelLb.gameObject:SetActiveEx(false) + self.PanelSoldOut.gameObject:SetActiveEx(true) + else + self.PanelLb.gameObject:SetActiveEx(true) + self.PanelSoldOut.gameObject:SetActiveEx(false) + end + + -- 少于3个插入空表 + local dataCount = #self.PurchaseDatas + if dataCount < 3 then + for i = 1, 3 - dataCount do + TableInsert(self.PurchaseDatas, {}) + end + end + + self.DynamicTable:SetDataSource(self.PurchaseDatas) + self.DynamicTable:ReloadDataASync() +end + +function XUiDrawPurchaseLB:AutoRegisterListener() + self.BtnMask.CallBack = function () self:Close() end + self.BtnClose.CallBack = function () self:Close() end +end + +function XUiDrawPurchaseLB:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelLb) + self.DynamicTable:SetProxy(XUiPurchaseLBListItem) + self.DynamicTable:SetDelegate(self) +end + +function XUiDrawPurchaseLB:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self, self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.PurchaseDatas[index] + grid:OnRefresh(data) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + local data = self.PurchaseDatas[index] + if not data or not next(data) then + return + end + + XDataCenter.PurchaseManager.RemoveNotInTimeDiscountCoupon(data) -- 移除未到时间的打折券 + self.CurData = data + XLuaUiManager.Open("UiPurchaseBuyTips", data, self.CheckBuyFun, self.UpdateCb, nil, XPurchaseConfigs.GetLBUiTypesList()) + -- CS.XAudioManager.PlaySound(1011) + end +end + +function XUiDrawPurchaseLB:CheckBuy(count, disCountCouponIndex) + count = count or 1 + disCountCouponIndex = disCountCouponIndex or 0 + + if not XDataCenter.PayManager.CheckCanBuy(self.CurData.Id) then + return false + end + + if self.CurData.BuyLimitTimes > 0 and self.CurData.BuyTimes == self.CurData.BuyLimitTimes then --卖完了,不管。 + XUiManager.TipText("PurchaseLiSellOut") + return false + end + + if self.CurData.TimeToShelve > 0 and self.CurData.TimeToShelve > XTime.GetServerNowTimestamp() then --没有上架 + XUiManager.TipText("PurchaseBuyNotSet") + return false + end + + if self.CurData.TimeToUnShelve > 0 and self.CurData.TimeToUnShelve < XTime.GetServerNowTimestamp() then --下架了 + XUiManager.TipText("PurchaseSettOff") + return false + end + + if self.CurData.TimeToInvalid > 0 and self.CurData.TimeToInvalid < XTime.GetServerNowTimestamp() then --失效了 + XUiManager.TipText("PurchaseSettOff") + return false + end + + if self.CurData.ConsumeCount > 0 and self.CurData.ConvertSwitch <= 0 then -- 礼包内容全部拥有 + XUiManager.TipText("PurchaseRewardAllHaveErrorTips") + return false + end + + local consumeCount = self.CurData.ConsumeCount + if disCountCouponIndex and disCountCouponIndex ~= 0 then + local disCountValue = XDataCenter.PurchaseManager.GetLBCouponDiscountValue(self.CurData, disCountCouponIndex) + consumeCount = math.floor(disCountValue * consumeCount) + else + if self.CurData.ConvertSwitch and consumeCount > self.CurData.ConvertSwitch then -- 已经被服务器计算了抵扣和折扣后的钱 + consumeCount = self.CurData.ConvertSwitch + end + + if XPurchaseConfigs.GetTagType(self.CurData.Tag) == XPurchaseConfigs.PurchaseTagType.Discount then -- 计算打折后的钱(普通打折或者选择了打折券) + local disCountValue = XDataCenter.PurchaseManager.GetLBDiscountValue(self.CurData) + consumeCount = math.floor(disCountValue * consumeCount) + end + end + + consumeCount = count * consumeCount -- 全部数量的总价 + if consumeCount > 0 and consumeCount > XDataCenter.ItemManager.GetCount(self.CurData.ConsumeId) then --钱不够 + local name = XDataCenter.ItemManager.GetItemName(self.CurData.ConsumeId) or "" + local tips = CSXTextManagerGetText("PurchaseBuyKaCountTips", name) + XUiManager.TipMsg(tips,XUiManager.UiTipType.Wrong) + if self.CurData.ConsumeId == XDataCenter.ItemManager.ItemId.PaidGem then + XLuaUiManager.Open("UiPurchase", XPurchaseConfigs.TabsConfig.HK, false) + elseif self.CurData.ConsumeId == XDataCenter.ItemManager.ItemId.HongKa then + XLuaUiManager.Open("UiPurchase", XPurchaseConfigs.TabsConfig.Pay, false) + end + return false + end + + return true +end + +function XUiDrawPurchaseLB:OnUpdate(rewardList) + self.Parent:UpdateItemCount() + self:OnRefresh() +end + +function XUiDrawPurchaseLB:OnSortFun(data) -- 排序方法来自 XUiPurchaseLB + self.SellOutList = {}--买完了 + self.SellingList = {}--在上架中 + self.SellOffList = {}--下架了 + self.SellWaitList = {}--待上架中 + local listData = {} + + local nowTime = XTime.GetServerNowTimestamp() + for _,v in pairs(data)do + if v and not v.IsSelloutHide then + if v.TimeToUnShelve > 0 and v.TimeToUnShelve <= nowTime then--下架了 + table.insert(self.SellOffList,v) + elseif v.TimeToShelve > 0 and v.TimeToShelve > nowTime then--待上架中 + table.insert(self.SellWaitList,v) + elseif v.BuyTimes > 0 and v.BuyLimitTimes > 0 and v.BuyTimes >= v.BuyLimitTimes then--买完了 + table.insert(self.SellOutList,v) + else --在上架中,还能买。 + table.insert(self.SellingList,v) + end + end + end + --在上架中,还能买。 + if Next(self.SellingList) then + table.sort(self.SellingList, XUiDrawPurchaseLB.SortByPriority) + for _,v in pairs(self.SellingList) do + table.insert(listData, v) + end + end + --待上架中 + if Next(self.SellWaitList) then + table.sort(self.SellWaitList, XUiDrawPurchaseLB.SortByPriority) + for _,v in pairs(self.SellWaitList) do + table.insert(listData, v) + end + end + --买完了 + if Next(self.SellOutList) then + table.sort(self.SellOutList, XUiDrawPurchaseLB.SortByPriority) + for _,v in pairs(self.SellOutList) do + table.insert(listData, v) + end + end + --下架了 + if Next(self.SellOffList) then + table.sort(self.SellOffList, XUiDrawPurchaseLB.SortByPriority) + for _,v in pairs(self.SellOffList) do + table.insert(listData, v) + end + end + + return listData +end + +function XUiDrawPurchaseLB.SortByPriority(a,b) + return a.Priority < b.Priority +end + +-- 计时器相关 +function XUiDrawPurchaseLB:StartLBTimer() + if self.IsStart then + return + end + + self.IsStart = true + CurrentSchedule = XScheduleManager.ScheduleForever(function() self:UpdateLBTimer()end, 1000) +end + +function XUiDrawPurchaseLB:UpdateLBTimer() + if Next(self.TimeFuns) then + for _,timerFun in pairs(self.TimeFuns)do + if timerFun then + timerFun() + end + end + return + end + self:DestroyTimer() +end + +function XUiDrawPurchaseLB:RemoveTimerFun(id) + if id and self.TimeFuns[id] then + self.TimeFuns[id] = nil + end +end + +function XUiDrawPurchaseLB:RecoverTimerFun(id) + if self.TimeFuns[id] then + self.TimeFuns[id](true) + end +end + +function XUiDrawPurchaseLB:RegisterTimerFun(id, fun) + self.TimeFuns[id] = fun +end + +function XUiDrawPurchaseLB:DestroyTimer() + if CurrentSchedule then + self.IsStart = false + XScheduleManager.UnSchedule(CurrentSchedule) + CurrentSchedule = nil + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDraw/XUiChangeCombination.lua b/Resources/Scripts/XUi/XUiDraw/XUiChangeCombination.lua new file mode 100644 index 00000000..26006424 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDraw/XUiChangeCombination.lua @@ -0,0 +1,87 @@ +local XUiChangeCombination = XLuaUiManager.Register(XLuaUi, "UiChangeCombination") +local CSTextManagerGetText = CS.XTextManager.GetText +function XUiChangeCombination:OnStart(drawId, count, IsChange, sureCb, closeCb) + self.Count = count + self.IsChange = IsChange + self.SureCb = sureCb + self.CloseCb = closeCb + self:SetButtonCallBack() + self:UpdatePanel(drawId) +end + +function XUiChangeCombination:OnEnable() + +end + +function XUiChangeCombination:SetButtonCallBack() + self.BtnClose.CallBack = function() + self:OnBtnCloseClick() + end + self.BtnConfirm.CallBack = function() + self:OnBtnConfirmClick() + end + self.PaneCharacter:GetObject("BtnIconClick").CallBack = function() + -- self:OnBtnIconClick() + end +end + +function XUiChangeCombination:OnBtnCloseClick() + self:Close() + if self.CloseCb then self.CloseCb() end +end + +function XUiChangeCombination:OnBtnConfirmClick() + self:Close() + if self.SureCb then self.SureCb(self.IsChange) end +end + +function XUiChangeCombination:OnBtnIconClick() + if self.CharId then + XLuaUiManager.Open("UiCharacterDetail", self.CharId) + end +end + +function XUiChangeCombination:UpdatePanel(drawId) + local combination = XDataCenter.DrawManager.GetDrawCombination(drawId) + if not combination then return end + local goodsList = combination.GoodsId or {} + local type = #goodsList > 0 and XArrangeConfigs.GetType(goodsList[1]) or XArrangeConfigs.Types.Error + + if type == XArrangeConfigs.Types.Character then + self:SetCharacterData(combination) + elseif type == XArrangeConfigs.Types.Error then + self:SetBaseData(combination) + end + + self.PaneCharacter.gameObject:SetActiveEx(type == XArrangeConfigs.Types.Character) + self.PaneRandom.gameObject:SetActiveEx(type == XArrangeConfigs.Types.Error) + + if self.IsChange then + self.TxtInfo.text = CSTextManagerGetText("DrawSelectNormalHint", self.Count) + else + self.TxtInfo.text = CSTextManagerGetText("DrawSelectRandomHint") + end +end + +function XUiChangeCombination:SetCharacterData(combination) + local goodsShowParams = XGoodsCommonManager.GetGoodsShowParamsByTemplateId(combination.GoodsId[1]) + local quality = XCharacterConfigs.GetCharMinQuality(combination.GoodsId[1]) + local drawAimProbability = XDrawConfigs.GetDrawAimProbability() + + self.CharId = combination.GoodsId[1] + self.PaneCharacter:GetObject("ImgBottomIcon"):SetRawImage(goodsShowParams.Icon) + + self.PaneCharacter:GetObject("TxtUp").text = drawAimProbability[combination.Id].UpProbability or "" + self.PaneCharacter:GetObject("TxtUp").gameObject:SetActiveEx(drawAimProbability[combination.Id].UpProbability ~= nil) + + if goodsShowParams.Quality then + local qualityIcon = goodsShowParams.QualityIcon or XArrangeConfigs.GeQualityPath(goodsShowParams.Quality) + self.PaneCharacter:GetObject("ImgQuality"):SetSprite(qualityIcon) + end +end + +function XUiChangeCombination:SetBaseData(combination) + local drawAimProbability = XDrawConfigs.GetDrawAimProbability() + self.PaneRandom:GetObject("TxtUp").text = drawAimProbability[combination.Id].UpProbability or "" + self.PaneRandom:GetObject("TxtUp").gameObject:SetActiveEx(drawAimProbability[combination.Id].UpProbability ~= nil) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDraw/XUiDraw.lua b/Resources/Scripts/XUi/XUiDraw/XUiDraw.lua new file mode 100644 index 00000000..bc8cd22d --- /dev/null +++ b/Resources/Scripts/XUi/XUiDraw/XUiDraw.lua @@ -0,0 +1,613 @@ +local XUiDraw = XLuaUiManager.Register(XLuaUi, "UiDraw") +local drawControl = require("XUi/XUiDraw/XUiDrawControl") +local XUiGridSuitDetail = require("XUi/XUiEquipAwarenessReplace/XUiGridSuitDetail") +local gridParams = { ShowUp = true } +local IndexBaseRule = 1 +local IndexPreview = 2 +local IndexEventRule = 4 +function XUiDraw:OnAwake() + self:InitAutoScript() +end + +function XUiDraw:OnStart(groupId, closeCb, backGround) + self.GroupId = groupId + self.CloseCb = closeCb + self.BackGroundPath = backGround + XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self.UpShows = {} + self.UpSuitShows = {} + self.BottomInfoTxts = {} + + self.FirstAnim = true + self.FirstAutoOpen = true + local upShow = XUiGridCommon.New(self, self.GridCommon) + table.insert(self.UpShows, upShow) + local drawInfo = XDataCenter.DrawManager.GetUseDrawInfoByGroupId(groupId) + self.DrawControl = drawControl.New(self, drawInfo, function() + self:UpdateItemCount() + end, self) + self:UpdateInfo(drawInfo) + self.ImgMask.gameObject:SetActiveEx(false) + self:LoadMainRule() + self:UpdateResetTime() + self:InitDrawBackGround(self.BackGroundPath) + self.PanelCharacterBottomInfo.gameObject:SetActiveEx(false) +end + +function XUiDraw:OnDestroy() + XCountDown.RemoveTimer(self.Name) + if self.CloseCb then + self.CloseCb() + end +end + +function XUiDraw:OnEnable() + XUiHelper.SetDelayPopupFirstGet(true) + self.ImgMask.gameObject:SetActiveEx(true) + self:PlayAnimation("DrawBegan", function() + self.ImgMask.gameObject:SetActiveEx(false) + self:ShowExtraReward(function () + self:CheckAutoOpen() + end) + end) + self:PlaySpcalAnime() + self.PlayableDirector = self.BackGround:GetComponent("PlayableDirector") + self.PlayableDirector:Stop() + self.PlayableDirector:Evaluate() +end + +function XUiDraw:LoadMainRule() + local groupRule = XDataCenter.DrawManager.GetDrawGroupRule(self.GroupId) + self.TxtTitle.text = groupRule.TitleCN + local mainRules = groupRule.MainRules + local mainRule = mainRules[1] + for i = 2, #mainRules do + mainRule = mainRule .. "\n" .. mainRules[i] + end + self.TxtDesc.text = mainRule +end + +function XUiDraw:UpdateResetTime() + local groupInfo = XDataCenter.DrawManager.GetDrawGroupInfoByGroupId(self.GroupId) + if groupInfo and groupInfo.EndTime > 0 then + local remainTime = groupInfo.EndTime - XTime.GetServerNowTimestamp() + XCountDown.CreateTimer(self.GameObject.name, remainTime) + XCountDown.BindTimer(self.GameObject, self.GameObject.name, function(v) + if groupInfo.Type == XDataCenter.DrawManager.DrawEventType.Activity then + self.TxtRemainTime.text = CS.XTextManager.GetText("DrawResetTimeActivity", XUiHelper.GetTime(v, XUiHelper.TimeFormatType.DRAW)) + elseif groupInfo.Type == XDataCenter.DrawManager.DrawEventType.OldActivity then + self.TxtRemainTime.text = CS.XTextManager.GetText("DrawResetTimeOldActivity", XUiHelper.GetTime(v, XUiHelper.TimeFormatType.DRAW)) + else + self.TxtRemainTime.text = CS.XTextManager.GetText("DrawResetTime", XUiHelper.GetTime(v, XUiHelper.TimeFormatType.DRAW)) + end + end) + self.TxtRemainTime.gameObject:SetActiveEx(false) + else + self.TxtRemainTime.gameObject:SetActiveEx(false) + end +end + +function XUiDraw:UpdateInfo(drawInfo) + local groupInfo = XDataCenter.DrawManager.GetDrawGroupInfoByGroupId(self.GroupId) + self.DrawInfo = drawInfo + if self.DrawInfo.UseItemId then --修复在研发界面购买礼包后道具数量刷新问题 + XDataCenter.ItemManager.AddCountUpdateListener(self.DrawInfo.UseItemId, function() + self:UpdateItemCount() + end, self.TxtUseItemCount) + end + self.DrawControl:Update(self.DrawInfo) + local icon = XDataCenter.ItemManager.GetItemBigIcon(drawInfo.UseItemId) + self.ImgUseItemIcon:SetRawImage(icon) + local combination = XDataCenter.DrawManager.GetDrawCombination(drawInfo.Id) + self.PanelUp.gameObject:SetActiveEx(false) + self.PanelSuitUpShow.gameObject:SetActiveEx(false) + self.BtnPreviewLeft.gameObject:SetActiveEx(false) + self.PanelCharacter.gameObject:SetActiveEx(false) + self.PanelUpShowCharacter.gameObject:SetActiveEx(false) + self.PanelNewUp.gameObject:SetActiveEx(false) + self.PanelUpShow.gameObject:SetActiveEx(false) + self.PanelUpShowCharacter.gameObject:SetActiveEx(false) + self.BtnOptionalDraw.gameObject:SetActiveEx(false) + if combination then + self.CurDrawType = combination.Type + if combination.Type == XDrawConfigs.CombinationsTypes.Normal then + self:UpdateLeftUpInfo(combination) + elseif combination.Type == XDrawConfigs.CombinationsTypes.Aim then + self:UpdateLeftAimUpInfo(combination, groupInfo) + elseif combination.Type == XDrawConfigs.CombinationsTypes.NewUp then + self:UpdateNewUpInfo(combination) + elseif combination.Type == XDrawConfigs.CombinationsTypes.Furniture then + self:UpdateLeftUpInfo(combination) + elseif combination.Type == XDrawConfigs.CombinationsTypes.EquipSuit then + self:UpdateLeftSuitUpInfo(combination) + elseif combination.Type == XDrawConfigs.CombinationsTypes.CharacterUp then + self.PanelCharacter.gameObject:SetActiveEx(true) + self:UpdateCharacterInfo(combination) + end + end + self:UpdateItemCount() + CS.UnityEngine.UI.LayoutRebuilder.ForceRebuildLayoutImmediate(self.PanelLeft) + + if groupInfo.Type == XDataCenter.DrawManager.DrawEventType.NewHand then + if drawInfo.MaxBottomTimes == XDataCenter.DrawManager.GetDrawGroupRule(self.GroupId).NewHandBottomCount then + self.PanelNewHand.gameObject:SetActiveEx(true) + self.NewHandCount.text = CS.XTextManager.GetText("DrawNewHandCount",drawInfo.BottomTimes.."/"..drawInfo.MaxBottomTimes) + else + self.PanelNewHand.gameObject:SetActiveEx(false) + end + else + self.PanelNewHand.gameObject:SetActiveEx(false) + end + + local Rules = XDataCenter.DrawManager.GetDrawGroupRule(self.GroupId) + local IsBottomHintShow = drawInfo.IsTriggerSpecified and drawInfo.IsTriggerSpecified or false + local hintText = Rules and Rules.DrawBottomHint and Rules.DrawBottomHint or "" + self.TxtBottomHint.text = hintText + self.PanelBottomHint.gameObject:SetActiveEx(IsBottomHintShow and #hintText > 0) + + self:UpdateCharacterTxt() + self:UpdatePurchaseLB() +end +--更新一般物品Up保底显示列表(左边) +function XUiDraw:UpdateLeftUpInfo(combination) + local parentObj = nil + local startIndex = 1 + local list = combination and combination.GoodsId or {} + for i = startIndex, #list do + if not self.UpShows[i] then + local go = CS.UnityEngine.Object.Instantiate(self.GridCommon, parentObj) + local upShow = XUiGridCommon.New(self, go) + table.insert(self.UpShows, upShow) + end + + self.UpShows[i]:Refresh(list[i], gridParams) + end + + for i = #list + 1, #self.UpShows do + self.UpShows[i].GameObject:SetActiveEx(false) + end + + if #list > 0 then + self.BtnPreviewLeft.gameObject:SetActiveEx(true) + else + self.BtnPreviewLeft.gameObject:SetActiveEx(false) + end +end +--更新狙击物品Up保底显示列表(左边) +function XUiDraw:UpdateLeftAimUpInfo(combination, groupInfo) + local parentObj + local startIndex = 1 + local list = combination and combination.GoodsId or {} + local drawAimProbability = XDrawConfigs.GetDrawAimProbability() + local IsSpAim = not(#list > 0) + + self:CheckAimHaveActivty() + self.BtnOptionalDraw.gameObject:SetActiveEx(true) + self.TxtAimProbability.gameObject:SetActiveEx(false) + self.PanelUp.gameObject:SetActiveEx(true) + + self.BtnPreviewLeft.gameObject:SetActiveEx(true) + self.PanelUpShowBase.gameObject:SetActiveEx(IsSpAim) + + if drawAimProbability[combination.Id] then + self.TxtAimProbability.text = drawAimProbability[combination.Id].UpProbability or "" + self.TxtAimProbability.gameObject:SetActiveEx(drawAimProbability[combination.Id].UpProbability ~= nil) + end + + local maxSwitchCount = groupInfo.MaxSwitchDrawIdCount + local curSwitchCount = groupInfo.SwitchDrawIdCount + self.PanelSycs.gameObject:SetActiveEx(maxSwitchCount > 0) + if maxSwitchCount > 0 then + local count = maxSwitchCount - curSwitchCount + self.PanelSycs:GetObject("TxtCount").text = CS.XTextManager.GetText("DrawSelectCountText", count) + self.PanelSycs:GetObject("TxtNone").text = CS.XTextManager.GetText("DrawSelectNotCountText") + self.PanelSycs:GetObject("TxtCount").gameObject:SetActiveEx(count > 0) + self.PanelSycs:GetObject("TxtNone").gameObject:SetActiveEx(count <= 0) + end + + if IsSpAim then + return + end + + self.AimType = XArrangeConfigs.GetType(combination.GoodsId[1]) + if self.AimType ~= XArrangeConfigs.Types.Character then + parentObj = self.PanelUpShow + self.PanelUpShow.gameObject:SetActiveEx(true) + for i = startIndex, #list do + if not self.UpShows[i] then + local go = CS.UnityEngine.Object.Instantiate(self.GridCommon, parentObj) + local upShow = XUiGridCommon.New(self, go) + table.insert(self.UpShows, upShow) + end + + self.UpShows[i]:Refresh(list[i], gridParams) + end + + for i = #list + 1, #self.UpShows do + self.UpShows[i].GameObject:SetActiveEx(false) + end + else + self.PanelUpShowCharacter.gameObject:SetActiveEx(true) + self.GoodsShowParams = XGoodsCommonManager.GetGoodsShowParamsByTemplateId(combination.GoodsId[1]) + self.AimImgBottomIco:SetRawImage(self.GoodsShowParams.Icon) + local quality = XCharacterConfigs.GetCharMinQuality(combination.GoodsId[1]) + self.AimImgBottomRank:SetRawImage(XCharacterConfigs.GetCharQualityIcon(quality)) + + if self.GoodsShowParams.Quality then + local qualityIcon = self.GoodsShowParams.QualityIcon + + if qualityIcon then + self:SetUiSprite(self.AimImgQuality, qualityIcon) + else + XUiHelper.SetQualityIcon(self, self.AimImgQuality, self.GoodsShowParams.Quality) + end + end + end + + if #list > 0 then + self.BtnPreviewLeft.gameObject:SetActiveEx(true) + else + self.BtnPreviewLeft.gameObject:SetActiveEx(false) + end + +end + +--更新Up保底显示列表(意识组合Up类)(左边) +function XUiDraw:UpdateLeftSuitUpInfo(combination) + self.GridSuitCommon.gameObject:SetActiveEx(false) + self.PanelSuitUpShow.gameObject:SetActiveEx(true) + self.PanelUp.gameObject:SetActiveEx(false) + + if self.DrawInfo then + local list = combination and combination.GoodsId or {} + for i = 1, #list do + if not self.UpSuitShows[i] then + local go = CS.UnityEngine.Object.Instantiate(self.GridSuitCommon, self.PanelSuitUpShow) + go.gameObject:SetActiveEx(true) + local upShow = XUiGridSuitDetail.New(go, self) + table.insert(self.UpSuitShows, upShow) + end + + self.UpSuitShows[i]:Refresh(list[i], nil, true) + end + + for i = #list + 1, #self.UpSuitShows do + self.UpSuitShows[i].GameObject:SetActiveEx(false) + end + + if #list > 0 then + self.BtnPreviewLeft.gameObject:SetActiveEx(true) + else + self.BtnPreviewLeft.gameObject:SetActiveEx(false) + end + end +end +--更新角色Up保底显示信息(左边) +function XUiDraw:UpdateCharacterInfo(combination) + --self.TxtBottomTimes.text = CS.XTextManager.GetText("DrawRuleHint","asd","asd")--, self.DrawInfo.BottomTimes + if self.DrawInfo then + -- self.ImgBottomIco = self.Transform:Find("SafeAreaContentPane/PanelDrawGroup/PanelDraw/PanelLeft/PanelCharacter/PanelCharacterBottom/UpCharacter/ImgBottomIco"):GetComponent("RawImage") + -- self.ImgBottomRank = self.Transform:Find("SafeAreaContentPane/PanelDrawGroup/PanelDraw/PanelLeft/PanelCharacter/PanelCharacterBottom/UpCharacter/ImgBottomRank"):GetComponent("RawImage") + self.GoodsShowParams = XGoodsCommonManager.GetGoodsShowParamsByTemplateId(combination.GoodsId[1]) + self.ImgBottomIco:SetRawImage(self.GoodsShowParams.Icon) + local quality = XCharacterConfigs.GetCharMinQuality(combination.GoodsId[1]) + self.ImgBottomRank:SetRawImage(XCharacterConfigs.GetCharQualityIcon(quality)) + if #combination.GoodsId > 1 then + -- self.Transform:Find("SafeAreaContentPane/PanelDrawGroup/PanelDraw/PanelLeft/PanelCharacter/PanelCharacterUpShow/UpCharacter2").gameObject:SetActiveEx(true) + -- self.ImgBottomIco2 = self.Transform:Find("SafeAreaContentPane/PanelDrawGroup/PanelDraw/PanelLeft/PanelCharacter/PanelCharacterUpShow/UpCharacter2/ImgBottomIco2"):GetComponent("RawImage") + -- self.ImgBottomRank2 = self.Transform:Find("SafeAreaContentPane/PanelDrawGroup/PanelDraw/PanelLeft/PanelCharacter/PanelCharacterUpShow/UpCharacter2/ImgBottomRank2"):GetComponent("RawImage") + self.UpCharacter2.gameObject:SetActiveEx(true) + self.GoodsShowParams = XGoodsCommonManager.GetGoodsShowParamsByTemplateId(combination.GoodsId[2]) + self.ImgBottomIco2:SetRawImage(self.GoodsShowParams.Icon) + local tmpQuality = XCharacterConfigs.GetCharMinQuality(combination.GoodsId[2]) + self.ImgBottomRank2:SetRawImage(XCharacterConfigs.GetCharQualityIcon(tmpQuality)) + else + -- self.Transform:Find("SafeAreaContentPane/PanelDrawGroup/PanelDraw/PanelLeft/PanelCharacter/PanelCharacterUpShow/UpCharacter2").gameObject:SetActiveEx(false) + self.UpCharacter2.gameObject:SetActiveEx(false) + end + end +end + +--更新角色Up保底显示信息(左边) +function XUiDraw:UpdateNewUpInfo(combination) + self.PanelNewUp.gameObject:SetActiveEx(true) + self.NewUpItem.gameObject:SetActiveEx(false) + self.NewUpCharacter.gameObject:SetActiveEx(false) + self.BtnPreviewLeft.gameObject:SetActiveEx(true) + if self.DrawInfo then + if XArrangeConfigs.GetType(combination.GoodsId[1]) ~= XArrangeConfigs.Types.Character then + local upShow = XUiGridCommon.New(self, self.NewUpItem) + upShow:Refresh(combination.GoodsId[1], gridParams) + self.NewUpItem.gameObject:SetActiveEx(true) + else + self.GoodsShowParams = XGoodsCommonManager.GetGoodsShowParamsByTemplateId(combination.GoodsId[1]) + self.ImgNewUpIco:SetRawImage(self.GoodsShowParams.Icon) + local quality = XCharacterConfigs.GetCharMinQuality(combination.GoodsId[1]) + self.ImgNewUpRank:SetRawImage(XCharacterConfigs.GetCharQualityIcon(quality)) + + if self.GoodsShowParams.Quality then + local qualityIcon = self.GoodsShowParams.QualityIcon + + if qualityIcon then + self:SetUiSprite(self.ImgQuality, qualityIcon) + else + XUiHelper.SetQualityIcon(self, self.ImgQuality, self.GoodsShowParams.Quality) + end + end + + self.NewUpCharacter.gameObject:SetActiveEx(true) + end + end +end + +function XUiDraw:UpdateCharacterTxt() + local combination = XDataCenter.DrawManager.GetDrawCombination(self.DrawInfo.Id) + if combination then + if combination.Type == XDrawConfigs.CombinationsTypes.CharacterUp then + self.TxtBottomTimes.text = CS.XTextManager.GetText("DrawBottomTimes", self.DrawInfo.BottomTimes) + end + if combination.Type == XDrawConfigs.CombinationsTypes.NewUp then + local type = XDataCenter.DrawManager.GetDrawGroupRule(self.GroupId).UpType + local quality = XDataCenter.DrawManager.GetDrawGroupRule(self.GroupId).UpQuality + local probability = XDataCenter.DrawManager.GetDrawGroupRule(self.GroupId).UpProbability + self.TxtNewUpTimes.text = CS.XTextManager.GetText("DrawRuleHint",quality,type,probability) + end + end +end + +function XUiDraw:UpdatePurchaseLB() + if self.DrawInfo then + if self.DrawInfo.PurchaseId and next(self.DrawInfo.PurchaseId) then + self.BtnDrawPurchaseLB.gameObject:SetActiveEx(true) + if self.DrawInfo.PurchaseUiType and self.DrawInfo.PurchaseUiType ~= 0 then + local uiType = self.DrawInfo.PurchaseUiType + XDataCenter.PurchaseManager.GetPurchaseListRequest({uiType}) + end + else + self.BtnDrawPurchaseLB.gameObject:SetActiveEx(false) + end + end +end + +function XUiDraw:UpdateItemCount() + if not self.DrawInfo then + return + end + self.TxtUseItemCount.text = XDataCenter.ItemManager.GetItem(self.DrawInfo.UseItemId).Count +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiDraw:InitAutoScript() + self:AutoAddListener() +end + +function XUiDraw:AutoAddListener() + self:RegisterClickEvent(self.BtnCloseBottomInfo, self.OnBtnCloseBottomInfoClick) + self:RegisterClickEvent(self.ScrollView, self.OnScrollViewClick) + self:RegisterClickEvent(self.Scrollbar, self.OnScrollbarClick) + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:RegisterClickEvent(self.BtnCharacterBottomInfo, self.OnBtnCharacterBottomInfoClick) + self:RegisterClickEvent(self.BtnOptionalDraw, self.OnBtnOptionalDrawClick) + self:RegisterClickEvent(self.BtnUseItem, self.OnBtnUseItemClick) + self:RegisterClickEvent(self.BtnPreview, self.OnBtnPreviewClick) + self:RegisterClickEvent(self.BtnDrawRule, self.OnBtnDrawRuleClick) + self:RegisterClickEvent(self.BtnMainRule, self.OnBtnMainRuleClick) + self:RegisterClickEvent(self.BtnPreviewLeft, self.OnBtnPreviewLeftClick) + self:RegisterClickEvent(self.BtnNewUpInfo, self.OnBtnCharacterBottomInfoClick) + self:RegisterClickEvent(self.BtnDrawPurchaseLB, self.OnBtnDrawPurchaseLBClick) +end +-- auto + +function XUiDraw:OnScrollViewClick() + +end + +function XUiDraw:OnScrollbarClick() + +end + +function XUiDraw:OnBtnCloseBottomInfoClick() + for _, v in pairs(self.BottomInfoTxts) do + CS.UnityEngine.Object.Destroy(v.gameObject) + end + self.BottomInfoTxts = {} + self.PanelCharacterBottomInfo.gameObject:SetActiveEx(false) +end + +function XUiDraw:OnBtnCharacterBottomInfoClick() + self.BtnDrawRule.interactable = false + local eventRules = XDataCenter.DrawManager.GetDrawGroupRule(self.GroupId).EventRules -- 海外修改,先判断是否存在eventRules,在进行跳转显示 + if eventRules and #eventRules > 0 then + XLuaUiManager.Open("UiDrawLog",self.DrawInfo,IndexEventRule,function() + self.BtnDrawRule.interactable = true + end) + else + XLuaUiManager.Open("UiDrawLog",self.DrawInfo,nil,function() + self.BtnDrawRule.interactable = true + end) + end +end +function XUiDraw:OnBtnMainRuleClick(...) + self:OnBtnDrawRuleClick(...) +end + +function XUiDraw:OnBtnPreviewLeftClick(...) + self:OnBtnPreviewClick(...) +end + +function XUiDraw:OnBtnBackClick() + self:Close() +end + +function XUiDraw:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiDraw:OnBtnOptionalDrawClick() + self:OpenChildUi("UiDrawOptional",self, + function(drawId) + local drawInfo = XDataCenter.DrawManager.GetDrawInfo(drawId) + self:UpdateInfo(drawInfo) + end, + function () + self:Close() + end) +end + +function XUiDraw:OnBtnPreviewClick() + self:OpenChildUi("UiDrawOptional",self, + function(drawId) + local drawInfo = XDataCenter.DrawManager.GetDrawInfo(drawId) + self:UpdateInfo(drawInfo) + end, + function () + self:Close() + end) +end + +function XUiDraw:OnBtnDrawRuleClick() + self.BtnDrawRule.interactable = false + XLuaUiManager.Open("UiDrawLog",self.DrawInfo,IndexBaseRule,function() + self.BtnDrawRule.interactable = true + end) +end + +function XUiDraw:OnBtnUseItemClick() + local data = XDataCenter.ItemManager.GetItem(self.DrawInfo.UseItemId) + XLuaUiManager.Open("UiTip", data) +end + +function XUiDraw:OnBtnDrawPurchaseLBClick() + self:OpenChildUi("UiDrawPurchaseLB", self) +end + +function XUiDraw:HideUiView(onAnimFinish) + self.OpenSound = CS.XAudioManager.PlaySound(XSoundManager.UiBasicsMusic.UiDrawCard_BoxOpen) + + self:PlayAnimation("DrawRetract", function() + onAnimFinish() + end, function() + self.ImgMask.gameObject:SetActiveEx(true) + end) +end + +function XUiDraw:ResetScene() + XRTextureManager.SetTextureCache(self.RImgDrawCard) +end + +function XUiDraw:PushShow(drawInfo, rewardList) + self:OpenChildUi("UiDrawShow") + self.PanelNewHand.gameObject:SetActiveEx(false) + self:FindChildUiObj("UiDrawShow"):SetData(drawInfo, rewardList, function() + if self.OpenSound then + self.OpenSound:Stop() + end + + local fun = function() + self:PushResult(drawInfo, rewardList) + self:UpdateInfo(drawInfo) + local groupInfo = XDataCenter.DrawManager.GetDrawGroupInfoByGroupId(self.GroupId) + if groupInfo.Type == XDataCenter.DrawManager.DrawEventType.NewHand then + if drawInfo.MaxBottomTimes == XDataCenter.DrawManager.GetDrawGroupRule(self.GroupId).NewHandBottomCount then + self.PanelNewHand.gameObject:SetActiveEx(true) + else + self.PanelNewHand.gameObject:SetActiveEx(false) + end + else + self.PanelNewHand.gameObject:SetActiveEx(false) + end + end + + if self.CurDrawType and self.CurDrawType == XDrawConfigs.CombinationsTypes.Aim then + XDataCenter.DrawManager.GetDrawInfoList(drawInfo.GroupId,fun,true) + else + fun() + end + + + end, self.BackGround) +end + +function XUiDraw:PushResult(drawInfo, rewardList) + XLuaUiManager.Open("UiDrawResult", drawInfo, rewardList, function() end) +end + +function XUiDraw:CheckAimHaveActivty() + local IsHaveActivty = false + local drawInfoList = XDataCenter.DrawManager.GetDrawInfoListByGroupId(self.GroupId) + for _,drawInfo in pairs(drawInfoList) do + if drawInfo.EndTime > 0 then + IsHaveActivty = true + break + end + end + self.BtnOptionalDraw:ShowTag(IsHaveActivty) +end + +function XUiDraw:CheckAutoOpen() + if not self.FirstAutoOpen then + return + end + if self.CurDrawType ~= XDrawConfigs.CombinationsTypes.Aim then + return + end + local IsHaveActivty = false + local activtyTime = 0 + local groupInfo = XDataCenter.DrawManager.GetDrawGroupInfoByGroupId(self.GroupId) + local drawInfoList = XDataCenter.DrawManager.GetDrawInfoListByGroupId(self.GroupId) + for _,drawInfo in pairs(drawInfoList) do + if drawInfo.StartTime > 0 then + IsHaveActivty = true + if drawInfo.StartTime > activtyTime then + activtyTime = drawInfo.StartTime + end + end + end + + local IsCanActivtyOpen = IsHaveActivty and XDataCenter.DrawManager.IsCanAutoOpenAimGroupSelect(activtyTime,self.GroupId) + if IsCanActivtyOpen or (groupInfo.MaxSwitchDrawIdCount > 0 and groupInfo.UseDrawId == 0) then + self:OnBtnOptionalDrawClick() + end + self.FirstAutoOpen = false +end + +function XUiDraw:PlaySpcalAnime() + local combination = XDataCenter.DrawManager.GetDrawCombination(self.DrawInfo.Id) + if combination then + if combination.Type == XDrawConfigs.CombinationsTypes.Aim then + if self.FirstAnim then + self.FirstAnim = false + else + self:PlayAnimation("AniZixuan") + end + end + end +end + +function XUiDraw:ShowExtraReward(cb) + if self.ExtraRewardList and next(self.ExtraRewardList) then + XUiManager.OpenUiObtain(self.ExtraRewardList, nil, function () + if cb then cb() end + end) + self.ExtraRewardList = nil + else + if cb then cb() end + end +end + +function XUiDraw:SetExtraRewardList(list) + self.ExtraRewardList = list +end + +function XUiDraw:OnDisable() + XUiHelper.SetDelayPopupFirstGet() +end + + +function XUiDraw:InitDrawBackGround(backgroundName) + local root = self.UiSceneInfo.Transform + self.BackGround = root:FindTransform("GroupBase"):LoadPrefab(backgroundName) + CS.XShadowHelper.AddShadow(self.BackGround:FindTransform("BoxModeParent").gameObject) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDraw/XUiDrawBuyVoucher.lua b/Resources/Scripts/XUi/XUiDraw/XUiDrawBuyVoucher.lua new file mode 100644 index 00000000..7cd76597 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDraw/XUiDrawBuyVoucher.lua @@ -0,0 +1,91 @@ +local XUiDrawBuyVoucher = XLuaUiManager.Register(XLuaUi, "UiDrawBuyVoucher") + + +function XUiDrawBuyVoucher:OnAwake() + self:InitAutoScript() +end + +--voucherId 卡券Id +--ownAmount 拥有数量 +--buyAmount 购买数量 +--confirmCb 确定回调 +function XUiDrawBuyVoucher:OnStart(voucherId, ownAmount, buyAmount, confirmCb) + self.VoucherId = voucherId + self.BuyAmount = buyAmount + self.ConfirmCb = confirmCb + local voucherTemplate = XDataCenter.ItemManager.GetItemTemplate(voucherId) + local voucherName = voucherTemplate.Name + local assetTemplate = XDataCenter.ItemManager.GetBuyAssetTemplate(voucherId, -1) + local consumeCost = assetTemplate.ConsumeCount * buyAmount + local consumeId = assetTemplate.ConsumeId + local consumeTemplate = XDataCenter.ItemManager.GetItemTemplate(consumeId) + local consumeName = consumeTemplate.Name + self.ImgIcon:SetRawImage(voucherTemplate.Icon) + self.TxtName.text = CS.XTextManager.GetText("DrawVoucherNotEnough", voucherName) + self.TxtTip.text = CS.XTextManager.GetText("DrawBuyVoucherQuery", consumeCost, consumeName, buyAmount * assetTemplate.GainCount, voucherName) + self.TxtCount.text = CS.XTextManager.GetText("DrawOwnVoucherAmount", ownAmount) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiDrawBuyVoucher:InitAutoScript() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiDrawBuyVoucher:GetAutoKey(uiNode, eventName) + if not uiNode then + return + end + return eventName .. uiNode:GetHashCode() +end + +function XUiDrawBuyVoucher:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then + return + end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiDrawBuyVoucher:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiDrawBuyVoucher:AutoAddListener() + self.AutoCreateListeners = {} + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnBuy, self.OnBtnBuyClick) + self:RegisterClickEvent(self.BtnCancel, self.OnBtnCancelClick) +end +-- auto +function XUiDrawBuyVoucher:OnBtnBackClick(...) + self:OnBtnCancelClick(...) +end + +function XUiDrawBuyVoucher:OnBtnCancelClick() + self:Close() +end + +function XUiDrawBuyVoucher:OnBtnBuyClick() + self.ImgMask.gameObject:SetActive(true) + XDataCenter.ItemManager.BuyAsset(self.VoucherId, function() + self:Close() + self.ConfirmCb() + end, function() + self.ImgMask.gameObject:SetActive(false) + end, self.BuyAmount) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDraw/XUiDrawControl.lua b/Resources/Scripts/XUi/XUiDraw/XUiDrawControl.lua new file mode 100644 index 00000000..4d948b61 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDraw/XUiDrawControl.lua @@ -0,0 +1,150 @@ +local XUiDrawControl = XClass(nil, "XUiDrawControl") +local characterRecord = require("XUi/XUiDraw/XUiDrawTools/XUiDrawCharacterRecord") + +local MAX_DRAW_BTN_COUNT = 3 + +function XUiDrawControl:Ctor(rootUi, drawInfo, drawCb, uiDraw) + self.RootUi = rootUi + self.DrawInfo = drawInfo + self.DrawCb = drawCb + self.UiDraw = uiDraw + self.DrawBtns = {} + self.IsCanDraw = true + self:InitRes() + self:InitButtons() + self:Update(drawInfo) + return self +end + +function XUiDrawControl:InitRes() + self.UseItemIcon = XDataCenter.ItemManager.GetItemBigIcon(self.DrawInfo.UseItemId) + self.TxtDrawCount = XUiHelper.TryGetComponent(self.RootUi.PanelDrawButtons, "TxtTotalDrawCount", "Text") +end + +function XUiDrawControl:InitButtons() + for i = 1, MAX_DRAW_BTN_COUNT do + local btnName = "BtnDraw" .. i + local btn = XUiHelper.TryGetComponent(self.RootUi.PanelDrawButtons, btnName) + if btn then + self:InitButton(btn, i) + end + end +end + +function XUiDrawControl:InitButton(btn, index) + --@DATA + local drawCount = self.DrawInfo.BtnDrawCount[index] + btn.transform:Find("TxtDrawDesc"):GetComponent("Text").text = CS.XTextManager.GetText("DrawCount", drawCount) + local itemIcon = btn.transform:Find("ImgUseItemIcon"):GetComponent("RawImage") + itemIcon:SetRawImage(self.UseItemIcon) + btn.transform:Find("TxtUseItemCount"):GetComponent("Text").text = drawCount * self.DrawInfo.UseItemCount + + self.DrawBtns[index] = { + Tips = btn.transform:Find("ImgTips"), + DrawCount = drawCount, + Btn = btn + } + + self.RootUi:RegisterClickEvent(btn:GetComponent("Button"), function() + self.UiDraw:UpdateItemCount() + self:OnDraw(drawCount) + end) +end + +function XUiDrawControl:OnDraw(drawCount) + local info + local list + + if self.DrawInfo.CapacityCheckType == XDrawConfigs.DrawCapacityCheckType.Partner then + if not XDataCenter.PartnerManager.CheckPartnerCount() then + return + end + else + if XDataCenter.EquipManager.CheckBoxOverLimitOfDraw() then + return + end + end + + if XDataCenter.DrawManager.CheckDrawIsTimeOver(self.DrawInfo.Id) then + XUiManager.TipText("DrawAimLeftTimeOver") + return + end + + if not XDataCenter.ItemManager.DoNotEnoughBuyAsset(self.DrawInfo.UseItemId, + self.DrawInfo.UseItemCount, + drawCount, + function() self.UiDraw:UpdateItemCount() end, + "DrawNotEnoughError") then + return + end + + if self.IsCanDraw then + self.IsCanDraw = false + local onAnimFinish = function() + if list and #list > 0 then + self.IsCanDraw = true + self.UiDraw:PushShow(info, list) + end + end + + characterRecord.Record() + + XDataCenter.DrawManager.DrawCard(self.DrawInfo.Id, drawCount, function(drawInfo, rewardList, extraRewardList) + XDataCenter.AntiAddictionManager.BeginDrawCardAction() + if self.DrawCb then + self.DrawCb() + end + + self:Update(drawInfo) + info = drawInfo + list = rewardList + self.UiDraw:SetExtraRewardList(extraRewardList) + self.UiDraw:HideUiView(onAnimFinish) + self:SetDrawEvent(drawInfo,drawCount) + end, function() + self.IsCanDraw = true + end) + end +end + +function XUiDrawControl:SetDrawEvent(drawInfo, drawCount) + if drawCount < 10 then + return + end + local combination = XDataCenter.DrawManager.GetDrawCombination(drawInfo.Id) + if combination then + if combination.Type == XDrawConfigs.CombinationsTypes.Aim then + local aimType = combination.GoodsId[1] + if aimType ~= nil then + aimType = XArrangeConfigs.GetType(aimType) + end + if not aimType or aimType == XArrangeConfigs.Types.Character then + --CheckPoint: APPEVENT_DRAWS_ROLE_10_1 + XAppEventManager.AppLogEvent(XAppEventManager.CommonEventNameConfig.draws_role_10) + else + --CheckPoint: APPEVENT_DRAWS_WEAPON_10_1 + XAppEventManager.AppLogEvent(XAppEventManager.CommonEventNameConfig.draws_weapon_10) + end + elseif combination.Type == XDrawConfigs.CombinationsTypes.NewUp then + --CheckPoint: APPEVENT_DRAWS_LIMIT_10 + XAppEventManager.AppLogEvent(XAppEventManager.CommonEventNameConfig.draws_limit_10) + end + else + if drawInfo.Id == 101 then + --CheckPoint: APPEVENT_DRAWS_ROLE_10_2 + XAppEventManager.AppLogEvent(XAppEventManager.CommonEventNameConfig.draws_role_10) + elseif drawInfo.Id == 201 then + --CheckPoint: APPEVENT_DRAWS_WEAPON_10_2 + XAppEventManager.AppLogEvent(XAppEventManager.CommonEventNameConfig.draws_weapon_10) + end + end +end +function XUiDrawControl:Update(drawInfo) + self.DrawInfo = drawInfo + + if self.TxtDrawCount then + self.TxtDrawCount.text = CS.XTextManager.GetText("DrawTotalCount", drawInfo.TotalCount) + end +end + +return XUiDrawControl \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDraw/XUiDrawGroup.lua b/Resources/Scripts/XUi/XUiDraw/XUiDrawGroup.lua new file mode 100644 index 00000000..7e172aaf --- /dev/null +++ b/Resources/Scripts/XUi/XUiDraw/XUiDrawGroup.lua @@ -0,0 +1,137 @@ +local XUiDrawGroup = XLuaUiManager.Register(XLuaUi, "UiDrawGroup") +local XUiGridBanner = require("XUi/XUiDraw/XUiGridDrawGroupBanner") + +function XUiDrawGroup:OnAwake() + +end + +function XUiDrawGroup:OnStart() + self:InitAutoScript() + + XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self:InitBanners() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiDrawGroup:InitAutoScript() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiDrawGroup:GetAutoKey(uiNode, eventName) + if not uiNode then + return + end + return eventName .. uiNode:GetHashCode() +end + +function XUiDrawGroup:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then + return + end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiGridDrawGroupBanner:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiDrawGroup:AutoAddListener() + self.AutoCreateListeners = {} + --self:RegisterListener(self.SViewBanners, "onValueChanged", self.OnSViewBannersValueChanged) + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) +end +-- auto +function XUiDrawGroup:OnBtnBackClick() + self:Close() +end + +function XUiDrawGroup:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiDrawGroup:InitBanners() + local infoList = XDataCenter.DrawManager.GetDrawGroupInfos() + local gridTab = {} + local availableList = {} + + local count = 0 + + local setParent = function() + count = count + 1 + if count < #availableList then + return + end + for _, info in pairs(infoList) do + if gridTab[info.Id] then + gridTab[info.Id].Transform:SetParent(self.PanelContentTabBtns, false) + end + end + --XUiHelper.PlayAnimation(self, "DrawGroupBegin") + end + + local createBanners = function() + count = 0 + for _, info in pairs(availableList) do + local result = CS.XAssetManager.InstantiateUiComponent(info.Banner, self.Name, CS.XResourceRefType.Ui) + CS.XTool.WaitCoroutine(result, function() + if result.Error then + XLog.Error("XUiDrawGroup InitBanners 函数错误, instantiate生成组件失败, 要挂载的游戏物体是: " .. info.Banner) + return + end + + local banner = result.Asset + if not banner then + XLog.Error("XUiDrawGroup InitBanners 函数错误, 要挂载的游戏物体为空 : " .. info.Banner) + return + end + gridTab[info.Id] = XUiGridBanner.New(banner, info) + setParent() + end) + end + end + + local init = function() + local now = XTime.GetServerNowTimestamp() + for _, info in pairs(infoList) do + XDataCenter.DrawManager.GetDrawInfoList(info.Id, function() + local drawInfoList = XDataCenter.DrawManager.GetDrawInfoListByGroupId(info.Id) + if #drawInfoList > 0 then + local isDefaultTime = info.StartTime <= 0 and info.EndTime <= 0 + if isDefaultTime or now >= info.StartTime and now <= info.EndTime then + table.insert(availableList, info) + end + end + count = count + 1 + if count >= #infoList then + createBanners() + end + end) + end + end + + if #infoList > 0 then + init() + else + XDataCenter.DrawManager.GetDrawGroupList(function() + infoList = XDataCenter.DrawManager.GetDrawGroupInfos() + init() + end) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDraw/XUiDrawLog.lua b/Resources/Scripts/XUi/XUiDraw/XUiDrawLog.lua new file mode 100644 index 00000000..56d2a5fc --- /dev/null +++ b/Resources/Scripts/XUi/XUiDraw/XUiDrawLog.lua @@ -0,0 +1,309 @@ +local XUiDrawLog = XLuaUiManager.Register(XLuaUi, "UiDrawLog") +local BtnMaxCount = 4 +local IndexEventRule = 4 +local TypeText = {} +local IsInit = {} +local AnimeNames = {} +local InitFunctionList = {} +local TimestampToGameDateTimeString = XTime.TimestampToGameDateTimeString +local DrawLogLimit = CS.XGame.ClientConfig:GetInt("DrawLogLimit") +function XUiDrawLog:OnStart(drawInfo, selectIndex, cb) + self.DrawId = drawInfo.Id + self.DrawInfo = drawInfo + self.SelectIndex = selectIndex + if not self.SelectIndex then + self.SelectIndex = 1 + end + self.Cb = cb + self.BtnTanchuangClose.CallBack = function() + self:OnBtnTanchuangClose() + end + self.BtnClose.CallBack = function() + self:OnBtnTanchuangClose() + end + self.BtnSwitchOff.CallBack = function() + self:OnBtnSwitchOff() + end + self.BtnSwitchOn.CallBack = function() + self:OnBtnSwitchOn() + end + InitFunctionList = { + function() + self:InitBaseRulePanel() + end, + function() + self:InitDrawPreview() + end, + function() + self:InitDrawLogListPanel() + end, + function() + self:InitEventRulePanel() + end, + } + IsInit = {false, false, false, false } + AnimeNames = { "QieHuanOne", "QieHuanTwo", "QieHuanThree", "QieHuanFour" } + self:SetTypeText() + self:InitBtnTab() +end + +function XUiDrawLog:SetTypeText() + TypeText[XArrangeConfigs.Types.Item] = CS.XTextManager.GetText("TypeItem") + TypeText[XArrangeConfigs.Types.Character] = function(templateId) + local characterType = XCharacterConfigs.GetCharacterType(templateId) + if characterType == XCharacterConfigs.CharacterType.Normal then + return CS.XTextManager.GetText("TypeCharacter") + elseif characterType == XCharacterConfigs.CharacterType.Isomer then + return CS.XTextManager.GetText("TypeIsomer") + end + end + TypeText[XArrangeConfigs.Types.Weapon] = CS.XTextManager.GetText("TypeWeapon") + TypeText[XArrangeConfigs.Types.Wafer] = CS.XTextManager.GetText("TypeWafer") + TypeText[XArrangeConfigs.Types.Fashion] = CS.XTextManager.GetText("TypeFashion") + TypeText[XArrangeConfigs.Types.Furniture] = CS.XTextManager.GetText("TypeFurniture") + TypeText[XArrangeConfigs.Types.HeadPortrait] = CS.XTextManager.GetText("TypeHeadPortrait") + TypeText[XArrangeConfigs.Types.ChatEmoji] = CS.XTextManager.GetText("TypeChatEmoji") + TypeText[XArrangeConfigs.Types.Partner] = CS.XTextManager.GetText("TypePartner") +end + +function XUiDrawLog:InitDrawLogListPanel() + local groupId = XDataCenter.DrawManager.GetDrawInfo(self.DrawId).GroupId + local Rules = XDataCenter.DrawManager.GetDrawGroupRule(groupId) + local name + local quality + local fromName + local time + local type + + local PanelObj = {} + PanelObj.Transform = self.Panel3.transform + XTool.InitUiObject(PanelObj) + + PanelObj.GridLogHigh.gameObject:SetActiveEx(false) + PanelObj.GridLogMid.gameObject:SetActiveEx(false) + PanelObj.GridLogLow.gameObject:SetActiveEx(false) + PanelObj.TxtLogCount.text = CS.XTextManager.GetText("DrawLogCpunt", DrawLogLimit) + if Rules.SpecialBottomMin > 0 and Rules.SpecialBottomMax > 0 then + PanelObj.TxtEnsureCount.text = Rules.BottomText .. " " .. self.DrawInfo.BottomTimes .. "/(" .. Rules.SpecialBottomMin .. "~" .. Rules.SpecialBottomMax .. ")" + else + PanelObj.TxtEnsureCount.text = Rules.BottomText .. " " .. self.DrawInfo.BottomTimes .. "/" .. self.DrawInfo.MaxBottomTimes + end + for _, v in pairs(self.DrawInfo.HistoryRewardList) do + if v.RewardGoods.ConvertFrom ~= 0 then + local fromGoods = XGoodsCommonManager.GetGoodsShowParamsByTemplateId(v.RewardGoods.ConvertFrom) + local Goods = XGoodsCommonManager.GetGoodsShowParamsByTemplateId(v.RewardGoods.TemplateId) + quality = fromGoods.Quality + quality = quality or 1 + fromName = fromGoods.Name + if fromGoods.TradeName then + fromName = fromName .. "." .. fromGoods.TradeName + end + name = Goods.Name + time = TimestampToGameDateTimeString(v.DrawTime) + self:SetLogData(PanelObj, fromName, v.RewardGoods.ConvertFrom, name, time, quality) + else + local Goods = XGoodsCommonManager.GetGoodsShowParamsByTemplateId(v.RewardGoods.TemplateId) + quality = Goods.Quality + quality = quality or 1 + name = Goods.Name + if Goods.TradeName then + name = name .. "." .. Goods.TradeName + end + time = TimestampToGameDateTimeString(v.DrawTime) + self:SetLogData(PanelObj, name, v.RewardGoods.TemplateId, nil, time, quality) + end + end +end + +function XUiDrawLog:SetLogData(obj, name, templateId, from, time, quality) + local itemType = XArrangeConfigs.GetType(templateId) + local go + if itemType == XArrangeConfigs.Types.Character or itemType == XArrangeConfigs.Types.Partner then + if quality >= XItemConfigs.Quality.Three then + go = CS.UnityEngine.Object.Instantiate(obj.GridLogHigh, obj.PanelContent) + else + go = CS.UnityEngine.Object.Instantiate(obj.GridLogMid, obj.PanelContent) + end + else + if quality == XItemConfigs.Quality.Six then + go = CS.UnityEngine.Object.Instantiate(obj.GridLogHigh, obj.PanelContent) + elseif quality == XItemConfigs.Quality.Five then + go = CS.UnityEngine.Object.Instantiate(obj.GridLogMid, obj.PanelContent) + else + go = CS.UnityEngine.Object.Instantiate(obj.GridLogLow, obj.PanelContent) + end + end + + local tmpObj = {} + tmpObj.Transform = go.transform + tmpObj.GameObject = go.gameObject + XTool.InitUiObject(tmpObj) + tmpObj.TxtName.text = name + + if type(TypeText[itemType]) == "function" then + tmpObj.TxtType.text = TypeText[itemType](templateId) + else + tmpObj.TxtType.text = TypeText[itemType] + end + + if not from then + tmpObj.TxtTo.gameObject:SetActiveEx(false) + else + tmpObj.TxtTo.text = CS.XTextManager.GetText("ToOtherThing", from) + end + tmpObj.TxtTime.text = time + tmpObj.GameObject:SetActiveEx(true) +end + +function XUiDrawLog:InitBaseRulePanel() + local groupId = XDataCenter.DrawManager.GetDrawInfo(self.DrawId).GroupId + local baseRules = XDataCenter.DrawManager.GetDrawGroupRule(groupId).BaseRules + local baseRuleTitles = XDataCenter.DrawManager.GetDrawGroupRule(groupId).BaseRuleTitles + self:SetRuleData(baseRules, baseRuleTitles, self.Panel1) +end + +function XUiDrawLog:InitEventRulePanel() + local groupId = XDataCenter.DrawManager.GetDrawInfo(self.DrawId).GroupId + local eventRules = XDataCenter.DrawManager.GetDrawGroupRule(groupId).EventRules + local eventRuleTitles = XDataCenter.DrawManager.GetDrawGroupRule(groupId).EventRuleTitles + self:SetRuleData(eventRules, eventRuleTitles, self.Panel4) +end + +function XUiDrawLog:SetRuleData(rules, ruleTitles, panel) + local PanelObj = {} + PanelObj.Transform = panel.transform + XTool.InitUiObject(PanelObj) + PanelObj.PanelTxt.gameObject:SetActiveEx(false) + for k, _ in pairs(rules) do + local go = CS.UnityEngine.Object.Instantiate(PanelObj.PanelTxt, PanelObj.PanelContent) + local tmpObj = {} + tmpObj.Transform = go.transform + tmpObj.GameObject = go.gameObject + XTool.InitUiObject(tmpObj) + tmpObj.TxtRuleTittle.text = ruleTitles[k] + tmpObj.TxtRule.text = rules[k] + tmpObj.GameObject:SetActiveEx(true) + end +end + +function XUiDrawLog:InitDrawPreview() + local PanelObj = {} + PanelObj.Transform = self.Panel2.transform + XTool.InitUiObject(PanelObj) + PanelObj.PanelProCard.gameObject:SetActiveEx(false) + PanelObj.PanelStdCard.gameObject:SetActiveEx(false) + PanelObj.TxtUp.gameObject:SetActiveEx(false) + PanelObj.TxtNor.gameObject:SetActiveEx(false) + + local previewList = XDataCenter.DrawManager.GetDrawPreview(self.DrawId) + if not previewList then + return + end + local upGoods = previewList.UpGoods + local goods = previewList.Goods + for i = 1, #upGoods do + local go = CS.UnityEngine.Object.Instantiate(PanelObj.PanelProCard, PanelObj.PanelCardParent) + local item = XUiGridCommon.New(self, go) + item:Refresh(upGoods[i]) + end + + for i = 1, #goods do + local go = CS.UnityEngine.Object.Instantiate(PanelObj.PanelStdCard, PanelObj.PanelCardParent) + local item = XUiGridCommon.New(self, go) + item:Refresh(goods[i]) + end + local list = XDataCenter.DrawManager.GetDrawProb(self.DrawId) + if not list then + return + end + for i = 1, #list do + local go + if list[i].IsUp then + go = CS.UnityEngine.Object.Instantiate(PanelObj.TxtUp, PanelObj.PanelTxtParent) + else + go = CS.UnityEngine.Object.Instantiate(PanelObj.TxtNor, PanelObj.PanelTxtParent) + end + local tmpObj = {} + tmpObj.Transform = go.transform + tmpObj.GameObject = go.gameObject + XTool.InitUiObject(tmpObj) + --这里应该是定制化需求 先合并过来再说 + tmpObj.TxtName.HrefListener = function(link, content) + self:ClickLink(link) + end + tmpObj.GameObject:SetActiveEx(true) + local str = list[i].Name + if string.find(str, " 0 then + self.TabGroup[IndexEventRule].gameObject:SetActiveEx(true) + else + self.TabGroup[IndexEventRule].gameObject:SetActiveEx(false) + end + self.PanelTabTc:SelectIndex(self.SelectIndex) +end + +function XUiDrawLog:OnBtnTanchuangClose() + self:Close() +end + +function XUiDrawLog:OnBtnSwitchOff() + self.BtnSwitchOff.gameObject:SetActiveEx(false) + self.BtnSwitchOn.gameObject:SetActiveEx(true) + + self.PanelTextView.gameObject:SetActiveEx(true) + self.PanelDetailView.gameObject:SetActiveEx(false) + + self:PlayAnimation("TextViewQieHuan") +end + +function XUiDrawLog:OnBtnSwitchOn() + self.BtnSwitchOff.gameObject:SetActiveEx(true) + self.BtnSwitchOn.gameObject:SetActiveEx(false) + + self.PanelTextView.gameObject:SetActiveEx(false) + self.PanelDetailView.gameObject:SetActiveEx(true) + + self:PlayAnimation("DetailViewQieHuan") +end + +function XUiDrawLog:OnSelectedTog(index) + for i = 1, BtnMaxCount do + self["Panel" .. i].gameObject:SetActiveEx(false) + end + + self["Panel" .. index].gameObject:SetActiveEx(true) + if not IsInit[index] then + InitFunctionList[index]() + IsInit[index] = true + end + + self:PlayAnimation(AnimeNames[index]) +end + +function XUiDrawLog:ClickLink(url) + CS.UnityEngine.Application.OpenURL(url) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDraw/XUiDrawOptional.lua b/Resources/Scripts/XUi/XUiDraw/XUiDrawOptional.lua new file mode 100644 index 00000000..c4c8f4c6 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDraw/XUiDrawOptional.lua @@ -0,0 +1,190 @@ +local XUiDrawOptional = XLuaUiManager.Register(XLuaUi, "UiDrawOptional") +local combination = require("XUi/XUiDraw/XUiPanelCombination") +local CSTextManagerGetText = CS.XTextManager.GetText +local firstIndex = 1 + +function XUiDrawOptional:OnStart(parentUi, optionalCb,allTimeOverCb) + self.PanelCombinationHero.gameObject:SetActiveEx(false) + self.PanelCombinationBase.gameObject:SetActiveEx(false) + self.PanelCombination.gameObject:SetActiveEx(false) + self.PanelCombinationPartner.gameObject:SetActiveEx(false) + self.ParentUi = parentUi + self.OptionalCb = optionalCb + self.AllTimeOverCb = allTimeOverCb + self.CurSuitId = 0 + self.CurSelectDrawId = 0 + self:AutoAddListener() +end + +function XUiDrawOptional:OnEnable() + self:PlayAnimation("UiDrawOptionalBegin") + self:SetData(self.ParentUi.GroupId) +end + +function XUiDrawOptional:SetData(groupId) + self.InfoList = XDataCenter.DrawManager.GetDrawInfoListByGroupId(groupId) + self.GroupInfo = XDataCenter.DrawManager.GetDrawGroupInfoByGroupId(groupId) + + local aimType = nil + if not self.Combinations then + self.Combinations = {} + end + + local maxSwitchCount = self.GroupInfo.MaxSwitchDrawIdCount + local curSwitchCount = self.GroupInfo.SwitchDrawIdCount + local IsCanSwitch = not self:IsHaveSwitchLimit() or maxSwitchCount > curSwitchCount + self.PanelQieHuan.gameObject:SetActiveEx(maxSwitchCount > 0) + if self:IsHaveSwitchLimit() then + local count = maxSwitchCount - curSwitchCount + self.TxtHaveCount.text = CSTextManagerGetText("DrawSelectCountFullText", count) + self.TxtNotHaveCount.text = CSTextManagerGetText("DrawSelectNotCountFullText") + self.TxtHaveCount.gameObject:SetActiveEx(count > 0) + self.TxtNotHaveCount.gameObject:SetActiveEx(count <= 0) + end + + for i = 1, #self.InfoList do + if not self.Combinations[i] then + local go + local drawCt = XDataCenter.DrawManager.GetDrawCombination(self.InfoList[i].Id) + local goodsList = drawCt.GoodsId or {} + local goodsType = #goodsList > 0 and XArrangeConfigs.GetType(goodsList[1]) or XArrangeConfigs.Types.Error + if goodsType == XArrangeConfigs.Types.Character then + go = CS.UnityEngine.Object.Instantiate(self.PanelCombinationHero, self.PanelCombinationContent) + aimType = goodsType + elseif goodsType == XArrangeConfigs.Types.Partner then + aimType = goodsType + go = CS.UnityEngine.Object.Instantiate(self.PanelCombinationPartner, self.PanelCombinationContent) + elseif goodsType == XArrangeConfigs.Types.Error then + go = CS.UnityEngine.Object.Instantiate(self.PanelCombinationBase, self.PanelCombinationContent) + else + aimType = goodsType + go = CS.UnityEngine.Object.Instantiate(self.PanelCombination, self.PanelCombinationContent) + end + + local item = combination.New(go, self, i) + table.insert(self.Combinations, item) + end + + local IsDefaultDraw = false + local id = self:IsHaveSwitchLimit() and self.GroupInfo.UseDrawId or self.ParentUi.DrawInfo.Id + if self.InfoList[i].Id == id then + self.DefaultIndex = i + IsDefaultDraw = true + end + + self.Combinations[i]:SetData(self.InfoList[i].Id, IsDefaultDraw, IsCanSwitch) + self.Combinations[i]:SetActiveEx(true) + end + + if aimType and aimType == XArrangeConfigs.Types.Character then + self.TitleText.text = CSTextManagerGetText("AimCharacterSelectTitle") + elseif aimType and aimType == XArrangeConfigs.Types.Weapon then + self.TitleText.text = CSTextManagerGetText("AimEquipSelectTitle") + elseif aimType and aimType == XArrangeConfigs.Types.Partner then + self.TitleText.text = CSTextManagerGetText("AimPartnerSelectTitle") + end + + for i = #self.InfoList + 1, #self.Combinations do + self.Combinations[i]:SetActiveEx(false) + end + if self.DefaultIndex and self.Combinations[self.DefaultIndex] then + self:SelectCombination(self.DefaultIndex, self.InfoList[self.DefaultIndex].Id) + else + if not self:IsHaveSwitchLimit() then + self:SelectCombination(firstIndex, self.InfoList[firstIndex].Id) + end + end +end + +function XUiDrawOptional:SelectCombination(index, drawId) + if not index or not drawId then + if self.SelectedIndex and self.Combinations[self.SelectedIndex] then + self.Combinations[self.SelectedIndex]:SetSelectState(false) + end + self.SelectedIndex = nil + self.CurSelectDrawId = 0 + else + if self.Combinations[index] then + if self.SelectedIndex and self.Combinations[self.SelectedIndex] then + self.Combinations[self.SelectedIndex]:SetSelectState(false) + end + self.SelectedIndex = index + self.Combinations[index]:SetSelectState(true) + self.CurSelectDrawId = drawId + self.OptionalCb(self.CurSelectDrawId) + end + end +end + +function XUiDrawOptional:SetActiveEx(bool) + self.GameObject:SetActiveEx(bool) +end + +function XUiDrawOptional:AutoAddListener() + self.BtnClose.CallBack = function() + self:OnBtnCloseClick() + end + self.BtnTanchuangClose.CallBack = function() + self:OnBtnCloseClick() + end +end +-- auto +function XUiDrawOptional:OnBtnCloseClick() + local IsAllTimeOvel = true + for _,info in pairs(self.InfoList) do + if not XDataCenter.DrawManager.CheckDrawIsTimeOver(info.Id) then + IsAllTimeOvel = false + break + end + end + if IsAllTimeOvel or self.CurSelectDrawId == 0 then + self:Close() + if self.AllTimeOverCb then + self.AllTimeOverCb() + end + return + end + + if XDataCenter.DrawManager.CheckDrawIsTimeOver(self.CurSelectDrawId) then + XUiManager.TipText("DrawAimLeftTimeOver") + return + end + + local sureFun = function(IsChange) + self:Close() + self.ParentUi:PlaySpcalAnime() + if IsChange then + XDataCenter.DrawManager.SaveDrawAimId(self.CurSelectDrawId, self.ParentUi.GroupId,function () + self.OptionalCb(self.CurSelectDrawId) + end) + end + end + + local closeFun = function() + local drawId = self.DefaultIndex and self.InfoList[self.DefaultIndex] and self.InfoList[self.DefaultIndex].Id + self:SelectCombination(self.DefaultIndex, drawId) + end + + local combination = XDataCenter.DrawManager.GetDrawCombination(self.CurSelectDrawId) + local goodsList = combination and combination.GoodsId or {} + local IsRandom = #goodsList == 0 + local maxSwitchCount = self.GroupInfo.MaxSwitchDrawIdCount + local curSwitchCount = self.GroupInfo.SwitchDrawIdCount + local count = maxSwitchCount - curSwitchCount + local IsChang = self.GroupInfo.UseDrawId ~= self.CurSelectDrawId + if (IsChang or IsRandom) and maxSwitchCount > 0 then + XLuaUiManager.Open("UiChangeCombination", self.CurSelectDrawId, count, IsChang, sureFun, closeFun) + else + sureFun(IsChang) + end +end + +function XUiDrawOptional:OnSuitGridClick(suitId) + self.CurSuitId = suitId + self.ParentUi:OpenChildUi("UiDrawSuitPreview", self.CurSuitId, self) + --XLuaUiManager.Open("UiDrawSuitPreview", suitId) +end + +function XUiDrawOptional:IsHaveSwitchLimit() + return self.GroupInfo and self.GroupInfo.MaxSwitchDrawIdCount and self.GroupInfo.MaxSwitchDrawIdCount > 0 +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDraw/XUiDrawPreview.lua b/Resources/Scripts/XUi/XUiDraw/XUiDrawPreview.lua new file mode 100644 index 00000000..a0c82167 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDraw/XUiDrawPreview.lua @@ -0,0 +1,137 @@ +local XUiDrawPreview = XLuaUiManager.Register(XLuaUi, "UiDrawPreview") + +function XUiDrawPreview:OnAwake() + self:InitAutoScript() +end + +function XUiDrawPreview:OnStart(drawId, closeCb, father) + self.PanelProCard.gameObject:SetActive(false) + self.PanelStdCard.gameObject:SetActive(false) + self.DrawId = drawId + self.CloseCb = closeCb + self.Father = father + self.ProCards = {} + self.StdCards = {} +end + +function XUiDrawPreview:OnEnable() + self:Init(self.Father.DrawInfo.Id) +end + +function XUiDrawPreview:Init(id) + self.DrawId = id + local previewList = XDataCenter.DrawManager.GetDrawPreview(self.DrawId) + if not previewList then + return + end + + local upGoods = previewList.UpGoods + + if #upGoods > 0 then + self.ProTitle.gameObject:SetActive(true) + else + self.ProTitle.gameObject:SetActive(false) + end + + for i = 1, #upGoods do + if not self.ProCards[i] then + local go = CS.UnityEngine.Object.Instantiate(self.PanelProCard, self.PanelPro) + local item = XUiGridCommon.New(self, go) + item:Refresh(upGoods[i]) + table.insert(self.ProCards, item) + else + self.ProCards[i]:Refresh(upGoods[i]) + end + self.ProCards[i].GameObject:SetActive(true) + end + + for i = #upGoods + 1, #self.ProCards do + self.ProCards[i].GameObject:SetActive(false) + end + + + local goods = previewList.Goods + for i = 1, #goods do + if not self.StdCards[i] then + local go = CS.UnityEngine.Object.Instantiate(self.PanelStdCard, self.PanelStd) + local item = XUiGridCommon.New(self, go) + item:Refresh(goods[i]) + table.insert(self.StdCards, item) + else + self.StdCards[i]:Refresh(goods[i]) + end + self.StdCards[i].GameObject:SetActive(true) + end + + for i = #goods + 1, #self.StdCards do + self.StdCards[i].GameObject:SetActive(false) + end +end + +function XUiDrawPreview:SetActive(bool) + self.GameObject:SetActive(bool) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiDrawPreview:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiDrawPreview:AutoInitUi() + -- self.PanelPreview = self.Transform:Find("SafeAreaContentPane/PanelPreview") + -- self.PanelPro = self.Transform:Find("SafeAreaContentPane/PanelPreview/PnlScrollView/PnlViewport/PnlDetailContent/PanelPro") + -- self.PanelProCard = self.Transform:Find("SafeAreaContentPane/PanelPreview/PnlScrollView/PnlViewport/PnlDetailContent/PanelPro/PanelProCard") + -- self.PanelStd = self.Transform:Find("SafeAreaContentPane/PanelPreview/PnlScrollView/PnlViewport/PnlDetailContent/PanelStd") + -- self.PanelStdCard = self.Transform:Find("SafeAreaContentPane/PanelPreview/PnlScrollView/PnlViewport/PnlDetailContent/PanelStd/PanelStdCard") + -- self.BtnClose = self.Transform:Find("SafeAreaContentPane/BtnClose"):GetComponent("Button") + -- self.ProTitle = self.Transform:Find("SafeAreaContentPane/PanelPreview/PnlScrollView/PnlViewport/PnlDetailContent/ProTitle") +end + +function XUiDrawPreview:GetAutoKey(uiNode, eventName) + if not uiNode then + return + end + return eventName .. uiNode:GetHashCode() +end + +function XUiDrawPreview:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then + return + end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiDrawPreview:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiDrawPreview:AutoAddListener() + self.AutoCreateListeners = {} + self:RegisterClickEvent(self.BtnClose, self.OnBtnCloseClick) +end +-- auto +function XUiDrawPreview:OnBtnCloseClick() +--[[ if self.Closed then + return + end + + self.Closed = true + --]] +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDraw/XUiDrawResult.lua b/Resources/Scripts/XUi/XUiDraw/XUiDrawResult.lua new file mode 100644 index 00000000..905e78be --- /dev/null +++ b/Resources/Scripts/XUi/XUiDraw/XUiDrawResult.lua @@ -0,0 +1,169 @@ +local XUiDrawResult = XLuaUiManager.Register(XLuaUi, "UiDrawResult") + +local MODE_LOOP = 1 + +function XUiDrawResult:OnAwake() + self:InitAutoScript() +end + +function XUiDrawResult:OnStart(drawInfo, rewardList, backCb) + local behaviour = self.GameObject:AddComponent(typeof(CS.XLuaBehaviour)) + if self.Update then + behaviour.LuaUpdate = function() self:Update() end + end + self.ShowInterval = 0.2 + self.StartShow = false + self.LastShowTime = 0 + self.ShowIndex = 1 + + self.TarnsInterval = 0.4 + self.StartTrans = false + self.LastTarnsTime = 0 + self.TransIndex = 1 + self.TransNum = 0 + self.GridObj = {} + + self.GridGain.gameObject:SetActive(false) + self.PanelTrans.gameObject:SetActive(false) + self.RewardList = rewardList + self:SetupRewards() + self.BackCb = backCb + self.IsFinish = false + self.BtnBack.gameObject.transform:SetAsLastSibling() + self:PlayAnimation("AniResultGridGain", function() + self:PlayAnimation("AniResultGridGainLoop") + self.AniResultGridGainLoop.extrapolationMode = MODE_LOOP + self.StartShow = true + end) +end + +function XUiDrawResult:Update() + if self.StartShow then + if self.ShowIndex > #self.RewardList then + self.StartShow = false + self.StartTrans = true + self.LastTarnsTime = CS.UnityEngine.Time.time + else + if CS.UnityEngine.Time.time - self.LastShowTime > self.ShowInterval then + self:ShowResult() + end + end + elseif self.StartTrans then + if CS.UnityEngine.Time.time - self.LastShowTime > self.ShowInterval then + if self.TransIndex > self.TransNum then + self.IsFinish = true + self.StartTrans = false + self.BtnBack.gameObject.transform:SetAsFirstSibling() + else + if CS.UnityEngine.Time.time - self.LastTarnsTime > self.TarnsInterval then + self:ShowTrans() + end + end + end + end +end + +function XUiDrawResult:OnEnable() + XUiHelper.PopupFirstGet() +end + +function XUiDrawResult:OnDisable() + XDataCenter.AntiAddictionManager.EndDrawCardAction() +end + +function XUiDrawResult:InitAutoScript() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiDrawResult:GetAutoKey(uiNode, eventName) + if not uiNode then + return + end + return eventName .. uiNode:GetHashCode() +end + +function XUiDrawResult:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then + return + end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiDrawResult:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiDrawResult:AutoAddListener() + self.AutoCreateListeners = {} + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) +end + +function XUiDrawResult:OnBtnBackClick() + if self.IsFinish then + XUiHelper.StopAnimation(self, "AniResultGridGainLoop") + if self.BackCb then + self.BackCb() + end + self:Close() + end +end + +function XUiDrawResult:SetupRewards() + for i = 1, #self.RewardList do + local ui = CS.UnityEngine.Object.Instantiate(self.GridGain) + local grid = XUiGridCommon.New(self, ui) + grid.Transform:SetParent(self.PanelGainList, false) + --被转化物品 + if self.RewardList[i].ConvertFrom ~= 0 then + self.TransNum = self.TransNum + 1 + grid:Refresh(self.RewardList[i].ConvertFrom) + else + grid:Refresh(self.RewardList[i]) + end + table.insert(self.GridObj, grid) + grid.GameObject:SetActive(false) + end +end + +function XUiDrawResult:ShowResult() + self.GridObj[self.ShowIndex].GameObject:SetActive(true) + self.GridObj[self.ShowIndex].GameObject:PlayTimelineAnimation() + CS.XAudioManager.PlaySound(XSoundManager.UiBasicsMusic.UiDrawCard_Reward_Normal) + self.LastShowTime = CS.UnityEngine.Time.time + self.ShowIndex = self.ShowIndex + 1 +end + +--已经拥有的角色转换碎片过程 +function XUiDrawResult:ShowTrans() + local count = 0 + for i = 1, #self.RewardList do + if self.RewardList[i].ConvertFrom ~= 0 then + count = count + 1 + if count == self.TransIndex then + self.GridObj[i]:Refresh(self.RewardList[i]) + local tempTransEffect = CS.UnityEngine.Object.Instantiate(self.PanelTrans) + tempTransEffect.transform:SetParent(self.PanelContent, false) + tempTransEffect.gameObject:SetActive(true) + tempTransEffect.transform.localPosition = self.GridObj[i].GameObject.transform.localPosition + self.PanelGainList.transform.localPosition + CS.XAudioManager.PlaySound(XSoundManager.UiBasicsMusic.UiDrawCard_Reward_Suipian) + end + end + end + self.LastTarnsTime = CS.UnityEngine.Time.time + self.TransIndex = self.TransIndex + 1 +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDraw/XUiDrawRule.lua b/Resources/Scripts/XUi/XUiDraw/XUiDrawRule.lua new file mode 100644 index 00000000..cd7eb133 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDraw/XUiDrawRule.lua @@ -0,0 +1,108 @@ +local XUiDrawRule = XLuaUiManager.Register(XLuaUi, "UiDrawRule") +local prob = require("XUi/XUiDraw/XUiPanelProbability") + +function XUiDrawRule:OnAwake() + self:InitAutoScript() +end + +function XUiDrawRule:OnStart(drawId, closeCb) + self.PanelProbability.gameObject:SetActive(false) + self.CloseCb = closeCb + self:SetData(drawId) +end + +function XUiDrawRule:SetData(drawId) + local groupId = XDataCenter.DrawManager.GetDrawInfo(drawId).GroupId + local rules = XDataCenter.DrawManager.GetDrawGroupRule(groupId).BaseRules + local rule = rules[1] + for i = 2, #rules do + rule = rule .. "\n" .. rules[i] + end + self.TxtRule.text = rule + if not self.Probs then + self.Probs = {} + end + local list = XDataCenter.DrawManager.GetDrawProb(drawId) + if not list then + return + end + for i = 1, #list do + if not self.Probs[i] then + local go = CS.UnityEngine.Object.Instantiate(self.PanelProbability, self.PanelDetailContent) + local item = prob.New(go, self) + table.insert(self.Probs, item) + end + self.Probs[i]:SetData(list[i]) + self.Probs[i]:SetActive(true) + end + if #list < #self.Probs then + for i = #list + 1, #self.Probs do + self.Probs[i]:SetActive(false) + end + end +end + +function XUiDrawRule:SetActive(bool) + self.GameObject:SetActive(bool) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiDrawRule:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiDrawRule:AutoInitUi() + -- self.BtnClose = self.Transform:Find("SafeAreaContentPane/BtnClose"):GetComponent("Button") + -- self.PanelRule = self.Transform:Find("SafeAreaContentPane/PanelRule") + -- self.PanelDetailContent = self.Transform:Find("SafeAreaContentPane/PanelRule/PnlScrollView/PnlViewport/PanelDetailContent") + -- self.TxtRule = self.Transform:Find("SafeAreaContentPane/PanelRule/PnlScrollView/PnlViewport/PanelDetailContent/TxtRule"):GetComponent("Text") + -- self.PanelProbability = self.Transform:Find("SafeAreaContentPane/PanelRule/PnlScrollView/PnlViewport/PanelDetailContent/PanelProbability") +end + +function XUiDrawRule:GetAutoKey(uiNode, eventName) + if not uiNode then + return + end + return eventName .. uiNode:GetHashCode() +end + +function XUiDrawRule:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then + return + end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiDrawRule:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiDrawRule:AutoAddListener() + self.AutoCreateListeners = {} + self:RegisterClickEvent(self.BtnClose, self.OnBtnCloseClick) +end +-- auto +function XUiDrawRule:OnBtnCloseClick() + if self.Closed then + return + end + + self.Closed = true +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDraw/XUiDrawShow.lua b/Resources/Scripts/XUi/XUiDraw/XUiDrawShow.lua new file mode 100644 index 00000000..b2208ec7 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDraw/XUiDrawShow.lua @@ -0,0 +1,607 @@ +local XUiDrawShow = XLuaUiManager.Register(XLuaUi, "UiDrawShow") +-- local drawShowWeapon = require("XUi/XUiDraw/XUiDrawTools/XUiDrawWeapon") +local drawShowEffect = require("XUi/XUiDraw/XUiDrawTools/XUiDrawShowEffect") +local drawScene = require("XUi/XUiDraw/XUiDrawTools/XUiDrawScene") + +function XUiDrawShow:OnAwake() + self:InitAutoScript() +end + +function XUiDrawShow:OnStart() + self.Animation = self.Transform:GetComponent("Animation") + self:InitImgRewards() +end + +function XUiDrawShow:SetData(drawInfo, rewardList, resultCb, backGround) + self.BackGround = backGround + self.RewardList = rewardList + self.ResultCb = resultCb + + self:ResetState() + self:InitTools() + self.ShowIndex = 1 + self.PartnerIndex = 1 + self.IsOpening = false + self.CurLight = {} + self.PlayBoxAnim = false + self.BtnClick.gameObject:SetActiveEx(false) + self:InitDrawBackGround() + XUiHelper.SetDelayPopupFirstGet(true) +end + +function XUiDrawShow:OnDisable() + self:HideAllEffect() + XUiHelper.SetDelayPopupFirstGet() +end + +function XUiDrawShow:Update() + if self.PlayBoxAnim then + if self.PlayableDirector.time >= self.PlayableDirector.duration - 0.1 then + self:BoxAnimEnd() + end + end +end + +function XUiDrawShow:InitImgRewards() + self.ImgRewards = {} + self.ImgRewards[XArrangeConfigs.Types.Character] = self.ImgCharacter + self.ImgRewards[XArrangeConfigs.Types.Fashion] = self.ImgItem + self.ImgRewards[XArrangeConfigs.Types.Item] = self.ImgItem + self.ImgRewards[XArrangeConfigs.Types.Wafer] = self.ImgWafer + self.ImgRewards[XArrangeConfigs.Types.Weapon] = self.ImgEquip + self.ImgRewards[XArrangeConfigs.Types.Furniture] = self.ImgItem + self.ImgRewards[XArrangeConfigs.Types.HeadPortrait] = self.ImgItem + self.ImgRewards[XArrangeConfigs.Types.ChatEmoji] = self.ImgItem + self.ImgRewards[XArrangeConfigs.Types.Partner] = self.ImgPartner +end + +function XUiDrawShow:ResetState() + self.ImgCharacter.gameObject:SetActiveEx(false) + self.ImgItem.gameObject:SetActiveEx(false) + self.ImgWafer.gameObject:SetActiveEx(false) + self.ImgEquip.gameObject:SetActiveEx(false) + self.ImgPartner.gameObject:SetActiveEx(false) + + self.ImageItemPack.gameObject:SetActiveEx(false) + self.ImageWeaponPack.gameObject:SetActiveEx(false) + self.ImageCharacterPack.gameObject:SetActiveEx(false) + self.ImageWaferPack.gameObject:SetActiveEx(false) + self.ImagePartnerPack.gameObject:SetActiveEx(false) +end + +function XUiDrawShow:InitTools() + --drawScene.AddObject(self.PanelWeapon, drawScene.Types.WEAPON) + --drawShowWeapon.SetNode(self.PanelAnim, self.PanelWeapon) + drawScene.SetActive(drawScene.Types.BOX, false) + drawScene.SetActive(drawScene.Types.BG, false) + XRTextureManager.SetTextureCache(self.RImgDrawCardShow) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiDrawShow:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiDrawShow:AutoInitUi() + -- self.PanelDrawBackGround = self.Transform:Find("FullScreenBackground/PanelDrawBackGround") + -- self.PanelResult = self.Transform:Find("SafeAreaContentPane/PanelResult") + -- self.ImgItem = self.Transform:Find("SafeAreaContentPane/PanelResult/ImgItem"):GetComponent("RawImage") + -- self.ImgCharacter = self.Transform:Find("SafeAreaContentPane/PanelResult/ImgCharacter"):GetComponent("RawImage") + -- self.ImgWafer = self.Transform:Find("SafeAreaContentPane/PanelResult/ImgWafer"):GetComponent("RawImage") + -- self.RImgDrawCardShow = self.Transform:Find("SafeAreaContentPane/RImgDrawCardShow"):GetComponent("RawImage") + -- self.PanelEffect = self.Transform:Find("SafeAreaContentPane/PanelEffect") + -- self.BtnClick = self.Transform:Find("SafeAreaContentPane/BtnClick"):GetComponent("Button") + -- self.PanelAnim = self.Transform:Find("SafeAreaContentPane/ModelRoot/NearRoot/PanelAnim") + -- self.PanelInfo = self.Transform:Find("SafeAreaContentPane/PanelInfo") + -- self.TxtType = self.Transform:Find("SafeAreaContentPane/PanelInfo/TxtType"):GetComponent("Text") + -- self.TxtName = self.Transform:Find("SafeAreaContentPane/PanelInfo/TxtName"):GetComponent("Text") + -- self.TxtQuality = self.Transform:Find("SafeAreaContentPane/PanelInfo/TxtQuality"):GetComponent("Text") + -- self.ImgEquip = self.Transform:Find("SafeAreaContentPane/PanelResult/ImgEquip"):GetComponent("RawImage") + -- self.BtnSkip = self.Transform:Find("SafeAreaContentPane/BtnSkip"):GetComponent("Button") +end + +function XUiDrawShow:AutoAddListener() + self:RegisterClickEvent(self.BtnClick, self.OnBtnClickClick) + self:RegisterClickEvent(self.BtnSkip, self.OnBtnSkipClick) +end +-- auto +function XUiDrawShow:OnBtnClickClick() + if self.IsOpening then + self:ShowResult() + else + if self.IsPartner then + self.PartnerIndex = self.PartnerIndex + 1 + self.IsPartner = false + end + self:HideAllEffect() + self:NextPack() + end +end + +function XUiDrawShow:OnBtnSkipClick() + if self.IsPartner then + self.PartnerIndex = self.PartnerIndex + 1 + self.IsPartner = false + end + + self:ClearLastModel() + self:PlayEnd() +end + +function XUiDrawShow:ShowWeapon() + drawScene.SetActive(drawScene.Types.WEAPON, true) +end + +function XUiDrawShow:ShowResult() + XUiHelper.StopAnimation(false) + + local reward = self.RewardList[self.ShowIndex] + local id = reward.Id and reward.Id > 0 and reward.Id or reward.TemplateId + if reward.ConvertFrom > 0 then + id = reward.ConvertFrom + end + local Type = XTypeManager.GetTypeById(id) + local quality + local templateIdData = XGoodsCommonManager.GetGoodsShowParamsByTemplateId(id) + if Type == XArrangeConfigs.Types.Wafer then + quality = templateIdData.Star + elseif Type == XArrangeConfigs.Types.Weapon then + quality = templateIdData.Star + elseif Type == XArrangeConfigs.Types.Character then + quality = XCharacterConfigs.GetCharMinQuality(id) + else + quality = XTypeManager.GetQualityById(id) + end + local showTable = XDataCenter.DrawManager.GetDrawShow(Type) + local skipEffect = XDrawConfigs.GetSkipEffect(showTable.DrawEffectGroupId[quality]) + self.CurPanelOpenUpEffect = self.PanelOpenUp:LoadPrefab(skipEffect) + self.CurPanelOpenUpEffect.gameObject.name = skipEffect + self.CurPanelOpenUpEffect.gameObject:SetActiveEx(true) + + self.Plane.gameObject:SetActiveEx(false) + + self.IsOpening = false + self.Animation:Play(showTable.UiResultAnim) + -- if Type == XArrangeConfigs.Types.Weapon then + -- drawShowWeapon.PlayResultAnim() + -- end + + self.ShowIndex = self.ShowIndex + 1 +end + +function XUiDrawShow:ClearLastModel() + if self.LastCharacterModel then + self.LastCharacterModel.gameObject:SetActiveEx(false) + self.LastCharacterModel = nil + end + + if self.LastWeaponModel then + self.LastWeaponModel.gameObject:SetActiveEx(false) + self.LastWeaponModel = nil + end + + if self.LastPartnerModel then + self.LastPartnerModel.gameObject:SetActiveEx(false) + self.LastPartnerModel = nil + end +end + +function XUiDrawShow:NextPack() + self.BtnClick.gameObject:SetActiveEx(false) + self:ClearLastModel() + if self.ShowIndex > #self.RewardList then + self:PlayEnd() + return + end + + if self.CvInfo then + self.CvInfo:Stop() + self.CvInfo = nil + end + self.Plane.gameObject:SetActiveEx(false) + local reward = self.RewardList[self.ShowIndex] + local id = reward.Id and reward.Id > 0 and reward.Id or reward.TemplateId + if reward.ConvertFrom > 0 then + id = reward.ConvertFrom + end + local Type = XTypeManager.GetTypeById(id) + local quality + local templateIdData = XGoodsCommonManager.GetGoodsShowParamsByTemplateId(id) + if Type == XArrangeConfigs.Types.Wafer then + quality = templateIdData.Star + elseif Type == XArrangeConfigs.Types.Weapon then + quality = templateIdData.Star + elseif Type == XArrangeConfigs.Types.Character then + quality = XCharacterConfigs.GetCharMinQuality(id) + elseif Type == XArrangeConfigs.Types.Partner then + quality = templateIdData.Quality + else + quality = XTypeManager.GetQualityById(id) + end + + local soundType = XSoundManager.UiBasicsMusic.UiDrawCard_Type.Normal + + if quality then + if quality == 5 then + soundType = XSoundManager.UiBasicsMusic.UiDrawCard_Type.FiveStar + elseif quality == 6 then + soundType = XSoundManager.UiBasicsMusic.UiDrawCard_Type.SixStar + end + end + + local icon + if Type == XArrangeConfigs.Types.Weapon or Type == XArrangeConfigs.Types.Furniture or Type == XArrangeConfigs.Types.HeadPortrait then + local goodsShowParams = XGoodsCommonManager.GetGoodsShowParamsByTemplateId(id) + icon = goodsShowParams.BigIcon + + if Type ~= XArrangeConfigs.Types.Weapon then + self.ImgRewards[Type]:SetRawImage(icon) + self.BtnClick.gameObject:SetActiveEx(true) + end + else + if Type == XArrangeConfigs.Types.Character then + icon = XDataCenter.CharacterManager.GetCharHalfBodyImage(id) + if quality < 3 then + soundType = XSoundManager.UiBasicsMusic.UiDrawCard_Type.FiveStar + elseif quality > 2 then + soundType = XSoundManager.UiBasicsMusic.UiDrawCard_Type.SixStar + end + elseif Type == XArrangeConfigs.Types.Wafer then + icon = XDataCenter.EquipManager.GetEquipLiHuiPath(id) + elseif Type == XArrangeConfigs.Types.Item then + icon = XDataCenter.ItemManager.GetItemBigIcon(id) + elseif Type == XArrangeConfigs.Types.Fashion then + icon = XDataCenter.FashionManager.GetFashionIcon(id) + elseif Type == XArrangeConfigs.Types.ChatEmoji then + icon = XDataCenter.ChatManager.GetEmojiIcon(id) + elseif Type == XArrangeConfigs.Types.Partner then + icon = templateIdData.Icon + if quality < 3 then + soundType = XSoundManager.UiBasicsMusic.UiDrawCard_Type.FiveStar + elseif quality > 2 then + soundType = XSoundManager.UiBasicsMusic.UiDrawCard_Type.SixStar + end + end + + if Type ~= XArrangeConfigs.Types.Character and Type ~= XArrangeConfigs.Types.Partner then + self.ImgRewards[Type]:SetRawImage(icon) + self.BtnClick.gameObject:SetActiveEx(true) + end + end + local curShowNum = self.ShowIndex + local showTable = XDataCenter.DrawManager.GetDrawShow(Type) + self.IsOpening = true + self.IsPartner = false + XUiHelper.StopAnimation(false) + XUiHelper.PlayAnimation(self, showTable.UiAnim, nil, function() + self.PanelCardShowOff.gameObject:SetActiveEx(true) + if self.GameObject.activeInHierarchy then + if curShowNum == self.ShowIndex then + local effect = XDrawConfigs.GetOpenUpEffect(showTable.DrawEffectGroupId[quality]) + self.CurPanelOpenUpEffect = self.PanelOpenUp.transform:Find(effect) + if self.CurPanelOpenUpEffect then + self.CurPanelOpenUpEffect.gameObject:SetActiveEx(true) + else + self.CurPanelOpenUpEffect = self.PanelOpenUp:LoadPrefab(effect) + self.CurPanelOpenUpEffect.gameObject.name = effect + self.CurPanelOpenUpEffect.gameObject:SetActiveEx(true) + end + end + if Type == XArrangeConfigs.Types.Character then + self:ShowCharacterModel(id) + elseif Type == XArrangeConfigs.Types.Weapon then + self:ShowWeaponModel(id) + elseif Type == XArrangeConfigs.Types.Partner then + self.IsPartner = true + self:ShowPartnerModel(id) + end + XUiHelper.PlayAnimation(self, showTable.UiAnim .. "Item", nil, function() + if curShowNum == self.ShowIndex then + self.IsOpening = false + self.ShowIndex = self.ShowIndex + 1 + end + end) + end + + CS.XAudioManager.PlaySound(soundType.Show) + end) + + CS.XAudioManager.PlaySound(soundType.Start) + + local templeid = id + if XArrangeConfigs.Types.Furniture == reward.RewardType then + local cfg = XFurnitureConfigs.GetFurnitureReward(id) + if cfg and cfg.FurnitureId then + templeid = cfg.FurnitureId + end + end + self.TxtName.text = XTypeManager.GetNameById(templeid) + self.TxtType.text = showTable.TypeText + self.TxtQuality.text = showTable.QualityText[quality] + + --effect + self.PanelOpenUp.gameObject:SetActiveEx(true) + self.PanelOpenDown.gameObject:SetActiveEx(true) + + local effect = XDrawConfigs.GetOpenDownEffect(showTable.DrawEffectGroupId[quality]) + self.CurPanelOpenDownEffect = self.PanelOpenDown.transform:Find(effect) + if self.CurPanelOpenDownEffect then + self.CurPanelOpenDownEffect.gameObject:SetActiveEx(true) + else + self.CurPanelOpenDownEffect = self.PanelOpenDown:LoadPrefab(effect) + self.CurPanelOpenDownEffect.gameObject.name = effect + self.CurPanelOpenDownEffect.gameObject:SetActiveEx(true) + end + +end + +function XUiDrawShow:ShowWeaponModel(templateId) + local modelConfig = XDataCenter.EquipManager.GetWeaponModelCfg(templateId, self.Name, 0) + if modelConfig then + XModelManager.LoadWeaponModel(modelConfig.ModelId, self.WeaponRoot, modelConfig.TransformConfig, self.Name, function(model) + model.gameObject:SetActiveEx(true) + self.LastWeaponModel = model + self.BtnClick.gameObject:SetActiveEx(true) + end, { gameObject = self.GameObject }) + end +end + +function XUiDrawShow:ShowCharacterModel(templateId) + if not self.InitRoleMode then + self.InitRoleMode = true + self.RoleModelPanel = XUiPanelRoleModel.New(self.CharacterRoot, self.Name, true, false, false) + end + + local fashtionId = XCharacterConfigs.GetCharacterTemplate(templateId).DefaultNpcFashtionId + XDataCenter.DisplayManager.UpdateRoleModel(self.RoleModelPanel, templateId, nil, fashtionId) + + self.RoleModelPanel:UpdateCharacterModel(templateId, self.CharacterRoot, XModelManager.MODEL_UINAME.XUiDrawShow, function(model) + CS.XAudioManager.PlaySound(XSoundManager.UiBasicsMusic.UiDrawCard_Chouka_Name) + model.gameObject:SetActiveEx(true) + + local animeID = XDataCenter.DrawManager.GetDrawShowCharacter(templateId).AnimeID + local voiceId = XDataCenter.DrawManager.GetDrawShowCharacter(templateId).VoiceId + + if animeID then + self.RoleModelPanel:PlayAnima(animeID) + end + + if voiceId then + self.CvInfo = CS.XAudioManager.PlayCv(voiceId) + end + + self.LastCharacterModel = model + self.BtnClick.gameObject:SetActiveEx(true) + end, nil, fashtionId) +end + +--- +--- 展示伙伴模型,并且播放变形动画 +--- 待机模型->战斗模型 +function XUiDrawShow:ShowPartnerModel(templateId) + if not self.InitPartnerMode then + self.InitPartnerMode = true + self.PartnerModelPanel = XUiPanelRoleModel.New(self.PartnerRoot, self.Name, nil, true, nil, true) + end + + -- 待机模型 + local standByModel = XPartnerConfigs.GetPartnerModelStandbyModel(templateId) + self.PartnerModelPanel:UpdatePartnerModel(standByModel, XModelManager.MODEL_UINAME.XUiDrawShow, nil, function(SModel) + SModel.gameObject:SetActiveEx(true) + self.LastPartnerModel = SModel + self.BtnClick.gameObject:SetActiveEx(true) + end, false, true) + + -- 变形 + local sToCAnime = XPartnerConfigs.GetPartnerModelSToCAnime(templateId) + local sToCBornEffect = XPartnerConfigs.GetPartnerModelSToCEffect(templateId) + local combatBornEffect = XPartnerConfigs.GetPartnerModelCombatBornEffect(templateId) + local combatModel = XPartnerConfigs.GetPartnerModelCombatModel(templateId) + local CombatBornAnime = XPartnerConfigs.GetPartnerModelCombatBornAnime(templateId) + local voiceId = XPartnerConfigs.GetPartnerModelSToCVoice(templateId) + -- 音效 + if voiceId and voiceId > 0 then + self.CvInfo = XSoundManager.PlaySoundByType(voiceId, XSoundManager.SoundType.Sound) + end + + local partnerCurShowNum = self.PartnerIndex + + -- 变形特效 + self.PartnerModelPanel:LoadEffect(sToCBornEffect, "ModelOffEffect", true, true) + -- 动画 + self.PartnerModelPanel:PlayAnima(sToCAnime, true, function() + if partnerCurShowNum == self.PartnerIndex then + -- 出生特效 + self.PartnerModelPanel:LoadEffect(combatBornEffect, "ModelOnEffect", true, true) + -- 战斗模型 + self.PartnerModelPanel:UpdatePartnerModel(combatModel, XModelManager.MODEL_UINAME.XUiDrawShow, nil, function(CModel) + CModel.gameObject:SetActiveEx(true) + self.LastPartnerModel = CModel + end, false, true) + -- 动画 + self.PartnerModelPanel:PlayAnima(CombatBornAnime, true,function() + if partnerCurShowNum == self.PartnerIndex then + self.PartnerIndex = self.PartnerIndex + 1 + end + end) + end + end) +end + +function XUiDrawShow:HideAllEffect() + if not XTool.UObjIsNil(self.PanelOpenUp) then + self.PanelOpenUp.gameObject:SetActiveEx(false) + end + if not XTool.UObjIsNil(self.PanelOpenDown) then + self.PanelOpenDown.gameObject:SetActiveEx(false) + end + if not XTool.UObjIsNil(self.PanelCardShowOff) then + self.PanelCardShowOff.gameObject:SetActiveEx(false) + end + if not XTool.UObjIsNil(self.CurPanelOpenUpEffect) then + self.CurPanelOpenUpEffect.gameObject:SetActiveEx(false) + end + if not XTool.UObjIsNil(self.CurPanelOpenDownEffect) then + self.CurPanelOpenDownEffect.gameObject:SetActiveEx(false) + end + if not XTool.UObjIsNil(self.CurPanelCardShowOffEffect) then + self.CurPanelCardShowOffEffect.gameObject:SetActiveEx(false) + end + if self.PartnerModelPanel then + self.PartnerModelPanel:HideAllEffects() + end +end + +function XUiDrawShow:PlayEnd() + XUiHelper.StopAnimation() + self.Plane.gameObject:SetActiveEx(true) + self.BtnClick.gameObject:SetActiveEx(true) + drawScene.SetActive(drawScene.Types.BOX, true) + if self.CurLight.gameObject then + self.CurLight.gameObject:SetActiveEx(false) + end + if self.CurLightLock and not XTool.UObjIsNil(self.CurLightLock.gameObject) then + self.CurLightLock.gameObject:SetActiveEx(false) + end + if self.CvInfo then + self.CvInfo:Stop() + self.CvInfo = nil + end + self:Close() + self.ResultCb() +end + +function XUiDrawShow:OnDestroy() + drawScene.DestroyObject(drawScene.Types.EFFECT) + drawScene.DestroyObject(drawScene.Types.WEAPON) + drawScene.DestroyObject(drawScene.Types.SHOWBG) + drawShowEffect.Dispose() +end + +--wind +function XUiDrawShow:InitDrawBackGround() + self.TxtType.text = "" + self.TxtName.text = "" + self.TxtQuality.text = "" + self.PanelInfo.gameObject:GetComponent("CanvasGroup").alpha = 0 + + self:PlayBoxAnimStart() +end + +function XUiDrawShow:PlayBoxAnimStart() + self.PanelOpenUp = self.BackGround.transform:Find("ModelRoot/UiNearRoot/EffectRoot/PanelOpenUp") + self.PanelOpenDown = self.BackGround.transform:Find("ModelRoot/UiNearRoot/EffectRoot/PanelOpenDown") + self.PanelCardShowOff = self.BackGround.transform:Find("ModelRoot/UiNearRoot/EffectRoot/PanelCardShowOff") + self.WeaponRoot = self.BackGround.transform:Find("ModelRoot/UiNearRoot/WeaponRoot") + self.CharacterRoot = self.BackGround.transform:Find("ModelRoot/UiNearRoot/CharacterRoot") + self.PartnerRoot = self.BackGround.transform:Find("ModelRoot/UiNearRoot/PartnerRoot") + self.Plane = self.BackGround.transform:Find("ModelRoot/UiFarRoot/Plane") + + local behaviour = self.GameObject:GetComponent("XLuaBehaviour") + if not behaviour then + behaviour = self.GameObject:AddComponent(typeof(CS.XLuaBehaviour)) + end + + if self.Update then + behaviour.LuaUpdate = function() self:Update() end + end + self.PlayableDirector = self.BackGround:GetComponent("PlayableDirector") + self.PlayableDirector:Play() + self.PlayBoxAnim = true + self.PanelBoxLight = self.BackGround.transform:Find("ModelRoot/UiNearRoot/PanelBox/PanelBoxLight") + self.PanelBoxLock = self.BackGround.transform:Find("ModelRoot/UiNearRoot/PanelBox/PanelBoxLock") + self.CurLight = self.PanelBoxLight:LoadPrefab(self:GetMaxQualityEffectName()) + self.CurLight.gameObject:SetActiveEx(true) + + if self.PanelBoxLock then + self.CurLightLock = self.PanelBoxLock:LoadPrefab(XUiConfigs.GetComponentUrl("UiDrawOpenBoxPre")) + self.CurLightLock.gameObject:SetActiveEx(true) + end +end + +function XUiDrawShow:BoxAnimEnd() + self.PlayBoxAnim = false + self:NextPack() +end + +function XUiDrawShow:GetQuality(showIndex) + local reward = self.RewardList[showIndex] + local id = reward.Id and reward.Id > 0 and reward.Id or reward.TemplateId + if reward.ConvertFrom > 0 then + id = reward.ConvertFrom + end + local quality + local templateIdData = XGoodsCommonManager.GetGoodsShowParamsByTemplateId(id) + local Type = XTypeManager.GetTypeById(id) + if Type == XArrangeConfigs.Types.Wafer then + quality = templateIdData.Star + elseif Type == XArrangeConfigs.Types.Weapon then + quality = templateIdData.Star + elseif Type == XArrangeConfigs.Types.Character then + quality = XCharacterConfigs.GetCharMinQuality(id) + else + quality = XTypeManager.GetQualityById(id) + end + return quality +end + +function XUiDrawShow:GetRewardType(showIndex) + local reward = self.RewardList[showIndex] + local id = reward.Id and reward.Id > 0 and reward.Id or reward.TemplateId + if reward.ConvertFrom > 0 then + id = reward.ConvertFrom + end + local type = XTypeManager.GetTypeById(id) + return type +end + +--获取最高品级效果,按类型取每一类最大值,最后比较大小得出最大的类型和值 +function XUiDrawShow:GetMaxQualityEffectName() + local maxByType = {} + + for k, v in pairs(XArrangeConfigs.Types) do + local maxQuality = 0 + for i = 1, #self.RewardList do + if self:GetRewardType(i) == v then + local tempQuality = self:GetQuality(i) + if tempQuality > maxQuality then + maxQuality = tempQuality + end + end + end + maxByType[k] = maxQuality + end + + local maxEffectLevel = 1 + local maxEffectPath + for k, v in pairs(XArrangeConfigs.Types) do + if maxByType[k] > 0 then + local showTable = XDataCenter.DrawManager.GetDrawShow(v) + local effect = XDrawConfigs.GetOpenBoxEffect(showTable.DrawEffectGroupId[maxByType[k]]) + + if tonumber(string.sub(effect, -8, -8)) > maxEffectLevel then + maxEffectLevel = tonumber(string.sub(effect, -8, -8)) + maxEffectPath = effect + end + end + end + return maxEffectPath +end + +function XUiDrawShow:SetWeaponPos(target, config) + if not target or not config then + return + end + target.transform.localPosition = CS.UnityEngine.Vector3(config.PositionX, config.PositionY, config.PositionZ) + --检查数据 模型旋转 + target.transform.localEulerAngles = CS.UnityEngine.Vector3(config.RotationX, config.RotationY, config.RotationZ) + --检查数据 模型大小 + target.transform.localScale = CS.UnityEngine.Vector3( + config.ScaleX == 0 and 1 or config.ScaleX, + config.ScaleY == 0 and 1 or config.ScaleY, + config.ScaleZ == 0 and 1 or config.ScaleZ + ) +end +--windEnd \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDraw/XUiDrawSuitPreview.lua b/Resources/Scripts/XUi/XUiDraw/XUiDrawSuitPreview.lua new file mode 100644 index 00000000..7b186a88 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDraw/XUiDrawSuitPreview.lua @@ -0,0 +1,75 @@ +local XUiDrawSuitPreview = XLuaUiManager.Register(XLuaUi, "UiDrawSuitPreview") + +function XUiDrawSuitPreview:OnAwake() + self:InitAutoScript() +end + + +function XUiDrawSuitPreview:OnStart(suitId, parentUi) + self.ParentUi = parentUi + self.Grids = {} + self:UpdatePanel() +end + +function XUiDrawSuitPreview:UpdatePanel() + self.SuitId = self.ParentUi.CurSuitId + self.GridCommon.gameObject:SetActive(false) + local skillDesList = XDataCenter.EquipManager.GetSuitSkillDesList(self.SuitId) + for i = 1, XEquipConfig.MAX_SUIT_SKILL_COUNT do + if skillDesList[i * 2] then + self["TxtSkillDes" .. i].text = skillDesList[i * 2] + self["TxtSkillDes" .. i].gameObject:SetActive(true) + else + self["TxtSkillDes" .. i].gameObject:SetActive(false) + end + end + CS.UnityEngine.UI.LayoutRebuilder.ForceRebuildLayoutImmediate(self.PanelContent) + self.TxtName.text = XDataCenter.EquipManager.GetSuitName(self.SuitId) + self.RImgIco:SetRawImage(XDataCenter.EquipManager.GetSuitBigIconBagPath(self.SuitId)) + local ids = XDataCenter.EquipManager.GetEquipTemplateIdsBySuitId(self.SuitId) + + table.sort(ids, function(a, b) + local aid = XGoodsCommonManager.GetGoodsShowParamsByTemplateId(a) + local bid = XGoodsCommonManager.GetGoodsShowParamsByTemplateId(b) + return aid.Site < bid.Site + end) + + for i = 1, #ids do + if not self.Grids[i] then + local go = CS.UnityEngine.Object.Instantiate(self.GridCommon, self.PanelGrid) + local item = XUiGridCommon.New(self, go) + go.gameObject:SetActive(true) + table.insert(self.Grids, item) + end + end + + for i = 1, #self.Grids do + self.Grids[i]:Refresh(ids[i]) + end + + for i = #ids + 1, #self.Grids do + self.Grids[i].GameObject:SetActive(false) + end +end + +function XUiDrawSuitPreview:RefreshData() + +end + +function XUiDrawSuitPreview:OnEnable() + if self.ParentUi then + self:UpdatePanel() + end +end + + +-- auto +-- Automatic generation of code, forbid to edit +function XUiDrawSuitPreview:InitAutoScript() + self:AutoAddListener() +end + +function XUiDrawSuitPreview:AutoAddListener() + -- self:RegisterClickEvent(self.BtnClose, self.OnBtnCloseClick) +end +-- auto diff --git a/Resources/Scripts/XUi/XUiDraw/XUiDrawTools/XUiDrawBox.lua b/Resources/Scripts/XUi/XUiDraw/XUiDrawTools/XUiDrawBox.lua new file mode 100644 index 00000000..e5389105 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDraw/XUiDrawTools/XUiDrawBox.lua @@ -0,0 +1,28 @@ +local boxAnim +local animOpen = "BoxBegan" +local animReset = "BoxReset" +local animLength --ms + +local Init = function(panelAnim) + local box = panelAnim:GetChild(0) + boxAnim = box:GetComponent("Animation") + local clip = boxAnim:GetClip(animOpen) + animLength = math.floor(clip.length * 1000) +end + +local OpenBox = function(cb) + boxAnim:Play(animOpen) + XScheduleManager.ScheduleOnce(cb, animLength) +end + +local ResetBox = function() + boxAnim:Play(animReset) +end + +local XUiDrawBox = {} + +XUiDrawBox.Init = Init +XUiDrawBox.OpenBox = OpenBox +XUiDrawBox.ResetBox = ResetBox + +return XUiDrawBox \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDraw/XUiDrawTools/XUiDrawCamera.lua b/Resources/Scripts/XUi/XUiDraw/XUiDrawTools/XUiDrawCamera.lua new file mode 100644 index 00000000..375cf323 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDraw/XUiDrawTools/XUiDrawCamera.lua @@ -0,0 +1,37 @@ +-- local Type = { +-- Default = 1, +-- Draw = 2 +-- } +-- local Init = function(transform) +-- --camTrf = transform.root:Find("UiModelCamera") +-- --camera = camTrf:GetComponent("Camera") +-- --local ppb = camTrf:GetComponent("PostProcessingBehaviour") +-- --local profile = ppb.profile +-- --bloom = profile.bloomModel +-- end +-- local LoadSettings = function(type) +-- -- local data = XDataCenter.DrawManager.GetDrawCamera(type) +-- -- if not data then +-- -- return +-- -- end +-- -- camera.allowHDR = data.AllowHDR +-- -- local settings = bloom.settings +-- -- local bloomSettings = settings.bloom +-- -- bloomSettings.intensity = data.Intensity +-- -- bloomSettings.threshold = data.Threshold +-- -- bloomSettings.saturation = data.Saturation +-- -- bloomSettings.softKnee = data.SoftKnee +-- -- bloomSettings.radius = data.Radius +-- -- bloomSettings.iterations = data.Iterations +-- -- settings.bloom = bloomSettings +-- -- bloom.settings = settings +-- end +-- local GetCameraTransform = function() +-- return camTrf +-- end +-- local DrawCamera = {} +-- DrawCamera.Type = Type +-- DrawCamera.Init = Init +-- DrawCamera.LoadSettings = LoadSettings +-- DrawCamera.GetCameraTransform = GetCameraTransform +--return DrawCamera \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDraw/XUiDrawTools/XUiDrawCharacterRecord.lua b/Resources/Scripts/XUi/XUiDraw/XUiDrawTools/XUiDrawCharacterRecord.lua new file mode 100644 index 00000000..3e090dd9 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDraw/XUiDrawTools/XUiDrawCharacterRecord.lua @@ -0,0 +1,46 @@ +local list + +local Record = function() + local charList = XDataCenter.CharacterManager.GetOwnCharacterList() + list = {} + for i = 1, #charList do + table.insert(list, charList[i].Id) + end +end + +local IsOwnCharacter = function(id) + if not list then + XLog.Warning("Haven't record character list yet.") + return + end + + if XArrangeConfigs.GetType(id) ~= XArrangeConfigs.Types.Character then + return false + end + + for i = 1, #list do + if list[i] == id then + return true + end + end + + table.insert(list, id) + + return false +end + +local GetDecomposeData = function(goods) + local characterId = goods.TemplateId + local template = XCharacterConfigs.GetCharacterTemplate(characterId) + local characterType = XCharacterConfigs.GetCharacterType(characterId) + local decomposeCount = XCharacterConfigs.GetDecomposeCount(characterType, goods.Quality) + return { TemplateId = template.ItemId, Count = decomposeCount } +end + +local CharacterRecord = {} + +CharacterRecord.Record = Record +CharacterRecord.IsOwnCharacter = IsOwnCharacter +CharacterRecord.GetDecomposeData = GetDecomposeData + +return CharacterRecord \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDraw/XUiDrawTools/XUiDrawRemainTime.lua b/Resources/Scripts/XUi/XUiDraw/XUiDrawTools/XUiDrawRemainTime.lua new file mode 100644 index 00000000..1a7168dc --- /dev/null +++ b/Resources/Scripts/XUi/XUiDraw/XUiDrawTools/XUiDrawRemainTime.lua @@ -0,0 +1,32 @@ +local timer + +local function RemoveTimer() + if timer then + XScheduleManager.UnSchedule(timer) + timer = nil + end +end + +local function Init(txt, txtName, time) + if not txt or not txt:Exist() then + return + end + txt.text = CS.XTextManager.GetText(txtName, XUiHelper.GetTime(time)) + + local refresh = function() + if not txt or not txt:Exist() then + RemoveTimer() + end + time = time - 1 + txt.text = CS.XTextManager.GetText(txtName, XUiHelper.GetTime(time)) + end + + timer = XScheduleManager.ScheduleForever(refresh, XScheduleManager.SECOND) +end + +local DrawRemainTime = {} + +DrawRemainTime.Init = Init +DrawRemainTime.RemoveTimer = RemoveTimer + +return DrawRemainTime \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDraw/XUiDrawTools/XUiDrawScene.lua b/Resources/Scripts/XUi/XUiDraw/XUiDrawTools/XUiDrawScene.lua new file mode 100644 index 00000000..c05eba9b --- /dev/null +++ b/Resources/Scripts/XUi/XUiDraw/XUiDrawTools/XUiDrawScene.lua @@ -0,0 +1,69 @@ +local Object = CS.UnityEngine.Object +local V3Zero = CS.UnityEngine.Vector3.zero +local V3One = CS.UnityEngine.Vector3.one +local Rotation = CS.UnityEngine.Quaternion.identity +local cam +local objects = {} +local Types = { + BG = 1, + SHOWBG = 2, + BOX = 3, + EFFECT = 4, + WEAPON = 5 +} + +local SetCamera = function(camera) + cam = camera +end + +local AddObject = function(transform, type) + transform:SetParent(cam) + transform.localPosition = V3Zero + transform.localRotation = Rotation + transform.localScale = V3One + objects[type] = transform.gameObject +end + +local SetActive = function(type, bool) + local obj = objects[type] + if obj and obj:Exist() then + obj:SetActive(bool) + end +end + +local SetAllActive = function(bool) + for _, v in pairs(objects) do + if v:Exist() then + v:SetActive(bool) + end + end +end + +local DestroyObject = function(type) + local obj = objects[type] + if obj then + Object.Destroy(obj) + objects[type] = nil + end +end + +local Dispose = function() + for _, v in pairs(objects) do + if v:Exist() then + Object.Destroy(v) + end + end + objects = {} +end + +local DrawScene = {} + +DrawScene.Types = Types +DrawScene.SetCamera = SetCamera +DrawScene.AddObject = AddObject +DrawScene.SetActive = SetActive +DrawScene.SetAllActive = SetAllActive +DrawScene.DestroyObject = DestroyObject +DrawScene.Dispose = Dispose + +return DrawScene \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDraw/XUiDrawTools/XUiDrawShowEffect.lua b/Resources/Scripts/XUi/XUiDraw/XUiDrawTools/XUiDrawShowEffect.lua new file mode 100644 index 00000000..412205cf --- /dev/null +++ b/Resources/Scripts/XUi/XUiDraw/XUiDrawTools/XUiDrawShowEffect.lua @@ -0,0 +1,84 @@ +local effectNode +local effects = {} +local format = string.format + +local Init = function(node) + if not node then + XLog.Warning("XUiDrawShowEffect: Init with nil.") + return + end + if effectNode then + XLog.Warning("XUiDrawShowEffect: Reset effectNode.") + end + effectNode = node +end + +local PlayEffect = function(name) + if not effectNode then + XLog.Warning("XUiDrawShowEffect: Play effect without Init.") + return + end + + if not name or type(name) ~= "string" then + XLog.Warning(format("XUiDrawShowEffect: Invalid name: %s.", name)) + end + + if not effects[name] then + local effect = effectNode:Find(name) + if effect then + effects[name] = effect.gameObject + else + XLog.Warning(format("XUiDrawShowEffect: Effect not found. Name: %s", name)) + return + end + end + + if effects[name]:Exist() then + effects[name]:SetActive(false) + effects[name]:SetActive(true) + else + XLog.Warning(format("XUiDrawShowEffect: UnityObject has been destroyed. Name: %s", name)) + return + end +end + +local HideEffect = function(name) + if not name or type(name) ~= "string" then + XLog.Warning("XUiDrawShowEffect: Invalid name.") + end + + if effects[name] and effects[name]:Exist() then + effects[name]:SetActive(false) + else + XLog.Warning(format("XUiDrawShowEffect: Effect not found. Name: %s", name)) + end +end + +local HideAll = function() + for k, v in pairs(effects) do + if v:Exist() then + v:SetActive(false) + else + effects[k] = nil + end + end +end + +local Dispose = function() + effectNode = nil + for k, _ in pairs(effects) do + effects[k] = nil + end + effects = {} + effectNode = nil +end + +local DrawShowEffect = {} + +DrawShowEffect.Init = Init +DrawShowEffect.PlayEffect = PlayEffect +DrawShowEffect.HideEffect = HideEffect +DrawShowEffect.HideAll = HideAll +DrawShowEffect.Dispose = Dispose + +return DrawShowEffect \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDraw/XUiDrawTools/XUiDrawWeapon.lua b/Resources/Scripts/XUi/XUiDraw/XUiDrawTools/XUiDrawWeapon.lua new file mode 100644 index 00000000..31902968 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDraw/XUiDrawTools/XUiDrawWeapon.lua @@ -0,0 +1,52 @@ +-- local Object = CS.UnityEngine.Object +-- local Model +-- local node +-- local anim +-- local beginAnim = "WeaponShowBegan" +-- local resultAnim = "WeaponShowLoop" + +-- local SetNode = function(weaponNode, animNode) +-- node = weaponNode +-- anim = animNode:GetComponent("Animation") +-- end + +-- -- local Load = function(equipId, refName) +-- -- local modelConfig = XDataCenter.EquipManager.GetWeaponModelCfgByEquipId(equipId, refName) +-- -- if modelConfig then +-- -- XModelManager.LoadWeaponModel(modelConfig.ModelId, node, modelConfig.TransformConfig, self.Name, function(model) +-- -- Model = model +-- -- end, { noRotation = true }) +-- -- end +-- -- end +-- local PlayAnim = function() +-- if not anim then +-- XLog.Warning("XUiDrawWeapon: Missing animation.") +-- return +-- end +-- anim:Play(beginAnim) +-- end + +-- local PlayResultAnim = function() +-- if not anim then +-- XLog.Warning("XUiDrawWeapon: Missing animation.") +-- return +-- end +-- anim:Play(resultAnim) +-- end + +-- local Destroy = function() +-- if Model then +-- Object.Destroy(Model.gameObject) +-- Model = nil +-- end +-- end + +-- local XUiDrawWeapon = {} + +-- XUiDrawWeapon.SetNode = SetNode +-- -- XUiDrawWeapon.Load = Load +-- XUiDrawWeapon.Destroy = Destroy +-- XUiDrawWeapon.PlayAnim = PlayAnim +-- XUiDrawWeapon.PlayResultAnim = PlayResultAnim + +-- return XUiDrawWeapon \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDraw/XUiGridDrawGroupBanner.lua b/Resources/Scripts/XUi/XUiDraw/XUiGridDrawGroupBanner.lua new file mode 100644 index 00000000..fc60dac9 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDraw/XUiGridDrawGroupBanner.lua @@ -0,0 +1,177 @@ +local XUiGridDrawGroupBanner = XClass(nil, "XUiGridDrawGroupBanner") + +function XUiGridDrawGroupBanner:Ctor(ui, info, father) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Info = info + self.NeedCountDown = false + self.UiDrawMain = father + self:InitAutoScript() + self:SetUpCountDown() + self:SetUpBottomTimes() + self:SetUpTransformBtn() + self:SetNewHandHint() + self:SetBannerTime() +end +function XUiGridDrawGroupBanner:SetNewHandHint() + if self.Info.Type == XDataCenter.DrawManager.DrawEventType.NewHand then + if self.Info.MaxBottomTimes == XDataCenter.DrawManager.GetDrawGroupRule(self.Info.Id).NewHandBottomCount then + self:ShowPanelNewHand(true) + else + self:ShowPanelNewHand(false) + end + else + self:ShowPanelNewHand(false) + end +end +-- auto +-- Automatic generation of code, forbid to edit +function XUiGridDrawGroupBanner:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiGridDrawGroupBanner:AutoInitUi() + self.BtnClick = XUiHelper.TryGetComponent(self.Transform, "BtnClick", "Button") + self.BtnTransform = XUiHelper.TryGetComponent(self.Transform, "BtnTransform", "Button") + self.PanelNewHand = self.Transform:Find("PanelNewHand") + self.TimeTxt = XUiHelper.TryGetComponent(self.Transform, "TimeTxt", "Text") +end + +function XUiGridDrawGroupBanner:GetAutoKey(uiNode, eventName) + if not uiNode then + return + end + return eventName .. uiNode:GetHashCode() +end + +function XUiGridDrawGroupBanner:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then + return + end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiGridDrawGroupBanner:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiGridDrawGroupBanner:AutoAddListener() + self.AutoCreateListeners = {} + XUiHelper.RegisterClickEvent(self, self.BtnClick, self.OnBtnClickClick) + XUiHelper.RegisterClickEvent(self, self.BtnTransform, self.OnBtnTransformClick) +end +-- auto +function XUiGridDrawGroupBanner:OnBtnClickClick() + if not self.UiDrawMain.IsInEndAnimation then + self.UiDrawMain.IsInEndAnimation = true + XDataCenter.DrawManager.GetDrawInfoList(self.Info.Id, function() + self.UiDrawMain:PlayAnimation("UiDrawMainEnd", function() + XLuaUiManager.Open(self.Info.UiPrefab, self.Info.Id, function() + self.UiDrawMain.IsInEndAnimation = false + end, self.Info.UiBackGround) + end) + end) + end +end + +function XUiGridDrawGroupBanner:OnBtnTransformClick() + if #self.Info.TransformSuitList > 0 then + XLuaUiManager.Open("UiAwarenessTfChoice", self.Info.TransformSuitList, self.Info.EndTime) + end +end + +function XUiGridDrawGroupBanner:UpdateBanner(info) + self.Info = info + self.NeedCountDown = false + self:SetUpCountDown() + self:SetUpBottomTimes() + self:SetBannerTime() +end + +function XUiGridDrawGroupBanner:SetUpCountDown() + self.TxtCountDownShort = XUiHelper.TryGetComponent(self.Transform, "TxtCountDownShort", "Text") + self.TxtCountDown = XUiHelper.TryGetComponent(self.Transform, "TxtCountDown", "Text") + if self.TxtCountDownShort then + self.TxtCountDownShort.gameObject:SetActiveEx(false) + end + if self.TxtCountDown then + self.TxtCountDown.gameObject:SetActiveEx(false) + end + if self.Info.EndTime > 0 then + local remainTime = self.Info.EndTime - XTime.GetServerNowTimestamp() + XCountDown.CreateTimer(self.GameObject.name, remainTime) + XCountDown.BindTimer(self.GameObject, self.GameObject.name, function(v) + if self.TxtCountDownShort then + self.TxtCountDownShort.text = CS.XTextManager.GetText("DrawResetTimeShort", XUiHelper.GetTime(v, XUiHelper.TimeFormatType.DRAW)) + self.TxtCountDownShort.gameObject:SetActiveEx(true) + elseif self.TxtCountDown then + self.TxtCountDown.text = CS.XTextManager.GetText("DrawCardResetTime", XUiHelper.GetTime(v, XUiHelper.TimeFormatType.DRAW)) + self.TxtCountDown.gameObject:SetActiveEx(true) + end + end) + self.NeedCountDown = true + end +end + +function XUiGridDrawGroupBanner:RemoveCountDown() + if self.NeedCountDown then + XCountDown.RemoveTimer(self.GameObject.name) + end +end + +function XUiGridDrawGroupBanner:SetUpBottomTimes() + self.TxtBottomTimes = XUiHelper.TryGetComponent(self.Transform, "TxtBottomTimes", "Text") + if self.TxtBottomTimes then + if self.Info.BottomTimes > 0 then + self.TxtBottomTimes.text = CS.XTextManager.GetText("DrawBottomTimes", self.Info.BottomTimes) + self.TxtBottomTimes.gameObject:SetActiveEx(true) + else + self.TxtBottomTimes.gameObject:SetActiveEx(false) + end + end +end + +function XUiGridDrawGroupBanner:SetUpTransformBtn() + if self.BtnTransform then + if #self.Info.TransformSuitList > 0 then + self.BtnTransform.gameObject:SetActiveEx(true) + else + self.BtnTransform.gameObject:SetActiveEx(false) + end + end +end + +function XUiGridDrawGroupBanner:ShowPanelNewHand(IsShow) + if self.PanelNewHand then + self.PanelNewHand.gameObject:SetActiveEx(IsShow) + end +end + +function XUiGridDrawGroupBanner:SetBannerTime() + if self.TimeTxt then + local beginTime = self.Info.BannerBeginTime or 0 + local endTime = self.Info.BannerEndTime or 0 + self.TimeTxt.gameObject:SetActiveEx(beginTime ~= 0 and endTime ~= 0) + local beginTimeStr = XTime.TimestampToGameDateTimeString(beginTime, "yyyy/MM/dd HH:mm") + local endTimeStr = XTime.TimestampToGameDateTimeString(endTime, "yyyy/MM/dd HH:mm") + self.TimeTxt.text = string.format("%s-%s", beginTimeStr, endTimeStr) + end +end + +return XUiGridDrawGroupBanner \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDraw/XUiGridDrawSet.lua b/Resources/Scripts/XUi/XUiDraw/XUiGridDrawSet.lua new file mode 100644 index 00000000..e128971b --- /dev/null +++ b/Resources/Scripts/XUi/XUiDraw/XUiGridDrawSet.lua @@ -0,0 +1,69 @@ +local XUiGridDrawSet = XClass(nil, "XUiGridDrawSet") +local FirstIndex = 1 +function XUiGridDrawSet:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.CurType = XDrawConfigs.DrawSetType.Normal + self:SetButtonCallback() +end + +function XUiGridDrawSet:Reset() + self.DrawMainBanner = nil + self.DrawSubBanner = nil + self.GameObject.name = "GridDrawSet" +end + +function XUiGridDrawSet:SetButtonCallback() + self.BtnChange.CallBack = function() + self:OnBtnChangeClick() + end +end + +function XUiGridDrawSet:OnBtnChangeClick() + local IsNormal = self.CurType == XDrawConfigs.DrawSetType.Normal + self.CurType = IsNormal and XDrawConfigs.DrawSetType.Destiny or XDrawConfigs.DrawSetType.Normal + self:Update() +end + +function XUiGridDrawSet:Update() + if self.IsCanShow then + if self.DrawMainBanner and self.DrawSubBanner then + + local IsNormal = self.CurType == XDrawConfigs.DrawSetType.Normal + self.DrawMainBanner.GameObject:SetActiveEx(IsNormal) + self.DrawSubBanner.GameObject:SetActiveEx(not IsNormal) + + local mainTypeName = "" + local subTypeName = "" + local typeChangeCfg = XDrawConfigs.GetDrawTypeChangeCfgById(self.DrawMainBanner.Info.Id) + if typeChangeCfg then + mainTypeName = typeChangeCfg.MainTypeName + subTypeName = typeChangeCfg.SubTypeName[FirstIndex] + end + self.BtnChange:SetName(IsNormal and subTypeName or mainTypeName) + self.BtnChange.gameObject:SetActiveEx(true) + + else + self.BtnChange.gameObject:SetActiveEx(false) + end + end + self.GameObject:SetActiveEx(self.IsCanShow and (self.DrawMainBanner or self.DrawSubBanner)) +end + +function XUiGridDrawSet:SetDrawMainBanner(banner) + if banner then + self.DrawMainBanner = banner + self.DrawMainBanner.Transform:SetParent(self.PanelSet, false) + self.GameObject.name = string.format("GridDrawSet%d",banner.Info.Id) + end +end + +function XUiGridDrawSet:SetDrawSubBanner(banner) + if banner then + self.DrawSubBanner = banner + self.DrawSubBanner.Transform:SetParent(self.PanelSet, false) + end +end + +return XUiGridDrawSet \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDraw/XUiGridGain.lua b/Resources/Scripts/XUi/XUiDraw/XUiGridGain.lua new file mode 100644 index 00000000..53175813 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDraw/XUiGridGain.lua @@ -0,0 +1,52 @@ +local XUiGridGain = XClass(nil, "XUiGridGain") + +function XUiGridGain:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self:InitAutoScript() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiGridGain:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiGridGain:AutoInitUi() +end + +function XUiGridGain:GetAutoKey(uiNode, eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiGridGain:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiGridGain:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiGridGain:AutoAddListener() + self.AutoCreateListeners = {} +end +-- auto +return XUiGridGain \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDraw/XUiNewDrawMain.lua b/Resources/Scripts/XUi/XUiDraw/XUiNewDrawMain.lua new file mode 100644 index 00000000..6ba531d4 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDraw/XUiNewDrawMain.lua @@ -0,0 +1,307 @@ +local XDrawTabBtnEntity = require("XEntity/XDrawMianButton/XDrawTabBtnEntity") +local XNormalDrawGroupBtnEntity = require("XEntity/XDrawMianButton/XNormalDrawGroupBtnEntity") +local XLottoDrawGroupBtnEntity = require("XEntity/XDrawMianButton/XLottoDrawGroupBtnEntity") + +local XUiNewDrawMain = XLuaUiManager.Register(XLuaUi, "UiNewDrawMain") +local XUiNewGridDrawBanner = require("XUi/XUiDraw/XUiNewGridDrawBanner") +local ServerDataReadyMaxCount = 2--增加不同系统类型抽卡时记得酌情增加 +function XUiNewDrawMain:OnStart(ruleType, groupId) + self.RuleType = ruleType + self.DefaultGroupId = groupId + + self.AssetActivityPanel = XUiPanelActivityAsset.New(self.PanelSpecialTool) + self.BtnFirst.gameObject:SetActiveEx(false) + self.BtnChild.gameObject:SetActiveEx(false) + + self.MainBtnList = {} -- 保存一级标签按钮物体,重复使用,在CreateMainBtn函数中,按钮不足时会生成按钮 + self.SubBtnList = {} -- 保存二级标签按钮物体,重复使用,在CreateSubBtn函数中,按钮不足时会生成按钮 + + self.CurBanner = {} + + self:SetButtonCallBack() + self.IsFirstIn = true + self.BtnIndex = 0 +end + +function XUiNewDrawMain:OnDestroy() + self:MarkAllNewTag() +end + +function XUiNewDrawMain:OnEnable() + self:InitDrawCardsData() +end + +function XUiNewDrawMain:SetButtonCallBack() + self.BtnMainUi.CallBack = function() + self:OnBtnMainUiClick() + end + self.BtnBack.CallBack = function() + self:OnBtnBackClick() + end +end + +function XUiNewDrawMain:OnBtnBackClick() + self:Close() +end + +function XUiNewDrawMain:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiNewDrawMain:InitDrawCardsData() + self.readyCount = 0 + self.NormalGroupInfoList = {} + self.LottoGroupInfoList = {} + + XDataCenter.DrawManager.GetDrawGroupList(function()--普通抽卡 + self.NormalGroupInfoList = XDataCenter.DrawManager.GetDrawGroupInfos() + self:CheckServerDataReady() + end) + + XDataCenter.LottoManager.GetLottoRewardInfoRequest(function()--皮肤抽卡 + self.LottoGroupInfoList = XDataCenter.LottoManager.GetLottoGroupDataList() + self:CheckServerDataReady() + end) +end + +function XUiNewDrawMain:CheckServerDataReady()--增加不同系统类型抽卡时记得检查“ServerDataReadyMaxCount”是否相应的增加 + self.readyCount = self.readyCount + 1 + if self.readyCount == ServerDataReadyMaxCount then + self:InitDrawTabs() + end +end + +function XUiNewDrawMain:InitDrawTabs() + self.BtnIndex = 1 + self.MainBtnCount = 1 + self.SubBtnCount = 1 + + -- 保存一级标签(XDrawTabBtnEntity类)的字典与数组 + self.DrawTabDic = {} + self.DrawTabList = {} + + self.AllDataList = {} -- 保存所有标签类,包括一级、二级标签类 + self.AllBtnList = {} -- 保存所有标签按钮物体,包括一级、二级标签按钮物体 + + self.SkipIndexDic = {} -- DrawGroupId对应ButtonGroup的索引 + + self:CreateDrawTabData(self.NormalGroupInfoList, XNormalDrawGroupBtnEntity) --普通抽卡 + self:CreateDrawTabData(self.LottoGroupInfoList, XLottoDrawGroupBtnEntity) --皮肤抽卡 + self:SortDrawTabData() + self:InitButtonGroup() +end + +--- +--- 初始化一级标签类,并保存其子标签类 +function XUiNewDrawMain:CreateDrawTabData(groupInfoList,class)----增加不同系统类型抽卡时页签生成需要添加对应的实体与初始化逻辑 + for _, drawGroupInfo in pairs(groupInfoList or {}) do + + local groupEntity = class.New() -- 生成组(二级标签)按钮用实体 + groupEntity:UpdateData(drawGroupInfo) + + if not self.DrawTabDic[groupEntity:GetTag()] then + self.DrawTabDic[groupEntity:GetTag()] = XDrawTabBtnEntity.New(groupEntity:GetTag()) -- 生成类(一级标签)按钮用实体 + table.insert(self.DrawTabList, self.DrawTabDic[groupEntity:GetTag()]) + end + + self.DrawTabDic[groupEntity:GetTag()]:InsertDrawGroupList(groupEntity) + end +end + +function XUiNewDrawMain:SortDrawTabData() + table.sort(self.DrawTabList,function (a,b) + return a:GetPriority() < b:GetPriority() + end) +end + +--- +--- 初始化按钮组,选择默认标签 +function XUiNewDrawMain:InitButtonGroup() + self:BtnInit(self.MainBtnList) + self:BtnInit(self.SubBtnList) + + for _,drawTab in pairs(self.DrawTabList or {}) do + local subgroupIndex = self:CreateMainBtn(drawTab) + for _,drawGroupInfo in pairs(drawTab:GetDrawGroupList() or {}) do + self:CreateSubBtn(subgroupIndex, drawGroupInfo) + end + end + + local curBtnIndex = 0 + local tmpGroupId = 0 + + if self.DefaultGroupId then + tmpGroupId = self.DefaultGroupId + curBtnIndex = self:GetBtnIndexByGroupId(self.RuleType, tmpGroupId) + self.DefaultGroupId = nil + else + tmpGroupId = XDataCenter.DrawManager.GetLostSelectDrawGroupId() + local tmptype = XDataCenter.DrawManager.GetLostSelectDrawType() + curBtnIndex = self:GetBtnIndexByGroupId(tmptype, tmpGroupId) + if not curBtnIndex and self.IsFirstIn then + curBtnIndex = 1 + end + end + + if curBtnIndex then + local tagEntity = self.AllDataList[curBtnIndex] + if tagEntity and not tagEntity:IsMainButton() then + -- 如果tagEntity为二级标签,则获取它所属的一级标签,然后判断是否可以打开 + local mainTagEntity = self.DrawTabDic[tagEntity:GetTag()] + local isOpen = mainTagEntity:JudgeCanOpen(true) + if not isOpen then + curBtnIndex = 1 + end + end + else + XUiManager.TipText("NewDrawSkipNotInTime") + curBtnIndex = 1 + end + + self.IsFirstIn = false + self.PanelNoticeTitleBtnGroup:Init(self.AllBtnList, function(index) self:OnSelectedTog(index) end) + self.PanelNoticeTitleBtnGroup:SelectIndex(self.AllBtnList[curBtnIndex] and curBtnIndex or 1) +end + +function XUiNewDrawMain:BtnInit(BtnList) + for _,btn in pairs(BtnList or {}) do + btn.gameObject:SetActiveEx(false) + btn:SetButtonState(CS.UiButtonState.Normal) + btn.TempState = CS.UiButtonState.Normal + btn.IsFold = false --初始化时需要把按钮的状态已打开设置为false + end +end + +function XUiNewDrawMain:GetBtnIndexByGroupId(ruleType, groupId) + local curBtnIndex = self.SkipIndexDic and + self.SkipIndexDic[ruleType] and + self.SkipIndexDic[ruleType][groupId] + return curBtnIndex +end + +--- +--- 一级标签的按钮状态为Disable时传入的index为它自己的index,否则为它的第一个子标签的index +--- +--- 只有一级标签类才会判断是否能打开卡池 +function XUiNewDrawMain:OnSelectedTog(index) + if self.AllDataList[index] then + local IsTypeTab = self.AllDataList[index]:GetRuleType() == XDrawConfigs.RuleType.Tab + self.RuleType = not IsTypeTab and + self.AllDataList[index]:GetRuleType() or self.RuleType + if not IsTypeTab then + XDataCenter.DrawManager.SetLostSelectDrawGroupId(self.AllDataList[index]:GetId()) + XDataCenter.DrawManager.SetLostSelectDrawType(self.RuleType) + end + if self.AllDataList[index]:DoSelect(self) then + self.CurSelectId = index + self.AssetActivityPanel:Refresh(self.AllDataList[index]:GetUseItemIdList()) + end + end +end + +--- +--- 初始化一级标签按钮物体 +function XUiNewDrawMain:CreateMainBtn(data) + local uiButton = self.MainBtnList[self.MainBtnCount] + if not uiButton then + local obj = CS.UnityEngine.Object.Instantiate(self.BtnFirst) + uiButton = obj:GetComponent("XUiButton") + self.MainBtnList[self.MainBtnCount] = uiButton + end + if uiButton then + uiButton.gameObject:SetActiveEx(true) + uiButton.transform:SetParent(self.transform, false) + uiButton.transform:SetParent(self.PanelNoticeTitleBtnGroup.transform, false) + local IsUnLock = data:JudgeCanOpen(false) + uiButton:SetDisable(not IsUnLock) + uiButton:SetNameByGroup(0, IsUnLock and (string.format("0%d",data:GetTxtName1())) or "") + uiButton:SetNameByGroup(1, data:GetTxtName2()) + uiButton:SetNameByGroup(2, data:GetTxtName3()) + uiButton:SetRawImage(data:GetTabBg()) + uiButton:ShowTag(data:IsShowTag()) + + table.insert(self.AllBtnList, uiButton) + table.insert(self.AllDataList, data) + end + local subGroupIndex = self.BtnIndex + self.BtnIndex = self.BtnIndex + 1 + self.MainBtnCount = self.MainBtnCount + 1 + return subGroupIndex +end + +--- +--- 初始化二级标签按钮物体 +function XUiNewDrawMain:CreateSubBtn(subGroupIndex,data) + local uiButton = self.SubBtnList[self.SubBtnCount] + if not uiButton then + local obj = CS.UnityEngine.Object.Instantiate(self.BtnChild) + uiButton = obj:GetComponent("XUiButton") + self.SubBtnList[self.SubBtnCount] = uiButton + end + if uiButton then + uiButton.gameObject:SetActiveEx(true) + uiButton.transform:SetParent(self.transform, false) + uiButton.transform:SetParent(self.PanelNoticeTitleBtnGroup.transform, false) + local uiObject = uiButton.transform:GetComponent("UiObject") + uiButton:SetName(data:GetName()) + uiButton:SetRawImage(data:GetGroupBtnBg()) + uiButton.SubGroupIndex = subGroupIndex + uiObject:GetObject("A").gameObject:SetActiveEx(data:GetRareRank() == XDrawConfigs.RareRank.A) + uiObject:GetObject("S").gameObject:SetActiveEx(data:GetRareRank() == XDrawConfigs.RareRank.S) + + self.SkipIndexDic[data:GetRuleType()] = self.SkipIndexDic[data:GetRuleType()] or {} + self.SkipIndexDic[data:GetRuleType()][data:GetId()] = self.BtnIndex + + uiButton:ShowTag(data:IsShowTag()) + + table.insert(self.AllBtnList, uiButton) + table.insert(self.AllDataList, data) + end + self.BtnIndex = self.BtnIndex + 1 + self.SubBtnCount = self.SubBtnCount + 1 +end + +function XUiNewDrawMain:CreateBanner(data) + local prefab = self.PanelBanner:LoadPrefab(data:GetBanner()) + self.CurBanner = XUiNewGridDrawBanner.New(prefab, data, self) + self.CurBanner.GameObject.name = data:GetId() +end + +function XUiNewDrawMain:GetRelationGroupData(id) + local groupRelationDic = XDrawConfigs.GetDrawGroupRelationDic() + local relationGroupId = groupRelationDic[id] + if relationGroupId then + for _,data in pairs(self.AllDataList or {}) do + if data:GetId() == relationGroupId then + return data + end + end + end + return +end + +function XUiNewDrawMain:MarkCurNewTag() + if self.CurSelectId then + self:DoMark(self.CurSelectId) + else + XLog.Error("XUiNewDrawMain:MarkCurNewTag函数错误,self.CurSelectId为nil") + end +end + +function XUiNewDrawMain:MarkAllNewTag() + for index = 1, self.BtnIndex do + self:DoMark(index) + end +end + +function XUiNewDrawMain:DoMark(index) + if self.AllDataList[index] and self.AllBtnList[index] then + if self.AllBtnList[index].SubGroupIndex > 0 and self.AllDataList[index]:GetBannerBeginTime() > 0 then + XDataCenter.DrawManager.MarkNewTag(self.AllDataList[index]:GetBannerBeginTime(), + self.AllDataList[index]:GetRuleType(), + self.AllDataList[index]:GetId()) + + self.AllBtnList[index]:ShowTag(false) + end + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDraw/XUiNewGridDrawBanner.lua b/Resources/Scripts/XUi/XUiDraw/XUiNewGridDrawBanner.lua new file mode 100644 index 00000000..08e305ba --- /dev/null +++ b/Resources/Scripts/XUi/XUiDraw/XUiNewGridDrawBanner.lua @@ -0,0 +1,172 @@ +local XUiNewGridDrawBanner = XClass(nil, "XUiNewGridDrawBanner") + +function XUiNewGridDrawBanner:Ctor(ui, data, base) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.Data = data + self.Base = base + + self.BtnSkipList = {} + + self:TryGetComponent() + self:SetButtonCallBack() + self:SetUpBottomTimes() + self:SetUpRewardPreview() + self:SetBannerTime() + self:SetSwitchInfo() + self:SetNewHandTag() +end + +function XUiNewGridDrawBanner:TryGetComponent() + if self.BtnGo then + self.BtnGo = self.BtnGo.transform:GetComponent("XUiButton") + end + if self.MingyunSelectChoukacounts then + self.MingyunSelectChoukacounts = self.MingyunSelectChoukacounts.transform:GetComponent("Text") + end + if self.MingyunNomalChoukacounts then + self.MingyunNomalChoukacounts = self.MingyunNomalChoukacounts.transform:GetComponent("Text") + end + if self.PutongSelectChoukacounts then + self.PutongSelectChoukacounts = self.PutongSelectChoukacounts.transform:GetComponent("Text") + end + if self.PutongNormalChoukacounts then + self.PutongNormalChoukacounts = self.PutongNormalChoukacounts.transform:GetComponent("Text") + end + if self.PifuChoukaCounts then + self.PifuChoukaCounts = self.PifuChoukaCounts.transform:GetComponent("Text") + end + if self.TimeTxt then + self.TimeTxt = self.TimeTxt.transform:GetComponent("Text") + end + if self.TxtSwitch then + self.TxtSwitch = self.TxtSwitch.transform:GetComponent("Text") + end + + -- 隐藏所有的跳转按钮 + local index = 1 + while true do + local btnSkip = self[string.format("BtnSkip%s", tostring(index))] + if not btnSkip then + break + end + btnSkip = btnSkip.transform:GetComponent("Button") + btnSkip.gameObject:SetActiveEx(false) + self.BtnSkipList[index] = btnSkip + index = index + 1 + end +end + +function XUiNewGridDrawBanner:SetButtonCallBack() + if self.BtnGo then + self.BtnGo.CallBack = function() + self:OnBtnGoClick() + end + end + + -- 添加跳转逻辑并显示跳转按钮 + local skipList = XDrawConfigs.GetDrawSkipList(self.Data.Id) + if skipList and next(skipList) then + for i = 1, #skipList do + if not self.BtnSkipList[i] then + XLog.Warning(string.format("XUiNewGridDrawBanner:TryGetComponent()函数警告,DrawGroupId:%s 预制界面的跳转按钮不足,第%s个跳转:%s 与后面配置的跳转无法生效", + tostring(self.Data.Id), tostring(i), tostring(skipList[i]))) + break + end + + self.BtnSkipList[i].CallBack = function() + XFunctionManager.SkipInterface(skipList[i]) + end + self.BtnSkipList[i].gameObject:SetActiveEx(true) + end + end +end + +function XUiNewGridDrawBanner:OnBtnGoClick() + self.Data:GoDraw(function () + self.Base:MarkCurNewTag() + end) +end + +function XUiNewGridDrawBanner:SetUpBottomTimes() + if self.MingyunSelectChoukacounts then + self.MingyunSelectChoukacounts.text = self:GetBottomText(XDrawConfigs.GroupType.Destiny) + end + + if self.MingyunNomalChoukacounts then + self.MingyunNomalChoukacounts.text = self:GetBottomText(XDrawConfigs.GroupType.Destiny) + end + + if self.PutongSelectChoukacounts then + self.PutongSelectChoukacounts.text = self:GetBottomText(XDrawConfigs.GroupType.Normal) + end + + if self.PutongNormalChoukacounts then + self.PutongNormalChoukacounts.text = self:GetBottomText(XDrawConfigs.GroupType.Normal) + end + + if self.PifuChoukaCounts then + self.PifuChoukaCounts.text = self.Data:GetBottomText() + end +end + +function XUiNewGridDrawBanner:GetBottomText(type) + local relationGroupData = self.Base:GetRelationGroupData(self.Data:GetId()) + local bottomText = "———" + local count = 0 + if relationGroupData and relationGroupData:GetGroupType() == type then + bottomText = relationGroupData:GetBottomText() + count = count + 1 + end + if self.Data:GetGroupType() == type then + bottomText = self.Data:GetBottomText() + count = count + 1 + end + if count == 2 then + XLog.Error("Client/Draw/DrawGroupRelation.tab's Data Is Error: NormalGroupId and DestinyGroupId Is Same Type") + end + return bottomText +end + +function XUiNewGridDrawBanner:SetUpRewardPreview() + if self.Grid256 then + local grid = XUiGridCommon.New(self.Base, self.Grid256) + local rewardData = self.Data:GetTopRewardData() + grid:Refresh(rewardData:GetTemplateId()) + if self.ImgGet then + self.ImgGet.gameObject:SetActiveEx(rewardData:GetIsGeted()) + end + end +end + +function XUiNewGridDrawBanner:SetBannerTime() + local beginTime = self.Data:GetBannerBeginTime() or 0 + local endTime = self.Data:GetBannerEndTime() or 0 + if self.TimeTxt then + self.TimeTxt.gameObject:SetActiveEx(beginTime ~= 0 and endTime ~= 0) + local beginTimeStr = XTime.TimestampToGameDateTimeString(beginTime, "MM/dd") + local endTimeStr = XTime.TimestampToGameDateTimeString(endTime, "MM/dd HH:mm") + self.TimeTxt.text = string.format("%s-%s", beginTimeStr, endTimeStr) + end + if self.TimeDetail then + self.TimeDetail.gameObject:SetActiveEx(beginTime ~= 0 and endTime ~= 0) + end +end + +function XUiNewGridDrawBanner:SetNewHandTag() + if self.PanelNewHand then + self.PanelNewHand.gameObject:SetActiveEx(self.Data:GetMaxBottomTimes() == self.Data:GetNewHandBottomCount()) + end + if self.PanelNewHandTop then + self.PanelNewHandTop.gameObject:SetActiveEx(self.Data:GetMaxBottomTimes() == self.Data:GetNewHandBottomCount()) + end +end + +function XUiNewGridDrawBanner:SetSwitchInfo() + if self.TxtSwitch then + self.TxtSwitch.text = self.Data:GetSwitchText() + end +end + +return XUiNewGridDrawBanner \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDraw/XUiPanelCombination.lua b/Resources/Scripts/XUi/XUiDraw/XUiPanelCombination.lua new file mode 100644 index 00000000..32e9f644 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDraw/XUiPanelCombination.lua @@ -0,0 +1,220 @@ +local XUiPanelCombination = XClass(nil, "XUiPanelCombination") +local XUiGridSuitDetail = require("XUi/XUiEquipAwarenessReplace/XUiGridSuitDetail") +local CSTextManagerGetText = CS.XTextManager.GetText +function XUiPanelCombination:Ctor(ui, parent, index) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:AutoAddListener() + self.Parent = parent + self.Index = index + self.TxtCombination.text = CS.XTextManager.GetText("DrawCombination", index) +end + +function XUiPanelCombination:SetData(drawId, IsDefaultDraw, IsCanSwitch) + local clickCb = function(data, grid) + self.Parent:OnSuitGridClick(data, grid) + end + + if self.DrawId ~= drawId then + self.DrawId = drawId + local combination = XDataCenter.DrawManager.GetDrawCombination(drawId) + if not combination then return end + local goodsList = combination.GoodsId or {} + self.Type = #goodsList > 0 and XArrangeConfigs.GetType(goodsList[1]) or XArrangeConfigs.Types.Error + + local list = combination.GoodsId + if not self.Compositions then + self.Compositions = {} + end + + if self.Type == XArrangeConfigs.Types.Character then + self:SetCharacterData(combination) + elseif self.Type == XArrangeConfigs.Types.Partner then + self:SetPartnerData(combination, list) + elseif self.Type ~= XArrangeConfigs.Types.Error then + self:SetEquipData(combination, list, clickCb) + else + self:SetBaseData() + end + end + + self:SetSelectState(false) + self:SetPanelSwitch(IsDefaultDraw, IsCanSwitch) + self:SetActiveEx(true) + + local drawAimProbability = XDrawConfigs.GetDrawAimProbability() + local drawInfo = XDataCenter.DrawManager.GetDrawInfo(self.DrawId) + local nowTime = XTime.GetServerNowTimestamp() + + if self.TxtTitle then + if drawInfo.EndTime - nowTime > 0 then + self.TxtTitle.text = CSTextManagerGetText("DrawAimLeftTime", XUiHelper.GetTime(drawInfo.EndTime - nowTime, XUiHelper.TimeFormatType.ACTIVITY)) + else + self.TxtTitle.text = CSTextManagerGetText("DrawAimLeftTimeOver") + end + self.TxtTitle.gameObject:SetActiveEx(drawInfo.EndTime > 0) + end + + self.UpTip.gameObject:SetActiveEx(drawInfo.EndTime > 0) + + if self.TxtCount then + self.TxtCount.gameObject:SetActiveEx(false) + if drawAimProbability[self.DrawId] then + self.TxtCount.text = drawAimProbability[self.DrawId].UpProbability or "" + self.TxtCount.gameObject:SetActiveEx(drawAimProbability[self.DrawId].UpProbability ~= nil) + end + end + + self.Probability.gameObject:SetActiveEx(true) +end + +function XUiPanelCombination:SetEquipData(combination, list, clickCb) + self.PanelComposition.gameObject:SetActiveEx(false) + self.PanelSuitCommon.gameObject:SetActiveEx(false) + + for _, v in pairs(self.Compositions) do + CS.UnityEngine.Object.Destroy(v.GameObject) + end + self.Compositions = {} + for i = 1, #list do + if not self.Compositions[i] then + local go + if combination.Type == XDrawConfigs.CombinationsTypes.Aim then + go = CS.UnityEngine.Object.Instantiate(self.PanelComposition, self.PanelNormal) + local item = XUiGridCommon.New(self.Parent, go) + item.GameObject:SetActiveEx(true) + table.insert(self.Compositions, item) + elseif combination.Type == XDrawConfigs.CombinationsTypes.EquipSuit then + go = CS.UnityEngine.Object.Instantiate(self.PanelSuitCommon, self.PanelSuit) + local item = XUiGridSuitDetail.New(go, self.Parent, clickCb) + item.GameObject:SetActiveEx(true) + table.insert(self.Compositions, item) + end + end + self.Compositions[i]:Refresh(list[i], nil, true) + end + + if self.InfectTip then + local IsIsomer = false + for _,composition in pairs(self.Compositions) do + local templateData = XEquipConfig.GetEquipCfg(composition.TemplateId) + if templateData.CharacterType == XEquipConfig.UserType.Isomer then + IsIsomer = true + break + end + end + + self.InfectTip.gameObject:SetActiveEx(IsIsomer) + end +end + +function XUiPanelCombination:SetPartnerData(combination, list) + self.PanelComposition.gameObject:SetActiveEx(false) + + for _, v in pairs(self.Compositions) do + CS.UnityEngine.Object.Destroy(v.GameObject) + end + + self.Compositions = {} + for i = 1, #list do + if not self.Compositions[i] then + local go + if combination.Type == XDrawConfigs.CombinationsTypes.Aim then + go = CS.UnityEngine.Object.Instantiate(self.PanelComposition, self.PanelNormal) + local item = XUiGridCommon.New(self.Parent, go) + item.GameObject:SetActiveEx(true) + table.insert(self.Compositions, item) + end + end + self.Compositions[i]:Refresh(list[i], nil, true) + end +end + +function XUiPanelCombination:SetCharacterData(combination) + local goodsShowParams = XGoodsCommonManager.GetGoodsShowParamsByTemplateId(combination.GoodsId[1]) + local quality = XCharacterConfigs.GetCharMinQuality(combination.GoodsId[1]) + + self.CharId = combination.GoodsId[1] + self.AimImgBottomIco:SetRawImage(goodsShowParams.Icon) + self.AimImgBottomRank:SetRawImage(XCharacterConfigs.GetCharQualityIcon(quality)) + + if goodsShowParams.Quality then + local qualityIcon = goodsShowParams.QualityIcon + + if qualityIcon then + self.Parent:SetUiSprite(self.AimImgQuality, qualityIcon) + else + XUiHelper.SetQualityIcon(self.Parent, self.AimImgQuality, goodsShowParams.Quality) + end + end +end + +function XUiPanelCombination:SetBaseData() + --self.Probability.gameObject:SetActiveEx(false) + --local drawInfo = XDataCenter.DrawManager.GetDrawInfo(self.DrawId) + --self.TxtCount.text = string.format("%d/%d",drawInfo.BottomTimes,drawInfo.MaxBottomTimes) +end + +function XUiPanelCombination:SetPanelSwitch(IsDefaultDraw, IsCanSwitch) + if not IsDefaultDraw and not IsCanSwitch then + if self.BtnSelect then + self.BtnSelect.gameObject:SetActiveEx(false) + end + if self.TxtSelected then + self.TxtSelected.gameObject:SetActiveEx(false) + end + if self.PanelCanNotSelect then + self.PanelCanNotSelect.gameObject:SetActiveEx(true) + end + else + if self.PanelCanNotSelect then + self.PanelCanNotSelect.gameObject:SetActiveEx(false) + end + end +end + +function XUiPanelCombination:SetSelectState(bool) + + self.BtnSelect.gameObject:SetActiveEx(not bool) + self.TxtSelected.gameObject:SetActiveEx(bool) + + if self.Type == XArrangeConfigs.Types.Character then + self.Up.gameObject:SetActiveEx(bool) + elseif self.Type ~= XArrangeConfigs.Types.Error then + if not self.Compositions then + return + end + for _, v in pairs(self.Compositions) do + v:SetShowUp(bool) + end + end +end + +function XUiPanelCombination:SetActiveEx(bool) + self.GameObject:SetActiveEx(bool) +end + +function XUiPanelCombination:AutoAddListener() + self.BtnSelect.CallBack = function() self:OnBtnSelectClick() end + + if self.BtnClick then + self.BtnClick.CallBack = function() + self:OnBtnClickClick() + end + end +end +-- auto +function XUiPanelCombination:OnBtnSelectClick() + self.Parent:SelectCombination(self.Index, self.DrawId) + --CS.XUiManager.ViewManager:Pop() +end + +function XUiPanelCombination:OnBtnClickClick() + if self.Type == XArrangeConfigs.Types.Character then + XDataCenter.AutoWindowManager.StopAutoWindow() + XLuaUiManager.Open("UiCharacterDetail", self.CharId) + end +end + +return XUiPanelCombination \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDraw/XUiPanelProbability.lua b/Resources/Scripts/XUi/XUiDraw/XUiPanelProbability.lua new file mode 100644 index 00000000..314f06df --- /dev/null +++ b/Resources/Scripts/XUi/XUiDraw/XUiPanelProbability.lua @@ -0,0 +1,84 @@ +local XUiPanelProbability = XClass(nil, "XUiPanelProbability") + +function XUiPanelProbability:Ctor(ui, parent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self:InitAutoScript() + self.Parent = parent +end + +function XUiPanelProbability:SetData(data) + if not data or self.Data == data then + return + end + self.Data = data + self:SetIsUp(data.IsUp) + self.TxtName.text = data.Name + self.TxtType.text = data.Type + if data.IsUp then + self.TxtUpProb.text = data.ProbShow + else + self.TxtNorProb.text = data.ProbShow + end + self:SetActive(true) +end + +function XUiPanelProbability:SetIsUp(bool) + self.TxtUp.gameObject:SetActive(bool) + self.TxtUpProb.gameObject:SetActive(bool) + self.TxtNorProb.gameObject:SetActive(not bool) +end + +function XUiPanelProbability:SetActive(bool) + self.GameObject:SetActive(bool) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelProbability:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiPanelProbability:AutoInitUi() + self.TxtType = self.Transform:Find("TxtType"):GetComponent("Text") + self.TxtName = self.Transform:Find("TxtName"):GetComponent("Text") + self.TxtUpProb = self.Transform:Find("TxtUpProb"):GetComponent("Text") + self.TxtNorProb = self.Transform:Find("TxtNorProb"):GetComponent("Text") + self.TxtUp = self.Transform:Find("TxtUp"):GetComponent("Text") +end + +function XUiPanelProbability:GetAutoKey(uiNode, eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiPanelProbability:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiPanelProbability:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiPanelProbability:AutoAddListener() + self.AutoCreateListeners = {} +end +-- auto +return XUiPanelProbability \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDraw/XUiTogDrawGroup.lua b/Resources/Scripts/XUi/XUiDraw/XUiTogDrawGroup.lua new file mode 100644 index 00000000..328112b4 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDraw/XUiTogDrawGroup.lua @@ -0,0 +1,44 @@ +local XUiTogDrawGroup = XClass(nil, "XUiTogDrawGroup") + +function XUiTogDrawGroup:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self:InitAutoScript() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiTogDrawGroup:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiTogDrawGroup:AutoInitUi() + self.TogDrawGroup = self.Transform:GetComponent("Toggle") + self.TxtTabName = self.Transform:Find("TxtTabName"):GetComponent("Text") + self.PanelTag = self.Transform:Find("PanelTag") + self.TxtTagName = self.Transform:Find("PanelTag/TxtTagName"):GetComponent("Text") +end + +function XUiTogDrawGroup:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiTogDrawGroup:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiTogDrawGroup:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiTogDrawGroup:AutoAddListener() + -- self:RegisterClickEvent(self.TogDrawGroup, self.OnTogDrawGroupClick) +end +-- auto +return XUiTogDrawGroup \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiDraw/XUiTogDrawGroupTab.lua b/Resources/Scripts/XUi/XUiDraw/XUiTogDrawGroupTab.lua new file mode 100644 index 00000000..c8d66754 --- /dev/null +++ b/Resources/Scripts/XUi/XUiDraw/XUiTogDrawGroupTab.lua @@ -0,0 +1,61 @@ +local XUiTogDrawGroupTab = XClass(nil, "XUiTogDrawGroupTab") + +function XUiTogDrawGroupTab:Ctor(ui, rootUi, info) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self.Info = info + self:InitAutoScript() + self:RefreshView() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiTogDrawGroupTab:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiTogDrawGroupTab:AutoInitUi() + self.TogDrawGroupTab = self.Transform:GetComponent("Toggle") + self.TxtTabName = self.Transform:Find("TxtTabName"):GetComponent("Text") + self.PanelTag = self.Transform:Find("PanelTag") + self.TxtTagName = self.Transform:Find("PanelTag/TxtTagName"):GetComponent("Text") +end + +function XUiTogDrawGroupTab:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiTogDrawGroupTab:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiTogDrawGroupTab:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiTogDrawGroupTab:AutoAddListener() + self:RegisterClickEvent(self.TogDrawGroupTab, self.OnTogDrawGroupTabClick) +end +-- auto +function XUiTogDrawGroupTab:OnTogDrawGroupTabClick() + self.RootUi:UpdateCards(self.Info) +end + +function XUiTogDrawGroupTab:RefreshView() + self.TxtTabName.text = self.Info.TxtName + if (self.Info.TxtTagName) then + self.PanelTag.gameObject:SetActive(true) + self.TxtTagName.text = self.Info.TxtTagName + else + self.PanelTag.gameObject:SetActive(false) + end +end + +return XUiTogDrawGroupTab \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiEnterFight/XUiEnterFight.lua b/Resources/Scripts/XUi/XUiEnterFight/XUiEnterFight.lua new file mode 100644 index 00000000..e4565061 --- /dev/null +++ b/Resources/Scripts/XUi/XUiEnterFight/XUiEnterFight.lua @@ -0,0 +1,164 @@ +local XUiEnterFight = XLuaUiManager.Register(XLuaUi, "UiEnterFight") + +function XUiEnterFight:OnStart(type, name, dis, icon, rewardId, cb, stageId, areaId) + self.Callback = cb + self.RewardId = rewardId + self.Items = {} + self.StageId = stageId + self.AreaId = areaId + + self:InitAutoScript() + if type == XFubenExploreConfigs.NodeTypeEnum.Story then + self:OnShowStoryDialog(name, dis, icon) + elseif type == XFubenExploreConfigs.NodeTypeEnum.Stage then + self:OnShowFightDialog(name, dis, icon) + elseif type == XFubenExploreConfigs.NodeTypeEnum.Arena then + self:OnShowArenaDialog() + end + self:UpdateReward() +end + +function XUiEnterFight:OnGetEvents() + return { XEventId.EVENT_ARENA_RESULT_AUTOFIGHT } +end + +function XUiEnterFight:OnNotify(evt) + if evt == XEventId.EVENT_ARENA_RESULT_AUTOFIGHT then + self:OnShowArenaDialog() + end +end + +function XUiEnterFight:InitAutoScript() + self:AutoAddListener() +end + +function XUiEnterFight:AutoAddListener() + self:RegisterClickEvent(self.BtnMaskB, self.OnBtnMaskBClick) + self:RegisterClickEvent(self.BtnEnterStory, self.OnBtnEnterStoryClick) + self:RegisterClickEvent(self.BtnEnterFight, self.OnBtnEnterFightClick) + self:RegisterClickEvent(self.BtnEnterArena, self.OnBtnEnterArenaClick) + self.BtnCannotAutoFight.CallBack = function() + self:OnBtnCannotAutoFightClick() + end + + self.BtnAutoFight.CallBack = function() + self:OnBtnAutoFightClick() + end +end + +function XUiEnterFight:OnBtnMaskBClick() + self:Close() +end + +function XUiEnterFight:OnBtnEnterStoryClick() + self:Close() + self:OnCallback() +end + +function XUiEnterFight:OnBtnEnterFightClick() + self:Close() + self:OnCallback() +end + +function XUiEnterFight:OnBtnEnterArenaClick() + self:Close() + self:OnCallback() +end + +function XUiEnterFight:OnBtnCannotAutoFightClick() + --1.没有满分通关过 + if not XDataCenter.ArenaManager.IsCanAutoFightByStageId(self.StageId) then + XUiManager.TipText("ArenaCannotAutoFight") + return + end + --2.满分通关过,但是现在已经满分了 + local score = XDataCenter.ArenaManager.GetArenaStageScore(self.AreaId, self.StageId) + local config = XArenaConfigs.GetArenaStageConfig(self.StageId) + local maxPoint = XArenaConfigs.GetMarkMaxPointById(config.MarkId) + if score == maxPoint then + XUiManager.TipText("ArenaMarkAlreadyMax") + return + end +end + +function XUiEnterFight:OnBtnAutoFightClick() + XDataCenter.ArenaManager.RequestAutoFight(self.AreaId, self.StageId) +end + +function XUiEnterFight:OnShowStoryDialog(name, dis, icon) + self.PanelStory.gameObject:SetActiveEx(true) + self.PanelFight.gameObject:SetActiveEx(false) + self.PanelArena.gameObject:SetActiveEx(false) + + self.TxtStoryName.text = name + self.TxtStoryDec.text = dis + self.RImgStory:SetRawImage(icon) +end + +function XUiEnterFight:OnShowFightDialog(name, dis, icon) + self.PanelFight.gameObject:SetActiveEx(true) + self.PanelStory.gameObject:SetActiveEx(false) + self.PanelArena.gameObject:SetActiveEx(false) + + self.TxtFightName.text = name + self.TxtFightDec.text = string.gsub(dis, "\\n", "\n") + self.RImgFight:SetRawImage(icon) +end + +function XUiEnterFight:OnShowArenaDialog() + self.PanelFight.gameObject:SetActiveEx(false) + self.PanelStory.gameObject:SetActiveEx(false) + self.PanelReward.gameObject:SetActiveEx(false) + self.ImgGqdl.gameObject:SetActiveEx(false) + self.PanelArena.gameObject:SetActiveEx(true) + + local score = XDataCenter.ArenaManager.GetArenaStageScore(self.AreaId, self.StageId) + local config = XArenaConfigs.GetArenaStageConfig(self.StageId) + local areaStageConfig = XArenaConfigs.GetArenaAreaStageCfgByAreaId(self.AreaId) + if score > 0 then + self.TxtArenaScore.text = CS.XTextManager.GetText("ArenaHighDesc", score) + else + self.TxtArenaScore.text = score + end + + if areaStageConfig.AutoFight[config.MarkId] == nil or areaStageConfig.AutoFight[config.MarkId] == 0 then + self.BtnAutoFight.gameObject:SetActiveEx(false) + self.BtnCannotAutoFight.gameObject:SetActiveEx(false) + else + local maxPoint = XArenaConfigs.GetMarkMaxPointById(config.MarkId) + local isCurrentMaxMark = score == maxPoint + if XDataCenter.ArenaManager.IsCanAutoFightByStageId(self.StageId) and not isCurrentMaxMark then + self.BtnAutoFight.gameObject:SetActiveEx(true) + self.BtnCannotAutoFight.gameObject:SetActiveEx(false) + else + self.BtnAutoFight.gameObject:SetActiveEx(false) + self.BtnCannotAutoFight.gameObject:SetActiveEx(true) + end + end + + self.RImgArena:SetRawImage(config.BgIconBig) + self.ImgArenaDifficulty:SetRawImage(config.DifficuIocn) + self.TxtArenatName.text = config.Name +end + +function XUiEnterFight:UpdateReward() + self.Grid128.gameObject:SetActiveEx(false) + if self.RewardId and self.RewardId > 0 then + self.ImgGqdl.gameObject:SetActiveEx(true) + self.PanelReward.gameObject:SetActiveEx(true) + local data = XRewardManager.GetRewardList(self.RewardId) + data = XRewardManager.MergeAndSortRewardGoodsList(data) + XUiHelper.CreateTemplates(self, self.Items, data, XUiGridCommon.New, self.Grid128, self.PanelReward, function(grid, gridData) + grid:Refresh(gridData) + end) + else + self.PanelReward.gameObject:SetActiveEx(false) + self.ImgGqdl.gameObject:SetActiveEx(false) + end +end + +function XUiEnterFight:OnCallback() + if self.Callback then + self.Callback() + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiEquipAwarenessReplace/XUiEquipAwarenessPopup.lua b/Resources/Scripts/XUi/XUiEquipAwarenessReplace/XUiEquipAwarenessPopup.lua new file mode 100644 index 00000000..4562c11d --- /dev/null +++ b/Resources/Scripts/XUi/XUiEquipAwarenessReplace/XUiEquipAwarenessPopup.lua @@ -0,0 +1,363 @@ +local XUiGridEquip = require("XUi/XUiEquipAwarenessReplace/XUiGridEquip") + +local CSXTextManagerGetText = CS.XTextManager.GetText + +local MAX_AWARENESS_ATTR_COUNT = 2 + +local SKILL_DES_COLOR = { + [true] = XUiHelper.Hexcolor2Color("188649ff"), + [false] = XUiHelper.Hexcolor2Color("00000099"), +} + +local ATTR_COLOR = { + BELOW = XUiHelper.Hexcolor2Color("d11e38ff"), + EQUAL = XUiHelper.Hexcolor2Color("000000ff"), + OVER = XUiHelper.Hexcolor2Color("188649ff"), +} + +local CUR_EQUIP_CLICK_POPUP_POS = { + [XEquipConfig.EquipSite.Awareness.One] = CS.UnityEngine.Vector2(-230, 14), + [XEquipConfig.EquipSite.Awareness.Two] = CS.UnityEngine.Vector2(-681, 14), + [XEquipConfig.EquipSite.Awareness.Three] = CS.UnityEngine.Vector2(-681, 14), + [XEquipConfig.EquipSite.Awareness.Four] = CS.UnityEngine.Vector2(-230, 14), + [XEquipConfig.EquipSite.Awareness.Five] = CS.UnityEngine.Vector2(-681, 14), + [XEquipConfig.EquipSite.Awareness.Six] = CS.UnityEngine.Vector2(-681, 14), +} + +local XUiEquipAwarenessPopup = XLuaUiManager.Register(XLuaUi, "UiEquipAwarenessPopup") + +function XUiEquipAwarenessPopup:OnAwake() + self:AutoAddListener() +end + +function XUiEquipAwarenessPopup:OnStart(rootUi, HideStrengthenBtn, equipId, charaterId, hideAllBtns) + self.RootUi = rootUi --子窗口在隐藏/显示时无法再次调到onstart + self.InitEquipId = equipId + self.InitCharacterId = charaterId + self.HideStrengthenBtn = HideStrengthenBtn + self.HideAllBtns = hideAllBtns + self.PanelSelectRectTransform = self.PanelSelect:GetComponent("RectTransform") +end + +function XUiEquipAwarenessPopup:OnEnable() + self.EquipId = self.InitEquipId or self.RootUi.SelectEquipId + self.CharacterId = self.InitCharacterId or self.RootUi.CharacterId + + self:Refresh() + if self.RootUi.BtnClosePopup then + self.RootUi.BtnClosePopup.gameObject:SetActiveEx(true) + end +end + +function XUiEquipAwarenessPopup:OnDisable() + if self.RootUi.BtnClosePopup then + self.RootUi.BtnClosePopup.gameObject:SetActiveEx(false) + end +end + +function XUiEquipAwarenessPopup:Refresh() + local equipSite = XDataCenter.EquipManager.GetEquipSite(self.EquipId) + self.UsingEquipId = XDataCenter.EquipManager.GetWearingEquipIdBySite(self.CharacterId, equipSite) + self.UsingAttrMap = XDataCenter.EquipManager.GetEquipAttrMap(self.UsingEquipId) + + self:UpdateSelectPanel() + self:UpdateUsingPanel() + self:UpdateUsingPanelBtn() + self:UpdateLockStatues(self.EquipId) + self:UpdateLockStatues(self.UsingEquipId) + self:UpdateRecycleStatues(self.EquipId) + self:UpdateRecycleStatues(self.UsingEquipId) +end + +function XUiEquipAwarenessPopup:OnGetEvents() + return { + XEventId.EVENT_EQUIP_PUTON_NOTYFY + , XEventId.EVENT_EQUIPLIST_TAKEOFF_NOTYFY + , XEventId.EVENT_EQUIP_LOCK_STATUS_CHANGE_NOTYFY + , XEventId.EVENT_EQUIP_RECYCLE_STATUS_CHANGE_NOTYFY + , XEventId.EVENT_EQUIP_RECYCLE_NOTIFY + } +end + +function XUiEquipAwarenessPopup:OnNotify(evt, ...) + local args = { ... } + + if evt == XEventId.EVENT_EQUIP_PUTON_NOTYFY then + local equipId = args[1] + if equipId == self.EquipId then + self:Close() + end + elseif evt == XEventId.EVENT_EQUIPLIST_TAKEOFF_NOTYFY + or evt == XEventId.EVENT_EQUIP_RECYCLE_NOTIFY then + local equipIds = args[1] + for _, equipId in pairs(equipIds) do + if equipId == self.EquipId then + self:Close() + return + end + end + elseif evt == XEventId.EVENT_EQUIP_LOCK_STATUS_CHANGE_NOTYFY then + local equipId = args[1] + if equipId ~= self.EquipId then return end + self:UpdateLockStatues(equipId) + self:UpdateRecycleStatues(equipId) + elseif evt == XEventId.EVENT_EQUIP_RECYCLE_STATUS_CHANGE_NOTYFY then + local equipId = args[1] + if equipId ~= self.EquipId then return end + self:UpdateRecycleStatues(equipId) + end +end + +function XUiEquipAwarenessPopup:UpdateLockStatues(equipId) + if self.HideAllBtns then + self.BtnLockSelect.gameObject:SetActiveEx(false) + self.BtnUnlockSelect.gameObject:SetActiveEx(false) + self.BtnLockUsing.gameObject:SetActiveEx(false) + self.BtnUnlockUsing.gameObject:SetActiveEx(false) + return + end + + if not equipId then return end + + if equipId == self.EquipId then + local isLock = XDataCenter.EquipManager.IsLock(equipId) + self.BtnLockSelect.gameObject:SetActiveEx(isLock) + self.BtnUnlockSelect.gameObject:SetActiveEx(not isLock) + end +end + +function XUiEquipAwarenessPopup:UpdateRecycleStatues(equipId) + if self.HideAllBtns then + self.BtnLaJiSelect.gameObject:SetActiveEx(false) + self.BtnUnlaJiSelect.gameObject:SetActiveEx(false) + self.BtnLaJiUsing.gameObject:SetActiveEx(false) + self.BtnUnlaJiUsing.gameObject:SetActiveEx(false) + return + end + + if not equipId then return end + + if equipId == self.EquipId then + local isCanRecycle = XDataCenter.EquipManager.IsEquipCanRecycle(equipId) + local isRecycle = XDataCenter.EquipManager.IsRecycle(equipId) + self.BtnLaJiSelect.gameObject:SetActiveEx(isCanRecycle and isRecycle) + self.BtnUnlaJiSelect.gameObject:SetActiveEx(isCanRecycle and not isRecycle) + end +end + +function XUiEquipAwarenessPopup:UpdateSelectPanel() + if not self.SelectEquipGrid then + self.SelectEquipGrid = XUiGridEquip.New(self.GridEquipSelect) + self.SelectEquipGrid:InitRootUi(self) + end + self.SelectEquipGrid:Refresh(self.EquipId) + + local equip = XDataCenter.EquipManager.GetEquip(self.EquipId) + self.TxtNameA.text = XDataCenter.EquipManager.GetEquipName(equip.TemplateId) + + local attrCount = 1 + local attrMap = XDataCenter.EquipManager.GetEquipAttrMap(self.EquipId) + for attrIndex, attrInfo in pairs(attrMap) do + if attrCount > MAX_AWARENESS_ATTR_COUNT then break end + + local usingAttr = self.UsingAttrMap[attrIndex] + local usingAttrValue = usingAttr and usingAttr.Value or 0 + local selectAttrValue = attrInfo.Value + if selectAttrValue > usingAttrValue then + self["TxtSelectAttrValue" .. attrCount].color = ATTR_COLOR.OVER + self["ImgArrowUpSelect" .. attrCount].gameObject:SetActiveEx(true) + self["ImgArrowDownSelect" .. attrCount].gameObject:SetActiveEx(false) + elseif selectAttrValue == usingAttrValue then + self["TxtSelectAttrValue" .. attrCount].color = ATTR_COLOR.EQUAL + self["ImgArrowUpSelect" .. attrCount].gameObject:SetActiveEx(false) + self["ImgArrowDownSelect" .. attrCount].gameObject:SetActiveEx(false) + else + self["TxtSelectAttrValue" .. attrCount].color = ATTR_COLOR.BELOW + self["ImgArrowUpSelect" .. attrCount].gameObject:SetActiveEx(false) + self["ImgArrowDownSelect" .. attrCount].gameObject:SetActiveEx(true) + end + self["TxtSelectAttrName" .. attrCount].text = attrInfo.Name + self["TxtSelectAttrValue" .. attrCount].text = selectAttrValue + self["PanelSelectAttr" .. attrCount].gameObject:SetActiveEx(true) + + attrCount = attrCount + 1 + end + for i = attrCount, MAX_AWARENESS_ATTR_COUNT do + self["PanelSelectAttr" .. i].gameObject:SetActiveEx(false) + end + + --是否激活颜色不同 + local suitId = XDataCenter.EquipManager.GetSuitId(equip.Id) + local activeEquipsCount = XDataCenter.EquipManager.GetActiveSuitEquipsCount(self.CharacterId, suitId) + local skillDesList = XDataCenter.EquipManager.GetSuitActiveSkillDesList(suitId, activeEquipsCount) + for i = 1, XEquipConfig.MAX_SUIT_SKILL_COUNT do + local componentText = self["TxtSkillDesA" .. i] + if not skillDesList[i] then + componentText.gameObject:SetActiveEx(false) + else + local color = SKILL_DES_COLOR[skillDesList[i].IsActive] + componentText.text = skillDesList[i].SkillDes + componentText.gameObject:SetActiveEx(true) + componentText.color = color + self["TxtPosA" .. i].color = color + end + end + + --修正弹窗位置 + if self.RootUi.NeedFixPopUpPos and (not self.UsingEquipId or self.UsingEquipId == self.EquipId) then + local equipSite = XDataCenter.EquipManager.GetEquipSite(self.EquipId) + self.PanelSelectRectTransform.anchoredPosition = CUR_EQUIP_CLICK_POPUP_POS[equipSite] + else + self.PanelSelectRectTransform.anchoredPosition = CUR_EQUIP_CLICK_POPUP_POS[XEquipConfig.EquipSite.Awareness.One] + end + + self.BtnStrengthen.gameObject:SetActiveEx(not self.HideStrengthenBtn and not self.HideAllBtns) + + CS.UnityEngine.UI.LayoutRebuilder.ForceRebuildLayoutImmediate(self.PanelContentA) +end + +function XUiEquipAwarenessPopup:UpdateUsingPanel() + if not self.UsingEquipId or self.UsingEquipId == self.EquipId then + self.PanelUsing.gameObject:SetActiveEx(false) + return + end + + if not self.UsingEquipGrid then + self.UsingEquipGrid = XUiGridEquip.New(self.GridEquipUsing) + self.UsingEquipGrid:InitRootUi(self) + end + self.UsingEquipGrid:Refresh(self.UsingEquipId) + + local equip = XDataCenter.EquipManager.GetEquip(self.UsingEquipId) + self.TxtName.text = XDataCenter.EquipManager.GetEquipName(equip.TemplateId) + + local attrCount = 1 + local attrMap = self.UsingAttrMap + for _, attrInfo in pairs(attrMap) do + if attrCount > MAX_AWARENESS_ATTR_COUNT then break end + + self["TxtUsingAttrName" .. attrCount].text = attrInfo.Name + self["TxtUsingAttrValue" .. attrCount].text = attrInfo.Value + self["PanelUsingAttr" .. attrCount].gameObject:SetActiveEx(true) + + attrCount = attrCount + 1 + end + for i = attrCount, MAX_AWARENESS_ATTR_COUNT do + self["PanelUsingAttr" .. i].gameObject:SetActiveEx(false) + end + + --是否激活颜色不同 + local suitId = XDataCenter.EquipManager.GetSuitId(equip.Id) + local activeEquipsCount = XDataCenter.EquipManager.GetActiveSuitEquipsCount(self.CharacterId, suitId) + local skillDesList = XDataCenter.EquipManager.GetSuitActiveSkillDesList(suitId, activeEquipsCount) + + for i = 1, XEquipConfig.MAX_SUIT_SKILL_COUNT do + local componentText = self["TxtSkillDes" .. i] + if not skillDesList[i] then + componentText.gameObject:SetActiveEx(false) + else + local color = SKILL_DES_COLOR[skillDesList[i].IsActive] + componentText.text = skillDesList[i].SkillDes + componentText.gameObject:SetActiveEx(true) + componentText.color = color + self["TxtPos" .. i].color = color + end + end + + --去掉穿戴中装备的锁按钮 + self.BtnLockUsing.gameObject:SetActiveEx(false) + self.BtnUnlockUsing.gameObject:SetActiveEx(false) + self.BtnLaJiUsing.gameObject:SetActiveEx(false) + self.BtnUnlaJiUsing.gameObject:SetActiveEx(false) + + self.PanelUsing.gameObject:SetActiveEx(true) + + CS.UnityEngine.UI.LayoutRebuilder.ForceRebuildLayoutImmediate(self.PanelContent) +end + +function XUiEquipAwarenessPopup:UpdateUsingPanelBtn() + if self.HideAllBtns then + self.BtnPutOn.gameObject:SetActiveEx(false) + self.BtnTakeOff.gameObject:SetActiveEx(false) + return + end + + if self.UsingEquipId and self.UsingEquipId == self.EquipId then + self.BtnPutOn.gameObject:SetActiveEx(false) + self.BtnTakeOff.gameObject:SetActiveEx(true) + else + self.BtnPutOn.gameObject:SetActiveEx(true) + self.BtnTakeOff.gameObject:SetActiveEx(false) + end +end + +function XUiEquipAwarenessPopup:AutoAddListener() + self:RegisterClickEvent(self.BtnStrengthen, self.OnBtnStrengthenClick) + self:RegisterClickEvent(self.BtnPutOn, self.OnBtnPutOnClick) + self:RegisterClickEvent(self.BtnTakeOff, self.OnBtnTakeOffClick) + self:RegisterClickEvent(self.BtnLockUsing, self.OnBtnLockUsingClick) + self:RegisterClickEvent(self.BtnUnlockUsing, self.OnBtnUnlockUsingClick) + self:RegisterClickEvent(self.BtnLockSelect, self.OnBtnLockSelectClick) + self:RegisterClickEvent(self.BtnUnlockSelect, self.OnBtnUnlockSelectClick) + self:RegisterClickEvent(self.BtnLaJiUsing, self.OnBtnLaJiUsingClick) + self:RegisterClickEvent(self.BtnUnlaJiUsing, self.OnBtnUnlaJiUsingClick) + self:RegisterClickEvent(self.BtnLaJiSelect, self.OnBtnLaJiSelectClick) + self:RegisterClickEvent(self.BtnUnlaJiSelect, self.OnBtnUnlaJiSelectClick) +end + +function XUiEquipAwarenessPopup:OnBtnLaJiSelectClick() + XDataCenter.EquipManager.EquipUpdateRecycleRequest(self.EquipId, false) +end + +function XUiEquipAwarenessPopup:OnBtnUnlaJiSelectClick() + XDataCenter.EquipManager.EquipUpdateRecycleRequest(self.EquipId, true) +end + +function XUiEquipAwarenessPopup:OnBtnLaJiUsingClick() + XDataCenter.EquipManager.EquipUpdateRecycleRequest(self.UsingEquipId, false) +end + +function XUiEquipAwarenessPopup:OnBtnUnlaJiUsingClick() + XDataCenter.EquipManager.EquipUpdateRecycleRequest(self.UsingEquipId, true) +end + +function XUiEquipAwarenessPopup:OnBtnUnlockSelectClick() + XDataCenter.EquipManager.SetLock(self.EquipId, true) +end + +function XUiEquipAwarenessPopup:OnBtnLockSelectClick() + XDataCenter.EquipManager.SetLock(self.EquipId, false) +end + +function XUiEquipAwarenessPopup:OnBtnLockUsingClick() + XDataCenter.EquipManager.SetLock(self.UsingEquipId, false) +end + +function XUiEquipAwarenessPopup:OnBtnUnlockUsingClick() + XDataCenter.EquipManager.SetLock(self.UsingEquipId, true) +end + +function XUiEquipAwarenessPopup:OnBtnStrengthenClick() + XLuaUiManager.Open("UiEquipDetail", self.EquipId, nil, self.CharacterId) + self:Close() +end + +function XUiEquipAwarenessPopup:OnBtnPutOnClick() + local characterId = self.CharacterId + local equipId = self.EquipId + + local wearingCharacterId = XDataCenter.EquipManager.GetEquipWearingCharacterId(equipId) + if wearingCharacterId and wearingCharacterId > 0 then + local fullName = XCharacterConfigs.GetCharacterFullNameStr(wearingCharacterId) + local content = CSXTextManagerGetText("EquipAwarenessReplaceTip", fullName) + XUiManager.DialogTip(CSXTextManagerGetText("TipTitle"), content, XUiManager.DialogType.Normal, function() end, function() + XDataCenter.EquipManager.PutOn(characterId, equipId) + end) + else + XDataCenter.EquipManager.PutOn(characterId, equipId) + end +end + +function XUiEquipAwarenessPopup:OnBtnTakeOffClick() + XDataCenter.EquipManager.TakeOff({ self.EquipId }) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiEquipAwarenessReplace/XUiEquipAwarenessReplace.lua b/Resources/Scripts/XUi/XUiEquipAwarenessReplace/XUiEquipAwarenessReplace.lua new file mode 100644 index 00000000..73b09a7e --- /dev/null +++ b/Resources/Scripts/XUi/XUiEquipAwarenessReplace/XUiEquipAwarenessReplace.lua @@ -0,0 +1,774 @@ +local XUiPanelEquipScroll = require("XUi/XUiEquipAwarenessReplace/XUiPanelEquipScroll") +local XUiPanelSuitDetailScroll = require("XUi/XUiEquipAwarenessReplace/XUiPanelSuitDetailScroll") +local XUiPanelSuitSimpleScroll = require("XUi/XUiEquipAwarenessReplace/XUiPanelSuitSimpleScroll") +local XUiGridEquip = require("XUi/XUiEquipAwarenessReplace/XUiGridEquip") +local XUiGridDoubleResonanceSkill = require("XUi/XUiEquipResonanceSkill/XUiGridDoubleResonanceSkill") + +local type = type +local tableInsert = table.insert +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate +local CSXTextManagerGetText = CS.XTextManager.GetText +local CSXScheduleManagerUnSchedule = XScheduleManager.UnSchedule +local CSXScheduleManagerScheduleOnce = XScheduleManager.ScheduleOnce + +local MAX_MERGE_ATTR_COUNT = 4 +local MAX_RESONANCE_SKILL_COUNT = 6 + +local ViewPattern = { + Pos = 1, + Suit = 2, + Resonance = 3, + Quick = 4, +} + +local GridPattern = { + Simple = 1, + Detail = 2, +} + +local ShowPropertyIndex = { + Attr = 1, + SuitSkill = 2, + ResonanceSkill = 3, +} + +local ResonanceType = { + CurCharacter = 1, --当前角色共鸣 + Others = 2, --其他角色共鸣 + None = 3, --无共鸣 +} + +local XUiEquipAwarenessReplace = XLuaUiManager.Register(XLuaUi, "UiEquipAwarenessReplace") + +function XUiEquipAwarenessReplace:OnAwake() + self:AutoAddListener() + self:InitComponentStatus() +end + +function XUiEquipAwarenessReplace:OnStart(characterId, equipSite, notShowStrengthenBtn) + equipSite = equipSite or XEquipConfig.EquipSite.Awareness.One + self.InitSelectPos = equipSite + self.CharacterId = characterId + self.IsAscendOrder = false --初始降序 + self.LastViewPattern = ViewPattern.Pos + self.GridPattern = GridPattern.Simple + self.SelectedSuitStar = 6 + self.NotShowStrengthenBtn = notShowStrengthenBtn or false + self.SelectShowProperty = ShowPropertyIndex.Attr + self.SelectedResonanceType = ResonanceType.CurCharacter + self.TempSpriteList = {} + self.GridDoubleResonanceSkills = {} + + self.PanelTabBtns:Init({ + self.BtnPos, + self.BtnSuit, + self.BtnGongming, + }, function(tabIndex) self:OnSelectViewPattern(tabIndex) end) + + self.PanelTogPos:Init({ + self.Tog1, + self.Tog2, + self.Tog3, + self.Tog4, + self.Tog5, + self.Tog6, + }, function(tabIndex) self:OnSelectEquipSite(tabIndex) end) + + self.PanelTogPosStar:Init({ + self.TogStar1, + self.TogStar2, + self.TogStar3, + self.TogStar4, + self.TogStar5, + self.TogStar6, + }, function(tabIndex) self:OnSelectSuitStar(tabIndex) end) + + + local characterTradeName = XCharacterConfigs.GetCharacterTradeName(characterId) + local btnNameStr = CSXTextManagerGetText("EquipAwarenessReplaceBtnName", characterTradeName) + self.TogType01:SetNameByGroup(0, btnNameStr) + self.PanelTogPosGmtype:Init({ + self.TogType01, + self.TogType02, + self.TogType03, + }, function(tabIndex) self:OnSelectResonanceType(tabIndex) end) + + self.EquipBtnGroup:Init({ + self.BtnEquipProperty, + self.BtnEquipSkill, + self.BtnEquipResonance, + }, function(tabIndex) self:OnSelectShowProperty(tabIndex) end) + + self:InitScrollPanel() + self:InitCurEquipGrids() +end + +function XUiEquipAwarenessReplace:OnEnable() + self:UpdateCurEquipGrids() + self:UpdateViewData() + if self.LastViewPattern ~= ViewPattern.Quick then + self.PanelTabBtns:SelectIndex(self.LastViewPattern) + else + self:UpdateSuitDrdOptionList() + self:OnSelectSortType(self.DrdSort.value, true) + end + self.EquipBtnGroup:SelectIndex(self.SelectShowProperty) + self:HideActiveEffect() +end + +function XUiEquipAwarenessReplace:OnDestroy() + for _, info in pairs(self.TempSpriteList) do + CS.UnityEngine.Object.Destroy(info.Sprite) + CS.XResourceManager.Unload(info.Resource) + end +end + +--注册监听事件 +function XUiEquipAwarenessReplace:OnGetEvents() + return { + XEventId.EVENT_EQUIP_PUTON_NOTYFY + , XEventId.EVENT_EQUIPLIST_TAKEOFF_NOTYFY + , XEventId.EVENT_EQUIP_LOCK_STATUS_CHANGE_NOTYFY + , XEventId.EVENT_EQUIP_RECYCLE_STATUS_CHANGE_NOTYFY + , XEventId.EVENT_EQUIP_RECYCLE_NOTIFY + } +end + +--处理事件监听 +function XUiEquipAwarenessReplace:OnNotify(evt, ...) + local args = { ... } + + if evt == XEventId.EVENT_EQUIP_PUTON_NOTYFY then + local equipId = args[1] + self:UpdateViewData() + if self.LastViewPattern == ViewPattern.Quick then + local suitId = XDataCenter.EquipManager.GetSuitId(equipId) + self:UpdateSuitDrdOptionList() + self:UpdateDrdSuitValue(suitId) + end + self:OnSelectSortType(self.DrdSort.value) + + local equipSite = XDataCenter.EquipManager.GetEquipSite(equipId) + self:UpdateCurEquipGrid(equipSite) + self.EquipBtnGroup:SelectIndex(self.SelectShowProperty) + self:PlayActiveEffect(equipId) + elseif evt == XEventId.EVENT_EQUIPLIST_TAKEOFF_NOTYFY then + local equipIds = args[1] + self:UpdateViewData() + for _, equipId in pairs(equipIds) do + if self.LastViewPattern == ViewPattern.Quick then + local suitId = XDataCenter.EquipManager.GetSuitId(equipId) + self:UpdateSuitDrdOptionList() + self:UpdateDrdSuitValue(suitId) + end + local equipSite = XDataCenter.EquipManager.GetEquipSite(equipId) + self:UpdateCurEquipGrid(equipSite) + end + self:OnSelectSortType(self.DrdSort.value) + self.EquipBtnGroup:SelectIndex(self.SelectShowProperty) + elseif evt == XEventId.EVENT_EQUIP_LOCK_STATUS_CHANGE_NOTYFY + or evt == XEventId.EVENT_EQUIP_RECYCLE_STATUS_CHANGE_NOTYFY then + local equipId = args[1] + local equipSite = XDataCenter.EquipManager.GetEquipSite(equipId) + self:UpdateCurEquipGrid(equipSite) + self:OnSelectSortType(self.DrdSort.value, true) + elseif evt == XEventId.EVENT_EQUIP_RECYCLE_NOTIFY then + self:UpdateViewData() + self:OnSelectSortType(self.DrdSort.value, true) + end +end + +function XUiEquipAwarenessReplace:InitComponentStatus() + self.GridSuitSimple.gameObject:SetActive(false) + self.GridDoubleResonanceSkill.gameObject:SetActive(false) + self.Verticallayout = self.PanelAdapter:GetComponent("VerticalLayoutGroup") + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self.DrdSort.onValueChanged:AddListener(function() + self:OnDrdSortValueChanged() + end) + self.DrdSuit.onValueChanged:AddListener(function() + self:OnDrdSuitValueChanged() + end) +end + +function XUiEquipAwarenessReplace:UpdateViewData() + local characterId = self.CharacterId + local characterType = XCharacterConfigs.GetCharacterType(characterId) + self.SiteToEquipIdsDic = XDataCenter.EquipManager.ConstructAwarenessSiteToEquipIdsDic(characterType) + self.StarToSiteToSuitIdsDic = XDataCenter.EquipManager.ConstructAwarenessStarToSiteToSuitIdsDic(characterType) + self.SuitIdToEquipIdsDic = XDataCenter.EquipManager.ConstructAwarenessSuitIdToEquipIdsDic(characterType) + self.ResonanceTypeToEquipIdsDic = XDataCenter.EquipManager.ConstructAwarenessResonanceTypeToEquipIdsDic(characterId) +end + +function XUiEquipAwarenessReplace:UpdateSuitDrdOptionList() + self.DrdSuit:ClearOptions() + local optionDataList = CS.UnityEngine.UI.Dropdown.OptionDataList() + for _, suitId in pairs(self.StarToSiteToSuitIdsDic[self.SelectedSuitStar][self.SelectedEquipSite]) do + local optionData = CS.UnityEngine.UI.Dropdown.OptionData() + optionData.text = XDataCenter.EquipManager.GetSuitName(suitId) + + local resource = CS.XResourceManager.Load(XDataCenter.EquipManager.GetSuitIconBagPath(suitId)) + local texture = resource.Asset + local sprite = CS.UnityEngine.Sprite.Create(texture, + CS.UnityEngine.Rect(0, 0, texture.width, texture.height), + CS.UnityEngine.Vector2.zero) + optionData.image = sprite + optionDataList.options:Add(optionData) + + local info = { + Sprite = sprite, + Resource = resource, + } + tableInsert(self.TempSpriteList, info) + end + self.DrdSuit:AddOptions(optionDataList.options) +end + +function XUiEquipAwarenessReplace:InitScrollPanel() + local equipTouchCb = function(equipId) + self:OnSelectEquip(equipId) + end + + local suitTouchCb = function(suitId) + self:OnSelectViewPattern(ViewPattern.Quick) + self:UpdateSuitDrdOptionList() + self:UpdateDrdSuitValue(suitId) + end + + local gridReloadCb = function() + self:SetSortBtnEnabled(true) + end + + self.EquipScroll = XUiPanelEquipScroll.New(self, self.PanelEquipScroll, equipTouchCb, gridReloadCb) + self.SuitSimpleScroll = XUiPanelSuitSimpleScroll.New(self, self.PanelSuitSimpleScroll, suitTouchCb, gridReloadCb) + self.SuitDetailScroll = XUiPanelSuitDetailScroll.New(self, self.PanelSuitDetailScroll, suitTouchCb, gridReloadCb) +end + +function XUiEquipAwarenessReplace:InitCurEquipGrids() + local clickCb = function(equipId) + local equipSite = XDataCenter.EquipManager.GetEquipSite(equipId) + self.PanelTogPos:SelectIndex(equipSite) + self:OnSelectEquip(equipId, true) + end + + self.CurEquipGirds = {} + for _, equipSite in pairs(XEquipConfig.EquipSite.Awareness) do + local item = CSUnityEngineObjectInstantiate(self.GridCurAwareness) + self.CurEquipGirds[equipSite] = XUiGridEquip.New(item, clickCb) + self.CurEquipGirds[equipSite]:InitRootUi(self) + self.CurEquipGirds[equipSite].Transform:SetParent(self["PanelPos" .. equipSite], false) + end +end + +function XUiEquipAwarenessReplace:UpdateCurEquipGrids() + for _, equipSite in pairs(XEquipConfig.EquipSite.Awareness) do + self:UpdateCurEquipGrid(equipSite) + end +end + +function XUiEquipAwarenessReplace:UpdateCurEquipGrid(equipSite) + local wearingEquipId = XDataCenter.EquipManager.GetWearingEquipIdBySite(self.CharacterId, equipSite) + if not wearingEquipId then + self.CurEquipGirds[equipSite].GameObject:SetActive(false) + self["PanelNoEquip" .. equipSite].gameObject:SetActive(true) + else + self.CurEquipGirds[equipSite]:Refresh(wearingEquipId) + self.CurEquipGirds[equipSite].GameObject:SetActive(true) + self["PanelNoEquip" .. equipSite].gameObject:SetActive(false) + end +end + +function XUiEquipAwarenessReplace:UpdateCurEquipAttr() + local attrMap = XDataCenter.EquipManager.GetWearingAwarenessMergeAttrMap(self.CharacterId) + local attrCount = 0 + + for _, attr in pairs(attrMap) do + attrCount = attrCount + 1 + if attrCount > MAX_MERGE_ATTR_COUNT then + break + end + self["TxtName" .. attrCount].text = attr.Name + self["TxtAttr" .. attrCount].text = attr.Value + self["PanelAttr" .. attrCount].gameObject:SetActive(true) + end + + for i = attrCount + 1, MAX_MERGE_ATTR_COUNT do + self["PanelAttr" .. i].gameObject:SetActive(false) + end +end + +function XUiEquipAwarenessReplace:UpdateCurEquipSkill() + local skillCount = 0 + local activeSkillDesInfoList = XDataCenter.EquipManager.GetCharacterWearingSuitMergeActiveSkillDesInfoList(self.CharacterId) + + for i = 1, XEquipConfig.MAX_SUIT_SKILL_COUNT do + if not activeSkillDesInfoList[i] then + self["TxtSkillDes" .. i].gameObject:SetActive(false) + else + self["TxtPos" .. i].text = activeSkillDesInfoList[i].PosDes + self["TxtSkillDes" .. i].text = activeSkillDesInfoList[i].SkillDes + self["TxtSkillDes" .. i].gameObject:SetActive(true) + skillCount = skillCount + 1 + end + end + + if skillCount == 0 then + self.PanelNoSkill.gameObject:SetActive(true) + else + self.PanelNoSkill.gameObject:SetActive(false) + end + + CS.UnityEngine.UI.LayoutRebuilder.ForceRebuildLayoutImmediate(self["TxtSkillDes1"].transform.parent) +end + +function XUiEquipAwarenessReplace:UpdateCurEquipResonanceSkill() + for index = 1, MAX_RESONANCE_SKILL_COUNT do + local grid = self.GridDoubleResonanceSkills[index] + if not grid then + local go = CSUnityEngineObjectInstantiate(self.GridDoubleResonanceSkill, self.PanelResonanceSkill) + local clickCb = function(grid) + if self.LastSelectResonanceGrid then + self.LastSelectResonanceGrid:SetSelect(false) + end + self.LastSelectResonanceGrid = grid + grid:SetSelect(true) + end + grid = XUiGridDoubleResonanceSkill.New(go, clickCb) + self.GridDoubleResonanceSkills[index] = grid + grid.GameObject:SetActive(true) + end + + grid:Refresh(self.CharacterId, index) + end +end + +function XUiEquipAwarenessReplace:OnSelectSortType(sortType, doNotResetSelect) + for key, list in pairs(self.SiteToEquipIdsDic) do + XDataCenter.EquipManager.SortEquipIdListByPriorType(list, sortType) + if self.IsAscendOrder then + XTool.ReverseList(list) + end + end + + for _, lists in pairs(self.SuitIdToEquipIdsDic) do + for key, list in pairs(lists) do + XDataCenter.EquipManager.SortEquipIdListByPriorType(list, sortType) + if self.IsAscendOrder then + XTool.ReverseList(list) + end + end + end + + for key, list in pairs(self.ResonanceTypeToEquipIdsDic) do + XDataCenter.EquipManager.SortEquipIdListByPriorType(list, sortType) + if self.IsAscendOrder then + XTool.ReverseList(list) + end + end + + self.ImgAscend.gameObject:SetActive(self.IsAscendOrder) + self.ImgDescend.gameObject:SetActive(not self.IsAscendOrder) + + self:UpdateScroll(doNotResetSelect) +end + +--防手快一直点 +function XUiEquipAwarenessReplace:SetSortBtnEnabled(enabled) + self.BtnOrder.enabled = enabled + self.BtnToDetail.enabled = enabled + self.BtnToSimple.enabled = enabled +end + +function XUiEquipAwarenessReplace:OnSelectViewPattern(viewPattern) + self.LastViewPattern = viewPattern + + if viewPattern == ViewPattern.Pos then + self.PanelEquipScroll.gameObject:SetActive(true) + self:PlayAnimation("LeftEnableOne") + self.PanelSuitSimpleScroll.gameObject:SetActive(false) + self.PanelSuitDetailScroll.gameObject:SetActive(false) + self.PanelSuitDropDown.gameObject:SetActive(false) + self.PanelTabBtns.gameObject:SetActive(true) + self.PanelTogPosStar.gameObject:SetActive(false) + self.PanelTogPosGmtype.gameObject:SetActive(false) + self.DrdSort.gameObject:SetActive(true) + self.BtnOrder.gameObject:SetActive(true) + self.BtnToSimple.gameObject:SetActive(false) + self.BtnToDetail.gameObject:SetActive(false) + self.PanelTogPos.CanDisSelect = false + self.PanelTogPos.gameObject:SetActive(true) + if type(self.SelectedEquipSite) == "number" then + self.PanelTogPos:SelectIndex(self.SelectedEquipSite) + else + self.PanelTogPos:SelectIndex(self.InitSelectPos) + self.InitSelectPos = XEquipConfig.EquipSite.Awareness.One --初始位置修改只打开时生效一次 + end + elseif viewPattern == ViewPattern.Suit then + self.PanelEquipScroll.gameObject:SetActive(false) + self.PanelSuitDropDown.gameObject:SetActive(false) + self.PanelTabBtns.gameObject:SetActive(true) + self.PanelTogPos.gameObject:SetActive(false) + self.DrdSort.gameObject:SetActive(false) + self.BtnOrder.gameObject:SetActive(false) + self.PanelTogPosStar.gameObject:SetActive(true) + self.PanelTogPosGmtype.gameObject:SetActive(false) + self.PanelTogPos.CanDisSelect = true + if type(self.SelectedEquipSite) == "number" then + self.PanelTogPos:SelectIndex(self.SelectedEquipSite) --重置位置选择 + end + self:OnSelectGridPattern(self.GridPattern) + elseif viewPattern == ViewPattern.Resonance then + self.PanelEquipScroll.gameObject:SetActive(true) + self:PlayAnimation("LeftEnableOne") + self.PanelSuitSimpleScroll.gameObject:SetActive(false) + self.PanelSuitDetailScroll.gameObject:SetActive(false) + self.PanelSuitDropDown.gameObject:SetActive(false) + self.PanelTabBtns.gameObject:SetActive(true) + self.PanelTogPosStar.gameObject:SetActive(false) + self.DrdSort.gameObject:SetActive(true) + self.BtnOrder.gameObject:SetActive(true) + self.BtnToSimple.gameObject:SetActive(false) + self.BtnToDetail.gameObject:SetActive(false) + self.PanelTogPos.CanDisSelect = false + self.PanelTogPos.gameObject:SetActive(false) + self.PanelTogPosGmtype.gameObject:SetActive(true) + self.PanelTogPosGmtype:SelectIndex(self.SelectedResonanceType) + elseif viewPattern == ViewPattern.Quick then + self.PanelEquipScroll.gameObject:SetActive(true) + self:PlayAnimation("LeftEnableOne") + self.PanelSuitSimpleScroll.gameObject:SetActive(false) + self.PanelSuitDetailScroll.gameObject:SetActive(false) + self.PanelSuitDropDown.gameObject:SetActive(true) + self.PanelTabBtns.gameObject:SetActive(false) + self.PanelTogPosStar.gameObject:SetActive(false) + self.DrdSort.gameObject:SetActive(true) + self.BtnOrder.gameObject:SetActive(true) + self.BtnToSimple.gameObject:SetActive(false) + self.BtnToDetail.gameObject:SetActive(false) + self.PanelTogPos.CanDisSelect = true + self.PanelTogPos.gameObject:SetActive(true) + end +end + +function XUiEquipAwarenessReplace:OnSelectEquipSite(equipSite) + equipSite = self.PanelTogPos.CanDisSelect and equipSite == self.SelectedEquipSite and "Total" or equipSite + self.SelectedEquipSite = equipSite + + if self.LastSelectPos then + local go = self["ImgSelect" .. self.LastSelectPos] + if go then + go.gameObject:SetActive(false) + end + end + self.LastSelectPos = equipSite + if self.LastSelectPos then + local go = self["ImgSelect" .. self.LastSelectPos] + if go then + go.gameObject:SetActive(true) + end + end + + if self.LastSelectCurGrid then + self.LastSelectCurGrid:SetSelected(false) + end + self.LastSelectCurGrid = self.CurEquipGirds[equipSite] + if self.LastSelectCurGrid then + self.LastSelectCurGrid:SetSelected(true) + end + + if self.LastViewPattern == ViewPattern.Quick then + self:UpdateSuitDrdOptionList() + self:UpdateDrdSuitValue(self.QuickLastSelectSuitId) + end + + self:OnSelectSortType(self.DrdSort.value) + self:PlayAnimation("EquipScrollQieHuan") + self:UpdateDrdSuitValue() -- 海外修改 +end + +function XUiEquipAwarenessReplace:OnSelectGridPattern(gridPattern) + self.GridPattern = gridPattern + + if gridPattern == GridPattern.Simple then + self.PanelSuitSimpleScroll.gameObject:SetActive(true) + self:PlayAnimation("SuitSimpleScrollQieHuan") + self.PanelSuitDetailScroll.gameObject:SetActive(false) + self.BtnToSimple.gameObject:SetActive(false) + self.BtnToDetail.gameObject:SetActive(true) + elseif gridPattern == GridPattern.Detail then + self.PanelSuitSimpleScroll.gameObject:SetActive(false) + self.PanelSuitDetailScroll.gameObject:SetActive(true) + self:PlayAnimation("SuitDetailScrollQieHuan") + self.BtnToSimple.gameObject:SetActive(true) + self.BtnToDetail.gameObject:SetActive(false) + end + + self:PlayAnimation("LeftEnableTwo") + self.PanelTogPosStar:SelectIndex(self.SelectedSuitStar) +end + +function XUiEquipAwarenessReplace:OnSelectSuitStar(star) + self.SelectedSuitStar = star + self:OnSelectSortType(self.DrdSort.value) + self:PlayAnimation("EquipScrollQieHuan") +end + +function XUiEquipAwarenessReplace:OnSelectResonanceType(index) + self.SelectedResonanceType = index + self:OnSelectSortType(self.DrdSort.value) + self:PlayAnimation("EquipScrollQieHuan") +end + +function XUiEquipAwarenessReplace:OnSelectShowProperty(selectShowProperty) + self.SelectShowProperty = selectShowProperty + + if selectShowProperty == ShowPropertyIndex.Attr then + self:UpdateCurEquipAttr() + self.PanelAttrParent.gameObject:SetActive(true) + self.PanelSuitSkill.gameObject:SetActive(false) + self.PanelResonanceSkill.gameObject:SetActive(false) + elseif selectShowProperty == ShowPropertyIndex.SuitSkill then + self:UpdateCurEquipSkill() + self.PanelAttrParent.gameObject:SetActive(false) + self.PanelSuitSkill.gameObject:SetActive(true) + self.PanelResonanceSkill.gameObject:SetActive(false) + elseif selectShowProperty == ShowPropertyIndex.ResonanceSkill then + self:UpdateCurEquipResonanceSkill() + self.PanelAttrParent.gameObject:SetActive(false) + self.PanelSuitSkill.gameObject:SetActive(false) + self.PanelResonanceSkill.gameObject:SetActive(true) + end + + XLuaUiManager.Close("UiEquipAwarenessPopup") +end + +function XUiEquipAwarenessReplace:OnSelectDrdSuit(suitId) + if not suitId then + return + end + self.SelectedSuitId = suitId + + self.PanelTogPosStar:SelectIndex(XDataCenter.EquipManager.GetSuitStar(suitId)) +end + +function XUiEquipAwarenessReplace:UpdateDrdSuitValue(suitId) + local findSuitInDrd = false + for k, v in pairs(self.StarToSiteToSuitIdsDic[self.SelectedSuitStar][self.SelectedEquipSite]) do + if v == suitId then + self.DrdSuit.value = k - 1 + findSuitInDrd = true + break + end + end + + -- 如果当前位置没有对应套装ID,那么也调用调度函数刷到下个套装显示 + if not findSuitInDrd then + if self.DrdSuit.value == 0 then + self:OnDrdSuitValueChanged() + else + self.DrdSuit.value = 0 + end + else + self:OnDrdSuitValueChanged() + end +end + +function XUiEquipAwarenessReplace:UpdateScroll(doNotResetSelect) + if not self.LastViewPattern then + return + end + + local scroll, idList + if self.LastViewPattern == ViewPattern.Suit then + if not self.GridPattern then return end + + idList = self.StarToSiteToSuitIdsDic[self.SelectedSuitStar] + and self.StarToSiteToSuitIdsDic[self.SelectedSuitStar][self.SelectedEquipSite] or {} + + if self.GridPattern == GridPattern.Simple then + scroll = self.SuitSimpleScroll + self.PanelNoSuitSimple.gameObject:SetActive(not next(idList)) + elseif self.GridPattern == GridPattern.Detail then + scroll = self.SuitDetailScroll + self.PanelNoSuitDetail.gameObject:SetActive(not next(idList)) + end + elseif self.LastViewPattern == ViewPattern.Pos then + scroll = self.EquipScroll + idList = self.SiteToEquipIdsDic[self.SelectedEquipSite] or {} + self.PanelNoEquip.gameObject:SetActive(not next(idList)) + elseif self.LastViewPattern == ViewPattern.Resonance then + scroll = self.EquipScroll + idList = self.ResonanceTypeToEquipIdsDic[self.SelectedResonanceType] or {} + self.PanelNoEquip.gameObject:SetActive(not next(idList)) + elseif self.LastViewPattern == ViewPattern.Quick then + scroll = self.EquipScroll + idList = self.SuitIdToEquipIdsDic[self.SelectedSuitId] + and self.SuitIdToEquipIdsDic[self.SelectedSuitId][self.SelectedEquipSite] or {} + self.PanelNoEquip.gameObject:SetActive(not next(idList)) + end + + if scroll then + self:SetSortBtnEnabled(false) + XLuaUiManager.Close("UiEquipAwarenessPopup") + + --NEVER DELETE ME! + CS.UnityEngine.UI.LayoutRebuilder.ForceRebuildLayoutImmediate(self.PanelAdapter) + if self.TimerId then + CSXScheduleManagerUnSchedule(self.TimerId) + self.TimerId = nil + end + self.TimerId = CSXScheduleManagerScheduleOnce(function() + if XTool.UObjIsNil(scroll.GameObject) then return end + scroll:UpdateEquipGridList(idList, doNotResetSelect, self.SelectedEquipSite) + end, 0) + end +end + +function XUiEquipAwarenessReplace:OnSelectEquip(equipId, needFixPopUpPos) + self.SelectEquipId = equipId + self.NeedFixPopUpPos = needFixPopUpPos + + self:OpenChildUi() +end + +function XUiEquipAwarenessReplace:PlayActiveEffect(equipId) + local suitId = XDataCenter.EquipManager.GetSuitId(equipId) + local count, siteCheckDic = XDataCenter.EquipManager.GetActiveSuitEquipsCount(self.CharacterId, suitId) + + if count == 2 or count == 4 or count == 6 then + for _, site in pairs(XEquipConfig.EquipSite.Awareness) do + if siteCheckDic[site] then + self["PanelEffect" .. site].gameObject:SetActive(false) + self["PanelEffect" .. site].gameObject:SetActive(true) + end + end + end +end + +function XUiEquipAwarenessReplace:HideActiveEffect() + for _, site in pairs(XEquipConfig.EquipSite.Awareness) do + self["PanelEffect" .. site].gameObject:SetActive(false) + end +end + +function XUiEquipAwarenessReplace:AutoAddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainClick) + self:RegisterClickEvent(self.BtnOrder, self.OnBtnOrderClick) + self:RegisterClickEvent(self.BtnToDetail, self.OnBtnToDetailClick) + self:RegisterClickEvent(self.BtnToSimple, self.OnBtnToSimpleClick) + self:RegisterClickEvent(self.BtnClosePopup, self.OnBtnClosePopupClick) + self:RegisterClickEvent(self.BtnPos1, self.OnBtnPos1Click) + self:RegisterClickEvent(self.BtnPos2, self.OnBtnPos2Click) + self:RegisterClickEvent(self.BtnPos3, self.OnBtnPos3Click) + self:RegisterClickEvent(self.BtnPos4, self.OnBtnPos4Click) + self:RegisterClickEvent(self.BtnPos5, self.OnBtnPos5Click) + self:RegisterClickEvent(self.BtnPos6, self.OnBtnPos6Click) + self:RegisterClickEvent(self.BtnAutoTakeOff, self.OnBtnAutoTakeOffClick) + self:RegisterClickEvent(self.BtnAwarenessSuitPrefab, self.OnBtnAwarenessSuitPrefabClick) + self:RegisterClickEvent(self.PanelEquipScroll, self.OnPanelEquipScrollClick) +end + +function XUiEquipAwarenessReplace:OpenChildUi() + XLuaUiManager.Close("UiEquipAwarenessPopup") + XLuaUiManager.Open("UiEquipAwarenessPopup", self, self.NotShowStrengthenBtn) +end + +function XUiEquipAwarenessReplace:OnPanelEquipScrollClick() + XLuaUiManager.Close("UiEquipAwarenessPopup") +end + +function XUiEquipAwarenessReplace:OnBtnClosePopupClick() + self.EquipScroll:ResetSelectGrid() + XLuaUiManager.Close("UiEquipAwarenessPopup") +end + +function XUiEquipAwarenessReplace:OnBtnPos1Click() + self.PanelTogPos:SelectIndex(XEquipConfig.EquipSite.Awareness.One) +end + +function XUiEquipAwarenessReplace:OnBtnPos2Click() + self.PanelTogPos:SelectIndex(XEquipConfig.EquipSite.Awareness.Two) +end + +function XUiEquipAwarenessReplace:OnBtnPos3Click() + self.PanelTogPos:SelectIndex(XEquipConfig.EquipSite.Awareness.Three) +end + +function XUiEquipAwarenessReplace:OnBtnPos4Click() + self.PanelTogPos:SelectIndex(XEquipConfig.EquipSite.Awareness.Four) +end + +function XUiEquipAwarenessReplace:OnBtnPos5Click() + self.PanelTogPos:SelectIndex(XEquipConfig.EquipSite.Awareness.Five) +end + +function XUiEquipAwarenessReplace:OnBtnPos6Click() + self.PanelTogPos:SelectIndex(XEquipConfig.EquipSite.Awareness.Six) +end + +function XUiEquipAwarenessReplace:OnBtnBackClick() + XLuaUiManager.Close("UiEquipAwarenessPopup") + if self.LastViewPattern == ViewPattern.Quick then + self.PanelTabBtns:SelectIndex(ViewPattern.Suit) + else + self:Close() + end +end + +function XUiEquipAwarenessReplace:OnBtnMainClick() + XLuaUiManager.RunMain() +end + +function XUiEquipAwarenessReplace:OnDrdSortValueChanged() + self:OnSelectSortType(self.DrdSort.value) +end + +function XUiEquipAwarenessReplace:OnDrdSuitValueChanged() + local suitId = self.StarToSiteToSuitIdsDic[self.SelectedSuitStar][self.SelectedEquipSite][self.DrdSuit.value + 1] + self.QuickLastSelectSuitId = suitId + self:OnSelectDrdSuit(suitId) +end + +function XUiEquipAwarenessReplace:OnBtnOrderClick() + self.IsAscendOrder = not self.IsAscendOrder + self.ImgAscend.gameObject:SetActive(self.IsAscendOrder) + self.ImgDescend.gameObject:SetActive(not self.IsAscendOrder) + + for key, list in pairs(self.SiteToEquipIdsDic) do + XTool.ReverseList(list) + end + + for _, lists in pairs(self.SuitIdToEquipIdsDic) do + for key, list in pairs(lists) do + XTool.ReverseList(list) + end + end + + for key, list in pairs(self.ResonanceTypeToEquipIdsDic) do + XTool.ReverseList(list) + end + + self:UpdateScroll() +end + +function XUiEquipAwarenessReplace:OnBtnToDetailClick() + self:OnSelectGridPattern(GridPattern.Detail) +end + +function XUiEquipAwarenessReplace:OnBtnToSimpleClick() + self:OnSelectGridPattern(GridPattern.Simple) +end + +function XUiEquipAwarenessReplace:OnBtnAutoTakeOffClick() + local wearingEquipIds = XDataCenter.EquipManager.GetCharacterWearingAwarenessIds(self.CharacterId) + if not wearingEquipIds or not next(wearingEquipIds) then + XUiManager.TipText("EquipAutoTakeOffNotWearingEquip") + return + end + XDataCenter.EquipManager.TakeOff(wearingEquipIds) +end + +function XUiEquipAwarenessReplace:OnBtnAwarenessSuitPrefabClick() + XLuaUiManager.Open("UiEquipAwarenessSuitPrefab", self.CharacterId) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiEquipAwarenessReplace/XUiEquipAwarenessSuitPrefab.lua b/Resources/Scripts/XUi/XUiEquipAwarenessReplace/XUiEquipAwarenessSuitPrefab.lua new file mode 100644 index 00000000..12e245aa --- /dev/null +++ b/Resources/Scripts/XUi/XUiEquipAwarenessReplace/XUiEquipAwarenessSuitPrefab.lua @@ -0,0 +1,488 @@ +local XUiGridSuitPrefab = require("XUi/XUiEquipAwarenessReplace/XUiGridSuitPrefab") +local XUiGridEquip = require("XUi/XUiEquipAwarenessReplace/XUiGridEquip") +local XUiGridResonanceSkill = require("XUi/XUiEquipResonanceSkill/XUiGridResonanceSkill") +local XUiGridDoubleResonanceSkill = require("XUi/XUiEquipResonanceSkill/XUiGridDoubleResonanceSkill") + +local tableInsert = table.insert +local tableSort = table.sort +local CSXTextManagerGetText = CS.XTextManager.GetText +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate + +local CUR_SUIT_PREFAB_INDEX = 0 +local MAX_MERGE_ATTR_COUNT = 4 +local MAX_RESONANCE_SKILL_COUNT = 6 +local ShowPropertyIndex = { + Attr = 1, + SuitSkill = 2, + ResonanceSkill = 3, +} +local TAB_TYPE = { + ALL = 1, --通用 + ONE = 2, --专属 +} + +local XUiEquipAwarenessSuitPrefab = XLuaUiManager.Register(XLuaUi, "UiEquipAwarenessSuitPrefab") + +function XUiEquipAwarenessSuitPrefab:OnAwake() + self:AutoAddListener() + self.GridSuitPrefab.gameObject:SetActiveEx(false) +end + +function XUiEquipAwarenessSuitPrefab:OnStart(characterId) + self.CharacterId = characterId + self.CurPrefabIndex = CUR_SUIT_PREFAB_INDEX + self.SelectShowProperty = ShowPropertyIndex.Attr + self.GridDoubleResonanceSkills = {} + self.GridDoubleResonanceSkill.gameObject:SetActiveEx(false) + + self:InitDynamicTable() + self:InitCurEquipGrids() + self:InitPropertyBtnGroup() + self:InitTabGroup() +end + +function XUiEquipAwarenessSuitPrefab:OnEnable() + -- 获取是否有专属意识组合数据 + local oneSuitPrefabIndexs = self:GetSuitPrefabIndexList(TAB_TYPE.ONE) + -- 如果已经有专属意识组合,直接切换专属 + if #oneSuitPrefabIndexs > 1 then + self.TabGroup:SelectIndex(TAB_TYPE.ONE) + -- 默认切换通用 + else + self.TabGroup:SelectIndex(TAB_TYPE.ALL) + end +end + +function XUiEquipAwarenessSuitPrefab:OnGetEvents() + return { + XEventId.EVENT_EQUIP_SUIT_PREFAB_DATA_UPDATE_NOTIFY + , XEventId.EVENT_EQUIP_DATA_LIST_UPDATE_NOTYFY + , XEventId.EVENT_EQUIP_PUTON_NOTYFY + , XEventId.EVENT_EQUIP_TAKEOFF_NOTYFY + , XEventId.EVENT_EQUIPLIST_TAKEOFF_NOTYFY + } +end + +function XUiEquipAwarenessSuitPrefab:OnNotify(evt) + if evt == XEventId.EVENT_EQUIP_SUIT_PREFAB_DATA_UPDATE_NOTIFY + or evt == XEventId.EVENT_EQUIP_DATA_LIST_UPDATE_NOTYFY + or evt == XEventId.EVENT_EQUIP_PUTON_NOTYFY + or evt == XEventId.EVENT_EQUIPLIST_TAKEOFF_NOTYFY + or evt == XEventId.EVENT_EQUIP_TAKEOFF_NOTYFY then + self:Refresh(nil, true) + end +end + +--@region 点击事件 + +function XUiEquipAwarenessSuitPrefab:AutoAddListener() + self.BtnTanchuangClose.CallBack = function() self:OnBtnTanchuangClose() end + self.BtnClosePopup.CallBack = function() self:ClosePopup() end + self.BtnSetName.CallBack = function() self:OnBtnSetName() end + self.BtnSave.CallBack = function() self:OnBtnSave() end + self.BtnEquip.CallBack = function() self:OnBtnEquip() end + self.BtnChangeName.CallBack = function() self:OnBtnChangeName() end + self.BtnDelete.CallBack = function() self:OnBtnDelete() end + self:RegisterClickEvent(self.BtnPos1, function() self:OnSelectEquipSite(XEquipConfig.EquipSite.Awareness.One) end) + self:RegisterClickEvent(self.BtnPos2, function() self:OnSelectEquipSite(XEquipConfig.EquipSite.Awareness.Two) end) + self:RegisterClickEvent(self.BtnPos3, function() self:OnSelectEquipSite(XEquipConfig.EquipSite.Awareness.Three) end) + self:RegisterClickEvent(self.BtnPos4, function() self:OnSelectEquipSite(XEquipConfig.EquipSite.Awareness.Four) end) + self:RegisterClickEvent(self.BtnPos5, function() self:OnSelectEquipSite(XEquipConfig.EquipSite.Awareness.Five) end) + self:RegisterClickEvent(self.BtnPos6, function() self:OnSelectEquipSite(XEquipConfig.EquipSite.Awareness.Six) end) + self:RegisterClickEvent(self.PanelDynamicTable, self.OnPanelDynamicTable) +end + +function XUiEquipAwarenessSuitPrefab:OnSelectType(index) + if self.TabType ~= index then + self.TabType = index + self.CurPrefabIndex = CUR_SUIT_PREFAB_INDEX + + self:Refresh() + end +end + +function XUiEquipAwarenessSuitPrefab:OnBtnTanchuangClose() + self:ClosePopup() + self:Close() +end + +function XUiEquipAwarenessSuitPrefab:OnPanelDynamicTable() + self:ClosePopup() +end + +function XUiEquipAwarenessSuitPrefab:OnBtnSetName() + self:ClosePopup() + XLuaUiManager.Open("UiEquipSuitPrefabRename", function(newName) + self.UnSavedPrefabInfo:SetName(newName) + self:Refresh(true) + end) +end + +function XUiEquipAwarenessSuitPrefab:OnBtnSave() + local num = #self.SuitPrefabInfoList-1 + local maxNum + + if self.TabType == TAB_TYPE.ALL then + maxNum = XDataCenter.EquipManager.GetSuitPrefabNumMax() + elseif self.TabType == TAB_TYPE.ONE then + maxNum = XDataCenter.EquipManager.GetEquipSuitCharacterPrefabMaxNum() + end + + if num >= maxNum then + XUiManager.TipText("EquipSuitPrefabSaveOverMaxNum") + return + end + + if self.TabType == TAB_TYPE.ALL then + XDataCenter.EquipManager.EquipSuitPrefabSave(self.UnSavedPrefabInfo, 0) + elseif self.TabType == TAB_TYPE.ONE then + XDataCenter.EquipManager.EquipSuitPrefabSave(self.UnSavedPrefabInfo, self.CharacterId) + end + + self:ClosePopup() +end + +function XUiEquipAwarenessSuitPrefab:OnBtnEquip() + self:ClosePopup() + + local characterType = XCharacterConfigs.GetCharacterType(self.CharacterId) + local conflictInfoList = {} + local suitPrefabInfo = self:GetShowingPrefabInfo() + local equipIds = suitPrefabInfo:GetEquipIds() + for _, equipId in pairs(equipIds) do + if not XDataCenter.EquipManager.IsCharacterTypeFit(equipId, characterType) then + XUiManager.TipText("EquipAwarenessSuitPrefabCharacterTypeWrong") + return + end + + local characterId = XDataCenter.EquipManager.GetEquipWearingCharacterId(equipId) + if characterId and characterId ~= self.CharacterId then + local conflictInfo = { + EquipId = equipId, + CharacterId = characterId, + } + tableInsert(conflictInfoList, conflictInfo) + end + end + tableSort(conflictInfoList, function(a, b) + return XDataCenter.EquipManager.GetEquipSite(a.EquipId) < XDataCenter.EquipManager.GetEquipSite(b.EquipId) + end) + + local equipFunc = function() + XDataCenter.EquipManager.EquipSuitPrefabEquip(self.CurPrefabIndex, self.CharacterId, function() + self.CurPrefabIndex = CUR_SUIT_PREFAB_INDEX + end) + end + + if not next(conflictInfoList) then + equipFunc() + else + XLuaUiManager.Open("UiEquipSuitPrefabConflict", conflictInfoList, equipFunc) + end +end + +function XUiEquipAwarenessSuitPrefab:OnBtnChangeName() + self:ClosePopup() + XLuaUiManager.Open("UiEquipSuitPrefabRename", function(newName) + XDataCenter.EquipManager.EquipSuitPrefabRename(self.CurPrefabIndex, newName) + end) +end + +function XUiEquipAwarenessSuitPrefab:OnBtnDelete() + self:ClosePopup() + + local suitPrefabInfo = self:GetShowingPrefabInfo() + local content = suitPrefabInfo:GetName() + XLuaUiManager.Open("UiEquipSuitPrefabConfirm", content, function() + local prefabIndex = self.CurPrefabIndex + self.CurPrefabIndex = CUR_SUIT_PREFAB_INDEX + XDataCenter.EquipManager.EquipSuitPrefabDelete(prefabIndex) + end) +end + +--@endregion + +--@region 初始化函数 +function XUiEquipAwarenessSuitPrefab:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelDynamicTable) + self.DynamicTable:SetProxy(XUiGridSuitPrefab) + self.DynamicTable:SetDelegate(self) +end + +function XUiEquipAwarenessSuitPrefab:InitCurEquipGrids() + local clickCb = function(equipId) + self:OnSelectEquip(equipId) + end + + self.CurEquipGirds = {} + self.GridCurAwareness.gameObject:SetActiveEx(false) + for _, equipSite in pairs(XEquipConfig.EquipSite.Awareness) do + local item = CS.UnityEngine.Object.Instantiate(self.GridCurAwareness) + self.CurEquipGirds[equipSite] = XUiGridEquip.New(item, clickCb) + self.CurEquipGirds[equipSite]:InitRootUi(self) + self.CurEquipGirds[equipSite].Transform:SetParent(self["PanelPos" .. equipSite], false) + end +end + +function XUiEquipAwarenessSuitPrefab:InitTabGroup() + local tabBtns = { self.BtnTabAll, self.BtnTabOne } + + self.TabGroup:Init(tabBtns, function(index) self:OnSelectType(index) end) + self.RImgRole:SetRawImage(XDataCenter.CharacterManager.GetCharSmallHeadIcon(self.CharacterId)) +end + +function XUiEquipAwarenessSuitPrefab:InitPropertyBtnGroup() + self.EquipBtnGroup:Init({ + self.BtnEquipProperty, + self.BtnEquipSkill, + self.BtnEquipResonance, + }, function(tabIndex) self:OnSelectShowProperty(tabIndex) end) +end + +function XUiEquipAwarenessSuitPrefab:OnSelectShowProperty(selectShowProperty) + self.SelectShowProperty = selectShowProperty + + if selectShowProperty == ShowPropertyIndex.Attr then + self:UpdateCurEquipAttr() + self.PanelAttrParent.gameObject:SetActiveEx(true) + self.PanelSuitSkill.gameObject:SetActiveEx(false) + self.PanelResonanceSkill.gameObject:SetActiveEx(false) + elseif selectShowProperty == ShowPropertyIndex.SuitSkill then + self:UpdateCurEquipSkill() + self.PanelAttrParent.gameObject:SetActiveEx(false) + self.PanelSuitSkill.gameObject:SetActiveEx(true) + self.PanelResonanceSkill.gameObject:SetActiveEx(false) + elseif selectShowProperty == ShowPropertyIndex.ResonanceSkill then + self:UpdateCurEquipResonanceSkill() + self.PanelAttrParent.gameObject:SetActiveEx(false) + self.PanelSuitSkill.gameObject:SetActiveEx(false) + self.PanelResonanceSkill.gameObject:SetActiveEx(true) + end + + self:ClosePopup() +end +--@endregion + +function XUiEquipAwarenessSuitPrefab:Refresh(doNotResetUnsaved, resetScroll) + local characterId = self.CharacterId + self.UnSavedPrefabInfo = not doNotResetUnsaved and XDataCenter.EquipManager.GetUnSavedSuitPrefabInfo(characterId) or self.UnSavedPrefabInfo + self.SuitPrefabInfoList = self:GetSuitPrefabIndexList() + + self:UpdateDynamicTable(resetScroll) + self:UpdateCurEquipGrids(self.CurPrefabIndex) +end + +function XUiEquipAwarenessSuitPrefab:UpdateCurEquipAttr() + local suitPrefabInfo = self:GetShowingPrefabInfo() + local attrMap = XDataCenter.EquipManager.GetAwarenessMergeAttrMap(suitPrefabInfo:GetEquipIds()) + local attrCount = 0 + + for _, attr in pairs(attrMap) do + attrCount = attrCount + 1 + if attrCount > MAX_MERGE_ATTR_COUNT then + break + end + self["TxtName" .. attrCount].text = attr.Name + self["TxtAttr" .. attrCount].text = attr.Value + self["PanelAttr" .. attrCount].gameObject:SetActiveEx(true) + end + + for i = attrCount + 1, MAX_MERGE_ATTR_COUNT do + self["PanelAttr" .. i].gameObject:SetActiveEx(false) + end +end + +function XUiEquipAwarenessSuitPrefab:UpdateCurEquipSkill() + local suitPrefabInfo = self:GetShowingPrefabInfo() + local activeSkillDesInfoList = XDataCenter.EquipManager.GetSuitMergeActiveSkillDesInfoList(suitPrefabInfo:GetEquipIds()) + local skillCount = 0 + + for i = 1, XEquipConfig.MAX_SUIT_SKILL_COUNT do + if not activeSkillDesInfoList[i] then + self["TxtSkillDes" .. i].gameObject:SetActiveEx(false) + else + self["TxtPos" .. i].text = activeSkillDesInfoList[i].PosDes + self["TxtSkillDes" .. i].text = activeSkillDesInfoList[i].SkillDes + self["TxtSkillDes" .. i].gameObject:SetActiveEx(true) + skillCount = skillCount + 1 + end + end + + if skillCount == 0 then + self.PanelNoSkill.gameObject:SetActiveEx(true) + else + self.PanelNoSkill.gameObject:SetActiveEx(false) + end + + CS.UnityEngine.UI.LayoutRebuilder.ForceRebuildLayoutImmediate(self["TxtSkillDes1"].transform.parent) +end + +function XUiEquipAwarenessSuitPrefab:UpdateCurEquipResonanceSkill() + local skillCount = 0 + + for equipSite = 1, MAX_RESONANCE_SKILL_COUNT do + local suitPrefabInfo = self:GetShowingPrefabInfo() + local equipId = suitPrefabInfo:GetEquipId(equipSite) + + local grid = self.GridDoubleResonanceSkills[equipSite] + if not grid then + local go = CSUnityEngineObjectInstantiate(self.GridDoubleResonanceSkill, self.PanelResonanceSkillParent) + grid = XUiGridDoubleResonanceSkill.New(go) + self.GridDoubleResonanceSkills[equipSite] = grid + grid.GameObject:SetActiveEx(true) + end + + if not equipId or equipId == 0 then + grid:RefreshByEquipId(nil, nil, equipSite) + else + grid:RefreshByEquipId(self.CharacterId, equipId, equipSite) + skillCount = skillCount + 1 + end + end + + local noResonanceSkill = skillCount == 0 + self.PanelResonanceSkillParent.gameObject:SetActiveEx(not noResonanceSkill) + self.PanelNoResonanceSkill.gameObject:SetActiveEx(noResonanceSkill) +end + +function XUiEquipAwarenessSuitPrefab:UpdateSavePanel() + local isPreafabSaved = self.CurPrefabIndex ~= CUR_SUIT_PREFAB_INDEX + self.PanelSavedPrefab.gameObject:SetActiveEx(isPreafabSaved) + self.PanelUnSavedPrefab.gameObject:SetActiveEx(not isPreafabSaved) + + if not isPreafabSaved then + local suitPrefabInfo = self:GetShowingPrefabInfo() + self.BtnSetName:SetName(suitPrefabInfo:GetName()) + end +end + +function XUiEquipAwarenessSuitPrefab:UpdateDynamicTable(resetScroll) + local num = #self.SuitPrefabInfoList-1 + if self.TabType == TAB_TYPE.ALL then + self.TxtTotalNum.text = CSXTextManagerGetText("EquipSuitPrefabNum", num, XDataCenter.EquipManager.GetSuitPrefabNumMax()) + self.TextName.text = CSXTextManagerGetText("AwarenessGroup") + elseif self.TabType == TAB_TYPE.ONE then + local charConfig = XCharacterConfigs.GetCharacterTemplate(self.CharacterId) + self.TxtTotalNum.text = CSXTextManagerGetText("EquipSuitPrefabNum", num, XDataCenter.EquipManager.GetEquipSuitCharacterPrefabMaxNum()) + self.TextName.text = CSXTextManagerGetText("AwarenessGroupWithName", charConfig.TradeName) + end + + self.DynamicTable:SetDataSource(self.SuitPrefabInfoList) + self.DynamicTable:ReloadDataASync(resetScroll and 1) +end + +function XUiEquipAwarenessSuitPrefab:OnDynamicTableEvent(event, index, grid) + local suitPrefabIndex = self.SuitPrefabInfoList[index] + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local suitPrefabInfo = self:GetShowingPrefabInfo(suitPrefabIndex) + local isPreafabSaved = suitPrefabIndex ~= CUR_SUIT_PREFAB_INDEX + grid:Refresh(suitPrefabInfo, index-1, isPreafabSaved) + if self.CurPrefabIndex == suitPrefabIndex then + grid:SetSelected(true) + self.LastSelectSuitPrefabGird = grid + else + grid:SetSelected(false) + end + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + if self.LastSelectSuitPrefabGird then + self.LastSelectSuitPrefabGird:SetSelected(false) + end + self.LastSelectSuitPrefabGird = grid + if self.LastSelectSuitPrefabGird then + self.LastSelectSuitPrefabGird:SetSelected(true) + end + self:UpdateCurEquipGrids(suitPrefabIndex) + self:ClosePopup() + end +end + +function XUiEquipAwarenessSuitPrefab:UpdateCurEquipGrids(suitPrefabIndex) + self.CurPrefabIndex = suitPrefabIndex + + self:UpdateSavePanel() + self.EquipBtnGroup:SelectIndex(self.SelectShowProperty) + for _, equipSite in pairs(XEquipConfig.EquipSite.Awareness) do + self:UpdateCurEquipGrid(equipSite) + end +end + +function XUiEquipAwarenessSuitPrefab:UpdateCurEquipGrid(equipSite) + local suitPrefabInfo = self:GetShowingPrefabInfo() + + local equipId = suitPrefabInfo:GetEquipId(equipSite) + if not equipId or equipId == 0 then + self.CurEquipGirds[equipSite].GameObject:SetActiveEx(false) + self["PanelNoEquip" .. equipSite].gameObject:SetActiveEx(true) + else + self.CurEquipGirds[equipSite]:Refresh(equipId) + self.CurEquipGirds[equipSite].GameObject:SetActiveEx(true) + self["PanelNoEquip" .. equipSite].gameObject:SetActiveEx(false) + end +end + +function XUiEquipAwarenessSuitPrefab:ClosePopup() + if XLuaUiManager.IsUiShow("UiEquipAwarenessPopup") then + XLuaUiManager.Close("UiEquipAwarenessPopup") + end +end + +function XUiEquipAwarenessSuitPrefab:OnSelectEquip(equipId) + local equipSite = XDataCenter.EquipManager.GetEquipSite(equipId) + self:OnSelectEquipSite(equipSite) + + if self.CurEquipGirds[equipSite] then + XLuaUiManager.Open("UiEquipAwarenessPopup", self, nil, equipId, self.CharacterId, true) + end +end + +function XUiEquipAwarenessSuitPrefab:OnSelectEquipSite(equipSite) + if self.LastSelectPos then + local go = self["ImgSelect" .. self.LastSelectPos] + if go then + go.gameObject:SetActiveEx(false) + end + end + self.LastSelectPos = equipSite + if self.LastSelectPos then + local go = self["ImgSelect" .. self.LastSelectPos] + if go then + go.gameObject:SetActiveEx(true) + end + end + + if self.LastSelectCurGrid then + self.LastSelectCurGrid:SetSelected(false) + end + self.LastSelectCurGrid = self.CurEquipGirds[equipSite] + if self.LastSelectCurGrid then + self.LastSelectCurGrid:SetSelected(true) + end + + self:ClosePopup() +end + +function XUiEquipAwarenessSuitPrefab:GetShowingPrefabInfo(prefabIndex) + prefabIndex = prefabIndex or self.CurPrefabIndex + return XDataCenter.EquipManager.GetSuitPrefabInfo(prefabIndex) or self.UnSavedPrefabInfo +end + +function XUiEquipAwarenessSuitPrefab:GetSuitPrefabIndexList(tabType) + if tabType == nil then tabType = self.TabType end + local tl = {0} --0对应自定义的那列 + local suitPrefabInfoList = XDataCenter.EquipManager.GetSuitPrefabIndexList() + + for i,suitPrefabIndex in ipairs(suitPrefabInfoList) do + local suitPrefabInfo = self:GetShowingPrefabInfo(suitPrefabIndex) + if tabType == TAB_TYPE.ALL then + if suitPrefabInfo:GetCharacterId() == 0 then + table.insert(tl, suitPrefabIndex) + end + elseif tabType == TAB_TYPE.ONE then + if suitPrefabInfo:GetCharacterId() == self.CharacterId then + table.insert(tl, suitPrefabIndex) + end + end + end + + return tl +end diff --git a/Resources/Scripts/XUi/XUiEquipAwarenessReplace/XUiEquipSuitPrefabConfirm.lua b/Resources/Scripts/XUi/XUiEquipAwarenessReplace/XUiEquipSuitPrefabConfirm.lua new file mode 100644 index 00000000..7d9c6c05 --- /dev/null +++ b/Resources/Scripts/XUi/XUiEquipAwarenessReplace/XUiEquipSuitPrefabConfirm.lua @@ -0,0 +1,20 @@ +local XUiEquipSuitPrefabConfirm = XLuaUiManager.Register(XLuaUi, "UiEquipSuitPrefabConfirm") + +function XUiEquipSuitPrefabConfirm:OnAwake() + self:AutoAddListener() +end + +function XUiEquipSuitPrefabConfirm:OnStart(content, confirmCb) + self.TxtContent.text = content + self.ConfirmCb = confirmCb +end + +function XUiEquipSuitPrefabConfirm:AutoAddListener() + self.BtnClose.CallBack = function() self:Close() end + self.BtnTanchuangClose.CallBack = function() self:Close() end + self.BtnNameCancel.CallBack = function() self:Close() end + self.BtnNameSure.CallBack = function() + self.ConfirmCb() + self:Close() + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiEquipAwarenessReplace/XUiEquipSuitPrefabConflict.lua b/Resources/Scripts/XUi/XUiEquipAwarenessReplace/XUiEquipSuitPrefabConflict.lua new file mode 100644 index 00000000..85cd8658 --- /dev/null +++ b/Resources/Scripts/XUi/XUiEquipAwarenessReplace/XUiEquipSuitPrefabConflict.lua @@ -0,0 +1,34 @@ +local XUiGridSuitPrefabEquip = require("XUi/XUiEquipAwarenessReplace/XUiGridSuitPrefabEquip") + +local XUiEquipSuitPrefabConflict = XLuaUiManager.Register(XLuaUi, "UiEquipSuitPrefabConflict") + +function XUiEquipSuitPrefabConflict:OnAwake() + self:AutoAddListener() +end + +function XUiEquipSuitPrefabConflict:OnStart(conflictInfoList, confirmCb) + self.ConflictInfoList = conflictInfoList + self.ConfirmCb = confirmCb + self:InitGrids() +end + +function XUiEquipSuitPrefabConflict:InitGrids() + self.GridSuitPrefabEquip.gameObject:SetActiveEx(false) + for _, conflictInfo in pairs(self.ConflictInfoList) do + local item = CS.UnityEngine.Object.Instantiate(self.GridSuitPrefabEquip) + local grid = XUiGridSuitPrefabEquip.New(item, self) + grid:Refresh(conflictInfo) + grid.GameObject:SetActiveEx(true) + grid.Transform:SetParent(self.PanelContent.transform, false) + end +end + +function XUiEquipSuitPrefabConflict:AutoAddListener() + self.BtnClose.CallBack = function() self:Close() end + self.BtnTanchuangClose.CallBack = function() self:Close() end + self.BtnNameCancel.CallBack = function() self:Close() end + self.BtnNameSure.CallBack = function() + self.ConfirmCb() + self:Close() + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiEquipAwarenessReplace/XUiEquipSuitPrefabRename.lua b/Resources/Scripts/XUi/XUiEquipAwarenessReplace/XUiEquipSuitPrefabRename.lua new file mode 100644 index 00000000..61ca6b24 --- /dev/null +++ b/Resources/Scripts/XUi/XUiEquipAwarenessReplace/XUiEquipSuitPrefabRename.lua @@ -0,0 +1,35 @@ +local CSXTextManagerGetText = CS.XTextManager.GetText +local MaxNameLength = CS.XGame.Config:GetInt("EquipSuitPrefabNameLength") + +local XUiEquipSuitPrefabRename = XLuaUiManager.Register(XLuaUi, "UiEquipSuitPrefabRename") + +function XUiEquipSuitPrefabRename:OnAwake() + self:AutoAddListener() +end + +function XUiEquipSuitPrefabRename:OnStart(confirmCb) + self.ConfirmCb = confirmCb +end + +function XUiEquipSuitPrefabRename:AutoAddListener() + self.BtnClose.CallBack = function() self:Close() end + self.BtnTanchuangClose.CallBack = function() self:Close() end + self.BtnNameSure.CallBack = function() self:OnBtnNameSure() end + self.BtnNameCancel.CallBack = function() self:Close() end +end + +function XUiEquipSuitPrefabRename:OnBtnNameSure() + local editName = string.gsub(self.InFSigm.text, "^%s*(.-)%s*$", "%1") + if string.len(editName) > 0 then + local utf8Count = self.InFSigm.textComponent.cachedTextGenerator.characterCount - 1 + if utf8Count > MaxNameLength then + XUiManager.TipError(CSXTextManagerGetText("MaxNameLengthTips", MaxNameLength)) + return + end + + self.ConfirmCb(editName) + self:Close() + else + XUiManager.TipError(CSXTextManagerGetText("EquipSuitPrefabRenameLengthError")) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiEquipAwarenessReplace/XUiGridEquip.lua b/Resources/Scripts/XUi/XUiEquipAwarenessReplace/XUiGridEquip.lua new file mode 100644 index 00000000..f621c8a1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiEquipAwarenessReplace/XUiGridEquip.lua @@ -0,0 +1,187 @@ +local PanelUsingWords = CS.XTextManager.GetText("EquipGridUsingWords") +local PanelInPrefabWords = CS.XTextManager.GetText("EquipGridInPrefabWords") +local PanelSelectedWords = CS.XTextManager.GetText("MentorGiftIsSelectedText") +local XUiGridEquip = XClass(nil, "XUiGridEquip") + +function XUiGridEquip:Ctor(ui, clickCb, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self.ClickCb = clickCb + self:InitAutoScript() + self:SetSelected(false) + + XEventManager.AddEventListener(XEventId.EVENT_EQUIP_PUTON_NOTYFY, self.UpdateUsing, self) + XEventManager.AddEventListener(XEventId.EVENT_EQUIP_TAKEOFF_NOTYFY, self.UpdateUsing, self) + XEventManager.AddEventListener(XEventId.EVENT_EQUIP_LOCK_STATUS_CHANGE_NOTYFY, self.UpdateIsLock, self) + XEventManager.AddEventListener(XEventId.EVENT_EQUIP_RECYCLE_STATUS_CHANGE_NOTYFY, self.UpdateIsRecycle, self) + XEventManager.AddEventListener(XEventId.EVENT_EQUIP_BREAKTHROUGH_NOTYFY, self.UpdateBreakthrough, self) +end + +function XUiGridEquip:InitRootUi(rootUi) + self.RootUi = rootUi +end + +function XUiGridEquip:Refresh(equipId,idList) + self.EquipId = equipId + local equip = XDataCenter.EquipManager.GetEquip(equipId) + if not equip then + return + end + + local templateId = equip.TemplateId + + if self.RImgIcon and self.RImgIcon:Exist() then + self.RImgIcon:SetRawImage(XDataCenter.EquipManager.GetEquipIconBagPath(templateId, equip.Breakthrough), nil, true) + end + + --通用的横条品质色 + if self.ImgQuality then + self.RootUi:SetUiSprite(self.ImgQuality, XDataCenter.EquipManager.GetEquipQualityPath(templateId)) + end + + --装备专用的竖条品质色 + if self.ImgEquipQuality then + self.RootUi:SetUiSprite(self.ImgEquipQuality, XDataCenter.EquipManager.GetEquipBgPath(templateId)) + end + + if self.TxtName then + self.TxtName.text = XDataCenter.EquipManager.GetEquipName(templateId) + end + + if self.TxtLevel then + self.TxtLevel.text = equip.Level + end + + if self.PanelSite and self.TxtSite then + local equipSite = XDataCenter.EquipManager.GetEquipSite(equipId) + if equipSite and equipSite ~= XEquipConfig.EquipSite.Weapon then + self.TxtSite.text = "0" .. equipSite + self.PanelSite.gameObject:SetActiveEx(true) + else + self.PanelSite.gameObject:SetActiveEx(false) + end + end + + for i = 1, XEquipConfig.MAX_STAR_COUNT do + if self["ImgGirdStar" .. i] then + if i <= XDataCenter.EquipManager.GetEquipStar(templateId) then + self["ImgGirdStar" .. i].transform.parent.gameObject:SetActiveEx(true) + else + self["ImgGirdStar" .. i].transform.parent.gameObject:SetActiveEx(false) + end + end + end + + for i = 1, XEquipConfig.MAX_RESONANCE_SKILL_COUNT do + local obj = self["ImgResonance" .. i] + if obj then + if XDataCenter.EquipManager.CheckEquipPosResonanced(equipId, i) then + local icon = XEquipConfig.GetEquipResoanceIconPath(XDataCenter.EquipManager.IsEquipPosAwaken(equipId, i)) + self.RootUi:SetUiSprite(obj, icon) + obj.gameObject:SetActiveEx(true) + else + obj.gameObject:SetActiveEx(false) + end + end + end + + self:UpdateIsLock(equipId) + self:UpdateIsRecycle(equipId) + self:UpdateUsing(equipId,idList) + self:UpdateBreakthrough(equipId) +end + +function XUiGridEquip:SetSelected(status) + if XTool.UObjIsNil(self.ImgSelect) then + return + end + self.ImgSelect.gameObject:SetActiveEx(status) +end + +function XUiGridEquip:IsSelected() + return not XTool.UObjIsNil(self.ImgSelect) and self.ImgSelect.gameObject.activeSelf +end + +function XUiGridEquip:UpdateUsing(equipId,idList) + if equipId ~= self.EquipId then return end + if XTool.UObjIsNil(self.PanelUsing) then return end + + if XDataCenter.EquipManager.IsWearing(equipId) then + if not XTool.UObjIsNil(self.TxtUsingOrInSuitPrefab) then + self.TxtUsingOrInSuitPrefab.text = PanelUsingWords + end + self.PanelUsing.gameObject:SetActiveEx(true) + elseif XDataCenter.EquipManager.IsInSuitPrefab(equipId) + and not XTool.UObjIsNil(self.TxtUsingOrInSuitPrefab) then + self.TxtUsingOrInSuitPrefab.text = PanelInPrefabWords + self.PanelUsing.gameObject:SetActiveEx(true) + else + self.PanelUsing.gameObject:SetActiveEx(false) + end + + if idList then + for _,id in pairs(idList) do + if equipId == id then + if not XTool.UObjIsNil(self.TxtUsingOrInSuitPrefab) then + self.TxtUsingOrInSuitPrefab.text = PanelSelectedWords + end + self.PanelUsing.gameObject:SetActiveEx(true) + end + end + end +end + +function XUiGridEquip:UpdateIsLock(equipId) + if equipId ~= self.EquipId then + return + end + if XTool.UObjIsNil(self.ImgLock) then + return + end + self.ImgLock.gameObject:SetActiveEx(XDataCenter.EquipManager.IsLock(self.EquipId)) +end + +function XUiGridEquip:UpdateIsRecycle(equipId) + if equipId ~= self.EquipId then + return + end + if XTool.UObjIsNil(self.ImgLaJi) then + return + end + self.ImgLaJi.gameObject:SetActiveEx(XDataCenter.EquipManager.IsRecycle(self.EquipId)) +end + +function XUiGridEquip:UpdateBreakthrough(equipId) + if equipId ~= self.EquipId then + return + end + if XTool.UObjIsNil(self.ImgBreakthrough) then + return + end + + local icon = XDataCenter.EquipManager.GetEquipBreakThroughSmallIcon(self.EquipId) + if icon then + self.RootUi:SetUiSprite(self.ImgBreakthrough, icon) + self.ImgBreakthrough.gameObject:SetActiveEx(true) + else + self.ImgBreakthrough.gameObject:SetActiveEx(false) + end +end + +function XUiGridEquip:InitAutoScript() + XTool.InitUiObject(self) + if not XTool.UObjIsNil(self.PanelUsing) then + local textGo = self.PanelUsing:Find("TextUsing") + self.TxtUsingOrInSuitPrefab = textGo and textGo:GetComponent("Text") + end + CsXUiHelper.RegisterClickEvent(self.BtnClick, function() self:OnBtnClickClick() end) +end + +function XUiGridEquip:OnBtnClickClick() + if self.ClickCb then + self.ClickCb(self.EquipId, self) + end +end + +return XUiGridEquip \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiEquipAwarenessReplace/XUiGridSuitDetail.lua b/Resources/Scripts/XUi/XUiEquipAwarenessReplace/XUiGridSuitDetail.lua new file mode 100644 index 00000000..bacca5e5 --- /dev/null +++ b/Resources/Scripts/XUi/XUiEquipAwarenessReplace/XUiGridSuitDetail.lua @@ -0,0 +1,205 @@ +local MAX_SKILL_DES_LINE_TWO = 2 -- 二件套技能说明最大行数 +local MAX_SKILL_DES_LINE_FOUR = 4 -- 四件套技能说明最大行数 + +local XUiGridSuitDetail = XClass(nil, "XUiGridSuitDetail") + +function XUiGridSuitDetail:Ctor(ui, rootUi, clickCb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self.ClickCb = clickCb + self:InitAutoScript() + XTool.InitUiObject(self) +end + +local singleCharWidth = nil + +function XUiGridSuitDetail:InitRootUi(rootUi) + self.RootUi = rootUi +end + +function XUiGridSuitDetail:Refresh(suitId, defaultSuitIds, isBigIcon, desPrefix, site) + self.SuitId = suitId + + if self.RImgIcon then + if XEquipConfig.IsDefaultSuitId(suitId) then + self.RImgIcon.gameObject:SetActive(false) + else + local icon + if isBigIcon then + icon = XDataCenter.EquipManager.GetSuitBigIconBagPath(suitId) + else + icon = XDataCenter.EquipManager.GetSuitIconBagPath(suitId) + end + + self.RImgIcon:SetRawImage(icon) + self.RImgIcon.gameObject:SetActive(true) + end + end + --意识套装没有质量等级,默认用套装第一个部位的品级 + if self.ImgQuality then + if XEquipConfig.IsDefaultSuitId(suitId) then + self.ImgQuality.gameObject:SetActive(false) + else + local ids = XDataCenter.EquipManager.GetEquipTemplateIdsBySuitId(self.SuitId) + self.RootUi:SetUiSprite(self.ImgQuality, XDataCenter.EquipManager.GetEquipBgPath(ids[1])) + self.ImgQuality.gameObject:SetActive(true) + end + end + + if self.ImgDefaultIcon then + self.ImgDefaultIcon.gameObject:SetActive(XEquipConfig.IsDefaultSuitId(suitId)) + end + + if self.ImgDefaultIconIsomer then + self.ImgDefaultIconIsomer.gameObject:SetActive(suitId == XEquipConfig.DEFAULT_SUIT_ID.Isomer) + end + + if self.ImgDefaultIconNormal then + self.ImgDefaultIconNormal.gameObject:SetActive(suitId == XEquipConfig.DEFAULT_SUIT_ID.Normal) + end + + if self.TxtName then + if XEquipConfig.IsDefaultSuitId(suitId) then + self.PanelName.gameObject:SetActive(false) + else + self.TxtName.text = XDataCenter.EquipManager.GetSuitName(suitId) + self.PanelName.gameObject:SetActive(true) + end + end + + if self.TxtDes then + local des = XDataCenter.EquipManager.GetSuitDescription(suitId) + self.TxtDes.text = desPrefix and string.format("(%s)", des) or des + end + + if self.TxtNum then + local suitNum + + if suitId == XEquipConfig.DEFAULT_SUIT_ID.Normal then + suitNum = XDataCenter.EquipManager.GetAwarenessCount(XCharacterConfigs.CharacterType.Normal) + elseif suitId == XEquipConfig.DEFAULT_SUIT_ID.Normal then + suitNum = XDataCenter.EquipManager.GetAwarenessCount(XCharacterConfigs.CharacterType.Isomer) + else + suitNum = XDataCenter.EquipManager.GetEquipCountInSuit(suitId, site) + end + + self.TxtNum.text = suitNum + end + + if self.ImgUp then + self.ImgUp.gameObject:SetActive(false) + end + + for i = 1, XEquipConfig.MAX_STAR_COUNT do + if self["ImgGirdStar" .. i] then + if i <= XDataCenter.EquipManager.GetSuitStar(suitId) then + self["ImgGirdStar" .. i].gameObject:SetActive(true) + else + self["ImgGirdStar" .. i].gameObject:SetActive(false) + end + end + end + + local skillDesList = XDataCenter.EquipManager.GetSuitActiveSkillDesList(suitId) + for i = 1, XEquipConfig.MAX_SUIT_SKILL_COUNT do + local textObj = self["TxtSkillDesDetail" .. i] + if textObj then + if skillDesList[i] then + local skillDes = skillDesList[i].SkillDes + textObj.text = skillDes + if desPrefix then + XScheduleManager.ScheduleOnce(function() + local rect = textObj.gameObject:GetComponent("RectTransform") + local desWidth = XUiHelper.CalcTextWidth(textObj) + local txtWidth = rect.sizeDelta.x + + local maxLine = i == 1 and MAX_SKILL_DES_LINE_TWO or MAX_SKILL_DES_LINE_FOUR + local maxDesWidth = maxLine * txtWidth + --英文服特殊逻辑,非等宽字体,计算字符要选个差不多的字符 + --local singleChar = string.Utf8Sub(skillDes, 1, 1) + if singleCharWidth == nil then + textObj.text = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" + singleCharWidth = XUiHelper.CalcTextWidth(textObj) / 52 + end + + local spaceFix = 5 --你省略号长度也得算啊老弟 + local maxCharNum = singleCharWidth ~= 0 and (math.ceil(maxDesWidth / singleCharWidth) - spaceFix - 6) or spaceFix + textObj.text = desWidth > maxDesWidth and string.Utf8Sub(skillDes, 1, maxCharNum) .. [[......]] or skillDes + end, 0) + end + textObj.gameObject:SetActive(true) + else + textObj.gameObject:SetActive(false) + end + end + end + + --装备专用的竖条品质色 + if self.ImgEquipQuality then + self.RootUi:SetUiSprite(self.ImgEquipQuality, XDataCenter.EquipManager.GetSuitQualityIcon(suitId)) + end +end + +function XUiGridSuitDetail:SetShowUp(isShow) + if self.ImgUp then + self.ImgUp.gameObject:SetActive(isShow) + end +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiGridSuitDetail:InitAutoScript() + self:AutoInitUi() + XTool.InitUiObject(self) + self:AutoAddListener() +end + +function XUiGridSuitDetail:AutoInitUi() + self.RImgIcon = XUiHelper.TryGetComponent(self.Transform, "RImgIcon", "RawImage") + self.ImgDefaultIcon = XUiHelper.TryGetComponent(self.Transform, "ImgDefaultIcon", "Image") + self.TxtNum = XUiHelper.TryGetComponent(self.Transform, "ImageNumBg/TxtNum", "Text") + self.PanelName = XUiHelper.TryGetComponent(self.Transform, "PanelName", nil) + self.TxtName = XUiHelper.TryGetComponent(self.Transform, "PanelName/TxtName", "Text") + self.PanelSkillDes = XUiHelper.TryGetComponent(self.Transform, "PanelSkillDes", nil) + self.TxtSkillDesDetail1 = XUiHelper.TryGetComponent(self.Transform, "PanelSkillDes/Image1/TxtSkillDesDetail1", "Text") + self.TxtSkillDesDetail2 = XUiHelper.TryGetComponent(self.Transform, "PanelSkillDes/Image2/TxtSkillDesDetail2", "Text") + self.TxtSkillDesDetail3 = XUiHelper.TryGetComponent(self.Transform, "PanelSkillDes/Image3/TxtSkillDesDetail3", "Text") + self.ImgGirdStar1 = XUiHelper.TryGetComponent(self.Transform, "Stars/PaneStar1/ImgGirdStar1", "Image") + self.ImgGirdStar2 = XUiHelper.TryGetComponent(self.Transform, "Stars/PaneStar2/ImgGirdStar2", "Image") + self.ImgGirdStar3 = XUiHelper.TryGetComponent(self.Transform, "Stars/PaneStar3/ImgGirdStar3", "Image") + self.ImgGirdStar4 = XUiHelper.TryGetComponent(self.Transform, "Stars/PaneStar4/ImgGirdStar4", "Image") + self.ImgGirdStar5 = XUiHelper.TryGetComponent(self.Transform, "Stars/PaneStar5/ImgGirdStar5", "Image") + self.ImgGirdStar6 = XUiHelper.TryGetComponent(self.Transform, "Stars/PaneStar6/ImgGirdStar6", "Image") + self.BtnClick = XUiHelper.TryGetComponent(self.Transform, "BtnClick", "Button") + self.ImgUp = XUiHelper.TryGetComponent(self.Transform, "ImgUp", "Image") + self.ImgQuality = XUiHelper.TryGetComponent(self.Transform, "ImgQuality", "Image") + self.TxtDes = XUiHelper.TryGetComponent(self.Transform, "TxtDes", "Text") +end + +function XUiGridSuitDetail:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiGridSuitDetail:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiGridSuitDetail:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiGridSuitDetail:AutoAddListener() + self:RegisterClickEvent(self.BtnClick, self.OnBtnClickClick) +end +-- auto +function XUiGridSuitDetail:OnBtnClickClick() + if self.ClickCb then self.ClickCb(self.SuitId, self) end +end + +return XUiGridSuitDetail \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiEquipAwarenessReplace/XUiGridSuitPrefab.lua b/Resources/Scripts/XUi/XUiEquipAwarenessReplace/XUiGridSuitPrefab.lua new file mode 100644 index 00000000..2ef43b9c --- /dev/null +++ b/Resources/Scripts/XUi/XUiEquipAwarenessReplace/XUiGridSuitPrefab.lua @@ -0,0 +1,55 @@ +local CSXTextManagerGetText = CS.XTextManager.GetText + +local CurSuitName = CSXTextManagerGetText("EquipSuitPrefabCurName") + +local XUiGridSuitPrefab = XClass(nil, "XUiGridSuitPrefab") + +function XUiGridSuitPrefab:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.PanelSelect.gameObject:SetActiveEx(false) +end + +function XUiGridSuitPrefab:Refresh(suitPrefabInfo, index, isPreafabSaved) + -- 套装预设序号 + if isPreafabSaved then + if index < 10 then + self.TxtOrder.text = "0" .. index + else + self.TxtOrder.text = index + end + self.TxtOrder.gameObject:SetActiveEx(true) + else + self.TxtOrder.gameObject:SetActiveEx(false) + end + + -- 套装预设图标 + local presentSuitId = suitPrefabInfo:GetPresentSuitId() + if presentSuitId then + self.RImgIcon:SetRawImage(XDataCenter.EquipManager.GetSuitBigIconBagPath(presentSuitId)) + self.ImgDefaultIcon.gameObject:SetActiveEx(false) + self.RImgIcon.gameObject:SetActiveEx(true) + else + self.ImgDefaultIcon.gameObject:SetActiveEx(true) + self.RImgIcon.gameObject:SetActiveEx(false) + end + + -- 套装预设名字 + self.TxtName.text = isPreafabSaved and suitPrefabInfo:GetName() or CurSuitName + + -- 套装预设数量 + local equipCount = suitPrefabInfo:GetEquipCount() + local maxCount = XEquipConfig.MAX_SUIT_COUNT + if equipCount == maxCount then + self.TxtNum.text = CSXTextManagerGetText("EquipSuitPrefabCountMax", equipCount, maxCount) + else + self.TxtNum.text = CSXTextManagerGetText("EquipSuitPrefabCount", equipCount, maxCount) + end +end + +function XUiGridSuitPrefab:SetSelected(selected) + self.PanelSelect.gameObject:SetActiveEx(selected) +end + +return XUiGridSuitPrefab \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiEquipAwarenessReplace/XUiGridSuitPrefabEquip.lua b/Resources/Scripts/XUi/XUiEquipAwarenessReplace/XUiGridSuitPrefabEquip.lua new file mode 100644 index 00000000..4942be71 --- /dev/null +++ b/Resources/Scripts/XUi/XUiEquipAwarenessReplace/XUiGridSuitPrefabEquip.lua @@ -0,0 +1,19 @@ +local XUiGridEquip = require("XUi/XUiEquipAwarenessReplace/XUiGridEquip") + +local XUiGridSuitPrefabEquip = XClass(nil, "XUiGridSuitPrefabEquip") + +function XUiGridSuitPrefabEquip:Ctor(ui, parent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Parent = parent + XTool.InitUiObject(self) +end + +function XUiGridSuitPrefabEquip:Refresh(conflictInfo) + self.RImgHead:SetRawImage(XDataCenter.CharacterManager.GetCharRoundnessHeadIcon(conflictInfo.CharacterId)) + local grid = XUiGridEquip.New(self.GridEquip) + grid:InitRootUi(self.Parent) + grid:Refresh(conflictInfo.EquipId) +end + +return XUiGridSuitPrefabEquip \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiEquipAwarenessReplace/XUiPanelEquipScroll.lua b/Resources/Scripts/XUi/XUiEquipAwarenessReplace/XUiPanelEquipScroll.lua new file mode 100644 index 00000000..a84cfded --- /dev/null +++ b/Resources/Scripts/XUi/XUiEquipAwarenessReplace/XUiPanelEquipScroll.lua @@ -0,0 +1,120 @@ +local XUiGridEquip = require("XUi/XUiEquipAwarenessReplace/XUiGridEquip") +local XUiPanelEquipScroll = XClass(nil, "XUiPanelEquipScroll") + +--multiSelect复用 +function XUiPanelEquipScroll:Ctor(rootUi, ui, gridTouchCb, gridReloadCb, multiSelect, gridSelectCheckCb) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.GridTouchCb = gridTouchCb + self.GridReloadCb = gridReloadCb + self.MultiSelect = multiSelect + self.GridSelectCheckCb = gridSelectCheckCb + self:InitDynamicTable() +end + +function XUiPanelEquipScroll:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.GameObject) + self.DynamicTable:SetDelegate(self) + self.DynamicTable:SetProxy(XUiGridEquip) + self.LastSelectIds = {} +end + +function XUiPanelEquipScroll:UpdateEquipGridList(equipIdList, notResetSelect) + if not notResetSelect then + self.LastSelectIds = {} + end + self.EquipIdList = equipIdList or {} + self.DynamicTable:UpdateViewSize() + self.DynamicTable:SetDataSource(self.EquipIdList) + self.DynamicTable:ReloadDataSync(#self.EquipIdList > 0 and not notResetSelect and 1 or -1) +end + +function XUiPanelEquipScroll:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:InitRootUi(self.RootUi) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local equipId = self.EquipIdList[index] + grid:Refresh(equipId, self.RootUi.SelectedEquipIdList) + + if self.LastSelectIds[equipId] then + grid:SetSelected(true) + self.LastSelectGrid = grid + else + grid:SetSelected(false) + end + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + local equipId = self.EquipIdList[index] + + --不是多选 + if not self.MultiSelect and self.LastSelectGrid then + self.LastSelectGrid:SetSelected(false) + end + + local isSelected = grid:IsSelected() + --不能选中return + if not isSelected and self.GridSelectCheckCb and not self.GridSelectCheckCb() then + return + end + + --复选取消 + if self.MultiSelect then + isSelected = not isSelected + else + isSelected = true + end + + --普通选中时清除上一条记录 + if not self.MultiSelect and self.LastSelectId then + self.LastSelectIds[self.LastSelectId] = nil + end + + self.LastSelectId = equipId + self.LastSelectIds[self.LastSelectId] = isSelected + + self.LastSelectGrid = grid + self.LastSelectGrid:SetSelected(isSelected) + + if self.GridTouchCb then + self.GridTouchCb(equipId, isSelected) + end + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_RELOAD_COMPLETED then + if self.GridReloadCb then + self.GridReloadCb() + end + end +end + +function XUiPanelEquipScroll:SelectGrids(equipIds) + self.LastSelectIds = equipIds + self.DynamicTable:ReloadDataSync(#self.EquipIdList > 0 and 1 or -1) +end + +function XUiPanelEquipScroll:ResetSelectGrids() + self.LastSelectIds = {} + self.LastSelectGrid = nil + self.LastSelectId = nil + self.DynamicTable:ReloadDataSync(#self.EquipIdList > 0 and 1 or -1) +end + +function XUiPanelEquipScroll:ResetSelectGrid() + if self.LastSelectGrid then + self.LastSelectGrid:SetSelected(false) + self.LastSelectGrid = nil + self.LastSelectIds[self.LastSelectId] = nil + self.LastSelectId = nil + end +end + +function XUiPanelEquipScroll:GuideGetDynamicTableIndex(id) + for i, v in ipairs(self.EquipIdList) do + local equip = XDataCenter.EquipManager.GetEquip(v) + if tostring(equip.TemplateId) == id then + return i + end + end + + return -1 +end + +return XUiPanelEquipScroll \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiEquipAwarenessReplace/XUiPanelSuitDetailScroll.lua b/Resources/Scripts/XUi/XUiEquipAwarenessReplace/XUiPanelSuitDetailScroll.lua new file mode 100644 index 00000000..b834cea4 --- /dev/null +++ b/Resources/Scripts/XUi/XUiEquipAwarenessReplace/XUiPanelSuitDetailScroll.lua @@ -0,0 +1,45 @@ +local XUiGridSuitDetail = require("XUi/XUiEquipAwarenessReplace/XUiGridSuitDetail") +local XUiPanelSuitDetailScroll = XClass(nil, "XUiPanelSuitDetailScroll") + +function XUiPanelSuitDetailScroll:Ctor(rootUi, ui, gridTouchCb, gridReloadCb) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.GridTouchCb = gridTouchCb + self.GridReloadCb = gridReloadCb + XTool.InitUiObject(self) + self:InitDynamicTable() +end + +function XUiPanelSuitDetailScroll:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.GameObject) + self.DynamicTable:SetDelegate(self) + self.DynamicTable:SetProxy(XUiGridSuitDetail) +end + +function XUiPanelSuitDetailScroll:UpdateEquipGridList(suitIdList, _, selelctSite) + self.SuitIdList = suitIdList or {} + self.SelelctSite = selelctSite + self.DynamicTable:SetDataSource(self.SuitIdList) + self.DynamicTable:ReloadDataASync(#self.SuitIdList > 0 and 1 or -1) +end + +function XUiPanelSuitDetailScroll:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:InitRootUi(self.RootUi) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local suitId = self.SuitIdList[index] + grid:Refresh(suitId, nil, nil, true, self.SelelctSite) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + local suitId = self.SuitIdList[index] + if self.GridTouchCb then + self.GridTouchCb(suitId) + end + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_RELOAD_COMPLETED then + if self.GridReloadCb then + self.GridReloadCb() + end + end +end + +return XUiPanelSuitDetailScroll \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiEquipAwarenessReplace/XUiPanelSuitSimpleScroll.lua b/Resources/Scripts/XUi/XUiEquipAwarenessReplace/XUiPanelSuitSimpleScroll.lua new file mode 100644 index 00000000..37c6e0f2 --- /dev/null +++ b/Resources/Scripts/XUi/XUiEquipAwarenessReplace/XUiPanelSuitSimpleScroll.lua @@ -0,0 +1,44 @@ +local XUiGridSuitDetail = require("XUi/XUiEquipAwarenessReplace/XUiGridSuitDetail") +local XUiPanelSuitSimpleScroll = XClass(nil, "XUiPanelSuitSimpleScroll") + +function XUiPanelSuitSimpleScroll:Ctor(rootUi, ui, gridTouchCb, gridReloadCb) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.GridTouchCb = gridTouchCb + self.GridReloadCb = gridReloadCb + self:InitDynamicTable() +end + +function XUiPanelSuitSimpleScroll:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.GameObject) + self.DynamicTable:SetDelegate(self) + self.DynamicTable:SetProxy(XUiGridSuitDetail) +end + +function XUiPanelSuitSimpleScroll:UpdateEquipGridList(suitIdList, _, selelctSite) + self.SuitIdList = suitIdList or {} + self.SelelctSite = selelctSite + self.DynamicTable:SetDataSource(self.SuitIdList) + self.DynamicTable:ReloadDataASync(#self.SuitIdList > 0 and 1 or -1) +end + +function XUiPanelSuitSimpleScroll:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:InitRootUi(self.RootUi) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local suitId = self.SuitIdList[index] + grid:Refresh(suitId, nil, nil, nil, self.SelelctSite) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + local suitId = self.SuitIdList[index] + if self.GridTouchCb then + self.GridTouchCb(suitId) + end + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_RELOAD_COMPLETED then + if self.GridReloadCb then + self.GridReloadCb() + end + end +end + +return XUiPanelSuitSimpleScroll \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiEquipBreakThrough/XUiEquipBreakThrough.lua b/Resources/Scripts/XUi/XUiEquipBreakThrough/XUiEquipBreakThrough.lua new file mode 100644 index 00000000..18018ac0 --- /dev/null +++ b/Resources/Scripts/XUi/XUiEquipBreakThrough/XUiEquipBreakThrough.lua @@ -0,0 +1,132 @@ +local CONDITION_COLOR = { + [true] = CS.UnityEngine.Color.black, + [false] = CS.UnityEngine.Color.gray, +} + +local XUiGridCostItem = require("XUi/XUiEquipBreakThrough/XUiGridCostItem") +local XUiGridEquipReplaceAttr = require("XUi/XUiEquipReplaceNew/XUiGridEquipReplaceAttr") + +local XUiEquipBreakThrough = XLuaUiManager.Register(XLuaUi, "UiEquipBreakThrough") + +function XUiEquipBreakThrough:OnAwake() + self:InitAutoScript() + self.GridEquipReplaceAttr.gameObject:SetActive(false) + self.GridCostItem.gameObject:SetActive(false) + self.TxtPass.gameObject:SetActive(false) + self.TxtNotPass.gameObject:SetActive(false) +end + +function XUiEquipBreakThrough:OnStart(equipId, rootUi) + self.EquipId = equipId + self.RootUi = rootUi +end + +function XUiEquipBreakThrough:OnEnable() + self:InitEquipPreInfo() + self:InitBreakthroughCondition() + self:InitBreakthroughConsume() + self:UpdateEquipBreakThrough() +end + +function XUiEquipBreakThrough:OnGetEvents() + return { XEventId.EVENT_EQUIP_BREAKTHROUGH_NOTYFY } +end + +function XUiEquipBreakThrough:OnNotify(evt, ...) + local args = { ... } + local equipId = args[1] + if equipId ~= self.EquipId then return end + + if evt == XEventId.EVENT_EQUIP_BREAKTHROUGH_NOTYFY then + CS.XAudioManager.PlaySound(XSoundManager.UiBasicsMusic.UiEquip_BreakThroughPopUp) + XLuaUiManager.Open("UiEquipBreakThroughPopUp", self.NextLevel, self.CurAttrMap, self.PreAttrMap, function() + self.RootUi:OpenOneChildUi("UiEquipStrengthen", self.EquipId, self.RootUi) + end) + end +end + +function XUiEquipBreakThrough:InitEquipPreInfo() + local equip = XDataCenter.EquipManager.GetEquip(self.EquipId) + self.NextLevel = XDataCenter.EquipManager.GetBreakthroughLevelLimitNext(self.EquipId) + self.CurAttrMap = XDataCenter.EquipManager.GetBreakthroughPromotedAttrMap(self.EquipId) + self.PreAttrMap = XDataCenter.EquipManager.GetBreakthroughPromotedAttrMap(self.EquipId, 1) + + self.TxtCurLevel.text = XDataCenter.EquipManager.GetBreakthroughLevelLimit(self.EquipId) + self.TxtNextLevel.text = self.NextLevel + self.TxtCurDes.text = CS.XTextManager.GetText("EquipBreakThroughDes" .. equip.Breakthrough) + self.TxtNextDes.text = CS.XTextManager.GetText("EquipBreakThroughDes" .. (equip.Breakthrough + 1)) + + self.AttrGridList = self.AttrGridList or {} + for attrOrder, attrInfo in pairs(self.CurAttrMap) do + local attrIndex = attrInfo.AttrIndex + local grid = self.AttrGridList[attrIndex] + if not grid then + local ui = CS.UnityEngine.Object.Instantiate(self.GridEquipReplaceAttr) + grid = XUiGridEquipReplaceAttr.New(ui, CS.XTextManager.GetText("EquipBreakThroughPopUpAttrPrefix", attrInfo.Name)) + grid.Transform:SetParent(self.PanelAttrParent, false) + grid.GameObject:SetActive(true) + self.AttrGridList[attrIndex] = grid + end + self.AttrGridList[attrIndex]:UpdateData(attrInfo.Value, self.PreAttrMap[attrOrder].Value) + end +end + +function XUiEquipBreakThrough:InitBreakthroughCondition() + local conditionId = XDataCenter.EquipManager.GetBreakthroughCondition(self.EquipId) + if not conditionId or conditionId == 0 then + return + end + + local conditionCfg = XConditionManager.GetConditionTemplate(conditionId) + if XConditionManager.CheckCondition(conditionId) then + self.TxtPass.text = conditionCfg.Desc + self.TxtPass.gameObject:SetActive(true) + else + self.TxtNotPass.text = conditionCfg.Desc + self.TxtNotPass.gameObject:SetActive(true) + end +end + +function XUiEquipBreakThrough:InitBreakthroughConsume() + local costMoney = XDataCenter.EquipManager.GetBreakthroughUseMoney(self.EquipId) + self.TxtCost.text = costMoney + self.TxtCost.color = CONDITION_COLOR[XDataCenter.ItemManager.GetCoinsNum() >= costMoney] + + self.GridCostItems = self.GridCostItems or {} + local consumeItems = XDataCenter.EquipManager.GetBreakthroughConsumeItems(self.EquipId) + for index, item in ipairs(consumeItems) do + local grid = self.GridCostItems[index] + if not grid then + local ui = CS.UnityEngine.Object.Instantiate(self.GridCostItem) + grid = XUiGridCostItem.New(self, ui) + grid.Transform:SetParent(self.PanelCostItem, false) + grid.GameObject:SetActive(true) + self.GridCostItems[index] = grid + end + grid:Refresh(item.Id, item.Count) + end + + for i = #consumeItems + 1, #self.GridCostItems do + self.GridCostItems[i].gameObject:SetActive(false) + end +end + +function XUiEquipBreakThrough:UpdateEquipBreakThrough() + local preBreakthrough = 1 + self:SetUiSprite(self.ImgBreakthrough, XDataCenter.EquipManager.GetEquipBreakThroughBigIcon(self.EquipId)) + self:SetUiSprite(self.ImgBreakthrough2, XDataCenter.EquipManager.GetEquipBreakThroughBigIcon(self.EquipId, preBreakthrough)) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiEquipBreakThrough:InitAutoScript() + self:AutoAddListener() +end + +function XUiEquipBreakThrough:AutoAddListener() + self:RegisterClickEvent(self.BtnBreak, self.OnBtnBreakClick) +end +-- auto +function XUiEquipBreakThrough:OnBtnBreakClick() + XDataCenter.EquipManager.Breakthrough(self.EquipId) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiEquipBreakThrough/XUiEquipBreakThroughPopUp.lua b/Resources/Scripts/XUi/XUiEquipBreakThrough/XUiEquipBreakThroughPopUp.lua new file mode 100644 index 00000000..dd2b74ed --- /dev/null +++ b/Resources/Scripts/XUi/XUiEquipBreakThrough/XUiEquipBreakThroughPopUp.lua @@ -0,0 +1,61 @@ +local CLOSE_TIME = 2 + +local XUiGridEquipReplaceAttr = require("XUi/XUiEquipReplaceNew/XUiGridEquipReplaceAttr") + +local XUiEquipBreakThroughPopUp = XLuaUiManager.Register(XLuaUi, "UiEquipBreakThroughPopUp") + +function XUiEquipBreakThroughPopUp:OnAwake() + self.GridEquipReplaceAttr.gameObject:SetActive(false) +end + +function XUiEquipBreakThroughPopUp:OnStart(nextLevel, curAttrMap, preAttrMap, closeCb) + self.NextLevel = nextLevel + self.CurAttrMap = curAttrMap + self.PreAttrMap = preAttrMap + self.CloseCb = closeCb + self.BtnClose.CallBack = function() + self:Close() + end +end + +function XUiEquipBreakThroughPopUp:OnEnable() + self:InitEquipPreInfo() + self:AddCloseTimer() +end + +function XUiEquipBreakThroughPopUp:OnDestroy() + self:ClearCloseTimer() + if self.CloseCb then self.CloseCb() end +end + +function XUiEquipBreakThroughPopUp:InitEquipPreInfo() + self.TxtNextLevel.text = self.NextLevel + + self.AttrGridList = {} + for attrIndex, attrInfo in pairs(self.CurAttrMap) do + local ui = CS.UnityEngine.Object.Instantiate(self.GridEquipReplaceAttr) + self.AttrGridList[attrIndex] = XUiGridEquipReplaceAttr.New(ui, CS.XTextManager.GetText("EquipBreakThroughPopUpAttrPrefix", attrInfo.Name)) + self.AttrGridList[attrIndex].Transform:SetParent(self.PanelAttrParent, false) + self.AttrGridList[attrIndex].GameObject:SetActive(true) + self.AttrGridList[attrIndex]:UpdateData(attrInfo.Value, self.PreAttrMap[attrIndex].Value) + end +end + +function XUiEquipBreakThroughPopUp:AddCloseTimer() + self:ClearCloseTimer() + local time = 0 + local function action() + time = time + 1 + if time == CLOSE_TIME then + self:Close() + end + end + self.Timer = XScheduleManager.Schedule(action, XScheduleManager.SECOND, CLOSE_TIME, 0) +end + +function XUiEquipBreakThroughPopUp:ClearCloseTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiEquipBreakThrough/XUiEquipCanBreakthroughTip.lua b/Resources/Scripts/XUi/XUiEquipBreakThrough/XUiEquipCanBreakthroughTip.lua new file mode 100644 index 00000000..8f5a44fd --- /dev/null +++ b/Resources/Scripts/XUi/XUiEquipBreakThrough/XUiEquipCanBreakthroughTip.lua @@ -0,0 +1,35 @@ +local XUiEquipCanBreakthroughTip = XLuaUiManager.Register(XLuaUi, "UiEquipCanBreakthroughTip") + +function XUiEquipCanBreakthroughTip:OnStart(equipId, changeTxt, closeCb, setMask) + self.EquipId = equipId + self.CloseCb = closeCb + self.SetMask = setMask + + if changeTxt then + self.TxtDes.text = changeTxt + self.ChangeTxt = true + end +end + +function XUiEquipCanBreakthroughTip:OnEnable() + if self.SetMask then + self:PlayAnimationWithMask("AnimShow", function() + self:CloseSelf() + end) + else + self:PlayAnimation("AnimShow", function() + self:CloseSelf() + end) + end +end + +function XUiEquipCanBreakthroughTip:OnDestroy() + CsXGameEventManager.Instance:Notify(XEventId.EVENT_EQUIP_CAN_BREAKTHROUGH_TIP_CLOSE, self.EquipId) + self.SetMask = nil +end + +function XUiEquipCanBreakthroughTip:CloseSelf() + if not self.GameObject.activeInHierarchy then return end + self:Close() + if self.CloseCb then self.CloseCb() end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiEquipBreakThrough/XUiEquipLevelUpTips.lua b/Resources/Scripts/XUi/XUiEquipBreakThrough/XUiEquipLevelUpTips.lua new file mode 100644 index 00000000..2babc455 --- /dev/null +++ b/Resources/Scripts/XUi/XUiEquipBreakThrough/XUiEquipLevelUpTips.lua @@ -0,0 +1,47 @@ +local CLOSE_TIME = 2 + +local XUiEquipLevelUpTips = XLuaUiManager.Register(XLuaUi, "UiEquipLevelUpTips") + +function XUiEquipLevelUpTips:OnStart(tipStr, closeCb) + self.TipStr = tipStr + self.CloseCb = closeCb + self.BtnClose.CallBack = function() + self:Close() + end +end + +function XUiEquipLevelUpTips:OnEnable() + self:UpdateView() + self:AddCloseTimer() +end + +function XUiEquipLevelUpTips:OnDisable() + self:ClearCloseTimer() +end + +function XUiEquipLevelUpTips:OnDestroy() + if self.CloseCb then self.CloseCb() end +end + +function XUiEquipLevelUpTips:UpdateView() + self.TxtDes.text = self.TipStr +end + +function XUiEquipLevelUpTips:AddCloseTimer() + self:ClearCloseTimer() + local time = 0 + local function action() + time = time + 1 + if time == CLOSE_TIME then + self:Close() + end + end + self.Timer = XScheduleManager.Schedule(action, XScheduleManager.SECOND, CLOSE_TIME, 0) +end + +function XUiEquipLevelUpTips:ClearCloseTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiEquipBreakThrough/XUiGridCostItem.lua b/Resources/Scripts/XUi/XUiEquipBreakThrough/XUiGridCostItem.lua new file mode 100644 index 00000000..846ef494 --- /dev/null +++ b/Resources/Scripts/XUi/XUiEquipBreakThrough/XUiGridCostItem.lua @@ -0,0 +1,73 @@ +local CONDITION_COLOR = { + [true] = CS.UnityEngine.Color.black, + [false] = CS.UnityEngine.Color.red, +} + +local XUiGridCostItem = XClass(nil, "XUiGridCostItem") + +function XUiGridCostItem:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + + self:InitAutoScript() +end + +function XUiGridCostItem:Refresh(itemId, needCount) + self.ItemId = itemId + self.NeedCount = needCount + + self:InitItemInfo() + self:UpdateHaveCount() + + XDataCenter.ItemManager.AddCountUpdateListener(itemId, function() + self:UpdateHaveCount() + end, self.TxtHaveCount) +end + +function XUiGridCostItem:InitItemInfo() + local goodsShowParams = XGoodsCommonManager.GetGoodsShowParamsByTemplateId(self.ItemId) + + self.RImgIcon:SetRawImage(goodsShowParams.Icon) + XUiHelper.SetQualityIcon(self.RootUi, self.ImgQuality, goodsShowParams.Quality) + self.TxtNeedCount.text = "/" .. self.NeedCount +end + +function XUiGridCostItem:UpdateHaveCount() + local haveCount = XDataCenter.ItemManager.GetCount(self.ItemId) + + self.TxtHaveCount.text = haveCount + self.TxtHaveCount.color = CONDITION_COLOR[haveCount >= self.NeedCount] +end + +function XUiGridCostItem:InitAutoScript() + XTool.InitUiObject(self) + self:AutoAddListener() +end + +function XUiGridCostItem:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiGridCostItem:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiGridCostItem:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiGridCostItem:AutoAddListener() + self:RegisterClickEvent(self.BtnClick, self.OnBtnClickClick) +end + +function XUiGridCostItem:OnBtnClickClick() + XLuaUiManager.Open("UiTip", XDataCenter.ItemManager.GetItem(self.ItemId)) +end + +return XUiGridCostItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiEquipDetail/XUiEquipDetail.lua b/Resources/Scripts/XUi/XUiEquipDetail/XUiEquipDetail.lua new file mode 100644 index 00000000..2bcad3dc --- /dev/null +++ b/Resources/Scripts/XUi/XUiEquipDetail/XUiEquipDetail.lua @@ -0,0 +1,282 @@ +local CSTextManager = CS.XTextManager + +local XUiEquipDetail = XLuaUiManager.Register(XLuaUi, "UiEquipDetail") + +function XUiEquipDetail:OnAwake() + self:InitAutoScript() + + XUiEquipDetail.BtnTabIndex = XEquipConfig.EquipDetailBtnTabIndex + + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) +end + +--参数isPreview为true时是装备详情预览,传templateId进来 +--characterId只有需要判断武器共鸣特效时才传 +function XUiEquipDetail:OnStart(equipId, isPreview, characterId, forceShowBindCharacter, childUiIndex, openUiType) + self.IsPreview = isPreview + self.EquipId = equipId + self.CharacterId = characterId + self.ForceShowBindCharacter = forceShowBindCharacter + self.TemplateId = isPreview and self.EquipId or XDataCenter.EquipManager.GetEquipTemplateId(equipId) + self.OpenUiType = openUiType + + local sceneRoot = self.UiSceneInfo.Transform + local root = self.UiModelGo.transform + self.PanelWeapon = root:FindTransform("PanelWeapon") + self.PanelWeaponPlane = sceneRoot:FindTransform("Plane") + self.PanelWeaponPlane.gameObject:SetActiveEx(false) + + self:InitTabBtnState() + self:UpdateStrengthenBtn() + + local btnIndex = self.TabIndex or childUiIndex or XUiEquipDetail.BtnTabIndex.Detail + self.TabGroup = { + self.BtnDetail, + self.BtnStrengthen, + self.BtnResonance, + } + self.PanelTabGroup:Init(self.TabGroup, function(tabIndex) self:OnClickTabCallBack(tabIndex) end, btnIndex) + self.PanelTabGroup:SelectIndex(btnIndex) + + self.BtnStrengthenMax.CallBack = function() + XUiManager.TipMsg(CSTextManager.GetText("EquipStrengthenMaxLevel")) + end + + if not XDataCenter.VoteManager.IsInit() then + XDataCenter.VoteManager.GetVoteGroupListRequest(function() + self:SetPanelRole() + self:ShowPanelRole(true) + end) + else + self:SetPanelRole() + self:ShowPanelRole(true) + end + --self.PanelAsset.gameObject:SetActiveEx(not isPreview) + self:RegisterHelpBtn() +end + +function XUiEquipDetail:OnEnable() + self:InitClassifyPanel() +end + +function XUiEquipDetail:OnDestroy() + self.PanelWeaponPlane.gameObject:SetActiveEx(true) + if self.Resource then + CS.XResourceManager.Unload(self.Resource) + self.Resource = nil + end +end + +function XUiEquipDetail:OnReleaseInst() + return self.TabIndex +end + +function XUiEquipDetail:OnResume(value) + self.TabIndex = value +end + +function XUiEquipDetail:OnGetEvents() + return { + XEventId.EVENT_EQUIP_STRENGTHEN_NOTYFY, + XEventId.EVENT_EQUIP_BREAKTHROUGH_NOTYFY, + XEventId.EVENT_EQUIP_CAN_BREAKTHROUGH_TIP_CLOSE, + XEventId.EVENT_EQUIP_RECYCLE_NOTIFY, + } +end + +function XUiEquipDetail:OnNotify(evt, ...) + local args = { ... } + if self.IsPreview then return end + + if evt == XEventId.EVENT_EQUIP_STRENGTHEN_NOTYFY then + local equipId = args[1] + if equipId ~= self.EquipId then return end + if XDataCenter.EquipManager.IsReachBreakthroughLevel(equipId) and XDataCenter.EquipManager.IsMaxBreakthrough(equipId) then + self.PanelTabGroup:SelectIndex(XUiEquipDetail.BtnTabIndex.Detail) + self:UpdateStrengthenBtn() + return + end + elseif evt == XEventId.EVENT_EQUIP_BREAKTHROUGH_NOTYFY then + local equipId = args[1] + if equipId ~= self.EquipId then return end + self:UpdateStrengthenBtn() + self:InitClassifyPanel() + elseif evt == XEventId.EVENT_EQUIP_CAN_BREAKTHROUGH_TIP_CLOSE then + local equipId = args[1] + if equipId ~= self.EquipId then return end + if not equipId then return end + self:UpdateStrengthenBtn() + self:OpenOneChildUi("UiEquipBreakThrough", self.EquipId, self) + elseif evt == XEventId.EVENT_EQUIP_RECYCLE_NOTIFY then + self:Close() + end +end + +function XUiEquipDetail:InitClassifyPanel() + self.FxUiLihuiChuxian01.gameObject:SetActiveEx(false) + if XDataCenter.EquipManager.IsClassifyEqualByTemplateId(self.TemplateId, XEquipConfig.Classify.Weapon) then + local breakthroughTimes = not self.IsPreview and XDataCenter.EquipManager.GetBreakthroughTimes(self.EquipId) or 0 + local resonanceCount = not self.IsPreview and XDataCenter.EquipManager.GetResonanceCount(self.EquipId) or 0 + local modelConfig = XDataCenter.EquipManager.GetWeaponModelCfg(self.TemplateId, self.Name, breakthroughTimes, resonanceCount) + if modelConfig then + XModelManager.LoadWeaponModel(modelConfig.ModelId, self.PanelWeapon, modelConfig.TransformConfig, self.Name, nil + , { gameObject = self.GameObject, usage = XEquipConfig.WeaponUsage.Show }) + end + self.PanelWeapon.gameObject:SetActiveEx(true) + self.ImgLihuiMask.gameObject:SetActiveEx(false) + elseif XDataCenter.EquipManager.IsClassifyEqualByTemplateId(self.TemplateId, XEquipConfig.Classify.Awareness) then + local breakthroughTimes = not self.IsPreview and XDataCenter.EquipManager.GetBreakthroughTimes(self.EquipId) or 0 + + local resource = CS.XResourceManager.Load(XDataCenter.EquipManager.GetEquipLiHuiPath(self.TemplateId, breakthroughTimes)) + local texture = resource.Asset + self.MeshLihui.sharedMaterial:SetTexture("_MainTex", texture) + if self.Resource then + CS.XResourceManager.Unload(self.Resource) + end + self.Resource = resource + XScheduleManager.ScheduleOnce(function() + self.FxUiLihuiChuxian01.gameObject:SetActiveEx(true) + end, 500) + + self.PanelWeapon.gameObject:SetActiveEx(false) + end +end + +function XUiEquipDetail:InitTabBtnState() + if self.IsPreview then + self.PanelTabGroup.gameObject:SetActiveEx(false) + return + end + + self.BtnStrengthen.gameObject:SetActiveEx(not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.EquipStrengthen)) + self.BtnResonance.gameObject:SetActiveEx(not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.EquipResonance) and XDataCenter.EquipManager.CanResonanceByTemplateId(self.TemplateId)) + + self.BtnStrengthen:SetDisable(not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.EquipStrengthen)) + self.BtnResonance:SetDisable(not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.EquipResonance)) +end + + +function XUiEquipDetail:UpdateStrengthenBtn() + if self.IsPreview then + return + end + local equipId = self.EquipId + + if XDataCenter.EquipManager.CanBreakThrough(equipId) then + self.BtnStrengthen:SetNameByGroup(0, CSTextManager.GetText("EquipBreakthroughBtnTxt1")) + self.BtnStrengthen:SetNameByGroup(1, CSTextManager.GetText("EquipBreakthroughBtnTxt2")) + else + self.BtnStrengthen:SetNameByGroup(0, CSTextManager.GetText("EquipStrengthenBtnTxt1")) + self.BtnStrengthen:SetNameByGroup(1, CSTextManager.GetText("EquipStrengthenBtnTxt2")) + end + + local isMaxLevel = XDataCenter.EquipManager.IsMaxBreakthrough(equipId) and XDataCenter.EquipManager.IsReachBreakthroughLevel(equipId) + self.BtnStrengthen.gameObject:SetActiveEx(not isMaxLevel) + self.BtnStrengthenMax.gameObject:SetActiveEx(isMaxLevel) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiEquipDetail:InitAutoScript() + self:AutoAddListener() +end + +function XUiEquipDetail:AutoAddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainClick) +end +-- auto +function XUiEquipDetail:OnBtnBackClick() + if XLuaUiManager.IsUiShow("UiEquipResonanceSelect") or XLuaUiManager.IsUiShow("UiEquipResonanceAwake") then + self:OpenOneChildUi("UiEquipResonanceSkill", self.EquipId, self) + else + self:Close() + end +end + +function XUiEquipDetail:OnBtnMainClick() + XLuaUiManager.RunMain() +end + +function XUiEquipDetail:OnClickTabCallBack(tabIndex) + if tabIndex == XUiEquipDetail.BtnTabIndex.Detail then + self:OpenOneChildUi("UiEquipDetailChild", self.EquipId, self.IsPreview, self.OpenUiType) + self.ImgLihuiMask.gameObject:SetActiveEx(false) + self:ShowPanelRole(true) + elseif tabIndex == XUiEquipDetail.BtnTabIndex.Strengthen then + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.EquipStrengthen) then + return + end + + if XDataCenter.EquipManager.CanBreakThrough(self.EquipId) then + self:OpenOneChildUi("UiEquipBreakThrough", self.EquipId, self) + else + self:OpenOneChildUi("UiEquipStrengthen", self.EquipId, self) + end + self:ShowPanelRole(false) + self.ImgLihuiMask.gameObject:SetActiveEx(true) + elseif tabIndex == XUiEquipDetail.BtnTabIndex.Resonance then + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.EquipResonance) then + return + end + + self:OpenOneChildUi("UiEquipResonanceSkill", self.EquipId, self) + self.ImgLihuiMask.gameObject:SetActiveEx(false) + self:ShowPanelRole(false) + end + + self.TabIndex = tabIndex +end + +function XUiEquipDetail:RegisterHelpBtn() + local isClassifyEqual = XDataCenter.EquipManager.IsClassifyEqualByTemplateId(self.TemplateId, XEquipConfig.Classify.Weapon) + local keyStr = isClassifyEqual and "EquipWeapon" or "EquipAwareness" + self:BindHelpBtn(self.BtnHelp, keyStr) +end + +function XUiEquipDetail:SetPanelRole() + if XArrangeConfigs.GetType(self.TemplateId) == XArrangeConfigs.Types.Weapon then + local weaponUsers = XDataCenter.EquipManager.GetWeaponUserTemplateIds(self.TemplateId) + for _, v in pairs(weaponUsers) do + local go = CS.UnityEngine.Object.Instantiate(self.PanelText, self.PaneContent) + local tmpObj = {} + tmpObj.Transform = go.transform + tmpObj.GameObject = go.gameObject + XTool.InitUiObject(tmpObj) + tmpObj.Text.text = v.Name .. "-" .. v.TradeName + self:CheckShowRoleTag(v.Id, tmpObj) + tmpObj.GameObject:SetActiveEx(true) + end + + self.IsPanelRoleCanShow = weaponUsers and #weaponUsers > 0 + end +end + +function XUiEquipDetail:ShowPanelRole(IsShow) + if XArrangeConfigs.GetType(self.TemplateId) == XArrangeConfigs.Types.Weapon and self.IsPreview then + self.PanelRole.gameObject:SetActiveEx(IsShow and self.IsPanelRoleCanShow) + else + self.PanelRole.gameObject:SetActiveEx(false) + end +end + +function XUiEquipDetail:CheckShowRoleTag(Id, obj) + local IsShow = false + local tabMap = XCharacterConfigs.GetRecommendTabMap(Id, XCharacterConfigs.RecommendType.Equip) + for _, v in pairs(tabMap or {}) do + if v.GroupId then + local voteIds = XDataCenter.VoteManager.GetVoteIdListByGroupId(v.GroupId) + for _, v2 in pairs(voteIds or {}) do + local template = XCharacterConfigs.GetCharDetailEquipTemplate(v2) + if template.EquipRecomend == self.TemplateId then + IsShow = true + break + end + end + end + if IsShow then + break + end + end + obj.Image.gameObject:SetActiveEx(IsShow) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiEquipDetail/XUiEquipDetailChild.lua b/Resources/Scripts/XUi/XUiEquipDetail/XUiEquipDetailChild.lua new file mode 100644 index 00000000..04d741ff --- /dev/null +++ b/Resources/Scripts/XUi/XUiEquipDetail/XUiEquipDetailChild.lua @@ -0,0 +1,341 @@ +local CsXTextManager = CS.XTextManager + +local MAX_AWARENESS_ATTR_COUNT = 2 --不包括共鸣属性,最大有2条 +local XUiGridResonanceSkill = require("XUi/XUiEquipResonanceSkill/XUiGridResonanceSkill") + +local XUiEquipDetailChild = XLuaUiManager.Register(XLuaUi, "UiEquipDetailChild") + +XUiEquipDetailChild.BtnTabIndex = { + SuitSkill = 1, + ResonanceSkill = 2, +} + +function XUiEquipDetailChild:OnAwake() + self:AutoAddListener() + + local tabGroupList = { + self.BtnSuitSkill, + self.BtnResonanceSkill, + } + self.TabGroupRight:Init(tabGroupList, function(tabIndex) self:OnClickTabCallBack(tabIndex) end) +end + +function XUiEquipDetailChild:OnStart(equipId, isPreview, openUiType) + self.IsPreview = isPreview + self.EquipId = equipId + self.TemplateId = isPreview and self.EquipId or XDataCenter.EquipManager.GetEquipTemplateId(equipId) + self.GridResonanceSkills = {} + self.OpenUiType = openUiType + + self:InitTabBtns() + self:InitClassifyPanel() + self:InitEquipInfo() +end + +function XUiEquipDetailChild:OnEnable() + self:UpdateEquipAttr() + self:UpdateEquipLevel() + self:UpdateEquipBreakThrough() + self:UpdateEquipLock() + self:UpdateEquipRecycle() + self:UpdateEquipSkillDes() + self:UpdateResonanceSkills() +end + +function XUiEquipDetailChild:OnGetEvents() + return { + XEventId.EVENT_EQUIP_STRENGTHEN_NOTYFY + , XEventId.EVENT_EQUIP_LOCK_STATUS_CHANGE_NOTYFY + , XEventId.EVENT_EQUIP_RECYCLE_STATUS_CHANGE_NOTYFY + } +end + +function XUiEquipDetailChild:OnNotify(evt, ...) + local args = { ... } + local equipId = args[1] + if self.IsPreview or equipId ~= self.EquipId then return end + + if evt == XEventId.EVENT_EQUIP_STRENGTHEN_NOTYFY then + self:UpdateEquipLevel() + self:UpdateEquipAttr() + elseif evt == XEventId.EVENT_EQUIP_LOCK_STATUS_CHANGE_NOTYFY then + self:UpdateEquipLock() + self:UpdateEquipRecycle() + elseif evt == XEventId.EVENT_EQUIP_RECYCLE_STATUS_CHANGE_NOTYFY then + self:UpdateEquipRecycle() + elseif evt == XEventId.EVENT_EQUIP_BREAKTHROUGH_NOTYFY then + self:UpdateEquipBreakThrough() + end +end + +function XUiEquipDetailChild:OnClickTabCallBack(tabIndex) + if tabIndex == XUiEquipDetailChild.BtnTabIndex.SuitSkill then + self.PanelSuitSkill.gameObject:SetActive(true) + self.PanelResonanceSkill.gameObject:SetActive(false) + self:UpdateEquipSkillDes() + self:PlayAnimation("SuitSkill") + elseif tabIndex == XUiEquipDetailChild.BtnTabIndex.ResonanceSkill then + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.EquipResonance) then + return + end + self.PanelSuitSkill.gameObject:SetActive(false) + self.PanelResonanceSkill.gameObject:SetActive(true) + self:UpdateResonanceSkills() + self:PlayAnimation("ResonanceSkill") + end +end + +function XUiEquipDetailChild:InitTabBtns() + if not XDataCenter.EquipManager.CanResonanceByTemplateId(self.TemplateId) or (self.OpenUiType and self.OpenUiType == XUiConfigs.OpenUiType.NieRCharacterUI) then + self.BtnResonanceSkill.gameObject:SetActive(false) + self.BtnSuitSkill.gameObject:SetActive(false) + return + end + + self.BtnResonanceSkill:SetDisable(not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.EquipResonance)) + self.TabGroupRight:SelectIndex(XUiEquipDetailChild.BtnTabIndex.SuitSkill) +end + +function XUiEquipDetailChild:InitClassifyPanel() + if XDataCenter.EquipManager.IsClassifyEqualByTemplateId(self.TemplateId, XEquipConfig.Classify.Weapon) then + self.TxtTitle.text = CsXTextManager.GetText("WeaponDetailTitle") + self.PanelPainter.gameObject:SetActive(false) + else + local breakthroughTimes = not self.IsPreview and XDataCenter.EquipManager.GetBreakthroughTimes(self.EquipId) or 0 + self.TxtPainter.text = XDataCenter.EquipManager.GetEquipPainterName(self.TemplateId, breakthroughTimes) + self.PanelPainter.gameObject:SetActive(true) + self.TxtTitle.text = CsXTextManager.GetText("AwarenessDetailTitle") + end +end + +function XUiEquipDetailChild:UpdateEquipSkillDes() + if XDataCenter.EquipManager.IsClassifyEqualByTemplateId(self.TemplateId, XEquipConfig.Classify.Weapon) then + local weaponSkillInfo = XDataCenter.EquipManager.GetOriginWeaponSkillInfo(self.TemplateId) + local noWeaponSkill = not weaponSkillInfo.Name and not weaponSkillInfo.Description + + self.TxtSkillName.text = weaponSkillInfo.Name + self.TxtSkillDes.text = weaponSkillInfo.Description + + self.PanelAwarenessSkillDes.gameObject:SetActive(false) + self.PanelNoAwarenessSkill.gameObject:SetActive(false) + self.PanelWeaponSkillDes.gameObject:SetActive(not noWeaponSkill) + self.PanelNoWeaponSkill.gameObject:SetActive(noWeaponSkill) + elseif XDataCenter.EquipManager.IsClassifyEqualByTemplateId(self.TemplateId, XEquipConfig.Classify.Awareness) then + local suitId = XDataCenter.EquipManager.GetSuitIdByTemplateId(self.TemplateId) + local skillDesList = XDataCenter.EquipManager.GetSuitSkillDesList(suitId) + + local noSuitSkill = true + for i = 1, XEquipConfig.MAX_SUIT_SKILL_COUNT do + if skillDesList[i * 2] then + self["TxtSkillDes" .. i].text = skillDesList[i * 2] + self["TxtSkillDes" .. i].gameObject:SetActive(true) + noSuitSkill = false + else + self["TxtSkillDes" .. i].gameObject:SetActive(false) + end + end + + self.PanelNoAwarenessSkill.gameObject:SetActive(noSuitSkill) + self.PanelAwarenessSkillDes.gameObject:SetActive(not noSuitSkill) + self.PanelWeaponSkillDes.gameObject:SetActive(false) + self.PanelNoWeaponSkill.gameObject:SetActive(false) + end +end + +function XUiEquipDetailChild:UpdateEquipLock() + if self.IsPreview then + self.BtnUnlock.gameObject:SetActive(false) + self.BtnLock.gameObject:SetActive(false) + return + end + + local isLock = XDataCenter.EquipManager.IsLock(self.EquipId) + self.BtnUnlock.gameObject:SetActive(not isLock) + self.BtnLock.gameObject:SetActive(isLock) +end + +function XUiEquipDetailChild:UpdateEquipRecycle() + if self.IsPreview then + self.BtnLaJi.gameObject:SetActive(false) + self.BtnUnLaJi.gameObject:SetActive(false) + return + end + + local isCanRecycle = XDataCenter.EquipManager.IsEquipCanRecycle(self.EquipId) + local isRecycle = XDataCenter.EquipManager.IsRecycle(self.EquipId) + self.BtnLaJi.gameObject:SetActiveEx(isCanRecycle and isRecycle) + self.BtnUnLaJi.gameObject:SetActiveEx(isCanRecycle and not isRecycle) +end + +function XUiEquipDetailChild:UpdateEquipLevel() + local level, levelLimit + local equipId = self.EquipId + + if self.OpenUiType and self.OpenUiType == XUiConfigs.OpenUiType.NieRCharacterUI then + local character = XDataCenter.NieRManager.GetSelNieRCharacter() + level = character:GetNieRWeaponLevel() + local equipSite = XDataCenter.EquipManager.GetEquipSiteByTemplateId(self.TemplateId) + local breakTimes = character:GetNieRWeaponBreakThrough() + if equipSite and equipSite ~= XEquipConfig.EquipSite.Weapon then + level = character:GetNieRWaferLevel(equipId) + breakTimes = character:GetNieRWaferBreakThroughById(equipId) + end + levelLimit = XDataCenter.EquipManager.GetBreakthroughLevelLimitByTemplateId(self.TemplateId, breakTimes) + self.PanelMaxLevel.gameObject:SetActive(XDataCenter.EquipManager.IsMaxLevelByTemplateId(self.TemplateId, breakTimes, level) and not XDataCenter.EquipManager.CanBreakThroughByTemplateId(equipId, breakTimes, level)) + elseif self.IsPreview then + level = 1 + levelLimit = XDataCenter.EquipManager.GetBreakthroughLevelLimitByTemplateId(self.TemplateId) + self.PanelMaxLevel.gameObject:SetActive(false) + else + local equip = XDataCenter.EquipManager.GetEquip(equipId) + level = equip.Level + levelLimit = XDataCenter.EquipManager.GetBreakthroughLevelLimit(equipId) + self.PanelMaxLevel.gameObject:SetActive(XDataCenter.EquipManager.IsMaxLevel(equipId) and not XDataCenter.EquipManager.CanBreakThrough(equipId)) + end + + if level and levelLimit then + self.TxtLevel.text = CsXTextManager.GetText("EquipLevelText", level, levelLimit) + end +end + +function XUiEquipDetailChild:UpdateEquipBreakThrough() + if self.OpenUiType and self.OpenUiType == XUiConfigs.OpenUiType.NieRCharacterUI then + local character = XDataCenter.NieRManager.GetSelNieRCharacter() + local equipSite = XDataCenter.EquipManager.GetEquipSiteByTemplateId(self.TemplateId) + local breakTimes = character:GetNieRWeaponBreakThrough() + if equipSite and equipSite ~= XEquipConfig.EquipSite.Weapon then + breakTimes = character:GetNieRWaferBreakThroughById(self.EquipId) + end + self:SetUiSprite(self.ImgBreakThrough, XEquipConfig.GetEquipBreakThroughIcon(breakTimes)) + return + elseif self.IsPreview then + self:SetUiSprite(self.ImgBreakThrough, XEquipConfig.GetEquipBreakThroughIcon(0)) + return + end + + self:SetUiSprite(self.ImgBreakThrough, XDataCenter.EquipManager.GetEquipBreakThroughIcon(self.EquipId)) +end + +function XUiEquipDetailChild:InitEquipInfo() + local star = XDataCenter.EquipManager.GetEquipStar(self.TemplateId) + for i = 1, XEquipConfig.MAX_STAR_COUNT do + if i <= star then + self["ImgStar" .. i].gameObject:SetActive(true) + else + self["ImgStar" .. i].gameObject:SetActive(false) + end + end + + self.TxtEquipName.text = XDataCenter.EquipManager.GetEquipName(self.TemplateId) + + local equipSite = XDataCenter.EquipManager.GetEquipSiteByTemplateId(self.TemplateId) + if equipSite ~= XEquipConfig.EquipSite.Weapon then + local breakthrough = 0 + if not self.IsPreview then + local equip = XDataCenter.EquipManager.GetEquip(self.EquipId) + breakthrough = equip.Breakthrough + end + self.RImgIcon:SetRawImage(XDataCenter.EquipManager.GetEquipIconBagPath(self.TemplateId, breakthrough)) + self.TxtPos.text = "0" .. equipSite + self.PanelPos.gameObject:SetActive(true) + self.RImgType.gameObject:SetActive(false) + else + self.RImgType:SetRawImage(XEquipConfig.GetWeaponTypeIconPath(self.TemplateId)) + self.RImgType.gameObject:SetActive(true) + self.PanelPos.gameObject:SetActive(false) + end + + local equipSpecialCharacterId = XDataCenter.EquipManager.GetEquipSpecialCharacterIdByTemplateId(self.TemplateId) + if equipSpecialCharacterId then + self.RImgHead:SetRawImage(XDataCenter.CharacterManager.GetCharSmallHeadIcon(equipSpecialCharacterId)) + self.PanelSpecialCharacter.gameObject:SetActive(true) + else + self.PanelSpecialCharacter.gameObject:SetActive(false) + end +end + +function XUiEquipDetailChild:UpdateEquipAttr() + local attrMap + if self.OpenUiType and self.OpenUiType == XUiConfigs.OpenUiType.NieRCharacterUI then + local equipLevel = XDataCenter.NieRManager.GetSelNieRCharacter():GetNieRWeaponLevel() + local equipSite = XDataCenter.EquipManager.GetEquipSiteByTemplateId(self.TemplateId) + if equipSite and equipSite ~= XEquipConfig.EquipSite.Weapon then + equipLevel = XDataCenter.NieRManager.GetSelNieRCharacter():GetNieRWaferLevel(self.EquipId) + end + attrMap = XDataCenter.EquipManager.GetTemplateEquipAttrMap(self.EquipId, equipLevel) + elseif self.IsPreview then + attrMap = XDataCenter.EquipManager.GetTemplateEquipAttrMap(self.EquipId) + else + attrMap = XDataCenter.EquipManager.GetEquipAttrMap(self.EquipId) + end + + local attrCount = 1 + for _, attrInfo in pairs(attrMap) do + if attrCount > MAX_AWARENESS_ATTR_COUNT then break end + self["TxtName" .. attrCount].text = attrInfo.Name + self["TxtAttr" .. attrCount].text = attrInfo.Value + self["PanelAttr" .. attrCount].gameObject:SetActive(true) + attrCount = attrCount + 1 + end + for i = attrCount, MAX_AWARENESS_ATTR_COUNT do + self["PanelAttr" .. i].gameObject:SetActive(false) + end +end + +function XUiEquipDetailChild:UpdateResonanceSkills() + local count = 1 + local resonanceSkillNum = XDataCenter.EquipManager.GetResonanceSkillNumByTemplateId(self.TemplateId) + for pos = 1, resonanceSkillNum do + self["PanelSkill" .. pos].gameObject:SetActive(true) + self["PanelEmptySkill" .. pos].gameObject:SetActive(true) + count = count + 1 + self:UpdateResonanceSkill(pos) + end + for pos = count, XEquipConfig.MAX_RESONANCE_SKILL_COUNT do + self["PanelSkill" .. pos].gameObject:SetActive(false) + end +end + +function XUiEquipDetailChild:UpdateResonanceSkill(pos) + if self.IsPreview then return end + local grid = self.GridResonanceSkills[pos] + if XDataCenter.EquipManager.CheckEquipPosResonanced(self.EquipId, pos) then + if not grid then + local item = CS.UnityEngine.Object.Instantiate(self.GridResonanceSkill) + grid = XUiGridResonanceSkill.New(item, self.EquipId, pos) + grid.Transform:SetParent(self["PanelSkill" .. pos], false) + self.GridResonanceSkills[pos] = grid + end + + grid:Refresh() + grid.GameObject:SetActive(true) + self["PanelEmptySkill" .. pos].gameObject:SetActive(false) + else + if grid then + grid.GameObject:SetActive(false) + end + end +end + +function XUiEquipDetailChild:AutoAddListener() + self:RegisterClickEvent(self.BtnLock, self.OnBtnLockClick) + self:RegisterClickEvent(self.BtnUnlock, self.OnBtnUnlockClick) + self:RegisterClickEvent(self.BtnLaJi, self.OnBtnLaJiClick) + self:RegisterClickEvent(self.BtnUnLaJi, self.OnBtnBtnUnLaJiClick) +end + +function XUiEquipDetailChild:OnBtnLockClick() + XDataCenter.EquipManager.SetLock(self.EquipId, false) +end + +function XUiEquipDetailChild:OnBtnUnlockClick() + XDataCenter.EquipManager.SetLock(self.EquipId, true) +end + +function XUiEquipDetailChild:OnBtnLaJiClick() + XDataCenter.EquipManager.EquipUpdateRecycleRequest(self.EquipId, false) +end + +function XUiEquipDetailChild:OnBtnBtnUnLaJiClick() + XDataCenter.EquipManager.EquipUpdateRecycleRequest(self.EquipId, true) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiEquipReplaceNew/XUiEquipReplaceNew.lua b/Resources/Scripts/XUi/XUiEquipReplaceNew/XUiEquipReplaceNew.lua new file mode 100644 index 00000000..b93a298f --- /dev/null +++ b/Resources/Scripts/XUi/XUiEquipReplaceNew/XUiEquipReplaceNew.lua @@ -0,0 +1,348 @@ +local XUiGridEquip = require("XUi/XUiEquipAwarenessReplace/XUiGridEquip") +local XUiGridEquipReplaceAttr = require("XUi/XUiEquipReplaceNew/XUiGridEquipReplaceAttr") +local XUiGridResonanceSkill = require("XUi/XUiEquipResonanceSkill/XUiGridResonanceSkill") + +local XUiEquipReplaceNew = XLuaUiManager.Register(XLuaUi, "UiEquipReplaceNew") + +function XUiEquipReplaceNew:OnAwake() + self:AutoAddListener() + self:InitComponentStatus() +end + +function XUiEquipReplaceNew:OnStart(charId, closecallback, notShowStrengthenBtn) + self.IsAscendOrder = false --初始降序 + self.NotShowStrengthenBtn = notShowStrengthenBtn or false + self:InitViewData(charId, closecallback) + self:InitDynamicTable() + + self.ImgAscend.gameObject:SetActive(self.IsAscendOrder) + self.ImgDescend.gameObject:SetActive(not self.IsAscendOrder) +end + +function XUiEquipReplaceNew:OnEnable() + self:UpdateView() +end + +function XUiEquipReplaceNew:OnDestroy() + if self.CloseCallback then + self.CloseCallback(self.CharacterId, self.ChangeEquipSuccess) + end +end + +--注册监听事件 +function XUiEquipReplaceNew:OnGetEvents() + return { + XEventId.EVENT_EQUIP_PUTON_NOTYFY + , XEventId.EVENT_EQUIP_LOCK_STATUS_CHANGE_NOTYFY + , XEventId.EVENT_EQUIP_RECYCLE_STATUS_CHANGE_NOTYFY + , XEventId.EVENT_EQUIP_STRENGTHEN_NOTYFY + , XEventId.EVENT_EQUIP_BREAKTHROUGH_NOTYFY + , XEventId.EVENT_EQUIP_RESONANCE_ACK_NOTYFY + , XEventId.EVENT_EQUIP_RECYCLE_NOTIFY + } +end + +--处理事件监听 +function XUiEquipReplaceNew:OnNotify(evt, ...) + local args = { ... } + local equipId = args[1] + + if evt == XEventId.EVENT_EQUIP_PUTON_NOTYFY then + self.UsingEquipId = equipId + self:OnPutOnEquip() + elseif evt == XEventId.EVENT_EQUIP_LOCK_STATUS_CHANGE_NOTYFY + or evt == XEventId.EVENT_EQUIP_RECYCLE_STATUS_CHANGE_NOTYFY then + self:OnEquipLockStatusChange(equipId) + self:UpdateEquipGridList() + elseif evt == XEventId.EVENT_EQUIP_STRENGTHEN_NOTYFY + or evt == XEventId.EVENT_EQUIP_BREAKTHROUGH_NOTYFY + or evt == XEventId.EVENT_EQUIP_RESONANCE_ACK_NOTYFY + or evt == XEventId.EVENT_EQUIP_RECYCLE_NOTIFY + then + self:UpdateView() + end +end + +function XUiEquipReplaceNew:InitComponentStatus() + self.GridEquip.gameObject:SetActive(false) + self.GridEquipReplaceAttr.gameObject:SetActive(false) + self.GridEquipReplaceAttr.gameObject:SetActive(false) + self.GridResonanceSkill.gameObject:SetActive(false) + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) +end + +function XUiEquipReplaceNew:InitViewData(characterid, closecallback) + self.CharacterId = characterid + self.CloseCallback = closecallback + self.AttrGridList = {} + self.GridResonanceSkills = {} + self.PriorSortType = XEquipConfig.PriorSortType.Star + local equipId = XDataCenter.EquipManager.GetCharacterWearingWeaponId(self.CharacterId) --初始为角色身上的装备 + self.SelectEquipId = equipId + self.UsingEquipId = equipId +end + +function XUiEquipReplaceNew:UpdateView() + self.WeaponIdList = XDataCenter.EquipManager.GetCanUseWeaponIds(self.CharacterId) + self:OnPutOnEquip() + self:SelectSortType() + self:OnSelectEquip() +end + +function XUiEquipReplaceNew:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelEquipScroll) + self.DynamicTable:SetProxy(XUiGridEquip) + self.DynamicTable:SetDelegate(self) +end + +function XUiEquipReplaceNew:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:InitRootUi(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local equipId = self.WeaponIdList[index] + grid:Refresh(equipId) + + local isSelected = equipId == self.SelectEquipId + grid:SetSelected(isSelected) + if isSelected then + self.LastSelectGrid = grid + end + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + self.SelectEquipId = self.WeaponIdList[index] + self:OnSelectEquip() + if self.LastSelectGrid then + self.LastSelectGrid:SetSelected(false) + end + self.LastSelectGrid = grid + self.LastSelectGrid:SetSelected(true) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_RELOAD_COMPLETED then + XEventManager.DispatchEvent(XEventId.EVENT_GUIDE_STEP_OPEN_EVENT) + end +end + +function XUiEquipReplaceNew:OnPutOnEquip() + self:UpdateCompareAttr() + self:UpdateBtnEquipStatus() + self:SelectSortType() +end + +function XUiEquipReplaceNew:OnEquipLockStatusChange(equipId) + if equipId ~= self.SelectEquipId then return end + local equip = XDataCenter.EquipManager.GetEquip(equipId) + + self.BtnLock.gameObject:SetActive(equip.IsLock) + self.BtnUnlock.gameObject:SetActive(not equip.IsLock) +end + +function XUiEquipReplaceNew:SelectSortType() + XDataCenter.EquipManager.SortEquipIdListByPriorType(self.WeaponIdList, self.PriorSortType) + if self.IsAscendOrder then + XTool.ReverseList(self.WeaponIdList) + end + self:UpdateEquipGridList() +end + +function XUiEquipReplaceNew:UpdateEquipGridList() + self:UsingWeaponFirstInList() + self.DynamicTable:SetDataSource(self.WeaponIdList) + self.DynamicTable:ReloadDataASync(#self.WeaponIdList > 0 and 1 or -1) + + self:PlayAnimation("LeftQieHuan") +end + +function XUiEquipReplaceNew:UpdateResonanceSkills() + local skillCount = 0 + + local resonanceSkillNum = XDataCenter.EquipManager.GetResonanceSkillNum(self.SelectEquipId) + for pos = resonanceSkillNum, 1, -1 do + if XDataCenter.EquipManager.CheckEquipPosResonanced(self.SelectEquipId, pos) then + if not self.GridResonanceSkills[pos] then + local item = CS.UnityEngine.Object.Instantiate(self.GridResonanceSkill) -- 复制一个item + self.GridResonanceSkills[pos] = XUiGridResonanceSkill.New(item, self.SelectEquipId, pos, self.CharacterId, function(equipId, selectPos, characterId) + XLuaUiManager.Open("UiEquipResonanceSkillDetailInfo", equipId, selectPos, characterId) + end) + self.GridResonanceSkills[pos].Transform:SetParent(self.PanelSkills, false) + end + + self.GridResonanceSkills[pos]:SetEquipIdAndPos(self.SelectEquipId, pos) + self.GridResonanceSkills[pos]:Refresh() + self.GridResonanceSkills[pos].GameObject:SetActive(true) + self.GridResonanceSkills[pos].Transform:SetAsFirstSibling() + + skillCount = skillCount + 1 + else + if self.GridResonanceSkills[pos] then + self.GridResonanceSkills[pos].GameObject:SetActive(false) + end + end + end + + if skillCount == 0 then + for _, grid in pairs(self.GridResonanceSkills) do + grid.GameObject:SetActive(false) + end + end + + for pos = 1, XEquipConfig.MAX_RESONANCE_SKILL_COUNT do + self["ImgBg" .. pos].gameObject:SetActive(pos > skillCount and pos <= resonanceSkillNum) + end + + if resonanceSkillNum == 0 then + self.PanelResonanceSkill.gameObject:SetActive(false) + else + self.PanelResonanceSkill.gameObject:SetActive(true) + end +end + +function XUiEquipReplaceNew:OnSelectEquip() + self:UpdateSelectEquip() + self:UpdateCompareAttr() + self:UpdateBtnEquipStatus() + self:OnEquipLockStatusChange(self.SelectEquipId) + self:UpdateResonanceSkills() +end + +function XUiEquipReplaceNew:UpdateSelectEquip() + local equip = XDataCenter.EquipManager.GetEquip(self.SelectEquipId) + local weaponSkillInfo = XDataCenter.EquipManager.GetOriginWeaponSkillInfo(equip.TemplateId) + + self.RImgEquipIcon:SetRawImage(XDataCenter.EquipManager.GetWeaponTypeIconPath(self.SelectEquipId)) + self.TxtEquipName.text = XDataCenter.EquipManager.GetEquipName(equip.TemplateId) + self.TxtEquipLevel.text = equip.Level + self.TxtSkillDes.text = weaponSkillInfo.Description + + local noSkill = not weaponSkillInfo.Description and not weaponSkillInfo.Name + self.PanelSkillDes.gameObject:SetActive(not noSkill) + + for i = 1, XEquipConfig.MAX_STAR_COUNT do + if i <= XDataCenter.EquipManager.GetEquipStar(equip.TemplateId) then + self["ImgStar" .. i].gameObject:SetActive(true) + else + self["ImgStar" .. i].gameObject:SetActive(false) + end + end +end + +function XUiEquipReplaceNew:UpdateCompareAttr() + if not self.UsingEquipId or not self.SelectEquipId then return end + local curAttrMap = XDataCenter.EquipManager.GetEquipAttrMap(self.UsingEquipId) + local newAttrMap = XDataCenter.EquipManager.GetEquipAttrMap(self.SelectEquipId) + + for key, _ in pairs(curAttrMap) do + local curAttrValue = curAttrMap[key] and curAttrMap[key].Value or 0 + local newAttrValue = newAttrMap[key] and newAttrMap[key].Value or 0 + + if not self.AttrGridList[key] then + local ui = CS.UnityEngine.Object.Instantiate(self.GridEquipReplaceAttr) + self.AttrGridList[key] = XUiGridEquipReplaceAttr.New(ui, curAttrMap[key].Name) + self.AttrGridList[key].Transform:SetParent(self.PanelAttrParent, false) + end + + self.AttrGridList[key]:UpdateData(curAttrValue, newAttrValue) + self.AttrGridList[key].GameObject:SetActive(true) + end + + self:PlayAnimation("RightQieHuan") +end + +function XUiEquipReplaceNew:UpdateBtnEquipStatus() + if self.UsingEquipId == self.SelectEquipId then + --当前角色使用中 + self.BtnTakeOn.gameObject:SetActive(false) + self.ImgEquipOn.gameObject:SetActive(true) + else + self.BtnTakeOn.gameObject:SetActive(true) + self.ImgEquipOn.gameObject:SetActive(false) + end + + self.BtnStrengthen.gameObject:SetActive(not self.NotShowStrengthenBtn) +end + +function XUiEquipReplaceNew:AutoAddListener() + self:RegisterClickEvent(self.BtnTakeOn, self.OnBtnTakeOnClick) + self:RegisterClickEvent(self.BtnStrengthen, self.OnBtnStrengthenClick) + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMain, self.OnBtnMainClick) + self:RegisterClickEvent(self.BtnOrder, self.OnBtnOrderClick) + self:RegisterClickEvent(self.BtnLock, self.OnBtnLockClick) + self:RegisterClickEvent(self.BtnUnlock, self.OnBtnUnlockClick) + self.DrdSort.onValueChanged:AddListener(function() + self.PriorSortType = self.DrdSort.value + self:SelectSortType() + end) +end + +function XUiEquipReplaceNew:OnBtnOrderClick() + self.IsAscendOrder = not self.IsAscendOrder + XTool.ReverseList(self.WeaponIdList) + self:UpdateEquipGridList() + self.ImgAscend.gameObject:SetActive(self.IsAscendOrder) + self.ImgDescend.gameObject:SetActive(not self.IsAscendOrder) +end + +function XUiEquipReplaceNew:OnBtnLockClick() + XDataCenter.EquipManager.SetLock(self.SelectEquipId, false) +end + +function XUiEquipReplaceNew:OnBtnUnlockClick() + XDataCenter.EquipManager.SetLock(self.SelectEquipId, true) +end + +function XUiEquipReplaceNew:OnBtnStrengthenClick() + XLuaUiManager.Open("UiEquipDetail", self.SelectEquipId, nil, self.CharacterId) +end + +function XUiEquipReplaceNew:OnBtnTakeOnClick() + local equip = XDataCenter.EquipManager.GetEquip(self.SelectEquipId) + local characterId = equip.CharacterId + --其他角色使用中 + if characterId and characterId > 0 then + --自己穿戴了专属装备 + local specialCharacterId = XDataCenter.EquipManager.GetEquipSpecialCharacterId(self.UsingEquipId) + if specialCharacterId and specialCharacterId > 0 then + XUiManager.TipText("EquipWithSpecialCharacterIdCanNotBeReplaced") + return + end + + local fullName = XCharacterConfigs.GetCharacterFullNameStr(characterId) + local content = CS.XTextManager.GetText("EquipReplaceTip", fullName) + XUiManager.DialogTip(CS.XTextManager.GetText("TipTitle"), content, XUiManager.DialogType.Normal, function() end, function() + XDataCenter.EquipManager.PutOn(self.CharacterId, self.SelectEquipId) + self.ChangeEquipSuccess = true + end) + else + XDataCenter.EquipManager.PutOn(self.CharacterId, self.SelectEquipId) + self.ChangeEquipSuccess = true + end +end + +function XUiEquipReplaceNew:OnBtnBackClick() + self:Close() +end + +function XUiEquipReplaceNew:OnBtnMainClick() + XLuaUiManager.RunMain() +end + +function XUiEquipReplaceNew:UsingWeaponFirstInList() + local usingEquipId + for index, equipId in pairs(self.WeaponIdList) do + if equipId == self.UsingEquipId then + usingEquipId = table.remove(self.WeaponIdList, index) + end + end + if usingEquipId then + table.insert(self.WeaponIdList, 1, usingEquipId) + end +end + +function XUiEquipReplaceNew:GuideGetDynamicTableIndex(id) + for i, v in ipairs(self.WeaponIdList) do + local equip = XDataCenter.EquipManager.GetEquip(v) + if tostring(equip.TemplateId) == id then + return i + end + end + + return -1 +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiEquipReplaceNew/XUiEquipResonanceSkillDetailInfo.lua b/Resources/Scripts/XUi/XUiEquipReplaceNew/XUiEquipResonanceSkillDetailInfo.lua new file mode 100644 index 00000000..047f52ea --- /dev/null +++ b/Resources/Scripts/XUi/XUiEquipReplaceNew/XUiEquipResonanceSkillDetailInfo.lua @@ -0,0 +1,43 @@ +local XUiGridResonanceSkill = require("XUi/XUiEquipResonanceSkill/XUiGridResonanceSkill") +local XUiGridResonanceSkillOther = require("XUi/XUiPlayerInfo/XUiGridResonanceSkillOther") + +local XUiEquipResonanceSkillDetailInfo = XLuaUiManager.Register(XLuaUi, "UiEquipResonanceSkillDetailInfo") + +function XUiEquipResonanceSkillDetailInfo:OnAwake() + self:RegisterClickEvent(self.BtnHideCurResonance, function() + self:Close() + end) +end + +--fromeOther:是否在查看其他玩家信息 +--fromTip:是否点击其他玩家的超频详情,然后弹出tip +function XUiEquipResonanceSkillDetailInfo:OnStart(equipId, pos, characterId, isAwakeDes, forceShowBindCharacter, fromeOther, fromTip, character, equip) + self.EquipId = equipId + self.Pos = pos + self.CharacterId = characterId + self.IsAwakeDes = isAwakeDes + self.ForceShowBindCharacter = forceShowBindCharacter + + if fromeOther then + self:RefreshOther(fromTip,character,equip) + else + self:Refresh() + end +end + +function XUiEquipResonanceSkillDetailInfo:Refresh() + local equipId = self.EquipId + local pos = self.Pos + local characterId = self.CharacterId + local isAwakeDes = self.IsAwakeDes + local forceShowBindCharacter = self.ForceShowBindCharacter + self.CurResonanceSkillGrid = self.CurResonanceSkillGrid or XUiGridResonanceSkill.New(self.GridCurResonanceSkill, equipId, pos, characterId, nil, nil, forceShowBindCharacter) + self.CurResonanceSkillGrid:SetEquipIdAndPos(equipId, pos, isAwakeDes) + self.CurResonanceSkillGrid:Refresh() +end + +function XUiEquipResonanceSkillDetailInfo:RefreshOther(fromTip,character,equip) + local pos = self.Pos + self.CurResonanceSkillGrid = self.CurResonanceSkillGrid or XUiGridResonanceSkillOther.New(self.GridCurResonanceSkill, equip, pos, fromTip, character) + self.CurResonanceSkillGrid:Refresh() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiEquipReplaceNew/XUiGridEquipReplaceAttr.lua b/Resources/Scripts/XUi/XUiEquipReplaceNew/XUiGridEquipReplaceAttr.lua new file mode 100644 index 00000000..98d82b51 --- /dev/null +++ b/Resources/Scripts/XUi/XUiEquipReplaceNew/XUiGridEquipReplaceAttr.lua @@ -0,0 +1,75 @@ +local ATTR_COLOR = { + BELOW = XUiHelper.Hexcolor2Color("d11e38ff"), + EQUAL = XUiHelper.Hexcolor2Color("000000ff"), + OVER = XUiHelper.Hexcolor2Color("188649ff"), +} + +local XUiGridEquipReplaceAttr = XClass(nil, "XUiGridEquipReplaceAttr") + +function XUiGridEquipReplaceAttr:Ctor(ui, name, doNotChangeColor) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self:InitAutoScript() + self.TxtName.text = name + self.DoNotChangeColor = doNotChangeColor +end + +function XUiGridEquipReplaceAttr:UpdateData(curAttrValue, newattrvalue, notShowSame) + if curAttrValue then + self.CurAttrValue = curAttrValue + self.TxtCurAttr.text = self.CurAttrValue + end + + if not newattrvalue or notShowSame and self.CurAttrValue and newattrvalue == self.CurAttrValue then + self.TxtSelectAttr.gameObject:SetActive(false) + return + end + + self.Newattrvalue = newattrvalue + self.TxtSelectAttr.text = self.Newattrvalue + self.TxtSelectAttr.gameObject:SetActive(true) + + if not self.DoNotChangeColor then + if self.CurAttrValue == self.Newattrvalue then + self.TxtSelectAttr.color = ATTR_COLOR.EQUAL + elseif self.CurAttrValue < self.Newattrvalue then + self.TxtSelectAttr.color = ATTR_COLOR.OVER + elseif self.CurAttrValue > self.Newattrvalue then + self.TxtSelectAttr.color = ATTR_COLOR.BELOW + end + end +end +-- auto +-- Automatic generation of code, forbid to edit +function XUiGridEquipReplaceAttr:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiGridEquipReplaceAttr:AutoInitUi() + self.TxtName = self.Transform:Find("TxtName"):GetComponent("Text") + self.TxtCurAttr = self.Transform:Find("TxtCurAttr"):GetComponent("Text") + self.TxtSelectAttr = self.Transform:Find("TxtSelectAttr"):GetComponent("Text") +end + +function XUiGridEquipReplaceAttr:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiGridEquipReplaceAttr:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiGridEquipReplaceAttr:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiGridEquipReplaceAttr:AutoAddListener() +end +-- auto +return XUiGridEquipReplaceAttr \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiEquipResonanceSelect/XUiEquipResonanceAwake.lua b/Resources/Scripts/XUi/XUiEquipResonanceSelect/XUiEquipResonanceAwake.lua new file mode 100644 index 00000000..4dcd6ac3 --- /dev/null +++ b/Resources/Scripts/XUi/XUiEquipResonanceSelect/XUiEquipResonanceAwake.lua @@ -0,0 +1,250 @@ +local CSXTextManagerGetText = CS.XTextManager.GetText +local DescriptionTitle = CSXTextManagerGetText("EquipResonanceAwakeExplainTitle") +local Description = string.gsub(CSXTextManagerGetText("EquipResonanceAwakeExplain"), "\\n", "\n") +local XUiGridResonanceSkill = require("XUi/XUiEquipResonanceSkill/XUiGridResonanceSkill") + +local CONDITION_COLOR = { + [true] = CS.UnityEngine.Color.black, + [false] = CS.UnityEngine.Color.gray, +} + +local TOG_STATE = { + NORMAL = 0, + SELECT = 2, +} + +local XUiEquipResonanceAwake = XLuaUiManager.Register(XLuaUi, "UiEquipResonanceAwake") + +function XUiEquipResonanceAwake:OnAwake() + self:AutoAddListener() +end + +function XUiEquipResonanceAwake:OnStart(equipId, rootUi) + self.EquipId = equipId + self.RootUi = rootUi +end + +function XUiEquipResonanceAwake:OnEnable() + self:SetTogRedPoint() + self:UpdateTogButtonState() + self:UpdateResonanceSkill() + self:UpdateConsumeCoin() + self:UpdateConsumeItem() +end + +function XUiEquipResonanceAwake:OnGetEvents() + return { + XEventId.EVENT_EQUIP_AWAKE_NOTYFY, + XEventId.EVENT_ITEM_FAST_TRADING, + } +end + +function XUiEquipResonanceAwake:OnNotify(evt, ...) + if evt == XEventId.EVENT_EQUIP_AWAKE_NOTYFY then + local args = { ... } + local equipId = args[1] + local pos = args[2] + if equipId ~= self.EquipId then return end + if pos ~= self.Pos then return end + + self.RootUi:FindChildUiObj("UiEquipResonanceSkill").UiProxy:SetActive(true) + self.UiProxy:SetActive(false) + local isAwakeDes = true + local forceShowBindCharacter = self.RootUi.ForceShowBindCharacter + XLuaUiManager.Open("UiEquipResonanceSelectAfter", self.EquipId, self.Pos, self.RootUi.CharacterId, isAwakeDes, forceShowBindCharacter) + elseif evt == XEventId.EVENT_ITEM_FAST_TRADING then + self:UpdateResonanceSkill() + self:UpdateConsumeCoin() + self:UpdateConsumeItem() + end +end + +function XUiEquipResonanceAwake:Refresh(pos) + self.Pos = pos +end + +function XUiEquipResonanceAwake:UpdateResonanceSkill() + local isawake = true + self.TxtSlot.text = self.Pos + self.ResonanceSkillGrid = self.ResonanceSkillGrid or XUiGridResonanceSkill.New(self.GridResonanceSkill, self.EquipId, self.Pos) + self.ResonanceSkillGrid:SetEquipIdAndPos(self.EquipId, self.Pos, isawake) + self.ResonanceSkillGrid:Refresh() + self.ResonanceSkillGrid.GameObject:SetActiveEx(true) +end + +--@region 物品消耗列表 +function XUiEquipResonanceAwake:GetAwakeConsumeCoin(equipAwakeTabIndex) + if equipAwakeTabIndex == XEquipConfig.EquipAwakeTabIndex.Material then + return XDataCenter.EquipManager.GetAwakeConsumeCoin(self.EquipId) + elseif equipAwakeTabIndex == XEquipConfig.EquipAwakeTabIndex.CrystalMoney then + return XDataCenter.EquipManager.GetAwakeConsumeCrystalCoin(self.EquipId) + end +end + +function XUiEquipResonanceAwake:GetAwakeConsumeItemList(equipAwakeTabIndex) + if equipAwakeTabIndex == XEquipConfig.EquipAwakeTabIndex.Material then + return XDataCenter.EquipManager.GetAwakeConsumeItemList(self.EquipId) + elseif equipAwakeTabIndex == XEquipConfig.EquipAwakeTabIndex.CrystalMoney then + return XDataCenter.EquipManager.GetAwakeConsumeItemCrystalList(self.EquipId) + end +end + +function XUiEquipResonanceAwake:UpdateConsumeCoin() + local equipId = self.EquipId + + local consumeCoin = self:GetAwakeConsumeCoin(XEquipConfig.GetEquipAwakeTabIndex()) + if consumeCoin == 0 then + self.PanelCostCoin.gameObject:SetActiveEx(false) + else + self.TxtCostCoin.text = consumeCoin + self.PanelCostCoin.gameObject:SetActiveEx(true) + end + + local ownItemCount = XDataCenter.ItemManager.GetCount(XDataCenter.ItemManager.ItemId.Coin) + local coinEnough = ownItemCount >= consumeCoin + self.TxtCostCoin.color = CONDITION_COLOR[coinEnough] +end + +function XUiEquipResonanceAwake:UpdateConsumeItem() + local equipId = self.EquipId + local itemList = self:GetAwakeConsumeItemList(XEquipConfig.GetEquipAwakeTabIndex()) + + if next(itemList) then + self.ConsumeItem = self.ConsumeItem or {} + local length = #self.ConsumeItem > #itemList and #self.ConsumeItem or #itemList + for index=1,length do + local itemInfo = itemList[index] + if itemInfo then + local itemId = itemInfo.ItemId + local needCount = itemInfo.Count + local haveCount = XDataCenter.ItemManager.GetCount(itemId) + local consumeItemInfo = { + TemplateId = itemId, + Count = haveCount, + CostCount = needCount, + } + + self.ConsumeItem[index] = self.ConsumeItem[index] or XUiGridCommon.New(self, CS.UnityEngine.Object.Instantiate(self.GridCostItem)) + self.ConsumeItem[index].Transform:SetParent(self.PanelCostItem, false) + self.ConsumeItem[index]:Refresh(consumeItemInfo) + self.ConsumeItem[index].GameObject:SetActiveEx(true) + else + if self.ConsumeItem[index] then + self.ConsumeItem[index].GameObject:SetActiveEx(false) + end + end + end + + self.PanelCostItem.gameObject:SetActiveEx(true) + else + self.PanelCostItem.gameObject:SetActiveEx(false) + end + + self.GridCostItem.gameObject:SetActiveEx(false) + + local imageRedPoint = self:GetImgRedPoint(XEquipConfig.GetEquipAwakeTabIndex()) + imageRedPoint.gameObject:SetActiveEx(false) +end +--@endregion + + +--@region 点击事件 +function XUiEquipResonanceAwake:AutoAddListener() + self:RegisterClickEvent(self.BtnHelp, self.OnBtnHelpClick) + self.BtnAwake.CallBack = function() self:OnBtnAwakeClick() end + self.TogConsumeType.CallBack = function(value) self:OnTogConsumeTypeClick(value, true) end +end + +function XUiEquipResonanceAwake:OnBtnAwakeClick() + local equipId = self.EquipId + local pos = self.Pos + local coinEnough, itemEnough, consumeCoin = self:CheckIsEnough(XEquipConfig.GetEquipAwakeTabIndex()) + + if not coinEnough then + local closeCb = function () + self:UpdateConsumeCoin() + self:OnBtnAwakeClick() + end + if not XDataCenter.ItemManager.DoNotEnoughBuyAsset(XDataCenter.ItemManager.ItemId.Coin, consumeCoin, 1, closeCb, "EquipAwakenCoinNotEnough") then + return + end + end + + if not itemEnough then + XUiManager.TipText("EquipAwakenItemNotEnough") + return + end + + local title = CSXTextManagerGetText("EquipAwakeTipTitle") + local bindCharacterId = XDataCenter.EquipManager.GetResonanceBindCharacterId(equipId, pos) + local name = XCharacterConfigs.GetCharacterTradeName(bindCharacterId) + local content = CSXTextManagerGetText("EquipAwakeTipContent", name) + XUiManager.DialogTip(title, content, XUiManager.DialogType.Normal, nil, function() + XDataCenter.EquipManager.Awake(equipId, pos, XEquipConfig.GetEquipAwakeTabIndex()) + end) +end + +function XUiEquipResonanceAwake:OnBtnHelpClick() + XUiManager.UiFubenDialogTip(DescriptionTitle, Description) +end + +function XUiEquipResonanceAwake:OnTogConsumeTypeClick(value, doTip) + XEquipConfig.SetEquipAwakeTabIndex(value == 0 and XEquipConfig.EquipAwakeTabIndex.Material or XEquipConfig.EquipAwakeTabIndex.CrystalMoney) + + self:UpdateConsumeCoin() + self:UpdateConsumeItem() +end +--@endregion + +function XUiEquipResonanceAwake:UpdateTogButtonState() + if XEquipConfig.GetEquipAwakeTabIndex() == XEquipConfig.EquipAwakeTabIndex.Material then + self.TogConsumeType:SetButtonState(TOG_STATE.NORMAL) + else + self.TogConsumeType:SetButtonState(TOG_STATE.SELECT) + end +end + +function XUiEquipResonanceAwake:UpdateTogButtonState() + if XEquipConfig.GetEquipAwakeTabIndex() == XEquipConfig.EquipAwakeTabIndex.Material then + self.TogConsumeType:SetButtonState(TOG_STATE.NORMAL) + else + self.TogConsumeType:SetButtonState(TOG_STATE.SELECT) + end +end + +function XUiEquipResonanceAwake:SetTogRedPoint() + local coinEnough, itemEnough, consumeCoin = self:CheckIsEnough(XEquipConfig.EquipAwakeTabIndex.CrystalMoney) + self.ImgRedPointCrystal.gameObject:SetActiveEx(coinEnough and itemEnough) + + local coinEnough, itemEnough, consumeCoin = self:CheckIsEnough(XEquipConfig.EquipAwakeTabIndex.Material) + self.ImgRedPointMaterials.gameObject:SetActiveEx(coinEnough and itemEnough) +end + +function XUiEquipResonanceAwake:GetImgRedPoint(equipAwakeTabIndex) + if equipAwakeTabIndex == XEquipConfig.EquipAwakeTabIndex.Material then + return self.ImgRedPointMaterials + else + return self.ImgRedPointCrystal + end +end + +function XUiEquipResonanceAwake:CheckIsEnough(equipAwakeTabIndex) + local itemEnough = true + local itemList = self:GetAwakeConsumeItemList(equipAwakeTabIndex) + local consumeCoin = self:GetAwakeConsumeCoin(equipAwakeTabIndex) + local ownItemCount = XDataCenter.ItemManager.GetCount(XDataCenter.ItemManager.ItemId.Coin) + local coinEnough = ownItemCount >= consumeCoin + + for index=1,#itemList do + local itemInfo = itemList[index] + local itemId = itemInfo.ItemId + local needCount = itemInfo.Count + local haveCount = XDataCenter.ItemManager.GetCount(itemId) + if haveCount < needCount then + itemEnough = false + break + end + end + + return itemEnough, coinEnough, consumeCoin +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiEquipResonanceSelect/XUiEquipResonanceSelect.lua b/Resources/Scripts/XUi/XUiEquipResonanceSelect/XUiEquipResonanceSelect.lua new file mode 100644 index 00000000..85a326d6 --- /dev/null +++ b/Resources/Scripts/XUi/XUiEquipResonanceSelect/XUiEquipResonanceSelect.lua @@ -0,0 +1,525 @@ +local CsXTextManagerGetText = CS.XTextManager.GetText + +local XUiGridEquip = require("XUi/XUiEquipAwarenessReplace/XUiGridEquip") +local XUiGridResonanceSkill = require("XUi/XUiEquipResonanceSkill/XUiGridResonanceSkill") + +local TabConsumeType = { + Equip = 0, + Item = 1, +} + +--对应按钮状态(避免歧义) +local TCTButtonState = { + NORMAL = 0, + SELECT = 2, + Disable = 3 +} + +local XUiEquipResonanceSelect = XLuaUiManager.Register(XLuaUi, "UiEquipResonanceSelect") + +function XUiEquipResonanceSelect:OnAwake() + self:AutoAddListener() + self.GridCurAwareness.gameObject:SetActiveEx(false) + self.GridCurItem.gameObject:SetActiveEx(false) +end + +function XUiEquipResonanceSelect:OnStart(equipId, rootUi) + self.RootUi = rootUi + self.EquipId = equipId + self.DescriptionTitle = CsXTextManagerGetText("EquipResonanceExplainTitle") + self.Description = string.gsub(CsXTextManagerGetText("EquipResonanceExplain"), "\\n", "\n") +end + +function XUiEquipResonanceSelect:OnEnable() + self.TabConsumeType = TabConsumeType.Equip + + self:ClearData() + self:InitRightView() + self:UpdateBtnStatus() + self:SetTCTButtonStateByTabConsumeType(self.TabConsumeType) + self:OnTogConsumeTypeClick(self.TabConsumeType) + self:UpdateCurCharacter() + self:UpdateResonanceSkill() + self:UpdateResonanceConsumeItem() + self:UpdateCurGrid() +end + +function XUiEquipResonanceSelect:OnGetEvents() + return { XEventId.EVENT_EQUIP_RESONANCE_NOTYFY, XEventId.EVENT_EQUIP_RESONANCE_ACK_NOTYFY } +end + +function XUiEquipResonanceSelect:OnNotify(evt, ...) + local args = { ... } + local equipId = args[1] + local pos = args[2] + if equipId ~= self.EquipId then return end + if pos ~= self.Pos then return end + + if evt == XEventId.EVENT_EQUIP_RESONANCE_NOTYFY then + self.RootUi:FindChildUiObj("UiEquipResonanceSkill").UiProxy:SetActive(true) + self.UiProxy:SetActive(false) + + local forceShowBindCharacter = self.RootUi.ForceShowBindCharacter + --如果是武器自选只需要弹提示 + if XDataCenter.EquipManager.IsClassifyEqual(self.EquipId, XEquipConfig.Classify.Weapon) then + if self.IsNewSkill then + XLuaUiManager.Open("UiEquipResonanceSelectAfter", self.EquipId, self.Pos, self.RootUi.CharacterId, nil, forceShowBindCharacter) + else + XUiManager.TipText("EquipResonanceChangeSuccess") + end + else + XLuaUiManager.Open("UiEquipResonanceSelectAfter", self.EquipId, self.Pos, self.RootUi.CharacterId, nil, forceShowBindCharacter) + end + + self:ClearData() + self:UpdateBtnStatus() + self:OnTogConsumeTypeClick(self.TabConsumeType) + self:UpdateResonanceSkill() + elseif evt == XEventId.EVENT_EQUIP_RESONANCE_ACK_NOTYFY then + self:ClearData() + self:UpdateBtnStatus() + self:OnTogConsumeTypeClick(self.TabConsumeType) + self:UpdateResonanceSkill() + end +end + +function XUiEquipResonanceSelect:Refresh(pos) + self.Pos = pos + self:ClearData() +end + +function XUiEquipResonanceSelect:ClearData() + self.SelectCharacterId = nil + self.SelectEquipId = nil + self.SelectSkillInfo = nil + self.SelectItemId = nil +end + +function XUiEquipResonanceSelect:UpdateConsumeTxt() + local equipId = self.EquipId + if self.TabConsumeType == TabConsumeType.Item then + local consumeCount + if XDataCenter.EquipManager.GetResonanceConsumeSelectSkillItemId(self.EquipId) == self.SelectItemId then + consumeCount = XDataCenter.EquipManager.GetResonanceConsumeSelectSkillItemCount(equipId) + else + consumeCount = XDataCenter.EquipManager.GetResonanceConsumeItemCount(equipId) + end + self.TxtConsumeWhat.text = CsXTextManagerGetText("EquipResonanceConsumeItemCount", consumeCount) + elseif self.TabConsumeType == TabConsumeType.Equip then + if XDataCenter.EquipManager.IsClassifyEqual(equipId, XEquipConfig.Classify.Weapon) then + self.TxtConsumeWhat.text = CsXTextManagerGetText("WeaponStrengthenTitle") + self.TogConsumeType:SetNameByGroup(0, CsXTextManagerGetText("TypeWeapon")) + elseif XDataCenter.EquipManager.IsClassifyEqual(equipId, XEquipConfig.Classify.Awareness) then + self.TxtConsumeWhat.text = CsXTextManagerGetText("AwarenessStrengthenTitle") + self.TogConsumeType:SetNameByGroup(0, CsXTextManagerGetText("TypeWafer")) + end + end +end + +function XUiEquipResonanceSelect:InitRightView() + local equipId = self.EquipId + + --专属装备自动选择共鸣绑定角色 + local equipSpecialCharacterId = XDataCenter.EquipManager.GetEquipSpecialCharacterId(equipId) + if equipSpecialCharacterId and equipSpecialCharacterId > 0 then + self.SelectCharacterId = equipSpecialCharacterId + self.PanelCharacter.gameObject:SetActiveEx(true) + else + --五星以上才可以选择共鸣绑定角色 + if XDataCenter.EquipManager.CanResonanceBindCharacter(equipId) then + local wearingCharacterId = XDataCenter.EquipManager.GetEquipWearingCharacterId(equipId) + self.SelectCharacterId = wearingCharacterId + self.PanelCharacter.gameObject:SetActiveEx(true) + else + self.PanelCharacter.gameObject:SetActiveEx(false) + end + end + + self.CurEquipGird = self.CurEquipGird or XUiGridEquip.New(self.GridCurAwareness, function() + self:OnBtnSelectAwarenessClick() + end,self) + + self.CurItemGird = self.CurItemGird or XUiGridCommon.New(self, self.GridCurItem) + self.CurItemGird:SetClickCallback(function () + self:OnBtnSelectAwarenessClick() + end) +end + +function XUiEquipResonanceSelect:UpdateCurGrid() + local buttonState = self:GetTCTButtonState(self.TabConsumeType) + if buttonState == TCTButtonState.Disable then + self.CurItemGird.GameObject:SetActiveEx(false) + self.CurEquipGird.GameObject:SetActiveEx(false) + self.PanelNoAwareness.gameObject:SetActiveEx(false) + self.TxtNoConsumption.gameObject:SetActiveEx(true) + elseif buttonState == TCTButtonState.NORMAL then + if not self.SelectEquipId then + self.CurItemGird.GameObject:SetActiveEx(false) + self.CurEquipGird.GameObject:SetActiveEx(false) + self.PanelNoAwareness.gameObject:SetActiveEx(true) + self.TxtNoConsumption.gameObject:SetActiveEx(false) + else + self.CurEquipGird:Refresh(self.SelectEquipId) + self.CurEquipGird.GameObject:SetActiveEx(true) + self.CurItemGird.GameObject:SetActiveEx(false) + self.PanelNoAwareness.gameObject:SetActiveEx(false) + self.TxtNoConsumption.gameObject:SetActiveEx(false) + end + elseif buttonState == TCTButtonState.SELECT then + if not self.SelectItemId then + self.CurEquipGird.GameObject:SetActiveEx(false) + self.CurItemGird.GameObject:SetActiveEx(false) + self.PanelNoAwareness.gameObject:SetActiveEx(true) + self.TxtNoConsumption.gameObject:SetActiveEx(false) + else + self.CurItemGird:Refresh(self.SelectItemId) + self.CurEquipGird.GameObject:SetActiveEx(false) + self.CurItemGird.GameObject:SetActiveEx(true) + self.PanelNoAwareness.gameObject:SetActiveEx(false) + self.TxtNoConsumption.gameObject:SetActiveEx(false) + end + end +end + +function XUiEquipResonanceSelect:UpdateCurCharacter() + if not self.SelectCharacterId then + self.PanelCurCharacter.gameObject:SetActiveEx(false) + self.PanelNoCharacter.gameObject:SetActiveEx(true) + else + self.PanelCurCharacter.gameObject:SetActiveEx(true) + self.PanelNoCharacter.gameObject:SetActiveEx(false) + + self.RImgHead:SetRawImage(XDataCenter.CharacterManager.GetCharSmallHeadIcon(self.SelectCharacterId)) + end +end + +function XUiEquipResonanceSelect:UpdateResonanceSkill() + self.TxtSlot.text = self.Pos + if self.SelectSkillInfo then + self:UpdateUiGridResonanceSkill(self.SelectSkillInfo, self.SelectCharacterId) + self.TxtNoAwareness.gameObject:SetActiveEx(false) + elseif XDataCenter.EquipManager.CheckEquipPosResonanced(self.EquipId, self.Pos) then + self:UpdateUiGridResonanceSkill() + self.TxtNoAwareness.gameObject:SetActiveEx(false) + else + if self.ResonanceSkillGrid then + self.ResonanceSkillGrid.GameObject:SetActiveEx(false) + end + self.TxtNoAwareness.gameObject:SetActiveEx(true) + end +end + +function XUiEquipResonanceSelect:UpdateUiGridResonanceSkill(skillInfo, characterId) + if not self.ResonanceSkillGrid then + self.ResonanceSkillGrid = XUiGridResonanceSkill.New(self.GridResonanceSkill, self.EquipId, self.Pos) + end + + self.ResonanceSkillGrid:SetEquipIdAndPos(self.EquipId, self.Pos) + self.ResonanceSkillGrid:Refresh(skillInfo, characterId) + self.ResonanceSkillGrid.GameObject:SetActiveEx(true) + self.TxtChoice.gameObject:SetActiveEx(self.SelectSkillInfo ~= nil) +end + +function XUiEquipResonanceSelect:UpdateResonanceConsumeItem() + local consumeItemId = XDataCenter.EquipManager.GetResonanceConsumeItemId(self.EquipId) + local consumeSelectSkillItemId = XDataCenter.EquipManager.GetResonanceConsumeSelectSkillItemId(self.EquipId) + + if not consumeItemId and not consumeSelectSkillItemId then return end + + if not self.ConsumeItems then + self.ConsumeItems = {} + end + + local index = 1 + + local function RefreshItem(itemId) + local gridConsumeItem = self["GridConsumeItem" .. index] + if not itemId then + gridConsumeItem.gameObject:SetActiveEx(false) + return + end + + local consumeItemInfo = {} + consumeItemInfo.TemplateId = itemId + consumeItemInfo.Count = XDataCenter.ItemManager.GetCount(itemId) + + local consumeItem + if self.ConsumeItems[index] then + consumeItem = self.ConsumeItems[index] + else + consumeItem = XUiGridCommon.New(self, gridConsumeItem) + end + consumeItem:Refresh(consumeItemInfo) + gridConsumeItem.gameObject:SetActiveEx(true) + index = index + 1 + end + + RefreshItem(consumeItemId) + RefreshItem(consumeSelectSkillItemId) +end + +function XUiEquipResonanceSelect:UpdateBtnStatus() + if self.SelectCharacterId then + self.BtnSkillPreview.gameObject:SetActiveEx(true) + else + self.BtnSkillPreview.gameObject:SetActiveEx(false) + end + + local state = self:GetBtnResonanceState() + self.BtnResonance:SetDisable(not state) + + --物品不足时或可无消耗共鸣,不可切换至消耗物品, + if not XDataCenter.EquipManager.CheckResonanceConsumeItemEnough(self.EquipId) or self:CheckIsNoConsumption() then + self.TogConsumeType:SetDisable(true) + else + self.TogConsumeType:SetDisable(false) + self:SetTCTButtonStateByTabConsumeType(self.TabConsumeType) + end + + self:UpdateBtnSkillPreviewName() +end + +--@region 绑定onclick事件 +function XUiEquipResonanceSelect:AutoAddListener() + self:RegisterClickEvent(self.BtnSkillPreview, self.OnBtnSkillPreviewClick) + self:RegisterClickEvent(self.BtnSelectCharacter, self.OnBtnSelectCharacterClick) + self:RegisterClickEvent(self.BtnCharacterClick, self.OnBtnCharacterClickClick) + self:RegisterClickEvent(self.BtnSelectAwareness, self.OnBtnSelectAwarenessClick) + self:RegisterClickEvent(self.BtnHelp, self.OnBtnHelpClick) + self:RegisterClickEvent(self.BtnNoConsumption, self.OnBtnNoConsumption) + + self.BtnResonance.CallBack = function() self:OnBtnResonanceClick() end + self.TogConsumeType.CallBack = function(value) self:OnTogConsumeTypeClick(value, true) end +end + +function XUiEquipResonanceSelect:OnBtnCharacterClickClick() + local equipSpecialCharacterId = XDataCenter.EquipManager.GetEquipSpecialCharacterId(self.EquipId) + if equipSpecialCharacterId and equipSpecialCharacterId > 0 then + XUiManager.TipText("EquipIsBindCharacter") + return + end + + self:OnBtnSelectCharacterClick() +end + +function XUiEquipResonanceSelect:OnBtnNoConsumption() + XUiManager.TipText("EquipResonanceSelectFree") +end + +function XUiEquipResonanceSelect:OnBtnResonanceClick() + local useEquipId + local useItemId + local selectSkillId + local equipResonanceType + local state, msg = self:GetBtnResonanceState() + + if not state then + XUiManager.TipMsg(msg) + return + end + + if self.SelectSkillInfo then + selectSkillId = self.SelectSkillInfo:GetSkillIdToServer() + equipResonanceType = self.SelectSkillInfo.EquipResonanceType + end + + if not self:CheckIsNoConsumption() then + if self.TabConsumeType == TabConsumeType.Equip then + useEquipId = self.SelectEquipId + else + useItemId = self.SelectItemId + end + end + + --是否获得新技能 + if self:SelectCharacteIsBindCharacte() then + self.IsNewSkill = not XDataCenter.EquipManager.CheckEquipPosResonanced(self.EquipId, self.Pos) + else + self.IsNewSkill = true + end + + XDataCenter.EquipManager.Resonance( + self.EquipId, + self.Pos, + self.SelectCharacterId, + useEquipId, + useItemId, + selectSkillId, + equipResonanceType + ) +end + +function XUiEquipResonanceSelect:OnBtnSkillPreviewClick() + XLuaUiManager.Open("UiEquipResonanceSkillPreview", { + pos = self.Pos, + rootUi = self, + selectSkillInfo = self.SelectSkillInfo, + isNeedSelectSkill = self:IsNeedSelectSkill(), + ClickCb = function (skillInfo) + self.SelectSkillInfo = skillInfo + self:UpdateBtnStatus() + self:UpdateResonanceSkill() + end + }) +end + +function XUiEquipResonanceSelect:OnBtnSelectCharacterClick() + local confirmCb = function(selectCharacterId) + self.SelectCharacterId = selectCharacterId + self:UpdateBtnStatus() + self:UpdateCurCharacter() + self:UpdateCurGrid() + end + self.RootUi:OpenChildUi("UiEquipResonanceSelectCharacter", self.EquipId, confirmCb) +end + +function XUiEquipResonanceSelect:OnBtnSelectAwarenessClick() + if self.TabConsumeType == TabConsumeType.Equip then + self.RootUi:OpenChildUi("UiEquipResonanceSelectEquip", self.EquipId, function(selectEquipId) + self.SelectEquipId = selectEquipId + self:UpdateBtnStatus() + self:OnTogConsumeTypeClick(self.TabConsumeType) + end) + elseif self.TabConsumeType == TabConsumeType.Item then + local isEnough, itemIds = XDataCenter.EquipManager.CheckResonanceConsumeItemEnough(self.EquipId) + + if isEnough and #itemIds >= 2 then + self.RootUi:OpenChildUi("UiEquipResonanceSelectItem", self.EquipId, function(selectItemId) + self.SelectItemId = selectItemId + self:UpdateBtnStatus() + self:UpdateCurGrid() + end) + else + if self.SelectItemId then + XLuaUiManager.Open("UiTip", self.SelectItemId) + end + end + end +end + +function XUiEquipResonanceSelect:OnBtnHelpClick() + XUiManager.UiFubenDialogTip(self.DescriptionTitle, self.Description) +end + +function XUiEquipResonanceSelect:OnTogConsumeTypeClick(value, doTip) + local buttonState = self:GetTCTButtonState(self.TabConsumeType) + if buttonState == TCTButtonState.Disable then + return + end + + if value == TabConsumeType.Item then + local isEnough, itemIds = XDataCenter.EquipManager.CheckResonanceConsumeItemEnough(self.EquipId) + if not isEnough then + if doTip then + XUiManager.TipText("EquipResonanceConsumeItemLack") + end + + return + end + + if not self.SelectItemId then + if #itemIds == 1 then + self.SelectItemId = itemIds[1] + end + end + self.SelectEquipId = nil + else + self.SelectItemId = nil + end + + self.TabConsumeType = value + + self:UpdateCurGrid() + self:UpdateConsumeTxt() + self:UpdateBtnStatus() +end + +--@endregion + +function XUiEquipResonanceSelect:UpdateBtnSkillPreviewName() + if XDataCenter.EquipManager.IsClassifyEqual(self.EquipId, XEquipConfig.Classify.Weapon) then + if XDataCenter.EquipManager.CheckEquipPosResonanced(self.EquipId, self.Pos) and self:SelectCharacteIsBindCharacte() then + self.BtnSkillPreview:SetName(CsXTextManagerGetText("EquipResonanceChange")) + else + self.BtnSkillPreview:SetName(CsXTextManagerGetText("EquipResonanceSelect")) + end + else + if XDataCenter.EquipManager.GetResonanceConsumeSelectSkillItemId(self.EquipId) == self.SelectItemId then + self.BtnSkillPreview:SetName(CsXTextManagerGetText("EquipResonanceSelect")) + else + self.BtnSkillPreview:SetName(CsXTextManagerGetText("EquipResonancePreview")) + end + end +end + +--不需要消耗材料即可共鸣 +function XUiEquipResonanceSelect:CheckIsNoConsumption() + if XDataCenter.EquipManager.IsClassifyEqual(self.EquipId, XEquipConfig.Classify.Weapon) then + local isFiveStar = XDataCenter.EquipManager.IsFiveStar(self.EquipId) + if not isFiveStar then + return self:SelectCharacteIsBindCharacte() + else + return false + end + else + return false + end +end + +function XUiEquipResonanceSelect:IsNeedSelectSkill() + if XDataCenter.EquipManager.IsClassifyEqual(self.EquipId, XEquipConfig.Classify.Weapon) then + if XDataCenter.EquipManager.CanResonanceBindCharacter(self.EquipId) then + local isFiveStar = XDataCenter.EquipManager.IsFiveStar(self.EquipId) + return not isFiveStar + else + return false + end + else + if self.SelectItemId then + return XDataCenter.EquipManager.GetResonanceConsumeSelectSkillItemId(self.EquipId) == self.SelectItemId + else + return false + end + end +end + +function XUiEquipResonanceSelect:SetTCTButtonStateByTabConsumeType(tabConsumeType) + self.TabConsumeType = tabConsumeType + self.TogConsumeType:SetButtonState(self:GetTCTButtonState(tabConsumeType)) +end + +function XUiEquipResonanceSelect:GetTCTButtonState(tabConsumeType) + if self:CheckIsNoConsumption() then + return TCTButtonState.Disable + else + if tabConsumeType == TabConsumeType.Equip then + return TCTButtonState.NORMAL + else + return TCTButtonState.SELECT + end + end +end + +function XUiEquipResonanceSelect:GetBtnResonanceState() + if self:IsNeedSelectSkill() and not self.SelectSkillInfo then + return false, CsXTextManagerGetText("EquipResonanceSelectTips") + else + local buttonState = self:GetTCTButtonState(self.TabConsumeType) + if buttonState == TCTButtonState.Disable then + return true + else + if self.TabConsumeType == TabConsumeType.Equip and not self.SelectEquipId then + return false, CsXTextManagerGetText("EquipResonanceSelectEquipTips") + elseif self.TabConsumeType == TabConsumeType.Item and not self.SelectItemId then + return false, CsXTextManagerGetText("EquipResonanceSelectItemTips") + else + return true + end + end + end +end + +function XUiEquipResonanceSelect:SelectCharacteIsBindCharacte() + local bindCharacterId = XDataCenter.EquipManager.GetResonanceBindCharacterId(self.EquipId, self.Pos) + return self.SelectCharacterId == bindCharacterId +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiEquipResonanceSelect/XUiEquipResonanceSelectAfter.lua b/Resources/Scripts/XUi/XUiEquipResonanceSelect/XUiEquipResonanceSelectAfter.lua new file mode 100644 index 00000000..57ef51d3 --- /dev/null +++ b/Resources/Scripts/XUi/XUiEquipResonanceSelect/XUiEquipResonanceSelectAfter.lua @@ -0,0 +1,185 @@ +local XUiGridResonanceSkill = require("XUi/XUiEquipResonanceSkill/XUiGridResonanceSkill") +local XUiEquipResonanceSelectAfter = XLuaUiManager.Register(XLuaUi, "UiEquipResonanceSelectAfter") + +function XUiEquipResonanceSelectAfter:OnAwake() + self:InitAutoScript() + local sceneRootTrans = self.UiModelGo + self.PanelWeapon = sceneRootTrans:FindTransform("PanelWeapon") + self.EffectAwakeGo = sceneRootTrans:FindTransform("EffectAwakeGo").gameObject +end + +function XUiEquipResonanceSelectAfter:OnStart(equipId, pos, characterId, isAwakeDes, forceShowBindCharacter) + self.CharacterId = characterId + self.EquipId = equipId + self.Pos = pos + self.IsAwakeDes = isAwakeDes + self.ForceShowBindCharacter = forceShowBindCharacter + + self:InitClassifyPanel() +end + +function XUiEquipResonanceSelectAfter:OnEnable() + CS.XAudioManager.PlaySound(XSoundManager.UiBasicsMusic.UiEquip_ResonanceSelectAfter) + self:UpdateResonanceSkillGrids() +end + +function XUiEquipResonanceSelectAfter:OnDisable() + self:RemoveWeaponTimer() +end + +function XUiEquipResonanceSelectAfter:OnDestroy() + if self.Resource then + CS.XResourceManager.Unload(self.Resource) + self.Resource = nil + end + self:RemoveWeaponTimer() +end + +function XUiEquipResonanceSelectAfter:OnGetEvents() + return { XEventId.EVENT_EQUIP_RESONANCE_ACK_NOTYFY } +end + +function XUiEquipResonanceSelectAfter:OnNotify(evt, ...) + local args = { ... } + local equipId = args[1] + if equipId ~= self.EquipId then return end + + if evt == XEventId.EVENT_EQUIP_RESONANCE_ACK_NOTYFY then + self:Close() + end +end + +function XUiEquipResonanceSelectAfter:InitClassifyPanel() + self.FxUiLihuiChuxian01.gameObject:SetActiveEx(false) + if XDataCenter.EquipManager.IsClassifyEqual(self.EquipId, XEquipConfig.Classify.Weapon) then + local modelConfig = XDataCenter.EquipManager.GetWeaponModelCfgByEquipId(self.EquipId, self.Name) + self.EffectAwakeGo.gameObject:SetActiveEx(false) + self:RemoveWeaponTimer() + if modelConfig then + XModelManager.LoadWeaponModel(modelConfig.ModelId, self.PanelWeapon, modelConfig.TransformConfig, self.Name, function(model) + -- 延时显示模型 + local delay = XEquipConfig.WeaponResonanceShowDelay + if delay ~= 0 then + model:SetActiveEx(false) + self.scheduleIdModel = XScheduleManager.ScheduleOnce(function() + model:SetActiveEx(true) + XModelManager.PlayWeaponShowing(model, modelConfig.ModelId, self.Name, self.GameObject, { usage = XEquipConfig.WeaponUsage.Show }) + XModelManager.AutoRotateWeapon(self.PanelWeapon, model, modelConfig.ModelId, self.GameObject) + end, delay) + else + XModelManager.PlayWeaponShowing(model, modelConfig.ModelId, self.Name, self.GameObject, { usage = XEquipConfig.WeaponUsage.Show }) + XModelManager.AutoRotateWeapon(self.PanelWeapon, model, modelConfig.ModelId, self.GameObject) + end + + -- 延时ui特效 + local resonanceCount = XDataCenter.EquipManager.GetResonanceCount(self.EquipId) + local effectDelay = XDataCenter.EquipManager.GetWeaponResonanceEffectDelay(self.EquipId, resonanceCount) + if effectDelay then + self.scheduleIdEffect = XScheduleManager.ScheduleOnce(function() + self.EffectAwakeGo:SetActiveEx(true) + end, effectDelay) + end + end, { noShowing = true, gameObject = self.GameObject, noRotation = true }) + end + self.PanelWeapon.gameObject:SetActiveEx(true) + self.PanelAwareness.gameObject:SetActiveEx(false) + elseif XDataCenter.EquipManager.IsClassifyEqual(self.EquipId, XEquipConfig.Classify.Awareness) then + local equip = XDataCenter.EquipManager.GetEquip(self.EquipId) + local resource = CS.XResourceManager.Load(XDataCenter.EquipManager.GetEquipLiHuiPath(equip.TemplateId, equip.Breakthrough)) + local texture = resource.Asset + self.MeshLihui.sharedMaterial:SetTexture("_MainTex", texture) + if self.Resource then + CS.XResourceManager.Unload(self.Resource) + end + self.Resource = resource + XScheduleManager.ScheduleOnce(function() + if XTool.UObjIsNil(self.FxUiLihuiChuxian01) then return end + self.FxUiLihuiChuxian01.gameObject:SetActiveEx(true) + end, 500) + + self.PanelAwareness.gameObject:SetActiveEx(true) + self.PanelWeapon.gameObject:SetActiveEx(false) + end +end + +function XUiEquipResonanceSelectAfter:RemoveWeaponTimer() + if self.scheduleIdModel then + XScheduleManager.UnSchedule(self.scheduleIdModel) + self.scheduleIdModel = nil + end + if self.scheduleIdEffect then + XScheduleManager.UnSchedule(self.scheduleIdEffect) + self.scheduleIdEffect = nil + end +end + +function XUiEquipResonanceSelectAfter:UpdateResonanceSkillGrids() + local isAwakeDes = self.IsAwakeDes + local characterId = self.CharacterId + local forceShowBindCharacter = self.ForceShowBindCharacter + + self.ImgNewTag.gameObject:SetActiveEx(not isAwakeDes) + self.TxtSlot.text = CS.XTextManager.GetText("EquipResonancePosText", self.Pos) + + self.ResonanceSkillGridOld = self.ResonanceSkillGridOld or XUiGridResonanceSkill.New(self.GridResonanceSkill, self.EquipId, self.Pos, characterId, nil, isAwakeDes, forceShowBindCharacter) + self.ResonanceSkillGridNew = self.ResonanceSkillGridNew or XUiGridResonanceSkill.New(self.GridResonanceSkillA, self.EquipId, self.Pos, characterId, nil, isAwakeDes, forceShowBindCharacter) + + local unconfirmedSkillInfo = XDataCenter.EquipManager.GetUnconfirmedResonanceSkillInfo(self.EquipId, self.Pos) + local bindCharacterId = XDataCenter.EquipManager.GetUnconfirmedResonanceBindCharacterId(self.EquipId, self.Pos) + + if not XDataCenter.EquipManager.CheckEquipPosUnconfirmedResonanced(self.EquipId, self.Pos) then + self.ResonanceSkillGridNew:Refresh() + self.BtnConfirm.gameObject:SetActiveEx(true) + self.BtnChange.gameObject:SetActiveEx(false) + self.PanelSlotOld.gameObject:SetActiveEx(false) + self:PlayAnimation("RImgLihui") + else + self.ResonanceSkillGridOld:Refresh() + self.ResonanceSkillGridNew:Refresh(unconfirmedSkillInfo, bindCharacterId) + + self.BtnConfirm.gameObject:SetActiveEx(false) + self.BtnChange.gameObject:SetActiveEx(true) + self.PanelSlotOld.gameObject:SetActiveEx(true) + self:PlayAnimation("ContianerEnable") + end +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiEquipResonanceSelectAfter:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiEquipResonanceSelectAfter:AutoInitUi() + self.PanelSlotNew = self.Transform:Find("SafeAreaContentPane/Contianer/Layout/PanelSlotNew") + self.GridResonanceSkillA = self.Transform:Find("SafeAreaContentPane/Contianer/Layout/PanelSlotNew/GridResonanceSkill") + self.RImgResonanceSkillA = self.Transform:Find("SafeAreaContentPane/Contianer/Layout/PanelSlotNew/GridResonanceSkill/RImgResonanceSkill"):GetComponent("RawImage") + self.BtnChange = self.Transform:Find("SafeAreaContentPane/Contianer/Layout/PanelSlotNew/BtnChange"):GetComponent("Button") + self.BtnConfirm = self.Transform:Find("SafeAreaContentPane/Contianer/Layout/PanelSlotNew/BtnConfirm"):GetComponent("Button") + self.PanelSlotOld = self.Transform:Find("SafeAreaContentPane/Contianer/Layout/PanelSlotOld") + self.GridResonanceSkill = self.Transform:Find("SafeAreaContentPane/Contianer/Layout/PanelSlotOld/GridResonanceSkill") + self.RImgResonanceSkill = self.Transform:Find("SafeAreaContentPane/Contianer/Layout/PanelSlotOld/GridResonanceSkill/RImgResonanceSkill"):GetComponent("RawImage") + self.TxtSlot = self.Transform:Find("SafeAreaContentPane/Contianer/Layout/PanelSlotOld/TxtSlot"):GetComponent("Text") + self.BtnRemain = self.Transform:Find("SafeAreaContentPane/Contianer/Layout/PanelSlotOld/BtnRemain"):GetComponent("Button") + self.PanelAwareness = self.Transform:Find("SafeAreaContentPane/Left/PanelAwareness") + self.PanelCharacter = self.Transform:Find("SafeAreaContentPane/Left/PanelCharacter") +end + +function XUiEquipResonanceSelectAfter:AutoAddListener() + self:RegisterClickEvent(self.BtnChange, self.OnBtnChangeClick) + self:RegisterClickEvent(self.BtnConfirm, self.OnBtnConfirmClick) + self:RegisterClickEvent(self.BtnRemain, self.OnBtnRemainClick) +end +-- auto +function XUiEquipResonanceSelectAfter:OnBtnConfirmClick() + self:Close() +end + +function XUiEquipResonanceSelectAfter:OnBtnChangeClick() + XDataCenter.EquipManager.ResonanceConfirm(self.EquipId, self.Pos, true) +end + +function XUiEquipResonanceSelectAfter:OnBtnRemainClick() + XDataCenter.EquipManager.ResonanceConfirm(self.EquipId, self.Pos, false) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiEquipResonanceSelect/XUiEquipResonanceSelectCharacter.lua b/Resources/Scripts/XUi/XUiEquipResonanceSelect/XUiEquipResonanceSelectCharacter.lua new file mode 100644 index 00000000..1524a083 --- /dev/null +++ b/Resources/Scripts/XUi/XUiEquipResonanceSelect/XUiEquipResonanceSelectCharacter.lua @@ -0,0 +1,71 @@ +local XUiEquipResonanceSelectCharacter = XLuaUiManager.Register(XLuaUi, "UiEquipResonanceSelectCharacter") + +function XUiEquipResonanceSelectCharacter:OnAwake() + self:InitAutoScript() + self.GridCharacter.gameObject:SetActive(false) +end + +function XUiEquipResonanceSelectCharacter:OnStart(equipId, confirmCb) + self.EquipId = equipId + self.ConfirmCb = confirmCb + self:InitCharacterList() +end + +function XUiEquipResonanceSelectCharacter:OnEnable(...) + self.SelectCharacterId = nil + self:RefreshList() +end + +function XUiEquipResonanceSelectCharacter:InitCharacterList() + self.CharacterGridDic = {} + + local clickCallback = function(character) + self.SelectCharacterId = character.Id + self:RefreshList(self.SelectCharacterId) + end + + local noCharacter = true + local canResonanceCharacterList = XDataCenter.EquipManager.GetCanResonanceCharacterList(self.EquipId) + for _, character in pairs(canResonanceCharacterList) do + if not self.CharacterGridDic[character.Id] then + local item = CS.UnityEngine.Object.Instantiate(self.GridCharacter) + local grid = XUiGridCharacter.New(item, self, character, clickCallback) + grid.GameObject:SetActive(true) + grid.Transform:SetParent(self.PanelCharacterContent, false) + self.CharacterGridDic[character.Id] = grid + noCharacter = false + end + end + self.PanelNoCharacter.gameObject:SetActive(noCharacter) +end + +function XUiEquipResonanceSelectCharacter:RefreshList(selectCharacterId) + self.BtnConfirm:SetDisable(not selectCharacterId, true) + + for characterId, characterGridDic in pairs(self.CharacterGridDic) do + characterGridDic:UpdateGrid(nil, selectCharacterId) + end +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiEquipResonanceSelectCharacter:InitAutoScript() + self:AutoAddListener() +end + +function XUiEquipResonanceSelectCharacter:AutoAddListener() + self:RegisterClickEvent(self.BtnConfirm, self.OnBtnConfirmClick) + self:RegisterClickEvent(self.BtnClose, self.OnBtnCloseClick) + self:RegisterClickEvent(self.Btncancel, self.OnBtnCloseClick) +end +-- auto +function XUiEquipResonanceSelectCharacter:OnBtnCloseClick() + self:Close() +end + +function XUiEquipResonanceSelectCharacter:OnBtnConfirmClick() + if self.ConfirmCb and self.SelectCharacterId then + self.ConfirmCb(self.SelectCharacterId) + self:Close() + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiEquipResonanceSelect/XUiEquipResonanceSelectEquip.lua b/Resources/Scripts/XUi/XUiEquipResonanceSelect/XUiEquipResonanceSelectEquip.lua new file mode 100644 index 00000000..3c7eb18f --- /dev/null +++ b/Resources/Scripts/XUi/XUiEquipResonanceSelect/XUiEquipResonanceSelectEquip.lua @@ -0,0 +1,100 @@ +local XUiGridEquip = require("XUi/XUiEquipAwarenessReplace/XUiGridEquip") + +local XUiEquipResonanceSelectEquip = XLuaUiManager.Register(XLuaUi, "UiEquipResonanceSelectEquip") + +function XUiEquipResonanceSelectEquip:OnAwake() + self:InitAutoScript() +end + +function XUiEquipResonanceSelectEquip:OnStart(equipId, confirmCb) + self.EquipId = equipId + self.ConfirmCb = confirmCb + self.LastSelectId = nil + self.SelectEquipId = nil + + self:InitDynamicTable() +end + +function XUiEquipResonanceSelectEquip:OnEnable() + self.EquipIdList = XDataCenter.EquipManager.GetResonanceCanEatEquipIds(self.EquipId) + XTool.ReverseList(self.EquipIdList) --这个UI要初始升序 + + self:UpdateEquipGridList() +end + +function XUiEquipResonanceSelectEquip:Reset() + self.LastSelectId = nil + self.SelectEquipId = nil +end + +function XUiEquipResonanceSelectEquip:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelEquipScroll) + self.DynamicTable:SetDelegate(self) + self.DynamicTable:SetProxy(XUiGridEquip) +end + +function XUiEquipResonanceSelectEquip:UpdateEquipGridList() + self.DynamicTable:SetDataSource(self.EquipIdList) + self.DynamicTable:ReloadDataASync(#self.EquipIdList > 0 and 1 or -1) + + if not self.EquipIdList or not next(self.EquipIdList) then + if XDataCenter.EquipManager.IsClassifyEqual(self.EquipId, XEquipConfig.Classify.Weapon) then + self.TxtNoEquip.text = CS.XTextManager.GetText("EquipResonanceNoWeaponTip") + else + self.TxtNoEquip.text = CS.XTextManager.GetText("EquipResonanceNoAwarenessTip") + end + self.PanelNoEquip.gameObject:SetActive(true) + else + self.PanelNoEquip.gameObject:SetActive(false) + end +end + +function XUiEquipResonanceSelectEquip:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:InitRootUi(self) + grid:SetSelected(false) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local equipId = self.EquipIdList[index] + grid:Refresh(equipId) + + local isSelected = self.LastSelectId and self.LastSelectId == equipId + if isSelected then + self.LastSelectGrid = grid + end + grid:SetSelected(isSelected) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + local equipId = self.EquipIdList[index] + if self.LastSelectGrid then + self.LastSelectGrid:SetSelected(false) + end + + self.SelectEquipId = equipId + self.LastSelectGrid = grid + self.LastSelectGrid:SetSelected(true) + end +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiEquipResonanceSelectEquip:InitAutoScript() + self:AutoAddListener() +end + +function XUiEquipResonanceSelectEquip:AutoAddListener() + self:RegisterClickEvent(self.BtnConfirm, self.OnBtnConfirmClick) + self:RegisterClickEvent(self.BtnClose, self.OnBtnCloseClick) + self:RegisterClickEvent(self.Btncancel, self.OnBtnCloseClick) +end +-- auto +function XUiEquipResonanceSelectEquip:OnBtnCloseClick() + self:Close() +end + +function XUiEquipResonanceSelectEquip:OnBtnConfirmClick() + local equipId = self.SelectEquipId + if self.ConfirmCb and equipId then + self.ConfirmCb(equipId) + self.LastSelectId = equipId + end + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiEquipResonanceSelect/XUiEquipResonanceSelectItem.lua b/Resources/Scripts/XUi/XUiEquipResonanceSelect/XUiEquipResonanceSelectItem.lua new file mode 100644 index 00000000..e914ffc2 --- /dev/null +++ b/Resources/Scripts/XUi/XUiEquipResonanceSelect/XUiEquipResonanceSelectItem.lua @@ -0,0 +1,138 @@ +local XUiEquipResonanceSelectItem = XLuaUiManager.Register(XLuaUi, "UiEquipResonanceSelectItem") + +local ITEM_TYPE = { + DEFAULT = 1, + SELECT = 2 +} + +function XUiEquipResonanceSelectItem:OnAwake() + self:AutoAddListener() +end + +function XUiEquipResonanceSelectItem:OnStart(equipId, confirmCb) + self.EquipId = equipId + self.ConfirmCb = confirmCb + + self:InitDynamicTable() +end + +function XUiEquipResonanceSelectItem:OnEnable() + self:Update() +end + +--@region 绑定事件 + +function XUiEquipResonanceSelectItem:AutoAddListener() + self:RegisterClickEvent(self.BtnConfirm, self.OnBtnConfirmClick) + self:RegisterClickEvent(self.BtnClose, self.OnBtnCloseClick) + self:RegisterClickEvent(self.Btncancel, self.OnBtnCloseClick) +end + +function XUiEquipResonanceSelectItem:OnBtnCloseClick() + self:Close() +end + +function XUiEquipResonanceSelectItem:OnBtnConfirmClick() + if self.ConfirmCb then + self.ConfirmCb(self.SelectItemId) + end + self.SelectItemId = nil + self:Close() +end + +--@endregion + +function XUiEquipResonanceSelectItem:InitDynamicTable() + self.DynamicTableA = XDynamicTableNormal.New(self.PanelScrollA) + self.DynamicTableA:SetDelegate(self) + self.DynamicTableA:SetProxy(XUiGridCommon) + self.DynamicTableA:SetDynamicEventDelegate(function (event, index, grid) + self:OnDynamicTableEvent(event, index, grid, ITEM_TYPE.DEFAULT) + end) + + self.DynamicTableB = XDynamicTableNormal.New(self.PanelScrollB) + self.DynamicTableB:SetDelegate(self) + self.DynamicTableB:SetProxy(XUiGridCommon) + self.DynamicTableB:SetDynamicEventDelegate(function (event, index, grid) + self:OnDynamicTableEvent(event, index, grid, ITEM_TYPE.SELECT) + end) +end + +function XUiEquipResonanceSelectItem:Update() + local templateId = XDataCenter.EquipManager.GetEquipTemplateId(self.EquipId) + local quality = XDataCenter.EquipManager.GetEquipQuality(templateId) + + self.TextTitle1.text = CS.XTextManager.GetText("EquipResonanceSelectItemTitle", quality) + self.TextTitleShadow1.text = CS.XTextManager.GetText("EquipResonanceSelectItemTitle", quality) + + self.BtnConfirm:SetDisable(self.SelectItemId == nil, false) + self:UpdateEquipGridList() +end + +function XUiEquipResonanceSelectItem:UpdateEquipGridList() + local consumeItemId = XDataCenter.EquipManager.GetResonanceConsumeItemId(self.EquipId) + local consumeSelectSkillItemId = XDataCenter.EquipManager.GetResonanceConsumeSelectSkillItemId(self.EquipId) + + self.ListA = {consumeItemId} + self.ListB = {consumeSelectSkillItemId} + + if consumeItemId then + self.DynamicTableA:SetDataSource(self.ListA) + self.DynamicTableA:ReloadDataSync() + self.PanelScrollA.gameObject:SetActiveEx(true) + else + self.PanelScrollA.gameObject:SetActiveEx(false) + end + + if consumeSelectSkillItemId then + self.DynamicTableB:SetDataSource(self.ListB) + self.DynamicTableB:ReloadDataSync() + self.PanelScrollB.gameObject:SetActiveEx(true) + else + self.PanelScrollB.gameObject:SetActiveEx(false) + end +end + +function XUiEquipResonanceSelectItem:OnDynamicTableEvent(event, index, grid, type) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local itemId = self:GetListByType(type)[index] + if not itemId then + return + end + local haveCount = XDataCenter.ItemManager.GetCount(itemId) + + grid:Refresh(itemId) + grid.ImgSelect.gameObject:SetActiveEx(self.SelectItemId == itemId) + grid.TxtCount.text = CS.XTextManager.GetText("ShopGridCommonCount", haveCount) + grid.TxtCount.gameObject:SetActiveEx(true) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + local itemId = self:GetListByType(type)[index] + if self:IsEnough(itemId, type) then + self.SelectItemId = itemId + self:Update() + else + XUiManager.TipMsg(CS.XTextManager.GetText("EquipResonanceNoEnough")) + return + end + end +end + +function XUiEquipResonanceSelectItem:GetListByType(type) + if type == ITEM_TYPE.DEFAULT then + return self.ListA + elseif type == ITEM_TYPE.SELECT then + return self.ListB + end +end + +function XUiEquipResonanceSelectItem:IsEnough(itemId, type) + local haveCount = XDataCenter.ItemManager.GetCount(itemId) + + if type == ITEM_TYPE.DEFAULT then + return haveCount >= XDataCenter.EquipManager.GetResonanceConsumeItemCount(self.EquipId) + elseif type == ITEM_TYPE.SELECT then + return haveCount >= XDataCenter.EquipManager.GetResonanceConsumeSelectSkillItemCount(self.EquipId) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiEquipResonanceSkill/XUiEquipResonanceSkill.lua b/Resources/Scripts/XUi/XUiEquipResonanceSkill/XUiEquipResonanceSkill.lua new file mode 100644 index 00000000..bbffb2b4 --- /dev/null +++ b/Resources/Scripts/XUi/XUiEquipResonanceSkill/XUiEquipResonanceSkill.lua @@ -0,0 +1,195 @@ +local XUiGridResonanceSkill = require("XUi/XUiEquipResonanceSkill/XUiGridResonanceSkill") + +local XUiEquipResonanceSkill = XLuaUiManager.Register(XLuaUi, "UiEquipResonanceSkill") + +function XUiEquipResonanceSkill:OnAwake() + self:AutoAddListener() + + self.BtnHelp.gameObject:SetActiveEx(false) + self.GridResonanceSkill.gameObject:SetActiveEx(false) +end + +function XUiEquipResonanceSkill:OnStart(equipId, rootUi) + self.EquipId = equipId + self.RootUi = rootUi + self.GridResonanceSkills = {} + self.DescriptionTitle = CS.XTextManager.GetText("EquipResonanceExplainTitle") + self.Description = string.gsub(CS.XTextManager.GetText("EquipResonanceExplain"), "\\n", "\n") +end + +function XUiEquipResonanceSkill:OnEnable() + self:UpdateResonanceSkills() +end + +function XUiEquipResonanceSkill:OnGetEvents() + return { + XEventId.EVENT_EQUIP_RESONANCE_ACK_NOTYFY + } +end + +function XUiEquipResonanceSkill:OnNotify(evt, ...) + local args = { ... } + local equipId = args[1] + local pos = args[2] + if equipId ~= self.EquipId then return end + + if evt == XEventId.EVENT_EQUIP_RESONANCE_ACK_NOTYFY then + self:UpdateResonanceSkill(pos) + end +end + +function XUiEquipResonanceSkill:UpdateResonanceSkills() + local count = 1 + local resonanceSkillNum = XDataCenter.EquipManager.GetResonanceSkillNum(self.EquipId) + for pos = 1, resonanceSkillNum do + self:UpdateResonanceSkill(pos) + self["PanelSkill" .. pos].gameObject:SetActiveEx(true) + self["PanelSkill" .. pos].transform:GetComponent("CanvasGroup").alpha = 1 + count = count + 1 + end + for pos = count, XEquipConfig.MAX_RESONANCE_SKILL_COUNT do + self["PanelSkill" .. pos].gameObject:SetActiveEx(false) + end +end + +function XUiEquipResonanceSkill:UpdateResonanceSkill(pos) + local equipId = self.EquipId + local characterId = self.RootUi.CharacterId + local forceShowBindCharacter = self.RootUi.ForceShowBindCharacter + + local btnAwake = self["BtnAwake" .. pos] + local btnAwakeDetail = self["BtnAwakeDetail" .. pos] + if XDataCenter.EquipManager.CheckEquipPosResonanced(equipId, pos) then + if not self.GridResonanceSkills[pos] then + local item = CS.UnityEngine.Object.Instantiate(self.GridResonanceSkill) + self.GridResonanceSkills[pos] = XUiGridResonanceSkill.New(item, equipId, pos, characterId, nil, nil, forceShowBindCharacter) + self.GridResonanceSkills[pos].Transform:SetParent(self["PanelSkill" .. pos], false) + end + + self.GridResonanceSkills[pos]:Refresh() + self.GridResonanceSkills[pos].GameObject:SetActiveEx(true) + self["PanelNoSkill" .. pos].gameObject:SetActiveEx(false) + self["BtnRepeatResonance" .. pos].gameObject:SetActiveEx(true) + + if XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.EquipAwake) + and XDataCenter.EquipManager.CheckEquipStarCanAwake(equipId) + and XDataCenter.EquipManager.IsAwareness(equipId) then + if not XDataCenter.EquipManager.IsEquipPosAwaken(equipId, pos) then + btnAwake:SetDisable(not XDataCenter.EquipManager.CheckEquipCanAwake(equipId)) + btnAwake.gameObject:SetActiveEx(true) + btnAwakeDetail.gameObject:SetActiveEx(false) + else + btnAwake.gameObject:SetActiveEx(false) + btnAwakeDetail.gameObject:SetActiveEx(true) + end + else + btnAwake.gameObject:SetActiveEx(false) + end + else + if self.GridResonanceSkills[pos] then + self.GridResonanceSkills[pos].GameObject:SetActiveEx(false) + end + self["PanelNoSkill" .. pos].gameObject:SetActiveEx(true) + self["BtnRepeatResonance" .. pos].gameObject:SetActiveEx(false) + btnAwake.gameObject:SetActiveEx(false) + end + self["BtnResonance" .. pos].transform:SetAsLastSibling() +end + +function XUiEquipResonanceSkill:AutoAddListener() + self:RegisterClickEvent(self.BtnResonance1, self.OnBtnResonance1Click) + self:RegisterClickEvent(self.BtnResonance2, self.OnBtnResonance2Click) + self:RegisterClickEvent(self.BtnResonance3, self.OnBtnResonance3Click) + self:RegisterClickEvent(self.BtnRepeatResonance1, self.OnBtnResonance1Click) + self:RegisterClickEvent(self.BtnRepeatResonance2, self.OnBtnResonance2Click) + self:RegisterClickEvent(self.BtnRepeatResonance3, self.OnBtnResonance3Click) + self:RegisterClickEvent(self.BtnAwake1, self.OnBtnAwake1Click) + self:RegisterClickEvent(self.BtnAwake2, self.OnBtnAwake2Click) + self:RegisterClickEvent(self.BtnAwake3, self.OnBtnAwake3Click) + self:RegisterClickEvent(self.BtnAwakeDetail1, self.OnBtnAwakeDetail1Click) + self:RegisterClickEvent(self.BtnAwakeDetail2, self.OnBtnAwakeDetail2Click) + self:RegisterClickEvent(self.BtnAwakeDetail3, self.OnBtnAwakeDetail3Click) + self:RegisterClickEvent(self.BtnHelp, self.OnBtnHelpClick) +end + +function XUiEquipResonanceSkill:OnBtnResonance3Click() + self:OnBtnResonanceClick(3) +end + +function XUiEquipResonanceSkill:OnBtnResonance1Click() + self:OnBtnResonanceClick(1) +end + +function XUiEquipResonanceSkill:OnBtnResonance2Click() + self:OnBtnResonanceClick(2) +end + +function XUiEquipResonanceSkill:OnBtnAwake3Click() + self:OnBtnAwakeClick(3) +end + +function XUiEquipResonanceSkill:OnBtnAwake1Click() + self:OnBtnAwakeClick(1) +end + +function XUiEquipResonanceSkill:OnBtnAwake2Click() + self:OnBtnAwakeClick(2) +end + +function XUiEquipResonanceSkill:OnBtnAwakeDetail3Click() + self:OnBtnAwakeDetailClick(3) +end + +function XUiEquipResonanceSkill:OnBtnAwakeDetail1Click() + self:OnBtnAwakeDetailClick(1) +end + +function XUiEquipResonanceSkill:OnBtnAwakeDetail2Click() + self:OnBtnAwakeDetailClick(2) +end + +function XUiEquipResonanceSkill:OnBtnHelpClick() + XUiManager.UiFubenDialogTip(self.DescriptionTitle, self.Description) +end + +function XUiEquipResonanceSkill:OnBtnResonanceClick(pos) + local equipId = self.EquipId + + if XDataCenter.EquipManager.IsWeapon(equipId) + and XDataCenter.EquipManager.CheckEquipPosResonanced(equipId, pos) + and XDataCenter.EquipManager.IsFiveStar(equipId) then + XUiManager.TipText("EquipResonance5StarWeaponRepeatTip") + return + end + + self:PlayAnimationWithMask("PanelSkill" .. pos, function() + if XDataCenter.EquipManager.CheckEquipPosUnconfirmedResonanced(self.EquipId, pos) then + local forceShowBindCharacter = self.RootUi.ForceShowBindCharacter + XLuaUiManager.Open("UiEquipResonanceSelectAfter", self.EquipId, pos, self.RootUi.CharacterId, nil, forceShowBindCharacter) + else + self.RootUi:FindChildUiObj("UiEquipResonanceSelect"):Refresh(pos) + self.RootUi:FindChildUiObj("UiEquipResonanceSelectEquip"):Reset() + self.RootUi:OpenOneChildUi("UiEquipResonanceSelect", equipId, self.RootUi) + end + end) +end + +function XUiEquipResonanceSkill:OnBtnAwakeClick(pos) + local equipId = self.EquipId + + if not XDataCenter.EquipManager.CheckEquipCanAwake(equipId, pos) then + XUiManager.TipText("EquipCanNotAwakeCondition") + return + end + + self.RootUi:FindChildUiObj("UiEquipResonanceAwake"):Refresh(pos) + self.RootUi:OpenOneChildUi("UiEquipResonanceAwake", equipId, self.RootUi) +end + +function XUiEquipResonanceSkill:OnBtnAwakeDetailClick(pos) + local equipId = self.EquipId + local characterId = self.RootUi.CharacterId + local isAwakeDes = true + local forceShowBindCharacter = self.RootUi.ForceShowBindCharacter + XLuaUiManager.Open("UiEquipResonanceSkillDetailInfo", equipId, pos, characterId, isAwakeDes, forceShowBindCharacter) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiEquipResonanceSkill/XUiEquipResonanceSkillPreview.lua b/Resources/Scripts/XUi/XUiEquipResonanceSkill/XUiEquipResonanceSkillPreview.lua new file mode 100644 index 00000000..b2aa6036 --- /dev/null +++ b/Resources/Scripts/XUi/XUiEquipResonanceSkill/XUiEquipResonanceSkillPreview.lua @@ -0,0 +1,134 @@ +local XUiGridEquipResonanceSkillPreview = require("XUi/XUiEquipResonanceSkill/XUiGridEquipResonanceSkillPreview") +local XUiEquipResonanceSkillPreview = XLuaUiManager.Register(XLuaUi, "UiEquipResonanceSkillPreview") + +function XUiEquipResonanceSkillPreview:OnAwake() + self:AutoAddListener() + + self.GridResonanceSkill.gameObject:SetActiveEx(false) +end + +function XUiEquipResonanceSkillPreview:OnStart(params) + self.RootUi = params.rootUi + self.Params = params + self.SelectSkillInfo = params.selectSkillInfo + + self.BtnEnter:SetDisable(true, false) + self.BtnCancel.gameObject:SetActiveEx(self.Params.isNeedSelectSkill) + self.BtnEnter.gameObject:SetActiveEx(self.Params.isNeedSelectSkill) + + self:UpdateCharacterName() + self:UpdateSkillPreviewScroll() + self:UpdateResonanceSkillGridsBtnGroup() +end + +function XUiEquipResonanceSkillPreview:UpdateCharacterName() + local charConfig = XCharacterConfigs.GetCharacterTemplate(self.RootUi.SelectCharacterId) + self.TxtCharacterName.text = charConfig.Name + self.TxtCharacterNameOther.text = charConfig.TradeName +end + +--@region Update PreviewScroll Item + +function XUiEquipResonanceSkillPreview:UpdateResonanceSkillGridsBtnGroup() + if not self.Params.isNeedSelectSkill then + return + end + local btnGroup = self.PanelCharacterContent:GetComponent("XUiButtonGroup") + local tlButtonGo = {} + for i,v in ipairs(self.ResonanceSkillGrids) do + table.insert(tlButtonGo, v.GameObject:GetComponent("XUiButton")) + end + + btnGroup:Init(tlButtonGo, function(index) self:OnItemClick(index) end) +end + +function XUiEquipResonanceSkillPreview:UpdateSkillPreviewScroll() + self.ResonanceSkillGrids = {} + local equipId = self.RootUi.EquipId + local preSkillInfoList = self:GetPreSkillInfoList(equipId) + + for skillIndex, skillInfo in ipairs(preSkillInfoList) do + if not self.ResonanceSkillGrids[skillIndex] then + self.ResonanceSkillGrids[skillIndex] = self:CreateItem() + end + + self.ResonanceSkillGrids[skillIndex]:Refresh({ + equipId = equipId, + skillInfo = skillInfo, + selectSkillInfo = self.SelectSkillInfo, + selectCharacterId = self.RootUi.SelectCharacterId, + pos = self.Params.pos + }) + end +end + +function XUiEquipResonanceSkillPreview:GetPreSkillInfoList(equipId) + local equipId = self.RootUi.EquipId + local list = XDataCenter.EquipManager.GetResonancePreSkillInfoList(equipId, self.RootUi.SelectCharacterId, self.RootUi.Pos) + local equip = XDataCenter.EquipManager.GetEquip(equipId) + + if equip.ResonanceInfo then + local getWeight = function (skillInfo) + for i,v in pairs(equip.ResonanceInfo) do + local bindCharacterId = v.CharacterId + if bindCharacterId == self.RootUi.SelectCharacterId then + local s = XDataCenter.EquipManager.GetResonanceSkillInfo(equipId, v.Slot) + if XDataCenter.EquipManager.IsClassifyEqual(equipId, XEquipConfig.Classify.Awareness) then + if s.Id == skillInfo.Id and v.Slot == self.Params.pos then + return math.maxinteger + end + else + if s.Id == skillInfo.Id then + return math.maxinteger + end + end + end + end + + return skillInfo.Id + end + + table.sort(list, function (a, b) + local aWeight = getWeight(a) + local bWeight = getWeight(b) + + return aWeight < bWeight + end) + end + + return list +end + +function XUiEquipResonanceSkillPreview:CreateItem() + local item = CS.UnityEngine.Object.Instantiate(self.GridResonanceSkill) -- 复制一个item + local grid = XUiGridEquipResonanceSkillPreview.New(item) + grid.Transform:SetParent(self.PanelCharacterContent, false) + grid.GameObject:SetActiveEx(true) + + return grid +end + +function XUiEquipResonanceSkillPreview:OnItemClick(index) + self.SelectSkillInfo = self.ResonanceSkillGrids[index]:GetSkillInfo() + self.BtnEnter:SetDisable(false, false) +end + +--@endregion + + +function XUiEquipResonanceSkillPreview:AutoAddListener() + self:RegisterClickEvent(self.BtnClose, self.OnBtnCloseClick) + self:RegisterClickEvent(self.BtnCancel, self.OnBtnCloseClick) + self:RegisterClickEvent(self.BtnEnter, self.OnBtnEnterClick) +end + +function XUiEquipResonanceSkillPreview:OnBtnCloseClick() + self:Close() +end + +function XUiEquipResonanceSkillPreview:OnBtnEnterClick() + if self.SelectSkillInfo then + self.Params.ClickCb(self.SelectSkillInfo) + self:Close() + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiEquipResonanceSkill/XUiGridDoubleResonanceSkill.lua b/Resources/Scripts/XUi/XUiEquipResonanceSkill/XUiGridDoubleResonanceSkill.lua new file mode 100644 index 00000000..99841fb8 --- /dev/null +++ b/Resources/Scripts/XUi/XUiEquipResonanceSkill/XUiGridDoubleResonanceSkill.lua @@ -0,0 +1,123 @@ +local XUiGridResonanceSkill = require("XUi/XUiEquipResonanceSkill/XUiGridResonanceSkill") + +local SINGLE_SITE_RESONANCE_SKILL_NUM = 2 + +local XUiGridDoubleResonanceSkill = XClass(nil, "XUiGridDoubleResonanceSkill") + +function XUiGridDoubleResonanceSkill:Ctor(ui, clickCb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.ClickCb = clickCb + self.ResonanceSkillGrids = {} + XTool.InitUiObject(self) + + for i = 1, SINGLE_SITE_RESONANCE_SKILL_NUM do + self["BtnAddResonanceSkill" .. i].CallBack = function() + XLuaUiManager.Open("UiEquipDetail", self.EquipId, nil, self.CharacterId, nil, XEquipConfig.EquipDetailBtnTabIndex.Resonance) + if clickCb then clickCb(self) end + end + end + self:SetSelect(false) + self.BtnClick.CallBack = function() + if clickCb then clickCb(self) end + end +end + +function XUiGridDoubleResonanceSkill:Refresh(characterId, site) + self:RefreshBySite(characterId, site) +end + +--[[ + --@equipId:意识的id +]] +function XUiGridDoubleResonanceSkill:RefreshByEquipId(characterId, equipId, site) + self.CharacterId = characterId + + self:RefreshTxtPos(site) + if characterId and equipId then + --已穿戴装备 + self.EquipId = equipId + + self:RefreshResonanceSkill(characterId, equipId) + else + --未穿戴装备 + self.PanelEmpty.gameObject:SetActiveEx(true) + self.PanelNoResnoanceSkill.gameObject:SetActiveEx(false) + self.ImgPos.gameObject:SetActiveEx(false) + self.GridResnanceSkill1.gameObject:SetActiveEx(false) + self.GridResnanceSkill2.gameObject:SetActiveEx(false) + end +end + +--[[ + --@site: 意识的位置 +]] +function XUiGridDoubleResonanceSkill:RefreshBySite(characterId, site) + self.CharacterId = characterId + local wearingEquipId = XDataCenter.EquipManager.GetWearingEquipIdBySite(characterId, site) + + self:RefreshTxtPos(site) + if wearingEquipId and wearingEquipId > 0 then + --已穿戴装备 + self.EquipId = wearingEquipId + + self:RefreshResonanceSkill(characterId, wearingEquipId) + else + --未穿戴装备 + self.PanelEmpty.gameObject:SetActiveEx(true) + self.PanelNoResnoanceSkill.gameObject:SetActiveEx(false) + self.ImgPos.gameObject:SetActiveEx(false) + self.GridResnanceSkill1.gameObject:SetActiveEx(false) + self.GridResnanceSkill2.gameObject:SetActiveEx(false) + end +end + +function XUiGridDoubleResonanceSkill:RefreshResonanceSkill(characterId, equipId) + local resonanceSkillNum = XDataCenter.EquipManager.GetResonanceSkillNum(equipId) + if resonanceSkillNum == 0 then + --穿戴中的装备无共鸣技能 + self.PanelEmpty.gameObject:SetActiveEx(true) + self.PanelNoResnoanceSkill.gameObject:SetActiveEx(false) + self.ImgPos.gameObject:SetActiveEx(false) + self.GridResnanceSkill1.gameObject:SetActiveEx(false) + self.GridResnanceSkill2.gameObject:SetActiveEx(false) + else + --有共鸣技能时 + for skillIndex = 1, SINGLE_SITE_RESONANCE_SKILL_NUM do + local go = self["GridResnanceSkill" .. skillIndex] + if XDataCenter.EquipManager.CheckEquipPosResonanced(equipId, skillIndex) then + local grid = self.ResonanceSkillGrids[skillIndex] + if not grid then + grid = XUiGridResonanceSkill.New(go, equipId, skillIndex, characterId, function(tmpEquipId, tmpPos, tmpCharacterId) + XLuaUiManager.Open("UiEquipResonanceSkillDetailInfo", tmpEquipId, tmpPos, tmpCharacterId) + if self.ClickCb then self.ClickCb(self) end + end) + self.ResonanceSkillGrids[skillIndex] = grid + end + grid:SetEquipIdAndPos(equipId, skillIndex) + grid:Refresh() + grid.GameObject:SetActiveEx(true) + else + go.gameObject:SetActiveEx(false) + end + end + self.PanelEmpty.gameObject:SetActiveEx(false) + self.PanelNoResnoanceSkill.gameObject:SetActiveEx(true) + self.ImgPos.gameObject:SetActiveEx(true) + end +end + +function XUiGridDoubleResonanceSkill:RefreshTxtPos(site) + local siteStr = "0" .. site + self.TxtPos.text = siteStr + self.TxtPosEmpty.text = siteStr +end + +function XUiGridDoubleResonanceSkill:SetSelect(value) + if self.ImgSelect then + -- self.ImgSelect.gameObject:SetActiveEx(value) + self.ImgSelect.gameObject:SetActiveEx(false) + end +end + +return XUiGridDoubleResonanceSkill \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiEquipResonanceSkill/XUiGridEquipResonanceSkillPreview.lua b/Resources/Scripts/XUi/XUiEquipResonanceSkill/XUiGridEquipResonanceSkillPreview.lua new file mode 100644 index 00000000..6963a4e0 --- /dev/null +++ b/Resources/Scripts/XUi/XUiEquipResonanceSkill/XUiGridEquipResonanceSkillPreview.lua @@ -0,0 +1,57 @@ +local CsXTextManagerGetText = CS.XTextManager.GetText + +local XUiGridEquipResonanceSkillPreview = XClass(nil, "XUiGridEquipResonanceSkillPreview") + +function XUiGridEquipResonanceSkillPreview:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) +end + +function XUiGridEquipResonanceSkillPreview:Refresh(params) + self.Params = params + self.RImgResonanceSkill:SetRawImage(params.skillInfo.Icon) + self.TxtSkillName.text = params.skillInfo.Name + self.TxtSkillDes.text = params.skillInfo.Description + + self.TxtSelect.gameObject:SetActiveEx(self.Params.skillInfo:IsSame(self.Params.selectSkillInfo)) + self:SetIsResonanceInfo() +end + +function XUiGridEquipResonanceSkillPreview:SetIsResonanceInfo() + local isResonance, slot = self:IsResonance() + if isResonance then + self.TxtSelectName.text = CsXTextManagerGetText("EquipResonanceIsExist", slot) + self.BtnIsResonanc.gameObject:SetActiveEx(true) + else + self.BtnIsResonanc.gameObject:SetActiveEx(false) + end +end + +function XUiGridEquipResonanceSkillPreview:IsResonance() + local equip = XDataCenter.EquipManager.GetEquip(self.Params.equipId) + if equip.ResonanceInfo then + for i,v in pairs(equip.ResonanceInfo) do + local bindCharacterId = v.CharacterId + if bindCharacterId == self.Params.selectCharacterId then + local skillInfo = XDataCenter.EquipManager.GetResonanceSkillInfo(self.Params.equipId, v.Slot) + if XDataCenter.EquipManager.IsClassifyEqual(self.Params.equipId, XEquipConfig.Classify.Awareness) then + if self.Params.skillInfo:IsSame(skillInfo) and v.Slot == self.Params.pos then + return true, v.Slot + end + else + if self.Params.skillInfo:IsSame(skillInfo) then + return true, v.Slot + end + end + end + end + end +end + +function XUiGridEquipResonanceSkillPreview:GetSkillInfo() + return self.Params.skillInfo +end + +return XUiGridEquipResonanceSkillPreview \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiEquipResonanceSkill/XUiGridResonanceSkill.lua b/Resources/Scripts/XUi/XUiEquipResonanceSkill/XUiGridResonanceSkill.lua new file mode 100644 index 00000000..55015005 --- /dev/null +++ b/Resources/Scripts/XUi/XUiEquipResonanceSkill/XUiGridResonanceSkill.lua @@ -0,0 +1,142 @@ +local CsXTextManagerGetText = CS.XTextManager.GetText + +local CONDITION_COLOR = { + [true] = XUiHelper.Hexcolor2Color("188649FF"), + [false] = XUiHelper.Hexcolor2Color("FF4E4EFF"), +} + +local XUiGridResonanceSkill = XClass(nil, "XUiGridResonanceSkill") + +function XUiGridResonanceSkill:Ctor(ui, equipId, pos, characterId, clickCb, isAwakeDes, forceShowBindCharacter) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.EquipId = equipId + self.Pos = pos + self.CharacterId = characterId + self.ClickCb = clickCb + self.IsAwakeDes = isAwakeDes + self.ForceShowBindCharacter = forceShowBindCharacter + self:InitAutoScript() +end + +function XUiGridResonanceSkill:SetEquipIdAndPos(equipId, pos, isAwakeDes) + self.EquipId = equipId + self.Pos = pos + self.IsAwakeDes = isAwakeDes +end + +function XUiGridResonanceSkill:Refresh(skillInfo, bindCharacterId) + local equipId = self.EquipId + local pos = self.Pos + local characterId = self.CharacterId + local isAwakeDes = self.IsAwakeDes + skillInfo = skillInfo or XDataCenter.EquipManager.GetResonanceSkillInfo(equipId, pos) + bindCharacterId = bindCharacterId or XDataCenter.EquipManager.GetResonanceBindCharacterId(equipId, pos) + + if self.PanelBindCharacter and self.RImgHead then + if not isAwakeDes then + if bindCharacterId > 0 then + self.RImgHead:SetRawImage(XDataCenter.CharacterManager.GetCharBigRoundnessNotItemHeadIcon(bindCharacterId)) + self.PanelBindCharacter.gameObject:SetActiveEx(true) + else + self.PanelBindCharacter.gameObject:SetActiveEx(false) + end + else + self.PanelBindCharacter.gameObject:SetActiveEx(false) + end + end + + if self.RImgResonanceSkill and skillInfo.Icon then + self.RImgResonanceSkill:SetRawImage(skillInfo.Icon) + end + + if self.TxtSkillName then + self.TxtSkillName.text = skillInfo.Name + end + + if self.TxtSkillDes then + XUiHelper.TextHasBubble(self.TxtSkillDes, skillInfo.Description) -- 海外修改 + self.TxtSkillDes.gameObject:SetActiveEx(not self.IsAwakeDes) + end + + if self.TxtPos then + -- self.TxtPos.text = CsXTextManagerGetText("EquipResonancePosText", self.Pos) + self.TxtPos.gameObject:SetActiveEx(false) + end + + if self.PanelAwakeSkills then + if isAwakeDes then + local awakeSkillDes = XDataCenter.EquipManager.GetAwakeSkillDesList(equipId, pos) + for i = 1, XEquipConfig.AWAKE_SKILL_COUNT do + self["TxtAwakeSkill" .. i].text = awakeSkillDes[i] + end + self.PanelAwakeSkills.gameObject:SetActiveEx(true) + else + self.PanelAwakeSkills.gameObject:SetActiveEx(false) + end + end + + local notBindResonance = bindCharacterId ~= 0 and characterId ~= bindCharacterId + if self.ForceShowBindCharacter then + notBindResonance = false + end + local isAwaken = XDataCenter.EquipManager.IsEquipPosAwaken(equipId, pos) + if self.PanelAwaken then + self.PanelAwaken.gameObject:SetActiveEx(isAwaken) + end + + if self.PanelAwakenNotResonance then + if self.PanelAwaken then + self.PanelAwaken.gameObject:SetActiveEx(isAwaken and not notBindResonance) + end + self.PanelAwakenNotResonance.gameObject:SetActiveEx(isAwaken and notBindResonance) + end + + if self.ImgNotResonance then + self.ImgNotResonance.gameObject:SetActiveEx(notBindResonance) + if self.PanelAwaken then + self.PanelAwaken.gameObject:SetActiveEx(not notBindResonance and isAwaken) + end + end + + if self.TxtAwake then + if isAwakeDes then + if bindCharacterId ~= 0 then + local characterName = XCharacterConfigs.GetCharacterTradeName(bindCharacterId) + self.TxtAwake.text = CsXTextManagerGetText("AwakeCharacterName", characterName) + self.TxtAwake.color = CONDITION_COLOR[not notBindResonance] + self.TxtAwake.gameObject:SetActiveEx(true) + else + self.TxtAwake.gameObject:SetActiveEx(false) + end + else + self.TxtAwake.gameObject:SetActiveEx(false) + end + end +end + +function XUiGridResonanceSkill:InitAutoScript() + self:AutoInitUi() + XTool.InitUiObject(self) + self:AutoAddListener() +end + +function XUiGridResonanceSkill:AutoInitUi() + self.TxtSkillDes = XUiHelper.TryGetComponent(self.Transform, "TxtSkillDes", "Text") + self.TxtSkillName = XUiHelper.TryGetComponent(self.Transform, "TxtSkillName", "Text") + self.PanelBindCharacter = XUiHelper.TryGetComponent(self.Transform, "PanelBindCharacter", nil) + self.RImgHead = XUiHelper.TryGetComponent(self.Transform, "PanelBindCharacter/RImgHead", "RawImage") + self.RImgResonanceSkill = XUiHelper.TryGetComponent(self.Transform, "RImgResonanceSkill", "RawImage") + self.ImgNotResonance = XUiHelper.TryGetComponent(self.Transform, "ImgNotResonance", "Image") + self.BtnClick = XUiHelper.TryGetComponent(self.Transform, "BtnClick", "Button") +end + +function XUiGridResonanceSkill:AutoAddListener() + CsXUiHelper.RegisterClickEvent(self.BtnClick, function() self:OnBtnClickClick() end) +end + +function XUiGridResonanceSkill:OnBtnClickClick() + if self.ClickCb then self.ClickCb(self.EquipId, self.Pos, self.CharacterId) end +end + +return XUiGridResonanceSkill \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiEquipStrengthen/XUiEquipStrengthen.lua b/Resources/Scripts/XUi/XUiEquipStrengthen/XUiEquipStrengthen.lua new file mode 100644 index 00000000..3ab96dee --- /dev/null +++ b/Resources/Scripts/XUi/XUiEquipStrengthen/XUiEquipStrengthen.lua @@ -0,0 +1,486 @@ +local CONDITION_COLOR = { + [true] = CS.UnityEngine.Color.black, + [false] = CS.UnityEngine.Color.gray, +} + +local XUiPanelExpBar = require("XUi/XUiSettleWinMainLine/XUiPanelExpBar") +local XUiGridEquipReplaceAttr = require("XUi/XUiEquipReplaceNew/XUiGridEquipReplaceAttr") +local XUiPanelEquipScroll = require("XUi/XUiEquipAwarenessReplace/XUiPanelEquipScroll") +local XUiGridEquipExpItem = require("XUi/XUiEquipStrengthen/XUiGridEquipExpItem") + +local mathMax = math.max +local mathFloor = math.floor +local next = next +local CSXTextManagerGetText = CS.XTextManager.GetText + +local BtnTabIndex = { + Equips = 1, + Items = 2, +} + +local XUiEquipStrengthen = XLuaUiManager.Register(XLuaUi, "UiEquipStrengthen") + +function XUiEquipStrengthen:OnAwake() + self:AutoAddListener() + + self.GridEquip.gameObject:SetActiveEx(false) + self.GridEquipReplaceAttr.gameObject:SetActiveEx(false) + self.GridExpItem.gameObject:SetActiveEx(false) + self.BtnAllSelect.gameObject:SetActiveEx(not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.EquipStrengthenAutoSelect)) + self.PanelTabBtns:Init({ + self.BtnEquips, + self.BtnItems, + }, function(tabIndex) self:OnClickTabCallBack(tabIndex) end) +end + +function XUiEquipStrengthen:OnStart(equipId, rootUi) + self.EquipId = equipId + self.RootUi = rootUi + self.IsAscendOrder = true --初始升序 + self.SelectedTabIndex = XDataCenter.EquipManager.IsStrengthenDefaultUseEquip(equipId) and BtnTabIndex.Equips or BtnTabIndex.Items + + self:InitEquipScroll() + self:InitItemScroll() + self:InitEquipAttr() +end + +function XUiEquipStrengthen:OnEnable() + self.PanelTabBtns:SelectIndex(self.SelectedTabIndex) + self:UpdateView() + self:PlayAnimation("PaneCommon") +end + +function XUiEquipStrengthen:OnGetEvents() + return { + XEventId.EVENT_EQUIP_STRENGTHEN_NOTYFY + , XEventId.EVENT_EQUIP_BREAKTHROUGH_NOTYFY + } +end + +function XUiEquipStrengthen:OnNotify(evt, ...) + local args = { ... } + local equipId = args[1] + if equipId ~= self.EquipId then return end + + if evt == XEventId.EVENT_EQUIP_STRENGTHEN_NOTYFY then + if XDataCenter.EquipManager.CanBreakThrough(self.EquipId) then + return + end + + if XDataCenter.EquipManager.IsMaxLevel(self.EquipId) then + return + end + + self:UpdateView() + elseif evt == XEventId.EVENT_EQUIP_BREAKTHROUGH_NOTYFY then + self:Close() + end +end + +function XUiEquipStrengthen:OnClickTabCallBack(tabIndex) + if tabIndex == self.SelectedTabIndex then return end + self.SelectedTabIndex = tabIndex + + self:UpdateView() +end + +function XUiEquipStrengthen:UpdateView() + self:ResetSelectedData() + self:UpdateViewData() + self:UpdateScrollView() + self:UpdateEquipInfo() + self:UpdateEquipPreView() +end + +function XUiEquipStrengthen:InitEquipAttr() + self.AttrGridList = {} + local curAttrMap = XDataCenter.EquipManager.GetEquipAttrMap(self.EquipId) + for attrIndex, attrInfo in pairs(curAttrMap) do + local ui = CS.UnityEngine.Object.Instantiate(self.GridEquipReplaceAttr) + self.AttrGridList[attrIndex] = XUiGridEquipReplaceAttr.New(ui, attrInfo.Name, true) + self.AttrGridList[attrIndex].Transform:SetParent(self.PanelAttrParent, false) + self.AttrGridList[attrIndex].GameObject:SetActiveEx(true) + end + self.ExpBar = XUiPanelExpBar.New(self.PanelExpBar) +end + +function XUiEquipStrengthen:InitEquipScroll() + local equipTouchCb = function(equipId, isSelect) + self:OnSelectEquip(equipId, isSelect) + end + + local gridReloadCb = function() + self.BtnOrder.enabled = true + end + + local addCountCheckCb = function() + return self:CheckCanSelect() + end + + self.EquipScroll = XUiPanelEquipScroll.New(self, self.PanelEquipScroll, equipTouchCb, gridReloadCb, true, addCountCheckCb) +end + +function XUiEquipStrengthen:InitItemScroll() + self.DynamicTable = XDynamicTableNormal.New(self.PanelItemScroll) + self.DynamicTable:SetDelegate(self) + self.DynamicTable:SetProxy(XUiGridEquipExpItem) +end + +function XUiEquipStrengthen:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + local addCountCb = function(itemId, addCount) + self:OnSelectItem(itemId, addCount) + end + + local addCountCheckCb = function(doNotTip) + return self:CheckCanSelect(doNotTip) + end + + grid:Init(self, addCountCb, addCountCheckCb) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local itemId = self.ItemIdList[index] + local selectCount = self.SelectItemDic[itemId] or 0 + grid:Refresh(itemId, selectCount) + end +end + +function XUiEquipStrengthen:UpdateViewData() + if self:IsEquipView() then + local equipIdList = XDataCenter.EquipManager.GetCanEatEquipIds(self.EquipId) + self.EquipIdList = not self.IsAscendOrder and XTool.ReverseList(equipIdList) or equipIdList + elseif self:IsItemView() then + self.ItemIdList = XDataCenter.EquipManager.GetCanEatItemIds(self.EquipId) + end +end + +function XUiEquipStrengthen:UpdateScrollView() + if self:IsEquipView() then + self.BtnOrder.gameObject:SetActiveEx(true) + self.EquipScroll:UpdateEquipGridList(self.EquipIdList) + self.EquipScroll.GameObject:SetActiveEx(true) + self.PanelItemScroll.gameObject:SetActiveEx(false) + elseif self:IsItemView() then + self.BtnOrder.gameObject:SetActiveEx(false) + self.DynamicTable:SetDataSource(self.ItemIdList) + self.DynamicTable:ReloadDataSync() + self.PanelItemScroll.gameObject:SetActiveEx(true) + self.EquipScroll.GameObject:SetActiveEx(false) + end +end + +function XUiEquipStrengthen:UpdateEquipInfo() + local equipId = self.EquipId + local equip = XDataCenter.EquipManager.GetEquip(equipId) + local maxExp = XDataCenter.EquipManager.GetNextLevelExp(equipId) + local curLv = equip.Level + local maxLv = XDataCenter.EquipManager.GetBreakthroughLevelLimit(equipId) + + for _, grid in pairs(self.AttrGridList) do + grid:UpdateData() + end + + self.TxtCurLv.text = CSXTextManagerGetText("EquipStrengthenCurLevel", curLv, maxLv) + self.TxtExp.text = mathFloor(equip.Exp) .. "/" .. maxExp + self.TxtPreExp.gameObject:SetActiveEx(false) + self.ImgPlayerExpFill.fillAmount = equip.Exp / maxExp + + local curAttrMap = XDataCenter.EquipManager.GetEquipAttrMap(self.EquipId) + for attrIndex, attrInfo in pairs(curAttrMap) do + if self.AttrGridList[attrIndex] then + self.AttrGridList[attrIndex]:UpdateData(attrInfo.Value) + end + end + + CS.UnityEngine.UI.LayoutRebuilder.ForceRebuildLayoutImmediate(self.PanelLevel) +end + +function XUiEquipStrengthen:UpdateEquipPreView() + local equipId = self.EquipId + local preLevel = self.PreLevel + local preExp = self.PreExp + local totalAddExp = self.TotalAddExp + + local maxLv = XDataCenter.EquipManager.GetBreakthroughLevelLimit(equipId) + self.TxtCurLv.text = CSXTextManagerGetText("EquipStrengthenCurLevel", preLevel, maxLv) + + if preExp == 0 then + self.ImgPlayerExpFill.gameObject:SetActiveEx(false) + else + local equip = XDataCenter.EquipManager.GetEquip(equipId) + if equip.Level ~= preLevel then + self.ImgPlayerExpFill.gameObject:SetActiveEx(false) + else + self.ImgPlayerExpFill.gameObject:SetActiveEx(true) + end + end + local maxExp = XDataCenter.EquipManager.GetNextLevelExp(equipId, preLevel) + self.TxtExp.text = mathFloor(preExp) .. "/" .. maxExp + self.ImgPlayerExpFillAdd.fillAmount = preExp / maxExp + + local addExp = mathFloor(totalAddExp) + if addExp > 0 then + self.TxtPreExp.text = "+" .. addExp + self.TxtPreExp.gameObject:SetActiveEx(true) + else + self.TxtPreExp.gameObject:SetActiveEx(false) + end + + local preAttrMap = XDataCenter.EquipManager.GetEquipAttrMap(equipId, preLevel) + for attrIndex, attrInfo in pairs(preAttrMap) do + if self.AttrGridList[attrIndex] then + self.AttrGridList[attrIndex]:UpdateData(nil, attrInfo.Value, true) + end + end + + if self:IsEquipView() then + local costMoney = XDataCenter.EquipManager.GetEatEquipsCostMoney(self.SelectEquipIds) + self.TxtCost.text = costMoney + self.TxtCost.color = CONDITION_COLOR[XDataCenter.ItemManager.GetCoinsNum() >= costMoney] + + local canStrengthen = next(self.SelectEquipIds) + self.BtnStrengthen:SetDisable(not canStrengthen) + elseif self:IsItemView() then + local costMoney = XDataCenter.EquipManager.GetEatItemsCostMoney(self.SelectItemDic) + self.TxtCost.text = costMoney + self.TxtCost.color = CONDITION_COLOR[XDataCenter.ItemManager.GetCoinsNum() >= costMoney] + + local canStrengthen = next(self.SelectItemDic) + self.BtnStrengthen:SetDisable(not canStrengthen) + end +end + +function XUiEquipStrengthen:CheckCanSelect(doNotTip) + local preLevel = self.PreLevel + local limitLevel = XDataCenter.EquipManager.GetBreakthroughLevelLimit(self.EquipId) + if preLevel >= limitLevel then + if not doNotTip then + XUiManager.TipMsg(CSXTextManagerGetText("EquipStrengthenMaxLevel")) + end + return false + else + return true + end +end + +function XUiEquipStrengthen:OnSelectEquip(equipId, isSelect) + --取消选中直接刷新UI缓存 + local count = 1 + if isSelect then + self.SelectEquipIds[equipId] = true + else + count = -1 + self.SelectEquipIds[equipId] = nil + end + + local addExp = XDataCenter.EquipManager.GetEquipAddExp(equipId, count) + self.PreLevel, self.TotalAddExp, self.PreExp = self:GetStrengthenPreData(addExp) + self:UpdateEquipPreView() +end + +function XUiEquipStrengthen:OnSelectItem(itemId, addCount) + local selectItemDic = self.SelectItemDic + local oldCount = selectItemDic[itemId] or 0 + local newCount = mathMax(0, oldCount + addCount) + selectItemDic[itemId] = newCount > 0 and newCount or nil + + local addExp = XDataCenter.ItemManager.GetItemsAddEquipExp(itemId, addCount) + self.PreLevel, self.TotalAddExp, self.PreExp = self:GetStrengthenPreData(addExp) + self:UpdateEquipPreView() +end + +function XUiEquipStrengthen:AutoAddListener() + self:RegisterClickEvent(self.BtnOrder, self.OnBtnOrderClick) + self:RegisterClickEvent(self.BtnStrengthen, self.OnBtnStrengthenClick) + self:RegisterClickEvent(self.BtnSource, self.OnBtnSourceClick) + self:RegisterClickEvent(self.BtnAllSelect, self.OnBtnAllSelectClick) +end + +function XUiEquipStrengthen:OnBtnOrderClick() + self.IsAscendOrder = not self.IsAscendOrder + XTool.ReverseList(self.EquipIdList) + + self.BtnOrder.enabled = false + self.ImgAscend.gameObject:SetActiveEx(self.IsAscendOrder) + self.ImgDescend.gameObject:SetActiveEx(not self.IsAscendOrder) + + self:ResetSelectedData() + self:UpdateEquipPreView() + self:UpdateScrollView() +end + +function XUiEquipStrengthen:OnBtnStrengthenClick() + local equipId = self.EquipId + local equip = XDataCenter.EquipManager.GetEquip(equipId) + + local lastLevel = equip.Level + local lastExp = equip.Exp + local lastMaxExp = XDataCenter.EquipManager.GetNextLevelExp(equipId, lastLevel) + local curLevel = self.PreLevel + local curExp = self.PreExp + local curMaxExp = XDataCenter.EquipManager.GetNextLevelExp(equipId, curLevel) + XDataCenter.EquipManager.LevelUp(self.EquipId, self.SelectEquipIds, self.SelectItemDic, function() + self.ExpBar:SkipRoll(lastLevel, lastExp, lastMaxExp, curLevel, curExp, curMaxExp) + end) +end + +function XUiEquipStrengthen:OnBtnSourceClick() + local eatType = self:IsEquipView() and XEquipConfig.EatType.Equip or XEquipConfig.EatType.Item + local skipIds = XDataCenter.EquipManager.GetEquipSkipIds(eatType, self.EquipId) + XLuaUiManager.Open("UiEquipStrengthenSkip", skipIds) +end + +function XUiEquipStrengthen:OnBtnAllSelectClick() + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.EquipStrengthenAutoSelect) then + return + end + + if self:IsEquipView() then + self:AutoSelectEquips() + elseif self:IsItemView() then + self:AutoSelectItems() + end +end + +function XUiEquipStrengthen:IsEquipView() + return self.SelectedTabIndex == BtnTabIndex.Equips +end + +function XUiEquipStrengthen:IsItemView() + return self.SelectedTabIndex == BtnTabIndex.Items +end + +function XUiEquipStrengthen:ResetSelectedData() + local equip = XDataCenter.EquipManager.GetEquip(self.EquipId) + self.PreLevel = equip.Level + self.TotalAddExp = 0 + self.PreExp = equip.Exp + self.SelectEquipIds = {} + self.SelectItemDic = {} +end + +function XUiEquipStrengthen:GetStrengthenPreData(addExp) + local equipId = self.EquipId + local equip = XDataCenter.EquipManager.GetEquip(equipId) + + local preLevel = equip.Level + local totalAddExp = self.TotalAddExp + addExp + local preExp = totalAddExp + equip.Exp + + local limitLevel = XDataCenter.EquipManager.GetBreakthroughLevelLimit(equipId) + while true do + local nextExp = XDataCenter.EquipManager.GetNextLevelExp(equipId, preLevel) + if preExp < nextExp then + break + end + + preExp = preExp - nextExp + preLevel = preLevel + 1 + + --超出需要吃的装备个数范围检测 + if preLevel >= limitLevel then + preLevel = limitLevel + preExp = 0 + return preLevel, totalAddExp, preExp + end + end + + return preLevel, totalAddExp, preExp +end + +function XUiEquipStrengthen:AutoSelectEquips() + local recommendEatEquipIds = XDataCenter.EquipManager.GetRecomendEatEquipIds(self.EquipId) + if not next(recommendEatEquipIds) then + XUiManager.TipText("EquipStrengthenAutoSelectEmpty") + return + end + + local equipScroll = self.EquipScroll + equipScroll:ResetSelectGrids() + self:ResetSelectedData() + + local equipId = self.EquipId + local equipIds = {} + local preLevel, totalAddExp, preExp + local doNotTip = true + for _, costEquipId in ipairs(recommendEatEquipIds) do + local addExp = XDataCenter.EquipManager.GetEquipAddExp(costEquipId) + preLevel, totalAddExp, preExp = self:GetStrengthenPreData(addExp) + if not self:CheckCanSelect(doNotTip) then + break + end + + self.PreLevel, self.TotalAddExp, self.PreExp = preLevel, totalAddExp, preExp + equipIds[costEquipId] = true + self.SelectEquipIds[costEquipId] = true + end + + local limitLevel = XDataCenter.EquipManager.GetBreakthroughLevelLimit(equipId) + local totalNeedExp = XDataCenter.EquipManager.GetEquipLevelTotalNeedExp(equipId, limitLevel) + totalAddExp = self.TotalAddExp + for _, costEquipId in ipairs(recommendEatEquipIds) do + local addExp = XDataCenter.EquipManager.GetEquipAddExp(costEquipId) + addExp = -addExp + if totalAddExp + addExp < totalNeedExp then + break + end + preLevel, totalAddExp, preExp = self:GetStrengthenPreData(addExp) + + self.PreLevel, self.TotalAddExp, self.PreExp = preLevel, totalAddExp, preExp + equipIds[costEquipId] = nil + self.SelectEquipIds[costEquipId] = nil + end + + equipScroll:SelectGrids(equipIds) + self:UpdateEquipPreView() +end + +function XUiEquipStrengthen:AutoSelectItems() + local recommendEatItemIds = self.ItemIdList + if not next(recommendEatItemIds) then + XUiManager.TipText("EquipStrengthenAutoSelectEmpty") + return + end + + self:ResetSelectedData() + + local equipId = self.EquipId + local costItemCount + local preLevel, totalAddExp, preExp, addExp + local doNotTip = true + for _, costItemId in ipairs(recommendEatItemIds) do + costItemCount = XDataCenter.ItemManager.GetCount(costItemId) + for costCount = 1, costItemCount do + addExp = XDataCenter.ItemManager.GetItemsAddEquipExp(costItemId, 1) + preLevel, totalAddExp, preExp = self:GetStrengthenPreData(addExp) + if not self:CheckCanSelect(doNotTip) then + break + end + + self.PreLevel, self.TotalAddExp, self.PreExp = preLevel, totalAddExp, preExp + self.SelectItemDic[costItemId] = costCount > 0 and costCount or nil + end + end + + local limitLevel = XDataCenter.EquipManager.GetBreakthroughLevelLimit(equipId) + local totalNeedExp = XDataCenter.EquipManager.GetEquipLevelTotalNeedExp(equipId, limitLevel) + local selectCount + totalAddExp = self.TotalAddExp + for _, costItemId in ipairs(recommendEatItemIds) do + costItemCount = XDataCenter.ItemManager.GetCount(costItemId) + for _ = 1, costItemCount do + addExp = XDataCenter.ItemManager.GetItemsAddEquipExp(costItemId, -1) + if totalAddExp + addExp < totalNeedExp then + break + end + preLevel, totalAddExp, preExp = self:GetStrengthenPreData(addExp) + + self.PreLevel, self.TotalAddExp, self.PreExp = preLevel, totalAddExp, preExp + selectCount = self.SelectItemDic[costItemId] or 0 + selectCount = selectCount - 1 + self.SelectItemDic[costItemId] = selectCount > 0 and selectCount or nil + end + end + + self:UpdateEquipPreView() + self:UpdateScrollView() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiEquipStrengthen/XUiGridEquipExpItem.lua b/Resources/Scripts/XUi/XUiEquipStrengthen/XUiGridEquipExpItem.lua new file mode 100644 index 00000000..a4cf124d --- /dev/null +++ b/Resources/Scripts/XUi/XUiEquipStrengthen/XUiGridEquipExpItem.lua @@ -0,0 +1,147 @@ +local mathFloor = math.floor +local XMathClamp = XMath.Clamp +local stringFormat = string.format + +local LongClickIntervel = 100 +local AddCountPerPressTime = 1 / 150 + +local XUiGridEquipExpItem = XClass(nil, "XUiGridEquipExpItem") + +function XUiGridEquipExpItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + self:AddBtnListener() +end + +function XUiGridEquipExpItem:Init(rootUi, addCountCb, addCountCheckCb) + self.RootUi = rootUi + self.AddCountCb = addCountCb + self.AddCountCheckCb = addCountCheckCb +end + +function XUiGridEquipExpItem:Refresh(itemId, selectCount) + selectCount = selectCount or 0 + self.ItemId = itemId + self.ItemCount = XDataCenter.ItemManager.GetCount(itemId) + + self.RImgIcon:SetRawImage(XDataCenter.ItemManager.GetItemIcon(itemId)) + self.TxtName.text = XDataCenter.ItemManager.GetItemName(itemId) + self.TxtCount.text = self.ItemCount + local quality = XDataCenter.ItemManager.GetItemQuality(itemId) + XUiHelper.SetQualityIcon(self.RootUi, self.ImgIconBg, quality) + + self:OnSelectCountChange(selectCount) +end + +function XUiGridEquipExpItem:OnSelectCountChange(newCount) + self.SelectCount = newCount + if newCount > 0 then + self.TxtSelectNum.text = stringFormat("x%d", newCount) + self.ImgSelect.gameObject:SetActiveEx(true) + self.BtnMinus.gameObject:SetActiveEx(true) + else + self.ImgSelect.gameObject:SetActiveEx(false) + self.BtnMinus.gameObject:SetActiveEx(false) + end +end + +function XUiGridEquipExpItem:AddBtnListener() + self.BtnMax.CallBack = function() self:OnClickBtnMax() end + self.BtnMinus.CallBack = function() self:OnClickBtnMinus() end + self.BtnAdd.CallBack = function() self:OnClickBtnAdd() end + XUiButtonLongClick.New(self.PointerAdd, LongClickIntervel, self, nil, self.OnLongClickBtnAdd, nil, true) + XUiButtonLongClick.New(self.PointerMinus, LongClickIntervel, self, nil, self.OnLongClickBtnMinus, nil, true) +end + +function XUiGridEquipExpItem:OnClickBtnAdd() + local addCount = 1 + local newCount = self.SelectCount + addCount + local itemId = self.ItemId + + if not self:CheckItemCount(newCount) then + return + end + + if not self.AddCountCheckCb() then + return + end + + self:OnSelectCountChange(newCount) + self.AddCountCb(itemId, addCount) +end + +function XUiGridEquipExpItem:OnLongClickBtnAdd(pressingTime) + local addCount = 1 + local totalCount = XMathClamp(mathFloor(pressingTime * AddCountPerPressTime), 0, self.ItemCount) + local newCount = self.SelectCount + local itemId = self.ItemId + + local doNotTip = true + for _ = 1, totalCount do + if not self.AddCountCheckCb(doNotTip) then + break + end + + newCount = newCount + addCount + if not self:CheckItemCount(newCount) then + newCount = newCount - addCount + break + end + + self.AddCountCb(itemId, addCount) + end + + self:OnSelectCountChange(newCount) +end + +function XUiGridEquipExpItem:OnClickBtnMinus() + local addCount = -1 + addCount = addCount + self.SelectCount < 0 and -self.SelectCount or addCount + local newCount = self.SelectCount + addCount + local itemId = self.ItemId + + self:OnSelectCountChange(newCount) + self.AddCountCb(itemId, addCount) +end + +function XUiGridEquipExpItem:OnLongClickBtnMinus(pressingTime) + local addCount = -mathFloor(pressingTime * AddCountPerPressTime) + addCount = addCount + self.SelectCount < 0 and -self.SelectCount or addCount + local newCount = self.SelectCount + addCount + local itemId = self.ItemId + + self:OnSelectCountChange(newCount) + self.AddCountCb(itemId, addCount) +end + +function XUiGridEquipExpItem:OnClickBtnMax() + local addCount = 1 + local totalCount = self.ItemCount + local newCount = self.SelectCount + local itemId = self.ItemId + + local doNotTip = true + for _ = 1, totalCount do + if not self.AddCountCheckCb(doNotTip) then + break + end + + newCount = newCount + addCount + if not self:CheckItemCount(newCount) then + newCount = newCount - addCount + break + end + + self.AddCountCb(itemId, addCount) + end + + self:OnSelectCountChange(newCount) +end + +function XUiGridEquipExpItem:CheckItemCount(checkCount) + return checkCount >= 0 and checkCount <= self.ItemCount +end + +return XUiGridEquipExpItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiEquipStrengthenSkip/XUiEquipStrengthenSkip.lua b/Resources/Scripts/XUi/XUiEquipStrengthenSkip/XUiEquipStrengthenSkip.lua new file mode 100644 index 00000000..190fdf0e --- /dev/null +++ b/Resources/Scripts/XUi/XUiEquipStrengthenSkip/XUiEquipStrengthenSkip.lua @@ -0,0 +1,33 @@ +local XUiEquipStrengthenSkip = XLuaUiManager.Register(XLuaUi, "UiEquipStrengthenSkip") + +function XUiEquipStrengthenSkip:OnAwake() + self:InitAutoScript() + self.PanelGridSkip.gameObject:SetActive(false) +end + +function XUiEquipStrengthenSkip:OnStart(skipIds) + self.GridPool = {} + self:Refresh(skipIds) +end + +function XUiEquipStrengthenSkip:Refresh(skipIds) + + XUiHelper.CreateTemplates(self, self.GridPool, skipIds, XUiGridSkip.New, self.PanelGridSkip, self.PanelContent, function(grid, data) + grid:Refresh(data) + end) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiEquipStrengthenSkip:InitAutoScript() + self:AutoAddListener() +end + +function XUiEquipStrengthenSkip:AutoAddListener() + self:RegisterClickEvent(self.BtnClose, self.OnBtnCloseClick) + self:RegisterClickEvent(self.BtnTanchuangClose, self.OnBtnCloseClick) +end +-- auto +function XUiEquipStrengthenSkip:OnBtnCloseClick() + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExhibition/XUiExhibition.lua b/Resources/Scripts/XUi/XUiExhibition/XUiExhibition.lua new file mode 100644 index 00000000..74ab0c76 --- /dev/null +++ b/Resources/Scripts/XUi/XUiExhibition/XUiExhibition.lua @@ -0,0 +1,253 @@ +local XUiExhibition = XLuaUiManager.Register(XLuaUi, "UiExhibition") + +local XUiGridCharacterIcon = require("XUi/XUiExhibition/XUiGridCharacterIcon") +local XUiGridCharacterName = require("XUi/XUiExhibition/XUiGridCharacterName") +local XUiGridGroupIcon = require("XUi/XUiExhibition/XUiGridGroupIcon") +local XUiGridGroupName = require("XUi/XUiExhibition/XUiGridGroupName") +local XUiPanelCollection = require("XUi/XUiExhibition/XUiPanelCollection") + +local ShowComponents = { + CharacterIcon = { Name = "CharacterIcon", PrefabName = "ExhibitionCharacterIcon", LuaScript = XUiGridCharacterIcon}, + CharacterName = { Name = "CharacterName", PrefabName = "ExhibitionCharacterName", LuaScript = XUiGridCharacterName}, + GroupIcon = { Name = "GroupIcon", PrefabName = "ExhibitionGroupIcon", LuaScript = XUiGridGroupIcon}, + GroupName = { Name = "GroupName", PrefabName = "ExhibitionGroupName", LuaScript = XUiGridGroupName} +} +local CharacterPortList = {} -- 角色显示编号 +local GroupPortList = {} -- 阵营显示编号 + +function XUiExhibition:OnAwake() + self:AddBtnListener() + self:InitTabGroup() + self:InitShowComponentList() +end + +function XUiExhibition:OnStart(isSelf, showType) + self.IsSelf = isSelf --是否浏览自身的收藏 + self.ShowType = showType or XDataCenter.ExhibitionManager.ExhibitionType.STRUCT + self.CharacterIconGridList = {} + self.CharacterNameGridList = {} + self.GroupIconGridList = {} + self.GroupNameGridList = {} + local behaviour = self.Transform.gameObject:AddComponent(typeof(CS.XLuaBehaviour)) + if self.Update then + behaviour.LuaUpdate = function() self:Update() end + end + self.CurCharacterId = nil + self.CurIndex = nil + self.Focusing = false + self.ShowDetailMinScale = CS.XGame.ClientConfig:GetFloat("ExhibitionShowDetailMinScale") + self.DetailFadeTime = CS.XGame.ClientConfig:GetFloat("ExhibitionDetailFadeTime") + self.DetailZoomTime = CS.XGame.ClientConfig:GetFloat("ExhibitionDetailZoomTime") + self.CollectionInfoPanel = XUiPanelCollection.New(self.PanelCollection, self) + self.PanelTab:SelectIndex(self.ShowType) +end + +function XUiExhibition:OnEnable() + self:RefreshExhibitionInfo() +end + +function XUiExhibition:OnDestroy() + +end + +function XUiExhibition:InitTabGroup() + local tabGroup = { + self.BtnTab1, + self.BtnTab2, + self.BtnTab3, + } + self.PanelTab:Init(tabGroup, function(tabIndex) self:OnClickTabCallBack(tabIndex) end) +end + +function XUiExhibition:InitShowComponentList() + local cPortNum = self.PanelCharacterIcon.transform.childCount + for i = 0, cPortNum - 1 do + local name = tonumber(self.PanelCharacterIcon.transform:GetChild(i).name) + table.insert(CharacterPortList, name) + end + local gPortNum = self.PanelGroupIcon.transform.childCount + for i = 0, gPortNum - 1 do + local name = tonumber(self.PanelGroupIcon.transform:GetChild(i).name) + table.insert(GroupPortList, name) + end +end + +function XUiExhibition:OnClickTabCallBack(tabIndex) + self.ShowType = tabIndex + self:RefreshExhibitionInfo() +end + +function XUiExhibition:AddBtnListener() + self.BtnHelp.CallBack = function() self:OnBtnHelpClick() end + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:RegisterClickEvent(self.BtnOpenCollection, self.OnBtnOpenCollectionClick) + self:RegisterClickEvent(self.BtnCloseCollection, self.OnBtnCloseCollectionClick) +end + +function XUiExhibition:RefreshExhibitionInfo() + self.ShowName = false + local exhibitionPortConfig = XExhibitionConfigs.GetExhibitionPortConfigByType(self.ShowType) + local exhibitionGroupConfig = XExhibitionConfigs.GetExhibitionGroupConfigByType(self.ShowType) + self:RefreshGroupLine() + for _, port in pairs(CharacterPortList) do + local config = exhibitionPortConfig[port] + local iconGrid = self:UpdateGridComponent(port, ShowComponents.CharacterIcon, config) + if not iconGrid then return end + local nameGrid = self:UpdateGridComponent(port, ShowComponents.CharacterName, config) + if not nameGrid then return end + nameGrid:ResetPosition(iconGrid.Transform.position) + end + for _,port in pairs(GroupPortList) do + local config = exhibitionGroupConfig[port] + local iconGrid = self:UpdateGridComponent(port, ShowComponents.GroupIcon, config) + if not iconGrid then return end + local nameGrid = self:UpdateGridComponent(port, ShowComponents.GroupName, config) + if not nameGrid then return end + nameGrid:ResetPosition(iconGrid.Transform.position) + end + self:RefreshCollectionInfo() +end + +function XUiExhibition:RefreshGroupLine() + local inVisibleTable = XExhibitionConfigs.GetExhibitionInVisbleGroupTable(self.ShowType) + for groupId, visible in pairs(inVisibleTable) do + local lineGroup = self.LineRoot.transform:Find(string.format("LineGroup%02d", groupId)) + if lineGroup then lineGroup.gameObject:SetActiveEx(visible) end + end +end + +function XUiExhibition:UpdateGridComponent(portId, showComponentsType, exhibitionConfig) + local gridComponent + local name = showComponentsType.Name + local gridParent = self["Panel" .. name]:Find(portId) + local gridList = self[name .. "GridList"] + local visible = XExhibitionConfigs.GetIsExhibitionInVisbleGroup(self.ShowType, exhibitionConfig and exhibitionConfig.GroupId or 0) + gridParent.gameObject:SetActiveEx(visible) + if gridList[portId] ~= nil then + gridComponent = gridList[portId] + gridComponent:Refresh(exhibitionConfig or nil) + else + local gridGo = gridParent.childCount > 0 and gridParent:GetChild(0) or CS.UnityEngine.Object.Instantiate(self.Obj:GetPrefab(showComponentsType.PrefabName)) + gridGo.transform:SetParent(gridParent, false) + if gridGo == nil or not gridGo:Exist() then + return + end + if showComponentsType == ShowComponents.CharacterIcon or showComponentsType == ShowComponents.CharacterName then + gridComponent = showComponentsType.LuaScript.New(self, portId, gridGo, exhibitionConfig) + else + gridComponent = showComponentsType.LuaScript.New(gridGo, exhibitionConfig) + end + gridList[portId] = gridComponent + end + return gridComponent +end + +function XUiExhibition:Update() + if self.Focusing then + return + end + local curScale = self.PanelCharacter.localScale.x + if curScale > self.ShowDetailMinScale and not self.ShowName then + self.ShowName = true + self:ShowNameLayer() + elseif curScale < self.ShowDetailMinScale and self.ShowName then + self.ShowName = false + self:HideNameLayer() + end +end + +function XUiExhibition:ShowNameLayer() + self.LayerNameCanvasGroup:DOFade(1, self.DetailFadeTime) +end + +function XUiExhibition:HideNameLayer() + self.LayerNameCanvasGroup:DOFade(0, self.DetailFadeTime) +end + +function XUiExhibition:StartFocus(index, characterId) + + -- self.Focusing = true + -- self.CurIndex = index + -- self.CurGridCanvasGroup = self.CharacterIconGridList[index].GameObject:AddComponent(typeof(CS.UnityEngine.CanvasGroup)) + -- self.CurGridCanvasGroup.ignoreParentGroups = true + -- self:PlayAnimation("AnimPanelTaskHide") + -- local offset = CS.UnityEngine.Vector3(self.IconPosition.position.x, 0, 0) + -- self.DragArea:StartFocus(self.CharacterIconGridList[index].Transform.position, 1.0, self.DetailZoomTime, offset, true) + self:ShowExhibitionInfo(characterId) +end + +function XUiExhibition:EndFocus() + self:PlayAnimation("AnimPanelTaskShow", function() + CS.UnityEngine.GameObject.Destroy(self.CurGridCanvasGroup) + end) + self.DragArea:EndFocus(function() + self.Focusing = false + end) +end + +function XUiExhibition:ShowExhibitionInfo(characterId) + self.CurCharacterId = characterId + XLuaUiManager.Open("UiExhibitionInfo", characterId, self.ShowType) +end + +function XUiExhibition:OnBtnOpenCollectionClick() + self.CollectionInfoPanel:Show(self.ShowType) + self:PlayAnimation("AnimPanelCollectionEnable") +end + +function XUiExhibition:OnBtnCloseCollectionClick() + self:PlayAnimation("AnimPanelCollectionDisable", function() + self.CollectionInfoPanel:Hide() + end) +end + +function XUiExhibition:OnBtnHelpClick() + XUiManager.UiFubenDialogTip("", CS.XTextManager.GetText("ExhibitionExplain") or "") +end + +-- function XUiExhibition:HandleCharacterGrowUp() +-- self.CharacterIconGridList[self.CurIndex]:CharacterGrowUp() +-- self:RefreshCollectionInfo() +-- end +function XUiExhibition:RefreshCollectionInfo() + local collectionRate = XDataCenter.ExhibitionManager.GetCollectionRate(true, self.ShowType) + self.TxtCollectionRate.text = math.floor(collectionRate * 100) + self.ImgRate.fillAmount = collectionRate + if self.ShowType then + self.TxtCenterRate.text = CS.XTextManager.GetText("ExhibitionCollectionLable" .. self.ShowType) + else + self.TxtCenterRate.text = CS.XTextManager.GetText("ExhibitionCollectionDefaultLable") + end + local totleCollectionRate = XDataCenter.ExhibitionManager.GetCollectionRate(true) + self.TxtTotalCollectRate.text = string.format("%d%s", math.floor(totleCollectionRate * 100), "%") +end + +function XUiExhibition:OnBtnBackClick() + self:Close() +end + +function XUiExhibition:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiExhibition:OnGetEvents() + return { XEventId.EVENT_CHARACTER_EXHIBITION_AUTOSELECT } +end + +function XUiExhibition:OnNotify(evt, ...) + local args = { ... } + + if evt == XEventId.EVENT_CHARACTER_EXHIBITION_AUTOSELECT then + if not args[1] then return end + local selectGrid = nil + for _, v in pairs(self.CharacterIconGridList or {}) do + if v.CharacterId == args[1] then + selectGrid = v + break + end + end + if not selectGrid then return end + selectGrid:BtnSelectClick() + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExhibition/XUiExhibitionGroupTip.lua b/Resources/Scripts/XUi/XUiExhibition/XUiExhibitionGroupTip.lua new file mode 100644 index 00000000..0db59c59 --- /dev/null +++ b/Resources/Scripts/XUi/XUiExhibition/XUiExhibitionGroupTip.lua @@ -0,0 +1,22 @@ +local XUiExhibitionGroupTip = XLuaUiManager.Register(XLuaUi, "UiExhibitionGroupTip") + +function XUiExhibitionGroupTip:OnAwake() + self.BtnClose.CallBack = function() self:OnBtnCloseClick() end +end + +function XUiExhibitionGroupTip:OnStart(groupID, showType) + self.GroupID = groupID + self.ShowType = showType + self:ShowGroupInfo() +end + +function XUiExhibitionGroupTip:ShowGroupInfo() + local config = XExhibitionConfigs.GetExhibitionConfigByTypeAndGroup(self.ShowType, self.GroupID) + self.TxtGroupName.text = config and config.GroupName or CS.XTextManager.GetText("ExhibitionDefaultGroupName") + self.RImgGroupIcon:SetRawImage(config and config.GroupLogo or CS.XGame.ClientConfig:GetString("DefaultGroupExhibitionImagePath")) + self.TxtContent.text = config and config.GroupDescription or CS.XTextManager.GetText("ExhibitionDefaultGroupDescription") +end + +function XUiExhibitionGroupTip:OnBtnCloseClick() + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExhibition/XUiExhibitionInfo.lua b/Resources/Scripts/XUi/XUiExhibition/XUiExhibitionInfo.lua new file mode 100644 index 00000000..ddf72173 --- /dev/null +++ b/Resources/Scripts/XUi/XUiExhibition/XUiExhibitionInfo.lua @@ -0,0 +1,205 @@ +local ConditionDesNum = 3 +local TabIndexToGrowUpLevel = { + XCharacterConfigs.GrowUpLevel.Lower, + XCharacterConfigs.GrowUpLevel.Middle, + XCharacterConfigs.GrowUpLevel.Higher, +} + +local XUiGridCondition = require("XUi/XUiExhibition/XUiGridCondition") + +local XUiExhibitionInfo = XLuaUiManager.Register(XLuaUi, "UiExhibitionInfo") + +function XUiExhibitionInfo:OnAwake() + self.GridRewardItem.gameObject:SetActive(false) + self:InitListener() +end + +function XUiExhibitionInfo:OnStart(characterId, showType) + self.CharacterId = characterId + self.ShowType = showType or XDataCenter.ExhibitionManager.ExhibitionType.STRUCT + self:InitModelRoot() + self:InitTabBtnGroup() + self:RegisterRedPointEvent() +end + +function XUiExhibitionInfo:OnEnable() + CS.XGraphicManager.UseUiLightDir = true +end + +function XUiExhibitionInfo:OnDisable() + CS.XGraphicManager.UseUiLightDir = false +end + +function XUiExhibitionInfo:InitModelRoot() + local root = self.UiModelGo + self.PanelRoleModel = root:FindTransform("PanelRoleModel") + self.EffectHuanren1 = root:FindTransform("ImgEffectHuanren1") + self.EffectHuanren = root:FindTransform("ImgEffectHuanren") + self.EffectHuanren.gameObject:SetActiveEx(false) + self.EffectHuanren1.gameObject:SetActiveEx(false) + self.RoleModelPanel = XUiPanelRoleModel.New(self.PanelRoleModel, self.Name, nil, true, nil, true) +end + +function XUiExhibitionInfo:InitListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self.BtnBreak.CallBack = function() self:OnBtnBreakClick() end + self.BtnShowInfoToggle.CallBack = function(value) self:OnBtnShowInfoToggleClick(value) end +end + +function XUiExhibitionInfo:RegisterRedPointEvent() + local characterId = self.CharacterId + XRedPointManager.AddRedPointEvent(self.BtnTog1, self.OnCheckExhibitionRedPoint, self, { XRedPointConditions.Types.CONDITION_EXHIBITION_NEW }, { characterId, 1 }) + XRedPointManager.AddRedPointEvent(self.BtnTog2, self.OnCheckExhibitionRedPoint, self, { XRedPointConditions.Types.CONDITION_EXHIBITION_NEW }, { characterId, 2 }) + XRedPointManager.AddRedPointEvent(self.BtnTog3, self.OnCheckExhibitionRedPoint, self, { XRedPointConditions.Types.CONDITION_EXHIBITION_NEW }, { characterId, 3 }) +end + +function XUiExhibitionInfo:OnCheckExhibitionRedPoint(count, args) + local characterId = args[1] + local index = args[2] + local growUpLevel = XDataCenter.ExhibitionManager.GetCharacterGrowUpLevel(characterId, true) + self["BtnTog" .. index]:ShowReddot(count >= 0 and growUpLevel == index) +end + +function XUiExhibitionInfo:InitTabBtnGroup() + local tabGroup = { + self.BtnTog1, + self.BtnTog2, + self.BtnTog3, + } + self.PanelTogs:Init(tabGroup, function(tabIndex) self:OnClickTabCallBack(tabIndex) end) + + local selected, lastIndex = false + local growUpLevel = XDataCenter.ExhibitionManager.GetCharacterGrowUpLevel(self.CharacterId, true) + for index, level in pairs(TabIndexToGrowUpLevel) do + if level == growUpLevel + 1 then + self.PanelTogs:SelectIndex(index) + selected = true + break + end + lastIndex = index + end + if not selected then + self.PanelTogs:SelectIndex(lastIndex) + end +end + +function XUiExhibitionInfo:OnClickTabCallBack(tabIndex) + if self.SelectedIndex and self.SelectedIndex == tabIndex then + return + end + self.SelectedIndex = tabIndex + + self:UpdateView() + self:PlayAnimation("ExhibitionTaskQiehuan") +end + +function XUiExhibitionInfo:UpdateView() + self.BtnShowInfoToggle:SetButtonState(XUiButtonState.Select) + self:UpdateCharacterInfo() + self:UpdateCharacterModel(TabIndexToGrowUpLevel[self.SelectedIndex]) + self:ShowTaskInfo() +end + +function XUiExhibitionInfo:UpdateCharacterInfo() + local characterId = self.CharacterId + self.TxtName.text = XCharacterConfigs.GetCharacterName(characterId) + self.TxtType.text = XCharacterConfigs.GetCharacterTradeName(characterId) + self.TxtNumber.text = XCharacterConfigs.GetCharacterCodeStr(characterId) + + local growUpLevel = XDataCenter.ExhibitionManager.GetCharacterGrowUpLevel(characterId, true) + local levelIcon = XExhibitionConfigs.GetExhibitionLevelIconByLevel(growUpLevel) + if not levelIcon or levelIcon == "" then + self.ImgClassIcon.gameObject:SetActive(false) + else + self:SetUiSprite(self.ImgClassIcon, levelIcon) + self.ImgClassIcon.gameObject:SetActive(true) + end +end + +function XUiExhibitionInfo:UpdateCharacterModel(growUpLevel) + local characterId = self.CharacterId + growUpLevel = growUpLevel or XDataCenter.ExhibitionManager.GetCharacterGrowUpLevel(characterId, true) + local modelId = XDataCenter.CharacterManager.GetCharLiberationLevelModelId(characterId, growUpLevel) + + self.RoleModelPanel:UpdateCharacterModelByModelId(modelId, characterId, self.PanelRoleModel, XModelManager.MODEL_UINAME.XUiExhibitionInfo, function(model) + self.PanelDrag.Target = model.transform + self.EffectHuanren.gameObject:SetActiveEx(false) + self.EffectHuanren1.gameObject:SetActiveEx(false) + if self.ShowType == XDataCenter.ExhibitionManager.ExhibitionType.STRUCT or self.ShowType == XDataCenter.ExhibitionManager.ExhibitionType.Linkage then + self.EffectHuanren.gameObject:SetActiveEx(true) + else + self.EffectHuanren1.gameObject:SetActiveEx(true) + end + end, growUpLevel, true) +end + +function XUiExhibitionInfo:ShowTaskInfo() + local characterId = self.CharacterId + local curSelectLevel = TabIndexToGrowUpLevel[self.SelectedIndex] + local taskConfig = XExhibitionConfigs.GetCharacterGrowUpTask(characterId, curSelectLevel) + + local levelId = taskConfig.LevelId + self.TxtTitle.text = XCharacterConfigs.GetCharLiberationLevelTitle(characterId, levelId) + self.TxtDesc.text = XCharacterConfigs.GetCharLiberationLevelDesc(characterId, levelId) + + local passed = true + self.ConditionGrids = self.ConditionGrids or {} + local conditionIds = taskConfig.ConditionIds + for i = 1, ConditionDesNum do + local conditionGrid = self.ConditionGrids[i] + if not conditionGrid then + conditionGrid = XUiGridCondition.New(self["GridCondition" .. i]) + self.ConditionGrids[i] = conditionGrid + end + + local conditionId = conditionIds[i] + local subPassed = conditionGrid:Refresh(conditionId, characterId) + passed = passed and subPassed + end + + local rewardItems = XRewardManager.GetRewardList(taskConfig.RewardId) + self.RewardPool = self.RewardPool or {} + XUiHelper.CreateTemplates(self, self.RewardPool, rewardItems, XUiGridCommon.New, self.GridRewardItem, self.PanelRewardItem, function(grid, data) + grid:Refresh(data) + end) + + local taskId = taskConfig.Id + local taskFinished = XDataCenter.ExhibitionManager.CheckGrowUpTaskFinish(taskId) + local canGetReward = passed and not taskFinished + self.BtnBreak:SetDisable(not canGetReward, canGetReward) + self.PanelAlreadyBreak.gameObject:SetActive(taskFinished) + self.BtnBreak.gameObject:SetActive(not taskFinished) + + self.BtnShowInfoToggle.gameObject:SetActiveEx(false) +end + +function XUiExhibitionInfo:OnBtnBackClick() + self:Close() +end + +function XUiExhibitionInfo:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiExhibitionInfo:OnBtnBreakClick() + local characterId = self.CharacterId + local curSelectLevel = TabIndexToGrowUpLevel[self.SelectedIndex] + local growUpLevel = XDataCenter.ExhibitionManager.GetCharacterGrowUpLevel(characterId, true) + if curSelectLevel ~= growUpLevel + 1 then + XUiManager.TipText("CharacterLiberateShouldFollowOrder") + return + end + + XDataCenter.ExhibitionManager.GetGatherReward(characterId, curSelectLevel, function() + CS.XAudioManager.PlaySound(XSoundManager.UiBasicsMusic.UiCharacter_Liberation) + self:UpdateView() + end) +end + +function XUiExhibitionInfo:OnBtnShowInfoToggleClick(value) + local growUpLevel = value == XUiButtonState.Press and TabIndexToGrowUpLevel[self.SelectedIndex] + self:UpdateCharacterModel(growUpLevel) +end + +return XUiExhibitionInfo \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExhibition/XUiGridCharacterIcon.lua b/Resources/Scripts/XUi/XUiExhibition/XUiGridCharacterIcon.lua new file mode 100644 index 00000000..76cc1ce1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiExhibition/XUiGridCharacterIcon.lua @@ -0,0 +1,98 @@ +local XUiGridCharacterIcon = XClass(nil, "XUiGridCharacterIcon") + +function XUiGridCharacterIcon:Ctor(RootUI, index, uiIcon, exhibitionCfg) + self.RootUI = RootUI + self.Index = index + self.GameObject = uiIcon.gameObject + self.Transform = uiIcon.transform + self.Behaviour = self.GameObject:AddComponent(typeof(CS.XLuaBehaviour)) + XTool.InitUiObject(self) + self:Refresh(exhibitionCfg) + self:AddBtnListener() +end + +function XUiGridCharacterIcon:Refresh(exhibitionCfg) + self.CharacterId = exhibitionCfg and exhibitionCfg.CharacterId or 0 + self.RImgIcon:SetRawImage(XDataCenter.ExhibitionManager.GetCharHeadPortrait(self.CharacterId, true)) + if self.CharacterId == nil or self.CharacterId == 0 then + self.ImgMask.gameObject:SetActive(false) + self.LevelPanel.gameObject:SetActive(false) + self.ImgRedPoint.gameObject:SetActive(false) + local levelConfig = XExhibitionConfigs.GetExhibitionGrowUpLevelConfig(XCharacterConfigs.GrowUpLevel.New) + self.RootUI:SetUiSprite(self.ImgIconFrame, levelConfig.IconFrame) + elseif self:IsOwnCharacter(self.CharacterId) then + self.ImgMask.gameObject:SetActive(false) + local growUpLevel = XDataCenter.ExhibitionManager.GetCharacterGrowUpLevel(self.CharacterId, true) + local levelConfig = XExhibitionConfigs.GetExhibitionGrowUpLevelConfig(growUpLevel) + if growUpLevel == XCharacterConfigs.GrowUpLevel.New then + self.LevelPanel.gameObject:SetActive(false) + self.RootUI:SetUiSprite(self.ImgIconFrame, levelConfig.IconFrame) + else + self.RootUI:SetUiSprite(self.ImgLevel, levelConfig.LevelLogo) + self.RootUI:SetUiSprite(self.ImgLevelFrame, levelConfig.LevelFrame) + self.RootUI:SetUiSprite(self.ImgIconFrame, levelConfig.IconFrame) + self.LevelPanel.gameObject:SetActive(true) + end + if self.RootUI.IsSelf then + local showRedPoint = XDataCenter.ExhibitionManager.CheckNewRewardByCharacterId(self.CharacterId) + self.ImgRedPoint.gameObject:SetActive(showRedPoint) + else + self.ImgRedPoint.gameObject:SetActive(false) + end + else + self.ImgMask.gameObject:SetActive(true) + self.LevelPanel.gameObject:SetActive(false) + self.ImgRedPoint.gameObject:SetActive(false) + end +end + +function XUiGridCharacterIcon:IsOwnCharacter(characterId) + return XDataCenter.ExhibitionManager.CheckIsOwnCharacter(characterId, true) +end + +function XUiGridCharacterIcon:AddBtnListener() + self:RegisterClickEvent(self.BtnSelect, self.BtnSelectClick) +end + +function XUiGridCharacterIcon:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiGridExhibition:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiGridExhibition:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiGridCharacterIcon:BtnSelectClick() + if self.RootUI.IsSelf then + if self.CharacterId == nil or self.CharacterId == 0 then + XUiManager.TipText("ExhibitionUnknownCharacter") + elseif XDataCenter.CharacterManager.IsOwnCharacter(self.CharacterId) then + self.RootUI:StartFocus(self.Index, self.CharacterId) + else + XUiManager.TipText("ExhibitionNotObtainCharacter") + end + end +end + +function XUiGridCharacterIcon:CharacterGrowUp() + self.AnimCharacterIcon:Play() + self.Behaviour.LuaUpdate = function() self:CheckAnimEnd() end +end + +function XUiGridCharacterIcon:CheckAnimEnd() + if self.AnimCharacterIcon.time > self.AnimCharacterIcon.duration / 2 then + self:Refresh(self.CharacterId) + self.Behaviour.LuaUpdate = nil + end +end + +return XUiGridCharacterIcon \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExhibition/XUiGridCharacterName.lua b/Resources/Scripts/XUi/XUiExhibition/XUiGridCharacterName.lua new file mode 100644 index 00000000..bd8ded72 --- /dev/null +++ b/Resources/Scripts/XUi/XUiExhibition/XUiGridCharacterName.lua @@ -0,0 +1,27 @@ +local XUiGridExhibitionName = XClass(nil, "XUiGridExhibitionName") + +function XUiGridExhibitionName:Ctor(RootUI, index, uiName, exhibitionCfg) + self.RootUI = RootUI + self.Index = index + self.GameObject = uiName.gameObject + self.Transform = uiName.transform + XTool.InitUiObject(self) + self:Refresh(exhibitionCfg) +end + +function XUiGridExhibitionName:Refresh(exhibitionCfg) + self.CharacterId = exhibitionCfg and exhibitionCfg.CharacterId or 0 + local name + if self.CharacterId == nil or self.CharacterId == 0 then + name = "???" + else + name = XCharacterConfigs.GetCharacterFullNameStr(self.CharacterId) + end + self.TxtName.text = name +end + +function XUiGridExhibitionName:ResetPosition(position) + self.Transform.position = position +end + +return XUiGridExhibitionName \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExhibition/XUiGridCondition.lua b/Resources/Scripts/XUi/XUiExhibition/XUiGridCondition.lua new file mode 100644 index 00000000..ab33dc7b --- /dev/null +++ b/Resources/Scripts/XUi/XUiExhibition/XUiGridCondition.lua @@ -0,0 +1,25 @@ +local XUiGridCondition = XClass(nil, "XUiGridCondition") + +function XUiGridCondition:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiGridCondition:Refresh(conditionId, characterId) + if not conditionId or conditionId == 0 then + self.GameObject:SetActive(false) + return true + end + self.GameObject:SetActive(true) + + local passed, desc = XConditionManager.CheckCondition(conditionId, characterId) + self.TxtPass.text = desc + self.TxtNotPass.text = desc + self.TxtPass.gameObject:SetActive(passed) + self.TxtNotPass.gameObject:SetActive(not passed) + + return passed +end + +return XUiGridCondition \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExhibition/XUiGridGroupIcon.lua b/Resources/Scripts/XUi/XUiExhibition/XUiGridGroupIcon.lua new file mode 100644 index 00000000..3d59951e --- /dev/null +++ b/Resources/Scripts/XUi/XUiExhibition/XUiGridGroupIcon.lua @@ -0,0 +1,29 @@ +local XUiGridGroupIcon = XClass(nil, "XUiGridGroupIcon") + +function XUiGridGroupIcon:Ctor(ui, exhibitionCfg) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:RefreshGroupIcon(exhibitionCfg) + self.BtnGroupInfo.CallBack = function() self:OnBtnGroupInfoClick() end +end + +function XUiGridGroupIcon:RefreshGroupIcon() + self.RImgIcon:SetRawImage(self.ImgPath) +end + +function XUiGridGroupIcon:Refresh(exhibitionCfg) + self.ImgPath = exhibitionCfg and exhibitionCfg.GroupLogo or CS.XGame.ClientConfig:GetString("DefaultGroupExhibitionImagePath") + self.GroupID = exhibitionCfg and exhibitionCfg.GroupId or 0 + self.ShowType = exhibitionCfg and exhibitionCfg.Type or 1 + self.CanClick = exhibitionCfg and exhibitionCfg.CanClickGroup or 1 + self:RefreshGroupIcon() +end + +function XUiGridGroupIcon:OnBtnGroupInfoClick() + if self.CanClick == 0 then + XLuaUiManager.Open("UiExhibitionGroupTip", self.GroupID, self.ShowType) + end +end + +return XUiGridGroupIcon \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExhibition/XUiGridGroupName.lua b/Resources/Scripts/XUi/XUiExhibition/XUiGridGroupName.lua new file mode 100644 index 00000000..05c87518 --- /dev/null +++ b/Resources/Scripts/XUi/XUiExhibition/XUiGridGroupName.lua @@ -0,0 +1,23 @@ +local XUiGridGroupName = XClass(nil, "XUiGridGroupName") + +function XUiGridGroupName:Ctor(ui, exhibitionCfg) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:Refresh(exhibitionCfg) +end + +function XUiGridGroupName:RefreshNameInfo() + self.TxtName.text = self.GroupName +end + +function XUiGridGroupName:Refresh(exhibitionCfg) + self.GroupName = exhibitionCfg and exhibitionCfg.GroupName or CS.XTextManager.GetText("ExhibitionDefaultGroupName") + self:RefreshNameInfo() +end + +function XUiGridGroupName:ResetPosition(position) + self.Transform.position = position +end + +return XUiGridGroupName \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExhibition/XUiPanelCollection.lua b/Resources/Scripts/XUi/XUiExhibition/XUiPanelCollection.lua new file mode 100644 index 00000000..f44d7239 --- /dev/null +++ b/Resources/Scripts/XUi/XUiExhibition/XUiPanelCollection.lua @@ -0,0 +1,55 @@ +local XUiPanelCollection = XClass(nil, "XUiPanelCollection") + +function XUiPanelCollection:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) +end + +function XUiPanelCollection:Refresh(exhibitionType) + local collectionRate = XDataCenter.ExhibitionManager.GetCollectionRate(true, exhibitionType) + self.TxtPanelCollectionRate.text = math.floor(collectionRate * 100) + self.ImgRate.fillAmount = collectionRate + if exhibitionType then + self.TextNameLabel.text = CS.XTextManager.GetText("ExhibitionCollectionLable" .. exhibitionType) + else + self.TextNameLabel.text = CS.XTextManager.GetText("ExhibitionCollectionDefaultLable") + end + local totalCharacterNum = XDataCenter.ExhibitionManager.GetCollectionTotalNum(exhibitionType) + local curFinishNum = XDataCenter.ExhibitionManager.GetTaskFinishNum(true, exhibitionType) + if totalCharacterNum == 0 then + self.ImgRateNew.fillAmount = 1 + self.ImgRateLower.fillAmount = 1 + self.ImgRateMiddle.fillAmount = 1 + self.ImgRateHigher.fillAmount = 1 + else + self.ImgRateNew.fillAmount = curFinishNum[XCharacterConfigs.GrowUpLevel.New] / totalCharacterNum + self.ImgRateLower.fillAmount = curFinishNum[XCharacterConfigs.GrowUpLevel.Lower] / totalCharacterNum + self.ImgRateMiddle.fillAmount = curFinishNum[XCharacterConfigs.GrowUpLevel.Middle] / totalCharacterNum + self.ImgRateHigher.fillAmount = curFinishNum[XCharacterConfigs.GrowUpLevel.Higher] / totalCharacterNum + end + self.TxtNumNew.text = curFinishNum[XCharacterConfigs.GrowUpLevel.New] + self.TxtTotalNew.text = totalCharacterNum + self.TxtNumLower.text = curFinishNum[XCharacterConfigs.GrowUpLevel.Lower] + self.TxtTotalLower.text = totalCharacterNum + self.TxtNumMiddle.text = curFinishNum[XCharacterConfigs.GrowUpLevel.Middle] + self.TxtTotalMiddle.text = totalCharacterNum + self.TxtNumHigher.text = curFinishNum[XCharacterConfigs.GrowUpLevel.Higher] + self.TxtTotalHigher.text = totalCharacterNum + self.InfoLabelNew.text = XExhibitionConfigs.GetExhibitionLevelNameByLevel(XCharacterConfigs.GrowUpLevel.New) + self.InfoLabelLower.text = XExhibitionConfigs.GetExhibitionLevelNameByLevel(XCharacterConfigs.GrowUpLevel.Lower) + self.InfoLabelMiddle.text = XExhibitionConfigs.GetExhibitionLevelNameByLevel(XCharacterConfigs.GrowUpLevel.Middle) + self.InfoLabelHigher.text = XExhibitionConfigs.GetExhibitionLevelNameByLevel(XCharacterConfigs.GrowUpLevel.Higher) +end + +function XUiPanelCollection:Show(exhibitionType) + self:Refresh(exhibitionType) + self.GameObject:SetActive(true) +end + +function XUiPanelCollection:Hide() + self.GameObject:SetActive(false) +end + +return XUiPanelCollection \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/Battle/ChangeMember/XUiExpeditionRoomCharListGrid.lua b/Resources/Scripts/XUi/XUiExpedition/Battle/ChangeMember/XUiExpeditionRoomCharListGrid.lua new file mode 100644 index 00000000..05d59af6 --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/Battle/ChangeMember/XUiExpeditionRoomCharListGrid.lua @@ -0,0 +1,51 @@ +--虚像地平线战斗准备换人界面成员列表控件 +local XUiExpeditionRoomCharListGrid = XClass(nil, "XUiExpeditionRoomCharacterGrid") +function XUiExpeditionRoomCharListGrid:Ctor() + +end + +function XUiExpeditionRoomCharListGrid:Init(ui, rootUi) + self.Transform = ui.transform + self.GameObject = ui.gameObject + self.RootUi = rootUi + XTool.InitUiObject(self) + self.PanelSelected.gameObject:SetActiveEx(false) + self:SetInTeam(false) +end + +function XUiExpeditionRoomCharListGrid:RefreshDatas(eChara) + if not eChara then + return + end + self.EChara = eChara + self.RImgHeadIcon:SetRawImage(self.EChara:GetSmallHeadIcon()) + self.TxtFight.text = self.EChara:GetAbility() + self.TxtLevel.text = self.EChara:GetRankStr() + self:RefreshElements() +end + +function XUiExpeditionRoomCharListGrid:SetSelect(isSelect) + self.PanelSelected.gameObject:SetActiveEx(isSelect) + self.IsSelect = isSelect + if isSelect and self.EChara then self.RootUi:Refresh(self.EChara:GetCharacterId(), self.EChara:GetRobotId(), self.EChara:GetBaseId()) end +end + +function XUiExpeditionRoomCharListGrid:SetInTeam(isInTeam) + self.ImgInTeam.gameObject:SetActiveEx(isInTeam) +end + +function XUiExpeditionRoomCharListGrid:RefreshElements() + local elementList = self.EChara:GetCharacterElements() + for i = 1, 3 do + local rImg = self["RImgCharElement" .. i] + if rImg and elementList[i] then + rImg.transform.gameObject:SetActive(true) + local elementConfig = XExpeditionConfig.GetCharacterElementById(elementList[i]) + rImg:SetRawImage(elementConfig.Icon) + elseif rImg then + rImg.transform.gameObject:SetActive(false) + end + end +end + +return XUiExpeditionRoomCharListGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/Battle/ChangeMember/XUiExpeditionRoomCharListPanel.lua b/Resources/Scripts/XUi/XUiExpedition/Battle/ChangeMember/XUiExpeditionRoomCharListPanel.lua new file mode 100644 index 00000000..43fc0226 --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/Battle/ChangeMember/XUiExpeditionRoomCharListPanel.lua @@ -0,0 +1,55 @@ +--虚像地平线战斗准备换人界面:角色列表 +local XUiExpeditionRoomCharListPanel = XClass(nil, "XUiExpeditionRoomCharListPanel") +local XUiExpeditionRoomCharListGrid = require("XUi/XUiExpedition/Battle/ChangeMember/XUiExpeditionRoomCharListGrid") +function XUiExpeditionRoomCharListPanel:Ctor(ui, rootUi) + self.Transform = ui.transform + self.GameObject = ui.gameObject + self.RootUi = rootUi + XTool.InitUiObject(self) + self.DynamicTable = XDynamicTableNormal.New(self.GameObject) + self.DynamicTable:SetProxy(XUiExpeditionRoomCharListGrid) + self.DynamicTable:SetDelegate(self) +end + +function XUiExpeditionRoomCharListPanel:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(grid.DynamicGrid.gameObject, self.RootUi, index) + if self.CurrentSelect == index then + self:SetSelectCharacter(grid) + end + local memberData = self.MemberList[index] + grid:SetInTeam(XDataCenter.ExpeditionManager.GetCharacterIsInTeam(memberData:GetBaseId())) + grid:RefreshDatas(memberData) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:SetSelect(false) + grid:SetInTeam(false) + if self.CurrentSelect == index then + self:SetSelectCharacter(grid) + end + local memberData = self.MemberList[index] + grid:SetInTeam(XDataCenter.ExpeditionManager.GetCharacterIsInTeam(memberData:GetBaseId())) + grid:RefreshDatas(memberData) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + self.CurrentSelect = index + self:SetSelectCharacter(grid) + end +end + +function XUiExpeditionRoomCharListPanel:UpdateData(index) + self.MemberList = XDataCenter.ExpeditionManager.GetTeam():GetDisplayTeamList() + self.CurrentSelect = index + self.DynamicTable:SetDataSource(self.MemberList) + if #self.MemberList > 0 then + self.DynamicTable:ReloadDataSync(index) + end +end +--选中 +function XUiExpeditionRoomCharListPanel:SetSelectCharacter(grid) + if self.CurCharacterGrid then + self.CurCharacterGrid:SetSelect(false) + end + self.CurCharacterGrid = grid + self.CurCharacterGrid:SetSelect(true) + self.RootUi.CurrentSelect = self.CurrentSelect +end +return XUiExpeditionRoomCharListPanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/Battle/ChangeMember/XUiExpeditionRoomCharacter.lua b/Resources/Scripts/XUi/XUiExpedition/Battle/ChangeMember/XUiExpeditionRoomCharacter.lua new file mode 100644 index 00000000..ea76d91c --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/Battle/ChangeMember/XUiExpeditionRoomCharacter.lua @@ -0,0 +1,136 @@ +--虚像地平线战斗准备换人界面 +local XUiExpeditionRoomCharacter = XLuaUiManager.Register(XLuaUi, "UiExpeditionRoomCharacter") +local XUiExpeditionRoomCharListPanel = require("XUi/XUiExpedition/Battle/ChangeMember/XUiExpeditionRoomCharListPanel") +function XUiExpeditionRoomCharacter:OnAwake() + XTool.InitUiObject(self) + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + local root = self.UiModelGo.transform + self.PanelRoleModel = root:FindTransform("PanelRoleModel") + self.ImgEffectHuanren = root:FindTransform("ImgEffectHuanren") + self.GridCharacter.gameObject:SetActiveEx(false) + self.CharacterList = XUiExpeditionRoomCharListPanel.New(self.SViewCharacterList, self) + self.RoleModelPanel = XUiPanelRoleModel.New(self.PanelRoleModel, self.Name, nil, true, nil, true) + self:AddListener() +end + +function XUiExpeditionRoomCharacter:OnStart(teamData, changePos, cb) + self.TeamData = teamData + self.ChangePos = changePos + local baseId = teamData[changePos] + if baseId ~= 0 then + local selectIndex = XDataCenter.ExpeditionManager.GetCharaDisplayIndex(baseId) + self.CurrentSelect = selectIndex + else + self.CurrentSelect = 1 + end + self.CharacterList:UpdateData(self.CurrentSelect) + self.CallBack = cb +end + +function XUiExpeditionRoomCharacter:OnEnable() + CS.XGraphicManager.UseUiLightDir = true + self.CharacterList:UpdateData(self.CurrentSelect or 1) +end + +function XUiExpeditionRoomCharacter:Refresh(characterId, robotId, baseId) + self.RobotId = robotId + self:UpdateModel(characterId, robotId) + self:SetTeamBtns(baseId) +end + +function XUiExpeditionRoomCharacter:UpdateModel(characterId, robotId) + if not characterId then return end + self.ImgEffectHuanren.gameObject:SetActiveEx(false) + self.ImgEffectHuanren.gameObject:SetActiveEx(true) + local callback = function() + self.ModelReady = true + end + self.ModelReady = false + local robotCfg = XRobotManager.GetRobotTemplate(robotId) + if not robotCfg then return end + self.RoleModelPanel:UpdateRobotModel(robotId, characterId, callback, robotCfg and robotCfg.FashionId, robotCfg and robotCfg.WeaponId) +end + +function XUiExpeditionRoomCharacter:OnDisable() + CS.XGraphicManager.UseUiLightDir = false +end + +function XUiExpeditionRoomCharacter:OnDestroy() + if self.CallBack then + self.CallBack(self.TeamData) + self.CallBack = nil + end +end +function XUiExpeditionRoomCharacter:SetTeamBtns(baseId) + local isInTeam = XDataCenter.ExpeditionManager.GetCharacterIsInTeam(baseId) + self.BtnJoinTeam.gameObject:SetActiveEx(not isInTeam) + self.BtnQuitTeam.gameObject:SetActiveEx(isInTeam) +end +function XUiExpeditionRoomCharacter:OnGetEvents() + return { XEventId.EVENT_ACTIVITY_ON_RESET } +end + +function XUiExpeditionRoomCharacter:OnNotify(evt, ...) + local args = { ... } + if evt == XEventId.EVENT_ACTIVITY_ON_RESET then + if args[1] ~= XDataCenter.FubenManager.StageType.Expedition then return end + XLuaUiManager.RunMain() + XUiManager.TipMsg(CS.XTextManager.GetText("ExpeditionOnClose")) + end +end +function XUiExpeditionRoomCharacter:AddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:RegisterClickEvent(self.BtnJoinTeam, self.OnBtnJoinClick) + self:RegisterClickEvent(self.BtnQuitTeam, self.OnBtnQuitClick) +end + +function XUiExpeditionRoomCharacter:OnBtnBackClick() + self:Close() +end + +function XUiExpeditionRoomCharacter:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiExpeditionRoomCharacter:OnBtnJoinClick() + local eChara = XDataCenter.ExpeditionManager.GetECharaByDisplayIndex(self.CurrentSelect) + local id = eChara:GetBaseId() + for k, v in pairs(self.TeamData) do + if v == id then + self.TeamData[k] = 0 + break + end + end + + self.TeamData[self.ChangePos] = id + if self.CallBack then + self.CallBack(self.TeamData) + self.CallBack = nil + end + self:Close() +end + +function XUiExpeditionRoomCharacter:OnBtnQuitClick() + local count = 0 + for _, v in pairs(self.TeamData) do + if v > 0 then + count = count + 1 + end + end + + local eChara = XDataCenter.ExpeditionManager.GetECharaByDisplayIndex(self.CurrentSelect) + local id = eChara:GetBaseId() + for k, v in pairs(self.TeamData) do + if v == id then + self.TeamData[k] = 0 + break + end + end + + if self.CallBack then + self.CallBack(self.TeamData) + self.CallBack = nil + end + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/Battle/XUiExpeditionInfinityCombo.lua b/Resources/Scripts/XUi/XUiExpedition/Battle/XUiExpeditionInfinityCombo.lua new file mode 100644 index 00000000..7aa2545b --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/Battle/XUiExpeditionInfinityCombo.lua @@ -0,0 +1,16 @@ +-- 虚像地平线无尽关结算界面羁绊控件 +local XUiExpeditionInfinityCombo = XClass(nil, "XUiExpeditionInfinityCombo") + +function XUiExpeditionInfinityCombo:Ctor() + +end + +function XUiExpeditionInfinityCombo:Init(ui) + XTool.InitUiObjectByUi(self, ui) +end + +function XUiExpeditionInfinityCombo:RefreshData(eCombo) + self.RImgActive:SetRawImage(eCombo:GetIconPath()) +end + +return XUiExpeditionInfinityCombo \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/Battle/XUiExpeditionInfinityComboList.lua b/Resources/Scripts/XUi/XUiExpedition/Battle/XUiExpeditionInfinityComboList.lua new file mode 100644 index 00000000..f7153790 --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/Battle/XUiExpeditionInfinityComboList.lua @@ -0,0 +1,32 @@ +-- 虚像地平线无尽关羁绊动态列表控件 +local XUiExpeditionInfinityComboList = XClass(nil, "XUiExpeditionInfinityComboList") +local XUiExpeditionInfinityCombo = require("XUi/XUiExpedition/Battle/XUiExpeditionInfinityCombo") +function XUiExpeditionInfinityComboList:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self:InitDynamicTable() +end + +function XUiExpeditionInfinityComboList:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.GameObject) + self.DynamicTable:SetProxy(XUiExpeditionInfinityCombo) + self.DynamicTable:SetDelegate(self) +end + +--动态列表事件 +function XUiExpeditionInfinityComboList:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(grid.DynamicGrid.gameObject) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + if self.ComboList and self.ComboList[index] then + grid:RefreshData(self.ComboList[index]) + end + end +end + +function XUiExpeditionInfinityComboList:RefreshData() + self.ComboList = XDataCenter.ExpeditionManager.GetTeam():GetActiveTeamComboList() + self.DynamicTable:SetDataSource(self.ComboList) + self.DynamicTable:ReloadDataASync(1) +end +return XUiExpeditionInfinityComboList \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/Battle/XUiExpeditionInfinityHeadIcon.lua b/Resources/Scripts/XUi/XUiExpedition/Battle/XUiExpeditionInfinityHeadIcon.lua new file mode 100644 index 00000000..48040354 --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/Battle/XUiExpeditionInfinityHeadIcon.lua @@ -0,0 +1,14 @@ +-- 虚像地平线无尽关结算界面头像控件 +local XUiExpeditionInfinityHeadIcon = XClass(nil, "XUiExpeditionInfinityHeadIcon") + +function XUiExpeditionInfinityHeadIcon:Ctor(ui) + XTool.InitUiObjectByUi(self, ui) +end + +function XUiExpeditionInfinityHeadIcon:RefreshData(eChara) + self.RImgIcon:SetRawImage(eChara:GetBigHeadIcon()) + self.TxtLevel.text = eChara:GetRankStr() + self.TxtRoleName.text = eChara:GetCharaFullName() +end + +return XUiExpeditionInfinityHeadIcon \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/Battle/XUiExpeditionInfinityWin.lua b/Resources/Scripts/XUi/XUiExpedition/Battle/XUiExpeditionInfinityWin.lua new file mode 100644 index 00000000..f8a1ecd2 --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/Battle/XUiExpeditionInfinityWin.lua @@ -0,0 +1,125 @@ +-- 虚像地平线无尽关胜利结算界面 +local XUiExpeditionInfinityWin = XLuaUiManager.Register(XLuaUi, "UiExpeditionInfinityWin") + +function XUiExpeditionInfinityWin:OnAwake() + XTool.InitUiObject(self) + self:InitPanel() + self:RegisterBtns() +end + +function XUiExpeditionInfinityWin:InitPanel() + self.GridWinRole.gameObject:SetActive(false) + self.GridCombo.gameObject:SetActive(false) + self.PanelNewRecord.gameObject:SetActive(false) +end + +function XUiExpeditionInfinityWin:RegisterBtns() + self.BtnExitFight.CallBack = function() self:OnBtnExitClick() end + self.BtnReFight.CallBack = function() self:OnBtnReFightClick() end +end + +function XUiExpeditionInfinityWin:OnBtnExitClick() + if XDataCenter.ExpeditionManager.GetIfBackMain() then + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end + self:StopAudio() + XLuaUiManager.RunMain() + XUiManager.TipMsg(CS.XTextManager.GetText("ExpeditionOnClose")) + else + self:StopAudio() + self:Close() + end +end + +function XUiExpeditionInfinityWin:OnBtnReFightClick() + if XDataCenter.ExpeditionManager.GetIfBackMain() then + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end + self:StopAudio() + XLuaUiManager.RunMain() + XUiManager.TipMsg(CS.XTextManager.GetText("ExpeditionOnClose")) + else + self:StopAudio() + self:Close() + XLuaUiManager.Open("UiNewRoomSingle", self.EStage:GetStageId()) + end +end + +function XUiExpeditionInfinityWin:OnStart(data) + self.WinData = data.SettleData.ExpeditionFightResult + self.EStage = XDataCenter.ExpeditionManager.GetEStageByStageId(data.StageId) + self.HistoryWave = XDataCenter.ExpeditionManager.GetWave() + local newWave = self.WinData.NpcGroup > 0 and self.WinData.NpcGroup or 0 + if self.HistoryWave < newWave then XDataCenter.ExpeditionManager.SetWave(self.WinData.NpcGroup) end + self.CurrentStageId = data.StageId + self.IsFirst = true + self:InitInfo() + XLuaUiManager.SetMask(true) +end + +function XUiExpeditionInfinityWin:InitInfo() + self:InitStageNameAndTime() + self:InitRolePanel() + self:InitComboPanel() + self:ShowWave() +end + +function XUiExpeditionInfinityWin:InitStageNameAndTime() + self.TxtStageName.text = self.EStage:GetStageName() + self.TxtCostTime.text = self.WinData.UseTime or "-" +end + +function XUiExpeditionInfinityWin:InitRolePanel() + local team = XDataCenter.ExpeditionManager.GetTeam():GetBattleTeam() + local XHeadIcon = require("XUi/XUiExpedition/Battle/XUiExpeditionInfinityHeadIcon") + for _, member in pairs(team) do + local prefab = CS.UnityEngine.Object.Instantiate(self.GridWinRole.gameObject) + prefab.transform:SetParent(self.PanelRoleContent.transform, false) + local headIcon = XHeadIcon.New(prefab) + headIcon:RefreshData(member) + prefab.gameObject:SetActiveEx(true) + end +end + +function XUiExpeditionInfinityWin:InitComboPanel() + local XComboList = require("XUi/XUiExpedition/Battle/XUiExpeditionInfinityComboList") + self.ComboList = XComboList.New(self.DyanamicTableCombo) + self.ComboList:RefreshData() +end + +function XUiExpeditionInfinityWin:ShowWave() + self.AudioInfo = CS.XAudioManager.PlaySound(XSoundManager.UiBasicsMusic.UiSettle_Win_Number) + local time = CS.XGame.ClientConfig:GetFloat("BossSingleAnimaTime") + local newWave = self.WinData.NpcGroup > 0 and (self.WinData.NpcGroup - 1) or 0 + XUiHelper.Tween(time, function(f) + if XTool.UObjIsNil(self.Transform) then + return + end + + -- 通关时间 + local costTime = XUiHelper.GetTime(math.floor(f * self.WinData.UseTime), XUiHelper.TimeFormatType.SHOP) + self.TxtCostTime.text = costTime + + -- 当前波数 + local wave = math.floor(f * newWave) + self.TxtCurrentWave.text = wave + + -- 历史最高分 + local highScore = math.floor(f * self.HistoryWave) + self.TxtHistoryWave.text = highScore + end, function() + self:StopAudio() + self.PanelNewRecord.gameObject:SetActiveEx(newWave > self.HistoryWave) + XLuaUiManager.SetMask(false) + end) +end + +function XUiExpeditionInfinityWin:StopAudio() + if self.AudioInfo then + self.AudioInfo:Stop() + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/Battle/XUiExpeditionNewRoomSingle.lua b/Resources/Scripts/XUi/XUiExpedition/Battle/XUiExpeditionNewRoomSingle.lua new file mode 100644 index 00000000..ebc18eab --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/Battle/XUiExpeditionNewRoomSingle.lua @@ -0,0 +1,89 @@ +-- 虚像地平线出战界面代理 +local XUiExpeditionNewRoomSingle = {} + +function XUiExpeditionNewRoomSingle.InitEditBattleUi(newRoomSingle) + newRoomSingle.BtnTeamPrefab.gameObject:SetActiveEx(false) + newRoomSingle.PanelCharacterLimit.gameObject:SetActiveEx(false) +end + +function XUiExpeditionNewRoomSingle.InitEditBattleUiCharacterInfo(newRoomSingle) + newRoomSingle.BtnShowInfoToggle.gameObject:SetActiveEx(false) + newRoomSingle.IsShowCharacterInfo = 0 +end + +function XUiExpeditionNewRoomSingle.GetEditBattleUiCaptainId(newRoomSingle) + local eChara = XDataCenter.ExpeditionManager.GetECharaByEBaseId(newRoomSingle.CurTeam.TeamData[newRoomSingle.CurTeam.CaptainPos]) + return eChara and eChara:GetRobotId() or 0 +end + +function XUiExpeditionNewRoomSingle.GetBattleTeamData(newRoomSingle) + return XDataCenter.ExpeditionManager.GetExpeditionTeam() +end + +function XUiExpeditionNewRoomSingle.HandleCharClick(newRoomSingle, charPos) + XLuaUiManager.Open("UiExpeditionRoomCharacter", XTool.Clone(newRoomSingle.CurTeam.TeamData), charPos, function(resTeam) + newRoomSingle:UpdateTeam(resTeam) + end) +end + +function XUiExpeditionNewRoomSingle.UpdateTeam(newRoomSingle) + XDataCenter.TeamManager.SetExpeditionTeamData(newRoomSingle.CurTeam) +end + +function XUiExpeditionNewRoomSingle.UpdateRoleModel(newRoomSingle, charId, roleModelPanel, pos) + roleModelPanel:ShowRoleModel() + local callback = function() + newRoomSingle.LoadModelCount = newRoomSingle.LoadModelCount - 1 + if newRoomSingle.LoadModelCount <= 0 then + newRoomSingle.BtnEnterFight:SetDisable(false) + end + end + local eChara = XDataCenter.ExpeditionManager.GetECharaByEBaseId(charId) + local robotId = eChara and eChara:GetRobotId() or 0 + local characterId = eChara and eChara:GetCharacterId() + local robotCfg = XRobotManager.GetRobotTemplate(robotId) + roleModelPanel:UpdateRobotModel(robotId, characterId, callback, robotCfg.FashionId, robotCfg.WeaponId) +end + +function XUiExpeditionNewRoomSingle.OnResetEvent(newRoomSingle) + XLuaUiManager.RunMain() + XUiManager.TipMsg(CS.XTextManager.GetText("ExpeditionOnClose")) +end + +function XUiExpeditionNewRoomSingle.SetEditBattleUiTeam(newRoomSingle) + XDataCenter.TeamManager.SetExpeditionTeamData(newRoomSingle.CurTeam) +end + +function XUiExpeditionNewRoomSingle.GetRealCharData(newRoomSingle) + local teamData = newRoomSingle.CurTeam.TeamData + local teamIdData = {} + for pos, eBaseId in pairs(teamData) do + if eBaseId and eBaseId > 0 then + local eChara = XDataCenter.ExpeditionManager.GetECharaByEBaseId(eBaseId) + teamIdData[pos] = eChara and eChara:GetRobotId() or 0 + else + teamIdData[pos] = 0 + end + end + return teamIdData +end + +function XUiExpeditionNewRoomSingle.UpdateFightControl(newRoomSingle, curTeam) + local eStageId = XExpeditionConfig.GetEStageByStageId(newRoomSingle.CurrentStageId).Id + local eStage = XDataCenter.ExpeditionManager.GetEStageByEStageId(eStageId) + newRoomSingle.FightControlResult = newRoomSingle.FightControl:UpdateByTextAndWarningLevel( + eStage:GetStageIsDanger(curTeam), + CS.XTextManager.GetText("ExpeditionWarningControlName"), + eStage:GetRecommentStar(), + CS.XTextManager.GetText("ExpeditionWarningCurNumText", XDataCenter.ExpeditionManager.GetTeamAverageStar()) + ) +end + +function XUiExpeditionNewRoomSingle.LimitCharacter(newRoomSingle, curTeam) + +end + +function XUiExpeditionNewRoomSingle.UpdatePartnerInfo(newRoomSingle, maxCount) + +end +return XUiExpeditionNewRoomSingle \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/Battle/XUiExpeditionSettleWin.lua b/Resources/Scripts/XUi/XUiExpedition/Battle/XUiExpeditionSettleWin.lua new file mode 100644 index 00000000..630c256b --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/Battle/XUiExpeditionSettleWin.lua @@ -0,0 +1,195 @@ +--虚像地平线战斗结算界面 +local XUiExpeditionSettleWin = XLuaUiManager.Register(XLuaUi, "UiExpeditionSettleWin") +local XUiExpeditionSettleWinHeadIcon = require("XUi/XUiExpedition/Battle/XUiExpeditionSettleWinHeadIcon") +local XUiPanelExpBar = require("XUi/XUiSettleWinMainLine/XUiPanelExpBar") +function XUiExpeditionSettleWin:OnAwake() + XTool.InitUiObject(self) + self:InitAutoScript() + self.GridReward.gameObject:SetActive(false) +end + +function XUiExpeditionSettleWin:OnStart(data, cb) + self.WinData = data + self.StageInfos = XDataCenter.FubenManager.GetStageInfo(data.StageId) + self.StageCfg = XDataCenter.FubenManager.GetStageCfg(data.StageId) + self.CurrentStageId = data.StageId + self.CurrAssistInfo = data.ClientAssistInfo + self.Cb = cb + self.IsFirst = true; + self:InitInfo(data) + XLuaUiManager.SetMask(true) + self:PlayRewardAnimation() +end + +function XUiExpeditionSettleWin:OnEnable() + if not self.IsFirst then + XLuaUiManager.SetMask(true) + self.Timer = XScheduleManager.ScheduleOnce(function() + self:PlaySecondAnimation() + end, 0) + end +end + +function XUiExpeditionSettleWin:OnDestroy() + XDataCenter.AntiAddictionManager.EndFightAction() +end + +-- 奖励动画 +function XUiExpeditionSettleWin:PlayRewardAnimation() + local delay = XDataCenter.FubenManager.SettleRewardAnimationDelay + local interval = XDataCenter.FubenManager.SettleRewardAnimationInterval + local this = self + + -- 没有奖励则直接播放第二个动画 + if not self.GridRewardList or #self.GridRewardList == 0 then + self.Timer = XScheduleManager.ScheduleOnce(function() + this:PlaySecondAnimation() + end, delay) + return + end + + self.RewardAnimationIndex = 1 + self.Timer = XScheduleManager.Schedule(function() + if this.RewardAnimationIndex == #self.GridRewardList then + this:PlayReward(this.RewardAnimationIndex, function() + this:PlaySecondAnimation() + end) + else + this:PlayReward(this.RewardAnimationIndex) + end + this.RewardAnimationIndex = this.RewardAnimationIndex + 1 + end, interval, #self.GridRewardList, delay) +end + + +function XUiExpeditionSettleWin:PlaySecondAnimation() + local this = self + self:PlayAnimation("AnimEnable2", function() + XLuaUiManager.SetMask(false) + -- this:PlayTipMission() + XDataCenter.FunctionEventManager.UnLockFunctionEvent() + self.IsFirst = false; + end) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiExpeditionSettleWin:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiExpeditionSettleWin:AutoInitUi() + self.PanelNorWinInfo = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo") + self.PanelNor = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor") + self.PanelBtn = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelBtn") + self.PanelBtns = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelBtn/PanelBtns") + self.BtnLeft = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelBtn/PanelBtns/BtnLeft"):GetComponent("Button") + self.TxtLeft = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelBtn/PanelBtns/BtnLeft/TxtLeft"):GetComponent("Text") + self.BtnRight = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelBtn/PanelBtns/BtnRight"):GetComponent("Button") + self.TxtRight = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelBtn/PanelBtns/BtnRight/TxtRight"):GetComponent("Text") + self.PanelTouch = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelBtn/PanelTouch") + self.BtnBlock = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelBtn/PanelTouch/BtnBlock"):GetComponent("Button") + self.TxtLeftA = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelBtn/PanelTouch/BtnBlock/TxtLeft"):GetComponent("Text") + self.PanelLeft = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelLeft") + self.PanelRoleContent = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelLeft/Team/PanelRoleContent") + self.GridWinRole = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelLeft/Team/PanelRoleContent/GridWinRole") + self.PanelRight = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelRight") + self.TxtChapterName = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelRight/StageInfo/TxtChapterName"):GetComponent("Text") + self.TxtStageName = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelRight/StageInfo/TxtStageName"):GetComponent("Text") + self.PanelRewardContent = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelRight/RewardList/Viewport/PanelRewardContent") + self.GridReward = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelRight/RewardList/Viewport/PanelRewardContent/GridReward") + self.PanelFriend = self.Transform:Find("SafeAreaContentPane/PanelFriend") + self.PanelInf = self.Transform:Find("SafeAreaContentPane/PanelFriend/PanelInf") + self.TxtName = self.Transform:Find("SafeAreaContentPane/PanelFriend/PanelInf/TxtName"):GetComponent("Text") + self.TxtLv = self.Transform:Find("SafeAreaContentPane/PanelFriend/PanelInf/TxtLv"):GetComponent("Text") + self.PanelPlayerExpBar = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelLeft/PlayerExp/PanelPlayerExpBar") +end + +function XUiExpeditionSettleWin:AutoAddListener() + self:RegisterClickEvent(self.BtnBlock, self.OnBtnExitClick) +end + +function XUiExpeditionSettleWin:InitInfo(data) + self.PanelFriend.gameObject:SetActive(false) + self:SetBtnsInfo() + self:SetStageInfo(data) + self:UpdatePlayerInfo(data) + self:InitRewardCharacterList(data) + self:InitRewardList(data.RewardGoodsList) +end + +function XUiExpeditionSettleWin:SetBtnsInfo() + self.PanelTouch.gameObject:SetActive(true) + self.PanelBtns.gameObject:SetActive(false) +end + +function XUiExpeditionSettleWin:SetStageInfo(data) + local chapterName, stageName = XDataCenter.FubenManager.GetFubenNames(data.StageId) + self.TxtChapterName.text = chapterName + self.TxtStageName.text = stageName +end + +-- 角色奖励列表 +function XUiExpeditionSettleWin:InitRewardCharacterList(data) + self.GridWinRole.gameObject:SetActive(false) + local teamData = XDataCenter.ExpeditionManager.GetExpeditionTeam() + for i = 1, #teamData.TeamData do + if teamData.TeamData[i] ~= 0 then + local ui = CS.UnityEngine.Object.Instantiate(self.GridWinRole) + local grid = XUiExpeditionSettleWinHeadIcon.New(ui) + grid.Transform:SetParent(self.PanelRoleContent, false) + grid:RefreshData(teamData.TeamData[i]) + grid.GameObject:SetActive(true) + end + end +end + +-- 玩家经验 +function XUiExpeditionSettleWin:UpdatePlayerInfo(data) + if not data or not next(data) then return end + local lastLevel = data.RoleLevel + local lastExp = data.RoleExp + local lastMaxExp = XPlayerManager.GetMaxExp(lastLevel, XPlayer.IsHonorLevelOpen()) + local curLevel = XPlayer.GetLevelOrHonorLevel() + local curExp = XPlayer.Exp + local curMaxExp = XPlayerManager.GetMaxExp(curLevel, XPlayer.IsHonorLevelOpen()) + local txtLevelName = XPlayer.IsHonorLevelOpen() and CS.XTextManager.GetText("HonorLevel") or nil + local addExp = self.StageCfg.TeamExp + + self.PlayerExpBar = self.PlayerExpBar or XUiPanelExpBar.New(self.PanelPlayerExpBar) + self.PlayerExpBar:LetsRoll(lastLevel, lastExp, lastMaxExp, curLevel, curExp, curMaxExp, addExp, txtLevelName) +end + +-- 物品奖励列表 +function XUiExpeditionSettleWin:InitRewardList(rewardGoodsList) + rewardGoodsList = rewardGoodsList or {} + self.GridRewardList = {} + local rewards = XRewardManager.MergeAndSortRewardGoodsList(rewardGoodsList) + for _, item in ipairs(rewards) do + local ui = CS.UnityEngine.Object.Instantiate(self.GridReward) + local grid = XUiGridCommon.New(self, ui) + grid.Transform:SetParent(self.PanelRewardContent, false) + grid:Refresh(item, nil, nil, true) + grid.GameObject:SetActive(false) + table.insert(self.GridRewardList, grid) + end +end + +function XUiExpeditionSettleWin:OnBtnExitClick() + if XDataCenter.ExpeditionManager.GetIfBackMain() then + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end + XLuaUiManager.RunMain() + XUiManager.TipMsg(CS.XTextManager.GetText("ExpeditionOnClose")) + else + self:Close() + end +end + +function XUiExpeditionSettleWin:PlayReward(index, cb) + self.GridRewardList[index].GameObject:SetActive(true) + self:PlayAnimation("GridReward", cb) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/Battle/XUiExpeditionSettleWinHeadIcon.lua b/Resources/Scripts/XUi/XUiExpedition/Battle/XUiExpeditionSettleWinHeadIcon.lua new file mode 100644 index 00000000..73ebc43d --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/Battle/XUiExpeditionSettleWinHeadIcon.lua @@ -0,0 +1,16 @@ +--虚像地平线结算界面头像控件 +local XUiExpeditionSettleWinHeadIcon = XClass(nil, "XUiExpeditionSettleWinHeadIcon") +function XUiExpeditionSettleWinHeadIcon:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiExpeditionSettleWinHeadIcon:RefreshData(baseId) + local eChara = XDataCenter.ExpeditionManager.GetECharaByEBaseId(baseId) + self.RImgIcon:SetRawImage(eChara:GetBigHeadIcon()) + self.Rank = eChara and eChara:GetRank() or 1 + self.TxtLevel.text = eChara and eChara:GetRankStr() or 1 +end + +return XUiExpeditionSettleWinHeadIcon \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/ComboList/XUiEXpeditionComboTipsHeadIcon.lua b/Resources/Scripts/XUi/XUiExpedition/ComboList/XUiEXpeditionComboTipsHeadIcon.lua new file mode 100644 index 00000000..f8bad2f1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/ComboList/XUiEXpeditionComboTipsHeadIcon.lua @@ -0,0 +1,40 @@ +--虚像地平线羁绊组合详细页面: 羁绊详细项控件: 头像控件 +local XUiExpeditionComboTipsHeadIcon = XClass(nil, "XUiExpeditionComboTipsHeadIcon") +function XUiExpeditionComboTipsHeadIcon:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiExpeditionComboTipsHeadIcon:Show() + self.GameObject:SetActiveEx(true) +end + +function XUiExpeditionComboTipsHeadIcon:Hide() + self.GameObject:SetActiveEx(false) +end + +function XUiExpeditionComboTipsHeadIcon:RefreshData(displayData, sampleRank) + self.SampleRank = sampleRank + if displayData.IsBlank then + local BlankIconPath = CS.XGame.ClientConfig:GetString("ExpeditionNoMember") + self.RImgRoleNor:SetRawImage(BlankIconPath) + self.RImgRoleDis:SetRawImage(BlankIconPath) + self.RImgRoleNor.gameObject:SetActiveEx(false) + self.RImgRoleDis.gameObject:SetActiveEx(true) + self.TxtDis.gameObject:SetActiveEx(true) + self.TxtLevel.gameObject:SetActiveEx(false) + if self.TxtName then self.TxtName.text = "" end + else + self.IsActive = displayData.IsActive + self.TxtLevel.gameObject:SetActiveEx(displayData.EChara:GetIsInTeam()) + self.TxtDis.gameObject:SetActiveEx(not displayData.EChara:GetIsInTeam()) + self.RImgRoleNor:SetRawImage(displayData.EChara:GetSmallHeadIcon()) + self.RImgRoleDis:SetRawImage(displayData.EChara:GetSmallHeadIcon()) + self.RImgRoleNor.gameObject:SetActiveEx(self.IsActive) + self.RImgRoleDis.gameObject:SetActiveEx(not self.IsActive) + self.TxtLevel.text = displayData.EChara:GetRankStr() + if self.TxtName then self.TxtName.text = displayData.EChara:GetCharacterTradeName() end + end +end +return XUiExpeditionComboTipsHeadIcon \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/ComboList/XUiExpeditionComboTips.lua b/Resources/Scripts/XUi/XUiExpedition/ComboList/XUiExpeditionComboTips.lua new file mode 100644 index 00000000..119b836e --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/ComboList/XUiExpeditionComboTips.lua @@ -0,0 +1,128 @@ +--虚像地平线羁绊组合详细页面 +local XUiExpeditionComboTips = XLuaUiManager.Register(XLuaUi, "UiExpeditionComboTips") +local XUiExpeditionComboTipsTab = require("XUi/XUiExpedition/ComboList/XUiExpeditionComboTipsTab") +local XUiExpeditionComboTipsItemPanel = require("XUi/XUiExpedition/ComboList/XUiExpeditionComboTipsItemPanel") +local TabType = { + First = "BtnFirstHasSnd", + SecondTop = "BtnSecondTop", + SecondBottom = "BtnSecondBottom", + Second = "BtnSecond", + SecondAll = "BtnSecondAll" +} +local UiButtonState = CS.UiButtonState +function XUiExpeditionComboTips:OnAwake() + XTool.InitUiObject(self) + self:RegisterBtnEvent() + self:SetBtnTemplateDisable() +end + +function XUiExpeditionComboTips:OnStart(eCombo, team) + self:InitComboTab(team) + self.ItemPanel = XUiExpeditionComboTipsItemPanel.New(self.PanelPart, self) + self.BtnContent:SelectIndex(eCombo and self.ChildTabList[eCombo:GetComboId()] or 1) +end + +function XUiExpeditionComboTips:SetBtnTemplateDisable() + self.BtnFirst.gameObject:SetActiveEx(false) + self.BtnFirstHasSnd.gameObject:SetActiveEx(false) + self.BtnSecondTop.gameObject:SetActiveEx(false) + self.BtnSecond.gameObject:SetActiveEx(false) + self.BtnSecondBottom.gameObject:SetActiveEx(false) + self.BtnSecondAll.gameObject:SetActiveEx(false) +end + +function XUiExpeditionComboTips:RegisterBtnEvent() + self:RegisterClickEvent(self.BtnTanchuangCloseBig, function() self:Close() end) +end + +function XUiExpeditionComboTips:InitComboTab(team) + if not team then team = XDataCenter.ExpeditionManager.GetTeam() end + self.ComboList = team:GetAllCombos() + self.ComboTabDataList = self:InitComboTabDataList() + self:CreateComboTab() +end + +function XUiExpeditionComboTips:InitComboTabDataList() + local comboList = {} -- {[BaseComboId] = {[1] = ComboListIndex…}} + local baseComboTypeCfgs = XExpeditionConfig.GetBaseComboTypeConfig() + for _, baseComboType in pairs(baseComboTypeCfgs) do + local baseId = baseComboType.Id + for _, eCombo in pairs(self.ComboList) do + if eCombo:GetComboTypeId() == baseId then + if not comboList[baseId] then comboList[baseId] = {} end + table.insert(comboList[baseId], eCombo) + end + end + end + local dataList = {} + local tabCount = 1 + for baseId, childComboList in pairs(comboList) do + local tabData = { + TabType = TabType.First, + Name = XExpeditionConfig.GetBaseComboTypeNameById(baseId), + TabId = tabCount, + BaseComboId = baseId + } + table.insert(dataList, tabData) + local fatherTabId = tabCount + tabCount = tabCount + 1 + local childNum = #childComboList + local childCount = 0 + local activeChildCount = 0 + for _, childCombo in pairs(childComboList) do + childCount = childCount + 1 + local childTabData = { + Name = childCombo:GetName(), + TabId = tabCount, + FatherTabId = fatherTabId, + ComboId = childCombo:GetComboId(), + Combo = childCombo, + IsActive = childCombo:GetComboActive() + } + if childNum == 1 then + childTabData.TabType = TabType.SecondAll + elseif childNum > 1 and childCount == 1 then + childTabData.TabType = TabType.SecondTop + elseif childNum > 1 and childCount < childNum then + childTabData.TabType = TabType.Second + elseif childNum > 1 and childCount == childNum then + childTabData.TabType = TabType.SecondBottom + end + table.insert(dataList, childTabData) + tabCount = tabCount + 1 + if childCombo:GetComboActive() then activeChildCount = activeChildCount + 1 end + end + tabData.ChildCount = childCount + tabData.ActiveChildCount = activeChildCount + end + return dataList +end + +function XUiExpeditionComboTips:CreateComboTab() + self.TabList = {} + self.FirstTabList = {} + self.ChildTabList = {} + self.BtnList = {} + for i = 1, #self.ComboTabDataList do + local data = self.ComboTabDataList[i] + local btnPrefab = CS.UnityEngine.Object.Instantiate(self[data.TabType].gameObject) + btnPrefab.transform:SetParent(self.BtnContent.transform, false) + self.TabList[i] = XUiExpeditionComboTipsTab.New(btnPrefab, self, i, data, + function(index, tabType, isSelect) self:OnTabClick(index, tabType, isSelect) end) + btnPrefab.gameObject:SetActiveEx(data.TabType == TabType.First) + self.BtnList[i] = btnPrefab:GetComponent("XUiButton") + if data.TabType == TabType.First then + self.FirstTabList[data.BaseComboId] = i + end + if data.TabType ~= TabType.First then + self.BtnList[i].SubGroupIndex = data.FatherTabId + self.ChildTabList[data.ComboId] = i + end + self.BtnList[i]:SetButtonState(UiButtonState.Normal) + end + self.BtnContent:Init(self.BtnList, function(index) self.TabList[index]:OnClick() end) +end + +function XUiExpeditionComboTips:RefreshComboList(childComboData) + self.ItemPanel:UpdateData(childComboData) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/ComboList/XUiExpeditionComboTipsItem.lua b/Resources/Scripts/XUi/XUiExpedition/ComboList/XUiExpeditionComboTipsItem.lua new file mode 100644 index 00000000..b71bacec --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/ComboList/XUiExpeditionComboTipsItem.lua @@ -0,0 +1,37 @@ +--虚像地平线羁绊组合详细页面: 羁绊详细项控件 +local XUiExpeditionComboTipsItem = XClass(nil, "XUiExpeditionComboTipsItem") + +local TextGroup = { + Effect = 0, -- 效果描述 + Condition = 1, -- 条件描述 + Title = 2 -- 标题描述 + } +function XUiExpeditionComboTipsItem:Ctor() + +end + +function XUiExpeditionComboTipsItem:Init(ui, rootUi) + self.Transform = ui.transform + self.GameObject = ui.gameObject + XTool.InitUiObject(self) + self.RootUi = rootUi +end + +function XUiExpeditionComboTipsItem:RefreshDatas(phaseCombo, eCombo, index) + self.ECombo = eCombo + self.PhaseCombo = phaseCombo + self.IsActive = eCombo:GetComboActive() and eCombo:GetPhase() == index + self.Normal.gameObject:SetActiveEx(not self.IsActive) + self.Active.gameObject:SetActiveEx(self.IsActive) + if self.IsActive then + self.TxtTitleActive.text = CS.XTextManager.GetText("ExpeditionComboTipsPhaseTitle", index) + self.TxtEffectActive.text = self.ECombo:GetPhaseComboEffectDes(index) + self.TxtConditionActive.text = self.ECombo:GetPhaseComboConditionDes(index) + else + self.TxtTitleNormal.text = CS.XTextManager.GetText("ExpeditionComboTipsPhaseTitle", index) + self.TxtEffectNormal.text = self.ECombo:GetPhaseComboEffectDes(index) + self.TxtConditionNormal.text = self.ECombo:GetPhaseComboConditionDes(index) + end +end + +return XUiExpeditionComboTipsItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/ComboList/XUiExpeditionComboTipsItemPanel.lua b/Resources/Scripts/XUi/XUiExpedition/ComboList/XUiExpeditionComboTipsItemPanel.lua new file mode 100644 index 00000000..a255e4f2 --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/ComboList/XUiExpeditionComboTipsItemPanel.lua @@ -0,0 +1,80 @@ +--虚像地平线羁绊展示页面:羁绊列表控件 +local XUiExpeditionComboTipsItemPanel = XClass(nil, "XUiExpeditionComboTipsItemPanel") +local XUiExpeditionComboTipsItem = require("XUi/XUiExpedition/ComboList/XUiExpeditionComboTipsItem") +local XUiExpeditionComboTipsHeadIcon = require("XUi/XUiExpedition/ComboList/XUiEXpeditionComboTipsHeadIcon") +function XUiExpeditionComboTipsItemPanel:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + self.GridBuff.gameObject:SetActiveEx(false) + self:InitDynamicTable() + self.RoleTemplate.gameObject:SetActiveEx(false) +end + +function XUiExpeditionComboTipsItemPanel:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelBufftList.gameObject) + self.DynamicTable:SetProxy(XUiExpeditionComboTipsItem) + self.DynamicTable:SetDelegate(self) +end + +--动态列表事件 +function XUiExpeditionComboTipsItemPanel:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(grid.DynamicGrid.gameObject, self.RootUi) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + if self.ComboList and self.ComboList[index] then + grid:RefreshDatas(self.ComboList[index], self.ECombo, index) + end + end +end + +function XUiExpeditionComboTipsItemPanel:UpdateData(eCombo) + self.ECombo = eCombo + self.ComboList = eCombo:GetPhaseCombo() + self.DynamicTable:SetDataSource(self.ComboList) + self.DynamicTable:ReloadDataASync(1) + self:UpdateEComboStatus() +end + +function XUiExpeditionComboTipsItemPanel:UpdateEComboStatus() + self:ResetReference() + if not self.ECombo then return end + self.TxtName.text = self.ECombo:GetName() + self.RImgIcon:SetRawImage(self.ECombo:GetIconPath()) + local active = self.ECombo:GetComboActive() + self.On.gameObject:SetActiveEx(active) + self.Off.gameObject:SetActiveEx(not active) + if active then + self.TextLevelNumber.text = CS.XTextManager.GetText("ExpeditionComboTipsPhaseTitle", self.ECombo:GetPhase()) + end + local referenceList = self.ECombo:GetDisplayReferenceList() + local sampleRank = self.ECombo:GetConditionLevel(self.ECombo:GetPhase()) + if not self.RoleList then self.RoleList = {} end + local count = #referenceList + for i = 1, count do + if not self.RoleList[i] then + local prefab = CS.UnityEngine.Object.Instantiate(self.RoleTemplate.gameObject) + prefab.transform:SetParent(self.RolePanel.transform, false) + self.RoleList[i] = XUiExpeditionComboTipsHeadIcon.New(prefab) + end + self.RoleList[i]:Show() + self.RoleList[i]:RefreshData(referenceList[i], sampleRank) + end + for i = count + 1, #self.RoleList do + if self.RoleList[i] then + self.RoleList[i]:Hide() + end + end +end + +function XUiExpeditionComboTipsItemPanel:ResetReference() + if not self.RoleList then return end + for i = 1, #self.RoleList do + if self.RoleList[i] then + self.RoleList[i]:Hide() + end + end +end + +return XUiExpeditionComboTipsItemPanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/ComboList/XUiExpeditionComboTipsTab.lua b/Resources/Scripts/XUi/XUiExpedition/ComboList/XUiExpeditionComboTipsTab.lua new file mode 100644 index 00000000..0b22361a --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/ComboList/XUiExpeditionComboTipsTab.lua @@ -0,0 +1,35 @@ +--虚像地平线羁绊组合详细页面:页签控件 +local XUiExpeditionComboTipsTab = XClass(nil, "XUiExpeditionComboTipsTab") +local UiButtonState = CS.UiButtonState +function XUiExpeditionComboTipsTab:Ctor(ui, rootUi, index, tabData, onClickCallBack) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self.Button = self.GameObject:GetComponent("XUiButton") + if tabData.TabType ~= "BtnFirstHasSnd" then + self.BtnType = XDataCenter.ExpeditionManager.ComboBtnType.ChildComboType + self.Button:ShowTag(tabData.IsActive) + self.Button:SetNameByGroup(0, tabData.Name) + else + self.BtnType = XDataCenter.ExpeditionManager.ComboBtnType.BaseComboType + self.Button:SetNameByGroup(0, tabData.Name) + self.Button:SetNameByGroup(1, string.format("%d/%d", tabData.ActiveChildCount, tabData.ChildCount)) + end + if self.BtnType == XDataCenter.ExpeditionManager.ComboBtnType.ChildComboType then + self.ECombo = tabData.Combo + end + self.OnClickCallBack = onClickCallBack + self.Index = index +end + +function XUiExpeditionComboTipsTab:OnClick() + if self.BtnType == XDataCenter.ExpeditionManager.ComboBtnType.ChildComboType then + self:RefreshComboList() + end +end + +function XUiExpeditionComboTipsTab:RefreshComboList() + self.RootUi:RefreshComboList(self.ECombo) +end + +return XUiExpeditionComboTipsTab \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/MainPage/ChapterBuff/XUiExpeditionBuffTips.lua b/Resources/Scripts/XUi/XUiExpedition/MainPage/ChapterBuff/XUiExpeditionBuffTips.lua new file mode 100644 index 00000000..c146cda6 --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/MainPage/ChapterBuff/XUiExpeditionBuffTips.lua @@ -0,0 +1,72 @@ +--虚像地平线词缀展示页面 +local XUiExpeditionBuffTips = XLuaUiManager.Register(XLuaUi, "UiExpeditionBuffTips") +local XUiExpeditionBuffTipsItem = require("XUi/XUiExpedition/MainPage/ChapterBuff/XUiExpeditionBuffTipsItem") +function XUiExpeditionBuffTips:OnAwake() + XTool.InitUiObject(self) + self.GridBuff.gameObject:SetActiveEx(false) + self:RegisterUiButtonEvent() +end + +function XUiExpeditionBuffTips:OnStart(type, dataList) + self.Type = type + self.DataList = dataList + self.StageTitle.gameObject:SetActiveEx(self.Type == XDataCenter.ExpeditionManager.BuffTipsType.StageBuff) + self.GlobleTitle.gameObject:SetActiveEx(self.Type == XDataCenter.ExpeditionManager.BuffTipsType.GlobalBuff) + if self.Type == XDataCenter.ExpeditionManager.BuffTipsType.GlobalBuff then + self:RefreshGlobalType() + elseif self.Type == XDataCenter.ExpeditionManager.BuffTipsType.StageBuff then + self:RefreshStageType() + elseif self.Type == XDataCenter.ExpeditionManager.BuffTipsType.Skill then + self:RefreshSkillType() + end +end + +function XUiExpeditionBuffTips:RegisterUiButtonEvent() + self.BtnClose.CallBack = function() self:OnBtnCloseClick() end +end + +function XUiExpeditionBuffTips:OnBtnCloseClick() + self:Close() +end + +function XUiExpeditionBuffTips:RefreshGlobalType() + for _, globalCfg in pairs(self.DataList) do + local prefab = CS.UnityEngine.Object.Instantiate(self.GridBuff.gameObject) + prefab.transform:SetParent(self.PanelContent.transform, false) + local tipItem = XUiExpeditionBuffTipsItem.New(prefab, self) + local tipData = { + Type = self.Type, + Cfg = globalCfg, + } + tipItem:RefreshData(tipData) + tipItem.GameObject:SetActiveEx(true) + end +end + +function XUiExpeditionBuffTips:RefreshStageType() + for _, stageBuffCfg in pairs(self.DataList) do + local prefab = CS.UnityEngine.Object.Instantiate(self.GridBuff.gameObject) + prefab.transform:SetParent(self.PanelContent.transform, false) + local tipItem = XUiExpeditionBuffTipsItem.New(prefab, self) + local tipData = { + Type = self.Type, + Cfg = stageBuffCfg, + } + tipItem:RefreshData(tipData) + tipItem.GameObject:SetActiveEx(true) + end +end + +function XUiExpeditionBuffTips:RefreshSkillType() + for _, skillInfo in pairs(self.DataList) do + local prefab = CS.UnityEngine.Object.Instantiate(self.GridBuff.gameObject) + prefab.transform:SetParent(self.PanelContent.transform, false) + local tipItem = XUiExpeditionBuffTipsItem.New(prefab, self) + local tipData = { + Type = self.Type, + Cfg = skillInfo, + } + tipItem:RefreshData(tipData) + tipItem.GameObject:SetActiveEx(true) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/MainPage/ChapterBuff/XUiExpeditionBuffTipsItem.lua b/Resources/Scripts/XUi/XUiExpedition/MainPage/ChapterBuff/XUiExpeditionBuffTipsItem.lua new file mode 100644 index 00000000..94d48b85 --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/MainPage/ChapterBuff/XUiExpeditionBuffTipsItem.lua @@ -0,0 +1,39 @@ +--虚像地平线词缀展示界面:词缀详细显示控件 +local XUiExpeditionBuffTipsItem = XClass(nil, "XUiExpeditionBuffTipsItem") +function XUiExpeditionBuffTipsItem:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiExpeditionBuffTipsItem:RefreshData(data) + self.Cfg = data.Cfg + if data.Type == XDataCenter.ExpeditionManager.BuffTipsType.GlobalBuff then + self:RefreshGlobalType() + elseif data.Type == XDataCenter.ExpeditionManager.BuffTipsType.StageBuff then + self:RefreshStageType() + elseif data.Type == XDataCenter.ExpeditionManager.BuffTipsType.Skill then + self:RefreshSkillType() + end +end + +function XUiExpeditionBuffTipsItem:RefreshGlobalType() + local comboCfg = XExpeditionConfig.GetComboById(self.Cfg.Id) + self.RImgIcon:SetRawImage(self.Cfg.IconPath) + self.TxtName.text = self.Cfg.Name + self.TxtDesc.text = comboCfg.EffectDescription +end + +function XUiExpeditionBuffTipsItem:RefreshStageType() + self.RImgIcon:SetRawImage(self.Cfg.Icon) + self.TxtName.text = self.Cfg.Name + self.TxtDesc.text = self.Cfg.Description +end + +function XUiExpeditionBuffTipsItem:RefreshSkillType() + self.RImgIcon:SetRawImage(self.Cfg.IconPath) + self.TxtName.text = self.Cfg.SkillInfo.Name + self.TxtDesc.text = self.Cfg.SkillInfo.Intro +end + +return XUiExpeditionBuffTipsItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/MainPage/ChapterBuff/XUiGlobalComboIcon.lua b/Resources/Scripts/XUi/XUiExpedition/MainPage/ChapterBuff/XUiGlobalComboIcon.lua new file mode 100644 index 00000000..5d7d816b --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/MainPage/ChapterBuff/XUiGlobalComboIcon.lua @@ -0,0 +1,17 @@ +--虚像地平线全局增益图标控件 +local XUiGlobalComboIcon = XClass(nil, "XUiGlobalComboIcon") + +function XUiGlobalComboIcon:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self.RawBuffIcon = self.Transform:Find("RawBuffIcon"):GetComponent("RawImage") +end + +function XUiGlobalComboIcon:RefreshData(comboConfig) + self.GlobalComboId = comboConfig.Id + self.GlobalComboConfig = comboConfig + self.RawBuffIcon:SetRawImage(comboConfig.IconPath) +end + +return XUiGlobalComboIcon \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/MainPage/StageDetail/XUiExpeditionStageBattleDetail.lua b/Resources/Scripts/XUi/XUiExpedition/MainPage/StageDetail/XUiExpeditionStageBattleDetail.lua new file mode 100644 index 00000000..66de86f9 --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/MainPage/StageDetail/XUiExpeditionStageBattleDetail.lua @@ -0,0 +1,140 @@ +--虚像地平线战斗关关卡组件 +local XUiExpeditionStageBattleDetail = {} +local XUiExpeditionStageBuffIcon = require("XUi/XUiExpedition/MainPage/StageDetail/XUiExpeditionStageBuffIcon") + +function XUiExpeditionStageBattleDetail.OnEnable(component) + +end + +function XUiExpeditionStageBattleDetail.RefreshData(component, stageData) + +end + +function XUiExpeditionStageBattleDetail.OnDisable(component) + +end + +function XUiExpeditionStageBattleDetail.OnDestroy(component) + +end + +function XUiExpeditionStageBattleDetail.SetSelect(component) + component.ImgSelect.gameObject:SetActiveEx(true) +end + +function XUiExpeditionStageBattleDetail.CancelSelect(component) + component.ImgSelect.gameObject:SetActiveEx(false) +end + +function XUiExpeditionStageBattleDetail.OnClick(component) + local stageDetail = component.RootUi:FindChildUiObj("UiExpeditionStageDetail") + if stageDetail then stageDetail:RefreshChapter(component) end + component.RootUi:OpenOneChildUi("UiExpeditionStageDetail", component) +end + +function XUiExpeditionStageBattleDetail.SetDropList(eStage, detailUi) + if not detailUi.GridList then detailUi.GridList = {} end + detailUi.ImgFirstReward.gameObject:SetActiveEx(detailUi.EStage:GetIsPass()) + if eStage:GetIsPass() then + for j = 1, #detailUi.GridList do + detailUi.GridList[j].GameObject:SetActiveEx(false) + end + return + end + local rewardId = eStage:GetFirstRewardId() + if not rewardId or rewardId == 0 then + for j = 1, #detailUi.GridList do + detailUi.GridList[j].GameObject:SetActiveEx(false) + end + return + end + local rewards = XRewardManager.GetRewardList(rewardId) or XRewardManager.GetRewardListNotCount(rewardId) + if rewards then + for i, item in ipairs(rewards) do + local grid + if detailUi.GridList[i] then + grid = detailUi.GridList[i] + else + local ui = CS.UnityEngine.Object.Instantiate(detailUi.GridCommon) + grid = XUiGridCommon.New(detailUi.RootUi, ui) + grid.Transform:SetParent(detailUi.PanelDropContent, false) + detailUi.GridList[i] = grid + end + grid:Refresh(item) + grid.GameObject:SetActiveEx(true) + end + end + local rewardsCount = 0 + if rewards then + rewardsCount = #rewards + end + for j = 1, #detailUi.GridList do + if j > rewardsCount then + detailUi.GridList[j].GameObject:SetActiveEx(false) + end + end +end + +function XUiExpeditionStageBattleDetail.SetBuffList(component, ui) + if not ui.BuffList then ui.BuffList = {} end + local buffList = component.EStage:GetStageEvents() + ui.GridBuff.gameObject:SetActiveEx(false) + ui.StageBuffCfgList = {} + for i = 1, #buffList do + if not ui.BuffList[i] then + local prefab = CS.UnityEngine.GameObject.Instantiate(ui.GridBuff.gameObject) + prefab.transform:SetParent(ui.PanelBuffContent, false) + ui.BuffList[i] = XUiExpeditionStageBuffIcon.New(prefab, component.RootUi) + end + end + for i = 1, #ui.BuffList do + if buffList[i] then + ui.BuffList[i]:RefreshData(buffList[i]) + ui.BuffList[i]:Show() + table.insert(ui.StageBuffCfgList, buffList[i]) + else + ui.BuffList[i]:Hide() + end + end + for i = 1, #buffList do + ui.BuffList[i].BtnClick.CallBack = function() + local BuffTipsType = XDataCenter.ExpeditionManager.BuffTipsType.StageBuff + XLuaUiManager.Open("UiExpeditionBuffTips", BuffTipsType, ui.StageBuffCfgList) + end + end + ui.ImgBattleBuffEmpty.gameObject:SetActiveEx(#buffList == 0) +end + +function XUiExpeditionStageBattleDetail.OnUiEnable(component, ui) + if not component.Ui or component.Ui ~= ui then component.Ui = ui end + local eStage = component.EStage + ui.PanelStory.gameObject:SetActiveEx(false) + ui.Panellist.gameObject:SetActiveEx(true) + ui.PanelDropList.gameObject:SetActiveEx(true) + ui.PanelEndless.gameObject:SetActiveEx(false) + ui.TxtTitle.text = eStage:GetStageName() + ui.TxtBattleRecruit.text = eStage:GetDrawTimesRewardStr() + for i = 1, 3 do + ui["GridStar" .. i].gameObject:SetActiveEx(false) + end + local stageTarget = eStage:GetStageTargetDesc() + for i = 1, 2 do + if stageTarget[i] then + ui["GridStar" .. i].gameObject:SetActiveEx(true) + ui["TxtStarActive" .. i].text = stageTarget[i] + end + end + ui.TxtATNums.text = 0 + XUiExpeditionStageBattleDetail.SetDropList(eStage, ui) + XUiExpeditionStageBattleDetail.SetBuffList(component, ui) + ui:PlayAnimation("PanellistEnable") + CsXUiHelper.RegisterClickEvent(ui.BattleEnter, function() ui:OnEnterBattle() end) + CsXUiHelper.RegisterClickEvent(ui.BtnClose, function() ui:Hide() end) +end + +function XUiExpeditionStageBattleDetail.OnUiDisable(component, ui) + component.ImgSelect.gameObject:SetActiveEx(false) + component.ChapterComponent:CancelSelect() +end + +return XUiExpeditionStageBattleDetail \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/MainPage/StageDetail/XUiExpeditionStageBuffIcon.lua b/Resources/Scripts/XUi/XUiExpedition/MainPage/StageDetail/XUiExpeditionStageBuffIcon.lua new file mode 100644 index 00000000..f14bcc64 --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/MainPage/StageDetail/XUiExpeditionStageBuffIcon.lua @@ -0,0 +1,23 @@ +--虚像地平线关卡详细页面:关卡增益图标控件 +local XUiExpeditionStageBuffIcon = XClass(nil, "XUiExpeditionStageBuffIcon") + +function XUiExpeditionStageBuffIcon:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) +end + +function XUiExpeditionStageBuffIcon:RefreshData(buffCfg) + self.RImgIcon:SetRawImage(buffCfg.Icon) +end + +function XUiExpeditionStageBuffIcon:Show() + self.GameObject:SetActiveEx(true) +end + +function XUiExpeditionStageBuffIcon:Hide() + self.GameObject:SetActiveEx(false) +end + +return XUiExpeditionStageBuffIcon \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/MainPage/StageDetail/XUiExpeditionStageInfinityDetail.lua b/Resources/Scripts/XUi/XUiExpedition/MainPage/StageDetail/XUiExpeditionStageInfinityDetail.lua new file mode 100644 index 00000000..347864cd --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/MainPage/StageDetail/XUiExpeditionStageInfinityDetail.lua @@ -0,0 +1,99 @@ +-- 虚拟地平线无尽关显示组件 +local XUiExpeditionStageInfinityDetail = {} + +function XUiExpeditionStageInfinityDetail.OnEnable(component) + +end + +function XUiExpeditionStageInfinityDetail.RefreshData(component, stageData) + +end + +function XUiExpeditionStageInfinityDetail.OnDisable(component) + +end + +function XUiExpeditionStageInfinityDetail.OnUiDisable(component, ui) + component.ImgSelect.gameObject:SetActiveEx(false) + component.ChapterComponent:CancelSelect() +end + +function XUiExpeditionStageInfinityDetail.OnDestroy(component) + +end + +function XUiExpeditionStageInfinityDetail.SetSelect(component) + component.ImgSelect.gameObject:SetActiveEx(true) +end + +function XUiExpeditionStageInfinityDetail.CancelSelect(component) + component.ImgSelect.gameObject:SetActiveEx(false) +end + +function XUiExpeditionStageInfinityDetail.OnClick(component) + local stageDetail = component.RootUi:FindChildUiObj("UiExpeditionStageDetail") + if stageDetail then stageDetail:RefreshChapter(component) end + component.RootUi:OpenOneChildUi("UiExpeditionStageDetail", component) +end + +function XUiExpeditionStageInfinityDetail.SetBuffList(component, ui) + if not ui.BuffList then ui.BuffList = {} end + local buffList = component.EStage:GetStageEvents() + ui.GridBuff.gameObject:SetActiveEx(false) + ui.StageBuffCfgList = {} + for i = 1, #buffList do + if not ui.BuffList[i] then + local prefab = CS.UnityEngine.GameObject.Instantiate(ui.GridBuff.gameObject) + prefab.transform:SetParent(ui.PanelBuffContent, false) + ui.BuffList[i] = XUiExpeditionStageBuffIcon.New(prefab, component.RootUi) + end + end + for i = 1, #ui.BuffList do + if buffList[i] then + ui.BuffList[i]:RefreshData(buffList[i]) + ui.BuffList[i]:Show() + table.insert(ui.StageBuffCfgList, buffList[i]) + else + ui.BuffList[i]:Hide() + end + end + for i = 1, #buffList do + ui.BuffList[i].BtnClick.CallBack = function() + local BuffTipsType = XDataCenter.ExpeditionManager.BuffTipsType.StageBuff + XLuaUiManager.Open("UiExpeditionBuffTips", BuffTipsType, ui.StageBuffCfgList) + end + end + ui.ImgBattleBuffEmpty.gameObject:SetActiveEx(#buffList == 0) +end + +function XUiExpeditionStageInfinityDetail.OnUiEnable(component, ui) + if not component.Ui or component.Ui ~= ui then component.Ui = ui end + local eStage = component.EStage + ui.PanelStory.gameObject:SetActiveEx(false) + ui.Panellist.gameObject:SetActiveEx(true) + ui.PanelDropList.gameObject:SetActiveEx(false) + ui.PanelEndless.gameObject:SetActiveEx(true) + ui.TxtTitle.text = eStage:GetStageName() + for i = 1, 3 do + ui["GridStar" .. i].gameObject:SetActiveEx(false) + end + local stageTarget = eStage:GetStageTargetDesc() + for i = 1, 2 do + if stageTarget[i] then + ui["GridStar" .. i].gameObject:SetActiveEx(true) + ui["TxtStarActive" .. i].text = stageTarget[i] + end + end + ui.TxtATNums.text = 0 + XUiExpeditionStageInfinityDetail.SetEndlessWave(ui) + XUiExpeditionStageInfinityDetail.SetBuffList(component, ui) + ui:PlayAnimation("PanellistEnable") + CsXUiHelper.RegisterClickEvent(ui.BattleEnter, function() ui:OnEnterBattle() end) + CsXUiHelper.RegisterClickEvent(ui.BtnClose, function() ui:Hide() end) +end + +function XUiExpeditionStageInfinityDetail.SetEndlessWave(ui) + ui.TxtEndlessWave.text = CS.XTextManager.GetText("ExpeditionInfiDetail", XDataCenter.ExpeditionManager.GetWave()) +end + +return XUiExpeditionStageInfinityDetail \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/MainPage/StageDetail/XUiExpeditionStageStoryDetail.lua b/Resources/Scripts/XUi/XUiExpedition/MainPage/StageDetail/XUiExpeditionStageStoryDetail.lua new file mode 100644 index 00000000..428973ed --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/MainPage/StageDetail/XUiExpeditionStageStoryDetail.lua @@ -0,0 +1,49 @@ +--虚像地平线准备关关卡组件 +local XUiExpeditionStageStoryDetail = {} +function XUiExpeditionStageStoryDetail.OnEnable(component) + +end + +function XUiExpeditionStageStoryDetail.RefreshData(component, stageData) + +end + +function XUiExpeditionStageStoryDetail.OnDisable(component) + +end + +function XUiExpeditionStageStoryDetail.OnDestroy(component) + +end + +function XUiExpeditionStageStoryDetail.SetSelect(component) + component.ImgSelect.gameObject:SetActiveEx(true) +end + +function XUiExpeditionStageStoryDetail.CancelSelect(component) + component.ImgSelect.gameObject:SetActiveEx(false) +end + +function XUiExpeditionStageStoryDetail.OnClick(component) + local stageDetail = component.RootUi:FindChildUiObj("UiExpeditionStageDetail") + if stageDetail then stageDetail:RefreshChapter(component) end + component.RootUi:OpenOneChildUi("UiExpeditionStageDetail", component) +end + +function XUiExpeditionStageStoryDetail.OnUiEnable(component, ui) + local eStage = component.EStage + ui.PanelStory.gameObject:SetActiveEx(true) + ui.Panellist.gameObject:SetActiveEx(false) + ui.TxtStoryTitle.text = eStage:GetStageName() + ui.TxtStoryDes.text = eStage:GetStageDes() + ui.TxtStoryRecruit.text = eStage:GetDrawTimesRewardStr() + ui:PlayAnimation("PanelStoryEnable") + CsXUiHelper.RegisterClickEvent(ui.BtnClose, function() ui:Hide() end) + CsXUiHelper.RegisterClickEvent(ui.StoryEnter, function() ui:OnStoryEnterClick() end) +end + +function XUiExpeditionStageStoryDetail.OnUiDisable(component, ui) + component.ImgSelect.gameObject:SetActiveEx(false) + component.ChapterComponent:CancelSelect() +end +return XUiExpeditionStageStoryDetail \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/MainPage/XUiExpeditionChapter.lua b/Resources/Scripts/XUi/XUiExpedition/MainPage/XUiExpeditionChapter.lua new file mode 100644 index 00000000..079af2a1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/MainPage/XUiExpeditionChapter.lua @@ -0,0 +1,40 @@ +-- 虚像地平线章节控件 +local XUiExpeditionChapter = XClass(nil, "XUiExpeditionChapter") +local XUiExpeditionChapterComponent = require("XUi/XUiExpedition/MainPage/XUiExpeditionChapterComponent") +function XUiExpeditionChapter:Ctor(rootUi) + self.RootUi = rootUi + self.Chapter = XDataCenter.ExpeditionManager.GetCurrentChapter() +end +--============= +--显示章节 +--@param difficulty:难度 +--============= +function XUiExpeditionChapter:Show(difficulty) + if (not difficulty) or (not self.Chapter) then return end + local chapterName = "Chapter" .. difficulty + if not self[chapterName] then + local chapterPrefab + if difficulty == XDataCenter.ExpeditionManager.StageDifficulty.Normal then + chapterPrefab = self.RootUi.PanelStageListNormal.transform:LoadPrefab(self.Chapter:GetChapterPrefabByDifficulty(difficulty)) + else + chapterPrefab = self.RootUi.PanelStageListNightmare.transform:LoadPrefab(self.Chapter:GetChapterPrefabByDifficulty(difficulty)) + end + if chapterPrefab then + self[chapterName] = XUiExpeditionChapterComponent.New(self.RootUi, chapterPrefab, difficulty) + self[chapterName]:RefreshData(difficulty) + if self.CurrentComponent then self.CurrentComponent:Hide() end + self.CurrentComponent = self[chapterName] + self.CurrentComponent:Show() + end + else + if self.CurrentComponent and self.CurrentComponent ~= self[chapterName] then self.CurrentComponent:Hide() end + self.CurrentComponent = self[chapterName] + self.CurrentComponent:Show() + end + self.CurrentComponent:RefreshData() + self.RootUi:ChangeBg(self.Chapter:GetStageBgByDifficult(difficulty)) + self.RootUi:ChangeBgFx(self.Chapter:GetChapterBgFxByDifficult(difficulty)) + self.RootUi:ChangeRewardIcon(self.Chapter:GetRewardIconByDifficult(difficulty)) +end + +return XUiExpeditionChapter \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/MainPage/XUiExpeditionChapterComponent.lua b/Resources/Scripts/XUi/XUiExpedition/MainPage/XUiExpeditionChapterComponent.lua new file mode 100644 index 00000000..5a83c592 --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/MainPage/XUiExpeditionChapterComponent.lua @@ -0,0 +1,207 @@ +local XUiExpeditionStageDetailComponent = require("XUi/XUiExpedition/MainPage/XUiExpeditionStageDetailComponent") +--虚像地平线章节关卡组件 +local XUiExpeditionChapterComponent = XClass(nil, "XUiExpeditionChapterComponent") +function XUiExpeditionChapterComponent:Ctor(rootUi, ui, difficulty) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RectTransform = self.Transform:GetComponent("RectTransform") + self.GridStageList = {} + self.LineList = {} + self.Difficulty = difficulty + self:InitUi() + CsXUiHelper.RegisterClickEvent(self.ScrollRect, handler(self, self.CancelSelect)) + local dragProxy = self.ScrollRect.gameObject:AddComponent(typeof(CS.XUguiDragProxy)) + dragProxy:RegisterHandler(handler(self, self.OnDragProxy)) +end + +function XUiExpeditionChapterComponent:OnDragProxy(dragType) + if dragType == 0 then + self:OnScrollRectBeginDrag() + elseif dragType == 2 then + self:OnScrollRectEndDrag() + end +end + +function XUiExpeditionChapterComponent:OnScrollRectBeginDrag() + if self:CancelSelect() then + self.ScrollRect.enabled = false + end +end + +function XUiExpeditionChapterComponent:OnScrollRectEndDrag() + self.ScrollRect.enabled = true +end + +-- 返回滚动容器是否动画回弹 +function XUiExpeditionChapterComponent:CancelSelect() + if not self.StageSelected then + return false + end + self.StageSelected:CancelSelect() + self.ScrollRect.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Elastic + self.StageSelected = nil + return self:ScrollRectRollBack() +end + +function XUiExpeditionChapterComponent:InitUi() + self.PanelStageContent = XUiHelper.TryGetComponent(self.Transform, "PaneStageList/ViewPort/PanelStageContent", "RectTransform") + self.BoundSizeFitter = XUiHelper.TryGetComponent(self.Transform, "PaneStageList/ViewPort/PanelStageContent", "XBoundSizeFitter") + self.ScrollRect = XUiHelper.TryGetComponent(self.Transform, "PaneStageList", "ScrollRect") + -- 连线 + for i = 1, self.PanelStageContent.transform.childCount do + if not self.LineList[i] then + local line = self.PanelStageContent.transform:Find("Line" .. i) + self.LineList[i] = not XTool.UObjIsNil(line) and line + end + end +end + +function XUiExpeditionChapterComponent:ScrollRectRollBack() + -- 滚动容器回弹 + local width = self.RectTransform.rect.width + local innerWidth = self.PanelStageContent.rect.width + innerWidth = innerWidth < width and width or innerWidth + local diff = innerWidth - width + local tarPosX + if self.PanelStageContent.localPosition.x < -width / 2 - diff then + tarPosX = -width / 2 - diff + elseif self.PanelStageContent.localPosition.x > -width / 2 then + tarPosX = -width / 2 + else + self.ScrollRect.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Elastic + return false + end + + self:PlayScrollViewMoveBack(tarPosX) + return true +end + +function XUiExpeditionChapterComponent:PlayScrollViewMoveBack(tarPosX) + local tarPos = self.PanelStageContent.localPosition + tarPos.x = tarPosX + XLuaUiManager.SetMask(true) + + XUiHelper.DoMove(self.PanelStageContent, tarPos, XDataCenter.FubenMainLineManager.UiGridChapterMoveDuration, XUiHelper.EaseType.Sin, function() + self.ScrollRect.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Elastic + XLuaUiManager.SetMask(false) + end) +end + +function XUiExpeditionChapterComponent:GoToLastStage() + local currentIndex = self.Chapter:GetCurrentIndexByDifficulty(self.Difficulty) + local grid = self.GridStageList[currentIndex] + if not grid then + return + end + local gridTf = grid.Parent.gameObject:GetComponent("RectTransform") + local posX = gridTf.localPosition.x - self.RectTransform.rect.width / 2 + self.ScrollRect.horizontalNormalizedPosition = 0 + self.ScrollRect.horizontalNormalizedPosition = posX / (1 * self.ScrollRect.content.rect.width - self.RectTransform.rect.width) +end + +function XUiExpeditionChapterComponent:RefreshData() + if not self.Chapter then self.Chapter = XDataCenter.ExpeditionManager.GetCurrentChapter() end + self.Stages = self.Chapter:GetStagesByDifficulty(self.Difficulty) + self:SetStageList() + self:GoToLastStage() +end + +function XUiExpeditionChapterComponent:SetStageList() + if not self.Stages then + XLog.Error("虚像地平线章节数据为空!章节Id : " .. tostring(self.ChapterId)) + return + end + for i = 1, #self.Stages do + if self.Stages[i]:GetIsUnlock() then + local grid = self.GridStageList[i] + if not grid then + --没有关卡预制体,则加载预制体 + grid = self:CreateNewStageGrid(self.Stages[i], i) + self.GridStageList[i] = grid + end + grid:RefreshData(self.Stages[i]) + grid.Transform.parent.gameObject:SetActive(true) + self:SetLineActive(i, true) + end + end + local activeStageCount = #self.GridStageList + for i = activeStageCount + 1, self.PanelStageContent.transform.childCount do + local parent = self.PanelStageContent.transform:Find("Stage" .. i) + if parent then + parent.gameObject:SetActive(false) + end + self:SetLineActive(i, false) + end + -- 移动至ListView正确的位置 + if self.BoundSizeFitter then + self.BoundSizeFitter:SetLayoutHorizontal() + end +end + +-- 创建新关卡预制体 +function XUiExpeditionChapterComponent:CreateNewStageGrid(eStage, stageIndex) + local parent = self.PanelStageContent.transform:Find(string.format("Stage%d", stageIndex)) + if not parent then + XLog.Error("XUiExpeditionChapterComponent:CreateNewStageGrid error: prefab not found a child name " .. string.format("Stage%d", stageIndex)) + return + end + local prefab = parent:LoadPrefab(eStage:GetPrefabPath()) + local grid = XUiExpeditionStageDetailComponent.New(self, self.RootUi, prefab, eStage:GetStageType()) + return grid +end + +function XUiExpeditionChapterComponent:SetLineActive(index, active) + local line = self.LineList[index - 1] + if line then + line.gameObject:SetActive(active) + end +end + +function XUiExpeditionChapterComponent:Show() + if self.GameObject.activeSelf == true then return end + self.GameObject:SetActive(true) +end + +function XUiExpeditionChapterComponent:Hide() + if not self.GameObject:Exist() or self.GameObject.activeSelf == false then return end + self.GameObject:SetActive(false) +end + +function XUiExpeditionChapterComponent:PlayScrollViewMove(grid) + -- 动画 + local gridTf = grid.Parent.gameObject:GetComponent("RectTransform") + local diffX = gridTf.localPosition.x + self.PanelStageContent.localPosition.x + if diffX < XDataCenter.FubenMainLineManager.UiGridChapterMoveMinX or diffX > XDataCenter.FubenMainLineManager.UiGridChapterMoveMaxX then + local tarPosX = XDataCenter.FubenMainLineManager.UiGridChapterMoveTargetX - gridTf.localPosition.x + local tarPos = self.PanelStageContent.localPosition + tarPos.x = tarPosX + XLuaUiManager.SetMask(true) + XUiHelper.DoMove(self.PanelStageContent, tarPos, XDataCenter.FubenMainLineManager.UiGridChapterMoveDuration, XUiHelper.EaseType.Sin, function() + XLuaUiManager.SetMask(false) + end) + end +end + +-- 选中一个 stage grid +function XUiExpeditionChapterComponent:ClickStage(stageClick) + local stageSelected = self.StageSelected + if stageSelected and stageSelected.EStage:GetStageId() == stageClick.EStage:GetStageId() then + return false + end + if not stageClick.EStage:GetIsUnlock() then + XUiManager.TipMsg(XDataCenter.FubenManager.GetFubenOpenTips(stageClick.EStage:GetStageId())) + return false + end + if stageSelected then + stageSelected:CancelSelect() + end + stageClick:SetSelect() + -- 滚动容器自由移动 + self.ScrollRect.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Unrestricted + -- 面板移动 + self:PlayScrollViewMove(stageClick) + self.StageSelected = stageClick + return true +end +return XUiExpeditionChapterComponent \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/MainPage/XUiExpeditionMain.lua b/Resources/Scripts/XUi/XUiExpedition/MainPage/XUiExpeditionMain.lua new file mode 100644 index 00000000..e284be76 --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/MainPage/XUiExpeditionMain.lua @@ -0,0 +1,281 @@ +--虚像地平线主界面 +local XUiExpeditionMain = XLuaUiManager.Register(XLuaUi, "UiExpeditionMain") +local XUiExpeditionChapter = require("XUi/XUiExpedition/MainPage/XUiExpeditionChapter") +local XUiGlobalComboIcon = require("XUi/XUiExpedition/MainPage/ChapterBuff/XUiGlobalComboIcon") +function XUiExpeditionMain:OnAwake() + XTool.InitUiObject(self) + XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self.GridBuffIcon.gameObject:SetActiveEx(false) + self:AddListener() + XDataCenter.ExpeditionManager.SetIfBackMain(false) +end + +function XUiExpeditionMain:OnStart() + self:InitPanel() + XDataCenter.ExpeditionManager.GetMyRankingData() +end + +function XUiExpeditionMain:InitPanel() + self:InitChapter() + self:InitGlobalCombo() +end + +function XUiExpeditionMain:OnEnable() + self:OnRefresh() + self.BtnRecruit:ShowReddot(XDataCenter.ExpeditionManager.GetCanRecruit()) + XDataCenter.ExpeditionManager.GetMyRankingData() + XEventManager.AddEventListener(XEventId.EVENT_FUBEN_STAGE_SYNC, self.OnSyncStage, self) +end + +function XUiExpeditionMain:OnDisable() + self:StopTimer() + XEventManager.RemoveEventListener(XEventId.EVENT_FUBEN_STAGE_SYNC, self.OnSyncStage, self) +end + +function XUiExpeditionMain:OnDestroy() + self:StopTimer() + XEventManager.RemoveEventListener(XEventId.EVENT_FUBEN_STAGE_SYNC, self.OnSyncStage, self) +end + +function XUiExpeditionMain:OnGetEvents() + return { XEventId.EVENT_EXPEDITION_RECRUITTIME_REFRESH, XEventId.EVENT_EXPEDITION_ON_GET_CHAPTER_REWARD, XEventId.EVENT_ACTIVITY_ON_RESET, XEventId.EVENT_EXPEDITION_RANKING_REFRESH } +end + +function XUiExpeditionMain:OnNotify(evt, ...) + local args = { ... } + if evt == XEventId.EVENT_EXPEDITION_RECRUITTIME_REFRESH then + self:RefreshRecruitNumber() + elseif evt == XEventId.EVENT_EXPEDITION_ON_GET_CHAPTER_REWARD then + self:OnGetTreasure(args[1], args[2]) + self:RefreshProgress() + elseif evt == XEventId.EVENT_ACTIVITY_ON_RESET then + if args[1] ~= XDataCenter.FubenManager.StageType.Expedition then return end + self:OnActivityReset() + elseif evt == XEventId.EVENT_EXPEDITION_RANKING_REFRESH then + self:RefreshRanking() + end +end + +function XUiExpeditionMain:OnActivityReset() + self:StopTimer() + XLuaUiManager.RunMain() + XUiManager.TipMsg(CS.XTextManager.GetText("ExpeditionOnClose")) +end + +function XUiExpeditionMain:InitChapter() + self.ChapterComponent = XUiExpeditionChapter.New(self) + self:SwitchDifficulty(XDataCenter.ExpeditionManager.StageDifficulty.Normal) +end + +function XUiExpeditionMain:AddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:RegisterClickEvent(self.BtnList, self.OnBtnListClick) + self:RegisterClickEvent(self.BtnRecruit, self.OnBtnRecruitClick) + self:BindHelpBtn(self.BtnHelp, "ExpeditionMainHelp") + self:RegisterClickEvent(self.BtnTreasure, self.OnBtnTreasureClick) + self.BtnBuff.CallBack = function() self:OnBtnBuffClick() end + if self.BtnNightmareStage then + self.BtnNightmareStage.CallBack = function() self:OnBtnNightMareClick() end + end + if self.BtnNormalStage then + self.BtnNormalStage.CallBack = function() self:OnBtnNormalClick() end + end + if self.BtnRanking then + self.BtnRanking.CallBack = function() self:OnBtnRankingClick() end + end +end + +function XUiExpeditionMain:OnBtnNormalClick() + self:SwitchDifficulty(XDataCenter.ExpeditionManager.StageDifficulty.Normal) +end + +function XUiExpeditionMain:OnBtnNightMareClick() + self:SwitchDifficulty(XDataCenter.ExpeditionManager.StageDifficulty.NightMare) +end + +function XUiExpeditionMain:OnBtnTreasureClick() + if XDataCenter.ExpeditionManager.GetIsChapterClear(self.Difficult or XDataCenter.ExpeditionManager.StageDifficulty.Normal) then + local isGet = XDataCenter.ExpeditionManager.GetIsReceivedReward(self.Difficult or XDataCenter.ExpeditionManager.StageDifficulty.Normal) + if not isGet then + XDataCenter.ExpeditionManager.GetChapterReward(self.Difficult) + return + end + end + local rewardId = XDataCenter.ExpeditionManager.GetChapterRewardIdByDifficulty(self.Difficult) + local data = XRewardManager.GetRewardList(rewardId) + if not data then return end + XUiManager.OpenUiTipReward(data) +end + +function XUiExpeditionMain:OnGetTreasure(goodsList) + if goodsList then + XUiManager.OpenUiTipReward(goodsList) + else + local rewardId = XDataCenter.ExpeditionManager.GetChapterRewardIdByDifficulty(self.Difficult) + local data = XRewardManager.GetRewardList(rewardId) + if not data then return end + XUiManager.OpenUiTipReward(data) + end +end + +function XUiExpeditionMain:OnBtnBackClick() + self:Close() +end + +function XUiExpeditionMain:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiExpeditionMain:OnBtnRecruitClick() + XLuaUiManager.Open("UiExpeditionRecruit") +end + +function XUiExpeditionMain:OnBtnListClick() + if not XDataCenter.ExpeditionManager.CheckHaveMember() then + XUiManager.TipMsg(CS.XTextManager.GetText("ExpeditionNeedRecruitMember")) + return + end + XLuaUiManager.Open("UiExpeditionRoleList") +end + +function XUiExpeditionMain:OnBtnBuffClick() + local BuffTipsType = XDataCenter.ExpeditionManager.BuffTipsType.GlobalBuff + XLuaUiManager.Open("UiExpeditionBuffTips", BuffTipsType, self.GlobalCfgs) +end + +function XUiExpeditionMain:OnBtnRankingClick() + XLuaUiManager.Open("UiExpeditionRank") +end + +function XUiExpeditionMain:OnRefresh() + self:RefreshRecruitNumber() + self:SetResetTimer() + self:RefreshRanking() + self:SwitchDifficulty(self.Difficult or XDataCenter.ExpeditionManager.StageDifficulty.Normal) +end + +function XUiExpeditionMain:RefreshRecruitNumber() + self.TxtNumber.text = XDataCenter.ExpeditionManager.GetRecruitNumInfoString() +end + +function XUiExpeditionMain:SetResetTimer() + self:StopTimer() + self:SetResetTime() + self.Timer = XScheduleManager.ScheduleForever(function() + self:SetResetTime() + end, XScheduleManager.SECOND, 0) +end + +function XUiExpeditionMain:SetResetTime() + local endTimeSecond = XDataCenter.ExpeditionManager.GetResetTime() + local now = XTime.GetServerNowTimestamp() + local leftTime = endTimeSecond - now + self.TxtTime.text = XUiHelper.GetTime(leftTime, XUiHelper.TimeFormatType.ACTIVITY) + if leftTime <= 0 then + self:OnActivityReset() + end +end + +function XUiExpeditionMain:StopTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end + +function XUiExpeditionMain:OnSyncStage() + self.ChapterComponent:Show(self.Difficult) + self:RefreshProgress() +end + +function XUiExpeditionMain:RefreshProgress() + local progress = XDataCenter.ExpeditionManager.GetStageCompletePercent(self.Difficult) + self.TxtProgress.text = string.format("%d%s", math.floor(progress * 100), "%") + local IsReceivedReward = XDataCenter.ExpeditionManager.GetIsReceivedReward(self.Difficult) + self.ImgComplete.gameObject:SetActiveEx(IsReceivedReward) + self.ImgProgress.fillAmount = progress + self.ImgRedPoint.gameObject:SetActiveEx(progress == 1 and not IsReceivedReward) +end + +function XUiExpeditionMain:InitGlobalCombo() + local comboIdList = XDataCenter.ExpeditionManager.GetCurrentChapterGlobalCombos() + if not self.GlobalIcons then self.GlobalIcons = {} end + self.GlobalCfgs = {} + local count = 0 + for _, comboId in pairs(comboIdList) do + local comboCfg = XExpeditionConfig.GetGlobalConfigById(comboId) + if comboCfg.IsVisible == 1 then + count = count + 1 + if not self.GlobalIcons[count] then + local prefab = CS.UnityEngine.Object.Instantiate(self.GridBuffIcon.gameObject) + prefab.transform:SetParent(self.PanelBuffIcon.transform, false) + local icon = XUiGlobalComboIcon.New(prefab, self) + table.insert(self.GlobalIcons, icon) + end + self.GlobalIcons[count]:RefreshData(comboCfg) + self.GlobalIcons[count].GameObject:SetActiveEx(true) + table.insert(self.GlobalCfgs, comboCfg) + end + end + for i = count + 1, #self.GlobalIcons do + self.GlobalIcons[i].gameObject:SetActiveEx(false) + end +end +--============= +--切换难度 +--@param difficulty:难度 +--============= +function XUiExpeditionMain:SwitchDifficulty(difficulty) + self.ChapterComponent:Show(difficulty) + self.Difficult = difficulty + local isNightmare = self.Difficult == XDataCenter.ExpeditionManager.StageDifficulty.NightMare + local isNormal = self.Difficult == XDataCenter.ExpeditionManager.StageDifficulty.Normal + if self.BtnNormalStage then self.BtnNormalStage.gameObject:SetActiveEx(isNightmare) end + if self.BtnNightmareStage then + local isShowNightmare = isNormal and XDataCenter.ExpeditionManager.GetIsNormalClear() + if self.NightmareStatus == nil then self.NightmareStatus = isShowNightmare end + self.BtnNightmareStage.gameObject:SetActiveEx(isShowNightmare) + if self.FirstRefresh and isShowNightmare and self.NightmareStatus == false then + self.NightmareStatus = true + XUiManager.TipMsg(CS.XTextManager.GetText("ExpeditionNightmareOpen")) + end + end + if self.NightmarBg then self.NightmarBg.gameObject:SetActiveEx(isNightmare) end + self:RefreshProgress() + if not self.FirstRefresh then self.FirstRefresh = true end +end +--============= +--更改背景图 +--@param path:图片路径 +--============= +function XUiExpeditionMain:ChangeBg(path) + if self.Bg then self.Bg:SetRawImage(path) end +end +--============= +--更改背景特效 +--@param path:特效路径 +--============= +function XUiExpeditionMain:ChangeBgFx(path) + if not self.BgEffect then return end + local disable = string.IsNilOrEmpty(path) + self.BgEffect.gameObject:SetActiveEx(not disable) + if disable then return end + if self.fxName and self.fxName == path then return end + self.fxName = path + self.BgEffect.gameObject:LoadUiEffect(path) +end +--============= +--更改通关奖励图标 +--@param path:特效路径 +--============= +function XUiExpeditionMain:ChangeRewardIcon(path) + if not path then return end + if self.RImgBgIcon then self.RImgBgIcon:SetRawImage(path) end +end +--============= +--刷新排位 +--============= +function XUiExpeditionMain:RefreshRanking() + if self.BtnRanking then self.BtnRanking:SetName(XDataCenter.ExpeditionManager.GetSelfRankStr()) end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/MainPage/XUiExpeditionStageDetail.lua b/Resources/Scripts/XUi/XUiExpedition/MainPage/XUiExpeditionStageDetail.lua new file mode 100644 index 00000000..09089dcf --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/MainPage/XUiExpeditionStageDetail.lua @@ -0,0 +1,59 @@ +--虚像地平线主界面子页面:玩法关卡点击后的关卡详细 +local XUiExpeditionStageDetail = XLuaUiManager.Register(XLuaUi, "UiExpeditionStageDetail") +function XUiExpeditionStageDetail:OnAwake() + XTool.InitUiObject(self) + self.GridCommon.gameObject:SetActive(false) + self.PanelAsset = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint) +end + +function XUiExpeditionStageDetail:OnStart(detailComponent) + self.Chapter = detailComponent.ChapterComponent + self.RootUi = detailComponent.RootUi +end + +function XUiExpeditionStageDetail:OnEnable() + self.Component = self.Chapter.StageSelected + self.EStage = self.Component.EStage + self.Component.Ui = self + self.Component:OnUiEnable(self) +end + +function XUiExpeditionStageDetail:OnDisable() + if self.Component then self.Component:OnUiDisable(self) end +end + +function XUiExpeditionStageDetail:Hide() + self:Close() + CsXGameEventManager.Instance:Notify(XEventId.EVENT_FUBEN_CLOSE_FUBENSTAGEDETAIL) +end + +function XUiExpeditionStageDetail:OnEnterBattle() + if not XDataCenter.ExpeditionManager.CheckHaveMember() then + XUiManager.TipMsg(CS.XTextManager.GetText("ExpeditionNeedRecruitMember")) + return + end + if not XDataCenter.FubenManager.CheckPreFight(self.EStage:GetStageCfg()) then + return + end + self:Hide() + XLuaUiManager.Open("UiNewRoomSingle", self.EStage:GetStageId()) +end + +function XUiExpeditionStageDetail:RefreshChapter(detailComponent) + self.Chapter = detailComponent.ChapterComponent +end + +function XUiExpeditionStageDetail:OnStoryEnterClick() + self:Hide() + if self.EStage:GetIsPass() then + XDataCenter.MovieManager.PlayMovie(self.EStage:GetBeginStoryId()) + else + XDataCenter.FubenManager.FinishStoryRequest(self.EStage:GetStageId(), function() + XDataCenter.MovieManager.PlayMovie(self.EStage:GetBeginStoryId(), function() + self.EStage:SetPass() + self.RootUi:OnSyncStage() + end) + end) + end +end +return XUiExpeditionStageDetail \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/MainPage/XUiExpeditionStageDetailComponent.lua b/Resources/Scripts/XUi/XUiExpedition/MainPage/XUiExpeditionStageDetailComponent.lua new file mode 100644 index 00000000..95c7c5d8 --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/MainPage/XUiExpeditionStageDetailComponent.lua @@ -0,0 +1,90 @@ +--虚像地平线关卡组件 +local XUiExpeditionStageDetailComponent = XClass(nil, "XUiExpeditionStageDetailComponent") +local StageScripts = {} +function XUiExpeditionStageDetailComponent:Ctor(chapter, rootUi, ui, storyType) + self.ChapterComponent = chapter + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Parent = ui.transform.parent + XTool.InitUiObject(self) + self.ImgSelect.gameObject:SetActiveEx(false) + self:AddBtnListener() + self.EStage = storyType + local script = self:GetStageScript(storyType) + if script then self.StageScript = script end +end + +function XUiExpeditionStageDetailComponent:GetStageScript(storyType) + if StageScripts[storyType] ~= nil then return StageScripts[storyType] end + local scriptName = XDataCenter.ExpeditionManager.StageType[storyType] + if not scriptName then + XLog.Error("虚像地平线读取关卡出错!无效的关卡类型:StageType :" .. tostring(storyType)) + return nil + end + local script = require("XUi/XUiExpedition/MainPage/StageDetail/XUiExpeditionStage" .. scriptName .. "Detail") + if not script then + XLog.Error("虚像地平线读取关卡出错!无效的关卡类型:StageType :" .. tostring(storyType)) + return nil + end + StageScripts[storyType] = script + return script +end + +function XUiExpeditionStageDetailComponent:OnEnable() + if self.StageScript then self.StageScript.OnEnable() end +end + +function XUiExpeditionStageDetailComponent:OnUiEnable(ui) + if self.StageScript and self.EStage then self.StageScript.OnUiEnable(self, ui) end +end + +function XUiExpeditionStageDetailComponent:RefreshData(eStage) + self.EStage = eStage + self.TxtName.text = self.EStage:GetStageName() + if self.EStage:GetIsPass() then self.CommonFuBenClear.gameObject:SetActiveEx(true) end + if self.ImgBoss then + self.ImgBoss:SetRawImage(self.EStage:GetStageCover()) + end + local warning = self.EStage:GetStageIsDanger() + if self.IconYellow then + self.IconYellow.gameObject:SetActiveEx(warning == XDataCenter.ExpeditionManager.StageWarning.Warning) + end + if self.IconRed then + self.IconRed.gameObject:SetActiveEx(warning == XDataCenter.ExpeditionManager.StageWarning.Danger) + end + if self.TxtWave then + self.TxtWave.text = XDataCenter.ExpeditionManager.GetWave() + end + if self.StageScript then self.StageScript.RefreshData(self, self.EStage) end +end + +function XUiExpeditionStageDetailComponent:OnDisable() + if self.StageScript then self.StageScript.OnDisable() end +end + +function XUiExpeditionStageDetailComponent:OnUiDisable(ui) + if self.StageScript then self.StageScript.OnUiDisable(self, ui) end +end + +function XUiExpeditionStageDetailComponent:OnDestroy() + if self.StageScript then self.StageScript.OnDestroy() end +end + +function XUiExpeditionStageDetailComponent:CancelSelect() + if self.StageScript then self.StageScript.CancelSelect(self) end +end + +function XUiExpeditionStageDetailComponent:SetSelect() + if self.StageScript then self.StageScript.SetSelect(self) end +end + +function XUiExpeditionStageDetailComponent:OnBtnStageClick() + local canOpen = self.ChapterComponent:ClickStage(self) + if canOpen and self.StageScript then self.StageScript.OnClick(self) end +end + +function XUiExpeditionStageDetailComponent:AddBtnListener() + CsXUiHelper.RegisterClickEvent(self.ImgStage, function() self:OnBtnStageClick() end) +end +return XUiExpeditionStageDetailComponent \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/Ranking/XUiExpeditionMyRank.lua b/Resources/Scripts/XUi/XUiExpedition/Ranking/XUiExpeditionMyRank.lua new file mode 100644 index 00000000..53171080 --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/Ranking/XUiExpeditionMyRank.lua @@ -0,0 +1,36 @@ +-- 虚像地平线我的排行控件 +local XUiExpeditionMyRank = XClass(nil, "XUiExpeditionMyRank") + +function XUiExpeditionMyRank:Ctor(ui, rootUi) + XTool.InitUiObjectByUi(self, ui) + self.RootUi = rootUi +end + +function XUiExpeditionMyRank:Refresh() + XUiPLayerHead.InitPortrait(XPlayer.CurrHeadPortraitId, XPlayer.CurrHeadFrameId, self.Head) + self.TxtPlayerName.text = XPlayer.Name + self:RefreshStageProgress() + self:RefreshRankingText() +end + +function XUiExpeditionMyRank:RefreshStageProgress() + local chapter = XDataCenter.ExpeditionManager.GetCurrentChapter() + local eStage = chapter:GetLastStage() + if not eStage then self.TxtRankScore.text = CS.XTextManager.GetText("ExpeditionNoPassStage") return end + if eStage:GetIsInfinity() then + self.TxtRankScore.text = CS.XTextManager.GetText("ExpeditionRankingWaveStr", XDataCenter.ExpeditionManager.GetWave()) + else + self.TxtRankScore.text = eStage:GetStageName() + end +end + +function XUiExpeditionMyRank:RefreshRankingText() + local selfRanking = XDataCenter.ExpeditionManager.GetSelfRank() + if selfRanking == 0 then self.TxtRankNormal.text = CS.XTextManager.GetText("ExpeditionNoRanking") return end + local icon = XDataCenter.ExpeditionManager.GetRankSpecialIcon(XDataCenter.ExpeditionManager.GetSelfRank()) + if icon then self.RootUi:SetUiSprite(self.ImgRankSpecial, icon) end + self.TxtRankNormal.gameObject:SetActive(icon == nil) + self.ImgRankSpecial.gameObject:SetActive(icon ~= nil) + self.TxtRankNormal.text = XDataCenter.ExpeditionManager.GetSelfRankStr() +end +return XUiExpeditionMyRank \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/Ranking/XUiExpeditionRankGrid.lua b/Resources/Scripts/XUi/XUiExpedition/Ranking/XUiExpeditionRankGrid.lua new file mode 100644 index 00000000..ea86ef0b --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/Ranking/XUiExpeditionRankGrid.lua @@ -0,0 +1,95 @@ +-- 虚像地平线排行项控件 +local XUiExpeditionRankGrid = XClass(nil, "XUiExpeditionRankGrid") +local XTeam = require("XEntity/XExpedition/XExpeditionTeam") +function XUiExpeditionRankGrid:Ctor() + +end + +function XUiExpeditionRankGrid:Init(ui, rootUi) + XTool.InitUiObjectByUi(self, ui) + self.RootUi = rootUi + self.BtnDetail.CallBack = function() self:OnBtnDetailClick() end + self.BtnComboList.CallBack = function() self:OnBtnComboListClick() end +end + +--[[ XExpeditionRankData数据结构 +int Id 玩家ID +string Name +int HeadPortraitId +int HeadFrameId +int Ranking +int StageId 最后通关的关卡ID +int NpcGroup 怪物波数 +List FightCharacters +List OtherCharacters +]] + +function XUiExpeditionRankGrid:RefreshData(rankingData, index) + self.RankingData = rankingData + self.Ranking = index + XUiPLayerHead.InitPortrait(self.RankingData.HeadPortraitId, self.RankingData.HeadFrameId, self.Head) + self.TxtPlayerName.text = self.RankingData.Name + self:RefreshStageProgress() + self:RefreshRankingText() + self:RefreshRolePanel() +end + +function XUiExpeditionRankGrid:RefreshStageProgress() + local eStage = XDataCenter.ExpeditionManager.GetEStageByStageId(self.RankingData.StageId) + if not eStage then return end + if eStage:GetIsInfinity() then + local wave = self.RankingData.NpcGroup > 0 and (self.RankingData.NpcGroup - 1) or 0 + self.TxtRankScore.text = CS.XTextManager.GetText("ExpeditionRankingWaveStr", wave) + else + self.TxtRankScore.text = eStage:GetStageName() + end +end + +function XUiExpeditionRankGrid:RefreshRankingText() + local icon = XDataCenter.ExpeditionManager.GetRankSpecialIcon(self.Ranking) + if icon then self.RootUi:SetUiSprite(self.ImgRankSpecial, icon) end + self.TxtRankNormal.gameObject:SetActive(icon == nil) + self.ImgRankSpecial.gameObject:SetActive(icon ~= nil) + self.TxtRankNormal.text = self.Ranking +end + +function XUiExpeditionRankGrid:RefreshRolePanel() + local roleNum = self.RankingData.FightCharacters and #self.RankingData.FightCharacters or 0 + for i = 1, 3 do + local grid = {} + XTool.InitUiObjectByUi(grid, self["GridRole" .. i].gameObject) + if grid and i > roleNum or self.RankingData.FightCharacters[i].ECharacterId == 0 then + grid.GameObject:SetActiveEx(false) + elseif grid and i <= roleNum then + grid.GameObject:SetActiveEx(true) + local eCharaCfg = XExpeditionConfig.GetCharacterCfgById(self.RankingData.FightCharacters[i].ECharacterId) + local characterId = XExpeditionConfig.GetCharacterIdByBaseId(eCharaCfg.BaseId) + local fashionId = XCharacterConfigs.GetCharacterTemplate(characterId).DefaultNpcFashtionId + grid.RawImage:SetRawImage(XDataCenter.FashionManager.GetFashionSmallHeadIcon(fashionId)) + grid.TxtLevel.text = eCharaCfg.Rank + end + end +end + +function XUiExpeditionRankGrid:OnBtnDetailClick() + XDataCenter.PersonalInfoManager.ReqShowInfoPanel(self.RankingData.Id) +end + +function XUiExpeditionRankGrid:OnBtnComboListClick() + local eCharaIds = {} + if self.RankingData.FightCharacters then + for _, data in pairs(self.RankingData.FightCharacters) do + table.insert(eCharaIds, data.ECharacterId) + end + end + if self.RankingData.OtherCharacters then + for _, data in pairs(self.RankingData.OtherCharacters) do + table.insert(eCharaIds, data.ECharacterId) + end + end + local tempTeam = XTeam.New() + tempTeam:InitTeamPos(XDataCenter.ExpeditionManager.GetCurrentChapter():GetChapterId()) + tempTeam:AddMemberListByECharaIds(eCharaIds) + XLuaUiManager.Open("UiExpeditionComboTips", nil, tempTeam) +end +return XUiExpeditionRankGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/Ranking/XUiExpeditionRankInfo.lua b/Resources/Scripts/XUi/XUiExpedition/Ranking/XUiExpeditionRankInfo.lua new file mode 100644 index 00000000..f17674c1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/Ranking/XUiExpeditionRankInfo.lua @@ -0,0 +1,30 @@ +-- 虚像地平线排行榜控件 +local XUiExpeditionRankInfo = XClass(nil, "XUiExpeditionRankInfo") +local XUiPanelMyRank = require("XUi/XUiExpedition/Ranking/XUiExpeditionMyRank") +local XUiRankGrid = require("XUi/XUiExpedition/Ranking/XUiExpeditionRankGrid") +local XUiRankList = require("XUi/XUiExpedition/Ranking/XUiExpeditionRankList") +function XUiExpeditionRankInfo:Ctor(ui, rootUi) + XTool.InitUiObjectByUi(self, ui) + self.RootUi = rootUi + self:InitPanel() +end + +function XUiExpeditionRankInfo:InitPanel() + self.GridRank.gameObject:SetActive(false) + self.TxtCurTime.text = CS.XTextManager.GetText("ExpeditionResetCountDown", "-") + self.TxtIos.gameObject:SetActive(false) + self.TxtAndroid.gameObject:SetActive(false) + self.MyRank = XUiPanelMyRank.New(self.PanelMyRank, self.RootUi) + self.TopRankingList = XUiRankList.New(self.PlayerRankList, self.RootUi, self) +end + +function XUiExpeditionRankInfo:RefreshRankData() + self.TopRankingList:UpdateData() + self.MyRank:Refresh() +end + +function XUiExpeditionRankInfo:RefreshCountDown(time) + if self.TxtCurTime then self.TxtCurTime.text = CS.XTextManager.GetText("ExpeditionResetCountDown", time) end +end + +return XUiExpeditionRankInfo \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/Ranking/XUiExpeditionRankList.lua b/Resources/Scripts/XUi/XUiExpedition/Ranking/XUiExpeditionRankList.lua new file mode 100644 index 00000000..7fa15a8e --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/Ranking/XUiExpeditionRankList.lua @@ -0,0 +1,36 @@ +--虚像地平线前百排行榜控件 +local XUiExpeditionRankList = XClass(nil, "XUiExpeditionRankList") + +function XUiExpeditionRankList:Ctor(ui, rootUi, rankInfoPanel) + XTool.InitUiObjectByUi(self, ui) + self:InitDynamicTable() + self.RootUi = rootUi + self.InfoPanel = rankInfoPanel +end + +function XUiExpeditionRankList:InitDynamicTable() + local XGrid = require("XUi/XUiExpedition/Ranking/XUiExpeditionRankGrid") + self.DynamicTable = XDynamicTableNormal.New(self.GameObject) + self.DynamicTable:SetProxy(XGrid) + self.DynamicTable:SetDelegate(self) +end + +--动态列表事件 +function XUiExpeditionRankList:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(grid.DynamicGrid.gameObject, self.RootUi) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + if self.RankingList and self.RankingList[index] then + grid:RefreshData(self.RankingList[index], index) + end + end +end + +function XUiExpeditionRankList:UpdateData() + self.RankingList = XDataCenter.ExpeditionManager.GetRankingList() + self.DynamicTable:SetDataSource(self.RankingList) + self.DynamicTable:ReloadDataASync(1) + self.InfoPanel.PanelNoRank.gameObject:SetActiveEx(not (self.RankingList and #self.RankingList > 0)) +end + +return XUiExpeditionRankList \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/Ranking/XUiExpeditionRanking.lua b/Resources/Scripts/XUi/XUiExpedition/Ranking/XUiExpeditionRanking.lua new file mode 100644 index 00000000..bb6a0953 --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/Ranking/XUiExpeditionRanking.lua @@ -0,0 +1,81 @@ +-- 虚像地平线排行榜UI +local XUiExpeditionRanking = XLuaUiManager.Register(XLuaUi, "UiExpeditionRank") +local XRankInfo = require("XUi/XUiExpedition/Ranking/XUiExpeditionRankInfo") +function XUiExpeditionRanking:OnAwake() + XTool.InitUiObject(self) + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self.RankInfo = XRankInfo.New(self.PanelRankInfo, self) + self:SetResetTimer() + self:RegisterButtonEvent() +end + +function XUiExpeditionRanking:OnStart() + XDataCenter.ExpeditionManager.GetRankingData() +end + +function XUiExpeditionRanking:OnGetEvents() + return { XEventId.EVENT_ACTIVITY_ON_RESET, XEventId.EVENT_EXPEDITION_RANKING_REFRESH } +end + +function XUiExpeditionRanking:OnNotify(evt, ...) + local args = { ... } + if evt == XEventId.EVENT_ACTIVITY_ON_RESET then + if args[1] ~= XDataCenter.FubenManager.StageType.Expedition then return end + self:OnActivityReset() + elseif evt == XEventId.EVENT_EXPEDITION_RANKING_REFRESH then + self.RankInfo:RefreshRankData() + end +end + +function XUiExpeditionRanking:OnDisable() + self:StopTimer() +end + +function XUiExpeditionRanking:OnDestroy() + self:StopTimer() +end + +function XUiExpeditionRanking:SetResetTimer() + self:StopTimer() + self:SetResetTime() + self.Timer = XScheduleManager.ScheduleForever(function() + self:SetResetTime() + end, XScheduleManager.SECOND, 0) +end + +function XUiExpeditionRanking:SetResetTime() + local endTimeSecond = XDataCenter.ExpeditionManager.GetResetTime() + local now = XTime.GetServerNowTimestamp() + local leftTime = endTimeSecond - now + self.RankInfo:RefreshCountDown(XUiHelper.GetTime(leftTime, XUiHelper.TimeFormatType.ACTIVITY)) + if leftTime <= 0 then + self:OnActivityReset() + end +end + +function XUiExpeditionRanking:StopTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end + +function XUiExpeditionRanking:OnActivityReset() + self:StopTimer() + XLuaUiManager.RunMain() + XUiManager.TipMsg(CS.XTextManager.GetText("ExpeditionOnClose")) +end + +function XUiExpeditionRanking:RegisterButtonEvent() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:BindHelpBtn(self.BtnHelp, "ExpeditionMainHelp") +end + +function XUiExpeditionRanking:OnBtnBackClick() + self:Close() +end + +function XUiExpeditionRanking:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionComboPanel/XUiExpeditionComboGrid.lua b/Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionComboPanel/XUiExpeditionComboGrid.lua new file mode 100644 index 00000000..1fde1930 --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionComboPanel/XUiExpeditionComboGrid.lua @@ -0,0 +1,50 @@ +--虚像地平线招募界面队伍组合列表控件 +local XUiExpeditionComboGrid = XClass(nil, "XUiExpeditionComboGrid") +local XUiExpeditionComboPhase = require("XUi/XUiExpedition/Recruit/XUiExpeditionComboPanel/XUiExpeditionComboPhase") +function XUiExpeditionComboGrid:Ctor() + +end + +function XUiExpeditionComboGrid:Init(ui, rootUi) + self.Transform = ui.transform + self.GameObject = ui.gameObject + XTool.InitUiObject(self) + self.RootUi = rootUi + self.GridPhase.gameObject:SetActiveEx(false) + self.Disable.gameObject:SetActiveEx(false) + self.Select.gameObject:SetActiveEx(true) +end + +function XUiExpeditionComboGrid:RefreshDatas(eCombo) + self.ECombo = eCombo + local comboActive = self.ECombo:GetComboActive() + self.Select.gameObject:SetActiveEx(comboActive) + self.Disable.gameObject:SetActiveEx(not comboActive) + if comboActive then + self.RImgActive:SetRawImage(self.ECombo:GetIconPath()) + self.TxtActive.text = self.ECombo:GetCurrentPhaseStr() + else + self.RImgDisable:SetRawImage(self.ECombo:GetIconPath()) + self.TxtDisable.text = self.ECombo:GetCurrentPhaseStr() + end + self:RefreshPhase() +end + +function XUiExpeditionComboGrid:RefreshPhase() + if not self.ECombo then return end + if not self.GridPhaseList then self.GridPhaseList = {} end + for i = 1, self.ECombo:GetConditionCharaNum() do + if not self.GridPhaseList[i] then + local ui = CS.UnityEngine.Object.Instantiate(self.GridPhase.gameObject) + ui.transform:SetParent(self.GridPhase.transform.parent, false) + ui.gameObject:SetActiveEx(true) + self.GridPhaseList[i] = XUiExpeditionComboPhase.New(ui) + end + end + for i = 1, #self.GridPhaseList do + self.GridPhaseList[i].GameObject:SetActiveEx(i <= self.ECombo:GetConditionCharaNum()) + self.GridPhaseList[i]:SetIconActive(i <= self.ECombo:GetReachConditionNum()) + end +end + +return XUiExpeditionComboGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionComboPanel/XUiExpeditionComboPhase.lua b/Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionComboPanel/XUiExpeditionComboPhase.lua new file mode 100644 index 00000000..d8dabf85 --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionComboPanel/XUiExpeditionComboPhase.lua @@ -0,0 +1,14 @@ +--虚像地平线羁绊阶段显示图标控件 +local XUiExpeditionComboPhase = XClass(nil, "XUiExpeditionComboPhase") + +function XUiExpeditionComboPhase:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Active = self.Transform:Find("ImgSelect").gameObject +end + +function XUiExpeditionComboPhase:SetIconActive(isActive) + self.Active:SetActiveEx(isActive) +end + +return XUiExpeditionComboPhase \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionComboPanel/XUiExpeditionRecruitComboPanel.lua b/Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionComboPanel/XUiExpeditionRecruitComboPanel.lua new file mode 100644 index 00000000..7ecdf891 --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionComboPanel/XUiExpeditionRecruitComboPanel.lua @@ -0,0 +1,49 @@ +--虚像地平线招募界面:组合羁绊列表控件 +local XUiExpeditionRecruitComboPanel = XClass(nil, "XUiExpeditionRecruitComboPanel") +local XUiExpeditionComboGrid = require("XUi/XUiExpedition/Recruit/XUiExpeditionComboPanel/XUiExpeditionComboGrid") +function XUiExpeditionRecruitComboPanel:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self.GridSample = rootUi.GridCombo + self.GridSample.gameObject:SetActiveEx(false) + self.ImgEmpty = self.GameObject:FindGameObject("ImgEmpty") + self.RootUi:RegisterClickEvent(self.GameObject, self.ClickEmpty, self) + self:InitDynamicTable() +end + +function XUiExpeditionRecruitComboPanel:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.GameObject) + self.DynamicTable:SetProxy(XUiExpeditionComboGrid) + self.DynamicTable:SetDelegate(self) +end + +function XUiExpeditionRecruitComboPanel:ClickEmpty() + XLuaUiManager.Open("UiExpeditionComboTips", nil) +end + +--动态列表事件 +function XUiExpeditionRecruitComboPanel:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(grid.DynamicGrid.gameObject, self.RootUi) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + if self.ComboList and self.ComboList[index] then + grid:RefreshDatas(self.ComboList[index]) + end + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + if self.ComboList and self.ComboList[index] then + XLuaUiManager.Open("UiExpeditionComboTips", self.ComboList[index]) + end + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_RELOAD_COMPLETED then + XEventManager.DispatchEvent(XEventId.EVENT_GUIDE_STEP_OPEN_EVENT) + end +end + +function XUiExpeditionRecruitComboPanel:UpdateData() + self.ComboList = XDataCenter.ExpeditionManager.GetTeam():GetTeamComboList() + self.DynamicTable:SetDataSource(self.ComboList) + self.ImgEmpty:SetActiveEx(#self.ComboList == 0) + self.DynamicTable:ReloadDataASync(1) +end + +return XUiExpeditionRecruitComboPanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionDrawPR.lua b/Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionDrawPR.lua new file mode 100644 index 00000000..f5d1e7be --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionDrawPR.lua @@ -0,0 +1,57 @@ +-- 虚像地平线招募公示页面概率项 +local XUiExpeditionDrawPR = XClass(nil, "XUiExpeditionDrawPR") +local XTitle = require("XUi/XUiExpedition/Recruit/XUiExpeditionPublicityTitle") +function XUiExpeditionDrawPR:Ctor(ui) + XTool.InitUiObjectByUi(self, ui) + self.TxtDesc.gameObject:SetActiveEx(false) +end +--================ +--刷新数据 +--================ +function XUiExpeditionDrawPR:RefreshData(drawPRCfg) + self.DrawPRCfg = drawPRCfg + self:SetTitle() + self:AddPR() + self:AddDrawPRTimes() +end +--================ +--显示左侧等级标题 +--================ +function XUiExpeditionDrawPR:SetTitle() + local prefab = CS.UnityEngine.Object.Instantiate(self.TxtDesc.gameObject) + prefab.transform:SetParent(self.Content, false) + prefab.gameObject:SetActiveEx(true) + local title = XTitle.New(prefab.gameObject) + title:SetTitle(CS.XTextManager.GetText("ExpeditionDrawPRTitle", self.DrawPRCfg.Level)) +end +--================ +--显示概率分布 +--================ +function XUiExpeditionDrawPR:AddPR() + local totalWeight = 0 + for i = 1, #self.DrawPRCfg.RankPR do + totalWeight = totalWeight + self.DrawPRCfg.RankPR[i] + end + for i = 1, #self.DrawPRCfg.RankPR do + local prefab = CS.UnityEngine.Object.Instantiate(self.TxtDesc.gameObject) + prefab.transform:SetParent(self.Content, false) + prefab.gameObject:SetActiveEx(true) + local title = XTitle.New(prefab.gameObject) + if self.DrawPRCfg.RankPR[i] and self.DrawPRCfg.RankPR[i] > 0 then + title:SetTitle(CS.XTextManager.GetText("ExpeditionDrawPRPercent", math.floor(self.DrawPRCfg.RankPR[i] / totalWeight * 100))) + else + title:SetTitle("-") + end + end +end +--================ +--显示刷新次数 +--================ +function XUiExpeditionDrawPR:AddDrawPRTimes() + local prefab = CS.UnityEngine.Object.Instantiate(self.TxtDesc.gameObject) + prefab.transform:SetParent(self.Content, false) + prefab.gameObject:SetActiveEx(true) + local title = XTitle.New(prefab.gameObject) + title:SetTitle(self.DrawPRCfg.NeedRefreshTime) +end +return XUiExpeditionDrawPR \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionLevelTips/XUiExpeditionLevelTips.lua b/Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionLevelTips/XUiExpeditionLevelTips.lua new file mode 100644 index 00000000..aad4502d --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionLevelTips/XUiExpeditionLevelTips.lua @@ -0,0 +1,10 @@ +--虚像地平线招募界面:等级提示子页面 +local XUiExpeditionLevelTips = XLuaUiManager.Register(XLuaUi, "UiExpeditionLevelTips") +function XUiExpeditionLevelTips:OnAwake() + XTool.InitUiObject(self) + self:AddListener() +end + +function XUiExpeditionLevelTips:AddListener() + self.BtnClose.CallBack = function() self:Close() end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionMemberPanel/XUiExpeditionRecruitMemberGrid.lua b/Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionMemberPanel/XUiExpeditionRecruitMemberGrid.lua new file mode 100644 index 00000000..cd564d77 --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionMemberPanel/XUiExpeditionRecruitMemberGrid.lua @@ -0,0 +1,57 @@ +--虚像地平线招募界面成员列表控件 +local XUiExpeditionRecruitMemberGrid = XClass(nil, "XUiExpeditionRecruitMemberGrid") + +function XUiExpeditionRecruitMemberGrid:Ctor() + +end + +function XUiExpeditionRecruitMemberGrid:Init(ui, rootUi) + self.Transform = ui.transform + self.GameObject = ui.gameObject + XTool.InitUiObject(self) + self.Disable.gameObject:SetActiveEx(true) + self.Normal.gameObject:SetActiveEx(false) + self.PanelSelected.gameObject:SetActiveEx(false) +end + +function XUiExpeditionRecruitMemberGrid:RefreshDatas(teamPos, index) + if not teamPos then + self.GameObject:SetActiveEx(false) + return + end + local eChara = XDataCenter.ExpeditionManager.GetCharaByDisplayIndex(index) + local isUnLock = teamPos:GetIsUnLock() + self.Lock.gameObject:SetActiveEx(not isUnLock) + if not isUnLock then self.TxtLockCondition.text = teamPos:GetConditionDes() end + self.Disable.gameObject:SetActiveEx(isUnLock and eChara == nil) + self.Normal.gameObject:SetActiveEx(isUnLock and eChara ~= nil) + if not eChara then return end + self.EChara = eChara + self.TxtFight.text = eChara:GetAbility() + self.RImgHeadIcon:SetRawImage(eChara:GetSmallHeadIcon()) + local comboList = XDataCenter.ExpeditionManager.GetComboList() + local showCombos = comboList:GetActiveComboIdsByEChara(eChara) + for i = 1, 3 do + local rImg = self["RImgCharElement" .. i] + if rImg then + if showCombos[i] then + rImg.transform.parent.gameObject:SetActive(true) + local combo = comboList:GetComboByComboId(showCombos[i]) + rImg:SetRawImage(combo:GetIconPath()) + else + rImg.transform.parent.gameObject:SetActive(false) + end + end + end + self.TxtLevel.text = eChara:GetRankStr() + if eChara:GetIsNew() then + self.PanelEffectLvUp.gameObject:SetActiveEx(false) + self.PanelEffectLvUp.gameObject:SetActiveEx(true) + end +end + +function XUiExpeditionRecruitMemberGrid:InitEffect() + self.PanelEffectLvUp.gameObject:SetActiveEx(false) +end + +return XUiExpeditionRecruitMemberGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionMemberPanel/XUiExpeditionRecruitMemberPanel.lua b/Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionMemberPanel/XUiExpeditionRecruitMemberPanel.lua new file mode 100644 index 00000000..2baa90d7 --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionMemberPanel/XUiExpeditionRecruitMemberPanel.lua @@ -0,0 +1,47 @@ +--虚像地平线招募界面:成员列表控件 +local XUiExpeditionRecruitMemberPanel = XClass(nil, "XUiExpeditionRecruitMemberPanel") +local XUiExpeditionMemberGrid = require("XUi/XUiExpedition/Recruit/XUiExpeditionMemberPanel/XUiExpeditionRecruitMemberGrid") +local DetailsType = { + RecruitMember = 1, + FireMember = 2 +} +function XUiExpeditionRecruitMemberPanel:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self.GridSample = rootUi.GridCharacter + self.GridSample.gameObject:SetActiveEx(false) + self:InitDynamicTable() +end + +function XUiExpeditionRecruitMemberPanel:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.GameObject) + self.DynamicTable:SetProxy(XUiExpeditionMemberGrid) + self.DynamicTable:SetDelegate(self) +end + +--动态列表事件 +function XUiExpeditionRecruitMemberPanel:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(grid.DynamicGrid.gameObject, self.RootUi) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + if self.TeamPosList and self.TeamPosList[index] then + grid:RefreshDatas(self.TeamPosList[index], index) + end + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + if XDataCenter.ExpeditionManager.CheckCharaIsInDisplayByIndex(index) then + self.RootUi:OpenOneChildUi("UiExpeditionRoleDetails", self.RootUi) + self.RootUi.RoleDetails:RefreshData(XDataCenter.ExpeditionManager.GetECharaByDisplayIndex(index), DetailsType.FireMember, index) + end + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_RECYCLE then + grid:InitEffect() + end +end + +function XUiExpeditionRecruitMemberPanel:UpdateData() + self.TeamPosList = XDataCenter.ExpeditionManager.GetTeamPosDisplayList() + self.DynamicTable:SetDataSource(self.TeamPosList) + self.DynamicTable:ReloadDataASync(1) +end + +return XUiExpeditionRecruitMemberPanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionPublicity.lua b/Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionPublicity.lua new file mode 100644 index 00000000..94791eac --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionPublicity.lua @@ -0,0 +1,89 @@ +--虚像地平线招募公示 +local XUiExpeditionPublicity = XLuaUiManager.Register(XLuaUi, "UiExpeditionPublicity") +local XPublicityTitle = require("XUi/XUiExpedition/Recruit/XUiExpeditionPublicityTitle") +local XDrawPR = require("XUi/XUiExpedition/Recruit/XUiExpeditionDrawPR") + +function XUiExpeditionPublicity:OnAwake() + XTool.InitUiObject(self) + self.BtnClose.CallBack = function() self:OnBtnCloseClick() end + self:InitRecruitInfo() + self:InitPanelDrawPR() +end +--================ +--初始化招募信息 +--================ +function XUiExpeditionPublicity:InitRecruitInfo() + self.TxtRecruitTime.text = XDataCenter.ExpeditionManager.GetRecruitNum() + self.TxtLevel.text = XDataCenter.ExpeditionManager.GetRecruitLevel() +end +--================ +--初始化招募表 +--================ +function XUiExpeditionPublicity:InitPanelDrawPR() + self:InitTitle() + self:InitDrawPR() +end +--================ +--初始化招募表头 +--================ +function XUiExpeditionPublicity:InitTitle() + self.GridTitle.gameObject:SetActiveEx(false) + local drawStarCfg = XExpeditionConfig.GetDrawRankConfig() + for i = 1, #drawStarCfg do + if drawStarCfg[i] then + local prefab = CS.UnityEngine.Object.Instantiate(self.GridTitle.gameObject) + prefab.transform:SetParent(self.TitleContent, false) + prefab.gameObject:SetActiveEx(true) + local title = XPublicityTitle.New(prefab.gameObject) + title:RefreshTitle(drawStarCfg[i].Rank) + end + end + self:AddNeedTimesTitle() +end +--================ +--添加需求招募次数表头 +--================ +function XUiExpeditionPublicity:AddNeedTimesTitle() + local prefab = CS.UnityEngine.Object.Instantiate(self.GridTitle.gameObject) + prefab.transform:SetParent(self.TitleContent, false) + prefab.gameObject:SetActiveEx(true) + local title = XPublicityTitle.New(prefab.gameObject) + title:SetTitle(CS.XTextManager.GetText("ExpeditionDrawPRRecruitTimes")) +end +--================ +--初始化招募概率条目 +--================ +function XUiExpeditionPublicity:InitDrawPR() + self.GridPercents.gameObject:SetActiveEx(false) + local drawPRCfg = XExpeditionConfig.GetDrawPRConfig() + for i = 1, #drawPRCfg do + if drawPRCfg[i] then + local prefab = CS.UnityEngine.Object.Instantiate(self.GridPercents.gameObject) + prefab.transform:SetParent(self.DrawPRContent, false) + prefab.gameObject:SetActiveEx(true) + local drawPR = XDrawPR.New(prefab.gameObject) + drawPR:RefreshData(drawPRCfg[i]) + end + end +end + +function XUiExpeditionPublicity:OnGetEvents() + return { XEventId.EVENT_ACTIVITY_ON_RESET } +end + +function XUiExpeditionPublicity:OnNotify(evt, ...) + local args = { ... } + if evt == XEventId.EVENT_ACTIVITY_ON_RESET then + if args[1] ~= XDataCenter.FubenManager.StageType.Expedition then return end + self:OnActivityReset() + end +end + +function XUiExpeditionPublicity:OnActivityReset() + XLuaUiManager.RunMain() + XUiManager.TipMsg(CS.XTextManager.GetText("ExpeditionOnClose")) +end + +function XUiExpeditionPublicity:OnBtnCloseClick() + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionPublicityTitle.lua b/Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionPublicityTitle.lua new file mode 100644 index 00000000..fba6824b --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionPublicityTitle.lua @@ -0,0 +1,28 @@ +-- 招募公示标题控件 +local XUiExpeditionPublicityTitle = XClass(nil, "XUiExpeditionPublicityTitle") + +function XUiExpeditionPublicityTitle:Ctor(ui) + self.GameObject = ui + self.Transform = ui.transform + self.TitleLabel = self.Transform:GetComponent("Text") +end +--================ +--刷新星级文本 +--================ +function XUiExpeditionPublicityTitle:RefreshTitle(text) + if text and self.TitleLabel then + self.TitleLabel.text = CS.XTextManager.GetText("ExpeditionPBTitle", text) + else + self.GameObject:SetActiveEx(false) + end +end +--================ +--设置标题 +--================ +function XUiExpeditionPublicityTitle:SetTitle(text) + if text and self.TitleLabel then + self.TitleLabel.text = text + end +end + +return XUiExpeditionPublicityTitle \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionRecruit.lua b/Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionRecruit.lua new file mode 100644 index 00000000..7315db0a --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionRecruit.lua @@ -0,0 +1,152 @@ +--虚像地平线招募主界面 +local XUiExpeditionRecruit = XLuaUiManager.Register(XLuaUi, "UiExpeditionRecruit") +local XUiExpeditionRecruitComboPanel = require("XUi/XUiExpedition/Recruit/XUiExpeditionComboPanel/XUiExpeditionRecruitComboPanel") +local XUiExpeditionRecruitMemberPanel = require("XUi/XUiExpedition/Recruit/XUiExpeditionMemberPanel/XUiExpeditionRecruitMemberPanel") +local XUiExpeditionRecruitShopPanel = require("XUi/XUiExpedition/Recruit/XUiExpeditionRoomChar/XUiExpeditionRecruitShopPanel") +function XUiExpeditionRecruit:OnAwake() + XTool.InitUiObject(self) + XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self:AddListener() + self.Chapter = XDataCenter.ExpeditionManager.GetCurrentChapter() + self:SetComboList() + self:SetCharacterList() + self:Set3DCharacter() +end + +function XUiExpeditionRecruit:OnEnable() + self.TxtNumber.text = XDataCenter.ExpeditionManager.GetRecruitNumInfoString() + XDataCenter.ItemManager.AddCountUpdateListener(XDataCenter.ItemManager.ItemId.Coin,function() self:RefreshRecruitNumber() end, self.Ui) + self:SetRecruitRefreshTimer() + self:Refresh() +end + +function XUiExpeditionRecruit:OnDisable() + self:StopTimer() +end + +function XUiExpeditionRecruit:OnDestroy() + self:StopTimer() +end + +function XUiExpeditionRecruit:Refresh() + self:RefreshRecruitLevel() + self:RefreshRecruitNumber() +end + +function XUiExpeditionRecruit:RefreshRecruitLevel() + self.TxtRecruitLevel.text = CS.XTextManager.GetText("ExpeditionRecruitLevel", XDataCenter.ExpeditionManager.GetRecruitLevel()) +end + +function XUiExpeditionRecruit:RefreshRecruitNumber() + local canRecruit = XDataCenter.ExpeditionManager.GetCanRecruit() + local canBuy = XDataCenter.ExpeditionManager.GetCanBuyDraw() + self.TxtNumber.gameObject:SetActiveEx(canRecruit or not canBuy) + self.TxtBuy.gameObject:SetActiveEx((not canRecruit) and canBuy) + if canRecruit or not canBuy then + self.TxtNumber.text = XDataCenter.ExpeditionManager.GetRecruitNumInfoString() + else + local price = XDataCenter.ExpeditionManager.GetBuyDrawInfo() + local currentCoin = XDataCenter.ItemManager.GetCoinsNum() + if currentCoin and currentCoin < price then + self.TxtBuy.text = CS.XTextManager.GetText("ExpeditionCoinNotEnoughBuyDraw", price) + else + self.TxtBuy.text = price + end + end + self.TxtTime.gameObject:SetActiveEx(not XDataCenter.ExpeditionManager.GetRecruitTimeFull()) +end + +function XUiExpeditionRecruit:OnGetEvents() + return { XEventId.EVENT_EXPEDITION_RECRUIT_REFRESH, XEventId.EVENT_EXPEDITION_MEMBERLIST_CHANGE, XEventId.EVENT_EXPEDITION_RECRUITTIME_REFRESH, XEventId.EVENT_ACTIVITY_ON_RESET } +end + +function XUiExpeditionRecruit:OnNotify(evt, ...) + local args = { ... } + if evt == XEventId.EVENT_EXPEDITION_RECRUIT_REFRESH then + self.Character3DPanel:UpdateData(args[1]) + self:Refresh() + elseif evt == XEventId.EVENT_EXPEDITION_MEMBERLIST_CHANGE then + self.CharacterList:UpdateData() + self.ComboList:UpdateData() + elseif evt == XEventId.EVENT_EXPEDITION_RECRUITTIME_REFRESH then + self:Refresh() + local isRecruitLevelUp = args[1] + if isRecruitLevelUp then + XUiManager.TipMsg(CS.XTextManager.GetText("ExpeditionRecruitLevelUp")) + self.CharacterList:UpdateData() + end + elseif evt == XEventId.EVENT_ACTIVITY_ON_RESET then + if args[1] ~= XDataCenter.FubenManager.StageType.Expedition then return end + self:StopTimer() + XLuaUiManager.RunMain() + XUiManager.TipMsg(CS.XTextManager.GetText("ExpeditionOnClose")) + end +end + +function XUiExpeditionRecruit:AddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:RegisterClickEvent(self.BtnRefresh, self.OnBtnRefreshClick) + self:BindHelpBtn(self.BtnHelp, "ExpeditionMainHelp") + self:RegisterClickEvent(self.BtnRecruitDisplay, self.OnBtnRecruitDisplayClick) +end + +function XUiExpeditionRecruit:OnBtnBackClick() + self:Close() +end + +function XUiExpeditionRecruit:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiExpeditionRecruit:OnBtnRefreshClick() + XDataCenter.ExpeditionManager.RefreshRecruit() +end + +function XUiExpeditionRecruit:OnBtnRecruitDisplayClick() + XLuaUiManager.Open("UiExpeditionPublicity") +end + +function XUiExpeditionRecruit:SetComboList() + self.ComboList = XUiExpeditionRecruitComboPanel.New(self.SViewComboList, self) + self.ComboList:UpdateData() +end + +function XUiExpeditionRecruit:SetCharacterList() + self.CharacterList = XUiExpeditionRecruitMemberPanel.New(self.SViewCharacterList, self) + self.CharacterList:UpdateData() +end + +function XUiExpeditionRecruit:Set3DCharacter() + local uiModelRoot = self.UiModelGo.transform + local models = { + [1] = XUiPanelRoleModel.New(uiModelRoot:FindTransform("PanelModelCase1"), self.Name, nil, true, nil, true, true), + [2] = XUiPanelRoleModel.New(uiModelRoot:FindTransform("PanelModelCase2"), self.Name, nil, true, nil, true, true), + [3] = XUiPanelRoleModel.New(uiModelRoot:FindTransform("PanelModelCase3"), self.Name, nil, true, nil, true, true), + } + self.Character3DPanel = XUiExpeditionRecruitShopPanel.New(self.PanelChar, self, models) + self.Character3DPanel:UpdateData() +end + +function XUiExpeditionRecruit:SetRecruitRefreshTimer() + self:StopTimer() + self:SetRecruitRefreshTime() + self.Timer = XScheduleManager.ScheduleForever(function() + self:SetRecruitRefreshTime() + end, XScheduleManager.SECOND, 0) +end + +function XUiExpeditionRecruit:SetRecruitRefreshTime() + local endTimeSecond = XDataCenter.ExpeditionManager.GetNextRecruitAddTime() + local now = XTime.GetServerNowTimestamp() + local leftTime = endTimeSecond - now + if leftTime < 0 then leftTime = 0 end + self.TxtTime.text = string.format("%s%s", XUiHelper.GetTime(leftTime, XUiHelper.TimeFormatType.DEFAULT), CS.XTextManager.GetText("ExpeditionRecruitTimeCountDown")) +end +--停止计时器 +function XUiExpeditionRecruit:StopTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionRoleDetails/MessageBoard/XUiExpeditionGuesBook.lua b/Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionRoleDetails/MessageBoard/XUiExpeditionGuesBook.lua new file mode 100644 index 00000000..3fb0e306 --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionRoleDetails/MessageBoard/XUiExpeditionGuesBook.lua @@ -0,0 +1,70 @@ +--虚像地平线角色留言板 +local XUiExpeditionGuesBook = XLuaUiManager.Register(XLuaUi, "UiExpeditionGuesBook") +local XUiExpeditionMessageItemList = require("XUi/XUiExpedition/Recruit/XUiExpeditionRoleDetails/MessageBoard/XUiExpeditionMessageItemList") + +function XUiExpeditionGuesBook:OnAwake() + XTool.InitUiObject(self) + self.GridGuestbook.gameObject:SetActiveEx(false) + self.MessageItemList = XUiExpeditionMessageItemList.New(self.PanelSelectList, self) + self:RegisterClickEvent(self.BtnClose, self.OnBtnClose) + self:RegisterClickEvent(self.BtnSend, self.OnBtnSend) +end + +function XUiExpeditionGuesBook:OnStart(eCharaCfg, hadCommented) + self.HadCommented = hadCommented + self:RefreshData(eCharaCfg) +end + +function XUiExpeditionGuesBook:OnEnable() + self.MessageItemList:OnEnable() +end + +function XUiExpeditionGuesBook:OnBtnSend() + if not self.ECharaCfg then return end + if self.HadCommented then + XUiManager.TipMsg(CS.XTextManager.GetText("ExpeditionHaveCommented")) + end + XDataCenter.ExpeditionManager.SendComment(self.ECharaCfg.Id, self.InputFieldMsg.text) + self:ResetInput() +end + +function XUiExpeditionGuesBook:OnBtnClose() + self.MessageItemList:OnDisable() + self:Close() +end + +function XUiExpeditionGuesBook:RefreshData(eCharaCfg) + self.ECharaCfg = eCharaCfg + self.EBaseCharaCfg = XExpeditionConfig.GetBaseCharacterCfgById(eCharaCfg.BaseId) + self.CharacterId = self.EBaseCharaCfg.CharacterId + self:RefreshRoleInfo() + self:RefreshMessageList() +end + +function XUiExpeditionGuesBook:RefreshRoleInfo() + if not self.ECharaCfg then return end + local jobType = XRobotManager.GetRobotJobType(self.ECharaCfg.RobotId) + self.RImgRole:SetRawImage(XDataCenter.CharacterManager.GetCharHalfBodyImage(self.CharacterId)) + self.RImgIconCharacter:SetRawImage(XCharacterConfigs.GetNpcTypeIcon(jobType)) + self.TxtName.text = XCharacterConfigs.GetCharacterName(self.CharacterId) + self.TxtNameOther.text = XCharacterConfigs.GetCharacterTradeName(self.CharacterId) + local elementList = XExpeditionConfig.GetCharacterElementByBaseId(self.ECharaCfg.BaseId) + for i = 1, 3 do + local rImg = self["RImgCharElement" .. i] + if elementList[i] then + rImg.transform.parent.gameObject:SetActive(true) + local elementConfig = XExpeditionConfig.GetCharacterElementById(elementList[i]) + rImg:SetRawImage(elementConfig.Icon) + else + rImg.transform.parent.gameObject:SetActive(false) + end + end +end + +function XUiExpeditionGuesBook:RefreshMessageList() + self.MessageItemList:UpdateData(self.ECharaCfg.Id) +end + +function XUiExpeditionGuesBook:ResetInput() + self.InputFieldMsg.text = "" +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionRoleDetails/MessageBoard/XUiExpeditionMessageItem.lua b/Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionRoleDetails/MessageBoard/XUiExpeditionMessageItem.lua new file mode 100644 index 00000000..eba19b17 --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionRoleDetails/MessageBoard/XUiExpeditionMessageItem.lua @@ -0,0 +1,61 @@ +--虚像地平线角色留言板留言控件 +local XUiExpeditionMessageItem = XClass(nil, "XUiExpeditionMessageItem") +function XUiExpeditionMessageItem:Ctor() + +end + +--[[ commentData结构 +{ + int CommentId; // 留言id + int PlayerId; // 玩家id + int Icon; // 头像 + int HeadFrameId; // 头像框 + string PlayerName; // 玩家名字 + int MedalId; // 勋章id + string Content; // 留言内容 + int ECharacterLevel; // 留言的对象等级 + int LikeCount; // 点赞数 + bool DoILike; // 我是否点赞 +}]] + +function XUiExpeditionMessageItem:Init(ui, rootUi, eCharId) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self.ECharId = eCharId + self.ECharBaseId = XExpeditionConfig.GetBaseIdByECharId(eCharId) + XTool.InitUiObject(self) + self.RootUi:RegisterClickEvent(self.BtnLike, function() self:ClickLike() end) +end + +function XUiExpeditionMessageItem:RefreshData(commentData) + XUiPLayerHead.InitPortrait(commentData.Icon, commentData.HeadFrameId, self.Head) + self.TxtMsg.text = commentData.Content + self.TxtName.text = commentData.PlayerName + self.CommentId = commentData.CommentId + self.DoILike = commentData.DoILike + if commentData.DoILike then + self.BtnLike:SetButtonState(CS.UiButtonState.Disable) + else + self.BtnLike:SetButtonState(CS.UiButtonState.Normal) + end + self.BtnLike:SetName(commentData.LikeCount) + if commentData.MedalId and commentData.MedalId > 0 then + local medalConfig = XMedalConfigs.GetMeadalConfigById(commentData.MedalId) + self.RImgMedal.gameObject:SetActiveEx(true) + self.RImgMedal:SetRawImage(medalConfig.MedalIcon) + else + self.RImgMedal.gameObject:SetActiveEx(false) + end + self.TxtLevel.text = commentData.ECharacterLevel +end + +function XUiExpeditionMessageItem:ClickLike() + if self.DoILike then + XUiManager.TipMsg(CS.XTextManager.GetText("ExpeditionHaveDoLike")) + return + end + XDataCenter.ExpeditionManager.CommentDoLike(self.ECharBaseId, self.CommentId) +end + +return XUiExpeditionMessageItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionRoleDetails/MessageBoard/XUiExpeditionMessageItemList.lua b/Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionRoleDetails/MessageBoard/XUiExpeditionMessageItemList.lua new file mode 100644 index 00000000..a56bada5 --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionRoleDetails/MessageBoard/XUiExpeditionMessageItemList.lua @@ -0,0 +1,136 @@ +--虚像地平线角色留言板留言列表 +local XUiExpeditionMessageItemList = XClass(nil, "XUiExpeditionMessageItemList") +local XUiExpeditionMessageItem = require("XUi/XUiExpedition/Recruit/XUiExpeditionRoleDetails/MessageBoard/XUiExpeditionMessageItem") +function XUiExpeditionMessageItemList:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + self:ResetCommentsList() + self:InitDynamicTable() +end + +function XUiExpeditionMessageItemList:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.GameObject) + self.DynamicTable:SetProxy(XUiExpeditionMessageItem) + self.DynamicTable:SetDelegate(self) +end +--动态列表事件 +function XUiExpeditionMessageItemList:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(grid.DynamicGrid.gameObject, self.RootUi, self.ECharaId) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + if self.CommentsList and self.CommentsList[index] then + grid:RefreshData(self.CommentsList[index]) + end + if self.NextPage and index == #self.CommentsList then + self:GetComment() + end + end +end + +function XUiExpeditionMessageItemList:ResetCommentsList() + self.PageNo = 1 + self.CommentsList = {} + self.MyComments = nil +end + +function XUiExpeditionMessageItemList:GetComment() + XDataCenter.ExpeditionManager.GetComment(self.ECharBaseId, self.PageNo) +end +--[[ commentData结构 +{ +int CommentId; // 留言id +int PlayerId; // 玩家id +int Icon; // 头像 +int HeadFrameId; // 头像框 +string PlayerName; // 玩家名字 +int MedalId; // 勋章id +string Content; // 留言内容 +int ECharacterLevel; // 留言的对象等级 +int LikeCount; // 点赞数 +bool DoILike; // 我是否点赞 +}]] +function XUiExpeditionMessageItemList:OnSendMyMessage(commentId, commentText) + local MyComments = { + CommentId = commentId, + PlayerId = XPlayer.Id, + Content = commentText, + DoILike = false, + ECharacterLevel = XExpeditionConfig.GetCharacterCfgById(self.ECharaId).Rank, + MedalId = XPlayer.CurrMedalId, + PlayerName = XPlayer.Name, + Icon = XPlayer.CurrHeadPortraitId, + HeadFrameId = XPlayer.CurrHeadFrameId, + LikeCount = 0, + } + local newCommentList = {} + table.insert(newCommentList, MyComments) + for i = 1, #self.CommentsList do + table.insert(newCommentList, self.CommentsList[i]) + end + self.RootUi.ImgEmpty.gameObject:SetActiveEx(false) + self.CommentsList = newCommentList + self.DynamicTable:SetDataSource(self.CommentsList) + self.DynamicTable:ReloadDataASync(1) +end + +function XUiExpeditionMessageItemList:UpdateData(eCharaId) + self.ECharaId = eCharaId + self.ECharBaseId = XExpeditionConfig.GetBaseIdByECharId(eCharaId) + self:GetComment() +end + +function XUiExpeditionMessageItemList:OnReceiveComments(commentsList, pageNo) + self:AddComments(commentsList) + self.DynamicTable:SetDataSource(self.CommentsList) + self.DynamicTable:ReloadDataASync(-1) +end + +function XUiExpeditionMessageItemList:AddComments(commentsList) + self.RootUi.ImgEmpty.gameObject:SetActiveEx(not (commentsList and #commentsList > 0)) + if commentsList and #commentsList > 0 then + for i in pairs(commentsList) do + table.insert(self.CommentsList, commentsList[i]) + end + if #self.CommentsList % 20 == 0 and #self.CommentsList < 100 then + self.PageNo = self.PageNo + 1 + self.NextPage = true + else + self.NextPage = false + end + end +end + +function XUiExpeditionMessageItemList:OnDoLike(commentId) + for _, v in pairs (self.CommentsList) do + if v.CommentId == commentId then + v.DoILike = true + v.LikeCount = v.LikeCount + 1 + end + end + self.DynamicTable:SetDataSource(self.CommentsList) + self.DynamicTable:ReloadDataASync(-1) +end + +function XUiExpeditionMessageItemList:AddListener() + if self.IsAddedListener then return end + self.IsAddedListener = true + XEventManager.AddEventListener(XEventId.EVENT_EXPEDITION_COMMENTS_RECEIVE, self.OnReceiveComments, self) + XEventManager.AddEventListener(XEventId.EVENT_EXPEDITION_COMMENTS_SEND, self.OnSendMyMessage, self) + XEventManager.AddEventListener(XEventId.EVENT_EXPEDITION_COMMENTS_DOLIKE, self.OnDoLike, self) +end + +function XUiExpeditionMessageItemList:OnEnable() + self:AddListener() + self:ResetCommentsList() +end + +function XUiExpeditionMessageItemList:OnDisable() + XEventManager.RemoveEventListener(XEventId.EVENT_EXPEDITION_COMMENTS_RECEIVE, self.OnReceiveComments, self) + XEventManager.RemoveEventListener(XEventId.EVENT_EXPEDITION_COMMENTS_SEND, self.OnSendMyMessage, self) + XEventManager.RemoveEventListener(XEventId.EVENT_EXPEDITION_COMMENTS_DOLIKE, self.OnDoLike, self) + self.IsAddedListener = false +end + +return XUiExpeditionMessageItemList \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionRoleDetails/XUiExpeditionComboIconGrid.lua b/Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionRoleDetails/XUiExpeditionComboIconGrid.lua new file mode 100644 index 00000000..c2bcd265 --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionRoleDetails/XUiExpeditionComboIconGrid.lua @@ -0,0 +1,29 @@ +--虚像地平线招募界面子页面角色详细:羁绊显示控件 +local XUiExpeditionComboIconGrid = XClass(nil, "XUiExpeditionComboIconGrid") +local DetailsType = { + RecruitMember = 1, + FireMember = 2 +} +function XUiExpeditionComboIconGrid:Ctor() + +end + +function XUiExpeditionComboIconGrid:Init(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiExpeditionComboIconGrid:RefreshData(eComboId, detailsType) + self.ECombo = XDataCenter.ExpeditionManager.GetComboByChildComboId(eComboId) + self.RImgCombo:SetRawImage(self.ECombo:GetIconPath()) + self.ImgDown.gameObject:SetActiveEx(false) + if detailsType == DetailsType.FireMember then + self.ImgUp.gameObject:SetActiveEx(false) + --self.IsActive.gameObject:SetActiveEx(self.ECombo:GetComboActive()) + elseif detailsType == DetailsType.RecruitMember then + --self.IsActive.gameObject:SetActiveEx(self.ECombo:GetPreActive()) + self.ImgUp.gameObject:SetActiveEx(self.ECombo:GetPrePhaseUp() or self.ECombo:GetIsWillActive()) + end +end +return XUiExpeditionComboIconGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionRoleDetails/XUiExpeditionComboIconPanel.lua b/Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionRoleDetails/XUiExpeditionComboIconPanel.lua new file mode 100644 index 00000000..96a37017 --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionRoleDetails/XUiExpeditionComboIconPanel.lua @@ -0,0 +1,46 @@ +--虚像地平线招募界面角色详细子页面:羁绊展示动态列表 +local XUiExpeditionComboIconPanel = XClass(nil, "XUiExpeditionComboIconPanel") +local XUiExpeditionComboIconGrid = require("XUi/XUiExpedition/Recruit/XUiExpeditionRoleDetails/XUiExpeditionComboIconGrid") +local DetailsType = { + RecruitMember = 1, + FireMember = 2 +} +function XUiExpeditionComboIconPanel:Ctor(ui, rootUi, detailsType) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self.DetailsType = detailsType + self:InitDynamicTable() +end + +function XUiExpeditionComboIconPanel:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.GameObject) + self.DynamicTable:SetProxy(XUiExpeditionComboIconGrid) + self.DynamicTable:SetDelegate(self) +end + +--动态列表事件 +function XUiExpeditionComboIconPanel:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(grid.DynamicGrid.gameObject) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + if self.ComboList and self.ComboList[index] then + grid:RefreshData(self.ComboList[index], self.DetailsType) + end + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + if self.ComboList and self.ComboList[index] then + XLuaUiManager.Open("UiExpeditionComboTips", XDataCenter.ExpeditionManager.GetComboByChildComboId(self.ComboList[index])) + end + end +end + +function XUiExpeditionComboIconPanel:UpdateData(eChara) + if self.DetailsType == DetailsType.FireMember then + self.ComboList = XDataCenter.ExpeditionManager.GetComboList():GetActiveComboIdsByEChara(eChara) + elseif self.DetailsType == DetailsType.RecruitMember then + self.ComboList = XDataCenter.ExpeditionManager.GetComboList():GetPreviewCombosWhenRecruit(eChara) + end + self.DynamicTable:SetDataSource(self.ComboList) + self.DynamicTable:ReloadDataASync(1) +end +return XUiExpeditionComboIconPanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionRoleDetails/XUiExpeditionRoleDetails.lua b/Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionRoleDetails/XUiExpeditionRoleDetails.lua new file mode 100644 index 00000000..f9513be6 --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionRoleDetails/XUiExpeditionRoleDetails.lua @@ -0,0 +1,127 @@ +--虚像地平线招募界面角色详细子页面 +local XUiExpeditionRoleDetails = XLuaUiManager.Register(XLuaUi, "UiExpeditionRoleDetails") +local XUiExpeditionSkillIconGrid = require("XUi/XUiExpedition/Recruit/XUiExpeditionRoleDetails/XUiExpeditionSkillIconGrid") +local XUiExpeditionComboIconPanel = require("XUi/XUiExpedition/Recruit/XUiExpeditionRoleDetails/XUiExpeditionComboIconPanel") +local DetailsType = { + RecruitMember = 1, + FireMember = 2 + } +function XUiExpeditionRoleDetails:OnAwake() + XTool.InitUiObject(self) + self.RecruitPanel = { Transform = self.RecruitDetails.transform } + XTool.InitUiObject(self.RecruitPanel) + self.RecruitComboList = XUiExpeditionComboIconPanel.New(self.RecruitPanel.SViewComboList, self, DetailsType.RecruitMember) + self.FirePanel = { Transform = self.FireDetails.transform } + XTool.InitUiObject(self.FirePanel) + self.FireComboList = XUiExpeditionComboIconPanel.New(self.FirePanel.SViewComboList, self, DetailsType.FireMember) + self:AddListener() + self.RecruitPanel.GridSubSkill.gameObject:SetActiveEx(false) + self.FirePanel.GridSubSkill.gameObject:SetActiveEx(false) + self.FirePanel.GridCombo.gameObject:SetActiveEx(false) +end + +function XUiExpeditionRoleDetails:OnStart(rootUi, eChara, type, gridIndex) + self.RootUi = rootUi + self.RootUi.RoleDetails = self + if eChara then self:RefreshData(eChara, type, gridIndex) end +end + +function XUiExpeditionRoleDetails:RefreshData(eChara, type, gridIndex) + self.EChara = eChara + self.Type = type or DetailsType.RecruitMember + self.GridIndex = gridIndex + self:RefreshPanel() +end + +function XUiExpeditionRoleDetails:AddListener() + self:RegisterClickEvent(self.BtnRecruit, self.OnBtnRecruitClick) + self:RegisterClickEvent(self.BtnMessage, self.OnBtnMessageClick) + self:RegisterClickEvent(self.BtnFired, self.OnBtnFiredClick) + self:RegisterClickEvent(self.BtnClose, self.OnBtnCloseClick) +end + +function XUiExpeditionRoleDetails:RefreshPanel() + self.RecruitDetails.gameObject:SetActiveEx(self.Type == DetailsType.RecruitMember) + self.FireDetails.gameObject:SetActiveEx(self.Type == DetailsType.FireMember) + if self.Type == DetailsType.RecruitMember then + self.ShowPanel = self.RecruitPanel + else + self.ShowPanel = self.FirePanel + end + self.ShowPanel.TxtLv.text = self.EChara:GetAbility() + local attrib = self.EChara:GetCharaAttributes() + self.ShowPanel.TxtAttack.text = FixToInt(attrib[XNpcAttribType.AttackNormal]) + self.ShowPanel.TxtLife.text = FixToInt(attrib[XNpcAttribType.Life]) + self.ShowPanel.TxtDefense.text = FixToInt(attrib[XNpcAttribType.DefenseNormal]) + self.ShowPanel.TxtCrit.text = FixToInt(attrib[XNpcAttribType.Crit]) + self.ShowPanel.RImgTypeIcon:SetRawImage(self.EChara:GetJobTypeIcon()) + self.ShowPanel.TxtName.text = self.EChara:GetCharaName() + self.ShowPanel.TxtNameOther.text = self.EChara:GetCharacterTradeName() + self.ShowPanel.TxtLevel.text = self.EChara:GetRankStr() + local elementList = self.EChara:GetCharacterElements() + for i = 1, 3 do + local rImg = self.ShowPanel["RImgCharElement" .. i] + if elementList[i] then + rImg.gameObject:SetActive(true) + local elementConfig = XExpeditionConfig.GetCharacterElementById(elementList[i]) + rImg:SetRawImage(elementConfig.Icon) + else + rImg.gameObject:SetActive(false) + end + end + self:RefreshSkill() + if self.Type == DetailsType.FireMember then + self.FireComboList:UpdateData(self.EChara) + self:PlayAnimation("PanelRoleDetails2Enable") + else + self.RecruitComboList:UpdateData(self.EChara) + self:PlayAnimation("PanelRoleDetails1Enable") + end +end + +function XUiExpeditionRoleDetails:RefreshSkill() + self.Skills = self.EChara:GetLockSkill() + if not self.ShowPanel.SkillGrids then + self.ShowPanel.SkillGrids = {} + for i = 1, #self.Skills do + local skillInfo = self.Skills[i] + local skillPrefab = CS.UnityEngine.Object.Instantiate(self.ShowPanel.GridSubSkill.gameObject) + skillPrefab.transform:SetParent(self.ShowPanel.PanelSubSkillList.transform, false) + self.ShowPanel.SkillGrids[i] = XUiExpeditionSkillIconGrid.New(skillPrefab) + self.ShowPanel.SkillGrids[i]:RefreshData(skillInfo) + self.ShowPanel.SkillGrids[i].GameObject:SetActiveEx(true) + self:RegisterClickEvent(self.ShowPanel.SkillGrids[i].BtnSubSkillIconBg, function() + XLuaUiManager.Open("UiExpeditionBuffTips", XDataCenter.ExpeditionManager.BuffTipsType.Skill, self.Skills) + end + ) + end + else + for i = 1, #self.ShowPanel.SkillGrids do + if self.Skills[i] then + local skillInfo = self.Skills[i] + self.ShowPanel.SkillGrids[i]:RefreshData(skillInfo) + self.ShowPanel.SkillGrids[i].GameObject:SetActiveEx(true) + else + self.ShowPanel.SkillGrids[i].GameObject:SetActiveEx(false) + end + end + end +end + +function XUiExpeditionRoleDetails:OnBtnRecruitClick() + self:Close() + XDataCenter.ExpeditionManager.RecruitMember(self.GridIndex) +end + +function XUiExpeditionRoleDetails:OnBtnMessageClick() + --XLuaUiManager.Open("UiExpeditionGuesBook", self.ECharacterCfg, self.HadCommented) +end + +function XUiExpeditionRoleDetails:OnBtnCloseClick() + self:Close() +end + +function XUiExpeditionRoleDetails:OnBtnFiredClick() + self:Close() + XDataCenter.ExpeditionManager.FireMember(self.EChara:GetBaseId(), self.EChara:GetECharaId()) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionRoleDetails/XUiExpeditionSkillIconGrid.lua b/Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionRoleDetails/XUiExpeditionSkillIconGrid.lua new file mode 100644 index 00000000..00ca1a19 --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionRoleDetails/XUiExpeditionSkillIconGrid.lua @@ -0,0 +1,20 @@ +--虚像地平线招募界面子页面角色详细:技能显示控件 +local XUiExpeditionSkillIconGrid = XClass(nil, "XUiExpeditionSkillIconGrid") +function XUiExpeditionSkillIconGrid:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiExpeditionSkillIconGrid:RefreshData(skillInfo) + self.Data = skillInfo + self.RImgSkillIcon:SetRawImage(skillInfo.IconPath) + self.TxtSkillLevel.text = string.format("Lv:%d", skillInfo.Level) + if self.TxtStarLevel then self.TxtStarLevel.text = string.format(skillInfo.LockLevel) end + self:SetLock(skillInfo.IsLock) +end + +function XUiExpeditionSkillIconGrid:SetLock(isLock) + self.Lock.gameObject:SetActiveEx(isLock) +end +return XUiExpeditionSkillIconGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionRoomChar/XUiExpeditionRecruitShopGrid.lua b/Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionRoomChar/XUiExpeditionRecruitShopGrid.lua new file mode 100644 index 00000000..9d27e341 --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionRoomChar/XUiExpeditionRecruitShopGrid.lua @@ -0,0 +1,106 @@ +--虚像地平线招募界面招募显示列表控件 +local XUiExpeditionRecruitShopGrid = XClass(nil, "XUiExpeditionRecruitShopGrid") +local UiButtonState = CS.UiButtonState + +local DetailsType = { + RecruitMember = 1, + FireMember = 2 +} +function XUiExpeditionRecruitShopGrid:Ctor(ui, modelPanel, rootUi, gridIndex) + self.Transform = ui.transform + self.GameObject = ui.gameObject + XTool.InitUiObject(self) + self.ModelPanel = modelPanel + self.RootUi = rootUi + self.GridIndex = gridIndex + self.TxtName.text = "" + self.GameObject:SetActiveEx(false) +end + +function XUiExpeditionRecruitShopGrid:RefreshDatas(pos, playEffect) + if not pos then + self.GameObject:SetActiveEx(false) + self.ModelPanel:HideRoleModel() + return + end + self.GameObject:SetActiveEx(true) + self.EChara = XDataCenter.ExpeditionManager.GetRecruitMemberByPos(pos) + local isBlank = self.EChara:GetIsBlank(not self.EChara or isBlank) + if isBlank then + self.GameObject:SetActiveEx(false) + self.ModelPanel:HideRoleModel() + return + end + self.TxtName.gameObject:SetActiveEx(self.EChara and not isBlank) + local recruitMembers = XDataCenter.ExpeditionManager.GetRecruitMembers() + if recruitMembers:GetIsPicked() then + self.IsPicked = true + self.BtnRankUp.gameObject:SetActiveEx(false) + if recruitMembers:GetRecruitPos() ~= pos then + self.BtnRecruit.gameObject:SetActiveEx(false) + else + self.BtnRecruit.gameObject:SetActiveEx(true) + self.BtnRecruit:SetButtonState(UiButtonState.Disable) + end + else + self.IsPicked = false + local team = XDataCenter.ExpeditionManager.GetTeam() + local isExistInTeam = not isBlank and team:CheckInTeamByEBaseId(self.EChara:GetBaseId()) + self.BtnRecruit.gameObject:SetActiveEx(not isExistInTeam) + self.BtnRankUp.gameObject:SetActiveEx(isExistInTeam) + if isExistInTeam then + self.BtnRecruit.gameObject:SetActiveEx(false) + else + self.BtnRecruit:SetButtonState(UiButtonState.Normal) + end + end + if not self.EChara or isBlank then self:UpdateRoleModel() return end + self.TxtName.text = self.EChara:GetCharaFullName() + self:UpdateRoleModel(self.EChara:GetCharacterId(), self.EChara:GetRobotId(), playEffect) + self.TxtLevel.text = self.EChara:GetRankStr() +end + +--更新模型 +function XUiExpeditionRecruitShopGrid:UpdateRoleModel(charId, robotId, playEffect) + if not charId or not robotId then return end + self.GameObject:SetActiveEx(true) + if not self.ShowEffect then + self.ShowEffect = {} + self.ShowEffect[1] = self.ModelPanel.Transform:Find("ImgEffectHuanren1") + self.ShowEffect[2] = self.ModelPanel.Transform:Find("ImgEffectHuanren2") + self.ShowEffect[3] = self.ModelPanel.Transform:Find("ImgEffectHuanren3") + end + if playEffect then + for i in pairs(self.ShowEffect) do + self.ShowEffect[i].gameObject:SetActiveEx(false) + end + for i = #self.ShowEffect, 1, -1 do + local checkRank = XExpeditionConfig.GetRankByRankWeightId(i) + if self.EChara:GetRank() >= checkRank then + self.ShowEffect[i].gameObject:SetActiveEx(true) + break + end + end + end + self.ModelPanel:ShowRoleModel() + local callback = function() + self.ModelReady = true + end + self.ModelReady = false + local robotCfg = XRobotManager.GetRobotTemplate(robotId) + self.ModelPanel:UpdateRobotModel(robotId, charId, callback, robotCfg and robotCfg.FashionId, robotCfg and robotCfg.WeaponId) +end + +function XUiExpeditionRecruitShopGrid:OnClick() + if not self.EChara then return end + if self.EChara:GetIsBlank() then return end + if self.IsPicked then return end + if self.RootUi.RoleDetails then + self.RootUi:OpenOneChildUi("UiExpeditionRoleDetails", self.RootUi) + self.RootUi.RoleDetails:RefreshData(self.EChara, DetailsType.RecruitMember, self.GridIndex) + else + self.RootUi:OpenOneChildUi("UiExpeditionRoleDetails", self.RootUi, self.EChara, DetailsType.RecruitMember, self.GridIndex) + end +end + +return XUiExpeditionRecruitShopGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionRoomChar/XUiExpeditionRecruitShopPanel.lua b/Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionRoomChar/XUiExpeditionRecruitShopPanel.lua new file mode 100644 index 00000000..08f33867 --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/Recruit/XUiExpeditionRoomChar/XUiExpeditionRecruitShopPanel.lua @@ -0,0 +1,40 @@ +--虚像地平线招募界面招募商店角色列表控件 +local XUiExpeditionRecruitShopPanel = XClass(nil, "XUiExpeditionRecruitShopPanel") +local XUiExpeditionRecruitShopGrid = require("XUi/XUiExpedition/Recruit/XUiExpeditionRoomChar/XUiExpeditionRecruitShopGrid") +function XUiExpeditionRecruitShopPanel:Ctor(ui, rootUi, models) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self.GridSample = rootUi.GridRoomChar + self.GridSample.gameObject:SetActiveEx(false) + self.Model3D = models + self.GridNum = XDataCenter.ExpeditionManager.GetRecruitDrawNum() + self:InitPanel() +end + +function XUiExpeditionRecruitShopPanel:InitPanel() + self.CharaGrids = {} + for i = 1, self.GridNum do + local roomCharCase = self.Transform:FindTransform("RoomCharCase" .. i) + if roomCharCase then + local prefab = CS.UnityEngine.Object.Instantiate(self.GridSample.gameObject) + prefab.transform:SetParent(roomCharCase, false) + prefab.gameObject:SetActiveEx(true) + self.CharaGrids[i] = XUiExpeditionRecruitShopGrid.New(prefab, self.Model3D[i], self.RootUi, i) + CsXUiHelper.RegisterClickEvent(self.CharaGrids[i].BtnRecruit, function() self.CharaGrids[i]:OnClick() end) + CsXUiHelper.RegisterClickEvent(self.CharaGrids[i].BtnRankUp, function() self.CharaGrids[i]:OnClick() end) + end + end +end + +function XUiExpeditionRecruitShopPanel:UpdateData(playEffect) + local recruitMembers = XDataCenter.ExpeditionManager.GetRecruitMembers() + for i = 1, self.GridNum do + if recruitMembers and recruitMembers:GetCharaByPos(i) then + self.CharaGrids[i]:RefreshDatas(i, playEffect) + else + self.CharaGrids[i]:RefreshDatas(nil) + end + end +end +return XUiExpeditionRecruitShopPanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/RoleList/CharacterDetail/XUiExpeditionCharProperty.lua b/Resources/Scripts/XUi/XUiExpedition/RoleList/CharacterDetail/XUiExpeditionCharProperty.lua new file mode 100644 index 00000000..bad2aea6 --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/RoleList/CharacterDetail/XUiExpeditionCharProperty.lua @@ -0,0 +1,43 @@ +--虚像地平线成员列表界面:角色展示页面: 角色状态栏 +local XUiExpeditionCharProperty = XClass(nil, "XUiExpeditionCharProperty") + +function XUiExpeditionCharProperty:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiExpeditionCharProperty:ShowPanel(robotData) + self.RobotCfg = robotData + self.CharacterId = self.RobotCfg.CharacterId + self.IsShow = true + self.GameObject:SetActive(true) + self.PanelLeveInfo.gameObject:SetActive(true) + self.BtnLiberation = self.PanelLeveInfo.transform:Find("BtnLiberation") + self.ExpBar = self.PanelLeveInfo.transform:Find("ExpBar") + self.LeveInfoQiehuan:PlayTimelineAnimation() + self:UpdatePanel() + self.BtnLevelUpButton.gameObject:SetActive(false) + self.ImgMaxLevel.gameObject:SetActive(self.RobotCfg.CharacterLevel == XCharacterConfigs.GetCharMaxLevel(self.CharacterId)) +end + +function XUiExpeditionCharProperty:HidePanel() + self.IsShow = false + self.GameObject:SetActive(false) +end + +function XUiExpeditionCharProperty:UpdatePanel() + self.ExpBar.gameObject:SetActiveEx(false) + self.BtnLiberation.gameObject:SetActiveEx(false) + self.TxtCurLevel.text = self.RobotCfg.CharacterLevel + self.TxtMaxLevel.text = "/" .. XCharacterConfigs.GetCharMaxLevel(self.CharacterId) + self.TxtExp.text = "-" + self.ImgFill.fillAmount = 1 + self.CharacterAttributes = XRobotManager.GetRobotAttribs(self.RobotCfg.Id) + self.TxtAttack.text = FixToInt(self.CharacterAttributes[XNpcAttribType.AttackNormal]) + self.TxtLife.text = FixToInt(self.CharacterAttributes[XNpcAttribType.Life]) + self.TxtDefense.text = FixToInt(self.CharacterAttributes[XNpcAttribType.DefenseNormal]) + self.TxtCrit.text = FixToInt(self.CharacterAttributes[XNpcAttribType.Crit]) +end + +return XUiExpeditionCharProperty \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/RoleList/CharacterDetail/XUiExpeditionCharSkill.lua b/Resources/Scripts/XUi/XUiExpedition/RoleList/CharacterDetail/XUiExpeditionCharSkill.lua new file mode 100644 index 00000000..ce1ff275 --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/RoleList/CharacterDetail/XUiExpeditionCharSkill.lua @@ -0,0 +1,133 @@ +--虚像地平线成员列表界面:角色展示页面: 技能状态栏 + +-----------------二期功能,还没完成------------------- +local XUiExpeditionCharSkill = XClass(nil, "XUiExpeditionCharSkill") +--[[local XUiExpeditionCharSkillLevel = require("XUi/XUiExpedition/RoleList/CharacterDetail/XUiExpeditionCharSkillLevel") +local XUiExpeditionCharSkillInfo = require("XUi/XUiExpedition/RoleList/CharacterDetail/XUiExpeditionCharSkillInfo") +local MAX_SKILL_COUNT = 5]] +function XUiExpeditionCharSkill:Ctor(ui, parent) + --self.Parent = parent + --self.GameObject = ui.gameObject + --self.Transform = ui.transform + --self:InitAutoScript() + + --self.SkillInfoPanel = XUiExpeditionCharSkillInfo.New(self.PanelSkillInfo, self, self.Parent) + --self.SkillInfoPanel.GameObject:SetActive(false) + + --self.LevelDetailPanel = XUiExpeditionCharSkillLevel.New(self.PanelSkillDetails) + --self.LevelDetailPanel.GameObject:SetActive(false) +end +--[[ +-- auto +-- Automatic generation of code, forbid to edit +function XUiExpeditionCharSkill:InitAutoScript() + self:AutoInitUi() + XTool.InitUiObject(self) + self:AutoAddListener() +end + +function XUiExpeditionCharSkill:AutoInitUi() + self.PanelSkillItems = self.Transform:Find("PanelSkillItems") + self.GridSkillItem5 = self.Transform:Find("PanelSkillItems/GridSkillItem5") + self.GridSkillItem4 = self.Transform:Find("PanelSkillItems/GridSkillItem4") + self.GridSkillItem3 = self.Transform:Find("PanelSkillItems/GridSkillItem3") + self.GridSkillItem2 = self.Transform:Find("PanelSkillItems/GridSkillItem2") + self.GridSkillItem1 = self.Transform:Find("PanelSkillItems/GridSkillItem1") + self.BtnSkillTeach = self.Transform:Find("PanelSkillItems/SkillTeach/BtnSkillTeach"):GetComponent("Button") + self.PanelSkillInfo = self.Transform:Find("PanelSkillInfo") +end + +function XUiExpeditionCharSkill:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelCharSkill:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelCharSkill:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiExpeditionCharSkill:AutoAddListener() + self:RegisterClickEvent(self.BtnSkillTeach, self.OnBtnSkillTeachClick) +end +-- auto +function XUiExpeditionCharSkill:OnBtnSkillTeachClick() + XLuaUiManager.Open("UiPanelSkillTeach", self.Parent.CharacterId) +end + +function XUiExpeditionCharSkill:ShowPanel(robotCfg) + self.RobotCfg = robotCfg + self.CharacterId = self.RobotCfg.CharacterId + self.BtnSkillTeach.gameObject:SetActive(true) + self.SkillInfoPanel:HidePanel() + self.IsShow = true + self.GameObject:SetActive(true) + self:ShowSkillItemPanel() + self:UpdateSkill() +end + +function XUiExpeditionCharSkill:UpdateSkill() + local skills = XCharacterConfigs.GetCharacterSkills(self.CharacterId) + if (self.SkillGrids and #self.SkillGrids > 0) then + for i = 1, MAX_SKILL_COUNT do + self.SkillGrids[i]:SetClickCallback( + function() + self:HideSkillItemPanel() + self.BtnSkillTeach.gameObject:SetActive(false) + self.SkillInfoPanel:ShowPanel(self.CharacterId, skills, i) + end) + self.SkillGrids[i]:UpdateInfo(self.CharacterId, skills[i]) + end + else + self.SkillGrids = {} + for i = 1, MAX_SKILL_COUNT do + self.SkillGrids[i] = XUiGridSkillItem.New(self.Parent, self["GridSkillItem" .. i], skills[i], characterId, + function() + self:HideSkillItemPanel() + self.BtnSkillTeach.gameObject:SetActive(false) + self.SkillInfoPanel:ShowPanel(self.CharacterId, skills, i) + end + ) + end + end +end + +function XUiExpeditionCharSkill:OnSelectSkill(i) + local skills = XCharacterConfigs.GetCharacterSkills(self.CharacterId) + self:HideSkillItemPanel() + self.BtnSkillTeach.gameObject:SetActive(false) + self.SkillInfoPanel:ShowPanel(self.CharacterId, skills, i) +end + +function XUiPanelCharSkill:HidePanel() + self.BtnSkillTeach.gameObject:SetActive(true) + self.SkillInfoPanel:HidePanel() + self.IsShow = false + self.GameObject:SetActive(false) + self:HideSkillItemPanel() +end + +function XUiPanelCharSkill:HideSkillItemPanel() + self.PanelSkillItems.gameObject:SetActive(false) +end + +function XUiPanelCharSkill:ShowSkillItemPanel() + self.PanelSkillItems.gameObject:SetActive(true) + self.PanelSkillInfo.gameObject:SetActive(false) + self.BtnSkillTeach.gameObject:SetActive(true) + self.SkillItemsQiehuan:PlayTimelineAnimation() +end + +function XUiPanelCharSkill:ShowLevelDetail(skillId) + self.LevelDetailPanel:Refresh(self.CharacterId, skillId) + self.LevelDetailPanel.GameObject:SetActiveEx(true) +end]] + +return XUiExpeditionCharSkill \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/RoleList/CharacterDetail/XUiExpeditionViewRole.lua b/Resources/Scripts/XUi/XUiExpedition/RoleList/CharacterDetail/XUiExpeditionViewRole.lua new file mode 100644 index 00000000..c70e3a1a --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/RoleList/CharacterDetail/XUiExpeditionViewRole.lua @@ -0,0 +1,89 @@ +--虚像地平线成员列表界面:角色展示页面 +local XUiExpeditionViewRole = XLuaUiManager.Register(XLuaUi, "UiExpeditionViewRole") +local XUiExpeditionCharProperty = require("XUi/XUiExpedition/RoleList/CharacterDetail/XUiExpeditionCharProperty") +local XUiExpeditionCharSkill = require("XUi/XUiExpedition/RoleList/CharacterDetail/XUiExpeditionCharSkill") +local PANEL_INDEX = { + Property = 1, + Skill = 2, +} +local COMPONENT_NAME = "UiPanelCharProperty" +function XUiExpeditionViewRole:OnAwake() + +end + +function XUiExpeditionViewRole:OnStart(parent) + self.Parent = parent + self.CharacterId = self.Parent.CharacterId + self.RobotCfg = self.Parent.RobotCfg + self:InitChildUiInfos() + self:InitBtnTabGroup() + self.PanelPropertyButtons:SelectIndex(PANEL_INDEX.Property) + self.BtnTabSkill.gameObject:SetActiveEx(false) +end + +function XUiExpeditionViewRole:OnEnable() + self.CharacterId = self.Parent.CharacterId + self.RobotCfg = self.Parent.RobotCfg + self.Parent.CharacterList.GameObject:SetActiveEx(false) + self.Parent.ComboList.GameObject:SetActiveEx(false) +end + +function XUiExpeditionViewRole:OnDisable() + self.Parent.CharacterList.GameObject:SetActiveEx(true) + self.Parent.ComboList.GameObject:SetActiveEx(true) +end + +function XUiExpeditionViewRole:InitChildUiInfos() + self.PanelsMap = {} + self.ChildUiInitInfos = { + [PANEL_INDEX.Property] = { + ChildClass = XUiExpeditionCharProperty, + UiParent = self.PanelCharLevel, + AssetPath = XUiConfigs.GetComponentUrl(string.format(COMPONENT_NAME .. PANEL_INDEX.Property)), + }, + [PANEL_INDEX.Skill] = { + ChildClass = XUiExpeditionCharSkill, + UiParent = self.PanelCharSkill, + AssetPath = XUiConfigs.GetComponentUrl(string.format(COMPONENT_NAME .. PANEL_INDEX.Skill)), + }, + } +end + +function XUiExpeditionViewRole:InitBtnTabGroup() + local tabGroup = { + [PANEL_INDEX.Property] = self.BtnTabLevel, + --[PANEL_INDEX.Skill] = self.BtnTabSkill, + } + self.PanelPropertyButtons:Init(tabGroup, function(tabIndex) self:OnClickTabCallBack(tabIndex) end) +end + +function XUiExpeditionViewRole:OnClickTabCallBack(tabIndex) + if tabIndex == PANEL_INDEX.Property then + self.Parent:PlayAnimation("LevelBegan") + self.PreCameraType = XCharacterConfigs.XUiCharacter_Camera.LEVEL + elseif tabIndex == PANEL_INDEX.Skill then + self.PreCameraType = XCharacterConfigs.XUiCharacter_Camera.SKILL + self.Parent:PlayAnimation("SkillBegan") + end + self.SelectedIndex = tabIndex + --self:UpdateShowPanel() +end + +function XUiExpeditionViewRole:UpdateShowPanel() + self.Parent:UpdateCamera(self.PreCameraType) + local index = self.SelectedIndex + for k, panel in pairs(self.PanelsMap) do + if k ~= index then + panel:HidePanel() + end + end + + local panel = self.PanelsMap[index] + if not panel then + local childUiInfo = self.ChildUiInitInfos[index] + local ui = childUiInfo.UiParent:LoadPrefab(childUiInfo.AssetPath) + panel = childUiInfo.ChildClass.New(ui, self) + self.PanelsMap[index] = panel + end + panel:ShowPanel(self.RobotCfg) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/RoleList/EquipDetail/XUiExpeditionEquipDetail.lua b/Resources/Scripts/XUi/XUiExpedition/RoleList/EquipDetail/XUiExpeditionEquipDetail.lua new file mode 100644 index 00000000..e675cc20 --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/RoleList/EquipDetail/XUiExpeditionEquipDetail.lua @@ -0,0 +1,132 @@ +--虚像地平线成员列表装备详情 +local XUiExpeditionEquipDetail = XLuaUiManager.Register(XLuaUi, "UiExpeditionEquipDetail") +local CSTextManager = CS.XTextManager +function XUiExpeditionEquipDetail:OnAwake() + self:InitAutoScript() + XUiExpeditionEquipDetail.BtnTabIndex = XEquipConfig.EquipDetailBtnTabIndex + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) +end + +--参数isPreview为true时是装备详情预览,传templateId进来 +--characterId只有需要判断武器共鸣特效时才传 +function XUiExpeditionEquipDetail:OnStart(templateId, breakthroughTimes, level) + self.TemplateId = templateId + self.BreakThroughTime = breakthroughTimes + self.Level = level + local sceneRoot = self.UiSceneInfo.Transform + local root = self.UiModelGo.transform + self.PanelWeapon = root:FindTransform("PanelWeapon") + self.PanelWeaponPlane = sceneRoot:FindTransform("Plane") + self.PanelWeaponPlane.gameObject:SetActiveEx(false) + + self:InitTabBtnState() + + self.BtnStrengthenMax.CallBack = function() + XUiManager.TipMsg(CSTextManager.GetText("EquipStrengthenMaxLevel")) + end + self:ShowPanelRole(true) + self:OpenOneChildUi("UiExpeditionEquipDetailChild", self.TemplateId, self.BreakThroughTime, self.Level) + self:RegisterHelpBtn() +end + +function XUiExpeditionEquipDetail:OnEnable() + self:InitClassifyPanel() +end + +function XUiExpeditionEquipDetail:OnDestroy() + self.PanelWeaponPlane.gameObject:SetActiveEx(true) + if self.Resource then + CS.XResourceManager.Unload(self.Resource) + self.Resource = nil + end +end + +function XUiExpeditionEquipDetail:InitClassifyPanel() + self.FxUiLihuiChuxian01.gameObject:SetActiveEx(false) + if XDataCenter.EquipManager.IsClassifyEqualByTemplateId(self.TemplateId, XEquipConfig.Classify.Weapon) then + local resonanceCount = 0 + local modelConfig = XDataCenter.EquipManager.GetWeaponModelCfg(self.TemplateId, "UiEquipDetail", self.BreakThroughTime, resonanceCount) + if modelConfig then + XModelManager.LoadWeaponModel(modelConfig.ModelId, self.PanelWeapon, modelConfig.TransformConfig, "UiEquipDetail", nil, { gameObject = self.GameObject }) + end + self.PanelWeapon.gameObject:SetActiveEx(true) + self.ImgLihuiMask.gameObject:SetActiveEx(false) + elseif XDataCenter.EquipManager.IsClassifyEqualByTemplateId(self.TemplateId, XEquipConfig.Classify.Awareness) then + local resource = CS.XResourceManager.Load(XDataCenter.EquipManager.GetEquipLiHuiPath(self.TemplateId, self.BreakThroughTime)) + local texture = resource.Asset + self.MeshLihui.sharedMaterial:SetTexture("_MainTex", texture) + if self.Resource then + CS.XResourceManager.Unload(self.Resource) + end + self.Resource = resource + XScheduleManager.ScheduleOnce(function() + self.FxUiLihuiChuxian01.gameObject:SetActiveEx(true) + end, 500) + self.PanelWeapon.gameObject:SetActiveEx(false) + end +end + +function XUiExpeditionEquipDetail:InitTabBtnState() + self.PanelTabGroup.gameObject:SetActiveEx(false) +end + +function XUiExpeditionEquipDetail:InitAutoScript() + self:AutoAddListener() +end + +function XUiExpeditionEquipDetail:AutoAddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainClick) +end + +function XUiExpeditionEquipDetail:OnBtnBackClick() + self:Close() +end + +function XUiExpeditionEquipDetail:OnBtnMainClick() + XLuaUiManager.RunMain() +end + +function XUiExpeditionEquipDetail:RegisterHelpBtn() + local isClassifyEqual = XDataCenter.EquipManager.IsClassifyEqualByTemplateId(self.TemplateId, XEquipConfig.Classify.Weapon) + local keyStr = isClassifyEqual and "EquipWeapon" or "EquipAwareness" + self:BindHelpBtn(self.BtnHelp, keyStr) +end + +function XUiExpeditionEquipDetail:SetPanelRole() + if XArrangeConfigs.GetType(self.TemplateId) == XArrangeConfigs.Types.Weapon then + local weaponUsers = XDataCenter.EquipManager.GetWeaponUserTemplateIds(self.TemplateId) + for _, v in pairs(weaponUsers) do + local go = CS.UnityEngine.Object.Instantiate(self.PanelText, self.PaneContent) + local tmpObj = {} + tmpObj.Transform = go.transform + tmpObj.GameObject = go.gameObject + XTool.InitUiObject(tmpObj) + tmpObj.Text.text = v.Name .. "-" .. v.TradeName + self:CheckShowRoleTag(v.Id, tmpObj) + tmpObj.GameObject:SetActiveEx(true) + end + self.IsPanelRoleCanShow = weaponUsers and #weaponUsers > 0 + end +end + +function XUiExpeditionEquipDetail:ShowPanelRole(IsShow) + if XArrangeConfigs.GetType(self.TemplateId) == XArrangeConfigs.Types.Weapon and self.IsPreview then + self.PanelRole.gameObject:SetActiveEx(IsShow and self.IsPanelRoleCanShow) + else + self.PanelRole.gameObject:SetActiveEx(false) + end +end + +function XUiExpeditionEquipDetail:OnGetEvents() + return { XEventId.EVENT_ACTIVITY_ON_RESET } +end + +function XUiExpeditionEquipDetail:OnNotify(evt, ...) + local args = { ... } + if evt == XEventId.EVENT_ACTIVITY_ON_RESET then + if args[1] ~= XDataCenter.FubenManager.StageType.Expedition then return end + XLuaUiManager.RunMain() + XUiManager.TipMsg(CS.XTextManager.GetText("ExpeditionOnClose")) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/RoleList/EquipDetail/XUiExpeditionEquipDetailChild.lua b/Resources/Scripts/XUi/XUiExpedition/RoleList/EquipDetail/XUiExpeditionEquipDetailChild.lua new file mode 100644 index 00000000..161df17c --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/RoleList/EquipDetail/XUiExpeditionEquipDetailChild.lua @@ -0,0 +1,121 @@ +--虚像地平线装备详细子页面 +local XUiExpeditionEquipDetailChild = XLuaUiManager.Register(XLuaUi, "UiExpeditionEquipDetailChild") +local CsXTextManager = CS.XTextManager +local MAX_AWARENESS_ATTR_COUNT = 2 --不包括共鸣属性,最大有2条 + +function XUiExpeditionEquipDetailChild:OnAwake() + self.BtnSuitSkill.gameObject:SetActiveEx(false) + self.BtnResonanceSkill.gameObject:SetActiveEx(false) +end + +function XUiExpeditionEquipDetailChild:OnStart(equipId, breakthrough, level) + self.TemplateId = equipId + self.BreakThrough = breakthrough + self.Level = level + self:InitClassifyPanel() + self:InitEquipInfo() +end + +function XUiExpeditionEquipDetailChild:OnEnable() + self:UpdateEquipAttr() + self:UpdateEquipLevel() + self:UpdateEquipBreakThrough() + self:UpdateEquipLock() + self:UpdateEquipSkillDes() +end + +function XUiExpeditionEquipDetailChild:InitClassifyPanel() + if XDataCenter.EquipManager.IsClassifyEqualByTemplateId(self.TemplateId, XEquipConfig.Classify.Weapon) then + self.TxtTitle.text = CsXTextManager.GetText("WeaponDetailTitle") + self.PanelPainter.gameObject:SetActive(false) + else + self.TxtPainter.text = XDataCenter.EquipManager.GetEquipPainterName(self.TemplateId, self.BreakThrough) + self.PanelPainter.gameObject:SetActive(true) + self.TxtTitle.text = CsXTextManager.GetText("AwarenessDetailTitle") + end +end + +function XUiExpeditionEquipDetailChild:UpdateEquipSkillDes() + if XDataCenter.EquipManager.IsClassifyEqualByTemplateId(self.TemplateId, XEquipConfig.Classify.Weapon) then + local weaponSkillInfo = XDataCenter.EquipManager.GetOriginWeaponSkillInfo(self.TemplateId) + local noWeaponSkill = not weaponSkillInfo.Name and not weaponSkillInfo.Description + self.TxtSkillName.text = weaponSkillInfo.Name + self.TxtSkillDes.text = weaponSkillInfo.Description + self.PanelAwarenessSkillDes.gameObject:SetActive(false) + self.PanelNoAwarenessSkill.gameObject:SetActive(false) + self.PanelWeaponSkillDes.gameObject:SetActive(not noWeaponSkill) + self.PanelNoWeaponSkill.gameObject:SetActive(noWeaponSkill) + elseif XDataCenter.EquipManager.IsClassifyEqualByTemplateId(self.TemplateId, XEquipConfig.Classify.Awareness) then + local suitId = XDataCenter.EquipManager.GetSuitIdByTemplateId(self.TemplateId) + local skillDesList = XDataCenter.EquipManager.GetSuitSkillDesList(suitId) + local noSuitSkill = true + for i = 1, XEquipConfig.MAX_SUIT_SKILL_COUNT do + if skillDesList[i * 2] then + self["TxtSkillDes" .. i].text = skillDesList[i * 2] + self["TxtSkillDes" .. i].gameObject:SetActive(true) + noSuitSkill = false + else + self["TxtSkillDes" .. i].gameObject:SetActive(false) + end + end + self.PanelNoAwarenessSkill.gameObject:SetActive(noSuitSkill) + self.PanelAwarenessSkillDes.gameObject:SetActive(not noSuitSkill) + self.PanelWeaponSkillDes.gameObject:SetActive(false) + self.PanelNoWeaponSkill.gameObject:SetActive(false) + end +end + +function XUiExpeditionEquipDetailChild:UpdateEquipLock() + self.BtnUnlock.gameObject:SetActive(false) + self.BtnLock.gameObject:SetActive(false) +end + +function XUiExpeditionEquipDetailChild:UpdateEquipLevel() + local levelLimit = XEquipConfig.GetEquipBreakthroughCfg(self.TemplateId, self.BreakThrough).LevelLimit + self.TxtLevel.text = CsXTextManager.GetText("EquipLevelText", self.Level, levelLimit) +end + +function XUiExpeditionEquipDetailChild:UpdateEquipBreakThrough() + self:SetUiSprite(self.ImgBreakThrough, XEquipConfig.GetEquipBreakThroughIcon(self.BreakThrough)) +end + +function XUiExpeditionEquipDetailChild:InitEquipInfo() + local star = XDataCenter.EquipManager.GetEquipStar(self.TemplateId) + for i = 1, XEquipConfig.MAX_STAR_COUNT do + if i <= star then + self["ImgStar" .. i].gameObject:SetActive(true) + else + self["ImgStar" .. i].gameObject:SetActive(false) + end + end + + self.TxtEquipName.text = XDataCenter.EquipManager.GetEquipName(self.TemplateId) + + local equipSite = XDataCenter.EquipManager.GetEquipSiteByTemplateId(self.TemplateId) + if equipSite ~= XEquipConfig.EquipSite.Weapon then + self.RImgIcon:SetRawImage(XDataCenter.EquipManager.GetEquipIconBagPath(self.TemplateId, self.BreakThrough)) + self.TxtPos.text = "0" .. equipSite + self.PanelPos.gameObject:SetActive(true) + self.RImgType.gameObject:SetActive(false) + else + self.RImgType:SetRawImage(XEquipConfig.GetWeaponTypeIconPath(self.TemplateId)) + self.RImgType.gameObject:SetActive(true) + self.PanelPos.gameObject:SetActive(false) + end + self.PanelSpecialCharacter.gameObject:SetActive(false) +end + +function XUiExpeditionEquipDetailChild:UpdateEquipAttr() + local attrMap = XDataCenter.EquipManager.ConstructTemplateEquipAttrMap(self.TemplateId, self.BreakThrough, self.Level) + local attrCount = 1 + for _, attrInfo in pairs(attrMap) do + if attrCount > MAX_AWARENESS_ATTR_COUNT then break end + self["TxtName" .. attrCount].text = attrInfo.Name + self["TxtAttr" .. attrCount].text = attrInfo.Value + self["PanelAttr" .. attrCount].gameObject:SetActive(true) + attrCount = attrCount + 1 + end + for i = attrCount, MAX_AWARENESS_ATTR_COUNT do + self["PanelAttr" .. i].gameObject:SetActive(false) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/RoleList/XUiExpeditionEquipGrid/XUiExpeditionEquipGrid.lua b/Resources/Scripts/XUi/XUiExpedition/RoleList/XUiExpeditionEquipGrid/XUiExpeditionEquipGrid.lua new file mode 100644 index 00000000..c3cbbdd8 --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/RoleList/XUiExpeditionEquipGrid/XUiExpeditionEquipGrid.lua @@ -0,0 +1,107 @@ +--虚像地平线成员列表装备展示控件 +local XUiExpeditionEquipGrid = XClass(nil, "XUiExpeditionEquipGrid") + +function XUiExpeditionEquipGrid:Ctor(ui, clickCb, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self.ClickCb = clickCb + self:InitAutoScript() + self:SetSelected(false) +end + +function XUiExpeditionEquipGrid:Refresh(templateId, breakNum, equipSite, isWeapon, level, resonanceCount) + if self.RImgIcon and self.RImgIcon:Exist() then + self.RImgIcon:SetRawImage(XDataCenter.EquipManager.GetEquipIconBagPath(templateId, breakNum), nil, true) + end + + --通用的横条品质色 + if self.ImgQuality then + self.ImgQuality:SetSprite(XDataCenter.EquipManager.GetEquipQualityPath(templateId)) + end + + --装备专用的竖条品质色 + if self.ImgEquipQuality then + self.ImgEquipQuality:SetSprite(XDataCenter.EquipManager.GetEquipBgPath(templateId)) + end + + if self.TxtName then + self.TxtName.text = XDataCenter.EquipManager.GetEquipName(templateId) + end + + if self.TxtLevel then + self.TxtLevel.text = level + end + + if self.PanelSite and self.TxtSite then + if equipSite and not isWeapon then + self.TxtSite.text = "0" .. equipSite + self.PanelSite.gameObject:SetActiveEx(true) + else + self.PanelSite.gameObject:SetActiveEx(false) + end + end + + for i = 1, XEquipConfig.MAX_STAR_COUNT do + if self["ImgGirdStar" .. i] then + if i <= XDataCenter.EquipManager.GetEquipStar(templateId) then + self["ImgGirdStar" .. i].transform.parent.gameObject:SetActiveEx(true) + else + self["ImgGirdStar" .. i].transform.parent.gameObject:SetActiveEx(false) + end + end + end + for i = 1, XEquipConfig.MAX_RESONANCE_SKILL_COUNT do + local obj = self["ImgResonance" .. i] + if obj then + if XTool.IsNumberValid(resonanceCount) and resonanceCount >= i then + local icon = XEquipConfig.GetEquipResoanceIconPath(true) + self.RootUi:SetUiSprite(obj, icon) + obj.gameObject:SetActiveEx(true) + else + obj.gameObject:SetActiveEx(false) + end + end + end + self:UpdateBreakthrough(breakNum) +end + +function XUiExpeditionEquipGrid:SetSelected(status) + if XTool.UObjIsNil(self.ImgSelect) then + return + end + self.ImgSelect.gameObject:SetActiveEx(status) +end + +function XUiExpeditionEquipGrid:IsSelected() + return not XTool.UObjIsNil(self.ImgSelect) and self.ImgSelect.gameObject.activeSelf +end + + +function XUiExpeditionEquipGrid:UpdateBreakthrough(breakthroughNum) + if XTool.UObjIsNil(self.ImgBreakthrough) then + return + end + if breakthroughNum > 0 then + local icon = XEquipConfig.GetEquipBreakThroughSmallIcon(breakthroughNum) + if icon then + self.ImgBreakthrough:SetSprite(icon) + self.ImgBreakthrough.gameObject:SetActiveEx(true) + end + else + self.ImgBreakthrough.gameObject:SetActiveEx(false) + end +end + +function XUiExpeditionEquipGrid:InitAutoScript() + XTool.InitUiObject(self) + CsXUiHelper.RegisterClickEvent(self.BtnClick, function() self:OnBtnClickClick() end) +end + +function XUiExpeditionEquipGrid:OnBtnClickClick() + if self.ClickCb then + self.ClickCb(self.EquipId, self) + end +end + +return XUiExpeditionEquipGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/RoleList/XUiExpeditionRoleList.lua b/Resources/Scripts/XUi/XUiExpedition/RoleList/XUiExpeditionRoleList.lua new file mode 100644 index 00000000..c8aabf4e --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/RoleList/XUiExpeditionRoleList.lua @@ -0,0 +1,140 @@ +--虚像地平线成员列表页面 +local XUiExpeditionRoleList = XLuaUiManager.Register(XLuaUi, "UiExpeditionRoleList") +local XUiExpeditionRoleListCharacterList = require("XUi/XUiExpedition/RoleList/XUiExpeditionRoleListCharacterPanel/XUiExpeditionRoleListCharacterList") +local XUiExpeditionRoleListComboList = require("XUi/XUiExpedition/RoleList/XUiExpeditionRoleListComboPanel/XUiExpeditionRoleListComboList") +local CAMERA_NUM = 5 +XUiExpeditionRoleList.ChildUiName = { + UiExpeditionRoleListCharaInfo = "UiExpeditionRoleListCharaInfo", + UiExpeditionViewRole = "UiExpeditionViewRole" +} +function XUiExpeditionRoleList:OnAwake() + XTool.InitUiObject(self) + XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self:AddListener() +end + +function XUiExpeditionRoleList:OnStart() + self:OpenChild(XUiExpeditionRoleList.ChildUiName.UiExpeditionRoleListCharaInfo) + self:InitModel() + self:InitCharacterList() + self:InitComboList() +end + +function XUiExpeditionRoleList:AddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:BindHelpBtn(self.BtnHelp, "ExpeditionMainHelp") +end + +function XUiExpeditionRoleList:OnBtnBackClick() + if self.OpenChildName == XUiExpeditionRoleList.ChildUiName.UiExpeditionViewRole then + self:OpenChild(XUiExpeditionRoleList.ChildUiName.UiExpeditionRoleListCharaInfo) + self:UpdateCamera(XCharacterConfigs.XUiCharacter_Camera.MAIN) + self.TextRoleList.gameObject:SetActiveEx(true) + return + else + self:Close() + end +end + +function XUiExpeditionRoleList:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiExpeditionRoleList:Refresh(characterId, robotId, eCharaId) + self.RobotId = robotId + self.CharacterId = characterId + self.RobotCfg = XRobotManager.GetRobotTemplate(robotId) + self:UpdateModel(characterId, robotId) + self:UpdateCharaInfo(eCharaId) +end + +function XUiExpeditionRoleList:InitModel() + local root = self.UiModelGo.transform + self.PanelRoleModel = root:FindTransform("PanelRoleModel") + self.ImgEffectHuanren = root:FindTransform("ImgEffectHuanren") + self.ImgEffectHuanren1 = root:FindTransform("ImgEffectHuanren1") + self.ImgEffectLogoGouzao = root:FindTransform("ImgEffectLogoGouzao") + self.ImgEffectLogoGanran = root:FindTransform("ImgEffectLogoGanran") + self.CameraFar = { + root:FindTransform("UiCamFarLv"), + root:FindTransform("UiCamFarGrade"), + root:FindTransform("UiCamFarQuality"), + root:FindTransform("UiCamFarSkill"), + root:FindTransform("UiCamFarrExchange"), + } + self.CameraNear = { + root:FindTransform("UiCamNearLv"), + root:FindTransform("UiCamNearGrade"), + root:FindTransform("UiCamNearQuality"), + root:FindTransform("UiCamNearSkill"), + root:FindTransform("UiCamNearrExchange"), + } + self.RoleModelPanel = XUiPanelRoleModel.New(self.PanelRoleModel, self.Name, nil, true, nil, true) +end + +function XUiExpeditionRoleList:OnGetEvents() + return { XEventId.EVENT_ACTIVITY_ON_RESET } +end + +function XUiExpeditionRoleList:OnNotify(evt, ...) + local args = { ... } + if evt == XEventId.EVENT_ACTIVITY_ON_RESET then + if args[1] ~= XDataCenter.FubenManager.StageType.Expedition then return end + XLuaUiManager.RunMain() + XUiManager.TipMsg(CS.XTextManager.GetText("ExpeditionOnClose")) + end +end + +function XUiExpeditionRoleList:UpdateCamera(index) + self.CurCameraIndex = index + for i = 1, CAMERA_NUM do + if self.CurCameraIndex ~= i then + self.CameraFar[i].gameObject:SetActiveEx(false) + self.CameraNear[i].gameObject:SetActiveEx(false) + end + end + + if self.CameraFar[self.CurCameraIndex] then + self.CameraFar[self.CurCameraIndex].gameObject:SetActiveEx(true) + end + if self.CameraNear[self.CurCameraIndex] then + self.CameraNear[self.CurCameraIndex].gameObject:SetActiveEx(true) + end +end + +function XUiExpeditionRoleList:InitCharacterList() + self.CharacterList = XUiExpeditionRoleListCharacterList.New(self.PanelRoleContent, self, self.GridCharacter) +end + +function XUiExpeditionRoleList:InitComboList() + self.ComboList = XUiExpeditionRoleListComboList.New(self.SViewComboList, self) + self.ComboList:UpdateData() +end + +function XUiExpeditionRoleList:UpdateModel(characterId, robotId) + self.ImgEffectHuanren.gameObject:SetActiveEx(false) + local cb = function(model) + self.PanelDrag.Target = model.transform + self.ImgEffectHuanren.gameObject:SetActiveEx(true) + end + local robotCfg = XRobotManager.GetRobotTemplate(robotId) + self.RoleModelPanel:UpdateRobotModel(robotId, characterId, nil, robotCfg and robotCfg.FashionId, robotCfg and robotCfg.WeaponId, cb) +end + +function XUiExpeditionRoleList:UpdateCharaInfo(eCharacterId) + self.CharaInfo:UpdateView(eCharacterId) +end + +function XUiExpeditionRoleList:OpenChild(childName) + if self.OpenChildName == childName then return end + self.OpenChildName = childName + self:OpenOneChildUi(childName, self) + if childName == XUiExpeditionRoleList.ChildUiName.UiExpeditionViewRole then + self.TextRoleList.gameObject:SetActiveEx(false) + local propertyChildUi = self:FindChildUiObj(childName) + propertyChildUi:UpdateShowPanel() + end +end + +return XUiExpeditionRoleList \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/RoleList/XUiExpeditionRoleListCharaInfo/XUiExpeditionRoleListCharaInfo.lua b/Resources/Scripts/XUi/XUiExpedition/RoleList/XUiExpeditionRoleListCharaInfo/XUiExpeditionRoleListCharaInfo.lua new file mode 100644 index 00000000..64cf5c7b --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/RoleList/XUiExpeditionRoleListCharaInfo/XUiExpeditionRoleListCharaInfo.lua @@ -0,0 +1,133 @@ +--虚像地平线成员列表人物详细子页面 +local XUiExpeditionRoleListCharaInfo = XLuaUiManager.Register(XLuaUi, "UiExpeditionRoleListCharaInfo") +local XUiExpeditionEquipGrid = require("XUi/XUiExpedition/RoleList/XUiExpeditionEquipGrid/XUiExpeditionEquipGrid") +function XUiExpeditionRoleListCharaInfo:OnAwake() + self:AddListener() +end +function XUiExpeditionRoleListCharaInfo:OnStart(rootUi) + self.BtnLevelUp.gameObject:SetActive(true) + self.BtnJoin.gameObject:SetActive(false) + self.BtnSupport.gameObject:SetActive(false) + self.ImgRedPoint.gameObject:SetActive(false) + self.RootUi = rootUi + self.RootUi.CharaInfo = self + self.WearingAwarenessGrids = {} + local BtnText = self.BtnLevelUp.transform:Find("Text"):GetComponent("Text") + if BtnText then + BtnText.text = CS.XTextManager.GetText("ExpeditionRoleListRoleButtonText") + end +end + +function XUiExpeditionRoleListCharaInfo:OnEnable() + +end + +function XUiExpeditionRoleListCharaInfo:PreSetCharacterId(ECharacterId) + self.ECharacterId = ECharacterId +end + +function XUiExpeditionRoleListCharaInfo:UpdateView(eCharacterId) + self.ECharacterId = eCharacterId + self.ECharacterCfg = XExpeditionConfig.GetCharacterCfgById(eCharacterId) + self.BaseECharacterCfg = XExpeditionConfig.GetBaseCharacterCfgById(self.ECharacterCfg.BaseId) + self.CharacterId = XExpeditionConfig.GetCharacterIdByBaseId(self.ECharacterCfg.BaseId) + self.RobotId = self.ECharacterCfg.RobotId + self.RobotCfg = XRobotManager.GetRobotTemplate(self.RobotId) + local charConfig = XCharacterConfigs.GetCharacterTemplate(self.CharacterId) + self.TxtName.text = charConfig.Name + self.TxtNameOther.text = charConfig.TradeName + local jobType = XRobotManager.GetRobotJobType(self.RobotId) + self.RImgTypeIcon:SetRawImage(XCharacterConfigs.GetNpcTypeIcon(jobType)) + self.TxtLv.text = XRobotManager.GetRobotAbility(self.RobotId) + self.WeaponGrid = self.WeaponGrid or XUiExpeditionEquipGrid.New(self.GridWeapon, nil, self) + local usingWeaponId = self.RobotCfg.WeaponId + if usingWeaponId then + self.WeaponGrid:Refresh(usingWeaponId, self.RobotCfg.WeaponBeakThrough, 0, true, self.RobotCfg.WeaponLevel) + end + + for i = 1, 6 do + self.WearingAwarenessGrids[i] = self.WearingAwarenessGrids[i] or XUiExpeditionEquipGrid.New(CS.UnityEngine.Object.Instantiate(self.GridAwareness), nil, self) + self.WearingAwarenessGrids[i].Transform:SetParent(self["PanelAwareness" .. i], false) + local equipId = self.RobotCfg.WaferId[i] + if not equipId then + self.WearingAwarenessGrids[i].GameObject:SetActive(false) + self["PanelNoAwareness" .. i].gameObject:SetActive(true) + else + self.WearingAwarenessGrids[i].GameObject:SetActive(true) + self["BtnAwarenessReplace" .. i].transform:SetAsLastSibling() + self["PanelNoAwareness" .. i].gameObject:SetActive(false) + self.WearingAwarenessGrids[i]:Refresh(equipId, self.RobotCfg.WaferBreakThrough[i], i, false, self.RobotCfg.WaferLevel[i]) + end + end + + local elementList = XExpeditionConfig.GetCharacterElementByBaseId(self.ECharacterCfg.BaseId) + for i = 1, 3 do + local rImg = self["RImgCharElement" .. i] + if elementList[i] then + rImg.gameObject:SetActive(true) + local elementConfig = XExpeditionConfig.GetCharacterElementById(elementList[i]) + rImg:SetRawImage(elementConfig.Icon) + else + rImg.gameObject:SetActive(false) + end + end +end + +function XUiExpeditionRoleListCharaInfo:AddListener() + self:RegisterClickEvent(self.BtnLevelUp, self.OnBtnLevelUpClick) + self:RegisterClickEvent(self.BtnAwarenessReplace6, self.OnBtnAwarenessReplace6Click) + self:RegisterClickEvent(self.BtnAwarenessReplace5, self.OnBtnAwarenessReplace5Click) + self:RegisterClickEvent(self.BtnAwarenessReplace4, self.OnBtnAwarenessReplace4Click) + self:RegisterClickEvent(self.BtnAwarenessReplace3, self.OnBtnAwarenessReplace3Click) + self:RegisterClickEvent(self.BtnAwarenessReplace2, self.OnBtnAwarenessReplace2Click) + self:RegisterClickEvent(self.BtnAwarenessReplace1, self.OnBtnAwarenessReplace1Click) + self:RegisterClickEvent(self.BtnWeaponReplace, self.OnBtnWeaponReplaceClick) + self:RegisterClickEvent(self.BtnCareerTips, self.OnBtnCareerTipsClick) + self:RegisterClickEvent(self.BtnLevelUp, self.OnBtnLevelUpClick) + self.BtnElementDetail.CallBack = function() self:OnBtnElementDetailClick() end +end + +function XUiExpeditionRoleListCharaInfo:OnBtnAwarenessReplace5Click() + self:OnAwarenessClick(5) +end + +function XUiExpeditionRoleListCharaInfo:OnBtnAwarenessReplace4Click() + self:OnAwarenessClick(4) +end + +function XUiExpeditionRoleListCharaInfo:OnBtnAwarenessReplace3Click() + self:OnAwarenessClick(3) +end + +function XUiExpeditionRoleListCharaInfo:OnBtnAwarenessReplace2Click() + self:OnAwarenessClick(2) +end + +function XUiExpeditionRoleListCharaInfo:OnBtnAwarenessReplace1Click() + self:OnAwarenessClick(1) +end + +function XUiExpeditionRoleListCharaInfo:OnBtnAwarenessReplace6Click() + self:OnAwarenessClick(6) +end + +function XUiExpeditionRoleListCharaInfo:OnBtnLevelUpClick() + self.RootUi:OpenChild(self.RootUi.ChildUiName.UiExpeditionViewRole) +end + +function XUiExpeditionRoleListCharaInfo:OnAwarenessClick(site) + if not self.RobotCfg.WaferId[site] then return end + XLuaUiManager.Open("UiExpeditionEquipDetail", self.RobotCfg.WaferId[site], self.RobotCfg.WaferBreakThrough[site], self.RobotCfg.WaferLevel[site]) +end + +function XUiExpeditionRoleListCharaInfo:OnBtnCareerTipsClick() + XLuaUiManager.Open("UiCharacterCarerrTips") +end + +function XUiExpeditionRoleListCharaInfo:OnBtnWeaponReplaceClick() + XLuaUiManager.Open("UiExpeditionEquipDetail", self.RobotCfg.WeaponId, self.RobotCfg.WeaponBeakThrough, self.RobotCfg.WeaponLevel) +end + +function XUiExpeditionRoleListCharaInfo:OnBtnElementDetailClick() + XLuaUiManager.Open("UiCharacterElementDetail", self.CharacterId) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/RoleList/XUiExpeditionRoleListCharacterPanel/XUiExpeditionRoleListCharacterGrid.lua b/Resources/Scripts/XUi/XUiExpedition/RoleList/XUiExpeditionRoleListCharacterPanel/XUiExpeditionRoleListCharacterGrid.lua new file mode 100644 index 00000000..ac0b34a6 --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/RoleList/XUiExpeditionRoleListCharacterPanel/XUiExpeditionRoleListCharacterGrid.lua @@ -0,0 +1,66 @@ +--虚像地平线成员列表页面角色列表:角色控件 +local XUiExpeditionRoleListCharacterGrid = XClass(nil, "XUiExpeditionRoleListCharacterGrid") +function XUiExpeditionRoleListCharacterGrid:Ctor(ui, rootUi, gridIndex, onSelectCb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.RootUi = rootUi + self.GridIndex = gridIndex + self.SelectCb = onSelectCb + self:AddListener() + self.ImgInTeam.gameObject:SetActiveEx(false) + self.PanelSelected.gameObject:SetActiveEx(false) +end + +function XUiExpeditionRoleListCharacterGrid:AddListener() + self.RootUi:RegisterClickEvent(self.BtnCharacter, function() self:OnClick() end) +end + +function XUiExpeditionRoleListCharacterGrid:RefreshDatas(eChara) + if not eChara then + return + end + self.EChara = eChara + self.RImgHeadIcon:SetRawImage(self.EChara:GetSmallHeadIcon()) + self.TxtFight.text = self.EChara:GetAbility() + self.TxtLevel.text = self.EChara:GetRankStr() + self:RefreshElements() +end + +function XUiExpeditionRoleListCharacterGrid:Show() + self.GameObject:SetActiveEx(true) +end + +function XUiExpeditionRoleListCharacterGrid:Hide() + self.GameObject:SetActiveEx(false) +end + +function XUiExpeditionRoleListCharacterGrid:OnClick() + self:SetSelect(true) +end + +function XUiExpeditionRoleListCharacterGrid:SetSelect(isSelect) + if self.IsSelected == isSelect then return end + self.PanelSelected.gameObject:SetActiveEx(isSelect) + self.IsSelected = isSelect + if self.SelectCb and isSelect then + self.RootUi:Refresh(self.EChara:GetCharacterId(), self.EChara:GetRobotId(), self.EChara:GetECharaId()) + self.SelectCb(self.GridIndex) + end +end + +function XUiExpeditionRoleListCharacterGrid:RefreshElements() + local elementList = self.EChara:GetCharacterElements() + for i = 1, 3 do + local rImg = self["RImgCharElement" .. i] + if rImg and elementList[i] then + rImg.transform.gameObject:SetActiveEx(true) + local elementConfig = XExpeditionConfig.GetCharacterElementById(elementList[i]) + rImg:SetRawImage(elementConfig.Icon) + elseif rImg and not elementList[i] then + rImg.transform.gameObject:SetActiveEx(false) + end + end +end + +return XUiExpeditionRoleListCharacterGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/RoleList/XUiExpeditionRoleListCharacterPanel/XUiExpeditionRoleListCharacterList.lua b/Resources/Scripts/XUi/XUiExpedition/RoleList/XUiExpeditionRoleListCharacterPanel/XUiExpeditionRoleListCharacterList.lua new file mode 100644 index 00000000..95b7a05a --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/RoleList/XUiExpeditionRoleListCharacterPanel/XUiExpeditionRoleListCharacterList.lua @@ -0,0 +1,47 @@ +--虚像地平线成员列表页面:角色列表 +local XUiExpeditionRoleListCharacterList = XClass(nil, "XUiExpeditionRoleListCharacterList") +local XUiExpeditionRoleListCharacterGrid = require("XUi/XUiExpedition/RoleList/XUiExpeditionRoleListCharacterPanel/XUiExpeditionRoleListCharacterGrid") + +function XUiExpeditionRoleListCharacterList:Ctor(ui, rootUi, gridTemplate) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.RootUi = rootUi + self.GridTemplate = gridTemplate + self.GridTemplate.gameObject:SetActiveEx(false) + self:UpdateData() +end + +function XUiExpeditionRoleListCharacterList:UpdateData(index) + self.MemberList = XDataCenter.ExpeditionManager.GetTeam():GetDisplayTeamList() + self.CurrentSelect = index or 1 + if not self.GridCharacter then self.GridCharacter = {} end + for i = 1, #self.MemberList do + if not self.GridCharacter[i] then + local prefab = CS.UnityEngine.Object.Instantiate(self.GridTemplate.gameObject) + prefab.transform:SetParent(self.Transform, false) + self.GridCharacter[i] = XUiExpeditionRoleListCharacterGrid.New(prefab, self.RootUi, i, function(index) self:SetSelect(index) end) + end + end + for i = 1, #self.GridCharacter do + if self.MemberList[i] then + self.GridCharacter[i]:Show() + self.GridCharacter[i]:RefreshDatas(self.MemberList[i]) + else + self.GridCharacter[i]:Hide() + end + end + if self.GridCharacter[self.CurrentSelect] then + self.GridCharacter[self.CurrentSelect]:SetSelect(true) + end +end + +function XUiExpeditionRoleListCharacterList:SetSelect(index) + if self.CurrentSelect == index then return end + if self.CurrentSelect and self.GridCharacter[self.CurrentSelect] then + self.GridCharacter[self.CurrentSelect]:SetSelect(false) + end + self.CurrentSelect = index +end + +return XUiExpeditionRoleListCharacterList \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiExpedition/RoleList/XUiExpeditionRoleListComboPanel/XUiExpeditionRoleListComboList.lua b/Resources/Scripts/XUi/XUiExpedition/RoleList/XUiExpeditionRoleListComboPanel/XUiExpeditionRoleListComboList.lua new file mode 100644 index 00000000..62ccd1c2 --- /dev/null +++ b/Resources/Scripts/XUi/XUiExpedition/RoleList/XUiExpeditionRoleListComboPanel/XUiExpeditionRoleListComboList.lua @@ -0,0 +1,58 @@ +--虚像地平线成员列表页面:羁绊列表 +local XUiExpeditionRoleListComboList = XClass(nil, "XUiExpeditionRoleListComboList") +local XUiExpeditionComboGrid = require("XUi/XUiExpedition/Recruit/XUiExpeditionComboPanel/XUiExpeditionComboGrid") +function XUiExpeditionRoleListComboList:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self.GridSample = rootUi.GridCombo + self.GridSample.gameObject:SetActiveEx(false) + self.ImgEmpty = self.GameObject:FindGameObject("ImgEmpty") + self.RootUi:RegisterClickEvent(self.GameObject, self.ClickEmpty, self) + self:InitDynamicTable() +end + +function XUiExpeditionRoleListComboList:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.GameObject) + self.DynamicTable:SetProxy(XUiExpeditionComboGrid) + self.DynamicTable:SetDelegate(self) +end + +function XUiExpeditionRoleListComboList:ClickEmpty() + XLuaUiManager.Open("UiExpeditionComboTips", nil) +end + +--动态列表事件 +function XUiExpeditionRoleListComboList:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(grid.DynamicGrid.gameObject, self.RootUi) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + if self.ComboList and self.ComboList[index] then + grid:RefreshDatas(self.ComboList[index]) + end + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + if self.ComboList and self.ComboList[index] then + XLuaUiManager.Open("UiExpeditionComboTips", self.ComboList[index]) + end + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_RELOAD_COMPLETED then + XEventManager.DispatchEvent(XEventId.EVENT_GUIDE_STEP_OPEN_EVENT) + end +end + +function XUiExpeditionRoleListComboList:UpdateData() + self.ComboList = XDataCenter.ExpeditionManager.GetTeam():GetTeamComboList() + self.DynamicTable:SetDataSource(self.ComboList) + self.ImgEmpty:SetActiveEx(#self.ComboList == 0) + if #self.ComboList > 0 then + self.DynamicTable:ReloadDataASync(1) + end +end + +function XUiExpeditionRoleListComboList:OnEnable() + XEventManager.AddEventListener(XEventId.EVENT_EXPEDITION_ACTIVECOMBOLIST_CHANGE, self.UpdateData, self) +end + +function XUiExpeditionRoleListComboList:OnDisable() + XEventManager.RemoveEventListener(XEventId.EVENT_EXPEDITION_ACTIVECOMBOLIST_CHANGE, self.UpdateData, self) +end +return XUiExpeditionRoleListComboList \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFashion/XUiFashion.lua b/Resources/Scripts/XUi/XUiFashion/XUiFashion.lua new file mode 100644 index 00000000..7755d6d3 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFashion/XUiFashion.lua @@ -0,0 +1,639 @@ +local CSXTextManagerGetText = CS.XTextManager.GetText +local XUiPanelFashionList = require("XUi/XUiFashion/XUiPanelFashionList") +local stringFormat = string.format +local tableInsert = table.insert +local tableRemove = table.remove +local CameraIndex = { + Normal = 1, + Near = 2, +} +local BtnTabIndex = { + Character = 1, + Weapon = 2, +} +local LastSelectedTabIndex = BtnTabIndex.Character +local WeaponViewType = { + WithCharacter = 1, + OnlyWeapon = 2, +} +local SwitchWeaponViewType = { + [WeaponViewType.OnlyWeapon] = WeaponViewType.WithCharacter, + [WeaponViewType.WithCharacter] = WeaponViewType.OnlyWeapon, +} +local SwitchBtnName = { + [WeaponViewType.OnlyWeapon] = CSXTextManagerGetText("UiFashionBtnNameCharacter"), + [WeaponViewType.WithCharacter] = CSXTextManagerGetText("UiFashionBtnNameWeapon"), +} + +local XUiFashion = XLuaUiManager.Register(XLuaUi, "UiFashion") + +function XUiFashion:OnAwake() + self.ExpiredRefreshNameList = {} + + self.BtnLensOut.gameObject:SetActiveEx(true) + self.BtnLensIn.gameObject:SetActiveEx(false) + self.PanelUnlockShow.gameObject:SetActiveEx(false) + self.PanelAssistDistanceTip.gameObject:SetActiveEx(false) + self.GridFashion.gameObject:SetActiveEx(false) + self.GridWeapon.gameObject:SetActiveEx(false) + + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self.PanelCharacterFashionList = XUiPanelFashionList.New(XPlayerInfoConfigs.FashionType.Character, self.ScrollFashionList, function(fashionId) + self:OnSelectCharacterFashion(fashionId) + end, self) + self.PanelWeaponFashionList = XUiPanelFashionList.New(XPlayerInfoConfigs.FashionType.Weapon, self.ScrollWeaponList, function(fashionId) + self:OnSelectWeaponFashion(fashionId) + end, self) + self.PanelTagGroup:Init({ + self.BtnTogCharacter, + self.BtnTogWeapon, + }, function(tabIndex) self:OnClickTabCallBack(tabIndex) end) + + self.OnUiSceneLoadedCB = function(lastSceneUrl) self:OnUiSceneLoaded(lastSceneUrl) end + + self:AutoAddListener() +end + +function XUiFashion:OnStart(defaultCharacterId, isOnlyOneCharacter, notShowWeapon, openUiType) + self:InitSceneRoot() --设置摄像机 + + local defaultCharacterIndex = 1 + local characterList = XDataCenter.CharacterManager.GetCharacterList() + if defaultCharacterId then + self.CharacterId = defaultCharacterId + for index, character in pairs(characterList) do + if defaultCharacterId == character.Id then + defaultCharacterIndex = index + break + end + end + end + self.CharacterList = characterList + self.DefaultCharacterIndex = defaultCharacterIndex + self.CurWeaponViewType = WeaponViewType.WithCharacter + self.LastCharacterFashionSceneUrl = nil + self.IsOnlyOneCharacter = isOnlyOneCharacter + self.NotShowWeapon = notShowWeapon + self.OpenUiType = openUiType +end + +function XUiFashion:OnEnable() + CS.XGraphicManager.UseUiLightDir = true + if self.NotShowWeapon then + self.PanelTagGroup.gameObject:SetActiveEx(false) + self.PanelTagGroup:SelectIndex(BtnTabIndex.Character) + else + self.PanelTagGroup.gameObject:SetActiveEx(true) + end + self.PanelTagGroup:SelectIndex(LastSelectedTabIndex) +end + +function XUiFashion:OnDisable() + CS.XGraphicManager.UseUiLightDir = false +end + +function XUiFashion:OnGetEvents() + return { XEventId.EVENT_FASHION_WEAPON_EXPIRED_REFRESH } +end + +function XUiFashion:OnNotify(evt, ...) + if evt == XEventId.EVENT_FASHION_WEAPON_EXPIRED_REFRESH then + --过期刷新 + self:UpdateFashionList() + self:AddExpiredRefresh(...) + self:OpenTipMsg() + end +end + +function XUiFashion:AddExpiredRefresh(fashionIds) + if LastSelectedTabIndex ~= BtnTabIndex.Weapon then return end + + local characterId = self.CharacterList[self.CharacterIndex].Id + local fashionName + for _, weaponFashionId in pairs(fashionIds) do + if XDataCenter.WeaponFashionManager.IsCharacterFashion(weaponFashionId, characterId) then + fashionName = XDataCenter.WeaponFashionManager.GetWeaponFashionName(weaponFashionId) + if fashionName then + tableInsert(self.ExpiredRefreshNameList, fashionName) + end + end + end +end + +function XUiFashion:OpenTipMsg() + if next(self.ExpiredRefreshNameList) then + XUiManager.TipMsg(CSXTextManagerGetText("WeaponFashionNotOwnTipMsg", self.ExpiredRefreshNameList[1]), nil, function() + tableRemove(self.ExpiredRefreshNameList, 1) + self:OpenTipMsg() + end) + end +end + +function XUiFashion:OnUiSceneLoaded(lastSceneUrl) + if lastSceneUrl ~= self.LastCharacterFashionSceneUrl then + self:SetGameObject() + self:InitSceneRoot() + self.LastCharacterFashionSceneUrl = lastSceneUrl + end +end + +function XUiFashion:OnSelectCharacter(characterIndex) + self.CharacterIndex = characterIndex + self.CharacterId = self.CharacterList[self.CharacterIndex].Id + + local hasLast = characterIndex > 1 + self.BtnLast.interactable = hasLast + + local hasNext = self.CharacterList[characterIndex + 1] and true or false + self.BtnNext.interactable = hasNext + + self:UpdateFashionList() +end + +function XUiFashion:UpdateFashionList(selectDressing, doNotReset) + local defaultSelectId, dressedId + local haveCount, totalCount = 0, 0 + + local characterId = self.CharacterList[self.CharacterIndex].Id + if LastSelectedTabIndex == BtnTabIndex.Character then + local fashionStatus = XDataCenter.FashionManager.FashionStatus + local fashionList + if self.OpenUiType and self.OpenUiType == XUiConfigs.OpenUiType.NieRCharacterUI then + local nierCharacter = XDataCenter.NieRManager.GetSelNieRCharacter() + fashionList = nierCharacter:GetNieRFashionList() + dressedId = nierCharacter:GetNieRFashionId() + haveCount = #fashionList + else + fashionList = XDataCenter.FashionManager.GetCurrentTimeFashionByCharId(characterId) + for _, fashionId in pairs(fashionList) do + local status = XDataCenter.FashionManager.GetFashionStatus(fashionId) + if status ~= fashionStatus.UnOwned then + haveCount = haveCount + 1 + end + + if status == fashionStatus.Dressed then + dressedId = fashionId + end + end + end + totalCount = #fashionList + defaultSelectId = not selectDressing and dressedId or fashionList[1] + defaultSelectId = not doNotReset and defaultSelectId or nil + + self.PanelCharacterFashionList:UpdateViewList(fashionList, defaultSelectId) + self.PanelCharacterFashionList.GameObject:SetActiveEx(true) + self.PanelWeaponFashionList.GameObject:SetActiveEx(false) + elseif LastSelectedTabIndex == BtnTabIndex.Weapon then + local fashionStatus = XDataCenter.WeaponFashionManager.FashionStatus + local fashionList = XDataCenter.WeaponFashionManager.GetSortedWeaponFashionIdsByCharacterId(characterId) + for _, fashionId in pairs(fashionList) do + local status = XDataCenter.WeaponFashionManager.GetFashionStatus(fashionId, characterId) + if status ~= fashionStatus.UnOwned then + haveCount = haveCount + 1 + end + + -- if status == fashionStatus.Dressed then + -- defaultSelectId = fashionId + -- end + end + totalCount = #fashionList + defaultSelectId = fashionList[1] + defaultSelectId = not doNotReset and defaultSelectId or nil + + self:UpdateSceneAndModel() + + self.PanelWeaponFashionList:UpdateViewList(fashionList, defaultSelectId, characterId) + self.PanelWeaponFashionList.GameObject:SetActiveEx(true) + self.PanelCharacterFashionList.GameObject:SetActiveEx(false) + end + + self.TxtUseNumber.text = haveCount + self.TxtAllNumber.text = stringFormat("/%d", totalCount) + if self.BtnFashion then + self.BtnFashion:SetNameByGroup(0, CSXTextManagerGetText("UiFashionBtnNameFashion", haveCount, totalCount)) + end +end + +function XUiFashion:OnSelectCharacterFashion(fashionId) + self.CurFashionId = fashionId + self:UpdateSceneAndModel() + self:UpdateCamera(CameraIndex.Normal) + self:UpdateButtonState() +end + +function XUiFashion:UpdateSceneAndModel() + self:LoadModelScene() + self:UpdateCharacterModel() +end + +function XUiFashion:LoadModelScene(isDefault) + local sceneUrl = self:GetSceneUrl(isDefault) + local modelUrl = self:GetDefaultUiModelUrl() + self:LoadUiScene(sceneUrl, modelUrl, self.OnUiSceneLoadedCB, false) +end + +function XUiFashion:GetSceneUrl(isDefault) + if isDefault then + return self:GetDefaultSceneUrl() + end + + local sceneUrl + + if LastSelectedTabIndex == BtnTabIndex.Character then + sceneUrl = XDataCenter.FashionManager.GetFashionSceneUrl(self.CurFashionId) + elseif LastSelectedTabIndex == BtnTabIndex.Weapon then + sceneUrl = XDataCenter.CharacterManager.GetCharShowFashionSceneUrl(self.CharacterId) + end + + if sceneUrl and sceneUrl ~= "" then + return sceneUrl + else + return self:GetDefaultSceneUrl() + end +end + +function XUiFashion:UpdateCharacterModel() + local characterId + local func = function(model) + self.PanelDrag:GetComponent("XDrag").Target = model.transform + self:ShowImgEffectHuanren(characterId) + end + + if self.CurFashionId then + local template = XDataCenter.FashionManager.GetFashionTemplate(self.CurFashionId) + characterId = template.CharacterId + self.TxtFashionName.text = template.Name + self.RoleModelPanel:UpdateCharacterResModel(template.ResourcesId, template.CharacterId, XModelManager.MODEL_UINAME.XUiFashion, func) + self.PanelWeapon.gameObject:SetActiveEx(false) + self.RoleModelPanel.GameObject:SetActiveEx(true) + if self.IsOnlyOneCharacter then + self.BtnNext.gameObject:SetActiveEx(false) + self.BtnLast.gameObject:SetActiveEx(false) + else + self.BtnNext.gameObject:SetActiveEx(true) + self.BtnLast.gameObject:SetActiveEx(true) + end + self.PanelBtnSwitch.gameObject:SetActiveEx(false) + self:ResetPanelBtnLens() + self:UpdateFashionIntro(self.CurFashionId) + else + self.TxtFashionName.text = "" + self.PanelWeapon.gameObject:SetActiveEx(false) + self.RoleModelPanel.GameObject:SetActiveEx(false) + self.PanelBtnSwitch.gameObject:SetActiveEx(false) + self.PanelBtnLens.gameObject:SetActiveEx(false) + self.BtnNext.gameObject:SetActiveEx(false) + self.BtnLast.gameObject:SetActiveEx(false) + self.BtnUsed.gameObject:SetActiveEx(false) + self.PanelUnOwed.gameObject:SetActiveEx(false) + self.BtnUse.gameObject:SetActiveEx(false) + end +end + +function XUiFashion:UpdateButtonState() + if self.OpenUiType and self.OpenUiType == XUiConfigs.OpenUiType.NieRCharacterUI then + local nierCharacter = XDataCenter.NieRManager.GetSelNieRCharacter() + local dressedId = nierCharacter:GetNieRFashionId() + if self.CurFashionId == dressedId then + self.PanelUnOwed.gameObject:SetActiveEx(false) + self.BtnUse.gameObject:SetActiveEx(false) + self.BtnUsed.gameObject:SetActiveEx(true) + self.BtnFashionUnLock.gameObject:SetActiveEx(false) + else + self.PanelUnOwed.gameObject:SetActiveEx(false) + self.BtnUse.gameObject:SetActiveEx(true) + self.BtnUsed.gameObject:SetActiveEx(false) + self.BtnFashionUnLock.gameObject:SetActiveEx(false) + end + else + local status = XDataCenter.FashionManager.GetFashionStatus(self.CurFashionId) + local fashionStatus = XDataCenter.FashionManager.FashionStatus + if status == fashionStatus.Dressed then + self.PanelUnOwed.gameObject:SetActiveEx(false) + self.BtnUse.gameObject:SetActiveEx(false) + self.BtnUsed.gameObject:SetActiveEx(true) + self.BtnFashionUnLock.gameObject:SetActiveEx(false) + elseif status == fashionStatus.UnLock then + self.PanelUnOwed.gameObject:SetActiveEx(false) + self.BtnUse.gameObject:SetActiveEx(true) + self.BtnUsed.gameObject:SetActiveEx(false) + self.BtnFashionUnLock.gameObject:SetActiveEx(false) + elseif status == fashionStatus.Lock then + self.PanelUnOwed.gameObject:SetActiveEx(false) + self.BtnUse.gameObject:SetActiveEx(false) + self.BtnUsed.gameObject:SetActiveEx(false) + self.BtnFashionUnLock.gameObject:SetActiveEx(true) + elseif status == fashionStatus.UnOwned then + self.PanelUnOwed.gameObject:SetActiveEx(true) + self.BtnUse.gameObject:SetActiveEx(false) + self.BtnUsed.gameObject:SetActiveEx(false) + self.BtnFashionUnLock.gameObject:SetActiveEx(false) + end + end +end + +function XUiFashion:OnSelectWeaponFashion(weaponFashionId) + self.CurWeaponFashionId = weaponFashionId + self:OnSwitchWeaponViewType(true) + self:UpdateWeaponButtonState() +end + +function XUiFashion:OnSwitchWeaponViewType(doNotReset) + local oldType = self.CurWeaponViewType + local newType = not doNotReset and SwitchWeaponViewType[self.CurWeaponViewType] or oldType + self.CurWeaponViewType = newType + + if newType == WeaponViewType.WithCharacter then + self.BtnNext.gameObject:SetActiveEx(true) + self.BtnLast.gameObject:SetActiveEx(true) + + self:ResetPanelBtnLens() + self:LoadModelScene() + self:UpdateWeaponWithCharacterModel() + elseif newType == WeaponViewType.OnlyWeapon then + self.PanelBtnLens.gameObject:SetActiveEx(false) + self.BtnNext.gameObject:SetActiveEx(false) + self.BtnLast.gameObject:SetActiveEx(false) + self:LoadModelScene(true) + self:UpdateWeaponModel() + end + self:UpdateWeaponInfo() + + self.BtnSwitch:SetNameByGroup(0, SwitchBtnName[newType]) + self.PanelBtnSwitch.gameObject:SetActiveEx(true) + self.BtnFashionUnLock.gameObject:SetActiveEx(false) + + self:UpdateCamera(CameraIndex.Normal) +end + +function XUiFashion:UpdateWeaponInfo() + local characterId = self.CharacterList[self.CharacterIndex].Id + local fashionName = XDataCenter.WeaponFashionManager.GetWeaponFashionName(self.CurWeaponFashionId, characterId) + self.TxtFashionName.text = fashionName + self:UpdateFashionIntro(self.CurWeaponFashionId, characterId) +end + +function XUiFashion:UpdateFashionIntro(fashionId, characterId) + local isDefaultId = XWeaponFashionConfigs.IsDefaultId(fashionId) + if isDefaultId then + if not XDataCenter.CharacterManager.IsOwnCharacter(characterId) then + fashionId = XCharacterConfigs.GetCharacterDefaultEquipId(characterId) + else + local equipId = XDataCenter.EquipManager.GetCharacterWearingWeaponId(characterId) + fashionId = XDataCenter.EquipManager.GetEquipTemplateId(equipId) + end + end + + local desc = XGoodsCommonManager.GetGoodsDescription(fashionId) + local worldDesc = XGoodsCommonManager.GetGoodsWorldDesc(fashionId) + + if isDefaultId then + worldDesc = desc + if string.IsNilOrEmpty(worldDesc) then + local archiveCfg = XArchiveConfigs.GetWeaponSettingList(fashionId, XArchiveConfigs.SettingType.Setting) + if next(archiveCfg) then + worldDesc = archiveCfg[1].Text + end + end + desc = nil + end + + self.TxtIntroTitle.gameObject:SetActiveEx(not string.IsNilOrEmpty(desc)) + self.TxtIntroTitle.text = desc + + self.TxtIntroDesc.gameObject:SetActiveEx(not string.IsNilOrEmpty(worldDesc)) + self.TxtIntroDesc.text = worldDesc +end + +function XUiFashion:UpdateWeaponModel() + local characterId = self.CharacterList[self.CharacterIndex].Id + local uiName = XModelManager.MODEL_UINAME.XUiFashion + local modelConfig = XDataCenter.WeaponFashionManager.GetWeaponModelCfg(self.CurWeaponFashionId, characterId, uiName) + + self.RoleModelPanel.GameObject:SetActiveEx(false) + self.PanelWeapon.gameObject:SetActiveEx(true) + XModelManager.LoadWeaponModel(modelConfig.ModelId, self.PanelWeapon, modelConfig.TransformConfig, uiName, nil, { gameObject = self.GameObject }) +end + +function XUiFashion:UpdateWeaponWithCharacterModel() + local characterId = self.CharacterList[self.CharacterIndex].Id + local resourcesId = XDataCenter.FashionManager.GetFashionResourceIdByCharId(characterId) + local func = function(model) + self.PanelDrag:GetComponent("XDrag").Target = model.transform + self:ShowImgEffectHuanren(characterId) + end + + self.PanelWeapon.gameObject:SetActiveEx(false) + self.RoleModelPanel.GameObject:SetActiveEx(true) + self.RoleModelPanel:UpdateCharacterResModel(resourcesId, characterId, XModelManager.MODEL_UINAME.XUiFashion, func, nil, self.CurWeaponFashionId) +end + +function XUiFashion:UpdateWeaponButtonState() + local characterId = self.CharacterList[self.CharacterIndex].Id + local status = XDataCenter.WeaponFashionManager.GetFashionStatus(self.CurWeaponFashionId, characterId) + local fashionStatus = XDataCenter.WeaponFashionManager.FashionStatus + if status == fashionStatus.Dressed then + self.PanelUnOwed.gameObject:SetActiveEx(false) + self.BtnUse.gameObject:SetActiveEx(false) + self.BtnUsed.gameObject:SetActiveEx(true) + elseif status == fashionStatus.UnLock then + self.PanelUnOwed.gameObject:SetActiveEx(false) + self.BtnUse.gameObject:SetActiveEx(true) + self.BtnUsed.gameObject:SetActiveEx(false) + elseif status == fashionStatus.UnOwned then + self.PanelUnOwed.gameObject:SetActiveEx(true) + self.BtnUse.gameObject:SetActiveEx(false) + self.BtnUsed.gameObject:SetActiveEx(false) + end +end + +function XUiFashion:AutoAddListener() + self:RegisterClickEvent(self.BtnNext, self.OnBtnNextClick) + self:RegisterClickEvent(self.BtnLast, self.OnBtnLastClick) + self:RegisterClickEvent(self.BtnUse, self.OnBtnUseClick) + self:RegisterClickEvent(self.BtnFashionUnLock, self.OnBtnFashionUnLockClick) + self:RegisterClickEvent(self.BtnGet, self.OnBtnGetClick) + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self.BtnLensOut.CallBack = function() self:OnBtnLensOut() end + self.BtnLensIn.CallBack = function() self:OnBtnLensIn() end + self.BtnSwitch.CallBack = function() self:OnSwitchWeaponViewType() end + XUiHelper.RegisterSliderChangeEvent(self, self.SliderCharacter, self.OnSliderCharacterChanged) +end + +function XUiFashion:OnBtnFashionUnLockClick() + local fashionId = self.CurFashionId + local template = XDataCenter.FashionManager.GetFashionTemplate(fashionId) + + self.TxtUnlockFashionName.text = CSXTextManagerGetText("UiFashionUnlockName", template.Name) + self.RImgFashionIcon:SetRawImage(template.Icon) + self.ImgUnlockShowIcon.fillAmount = 0 + + local animGo = self.PanelUnlockShow + animGo.gameObject:SetActiveEx(true) + self:PlayAnimationWithMask("AniPanelUnlockShowBegin", function() + if XTool.UObjIsNil(animGo) then return end + animGo.gameObject:SetActiveEx(false) + + XDataCenter.FashionManager.UnlockFashion(fashionId, function() + local characterId = XDataCenter.FashionManager.GetCharacterId(fashionId) + local isOwnCharacter = XDataCenter.CharacterManager.IsOwnCharacter(characterId) + if isOwnCharacter then + -- 拥有该角色,替换新涂装 + XDataCenter.FashionManager.UseFashion(fashionId, + function() + XUiManager.TipText("UseSuccess") + self:UpdateFashionList(true) + end, + function() + self:UpdateFashionList(nil, true) + end, true) + end + if XTool.UObjIsNil(self.GameObject) then return end + + self:ShowImgEffectHuanren(template.CharacterId) + + self:PlayUnLockAnimation() + -- 拥有角色时,在穿戴涂装的协议回调中进行刷新 + if not isOwnCharacter then + self:UpdateFashionList(nil, true) + end + end) + end) +end + +function XUiFashion:OnBtnBackClick() + self:Close() +end + +function XUiFashion:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiFashion:OnBtnUseClick() + if LastSelectedTabIndex == BtnTabIndex.Character then + if self.OpenUiType and self.OpenUiType == XUiConfigs.OpenUiType.NieRCharacterUI then + XDataCenter.NieRManager.NieRCharacterChangeFashion(XDataCenter.NieRManager.GetSelNieRCharacter():GetNieRCharacterId(), self.CurFashionId, function() + XUiManager.TipText("UseSuccess") + self:UpdateFashionList(true) + end) + else + XDataCenter.FashionManager.UseFashion(self.CurFashionId, function() + XUiManager.TipText("UseSuccess") + self:UpdateFashionList(true) + end) + end + elseif LastSelectedTabIndex == BtnTabIndex.Weapon then + local characterId = self.CharacterList[self.CharacterIndex].Id + XDataCenter.WeaponFashionManager.UseFashion(self.CurWeaponFashionId, characterId, function() + XUiManager.TipText("UseSuccess") + self:UpdateFashionList(true) + end) + end +end + +function XUiFashion:OnBtnLastClick() + local characterIndex = self.CharacterIndex + if characterIndex > 1 then + characterIndex = characterIndex - 1 + self:OnSelectCharacter(characterIndex) + self:PlayAnimation("Qiehuan") + end +end + +function XUiFashion:OnBtnNextClick() + local characterIndex = self.CharacterIndex + if characterIndex < #self.CharacterList then + characterIndex = characterIndex + 1 + self:OnSelectCharacter(characterIndex) + self:PlayAnimation("Qiehuan") + end +end + +function XUiFashion:OnBtnGetClick() + local templateId + if LastSelectedTabIndex == BtnTabIndex.Character then + templateId = self.CurFashionId + elseif LastSelectedTabIndex == BtnTabIndex.Weapon then + templateId = self.CurWeaponFashionId + end + if not templateId then + return + end + + local showSkipList = XGoodsCommonManager.GetGoodsShowSkipId(templateId) + if showSkipList and next(showSkipList) then + XLuaUiManager.Open("UiSkip", templateId, nil, nil, showSkipList) + else + XLuaUiManager.Open("UiTip", templateId) + end +end + +function XUiFashion:OnClickTabCallBack(tabIndex) + LastSelectedTabIndex = tabIndex + self:OnSelectCharacter(self.CharacterIndex or self.DefaultCharacterIndex) +end + +function XUiFashion:OnBtnLensOut() + self.BtnLensOut.gameObject:SetActiveEx(false) + self.BtnLensIn.gameObject:SetActiveEx(true) + self:UpdateCamera(CameraIndex.Near) +end + +function XUiFashion:OnBtnLensIn() + self.BtnLensOut.gameObject:SetActiveEx(true) + self.BtnLensIn.gameObject:SetActiveEx(false) + self:UpdateCamera(CameraIndex.Normal) +end + +function XUiFashion:OnSliderCharacterChanged() + local pos = self.CameraNear[CameraIndex.Near].position + self.CameraNear[CameraIndex.Near].position = CS.UnityEngine.Vector3(pos.x, 1.7 - self.SliderCharacter.value, pos.z) +end + +function XUiFashion:InitSceneRoot() + local root = self.UiModelGo.transform + + self.RoleModelPanel = XUiPanelRoleModel.New(root:FindTransform("UiModelParent"), self.Name, nil, true, nil, true) + self.PanelWeapon = root:FindTransform("PanelWeapon") + self.ImgEffectHuanren = root:FindTransform("ImgEffectHuanren") + self.ImgEffectHuanren1 = root:FindTransform("ImgEffectHuanren1") + self.CameraNear = { + [CameraIndex.Normal] = root:FindTransform("FashionCamNearMain"), + [CameraIndex.Near] = root:FindTransform("FashionCamNearest"), + } +end + +function XUiFashion:UpdateCamera(camera) + for _, cameraIndex in pairs(CameraIndex) do + self.CameraNear[cameraIndex].gameObject:SetActiveEx(cameraIndex == camera) + end +end + +function XUiFashion:PlayUnLockAnimation() + local template = XDataCenter.FashionManager.GetFashionTemplate(self.CurFashionId) + self.TxtDistanceDesc.text = template.Name + + local animGo = self.PanelAssistDistanceTip + animGo.gameObject:SetActiveEx(true) + self:PlayAnimation("AniPanelAssistDistanceTip", function() + if XTool.UObjIsNil(animGo) then return end + animGo.gameObject:SetActiveEx(false) + end) +end + +function XUiFashion:ResetPanelBtnLens() + self.BtnLensIn.gameObject:SetActiveEx(false) + self.BtnLensOut.gameObject:SetActiveEx(true) + self.PanelBtnLens.gameObject:SetActiveEx(true) +end + +function XUiFashion:ShowImgEffectHuanren(templateId) + self.ImgEffectHuanren.gameObject:SetActiveEx(false) + self.ImgEffectHuanren1.gameObject:SetActiveEx(false) + if templateId and XCharacterConfigs.IsIsomer(templateId) then + self.ImgEffectHuanren1.gameObject:SetActiveEx(true) + else + self.ImgEffectHuanren.gameObject:SetActiveEx(true) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFashion/XUiFashionDetail.lua b/Resources/Scripts/XUi/XUiFashion/XUiFashionDetail.lua new file mode 100644 index 00000000..20a103e6 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFashion/XUiFashionDetail.lua @@ -0,0 +1,264 @@ +local CSXTextManagerGetText = CS.XTextManager.GetText +local Application = CS.UnityEngine.Application +local Platform = Application.platform +local RuntimePlatform = CS.UnityEngine.RuntimePlatform +local CameraIndex = { + Normal = 1, + Near = 2, +} + +local ViewType = { + Character = 1, + Weapon = 2, +} + +local TitleName = { + Title = { + [ViewType.Character] = CSXTextManagerGetText("UiFashionDetailTitleCharacter"), + [ViewType.Weapon] = CSXTextManagerGetText("UiFashionDetailTitleWeapon"), + }, + TipTitle = { + [ViewType.Character] = CSXTextManagerGetText("UiFashionDetailTipTitleCharacter"), + [ViewType.Weapon] = CSXTextManagerGetText("UiFashionDetailTipTitleWeapon"), + }, +} + +local XUiFashionDetail = XLuaUiManager.Register(XLuaUi, "UiFashionDetail") + +function XUiFashionDetail:OnAwake() + self:AutoAddListener() + self.BtnLensOut.gameObject:SetActiveEx(true) + self.BtnLensIn.gameObject:SetActiveEx(false) + self.PanelBtnSwich.gameObject:SetActiveEx(false) + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self.OnUiSceneLoadedCB = function() self:OnUiSceneLoaded() end +end + +function XUiFashionDetail:OnStart(fashionId, isWeaponFashion,buyData) + self:InitSceneRoot() --设置摄像机 + self.FashionId = fashionId + self.IsWeaponFashion = isWeaponFashion + self.BuyData = buyData + self:SetDetailData() +end + +function XUiFashionDetail:OnEnable() + CS.XGraphicManager.UseUiLightDir = true + if self.IsWeaponFashion then + self:LoadModelScene(true) + self:UpdateWeaponModel() + else + self:LoadModelScene(false) + self:UpdateCharacterModel() + end + self:InitBuyData() +end + +function XUiFashionDetail:OnDisable() + CS.XGraphicManager.UseUiLightDir = false +end + +function XUiFashionDetail:OnUiSceneLoaded() + self:SetGameObject() +end + +function XUiFashionDetail:InitBuyData() + self.BtnBuy.gameObject:SetActiveEx(false) + if not self.BuyData then + return + end + + self.BtnBuy.gameObject:SetActiveEx(true) + self.TxtHave.gameObject:SetActiveEx(self.BuyData.IsHave) + self.BtnBuy:SetDisable(self.BuyData.IsHave, not self.BuyData.IsHave) + self.PanelInformation.gameObject:SetActiveEx(self.BuyData.LimitText ~= nil or self.BuyData.IsHave) + + if self.BuyData.PayKeySuffix then + self.RawImageConsume.gameObject:SetActiveEx(false) + self.ImageYuan.gameObject:SetActiveEx(true) + self.BtnBuy:SetName(self:GetPayAmount(self.BuyData.PayKeySuffix)) + if self.BuyData.IsHave then + local path = CS.XGame.ClientConfig:GetString("LBBuyRiYuanIconPath1") + self.ImageYuan:SetRawImage(path) + else + local path = CS.XGame.ClientConfig:GetString("LBBuyRiYuanIconPath") + self.ImageYuan:SetRawImage(path) + end + else + self.BtnBuy:SetName(self.BuyData.ItemCount) + self.RawImageConsume.gameObject:SetActiveEx(true) + self.ImageYuan.gameObject:SetActiveEx(false) + self.RawImageConsume:SetRawImage(self.BuyData.ItemIcon) + end + + self.TxtLimitBuy.text = self.BuyData.LimitText or "" + + self.BtnBuy.CallBack = function() + self.BuyData.BuyCallBack() + self:OnBtnBackClick() + end + + --BuyData={ + -- IsHave --------是否已经拥有 + -- LimitText -------------限购提示字符串 + -- ItemIcon -------------货币Icon + -- ItemCount-------------货币数量 + -- BuyCallBack-----------购买时调用的接口 + -- } +end + +function XUiFashionDetail:GetPayAmount(PayKeySuffix) + local key + if Platform == RuntimePlatform.Android then + key = string.format("%s%s", XPayConfigs.GetPlatformConfig(1), PayKeySuffix) + else + key = string.format("%s%s", XPayConfigs.GetPlatformConfig(2), PayKeySuffix) + end + + local payConfig = XPayConfigs.GetPayTemplate(key) + return payConfig and payConfig.Amount or 0 +end + +function XUiFashionDetail:OnSliderCharacterHightChanged() + local pos = self.CameraNear[CameraIndex.Near].position + self.CameraNear[CameraIndex.Near].position = CS.UnityEngine.Vector3(pos.x, 1.7 - self.SliderCharacterHight.value, pos.z) +end + +--初始化摄像机 +function XUiFashionDetail:InitSceneRoot() + local root = self.UiModelGo.transform + + self.RoleModelPanel = XUiPanelRoleModel.New(root:FindTransform("UiModelParent"), self.Name, nil, true, nil, true) + self.PanelWeapon = root:FindTransform("PanelWeapon") + self.ImgEffectHuanren = root:FindTransform("ImgEffectHuanren") + self.CameraNear = { + [CameraIndex.Normal] = root:FindTransform("FashionCamNearMain"), + [CameraIndex.Near] = root:FindTransform("FashionCamNearest"), + } +end + +function XUiFashionDetail:UpdateCamera(camera) + for _, cameraIndex in pairs(CameraIndex) do + self.CameraNear[cameraIndex].gameObject:SetActiveEx(cameraIndex == camera) + end +end + +function XUiFashionDetail:OnBtnLensOut() + self.BtnLensOut.gameObject:SetActiveEx(false) + self.BtnLensIn.gameObject:SetActiveEx(true) + self:UpdateCamera(CameraIndex.Near) +end + +function XUiFashionDetail:OnBtnLensIn() + self.BtnLensOut.gameObject:SetActiveEx(true) + self.BtnLensIn.gameObject:SetActiveEx(false) + self:UpdateCamera(CameraIndex.Normal) +end + +function XUiFashionDetail:AutoAddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + XUiHelper.RegisterSliderChangeEvent(self, self.SliderCharacterHight, self.OnSliderCharacterHightChanged) + self.BtnLensOut.CallBack = function() self:OnBtnLensOut() end + self.BtnLensIn.CallBack = function() self:OnBtnLensIn() end +end + +function XUiFashionDetail:SetDetailData() + if (self.BuyData or {}).GiftRewardId then + if self.BuyData.GiftRewardId == 0 then + self.GridItem.gameObject:SetActiveEx(false) + self.Title.gameObject:SetActiveEx(false) + else + local rewardGood = XRewardManager.GetRewardList(self.BuyData.GiftRewardId)[1] + self.CommonGrid = XUiGridCommon.New(self, self.GridItem) + self.CommonGrid:Refresh(rewardGood) + self.Title.text = CS.XTextManager.GetText("SpecialFashionShopGiftTitle") + self.BtnClick.gameObject:SetActiveEx(true) + end + else + self.GoodsShowParams = XGoodsCommonManager.GetGoodsShowParamsByTemplateId(self.FashionId) + if self.DetailRImgIcon then + local icon = self.GoodsShowParams.Icon + if icon and #icon > 0 then + self.DetailRImgIcon:SetRawImage(icon) + end + end + if self.DetailImgQuality and self.GoodsShowParams.Quality then + XUiHelper.SetQualityIcon(self, self.DetailImgQuality, self.GoodsShowParams.Quality) + end + end + + if self.WorldDesc then + local worldDesc = XGoodsCommonManager.GetGoodsWorldDesc(self.FashionId) + if worldDesc and #worldDesc then + self.WorldDesc.text = worldDesc + end + end + if self.Desc then + local desc = XGoodsCommonManager.GetGoodsDescription(self.FashionId) + if desc and #desc > 0 then + self.Desc.text = desc + end + end +end + +function XUiFashionDetail:UpdateCharacterModel() + local template = XDataCenter.FashionManager.GetFashionTemplate(self.FashionId) + local func = function(model) + self.PanelDrag:GetComponent("XDrag").Target = model.transform + self.ImgEffectHuanren.gameObject:SetActiveEx(false) + self.ImgEffectHuanren.gameObject:SetActiveEx(true) + end + + + self.TxtTitle.text = TitleName.Title[ViewType.Character] + self.TxtTipTitle.text = TitleName.TipTitle[ViewType.Character] + self.TxtFashionName.text = template.Name + self.PanelWeapon.gameObject:SetActiveEx(false) + self.RoleModelPanel.GameObject:SetActiveEx(true) + self.PanelBtnLens.gameObject:SetActiveEx(true) + self.RoleModelPanel:UpdateCharacterResModel(template.ResourcesId, template.CharacterId, XModelManager.MODEL_UINAME.XUiFashionDetail, func) +end + +function XUiFashionDetail:UpdateWeaponModel() + local weaponFashionId = self.FashionId + local uiName = XModelManager.MODEL_UINAME.XUiFashionDetail + local modelConfig = XDataCenter.WeaponFashionManager.GetWeaponModelCfg(weaponFashionId, nil, uiName) + local fashionName = XDataCenter.WeaponFashionManager.GetWeaponFashionName(weaponFashionId) + + self.TxtTitle.text = TitleName.Title[ViewType.Weapon] + self.TxtTipTitle.text = TitleName.TipTitle[ViewType.Weapon] + self.TxtFashionName.text = fashionName + self.RoleModelPanel.GameObject:SetActiveEx(false) + self.PanelWeapon.gameObject:SetActiveEx(true) + self.PanelBtnLens.gameObject:SetActiveEx(false) + self.ImgEffectHuanren.gameObject:SetActiveEx(false) + XModelManager.LoadWeaponModel(modelConfig.ModelId, self.PanelWeapon, modelConfig.TransformConfig, uiName, nil, { gameObject = self.GameObject }) +end + +function XUiFashionDetail:OnBtnBackClick() + self:Close() +end + +function XUiFashionDetail:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiFashionDetail:LoadModelScene(isDefault) + local sceneUrl = self:GetSceneUrl(isDefault) + local modelUrl = self:GetDefaultUiModelUrl() + self:LoadUiScene(sceneUrl, modelUrl, self.OnUiSceneLoadedCB, false) +end + +function XUiFashionDetail:GetSceneUrl(isDefault) + if isDefault then + return self:GetDefaultSceneUrl() + end + + local sceneUrl = XDataCenter.FashionManager.GetFashionSceneUrl(self.FashionId) + if sceneUrl and sceneUrl ~= "" then + return sceneUrl + else + return self:GetDefaultSceneUrl() + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFashion/XUiGridFashion.lua b/Resources/Scripts/XUi/XUiFashion/XUiGridFashion.lua new file mode 100644 index 00000000..118e7ae7 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFashion/XUiGridFashion.lua @@ -0,0 +1,89 @@ +local CSUnityEngineColor = CS.UnityEngine.Color + +local XUiGridFashion = XClass(nil, "XUiGridFashion") + +function XUiGridFashion:Ctor(ui, index, clickCallback) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Index = index + self.ClickCallback = clickCallback + + XTool.InitUiObject(self) + self:SetSelect(false) +end + + +function XUiGridFashion:PlayAnimation() + if XTool.UObjIsNil(self.GridFashionTimeline) then return end + XScheduleManager.ScheduleOnce(function() + if self.GridFashionTimeline.gameObject.activeInHierarchy then + self.GridFashionTimeline:PlayTimelineAnimation() + end + end, 40) +end + +function XUiGridFashion:CheckAnimationFinish() + if not self.ImgSelected then + return + end + + local canvasGroup = self.ImgSelected:GetComponent("CanvasGroup") + if canvasGroup and canvasGroup.alpha ~= 1 then + self:PlayAnimation() + end +end + +function XUiGridFashion:SetSelect(isSelect) + if self.ImgSelected then + self.ImgSelected.gameObject:SetActiveEx(isSelect) + end +end + +function XUiGridFashion:UpdateStatus() + local status = XDataCenter.FashionManager.GetFashionStatus(self.FashionId) + + if self.OpenUiType and self.OpenUiType == XUiConfigs.OpenUiType.NieRCharacterUI then + local nieRCharacter = XDataCenter.NieRManager.GetSelNieRCharacter() + if nieRCharacter:GetNieRFashionId() == self.FashionId then + status = XDataCenter.FashionManager.FashionStatus.Dressed + else + status = XDataCenter.FashionManager.FashionStatus.UnLock + end + end + + if status == XDataCenter.FashionManager.FashionStatus.UnOwned then -- 未获得 + self.ImgLock.gameObject:SetActiveEx(true) + self.ImgUse.gameObject:SetActiveEx(false) + self.ImgRedPoint.gameObject:SetActiveEx(false) + self.RImgIcon.color = CSUnityEngineColor(1, 1, 1, 0.6) + elseif status == XDataCenter.FashionManager.FashionStatus.Dressed then --已穿戴 + self.ImgLock.gameObject:SetActiveEx(false) + self.ImgUse.gameObject:SetActiveEx(true) + self.ImgRedPoint.gameObject:SetActiveEx(false) + self.RImgIcon.color = CSUnityEngineColor(1, 1, 1, 1) + elseif status == XDataCenter.FashionManager.FashionStatus.Lock then --已获得,未解锁 + self.ImgLock.gameObject:SetActiveEx(false) + self.ImgUse.gameObject:SetActiveEx(false) + self.ImgRedPoint.gameObject:SetActiveEx(true) + self.RImgIcon.color = CSUnityEngineColor(1, 1, 1, 0.6) + elseif status == XDataCenter.FashionManager.FashionStatus.UnLock then --已解锁 + self.ImgLock.gameObject:SetActiveEx(false) + self.ImgUse.gameObject:SetActiveEx(false) + self.ImgRedPoint.gameObject:SetActiveEx(false) + self.RImgIcon.color = CSUnityEngineColor(1, 1, 1, 1) + end +end + +function XUiGridFashion:Refresh(fashionId, characterId, rootUi) + self:CheckAnimationFinish() + + self.FashionId = fashionId + self.CharacterId = characterId + self.OpenUiType = rootUi.OpenUiType + local template = XDataCenter.FashionManager.GetFashionTemplate(fashionId) + self.RImgIcon:SetRawImage(template.Icon) + + self:UpdateStatus() +end + +return XUiGridFashion \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFashion/XUiGridWeaponFashion.lua b/Resources/Scripts/XUi/XUiFashion/XUiGridWeaponFashion.lua new file mode 100644 index 00000000..996831b1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFashion/XUiGridWeaponFashion.lua @@ -0,0 +1,94 @@ +local CSUnityEngineColor = CS.UnityEngine.Color + +local XUiGridWeaponFashion = XClass(nil, "XUiGridWeaponFashion") + +function XUiGridWeaponFashion:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + self:SetSelect(false) +end + +function XUiGridWeaponFashion:PlayAnimation() + if XTool.UObjIsNil(self.GridFashionTimeline) then return end + + XScheduleManager.ScheduleOnce(function() + if self.GridFashionTimeline.gameObject.activeInHierarchy then + self.GridFashionTimeline:PlayTimelineAnimation() + end + end, 40) +end + +function XUiGridWeaponFashion:CheckAnimationFinish() + if not self.ImgSelected then + return + end + + local canvasGroup = self.ImgSelected:GetComponent("CanvasGroup") + if canvasGroup and canvasGroup.alpha ~= 1 then + self:PlayAnimation() + end +end + +function XUiGridWeaponFashion:SetSelect(isSelect) + if self.ImgSelected then + self.ImgSelected.gameObject:SetActiveEx(isSelect) + end +end + +function XUiGridWeaponFashion:Refresh(fashionId, characterId) + self.CharacterId = characterId + self.FashionId = fashionId + + self:CheckAnimationFinish() + + local icon + if XWeaponFashionConfigs.IsDefaultId(fashionId) then + local templateId + if not XDataCenter.CharacterManager.IsOwnCharacter(characterId) then + templateId = XCharacterConfigs.GetCharacterDefaultEquipId(characterId) + else + local equipId = XDataCenter.EquipManager.GetCharacterWearingWeaponId(characterId) + templateId = XDataCenter.EquipManager.GetEquipTemplateId(equipId) + end + icon = XDataCenter.EquipManager.GetEquipIconPath(templateId) + self.ImgTagDefault.gameObject:SetActiveEx(true) + else + icon = XWeaponFashionConfigs.GetFashionIcon(fashionId) + self.ImgTagDefault.gameObject:SetActiveEx(false) + end + self.RImgIcon:SetRawImage(icon) + + local weaponFashion = XDataCenter.WeaponFashionManager.GetWeaponFashion(fashionId) + if weaponFashion and weaponFashion:IsTimeLimit() then + local leftTime = weaponFashion:GetLeftTime() + self.TxtTime.text = XUiHelper.GetTime(leftTime, XUiHelper.TimeFormatType.ACTIVITY) + self.ImgTagTime.gameObject:SetActiveEx(true) + else + self.ImgTagTime.gameObject:SetActiveEx(false) + end + + self:UpdateStatus() +end + +function XUiGridWeaponFashion:UpdateStatus() + local status = XDataCenter.WeaponFashionManager.GetFashionStatus(self.FashionId, self.CharacterId) + local fashionStatus = XDataCenter.WeaponFashionManager.FashionStatus + + if status == fashionStatus.UnOwned then -- 未获得 + self.ImgLock.gameObject:SetActiveEx(true) + self.ImgUse.gameObject:SetActiveEx(false) + self.RImgIcon.color = CSUnityEngineColor(1, 1, 1, 0.6) + elseif status == fashionStatus.Dressed then --已穿戴 + self.ImgLock.gameObject:SetActiveEx(false) + self.ImgUse.gameObject:SetActiveEx(true) + self.RImgIcon.color = CSUnityEngineColor(1, 1, 1, 1) + elseif status == fashionStatus.UnLock then --已解锁 + self.ImgLock.gameObject:SetActiveEx(false) + self.ImgUse.gameObject:SetActiveEx(false) + self.RImgIcon.color = CSUnityEngineColor(1, 1, 1, 1) + end +end + +return XUiGridWeaponFashion \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFashion/XUiPanelFashionList.lua b/Resources/Scripts/XUi/XUiFashion/XUiPanelFashionList.lua new file mode 100644 index 00000000..752c4561 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFashion/XUiPanelFashionList.lua @@ -0,0 +1,59 @@ +local XUiPanelFashionList = XClass(nil, "XUiPanelFashionList") + +XUiPanelFashionList.ClassGrids = { + [XPlayerInfoConfigs.FashionType.Character] = require("XUi/XUiFashion/XUiGridFashion"), + [XPlayerInfoConfigs.FashionType.Weapon] = require("XUi/XUiFashion/XUiGridWeaponFashion"), +} + +function XUiPanelFashionList:Ctor(type, ui, gridTouchCb, rootUi) + self.Type = type + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.GridTouchCb = gridTouchCb + self.RootUi = rootUi + self:InitDynamicTable() +end + +function XUiPanelFashionList:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.GameObject) + self.DynamicTable:SetDelegate(self) + self.DynamicTable:SetProxy(XUiPanelFashionList.ClassGrids[self.Type]) +end + +function XUiPanelFashionList:UpdateViewList(fashionList, defualtSelectId, characterId) + self.CharacterId = characterId + self.FashionList = fashionList + self.LastSelectId = defualtSelectId or self.LastSelectId + self.GridTouchCb(self.LastSelectId) + self.DynamicTable:SetDataSource(fashionList) + self.DynamicTable:ReloadDataSync() +end + +function XUiPanelFashionList:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:PlayAnimation() + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local fashionId = self.FashionList[index] + grid:Refresh(fashionId, self.CharacterId, self.RootUi) + grid:PlayAnimation() + if fashionId == self.LastSelectId then + grid:SetSelect(true) + self.LastSelectGrid = grid + else + grid:SetSelect(false) + end + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + local fashionId = self.FashionList[index] + + self.LastSelectId = fashionId + if self.LastSelectGrid then + self.LastSelectGrid:SetSelect(false) + end + self.LastSelectGrid = grid + self.LastSelectGrid:SetSelect(true) + + self.GridTouchCb(fashionId) + end +end + +return XUiPanelFashionList \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFavorability/XUiFavorability.lua b/Resources/Scripts/XUi/XUiFavorability/XUiFavorability.lua new file mode 100644 index 00000000..d48e9e11 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFavorability/XUiFavorability.lua @@ -0,0 +1,283 @@ +local XUiFavorability = XLuaUiManager.Register(XLuaUi, "UiFavorability") + +local XFavorabilityType = { + UILikeMain = 1, + UILikeSwitchRole = 2, + UILikeFile = 3, + UILikePlot = 4, + UILikeGift = 5, +} + +function XUiFavorability:OnAwake() + + local root = self.UiModelGo + self.PanelCamFarrExchange = root:FindTransform("PanelCamFarrExchange") + self.PanelCamNearrExchange = root:FindTransform("PanelCamNearrExchange") + self.PanelCamFarrBegin = root:FindTransform("PanelCamFarrBegin") + self.PanelCamNearBegin = root:FindTransform("PanelCamNearrBegin") + + self:InitUiAfterAuto() +end + + +function XUiFavorability:OnStart() + self.CvType = CS.XAudioManager.CvType + self:OpenMainView(true) + + XDataCenter.FavorabilityManager.BoardMutualRequest() + + local characterId = self:GetCurrFavorabilityCharacter() + self.RedPointSwitchId = XRedPointManager.AddRedPointEvent(self.ImgReddot, nil, self, { XRedPointConditions.Types.CONDITION_FAVORABILITY_RED }, { CharacterId = characterId }) +end + +function XUiFavorability:OnEnable() + if self.SignBoard then + self.SignBoard:OnEnable() + end + self:RefreshSelectedModel() + if self.FavorabilityMain then + self.FavorabilityMain:UpdateAllInfos() + end +end + +function XUiFavorability:OnDisable() + if self.SignBoard then + self.SignBoard:OnDisable() + end +end + +function XUiFavorability:OnDestroy() + if self.SignBoard then + self.SignBoard:OnDestroy() + end + self.FavorabilityDocument:OnClose() + self.FavorabilityMain:OnClose() + self.CurrentCharacterId = nil +end + +function XUiFavorability:SetCurrFavorabilityCharacter(characterId) + self.CurrentCharacterId = characterId +end + +function XUiFavorability:GetCurrFavorabilityCharacter() + return self.CurrentCharacterId +end + +function XUiFavorability:OnGetEvents() + return { XEventId.EVENT_FAVORABILITY_MAIN_REFRESH, XEventId.EVENT_FAVORABILITY_RUMORS_PREVIEW, XEventId.EVENT_FAVORABILITY_ON_GIFT_CHANGED } +end + +function XUiFavorability:OnNotify(evt, ...) + local args = { ... } + + if evt == XEventId.EVENT_FAVORABILITY_MAIN_REFRESH then + self.FavorabilityMain:UpdateAllInfos(true) + self:OnCurrentCharacterFavorabilityLevelChanged(args[1]) + elseif evt == XEventId.EVENT_FAVORABILITY_RUMORS_PREVIEW then + self:OnPreView(args) + + elseif evt == XEventId.EVENT_FAVORABILITY_ON_GIFT_CHANGED then + self.FavorabilityMain:UpdatePreviewExp(args) + + end +end + +function XUiFavorability:OnBtnMainUIClick() + self:SetCurrFavorabilityCharacter(nil) + XLuaUiManager.RunMain() +end + +function XUiFavorability:OnBtnMaskClick() + self.PanelPreView.gameObject:SetActive(false) +end + +function XUiFavorability:InitUiAfterAuto() + local characterId = self:GetCurrFavorabilityCharacter() + characterId = (characterId == nil) and XDataCenter.DisplayManager.GetDisplayChar().Id or characterId + self:SetCurrFavorabilityCharacter(characterId) + + self.FavorabilityChangeRole = XUiPanelFavorabilityExchangeRole.New(self.PanelFavorabilityExchangeRole, self) + self.FavorabilityDocument = XUiPanelFavorabilityDocument.New(self.PanelFavorabilityDocument, self) + self.FavorabilityPlot = XUiPanelFavorabilityPlot.New(self.PanelFavorabilityPlot, self) + self.FavorabilityGift = XUiPanelLikeGiveGift.New(self.PanelFavorabilityGift, self) + + self.SignBoard = XUiPanelSignBoard.New(self.PanelFavorabilityBoard, self, XUiPanelSignBoard.SignBoardOpenType.FAVOR) + self.SignBoard.OperateTrigger = false + self.SignBoard:SetAutoPlay(false) + self.FavorabilityMain = XUiPanelFavorabilityMain.New(self.PanelFavorabilityMain, self) + + self.BtnMask.CallBack = function() self:OnBtnMaskClick() end + self.BtnSwitch.CallBack = function() self:OnBtnSwitchClick() end +end + +-- [更换模型] +function XUiFavorability:ChangeCharacterModel(templateId) + self.SignBoard:SetDisplayCharacterId(templateId) + self.SignBoard:RefreshCharacterModelById(templateId) + self.SignBoard:ResetPlayList(templateId) +end + +function XUiFavorability:RefreshSelectedModel() + local characterId = self:GetCurrFavorabilityCharacter() + characterId = (characterId == nil) and XDataCenter.DisplayManager.GetDisplayChar().Id or characterId + self:SetCurrFavorabilityCharacter(characterId) + self:ChangeCharacterModel(characterId) +end + +-- [预览] +function XUiFavorability:OnPreView(previewArgs) + if previewArgs and previewArgs[1] then + self.PanelPreView.gameObject:SetActive(true) + self:SetUiSprite(self.ImgPreview, previewArgs[1]) + end +end + +-- [标记显示的界面] +function XUiFavorability:ChangeViewType(currViewType) + self.LastViewType = self.CurrViewType + self.CurrViewType = currViewType +end + +-- [打开main:isAnim是否伴随动画] +function XUiFavorability:OpenMainView(isAnim) + self:RefreshSelectedModel() + + self.FavorabilityMain.GameObject:SetActive(true) + if isAnim then + self.FavorabilityMain:RefreshDatas() + else + self.FavorabilityMain:UpdateDatas() + end + self.LastViewType = self.CurrViewType or XFavorabilityType.UILikeMain + XRedPointManager.Check(self.RedPointSwitchId) +end + +function XUiFavorability:UpdateCamera(isChangeRoleOpen) + self.PanelCamFarrExchange.gameObject:SetActive(not isChangeRoleOpen) + self.PanelCamNearrExchange.gameObject:SetActive(isChangeRoleOpen) +end + +function XUiFavorability:UpdateBeginCamera(isOpen) + self.PanelCamFarrBegin.gameObject:SetActive(isOpen) + self.PanelCamNearBegin.gameObject:SetActive(not isOpen) +end + +-- [打开切换角色] +function XUiFavorability:OpenChangeRoleView() + self:CloseOtherViewWhenExchagneRoleOpen(self.CurrViewType) + self.FavorabilityChangeRole.GameObject:SetActive(true) + self.FavorabilityChangeRole:RefreshDatas() + self:ChangeViewType(XFavorabilityType.UILikeSwitchRole) + self:UpdateCamera(true) + self.FavorabilityMain:SetTopControlActive(false) + self:PlaySaftyAnimation("CharacterExchangeEnable") +end + +-- [关闭切换角色,回到上一个界面] +function XUiFavorability:CloseChangeRoleView() + self:PlaySaftyAnimation("CharacterExchangeDisable", function() + self.FavorabilityChangeRole.GameObject:SetActive(false) + self:OpenOtherViewWhenExchangeRoleClose(self.LastViewType) + self.FavorabilityMain:UpdateAllInfos() + self.FavorabilityMain:SetTopControlActive(true) + end) +end + +-- [打开档案界面] +function XUiFavorability:OpenInformationView() + self.FavorabilityDocument:SetViewActive(true) + self:ChangeViewType(XFavorabilityType.UILikeFile) + self.FavorabilityPlot:SetViewActive(false) + self.FavorabilityGift:SetViewActive(false) +end + +-- [打开剧情界面] +function XUiFavorability:OpenPlotView() + self.FavorabilityPlot:SetViewActive(true) + self:ChangeViewType(XFavorabilityType.UILikePlot) + self.FavorabilityDocument:SetViewActive(false) + self.FavorabilityGift:SetViewActive(false) +end + +-- [打开礼物界面] +function XUiFavorability:OpenGiftView() + self.FavorabilityGift:SetViewActive(true) + self:ChangeViewType(XFavorabilityType.UILikeGift) + self.FavorabilityDocument:SetViewActive(false) + self.FavorabilityPlot:SetViewActive(false) +end + +-- [关闭换人界面时打开上一个界面] +function XUiFavorability:OpenOtherViewWhenExchangeRoleClose(viewType) + if viewType == XFavorabilityType.UILikeFile then + self:OpenInformationView() + + elseif viewType == XFavorabilityType.UILikePlot then + self:OpenPlotView() + + elseif viewType == XFavorabilityType.UILikeGift then + self:OpenGiftView() + + end + self:OpenMainView() +end + +-- [打开换人界面时关闭其他界面]CloseOtherViewWhenExchagneRoleOpen +function XUiFavorability:CloseOtherViewWhenExchagneRoleOpen() + self.FavorabilityDocument:SetViewActive(false) + self.FavorabilityPlot:SetViewActive(false) + self.FavorabilityGift:SetViewActive(false) + self.FavorabilityMain:CloseFuncBtns() +end + +-- [切换角色] +function XUiFavorability:OnBtnSwitchClick() + self:OpenChangeRoleView() +end + +function XUiFavorability:UpdateExpFillAmount(lastLevel, lastExp, totalExp) + self.FavorabilityMain:DoFillAmountTween(lastLevel, lastExp, totalExp) +end + +function XUiFavorability:PlayCvContent(cvId) + if not self.SignBoard then return end + self.SignBoard:Stop() + local content = XFavorabilityConfigs.GetCvContentByIdAndType(cvId, self.CvType) + self.SignBoard:ShowContent(content) +end + +function XUiFavorability:StopCvContent() + if not self.SignBoard then return end + self.SignBoard:ShowContent(nil) +end + +function XUiFavorability:OnCurrentCharacterFavorabilityLevelChanged() + local characterId = self:GetCurrFavorabilityCharacter() + local favorUp = XSignBoardConfigs.GetSignBoardConfigByRoldIdAndCondition(characterId, XSignBoardEventType.FAVOR_UP) + if favorUp and favorUp[1] and (not self.SignBoard:IsPlaying()) then + self.SignBoard:ForcePlay(favorUp[1].Id) + end +end + +function XUiFavorability:PlaySubTabAnim() + self:PlaySaftyAnimation("YeMianTwo") +end + +function XUiFavorability:PlayBaseTabAnim() + self:PlaySaftyAnimation("YeMianOne") +end + +function XUiFavorability:PlaySaftyAnimation(animName, endCb, startCb) + self:PlayAnimation(animName, function() + if endCb then + endCb() + end + XLuaUiManager.SetMask(false) + end, + function() + if startCb then + startCb() + end + XLuaUiManager.SetMask(true) + end) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFavorability/XUiFavorabilityLineRoomCharacter.lua b/Resources/Scripts/XUi/XUiFavorability/XUiFavorabilityLineRoomCharacter.lua new file mode 100644 index 00000000..f831ce1c --- /dev/null +++ b/Resources/Scripts/XUi/XUiFavorability/XUiFavorabilityLineRoomCharacter.lua @@ -0,0 +1,197 @@ +local XUiFavorabilityLineRoomCharacter = XLuaUiManager.Register(XLuaUi, "UiFavorabilityLineRoomCharacter") + + +function XUiFavorabilityLineRoomCharacter:OnAwake() + self:InitUi() + + local root = self.UiModelGo.transform + self.PanelRoleModel = root:FindTransform("PanelRoleModel") + self.ImgEffectHuanren = root:FindTransform("ImgEffectHuanren") + self.ImgEffectHuanren1 = root:FindTransform("ImgEffectHuanren1") + self.ImgEffectHuanren1.gameObject:SetActive(false) + self.ImgEffectHuanren.gameObject:SetActive(false) +end + +function XUiFavorabilityLineRoomCharacter:InitUi() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self.BtnBack.CallBack = function() + self:Close() + end + + self.BtnMainUi.CallBack = function() + XLuaUiManager.RunMain() + end + + self.BtnExchange.CallBack = function() + self:OnBtnExchangeClick() + end + + self.BtnFashion.CallBack = function() + self:OnBtnFashionClick() + end + + + self.DynamicTableCharacter = XDynamicTableNormal.New(self.SViewCharacterList.gameObject) + self.DynamicTableCharacter:SetProxy(XUiGridLineCharacter) + self.DynamicTableCharacter:SetDelegate(self) + +end + +function XUiFavorabilityLineRoomCharacter:OnStart() + self.RoleModelPanel = XUiPanelRoleModel.New(self.PanelRoleModel, self.Name, nil, true) + self.Characters = self:LoadDatas() + + + local index = 1 + for i, v in ipairs(self.Characters) do + if v.Selected then + self.CurCharacter = v + index = i + break + end + end + + self.DynamicTableCharacter:SetDataSource(self.Characters) + self.DynamicTableCharacter:ReloadDataASync(index) +end + +function XUiFavorabilityLineRoomCharacter:OnEnable() + + local curAssistantId = self.CurCharacter and self.CurCharacter.Id or XDataCenter.DisplayManager.GetDisplayChar().Id + self:UpdateRoleModel(curAssistantId) + self:UpdateChangeStatus(curAssistantId) + local charType = XCharacterConfigs.GetCharacterType(curAssistantId) + if charType == 1 then + self.ImgEffectHuanren.gameObject:SetActive(false) + self.ImgEffectHuanren.gameObject:SetActive(true) + else + self.ImgEffectHuanren1.gameObject:SetActive(false) + self.ImgEffectHuanren1.gameObject:SetActive(true) + end +end + +function XUiFavorabilityLineRoomCharacter:LoadDatas() + local curAssistantId = XDataCenter.DisplayManager.GetDisplayChar().Id + + local allCharDatas = XDataCenter.CharacterManager.GetCharacterList() + local characterList = {} + for _, v in pairs(allCharDatas or {}) do + local isOwn = XDataCenter.CharacterManager.IsOwnCharacter(v.Id) + if isOwn then + table.insert(characterList, { + Id = v.Id, + TrustLv = v.TrustLv or 1, + Selected = (curAssistantId == v.Id), + }) + end + end + table.sort(characterList, function(characterA, characterB) + if characterA.TrustLv == characterB.TrustLv then + return characterA.Id < characterB.Id + end + return characterA.TrustLv > characterB.TrustLv + end) + + return characterList +end + +-- [监听动态列表事件] +function XUiFavorabilityLineRoomCharacter:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.Characters[index] + if not data then return end + grid:OnRefresh(self.Characters[index], index) + local selected = data.Selected or false + if selected then + self.CurCharacter = self.Characters[index] + self.CurCharacterGrid = grid + end + + if data.Id == XDataCenter.DisplayManager.GetDisplayChar().Id then + self.CurAssist = grid + end + + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + if not self.Characters[index] then return end + if self.CurCharacterGrid then + if self.CurCharacter then + self.CurCharacter.Selected = false + end + self.CurCharacterGrid:OnSelect() + end + self.CurCharacter = self.Characters[index] + + self.CurCharacter.Selected = true + self.CurCharacterGrid = grid + grid:OnSelect() + self:UpdateRoleModel(self.CurCharacter.Id) + + self:UpdateChangeStatus(self.CurCharacter.Id) + end +end + +function XUiFavorabilityLineRoomCharacter:UpdateChangeStatus(characterId) + local currDisplayId = XDataCenter.DisplayManager.GetDisplayChar().Id + local isOwn = XDataCenter.CharacterManager.IsOwnCharacter(characterId) + if not isOwn then + self.BtnExchange:SetButtonState(CS.UiButtonState.Disable) + return + end + local btnState = (currDisplayId ~= characterId) and CS.UiButtonState.Normal or CS.UiButtonState.Disable + self.BtnExchange:SetButtonState(btnState) + +end + +function XUiFavorabilityLineRoomCharacter:OnBtnExchangeClick() + if not self.CurCharacter then return end + local isOwn = XDataCenter.CharacterManager.IsOwnCharacter(self.CurCharacter.Id) + if not isOwn then + XUiManager.TipMsg(CS.XTextManager.GetText("FavorabilityNotOwnChar")) + return + end + + local currDisplayId = XDataCenter.DisplayManager.GetDisplayChar().Id + local characterId = self.CurCharacter.Id + if currDisplayId ~= characterId then + XDataCenter.DisplayManager.SetDisplayCharById(characterId, function() + + if self.CurAssist then + self.CurAssist:RefreshAssist() + end + + self.CurAssist = self.CurCharacterGrid + self.CurCharacterGrid:RefreshAssist() + + self:UpdateChangeStatus(characterId) + local currDisplayCharacterName = XCharacterConfigs.GetCharacterName(characterId) + local displayTips = CS.XTextManager.GetText("FavorabilitySetAssistSucc", currDisplayCharacterName) + XUiManager.TipMsg(displayTips) + end) + end +end + +function XUiFavorabilityLineRoomCharacter:OnBtnFashionClick() + if not self.CurCharacter then return end + local isOwn = XDataCenter.CharacterManager.IsOwnCharacter(self.CurCharacter.Id) + if not isOwn then + XUiManager.TipMsg(CS.XTextManager.GetText("FavorabilityNotOwnChar")) + return + end + + XLuaUiManager.Open("UiFashion", self.CurCharacter.Id) +end + +function XUiFavorabilityLineRoomCharacter:UpdateRoleModel(characterId) + local charType = XCharacterConfigs.GetCharacterType(characterId) + self.RoleModelPanel:UpdateCharacterModel(characterId, self.PanelRoleModel, XModelManager.MODEL_UINAME.XUiFavorabilityLineRoomCharacter, nil, function() + if charType == 1 then + self.ImgEffectHuanren.gameObject:SetActive(false) + self.ImgEffectHuanren.gameObject:SetActive(true) + else + self.ImgEffectHuanren1.gameObject:SetActive(false) + self.ImgEffectHuanren1.gameObject:SetActive(true) + end + end) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFavorability/XUiFavorabilityNew.lua b/Resources/Scripts/XUi/XUiFavorability/XUiFavorabilityNew.lua new file mode 100644 index 00000000..bf3dd65e --- /dev/null +++ b/Resources/Scripts/XUi/XUiFavorability/XUiFavorabilityNew.lua @@ -0,0 +1,340 @@ +local XUiFavorabilityNew = XLuaUiManager.Register(XLuaUi, "UiFavorabilityNew") + +local XFavorabilityType = { + UILikeMain = 1, + UILikeSwitchRole = 2, + UILikeFile = 3, + UILikePlot = 4, + UILikeGift = 5, +} + +local XQualityManager = CS.XQualityManager.Instance +local LowPowerValue = CS.XGame.ClientConfig:GetFloat("UiMainLowPowerValue") +local BatteryComponent = CS.XUiBattery + +function XUiFavorabilityNew:OnAwake() + local curSceneId = XDataCenter.PhotographManager.GetCurSceneId() + local curSceneTemplate = XDataCenter.PhotographManager.GetSceneTemplateById(curSceneId) + local curSceneUrl, _ = XSceneModelConfigs.GetSceneAndModelPathById(curSceneTemplate.SceneModelId) + local modelUrl = self:GetDefaultUiModelUrl() + self:LoadUiScene(curSceneUrl, modelUrl, function() self:OnUiSceneLoaded() end, false) +end + + +function XUiFavorabilityNew:OnStart() + self.CvType = CS.XAudioManager.CvType + self:OpenMainView(true) + + XDataCenter.FavorabilityManager.BoardMutualRequest() + + local characterId = self:GetCurrFavorabilityCharacter() + self.RedPointSwitchId = XRedPointManager.AddRedPointEvent(self.ImgReddot, nil, self, { XRedPointConditions.Types.CONDITION_FAVORABILITY_RED }, { CharacterId = characterId }) +end + +function XUiFavorabilityNew:OnEnable() + if self.SignBoard then + self.SignBoard:OnEnable() + end + self:RefreshSelectedModel() + if self.FavorabilityMain then + self.FavorabilityMain:UpdateAllInfos() + end +end + +function XUiFavorabilityNew:OnDisable() + if self.SignBoard then + self.SignBoard:OnDisable() + end +end + +function XUiFavorabilityNew:OnDestroy() + if self.SignBoard then + self.SignBoard:OnDestroy() + end + + self.FavorabilityMain:OnClose() + self.CurrentCharacterId = nil +end + +function XUiFavorabilityNew:SetCurrFavorabilityCharacter(characterId) + self.CurrentCharacterId = characterId +end + +function XUiFavorabilityNew:GetCurrFavorabilityCharacter() + return self.CurrentCharacterId +end + +function XUiFavorabilityNew:OnGetEvents() + return { XEventId.EVENT_FAVORABILITY_MAIN_REFRESH, XEventId.EVENT_FAVORABILITY_RUMORS_PREVIEW, XEventId.EVENT_FAVORABILITY_ON_GIFT_CHANGED } +end + +function XUiFavorabilityNew:OnNotify(evt, ...) + local args = { ... } + + if evt == XEventId.EVENT_FAVORABILITY_MAIN_REFRESH then + self.FavorabilityMain:UpdateAllInfos(true) + self:OnCurrentCharacterFavorabilityLevelChanged(args[1]) + elseif evt == XEventId.EVENT_FAVORABILITY_RUMORS_PREVIEW then + self:OnPreView(args) + + elseif evt == XEventId.EVENT_FAVORABILITY_ON_GIFT_CHANGED then + self.FavorabilityMain:UpdatePreviewExp(args) + + end +end + +function XUiFavorabilityNew:OnBtnMainUIClick() + self:SetCurrFavorabilityCharacter(nil) + XLuaUiManager.RunMain() +end + +function XUiFavorabilityNew:OnBtnMaskClick() + self.PanelPreView.gameObject:SetActiveEx(false) +end + +function XUiFavorabilityNew:InitUiAfterAuto() + local characterId = self:GetCurrFavorabilityCharacter() + characterId = (characterId == nil) and XDataCenter.DisplayManager.GetDisplayChar().Id or characterId + self:SetCurrFavorabilityCharacter(characterId) + + self.FavorabilityChangeRole = XUiPanelFavorabilityExchangeRole.New(self.PanelFavorabilityExchangeRole, self) + self.SignBoard = XUiPanelSignBoard.New(self.PanelFavorabilityBoard, self, XUiPanelSignBoard.SignBoardOpenType.FAVOR) + self.SignBoard.OperateTrigger = false + self.SignBoard:SetAutoPlay(true) + self.FavorabilityMain = XUiPanelFavorabilityMain.New(self.PanelFavorabilityMain, self) + + self.BtnMask.CallBack = function() self:OnBtnMaskClick() end + self.BtnSwitch.CallBack = function() self:OnBtnSwitchClick() end +end + +function XUiFavorabilityNew:PlayChangeActionEffect() + if self.ChangeActionEffect and self.WhetherPlayChangeActionEffect then + self.ChangeActionEffect.gameObject:SetActiveEx(false) + self.ChangeActionEffect.gameObject:SetActiveEx(true) + end + self.WhetherPlayChangeActionEffect = false +end + +function XUiFavorabilityNew:SetWhetherPlayChangeActionEffect(value) + self.WhetherPlayChangeActionEffect = value +end + +-- [更换模型] +function XUiFavorabilityNew:ChangeCharacterModel(templateId) + self.SignBoard:SetDisplayCharacterId(templateId) + self.SignBoard:RefreshCharacterModelById(templateId) + self.SignBoard:ResetPlayList(templateId) +end + +function XUiFavorabilityNew:RefreshSelectedModel() + local characterId = self:GetCurrFavorabilityCharacter() + characterId = (characterId == nil) and XDataCenter.DisplayManager.GetDisplayChar().Id or characterId + self:SetCurrFavorabilityCharacter(characterId) + self:ChangeCharacterModel(characterId) +end + +-- [预览] +function XUiFavorabilityNew:OnPreView(previewArgs) + if previewArgs and previewArgs[1] then + self.PanelPreView.gameObject:SetActiveEx(true) + self:SetUiSprite(self.ImgPreview, previewArgs[1]) + end +end + +-- [标记显示的界面] +function XUiFavorabilityNew:ChangeViewType(currViewType) + self.LastViewType = self.CurrViewType + self.CurrViewType = currViewType +end + +-- [打开main:isAnim是否伴随动画] +function XUiFavorabilityNew:OpenMainView(isAnim) + self:RefreshSelectedModel() + + self.FavorabilityMain.GameObject:SetActiveEx(true) + if isAnim then + self.FavorabilityMain:RefreshDatas() + else + self.FavorabilityMain:UpdateDatas() + end + self.LastViewType = self.CurrViewType or XFavorabilityType.UILikeMain + local characterId = self:GetCurrFavorabilityCharacter() + XRedPointManager.Check(self.RedPointSwitchId, { CharacterId = characterId }) +end + +function XUiFavorabilityNew:UpdateCamera(isChangeRoleOpen) + self.PanelCamFarMain.gameObject:SetActiveEx(true) + self.PanelCamFarrExchange.gameObject:SetActiveEx(not isChangeRoleOpen) + self.PanelCamNearrExchange.gameObject:SetActiveEx(isChangeRoleOpen) +end + +function XUiFavorabilityNew:UpdateBeginCamera(isOpen) + self.PanelCamFarrBegin.gameObject:SetActiveEx(isOpen) + self.PanelCamNearBegin.gameObject:SetActiveEx(not isOpen) +end + +-- [打开切换角色] +function XUiFavorabilityNew:OpenChangeRoleView() + self:CloseOtherViewWhenExchagneRoleOpen(self.CurrViewType) + self.FavorabilityChangeRole.GameObject:SetActiveEx(true) + self.FavorabilityChangeRole:RefreshDatas() + self:ChangeViewType(XFavorabilityType.UILikeSwitchRole) + self:UpdateCamera(true) + self.FavorabilityMain:SetTopControlActive(false) + self:PlaySaftyAnimation("CharacterExchangeEnable") +end + +-- [关闭切换角色,回到上一个界面] +function XUiFavorabilityNew:CloseChangeRoleView() + self:SetWhetherPlayChangeActionEffect(false) + self:PlaySaftyAnimation("CharacterExchangeDisable", function() + self.FavorabilityChangeRole.GameObject:SetActiveEx(false) + self:OpenOtherViewWhenExchangeRoleClose(self.LastViewType) + -- self.FavorabilityMain:UpdateAllInfos() + self.FavorabilityMain:SetTopControlActive(true) + end) +end + +-- [打开档案界面] +function XUiFavorabilityNew:OpenInformationView() + self:ChangeViewType(XFavorabilityType.UILikeFile) +end + +-- [打开剧情界面] +function XUiFavorabilityNew:OpenPlotView() + self:ChangeViewType(XFavorabilityType.UILikePlot) +end + +-- [打开礼物界面] +function XUiFavorabilityNew:OpenGiftView() + self:ChangeViewType(XFavorabilityType.UILikeGift) +end + +-- [关闭换人界面时打开上一个界面] +function XUiFavorabilityNew:OpenOtherViewWhenExchangeRoleClose() + self.FavorabilityMain:OpenFuncBtns() + self:OpenMainView() +end + +-- [打开换人界面时关闭其他界面]CloseOtherViewWhenExchagneRoleOpen +function XUiFavorabilityNew:CloseOtherViewWhenExchagneRoleOpen() + self.FavorabilityMain:CloseFuncBtns() +end + +-- [切换角色] +function XUiFavorabilityNew:OnBtnSwitchClick() + self:SetWhetherPlayChangeActionEffect(false) + self:StopCvContent() + self:OpenChangeRoleView() +end + +function XUiFavorabilityNew:PlayCvContent(cvId, cvType) + + if not self.SignBoard then return end + self.SignBoard:Stop() + self.SignBoard:Freeze() + local content = XFavorabilityConfigs.GetCvContentByIdAndType(cvId, cvType) + self.SignBoard:ShowContent(content) +end + +function XUiFavorabilityNew:StopCvContent() + if not self.SignBoard then return end + self.SignBoard:CvStop() +end + +function XUiFavorabilityNew:PauseCvContent() + if not self.SignBoard then return end + self.SignBoard:Freeze() +end + +function XUiFavorabilityNew:ResumeCvContent() + if not self.SignBoard then return end + self.SignBoard:Resume() +end + +function XUiFavorabilityNew:OnCurrentCharacterFavorabilityLevelChanged() + local characterId = self:GetCurrFavorabilityCharacter() + local favorUp = XSignBoardConfigs.GetSignBoardConfigByRoldIdAndCondition(characterId, XSignBoardEventType.FAVOR_UP) + if favorUp and favorUp[1] and (not self.SignBoard:IsPlaying()) then + self.SignBoard:ForcePlay(favorUp[1].Id) + end +end + +function XUiFavorabilityNew:PlaySubTabAnim() + --self:PlaySaftyAnimation("YeMianTwo") +end + +function XUiFavorabilityNew:PlayBaseTabAnim() + --self:PlaySaftyAnimation("YeMianOne") +end + +function XUiFavorabilityNew:PlaySaftyAnimation(animName, endCb, startCb) + self:PlayAnimation(animName, function() + if endCb then + endCb() + end + XLuaUiManager.SetMask(false) + end, + function() + if startCb then + startCb() + end + XLuaUiManager.SetMask(true) + end) +end + +function XUiFavorabilityNew:OnUiSceneLoaded() + self:SetGameObject() + local root = self.UiModelGo + self.PanelCamFarrExchange = self:FindVirtualCamera("PanelCamFarrExchange") + self.PanelCamNearrExchange = self:FindVirtualCamera("PanelCamNearrExchange") + self.PanelCamFarMain = self:FindVirtualCamera("CamFarMain") + self.PanelCamFarrBegin = self:FindVirtualCamera("PanelCamFarrBegin") + self.PanelCamNearBegin = self:FindVirtualCamera("PanelCamNearrBegin") + self.ChangeActionEffect = self:FindVirtualCamera("ChangeActionEffect") + self:InitUiAfterAuto() + self:UpdateCamera() + self:UpdateBatteryMode() +end + +function XUiFavorabilityNew:UpdateBatteryMode() -- editor模式下 BatteryComponent.BatteryLevel 默认值为-1 + if XQualityManager.IsSimulator and not BatteryComponent.DebugMode then + return + end + + local animationRoot = self.UiSceneInfo.Transform:Find("Animations") + local toChargeTimeLine = animationRoot:Find("ToChargeTimeLine") + local toFullTimeLine = animationRoot:Find("ToFullTimeLine") + local fullTimeLine = animationRoot:Find("FullTimeLine") + local chargeTimeLine = animationRoot:Find("ChargeTimeLine") + + toChargeTimeLine.gameObject:SetActiveEx(false) + toFullTimeLine.gameObject:SetActiveEx(false) + fullTimeLine.gameObject:SetActiveEx(false) + chargeTimeLine.gameObject:SetActiveEx(false) + + local curSelectSceneId = XDataCenter.PhotographManager.GetCurSceneId() + local particleGroupName = XDataCenter.PhotographManager.GetSceneTemplateById(curSelectSceneId).ParticleGroupName + local chargeAnimator = nil + if particleGroupName and particleGroupName ~= "" then + local chargeAnimatorTrans = self.UiSceneInfo.Transform:FindTransform(particleGroupName) + if chargeAnimatorTrans then + chargeAnimator = chargeAnimatorTrans:GetComponent("Animator") + else + XLog.Error("Can't Find \""..particleGroupName.."\", Plase Check \"ParticleGroupName\" In Share/PhotoMode/Background.tab") + end + end + + if BatteryComponent.IsCharging then --充电状态 + if chargeAnimator then chargeAnimator:Play("Full") end + fullTimeLine.gameObject:SetActiveEx(true) + else + if BatteryComponent.BatteryLevel > LowPowerValue then -- 比较电量 + if chargeAnimator then chargeAnimator:Play("Full") end + fullTimeLine.gameObject:SetActiveEx(true) + else + if chargeAnimator then chargeAnimator:Play("Low") end + chargeTimeLine.gameObject:SetActiveEx(true) + end + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFavorability/XUiGridLikeActionItem.lua b/Resources/Scripts/XUi/XUiFavorability/XUiGridLikeActionItem.lua new file mode 100644 index 00000000..562003be --- /dev/null +++ b/Resources/Scripts/XUi/XUiFavorability/XUiGridLikeActionItem.lua @@ -0,0 +1,94 @@ +XUiGridLikeActionItem = XClass(nil, "XUiGridLikeActionItem") + +local alphaSinScale = 10 + +function XUiGridLikeActionItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiGridLikeActionItem:Init(uiRoot) + self.UiRoot = uiRoot +end + +function XUiGridLikeActionItem:OnRefresh(actionData) + self.ActionData = actionData + local characterId = self.UiRoot:GetCurrFavorabilityCharacter() + local isUnlock = XDataCenter.FavorabilityManager.IsActionUnlock(characterId, self.ActionData.Id) + local canUnlock = XDataCenter.FavorabilityManager.CanActionUnlock(characterId, self.ActionData.Id) + + self.CurrentState = XFavorabilityConfigs.InfoState.Normal + if not isUnlock then + if canUnlock then + self.CurrentState = XFavorabilityConfigs.InfoState.Available + else + self.CurrentState = XFavorabilityConfigs.InfoState.Lock + end + end + + if canUnlock then + self:UpdatePlayStatus() + else + self:HidePlayStatus() + end + + self:UpdateNormalStatus(self.CurrentState == XFavorabilityConfigs.InfoState.Normal or self.CurrentState == XFavorabilityConfigs.InfoState.Available) + self:UpdateAvailableStatus(self.CurrentState == XFavorabilityConfigs.InfoState.Available) + self:UpdateLockStatus(self.CurrentState == XFavorabilityConfigs.InfoState.Lock) + self.ImgCurProgress.fillAmount = 0 +end + +function XUiGridLikeActionItem:UpdatePlayStatus() + local isPlay = self.ActionData.IsPlay or false + self.IconPlay.gameObject:SetActiveEx(not isPlay) + self.IconPause.gameObject:SetActiveEx(isPlay) + self.IconAction.gameObject:SetActiveEx(isPlay) + self.IconActionCanvasGroup.alpha = 0 +end + +function XUiGridLikeActionItem:HidePlayStatus() + self.IconPlay.gameObject:SetActiveEx(false) + self.IconPause.gameObject:SetActiveEx(false) + self.IconAction.gameObject:SetActiveEx(false) +end + +function XUiGridLikeActionItem:UpdateNormalStatus(isNormal) + self.ActionNor.gameObject:SetActiveEx(isNormal) + if isNormal and self.ActionData then + local currentCharacterId = self.UiRoot:GetCurrFavorabilityCharacter() + self.TxtTitle.text = self.ActionData.Name + self.RawImage:SetRawImage(XDataCenter.CharacterManager.GetCharSmallHeadIcon(currentCharacterId)) + end +end + +function XUiGridLikeActionItem:UpdateAvailableStatus(isAvailable) + self.ImgRedDot.gameObject:SetActiveEx(isAvailable) +end + +function XUiGridLikeActionItem:HideRedDot() + self.ImgRedDot.gameObject:SetActiveEx(false) +end + +function XUiGridLikeActionItem:UpdateLockStatus(isLock) + self.ActionLock.gameObject:SetActiveEx(isLock) + if isLock and self.ActionData then + self.TxtLockTitle.text = self.ActionData.Name + self.TxtLock.text = self.ActionData.ConditionDescript + end +end + +function XUiGridLikeActionItem:UpdateProgress(progress) + progress = (progress >= 1) and 1 or progress + self.ImgCurProgress.fillAmount = progress +end + +function XUiGridLikeActionItem:UpdateActionAlpha(count) + local alpha = math.sin(count / alphaSinScale) + self.IconActionCanvasGroup.alpha = alpha +end + +function XUiGridLikeActionItem:GetActionDataId() + if not self.ActionData then return 0 end + return self.ActionData.Id +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFavorability/XUiGridLikeAudioItem.lua b/Resources/Scripts/XUi/XUiFavorability/XUiGridLikeAudioItem.lua new file mode 100644 index 00000000..2f0c5b0e --- /dev/null +++ b/Resources/Scripts/XUi/XUiFavorability/XUiGridLikeAudioItem.lua @@ -0,0 +1,99 @@ +XUiGridLikeAudioItem = XClass(nil, "XUiGridLikeAudioItem") +local alphaSinScale = 10 + +function XUiGridLikeAudioItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiGridLikeAudioItem:Init(uiRoot) + self.UiRoot = uiRoot +end + +function XUiGridLikeAudioItem:OnRefresh(audioData) + self.AudioData = audioData + local characterId = self.UiRoot:GetCurrFavorabilityCharacter() + local isUnlock = XDataCenter.FavorabilityManager.IsVoiceUnlock(characterId, self.AudioData.Id) + local canUnlock = XDataCenter.FavorabilityManager.CanVoiceUnlock(characterId, self.AudioData.Id) + + self.CurrentState = XFavorabilityConfigs.InfoState.Normal + if not isUnlock then + if canUnlock then + self.CurrentState = XFavorabilityConfigs.InfoState.Available + else + self.CurrentState = XFavorabilityConfigs.InfoState.Lock + end + end + + if canUnlock then + self:UpdatePlayStatus() + else + self:HidePlayStatus() + end + + self:UpdateNormalStatus(self.CurrentState == XFavorabilityConfigs.InfoState.Normal or self.CurrentState == XFavorabilityConfigs.InfoState.Available) + self:UpdateAvailableStatus(self.CurrentState == XFavorabilityConfigs.InfoState.Available) + self:UpdateLockStatus(self.CurrentState == XFavorabilityConfigs.InfoState.Lock) + + self.ImgCurProgress.fillAmount = 0 + +end + +function XUiGridLikeAudioItem:HidePlayStatus() + self.IconPlay.gameObject:SetActiveEx(false) + self.IconPause.gameObject:SetActiveEx(false) + self.IconMicro.gameObject:SetActiveEx(false) +end + +function XUiGridLikeAudioItem:UpdatePlayStatus() + local isPlay = self.AudioData.IsPlay or false + self.IconPlay.gameObject:SetActiveEx(not isPlay) + self.IconPause.gameObject:SetActiveEx(isPlay) + self.IconMicro.gameObject:SetActiveEx(isPlay) + self.IconMicroCanvasGroup.alpha = 0 +end + +function XUiGridLikeAudioItem:UpdateNormalStatus(isNormal) + self.AudioNor.gameObject:SetActiveEx(isNormal) + if isNormal and self.AudioData then + local currentCharacterId = self.UiRoot:GetCurrFavorabilityCharacter() + self.TxtTitle.text = self.AudioData.Name + self.ImgIcon:SetRawImage(XDataCenter.CharacterManager.GetCharSmallHeadIcon(currentCharacterId)) + + end +end + +function XUiGridLikeAudioItem:UpdateAvailableStatus(isAvailable) + self.ImgRedDot.gameObject:SetActiveEx(isAvailable) +end + +function XUiGridLikeAudioItem:HideRedDot() + self.ImgRedDot.gameObject:SetActiveEx(false) +end + +function XUiGridLikeAudioItem:UpdateLockStatus(isLock) + self.AudioLock.gameObject:SetActiveEx(isLock) + if isLock and self.AudioData then + self.TxtLockTitle.text = self.AudioData.Name + self.TxtLock.text = self.AudioData.ConditionDescript + end +end + +function XUiGridLikeAudioItem:UpdateProgress(progress) + progress = (progress >= 1) and 1 or progress + self.ImgCurProgress.fillAmount = progress +end + +function XUiGridLikeAudioItem:UpdateMicroAlpha(count) + local alpha = math.sin(count / alphaSinScale) + + self.IconMicroCanvasGroup.alpha = alpha +end + +function XUiGridLikeAudioItem:GetAudioDataId() + if not self.AudioData then return 0 end + return self.AudioData.Id +end + +return XUiGridLikeAudioItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFavorability/XUiGridLikeInfoItem.lua b/Resources/Scripts/XUi/XUiFavorability/XUiGridLikeInfoItem.lua new file mode 100644 index 00000000..ee9190a2 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFavorability/XUiGridLikeInfoItem.lua @@ -0,0 +1,113 @@ +XUiGridLikeInfoItem = XClass(nil, "XUiGridLikeInfoItem") + +local ArrowDown = CS.UnityEngine.Vector3.one +local ArrowUp = CS.UnityEngine.Vector3(1, -1, 1) +local ImgContentSize = CS.UnityEngine.Vector2.zero +local ItemContentSize = CS.UnityEngine.Vector2.zero + +function XUiGridLikeInfoItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + + self:InitUiAfterAuto() +end + +function XUiGridLikeInfoItem:Init(uiRoot) + self.UiRoot = uiRoot +end + +function XUiGridLikeInfoItem:InitUiAfterAuto() + self.ImgArrowTransform = self.ImgArrow.transform + self.ImgArrowTransform.localScale = ArrowDown + self.ImgContentTransform = self.ImgContent.transform + self.TransformSizeDelta = self.Transform.sizeDelta + self.ImgContentSizeDelta = self.ImgContentTransform.sizeDelta +end + +function XUiGridLikeInfoItem:OnRefresh(datas, toggle) + self.CharacterDatas = datas + local characterId = self.UiRoot:GetCurrFavorabilityCharacter() + local isUnlock = XDataCenter.FavorabilityManager.IsInformationUnlock(characterId, self.CharacterDatas.Id) + local canUnlock = XDataCenter.FavorabilityManager.CanInformationUnlock(characterId, self.CharacterDatas.Id) + self.CurrentState = XFavorabilityConfigs.InfoState.Normal + if not isUnlock then + if canUnlock then + self.CurrentState = XFavorabilityConfigs.InfoState.Available + else + self.CurrentState = XFavorabilityConfigs.InfoState.Lock + end + end + + self:UpdateNormalStatus(self.CurrentState == XFavorabilityConfigs.InfoState.Normal or self.CurrentState == XFavorabilityConfigs.InfoState.Available) + self:UpdateAvailableStatus(self.CurrentState == XFavorabilityConfigs.InfoState.Available) + self:UpdateLockStatus(self.CurrentState == XFavorabilityConfigs.InfoState.Lock) + + self:ToggleContent(toggle or false) + if toggle then + self.ImgArrowTransform.localScale = ArrowUp + else + self.ImgArrowTransform.localScale = ArrowDown + end +end + +function XUiGridLikeInfoItem:OnToggle() + if not self.CharacterDatas then return end + self.CharacterDatas.IsToggle = not self.CharacterDatas.IsToggle +end + +function XUiGridLikeInfoItem:ToggleContent(isToggle) + if self.CharacterDatas == nil then return end + + self.ImgContent.gameObject:SetActive(isToggle) + if isToggle then + self.TxtInfo.text = string.gsub(self.CharacterDatas.Content, "\\n", "\n") + local txtHeight = self.TxtInfo.preferredHeight + -- ImgContentSize = CS.UnityEngine.Vector2(self.ImgContentSizeDelta.x, txtHeight + 30) + -- ItemContentSize = CS.UnityEngine.Vector2(self.TransformSizeDelta.x, ImgContentSize.y + self.TransformSizeDelta.y) + else + self.TxtInfo.text = "" + -- ItemContentSize = self.TransformSizeDelta + -- ImgContentSize = CS.UnityEngine.Vector2(self.ImgContentSizeDelta.x, 0) + end + self.ImgContentLayout:SetDirty() + self.LayoutNode:SetDirty() + --self:OnResize() +end + +function XUiGridLikeInfoItem:OnResize() + -- self.Transform.sizeDelta = CS.UnityEngine.Vector2(self.TransformSizeDelta.x, self.ImgContentTransform.sizeDelta.y + self.TransformSizeDelta.y) + --elf.ImgContentTransform.sizeDelta = ImgContentSize +end + + +function XUiGridLikeInfoItem:UpdateNormalStatus(isNormal) + self.InfoNor.gameObject:SetActive(isNormal) + if isNormal and self.CharacterDatas then + local title = self.CharacterDatas.Title + self.TxtTitle.text = title + self.TxtNum.text = string.sub(title, #title - 1, #title) + end +end + +function XUiGridLikeInfoItem:UpdateAvailableStatus(isAvailable) + --self.InfoUnlock.gameObject:SetActive(isAvailable) + self.ImgRedDot.gameObject:SetActive(isAvailable) +end + + +function XUiGridLikeInfoItem:HideRedDot() + --self.InfoUnlock.gameObject:SetActive(isAvailable) + self.ImgRedDot.gameObject:SetActive(false) +end + +function XUiGridLikeInfoItem:UpdateLockStatus(isLock) + self.InfoLock.gameObject:SetActive(isLock) + if isLock and self.CharacterDatas then + self.TxtLock.text = self.CharacterDatas.ConditionDescript + self.TxtLockTitle.text = self.CharacterDatas.Title + end +end + +return XUiGridLikeInfoItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFavorability/XUiGridLikeMessageItem.lua b/Resources/Scripts/XUi/XUiFavorability/XUiGridLikeMessageItem.lua new file mode 100644 index 00000000..8d36f8c3 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFavorability/XUiGridLikeMessageItem.lua @@ -0,0 +1,134 @@ +XUiGridLikeMessageItem = XClass(nil, "XUiGridLikeMessageItem") + +local ArrowDown = CS.UnityEngine.Vector3.one +local ArrowUp = CS.UnityEngine.Vector3(1, -1, 1) +local ImgContentSize = CS.UnityEngine.Vector2.zero +local ItemContentSize = CS.UnityEngine.Vector2.zero + +function XUiGridLikeMessageItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self:InitAutoScript() + self:InitUiAfterAuto() +end + +function XUiGridLikeMessageItem:Init(uiRoot) + self.UiRoot = uiRoot +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiGridLikeMessageItem:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiGridLikeMessageItem:AutoInitUi() + self.TxtTitle = self.Transform:Find("TxtTitle"):GetComponent("Text") + self.ImgArrow = self.Transform:Find("ImgArrow"):GetComponent("Image") + self.ImgContent = self.Transform:Find("ImgContent"):GetComponent("Image") + self.TxtInfo = self.Transform:Find("ImgContent/TxtInfo"):GetComponent("Text") + self.BtnOnUnlock = self.Transform:Find("BtnOnUnlock"):GetComponent("Button") + self.ImgRedDot = self.Transform:Find("ImgRedDot"):GetComponent("Image") + self.ImgLockBg = self.Transform:Find("ImgLockBg"):GetComponent("Image") + self.ImgLock = self.Transform:Find("ImgLockBg/ImgLock"):GetComponent("Image") + self.Txtlock = self.Transform:Find("Txtlock"):GetComponent("Text") +end + +function XUiGridLikeMessageItem:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiGridLikeMessageItem:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiGridLikeMessageItem:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiGridLikeMessageItem:AutoAddListener() + +end +-- auto +function XUiGridLikeMessageItem:InitUiAfterAuto() + self.ImgArrowTransform = self.ImgArrow.transform + self.ImgArrowTransform.localScale = ArrowDown + self.ImgContentTransform = self.ImgContent.transform + self.BtnOnUnlockCanvasGroup = self.Transform:Find("BtnOnUnlock"):GetComponent("CanvasGroup") + self.TransformSizeDelta = self.Transform.sizeDelta + self.ImgContentSizeDelta = self.ImgContentTransform.sizeDelta +end + +function XUiGridLikeMessageItem:OnRefresh(datas) + self.CharacterDatas = datas + local characterId = self.UiRoot:GetCurrFavorabilityCharacter() + local isUnlock = XDataCenter.FavorabilityManager.IsInformationUnlock(characterId, self.CharacterDatas.Id) + local canUnlock = XDataCenter.FavorabilityManager.CanInformationUnlock(characterId, self.CharacterDatas.Id) + + if isUnlock then + self:ChangeBtnStates(true, false, false, "") + self.TxtTitle.text = self.CharacterDatas.Title + else + self.TxtTitle.text = "" + if canUnlock then + self:ChangeBtnStates(false, true, false, "") + else + self:ChangeBtnStates(false, false, true, datas.ConditionDescript) + end + end + + self:ToggleContent(self.CharacterDatas.IsToggle or false) + if self.CharacterDatas.IsToggle then + self.ImgArrowTransform.localScale = ArrowUp + else + self.ImgArrowTransform.localScale = ArrowDown + end +end + +function XUiGridLikeMessageItem:OnToggle() + self.CharacterDatas.IsToggle = not self.CharacterDatas.IsToggle +end + +function XUiGridLikeMessageItem:ToggleContent(isToggle) + if self.CharacterDatas == nil then return end + + self.ImgContent.gameObject:SetActive(isToggle) + if isToggle then + self.TxtInfo.text = self.CharacterDatas.Content + local txtHeight = self.TxtInfo.preferredHeight + ImgContentSize = CS.UnityEngine.Vector2(self.ImgContentSizeDelta.x, txtHeight + 30) + ItemContentSize = CS.UnityEngine.Vector2(self.TransformSizeDelta.x, ImgContentSize.y + self.TransformSizeDelta.y) + else + self.TxtInfo.text = "" + ItemContentSize = self.TransformSizeDelta + ImgContentSize = CS.UnityEngine.Vector2(self.ImgContentSizeDelta.x, 0) + end + + self:OnResize() +end + +function XUiGridLikeMessageItem:ChangeBtnStates(arrow, reddot, lockbg, lockTxt) + self.ImgArrow.gameObject:SetActive(arrow) + self.ImgRedDot.gameObject:SetActive(reddot) + self.BtnOnUnlock.gameObject:SetActive(reddot) + self.ImgLockBg.gameObject:SetActive(lockbg) + self.Txtlock.text = lockTxt + + if reddot then + self.BtnOnUnlockCanvasGroup.alpha = 1 + end +end + +function XUiGridLikeMessageItem:OnResize() + self.Transform.sizeDelta = ItemContentSize + self.ImgContentTransform.sizeDelta = ImgContentSize +end + + +return XUiGridLikeMessageItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFavorability/XUiGridLikePlotItem.lua b/Resources/Scripts/XUi/XUiFavorability/XUiGridLikePlotItem.lua new file mode 100644 index 00000000..99e9e932 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFavorability/XUiGridLikePlotItem.lua @@ -0,0 +1,66 @@ +XUiGridLikePlotItem = XClass(nil, "XUiGridLikePlotItem") + + +function XUiGridLikePlotItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiGridLikePlotItem:Init(uiRoot) + self.UiRoot = uiRoot +end + +function XUiGridLikePlotItem:OnRefresh(plotData) + self.PlotData = plotData + local characterId = self.UiRoot:GetCurrFavorabilityCharacter() + local isUnlock = XDataCenter.FavorabilityManager.IsStoryUnlock(characterId, plotData.Id) + local canUnlock = XDataCenter.FavorabilityManager.CanStoryUnlock(characterId, plotData.Id) + + self.CurrentState = XFavorabilityConfigs.InfoState.Normal + if not isUnlock then + if canUnlock then + self.CurrentState = XFavorabilityConfigs.InfoState.Available + else + self.CurrentState = XFavorabilityConfigs.InfoState.Lock + end + end + + self:UpdateNormalStatus(self.CurrentState == XFavorabilityConfigs.InfoState.Normal or self.CurrentState == XFavorabilityConfigs.InfoState.Available) + self:UpdateAvailableStatus(self.CurrentState == XFavorabilityConfigs.InfoState.Available) + self:UpdateLockStatus(self.CurrentState == XFavorabilityConfigs.InfoState.Lock) +end + + +function XUiGridLikePlotItem:UpdateNormalStatus(isNoraml) + self.PlotNor.gameObject:SetActive(isNoraml) + + if isNoraml and self.PlotData then + self.TxtSerial.text = CS.XTextManager.GetText("FavorabilityStorySectionName", self.PlotData.SectionNumber) + self.TxtTitle.text = self.PlotData.Name + local currentCharacterId = self.UiRoot:GetCurrFavorabilityCharacter() + self.ImgIcon:SetRawImage(XDataCenter.CharacterManager.GetCharSmallHeadIcon(currentCharacterId)) + end +end + +function XUiGridLikePlotItem:UpdateAvailableStatus(isAvailable) + -- self.PlotUnlock.gameObject:SetActive(isAvailable) + self.ImgRedDot.gameObject:SetActive(isAvailable) +end + + +function XUiGridLikePlotItem:HideRedDot() + self.ImgRedDot.gameObject:SetActive(false) +end + +function XUiGridLikePlotItem:UpdateLockStatus(isLock) + self.PlotLock.gameObject:SetActive(isLock) + + if isLock and self.PlotData then + self.TxtLockSerial.text = CS.XTextManager.GetText("FavorabilityStorySectionName", self.PlotData.SectionNumber) + self.TxtLockTitle.text = self.PlotData.Name + self.TxtTLock.text = self.PlotData.ConditionDescript + end +end + +return XUiGridLikePlotItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFavorability/XUiGridLikeRoleItem.lua b/Resources/Scripts/XUi/XUiFavorability/XUiGridLikeRoleItem.lua new file mode 100644 index 00000000..6732b6dc --- /dev/null +++ b/Resources/Scripts/XUi/XUiFavorability/XUiGridLikeRoleItem.lua @@ -0,0 +1,68 @@ +XUiGridLikeRoleItem = XClass(nil, "XUiGridLikeRoleItem") + +function XUiGridLikeRoleItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiGridLikeRoleItem:Init(uiRoot) + self.UiRoot = uiRoot +end + +-- [刷新界面] +function XUiGridLikeRoleItem:OnRefresh(data) + self.CharacterData = data + self.TrustExp = XFavorabilityConfigs.GetTrustExpById(data.Id) + self.RImgHeadIcon:SetRawImage(XDataCenter.CharacterManager.GetCharSmallHeadIcon(data.Id)) + self.ImgAssist.gameObject:SetActiveEx(XDataCenter.DisplayManager.GetDisplayChar().Id == data.Id) + + local isOwn = XDataCenter.CharacterManager.IsOwnCharacter(data.Id) + self.ImgLock.gameObject:SetActiveEx(not isOwn) + self.RImgAIxin.gameObject:SetActiveEx(isOwn) + + if not isOwn then + self.TxtDisplayLevel.text = "" + self.ImgRedPoint.gameObject:SetActiveEx(false) + else + local trustLv = data.TrustLv or 1 + self.TxtLevel.text = trustLv + self.TxtDisplayLevel.text = XFavorabilityConfigs.GetWordsWithColor(trustLv, self.TrustExp[trustLv].Name) + self.UiRoot:SetUiSprite(self.RImgAIxin, XFavorabilityConfigs.GetTrustLevelIconByLevel(data.TrustLv)) + + self.ImgRedPoint.gameObject:SetActiveEx(self:IsRed()) + end + self:OnSelect() +end + +-- [修改选中状态] +function XUiGridLikeRoleItem:OnSelect() + local isSelect = self.CharacterData and self.CharacterData.Selected or false + self.ImgSelected.gameObject:SetActiveEx(isSelect) +end + +-- [是否有红点] +function XUiGridLikeRoleItem:IsRed() + if self.CharacterData then + local characterId = self.CharacterData.Id + local isOwn = XDataCenter.CharacterManager.IsOwnCharacter(characterId) + if not isOwn then return false end + + local rumorReddot = XDataCenter.FavorabilityManager.HasRumorsToBeUnlock(characterId) + local dataReddot = XDataCenter.FavorabilityManager.HasDataToBeUnlock(characterId) + local audioReddot = XDataCenter.FavorabilityManager.HasAudioToBeUnlock(characterId) + local actionReddot = XDataCenter.FavorabilityManager.HasActionToBeUnlock(characterId) + + local check = XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.FavorabilityFile) + local documentReddot = (not check) and (rumorReddot or dataReddot or audioReddot or actionReddot) + + local storyReddot = XDataCenter.FavorabilityManager.HasStroyToBeUnlock(characterId) + local plotReddot = (not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.FavorabilityStory)) and storyReddot + + return documentReddot or plotReddot + end + return false +end + + +return XUiGridLikeRoleItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFavorability/XUiGridLikeRumorItem.lua b/Resources/Scripts/XUi/XUiFavorability/XUiGridLikeRumorItem.lua new file mode 100644 index 00000000..df7cb777 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFavorability/XUiGridLikeRumorItem.lua @@ -0,0 +1,134 @@ +XUiGridLikeRumorItem = XClass(nil, "XUiGridLikeRumorItem") + +local ArrowUp = CS.UnityEngine.Vector3(1, -1, 1) +local ArrowDown = CS.UnityEngine.Vector3.one +local ImgContentSize = CS.UnityEngine.Vector2.zero +local ItemContentSize = CS.UnityEngine.Vector2.zero +local RumorImgSize = CS.UnityEngine.Vector2(530, 366) + +function XUiGridLikeRumorItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + self:InitUiAfterAuto() +end + +function XUiGridLikeRumorItem:Init(uiRoot) + self.UiRoot = uiRoot +end + +function XUiGridLikeRumorItem:InitUiAfterAuto() + self.ImgArrowTransform = self.ImgArrow.transform + self.ImgArrowTransform.localScale = ArrowDown + self.ImgContentTransform = self.ImgContent.transform + self.TxtInfoTransform = self.TxtInfo.transform + self.RumorImageTransform = self.BtnImage.transform + + self.TransformSizeDelta = self.Transform.sizeDelta + self.ImgContentSizeDelta = self.ImgContentTransform.sizeDelta + + self.StartPos = self.RumorImageTransform.localPosition + self.BtnImage.CallBack = function() self.OnBtnImageClick() end + +end + +function XUiGridLikeRumorItem:OnRefresh(rumorData, toggle) + self.RumorData = rumorData + local characterId = self.UiRoot:GetCurrFavorabilityCharacter() + local isUnlock = XDataCenter.FavorabilityManager.IsRumorUnlock(characterId, rumorData.Id) + local canUnlock = XDataCenter.FavorabilityManager.CanRumorsUnlock(characterId, rumorData.UnlockType, rumorData.UnlockPara) + + self.CurrentState = XFavorabilityConfigs.InfoState.Normal + if not isUnlock then + if canUnlock then + self.CurrentState = XFavorabilityConfigs.InfoState.Available + else + self.CurrentState = XFavorabilityConfigs.InfoState.Lock + end + end + + self:UpdateNormalStatus(self.CurrentState == XFavorabilityConfigs.InfoState.Normal or self.CurrentState == XFavorabilityConfigs.InfoState.Available) + self:UpdateAvailableStatus(self.CurrentState == XFavorabilityConfigs.InfoState.Available) + self:UpdateLockStatus(self.CurrentState == XFavorabilityConfigs.InfoState.Lock) + + self:ToggleContent(toggle or false) + if toggle then + self.ImgArrowTransform.localScale = ArrowUp + else + self.ImgArrowTransform.localScale = ArrowDown + end +end + +function XUiGridLikeRumorItem:ToggleContent(isToggle) + if self.RumorData == nil then return end + + self.ImgContent.gameObject:SetActive(isToggle) + + if isToggle then + self.TxtInfo.text = string.gsub(self.RumorData.Content, "\\n", "\n") + local txtHeight = self.TxtInfo.preferredHeight + if self.RumorData.Picture then + self.UiRoot:SetUiSprite(self.RumorImage, self.RumorData.Picture) + self.RumorImageTransform.sizeDelta = RumorImgSize + else + self.RumorImageTransform.sizeDelta = CS.UnityEngine.Vector2.zero + end + --改变容器大小 + local offsetY = self.RumorImageTransform.sizeDelta.y + -- ImgContentSize = CS.UnityEngine.Vector2(self.ImgContentSizeDelta.x, offsetY + txtHeight + 30) + -- ItemContentSize = CS.UnityEngine.Vector2(self.TransformSizeDelta.x, ImgContentSize.y + self.TransformSizeDelta.y) + else + self.TxtInfo.text = "" + self.RumorImageTransform.sizeDelta = CS.UnityEngine.Vector2.zero + -- ItemContentSize = self.TransformSizeDelta + -- ImgContentSize = CS.UnityEngine.Vector2(self.ImgContentSizeDelta.x, 0) + end + + -- local rumorImgY = self.RumorImageTransform.sizeDelta.y + -- local txtInfoPos = CS.UnityEngine.Vector3(self.StartPos.x, self.StartPos.y - rumorImgY - 10, self.StartPos.z) + -- self.TxtInfoTransform.localPosition = txtInfoPos + self.ImgContentLayoutNode:SetDirty() + self.LayoutNode:SetDirty() + -- self:OnResize() +end + +function XUiGridLikeRumorItem:OnResize() + self.Transform.sizeDelta = ItemContentSize + self.ImgContentTransform.sizeDelta = ImgContentSize +end + +function XUiGridLikeRumorItem:OnBtnImageClick() + if self.RumorData.Picture then + CsXGameEventManager.Instance:Notify(XEventId.EVENT_FAVORABILITY_RUMORS_PREVIEW, self.RumorData.PreviewPicture) + end +end + +function XUiGridLikeRumorItem:UpdateNormalStatus(isNormal) + self.RumorNor.gameObject:SetActive(isNormal) + if isNormal and self.RumorData then + self.TxtTitle.text = self.RumorData.Title + local currentCharacterId = self.UiRoot:GetCurrFavorabilityCharacter() + self.ImgIcon:SetRawImage(XDataCenter.CharacterManager.GetCharSmallHeadIcon(currentCharacterId)) + end +end + +function XUiGridLikeRumorItem:UpdateAvailableStatus(isAvailable) + self.ImgRedDot.gameObject:SetActive(isAvailable) +end + + +function XUiGridLikeRumorItem:HideRedDot() + self.ImgRedDot.gameObject:SetActive(false) +end + + +function XUiGridLikeRumorItem:UpdateLockStatus(isLock) + self.RumorLock.gameObject:SetActive(isLock) + if isLock and self.RumorData then + self.TxtLockTitle.text = self.RumorData.Title + self.TxtLock.text = self.RumorData.ConditionDescript + end +end + +return XUiGridLikeRumorItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFavorability/XUiGridLikeSendGiftItem.lua b/Resources/Scripts/XUi/XUiFavorability/XUiGridLikeSendGiftItem.lua new file mode 100644 index 00000000..697f6e3b --- /dev/null +++ b/Resources/Scripts/XUi/XUiFavorability/XUiGridLikeSendGiftItem.lua @@ -0,0 +1,183 @@ + +XUiGridLikeSendGiftItem = XClass(nil, "XUiGridLikeSendGiftItem") + +local mathFloor = math.floor +local XMathClamp = XMath.Clamp +local stringFormat = string.format + +local LongClickIntervel = 100 +local AddCountPerPressTime = 1 / 150 + +function XUiGridLikeSendGiftItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + self.BtnMax.CallBack = function() self:OnClickBtnMax() end + self.BtnMinus.CallBack = function() self:OnClickBtnMinus() end + self.BtnAdd.CallBack = function() self:OnClickBtnAdd() end + XUiButtonLongClick.New(self.PointerAdd, LongClickIntervel, self, nil, self.OnLongClickBtnAdd, nil, true) + XUiButtonLongClick.New(self.PointerMinus, LongClickIntervel, self, nil, self.OnLongClickBtnMinus, nil, true) + self.SelectCount = 0 + self.BtnMax.gameObject:SetActiveEx(false) + +end + +function XUiGridLikeSendGiftItem:Init(uiRoot,checkCall,changeCall,preCheck) + self.UiRoot = uiRoot + self.AddCountCheckCb= checkCall + self.AddCountCb = changeCall + self.PreCheck = preCheck +end + +function XUiGridLikeSendGiftItem:ResetSelect() + self:OnSelect(false) +end + +function XUiGridLikeSendGiftItem:OnRefresh(trustItemData,count) + self.SelectCount = count or 0 + self.TrustItem = trustItemData + self.ItemId = trustItemData.Id + local characterId = self.UiRoot:GetCurrFavorabilityCharacter() + self.RImgIcon:SetRawImage(XDataCenter.ItemManager.GetItemIcon(trustItemData.Id)) + self.ImgFlag.gameObject:SetActive(self:IsContains(trustItemData.FavorCharacterId, characterId)) + local giftQuality = XDataCenter.ItemManager.GetItemQuality(trustItemData.Id) + self.UiRoot:SetUiSprite(self.ImgIconBg, XFavorabilityConfigs.GetQualityIconByQuality(giftQuality)) + self.ItemCount = XDataCenter.ItemManager.GetCount(trustItemData.Id) + self.TxtCount.text = self.ItemCount + self.TxtName.text = XDataCenter.ItemManager.GetItemName(self.ItemId) + + self:OnSelectCountChange(self.SelectCount) + +end + +function XUiGridLikeSendGiftItem:IsContains(container, item) + for _, v in pairs(container or {}) do + if v == item then + return true + end + end + return false +end + +-- checkCount小于等于拥有数量时返回true +function XUiGridLikeSendGiftItem:CheckItemCount(checkCount) + return checkCount >= 0 and checkCount <= self.ItemCount +end + +function XUiGridLikeSendGiftItem:OnSelectCountChange(newCount) + self.SelectCount = newCount + if newCount > 0 then + self.TxtSelectNum.text = stringFormat("x%d", newCount) + self.ImgSelect.gameObject:SetActiveEx(true) + self.BtnMinus.gameObject:SetActiveEx(true) + self.BtnMax.gameObject:SetActiveEx(true) + else + self.ImgSelect.gameObject:SetActiveEx(false) + self.BtnMinus.gameObject:SetActiveEx(false) + self.BtnMax.gameObject:SetActiveEx(false) + end +end + +function XUiGridLikeSendGiftItem:OnClickBtnAdd() + local addCount = 1 + local newCount = self.SelectCount + addCount + local itemId = self.ItemId + + if not self.PreCheck(itemId) then + return + end + + if not self:CheckItemCount(newCount) then + XUiManager.TipMsg(CS.XTextManager.GetText("FavorabilityMaxGiftNum")) + return + end + + if not self.AddCountCheckCb(itemId, addCount) and itemId ~= 40801 then + return + end + + self:OnSelectCountChange(newCount) + self.AddCountCb(itemId, addCount) +end + +function XUiGridLikeSendGiftItem:OnLongClickBtnAdd(pressingTime) + local addCount = 1 + local totalCount = XMathClamp(mathFloor(pressingTime * AddCountPerPressTime), 0, self.ItemCount) + local newCount = self.SelectCount + local itemId = self.ItemId + + if not self.PreCheck(itemId) then + return + end + + for _ = 1, totalCount do + if not self.AddCountCheckCb(itemId, addCount) then + break + end + + newCount = newCount + addCount + if not self:CheckItemCount(newCount) then + XUiManager.TipMsg(CS.XTextManager.GetText("FavorabilityMaxGiftNum")) + newCount = newCount - addCount + break + end + + self.AddCountCb(itemId, addCount) + end + + self:OnSelectCountChange(newCount) +end + +function XUiGridLikeSendGiftItem:OnClickBtnMinus() + local addCount = -1 + addCount = addCount + self.SelectCount < 0 and -self.SelectCount or addCount + local newCount = self.SelectCount + addCount + local itemId = self.ItemId + + self:OnSelectCountChange(newCount) + self.AddCountCb(itemId, addCount) +end + +function XUiGridLikeSendGiftItem:OnLongClickBtnMinus(pressingTime) + local addCount = -mathFloor(pressingTime * AddCountPerPressTime) + addCount = addCount + self.SelectCount < 0 and -self.SelectCount or addCount + local newCount = self.SelectCount + addCount + local itemId = self.ItemId + + self:OnSelectCountChange(newCount) + self.AddCountCb(itemId, addCount) +end + +function XUiGridLikeSendGiftItem:OnClickBtnMax() + local addCount = 1 + local totalCount = self.ItemCount + local newCount = self.SelectCount + local itemId = self.ItemId + + if not self.PreCheck(itemId) then + return + end + + for _ = 1, totalCount do + if not self.AddCountCheckCb(itemId, addCount) then + break + end + + local total = newCount + addCount + + + if not self:CheckItemCount(total) then + break + end + + newCount = total + + self.AddCountCb(itemId, addCount) + end + + self:OnSelectCountChange(newCount) +end + + +return XUiGridLikeSendGiftItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFavorability/XUiGridLineCharacter.lua b/Resources/Scripts/XUi/XUiFavorability/XUiGridLineCharacter.lua new file mode 100644 index 00000000..1dc7574f --- /dev/null +++ b/Resources/Scripts/XUi/XUiFavorability/XUiGridLineCharacter.lua @@ -0,0 +1,18 @@ +local XUiGridLikeRoleItem = require("XUi/XUiFavorability/XUiGridLikeRoleItem") +XUiGridLineCharacter = XClass(XUiGridLikeRoleItem, "XUiGridLineCharacter") + +function XUiGridLineCharacter:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiGridLineCharacter:RefreshAssist() + self.ImgAssist.gameObject:SetActive(XDataCenter.DisplayManager.GetDisplayChar().Id == self.CharacterData.Id) +end + +function XUiGridLineCharacter:IsRed() + return false +end + +return XUiGridLineCharacter \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFavorability/XUiPanelFavorabilityAction.lua b/Resources/Scripts/XUi/XUiFavorability/XUiPanelFavorabilityAction.lua new file mode 100644 index 00000000..8883d66c --- /dev/null +++ b/Resources/Scripts/XUi/XUiFavorability/XUiPanelFavorabilityAction.lua @@ -0,0 +1,210 @@ +XUiPanelFavorabilityAction = XClass(nil, "XUiPanelFavorabilityAction") + +local CurrentActionSchedule +local loadGridComplete + +function XUiPanelFavorabilityAction:Ctor(ui, uiRoot, parent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + self.Parent = parent + XTool.InitUiObject(self) + + self.GridLikeActionItem.gameObject:SetActiveEx(false) + self.PanelEmpty.gameObject:SetActiveEx(false) +end + +function XUiPanelFavorabilityAction:OnSelected(isSelected) + self.GameObject:SetActiveEx(isSelected) + if isSelected then + self.UiRoot.SignBoard:SetClickTrigger(false) + self.UiRoot.SignBoard:SetRoll(false) + self:Refresh() + else + loadGridComplete = false + self.UiRoot.SignBoard:SetClickTrigger(true) + self.UiRoot.SignBoard:SetRoll(true) + end +end + +function XUiPanelFavorabilityAction:Refresh() + local currentCharacterId = self.UiRoot:GetCurrFavorabilityCharacter() + local actionDatas = XFavorabilityConfigs.GetCharacterActionById(currentCharacterId) + + self:UpdateActionList(actionDatas) +end + +function XUiPanelFavorabilityAction:UpdateActionList(actionDatas) + if not actionDatas then + self.PanelEmpty.gameObject:SetActiveEx(true) + self.TxtNoDataTip.text = CS.XTextManager.GetText("FavorabilityNoActionData") + self.ActionList = {} + else + self.PanelEmpty.gameObject:SetActiveEx(false) + self:SortActions(actionDatas) + for k, v in pairs(actionDatas or {}) do + if self.CurrentPlayAction and self.CurrentPlayAction.Id == v.Id then + v.IsPlay = true + self.CurrentPlayAction.Index = k + else + v.IsPlay = false + end + end + self.ActionList = actionDatas + end + + if not self.DynamicTableAction then + self.DynamicTableAction = XDynamicTableNormal.New(self.SViewActionList.gameObject) + self.DynamicTableAction:SetProxy(XUiGridLikeActionItem) + self.DynamicTableAction:SetDelegate(self) + end + + self.DynamicTableAction:SetDataSource(self.ActionList) + self.DynamicTableAction:ReloadDataASync() +end + +function XUiPanelFavorabilityAction:SortActions(actions) + local characterId = self.UiRoot:GetCurrFavorabilityCharacter() + for _, action in pairs(actions) do + local isUnlock = XDataCenter.FavorabilityManager.IsActionUnlock(characterId, action.Id) + local canUnlock = XDataCenter.FavorabilityManager.CanActionUnlock(characterId, action.Id) + + action.priority = 2 + if not isUnlock then + action.priority = canUnlock and 1 or 3 + end + end + table.sort(actions, function(action1, action2) + if action1.priority == action2.priority then + return action1.Id < action2.Id + else + return action1.priority < action2.priority + end + end) +end + +function XUiPanelFavorabilityAction:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self.UiRoot) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.ActionList[index] + if data ~= nil then + grid:OnRefresh(self.ActionList[index], index) + end + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + if self.CurrentPlayAction and self.CurrentPlayAction.Id == self.ActionList[index].Id and self.CurrentPlayAction.IsPlay then + --点击相同的动作停止播放动作 + self.CurrentPlayAction.IsPlay = false + grid:OnRefresh(self.CurrentPlayAction, index) + --播放打断特效 + self:UnScheduleAction(true) + return + end + self:OnActionClick(self.ActionList[index], grid, index) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_RELOAD_COMPLETED then + loadGridComplete = true + end +end + +function XUiPanelFavorabilityAction:ResetPlayStatus(index) + for k, v in pairs(self.ActionList) do + v.IsPlay = (k == index) + local grid = self.DynamicTableAction:GetGridByIndex(k) + if grid then + grid:OnRefresh(v) + end + end +end + +function XUiPanelFavorabilityAction:OnActionClick(clickAction, grid, index) + XDataCenter.FavorabilityManager.SetDontStopCvContent(true) + + local characterId = self.UiRoot:GetCurrFavorabilityCharacter() + local isUnlock = XDataCenter.FavorabilityManager.IsActionUnlock(characterId, clickAction.Id) + local canUnlock = XDataCenter.FavorabilityManager.CanActionUnlock(characterId, clickAction.Id) + + if isUnlock or canUnlock then + if canUnlock and not isUnlock then + XDataCenter.FavorabilityManager.OnUnlockCharacterAction(characterId, clickAction.Id) + grid:HideRedDot() + XEventManager.DispatchEvent(XEventId.EVENT_FAVORABILITY_ACTIONUNLOCK) + end + --停止正在播放的动作,准备播放新动作 + self:UnScheduleAction(true) + self:ResetPlayStatus(index) + + self.UiRoot.SignBoard:ForcePlay(clickAction.SignBoardActionId, self.Parent.CvType, true) + self.CurrentPlayAction = clickAction + self.CurrentPlayAction.Index = index + local isFinish = false + local progress = 0 + local updateCount = 0 + local startTime = self.UiRoot.SignBoard.SignBoardPlayer.PlayerData.PlayingElement.StartTime + local duration = self.UiRoot.SignBoard.SignBoardPlayer.PlayerData.PlayingElement.Duration + + CurrentActionSchedule = XScheduleManager.ScheduleForever(function() + local clickGrid + if loadGridComplete then + --根据index找到点击的数据所在的Grid + clickGrid = self.DynamicTableAction:GetGridByIndex(self.CurrentPlayAction.Index) + end + if clickGrid == nil then + --不存在点击数据的grid(列表滑动不显示这个数据的Grid),使用点击时的Grid来代替 + clickGrid = grid + end + if not clickGrid then + XLog.Error("XUiPanelFavorabilityAction:OnActionClick函数错误:clickGrid不能为空") + return + end + + if self.CurrentPlayAction then + local time = self.UiRoot.SignBoard.SignBoardPlayer.Time + progress = (time - startTime) / duration + if progress >= 1 or self.UiRoot.SignBoard.SignBoardPlayer.PlayerData.PlayingElement == nil then + progress = 1 + isFinish = true + end + --判断当前grid存放的数据是不是正在播放的数据 + if clickGrid:GetActionDataId() == clickAction.Id then + clickGrid:UpdateProgress(progress) + clickGrid:UpdateActionAlpha(updateCount) + end + updateCount = updateCount + 1 + end + if not self.CurrentPlayAction or isFinish then + clickAction.IsPlay = false + if clickGrid:GetActionDataId() == clickAction.Id then + clickGrid:UpdatePlayStatus() + clickGrid:UpdateProgress(0) + end + --自然结束动作,不播放打断特效 + self:UnScheduleAction(false) + end + end, 20) + else + XUiManager.TipMsg(clickAction.ConditionDescript) + end +end + +function XUiPanelFavorabilityAction:UnScheduleAction(playEffect) + self.UiRoot:SetWhetherPlayChangeActionEffect(playEffect) + if CurrentActionSchedule then + XScheduleManager.UnSchedule(CurrentActionSchedule) + CurrentActionSchedule = nil + end + self.UiRoot.SignBoard:Stop() + self.CurrentPlayAction = nil + self.UiRoot:ResumeCvContent() +end + +function XUiPanelFavorabilityAction:SetViewActive(isActive) + self.GameObject:SetActiveEx(isActive) + self:UnScheduleAction() + if isActive then + self:Refresh() + end +end + +function XUiPanelFavorabilityAction:OnClose() + self:UnScheduleAction() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFavorability/XUiPanelFavorabilityAudio.lua b/Resources/Scripts/XUi/XUiFavorability/XUiPanelFavorabilityAudio.lua new file mode 100644 index 00000000..bd4a70c4 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFavorability/XUiPanelFavorabilityAudio.lua @@ -0,0 +1,261 @@ +XUiPanelFavorabilityAudio = XClass(nil, "XUiPanelFavorabilityAudio") + +local CurrentAudioSchedule = nil +local loadGridComplete + +function XUiPanelFavorabilityAudio:Ctor(ui, uiRoot, parent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + self.Parent = parent + XTool.InitUiObject(self) + + self.GridLikeAudioItem.gameObject:SetActiveEx(false) + self.PanelEmpty.gameObject:SetActiveEx(false) +end + +-- [刷新界面] +function XUiPanelFavorabilityAudio:OnRefresh() + self:RefreshDatas() +end + +function XUiPanelFavorabilityAudio:RefreshDatas() + local currentCharacterId = self.UiRoot:GetCurrFavorabilityCharacter() + local audioDatas = XFavorabilityConfigs.GetCharacterVoiceById(currentCharacterId) + + self:UpdateAudioList(audioDatas) +end + +-- [装载数据] +function XUiPanelFavorabilityAudio:UpdateAudioList(audioDatas) + if not audioDatas then + self.PanelEmpty.gameObject:SetActiveEx(true) + self.TxtNoDataTip.text = CS.XTextManager.GetText("FavorabilityNoAudioData") + self.AudioList = {} + else + self.PanelEmpty.gameObject:SetActiveEx(false) + self:SortAudios(audioDatas) + + for k, v in pairs(audioDatas or {}) do + if self.CurAudio and self.CurAudio.Id == v.Id then + v.IsPlay = true + self.CurAudio.Index = k + else + v.IsPlay = false + end + end + self.AudioList = audioDatas + end + + + if not self.DynamicTableAudios then + self.DynamicTableAudios = XDynamicTableNormal.New(self.SViewAudioList.gameObject) + self.DynamicTableAudios:SetProxy(XUiGridLikeAudioItem) + self.DynamicTableAudios:SetDelegate(self) + end + + self.DynamicTableAudios:SetDataSource(self.AudioList) + self.DynamicTableAudios:ReloadDataASync() +end + +function XUiPanelFavorabilityAudio:SortAudios(audios) + -- 已解锁,可解锁,未解锁 + local characterId = self.UiRoot:GetCurrFavorabilityCharacter() + for _, audio in pairs(audios) do + local isUnlock = XDataCenter.FavorabilityManager.IsVoiceUnlock(characterId, audio.Id) + local canUnlock = XDataCenter.FavorabilityManager.CanVoiceUnlock(characterId, audio.Id) + + audio.priority = 2 + if not isUnlock then + audio.priority = canUnlock and 1 or 3 + end + end + table.sort(audios, function(audioA, audioB) + if audioA.priority == audioB.priority then + return audioA.Id < audioB.Id + else + return audioA.priority < audioB.priority + end + end) +end + +-- [监听动态列表事件] +function XUiPanelFavorabilityAudio:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self.UiRoot) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.AudioList[index] + if data ~= nil then + grid:OnRefresh(self.AudioList[index], index) + end + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + if self.CurAudio and self.AudioList[index] then + if self.CurAudio.Id == self.AudioList[index].Id and self.CurrentPlayAudio and self.CurAudio.IsPlay then + self.CurAudio.IsPlay = false + grid:OnRefresh(self.CurAudio, index) + self:UnScheduleAudio() + return + end + end + self:OnAudioClick(self.AudioList[index], grid, index) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_RELOAD_COMPLETED then + loadGridComplete = true + end +end + +function XUiPanelFavorabilityAudio:ResetPlayStatus(index) + for k, v in pairs(self.AudioList) do + v.IsPlay = (k == index) + local grid = self.DynamicTableAudios:GetGridByIndex(k) + if grid then + grid:OnRefresh(v, k) + end + end +end + +function XUiPanelFavorabilityAudio:UpdateGrids() + for i = 1, #self.AudioList do + local grid = self.DynamicTableAudios:GetGridByIndex(i) + if grid then + grid:UpdatePlayStatus() + end + end +end + +-- [音频按钮点击事件] +function XUiPanelFavorabilityAudio:OnAudioClick(clickAudio, grid, index) + local characterId = self.UiRoot:GetCurrFavorabilityCharacter() + local isUnlock = XDataCenter.FavorabilityManager.IsVoiceUnlock(characterId, clickAudio.Id) + local canUnlock = XDataCenter.FavorabilityManager.CanVoiceUnlock(characterId, clickAudio.Id) + + if isUnlock or canUnlock then + if canUnlock and not isUnlock then + XDataCenter.FavorabilityManager.OnUnlockCharacterVoice(characterId, clickAudio.Id) + grid:HideRedDot() + XEventManager.DispatchEvent(XEventId.EVENT_FAVORABILITY_AUDIOUNLOCK) + end + --如果语音打断了动作,则播放打断特效 + self.UiRoot:SetWhetherPlayChangeActionEffect(true) + self:UnScheduleAudio() + self:ResetPlayStatus(index) + local isFinish = false + local progress = 0 + local updateCount = 0 + + self.CurAudio = clickAudio + self.CurAudio.Index = index + + --语音播放完后,isFinish还是处于false(progress未能达到阈值),就会调用回调 + self.CurrentPlayAudio = CS.XAudioManager.PlayCvWithCvType(clickAudio.CvId, self.Parent.CvType, function() + if not isFinish then + isFinish = true + local clickGrid = self:FindClickGrid() or grid + if not clickGrid then + XLog.Error("XUiPanelFavorabilityAudio:OnAudioClick函数错误:clickGrid不能为空") + return + end + self:UnScheduleAudio(clickAudio, clickGrid) + end + end) + + self.UiRoot:PauseCvContent() + self.UiRoot:PlayCvContent(clickAudio.CvId, self.Parent.CvType) + + self.UiRoot:SetWhetherPlayChangeActionEffect(false) --重置播放打断特效标志 + self.UiRoot.SignBoard:SetPlayingAudio(true) --正在播放语音页签下语音,播放新动作时要播放打断特效 + + CurrentAudioSchedule = XScheduleManager.ScheduleForever(function() + local clickGrid = self:FindClickGrid() or grid + if not clickGrid then + XLog.Error("XUiPanelFavorabilityAudio:OnAudioClick函数错误:clickGrid不能为空") + return + end + + if self.CurrentPlayAudio.Done then + if self.CurrentPlayAudio.Duration <= 0 then + return + end + + progress = self.CurrentPlayAudio.Time / self.CurrentPlayAudio.Duration + if progress >= 1 then + progress = 1 + isFinish = true + end + + if clickGrid:GetAudioDataId() == clickAudio.Id then + clickGrid:UpdateProgress(progress) + clickGrid:UpdateMicroAlpha(updateCount) + end + updateCount = updateCount + 1 + end + + if not self.CurrentPlayAudio or isFinish then + self:UnScheduleAudio(clickAudio, clickGrid) + end + end, 20) + else + XUiManager.TipMsg(clickAudio.ConditionDescript) + end +end + +-- [用于寻找当前播放语音所在的Grid] +function XUiPanelFavorabilityAudio:FindClickGrid() + local clickGrid + if loadGridComplete then + --找到点击的index所在的Grid + clickGrid = self.DynamicTableAudios:GetGridByIndex(self.CurAudio.Index) + end + return clickGrid +end + +function XUiPanelFavorabilityAudio:UnScheduleAudio(clickAudio,clickGrid) + self.UiRoot.SignBoard:SetPlayingAudio(false) --停止播放语音页签下语音,播放新动作时不用播放打断特效 + if CurrentAudioSchedule then + XScheduleManager.UnSchedule(CurrentAudioSchedule) + CurrentAudioSchedule = nil + end + + if self.CurrentPlayAudio then + self.CurAudio = nil + self.CurrentPlayAudio:Stop() + self.CurrentPlayAudio = nil + if not XDataCenter.FavorabilityManager.GetDontStopCvContent() then + self.UiRoot:StopCvContent() + end + end + + if clickAudio and clickGrid then + clickAudio.IsPlay = false + if clickGrid:GetAudioDataId() == clickAudio.Id then + clickGrid:UpdatePlayStatus() + clickGrid:UpdateProgress(0) + end + end + self.UiRoot:ResumeCvContent() +end + +function XUiPanelFavorabilityAudio:SetViewActive(isActive) + self.GameObject:SetActiveEx(isActive) + self:UnScheduleAudio() + + if isActive then + self:RefreshDatas() + end +end + +function XUiPanelFavorabilityAudio:OnClose() + self:UnScheduleAudio() +end + +function XUiPanelFavorabilityAudio:OnSelected(isSelected) + self.GameObject:SetActiveEx(isSelected) + if isSelected then + self:RefreshDatas() + XDataCenter.FavorabilityManager.SetDontStopCvContent(false) + else + loadGridComplete = false + end +end + + +return XUiPanelFavorabilityAudio \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFavorability/XUiPanelFavorabilityDocument.lua b/Resources/Scripts/XUi/XUiFavorability/XUiPanelFavorabilityDocument.lua new file mode 100644 index 00000000..54e9cc39 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFavorability/XUiPanelFavorabilityDocument.lua @@ -0,0 +1,104 @@ +XUiPanelFavorabilityDocument = XClass(nil, "XUiPanelFavorabilityDocument") + +local DocumentTypeSize = 4 +local DocumentType = { + DocFile = 1, + DocInfo = 2, + DocRumor = 3, + DocAudo = 4, +} + +function XUiPanelFavorabilityDocument:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + XTool.InitUiObject(self) + self:InitUiAfterAuto() + + local characterId = self.UiRoot:GetCurrFavorabilityCharacter() + self.RedPointInfoId = XRedPointManager.AddRedPointEvent(self.ImgRedDotB, nil, self, { XRedPointConditions.Types.CONDITION_FAVORABILITY_DOCUMENT_INFO }, { CharacterId = characterId }) + self.RedPointRumorId = XRedPointManager.AddRedPointEvent(self.ImgRedDotC, nil, self, { XRedPointConditions.Types.CONDITION_FAVORABILITY_DOCUMENT_RUMOR }, { CharacterId = characterId }) + self.RedPointAudioId = XRedPointManager.AddRedPointEvent(self.ImgRedDotD, nil, self, { XRedPointConditions.Types.CONDITION_FAVORABILITY_DOCUMENT_AUDIO }, { CharacterId = characterId }) +end + +-- [资料标签页trigger] +function XUiPanelFavorabilityDocument:CheckDataReddot() + local characterId = self.UiRoot:GetCurrFavorabilityCharacter() + XRedPointManager.Check(self.RedPointInfoId, { CharacterId = characterId }) +end + +-- [异闻标签页trigger] +function XUiPanelFavorabilityDocument:CheckRumorReddot() + local characterId = self.UiRoot:GetCurrFavorabilityCharacter() + XRedPointManager.Check(self.RedPointRumorId, { CharacterId = characterId }) +end + +-- [语音标签页trigger] +function XUiPanelFavorabilityDocument:CheckAudioReddot() + local characterId = self.UiRoot:GetCurrFavorabilityCharacter() + XRedPointManager.Check(self.RedPointAudioId, { CharacterId = characterId }) +end + +function XUiPanelFavorabilityDocument:InitUiAfterAuto() + self.FavorabilityFile = XUiPanelFavorabilityFile.New(self.PanelFavorabilityFile, self.UiRoot, self) + self.FavorabilityInfo = XUiPanelFavorabilityInfo.New(self.PanelFavorabilityInfo, self.UiRoot, self) + self.FavorabilityRumors = XUiPanelFavorabilityRumors.New(self.PanelFavorabilityRumors, self.UiRoot, self) + self.FavorabilityAudio = XUiPanelFavorabilityAudio.New(self.PanelFavorabilityAudio, self.UiRoot, self) + + self.Tabs = {} + self.Tabs[DocumentType.DocFile] = {} + self.Tabs[DocumentType.DocFile].reddot = self.ImgRedDotA + self.Tabs[DocumentType.DocFile].view = self.FavorabilityFile + self.Tabs[DocumentType.DocInfo] = {} + self.Tabs[DocumentType.DocInfo].reddot = self.ImgRedDotB + self.Tabs[DocumentType.DocInfo].view = self.FavorabilityInfo + self.Tabs[DocumentType.DocRumor] = {} + self.Tabs[DocumentType.DocRumor].reddot = self.ImgRedDotC + self.Tabs[DocumentType.DocRumor].view = self.FavorabilityRumors + self.Tabs[DocumentType.DocAudo] = {} + self.Tabs[DocumentType.DocAudo].reddot = self.ImgRedDotD + self.Tabs[DocumentType.DocAudo].view = self.FavorabilityAudio + + self.TabsList = {} + self.TabsList[DocumentType.DocFile] = self.BtnTog0 + self.TabsList[DocumentType.DocInfo] = self.BtnTog1 + self.TabsList[DocumentType.DocRumor] = self.BtnTog2 + self.TabsList[DocumentType.DocAudo] = self.BtnTog3 + self.DocumentBtnGroup:Init(self.TabsList, function(index) self:OnBtnTabsListClick(index) end) +end + +function XUiPanelFavorabilityDocument:RefreshDatas() + self.DocumentBtnGroup:SelectIndex(self.LastSelectTab or DocumentType.DocFile) + self:CheckDataReddots() +end + +function XUiPanelFavorabilityDocument:CheckDataReddots() + self:CheckDataReddot() + self:CheckRumorReddot() + self:CheckAudioReddot() +end + +function XUiPanelFavorabilityDocument:OnBtnTabsListClick(index) + for i = 1, DocumentTypeSize do + self.Tabs[i].view:SetViewActive(index == i) + end + if self.LastSelectTab then + self.UiRoot:PlaySubTabAnim() + end + self.LastSelectTab = index +end + +function XUiPanelFavorabilityDocument:OnClose() + self.FavorabilityAudio:OnClose() +end + +function XUiPanelFavorabilityDocument:SetViewActive(isActive) + self.GameObject:SetActive(isActive) + if isActive then + self:RefreshDatas() + else + self:OnClose() + end +end + +return XUiPanelFavorabilityDocument \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFavorability/XUiPanelFavorabilityExchangeRole.lua b/Resources/Scripts/XUi/XUiFavorability/XUiPanelFavorabilityExchangeRole.lua new file mode 100644 index 00000000..ee34b55d --- /dev/null +++ b/Resources/Scripts/XUi/XUiFavorability/XUiPanelFavorabilityExchangeRole.lua @@ -0,0 +1,122 @@ +XUiPanelFavorabilityExchangeRole = XClass(nil, "XUiPanelFavorabilityExchangeRole") + +function XUiPanelFavorabilityExchangeRole:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + XTool.InitUiObject(self) + + self.BtnCancel.CallBack = function() self:OnBtnCancelClick() end +end + + +-- [刷新切换角色界面] +function XUiPanelFavorabilityExchangeRole:RefreshDatas() + self:LoadDatas() +end + +function XUiPanelFavorabilityExchangeRole:LoadDatas() + local characterId = self.UiRoot:GetCurrFavorabilityCharacter() + local allCharDatas = XDataCenter.CharacterManager.GetCharacterList() + local characterList = {} + for _, v in pairs(allCharDatas or {}) do + local isOwn = XDataCenter.CharacterManager.IsOwnCharacter(v.Id) + if isOwn then + table.insert(characterList, { + Id = v.Id, + TrustLv = v.TrustLv or 1, + Selected = (characterId == v.Id) + }) + end + end + table.sort(characterList, function(characterA, characterB) + if characterA.TrustLv == characterB.TrustLv then + return characterA.Id < characterB.Id + end + return characterA.TrustLv > characterB.TrustLv + end) + + self:UpdateCharacterList(characterList) +end + +-- [刷新角色ListView] +function XUiPanelFavorabilityExchangeRole:UpdateCharacterList(charList) + if not charList then + XLog.Warning("XUiPanelFavorabilityExchangeRole:UpdateCharacterList error: charList is nil") + return + end + + self.CharList = charList + + if not self.DynamicTabelCharacters then + self.DynamicTabelCharacters = XDynamicTableNormal.New(self.SViewSelectRole.gameObject) + self.DynamicTabelCharacters:SetProxy(XUiGridLikeRoleItem) + self.DynamicTabelCharacters:SetDelegate(self) + end + + self.DynamicTabelCharacters:SetDataSource(self.CharList) + self.DynamicTabelCharacters:ReloadDataASync() + +end + +-- [监听动态列表事件] +function XUiPanelFavorabilityExchangeRole:OnDynamicTableEvent(event, index, grid) + local characterId = self.UiRoot:GetCurrFavorabilityCharacter() + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self.UiRoot) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.CharList[index] + if not data then return end + grid:OnRefresh(self.CharList[index], index) + if characterId == data.Id then + self.CurCharacter = self.CharList[index] + self.CurCharacterGrid = grid + end + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + self.CurCharacter = self.CharList[index] + local isOwn = XDataCenter.CharacterManager.IsOwnCharacter(self.CurCharacter.Id) + if not isOwn then + XUiManager.TipMsg(CS.XTextManager.GetText("FavorabilityNotOwnChar")) + return + end + + if self.CurCharacterGrid then + if self.CurCharacter then + self.CurCharacter.Selected = false + end + self.CurCharacterGrid:OnSelect() + end + + self.CurCharacter.Selected = true + grid:OnSelect() + self.CurCharacterGrid = grid + self:OnChangeCharacter() + end +end + +-- [换人确定按钮] +function XUiPanelFavorabilityExchangeRole:OnChangeCharacter() + if self.CurCharacter == nil then + return + end + + local isOwn = XDataCenter.CharacterManager.IsOwnCharacter(self.CurCharacter.Id) + if not isOwn then + XUiManager.TipError(CS.XTextManager.GetText("FavorabilityNotOwnChar")) + return + end + + self.UiRoot:SetCurrFavorabilityCharacter(self.CurCharacter.Id) + self.UiRoot:UpdateCamera(false) + self.UiRoot:CloseChangeRoleView() +end + +-- [取消按钮] +function XUiPanelFavorabilityExchangeRole:OnBtnCancelClick() + local characterId = self.UiRoot:GetCurrFavorabilityCharacter() + self.UiRoot:ChangeCharacterModel(characterId) + self.UiRoot:UpdateCamera(false) + self.UiRoot:CloseChangeRoleView() +end + +return XUiPanelFavorabilityExchangeRole \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFavorability/XUiPanelFavorabilityFile.lua b/Resources/Scripts/XUi/XUiFavorability/XUiPanelFavorabilityFile.lua new file mode 100644 index 00000000..0f64dfda --- /dev/null +++ b/Resources/Scripts/XUi/XUiFavorability/XUiPanelFavorabilityFile.lua @@ -0,0 +1,81 @@ +XUiPanelFavorabilityFile = XClass(nil, "XUiPanelFavorabilityFile") + +function XUiPanelFavorabilityFile:Ctor(ui, uiRoot, parent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + self.Parent = parent + self.GridPool = {} + XTool.InitUiObject(self) + self.GridItem.gameObject:SetActiveEx(false) +end + +function XUiPanelFavorabilityFile:OnRefresh() + self:RefreshDatas() +end + +function XUiPanelFavorabilityFile:RefreshDatas() + local characterId = self.UiRoot:GetCurrFavorabilityCharacter() + if not characterId then + return + end + local fileData = XFavorabilityConfigs.GetCharacterBaseDataById(characterId) + + if fileData == nil then + return + end + + self.TxtRoleName.text = XDataCenter.FavorabilityManager.GetNameWithTitleById(characterId) + self.TxtTradeName.text = XCharacterConfigs.GetCharacterTradeName(characterId) + + self:GenerateDataGrid(fileData) +end + +function XUiPanelFavorabilityFile:GenerateDataGrid(fileData) + -- 回收格子 + for i = self.DataContent.transform.childCount - 1, 0, -1 do + local grid = self.DataContent:GetChild(i) + local gridGO = grid.gameObject + + if gridGO.activeSelf then + gridGO:SetActiveEx(false) + table.insert(self.GridPool, gridGO) + end + end + + -- 拿出格子 + for i, dataTitle in ipairs(fileData.BaseDataTitle) do + local grid + + if next(self.GridPool) then + grid = table.remove(self.GridPool) + else + grid = CS.UnityEngine.Object.Instantiate(self.GridItem) + end + + -- 数据赋值 + grid.transform:SetParent(self.DataContent, false) + local txtTitle = XUiHelper.TryGetComponent(grid.transform, "TxtBaseDataTitle", "Text") + local txtData = XUiHelper.TryGetComponent(grid.transform, "TxtBaseData", "Text") + txtTitle.text = dataTitle + txtData.text = fileData.BaseData[i] or "" + + grid.gameObject:SetActiveEx(true) + end +end + +function XUiPanelFavorabilityFile:SetViewActive(isActive) + self.GameObject:SetActive(isActive) + if isActive then + self:RefreshDatas() + end +end + +function XUiPanelFavorabilityFile:OnSelected(isSelected) + self.GameObject:SetActive(isSelected) + if isSelected then + self:RefreshDatas() + end +end + +return XUiPanelFavorabilityFile \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFavorability/XUiPanelFavorabilityInfo.lua b/Resources/Scripts/XUi/XUiFavorability/XUiPanelFavorabilityInfo.lua new file mode 100644 index 00000000..312585ed --- /dev/null +++ b/Resources/Scripts/XUi/XUiFavorability/XUiPanelFavorabilityInfo.lua @@ -0,0 +1,137 @@ +XUiPanelFavorabilityInfo = XClass(nil, "XUiPanelFavorabilityInfo") + +function XUiPanelFavorabilityInfo:Ctor(ui, uiRoot, parent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + self.Parent = parent + XTool.InitUiObject(self) + self.GridLikeInfoItem.gameObject:SetActiveEx(false) + self.PanelEmpty.gameObject:SetActiveEx(false) +end + +function XUiPanelFavorabilityInfo:OnRefresh() + -- 动画加这里 + self:RefreshDatas() +end + +function XUiPanelFavorabilityInfo:RefreshDatas() + local characterId = self.UiRoot:GetCurrFavorabilityCharacter() + local informations = XFavorabilityConfigs.GetCharacterInformationById(characterId) + + if not self.Toggle then + local toggle = {} + + self.Toggle = toggle + + end + + self:UpdateDataList(informations) +end + +function XUiPanelFavorabilityInfo:GetProxyType() + return "XUiGridLikeInfoItem" +end + +function XUiPanelFavorabilityInfo:UpdateDataList(dataList) + if not dataList or next(dataList) == nil then + self.PanelEmpty.gameObject:SetActiveEx(true) + self.TxtNoDataTip.text = CS.XTextManager.GetText("FavorabilityNoInfoData") + self.DataList = {} + else + self.PanelEmpty.gameObject:SetActiveEx(false) + self:SortInformation(dataList) + self.DataList = dataList + end + + + + if not self.DynamicTableData then + self.DynamicTableData = XDynamicTableIrregular.New(self.PanelDataList) + self.DynamicTableData:SetProxy("XUiGridLikeInfoItem", XUiGridLikeInfoItem, self.GridLikeInfoItem.gameObject) + self.DynamicTableData:SetDelegate(self) + end + + self.DynamicTableData:SetDataSource(self.DataList) + self.DynamicTableData:ReloadDataASync() + +end + +function XUiPanelFavorabilityInfo:SortInformation(dataList) + local characterId = self.UiRoot:GetCurrFavorabilityCharacter() + for _, dataItem in pairs(dataList) do + local isUnlock = XDataCenter.FavorabilityManager.IsInformationUnlock(characterId, dataItem.Id) + local canUnlock = XDataCenter.FavorabilityManager.CanInformationUnlock(characterId, dataItem.Id) + dataItem.priority = 2 + if not isUnlock then + dataItem.priority = canUnlock and 1 or 3 + end + end + table.sort(dataList, function(dataItemA, dataItemB) + if dataItemA.priority == dataItemB.priority then + return dataItemA.Id < dataItemB.Id + else + return dataItemA.priority < dataItemB.priority + end + end) +end + +-- [监听动态列表事件] +function XUiPanelFavorabilityInfo:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self.UiRoot) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.DataList[index] + if data ~= nil then + grid:OnRefresh(self.DataList[index], self.Toggle[data.Id]) + end + + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + self.CurData = self.DataList[index] + self:OnDataClick(index, grid) + end +end + +-- [点击资料] +function XUiPanelFavorabilityInfo:OnDataClick(index, grid) + if not self.CurData then return end + local characterId = self.UiRoot:GetCurrFavorabilityCharacter() + local isUnlock = XDataCenter.FavorabilityManager.IsInformationUnlock(characterId, self.CurData.Id) + local canUnlock = XDataCenter.FavorabilityManager.CanInformationUnlock(characterId, self.CurData.Id) + if isUnlock then + self.Toggle[self.CurData.Id] = self.Toggle[self.CurData.Id] or false + self.Toggle[self.CurData.Id] = not self.Toggle[self.CurData.Id] + self.DynamicTableData:ReloadDataASync() + elseif canUnlock then + XDataCenter.FavorabilityManager.OnUnlockCharacterInfomatin(characterId, self.CurData.Id) + XEventManager.DispatchEvent(XEventId.EVENT_FAVORABILITY_INFOUNLOCK) + grid:HideRedDot() + self.Toggle[self.CurData.Id] = not self.Toggle[self.CurData.Id] or false + self.Toggle[self.CurData.Id] = self.Toggle[self.CurData.Id] + self.DynamicTableData:ReloadDataASync() + else + -- 提示解锁条件 + XUiManager.TipMsg(self.CurData.ConditionDescript) + end +end + +function XUiPanelFavorabilityInfo:SetViewActive(isActive) + + self.Toggle = {} + + self.GameObject:SetActive(isActive) + if isActive then + self:RefreshDatas() + end +end + +function XUiPanelFavorabilityInfo:OnSelected(isSelected) + self.GameObject:SetActive(isSelected) + if isSelected then + self:RefreshDatas() + end +end + + + +return XUiPanelFavorabilityInfo \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFavorability/XUiPanelFavorabilityMain.lua b/Resources/Scripts/XUi/XUiFavorability/XUiPanelFavorabilityMain.lua new file mode 100644 index 00000000..7bffb0d4 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFavorability/XUiPanelFavorabilityMain.lua @@ -0,0 +1,531 @@ +XUiPanelFavorabilityMain = XClass(nil, "XUiPanelFavorabilityMain") + +local FuncType = { + File = 1, + Info = 2, + Secret = 3, + Audio = 4, + Story = 5, + Gift = 6, + Action = 7, +} + +local CvType = { + JPN = 1, + CN = 2, + HK = 3, +} + +local ExpSchedule = nil +local Delay_Second = CS.XGame.ClientConfig:GetInt("FavorabilityDelaySecond") / 1000 +local blue = "#87C8FF" +local white = "#ffffff" + +function XUiPanelFavorabilityMain:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + XTool.InitUiObject(self) + self.IsExpTweening = false + self.TxtNormalPos = self.TxtFavorabilityLv.rectTransform.anchoredPosition + self.TxtMaxPos = CS.UnityEngine.Vector2(self.TxtNormalPos.x, self.TxtNormalPos.y - 18) + self.CvType = CS.UnityEngine.PlayerPrefs.GetInt("CV_TYPE", CvType.JPN)--CvType.JPN-- + self:InitUiAfterAuto() +end + +function XUiPanelFavorabilityMain:InitUiAfterAuto() + + local characterId = self.UiRoot:GetCurrFavorabilityCharacter() + + self.RedPointPlotId = XRedPointManager.AddRedPointEvent(self.PlotRed, nil, self, { XRedPointConditions.Types.CONDITION_FAVORABILITY_PLOT }, { CharacterId = characterId }) + self.RedPointInfoId = XRedPointManager.AddRedPointEvent(self.InfoRed, nil, self, { XRedPointConditions.Types.CONDITION_FAVORABILITY_DOCUMENT_INFO }, { CharacterId = characterId }) + self.RedPointRumorId = XRedPointManager.AddRedPointEvent(self.SecretRed, nil, self, { XRedPointConditions.Types.CONDITION_FAVORABILITY_DOCUMENT_RUMOR }, { CharacterId = characterId }) + self.RedPointAudioId = XRedPointManager.AddRedPointEvent(self.SoundRed, nil, self, { XRedPointConditions.Types.CONDITION_FAVORABILITY_DOCUMENT_AUDIO }, { CharacterId = characterId }) + self.RedPointActionId = XRedPointManager.AddRedPointEvent(self.ActionRed, nil, self, { XRedPointConditions.Types.CONDITION_FAVORABILITY_DOCUMENT_ACTION }, { CharacterId = characterId }) + + + self.BtnBack.CallBack = function() self:OnBtnReturnClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + + + self.FavorabilityFile = XUiPanelFavorabilityFile.New(self.PanelFavorabilityFile, self.UiRoot, self) + self.FavorabilityInfo = XUiPanelFavorabilityInfo.New(self.PanelFavorabilityInfo, self.UiRoot, self) + self.FavorabilityRumors = XUiPanelFavorabilityRumors.New(self.PanelFavorabilityRumors, self.UiRoot, self) + self.FavorabilityAudio = XUiPanelFavorabilityAudio.New(self.PanelFavorabilityAudio, self.UiRoot, self) + self.FavorabilityPlot = XUiPanelFavorabilityPlot.New(self.PanelFavorabilityPlot, self.UiRoot, self) + self.FavorabilityGift = XUiPanelLikeGiveGift.New(self.PanelFavorabilityGift, self.UiRoot, self) + self.FavorabilityAction = XUiPanelFavorabilityAction.New(self.PanelFavorabilityAction, self.UiRoot, self) + + self.FavorabilityFile:OnSelected(false) + self.FavorabilityInfo:OnSelected(false) + self.FavorabilityRumors:OnSelected(false) + self.FavorabilityAudio:OnSelected(false) + self.FavorabilityGift:OnSelected(false) + self.FavorabilityPlot:OnSelected(false) + self.FavorabilityAction:OnSelected(false) + + -- 初始化按钮 + self.BtnTabList = {} + self.BtnTabList[FuncType.File] = self.BtnFile + self.BtnTabList[FuncType.Info] = self.BtnInfo + + self.BtnTabList[FuncType.Secret] = self.BtnSecret + self.BtnTabList[FuncType.Audio] = self.BtnSound + self.BtnTabList[FuncType.Story] = self.BtnPlot + self.BtnTabList[FuncType.Gift] = self.BtnGift + self.BtnTabList[FuncType.Action] = self.BtnAction + self.MenuBtnGroup:Init(self.BtnTabList, function(index) self:OnBtnTabListClick(index) end) + + self.BtnCvList = {} + self.BtnCvList[CvType.JPN] = self.BtnJap + self.BtnCvList[CvType.CN] = self.BtnMandarin + self.BtnCvList[CvType.HK] = self.BtnCantonese + self.PanelCvType:Init(self.BtnCvList, function(index) self:OnBtnCvListClick(index) end) + + + self.CurSelectedPanel = nil + local selected = self:GetAvailableSelectTab() + self:OnBtnTabListClick(selected) + self.CurrentSelectTab = selected + self.MenuBtnGroup:SelectIndex(self.CurrentSelectTab) + +end + +function XUiPanelFavorabilityMain:OnBtnCvListClick(index) + if self.BtnCvList[index].ButtonState == CS.UiButtonState.Disable then + return + end + self.CvType = index + self:UpdateCvName() +end + +function XUiPanelFavorabilityMain:UpdateCvName() + local currentCharacterId = self.UiRoot:GetCurrFavorabilityCharacter() + local castName = XFavorabilityConfigs.GetCharacterCvByIdAndType(currentCharacterId, self.CvType) + local cast = (castName ~= "") and CS.XTextManager.GetText("FavorabilityCast", tostring(castName)) or "" + self.TxtCV.text = cast +end + +function XUiPanelFavorabilityMain:GetAvailableSelectTab() + return FuncType.File +end + +-- [刷新主界面] +function XUiPanelFavorabilityMain:RefreshDatas() + self:UpdateDatas() +end + + + +function XUiPanelFavorabilityMain:UpdateDatas() + self.PanelMenu.gameObject:SetActiveEx(true) + + self:UpdateAllInfos() + self:UpdateCvName() +end + +function XUiPanelFavorabilityMain:UpdateAllInfos(doAnim) + -- 好感度信息 + self:UpdateMainInfo(doAnim) + + -- 红点checkcheck + self:CheckLockAndReddots() +end + +function XUiPanelFavorabilityMain:UpdateMainInfo(doAnim) + local characterId = self.UiRoot:GetCurrFavorabilityCharacter() + local curExp = tonumber(XDataCenter.FavorabilityManager.GetCurrCharacterExp(characterId)) + local trustLv = XDataCenter.FavorabilityManager.GetCurrCharacterFavorabilityLevel(characterId) + local name = XCharacterConfigs.GetCharacterName(characterId) + local tradeName = XCharacterConfigs.GetCharacterTradeName(characterId) + local isCollaborationCharacter = XFavorabilityConfigs.IsCollaborationCharacter(characterId) + self.TxtRoleName.text = string.format("%s %s", name, tradeName) + + local curFavorabilityTableData = XDataCenter.FavorabilityManager.GetFavorabilityTableData(characterId) + if curFavorabilityTableData == nil then return end + self.ImgExp.gameObject:SetActiveEx(true) + + if not doAnim then + self.ImgExp.fillAmount = curExp / (tonumber(curFavorabilityTableData.Exp) * 1) + self.TxtLevel.text = trustLv + end + self.UiRoot:SetUiSprite(self.ImgHeart, XFavorabilityConfigs.GetTrustLevelIconByLevel(trustLv)) + self.TxtFavorabilityLv.text = XDataCenter.FavorabilityManager.GetFavorabilityColorWorld(trustLv, curFavorabilityTableData.Name)--curFavorabilityTableData.Name + + --是不是联动角色 + if isCollaborationCharacter then + local icon = XFavorabilityConfigs.GetCollaborationCharacterIcon(characterId) + local tip = XFavorabilityConfigs.GetCollaborationCharacterText(characterId) + local cvType = XFavorabilityConfigs.GetCollaborationCharacterCvType(characterId) + local iconPos = XFavorabilityConfigs.GetCollaborationCharacterIconPos(characterId) + local iconScale = XFavorabilityConfigs.GetCollaborationCharacterIconScale(characterId) + + --联动角色是否可以使用当前设置的语言 + local hasSettingCvType = false + + --是否配置icon + if icon then + self.RImgCollaboration:SetRawImage(icon,function() + self.RImgCollaboration:SetNativeSize() + if iconScale ~= 0 then + self.RImgCollaboration.rectTransform.localScale = CS.UnityEngine.Vector3(iconScale, iconScale, iconScale) + else + self.RImgCollaboration.rectTransform.localScale = CS.UnityEngine.Vector3.one + end + local x = (iconPos.X ~= 0) and iconPos.X or self.RImgCollaboration.rectTransform.anchoredPosition.x + local y = (iconPos.Y ~= 0) and iconPos.Y or self.RImgCollaboration.rectTransform.anchoredPosition.y + self.RImgCollaboration.rectTransform.anchoredPosition = CS.UnityEngine.Vector2(x, y) + + end) + self.RImgCollaboration.gameObject:SetActiveEx(true) + else + self.RImgCollaboration.gameObject:SetActiveEx(false) + end + + --是否配置语言提示 + if tip then + self.TxtTips.text = tip + self.TxtTips.gameObject:SetActiveEx(true) + else + self.TxtTips.gameObject:SetActiveEx(false) + end + + --是否可以使用当前设置的语言 + for _,v in pairs(cvType) do + if v == self.CvType then + hasSettingCvType = true + end + end + + --禁用不可使用的语言 + for _, v in pairs(self.BtnCvList) do + v:SetDisable(true) + end + for _,v in pairs(cvType) do + self.BtnCvList[v]:SetDisable(false) + end + + if not hasSettingCvType then + self.PanelCvType:SelectIndex(cvType[1]) + else + self.PanelCvType:SelectIndex(self.CvType) + end + else + --不是联动角色,恢复语音选择按钮状态 + for _, v in pairs(self.BtnCvList) do + v:SetDisable(false) + end + self.PanelCvType:SelectIndex(self.CvType) + self.RImgCollaboration.gameObject:SetActiveEx(false) + self.TxtTips.gameObject:SetActiveEx(false) + end + + self:ResetPreviewExp() + + self:CheckExp(characterId) +end + +function XUiPanelFavorabilityMain:UpdatePreviewExp(args) + if not args then + self:ResetPreviewExp() + return + end + + local trustItems = args[1] + + --local count = args[2] + if not trustItems then + self:ResetPreviewExp() + return + end + + local characterId = self.UiRoot:GetCurrFavorabilityCharacter() + local isMax = XDataCenter.FavorabilityManager.IsMaxFavorabilityLevel(characterId) + if isMax then + return + end + + local curExp = tonumber(XDataCenter.FavorabilityManager.GetCurrCharacterExp(characterId)) + + local curFavorabilityTableData = XDataCenter.FavorabilityManager.GetFavorabilityTableData(characterId) + if not curFavorabilityTableData then + self:ResetPreviewExp() + return + end + + local favorData = XFavorabilityConfigs.GetTrustExpById(characterId) + + local addExp = 0 + for i, var in ipairs(trustItems) do + local favorExp = var.TrustItem.Exp + for _, v in pairs(var.TrustItem.FavorCharacterId) do + if v == characterId then + favorExp = var.TrustItem.FavorExp + break + end + end + addExp = addExp + favorExp * var.Count + end + + local totalExp = addExp + curExp + local startLevel = XDataCenter.FavorabilityManager.GetCurrCharacterFavorabilityLevel(characterId) + local trustLv, leftExp, levelExp = XFavorabilityConfigs.GetFavorabilityLevel(characterId, totalExp, startLevel) + + self.ImgExp.gameObject:SetActiveEx(startLevel >= trustLv) + + self.ImgExpUp.fillAmount = leftExp / levelExp + self.TxtLevel.text = trustLv + self.UiRoot:SetUiSprite(self.ImgHeart, XFavorabilityConfigs.GetTrustLevelIconByLevel(trustLv)) + self.TxtFavorabilityLv.text = XDataCenter.FavorabilityManager.GetFavorabilityColorWorld(trustLv, favorData[trustLv].Name)--curFavorabilityTableData.Name + self.TxtFavorabilityExpNum.text = string.format("%d / %s", blue, leftExp, levelExp) + + + local maxLevel = XFavorabilityConfigs.GetMaxFavorabilityLevel(characterId) + self.TxtFavorabilityExpNum.gameObject:SetActiveEx(maxLevel ~= trustLv) + self.TxtFavorabilityLv.rectTransform.anchoredPosition = maxLevel ~= trustLv and self.TxtNormalPos or self.TxtMaxPos + +end + +function XUiPanelFavorabilityMain:ResetPreviewExp() + self.ImgExpUp.fillAmount = 0 + self:UpdateExpNum(white) +end + + +function XUiPanelFavorabilityMain:UpdateExpNum(color, showExp) + local characterId = self.UiRoot:GetCurrFavorabilityCharacter() + local curFavorabilityTableData = XDataCenter.FavorabilityManager.GetFavorabilityTableData(characterId) + local curExp = tonumber(XDataCenter.FavorabilityManager.GetCurrCharacterExp(characterId)) + curExp = (showExp == nil) and curExp or showExp + self.TxtFavorabilityExpNum.gameObject:SetActiveEx(true) + self.TxtFavorabilityLv.rectTransform.anchoredPosition = self.TxtNormalPos + + local isMax = XDataCenter.FavorabilityManager.IsMaxFavorabilityLevel(characterId) + if isMax then + self.TxtFavorabilityExpNum.gameObject:SetActiveEx(false) + self.TxtFavorabilityLv.rectTransform.anchoredPosition = self.TxtMaxPos + curExp = 0 + end + + if curFavorabilityTableData == nil then return end + if curFavorabilityTableData.Exp <= 0 then + self.TxtFavorabilityExpNum.text = string.format("%d", curExp) + else + self.TxtFavorabilityExpNum.text = string.format("%d / %s", color, curExp, tostring(curFavorabilityTableData.Exp)) + end +end + +-- [发送检查红点事件] +function XUiPanelFavorabilityMain:CheckLockAndReddots() + local characterId = self.UiRoot:GetCurrFavorabilityCharacter() + XRedPointManager.Check(self.RedPointPlotId, { CharacterId = characterId }) + XRedPointManager.Check(self.RedPointRumorId, { CharacterId = characterId }) + XRedPointManager.Check(self.RedPointAudioId, { CharacterId = characterId }) + XRedPointManager.Check(self.RedPointInfoId, { CharacterId = characterId }) + XRedPointManager.Check(self.RedPointActionId, { CharacterId = characterId }) +end + +-- [关闭功能按钮界面] +function XUiPanelFavorabilityMain:CloseFuncBtns() + self.PanelMenu.gameObject:SetActiveEx(false) + self.RImgCollaboration.gameObject:SetActiveEx(false) + self.PanelCvType.gameObject:SetActiveEx(false) + self.FavorabilityAudio:UnScheduleAudio() + + if self.CurSelectedPanel then + self.CurSelectedPanel:SetViewActive(false) + end +end + +function XUiPanelFavorabilityMain:OpenFuncBtns() + self:PanelCvTypeShow() + if self.CurSelectedPanel then + self.CurSelectedPanel:SetViewActive(true) + end +end + +-- [点击的功能是否开启,如果未开启,提示] +function XUiPanelFavorabilityMain:CheckClickIsLock(funcName) + local isOpen = XFunctionManager.JudgeCanOpen(funcName) + local uplockTips = XFunctionManager.GetFunctionOpenCondition(funcName) + if not isOpen then + XUiManager.TipError(uplockTips) + end + return isOpen +end + + + +-- [打开档案] +function XUiPanelFavorabilityMain:OnBtnFileClick() + self.UiRoot:OpenInformationView() +end + +-- [打开剧情] +function XUiPanelFavorabilityMain:OnBtnPlotClick() + if not self:CheckClickIsLock(XFunctionManager.FunctionName.FavorabilityStory) then return end + self.UiRoot:OpenPlotView() +end + +-- [打开礼物] +function XUiPanelFavorabilityMain:OnBtnGiftClick() + if not self:CheckClickIsLock(XFunctionManager.FunctionName.FavorabilityGift) then return end + self.UiRoot:OpenGiftView() +end + +function XUiPanelFavorabilityMain:OnBtnTabListClick(index) + if self.LastSelectTab then + self.UiRoot:PlayBaseTabAnim() + end + + if index == self.CurrentSelectTab then + return + end + + + if self.CurrentSelectTab == FuncType.Gift then + self:UpdateMainInfo() + end + + self.LastSelectTab = self.CurrentSelectTab + self.CurrentSelectTab = index + + if self.CurSelectedPanel then + self.CurSelectedPanel:OnSelected(false) + end + + self.UiRoot:ChangeViewType(index) + + + if index == FuncType.File then + self.CurSelectedPanel = self.FavorabilityFile + elseif index == FuncType.Info then + self.CurSelectedPanel = self.FavorabilityInfo + elseif index == FuncType.Secret then + self.CurSelectedPanel = self.FavorabilityRumors + elseif index == FuncType.Audio then + self.CurSelectedPanel = self.FavorabilityAudio + elseif index == FuncType.Story then + self.CurSelectedPanel = self.FavorabilityPlot + elseif index == FuncType.Gift then + self.CurSelectedPanel = self.FavorabilityGift + elseif index == FuncType.Action then + self.CurSelectedPanel = self.FavorabilityAction + end + + self:PanelCvTypeShow() + self.CurSelectedPanel:OnSelected(true) +end + +function XUiPanelFavorabilityMain:PanelCvTypeShow() + if self.CurrentSelectTab == FuncType.Audio or self.CurrentSelectTab == FuncType.Action then + self.PanelCvType.gameObject:SetActiveEx(true) + self.BtnCantonese.gameObject:SetActiveEx(false) + else + self.PanelCvType.gameObject:SetActiveEx(false) + end + --self.PanelCvType.gameObject:SetActiveEx(false) +end + +-- [返回] +function XUiPanelFavorabilityMain:OnBtnReturnClick() + self.UiRoot:SetCurrFavorabilityCharacter(nil) + self.UiRoot:Close() +end + +function XUiPanelFavorabilityMain:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiPanelFavorabilityMain:StopCvContent() + return self.UiRoot:StopCvContent() +end + +function XUiPanelFavorabilityMain:GetCurrFavorabilityCharacter() + return self.UiRoot:GetCurrFavorabilityCharacter() +end + +function XUiPanelFavorabilityMain:DoFillAmountTween(lastLevel, lastExp, totalExp, isReset) + local characterId = self.UiRoot:GetCurrFavorabilityCharacter() + local levelUpDatas = XFavorabilityConfigs.GetTrustExpById(characterId) + if not levelUpDatas or not levelUpDatas[lastLevel] then + self:UpdateAnimInfo(characterId) + return + end + if isReset then + self.ImgExp.fillAmount = 0 + else + XLuaUiManager.SetMask(true) + end + + self.IsExpTweening = true + local progress = 1 + if lastExp + totalExp < levelUpDatas[lastLevel].Exp then + progress = (lastExp + totalExp) / levelUpDatas[lastLevel].Exp + totalExp = 0 + else + totalExp = totalExp - (levelUpDatas[lastLevel].Exp - lastExp) + end + + + self.ImgExp.gameObject:SetActiveEx(true) + + self.ImgExp:DOFillAmount(progress, Delay_Second) + ExpSchedule = XScheduleManager.ScheduleOnce(function() + local maxLevel = XFavorabilityConfigs.GetMaxFavorabilityLevel(characterId) + if totalExp <= 0 or maxLevel == lastLevel then + self:UpdateAnimInfo(characterId) + self:UnScheduleExp() + else + self.TxtLevel.text = lastLevel + 1 + self:DoFillAmountTween(lastLevel + 1, 0, totalExp, true) + end + end, Delay_Second * 1000 + 20) +end + +-- 动画执行不了则走这里 +function XUiPanelFavorabilityMain:UpdateAnimInfo(characterId) + local trustLv = XDataCenter.FavorabilityManager.GetCurrCharacterFavorabilityLevel(characterId) + self.TxtLevel.text = trustLv + self:CheckExp(characterId) +end + +function XUiPanelFavorabilityMain:CheckExp(characterId) + local isMax = XDataCenter.FavorabilityManager.IsMaxFavorabilityLevel(characterId) + if isMax then + self.ImgExp.fillAmount = 0 + self.TxtFavorabilityExpNum.text = 0 + return + end + + local curExp = tonumber(XDataCenter.FavorabilityManager.GetCurrCharacterExp(characterId)) + if curExp <= 0 and self.ImgExp.fillAmount >= 1 then + self.ImgExp.fillAmount = 0 + end +end + +function XUiPanelFavorabilityMain:UnScheduleExp() + if ExpSchedule then + XScheduleManager.UnSchedule(ExpSchedule) + ExpSchedule = nil + self.IsExpTweening = false + XLuaUiManager.SetMask(false) + end +end + +function XUiPanelFavorabilityMain:OnClose() + self:UnScheduleExp() + self.FavorabilityAudio:OnClose() + self.FavorabilityAction:OnClose() +end + +function XUiPanelFavorabilityMain:SetTopControlActive(isActive) + self.TopControl.gameObject:SetActiveEx(isActive) +end + + +function XUiPanelFavorabilityMain:SetUiSprite(image, spriteName, callBack) + self.UiRoot:SetUiSprite(image, spriteName, callBack) +end + +return XUiPanelFavorabilityMain \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFavorability/XUiPanelFavorabilityMessage.lua b/Resources/Scripts/XUi/XUiFavorability/XUiPanelFavorabilityMessage.lua new file mode 100644 index 00000000..8a854dd0 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFavorability/XUiPanelFavorabilityMessage.lua @@ -0,0 +1,127 @@ +XUiPanelFavorabilityMessage = XClass(nil, "XUiPanelFavorabilityMessage") + +function XUiPanelFavorabilityMessage:Ctor(ui, uiRoot, parent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + self.Parent = parent + self:InitAutoScript() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelFavorabilityMessage:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiPanelFavorabilityMessage:AutoInitUi() + self.PanelDataList = self.Transform:Find("PanelDataList") + self.GridLikeMessageItem = self.Transform:Find("PanelDataList/Viewport/GridLikeMessageItem") + self.ScrollbarVertical = self.Transform:Find("PanelDataList/ScrollbarVertical"):GetComponent("Scrollbar") +end + +function XUiPanelFavorabilityMessage:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelFavorabilityMessage:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelFavorabilityMessage:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelFavorabilityMessage:AutoAddListener() +end +-- auto +function XUiPanelFavorabilityMessage:OnRefresh() + self:RefreshDatas() +end + +function XUiPanelFavorabilityMessage:RefreshDatas() + local characterId = self.UiRoot:GetCurrFavorabilityCharacter() + local informations = XFavorabilityConfigs.GetCharacterInformationById(characterId) + self:UpdateDataList(informations, 1) + self.Parent:CheckDataReddot() +end + +function XUiPanelFavorabilityMessage:GetProxyType() + return "XUiGridLikeMessageItem" +end + +function XUiPanelFavorabilityMessage:UpdateDataList(dataList, selectIdx) + + if not dataList then + XLog.Warning("XUiPanelFavorabilityMessage:UpdateDataList error: dataList is nil") + return + end + + self.DataList = dataList + self.CurData = self.DataList[selectIdx] + + if not self.DynamicTableData then + self.DynamicTableData = XDynamicTableIrregular.New(self.PanelDataList) + self.DynamicTableData:SetProxy("XUiGridLikeMessageItem", XUiGridLikeMessageItem, self.GridLikeMessageItem.gameObject) + self.DynamicTableData:SetDelegate(self) + end + + self.DynamicTableData:SetDataSource(self.DataList) + self.DynamicTableData:ReloadDataASync(selectIdx) + +end + +-- [监听动态列表事件] +function XUiPanelFavorabilityMessage:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self.UiRoot) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.DataList[index] + if data ~= nil then + grid:OnRefresh(self.DataList[index], index) + end + + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + self.CurData = self.DataList[index] + self:OnDataClick(index, grid) + end +end + +-- [策划想要打开一个item,关闭其他打开中的item效果] +function XUiPanelFavorabilityMessage:ResetOtherItems(index) + for k, v in pairs(self.DataList) do + if index ~= k then + v.IsToggle = false + end + end +end + +-- [点击资料] +function XUiPanelFavorabilityMessage:OnDataClick(index, grid) + local characterId = self.UiRoot:GetCurrFavorabilityCharacter() + local isUnlock = XDataCenter.FavorabilityManager.IsInformationUnlock(characterId, self.CurData.Id) + local canUnlock = XDataCenter.FavorabilityManager.CanInformationUnlock(characterId, self.CurData.Id) + if isUnlock then + self:ResetOtherItems(index) + grid:OnToggle() + self.DynamicTableData:ReloadDataASync(1) + else + if canUnlock then + XDataCenter.FavorabilityManager.OnUnlockCharacterInfomatin(characterId, self.CurData.Id, function() + self:RefreshDatas() + end, self.CurData.Title) + else + -- 提示解锁条件 + XUiManager.TipMsg(self.CurData.ConditionDescript) + end + end +end + + +return XUiPanelFavorabilityMessage \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFavorability/XUiPanelFavorabilityPlot.lua b/Resources/Scripts/XUi/XUiFavorability/XUiPanelFavorabilityPlot.lua new file mode 100644 index 00000000..66a97940 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFavorability/XUiPanelFavorabilityPlot.lua @@ -0,0 +1,128 @@ +XUiPanelFavorabilityPlot = XClass(nil, "XUiPanelFavorabilityPlot") + +function XUiPanelFavorabilityPlot:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + XTool.InitUiObject(self) + self.GridLikePlotItem.gameObject:SetActiveEx(false) + self.PanelEmpty.gameObject:SetActiveEx(false) +end + + + +function XUiPanelFavorabilityPlot:RefreshDatas() + self:LoadDatas() +end + +function XUiPanelFavorabilityPlot:LoadDatas() + local currentCharacterId = self.UiRoot:GetCurrFavorabilityCharacter() + local plotDatas = XFavorabilityConfigs.GetCharacterStoryById(currentCharacterId) + self:UpdatePlotList(plotDatas) +end + +function XUiPanelFavorabilityPlot:UpdatePlotList(poltList) + + if not poltList then + self.PanelEmpty.gameObject:SetActiveEx(true) + self.TxtNoDataTip.text = CS.XTextManager.GetText("FavorabilityNoPlotData") + self.PoltList = { } + else + self.PanelEmpty.gameObject:SetActiveEx(false) + self:SortPlots(poltList) + self.PoltList = poltList + end + + if not self.DynamicTablePolt then + self.DynamicTablePolt = XDynamicTableNormal.New(self.SViewPlotList.gameObject) + self.DynamicTablePolt:SetProxy(XUiGridLikePlotItem) + self.DynamicTablePolt:SetDelegate(self) + end + + self.DynamicTablePolt:SetDataSource(self.PoltList) + self.DynamicTablePolt:ReloadDataASync() +end + +function XUiPanelFavorabilityPlot:SortPlots(plotList) + local characterId = self.UiRoot:GetCurrFavorabilityCharacter() + for _, plot in pairs(plotList) do + local isUnlock = XDataCenter.FavorabilityManager.IsStoryUnlock(characterId, plot.Id) + local canUnlock = XDataCenter.FavorabilityManager.CanStoryUnlock(characterId, plot.Id) + plot.priority = 2 + if not isUnlock then + plot.priority = canUnlock and 1 or 3 + end + end + table.sort(plotList, function(plotA, plotB) + if plotA.priority == plotB.priority then + return plotA.Id < plotB.Id + else + return plotA.priority < plotB.priority + end + end) +end + +-- [列表事件] +function XUiPanelFavorabilityPlot:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self.UiRoot) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.PoltList[index] + if data ~= nil then + grid:OnRefresh(data, index) + end + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + self.CurPolt = self.PoltList[index] + if not self.CurPolt then return end + self:OnPlotClick(self.CurPolt, grid) + end +end + +-- [剧情条目点击事件] +function XUiPanelFavorabilityPlot:OnPlotClick(plotData, grid) + local characterId = self.UiRoot:GetCurrFavorabilityCharacter() + local isUnlock = XDataCenter.FavorabilityManager.IsStoryUnlock(characterId, plotData.Id) + local canUnlock = XDataCenter.FavorabilityManager.CanStoryUnlock(characterId, plotData.Id) + + if isUnlock then + XDataCenter.MovieManager.PlayMovie(plotData.StoryId, function() + self.UiRoot.SignBoard:SetRoll(true) + self.UiRoot.SignBoard:Resume() + end) + self.UiRoot:StopCvContent() + self.UiRoot.FavorabilityMain.FavorabilityAudio:UnScheduleAudio() + self.UiRoot.SignBoard:SetRoll(false) + self.UiRoot.SignBoard:Freeze() + elseif canUnlock then + self.UiRoot:StopCvContent() + self.UiRoot.FavorabilityMain.FavorabilityAudio:UnScheduleAudio() + grid:HideRedDot() + XDataCenter.FavorabilityManager.OnUnlockCharacterStory(characterId, plotData.Id) + XEventManager.DispatchEvent(XEventId.EVENT_FAVORABILITY_PLOTUNLOCK) + XDataCenter.MovieManager.PlayMovie(plotData.StoryId, function() + self.UiRoot.SignBoard:SetRoll(true) + self.UiRoot.SignBoard:Resume() + end) + self.UiRoot.SignBoard:SetRoll(false) + self.UiRoot.SignBoard:Freeze() + else + XUiManager.TipMsg(plotData.ConditionDescript) + end +end + +function XUiPanelFavorabilityPlot:SetViewActive(isActive) + self.GameObject:SetActive(isActive) + if isActive then + self:RefreshDatas() + end +end + +function XUiPanelFavorabilityPlot:OnSelected(isSelected) + self.GameObject:SetActive(isSelected) + if isSelected then + self:RefreshDatas() + end +end + + +return XUiPanelFavorabilityPlot \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFavorability/XUiPanelFavorabilityRumors.lua b/Resources/Scripts/XUi/XUiFavorability/XUiPanelFavorabilityRumors.lua new file mode 100644 index 00000000..0f91c66c --- /dev/null +++ b/Resources/Scripts/XUi/XUiFavorability/XUiPanelFavorabilityRumors.lua @@ -0,0 +1,142 @@ +XUiPanelFavorabilityRumors = XClass(nil, "XUiPanelFavorabilityRumors") + +function XUiPanelFavorabilityRumors:Ctor(ui, uiRoot, parent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + self.Parent = parent + + XTool.InitUiObject(self) + self.GridLikeRumorItem.gameObject:SetActiveEx(false) + self.PanelEmpty.gameObject:SetActiveEx(false) +end + +function XUiPanelFavorabilityRumors:OnRefresh() + self:RefreshDatas() +end + +function XUiPanelFavorabilityRumors:RefreshDatas() + local characterId = self.UiRoot:GetCurrFavorabilityCharacter() + local rumors = XFavorabilityConfigs.GetCharacterRumorsById(characterId) + + if not self.Toggle then + self.Toggle = {} + end + self:UpdateRumorsList(rumors) +end + +function XUiPanelFavorabilityRumors:InitDynamicTable() + self.DynamicTableRumors = XDynamicTableIrregular.New(self.PanelRumorsList) + self.DynamicTableRumors:SetProxy("XUiGridLikeRumorItem", XUiGridLikeRumorItem, self.GridLikeRumorItem.gameObject) + self.DynamicTableRumors:SetDelegate(self) +end + +function XUiPanelFavorabilityRumors:GetProxyType() + return "XUiGridLikeRumorItem" +end + +function XUiPanelFavorabilityRumors:UpdateRumorsList(rumors) + if not rumors then + self.PanelEmpty.gameObject:SetActiveEx(true) + self.TxtNoDataTip.text = CS.XTextManager.GetText("FavorabilityNoStrangeNewsData") + self.Rumors = {} + else + self.PanelEmpty.gameObject:SetActiveEx(false) + self:SortRumors(rumors) + self.Rumors = rumors + end + + if not self.DynamicTableRumors then + self:InitDynamicTable() + end + self.DynamicTableRumors:SetDataSource(self.Rumors) + self.DynamicTableRumors:ReloadDataASync() + +end + +function XUiPanelFavorabilityRumors:SortRumors(rumors) + -- 已解锁,可解锁,未解锁 + local characterId = self.UiRoot:GetCurrFavorabilityCharacter() + for _, rumor in pairs(rumors) do + local isUnlock = XDataCenter.FavorabilityManager.IsRumorUnlock(characterId, rumor.Id) + local canUnlock = XDataCenter.FavorabilityManager.CanRumorsUnlock(characterId, rumor.UnlockType, rumor.UnlockPara) + rumor.priority = 2 + if not isUnlock then + rumor.priority = canUnlock and 1 or 3 + end + end + table.sort(rumors, function(rumorA, rumorB) + if rumorA.priority == rumorB.priority then + return rumorA.Id < rumorB.Id + else + return rumorA.priority < rumorB.priority + end + end) +end + +-- [监听动态列表事件] +function XUiPanelFavorabilityRumors:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self.UiRoot) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.Rumors[index] + if data ~= nil then + grid:OnRefresh(self.Rumors[index], self.Toggle[data.Id]) + end + + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + self.CurRumor = self.Rumors[index] + if not self.CurRumor then return end + self:OnRumorClick(index, grid) + end +end + +function XUiPanelFavorabilityRumors:ResetOtherItems(index) + for k, v in pairs(self.Rumors) do + if index ~= k then + v.IsToggle = false + end + end +end + +-- [处理点击事件] +function XUiPanelFavorabilityRumors:OnRumorClick(index, grid) + local characterId = self.UiRoot:GetCurrFavorabilityCharacter() + local isUnlock = XDataCenter.FavorabilityManager.IsRumorUnlock(characterId, self.CurRumor.Id) + local canUnlock = XDataCenter.FavorabilityManager.CanRumorsUnlock(characterId, self.CurRumor.UnlockType, self.CurRumor.UnlockPara) + + if isUnlock then + self.Toggle[self.CurRumor.Id] = self.Toggle[self.CurRumor.Id] or false + self.Toggle[self.CurRumor.Id] = not self.Toggle[self.CurRumor.Id] + self.DynamicTableRumors:ReloadDataASync() + elseif canUnlock then + grid:HideRedDot() + XDataCenter.FavorabilityManager.OnUnlockCharacterRumor(characterId, self.CurRumor.Id) + XEventManager.DispatchEvent(XEventId.EVENT_FAVORABILITY_RUMERUNLOCK) + + self.Toggle[self.CurRumor.Id] = self.Toggle[self.CurRumor.Id] or false + self.Toggle[self.CurRumor.Id] = not self.Toggle[self.CurRumor.Id] + self.DynamicTableRumors:ReloadDataASync() + else + XUiManager.TipMsg(self.CurRumor.ConditionDescript) + end +end + +function XUiPanelFavorabilityRumors:SetViewActive(isActive) + self.Toggle = {} + self.GameObject:SetActive(isActive) + if isActive then + self:RefreshDatas() + end +end + +function XUiPanelFavorabilityRumors:OnSelected(isSelected) + self.GameObject:SetActive(isSelected) + if isSelected then + self:RefreshDatas() + end +end + + + +return XUiPanelFavorabilityRumors \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFavorability/XUiPanelLikeGiveGift.lua b/Resources/Scripts/XUi/XUiFavorability/XUiPanelLikeGiveGift.lua new file mode 100644 index 00000000..7a131071 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFavorability/XUiPanelLikeGiveGift.lua @@ -0,0 +1,449 @@ +XUiPanelLikeGiveGift = XClass(nil, "XUiPanelLikeGiveGift") + +local Default_Min_Num = 1 +local CSTextManagerGetText = CS.XTextManager.GetText +local CommunicationGiftMaxCount = CS.XGame.ClientConfig:GetInt("CommunicationGiftMaxCount") + +function XUiPanelLikeGiveGift:Ctor(ui, uiRoot, parentUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + self.ParentUi = parentUi + XTool.InitUiObject(self) + self:InitUiAfterAuto() + self.GridGiftItem.gameObject:SetActiveEx(false) + +end + +function XUiPanelLikeGiveGift:InitUiAfterAuto() + + --self:InitBtnLongClicks() + --self.BtnIncrease.CallBack = function() self:OnBtnIncreaseClick() end + --self.BtnDecrease.CallBack = function() self:OnBtnDecreaseClick() end + --self.BtnMax.CallBack = function() self:OnBtnMaxClick() end + self.BtnUse.CallBack = function() self:OnBtnUseClick() end + self.BtnGo.CallBack = function() self:OnBtnGoClick() end + +end + + +function XUiPanelLikeGiveGift:OnRefresh() + self:RefreshDatas() +end + +function XUiPanelLikeGiveGift:RefreshDatas() + self.CurTrustItem = nil + self.SelectedGifts = {} + self.SelectGiftItemList = {} + local trustItems = self:FilterTrustItems(XFavorabilityConfigs.GetAllCharacterSendGift()) + + + table.sort(trustItems, XDataCenter.FavorabilityManager.SortTrustItems) + self:UpdateTrustItemList(trustItems) + + -- self:UpdateBottomByClickItem() + -- self:UpdateTextCount(0) +end + +function XUiPanelLikeGiveGift:FilterTrustItems(items) + + local characterId = self.UiRoot:GetCurrFavorabilityCharacter() + local trustItems = {} + for _, v in pairs(items) do + local count = XDataCenter.ItemManager.GetCount(v.Id) + if count > 0 then + v.IsFavourWeight = self:IsContains(v.FavorCharacterId, characterId) and 1 or 0 + v.TrustItemQuality = XDataCenter.ItemManager.GetItemQuality(v.Id) + table.insert(trustItems, v) + end + end + return trustItems +end + +function XUiPanelLikeGiveGift:ResetSelectStatus() + for _, v in pairs(self.TrustItemList or {}) do + v.IsSelect = false + end +end + +-- [刷先礼物ListView] +function XUiPanelLikeGiveGift:UpdateTrustItemList(trustItemList) + if not trustItemList then + XLog.Warning("XUiPanelLikeGiveGift:UpdateTrustItemList 函数错误: 参数trustItemList不能为空") + end + + self.TrustItemList = trustItemList + self:ResetSelectStatus() + + if not self.DynamicTableTrustItem then + self.DynamicTableTrustItem = XDynamicTableNormal.New(self.SViewGiftList.gameObject) + self.DynamicTableTrustItem:SetProxy(XUiGridLikeSendGiftItem) + self.DynamicTableTrustItem:SetDelegate(self) + end + + local isZero = self:IsZeroGift(self.TrustItemList) + self.SViewGiftList.gameObject:SetActive(not isZero) + self.PanelEmpty.gameObject:SetActive(isZero) + self.BtnUse.gameObject:SetActiveEx(not isZero) + + if not isZero then + self.DynamicTableTrustItem:SetDataSource(self.TrustItemList) + self.DynamicTableTrustItem:ReloadDataASync() + + end +end + +function XUiPanelLikeGiveGift:IsZeroGift(itemList) + for _, itemData in pairs(itemList or {}) do + local itemNum = XDataCenter.ItemManager.GetCount(itemData.Id) + if itemNum > 0 then + return false + end + end + return true +end + +-- [监听动态列表事件] +function XUiPanelLikeGiveGift:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self.UiRoot, handler(self, self.Check), handler(self, self.OnGiftChangeCallBack), handler(self, self.PreCheck)) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.TrustItemList[index] + if not data then return end + local id = data.Id + local count = self.SelectedGifts[id] + grid:OnRefresh(data, count) + + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + if self:ChekMaxFavorability(self.TrustItemList[index].TrustItemType) then return end + self.CurTrustItem = self.TrustItemList[index] + end +end + +function XUiPanelLikeGiveGift:PreCheck(itemId) + local characterId = self.UiRoot:GetCurrFavorabilityCharacter() + local isMax = XDataCenter.FavorabilityManager.IsMaxFavorabilityLevel(characterId) + if isMax and itemId ~= 40801 then --海外允许角色好感度满了的情况下赠送情人节特殊礼物 + XUiManager.TipMsg(CS.XTextManager.GetText("FavorabilityMaxLevel")) + return false + end + + local curExp = tonumber(XDataCenter.FavorabilityManager.GetCurrCharacterExp(characterId)) + local startLevel = XDataCenter.FavorabilityManager.GetCurrCharacterFavorabilityLevel(characterId) + + local addExp = 0 + for i, var in ipairs(self.SelectGiftItemList) do + local favorExp = var.TrustItem.Exp + for _, v in pairs(var.TrustItem.FavorCharacterId) do + if v == characterId then + favorExp = var.TrustItem.FavorExp + break + end + end + addExp = addExp + favorExp * var.Count + end + + local totalExp = addExp + curExp + local trustLv, leftExp, levelExp = XFavorabilityConfigs.GetFavorabilityLevel(characterId, totalExp, startLevel) + + local maxLevel = XFavorabilityConfigs.GetMaxFavorabilityLevel(characterId) + if maxLevel == trustLv and itemId ~= 40801 then --海外允许角色好感度满了的情况下赠送情人节特殊礼物 + XUiManager.TipMsg(CS.XTextManager.GetText("FavorabilityMaxLevel")) + return false + end + + return true +end + + +function XUiPanelLikeGiveGift:Check() + local characterId = self.UiRoot:GetCurrFavorabilityCharacter() + + local curExp = tonumber(XDataCenter.FavorabilityManager.GetCurrCharacterExp(characterId)) + local startLevel = XDataCenter.FavorabilityManager.GetCurrCharacterFavorabilityLevel(characterId) + + local addExp = 0 + for i, var in ipairs(self.SelectGiftItemList) do + local favorExp = var.TrustItem.Exp + for _, v in pairs(var.TrustItem.FavorCharacterId) do + if v == characterId then + favorExp = var.TrustItem.FavorExp + break + end + end + addExp = addExp + favorExp * var.Count + end + + local totalExp = addExp + curExp + local trustLv, leftExp, levelExp = XFavorabilityConfigs.GetFavorabilityLevel(characterId, totalExp, startLevel) + + local maxLevel = XFavorabilityConfigs.GetMaxFavorabilityLevel(characterId) + if maxLevel == trustLv then + return false + end + + return true +end + + +function XUiPanelLikeGiveGift:OnGiftChangeCallBack(itemId, addCount) + + local selectedGifts = self.SelectedGifts[itemId] + if not selectedGifts then + selectedGifts = 0 + end + + self.SelectedGifts[itemId] = selectedGifts + addCount + self.SelectGiftItemList = {} + + for _, v in ipairs(self.TrustItemList) do + local count = self.SelectedGifts[v.Id] + if count and count > 0 then + local gift = {} + gift.TrustItem = v + gift.Count = count + table.insert(self.SelectGiftItemList, gift) + else + self.SelectedGifts[v.Id] = nil + end + + end + CsXGameEventManager.Instance:Notify(XEventId.EVENT_FAVORABILITY_ON_GIFT_CHANGED, self.SelectGiftItemList) +end + +function XUiPanelLikeGiveGift:UpdateSelectStatus(index) + for i = 1, #self.TrustItemList do + local item = self.TrustItemList[i] + if i == index then + item.IsSelect = not item.IsSelect + else + item.IsSelect = false + end + local grid = self.DynamicTableTrustItem:GetGridByIndex(i) + if grid then + grid:OnRefresh(item, i) + end + end +end + + +function XUiPanelLikeGiveGift:UpdateBottomByClickItem() + if not self.CurTrustItem then + self:HideNumBtns() + self:UpdateTextCount(0) + return + end + local playerCount = XDataCenter.ItemManager.GetCount(self.CurTrustItem.Id) + if playerCount < Default_Min_Num or (not self.CurTrustItem.IsSelect) then + self:HideNumBtns() + self:UpdateTextCount(0) + else + self:ShowNumBtns() + self:UpdateTextCount(Default_Min_Num) + end +end + +function XUiPanelLikeGiveGift:UpdateTextCount(count) + self.CurrentCount = count + self.TxtNum.text = self.CurrentCount + CsXGameEventManager.Instance:Notify(XEventId.EVENT_FAVORABILITY_ON_GIFT_CHANGED, self.CurTrustItem, self.CurrentCount) +end + + +function XUiPanelLikeGiveGift:OnBtnUseClick() + + if not self.SelectedGifts or next(self.SelectedGifts) == nil then + XUiManager.TipMsg(CS.XTextManager.GetText("FavorabilityChooseAGift")) + return + end + + + local characterId = self.UiRoot:GetCurrFavorabilityCharacter() + local characterName = XCharacterConfigs.GetCharacterName(characterId) + local trustLv = XDataCenter.FavorabilityManager.GetCurrCharacterFavorabilityLevel(characterId) + local curExp = tonumber(XDataCenter.FavorabilityManager.GetCurrCharacterExp(characterId)) + local IsDoCommunication = false + local IsGivenItem = XDataCenter.FavorabilityManager.IsInGivenItemCharacterIdList(characterId) + local args = {} + + args.CharacterId = characterId + args.CharacterName = characterName + args.GiftItems = self.SelectedGifts + local addExp = 0 + + for i, var in ipairs(self.SelectGiftItemList) do + local exp = var.TrustItem.Exp + + for _, v in pairs(var.TrustItem.FavorCharacterId) do + if v == characterId then + exp = var.TrustItem.FavorExp + break + end + end + + if var.TrustItem.TrustItemType == XFavorabilityConfigs.TrustItemType.Communication then + IsDoCommunication = true + end + + addExp = addExp + exp * var.Count + end + + + if addExp == 0 then + return + end + + + local fun = function() + XDataCenter.FavorabilityManager.OnSendCharacterGift(args, function() + self.ParentUi:DoFillAmountTween(trustLv, curExp, addExp) + self:RefreshDatas() + if IsDoCommunication and not IsGivenItem then + XDataCenter.CommunicationManager.ShowItemCommunication(args.CharacterId) + XDataCenter.FavorabilityManager.AddGivenItemCharacterId(args.CharacterId) + end + local text + if self:ChekCharacterIsMaxLevel() then + text = CS.XTextManager.GetText("GiftGiven") + else + text = CS.XTextManager.GetText("FavorabilityAddExp", tostring(args.CharacterName), addExp) + end + XUiManager.TipMsg(text) + end) + end + + + if IsDoCommunication then + if IsGivenItem then + self:TipDialog(nil, fun, "GivenGiftText") + else + if self:ChekCharacterIsMaxLevel() then + self:TipDialog(nil, fun, "ExFullGiftText") + else + if addExp > 1 then + self:TipDialog(nil, fun, "OverGiftText") + else + fun() + end + end + end + else + fun() + end +end + + + +function XUiPanelLikeGiveGift:TipDialog(cancelCb, confirmCb, TextKey) + local tipTitle = CSTextManagerGetText("TipTitle") + local content = CSTextManagerGetText(TextKey) + + CsXUiManager.Instance:Open("UiDialog", tipTitle, content, XUiManager.DialogType.Normal, cancelCb, confirmCb) +end + +function XUiPanelLikeGiveGift:OnBtnGoClick() + XLuaUiManager.Open("UiEquipStrengthenSkip", XDataCenter.FavorabilityManager.GetFavorabilitySkipIds()) +end + +function XUiPanelLikeGiveGift:IsContains(container, item) + for _, v in pairs(container or {}) do + if v == item then + return true + end + end + return false +end + +function XUiPanelLikeGiveGift:GetMaxCountByItem(trustItem) + if trustItem.TrustItemType == XFavorabilityConfigs.TrustItemType.Communication then + return CommunicationGiftMaxCount + end + + local characterId = self.UiRoot:GetCurrFavorabilityCharacter() + local isFavor = self:IsContains(trustItem.FavorCharacterId, characterId) + local favorExp = isFavor and trustItem.FavorExp or trustItem.Exp + local curExp = tonumber(XDataCenter.FavorabilityManager.GetCurrCharacterExp(characterId)) + local trustLv = XDataCenter.FavorabilityManager.GetCurrCharacterFavorabilityLevel(characterId) + local maxTrustLv = XFavorabilityConfigs.GetMaxFavorabilityLevel(characterId) + local levelUpDatas = XFavorabilityConfigs.GetTrustExpById(characterId) + + if trustLv >= maxTrustLv then return 0 end + local totalNeedExp = 0 + for i = trustLv, maxTrustLv - 1 do + if i == trustLv then + totalNeedExp = totalNeedExp + levelUpDatas[i].Exp - curExp + else + totalNeedExp = totalNeedExp + levelUpDatas[i].Exp + end + end + + local count = math.modf(totalNeedExp / favorExp) + count = (totalNeedExp % favorExp == 0) and count or count + 1 + return count +end + +function XUiPanelLikeGiveGift:OnBtnMaxClick() + if not self.CurTrustItem then + XUiManager.TipMsg(CS.XTextManager.GetText("FavorabilityChooseAGift")) + return + end + + local playerCount = XDataCenter.ItemManager.GetCount(self.CurTrustItem.Id) + local count = self:GetMaxCountByItem(self.CurTrustItem) + if self.CurrentCount >= count then + XUiManager.TipMsg(CS.XTextManager.GetText("FavorabilityMaxGiftNum")) + return + end + playerCount = (playerCount > count) and count or playerCount + + self:UpdateTextCount(playerCount) +end + +function XUiPanelLikeGiveGift:HideNumBtns() + --self.TxtNum.gameObject:SetActive(false) + self.BtnIncrease.gameObject:SetActive(false) + self.BtnDecrease.gameObject:SetActive(false) + self.BtnMax.gameObject:SetActive(false) + self.BtnUse.gameObject:SetActive(false) +end + +function XUiPanelLikeGiveGift:ShowNumBtns() + -- self.TxtNum.gameObject:SetActive(true) + self.BtnIncrease.gameObject:SetActive(true) + self.BtnDecrease.gameObject:SetActive(true) + self.BtnMax.gameObject:SetActive(true) + self.BtnUse.gameObject:SetActive(true) +end + +function XUiPanelLikeGiveGift:SetViewActive(isActive) + self.GameObject:SetActive(isActive) + if isActive then + self:RefreshDatas() + end +end + +function XUiPanelLikeGiveGift:ChekMaxFavorability(itemType) + local isMax = self:ChekCharacterIsMaxLevel() + local IsCommunicationItem = itemType == XFavorabilityConfigs.TrustItemType.Communication + if isMax and not IsCommunicationItem then + XUiManager.TipMsg(CS.XTextManager.GetText("FavorabilityMaxLevel")) + return true + end + return false +end + +function XUiPanelLikeGiveGift:ChekCharacterIsMaxLevel() + local characterId = self.UiRoot:GetCurrFavorabilityCharacter() + local isMax = XDataCenter.FavorabilityManager.IsMaxFavorabilityLevel(characterId) + return isMax +end + + +function XUiPanelLikeGiveGift:OnSelected(isSelected) + self.GameObject:SetActive(isSelected) + if isSelected then + self:RefreshDatas() + end +end + +return XUiPanelLikeGiveGift \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFestivalActivity/XUiFestivalActivityNewRoomSingle.lua b/Resources/Scripts/XUi/XUiFestivalActivity/XUiFestivalActivityNewRoomSingle.lua new file mode 100644 index 00000000..ca9128d5 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFestivalActivity/XUiFestivalActivityNewRoomSingle.lua @@ -0,0 +1,23 @@ +local XUiFestivalActivityNewRoomSingle = {} + +function XUiFestivalActivityNewRoomSingle.GetAutoCloseInfo(stageCfg) + local chapterId = XDataCenter.FubenFestivalActivityManager.GetChapterIdByStageId(stageCfg.StageId) + local chapter = XDataCenter.FubenFestivalActivityManager.GetFestivalChapterById(chapterId) + if not chapter then return false end + local endTime = chapter:GetEndTime() + if type(endTime) == "number" and endTime > 0 then + return true, endTime, function(isClose) + if isClose then + XLuaUiManager.RunMain() + XUiManager.TipError(CS.XTextManager.GetText("FestivalActivityNotInActivityTime")) + end + end + end + return false +end + +function XUiFestivalActivityNewRoomSingle.UpdateTeam(rootUi) + XDataCenter.TeamManager.SetPlayerTeam(rootUi.CurTeam, false) +end + +return XUiFestivalActivityNewRoomSingle \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFestivalActivity/XUiFestivalStageItem.lua b/Resources/Scripts/XUi/XUiFestivalActivity/XUiFestivalStageItem.lua new file mode 100644 index 00000000..ad462c40 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFestivalActivity/XUiFestivalStageItem.lua @@ -0,0 +1,82 @@ +XUiFestivalStageItem = XClass(nil, "XUiFestivalStageItem") + +function XUiFestivalStageItem:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) +end + +function XUiFestivalStageItem:SetNormalStage() + self.PanelStageNormal.gameObject:SetActiveEx(not self.IsLock) + if not self.IsLock then + self.RImgFightActiveNor:SetRawImage(self.FStage:GetIcon()) + end + self.TxtStageOrder.text = self.FStage:GetOrderName() + -- SetLockStage + self.PanelStageLock.gameObject:SetActiveEx(self.IsLock) +end + + +function XUiFestivalStageItem:SetPassStage() + self.PanelStagePass.gameObject:SetActiveEx(self.FStage:GetIsPass()) +end + +function XUiFestivalStageItem:UpdateNode(festivalId, stageId) + local fStage = XDataCenter.FubenFestivalActivityManager.GetFestivalStageByFestivalIdAndStageId(festivalId, stageId) + if not fStage then return end + self.FestivalId = festivalId + self.StageId = stageId + self.FStage = fStage + self.FChapter = fStage:GetChapter() + self.StageIndex = fStage:GetOrderIndex() + local stagePrefabName = fStage:GetStagePrefab() + local isOpen, description = self.FStage:GetCanOpen() + self.GameObject:SetActiveEx(isOpen) + local gridGameObject = self.Transform:LoadPrefab(stagePrefabName) + local uiObj = gridGameObject.transform:GetComponent("UiObject") + for i = 0, uiObj.NameList.Count - 1 do + self[uiObj.NameList[i]] = uiObj.ObjList[i] + end + self.BtnStage.CallBack = function() self:OnBtnStageClick() end + self.IsLock = not isOpen + self.Description = description + self:SetNormalStage() + self:SetPassStage() + local isEgg = self.FStage:GetIsEggStage() + self.ImgStageOrder.gameObject:SetActiveEx(not isEgg) + self.ImgStageHide.gameObject:SetActiveEx(isEgg) + if self.ImgHideLine then + self.ImgHideLine.gameObject:SetActiveEx(isEgg) + end + +end + +function XUiFestivalStageItem:OnBtnStageClick() + if self.FStage then + if not self.IsLock then + self.RootUi:UpdateNodesSelect(self.StageId) + -- 打开详细界面 + self.RootUi:OpenStageDetails(self.StageId, self.FestivalId) + self.RootUi:PlayScrollViewMove(self.Transform) + else + XUiManager.TipMsg(self.Description) + end + + end +end + +function XUiFestivalStageItem:SetNodeSelect(isSelect) + if not self.IsLock then + self.ImageSelected.gameObject:SetActiveEx(isSelect) + end +end + +function XUiFestivalStageItem:ResetItemPosition(pos) + if self.ImgHideLine then + local rect = self.ImgHideLine:GetComponent("RectTransform").rect + self.Transform.localPosition = CS.UnityEngine.Vector3(pos.x, pos.y - rect.height, pos.z) + end +end + +return XUiFestivalStageItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFestivalActivity/XUiFubenChristmasMainLineChapter.lua b/Resources/Scripts/XUi/XUiFestivalActivity/XUiFubenChristmasMainLineChapter.lua new file mode 100644 index 00000000..83a77129 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFestivalActivity/XUiFubenChristmasMainLineChapter.lua @@ -0,0 +1,451 @@ +local XUiFubenChristmasMainLineChapter = XLuaUiManager.Register(XLuaUi, "UiFubenChristmasMainLineChapter") +local FESTIVAL_FIGHT_DETAIL = "UiFubenChristmasStageDetail" +local FESTIVAL_STORY_DETAIL = "UiStoryChristmasStageDetail" +local XUguiDragProxy = CS.XUguiDragProxy + +-- 副本小游戏按钮红点条件 +local SkipBtnRedPointCondition = { + [9] = { XRedPointConditions.Types.CONDITION_FUBEN_CLICKCLEARGAME_RED }, + [11] = { XRedPointConditions.Types.CONDITION_FUBEN_DRAGPUZZLEGAME_RED }, + [12] = { XRedPointConditions.Types.CONDITION_FUBEN_DRAGPUZZLEGAME_RED }, + [13] = { XRedPointConditions.Types.CONDITION_CHRISTMAS_TREE }, +} + +function XUiFubenChristmasMainLineChapter:OnAwake() + self:InitUiView() + self.LastOpenStage = nil + self.StageGroup = {} + XEventManager.AddEventListener(XEventId.EVENT_ON_FESTIVAL_CHANGED, self.RefreshFestivalNodes, self) + XUiNewRoomSingleProxy.RegisterProxy(XDataCenter.FubenManager.StageType.Festival, + require("XUi/XUiFestivalActivity/XUiFestivalActivityNewRoomSingle")) +end + +function XUiFubenChristmasMainLineChapter:OnEnable() + -- 对之前的预制体拼写错误变量做兼容 + self.PanelStageList = self.PanelStageList or self.PaneStageList + if self.PanelStageList and self.NeedReset then + self:SetPanelStageListMovementType(CS.UnityEngine.UI.ScrollRect.MovementType.Elastic) + self:ReopenAssetPanel() + else + self.NeedReset = true + end + + if not XDataCenter.MovieManager.IsPlayingMovie() then + local festivalConfig = XFestivalActivityConfig.GetFestivalById(self.ChapterId) + if festivalConfig and festivalConfig.ChapterBgm > 0 then + -- CS.XAudioManager.PlayMusic(festivalConfig.ChapterBgm) + XSoundManager.PlaySoundDoNotInterrupt(festivalConfig.ChapterBgm) + end + end + + if self.LastOpenStage then + self:MoveIntoStage(self.LastOpenStage) + end + + if self.RedPointId then + XRedPointManager.Check(self.RedPointId) + end + + -- 线条处理 + self:HandleStageLines() + -- 关卡处理 + self:HandleStages() + -- 彩蛋处理 + self:HandleEggStage() +end + +function XUiFubenChristmasMainLineChapter:OnDestroy() + self.IsOpenDetails = nil + self:StopActivityTimer() + XEventManager.RemoveEventListener(XEventId.EVENT_ON_FESTIVAL_CHANGED, self.RefreshFestivalNodes, self) +end + +function XUiFubenChristmasMainLineChapter:InitUiView() + self.SceneBtnBack.CallBack = function() self:OnBtnBackClick() end + self.SceneBtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + self.BtnCloseDetail.CallBack = function() self:OnBtnCloseDetailClick() end +end + +function XUiFubenChristmasMainLineChapter:OnBtnBackClick() + self:Close() +end + +function XUiFubenChristmasMainLineChapter:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiFubenChristmasMainLineChapter:OnStart(chapterId, defaultStageId) + self.ChapterId = chapterId + self.Chapter = XDataCenter.FubenFestivalActivityManager.GetFestivalChapterById(chapterId) + self.ChapterTemplate = XFestivalActivityConfig.GetFestivalById(self.ChapterId) + self:SetUiData(self.ChapterTemplate) + self.NeedReset = false + + if defaultStageId then + self:OpenDefaultStage(defaultStageId) + end +end + +function XUiFubenChristmasMainLineChapter:OpenDefaultStage(stageId) + if self.FestivalStageIds and self.FestivalStages then + for i = 2, #self.FestivalStageIds do + if self.FestivalStageIds[i] == stageId and self.FestivalStages[i] then + self.FestivalStages[i]:OnBtnStageClick() + break + end + end + end +end + +function XUiFubenChristmasMainLineChapter:SetUiData(chapterTemplate) + -- 初始化prefab组件 + local chapterGameObject = self.PanelChapter:LoadPrefab(chapterTemplate.FubenPrefab) + local uiObj = chapterGameObject.transform:GetComponent("UiObject") + for i = 0, uiObj.NameList.Count - 1 do + self[uiObj.NameList[i]] = uiObj.ObjList[i] + end + -- 设置顶部控制按钮 返回 和 主界面 + if self.TopControl then + self.SceneTopControl.gameObject:SetActiveEx(false) + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + self.TopControl.gameObject:SetActiveEx(true) + else + self.SceneTopControl.gameObject:SetActiveEx(true) + end + local skipId = self.Chapter:GetSkipId() + if self.BtnSkip and skipId ~= 0 then + self.BtnSkip.CallBack = function() + XFunctionManager.SkipInterface(skipId) + end + if SkipBtnRedPointCondition[self.Chapter:GetChapterId()] then + self.RedPointId = XRedPointManager.AddRedPointEvent(self.BtnSkip, self.OnCheckBtnGameRedPoint, self, SkipBtnRedPointCondition[self.Chapter:GetChapterId()], nil, false) + end + end + if self.PaneStageList then + local dragProxy = self.PaneStageList:GetComponent(typeof(XUguiDragProxy)) + if not dragProxy then + dragProxy = self.PaneStageList.gameObject:AddComponent(typeof(XUguiDragProxy)) + end + dragProxy:RegisterHandler(handler(self, self.OnDragProxy)) + end + self.FestivalStageIds = self:GetFakeStages(chapterTemplate) + -- 线条处理 + self:HandleStageLines() + -- 关卡处理 + self:HandleStages() + -- 彩蛋处理 + self:HandleEggStage() + -- 界面信息 + self:SwitchFestivalBg(chapterTemplate) + -- 加载特效 + self:LoadEffect(chapterTemplate.EffectUrl) + local now = XTime.GetServerNowTimestamp() + local startTime, endTimeSecond = XFunctionManager.GetTimeByTimeId(self.Chapter:GetTimeId()) + if endTimeSecond then + self.TxtDay.text = XUiHelper.GetTime(endTimeSecond - now, XUiHelper.TimeFormatType.ACTIVITY) + self:CreateActivityTimer(now, endTimeSecond) + end + self.TxtChapterName.text = self.Chapter:GetName() + self.TxtChapter.text = (self.ChapterId >= 10) and self.ChapterId or string.format("0%d", self.ChapterId) + local itemId = XDataCenter.ItemManager.ItemId + if self.PanelAsset then + if not self.AssetPanel then + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, itemId.FreeGem, itemId.ActionPoint, itemId.Coin) + end + end +end + +function XUiFubenChristmasMainLineChapter:HandleStages() + self.FestivalStages = {} + for i = 1, #self.FestivalStageIds do + local itemStage = self.PanelStageContent:Find(string.format("Stage%d", i)) + if not itemStage then + XLog.Error("XUiFubenChristmasMainLineChapter:HandleStages() 函数错误: 游戏物体PanelStageContent下找不到名字为:" .. string.format("Stage%d", i) .. "的游戏物体") + return + end + -- 组件初始化 + itemStage.gameObject:SetActiveEx(true) + self.StageGroup[i] = itemStage + self.FestivalStages[i] = XUiFestivalStageItem.New(self, itemStage) + self.FestivalStages[i]:UpdateNode(self.Chapter:GetChapterId(), self.FestivalStageIds[i]) + end + self:UpdateNodeLines() + -- 隐藏多余组件 + local indexStage = #self.FestivalStageIds + 1 + local extraStage = self.PanelStageContent:Find(string.format("Stage%d", indexStage)) + while extraStage do + extraStage.gameObject:SetActiveEx(false) + indexStage = indexStage + 1 + extraStage = self.PanelStageContent:Find(string.format("Stage%d", indexStage)) + end +end + +function XUiFubenChristmasMainLineChapter:HandleStageLines() + self.FestivalStageLine = {} + for i = 1, #self.FestivalStageIds - 1 do + local itemLine = self.PanelStageContent:Find(string.format("Line%d", i)) + if not itemLine then + XLog.Error("XUiFubenChristmasMainLineChapter:SetUiData() error: prefab not found a child name:" .. string.format("Line%d", i)) + return + end + itemLine.gameObject:SetActiveEx(false) + self.FestivalStageLine[i] = itemLine + end + + -- 隐藏多余组件 + local indexLine = #self.FestivalStageLine + local extraLine = self.PanelStageContent:Find(string.format("Line%d", indexLine)) + while extraLine do + extraLine.gameObject:SetActiveEx(false) + indexLine = indexLine + 1 + extraLine = self.PanelStageContent:Find(string.format("Line%d", indexLine)) + end +end + +-- 更新刷新 +function XUiFubenChristmasMainLineChapter:RefreshFestivalNodes() + if not self.Chapter or not self.FestivalStageIds then return end + for i = 1, #self.FestivalStageIds do + self.FestivalStages[i]:UpdateNode(self.Chapter:GetChapterId(), self.FestivalStageIds[i]) + end + self:UpdateNodeLines() + self:HandleEggStage() + -- 移动至ListView正确的位置 + if self.PanelStageContentSizeFitter then + self.PanelStageContentSizeFitter:SetLayoutHorizontal() + end +end + +-- 更新节点线条 +function XUiFubenChristmasMainLineChapter:UpdateNodeLines() + if not self.Chapter or not self.FestivalStageIds then return end + local stageLength = #self.FestivalStageIds + for i = 2, stageLength do + local isOpen = self.Chapter:GetStageByStageId(self.FestivalStageIds[i]):GetIsOpen() + self:SetStageLineActive(i - 1, isOpen) + if isOpen then + self.LastOpenStage = i + end + end + self:SetStageLineActive(1, false) + self:SetStageLineActive(stageLength, false) +end + +function XUiFubenChristmasMainLineChapter:SetStageLineActive(index, isActive) + if self.FestivalStageLine[index] then + self.FestivalStageLine[index].gameObject:SetActiveEx(isActive) + end +end + +function XUiFubenChristmasMainLineChapter:HandleEggStage() + local eggStageIndex = 1 + local eggStageId = self.FestivalStageIds[eggStageIndex] + local eggStage = self.Chapter:GetStageByOrderIndex(eggStageIndex) + if eggStage and eggStage:GetIsEggStage() then + -- 彩蛋处理 + local isUnlock = eggStage:GetIsOpen() + self.FestivalStages[eggStageIndex].GameObject:SetActiveEx(isUnlock) + if isUnlock then + local preStageIds = eggStage:GetPreStageId() + if preStageIds and preStageIds[1] then + for i = 1, #self.FestivalStageIds do + if preStageIds[1] == self.FestivalStageIds[i] then + self.FestivalStages[eggStageIndex]:ResetItemPosition(self.FestivalStages[i].Transform.localPosition) + break + end + end + end + end + else + -- 非彩蛋 + self.FestivalStages[eggStageIndex].GameObject:SetActiveEx(false) + end + self.FestivalStageLine[eggStageIndex].gameObject:SetActiveEx(false) +end + +-- 选中关卡 +function XUiFubenChristmasMainLineChapter:UpdateNodesSelect(stageId) + local stageIds = self.FestivalStageIds + for i = 1, #stageIds do + if self.FestivalStages[i] then + self.FestivalStages[i]:SetNodeSelect(stageIds[i] == stageId) + end + end +end + +-- 取消选中 +function XUiFubenChristmasMainLineChapter:ClearNodesSelect() + for i = 1, #self.FestivalStageIds do + if self.FestivalStages[i] then + self.FestivalStages[i]:SetNodeSelect(false) + end + end + self.IsOpenDetails = false +end + +-- 没有彩蛋则增加一个假彩蛋 +function XUiFubenChristmasMainLineChapter:GetFakeStages() + local stageIds = {} + local stageIdList = self.Chapter:GetStageIdList() + for i = 1, #stageIdList do + stageIds[i] = stageIdList[i] + end + local firstStage = self.Chapter:GetStageByOrderIndex(1) + if not firstStage:GetIsEggStage() then + table.insert(stageIds, 1, stageIds[1]) + end + return stageIds +end + +-- 打开剧情,战斗详情 +function XUiFubenChristmasMainLineChapter:OpenStageDetails(stageId, festivalId) + local fStage = XDataCenter.FubenFestivalActivityManager.GetFestivalStageByFestivalIdAndStageId(festivalId, stageId) + if not fStage then return end + self.FStage = fStage + self.IsOpenDetails = true + self.BtnCloseDetail.gameObject:SetActiveEx(true) + local detailType = self.FStage:GetStageShowType() + if detailType == XDataCenter.FubenFestivalActivityManager.StageFuben then + self:OpenOneChildUi(FESTIVAL_FIGHT_DETAIL, self) + self:FindChildUiObj(FESTIVAL_FIGHT_DETAIL):SetStageDetail(stageId, festivalId) + if XLuaUiManager.IsUiShow(FESTIVAL_STORY_DETAIL) then + self:FindChildUiObj(FESTIVAL_STORY_DETAIL):Close() + end + end + if detailType == XDataCenter.FubenFestivalActivityManager.StageStory then + self:OpenOneChildUi(FESTIVAL_STORY_DETAIL, self) + self:FindChildUiObj(FESTIVAL_STORY_DETAIL):SetStageDetail(stageId, festivalId) + if XLuaUiManager.IsUiShow(FESTIVAL_FIGHT_DETAIL) then + self:FindChildUiObj(FESTIVAL_FIGHT_DETAIL):Close() + end + end + if self.AssetPanel then + self.AssetPanel.GameObject:SetActiveEx(false) + end + self.PanelStageContentRaycast.raycastTarget = false +end + +-- 关闭剧情,战斗详情 +function XUiFubenChristmasMainLineChapter:CloseStageDetails() + self.IsOpenDetails = false + self.BtnCloseDetail.gameObject:SetActiveEx(false) + if XLuaUiManager.IsUiShow(FESTIVAL_STORY_DETAIL) then + self:FindChildUiObj(FESTIVAL_STORY_DETAIL):CloseDetailWithAnimation() + end + + if XLuaUiManager.IsUiShow(FESTIVAL_FIGHT_DETAIL) then + self:FindChildUiObj(FESTIVAL_FIGHT_DETAIL):CloseDetailWithAnimation() + end + self.PanelStageContentRaycast.raycastTarget = true + self:ClearNodesSelect() + self:ReopenAssetPanel() + self:SetPanelStageListMovementType(CS.UnityEngine.UI.ScrollRect.MovementType.Elastic) +end + +function XUiFubenChristmasMainLineChapter:OnBtnCloseDetailClick() + self:CloseStageDetails() +end + +function XUiFubenChristmasMainLineChapter:OnDragProxy(dragType) + if self.IsOpenDetails and dragType == 0 then + self:CloseStageDetails() + end +end + +function XUiFubenChristmasMainLineChapter:PlayScrollViewMove(gridTransform) + self:SetPanelStageListMovementType(CS.UnityEngine.UI.ScrollRect.MovementType.Unrestricted) + local gridRect = gridTransform:GetComponent("RectTransform") + local diffX = gridRect.localPosition.x + self.PanelStageContent.localPosition.x + if diffX < XDataCenter.FubenMainLineManager.UiGridChapterMoveMinX or diffX > XDataCenter.FubenMainLineManager.UiGridChapterMoveMaxX then + local tarPosX = XDataCenter.FubenMainLineManager.UiGridChapterMoveTargetX - gridRect.localPosition.x + local tarPos = self.PanelStageContent.localPosition + tarPos.x = tarPosX + XLuaUiManager.SetMask(true) + XUiHelper.DoMove(self.PanelStageContent, tarPos, XDataCenter.FubenMainLineManager.UiGridChapterMoveDuration, XUiHelper.EaseType.Sin, function() + XLuaUiManager.SetMask(false) + end) + end +end + +function XUiFubenChristmasMainLineChapter:MoveIntoStage(stageIndex) + local gridRect = self.StageGroup[stageIndex] + local diffX = gridRect.localPosition.x + self.PanelStageContent.localPosition.x + if diffX > CS.XResolutionManager.OriginWidth / 2 then + local tarPosX = (CS.XResolutionManager.OriginWidth / 4) - gridRect.localPosition.x + local tarPos = self.PanelStageContent.localPosition + tarPos.x = tarPosX + XLuaUiManager.SetMask(true) + self:SetPanelStageListMovementType(CS.UnityEngine.UI.ScrollRect.MovementType.Unrestricted) + XUiHelper.DoMove(self.PanelStageContent, tarPos, XDataCenter.FubenMainLineManager.UiGridChapterMoveDuration, XUiHelper.EaseType.Sin, function() + XLuaUiManager.SetMask(false) + self:SetPanelStageListMovementType(CS.UnityEngine.UI.ScrollRect.MovementType.Elastic) + end) + end +end + +function XUiFubenChristmasMainLineChapter:EndScrollViewMove() + self:SetPanelStageListMovementType(CS.UnityEngine.UI.ScrollRect.MovementType.Elastic) + self:ReopenAssetPanel() +end + +function XUiFubenChristmasMainLineChapter:ReopenAssetPanel() + if self.IsOpenDetails then + return + end + if self.AssetPanel then + self.AssetPanel.GameObject:SetActiveEx(true) + end +end + +-- 背景 +function XUiFubenChristmasMainLineChapter:SwitchFestivalBg(festivalTemplate) + if not festivalTemplate or not festivalTemplate.MainBackgound then + self.RImgFestivalBg.gameObject:SetActiveEx(false) + return + end + self.RImgFestivalBg:SetRawImage(festivalTemplate.MainBackgound) +end + +-- 加载特效 +function XUiFubenChristmasMainLineChapter:LoadEffect(effectUrl) + if not effectUrl or effectUrl == "" then + self.PanelEffect.gameObject:SetActiveEx(false) + return + end + + self.PanelEffect.gameObject:LoadUiEffect(effectUrl) + self.PanelEffect.gameObject:SetActiveEx(true) +end + +-- 计时器 +function XUiFubenChristmasMainLineChapter:CreateActivityTimer(startTime, endTime) + local time = XTime.GetServerNowTimestamp() + self:StopActivityTimer() + self.ActivityTimer = XScheduleManager.ScheduleForever(function() + time = XTime.GetServerNowTimestamp() + if time > endTime then + self:Close() + XUiManager.TipError(CS.XTextManager.GetText("ActivityMainLineEnd")) + self:StopActivityTimer() + return + end + self.TxtDay.text = XUiHelper.GetTime(endTime - time, XUiHelper.TimeFormatType.ACTIVITY) + end, XScheduleManager.SECOND, 0) +end + +function XUiFubenChristmasMainLineChapter:StopActivityTimer() + if self.ActivityTimer then + XScheduleManager.UnSchedule(self.ActivityTimer) + self.ActivityTimer = nil + end +end + +function XUiFubenChristmasMainLineChapter:SetPanelStageListMovementType(moveMentType) + if not self.PanelStageList then return end + self.PanelStageList.movementType = moveMentType +end + +function XUiFubenChristmasMainLineChapter:OnCheckBtnGameRedPoint(count) + self.BtnSkip:ShowReddot(count>=0) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFestivalActivity/XUiFubenChristmasStageDetail.lua b/Resources/Scripts/XUi/XUiFestivalActivity/XUiFubenChristmasStageDetail.lua new file mode 100644 index 00000000..929283ca --- /dev/null +++ b/Resources/Scripts/XUi/XUiFestivalActivity/XUiFubenChristmasStageDetail.lua @@ -0,0 +1,139 @@ +local XUiFubenChristmasStageDetail = XLuaUiManager.Register(XLuaUi, "UiFubenChristmasStageDetail") + +function XUiFubenChristmasStageDetail:OnAwake() + self.StarGridList = {} + self.CommonGridList = {} + self.GridList = {} + + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint) + self:InitStarPanels() + self.BtnEnter.CallBack = function() self:OnBtnEnterClick() end +end + +function XUiFubenChristmasStageDetail:InitStarPanels() + for i = 1, 3 do + self.StarGridList[i] = XUiGridStageStar.New(self[string.format("GridStageStar%d", i)]) + end +end + +function XUiFubenChristmasStageDetail:OnStart(rootUi) + self.RootUi = rootUi +end + +function XUiFubenChristmasStageDetail:SetStageDetail(stageId, festivalId) + local fStage = XDataCenter.FubenFestivalActivityManager.GetFestivalStageByFestivalIdAndStageId(festivalId, stageId) + if not fStage then return end + self.FStage = fStage + local maxChallengeNum = fStage:GetMaxChallengeNum() + local isLimitCount = maxChallengeNum > 0 + self.PanelNums.gameObject:SetActiveEx(isLimitCount) + self.PanelNoLimitCount.gameObject:SetActiveEx(not isLimitCount) + -- 有次数限制 + if isLimitCount then + self.TxtAllNums.text = string.format("/%d", maxChallengeNum) + self.TxtLeftNums.text = maxChallengeNum - fStage:GetPassCount() + end + self.TxtTitle.text = fStage:GetName() + for i = 1, 3 do + self.StarGridList[i]:Refresh(fStage:GetStarDescByIndex(i), fStage:GetStarMapsByIndex(i)) + end + self.ImgCostIcon:SetRawImage(XDataCenter.ItemManager.GetItemIcon(XDataCenter.ItemManager.ItemId.ActionPoint)) + self.TxtATNums.text = fStage:GetRequireActionPoint() + self:UpdateRewards() +end + +function XUiFubenChristmasStageDetail:UpdateRewardTitle(isFirstDrop) + self.TxtDrop.gameObject:SetActive(not isFirstDrop) + self.TxtFirstDrop.gameObject:SetActive(isFirstDrop) +end + +function XUiFubenChristmasStageDetail:UpdateRewards() + if not self.FStage then return end + local rewardId = self.FStage:GetFinishRewardShow() + local IsFirst = false + -- 首通有没有填 + local controlCfg = XDataCenter.FubenManager.GetStageLevelControl(self.FStage:GetStageId()) + -- 有首通 + if not self.FStage:GetIsPass() then + if controlCfg and controlCfg.FirstRewardShow > 0 then + rewardId = controlCfg.FirstRewardShow + IsFirst = true + elseif self.FStage:GetFirstRewardShow() > 0 then + rewardId = self.FStage:GetFirstRewardShow() + IsFirst = true + end + end + -- 没首通 + if not IsFirst then + if controlCfg and controlCfg.FinishRewardShow > 0 then + rewardId = controlCfg.FinishRewardShow + else + rewardId = self.FStage:GetFinishRewardShow() + end + end + self:UpdateRewardTitle(IsFirst) + + local rewards = {} + if rewardId > 0 then + rewards = IsFirst and XRewardManager.GetRewardList(rewardId) or XRewardManager.GetRewardListNotCount(rewardId) + end + + if rewards then + for i, item in ipairs(rewards) do + local grid + if self.GridList[i] then + grid = self.GridList[i] + else + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommon) + grid = XUiGridCommon.New(self, ui) + grid.Transform:SetParent(self.PanelDropContent, false) + self.GridList[i] = grid + end + grid:Refresh(item) + grid.GameObject:SetActive(true) + end + end + + local rewardsCount = 0 + if rewards then + rewardsCount = #rewards + end + + for j = 1, #self.GridList do + if j > rewardsCount then + self.GridList[j].GameObject:SetActive(false) + end + end +end + +function XUiFubenChristmasStageDetail:OnBtnEnterClick() + if not self.FStage then + XLog.Error("XUiFubenChristmasStageDetail:OnBtnEnterClick 函数错误: 关卡信息为空 ") + return + end + local isInTime, tips = self.FStage:GetChapter():GetIsInTimeAndTips() + if not isInTime then + XUiManager.TipMsg(tips) + return + end + local passedCounts = self.FStage:GetPassCount() + local maxChallengeNum = self.FStage:GetMaxChallengeNum() + if maxChallengeNum > 0 and passedCounts >= maxChallengeNum then + XUiManager.TipMsg(CS.XTextManager.GetText("FubenChallengeCountNotEnough")) + return + end + if XDataCenter.FubenManager.CheckPreFight(self.FStage:GetStageCfg()) then + if self.RootUi then + self.RootUi:ClearNodesSelect() + end + XLuaUiManager.Open("UiNewRoomSingle", self.FStage:GetStageId()) + self.RootUi.BtnCloseDetail.gameObject:SetActiveEx(false) + self:Close() + end +end + +function XUiFubenChristmasStageDetail:CloseDetailWithAnimation() + self:PlayAnimation("AnimDisableEnd", function() + self:Close() + end) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFestivalActivity/XUiStoryChristmasStageDetail.lua b/Resources/Scripts/XUi/XUiFestivalActivity/XUiStoryChristmasStageDetail.lua new file mode 100644 index 00000000..126927f0 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFestivalActivity/XUiStoryChristmasStageDetail.lua @@ -0,0 +1,57 @@ +local XUiStoryChristmasStageDetail = XLuaUiManager.Register(XLuaUi, "UiStoryChristmasStageDetail") + +function XUiStoryChristmasStageDetail:OnAwake() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint) + self.BtnEnter.CallBack = function() self:OnBtnEnterClick() end +end + +function XUiStoryChristmasStageDetail:OnStart(rootUi) + self.RootUi = rootUi +end + +function XUiStoryChristmasStageDetail:SetStageDetail(stageId, festivalId) + self.StageId = stageId + self.FestivalId = festivalId + local chapterTemplate = XFestivalActivityConfig.GetFestivalById(festivalId) + local stageCfg = XDataCenter.FubenManager.GetStageCfg(self.StageId) + + self.TxtTitle.text = stageCfg.Name + self.TxtStoryDes.text = stageCfg.Description + self.RImgNandu:SetRawImage(chapterTemplate.TitleIcon) + self.RImgTitleBg:SetRawImage(chapterTemplate.TitleBg) +end + +function XUiStoryChristmasStageDetail:OnBtnEnterClick() + if not self.StageId then return end + + local stageCfg = XDataCenter.FubenManager.GetStageCfg(self.StageId) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(self.StageId) + if not stageCfg or not stageInfo then return end + + if stageInfo.Passed then + self:PlayStoryId(stageCfg.BeginStoryId, self.StageId) + else + XDataCenter.FubenFestivalActivityManager.FinishStoryRequest(self.StageId, function() + XDataCenter.FubenFestivalActivityManager.RefreshStagePassedBySettleDatas({ StageId = self.StageId }) + self:PlayStoryId(stageCfg.BeginStoryId, self.StageId) + end) + end +end + +function XUiStoryChristmasStageDetail:PlayStoryId(movieId) + self.RootUi:ClearNodesSelect() + XDataCenter.MovieManager.PlayMovie(movieId, function() + self.RootUi:EndScrollViewMove() + end) + self.RootUi.BtnCloseDetail.gameObject:SetActiveEx(false) + self:Close() +end + +function XUiStoryChristmasStageDetail:CloseDetailWithAnimation() + self:PlayAnimation("AnimDisableEnd", function() + self:Close() + end) +end + +function XUiStoryChristmasStageDetail:OnDestroy() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFightButtonSettings/XUiFightButtonSettings.lua b/Resources/Scripts/XUi/XUiFightButtonSettings/XUiFightButtonSettings.lua new file mode 100644 index 00000000..c7a123d9 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFightButtonSettings/XUiFightButtonSettings.lua @@ -0,0 +1,101 @@ +local XUiFightButtonSettings = XLuaUiManager.Register(XLuaUi, "UiFightButtonSettings") + +function XUiFightButtonSettings:OnAwake() + self.CurSelect = 0 + XTool.InitUiObject(self) + self:InitUI() +end + +function XUiFightButtonSettings:OnStart(closeCb) + self.CloseCb = closeCb + local t + if XUiFightButtonDefaultStyleConfig.IsHaveCurSchemeStyle() then + t = XUiFightButtonDefaultStyleConfig.GetCurSchemeStyle() + else + t = XDataCenter.SetManager.GetCurSeleButton() + end + + if t == 0 then + self:OnButtonProject1() + else + self:OnButtonProject2() + end +end + +function XUiFightButtonSettings:InitUI() + self:AddListener() +end + +function XUiFightButtonSettings:InitFunction() +end + +function XUiFightButtonSettings:AddListener() + -- self.BtnCustomize.CallBack = function() self:OpenCustomFight() end + self.BtnProject1.CallBack = function() self:OnButtonProject1() end + self.BtnProject2.CallBack = function() self:OnButtonProject2() end + self.BtnGouxuan1.CallBack = function(value) self:OnBtnGouxuan1(value) end + self.BtnGouxuan2.CallBack = function(value) self:OnBtnGouxuan2(value) end + self.BtnClose.CallBack = function() self:OnBtnClose() end + self.BtnTongBlue.CallBack = function() self:OnBtnClose() end +end + +-- function XUiFightButtonSettings:OpenCustomFight() +-- XLuaUiManager.Open("UiFightCustom",true) +-- end +function XUiFightButtonSettings:OnBtnClose() + XUiFightButtonDefaultStyleConfig.SaveDefaultStyleById(self.CurSelect) + XDataCenter.SetManager.SetCurSeleButton(self.CurSelect) + local uiFightInstance = CS.XFight.Instance + if uiFightInstance then + local uiFightNpcPortrait = uiFightInstance.UiFightManager.UiFightNpcPortrait + if uiFightNpcPortrait then + uiFightNpcPortrait:OnApplyCustomUi() + end + local uiFightOnlineMsg = uiFightInstance.UiFightManager.UiFightOnlineMsg + if uiFightOnlineMsg then + uiFightOnlineMsg:OnApplyCustomUi() + end + end + self:Close() + if self.CloseCb then + self.CloseCb() + end +end + +function XUiFightButtonSettings:OnBtnGouxuan1(value) + self.CurSelect = 0 + self.BtnProject1:SetButtonState(XUiButtonState.Select) + self.BtnProject2:SetButtonState(XUiButtonState.Normal) + self.BtnGouxuan2:SetButtonState(XUiButtonState.Normal) + if value == 0 then + self:OnBtnGouxuan2() + self.BtnGouxuan2:SetButtonState(XUiButtonState.Select) + end +end + +function XUiFightButtonSettings:OnBtnGouxuan2(value) + self.CurSelect = 1 + self.BtnProject1:SetButtonState(XUiButtonState.Normal) + self.BtnProject2:SetButtonState(XUiButtonState.Select) + self.BtnGouxuan1:SetButtonState(XUiButtonState.Normal) + if value == 0 then + self:OnBtnGouxuan1() + self.BtnGouxuan1:SetButtonState(XUiButtonState.Select) + end +end + +function XUiFightButtonSettings:OnButtonProject1() + self.CurSelect = 0 + self.BtnProject1:SetButtonState(XUiButtonState.Select) + self.BtnProject2:SetButtonState(XUiButtonState.Normal) + self.BtnGouxuan1:SetButtonState(XUiButtonState.Select) + self.BtnGouxuan2:SetButtonState(XUiButtonState.Normal) +end + +function XUiFightButtonSettings:OnButtonProject2() + self.CurSelect = 1 + self.BtnProject1:SetButtonState(XUiButtonState.Normal) + self.BtnProject2:SetButtonState(XUiButtonState.Select) + self.BtnGouxuan1:SetButtonState(XUiButtonState.Normal) + self.BtnGouxuan2:SetButtonState(XUiButtonState.Select) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFightInfestorExplore/XUiFightInfestorExplore.lua b/Resources/Scripts/XUi/XUiFightInfestorExplore/XUiFightInfestorExplore.lua new file mode 100644 index 00000000..e8456bd8 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFightInfestorExplore/XUiFightInfestorExplore.lua @@ -0,0 +1,240 @@ +local XUiFightInfestorExplore = XLuaUiManager.Register(XLuaUi, "UiFightInfestorExplore") +local XUiGridFightInfestorRuler = require("XUi/XUiFightInfestorExplore/XUiGridFightInfestorRuler") +local XUiGridFightInfestorPlayer = require("XUi/XUiFightInfestorExplore/XUiGridFightInfestorPlayer") + +local DYNAMIC_DELEGATE_EVENT = DYNAMIC_DELEGATE_EVENT +local table = table +local math = math +local Vector3 = CS.UnityEngine.Vector3 + + +function XUiFightInfestorExplore:OnAwake() + self:InitComponent() +end + +function XUiFightInfestorExplore:InitComponent() + self.BrokePlayerIndexList = {} + self.PlayerItemList = {} + self.RemoveItemList = {} + self.PlayerItem.gameObject:SetActiveEx(false) + + self.ScrollViewHeight = self.ScrollViewList.rect.height + self.RulerHeight = self.Ruler.sizeDelta.y + + self.DynamicTable = XDynamicTableNormal.New(self.ScrollViewList.gameObject) + self.DynamicTable:SetProxy(XUiGridFightInfestorRuler) + self.DynamicTable:SetDelegate(self) + local playerLayerPos = self.PlayerLayer.transform.localPosition + self.PlayerLayer.transform.localPosition = Vector3(playerLayerPos.x, 0, playerLayerPos.z) + + self.PanelEffect.gameObject:SetActive(false) + self.PanelEffectLoader:SetLoadedCallback(function() self:OnEffectLoaded() end) +end + +function XUiFightInfestorExplore:OnEnable() + self:RefreshView() +end + +function XUiFightInfestorExplore:OnDisable() + self:RemoveTimer() +end + +function XUiFightInfestorExplore:OnDestroy() + self:RemoveTimer() +end + +function XUiFightInfestorExplore:OnGetEvents() + return { XEventId.EVENT_FIGHT_INFESTOR_SCORE_CHANGE} +end + +function XUiFightInfestorExplore:OnNotify(evt) + if evt == XEventId.EVENT_FIGHT_INFESTOR_SCORE_CHANGE then + self:UpdateScrollViewOffset() + end +end + +function XUiFightInfestorExplore:AddTimer() + self:RemoveTimer() + self.scheduleId = XScheduleManager.ScheduleForever(function() + self:CheckRemoveItemList() + local lastScore = self.Score + self.Score = XDataCenter.FightInfestorExploreManager.CalcScore(self.Score) + if lastScore ~= self.Score then + XDataCenter.FightInfestorExploreManager.SetScore(self.Score) + self:UpdateScrollViewOffset(self.Score) + self:RefreshScoreText() + end + end, XDataCenter.FightInfestorExploreManager.COLLECT_SCORE_TIME) +end + +function XUiFightInfestorExplore:RemoveTimer() + if self.scheduleId then + XScheduleManager.UnSchedule(self.scheduleId) + self.scheduleId = nil + end +end + +--动态列表事件 +function XUiFightInfestorExplore:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT or event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local topNum = self.ListDataRuler[index] + grid:Refresh(topNum) + + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_RELOAD_COMPLETED then + self:OnListLoaded() + end +end + +function XUiFightInfestorExplore:RefreshView() + self.Score = XDataCenter.FightInfestorExploreManager.GetScore() + self.ScoreFloor = XDataCenter.FightInfestorExploreManager.GetScoreFloor(self.Score) + self.ScoreGap = XDataCenter.FightInfestorExploreManager.GetScoreGap() + + self:RefreshScoreText() + self.ListDataPlayer = XDataCenter.FightInfestorExploreManager.GetPlayerList() + self.ListDataRuler = XDataCenter.FightInfestorExploreManager.GetRulerList(self.ListDataPlayer) + self.TotalRulerHeight = self.RulerHeight * #self.ListDataRuler + + self.DynamicTable:SetDataSource(self.ListDataRuler) + self.DynamicTable:ReloadDataASync() + + self:AddTimer() +end + +function XUiFightInfestorExplore:OnListLoaded() + self.DynamicTable:Freeze() + self.PlayerLayerSize = self.PanelContent.sizeDelta + self.PlayerLayer.sizeDelta = self.PlayerLayerSize + self:RefreshPlayerList() + + self:UpdateScrollViewOffset(self.Score) +end + +function XUiFightInfestorExplore:RefreshScoreText() + self.TextSelfNum.text = XDataCenter.FightInfestorExploreManager.GetScoreStr(self.Score) +end + +-- 设置列表偏移 +function XUiFightInfestorExplore:UpdateScrollViewOffset(score) + self.PosRate = (score - self.ScoreFloor) / self.ScoreGap + local offsetY = self.PosRate * self.RulerHeight + local normalizedPosition = offsetY / self.TotalRulerHeight + if normalizedPosition > 1 or normalizedPosition < 0 then + XLog.Error("列表位置超出范围 normalizedPosition:" .. tostring(normalizedPosition)) + end + -- XLog.Debug(" normalizedPosition " .. tostring(normalizedPosition) .. ", olde =" .. tostring(self.ScrollRect.verticalNormalizedPosition)) + self.ScrollRect.verticalNormalizedPosition = math.max(0, math.min(1, normalizedPosition)) + + self:CheckPlayerBroken() +end + + +-- 设置列表偏移 +function XUiFightInfestorExplore:GetPosYByScore(score) + local offsetY = (score - self.ScoreFloor) / self.ScoreGap * self.RulerHeight + local originY = self.TotalRulerHeight - self.ScrollViewHeight + if originY < 0 then + originY = 0 + XLog.Error("刻度数量过少,不足一页: " .. tostring(#self.ListDataRuler) .. "/" .. tostring(math.ceil(self.ScrollViewHeight / self.RulerHeight))) + end + local posY = originY - offsetY + return posY +end + +function XUiFightInfestorExplore:GetPlayerItem(index) + local item = self.PlayerItemList[index] + if not item then + local go = CS.UnityEngine.Object.Instantiate(self.PlayerItem) + go.transform:SetParent(self.PlayerLayer, false) + item = XUiGridFightInfestorPlayer.New(self, go) + self.PlayerItemList[index] = item + end + return item +end + +function XUiFightInfestorExplore:ResetPlayerItemAll(len) + if #self.PlayerItemList > len then + for i = len + 1, #self.PlayerItemList do + self.PlayerItemList[i].gameObject:SetActiveEx(false) + end + end +end + +-- 创建玩家头像 +function XUiFightInfestorExplore:RefreshPlayerList() + local list = self.ListDataPlayer + self:ResetPlayerItemAll(#list) + for i, data in ipairs(list) do + local item = self:GetPlayerItem(i) + local posY = data:GetPosRate() * self.RulerHeight - self.PlayerLayerSize.y + item.Transform.localPosition = Vector3(item.Transform.localPosition.x, posY) + item.GameObject:SetActiveEx(true) + item:Refresh(data) + end + return (#list > 0) +end + +function XUiFightInfestorExplore:CheckPlayerBroken() + local list = self.ListDataPlayer + local posY + for index = #list, 1, -1 do + local data = list[index] + if data:GetScore() <= self.Score then + table.remove(list, index) + local item = self.PlayerItemList[index] + if item then + if not posY then + posY = self:GetPosYByScore(self.Score) + end + item.Transform.localPosition = Vector3(item.Transform.localPosition.x, -self.RulerHeight) + table.insert(self.BrokePlayerIndexList, index) + else + XLog.Error("消失的同组玩家不存在 i:" .. tostring(index)) + end + end + end + self:DoPlayerBroken() +end + +function XUiFightInfestorExplore:DoPlayerBroken() + if #self.BrokePlayerIndexList == 0 then + return + end + self.PanelEffect.gameObject:SetActive(false) + self.PanelEffect.gameObject:SetActive(true) + + local index = self.BrokePlayerIndexList[1] + local item = self.PlayerItemList[index] + local rawImage = item:GetRawImage() + if self:PlayEffect(rawImage) then + table.remove(self.PlayerItemList, index) + table.remove(self.BrokePlayerIndexList, 1) + table.insert(self.RemoveItemList, item) + end +end + +function XUiFightInfestorExplore:OnEffectLoaded() + local go = self.PanelEffect.gameObject:FindGameObject("01") + self.EffectRenderer = go:GetComponent("Renderer") + self:DoPlayerBroken() +end + +function XUiFightInfestorExplore:PlayEffect(rawImage) + if XTool.UObjIsNil(rawImage) or XTool.UObjIsNil(rawImage.texture) then + return true + end + if not self.EffectRenderer then + return false + end + self.EffectRenderer.sharedMaterial:SetTexture("_MainTex", rawImage.texture) + return true +end + +function XUiFightInfestorExplore:CheckRemoveItemList() + if #self.RemoveItemList > 0 then + local item = table.remove(self.RemoveItemList, 1) + if item and not XTool.UObjIsNil(item.GameObject) then + CS.UnityEngine.Object.Destroy(item.GameObject) + end + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFightInfestorExplore/XUiGridFightInfestorPlayer.lua b/Resources/Scripts/XUi/XUiFightInfestorExplore/XUiGridFightInfestorPlayer.lua new file mode 100644 index 00000000..1f0dee3a --- /dev/null +++ b/Resources/Scripts/XUi/XUiFightInfestorExplore/XUiGridFightInfestorPlayer.lua @@ -0,0 +1,24 @@ +local XUiGridFightInfestorPlayer = XClass(nil, "XUiGridFightInfestorPlayer") + +function XUiGridFightInfestorPlayer:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + self:InitComponent() +end + +function XUiGridFightInfestorPlayer:InitComponent() +end + +function XUiGridFightInfestorPlayer:Refresh(data) + self.ImgIcon:SetRawImage(data:GetIcon()) + self.Name.text = data:GetName() + self.Num.text = data:GetScoreStr() +end + +function XUiGridFightInfestorPlayer:GetRawImage() + return self.ImgIcon +end + +return XUiGridFightInfestorPlayer \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFightInfestorExplore/XUiGridFightInfestorRuler.lua b/Resources/Scripts/XUi/XUiFightInfestorExplore/XUiGridFightInfestorRuler.lua new file mode 100644 index 00000000..4555f00b --- /dev/null +++ b/Resources/Scripts/XUi/XUiFightInfestorExplore/XUiGridFightInfestorRuler.lua @@ -0,0 +1,17 @@ +local XUiGridFightInfestorRuler = XClass(nil, "XUiGridFightInfestorRuler") + +function XUiGridFightInfestorRuler:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:InitComponent() +end + +function XUiGridFightInfestorRuler:InitComponent() +end + +function XUiGridFightInfestorRuler:Refresh(data) + self.TextNum.text = data +end + +return XUiGridFightInfestorRuler diff --git a/Resources/Scripts/XUi/XUiFightWords/XUiFightWords.lua b/Resources/Scripts/XUi/XUiFightWords/XUiFightWords.lua new file mode 100644 index 00000000..7e602879 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFightWords/XUiFightWords.lua @@ -0,0 +1,47 @@ +local XUiFightWords = XLuaUiManager.Register(XLuaUi, "UiFightWords") + +function XUiFightWords:OnAwake(id) + self.WordsId = id + self.PlayNextWordCb = function(content) self:PlayNextWord(content) end + self:AddListeners() +end + +function XUiFightWords:OnEnable() + self:ResetState() + self:RunWords() +end + +function XUiFightWords:OnDisable() +end + +function XUiFightWords:OnDestroy() + -- self.TxtWordsTypeWriter:Stop() + self:RemoveListeners() +end + +function XUiFightWords:AddListeners() + XEventManager.AddEventListener(XEventId.EVENT_FIGHT_WORDS_NEXT, self.PlayNextWordCb) +end + +function XUiFightWords:RemoveListeners() + XEventManager.RemoveEventListener(XEventId.EVENT_FIGHT_WORDS_NEXT, self.PlayNextWordCb) +end + +function XUiFightWords:ResetState() + self.TxtWords.text = "" + -- self.TxtWordsTypeWriter:Stop() +end + +function XUiFightWords:RunWords() + if not self.WordsId then + return + end + XDataCenter.FightWordsManager.Run(self.WordsId) +end + +function XUiFightWords:PlayNextWord(content) + if content == nil or content == '' then + return + end + self.TxtWords.text = string.gsub(content,"\\n","\n") +end diff --git a/Resources/Scripts/XUi/XUiFirstGetPopUp/XUiFirstGetPopUp.lua b/Resources/Scripts/XUi/XUiFirstGetPopUp/XUiFirstGetPopUp.lua new file mode 100644 index 00000000..41090c32 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFirstGetPopUp/XUiFirstGetPopUp.lua @@ -0,0 +1,75 @@ + +local tableRemove = table.remove + +local AnimBegin = "AniFirstGetBegin" + +local XUiFirstGetPopUp = XLuaUiManager.Register(XLuaUi, "UiFirstGetPopUp") + +function XUiFirstGetPopUp:OnAwake() + self:InitAutoScript() +end + +function XUiFirstGetPopUp:OnStart(waitToShowList) + self.WaitToShowList = waitToShowList + self.GridCommon.gameObject:SetActive(false) + self.PanelCharacter.gameObject:SetActive(false) +end + +function XUiFirstGetPopUp:OnEnable() + local data = tableRemove(self.WaitToShowList) + if not data then + self:Close() + return + end + + self:Refresh(data) + + -- local onEnd = function () + -- self:OnEnable() + -- end + +end + +function XUiFirstGetPopUp:Refresh(data) + self.TempateId = data.Id + self.Type = data.Type + + if self.Type == XArrangeConfigs.Types.Character then + local character = XDataCenter.CharacterManager.GetCharacter(self.TempateId) + self.TxtName.text = XCharacterConfigs.GetCharacterFullNameStr(self.TempateId) + self.RImgCharacterQualityIcon:SetRawImage(XCharacterConfigs.GetCharQualityIcon(character.Quality)) + self.RImgCharacter:SetRawImage(XDataCenter.CharacterManager.GetCharHalfBodyBigImage(self.TempateId)) + self.PanelCharacter.gameObject:SetActive(true) + elseif self.Type == XArrangeConfigs.Types.Weapon then + self.CommonGrid = self.CommonGrid or XUiGridCommon.New(self, self.GridCommon) + self.CommonGrid:Refresh(self.TempateId) + self.TxtName.text = XDataCenter.EquipManager.GetEquipName(self.TempateId) + self.GridCommon.gameObject:SetActive(true) + end +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiFirstGetPopUp:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiFirstGetPopUp:AutoInitUi() + self.BtnClose = self.Transform:Find("SafeAreaContentPane/BtnClose"):GetComponent("Button") + self.PanelFirstGet = self.Transform:Find("SafeAreaContentPane/PanelFirstGet") + self.PanelCharacter = self.Transform:Find("SafeAreaContentPane/PanelFirstGet/PaneContent/PanelCharacter") + self.RImgCharacterQualityIcon = self.Transform:Find("SafeAreaContentPane/PanelFirstGet/PaneContent/PanelCharacter/RImgCharacterQualityIcon"):GetComponent("RawImage") + self.RImgCharacter = self.Transform:Find("SafeAreaContentPane/PanelFirstGet/PaneContent/PanelCharacter/RImgCharacter"):GetComponent("RawImage") + self.GridCommon = self.Transform:Find("SafeAreaContentPane/PanelFirstGet/PaneContent/GridCommon") + self.TxtName = self.Transform:Find("SafeAreaContentPane/PanelFirstGet/TxtName"):GetComponent("Text") +end + +function XUiFirstGetPopUp:AutoAddListener() + self:RegisterClickEvent(self.BtnClose, self.OnBtnCloseClick) +end +-- auto +function XUiFirstGetPopUp:OnBtnCloseClick() + XUiHelper.StopAnimation(self, AnimBegin) + +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFuben/XUiFuben.lua b/Resources/Scripts/XUi/XUiFuben/XUiFuben.lua new file mode 100644 index 00000000..7d769916 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFuben/XUiFuben.lua @@ -0,0 +1,261 @@ +local XUiFuben = XLuaUiManager.Register(XLuaUi, "UiFuben") +XUiFuben.BtnTabIndex = { + Activity = 1, + Challenge = 2, + Daily = 3, + MainLine = 4, +} + +function XUiFuben:OnAwake() + self:InitAutoScript() + XDataCenter.FubenManager.InitNewChallengeRedPointTable() + self:InitTabBtnGroup() +end + +function XUiFuben:OnStart(type, stageId, subType) + self.CurType = type + self.CurSubType = subType + self.CurStageId = stageId + self.MainLineChapterInst = nil + self.ActivityCapterInst = nil + self.ChallengeChapterInst = nil + self.BtnTrial.gameObject:SetActiveEx(false) + self.CurDiff = XDataCenter.FubenManager.DifficultNormal + self.FirstIn = true + self:OnOpenInit() +end + +function XUiFuben:OnEnable() + XRedPointManager.Check(self.RedPointId) + XRedPointManager.Check(self.RedPointChallengeId) + XRedPointManager.Check(self.RedPointActivityId) + XRedPointManager.Check(self.RedPointExperimentId) + if self.FirstIn then + self.FirstIn = false + self:PlayAnimation("AnimStartEnable") + else + self:PlayAnimation("ExcessiveEnable") + end +end + +function XUiFuben:InitTabBtnGroup() + self.BtnTabActivity:SetDisable(not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.FubenActivity)) + self.BtnTabChallenge:SetDisable(not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.FubenChallenge)) + self.BtnTabDaily:SetDisable(not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.FubenDaily)) + + self.BtnTabChallenge.gameObject:SetActiveEx(not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.FubenChallenge)) + self.BtnTabDaily.gameObject:SetActiveEx(not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.FubenDaily)) + + local tabGroup = { + self.BtnTabActivity, + self.BtnTabChallenge, + self.BtnTabDaily, + self.BtnTabMainLine, + } + self.PanelBottomRight:Init(tabGroup, function(tabIndex) self:OnClickTabCallBack(tabIndex) end) + + if XUiManager.IsHideFunc then + self:HideFunc() + end + + self.RedPointId = XRedPointManager.AddRedPointEvent(self.BtnTabMainLine, self.RefreshBtnTabMainLineRedDot, self, { XRedPointConditions.Types.CONDITION_MAIN_CHAPTER }) + self.RedPointChallengeId = XRedPointManager.AddRedPointEvent(self.BtnTabChallenge, self.RefreshBtnTabChallengeRedDot, self, { + XRedPointConditions.Types.CONDITION_EXPLORE_REWARD, + XRedPointConditions.Types.CONDITION_TRIAL_RED, + XRedPointConditions.Types.CONDITION_ASSIGN_REWARD, + XRedPointConditions.Types.CONDITION_CHALLEGE_NEW, + XRedPointConditions.Types.CONDITION_EXPERIMENT_RED, + XRedPointConditions.Types.XRedPointConditionStrongholdRewardCanGet, + }) + self.RedPointActivityId = XRedPointManager.AddRedPointEvent(self.BtnTabActivity, self.RefreshBtnTabActivityRedDot, self, { + XRedPointConditions.Types.CONDITION_EXPEDITION_CAN_RECRUIT, + XRedPointConditions.Types.CONDITION_WORLDBOSS_RED, + XRedPointConditions.Types.CONDITION_SPECIALTRAIN_RED, + XRedPointConditions.Types.CONDITION_CHESSPURSUIT_REWARD_RED, + XRedPointConditions.Types.CONDITION_NIER_RED, + XRedPointConditions.Types.CONDITION_SIMULATED_COMBAT, + XRedPointConditions.Types.CONDITION_KOROMCHARACTIVITYMAINRED, + XRedPointConditions.Types.CONDITION_REFORM_All_RED_POINT, + XRedPointConditions.Types.CONDITION_POKER_GUESSING_RED, + XRedPointConditions.Types.XRedPointConditionKillZoneActivity, + }) + self.RedPointExperimentId = XRedPointManager.AddRedPointEvent(self.ExperimentRedPoint, self.OnCheckExperimentRedPoint, self, { XRedPointConditions.Types.CONDITION_EXPERIMENT_RED }) +end + +--- +--- 隐藏活动、挑战、资源按钮 +function XUiFuben:HideFunc() + self.BtnTabActivity.gameObject:SetActiveEx(false) + self.BtnTabChallenge.gameObject:SetActiveEx(false) + self.BtnTabDaily.gameObject:SetActiveEx(false) +end + +function XUiFuben:OnClickTabCallBack(tabIndex) + if self.SelectedIndex and self.SelectedIndex == tabIndex then + return + end + + if tabIndex == self.BtnTabIndex.Activity then + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.FubenActivity) then + return + end + self.BtnTrial.gameObject:SetActiveEx(false) + XDataCenter.FubenBossOnlineManager.RefreshBossData(function() + self:OpenOneChildUi("UiFubenActivityBanner", true) + end) + elseif tabIndex == self.BtnTabIndex.Challenge then + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.FubenChallenge) then + return + end + self.BtnTrial.gameObject:SetActiveEx(not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.FubenActivityTrial)) + XDataCenter.FubenManager.RefreshNewChallengeRedPoint() --刷新挑战页签红点 + self:OpenOneChildUi("UiFubenChallengeBanner", true) + elseif tabIndex == self.BtnTabIndex.Daily then + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.FubenDaily) then + return + end + self.BtnTrial.gameObject:SetActiveEx(false) + self:OpenOneChildUi("UiFubenDailyBanner", true) + elseif tabIndex == self.BtnTabIndex.MainLine then + self.BtnTrial.gameObject:SetActiveEx(false) + self:OpenOneChildUi("UiFubenMainLineBanner", true, self.CurSubType) + self.CurSubType = nil + end + + self.SelectedIndex = tabIndex +end + +function XUiFuben:RefreshBtnTabMainLineRedDot(count) + self.BtnTabMainLine:ShowReddot(count >= 0) +end + +function XUiFuben:RefreshBtnTabChallengeRedDot(count) + self.BtnTabChallenge:ShowReddot(count >= 0) +end + +function XUiFuben:RefreshBtnTabActivityRedDot(count) + self.BtnTabActivity:ShowReddot(count >= 0) +end + +function XUiFuben:OnCheckExperimentRedPoint(count) + self.ExperimentRedPoint.gameObject:SetActiveEx(count >= 0) +end + +function XUiFuben:OnOpenInit() + self.IsLoadFinish = true + local defaultSelectIndex + if self.ResumeIndex then + defaultSelectIndex = self.ResumeIndex + elseif self.CurStageId then + -- 指定关卡 + local stageInfo = XDataCenter.FubenManager.GetStageInfo(self.CurStageId) + if stageInfo.Type == XDataCenter.FubenManager.StageType.Mainline then + -- chapter + self.CurDiff = stageInfo.Difficult + self:RefreshForChangeDiff() + self.PanelBottomRightRT.gameObject:SetActiveEx(false) + elseif stageInfo.Type == XDataCenter.FubenManager.StageType.Daily + or stageInfo.Type == XDataCenter.FubenManager.StageType.Tower + or stageInfo.Type == XDataCenter.FubenManager.StageType.BossSingle + or stageInfo.Type == XDataCenter.FubenManager.StageType.Urgent then + defaultSelectIndex = self.BtnTabIndex.Challenge + elseif stageInfo.Type == XDataCenter.FubenManager.StageType.BossOnline then + defaultSelectIndex = self.BtnTabIndex.Activity + end + elseif self.CurType then + -- 副本类型 + if self.CurType == XDataCenter.FubenManager.StageType.Mainline then + defaultSelectIndex = self.BtnTabIndex.MainLine + elseif self.CurType == XDataCenter.FubenManager.StageType.Daily then + defaultSelectIndex = self.BtnTabIndex.Challenge + elseif self.CurType == XDataCenter.FubenManager.StageType.BossOnline then + defaultSelectIndex = self.BtnTabIndex.Activity + elseif self.CurType == XDataCenter.FubenManager.StageType.Resource then + defaultSelectIndex = self.BtnTabIndex.Daily + end + else + defaultSelectIndex = self.BtnTabIndex.MainLine + end + + if defaultSelectIndex then + self.PanelBottomRight:SelectIndex(defaultSelectIndex) + end +end + +function XUiFuben:OpenOneChildUi(childUiName, needAnimation, args) + + XUiFuben.Super.OpenOneChildUi(self, childUiName, args) + -- if needAnimation then + -- self:PlayAnimation("ChildUiParentEnable") + -- end +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiFuben:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiFuben:AutoInitUi() + self.BtnMainUi = self.Transform:Find("SafeAreaContentPane/Root/Top/BtnMainUi"):GetComponent("Button") + self.BtnBack = self.Transform:Find("SafeAreaContentPane/Root/Top/BtnBack"):GetComponent("Button") + self.PanelContent = self.Transform:Find("SafeAreaContentPane/PanelContent") + self.PanelAsset = self.Transform:Find("SafeAreaContentPane/Root/PanelAsset") + self.BtnTrial = self.Transform:Find("SafeAreaContentPane/Root/BtnTrial"):GetComponent("Button") +end + +function XUiFuben:AutoAddListener() + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.TogActivity, self.OnTogActivityClick) + self:RegisterClickEvent(self.TogChallenge, self.OnTogChallengeClick) + self:RegisterClickEvent(self.TogMainLine, self.OnTogMainLineClick) + self:RegisterClickEvent(self.TogDaily, self.OnTogDailyClick) + self:RegisterClickEvent(self.BtnTrial, self.OnBtnTrialClick) +end +-- auto +function XUiFuben:OnBtnTrialClick() + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.FubenActivityTrial) then + return + end + XLuaUiManager.Open("UiFubenExperiment") +end + +-- 播放完动画再打开界面 +function XUiFuben:PushUi(cb) + if self.IsPlaying then return end + self.IsPlaying = true + self:PlayAnimation("ExcessiveDisable", function() + cb() + self.IsPlaying = false + end) +end + +function XUiFuben:RefreshForChangeDiff() + if self.MainLineChapterInst then + self.MainLineChapterInst:InitChapterList(self.CurDiff) + end +end + +function XUiFuben:OnBtnBackClick() + if not self.IsLoadFinish then + return + end + self:Close() +end + +function XUiFuben:OnBtnMainUiClick() + if not self.IsLoadFinish then + return + end + XLuaUiManager.RunMain() +end + +function XUiFuben:OnReleaseInst() + return self.SelectedIndex +end + +function XUiFuben:OnResume(data) + self.ResumeIndex = data +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenActivityBanner/XUiFubenActivityBanner.lua b/Resources/Scripts/XUi/XUiFubenActivityBanner/XUiFubenActivityBanner.lua new file mode 100644 index 00000000..691ca16c --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenActivityBanner/XUiFubenActivityBanner.lua @@ -0,0 +1,417 @@ +local XUiGridActivityBanner = require("XUi/XUiFubenActivityBanner/XUiGridActivityBanner") +local XUiFubenActivityBanner = XLuaUiManager.Register(XLuaUi, "UiFubenActivityBanner") + +function XUiFubenActivityBanner:OnAwake() + self.DynamicTable = XDynamicTableNormal.New(self.PanelChapterList) + self.DynamicTable:SetProxy(XUiGridActivityBanner) + self.DynamicTable:SetDelegate(self) + self.GridActivityBanner.gameObject:SetActive(false) +end + +function XUiFubenActivityBanner:OnStart() +end + +function XUiFubenActivityBanner:OnEnable() + self:SetupDynamicTable() + self:PlayAnimation("ActivityQieHuanEnable") + + XEventManager.AddEventListener(XEventId.EVENT_ARENAONLINE_WEEK_REFRESH, self.OnArenaOnlineWeekRefrsh, self) + XEventManager.AddEventListener(XEventId.EVENT_ONLINE_BOSS_REFRESH, self.OnTableRefresh, self) + XEventManager.AddEventListener(XEventId.EVENT_NIER_ACTIVITY_REFRESH, self.OnNieRRefresh, self) +end + +function XUiFubenActivityBanner:OnDisable() + XEventManager.RemoveEventListener(XEventId.EVENT_ARENAONLINE_WEEK_REFRESH, self.OnArenaOnlineWeekRefrsh, self) + XEventManager.RemoveEventListener(XEventId.EVENT_ONLINE_BOSS_REFRESH, self.OnTableRefresh, self) + XEventManager.RemoveEventListener(XEventId.EVENT_NIER_ACTIVITY_REFRESH, self.OnNieRRefresh, self) +end + +-- 区域联机周刷新 +function XUiFubenActivityBanner:OnArenaOnlineWeekRefrsh() + self:SetupDynamicTable() + self:PlayAnimation("ActivityQieHuanEnable") +end + +function XUiFubenActivityBanner:OnTableRefresh() + self:SetupDynamicTable() +end + +function XUiFubenActivityBanner:OnNieRRefresh() + self:SetupDynamicTable() +end + +--动态列表事件 +function XUiFubenActivityBanner:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:Refresh(self.Chapters[index], self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + self:ClickChapterGrid(self.Chapters[index]) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_RECYCLE then + grid:OnDestroy() + end +end + +--设置动态列表 +function XUiFubenActivityBanner:SetupDynamicTable(bReload) + self.Chapters = XDataCenter.FubenManager.GetActivityChaptersBySort() + self.DynamicTable:SetDataSource(self.Chapters) + self.DynamicTable:ReloadDataSync(bReload and 1 or -1) +end + +function XUiFubenActivityBanner:ClickChapterGrid(chapter) + if chapter.Type == XDataCenter.FubenManager.ChapterType.BossOnline then + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.FubenActivityOnlineBoss) then + return + end + + local isActivity = XDataCenter.FubenBossOnlineManager.GetIsActivity() + if not XDataCenter.FubenBossOnlineManager.CheckNormalBossOnlineInTime() and not isActivity then + local tipStr = XDataCenter.FubenBossOnlineManager.GetNotInTimeTip() + XUiManager.TipError(tipStr) + return + end + self.ParentUi:PushUi(function() + XDataCenter.FubenBossOnlineManager.OpenBossOnlineUi() + end) + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.ActivtityBranch then + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.FubenActivityBranch) then + return + end + self.ParentUi:PushUi(function() + XLuaUiManager.Open("UiActivityBranch", chapter.Id) + end) + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.ActivityBossSingle then + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.FubenActivitySingleBoss) then + return + end + self.ParentUi:PushUi(function() + XLuaUiManager.Open("UiActivityBossSingle", chapter.Id) + end) + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.Christmas or + chapter.Type == XDataCenter.FubenManager.ChapterType.BriefDarkStream or + chapter.Type == XDataCenter.FubenManager.ChapterType.FestivalNewYear or + chapter.Type == XDataCenter.FubenManager.ChapterType.FoolsDay or + chapter.Type == XDataCenter.FubenManager.ChapterType.ChinaBoatPreheat then + self:OnClickFestivalActivity(chapter.Id) + + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.ActivityBabelTower then + + self:OnClickBabelTowerActivity() + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.RepeatChallenge then + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.RepeatChallenge) then + return + end + self.ParentUi:PushUi(function() + XLuaUiManager.Open("UiFubenRepeatchallenge") + end) + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.RogueLike then + self:OnClickRogueLikeActivity(chapter.Id) + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.ArenaOnline then + self:OnClicArenaOnlineActivity(chapter.Id) + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.UnionKill then + self:OnClickUnionKillActivity(chapter.Id) + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.SpecialTrain then + self:OnClickSpecialTrainActivity(chapter.Id) + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.Expedition then + self:OnClickExpedition(chapter.Id) + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.NewCharAct then + self:OnClickNewCharAct(chapter.Id) + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.WorldBoss then + self:OnClickWorldBoss() + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.RpgTower then + self:OnClickRpgTower() + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.NieR then + self:OnClickNieR() + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.Pokemon then + self:OnClickPokemon() + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.ChessPursuit then + self:OnClickChessPursuit() + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.SimulatedCombat then + self:OnClickSimulatedCombat() + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.SpringFestivalActivity then + self:OnClickSpringFestivalActivity() + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.MoeWar then + self:OnClickMoeWar() + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.Reform then + self:OnClickReform() + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.PokerGuessing then + self:OnClickPokerGuessing() + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.Hack then + self:OnClickFubenHack() + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.CoupleCombat then + self:OnClickFubenCoupleCombat() + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.FashionStory then + self:OnClickFashionStory(chapter.Id) + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.KillZone then + self:OnClickKillZone() + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.SuperTower then + self:OnClickSuperTower() + end +end + +function XUiFubenActivityBanner:OnClickKillZone() + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.KillZone) then + return + end + + local beforeOpenUiCb = handler(self.ParentUi, self.ParentUi.PushUi) + XDataCenter.KillZoneManager.EnterUiMain(beforeOpenUiCb) +end + +function XUiFubenActivityBanner:OnClickSuperTower() + XDataCenter.SuperTowerManager.JumpTo() +end + +function XUiFubenActivityBanner:OnClickNieR() + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.NieR) then + return + end + if XDataCenter.NieRManager.GetIsActivityEnd() then + XUiManager.TipMsg(CS.XTextManager.GetText("NieREnd")) + return + end + self.ParentUi:PushUi(function() + XLuaUiManager.Open("UiFubenNierEnter") + end) +end + +function XUiFubenActivityBanner:OnClickRpgTower() + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.RpgTower) then + return + end + if XDataCenter.RpgTowerManager.GetIsEnd() then + XUiManager.TipMsg(CS.XTextManager.GetText("RpgTowerEnd")) + return + end + self.ParentUi:PushUi(function() + XLuaUiManager.Open("UiRpgTowerMain") + end) +end + +function XUiFubenActivityBanner:OnClickFestivalActivity(festivalId) + local chapterTemplate = XFestivalActivityConfig.GetFestivalById(festivalId) + if chapterTemplate.FunctionOpenId and (not XFunctionManager.DetectionFunction(chapterTemplate.FunctionOpenId)) then + return + end + + self.ParentUi:PushUi(function() + XLuaUiManager.Open("UiFubenChristmasMainLineChapter", festivalId) + end) +end + +function XUiFubenActivityBanner:OnClickBabelTowerActivity() + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.BabelTower) then + return + end + + self.ParentUi:PushUi(function() + XDataCenter.FubenBabelTowerManager.OpenBabelTowerCheckStory() + end) +end + +function XUiFubenActivityBanner:OnClickRogueLikeActivity(rogueLikeId) + local activityConfig = XFubenRogueLikeConfig.GetRogueLikeConfigById(rogueLikeId) + + if not activityConfig then + return + end + if activityConfig.FunctionalOpenId > 0 and (not XFunctionManager.DetectionFunction(activityConfig.FunctionalOpenId)) then + return + end + self.ParentUi:PushUi(function() + XDataCenter.FubenRogueLikeManager.OpenRogueLikeCheckStory() + end) +end + +function XUiFubenActivityBanner:OnClicArenaOnlineActivity(chapterId) + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.ArenaOnline) then + return + end + + self.ParentUi:PushUi(function() + XDataCenter.ArenaOnlineManager.OpenArenaOnlineChapter(chapterId) + end) +end + +function XUiFubenActivityBanner:OnClickUnionKillActivity() + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.FubenUnionKill) then + return + end + + self.ParentUi:PushUi(function() + XLuaUiManager.Open("UiUnionKillMain") + end) +end + + + +function XUiFubenActivityBanner:OnClickSpecialTrainActivity(chapterId) + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.SpecialTrain, true) then + return + end + + if XDataCenter.FubenSpecialTrainManager.CheckActivityTimeout(chapterId, true) then + return + end + + self.ParentUi:PushUi(function() + XLuaUiManager.Open("UiSummerEpisodeNew",chapterId) + end) +end + +function XUiFubenActivityBanner:OnClickExpedition(chapterId) + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.Expedition) then + return + end + if XDataCenter.ExpeditionManager.GetIsActivityEnd() then + XUiManager.TipMsg(CS.XTextManager.GetText("ExpeditionActivityEnd")) + return + end + self.ParentUi:PushUi(function() + XLuaUiManager.Open("UiExpeditionMain") + end) +end + +function XUiFubenActivityBanner:OnClickNewCharAct(actId) + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.NewCharAct) then + return + end + + local newCharType = XFubenNewCharConfig.GetNewCharType(actId) + local uiName + if newCharType == XFubenNewCharConfig.NewCharType.YinMianZheGuang then + uiName = "UiNewCharActivity" + elseif newCharType == XFubenNewCharConfig.NewCharType.KoroChar then + uiName = "UiFunbenKoroTutorial" + elseif newCharType == XFubenNewCharConfig.NewCharType.WeiLa then + uiName = "UiFunbenWeiLaTutorial" + end + + self.ParentUi:PushUi(function() + XLuaUiManager.Open(uiName, actId) + end) +end + +function XUiFubenActivityBanner:OnClickWorldBoss() + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.WorldBoss) then + return + end + self.ParentUi:PushUi(function() + XDataCenter.WorldBossManager.OpenWorldMainWind() + end) +end + +function XUiFubenActivityBanner:OnClickPokemon() + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.Pokemon) then + return + end + + self.ParentUi:PushUi(function() + XDataCenter.PokemonManager.OpenPokemonMainUi() + end) +end + +function XUiFubenActivityBanner:OnClickChessPursuit() + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.ChessPursuitMain) then + return + end + + XDataCenter.FunctionalSkipManager.SkipToPursuit() +end + +function XUiFubenActivityBanner:OnClickSimulatedCombat() + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.FubenSimulatedCombat) then + return + end + + if XDataCenter.FubenSimulatedCombatManager.GetIsActivityEnd() then + XUiManager.TipMsg(CS.XTextManager.GetText("ActivityMainLineEnd")) + return + end + + self.ParentUi:PushUi(function() + XLuaUiManager.Open("UiSimulatedCombatMain") + end) +end + +function XUiFubenActivityBanner:OnClickSpringFestivalActivity() + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.SpringFestivalActivity) then + return + end + + self.ParentUi:PushUi(function() + XDataCenter.SpringFestivalActivityManager.OpenActivityMain() + end) +end + +function XUiFubenActivityBanner:OnClickMoeWar() + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.MoeWar) then + return + end + + self.ParentUi:PushUi(function() + XDataCenter.MoeWarManager.OnOpenMain() + end) +end + +function XUiFubenActivityBanner:OnClickReform() + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.Reform) then + return + end + XDataCenter.ReformActivityManager.EnterRequest(function() + self.ParentUi:PushUi(function() + XLuaUiManager.Open("UiReform") + end) + end) +end + +function XUiFubenActivityBanner:OnClickPokerGuessing() + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.PokerGuessing) then + return + end + + self.ParentUi:PushUi(function() + XDataCenter.PokerGuessingManager.OnOpenMain() + end) +end + +function XUiFubenActivityBanner:OnClickFubenHack() + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.FubenHack) then + return + end + + if XDataCenter.FubenHackManager.GetIsActivityEnd() then + XUiManager.TipMsg(CS.XTextManager.GetText("ActivityMainLineEnd")) + return + end + + self.ParentUi:PushUi(function() + XLuaUiManager.Open("UiFubenHack") + end) +end + +function XUiFubenActivityBanner:OnClickFubenCoupleCombat() + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.FubenCoupleCombat) then + return + end + + if XDataCenter.FubenCoupleCombatManager.GetIsActivityEnd() then + XUiManager.TipMsg(CS.XTextManager.GetText("ActivityMainLineEnd")) + return + end + + self.ParentUi:PushUi(function() + XLuaUiManager.Open("UiCoupleCombatMain") + end) +end + +-- 系列涂装剧情活动 +function XUiFubenActivityBanner:OnClickFashionStory(activityId) + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.FashionStory) then + return + end + + self.ParentUi:PushUi(function() + XDataCenter.FashionStoryManager.OpenFashionStoryMain(activityId) + end) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenActivityBanner/XUiGridActivityBanner.lua b/Resources/Scripts/XUi/XUiFubenActivityBanner/XUiGridActivityBanner.lua new file mode 100644 index 00000000..22456745 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenActivityBanner/XUiGridActivityBanner.lua @@ -0,0 +1,1157 @@ +local CsXTextManager = CS.XTextManager + +local XUiGridActivityBanner = XClass(nil, "XUiGridActivityBanner") + +function XUiGridActivityBanner:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiGridActivityBanner:OnDestroy() + self:DestroyActivityTimer() + self:StopCommonTimer() +end + +function XUiGridActivityBanner:Refresh(chapter, uiRoot) + self:ReSetActivityBanner() + if chapter.Type == XDataCenter.FubenManager.ChapterType.BossOnline then + self:RefreshBossOnline(chapter, uiRoot) + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.ActivtityBranch then + self:RefreshActivtityBranch(chapter, uiRoot) + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.ActivityBossSingle then + self:RefreshActivityBossSingle(chapter, uiRoot) + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.Christmas or + chapter.Type == XDataCenter.FubenManager.ChapterType.BriefDarkStream or + chapter.Type == XDataCenter.FubenManager.ChapterType.FestivalNewYear or + chapter.Type == XDataCenter.FubenManager.ChapterType.FoolsDay or + chapter.Type == XDataCenter.FubenManager.ChapterType.ChinaBoatPreheat or + chapter.Type == XDataCenter.FubenManager.ChapterType.SpringFestivalActivity then + self:RefreshActivityFestival(chapter, uiRoot) + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.ActivityBabelTower then + self:RefreshBabelTowerBanner(chapter, uiRoot) + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.RepeatChallenge then + self:RefreshRepeatChallenge(chapter, uiRoot) + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.RogueLike then + self:RefreshRogueLikeBanner(chapter, uiRoot) + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.ArenaOnline then + self:RefreshArenaOnline(chapter, uiRoot) + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.UnionKill then + self:RefreshUnionKillBanner(chapter, uiRoot) + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.SpecialTrain then + self:RefreshSpecialTrainBanner(chapter, uiRoot) + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.Expedition then + self:RefreshExpeditionBanner(chapter, uiRoot) + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.WorldBoss then + self:RefreshWorldBossBanner(chapter, uiRoot) + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.RpgTower then + self:RefreshRpgTowerBanner(chapter, uiRoot) + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.NieR then + self:RefreshNieRBanner(chapter, uiRoot) + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.NewCharAct then + self:RefreshNewCharAct(chapter, uiRoot) + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.Pokemon then + self:RefreshPokemonBanner(chapter, uiRoot) + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.ChessPursuit then + self:RefreshChessPursuit(chapter, uiRoot) + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.SimulatedCombat then + self:RefreshSimulatedCombatBanner(chapter, uiRoot) + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.MoeWar then + self:RefreshMoeWarBanner(chapter, uiRoot) + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.Reform then + self:RefreshReformBanner(chapter, uiRoot) + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.PokerGuessing then + self:RefreshPokerGuessingBanner(chapter, uiRoot) + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.Hack then + self:RefreshHackBanner(chapter, uiRoot) + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.CoupleCombat then + self:RefreshCoupleCombatBanner(chapter, uiRoot) + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.FashionStory then + self:RefreshFashionStory(chapter, uiRoot) + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.KillZone then + self:RefreshKillZone(chapter, uiRoot) + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.SuperTower then + self:RefreshSuperTower(chapter, uiRoot) + end +end + +-- 复刷关 +function XUiGridActivityBanner:RefreshRepeatChallenge(chapter, uiRoot) + local activityCfg = XDataCenter.FubenRepeatChallengeManager.GetActivityConfig() + self.TxtName.text = activityCfg.Name + self.RImgIcon:SetRawImage(activityCfg.Cover) + self.PanelActivityTag.gameObject:SetActiveEx(true) + + if XDataCenter.FubenRepeatChallengeManager.IsStatusEqualFightEnd() then + self.TxtConsumeCount.gameObject:SetActiveEx(false) + else + local chapterId = chapter.Id + local chapterCfg = XFubenRepeatChallengeConfigs.GetChapterCfg(chapterId) + local finishCount = XDataCenter.FubenRepeatChallengeManager.GetChapterFinishCount(chapterId) + local totalCount = #chapterCfg.StageId + self.TxtConsumeCount.text = CsXTextManager.GetText("ActivityRepeateChallengeProcess", chapterCfg.Name, finishCount, totalCount) + self.TxtConsumeCount.gameObject:SetActiveEx(true) + end + + if not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.RepeatChallenge) then + self.PanelLock.gameObject:SetActiveEx(true) + self.TxtLock.text = XFunctionManager.GetFunctionOpenCondition(XFunctionManager.FunctionName.RepeatChallenge) + else + self.PanelLock.gameObject:SetActiveEx(false) + end + + XRedPointManager.CheckOnce(self.OnCheckRedPoint, self, { XRedPointConditions.Types.CONDITION_REPEAT_CHALLENGE_REWARD }) + + local fightEndTime = XDataCenter.FubenRepeatChallengeManager.GetFightEndTime() + local activityEndTime = XDataCenter.FubenRepeatChallengeManager.GetActivityEndTime() + self:CreateActivityTimer(fightEndTime, activityEndTime, XDataCenter.FubenRepeatChallengeManager.OnActivityEnd) +end + +-- 节日活动 +function XUiGridActivityBanner:RefreshActivityFestival(chapter, uiRoot) + local sectionId = chapter.Id + local sectionCfg = XFestivalActivityConfig.GetFestivalById(sectionId) + + self.TxtName.text = sectionCfg.Name + self.PanelActivityTag.gameObject:SetActiveEx(true) + self.RImgIcon:SetRawImage(sectionCfg.BannerBg) + + local finishCount, totalCount = XDataCenter.FubenFestivalActivityManager.GetFestivalProgress(sectionId) + self.TxtConsumeCount.text = CsXTextManager.GetText("ActivityBossSingleProcess", finishCount, totalCount) + + local startTimeSecond, endTimeSecond = XFestivalActivityConfig.GetFestivalTime(sectionId) + local now = XTime.GetServerNowTimestamp() + if startTimeSecond and endTimeSecond and now >= startTimeSecond and now <= endTimeSecond then + self:CreateCommonTimer(startTimeSecond, endTimeSecond, function() + uiRoot:SetupDynamicTable() + end) + else + self.PanelLeftTime.gameObject:SetActiveEx(false) + end + -- 功能开启AcitvityFestivalProgress + if sectionCfg.FunctionOpenId > 0 then + if not XFunctionManager.JudgeCanOpen(sectionCfg.FunctionOpenId) then + self.PanelLock.gameObject:SetActiveEx(true) + self.TxtLock.text = XFunctionManager.GetFunctionOpenCondition(sectionCfg.FunctionOpenId) + else + self.PanelLock.gameObject:SetActiveEx(false) + end + else + self.PanelLock.gameObject:SetActiveEx(false) + end +end + +-- 单挑BOSS +function XUiGridActivityBanner:RefreshActivityBossSingle(chapter, uiRoot) + local sectionId = chapter.Id + local sectionCfg = XFubenActivityBossSingleConfigs.GetSectionCfg(sectionId) + local finishCount = XDataCenter.FubenActivityBossSingleManager.GetFinishCount() + local totalCount = #sectionCfg.ChallengeId + + self.TxtName.text = sectionCfg.ChapterName + self.PanelActivityTag.gameObject:SetActiveEx(true) + self.RImgIcon:SetRawImage(sectionCfg.Cover) + self.TxtConsumeCount.text = CsXTextManager.GetText("ActivityBossSingleProcess", finishCount, totalCount) + + if not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.FubenActivitySingleBoss) then + self.PanelLock.gameObject:SetActiveEx(true) + self.TxtLock.text = XFunctionManager.GetFunctionOpenCondition(XFunctionManager.FunctionName.FubenActivitySingleBoss) + else + self.PanelLock.gameObject:SetActiveEx(false) + end + + local fightEndTime = XDataCenter.FubenActivityBossSingleManager.GetFightEndTime() + local activityEndTime = XDataCenter.FubenActivityBossSingleManager.GetActivityEndTime() + self:CreateActivityTimer(fightEndTime, activityEndTime, XDataCenter.FubenActivityBossSingleManager.OnActivityEnd) +end + +-- 活动支线副本 +function XUiGridActivityBanner:RefreshActivtityBranch(chapter, uiRoot) + local sectionId = chapter.Id + local chapterId = XDataCenter.FubenActivityBranchManager.GetCurChapterId(sectionId) + local chapterCfg = XFubenActivityBranchConfigs.GetChapterCfg(chapterId) + local finishCount = XDataCenter.FubenActivityBranchManager.GetChapterFinishCount(chapterId) + local totalCount = #chapterCfg.StageId + + self.TxtName.text = chapterCfg.Name + self.PanelActivityTag.gameObject:SetActiveEx(true) + self.RImgIcon:SetRawImage(chapterCfg.Cover) + + if not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.FubenActivityBranch) then + self.PanelLock.gameObject:SetActiveEx(true) + self.TxtLock.text = XFunctionManager.GetFunctionOpenCondition(XFunctionManager.FunctionName.FubenActivityBranch) + else + self.PanelLock.gameObject:SetActiveEx(false) + end + + if not XDataCenter.FubenActivityBranchManager.IsSelectDifficult() then + self.TxtConsumeCount.text = CsXTextManager.GetText("ActivityBranchNormalProcess", finishCount, totalCount) + else + self.TxtConsumeCount.text = CsXTextManager.GetText("ActivityBranchDifficultProcess", finishCount, totalCount) + end + + local fightEndTime = XDataCenter.FubenActivityBranchManager.GetFightEndTime() + local activityEndTime = XDataCenter.FubenActivityBranchManager.GetActivityEndTime() + self:CreateActivityTimer(fightEndTime, activityEndTime, XDataCenter.FubenActivityBranchManager.OnActivityEnd) +end + +-- 联机BOSS +function XUiGridActivityBanner:RefreshBossOnline(chapter, uiRoot) + self.TxtName.text = chapter.Name + local count = XDataCenter.FubenBossOnlineManager.GetFlopConsumeItemCount() + self.TxtConsumeCount.text = CsXTextManager.GetText("BossOnlineProcess", count) + + local isActivity = XDataCenter.FubenBossOnlineManager.GetIsActivity() + + if not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.FubenActivityOnlineBoss) then + self.PanelLock.gameObject:SetActiveEx(true) + self.TxtLock.text = XFunctionManager.GetFunctionOpenCondition(XFunctionManager.FunctionName.FubenActivityOnlineBoss) + else + self.PanelLock.gameObject:SetActiveEx(false) + if not XDataCenter.FubenBossOnlineManager.CheckNormalBossOnlineInTime() and not isActivity then + self.PanelLock.gameObject:SetActive(true) + self.TxtLock.text = XDataCenter.FubenBossOnlineManager.GetNotInTimeTip() + end + end + + + self.PanelActivityTag.gameObject:SetActiveEx(isActivity) + self.RImgIcon:SetRawImage(chapter.Icon) + local leftTime = XDataCenter.FubenBossOnlineManager.GetOnlineBossUpdateTime() + if isActivity then + self:CreateActivityTimer(leftTime, leftTime, XDataCenter.FubenBossOnlineManager.OnActivityEnd) + else + self.PanelLeftTime.gameObject:SetActiveEx(false) + end +end + +-- 新角色预热活动 +function XUiGridActivityBanner:RefreshNewCharAct(chapter, uiRoot) + self.TxtName.text = chapter.Name + self.PanelActivityTag.gameObject:SetActiveEx(true) + self.RImgIcon:SetRawImage(chapter.Icon) + local passStageCount, allStageCount = XDataCenter.FubenNewCharActivityManager.GetStageSchedule(chapter.Id) + self.TxtConsumeCount.text = CS.XTextManager.GetText("ArenaOnlineJindu", passStageCount, allStageCount) + local newCharType = XFubenNewCharConfig.GetNewCharType(chapter.Id) + if newCharType == XFubenNewCharConfig.NewCharType.KoroChar then + self.TxtConsumeCount.gameObject:SetActiveEx(false) + end + + local _, endTimeSecond = XFubenNewCharConfig.GetActivityTime(chapter.Id) + self:CreateActivityTimer(endTimeSecond, endTimeSecond) + + -- 条件是否满足 + if not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.NewCharAct) then + self.PanelLock.gameObject:SetActiveEx(true) + self.TxtLock.text = XFunctionManager.GetFunctionOpenCondition(XFunctionManager.FunctionName.NewCharAct) + else + self.PanelLock.gameObject:SetActiveEx(false) + end + XRedPointManager.CheckOnce(self.OnCheckRedPoint, self, { XRedPointConditions.Types.CONDITION_KOROMCHARACTIVITYMAINRED }) +end + +-- 尼尔副本入口 +function XUiGridActivityBanner:RefreshNieRBanner(chapter, uiRoot) + self.TxtName.text = chapter.Name + self.RImgIcon:SetRawImage(chapter.BannerBg) + self.PanelActivityTag.gameObject:SetActiveEx(true) + self.TxtConsumeCount.gameObject:SetActiveEx(true) + + local activityEnd, notStart = XDataCenter.NieRManager.GetIsActivityEnd() + + if not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.NieR) then + self.PanelLock.gameObject:SetActiveEx(true) + self.TxtLock.text = XFunctionManager.GetFunctionOpenCondition(XFunctionManager.FunctionName.NieR) + else + self.PanelLock.gameObject:SetActiveEx(false) + end + + if activityEnd then + self.PanelLock.gameObject:SetActiveEx(true) + self.PanelLeftTime.gameObject:SetActiveEx(false) + if notStart then + self.TxtLock.text = CS.XTextManager.GetText("NieRNotStart") + self.TxtConsumeCount.text = CS.XTextManager.GetText("NieRNotStart") + else + self.TxtLock.text = CS.XTextManager.GetText("NieREnd") + self.TxtConsumeCount.text = CS.XTextManager.GetText("NieREnd") + end + return + end + + XRedPointManager.CheckOnce(self.OnCheckRedPoint, self, { XRedPointConditions.Types.CONDITION_NIER_RED }) + + local startTimeSecond = XDataCenter.NieRManager.GetStartTime() + local endTimeSecond = XDataCenter.NieRManager.GetEndTime() + local now = XTime.GetServerNowTimestamp() + if startTimeSecond and endTimeSecond and now >= startTimeSecond and now <= endTimeSecond then + self:CreateCommonTimer(startTimeSecond, endTimeSecond, function() + uiRoot:SetupDynamicTable() + end) + else + self.PanelLeftTime.gameObject:SetActiveEx(false) + end + self.TxtConsumeCount.text = XDataCenter.NieRManager.GetChapterProgressStr() + +end + +-- 兵法蓝图玩法入口 +function XUiGridActivityBanner:RefreshRpgTowerBanner(chapter, uiRoot) + self.TxtName.text = XDataCenter.RpgTowerManager.GetActivityName() + self.RImgIcon:SetRawImage(XDataCenter.RpgTowerManager.GetEntryTexture()) + self.PanelActivityTag.gameObject:SetActiveEx(true) + XRedPointManager.CheckOnce(self.OnCheckRpgTowerRedPoint, self, { XRedPointConditions.Types.CONDITION_RPGTOWER_TASK_RED, XRedPointConditions.Types.CONDITION_RPGTOWER_DAILYREWARD_RED }) + local activityEnd, notStart = XDataCenter.RpgTowerManager.GetIsEnd() + if not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.RpgTower) then + self.PanelLock.gameObject:SetActiveEx(true) + self.TxtLock.text = XFunctionManager.GetFunctionOpenCondition(XFunctionManager.FunctionName.RpgTower) + elseif activityEnd then + self.PanelLock.gameObject:SetActiveEx(true) + self.PanelLeftTime.gameObject:SetActiveEx(false) + if notStart then + self.TxtLock.text = CS.XTextManager.GetText("RpgTowerNotStart") + self.TxtConsumeCount.text = CS.XTextManager.GetText("RpgTowerNotStart") + else + self.TxtLock.text = CS.XTextManager.GetText("RpgTowerEnd") + self.TxtConsumeCount.text = CS.XTextManager.GetText("RpgTowerEnd") + end + return + else + self.PanelLock.gameObject:SetActiveEx(false) + end + local startTimeSecond = XDataCenter.RpgTowerManager.GetStartTime() + local endTimeSecond = XDataCenter.RpgTowerManager.GetEndTime() + local now = XTime.GetServerNowTimestamp() + if startTimeSecond and endTimeSecond and now >= startTimeSecond and now <= endTimeSecond then + self:CreateCommonTimer(startTimeSecond, endTimeSecond, function() + uiRoot:SetupDynamicTable() + end) + else + self.PanelLeftTime.gameObject:SetActiveEx(false) + end + self.TxtConsumeCount.text = XDataCenter.RpgTowerManager.GetChapterProgressStr() + self.TxtConsumeCount.gameObject:SetActiveEx(true) +end +--================== +--超级爬塔入口 +--================== +function XUiGridActivityBanner:RefreshSuperTower(chapter, uiRoot) + self.TxtName.text = XDataCenter.SuperTowerManager.GetActivityName() + self.RImgIcon:SetRawImage(XDataCenter.SuperTowerManager.GetActivityEntryImage()) + self.PanelActivityTag.gameObject:SetActiveEx(true) + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.SuperTower, false, true) then + self.PanelLock.gameObject:SetActiveEx(true) + self.TxtLock.text = XFunctionManager.GetFunctionOpenCondition(XFunctionManager.FunctionName.SuperTower) + else + self.PanelLock.gameObject:SetActiveEx(false) + end + local startTimeSecond = XDataCenter.SuperTowerManager.GetActivityStartTime() + local endTimeSecond = XDataCenter.SuperTowerManager.GetActivityEndTime() + local now = XTime.GetServerNowTimestamp() + if startTimeSecond and endTimeSecond and now >= startTimeSecond and now <= endTimeSecond then + self:CreateCommonTimer(startTimeSecond, endTimeSecond, function() + uiRoot:SetupDynamicTable() + end) + else + self.PanelLeftTime.gameObject:SetActiveEx(false) + end + local theme = XDataCenter.SuperTowerManager.GetStageManager():GetThemeByClearProgress() + if not theme then + self.TxtConsumeCount.gameObject:SetActiveEx(false) + else + self.TxtConsumeCount.text = theme:GetName() + self.TxtConsumeCount.gameObject:SetActiveEx(true) + end +end + +function XUiGridActivityBanner:OnCheckRpgTowerRedPoint(count) + if self.Red then + self.Red.gameObject:SetActive(count >= 0) + end +end + +--虚像地平线玩法入口 +function XUiGridActivityBanner:RefreshExpeditionBanner(chapter, uiRoot) + local eActivity = XDataCenter.ExpeditionManager.GetEActivity() + self.TxtName.text = eActivity:GetActivityName() + self.RImgIcon:SetRawImage(eActivity:GetBannerTexturePath()) + self.PanelActivityTag.gameObject:SetActiveEx(true) + if XDataCenter.ExpeditionManager.GetIsActivityEnd() then + self.PanelLock.gameObject:SetActiveEx(true) + self.PanelLeftTime.gameObject:SetActiveEx(false) + self.TxtLock.text = CS.XTextManager.GetText("ExpeditionActivityEnd") + self.TxtConsumeCount.text = CS.XTextManager.GetText("ExpeditionActivityEnd") + return + end + XRedPointManager.CheckOnce(self.OnCheckRedPoint, self, { XRedPointConditions.Types.CONDITION_EXPEDITION_CAN_RECRUIT }) + if not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.Expedition) then + self.PanelLock.gameObject:SetActiveEx(true) + self.TxtLock.text = XFunctionManager.GetFunctionOpenCondition(XFunctionManager.FunctionName.Expedition) + else + self.PanelLock.gameObject:SetActiveEx(false) + end + local startTimeSecond = XDataCenter.ExpeditionManager.GetStartTime() + local endTimeSecond = XDataCenter.ExpeditionManager.GetResetTime() + local now = XTime.GetServerNowTimestamp() + if startTimeSecond and endTimeSecond and now >= startTimeSecond and now <= endTimeSecond then + self:CreateCommonTimer(startTimeSecond, endTimeSecond, function() + uiRoot:SetupDynamicTable() + end) + else + self.PanelLeftTime.gameObject:SetActiveEx(false) + end + self.TxtConsumeCount.text = CsXTextManager.GetText("ExpeditionEntryBannerProcessStr", + XDataCenter.ExpeditionManager.GetStageCompleteStr(XDataCenter.ExpeditionManager.StageDifficulty.Normal)) + self.TxtConsumeCount.gameObject:SetActiveEx(true) +end + +function XUiGridActivityBanner:OnCheckRedPoint(count) + if self.Red then + self.Red.gameObject:SetActive(count >= 0) + end +end +--特训关 +function XUiGridActivityBanner:RefreshSpecialTrainBanner(chapter, uiRoot) + local activityId = chapter.Id + local activityConfig = XFubenSpecialTrainConfig.GetActivityConfigById(activityId) + + if not activityConfig then + return + end + self.TxtName.text = activityConfig.Name + self.PanelActivityTag.gameObject:SetActiveEx(true) + self.RImgIcon:SetRawImage(activityConfig.Icon) + + if not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.SpecialTrain) then + self.PanelLock.gameObject:SetActiveEx(true) + self.TxtLock.text = XFunctionManager.GetFunctionOpenCondition(XFunctionManager.FunctionName.SpecialTrain) + else + self.PanelLock.gameObject:SetActiveEx(false) + end + + XRedPointManager.CheckOnce(self.OnCheckRedPoint, self, { XRedPointConditions.Types.CONDITION_SPECIALTRAIN_RED }) + + local chapters = activityConfig.ChapterIds + local chapterConfig = {} + local totalStage = 0 + local passStage = 0 + for i, v in ipairs(chapters) do + local temp = XFubenSpecialTrainConfig.GetChapterConfigById(v) + for j = 1, #temp.StageIds do + local stageId = temp.StageIds[j] + totalStage = totalStage + 1 + + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + if stageInfo.Passed then + passStage = passStage + 1 + end + end + end + + self.TxtConsumeCount.text = CsXTextManager.GetText("ActivityBossSingleProcess", passStage, totalStage) + + local now = XTime.GetServerNowTimestamp() + local resetTime = XFunctionManager.GetEndTimeByTimeId(activityConfig.TimeId) + if not resetTime then + self.PanelLeftTime.gameObject:SetActiveEx(false) + return + end + + self:CreateCommonTimer(now, resetTime, function() + uiRoot:SetupDynamicTable() + end) +end + +--世界Boss +function XUiGridActivityBanner:RefreshWorldBossBanner(chapter, uiRoot) + self.TxtName.text = chapter.Name + self.RImgIcon:SetRawImage(chapter.BannerBg) + self.TitleText.text = CsXTextManager.GetText("WorldBossBossAreaSchedule") + self.PanelActivityTag.gameObject:SetActiveEx(true) + + XRedPointManager.CheckOnce(self.OnCheckRedPoint, self, { XRedPointConditions.Types.CONDITION_WORLDBOSS_RED }) + + local IsUnLock = XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.WorldBoss) + self.PanelLock.gameObject:SetActiveEx(not IsUnLock) + self.TxtLock.text = XFunctionManager.GetFunctionOpenCondition(XFunctionManager.FunctionName.WorldBoss) + + local now = XTime.GetServerNowTimestamp() + local endTime = XDataCenter.WorldBossManager.GetActivityEndTime() + if not endTime then + self.PanelLeftTime.gameObject:SetActiveEx(false) + return + end + + self:CreateCommonTimer(now, endTime, function() + uiRoot:SetupDynamicTable() + end) + + self.TxtConsumeCount.text = CsXTextManager.GetText("WorldBossKilled") + self.TxtConsumeCount.gameObject:SetActiveEx(chapter.BossHpPercent == 0) + self.PanelSlide.gameObject:SetActiveEx(chapter.BossHpPercent ~= 0) + + XDataCenter.WorldBossManager.GetWorldBossGlobalData(function() + self.TxtPercentNormal.text = string.format("%d%s", math.floor(chapter.BossHpPercent * 100), "%") + self.ImgPercentNormal.fillAmount = chapter.BossHpPercent + end) +end + +function XUiGridActivityBanner:RefreshUnionKillBanner(chapter, uiRoot) + local activityId = chapter.Id + local activityTemplate = XFubenUnionKillConfigs.GetUnionActivityById(activityId) + local activityConfig = XFubenUnionKillConfigs.GetUnionActivityConfigById(activityId) + if not activityTemplate then + return + end + self.TxtName.text = activityConfig.Name + self.PanelActivityTag.gameObject:SetActiveEx(true) + self.RImgIcon:SetRawImage(activityConfig.Icon) + + if not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.FubenUnionKill) then + self.PanelLock.gameObject:SetActiveEx(true) + self.TxtLock.text = XFunctionManager.GetFunctionOpenCondition(XFunctionManager.FunctionName.FubenUnionKill) + else + self.PanelLock.gameObject:SetActiveEx(false) + end + + local unionKillInfo = XDataCenter.FubenUnionKillManager.GetUnionKillInfo() + local curSectionIndex = 0 + if not unionKillInfo then + curSectionIndex = 0 + elseif unionKillInfo.CurSectionId == 0 then + curSectionIndex = #activityTemplate.SectionId + else + for i = 1, #activityTemplate.SectionId do + if unionKillInfo.CurSectionId == activityTemplate.SectionId[i] then + curSectionIndex = i + break + end + end + end + + self.TxtConsumeCount.text = CsXTextManager.GetText("UnionSectionProcessCount", curSectionIndex) + local now = XTime.GetServerNowTimestamp() + local _, resetTime = XFubenUnionKillConfigs.GetUnionActivityTimes(activityId) + if not resetTime then + self.PanelLeftTime.gameObject:SetActiveEx(false) + return + end + + if XFubenUnionKillConfigs.UnionKillInActivity(activityId) then + self:CreateCommonTimer(now, resetTime, function() + uiRoot:SetupDynamicTable() + end) + else + self.PanelLeftTime.gameObject:SetActiveEx(false) + end +end + +function XUiGridActivityBanner:RefreshRogueLikeBanner(chapter, uiRoot) + local activityId = chapter.Id + local activityConfig = XFubenRogueLikeConfig.GetRogueLikeConfigById(activityId) + local config = XFubenRogueLikeConfig.GetRougueLikeTemplateById(activityId) + if not activityConfig then + return + end + self.TxtName.text = activityConfig.Name + self.PanelActivityTag.gameObject:SetActiveEx(true) + self.RImgIcon:SetRawImage(chapter.BannerBg) + + if activityConfig.FunctionalOpenId > 0 and not XFunctionManager.JudgeCanOpen(activityConfig.FunctionalOpenId) then + self.PanelLock.gameObject:SetActiveEx(true) + self.TxtLock.text = XFunctionManager.GetFunctionOpenCondition(activityConfig.FunctionalOpenId) + else + self.PanelLock.gameObject:SetActiveEx(false) + end + + local index = XDataCenter.FubenRogueLikeManager.GetRogueLikeLevel() + local maxTier = XDataCenter.FubenRogueLikeManager.GetMaxTier() + self.TxtConsumeCount.text = CsXTextManager.GetText("ActivityBossSingleProcess", index, maxTier) + local now = XTime.GetServerNowTimestamp() + + local fightTime = XFunctionManager.GetEndTimeByTimeId(config.FightTimeId) + local endTime = XFunctionManager.GetEndTimeByTimeId(config.ActivityTimeId) + local resetTime = XDataCenter.FubenRogueLikeManager.GetWeekRefreshTime() + local desc = "" + if fightTime > now then + resetTime = fightTime + desc = CsXTextManager.GetText("RogueLikeWeekResetTime") + else + resetTime = endTime + desc = CsXTextManager.GetText("RogueLikeEndTime") + end + + if not resetTime then + self.PanelLeftTime.gameObject:SetActiveEx(false) + return + end + + if XDataCenter.FubenRogueLikeManager.IsInActivity() then + self:CreateCommonTimer(now, resetTime, function() + uiRoot:SetupDynamicTable() + end, desc) + + else + self.PanelLeftTime.gameObject:SetActiveEx(false) + end +end + +function XUiGridActivityBanner:RefreshArenaOnline(chapter, uiRoot) + self.TxtName.text = chapter.Name + self.PanelActivityTag.gameObject:SetActiveEx(true) + self.RImgIcon:SetRawImage(chapter.Icon) + local passStageCount, allStageCount = XDataCenter.ArenaOnlineManager.GetStageSchedule() + self.TxtConsumeCount.text = CS.XTextManager.GetText("ArenaOnlineJindu", passStageCount, allStageCount) + + local endTimeSecond = XDataCenter.ArenaOnlineManager.GetNextRefreshTime() + local now = XTime.GetServerNowTimestamp() + if now <= endTimeSecond then + local activeOverStr = CsXTextManager.GetText("ArenaOnlineLeftTimeOver") + local activityStr = CsXTextManager.GetText("ArenaOnlineLfteTime") + self:StopCommonTimer() + self.PanelLeftTime.gameObject:SetActiveEx(true) + if now <= endTimeSecond then + self.TxtLeftTime.text = string.format("%s%s", XUiHelper.GetTime(endTimeSecond - now, XUiHelper.TimeFormatType.DEFAULT), activityStr) + else + self.TxtLeftTime.text = activeOverStr + end + + self.CommonTimer = XScheduleManager.ScheduleForever(function() + now = XTime.GetServerNowTimestamp() + if now > endTimeSecond then + self:StopCommonTimer() + uiRoot:SetupDynamicTable() + return + end + if now <= endTimeSecond then + self.TxtLeftTime.text = string.format("%s%s", XUiHelper.GetTime(endTimeSecond - now, XUiHelper.TimeFormatType.DEFAULT), activityStr) + else + self.TxtLeftTime.text = activeOverStr + end + end, XScheduleManager.SECOND, 0) + else + self.PanelLeftTime.gameObject:SetActiveEx(false) + end + + -- 条件是否满足 + if XFunctionManager.FunctionName.ArenaOnline then + if not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.ArenaOnline) then + self.PanelLock.gameObject:SetActiveEx(true) + self.TxtLock.text = XFunctionManager.GetFunctionOpenCondition(XFunctionManager.FunctionName.ArenaOnline) + else + self.PanelLock.gameObject:SetActiveEx(false) + end + else + self.PanelLock.gameObject:SetActiveEx(false) + end +end + +function XUiGridActivityBanner:RefreshBabelTowerBanner(chapter, uiRoot) + local activityId = chapter.Id + local activityTemplate = XFubenBabelTowerConfigs.GetBabelTowerActivityTemplateById(activityId) + if not activityTemplate then + return + end + + self.TxtName.text = XFubenBabelTowerConfigs.GetActivityName(activityId) + self.PanelActivityTag.gameObject:SetActiveEx(true) + self.RImgIcon:SetRawImage(chapter.BannerBg) + local _, maxScore = XDataCenter.FubenBabelTowerManager.GetCurrentActivityScores() + self.TxtConsumeCount.text = CS.XTextManager.GetText("BabelTowerStageShowDesc", maxScore) + + local startTimeSecond, endTimeSecond = XFunctionManager.GetTimeByTimeId(activityTemplate.ActivityTimeId) + local fightTimeSecond = XFunctionManager.GetEndTimeByTimeId(activityTemplate.FightTimeId) + local now = XTime.GetServerNowTimestamp() + if startTimeSecond and endTimeSecond and fightTimeSecond and now >= startTimeSecond and now <= endTimeSecond then + self:CreateCommonActivityTimer(startTimeSecond, fightTimeSecond, endTimeSecond, function() + uiRoot:SetupDynamicTable() + end) + else + self.PanelLeftTime.gameObject:SetActiveEx(false) + end + + XRedPointManager.CheckOnce(self.OnCheckRedPoint, self, { XRedPointConditions.Types.CONDITION_ACTIVITYBRIE_BABELTOWER_REWARD }) + + -- 条件是否满足 + if XFunctionManager.FunctionName.BabelTower then + if not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.BabelTower) then + self.PanelLock.gameObject:SetActiveEx(true) + self.TxtLock.text = XFunctionManager.GetFunctionOpenCondition(XFunctionManager.FunctionName.BabelTower) + else + self.PanelLock.gameObject:SetActiveEx(false) + end + else + self.PanelLock.gameObject:SetActiveEx(false) + end +end + +function XUiGridActivityBanner:RefreshPokemonBanner(chapter, uiRoot) + local activityId = chapter.Id + self.TxtName.text = XPokemonConfigs.GetActivityName(activityId) + self.PanelActivityTag.gameObject:SetActiveEx(true) + self.RImgIcon:SetRawImage(chapter.BannerBg) + self.TxtConsumeCount.gameObject:SetActiveEx(true) + local chapters = XPokemonConfigs.GetChapters(activityId) + local passCount = 0 + local totalCount = 0 + for i = 1, #chapters - 1 do + passCount = passCount + XDataCenter.PokemonManager.GetPassedCountByChapterId(chapters[i].Id) + totalCount = totalCount + XPokemonConfigs.GetStageCountByChapter(activityId, chapters[i].Id) + end + passCount = XMath.Clamp(passCount, 0, totalCount) + self.TxtConsumeCount.text = CsXTextManager.GetText("PokemonJindu", passCount, totalCount) + XRedPointManager.CheckOnce(self.OnCheckRedPoint, self, { XRedPointConditions.Types.CONDITION_POKEMON_RED, XRedPointConditions.Types.CONDITION_POKEMON_TASK_RED }) + if XPokemonConfigs.IsActivityInTime(activityId) then + self:CreateCommonTimer(XPokemonConfigs.GetActivityStartTime(activityId), XPokemonConfigs.GetActivityEndTime(activityId), function() + uiRoot:SetupDynamicTable() + end) + end + + if XFunctionManager.FunctionName.Pokemon then + if not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.Pokemon) then + self.PanelLock.gameObject:SetActiveEx(true) + self.TxtLock.text = XFunctionManager.GetFunctionOpenCondition(XFunctionManager.FunctionName.Pokemon) + else + self.PanelLock.gameObject:SetActiveEx(false) + end + else + self.PanelLock.gameObject:SetActiveEx(false) + end +end + +function XUiGridActivityBanner:RefreshChessPursuit(chapter, uiRoot) + local time = XTime.GetServerNowTimestamp() + local beginTime = XChessPursuitConfig.GetActivityBeginTime() + local endTime = XChessPursuitConfig.GetActivityEndTime() + local config = XChessPursuitConfig.GetChessPursuitInTimeMapGroup() + + self.TxtName.text = config.ActivityName + self.PanelActivityTag.gameObject:SetActiveEx(true) + self.RImgIcon:SetRawImage(config.EntryTexture) + self.PanelLock.gameObject:SetActiveEx(false) + + self.TxtConsumeCount.text = config.Name + + local now = XTime.GetServerNowTimestamp() + if beginTime and endTime and now >= beginTime and now <= endTime then + self:CreateCommonActivityTimer(beginTime, endTime, endTime, function() + uiRoot:SetupDynamicTable() + end, chapter) + else + self.PanelLeftTime.gameObject:SetActiveEx(false) + end + + XRedPointManager.CheckOnce(self.OnCheckRedPoint, self, { XRedPointConditions.Types.CONDITION_CHESSPURSUIT_REWARD_RED }) + + if XFunctionManager.FunctionName.ChessPursuitMain then + if not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.ChessPursuitMain) then + self.PanelLock.gameObject:SetActiveEx(true) + self.TxtLock.text = XFunctionManager.GetFunctionOpenCondition(XFunctionManager.FunctionName.ChessPursuitMain) + else + self.PanelLock.gameObject:SetActiveEx(false) + end + else + self.PanelLock.gameObject:SetActiveEx(false) + end +end + +-- 模拟作战入口 +function XUiGridActivityBanner:RefreshSimulatedCombatBanner(chapter, uiRoot) + self.TxtName.text = chapter.Name + self.RImgIcon:SetRawImage(chapter.Icon) + self.PanelActivityTag.gameObject:SetActiveEx(true) + self.TxtConsumeCount.gameObject:SetActiveEx(true) + + local activityEnd, notStart = XDataCenter.FubenSimulatedCombatManager.GetIsActivityEnd() + + if not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.FubenSimulatedCombat) then + self.PanelLock.gameObject:SetActiveEx(true) + self.TxtLock.text = XFunctionManager.GetFunctionOpenCondition(XFunctionManager.FunctionName.FubenSimulatedCombat) + else + self.PanelLock.gameObject:SetActiveEx(false) + end + if activityEnd then + self.PanelLock.gameObject:SetActiveEx(true) + self.PanelLeftTime.gameObject:SetActiveEx(false) + if notStart then + self.TxtLock.text = CS.XTextManager.GetText("ActivityBranchNotOpen") + self.TxtConsumeCount.text = CS.XTextManager.GetText("ActivityBranchNotOpen") + else + self.TxtLock.text = CS.XTextManager.GetText("ActivityBranchOver") + self.TxtConsumeCount.text = CS.XTextManager.GetText("ActivityBranchOver") + end + return + end + + -- 模拟作战红点接入 + XRedPointManager.CheckOnce(self.OnCheckRedPoint, self, { XRedPointConditions.Types.CONDITION_SIMULATED_COMBAT }) + + local startTimeSecond = XDataCenter.FubenSimulatedCombatManager.GetStartTime() + local endTimeSecond = XDataCenter.FubenSimulatedCombatManager.GetEndTime() + local now = XTime.GetServerNowTimestamp() + if startTimeSecond and endTimeSecond and now >= startTimeSecond and now <= endTimeSecond then + self:CreateCommonTimer(startTimeSecond, endTimeSecond, function() + uiRoot:SetupDynamicTable() + end) + else + self.PanelLeftTime.gameObject:SetActiveEx(false) + end + local cur, count = XDataCenter.FubenSimulatedCombatManager.GetStageSchedule() + self.TxtConsumeCount.text = CS.XTextManager.GetText("SimulatedCombatProgressStr", cur, count) + self.TxtConsumeCount.gameObject:SetActiveEx(true) +end + +function XUiGridActivityBanner:RefreshSpringFestivalBanner(chapter, uiRoot) + self.TxtName.text = XSpringFestivalActivityConfigs.GetSpringFestivalActivityName() + self.PanelActivityTag.gameObject:SetActiveEx(true) + self.RImgIcon:SetRawImage(chapter.BannerBg) + self.TxtConsumeCount.gameObject:SetActiveEx(false) + local startTimeSecond = XDataCenter.SpringFestivalActivityManager.GetActivityStartTime() + local endTimeSecond = XDataCenter.SpringFestivalActivityManager.GetActivityEndTime() + local now = XTime.GetServerNowTimestamp() + if startTimeSecond and endTimeSecond and now >= startTimeSecond and now <= endTimeSecond then + self:CreateCommonTimer(startTimeSecond, endTimeSecond, function() + uiRoot:SetupDynamicTable() + end) + else + self.PanelLeftTime.gameObject:SetActiveEx(false) + end + + if not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.SpringFestivalActivity) then + self.PanelLock.gameObject:SetActiveEx(true) + self.TxtLock.text = XFunctionManager.GetFunctionOpenCondition(XFunctionManager.FunctionName.SpringFestivalActivity) + else + self.PanelLock.gameObject:SetActiveEx(false) + end +end + +function XUiGridActivityBanner:RefreshMoeWarBanner(chapter, uiRoot) + self.TxtName.text = chapter.Name + self.PanelActivityTag.gameObject:SetActiveEx(true) + self.RImgIcon:SetRawImage(chapter.Background) + self.TxtConsumeCount.gameObject:SetActiveEx(false) + local startTimeSecond = XDataCenter.MoeWarManager.GetActivityStartTime() + local endTimeSecond = XDataCenter.MoeWarManager.GetActivityEndTime() + local now = XTime.GetServerNowTimestamp() + if startTimeSecond and endTimeSecond and now >= startTimeSecond and now <= endTimeSecond then + self:CreateCommonTimer(startTimeSecond, endTimeSecond, function() + uiRoot:SetupDynamicTable() + end) + else + self.PanelLeftTime.gameObject:SetActiveEx(false) + end + + if not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.MoeWar) then + self.PanelLock.gameObject:SetActiveEx(true) + self.TxtLock.text = XFunctionManager.GetFunctionOpenCondition(XFunctionManager.FunctionName.MoeWar) + else + self.PanelLock.gameObject:SetActiveEx(false) + end +end + +function XUiGridActivityBanner:RefreshReformBanner(chapterData, uiRoot) + self.PanelActivityTag.gameObject:SetActiveEx(true) + if not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.Reform) then + self.PanelLock.gameObject:SetActiveEx(true) + self.TxtLock.text = XFunctionManager.GetFunctionOpenCondition(XFunctionManager.FunctionName.Reform) + else + self.PanelLock.gameObject:SetActiveEx(false) + end + self.TxtName.text = chapterData.Name + self.RImgIcon:SetRawImage(chapterData.Icon) + -- 刷新时间 + local startTimeSecond = XDataCenter.ReformActivityManager.GetActivityStartTime() + local endTimeSecond = XDataCenter.ReformActivityManager.GetActivityEndTime() + local now = XTime.GetServerNowTimestamp() + if startTimeSecond and endTimeSecond and now >= startTimeSecond and now <= endTimeSecond then + self:CreateCommonTimer(startTimeSecond, endTimeSecond, function() + uiRoot:SetupDynamicTable() + end) + else + self.PanelLeftTime.gameObject:SetActiveEx(false) + end + -- 进度 + self.TxtConsumeCount.text = "完成进度: " .. XDataCenter.ReformActivityManager.GetCurrentProgress() .. "/" .. XDataCenter.ReformActivityManager.GetMaxProgress() + -- 检查小红点 + XRedPointManager.CheckOnce(self.OnCheckRedPoint, self, { XRedPointConditions.Types.CONDITION_REFORM_All_RED_POINT }) +end + +function XUiGridActivityBanner:RefreshPokerGuessingBanner(chapterData, uiRoot) + self.TxtName.text = chapterData.Name + self.PanelActivityTag.gameObject:SetActiveEx(true) + self.RImgIcon:SetRawImage(chapterData.BannerBg) + self.TxtConsumeCount.gameObject:SetActiveEx(false) + local startTimeSecond = XDataCenter.PokerGuessingManager.GetStartTime() + local endTimeSecond = XDataCenter.PokerGuessingManager.GetEndTime() + local now = XTime.GetServerNowTimestamp() + if startTimeSecond and endTimeSecond and now >= startTimeSecond and now <= endTimeSecond then + self:CreateCommonTimer(startTimeSecond, endTimeSecond, function() + uiRoot:SetupDynamicTable() + end) + else + self.PanelLeftTime.gameObject:SetActiveEx(false) + end + + if not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.PokerGuessing) then + self.PanelLock.gameObject:SetActiveEx(true) + self.TxtLock.text = XFunctionManager.GetFunctionOpenCondition(XFunctionManager.FunctionName.PokerGuessing) + else + self.PanelLock.gameObject:SetActiveEx(false) + end + XRedPointManager.CheckOnce(self.OnCheckRedPoint, self, { XRedPointConditions.Types.CONDITION_POKER_GUESSING_RED }) +end + +--骇入玩法 +function XUiGridActivityBanner:RefreshHackBanner(chapter, uiRoot) + self.TxtName.text = chapter.Name + self.RImgIcon:SetRawImage(chapter.Icon) + self.PanelActivityTag.gameObject:SetActiveEx(true) + self.TxtConsumeCount.gameObject:SetActiveEx(true) + + if not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.FubenHack) then + self.PanelLock.gameObject:SetActiveEx(true) + self.TxtLock.text = XFunctionManager.GetFunctionOpenCondition(XFunctionManager.FunctionName.FubenHack) + else + self.PanelLock.gameObject:SetActiveEx(false) + end + + XRedPointManager.CheckOnce(self.OnCheckRedPoint, self, { XRedPointConditions.Types.CONDITION_FUBEN_HACK_STAR, XRedPointConditions.Types.CONDITION_FUBEN_HACK_BUFF }) + + local cur, count = XDataCenter.FubenHackManager.GetStageSchedule() + self.TxtConsumeCount.text = CS.XTextManager.GetText("ActivityBossSingleProcess", cur, count) + + local startTimeSecond = XDataCenter.FubenHackManager.GetStartTime() + local endTimeSecond = XDataCenter.FubenHackManager.GetCurChapterEndTime() + local now = XTime.GetServerNowTimestamp() + if startTimeSecond and endTimeSecond and now >= startTimeSecond and now <= endTimeSecond then + self:CreateCommonTimer(startTimeSecond, endTimeSecond, function() + uiRoot:SetupDynamicTable() + end) + else + self.PanelLeftTime.gameObject:SetActiveEx(false) + end +end + +--双人下场玩法 +function XUiGridActivityBanner:RefreshCoupleCombatBanner(chapter, uiRoot) + self.TxtName.text = chapter.Name + self.RImgIcon:SetRawImage(chapter.Icon) + self.PanelActivityTag.gameObject:SetActiveEx(true) + self.TxtConsumeCount.gameObject:SetActiveEx(true) + + if not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.FubenCoupleCombat) then + self.PanelLock.gameObject:SetActiveEx(true) + self.TxtLock.text = XFunctionManager.GetFunctionOpenCondition(XFunctionManager.FunctionName.FubenCoupleCombat) + else + self.PanelLock.gameObject:SetActiveEx(false) + end + + XRedPointManager.CheckOnce(self.OnCheckRedPoint, self, { XRedPointConditions.Types.CONDITION_COUPLE_COMBAT_NORMAL ,XRedPointConditions.Types.CONDITION_COUPLE_COMBAT_HARD}) + + local cur, count = XDataCenter.FubenCoupleCombatManager.GetStageSchedule() + self.TxtConsumeCount.text = CS.XTextManager.GetText("ActivityBossSingleProcess", cur, count) + + local startTimeSecond = XDataCenter.FubenCoupleCombatManager.GetStartTime() + local endTimeSecond = XDataCenter.FubenCoupleCombatManager.GetEndTime() + local now = XTime.GetServerNowTimestamp() + if startTimeSecond and endTimeSecond and now >= startTimeSecond and now <= endTimeSecond then + self:CreateCommonTimer(startTimeSecond, endTimeSecond, function() + uiRoot:SetupDynamicTable() + end) + else + self.PanelLeftTime.gameObject:SetActiveEx(false) + end +end + +-- 系列涂装剧情活动 +function XUiGridActivityBanner:RefreshFashionStory(chapter, uiRoot) + self.TxtName.text = chapter.Name + self.RImgIcon:SetRawImage(chapter.Icon) + + self.PanelActivityTag.gameObject:SetActiveEx(true) + self.TxtConsumeCount.gameObject:SetActiveEx(false) + + local startTimeSecond,endTimeSecond = XDataCenter.FashionStoryManager.GetActivityTime(chapter.Id) + local now = XTime.GetServerNowTimestamp() + if startTimeSecond and endTimeSecond and now >= startTimeSecond and now <= endTimeSecond then + self:CreateCommonTimer(startTimeSecond, endTimeSecond, function() + uiRoot:SetupDynamicTable() + end) + else + self.PanelLeftTime.gameObject:SetActiveEx(false) + end + + if not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.FashionStory) then + self.PanelLock.gameObject:SetActiveEx(true) + self.TxtLock.text = XFunctionManager.GetFunctionOpenCondition(XFunctionManager.FunctionName.FashionStory) + else + self.PanelLock.gameObject:SetActiveEx(false) + end + XRedPointManager.CheckOnce(self.OnCheckRedPoint, self, { XRedPointConditions.Types.CONDITION_FASHION_STORY_HAVE_STAGE }, chapter.Id) +end + +--杀戮空间 +function XUiGridActivityBanner:RefreshKillZone(chapter, uiRoot) + self.TxtName.text = chapter.Name + self.RImgIcon:SetRawImage(chapter.BannerBg) + self.PanelActivityTag.gameObject:SetActiveEx(true) + + if not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.KillZone) then + self.PanelLock.gameObject:SetActiveEx(true) + self.TxtLock.text = XFunctionManager.GetFunctionOpenCondition(XFunctionManager.FunctionName.KillZone) + else + self.PanelLock.gameObject:SetActiveEx(false) + end + + local cur, count = XDataCenter.KillZoneManager.GetStageProcess() + self.TxtConsumeCount.text = CS.XTextManager.GetText("KillZoneProcess", cur, count) + self.TxtConsumeCount.gameObject:SetActiveEx(true) + + local startTimeSecond = XDataCenter.KillZoneManager.GetStartTime() + local endTimeSecond = XDataCenter.KillZoneManager.GetEndTime() + local now = XTime.GetServerNowTimestamp() + if startTimeSecond and endTimeSecond and now >= startTimeSecond and now <= endTimeSecond then + self:CreateCommonTimer(startTimeSecond, endTimeSecond, function() + uiRoot:SetupDynamicTable() + end) + else + self.PanelLeftTime.gameObject:SetActiveEx(false) + end + + XRedPointManager.CheckOnce(self.OnCheckRedPoint, self, { XRedPointConditions.Types.XRedPointConditionKillZoneActivity }) +end + +function XUiGridActivityBanner:CreateCommonActivityTimer(startTime, figthEndTime, activityEndTime, endCb, chapter) + local time = XTime.GetServerNowTimestamp() + local fightStr + if chapter and chapter.Type == XDataCenter.FubenManager.ChapterType.ChessPursuit then + local config = XChessPursuitConfig.GetChessPursuitInTimeMapGroup() + if XChessPursuitConfig.GetStageTypeByGroupId(config.Id) == XChessPursuitCtrl.MAIN_UI_TYPE.STABLE then + fightStr = CsXTextManager.GetText("ChessPursuitStableTimeDesc") + else + fightStr = CsXTextManager.GetText("ChessPursuitFightTimeDesc") + end + else + fightStr = CsXTextManager.GetText("ActivityBranchFightLeftTime") + end + + local activityStr = CsXTextManager.GetText("BabelTowerActivityTimeLeft") + self:StopCommonTimer() + self.PanelLeftTime.gameObject:SetActiveEx(true) + if time <= figthEndTime then + self.TxtLeftTime.text = string.format("%s%s", fightStr, XUiHelper.GetTime(figthEndTime - time, XUiHelper.TimeFormatType.ACTIVITY)) + else + self.TxtLeftTime.text = string.format("%s%s", activityStr, XUiHelper.GetTime(activityEndTime - time, XUiHelper.TimeFormatType.ACTIVITY)) + end + + self.CommonTimer = XScheduleManager.ScheduleForever(function() + time = XTime.GetServerNowTimestamp() + if time > activityEndTime or time < startTime then + self:StopCommonTimer() + if endCb then + endCb() + end + return + end + if time <= figthEndTime then + self.TxtLeftTime.text = string.format("%s%s", fightStr, XUiHelper.GetTime(figthEndTime - time, XUiHelper.TimeFormatType.ACTIVITY)) + else + self.TxtLeftTime.text = string.format("%s%s", activityStr, XUiHelper.GetTime(activityEndTime - time, XUiHelper.TimeFormatType.ACTIVITY)) + end + end, XScheduleManager.SECOND, 0) +end + +function XUiGridActivityBanner:CreateCommonTimer(startTime, endTime, endCb, customStr) + local time = XTime.GetServerNowTimestamp() + local fightStr = customStr or CsXTextManager.GetText("ActivityBranchFightLeftTime") + self.TxtLeftTime.text = string.format("%s%s", fightStr, XUiHelper.GetTime(endTime - time, XUiHelper.TimeFormatType.ACTIVITY)) + self:StopCommonTimer() + self.PanelLeftTime.gameObject:SetActiveEx(true) + self.CommonTimer = XScheduleManager.ScheduleForever(function() + time = XTime.GetServerNowTimestamp() + if time > endTime then + self:StopCommonTimer() + if endCb then + endCb() + end + return + end + self.TxtLeftTime.text = string.format("%s%s", fightStr, XUiHelper.GetTime(endTime - time, XUiHelper.TimeFormatType.ACTIVITY)) + end, XScheduleManager.SECOND, 0) +end + +function XUiGridActivityBanner:StopCommonTimer() + if self.CommonTimer then + XScheduleManager.UnSchedule(self.CommonTimer) + self.CommonTimer = nil + end +end + +function XUiGridActivityBanner:CreateActivityTimer(fightEndTime, activityEndTime, endCb) + local time = XTime.GetServerNowTimestamp() + if time > activityEndTime then + return + end + + self:DestroyActivityTimer() + + local shopStr = CsXTextManager.GetText("ActivityBranchShopLeftTime") + local fightStr = CsXTextManager.GetText("ActivityBranchFightLeftTime") + + if fightEndTime <= time and time < activityEndTime then + self.TxtLeftTime.text = shopStr .. XUiHelper.GetTime(activityEndTime - time, XUiHelper.TimeFormatType.ACTIVITY) + else + self.TxtLeftTime.text = fightStr .. XUiHelper.GetTime(fightEndTime - time, XUiHelper.TimeFormatType.ACTIVITY) + end + + self.PanelLeftTime.gameObject:SetActiveEx(true) + self.ActivityTimer = XScheduleManager.ScheduleForever(function() + if XTool.UObjIsNil(self.TxtLeftTime) then + self:DestroyActivityTimer() + return + end + + time = time + 1 + + if fightEndTime <= time and time <= activityEndTime then + local leftTime = activityEndTime - time + if leftTime > 0 then + self.TxtLeftTime.text = shopStr .. XUiHelper.GetTime(leftTime, XUiHelper.TimeFormatType.ACTIVITY) + else + self:DestroyActivityTimer() + if endCb then + endCb() + end + end + else + local leftTime = fightEndTime - time + if leftTime > 0 then + self.TxtLeftTime.text = fightStr .. XUiHelper.GetTime(leftTime, XUiHelper.TimeFormatType.ACTIVITY) + else + self:DestroyActivityTimer() + self:CreateActivityTimer(fightEndTime, activityEndTime, endCb) + end + end + end, XScheduleManager.SECOND, 0) +end + +function XUiGridActivityBanner:DestroyActivityTimer() + if self.ActivityTimer then + XScheduleManager.UnSchedule(self.ActivityTimer) + self.ActivityTimer = nil + end +end + +function XUiGridActivityBanner:ReSetActivityBanner() + self.PanelSlide.gameObject:SetActiveEx(false) + self.TxtConsumeCount.gameObject:SetActiveEx(true) + if self.Red then + self.Red.gameObject:SetActiveEx(false) + end +end + +function XUiGridActivityBanner:SetActiveEx(active) + self.GameObject:SetActiveEx(active) +end + +return XUiGridActivityBanner \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenActivityPuzzle/XUiFubenActivityPuzzle.lua b/Resources/Scripts/XUi/XUiFubenActivityPuzzle/XUiFubenActivityPuzzle.lua new file mode 100644 index 00000000..3339ed62 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenActivityPuzzle/XUiFubenActivityPuzzle.lua @@ -0,0 +1,237 @@ +local tableInsert = table.insert +local CSXTextManagerGetText = CS.XTextManager.GetText + +local XUiFubenActivityPuzzle = XLuaUiManager.Register(XLuaUi, "UiFubenActivityPuzzle") + +local XUiFubenActivityPuzzleRewardPanel = require("XUi/XUiFubenActivityPuzzle/XUiFubenActivityPuzzleRewardPanel") +local XUiFubenActivityPuzzleGamePanel = require("XUi/XUiFubenActivityPuzzle/XUiFubenActivityPuzzleGamePanel") +local XUiFubenActivityPuzzlePasswordRewardPanel = require("XUi/XUiFubenActivityPuzzle/XUiFubenActivityPuzzlePasswordRewardPanel") + +function XUiFubenActivityPuzzle:OnAwake() + self.PanelReward = XUiFubenActivityPuzzleRewardPanel.New(self, self.LeftAwardPanel) + self.PanelGame = XUiFubenActivityPuzzleGamePanel.New(self, self.GamePanel) + self.PanelPasswordReward = XUiFubenActivityPuzzlePasswordRewardPanel.New(self, self.LeftAwardPassWordPanel) +end + +function XUiFubenActivityPuzzle:OnStart() + self.RedPointIdArr = {} + self:AutoRegisterBtn() + self.AssetPanel = XUiPanelActivityAsset.New(self.PanelAsset, true) + self.AssetPanel:Refresh({ XDataCenter.FubenActivityPuzzleManager.GetActivityInfo().ItemId }) + self:InitBtnGroup() +end + +function XUiFubenActivityPuzzle:OnEnable() + self:RefreshBtnTab() + self:StartActivityTimer() + local defaultTabIndex = XDataCenter.FubenActivityPuzzleManager.FindDefaultSelectTabIndex() + self.isEnable = true + self.PanelTab:SelectIndex(defaultTabIndex) + self.CurrentSelectIndex = defaultTabIndex + self:CheckHelpHitFace() +end + +function XUiFubenActivityPuzzle:OnDisable() + self:StopActivityTimer() +end + +function XUiFubenActivityPuzzle:OnDestroy() + self:RemoveRedPointEvent() +end + +function XUiFubenActivityPuzzle:OnGetEvents() + return { + XEventId.EVENT_DRAG_PUZZLE_GAME_GET_PIECE, + XEventId.EVENT_DRAG_PUZZLE_GAME_PUZZLE_CHANGED, + XEventId.EVENT_DRAG_PUZZLE_GAME_GOT_REWARD, + XEventId.EVENT_DRAG_PUZZLE_GAME_PUZZLE_COMPLETE, + XEventId.EVENT_DRAG_PUZZLE_GAME_PUZZLE_DECRYPTION, + XEventId.EVENT_DRAG_PUZZLE_GAME_PUZZLE_CHECK_WORD_ERROR, + } +end + +function XUiFubenActivityPuzzle:OnNotify(evt, ...) + local puzzleTemplate = XDataCenter.FubenActivityPuzzleManager.GetPuzzleTemplateByIndex(self.CurrentSelectIndex) + if evt == XEventId.EVENT_DRAG_PUZZLE_GAME_GET_PIECE then + self.AssetPanel:Refresh({ XDataCenter.FubenActivityPuzzleManager.GetActivityInfo().ItemId }) + self.PanelGame:RefreshChipPanel(...) + self.PanelGame:ShowSwitchPieceEffect() + elseif evt == XEventId.EVENT_DRAG_PUZZLE_GAME_PUZZLE_CHANGED then + self.PanelGame:RefreshPuzzlePanel(...) + self:RefreshLeftPanelByPuzzleType(puzzleTemplate.PuzzleType, ...) + elseif evt == XEventId.EVENT_DRAG_PUZZLE_GAME_GOT_REWARD then + self.PanelGame:RefreshPanel(...) + self:RefreshLeftPanelByPuzzleType(puzzleTemplate.PuzzleType, ...) + self:PlayVideoBtnAnimation(...) + elseif evt == XEventId.EVENT_DRAG_PUZZLE_GAME_PUZZLE_COMPLETE then + self:SetTabDisable() + XRedPointManager.Check(self.PanelGame.RedPointId) + self.PanelGame:SetComplete() + self.PanelGame:ShowPuzzleCompleteEffect() + self:RefreshLeftPanelByPuzzleType(puzzleTemplate.PuzzleType, ...) + self:PlayAnimation("Line") + self:ShowCompleteHintText(...) + if puzzleTemplate.PuzzleType == XFubenActivityPuzzleConfigs.PuzzleType.Decryption then + self:PlayAnimation("BgQieHuan", function () + self.PanelGame.PuzzleImgBigPassword.gameObject:SetActiveEx(false) + end, function () + self.PanelGame.PuzzleImgBigPassword.gameObject:SetActiveEx(true) + end) + end + elseif evt == XEventId.EVENT_DRAG_PUZZLE_GAME_PUZZLE_DECRYPTION then + self.PanelGame:SetDecryption() + self:RefreshLeftPanelByPuzzleType(puzzleTemplate.PuzzleType, ...) + XUiManager.TipText("DragPuzzleActivityTryDercyption") + elseif evt == XEventId.EVENT_DRAG_PUZZLE_GAME_PUZZLE_CHECK_WORD_ERROR then + self:RefreshLeftPanelByPuzzleType(puzzleTemplate.PuzzleType, ...) + end +end + +function XUiFubenActivityPuzzle:AutoRegisterBtn() + self.BtnBack.CallBack = function () self:Close() end + self.BtnMainUi.CallBack = function () + XLuaUiManager.RunMain() + end + self:RegisterHelpBtn() +end + +function XUiFubenActivityPuzzle:RegisterHelpBtn() + local helpId = XDataCenter.FubenActivityPuzzleManager.GetActivityInfo().HelpId + local template = XHelpCourseConfig.GetHelpCourseTemplateById(helpId) + self:BindHelpBtn(self.BtnHelp, template.Function) +end + +function XUiFubenActivityPuzzle:InitBtnGroup() + local tmpBtnTabs = {self.BtnTab1, self.BtnTab2, self.BtnTab3, self.BtnTab4,} + self.BtnTabs = {} + local puzzleTemplates = XDataCenter.FubenActivityPuzzleManager.GetPuzzleTemplates() + for i=1, #tmpBtnTabs, 1 do + if i <= #puzzleTemplates then + tmpBtnTabs[i].gameObject:SetActiveEx(true) + tableInsert(self.BtnTabs, tmpBtnTabs[i]) + local redPointId = XRedPointManager.AddRedPointEvent(tmpBtnTabs[i].ReddotObj, nil, nil, {XRedPointConditions.Types.CONDITION_DRAG_PUZZLE_GAME_TAB}, i, true) + tableInsert(self.RedPointIdArr, redPointId) + else + tmpBtnTabs[i].gameObject:SetActiveEx(false) + end + end + self.PanelTab:Init(self.BtnTabs, function (index) self:OnBtnTabClick(index) end) +end + +function XUiFubenActivityPuzzle:OnBtnTabClick(index) + if XDataCenter.FubenActivityPuzzleManager.CheckPuzzleIsOpen(index) then + local puzzleTemplate = XDataCenter.FubenActivityPuzzleManager.GetPuzzleTemplateByIndex(index) + self:PlayAnimation("Refresh") + local puzzleId = XDataCenter.FubenActivityPuzzleManager.GetPuzzleTemplateByIndex(index).Id + self:RefreshLeftPanelByPuzzleType(puzzleTemplate.PuzzleType, puzzleId) + self.PanelGame:RefreshPanel(puzzleId) + if self.isEnable then + self.CGImage:SetRawImage(puzzleTemplate.BgUrl) + self.isEnable = false + else + self:PlayAnimation("Bgloading1", function () + -- 切换背景 + self.CGImage:SetRawImage(puzzleTemplate.BgUrl) + self:PlayAnimation("Bgloading2") + end) + end + self.CurrentSelectIndex = index + else + XUiManager.TipError(CSXTextManagerGetText("DragPuzzleActivityPuzzleNotOpen")) + end +end + +function XUiFubenActivityPuzzle:RefreshBtnTab() + local puzzleTemplates = XDataCenter.FubenActivityPuzzleManager.GetPuzzleTemplates() + for index, btnTab in pairs(self.BtnTabs) do + btnTab:SetNameByGroup(0, string.format("%02d", index)) + btnTab:SetNameByGroup(1, puzzleTemplates[index].SubName) + btnTab:SetNameByGroup(2, puzzleTemplates[index].Name) + end + self:SetTabDisable() +end + +function XUiFubenActivityPuzzle:SetTabDisable() + for index, btnTab in pairs(self.BtnTabs) do + local isOpen = XDataCenter.FubenActivityPuzzleManager.CheckPuzzleIsOpen(index) + btnTab:SetDisable(not isOpen) + end + if self.CurrentSelectIndex and self.CurrentSelectIndex ~= 0 then + self.PanelTab:SelectIndex(self.CurrentSelectIndex) + end +end + +function XUiFubenActivityPuzzle:ShowCompleteHintText(puzzleId) + local puzzleTemplate = XFubenActivityPuzzleConfigs.GetPuzzleTemplateById(puzzleId) + if puzzleTemplate then + if puzzleTemplate.CompleteHintText and puzzleTemplate.CompleteHintText ~= "" then + XUiManager.TipMsg(puzzleTemplate.CompleteHintText) + end + end +end + +function XUiFubenActivityPuzzle:PlayVideoBtnAnimation(...) + local gotCompleteRewardState = XDataCenter.FubenActivityPuzzleManager.CheckCompleteRewardIsGot(...) + local isGotCompleteReward = gotCompleteRewardState == XFubenActivityPuzzleConfigs.CompleteRewardState.Rewarded + if isGotCompleteReward then self:PlayAnimation("PlayVideoBtnGroupEnable") end +end + +function XUiFubenActivityPuzzle:RefreshLeftPanelByPuzzleType(puzzleType, puzzleId) + self.PanelReward:SetActiveEx(puzzleType == XFubenActivityPuzzleConfigs.PuzzleType.Define) + self.PanelPasswordReward:SetActiveEx(puzzleType == XFubenActivityPuzzleConfigs.PuzzleType.Decryption) + + if puzzleType == XFubenActivityPuzzleConfigs.PuzzleType.Define then + self.PanelReward:RefreshPanel(puzzleId) + elseif puzzleType == XFubenActivityPuzzleConfigs.PuzzleType.Decryption then + self.PanelPasswordReward:RefreshPanel(puzzleId) + end +end + +function XUiFubenActivityPuzzle:CheckHelpHitFace() + local helpId = XDataCenter.FubenActivityPuzzleManager.GetActivityInfo().HelpId + local helpTemplate = XHelpCourseConfig.GetHelpCourseTemplateById(helpId) + local key = XFubenActivityPuzzleConfigs.HELP_HIT_FACE_KEY..helpId..XPlayer.Id + local hitFaceData = XSaveTool.GetData(key) + if not hitFaceData or hitFaceData == XFubenActivityPuzzleConfigs.HelpHitFaceState.UnHit then + XUiManager.ShowHelpTip(helpTemplate.Function) + XSaveTool.SaveData(key, XFubenActivityPuzzleConfigs.HelpHitFaceState.Hited) + end +end + +function XUiFubenActivityPuzzle:StartActivityTimer() + local timeId = XDataCenter.FubenActivityPuzzleManager.GetActivityInfo().TimeId + local startTime, endTime = XFunctionManager.GetTimeByTimeId(timeId) + local nowTime = XTime.GetServerNowTimestamp() + self.TxtDay.text = XUiHelper.GetTime(endTime - nowTime, XUiHelper.TimeFormatType.ACTIVITY) + if nowTime < startTime then + XUiManager.TipText("DragPuzzleActivityNotOpen") + self:Close() + elseif nowTime > endTime then + XUiManager.TipText("DragPuzzleActivityEnd") + self:Close() + else + self.ActivityTimer = XScheduleManager.ScheduleForever(function() + local time = XTime.GetServerNowTimestamp() + if time > endTime then + XLuaUiManager.RunMain() + XUiManager.TipError(CS.XTextManager.GetText("DragPuzzleActivityEnd")) + self:StopActivityTimer() + return + end + self.TxtDay.text = XUiHelper.GetTime(endTime - time, XUiHelper.TimeFormatType.ACTIVITY) + end, XScheduleManager.SECOND, 0) + end +end + +function XUiFubenActivityPuzzle:StopActivityTimer() + if self.ActivityTimer then + XScheduleManager.UnSchedule(self.ActivityTimer) + self.ActivityTimer = nil + end +end + +function XUiFubenActivityPuzzle:RemoveRedPointEvent() + for _, redPointId in ipairs(self.RedPointIdArr) do + XRedPointManager.RemoveRedPointEvent(redPointId) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenActivityPuzzle/XUiFubenActivityPuzzleAreaRewardBtn.lua b/Resources/Scripts/XUi/XUiFubenActivityPuzzle/XUiFubenActivityPuzzleAreaRewardBtn.lua new file mode 100644 index 00000000..1f4d7485 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenActivityPuzzle/XUiFubenActivityPuzzleAreaRewardBtn.lua @@ -0,0 +1,41 @@ +local tableInsert = table.insert + +local XUiFubenActivityPuzzleAreaRewardBtn = XClass(nil, "XUiFubenActivityPuzzleAreaRewardBtn") + +function XUiFubenActivityPuzzleAreaRewardBtn:Ctor(rootUi, ui, cb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + + self.CallBack = cb + self:Init() +end + +function XUiFubenActivityPuzzleAreaRewardBtn:Init() + CsXUiHelper.RegisterClickEvent(self.BtnArea, self.CallBack) +end + +function XUiFubenActivityPuzzleAreaRewardBtn:Refresh(itemIcon, count) + self.Image1:SetRawImage(itemIcon) + self.Image2:SetRawImage(itemIcon) + self.TxtCount1.text = string.format("%s%s", "x", count) + self.TxtCount2.text = string.format("%s%s", "x", count) +end + +function XUiFubenActivityPuzzleAreaRewardBtn:SetNormal() + self.LightAward.gameObject:SetActiveEx(false) + self.GetAward.gameObject:SetActiveEx(false) +end + +function XUiFubenActivityPuzzleAreaRewardBtn:SetCanTake() + self.LightAward.gameObject:SetActiveEx(true) + self.GetAward.gameObject:SetActiveEx(false) +end + +function XUiFubenActivityPuzzleAreaRewardBtn:SetTaked() + self.LightAward.gameObject:SetActiveEx(false) + self.GetAward.gameObject:SetActiveEx(true) +end + +return XUiFubenActivityPuzzleAreaRewardBtn \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenActivityPuzzle/XUiFubenActivityPuzzleGamePanel.lua b/Resources/Scripts/XUi/XUiFubenActivityPuzzle/XUiFubenActivityPuzzleGamePanel.lua new file mode 100644 index 00000000..68ab76bb --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenActivityPuzzle/XUiFubenActivityPuzzleGamePanel.lua @@ -0,0 +1,358 @@ +local tableInsert = table.insert +local CSXTextManagerGetText = CS.XTextManager.GetText + +local XUiFubenActivityPuzzleGamePanel = XClass(nil, "XUiFubenActivityPuzzleGamePanel") +local XUiFubenActivityPuzzlePieceItem = require("XUi/XUiFubenActivityPuzzle/XUiFubenActivityPuzzlePieceItem") + +local Empty_Index = -1 + +function XUiFubenActivityPuzzleGamePanel:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RectTransform = ui + self.RootUi = rootUi + XTool.InitUiObject(self) + + self:Init() +end + +function XUiFubenActivityPuzzleGamePanel:Init() + self.LongClicks = {} + self:AutoRegisterListener() + self:InitBlock() + self.Camera = CS.XUiManager.Instance.UiCamera + self.LongClicks[Empty_Index] = XUiButtonLongClick.New(self.PuzzleChipPointer, 5, self, nil, function () self:OnPuzzleChipDrag(Empty_Index) end, function () self:OnPuzzleChipUp() end, false) + local DragItemRectTransform = self.PuzzleChipDragItem.transform:GetComponent("RectTransform") + self.PieceMoveLimitX = (self.RectTransform.rect.width - DragItemRectTransform.rect.width)/2 + self.PieceMoveLimitY = (self.RectTransform.rect.height - DragItemRectTransform.rect.height)/2 + + self.RedPointId = XRedPointManager.AddRedPointEvent(self.BtnSwitch, self.OnCheckSwitchRedPoint, self, { XRedPointConditions.Types.CONDITION_DRAG_PUZZLE_GAME_SWITCH }, nil, true) + self.RedPointVideoId = XRedPointManager.AddRedPointEvent(self.PlayVideoBtn, self.OnCheckVideoRedPoint, self, { XRedPointConditions.Types.CONDITION_DRAG_PUZZLE_GAME_VIDEO }, nil, false) +end + +function XUiFubenActivityPuzzleGamePanel:OnCheckSwitchRedPoint(count) + if count < 0 then + self.BtnSwitch:ShowReddot(false) + return + end + + self.BtnSwitch:ShowReddot(self.PuzzleId and XDataCenter.FubenActivityPuzzleManager.CheckHasSwitchRedPointById(self.PuzzleId)) +end + +function XUiFubenActivityPuzzleGamePanel:OnCheckVideoRedPoint(count) + self.PlayVideoBtn:ShowReddot(count >= 0) +end + +function XUiFubenActivityPuzzleGamePanel:AutoRegisterListener() + self.BtnSwitch.CallBack = function () self:OnClickBtnSwitch() end + self.GetBtn.CallBack = function () self:OnClickBtnGetAll() end + self.PlayVideoBtn.CallBack = function () self:OnClickBtnPlayVideo() end +end + +function XUiFubenActivityPuzzleGamePanel:InitBlock() + self.PuzzleBlocks = {} + for i=1, 15, 1 do + self["PuzzleBlock"..i] = XUiFubenActivityPuzzlePieceItem.New(self.RootUi, self["PuzzleImgLocation"..i]) + tableInsert(self.PuzzleBlocks, self["PuzzleBlock"..i]) + end + + for index, block in ipairs(self.PuzzleBlocks) do + local pointer = self.PuzzleBlocks[index].Transform:GetComponent("XUiPointer") + self.LongClicks[index] = XUiButtonLongClick.New(pointer, 5, self, nil, function () self:OnPuzzleChipDrag(index) end, function () self:OnPuzzleChipUp(true) end, false) + end +end + +function XUiFubenActivityPuzzleGamePanel:RefreshPanel(puzzleId) + self.PuzzleId = puzzleId + self.BtnSwitch:ShowReddot(self.PuzzleId and XDataCenter.FubenActivityPuzzleManager.CheckHasSwitchRedPointById(self.PuzzleId)) -- 刷新转化碎片按钮红点 + self:RefreshChipPanel(puzzleId) + self:RefreshPuzzlePanel(puzzleId) + self.SwitchEffect.gameObject:SetActive(false) -- 隐藏特效 + self.PuzzleCompleteEffect.gameObject:SetActive(false) + XRedPointManager.Check(self.RedPointVideoId, puzzleId) -- 检查剧情红点 +end + +function XUiFubenActivityPuzzleGamePanel:RefreshChipPanel(puzzleId, isOnDrag) + local puzzleTemplate = XFubenActivityPuzzleConfigs.GetPuzzleTemplateById(puzzleId) + local pieceTable = XDataCenter.FubenActivityPuzzleManager.GetPieceTabelById(puzzleId) + self.TxtPieceConsume.text = puzzleTemplate.PieceItemCount + if not pieceTable or #pieceTable <= 0 then + self.PuzzleChipImg.gameObject:SetActiveEx(false) + self.TxtPieceNum.text = "0" + elseif isOnDrag then + if #pieceTable > 1 then + local pieceIcon = XFubenActivityPuzzleConfigs.GetPieceIconById(pieceTable[#pieceTable-1].Id) + self.PuzzleChipImg.gameObject:SetActiveEx(true) + self.PuzzleChipImg:SetRawImage(pieceIcon) + self.TxtPieceNum.text = #pieceTable-1 + else + self.PuzzleChipImg.gameObject:SetActiveEx(false) + self.TxtPieceNum.text = "0" + end + else + local pieceIcon = XFubenActivityPuzzleConfigs.GetPieceIconById(pieceTable[#pieceTable].Id) + self.PuzzleChipImg.gameObject:SetActiveEx(true) + self.PuzzleChipImg:SetRawImage(pieceIcon) + self.TxtPieceNum.text = #pieceTable + end +end + +function XUiFubenActivityPuzzleGamePanel:RefreshPuzzlePanel(puzzleId, targetIndex) + + local puzzleState = XDataCenter.FubenActivityPuzzleManager.GetPuzzleStateById(puzzleId) + if puzzleState == XFubenActivityPuzzleConfigs.PuzzleState.Incomplete then + self:SetInComplete(targetIndex) + elseif puzzleState == XFubenActivityPuzzleConfigs.PuzzleState.Complete then + self:SetComplete() + elseif puzzleState == XFubenActivityPuzzleConfigs.PuzzleState.PuzzleCompleteButNotDecryption then + self:SetDecryption() + end +end + +function XUiFubenActivityPuzzleGamePanel:OnClickBtnSwitch() + XDataCenter.FubenActivityPuzzleManager.ExchangePiece(self.PuzzleId) +end + +function XUiFubenActivityPuzzleGamePanel:OnClickBtnGetAll() + XDataCenter.FubenActivityPuzzleManager.GetReward(self.PuzzleId, 0) +end + +function XUiFubenActivityPuzzleGamePanel:OnClickBtnPlayVideo() + local puzzleTemplate = XFubenActivityPuzzleConfigs.GetPuzzleTemplateById(self.PuzzleId) + local movieId = puzzleTemplate.CompleteStoryId + XDataCenter.MovieManager.PlayMovie(movieId) + XSaveTool.SaveData(string.format("%s%s%s", XPlayer.Id, XFubenActivityPuzzleConfigs.PLAY_VIDEO_STATE_KEY ,self.PuzzleId), XFubenActivityPuzzleConfigs.PlayVideoState.Played) + XEventManager.DispatchEvent(XEventId.EVENT_DRAG_PUZZLE_GAME_PLAYED_VIDEO, self.PuzzleId) +end + +function XUiFubenActivityPuzzleGamePanel:SetInComplete(targetIndex) + local puzzleTemplate = XFubenActivityPuzzleConfigs.GetPuzzleTemplateById(self.PuzzleId) + local allCount = puzzleTemplate.RowSize * puzzleTemplate.ColSize + local pieceTable = XDataCenter.FubenActivityPuzzleManager.GetPuzzlePieceTabelById(self.PuzzleId) + self.PuzzleContent.gameObject:SetActiveEx(true) + self.BtnSwitch:SetDisable(false, true) + self.ArrowImg.gameObject:SetActiveEx(true) + self.PuzzleImgBig.gameObject:SetActiveEx(false) + self.PuzzleImgBigPassword.gameObject:SetActiveEx(false) + self.GetBtn.gameObject:SetActiveEx(false) + self.PlayVideoBtn.gameObject:SetActiveEx(false) + if not pieceTable or XTool.GetTableCount(pieceTable) <= 0 then + self.TxtPuzzleProgress.text = CSXTextManagerGetText("DragPuzzleActivityPuzzleProgress", 0, allCount) + for _, block in pairs(self.PuzzleBlocks) do + block:SetActive(false) + end + else + self.TxtPuzzleProgress.text = CSXTextManagerGetText("DragPuzzleActivityPuzzleProgress", XDataCenter.FubenActivityPuzzleManager.GetPuzzlePieceSuccessCount(self.PuzzleId), allCount) + for index, block in ipairs(self.PuzzleBlocks) do + if pieceTable[index] then + block:SetActive(true) + block:HideCorrectAndMistakeEffect() + local pieceIcon = XFubenActivityPuzzleConfigs.GetPieceIconById(pieceTable[index]) + block:SetRawImage(pieceIcon) + local isCorrect = XDataCenter.FubenActivityPuzzleManager.CheckPieceIsCorrect(self.PuzzleId, index) + block:SetCorrect(isCorrect) + if targetIndex and targetIndex == index then + if isCorrect then block:ShowCorrectEffect() else block:ShowMistakeEffect() end + end + else + block:SetActive(false) + end + end + end +end + +function XUiFubenActivityPuzzleGamePanel:SetComplete() + local puzzleTemplate = XFubenActivityPuzzleConfigs.GetPuzzleTemplateById(self.PuzzleId) + local allCount = puzzleTemplate.RowSize * puzzleTemplate.ColSize + self.PuzzleImgBig:SetRawImage(puzzleTemplate.CompleteImageUrl) + self.PuzzleContent.gameObject:SetActiveEx(false) + self.BtnSwitch:SetDisable(true, false) + self.ArrowImg.gameObject:SetActiveEx(false) + self.PuzzleImgBig.gameObject:SetActiveEx(true) + self.PuzzleImgBigPassword.gameObject:SetActiveEx(false) + local gotCompleteRewardState = XDataCenter.FubenActivityPuzzleManager.CheckCompleteRewardIsGot(self.PuzzleId) + local isGotCompleteReward = gotCompleteRewardState == XFubenActivityPuzzleConfigs.CompleteRewardState.Rewarded + self.GetBtn.gameObject:SetActiveEx(not isGotCompleteReward) + if puzzleTemplate.CompleteStoryId and puzzleTemplate.CompleteStoryId ~= "" then + self.PlayVideoBtn.gameObject:SetActiveEx(isGotCompleteReward) + else + self.PlayVideoBtn.gameObject:SetActiveEx(false) + end + self.TxtPuzzleProgress.text = CSXTextManagerGetText("DragPuzzleActivityPuzzleProgress", XDataCenter.FubenActivityPuzzleManager.GetPuzzlePieceSuccessCount(self.PuzzleId), allCount) +end + +function XUiFubenActivityPuzzleGamePanel:SetDecryption() + local puzzleTemplate = XFubenActivityPuzzleConfigs.GetPuzzleTemplateById(self.PuzzleId) + local allCount = puzzleTemplate.RowSize * puzzleTemplate.ColSize + local decryptionImg = XFubenActivityPuzzleConfigs.GetPuzzleDecryptionImgUrl(self.PuzzleId) + self.PuzzleContent.gameObject:SetActiveEx(false) + self.BtnSwitch:SetDisable(true, false) + self.ArrowImg.gameObject:SetActiveEx(false) + self.PuzzleImgBigPassword.gameObject:SetActiveEx(true) + self.PuzzleImgBig.gameObject:SetActiveEx(false) + self.GetBtn.gameObject:SetActiveEx(false) + self.PlayVideoBtn.gameObject:SetActiveEx(false) + if decryptionImg and decryptionImg ~= "" then + self.PuzzleImgBigPassword:SetRawImage(decryptionImg) + end + self.TxtPuzzleProgress.text = CSXTextManagerGetText("DragPuzzleActivityPuzzleProgress", XDataCenter.FubenActivityPuzzleManager.GetPuzzlePieceSuccessCount(self.PuzzleId), allCount) +end + +function XUiFubenActivityPuzzleGamePanel:OnPuzzleChipDrag(index) -- 拖拽 + if self.LastClickIndex and self.LastClickIndex ~= index then + self.LongClicks[self.LastClickIndex]:Reset() + self:RefreshPanel(self.PuzzleId) + self.LastClickIndex = nil + end + + if not self.DragItem then -- 第一次进入拖拽 没有拖拽的碎片 + if index == Empty_Index then + local hasValue, piece = XDataCenter.FubenActivityPuzzleManager.GetFirstPiece(self.PuzzleId) + if hasValue then + -- 读取所需数据 + self.PuzzlePieceTable = XDataCenter.FubenActivityPuzzleManager.GetPuzzlePieceTabelById(self.PuzzleId) + self.NearestIndex = nil + self:RefreshChipPanel(self.PuzzleId, true)-- 更新碎片列表UI + self.DragItem = self.PuzzleChipDragItem + self.DragItem.gameObject:SetActiveEx(true) + self.DragItem:SetRawImage(XFubenActivityPuzzleConfigs.GetPieceIconById(piece.Id)) + -- 更新位置到鼠标位置 + self.DragItem.gameObject.transform.localPosition = self:GetPisont() + end + else + local pieceId = XDataCenter.FubenActivityPuzzleManager.GetPuzzlePieceByIndex(self.PuzzleId, index) + if pieceId then + if not XDataCenter.FubenActivityPuzzleManager.CheckPieceIsCorrect(self.PuzzleId, index) then + self.CurDragPieceId = pieceId + self.CurDragPieceIdx = index + self.PuzzlePieceTable = XDataCenter.FubenActivityPuzzleManager.GetPuzzlePieceTabelById(self.PuzzleId) + self.NearestIndex = nil + self.PuzzleBlocks[index]:SetActive(false) -- 隐藏该格子碎片 + self.DragItem = self.PuzzleChipDragItem + self.DragItem.gameObject:SetActiveEx(true) + self.DragItem:SetRawImage(XFubenActivityPuzzleConfigs.GetPieceIconById(pieceId)) + self.DragItem.gameObject.transform.localPosition = self:GetPisont() + end + end + end + self.LastClickIndex = index + + else -- 持续更新拖拽的碎片位置 + self.DragItem.gameObject.transform.localPosition = self:GetPisont() + local nearestIndex = 0 + if index == Empty_Index then + nearestIndex = self:CalculateNearestBlockIndex() + else + nearestIndex = self:CalculateNearestBlockIndex(true) + end + if not self.NearestIndex then + self.NearestIndex = nearestIndex + self.PuzzleBlocks[nearestIndex]:SetLight(true) + else + if self.NearestIndex ~= nearestIndex then + self.PuzzleBlocks[self.NearestIndex]:SetLight(false) + self.NearestIndex = nearestIndex + self.PuzzleBlocks[nearestIndex]:SetLight(true) + end + end + end +end + +function XUiFubenActivityPuzzleGamePanel:OnPuzzleChipUp(isChangePiece) -- 抬起 + if not self.NearestIndex then -- 点击抬起过快可能导致NearestIndex为空 + self:RefreshChipPanel(self.PuzzleId) + self:RefreshPuzzlePanel(self.PuzzleId) + if self.DragItem then + self.DragItem.gameObject:SetActiveEx(false) + self.DragItem = nil + self.LastClickIndex = nil + end + return + end + if self.DragItem then + self.DragItem.gameObject:SetActiveEx(false) + self.DragItem = nil + self.LastClickIndex = nil + self.PuzzleBlocks[self.NearestIndex]:SetLight(false) + if isChangePiece then + XDataCenter.FubenActivityPuzzleManager.MovePieceFormPuzzle(self.PuzzleId, self.CurDragPieceId, self.CurDragPieceIdx,self.NearestIndex) + self.CurDragPieceId = nil + self.CurDragPieceIdx = nil + else + XDataCenter.FubenActivityPuzzleManager.MovePieceFormPieceTable(self.PuzzleId, self.NearestIndex) + end + self.NearestIndex = nil + end +end + +function XUiFubenActivityPuzzleGamePanel:GetPisont() + local screenPoint + if CS.UnityEngine.Application.platform == CS.UnityEngine.RuntimePlatform.WindowsEditor or CS.UnityEngine.Application.platform == CS.UnityEngine.RuntimePlatform.WindowsPlayer then + screenPoint = CS.UnityEngine.Vector2(CS.UnityEngine.Input.mousePosition.x, CS.UnityEngine.Input.mousePosition.y) + else + screenPoint = CS.UnityEngine.Input.GetTouch(0).position + end + + -- 设置拖拽 + local hasValue, v2 = CS.UnityEngine.RectTransformUtility.ScreenPointToLocalPointInRectangle(self.RectTransform, screenPoint, self.Camera) + if hasValue then + local x = v2.x + local y = v2.y + if x < -self.PieceMoveLimitX then x = -self.PieceMoveLimitX elseif x > self.PieceMoveLimitX then x = self.PieceMoveLimitX end + if y < -self.PieceMoveLimitY then y = -self.PieceMoveLimitY elseif y > self.PieceMoveLimitY then y = self.PieceMoveLimitY end + return CS.UnityEngine.Vector3(x, y, 0) + else + return CS.UnityEngine.Vector3.zero + end +end + +function XUiFubenActivityPuzzleGamePanel:CalculateNearestBlockIndex(isCorrect) + local nearestIndex = 0 + local nearestDistance = 0 + for index, block in ipairs(self.PuzzleBlocks) do + if not self.PuzzlePieceTable[index] or (isCorrect and not XDataCenter.FubenActivityPuzzleManager.CheckPieceIsCorrect(self.PuzzleId, index)) then + local x1 = self.DragItem.gameObject.transform.position.x + local y1 = self.DragItem.gameObject.transform.position.y + local x2 = self.PuzzleBlocks[index].Transform.position.x + local y2 = self.PuzzleBlocks[index].Transform.position.y + local distance = (y2-y1)^2 + (x2-x1)^2 + if nearestDistance == 0 then + nearestIndex = index + nearestDistance = distance + else + if distance < nearestDistance then + nearestIndex = index + nearestDistance = distance + end + end + end + end + + return nearestIndex +end + +function XUiFubenActivityPuzzleGamePanel:ShowAwardAreaByList(areaIndexList) + for _, index in pairs(areaIndexList) do + if self.PuzzleBlocks[index] then + self.PuzzleBlocks[index]:ShowAwardEffect(true) + end + end +end + +function XUiFubenActivityPuzzleGamePanel:HideAllAwardArea() + for _, block in pairs(self.PuzzleBlocks) do + block:ShowAwardEffect(false) + end +end + +function XUiFubenActivityPuzzleGamePanel:ShowSwitchPieceEffect() + self.SwitchEffect.gameObject:SetActive(false) + self.SwitchEffect.gameObject:SetActive(true) +end + +function XUiFubenActivityPuzzleGamePanel:ShowPuzzleCompleteEffect() + self.PuzzleCompleteEffect.gameObject:SetActive(false) + self.PuzzleCompleteEffect.gameObject:SetActive(true) +end + +return XUiFubenActivityPuzzleGamePanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenActivityPuzzle/XUiFubenActivityPuzzlePassword.lua b/Resources/Scripts/XUi/XUiFubenActivityPuzzle/XUiFubenActivityPuzzlePassword.lua new file mode 100644 index 00000000..274a4ac9 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenActivityPuzzle/XUiFubenActivityPuzzlePassword.lua @@ -0,0 +1,102 @@ +local tableInsert = table.insert +local CSXTextManagerGetText = CS.XTextManager.GetText + +local XUiFubenActivityPuzzlePassword = XLuaUiManager.Register(XLuaUi, "UiFubenActivityPuzzlePassword") + +local XUiPuzzleDercyptionPasswordItem = require("XUi/XUiFubenActivityPuzzle/XUiPuzzleDercyptionPasswordItem") + +function XUiFubenActivityPuzzlePassword:OnAwake() + +end + +function XUiFubenActivityPuzzlePassword:OnStart(rootUi) + self.RootUi = rootUi + self.PasswordItemPool = {} + self.PasswordItemList = {} + self:AutoRegisterBtn() +end + +function XUiFubenActivityPuzzlePassword:OnEnable() + self:InitPasswordList(self.RootUi.PuzzleId) + self:Refreash(self.RootUi.PuzzleId) +end + +function XUiFubenActivityPuzzlePassword:OnDisable() + +end + +function XUiFubenActivityPuzzlePassword:OnDestroy() + +end + +function XUiFubenActivityPuzzlePassword:OnGetEvents() + return { + XEventId.EVENT_DRAG_PUZZLE_GAME_CHANGE_PASSWORD, + XEventId.EVENT_DRAG_PUZZLE_GAME_PUZZLE_CHECK_WORD_ERROR, + XEventId.EVENT_DRAG_PUZZLE_GAME_PUZZLE_COMPLETE, + } +end + +function XUiFubenActivityPuzzlePassword:OnNotify(evt, ...) + if evt == XEventId.EVENT_DRAG_PUZZLE_GAME_CHANGE_PASSWORD then + self:ChangePassword(...) + elseif evt == XEventId.EVENT_DRAG_PUZZLE_GAME_PUZZLE_CHECK_WORD_ERROR then + --XUiManager.TipText("DragPuzzleActivityDercyptionErrorPassword") + XDataCenter.FubenActivityPuzzleManager.HitPasswordMessage(...) + self:Close() + elseif evt == XEventId.EVENT_DRAG_PUZZLE_GAME_PUZZLE_COMPLETE then + self:Close() + end +end + +function XUiFubenActivityPuzzlePassword:Refreash(puzzleId) + if not self.PasswordList or not next(self.PasswordList) then + return + end + + self.TxtTips.text = CsXTextManagerGetText("DragPuzzleActivityDercyptionTips", XFubenActivityPuzzleConfigs.GetPuzzlePasswordHintById(puzzleId)) + + local passwordIdxArr = {} + for index, password in ipairs(self.PasswordList) do + tableInsert(passwordIdxArr, {Index = index, Password = password}) + end + + local onCreate = function(item, data) + item:SetActiveEx(true) + item:OnCreate(data) + self.PasswordItemList[data.Index] = item + end + + XUiHelper.CreateTemplates(self, self.PasswordItemPool, passwordIdxArr, XUiPuzzleDercyptionPasswordItem.New, self.PasswordItem.gameObject, self.PanelDigital, onCreate) +end + +function XUiFubenActivityPuzzlePassword:AutoRegisterBtn() + self.BtnBack.CallBack = function () self:Close() end + self.BtnEnter.CallBack = function () self:OnBtnEnterClick() end +end + +function XUiFubenActivityPuzzlePassword:InitPasswordList(puzzleId) + local CenterPasswordList = XDataCenter.FubenActivityPuzzleManager.GetPasswordByPuzzleId(puzzleId) + self.PasswordList = {} + for _, centerPassword in ipairs(CenterPasswordList) do + tableInsert(self.PasswordList, centerPassword) + end +end + +function XUiFubenActivityPuzzlePassword:OnBtnEnterClick() + XDataCenter.FubenActivityPuzzleManager.ExchangePassword(self.RootUi.PuzzleId, self.PasswordList) +end + +function XUiFubenActivityPuzzlePassword:ChangePassword(index, flag) + if self.PasswordList[index] then + if flag == "Up" then + self.PasswordList[index] = self.PasswordList[index] + 1 + if self.PasswordList[index] > 9 then self.PasswordList[index] = 0 end + else + self.PasswordList[index] = self.PasswordList[index] - 1 + if self.PasswordList[index] < 0 then self.PasswordList[index] = 9 end + end + end + + self.PasswordItemList[index]:SetTextPassword(self.PasswordList[index]) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenActivityPuzzle/XUiFubenActivityPuzzlePasswordRewardPanel.lua b/Resources/Scripts/XUi/XUiFubenActivityPuzzle/XUiFubenActivityPuzzlePasswordRewardPanel.lua new file mode 100644 index 00000000..05ea89d2 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenActivityPuzzle/XUiFubenActivityPuzzlePasswordRewardPanel.lua @@ -0,0 +1,111 @@ +local tableInsert = table.insert + +local XUiFubenActivityPuzzlePasswordRewardPanel = XClass(nil, "XUiFubenActivityPuzzlePasswordRewardPanel") + +function XUiFubenActivityPuzzlePasswordRewardPanel:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + + self:Init() +end + +function XUiFubenActivityPuzzlePasswordRewardPanel:Init() + self.CompleteGridReward = XUiGridCommon.New(self.RootUi, self.GridReward) + self.PasswordArr = {} + for i = 1, 4 do + if self["Password"..i] then + tableInsert(self.PasswordArr, self["Password"..i]) + end + end + self.TxtPasswordArr = {} + for i = 1, 4 do + if self["TxtPassword"..i] then + tableInsert(self.TxtPasswordArr, self["TxtPassword"..i]) + end + end + + self:AutoRegisterListener() +end + +function XUiFubenActivityPuzzlePasswordRewardPanel:RefreshPanel(puzzleId) + self.PuzzleId = puzzleId + self:RefreshCompleteReward(self.PuzzleId) + self:RefreshPasswordReward(self.PuzzleId) +end + +function XUiFubenActivityPuzzlePasswordRewardPanel:RefreshCompleteReward(puzzleId) + local puzzleTemplate = XFubenActivityPuzzleConfigs.GetPuzzleTemplateById(puzzleId) + local reward = XRewardManager.GetRewardList(puzzleTemplate.CompleteRewardId)[1] + local count = reward.Count + self.CompleteRewardEffect.gameObject:SetActive(false) -- 隐藏特效 + if self.CompleteGridReward then + self.CompleteGridReward:Refresh(reward) + local isGot = XDataCenter.FubenActivityPuzzleManager.CheckCompleteRewardIsGot(puzzleId) + if isGot and isGot == XFubenActivityPuzzleConfigs.CompleteRewardState.Rewarded then + self.ReceiveItem.gameObject:SetActiveEx(true) + else + self.ReceiveItem.gameObject:SetActiveEx(false) + if XDataCenter.FubenActivityPuzzleManager.GetPuzzleStateById(puzzleId) == XFubenActivityPuzzleConfigs.PuzzleState.Complete then + self:ShowCompleteRewardEffect() + end + end + end +end + +function XUiFubenActivityPuzzlePasswordRewardPanel:RefreshPasswordReward(puzzleId) + self.PanelLock.gameObject:SetActiveEx(false) + self.PaneNormal.gameObject:SetActiveEx(false) + self.PanelSuccess.gameObject:SetActiveEx(false) + local puzzleState = XDataCenter.FubenActivityPuzzleManager.GetPuzzleStateById(puzzleId) + if puzzleState == XFubenActivityPuzzleConfigs.PuzzleState.Incomplete then + self.PanelLock.gameObject:SetActiveEx(true) + elseif puzzleState == XFubenActivityPuzzleConfigs.PuzzleState.PuzzleCompleteButNotDecryption then + self.PaneNormal.gameObject:SetActiveEx(true) + local passwordList = XDataCenter.FubenActivityPuzzleManager.GetPasswordByPuzzleId(puzzleId) + for index, passwordTrans in ipairs(self.PasswordArr) do + if passwordList[index] then + passwordTrans.gameObject:SetActiveEx(true) + if self.TxtPasswordArr[index] then + self.TxtPasswordArr[index].text = passwordList[index] + end + else + passwordTrans.gameObject:SetActiveEx(false) + end + end + elseif puzzleState == XFubenActivityPuzzleConfigs.PuzzleState.Complete then + self.PanelSuccess.gameObject:SetActiveEx(true) + local passwordList = XDataCenter.FubenActivityPuzzleManager.GetPasswordByPuzzleId(puzzleId) + local passwordStr = table.concat(passwordList) + self.TxtPasswordSuc.text = passwordStr + end +end + +-- function XUiFubenActivityPuzzlePasswordRewardPanel:OnRewardClick(index) +-- if self.CurTouchedIndex then +-- self.CurTouchedIndex = nil +-- return +-- end +-- XDataCenter.FubenActivityPuzzleManager.GetReward(self.PuzzleId, index) +-- end + +function XUiFubenActivityPuzzlePasswordRewardPanel:AutoRegisterListener() + self.BtnDecryption.CallBack = function () self:OnBtnBtnDecryptionClick() end + self.BtnLock.CallBack = function () XUiManager.TipText("DragPuzzleActivityDercyptionNeedComplete") end +end + +function XUiFubenActivityPuzzlePasswordRewardPanel:OnBtnBtnDecryptionClick() + self.RootUi:OpenChildUi("UiFubenActivityPuzzlePassword", self) +end + +function XUiFubenActivityPuzzlePasswordRewardPanel:ShowCompleteRewardEffect() + self.CompleteRewardEffect.gameObject:SetActive(false) + self.CompleteRewardEffect.gameObject:SetActive(true) +end + +function XUiFubenActivityPuzzlePasswordRewardPanel:SetActiveEx(bool) + self.GameObject:SetActiveEx(bool) +end + +return XUiFubenActivityPuzzlePasswordRewardPanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenActivityPuzzle/XUiFubenActivityPuzzlePieceItem.lua b/Resources/Scripts/XUi/XUiFubenActivityPuzzle/XUiFubenActivityPuzzlePieceItem.lua new file mode 100644 index 00000000..5cb11c9a --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenActivityPuzzle/XUiFubenActivityPuzzlePieceItem.lua @@ -0,0 +1,61 @@ +local tableInsert = table.insert + +local XUiFubenActivityPuzzlePieceItem = XClass(nil, "XUiFubenActivityPuzzlePieceItem") + +function XUiFubenActivityPuzzlePieceItem:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + + self:Init() +end + +function XUiFubenActivityPuzzlePieceItem:Init() + self.PuzzleImgItem.gameObject:SetActiveEx(false) +end + +function XUiFubenActivityPuzzlePieceItem:SetRawImage(path) + self.RawImage:SetRawImage(path) +end + +function XUiFubenActivityPuzzlePieceItem:SetActive(bool) + self.PuzzleImgItem.gameObject:SetActiveEx(bool) +end + +function XUiFubenActivityPuzzlePieceItem:SetCorrect(isCorrect) + if isCorrect then + self.CorrectItem.gameObject:SetActiveEx(true) + self.MistakeItem.gameObject:SetActiveEx(false) + else + self.CorrectItem.gameObject:SetActiveEx(false) + self.MistakeItem.gameObject:SetActiveEx(true) + end +end + +function XUiFubenActivityPuzzlePieceItem:SetLight(isLight) + self.LightItem.gameObject:SetActiveEx(isLight) +end + +function XUiFubenActivityPuzzlePieceItem:ShowMistakeEffect() + self.MistakeEffect.gameObject:SetActiveEx(false) + self.MistakeEffect.gameObject:SetActiveEx(true) + XSoundManager.PlaySoundByType(1115, XSoundManager.SoundType.Sound) +end + +function XUiFubenActivityPuzzlePieceItem:ShowCorrectEffect() + self.CorrectEffect.gameObject:SetActiveEx(false) + self.CorrectEffect.gameObject:SetActiveEx(true) + XSoundManager.PlaySoundByType(1114, XSoundManager.SoundType.Sound) +end + +function XUiFubenActivityPuzzlePieceItem:ShowAwardEffect(isShow) + self.AwardItem.gameObject:SetActiveEx(isShow) +end + +function XUiFubenActivityPuzzlePieceItem:HideCorrectAndMistakeEffect() + self.CorrectEffect.gameObject:SetActiveEx(false) + self.MistakeEffect.gameObject:SetActiveEx(false) +end + +return XUiFubenActivityPuzzlePieceItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenActivityPuzzle/XUiFubenActivityPuzzleRewardPanel.lua b/Resources/Scripts/XUi/XUiFubenActivityPuzzle/XUiFubenActivityPuzzleRewardPanel.lua new file mode 100644 index 00000000..d059f6af --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenActivityPuzzle/XUiFubenActivityPuzzleRewardPanel.lua @@ -0,0 +1,116 @@ +local tableInsert = table.insert + +local XUiFubenActivityPuzzleRewardPanel = XClass(nil, "XUiFubenActivityPuzzleRewardPanel") +local XUiFubenActivityPuzzleAreaRewardBtn = require("XUi/XUiFubenActivityPuzzle/XUiFubenActivityPuzzleAreaRewardBtn") + +function XUiFubenActivityPuzzleRewardPanel:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + + self:Init() +end + +function XUiFubenActivityPuzzleRewardPanel:Init() + self.CompleteGridReward = XUiGridCommon.New(self.RootUi, self.GridReward) + self.AreaBtns = {} + for i=1, 4, 1 do + self["AreaBtn"..i] = XUiFubenActivityPuzzleAreaRewardBtn.New(self.RootUi, self["AwardBtn0"..i], function () self:OnRewardClick(i) end) + XUiButtonLongClick.New(self["AreaBtn"..i].Pointer, 200, self, function() self:OnAreaLongExit() end, function () self:OnAreaLongClick(i) end, function () self:OnAreaLongUp() end, true) + tableInsert(self.AreaBtns, self["AreaBtn"..i]) + end +end + +function XUiFubenActivityPuzzleRewardPanel:RefreshPanel(puzzleId) + self.PuzzleId = puzzleId + self:RefreshCompleteReward(self.PuzzleId) + self:RefreshAreaReward(self.PuzzleId) +end + +function XUiFubenActivityPuzzleRewardPanel:RefreshCompleteReward(puzzleId) + local puzzleTemplate = XFubenActivityPuzzleConfigs.GetPuzzleTemplateById(puzzleId) + local reward = XRewardManager.GetRewardList(puzzleTemplate.CompleteRewardId)[1] + local count = reward.Count + self.CompleteRewardEffect.gameObject:SetActive(false) -- 隐藏特效 + if self.CompleteGridReward then + self.CompleteGridReward:Refresh(reward) + local isGot = XDataCenter.FubenActivityPuzzleManager.CheckCompleteRewardIsGot(puzzleId) + if isGot and isGot == XFubenActivityPuzzleConfigs.CompleteRewardState.Rewarded then + self.ReceiveItem.gameObject:SetActiveEx(true) + else + self.ReceiveItem.gameObject:SetActiveEx(false) + if XDataCenter.FubenActivityPuzzleManager.GetPuzzleStateById(puzzleId) == XFubenActivityPuzzleConfigs.PuzzleState.Complete then + self:ShowCompleteRewardEffect() + end + end + end +end + +function XUiFubenActivityPuzzleRewardPanel:RefreshAreaReward(puzzleId) + local puzzleTemplate = XFubenActivityPuzzleConfigs.GetPuzzleTemplateById(puzzleId) + local rewardIds = puzzleTemplate.RewardId + for index, rewardId in ipairs(rewardIds) do + local reward = XRewardManager.GetRewardList(rewardId)[1] + local itemId = reward.TemplateId + local itemIcon = XDataCenter.ItemManager.GetItemIcon(itemId) + local count = reward.Count + if self.AreaBtns[index] then + self.AreaBtns[index]:Refresh(itemIcon, count) + if XDataCenter.FubenActivityPuzzleManager.IsRewardHasTaked(puzzleId, index) then + self.AreaBtns[index]:SetTaked() + else + local isCanTake = XDataCenter.FubenActivityPuzzleManager.CheckAreaRewardCanTake(self.PuzzleId, index) + if isCanTake then self.AreaBtns[index]:SetCanTake() else self.AreaBtns[index]:SetNormal() end + end + end + end +end + +function XUiFubenActivityPuzzleRewardPanel:OnRewardClick(index) + if self.CurTouchedIndex then + self.CurTouchedIndex = nil + return + end + XDataCenter.FubenActivityPuzzleManager.GetReward(self.PuzzleId, index) +end + +function XUiFubenActivityPuzzleRewardPanel:OnAreaLongClick(index) + if XDataCenter.FubenActivityPuzzleManager.IsRewardHasTaked(self.PuzzleId, index) then + return + end + + if not self.CurTouchedIndex then + local needBlockStr = XFubenActivityPuzzleConfigs.GetPuzzleTemplateById(self.PuzzleId).RewardPiecesStr[index] + local needBlockArr = string.ToIntArray(needBlockStr) + self.RootUi.PanelGame:ShowAwardAreaByList(needBlockArr) + self.CurTouchedIndex = index + else + if self.CurTouchedIndex ~= index then + local needBlockStr = XFubenActivityPuzzleConfigs.GetPuzzleTemplateById(self.PuzzleId).RewardPiecesStr[index] + local needBlockArr = string.ToIntArray(needBlockStr) + self.RootUi.PanelGame:HideAllAwardArea() + self.RootUi.PanelGame:ShowAwardAreaByList(needBlockArr) + self.CurTouchedIndex = index + end + end +end + +function XUiFubenActivityPuzzleRewardPanel:OnAreaLongUp() + self.RootUi.PanelGame:HideAllAwardArea() +end + +function XUiFubenActivityPuzzleRewardPanel:OnAreaLongExit() + self.CurTouchedIndex = nil +end + +function XUiFubenActivityPuzzleRewardPanel:ShowCompleteRewardEffect() + self.CompleteRewardEffect.gameObject:SetActive(false) + self.CompleteRewardEffect.gameObject:SetActive(true) +end + +function XUiFubenActivityPuzzleRewardPanel:SetActiveEx(bool) + self.GameObject:SetActiveEx(bool) +end + +return XUiFubenActivityPuzzleRewardPanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenActivityPuzzle/XUiPuzzleDercyptionPasswordItem.lua b/Resources/Scripts/XUi/XUiFubenActivityPuzzle/XUiPuzzleDercyptionPasswordItem.lua new file mode 100644 index 00000000..fe87bee5 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenActivityPuzzle/XUiPuzzleDercyptionPasswordItem.lua @@ -0,0 +1,41 @@ +local XUiPuzzleDercyptionPasswordItem = XClass(nil, "XUiPuzzleDercyptionPasswordItem") + +function XUiPuzzleDercyptionPasswordItem:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + self:Init() +end + +function XUiPuzzleDercyptionPasswordItem:Init() + self:AutoRegisterListener() +end + +function XUiPuzzleDercyptionPasswordItem:AutoRegisterListener() + self.BtnUp.CallBack = function () self:OnBtnUpClick() end + self.BtnDown.CallBack = function () self:OnBtnDownClick() end +end + +function XUiPuzzleDercyptionPasswordItem:OnCreate(data) + self.Index = data.Index + self.TxtPassword.text = data.Password +end + +function XUiPuzzleDercyptionPasswordItem:OnBtnUpClick() + CsXGameEventManager.Instance:Notify(XEventId.EVENT_DRAG_PUZZLE_GAME_CHANGE_PASSWORD, self.Index, "Up") +end + +function XUiPuzzleDercyptionPasswordItem:OnBtnDownClick() + CsXGameEventManager.Instance:Notify(XEventId.EVENT_DRAG_PUZZLE_GAME_CHANGE_PASSWORD, self.Index, "Down") +end + +function XUiPuzzleDercyptionPasswordItem:SetActiveEx(bool) + self.GameObject:SetActiveEx(bool) +end + +function XUiPuzzleDercyptionPasswordItem:SetTextPassword(password) + self.TxtPassword.text = password +end + +return XUiPuzzleDercyptionPasswordItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelMemberHead.lua b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelMemberHead.lua new file mode 100644 index 00000000..b3d7bf95 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelMemberHead.lua @@ -0,0 +1,55 @@ +local XUiBabelMemberHead = XClass(nil, "XUiBabelMemberHead") + +function XUiBabelMemberHead:Ctor(ui, index) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Index = index + + XTool.InitUiObject(self) + self.UiButtonComp = self.Transform:GetComponent("XUiButton") +end + +function XUiBabelMemberHead:ClearMemberHead() + self.RImgRole.gameObject:SetActiveEx(false) + self.ImgLeader.gameObject:SetActiveEx(self:IsLeader()) + self.ImgSword.gameObject:SetActiveEx(false) +end + +function XUiBabelMemberHead:SetMemberInfo(characterId, isHalf, captainPos) + self.CharacterId = characterId + self.CaptainPos = captainPos + + if not characterId or characterId == 0 then + self:ClearMemberHead() + return + end + local character = XDataCenter.CharacterManager.GetCharacter(self.CharacterId) + if not character then + self:ClearMemberHead() + return + end + + self.RImgRole.gameObject:SetActiveEx(true) + self.ImgLeader.gameObject:SetActiveEx(self:IsLeader()) + self.ImgSword.gameObject:SetActiveEx(true) + + if isHalf then + self.RImgRole:SetRawImage(XDataCenter.CharacterManager.GetCharHalfBodyImage(self.CharacterId)) + else + self.RImgRole:SetRawImage(XDataCenter.CharacterManager.GetCharSmallHeadIcon(self.CharacterId)) + end + + self.TxtSword.text = math.floor(character.Ability) +end + +function XUiBabelMemberHead:SetMemberCallBack(cb) + if cb and self.UiButtonComp then + self.UiButtonComp.CallBack = function() cb() end + end +end + +function XUiBabelMemberHead:IsLeader() + return self.Index == self.CaptainPos +end + +return XUiBabelMemberHead \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelMemberSmallHead.lua b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelMemberSmallHead.lua new file mode 100644 index 00000000..b2558b36 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelMemberSmallHead.lua @@ -0,0 +1,15 @@ +local XUiBabelMemberSmallHead = XClass(nil, "XUiBabelMemberSmallHead") + +function XUiBabelMemberSmallHead:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) +end + +function XUiBabelMemberSmallHead:UpdateMember(characterId) + self.ImgIcon:SetRawImage(XDataCenter.CharacterManager.GetCharRoundnessHeadIcon(characterId)) + -- local character = XDataCenter.CharacterManager.GetCharacter(characterId) +end + +return XUiBabelMemberSmallHead \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerAutoFight.lua b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerAutoFight.lua new file mode 100644 index 00000000..e03f919c --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerAutoFight.lua @@ -0,0 +1,72 @@ +local XUiGridAutoFightMember = require("XUi/XUiFubenBabelTower/XUiGridAutoFightMember") + +local CSXTextManagerGetText = CS.XTextManager.GetText + +local XUiBabelTowerAutoFight = XLuaUiManager.Register(XLuaUi, "UiBabelTowerAutoFight") + +function XUiBabelTowerAutoFight:OnAwake() + self.BtnBg.CallBack = function() self:OnBtnBgClick() end + self.BtnAutoFight.CallBack = function() self:OnBtnAutoFightClik() end + self.BtnTanchuangClose.CallBack = function() self:OnBtnBgClick() end + + self.AutoFightGrid = {} + for i = 1, XFubenBabelTowerConfigs.MAX_TEAM_MEMBER do + self.AutoFightGrid[i] = XUiGridAutoFightMember.New(self[string.format("GridRoleAutoFight%d", i)]) + end +end + +function XUiBabelTowerAutoFight:OnStart(stageId, teamId, closeCb) + self.StageId = stageId + self.TeamId = teamId + self.CloseCb = closeCb + self.BlackList = XDataCenter.FubenBabelTowerManager.WipeOutBlackList(stageId, teamId) + + local includeReset = true + self.CharacterIds = XDataCenter.FubenBabelTowerManager.GetTeamCharacterIds(stageId, teamId, includeReset) + + for i = 1, XFubenBabelTowerConfigs.MAX_TEAM_MEMBER do + local characterId = self.CharacterIds[i] + local isLock = characterId and characterId ~= 0 and self.BlackList[characterId] + self.AutoFightGrid[i]:UpdateMember(characterId, isLock) + end + + local curScore = XDataCenter.FubenBabelTowerManager.GetTeamCurScore(stageId, teamId, true) + self.TxtScore.text = curScore + + self.TxtTeamId.text = CSXTextManagerGetText("BabelTowerTeamOrder", teamId) +end + +function XUiBabelTowerAutoFight:OnBtnBgClick() + self:Close() +end + +function XUiBabelTowerAutoFight:OnBtnAutoFightClik() + -- 黑名单判断 + local hasBlackListMember = false + local blackListMemberId = 0 + for i = 1, XFubenBabelTowerConfigs.MAX_TEAM_MEMBER do + local characterId = self.CharacterIds[i] + if characterId ~= nil and characterId ~= 0 then + if self.BlackList[characterId] then + hasBlackListMember = true + blackListMemberId = characterId + break + end + end + end + if hasBlackListMember and blackListMemberId > 0 then + local blackName = XCharacterConfigs.GetCharacterFullNameStr(blackListMemberId) + XUiManager.TipMsg(CS.XTextManager.GetText("BabelTowerCharacterLock", blackName)) + return + end + + XDataCenter.FubenBabelTowerManager.WipeOutBabelTowerStage(self.StageId, self.TeamId, function() + local stageConfigs = XFubenBabelTowerConfigs.GetBabelStageConfigs(self.StageId) + XUiManager.TipMsg(CS.XTextManager.GetText("BabelTowerStageWipeOutSucceed", stageConfigs.Name)) + if self.CloseCb then self.CloseCb() end + self:Close() + end) +end + +function XUiBabelTowerAutoFight:OnDestroy() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerBase.lua b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerBase.lua new file mode 100644 index 00000000..6c169de9 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerBase.lua @@ -0,0 +1,267 @@ +local XUiBabelTowerBase = XLuaUiManager.Register(XLuaUi, "UiBabelTowerBase") + +function XUiBabelTowerBase:OnAwake() + local itemId = XDataCenter.ItemManager.ItemId + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, itemId.FreeGem, itemId.ActionPoint, itemId.Coin) + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + self.BtnNext.CallBack = function() self:OnBtnNextClick() end + self.BtnLast.CallBack = function() self:OnBtnLastClick() end + self.BtnFight.CallBack = function() self:OnBtnFightClick() end + self.BtnEnvironment.CallBack = function() self:OnBtnEnvironmentClick() end + + XEventManager.AddEventListener(XEventId.EVENT_BABEL_ACTIVITY_STATUS_CHANGED, self.CheckActivityStatus, self) +end + +function XUiBabelTowerBase:OnStart(stageId, teamId, enterFightCb) + local cacheTeamData = XDataCenter.FubenBabelTowerManager.GetCacheTeam(stageId, teamId) + local teamList = cacheTeamData.TeamData + local captainPos = cacheTeamData.CaptainPos + local firstFightPos = cacheTeamData.FirstFightPos + + self.StageId = stageId + local stageTemplate = XFubenBabelTowerConfigs.GetBabelTowerStageTemplate(stageId) + self.GuideId = stageTemplate.StageGuideId[1] + self.TeamId = teamId + self.TeamList = teamList + self.CaptainPos = captainPos + self.FirstFightPos = firstFightPos + self.ChallengeBuffInfos = {} + self.SupportBuffInfos = {} + self.IsFirstOpenChildSupport = true + self.EnterFightCb = enterFightCb + + self.CurrentPhase = XFubenBabelTowerConfigs.ChallengePhase + + self:SetBabelTowerPhase() + + -- 显示红点 + self:ShowEnvirementDot() +end + +function XUiBabelTowerBase:OnDestroy() + XEventManager.RemoveEventListener(XEventId.EVENT_BABEL_ACTIVITY_STATUS_CHANGED, self.CheckActivityStatus, self) +end + +function XUiBabelTowerBase:OnEnable() + self:CheckActivityStatus() + + if not self.FirstOpenDiffcultUi then + self:FindChildUiObj(XFubenBabelTowerConfigs.CHALLENGE_CHILD_UI):OnClickBtnDifficult() + self.FirstOpenDiffcultUi = true + end + + if XDataCenter.FubenBabelTowerManager.IsNeedShowUiDifficult() then + XDataCenter.FubenBabelTowerManager.SetNeedShowUiDifficult(nil) + self:FindChildUiObj(XFubenBabelTowerConfigs.CHALLENGE_CHILD_UI):OnClickBtnDifficult() + end +end + +function XUiBabelTowerBase:OnReleaseInst() + return self.FirstOpenDiffcultUi +end + +function XUiBabelTowerBase:OnResume(value) + self.FirstOpenDiffcultUi = value +end + +function XUiBabelTowerBase:CheckActivityStatus() + if not XLuaUiManager.IsUiShow("UiBabelTowerBase") then return end + local curActivityNo = XDataCenter.FubenBabelTowerManager.GetCurrentActivityNo() + if not curActivityNo or not XDataCenter.FubenBabelTowerManager.IsInActivityTime(curActivityNo) then + XUiManager.TipMsg(CS.XTextManager.GetText("BabelTowerNoneOpen")) + XLuaUiManager.RunMain() + end +end + +function XUiBabelTowerBase:OnBtnBackClick() + if self.CurrentPhase and self.CurrentPhase == XFubenBabelTowerConfigs.SupportPhase then + local supportBuffs = self:GetHandleSupportBuffs() + XDataCenter.FubenBabelTowerManager.UpdateSupportBuffListCache(self.StageId, supportBuffs, self.TeamId) + self:Switch2ChallengePhase() + else + self:Close() + end +end + +function XUiBabelTowerBase:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiBabelTowerBase:OnBtnNextClick() + self:Switch2SupportPhase() +end + +function XUiBabelTowerBase:Switch2SupportPhase() + self.CurrentPhase = XFubenBabelTowerConfigs.SupportPhase + self:SetBabelTowerPhase() +end + +function XUiBabelTowerBase:OnBtnLastClick() + local supportBuffs = self:GetHandleSupportBuffs() + XDataCenter.FubenBabelTowerManager.UpdateSupportBuffListCache(self.StageId, supportBuffs, self.TeamId) + self:Switch2ChallengePhase() +end + +function XUiBabelTowerBase:Switch2ChallengePhase() + self.CurrentPhase = XFubenBabelTowerConfigs.ChallengePhase + self:SetBabelTowerPhase() +end + +function XUiBabelTowerBase:GetHandleSupportBuffs() + local supportBuffs = {} + for i = 1, #self.SupportBuffInfos do + local buffItem = self.SupportBuffInfos[i] + table.insert(supportBuffs, { + GroupId = buffItem.BuffGroupId, + BufferId = buffItem.SelectBuffId + }) + end + return supportBuffs +end + +function XUiBabelTowerBase:OnBtnFightClick() + local buffStageId = -1 + -- challenge_buff + local challengeBuffs = {} + + for i = 1, #self.ChallengeBuffInfos do + local buffItem = self.ChallengeBuffInfos[i] + table.insert(challengeBuffs, { + GroupId = buffItem.BuffGroupId, + BufferId = buffItem.SelectBuffId + }) + + local buffConfig = XFubenBabelTowerConfigs.GetBabelTowerBuffTemplate(buffItem.SelectBuffId) + if buffStageId <= 0 and buffConfig and buffConfig.StageId > 0 then + buffStageId = buffConfig.StageId + end + end + + + if buffStageId <= 0 then + buffStageId = self.StageId + end + + -- self.StageId = buffStageId + -- support_buff + local supportBuffs = self:GetHandleSupportBuffs() + + + -- 能否战斗 + local isUnlock, description = XDataCenter.FubenBabelTowerManager.IsBabelStageUnlock(self.StageId) + if not isUnlock then + XUiManager.TipMsg(description) + return + end + + -- 是否有队长 + local captainPos = self.CaptainPos + local captainId = self.TeamList[captainPos] + if captainId == nil or captainId <= 0 then + XUiManager.TipMsg(CS.XTextManager.GetText("BabelTowerPleaseSelectALeader")) + return + end + + -- 是否有首发 + local firstFightPos = self.FirstFightPos + local firFightId = self.TeamList[firstFightPos] + if firFightId == nil or firFightId <= 0 then + XUiManager.TipMsg(CS.XTextManager.GetText("BabelTowerPleaseSelectAFirstFight")) + return + end + + local selectDifficult = XDataCenter.FubenBabelTowerManager.GetTeamSelectDifficult(self.StageId, self.TeamId) + XDataCenter.FubenBabelTowerManager.SelectBabelTowerStage(self.StageId, self.GuideId, self.TeamList, challengeBuffs, supportBuffs, function() + XDataCenter.FubenBabelTowerManager.SaveCurStageInfo(self.StageId, self.TeamId, self.GuideId, self.TeamList, challengeBuffs, supportBuffs, captainPos, selectDifficult, firstFightPos) + + if XDataCenter.FubenBabelTowerManager.IsStageGuideAuto(self.GuideId) then + XDataCenter.FubenBabelTowerManager.UpdateBuffListCache(self.StageId, challengeBuffs, self.TeamId) + end + + XDataCenter.FubenBabelTowerManager.UpdateSupportBuffListCache(self.StageId, supportBuffs, self.TeamId) + XDataCenter.FubenBabelTowerManager.SetTeamChace(self.StageId, self.TeamId, self.TeamList, captainPos, firstFightPos) + + XDataCenter.FubenManager.EnterBabelTowerFight(buffStageId, self.TeamList, function() + if self.EnterFightCb then self:EnterFightCb() end + end, captainPos, firstFightPos) + end, selectDifficult, self.TeamId) +end + +function XUiBabelTowerBase:UpdateTeamList(teamList, captainPos, firstFightPos) + self.TeamList = teamList + self.CaptainPos = captainPos + self.FirstFightPos = firstFightPos +end + +function XUiBabelTowerBase:UpdateChallengeBuffInfos(choosedChallengeList) + self.ChallengeBuffInfos = choosedChallengeList + + -- 通知检查当前角色是否被禁用 + XEventManager.DispatchEvent(XEventId.EVNET_BABEL_CHALLENGE_BUFF_CHANGED) +end + +function XUiBabelTowerBase:UpdateSupportBuffInfos(choosedSupportBuffList) + self.SupportBuffInfos = choosedSupportBuffList +end + +function XUiBabelTowerBase:OnBtnEnvironmentClick() + local activityNo = XDataCenter.FubenBabelTowerManager.GetCurrentActivityNo() + local key = string.format(XFubenBabelTowerConfigs.ENVIROMENT_DOT_KEY, tostring(XPlayer.Id), tostring(activityNo), tostring(self.StageId)) + XDataCenter.FubenBabelTowerManager.UpdateBabalPrefsByKey(key, 1) + self:ShowEnvirementDot() + + XLuaUiManager.Open("UiBabelTowerDetails", XFubenBabelTowerConfigs.TIPSTYPE_ENVIRONMENT, self.StageId) +end + +function XUiBabelTowerBase:ShowEnvirementDot() + local activityNo = XDataCenter.FubenBabelTowerManager.GetCurrentActivityNo() + local key = string.format(XFubenBabelTowerConfigs.ENVIROMENT_DOT_KEY, tostring(XPlayer.Id), tostring(activityNo), tostring(self.StageId)) + local envir_dot = XDataCenter.FubenBabelTowerManager.GetBabelPrefsByKey(key, 0) + local hasTouch = envir_dot == 1 + self.BtnEnvironment:ShowReddot(not hasTouch) +end + +function XUiBabelTowerBase:SetBabelTowerPhase() + if not self.CurrentPhase then return end + if XFubenBabelTowerConfigs.ChallengePhase == self.CurrentPhase then + self.BtnNext.gameObject:SetActiveEx(true) + self.BtnLast.gameObject:SetActiveEx(false) + self.BtnFight.gameObject:SetActiveEx(false) + + self:OpenOneChildUi(XFubenBabelTowerConfigs.CHALLENGE_CHILD_UI, self, self.StageId, self.GuideId, self.TeamId) + self:FindChildUiObj(XFubenBabelTowerConfigs.CHALLENGE_CHILD_UI):PlayAnimation("AnimStartEnable") + if XLuaUiManager.IsUiShow(XFubenBabelTowerConfigs.SUPPORT_CHILD_UI) then + self:FindChildUiObj(XFubenBabelTowerConfigs.SUPPORT_CHILD_UI):Close() + end + end + + if XFubenBabelTowerConfigs.SupportPhase == self.CurrentPhase then + self.BtnNext.gameObject:SetActiveEx(false) + self.BtnLast.gameObject:SetActiveEx(false) + self.BtnFight.gameObject:SetActiveEx(true) + + self:OpenOneChildUi(XFubenBabelTowerConfigs.SUPPORT_CHILD_UI, self, self.StageId, self.GuideId, self.TeamId, self.TeamList, self.CaptainPos, self.FirstFightPos) + if not self.IsFirstOpenChildSupport then + self:FindChildUiObj(XFubenBabelTowerConfigs.SUPPORT_CHILD_UI):RestoreSupportBuff() + else + self.IsFirstOpenChildSupport = false + end + self:FindChildUiObj(XFubenBabelTowerConfigs.SUPPORT_CHILD_UI):PlayAnimation("AnimStartEnable") + if XLuaUiManager.IsUiShow(XFubenBabelTowerConfigs.CHALLENGE_CHILD_UI) then + self:FindChildUiObj(XFubenBabelTowerConfigs.CHALLENGE_CHILD_UI):Close() + end + end + self:SwitchBg() +end + +function XUiBabelTowerBase:SwitchBg() + local stageConfig = XFubenBabelTowerConfigs.GetBabelStageConfigs(self.StageId) + if XFubenBabelTowerConfigs.ChallengePhase == self.CurrentPhase then + self.BgImage:SetRawImage(stageConfig.ChallengeUiBg) + end + + if XFubenBabelTowerConfigs.SupportPhase == self.CurrentPhase then + self.BgImage:SetRawImage(stageConfig.SupportUiBg) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerChallengeChoice.lua b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerChallengeChoice.lua new file mode 100644 index 00000000..e4274ef2 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerChallengeChoice.lua @@ -0,0 +1,172 @@ +local CONDITION_COLOR = { + [true] = XUiHelper.Hexcolor2Color("CE2525FF"), + [false] = CS.UnityEngine.Color.black, +} + +local XUiBabelTowerChallengeChoice = XClass(nil, "XUiBabelTowerChallengeChoice") +local UiButtonState = CS.UiButtonState +local CSXTextManagerGetText = CS.XTextManager.GetText +local XUiGridBabelChallengeItem = require("XUi/XUiFubenBabelTower/XUiGridBabelChallengeItem") + +function XUiBabelTowerChallengeChoice:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.name = "XUiBabelTowerChallengeChoice" + + XTool.InitUiObject(self) + self.ChallengeItemList = {} + self.ChallengeBtnCompList = {} + + self.BtnGuideMask.CallBack = function() self:OnBtnGuideMaskClick() end +end + +function XUiBabelTowerChallengeChoice:Init(uiRoot) + self.UiRoot = uiRoot +end + +function XUiBabelTowerChallengeChoice:SetItemData(itemData) + self.BuffGoupDatas = itemData + self.BuffGroupId = itemData.BuffGroupId + self.GuideId = itemData.GuideId + self.StageId = itemData.StageId + self.TeamId = itemData.TeamId + self.BuffGroupDetails = XFubenBabelTowerConfigs.GetBabelBuffGroupConfigs(self.BuffGroupId) + self.BuffGroupTemplate = XFubenBabelTowerConfigs.GetBabelTowerBuffGroupTemplate(self.BuffGroupId) + + self.TxtChallengeName.text = self.BuffGroupDetails.Name + self:InitChallengeList() +end + +function XUiBabelTowerChallengeChoice:OnBtnGuideMaskClick() + if self.GuideId then + if not XDataCenter.FubenBabelTowerManager.IsStageGuideAuto(self.GuideId) then + XUiManager.TipMsg(CS.XTextManager.GetText("BabelTowerGuideStageCanntSelect")) + return + end + end + self.BtnGuideMask.gameObject:SetActiveEx(false) +end + +function XUiBabelTowerChallengeChoice:InitChallengeList() + for i = 1, #self.BuffGroupTemplate.BuffId do + local buffId = self.BuffGroupTemplate.BuffId[i] + local buffTemplate = XFubenBabelTowerConfigs.GetBabelTowerBuffTemplate(buffId) + local buffConfigs = XFubenBabelTowerConfigs.GetBabelBuffConfigs(buffId) + if not self.ChallengeItemList[i] then + local go = CS.UnityEngine.Object.Instantiate(self.GridChallenge) + go.transform:SetParent(self.GridContent.transform, false) + self.ChallengeItemList[i] = XUiGridBabelChallengeItem.New(go, self, i, XFubenBabelTowerConfigs.TYPE_CHALLENGE) + end + self.ChallengeItemList[i].GameObject:SetActiveEx(true) + self.ChallengeItemList[i]:UpdateBuff(buffTemplate, buffConfigs, i, XFubenBabelTowerConfigs.TYPE_CHALLENGE) + self.ChallengeBtnCompList[i] = self.ChallengeItemList[i]:GetXUiButtonComp() + self.ChallengeBtnCompList[i]:ShowTag(false) + + local isLock = self:IsBuffLock(buffId) + if isLock then + self.ChallengeBtnCompList[i]:SetButtonState(UiButtonState.Disable) + end + end + + local isAutoGuide = XDataCenter.FubenBabelTowerManager.IsStageGuideAuto(self.GuideId) + if isAutoGuide then + self.GridContent:Init(self.ChallengeBtnCompList, function(index) self:OnChallengeChoiceItemClick(index) end) + self.GridContent.CanDisSelect = true + self.GridContent.CurSelectId = self.BuffGoupDatas.CurSelectId + + if self.BuffGoupDatas.IsFirstInit then + local cache = XDataCenter.FubenBabelTowerManager.GetBuffListCacheByStageId(self.StageId, self.TeamId) + local index = self:GetBuffIndexByGroupId(self.BuffGroupId, cache[self.BuffGroupId]) + if index ~= -1 then + self.GridContent:SelectIndex(index) + end + self.BuffGoupDatas.IsFirstInit = false + end + else + self:InitAutoStageGuide() + end + self.BtnGuideMask.gameObject:SetActiveEx(not isAutoGuide) + + + for i = #self.BuffGroupTemplate.BuffId + 1, #self.ChallengeItemList do + self.ChallengeItemList[i].GameObject:SetActiveEx(false) + end + + local isHard = XFubenBabelTowerConfigs.IsBuffGroupHard(self.BuffGroupId) + self.ImgBgHard.gameObject:SetActiveEx(isHard) + self.TxtChallengeName.color = CONDITION_COLOR[isHard] +end + +function XUiBabelTowerChallengeChoice:GetBuffIndexByGroupId(groupId, buffId) + local index = -1 + if not buffId then return index end + local groupDatas = XFubenBabelTowerConfigs.GetBabelTowerBuffGroupTemplate(groupId) + for i = 1, #groupDatas.BuffId do + if buffId == groupDatas.BuffId[i] then + index = i + break + end + end + return index +end + +function XUiBabelTowerChallengeChoice:InitAutoStageGuide() + local stageGuideTemplate = XFubenBabelTowerConfigs.GetBabelTowerStageGuideTemplate(self.GuideId) + + local selectBuffId = nil + for index, buffGroupId in pairs(stageGuideTemplate.BuffGroup or {}) do + if buffGroupId == self.BuffGroupId then + selectBuffId = stageGuideTemplate.BuffId[index] + end + end + + for i = 1, #self.BuffGroupTemplate.BuffId do + if selectBuffId and selectBuffId == self.BuffGroupTemplate.BuffId[i] then + self.ChallengeBtnCompList[i]:SetButtonState(UiButtonState.Select) + self.ChallengeBtnCompList[i]:ShowTag(true) + else + self.ChallengeBtnCompList[i]:SetButtonState(UiButtonState.Disable) + self.ChallengeBtnCompList[i]:ShowTag(false) + end + self.ChallengeBtnCompList[i].enabled = false + end +end + +-- buttonGroup方式选中 +function XUiBabelTowerChallengeChoice:OnChallengeChoiceItemClick(index) + local currentSelectBuffId = self.BuffGroupTemplate.BuffId[index] + if self:IsBuffLock(currentSelectBuffId) then + local openLevel = XFubenBabelTowerConfigs.GetStageDifficultLockBuffIdOpenLevel(self.StageId, currentSelectBuffId) + openLevel = openLevel <= XFubenBabelTowerConfigs.Difficult.Count and openLevel + 1 or openLevel + local diffName = XFubenBabelTowerConfigs.GetStageDifficultName(self.StageId, openLevel) + local tip = CSXTextManagerGetText("BabelTowerStageLevelBuffLocked", diffName) + XUiManager.TipMsg(tip) + return + end + + if self.BuffGoupDatas.SelectedBuffId == currentSelectBuffId then + self.BuffGoupDatas.SelectedBuffId = nil + self.BuffGoupDatas.CurSelectId = -1 + else + self.BuffGoupDatas.SelectedBuffId = currentSelectBuffId + self.BuffGoupDatas.CurSelectId = index + end + self.UiRoot:UpdateChoosedChallengeDatas(self.BuffGroupId, self.BuffGoupDatas.SelectedBuffId) +end + +function XUiBabelTowerChallengeChoice:GetBuffSelectStatus(buffId) + if not self.BuffGoupDatas then return false end + return self.BuffGoupDatas.SelectedBuffId == buffId +end + +function XUiBabelTowerChallengeChoice:IsBuffListOverCount() + return false +end + +function XUiBabelTowerChallengeChoice:IsBuffLock(buffId) + local selectDifficult = XDataCenter.FubenBabelTowerManager.GetTeamSelectDifficult(self.StageId, self.TeamId) + local openLevel = XFubenBabelTowerConfigs.GetStageDifficultLockBuffIdOpenLevel(self.StageId, buffId) + return openLevel and openLevel ~= 0 and selectDifficult <= openLevel or false +end + +return XUiBabelTowerChallengeChoice \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerChallengeSelect.lua b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerChallengeSelect.lua new file mode 100644 index 00000000..95a43ad6 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerChallengeSelect.lua @@ -0,0 +1,47 @@ +local XUiBabelTowerChallengeSelect = XClass(nil, "XUiBabelTowerChallengeSelect") + +function XUiBabelTowerChallengeSelect:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + + XTool.InitUiObject(self) +end + +function XUiBabelTowerChallengeSelect:Init(uiRoot) + self.UiRoot = uiRoot +end + +function XUiBabelTowerChallengeSelect:SetItemData(chooseItem, buffType) + self.ChooseItem = chooseItem + self.BuffId = chooseItem.SelectBuffId + self.BuffType = buffType + self.BuffConfigs = XFubenBabelTowerConfigs.GetBabelBuffConfigs(self.BuffId) + self.BuffTemplate = XFubenBabelTowerConfigs.GetBabelTowerBuffTemplate(self.BuffId) + + self.TxtDescribe.text = string.format("%s\n%s", self.BuffConfigs.Name, self.BuffConfigs.Desc) + self:StopFx() +end + +function XUiBabelTowerChallengeSelect:PlayFx() + if self.ImgFx then + if self.ImgFx.gameObject.activeSelf then + self.ImgFx.gameObject:SetActiveEx(false) + end + + self.ImgFx.gameObject:SetActiveEx(true) + end +end + +function XUiBabelTowerChallengeSelect:StopFx() + if self.ImgFx then + self.ImgFx.gameObject:SetActiveEx(false) + end +end + +function XUiBabelTowerChallengeSelect:GetBuffDescriptionHeight() + return self.TxtDescribe.preferredHeight +end + + +return XUiBabelTowerChallengeSelect \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerChildChallenge.lua b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerChildChallenge.lua new file mode 100644 index 00000000..f9b5a839 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerChildChallenge.lua @@ -0,0 +1,356 @@ +local XUiBabelTowerChallengeChoice = require("XUi/XUiFubenBabelTower/XUiBabelTowerChallengeChoice") +local XUiBabelTowerChallengeSelect = require("XUi/XUiFubenBabelTower/XUiBabelTowerChallengeSelect") + +local CSXTextManagerGetText = CS.XTextManager.GetText + +local XUiBabelTowerChildChallenge = XLuaUiManager.Register(XLuaUi, "UiBabelTowerChildChallenge") + +function XUiBabelTowerChildChallenge:OnAwake() + self.BtnNext.CallBack = function() self:OnBtnNextClick() end + self.BtnDifficult.CallBack = function() self:OnClickBtnDifficult() end + self.BtnChallenge.CallBack = function() self:OnBtnChallengeClick() end + + self.DynamicTableChallengeChoice = XDynamicTableNormal.New(self.PanelChallengeChoice.gameObject) + self.DynamicTableChallengeChoice:SetProxy(XUiBabelTowerChallengeChoice) + self.DynamicTableChallengeChoice:SetDelegate(self) + self.DynamicTableChallengeChoice:SetDynamicEventDelegate(function(event, index, grid) + self:OnChallengeChoiceDynamicTableEvent(event, index, grid) + end) + + self.SelectChoiceList = {} + + self.ChoosedChallengeList = {} + self.ChallengeBuffSelectGroup = {} + self.RightRectTransform = self.PanelRight:GetComponent("RectTransform") + self.GridChoice.gameObject:SetActiveEx(false) +end + +function XUiBabelTowerChildChallenge:OnStart(uiRoot, stageId, guideId, teamId) + self.UiRoot = uiRoot + self.StageId = stageId + self.GuideId = guideId + self.TeamId = teamId + self.BabelTowerStageTemplate = XFubenBabelTowerConfigs.GetBabelTowerStageTemplate(self.StageId) + self:GenChallengeGroupDatas() + self:GenChallengeSelectDatas() + if XDataCenter.FubenBabelTowerManager.IsStageGuideAuto(self.GuideId) then + self:InitDefaultSelect() + else + self:UpdateChoosedChallengeDatasByStageGuide() + end +end + +function XUiBabelTowerChildChallenge:OnEnable() + self.DynamicTableChallengeChoice:SetDataSource(self.ChallengeBuffGroup) + self.DynamicTableChallengeChoice:ReloadDataASync() + self:SetChallengeScore() +end + +function XUiBabelTowerChildChallenge:RefreshSelectChoiceList(index) + if self.ChoosedChallengeList then + local chooseCount = #self.ChoosedChallengeList + for i = 1, chooseCount do + if not self.SelectChoiceList[i] then + local ui = CS.UnityEngine.Object.Instantiate(self.GridSelectChoice) + ui.transform:SetParent(self.PanelChoiceContainer, false) + self.SelectChoiceList[i] = XUiBabelTowerChallengeSelect.New(ui, self) + end + + self.SelectChoiceList[i].GameObject:SetActiveEx(true) + self.SelectChoiceList[i]:SetItemData(self.ChoosedChallengeList[i], XFubenBabelTowerConfigs.TYPE_CHALLENGE) + end + + for i = chooseCount + 1, #self.SelectChoiceList do + self.SelectChoiceList[i].GameObject:SetActiveEx(false) + end + -- 默认选中 + if index and index > 0 and index <= chooseCount then + self:CenterToGrid(self.SelectChoiceList[index], index) + self.SelectChoiceList[index]:PlayFx() + end + + self.ImgEmpty.gameObject:SetActiveEx(chooseCount <= 0) + end +end + +function XUiBabelTowerChildChallenge:OnDisable() + if self.ChoosedChallengeList then + for i = 1, #self.ChoosedChallengeList do + self.SelectChoiceList[i]:StopFx() + end + end +end + +function XUiBabelTowerChildChallenge:CenterToGrid(grid, index) + local normalizedPosition + local count = #self.SelectChoiceList + local itemTotalCount = #self.ChoosedChallengeList + local totalHeight = 0 + local curHeight = 0 + for i = 1, count do + local itemHeight = self.SelectChoiceList[i]:GetBuffDescriptionHeight() + totalHeight = totalHeight + itemHeight + if i <= index then + curHeight = curHeight + itemHeight + end + end + + local offset = 0 + if index + 1 <= itemTotalCount then + offset = self.SelectChoiceList[index + 1]:GetBuffDescriptionHeight() + end + if curHeight > totalHeight / 2 then + normalizedPosition = (curHeight + offset) / totalHeight + else + normalizedPosition = (curHeight - offset) / totalHeight + end + + self.DelayTimer = XScheduleManager.ScheduleOnce(function() + self.PanelSelectChallenge.verticalNormalizedPosition = math.max(0, math.min(1, (1 - normalizedPosition))) + XScheduleManager.UnSchedule(self.DelayTimer) + end, 50) +end + +function XUiBabelTowerChildChallenge:OnDestroy() + if self.DelayTimer then + XScheduleManager.UnSchedule(self.DelayTimer) + self.DelayTimer = nil + end +end + +function XUiBabelTowerChildChallenge:OnChallengeChoiceDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + if self.ChallengeBuffGroup[index] then + grid:SetItemData(self.ChallengeBuffGroup[index]) + end + end +end + +function XUiBabelTowerChildChallenge:OnChallengeSelectDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + if self.ChoosedChallengeList[index] then + grid:SetItemData(self.ChoosedChallengeList[index], XFubenBabelTowerConfigs.TYPE_CHALLENGE) + end + end +end + +function XUiBabelTowerChildChallenge:OnBtnNextClick() + self.UiRoot:Switch2SupportPhase() +end + +function XUiBabelTowerChildChallenge:OnBtnChallengeClick() + XLuaUiManager.Open("UiBabelTowerDetails", XFubenBabelTowerConfigs.TIPSTYPE_CHALLENGE, self.StageId) +end + +function XUiBabelTowerChildChallenge:InitDefaultSelect() + self.ChoosedChallengeList = {} + local cache = XDataCenter.FubenBabelTowerManager.GetBuffListCacheByStageId(self.StageId, self.TeamId) + for i = 1, #self.ChallengeBuffSelectGroup do + local groupItem = self.ChallengeBuffSelectGroup[i] + local buffId = cache[groupItem.BuffGroupId] + groupItem.SelectBuffId = buffId + if buffId and buffId ~= 0 and not self:IsBuffLock(buffId) then + table.insert(self.ChoosedChallengeList, groupItem) + end + end + + self:ReportChallengeChoice() + -- self.DynamicTableChallengeSelect:SetDataSource(self.ChoosedChallengeList) + -- self.DynamicTableChallengeSelect:ReloadDataASync() + self:RefreshSelectChoiceList() + self:UpdateCurChallengeScore(self.ChoosedChallengeList) +end + +function XUiBabelTowerChildChallenge:SetChallengeScore() + local stageId = self.StageId + local teamId = self.TeamId + + local selectDifficult = XDataCenter.FubenBabelTowerManager.GetTeamSelectDifficult(stageId, teamId) + + local recommendAblity = XFubenBabelTowerConfigs.GetStageDifficultRecommendAblity(stageId, selectDifficult) + self.TxtAbility.text = recommendAblity + + local name = XFubenBabelTowerConfigs.GetStageDifficultName(stageId, selectDifficult) + self.TxtDifficult.text = name + + local ratio = XFubenBabelTowerConfigs.GetStageDifficultRatio(stageId, selectDifficult) + self.TxtRatio.text = CSXTextManagerGetText("BabelTowerUiBaseRatio", ratio) + + local maxScore = XDataCenter.FubenBabelTowerManager.GetTeamMaxScore(stageId, teamId) + self.TxtChallengeTop.text = CSXTextManagerGetText("BabelTowerCurMaxScore", maxScore) +end + +-- 保存一份数据,记录玩家选中的挑战项SelectBuffList = {buffId = isSelect} +function XUiBabelTowerChildChallenge:GenChallengeGroupDatas() + if self.ChallengeBuffGroup then return self.ChallengeBuffGroup end + self.ChallengeBuffGroup = {} + for i = 1, #self.BabelTowerStageTemplate.ChallengeBuffGroup do + local groupId = self.BabelTowerStageTemplate.ChallengeBuffGroup[i] + table.insert(self.ChallengeBuffGroup, { + StageId = self.StageId, + GuideId = self.GuideId, + TeamId = self.TeamId, + BuffGroupId = groupId, + SelectedBuffId = nil, + CurSelectId = -1, + IsFirstInit = true + }) + end +end + +function XUiBabelTowerChildChallenge:GenChallengeSelectDatas() + self.ChallengeBuffSelectGroup = {} + for i = 1, #self.BabelTowerStageTemplate.ChallengeBuffGroup do + table.insert(self.ChallengeBuffSelectGroup, { + BuffGroupId = self.BabelTowerStageTemplate.ChallengeBuffGroup[i], + SelectBuffId = nil, + }) + end +end + +-- 设置已选战略组 +-- buffgroup组选中了一个buffId,如果buffId为空,则该buffgroup组没有选中任何一个buff +function XUiBabelTowerChildChallenge:UpdateChoosedChallengeDatas(buffGroupId, buffId) + if not self.ChallengeBuffSelectGroup then self:GenChallengeSelectDatas() end + -- isExist + if self.ChoosedChallengeList and #self.ChoosedChallengeList > 0 then + for _, v in pairs(self.ChoosedChallengeList) do + if v.BuffGroupId == buffGroupId and buffId and v.SelectBuffId == buffId then + return + end + end + end + + self.ChoosedChallengeList = {} + + for i = 1, #self.ChallengeBuffSelectGroup do + local groupItem = self.ChallengeBuffSelectGroup[i] + if groupItem.BuffGroupId == buffGroupId then + groupItem.SelectBuffId = buffId + end + if groupItem.SelectBuffId and groupItem.SelectBuffId ~= 0 and self:IsBuffLock(groupItem.SelectBuffId) then + groupItem.SelectBuffId = nil + end + if groupItem.SelectBuffId then + table.insert(self.ChoosedChallengeList, groupItem) + end + end + + if self.ChoosedChallengeList then + for k = #self.ChoosedChallengeList, 1, -1 do + local buffId = self.ChoosedChallengeList[k].SelectBuffId + if not buffId or buffId ~= 0 and self:IsBuffLock(buffId) then + table.remove(self.ChoosedChallengeList, k) + end + end + end + + local index = 0 + for i = 1, #self.ChoosedChallengeList do + local groupItem = self.ChoosedChallengeList[i] + if groupItem.BuffGroupId == buffGroupId and groupItem.SelectBuffId and groupItem.SelectBuffId == buffId then + index = i + break + end + end + + self:ReportChallengeChoice() + self:RefreshSelectChoiceList(index) + self.ImgEmpty.gameObject:SetActiveEx(#self.ChoosedChallengeList <= 0) + self:UpdateCurChallengeScore(self.ChoosedChallengeList) +end + +-- 非自选战略 +function XUiBabelTowerChildChallenge:UpdateChoosedChallengeDatasByStageGuide() + local stageGuideTemplate = XFubenBabelTowerConfigs.GetBabelTowerStageGuideTemplate(self.GuideId) + self.ChoosedChallengeList = {} + for i = 1, #stageGuideTemplate.BuffGroup do + table.insert(self.ChoosedChallengeList, { + BuffGroupId = stageGuideTemplate.BuffGroup[i], + SelectBuffId = stageGuideTemplate.BuffId[i] + }) + end + self:ReportChallengeChoice() + -- self.DynamicTableChallengeSelect:SetDataSource(self.ChoosedChallengeList) + -- self.DynamicTableChallengeSelect:ReloadDataASync() + self:RefreshSelectChoiceList() + self.ImgEmpty.gameObject:SetActiveEx(#self.ChoosedChallengeList <= 0) + self:UpdateCurChallengeScore(self.ChoosedChallengeList) +end + +function XUiBabelTowerChildChallenge:UpdateCurChallengeScore(challengeList) + local totalChallengeScore = 0 + if self.BabelTowerStageTemplate then + totalChallengeScore = self.BabelTowerStageTemplate.BaseScore + end + for _, v in pairs(challengeList or {}) do + local buffTemplate = XFubenBabelTowerConfigs.GetBabelTowerBuffTemplate(v.SelectBuffId) + totalChallengeScore = totalChallengeScore + (buffTemplate.ScoreAdd or 0) + end + + local selectDifficult = XDataCenter.FubenBabelTowerManager.GetTeamSelectDifficult(self.StageId, self.TeamId) + local ratio = XFubenBabelTowerConfigs.GetStageDifficultRatio(self.StageId, selectDifficult) + self.TxtChallengeNumber.text = math.floor(totalChallengeScore * ratio) +end + +function XUiBabelTowerChildChallenge:ReportChallengeChoice() + self.UiRoot:UpdateChallengeBuffInfos(self.ChoosedChallengeList) +end + +function XUiBabelTowerChildChallenge:DealDiffRealatedData() + local dataChanged = false + + if self.ChoosedChallengeList then + for k = #self.ChoosedChallengeList, 1, -1 do + local buffId = self.ChoosedChallengeList[k].SelectBuffId + if buffId ~= 0 and self:IsBuffLock(buffId) then + table.remove(self.ChoosedChallengeList, k) + dataChanged = true + end + end + end + + for i = 1, #self.ChallengeBuffSelectGroup do + local groupItem = self.ChallengeBuffSelectGroup[i] + if groupItem.SelectBuffId and groupItem.SelectBuffId ~= 0 and self:IsBuffLock(groupItem.SelectBuffId) then + groupItem.SelectBuffId = nil + end + end + + if self.ChallengeBuffGroup then + for k = #self.ChallengeBuffGroup, 1, -1 do + local data = self.ChallengeBuffGroup[k] + local buffId = data.SelectedBuffId + if buffId ~= 0 and self:IsBuffLock(buffId) then + data.SelectedBuffId = nil + data.CurSelectId = -1 + dataChanged = true + end + end + end + + if dataChanged then + XUiManager.TipText("BabelTowerStageLevelBuffChanged") + end +end + +function XUiBabelTowerChildChallenge:OnClickBtnDifficult() + XLuaUiManager.Open("UiBabelTowerSelectDiffcult", self.StageId, self.TeamId, function() + self:DealDiffRealatedData() + self:ReportChallengeChoice() + self:RefreshSelectChoiceList() + self.DynamicTableChallengeChoice:ReloadDataASync() + self:SetChallengeScore() + self:UpdateCurChallengeScore(self.ChoosedChallengeList) + end) +end + +function XUiBabelTowerChildChallenge:IsBuffLock(buffId) + local selectDifficult = XDataCenter.FubenBabelTowerManager.GetTeamSelectDifficult(self.StageId, self.TeamId) + local openLevel = XFubenBabelTowerConfigs.GetStageDifficultLockBuffIdOpenLevel(self.StageId, buffId) + return openLevel and openLevel ~= 0 and selectDifficult <= openLevel or false +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerChildSupport.lua b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerChildSupport.lua new file mode 100644 index 00000000..dd250677 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerChildSupport.lua @@ -0,0 +1,472 @@ +local XUiBabelTowerChildSupport = XLuaUiManager.Register(XLuaUi, "UiBabelTowerChildSupport") + +local XUiBabelMemberHead = require("XUi/XUiFubenBabelTower/XUiBabelMemberHead") +local XUiBabelTowerSupportChoice = require("XUi/XUiFubenBabelTower/XUiBabelTowerSupportChoice") +local XUiBabelTowerChallengeSelect = require("XUi/XUiFubenBabelTower/XUiBabelTowerChallengeSelect") + +function XUiBabelTowerChildSupport:OnAwake() + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnGo.CallBack = function() self:OnBtnGoClick() end + self.BtnSupport.CallBack = function() self:OnBtnSupportClick() end + + self.TeamMemberList = {} + for i = 1, XFubenBabelTowerConfigs.MAX_TEAM_MEMBER do + self.TeamMemberList[i] = XUiBabelMemberHead.New(self[string.format("TeamMember%d", i)], i) + self.TeamMemberList[i]:ClearMemberHead() + self.TeamMemberList[i]:SetMemberCallBack(function() + self:OnBtnGoClick() + end) + end + + self.DynamicTableSupportChoice = XDynamicTableNormal.New(self.PanelSupportChoice.gameObject) + self.DynamicTableSupportChoice:SetProxy(XUiBabelTowerSupportChoice) + self.DynamicTableSupportChoice:SetDelegate(self) + self.DynamicTableSupportChoice:SetDynamicEventDelegate(function(event, index, grid) + self:OnSupportChoiceDynamicTableEvent(event, index, grid) + end) + + self.SelectChoiceList = {} + + self.ChoosedSupportList = {} + self.SupportBuffSelectGroup = {} + + XEventManager.AddEventListener(XEventId.EVNET_BABEL_CHALLENGE_BUFF_CHANGED, self.CheckTeamBanCharacterList, self) +end + +function XUiBabelTowerChildSupport:OnStart(uiRoot, stageId, guideId, teamId, teamList, captainPos, firstFightPos) + self.UiRoot = uiRoot + self.StageId = stageId + self.GuideId = guideId + self.TeamId = teamId + self.TeamList = teamList + self.CaptainPos = captainPos + self.FirstFightPos = firstFightPos + self.BabelTowerStageTemplate = XFubenBabelTowerConfigs.GetBabelTowerStageTemplate(self.StageId) + + self:GetTotalSupportPoint() + self:SetSupportChoiceDatas() + + -- 初始化检查一遍阵容 + self:CheckTeamBanCharacterList() + self:InitSupportBuff() +end + +function XUiBabelTowerChildSupport:OnEnable() + self:SetTeamListDatas() + self:ReportTeamList() + self:OnUpdateTeamMemberEnd() +end + +function XUiBabelTowerChildSupport:OnDisable() + if self.ChoosedSupportList then + for i = 1, #self.ChoosedSupportList do + self.SelectChoiceList[i]:StopFx() + end + end +end + +function XUiBabelTowerChildSupport:OnDestroy() + if self.DelayTimer then + XScheduleManager.UnSchedule(self.DelayTimer) + self.DelayTimer = nil + end + XEventManager.RemoveEventListener(XEventId.EVNET_BABEL_CHALLENGE_BUFF_CHANGED, self.CheckTeamBanCharacterList, self) +end + +function XUiBabelTowerChildSupport:RefreshSelectChoiceList(index) + if self.ChoosedSupportList then + local chooseCount = #self.ChoosedSupportList + for i = 1, chooseCount do + if not self.SelectChoiceList[i] then + local ui = CS.UnityEngine.Object.Instantiate(self.GridSelectSupportChoice) + ui.transform:SetParent(self.PanelChoiceContainer, false) + ui.gameObject:SetActiveEx(true) + self.SelectChoiceList[i] = XUiBabelTowerChallengeSelect.New(ui, self) + end + self.SelectChoiceList[i].GameObject:SetActiveEx(true) + self.SelectChoiceList[i]:SetItemData(self.ChoosedSupportList[i], XFubenBabelTowerConfigs.TYPE_SUPPORT) + end + + for i = chooseCount + 1, #self.SelectChoiceList do + self.SelectChoiceList[i].GameObject:SetActiveEx(false) + end + + if index and index > 0 and index <= chooseCount then + self:CenterToGrid(self.SelectChoiceList[index], index) + self.SelectChoiceList[index]:PlayFx() + end + end +end + +function XUiBabelTowerChildSupport:CenterToGrid(grid, index) + local normalizedPosition + local count = #self.SelectChoiceList + local itemTotalCount = #self.ChoosedSupportList + local totalHeight = 0 + local curHeight = 0 + for i = 1, count do + local itemHeight = self.SelectChoiceList[i]:GetBuffDescriptionHeight() + totalHeight = totalHeight + itemHeight + if i <= index then + curHeight = curHeight + itemHeight + end + end + + local offset = 0 + if index + 1 <= itemTotalCount then + offset = self.SelectChoiceList[index + 1]:GetBuffDescriptionHeight() + end + if curHeight > totalHeight / 2 then + normalizedPosition = (curHeight + offset) / totalHeight + else + normalizedPosition = (curHeight - offset) / totalHeight + end + + self.DelayTimer = XScheduleManager.ScheduleOnce(function() + self.PanelSelectSupport.verticalNormalizedPosition = math.max(0, math.min(1, (1 - normalizedPosition))) + XScheduleManager.UnSchedule(self.DelayTimer) + end, 50) +end + +function XUiBabelTowerChildSupport:CheckTeamBanCharacterList() + local banCharacters = XDataCenter.FubenBabelTowerManager.GetBanCharacterIdsByBuff(self.UiRoot.ChallengeBuffInfos) + for i = 1, XFubenBabelTowerConfigs.MAX_TEAM_MEMBER do + local curChar = self.TeamList[i] + if curChar ~= nil and curChar ~= 0 and banCharacters[curChar] then + self.TeamList[i] = 0 + self.TeamMemberList[i]:SetMemberInfo(self.TeamList[i], nil, self.CaptainPos) + end + end +end + +-- 仅此一份,其他界面都以这个为准 +function XUiBabelTowerChildSupport:GetTeamList() + return self.TeamList +end + +function XUiBabelTowerChildSupport:OnSupportChoiceDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + if self.SupportBuffGroup[index] then + grid:SetItemData(self.SupportBuffGroup[index]) + end + end +end + +function XUiBabelTowerChildSupport:OnSupportSelectDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + if self.ChoosedSupportList[index] then + grid:SetItemData(self.ChoosedSupportList[index], XFubenBabelTowerConfigs.TYPE_SUPPORT) + end + end +end + +function XUiBabelTowerChildSupport:OnBtnBackClick() + self.UiRoot:Switch2ChallengePhase() +end + +function XUiBabelTowerChildSupport:OnBtnGoClick() + local babelTowerData = { + TeamId = self.TeamId, + TeamList = XDataCenter.FubenBabelTowerManager.GetCacheTeam(self.StageId, self.TeamId, self.TeamList, self.CaptainPos, self.FirstFightPos), + Cb = function(resTeam, captainPos, firstFightPos) + self.TeamList = resTeam + self.CaptainPos = captainPos + self.FirstFightPos = firstFightPos + end + } + local data = {BabelTowerData = babelTowerData} + XLuaUiManager.Open("UiNewRoomSingle", self.StageId, data) +end + +function XUiBabelTowerChildSupport:OnBtnSupportClick() + -- 支援详情 + XLuaUiManager.Open("UiBabelTowerDetails", XFubenBabelTowerConfigs.TIPSTYPE_SUPPORT, self.StageId) +end + +function XUiBabelTowerChildSupport:RestoreSupportBuff() + self:GetTotalSupportPoint() + self:SetSupportChoiceDatas() + + -- 初始化检查一遍阵容 + self:CheckTeamBanCharacterList() + self:ReportTeamList() + + self:InitSupportBuff() +end + +-- 设置支援目标战略组 +function XUiBabelTowerChildSupport:SetSupportChoiceDatas() + self:GenSupportGroupDatas() + self:GenSupportSelectDatas() + self.DynamicTableSupportChoice:SetDataSource(self.SupportBuffGroup) + self.DynamicTableSupportChoice:ReloadDataASync() +end + +-- 设置队伍信息:初始化 +function XUiBabelTowerChildSupport:SetTeamListDatas() + for i = 1, XFubenBabelTowerConfigs.MAX_TEAM_MEMBER do + self.TeamMemberList[i]:SetMemberInfo(self.TeamList[i], nil, self.CaptainPos) + end +end + +-- 更新队伍信息:手动改变队伍 +function XUiBabelTowerChildSupport:UpdateTeamMember(member_position, characterId) + if member_position <= 0 or member_position > XFubenBabelTowerConfigs.MAX_TEAM_MEMBER then return end + self.TeamList[member_position] = characterId or 0 + self.TeamMemberList[member_position]:SetMemberInfo(self.TeamList[member_position], nil, self.CaptainPos) + self:ReportTeamList() +end + +function XUiBabelTowerChildSupport:UpdateTeamInfo() + for i = 1, XFubenBabelTowerConfigs.MAX_TEAM_MEMBER do + local characterId = self.TeamMemberList[i].CharacterId + self.TeamMemberList[i]:SetMemberInfo(characterId, nil, self.CaptainPos) + end +end + +-- 切换队伍结束:计算支援点 +-- 不清除支援组 +-- 红色显色 +-- 支援点处理 +-- 现有的基础上、增加超出处理 +-- 控件刷新如何记住超出状态 +-- 超出状态出现一定是按下状态、取消的时候变成不可点击状态、超出状态消失 +-- 逻辑处理: +-- 判读是否超出: +-- 是:全部选项标记超出 +-- 每次取消:判读是否超出,更改标记 +-- 否:帮用户选上 +-- 更改标记 +-- 默认选中 +function XUiBabelTowerChildSupport:InitSupportBuff() + local supportBuffs = XDataCenter.FubenBabelTowerManager.GetSupportBuffListCacheByStageId(self.StageId, self.TeamId) + + -- 记录选中的 + for _, v in pairs(self.SupportBuffSelectGroup or {}) do + if supportBuffs[v.BuffGroupId] then + v.SelectBuffId = supportBuffs[v.BuffGroupId] + end + end + self.ChoosedSupportList = {} + for i = 1, #self.SupportBuffSelectGroup do + local groupItem = self.SupportBuffSelectGroup[i] + if groupItem.SelectBuffId then + table.insert(self.ChoosedSupportList, groupItem) + end + end + local availablePoint = self:GetAvailableSupportPoint() + -- 记录全部 + for _, v in pairs(self.SupportBuffGroup or {}) do + if supportBuffs[v.BuffGroupId] then + v.SelectedBuffId = supportBuffs[v.BuffGroupId] + local buffGroupTemplate = XFubenBabelTowerConfigs.GetBabelTowerBuffGroupTemplate(v.BuffGroupId) + for idx, buffId in pairs(buffGroupTemplate.BuffId) do + if buffId == supportBuffs[v.BuffGroupId] then + v.CurSelectId = idx + break + end + end + v.IsOverCount = availablePoint < 0 + end + end + + -- 更新界面 + self:UpdateSupportChooiceState() + self:ReportSupportChoice() + -- self.DynamicTableSupportSelect:SetDataSource(self.ChoosedSupportList) + -- self.DynamicTableSupportSelect:ReloadDataASync() + self:RefreshSelectChoiceList() + self.ImgEmpty.gameObject:SetActiveEx(#self.ChoosedSupportList <= 0) + self.TxtChallengeNumber.text = availablePoint +end + +-- 切换队友 +function XUiBabelTowerChildSupport:OnUpdateTeamMemberEnd() + -- 计算总的支援点数 + self:GetTotalSupportPoint() + + -- self:CheckSupportSelectBuffs() + local availableSupportPoint = self:GetAvailableSupportPoint() + self:UpdateSupportBuffOverCountTag(availableSupportPoint) + + self:UpdateSupportChooiceState() + self.TxtChallengeNumber.text = availableSupportPoint +end + +-- 更改标记 +function XUiBabelTowerChildSupport:UpdateSupportBuffOverCountTag(availablePoint) + for _, v in pairs(self.SupportBuffGroup or {}) do + v.IsOverCount = availablePoint < 0 + end +end + +-- 清理选中支援组 +function XUiBabelTowerChildSupport:CheckSupportSelectBuffs() + local supportSelectBuffs = {} + local usedSupportPoints = 0 + + for i = 1, #self.ChoosedSupportList do + local datas = self.ChoosedSupportList[i] + local buffTemplate = XFubenBabelTowerConfigs.GetBabelTowerBuffTemplate(datas.SelectBuffId) + local curCostSupportPoints = usedSupportPoints + buffTemplate.PointSub + local isChoose = false + if curCostSupportPoints <= self.TotalSupportPoint then + usedSupportPoints = curCostSupportPoints + table.insert(supportSelectBuffs, datas) + isChoose = true + else + self:UnselectSupportChoice(datas.BuffGroupId) + end + + for _, v in pairs(self.SupportBuffSelectGroup or {}) do + if v.BuffGroupId == datas.BuffGroupId then + local buffId = isChoose and datas.SelectBuffId or nil + v.SelectBuffId = buffId + break + end + end + + end + self.ChoosedSupportList = supportSelectBuffs + self:ReportSupportChoice() + -- self.DynamicTableSupportSelect:SetDataSource(self.ChoosedSupportList) + -- self.DynamicTableSupportSelect:ReloadDataASync() + self:RefreshSelectChoiceList() + self.ImgEmpty.gameObject:SetActiveEx(#self.ChoosedSupportList <= 0) +end + +-- 清理支援选项 +function XUiBabelTowerChildSupport:UnselectSupportChoice(buffGroupId) + for _, v in pairs(self.SupportBuffGroup or {}) do + if v.BuffGroupId == buffGroupId then + v.SelectedBuffId = nil + v.CurSelectId = -1 + break + end + end +end + +function XUiBabelTowerChildSupport:UpdateSupportChooiceState() + for i = 1, #self.SupportBuffGroup do + local grid = self.DynamicTableSupportChoice:GetGridByIndex(i) + if grid then + grid:UpdateGridChoiceState(self:GetAvailableSupportPoint()) + end + end +end + +function XUiBabelTowerChildSupport:CalcUsedSupportPoint() + local usedSupportPoint = 0 + + for _, choosedItem in pairs(self.ChoosedSupportList or {}) do + local buffTemplate = XFubenBabelTowerConfigs.GetBabelTowerBuffTemplate(choosedItem.SelectBuffId) + usedSupportPoint = usedSupportPoint + (buffTemplate.PointSub or 0) + end + + return usedSupportPoint +end + +function XUiBabelTowerChildSupport:GetAvailableSupportPoint() + return self.TotalSupportPoint - self:CalcUsedSupportPoint() +end + +-- 获取支援点数,阵容一旦确定,支援点数也可以确定 +function XUiBabelTowerChildSupport:GetTotalSupportPoint() + + self.TotalSupportPoint = self.BabelTowerStageTemplate.BaseSupportPoint or 0 + + local characterIds = {} + for i = 1, XFubenBabelTowerConfigs.MAX_TEAM_MEMBER do + local characterId = self.TeamMemberList[i].CharacterId + if characterId ~= nil and characterId ~= 0 then + table.insert(characterIds, characterId) + end + end + + for i = 1, #self.BabelTowerStageTemplate.SupportConditionId do + local supportConditionId = self.BabelTowerStageTemplate.SupportConditionId[i] + local supportConditionTemplate = XFubenBabelTowerConfigs.GetBabelTowerSupportConditonTemplate(supportConditionId) + if supportConditionTemplate.Condition == nil or supportConditionTemplate.Condition == 0 then + self.TotalSupportPoint = self.TotalSupportPoint + supportConditionTemplate.PointAdd + else + local isConditionAvailable = XConditionManager.CheckCondition(supportConditionTemplate.Condition, characterIds) + if isConditionAvailable then + self.TotalSupportPoint = self.TotalSupportPoint + supportConditionTemplate.PointAdd + end + end + end + + return self.TotalSupportPoint +end + +-- 保存一份数据,记录玩家选中的挑战项SelectBuffList = {buffId = isSelect} +function XUiBabelTowerChildSupport:GenSupportGroupDatas() + if self.SupportBuffGroup then return self.SupportBuffGroup end + self.SupportBuffGroup = {} + for i = 1, #self.BabelTowerStageTemplate.SupportBuffGroup do + table.insert(self.SupportBuffGroup, { + StageId = self.StageId, + GuideId = self.GuideId, + BuffGroupId = self.BabelTowerStageTemplate.SupportBuffGroup[i], + SelectedBuffId = nil, + CurSelectId = -1, + IsOverCount = false, + }) + end +end + +function XUiBabelTowerChildSupport:GenSupportSelectDatas() + self.SupportBuffSelectGroup = {} + for i = 1, #self.BabelTowerStageTemplate.SupportBuffGroup do + table.insert(self.SupportBuffSelectGroup, { + BuffGroupId = self.BabelTowerStageTemplate.SupportBuffGroup[i], + SelectBuffId = nil + }) + end +end + +-- 设置已选支援组 +function XUiBabelTowerChildSupport:UpdateChoosedChallengeDatas(buffGroupId, buffId) + if not self.SupportBuffSelectGroup then self:GenSupportSelectDatas() end + self.ChoosedSupportList = {} + for i = 1, #self.SupportBuffSelectGroup do + local groupItem = self.SupportBuffSelectGroup[i] + if groupItem.BuffGroupId == buffGroupId then + groupItem.SelectBuffId = buffId + end + if groupItem.SelectBuffId then + table.insert(self.ChoosedSupportList, groupItem) + end + end + local index = 0 + for i = 1, #self.ChoosedSupportList do + local groupItem = self.ChoosedSupportList[i] + if groupItem.BuffGroupId == buffGroupId and groupItem.SelectBuffId and groupItem.SelectBuffId == buffId then + index = i + break + end + end + + self:ReportSupportChoice() + -- self.DynamicTableSupportSelect:SetDataSource(self.ChoosedSupportList) + -- self.DynamicTableSupportSelect:ReloadDataASync() + self:RefreshSelectChoiceList(index) + self.ImgEmpty.gameObject:SetActiveEx(#self.ChoosedSupportList <= 0) + + local availableSupportPoint = self:GetAvailableSupportPoint() + self:UpdateSupportBuffOverCountTag(availableSupportPoint) + self:UpdateSupportChooiceState() + self.TxtChallengeNumber.text = availableSupportPoint +end + +function XUiBabelTowerChildSupport:ReportSupportChoice() + self.UiRoot:UpdateSupportBuffInfos(self.ChoosedSupportList) +end + +function XUiBabelTowerChildSupport:ReportTeamList() + self.UiRoot:UpdateTeamList(self.TeamList, self.CaptainPos, self.FirstFightPos) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerDetails.lua b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerDetails.lua new file mode 100644 index 00000000..670b0cee --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerDetails.lua @@ -0,0 +1,101 @@ +local XUiBabelTowerDetails = XLuaUiManager.Register(XLuaUi, "UiBabelTowerDetails") +local XUiGridInfoEnvironmentItem = require("XUi/XUiFubenBabelTower/XUiGridInfoEnvironmentItem") +local XUiGridInfoChallengeItem = require("XUi/XUiFubenBabelTower/XUiGridInfoChallengeItem") + +function XUiBabelTowerDetails:OnAwake() + self.BtnTanchuangClose.CallBack = function() self:OnBtnTanchuangClose() end + + self.DynamicTableTipsBaseBuff = XDynamicTableNormal.New(self.PanelAmbientText.gameObject) + self.DynamicTableTipsBaseBuff:SetProxy(XUiGridInfoEnvironmentItem) + self.DynamicTableTipsBaseBuff:SetDelegate(self) + self.DynamicTableTipsBaseBuff:SetDynamicEventDelegate(function(event, index, grid) + self:OnEnvironmentDynamicTableEvent(event, index, grid) + end) + + self.GridChallengeList = {} + self.GridSupportList = {} + +end + +function XUiBabelTowerDetails:OnBtnTanchuangClose() + self:Close() +end + +function XUiBabelTowerDetails:OnStart(tipsType, stageId) + self.StageId = stageId + self.TipsType = tipsType + self.BabelStageTemplate = XFubenBabelTowerConfigs.GetBabelTowerStageTemplate(self.StageId) + + self.IsEnvironmentTips = XFubenBabelTowerConfigs.TIPSTYPE_ENVIRONMENT == self.TipsType + self.IsChallengeTips = XFubenBabelTowerConfigs.TIPSTYPE_CHALLENGE == self.TipsType + self.IsSupportTips = XFubenBabelTowerConfigs.TIPSTYPE_SUPPORT == self.TipsType + + self.PanelAmbient.gameObject:SetActiveEx(self.IsEnvironmentTips) + self.PanelChallenge.gameObject:SetActiveEx(self.IsChallengeTips) + self.PanelSupport.gameObject:SetActiveEx(self.IsSupportTips) + + if self.IsEnvironmentTips then + self:SetEnvironmentTipsInfo() + end + + if self.IsChallengeTips then + self:SetChallengeTipsInfo() + end + + if self.IsSupportTips then + self:SetSupportTipsInfo() + end +end + +-- 环境情报 +function XUiBabelTowerDetails:SetEnvironmentTipsInfo() + self.BaseBuffs = self.BabelStageTemplate.BaseBuffId + self.DynamicTableTipsBaseBuff:SetDataSource(self.BaseBuffs) + self.DynamicTableTipsBaseBuff:ReloadDataASync() +end + +function XUiBabelTowerDetails:OnEnvironmentDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + if self.BaseBuffs[index] then + grid:SetItemInfo(self.BaseBuffs[index], index) + end + end +end + +-- 挑战详情 +function XUiBabelTowerDetails:SetChallengeTipsInfo() + for i = 1, #self.BabelStageTemplate.ChallengeBuffGroup do + if not self.GridChallengeList[i] then + local go = CS.UnityEngine.Object.Instantiate(self.GridChallengeDetails) + go.transform:SetParent(self.PanelChallengeContainer, false) + go.gameObject:SetActiveEx(true) + local challengeItem = XUiGridInfoChallengeItem.New(go, self.BabelStageTemplate.ChallengeBuffGroup[i], XFubenBabelTowerConfigs.TYPE_CHALLENGE) + table.insert(self.GridChallengeList, challengeItem) + else + self.GridChallengeList[i]:Refresh(self.BabelStageTemplate.ChallengeBuffGroup[i], XFubenBabelTowerConfigs.TYPE_CHALLENGE) + end + end + for i = #self.BabelStageTemplate.ChallengeBuffGroup + 1, #self.GridChallengeList do + self.GridChallengeList[i].GameObject:SetActiveEx(false) + end +end + +-- 支援详情 +function XUiBabelTowerDetails:SetSupportTipsInfo() + for i = 1, #self.BabelStageTemplate.SupportBuffGroup do + if not self.GridSupportList[i] then + local go = CS.UnityEngine.Object.Instantiate(self.GridSupportDetails) + go.transform:SetParent(self.PanelSupportContainer, false) + go.gameObject:SetActiveEx(true) + local challengeItem = XUiGridInfoChallengeItem.New(go, self.BabelStageTemplate.SupportBuffGroup[i], XFubenBabelTowerConfigs.TYPE_SUPPORT) + table.insert(self.GridSupportList, challengeItem) + else + self.GridSupportList[i]:Refresh(self.BabelStageTemplate.SupportBuffGroup[i], XFubenBabelTowerConfigs.TYPE_SUPPORT) + end + end + for i = #self.BabelStageTemplate.SupportBuffGroup + 1, #self.GridSupportList do + self.GridSupportList[i].GameObject:SetActiveEx(false) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerFightTips.lua b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerFightTips.lua new file mode 100644 index 00000000..52c47e36 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerFightTips.lua @@ -0,0 +1,345 @@ +local CsXTextManager = CS.XTextManager +--######################## XUiBabelTowerWinPanel ######################## +local XUiBabelTowerWinPanel = XClass(nil, "XUiBabelTowerWinPanel") + +function XUiBabelTowerWinPanel:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self.StageId = nil + self.TeamId = nil + XTool.InitUiObject(self) + self:RegisterUiEvents() + self.RImgHead.gameObject:SetActiveEx(false) +end + +function XUiBabelTowerWinPanel:SetData(stageId, teamId, challengeBuffs, supportBuffs, curTeamScore, curActivityMaxScore) + self.StageId = stageId + self.TeamId = teamId + -- 玩家基本信息 + XUiPLayerHead.InitPortrait(XPlayer.CurrHeadPortraitId, XPlayer.CurrHeadFrameId, self.Head) + self.TxtPlayName.text = XPlayer.Name + self.TxtPlayerId.text = XPlayer.Id + -- 编队基本信息 + local teamScore = XDataCenter.FubenBabelTowerManager.GetTeamCurScore(stageId, teamId) + self.TxtTeamNumber.text = CsXTextManager.GetText("BabelTowerTeamOrder", teamId) + self.TxtTeamLevel.text = teamScore + local characterIds = XDataCenter.FubenBabelTowerManager.GetTeamCharacterIds(stageId, teamId) + local characterId, characterIcon + local headContentChild, rImgHeadIcon + for i = 1, 3 do + characterId = characterIds[i] + if characterId and characterId > 0 then + characterIcon = XDataCenter.CharacterManager.GetCharSmallHeadIcon(characterId) + if i > self.HeadContent.childCount then + headContentChild = CS.UnityEngine.Object.Instantiate(self.RImgHead, self.HeadContent) + else + headContentChild = self.HeadContent:GetChild(i - 1) + end + headContentChild.gameObject:SetActiveEx(true) + rImgHeadIcon = headContentChild:GetComponent("RawImage") + rImgHeadIcon:SetRawImage(characterIcon) + end + end + -- 关卡难度 + local selectDifficult = XDataCenter.FubenBabelTowerManager.GetTeamSelectDifficult(stageId, teamId) + local name = XFubenBabelTowerConfigs.GetStageDifficultName(stageId, selectDifficult) + self.TxtDiffName.text = name + -- 关卡使用的词缀 + local isHard + local childUObj + local buffData + local buffContent = self.FightEventContent1 + buffContent:GetChild(0).gameObject:SetActiveEx(false) + local buffConfig + for i = 1, 10 do + buffContent = i <= 5 and self.FightEventContent1 or self.FightEventContent2 + buffData = challengeBuffs[i] + childUObj = CS.UnityEngine.Object.Instantiate(self.FightEventGrid, buffContent):GetComponent("UiObject") + childUObj.gameObject:SetActiveEx(true) + childUObj:GetObject("RImgNone").gameObject:SetActiveEx(buffData == nil) + childUObj:GetObject("RImgBg").gameObject:SetActiveEx(buffData ~= nil) + childUObj:GetObject("RImgIcon").gameObject:SetActiveEx(buffData ~= nil) + if buffData then + isHard = XFubenBabelTowerConfigs.IsBuffGroupHard(buffData.GroupId) + buffConfig = XFubenBabelTowerConfigs.GetBabelBuffConfigs(buffData.BufferId) + childUObj:GetObject("RImgRed").gameObject:SetActiveEx(isHard) + childUObj:GetObject("RImgBlue").gameObject:SetActiveEx(not isHard) + childUObj:GetObject("RImgIcon"):SetRawImage(buffConfig.BuffBg) + else + childUObj:GetObject("RImgRed").gameObject:SetActiveEx(false) + childUObj:GetObject("RImgBlue").gameObject:SetActiveEx(false) + end + end + -- 关卡号 + local stageConfig = XFubenBabelTowerConfigs.GetBabelStageConfigs(stageId) + self.TxtStageNumber.text = "0" .. stageConfig.Number + -- 关卡名 + self.TxtStageName.text = stageConfig.Title + -- 完成等级 + local finishedScore = self:GetChallengePoints(challengeBuffs) + self.RImgLevelUp.gameObject:SetActiveEx(finishedScore > curTeamScore) + self.TxtLevel.text = finishedScore + -- 总等级 + local _, maxScore = XDataCenter.FubenBabelTowerManager.GetCurrentActivityScores() + -- if maxScore > curActivityMaxScore then + -- XLog.Warning("====================== todo, 播放活动升级特效") + -- end + self.TxtTotalLevel.text = "Total Lv: " .. maxScore -- 海外修改 + -- 角色立绘 + local captainPos = XDataCenter.FubenBabelTowerManager.GetTeamCaptainPos(stageId, teamId) + self.RImgRole:SetRawImage(XDataCenter.CharacterManager.GetCharHalfBodyBigImage(characterIds[captainPos])) + -- 检查战斗计时器,回到活动主界面 + local currentActivityNo = XDataCenter.FubenBabelTowerManager.GetCurrentActivityNo() + local endTime = XDataCenter.FubenBabelTowerManager.GetFightEndTime(currentActivityNo) + self.RootUi:SetAutoCloseInfo(endTime, function(isClose) + if isClose then + self.RootUi:StopTimer() + XDataCenter.FunctionEventManager.UnLockFunctionEvent() + XLuaUiManager.RunMain() + XUiManager.TipError(CS.XTextManager.GetText("BabelTowerNoneFight")) + end + end) +end + +function XUiBabelTowerWinPanel:RegisterUiEvents() + self.BtnQuit.CallBack = function() self:OnBtnQuitClicked() end +end + +function XUiBabelTowerWinPanel:OnBtnQuitClicked() + self.RootUi:StopTimer() + self.RootUi:Close() + XDataCenter.FunctionEventManager.UnLockFunctionEvent() +end + +function XUiBabelTowerWinPanel:GetChallengePoints(buffList) + local totalChallengePoints = 0 + local buffId + local buffTemplates + for _, buffInfo in pairs(buffList) do + buffId = buffInfo.BufferId + buffTemplates = XFubenBabelTowerConfigs.GetBabelTowerBuffTemplate(buffId) + totalChallengePoints = totalChallengePoints + buffTemplates.ScoreAdd + end + local selectDifficult = XDataCenter.FubenBabelTowerManager.GetTeamSelectDifficult(self.StageId, self.TeamId) + local ratio = XFubenBabelTowerConfigs.GetStageDifficultRatio(self.StageId, selectDifficult) + return math.floor(totalChallengePoints * ratio) +end + + +--######################## XUiBabelTowerFightTips ######################## +local XUiBabelTowerFightTips = XLuaUiManager.Register(XLuaUi, "UiFightBabelTower") +local XUiBabelTowerTipsItem = require("XUi/XUiFubenBabelTower/XUiBabelTowerTipsItem") + +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate + +local BuffShowRate = CS.XGame.ClientConfig:GetInt("BabelTowerBuffShowRate") / 10 +local BuffDisapearTime = CS.XGame.ClientConfig:GetInt("BabelTowerBuffDisappearTime") +local ANIM_BEGIN_ENABLE = "AnimBeginEnable" +local ANIM_END_ENABLE = "AnimEndEnable" + +function XUiBabelTowerFightTips:OnAwake() + self.UiBabelTowerWinPanel = XUiBabelTowerWinPanel.New(self.PanelWin, self) + self.ChallengeBuffList = {} + self.SupportBuffList = {} + + for i = XFubenBabelTowerConfigs.START_INDEX, XFubenBabelTowerConfigs.MAX_CHALLENGE_BUFF_COUNT do + self.ChallengeBuffList[i] = XUiBabelTowerTipsItem.New(self[string.format("Challenge%d", i)], XFubenBabelTowerConfigs.TYPE_CHALLENGE) + self.ChallengeBuffList[i].GameObject:SetActiveEx(false) + end + + for i = XFubenBabelTowerConfigs.START_INDEX, XFubenBabelTowerConfigs.MAX_SUPPORT_BUFF_COUNT do + self.SupportBuffList[i] = XUiBabelTowerTipsItem.New(self[string.format("Support%d", i)], XFubenBabelTowerConfigs.TYPE_SUPPORT) + self.SupportBuffList[i].GameObject:SetActiveEx(false) + end + + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnPrepareMask.CallBack = function() self:OnBtnBackClick() end +end + +function XUiBabelTowerFightTips:OnBtnBackClick() + self:StopTimer() + self:Close() + XDataCenter.FunctionEventManager.UnLockFunctionEvent() + -- self:PlayAnimation("AnimEffertEnable", function() + -- self:Close() + -- XDataCenter.FunctionEventManager.UnLockFunctionEvent() + -- end) +end + + +function XUiBabelTowerFightTips:OnStart(stageId, battleStatus) + self.BaseBuffGrids = {} + + self.StageId = stageId + self.BattleStatus = battleStatus + self.CurStageId, self.CurTeamId, self.CurStageGuideId, self.CurTeamList, self.ChallengeBuffs, self.SupportBuffs + , self.CurCaptainPos, self.CurStageLevel, self.CurFirstFightPos, self.CurTeamScore, self.curActivityMaxScore + = XDataCenter.FubenBabelTowerManager.GetCurStageInfo() + + if self.StageId ~= self.CurStageId then + XLog.Error("stageId do not match...self.StageId = " .. tostring(self.StageId) .. "; self.CurStageId = " .. tostring(self.CurStageId)) + self:Close() + return + end + self.PanelReady.gameObject:SetActiveEx(self.BattleStatus == XFubenBabelTowerConfigs.BattleReady) + self.PanelWin.gameObject:SetActiveEx(self.BattleStatus == XFubenBabelTowerConfigs.BattleEnd) + -- 如果是胜利界面,直接交给胜利界面单独处理 + if self.BattleStatus == XFubenBabelTowerConfigs.BattleEnd then + self.UiBabelTowerWinPanel:SetData(self.CurStageId, self.CurTeamId, self.ChallengeBuffs, self.SupportBuffs, self.CurTeamScore, self.curActivityMaxScore) + self:PlayAnimation(ANIM_END_ENABLE) + return + end + + self:ClearFightTips() + + local animName = self.BattleStatus == XFubenBabelTowerConfigs.BattleReady and ANIM_BEGIN_ENABLE or ANIM_END_ENABLE + self:PlayAnimation(animName, function() + self:SetBabelTowerFightTips() + end) + + self:SetStageBaseBuffs() +end + +function XUiBabelTowerFightTips:ClearFightTips() + self.ModeTitle2.gameObject:SetActiveEx(false) + self.OverTitle.gameObject:SetActiveEx(false) + self.BtnPrepareMask.gameObject:SetActiveEx(false) + for i = 1, XFubenBabelTowerConfigs.MAX_CHALLENGE_BUFF_COUNT do + self.ChallengeBuffList[i].GameObject:SetActiveEx(false) + end + for i = 1, XFubenBabelTowerConfigs.MAX_SUPPORT_BUFF_COUNT do + self.SupportBuffList[i].GameObject:SetActiveEx(false) + end +end + +function XUiBabelTowerFightTips:GetChallengePoints(buffList) + self.ModeTitle2.gameObject:SetActiveEx(self.BattleStatus == XFubenBabelTowerConfigs.BattleReady) + self.OverTitle.gameObject:SetActiveEx(self.BattleStatus == XFubenBabelTowerConfigs.BattleEnd) + local totalChallengePoints = 0 + for _, buffInfo in pairs(buffList) do + local buffId = buffInfo.BufferId + local buffTemplates = XFubenBabelTowerConfigs.GetBabelTowerBuffTemplate(buffId) + totalChallengePoints = totalChallengePoints + buffTemplates.ScoreAdd + end + + local selectDifficult = XDataCenter.FubenBabelTowerManager.GetTeamSelectDifficult(self.StageId, self.CurTeamId) + local ratio = XFubenBabelTowerConfigs.GetStageDifficultRatio(self.StageId, selectDifficult) + return math.floor(totalChallengePoints * ratio) +end + +function XUiBabelTowerFightTips:SetBabelTowerFightTips() + + if self.BattleStatus == XFubenBabelTowerConfigs.BattleReady then + -- local curActivityNo = XDataCenter.FubenBabelTowerManager.GetCurrentActivityNo() + local challengePoints = self:GetChallengePoints(self.ChallengeBuffs) + local _, difficultyTitle, difficultyStatus = XFubenBabelTowerConfigs.GetBabelTowerDifficulty(self.StageId, challengePoints) + self.TxtStatusTitle.text = difficultyTitle + self.TxtStatusWarning.text = difficultyStatus + elseif self.BattleStatus == XFubenBabelTowerConfigs.BattleEnd then + self.TxtFinishLevel.text = self:GetChallengePoints(self.ChallengeBuffs) + end + + self:SetBattlePrepareBuff(self.ChallengeBuffs, self.SupportBuffs) +end + +--展示关卡基础难度buff +function XUiBabelTowerFightTips:SetStageBaseBuffs() + local baseBuffIds = XFubenBabelTowerConfigs.GetBaseBuffIds(self.StageId) + + for index, buffId in pairs(baseBuffIds) do + local grid = self.BaseBuffGrids[index] + if not grid then + local go = index == 1 and self.GridBaseBuff or CSUnityEngineObjectInstantiate(self.GridBaseBuff, self.PanelBaseBuffs) + grid = XTool.InitUiObjectByUi({}, go) + self.BaseBuffGrids[index] = grid + end + + grid.TxtBuff.text = XFubenBabelTowerConfigs.GetBaseBuffNameWithSpilt(buffId) + grid.GameObject:SetActiveEx(true) + end + + for index = #baseBuffIds + 1, #self.BaseBuffGrids do + local grid = self.BaseBuffGrids[index] + if grid then + grid.GameObject:SetActiveEx(false) + end + end + +end + +function XUiBabelTowerFightTips:SetBattlePrepareBuff(challengeBuffs, supportBuffs) + self.ChallengeBuffList[0].GameObject:SetActiveEx(true) + self.SupportBuffList[0].GameObject:SetActiveEx(true) + + self:StopTimer() + local currentShowBuffIndex = 0 + local timerGap = CS.XGame.ClientConfig:GetInt("BabelTowerBuffShowTime") + self.Timer = XScheduleManager.ScheduleForever(function() + if currentShowBuffIndex > #challengeBuffs and currentShowBuffIndex > #supportBuffs then + self:StopTimer() + if self.BattleStatus == XFubenBabelTowerConfigs.BattleReady then + self:SetAutoCloseTimer() + end + return + end + if currentShowBuffIndex > XFubenBabelTowerConfigs.START_INDEX then + if currentShowBuffIndex <= XFubenBabelTowerConfigs.MAX_CHALLENGE_BUFF_COUNT then + self.ChallengeBuffList[currentShowBuffIndex].GameObject:SetActiveEx(challengeBuffs[currentShowBuffIndex] ~= nil) + if challengeBuffs[currentShowBuffIndex] then + self.ChallengeBuffList[currentShowBuffIndex]:RefreshBuffInfo(challengeBuffs[currentShowBuffIndex], XFubenBabelTowerConfigs.TYPE_CHALLENGE) + end + end + if currentShowBuffIndex <= XFubenBabelTowerConfigs.MAX_SUPPORT_BUFF_COUNT then + self.SupportBuffList[currentShowBuffIndex].GameObject:SetActiveEx(supportBuffs[currentShowBuffIndex] ~= nil) + if supportBuffs[currentShowBuffIndex] then + self.SupportBuffList[currentShowBuffIndex]:RefreshBuffInfo(supportBuffs[currentShowBuffIndex], XFubenBabelTowerConfigs.TYPE_SUPPORT) + end + end + timerGap = timerGap * BuffShowRate + end + currentShowBuffIndex = currentShowBuffIndex + 1 + end, timerGap, 0) +end + +function XUiBabelTowerFightTips:SetAutoCloseTimer() + + self:StopAutoCloseTimer() + self.AutoCloseTimer = XScheduleManager.ScheduleOnce(function() + self.BtnPrepareMask.gameObject:SetActiveEx(true) + self:Close() + end, BuffDisapearTime) +end + +function XUiBabelTowerFightTips:StopAutoCloseTimer() + if self.AutoCloseTimer then + XScheduleManager.UnSchedule(self.AutoCloseTimer) + self.AutoCloseTimer = nil + end +end + +function XUiBabelTowerFightTips:StopTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end + +function XUiBabelTowerFightTips:OnEnable() + XUiBabelTowerFightTips.Super.OnEnable(self) + if CS.XFight.IsRunning then + CS.XFight.Instance:Pause() + end +end + +function XUiBabelTowerFightTips:OnDisable() + XUiBabelTowerFightTips.Super.OnDisable(self) + if CS.XFight.Instance then + CS.XFight.Instance:Resume() + end +end + +function XUiBabelTowerFightTips:OnDestroy() + self:StopTimer() + self:StopAutoCloseTimer() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerMainNew.lua b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerMainNew.lua new file mode 100644 index 00000000..4f230a31 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerMainNew.lua @@ -0,0 +1,262 @@ +local XUiGridBabelStageItem = require("XUi/XUiFubenBabelTower/XUiGridBabelStageItem") + +local SWITH_BG_TIME = 10 * XScheduleManager.SECOND +local SWITH_BG_INDEX = { 2, 1 } + +local XUiBabelTowerMainNew = XLuaUiManager.Register(XLuaUi, "UiBabelTowerMainNew") + +function XUiBabelTowerMainNew:OnAwake() + self:InitIsPlayLoopBgAnimation() + self:Init() + XEventManager.AddEventListener(XEventId.EVENT_BABEL_STAGE_INFO_ASYNC, self.RefreshMainUi, self) + XEventManager.AddEventListener(XEventId.EVENT_BABEL_RESET_STATUES_CHANGED, self.RefreshMainUi, self) + XEventManager.AddEventListener(XEventId.EVENT_BABEL_ACTIVITY_STATUS_CHANGED, self.OnActivityStatusChanged, self) +end + +function XUiBabelTowerMainNew:OnStart() + self.CurrentActivityNo = XDataCenter.FubenBabelTowerManager.GetCurrentActivityNo() + self.CurrentActivityMaxScore = XDataCenter.FubenBabelTowerManager.GetCurrentActivityMaxScore() + self.CurrentActivityTemplate = XFubenBabelTowerConfigs.GetBabelTowerActivityTemplateById(self.CurrentActivityNo) + if not self.CurrentActivityTemplate then + return + end + + self.BtnRank.gameObject:SetActiveEx(self.CurrentActivityTemplate.RankType ~= XFubenBabelTowerConfigs.RankType.NoRank) + self:RefreshMainUi() + + self.PanelAsset.gameObject:SetActiveEx(true) + XRedPointManager.AddRedPointEvent(self.RedAchievement, self.RefreshAchievementTaskRedDot, self, { XRedPointConditions.Types.CONDITION_TASK_TYPE }, XDataCenter.TaskManager.TaskType.BabelTower) + local babelTowerManager = XDataCenter.FubenBabelTowerManager + local value = babelTowerManager.GetBabelTowerPrefs(XFubenBabelTowerConfigs.HAS_PLAY_BEGINSTORY, 0) + local activityNo = babelTowerManager.GetCurrentActivityNo() + local hasPlay = value == 1 + if not hasPlay and activityNo then + XUiManager.ShowHelpTip("BabelTower") + XDataCenter.FubenBabelTowerManager.SaveBabelTowerPrefs(XFubenBabelTowerConfigs.HAS_PLAY_BEGINSTORY, 1) + end +end + +function XUiBabelTowerMainNew:OnEnable() + self:OnActivityStatusChanged() + + self:PlayAnimation("AnimStartEnable", function() + XLuaUiManager.SetMask(false) + end, function() + XLuaUiManager.SetMask(true) + end) + + self:PlayLoopBgAnimation() + XRedPointManager.CheckOnce(self.OnCheckTaskRedPoint, self, { XRedPointConditions.Types.CONDITION_ACTIVITYBRIE_BABELTOWER_REWARD }) +end + +function XUiBabelTowerMainNew:OnDisable() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end + +function XUiBabelTowerMainNew:OnDestroy() + XEventManager.RemoveEventListener(XEventId.EVENT_BABEL_STAGE_INFO_ASYNC, self.RefreshMainUi, self) + XEventManager.RemoveEventListener(XEventId.EVENT_BABEL_RESET_STATUES_CHANGED, self.RefreshMainUi, self) + XEventManager.RemoveEventListener(XEventId.EVENT_BABEL_ACTIVITY_STATUS_CHANGED, self.OnActivityStatusChanged, self) +end + +function XUiBabelTowerMainNew:Init() + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + self.BtnAchievement.CallBack = function() self:OnBtnAchievementClick() end + self:BindHelpBtn(self.BtnHelp, "BabelTower") + self.BtnRank.CallBack = function() self:OnBtnRankClick() end + self.BtnRank.gameObject:SetActive(true) + + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) +end + +function XUiBabelTowerMainNew:InitIsPlayLoopBgAnimation() + self.IsPlayLoopBgAnimation = true + for i in ipairs(SWITH_BG_INDEX) do + self["Bg" .. i].gameObject:SetActiveEx(true) + end + local bgObj1 = XUiHelper.TryGetComponent(self.Bg1.transform, "RImgBg", "XLoadRawImage") + local bgObj2 = XUiHelper.TryGetComponent(self.Bg2.transform, "RImgBg", "XLoadRawImage") + local bgTexture1 = bgObj1 and bgObj1.AssetUrl + local bgTexture2 = bgObj2 and bgObj2.AssetUrl + if bgTexture1 == bgTexture2 then + self.IsPlayLoopBgAnimation = false + end + self.Bg2.gameObject:SetActiveEx(false) +end + +function XUiBabelTowerMainNew:OnBeginDrag(eventData) + self.PanelTaskList:OnBeginDrag(eventData) + self.IsDraging = true + self.PreY = self.PanelTaskList.verticalNormalizedPosition +end + +function XUiBabelTowerMainNew:OnBtnRankClick() + XDataCenter.FubenBabelTowerManager.GetRank(function() + XLuaUiManager.Open("UiFubenBabelTowerRank") + end) +end + +function XUiBabelTowerMainNew:OnBtnBackClick() + self:Close() +end + +function XUiBabelTowerMainNew:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiBabelTowerMainNew:OnBtnAchievementClick() + -- 时间限制,不在活动期间不给打开 + if not self.CurrentActivityNo or not XDataCenter.FubenBabelTowerManager.IsInActivityTime(self.CurrentActivityNo) then + XUiManager.TipMsg(CS.XTextManager.GetText("BabelTowerNoneOpen")) + return + end + + XLuaUiManager.Open("UiBabelTowerTask") +end + +function XUiBabelTowerMainNew:OnActivityStatusChanged() + if not XLuaUiManager.IsUiShow("UiBabelTowerMainNew") then return end + local curActivityNo = XDataCenter.FubenBabelTowerManager.GetCurrentActivityNo() + if not curActivityNo or not XDataCenter.FubenBabelTowerManager.IsInActivityTime(curActivityNo) then + XUiManager.TipMsg(CS.XTextManager.GetText("BabelTowerNoneOpen")) + XLuaUiManager.RunMain() + end +end + +function XUiBabelTowerMainNew:CheckPlayBeginStory() + local value = XDataCenter.FubenBabelTowerManager.GetBabelTowerPrefs(XFubenBabelTowerConfigs.HAS_PLAY_BEGINSTORY, 0) + local hasPlay = value == 1 + if not hasPlay and self.CurrentActivityNo then + local storyId = XFubenBabelTowerConfigs.GetActivityBeginStory(self.CurrentActivityNo) + -- 播放剧情 + if storyId and storyId > 0 then + XDataCenter.MovieManager.PlayMovie(storyId) + end + XDataCenter.FubenBabelTowerManager.SaveBabelTowerPrefs(XFubenBabelTowerConfigs.HAS_PLAY_BEGINSTORY, 1) + end +end + +function XUiBabelTowerMainNew:RefreshAchievementTaskRedDot(count) + self.RedAchievement.gameObject:SetActive(count >= 0) +end + +function XUiBabelTowerMainNew:RefreshMainUi() + self:UpdateStageDetails() + self:UpdateStageScores() +end + +function XUiBabelTowerMainNew:UpdateStageScores() + local curScore, maxScore = XDataCenter.FubenBabelTowerManager.GetCurrentActivityScores() + self.TxtTotalLevel.text = curScore + self.TxtName.text = XFubenBabelTowerConfigs.GetActivityName(self.CurrentActivityNo) + self.TxtHighest.text = CS.XTextManager.GetText("BabelTowerCurMaxScore", maxScore) +end + +function XUiBabelTowerMainNew:UpdateStageDetails() + if not self.StageGridChapter then self.StageGridChapter = {} end + + for i = 1, #self.CurrentActivityTemplate.StageId do + local curStageId = self.CurrentActivityTemplate.StageId[i] + if not self.StageGridChapter[i] then + local go = self.PanelStageContent:Find(string.format("Stage%d", i)) + table.insert(self.StageGridChapter, XUiGridBabelStageItem.New(go, self, curStageId)) + end + self.StageGridChapter[i].GameObject:SetActiveEx(true) + self.StageGridChapter[i]:UpdateStageInfo(curStageId) + end + + for i = #self.CurrentActivityTemplate.StageId + 1, #self.StageGridChapter do + self.StageGridChapter[i].GameObject:SetActiveEx(false) + end +end + +-- 关卡点击 +function XUiBabelTowerMainNew:OnStageClick(stageId, grid) + + local isStageUnlock, desc = XDataCenter.FubenBabelTowerManager.IsBabelStageUnlock(stageId) + if not isStageUnlock then + XUiManager.TipMsg(desc) + return + end + + -- if self.SelectedGrid then + -- self.SelectedGrid:SetStageItemPress(false) + -- end + --self.SelectedGrid = grid + -- grid:SetStageItemPress(true) + local stageTemplate = XFubenBabelTowerConfigs.GetBabelTowerStageTemplate(stageId) + --如果多种难度选择 + if #stageTemplate.StageGuideId > 1 then + self:PlayScrollViewMove(grid.Transform) + else + local currentSelectGuideId = stageTemplate.StageGuideId[1] + -- 锁住return + local isUnlock = XDataCenter.FubenBabelTowerManager.IsBabelStageGuideUnlock(stageId, currentSelectGuideId) + if not isUnlock then + if not isStageUnlock then + XUiManager.TipMsg(desc) + else + XUiManager.TipMsg(CS.XTextManager.GetText("BabelTowerPassLastGuide")) + end + return + end + XLuaUiManager.Open("UiBabelTowerSelectTeam", stageId) + end +end + +function XUiBabelTowerMainNew:PlayScrollViewMove(gridTransform) + self.PanelTaskListScrollRect.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Unrestricted + local gridRect = gridTransform:GetComponent("RectTransform") + self.ViewPort.raycastTarget = false + local diffX = gridRect.localPosition.x + self.PanelStageContent.localPosition.x + if diffX < XDataCenter.FubenMainLineManager.UiGridChapterMoveMinX or diffX > XDataCenter.FubenMainLineManager.UiGridChapterMoveMaxX then + local tarPosX = XDataCenter.FubenMainLineManager.UiGridChapterMoveTargetX - gridRect.localPosition.x + local tarPos = self.PanelStageContent.localPosition + tarPos.x = tarPosX + XLuaUiManager.SetMask(true) + XUiHelper.DoMove(self.PanelStageContent, tarPos, XDataCenter.FubenMainLineManager.UiGridChapterMoveDuration, XUiHelper.EaseType.Sin, function() + XLuaUiManager.SetMask(false) + end) + end + self.PanelAsset.gameObject:SetActiveEx(false) +end + +function XUiBabelTowerMainNew:OnPanelDifficultyClose() + self.PanelTaskListScrollRect.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Elastic + self.ViewPort.raycastTarget = true + if self.CurrentActivityTemplate and self.StageGridChapter then + for i = 1, #self.CurrentActivityTemplate.StageId do + if self.StageGridChapter[i] then + self.StageGridChapter[i]:SetStageItemPress(false) + end + end + end + self.PanelAsset.gameObject:SetActiveEx(true) +end + +function XUiBabelTowerMainNew:PlayLoopBgAnimation() + if not self.IsPlayLoopBgAnimation then + return + end + + local curBgIndex = 1 + + self.Timer = self.Timer or XScheduleManager.ScheduleForever(function() + if XTool.UObjIsNil(self.GameObject) then return end + + self:PlayAnimation("DarkEnable", function() + self["Bg" .. curBgIndex].gameObject:SetActiveEx(false) + curBgIndex = SWITH_BG_INDEX[curBgIndex] + self["Bg" .. curBgIndex].gameObject:SetActiveEx(true) + self:PlayAnimation("DarkDisable") + end) + end, SWITH_BG_TIME) +end + +function XUiBabelTowerMainNew:OnCheckTaskRedPoint(count) + self.BtnAchievement:ShowReddot(count >= 0) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerMyRankInfos.lua b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerMyRankInfos.lua new file mode 100644 index 00000000..18ceb3bb --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerMyRankInfos.lua @@ -0,0 +1,34 @@ +local XUiBabelTowerMyRankInfos = XClass(nil, "XUiBabelTowerMyRankInfos") + +function XUiBabelTowerMyRankInfos:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + + XTool.InitUiObject(self) + + -- HeadIconEffect +end + +-- 刷新排名 +function XUiBabelTowerMyRankInfos:Refresh() + local _, maxScore = XDataCenter.FubenBabelTowerManager.GetCurrentActivityScores() + self.TxtPlayerName.text = XPlayer.Name + self.TxtRankScore.text = string.format(CS.XTextManager.GetText("BabelTowerMyRankLevel"), maxScore) + + XUiPLayerHead.InitPortrait(XPlayer.CurrHeadPortraitId, XPlayer.CurrHeadFrameId, self.Head) + + local curScore, curRank, totalRank = XDataCenter.FubenBabelTowerManager.GetScoreInfos() + if curRank == 0 then + self.TxtRankNormal.text = CS.XTextManager.GetText("None") + self.TxtRankNormal.text = CS.XTextManager.GetText("None") + elseif curRank <= 100 then + self.TxtRankNormal.text = curRank + else + local playerRank = (curRank * 1) / totalRank * 100 + self.TxtRankNormal.text = string.format("%s%%", math.ceil(playerRank)) + end +end + + +return XUiBabelTowerMyRankInfos \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerRankInfo.lua b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerRankInfo.lua new file mode 100644 index 00000000..6b0ca5cf --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerRankInfo.lua @@ -0,0 +1,68 @@ +local XUiBabelTowerRankInfo = XClass(nil, "XUiBabelTowerRankInfo") +local XUiBabelTowerMyRankInfos = require("XUi/XUiFubenBabelTower/XUiBabelTowerMyRankInfos") +local XUiBabelTowerRankReward = require("XUi/XUiFubenBabelTower/XUiBabelTowerRankReward") +local XUiGridRankItemInfo = require("XUi/XUiFubenBabelTower/XUiGridRankItemInfo") + + +function XUiBabelTowerRankInfo:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + + XTool.InitUiObject(self) + -- 我的排名 + self.MyRankInfos = XUiBabelTowerMyRankInfos.New(self.PanelMyBossRank, self.UiRoot) + -- 奖励 + self.RankReward = XUiBabelTowerRankReward.New(self.PanelRankReward, self.UiRoot) + + self.DynamicTable = XDynamicTableNormal.New(self.PlayerRankList.gameObject) + self.DynamicTable:SetProxy(XUiGridRankItemInfo) + self.DynamicTable:SetDelegate(self) + + -- TxtCurTime + self.BtnRankReward.CallBack = function() self:OnBtnRankRewardClick() end +end + +function XUiBabelTowerRankInfo:UpdateCurTime(timeStr) + self.TxtCurTime.text = timeStr +end + +function XUiBabelTowerRankInfo:OnDynamicTableEvent(event,index,grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self.UiRoot) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.RankInfos[index] + if not data then return end + grid:Refresh(data) + end +end + +-- 刷新排名 +function XUiBabelTowerRankInfo:Refresh() + self.CurScore, self.CurRank, self.TotalRank = XDataCenter.FubenBabelTowerManager.GetScoreInfos() + self.RankInfos = XDataCenter.FubenBabelTowerManager.GetRankInfos() + + self.DynamicTable:SetDataSource(self.RankInfos) + self.DynamicTable:ReloadDataASync() + self.PanelNoRank.gameObject:SetActiveEx(#self.RankInfos <= 0) + self.TxtIos.gameObject:SetActiveEx(false) + + self.MyRankInfos:Refresh() + + -- 更新奖励按钮 + self.BtnRankReward.gameObject:SetActiveEx(false) + self.RewardText.gameObject:SetActiveEx(false) + local activityNo = XDataCenter.FubenBabelTowerManager.GetCurrentActivityNo() + if not activityNo then return end + local activityTemplate = XFubenBabelTowerConfigs.GetBabelTowerActivityTemplateById(activityNo) + if not activityTemplate then return end + self.BtnRankReward.gameObject:SetActiveEx(activityTemplate.RankType == XFubenBabelTowerConfigs.RankType.RankAndReward) + self.RewardText.gameObject:SetActiveEx(activityTemplate.RankType == XFubenBabelTowerConfigs.RankType.OnlyRank) + +end + +function XUiBabelTowerRankInfo:OnBtnRankRewardClick() + self.RankReward:Refresh() +end + +return XUiBabelTowerRankInfo \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerRankReward.lua b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerRankReward.lua new file mode 100644 index 00000000..1bb952f2 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerRankReward.lua @@ -0,0 +1,56 @@ +local XUiBabelTowerRankReward = XClass(nil, "XUiBabelTowerRankReward") +local XUiGridRankRewardItem = require("XUi/XUiFubenBabelTower/XUiGridRankRewardItem") + + +function XUiBabelTowerRankReward:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + + XTool.InitUiObject(self) + + self.DynamicTable = XDynamicTableNormal.New(self.List.gameObject) + self.DynamicTable:SetProxy(XUiGridRankRewardItem) + self.DynamicTable:SetDelegate(self) + + self.BtnBlock.CallBack = function() self:OnBtnBlockClick() end + self.BtnTanchuangClose.CallBack = function() self:OnBtnTanchuangClose() end + +end + +function XUiBabelTowerRankReward:OnDynamicTableEvent(event,index,grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self.UiRoot) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.RankRewards[index] + if not data then return end + grid:Refresh(data) + end +end + +-- 刷新排名 +function XUiBabelTowerRankReward:Refresh() + self.GameObject:SetActiveEx(true) + local rankLevel = XDataCenter.FubenBabelTowerManager.GetRankLevel() + if rankLevel <= 0 then return end + self.RankRewards = XFubenBabelTowerConfigs.GetBabelTowerRankReward(rankLevel) + self.DynamicTable:SetDataSource(self.RankRewards) + self.DynamicTable:ReloadDataASync() + + if self.TxtRankTitle then + local activityNo = XDataCenter.FubenBabelTowerManager.GetCurrentActivityNo() + if activityNo and activityNo > 0 then + self.TxtRankTitle.text = XFubenBabelTowerConfigs.GetActivityRankTitle(activityNo) + end + end +end + +function XUiBabelTowerRankReward:OnBtnBlockClick() + self.GameObject:SetActiveEx(false) +end + +function XUiBabelTowerRankReward:OnBtnTanchuangClose() + self.GameObject:SetActiveEx(false) +end + +return XUiBabelTowerRankReward \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerRoomCharacter.lua b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerRoomCharacter.lua new file mode 100644 index 00000000..511cf65d --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerRoomCharacter.lua @@ -0,0 +1,541 @@ +local CSXTextManagerGetText = CS.XTextManager.GetText + +local TabBtnIndex = { + Normal = 1, + Isomer = 2, +} +local CharacterTypeConvert = { + [TabBtnIndex.Normal] = XCharacterConfigs.CharacterType.Normal, + [TabBtnIndex.Isomer] = XCharacterConfigs.CharacterType.Isomer, +} +local TabBtnIndexConvert = { + [XCharacterConfigs.CharacterType.Normal] = TabBtnIndex.Normal, + [XCharacterConfigs.CharacterType.Isomer] = TabBtnIndex.Isomer, +} + +local XUiBabelTowerRoomCharacter = XLuaUiManager.Register(XLuaUi, "UiBabelTowerRoomCharacter") + +function XUiBabelTowerRoomCharacter:OnAwake() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + + self.BtnFashion.CallBack = function() self:OnBtnFashionClick() end + self.BtnConsciousness.CallBack = function() self:OnBtnConsciousnessClick() end + self.BtnWeapon.CallBack = function() self:OnBtnWeaponClick() end + self.BtnJoinTeam.CallBack = function() self:OnBtnJoinTeamClick() end + self.BtnQuitTeam.CallBack = function() self:OnBtnQuitTeamClick() end + self.BtnPartner.CallBack = function() self:OnBtnPartnerClick() end + self.BtnFilter.CallBack = function() + self:OnBtnFilterClick() + end + + self.GridIndex = {} + self.TagCacheDic = {} + self.SortFunction = {} + self.SortFunction[XRoomCharFilterTipsConfigs.EnumSortTag.Default] = function(leftCharacter, rightCharacter) + local leftInTeam = self:IsInTeam(leftCharacter.Id) + local rightInTeam = self:IsInTeam(rightCharacter.Id) + + if leftInTeam ~= rightInTeam then + return leftInTeam + end + + return leftCharacter.Ability > rightCharacter.Ability + end + self.SortFunction[XRoomCharFilterTipsConfigs.EnumSortTag.Quality] = function(leftCharacter, rightCharacter) + local leftQuality = leftCharacter.Quality + local rightQuality = rightCharacter.Quality + if leftQuality ~= rightQuality then + return leftQuality > rightQuality + end + return self.SortFunction[XRoomCharFilterTipsConfigs.EnumSortTag.Default](leftCharacter, rightCharacter) + end + self.SortFunction[XRoomCharFilterTipsConfigs.EnumSortTag.Level] = function(leftCharacter, rightCharacter) + local leftLevel = leftCharacter.Level + local rightLevel = rightCharacter.Level + if leftLevel ~= rightLevel then + return leftLevel > rightLevel + end + return self.SortFunction[XRoomCharFilterTipsConfigs.EnumSortTag.Default](leftCharacter, rightCharacter) + end + self.SortFunction[XRoomCharFilterTipsConfigs.EnumSortTag.Ability] = function(leftCharacter, rightCharacter) + return leftCharacter.Ability > rightCharacter.Ability + end + + local root = self.UiModelGo.transform + self.PanelRoleModel = root:FindTransform("PanelRoleModel") + self.ImgEffectHuanren = root:FindTransform("ImgEffectHuanren") + self.ImgEffectHuanren1 = root:FindTransform("ImgEffectHuanren1") + + self.GridCharacter.gameObject:SetActiveEx(false) + + self.CharacterGrids = {} +end + +function XUiBabelTowerRoomCharacter:OnStart(args, cb) + self.RoleModelPanel = XUiPanelRoleModel.New(self.PanelRoleModel, nil, nil, true) + self.StageId = args.StageId + self.TeamId = args.TeamId + self.StageCfg = XDataCenter.FubenManager.GetStageCfg(self.StageId) + self.TeamSelectPos = args.Index + self.BanCharacters = {} + self.TeamCharIdMap = args.CurTeamList + self.CharacterLimitType = args.CharacterLimitType + self.LimitBuffId = args.LimitBuffId + self.TeamResultCb = cb + + self:InitRequireCharacterInfo() + self:InitCharacterTypeBtns() +end + +function XUiBabelTowerRoomCharacter:OnEnable() + self:OnCharacterClick() +end + +function XUiBabelTowerRoomCharacter:InitRequireCharacterInfo() + local characterLimitType = self.CharacterLimitType + + if not XFubenConfigs.IsStageCharacterLimitConfigExist(characterLimitType) then + self.PanelRequireCharacter.gameObject:SetActiveEx(false) + return + else + self.PanelRequireCharacter.gameObject:SetActiveEx(true) + end + + local icon = XFubenConfigs.GetStageCharacterLimitImageTeamEdit(characterLimitType) + self.ImgRequireCharacter:SetSprite(icon) +end + +function XUiBabelTowerRoomCharacter:RefreshCharacterTypeTips() + local limitBuffId = self.LimitBuffId + local characterType = CharacterTypeConvert[self.SelectTabBtnIndex] + local characterLimitType = self.CharacterLimitType + local text = XFubenConfigs.GetStageCharacterLimitTextSelectCharacter(characterLimitType, characterType, limitBuffId) + self.TxtRequireCharacter.text = text +end + +function XUiBabelTowerRoomCharacter:ResetTeamData() + self.TeamCharIdMap = { 0, 0, 0 } +end + +function XUiBabelTowerRoomCharacter:InitCharacterTypeBtns() + self.BtnTabShougezhe.gameObject:SetActiveEx(not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.Isomer)) + + local tabBtns = { self.BtnTabGouzaoti, self.BtnTabShougezhe } + self.PanelCharacterTypeBtns:Init(tabBtns, function(index) self:TrySelectCharacterType(index) end) + + local characterLimitType = self.CharacterLimitType + local lockGouzaoti = characterLimitType == XFubenConfigs.CharacterLimitType.Isomer + local lockShougezhe = not XFunctionManager.JudgeOpen(XFunctionManager.FunctionName.Isomer) or characterLimitType == XFubenConfigs.CharacterLimitType.Normal + self.BtnTabGouzaoti:SetDisable(lockGouzaoti) + self.BtnTabShougezhe:SetDisable(lockShougezhe) + + --检查选择角色类型是否和副本限制类型冲突 + local characterType = XDataCenter.FubenManager.GetDefaultCharacterTypeByCharacterLimitType(self.CharacterLimitType) + local tempCharacterType = self:GetTeamCharacterType() + if tempCharacterType and not (tempCharacterType == XCharacterConfigs.CharacterType.Normal and lockGouzaoti + or tempCharacterType == XCharacterConfigs.CharacterType.Isomer and lockShougezhe) then + characterType = tempCharacterType + end + self.PanelCharacterTypeBtns:SelectIndex(TabBtnIndexConvert[characterType]) +end + +function XUiBabelTowerRoomCharacter:TrySelectCharacterType(index) + local characterType = CharacterTypeConvert[index] + if characterType == XCharacterConfigs.CharacterType.Isomer and not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.Isomer) then return end + + local characterLimitType = self.CharacterLimitType + if characterLimitType == XFubenConfigs.CharacterLimitType.Normal then + if characterType == XCharacterConfigs.CharacterType.Isomer then + XUiManager.TipText("TeamSelectCharacterTypeLimitTipNormal") + return + end + elseif characterLimitType == XFubenConfigs.CharacterLimitType.Isomer then + if characterType == XCharacterConfigs.CharacterType.Normal then + XUiManager.TipText("TeamSelectCharacterTypeLimitTipIsomer") + return + end + -- elseif characterLimitType == XFubenConfigs.CharacterLimitType.IsomerDebuff then + -- if characterType == XCharacterConfigs.CharacterType.Isomer then + -- local buffDes = XFubenConfigs.GetBuffDes(self.LimitBuffId) + -- local content = CSXTextManagerGetText("TeamSelectCharacterTypeLimitTipIsomerDebuff", buffDes) + -- local sureCallBack = function() + -- self:OnSelectCharacterType(index) + -- end + -- local closeCallback = function() + -- self.PanelCharacterTypeBtns:SelectIndex(TabBtnIndexConvert[XCharacterConfigs.CharacterType.Normal]) + -- end + -- XUiManager.DialogTip(nil, content, XUiManager.DialogType.Normal, closeCallback, sureCallBack) + -- return + -- end + -- elseif characterLimitType == XFubenConfigs.CharacterLimitType.NormalDebuff then + -- if characterType == XCharacterConfigs.CharacterType.Normal then + -- local buffDes = XFubenConfigs.GetBuffDes(self.LimitBuffId) + -- local content = CSXTextManagerGetText("TeamSelectCharacterTypeLimitTipNormalDebuff", buffDes) + -- local sureCallBack = function() + -- self:OnSelectCharacterType(index) + -- end + -- local closeCallback = function() + -- self.PanelCharacterTypeBtns:SelectIndex(TabBtnIndexConvert[XCharacterConfigs.CharacterType.Isomer]) + -- end + -- XUiManager.DialogTip(nil, content, XUiManager.DialogType.Normal, closeCallback, sureCallBack) + -- return + -- end + end + + self:OnSelectCharacterType(index) +end + +function XUiBabelTowerRoomCharacter:OnSelectCharacterType(index) + if self.SelectTabBtnIndex == index then return end + self.SelectTabBtnIndex = index + XDataCenter.RoomCharFilterTipsManager.Reset() + + local characterType = CharacterTypeConvert[index] + local charlist = XDataCenter.CharacterManager.GetOwnCharacterList(characterType) + table.sort(charlist,self.SortFunction[XRoomCharFilterTipsConfigs.EnumSortTag.Default]) + + self:RefreshCharacterTypeTips() + self:UpdateCharacterList(charlist) +end + +function XUiBabelTowerRoomCharacter:SetPanelEmptyList(isEmpty) + self.BtnQuitTeam.gameObject:SetActiveEx(false) + self.BtnJoinTeam.gameObject:SetActiveEx(false) + + self.BtnConsciousness.gameObject:SetActiveEx(not isEmpty) + self.BtnFashion.gameObject:SetActiveEx(not isEmpty) + self.BtnWeapon.gameObject:SetActiveEx(not isEmpty) + self.BtnPartner.gameObject:SetActiveEx(not isEmpty) + + self.PanelRoleContent.gameObject:SetActiveEx(not isEmpty) + self.PanelRoleModel.gameObject:SetActiveEx(not isEmpty) + self.PanelEmptyList.gameObject:SetActiveEx(isEmpty) +end + +function XUiBabelTowerRoomCharacter:UpdateCharacterList(charlist) + if not next(charlist) then + self:SetPanelEmptyList(true) + return + end + self:SetPanelEmptyList(false) + + for _, item in pairs(self.CharacterGrids) do + item:Reset() + end + + self.CharacterGrids = {} + local charDic = {} + + for i = 1, #charlist do + local char = charlist[i] + local characterId = char.Id + charDic[characterId] = char + + local grid = self.GridIndex[i] + if not grid then + local item = CS.UnityEngine.Object.Instantiate(self.GridCharacter) + grid = XUiGridCharacter.New(item, self, char, function(character) + self:OnCharacterClick(character) + end) + grid.Transform:SetParent(self.PanelRoleContent, false) + self.GridIndex[i] = grid + end + + grid:UpdateGrid(char) + grid:SetInTeam(false) + -- 被禁用 + grid:SetLimited(self.BanCharacters[characterId]) + -- 被限制锁定 + grid:SetIsLock(not self.BanCharacters[characterId] and XDataCenter.FubenBabelTowerManager.IsCharacterLockByStageId(characterId, self.StageId, self.TeamId)) + grid.GameObject:SetActiveEx(true) + self.CharacterGrids[characterId] = self.GridIndex[i] + end + + local teamCharIdMap = self.TeamCharIdMap + local teamSelectPos = self.TeamSelectPos + + for _, characterId in pairs(teamCharIdMap) do + local grid = self.CharacterGrids[characterId] + if grid then + grid:SetInTeam(true) + end + end + + local selectId = teamCharIdMap[teamSelectPos] + local characterType = CharacterTypeConvert[self.SelectTabBtnIndex] + + if not selectId or selectId == 0 + or not self.CharacterGrids[selectId] + or characterType ~= XCharacterConfigs.GetCharacterType(selectId) + or not charDic[selectId] + then + selectId = charlist[1].Id + end + self:SelectCharacter(selectId) +end + +function XUiBabelTowerRoomCharacter:IsInTeam(characterId) + for _, v in pairs(self.TeamCharIdMap) do + if v == characterId then + return true + end + end + return false +end + +function XUiBabelTowerRoomCharacter:OnCharacterClick(character) + if character then + self.CurCharacter = character + end + if not self.CurCharacter then return end + + if self.CurCharacterItem then + self.CurCharacterItem:SetSelect(false) + end + + self.CurCharacterItem = self.CharacterGrids[self.CurCharacter.Id] + self.CurCharacterItem:UpdateGrid() + self.CurCharacterItem:SetSelect(true) + self.CurCharacterItem:SetLimited(self.BanCharacters[self.CurCharacter.Id]) + self.CurCharacterItem:SetIsLock(not self.BanCharacters[self.CurCharacter.Id] and XDataCenter.FubenBabelTowerManager.IsCharacterLockByStageId(self.CurCharacter.Id, self.StageId, self.TeamId)) + + self:CenterToGrid(self.CurCharacterItem) + + -- 更新按钮状态 + self:UpdateBtns(self.CurCharacter.Id) + self:UpdateRoleMode(self.CurCharacter.Id) +end + +-- 更新按钮状态 +function XUiBabelTowerRoomCharacter:UpdateBtns(curCharacterId) + local isInTeam = false + for _, member_char_id in pairs(self.TeamCharIdMap or {}) do + if curCharacterId == member_char_id then + isInTeam = true + break + end + end + local oldMemberId = self.TeamCharIdMap[self.TeamSelectPos] + local hasOldMember = oldMemberId ~= nil and oldMemberId ~= 0 + local isJoin = true + if hasOldMember and isInTeam and oldMemberId == curCharacterId then + isJoin = false + end + + local isLock = XDataCenter.FubenBabelTowerManager.IsCharacterLockByStageId(curCharacterId, self.StageId, self.TeamId) + local isBan = self.BanCharacters[curCharacterId] + -- 点击有角色的位置 + -- 选择的人在队伍中 + -- 选择的人是当前角色-卸下 + -- 选择的人不是当前角色-替换 + -- 选择的人不在队伍中-替换 + -- 点击无角色的位置 + -- 选择的人在队伍中-替换 + -- 选择的人不在队伍中-上阵 + self.BtnLimit.gameObject:SetActiveEx(isBan) + self.BtnLock.gameObject:SetActiveEx(not isBan and isLock) + if isLock or isBan then + self.BtnJoinTeam.gameObject:SetActiveEx(false) + self.BtnQuitTeam.gameObject:SetActiveEx(false) + else + self.BtnJoinTeam.gameObject:SetActiveEx(isJoin) + self.BtnQuitTeam.gameObject:SetActiveEx(not isJoin) + end +end + +--更新模型 +function XUiBabelTowerRoomCharacter:UpdateRoleMode(characterId) + self.ImgEffectHuanren.gameObject:SetActiveEx(false) + self.ImgEffectHuanren1.gameObject:SetActiveEx(false) + self.RoleModelPanel:UpdateCharacterModel(characterId, self.PanelRoleModel, XModelManager.MODEL_UINAME.XUiBabelTowerRoomCharacter, function(model) + if not model then return end + self.PanelDrag.Target = model.transform + if self.SelectTabBtnIndex == TabBtnIndex.Normal then + self.ImgEffectHuanren.gameObject:SetActiveEx(true) + elseif self.SelectTabBtnIndex == TabBtnIndex.Isomer then + self.ImgEffectHuanren1.gameObject:SetActiveEx(true) + end + end) +end + +-- 选一个角色 +function XUiBabelTowerRoomCharacter:SelectCharacter(id) + local grid = self.CharacterGrids[id] + local character = grid and grid.Character + self:OnCharacterClick(character) +end + +function XUiBabelTowerRoomCharacter:CenterToGrid(grid) + -- local normalizedPosition + -- local count = self.SViewCharacterList.content.transform.childCount + -- local index = grid.Transform:GetSiblingIndex() + -- if index > count / 2 then + -- normalizedPosition = (index + 1) / count + -- else + -- normalizedPosition = (index - 1) / count + -- end + -- self.SViewCharacterList.verticalNormalizedPosition = math.max(0, math.min(1, (1 - normalizedPosition))) +end + +function XUiBabelTowerRoomCharacter:OnBtnBackClick() + if self.TeamResultCb then + self.TeamResultCb(self.TeamCharIdMap) + end + self:Close() +end + +function XUiBabelTowerRoomCharacter:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiBabelTowerRoomCharacter:OnBtnFashionClick() + if not self.CurCharacter then return end + XLuaUiManager.Open("UiFashion", self.CurCharacter.Id) +end + +function XUiBabelTowerRoomCharacter:OnBtnConsciousnessClick() + if not self.CurCharacter then return end + XLuaUiManager.Open("UiEquipAwarenessReplace", self.CurCharacter.Id, nil, true) +end + +function XUiBabelTowerRoomCharacter:OnBtnWeaponClick() + if not self.CurCharacter then return end + XLuaUiManager.Open("UiEquipReplaceNew", self.CurCharacter.Id, nil, true) +end + +function XUiBabelTowerRoomCharacter:OnBtnPartnerClick() + XDataCenter.PartnerManager.GoPartnerCarry(self.CurCharacter.Id, false) +end + +-- 加入队伍 +function XUiBabelTowerRoomCharacter:OnBtnJoinTeamClick() + if not self.CurCharacter then return end + + local selectId = self.CurCharacter.Id + + local joinFunc = function(isReset) + if isReset then + self:ResetTeamData() + else + for k, v in pairs(self.TeamCharIdMap) do + if v == selectId then + self.TeamCharIdMap[k] = 0 + break + end + end + end + + self.TeamCharIdMap[self.TeamSelectPos] = selectId + + if self.TeamResultCb then + self.TeamResultCb(self.TeamCharIdMap) + end + + self:Close() + end + + -- 角色类型不一致拦截 + local inTeamCharacterType = self:GetTeamCharacterType() + if inTeamCharacterType then + local characterType = XCharacterConfigs.GetCharacterType(selectId) + if characterType and characterType ~= inTeamCharacterType then + local content = CSXTextManagerGetText("TeamCharacterTypeNotSame") + local sureCallBack = function() + local isReset = true + joinFunc(isReset) + end + XUiManager.DialogTip(nil, content, XUiManager.DialogType.Normal, nil, sureCallBack) + return + end + end + + joinFunc() +end + +-- 移出队伍 +function XUiBabelTowerRoomCharacter:OnBtnQuitTeamClick() + if not self.CurCharacter then return end + + local count = 0 + for _, v in pairs(self.TeamCharIdMap) do + if v > 0 then + count = count + 1 + end + end + + local id = self.CurCharacter.Id + for k, v in pairs(self.TeamCharIdMap) do + if v == id then + self.TeamCharIdMap[k] = 0 + break + end + end + + if self.TeamResultCb then + self.TeamResultCb(self.TeamCharIdMap) + end + + self:Close() +end + +function XUiBabelTowerRoomCharacter:OnBtnFilterClick() + local characterType = CharacterTypeConvert[self.SelectTabBtnIndex] + XLuaUiManager.Open("UiRoomCharacterFilterTips", + self, + XRoomCharFilterTipsConfigs.EnumFilterType.BabelTower, + XRoomCharFilterTipsConfigs.EnumSortType.BabelTower, + characterType) +end + +function XUiBabelTowerRoomCharacter:GetTeamCharacterType() + for k, v in pairs(self.TeamCharIdMap) do + if v ~= 0 then + return XCharacterConfigs.GetCharacterType(v) + end + end +end + +function XUiBabelTowerRoomCharacter:Filter(selectTagGroupDic, sortTagId, isThereFilterDataCb) + local judgeCb = function(groupId, tagValue, character) + local detailConfig = XCharacterConfigs.GetCharDetailTemplate(character.Id) + + local compareValue + if groupId == XRoomCharFilterTipsConfigs.EnumFilterTagGroup.Career then + compareValue = detailConfig.Career + if compareValue == tagValue then + -- 当前角色满足该标签 + return true + end + elseif groupId == XRoomCharFilterTipsConfigs.EnumFilterTagGroup.Element then + compareValue = detailConfig.ObtainElementList + for _, element in pairs(compareValue) do + if element == tagValue then + -- 当前角色满足该标签 + return true + end + end + else + XLog.Error(string.format("XUiBfrtRoomCharacter:Filter函数错误,没有处理排序组:%s的逻辑", groupId)) + return + end + end + + local allChar = XDataCenter.CharacterManager.GetOwnCharacterList(CharacterTypeConvert[self.SelectTabBtnIndex]) + XDataCenter.RoomCharFilterTipsManager.Filter(self.TagCacheDic, selectTagGroupDic, allChar, judgeCb, + function(filteredData) + self:FilterRefresh(filteredData, sortTagId) + end, + isThereFilterDataCb) +end + +function XUiBabelTowerRoomCharacter:FilterRefresh(filteredData, sortTagId) + if self.SortFunction[sortTagId] then + table.sort(filteredData, self.SortFunction[sortTagId]) + else + XLog.Error(string.format("XUiBfrtRoomCharacter:FilterRefresh函数错误,没有定义标签:%s的排序函数", sortTagId)) + return + end + self:UpdateCharacterList(filteredData) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerSelectDiffcult.lua b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerSelectDiffcult.lua new file mode 100644 index 00000000..d8ff8bef --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerSelectDiffcult.lua @@ -0,0 +1,38 @@ +local XUiGridBabelSelectDifficult = require("XUi/XUiFubenBabelTower/XUiGridBabelSelectDifficult") + +local XUiBabelTowerSelectDiffcult = XLuaUiManager.Register(XLuaUi, "UiBabelTowerSelectDiffcult") + +function XUiBabelTowerSelectDiffcult:OnAwake() + self.BtnTanchuangCloseBig.CallBack = function() self:Close() end + + self.DynamicTableSupportConditon = XDynamicTableNormal.New(self.PanelCondition) + self.DynamicTableSupportConditon:SetProxy(XUiGridBabelSelectDifficult) + self.DynamicTableSupportConditon:SetDelegate(self) + + self.GridCondition.gameObject:SetActiveEx(false) +end + +function XUiBabelTowerSelectDiffcult:OnStart(stageId, teamId, closeCb) + self.StageId = stageId + self.TeamId = teamId + self.CloseCb = closeCb +end + +function XUiBabelTowerSelectDiffcult:OnEnable() + local selectDifficult = XDataCenter.FubenBabelTowerManager.GetTeamSelectDifficult(self.StageId, self.TeamId) + self.DifficultConfigs = XFubenBabelTowerConfigs.GetStageDifficultConfigs(self.StageId, selectDifficult) + self.DynamicTableSupportConditon:SetDataSource(self.DifficultConfigs) + self.DynamicTableSupportConditon:ReloadDataASync() +end + +function XUiBabelTowerSelectDiffcult:OnDestroy() + if self.CloseCb then self.CloseCb() end +end + +function XUiBabelTowerSelectDiffcult:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:InitRootUi(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:Refresh(self.StageId, self.TeamId, self.DifficultConfigs[index]) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerSelectTeam.lua b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerSelectTeam.lua new file mode 100644 index 00000000..f9a12d11 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerSelectTeam.lua @@ -0,0 +1,41 @@ +local XUiGridBabelSelectTeam = require("XUi/XUiFubenBabelTower/XUiGridBabelSelectTeam") + +local XUiBabelTowerSelectTeam = XLuaUiManager.Register(XLuaUi, "UiBabelTowerSelectTeam") + +function XUiBabelTowerSelectTeam:OnAwake() + self.BtnTanchuangCloseBig.CallBack = function() self:Close() end + + self.DynamicTableSupportConditon = XDynamicTableNormal.New(self.PanelCondition) + self.DynamicTableSupportConditon:SetProxy(XUiGridBabelSelectTeam) + self.DynamicTableSupportConditon:SetDelegate(self) + + self.GridCondition.gameObject:SetActiveEx(false) +end + +function XUiBabelTowerSelectTeam:OnStart(stageId) + self.StageId = stageId + local lastOpenStageId = XDataCenter.FubenBabelTowerManager.GetLastOpenStageId() + if lastOpenStageId ~= nil then + XDataCenter.FubenBabelTowerManager.ClearTeamChace(lastOpenStageId) + end + XDataCenter.FubenBabelTowerManager.SetLastOpenStageId(stageId) +end + +-- function XUiBabelTowerSelectTeam:OnDestroy() +-- XDataCenter.FubenBabelTowerManager.ClearTeamChace(self.StageId) +-- end + +function XUiBabelTowerSelectTeam:OnEnable() + self.TeamIdList = XDataCenter.FubenBabelTowerManager.GetStageTeamIdList(self.StageId) + self.DynamicTableSupportConditon:SetDataSource(self.TeamIdList) + self.DynamicTableSupportConditon:ReloadDataASync() +end + +function XUiBabelTowerSelectTeam:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + -- grid:Init(function() self:Close() end) + grid:Init() + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:Refresh(self.StageId, self.TeamIdList[index]) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerSupportChoice.lua b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerSupportChoice.lua new file mode 100644 index 00000000..425feee9 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerSupportChoice.lua @@ -0,0 +1,116 @@ +local XUiBabelTowerSupportChoice = XClass(nil, "XUiBabelTowerSupportChoice") +local UiButtonState = CS.UiButtonState +local XUiGridBabelChallengeItem = require("XUi/XUiFubenBabelTower/XUiGridBabelChallengeItem") + +function XUiBabelTowerSupportChoice:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.name = "XUiBabelTowerSupportChoice" + + XTool.InitUiObject(self) + self.SupportItemList = {} + self.SupportBtnCompList = {} +end + +function XUiBabelTowerSupportChoice:Init(uiRoot) + self.UiRoot = uiRoot +end + +function XUiBabelTowerSupportChoice:SetItemData(itemData) + self.BuffGoupDatas = itemData + self.BuffGroupId = itemData.BuffGroupId + self.GuideId = itemData.GuideId + self.StageId = itemData.StageId + self.BuffGroupDetails = XFubenBabelTowerConfigs.GetBabelBuffGroupConfigs(self.BuffGroupId) + self.BuffGroupTemplate = XFubenBabelTowerConfigs.GetBabelTowerBuffGroupTemplate(self.BuffGroupId) + self.TxtSupportName.text = self.BuffGroupDetails.Name + self:InitSupportList() + self:UpdateGridChoiceState(self.UiRoot:GetAvailableSupportPoint()) +end + +function XUiBabelTowerSupportChoice:InitSupportList() + for i=1, #self.BuffGroupTemplate.BuffId do + local buffId = self.BuffGroupTemplate.BuffId[i] + local buffTemplate = XFubenBabelTowerConfigs.GetBabelTowerBuffTemplate(buffId) + local buffConfigs = XFubenBabelTowerConfigs.GetBabelBuffConfigs(buffId) + if not self.SupportItemList[i] then + local go = CS.UnityEngine.Object.Instantiate(self.GridChallenge) + go.transform:SetParent(self.GridContent.transform, false) + self.SupportItemList[i] = XUiGridBabelChallengeItem.New(go, self, i, XFubenBabelTowerConfigs.TYPE_SUPPORT) + end + self.SupportItemList[i].GameObject:SetActiveEx(true) + self.SupportItemList[i]:UpdateBuff(buffTemplate, buffConfigs, i, XFubenBabelTowerConfigs.TYPE_SUPPORT) + self.SupportBtnCompList[i] = self.SupportItemList[i]:GetXUiButtonComp() + end + + self.GridContent:Init(self.SupportBtnCompList, function(index) self:OnSupportChoiceItemClick(index) end) + self.GridContent.CanDisSelect = true + self.GridContent.CurSelectId = self.BuffGoupDatas.CurSelectId + + for i= #self.BuffGroupTemplate.BuffId + 1, #self.SupportItemList do + self.SupportItemList[i].GameObject:SetActiveEx(false) + end +end + +-- 保存更新buff选中状态 +function XUiBabelTowerSupportChoice:OnSupportChoiceItemClick(index) + -- 取消选中 + -- 选中 + -- 点数不足不可选中 + + local lastSelctBuffId = self.BuffGoupDatas.SelectedBuffId + local currentSelectBuffId = self.BuffGroupTemplate.BuffId[index] + if self.BuffGoupDatas.SelectedBuffId == currentSelectBuffId then + + self.BuffGoupDatas.SelectedBuffId = nil + self.BuffGoupDatas.CurSelectId = -1 + self.UiRoot:UpdateChoosedChallengeDatas(self.BuffGroupId, self.BuffGoupDatas.SelectedBuffId) + else + + local curbuffTemplate = XFubenBabelTowerConfigs.GetBabelTowerBuffTemplate(currentSelectBuffId) + local lastPointSub = 0 + if lastSelctBuffId then + local lastbuffTemplate = XFubenBabelTowerConfigs.GetBabelTowerBuffTemplate(lastSelctBuffId) + lastPointSub = lastbuffTemplate.PointSub + end + if curbuffTemplate.PointSub > self.UiRoot:GetAvailableSupportPoint() + lastPointSub then return end + + self.BuffGoupDatas.SelectedBuffId = currentSelectBuffId + self.BuffGoupDatas.CurSelectId = index + self.UiRoot:UpdateChoosedChallengeDatas(self.BuffGroupId, self.BuffGoupDatas.SelectedBuffId) + end +end + +function XUiBabelTowerSupportChoice:GetBuffSelectStatus(buffId) + if not self.BuffGoupDatas then return false end + return self.BuffGoupDatas.SelectedBuffId == buffId +end + +function XUiBabelTowerSupportChoice:IsBuffListOverCount() + if not self.BuffGoupDatas then return false end + return self.BuffGoupDatas.IsOverCount +end + +-- 更新未选中buff可选状态 +function XUiBabelTowerSupportChoice:UpdateGridChoiceState(availableSupportPoint) + if self.BuffGoupDatas.SelectedBuffId then + local lastBuffTemplate = XFubenBabelTowerConfigs.GetBabelTowerBuffTemplate(self.BuffGoupDatas.SelectedBuffId) + availableSupportPoint = availableSupportPoint + lastBuffTemplate.PointSub + end + self.GridContent.CurSelectId = self.BuffGoupDatas.CurSelectId + for i=1, #self.BuffGroupTemplate.BuffId do + local buffId = self.BuffGroupTemplate.BuffId[i] + local buffTemplate = XFubenBabelTowerConfigs.GetBabelTowerBuffTemplate(buffId) + + -- 没有被选中的 + if not self:GetBuffSelectStatus(buffId) and self.SupportBtnCompList[i] then + local btnStatus = (availableSupportPoint >= buffTemplate.PointSub) and UiButtonState.Normal or UiButtonState.Disable + self.SupportBtnCompList[i]:SetButtonState(btnStatus) + self.SupportItemList[i]:ShowOverCount(false) + else + self.SupportItemList[i]:ShowOverCount(self:IsBuffListOverCount()) + end + end +end + +return XUiBabelTowerSupportChoice \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerTask.lua b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerTask.lua new file mode 100644 index 00000000..3589b37e --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerTask.lua @@ -0,0 +1,135 @@ +local XUiBabelTowerTask = XLuaUiManager.Register(XLuaUi, "UiBabelTowerTask") + +function XUiBabelTowerTask:OnAwake() + self.AssetPanel = XUiPanelAsset.New( + self, + self.PanelAsset, + XDataCenter.ItemManager.ItemId.FreeGem, + XDataCenter.ItemManager.ItemId.ActionPoint, + XDataCenter.ItemManager.ItemId.Coin + ) + self.BtnBack.CallBack = function() + self:OnBtnBackClick() + end + self.BtnMainUi.CallBack = function() + self:OnBtnMainUiClick() + end + + self.DynamicTable = XDynamicTableNormal.New(self.SViewTask.gameObject) + self.DynamicTable:SetProxy(XDynamicGridTask) + self.DynamicTable:SetDelegate(self) + + XEventManager.AddEventListener(XEventId.EVENT_BABEL_ACTIVITY_STATUS_CHANGED, self.CheckActivityStatus, self) + XEventManager.AddEventListener(XEventId.EVENT_TASK_SYNC, self.OnTaskChangeSync, self) +end + +function XUiBabelTowerTask:OnDestroy() + self:StopCountDown() + XEventManager.RemoveEventListener(XEventId.EVENT_BABEL_ACTIVITY_STATUS_CHANGED, self.CheckActivityStatus, self) + XEventManager.RemoveEventListener(XEventId.EVENT_TASK_SYNC, self.OnTaskChangeSync, self) +end + +function XUiBabelTowerTask:OnBtnBackClick() + self:Close() +end + +function XUiBabelTowerTask:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiBabelTowerTask:OnStart() + self:OnTaskChangeSync() + self:CreateCountDown() +end + +function XUiBabelTowerTask:CreateCountDown() + self:StopCountDown() + local time = XTime.GetServerNowTimestamp() + local curActivityNo = XDataCenter.FubenBabelTowerManager.GetCurrentActivityNo() + if not curActivityNo then + return + end + local activityTemplate = XFubenBabelTowerConfigs.GetBabelTowerActivityTemplateById(curActivityNo) + if not activityTemplate then + return + end + + local endTime = XFunctionManager.GetEndTimeByTimeId(activityTemplate.ActivityTimeId) + if not endTime then + return + end + local leftTimeDesc = CS.XTextManager.GetText("BabelTowerLeftTimeDesc") + self.TxtTime.text = string.format("%s%s", leftTimeDesc, XUiHelper.GetTime(endTime - time, XUiHelper.TimeFormatType.ACTIVITY)) + self.Timer = XScheduleManager.ScheduleForever( + function() + time = XTime.GetServerNowTimestamp() + if time > endTime then + self:StopCountDown() + return + end + self.TxtTime.text = string.format( + "%s%s", + leftTimeDesc, + XUiHelper.GetTime(endTime - time, XUiHelper.TimeFormatType.ACTIVITY) + ) + end, + XScheduleManager.SECOND, + 0 + ) +end + +function XUiBabelTowerTask:StopCountDown() + if self.Timer ~= nil then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end + +function XUiBabelTowerTask:OnEnable() + self:CheckActivityStatus() +end + +function XUiBabelTowerTask:CheckActivityStatus() + if not XLuaUiManager.IsUiShow("UiBabelTowerTask") then + return + end + local curActivityNo = XDataCenter.FubenBabelTowerManager.GetCurrentActivityNo() + if not curActivityNo or not XDataCenter.FubenBabelTowerManager.IsInActivityTime(curActivityNo) then + XUiManager.TipMsg(CS.XTextManager.GetText("BabelTowerNoneOpen")) + XLuaUiManager.RunMain() + end +end + +function XUiBabelTowerTask:OnTaskChangeSync() + self.BabelTowerTasks = XDataCenter.TaskManager.GetBabelTowerFullTaskList() + for _, v in pairs(self.BabelTowerTasks or {}) do + v.SortWeight = 2 + if v.State == XDataCenter.TaskManager.TaskState.Achieved then + v.SortWeight = 1 + elseif v.State == XDataCenter.TaskManager.TaskState.Finish or v.State == XDataCenter.TaskManager.TaskState.Invalid then + v.SortWeight = 3 + end + end + + table.sort(self.BabelTowerTasks, function(taskA, taskB) + if taskA.SortWeight == taskB.SortWeight then + return taskA.Id < taskB.Id + end + return taskA.SortWeight < taskB.SortWeight + end) + self.DynamicTable:SetDataSource(self.BabelTowerTasks) + self.DynamicTable:ReloadDataASync() + self.ImgEmpty.gameObject:SetActiveEx(#self.BabelTowerTasks <= 0) +end + +--动态列表事件 +function XUiBabelTowerTask:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.BabelTowerTasks[index] + if not data then + return + end + grid.RootUi = self + grid:ResetData(data) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerTeamTips.lua b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerTeamTips.lua new file mode 100644 index 00000000..4bb7428c --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerTeamTips.lua @@ -0,0 +1,262 @@ +local XUiBabelTowerTeamTips = XLuaUiManager.Register(XLuaUi, "UiBabelTowerTeamTips") +local XUiGridInfoSupportCondition = require("XUi/XUiFubenBabelTower/XUiGridInfoSupportCondition") +local XUiBabelMemberHead = require("XUi/XUiFubenBabelTower/XUiBabelMemberHead") + +function XUiBabelTowerTeamTips:OnAwake() + self.BtnTanchuangClose.CallBack = function() self:OnBtnBackClick() end + self.BtnCancel.CallBack = function() self:OnBtnBackClick() end + self.BtnConfirm.CallBack = function() self:OnBtnConfirmClick() end + + self.TeamMemberList = {} + for i = 1, XFubenBabelTowerConfigs.MAX_TEAM_MEMBER do + self.TeamMemberList[i] = XUiBabelMemberHead.New(self[string.format("TeamMember%d", i)], i) + self.TeamMemberList[i]:ClearMemberHead() + self.TeamMemberList[i]:SetMemberCallBack(function() + self:ChooseTeamCharacter(i) + end) + end + + self.DynamicTableSupportConditon = XDynamicTableNormal.New(self.PanelCondition.gameObject) + self.DynamicTableSupportConditon:SetProxy(XUiGridInfoSupportCondition) + self.DynamicTableSupportConditon:SetDelegate(self) + +end + +function XUiBabelTowerTeamTips:OnEnable() + + + for i = 1, XFubenBabelTowerConfigs.MAX_TEAM_MEMBER do + self.TeamMemberList[i]:SetMemberInfo(self.TeamMemberList[i].CharacterId, true) + end + self.SupportConditionList = self:GetStageSupportConditionListSort() + self.DynamicTableSupportConditon:SetDataSource(self.SupportConditionList) + self.DynamicTableSupportConditon:ReloadDataASync() + self.TxtChallengeNumber.text = self:GetTotalSupportPoint() +end + +function XUiBabelTowerTeamTips:OnBtnBackClick() + -- for i = 1, XFubenBabelTowerConfigs.MAX_TEAM_MEMBER do + -- self.SupportUi:UpdateTeamMember(self.TeamMemberList[i].Index, self.TeamMemberList[i].CharacterId or 0) + -- end + -- 刷新支援界面信息 + self.SupportUi:UpdateTeamInfo() + self.SupportUi:OnUpdateTeamMemberEnd() + self:Close() +end + +-- 确定按钮,将阵容更新到上一个界面 +function XUiBabelTowerTeamTips:OnBtnConfirmClick() + for i = 1, XFubenBabelTowerConfigs.MAX_TEAM_MEMBER do + self.SupportUi:UpdateTeamMember(self.TeamMemberList[i].Index, self.TeamMemberList[i].CharacterId or 0) + end + -- 刷新支援界面信息 + self.SupportUi:OnUpdateTeamMemberEnd() + self:Close() +end + +function XUiBabelTowerTeamTips:OnStart(supportUi, stageId, guideId, challengeInfos) + self.StageId = stageId + self.GuideId = guideId + self.SupportUi = supportUi + self.StageTemplate = XFubenBabelTowerConfigs.GetBabelTowerStageTemplate(self.StageId) + self.ChallengeBuffList = challengeInfos + + self:RefreshTeamList() + + -- self.SupportConditionList = self:GetStageSupportConditionListSort() + -- self.DynamicTableSupportConditon:SetDataSource(self.SupportConditionList) + -- self.DynamicTableSupportConditon:ReloadDataASync() +end + +function XUiBabelTowerTeamTips:GetStageSupportConditionListSort() + if not self.StageTemplate then return {} end + local conditionList = {} + for i = 1, #self.StageTemplate.SupportConditionId do + local conditionId = self.StageTemplate.SupportConditionId[i] + local conditionTemplate = XFubenBabelTowerConfigs.GetBabelTowerSupportConditonTemplate(conditionId) + local isSupport = self:CheckBabelTeamCondition(conditionTemplate.Condition) + table.insert(conditionList, { + SupportConditionId = conditionId, + IsSupport = isSupport + }) + end + table.sort(conditionList, function(elementA, elemenbB) + local priorityA = elementA.IsSupport and 1 or 0 + local priorityB = elemenbB.IsSupport and 1 or 0 + if priorityA == priorityB then + return elementA.SupportConditionId < elemenbB.SupportConditionId + end + return priorityA > priorityB + end) + return conditionList +end + +-- 刷新队伍列表 +function XUiBabelTowerTeamTips:RefreshTeamList() + local teamList = self.SupportUi:GetTeamList() + for i = 1, XFubenBabelTowerConfigs.MAX_TEAM_MEMBER do + self.TeamMemberList[i]:SetMemberInfo(teamList[i], true) + end + -- 更新支援条件条件 + -- self:RefreshSupportConditionList() + self.TxtChallengeNumber.text = self:GetTotalSupportPoint() + + self:RefreshLeaderSkill() +end + + +function XUiBabelTowerTeamTips:RefreshLeaderSkill() + -- 如果有队长,增加队长描述 + local captainPos = XFubenBabelTowerConfigs.LEADER_POSITION + local captainId = self.TeamMemberList[captainPos].CharacterId + if captainId == nil or captainId <= 0 then + self.TxtLeaderSkill.text = CS.XTextManager.GetText("BabelTowerPleaseSelectALeader") + else + local captianSkillInfo = XDataCenter.CharacterManager.GetCaptainSkillInfo(captainId) + self.TxtLeaderSkill.text = captianSkillInfo.Intro + end +end + +function XUiBabelTowerTeamTips:GetCurTeamList() + local teamList = {} + for i = 1, XFubenBabelTowerConfigs.MAX_TEAM_MEMBER do + table.insert(teamList, i, self.TeamMemberList[i].CharacterId or 0) + end + return teamList +end + +-- 打开选人界面:没有角色不打开 +function XUiBabelTowerTeamTips:ChooseTeamCharacter(index) + local currentTeamList = self:GetCurTeamList() + local stageCfg = XDataCenter.FubenManager.GetStageCfg(self.StageId) + local args = {} + args.StageId = self.StageId + args.TeamId = self.TeamId + args.Index = index + args.CurTeamList = currentTeamList + args.CharacterLimitType = XFubenConfigs.GetStageCharacterLimitType(self.StageId) + args.LimitBuffId = XFubenConfigs.GetStageCharacterLimitBuffId(self.StageId) + XLuaUiManager.Open("UiBabelTowerRoomCharacter", args, function(characterId, isJoin, isReset) + return self:OnCharacterSelectChanged(index, characterId, isJoin, isReset) + end) +end + +-- 点击有角色的位置 +-- 卸下 +-- 替换角色 +-- 点击无角色的位置 +-- 上阵 +-- 替换角色 +-- 某个位置加入或者移出角色,更新当前界面的角色 +function XUiBabelTowerTeamTips:OnCharacterSelectChanged(index, characterId, isJoin, isReset) + if isReset then + for _, member in pairs(self.TeamMemberList) do + member:SetMemberInfo(0) + end + end + + -- 选中角色是否在队伍中 + local isTargetInTeam = false + local targetIndex = 0 + for i = 1, XFubenBabelTowerConfigs.MAX_TEAM_MEMBER do + local memberCharId = self.TeamMemberList[i].CharacterId or 0 + if memberCharId ~= 0 and memberCharId == characterId then + isTargetInTeam = true + targetIndex = i + break + end + end + + local oldMemberId = self.TeamMemberList[index].CharacterId or 0 + local hasOldMember = oldMemberId ~= nil and oldMemberId ~= 0 + if hasOldMember then + if isTargetInTeam then + if index == targetIndex then + self.TeamMemberList[index]:SetMemberInfo(0) + else + self.TeamMemberList[targetIndex]:SetMemberInfo(oldMemberId, true) + self.TeamMemberList[index]:SetMemberInfo(characterId, true) + end + else + self.TeamMemberList[index]:SetMemberInfo(characterId, true) + end + else + if isTargetInTeam then--替换位置 + self.TeamMemberList[targetIndex]:SetMemberInfo(0) + self.TeamMemberList[index]:SetMemberInfo(characterId, true) + else--上阵 + self.TeamMemberList[index]:SetMemberInfo(characterId, true) + end + end + + -- 更新支援条件条件 + self.SupportConditionList = self:GetStageSupportConditionListSort() + self.DynamicTableSupportConditon:SetDataSource(self.SupportConditionList) + self.DynamicTableSupportConditon:ReloadDataASync() + + self.TxtChallengeNumber.text = self:GetTotalSupportPoint() + self:RefreshLeaderSkill() + + return true +end + +-- 更新支援组条件状态 +-- function XUiBabelTowerTeamTips:RefreshSupportConditionList() +-- for i=1, #self.SupportConditionList do +-- local grid = self.DynamicTableSupportConditon:GetGridByIndex(i) +-- if grid then +-- grid:RefreshItemInfos() +-- end +-- end +-- end +function XUiBabelTowerTeamTips:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + if self.SupportConditionList[index] then + grid:SetItemInfo(self.SupportConditionList[index]) + end + end +end + +function XUiBabelTowerTeamTips:CheckBabelTeamCondition(conditionId) + if conditionId == nil or conditionId == 0 then return true end + local characterIds = {} + for i = 1, XFubenBabelTowerConfigs.MAX_TEAM_MEMBER do + local characterId = self.TeamMemberList[i].CharacterId + if characterId ~= nil and characterId ~= 0 then + table.insert(characterIds, characterId) + end + end + local isConditionAvailable = XConditionManager.CheckCondition(conditionId, characterIds) + return isConditionAvailable +end + + +function XUiBabelTowerTeamTips:GetTotalSupportPoint() + local totalSupportPoint = self.StageTemplate.BaseSupportPoint or 0 + + local characterIds = {} + for i = 1, XFubenBabelTowerConfigs.MAX_TEAM_MEMBER do + local characterId = self.TeamMemberList[i].CharacterId + if characterId ~= nil and characterId ~= 0 then + table.insert(characterIds, characterId) + end + end + + for i = 1, #self.StageTemplate.SupportConditionId do + local supportConditionId = self.StageTemplate.SupportConditionId[i] + local supportConditionTemplate = XFubenBabelTowerConfigs.GetBabelTowerSupportConditonTemplate(supportConditionId) + if supportConditionTemplate.Condition == nil or supportConditionTemplate.Condition == 0 then + totalSupportPoint = totalSupportPoint + supportConditionTemplate.PointAdd + else + local isConditionAvailable = XConditionManager.CheckCondition(supportConditionTemplate.Condition, characterIds) + if isConditionAvailable then + totalSupportPoint = totalSupportPoint + supportConditionTemplate.PointAdd + end + end + + end + + return totalSupportPoint +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerTipsItem.lua b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerTipsItem.lua new file mode 100644 index 00000000..0e71d366 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiBabelTowerTipsItem.lua @@ -0,0 +1,42 @@ +local XUiBabelTowerTipsItem = XClass(nil, "XUiBabelTowerTipsItem") + +function XUiBabelTowerTipsItem:Ctor(ui, itemType) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.ItemType = itemType + + XTool.InitUiObject(self) +end + +function XUiBabelTowerTipsItem:RefreshBuffInfo(buffInfo, itemType) + self.BuffInfo = buffInfo + self.ItemType = itemType + + self.BuffTemplate = XFubenBabelTowerConfigs.GetBabelTowerBuffTemplate(self.BuffInfo.BufferId) + self.BuffGroupTemplate = XFubenBabelTowerConfigs.GetBabelTowerBuffGroupTemplate(self.BuffInfo.GroupId) + self.BuffConfigs = XFubenBabelTowerConfigs.GetBabelBuffConfigs(self.BuffInfo.BufferId) + self.BuffGroupConfigs = XFubenBabelTowerConfigs.GetBabelBuffGroupConfigs(self.BuffInfo.GroupId) + + self.RImgBuff:SetRawImage(self.BuffConfigs.BuffBg) + if self.ItemType == XFubenBabelTowerConfigs.TYPE_CHALLENGE then + self.TxtPoint.text = self.BuffTemplate.ScoreAdd + end + + if self.ItemType == XFubenBabelTowerConfigs.TYPE_SUPPORT then + self.TxtPoint.text = self.BuffTemplate.PointSub + end + self.TxtLv.text = CS.XTextManager.GetText("BabelTowerLevelDesc", self:GetBuffLv(self.BuffInfo.BufferId)) +end + +function XUiBabelTowerTipsItem:GetBuffLv(buffId) + local index = 1 + for i = 1, #self.BuffGroupTemplate.BuffId do + if buffId == self.BuffGroupTemplate.BuffId[i] then + index = i + break + end + end + return self.BuffGroupConfigs.BuffLv[index] or 0 +end + +return XUiBabelTowerTipsItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenBabelTower/XUiFubenBabelTowerRank.lua b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiFubenBabelTowerRank.lua new file mode 100644 index 00000000..be778d2b --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiFubenBabelTowerRank.lua @@ -0,0 +1,87 @@ +local XUiFubenBabelTowerRank = XLuaUiManager.Register(XLuaUi, "UiFubenBabelTowerRank") +local XUiBabelTowerRankInfo = require("XUi/XUiFubenBabelTower/XUiBabelTowerRankInfo") + + +function XUiFubenBabelTowerRank:OnAwake() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + self:BindHelpBtn(self.BtnHelp, "BabelTowerRank") + self.BabelTowerRankInfo = XUiBabelTowerRankInfo.New(self.PanelBossRankInfo, self) + + XEventManager.AddEventListener(XEventId.EVENT_BABEL_ACTIVITY_STATUS_CHANGED, self.CheckActivityStatus, self) +end + +function XUiFubenBabelTowerRank:OnDestroy() + self:StopCounter() + XEventManager.RemoveEventListener(XEventId.EVENT_BABEL_ACTIVITY_STATUS_CHANGED, self.CheckActivityStatus, self) +end + +function XUiFubenBabelTowerRank:OnStart() + self.BabelTowerRankInfo:Refresh() + self:StartCounter() +end + +function XUiFubenBabelTowerRank:OnEnable() + self:CheckActivityStatus() +end + +function XUiFubenBabelTowerRank:CheckActivityStatus() + if not XLuaUiManager.IsUiShow("UiFubenBabelTowerRank") then + return + end + local curActivityNo = XDataCenter.FubenBabelTowerManager.GetCurrentActivityNo() + if not curActivityNo or not XDataCenter.FubenBabelTowerManager.IsInActivityTime(curActivityNo) then + XUiManager.TipMsg(CS.XTextManager.GetText("BabelTowerNoneOpen")) + XLuaUiManager.RunMain() + end +end + +function XUiFubenBabelTowerRank:OnBtnBackClick() + self:Close() +end + +function XUiFubenBabelTowerRank:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiFubenBabelTowerRank:StartCounter() + self:StopCounter() + + local time = XTime.GetServerNowTimestamp() + local curActivityNo = XDataCenter.FubenBabelTowerManager.GetCurrentActivityNo() + if not curActivityNo then + return + end + local activityTemplate = XFubenBabelTowerConfigs.GetBabelTowerActivityTemplateById(curActivityNo) + if not activityTemplate then + return + end + + local endTime = XFunctionManager.GetEndTimeByTimeId(activityTemplate.ActivityTimeId) + if not endTime then + return + end + local leftTimeDesc = CS.XTextManager.GetText("BabelTowerRankReset") + self.BabelTowerRankInfo:UpdateCurTime(string.format(leftTimeDesc, XUiHelper.GetTime(endTime - time, XUiHelper.TimeFormatType.ACTIVITY))) + self.Timer = XScheduleManager.ScheduleForever( + function() + time = XTime.GetServerNowTimestamp() + if time > endTime then + self:StopCountDown() + return + end + self.BabelTowerRankInfo:UpdateCurTime(string.format(leftTimeDesc, XUiHelper.GetTime(endTime - time, XUiHelper.TimeFormatType.ACTIVITY))) + end, + XScheduleManager.SECOND, + 0 + ) + +end + +function XUiFubenBabelTowerRank:StopCounter() + if self.Timer ~= nil then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenBabelTower/XUiGridAutoFightMember.lua b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiGridAutoFightMember.lua new file mode 100644 index 00000000..70a532b7 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiGridAutoFightMember.lua @@ -0,0 +1,21 @@ +local XUiGridAutoFightMember = XClass(nil, "XUiGridAutoFightMember") + +function XUiGridAutoFightMember:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) +end + +function XUiGridAutoFightMember:UpdateMember(characterId, isLock) + local isExistChar = characterId ~= nil and characterId ~= 0 + self.GameObject:SetActiveEx(isExistChar) + + if isExistChar then + self.RImgHead:SetRawImage(XDataCenter.CharacterManager.GetCharRoundnessHeadIcon(characterId)) + self.TxtNickName.text = XCharacterConfigs.GetCharacterFullNameStr(characterId) + end + self.TxtLock.gameObject:SetActiveEx(isLock) +end + +return XUiGridAutoFightMember \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenBabelTower/XUiGridBabelChallengeItem.lua b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiGridBabelChallengeItem.lua new file mode 100644 index 00000000..136e4084 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiGridBabelChallengeItem.lua @@ -0,0 +1,47 @@ +local XUiGridBabelChallengeItem = XClass(nil, "XUiGridBabelChallengeItem") +local UiButtonState = CS.UiButtonState + +function XUiGridBabelChallengeItem:Ctor(ui, parentUi, index, itemType) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.ParentUi = parentUi + self.Index = index + self.ItemType = itemType + + XTool.InitUiObject(self) + self.ToggleButon = self.Transform:GetComponent("XUiButton") +end + +function XUiGridBabelChallengeItem:GetXUiButtonComp() + return self.ToggleButon +end + +function XUiGridBabelChallengeItem:UpdateBuff(buffTemplate, buffConfigs, index, itemType) + self.BuffTemplate = buffTemplate + self.BuffConfigs = buffConfigs + if index then self.Index = index end + if itemType then self.ItemType = itemType end + if self.ItemType == XFubenBabelTowerConfigs.TYPE_CHALLENGE then + self.TxtNumber.text = buffTemplate.ScoreAdd + end + if self.ItemType == XFubenBabelTowerConfigs.TYPE_SUPPORT then + local isSelected = self.ParentUi:GetBuffSelectStatus(self.BuffTemplate.Id) + local isOver = self.ParentUi:IsBuffListOverCount() + self:ShowOverCount(isSelected and isOver) + self.TxtNumber.text = buffTemplate.PointSub + end + self.RImgChallengeIconNor:SetRawImage(self.BuffConfigs.BuffBg) + self.RImgChallengeIconPress:SetRawImage(self.BuffConfigs.BuffBg) + self.RImgChallengeIconSelect:SetRawImage(self.BuffConfigs.BuffBg) + self.RImgChallengeIconDisable:SetRawImage(self.BuffConfigs.BuffBg) + + local btnState = (self.ParentUi:GetBuffSelectStatus(self.BuffTemplate.Id)) and UiButtonState.Select or UiButtonState.Normal + self.ToggleButon:SetButtonState(btnState) + +end + +function XUiGridBabelChallengeItem:ShowOverCount(isSlectAndOver) + self.ToggleButon:ShowReddot(isSlectAndOver) +end + +return XUiGridBabelChallengeItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenBabelTower/XUiGridBabelSelectDifficult.lua b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiGridBabelSelectDifficult.lua new file mode 100644 index 00000000..fd02932e --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiGridBabelSelectDifficult.lua @@ -0,0 +1,38 @@ +local CSXTextManagerGetText = CS.XTextManager.GetText + +local XUiGridBabelSelectDifficult = XClass(nil, "XUiGridBabelSelectDifficult") + +function XUiGridBabelSelectDifficult:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + + self.BtnSelect.CallBack = function() self:OnClickBtnSelect() end +end + +function XUiGridBabelSelectDifficult:InitRootUi(rootUi) + self.RootUi = rootUi +end + +function XUiGridBabelSelectDifficult:Refresh(stageId, teamId, config) + self.StageId = stageId + self.TeamId = teamId + self.Difficult = config.Level + + self.TxtDiffcult.text = config.Name + self.TxtAbility.text = CSXTextManagerGetText("BabelTowerSelectDifficultAbility", config.RecommendAblity) + self.TxtPoint.text = CSXTextManagerGetText("BabelTowerSelectDifficultRatio", config.ScoreRatio) + + local selectDifficult = XDataCenter.FubenBabelTowerManager.GetTeamSelectDifficult(stageId, teamId) + local isCur = selectDifficult == self.Difficult + self.PanelCurSelect.gameObject:SetActiveEx(isCur) + self.BtnSelect.gameObject:SetActiveEx(not isCur) +end + +function XUiGridBabelSelectDifficult:OnClickBtnSelect() + XDataCenter.FubenBabelTowerManager.UpdateTeamSelectDifficult(self.StageId, self.TeamId, self.Difficult) + self.RootUi:Close() +end + +return XUiGridBabelSelectDifficult \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenBabelTower/XUiGridBabelSelectTeam.lua b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiGridBabelSelectTeam.lua new file mode 100644 index 00000000..ef095cd8 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiGridBabelSelectTeam.lua @@ -0,0 +1,91 @@ +local CSXTextManagerGetText = CS.XTextManager.GetText +local MAX_CHARACTER_NUM = 3 + +local XUiGridBabelSelectTeam = XClass(nil, "XUiGridBabelSelectTeam") + +function XUiGridBabelSelectTeam:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + + self.BtnRecover.CallBack = function() self:OnClickBtnRecover() end + self.BtnReset.CallBack = function() self:OnClickBtnReset() end + self.BtnSelect.CallBack = function() self:OnClickBtnSelect() end +end + +function XUiGridBabelSelectTeam:Init(enterFightCb) + self.EnterFightCb = enterFightCb +end + +function XUiGridBabelSelectTeam:Refresh(stageId, teamId) + self.StageId = stageId + self.TeamId = teamId + + local unlockTeamNum = XDataCenter.FubenBabelTowerManager.GetStageUnlockTeamNum() + local isLock = teamId > unlockTeamNum + 1 + if not isLock then + local isReset = XDataCenter.FubenBabelTowerManager.IsTeamReseted(stageId, teamId) + local isPassed = XDataCenter.FubenBabelTowerManager.IsStageTeamHasRecord(stageId, teamId) + + self.BtnRecover.gameObject:SetActiveEx(isReset) + self.BtnReset.gameObject:SetActiveEx(not isReset and isPassed) + self.TxtRecord.gameObject:SetActiveEx(false) + + self.PanelNor.gameObject:SetActiveEx(true) + self.PanelLock.gameObject:SetActiveEx(false) + else + self.TxtLock.text = CSXTextManagerGetText("BabelTowerTeamLock", XTool.ParseNumberString(teamId - 1), XTool.ParseNumberString(teamId)) + self.PanelNor.gameObject:SetActiveEx(false) + self.PanelLock.gameObject:SetActiveEx(true) + end + + local characterIds = XDataCenter.FubenBabelTowerManager.GetTeamCharacterIds(stageId, teamId) + for i = 1, MAX_CHARACTER_NUM do + local rImg = self["RImgRoleIcon" .. i] + + local characterId = characterIds[i] + if characterId and characterId > 0 then + local icon = XDataCenter.CharacterManager.GetCharSmallHeadIcon(characterId) + rImg:SetRawImage(icon) + rImg.gameObject:SetActiveEx(true) + else + rImg.gameObject:SetActiveEx(false) + end + end + + self.TxtTeamOrder.text = CSXTextManagerGetText("BabelTowerTeamOrder", teamId) + + local curScore = XDataCenter.FubenBabelTowerManager.GetTeamCurScore(stageId, teamId) + self.TxtLevel.text = curScore +end + +function XUiGridBabelSelectTeam:OnClickBtnReset() + local stageId = self.StageId + local teamId = self.TeamId + + local stageName = XFubenBabelTowerConfigs.GetStageName(stageId) + local title = CSXTextManagerGetText("BabelTowerResetDesc") + local content = CSXTextManagerGetText("BabelTowerIsResetDesc", stageName) + XUiManager.DialogTip(title, content, XUiManager.DialogType.Normal, nil, function() + XDataCenter.FubenBabelTowerManager.ResetBabelTowerStage(stageId, teamId, function() + XUiManager.TipMsg(CSXTextManagerGetText("BabelTowerStageResetSucceed", stageName)) + self:Refresh(stageId, teamId) + end) + end) +end + +function XUiGridBabelSelectTeam:OnClickBtnRecover() + local stageId = self.StageId + local teamId = self.TeamId + XLuaUiManager.Open("UiBabelTowerAutoFight", stageId, teamId, function() + self:Refresh(stageId, teamId) + end) +end + +function XUiGridBabelSelectTeam:OnClickBtnSelect() + -- local teamList = XDataCenter.FubenBabelTowerManager.GetCacheTeam(self.StageId, self.TeamId) + XLuaUiManager.Open("UiBabelTowerBase", self.StageId, self.TeamId, self.EnterFightCb) +end + +return XUiGridBabelSelectTeam \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenBabelTower/XUiGridBabelStageItem.lua b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiGridBabelStageItem.lua new file mode 100644 index 00000000..8db16444 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiGridBabelStageItem.lua @@ -0,0 +1,71 @@ +local XUiGridBabelStageItem = XClass(nil, "XUiGridBabelStageItem") + +function XUiGridBabelStageItem:Ctor(ui, uiRoot, stageId) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + self.StageId = stageId + XTool.InitUiObject(self) +end + +function XUiGridBabelStageItem:InitBanner() + self.PanelLocking.gameObject:SetActiveEx(false) + self.BtnReset.gameObject:SetActiveEx(false) + self.BtnSkip.gameObject:SetActiveEx(false) + self.BtnStageMask.CallBack = function() self:OnBtnStageMaskClick() end +end + +function XUiGridBabelStageItem:UpdateStageInfo(stageId) + self.StageId = stageId + self.StageConfigs = XFubenBabelTowerConfigs.GetBabelStageConfigs(self.StageId) + self.StageTemplate = XFubenBabelTowerConfigs.GetBabelTowerStageTemplate(self.StageId) + + if not self.GridStageChapter then + self.GridStageChapter = self.Transform:LoadPrefab(self.StageConfigs.StagePrefab) + local uiObj = self.GridStageChapter.transform:GetComponent("UiObject") + + for i = 0, uiObj.NameList.Count - 1 do + self[uiObj.NameList[i]] = uiObj.ObjList[i] + end + + self:InitBanner() + end + + self:RefreshStageBanner() +end + +function XUiGridBabelStageItem:RefreshStageBanner() + local stageId = self.StageId + + self.FubenStageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + self.BtnStageMask:SetNameByGroup(1, self.StageConfigs.Name) + + local curScore = XDataCenter.FubenBabelTowerManager.GetStageTotalScore(stageId) + self.BtnStageMask:SetNameByGroup(0, curScore) + + self:RefreshStageInfo() +end + +function XUiGridBabelStageItem:RefreshStageInfo() + self.BtnStageMask:SetRawImage(self.FubenStageCfg.Icon) + + local isUnlock = XDataCenter.FubenBabelTowerManager.IsBabelStageUnlock(self.StageId) + self.PanelStageOrder.gameObject:SetActiveEx(isUnlock) + self.ImgStageNormal.gameObject:SetActiveEx(isUnlock) + self.ImgStageLock.gameObject:SetActiveEx(not isUnlock) + self.BtnStageMask:SetDisable(not isUnlock, isUnlock) + + local isPassed = XDataCenter.FubenBabelTowerManager.IsStagePassed(self.StageId) + self.PanelNewChallenge.gameObject:SetActiveEx(isUnlock and (not isPassed)) + self.TabZx.gameObject:SetActiveEx(false) +end + +function XUiGridBabelStageItem:OnBtnStageMaskClick() + self.UiRoot:OnStageClick(self.StageId, self) +end + +function XUiGridBabelStageItem:SetStageItemPress(isPress) + self.PanelPress.gameObject:SetActiveEx(isPress) +end + +return XUiGridBabelStageItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenBabelTower/XUiGridInfoBuffItem.lua b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiGridInfoBuffItem.lua new file mode 100644 index 00000000..77f3fc4d --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiGridInfoBuffItem.lua @@ -0,0 +1,31 @@ +local XUiGridInfoBuffItem = XClass(nil, "XUiGridInfoBuffItem") + +function XUiGridInfoBuffItem:Ctor(ui, buffId, itemType) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.BuffId = buffId + self.ItemType = itemType + + XTool.InitUiObject(self) + self:Refresh(self.BuffId, self.ItemType) +end + +-- 需要区分支援、挑战 +function XUiGridInfoBuffItem:Refresh(buffId, itemType) + self.BuffId = buffId + self.ItemType = itemType + self.BuffTemplate = XFubenBabelTowerConfigs.GetBabelTowerBuffTemplate(self.BuffId) + self.BuffConfigs = XFubenBabelTowerConfigs.GetBabelBuffConfigs(self.BuffId) + + self.TxtDetails.text = self.BuffConfigs.Desc + self.RImgChallengeIcon:SetRawImage(self.BuffConfigs.BuffBg) + if self.ItemType == XFubenBabelTowerConfigs.TYPE_CHALLENGE then + self.TxtNumber.text = self.BuffTemplate.ScoreAdd + end + + if self.ItemType == XFubenBabelTowerConfigs.TYPE_SUPPORT then + self.TxtNumber.text = self.BuffTemplate.PointSub + end +end + +return XUiGridInfoBuffItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenBabelTower/XUiGridInfoChallengeItem.lua b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiGridInfoChallengeItem.lua new file mode 100644 index 00000000..776e4e7c --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiGridInfoChallengeItem.lua @@ -0,0 +1,42 @@ +local XUiGridInfoChallengeItem = XClass(nil, "XUiGridInfoChallengeItem") +local XUiGridInfoBuffItem = require("XUi/XUiFubenBabelTower/XUiGridInfoBuffItem") + +function XUiGridInfoChallengeItem:Ctor(ui, buffGroupId, itemType) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.BuffGroupId = buffGroupId + self.ItemType = itemType + self.BuffItemList = {} + XTool.InitUiObject(self) + self:Refresh(self.BuffGroupId, self.ItemType) +end + +function XUiGridInfoChallengeItem:Refresh(buffGroupId, itemType) + self.BuffGroupId = buffGroupId + self.ItemType = itemType + self.BuffGroupConfigs = XFubenBabelTowerConfigs.GetBabelBuffGroupConfigs(self.BuffGroupId) + self.BuffGroupTemplate = XFubenBabelTowerConfigs.GetBabelTowerBuffGroupTemplate(self.BuffGroupId) + + self.TxtChallengeTitle.text = self.BuffGroupConfigs.Name + self.TxtChallenge.text = self.BuffGroupConfigs.Desc + self:RefreshBuffItems() +end + +function XUiGridInfoChallengeItem:RefreshBuffItems() + for i=1, #self.BuffGroupTemplate.BuffId do + if not self.BuffItemList[i] then + local go = CS.UnityEngine.Object.Instantiate(self.ImgChallenge) + go.transform:SetParent(self.ChallengeContainer, false) + go.gameObject:SetActiveEx(true) + local challengeItem = XUiGridInfoBuffItem.New(go, self.BuffGroupTemplate.BuffId[i], self.ItemType) + table.insert(self.BuffItemList, challengeItem) + else + self.BuffItemList[i]:Refresh(self.BuffGroupTemplate.BuffId[i], self.ItemType) + end + end + for i = #self.BuffGroupTemplate.BuffId + 1, #self.BuffItemList do + self.BuffItemList[i].GameObject:SetActiveEx(false) + end +end + +return XUiGridInfoChallengeItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenBabelTower/XUiGridInfoEnvironmentItem.lua b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiGridInfoEnvironmentItem.lua new file mode 100644 index 00000000..a525c8a6 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiGridInfoEnvironmentItem.lua @@ -0,0 +1,20 @@ +local XUiGridInfoEnvironmentItem = XClass(nil, "XUiGridInfoEnvironmentItem") + +function XUiGridInfoEnvironmentItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) +end + +function XUiGridInfoEnvironmentItem:Init(uiRoot) + self.UiRoot = uiRoot +end + +function XUiGridInfoEnvironmentItem:SetItemInfo(buffId, index) + local buffConfigs = XFubenBabelTowerConfigs.GetBabelBuffConfigs(buffId) + self.TxtNumber.text = (index > 9) and index or string.format("0%d", index) + self.TxtAmbien.text = buffConfigs.Desc +end + +return XUiGridInfoEnvironmentItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenBabelTower/XUiGridInfoSupportCondition.lua b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiGridInfoSupportCondition.lua new file mode 100644 index 00000000..a2c0b334 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiGridInfoSupportCondition.lua @@ -0,0 +1,33 @@ +local XUiGridInfoSupportCondition = XClass(nil, "XUiGridInfoSupportCondition") + +function XUiGridInfoSupportCondition:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) +end + +function XUiGridInfoSupportCondition:Init(uiRoot) + self.UiRoot = uiRoot +end + +function XUiGridInfoSupportCondition:SetItemInfo(conditionData) + self.SupportConditionId = conditionData.SupportConditionId + self.SupportConditionTemplate = XFubenBabelTowerConfigs.GetBabelTowerSupportConditonTemplate(self.SupportConditionId) + + self:RefreshItemInfos() +end + +function XUiGridInfoSupportCondition:RefreshItemInfos() + if self.SupportConditionTemplate then + local isSupport = self.UiRoot:CheckBabelTeamCondition(self.SupportConditionTemplate.Condition) + local description = XFubenBabelTowerConfigs.GetConditionDescription(self.SupportConditionId) + self.PanelActive.gameObject:SetActiveEx(isSupport) + self.TxtUnActiveCondition.text = description + self.TxtUnActiveChallengeGet.text = self.SupportConditionTemplate.PointAdd + self.TxtActiveCondition.text = description + self.TxtActiveChallengeGet.text = self.SupportConditionTemplate.PointAdd + end +end + +return XUiGridInfoSupportCondition \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenBabelTower/XUiGridRankItemInfo.lua b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiGridRankItemInfo.lua new file mode 100644 index 00000000..ac8aba45 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiGridRankItemInfo.lua @@ -0,0 +1,40 @@ +local XUiGridRankItemInfo = XClass(nil, "XUiGridRankItemInfo") + +local MAX_SPECIAL_NUM = 3 + +function XUiGridRankItemInfo:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + self.BtnDetail.CallBack = function() self:OnBtnDetailClick() end +end + +function XUiGridRankItemInfo:Init(uiRoot) + self.UiRoot = uiRoot +end + +-- 刷新排名 +function XUiGridRankItemInfo:Refresh(rankInfo) + self.RankInfo = rankInfo + self.TxtRankScore.text = string.format(CS.XTextManager.GetText("BabelTowerRankItemLevel"), rankInfo.Score) + self.TxtPlayerName.text = XDataCenter.SocialManager.GetPlayerRemark(rankInfo.PlayerId, rankInfo.Name) + + XUiPLayerHead.InitPortrait(rankInfo.HeadPortraitId, rankInfo.HeadFrameId, self.Head) + + self.TxtRankNormal.gameObject:SetActive(rankInfo.Rank > MAX_SPECIAL_NUM) + self.ImgRankSpecial.gameObject:SetActive(rankInfo.Rank <= MAX_SPECIAL_NUM) + if rankInfo.Rank <= MAX_SPECIAL_NUM then + local icon = XFubenBabelTowerConfigs.RankIcon[rankInfo.Rank] + self.UiRoot:SetUiSprite(self.ImgRankSpecial, icon) + else + self.TxtRankNormal.text = rankInfo.Rank + end +end + +function XUiGridRankItemInfo:OnBtnDetailClick() + if not self.RankInfo then return end + XDataCenter.PersonalInfoManager.ReqShowInfoPanel(self.RankInfo.PlayerId) +end + +return XUiGridRankItemInfo \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenBabelTower/XUiGridRankRewardItem.lua b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiGridRankRewardItem.lua new file mode 100644 index 00000000..ac778308 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenBabelTower/XUiGridRankRewardItem.lua @@ -0,0 +1,46 @@ +local XUiGridRankRewardItem = XClass(nil, "XUiGridRankRewardItem") + +function XUiGridRankRewardItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + self.MailRewardList = {} + XTool.InitUiObject(self) +end + +function XUiGridRankRewardItem:Init(uiRoot) + self.UiRoot = uiRoot +end + +-- 刷新排名奖励 +function XUiGridRankRewardItem:Refresh(rewardInfo) + local minRank = rewardInfo.MinRank * 100 + local maxRank = rewardInfo.MaxRank * 100 + if minRank <= 0 then + self.TxtScore.text = string.format("%d%%", maxRank) + else + self.TxtScore.text = string.format("%d%%-%d%%", minRank, maxRank) + end + local _, curRank, totalRank = XDataCenter.FubenBabelTowerManager.GetScoreInfos() + local playerRank = (curRank * 1.0) / totalRank * 100 + self.PanelCurRank.gameObject:SetActiveEx(playerRank > minRank and playerRank <= maxRank) + + local rewardList = XDataCenter.MailManager.GetRewardList(rewardInfo.MailId) + + for i, reward in pairs(rewardList or {}) do + if not self.MailRewardList[i] then + local ui = CS.UnityEngine.Object.Instantiate(self.GridReward) + ui.transform:SetParent(self.PanelRewardContent, false) + local common = XUiGridCommon.New(self.UiRoot, ui) + self.MailRewardList[i] = common + end + + self.MailRewardList[i]:Refresh(reward) + end + for i = #rewardList + 1, #self.MailRewardList do + self.MailRewardList[i].GameObject:SetActiveEx(false) + end +end + + +return XUiGridRankRewardItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenBossSingle/XUiFubenBossSingle.lua b/Resources/Scripts/XUi/XUiFubenBossSingle/XUiFubenBossSingle.lua new file mode 100644 index 00000000..a883d5cf --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenBossSingle/XUiFubenBossSingle.lua @@ -0,0 +1,157 @@ +local XUiFubenBossSingle = XLuaUiManager.Register(XLuaUi, "UiFubenBossSingle") +local XUiPanelBossStgae = require("XUi/XUiFubenBossSingle/XUiPanelBossStgae") +local XUiPanelBossRankInfo = require("XUi/XUiFubenBossSingle/XUiPanelBossRankInfo") +local XUiPanelBossDetail = require("XUi/XUiFubenBossSingle/XUiPanelBossDetail") +local XUiPanelBossEnter = require("XUi/XUiFubenBossSingle/XUiPanelBossEnter") + +function XUiFubenBossSingle:OnAwake() + self:AutoAddListener() + local root = self.UiModelGo.transform + self.ImgEffectHuanren = root:FindTransform("ImgEffectHuanren") + self.ImgEffectHuanrenHideBoss = root:FindTransform("ImgEffectHuanren1") + self.ImgEffectHuanren.gameObject:SetActiveEx(false) + self.ImgEffectHuanrenHideBoss.gameObject:SetActiveEx(false) + self.RoleModelPanel = XUiPanelRoleModel.New(root:FindTransform("PanelRoleModel"), self.Name, nil, true) +end + +function XUiFubenBossSingle:OnStart(bossSingleData, bossList) + self:Init(bossSingleData, bossList) + XEventManager.AddEventListener(XEventId.EVENT_FUBEN_REFRESH_STAGE_DATA, self.OnSyncBossData, self) + XEventManager.AddEventListener(XEventId.EVENT_BOSS_SINGLE_GET_REWARD, self.OnRewardGet, self) + XEventManager.AddEventListener(XEventId.EVENT_FUBEN_SINGLE_BOSS_RESET, self.OnActivityEnd, self) +end + +function XUiFubenBossSingle:OnDestroy() + if self.BossRankInfo then + self.BossRankInfo:RemoveTimer() + end + + if self.BossEnter then + self.BossEnter:OnDestroy() + end + + XEventManager.RemoveEventListener(XEventId.EVENT_FUBEN_REFRESH_STAGE_DATA, self.OnSyncBossData, self) + XEventManager.RemoveEventListener(XEventId.EVENT_BOSS_SINGLE_GET_REWARD, self.OnRewardGet, self) + XEventManager.RemoveEventListener(XEventId.EVENT_FUBEN_SINGLE_BOSS_RESET, self.OnActivityEnd, self) +end + +function XUiFubenBossSingle:OnEnable() + if XDataCenter.FubenBossSingleManager.IsNeedReset() then + self:OnActivityEnd() + return + end + + self:PlayAnimation("AnimEnable1") + + if self.BossDetail and self.BossDetail.GameObject.activeInHierarchy then + self.BossDetail:ShowPanel() + end +end + +function XUiFubenBossSingle:AutoAddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:BindHelpBtn(self.BtnHelp, "BossSingle") +end + +function XUiFubenBossSingle:Init(bossSingleData, bossList) + self.BossSingleData = bossSingleData + self.BossList = XUiPanelBossStgae.New(self, self.PanelBossStgae, bossList) + self.BossList:PanelBossContentActive(true) + self.BossEnter = XUiPanelBossEnter.New(self, self.PanelBossEnter, bossSingleData) + self.BossRankInfo = XUiPanelBossRankInfo.New(self, self.PanelBossRankInfo) + self.BossRankInfo:HidePanel() + self.BossDetail = XUiPanelBossDetail.New(self, self.PanelBossDetail) + self.BossDetail:HidePanel() + self.RoleModelPanel:HideRoleModel() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self:OnSyncBossData() + + local scoreReardCfg = XDataCenter.FubenBossSingleManager.GetCurScoreRewardCfg() + self.CurScoreRewardId = scoreReardCfg and scoreReardCfg.Id or -1 +end + +function XUiFubenBossSingle:OnSyncBossData() + local bossSingleData = XDataCenter.FubenBossSingleManager.GetBoosSingleData() + self.BossSingleData = bossSingleData + local isAutoFight = self.BossDetail:CheckAutoFightOpen() + + if isAutoFight then + self.BossEnter:ShowPanel(true, bossSingleData, isAutoFight) + self.BossDetail:Refresh(bossSingleData) + self.BossDetail:SetAutoFightClose() + self.BossRankInfo:HidePanel() + self.BossList:PanelBossContentActive(false) + return + end + + self.BossEnter:ShowPanel(true, bossSingleData, false, true) + self.BossDetail:HidePanel() + self.BossDetail:Refresh(bossSingleData) + self.RoleModelPanel:HideRoleModel() + self.BossList:PanelBossContentActive(true) + self.BossList:RefreshBossDifficult() + self.BossRankInfo:HidePanel() +end + +function XUiFubenBossSingle:OnRewardGet() + self.BossEnter:CheckRedPoint() +end + +function XUiFubenBossSingle:OnActivityEnd() + XDataCenter.FubenBossSingleManager.OnActivityEnd() +end + +function XUiFubenBossSingle:OnBtnBackClick() + if self.BossEnter.GameObject.activeSelf then + self:Close() + elseif self.BossRankInfo.GameObject.activeSelf then + self:Back2Enter() + elseif self.BossDetail.GameObject.activeSelf then + self:Back2Enter() + end +end + +function XUiFubenBossSingle:Back2Enter() + self.BossEnter:ShowPanel() + self.BossDetail:HidePanel() + self.RoleModelPanel:HideRoleModel() + self.BossList:PanelBossContentActive(true) + self.BossRankInfo:HidePanel() +end + +function XUiFubenBossSingle:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiFubenBossSingle:ShowBossDetail(bossId) + self.BossEnter:HidePanel() + self.BossRankInfo:HidePanel() + self.BossList:PanelBossContentActive(false) + self.BossDetail:ShowPanel(self.BossSingleData, bossId) + self.RoleModelPanel:ShowRoleModel() +end + +function XUiFubenBossSingle:ShowBossRank(levelType, rankPlatform) + self.BossEnter:HidePanel() + self.BossDetail:HidePanel() + self.RoleModelPanel:HideRoleModel() + self.BossList:PanelBossContentActive(false) + self.BossRankInfo:ShowPanel(levelType, rankPlatform) +end + +function XUiFubenBossSingle:RefreshModel(modelId, isHideBoss) + self.RoleModelPanel:UpdateBossModel(modelId, XModelManager.MODEL_UINAME.XUiBossSingle) + self.RoleModelPanel:ShowRoleModel() + if isHideBoss then + self.ImgEffectHuanrenHideBoss.gameObject:SetActiveEx(false) + self.ImgEffectHuanrenHideBoss.gameObject:SetActiveEx(true) + else + self.ImgEffectHuanren.gameObject:SetActiveEx(false) + self.ImgEffectHuanren.gameObject:SetActiveEx(true) + end +end + +function XUiFubenBossSingle:ShowBossGroupInfo(groupId) + self.BossEnter:ShowBossGroupInfo(groupId) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenBossSingle/XUiFubenBossSingleChooseLevelType.lua b/Resources/Scripts/XUi/XUiFubenBossSingle/XUiFubenBossSingleChooseLevelType.lua new file mode 100644 index 00000000..cc8ffec8 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenBossSingle/XUiFubenBossSingleChooseLevelType.lua @@ -0,0 +1,35 @@ +local XUiFubenBossSingleChooseLevelType = XLuaUiManager.Register(XLuaUi, "UiFubenBossSingleChooseLevelType") + +function XUiFubenBossSingleChooseLevelType:OnAwake() + self:AutoAddListener() +end + +function XUiFubenBossSingleChooseLevelType:AutoAddListener() + self.BtnTanchuangClose.CallBack = function() self:Close() end + self.BtnCancel.CallBack = function() self:Close() end + self.BtnGaojiqu.CallBack = function() self:OnSelectLevelType(XFubenBossSingleConfigs.LevelType.High) end + self.BtnChaopinqu.CallBack = function() self:OnSelectLevelType(XFubenBossSingleConfigs.LevelType.Extreme) end + self.BtnConfirm.CallBack = function() self:OnClickBtnConfirm() end +end + +function XUiFubenBossSingleChooseLevelType:OnSelectLevelType(levelType) + self.LevelType = levelType + + if levelType == XFubenBossSingleConfigs.LevelType.High then + self.BtnGaojiqu:SetButtonState(CS.UiButtonState.Select) + self.BtnChaopinqu:SetButtonState(CS.UiButtonState.Normal) + elseif levelType == XFubenBossSingleConfigs.LevelType.Extreme then + self.BtnGaojiqu:SetButtonState(CS.UiButtonState.Normal) + self.BtnChaopinqu:SetButtonState(CS.UiButtonState.Select) + end +end + +function XUiFubenBossSingleChooseLevelType:OnClickBtnConfirm() + if not self.LevelType then + XUiManager.TipText("BossSingleChooseLevelTypeEmpty") + return + end + + XDataCenter.FubenBossSingleManager.ReqChooseLevelType(self.LevelType) + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenBossSingle/XUiFubenBossSingleHide.lua b/Resources/Scripts/XUi/XUiFubenBossSingle/XUiFubenBossSingleHide.lua new file mode 100644 index 00000000..843398b6 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenBossSingle/XUiFubenBossSingleHide.lua @@ -0,0 +1,115 @@ +local XUiFubenBossSingleHide = XLuaUiManager.Register(XLuaUi, "UiFubenBossSingleHide") + +function XUiFubenBossSingleHide:OnAwake() + self:AutoAddListener() + self.GridFeatureList = {} + self.GridBuffDetailList = {} +end + +function XUiFubenBossSingleHide:OnStart(bossStageCfg) + self:Init(bossStageCfg) +end + +function XUiFubenBossSingleHide:AutoAddListener() + self:RegisterClickEvent(self.BtnClose, self.OnBtnBackClick) +end + +function XUiFubenBossSingleHide:Init(bossStageCfg) + self.BossStageCfg = bossStageCfg + self.GridFeatures.gameObject:SetActiveEx(false) + self.GridBuffTitle.gameObject:SetActiveEx(false) + self.GridBuffDetails.gameObject:SetActiveEx(false) + self.IsHideBoss = self.BossStageCfg.DifficultyType == XFubenBossSingleConfigs.DifficultyType.Hide + + local buffDetailIds = self.BossStageCfg.BuffDetailsId + local featuresIds = self.BossStageCfg.FeaturesId + local showFeatures = featuresIds and #featuresIds > 0 + local showBuff = buffDetailIds and #buffDetailIds > 0 + + if not showBuff and not showFeatures then + return + end + + self:SetFeatures(showFeatures) + self:SetBuffTitle(showBuff) + self:SetBuffDetails(showBuff) +end + +function XUiFubenBossSingleHide:SetFeatures(showFeatures) + if not showFeatures then + return + end + + for _, grid in pairs(self.GridFeatureList) do + grid.gameObject:SetActiveEx(false) + end + + for i = 1, #self.BossStageCfg.FeaturesId do + local grid = self.GridFeatureList[i] + if not grid then + grid = CS.UnityEngine.Object.Instantiate(self.GridFeatures) + grid.transform:SetParent(self.PanelContent, false) + self.GridFeatureList[i] = grid + end + + local desc = XUiHelper.TryGetComponent(grid.transform, "TxtDesc", "Text") + local name = XUiHelper.TryGetComponent(grid.transform, "TxtName", "Text") + local featuresCfg = XFubenConfigs.GetFeaturesById(self.BossStageCfg.FeaturesId[i]) + desc.text = featuresCfg.Desc + name.text = self.IsHideBoss and CS.XTextManager.GetText("BossSingleLevelHideBoss", featuresCfg.Name) + or CS.XTextManager.GetText("BossSingleLevel", featuresCfg.Name) + + grid.gameObject:SetActiveEx(true) + end +end + +function XUiFubenBossSingleHide:SetBuffTitle(showBuff) + if not showBuff then + return + end + + local grid = CS.UnityEngine.Object.Instantiate(self.GridBuffTitle) + grid.transform:SetParent(self.PanelContent, false) + local hide = XUiHelper.TryGetComponent(grid.transform, "PanelBuffHideTitle") + local normal = XUiHelper.TryGetComponent(grid.transform, "PanelBuffTitle") + hide.gameObject:SetActiveEx(self.IsHideBoss) + normal.gameObject:SetActiveEx(not self.IsHideBoss) + grid.gameObject:SetActiveEx(true) +end + +function XUiFubenBossSingleHide:SetBuffDetails(showBuff) + if not showBuff then + return + end + + for _, grid in pairs(self.GridBuffDetailList) do + grid.gameObject:SetActiveEx(false) + end + + for i = 1, #self.BossStageCfg.BuffDetailsId do + local grid = self.GridBuffDetailList[i] + if not grid then + grid = CS.UnityEngine.Object.Instantiate(self.GridBuffDetails) + grid.transform:SetParent(self.PanelContent, false) + self.GridBuffDetailList[i] = grid + end + + local desc = XUiHelper.TryGetComponent(grid.transform, "TxtDesc", "Text") + local name = XUiHelper.TryGetComponent(grid.transform, "TxtName", "Text") + local icon = XUiHelper.TryGetComponent(grid.transform, "RImgIcon", "RawImage") + local bg = XUiHelper.TryGetComponent(grid.transform, "ImgfTriangleBg", "Image") + local buffDetailsCfg = XFubenBabelTowerConfigs.GetBabelBuffConfigs(self.BossStageCfg.BuffDetailsId[i]) + desc.text = buffDetailsCfg.Desc + name.text = buffDetailsCfg.Name + icon:SetRawImage(buffDetailsCfg.BuffBg) + if buffDetailsCfg.BuffTriangleBg then + self:SetUiSprite(bg, buffDetailsCfg.BuffTriangleBg) + end + + grid.gameObject:SetActiveEx(true) + end +end + +function XUiFubenBossSingleHide:OnBtnBackClick() + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenBossSingle/XUiGridBossRank.lua b/Resources/Scripts/XUi/XUiFubenBossSingle/XUiGridBossRank.lua new file mode 100644 index 00000000..0613a4ab --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenBossSingle/XUiGridBossRank.lua @@ -0,0 +1,77 @@ +local XUiGridBossRank = XClass(nil, "XUiGridBossRank") + +local MAX_SPECIAL_NUM = 3 + +function XUiGridBossRank:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + self:AutoAddListener() +end + +function XUiGridBossRank:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiGridBossRank:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiGridBossRank:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiGridBossRank:AutoAddListener() + self:RegisterClickEvent(self.BtnDetail, self.OnBtnDetailClick) +end + +function XUiGridBossRank:Refresh(rankMetaData, curLevelType) + if rankMetaData then + self.RankMetaData = rankMetaData + else + return + end + + if curLevelType then + self.CurLevelType = curLevelType + end + + self.TxtRankNormal.gameObject:SetActive(self.RankMetaData.RankNum > MAX_SPECIAL_NUM) + self.ImgRankSpecial.gameObject:SetActive(self.RankMetaData.RankNum <= MAX_SPECIAL_NUM) + if self.RankMetaData.RankNum <= MAX_SPECIAL_NUM then + local icon = XDataCenter.FubenBossSingleManager.GetRankSpecialIcon(math.floor(self.RankMetaData.RankNum), self.CurLevelType) + self.RootUi:SetUiSprite(self.ImgRankSpecial, icon) + else + self.TxtRankNormal.text = math.floor(self.RankMetaData.RankNum) + end + local text = CS.XTextManager.GetText("BossSingleBossRankSocre", self.RankMetaData.Score) + self.TxtRankScore.text = text + self.TxtPlayerName.text = XDataCenter.SocialManager.GetPlayerRemark(self.RankMetaData.PlayerId, self.RankMetaData.Name) + + XUiPLayerHead.InitPortrait(self.RankMetaData.HeadPortraitId, self.RankMetaData.HeadFrameId, self.Head) + + for i = 1, #self.RankMetaData.CharacterHeadData do + self["RImgTeam" .. i].gameObject:SetActive(true) + local charId = self.RankMetaData.CharacterHeadData[i].Id + local liberateLv = self.RankMetaData.CharacterHeadData[i].LiberateLv + local charIcon = XDataCenter.CharacterManager.GetCharSmallHeadIcon(charId, liberateLv) + self["RImgTeam" .. i]:SetRawImage(charIcon) + end + + for i = #self.RankMetaData.CharacterHeadData + 1, 3 do + self["RImgTeam" .. i].gameObject:SetActive(false) + end + +end + +function XUiGridBossRank:OnBtnDetailClick() + XDataCenter.PersonalInfoManager.ReqShowInfoPanel(self.RankMetaData.PlayerId) +end + +return XUiGridBossRank \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenBossSingle/XUiGridBossRankReward.lua b/Resources/Scripts/XUi/XUiFubenBossSingle/XUiGridBossRankReward.lua new file mode 100644 index 00000000..0d268131 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenBossSingle/XUiGridBossRankReward.lua @@ -0,0 +1,63 @@ +local XUiGridBossRankReward = XClass(nil, "XUiGridBossRankReward") + +function XUiGridBossRankReward:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self.GridRewardList = {} + XTool.InitUiObject(self) + self.GridReward.gameObject:SetActive(false) +end + +function XUiGridBossRankReward:Refresh(cfg, myRankNum, myLevelType, totalCount) + local rewardList = XDataCenter.MailManager.GetRewardList(cfg.MailID) + + for i = 1, #rewardList do + local grid = self.GridRewardList[i] + if not grid then + local ui = CS.UnityEngine.Object.Instantiate(self.GridReward) + grid = XUiGridCommon.New(self.RootUi, ui) + grid.Transform:SetParent(self.PanelRewardContent, false) + self.GridRewardList[i] = grid + end + + grid:Refresh(rewardList[i]) + grid.GameObject:SetActive(true) + end + + for i = #rewardList + 1, #self.GridRewardList do + self.GridRewardList[i].GameObject:SetActive(false) + end + + if cfg.MinRank <= 1 and cfg.MaxRank <= 1 then + local min + if cfg.MinRank > 0 then + min = math.floor(cfg.MinRank * 100) .. "%" .. "-" + else + min = "" + end + local max = math.floor(cfg.MaxRank * 100) .. "%" + self.TxtScore.text = min .. max + else + if cfg.MinRank == cfg.MaxRank then + self.TxtScore.text = cfg.MinRank + else + self.TxtScore.text = cfg.MinRank .. "-" .. cfg.MaxRank + end + end + + if myLevelType ~= cfg.LevelType then + self.PanelCurRank.gameObject:SetActive(false) + return + end + + if myRankNum >= 1 and totalCount > 0 then + myRankNum = myRankNum / totalCount + end + + local isCur = myRankNum > cfg.MinRank and myRankNum <= cfg.MaxRank + self.PanelCurRank.gameObject:SetActive(isCur) +end + +return XUiGridBossRankReward + diff --git a/Resources/Scripts/XUi/XUiFubenBossSingle/XUiGridBossScore.lua b/Resources/Scripts/XUi/XUiFubenBossSingle/XUiGridBossScore.lua new file mode 100644 index 00000000..529e55b4 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenBossSingle/XUiGridBossScore.lua @@ -0,0 +1,87 @@ +local XUiGridBossScore = XClass(nil, "XUiGridBossScore") + +function XUiGridBossScore:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self.GridRewardList = {} + XTool.InitUiObject(self) + self:AutoAddListener() +end + +function XUiGridBossScore:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiGridBossScore:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiGridBossScore:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiGridBossScore:AutoAddListener() + self:RegisterClickEvent(self.BtnReceive, self.OnBtnReceiveClick) +end + +function XUiGridBossScore:OnBtnReceiveClick() + local canGet = self.TotalScore >= self.ScoreCfg.Score + if not canGet then + XUiManager.TipText("BossSingleCannotReward") + return + end + + XDataCenter.FubenBossSingleManager.GetRankRewardReq(self.ScoreCfg.Id, function(rewards) + if rewards and #rewards> 0 then + XUiManager.OpenUiObtain(rewards) + end + + XEventManager.DispatchEvent(XEventId.EVENT_BOSS_SINGLE_GET_REWARD) + self.PanelAlreadyGet.gameObject:SetActive(true) + self.BtnReceive.gameObject:SetActive(false) + end) +end + +function XUiGridBossScore:Refresh(scoreCfg, totalScore) + self.TotalScore = totalScore + self.ScoreCfg = scoreCfg + self.GridReward.gameObject:SetActive(false) + local isGet = XDataCenter.FubenBossSingleManager.CheckRewardGet(scoreCfg.Id) + local rewardList = XRewardManager.GetRewardList(scoreCfg.RewardId) + + self.TxtScore.text = scoreCfg.Score + self.PanelAlreadyGet.gameObject:SetActive(isGet) + self.BtnReceive.gameObject:SetActive(not isGet) + + local canGet = self.TotalScore >= self.ScoreCfg.Score + if not canGet then + self.BtnReceive:SetButtonState(CS.UiButtonState.Disable) + else + self.BtnReceive:SetButtonState(CS.UiButtonState.Normal) + end + + for i = 1, #rewardList do + local grid = self.GridRewardList[i] + if not grid then + local ui = CS.UnityEngine.Object.Instantiate(self.GridReward) + grid = XUiGridCommon.New(self.RootUi, ui) + grid.Transform:SetParent(self.PanelRewardContent, false) + self.GridRewardList[i] = grid + end + + grid:Refresh(rewardList[i]) + grid.GameObject:SetActive(true) + end + + for i = #rewardList + 1, #self.GridRewardList do + self.GridRewardList[i].GameObject:SetActive(false) + end +end + +return XUiGridBossScore \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenBossSingle/XUiGridBossSkill.lua b/Resources/Scripts/XUi/XUiFubenBossSingle/XUiGridBossSkill.lua new file mode 100644 index 00000000..4bc6c1c2 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenBossSingle/XUiGridBossSkill.lua @@ -0,0 +1,16 @@ +local XUiGridBossSkill = XClass(nil, "XUiGridBossSkill") + +function XUiGridBossSkill:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiGridBossSkill:Refresh(title, desc, isHideBoss) + self.TxtTitle.text = title + self.TxtDesc.text = desc + self.ImgBg.gameObject:SetActiveEx(not isHideBoss) + self.ImgBgHb.gameObject:SetActiveEx(isHideBoss) +end + +return XUiGridBossSkill diff --git a/Resources/Scripts/XUi/XUiFubenBossSingle/XUiPanelAutoFight.lua b/Resources/Scripts/XUi/XUiFubenBossSingle/XUiPanelAutoFight.lua new file mode 100644 index 00000000..12027889 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenBossSingle/XUiPanelAutoFight.lua @@ -0,0 +1,146 @@ +local XUiPanelAutoFight = XClass(nil, "XUiPanelAutoFight") + +function XUiPanelAutoFight:Ctor(ui, rootUi, autoFightCb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self.AutoFightCb = autoFightCb + + XTool.InitUiObject(self) + self.TeamMemberList = {} + table.insert(self.TeamMemberList, self.GridBossAutoFight1) + table.insert(self.TeamMemberList, self.GridBossAutoFight2) + table.insert(self.TeamMemberList, self.GridBossAutoFight3) + self:AutoAddListener() +end + +function XUiPanelAutoFight:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelAutoFight:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelAutoFight:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelAutoFight:AutoAddListener() + self:RegisterClickEvent(self.BtnAutoFight, self.OnBtnAutoFightClick) + self:RegisterClickEvent(self.BtnClose, self.OnBtnCloseClick) + self:RegisterClickEvent(self.BtnHelp, self.OnBtnHelpClick) +end + +function XUiPanelAutoFight:OnBtnCloseClick() + if self.CloseCb then + self.CloseCb() + end + self:Close() +end + +function XUiPanelAutoFight:OnBtnHelpClick() + XUiManager.UiFubenDialogTip("", CS.XTextManager.GetText("BossSingleAutoFightDesc") or "") +end + +function XUiPanelAutoFight:OnBtnAutoFightClick() + if not self.StaminaEnough then + XUiManager.TipText("BossSingleAutoFightDesc7") + return + end + + if not self.ChallengeCountEnough then + XUiManager.TipText("BossSingleAutoFightDesc8") + return + end + + local titletext = CS.XTextManager.GetText("TipTitle") + local stageData = XDataCenter.FubenManager.GetStageData(self.StageId) + local curScore = stageData and stageData.Score or 0 + local contenttext = curScore > 0 and CS.XTextManager.GetText("BossSingleAutoFightDesc11") or CS.XTextManager.GetText("BossSingleAutoFightDesc9") + XUiManager.DialogTip(titletext, contenttext, XUiManager.DialogType.Normal, nil, function() + XDataCenter.FubenBossSingleManager.AutoFight(self.StageId, function(isTip) + XEventManager.DispatchEvent(XEventId.EVENT_BOSS_SINGLE_GET_REWARD) + if self.CloseCb then + self.CloseCb() + end + + self:Close() + + if self.AutoFightCb then + self.AutoFightCb(isTip) + end + end) + end) +end + +function XUiPanelAutoFight:Close() + self.GameObject:SetActive(false) +end + +function XUiPanelAutoFight:Open(autoFightData, challengeCount, cfg, closeCb) + self.CloseCb = closeCb + self.StaminaEnough = true + self.ChallengeCountEnough = true + self.StageId = autoFightData.StageId + + local score = cfg.Score + local curScore = autoFightData.Score or 0 + curScore = math.floor(XFubenBossSingleConfigs.AUTO_FIGHT_REBATE * curScore / 100) + local scoreDesc = XFubenBossSingleConfigs.AUTO_FIGHT_REBATE .. "%" + + self.TxtScore.text = CS.XTextManager.GetText("BossSingleAutoFightDesc3", curScore, score) + self.TxtScoreDesc.text = CS.XTextManager.GetText("BossSingleAutoFightRateDesc", scoreDesc) + + local allCount = XDataCenter.FubenBossSingleManager.GetChallengeCount() + local leftCount = allCount - challengeCount + self.TxtCount.text = CS.XTextManager.GetText("BossSingleAutoFightDesc4", leftCount, allCount) + if leftCount <= 0 then + self.ChallengeCountEnough = false + end + + for _, v in pairs(self.TeamMemberList) do + v.gameObject:SetActive(false) + end + + for i, v in pairs(autoFightData.Characters) do + if v > 0 then + local grid = self.TeamMemberList[i] + + local nickname = XUiHelper.TryGetComponent(grid, "TxtNickName", "Text") + local enough = XUiHelper.TryGetComponent(grid, "TxtCountEnough", "Text") + local notEnough = XUiHelper.TryGetComponent(grid, "TxtCountNotEnough", "Text") + local head = XUiHelper.TryGetComponent(grid, "Gouzaoti/RImgHead", "RawImage") + + local info = XDataCenter.CharacterManager.GetCharBigRoundnessNotItemHeadIcon(v) + if info ~= nil then + head:SetRawImage(info) + end + + local fullName = XCharacterConfigs.GetCharacterFullNameStr(v) + nickname.text = fullName + + local maxStamina = XDataCenter.FubenBossSingleManager.GetMaxStamina() + local curStamina = maxStamina - XDataCenter.FubenBossSingleManager.GetCharacterChallengeCount(v) + + enough.text = CS.XTextManager.GetText("BossSingleAutoFightDesc5", curStamina, maxStamina) + notEnough.text = CS.XTextManager.GetText("BossSingleAutoFightDesc6", curStamina, maxStamina) + enough.gameObject:SetActive(curStamina > 0) + notEnough.gameObject:SetActive(curStamina <= 0) + if curStamina <= 0 then + self.StaminaEnough = false + end + + grid.gameObject:SetActive(true) + end + end + + self.GameObject:SetActive(true) +end + +return XUiPanelAutoFight \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenBossSingle/XUiPanelBossDetail.lua b/Resources/Scripts/XUi/XUiFubenBossSingle/XUiPanelBossDetail.lua new file mode 100644 index 00000000..36c408bf --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenBossSingle/XUiPanelBossDetail.lua @@ -0,0 +1,499 @@ +local XUiPanelBossDetail = XClass(nil, "XUiPanelBossDetail") +local XUiGridBossSkill = require("XUi/XUiFubenBossSingle/XUiGridBossSkill") +local XUiPanelAutoFight = require("XUi/XUiFubenBossSingle/XUiPanelAutoFight") +local XUiPanelBossDetailTip = require("XUi/XUiFubenBossSingle/XUiPanelBossDetailTip") + +local ONE_MINUTE_SECOND = 60 + +function XUiPanelBossDetail:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self.SkillGridList = {} + XTool.InitUiObject(self) + self:AutoAddListener() + self.ToggleTabList = { + self.GridBossLevel1, + self.GridBossLevel2, + self.GridBossLevel3, + self.GridBossLevel4, + self.GridBossLevel5, + self.GridBossLevel6, + } + self.HideBossBtnGrid = self.GridBossLevel6 + self.GridBossSkill.gameObject:SetActiveEx(false) + self:InitAutoFight() + self:InitDetailTip() +end + +function XUiPanelBossDetail:OnShow() + self:OnBtnClickClick() +end + +function XUiPanelBossDetail:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelBossDetail:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelBossDetail:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelBossDetail:AutoAddListener() + self:RegisterClickEvent(self.BtnStart, self.OnBtnStartClick) + self:RegisterClickEvent(self.BtnClick, self.OnBtnClickClick) + self:RegisterClickEvent(self.BtnAuto, self.OnBtnAutoClick) +end + +function XUiPanelBossDetail:HidePanel() + self.GameObject:SetActiveEx(false) +end + +function XUiPanelBossDetail:InitAutoFight() + self.PanelAutoFight = XUiPanelAutoFight.New(self.PanelAutoFight, self.RootUi, function(isTip) + local text = CS.XTextManager.GetText("BossSingleAutoSuccess") + local msgType = XUiManager.UiTipType.Success + XUiManager.TipMsg(text, msgType, function() + local time = CS.XGame.ClientConfig:GetFloat("BossSingleAnimaTime") + XUiHelper.Tween(time, function() + if XTool.UObjIsNil(self.Transform) or not self.GameObject.activeSelf then + return + end + + local score = self.CurBossStageCfg.Score + local stageData = XDataCenter.FubenManager.GetStageData(self.CurBossStageCfg.StageId) + local curScore = stageData and stageData.Score or 0 + self:SetMyScore(score, curScore) + end) + + if isTip then + XUiManager.TipText("BossSignleBufenTip", XUiManager.UiTipType.Tip) + end + end) + end) + self.PanelAutoFight:Close() +end + +function XUiPanelBossDetail:InitDetailTip() + self.PanelBossDetailTip = XUiPanelBossDetailTip.New(self.RootUi, self.PanelTip) + self.PanelBossDetailTip:HidePanel() +end + +function XUiPanelBossDetail:ShowPanel(bossSingleData, bossId) + self.Index = nil + if bossId then + self.BossId = bossId + end + + if bossSingleData then + self.BossSingleData = bossSingleData + end + + self.LastBossIsHide = false + self:SetToggle() + self.GameObject:SetActiveEx(true) + self.RootUi:PlayAnimation("AnimDeatilEnable") +end + +function XUiPanelBossDetail:Refresh(bossSingleData) + self.BossSingleData = bossSingleData + -- 刷新分数 + if not self.CurBossStageCfg then + return + end + + -- 刷新挑战次数 + local isHideBoss = self.CurBossStageCfg.DifficultyType == XFubenBossSingleConfigs.DifficultyType.Hide + self.TxtAllScore.text = isHideBoss and CS.XTextManager.GetText("BossSingleLevelHideBoss", self.BossSingleData.TotalScore) + or CS.XTextManager.GetText("BossSingleLevel", self.BossSingleData.TotalScore) + local allNums = XDataCenter.FubenBossSingleManager.GetChallengeCount() + local leftNums = allNums - self.BossSingleData.ChallengeCount + self.TxtChangeNums.text = isHideBoss and CS.XTextManager.GetText("BossSingleChallgeCountHB", leftNums, allNums) + or CS.XTextManager.GetText("BossSingleChallgeCount", leftNums, allNums) + + local score = self.CurBossStageCfg.Score + local stageData = XDataCenter.FubenManager.GetStageData(self.CurBossStageCfg.StageId) + local curScore = stageData and stageData.Score or 0 + self:SetMyScore(score, curScore) +end + +function XUiPanelBossDetail:SetMyScore(score, curScore) + local isHideBoss = false + if self.CurBossStageCfg then + isHideBoss = self.CurBossStageCfg.DifficultyType == XFubenBossSingleConfigs.DifficultyType.Hide + end + + local text = isHideBoss and CS.XTextManager.GetText("BossSingleBossScoreHb", curScore, score) + or CS.XTextManager.GetText("BossSingleBossScore", curScore, score) + self.TxtMyScore.text = text + self.ImgBg.gameObject:SetActiveEx(not isHideBoss) + self.ImgBgHb.gameObject:SetActiveEx(isHideBoss) +end + +function XUiPanelBossDetail:SetToggle() + if self.TabBtnGroup then + self.TabBtnGroup:Dispose() + end + self.TabBtnGroup = nil + self.BtnTabList = {} + local sectionInfo = XDataCenter.FubenBossSingleManager.GetBossSectionInfo(self.BossId) + local hasHideBoss = XDataCenter.FubenBossSingleManager.CheckLevelHasHideBoss() + local count = hasHideBoss and #sectionInfo or #sectionInfo - 1 + if hasHideBoss then + self:HideBossGridEnable() + else + self:HideBossGridDisable() + end + + self.TxtSelectedEn.gameObject:SetActiveEx(hasHideBoss) + self.TxtHideSelectedBoss.gameObject:SetActiveEx(hasHideBoss) + + for i = 1, count do + local grid = self.ToggleTabList[i] + grid.gameObject:SetActiveEx(true) + table.insert(self.BtnTabList, grid) + end + + -- 设置Togge按钮 + self.TabBtnGroup = XUiTabBtnGroup.New(self.BtnTabList, function(index) + self:RefrshBossInfo(index) + end, function(index) + return self:CheckClick(index, true) + end, true) + + -- 设置Toggle名字 + for k, btn in ipairs(self.TabBtnGroup.TabBtnList) do + local bossStageCfg = XDataCenter.FubenBossSingleManager.GetBossStageCfg(sectionInfo[k].StageId) + btn:SetName(bossStageCfg.DifficultyDesc, bossStageCfg.DifficultyDescEn) + + if k ~= XFubenBossSingleConfigs.DifficultyType.experiment then + if self:CheckClick(k, false) then + self.TabBtnGroup:UnLockIndex(k) + else + self.TabBtnGroup:LockIndex(k) + end + end + end + + -- 设置默认Toggle + if self.Index then + self.TabBtnGroup:SelectIndex(self.Index) + else + local index = XDataCenter.FubenBossSingleManager.GetCurBossIndex(self.BossId) + self.TabBtnGroup:SelectIndex(index) + end +end + +function XUiPanelBossDetail:RefrshBossInfo(index) + self.Index = index + local sectionInfo = XDataCenter.FubenBossSingleManager.GetBossSectionInfo(self.BossId) + self.CurBossStageCfg = sectionInfo[index] + local isHideBoss = self.CurBossStageCfg.DifficultyType == XFubenBossSingleConfigs.DifficultyType.Hide + if isHideBoss then + self.LastBossIsHide = true + self.RootUi:PlayAnimation("BossDetailQieHuan") + else + if self.LastBossIsHide then + self.BossDetailDisable.gameObject:SetActiveEx(true) + self.RootUi:PlayAnimation("BossDetailDisable", function() + self.BossDetailDisable.gameObject:SetActiveEx(false) + end) + else + self.RootUi:PlayAnimation("AnimQieHuan") + end + self.LastBossIsHide = false + end + self:RefreshDesc() + self:RefreshInfo() + self:RefreshHideBoss() + self.PanelBossDetailTip:ShowBossTip(self.CurBossStageCfg) + self.RootUi:RefreshModel(self.CurBossStageCfg.ModelId, isHideBoss) +end + +function XUiPanelBossDetail:RefreshDesc() + local stageId = self.CurBossStageCfg.StageId + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + local isHideBoss = self.CurBossStageCfg.DifficultyType == XFubenBossSingleConfigs.DifficultyType.Hide + + local time = math.floor(stageCfg.PassTimeLimit / ONE_MINUTE_SECOND) + local text = isHideBoss and CS.XTextManager.GetText("BossSingleMinuteHideBoss", time) or CS.XTextManager.GetText("BossSingleMinute", time) + local sectionCfg = XDataCenter.FubenBossSingleManager.GetBossSectionCfg(self.BossId) + local level = XDataCenter.FubenBossSingleManager.GetProposedLevel(stageId) + self.TxtTimeLimit.text = text + self.TxtBossName.text = self.CurBossStageCfg.BossName + self.TxtFightCharCount.text = isHideBoss and CS.XTextManager.GetText("BossSingleFightCharCountHB", self.CurBossStageCfg.FightCharCount) + or CS.XTextManager.GetText("BossSingleFightCharCount", self.CurBossStageCfg.FightCharCount) + self.TxtBossDes.text = sectionCfg.Desc + self.TxtLevel.text = isHideBoss and CS.XTextManager.GetText("BossSingleLevelHideBoss", level) or CS.XTextManager.GetText("BossSingleLevel", level) + self.TxtATNums.text = stageCfg.RequireActionPoint + + local allNums = XDataCenter.FubenBossSingleManager.GetChallengeCount() + local leftNums = allNums - self.BossSingleData.ChallengeCount + self.TxtChangeNums.text = isHideBoss and CS.XTextManager.GetText("BossSingleChallgeCountHB", leftNums, allNums) + or CS.XTextManager.GetText("BossSingleChallgeCount", leftNums, allNums) + + local preFullScore = XDataCenter.FubenBossSingleManager.GetPreFullScore(stageId) + if preFullScore > 0 then + self.TxtRepeatDesc.text = string.gsub(CS.XTextManager.GetText("BossSingleScoreDesc", self.CurBossStageCfg.DifficultyDesc, preFullScore), + "\\n", "\n") + else + self.TxtRepeatDesc.text = string.gsub(CS.XTextManager.GetText("BossSingleRepeartDesc"), "\\n", "\n") + end + + self.TxtAllScore.text = isHideBoss and CS.XTextManager.GetText("BossSingleLevelHideBoss", self.BossSingleData.TotalScore) + or CS.XTextManager.GetText("BossSingleLevel", self.BossSingleData.TotalScore) + self.ImagBossTileBg.gameObject:SetActiveEx(not isHideBoss) + self.ImagBossTileBgHb.gameObject:SetActiveEx(isHideBoss) + self.PanelEffectHb.gameObject:SetActiveEx(isHideBoss) + + for i = 1, #self.CurBossStageCfg.SkillTitle do + local grid = self.SkillGridList[i] + if not grid then + local ui = CS.UnityEngine.Object.Instantiate(self.GridBossSkill) + grid = XUiGridBossSkill.New(ui) + grid.Transform:SetParent(self.PanelSkill, false) + self.SkillGridList[i] = grid + end + + grid:Refresh(self.CurBossStageCfg.SkillTitle[i], self.CurBossStageCfg.SkillDesc[i], isHideBoss) + grid.GameObject:SetActiveEx(true) + end + + for i = #self.CurBossStageCfg.SkillTitle + 1, #self.SkillGridList do + self.SkillGridList[i].GameObject:SetActiveEx(false) + end + + if #stageCfg.ForceConditionId <= 0 then + self.PanelCondition.gameObject:SetActiveEx(false) + else + self.PanelCondition.gameObject:SetActiveEx(true) + + if stageCfg.ForceConditionId[1] then + self.ImgCondition1.gameObject:SetActiveEx(true) + self.ImgCondition1.gameObject:SetActiveEx(false) + self.TxtConditon1.text = XConditionManager.GetConditionTemplate(stageCfg.ForceConditionId[1]).Desc + else + self.TxtConditon1.text = "" + end + + if stageCfg.ForceConditionId[2] then + self.ImgCondition1.gameObject:SetActiveEx(false) + self.ImgCondition2.gameObject:SetActiveEx(true) + self.TxtConditon2.text = XConditionManager.GetConditionTemplate(stageCfg.ForceConditionId[2]).Desc + else + self.TxtConditon2.text = "" + end + end +end + +function XUiPanelBossDetail:RefreshInfo() + local score = self.CurBossStageCfg.Score + local stageData = XDataCenter.FubenManager.GetStageData(self.CurBossStageCfg.StageId) + local curScore = stageData and stageData.Score or 0 + --local text = CS.XTextManager.GetText("BossSingleBossScore", curScore, score) + self:SetMyScore(score, curScore) + self.ImgEffect.gameObject:SetActiveEx(self.Index > XFubenBossSingleConfigs.DifficultyType.kinght) + + -- 设置自动按钮状态 + local maxCount = XFubenBossSingleConfigs.AUTO_FIGHT_COUNT + local curCount = XFubenBossSingleConfigs.AUTO_FIGHT_COUNT - self.BossSingleData.AutoFightCount + + if maxCount > 0 then + self.BtnAuto:SetName(CS.XTextManager.GetText("BossSingleAutoFightCount2", curCount, maxCount)) + else + self.BtnAuto:SetName(CS.XTextManager.GetText("BossSingleAutoFightCount1")) + end + + self.BtnAuto.gameObject:SetActiveEx(self.CurBossStageCfg.AutoFight) + local autoFightData = XDataCenter.FubenBossSingleManager.CheckAtuoFight(self.CurBossStageCfg.StageId) + + + if autoFightData then + local autoScore = math.floor(XFubenBossSingleConfigs.AUTO_FIGHT_REBATE * autoFightData.Score / 100) + if curScore >= autoScore then + self.BtnAuto:SetButtonState(CS.UiButtonState.Disable) + else + self.BtnAuto:SetButtonState(CS.UiButtonState.Normal) + end + else + self.BtnAuto:SetButtonState(CS.UiButtonState.Disable) + end +end + +-- 设置隐藏Boss相关信息 +function XUiPanelBossDetail:RefreshHideBoss() + local hasHideBoss = XDataCenter.FubenBossSingleManager.CheckLevelHasHideBoss() + if not hasHideBoss then + self:HideBossGridDisable() + self.TxtSelectedEn.gameObject:SetActiveEx(true) + self.TxtHideSelectedBoss.gameObject:SetActiveEx(false) + return + end + + local isHideOpen, desc = XDataCenter.FubenBossSingleManager.CheckHideBossOpenByBossId(self.BossId) + if not isHideOpen then + if self.CurBossStageCfg.DifficultyType == XFubenBossSingleConfigs.DifficultyType.hell then + self.TxtSelectedEn.gameObject:SetActiveEx(false) + self.TxtNormalEn.gameObject:SetActiveEx(false) + self.TxtHideSelectedBoss.gameObject:SetActiveEx(true) + self:HideBossGridEnable(true) + self.TxtHideLockBoss.gameObject:SetActiveEx(true) + + self.TxtHideLockBoss.text = desc + + local stageData = XDataCenter.FubenManager.GetStageData(self.CurBossStageCfg.StageId) + local time = stageData and stageData.BestRecordTime or 0 + if time > 0 then + self.TxtHideSelectedBoss.text = CS.XTextManager.GetText("BossSingleNameHidePassDesc1", time) + else + self.TxtHideSelectedBoss.text = CS.XTextManager.GetText("BossSingleNameHidePassDesc2") + end + else + self:HideBossGridDisable() + end + return + end + + self.TxtSelectedEn.gameObject:SetActiveEx(true) + self.TxtNormalEn.gameObject:SetActiveEx(true) + self.TxtHideSelectedBoss.gameObject:SetActiveEx(false) + self:HideBossGridEnable() + self.TxtHideLockBoss.gameObject:SetActiveEx(false) +end + +function XUiPanelBossDetail:HideBossGridEnable(needAnim) + if not needAnim then + self.HideBossBtnGrid.gameObject:SetActiveEx(true) + return + end + + if not self.HideBossBtnGrid.gameObject.activeSelf then + self.GridBossLevel6Alpha.alpha = 0 + self.HideBossBtnGrid.gameObject:SetActiveEx(true) + end + + self.RootUi:PlayAnimation("GridBossLevel6Enable") +end + +function XUiPanelBossDetail:HideBossGridDisable(needAnim) + if not needAnim then + self.HideBossBtnGrid.gameObject:SetActiveEx(false) + return + end + + if not self.HideBossBtnGrid.gameObject.activeSelf then + self.GridBossLevel6Alpha.alpha = 1 + self.HideBossBtnGrid.gameObject:SetActiveEx(true) + end + + self.RootUi:PlayAnimation("GridBossLevel6Disable", function() + self.HideBossBtnGrid.gameObject:SetActiveEx(false) + end) +end + +function XUiPanelBossDetail:CheckClick(index, isLogTip) + local isPassed = XDataCenter.FubenBossSingleManager.CheckStagePassed(self.BossId, index) + local sectionInfo = XDataCenter.FubenBossSingleManager.GetBossSectionInfo(self.BossId) + local isOpen, desc = XDataCenter.FubenBossSingleManager.CheckBossOpen(sectionInfo[index]) + + if (not isPassed or not isOpen) and isLogTip then + local text + if not isOpen then + text = desc + else + local preName = "" + if index ~= 1 then + if sectionInfo ~= nil then + local stageId = sectionInfo[index - 1].StageId + preName = XDataCenter.FubenManager.GetStageName(stageId) + end + end + text = CS.XTextManager.GetText("FubenPreStage", preName) + end + XUiManager.TipError(text) + end + + return isPassed and isOpen +end + +function XUiPanelBossDetail:OnBtnStartClick() + local stageId = self.CurBossStageCfg.StageId + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + local teamBuffId = XFubenBossSingleConfigs.GetBossSectionTeamBuffId(self.BossId) + local data = {TeamBuffId = teamBuffId} + XDataCenter.FubenManager.OpenRoomSingle(stageCfg, data) +end + +function XUiPanelBossDetail:OnBtnClickClick() + -- TODO::播放模型动画 +end + +function XUiPanelBossDetail:OnBtnAutoClick() + if not self.CurBossStageCfg.AutoFight then + local text = CS.XTextManager.GetText("BossSingleAutoFightDesc2", self.CurBossStageCfg.DifficultyDesc) + XUiManager.TipMsg(text) + return + end + + local autoFightData = XDataCenter.FubenBossSingleManager.CheckAtuoFight(self.CurBossStageCfg.StageId) + if not autoFightData then + XUiManager.TipText("BossSingleAutoFightDesc1") + return + end + + local stageData = XDataCenter.FubenManager.GetStageData(self.CurBossStageCfg.StageId) + local curScore = stageData and stageData.Score or 0 + local autoScore = math.floor(XFubenBossSingleConfigs.AUTO_FIGHT_REBATE * autoFightData.Score / 100) + if curScore >= autoScore then + XUiManager.TipText("BossSingleAutoFightDesc12") + return + end + + local maxCount = XFubenBossSingleConfigs.AUTO_FIGHT_COUNT + local curCount = XFubenBossSingleConfigs.AUTO_FIGHT_COUNT - self.BossSingleData.AutoFightCount + + if maxCount > 0 and curCount <= 0 then + XUiManager.TipText("BossSingleAutoFightCount3") + return + end + + self.AutoFightOpen = true + self.PanelAutoFight:Open(autoFightData, self.BossSingleData.ChallengeCount, self.CurBossStageCfg, function() + for k, _ in ipairs(self.TabBtnGroup.TabBtnList) do + if self:CheckClick(k, false) then + self.TabBtnGroup:UnLockIndex(k) + else + self.TabBtnGroup:LockIndex(k) + end + end + + self:SetAutoFightClose() + + if self.Index then + self.TabBtnGroup:SelectIndex(self.Index) + else + local index = XDataCenter.FubenBossSingleManager.GetCurBossIndex(self.BossId) + self.TabBtnGroup:SelectIndex(index) + end + + end) + self.RootUi:PlayAnimation("PanelAutoFightEnable") +end + +function XUiPanelBossDetail:CheckAutoFightOpen() + return self.AutoFightOpen +end + +function XUiPanelBossDetail:SetAutoFightClose() + self.AutoFightOpen = false +end + +return XUiPanelBossDetail \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenBossSingle/XUiPanelBossDetailTip.lua b/Resources/Scripts/XUi/XUiFubenBossSingle/XUiPanelBossDetailTip.lua new file mode 100644 index 00000000..637f265a --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenBossSingle/XUiPanelBossDetailTip.lua @@ -0,0 +1,102 @@ +local XUiPanelBossDetailTip = XClass(nil, "XUiPanelBossDetailTip") + +function XUiPanelBossDetailTip:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self.GridBuffList = {} + + XTool.InitUiObject(self) + self:AutoAddListener() + self:Init() +end + +function XUiPanelBossDetailTip:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelBossDetailTip:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelBossDetailTip:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelBossDetailTip:AutoAddListener() + self:RegisterClickEvent(self.BtnDetail, self.OnBtnDetailClick) +end + +function XUiPanelBossDetailTip:Init() + self.GridBuffDetail.gameObject:SetActiveEx(false) +end + +function XUiPanelBossDetailTip:ShowBossTip(bossStageCfg) + self.BossStageCfg = bossStageCfg + + local buffDetailIds = bossStageCfg.BuffDetailsId + local featuresIds = bossStageCfg.FeaturesId + local showFeatures = featuresIds and #featuresIds > 0 + local showBuff = buffDetailIds and #buffDetailIds > 0 + + if not showBuff and not showFeatures then + self:HidePanel() + return + end + local isHideBoss = self.BossStageCfg.DifficultyType == XFubenBossSingleConfigs.DifficultyType.Hide + self.PanelFeatures.gameObject:SetActiveEx(showFeatures) + self.PanelBuffDetail.gameObject:SetActiveEx(showBuff) + self.PanelHideBg.gameObject:SetActiveEx(isHideBoss) + self.PanelBg.gameObject:SetActiveEx(not isHideBoss) + + -- 设置词缀 + if showFeatures then + local featureCfg = XFubenConfigs.GetFeaturesById(featuresIds[1]) + self.TxtFeatureTitle.text = featureCfg.Name + self.TxtFeatureDesc.text = featureCfg.Desc + end + + for _, grid in pairs(self.GridBuffList) do + grid.gameObject:SetActiveEx(false) + end + + if showBuff then + for i = 1, #buffDetailIds do + local grid = self.GridBuffList[i] + if not grid then + grid = CS.UnityEngine.Object.Instantiate(self.GridBuffDetail) + grid.transform:SetParent(self.PanelBuffContent, false) + self.GridBuffList[i] = grid + end + + local icon = XUiHelper.TryGetComponent(grid.transform, "RImgIcom", "RawImage") + local name = XUiHelper.TryGetComponent(grid.transform, "TxtName", "Text") + local bg = XUiHelper.TryGetComponent(grid.transform, "ImgfTriangleBg", "Image") + local buffCfg = XFubenBabelTowerConfigs.GetBabelBuffConfigs(buffDetailIds[i]) + icon:SetRawImage(buffCfg.BuffBg) + name.text = buffCfg.Name + if buffCfg.BuffTriangleBg then + self.RootUi:SetUiSprite(bg, buffCfg.BuffTriangleBg) + end + + grid.gameObject:SetActiveEx(true) + end + end + + self.GameObject:SetActiveEx(true) +end + +function XUiPanelBossDetailTip:OnBtnDetailClick() + XLuaUiManager.Open("UiFubenBossSingleHide", self.BossStageCfg) +end + +function XUiPanelBossDetailTip:HidePanel() + self.GameObject:SetActiveEx(false) +end + +return XUiPanelBossDetailTip \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenBossSingle/XUiPanelBossEnter.lua b/Resources/Scripts/XUi/XUiFubenBossSingle/XUiPanelBossEnter.lua new file mode 100644 index 00000000..7f88b43b --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenBossSingle/XUiPanelBossEnter.lua @@ -0,0 +1,196 @@ +local XUiPanelBossEnter = XClass(nil, "XUiPanelBossEnter") +local XUiPanelScoreInfo = require("XUi/XUiFubenBossSingle/XUiPanelScoreInfo") +local XUiPanelGroupInfo = require("XUi/XUiFubenBossSingle/XUiPanelGroupInfo") + +function XUiPanelBossEnter:Ctor(rootUi, ui, bossSingleData) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.BossSingleData = bossSingleData + self.CurScoreRewardId = -1 + self.RootUi = rootUi + self.GridRewardList = {} + XTool.InitUiObject(self) + self:AutoAddListener() + self:RegisterRedPointEvent() + self:Init() +end + +function XUiPanelBossEnter:CheckRedPoint() + if self.EventId then + XRedPointManager.Check(self.EventId) + end +end + +function XUiPanelBossEnter:RegisterRedPointEvent() + self.EventId = XRedPointManager.AddRedPointEvent(self.ImgRedHint, self.OnCheckRewardNews, self, { XRedPointConditions.Types.CONDITION_BOSS_SINGLE_REWARD }) + XEventManager.AddEventListener(XEventId.EVENT_FUBEN_SINGLE_BOSS_RANK_SYNC, self.OnSyncBossRank, self) +end + +function XUiPanelBossEnter:OnDestroy() + XEventManager.RemoveEventListener(XEventId.EVENT_FUBEN_SINGLE_BOSS_RANK_SYNC, self.OnSyncBossRank, self) +end + +function XUiPanelBossEnter:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelBossEnter:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelBossEnter:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelBossEnter:AutoAddListener() + self:RegisterClickEvent(self.BtnActDesc, self.OnBtnActDescClick) + self:RegisterClickEvent(self.BtnRank, self.OnBtnRankClick) + self:RegisterClickEvent(self.BtnReward, self.OnBtnRewardClick) + self:RegisterClickEvent(self.BtnShop, self.OnBtnShopClick) +end + +function XUiPanelBossEnter:Init() + local rankLevelCfg = XDataCenter.FubenBossSingleManager.GetRankLevelCfgByType(self.BossSingleData.LevelType) + + self.RootUi:SetUiSprite(self.ImgLevelIcon, rankLevelCfg.Icon) + self.TxtLevelName.text = rankLevelCfg.LevelName + local text = CS.XTextManager.GetText("BossSingleRankDesc", rankLevelCfg.MinPlayerLevel, rankLevelCfg.MaxPlayerLevel) + self.TxtLevel.text = "(" .. text .. ")" + self.GridReward.gameObject:SetActiveEx(false) + self.ScoreInfo = XUiPanelScoreInfo.New(self.RootUi, self.PanelScoreInfo, self.BossSingleData) + self.GroupInfo = XUiPanelGroupInfo.New(self.RootUi, self.PanelGroupInfo) + self.RootUi:PlayAnimation("AnimScoreInfoDisable") + self.ScoreInfo:HidePanel() + self.GroupInfo:HidePanel() + self:ShowPanel(true, self.BossSingleData) +end + +function XUiPanelBossEnter:OnSyncBossRank() + local rank = XDataCenter.FubenBossSingleManager.GetSelfRank() + local totalRank = XDataCenter.FubenBossSingleManager.GetSelfTotalRank() + local maxCount = XDataCenter.FubenBossSingleManager.MAX_RANK_COUNT + if rank <= maxCount and rank > 0 then + self.TxtRank.text = math.floor(rank) + else + if not totalRank or totalRank <= 0 or rank <= 0 then + self.TxtRank.text = CS.XTextManager.GetText("None") + else + local num = math.floor(rank / totalRank * 100) + if num < 1 then + num = 1 + end + + self.TxtRank.text = CS.XTextManager.GetText("BossSinglePrecentDesc", num) + end + end +end + +function XUiPanelBossEnter:ShowPanel(refresh, bossSingleData, isAutoFight, isSync) + if bossSingleData then + self.BossSingleData = bossSingleData + end + + self:CheckRedPoint() + if refresh then + local allCount = XDataCenter.FubenBossSingleManager.GetChallengeCount() + local numText = CS.XTextManager.GetText("BossSingleChallengeCount", self.BossSingleData.ChallengeCount, allCount) + + self.TxtLeftCount.text = numText + self.TxtScore.text = self.BossSingleData.TotalScore + + self:OnSyncBossRank() + self:SetRewardInfo() + + local isInLevelTypeHigh = XDataCenter.FubenBossSingleManager.IsInLevelTypeHigh() + local isChooseLevelTypeConditionOk = XDataCenter.FubenBossSingleManager.IsChooseLevelTypeConditionOk() + self.PanelChooseLevelConditionOk.gameObject:SetActiveEx(isInLevelTypeHigh and isChooseLevelTypeConditionOk) + self.PanelChooseLevelConditionBad.gameObject:SetActiveEx(isInLevelTypeHigh and not isChooseLevelTypeConditionOk) + end + + if not isAutoFight then + if not isSync then + self.RootUi:PlayAnimation("AnimEnable1") + end + self.GameObject:SetActiveEx(true) + end +end + +function XUiPanelBossEnter:SetRewardInfo() + local scoreReardCfg = XDataCenter.FubenBossSingleManager.GetCurScoreRewardCfg() + local rewardList = {} + + if scoreReardCfg then + local needScore = CS.XTextManager.GetText("BossSingleScore", scoreReardCfg.Score) + self.TxtReward.text = needScore + rewardList = XRewardManager.GetRewardList(scoreReardCfg.RewardId) + else + local needScore = CS.XTextManager.GetText("BossSingleNoNeedScore") + self.TxtReward.text = needScore + end + + if scoreReardCfg and self.CurScoreRewardId == scoreReardCfg.Id then + return + end + + self.CurScoreRewardId = scoreReardCfg and scoreReardCfg.Id or -1 + + for i = 1, #rewardList do + local grid = self.GridRewardList[i] + if not grid then + local ui = CS.UnityEngine.Object.Instantiate(self.GridReward) + grid = XUiGridCommon.New(self.RootUi, ui) + grid.Transform:SetParent(self.PanelRewardContent, false) + self.GridRewardList[i] = grid + end + + grid:Refresh(rewardList[i]) + grid.GameObject:SetActiveEx(true) + end + + for i = #rewardList + 1, #self.GridRewardList do + self.GridRewardList[i].GameObject:SetActiveEx(false) + end +end + +function XUiPanelBossEnter:HidePanel() + self.GameObject:SetActiveEx(false) +end + +function XUiPanelBossEnter:OnBtnActDescClick() + local text = CS.XTextManager.GetText("BossSingleDesc") + XUiManager.UiFubenDialogTip("", text or "") +end + +function XUiPanelBossEnter:OnBtnRankClick() + local func = function() + self.RootUi:ShowBossRank(self.BossSingleData.LevelType, self.BossSingleData.RankPlatform) + end + XDataCenter.FubenBossSingleManager.GetRankData(func, self.BossSingleData.LevelType) +end + +function XUiPanelBossEnter:OnBtnRewardClick() + self.ScoreInfo:ShowPanel(self.BossSingleData) + self.RootUi:PlayAnimation("AnimScoreInfoEnable") +end + +function XUiPanelBossEnter:OnBtnShopClick() + XLuaUiManager.Open("UiShop", XShopManager.ShopType.Boss) +end + +function XUiPanelBossEnter:ShowBossGroupInfo(groupId) + self.GroupInfo:ShowBossGroupInfo(groupId) +end + +-- 红点 +function XUiPanelBossEnter:OnCheckRewardNews(count) + if self.ImgRedHint then + self.ImgRedHint.gameObject:SetActiveEx(count > 0) + end +end + +return XUiPanelBossEnter \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenBossSingle/XUiPanelBossRankInfo.lua b/Resources/Scripts/XUi/XUiFubenBossSingle/XUiPanelBossRankInfo.lua new file mode 100644 index 00000000..fe967551 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenBossSingle/XUiPanelBossRankInfo.lua @@ -0,0 +1,204 @@ +local XUiPanelBossRankInfo = XClass(nil, "XUiPanelBossRankInfo") +local XUiPanelMyBossRank = require("XUi/XUiFubenBossSingle/XUiPanelMyBossRank") +local XUiPanelRankReward = require("XUi/XUiFubenBossSingle/XUiPanelRankReward") +local XUiGridBossRank = require("XUi/XUiFubenBossSingle/XUiGridBossRank") + +function XUiPanelBossRankInfo:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + self:AutoAddListener() + self.PanelRankReward.gameObject:SetActive(false) + self.GridRankList = {} + self.GridRankLevel.gameObject:SetActive(false) + self.GridBossRank.gameObject:SetActive(false) + self.TxtCurTime.text = "" + self:Init() +end + +function XUiPanelBossRankInfo:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelBossRankInfo:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelBossRankInfo:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelBossRankInfo:AutoAddListener() + self:RegisterClickEvent(self.BtnRankReward, self.OnBtnRankRewardClick) +end + +function XUiPanelBossRankInfo:Init() + if self.TabBtnGroup then + self.TabBtnGroup:Dispose() + end + self.TabBtnGroup = nil + self.BtnTabList = {} + local Cfgs = XDataCenter.FubenBossSingleManager.GetRankLevelCfgs() + + for _ = 1, #Cfgs do + local grid = CS.UnityEngine.Object.Instantiate(self.GridRankLevel) + grid.transform:SetParent(self.PanelTags, false) + grid.gameObject:SetActive(true) + table.insert(self.BtnTabList, grid) + end + + self.TabBtnGroup = XUiTabBtnGroup.New(self.BtnTabList, function(levelType) + self:RefreshRankInfo(levelType) + end) + + for k, btn in ipairs(self.TabBtnGroup.TabBtnList) do + local text = CS.XTextManager.GetText("BossSingleRankDesc", Cfgs[k].MinPlayerLevel, Cfgs[k].MaxPlayerLevel) + btn:SetName(Cfgs[k].LevelName, text) + local icon = btn.Transform:Find("RImgIcon"):GetComponent("RawImage") + icon:SetRawImage(Cfgs[k].Icon) + self.TabBtnGroup:UnLockIndex(k) + end + + self.MyBossRank = XUiPanelMyBossRank.New(self.RootUi, self.PanelMyBossRank) + self.MyBossRank:HidePanel() + self.RankReward = XUiPanelRankReward.New(self.RootUi, self.PanelRankReward) +end + + +function XUiPanelBossRankInfo:ShowPanel(levelType, rankPlatform) + self.CurLevelType = levelType + self.RankPlatform = rankPlatform + + self.TabBtnGroup:SelectIndex(self.CurLevelType) + self.GameObject:SetActive(true) + + self.RootUi:PlayAnimation("AnimRankInfolEnable") + self:RefreshTime() +end + +function XUiPanelBossRankInfo:HidePanel() + self:RemoveTimer() + self.GameObject:SetActive(false) +end + +function XUiPanelBossRankInfo:RefreshRankInfo(levelType) + self.CurLevelType = levelType + self.RootUi:PlayAnimation("AnimInfoQieHuan") + self:RefreshRank() +end + +function XUiPanelBossRankInfo:RemoveTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end + +function XUiPanelBossRankInfo:RefreshRank() + local func = function(rankData) + self:SetRankInfo(rankData) + self:RefreshMyRankInfo(rankData) + end + XDataCenter.FubenBossSingleManager.GetRankData(func, self.CurLevelType) +end + +function XUiPanelBossRankInfo:RefreshTime() + local func = function(rankData) + self:SetLeftTime(rankData) + end + XDataCenter.FubenBossSingleManager.GetRankData(func, self.CurLevelType) +end + +function XUiPanelBossRankInfo:SetLeftTime(rankData) + local leftTime = rankData.LeftTime + if self.Timer then + self:RemoveTimer() + end + self.TxtIos.gameObject:SetActiveEx(false) + self.Timer = XScheduleManager.ScheduleForever(function() + if XTool.UObjIsNil(self.GameObject) then + return + end + + local desc = "BossSingleLeftTimeIos" + if self.RankPlatform == XFubenBossSingleConfigs.Platform.Win then + desc = "BossSingleLeftTimeWin" + elseif self.RankPlatform == XFubenBossSingleConfigs.Platform.Android then + desc = "BossSingleLeftTimeAndroid" + elseif self.RankPlatform == XFubenBossSingleConfigs.Platform.IOS then + desc = "BossSingleLeftTimeIos" + elseif self.RankPlatform == XFubenBossSingleConfigs.Platform.All then + desc = "BossSingleLeftTimeAll" + end + self.TxtIos.text = CS.XTextManager.GetText(desc) + + leftTime = leftTime - 1 + if leftTime <= 0 then + local dataTime = XUiHelper.GetTime(0) + self.TxtCurTime.text = CS.XTextManager.GetText("BossSingleLeftTime", dataTime) + self:RemoveTimer() + else + local dataTime = XUiHelper.GetTime(leftTime) + self.TxtCurTime.text = CS.XTextManager.GetText("BossSingleLeftTime", dataTime) + end + end, 1000) +end + +function XUiPanelBossRankInfo:SetRankInfo(rankData) + local count = #rankData.rankData + local maxCount = XDataCenter.FubenBossSingleManager.MAX_RANK_COUNT + + if #rankData.rankData > maxCount then + count = maxCount + end + + for i = 1, count do + local grid = self.GridRankList[i] + if not grid then + local ui = CS.UnityEngine.Object.Instantiate(self.GridBossRank) + grid = XUiGridBossRank.New(self.RootUi, ui) + grid.Transform:SetParent(self.PanelRankContent, false) + self.GridRankList[i] = grid + end + + grid:Refresh(rankData.rankData[i], self.CurLevelType) + grid.GameObject:SetActive(true) + end + + for i = count + 1, #self.GridRankList do + self.GridRankList[i].GameObject:SetActive(false) + end + + self.PanelNoRank.gameObject:SetActive(count <= 0) +end + +function XUiPanelBossRankInfo:RefreshMyRankInfo(rankData) + local myLevelType = XDataCenter.FubenBossSingleManager.GetBoosSingleData().LevelType + + self.MyRankData = { + MylevelType = myLevelType, + MineRankNum = rankData.MineRankNum, + HistoryMaxRankNum = rankData.HistoryMaxRankNum, + TotalCount = rankData.TotalCount, + } + + if self.CurLevelType == myLevelType then + self.MyBossRank:ShowPanel() + self.MyBossRank:Refresh(self.MyRankData) + else + self.MyBossRank:HidePanel() + end + +end + +function XUiPanelBossRankInfo:OnBtnRankRewardClick() + self.RankReward:ShowPanel(self.CurLevelType, self.MyRankData) +end + +return XUiPanelBossRankInfo \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenBossSingle/XUiPanelBossStgae.lua b/Resources/Scripts/XUi/XUiFubenBossSingle/XUiPanelBossStgae.lua new file mode 100644 index 00000000..5ae9fced --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenBossSingle/XUiPanelBossStgae.lua @@ -0,0 +1,168 @@ +local XUiPanelBossStgae = XClass(nil, "XUiPanelBossStgae") +local BOSS_MAX_COUNT = 3 + +function XUiPanelBossStgae:Ctor(parent, ui, bossList) + self.Parent = parent + self.BossList = bossList + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + self:AutoAddListener() + self:Init() +end + +function XUiPanelBossStgae:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelBossStgae:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelBossStgae:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelBossStgae:AutoAddListener() + self:RegisterClickEvent(self.BtnEnter1, self.OnBtnEnter1Click) + self:RegisterClickEvent(self.BtnEnter2, self.OnBtnEnter2Click) + self:RegisterClickEvent(self.BtnEnter3, self.OnBtnEnter3Click) + self:RegisterClickEvent(self.BtnName1, self.OnBtnName1Click) + self:RegisterClickEvent(self.BtnName2, self.OnBtnName2Click) + self:RegisterClickEvent(self.BtnName3, self.OnBtnName3Click) +end + +function XUiPanelBossStgae:Init() + self:RefreshBossInfo() +end + +function XUiPanelBossStgae:RefreshBossInfo() + self.GroupId = {} + for i = 1, BOSS_MAX_COUNT do + if not self.BossList[i] then + self["PanelStageLock" .. i].gameObject:SetActiveEx(true) + self["PanelStageOpen" .. i].gameObject:SetActiveEx(false) + self["PanelBossNameInfo" .. i].gameObject:SetActiveEx(false) + self["PanelHideBoss" .. i].gameObject:SetActiveEx(false) + self["PanelBossLeftTime" .. i].gameObject:SetActiveEx(false) + self["TxtBoosName" .. i].gameObject:SetActiveEx(false) + self["PanelRongtiaoBuff" .. i].gameObject:SetActiveEx(false) + self["TxtBoosName" .. i].text = "--" + self["TxtBoosLevel" .. i].text = "--" + return + end + + local bossId = self.BossList[i] + self["PanelStageLock" .. i].gameObject:SetActiveEx(false) + self["PanelStageOpen" .. i].gameObject:SetActiveEx(true) + self["PanelBossNameInfo" .. i].gameObject:SetActiveEx(true) + + local bossInfo = XDataCenter.FubenBossSingleManager.GetBossCurDifficultyInfo(bossId, i) + if bossInfo.isHideBoss then + self["TxtBoosLevel" .. i].text = CS.XTextManager.GetText("BossSingleNameHideDesc", bossInfo.bossDiffiName) + else + self["TxtBoosLevel" .. i].text = CS.XTextManager.GetText("BossSingleNameNotHideDesc", bossInfo.bossDiffiName) + end + + self["TxtBoosName" .. i].text = bossInfo.bossName + self["RImgBossIcon" .. i]:SetRawImage(bossInfo.bossIcon) + self["PanelHideBoss" .. i].gameObject:SetActiveEx(bossInfo.isHideBoss) + + self["ImgTag" .. i].gameObject:SetActiveEx(bossInfo.tagIcon ~= nil) + if bossInfo.tagIcon then + self.Parent:SetUiSprite(self["ImgTag" .. i], bossInfo.tagIcon) + end + + if bossInfo.groupName then + self["BtnName" .. i]:SetName(bossInfo.groupName) + end + + if bossInfo.groupIcon then + self["BtnName" .. i]:SetSprite(bossInfo.groupIcon) + end + + local leftTime = XFubenBossSingleConfigs.GetBossSectionLeftTime(bossId) + if leftTime > 0 then + local timeStr = XUiHelper.GetTime(leftTime, XUiHelper.TimeFormatType.ACTIVITY) + self["TxtBossLeftTime" .. i].text = CS.XTextManager.GetText("BossSingleBossSectionLeftTime", timeStr) + self["PanelBossLeftTime" .. i].gameObject:SetActiveEx(true) + else + self["PanelBossLeftTime" .. i].gameObject:SetActiveEx(false) + end + + local teamBuffId = XFubenBossSingleConfigs.GetBossSectionTeamBuffId(bossId) + local showBuffIcon = teamBuffId > 0 + self["PanelRongtiaoBuff" .. i].gameObject:SetActiveEx(showBuffIcon) + + self.GroupId[i] = bossInfo.groupId + end +end + +function XUiPanelBossStgae:RefreshBossDifficult() + for i = 1, BOSS_MAX_COUNT do + if self.BossList[i] then + local bossId = self.BossList[i] or 0 + local bossInfo = XDataCenter.FubenBossSingleManager.GetBossCurDifficultyInfo(bossId, i) + self["TxtBoosName" .. i].text = bossInfo.bossName + self["RImgBossIcon" .. i]:SetRawImage(bossInfo.bossIcon) + self["PanelHideBoss" .. i].gameObject:SetActiveEx(bossInfo.isHideBoss) + + if bossInfo.isHideBoss then + self["TxtBoosLevel" .. i].text = CS.XTextManager.GetText("BossSingleNameHideDesc", bossInfo.bossDiffiName) + else + self["TxtBoosLevel" .. i].text = CS.XTextManager.GetText("BossSingleNameNotHideDesc", bossInfo.bossDiffiName) + end + else + self["TxtBoosName" .. i].text = "--" + self["TxtBoosLevel" .. i].text = "--" + self["PanelHideBoss" .. i].gameObject:SetActiveEx(false) + end + end +end + +function XUiPanelBossStgae:EnterDetail(index) + if not self.BossList[index] then + XUiManager.TipText("BossSingleBossNotEnough") + return + end + self.Parent:ShowBossDetail(self.BossList[index]) +end + +function XUiPanelBossStgae:PanelBossContentActive(active) + self.GameObject:SetActiveEx(active) +end + +function XUiPanelBossStgae:OnBtnEnter1Click() + self:EnterDetail(1) +end + +function XUiPanelBossStgae:OnBtnEnter2Click() + self:EnterDetail(2) +end + +function XUiPanelBossStgae:OnBtnEnter3Click() + self:EnterDetail(3) +end + +function XUiPanelBossStgae:OnBtnName1Click() + local groupId = self.GroupId[1] + self.Parent:ShowBossGroupInfo(groupId) +end + +function XUiPanelBossStgae:OnBtnName2Click() + local groupId = self.GroupId[2] + self.Parent:ShowBossGroupInfo(groupId) +end + +function XUiPanelBossStgae:OnBtnName3Click() + local groupId = self.GroupId[3] + self.Parent:ShowBossGroupInfo(groupId) +end + +return XUiPanelBossStgae \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenBossSingle/XUiPanelGroupInfo.lua b/Resources/Scripts/XUi/XUiFubenBossSingle/XUiPanelGroupInfo.lua new file mode 100644 index 00000000..11d9e86f --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenBossSingle/XUiPanelGroupInfo.lua @@ -0,0 +1,94 @@ +local XUiPanelGroupInfo = XClass(nil, "XUiPanelGroupInfo") + +function XUiPanelGroupInfo:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self.GridBosList = {} + XTool.InitUiObject(self) + self:AutoAddListener() + self:Init() +end + +function XUiPanelGroupInfo:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelGroupInfo:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelGroupInfo:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelGroupInfo:AutoAddListener() + self:RegisterClickEvent(self.BtnBlock, self.OnBtnBlockClick) + self:RegisterClickEvent(self.BtnTanchuangClose, self.OnBtnBlockClick) +end + +function XUiPanelGroupInfo:Init() + self.GridBoss.gameObject:SetActiveEx(false) +end + +function XUiPanelGroupInfo:ShowBossGroupInfo(groupId) + self.RootUi:PlayAnimation("GroupInfoEnable") + local groupInfo = XFubenBossSingleConfigs.GetBossSingleGroupById(groupId) + self.TxtGroupName.text = groupInfo.GroupName + + self.TxtInfo.gameObject:SetActiveEx(XDataCenter.FubenBossSingleManager.IsInLevelTypeExtreme()) + + for _, grid in pairs(self.GridBosList) do + grid.gameObject:SetActiveEx(false) + end + + for i = 1, #groupInfo.SectionId do + local bossId = groupInfo.SectionId[i] + local sectionCfg = XDataCenter.FubenBossSingleManager.GetBossSectionCfg(bossId) + -- 判断关闭时间 + if XFubenBossSingleConfigs.IsInBossSectionTime(bossId) then + local grid = self.GridBosList[i] + if not grid then + grid = CS.UnityEngine.Object.Instantiate(self.GridBoss) + grid.transform:SetParent(self.PanelScoreContent, false) + self.GridBosList[i] = grid + end + + local headIcon = XUiHelper.TryGetComponent(grid.transform, "RImgBossIcon", "RawImage") + local nickname = XUiHelper.TryGetComponent(grid.transform, "TxtBoosName", "Text") + local sossStageCfg = XDataCenter.FubenBossSingleManager.GetBossStageCfg(sectionCfg.StageId[1]) + headIcon:SetRawImage(sectionCfg.BossHeadIcon) + nickname.text = sossStageCfg.BossName + + local panelBossLeftTime = XUiHelper.TryGetComponent(grid.transform, "PanelBossLeftTime") + local leftTime = XFubenBossSingleConfigs.GetBossSectionLeftTime(bossId) + if leftTime > 0 then + local textleftTime = XUiHelper.TryGetComponent(grid.transform, "PanelBossLeftTime/TxtBossLeftTime", "Text") + local timeStr = XUiHelper.GetTime(leftTime, XUiHelper.TimeFormatType.ACTIVITY) + textleftTime.text = CS.XTextManager.GetText("BossSingleBossSectionLeftTime", timeStr) + panelBossLeftTime.gameObject:SetActiveEx(true) + else + panelBossLeftTime.gameObject:SetActiveEx(false) + end + + grid.gameObject:SetActiveEx(true) + end + end + + self.GameObject:SetActiveEx(true) +end + +function XUiPanelGroupInfo:OnBtnBlockClick() + self:HidePanel() +end + +function XUiPanelGroupInfo:HidePanel() + self.GameObject:SetActiveEx(false) +end + +return XUiPanelGroupInfo \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenBossSingle/XUiPanelMyBossRank.lua b/Resources/Scripts/XUi/XUiFubenBossSingle/XUiPanelMyBossRank.lua new file mode 100644 index 00000000..78315ca7 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenBossSingle/XUiPanelMyBossRank.lua @@ -0,0 +1,77 @@ +local XUiPanelMyBossRank = XClass(nil, "XUiPanelMyBossRank") + +local MAX_SPECIAL_NUM = 3 + +function XUiPanelMyBossRank:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) +end + +function XUiPanelMyBossRank:Refresh(rankMyData) + if rankMyData then + self.RankMyData = rankMyData + else + return + end + + local boosSingleData = XDataCenter.FubenBossSingleManager.GetBoosSingleData() + local maxCount = XDataCenter.FubenBossSingleManager.MAX_RANK_COUNT + + if rankMyData.MineRankNum <= maxCount and rankMyData.MineRankNum > 0 then + self.TxtRankPrecent.gameObject:SetActive(false) + self.TxtRankNormal.gameObject:SetActive(math.floor(rankMyData.MineRankNum) > MAX_SPECIAL_NUM) + self.ImgRankSpecial.gameObject:SetActive(rankMyData.MineRankNum <= MAX_SPECIAL_NUM) + + if rankMyData.MineRankNum <= MAX_SPECIAL_NUM then + local icon = XDataCenter.FubenBossSingleManager.GetRankSpecialIcon(math.floor(rankMyData.MineRankNum)) + self.RootUi:SetUiSprite(self.ImgRankSpecial, icon) + else + self.TxtRankNormal.text = math.floor(rankMyData.MineRankNum) + end + else + self.TxtRankPrecent.gameObject:SetActive(true) + self.TxtRankNormal.gameObject:SetActive(false) + self.ImgRankSpecial.gameObject:SetActive(false) + local text + if rankMyData.MineRankNum > 0 then + if not rankMyData.TotalCount or rankMyData.TotalCount == 0 then + text = CS.XTextManager.GetText("None") + else + local num = math.floor(rankMyData.MineRankNum / rankMyData.TotalCount * 100) + if num < 1 then + num = 1 + end + + text = CS.XTextManager.GetText("BossSinglePrecentDesc", num) + end + else + text = CS.XTextManager.GetText("None") + end + self.TxtRankPrecent.text = text + end + + local text = CS.XTextManager.GetText("BossSingleBossRankSocre", boosSingleData.TotalScore) + self.TxtRankScore.text = text + local name = XPlayer.Name + self.TxtPlayerName.text = name + + XUiPLayerHead.InitPortrait(XPlayer.CurrHeadPortraitId, XPlayer.CurrHeadFrameId, self.Head) + + if rankMyData.HistoryMaxRankNum <= maxCount and rankMyData.HistoryMaxRankNum > 0 then + self.TxtHighistRank.text = math.floor(rankMyData.HistoryMaxRankNum) + else + self.TxtHighistRank.text = CS.XTextManager.GetText("None") + end +end + +function XUiPanelMyBossRank:HidePanel() + self.GameObject:SetActive(false) +end + +function XUiPanelMyBossRank:ShowPanel() + self.GameObject:SetActive(true) +end + +return XUiPanelMyBossRank \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenBossSingle/XUiPanelRankReward.lua b/Resources/Scripts/XUi/XUiFubenBossSingle/XUiPanelRankReward.lua new file mode 100644 index 00000000..c2449634 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenBossSingle/XUiPanelRankReward.lua @@ -0,0 +1,69 @@ +local XUiPanelRankReward = XClass(nil, "XUiPanelRankReward") +local XUiGridBossRankReward = require("XUi/XUiFubenBossSingle/XUiGridBossRankReward") + +function XUiPanelRankReward:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self.GridBossRankList = {} + XTool.InitUiObject(self) + self:AutoAddListener() + self.GridBossRankReward.gameObject:SetActive(false) +end + +function XUiPanelRankReward:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelRankReward:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelRankReward:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelRankReward:AutoAddListener() + self:RegisterClickEvent(self.BtnBlock, self.OnBtnBlockClick) +end + +function XUiPanelRankReward:ShowPanel(levelType, myRankData) + local cfgs = XDataCenter.FubenBossSingleManager.GetRankRewardCfg(levelType) + for i = 1, #cfgs do + local grid = self.GridBossRankList[i] + if not grid then + local ui = CS.UnityEngine.Object.Instantiate(self.GridBossRankReward) + grid = XUiGridBossRankReward.New(self.RootUi, ui) + grid.Transform:SetParent(self.PanelRankContent, false) + self.GridBossRankList[i] = grid + end + + grid:Refresh(cfgs[i], myRankData.MineRankNum, myRankData.MylevelType, myRankData.TotalCount) + grid.GameObject:SetActive(true) + end + + for i = #cfgs + 1, #self.GridBossRankList do + self.GridBossRankList[i].GameObject:SetActive(false) + end + + self.GameObject:SetActive(true) + self.RootUi:PlayAnimation("AnimRankRewardEnable") +end + +function XUiPanelRankReward:OnBtnBlockClick() + self:HidePanel() +end + +function XUiPanelRankReward:HidePanel() + self.RootUi:PlayAnimation("AnimRankRewardDisable", function() + self.GameObject:SetActive(false) + end) +end + +return XUiPanelRankReward + diff --git a/Resources/Scripts/XUi/XUiFubenBossSingle/XUiPanelScoreInfo.lua b/Resources/Scripts/XUi/XUiFubenBossSingle/XUiPanelScoreInfo.lua new file mode 100644 index 00000000..4d99de07 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenBossSingle/XUiPanelScoreInfo.lua @@ -0,0 +1,108 @@ +local XUiPanelScoreInfo = XClass(nil, "XUiPanelScoreInfo") +local XUiGridBossScore = require("XUi/XUiFubenBossSingle/XUiGridBossScore") + +function XUiPanelScoreInfo:Ctor(rootUi, ui, bossSingleData) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.BossSingleData = bossSingleData + self.RootUi = rootUi + self.GridBossScoreList = {} + XTool.InitUiObject(self) + self:AutoAddListener() + self:Init() +end + +function XUiPanelScoreInfo:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelScoreInfo:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelScoreInfo:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelScoreInfo:AutoAddListener() + self:RegisterClickEvent(self.BtnBlock, self.OnBtnBlockClick) +end + +function XUiPanelScoreInfo:Init() + self.GridBossScore.gameObject:SetActive(false) + self:Rrefrsh() +end + +function XUiPanelScoreInfo:ShowPanel(bossSingleData) + self.BossSingleData = bossSingleData + self:Rrefrsh() + self.GameObject:SetActive(true) +end + +function XUiPanelScoreInfo:Rrefrsh() + local cfgs = XDataCenter.FubenBossSingleManager.GetScoreRewardCfg(self.BossSingleData.LevelType) + local canGetList = {} + local unGetList = {} + local gotList = {} + + for i = 1, #cfgs do + local canGet = self.BossSingleData.TotalScore >= cfgs[i].Score + local isGet = XDataCenter.FubenBossSingleManager.CheckRewardGet(cfgs[i].Id) + if canGet and not isGet then + table.insert(canGetList, cfgs[i]) + elseif not canGet then + table.insert(unGetList, cfgs[i]) + else + table.insert(gotList, cfgs[i]) + end + end + + for i = 1, #unGetList do + table.insert(canGetList, unGetList[i]) + end + + for i = 1, #gotList do + table.insert(canGetList, gotList[i]) + end + + local curScore = CS.XTextManager.GetText("BossSingleScore2", self.BossSingleData.TotalScore) + self.TxtCurScore.text = curScore + + for i = 1, #canGetList do + local grid = self.GridBossScoreList[i] + if not grid then + local ui = CS.UnityEngine.Object.Instantiate(self.GridBossScore) + grid = XUiGridBossScore.New(self.RootUi, ui) + grid.Transform:SetParent(self.PanelScoreContent, false) + self.GridBossScoreList[i] = grid + end + + grid:Refresh(canGetList[i], self.BossSingleData.TotalScore) + grid.GameObject:SetActive(true) + end + + for i = #canGetList + 1, #self.GridBossScoreList do + self.GridBossScoreList[i].GameObject:SetActive(false) + end +end + +function XUiPanelScoreInfo:OnBtnBlockClick() + self:HidePanel(true) +end + +function XUiPanelScoreInfo:HidePanel(isAniam) + if isAniam then + self.RootUi:PlayAnimation("AnimScoreInfoDisable", function() + self.GameObject:SetActive(false) + end) + else + self.GameObject:SetActive(false) + end +end + +return XUiPanelScoreInfo \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenChallengeBanner/XUiFubenChallengeBanner.lua b/Resources/Scripts/XUi/XUiFubenChallengeBanner/XUiFubenChallengeBanner.lua new file mode 100644 index 00000000..3abc0ad1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenChallengeBanner/XUiFubenChallengeBanner.lua @@ -0,0 +1,172 @@ +local XUiFubenChallengeBanner = XLuaUiManager.Register(XLuaUi, "UiFubenChallengeBanner") + +function XUiFubenChallengeBanner:OnAwake() + self:InitAutoScript() + self.DynamicTable = XDynamicTableNormal.New(self.PanelChapterList) + self.DynamicTable:SetProxy(XUiGridChallengeBanner) + self.DynamicTable:SetDelegate(self) + self.GridChallengeBanner.gameObject:SetActive(false) +end + +function XUiFubenChallengeBanner:OnStart() + XEventManager.AddEventListener(XEventId.EVENT_FUBEN_DAILY_REFRESH, self.SetupDynamicTable, self) + XEventManager.AddEventListener(XEventId.EVENT_URGENTEVENT_SYNC, self.SetupDynamicTable, self) + XEventManager.AddEventListener(XEventId.EVENT_FUBEN_SINGLE_BOSS_SYNC, self.SetupDynamicTable, self) + +end + +function XUiFubenChallengeBanner:OnDestroy() + XEventManager.RemoveEventListener(XEventId.EVENT_FUBEN_DAILY_REFRESH, self.SetupDynamicTable, self) + XEventManager.RemoveEventListener(XEventId.EVENT_URGENTEVENT_SYNC, self.SetupDynamicTable, self) + XEventManager.RemoveEventListener(XEventId.EVENT_FUBEN_SINGLE_BOSS_SYNC, self.SetupDynamicTable, self) +end + +function XUiFubenChallengeBanner:OnEnable() + self:SetupDynamicTable() + XDataCenter.FubenManager.EnterChallenge() + self.IsShow = true + self:PlayAnimation("ChapterQieHuanEnable") +end + +function XUiFubenChallengeBanner:OnDisable() + self.IsShow = false +end + +--动态列表事件 +function XUiFubenChallengeBanner:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:UpdateGrid(self.PageDatas[index], self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + self:OnClickChapterGrid(self.PageDatas[index]) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_RECYCLE then + grid:OnRecycle() + end +end + +--设置动态列表 +function XUiFubenChallengeBanner:SetupDynamicTable(bReload) + self.PageDatas = XDataCenter.FubenManager.GetChallengeChapters() + self.DynamicTable:SetDataSource(self.PageDatas) + self.DynamicTable:ReloadDataSync(bReload and 1 or -1) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiFubenChallengeBanner:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiFubenChallengeBanner:AutoInitUi() + -- self.PanelChallengeChapter = self.Transform:Find("SafeAreaContentPane/PanelChallengeChapter") + -- self.PanelChapterList = self.Transform:Find("SafeAreaContentPane/PanelChallengeChapter/PanelChapterList") + -- self.PanelChapterContent = self.Transform:Find("SafeAreaContentPane/PanelChallengeChapter/PanelChapterList/Viewport/PanelChapterContent") + -- self.GridChallengeBanner = self.Transform:Find("SafeAreaContentPane/PanelChallengeChapter/PanelChapterList/Viewport/GridChallengeBanner") +end + +function XUiFubenChallengeBanner:AutoAddListener() +end +-- auto +function XUiFubenChallengeBanner:OnClickChapterGrid(chapter) + if chapter.IsClose then + XUiManager.TipText("CommonNotOpen") + return + end + + if chapter.Type == XDataCenter.FubenManager.ChapterType.BossSingle then + if XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.FubenChallengeBossSingle) then + if XDataCenter.FubenBossSingleManager.CheckNeedChooseLevelType() then + XLuaUiManager.Open("UiFubenBossSingleChooseLevelType") + return + end + + self.ParentUi:PushUi(function() + XDataCenter.FubenBossSingleManager.OpenBossSingleView() + end) + end + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.Urgent then + self.ParentUi:PushUi(function() + XLuaUiManager.Open("UiFubenChallengeMap", chapter) + end) + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.Explore then + if XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.FubenExplore) then + self.ParentUi:PushUi(function() + XLuaUiManager.Open("UiFubenExploreChapter") + end) + end + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.ARENA then + if XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.FubenArena) then + XDataCenter.ArenaManager.RequestSignUpArena(function() + self.ParentUi:PushUi(function() + XLuaUiManager.Open("UiArena", chapter) + end) + end) + end + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.Trial then + if XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.FubenChallengeTrial) then + if self.IsTrialOpening then + return + end + self.IsTrialOpening = true + self.ParentUi:PushUi(function() + XLuaUiManager.OpenWithCallback("UiTrial", function() + self.IsTrialOpening = nil + end) + end) + end + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.Practice then + + if XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.Practice) then + self.ParentUi:PushUi(function() + XLuaUiManager.Open(chapter.NameEn) + end) + end + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.Assign then + + if XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.FubenAssign) then + self.ParentUi:PushUi(function() + XLuaUiManager.Open(chapter.NameEn) + end) + end + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.InfestorExplore then + if XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.FubenInfesotorExplore) then + if XDataCenter.FubenInfestorExploreManager.IsInSectionOne() + or XDataCenter.FubenInfestorExploreManager.IsInSectionTwo() then + local openCb = function() + self.ParentUi:PushUi(function() + XLuaUiManager.Open("UiInfestorExploreRank") + end) + end + XDataCenter.FubenInfestorExploreManager.OpenEntranceUi(openCb) + elseif XDataCenter.FubenInfestorExploreManager.IsInSectionEnd() then + XUiManager.TipText("InfestorExploreEnterSectionEnd") + elseif not XDataCenter.FubenInfestorExploreManager.IsOpen() then + XUiManager.TipText("InfestorExploreEnterSectionEnd") + end + end + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.MaintainerAction then + self:OnClickMaintainerAction() + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.Stronghold then + local beforeOpenUiCb = handler(self.ParentUi, self.ParentUi.PushUi)--so sick! + XDataCenter.StrongholdManager.EnterUiMain(beforeOpenUiCb) + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.PartnerTeaching then + if XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.PartnerTeaching) then + self.ParentUi:PushUi(function() + XLuaUiManager.Open("UiPartnerTeachingBanner") + end) + end + end +end + +function XUiFubenChallengeBanner:OnClickMaintainerAction() + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.MaintainerAction) then + return + end + self.ParentUi:PushUi(function() + XDataCenter.MaintainerActionManager.OpenMaintainerActionWind() + end) +end + +function XUiFubenChallengeBanner:GuideGetDynamicTableIndex(id) + return id +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenChallengeBanner/XUiGridChallengeBanner.lua b/Resources/Scripts/XUi/XUiFubenChallengeBanner/XUiGridChallengeBanner.lua new file mode 100644 index 00000000..34e76ce6 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenChallengeBanner/XUiGridChallengeBanner.lua @@ -0,0 +1,390 @@ +XUiGridChallengeBanner = XClass(nil, "XUiGridChallengeBanner") + +function XUiGridChallengeBanner:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:InitAutoScript() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiGridChallengeBanner:InitAutoScript() + self:AutoAddListener() +end + +function XUiGridChallengeBanner:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiGridChallengeBanner:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiGridChallengeBanner:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiGridChallengeBanner:AutoAddListener() +end +-- auto +function XUiGridChallengeBanner:UpdateGrid(chapter) + self.Chapter = chapter + self.RImgChallenge.transform:DestroyChildren() + self.PanelLock.gameObject:SetActiveEx(false) + self.ImgRedPoint.gameObject:SetActiveEx(false) + self:UnBindTimer() + --显示New角标 + self.PanelNewEffect.gameObject:SetActiveEx(self:CanShowIconNew(chapter)) + if chapter.Type == XDataCenter.FubenManager.ChapterType.Urgent then + -- 紧急事件 + self.TxtRank.text = "" + self.TxtProgress.text = "" + self.TxtDes.text = chapter.UrgentCfg.SimpleDesc + self.ImgForbidEnter.gameObject:SetActiveEx(false) + self.RImgChallenge:SetRawImage(chapter.UrgentCfg.Icon) + local refreshTime = function() + local v = XCountDown.GetRemainTime(tostring(chapter.Id)) + v = v > 0 and v or 0 + local timeText = XUiHelper.GetTime(v, XUiHelper.TimeFormatType.CHALLENGE) + self.TxtTime.text = CS.XTextManager.GetText("BossSingleLeftTimeIcon", timeText) + end + refreshTime() + self.Timer = XScheduleManager.ScheduleForever(refreshTime, XScheduleManager.SECOND, 0) + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.ARENA then + -- 竞技副本 + self.TxtRank.text = "" + self.TxtDes.text = chapter.SimpleDesc + self.RImgChallenge:SetRawImage(chapter.Icon) + self.ImgForbidEnter.gameObject:SetActiveEx(false) + + local functionNameId = XFunctionManager.FunctionName.FubenArena + if not XFunctionManager.JudgeCanOpen(functionNameId) then + self.PanelLock.gameObject:SetActiveEx(true) + self.TxtLock.text = XFunctionManager.GetFunctionOpenCondition(functionNameId) + self.TxtTime.text = "" + self.TxtProgress.text = "" + else + local status = XDataCenter.ArenaManager.GetArenaActivityStatus() + if status == XArenaActivityStatus.Rest then + self.TxtProgress.text = CS.XTextManager.GetText("ArenaTeamDescription") + elseif status == XArenaActivityStatus.Fight then + local isJoin = XDataCenter.ArenaManager.GetIsJoinActivity() + if isJoin then + self.TxtProgress.text = CS.XTextManager.GetText("ArenaFightJoinDescription") + else + self.TxtProgress.text = CS.XTextManager.GetText("ArenaFightNotJoinDescription") + end + elseif status == XArenaActivityStatus.Over then + self.TxtProgress.text = CS.XTextManager.GetText("ArenaOverDescription") + end + + XCountDown.BindTimer(self, XArenaConfigs.ArenaTimerName, function(v) + v = v > 0 and v or 0 + local state = XDataCenter.ArenaManager.GetArenaActivityStatus() + local timeText = "" + if state == XArenaActivityStatus.Rest then + timeText = CS.XTextManager.GetText("ArenaActivityBeginCountDown") .. XUiHelper.GetTime(v, XUiHelper.TimeFormatType.CHALLENGE) + elseif state == XArenaActivityStatus.Fight then + timeText = CS.XTextManager.GetText("ArenaActivityEndCountDown", XUiHelper.GetTime(v, XUiHelper.TimeFormatType.CHALLENGE)) + elseif state == XArenaActivityStatus.Over then + timeText = CS.XTextManager.GetText("ArenaActivityResultCountDown") .. XUiHelper.GetTime(v, XUiHelper.TimeFormatType.CHALLENGE) + end + self.TxtTime.text = timeText + end) + end + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.Trial then + self.TxtTime.text = "" + self.TxtRank.text = "" + self.TxtProgress.text = "" + self.TxtDes.text = chapter.SimpleDesc + self.RImgChallenge:SetRawImage(chapter.Icon) + + local functionNameId = XFunctionManager.FunctionName.FubenChallengeTrial + if not XFunctionManager.JudgeCanOpen(functionNameId) then + self.PanelLock.gameObject:SetActiveEx(true) + self.TxtLock.text = XFunctionManager.GetFunctionOpenCondition(functionNameId) + self.TxtTime.text = "" + self.TxtProgress.text = "" + else + if not self.InitRedPoint then + self.InitRedPoint = true + self.RedPointId = XRedPointManager.AddRedPointEvent(self.ImgRedPoint, nil, self, { XRedPointConditions.Types.CONDITION_TRIAL_RED }) + end + XRedPointManager.Check(self.RedPointId) + if XDataCenter.TrialManager.FinishTrialType() == XDataCenter.TrialManager.TrialTypeCfg.TrialBackEnd and XDataCenter.TrialManager.TrialRewardGetedFinish() then + self.TxtProgress.text = CS.XTextManager.GetText("TrialBackEndPro", XDataCenter.TrialManager:TrialBackEndFinishLevel(), XTrialConfigs.GetBackEndTotalLength()) + else + self.TxtProgress.text = CS.XTextManager.GetText("TrialForPro", XDataCenter.TrialManager:TrialForFinishLevel(), XTrialConfigs.GetForTotalLength()) + + end + end + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.BossSingle then + self.RImgChallenge:SetRawImage(chapter.Icon) + self.TxtRank.text = "" + self.TxtTime.text = "" + self.TxtProgress.text = "" + self.TxtDes.text = chapter.SimpleDesc + + local functionNameId = XFunctionManager.FunctionName.FubenChallengeBossSingle + if not XFunctionManager.JudgeCanOpen(functionNameId) then + self.PanelLock.gameObject:SetActiveEx(true) + self.TxtLock.text = XFunctionManager.GetFunctionOpenCondition(functionNameId) + self.TxtTime.text = "" + self.TxtProgress.text = "" + else + if not self.InitRedPointBossSingle then + self.InitRedPointBossSingle = true + self.RedPointBossSingleId = XRedPointManager.AddRedPointEvent(self.ImgRedPoint, nil, self, { XRedPointConditions.Types.CONDITION_BOSS_SINGLE_REWARD }) + end + + -- 剩余时间 + XCountDown.BindTimer(self, XDataCenter.FubenBossSingleManager.GetResetCountDownName(), function(v) + v = v > 0 and v or 0 + local timeText = XUiHelper.GetTime(v, XUiHelper.TimeFormatType.CHALLENGE) + self.TxtTime.text = CS.XTextManager.GetText("BossSingleLeftTimeIcon", timeText) + end) + + -- 进度 + if XDataCenter.FubenBossSingleManager.CheckNeedChooseLevelType() then + self.TxtProgress.text = CS.XTextManager.GetText("BossSingleProgressChooseable") + else + local allCount = XDataCenter.FubenBossSingleManager.GetChallengeCount() + local challengeCount = XDataCenter.FubenBossSingleManager.GetBoosSingleData().ChallengeCount + self.TxtProgress.text = CS.XTextManager.GetText("BossSingleProgress", challengeCount, allCount) + end + end + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.Explore then + self.RImgChallenge:SetRawImage(chapter.Icon) + self.TxtRank.text = "" + self.TxtTime.text = "" + self.TxtProgress.text = "" + self.TxtDes.text = chapter.SimpleDesc + + local functionNameId = XFunctionManager.FunctionName.FubenExplore + if not XFunctionManager.JudgeCanOpen(functionNameId) then + self.PanelLock.gameObject:SetActiveEx(true) + self.TxtLock.text = XFunctionManager.GetFunctionOpenCondition(functionNameId) + self.TxtTime.text = "" + self.TxtProgress.text = "" + else + if not self.InitRedPointExplore then + self.InitRedPointExplore = true + self.RedPointExploreId = XRedPointManager.AddRedPointEvent(self.ImgRedPoint, nil, self, { XRedPointConditions.Types.CONDITION_EXPLORE_REWARD }) + end + XRedPointManager.Check(self.RedPointExploreId) + if XDataCenter.FubenExploreManager.GetCurProgressName() ~= nil then + self.TxtProgress.text = CS.XTextManager.GetText("ExploreBannerProgress") .. XDataCenter.FubenExploreManager.GetCurProgressName() + else + self.TxtProgress.text = CS.XTextManager.GetText("ExploreBannerProgressEnd") + end + end + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.Practice then + self.RImgChallenge:SetRawImage(chapter.Icon) + self.TxtRank.text = "" + self.TxtTime.text = "" + self.TxtProgress.text = "" + self.TxtDes.text = chapter.SimpleDesc + local functionNameId = XFunctionManager.FunctionName.Practice + + if not XFunctionManager.JudgeCanOpen(functionNameId) then + self.PanelLock.gameObject:SetActiveEx(true) + self.TxtLock.text = XFunctionManager.GetFunctionOpenCondition(functionNameId) + end + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.Assign then + self.RImgChallenge:SetRawImage(chapter.Icon) + self.TxtRank.text = "" + self.TxtTime.text = "" + self.TxtProgress.text = XDataCenter.FubenAssignManager.GetChapterProgressTxt() + self.TxtDes.text = chapter.SimpleDesc + local functionNameId = XFunctionManager.FunctionName.FubenAssign + if not XFunctionManager.JudgeCanOpen(functionNameId) then + self.PanelLock.gameObject:SetActiveEx(true) + self.TxtLock.text = XFunctionManager.GetFunctionOpenCondition(functionNameId) + else + self.TxtLock.text = "" + if not self.InitRedPointAssign then + self.InitRedPointAssign = true + self.RedPointAssignId = XRedPointManager.AddRedPointEvent(self.ImgRedPoint, nil, self, { XRedPointConditions.Types.CONDITION_ASSIGN_REWARD }) + end + XRedPointManager.Check(self.RedPointAssignId) + end + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.InfestorExplore then + self.RImgChallenge:SetRawImage(chapter.Icon) + self.TxtDes.text = chapter.SimpleDesc + self.TxtRank.text = "" + + local functionNameId = XFunctionManager.FunctionName.FubenInfesotorExplore + if not XFunctionManager.JudgeCanOpen(functionNameId) then + self.PanelLock.gameObject:SetActiveEx(true) + self.TxtProgress.gameObject:SetActiveEx(false) + self.TxtLock.text = XFunctionManager.GetFunctionOpenCondition(functionNameId) + else + self.TxtProgress.text = XDataCenter.FubenInfestorExploreManager.GetCurSectionName() + self.TxtProgress.gameObject:SetActiveEx(true) + self.PanelLock.gameObject:SetActiveEx(false) + XCountDown.BindTimer(self, XCountDown.GTimerName.FubenInfestorExplore, function(time) + time = time > 0 and time or 0 + local timeText = XUiHelper.GetTime(time, XUiHelper.TimeFormatType.CHALLENGE) + if XDataCenter.FubenInfestorExploreManager.IsInSectionOne() then + self.TxtTime.text = CS.XTextManager.GetText("InfestorExploreSectionLeftTimeSection1", timeText) + else + self.TxtTime.text = CS.XTextManager.GetText("InfestorExploreSectionLeftTimeSection2", timeText) + end + end) + end + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.MaintainerAction then + self:RefreshMaintainerActionBanner(chapter) + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.Stronghold then + self:RefreshStrongholdBanner() + elseif chapter.Type == XDataCenter.FubenManager.ChapterType.PartnerTeaching then + self:RefreshPartnerTeaching() + end +end + +function XUiGridChallengeBanner:OnRecycle() + self:UnBindTimer() +end + +function XUiGridChallengeBanner:UnBindTimer() + XCountDown.UnBindTimer(self, XCountDown.GTimerName.FubenInfestorExplore) + XCountDown.UnBindTimer(self, XCountDown.GTimerName.Stronghold) + XCountDown.UnBindTimer(self, XArenaConfigs.ArenaTimerName) + XCountDown.UnBindTimer(self, XDataCenter.FubenBossSingleManager.GetResetCountDownName()) + XCountDown.UnBindTimer(self, XDataCenter.MaintainerActionManager.GetResetCountDownName()) + if self.RedPointExploreId then + XRedPointManager.RemoveRedPointEvent(self.RedPointExploreId) + self.InitRedPointExplore = nil + self.RedPointExploreId = nil + end + + if self.RedPointId then + XRedPointManager.RemoveRedPointEvent(self.RedPointId) + self.InitRedPoint = nil + self.RedPointId = nil + end + + if self.RedPointBossSingleId then + XRedPointManager.RemoveRedPointEvent(self.RedPointBossSingleId) + self.InitRedPointBossSingle = nil + self.RedPointBossSingleId = nil + end + + if self.RedPointAssignId then + XRedPointManager.RemoveRedPointEvent(self.RedPointAssignId) + self.InitRedPointAssign = nil + self.RedPointAssignId = nil + end + + XEventManager.RemoveEventListener(XEventId.EVENT_STRONGHOLD_ACTIVITY_STATUS_CHANGE, self.RefreshStrongholdBanner, self) +end + +-- 显示新玩法新角标 +function XUiGridChallengeBanner:CanShowIconNew(chapter) + -- 检查是否有配置New角标时间段 + if string.IsNilOrEmpty(chapter.ShowNewStartTime) then return false end + -- 检查配置时间段是否符合条件 + local timeNow = XTime.GetServerNowTimestamp() + local startTime = XTime.ParseToTimestamp(chapter.ShowNewStartTime) + local endTime = XTime.ParseToTimestamp(chapter.ShowNewEndTime) + return startTime and endTime and startTime <= timeNow and endTime >= timeNow +end + +-- 大富翁玩法入口 +function XUiGridChallengeBanner:RefreshMaintainerActionBanner(chapter) + local name = XDataCenter.MaintainerActionManager.GetMaintainerActionName() + self.RImgChallenge:SetRawImage(chapter.Icon) + self.TxtDes.text = name + self.TxtRank.text = "" + self.TxtTime.text = "" + + local functionNameId = XFunctionManager.FunctionName.MaintainerAction + if not XFunctionManager.JudgeCanOpen(functionNameId) then + self.PanelLock.gameObject:SetActiveEx(true) + self.TxtProgress.gameObject:SetActiveEx(false) + self.TxtLock.text = XFunctionManager.GetFunctionOpenCondition(functionNameId) + else + self.TxtProgress.gameObject:SetActiveEx(true) + -- 剩余时间 + XCountDown.BindTimer(self, XDataCenter.MaintainerActionManager.GetResetCountDownName(), function(v) + v = v > 0 and v or 0 + local timeText = XUiHelper.GetTime(v, XUiHelper.TimeFormatType.CHALLENGE) + self.TxtTime.text = CS.XTextManager.GetText("MaintainerActionLeftTime", timeText) + end) + + -- 进度 + local gameData = XDataCenter.MaintainerActionManager.GetGameData() + local allCount = gameData:GetMaxFightWinCount() + local challengeCount = gameData:GetFightWinCount() + self.TxtProgress.text = CS.XTextManager.GetText("MaintainerActionProgress", challengeCount, allCount) + end +end + +-- 超级据点 +function XUiGridChallengeBanner:RefreshStrongholdBanner() + local chapter = self.Chapter + if not chapter then return end + + XEventManager.AddEventListener(XEventId.EVENT_STRONGHOLD_ACTIVITY_STATUS_CHANGE, self.RefreshStrongholdBanner, self) + + self.RImgChallenge:SetRawImage(chapter.Icon) + self.TxtDes.text = chapter.SimpleDesc + self.TxtRank.text = "" + + local functionNameId = XFunctionManager.FunctionName.Stronghold + if not XFunctionManager.JudgeCanOpen(functionNameId) then + self.PanelLock.gameObject:SetActiveEx(true) + self.TxtProgress.gameObject:SetActiveEx(false) + self.TxtLock.text = XFunctionManager.GetFunctionOpenCondition(functionNameId) + else + + if not XDataCenter.StrongholdManager.IsOpen() then + self.PanelLock.gameObject:SetActiveEx(true) + self.TxtProgress.gameObject:SetActiveEx(false) + self.TxtLock.text = CsXTextManagerGetText("StrongholdActivityTimeNotOpen") + else + + local finishCount = XDataCenter.StrongholdManager.GetFinishGroupCount() + local totalCount = XDataCenter.StrongholdManager.GetAllGroupCount() + self.TxtProgress.text = CsXTextManagerGetText("StrongholdActivityProgress", finishCount, totalCount) + self.TxtProgress.gameObject:SetActiveEx(true) + self.PanelLock.gameObject:SetActiveEx(false) + + XCountDown.UnBindTimer(self, XCountDown.GTimerName.Stronghold) + XCountDown.BindTimer(self, XCountDown.GTimerName.Stronghold, function(time) + time = time > 0 and time or 0 + + local timeText = XUiHelper.GetTime(time, XUiHelper.TimeFormatType.STRONGHOLD) + if XDataCenter.StrongholdManager.IsActivityBegin() then + self.TxtTime.text = CsXTextManagerGetText("StrongholdActivityTimeActivityBegin", timeText) + elseif XDataCenter.StrongholdManager.IsFightBegin() then + self.TxtTime.text = CsXTextManagerGetText("StrongholdActivityTimeFightBegin", timeText) + elseif XDataCenter.StrongholdManager.IsFightEnd() then + self.TxtTime.text = CsXTextManagerGetText("StrongholdActivityTimeFightEnd", timeText) + end + end) + + local isShow = XRedPointConditionStrongholdRewardCanGet.Check() + self.ImgRedPoint.gameObject:SetActiveEx(isShow) + end + end +end + +-- 宠物教学 +function XUiGridChallengeBanner:RefreshPartnerTeaching() + self.RImgChallenge:SetRawImage(self.Chapter.Icon) + self.TxtRank.text = "" + self.TxtTime.text = "" + self.TxtProgress.text = "" + self.TxtDes.text = self.Chapter.SimpleDesc + local functionNameId = XFunctionManager.FunctionName.PartnerTeaching + if not XFunctionManager.JudgeCanOpen(functionNameId) then + self.PanelLock.gameObject:SetActiveEx(true) + self.TxtLock.text = XFunctionManager.GetFunctionOpenCondition(functionNameId) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenChallengeEMEX/XUiFubenChallengeEMEX.lua b/Resources/Scripts/XUi/XUiFubenChallengeEMEX/XUiFubenChallengeEMEX.lua new file mode 100644 index 00000000..6dc33bf9 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenChallengeEMEX/XUiFubenChallengeEMEX.lua @@ -0,0 +1,249 @@ +local XUiFubenChallengeEMEX = XLuaUiManager.Register(XLuaUi, "UiFubenChallengeEMEX") +local MAX_DISPLAY_STAGE = 7 + +function XUiFubenChallengeEMEX:OnAwake() + self:InitAutoScript() + self.SViewBg.gameObject:SetActive(false) +end + +function XUiFubenChallengeEMEX:OnStart(parent, config) + self.Parent = parent + self:Init(config) + self.timer = XScheduleManager.ScheduleForever(self.Refresh, 0) + self.PanelHover.gameObject:SetActive(false) + self.OrgPosition = self.PanelMapContainer.transform.localPosition + self.TargetPosition = self.PanelTargetFlag.transform.position + + XEventManager.AddEventListener(XEventId.EVENT_FUBEN_CLOSE_FUBENSTAGEDETAIL, self.UnFocus, self) + XEventManager.AddEventListener(XEventId.EVENT_FUBEN_REFRESH_STAGE_DATA, self.RefreshStage, self) +end + +function XUiFubenChallengeEMEX:OnDestroy() + if self.timer then + XScheduleManager.UnSchedule(self.timer) + self.timer = nil + end + + XEventManager.RemoveEventListener(XEventId.EVENT_FUBEN_CLOSE_FUBENSTAGEDETAIL, self.UnFocus, self) + XEventManager.RemoveEventListener(XEventId.EVENT_FUBEN_REFRESH_STAGE_DATA, self.RefreshStage, self) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiFubenChallengeEMEX:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiFubenChallengeEMEX:AutoInitUi() + self.PanelMapContainer = self.Transform:Find("FullScreenBackground/PanelMapContainer") + self.SViewBg = self.Transform:Find("FullScreenBackground/PanelMapContainer/SViewBg"):GetComponent("ScrollRect") + self.PanelContentBg = self.Transform:Find("FullScreenBackground/PanelMapContainer/SViewBg/Viewport/PanelContentBg") + self.PanelBg = self.Transform:Find("FullScreenBackground/PanelMapContainer/SViewBg/Viewport/PanelContentBg/PanelBg") + self.SViewStage = self.Transform:Find("FullScreenBackground/PanelMapContainer/SViewStage"):GetComponent("ScrollRect") + self.PanelContent = self.Transform:Find("FullScreenBackground/PanelMapContainer/SViewStage/Viewport/PanelContent") + self.PanelStage = self.Transform:Find("FullScreenBackground/PanelMapContainer/SViewStage/Viewport/PanelContent/PanelStage") + --self.ImgOpen = self.Transform:Find("FullScreenBackground/PanelMapContainer/SViewStage/Viewport/PanelContent/PanelStage/Stage1/RImgOpen"):GetComponent("RawImage") + --self.ImgOpenA = self.Transform:Find("FullScreenBackground/PanelMapContainer/SViewStage/Viewport/PanelContent/PanelStage/Stage2/RImgOpen"):GetComponent("RawImage") + --self.ImgOpenB = self.Transform:Find("FullScreenBackground/PanelMapContainer/SViewStage/Viewport/PanelContent/PanelStage/Stage3/RImgOpen"):GetComponent("RawImage") + --self.ImgOpenC = self.Transform:Find("FullScreenBackground/PanelMapContainer/SViewStage/Viewport/PanelContent/PanelStage/Stage4/RImgOpen"):GetComponent("RawImage") + --self.ImgOpenD = self.Transform:Find("FullScreenBackground/PanelMapContainer/SViewStage/Viewport/PanelContent/PanelStage/Stage5/RImgOpen"):GetComponent("RawImage") + --self.ImgOpenE = self.Transform:Find("FullScreenBackground/PanelMapContainer/SViewStage/Viewport/PanelContent/PanelStage/Stage6/RImgOpen"):GetComponent("RawImage") + --self.ImgOpenF = self.Transform:Find("FullScreenBackground/PanelMapContainer/SViewStage/Viewport/PanelContent/PanelStage/Stage7/RImgOpen"):GetComponent("RawImage") + self.PanelTargetFlag = self.Transform:Find("FullScreenBackground/PanelTargetFlag") + self.PanelHover = self.Transform:Find("FullScreenBackground/PanelHover") +end + +function XUiFubenChallengeEMEX:GetAutoKey(uiNode, eventName) + if not uiNode then + return + end + return eventName .. uiNode:GetHashCode() +end + +function XUiFubenChallengeEMEX:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then + return + end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiFubenChallengeEMEX:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiFubenChallengeEMEX:AutoAddListener() + self.AutoCreateListeners = {} +end + +-- auto +function XUiFubenChallengeEMEX:Init(chapter) + self.SectionCfg = XDataCenter.FubenDailyManager.GetDailySectionByChapterId(chapter.Id) + local maxStage = math.min(#self.SectionCfg.StageId, MAX_DISPLAY_STAGE) + for i = 1, maxStage do + local stageId = self.SectionCfg.StageId[i] + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + local stageItem = self.PanelStage:Find("Stage" .. i) + local stageButton = stageItem:Find("Enter"):GetComponent("Button") + local stageLock = stageItem:Find("StageLock"):GetComponent("Button") + stageItem:Find("StageLock/Text"):GetComponent("Text").text = stageCfg.Name + stageItem:Find("StageOpen/Text"):GetComponent("Text").text = stageCfg.Name + local rImgOpen = stageItem:Find("RImgOpen"):GetComponent("RawImage") + --self:SetUiSprite(imgOpen, stageCfg.Icon) + rImgOpen:SetRawImage(stageCfg.Icon) + stageButton.interactable = true + stageLock.interactable = true + self:RegisterClickEvent(stageButton, function() + self:OpenDetail(stageItem, stageCfg) + end) + self:RegisterClickEvent(stageLock, function() + self:OpenDetail(stageItem, stageCfg) + end) + end + local linePanel = self.PanelStage:Find("Line") + local rectTransform = self.PanelContent:GetComponent("RectTransform") + local minX = rectTransform.sizeDelta.x + for i = maxStage + 1, MAX_DISPLAY_STAGE do + local stageItem = self.PanelStage:Find("Stage" .. i) + stageItem.gameObject:SetActive(false) + local line = linePanel:Find("Image" .. (i - 1)) + if line then + line.gameObject:SetActive(false) + local pos = self.PanelContent.transform:InverseTransformPoint(line.transform.position) + if minX then + minX = math.min(pos.x + 150, minX) + else + minX = pos.x + 150 + end + end + end + rectTransform.sizeDelta = CS.UnityEngine.Vector2(minX, rectTransform.sizeDelta.y) + self:RefreshStage() +end + +function XUiFubenChallengeEMEX:RefreshStage() + local maxStage = math.min(#self.SectionCfg.StageId, MAX_DISPLAY_STAGE) + for i = 1, maxStage do + local stageId = self.SectionCfg.StageId[i] + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + local stageItem = self.PanelStage:Find("Stage" .. i) + local stageLock = stageItem:Find("StageLock") + local stageOpen = stageItem:Find("StageOpen") + local enter = stageItem:Find("Enter") + local rImgOpen = XUiHelper.TryGetComponent(stageItem, "RImgOpen", "RawImage") + if stageInfo.Unlock then + rImgOpen:SetRawImage(stageCfg.Icon) + end + stageLock.gameObject:SetActive(not stageInfo.Unlock) + enter.gameObject:SetActive(stageInfo.Unlock) + rImgOpen.gameObject:SetActive(stageInfo.Unlock) + stageOpen.gameObject:SetActive(stageInfo.Unlock) + + end +end + +function XUiFubenChallengeEMEX:OpenDetail(stageItem, stageCfg) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageCfg.StageId) + if stageInfo and not stageInfo.Unlock then + local msg = XDataCenter.FubenManager.GetFubenOpenTips(stageCfg.StageId) + XUiManager.TipMsg(msg) + return + end + self:FocusStage(stageItem) + if stageCfg.IsMultiplayer then + self:OpenMultiplayerStageDetail(stageCfg, stageInfo) + else + self.Parent:OpenPanelStageDetail(stageCfg, stageInfo) + end +end + +function XUiFubenChallengeEMEX:OpenMultiplayerStageDetail(stageCfg) + -- XLuaUiManager.Open("UiOnLineTranscript", stageCfg) + XLuaUiManager.Open("UiFubenStageDetail", stageCfg) +end + +function XUiFubenChallengeEMEX:OnCloseStageDetail() + self:UnFocus() +end + +function XUiFubenChallengeEMEX:OnEnterFight() + self:UnFocus(true) +end + +function XUiFubenChallengeEMEX:FocusStage(stageItem) + local worldPos = stageItem.transform.position + local localPos = self.PanelMapContainer.transform:InverseTransformPoint(worldPos) + local tPos = self.PanelMapContainer.transform:InverseTransformPoint(self.TargetPosition) + local deltaPos = tPos - localPos + local lineAni = CS.UnityEngine.AnimationCurve.Linear(0, 0, 1, 1) + local startPos = self.PanelMapContainer.localPosition + self.PanelHover.gameObject:SetActive(true) + XUiHelper.Tween(0.3, function(t) + if XTool.UObjIsNil(self.PanelMapContainer) then + return + end + + self.PanelMapContainer.localPosition = startPos + deltaPos * lineAni:Evaluate(t) + end, function() + if XTool.UObjIsNil(self.PanelMapContainer) then + return + end + + self.PanelMapContainer.localPosition = startPos + deltaPos + end) +end + +function XUiFubenChallengeEMEX:UnFocus(immediate) + if immediate then + self.PanelMapContainer.localPosition = self.OrgPosition + self.PanelHover.gameObject:SetActive(false) + return + end + local startPos = self.PanelMapContainer.localPosition + local deltaPos = self.OrgPosition - startPos + local lineAni = CS.UnityEngine.AnimationCurve.Linear(0, 0, 1, 1) + XUiHelper.Tween(0.3, function(t) + if XTool.UObjIsNil(self.PanelMapContainer) then + return + end + + self.PanelMapContainer.localPosition = startPos + deltaPos * lineAni:Evaluate(t) + end, function() + if XTool.UObjIsNil(self.PanelMapContainer) then + return + end + + self.PanelMapContainer.localPosition = self.OrgPosition + self.PanelHover.gameObject:SetActive(false) + end) +end + +function XUiFubenChallengeEMEX:Refresh() + if XTool.UObjIsNil(self.GameObject) then + if self.timer then + XScheduleManager.UnSchedule(self.timer) + self.timer = nil + end + return + end + self.SViewBg.horizontalNormalizedPosition = self.SViewStage.horizontalNormalizedPosition + self.SViewBg.verticalNormalizedPosition = self.SViewStage.verticalNormalizedPosition +end + +return XUiFubenChallengeEMEX \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenChallengeMap/XUiFubenChallengeMap.lua b/Resources/Scripts/XUi/XUiFubenChallengeMap/XUiFubenChallengeMap.lua new file mode 100644 index 00000000..65eb1199 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenChallengeMap/XUiFubenChallengeMap.lua @@ -0,0 +1,377 @@ +local XUiFubenChallengeMap = XLuaUiManager.Register(XLuaUi, "UiFubenChallengeMap") + +local MAX_PLAYER_GRID_COUNT = 4 +local LOCAL_CHALLENGE_TIMER_NAME = "XUiFubenChallengeMapTitleTimer" + +function XUiFubenChallengeMap:OnAwake() + self:InitAutoScript() +end + +function XUiFubenChallengeMap:OnStart(challenge, timeOutCb) + self.TimeOutCb = timeOutCb + self:InitWithCfg(challenge) + XEventManager.AddEventListener(XEventId.EVENT_FUBEN_DAILY_REFRESH, self.RefreshReward, self) + XEventManager.AddEventListener(XEventId.EVENT_ROOM_CANCEL_MATCH, self.RefreshMatching, self) +end + +function XUiFubenChallengeMap:OnDestroy() + XCountDown.RemoveTimer(LOCAL_CHALLENGE_TIMER_NAME) + XEventManager.RemoveEventListener(XEventId.EVENT_FUBEN_DAILY_REFRESH, self.RefreshReward, self) + XEventManager.RemoveEventListener(XEventId.EVENT_ROOM_CANCEL_MATCH, self.RefreshMatching, self) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiFubenChallengeMap:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiFubenChallengeMap:AutoInitUi() + self.PanelContent = self.Transform:Find("FullScreenBackground/PanelContent") + self.PanelBottom = self.Transform:Find("SafeAreaContentPane/LayerWrap/PanelBottom") + self.BtnReward = self.Transform:Find("SafeAreaContentPane/LayerWrap/PanelBottom/GameObject/BtnReward"):GetComponent("Button") + self.ImgSlide = self.Transform:Find("SafeAreaContentPane/LayerWrap/PanelBottom/GameObject/ImgSlide"):GetComponent("Image") + self.TxtProgress = self.Transform:Find("SafeAreaContentPane/LayerWrap/PanelBottom/GameObject/TxtProgress"):GetComponent("Text") + self.Panelreceived = self.Transform:Find("SafeAreaContentPane/LayerWrap/PanelBottom/GameObject/Panelreceived") + self.PanelEffect = self.Transform:Find("SafeAreaContentPane/LayerWrap/PanelBottom/GameObject/PanelEffect") + self.BtnBack = self.Transform:Find("SafeAreaContentPane/LayerWrap/Top/BtnBack"):GetComponent("Button") + self.PanelAsset = self.Transform:Find("SafeAreaContentPane/LayerWrap/PanelAsset") + self.PanelTip = self.Transform:Find("SafeAreaContentPane/LayerWrap/PanelTip") + self.BtnCancelMatch = self.Transform:Find("SafeAreaContentPane/LayerWrap/PanelTip/BtnCancelMatch"):GetComponent("Button") + self.TxtPipei = self.Transform:Find("SafeAreaContentPane/LayerWrap/PanelTip/TxtPipei"):GetComponent("Text") + self.PanelEvent = self.Transform:Find("SafeAreaContentPane/LayerWrap/PanelEvent") + self.TxtEventDesc = self.Transform:Find("SafeAreaContentPane/LayerWrap/PanelEvent/head/TxtEventDesc"):GetComponent("Text") + self.PanelTitle = self.Transform:Find("SafeAreaContentPane/LayerWrap/PanelTitle") + self.BtnActDesc = self.Transform:Find("SafeAreaContentPane/LayerWrap/PanelTitle/BtnActDesc"):GetComponent("Button") + self.TxtShuaxin = self.Transform:Find("SafeAreaContentPane/LayerWrap/PanelTitle/TxtShuaxin"):GetComponent("Text") + self.TxtCurTime = self.Transform:Find("SafeAreaContentPane/LayerWrap/PanelTitle/TxtCurTime"):GetComponent("Text") + self.TxtBt = self.Transform:Find("SafeAreaContentPane/LayerWrap/PanelTitle/TxtBt"):GetComponent("Text") + self.BtnMainUi = self.Transform:Find("SafeAreaContentPane/LayerWrap/Top/BtnMainUi"):GetComponent("Button") +end + +function XUiFubenChallengeMap:GetAutoKey(uiNode, eventName) + if not uiNode then + return + end + return eventName .. uiNode:GetHashCode() +end + +function XUiFubenChallengeMap:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then + return + end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiFubenChallengeMap:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiFubenChallengeMap:AutoAddListener() + self.AutoCreateListeners = {} + self:RegisterClickEvent(self.BtnReward, self.OnBtnRewardClick) + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnCancelMatch, self.OnBtnCancelMatchClick) + self:RegisterClickEvent(self.BtnActDesc, self.OnBtnActDescClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) +end +-- auto +function XUiFubenChallengeMap:OnBtnRewardClick() + if not self.SectionCfg then + return + end + + if self.isGetChallengeReward then + XUiManager.TipText("ChallengeRewardIsGetted") + else + if self.curFightNum >= self.SectionCfg.RewardNeedFinishCount then + XDataCenter.FubenDailyManager.ReceiveDailyReward(function(reward) + self.isGetChallengeReward = true + XUiManager.OpenUiObtain(reward, CS.XTextManager.GetText("Award")) + self:RefreshReward() + end, self.SectionCfg.Id) + else + local data = XRewardManager.GetRewardList(self.SectionCfg.RewardId) + XUiManager.OpenUiTipReward(data) + end + end +end + +function XUiFubenChallengeMap:OnBtnActDescClick() + --详细介绍 + XUiManager.UiFubenDialogTip("", self.ChallengeCfg.DetailDesc or "") +end + +function XUiFubenChallengeMap:OnBtnCancelMatchClick() + XDataCenter.RoomManager.CancelMatch() +end + +function XUiFubenChallengeMap:RefreshPlayerState() + if XDataCenter.RoomManager.UiRoom then + -- self.PanelPlayerState.gameObject:SetActive(true) + local roomData = XDataCenter.RoomManager.RoomData + local idx = 1 + if roomData.PlayerDataList then + for i = 0, roomData.PlayerDataList.Count - 1 do + if roomData.PlayerDataList[i].Id ~= XPlayer.Id then + local grid = self.PlayerStateGridList[idx] + grid:SetActive(true) + grid:RefreshUI(roomData.PlayerDataList[i]) + idx = idx + 1 + end + end + end + + for index = idx, MAX_PLAYER_GRID_COUNT do + local grid = self.PlayerStateGridList[index] + grid:SetActive(false) + end + --else + -- self.PanelPlayerState.gameObject:SetActive(false) + end +end + +function XUiFubenChallengeMap:RefreshUI() + self:RefreshReward() + self:RefreshMatching() + self:RefreshShow() +end + +function XUiFubenChallengeMap:RefreshShow() + self.PanelTitle.gameObject:SetActive(self.ChallengeCfg.Type ~= XDataCenter.FubenManager.ChapterType.Urgent) + self:RefreshPlayerState() +end + +function XUiFubenChallengeMap:OnBtnBackClick() + local title = CS.XTextManager.GetText("TipTitle") + local cancelMatchMsg = CS.XTextManager.GetText("OnlineInstanceQuitRoom") + if XDataCenter.RoomManager.UiRoom then + CS.XUiManager.ViewManager:ShowNext() + else + if XDataCenter.RoomManager.Matching then + XUiManager.DialogTip(title, cancelMatchMsg, XUiManager.DialogType.Normal, nil, function() + XDataCenter.RoomManager.CancelMatch(function() + self:Close() + end) + end) + else + self:Close() + end + end +end + +function XUiFubenChallengeMap:OnBtnMainUiClick() + local title = CS.XTextManager.GetText("TipTitle") + local quitRoomMsg = CS.XTextManager.GetText("OnlineInstanceQuitRoom") + local cancelMatchMsg = CS.XTextManager.GetText("OnlineInstanceCancelMatch") + if XDataCenter.RoomManager.UiRoom then + XUiManager.DialogTip(title, quitRoomMsg, XUiManager.DialogType.Normal, nil, function() + XLuaUiManager.RunMain() + end) + else + if XDataCenter.RoomManager.Matching then + XUiManager.DialogTip(title, cancelMatchMsg, XUiManager.DialogType.Normal, nil, function() + XDataCenter.RoomManager.CancelMatch(function() + XLuaUiManager.RunMain() + end) + end) + else + XLuaUiManager.RunMain() + end + end +end + +function XUiFubenChallengeMap:InitTitle() + if self.ChallengeCfg.Type == XDataCenter.FubenManager.ChapterType.Urgent then + self.PanelTitle.gameObject:SetActive(false) + return + end + + if self.TxtShuaxin then + self.TxtShuaxin.text = CS.XTextManager.GetText("FubenChallengeResetTime") + end + + if self.ChallengeCfg.Type == XDataCenter.FubenManager.ChapterType.YSHTX or + self.ChallengeCfg.Type == XDataCenter.FubenManager.ChapterType.EMEX then + self.TxtBt.text = self.SectionCfg.Name or "" + end + + XCountDown.CreateTimer(LOCAL_CHALLENGE_TIMER_NAME, XDataCenter.FubenDailyManager.GetDailyRemainTime(self.ChallengeCfg.Id)) + XCountDown.BindTimer(self, LOCAL_CHALLENGE_TIMER_NAME, function(v) + if v > 0 then + self.TxtCurTime.text = XUiHelper.GetTime(v, XUiHelper.TimeFormatType.CHALLENGE) + else + if XLuaUiManager.IsUiShow("UiFubenChallengeMap") then + XUiManager.TipText("FubenDailyIsAlreadyReset") + self:Close() + if self.TimeOutCb then + self.TimeOutCb() + end + else + self:Remove() + end + end + end) +end + +function XUiFubenChallengeMap:InitWithCfg(challenge) + self.ChallengeCfg = challenge + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + if self.ChallengeCfg.Type == XDataCenter.FubenManager.ChapterType.Urgent then + self.SectionCfg = nil + else + self.SectionCfg = XDataCenter.FubenDailyManager.GetDailySectionByChapterId(challenge.Id) + end + + self:InitTitle() + self:InitChallengeEventDesc() + self:LoadContent() + self:InitRewardItem() + self:RefreshUI() +end + +function XUiFubenChallengeMap:InitRewardItem() + self.Panelreceived.gameObject:SetActive(false) + self.PanelEffect.gameObject:SetActive(false) + self.curFightNum = 0 + self.isGetChallengeReward = false +end + +function XUiFubenChallengeMap:RefreshReward() + --TODO 临时删除奖励 + self.PanelBottom.gameObject:SetActive(false) + -- local isGetChallengeReward = false + -- if not self.SectionCfg then + -- self.PanelBottom.gameObject:SetActive(false) + -- return + -- end + -- local sectionData = XDataCenter.FubenDailyManager.GetDailySectionData(self.SectionCfg.Id) + -- local curFightNum = 0 + -- if sectionData then + -- curFightNum = sectionData.PassTimesToday + -- isGetChallengeReward = sectionData.ReceiveReward + -- end + -- local rewardNeedFinishCount = self.SectionCf .RewardNeedFinishCount or 0 + -- if curFightNum > rewardNeedFinishCount then + -- curFightNum = rewardNeedFinishCount + -- end + -- self.ImgSlide.fillAmount = curFightNum / rewardNeedFinishCount + -- self.TxtProgress.text = (rewardNeedFinishCount - curFightNum) .. "/" .. rewardNeedFinishCount + -- if curFightNum >= rewardNeedFinishCount then + -- if isGetChallengeReward then + -- self.Panelreceived.gameObject:SetActive(true) + -- self.PanelEffect.gameObject:SetActive(false) + -- else + -- self.PanelEffect.gameObject:SetActive(true) + -- self.Panelreceived.gameObject:SetActive(false) + -- end + -- else + -- self.PanelEffect.gameObject:SetActive(false) + -- self.Panelreceived.gameObject:SetActive(false) + -- end + -- self.isGetChallengeReward = isGetChallengeReward + -- self.curFightNum = curFightNum +end + +function XUiFubenChallengeMap:RefreshMatching() + self.PanelTip.gameObject:SetActive(XDataCenter.RoomManager.Matching) +end + +function XUiFubenChallengeMap:LoadContent() + if self.ChallengeCfg.Type == XDataCenter.FubenManager.ChapterType.YSHTX then + self:OpenChildUi("UiFubenChallengeYSHTX", self, self.ChallengeCfg) + self.ContentViewInst = self:FindChildUiObj("UiFubenChallengeYSHTX") + elseif self.ChallengeCfg.Type == XDataCenter.FubenManager.ChapterType.EMEX then + self:OpenChildUi("UiFubenChallengeEMEX", self, self.ChallengeCfg) + self.ContentViewInst = self:FindChildUiObj("UiFubenChallengeEMEX") + elseif self.ChallengeCfg.Type == XDataCenter.FubenManager.ChapterType.Urgent then + self:OpenChildUi("UiFubenChallengeUrgent", self, self.ChallengeCfg) + self.ContentViewInst = self:FindChildUiObj("UiFubenChallengeUrgent") + end +end + +function XUiFubenChallengeMap:OpenPanelStageDetail(stageCfg, stageInfo) + self.CurStageCfg = stageCfg + self.CurStageData = stageInfo + self.PanelAsset.gameObject:SetActive(false) + self.Stage = stageCfg + self.PanelEvent.gameObject:SetActive(false) + XLuaUiManager.Open("UiFubenStageDetail", stageCfg) +end + +function XUiFubenChallengeMap:OnCloseStageDetail() + self.PanelAsset.gameObject:SetActive(true) + if self.ContentViewInst and self.ContentViewInst.OnCloseStageDetail then + self.ContentViewInst:OnCloseStageDetail() + end + + if self.HasChallengeEvent then + self.PanelEvent.gameObject:SetActive(true) + else + self.PanelEvent.gameObject:SetActive(false) + end +end + +function XUiFubenChallengeMap:InitChallengeEventDesc() + local envenId = 0 + if self.ChallengeCfg.Type == XDataCenter.FubenManager.ChapterType.Urgent then + envenId = self.ChallengeCfg.UrgentInfo.EventId + end + + if envenId > 0 then + local fightEventCfg = CS.XNpcManager.GetFightEventTemplate(envenId) + self.TxtEventDesc.text = fightEventCfg.Description + self.ChallengeEventCfg = fightEventCfg + self.PanelEvent.gameObject:SetActive(true) + self.HasChallengeEvent = true + else + self.PanelEvent.gameObject:SetActive(false) + end +end + +function XUiFubenChallengeMap:EnterFight(stage) + local conditions + if self.ChallengeEventCfg and self.ChallengeEventCfg.ConditionId then + conditions = XTool.CsList2LuaTable(self.ChallengeEventCfg.ConditionId) + end + local data = {ForceConditionIds = conditions} + if XDataCenter.FubenManager.OpenRoomSingle(stage, data) then + if self.ContentViewInst and self.ContentViewInst.OnEnterFight then + self.ContentViewInst:OnEnterFight() + end + XLuaUiManager.Remove("UiFubenStageDetail") + self:OnCloseStageDetail() + end +end + +function XUiFubenChallengeMap:OnGetEvents() + return { XEventId.EVENT_FUBEN_CLOSE_FUBENSTAGEDETAIL, XEventId.EVENT_FUBEN_ENTERFIGHT } +end + +--事件监听 +function XUiFubenChallengeMap:OnNotify(evt, ...) + local args = { ... } + if evt == XEventId.EVENT_FUBEN_CLOSE_FUBENSTAGEDETAIL then + self:OnCloseStageDetail() + elseif evt == XEventId.EVENT_FUBEN_ENTERFIGHT then + self:EnterFight(args[1]) + end +end + +return XUiFubenChallengeMap \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenChallengeMap/XUiGridChallengePlayerState.lua b/Resources/Scripts/XUi/XUiFubenChallengeMap/XUiGridChallengePlayerState.lua new file mode 100644 index 00000000..7ce057e8 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenChallengeMap/XUiGridChallengePlayerState.lua @@ -0,0 +1,77 @@ +XUiGridChallengePlayerState = XClass(nil, "XUiGridChallengePlayerState") + +function XUiGridChallengePlayerState:Ctor(rootUi, ui) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RectTransform = ui:GetComponent("RectTransform") + self:InitAutoScript() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiGridChallengePlayerState:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiGridChallengePlayerState:AutoInitUi() + self.ImgRoleLoading = self.Transform:Find("ImgRoleLoading"):GetComponent("Image") + self.ImgRoleBg = self.Transform:Find("ImgRoleBg"):GetComponent("Image") + self.ImgRole = self.Transform:Find("ImgRole"):GetComponent("Image") + self.PanelTxtName = self.Transform:Find("PanelTxtName") + self.TxtName = self.Transform:Find("PanelTxtName/TxtName"):GetComponent("Text") + self.PanelPlayer = self.Transform:Find("PanelPlayer") + self.TxtLevel = self.Transform:Find("PanelPlayer/TxtLevel"):GetComponent("Text") + self.TxtLevelNum = self.Transform:Find("PanelPlayer/TxtLevelNum"):GetComponent("Text") +end + +function XUiGridChallengePlayerState:GetAutoKey(uiNode,eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiGridChallengePlayerState:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiGridChallengePlayerState:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key],eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiGridChallengePlayerState:AutoAddListener() + self.AutoCreateListeners = {} +end +-- auto + +function XUiGridChallengePlayerState:Refresh(playerData) + self.TxtNameE.text = playerData.Name + if playerData.CharacterData then + self.TxtLevelNum.text = playerData.CharacterData.Level + self.RootUi:SetUiSprite(self.ImgRole, XDataCenter.CharacterManager.GetCharSmallHeadIcon(playerData.CharacterData.Id)) + end +end + +function XUiGridChallengePlayerState:SetPosition(x, y) + self.RectTransform.anchoredPosition = CS.UnityEngine.Vector2(x, y) +end + +function XUiGridChallengePlayerState:SetActive(active) + self.GameObject:SetActive(active) +end diff --git a/Resources/Scripts/XUi/XUiFubenChallengeMap/XUiPanelJieduan.lua b/Resources/Scripts/XUi/XUiFubenChallengeMap/XUiPanelJieduan.lua new file mode 100644 index 00000000..953b7abb --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenChallengeMap/XUiPanelJieduan.lua @@ -0,0 +1,94 @@ +local XUiPanelJieduan = XClass(nil, "XUiPanelJieduan") + +XUiPanelJieduan.StatusType = { + OFF = 1, + ON = 2, + REWARD = 3 +} + +function XUiPanelJieduan:Ctor(ui, isLast, sectionId, status) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.SectionId = sectionId + self.IsLast = isLast + self:InitAutoScript() + self:SetStatus(status) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelJieduan:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiPanelJieduan:AutoInitUi() + self.ImgJieduanOn = self.Transform:Find("ImgJieduanOn"):GetComponent("Image") + self.ImgJieduanOff = self.Transform:Find("ImgJieduanOff"):GetComponent("Image") + self.BtnJieduanGift = self.Transform:Find("BtnJieduanGift"):GetComponent("Button") +end + +function XUiPanelJieduan:GetAutoKey(uiNode,eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiPanelJieduan:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiPanelJieduan:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key],eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiPanelJieduan:AutoAddListener() + self.AutoCreateListeners = {} + XUiHelper.RegisterClickEvent(self, self.BtnJieduanGift, self.OnBtnJieduanGiftClick) +end +-- auto + +function XUiPanelJieduan:OnBtnJieduanGiftClick() + if self.Status == XUiPanelJieduan.StatusType.REWARD then + XDataCenter.FubenDailyManager.ReceiveDailyReward(function(reward) + self.Status = XUiPanelJieduan.StatusType.ON + self:RefreshUI() + XUiManager.OpenUiObtain(reward, CS.XTextManager.GetText("Award")) + end, self.SectionId) + elseif self.Status == XUiPanelJieduan.StatusType.OFF then + local cfg = XDataCenter.FubenDailyManager.GetDailySection(self.SectionId) + local data = XRewardManager.GetRewardList(cfg.RewardId) + XUiManager.OpenUiObtain(data) + else + XUiManager.TipMsg(CS.XTextManager.GetText("ChallengeRewardIsGetted")) + end +end + +function XUiPanelJieduan:RefreshUI() + self.BtnJieduanGift.gameObject:SetActive(self.IsLast) + self.BtnJieduanGift.interactable = self.Status == XUiPanelJieduan.StatusType.REWARD or self.Status == XUiPanelJieduan.StatusType.OFF + self.ImgJieduanOn.gameObject:SetActive(not self.IsLast and self.Status == XUiPanelJieduan.StatusType.ON) + self.ImgJieduanOff.gameObject:SetActive(not self.IsLast and self.Status == XUiPanelJieduan.StatusType.OFF) +end + +function XUiPanelJieduan:SetStatus(status) + self.Status = status + self:RefreshUI() +end + +return XUiPanelJieduan \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenChallengeMapEmex/XUiFubenChallengeMapEmex.lua b/Resources/Scripts/XUi/XUiFubenChallengeMapEmex/XUiFubenChallengeMapEmex.lua new file mode 100644 index 00000000..03b4ce00 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenChallengeMapEmex/XUiFubenChallengeMapEmex.lua @@ -0,0 +1,131 @@ +local XUiFubenChallengeMapEmex = XLuaUiManager.Register(XLuaUi, "UiFubenChallengeMapEmex") + +function XUiFubenChallengeMapEmex:RefreshReward() + self.Panelreceived.gameObject:SetActive(false) + self.PanelEffect.gameObject:SetActive(false) + local curFightNum = 0 + local isGetChallengeReward = false + local sectionData = XDataCenter.FubenDailyManager.GetDailySectionData(self.SectionCfg.Id) + if sectionData then + curFightNum = sectionData.PassTimesToday + isGetChallengeReward = sectionData.ReceiveReward + end + + self.curFightNum = curFightNum + self.BtnReward.interactable = true + self.PanelBottom.gameObject:SetActive(true) + self:RefreshText(isGetChallengeReward) +end + +function XUiFubenChallengeMapEmex:RefreshText(isGetChallengeReward) + if not self.SectionCfg then + return + end + + local rewardNeedFinishCount = self.SectionCfg.RewardNeedFinishCount or 0 + if self.curFightNum > rewardNeedFinishCount then + self.curFightNum = rewardNeedFinishCount + end + + self.TxtProgress.text = (rewardNeedFinishCount - self.curFightNum) .. "/" .. rewardNeedFinishCount + self.TxtBt.text = self.SectionCfg.Name or "" + self.ImgSlide.fillAmount = self.curFightNum / rewardNeedFinishCount + self.isGetChallengeReward = isGetChallengeReward + if isGetChallengeReward then + self.Panelreceived.gameObject:SetActive(true) + self.PanelEffect.gameObject:SetActive(false) + else + if self.curFightNum >= rewardNeedFinishCount then + self.PanelEffect.gameObject:SetActive(true) + end + end + +end + +function XUiFubenChallengeMapEmex:OnBtnRewardClick() + if self.isGetChallengeReward then + XUiManager.TipText("ChallengeRewardIsGetted") + else + if self.curFightNum >= self.SectionCfg.RewardNeedFinishCount then + XDataCenter.FubenDailyManager.ReceiveDailyReward(function(reward) + self.isGetChallengeReward = true + XUiManager.OpenUiObtain(reward, CS.XTextManager.GetText("Award")) + self:RefreshText(self.isGetChallengeReward) + end, self.SectionCfg.Id) + else + local data = XRewardManager.GetRewardList(self.SectionCfg.RewardId) + XUiManager.OpenUiTipReward(data) + end + end +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiFubenChallengeMapEmex:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiFubenChallengeMapEmex:AutoInitUi() + self.BtnActDesc = self.Transform:Find("SafeAreaContentPane/LayerWrap/BtnActDesc"):GetComponent("Button") + self.TxtPipei = self.Transform:Find("SafeAreaContentPane/LayerWrap/BtnActDesc/TxtPipei"):GetComponent("Text") + self.PanelEvent = self.Transform:Find("SafeAreaContentPane/LayerWrap/PanelEvent") + self.TxtEventDesc = self.Transform:Find("SafeAreaContentPane/LayerWrap/PanelEvent/head/TxtEventDesc"):GetComponent("Text") + self.PanelTip = self.Transform:Find("SafeAreaContentPane/LayerWrap/PanelTip") + self.BtnCancelMatch = self.Transform:Find("SafeAreaContentPane/LayerWrap/PanelTip/BtnCancelMatch"):GetComponent("Button") + self.TxtPipeiA = self.Transform:Find("SafeAreaContentPane/LayerWrap/PanelTip/TxtPipei"):GetComponent("Text") + self.PanelBottom = self.Transform:Find("SafeAreaContentPane/LayerWrap/PanelBottom") + self.TxtProgress = self.Transform:Find("SafeAreaContentPane/LayerWrap/PanelBottom/GameObject/TxtProgress"):GetComponent("Text") + self.ImgSlide = self.Transform:Find("SafeAreaContentPane/LayerWrap/PanelBottom/GameObject/ImgSlide"):GetComponent("Image") + self.BtnReward = self.Transform:Find("SafeAreaContentPane/LayerWrap/PanelBottom/GameObject/BtnReward"):GetComponent("Button") + self.Panelreceived = self.Transform:Find("SafeAreaContentPane/LayerWrap/PanelBottom/GameObject/Panelreceived") + self.PanelEffect = self.Transform:Find("SafeAreaContentPane/LayerWrap/PanelBottom/GameObject/PanelEffect") + self.PanelAsset = self.Transform:Find("SafeAreaContentPane/LayerWrap/PanelAsset") + self.BtnBack = self.Transform:Find("SafeAreaContentPane/LayerWrap/Top/BtnBack"):GetComponent("Button") + self.BtnMainUi = self.Transform:Find("SafeAreaContentPane/LayerWrap/Top/BtnMainUi"):GetComponent("Button") + self.PanelTitle = self.Transform:Find("SafeAreaContentPane/LayerWrap/PanelTitle") + self.TxtShuaxin = self.Transform:Find("SafeAreaContentPane/LayerWrap/PanelTitle/TxtShuaxin"):GetComponent("Text") + self.TxtCurTime = self.Transform:Find("SafeAreaContentPane/LayerWrap/PanelTitle/TxtCurTime"):GetComponent("Text") + self.TxtBt = self.Transform:Find("SafeAreaContentPane/LayerWrap/PanelTitle/TxtBt"):GetComponent("Text") + self.ImgBg = self.Transform:Find("FullScreenBackground/ImgBg"):GetComponent("Image") + self.PanelContent = self.Transform:Find("FullScreenBackground/PanelContent") +end + +function XUiFubenChallengeMapEmex:GetAutoKey(uiNode, eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiFubenChallengeMapEmex:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiFubenChallengeMapEmex:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiFubenChallengeMapEmex:AutoAddListener() + self.AutoCreateListeners = {} + self:RegisterClickEvent(self.BtnActDesc, self.OnBtnActDescClick) + self:RegisterClickEvent(self.BtnCancelMatch, self.OnBtnCancelMatchClick) + self:RegisterClickEvent(self.BtnReward, self.OnBtnRewardClick) + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) +end +-- auto \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenChallengeUrgent/XUiFubenChallengeUrgent.lua b/Resources/Scripts/XUi/XUiFubenChallengeUrgent/XUiFubenChallengeUrgent.lua new file mode 100644 index 00000000..da48e03f --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenChallengeUrgent/XUiFubenChallengeUrgent.lua @@ -0,0 +1,126 @@ +local XUiFubenChallengeUrgent = XLuaUiManager.Register(XLuaUi, "UiFubenChallengeUrgent") + +function XUiFubenChallengeUrgent:OnAwake() + self:InitAutoScript() +end + +function XUiFubenChallengeUrgent:OnStart(parent, config) + self.Parent = parent + self:Init(config) + --self.timer = XScheduleManager.ScheduleForever(function(...) + --self:Refresh() + --end, 0) + self.PanelHover.gameObject:SetActive(false) + self.orgPosition = self.PanelMapContainer.transform.localPosition + self.targetPosition = self.PanelTargetFlag.transform.position +end + +function XUiFubenChallengeUrgent:OnDestroy() + if self.timer then + XScheduleManager.UnSchedule(self.timer) + self.timer = nil + end + + if self.TimerTween then + XScheduleManager.UnSchedule(self.TimerTween) + self.TimerTween = nil + end +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiFubenChallengeUrgent:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiFubenChallengeUrgent:AutoInitUi() + self.PanelMapContainer = self.Transform:Find("FullScreenBackground/PanelMapContainer") + self.SViewStage = self.Transform:Find("FullScreenBackground/PanelMapContainer/SViewStage"):GetComponent("ScrollRect") + self.PanelContent = self.Transform:Find("FullScreenBackground/PanelMapContainer/SViewStage/Viewport/PanelContent") + self.PanelStage = self.Transform:Find("FullScreenBackground/PanelMapContainer/SViewStage/Viewport/PanelContent/PanelStage") + self.PanelStageA = self.Transform:Find("FullScreenBackground/PanelMapContainer/SViewStage/Viewport/PanelContent/PanelStage/PanelStageA") + self.ImgOpen = self.Transform:Find("FullScreenBackground/PanelMapContainer/SViewStage/Viewport/PanelContent/PanelStage/PanelStageA/ImgOpen"):GetComponent("Image") + self.TxtName = self.Transform:Find("FullScreenBackground/PanelMapContainer/SViewStage/Viewport/PanelContent/PanelStage/PanelStageA/StageOpen/TxtName"):GetComponent("Text") + self.TxtTime = self.Transform:Find("FullScreenBackground/PanelMapContainer/SViewStage/Viewport/PanelContent/PanelStage/PanelStageA/StageOpen/TxtTime"):GetComponent("Text") + self.BtnEnter = self.Transform:Find("FullScreenBackground/PanelMapContainer/SViewStage/Viewport/PanelContent/PanelStage/PanelStageA/BtnEnter"):GetComponent("Button") + self.PanelHover = self.Transform:Find("FullScreenBackground/PanelHover") + self.PanelTargetFlag = self.Transform:Find("FullScreenBackground/PanelTargetFlag") +end + +function XUiFubenChallengeUrgent:AutoAddListener() + self:RegisterClickEvent(self.BtnEnter, self.OnBtnEnterClick) +end +-- auto + +function XUiFubenChallengeUrgent:OnBtnEnterClick() + self:FocusStage() + self.Parent:OpenPanelStageDetail(self.StageCfg, self.StageInfo) +end + +function XUiFubenChallengeUrgent:Init(config) + local urgentCfg = config.UrgentCfg + self.StageCfg = XDataCenter.FubenManager.GetStageCfg(config.UrgentInfo.StageId) + self.StageInfo = XDataCenter.FubenManager.GetStageInfo(config.UrgentInfo.StageId) + self:SetUiSprite(self.ImgOpen, urgentCfg.StageIcon) + self.TxtName.text = self.StageCfg.Name + XCountDown.BindTimer(self, tostring(urgentCfg.Id), function(v) + if v > 1 then + self.TxtTime.text = XUiHelper.GetTime(v, XUiHelper.TimeFormatType.CHALLENGE) + else + self.TxtTime.text = XUiHelper.GetTime(0) + end + end) +end + +function XUiFubenChallengeUrgent:OnCloseStageDetail() + self:UnFocus() +end + +function XUiFubenChallengeUrgent:FocusStage() + local worldPos = self.PanelStageA.transform.position + local localPos = self.PanelMapContainer.transform:InverseTransformPoint(worldPos) + local tPos = self.PanelMapContainer.transform:InverseTransformPoint(self.targetPosition) + local deltaPos = tPos - localPos + local lineAni = CS.UnityEngine.AnimationCurve.Linear(0, 0, 1, 1) + local startPos = self.PanelMapContainer.localPosition + self.PanelHover.gameObject:SetActive(true) + XUiHelper.Tween(0.3, function(t) + if XTool.UObjIsNil(self.PanelMapContainer) then + return + end + + self.PanelMapContainer.localPosition = startPos + deltaPos * lineAni:Evaluate(t) + end, function() + if XTool.UObjIsNil(self.PanelMapContainer) then + return + end + + self.PanelMapContainer.localPosition = startPos + deltaPos + end) +end + +function XUiFubenChallengeUrgent:UnFocus() + local startPos = self.PanelMapContainer.localPosition + local deltaPos = self.orgPosition - startPos + local lineAni = CS.UnityEngine.AnimationCurve.Linear(0, 0, 1, 1) + self.TimerTween = XUiHelper.Tween(0.3, function(t) + if XTool.UObjIsNil(self.PanelMapContainer) then + return + end + + self.PanelMapContainer.localPosition = startPos + deltaPos * lineAni:Evaluate(t) + end, function() + if XTool.UObjIsNil(self.PanelMapContainer) then + return + end + + self.PanelMapContainer.localPosition = self.orgPosition + self.PanelHover.gameObject:SetActive(false) + end) +end + +--function XUiFubenChallengeUrgent:Refresh() +----self.SViewBg.horizontalNormalizedPosition = self.SViewStage.horizontalNormalizedPosition +----self.SViewBg.verticalNormalizedPosition = self.SViewStage.verticalNormalizedPosition +--end diff --git a/Resources/Scripts/XUi/XUiFubenChallengeYSHTX/XUiFubenChallengeYSHTX.lua b/Resources/Scripts/XUi/XUiFubenChallengeYSHTX/XUiFubenChallengeYSHTX.lua new file mode 100644 index 00000000..a424e0f6 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenChallengeYSHTX/XUiFubenChallengeYSHTX.lua @@ -0,0 +1,70 @@ +local XUiFubenChallengeYSHTX = XLuaUiManager.Register(XLuaUi, "UiFubenChallengeYSHTX") +-- local XUiPanelYSHTXStageTemplate = require("XUi/XUiFubenChallengeYSHTX/XUiPanelYSHTXStageTemplate") + +function XUiFubenChallengeYSHTX:OnAwake() + self:InitAutoScript() +end + +function XUiFubenChallengeYSHTX:OnStart(parent, config) + self.Parent = parent + self:Init(config) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiFubenChallengeYSHTX:InitAutoScript() + self:AutoInitUi() +end + +function XUiFubenChallengeYSHTX:AutoInitUi() + self.PanelPageView = self.Transform:Find("SafeAreaContentPane/PanelPageView") + self.PanelContent = self.Transform:Find("SafeAreaContentPane/PanelPageView/Viewport/PanelContent") + self.PanelYSHTXStageTemplate = self.Transform:Find("SafeAreaContentPane/PanelPageView/Viewport/PanelContent/PanelYSHTXStageTemplate") + self.ImgBg = self.Transform:Find("FullScreenBackground/ImgBg"):GetComponent("Image") + self.ImgHero = self.Transform:Find("SafeAreaContentPane/ImgHero"):GetComponent("Image") +end + +-- auto +function XUiFubenChallengeYSHTX:Init(config) + self.ChallengeCfg = config + if config.Bg and config.Bg ~= "" then + self:SetUiSprite(self.ImgBg, config.Bg) + end + self.PanelYSHTXStageTemplate.gameObject:SetActive(false) + + -- 自己的列表 + --local rect = self.PanelYSHTXStageTemplate:GetComponent("RectTransform").rect + self.SectionCfg = XDataCenter.FubenDailyManager.GetDailySectionByChapterId(config.Id, self.Parent.CurDiff) + -- local lastIndex = 0 + for index, stageId in ipairs(self.SectionCfg.StageId) do + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + if stageCfg then + local obj = CS.UnityEngine.Object.Instantiate(self.PanelYSHTXStageTemplate) + obj.gameObject:SetActive(true) + obj.gameObject.name = index + -- local item = XUiPanelYSHTXStageTemplate.New(self, obj, stageCfg, function(cfg, info) + -- self:OnEnterStage(cfg, info) + -- end) + --if item:IsOpen() then + --lastIndex = index - 1 + --end + obj.transform:SetParent(self.PanelContent, false) + end + end +end + +function XUiFubenChallengeYSHTX:OnEnterStage(stageCfg, stageInfo) + if stageInfo and not stageInfo.Unlock then + local msg = XDataCenter.FubenManager.GetFubenOpenTips(stageCfg.StageId) + XUiManager.TipMsg(msg) + return + end + -- self.PanelPageView.gameObject:SetActive(false) + self.Parent:OpenPanelStageDetail(stageCfg, stageInfo) +end + +function XUiFubenChallengeYSHTX:OnCloseStageDetail() + self.PanelPageView.gameObject:SetActive(true) +end + +return XUiFubenChallengeYSHTX \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenChallengeYSHTX/XUiPanelYSHTXStageTemplate.lua b/Resources/Scripts/XUi/XUiFubenChallengeYSHTX/XUiPanelYSHTXStageTemplate.lua new file mode 100644 index 00000000..b9c0544e --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenChallengeYSHTX/XUiPanelYSHTXStageTemplate.lua @@ -0,0 +1,90 @@ +local XUiPanelYSHTXStageTemplate = XClass(nil, "XUiPanelYSHTXStageTemplate") + +function XUiPanelYSHTXStageTemplate:Ctor(rootUi, ui, stageCfg, cb) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Callback = cb + self.StageCfg = stageCfg + self:InitAutoScript() + self:Refresh() + XEventManager.BindEvent(self, XEventId.EVENT_FUBEN_REFRESH_STAGE_DATA, self.Refresh, self) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelYSHTXStageTemplate:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiPanelYSHTXStageTemplate:AutoInitUi() + self.PanelRight = self.Transform:Find("PanelRight") + self.RImgIcon = self.Transform:Find("PanelRight/RImgIcon"):GetComponent("RawImage") + self.TxtName = self.Transform:Find("PanelRight/TxtName"):GetComponent("Text") + self.TxtDesc = self.Transform:Find("PanelRight/TxtDesc"):GetComponent("Text") + self.ImgLock = self.Transform:Find("ImgLock"):GetComponent("Image") + self.TxtLockDesc = self.Transform:Find("ImgLock/TxtLockDesc"):GetComponent("Text") + self.TxtLockName = self.Transform:Find("ImgLock/TxtLockName"):GetComponent("Text") + self.BtnEnter = self.Transform:Find("BtnEnter"):GetComponent("Button") +end + +function XUiPanelYSHTXStageTemplate:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelYSHTXStageTemplate:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelYSHTXStageTemplate:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelYSHTXStageTemplate:AutoAddListener() + self:RegisterClickEvent(self.BtnEnter, self.OnBtnEnterClick) +end +-- auto +function XUiPanelYSHTXStageTemplate:OnBtnEnterClick() + if self.Callback then + self.Callback(self.StageCfg, self.StageInfo) + end +end + +function XUiPanelYSHTXStageTemplate:IsOpen() + return self.StageInfo.Unlock +end + +function XUiPanelYSHTXStageTemplate:Refresh() + if XTool.UObjIsNil(self.GameObject) then + return + end + + self.StageInfo = XDataCenter.FubenManager.GetStageInfo(self.StageCfg.StageId) + if not self.StageInfo then + return + end + + if self.StageInfo.Unlock then + self.PanelRight.gameObject:SetActive(true) + self.ImgLock.gameObject:SetActive(false) + self.TxtName.text = self.StageCfg.Name + self.TxtDesc.text = self.StageCfg.RecommandLevel + else + self.PanelRight.gameObject:SetActive(false) + self.ImgLock.gameObject:SetActive(true) + self.TxtLockName.text = self.StageCfg.Name + self.TxtLockDesc.text = self.StageCfg.RecommandLevel + end + + if self.StageCfg.Icon and self.StageCfg.Icon ~= "" then + self.RImgIcon:SetRawImage(self.StageCfg.Icon) + end +end + +return XUiPanelYSHTXStageTemplate \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenCoinSkill/XUiFubenCoinSkill.lua b/Resources/Scripts/XUi/XUiFubenCoinSkill/XUiFubenCoinSkill.lua new file mode 100644 index 00000000..4c534a65 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenCoinSkill/XUiFubenCoinSkill.lua @@ -0,0 +1,214 @@ + +local XUiFubenCoinSkill = XLuaUiManager.Register(XLuaUi, "UiFubenCoinSkill") + +local LOCAL_COUNTDOWN_NAME = "UiFubenCoinSkillCountDown" + + +function XUiFubenCoinSkill:OnAwake() + self:InitAutoScript() +end + +function XUiFubenCoinSkill:OnStart() + self.DetailParams = {} + self.FubenPanelTabList = {} + self.CsUiList = {} + self.BtnsGameObject = self.PanelBtns.gameObject + self.Animation = self.Transform:GetComponent("Animation") + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self:InitTextByCfg() + self:StartCountDown() + self:InitXUiPanelFubenTab() + self:CheckPlayerLevelUp() +end + +function XUiFubenCoinSkill:OnEnable() + self:CheckPlayerLevelUp() + self:UpdateData() +end + +function XUiFubenCoinSkill:OnDestroy() + XDataCenter.FubenResourceManager.UpdateRewardFromTemp() + for _, v in pairs(self.CsUiList) do + v:Close() + end +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiFubenCoinSkill:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiFubenCoinSkill:AutoInitUi() + self.BtnBack = self.Transform:Find("SafeAreaContentPane/Top/BtnBack"):GetComponent("Button") + self.BtnMainUi = self.Transform:Find("SafeAreaContentPane/Top/BtnMainUi"):GetComponent("Button") + self.PanelAsset = self.Transform:Find("SafeAreaContentPane/PanelAsset") + self.PanelLevelUpTip = self.Transform:Find("SafeAreaContentPane/PanelLevelUpTip") + self.BtnClosePanelLevelUpTip = self.Transform:Find("SafeAreaContentPane/PanelLevelUpTip/BtnClosePanelLevelUpTip"):GetComponent("Button") + self.TxtChallengeLevel = self.Transform:Find("SafeAreaContentPane/PanelLevelUpTip/TxtChallengeLevel"):GetComponent("Text") + self.Panel = self.Transform:Find("SafeAreaContentPane/Panel") + self.PanelResetTime = self.Transform:Find("SafeAreaContentPane/Panel/PanelResetTime") + self.TxtResetTime = self.Transform:Find("SafeAreaContentPane/Panel/PanelResetTime/TxtResetTime"):GetComponent("Text") + self.PanelTitle = self.Transform:Find("SafeAreaContentPane/Panel/PanelTitle") + self.TxtName = self.Transform:Find("SafeAreaContentPane/Panel/PanelTitle/TxtName"):GetComponent("Text") + self.TxtDetail = self.Transform:Find("SafeAreaContentPane/Panel/PanelTitle/TxtDetail"):GetComponent("Text") + self.PanelBtns = self.Transform:Find("SafeAreaContentPane/Panel/PanelBtns") + self.PanelTab1 = self.Transform:Find("SafeAreaContentPane/Panel/PanelBtns/PanelTab1") + self.PanelTab2 = self.Transform:Find("SafeAreaContentPane/Panel/PanelBtns/PanelTab2") + self.PanelFubenTab = self.Transform:Find("SafeAreaContentPane/Panel/TargetFlag/PanelFubenTab") + self.PanelChallengeLevel = self.Transform:Find("SafeAreaContentPane/Panel/PanelChallengeLevel") + self.TxtTitle = self.Transform:Find("SafeAreaContentPane/Panel/PanelChallengeLevel/TxtTitle"):GetComponent("Text") + self.TxtLevelNow = self.Transform:Find("SafeAreaContentPane/Panel/PanelChallengeLevel/TxtLevelNow"):GetComponent("Text") + self.TxtLevelBefore = self.Transform:Find("SafeAreaContentPane/Panel/PanelChallengeLevel/TxtLevelBefore"):GetComponent("Text") + self.BtnActDesc = self.Transform:Find("SafeAreaContentPane/Panel/BtnActDesc"):GetComponent("Button") +end + +function XUiFubenCoinSkill:GetAutoKey(uiNode,eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiFubenCoinSkill:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiFubenCoinSkill:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiFubenCoinSkill:AutoAddListener() + self.AutoCreateListeners = {} + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:RegisterClickEvent(self.BtnActDesc, self.OnBtnActDescClick) +end +-- auto +--初始化ui文本 +function XUiFubenCoinSkill:InitTextByCfg() + local chapterTemplate = XDataCenter.FubenResourceManager.GetResourceChapters() + for _, v in pairs(chapterTemplate) do + self.TxtName.text = v.Name + self.TxtDetail.text = v.SimpleDesc + end +end + +function XUiFubenCoinSkill:StartCountDown() + local remainingTime = XDataCenter.FubenResourceManager.GetRemainingTime() + XCountDown.CreateTimer(LOCAL_COUNTDOWN_NAME, remainingTime) + XCountDown.BindTimer(self, LOCAL_COUNTDOWN_NAME, function(v) + if self.IsHide then + return + end + if v > 0 then + self.PanelResetTime.gameObject:SetActive(true) + self.TxtResetTime.text = XUiHelper.GetTime(v, XUiHelper.TimeFormatType.CHALLENGE) + else + self.TxtResetTime.text = "" + self.PanelResetTime.gameObject:SetActive(false) + end + end) +end + +--初始化副本按钮 +function XUiFubenCoinSkill:InitXUiPanelFubenTab() + local sectionDatas = XDataCenter.FubenResourceManager.GetSectionDatas() + local i = 1 + for typeId, data in pairs(sectionDatas) do + local btn = self.Transform:Find("SafeAreaContentPane/Panel/PanelBtns/PanelTab" .. i) + if btn then + local ui = XUiPanelFubenTab.New(self, btn) + ui:SetData(data) + self.FubenPanelTabList[typeId] = ui + end + i = i + 1 + end + self.FocusPanelTab = XUiPanelFubenTab.New(self, self.PanelFubenTab) +end + +--更新副本按钮表现 +function XUiFubenCoinSkill:UpdateData() + local sectionDatas = XDataCenter.FubenResourceManager.GetSectionDatas() + for typeId, data in pairs(sectionDatas) do + self.FubenPanelTabList[typeId]:UpdateData(data) + end +end + +--挑战等级提升提示 +function XUiFubenCoinSkill:CheckPlayerLevelUp() + local nowLevel, lastLevel = XDataCenter.FubenResourceManager.GetPlayerLevelInfo() + self.TxtLevelNow.text = nowLevel + if not lastLevel then + return + end + -- XUiHelper.PlayAnimation(self, "CoinSkillLevelUp", function() + -- self.TxtChallengeLevel.text = nowLevel + -- self.PanelLevelUpTip.gameObject:SetActive(true) + -- end, nil) +end + +function XUiFubenCoinSkill:OnBtnBackClick() + self:Close() +end + +function XUiFubenCoinSkill:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiFubenCoinSkill:OnBtnActDescClick() + local resourceChapterCfg = XDataCenter.FubenResourceManager.GetResourceChapters() + for _, v in pairs(resourceChapterCfg) do + XUiManager.UiFubenDialogTip("", v.DetailDesc or "") + return + end +end + +--副本按钮入口 +function XUiFubenCoinSkill:OnFubenSelected(typeId) + if not self.BeginAnim then + return + end + self:SetActive(false) + + local fightCb = function(stage) + XDataCenter.FubenManager.OpenRoomSingle(stage) + XDataCenter.FubenResourceManager.UpdateRewardFromTemp() + self:SetActive(true) + end + local closeCb = function() + self:SetActive(true) + end + + self.DetailParams.typeId = typeId + self.DetailParams.fightCb = fightCb + self.DetailParams.closeCb = closeCb + + self:OpenOneChildUi("UiFubenResourceDetail", self.DetailParams) +end + +function XUiFubenCoinSkill:SetActive(flag) + self.PanelResetTime.gameObject:SetActive(flag) + self.PanelTitle.gameObject:SetActive(flag) + self.PanelBtns.gameObject:SetActive(flag) + self.PanelAsset.gameObject:SetActive(flag) + self.BtnActDesc.gameObject:SetActive(flag) + self.IsHide = not flag +end + +return XUiFubenCoinSkill \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenCoinSkill/XUiPanelFubenTab.lua b/Resources/Scripts/XUi/XUiFubenCoinSkill/XUiPanelFubenTab.lua new file mode 100644 index 00000000..b7fb6c50 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenCoinSkill/XUiPanelFubenTab.lua @@ -0,0 +1,86 @@ +XUiPanelFubenTab = XClass(nil, "XUiPanelFubenTab") + +function XUiPanelFubenTab:Ctor(rootUi, ui) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + self:InitAutoScript() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelFubenTab:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiPanelFubenTab:AutoInitUi() + self.RImgFuben = self.Transform:Find("RImgFuben"):GetComponent("RawImage") + self.PanelFubenTitle = self.Transform:Find("PanelFubenTitle") + self.TxtFubenName = self.Transform:Find("PanelFubenTitle/TxtFubenName"):GetComponent("Text") + self.PanelChallenge = self.Transform:Find("PanelChallenge") + self.TxtChallenge = self.Transform:Find("PanelChallenge/TxtChallenge"):GetComponent("Text") + self.TxtChallengeCount = self.Transform:Find("PanelChallenge/TxtChallengeCount"):GetComponent("Text") + self.TxtReward = self.Transform:Find("TxtReward"):GetComponent("Text") + self.BtnFuben = self.Transform:Find("BtnFuben"):GetComponent("Button") + self.ImgRewardUp = self.Transform:Find("ImgRewardUp"):GetComponent("Image") +end + +function XUiPanelFubenTab:GetAutoKey(uiNode,eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiPanelFubenTab:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiPanelFubenTab:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key],eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiPanelFubenTab:AutoAddListener() + self.AutoCreateListeners = {} + XUiHelper.RegisterClickEvent(self, self.BtnFuben, self.OnBtnFubenClick) +end +-- auto + +function XUiPanelFubenTab:OnBtnFubenClick() + self.RootUi:OnFubenSelected(self.TypeId) +end + +--初始化数据 +function XUiPanelFubenTab:SetData(sectionData) + self.TypeId = sectionData.Type + local stageCfg = XDataCenter.FubenManager.GetStageCfg(sectionData.StageId) + self.RImgFuben:SetRawImage(stageCfg.Icon) + self.TxtFubenName.text = stageCfg.Name .. (sectionData.Difficulty or "") + self:UpdateData(sectionData) +end + +--更新数据 +function XUiPanelFubenTab:UpdateData(sectionData) + self.TxtChallengeCount.text = CS.XTextManager.GetText("UiFubenCoinSkillChallenge", sectionData.ColorChallenge, sectionData.LeftCount) + self.TxtReward.text = CS.XTextManager.GetText("UiFubenCoinSkillReward", sectionData.ColorReward, XDataCenter.FubenResourceManager.GetTopRewardByTypeId(self.TypeId)) + + local value = XDataCenter.FubenResourceManager.CheckRewradChange(self.TypeId) + self.ImgRewardUp.gameObject:SetActive(value) +end + +return XUiPanelFubenTab diff --git a/Resources/Scripts/XUi/XUiFubenCoupleCombat/ChildItem/XUiStageItem.lua b/Resources/Scripts/XUi/XUiFubenCoupleCombat/ChildItem/XUiStageItem.lua new file mode 100644 index 00000000..18826452 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenCoupleCombat/ChildItem/XUiStageItem.lua @@ -0,0 +1,97 @@ +local XUiStageItem = XClass(nil, "XUiStageItem") + +local XUiPanelStars = require("XUi/XUiFubenMainLineChapter/XUiPanelStars") + +function XUiStageItem:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) +end + +function XUiStageItem:SetNormalStage(stageId, stagePrefix, stageName) + self.PanelStageNormal.gameObject:SetActiveEx(not self.IsLock) + + self.TxtStageTitle.text = string.format("%02d", self.Index) + -- SetLockStage + self.PanelStageLock.gameObject:SetActiveEx(self.IsLock) + self:SetPassStage() + self:SetNodeSelect(false) +end + +function XUiStageItem:SetPassStage() + --XDataCenter.FubenManager.CheckStageIsPass(self.StageId) + local useList = XDataCenter.FubenCoupleCombatManager.GetStageUsedRobot(self.StageId) + if useList and next(useList) then + self.PanelHead.gameObject:SetActiveEx(true) + self.PanelStagePass.gameObject:SetActiveEx(true) + for i, v in ipairs(useList) do + self["RImgHead"..i]:SetRawImage(XDataCenter.CharacterManager.GetDefaultCharSmallHeadIcon(XRobotManager.GetCharacterId(v))) + end + else + self.PanelHead.gameObject:SetActiveEx(false) + self.PanelStagePass.gameObject:SetActiveEx(false) + end +end + +function XUiStageItem:UpdateNode(stageId, index, stageType) + self.StageId = stageId + self.Index = index + --self.StageType = stageType + local stageInfo = XDataCenter.FubenManager.GetStageInfo(self.StageId) + local actCfg = XDataCenter.FubenCoupleCombatManager.GetCurrentActTemplate() + + local isOpen = stageInfo.IsOpen + self.GameObject:SetActiveEx(isOpen) + local gridGo = self.Transform:LoadPrefab(actCfg.GridPrefab) + local uiObj = gridGo.transform:GetComponent("UiObject") + for i = 0, uiObj.NameList.Count - 1 do + self[uiObj.NameList[i]] = uiObj.ObjList[i] + end + self.RImgNormalBg:SetRawImage(actCfg.StageGridBg[stageType]) + self.BtnStage.CallBack = function() self:OnBtnStageClick() end + + self.IsLock = not stageInfo.Unlock + --local stagePrefix = XDataCenter.FubenManager.GetStageName(stageId) + --local stageName = XDataCenter.FubenManager.GetStageDes(stageId) + self:SetNormalStage(self.StageId) + --self.IsPass = stageInfo.Passed + --self.PanelStagePass.gameObject:SetActiveEx(self.IsPass) + + --self.PanelStarMap = self.PanelStarMap or XUiPanelStars.New(self.PanelStars) + --self.PanelStars.gameObject:SetActiveEx(stageType == XFubenSimulatedCombatConfig.StageType.Hard) + --local starsMap = XDataCenter.FubenSimulatedCombatManager.GetPlainStarMap(self.StageId) + --self.PanelStarMap:OnEnable(starsMap) +end + +function XUiStageItem:OnBtnStageClick() + if not self.StageId then return end + if not self.IsLock then + self.RootUi:UpdateNodesSelect(self.StageId) + -- 打开详细界面 + self.RootUi:OpenStageDetails(self.StageId) + self.RootUi:PlayScrollViewMove(self.Transform) + else + -- 是否达到时间 + local isInOpenTime, desc = XDataCenter.FubenCoupleCombatManager.CheckStageOpen(self.StageId, true) + if isInOpenTime then + desc = CS.XTextManager.GetText("FubenPreStageNotPass") + end + XUiManager.TipMsg(desc) + end +end + +function XUiStageItem:SetNodeSelect(isSelect) + if not self.IsLock then + self.ImageSelected.gameObject:SetActiveEx(isSelect) + end +end + +function XUiStageItem:ResetItemPosition(pos) + if self.ImgHideLine then + local rect = self.ImgHideLine:GetComponent("RectTransform").rect + self.Transform.localPosition = CS.UnityEngine.Vector3(pos.x, pos.y - rect.height, pos.z) + end +end + +return XUiStageItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenCoupleCombat/ChildView/XUiCoupleCombatChapter.lua b/Resources/Scripts/XUi/XUiFubenCoupleCombat/ChildView/XUiCoupleCombatChapter.lua new file mode 100644 index 00000000..a1809d65 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenCoupleCombat/ChildView/XUiCoupleCombatChapter.lua @@ -0,0 +1,263 @@ +local XUiCoupleCombatChapter = XClass(nil, "XUiCoupleCombatChapter") +local XUiStageItem = require("XUi/XUiFubenCoupleCombat/ChildItem/XUiStageItem") + +local FUBEN_FIGHT_DETAIL = "UiFubenCoupleCombatDetail" +local XUguiDragProxy = CS.XUguiDragProxy + +function XUiCoupleCombatChapter:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + XEventManager.AddEventListener(XEventId.EVENT_FUBEN_CLOSE_FUBENSTAGEDETAIL, self.CloseStageDetails, self) + + self.StageGroup = {} + self.NeedReset = false +end + +function XUiCoupleCombatChapter:OnEnable() + if self.NeedReset then + self:SetPanelStageListMovementType(CS.UnityEngine.UI.ScrollRect.MovementType.Elastic) + self:ReopenAssetPanel() + else + self.NeedReset = true + end + + -- 线条处理 + self:HandleStageLines() + -- 关卡处理 + self:HandleStages() +end + +function XUiCoupleCombatChapter:OnDestroy() + self.IsOpenDetails = nil + XEventManager.RemoveEventListener(XEventId.EVENT_FUBEN_CLOSE_FUBENSTAGEDETAIL, self.CloseStageDetails, self) +end + +function XUiCoupleCombatChapter:SetUiData(chapterType, isAutoMove) + self.LastUnlockStage = 1 + self.ChapterType = chapterType + self.StageIdList = XDataCenter.FubenCoupleCombatManager.GetChapterTemplate(chapterType).StageIds + -- 初始化prefab组件 + --local chapterGameObject = self.Transform:LoadPrefab(self.ChapterTemplate.ChapterPrefab[chapterType]) + --XTool.InitUiObjectByUi(self, chapterGameObject) + + --local uiObj = chapterGameObject.transform:GetComponent("UiObject") + --for i = 0, uiObj.NameList.Count - 1 do + -- self[uiObj.NameList[i]] = uiObj.ObjList[i] + --end + self.AssetPanel = self.RootUi.AssetPanel + + if self.PaneStageList then + local dragProxy = self.PaneStageList:GetComponent(typeof(XUguiDragProxy)) + if not dragProxy then + dragProxy = self.PaneStageList.gameObject:AddComponent(typeof(XUguiDragProxy)) + end + dragProxy:RegisterHandler(handler(self, self.OnDragProxy)) + end + -- 线条处理 + self:HandleStageLines() + + self:UpdateNodeLines() + -- 关卡处理 + self:HandleStages() + + -- 移动至ListView正确的位置 + if self.PanelStageContentSizeFitter then + self.PanelStageContentSizeFitter:SetLayoutHorizontal() + end + + if isAutoMove then + self:MoveIntoStage(self.LastUnlockStage) + end +end + +function XUiCoupleCombatChapter:HandleStages() + self.ChapterStages = {} + for i = 1, #self.StageIdList do + local itemStage = self.PanelStageContent:Find(string.format("Stage%d", i)) + if not itemStage then + XLog.Error("XUiCoupleCombatChapter:HandleStages() 函数错误: 游戏物体PanelStageContent下找不到名字为:" .. string.format("Stage%d", i) .. "的游戏物体") + return + end + -- 组件初始化 + itemStage.gameObject:SetActiveEx(true) + self.StageGroup[i] = itemStage + self.ChapterStages[i] = XUiStageItem.New(self, itemStage) + self.ChapterStages[i]:UpdateNode(self.StageIdList[i], i, self.ChapterType) + --self.ChapterStages[i]:SetChallengingStage(i == self.LastUnlockStage) + end +end + +function XUiCoupleCombatChapter:HandleStageLines() + self.ChapterStageLine = {} + for i = 1, #self.StageIdList-1 do + local itemLine = self.PanelStageContent:Find(string.format("Line%d", i)) + if not itemLine then + XLog.Error("XUiCoupleCombatChapter:SetUiData() error: prefab not found a child name:" .. string.format("Line%d", i)) + return + end + itemLine.gameObject:SetActiveEx(false) + self.ChapterStageLine[i] = itemLine + end + + -- 隐藏多余组件 + local indexLine = #self.ChapterStageLine + local extraLine = self.PanelStageContent:Find(string.format("Line%d", indexLine)) + while extraLine do + extraLine.gameObject:SetActiveEx(false) + indexLine = indexLine + 1 + extraLine = self.PanelStageContent:Find(string.format("Line%d", indexLine)) + end +end + +-- 更新节点线条 +function XUiCoupleCombatChapter:UpdateNodeLines() + if not self.StageIdList then return end + local stageLength = #self.StageIdList + + for i = 1, stageLength - 1 do + local isOpen = XDataCenter.FubenManager.CheckStageOpen(self.StageIdList[i + 1]) + self:SetStageLineActive(i, isOpen) + end + + for i = 1, stageLength do + local isUnlock = XDataCenter.FubenManager.CheckStageIsUnlock(self.StageIdList[i]) + if isUnlock then + self.LastUnlockStage = i + end + end + + --self:SetStageLineActive(1, false) + --self:SetStageLineActive(stageLength + 1, true) +end + +function XUiCoupleCombatChapter:SetStageLineActive(index, isActive) + if self.ChapterStageLine[index] then + self.ChapterStageLine[index].gameObject:SetActiveEx(isActive) + end +end + +-- 选中关卡 +function XUiCoupleCombatChapter:UpdateNodesSelect(stageId) + for i = 1, #self.StageIdList do + if self.ChapterStages[i] then + self.ChapterStages[i]:SetNodeSelect(self.StageIdList[i] == stageId) + end + end +end + +-- 取消选中 +function XUiCoupleCombatChapter:ClearNodesSelect() + for i = 1, #self.StageIdList do + if self.ChapterStages[i] then + self.ChapterStages[i]:SetNodeSelect(false) + end + end + self.IsOpenDetails = false +end + +-- 打开剧情,战斗详情 +function XUiCoupleCombatChapter:OpenStageDetails(stageId) + self.IsOpenDetails = true + --self.BtnCloseDetail.gameObject:SetActiveEx(true) + self.RootUi:OpenOneChildUi(FUBEN_FIGHT_DETAIL, self) + self.RootUi:FindChildUiObj(FUBEN_FIGHT_DETAIL):SetStageDetail(stageId) + + if self.AssetPanel then + self.AssetPanel.GameObject:SetActiveEx(false) + end + self.PanelStageContentRaycast.raycastTarget = false +end + +-- 关闭剧情,战斗详情 +function XUiCoupleCombatChapter:CloseStageDetails() + self.IsOpenDetails = false + --self.BtnCloseDetail.gameObject:SetActiveEx(false) + self.PanelStageContentRaycast.raycastTarget = true + self:ClearNodesSelect() + self:ReopenAssetPanel() + self:SetPanelStageListMovementType(CS.UnityEngine.UI.ScrollRect.MovementType.Elastic) +end + +function XUiCoupleCombatChapter:OnBtnCloseDetailClick() + self:CloseStageDetails() +end + +function XUiCoupleCombatChapter:OnDragProxy(dragType) + if self.IsOpenDetails and dragType == 0 then + self:CloseStageDetails() + end +end + +function XUiCoupleCombatChapter:PlayScrollViewMove(gridTransform) + self:SetPanelStageListMovementType(CS.UnityEngine.UI.ScrollRect.MovementType.Unrestricted) + local gridRect = gridTransform:GetComponent("RectTransform") + local diffX = gridRect.localPosition.x + self.PanelStageContent.localPosition.x + if diffX < XDataCenter.FubenMainLineManager.UiGridChapterMoveMinX or diffX > XDataCenter.FubenMainLineManager.UiGridChapterMoveMaxX then + local tarPosX = XDataCenter.FubenMainLineManager.UiGridChapterMoveTargetX - gridRect.localPosition.x + local tarPos = self.PanelStageContent.localPosition + tarPos.x = tarPosX + XLuaUiManager.SetMask(true) + XUiHelper.DoMove(self.PanelStageContent, tarPos, XDataCenter.FubenMainLineManager.UiGridChapterMoveDuration, XUiHelper.EaseType.Sin, function() + XLuaUiManager.SetMask(false) + end) + end +end + +function XUiCoupleCombatChapter:MoveIntoStage(stageIndex) + local gridRect = self.StageGroup[stageIndex] + local diffX = gridRect.localPosition.x + self.PanelStageContent.localPosition.x + if diffX > CS.XResolutionManager.OriginWidth / 2 then + local tarPosX = (CS.XResolutionManager.OriginWidth / 4) - gridRect.localPosition.x + local tarPos = self.PanelStageContent.localPosition + tarPos.x = tarPosX + XLuaUiManager.SetMask(true) + self:SetPanelStageListMovementType(CS.UnityEngine.UI.ScrollRect.MovementType.Unrestricted) + XUiHelper.DoMove(self.PanelStageContent, tarPos, XDataCenter.FubenMainLineManager.UiGridChapterMoveDuration, XUiHelper.EaseType.Sin, function() + XLuaUiManager.SetMask(false) + self:SetPanelStageListMovementType(CS.UnityEngine.UI.ScrollRect.MovementType.Elastic) + end) + end +end + +function XUiCoupleCombatChapter:EndScrollViewMove() + self:SetPanelStageListMovementType(CS.UnityEngine.UI.ScrollRect.MovementType.Elastic) + self:ReopenAssetPanel() +end + +function XUiCoupleCombatChapter:ReopenAssetPanel() + if self.IsOpenDetails then + return + end + if self.AssetPanel then + self.AssetPanel.GameObject:SetActiveEx(true) + end +end + +-- 背景 +function XUiCoupleCombatChapter:SwitchFestivalBg(festivalTemplate) + if not festivalTemplate or not festivalTemplate.MainBackgound then + self.RImgFestivalBg.gameObject:SetActiveEx(false) + return + end + self.RImgFestivalBg:SetRawImage(festivalTemplate.MainBackgound) +end + +-- 加载特效 +function XUiCoupleCombatChapter:LoadEffect(effectUrl) + if not effectUrl or effectUrl == "" then + self.PanelEffect.gameObject:SetActiveEx(false) + return + end + + self.PanelEffect.gameObject:LoadUiEffect(effectUrl) + self.PanelEffect.gameObject:SetActiveEx(true) +end + +function XUiCoupleCombatChapter:SetPanelStageListMovementType(movementType) + if not self.PaneStageList then return end + self.PaneStageList.movementType = movementType +end + +return XUiCoupleCombatChapter \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenCoupleCombat/ChildView/XUiPanelFeature.lua b/Resources/Scripts/XUi/XUiFubenCoupleCombat/ChildView/XUiPanelFeature.lua new file mode 100644 index 00000000..630bba93 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenCoupleCombat/ChildView/XUiPanelFeature.lua @@ -0,0 +1,60 @@ +local XUiPanelFeature = XClass(nil, "XUiPanelFeature") + +function XUiPanelFeature:Ctor(uiRoot, ui) + self.UiRoot = uiRoot + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + self:InitUi() +end + +function XUiPanelFeature:InitUi() + self.GameObject:SetActiveEx(true) + self.PanelFeature = self.Transform:Find("PanelFeature") + self.GridFeature = self.Transform:Find("PanelFeature/GridFeature") + self.GridFeature.gameObject:SetActiveEx(false) + self.GridFeatureList = {} +end + +function XUiPanelFeature:Refresh(featureList, matchDic) + if featureList and matchDic then + self.GameObject:SetActiveEx(true) + else + self.GameObject:SetActiveEx(false) + return + end + self.FeatureList = featureList + for i, v in ipairs(featureList) do + local info = XFubenCoupleCombatConfig.GetFeatureById(v) + if not info then return end + local item = self.GridFeatureList[i] + + if not item then + item = CS.UnityEngine.Object.Instantiate(self.GridFeature, self.PanelFeature) -- 复制一个item + self.GridFeatureList[i] = item + --CsXUiHelper.RegisterClickEvent(item:Find("BgNormal"):GetComponent("Image"), function() self:ShowInfo() end) + CsXUiHelper.RegisterClickEvent(item:Find("RImgIcon"):GetComponent("RawImage"), function() self:ShowInfo(i) end) + end + item.gameObject:SetActiveEx(true) + local isActive = matchDic[v] and matchDic[v] > 0 + item:Find("BgNormal").gameObject:SetActiveEx(not isActive) + item:Find("BgActive").gameObject:SetActiveEx(isActive) + item:Find("RImgIcon"):GetComponent("RawImage"):SetRawImage(info.Icon) + end + for i = #featureList + 1, #self.GridFeatureList do + self.GridFeatureList[i].gameObject:SetActiveEx(false) + end + + self.GridFeature.gameObject:SetActiveEx(false) +end + +function XUiPanelFeature:ShowInfo(index) + local info = XFubenCoupleCombatConfig.GetFeatureById(self.FeatureList[index]) + XUiManager.UiFubenDialogTip(info.Name, info.Description) +end + +function XUiPanelFeature:OnDisable() +end + +return XUiPanelFeature \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenCoupleCombat/Proxy/XUiCoupleCombatNewRoomSingle.lua b/Resources/Scripts/XUi/XUiFubenCoupleCombat/Proxy/XUiCoupleCombatNewRoomSingle.lua new file mode 100644 index 00000000..f56dd353 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenCoupleCombat/Proxy/XUiCoupleCombatNewRoomSingle.lua @@ -0,0 +1,108 @@ +-- 双人下场玩法出战界面代理 +local XUiCoupleCombatNewRoomSingle = {} +local XUiPanelFeature = require("XUi/XUiFubenCoupleCombat/ChildView/XUiPanelFeature") + +function XUiCoupleCombatNewRoomSingle.InitEditBattleUi(newRoomSingle) + newRoomSingle.BtnTeamPrefab.gameObject:SetActiveEx(false) + newRoomSingle.ImgSkillLine.gameObject:SetActiveEx(false) + newRoomSingle.PanelEnvIntro.gameObject:SetActiveEx(true) + newRoomSingle.DarkBottom.gameObject:SetActiveEx(true) + local stageInterInfo = XFubenCoupleCombatConfig.GetStageInfo(newRoomSingle.CurrentStageId) + + for _, v in ipairs(stageInterInfo.Intro) do + local item = CS.UnityEngine.Object.Instantiate(newRoomSingle.GridIntroDesc, newRoomSingle.PanelIntroContent) -- 复制一个item + item:Find("Text"):GetComponent("Text").text = v + end + newRoomSingle.GridIntroDesc.gameObject:SetActiveEx(false) +end + +function XUiCoupleCombatNewRoomSingle.InitEditBattleUiCharacterInfo(newRoomSingle) + newRoomSingle.BtnShowInfoToggle.gameObject:SetActiveEx(false) + newRoomSingle.IsShowCharacterInfo = 0 +end + +function XUiCoupleCombatNewRoomSingle.GetBattleTeamData(newRoomSingle) + local curTeam = XTool.Clone(XDataCenter.TeamManager.EmptyTeam) + --XDataCenter.TeamManager.SaveTeamLocal(curTeam, newRoomSingle.CurrentStageId) + XDataCenter.TeamManager.SetPlayerTeam(curTeam, false) + return curTeam +end + +function XUiCoupleCombatNewRoomSingle.HandleCharClick(newRoomSingle, charPos) + if newRoomSingle.CurTeam.TeamData[charPos] == 0 then + local curTeamMemberCount = 0 + for _, charId in ipairs(newRoomSingle.CurTeam.TeamData) do + if charId > 0 then + curTeamMemberCount = curTeamMemberCount + 1 + end + end + -- 双人玩法 不允许上超过2个人 + if curTeamMemberCount >= 2 then + XUiManager.TipText("CoupleCombatTeamOverDoubleTip", XUiManager.UiTipType.Wrong) + return + end + end + + local teamData = XTool.Clone(newRoomSingle.CurTeam.TeamData) + local robotIdList = XDataCenter.FubenCoupleCombatManager.GetRobotByStage(newRoomSingle.CurrentStageId) + XLuaUiManager.Open("UiRoomCharacter", teamData, charPos, function(resTeam) + newRoomSingle:UpdateTeam(resTeam) + end, XDataCenter.FubenManager.StageType.CoupleCombat, nil, {IsRobotOnly = true, RobotIdList = robotIdList, StageId = newRoomSingle.CurrentStageId}) +end + +function XUiCoupleCombatNewRoomSingle.UpdateFeatureInfo(newRoomSingle, MAX_CHAR_COUNT) + local matchDic, featureFullList = XDataCenter.FubenCoupleCombatManager.GetFeatureMatch(newRoomSingle.CurrentStageId, newRoomSingle.CurTeam.TeamData) + if not newRoomSingle.PanelFeature then + newRoomSingle.PanelFeature = {} + newRoomSingle.PanelFeature[0] = XUiPanelFeature.New(newRoomSingle, newRoomSingle.PanelStageFeature) + for i = 1, MAX_CHAR_COUNT do + newRoomSingle.PanelFeature[i] = XUiPanelFeature.New(newRoomSingle, newRoomSingle["CharacterFeature" .. i]) + end + end + for i ,v in pairs(newRoomSingle.PanelFeature) do + v:Refresh(featureFullList[i], matchDic) + end +end + +function XUiCoupleCombatNewRoomSingle.UpdateTeam(newRoomSingle) + XDataCenter.TeamManager.SaveTeamLocal(newRoomSingle.CurTeam, newRoomSingle.CurrentStageId) + XDataCenter.TeamManager.SetPlayerTeam(newRoomSingle.CurTeam, false) +end + +function XUiCoupleCombatNewRoomSingle.CheckEnterFight(newRoomSingle, curTeam) + local curTeamMemberCount = 0 + for _, charId in ipairs(curTeam.TeamData) do + if charId > 0 then + curTeamMemberCount = curTeamMemberCount + 1 + end + end + + -- 双人玩法 只能上2个人 + if curTeamMemberCount == 2 then + return true + else + XUiManager.TipText("CoupleCombatTeamLessDoubleTip", XUiManager.UiTipType.Wrong) + return false + end +end + +function XUiCoupleCombatNewRoomSingle.GetRealCharData(newRoomSingle) + local teamData = newRoomSingle.CurTeam.TeamData + local teamIdData = {} + for pos, charId in pairs(teamData) do + if charId and charId > 0 then + local data = XFubenCoupleCombatConfig.GetRobotInfo(charId) + teamIdData[pos] = data and data.RobotId or 0 + else + teamIdData[pos] = 0 + end + end + return teamIdData +end + +function XUiCoupleCombatNewRoomSingle.OnResetEvent(newRoomSingle) + XLuaUiManager.RunMain() + XUiManager.TipMsg(CS.XTextManager.GetText("ActivityMainLineEnd")) +end + +return XUiCoupleCombatNewRoomSingle \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenCoupleCombat/Proxy/XUiCoupleCombatRoomCharacter.lua b/Resources/Scripts/XUi/XUiFubenCoupleCombat/Proxy/XUiCoupleCombatRoomCharacter.lua new file mode 100644 index 00000000..010a3c0d --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenCoupleCombat/Proxy/XUiCoupleCombatRoomCharacter.lua @@ -0,0 +1,122 @@ +-- 双人玩法选人列表界面代理 +local XUiCoupleCombatRoomCharacter = {} +local XUiPanelFeature = require("XUi/XUiFubenCoupleCombat/ChildView/XUiPanelFeature") + +function XUiCoupleCombatRoomCharacter.InitCharacterTypeBtns(roomCharacterUi, teamCharIdMap, TabBtnIndex) + roomCharacterUi.BtnTabShougezhe.gameObject:SetActiveEx(false) + roomCharacterUi.PanelCharacterTypeBtns:SelectIndex(TabBtnIndex.Normal) +end + +function XUiCoupleCombatRoomCharacter.SortList(roomCharacterUi, charIdList) + local indexDic = {} + for i, v in ipairs(charIdList) do + indexDic[v] = i + end + + local matchCountDic = {} + local stageFeatureDic = {} + local stageId = roomCharacterUi.StageId + local stageInterInfo = XFubenCoupleCombatConfig.GetStageInfo(stageId) + if not stageInterInfo then return charIdList end + for _, v in ipairs(stageInterInfo.Feature) do + stageFeatureDic[v] = true + end + + for _, id in ipairs(charIdList) do + matchCountDic[id] = 0 + local allMatch = true + local memberInfo = XFubenCoupleCombatConfig.GetRobotInfo(id) + if memberInfo then + for _, v in ipairs(memberInfo.Feature) do + if stageFeatureDic[v] then + matchCountDic[id] = matchCountDic[id] + 1 + else + allMatch = false + end + end + if allMatch then + matchCountDic[id] = matchCountDic[id] + XMath.IntMax() + end + end + end + + table.sort(charIdList, function(a, b) + if XDataCenter.FubenCoupleCombatManager.CheckRobotUsed(stageId, a) ~= + XDataCenter.FubenCoupleCombatManager.CheckRobotUsed(stageId, b) then + return XDataCenter.FubenCoupleCombatManager.CheckRobotUsed(stageId, b) + elseif matchCountDic[a] ~= matchCountDic[b] then + return matchCountDic[a] > matchCountDic[b] + else + return indexDic[a] < indexDic[b] + end + end) + + return charIdList +end + +function XUiCoupleCombatRoomCharacter.SetPanelEmptyList(roomCharacterUi, isEmpty) + if not roomCharacterUi.PanelFeatureStage then + roomCharacterUi.PanelFeatureStage = XUiPanelFeature.New(roomCharacterUi, roomCharacterUi.StageFeature) + roomCharacterUi.PanelFeatureCharacter = XUiPanelFeature.New(roomCharacterUi, roomCharacterUi.CharacterFeature) + local stageInterInfo = XFubenCoupleCombatConfig.GetStageInfo(roomCharacterUi.StageId) + if not stageInterInfo then return end + roomCharacterUi.PanelFeatureStage:Refresh(stageInterInfo.Feature, {}) + + roomCharacterUi.BtnConsciousness.gameObject:SetActiveEx(false) + roomCharacterUi.BtnFashion.gameObject:SetActiveEx(false) + roomCharacterUi.BtnWeapon.gameObject:SetActiveEx(false) + roomCharacterUi.BtnPartner.gameObject:SetActiveEx(false) + end + roomCharacterUi.PanelFeatureElement.gameObject:SetActiveEx(not isEmpty) + + roomCharacterUi.BtnQuitTeam.gameObject:SetActiveEx(false) + roomCharacterUi.BtnJoinTeam.gameObject:SetActiveEx(false) + + roomCharacterUi.PanelRoleModel.gameObject:SetActiveEx(not isEmpty) + roomCharacterUi.PanelRoleContent.gameObject:SetActiveEx(not isEmpty) + roomCharacterUi.PanelEmptyList.gameObject:SetActiveEx(isEmpty) +end + +function XUiCoupleCombatRoomCharacter.UpdatePanelEmptyList(roomCharacterUi, charId) + local robotInfo = XFubenCoupleCombatConfig.GetRobotInfo(charId) + if not robotInfo then return end + + roomCharacterUi.PanelFeatureCharacter:Refresh(robotInfo.Feature, {}) + --roomCharacterUi.BtnJoinTeam.gameObject:SetActiveEx(roomCharacterUi.NeedShowBtnJoinTeam) +end + +function XUiCoupleCombatRoomCharacter.UpdateTeamBtn(roomCharacterUi, charId) + if not (roomCharacterUi.TeamCharIdMap and next(roomCharacterUi.TeamCharIdMap)) then + roomCharacterUi.BtnJoinTeam.gameObject:SetActiveEx(false) + return + end + + --在当前操作的队伍中 + local isInTeam = roomCharacterUi:IsInTeam(charId) + local hideBtnJoinTeam = isInTeam or XDataCenter.FubenCoupleCombatManager.CheckRobotUsed(roomCharacterUi.StageId, charId) + roomCharacterUi.BtnQuitTeam.gameObject:SetActiveEx(isInTeam) + roomCharacterUi.BtnJoinTeam.gameObject:SetActiveEx(not hideBtnJoinTeam) +end + +function XUiCoupleCombatRoomCharacter.GetCharInfo(roomCharacterUi, charId) + local charInfo = {} + + if XFubenCoupleCombatConfig.GetRobotInfo(charId) then + charInfo.Id = charId + charInfo.IsRobot = true + charInfo.HideTryTag = true + if XDataCenter.FubenCoupleCombatManager.CheckRobotUsed(roomCharacterUi.StageId, charId) then + charInfo.ShowText = CSXTextManagerGetText("CoupleCombatRobotUsed") + end + --charInfo.Ability = XRobotManager.GetRobotAbility(charId) + end + + return charInfo +end + +function XUiCoupleCombatRoomCharacter.OnResetEvent() + XLuaUiManager.RunMain() + XDataCenter.FubenHackManager.OnActivityEnd() +end + +return XUiCoupleCombatRoomCharacter \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenCoupleCombat/XUiCoupleCombatMain.lua b/Resources/Scripts/XUi/XUiFubenCoupleCombat/XUiCoupleCombatMain.lua new file mode 100644 index 00000000..f9e96efb --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenCoupleCombat/XUiCoupleCombatMain.lua @@ -0,0 +1,176 @@ +local XUiCoupleCombatChapter = require("XUi/XUiFubenCoupleCombat/ChildView/XUiCoupleCombatChapter") + +local XUiCoupleCombatMain = XLuaUiManager.Register(XLuaUi, "UiCoupleCombatMain") + +local StageType = XFubenCoupleCombatConfig.StageType + +function XUiCoupleCombatMain:OnAwake() + self.TabBtns = {} + self.SwitchEffect = {} +end + +function XUiCoupleCombatMain:OnEnable() + self:Refresh() +end + +function XUiCoupleCombatMain:OnResume(data) + self.CurrentView = data +end + +function XUiCoupleCombatMain:OnStart(defaultView) + if not self.CurrentView then + self.CurrentView = defaultView or StageType.Normal + end + + self.ActTemplate = XDataCenter.FubenCoupleCombatManager.GetCurrentActTemplate() + if not self.ActTemplate then + return + end + + self:CreateActivityTimer(XDataCenter.FubenCoupleCombatManager.GetEndTime()) + self.TxtTitle.text = self.ActTemplate.Name + + self:InitUiView() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self.PointRewardGridList = {} + + self:OnSwitchView(self.CurrentView, true) + self.RedPointNormalMode = XRedPointManager.AddRedPointEvent(self.BtnSwitchNormal, self.OnCheckNormalMode, self, { XRedPointConditions.Types.CONDITION_COUPLE_COMBAT_NORMAL }, nil, true) + self.RedPointHardMode = XRedPointManager.AddRedPointEvent(self.BtnSwitchHard, self.OnCheckHardMode, self, { XRedPointConditions.Types.CONDITION_COUPLE_COMBAT_HARD }, nil, true) +end + +function XUiCoupleCombatMain:OnReleaseInst() + return self.CurrentView +end + +function XUiCoupleCombatMain:OnGetEvents() + return { XEventId.EVENT_FUBEN_COUPLECOMBAT_UPDATE, + CS.XEventId.EVENT_UI_DONE, + XEventId.EVENT_ACTIVITY_ON_RESET} +end + +function XUiCoupleCombatMain:OnNotify(evt, ...) + local args = { ... } + if evt == XEventId.EVENT_FUBEN_COUPLECOMBAT_UPDATE then + self:Refresh() + elseif evt == CS.XEventId.EVENT_UI_DONE then + if XDataCenter.FubenCoupleCombatManager.GetIsActivityEnd() then + XDataCenter.FubenCoupleCombatManager.OnActivityEnd() + return + end + elseif evt == XEventId.EVENT_ACTIVITY_ON_RESET then + if args[1] ~= XDataCenter.FubenManager.StageType.CoupleCombat then return end + XDataCenter.FubenCoupleCombatManager.OnActivityEnd() + end +end + +function XUiCoupleCombatMain:OnCheckNormalMode(count) + self.BtnSwitchNormal:ShowReddot(count >= 0) +end + +function XUiCoupleCombatMain:OnCheckHardMode(count) + self.BtnSwitchHard:ShowReddot(count >= 0) +end + +function XUiCoupleCombatMain:Refresh(isAutoScroll) + if XDataCenter.FubenCoupleCombatManager.GetIsActivityEnd() then + XDataCenter.FubenCoupleCombatManager.OnActivityEnd() + return + end + self.BtnSwitchNormal.gameObject:SetActiveEx(self.CurrentView == StageType.Hard) + self.BtnSwitchHard.gameObject:SetActiveEx(self.CurrentView == StageType.Normal) + + self.PanelStage:SetUiData(self.CurrentView, isAutoScroll) + + local passCount, allCount = XDataCenter.FubenCoupleCombatManager.GetStageSchedule(self.CurrentView) + self.TxtPassCount.text = passCount + self.TxtStageCount.text = string.format("/%d", allCount) + + passCount, allCount = XDataCenter.TaskManager.GetTaskProgress(TaskType.CoupleCombat, self.CurrentView) + self.TxtTaskGotCount.text = passCount + self.TxtTaskCount.text = allCount + self.ImgJindu.fillAmount = passCount / allCount + + self.BtnTaskReward:ShowReddot(XDataCenter.TaskManager.GetIsRewardForEx(TaskType.CoupleCombat, self.CurrentView)) + XRedPointManager.Check(self.RedPointNormalMode) + XRedPointManager.Check(self.RedPointHardMode) + local isOpen = XDataCenter.FubenCoupleCombatManager.CheckModeOpen(StageType.Hard) + self.BtnSwitchHard:SetButtonState(isOpen and XUiButtonState.Normal or XUiButtonState.Disable) +end + +function XUiCoupleCombatMain:OnDestroy() + self:StopActivityTimer() + if self.PanelStage then + self.PanelStage:OnDestroy() + end +end + +function XUiCoupleCombatMain:InitUiView() + self.SceneBtnBack.CallBack = function() self:OnBtnBackClick() end + self.SceneBtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + + self.BtnSwitchNormal.CallBack = function() self:OnSwitchView(StageType.Normal) end + self.BtnSwitchHard.CallBack = function() self:OnSwitchView(StageType.Hard) end + self.BtnTaskReward.CallBack = function() self:OnBtnTaskRewardClick() end + + self:BindHelpBtn(self.BtnHelp, "CoupleCombat") + self.PanelStage = XUiCoupleCombatChapter.New(self.PanelChapter, self) +end + +function XUiCoupleCombatMain:OnBtnBackClick() + self:Close() +end + +function XUiCoupleCombatMain:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiCoupleCombatMain:OnBtnTaskRewardClick() + XLuaUiManager.Open("UiFubenTaskReward", TaskType.CoupleCombat, self.CurrentView, function() + self:Refresh() + end) +end + +function XUiCoupleCombatMain:OnSwitchView(type, isFromOtherUi) + local isOpen, desc = XDataCenter.FubenCoupleCombatManager.CheckModeOpen(type) + if not isOpen then + XUiManager.TipMsg(desc) + return + end + + if not isFromOtherUi then + self:PlayAnimation("QieHuan") + end + self.CurrentView = type + XDataCenter.FubenCoupleCombatManager.SetReadNewStageMark(type) + self.RImgBgNor.gameObject:SetActiveEx(type == StageType.Normal) + self.RImgBgHard.gameObject:SetActiveEx(type == StageType.Hard) + self:Refresh(true) +end + +-- 计时器 +function XUiCoupleCombatMain:CreateActivityTimer(endTime) + local time = XTime.GetServerNowTimestamp() + self.TxtDay.text = XUiHelper.GetTime(endTime - time, XUiHelper.TimeFormatType.ACTIVITY) + self:StopActivityTimer() + self.ActivityTimer = XScheduleManager.ScheduleForever(function() + time = XTime.GetServerNowTimestamp() + if time > endTime then + --self:StopActivityTimer() + return + end + self.TxtDay.text = XUiHelper.GetTime(endTime - time, XUiHelper.TimeFormatType.ACTIVITY) + end, XScheduleManager.SECOND, 0) +end + +function XUiCoupleCombatMain:StopActivityTimer() + if self.ActivityTimer then + XScheduleManager.UnSchedule(self.ActivityTimer) + self.ActivityTimer = nil + end + + if self.AnimTimer then + XScheduleManager.UnSchedule(self.AnimTimer) + self.AnimTimer = nil + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenCoupleCombat/XUiFubenCoupleCombatDetail.lua b/Resources/Scripts/XUi/XUiFubenCoupleCombat/XUiFubenCoupleCombatDetail.lua new file mode 100644 index 00000000..9f60d676 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenCoupleCombat/XUiFubenCoupleCombatDetail.lua @@ -0,0 +1,231 @@ +local XUiFubenCoupleCombatDetail = XLuaUiManager.Register(XLuaUi, "UiFubenCoupleCombatDetail") + +function XUiFubenCoupleCombatDetail:OnAwake() + self:AutoAddListener() + --self.GridStageStar.gameObject:SetActive(false) + --self.GridCommon.gameObject:SetActive(false) + --self:InitStarPanels() +end + +function XUiFubenCoupleCombatDetail:OnStart(rootUi) + self.GridList = {} + self.DescList = {} + self.RootUi = rootUi + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) +end + +function XUiFubenCoupleCombatDetail:OnEnable() + -- 动画 + --self.IsPlaying = true + --self:PlayAnimation("AnimBegin", handler(self, function() + -- self.IsPlaying = false + --end)) + + self.IsOpen = true +end + +function XUiFubenCoupleCombatDetail:OnDisable() + self.IsOpen = false +end + +function XUiFubenCoupleCombatDetail:SetStageDetail(stageId) + self.StageId = stageId + self.StageCfg = XDataCenter.FubenManager.GetStageCfg(self.StageId) + + self.StageInfo = XDataCenter.FubenManager.GetStageInfo(self.StageId) + self.StageInterInfo = XFubenCoupleCombatConfig.GetStageInfo(self.StageId) + self.IsPassed = self.StageInfo and self.StageInfo.Passed + if not self.StageInterInfo then return end + + local showReset = false + local useList = XDataCenter.FubenCoupleCombatManager.GetStageUsedRobot(self.StageId) + if useList and next(useList) then + showReset = true + end + + self.BtnEnter.gameObject:SetActiveEx(not showReset) + self.BtnReset.gameObject:SetActiveEx(showReset) + + self:UpdateDesc() + self:UpdateCommon() + self:UpdateRewards() + --self:UpdateStageFightControl()--更新战力限制提示 +end + +function XUiFubenCoupleCombatDetail:InitStarPanels() + self.GridStarList = {} + for i = 1, 3 do + local ui = self.Transform:Find("SafeAreaContentPane/PanelDetail/PanelTargetList/GridStageStar" .. i) + ui.gameObject:SetActive(true) + local grid = XUiGridStageStar.New(ui) + self.GridStarList[i] = grid + end +end + +function XUiFubenCoupleCombatDetail:UpdateDesc() + self.TxtActive.gameObject:SetActiveEx(false) + for i, desc in ipairs(self.StageInterInfo.Intro) do + if not self.DescList[i] then + self.DescList[i] = CS.UnityEngine.GameObject.Instantiate(self.TxtActive.gameObject, self.DescContent):GetComponent("Text") + end + self.DescList[i].text = desc + self.DescList[i].gameObject:SetActiveEx(true) + end + + for i = #self.StageInterInfo.Intro + 1, #self.DescList do + self.DescList[i].gameObject:SetActiveEx(false) + end + CS.UnityEngine.UI.LayoutRebuilder.ForceRebuildLayoutImmediate(self.DescContent) +end + +function XUiFubenCoupleCombatDetail:AutoAddListener() + self.BtnEnter.CallBack = function() self:OnBtnEnterClick() end + self.BtnReset.CallBack = function() self:OnBtnResetClick() end + self.BtnCloseDetail.CallBack = function() self:OnBtnCloseDetailClick() end +end +-- auto +function XUiFubenCoupleCombatDetail:OnBtnResetClick() + XUiManager.DialogTip(nil, CSXTextManagerGetText("CoupleCombatResetStageTip"), XUiManager.DialogType.Normal, nil, function() + XDataCenter.FubenCoupleCombatManager.ResetStage(self.StageId, function() + XUiManager.TipText("CoupleCombatResetStageSucc") + self:Hide() + end) + end) +end + +function XUiFubenCoupleCombatDetail:OnBtnCloseDetailClick() + self:Hide() +end + +function XUiFubenCoupleCombatDetail:OnBtnEnterClick() + if self.IsPlaying then + return + end + + if XDataCenter.FubenManager.CheckPreFight(self.StageCfg) then + XEventManager.DispatchEvent(XEventId.EVENT_FUBEN_CLOSE_FUBENSTAGEDETAIL) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_FUBEN_COUPLECOMBAT_UPDATE) + + XLuaUiManager.Open("UiNewRoomSingle", self.StageId) + --self:Hide() + self:Close() + end +end + +function XUiFubenCoupleCombatDetail:Hide() + if self.IsPlaying or not self.IsOpen then + return + end + + self.IsPlaying = true + self:PlayAnimation("AnimEnd", handler(self, function() + if XTool.UObjIsNil(self.GameObject) then + return + end + self.IsPlaying = false + self:Close() + + XEventManager.DispatchEvent(XEventId.EVENT_FUBEN_CLOSE_FUBENSTAGEDETAIL) + end)) +end + +function XUiFubenCoupleCombatDetail:UpdateCommon() + local stageCfg = XDataCenter.FubenManager.GetStageCfg(self.StageId) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(self.StageId) + + self.TxtTitle.text = stageCfg.Name + --self.TxtDesc.text = stageCfg.Description + self.TxtATNums.text = stageCfg.RequireActionPoint + + local maxChallengeNum = XDataCenter.FubenManager.GetStageMaxChallengeNums(self.StageId) + + --self.PanelNums.gameObject:SetActive(maxChallengeNum > 0) + --self.PanelNoLimitCount.gameObject:SetActive(maxChallengeNum <= 0) + -- + --if maxChallengeNum > 0 then + -- local stageData = XDataCenter.FubenManager.GetStageData(self.StageId) + -- local chanllengeNum = stageData and stageData.PassTimesToday or 0 + -- self.TxtAllNums.text = "/" .. maxChallengeNum + -- self.TxtLeftNums.text = maxChallengeNum - chanllengeNum + --end + + local firstDrop = false + if not stageInfo.Passed then + local cfg = XDataCenter.FubenManager.GetStageLevelControl(self.StageId) + if cfg and cfg.FirstRewardShow > 0 or stageCfg.FirstRewardShow > 0 then + firstDrop = true + end + end + self.TxtFirstDrop.gameObject:SetActive(firstDrop) + self.TxtDrop.gameObject:SetActive(not firstDrop) + + --for i = 1, 3 do + -- self.GridStarList[i]:Refresh(stageCfg.StarDesc[i], stageInfo.StarsMap[i]) + --end +end + +function XUiFubenCoupleCombatDetail:UpdateRewards() + self.GridCommon.gameObject:SetActiveEx(false) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(self.StageId) + + -- 获取显示奖励Id + local rewardId = 0 + local IsFirst = false + local cfg = XDataCenter.FubenManager.GetStageLevelControl(self.StageId) + if not stageInfo.Passed then + rewardId = cfg and cfg.FirstRewardShow or self.StageCfg.FirstRewardShow + if cfg and cfg.FirstRewardShow > 0 or self.StageCfg.FirstRewardShow > 0 then + IsFirst = true + end + end + if rewardId == 0 then + rewardId = cfg and cfg.FinishRewardShow or self.StageCfg.FinishRewardShow + end + if rewardId == 0 then + for j = 1, #self.GridList do + self.GridList[j].GameObject:SetActive(false) + end + return + end + + local rewards = IsFirst and XRewardManager.GetRewardList(rewardId) or XRewardManager.GetRewardListNotCount(rewardId) + if rewards then + for i, item in ipairs(rewards) do + local grid + if self.GridList[i] then + grid = self.GridList[i] + else + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommon) + grid = XUiGridCommon.New(self, ui) + grid.Transform:SetParent(self.PanelDropContent, false) + self.GridList[i] = grid + end + grid:Refresh(item) + grid.GameObject:SetActive(true) + end + end + + local rewardsCount = 0 + if rewards then + rewardsCount = #rewards + end + + for j = 1, #self.GridList do + if j > rewardsCount then + self.GridList[j].GameObject:SetActive(false) + end + end +end + +function XUiFubenCoupleCombatDetail:UpdateStageFightControl() + local stageInfo = XDataCenter.FubenManager.GetStageInfo(self.StageId) + if self.StageFightControl == nil then + self.StageFightControl = XUiStageFightControl.New(self.PanelStageFightControl, self.StageCfg.FightControlId) + end + if not stageInfo.Passed and stageInfo.Unlock then + self.StageFightControl.GameObject:SetActive(true) + self.StageFightControl:UpdateInfo(self.StageCfg.FightControlId) + else + self.StageFightControl.GameObject:SetActive(false) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenDailyBanner/XUiFubenDailyBanner.lua b/Resources/Scripts/XUi/XUiFubenDailyBanner/XUiFubenDailyBanner.lua new file mode 100644 index 00000000..a430bf7b --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenDailyBanner/XUiFubenDailyBanner.lua @@ -0,0 +1,59 @@ +local XUiFubenDailyBanner = XLuaUiManager.Register(XLuaUi, "UiFubenDailyBanner") + +function XUiFubenDailyBanner:OnAwake() + self.DynamicTable = XDynamicTableNormal.New(self.PanelChapterList) + self.DynamicTable:SetProxy(XUiGridDailyBanner) + self.DynamicTable:SetDelegate(self) + self.GridDailyBanner.gameObject:SetActive(false) + self.CurrentSelectIndex = 1 +end + +function XUiFubenDailyBanner:OnStart() + self:SetupDynamicTable() +end + +function XUiFubenDailyBanner:OnEnable() + self:SetupDynamicTable() + self:PlayAnimation("DailyOut") +end + +--动态列表事件 +function XUiFubenDailyBanner:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:UpdateGrid(self.PageDatas[index], self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:UpdateGrid(self.PageDatas[index], self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + self.CurrentSelectIndex = index + self:OnClickChapterGrid(self.PageDatas[index]) + end +end + +--设置动态列表 +function XUiFubenDailyBanner:SetupDynamicTable() + self.PageDatas = XDataCenter.FubenManager.GetDailyDungeonRules() + self.DynamicTable:SetDataSource(self.PageDatas) + self.DynamicTable:ReloadDataSync(self.CurrentSelectIndex) +end + +function XUiFubenDailyBanner:OnClickChapterGrid(chapter) + local tmpDay = XDataCenter.FubenDailyManager.IsDayLock(chapter.Id) + local tmpCon = XDataCenter.FubenDailyManager.GetConditionData(chapter.Id) + local tmpOpen = XDataCenter.FubenDailyManager.GetEventOpen(chapter.Id).IsOpen + + if tmpCon.IsLock then + XUiManager.TipError(XFunctionManager.GetFunctionOpenCondition(tmpCon.functionNameId)) + return + end + if tmpDay and not tmpOpen then + XUiManager.TipError(CS.XTextManager.GetText("FubenDailyOpenHint", + XDataCenter.FubenDailyManager.GetOpenDayString(chapter))) + return + end + + self.ParentUi:PushUi(function() + XLuaUiManager.Open("UiFubenDaily", chapter) + end) + + -- local IsCanOpen = false +end diff --git a/Resources/Scripts/XUi/XUiFubenDailyBanner/XUiFubenDailyBranch.lua b/Resources/Scripts/XUi/XUiFubenDailyBanner/XUiFubenDailyBranch.lua new file mode 100644 index 00000000..2c4f0eae --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenDailyBanner/XUiFubenDailyBranch.lua @@ -0,0 +1,232 @@ +local XUiFubenDailyBranch = XLuaUiManager.Register(XLuaUi, "UiFubenDaily") +local stringGsub = string.gsub +local STAGE_COUNT_MAX = 5 + +function XUiFubenDailyBranch:OnAwake() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self:AutoAddListener() + + self.PaneStageScrollRect = self.PaneStageList.transform:GetComponent(typeof(CS.UnityEngine.UI.ScrollRect)) + self.HorizontalLayoutGroup = self.PanelStageContent.gameObject:GetComponent(typeof(CS.UnityEngine.UI.HorizontalLayoutGroup)) +end + +function XUiFubenDailyBranch:OnStart(Rule) + self.Rule = Rule + self.DungeonId = self.Rule.DungeonOfWeek[XDataCenter.FubenDailyManager.GetNowDayOfWeekByRefreshTime()] + + self.Stage = {} + self.StageObjs = {} +end + +function XUiFubenDailyBranch:OnEnable() + self:InitShop() + self:StageRefresh() + XEventManager.AddEventListener(XEventId.EVENT_AUTO_FIGHT_START, self.OnAutoFightStart, self) +end + +function XUiFubenDailyBranch:InitShop() + self.ShopId = XDailyDungeonConfigs.GetFubenDailyShopId(self.Rule.Id) + self.BtnShop.gameObject:SetActiveEx(self.ShopId > 0) + self.BtnShop:SetName(string.gsub(XShopManager.GetShopTypeDataById(XShopManager.ShopType.FubenDaily).Desc, "\\n", "\n")) -- 海外定制换行修改 + self.BtnShop:ShowReddot(false) + if XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.FubenDailyShop) then + if self.ShopId > 0 then + XShopManager.GetShopInfo(self.ShopId, function() + local shopItemList = XShopManager.GetShopGoodsList(self.ShopId) + XRedPointManager.AddRedPointEvent(self.BtnShop, self.OnCheckShopNew, self, { XRedPointConditions.Types.CONDITION_FUBEN_DAILY_SHOP }, shopItemList) + end) + end + end +end + +function XUiFubenDailyBranch:StageRefresh() + if not self.StageObjs then + return + end + + local dungeoData = XDailyDungeonConfigs.GetDailyDungeonData(self.DungeonId) + local exValue = 0 + self.TxtTitle.text = dungeoData.Name + self.BgCommonBai:SetRawImage(dungeoData.BgImg) + + for i = 1, STAGE_COUNT_MAX do + if not self.StageObjs[i] then + local temp + temp = CS.UnityEngine.Object.Instantiate(self.FubenDailyStageObj) + temp.transform:SetParent(self.PanelStageContent.transform, false) + table.insert(self.StageObjs, temp) + end + self.StageObjs[i].gameObject:SetActive(false) + end + + self.StageCount = 0 + for k, v in pairs(dungeoData.StageId) do + if v ~= 0 then + if not self.Stage[k] then + self.Stage[k] = XUiFubenDailyStage.New(self, self.StageObjs[k], v, exValue, dungeoData, k) + else + self.Stage[k]:ReSetStageCfg() + end + self.Stage[k]:SetCallBack(function(num, IsOpen) + self:StageIconMove(num, IsOpen) + end) + self.StageObjs[k].gameObject:SetActive(true) + + self.StageCount = self.StageCount + 1 + else + self.StageObjs[k].gameObject:SetActive(false) + end + exValue = v + end + + if self.StageCount >= 5 then + self.HorizontalLayoutGroup.padding.left = -960 + self.HorizontalLayoutGroup.spacing = 180 + else + self.HorizontalLayoutGroup.padding.left = -720 + self.HorizontalLayoutGroup.spacing = 230 + end +end + +function XUiFubenDailyBranch:StageIconMove(num, IsOpen) + if IsOpen then + local grid = self.PanelStageContent.transform:GetChild(num - 1) + if grid then + self:PlayScrollViewMove(grid) + end + else + local zeroPos = { 0, 0, 0 } + XUiHelper.DoMove(self.PaneStageList, zeroPos, 0.3, XUiHelper.EaseType.Sin) + end +end + +function XUiFubenDailyBranch:PlayScrollViewMove(grid) + self.PaneStageScrollRect.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Unrestricted + + local gridTf = grid.gameObject:GetComponent("RectTransform") + self.LastContentPosX = self.PanelStageContent.localPosition.x + + local tarPosX = XDataCenter.FubenMainLineManager.UiGridChapterMoveTargetX - gridTf.localPosition.x + local tarPos = self.PanelStageContent.localPosition + tarPos.x = tarPosX + + XLuaUiManager.SetMask(true) + XUiHelper.DoMove(self.PanelStageContent, tarPos, 0.5, XUiHelper.EaseType.Sin, function() + XLuaUiManager.SetMask(false) + end) +end + +function XUiFubenDailyBranch:PlayScrollViewMoveBack(noAnim) + local tarPos = self.PanelStageContent.localPosition + tarPos.x = self.LastContentPosX + + if noAnim then + self.PanelStageContent.localPosition = tarPos + self.PaneStageScrollRect.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Elastic + else + XLuaUiManager.SetMask(true) + XUiHelper.DoMove(self.PanelStageContent, tarPos, 0.3, XUiHelper.EaseType.Sin, function() + self.PaneStageScrollRect.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Elastic + XLuaUiManager.SetMask(false) + end) + end +end + +function XUiFubenDailyBranch:AutoAddListener() + self.BtnBack.CallBack = function(eventData) + self:OnBtnBackClick(eventData) + end + self.BtnMainUi.CallBack = function(eventData) + self:OnBtnMainUiClick(eventData) + end + self.BtnActDesc.CallBack = function(eventData) + self:OnBtnActDescClick(eventData) + end + self.BtnShop.CallBack = function(eventData) + self:OnBtnShopClick(eventData) + end +end + +function XUiFubenDailyBranch:OnBtnBackClick() + self:Close() +end + +function XUiFubenDailyBranch:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiFubenDailyBranch:OnBtnActDescClick() + local dungeoData = XDailyDungeonConfigs.GetDailyDungeonData(self.DungeonId) + local description = stringGsub(dungeoData.Description, "\\n", "\n") + XUiManager.UiFubenDialogTip("", description) +end + +function XUiFubenDailyBranch:OnBtnShopClick() + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.FubenDailyShop) then + return + end + + if not self.ShopId then + return + end + + XShopManager.GetBaseInfo(function() + XShopManager.GetShopInfo(self.ShopId, function() + XLuaUiManager.Open("UiFubenDailyShop", self.ShopId) + end) + end) +end + +function XUiFubenDailyBranch:OnGetEvents() + return { XEventId.EVENT_FUBEN_CLOSE_FUBENSTAGEDETAIL, XEventId.EVENT_FUBEN_ENTERFIGHT, XEventId.EVENT_FUBEN_RESOURCE_AUTOSELECT } +end + +--事件监听 +function XUiFubenDailyBranch:OnNotify(evt, ...) + local args = { ... } + if evt == XEventId.EVENT_FUBEN_ENTERFIGHT then + self:EnterFight(args[1]) + elseif evt == XEventId.EVENT_FUBEN_RESOURCE_AUTOSELECT then + if not self.DungeonId then return end + local stageId = args[1] + local dungeoData = XDailyDungeonConfigs.GetDailyDungeonData(self.DungeonId) + if not dungeoData then return end + + for k, v in pairs(dungeoData.StageId) do + if stageId and v == stageId and self.Stage[k] then + self.Stage[k]:OnBtnEnter() + break + end + end + elseif evt == XEventId.EVENT_FUBEN_CLOSE_FUBENSTAGEDETAIL then + self:PlayScrollViewMoveBack() + end +end + +function XUiFubenDailyBranch:EnterFight(stage) + if XDataCenter.FubenManager.OpenRoomSingle(stage) then + XLuaUiManager.Remove("UiFubenStageDetail") + end +end + +function XUiFubenDailyBranch:ShowPanelAsset(IsShow) + self.PanelAsset.gameObject:SetActiveEx(IsShow) +end + +function XUiFubenDailyBranch:OnCheckShopNew(count) + self.BtnShop:ShowReddot(count >= 0) +end + +function XUiFubenDailyBranch:OnAutoFightStart() + self:PlayScrollViewMoveBack(true) + XLuaUiManager.Remove("UiFubenStageDetail") +end + +function XUiFubenDailyBranch:OnDisable() + XEventManager.RemoveEventListener(XEventId.EVENT_AUTO_FIGHT_START, self.OnAutoFightStart, self) +end + +function XUiFubenDailyBranch:OnDestroy() + self.PaneStageScrollRect = nil + self.HorizontalLayoutGroup = nil +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenDailyBanner/XUiFubenDailyDrop.lua b/Resources/Scripts/XUi/XUiFubenDailyBanner/XUiFubenDailyDrop.lua new file mode 100644 index 00000000..9f4d112d --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenDailyBanner/XUiFubenDailyDrop.lua @@ -0,0 +1,143 @@ +local XUiFubenDailyDrop = XLuaUiManager.Register(XLuaUi, "UiFubenDailyDrop") +local WEEK = 7 +local DROP_VIEW_MAX = 5 +function XUiFubenDailyDrop:OnAwake() + self.DropGroupDatas = {} + self.BtnTabGoList = {} + + self.RandomDorpDynamicTable = XDynamicTableNormal.New(self.RandomDorpList) + self.RandomDorpDynamicTable:SetDynamicEventDelegate(function(event, index, grid) + self:OnRandomDropEvent(event, index, grid) + end) + self.RandomDorpDynamicTable:SetProxy(XUiGridCommon) + self.RandomDorpDynamicTable:SetDelegate(self) + self.RandomDropGrid.gameObject:SetActive(false) + + self.FixedDorpDynamicTable = XDynamicTableNormal.New(self.FixedDorpList) + self.FixedDorpDynamicTable:SetDynamicEventDelegate(function(event, index, grid) + self:OnFixedDropEvent(event, index, grid) + end) + self.FixedDorpDynamicTable:SetProxy(XUiGridCommon) + self.FixedDorpDynamicTable:SetDelegate(self) + self.FixedDropGrid.gameObject:SetActive(false) +end + +function XUiFubenDailyDrop:OnStart(dungeon) + self.Rule = dungeon.Rule + self.DungeonId = dungeon.DungeonId + self.CurSelectIndex = XDataCenter.FubenDailyManager.GetNowDayOfWeekByRefreshTime()--默认选中本日 + self:SetupDynamicTable(false, self.CurSelectIndex); + self:InitTab() +end + +function XUiFubenDailyDrop:OnRandomDropEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + self:InitDropData(grid) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + self:RefreshDropData(true, index, grid) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + self:RefreshDropData(true, index, grid) + end +end + +function XUiFubenDailyDrop:OnFixedDropEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + self:InitDropData(grid) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + self:RefreshDropData(false, index, grid) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + self:RefreshDropData(false, index, grid) + end +end + +function XUiFubenDailyDrop:InitTab() + for i = 1, WEEK do + if not self.BtnTabGoList[i] then + local tempBtnTab + tempBtnTab = CS.UnityEngine.Object.Instantiate(self.BtnDayOfWeek) + tempBtnTab.transform:SetParent(self.BtnDayOfWeekGroup.transform, false) + local uiButton = tempBtnTab:GetComponent("XUiButton") + table.insert(self.BtnTabGoList, uiButton) + end + self.BtnTabGoList[i].gameObject:SetActive(true) + end + + self.BtnDayOfWeekGroup:Init(self.BtnTabGoList, function(index) self:OnSelectedTog(index) end) + self.BtnTanchuangClose.CallBack = function() + self:OnBtnCloseClick() + end + + for k, v in pairs(self.DropGroupDatas) do + self.BtnTabGoList[k]:SetName(v.Remark) + self.BtnTabGoList[k]:SetButtonState(CS.UiButtonState.Normal) + end + + local tmpOpen = XDataCenter.FubenDailyManager.GetEventOpen(self.DungeonId).IsOpen + if not tmpOpen then + for i = 1, WEEK do + if self.Rule.OpenDayOfWeek[i] == 0 then + self.BtnTabGoList[i]:SetButtonState(CS.UiButtonState.Disable) + end + end + end + + self.BtnDayOfWeekGroup:SelectIndex(self.CurSelectIndex); + +end + + + +function XUiFubenDailyDrop:SetupDynamicTable(bReload, dayOfWeek)--设置动态表属性 + self:GetDropGroupList() + self.RandomDropDatas, self.FixedDropDatas = XDataCenter.FubenDailyManager.GetDropDataList(self.DungeonId, dayOfWeek) + + self.RandomDorpDynamicTable:SetDataSource(self.RandomDropDatas) + self.RandomDorpDynamicTable:ReloadDataSync(bReload and 1 or -1) + if #self.RandomDropDatas < DROP_VIEW_MAX then + self.RandomDorpListScroll.enabled = false + else + self.RandomDorpListScroll.enabled = true + end + + self.FixedDorpDynamicTable:SetDataSource(self.FixedDropDatas) + self.FixedDorpDynamicTable:ReloadDataSync(bReload and 1 or -1) + if #self.FixedDropDatas < DROP_VIEW_MAX then + self.FixedDorpListScroll.enabled = false + else + self.FixedDorpListScroll.enabled = true + end +end + + +function XUiFubenDailyDrop:GetDropGroupList()--获取当前副本的掉落组 + local AllGroup = XDailyDungeonConfigs.GetDailyDropGroupList() + for _, v in pairs(AllGroup) do + if v.DungeonId == self.DungeonId then + table.insert(self.DropGroupDatas, v) + end + end +end + + +function XUiFubenDailyDrop:RefreshDropData(isRandom, index, grid)--将动态表内容加载进容器中 + if isRandom then + grid:Refresh(self.RandomDropDatas[index]) + else + grid:Refresh(self.FixedDropDatas[index]) + end +end + +function XUiFubenDailyDrop:InitDropData(grid) + grid:Init(self) +end + +function XUiFubenDailyDrop:OnSelectedTog(index) + if self.BtnTabGoList[index].ButtonState ~= CS.UiButtonState.Disable then + self.CurSelectIndex = index + self:SetupDynamicTable(true, index); + end +end + +function XUiFubenDailyDrop:OnBtnCloseClick() + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenDailyBanner/XUiFubenDailyStage.lua b/Resources/Scripts/XUi/XUiFubenDailyBanner/XUiFubenDailyStage.lua new file mode 100644 index 00000000..3f7e69bd --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenDailyBanner/XUiFubenDailyStage.lua @@ -0,0 +1,115 @@ +XUiFubenDailyStage = XClass(nil, "XUiFubenDailyStage") + +local START_NUM = 1 +local LockType = { + Level = 1, + Stage = 2, + Passed = 3, +} + +function XUiFubenDailyStage:Ctor(base, ui, stageId, exStageId, stageData, num) + self.Base = base + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.StageData = stageData + self.Id = stageId + self.ExId = exStageId + self.num = num + self.RequireLevel = 0 + self.SelectCallBack = {} + self:InitUiObjects() + +end + +function XUiFubenDailyStage:SetCallBack(cb) + self.SelectCallBack = cb +end + +function XUiFubenDailyStage:InitUiObjects() + XTool.InitUiObject(self) + self.BtnEnter.CallBack = function(...) + self:OnBtnEnter(...) + end + self.TxtLevelID.text = self.StageData.Code .. "-" .. self.num + self:ReSetStageCfg() +end + +function XUiFubenDailyStage:ReSetStageCfg() + local stageCfg = XDataCenter.FubenManager.GetStageCfg(self.Id) + self.RImgNodeIco:SetRawImage(stageCfg.Icon) + self.RequireLevel = stageCfg.RequireLevel + self.ConditionIds = self.StageData.ConditionId + self.Islock = false + self.ConditionText = "" + + if stageCfg.RequireLevel > 0 and XPlayer.Level < stageCfg.RequireLevel then + self.Islock = self.Islock or true + self.LockType = LockType.Level + end + + if self.num > START_NUM then + if not XDataCenter.FubenManager.CheckStageIsPass(self.ExId) then + self.LockType = LockType.Passed + self.Islock = self.Islock or true + end + end + + if self.ConditionIds[self.num] ~= 0 then + local ret, desc = XConditionManager.CheckCondition(self.ConditionIds[self.num]) + if not ret then + self.Islock = self.Islock or true + self.LockType = LockType.Stage + self.ConditionText = desc + end + end + + if self.Islock then + self.PanelLock.gameObject:SetActive(true) + else + self.PanelLock.gameObject:SetActive(false) + end + + if XDataCenter.FubenManager.CheckStageIsPass(self.Id) then + self.PanelComplete.gameObject:SetActive(true) + else + self.PanelComplete.gameObject:SetActive(false) + end +end + +function XUiFubenDailyStage:OnBtnEnter() + if not self.Islock then + + if self.SelectCallBack then + self.SelectCallBack(self.num, true) + end + + self.Base:ShowPanelAsset(false) + + local stageCfg = XDataCenter.FubenManager.GetStageCfg(self.Id) + XLuaUiManager.Open("UiFubenStageDetail", stageCfg, function() + self.Base:ShowPanelAsset(true) + -- if self.SelectCallBack then + -- self.SelectCallBack(0, false) + -- end + end) + else + if self.LockType == LockType.Level then + XUiManager.TipError(CS.XTextManager.GetText("BaseEquipNeedLevel", self.RequireLevel)) + end + if self.LockType == LockType.Stage and self.ConditionText ~= "" then + XUiManager.TipError(self.ConditionText) + end + if self.LockType == LockType.Passed then + XUiManager.TipError(CS.XTextManager.GetText("ExploreBuffUnlock", self.StageData.Code .. "-" .. (self.num - 1))) + end + end +end + + +function XUiFubenDailyStage:UpdateStage(Info) + if self.Id == Info.CurStageId then + self.PanelSelect.gameObject:SetActive(true) + else + self.PanelSelect.gameObject:SetActive(false) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenDailyBanner/XUiGridDailyBanner.lua b/Resources/Scripts/XUi/XUiFubenDailyBanner/XUiGridDailyBanner.lua new file mode 100644 index 00000000..d33736e4 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenDailyBanner/XUiGridDailyBanner.lua @@ -0,0 +1,56 @@ +XUiGridDailyBanner = XClass(nil, "XUiGridDailyBanner") + +function XUiGridDailyBanner:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiGridDailyBanner:UpdateGrid(chapter) + self.RImgIcon:SetRawImage(chapter.Icon) + self.TxtName.text = chapter.Title + self.TxtRemainCount.text = "" + self.TxtSimpleDesc.text = chapter.Describe + + local tmpText, IsAllDay = XDataCenter.FubenDailyManager.GetOpenDayString(chapter) + + if IsAllDay then + self.TxtRemainCount.text = tmpText + else + self.TxtRemainCount.text = CS.XTextManager.GetText("FubenDailyOpenRemark", tmpText) + end + + local IsConditionLock = XDataCenter.FubenDailyManager.GetConditionData(chapter.Id).IsLock + local IsDayLock = XDataCenter.FubenDailyManager.IsDayLock(chapter.Id) + local IsEventOpen = XDataCenter.FubenDailyManager.GetEventOpen(chapter.Id).IsOpen + local EventText = XDataCenter.FubenDailyManager.GetEventOpen(chapter.Id).Text + + if IsConditionLock then + self.PanelLock.gameObject:SetActive(true) + self.ImgEvent.gameObject:SetActive(false) + self.TxtLock.text = CS.XTextManager.GetText("NotUnlock") + else + if IsEventOpen then + self.PanelLock.gameObject:SetActive(false) + self.ImgEvent.gameObject:SetActive(true) + self.TxtEvent.text = EventText + else + if IsDayLock then + self.PanelLock.gameObject:SetActive(true) + else + self.PanelLock.gameObject:SetActive(false) + end + self.TxtLock.text = CS.XTextManager.GetText("NotUnlock") + self.ImgEvent.gameObject:SetActive(false) + end + end + + local shopId = XDailyDungeonConfigs.GetFubenDailyShopId(chapter.Id) + self.PanelShopTag.gameObject:SetActiveEx(shopId > 0 and self.PanelLock.gameObject.activeSelf == false) + if shopId > 0 then + local shopName = XShopManager.GetShopTypeDataById(XShopManager.ShopType.FubenDaily).Desc + self.TxtPanelShopTag.text = shopName + end +end + +return XUiGridDailyBanner \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenDailyShop/XUiFubenDailyShop.lua b/Resources/Scripts/XUi/XUiFubenDailyShop/XUiFubenDailyShop.lua new file mode 100644 index 00000000..0c64d571 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenDailyShop/XUiFubenDailyShop.lua @@ -0,0 +1,153 @@ +local XUiFubenDailyShop = XLuaUiManager.Register(XLuaUi, "UiFubenDailyShop") +local SuitIdRecordCache = -1 + +function XUiFubenDailyShop:OnAwake() + self:InitComponent() + self:InitDynamicTable() +end + +function XUiFubenDailyShop:OnStart(shopId) + self.ShopId = shopId + + self.AssetActivityPanel = XUiPanelActivityAsset.New(self.PanelActivityAsset, true) + + self.SuitShopItemDic = {} + self.ShopItemList = XShopManager.GetShopGoodsList(self.ShopId) + for _, v in ipairs(self.ShopItemList) do + local suitId = XDataCenter.EquipManager.GetSuitIdByTemplateId(v.RewardGoods.TemplateId) + if not self.SuitShopItemDic[suitId] then + self.SuitShopItemDic[suitId] = {} + end + table.insert(self.SuitShopItemDic[suitId], v) + end + + local isShopAvailable = #self.ShopItemList > 0 + if isShopAvailable then + self.AssetActivityPanel:Refresh(XShopManager.GetShopShowIdList(shopId)) + local suitId = next(self.SuitShopItemDic) + if SuitIdRecordCache > 0 then + local exist = false + for k, _ in pairs(self.SuitShopItemDic) do + if k == SuitIdRecordCache then + exist = true + break + end + end + self:SelectPage(exist and SuitIdRecordCache or suitId) + else + self:SelectPage(suitId) + end + end + + self.TxtDesc.gameObject:SetActiveEx(not isShopAvailable) + self.WaferNameGroup.gameObject:SetActiveEx(isShopAvailable) + self.PanelActivityAsset.gameObject:SetActiveEx(isShopAvailable) + + XRedPointManager.AddRedPointEvent(self.BtnSwitch, self.OnCheckShopNew, self, { XRedPointConditions.Types.CONDITION_FUBEN_DAILY_SHOP }, self.ShopItemList) +end + +function XUiFubenDailyShop:InitComponent() + self.BtnSwitch.CallBack = function() self:OnBtnSwitchClick() end + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + self.GridShop.gameObject:SetActiveEx(false) +end + +function XUiFubenDailyShop:InitDynamicTable() + self.DynamicShopTable = XDynamicTableNormal.New(self.PanelItemList.gameObject) + self.DynamicShopTable:SetDelegate(self) + self.DynamicShopTable:SetProxy(XUiGridShop) +end + +function XUiFubenDailyShop:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local shopItemList = self.SuitShopItemDic[self.CurSuitId] + local data = shopItemList[index] + if data then + grid:UpdateData(data) + end + end +end + +function XUiFubenDailyShop:UpdateBuy(data, cb) + XLuaUiManager.Open("UiShopItem", self, data, cb) +end + +function XUiFubenDailyShop:RefreshBuy() + local shopItemList = self.SuitShopItemDic[self.CurSuitId] + for index, data in ipairs(shopItemList) do + local grid = self.DynamicShopTable:GetGridByIndex(index) + if grid then + grid:UpdateData(data) + end + end + self:UpdateUI() + self.AssetActivityPanel:Refresh(XShopManager.GetShopShowIdList(self.ShopId)) +end + +function XUiFubenDailyShop:SelectPage(suitId) + self:PlayAnimation("AnimQieHuan") + if suitId then + self.CurSuitId = suitId + XShopManager.GetShopInfo(self.ShopId, function() + self.CurPageShopItemList = self:GetShopItemListBySuitId(suitId) + self:RefreshShopList() + self:UpdateUI() + end) + end +end + +function XUiFubenDailyShop:GetShopItemListBySuitId(suitId) + return self.SuitShopItemDic[suitId] +end + +function XUiFubenDailyShop:RefreshShopList() + self.DynamicShopTable:SetDataSource(self.CurPageShopItemList) + self.DynamicShopTable:ReloadDataASync() +end + +function XUiFubenDailyShop:UpdateUI() + local suitCfg = XEquipConfig.GetEquipSuitCfg(self.CurSuitId) + + if suitCfg == nil then + XLog.Error("suitCfg == nil, suitId = " .. self.CurSuitId) + return + end + + self.WaferNameText.text = suitCfg.Name + self.PropertyText.text = suitCfg.Description + + self.TxtDesc.gameObject:SetActiveEx(#self.ShopItemList == 0) + self.TxtTitle.text = XShopManager.GetShopName(self.ShopId) +end + +function XUiFubenDailyShop:GetCurShopId() + return self.ShopId +end + +function XUiFubenDailyShop:OnCheckShopNew(count) + self.BtnSwitch:ShowReddot(count >= 0) +end + +function XUiFubenDailyShop:OnBtnSwitchClick() + local callBack = function(suitId) + if suitId then + self:SelectPage(suitId) + end + end + XLuaUiManager.Open("UiWaferSelect", self.CurSuitId, self.ShopItemList, self.SuitShopItemDic, callBack) +end + +function XUiFubenDailyShop:OnBtnBackClick() + self:Close() +end + +function XUiFubenDailyShop:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiFubenDailyShop:OnDestroy() + SuitIdRecordCache = self.CurSuitId +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenDailyShop/XUiGridWaferSelect.lua b/Resources/Scripts/XUi/XUiFubenDailyShop/XUiGridWaferSelect.lua new file mode 100644 index 00000000..27d90528 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenDailyShop/XUiGridWaferSelect.lua @@ -0,0 +1,36 @@ +local XUiGridWaferSelect = XClass(nil, "XUiGridWaferSelect") + +function XUiGridWaferSelect:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) +end + +function XUiGridWaferSelect:Init(parent, rootUi) + self.Parent = parent + self.RootUi = rootUi or parent +end + +function XUiGridWaferSelect:Refresh(suitId, isSelected, isNew) + local suitCfg = XEquipConfig.GetEquipSuitCfg(suitId) + + local icon = XDataCenter.EquipManager.GetSuitIconBagPath(suitId) + self.RImgIcon:SetRawImage(icon) + self.RImgIcon.gameObject:SetActive(true) + + self.TxtName.text = suitCfg.Name + self.TxtDes.text = suitCfg.Description + + self.Select.gameObject:SetActiveEx(isSelected) + self.Tag.gameObject:SetActiveEx(isNew) + + --装备专用的竖条品质色 + if self.ImgEquipQuality then + self.RootUi:SetUiSprite(self.ImgEquipQuality, XDataCenter.EquipManager.GetSuitQualityIcon(suitId)) + end + + self.GameObject:SetActiveEx(true) +end + +return XUiGridWaferSelect \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenDailyShop/XUiWaferSelect.lua b/Resources/Scripts/XUi/XUiFubenDailyShop/XUiWaferSelect.lua new file mode 100644 index 00000000..5d774055 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenDailyShop/XUiWaferSelect.lua @@ -0,0 +1,105 @@ +local XUiGridWaferSelect = require("XUi/XUiFubenDailyShop/XUiGridWaferSelect") + +local XUiWaferSelect = XLuaUiManager.Register(XLuaUi, "UiWaferSelect") + +function XUiWaferSelect:OnAwake() + self:InitComponent() + self:InitDynamicTable() +end + +function XUiWaferSelect:OnStart(suitId, ShopItemList, suitShopItemDic, selectCallBack) + if not suitId then + return + end + + self.CurSuitId = suitId + self.ShopItemList = ShopItemList + self.SuitShopItemDic = suitShopItemDic + self.SelectCallBack = selectCallBack + + self.ShopPageList = {} + for k, _ in pairs(suitShopItemDic) do + table.insert(self.ShopPageList, k) + end + + self:UpdateGridList() +end + +function XUiWaferSelect:InitComponent() + self.BtnConfirm.CallBack = function() self:OnBtnConfirmClick() end + self.BtnClose.CallBack = function() self:OnBtnCloseClick() end + self.BtnCancel.CallBack = function() self:OnBtnCloseClick() end + self.BtnTanchuangClose.CallBack = function() self:OnBtnCloseClick() end + + self.GridSuitSimple.gameObject:SetActiveEx(false) +end + +function XUiWaferSelect:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelSelectList.gameObject) + self.DynamicTable:SetDelegate(self) + self.DynamicTable:SetProxy(XUiGridWaferSelect) +end + +function XUiWaferSelect:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local suitId = self.ShopPageList[index] + self:UpdateGrid(grid, suitId) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + local suitId = self.ShopPageList[index] + self:OnGridClick(suitId) + end +end + +function XUiWaferSelect:OnGridClick(suitId) + self.CurSuitId = suitId + for k, v in ipairs(self.ShopPageList) do + local grid = self.DynamicTable:GetGridByIndex(k) + if grid then + self:UpdateGrid(grid, v) + end + end +end + +function XUiWaferSelect:UpdateGrid(grid, suitId) + if suitId then + local isNew = self:CheckIsNew(suitId) + local isSelected = self.CurSuitId == suitId + if isSelected then + if isNew then + XShopManager.SetDailyShopSuitNotNew(suitId) + isNew = false + end + + XEventManager.DispatchEvent(XEventId.EVENT_FUBEN_DAILY_SHOP_CHECK_NEW, self.ShopItemList) + end + grid:Refresh(suitId, isSelected, isNew) + end +end + +function XUiWaferSelect:UpdateGridList() + self.ImgEmpty.gameObject:SetActiveEx(not self.ShopPageList or #self.ShopPageList == 0) + + self.DynamicTable:SetDataSource(self.ShopPageList) + self.DynamicTable:ReloadDataASync() +end + +function XUiWaferSelect:CheckIsNew(suitId) + local suitShopItemList = self.SuitShopItemDic[suitId] + return XShopManager.CheckDailyShopSuitIsNew(suitId, suitShopItemList) +end + +function XUiWaferSelect:OnBtnConfirmClick() + if self.SelectCallBack then + self.SelectCallBack(self.CurSuitId) + end + + self:Close() +end + +function XUiWaferSelect:OnBtnCloseClick() + self:Close() +end + +return XUiWaferSelect \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenDialog/XUiFubenDialog.lua b/Resources/Scripts/XUi/XUiFubenDialog/XUiFubenDialog.lua new file mode 100644 index 00000000..15c5cf18 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenDialog/XUiFubenDialog.lua @@ -0,0 +1,109 @@ +local XUiFubenDialog = XLuaUiManager.Register(XLuaUi, "UiFubenDialog") + +function XUiFubenDialog:OnAwake() + self:InitAutoScript() + self:InitBtnSound() +end + +function XUiFubenDialog:OnStart(title, content, closeCallback, sureCallback) + if title ~= nil and title ~= "" then + self.Txt.text = title + else + self.Txt.text = CS.XTextManager.GetText("FubenDialogTitle") + end + + self.TxtInfo.text = string.gsub(content, "\\n", "\n") + self.OkCallBack = sureCallback + self.CancelCallBack = closeCallback +end + +--初始化音效 +function XUiFubenDialog:InitBtnSound() + self.SpecialSoundMap[self:GetAutoKey(self.BtnClose, "onClick")] = XSoundManager.UiBasicsMusic.Return + self.SpecialSoundMap[self:GetAutoKey(self.BtnConfirm, "onClick")] = XSoundManager.UiBasicsMusic.Confirm +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiFubenDialog:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiFubenDialog:AutoInitUi() + self.PanelDialog = self.Transform:Find("SafeAreaContentPane/PanelDialog") + self.BtnConfirm = self.Transform:Find("SafeAreaContentPane/PanelDialog/BtnConfirm"):GetComponent("Button") + self.BtnClose = self.Transform:Find("SafeAreaContentPane/PanelDialog/BtnClose"):GetComponent("Button") + self.Txt = self.Transform:Find("SafeAreaContentPane/PanelDialog/Txt"):GetComponent("Text") + self.PanelTextList = self.Transform:Find("SafeAreaContentPane/PanelTextList") + self.TxtInfo = self.Transform:Find("SafeAreaContentPane/PanelTextList/Viewport/TxtInfo"):GetComponent("Text") +end + +function XUiFubenDialog:GetAutoKey(uiNode, eventName) + if not uiNode then + return + end + return eventName .. uiNode:GetHashCode() +end + +function XUiFubenDialog:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then + return + end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiFubenDialog:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiFubenDialog:AutoAddListener() + self.AutoCreateListeners = {} + self:RegisterClickEvent(self.BtnConfirm, self.OnBtnConfirmClick) + self:RegisterClickEvent(self.BtnClose, self.OnBtnCloseClick) +end +-- auto +function XUiFubenDialog:OnBtnConfirmClick() + self:OkBtnClick() +end + +function XUiFubenDialog:OnBtnCloseClick() + self:CancelBtnClick() +end + +function XUiFubenDialog:OkBtnClick() + --CS.XUiManager.DialogManager:Pop() + self:Close() + if self.OkCallBack then + self.OkCallBack() + end + + self.OkCallBack = nil + self.CancelCallBack = nil +end + +function XUiFubenDialog:CancelBtnClick() + --CS.XUiManager.DialogManager:Pop() + self:Close() + if self.CancelCallBack and type(self.CancelCallBack) == "function" then + self.CancelCallBack() + end + + self.OkCallBack = nil + self.CancelCallBack = nil +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenExperiment/XUiFubenExperiment.lua b/Resources/Scripts/XUi/XUiFubenExperiment/XUiFubenExperiment.lua new file mode 100644 index 00000000..ff28532c --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenExperiment/XUiFubenExperiment.lua @@ -0,0 +1,232 @@ +local XUiFubenExperiment = XLuaUiManager.Register(XLuaUi, "UiFubenExperiment") +local ParseToTimestamp = XTime.ParseToTimestamp + +function XUiFubenExperiment:OnAwake() + self:AddListener() +end + +function XUiFubenExperiment:OnStart(selectIdx) + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, + XDataCenter.ItemManager.ItemId.FreeGem, + XDataCenter.ItemManager.ItemId.ActionPoint, + XDataCenter.ItemManager.ItemId.Coin) + self.TrialGroup = XDataCenter.FubenExperimentManager.GetShowTrialGroup(function(a, b) + return a.Order < b.Order + end) + self.BtnTabGoList = {} + self.CurSelectIndex = 1 + self.BannerList = {} + self:InitDynamicTable() + self:InitTab(selectIdx) + XEventManager.AddEventListener(XEventId.EVENT_UPDATE_EXPERIMENT, self.UpdateCurBannerState, self) +end + +function XUiFubenExperiment:OnEnable() + self:UpdateLeftTabGroup() + self:UpdateCurBannerState() + self:UpdateToggleRedPoint() +end + +function XUiFubenExperiment:OnDestroy() + XCountDown.RemoveTimer(self.GameObject.name) + XEventManager.RemoveEventListener(XEventId.EVENT_UPDATE_EXPERIMENT, self.UpdateCurBannerState, self) +end + +function XUiFubenExperiment:InitTab(selectIdx) + --CreateGameObject + for i = 1, #self.TrialGroup do + if not self.BtnTabGoList[i] then + local tempBtnTab + if self.TrialGroup[i].SubIndex > 0 then + tempBtnTab = CS.UnityEngine.Object.Instantiate(self.Obj:GetPrefab("BtnTab2")) + else + tempBtnTab = CS.UnityEngine.Object.Instantiate(self.Obj:GetPrefab("BtnTab1")) + end + tempBtnTab.transform:SetParent(self.TabBtnContent, false) + local uiButton = tempBtnTab:GetComponent("XUiButton") + uiButton.SubGroupIndex = self.TrialGroup[i].SubIndex + table.insert(self.BtnTabGoList, uiButton) + end + self.BtnTabGoList[i]:SetName(self.TrialGroup[i].Name) + self.BtnTabGoList[i].gameObject:SetActiveEx(self:CheckTime(i)) + end + + --防止配置的subIndex因为有按钮隐藏指向错误的button,所以重新计算一遍 + local subIndex = 0 + for i = 1, #self.BtnTabGoList do + if self.BtnTabGoList[i].SubGroupIndex > 0 then + self.BtnTabGoList[i].SubGroupIndex = subIndex + else + subIndex = i + end + + end + + for i = #self.BtnTabGoList, #self.TrialGroup + 1, -1 do + CS.UnityEngine.Object.Destroy(self.BtnTabGoList[i].gameObject) + table.remove(self.BtnTabGoList, i) + end + --BtnGroup + self.TabBtnGroup:Init(self.BtnTabGoList, function(index) self:OnSelectedTog(index) end) + --刷新Toggle红点 + self:UpdateToggleRedPoint() + --default select + self.LeftTabScroll.verticalNormalizedPosition = 1 + self.TabBtnGroup:SelectIndex(selectIdx or 1); +end + +function XUiFubenExperiment:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelTaskList) + self.DynamicTable:SetProxy(XUiFubenExperimentBanner) + self.DynamicTable:SetDelegate(self) + self.FubenTriallBanner.gameObject:SetActiveEx(false) +end + +function XUiFubenExperiment:SetupDynamicTable(id, IsTimeIn) + if IsTimeIn then + self.PageDatas = XDataCenter.FubenExperimentManager.GetTrialLevelByGroupID(id) + else + self.PageDatas = {} + end + + self.DynamicTable:SetDataSource(self.PageDatas) + self.DynamicTable:ReloadDataSync(1) +end + +function XUiFubenExperiment:CheckTime(id) + local endTime = XDataCenter.FubenExperimentManager.GetEndTime(id) + if not endTime then + return false + end + if endTime > 0 then + if (endTime == nil) or (endTime - XTime.GetServerNowTimestamp() <= 0) then + return false + end + end + local startTime = XDataCenter.FubenExperimentManager.GetStartTime(id) + if not startTime then + return false + end + if startTime > 0 then + if (startTime == nil) or (startTime - XTime.GetServerNowTimestamp() > 0) then + return false + end + end + return true +end + +function XUiFubenExperiment:SetTime(timestamp) + if not timestamp then return end + local leftTime = timestamp - XTime.GetServerNowTimestamp() + XCountDown.CreateTimer(self.GameObject.name, leftTime) + XCountDown.BindTimer(self.GameObject, self.GameObject.name, function(v) + self.TxtTime.text = CS.XTextManager.GetText("DrawResetTimeShort", XUiHelper.GetTime(v, XUiHelper.TimeFormatType.DRAW)) + end) +end + +function XUiFubenExperiment:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(index, function(idx, curType) + self:OnBannerClick(idx, curType) + end) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:UpdateBanner(self.PageDatas[index]) + end +end + +function XUiFubenExperiment:AddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:RegisterClickEvent(self.BtnActDesc, self.OnBtnActDescClick) +end + +function XUiFubenExperiment:OnBtnActDescClick() + XUiManager.UiFubenDialogTip("", self.TrialGroup[self.CurSelectIndex].Description or "") +end + +function XUiFubenExperiment:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiFubenExperiment:OnBtnBackClick() + self:Close() +end + +function XUiFubenExperiment:OnBannerClick(index, curType) + if curType == XDataCenter.FubenExperimentManager.TrialLevelType.SkinTrial then + XLuaUiManager.Open("UiFubenExperimentSkinTrialDetail", self.PageDatas[index], curType) + else + XLuaUiManager.Open("UiFubenExperimentDetail", self.PageDatas[index], curType) + end + +end + +function XUiFubenExperiment:OnSelectedTog(index) + local endTime = XDataCenter.FubenExperimentManager.GetEndTime(self.TrialGroup[index].Id) + local isTimeIn = false + self.CurSelectIndex = index + + for i = 1, #self.BtnTabGoList do + local tmp = self:CheckTime(i) + if not tmp then self.BtnTabGoList[i].gameObject:SetActiveEx(tmp) end + if i == index then isTimeIn = tmp end + end + + self.PanelTime.gameObject:SetActiveEx(isTimeIn) + if endTime and endTime > 0 then + self:SetTime(endTime) + else + self.PanelTime.gameObject:SetActiveEx(false) + end + + if self.TrialGroup[index].TimeId and self.TrialGroup[index].TimeId > 0 and not XDataCenter.FubenExperimentManager.CheckGroupHasInTimeTask(self.TrialGroup[index].Id) then + self:UpdateLeftTabGroup() + XUiManager.TipText("ActivityBranchNotOpen") + return + end + + self:SetupDynamicTable(self.TrialGroup[index].Id, isTimeIn) + self.TxtModeExplain.text = self.TrialGroup[index].ModeExplainText +end + +function XUiFubenExperiment:UpdateCurBannerState() + self:OnSelectedTog(self.CurSelectIndex) +end + +function XUiFubenExperiment:UpdateToggleRedPoint() + local firstNeedShowRedIndexDic = {} + for index, xBtn in ipairs(self.BtnTabGoList) do -- 先遍历二级toggle + local isShowRed = false + if xBtn.SubGroupIndex and xBtn.SubGroupIndex > 0 then + if XDataCenter.FubenExperimentManager.CheckExperimentGroupHaveRedPoint(self.TrialGroup[index].Id) then + isShowRed = true + firstNeedShowRedIndexDic[xBtn.SubGroupIndex] = true + else + isShowRed = false + end + end + xBtn:ShowReddot(isShowRed) + end + + for index, xBtn in ipairs(self.BtnTabGoList) do -- 一级toggle红点 + if not xBtn.SubGroupIndex or xBtn.SubGroupIndex == 0 then + if firstNeedShowRedIndexDic[index] then + xBtn:ShowReddot(true) + else + xBtn:ShowReddot(XDataCenter.FubenExperimentManager.CheckExperimentGroupHaveRedPoint(self.TrialGroup[index].Id)) --只有一级toggle带关卡也需要检查红点 + end + end + end +end + +function XUiFubenExperiment:UpdateLeftTabGroup() + --返回到试玩区时,如果有时间到的活动隐藏 + for i = 1, #self.TrialGroup do + if self.TrialGroup[i].TimeId and self.TrialGroup[i].TimeId > 0 and not XDataCenter.FubenExperimentManager.CheckGroupHasInTimeTask(self.TrialGroup[i].Id) then + self.BtnTabGoList[i].gameObject:SetActiveEx(false) + if self.CurSelectIndex == i then + self.TabBtnGroup:SelectIndex(self.CurSelectIndex + 1); + end + end + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenExperiment/XUiFubenExperimentBanner.lua b/Resources/Scripts/XUi/XUiFubenExperiment/XUiFubenExperimentBanner.lua new file mode 100644 index 00000000..5789574e --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenExperiment/XUiFubenExperimentBanner.lua @@ -0,0 +1,180 @@ +local CSXTextManagerGetText = CS.XTextManager.GetText + +XUiFubenExperimentBanner = XClass(nil, "XUiFubenExperimentBanner") +local CSXTextManagerGetText = CS.XTextManager.GetText +function XUiFubenExperimentBanner:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.IsLock = false + self.IsShowPass = false + self.LockText = "" +end + +function XUiFubenExperimentBanner:Init(index, callback) + self.Index = index + self.Callback = callback + self:InitUiObjects() + self.TrialLevelInfo = {} +end + +function XUiFubenExperimentBanner:InitUiObjects() + XTool.InitUiObject(self) + self.AutoCreateListeners = {} + XUiHelper.RegisterClickEvent(self, self.BtnModelSwitch, self.OnBtnModelSwitchClick) + XUiHelper.RegisterClickEvent(self, self.BtnEnter, self.OnBtnEnter) +end + +function XUiFubenExperimentBanner:RegisterListener(uiNode, eventName, func) + if not uiNode then return end + local key = eventName .. uiNode:GetHashCode() + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiBtnTab:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiFubenExperimentBanner:OnBtnModelSwitchClick() + if self.TrialLevelInfo.Type == XDataCenter.FubenExperimentManager.TrialLevelType.Switch then + if self.CurType == XDataCenter.FubenExperimentManager.TrialLevelType.Signle then + self.CurType = XDataCenter.FubenExperimentManager.TrialLevelType.Mult + else + self.CurType = XDataCenter.FubenExperimentManager.TrialLevelType.Signle + end + self:UpdateType() + end +end + +function XUiFubenExperimentBanner:OnBtnEnter() + self:CheckLock() + if self.IsLock then + XUiManager.TipError(self.LockText) + return + end + self.Callback(self.Index, self.CurType) +end + +function XUiFubenExperimentBanner:UpdateBanner(trialLevelInfo) + self.TrialLevelInfo = trialLevelInfo + if self.TrialLevelInfo.Type ~= XDataCenter.FubenExperimentManager.TrialLevelType.Switch then + self.BtnModelSwitch.gameObject:SetActiveEx(false) + else + self.BtnModelSwitch.gameObject:SetActiveEx(true) + end + self.TxtLevelName.text = trialLevelInfo.Name + self.CurType = trialLevelInfo.Type + self.Back:SetRawImage(trialLevelInfo.Ico) + self:UpdateType() + self:CheckLock() + self:CheckShowPass() + self:CheckProgress() + self:CheckRedPoint() + self:UpdateTime() +end + +function XUiFubenExperimentBanner:UpdateType() + self.ModelIconSingle.gameObject:SetActiveEx(false) + self.ModelIconTeam.gameObject:SetActiveEx(false) + self.ImageSingle.gameObject:SetActiveEx(false) + self.ImageTeam.gameObject:SetActiveEx(false) + self.PanelImgJindu.gameObject:SetActiveEx(false) + + if self.CurType == XDataCenter.FubenExperimentManager.TrialLevelType.Signle or self.CurType == XDataCenter.FubenExperimentManager.TrialLevelType.SkinTrial then + self.ModelIconSingle.gameObject:SetActiveEx(true) + self.ImageSingle.gameObject:SetActiveEx(true) + else + self.ModelIconTeam.gameObject:SetActiveEx(true) + self.ImageTeam.gameObject:SetActiveEx(true) + end + + if self.TrialLevelInfo.StarReward and self.TrialLevelInfo.StarReward > 0 then + self.PanelImgJindu.gameObject:SetActiveEx(true) + end +end + +function XUiFubenExperimentBanner:CheckLock() + local conditionIds = XDataCenter.FubenExperimentManager.GetStageCondition(self.TrialLevelInfo.Id) + local ret = true + local desc = "" + for _, v in pairs(conditionIds) do + if v ~= 0 then + ret, desc = XConditionManager.CheckCondition(v) + if not ret then + break + end + end + end + self.IsLock = not ret + self.PaenlLock.gameObject:SetActiveEx(not ret) + self.TxtLock.text = desc + self.LockText = desc +end + +function XUiFubenExperimentBanner:CheckShowPass() + if self.TrialLevelInfo.StarReward and self.TrialLevelInfo.StarReward > 0 then + self.PanelUse.gameObject:SetActiveEx(false) + return + end + + local showPass = XDataCenter.FubenExperimentManager.GetStageShowPass(self.TrialLevelInfo.Id) + local finishExperimentIds = XDataCenter.FubenExperimentManager.GetFinishExperimentIds() + self.PanelUse.gameObject:SetActiveEx(false) + + for _, v in pairs(finishExperimentIds) do + if v == self.TrialLevelInfo.Id then + self.PanelUse.gameObject:SetActiveEx(showPass ~= nil and showPass > 0) + end + end +end + +function XUiFubenExperimentBanner:CheckProgress() + if not self.TrialLevelInfo.StarReward or self.TrialLevelInfo.StarReward == 0 then + return + end + + local curStarNum, maxStarNum = XDataCenter.FubenExperimentManager.GetExperimentStarProgressById(self.TrialLevelInfo.Id) + self.ImgPercent.fillAmount = curStarNum / maxStarNum + self.TxtPercentNormal.text = CSXTextManagerGetText("FuBenExperimentProgress", curStarNum, maxStarNum) +end + +function XUiFubenExperimentBanner:CheckRedPoint() + if self.RedPoint then + self.RedPoint.gameObject:SetActiveEx(false) + if self.TrialLevelInfo then + if self.RedPointId then + XRedPointManager.RemoveRedPointEvent(self.RedPointId) + end + self.RedPointId = XRedPointManager.AddRedPointEvent(self.RedPoint, self.OnCheckRedPoint, self, { XRedPointConditions.Types.CONDITION_EXPERIMENT_CHAPTER_REWARD }, self.TrialLevelInfo, true) + end + end +end + +function XUiFubenExperimentBanner:OnCheckRedPoint(count) + self.RedPoint.gameObject:SetActiveEx(count >= 0) +end + +function XUiFubenExperimentBanner:UpdateTime() + if self.TxtTime then + local isVisible = XFunctionManager.CheckInTimeByTimeId(self.TrialLevelInfo.TimeId) + self.TxtTime.gameObject:SetActiveEx(isVisible) + if isVisible then + local nowTime = XTime.GetServerNowTimestamp() + local endTime = XFunctionManager.GetEndTimeByTimeId(self.TrialLevelInfo.TimeId) + local timeStr = XUiHelper.GetTime(endTime- nowTime, XUiHelper.TimeFormatType.ACTIVITY) + local text = CSXTextManagerGetText("ActivityBriefLeftTime", timeStr) + self.TxtTime.text = text + end + end +end diff --git a/Resources/Scripts/XUi/XUiFubenExperiment/XUiFubenExperimentDetail.lua b/Resources/Scripts/XUi/XUiFubenExperiment/XUiFubenExperimentDetail.lua new file mode 100644 index 00000000..9d5aec12 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenExperiment/XUiFubenExperimentDetail.lua @@ -0,0 +1,330 @@ +local XUiFubenExperimentDetail = XLuaUiManager.Register(XLuaUi, "UiFubenExperimentDetail") + +local UiState = +{ + Normal = 1, + SkillExplain = 2, +} + +local XUiFubenExperimentGridStar = require("XUi/XUiFubenExperiment/XUiFubenExperimentGridStar") + +function XUiFubenExperimentDetail:OnAwake() + self:AutoSetGameObject() + self:AddListener() +end + +function XUiFubenExperimentDetail:OnStart(trialLevelInfo, curType) + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, + XDataCenter.ItemManager.ItemId.FreeGem, + XDataCenter.ItemManager.ItemId.ActionPoint, + XDataCenter.ItemManager.ItemId.Coin) + self.TrialLevelInfo = trialLevelInfo + XDataCenter.FubenExperimentManager.SetCurExperimentLevelId(self.TrialLevelInfo.Id) + + if self.TrialLevelInfo.Type ~= XDataCenter.FubenExperimentManager.TrialLevelType.Switch then + self.BtnSingle.gameObject:SetActive(false) + self.BtnMult.gameObject:SetActive(false) + if curType == XDataCenter.FubenExperimentManager.TrialLevelType.Mult then + self.MultStageCfg = XDataCenter.FubenManager.GetStageCfg(self.TrialLevelInfo.MultStageId) + end + else + self.MultStageCfg = XDataCenter.FubenManager.GetStageCfg(self.TrialLevelInfo.MultStageId) + end + self.CurUiState = UiState.Normal + self.BtnHelp.gameObject:SetActiveEx(self.TrialLevelInfo.HelpCourseId ~= 0) + self.PanelSkillInformation.gameObject:SetActiveEx(false) + + if self.TrialLevelInfo.HeadIcon then + self.RImgNandu:SetRawImage(self.TrialLevelInfo.HeadIcon) + end + + XEventManager.AddEventListener(XEventId.EVENT_ROOM_CANCEL_MATCH, self.OnCancelMatch, self) + self.CurType = curType + self:UpdateInfo() + self:UpdateMode() + self:InitBossSkillInfo() +end + +function XUiFubenExperimentDetail:OnEnable() + self.BtnQuickMatch:SetDisable(false) + self:UpdatePanelStarReward() +end + +function XUiFubenExperimentDetail:OnDestroy() + XEventManager.RemoveEventListener(XEventId.EVENT_ROOM_CANCEL_MATCH, self.OnCancelMatch, self) +end + +function XUiFubenExperimentDetail:OnGetEvents() + return { + XEventId.EVENT_EXPERIMENT_GET_STAR_REWARD, + } +end + +function XUiFubenExperimentDetail:OnNotify(evt, ...) + if evt == XEventId.EVENT_EXPERIMENT_GET_STAR_REWARD then + self:UpdatePanelStarReward() + end +end + +function XUiFubenExperimentDetail:AddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:RegisterClickEvent(self.BtnSingle, self.OnBtnSingleClick) + self:RegisterClickEvent(self.BtnSingleEnter, self.OnBtnSingleEnterClick) + self:RegisterClickEvent(self.BtnMult, self.OnBtnMultClick) + self:RegisterClickEvent(self.BtnMultCreateRoom, self.OnBtnMultCreateRoomClick) + self:RegisterClickEvent(self.BtnQuickMatch, self.OnBtnQuickMatchClick) + self.BtnHelp.CallBack = function() + self:OnBtnHelpClick() + end + self:BindHelpBtnOnly(self.BtnHelp) + self.BtnBossInfo.CallBack = function() + self:OnBtnBossInfoClick() + end + for i=1, #self.GridStarCommonTable, 1 do + self.GridStarCommonTable[i].BtnGet.CallBack = function () + self:OnClickGetBtnStarReward(i) + end + end +end + +function XUiFubenExperimentDetail:AutoSetGameObject() + self.GridStageStarTable = {} + for i=0, self.PanelTargetList.childCount - 1, 1 do + table.insert(self.GridStageStarTable, XUiFubenExperimentGridStar.New(self.PanelTargetList:GetChild(i))) + end + + self.GridStarCommonTable = {} + for i=1, 3, 1 do + local panelGridCommon = self.PanelDrop:Find("PanelGridCommon"..i) + table.insert(self.GridStarCommonTable, + { PanelGridCommon = panelGridCommon, + GridCommon = XUiGridCommon.New(self, panelGridCommon:Find("GridCommon")), + Effect = panelGridCommon:Find("PanelEffect"), + BtnGet = panelGridCommon:Find("BtnGet"):GetComponent("XUiButton")}) + end +end + +--初始化技能介绍 +function XUiFubenExperimentDetail:InitBossSkillInfo() + self.PanelTxtDes.gameObject:SetActiveEx(false) + + if self.TrialLevelInfo.SkillExplainId ~= 0 then + --是否显示技能按钮 + self.BtnBossInfo.gameObject:SetActiveEx(true) + + self.SkillDescDatas = XFubenExperimentConfigs.GetExperimentSkillExplainById(self.TrialLevelInfo.SkillExplainId) + if self.SkillDescDatas and self.SkillDescDatas.SkillTitle then + for i = 1, #self.SkillDescDatas.SkillTitle do + local go = CS.UnityEngine.Object.Instantiate(self.PanelTxtDes, self.PanelContent) + local tmpObj = {} + tmpObj.Transform = go.transform + tmpObj.GameObject = go.gameObject + XTool.InitUiObject(tmpObj) + tmpObj.TxtRuleTittle.text = self.SkillDescDatas.SkillTitle[i] + tmpObj.TxtRule.text = self.SkillDescDatas.SkillDesc[i] + tmpObj.GameObject:SetActiveEx(true) + end + end + else + self.BtnBossInfo.gameObject:SetActiveEx(false) + end +end + +function XUiFubenExperimentDetail:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiFubenExperimentDetail:OnBtnBackClick() + if self.CurUiState == UiState.SkillExplain then + self.CurUiState = UiState.Normal + self.BtnBossInfo.gameObject:SetActiveEx(true) + self:UpdateMode() + --播放动画 + XLuaUiManager.SetMask(true) + self:PlayAnimation("PanelSkillInformationDisable", function() + self:PlayAnimation("AnimEnable", function() + XLuaUiManager.SetMask(false) + end) + end) + return + end + local title = CS.XTextManager.GetText("TipTitle") + local cancelMatchMsg = CS.XTextManager.GetText("OnlineInstanceCancelMatch") + if XDataCenter.RoomManager.Matching then + XUiManager.DialogTip(title, cancelMatchMsg, XUiManager.DialogType.Normal, nil, function() + XDataCenter.RoomManager.CancelMatch(function() + self:Close() + end) + end) + else + self:Close() + end +end + +function XUiFubenExperimentDetail:OnBtnSingleClick() + self:OnSwitchButton() +end + +function XUiFubenExperimentDetail:OnBtnSingleEnterClick() + if self.TrialLevelInfo.TimeId and self.TrialLevelInfo.TimeId ~= 0 then + if XFunctionManager.CheckInTimeByTimeId(self.TrialLevelInfo.TimeId) then + XLuaUiManager.Open("UiNewRoomSingle", self.TrialLevelInfo.SingStageId) + else + XUiManager.TipText("ActivityBranchNotOpen") + end + else + XLuaUiManager.Open("UiNewRoomSingle", self.TrialLevelInfo.SingStageId) + end +end + +function XUiFubenExperimentDetail:OnBtnMultClick() + self:OnSwitchButton() +end + +function XUiFubenExperimentDetail:OnBtnMultCreateRoomClick() + XDataCenter.FubenManager.RequestCreateRoom(self.MultStageCfg) +end + +function XUiFubenExperimentDetail:OnBtnQuickMatchClick() + if XDataCenter.RoomManager.Matching then + return + end + + XDataCenter.FubenManager.RequestMatchRoom(self.MultStageCfg, function()--匹配房间 + self:RefreshMatching() + self.BtnQuickMatch:SetDisable(true) + end) +end + +--打开图文面板 +function XUiFubenExperimentDetail:OnBtnHelpClick() + local template = XHelpCourseConfig.GetHelpCourseTemplateById(self.TrialLevelInfo.HelpCourseId) + XUiManager.ShowHelpTip(template.Function) +end + +function XUiFubenExperimentDetail:OnBtnBossInfoClick() + self.CurUiState = UiState.SkillExplain + + self.BtnBossInfo.gameObject:SetActiveEx(false) + self.PanelSingle.gameObject:SetActive(false) + self.PanelTeam.gameObject:SetActive(false) + --播放动画 + XLuaUiManager.SetMask(true) + self:PlayAnimation("PanelInformationDisable", function() + self.PanelSkillInformation.gameObject:SetActiveEx(true) + self:PlayAnimation("PanelSkillInformationEnable", function() + XLuaUiManager.SetMask(false) + end) + end) + +end + +function XUiFubenExperimentDetail:OnCancelMatch() + self.BtnQuickMatch:SetDisable(false) +end + +function XUiFubenExperimentDetail:RefreshMatching() + if XDataCenter.RoomManager.Matching then + XLuaUiManager.Open("UiOnLineMatching", self.MultStageCfg) + end +end + +function XUiFubenExperimentDetail:OnSwitchButton() + XDataCenter.RoomManager.CancelMatch() -- 切换模式先取消匹配 + if self.TrialLevelInfo.Type == XDataCenter.FubenExperimentManager.TrialLevelType.Switch then + if self.CurType == XDataCenter.FubenExperimentManager.TrialLevelType.Signle then + self.CurType = XDataCenter.FubenExperimentManager.TrialLevelType.Mult + else + self.CurType = XDataCenter.FubenExperimentManager.TrialLevelType.Signle + end + end + self:UpdateMode() + self:UpdateDes() +end + +function XUiFubenExperimentDetail:UpdateMode() + if self.CurType == XDataCenter.FubenExperimentManager.TrialLevelType.Signle or self.CurType == XDataCenter.FubenExperimentManager.TrialLevelType.SkinTrial then + self.PanelSingle.gameObject:SetActive(true) + self.PanelTeam.gameObject:SetActive(false) + else + self.PanelSingle.gameObject:SetActive(false) + self.PanelTeam.gameObject:SetActive(true) + end +end + +function XUiFubenExperimentDetail:UpdateInfo() + self.TxtTitle.text = self.TrialLevelInfo.Name + self.TxtRecommendLevel.text = self.TrialLevelInfo.RecommendLevel + self.ImgFullScreen:SetRawImage(self.TrialLevelInfo.DetailBackGroundIco) + if self.TrialLevelInfo.StarReward and self.TrialLevelInfo.StarReward > 0 then -- 带有目标奖励的试玩关 + self.PanelJindu.gameObject:SetActiveEx(true) + self.PanelNor.gameObject:SetActiveEx(false) + + self:UpdatePanelStarReward() + else + self.PanelJindu.gameObject:SetActiveEx(false) + self.PanelNor.gameObject:SetActiveEx(true) + end + self:UpdateDes() +end + +function XUiFubenExperimentDetail:UpdateDes() + if self.CurType == XDataCenter.FubenExperimentManager.TrialLevelType.Signle or self.CurType == XDataCenter.FubenExperimentManager.TrialLevelType.SkinTrial then + self.TxtDes.text = string.gsub(self.TrialLevelInfo.SingleDescription, "\\n", "\n") + else + self.TxtDes.text = string.gsub(self.TrialLevelInfo.MultDescription, "\\n", "\n") + end +end + +function XUiFubenExperimentDetail:UpdatePanelStarReward() + if not self.TrialLevelInfo.StarReward or self.TrialLevelInfo.StarReward <= 0 then + return + end + + local StarDescList = self.TrialLevelInfo.StarDesc + for i, gridStageStar in ipairs(self.GridStageStarTable) do + if StarDescList[i] then + gridStageStar.GameObject:SetActiveEx(true) + gridStageStar:SetDesc(StarDescList[i]) + gridStageStar:SetActiveEx(XDataCenter.FubenExperimentManager.CheckTargetComplete(self.TrialLevelInfo.Id, i)) + else + gridStageStar.GameObject:SetActiveEx(false) + end + end + + local curStarNum, maxStarNum = XDataCenter.FubenExperimentManager.GetExperimentStarProgressById(self.TrialLevelInfo.Id) + self.ImgProgress.fillAmount = curStarNum / maxStarNum + local trialRewardCfg = XFubenExperimentConfigs.GetTrialStarRewardCfgById(self.TrialLevelInfo.StarReward) + local rewardIdList = trialRewardCfg.RewardId + for i, PanelStarCommon in ipairs(self.GridStarCommonTable) do + if rewardIdList[i] then + PanelStarCommon.PanelGridCommon.gameObject:SetActiveEx(true) + local rewardItemId = XRewardManager.GetRewardList(rewardIdList[i])[1] + PanelStarCommon.GridCommon:Refresh(rewardItemId) + local isResived = XDataCenter.FubenExperimentManager.CheckExperimentRewardIsTaked(self.TrialLevelInfo.Id, i) + if isResived then -- 已领取 + PanelStarCommon.GridCommon:SetReceived(true) + PanelStarCommon.Effect.gameObject:SetActiveEx(false) + PanelStarCommon.BtnGet.gameObject:SetActiveEx(true) + else + local isCanResive = XDataCenter.FubenExperimentManager.CheckExperimentRewardIsCanTake(self.TrialLevelInfo.Id, i) + if isCanResive then + PanelStarCommon.GridCommon:SetReceived(false) + PanelStarCommon.Effect.gameObject:SetActiveEx(true) + PanelStarCommon.BtnGet.gameObject:SetActiveEx(true) + else + PanelStarCommon.GridCommon:SetReceived(false) + PanelStarCommon.Effect.gameObject:SetActiveEx(false) + PanelStarCommon.BtnGet.gameObject:SetActiveEx(false) + end + end + else + PanelStarCommon.PanelGridCommon.gameObject:SetActiveEx(false) + end + end +end + +function XUiFubenExperimentDetail:OnClickGetBtnStarReward(index) + XDataCenter.FubenExperimentManager.GetStarReward(self.TrialLevelInfo.Id, index) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenExperiment/XUiFubenExperimentGridStar.lua b/Resources/Scripts/XUi/XUiFubenExperiment/XUiFubenExperimentGridStar.lua new file mode 100644 index 00000000..5d2b165e --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenExperiment/XUiFubenExperimentGridStar.lua @@ -0,0 +1,25 @@ +local CSXTextManagerGetText = CS.XTextManager.GetText + +local XUiFubenExperimentGridStar = XClass(nil, "XUiFubenExperimentGridStar") +function XUiFubenExperimentGridStar:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + self:Init() +end + +function XUiFubenExperimentGridStar:Init() + XTool.InitUiObject(self) +end + +function XUiFubenExperimentGridStar:SetDesc(desc) + self.TxtUnActive.text = desc + self.TxtActive.text = desc +end + +function XUiFubenExperimentGridStar:SetActiveEx(active) + self.PanelActive.gameObject:SetActiveEx(active) + self.PanelUnActive.gameObject:SetActiveEx(not active) +end + +return XUiFubenExperimentGridStar \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenExperiment/XUiFubenExperimentSkinTrialDetail.lua b/Resources/Scripts/XUi/XUiFubenExperiment/XUiFubenExperimentSkinTrialDetail.lua new file mode 100644 index 00000000..321912ff --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenExperiment/XUiFubenExperimentSkinTrialDetail.lua @@ -0,0 +1,213 @@ +local XUiFubenExperimentSkinTrialDetail = XLuaUiManager.Register(XLuaUi, "UiFubenExperimentSkinTrialDetail") + +local XUiFubenExperimentGridStar = require("XUi/XUiFubenExperiment/XUiFubenExperimentGridStar") + +function XUiFubenExperimentSkinTrialDetail:OnAwake() + self:AddListener() +end + +function XUiFubenExperimentSkinTrialDetail:OnStart(trialLevelInfo, curType) + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, + XDataCenter.ItemManager.ItemId.FreeGem, + XDataCenter.ItemManager.ItemId.ActionPoint, + XDataCenter.ItemManager.ItemId.Coin) + self.TrialLevelInfo = trialLevelInfo + self.RewardPanelList = {} + XDataCenter.FubenExperimentManager.SetCurExperimentLevelId(self.TrialLevelInfo.Id) + + if self.TrialLevelInfo.Type ~= XDataCenter.FubenExperimentManager.TrialLevelType.Switch then + self.BtnSingle.gameObject:SetActive(false) + self.BtnMult.gameObject:SetActive(false) + if curType == XDataCenter.FubenExperimentManager.TrialLevelType.Mult then + self.MultStageCfg = XDataCenter.FubenManager.GetStageCfg(self.TrialLevelInfo.MultStageId) + end + else + self.MultStageCfg = XDataCenter.FubenManager.GetStageCfg(self.TrialLevelInfo.MultStageId) + end + self.BtnHelp.gameObject:SetActiveEx(self.TrialLevelInfo.HelpCourseId ~= 0) + + if self.TrialLevelInfo.HeadIcon then + self.RImgNandu:SetRawImage(self.TrialLevelInfo.HeadIcon) + end + + XEventManager.AddEventListener(XEventId.EVENT_ROOM_CANCEL_MATCH, self.OnCancelMatch, self) + self.CurType = curType + self:UpdateInfo() + self:UpdateMode() +end + +function XUiFubenExperimentSkinTrialDetail:OnEnable() + self:UpdateFirstReward() + self.BtnQuickMatch:SetDisable(false) +end + +function XUiFubenExperimentSkinTrialDetail:OnDestroy() + XEventManager.RemoveEventListener(XEventId.EVENT_ROOM_CANCEL_MATCH, self.OnCancelMatch, self) +end + +function XUiFubenExperimentSkinTrialDetail:AddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:RegisterClickEvent(self.BtnSingle, self.OnBtnSingleClick) + self:RegisterClickEvent(self.BtnSingleEnter, self.OnBtnSingleEnterClick) + self:RegisterClickEvent(self.BtnMult, self.OnBtnMultClick) + self:RegisterClickEvent(self.BtnMultCreateRoom, self.OnBtnMultCreateRoomClick) + self:RegisterClickEvent(self.BtnQuickMatch, self.OnBtnQuickMatchClick) + self.BtnHelp.CallBack = function() + self:OnBtnHelpClick() + end + self:BindHelpBtnOnly(self.BtnHelp) +end + +function XUiFubenExperimentSkinTrialDetail:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiFubenExperimentSkinTrialDetail:OnBtnBackClick() + local title = CS.XTextManager.GetText("TipTitle") + local cancelMatchMsg = CS.XTextManager.GetText("OnlineInstanceCancelMatch") + if XDataCenter.RoomManager.Matching then + XUiManager.DialogTip(title, cancelMatchMsg, XUiManager.DialogType.Normal, nil, function() + XDataCenter.RoomManager.CancelMatch(function() + self:Close() + end) + end) + else + self:Close() + end +end + +function XUiFubenExperimentSkinTrialDetail:OnBtnSingleClick() + self:OnSwitchButton() +end + +function XUiFubenExperimentSkinTrialDetail:OnBtnSingleEnterClick() + if self.TrialLevelInfo.TimeId and self.TrialLevelInfo.TimeId ~= 0 then + if XFunctionManager.CheckInTimeByTimeId(self.TrialLevelInfo.TimeId) then + XLuaUiManager.Open("UiNewRoomSingle", self.TrialLevelInfo.SingStageId) + else + XUiManager.TipText("ActivityBranchNotOpen") + end + else + XLuaUiManager.Open("UiNewRoomSingle", self.TrialLevelInfo.SingStageId) + end +end + +function XUiFubenExperimentSkinTrialDetail:OnBtnMultClick() + self:OnSwitchButton() +end + +function XUiFubenExperimentSkinTrialDetail:OnBtnMultCreateRoomClick() + XDataCenter.FubenManager.RequestCreateRoom(self.MultStageCfg) +end + +function XUiFubenExperimentSkinTrialDetail:OnBtnQuickMatchClick() + if XDataCenter.RoomManager.Matching then + return + end + + XDataCenter.FubenManager.RequestMatchRoom(self.MultStageCfg, function()--匹配房间 + self:RefreshMatching() + self.BtnQuickMatch:SetDisable(true) + end) +end + +--打开图文面板 +function XUiFubenExperimentSkinTrialDetail:OnBtnHelpClick() + local template = XHelpCourseConfig.GetHelpCourseTemplateById(self.TrialLevelInfo.HelpCourseId) + XUiManager.ShowHelpTip(template.Function) +end + +function XUiFubenExperimentSkinTrialDetail:OnCancelMatch() + self.BtnQuickMatch:SetDisable(false) +end + +function XUiFubenExperimentSkinTrialDetail:RefreshMatching() + if XDataCenter.RoomManager.Matching then + XLuaUiManager.Open("UiOnLineMatching", self.MultStageCfg) + end +end + +function XUiFubenExperimentSkinTrialDetail:OnSwitchButton() + if self.TrialLevelInfo.Type == XDataCenter.FubenExperimentManager.TrialLevelType.Switch then + if self.CurType == XDataCenter.FubenExperimentManager.TrialLevelType.Signle then + self.CurType = XDataCenter.FubenExperimentManager.TrialLevelType.Mult + else + self.CurType = XDataCenter.FubenExperimentManager.TrialLevelType.Signle + end + end + self:UpdateMode() + self:UpdateDes() +end + +function XUiFubenExperimentSkinTrialDetail:UpdateMode() + if self.CurType == XDataCenter.FubenExperimentManager.TrialLevelType.Signle or self.CurType == XDataCenter.FubenExperimentManager.TrialLevelType.SkinTrial then + self.PanelSingle.gameObject:SetActive(true) + self.PanelTeam.gameObject:SetActive(false) + else + self.PanelSingle.gameObject:SetActive(false) + self.PanelTeam.gameObject:SetActive(true) + end +end + +function XUiFubenExperimentSkinTrialDetail:UpdateInfo() + self.TxtTitle.text = self.TrialLevelInfo.Name + self.TxtRecommendLevel.text = self.TrialLevelInfo.RecommendLevel + if self.TrialLevelInfo.SpinePath and self.PanelSpine then + self.PanelSpine.gameObject:LoadSpinePrefab(self.TrialLevelInfo.SpinePath) + else + self.ImgFullScreen.gameObject:SetActiveEx(true) + if self.TrialLevelInfo.DetailBackGroundIco then + self.ImgFullScreen:SetRawImage(self.TrialLevelInfo.DetailBackGroundIco) + end + end + if self.TrialLevelInfo.StarReward and self.TrialLevelInfo.StarReward > 0 then -- 带有目标奖励的试玩关 + self.PanelNor.gameObject:SetActiveEx(false) + else + self.PanelNor.gameObject:SetActiveEx(true) + end + self:UpdateDes() +end + +function XUiFubenExperimentSkinTrialDetail:UpdateDes() + if self.CurType == XDataCenter.FubenExperimentManager.TrialLevelType.Signle or self.CurType == XDataCenter.FubenExperimentManager.TrialLevelType.SkinTrial then + self.TxtDes.text = string.gsub(self.TrialLevelInfo.SingleDescription, "\\n", "\n") + else + self.TxtDes.text = string.gsub(self.TrialLevelInfo.MultDescription, "\\n", "\n") + end +end + +function XUiFubenExperimentSkinTrialDetail:UpdateFirstReward() + local stage = XDataCenter.FubenManager.GetStageCfg(self.TrialLevelInfo.SingStageId) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(self.TrialLevelInfo.SingStageId) + local rewardId = 0 + local IsFirst = false + for i = 1, #self.RewardPanelList do + self.RewardPanelList[i]:Refresh() + end + rewardId = stage.FirstRewardShow + if not stageInfo.Passed then + IsFirst = true + end + + if not rewardId or rewardId == 0 then + return + end + + local rewardsList = XRewardManager.GetRewardList(rewardId) + if not rewardsList then return end + + for i = 1, #rewardsList do + local panel = self.RewardPanelList[i] + if not panel then + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommon) + ui.transform:SetParent(self.PanelDropContent, false) + panel = XUiGridCommon.New(self, ui) + table.insert(self.RewardPanelList, panel) + end + local temp = { + ShowReceived = not IsFirst + } + panel:Refresh(rewardsList[i], temp) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenExplore/XUiFubenExploreBuff.lua b/Resources/Scripts/XUi/XUiFubenExplore/XUiFubenExploreBuff.lua new file mode 100644 index 00000000..602a5533 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenExplore/XUiFubenExploreBuff.lua @@ -0,0 +1,33 @@ +XUiFubenExploreBuff = XClass(nil, "XUiFubenExploreBuff") +function XUiFubenExploreBuff:Ctor(ui, buffInfo) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.BuffInfo = buffInfo + self.IsUnlock = XDataCenter.FubenExploreManager.IsBuffUnlock(buffInfo) + self:InitUiObjects() + self:Update(self.BuffInfo, true) +end + +function XUiFubenExploreBuff:InitUiObjects() + XTool.InitUiObject(self) +end + +function XUiFubenExploreBuff:Update(buffInfo, isInit) + local isUnlock = XDataCenter.FubenExploreManager.IsBuffUnlock(buffInfo) + local unLockProgress = XDataCenter.FubenExploreManager.GetBuffUnlockProgress(buffInfo) + if isUnlock then + if isInit == nil and isUnlock ~= self.IsUnlock then + self.IsUnlock = isUnlock + self.FxUiTanSuoUnlock.gameObject:SetActive(true) + else + self.FxUiTanSuoUnlock.gameObject:SetActive(false) + end + self.Ico:SetRawImage(buffInfo.Icon) + self.Ico.gameObject:SetActive(true) + self.Lock.gameObject:SetActive(false) + else + self.Ico.gameObject:SetActive(false) + self.Lock.gameObject:SetActive(true) + self.ImgProgress.fillAmount = unLockProgress + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenExplore/XUiFubenExploreBuffDetail.lua b/Resources/Scripts/XUi/XUiFubenExplore/XUiFubenExploreBuffDetail.lua new file mode 100644 index 00000000..41098223 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenExplore/XUiFubenExploreBuffDetail.lua @@ -0,0 +1,47 @@ +XUiFubenExploreBuffDetail = XClass(nil, "XUiFubenExploreBuffDetail") +function XUiFubenExploreBuffDetail:Ctor(ui, buffInfo) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.BuffInfo = buffInfo + self:InitUiObjects() + self.UnlockColor = self.TxtLock.color + self:Update(self.BuffInfo) +end + +function XUiFubenExploreBuffDetail:InitUiObjects() + XTool.InitUiObject(self) +end + +function XUiFubenExploreBuffDetail:Update(buffInfo) + local isUnlock = true + for i = 1, #buffInfo.UnlockEvent do + if i == 1 then + if not XDataCenter.FubenExploreManager.IsBuffUnlockEvent(buffInfo, buffInfo.UnlockEvent[i]) then + isUnlock = false + self.TxtLock.color = CS.UnityEngine.Color.white + else + self.TxtLock.color = self.UnlockColor + end + elseif i == 2 then + if not XDataCenter.FubenExploreManager.IsBuffUnlockEvent(buffInfo, buffInfo.UnlockEvent[i]) then + isUnlock = false + self.TxtLock2.color = CS.UnityEngine.Color.white + else + self.TxtLock2.color = self.UnlockColor + end + end + end + + if isUnlock then + self.Normal.gameObject:SetActive(true) + self.Lock.gameObject:SetActive(false) + else + self.Normal.gameObject:SetActive(false) + self.Lock.gameObject:SetActive(true) + end + self.ImgIco:SetRawImage(buffInfo.Icon) + self.TxtName.text = buffInfo.BuffName + self.TxtDis.text = buffInfo.Explain + self.TxtLock.text = buffInfo.GainDesc[1] + self.TxtLock2.text = buffInfo.GainDesc[2] +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenExplore/XUiFubenExploreChapter.lua b/Resources/Scripts/XUi/XUiFubenExplore/XUiFubenExploreChapter.lua new file mode 100644 index 00000000..3b33ae9d --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenExplore/XUiFubenExploreChapter.lua @@ -0,0 +1,143 @@ +local XUiFubenExploreChapter = XLuaUiManager.Register(XLuaUi, "UiFubenExploreChapter") +function XUiFubenExploreChapter:OnAwake() + self.CurChapterId = 0 + self.GridRecordList = {} + self.ChapterTabBtnList = {} + self.AnimQieHuanGo = self:FindGameObject("AnimQieHuan") + self:AddListener() + self:InitTabBtn() + self.TabBtnGroup:SelectIndex(XDataCenter.FubenExploreManager.GetNewestChapterId()) +end + +function XUiFubenExploreChapter:OnStart() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, + XDataCenter.ItemManager.ItemId.FreeGem, + XDataCenter.ItemManager.ItemId.ActionPoint, + XDataCenter.ItemManager.ItemId.Coin) +end + +function XUiFubenExploreChapter:OnEnable() + self:InitTabBtn() + local chapterId = XDataCenter.FubenExploreManager.GetNewestChapterId() + if chapterId ~= nil then + self.TabBtnGroup:SelectIndex(chapterId) + else + self.TabBtnGroup:SelectIndex(1) + end +end + +function XUiFubenExploreChapter:UpdateInfo() + self.TxtTitle.text = self.CurChapterData.Name + local progress = XDataCenter.FubenExploreManager.GetExploreProgress(self.CurChapterId) + local progressInt = math.floor(progress * 100) + self.TxtExplorNumber.text = string.format("%d%%", progressInt) + self.ImgProgress.fillAmount = 0 + --CS.DG.Tweening.DOTween.To(self.ImgProgress.fillAmount,self.ImgProgress.fillAmount,progress, 0.5) + self.ImgProgress:DOFillAmount(progress, 0.5) + --self.ImgProgress.fillAmount = progress + self.RImgBigBg:SetRawImage(self.CurChapterData.BgPic) + self:UpdateRecord() +end + +function XUiFubenExploreChapter:UpdateRecord() + local allRecordData = XDataCenter.FubenExploreManager.GetChapterStoryText(self.CurChapterId) + for i = 1, #allRecordData do + if self.GridRecordList[i] == nil then + local tempGridRecord = CS.UnityEngine.Object.Instantiate(self.GridRecord) + tempGridRecord.transform:SetParent(self.PanelContent, false) + tempGridRecord.gameObject:SetActive(true) + + table.insert(self.GridRecordList, tempGridRecord) + else + self.GridRecordList[i].gameObject:SetActive(true) + end + --setdata + local uiObj = self.GridRecordList[i]:GetComponent(typeof(CS.UiObject)) + uiObj:GetObject("TxtSubtitle").text = allRecordData[i].Title + uiObj:GetObject("TxtContent").text = allRecordData[i].Text + end + + if #XFubenExploreConfigs.GetChapterStoryText(self.CurChapterId) ~= #allRecordData then + self.GridExploring.gameObject.transform:SetAsLastSibling() + self.GridExploring.gameObject:SetActive(true) + else + self.GridExploring.gameObject:SetActive(false) + end + + for i = #allRecordData + 1, #self.GridRecordList do + self.GridRecordList[i].gameObject:SetActive(false) + end + CS.UnityEngine.UI.LayoutRebuilder.ForceRebuildLayoutImmediate(self.PanelContent) +end + +function XUiFubenExploreChapter:InitTabBtn() + local allChapterData = XFubenExploreConfigs.GetExploreChapterCfg() + for i = 1, #allChapterData do + if self.ChapterTabBtnList[i] == nil then + local tempChapterTabBtn = CS.UnityEngine.Object.Instantiate(self.Obj:GetPrefab("BtnExploreChapter")) + tempChapterTabBtn.transform:SetParent(self.ChapterTabGroup, false) + table.insert(self.ChapterTabBtnList, tempChapterTabBtn) + end + end + self.TabBtnGroup = XUiTabBtnGroup.New(self.ChapterTabBtnList, + function(index) self:OnBtnChapterClick(index) end, + function(tabId) return self:TabBtnClickCheck(tabId) end, + nil, + XUiTabBtnGroup.TabBtnType.Chapter) + for i = 1, #allChapterData do + --setdata + self.TabBtnGroup.TabBtnList[i]:SetName(allChapterData[i].Name, CS.XTextManager.GetText("ExploreChapterName", i)) + self.TabBtnGroup.TabBtnList[i]:SetPic(allChapterData[i].Icon) + self.TabBtnGroup.TabBtnList[i]:SetRedPoint(XDataCenter.FubenExploreManager.IsChapterRedPoint(allChapterData[i].Id)) + if i ~= 1 and allChapterData[i].PreId > 0 and XDataCenter.FubenExploreManager.GetExploreProgress(allChapterData[i].PreId) ~= 1 then + self.TabBtnGroup:LockIndex(i) + else + self.TabBtnGroup:UnLockIndex(i) + end + end +end + +function XUiFubenExploreChapter:TabBtnClickCheck(index) + local result = true + local allChapterData = XFubenExploreConfigs.GetExploreChapterCfg() + if index ~= 1 and XDataCenter.FubenExploreManager.GetExploreProgress(allChapterData[index - 1].Id) ~= 1 then + XUiManager.TipError(CS.XTextManager.GetText("ExploreNotOpenError")) + result = false + end + + return result +end + +function XUiFubenExploreChapter:AddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:RegisterClickEvent(self.BtnEnter, self.OnBtnEnterClick) + self:RegisterClickEvent(self.BtnHelp, self.OnBtnHelpClick) + self:BindHelpBtn(self.BtnHelpCourse, "Explore") +end + +function XUiFubenExploreChapter:OnBtnHelpClick() + XUiManager.UiFubenDialogTip("", CS.XTextManager.GetText("ExploreExplain") or "") +end + +function XUiFubenExploreChapter:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiFubenExploreChapter:OnBtnBackClick() + self:Close() +end + +function XUiFubenExploreChapter:OnBtnEnterClick() + XLuaUiManager.Open("UiFubenExploreLevel", self.CurChapterId) +end + +function XUiFubenExploreChapter:OnBtnChapterClick(chapterId) + if self.AnimQieHuanGo and self.AnimQieHuanGo.activeInHierarchy then + self:PlayAnimation("AnimQieHuan") + end + self.CurChapterId = chapterId + XDataCenter.FubenExploreManager.SetCurChapterId(self.CurChapterId) + self.CurChapterData = XFubenExploreConfigs.GetChapterData(self.CurChapterId) + self:UpdateInfo() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenExplore/XUiFubenExploreLevel.lua b/Resources/Scripts/XUi/XUiFubenExplore/XUiFubenExploreLevel.lua new file mode 100644 index 00000000..581834fc --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenExplore/XUiFubenExploreLevel.lua @@ -0,0 +1,286 @@ +local XUiFubenExploreLevel = XLuaUiManager.Register(XLuaUi, "UiFubenExploreLevel") +function XUiFubenExploreLevel:OnAwake() + self:AddListener() +end + +function XUiFubenExploreLevel:OnStart(chapterId) + self.ChapterId = chapterId + self.BannerList = {} + self.QuickJumpBtnList = {} + self.BuffList = {} + self.BuffDetailList = {} + self.BtnNormalDot.gameObject:SetActive(false) + self.ExploreBuff.gameObject:SetActive(false) + self.ExploreBuffDetail.gameObject:SetActive(false) + self.AnimFullExploreEnable = self:FindGameObject("AnimFullExploreEnable") + self:InitDragPanel() + self:Init() + XEventManager.AddEventListener(XEventId.EVENT_FUBEN_EXPLORE_UPDATE, self.Init, self) + XEventManager.AddEventListener(XEventId.EVENT_FUBEN_EXPLORE_UPDATEBUFF, self.UpdateBuffList, self) +end + +function XUiFubenExploreLevel:OnEnable() + if XDataCenter.FubenExploreManager.GetExploreProgress(self.ChapterId) ~= 1 then + --选择最近的可打节点去focuse + self:AutoFocus() + end +end + +function XUiFubenExploreLevel:OnDestroy() + if self.LoadResource then + self.LoadResource:Release() + end + XEventManager.RemoveEventListener(XEventId.EVENT_FUBEN_EXPLORE_UPDATE, self.Init, self) + XEventManager.RemoveEventListener(XEventId.EVENT_FUBEN_EXPLORE_UPDATEBUFF, self.UpdateBuffList, self) +end + +function XUiFubenExploreLevel:AddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:RegisterClickEvent(self.BtnBuff, self.OnBtnBuffClick) + self:RegisterClickEvent(self.BtnClose, self.OnBtnCloseClick) + self:RegisterClickEvent(self.BtnReward, self.OnBtnRewardClick) + self:BindHelpBtn(self.BtnHelpCourse, "Explore") +end + +function XUiFubenExploreLevel:OnBtnRewardClick() + local chapterData = XFubenExploreConfigs.GetChapterData(self.ChapterId) + if XDataCenter.FubenExploreManager.GetChapterData(self.ChapterId) ~= nil + and XDataCenter.FubenExploreManager.GetChapterData(self.ChapterId).RewardStatus == 1 then + -- XUiManager.TipError(CS.XTextManager.GetText("ExploreRewardError")) + -- 已领取状态下直接显示奖励物品信息 + XUiManager.OpenUiTipRewardByRewardId(chapterData.RewardId, CS.XTextManager.GetText("ExploreRewardTitle")) + else + if XDataCenter.FubenExploreManager.GetExploreProgress(self.ChapterId) == 1 then + XDataCenter.FubenExploreManager.GetChapterReward(self.ChapterId, function() self:CompleteInit() end) + else + XUiManager.OpenUiTipRewardByRewardId(chapterData.RewardId, CS.XTextManager.GetText("ExploreRewardTitle")) + end + end +end + +function XUiFubenExploreLevel:OnBtnMainUiClick() + XLuaUiManager.RunMain() + --self.PanelDragArea:EndFocus() +end + +function XUiFubenExploreLevel:OnBtnBackClick() + self:Close() +end + +function XUiFubenExploreLevel:OnBtnBuffClick() + self.PanelBuffDetail.gameObject:SetActive(true) + self:PlayAnimation("AnimBuffDetailEnable") +end + +function XUiFubenExploreLevel:OnBtnCloseClick() + self.PanelBuffDetail.gameObject:SetActive(false) +end + +function XUiFubenExploreLevel:OnQuickJumpClick(nodeInfo) + self.PanelDragArea:FocusTarget(self:GetNodeObj(nodeInfo), 1, 0.5, CS.UnityEngine.Vector3.zero, function() self:OnLevelNodeClick(nodeInfo) end) + --self.PanelDragArea:StartFocus(self:GetNodeObj(nodeInfo).transform.position, 1, 0.5, CS.UnityEngine.Vector3.zero, true, function() XLog.Debug("StartFinish!!!!") end) +end + +function XUiFubenExploreLevel:InitDragPanel() + local chapterData = XFubenExploreConfigs.GetChapterData(self.ChapterId) + local prefabName = string.format(chapterData.ChapterPrefab) + self.LoadResource = CS.XResourceManager.Load(prefabName); + self.DragPanel = CS.UnityEngine.Object.Instantiate(self.LoadResource.Asset) + self.DragPanel.transform:SetParent(self.FullScreenBackground, false) + self.PanelDragArea = self.DragPanel:GetComponentInChildren(typeof(CS.XDragArea)) + self.LayerLevel = self.PanelDragArea.gameObject.transform:Find("LayerLevel") +end + +function XUiFubenExploreLevel:CompleteInit() + self.PanelFullExplore.gameObject:SetActive(true) + if self.AnimFullExploreEnable and self.AnimFullExploreEnable.activeInHierarchy then + self:PlayAnimationWithMask("AnimFullExploreEnable", function() + self:Close() + end) + else + self:Close() + end +end + +function XUiFubenExploreLevel:Init() + local chapterData = XFubenExploreConfigs.GetChapterData(self.ChapterId) + --生成可拖动区域内的所有节点 + --获取这一章表所有的关卡(处理后) + self.AllNodeList = XDataCenter.FubenExploreManager.GetAllNodeData(self.ChapterId) + local useNodeList = {} + for i = 1, #self.AllNodeList do + if self.AllNodeList[i].State ~= XFubenExploreConfigs.NodeStateEnum.Invisivle then + table.insert(useNodeList, self.AllNodeList[i]) + end + end + + for i = 1, #useNodeList do + if self.BannerList[useNodeList[i].tableData.Id] == nil then + local tempLevelNodeObj + if useNodeList[i].tableData.IsBossNode then + tempLevelNodeObj = CS.UnityEngine.Object.Instantiate(self.Obj:GetPrefab("FubenExploreBossLevel")) + else + tempLevelNodeObj = CS.UnityEngine.Object.Instantiate(self.Obj:GetPrefab("FubenExploreLevel")) + end + local parentObj = self.LayerLevel.transform:Find(useNodeList[i].tableData.Id) + parentObj.gameObject:SetActive(true) + tempLevelNodeObj.transform:SetParent(parentObj, false) + tempLevelNodeObj.transform:SetAsLastSibling() + local tempLevelNode = XUiFubenExploreLevelNode.New(tempLevelNodeObj, useNodeList[i], self, function(nodeInfo) self:OnLevelNodeClick(nodeInfo) end) + self.BannerList[useNodeList[i].tableData.Id] = tempLevelNode + else + self.BannerList[useNodeList[i].tableData.Id]:UpdateNode(useNodeList[i]) + end + end + + --生成所有可到达节点按钮 + self.CanPlayList = {} + for i = 1, #self.AllNodeList do + if self.AllNodeList[i].State == XFubenExploreConfigs.NodeStateEnum.Availavle then + table.insert(self.CanPlayList, self.AllNodeList[i]) + end + end + for i = 1, #self.CanPlayList do + if self.QuickJumpBtnList[i] == nil then + local tempBtn = CS.UnityEngine.Object.Instantiate(self.BtnNormalDot) + tempBtn.transform:SetParent(self.PanelNodeList, false) + tempBtn.gameObject:SetActive(true) + self.QuickJumpBtnList[i] = XUiFubenExploreQuickJumpBtn.New(tempBtn, self.CanPlayList[i], function(nodeInfo) self:OnQuickJumpClick(nodeInfo) end) + else + self.QuickJumpBtnList[i]:UpdateNode(self.CanPlayList[i]) + self.QuickJumpBtnList[i].GameObject:SetActiveEx(true) + end + end + for i = #self.CanPlayList + 1, #self.QuickJumpBtnList do + self.QuickJumpBtnList[i].GameObject:SetActiveEx(false) + end + + --更新探索率 + local progress = XDataCenter.FubenExploreManager.GetExploreProgress(self.ChapterId) + local progressInt = math.floor(progress * 100) + self.TxtProgress.text = string.format("%d%%", progressInt) + self.ImgProgress.fillAmount = progress + self.ImgRedPoint.gameObject:SetActive(XDataCenter.FubenExploreManager.IsChapterRedPoint(self.ChapterId)) + --0未领取,1已领取 + if XDataCenter.FubenExploreManager.GetChapterData(self.ChapterId) ~= nil + and XDataCenter.FubenExploreManager.GetChapterData(self.ChapterId).RewardStatus == 1 then + self.ImgComplete.gameObject:SetActive(true) + else + self.ImgComplete.gameObject:SetActive(false) + end + --更新buff以及章节名 + self.TxtTitle.text = chapterData.Name + self.TxtChapterId.text = chapterData.Id + self:UpdateBuffList() + + --为了粒子层正常,更新canvas的order + self:InitCanvas() +end + +function XUiFubenExploreLevel:InitCanvas() + self.PanelTopareaCanvas.sortingOrder = self.UiFubenExploreLevelCanvas.sortingOrder + 5 + self.PanelTopCenterCanvas.sortingOrder = self.UiFubenExploreLevelCanvas.sortingOrder + 5 + self.PanelBottomLeftCanvas.sortingOrder = self.UiFubenExploreLevelCanvas.sortingOrder + 5 + self.PanelFullExploreCanvas.sortingOrder = self.UiFubenExploreLevelCanvas.sortingOrder + 5 + self.PanelBuffDetailCanvas.sortingOrder = self.UiFubenExploreLevelCanvas.sortingOrder + 5 +end + +function XUiFubenExploreLevel:AutoFocus() + if #self.CanPlayList > 0 then + local nearestNode = self.CanPlayList[1] + local minDis = CS.UnityEngine.Vector3.Distance(self:GetNodeObj(self.CanPlayList[1]).transform.position, self.DragPanel.gameObject.transform.position) + for i = 2, #self.CanPlayList do + local tempDis = CS.UnityEngine.Vector3.Distance(self:GetNodeObj(self.CanPlayList[i]).transform.position, self.DragPanel.gameObject.transform.position) + if tempDis < minDis then + nearestNode = self.CanPlayList[i] + minDis = tempDis + end + end + self.PanelDragArea:FocusTarget(self:GetNodeObj(nearestNode), 1, 0.5, CS.UnityEngine.Vector3.zero) + end +end + +function XUiFubenExploreLevel:UpdateBuffList() + --小buffIco + local allBuff = XFubenExploreConfigs.GetChapterBuff(self.ChapterId) + for i = 1, #allBuff do + if self.BuffList[i] == nil then + local tempBuff = CS.UnityEngine.Object.Instantiate(self.ExploreBuff) + tempBuff.transform:SetParent(self.BtnBuff.transform, false) + tempBuff.gameObject:SetActive(true) + self.BuffList[i] = XUiFubenExploreBuff.New(tempBuff, allBuff[i]) + else + self.BuffList[i]:Update(allBuff[i]) + end + end + + for i = #allBuff + 1, #self.BuffList do + self.BuffList[i].GameObject:SetActive(false) + end + --大BuffList + for i = 1, #allBuff do + if self.BuffDetailList[i] == nil then + local tempBuff = CS.UnityEngine.Object.Instantiate(self.ExploreBuffDetail) + tempBuff.transform:SetParent(self.DetailBuffListPanel.transform, false) + tempBuff.gameObject:SetActive(true) + self.BuffDetailList[i] = XUiFubenExploreBuffDetail.New(tempBuff, allBuff[i]) + else + self.BuffDetailList[i]:Update(allBuff[i]) + end + end + + for i = #allBuff + 1, #self.BuffDetailList do + self.BuffDetailList[i].GameObject:SetActive(false) + end +end + +function XUiFubenExploreLevel:GetNodeObj(nodeInfo) + for _, v in pairs(self.BannerList) do + if v.NodeInfo.tableData.Id == nodeInfo.tableData.Id then + return v.GameObject.transform + end + end +end + +function XUiFubenExploreLevel:OnLevelNodeClick(nodeInfo) + --锁定的点了不能进 + if nodeInfo.State == XFubenExploreConfigs.NodeStateEnum.Visivle then + local unLockText = "" + local unLockTextSeparate = CS.XTextManager.GetText("ExploreBuffUnlockSeparate") + for i = 1, #nodeInfo.tableData.PreOpenId do + if not XDataCenter.FubenExploreManager.IsNodeFinish(self.ChapterId, nodeInfo.tableData.PreOpenId[i]) then + local lockNodeInfo = XFubenExploreConfigs.GetLevel(nodeInfo.tableData.PreOpenId[i]) + if i >= 2 then + unLockText = unLockText .. unLockTextSeparate .. lockNodeInfo.Name + else + unLockText = lockNodeInfo.Name + end + end + end + XUiManager.TipError(CS.XTextManager.GetText("ExploreBuffUnlock", unLockText)) + return + end + + XDataCenter.FubenExploreManager.SetCurNodeId(nodeInfo.tableData.Id) + --剧情节点 + if nodeInfo.tableData.Type == XFubenExploreConfigs.NodeTypeEnum.Story then + XLuaUiManager.Open("UiEnterFight", nodeInfo.tableData.Type, nodeInfo.tableData.Title, nodeInfo.tableData.Explain, nodeInfo.tableData.EnterIco, nodeInfo.tableData.RewardId, function() + XDataCenter.MovieManager.PlayMovie(nodeInfo.tableData.TypeValue, function() + if not XDataCenter.FubenExploreManager.IsNodeFinish(self.ChapterId, nodeInfo.tableData.Id) then + XDataCenter.FubenExploreManager.FinishNode(self.ChapterId, nodeInfo.tableData.Id, function() + self:Init() + self:AutoFocus() + end) + end + end) + end) + end + + --战斗节点 + if nodeInfo.tableData.Type == XFubenExploreConfigs.NodeTypeEnum.Stage then + XLuaUiManager.Open("UiEnterFight", nodeInfo.tableData.Type, nodeInfo.tableData.Title, nodeInfo.tableData.Explain, nodeInfo.tableData.EnterIco, nodeInfo.tableData.RewardId, function() + XLuaUiManager.Open("UiNewRoomSingle", tonumber(nodeInfo.tableData.TypeValue)) + end) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenExplore/XUiFubenExploreLevelNode.lua b/Resources/Scripts/XUi/XUiFubenExplore/XUiFubenExploreLevelNode.lua new file mode 100644 index 00000000..9c032053 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenExplore/XUiFubenExploreLevelNode.lua @@ -0,0 +1,87 @@ +XUiFubenExploreLevelNode = XClass(nil, "XUiFubenExploreLevelNode") +function XUiFubenExploreLevelNode:Ctor(ui, nodeInfo, rootUi, cb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self.NodeInfo = nodeInfo + self.ShowDetail = false + local behaviour = self.Transform.gameObject:AddComponent(typeof(CS.XLuaBehaviour)) + if self.Update then + behaviour.LuaUpdate = function() self:Update() end + end + self.ShowDetailMinScale = CS.XGame.ClientConfig:GetFloat("ExploreShowDetailMinScale") + self.DetailFadeTime = CS.XGame.ClientConfig:GetFloat("ExploreDetailFadeTime") + self.Cb = cb + XTool.InitUiObject(self) + self.BtnNode.CallBack = function() self:OnBtnNodeClick() end + self:UpdateNode() +end + +function XUiFubenExploreLevelNode:OnBtnNodeClick() + self.Cb(self.NodeInfo) +end + +function XUiFubenExploreLevelNode:UpdateNode(nodeInfo) + if nodeInfo ~= nil then + self.NodeInfo = nodeInfo + end + --初始默认值 + self.ImgKeyNode.gameObject:SetActive(false) + self.PanelStrory.gameObject:SetActive(false) + self.RImgNodeIco.gameObject:SetActive(false) + self.PanelComplete.gameObject:SetActive(false) + self.PanelLock.gameObject:SetActive(false) + self.PanelReward.gameObject:SetActive(false) + self.PanelSelect.gameObject:SetActive(false) + --关键关卡(右上角标识) + if self.NodeInfo.tableData.IsKeyNode then + self.ImgKeyNode.gameObject:SetActive(true) + end + --关卡类型 + if self.NodeInfo.tableData.Type == XFubenExploreConfigs.NodeTypeEnum.Story then + self.PanelStrory.gameObject:SetActive(true) + elseif self.NodeInfo.tableData.Type == XFubenExploreConfigs.NodeTypeEnum.Battle then + self.RImgNodeIco.gameObject:SetActive(true) + end + --状态 + if self.NodeInfo.State == XFubenExploreConfigs.NodeStateEnum.Complete then + self.PanelComplete.gameObject:SetActive(true) + self.RImgNodeIco.gameObject:SetActive(true) + elseif self.NodeInfo.State == XFubenExploreConfigs.NodeStateEnum.Visivle then + self.PanelLock.gameObject:SetActive(true) + self.RImgNodeIco.gameObject:SetActive(true) + elseif self.NodeInfo.State == XFubenExploreConfigs.NodeStateEnum.Availavle then + self.RImgNodeIco.gameObject:SetActive(true) + self.PanelSelect.gameObject:SetActive(true) + end + --战利品 + if self.NodeInfo.tableData.RewardId > 0 then + self.PanelReward.gameObject:SetActive(true) + self.RImgRewardIco:SetRawImage(self.NodeInfo.tableData.RewardIcon) + end + --背景图片 + self.RImgNodeIco:SetRawImage(self.NodeInfo.tableData.Icon) + --头像 + self.RImgRole:SetRawImage(self.NodeInfo.tableData.CharacterIcon) + --关卡名 + self.TxtLevelID.text = self.NodeInfo.tableData.Name + --时间 + self.TxtLevelTime.text = self.NodeInfo.tableData.TimeDesc +end + +function XUiFubenExploreLevelNode:Update() + local curScale = self.RootUi.PanelDragArea.gameObject.transform.localScale.x + if curScale > self.ShowDetailMinScale and not self.ShowDetail then + self.ShowDetail = true + if self.TweenFade ~= nil then + self.TweenFade:Kill() + end + self.TweenFade = self.PanelHideCanvasGroup:DOFade(1, self.DetailFadeTime) + elseif curScale < self.ShowDetailMinScale and self.ShowDetail then + self.ShowDetail = false + if self.TweenFade ~= nil then + self.TweenFade:Kill() + end + self.TweenFade = self.PanelHideCanvasGroup:DOFade(0, self.DetailFadeTime) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenExplore/XUiFubenExploreQuickJumpBtn.lua b/Resources/Scripts/XUi/XUiFubenExplore/XUiFubenExploreQuickJumpBtn.lua new file mode 100644 index 00000000..62f4c9f9 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenExplore/XUiFubenExploreQuickJumpBtn.lua @@ -0,0 +1,19 @@ +XUiFubenExploreQuickJumpBtn = XClass(nil, "XUiFubenExploreQuickJumpBtn") +function XUiFubenExploreQuickJumpBtn:Ctor(ui, data, cb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.NodeInfo = data + self.Cb = cb + XTool.InitUiObject(self) + self.BtnNormalDot.CallBack = function() self:OnBtnNodeClick() end + self:UpdateNode(self.NodeInfo) +end + +function XUiFubenExploreQuickJumpBtn:OnBtnNodeClick() + self.Cb(self.NodeInfo) +end + +function XUiFubenExploreQuickJumpBtn:UpdateNode(data) + self.NodeInfo = data + self.TxtName.text = data.tableData.Name +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenExtra/XUiExtraChapterStoryDetail.lua b/Resources/Scripts/XUi/XUiFubenExtra/XUiExtraChapterStoryDetail.lua new file mode 100644 index 00000000..592b428c --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenExtra/XUiExtraChapterStoryDetail.lua @@ -0,0 +1,62 @@ +local XUiExtraChapterStoryDetail = XLuaUiManager.Register(XLuaUi, "UiStoryStageDetailFw") + +function XUiExtraChapterStoryDetail:OnAwake() + self:InitAutoScript() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) +end + +function XUiExtraChapterStoryDetail:OnStart(rootUi) + self.RootUi = rootUi +end + +function XUiExtraChapterStoryDetail:OnEnable() + self:Refresh() +end + +function XUiExtraChapterStoryDetail:Refresh() + local stageCfg = self.RootUi.Stage + local stageId = stageCfg.StageId + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + local stageTitle = XDataCenter.ExtraChapterManager.GetChapterDetailsStageTitle(stageInfo.ChapterId) + self.TxtTitle.text = stageTitle .. "-" .. stageCfg.OrderId .. stageCfg.Name + self.TxtStoryDes.text = stageCfg.Description + if stageCfg.Icon then + self.RImgNandu:SetRawImage(stageCfg.Icon) + end + if stageCfg.StoryIcon then + self.RImgTitleBg:SetRawImage(stageCfg.StoryIcon) + end +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiExtraChapterStoryDetail:InitAutoScript() + self:AutoAddListener() +end + +function XUiExtraChapterStoryDetail:AutoAddListener() + self.BtnEnter.CallBack = function() + self:OnBtnEnterClick() + end +end +-- auto +function XUiExtraChapterStoryDetail:OnBtnEnterClick() + local stageCfg = self.RootUi.Stage + local stageId = stageCfg.StageId + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + self:Hide() + if stageInfo.Passed then + XDataCenter.MovieManager.PlayMovie(stageCfg.BeginStoryId) + else + XDataCenter.FubenManager.FinishStoryRequest(stageId, function() + XDataCenter.MovieManager.PlayMovie(stageCfg.BeginStoryId, function() + self.RootUi:RefreshForChangeDiff() + end) + end) + end +end + +function XUiExtraChapterStoryDetail:Hide() + self:Close() + CsXGameEventManager.Instance:Notify(XEventId.EVENT_FUBEN_CLOSE_FUBENSTAGEDETAIL) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenExtra/XUiFubenExtraChapter.lua b/Resources/Scripts/XUi/XUiFubenExtra/XUiFubenExtraChapter.lua new file mode 100644 index 00000000..246407a3 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenExtra/XUiFubenExtraChapter.lua @@ -0,0 +1,998 @@ +local XUiGridChapter = require("XUi/XUiFubenMainLineChapter/XUiGridChapter") +local XUiGridExploreChapter = require("XUi/XUiFubenMainLineChapter/XUiGridExploreChapter") +local XUiFubenExtraChapter = XLuaUiManager.Register(XLuaUi, "UiFubenMainLineChapterFw") + +function XUiFubenExtraChapter:OnAwake() + self:AddListener() +end + +function XUiFubenExtraChapter:OnStart(chapter, stageId, hideDiffTog) + self.UnderBg = self.Transform:Find("SafeAreaContentPane/ImageUnder") + self.SafeAreaContentPane = self.Transform:Find("SafeAreaContentPane") + self.Camera = self.Transform:GetComponent("Canvas").worldCamera + if self.LastData then + self.Chapter = self.LastData.Chapter or chapter + self.StageId = self.LastData.StageId or stageId + self.HideDiffTog = self.LastData.HideDiffTog or hideDiffTog + self.LastData = nil + else + self.Chapter = chapter + self.StageId = stageId + self.HideDiffTog = hideDiffTog + end + self.Opened = false + self.IsOnZhouMu = false + self.GridTreasureList = {} + self.GridMultipleWeeksTaskList = {} + self.GridChapterList = {} --存的是各种Chapter的预制体实例列表 + self.QuickJumpBtnList = {} + self.PanelExploreBottom = {} + self.CurChapterGrid = nil + self.CurChapterGridName = "" + self.PanelStageDetailInst = nil + self.CurDiff = self.Chapter.Difficult + self.PanelTreasure.gameObject:SetActiveEx(false) + self.ImgRedProgress.gameObject:SetActiveEx(false) + self.ExtraChapterId = self.Chapter.ChapterId + self.IsExploreMod = XDataCenter.ExtraChapterManager.CheckChapterTypeIsExplore(self.Chapter) + + local chapterInfo = XDataCenter.ExtraChapterManager.GetChapterInfo(self.Chapter.ChapterId) + self.ChapterMainId = (chapterInfo or {}).ChapterMainId or 0 + self.ZhouMuId = XFubenExtraChapterConfigs.GetZhouMuId(self.ChapterMainId) + + --保存初始颜色 + self.OriginalColors = { + TxtChapterNameColor = self.TxtChapterName.color, --章节名称 + TxtLeftTimeTipColor = self.Text_1.color, --剩余时间描述 + TxtLeftTimeColor = self.TxtLeftTime.color, --剩余时间 + StarColor = self.ImageLine.color, --星星 + ImageBottomColor = self.ImageBottom.color, --底部栏 + TxtStarNumColor = self.TxtStarNum.color, --星星数量 + TxtDescrColor = self.Txet.color, --收集进度 + Triangle0Color = self.Triangle0.color, --底部栏左侧三角形 + Triangle1Color = self.Triangle1.color, + Triangle2Color = self.Triangle2.color, + Triangle3Color = self.Triangle3.color, + } + + -- 注册红点事件 + self.RedPointId = XRedPointManager.AddRedPointEvent(self.ImgRedProgress, self.OnCheckRewards, self, { XRedPointConditions.Types.CONDITION_EXTRA_TREASURE }, self.Chapter.ChapterId, false) + self.RedPointZhouMuId = XRedPointManager.AddRedPointEvent(self.ImgRedProgress, self.OnCheckRewards, self, { XRedPointConditions.Types.CONDITION_ZHOUMU_TASK }, self.ZhouMuId, false) + + XRedPointManager.AddRedPointEvent(self.BtnExItem, self.OnCheckExploreItemNews, self, { XRedPointConditions.Types.CONDITION_EXTRA_EXPLORE_ITEM_GET }, self.ExtraChapterId) + + -- 注册stage事件 + XEventManager.AddEventListener(XEventId.EVENT_FUBEN_STAGE_SYNC, self.OnSyncStage, self) + XEventManager.AddEventListener(XEventId.EVENT_AUTO_FIGHT_START, self.OnAutoFightStart, self) + + -- 难度toggle + if not self.HideDiffTog then + self.IsShowDifficultPanel = false + self:UpdateDifficultToggles() + else + self.PanelTopDifficult.gameObject:SetActiveEx(false) + end + self:InitPanelBottom() +end + +function XUiFubenExtraChapter:OnEnable() + -- 是否显示周目挑战按钮 + self.ZhouMuNumber = XDataCenter.FubenZhouMuManager.GetZhouMuNumber(self.ZhouMuId) + self.PanelMultipleWeeksInfo.gameObject:SetActiveEx(self.ZhouMuNumber ~= 0) + + if self.GridChapterList then + for _, v in pairs(self.GridChapterList) do + v:OnEnable() + end + end + + self:UpdateDifficultToggles() + self:UpdateCurChapter(self.Chapter) + + self:GoToLastPassStage() +end + +function XUiFubenExtraChapter:OnDisable() + if self.GridChapterList then + for _, v in pairs(self.GridChapterList) do + v:OnDisable() + end + end + + if not self.IsExploreMod then + local childUi = self:GetCurDetailChildUi() + self:CloseChildUi(childUi) + self:OnCloseStageDetail() + end +end + +function XUiFubenExtraChapter:OnDestroy() + self:DestroyActivityTimer() + XEventManager.RemoveEventListener(XEventId.EVENT_FUBEN_STAGE_SYNC, self.OnSyncStage, self) + XEventManager.RemoveEventListener(XEventId.EVENT_AUTO_FIGHT_START, self.OnAutoFightStart, self) +end + +function XUiFubenExtraChapter:InitPanelBottom() + self.PanelExploreBottom.Transform = self.PanelExploreBottomObj.transform + self.PanelExploreBottom.GameObject = self.PanelExploreBottomObj.gameObject + XTool.InitUiObject(self.PanelExploreBottom) + + self.PanelExploreBottom.BtnNormalJump.gameObject:SetActiveEx(false) + self.PanelExploreBottom.BtnHardlJump.gameObject:SetActiveEx(false) +end + +function XUiFubenExtraChapter:GoToLastPassStage() + if self.CurChapterGrid then + + if self.IsExploreMod then + if self.IsCanGoNearestStage or not self.Opened then + self.CurChapterGrid:GoToNearestStage() + self.Opened = true + self.IsCanGoNearestStage = false + end + else + if not self.Opened then + local lastPassStageId = XDataCenter.ExtraChapterManager.GetLastPassStage(self.Chapter.ChapterId) + self.CurChapterGrid:GoToStage(lastPassStageId) + self.Opened = true + end + end + end +end + +function XUiFubenExtraChapter:StageLevelChangeAutoMove() + if self.CurChapterGrid then + if self.IsExploreMod then + self.CurChapterGrid:GoToNearestStage() + else + local lastPassStageId = XDataCenter.ExtraChapterManager.GetLastPassStage(self.Chapter.ChapterId) + self.CurChapterGrid:GoToStage(lastPassStageId) + end + end +end + +-- 打开关卡详情 +function XUiFubenExtraChapter:OpenStage(stageId, needRefreshChapter) + local orderId + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + orderId = stageInfo.OrderId + self.CurDiff = stageInfo.Difficult + XDataCenter.ExtraChapterManager.SetCurDifficult(self.CurDiff) + + self:UpdateDifficultToggles() + + if needRefreshChapter then + local chapter = self:GetChapterCfgByStageId(stageId) + self:UpdateCurChapter(chapter) + end + self.CurChapterGrid:ClickStageGridByIndex(orderId) +end + +function XUiFubenExtraChapter:EnterFight(stage) + if not XDataCenter.FubenManager.CheckPreFight(stage) then + return + end + XLuaUiManager.Open("UiNewRoomSingle", stage.StageId) +end + +-- 是否显示红点 +function XUiFubenExtraChapter:OnCheckRewards(count, chapterId) + if self.IsOnZhouMu then + if self.ImgRedProgress and chapterId == self.ZhouMuId then + self.ImgRedProgress.gameObject:SetActiveEx(count >= 0) + end + else + if self.ImgRedProgress and chapterId == self.Chapter.ChapterId then + self.ImgRedProgress.gameObject:SetActiveEx(count >= 0) + end + end +end + +function XUiFubenExtraChapter:AddListener() + self:RegisterClickEvent(self.BtnTreasureBg, self.OnBtnTreasureBgClick) + self:RegisterClickEvent(self.Scrollbar, self.OnScrollbarClick) + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:RegisterClickEvent(self.BtnTreasure, self.OnBtnTreasureClick) + self:RegisterClickEvent(self.BtnCloseDifficult, self.OnBtnCloseDifficultClick) + self:RegisterClickEvent(self.BtnCloseDetail, self.OnBtnCloseDetailClick) + + self.BtnExItem.CallBack = function() + self:OnBtnExItemClick() + end + self.BtnNormal.CallBack = function() + self:OnBtnNormalClick(true) + end + self.BtnHard.CallBack = function() + self:OnBtnHardClick(true) + end + self.BtnSwitch1MultipleWeeks.CallBack = function() + self:OnBtnSwitch1MultipleWeeksClick() + end + self.BtnSwitch2Normal.CallBack = function() + self:OnBtnSwitch2NormalClidk() + end +end +-- auto +function XUiFubenExtraChapter:OnBtnCloseDetailClick() + self:OnCloseStageDetail() +end + +function XUiFubenExtraChapter:OnBtnCloseDifficultClick() + self:UpdateDifficultToggles() +end + +function XUiFubenExtraChapter:OnScrollbarClick() + +end + +function XUiFubenExtraChapter:OnBtnExItemClick() + XLuaUiManager.Open("UiFubenExItemTip", self) +end + +function XUiFubenExtraChapter:OnBtnBackClick() + if self:CloseStageDetail() then + return + end + self:Close() +end + +function XUiFubenExtraChapter:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +--[[function XUiFubenExtraChapter:OpenDifficultPanel() + +end]] +function XUiFubenExtraChapter:OnBtnNormalClick(IsAutoMove) + if self.IsShowDifficultPanel then + if self.CurDiff ~= XDataCenter.FubenManager.DifficultNormal then + local chapterInfo = XDataCenter.ExtraChapterManager.GetChapterInfoForOrderId(XDataCenter.FubenManager.DifficultNormal, self.Chapter.OrderId) + if not (chapterInfo and chapterInfo.Unlock) then + XUiManager.TipMsg(XDataCenter.FubenManager.GetFubenOpenTips(chapterInfo.FirstStage), XUiManager.UiTipType.Wrong) + return false + end + self.CurDiff = XDataCenter.FubenManager.DifficultNormal + XDataCenter.ExtraChapterManager.SetCurDifficult(self.CurDiff) + self:RefreshForChangeDiff(IsAutoMove) + end + self:UpdateDifficultToggles() + else + self:UpdateDifficultToggles(true) + end + return true +end + +function XUiFubenExtraChapter:OnBtnHardClick(IsAutoMove) + if self.IsShowDifficultPanel then + if self.CurDiff ~= XDataCenter.FubenManager.DifficultHard then + -- 检查困难开启 + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.FubenDifficulty) then + return false + end + + -- 检查主线副本活动 + local chapterInfo = XDataCenter.ExtraChapterManager.GetChapterInfoForOrderId(XDataCenter.FubenManager.DifficultHard, self.Chapter.OrderId) + if chapterInfo.IsActivity then + local chapterId = XDataCenter.ExtraChapterManager.GetChapterIdByChapterExtraId(chapterInfo.ChapterMainId, XDataCenter.FubenManager.DifficultHard) + local ret, desc = XDataCenter.ExtraChapterManager.CheckActivityCondition(chapterId) + if not ret then + XUiManager.TipMsg(desc, XUiManager.UiTipType.Wrong) + return false + end + end + -- 检查困难这个章节解锁 + if not chapterInfo or not chapterInfo.IsOpen then + local chapterId = XDataCenter.ExtraChapterManager.GetChapterIdByChapterExtraId(chapterInfo.ChapterMainId, XDataCenter.FubenManager.DifficultHard) + local ret, desc = XDataCenter.ExtraChapterManager.CheckOpenCondition(chapterId) + if not ret then + XUiManager.TipError(desc) + return false + end + local tipMsg = XDataCenter.FubenManager.GetFubenOpenTips(chapterInfo.FirstStage) + XUiManager.TipMsg(tipMsg) + return false + end + self.CurDiff = XDataCenter.FubenManager.DifficultHard + XDataCenter.ExtraChapterManager.SetCurDifficult(self.CurDiff) + self:RefreshForChangeDiff(IsAutoMove) + end + self:UpdateDifficultToggles() + else + self:UpdateDifficultToggles(true) + end + return true +end + +function XUiFubenExtraChapter:UpdateDifficultToggles(showAll) + if showAll then + self:SetBtnTogleActive(true, true, true) + self.BtnCloseDifficult.gameObject:SetActiveEx(true) + else + if self.CurDiff == XDataCenter.FubenManager.DifficultNormal then + self:SetBtnTogleActive(true, false, false) + self.BtnNormal.transform:SetAsFirstSibling() + elseif self.CurDiff == XDataCenter.FubenManager.DifficultHard then + self:SetBtnTogleActive(false, true, false) + self.BtnHard.transform:SetAsFirstSibling() + else + self:SetBtnTogleActive(false, false, true) + end + self.BtnCloseDifficult.gameObject:SetActiveEx(false) + end + self.IsShowDifficultPanel = showAll + --progress + local pageDatas = XDataCenter.ExtraChapterManager.GetChapterExtraCfgs(self.CurDiff) + local chapterIds = {} + for _, v in pairs(pageDatas) do + if v.OrderId == self.Chapter.OrderId then + chapterIds = v.ChapterId + break + end + end + if chapterIds then + self.TxtNormalProgress.text = XDataCenter.ExtraChapterManager.GetProgressByChapterId(chapterIds[1]) + self.TxtHardProgress.text = XDataCenter.ExtraChapterManager.GetProgressByChapterId(chapterIds[2]) + end + -- 抢先体验活动倒计时 + self:UpdateActivityTime() +end + +function XUiFubenExtraChapter:UpdateChapterTxt() + local extraTitle = self.Chapter.StageTitle + self.TxtChapter.text = (extraTitle or "") + self.TxtChapterName.text = self.Chapter.ChapterEn +end + +function XUiFubenExtraChapter:SetBtnTogleActive(isNormal, isHard) + self.BtnNormal.gameObject:SetActiveEx(isNormal) + + self.BtnHard.gameObject:SetActiveEx(isHard) + if isHard then + local hardOpen = XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.FubenDifficulty) + local chapterInfo = XDataCenter.ExtraChapterManager.GetChapterInfoForOrderId(XDataCenter.FubenManager.DifficultHard, self.Chapter.OrderId) + hardOpen = hardOpen and chapterInfo and chapterInfo.IsOpen + self.PanelHardOn.gameObject:SetActiveEx(hardOpen) + self.PanelHardOff.gameObject:SetActiveEx(not hardOpen) + end +end + +function XUiFubenExtraChapter:RefreshForChangeDiff(IsAutoMove) + XDataCenter.ExtraChapterManager.SetCurDifficult(self.CurDiff) + local chapterList = XDataCenter.ExtraChapterManager.GetChapterList(self.CurDiff) + local chapter = XDataCenter.ExtraChapterManager.GetChapterDetailsCfg(chapterList[self.Chapter.OrderId]) + + self:UpdateCurChapter(chapter) + if IsAutoMove then + self:StageLevelChangeAutoMove() + end + self:PlayAnimation("AnimEnable2") +end + +function XUiFubenExtraChapter:SetPanelBottomActive(isActive) + local panelParent = self.IsExploreMod and self.ExPanel or self.NorPanel + self.PanelBottom.gameObject:SetActiveEx(isActive) + self.PanelExploreBottom.GameObject:SetActiveEx(isActive and self.IsExploreMod and not self.IsOnZhouMu) + self.PanelBottom.transform:SetParent(panelParent, false) + self.PanelBottom.transform.localPosition = CS.UnityEngine.Vector3.zero + self.FubenEx.gameObject:SetActiveEx(self.IsExploreMod) +end + +function XUiFubenExtraChapter:UpdateCurChapter(chapter) + if self.IsOnZhouMu then + -- 切换到周目模式 + self:OnBtnSwitch1MultipleWeeksClick() + return + end + + if not chapter then + return + end + self.Chapter = chapter + self.IsExploreMod = XDataCenter.ExtraChapterManager.CheckChapterTypeIsExplore(self.Chapter) + self.ExtraChapterId = self.Chapter.ChapterId + for _, v in pairs(self.GridChapterList) do + v:Hide() + end + local data = { + Chapter = self.Chapter, + HideStageCb = handler(self, self.HideStageDetail), + ShowStageCb = handler(self, self.ShowStageDetail), + } + + data.StageList = self.Chapter.StageId + + local chapterId = self.Chapter.ChapterId + local grid = self.CurChapterGrid + local prefabName = self.Chapter.PrefabName + if self.CurChapterGridName ~= prefabName then + local gameObject = self.PanelChapter:LoadPrefab(prefabName) + if gameObject == nil or not gameObject:Exist() then + return + end + + if self.IsExploreMod then + grid = XUiGridExploreChapter.New(self, gameObject, XDataCenter.FubenManager.StageType.ExtraChapter) + else + self.AnimBeijingEnable = gameObject:FindTransform("BgQieHuan1") + self.AnimBeijingDisable = gameObject:FindTransform("BgQieHuan2") + + local autoChangeBgArgs + if self.AnimBeijingEnable and self.AnimBeijingDisable then + + self.RImgBg1 = gameObject:FindTransform("RImgChapterBg1"):GetComponent("CanvasGroup") + self.RImgBg2 = gameObject:FindTransform("RImgChapterBg2"):GetComponent("CanvasGroup") + + autoChangeBgArgs = { + AutoChangeBgCb = function(autoChangeBgFlag) + if autoChangeBgFlag then + self.AnimBeijingEnable:PlayTimelineAnimation() + else + if self.FirstSetBg then + self.FirstSetBg = nil + return + end + self.AnimBeijingDisable:PlayTimelineAnimation() + end + CS.XAudioManager.PlaySound(XSoundManager.UiBasicsMusic.UiActivityBranch_SwitchBg) + end, + DatumLinePrecent = XDataCenter.ExtraChapterManager.GetAutoChangeBgDatumLinePrecent(chapterId), + StageIndex = XDataCenter.ExtraChapterManager.GetAutoChangeBgStageIndex(chapterId), + } + end + + grid = XUiGridChapter.New(self, gameObject, autoChangeBgArgs) + end + grid.Transform:SetParent(self.PanelChapter, false) + + self.CurChapterGridColors = grid:GetColors() + --保存星星颜色,传给XUiPanelStars与XUiGriTreasureGrade改变星星颜色 + self.StarColor = self.CurChapterGridColors.StarColor + self.StarDisColor = self.CurChapterGridColors.StarDisColor + + self.CurChapterGridName = prefabName + self.CurChapterGrid = grid + self.GridChapterList[prefabName] = grid + end + + grid:UpdateChapterGrid(data) + grid:Show() + self:UpdateChapterStars() + + if self.AnimBeijingEnable and self.AnimBeijingDisable then + CS.XTool.WaitForEndOfFrame(function() + local fitCondition = grid.FirstSetBg + if not fitCondition then + self.RImgBg1.gameObject:SetActiveEx(true) + self.AnimBeijingEnable.gameObject:SetActiveEx(false) + self.AnimBeijingEnable.gameObject:SetActiveEx(true) + self.RImgBg1.alpha = 1 + else + self.RImgBg2.gameObject:SetActiveEx(true) + self.AnimBeijingDisable.gameObject:SetActiveEx(false) + self.AnimBeijingDisable.gameObject:SetActiveEx(true) + self.RImgBg2.alpha = 1 + end + end) + end + + if self.StageId then + self:OpenStage(self.StageId) + self.StageId = nil + end + + XEventManager.DispatchEvent(XEventId.EVENT_GUIDE_STEP_OPEN_EVENT) + self:UpdateChapterTxt() + self:UpdateColor() + self:UpdateExploreBottom() + self:SetPanelBottomActive(true) + self:UpdateFubenExploreItem() +end + +function XUiFubenExtraChapter:UpdateColor() + --章节标题 + self.TxtChapter.color = self.CurChapterGridColors.TxtChapterNameColor or self.OriginalColors.TxtChapterNameColor + self.TxtChapterName.color = self.CurChapterGridColors.TxtChapterNameColor or self.OriginalColors.TxtChapterNameColor + --剩余时间 + self.Text_1.color = self.CurChapterGridColors.TxtLeftTimeTipColor or self.OriginalColors.TxtLeftTimeTipColor + self.TxtLeftTime.color = self.CurChapterGridColors.TxtLeftTimeColor or self.OriginalColors.TxtLeftTimeColor + + --底部栏 + self.ImageBottom.color = self.CurChapterGridColors.ImageBottomColor or self.OriginalColors.ImageBottomColor + --底部栏左侧三角形 + self.Triangle0.color = self.CurChapterGridColors.Triangle0Color or self.OriginalColors.Triangle0Color + self.Triangle1.color = self.CurChapterGridColors.Triangle1Color or self.OriginalColors.Triangle1Color + self.Triangle2.color = self.CurChapterGridColors.Triangle2Color or self.OriginalColors.Triangle2Color + self.Triangle3.color = self.CurChapterGridColors.Triangle3Color or self.OriginalColors.Triangle3Color + + --章节奖励描述的星星图标 + self.ImageLine.color = self.CurChapterGridColors.StarColor or self.OriginalColors.StarColor + --章节奖励描述的星星数量描述 + self.TxtStarNum.color = self.CurChapterGridColors.TxtStarNumColor or self.OriginalColors.TxtStarNumColor + --章节奖励描述的收集进度 + self.Txet.color = self.CurChapterGridColors.TxtDescrColor or self.OriginalColors.TxtDescrColor +end + +function XUiFubenExtraChapter:UpdateExploreBottom() + if not self.IsExploreMod then + return + end + self.CanPlayList = {} + + local chapterList = XDataCenter.ExtraChapterManager.GetChapterList(XDataCenter.FubenManager.DifficultNormal) + local normalChapter = XDataCenter.ExtraChapterManager.GetChapterDetailsCfg(chapterList[self.Chapter.OrderId]) + + chapterList = XDataCenter.ExtraChapterManager.GetChapterList(XDataCenter.FubenManager.DifficultHard) + local hardChapter = XDataCenter.ExtraChapterManager.GetChapterDetailsCfg(chapterList[self.Chapter.OrderId]) + + self:SetCanPlayStageList(normalChapter, XDataCenter.FubenManager.DifficultNormal) + self:SetCanPlayStageList(hardChapter, XDataCenter.FubenManager.DifficultHard) + + self:ReSetQuickJumpButton(normalChapter, XDataCenter.FubenManager.DifficultNormal, self.PanelExploreBottom.BtnNormalJump) + self:ReSetQuickJumpButton(hardChapter, XDataCenter.FubenManager.DifficultHard, self.PanelExploreBottom.BtnHardlJump) + + if self.CurChapterGrid then + self.CurChapterGrid:SetCanPlayList(self.CanPlayList[self.CurDiff]) + end +end + +function XUiFubenExtraChapter:SetCanPlayStageList(chapter, diff) + for index, stageId in pairs(chapter.StageId) do + if not self.CanPlayList[diff] then + self.CanPlayList[diff] = {} + end + + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + local IsEgg = stageCfg.StageType == XFubenConfigs.STAGETYPE_FIGHTEGG or stageCfg.StageType == XFubenConfigs.STAGETYPE_STORYEGG + local exploreInfoList = XDataCenter.ExtraChapterManager.GetExploreGroupInfoByGroupId(chapter.ExploreGroupId) + local exploreInfo = exploreInfoList[index] or {} + local IsShow = true + for _, idx in pairs(exploreInfo.PreShowIndex or {}) do + local Info = XDataCenter.FubenManager.GetStageInfo(chapter.StageId[idx]) + if not Info or not Info.Passed then + IsShow = false + end + end + + if stageInfo.Unlock and IsShow then + if not stageInfo.Passed and not IsEgg then + table.insert(self.CanPlayList[diff], index) + end + end + end +end + +function XUiFubenExtraChapter:ReSetQuickJumpButton(chapter, diff, jumpButton) + if not self.QuickJumpBtnList[diff] then + self.QuickJumpBtnList[diff] = {} + end + + local canPlayList = self.CanPlayList[diff] + local quickJumpBtnList = self.QuickJumpBtnList[diff] + local lenght = #canPlayList + + for i = 1, lenght do + local stageId = chapter.StageId[canPlayList[i]] + local quickJumpBtn = quickJumpBtnList[i] + if not quickJumpBtn then + local tempBtn = CS.UnityEngine.Object.Instantiate(jumpButton) + tempBtn.gameObject:SetActiveEx(true) + + quickJumpBtn = XUiFubenMainLineQuickJumpBtn.New(tempBtn, canPlayList[i], chapter, + function(index, clickStageId) + self:OnQuickJumpClick(diff, index) + XDataCenter.ExtraChapterManager.MarkNewJumpStageButtonEffectByStageId(clickStageId) + quickJumpBtn.Transform:GetComponent("XUiButton"):ShowTag(false) + end, XDataCenter.FubenManager.StageType.ExtraChapter) + quickJumpBtnList[i] = quickJumpBtn + else + quickJumpBtn:UpdateNode(canPlayList[i], chapter) + quickJumpBtn.GameObject:SetActiveEx(true) + end + + quickJumpBtn.Transform:SetParent(self.transform, false) + quickJumpBtn.Transform:SetParent(self.PanelExploreBottom.PanelNodeList, false) + + XDataCenter.ExtraChapterManager.SaveNewJumpStageButtonEffect(stageId) + local IsHaveNew = XDataCenter.ExtraChapterManager.CheckHaveNewJumpStageButtonByStageId(stageId) + quickJumpBtn.Transform:GetComponent("XUiButton"):ShowTag(IsHaveNew) + end + + lenght = #quickJumpBtnList + for i = #canPlayList + 1, lenght do + quickJumpBtnList[i].GameObject:SetActiveEx(false) + end +end + +function XUiFubenExtraChapter:OnQuickJumpClick(diff, index) + if diff ~= self.CurDiff then + local IsLock = false + self.IsShowDifficultPanel = true + if diff == XDataCenter.FubenManager.DifficultNormal then + IsLock = self:OnBtnNormalClick(false) + elseif diff == XDataCenter.FubenManager.DifficultHard then + IsLock = self:OnBtnHardClick(false) + end + + if IsLock then + self.CurChapterGrid:OnQuickJumpClick(index) + end + else + self.CurChapterGrid:OnQuickJumpClick(index) + end +end + +function XUiFubenExtraChapter:CheckDetailOpen() + local childUi = self:GetCurDetailChildUi() + return XLuaUiManager.IsUiShow(childUi) +end + +function XUiFubenExtraChapter:ShowStageDetail(stage) + self.Stage = stage + if self.IsExploreMod or self.IOnZhouMu then + self:OpenExploreDetail() + else + local childUi = self:GetCurDetailChildUi() + self:OpenOneChildUi(childUi, self) + end +end + +function XUiFubenExtraChapter:OnEnterStory(stageId) + self.Stage = XDataCenter.FubenManager.GetStageCfg(stageId) + local childUi = self:GetCurDetailChildUi() + self:OpenOneChildUi(childUi, self) +end + +function XUiFubenExtraChapter:HideStageDetail() + if not self.Stage then + return + end + + local childUi = self:GetCurDetailChildUi() + local childUiObj = self:FindChildUiObj(childUi) + if childUiObj then + childUiObj:Hide() + end +end + +function XUiFubenExtraChapter:OnCloseStageDetail() + if self.CurChapterGrid then + self.CurChapterGrid:CancelSelect() + end +end + +-- 更新左下角的奖励按钮的状态 +function XUiFubenExtraChapter:UpdateChapterStars() + local curStars + local totalStars + local received = true + self.PanelDesc.gameObject:SetActiveEx(true) + + if self.IsOnZhouMu then + -- 周目奖励 + self.MultipleWeeksTxet.gameObject:SetActiveEx(true) + self.TxtDesc.gameObject:SetActiveEx(false) + self.ImgStarIcon.gameObject:SetActiveEx(false) + + curStars, totalStars = XDataCenter.FubenZhouMuManager.GetZhouMuTaskProgress(self.ZhouMuId) + received = XDataCenter.FubenZhouMuManager.ZhouMuTaskIsAllFinish(self.ZhouMuId) + + XRedPointManager.Check(self.RedPointZhouMuId, self.ZhouMuId) + else + -- 收集奖励 + curStars, totalStars = XDataCenter.ExtraChapterManager.GetChapterStars(self.Chapter.ChapterId) + local chapterTemplate = XDataCenter.ExtraChapterManager.GetChapterDetailsCfg(self.Chapter.ChapterId) + for _, v in pairs(chapterTemplate.TreasureId) do + if not XDataCenter.ExtraChapterManager.IsTreasureGet(v) then + received = false + break + end + end + self.MultipleWeeksTxet.gameObject:SetActiveEx(false) + self.TxtDesc.gameObject:SetActiveEx(true) + self.ImgStarIcon.gameObject:SetActiveEx(true) + + XRedPointManager.Check(self.RedPointId, self.Chapter.ChapterId) + end + + self.ImgJindu.fillAmount = totalStars > 0 and curStars / totalStars or 0 + self.ImgJindu.gameObject:SetActiveEx(true) + self.TxtStarNum.text = CS.XTextManager.GetText("Fract", curStars, totalStars) + self.ImgLingqu.gameObject:SetActiveEx(received) +end + +function XUiFubenExtraChapter:OnBtnTreasureClick() + if self:CloseStageDetail() then + return + end + self:InitTreasureGrade() + self.PanelTreasure.gameObject:SetActiveEx(true) + self.PanelTop.gameObject:SetActiveEx(true) + self:SetPanelBottomActive(true) + self:PlayAnimation("TreasureEnable") +end + +function XUiFubenExtraChapter:CloseStageDetail() + if self:CheckDetailOpen() then + if self.CurChapterGrid then + self.CurChapterGrid:ScrollRectRollBack() + end + self:HideStageDetail() + return true + end + return false +end + +function XUiFubenExtraChapter:OnBtnTreasureBgClick() + self:PlayAnimation("TreasureDisable", handler(self, function() + self.PanelTreasure.gameObject:SetActiveEx(false) + self.PanelTop.gameObject:SetActiveEx(true) + self:SetPanelBottomActive(true) + self:UpdateChapterStars() + end)) +end + +-- 点击切换到周目模式 +function XUiFubenExtraChapter:OnBtnSwitch1MultipleWeeksClick() + self.IsOnZhouMu = true + self.TxtCurMWNum.text = self.ZhouMuNumber + + local zhouMuChapter = XDataCenter.FubenZhouMuManager.GetZhouMuChapterData(self.ChapterMainId, true) + + for _, v in pairs(self.GridChapterList) do + v:Hide() + end + local data = { + Chapter = zhouMuChapter, + HideStageCb = handler(self, self.HideStageDetail), + ShowStageCb = handler(self, self.ShowStageDetail), + } + data.StageList = XFubenZhouMuConfigs.GetZhouMuChapterStages(zhouMuChapter.Id) + + local grid = self.CurChapterGrid + local prefabName = zhouMuChapter.PrefabName + if self.CurChapterGridName ~= prefabName then + local gameObject = self.PanelChapter:LoadPrefab(prefabName) + if gameObject == nil or not gameObject:Exist() then + return + end + + grid = XUiGridChapter.New(self, gameObject, nil, true) + grid.Transform:SetParent(self.PanelChapter, false) + self.CurChapterGridName = prefabName + self.CurChapterGrid = grid + self.GridChapterList[prefabName] = grid + end + + grid:UpdateChapterGrid(data) + grid:Show() + + self:UpdateChapterStars() + self:UpdateChapterTxt() + self:SetPanelBottomActive(true) + + self.BtnSwitch1MultipleWeeks.gameObject:SetActiveEx(false) + self.BtnSwitch2Normal.gameObject:SetActiveEx(true) + self.PanelTopDifficult.gameObject:SetActiveEx(false) + self.TxtCurMWNum.gameObject:SetActiveEx(true) + self:PlayAnimation("AnimEnable2") +end + +function XUiFubenExtraChapter:OnBtnSwitch2NormalClidk() + self.IsOnZhouMu = false + self:RefreshForChangeDiff(true) + self.BtnSwitch1MultipleWeeks.gameObject:SetActiveEx(true) + self.BtnSwitch2Normal.gameObject:SetActiveEx(false) + self.TxtCurMWNum.gameObject:SetActiveEx(false) + self.PanelTopDifficult.gameObject:SetActiveEx(true) +end + +-- 初始化 treasure grade grid panel,填充数据 +-- 周目奖励和进度奖励使用不同的Grid模板,用GridTreasureList、GridMultipleWeeksTaskList分别存储 +function XUiFubenExtraChapter:InitTreasureGrade() + local baseItem = self.IsOnZhouMu and self.GridMultipleWeeksTask or self.GridTreasureGrade + self.GridMultipleWeeksTask.gameObject:SetActiveEx(false) + self.GridTreasureGrade.gameObject:SetActiveEx(false) + + -- 先把所有的格子隐藏 + for j = 1, #self.GridTreasureList do + self.GridTreasureList[j].GameObject:SetActiveEx(false) + end + for j = 1, #self.GridMultipleWeeksTaskList do + self.GridMultipleWeeksTaskList[j].GameObject:SetActiveEx(false) + end + + local targetList + if self.IsOnZhouMu then + targetList = XFubenZhouMuConfigs.GetZhouMuTasks(self.ZhouMuId) + else + targetList = self.Chapter.TreasureId + end + if not targetList then + return + end + + local offsetValue = 260 + local gridCount = #targetList + + for i = 1, gridCount do + local offerY = (1 - i) * offsetValue + local grid + if self.IsOnZhouMu then + grid = self.GridMultipleWeeksTaskList[i] + else + grid = self.GridTreasureList[i] + end + if not grid then + local item = CS.UnityEngine.Object.Instantiate(baseItem) -- 复制一个item + grid = XUiGridTreasureGrade.New(self, item, XDataCenter.FubenManager.StageType.ExtraChapter) + grid.Transform:SetParent(self.PanelGradeContent, false) + grid.Transform.localPosition = CS.UnityEngine.Vector3(item.transform.localPosition.x, item.transform.localPosition.y + offerY, item.transform.localPosition.z) + if self.IsOnZhouMu then + self.GridMultipleWeeksTaskList[i] = grid + else + self.GridTreasureList[i] = grid + end + end + + if self.IsOnZhouMu then + grid:UpdateGradeGridTask(targetList[i]) + else + local treasureCfg = XDataCenter.ExtraChapterManager.GetTreasureCfg(targetList[i]) + local chapterInfo = XDataCenter.ExtraChapterManager.GetChapterInfo(self.Chapter.ChapterId) + grid:UpdateGradeGrid(chapterInfo.Stars, treasureCfg, self.Chapter.ChapterId) + end + grid:InitTreasureList() + grid.GameObject:SetActiveEx(true) + end +end + +function XUiFubenExtraChapter:OnSyncStage(stageId) + if not stageId then + return + end + local stageData = XDataCenter.FubenManager.GetStageData(stageId) + if not stageData then + return + end + if stageData.PassTimesToday > 1 then + return + end + if not self.CurDiff or self.CurDiff < 0 then + return + end + + local chapter = self:GetChapterCfgByStageId(stageId) + if chapter then + self:UpdateCurChapter(chapter) + end + + if self.CurChapterGrid then + if self.CurChapterGrid.IsNotPassedFightStage then + self.IsCanGoNearestStage = true + end + end +end + +function XUiFubenExtraChapter:GetChapterCfgByStageId(stageId) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + local chapter + if stageInfo.Type == XDataCenter.FubenManager.StageType.ExtraChapter then + chapter = XDataCenter.ExtraChapterManager.GetChapterDetailsCfg(stageInfo.ChapterId) + else + return + end + + return chapter +end + +function XUiFubenExtraChapter:OnGetEvents() + return { XEventId.EVENT_FUBEN_CLOSE_FUBENSTAGEDETAIL, XEventId.EVENT_FUBEN_ENTERFIGHT } +end + +--事件监听 +function XUiFubenExtraChapter:OnNotify(evt, ...) + if evt == XEventId.EVENT_FUBEN_CLOSE_FUBENSTAGEDETAIL then + self:OnCloseStageDetail() + elseif evt == XEventId.EVENT_FUBEN_ENTERFIGHT then + self:EnterFight(...) + end +end + +function XUiFubenExtraChapter:UpdateActivityTime() + if not XDataCenter.ExtraChapterManager.IsExtraActivityOpen() then + self:DestroyActivityTimer() + self.PanelActivityTime.gameObject:SetActiveEx(false) + return + end + + self:CreateActivityTimer() + + local curDiffHasActivity = XDataCenter.ExtraChapterManager.CheckDiffHasAcitivity(self.Chapter) + self.PanelActivityTime.gameObject:SetActiveEx(curDiffHasActivity) +end + +function XUiFubenExtraChapter:UpdateFubenExploreItem() + local itemCurCount = #XDataCenter.ExtraChapterManager.GetChapterExploreItemList(self.ExtraChapterId) + self.PanelFubenExItem.gameObject:SetActiveEx(itemCurCount > 0 and self.IsExploreMod) +end + +function XUiFubenExtraChapter:CreateActivityTimer() + self:DestroyActivityTimer() + + local time = XTime.GetServerNowTimestamp() + local endTime = XDataCenter.ExtraChapterManager.GetActivityEndTime() + self.TxtLeftTime.text = XUiHelper.GetTime(endTime - time, XUiHelper.TimeFormatType.ACTIVITY) + self.ActivityTimer = XScheduleManager.ScheduleForever(function() + if XTool.UObjIsNil(self.TxtLeftTime) then + self:DestroyActivityTimer() + return + end + + local leftTime = endTime - time + time = time + 1 + + if leftTime >= 0 then + self.TxtLeftTime.text = XUiHelper.GetTime(leftTime, XUiHelper.TimeFormatType.ACTIVITY) + else + self:DestroyActivityTimer() + XDataCenter.ExtraChapterManager.OnActivityEnd() + end + end, XScheduleManager.SECOND, 0) +end + +function XUiFubenExtraChapter:DestroyActivityTimer() + if self.ActivityTimer then + XScheduleManager.UnSchedule(self.ActivityTimer) + self.ActivityTimer = nil + end +end + +function XUiFubenExtraChapter:GetCurDetailChildUi() + local stageCfg = self.Stage + if not stageCfg then return "" end + + if stageCfg.StageType == XFubenConfigs.STAGETYPE_STORY or stageCfg.StageType == XFubenConfigs.STAGETYPE_STORYEGG then + return "UiStoryStageDetailFw" + else + return "UiFubenMainLineDetailFw" + end +end + +function XUiFubenExtraChapter:GoToStage(stageId) + if self.CurChapterGrid then + self.CurChapterGrid:GoToStage(stageId) + end +end + +function XUiFubenExtraChapter:OpenExploreDetail() + XLuaUiManager.Open("UiFubenExploreDetail", self, self.Stage, function() + if (self.CurChapterGrid or {}).ScaleBack and self.IsExploreMod then + self.CurChapterGrid:ScaleBack() + end + self:OnCloseStageDetail() + end, XDataCenter.FubenManager.StageType.ExtraChapter) +end + +function XUiFubenExtraChapter:OnCheckExploreItemNews(count) + self.BtnExItem:ShowReddot(count >= 0) +end + +function XUiFubenExtraChapter:OnAutoFightStart(stageId) + if self.Stage.StageId == stageId then + if self.CurChapterGrid and self.IsExploreMod then + self.CurChapterGrid:ScaleBack() + end + self:OnCloseStageDetail() + XLuaUiManager.Remove("UiFubenExploreDetail") + end +end + +function XUiFubenExtraChapter:OnReleaseInst() + return {Chapter = self.Chapter, StageId = self.StageId, HideDiffTog = self.HideDiffTog} +end + +function XUiFubenExtraChapter:OnResume(data) + self.LastData = data +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenExtra/XUiFubenExtraChapterDetail.lua b/Resources/Scripts/XUi/XUiFubenExtra/XUiFubenExtraChapterDetail.lua new file mode 100644 index 00000000..7bc1bd90 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenExtra/XUiFubenExtraChapterDetail.lua @@ -0,0 +1,287 @@ +local XUiFubenExtraChapterDetail = XLuaUiManager.Register(XLuaUi, "UiFubenMainLineDetailFw") + +function XUiFubenExtraChapterDetail:OnAwake() + self:InitAutoScript() + self.GridStageStar.gameObject:SetActive(false) + self.GridCommon.gameObject:SetActive(false) + self:InitStarPanels() +end + +function XUiFubenExtraChapterDetail:OnStart(rootUi) + self.GridList = {} + self.RootUi = rootUi + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) +end + +function XUiFubenExtraChapterDetail:OnEnable() + -- 动画 + self.IsPlaying = true + self:PlayAnimation("AnimBegin", handler(self, function() + self.IsPlaying = false + end)) + + self:AddEventListener() + self.IsOpen = true + + self:Refresh(self.RootUi.Stage) +end + +function XUiFubenExtraChapterDetail:OnDisable() + self:RemoveEventListener() + self.IsOpen = false +end + +function XUiFubenExtraChapterDetail:InitStarPanels() + self.GridStarList = {} + for i = 1, 3 do + local ui = self.Transform:Find("SafeAreaContentPane/PanelDetail/PanelTargetList/GridStageStar" .. i) + ui.gameObject:SetActive(true) + local grid = XUiGridStageStar.New(ui) + self.GridStarList[i] = grid + end +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiFubenExtraChapterDetail:InitAutoScript() + self:AutoAddListener() +end + +function XUiFubenExtraChapterDetail:AutoAddListener() + self:RegisterClickEvent(self.BtnAddNum, self.OnBtnAddNumClick) + self:RegisterClickEvent(self.BtnEnter, self.OnBtnEnterClick) + self:RegisterClickEvent(self.BtnEnterB, self.OnBtnEnterBClick) + self:RegisterClickEvent(self.BtnAutoFight, self.OnBtnAutoFightClick) + self:RegisterClickEvent(self.BtnAutoFightComplete, self.OnBtnAutoFightCompleteClick) +end +-- auto +function XUiFubenExtraChapterDetail:OnBtnEnterBClick() + self:OnBtnEnterClick() +end + +function XUiFubenExtraChapterDetail:OnBtnAutoFightClick() + XDataCenter.AutoFightManager.CheckOpenDialog(self.Stage.StageId, self.Stage) +end + +function XUiFubenExtraChapterDetail:OnBtnAutoFightCompleteClick() + local index = XDataCenter.AutoFightManager.GetIndexByStageId(self.Stage.StageId) + XDataCenter.AutoFightManager.ObtainRewards(index) +end + +function XUiFubenExtraChapterDetail:OnBtnCloseClick() + self:Hide() +end + +function XUiFubenExtraChapterDetail:OnBtnAddNumClick() + local challengeData = XDataCenter.FubenMainLineManager.GetStageBuyChallengeData(self.Stage.StageId) + XLuaUiManager.Open("UiBuyAsset", 1, function() + self:UpdateCommon() + end, challengeData) +end + +function XUiFubenExtraChapterDetail:OnBtnEnterClick() + if self.IsPlaying then + return + end + + if self.Stage == nil then + XLog.Error("XUiFubenExtraChapterDetail.OnBtnEnterClick: Can not find stage!") + return + end + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_FUBEN_ENTERFIGHT, self.Stage) +end + +function XUiFubenExtraChapterDetail:Hide() + if self.IsPlaying or not self.IsOpen then + return + end + + self.IsPlaying = true + self:PlayAnimation("AnimEnd", handler(self, function() + if XTool.UObjIsNil(self.GameObject) then + return + end + self.IsPlaying = false + self:Close() + end)) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_FUBEN_CLOSE_FUBENSTAGEDETAIL) +end + +function XUiFubenExtraChapterDetail:Refresh(stage) + self.Stage = stage or self.Stage + self:UpdateCommon() + self:UpdateRewards() + self:UpdateDifficulty() + self:UpdateStageFightControl()--更新战力限制提示 +end + +function XUiFubenExtraChapterDetail:UpdateCommon() + local stageCfg = XDataCenter.FubenManager.GetStageCfg(self.Stage.StageId) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(self.Stage.StageId) + local stageTitle = XDataCenter.ExtraChapterManager.GetChapterDetailsStageTitle(stageInfo.ChapterId) + self.TxtTitle.text = stageTitle .. "-" .. stageCfg.OrderId .. self.Stage.Name + self.TxtDesc.text = self.Stage.Description + self.TxtATNums.text = self.Stage.RequireActionPoint + + local maxChallengeNum = XDataCenter.FubenManager.GetStageMaxChallengeNums(self.Stage.StageId) + local buyChallengeCount = XDataCenter.FubenManager.GetStageBuyChallengeCount(self.Stage.StageId) + + self.PanelNums.gameObject:SetActive(maxChallengeNum > 0) + self.PanelNoLimitCount.gameObject:SetActive(maxChallengeNum <= 0) + self.BtnAddNum.gameObject:SetActive(buyChallengeCount > 0) + local showAutoFightBtn = false + if stageCfg.AutoFightId > 0 then + local record = XDataCenter.AutoFightManager.GetRecordByStageId(self.Stage.StageId) + if record then + local now = XTime.GetServerNowTimestamp() + if now >= record.CompleteTime then + self:SetAutoFightState(XDataCenter.AutoFightManager.State.Complete) + else + self:SetAutoFightState(XDataCenter.AutoFightManager.State.Fighting) + end + showAutoFightBtn = true + else + local autoFightAvailable = XDataCenter.AutoFightManager.CheckAutoFightAvailable(self.Stage.StageId) == XCode.Success + if autoFightAvailable then + self:SetAutoFightState(XDataCenter.AutoFightManager.State.None) + showAutoFightBtn = true + end + end + end + self:SetAutoFightActive(showAutoFightBtn) + + if maxChallengeNum > 0 then + local stageData = XDataCenter.FubenManager.GetStageData(self.Stage.StageId) + local chanllengeNum = stageData and stageData.PassTimesToday or 0 + self.TxtAllNums.text = "/" .. maxChallengeNum + self.TxtLeftNums.text = maxChallengeNum - chanllengeNum + end + + local firstDrop = false + if not stageInfo.Passed then + local cfg = XDataCenter.FubenManager.GetStageLevelControl(self.Stage.StageId) + if cfg and cfg.FirstRewardShow > 0 or self.Stage.FirstRewardShow > 0 then + firstDrop = true + end + end + self.TxtFirstDrop.gameObject:SetActive(firstDrop) + self.TxtDrop.gameObject:SetActive(not firstDrop) + + for i = 1, 3 do + self.GridStarList[i]:Refresh(self.Stage.StarDesc[i], stageInfo.StarsMap[i]) + end +end + +function XUiFubenExtraChapterDetail:UpdateDifficulty() + local nanDuIcon = XDataCenter.FubenManager.GetDifficultIcon(self.Stage.StageId) + self.RImgNandu:SetRawImage(nanDuIcon) +end + +function XUiFubenExtraChapterDetail:UpdateRewards() + local stage = self.Stage + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stage.StageId) + + -- 获取显示奖励Id + local rewardId = 0 + local IsFirst = false + local cfg = XDataCenter.FubenManager.GetStageLevelControl(stage.StageId) + if not stageInfo.Passed then + rewardId = cfg and cfg.FirstRewardShow or stage.FirstRewardShow + if cfg and cfg.FirstRewardShow > 0 or stage.FirstRewardShow > 0 then + IsFirst = true + end + end + if rewardId == 0 then + rewardId = cfg and cfg.FinishRewardShow or stage.FinishRewardShow + end + if rewardId == 0 then + for j = 1, #self.GridList do + self.GridList[j].GameObject:SetActive(false) + end + return + end + + local rewards = IsFirst and XRewardManager.GetRewardList(rewardId) or XRewardManager.GetRewardListNotCount(rewardId) + if rewards then + for i, item in ipairs(rewards) do + local grid + if self.GridList[i] then + grid = self.GridList[i] + else + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommon) + grid = XUiGridCommon.New(self, ui) + grid.Transform:SetParent(self.PanelDropContent, false) + self.GridList[i] = grid + end + grid:Refresh(item) + grid.GameObject:SetActive(true) + end + end + + local rewardsCount = 0 + if rewards then + rewardsCount = #rewards + end + + for j = 1, #self.GridList do + if j > rewardsCount then + self.GridList[j].GameObject:SetActive(false) + end + end +end + +function XUiFubenExtraChapterDetail:UpdateStageFightControl() + local stageInfo = XDataCenter.FubenManager.GetStageInfo(self.Stage.StageId) + if self.StageFightControl == nil then + self.StageFightControl = XUiStageFightControl.New(self.PanelStageFightControl, self.Stage.FightControlId) + end + if not stageInfo.Passed and stageInfo.Unlock then + self.StageFightControl.GameObject:SetActive(true) + self.StageFightControl:UpdateInfo(self.Stage.FightControlId) + else + self.StageFightControl.GameObject:SetActive(false) + end +end + +function XUiFubenExtraChapterDetail:SetAutoFightActive(value) + self.PanelAutoFightButton.gameObject:SetActive(value) + self.BtnEnter.gameObject:SetActive(not value) +end + +function XUiFubenExtraChapterDetail:SetAutoFightState(value) + local state = XDataCenter.AutoFightManager.State + self.BtnAutoFight.gameObject:SetActive(value == state.None) + self.ImgAutoFighting.gameObject:SetActive(value == state.Fighting) + self.BtnAutoFightComplete.gameObject:SetActive(value == state.Complete) +end + +function XUiFubenExtraChapterDetail:OnAutoFightStart(stageId) + if self.Stage.StageId == stageId then + self.ParentUi:CloseStageDetail() + end +end + +function XUiFubenExtraChapterDetail:OnAutoFightRemove(stageId) + if self.Stage.StageId == stageId then + self:SetAutoFightState(XDataCenter.AutoFightManager.State.None) + end +end + +function XUiFubenExtraChapterDetail:OnAutoFightComplete(stageId) + if self.Stage.StageId == stageId then + self:SetAutoFightState(XDataCenter.AutoFightManager.State.Complete) + end +end + +function XUiFubenExtraChapterDetail:AddEventListener() + XEventManager.AddEventListener(XEventId.EVENT_AUTO_FIGHT_START, self.OnAutoFightStart, self) + XEventManager.AddEventListener(XEventId.EVENT_AUTO_FIGHT_REMOVE, self.OnAutoFightRemove, self) + XEventManager.AddEventListener(XEventId.EVENT_AUTO_FIGHT_COMPLETE, self.OnAutoFightComplete, self) +end + +function XUiFubenExtraChapterDetail:RemoveEventListener() + XEventManager.RemoveEventListener(XEventId.EVENT_AUTO_FIGHT_START, self.OnAutoFightStart, self) + XEventManager.RemoveEventListener(XEventId.EVENT_AUTO_FIGHT_REMOVE, self.OnAutoFightRemove, self) + XEventManager.RemoveEventListener(XEventId.EVENT_AUTO_FIGHT_COMPLETE, self.OnAutoFightComplete, self) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenFashionStory/XUiFashionStoryChapter.lua b/Resources/Scripts/XUi/XUiFubenFashionStory/XUiFashionStoryChapter.lua new file mode 100644 index 00000000..5904c68e --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenFashionStory/XUiFashionStoryChapter.lua @@ -0,0 +1,183 @@ +local XUiFashionStoryChapter = XClass(nil,"XUiFashionStoryChapter") + +local XUiGridFashionStoryStage = require("XUi/XUiFubenFashionStory/XUiGridFashionStoryStage") + +function XUiFashionStoryChapter:Ctor(ui,activityId) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.ActivityId = activityId + + self.LastOpenStage = nil + + self.StageItemList = {} -- 关卡数组 + self.LineItemList = {} -- 关卡线数组 + + self.StageClassList = {} -- 关卡类实例数组 + self.StageIdList = XFashionStoryConfigs.GetChapterStagesList(activityId) -- 关卡Id数组 + + XTool.InitUiObject(self) + self:InitComponent() +end + +function XUiFashionStoryChapter:InitComponent() + -- 保存关卡与关卡线物体 + self:FindItem("Stage%d", self.StageItemList) + self:FindItem("Line%d", self.LineItemList) + + -- 实例化关卡类 + local setLineCb = handler(self, self.SetLineActive) + for i, stageItem in ipairs(self.StageItemList) do + local stageClass = XUiGridFashionStoryStage.New(stageItem, i, setLineCb) + self.StageClassList[i] = stageClass + end + + self:LoadAllStages() +end + +--- +--- 寻找'PanelStageContent'下的 'itemName+index' 物体,并保存在'saveList' +function XUiFashionStoryChapter:FindItem(itemName, saveList) + local i = 1 + local item = self.PanelStageContent:Find(string.format(itemName, i)) + while item do + table.insert(saveList, item) + i = i + 1 + item = self.PanelStageContent:Find(string.format(itemName, i)) + end +end + +--- +--- 设置第 'index' 条关卡线的显隐 +function XUiFashionStoryChapter:SetLineActive(index, isActive) + local line = self.LineItemList[index - 1] + if line then + line.gameObject:SetActiveEx(isActive) + end +end + +--- +--- 关卡类根据 StageIdList 来加载对应的关卡预制 +function XUiFashionStoryChapter:LoadAllStages() + local stageClassNum = #self.StageClassList + local stageIdNum = #self.StageIdList + if stageIdNum > stageClassNum then + XLog.Error(string.format("XUiFashionStoryChapter:LoadAllStages函数错误,PanelStageContent下的关卡数量少于%s个", + stageIdNum)) + end + + -- 如果stageClassNum > stageIdNum,多余的stageClass会拿到空的stageId,然后隐藏关卡与线条 + for i, stageClass in ipairs(self.StageClassList) do + stageClass:LoadStagePrefab(self.ActivityId, self.StageIdList[i]) + end +end + + +--------------------------------------------------------刷新------------------------------------------------------------- + +function XUiFashionStoryChapter:Refresh(moveToLast) + for i, stageClass in ipairs(self.StageClassList) do + stageClass:Refresh() + local isOpen = stageClass:GetIsOpen() + if isOpen then + self.LastOpenStage = i + end + end + if self.PanelStageContentSizeFitter then + self.PanelStageContentSizeFitter:SetLayoutHorizontal() + end + if moveToLast then + self:MoveToLastStage() + end +end + +--- +--- 滑动到最后一个关卡 +function XUiFashionStoryChapter:MoveToLastStage() + if self.LastOpenStage then + local gridRect = self.StageItemList[self.LastOpenStage] + local diffX = gridRect.localPosition.x + self.PanelStageContent.localPosition.x + if diffX > CS.XResolutionManager.OriginWidth / 2 then + local tarPosX = (CS.XResolutionManager.OriginWidth / 4) - gridRect.localPosition.x + local tarPos = self.PanelStageContent.localPosition + tarPos.x = tarPosX + + XLuaUiManager.SetMask(true) + self.PanelStageList.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Unrestricted + + XUiHelper.DoMove(self.PanelStageContent, tarPos, XDataCenter.FubenMainLineManager.UiGridChapterMoveDuration, XUiHelper.EaseType.Sin, function() + XLuaUiManager.SetMask(false) + self.PanelStageList.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Elastic + end) + end + end +end + + +-------------------------------------------------------选择关卡---------------------------------------------------------- + +--- +--- 选择关卡 +function XUiFashionStoryChapter:SelectStage(stageId) + local index = self:FindStageIndex(stageId) + self:SetStageSelect(index, true) + self:PlayScrollViewMove(self.StageItemList[index]) +end + +--- +--- 得到关卡 'stageId' 的索引 +function XUiFashionStoryChapter:FindStageIndex(stageId) + for _, stageClass in ipairs(self.StageClassList) do + local classStageId = stageClass:GetStageId() + if classStageId == stageId then + return stageClass:GetIndex() + end + end +end + +--- +--- 滑动关卡列表,使选择的关卡到达合适位置 +function XUiFashionStoryChapter:PlayScrollViewMove(gridRect) + local diffX = gridRect.localPosition.x + self.PanelStageContent.localPosition.x + + if diffX < XDataCenter.FubenMainLineManager.UiGridChapterMoveMinX or diffX > XDataCenter.FubenMainLineManager.UiGridChapterMoveMaxX then + local tarPosX = XDataCenter.FubenMainLineManager.UiGridChapterMoveTargetX - gridRect.localPosition.x + local tarPos = self.PanelStageContent.localPosition + tarPos.x = tarPosX + + XLuaUiManager.SetMask(true) + self.PanelStageList.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Unrestricted + + XUiHelper.DoMove(self.PanelStageContent, tarPos, XDataCenter.FubenMainLineManager.UiGridChapterMoveDuration, XUiHelper.EaseType.Sin, function() + XLuaUiManager.SetMask(false) + end) + end +end + +--- +--- 取消选择关卡 +function XUiFashionStoryChapter:CancelSelectStage() + if self.SelectStageIndex then + self:SetStageSelect(self.SelectStageIndex, false) + self.SelectStageIndex = nil + end + self:EndScrollViewMove() +end + +--- +--- 结束关卡列表滑动 +function XUiFashionStoryChapter:EndScrollViewMove() + self.PanelStageList.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Elastic +end + +--- +--- 设置关卡的选择效果 +function XUiFashionStoryChapter:SetStageSelect(index, isActive) + if not self.StageClassList[index] then + XLog.Error(string.format("XUiFashionStoryChapter:SetStageSelect函数错误,没有第%s个关卡的类实例", tostring(index))) + return + end + self.StageClassList[index]:SetSelect(isActive) + self.SelectStageIndex = index +end + +return XUiFashionStoryChapter \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenFashionStory/XUiFashionStoryStageFightDetail.lua b/Resources/Scripts/XUi/XUiFubenFashionStory/XUiFashionStoryStageFightDetail.lua new file mode 100644 index 00000000..bf4eadd9 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenFashionStory/XUiFashionStoryStageFightDetail.lua @@ -0,0 +1,111 @@ +local XUiFashionStoryStageFightDetail = XLuaUiManager.Register(XLuaUi, "UiFashionStoryStageFightDetail") + +local MAX_STAR = 3 + +function XUiFashionStoryStageFightDetail:OnAwake() + self.StarGridList = {} + self.CommonGridList = {} + self.GridCommonList = {} + + self:InitComponent() + self:AddListener() +end + +function XUiFashionStoryStageFightDetail:OnStart(closeParentCb) + self.CloseParentCb = closeParentCb +end + +function XUiFashionStoryStageFightDetail:InitComponent() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, + XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint) + + for i = 1, MAX_STAR do + self.StarGridList[i] = XUiGridStageStar.New(self[string.format("GridStageStar%d", i)]) + end + + self.GridCommon.gameObject:SetActiveEx(false) +end + + +-----------------------------------------------按钮响应函数--------------------------------------------------------------- + +function XUiFashionStoryStageFightDetail:AddListener() + self.BtnEnter.CallBack = function() + self:OnBtnEnterClick() + end +end + +function XUiFashionStoryStageFightDetail:OnBtnEnterClick() + local leftTimeStamp = XDataCenter.FashionStoryManager.GetLeftTimeStamp(self.ActivityId) + if leftTimeStamp <= 0 then + XUiManager.TipText("FashionStoryActivityEnd") + self.CloseParentCb() + return + end + + local stageCfg = XDataCenter.FubenManager.GetStageCfg(self.StageId) + if XDataCenter.FubenManager.CheckPreFight(stageCfg) then + XEventManager.DispatchEvent(XEventId.EVENT_FASHION_STORY_CLOSE_STAGE_DETAIL) + XLuaUiManager.Open("UiNewRoomSingle", self.StageId) + end +end + + +---------------------------------------------------刷新------------------------------------------------------------------ + +function XUiFashionStoryStageFightDetail:Refresh(stageId, activityId) + self.StageId = stageId + self.ActivityId = activityId + + -- 名称 + self.TxtTitle.text = XDataCenter.FubenManager.GetStageName(stageId) + + -- 关卡通关描述 + local starDescList = XFubenConfigs.GetStarDesc(stageId) + for i = 1, MAX_STAR do + self.StarGridList[i]:Refresh(starDescList[i], false) + end + + self:UpdateRewards() +end + +--- +--- 刷新掉落奖励 +function XUiFashionStoryStageFightDetail:UpdateRewards() + local rewardId = XFubenConfigs.GetFirstRewardShow(self.StageId) + local rewardCount = 0 + + if rewardId > 0 then + local rewardsList = XRewardManager.GetRewardList(rewardId) + if not rewardsList then + return + end + rewardCount = #rewardsList + + local isPass = XDataCenter.FubenManager.CheckStageIsPass(self.StageId) + for i = 1, rewardCount do + local reward = self.GridCommonList[i] + if not reward then + local obj = CS.UnityEngine.Object.Instantiate(self.GridCommon, self.PanelDropContent) + reward = XUiGridCommon.New(self, obj) + table.insert(self.GridCommonList, reward) + end + local temp = { ShowReceived = isPass } + reward:Refresh(rewardsList[i], temp) + end + end + + -- 隐藏多余的奖励格子 + local gridCommonCount = #self.GridCommonList + if gridCommonCount > rewardCount then + for j = rewardCount + 1, gridCommonCount do + self.GridCommonList[j]:Refresh() + end + end +end + +function XUiFashionStoryStageFightDetail:CloseDetailWithAnimation() + self:PlayAnimation("AnimClose", function() + self:Close() + end) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenFashionStory/XUiFashionStoryStageStoryDetail.lua b/Resources/Scripts/XUi/XUiFubenFashionStory/XUiFashionStoryStageStoryDetail.lua new file mode 100644 index 00000000..ca3996d7 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenFashionStory/XUiFashionStoryStageStoryDetail.lua @@ -0,0 +1,95 @@ +local XUiFashionStoryStageStoryDetail = XLuaUiManager.Register(XLuaUi, "UiFashionStoryStageStoryDetail") + +function XUiFashionStoryStageStoryDetail:OnAwake() + self:InitComponent() + self:AddListener() +end + +function XUiFashionStoryStageStoryDetail:OnStart(closeParentCb) + self.CloseParentCb = closeParentCb +end + +function XUiFashionStoryStageStoryDetail:InitComponent() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, + XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint) +end + + +-----------------------------------------------按钮响应函数--------------------------------------------------------------- + +function XUiFashionStoryStageStoryDetail:AddListener() + self.BtnEnter.CallBack = function() + self:OnBtnEnterClick() + end +end + +function XUiFashionStoryStageStoryDetail:OnBtnEnterClick() + local leftTimeStamp = XDataCenter.FashionStoryManager.GetLeftTimeStamp(self.ActivityId) + if leftTimeStamp <= 0 then + XUiManager.TipText("FashionStoryActivityEnd") + self.CloseParentCb() + return + end + + local beginStoryId = XFubenConfigs.GetBeginStoryId(self.StageId) + if not beginStoryId then + XLog.Error(string.format("XUiFashionStoryStageStoryDetail:OnBtnEnterClick函数错误,关卡:%s的剧情Id为空", + tostring(self.StageId))) + return + end + + local playStory = function(isPassed) + XDataCenter.MovieManager.PlayMovie(beginStoryId, function() + if isPassed then + -- 非首次通关,关闭关卡详情 + XEventManager.DispatchEvent(XEventId.EVENT_FASHION_STORY_CLOSE_STAGE_DETAIL) + else + -- 首次通关,刷新关卡并移动到最后一关 + XEventManager.DispatchEvent(XEventId.EVENT_FASHION_STORY_CHAPTER_REFRESH, true) + end + end) + self:Close() + end + + local isPassed = XDataCenter.FubenManager.CheckStageIsPass(self.StageId) + if isPassed then + playStory(true) + else + XDataCenter.FubenManager.FinishStoryRequest(self.StageId, function() + XDataCenter.FashionStoryManager.RefreshStagePassedBySettleData({ StageId = self.StageId }) + XEventManager.DispatchEvent(XEventId.EVENT_FASHION_STORY_CLOSE_STAGE_DETAIL) + playStory(false) + end) + end +end + + +-----------------------------------------------------刷新--------------------------------------------------------------- + +function XUiFashionStoryStageStoryDetail:Refresh(stageId, activityId) + self.StageId = stageId + self.ActivityId = activityId + + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + self.TxtTitle.text = stageCfg.Name + self.TxtStoryDes.text = stageCfg.Description + + local titleBg = XFashionStoryConfigs.GetStoryStageDetailBg(stageId) + local enterIcon = XFashionStoryConfigs.GetStoryStageDetailIcon(stageId) + if titleBg then + self.RImgTitleBg:SetRawImage(titleBg) + else + self.RImgTitleBg.gameObject:SetActiveEx(false) + end + if enterIcon then + self.RImgNandu:SetRawImage(enterIcon) + else + self.RImgNandu.gameObject:SetActiveEx(false) + end +end + +function XUiFashionStoryStageStoryDetail:CloseDetailWithAnimation() + self:PlayAnimation("AnimClose", function() + self:Close() + end) +end diff --git a/Resources/Scripts/XUi/XUiFubenFashionStory/XUiFashionStoryStageTrialDetail.lua b/Resources/Scripts/XUi/XUiFubenFashionStory/XUiFashionStoryStageTrialDetail.lua new file mode 100644 index 00000000..1222f484 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenFashionStory/XUiFashionStoryStageTrialDetail.lua @@ -0,0 +1,101 @@ +local XUiFashionStoryStageTrialDetail = XLuaUiManager.Register(XLuaUi, "UiFashionStoryStageTrialDetail") + +function XUiFashionStoryStageTrialDetail:OnAwake() + self.RewardList = {} + self:AddListener() +end + +function XUiFashionStoryStageTrialDetail:OnStart(closeParentCb,CloseTrialDetailCb) + self.CloseParentCb = closeParentCb + self.CloseTrialDetailCb = CloseTrialDetailCb +end + +function XUiFashionStoryStageTrialDetail:AddListener() + self.BtnBack.CallBack = function() + self.CloseTrialDetailCb() + self:Close() + end + self.BtnMainUi.CallBack = function() + XLuaUiManager.RunMain() + end + self.BtnEnter.CallBack = function() + self:OnBtnEnterClick() + end +end + +function XUiFashionStoryStageTrialDetail:OnBtnEnterClick() + local leftTimeStamp = XDataCenter.FashionStoryManager.GetLeftTimeStamp(self.ActivityId) + if leftTimeStamp <= 0 then + XUiManager.TipText("FashionStoryActivityEnd") + self.CloseParentCb() + return + end + + local isInTime = XDataCenter.FashionStoryManager.IsTrialStageInTime(self.StageId) + if isInTime then + XLuaUiManager.Open("UiNewRoomSingle", self.StageId) + else + XUiManager.TipText("FashionStoryTrialStageEnd") + end +end + +function XUiFashionStoryStageTrialDetail:Refresh(activityId, stageId) + self.ActivityId = activityId + self.StageId = stageId + + -- 图标 + self.RImgNandu:SetRawImage(XFashionStoryConfigs.GetTrialDetailHeadIcon(stageId)) + + -- 名称 + self.TxtTitle.text = XFubenConfigs.GetStageName(stageId) + + -- 推荐等级 + self.TxtRecommendLevel.text = XFashionStoryConfigs.GetTrialDetailRecommendLevel(stageId) + + -- 背景 + self.ImgFullScreen.gameObject:SetActiveEx(true) + self.PanelSpine.gameObject:SetActiveEx(false) + local spine = XFashionStoryConfigs.GetTrialDetailSpine(stageId) + if spine then + self.PanelSpine.gameObject:SetActiveEx(true) + self.PanelSpine.gameObject:LoadSpinePrefab(spine) + else + self.ImgFullScreen.gameObject:SetActiveEx(true) + self.ImgFullScreen:SetRawImage(XFashionStoryConfigs.GetTrialDetailBg(stageId)) + end + + -- 描述 + self.TxtDes.text = string.gsub(XFashionStoryConfigs.GetTrialDetailDesc(stageId), "\\n", "\n") + + -- 奖励 + local rewardId = XFubenConfigs.GetFirstRewardShow(self.StageId) + local rewardCount = 0 + + if rewardId > 0 then + local rewardsList = XRewardManager.GetRewardList(rewardId) + if not rewardsList then + return + end + rewardCount = #rewardsList + + local isPass = XDataCenter.FubenManager.CheckStageIsPass(self.StageId) + for i = 1, rewardCount do + local reward = self.RewardList[i] + if not reward then + local obj = CS.UnityEngine.Object.Instantiate(self.GridCommon, self.PanelDropContent) + reward = XUiGridCommon.New(self, obj) + table.insert(self.RewardList, reward) + end + local temp = { ShowReceived = isPass } + reward:Refresh(rewardsList[i], temp) + end + end + + -- 隐藏多余的奖励格子 + local gridCommonCount = #self.RewardList + if gridCommonCount > rewardCount then + for j = rewardCount + 1, gridCommonCount do + self.RewardList[j]:Refresh() + end + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenFashionStory/XUiFubenFashionStory.lua b/Resources/Scripts/XUi/XUiFubenFashionStory/XUiFubenFashionStory.lua new file mode 100644 index 00000000..d219cb72 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenFashionStory/XUiFubenFashionStory.lua @@ -0,0 +1,421 @@ +local XUiFubenFashionStory = XLuaUiManager.Register(XLuaUi, "UiFubenFashionStory") + +local XUiFashionStoryChapter = require("XUi/XUiFubenFashionStory/XUiFashionStoryChapter") +local XUiGridFashionStoryTrial = require("XUi/XUiFubenFashionStory/XUiGridFashionStoryTrial") + +local FIGHT_DETAIL = "UiFashionStoryStageFightDetail" +local STORY_DETAIL = "UiFashionStoryStageStoryDetail" +local TRIAL_DETAIL = "UiFashionStoryStageTrialDetail" + +local CurrentSchedule + +function XUiFubenFashionStory:OnAwake() + self.BtnSkipList = {} + self.TimerFunctions = {} + self.MoveToLast = true + + self:InitComponent() + self:AddListener() +end + +function XUiFubenFashionStory:OnStart(activityId,trialStageId) + self.TrialStageId = trialStageId + self:LoadActivity(activityId) +end + +function XUiFubenFashionStory:OnEnable() + XEventManager.AddEventListener(XEventId.EVENT_FASHION_STORY_CHAPTER_REFRESH, self.Refresh, self) + XEventManager.AddEventListener(XEventId.EVENT_FASHION_STORY_TRIAL_REFRESH, self.RefreshTrial, self) + + XEventManager.AddEventListener(XEventId.EVENT_FASHION_STORY_OPEN_STAGE_DETAIL, self.OpenStageDetail, self) + XEventManager.AddEventListener(XEventId.EVENT_FASHION_STORY_CLOSE_STAGE_DETAIL, self.CloseStageDetail, self) + XEventManager.AddEventListener(XEventId.EVENT_FASHION_STORY_OPEN_TRIAL_DETAIL, self.OpenTrialDetail, self) + + self:Refresh(self.MoveToLast) + self:RefreshLeftTime() +end + +function XUiFubenFashionStory:OnDisable() + XEventManager.RemoveEventListener(XEventId.EVENT_FASHION_STORY_CHAPTER_REFRESH, self.Refresh, self) + XEventManager.RemoveEventListener(XEventId.EVENT_FASHION_STORY_TRIAL_REFRESH, self.RefreshTrial, self) + + XEventManager.RemoveEventListener(XEventId.EVENT_FASHION_STORY_OPEN_STAGE_DETAIL, self.OpenStageDetail, self) + XEventManager.RemoveEventListener(XEventId.EVENT_FASHION_STORY_CLOSE_STAGE_DETAIL, self.CloseStageDetail, self) + XEventManager.RemoveEventListener(XEventId.EVENT_FASHION_STORY_OPEN_TRIAL_DETAIL, self.OpenTrialDetail, self) + + self:RemoveTimerFun(self.ActivityId) + + -- 首次打开界面、通关关卡时才会自动移动到最后一关 + self.MoveToLast = false +end + +function XUiFubenFashionStory:OnDestroy() + self.Type = nil + self.Mode = nil + self.ActivityId = nil + self:DestroyTimer() +end + +function XUiFubenFashionStory:InitComponent() + self.BtnCloseDetail.gameObject:SetActiveEx(false) + self.GridTrial.gameObject:SetActiveEx(false) + + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, + XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + + -- 保存章节关的跳转按钮 + local index = 1 + while true do + local btnSkip = self[string.format("BtnSkip%s", tostring(index))] + if not btnSkip then + break + end + btnSkip = btnSkip.transform:GetComponent("Button") + self.BtnSkipList[index] = btnSkip + index = index + 1 + end + + self:InitDynamicTable() + self:StartTimer() +end + +function XUiFubenFashionStory:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelTrialList) + self.DynamicTable:SetProxy(XUiGridFashionStoryTrial, self) + self.DynamicTable:SetDelegate(self) +end + +function XUiFubenFashionStory:AddListener() + self.BtnBack.CallBack = function() + self:OnBtnBackClick() + end + self.BtnMainUi.CallBack = function() + self:OnBtnMainUiClick() + end + self.BtnCloseDetail.CallBack = function() + self:CloseStageDetail() + end +end + +function XUiFubenFashionStory:OnBtnBackClick() + if XLuaUiManager.IsUiShow(FIGHT_DETAIL) or XLuaUiManager.IsUiShow(STORY_DETAIL) then + self:CloseStageDetail() + else + if self.Mode == XFashionStoryConfigs.Mode.Chapter then + self:OnBtnSwitchClick(XFashionStoryConfigs.Mode.Trial) + else + self:Close() + end + end + +end + +function XUiFubenFashionStory:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiFubenFashionStory:OnBtnSwitchClick(mode) + self:SetMode(mode) + self:Refresh(false) +end + + +------------------------------------------------------初始化加载---------------------------------------------------------- + +--- +--- 加载 'activityId' 活动,并设置类型与初始模式 +function XUiFubenFashionStory:LoadActivity(activityId) + self.ActivityId = activityId + + local type = XDataCenter.FashionStoryManager.GetType(activityId) + self:SetType(type) + + local initMode + if type == XFashionStoryConfigs.Type.OnlyTrial or type == XFashionStoryConfigs.Type.Both then + initMode = self.Mode or XFashionStoryConfigs.Mode.Trial + elseif type == XFashionStoryConfigs.Type.OnlyChapter then + initMode = self.Mode or XFashionStoryConfigs.Mode.Chapter + else + XLog.Error(string.format("XUiFubenFashionStory.LoadActivity函数错误,没有类型:%d的处理逻辑", type)) + return + end + + self:LoadChapter() + self:SetMode(initMode) +end + +--- +--- 设置活动类型,并设置模式切换按钮的显隐 +function XUiFubenFashionStory:SetType(type) + self.Type = type + local isBothMode = type == XFashionStoryConfigs.Type.Both + local isOnlyTrial = type == XFashionStoryConfigs.Type.OnlyTrial + self.PanelTrialLeftTime.gameObject:SetActiveEx(not isOnlyTrial) +end + +--- +--- 加载章节关 +function XUiFubenFashionStory:LoadChapter() + -- 处理跳转按钮 + local skipList = XFashionStoryConfigs.GetSkipIdList(self.ActivityId) + if not XTool.IsTableEmpty(skipList) then + for i, skipId in ipairs(skipList) do + + -- 是否有对应的跳转按钮 + local btn = self.BtnSkipList[i] + if not btn then + XLog.Error(string.format("XUiFubenFashionStory.LoadChapter函数错误,FashionStory:%s 预制界面的跳转按钮不足,第%s个跳转:%s 与后面配置的跳转无法生效", + tostring(self.ActivityId), tostring(i), tostring(skipId))) + break + end + + -- 添加跳转逻辑 + btn.CallBack = function() + XFunctionManager.SkipInterface(skipId) + end + btn.gameObject:SetActiveEx(true) + btn:SetName(XFunctionConfig.GetExplain(skipId)) + end + end + + -- 隐藏多余的跳转按钮 + if #self.BtnSkipList > #skipList then + for i = #skipList + 1, #self.BtnSkipList do + self.BtnSkipList[i].gameObject:SetActiveEx(false) + end + end + + -- 预制体 + local prefabPath = XFashionStoryConfigs.GetChapterPrefab(self.ActivityId) + if prefabPath then + local go = self.PanelChapterContent:LoadPrefab(prefabPath) + self.ChapterContent = XUiFashionStoryChapter.New(go, self.ActivityId) + end +end + + +------------------------------------------------------切换模式------------------------------------------------------------ + +--- +--- 切换到 'mode' 模式,显示对应模式的面板 +function XUiFubenFashionStory:SetMode(mode) + if (self.Type == XFashionStoryConfigs.Type.OnlyChapter and mode == XFashionStoryConfigs.Mode.Trial) + or (self.Type == XFashionStoryConfigs.Type.OnlyTrial and mode == XFashionStoryConfigs.Mode.Chapter) then + XLog.Error(string.format("XUiFubenFashionStory.SetMode函数错误,Type:%d与Mode:%s冲突", self.Type, mode)) + return + end + self.Mode = mode + self:ShowPanelByMode() +end + +--- +--- 根据Self.Mode显示对应的面板 +function XUiFubenFashionStory:ShowPanelByMode() + local bg + if self.Mode == XFashionStoryConfigs.Mode.Chapter then + self.PanelChapter.gameObject:SetActiveEx(true) + self.PanelTrial.gameObject:SetActiveEx(false) + bg = XFashionStoryConfigs.GetChapterBg(self.ActivityId) + elseif self.Mode == XFashionStoryConfigs.Mode.Trial then + self.PanelChapter.gameObject:SetActiveEx(false) + self.PanelTrial.gameObject:SetActiveEx(true) + bg = XFashionStoryConfigs.GetTrialBg(self.ActivityId) + else + XLog.Error(string.format("XUiFubenFashionStory.ShowPanelByMode函数错误,没有模式:%d的处理逻辑", self.Mode)) + return + end + + if bg then + self.RImgFestivalBg:SetRawImage(bg) + end +end + + +-------------------------------------------------------界面刷新----------------------------------------------------------- + +--- +--- 根据self.Mode刷新对应面板, 'moveToLast' 是否移动到最后一关 +function XUiFubenFashionStory:Refresh(moveToLast) + if self.Mode == XFashionStoryConfigs.Mode.Chapter then + -- 通关进度 + local passNum, totalNum = XDataCenter.FashionStoryManager.GetChapterProgress(self.ActivityId) + self.TxtCurProgress.text = passNum + self.TxtTotalProgress.text = totalNum + -- 章节预制 + if self.ChapterContent then + self.ChapterContent:Refresh(moveToLast) + end + elseif self.Mode == XFashionStoryConfigs.Mode.Trial then + self:RefreshTrial() + else + XLog.Error(string.format("XUiFubenFashionStory.Refresh函数错误,没有模式:%s的处理逻辑", tostring(self.Mode))) + return + end +end + +--- +--- 刷新试玩关 +function XUiFubenFashionStory:RefreshTrial() + self.DataSource = XDataCenter.FashionStoryManager.GetActiveTrialStage(self.ActivityId) + + if XDataCenter.FashionStoryManager.IsStoryInTime(self.ActivityId) then + -- 剧情模式处于开放时间,插入模式入口 + table.insert(self.DataSource, 1, XFashionStoryConfigs.StoryEntranceId) + end + + for i, v in pairs(self.DataSource) do + if self.TrialStageId == v then + self.SelectIndex = i + break + end + end + self.DynamicTable:SetDataSource(self.DataSource) + self.DynamicTable:ReloadDataSync(self.SelectIndex) +end + +--- +--- 动态列表事件 +function XUiFubenFashionStory:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + if self.DataSource[index] == XFashionStoryConfigs.StoryEntranceId then + grid:Refresh(self.DataSource[index], self.ActivityId, function() + self:OnBtnSwitchClick(XFashionStoryConfigs.Mode.Chapter) + self:PlayAnimation("PanelChapterEnable") + end) + else + grid:Refresh(self.DataSource[index]) + end + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + grid:OnClick() + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_RECYCLE then + grid:OnRecycle() + end +end + +--- +--- 刷新活动剩余时间 +function XUiFubenFashionStory:RefreshLeftTime() + local leftTimeStamp = XDataCenter.FashionStoryManager.GetLeftTimeStamp(self.ActivityId) + local refreshFunc = function() + leftTimeStamp = leftTimeStamp > 0 and leftTimeStamp or 0 + local timeStr = XUiHelper.GetTime(leftTimeStamp, XUiHelper.TimeFormatType.ACTIVITY) + if self.TxtTrialLeftTime and self.TxtChapterLeftTime then + self.TxtTrialLeftTime.text = timeStr + self.TxtChapterLeftTime.text = timeStr + end + + if leftTimeStamp <= 0 then + XUiManager.TipMsg(CSXTextManagerGetText("FashionStoryActivityEnd")) + self:RemoveTimerFun(self.ActivityId) + self:Close() + end + end + refreshFunc() + + -- 活动已结束 + if leftTimeStamp <= 0 then + return + end + self:RegisterTimerFun(self.ActivityId, function() + leftTimeStamp = leftTimeStamp - 1 + refreshFunc() + end) +end + + +-------------------------------------------------------计时器------------------------------------------------------------ + +function XUiFubenFashionStory:StartTimer() + self:DestroyTimer() + CurrentSchedule = XScheduleManager.ScheduleForever(function() + self:UpdateTimer() + end, 1000) +end + +function XUiFubenFashionStory:UpdateTimer() + if next(self.TimerFunctions) then + for _, timerFun in pairs(self.TimerFunctions) do + if timerFun then + timerFun() + end + end + end +end + +function XUiFubenFashionStory:RegisterTimerFun(id, fun) + self.TimerFunctions[id] = fun +end + +function XUiFubenFashionStory:RemoveTimerFun(id) + self.TimerFunctions[id] = nil +end + +function XUiFubenFashionStory:DestroyTimer() + if CurrentSchedule then + XScheduleManager.UnSchedule(CurrentSchedule) + CurrentSchedule = nil + self.TimerFunctions = {} + end +end + + +-------------------------------------------------------关卡相关----------------------------------------------------------- + +--- +--- 打开章节关卡详情 +function XUiFubenFashionStory:OpenStageDetail(stageId) + -- 选择关卡 + self.ChapterContent:SelectStage(stageId) + + local detailType + local stageType = XFubenConfigs.GetStageType(stageId) + if stageType == XFubenConfigs.STAGETYPE_FIGHT or stageType == XFubenConfigs.STAGETYPE_FIGHTEGG + or stageType == XFubenConfigs.STAGETYPE_COMMON then + detailType = FIGHT_DETAIL + elseif stageType == XFubenConfigs.STAGETYPE_STORY or stageType == XFubenConfigs.STAGETYPE_STORYEGG then + detailType = STORY_DETAIL + else + XLog.Error(string.format("XUiPartnerTeachingChapter.OpenStageDetail函数错误,没有对应StageType的处理逻辑,关卡:%s,StageType:%s", + stageId, stageType)) + return + end + self:OpenOneChildUi(detailType, handler(self, self.Close)) + self:FindChildUiObj(detailType):Refresh(stageId, self.ActivityId) + self.BtnCloseDetail.gameObject:SetActiveEx(true) +end + +--- +--- 关闭章节关卡详情 +function XUiFubenFashionStory:CloseStageDetail() + -- 取消关卡选择 + self.ChapterContent:CancelSelectStage() + + if XLuaUiManager.IsUiShow(FIGHT_DETAIL) then + self:FindChildUiObj(FIGHT_DETAIL):CloseDetailWithAnimation() + end + if XLuaUiManager.IsUiShow(STORY_DETAIL) then + self:FindChildUiObj(STORY_DETAIL):CloseDetailWithAnimation() + end + + self.BtnCloseDetail.gameObject:SetActiveEx(false) +end + +--- +--- 打开试玩关卡详情 +function XUiFubenFashionStory:OpenTrialDetail(stageId) + self:OpenOneChildUi(TRIAL_DETAIL, handler(self, self.Close),handler(self,self.CloseTrialDetailCb)) + self:FindChildUiObj(TRIAL_DETAIL):Refresh(self.ActivityId, stageId) + self.PanelEffect.gameObject:SetActiveEx(false) +end + +function XUiFubenFashionStory:CloseTrialDetailCb() + self.PanelEffect.gameObject:SetActiveEx(true) +end + +function XUiFubenFashionStory:OnReleaseInst() + return self.Mode +end + +function XUiFubenFashionStory:OnResume(mode) + self.Mode = mode +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenFashionStory/XUiGridFashionStoryStage.lua b/Resources/Scripts/XUi/XUiFubenFashionStory/XUiGridFashionStoryStage.lua new file mode 100644 index 00000000..d3dd5a5d --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenFashionStory/XUiGridFashionStoryStage.lua @@ -0,0 +1,112 @@ +local XUiGridFashionStoryStage = XClass(nil, "XUiGridFashionStoryStage") + +function XUiGridFashionStoryStage:Ctor(ui, index, setLineCb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Index = index + self.SetLineCb = setLineCb + self.IsOpen = false +end + +--- +--- 加载关卡预制体 +function XUiGridFashionStoryStage:LoadStagePrefab(activityId, stageId) + if activityId and stageId then + self.ActivityId = activityId + self.StageId = stageId + local prefabName + local stageType = XFubenConfigs.GetStageType(stageId) + + -- 选择对应StageType的关卡预制体 + if stageType == XFubenConfigs.STAGETYPE_FIGHT or stageType == XFubenConfigs.STAGETYPE_FIGHTEGG + or stageType == XFubenConfigs.STAGETYPE_COMMON then + prefabName = XFashionStoryConfigs.GetChapterFightStagePrefab(activityId) + elseif stageType == XFubenConfigs.STAGETYPE_STORY or stageType == XFubenConfigs.STAGETYPE_STORYEGG then + prefabName = XFashionStoryConfigs.GetChapterStoryStagePrefab(activityId) + else + XLog.Error(string.format("XUiGridFashionStoryStage.LoadStagePrefab函数错误,没有对应StageType的处理逻辑,关卡:%s,StageType:%s", stageId, stageType)) + return + end + self.StagePrefab = self.Transform:LoadPrefab(prefabName) + + -- 加载关卡预制体的UiObject + local uiObj = self.StagePrefab.transform:GetComponent("UiObject") + for i = 0, uiObj.NameList.Count - 1 do + self[uiObj.NameList[i]] = uiObj.ObjList[i] + end + -- 卡关图标 + if self.RImgBg then + self.RImgBg:SetRawImage(XFubenConfigs.GetStageIcon(self.StageId)) + end + -- 注册关卡点击响应函数 + if self.BtnStage then + self.BtnStage.CallBack = function() + self:OnBtnStageClick() + end + end + else + self.ActivityId = nil + self.StageId = nil + end +end + + +--------------------------------------------------------刷新------------------------------------------------------------- + +function XUiGridFashionStoryStage:Refresh() + if self.ActivityId and self.StageId then + self.IsOpen = XDataCenter.FubenManager.CheckStageOpen(self.StageId) + self.IsUnlock = XDataCenter.FubenManager.CheckStageIsUnlock(self.StageId) + self.IsPassed = XDataCenter.FubenManager.CheckStageIsPass(self.StageId) + + -- 通关标志 + if self.PanelStagePass then + self.PanelStagePass.gameObject:SetActiveEx(self.IsPassed) + end + else + self.IsOpen = false + self.IsUnlock = false + end + + -- 设置关卡与关卡线条的显隐 + self.GameObject:SetActiveEx(self.IsOpen and self.IsUnlock) + self.SetLineCb(self.Index, self.IsOpen and self.IsUnlock) +end + + +-------------------------------------------------------选择关卡---------------------------------------------------------- + +function XUiGridFashionStoryStage:OnBtnStageClick() + if self.IsOpen and self.IsUnlock then + XEventManager.DispatchEvent(XEventId.EVENT_FASHION_STORY_OPEN_STAGE_DETAIL, self.StageId) + else + XUiManager.TipMsg(CSXTextManagerGetText("FubenNotUnlock")) + end +end + +--- +--- 是否显示选中框 +function XUiGridFashionStoryStage:SetSelect(isSelect) + self.ImageSelected.gameObject:SetActiveEx(isSelect) +end +------------------------------------------------------------------------------------------------------------------------ + +--- +--- 获取关卡索引 +function XUiGridFashionStoryStage:GetIndex() + return self.Index +end + +--- +--- 获取关卡Id +function XUiGridFashionStoryStage:GetStageId() + return self.StageId +end + +--- +--- 关卡是否开放 +function XUiGridFashionStoryStage:GetIsOpen() + return self.IsOpen and self.IsUnlock +end + +return XUiGridFashionStoryStage \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenFashionStory/XUiGridFashionStoryTrial.lua b/Resources/Scripts/XUi/XUiFubenFashionStory/XUiGridFashionStoryTrial.lua new file mode 100644 index 00000000..fbd89538 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenFashionStory/XUiGridFashionStoryTrial.lua @@ -0,0 +1,90 @@ +local XUiGridFashionStoryTrial = XClass(nil, "UiGridFashionStoryTrial") + +function XUiGridFashionStoryTrial:Ctor(ui, parent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Parent = parent + + XTool.InitUiObject(self) + self:AutoAddListener() +end + +function XUiGridFashionStoryTrial:Refresh(stageId, activityId, entranceCb) + if stageId == XFashionStoryConfigs.StoryEntranceId and activityId then + self.IsStoryEntrance = true + self.ActivityId = activityId + self.EntranceCb = entranceCb + else + self.IsStoryEntrance = false + self.ActivityId = nil + end + self.StageId = stageId + self.BtnSummer:SetRawImage(self.IsStoryEntrance and XFashionStoryConfigs.GetStoryEntranceBg(activityId) or XFubenConfigs.GetStageIcon(stageId)) + self.ImageStoryProcess:SetSprite(self.IsStoryEntrance and XFashionStoryConfigs.GetStoryEntranceFinishTag(activityId) or XFashionStoryConfigs.GetTrialFinishTag(stageId)) + if self.IsStoryEntrance then + local passNum, totalNum = XDataCenter.FashionStoryManager.GetChapterProgress(self.ActivityId) + self.TxtStoryProcessNumber.text= string.format("%d/%d",passNum, totalNum) + self.TxtStoryProcess.gameObject:SetActiveEx(true) + self.PanelPass.gameObject:SetActiveEx(false) + else + local isPassed = XDataCenter.FubenManager.CheckStageIsPass(self.StageId) + self.PanelPass.gameObject:SetActiveEx(isPassed) + self.TxtStoryProcess.gameObject:SetActiveEx(false) + end + + self:RefreshLeftTime() +end + +function XUiGridFashionStoryTrial:AutoAddListener() + self.BtnSummer.CallBack = function() + self:OnClick() + end +end + +function XUiGridFashionStoryTrial:OnClick() + if self.IsStoryEntrance then + self.EntranceCb() + else + XEventManager.DispatchEvent(XEventId.EVENT_FASHION_STORY_OPEN_TRIAL_DETAIL, self.StageId) + end +end + +function XUiGridFashionStoryTrial:RefreshLeftTime() + local leftTime + if self.IsStoryEntrance then + leftTime = XDataCenter.FashionStoryManager.GetStoryTimeStamp(self.ActivityId) + else + leftTime = XDataCenter.FashionStoryManager.GetTrialStageLeftTimeStamp(self.StageId) + end + + -- 刷新剩余时间 + local func = function() + leftTime = leftTime > 0 and leftTime or 0 + + local strTime = XUiHelper.GetTime(leftTime, XUiHelper.TimeFormatType.ACTIVITY) + if self.TxtLeftTime then + self.TxtLeftTime.text = CSXTextManagerGetText("FashionStoryTrialStageLeftTime", strTime) + end + + if leftTime <= 0 then + self:RemoveTimer() + XEventManager.DispatchEvent(XEventId.EVENT_FASHION_STORY_TRIAL_REFRESH) + end + end + + func() + self.Parent:RegisterTimerFun(self.StageId, function() + leftTime = leftTime - 1 + func() + end) +end + +function XUiGridFashionStoryTrial:OnRecycle() + self:RemoveTimer() +end + +function XUiGridFashionStoryTrial:RemoveTimer() + self.Parent:RemoveTimerFun(self.StageId) +end + +return XUiGridFashionStoryTrial \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenFlopReward/XUiFubenFlopReward.lua b/Resources/Scripts/XUi/XUiFubenFlopReward/XUiFubenFlopReward.lua new file mode 100644 index 00000000..3df850a8 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenFlopReward/XUiFubenFlopReward.lua @@ -0,0 +1,267 @@ +local XUiFubenFlopReward = XLuaUiManager.Register(XLuaUi, "UiFubenFlopReward") + +local PanelStatus = { + SelectTime = 0, + WaitForClose = 1 +} + +function XUiFubenFlopReward:OnAwake() + self:InitAutoScript() +end + +function XUiFubenFlopReward:OnStart(cb, winData) + self.Cb = cb + self.WinData = winData + self.Animation = self.Transform:GetComponent("Animation") + self.PanelRewardBox.gameObject:SetActive(false) + self.RewardBox = {} + + local roomData = XDataCenter.RoomManager.RoomData + if roomData then + local levelControl = XDataCenter.FubenManager.GetStageMultiplayerLevelControl(roomData.StageId, roomData.StageLevel) + self.TxtDifficulty.text = string.format("(%s)", levelControl.DifficultyDesc) + end + + self:InitRewardBox() + self.Selected = false + self.Status = PanelStatus.SelectTime + self:StartTimer() + self.SelectedPlayerId = {} + self.SelectedPos = {} + for _, v in pairs(self.WinData.FlopRewardList) do + if v.PlayerId and v.PlayerId ~= 0 then + self.SelectedPlayerId[v.PlayerId] = false + end + end + + XEventManager.AddEventListener(XEventId.EVENT_ONLINEBOSS_DROPREWARD_NOTIFY, self.OnDropReaward, self) +end + +function XUiFubenFlopReward:OnEnable() + for _, v in pairs(self.RewardBox) do + v:OnEnable() + end +end + +function XUiFubenFlopReward:OnDisable() + for _, v in pairs(self.RewardBox) do + v:OnDisable() + end +end + +function XUiFubenFlopReward:CheckAllSelected() + for _, v in pairs(self.SelectedPlayerId) do + if not v then + return false + end + end + return true +end + +--选取奖励推送 +function XUiFubenFlopReward:OnDropReaward(dropData) + if not self.RewardBox then + return + end + + local pos = dropData.Pos + local playerId = dropData.PlayerId + local flopRewardList = self.WinData.FlopRewardList + + if playerId == XPlayer.Id then + self.Animation:Stop() + self.Selected = true + self.TxtDesc.color = CS.UnityEngine.Color(1, 1, 1, 1) + self.TxtDesc.text = CS.XTextManager.GetText("FlopRewardWait") + end + + self.SelectedPlayerId[playerId] = true + + for _, v in pairs(flopRewardList) do + if v and playerId == v.PlayerId then + self.RewardBox[pos]:Refresh(v) + self.SelectedPos[pos] = true + break + end + end + + if self:CheckAllSelected() then + self:AutoDrawReward() + end +end + +--自动选择奖励 +function XUiFubenFlopReward:AutoDrawReward() + self.Animation:Stop() + self.Selected = true + self.TotalTime = CS.XGame.Config:GetFloat("FlopRewardCloseTime") + self.Time = self.TotalTime + self.StartTicks = CS.XTimerManager.Ticks + + self.TxtDesc.text = CS.XTextManager.GetText("FlopRewardWaitClose") + self.Status = PanelStatus.WaitForClose + self.TxtDesc.color = CS.UnityEngine.Color(1, 1, 1, 1) + + local flopRewardList = self.WinData.FlopRewardList + if not flopRewardList then + return + end + + for _, var in pairs(flopRewardList) do + if not self.SelectedPlayerId[var.PlayerId] then + for k, v in pairs(self.RewardBox) do + if var and not self.SelectedPos[k] then + v:Refresh(var) + self.SelectedPos[k] = true + break + end + end + end + end +end + +function XUiFubenFlopReward:StartTimer() + if self.Timers then + self:StopTimer() + end + + self.TotalTime = CS.XGame.Config:GetInt("OnlineBossResultSelectTime") + self.Time = self.TotalTime + self.StartTicks = CS.XTimerManager.Ticks + + self.Timers = XScheduleManager.ScheduleForever(function(timer) + self:OnUpdateTime(timer) + end, 0) +end + +function XUiFubenFlopReward:StopTimer() + if self.Timers then + XScheduleManager.UnSchedule(self.Timers) + self.ImgCountDownBarRight.fillAmount = 0 + self.ImgCountDownBarLeft.fillAmount = 0 + + self.Timers = nil + self:OnBtnBgClick() + end +end + +function XUiFubenFlopReward:OnUpdateTime() + if not self.ImgCountDownBarRight.gameObject:Exist() or not self.ImgCountDownBarLeft.gameObject:Exist() then + self:StopTimer() + return + end + + self.ImgCountDownBarRight.fillAmount = self.Time / self.TotalTime + self.ImgCountDownBarLeft.fillAmount = self.Time / self.TotalTime + + local t = self.TotalTime - (CS.XTimerManager.Ticks - self.StartTicks) / CS.System.TimeSpan.TicksPerSecond + self.Time = t + if self.Time <= 0 then + if self.Status == PanelStatus.SelectTime then + self:AutoDrawReward() + else + self:StopTimer() + end + end +end + + +-- auto +-- Automatic generation of code, forbid to edit +function XUiFubenFlopReward:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiFubenFlopReward:AutoInitUi() + self.PanelBase = self.Transform:Find("SafeAreaContentPane/PanelBase") + self.PanelCountDown = self.Transform:Find("SafeAreaContentPane/PanelBase/PanelCountDown") + self.ImgCountDownBarRight = self.Transform:Find("SafeAreaContentPane/PanelBase/PanelCountDown/ImgCountDownBarRight"):GetComponent("Image") + self.ImgCountDownBarLeft = self.Transform:Find("SafeAreaContentPane/PanelBase/PanelCountDown/ImgCountDownBarLeft"):GetComponent("Image") + self.TxtDesc = self.Transform:Find("SafeAreaContentPane/PanelBase/TxtDesc"):GetComponent("Text") + self.TxtDifficulty = self.Transform:Find("SafeAreaContentPane/PanelBase/PanelTxt/TxtDifficulty"):GetComponent("Text") + self.PanelReward = self.Transform:Find("SafeAreaContentPane/PanelReward") + self.PanelLayout = self.Transform:Find("SafeAreaContentPane/PanelReward/PanelLayout") + self.PanelRewardBox = self.Transform:Find("SafeAreaContentPane/PanelReward/PanelLayout/PanelRewardBox") + self.BtnBg = self.Transform:Find("FullScreenBackground/BtnBg"):GetComponent("Button") +end + +function XUiFubenFlopReward:GetAutoKey(uiNode, eventName) + if not uiNode then + return + end + return eventName .. uiNode:GetHashCode() +end + +function XUiFubenFlopReward:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then + return + end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiFubenFlopReward:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiFubenFlopReward:AutoAddListener() + self.AutoCreateListeners = {} + self:RegisterClickEvent(self.BtnBg, self.OnBtnBgClick) +end +-- auto +function XUiFubenFlopReward:OnBtnBgClick() + if self.Time > 0 then + return + end + + if self.Selected == false then + return + end + + if self.Cb then + self.Cb() + else + self:Close() + end +end + +function XUiFubenFlopReward:InitRewardBox() + local rewardCount = XDataCenter.FubenManager.FubenFlopCount + local canSelect = XDataCenter.FubenManager.CheckHasFlopReward(self.WinData, true) + local stage = XDataCenter.FubenManager.GetStageCfg(self.WinData.StageId) + for i = 1, rewardCount do + local ui = CS.UnityEngine.Object.Instantiate(self.PanelRewardBox) + local grid = XUiPanelRewardBox.New(ui, self, i, canSelect, stage.IsMultiplayer) + grid.Transform:SetParent(self.PanelLayout, false) + grid.GameObject:SetActive(true) + self.RewardBox[i] = grid + end + self.Animation:Stop() + + if XDataCenter.FubenManager.CheckHasFlopReward(self.WinData, true) then + self.TxtDesc.text = CS.XTextManager.GetText("FlopRewardSelect") + self.Animation:Play("UiTxtTips") + else + self.TxtDesc.text = CS.XTextManager.GetText("FlopRewardWait") + end +end + +function XUiFubenFlopReward:OnDestroy() + self:StopTimer() + XEventManager.RemoveEventListener(XEventId.EVENT_ONLINEBOSS_DROPREWARD_NOTIFY, self.OnDropReaward, self) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenFlopReward/XUiPanelRewardBox.lua b/Resources/Scripts/XUi/XUiFubenFlopReward/XUiPanelRewardBox.lua new file mode 100644 index 00000000..756774c1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenFlopReward/XUiPanelRewardBox.lua @@ -0,0 +1,213 @@ +XUiPanelRewardBox = XClass(nil, "XUiPanelRewardBox") + +local RewardBoxState = { + LOCK = 1, + OPEN = 2, + UNREWARD = 3 +} + +function XUiPanelRewardBox:Ctor(ui, parent, pos, canSelect, isMultiplayer) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Parent = parent + self.Pos = pos + self.CanSelect = canSelect + self.IsMultiplayer = isMultiplayer + self:InitAutoScript() + self.Animation = self.GameObject:GetComponent("Animation") + self.State = RewardBoxState.LOCK + self.Grid = XUiGridCommon.New(self.Parent, self.GridCommon) + + self.Grid.BtnClick.gameObject:SetActive(false) + + self.FxUiFanpaiBlue = self.Transform:Find("PanelBox/PanelEffect/FanpaiBlue"):GetComponent("Animation") + self.FxUiFanpaiGreen = self.Transform:Find("PanelBox/PanelEffect/FanpaiGreen"):GetComponent("Animation") + self.FxUiFanpaiOrange = self.Transform:Find("PanelBox/PanelEffect/FanpaiOrange"):GetComponent("Animation") + self.FxUiFanpaiPurple = self.Transform:Find("PanelBox/PanelEffect/FanpaiPurple"):GetComponent("Animation") +end + +function XUiPanelRewardBox:OnEnable() + if self.IsPlaying then + self:PlayAnimationSelect() + end +end + +function XUiPanelRewardBox:OnDisable() + self.IsPlaying = self.Animation.isPlaying +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelRewardBox:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiPanelRewardBox:AutoInitUi() + self.PanelBox = self.Transform:Find("PanelBox") + self.GridCommon = self.Transform:Find("PanelBox/GridCommon") + self.ImgIcon = self.Transform:Find("PanelBox/GridCommon/ImgIcon") + self.ImgQuality = self.Transform:Find("PanelBox/GridCommon/ImgQuality") + self.BtnClick = self.Transform:Find("PanelBox/GridCommon/BtnClick") + self.TxtNameB = self.Transform:Find("PanelBox/GridCommon/TxtName") + self.Panel_Lock = self.Transform:Find("PanelBox/Panel_Lock") + self.ImgDefault = self.Transform:Find("PanelBox/Panel_Lock/ImgDefault"):GetComponent("Image") + self.BtnOpen = self.Transform:Find("PanelBox/Panel_Lock/BtnOpen"):GetComponent("Button") + self.PanelRewards = self.Transform:Find("PanelBox/PanelRewards") + self.TxtName = self.Transform:Find("PanelBox/PanelRewards/TxtName"):GetComponent("Text") + self.PanelUnRewards = self.Transform:Find("PanelBox/PanelUnRewards") + self.TxtNameA = self.Transform:Find("PanelBox/PanelUnRewards/TxtName") + self.PanelEffect = self.Transform:Find("PanelBox/PanelEffect") +end + +function XUiPanelRewardBox:GetAutoKey(uiNode, eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiPanelRewardBox:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiPanelRewardBox:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiPanelRewardBox:AutoAddListener() + self.AutoCreateListeners = {} + XUiHelper.RegisterClickEvent(self, self.BtnOpen, self.OnBtnOpenClick) +end +-- auto +function XUiPanelRewardBox:Refresh(data) + if self.State ~= RewardBoxState.LOCK then + return + end + + if not data.GoodsList then + return + end + self.Grid:ShowCount(true) + self.Grid:Refresh(data.GoodsList[1], { Disable = true }) + self.State = RewardBoxState.OPEN + self.Panel_Lock.gameObject:SetActive(false) + self.Qulity = self.Grid:GetQuality() + self.GridCommon.gameObject:SetActive(true) + + local name = "" + if data.PlayerId == XPlayer.Id then + name = XPlayer.Name + elseif self.Parent.WinData.PlayerList then + for _, v in pairs(self.Parent.WinData.PlayerList) do + if v.Id == data.PlayerId then + name = XDataCenter.SocialManager.GetPlayerRemark(data.PlayerId, v.Name) + end + end + end + + -- 合众战局单机模式下不显示玩家名,显示“获得奖励” + if not self.IsMultiplayer and XDataCenter.ArenaOnlineManager.GetCurChallengeId() then + self.TxtName.text = CS.XTextManager.GetText("FlopRewardGetReward") + else + self.TxtName.text = name + end + + if data.PlayerId ~= 0 then + self.State = RewardBoxState.OPEN + self:PlayAnimationSelect() + else + self.State = RewardBoxState.UNREWARD + self:PlayAnimationAutoShow() + end +end + +function XUiPanelRewardBox:OnBtnOpenClick() + if not self.CanSelect or self.Parent.Selected then + return + end + + if self.IsMultiplayer then + XDataCenter.RoomManager.SelectReward(self.Pos) + else + XEventManager.DispatchEvent(XEventId.EVENT_ONLINEBOSS_DROPREWARD_NOTIFY, { + PlayerId = XPlayer.Id, + Pos = self.Pos + }) + end +end + +-- function XUiPanelRewardBox:SetupRewards(pos, goodsList) +-- if self.Pos ~= pos then +-- return +-- end +-- end +function XUiPanelRewardBox:PlayAnimationSelect() + local aniName = 'UiFanpai0' + self.Animation:Play(aniName) + local clip = self.Animation:GetClip(aniName) + + XScheduleManager.Schedule(function() + self:PlayQualityAni() + XScheduleManager.Schedule(function() + self.PanelRewards.gameObject:SetActive(true) + self.Animation:Play("UiFanpai1") + self.Grid.BtnClick.gameObject:SetActive(true) + end, 500, 1, clip.length * 1000) + end, clip.length * 1000, 1, clip.length * 1000) +end + + +function XUiPanelRewardBox:PlayAnimationAutoShow() + local aniName = 'UiFanpai0' + self.Animation:Play(aniName) + local clip = self.Animation:GetClip(aniName) + + XScheduleManager.Schedule(function() + self:PlayQualityAni() + XScheduleManager.Schedule(function() + self.PanelUnRewards.gameObject:SetActive(true) + self.Animation:Play("UiFanpai2") + self.Grid.BtnClick.gameObject:SetActive(true) + end, 500, 1, clip.length * 1000) + end, clip.length * 1000, 1, clip.length * 1000) +end + + +function XUiPanelRewardBox:PlayQualityAni() + if self.Qulity <= 2 then + self.FxUiFanpaiGreen.gameObject:SetActive(true) + self.FxUiFanpaiGreen:Play("FanpaiGreen") + end + + if self.Qulity == 3 then + self.FxUiFanpaiBlue.gameObject:SetActive(true) + self.FxUiFanpaiBlue:Play("FanpaiBlue") + end + + if self.Qulity == 4 then + self.FxUiFanpaiPurple.gameObject:SetActive(true) + self.FxUiFanpaiPurple:Play("FanpaiPurple") + end + + if self.Qulity > 4 then + self.FxUiFanpaiOrange.gameObject:SetActive(true) + self.FxUiFanpaiOrange:Play("FanpaiOrange") + end +end + +return XUiPanelRewardBox \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenHack/ChildItem/XUiGridLevelBuff.lua b/Resources/Scripts/XUi/XUiFubenHack/ChildItem/XUiGridLevelBuff.lua new file mode 100644 index 00000000..bfa07fb9 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenHack/ChildItem/XUiGridLevelBuff.lua @@ -0,0 +1,116 @@ +local XUiGridLevelBuff = XClass(nil, "XUiGridLevelBuff") +local Type = { + Unlocked = 1, + CanUnlock = 2, + Locked = 3, +} +function XUiGridLevelBuff:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + self.BtnDetail.CallBack = function() self:OnBtnDetailClick() end + self.BtnDetail2.CallBack = function() self:OnBtnDetailClick() end + --self.TxtTitleEn.text = "" + XEventManager.AddEventListener(XEventId.EVENT_FUBEN_HACK_CLICK, self.OnGridClick, self) + self.IsPlayedAnim = false + self.IsPlayingAnim = false +end + +function XUiGridLevelBuff:OnDestroy() + XEventManager.RemoveEventListener(XEventId.EVENT_FUBEN_HACK_CLICK, self.OnGridClick, self) +end + +function XUiGridLevelBuff:Refresh(level) + self.Index = level + self.Cfg = XDataCenter.FubenHackManager.GetLevelCfg(level) + if not self.Cfg then return end + self.BuffCfg = XFubenHackConfig.GetBuffById(self.Cfg.BuffId) + self.CurLevel = XDataCenter.FubenHackManager.GetLevel() + + if XDataCenter.FubenHackManager.IsAffixUnlock(level) then + self.State = Type.Unlocked + elseif self.CurLevel >= level then + self.State = Type.CanUnlock + else + self.State = Type.Locked + end + + if self.CurLevel > level then + self.ImgProgress.fillAmount = 1 + elseif self.CurLevel == level then + local curExp = XDataCenter.FubenHackManager.GetCurExp() + local upExp = XDataCenter.FubenHackManager.GetNextUpExp() + self.ImgProgress.fillAmount = curExp / upExp + else + self.ImgProgress.fillAmount = 0 + end + + if level >= XDataCenter.FubenHackManager.GetMaxLevel() then + self.PanelProgress.gameObject:SetActiveEx(false) + end + + self.ImgLvUnlock.gameObject:SetActiveEx(self.State == Type.Unlocked) + self.ImgLvLock.gameObject:SetActiveEx(self.State ~= Type.Unlocked) + self.TxtLvUnlock.text = string.format("Lv.%d", level) + self.TxtLvLock.text = string.format("Lv.%d", level) + self.RImgBuff:SetRawImage(self.BuffCfg.Icon) + self.RImgBuffLock:SetRawImage(self.BuffCfg.Icon) + self.ImgUnlock.gameObject:SetActiveEx(self.State == Type.Unlocked) + self.ImgBuffUnlock.gameObject:SetActiveEx(self.State == Type.Unlocked) + self.ImgBuffLock.gameObject:SetActiveEx(self.State ~= Type.Unlocked) + self.TagEquip.gameObject:SetActiveEx(self.State == Type.Unlocked and XDataCenter.FubenHackManager.CheckAffixEquip(self.BuffCfg.Id)) + self.TxtEquiped.text = CSXTextManagerGetText("FubenHackEquipBuffUsed") + self.ImgLock.gameObject:SetActiveEx(self.State == Type.Locked) + self.PaneCanUnlock.gameObject:SetActiveEx(self.State == Type.CanUnlock) + self.BtnDetail:SetNameByGroup(0, self.BuffCfg.Name) + self.BtnDetail:SetButtonState(self.State == Type.Unlocked and XUiButtonState.Normal or XUiButtonState.Disable) + self.BtnDetail2:SetNameByGroup(0, self.BuffCfg.Name) + self.BtnDetail2:SetButtonState(self.State == Type.Unlocked and XUiButtonState.Normal or XUiButtonState.Disable) +end + +function XUiGridLevelBuff:OnBtnDetailClick() + if not self.IsPlayedAnim then + XEventManager.DispatchEvent(XEventId.EVENT_FUBEN_HACK_CLICK) + return + end + + if self.State == Type.CanUnlock then + local result, desc = XDataCenter.FubenHackManager.UnlockAffix(self.Index) + if result then + self:Refresh(self.Index) + end + XUiManager.TipMsg(desc) + return + end + + self.RootUi:OpenPanelBuffDetail(self.Cfg.BuffId, XFubenHackConfig.PopUpPos.Right) + XEventManager.DispatchEvent(XEventId.EVENT_FUBEN_HACK_CLICK, self.Cfg.BuffId) +end + +function XUiGridLevelBuff:OnGridClick(id, isPlayHighlightAnim) + if id == 0 and self.State == Type.Unlocked and + not XDataCenter.FubenHackManager.CheckAffixEquip(self.BuffCfg.Id) then + self.PanelAnim.gameObject:SetActiveEx(true) + self.SelectionTips:PlayTimelineAnimation() + end + + if self.IsPlayedAnim then + self.ImgSelect.gameObject:SetActiveEx(self.Cfg.BuffId == id) + self.ImgSelect2.gameObject:SetActiveEx(self.Cfg.BuffId == id) + if isPlayHighlightAnim and self.Cfg.BuffId == id then + self.PanelAnim.gameObject:SetActiveEx(true) + self.SelectionTips:PlayTimelineAnimation() + end + elseif self.IsPlayingAnim then + return + else + self.GridBuffEnable:PlayTimelineAnimation(function() + self.IsPlayedAnim = true + self.IsPlayingAnim = false + end) + self.IsPlayingAnim = true + end +end + +return XUiGridLevelBuff \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenHack/ChildItem/XUiGridStageItem.lua b/Resources/Scripts/XUi/XUiFubenHack/ChildItem/XUiGridStageItem.lua new file mode 100644 index 00000000..0997a4f8 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenHack/ChildItem/XUiGridStageItem.lua @@ -0,0 +1,106 @@ +local XUiGridStageItem = XClass(nil, "XUiGridStageItem") +local Type = { + Locked = 1, + First = 2, + NotFirst = 3, -- 人物专属词缀 +} + +local XUiPanelStars = require("XUi/XUiFubenMainLineChapter/XUiPanelStars") + +function XUiGridStageItem:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) +end + +function XUiGridStageItem:SetNormalStage(stageId, stageName) + local stageInterInfo = XFubenHackConfig.GetStageInfo(stageId) + self.PanelStageNormal.gameObject:SetActiveEx(not self.IsLock) + if not self.IsLock then + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + self.RImgNor:SetRawImage(stageCfg.Icon) + end + + self.TxtStageName.text = stageInterInfo.GridName + self.PanelStageLock.gameObject:SetActiveEx(self.IsLock) + self.GridSecond.gameObject:SetActiveEx(false) + self.GridFirst.gameObject:SetActiveEx(self.State == Type.First) + CS.UnityEngine.UI.LayoutRebuilder.ForceRebuildLayoutImmediate(self.GridFirst) + + self.GridLock.gameObject:SetActiveEx(self.State == Type.Locked) + self.TxtNumber.text = string.format("x%d", stageInterInfo.ConsumeTicket) + --self.TxtFirstResume.text = CS.XTextManager.GetText("FubenHackFirstResume") + self.TxtUnlockTip.text = CS.XTextManager.GetText("FubenHackUnlockTip") + self.RImgIcon:SetRawImage(XDataCenter.ItemManager.GetItemIcon(self.ActTemplate.ExpId)) +end + +function XUiGridStageItem:UpdateNode(actId, stageId, stageIndex) + self.ActId = actId + self.StageId = stageId + self.StageIndex = stageIndex + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + local actTemplate = XDataCenter.FubenHackManager.GetCurrentActTemplate() + self.ActTemplate = actTemplate + local isOpen, description = XDataCenter.FubenManager.CheckStageOpen(stageId), CS.XTextManager.GetText("FubenHackUnlockTip") + self.GameObject:SetActiveEx(isOpen) + local prefabPath + if stageCfg.StageGridStyle == "Normal" then + prefabPath = actTemplate.GridPrefab[1] + elseif stageCfg.StageGridStyle == "Hard" then + prefabPath = actTemplate.GridPrefab[2] + end + local gridGo = self.Transform:LoadPrefab(prefabPath) + local uiObj = gridGo.transform:GetComponent("UiObject") + for i = 0, uiObj.NameList.Count - 1 do + self[uiObj.NameList[i]] = uiObj.ObjList[i] + end + self.BtnStage.CallBack = function() self:OnBtnStageClick() end + + self.IsLock = not XDataCenter.FubenManager.CheckStageIsUnlock(stageId) + self.IsPass = XDataCenter.FubenManager.CheckStageIsPass(stageId) + if self.IsLock then + self.State = Type.Locked + elseif self.IsPass then + self.State = Type.NotFirst + else + self.State = Type.First + end + self.Description = description + local stageName = XDataCenter.FubenManager.GetStageName(stageId) + self:SetNormalStage(self.StageId, stageName) + self.PanelStagePass.gameObject:SetActiveEx(self.IsPass) + + self.PanelStars = XUiPanelStars.New(self.PanelStar) + local starsMap = XDataCenter.FubenHackManager.GetStarMap(self.StageId) + self.PanelStars:OnEnable(starsMap) +end + +function XUiGridStageItem:OnBtnStageClick() + if self.StageId and self.ActId then + if not self.IsLock then + self.RootUi:UpdateNodesSelect(self.StageId) + -- 打开详细界面 + self.RootUi:OpenStageDetails(self.StageId, self.ActId) + self.RootUi:PlayScrollViewMove(self.Transform) + else + XUiManager.TipMsg(self.Description) + end + + end +end + +function XUiGridStageItem:SetNodeSelect(isSelect) + if not self.IsLock then + self.ImageSelected.gameObject:SetActiveEx(isSelect) + end +end + +function XUiGridStageItem:ResetItemPosition(pos) + if self.ImgHideLine then + local rect = self.ImgHideLine:GetComponent("RectTransform").rect + self.Transform.localPosition = CS.UnityEngine.Vector3(pos.x, pos.y - rect.height, pos.z) + end +end + +return XUiGridStageItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenHack/ChildItem/XUiGridStarReward.lua b/Resources/Scripts/XUi/XUiFubenHack/ChildItem/XUiGridStarReward.lua new file mode 100644 index 00000000..93da33f7 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenHack/ChildItem/XUiGridStarReward.lua @@ -0,0 +1,101 @@ +local XUiGridStarReward = XClass(nil, "XUiGridStarReward") + +function XUiGridStarReward:Ctor(uiRoot, ui) + self.UiRoot = uiRoot + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + self.GridCommon.gameObject:SetActive(false) + + self.GridList = {} + + self.BtnReceive.CallBack = function() self:OnBtnReceiveClick() end +end + +-- auto +function XUiGridStarReward:OnBtnReceiveClick() + + if not self.Data.IsFinish then + return + end + + XDataCenter.FubenHackManager.GetStarReward(self.Data.Id, function(reward) + XUiManager.OpenUiObtain(reward, CS.XTextManager.GetText("Award")) + self:SetBtnAlreadyReceive() + end) +end + +function XUiGridStarReward:Refresh(data) + self.Data = data + local ownStars = XDataCenter.FubenHackManager.GetStarProgress() + local requireStars = data.RequireStar + local curStars = ownStars > requireStars and requireStars or ownStars + self.TxtGradeStarNums.text = CS.XTextManager.GetText("GradeStarNum", curStars, requireStars) + if data.IsFinish then + self:SetStarsActive(true) + local isGet = XDataCenter.FubenHackManager.CheckStarRewardGet(data.Id) + if isGet then + self:SetBtnAlreadyReceive() + else + self:SetBtnActive() + end + else + self:SetStarsActive(false) + self:SetBtnCannotReceive() + end + + self:SetupTreasureList() +end + +function XUiGridStarReward:SetBtnActive() + self.BtnReceive.gameObject:SetActive(true) + self.ImgAlreadyReceived.gameObject:SetActive(false) + self.ImgCannotReceive.gameObject:SetActive(false) +end + +function XUiGridStarReward:SetBtnCannotReceive() + self.BtnReceive.gameObject:SetActive(false) + self.ImgAlreadyReceived.gameObject:SetActive(false) + self.ImgCannotReceive.gameObject:SetActive(true) +end + +function XUiGridStarReward:SetBtnAlreadyReceive() + self.BtnReceive.gameObject:SetActive(false) + self.ImgAlreadyReceived.gameObject:SetActive(true) + self.ImgCannotReceive.gameObject:SetActive(false) +end + +function XUiGridStarReward:SetStarsActive(flag) + self.ImgGradeStarActive.gameObject:SetActive(flag) + self.ImgGradeStarUnactive.gameObject:SetActive(not flag) +end + +-- 初始化 +function XUiGridStarReward:SetupTreasureList() + if self.Data == nil or self.Data.RewardId == 0 then + XLog.Error("treasure have no RewardId ") + return + end + + local rewards = XRewardManager.GetRewardList(self.Data.RewardId) + for i, item in ipairs(rewards) do + local grid = self.GridList[i] + if not grid then + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommon) + grid = XUiGridCommon.New(self.UiRoot, ui) + grid.Transform:SetParent(self.PanelTreasureContent, false) + self.GridList[i] = grid + end + grid:Refresh(item) + grid.GameObject:SetActive(true) + end + + for j = 1, #self.GridList do + if j > #rewards then + self.GridList[j].GameObject:SetActive(false) + end + end +end + +return XUiGridStarReward \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenHack/ChildView/XUiPanelBuffDetail.lua b/Resources/Scripts/XUi/XUiFubenHack/ChildView/XUiPanelBuffDetail.lua new file mode 100644 index 00000000..95ff50d5 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenHack/ChildView/XUiPanelBuffDetail.lua @@ -0,0 +1,100 @@ +local XUiPanelBuffDetail = XClass(nil, "XUiPanelBuffDetail") + +local Type = { + Unlocked = 1, + Equipped = 2, + Locked = 3, + Character = 4, -- 人物专属词缀 +} + +function XUiPanelBuffDetail:Ctor(uiRoot, ui) + self.UiRoot = uiRoot + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + self:AutoAddListener() + self:Hide() +end + +function XUiPanelBuffDetail:Hide() + self.GameObject:SetActiveEx(false) +end + +function XUiPanelBuffDetail:Show(buffId) + self.BuffId = buffId + self:InitUi() + self.GameObject:SetActiveEx(true) +end + +function XUiPanelBuffDetail:InitUi() + local buffId = self.BuffId + local info = XFubenHackConfig.GetBuffById(buffId) + local buffLevel = XDataCenter.FubenHackManager.GetLevelByBuffId(buffId) + local curLevel = XDataCenter.FubenHackManager.GetLevel() + + if not buffLevel then + self.State = Type.Character + elseif buffLevel > curLevel then + self.State = Type.Locked + else + self.State = Type.Unlocked + end + self.BuffBarList = XDataCenter.FubenHackManager.GetBuffBarList() + for i, v in ipairs(self.BuffBarList) do + if v == buffId then + self.State = Type.Equipped + self.EquipIndex = i + end + end + + self.TxtLocked.gameObject:SetActiveEx(self.State == Type.Locked) + self.TxtLocked.text = CSXTextManagerGetText("FubenHackEquipBuffLock", buffLevel) + self.TxtUnlocked.gameObject:SetActiveEx(self.State == Type.Unlocked) + self.TxtUnlocked.text = CSXTextManagerGetText("FubenHackEquipBuffAvailable") + self.TxtEquipped.gameObject:SetActiveEx(self.State == Type.Equipped) + self.TxtEquipped.text = CSXTextManagerGetText("FubenHackEquipBuffUsed") + self.TxtName.text = info.Name + self.BtnEquip.gameObject:SetActiveEx(self.State == Type.Unlocked) + self.BtnEquip:SetNameByGroup(0, XUiHelper.ReadTextWithNewLine("FubenHackEquipBuffApply")) + self.BtnTakeOff.gameObject:SetActiveEx(self.State == Type.Equipped) + self.TxtSimpleDesc.gameObject:SetActiveEx(self.State == Type.Character) + self.TxtSimpleDesc.text = info.SimpleDesc + self.RImgBuffIcon:SetRawImage(info.Icon) + self.TxtTitle.text = CS.XTextManager.GetText("FubenHackBuffDetailTitle") + self.TxtDesc.text = XUiHelper.ConvertLineBreakSymbol(info.Description) +end + +function XUiPanelBuffDetail:AutoAddListener() + self.UiRoot:RegisterClickEvent(self.BtnClose, function() self:OnBtnCloseClick() end) + self.BtnEquip.CallBack = function() self:OnBtnEquipClick() end + self.BtnTakeOff.CallBack = function() self:OnBtnTakeOffClick() end +end + +function XUiPanelBuffDetail:OnBtnCloseClick() + XEventManager.DispatchEvent(XEventId.EVENT_FUBEN_HACK_CLICK) + self:Hide() +end + +function XUiPanelBuffDetail:OnBtnEquipClick() + XDataCenter.FubenHackManager.SetBuff(0, self.BuffId, function(res, desc) + if res then + XUiManager.TipText("FubenHackEquipBuffSucc") + self:Hide() + else + XUiManager.TipMsg(desc) + end + end) +end + +function XUiPanelBuffDetail:OnBtnTakeOffClick() + XDataCenter.FubenHackManager.SetBuff(self.EquipIndex, 0, function(res, desc) + if res then + XUiManager.TipText("FubenHackTakeOffBuffSucc") + end + end) + + self:Hide() +end + +return XUiPanelBuffDetail \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenHack/ChildView/XUiPanelLevelInfo.lua b/Resources/Scripts/XUi/XUiFubenHack/ChildView/XUiPanelLevelInfo.lua new file mode 100644 index 00000000..e27af391 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenHack/ChildView/XUiPanelLevelInfo.lua @@ -0,0 +1,86 @@ +local XUiPanelLevelInfo = XClass(nil, "XUiPanelLevelInfo") + +local Lerp = CS.UnityEngine.Mathf.Lerp + +function XUiPanelLevelInfo:Ctor(uiRoot, ui) + self.UiRoot = uiRoot + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + self:InitUi() + self:Refresh() +end + +function XUiPanelLevelInfo:InitUi() + self.ActTemplate = XDataCenter.FubenHackManager.GetCurrentActTemplate() + self.TxtName.text = CS.XTextManager.GetText("FubenHackLevelName") + --self.RImgIcon:SetRawImage(XDataCenter.ItemManager.GetItemIcon(self.ActTemplate.ExpId)) +end + +function XUiPanelLevelInfo:Refresh(isPlayAnim) + self.IsPlayAnim = isPlayAnim + self.TxtMaxLevel.text = string.format("/%d", XDataCenter.FubenHackManager.GetMaxLevel()) + + if self.IsPlayAnim then + self:NextStep() + else + self:ShowInfo() + end +end + +function XUiPanelLevelInfo:ShowInfo() + local curLv = XDataCenter.FubenHackManager.GetLevel() + local isMaxLv = curLv >= XDataCenter.FubenHackManager.GetMaxLevel() + self.TxtLevel.text = string.format("%02d", curLv) + if isMaxLv then + self.TxtExp.text = CS.XTextManager.GetText("RpgTowerMaxLevel") + self.ImgProgress.fillAmount = 1 + --self.RImgIcon.gameObject:SetActiveEx(false) + else + local curExp = XDataCenter.FubenHackManager.GetCurExp() + local upExp = XDataCenter.FubenHackManager.GetNextUpExp() + self.TxtExp.text = string.format("%d/%d", curExp, upExp) + self.ImgProgress.fillAmount = curExp / upExp + end +end + +function XUiPanelLevelInfo:NextStep() + if not self.IsPlayAnim then return end + local isExpAdd, isLvUp, showLv, curExp, nextExp, fullExp = XDataCenter.FubenHackManager.CheckExpAdd() + if isExpAdd then + self.TxtLevel.text = string.format("%02d", showLv) + self.AnimTimer = XUiHelper.Tween(0.7, function(f) + local tempExp + if isLvUp then + tempExp = Lerp(curExp, 2 * fullExp - nextExp, f) + else + tempExp = Lerp(curExp, nextExp, f) + end + if tempExp <= fullExp then + self.ImgProgress.fillAmount = tempExp / fullExp + self.TxtExp.text = string.format("%.f/%d", tempExp, fullExp) + else + self.ImgProgress.fillAmount = (2 * fullExp - tempExp) / fullExp + end + --XLog.Warning(showLv, curExp, nextExp, fullExp) + end, function() + self:NextStep() + end, function(t) + return XUiHelper.Evaluate(XUiHelper.EaseType.Sin, t) + end) + return true + else + self:ShowInfo() + XDataCenter.FubenHackManager.CheckLevelUp() + end +end + +function XUiPanelLevelInfo:OnDisable() + if self.AnimTimer then + XScheduleManager.UnSchedule(self.AnimTimer) + end + self.IsPlayAnim = false +end + +return XUiPanelLevelInfo \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenHack/ChildView/XUiPanelLineChapter.lua b/Resources/Scripts/XUi/XUiFubenHack/ChildView/XUiPanelLineChapter.lua new file mode 100644 index 00000000..416e239e --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenHack/ChildView/XUiPanelLineChapter.lua @@ -0,0 +1,222 @@ +local XUiPanelLineChapter = XClass(nil, "XUiPanelLineChapter") +local XUguiDragProxy = CS.XUguiDragProxy + +local XUiGridStageItem = require("XUi/XUiFubenHack/ChildItem/XUiGridStageItem") + +function XUiPanelLineChapter:Ctor(uiRoot, ui, chapterTemplate) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + self.ChapterTemplate = chapterTemplate + self.StageGroup = {} + self.GridTreasureList = {} + + XTool.InitUiObject(self) + XEventManager.AddEventListener(XEventId.EVENT_FUBEN_CLOSE_FUBENSTAGEDETAIL, self.CloseStageDetails, self) +end + +function XUiPanelLineChapter:OnShow(delay) + --self.GameObject:SetActiveEx(false) + self:Refresh() + --self.AnimTimer = XScheduleManager.ScheduleOnce(function() + -- self.GameObject:SetActiveEx(true) + -- --self.AnimEnable:PlayTimelineAnimation() + -- self.LineEnable:PlayTimelineAnimation() + -- for _, v in ipairs(self.ActStages) do + -- v.IconEnable:PlayTimelineAnimation() + -- end + --end, delay or 1000) + + if self.PaneStageList and self.NeedReset then + self.PaneStageList.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Elastic + else + self.NeedReset = true + end + + if self.LastOpenStage then + self:MoveIntoStage(self.LastOpenStage) + end +end + +function XUiPanelLineChapter:OnHide() + self.GameObject:SetActiveEx(true) + self.LineDisable:PlayTimelineAnimation() + for _, v in ipairs(self.ActStages) do + v.IconDisable:PlayTimelineAnimation() + end + if self.AnimTimer then + XScheduleManager.UnSchedule(self.AnimTimer) + self.AnimTimer = nil + end +end + +-- 更新刷新 +function XUiPanelLineChapter:Refresh() + local dragProxy = self.PaneStageList:GetComponent(typeof(XUguiDragProxy)) + if not dragProxy then + dragProxy = self.PaneStageList.gameObject:AddComponent(typeof(XUguiDragProxy)) + end + dragProxy:RegisterHandler(handler(self, self.OnDragProxy)) + + self.ActStageIds = self.ChapterTemplate.StageId + --XDataCenter.FubenNewCharActivityManager.GetAvailableStageIds(self.ChapterTemplate.Id) + -- 线条处理 + self:HandleStageLines() + -- 关卡处理 + self:HandleStages() + -- 界面信息 + -- self:SwitchFestivalBg(chapterTemplate) +end + +function XUiPanelLineChapter:HandleStages() + self.ActStages = {} + for i = 1, #self.ActStageIds do + local itemStage = self.PanelStageContent:Find(string.format("Stage%d", i)) + if not itemStage then + XLog.Error("XUiPanelLineChapter:HandleStages() 函数错误: 游戏物体PanelStageContent下找不到名字为:" .. string.format("Stage%d", i) .. "的游戏物体") + return + end + -- 组件初始化 + -- XLog.Warning(self.ActStageIds[i], isOpen, itemStage) + self.StageGroup[i] = itemStage + self.ActStages[i] = XUiGridStageItem.New(self, itemStage) + itemStage.gameObject:SetActiveEx(true) + self.ActStages[i]:UpdateNode(self.ChapterTemplate.Id, self.ActStageIds[i], i) + end + self:UpdateNodeLines() +end + +function XUiPanelLineChapter:HandleStageLines() + self.ActStageLine = {} + for i = 2, #self.ActStageIds do + local itemLine = self.PanelStageContent:Find(string.format("Line%d", i-1)) + if not itemLine then + XLog.Error("XUiPanelLineChapter:SetUiData() error: prefab not found a child name:" .. string.format("Line%d", i)) + return + end + itemLine.gameObject:SetActiveEx(false) + self.ActStageLine[i] = itemLine + end +end + +-- 更新节点线条 +function XUiPanelLineChapter:UpdateNodeLines() + if not self.ChapterTemplate or not self.ActStageIds then return end + local stageLength = #self.ActStageIds + for i = 2, stageLength do + local isOpen = XDataCenter.FubenManager.CheckStageOpen(self.ActStageIds[i]) + self:SetStageLineActive(i, isOpen) + if isOpen then + self.LastOpenStage = i + end + end + self:SetStageLineActive(1, true) +end + +function XUiPanelLineChapter:SetStageLineActive(index, isActive) + if self.ActStageLine[index] then + self.ActStageLine[index].gameObject:SetActiveEx(isActive) + end +end + +-- 选中关卡 +function XUiPanelLineChapter:UpdateNodesSelect(stageId) + local stageIds = self.ActStageIds + for i = 1, #stageIds do + if self.ActStages[i] then + self.ActStages[i]:SetNodeSelect(stageIds[i] == stageId) + end + end +end + +-- 取消选中 +function XUiPanelLineChapter:ClearNodesSelect() + for i = 1, #self.ActStageIds do + if self.ActStages[i] then + self.ActStages[i]:SetNodeSelect(false) + end + end + self.IsOpenDetails = false +end + +function XUiPanelLineChapter:GetStages() + local stageIds = {} + for i = 1, #self.ChapterTemplate.StageId do + stageIds[i] = self.ChapterTemplate.StageId[i] + end + return stageIds +end + +-- 打开剧情,战斗详情 +function XUiPanelLineChapter:OpenStageDetails(stageId) + --self:CloseStageDetails() + + self.UiRoot:OpenChildUi("UiFubenHackSection", self.UiRoot) + local childUiObj = self.UiRoot:FindChildUiObj("UiFubenHackSection") + if childUiObj then + childUiObj:SetStageDetail(stageId) + end + + self.PanelStageContentRaycast.raycastTarget = false +end + +-- 关闭剧情,战斗详情 +function XUiPanelLineChapter:CloseStageDetails() + self.IsOpenDetails = false + self.PanelStageContentRaycast.raycastTarget = true + self:ClearNodesSelect() + self.PaneStageList.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Elastic +end + +function XUiPanelLineChapter:OnDragProxy(dragType) + if self.IsOpenDetails and dragType == 0 then + self:CloseStageDetails() + end +end + +function XUiPanelLineChapter:OnDestroy() + XEventManager.RemoveEventListener(XEventId.EVENT_FUBEN_CLOSE_FUBENSTAGEDETAIL, self.CloseStageDetails, self) +end + +function XUiPanelLineChapter:PlayScrollViewMove(gridTransform) + self.PaneStageList.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Unrestricted + local gridRect = gridTransform:GetComponent("RectTransform") + local diffX = gridRect.localPosition.x + self.PanelStageContent.localPosition.x + if diffX < XDataCenter.FubenMainLineManager.UiGridChapterMoveMinX or diffX > XDataCenter.FubenMainLineManager.UiGridChapterMoveMaxX then + local tarPosX = XDataCenter.FubenMainLineManager.UiGridChapterMoveTargetX - gridRect.localPosition.x + local tarPos = self.PanelStageContent.localPosition + tarPos.x = tarPosX + XLuaUiManager.SetMask(true) + XUiHelper.DoMove(self.PanelStageContent, tarPos, XDataCenter.FubenMainLineManager.UiGridChapterMoveDuration, XUiHelper.EaseType.Sin, function() + XLuaUiManager.SetMask(false) + end) + end +end + +function XUiPanelLineChapter:MoveIntoStage(stageIndex) + local gridRect = self.StageGroup[stageIndex] + local diffX = gridRect.localPosition.x + self.PanelStageContent.localPosition.x + if diffX > CS.XResolutionManager.OriginWidth / 2 then + local tarPosX = (CS.XResolutionManager.OriginWidth / 4) - gridRect.localPosition.x + local tarPos = self.PanelStageContent.localPosition + tarPos.x = tarPosX + XLuaUiManager.SetMask(true) + self.PaneStageList.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Unrestricted + XUiHelper.DoMove(self.PanelStageContent, tarPos, XDataCenter.FubenMainLineManager.UiGridChapterMoveDuration, XUiHelper.EaseType.Sin, function() + XLuaUiManager.SetMask(false) + self.PaneStageList.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Elastic + end) + end +end + +function XUiPanelLineChapter:EndScrollViewMove() + self.PaneStageList.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Elastic +end + +-- 背景 +function XUiPanelLineChapter:SwitchFestivalBg(festivalTemplate) + if not festivalTemplate or not festivalTemplate.MainBackgound then return end + self.RImgFestivalBg:SetRawImage(festivalTemplate.MainBackgound) +end + +return XUiPanelLineChapter \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenHack/Proxy/XUiHackNewRoomSingle.lua b/Resources/Scripts/XUi/XUiFubenHack/Proxy/XUiHackNewRoomSingle.lua new file mode 100644 index 00000000..49ab30ee --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenHack/Proxy/XUiHackNewRoomSingle.lua @@ -0,0 +1,42 @@ +-- 骇入玩法出战界面代理 +local XUiHackNewRoomSingle = {} + +function XUiHackNewRoomSingle.InitEditBattleUi(newRoomSingle) + newRoomSingle.BtnTeamPrefab.gameObject:SetActiveEx(false) +end + +function XUiHackNewRoomSingle.GetCharAbility(charId) + if XRobotManager.CheckIsRobotId(charId) then + -- 骇入玩法战力计算特殊处理 + return XRobotManager.GetRobotAbility(charId) + XDataCenter.FubenHackManager.GetBuffAbilityBonus() + else + return 0 + end +end + +function XUiHackNewRoomSingle.GetBattleTeamData(newRoomSingle) + local curTeam = XDataCenter.FubenHackManager.LoadTeamLocal() + XDataCenter.FubenHackManager.SaveTeamLocal(curTeam, newRoomSingle.CurrentStageId) + XDataCenter.TeamManager.SetPlayerTeam(curTeam, false) + return XTool.Clone(curTeam) +end + +function XUiHackNewRoomSingle.HandleCharClick(newRoomSingle, charPos) + local teamData = XTool.Clone(newRoomSingle.CurTeam.TeamData) + local robotIdList = XDataCenter.FubenHackManager.GetCurChapterTemplate().RobotId + XLuaUiManager.Open("UiRoomCharacter", teamData, charPos, function(resTeam) + newRoomSingle:UpdateTeam(resTeam) + end, XDataCenter.FubenManager.StageType.Hack, nil, {IsRobotOnly = true, RobotIdList = robotIdList}) +end + +function XUiHackNewRoomSingle.UpdateTeam(newRoomSingle) + XDataCenter.FubenHackManager.SaveTeamLocal(newRoomSingle.CurTeam, newRoomSingle.CurrentStageId) + XDataCenter.TeamManager.SetPlayerTeam(newRoomSingle.CurTeam, false) +end + +function XUiHackNewRoomSingle.OnResetEvent(newRoomSingle) + XLuaUiManager.RunMain() + XDataCenter.FubenHackManager.OnActivityEnd() +end + +return XUiHackNewRoomSingle \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenHack/Proxy/XUiHackRoomCharacter.lua b/Resources/Scripts/XUi/XUiFubenHack/Proxy/XUiHackRoomCharacter.lua new file mode 100644 index 00000000..4077d178 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenHack/Proxy/XUiHackRoomCharacter.lua @@ -0,0 +1,46 @@ +-- 骇入玩法选人列表界面代理 +local XUiHackRoomCharacter = {} + +function XUiHackRoomCharacter.InitCharacterTypeBtns(roomCharacterUi, teamCharIdMap, TabBtnIndex) + roomCharacterUi.BtnTabShougezhe.gameObject:SetActiveEx(false) + roomCharacterUi.PanelCharacterTypeBtns:SelectIndex(TabBtnIndex.Normal) +end + +function XUiHackRoomCharacter.SortList(roomCharacterUi, charIdList) + local indexDic = {} + for i, v in ipairs(charIdList) do + indexDic[v] = i + end + + table.sort(charIdList, function(a, b) + local AIsInTeam = roomCharacterUi:IsInTeam(a) + local BIsInTeam = roomCharacterUi:IsInTeam(b) + if AIsInTeam ~= BIsInTeam then + return AIsInTeam + else + return indexDic[a] < indexDic[b] + end + end) + return charIdList +end + +function XUiHackRoomCharacter.GetCharInfo(roomCharacterUi, charId) + local charInfo = {} + if XRobotManager.CheckIsRobotId(charId) then + charInfo.Id = charId + charInfo.IsRobot = true + charInfo.HideTryTag = true + -- 骇入玩法战力计算特殊处理 + charInfo.Ability = XRobotManager.GetRobotAbility(charId) + XDataCenter.FubenHackManager.GetBuffAbilityBonus() + else + charInfo = XDataCenter.CharacterManager.GetCharacter(charId) + end + return charInfo +end + +function XUiHackRoomCharacter.OnResetEvent() + XLuaUiManager.RunMain() + XDataCenter.FubenHackManager.OnActivityEnd() +end + +return XUiHackRoomCharacter \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenHack/XUiFubenHack.lua b/Resources/Scripts/XUi/XUiFubenHack/XUiFubenHack.lua new file mode 100644 index 00000000..5c534801 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenHack/XUiFubenHack.lua @@ -0,0 +1,217 @@ +local XUiPanelLineChapter = require("XUi/XUiFubenHack/ChildView/XUiPanelLineChapter") +local XUiPanelLevelInfo = require("XUi/XUiFubenHack/ChildView/XUiPanelLevelInfo") +local XUiGridStarReward = require("XUi/XUiFubenHack/ChildItem/XUiGridStarReward") + +local XUiFubenHack = XLuaUiManager.Register(XLuaUi, "UiFubenHack") +function XUiFubenHack:OnAwake() + self.GridTreasureList = {} -- 任务格子 +end + +function XUiFubenHack:OnResume(data) + self.LastChapter = data +end + +function XUiFubenHack:OnEnable() + if self.RedPointId then + XRedPointManager.Check(self.RedPointId) + end + + self:Refresh() +end + +function XUiFubenHack:OnStart() + self.ActTemplate = XDataCenter.FubenHackManager.GetCurrentActTemplate() + self.ChapterTemplate = XDataCenter.FubenHackManager.GetCurChapterTemplate() + if not self.ActTemplate then + return + end + + self:CreateActivityTimer(XDataCenter.FubenHackManager.GetCurChapterEndTime()) + self.TxtChapterName.text = self.ActTemplate.Name + + self:InitUiView() + self.AssetActivityPanel = XUiPanelActivityAsset.New(self.PanelSpecialTool, true) +end + +function XUiFubenHack:OnGetEvents() + return { XEventId.EVENT_FUBEN_HACK_UPDATE, + CS.XEventId.EVENT_UI_DONE} +end + +function XUiFubenHack:OnNotify(evt, ...) + local args = { ... } + if evt == XEventId.EVENT_FUBEN_HACK_UPDATE then + self:Refresh(args) + elseif evt == XEventId.EVENT_ACTIVITY_ON_RESET then + if args[1] ~= XDataCenter.FubenManager.StageType.Hack then return end + XDataCenter.FubenHackManager.OnActivityEnd() + elseif evt == CS.XEventId.EVENT_UI_DONE then + if self:CheckIsNeedPop() then + XDataCenter.FubenHackManager.OnActivityEnd() + end + end +end + +function XUiFubenHack:Refresh() + if self:CheckIsNeedPop() then return end + self.PanelChapter:Refresh() + self.AssetActivityPanel:Refresh({self.ActTemplate.TicketId}) + self:SetupStarReward() + self.PanelLevelInfo:Refresh(true) + + XDataCenter.FubenHackManager.GetHackDailyTicket() + self.BtnLevel:ShowReddot(XDataCenter.FubenHackManager.CheckAffixRedPoint()) +end + +function XUiFubenHack:OnDisable() + if self.PanelLevelInfo then + self.PanelLevelInfo:OnDisable() + end +end + +function XUiFubenHack:OnDestroy() + if self.PanelChapter then + self.PanelChapter:OnDestroy() + end + self:StopActivityTimer() +end + +function XUiFubenHack:OnReleaseInst() + return self.LastChapter +end + +function XUiFubenHack:SetupStarReward() + local curStars, totalStars = XDataCenter.FubenHackManager.GetStarProgress() + local rewardList, isRed = XDataCenter.FubenHackManager.GetStarRewardList() + self.RewardList = rewardList + + self.ImgJindu.fillAmount = totalStars > 0 and curStars / totalStars or 0 + self.ImgJindu.gameObject:SetActiveEx(true) + self.ImgLingqu.gameObject:SetActiveEx(totalStars <= curStars and (not isRed)) + self.ImgRedProgress.gameObject:SetActiveEx(isRed) + + self.TxtStarNum.text = string.format("%d/%d", curStars, totalStars) +end + +function XUiFubenHack:InitUiView() + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + self.BtnRole.CallBack = function() self:OnBtnRoleClick() end + self.BtnLevel.CallBack = function() self:OnBtnLevelClick() end + self.BtnLevel:SetNameByGroup(0, XUiHelper.ReadTextWithNewLine("FubenHackDevelopBtn")) + self:RegisterClickEvent(self.BtnTreasure, self.OnBtnTreasureClick) + self:RegisterClickEvent(self.BtnTreasureBg, self.OnBtnTreasureBgClick) + + self:BindHelpBtn(self.BtnHelp, "FubenHack") + self.PanelChapter = XUiPanelLineChapter.New(self, self.PaneStageList, self.ChapterTemplate) + self.PanelChapter:OnShow() + self.PanelLevelInfo = XUiPanelLevelInfo.New(self, self.PanelLvInfo) +end + +-- 是否显示红点 +function XUiFubenHack:OnCheckAffix(count) + self.ImgRedProgress.gameObject:SetActiveEx(count >= 0) +end + +function XUiFubenHack:OnBtnBackClick() + self:Close() +end + +function XUiFubenHack:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiFubenHack:OnBtnTreasureBgClick() + --self.TreasureDisable:PlayTimelineAnimation(function() + self.PanelTreasure.gameObject:SetActiveEx(false) + --end) +end + +function XUiFubenHack:OnBtnTreasureClick() + self:InitTreasureGrade() + self.PanelTreasure.gameObject:SetActiveEx(true) + self.TreasureEnable:PlayTimelineAnimation() +end + +function XUiFubenHack:OnBtnRoleClick() + XLuaUiManager.Open("UiHackCharInfo") +end + +function XUiFubenHack:OnBtnLevelClick() + XLuaUiManager.Open("UiHackDevelop") +end + +function XUiFubenHack:InitTreasureGrade() + self.GridTreasureGrade.gameObject:SetActiveEx(false) + -- 先把所有的格子隐藏 + for j = 1, #self.GridTreasureList do + self.GridTreasureList[j].GameObject:SetActiveEx(false) + end + + if not self.RewardList then + return + end + + local offsetValue = 260 + local gridCount = #self.RewardList + + for i = 1, gridCount do + local offerY = (1 - i) * offsetValue + local grid = self.GridTreasureList[i] + + if not grid then + local item = CS.UnityEngine.Object.Instantiate(self.GridTreasureGrade, self.PanelGradeContent) -- 复制一个item + grid = XUiGridStarReward.New(self, item) + grid.Transform.localPosition = CS.UnityEngine.Vector3(item.transform.localPosition.x, item.transform.localPosition.y + offerY, item.transform.localPosition.z) + self.GridTreasureList[i] = grid + end + + grid:Refresh(self.RewardList[i]) + + --grid:InitTreasureList() + grid.GameObject:SetActiveEx(true) + end +end + +-- 背景 +function XUiFubenHack:SwitchBg(actTemplate) + if not actTemplate or not actTemplate.MainBackgound then return end + self.RImgFestivalBg:SetRawImage(actTemplate.MainBackgound) +end + +-- 计时器 +function XUiFubenHack:CreateActivityTimer(endTime) + local time = XTime.GetServerNowTimestamp() + self.TxtDay.text = XUiHelper.GetTime(endTime - time, XUiHelper.TimeFormatType.ACTIVITY) + self:StopActivityTimer() + self.ActivityTimer = XScheduleManager.ScheduleForever(function() + time = XTime.GetServerNowTimestamp() + if time > endTime then + self:StopActivityTimer() + XDataCenter.FubenHackManager.OnActivityEnd() + return + end + self.TxtDay.text = XUiHelper.GetTime(endTime - time, XUiHelper.TimeFormatType.ACTIVITY) + end, XScheduleManager.SECOND, 0) +end + +function XUiFubenHack:StopActivityTimer() + if self.ActivityTimer then + XScheduleManager.UnSchedule(self.ActivityTimer) + self.ActivityTimer = nil + end + + if self.AnimTimer then + XScheduleManager.UnSchedule(self.AnimTimer) + self.AnimTimer = nil + end +end + +function XUiFubenHack:CheckIsNeedPop() + local chapter = XDataCenter.FubenHackManager.GetCurChapterTemplate() + if self.LastChapter and chapter ~= self.LastChapter then + return true + else + self.LastChapter = XDataCenter.FubenHackManager.GetCurChapterTemplate() + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenHack/XUiFubenHackDetails.lua b/Resources/Scripts/XUi/XUiFubenHack/XUiFubenHackDetails.lua new file mode 100644 index 00000000..8c8b8691 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenHack/XUiFubenHackDetails.lua @@ -0,0 +1,49 @@ +local XUiFubenHackDetails = XLuaUiManager.Register(XLuaUi, "UiFubenHackDetails") + +function XUiFubenHackDetails:OnAwake() + self:AutoAddListener() + self.GridSkillList = {} +end + +function XUiFubenHackDetails:OnStart(stageId) + self.StageId = stageId + self:InitUi() +end + +--function XUiFubenHackDetails:OnGetEvents() +-- return {XEventId.EVENT_ACTIVITY_ON_RESET} +--end +-- +--function XUiFubenHackDetails:OnNotify(evt, ...) +-- local args = { ... } +-- if evt == XEventId.EVENT_ACTIVITY_ON_RESET then +-- if args[1] ~= XDataCenter.FubenManager.StageType.Hack then return end +-- XDataCenter.FubenHackManager.OnActivityEnd() +-- end +--end + +function XUiFubenHackDetails:InitUi() + local stageInterInfo = XFubenHackConfig.GetStageInfo(self.StageId) + local count = #stageInterInfo.FeatureTitle + + for i = 1, count do + local item = self.GridSkillList[i] + + if not item then + item = CS.UnityEngine.Object.Instantiate(self.GridDetail, self.Content) -- 复制一个item + self.GridSkillList[i] = item + end + item:Find("TxtTitle"):GetComponent("Text").text = stageInterInfo.FeatureTitle[i] + item:Find("TxtDesc"):GetComponent("Text").text = XUiHelper.ConvertLineBreakSymbol(stageInterInfo.FeatureDesc[i]) + item:Find("TxtNumber"):GetComponent("Text").text = string.format("%02d", i) + end + self.GridDetail.gameObject:SetActiveEx(false) +end + +function XUiFubenHackDetails:AutoAddListener() + self.BtnTanchuangCloseBig.CallBack = function() self:OnBtnTanchuangCloseBigClick() end +end + +function XUiFubenHackDetails:OnBtnTanchuangCloseBigClick() + self:Close() +end diff --git a/Resources/Scripts/XUi/XUiFubenHack/XUiFubenHackSection.lua b/Resources/Scripts/XUi/XUiFubenHack/XUiFubenHackSection.lua new file mode 100644 index 00000000..b41e7811 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenHack/XUiFubenHackSection.lua @@ -0,0 +1,195 @@ +local XUiFubenHackSection = XLuaUiManager.Register(XLuaUi, "UiFubenHackSection") +local ViewType = { + StageInfo = 1, + TargetInfo = 2, +} +function XUiFubenHackSection:OnAwake() + self.StarGridList = {} + self.GridList = {} + + self.AssetActivityPanel = XUiPanelActivityAsset.New(self.PanelSpecialTool, true) + self:InitStarPanels() +end + +function XUiFubenHackSection:InitStarPanels() + for i = 1, 3 do + self.StarGridList[i] = XUiGridStageStar.New(self[string.format("GridStageStar%d", i)]) + end +end + +function XUiFubenHackSection:OnStart(rootUi) + self.RootUi = rootUi + + self.BtnEnter.CallBack = function() self:OnBtnEnterClick() end + self.BtnTarget.CallBack = function() self:OnBtnTargetClick() end + + XUiHelper.RegisterClickEvent(self, self.BtnClose, function() self:OnBtnCloseClick() end) +end + +function XUiFubenHackSection:OnGetEvents() + return { XEventId.EVENT_FUBEN_HACK_UPDATE, + XEventId.EVENT_ACTIVITY_ON_RESET} +end + +function XUiFubenHackSection:OnNotify(evt, ...) + local args = { ... } + if evt == XEventId.EVENT_FUBEN_HACK_UPDATE then + --self:Refresh(args) + elseif evt == XEventId.EVENT_ACTIVITY_ON_RESET then + if args[1] ~= XDataCenter.FubenManager.StageType.Hack then return end + XDataCenter.FubenHackManager.OnActivityEnd() + end +end + +function XUiFubenHackSection:SetStageDetail(stageId) + self.StageId = stageId + self.ActTemplate = XDataCenter.FubenHackManager.GetCurrentActTemplate() + + self.CurrentView = ViewType.StageInfo + self:OnSwitchView(self.CurrentView, true) + + local stageCfg = XDataCenter.FubenManager.GetStageCfg(self.StageId) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(self.StageId) + local stageInterInfo = XFubenHackConfig.GetStageInfo(self.StageId) + + self.TxtTitle.text = stageCfg.Name + self.AssetActivityPanel:Refresh({self.ActTemplate.TicketId}) + for i = 1, 3 do + self.StarGridList[i]:Refresh(stageCfg.StarDesc[i], stageInfo.StarsMap[i]) + end + + self.RImgCostIcon:SetRawImage(XDataCenter.ItemManager.GetItemIcon(self.ActTemplate.TicketId)) + self.TxtResumeCount.text = stageInterInfo.ConsumeTicket or 0 + local isFirst = not XDataCenter.FubenManager.CheckStageIsPass(stageId) + self.TxtFirstResume.gameObject:SetActiveEx(isFirst) + self.TxtResume.gameObject:SetActiveEx(not isFirst) + self.TxtResume.text = CS.XTextManager.GetText("FubenHackRepeatResume") + self.TxtCondition.text = stageInterInfo.ConditionDesc + self:UpdateRewards() +end + +function XUiFubenHackSection:OnSwitchView(type, isFromOtherUi) + if not isFromOtherUi then + --self:PlayAnimation("QieHuan") + end + self.CurrentView = type + + self.PanelStageInfo.gameObject:SetActiveEx(type == ViewType.StageInfo) + self.BtnTarget.gameObject:SetActiveEx(type == ViewType.StageInfo) + self.PanelTargetInfo.gameObject:SetActiveEx(type == ViewType.TargetInfo) + self.BtnStage.gameObject:SetActiveEx(type == ViewType.TargetInfo) + if type == ViewType.StageInfo then + local isRed = not XDataCenter.FubenHackManager.GetReadDetailMark(self.StageId) + self.BtnTarget:ShowReddot(isRed) + else + XDataCenter.FubenHackManager.SetReadDetailMark(self.StageId) + self.BtnTarget:ShowReddot(false) + end +end + +function XUiFubenHackSection:UpdateRewards() + if not self.StageId then return end + local stageId = self.StageId + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + + local rewardId = stageCfg.FinishRewardShow + local IsFirst = false + -- 首通有没有填 + local controlCfg = XDataCenter.FubenManager.GetStageLevelControl(stageId) + -- 有首通 + if not stageInfo.Passed then + if controlCfg and controlCfg.FirstRewardShow > 0 then + rewardId = controlCfg.FirstRewardShow + IsFirst = true + elseif stageCfg.FirstRewardShow > 0 then + rewardId = stageCfg.FirstRewardShow + IsFirst = true + end + end + + -- 没首通 + if not IsFirst then + if controlCfg and controlCfg.FinishRewardShow > 0 then + rewardId = controlCfg.FinishRewardShow + else + rewardId = stageCfg.FinishRewardShow + end + end + + local rewards = {} + if rewardId > 0 then + rewards = IsFirst and XRewardManager.GetRewardList(rewardId) or XRewardManager.GetRewardListNotCount(rewardId) + end + + if rewards then + for i, item in ipairs(rewards) do + local grid + if self.GridList[i] then + grid = self.GridList[i] + else + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommon, self.PanelDropContent) + grid = XUiGridCommon.New(self, ui) + self.GridList[i] = grid + end + -- 经验值道具特殊处理 + if item.TemplateId == self.ActTemplate.ExpId then + local itemId = self.ActTemplate.ExpId + local data = XTool.Clone(XGoodsCommonManager.GetGoodsShowParamsByTemplateId(itemId)) + data.IsTempItemData = true + data.OwnCount = XDataCenter.FubenHackManager.GetTotalExp() + data.Count = item.Count + data.Description = XGoodsCommonManager.GetGoodsDescription(itemId) + data.WorldDesc = XGoodsCommonManager.GetGoodsWorldDesc(itemId) + grid:Refresh(data) + else + grid:Refresh(item) + end + grid.GameObject:SetActive(true) + end + end + + local rewardsCount = 0 + if rewards then + rewardsCount = #rewards + end + + for j = 1, #self.GridList do + if j > rewardsCount then + self.GridList[j].GameObject:SetActive(false) + end + end + + self.GridCommon.gameObject:SetActiveEx(false) +end + +function XUiFubenHackSection:OnBtnEnterClick() + if not self.StageId then + XLog.Error("XUiFubenHackSection:OnBtnEnterClick 函数错误: 变量stageId为空 " .. tostring(self.StageId)) + return + end + local stageId = self.StageId + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + if not stageCfg then + local path = XFubenConfigs.GetTableStagePath() + XLog.ErrorTableDataNotFound("XUiFubenHackSection:OnBtnEnterClick", "StageCfg", path, "stageId", tostring(stageId)) + return + end + + if XDataCenter.FubenManager.CheckPreFight(stageCfg) then + XEventManager.DispatchEvent(XEventId.EVENT_FUBEN_CLOSE_FUBENSTAGEDETAIL) + XLuaUiManager.Open("UiNewRoomSingle", stageCfg.StageId) + self:Close() + end +end + +function XUiFubenHackSection:OnBtnTargetClick() + XLuaUiManager.Open("UiFubenHackDetails", self.StageId) + XDataCenter.FubenHackManager.SetReadDetailMark(self.StageId) + self.BtnTarget:ShowReddot(false) +end + +function XUiFubenHackSection:OnBtnCloseClick() + XEventManager.DispatchEvent(XEventId.EVENT_FUBEN_CLOSE_FUBENSTAGEDETAIL) + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenHack/XUiHackDevelop.lua b/Resources/Scripts/XUi/XUiFubenHack/XUiHackDevelop.lua new file mode 100644 index 00000000..c254eecf --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenHack/XUiHackDevelop.lua @@ -0,0 +1,174 @@ +local XUiHackDevelop = XLuaUiManager.Register(XLuaUi, "UiHackDevelop") + +local XUiPanelLevelInfo = require("XUi/XUiFubenHack/ChildView/XUiPanelLevelInfo") +local XUiPanelBuffDetail = require("XUi/XUiFubenHack/ChildView/XUiPanelBuffDetail") +local XUiGridLevelBuff = require("XUi/XUiFubenHack/ChildItem/XUiGridLevelBuff") + +function XUiHackDevelop:OnAwake() + self:AutoAddListener() +end + +function XUiHackDevelop:OnStart() + self.ActTemplate = XDataCenter.FubenHackManager.GetCurrentActTemplate() + self:InitUi() + self:Refresh() + XScheduleManager.ScheduleOnce(function() + self:MoveIntoBuff(XDataCenter.FubenHackManager.GetBuffListShowIndex()) + end, 0) + self.IsPlayingAnim = false + self.IsPlayedAnim = false +end + +function XUiHackDevelop:OnGetEvents() + return { XEventId.EVENT_FUBEN_HACK_UPDATE, + XEventId.EVENT_ACTIVITY_ON_RESET} +end + +function XUiHackDevelop:OnNotify(evt, ...) + local args = { ... } + if evt == XEventId.EVENT_FUBEN_HACK_UPDATE then + self:Refresh(args) + elseif evt == XEventId.EVENT_ACTIVITY_ON_RESET then + if args[1] ~= XDataCenter.FubenManager.StageType.Hack then return end + XDataCenter.FubenHackManager.OnActivityEnd() + end +end + +function XUiHackDevelop:OnDestroy() + for i, v in pairs(self.LvBuffList)do + v:OnDestroy() + self.LvBuffList[i] = nil + end +end + +function XUiHackDevelop:OnBtnExpandClick() + XEventManager.DispatchEvent(XEventId.EVENT_FUBEN_HACK_CLICK) + if self.IsPlayingAnim then return end + self.BtnExpand.gameObject:SetActiveEx(false) + self.IsPlayingAnim = true + self:PlayAnimation("PanelQuanRotate", function() + self.IsPlayedAnim = true + self.IsPlayingAnim = false + self:PlayAnimation("PanelQuanLoop") + end) +end + +function XUiHackDevelop:InitUi() + self.TxtTitle.text = CSXTextManagerGetText("FubenHackDevelop") + self.TxtTitleEn.text = CSXTextManagerGetText("FubenHackDevelopEn") + + self.AssetActivityPanel = XUiPanelActivityAsset.New(self.PanelSpecialTool, true) + self.PanelLevelInfo = XUiPanelLevelInfo.New(self, self.PanelLvInfo) + self.BtnBuffBarList = {} + for i = 1, XFubenHackConfig.BuffBarCapacity do + self.BtnBuffBarList[i] = self["BtnBuffBar"..i] + self.BtnBuffBarList[i].CallBack = function() self:OnBtnBuffBarClick(i) end + end + self.LvBuffList = {} + for i = 1, XDataCenter.FubenHackManager.GetMaxLevel() do + local ui = CS.UnityEngine.Object.Instantiate(self.GridBuff, self.BuffListContent) + ui.name = i + self.LvBuffList[i] = XUiGridLevelBuff.New(self, ui) + end + self.GridBuff.gameObject:SetActiveEx(false) + self.PanelBuffDetail = {} + self.PanelBuffDetail[XFubenHackConfig.PopUpPos.Left] = XUiPanelBuffDetail.New(self, self.PanelSelectLeft) + self.PanelBuffDetail[XFubenHackConfig.PopUpPos.Right] = XUiPanelBuffDetail.New(self, self.PanelSelectRight) +end + +function XUiHackDevelop:MoveIntoBuff(level, isPlayAnim) + if level <= 0 or level > XDataCenter.FubenHackManager.GetMaxLevel() then return end + local height = CS.XResolutionManager.OriginHeight + local gridRect = self.LvBuffList[level].Transform + local tarPosY = (height / 4) - gridRect.localPosition.y + local tarPos = self.BuffListContent.localPosition + --XLog.Warning(tarPosY, self.BuffListContent.localPosition.y) + tarPos.y = tarPosY + self.SRBuffList.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Unrestricted + if isPlayAnim then + if tarPosY - self.BuffListContent.localPosition.y < height / 2 and + tarPosY - self.BuffListContent.localPosition.y > -40 then + self.SRBuffList.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Elastic + return + end + XUiHelper.DoMove(self.BuffListContent, tarPos, 0.5, XUiHelper.EaseType.Sin, function() + self.SRBuffList.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Elastic + end) + else + self.BuffListContent.localPosition = tarPos + self.SRBuffList.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Elastic + end +end + +function XUiHackDevelop:Refresh() + self.BuffBarList = XDataCenter.FubenHackManager.GetBuffBarList() + + self.AssetActivityPanel:Refresh({self.ActTemplate.TicketId}) + + for i = 1, XFubenHackConfig.BuffBarCapacity do + self.BtnBuffBarList[i]:SetButtonState(XDataCenter.FubenHackManager.IsBuffPosUnlock(i) and XUiButtonState.Normal or XUiButtonState.Disable) + local item = self.BtnBuffBarList[i].transform + local imgPlus = item:Find("ImgPlus") + local rimgBuff = item:Find("RImgBuff"):GetComponent("RawImage") + if self.BuffBarList[i] == 0 then + imgPlus.gameObject:SetActiveEx(XDataCenter.FubenHackManager.IsBuffPosUnlock(i)) + rimgBuff.gameObject:SetActiveEx(false) + else + imgPlus.gameObject:SetActiveEx(false) + rimgBuff.gameObject:SetActiveEx(true) + rimgBuff:SetRawImage(XFubenHackConfig.GetBuffById(self.BuffBarList[i]).Icon) + if self.BuffBarLastState and self.BuffBarLastState[i] == 0 then + self.BtnBuffBarList[i]:ShowTag(false) + self.BtnBuffBarList[i]:ShowTag(true) + end + end + end + self.BuffBarLastState = XTool.Clone(self.BuffBarList) + + for i = 1, XDataCenter.FubenHackManager.GetMaxLevel() do + self.LvBuffList[i]:Refresh(i) + end + + self.PanelLevelInfo:Refresh() +end + +function XUiHackDevelop:AutoAddListener() + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + + self:BindHelpBtn(self.BtnHelp, "FubenHack") + + self:RegisterClickEvent(self.BtnExpand, self.OnBtnExpandClick) +end + +function XUiHackDevelop:OpenPanelBuffDetail(buffId, pos) + self.PanelBuffDetail[pos]:Show(buffId) +end + +function XUiHackDevelop:OnBtnBuffBarClick(index) + --for i = 1, XDataCenter.FubenHackManager.GetMaxLevel() do + -- local buffId = XDataCenter.FubenHackManager.GetLevelCfg(i).Id + -- if self.BuffBarList[index] == buffId then + -- self:MoveIntoBuff(i, true) + -- break + -- end + --end + + local res, level = XDataCenter.FubenHackManager.IsBuffPosUnlock(index) + if res then + XEventManager.DispatchEvent(XEventId.EVENT_FUBEN_HACK_CLICK, self.BuffBarList[index], true) + else + XUiManager.TipMsg(CS.XTextManager.GetText("FubenHackBuffPosLockTip", level)) + end + + if not self.IsPlayedAnim or self.IsPlayingAnim or self.BuffBarList[index] == 0 then return end + self:OpenPanelBuffDetail(self.BuffBarList[index], XFubenHackConfig.PopUpPos.Left) +end + +function XUiHackDevelop:OnBtnBackClick() + self:Close() +end + +function XUiHackDevelop:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end diff --git a/Resources/Scripts/XUi/XUiFubenHack/XUiHackLevelUpTips.lua b/Resources/Scripts/XUi/XUiFubenHack/XUiHackLevelUpTips.lua new file mode 100644 index 00000000..ad699898 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenHack/XUiHackLevelUpTips.lua @@ -0,0 +1,34 @@ +local XUiHackLevelUpTips = XLuaUiManager.Register(XLuaUi, "UiHackLevelUpTips") + +function XUiHackLevelUpTips:OnStart(lastLevel, curLevel, cb) + self.LastLevel = lastLevel + self.CurLevel = curLevel + self.Cb = cb + self.BtnClose.CallBack = function() self:OnBtnCloseClick() end + self:RefreshLevel() +end + +function XUiHackLevelUpTips:RefreshLevel() + self.TxtLastLevel.text = "Lv." .. self.LastLevel + self.TxtCurrentLevel.text = "Lv." .. self.CurLevel + self.TxtTitle.text = CS.XTextManager.GetText("FubenHackLevelUpTitle") + self.TxtDesc.text = CS.XTextManager.GetText("FubenHackLevelUpDesc") + self.TxtUnlockBuffPos.gameObject:SetActiveEx(false) + + for pos = 1, XFubenHackConfig.BuffBarCapacity do + local _, level = XDataCenter.FubenHackManager.IsBuffPosUnlock(pos) + if self.LastLevel < level and self.CurLevel == level then + self.TxtUnlockBuffPos.gameObject:SetActiveEx(true) + break + end + end +end + +function XUiHackLevelUpTips:OnBtnCloseClick() + if self.Cb then + self.Cb() + end + self:Close() +end + +return XUiHackLevelUpTips \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridChooseReward.lua b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridChooseReward.lua new file mode 100644 index 00000000..633b1358 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridChooseReward.lua @@ -0,0 +1,68 @@ +local XUiGridInfestorExploreCore = require("XUi/XUiFubenInfestorExplore/XUiGridInfestorExploreCore") + +local CONDITION_COLOR = { + [true] = CS.UnityEngine.Color.black, + [false] = CS.UnityEngine.Color.red, +} + +local XUiGridChooseReward = XClass(nil, "XUiGridChooseReward") + +function XUiGridChooseReward:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + local icon = XDataCenter.FubenInfestorExploreManager.GetMoneyIcon() + self.RImgCost:SetRawImage(icon) + + self.PanelRewards.gameObject:SetActiveEx(false) + + self.IsFirstPlayFanpai = true +end + +function XUiGridChooseReward:InitRootUi(rootUi) + self.RootUi = rootUi +end + +function XUiGridChooseReward:Refresh(rewardId) + self.GridCore = self.GridCore or XUiGridInfestorExploreCore.New(self.GridInfestorExploreCore, self.RootUi) + local coreId = XFubenInfestorExploreConfigs.GetRewardCoreId(rewardId) + local coreLevel = XFubenInfestorExploreConfigs.GetRewardCoreLevel(rewardId) + self.GridCore:Refresh(coreId, coreLevel) + + local buyTimes = XDataCenter.FubenInfestorExploreManager.GetFightRewadBuyTimes() + if buyTimes > 0 then + local isRewardBuy = XDataCenter.FubenInfestorExploreManager.IsFightRewadBuy(rewardId) + if isRewardBuy then + self.TxtSpend.gameObject:SetActiveEx(false) + self.TxtSellOut.gameObject:SetActiveEx(true) + else + local cost = XFubenInfestorExploreConfigs.GetFightRewardCost(buyTimes + 1) + self.TxtSpend.text = cost + self.TxtSpend.color = CONDITION_COLOR[XDataCenter.FubenInfestorExploreManager.CheckMoneyEnough(cost)] + + self.TxtSpend.gameObject:SetActiveEx(true) + self.TxtSellOut.gameObject:SetActiveEx(false) + end + --获得品质 + local quality = XFubenInfestorExploreConfigs.GetCoreQuality(coreId) + --1 金色 2 紫色 + if self.IsFirstPlayFanpai then + self.IsFirstPlayFanpai = false + if XFubenInfestorExploreConfigs.IsPrecious(quality) then + XScheduleManager.ScheduleOnce(function() + self.UiFanpai1:Play() + end, 0) + else + XScheduleManager.ScheduleOnce(function() + self.UiFanpai2:Play() + end, 0) + end + end + self.PanelLock.gameObject:SetActiveEx(false) + else + self.PanelLock.gameObject:SetActiveEx(true) + end +end + +return XUiGridChooseReward \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridFubenInfestorExploreChapter.lua b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridFubenInfestorExploreChapter.lua new file mode 100644 index 00000000..e9cb0c35 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridFubenInfestorExploreChapter.lua @@ -0,0 +1,55 @@ +local XUiGridFubenInfestorExploreChapter = XClass(nil, "XUiGridFubenInfestorExploreChapter") + +function XUiGridFubenInfestorExploreChapter:Ctor(ui, clickCb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.ClickCb = clickCb + + XTool.InitUiObject(self) + self.BtnClick.CallBack = function() self:OnClickBtnClick() end +end + +function XUiGridFubenInfestorExploreChapter:Refresh(chapterId) + self.ChapterId = chapterId + + local isHard = XDataCenter.FubenInfestorExploreManager.IsChapterRequireIsomer(chapterId) + local name = XFubenInfestorExploreConfigs.GetChapterName(chapterId) + + if XDataCenter.FubenInfestorExploreManager.IsChapterUnlock(chapterId) then + local icon = XFubenInfestorExploreConfigs.GetChapterIcon(chapterId) + self.RImgChapterIcon:SetRawImage(icon) + + self.TxtChapterName.text = name + + self.ImgHard.gameObject:SetActiveEx(isHard) + self.ImgEasy.gameObject:SetActiveEx(not isHard) + + self.PanelNormal.gameObject:SetActiveEx(true) + self.PanelDisable.gameObject:SetActiveEx(false) + else + self.TxtChapterNameDis.text = name + + self.ImgHardDis.gameObject:SetActiveEx(isHard) + self.ImgEasyDis.gameObject:SetActiveEx(not isHard) + + self.PanelNormal.gameObject:SetActiveEx(false) + self.PanelDisable.gameObject:SetActiveEx(true) + end + + self.ImgClear.gameObject:SetActiveEx(XDataCenter.FubenInfestorExploreManager.IsChapterPassed(chapterId)) +end + +function XUiGridFubenInfestorExploreChapter:OnClickBtnClick() + local chapterId = self.ChapterId + if XDataCenter.FubenInfestorExploreManager.IsChapterUnlock(chapterId) then + if XDataCenter.FubenInfestorExploreManager.IsChapterPassed(chapterId) then + XLuaUiManager.Open("UiInfestorExploreStage", chapterId) + else + self.ClickCb() + end + else + XUiManager.TipText("InfestorExploreChapterLockTip") + end +end + +return XUiGridFubenInfestorExploreChapter \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridFubenInfestorExploreChapter2Stage.lua b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridFubenInfestorExploreChapter2Stage.lua new file mode 100644 index 00000000..682f606e --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridFubenInfestorExploreChapter2Stage.lua @@ -0,0 +1,35 @@ +local XUiGridFubenInfestorExploreChapter2Stage = XClass(nil, "XUiGridFubenInfestorExploreChapter2Stage") + +function XUiGridFubenInfestorExploreChapter2Stage:Ctor(ui, clickCb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.ClickCb = clickCb + + XTool.InitUiObject(self) + self.BtnClick.CallBack = function() self:OnClickBtnClick() end + + self.Normal.gameObject:SetActiveEx(true) + self.Disable.gameObject:SetActiveEx(false) +end + +function XUiGridFubenInfestorExploreChapter2Stage:Refresh(stageId) + self.StageId = stageId + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + + local icon = stageCfg.Icon + if not string.IsNilOrEmpty(icon) then + self.RImgIcon:SetRawImage(icon) + end + + self.TxtName.text = stageCfg.Name + + local score = XDataCenter.FubenInfestorExploreManager.GetChapter2StageScore(stageId) + self.TxtScore.text = score +end + +function XUiGridFubenInfestorExploreChapter2Stage:OnClickBtnClick() + local stageId = self.StageId + self.ClickCb(stageId) +end + +return XUiGridFubenInfestorExploreChapter2Stage \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridFubenInfestorExploreMember.lua b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridFubenInfestorExploreMember.lua new file mode 100644 index 00000000..bf6d4190 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridFubenInfestorExploreMember.lua @@ -0,0 +1,63 @@ +local CSXTextManagerGetText = CS.XTextManager.GetText + +local XUiGridFubenInfestorExploreMember = XClass(nil, "XUiGridFubenInfestorExploreMember") + +function XUiGridFubenInfestorExploreMember:Ctor(ui, clickCb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + if self.BtnClick then + self.BtnClick.CallBack = function() clickCb() end + end + self:SetSelect(false) +end + +function XUiGridFubenInfestorExploreMember:Refresh(characterId, isCaptain, isFirstFight) + if not characterId then return end + + if self.TxtName then + self.TxtName.text = XCharacterConfigs.GetCharacterFullNameStr(characterId) + end + + if self.RImgHead then + local icon = XDataCenter.CharacterManager.GetCharBigHeadIcon(characterId) + self.RImgHead:SetRawImage(icon) + end + + if self.RImgHalf then + local halfIcon = XDataCenter.CharacterManager.GetCharHalfBodyImage(characterId) + self.RImgHalf:SetRawImage(halfIcon) + end + + if self.RImgHeadSmall then + local smallIcon = XDataCenter.CharacterManager.GetCharRoundnessHeadIcon(characterId) + self.RImgHeadSmall:SetRawImage(smallIcon) + end + + if self.ImgLeader then + self.ImgLeader.gameObject:SetActiveEx(isCaptain) + end + + if self.ImgFirstRole then + self.ImgFirstRole.gameObject:SetActiveEx(isFirstFight) + end + + local hpPercent = XDataCenter.FubenInfestorExploreManager.GetCharacterHpPrecent(characterId) + if self.TxtHpPercent then + self.TxtHpPercent.text = CSXTextManagerGetText("InfestorExploreCharacterHpPercent", hpPercent) + end + if self.TxtHp then + self.TxtHp.text = CSXTextManagerGetText("InfestorExploreCharacterHpPercent", hpPercent) + end + if self.ImgHpProgress then + self.ImgHpProgress.fillAmount = hpPercent * 0.01 + end +end + +function XUiGridFubenInfestorExploreMember:SetSelect(value) + if self.ImgSelect then + self.ImgSelect.gameObject:SetActiveEx(value) + end +end + +return XUiGridFubenInfestorExploreMember \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridFubenInfestorExploreOccupiedPlayer.lua b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridFubenInfestorExploreOccupiedPlayer.lua new file mode 100644 index 00000000..fd01a7e2 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridFubenInfestorExploreOccupiedPlayer.lua @@ -0,0 +1,22 @@ +local XUiGridFubenInfestorExploreOccupiedPlayer = XClass(nil, "XUiGridFubenInfestorExploreOccupiedPlayer") + +function XUiGridFubenInfestorExploreOccupiedPlayer:Ctor(ui, playerId) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + local name = XDataCenter.FubenInfestorExploreManager.GetPlayerName(playerId) + self.TxtName.text = name + + local headId = XDataCenter.FubenInfestorExploreManager.GetPlayerHeadId(playerId) + local frameId = XDataCenter.FubenInfestorExploreManager.GetPlayerHeadFrameId(playerId) + + XUiPLayerHead.InitPortrait(headId, frameId, self.HeadMe) + XUiPLayerHead.InitPortrait(headId, frameId, self.HeadPeople) + + local isMe = playerId == XPlayer.Id + self.PanelMe.gameObject:SetActiveEx(isMe) + self.PanelPeople.gameObject:SetActiveEx(not isMe) +end + +return XUiGridFubenInfestorExploreOccupiedPlayer \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridFubenInfestorExploreStage.lua b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridFubenInfestorExploreStage.lua new file mode 100644 index 00000000..edcce63a --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridFubenInfestorExploreStage.lua @@ -0,0 +1,49 @@ +local XUiGridFubenInfestorExploreStage = XClass(nil, "XUiGridFubenInfestorExploreStage") + +function XUiGridFubenInfestorExploreStage:Ctor(rootUi, chapterId, nodeId, clickCb) + self.RootUi = rootUi + self.ChapterId = chapterId + self.NodeId = nodeId + self.ClickCb = clickCb +end + +function XUiGridFubenInfestorExploreStage:Refresh(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + if self.BtnClick then + CsXUiHelper.RegisterClickEvent(self.BtnClick, function() self:OnClickBtnClick() end) + end + + self:SetSelect(false) + + local chapterId = self.ChapterId + local nodeId = self.NodeId + if self.ImgIcon then + local icon = XDataCenter.FubenInfestorExploreManager.GetNodeTypeIcon(chapterId, nodeId) + self.RootUi:SetUiSprite(self.ImgIcon, icon) + end +end + +function XUiGridFubenInfestorExploreStage:OnClickBtnClick() + local chapterId = self.ChapterId + local nodeId = self.NodeId + + if XDataCenter.FubenInfestorExploreManager.IsNodeCurrent(chapterId, nodeId) + or XDataCenter.FubenInfestorExploreManager.IsNodeReach(chapterId, nodeId) + or XDataCenter.FubenInfestorExploreManager.IsNodePassed(chapterId, nodeId) + or XDataCenter.FubenInfestorExploreManager.IsNodeUnReach(chapterId, nodeId) then + self.ClickCb(self, nodeId) + elseif XDataCenter.FubenInfestorExploreManager.IsNodeFog(chapterId, nodeId) then + XUiManager.TipText("InfestorExploreNodeFogTip") + end +end + +function XUiGridFubenInfestorExploreStage:SetSelect(value) + if self.PanelSelect then + self.PanelSelect.gameObject:SetActiveEx(value) + end +end + +return XUiGridFubenInfestorExploreStage \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridInfestorExploreBuff.lua b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridInfestorExploreBuff.lua new file mode 100644 index 00000000..6a8f2e1a --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridInfestorExploreBuff.lua @@ -0,0 +1,15 @@ +local XUiGridInfestorExploreBuff = XClass(nil, "XUiGridInfestorExploreBuff") + +function XUiGridInfestorExploreBuff:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiGridInfestorExploreBuff:Refresh(buffId) + self.TxtName.text = XFubenInfestorExploreConfigs.GetBuffName(buffId) + self.TxtDetails.text = XFubenInfestorExploreConfigs.GetBuffDes(buffId) + self.RImgBuffIcon:SetRawImage(XFubenInfestorExploreConfigs.GetBuffIcon(buffId)) +end + +return XUiGridInfestorExploreBuff \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridInfestorExploreContract.lua b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridInfestorExploreContract.lua new file mode 100644 index 00000000..15b586f6 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridInfestorExploreContract.lua @@ -0,0 +1,33 @@ +local XUiGridInfestorExploreEvent = require("XUi/XUiFubenInfestorExplore/XUiGridInfestorExploreEvent") + +local XUiGridInfestorExploreContract = XClass(nil, "XUiGridInfestorExploreContract") + +function XUiGridInfestorExploreContract:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + self:SetSelect(false) +end + +function XUiGridInfestorExploreContract:InitRootUi(rootUi) + self.RootUi = rootUi +end + +function XUiGridInfestorExploreContract:Refresh(shopEventId) + local cost = XFubenInfestorExploreConfigs.GetEventGoodsCost(shopEventId) + self.TxtPrice.text = cost + + self.EventGrid = self.EventGrid or XUiGridInfestorExploreEvent.New(self.GridEvent, self.RootUi) + self.EventGrid:Refresh(shopEventId) + + self.ImgSellOut.gameObject:SetActiveEx(XDataCenter.FubenInfestorExploreManager.IsShopEventSellOut()) +end + +function XUiGridInfestorExploreContract:SetSelect(value) + if self.ImgSelect then + self.ImgSelect.gameObject:SetActiveEx(value) + end +end + +return XUiGridInfestorExploreContract \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridInfestorExploreCore.lua b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridInfestorExploreCore.lua new file mode 100644 index 00000000..525d48b0 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridInfestorExploreCore.lua @@ -0,0 +1,73 @@ +local MAX_LEVEL_NUM = 6 + +local XUiGridInfestorExploreCore = XClass(nil, "XUiGridInfestorExploreCore") + +function XUiGridInfestorExploreCore:Ctor(ui, rootUi, clickCb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + self:InitRootUi(rootUi) + self:SetSelect(false) + + if self.BtnClick then + self.BtnClick.CallBack = function() if clickCb then clickCb() end end + end +end + +function XUiGridInfestorExploreCore:InitRootUi(rootUi) + self.RootUi = rootUi +end + +function XUiGridInfestorExploreCore:Refresh(coreId, coreLevel, isNotShowImgHave) + if self.RImgIcon then + local icon = XFubenInfestorExploreConfigs.GetCoreIcon(coreId) + self.RImgIcon:SetRawImage(icon) + end + + if self.ImgQuality then + local qualityIcon = XFubenInfestorExploreConfigs.GetCoreQualityIcon(coreId) + self.RootUi:SetUiSprite(self.ImgQuality, qualityIcon) + end + + local curLv = coreLevel or XDataCenter.FubenInfestorExploreManager.GetCoreLevel(coreId) + local maxLv = XFubenInfestorExploreConfigs.GetCoreMaxLevel(coreId) + for i = 1, MAX_LEVEL_NUM do + local belowMaxLv = i <= maxLv + self["GridLevel" .. i].gameObject:SetActiveEx(belowMaxLv) + self["ImgMaxLevel" .. i].gameObject:SetActiveEx(belowMaxLv) + + local belowCurLv = i <= curLv + self["ImgCurLevel" .. i].gameObject:SetActiveEx(belowCurLv) + end + + if self.TxtMax then + self.TxtMax.gameObject:SetActiveEx(curLv == maxLv) + end + + if self.TxtName then + self.TxtName.text = XFubenInfestorExploreConfigs.GetCoreName(coreId) + end + + if self.TxtDes then + self.TxtDes.text = XFubenInfestorExploreConfigs.GetCoreLevelDes(coreId, curLv) + end + + local isHaveCore = XDataCenter.FubenInfestorExploreManager.IsHaveCore(coreId) + local bagCoreLevel = isHaveCore and XDataCenter.FubenInfestorExploreManager.GetCoreLevel(coreId) or 0 + if self.ImgHave then + self.ImgHave.gameObject:SetActiveEx(not isNotShowImgHave and isHaveCore and bagCoreLevel < maxLv) + end + + if self.ImgHaveMax then + self.ImgHaveMax.gameObject:SetActiveEx(not isNotShowImgHave and isHaveCore and bagCoreLevel >= maxLv) + end +end + +function XUiGridInfestorExploreCore:SetSelect(value) + if self.ImgSelect then + self.ImgSelect.gameObject:SetActiveEx(value) + end +end + +return XUiGridInfestorExploreCore \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridInfestorExploreEvent.lua b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridInfestorExploreEvent.lua new file mode 100644 index 00000000..802ec57f --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridInfestorExploreEvent.lua @@ -0,0 +1,19 @@ +local XUiGridInfestorExploreEvent = XClass(nil, "XUiGridInfestorExploreEvent") + +function XUiGridInfestorExploreEvent:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) +end + +function XUiGridInfestorExploreEvent:Refresh(eventId) + self.TxtName.text = XFubenInfestorExploreConfigs.GetEventName(eventId) + self.TxtDetails.text = XFubenInfestorExploreConfigs.GetEventDes(eventId) + self.RImgBuffIcon:SetRawImage(XFubenInfestorExploreConfigs.GetEventIcon(eventId)) + if self.ImgQuality then + self.RootUi:SetUiSprite(XFubenInfestorExploreConfigs.GetEventQualityIcon(eventId)) + end +end + +return XUiGridInfestorExploreEvent \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridInfestorExploreOutPostStory.lua b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridInfestorExploreOutPostStory.lua new file mode 100644 index 00000000..605e8736 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridInfestorExploreOutPostStory.lua @@ -0,0 +1,14 @@ +local XUiGridInfestorExploreOutPostStory = XClass(nil, "XUiGridInfestorExploreOutPostStory") + +function XUiGridInfestorExploreOutPostStory:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiGridInfestorExploreOutPostStory:Refresh(des, timestamp) + self.TxtTime.text = XTime.TimestampToGameDateTimeString(timestamp) + self.TxtDescribe.text = des +end + +return XUiGridInfestorExploreOutPostStory \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridInfestorExplorePlayerMessage.lua b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridInfestorExplorePlayerMessage.lua new file mode 100644 index 00000000..8a81cf53 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridInfestorExplorePlayerMessage.lua @@ -0,0 +1,34 @@ +local XUiGridInfestorExplorePlayerMessage = XClass(nil, "XUiGridInfestorExplorePlayerMessage") + +function XUiGridInfestorExplorePlayerMessage:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) +end + +function XUiGridInfestorExplorePlayerMessage:Refresh(msg) + local playerId = msg.Id + + local headId = XDataCenter.FubenInfestorExploreManager.GetPlayerHeadId(playerId) + local frameId = XDataCenter.FubenInfestorExploreManager.GetPlayerHeadFrameId(playerId) + + XUiPLayerHead.InitPortrait(headId, frameId, self.Head) + + local name = XDataCenter.FubenInfestorExploreManager.GetPlayerName(playerId) + self.TxtName.text = name + + local level = XDataCenter.FubenInfestorExploreManager.GetPlayerLevel(playerId) + + XUiPlayerLevel.UpdateLevel(level, self.TxtLevel) + + local diffName = XDataCenter.FubenInfestorExploreManager.GetPlayerDiffName(playerId) + self.TxtRegion.text = diffName + + local diffIcon = XDataCenter.FubenInfestorExploreManager.GetPlayerDiffIcon(playerId) + self.RImgIconRegion:SetRawImage(diffIcon) + + self.TxtMsg.text = msg.Msg +end + +return XUiGridInfestorExplorePlayerMessage \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridInfestorExploreRank.lua b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridInfestorExploreRank.lua new file mode 100644 index 00000000..65accc12 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridInfestorExploreRank.lua @@ -0,0 +1,65 @@ +local CSXTextManagerGetText = CS.XTextManager.GetText + +local IS_ME_CONDITION_COLOR = { + [true] = XUiHelper.Hexcolor2Color("59f5ffff"), + [false] = CS.UnityEngine.Color.white, +} + +local XUiGridInfestorExploreRank = XClass(nil, "XUiGridInfestorExploreRank") + +function XUiGridInfestorExploreRank:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + + if self.BtnClick then + self.BtnClick.CallBack = function() self:OnClickBtn() end + end +end + +function XUiGridInfestorExploreRank:Refresh(rankIndex) + self.RankIndex = rankIndex + + local playerRankData = XDataCenter.FubenInfestorExploreManager.GetPlayerRankData(rankIndex) + if not playerRankData then return end + + local playerId = playerRankData:GetPlayerId() + local myId = XPlayer.Id + local isMe = playerId == myId + + self.TxtRank.text = "NO." .. rankIndex + self.TxtRank.color = IS_ME_CONDITION_COLOR[isMe] + + local headPortraitId = playerRankData:GetHeadPortraitId() + local headFrameId = playerRankData:GetHeadFrameId() + XUiPLayerHead.InitPortrait(headPortraitId, headFrameId, self.Head) + + self.TxtSign.text = playerRankData:GetSign() + self.TxtName.text = playerRankData:GetName() + self.TxtName.color = IS_ME_CONDITION_COLOR[isMe] + self.TxtSign.color = IS_ME_CONDITION_COLOR[isMe] + + if self.TxtPoint then + local chapterId = playerRankData:GetChapterId() + local chapterName = XFubenInfestorExploreConfigs.GetChapterName(chapterId) + self.TxtPoint.text = chapterName + end + + if self.TxtScore then + local score = playerRankData:GetScore() + self.TxtScore.text = CSXTextManagerGetText("InfestorExploreRankScoreDes", score) + end + + self.ImgMe.gameObject:SetActiveEx(isMe) +end + +function XUiGridInfestorExploreRank:OnClickBtn() + local rankIndex = self.RankIndex + local playerId = XDataCenter.FubenInfestorExploreManager.GetRankPlayerId(rankIndex) + if playerId and playerId ~= XPlayer.Id then + XDataCenter.PersonalInfoManager.ReqShowInfoPanel(playerId) + end +end + +return XUiGridInfestorExploreRank \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridInfestorExploreRegionTitle.lua b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridInfestorExploreRegionTitle.lua new file mode 100644 index 00000000..2c1eaccd --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridInfestorExploreRegionTitle.lua @@ -0,0 +1,26 @@ +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate + +local XUiGridInfestorExploreRegionTitle = XClass(nil, "XUiGridInfestorExploreRegionTitle") + +function XUiGridInfestorExploreRegionTitle:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Grids = {} + XTool.InitUiObject(self) + self.GridItem.gameObject:SetActiveEx(false) +end + +function XUiGridInfestorExploreRegionTitle:Refresh(rankRegion, rewardList) + self.TxtRegional.text = XFubenInfestorExploreConfigs.GetRankRegionName(rankRegion) + + for index, data in pairs(rewardList) do + local grid = self.Grids[index] + if not grid then + grid = XUiGridCommon.New(self, CSUnityEngineObjectInstantiate(self.GridItem, self.PanelPrize)) + self.Grids[index] = grid + end + grid:Refresh(data) + end +end + +return XUiGridInfestorExploreRegionTitle \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridInfestorExploreShopGoods.lua b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridInfestorExploreShopGoods.lua new file mode 100644 index 00000000..201d7a8f --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridInfestorExploreShopGoods.lua @@ -0,0 +1,45 @@ +local XUiGridInfestorExploreCore = require("XUi/XUiFubenInfestorExplore/XUiGridInfestorExploreCore") + +local CONDITION_COLOR = { + [true] = CS.UnityEngine.Color.white, + [false] = CS.UnityEngine.Color.red, +} + +local XUiGridInfestorExploreShopGoods = XClass(nil, "XUiGridInfestorExploreShopGoods") + +function XUiGridInfestorExploreShopGoods:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + self:SetSelect(false) + + local icon = XDataCenter.FubenInfestorExploreManager.GetMoneyIcon() + self.RImgPrice:SetRawImage(icon) +end + +function XUiGridInfestorExploreShopGoods:InitRootUi(rootUi) + self.RootUi = rootUi +end + +function XUiGridInfestorExploreShopGoods:Refresh(goodsId) + local cost = XFubenInfestorExploreConfigs.GetGoodsCost(goodsId) + local isMoneyEnough = XDataCenter.FubenInfestorExploreManager.CheckMoneyEnough(cost) + self.TxtPrice.text = cost + self.TxtPrice.color = CONDITION_COLOR[isMoneyEnough] + + self.GridCore = self.GridCore or XUiGridInfestorExploreCore.New(self.GridInfestorExploreCore, self.RootUi) + local coreId = XFubenInfestorExploreConfigs.GetGoodsCoreId(goodsId) + local coreLevel = XFubenInfestorExploreConfigs.GetGoodsCoreLevel(goodsId) + self.GridCore:Refresh(coreId, coreLevel) + + self.ImgSellOut.gameObject:SetActiveEx(XDataCenter.FubenInfestorExploreManager.IsGoodsSellOut(goodsId)) +end + +function XUiGridInfestorExploreShopGoods:SetSelect(value) + if self.ImgSelect then + self.ImgSelect.gameObject:SetActiveEx(value) + end +end + +return XUiGridInfestorExploreShopGoods \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridInfestorShopReward.lua b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridInfestorShopReward.lua new file mode 100644 index 00000000..36befaac --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiGridInfestorShopReward.lua @@ -0,0 +1,45 @@ +local XUiGridInfestorExploreCore = require("XUi/XUiFubenInfestorExplore/XUiGridInfestorExploreCore") + +local CSXTextManagerGetText = CS.XTextManager.GetText + +local XUiGridInfestorShopReward = XClass(nil, "XUiGridInfestorShopReward") + +function XUiGridInfestorShopReward:Ctor(ui, rootUi, clickCb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + self:InitRootUi(rootUi) + self:SetSelect(false) +end + +function XUiGridInfestorShopReward:InitRootUi(rootUi) + self.RootUi = rootUi +end + +function XUiGridInfestorShopReward:Refresh(rewardId, chapterId, nodeId) + self.GridCore = self.GridCore or XUiGridInfestorExploreCore.New(self.GridInfestorExploreCore, self.RootUi) + local coreId = XFubenInfestorExploreConfigs.GetRewardCoreId(rewardId) + local coreLevel = XFubenInfestorExploreConfigs.GetRewardCoreLevel(rewardId) + self.GridCore:Refresh(coreId, coreLevel) + + if XDataCenter.FubenInfestorExploreManager.IsLastPlayerSelectReward(chapterId, nodeId, rewardId) then + + local headPortraitId = XDataCenter.FubenInfestorExploreManager.GetSelectRewardPlayerHeadId(chapterId, nodeId) + local headFrameId = XDataCenter.FubenInfestorExploreManager.GetSelectRewardPlayerHeadFrameId(chapterId, nodeId) + XUiPLayerHead.InitPortrait(headPortraitId, headFrameId, self.Head) + + local playerName = XDataCenter.FubenInfestorExploreManager.GetSelectRewardPlayerName(chapterId, nodeId) + self.TxtLastPlayer.text = CSXTextManagerGetText("InfestorExploreRewardNodeLastPlayerSelect", playerName) + + self.PanelPlayer.gameObject:SetActiveEx(true) + else + self.PanelPlayer.gameObject:SetActiveEx(false) + end +end + +function XUiGridInfestorShopReward:SetSelect(value) + self.ImgSelect.gameObject:SetActiveEx(value) +end + +return XUiGridInfestorShopReward \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreActivityResult.lua b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreActivityResult.lua new file mode 100644 index 00000000..61ecde5e --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreActivityResult.lua @@ -0,0 +1,29 @@ +local CSXTextManagerGetText = CS.XTextManager.GetText + +local XUiInfestorExploreActivityResult = XLuaUiManager.Register(XLuaUi, "UiInfestorExploreActivityResult") + +function XUiInfestorExploreActivityResult:OnAwake() + self:AutoAddListener() +end + +function XUiInfestorExploreActivityResult:OnStart(lastDiff, curDiff) + local icon = XDataCenter.FubenInfestorExploreManager.GetDiffIcon(curDiff) + self.RImgArenaLevel:SetRawImage(icon) + + local diffName = XDataCenter.FubenInfestorExploreManager.GetDiffName(curDiff) + if curDiff > lastDiff then + self.TxtInfo.text = CSXTextManagerGetText("InfestorExploreUpDiff", diffName) + elseif curDiff == lastDiff then + self.TxtInfo.text = CSXTextManagerGetText("InfestorExploreUnchangeDiff", diffName) + else + self.TxtInfo.text = CSXTextManagerGetText("InfestorExploreDownDiff", diffName) + end + + self.EffectUp.gameObject:SetActiveEx(curDiff > lastDiff) + self.EffectDown.gameObject:SetActiveEx(curDiff < lastDiff) + self.EffectStay.gameObject:SetActiveEx(curDiff == lastDiff) +end + +function XUiInfestorExploreActivityResult:AutoAddListener() + self.BtnBg.CallBack = function() self:Close() end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreChapter.lua b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreChapter.lua new file mode 100644 index 00000000..f28c8b16 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreChapter.lua @@ -0,0 +1,85 @@ +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate +local CSXTextManagerGetText = CS.XTextManager.GetText + +local XUiGridFubenInfestorExploreChapter = require("XUi/XUiFubenInfestorExplore/XUiGridFubenInfestorExploreChapter") + +local XUiInfestorExploreChapter = XLuaUiManager.Register(XLuaUi, "UiInfestorExploreChapter") + +function XUiInfestorExploreChapter:OnAwake() + self:AutoAddListener() + self.GridFubenInfestorExploreChapter.gameObject:SetActiveEx(false) + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) +end + +function XUiInfestorExploreChapter:OnStart() + self:InitView() +end + +function XUiInfestorExploreChapter:OnEnable() + self:RefreshView() +end + +function XUiInfestorExploreChapter:OnDestroy() + XCountDown.UnBindTimer(self, XCountDown.GTimerName.FubenInfestorExplore) +end + +function XUiInfestorExploreChapter:OnGetEvents() + return { XEventId.EVENT_INFESTOREXPLORE_RESET } +end + +function XUiInfestorExploreChapter:OnNotify(evt, ...) + if evt == XEventId.EVENT_INFESTOREXPLORE_RESET then + XDataCenter.FubenInfestorExploreManager.Reset() + end +end + +function XUiInfestorExploreChapter:InitView() + self.TxtBuffDes.text = XDataCenter.FubenInfestorExploreManager.GetBuffDes() + self.TxtTile.text = XDataCenter.FubenInfestorExploreManager.GetCurSectionName() + self.TxtLeftTimeDes.text = CSXTextManagerGetText("InfestorExplorLeftTimeDesSection1") + XCountDown.BindTimer(self, XCountDown.GTimerName.FubenInfestorExplore, function(time) + time = time > 0 and time or 0 + local timeText = XUiHelper.GetTime(time, XUiHelper.TimeFormatType.CHALLENGE) + self.TxtTime.text = timeText + end) +end + +function XUiInfestorExploreChapter:RefreshView() + self.ChapterGrids = self.ChapterGrids or {} + + local index = 1 + local chapterConfigs = XFubenInfestorExploreConfigs.GetChapterConfigs() + for chapterId in pairs(chapterConfigs) do + local grid = self.ChapterGrids[chapterId] + if not grid then + local go = CSUnityEngineObjectInstantiate(self.GridFubenInfestorExploreChapter, self["Chapter0" .. index]) + local clickCb = function() + if XDataCenter.FubenInfestorExploreManager.IsChapterTeamExist(chapterId) then + XLuaUiManager.Open("UiInfestorExploreStage", chapterId) + else + self:OpenOneChildUi("UiInfestorExploreChapterDetail", chapterId) + self:FindChildUiObj("UiInfestorExploreChapterDetail"):RefreshView(chapterId) + end + end + grid = XUiGridFubenInfestorExploreChapter.New(go, clickCb) + grid.GameObject:SetActiveEx(true) + self.ChapterGrids[chapterId] = grid + end + grid:Refresh(chapterId) + index = index + 1 + end +end + +function XUiInfestorExploreChapter:AutoAddListener() + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + self:BindHelpBtn(self.BtnHelpCourse, "InfestorExplore") +end + +function XUiInfestorExploreChapter:OnBtnBackClick() + self:Close() +end + +function XUiInfestorExploreChapter:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreChapterDetail.lua b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreChapterDetail.lua new file mode 100644 index 00000000..d7c1e67d --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreChapterDetail.lua @@ -0,0 +1,108 @@ +local XUiGridFubenInfestorExploreMember = require("XUi/XUiFubenInfestorExplore/XUiGridFubenInfestorExploreMember") + +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate +local CSXTextManagerGetText = CS.XTextManager.GetText +local TipTitle = CSXTextManagerGetText("InfestorExploreTeamChangeConfirmTitle") +local TipContent = CSXTextManagerGetText("InfestorExploreTeamChangeConfirmContent") +local MAX_MEMBER_NUM = 3 + +local XUiInfestorExploreChapterDetail = XLuaUiManager.Register(XLuaUi, "UiInfestorExploreChapterDetail") + +function XUiInfestorExploreChapterDetail:OnAwake() + self:AutoAddListener() + self.GridMember.gameObject:SetActiveEx(false) +end + +function XUiInfestorExploreChapterDetail:OnStart() + self.MemberGrids = {} +end + +function XUiInfestorExploreChapterDetail:RefreshView(chapterId) + self.ChapterId = chapterId + + self.TxtChapter.text = XFubenInfestorExploreConfigs.GetChapterName(chapterId) + self.TxtActionPoint.text = XDataCenter.FubenInfestorExploreManager.GetActionPoint() + + local chapterId = self.ChapterId + self.TxtDes.text = XFubenInfestorExploreConfigs.GetChapterDescription(chapterId) + + local characterLimitType = XFubenInfestorExploreConfigs.GetChapterCharacterLimitType(chapterId) + local limitBuffId = XFubenInfestorExploreConfigs.GetChapterLimitBuffId(chapterId) + if not XFubenConfigs.IsStageCharacterLimitConfigExist(characterLimitType) then + self.TxtConditions.gameObject:SetActiveEx(false) + else + self.TxtConditions.text = XFubenConfigs.GetChapterCharacterLimitText(characterLimitType, limitBuffId) + self.TxtConditions.gameObject:SetActiveEx(true) + end + + self.TxtEffectPosion.text = XDataCenter.FubenInfestorExploreManager.GetBuffDes() + + local characterIds = XDataCenter.FubenInfestorExploreManager.GetChapterTeamCharacterIds(chapterId) + local captainPos = XDataCenter.FubenInfestorExploreManager.GetChapterTeamCaptainPos(chapterId) + local firstFightPos = XDataCenter.FubenInfestorExploreManager.GetChapterTeamFirstFightPos(chapterId) + for pos = 1, MAX_MEMBER_NUM do + local characterId = characterIds[pos] + local isCaptain = pos == captainPos + local isFirstFight = pos == firstFightPos + local grid = self.MemberGrids[pos] + if characterId > 0 then + if not grid then + local go = CSUnityEngineObjectInstantiate(self.GridMember, self["PanelGrid" .. pos]) + grid = XUiGridFubenInfestorExploreMember.New(go) + self.MemberGrids[pos] = grid + end + grid:Refresh(characterId, isCaptain, isFirstFight) + grid.GameObject:SetActiveEx(true) + else + if grid then + grid.GameObject:SetActiveEx(false) + end + end + end +end + +function XUiInfestorExploreChapterDetail:AutoAddListener() + self.BtnBg.CallBack = function() self:Close() end + self.BtnTanchuangClose.CallBack = function() self:Close() end + self.BtnEnter.CallBack = function() self:OnClickBtnEnter() end + for index = 1, MAX_MEMBER_NUM do + self["BtnJoin" .. index].CallBack = function() self:OnClickBtnJoin() end + end +end + +function XUiInfestorExploreChapterDetail:OnClickBtnEnter() + local chapterId = self.ChapterId + if XDataCenter.FubenInfestorExploreManager.IsChapterTeamEmpty(chapterId) then + XUiManager.TipText("InfestorExploreTeamEmptyTip") + return + end + + if XDataCenter.FubenInfestorExploreManager.IsChapterTeamNoCaptain(chapterId) then + XUiManager.TipText("TeamManagerCheckCaptainNil") + return + end + + local sureCallback = function() + local callBack = function() + self:Close() + XUiManager.TipText("InfestorExploreTeamSaveSuc") + XLuaUiManager.Open("UiInfestorExploreStage", chapterId) + end + XDataCenter.FubenInfestorExploreManager.RequestUpdateTeam(chapterId, callBack) + end + XUiManager.DialogTip(TipTitle, TipContent, XUiManager.DialogType.Normal, nil, sureCallback) +end + +function XUiInfestorExploreChapterDetail:OnClickBtnJoin() + local chapterId = self.ChapterId + local characterIds = XDataCenter.FubenInfestorExploreManager.GetChapterTeamCharacterIds(chapterId) + local captainPos = XDataCenter.FubenInfestorExploreManager.GetChapterTeamCaptainPos(chapterId) + local firstFightPos = XDataCenter.FubenInfestorExploreManager.GetChapterTeamFirstFightPos(chapterId) + local saveCallBack = function(cacheCharacterIds, cacheCaptainPos, cacheFirstFightPos) + XDataCenter.FubenInfestorExploreManager.SaveChapterTeam(chapterId, cacheCharacterIds, cacheCaptainPos, cacheFirstFightPos) + self:RefreshView(self.ChapterId) + end + local characterLimitType = XFubenInfestorExploreConfigs.GetChapterCharacterLimitType(chapterId) + local limitBuffId = XFubenInfestorExploreConfigs.GetChapterLimitBuffId(chapterId) + XLuaUiManager.Open("UiInfestorExploreTeamEdit", characterLimitType, limitBuffId, characterIds, captainPos, saveCallBack, nil, nil, firstFightPos) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreChapterPart2.lua b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreChapterPart2.lua new file mode 100644 index 00000000..5d550d52 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreChapterPart2.lua @@ -0,0 +1,93 @@ +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate +local CSXTextManagerGetText = CS.XTextManager.GetText + +local XUiGridFubenInfestorExploreChapter2Stage = require("XUi/XUiFubenInfestorExplore/XUiGridFubenInfestorExploreChapter2Stage") + +local XUiInfestorExploreChapterPart2 = XLuaUiManager.Register(XLuaUi, "UiInfestorExploreChapterPart2") + +function XUiInfestorExploreChapterPart2:OnAwake() + self:AutoAddListener() + self.GridFubenInfestorExploreChapter2.gameObject:SetActiveEx(false) + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) +end + +function XUiInfestorExploreChapterPart2:OnStart() + self:InitView() +end + +function XUiInfestorExploreChapterPart2:OnEnable() + self:RefreshView() +end + +function XUiInfestorExploreChapterPart2:OnDestroy() + XCountDown.UnBindTimer(self, XCountDown.GTimerName.FubenInfestorExplore) +end + +function XUiInfestorExploreChapterPart2:OnGetEvents() + return { XEventId.EVENT_INFESTOREXPLORE_RESET } +end + +function XUiInfestorExploreChapterPart2:OnNotify(evt, ...) + if evt == XEventId.EVENT_INFESTOREXPLORE_RESET then + XDataCenter.FubenInfestorExploreManager.Reset() + end +end + +function XUiInfestorExploreChapterPart2:InitView() + self.TxtBuffDes.text = XDataCenter.FubenInfestorExploreManager.GetBuffDes() + self.TxtLeftTimeDes.text = CSXTextManagerGetText("InfestorExplorLeftTimeDesSection2") + self.TxtTile.text = XDataCenter.FubenInfestorExploreManager.GetCurSectionName() + XCountDown.BindTimer(self, XCountDown.GTimerName.FubenInfestorExplore, function(time) + time = time > 0 and time or 0 + local timeText = XUiHelper.GetTime(time, XUiHelper.TimeFormatType.CHALLENGE) + self.TxtTime.text = timeText + end) +end + +function XUiInfestorExploreChapterPart2:RefreshView() + self.StageGrids = self.StageGrids or {} + + local index = 1 + local stageIds = XDataCenter.FubenInfestorExploreManager.GetChapter2StageIds() + for _, stageId in pairs(stageIds) do + local grid = self.StageGrids[stageId] + if not grid then + local go = CSUnityEngineObjectInstantiate(self.GridFubenInfestorExploreChapter2, self["Chapter0" .. index]) + local clickCb = function(paramStageId) + self:OpenOneChildUi("UiInfestorExploreChapterPart2Detail", paramStageId) + self:FindChildUiObj("UiInfestorExploreChapterPart2Detail"):RefreshView(paramStageId) + end + grid = XUiGridFubenInfestorExploreChapter2Stage.New(go, clickCb) + grid.GameObject:SetActiveEx(true) + self.StageGrids[stageId] = grid + end + grid:Refresh(stageId) + index = index + 1 + end + + self.TxtScore.text = XDataCenter.FubenInfestorExploreManager.GetPlayerScore(XPlayer.Id) +end + +function XUiInfestorExploreChapterPart2:AutoAddListener() + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + self:BindHelpBtn(self.BtnHelpCourse, "InfestorExplore2") + self.BtnNegativeEffects.CallBack = function() self:OnClickBtnNegativeEffects() end + self.BtnTacticalCore.CallBack = function() self:OnClickBtnTacticalCore() end +end + +function XUiInfestorExploreChapterPart2:OnBtnBackClick() + self:Close() +end + +function XUiInfestorExploreChapterPart2:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiInfestorExploreChapterPart2:OnClickBtnNegativeEffects() + XLuaUiManager.Open("UiInfestorExploreDebuff") +end + +function XUiInfestorExploreChapterPart2:OnClickBtnTacticalCore() + XLuaUiManager.Open("UiInfestorExploreCore") +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreChapterPart2Detail.lua b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreChapterPart2Detail.lua new file mode 100644 index 00000000..5db0da09 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreChapterPart2Detail.lua @@ -0,0 +1,41 @@ +local XUiInfestorExploreChapterPart2Detail = XLuaUiManager.Register(XLuaUi, "UiInfestorExploreChapterPart2Detail") + +function XUiInfestorExploreChapterPart2Detail:OnAwake() + self:AutoAddListener() +end + +function XUiInfestorExploreChapterPart2Detail:OnEnable() + self:RefreshView(self.StageId) +end + +function XUiInfestorExploreChapterPart2Detail:RefreshView(stageId) + if not stageId then return end + + self.StageId = stageId + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + + self.TxtArenatName.text = stageCfg.Name + self.TxtDetails.text = stageCfg.Description + + local icon = stageCfg.StoryIcon + if not string.IsNilOrEmpty(icon) then + self.RImgIcon:SetRawImage(icon) + end + + local score = XDataCenter.FubenInfestorExploreManager.GetChapter2StageScore(stageId) + if score > 0 then + self.TxtArenaScore.text = CS.XTextManager.GetText("ArenaHighDesc", score) + else + self.TxtArenaScore.text = score + end +end + +function XUiInfestorExploreChapterPart2Detail:AutoAddListener() + self.BtnTanchuangClose.CallBack = function() self:Close() end + self.BtnEnterArena.CallBack = function() self:OnClickBtnEnter() end +end + +function XUiInfestorExploreChapterPart2Detail:OnClickBtnEnter() + local stageId = self.StageId + XLuaUiManager.Open("UiNewRoomSingle", stageId) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreChoose.lua b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreChoose.lua new file mode 100644 index 00000000..de56e756 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreChoose.lua @@ -0,0 +1,109 @@ +local XUiGridChooseReward = require("XUi/XUiFubenInfestorExplore/XUiGridChooseReward") + +local CSXTextManagerGetText = CS.XTextManager.GetText + +local XUiInfestorExploreChoose = XLuaUiManager.Register(XLuaUi, "UiInfestorExploreChoose") + +function XUiInfestorExploreChoose:OnAwake() + self:AutoAddListener() + self.GridChooseReward.gameObject:SetActiveEx(false) +end + +function XUiInfestorExploreChoose:OnStart(closeCb) + self.CloseCb = closeCb + + self:InitDynamicTable() + self:UpdateView() +end + +function XUiInfestorExploreChoose:OnDestroy() + if self.CloseCb then self.CloseCb() end +end + +function XUiInfestorExploreChoose:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelReward) + self.DynamicTable:SetProxy(XUiGridChooseReward) + self.DynamicTable:SetDelegate(self) +end + +function XUiInfestorExploreChoose:UpdateView() + local fightRewardIds = XDataCenter.FubenInfestorExploreManager.GetFightRewardIds() + self.FightRewardIds = fightRewardIds + + local buyTimes = XDataCenter.FubenInfestorExploreManager.GetFightRewadBuyTimes() + local hasBuy = buyTimes > 0 + self.BtnBack.gameObject:SetActiveEx(hasBuy) + + self.DynamicTable:SetDataSource(fightRewardIds) + self.DynamicTable:ReloadDataASync() + self:UpdateMoney() +end + +function XUiInfestorExploreChoose:UpdateMoney() + local count = XDataCenter.FubenInfestorExploreManager.GetMoneyCount() + self.TxtCost.text = "x" .. count +end + +function XUiInfestorExploreChoose:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:InitRootUi(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local rewardId = self.FightRewardIds[index] + grid:Refresh(rewardId) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + local rewardId = self.FightRewardIds[index] + + local isRewardBuy = XDataCenter.FubenInfestorExploreManager.IsFightRewadBuy(rewardId) + if isRewardBuy then return end + + local buyTimes = XDataCenter.FubenInfestorExploreManager.GetFightRewadBuyTimes() + local cost = XFubenInfestorExploreConfigs.GetFightRewardCost(buyTimes + 1) + local moneyName = XDataCenter.FubenInfestorExploreManager.GetMoneyName() + if not XDataCenter.FubenInfestorExploreManager.CheckMoneyEnough(cost) then + XUiManager.TipMsg(CSXTextManagerGetText("InfestorExploreFightRewardMoneyLack", moneyName)) + else + local buyFunc = function() + local callBack = function() + self:UpdateView() + end + XDataCenter.FubenInfestorExploreManager.RequestInfestorExploreBuyFightReward(rewardId, callBack) + end + + if cost > 0 then + local title = CSXTextManagerGetText("InfestorExploreFightRewardConfirmTitle") + local coreId = XFubenInfestorExploreConfigs.GetRewardCoreId(rewardId) + local coreName = XFubenInfestorExploreConfigs.GetCoreName(coreId) + local content = CSXTextManagerGetText("InfestorExploreFightRewardConfirmContent", cost, moneyName, coreName) + local sureCallback = function() + buyFunc() + end + XUiManager.DialogTip(title, content, XUiManager.DialogType.Normal, nil, sureCallback) + else + XDataCenter.FubenInfestorExploreManager.SetOpenInfestorExploreCoreDelay(1000) + buyFunc() + end + end + end +end + +function XUiInfestorExploreChoose:AutoAddListener() + self.BtnBack.CallBack = function() self:OnClickBtnBack() end + self.BtnRImgCost.CallBack = function() self:OnClickRImgCostBack() end +end + +function XUiInfestorExploreChoose:OnClickBtnBack() + local callBack = function() + XDataCenter.FubenInfestorExploreManager.ClearFightRewards() + end + XDataCenter.FubenInfestorExploreManager.RequestFinishAction(callBack) + + self:Close() +end + +function XUiInfestorExploreChoose:OnClickRImgCostBack() + local data = { + Id = XDataCenter.ItemManager.ItemId.InfestorMoney, + Count = XDataCenter.FubenInfestorExploreManager.GetMoneyCount() + } + XLuaUiManager.Open("UiTip", data) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreContract.lua b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreContract.lua new file mode 100644 index 00000000..0e32b8ce --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreContract.lua @@ -0,0 +1,125 @@ +local XUiGridInfestorExploreContract = require("XUi/XUiFubenInfestorExplore/XUiGridInfestorExploreContract") + +local CSXTextManagerGetText = CS.XTextManager.GetText + +local XUiInfestorExploreContract = XLuaUiManager.Register(XLuaUi, "UiInfestorExploreContract") + +function XUiInfestorExploreContract:OnAwake() + self.GridContract.gameObject:SetActiveEx(false) + self.PanelBuy.gameObject:SetActiveEx(false) + + self.DynamicTable = XDynamicTableNormal.New(self.PanelItemList.gameObject) + self.DynamicTable:SetProxy(XUiGridInfestorExploreContract) + self.DynamicTable:SetDelegate(self) + + self:AutoAddListener() +end + +function XUiInfestorExploreContract:OnEnable() + self:UpdateView() +end + +function XUiInfestorExploreContract:OnDisable() + XCountDown.UnBindTimer(self, XCountDown.GTimerName.FubenInfestorExploreDaily) +end + +function XUiInfestorExploreContract:OnGetEvents() + return { XEventId.EVENT_INFESTOREXPLORE_CONTRACT_DAILY_RESET } +end + +function XUiInfestorExploreContract:OnNotify(evt, ...) + local args = { ... } + if evt == XEventId.EVENT_INFESTOREXPLORE_CONTRACT_DAILY_RESET then + self:UpdateView() + end +end + +function XUiInfestorExploreContract:UpdateView() + XCountDown.BindTimer(self, XCountDown.GTimerName.FubenInfestorExploreDaily, function(time) + time = time > 0 and time or 0 + local timeText = XUiHelper.GetTime(time, XUiHelper.TimeFormatType.CHALLENGE) + self.TxtResetTime.text = timeText + end) + + self:UpdateDynamicTable() + self:UpdateMoney() +end + +function XUiInfestorExploreContract:UpdateMoney() + self.TxtSpecialTool.text = XDataCenter.FubenInfestorExploreManager.GetActionPoint() +end + +function XUiInfestorExploreContract:UpdateDynamicTable() + local shopEventIds = XDataCenter.FubenInfestorExploreManager.GetShopEventIds() + self.ShopEventIds = shopEventIds + + local isEmpty = not next(shopEventIds) + if isEmpty then + self.ImgEmpty.gameObject:SetActiveEx(true) + self.PanelItemList.gameObject:SetActiveEx(false) + else + self.ImgEmpty.gameObject:SetActiveEx(false) + self.PanelItemList.gameObject:SetActiveEx(true) + self.DynamicTable:SetDataSource(shopEventIds) + self.DynamicTable:ReloadDataSync() + end +end + +function XUiInfestorExploreContract:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:InitRootUi(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local shopEventId = self.ShopEventIds[index] + grid:Refresh(shopEventId) + + local isSelect = self.LastSelectId and self.LastSelectId == shopEventId + grid:SetSelect(isSelect) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + local shopEventId = self.ShopEventIds[index] + + if self.LastSelectGrid then + self.LastSelectGrid:SetSelect(false) + end + self.LastSelectGrid = grid + self.LastSelectGrid:SetSelect(true) + self.LastSelectId = shopEventId + + self:ShowBuyPanel(shopEventId) + end +end + +function XUiInfestorExploreContract:ShowBuyPanel(shopEventId) + if XDataCenter.FubenInfestorExploreManager.IsShopEventSellOut() then + return + end + + self.SelectShopEventId = shopEventId + self.PanelBuy.gameObject:SetActiveEx(true) + + local cost = XFubenInfestorExploreConfigs.GetEventGoodsCost(shopEventId) + local goodsName = XFubenInfestorExploreConfigs.GetEventName(shopEventId) + self.TxtTips.text = CSXTextManagerGetText("InfestorExploreContractBuyTips", cost, goodsName) +end + +function XUiInfestorExploreContract:AutoAddListener() + self.BtnBuy.CallBack = function() self:OnClickBtnBuy() end + self.BtnClose.CallBack = function() self:Close() end + self.BtnTanchuangClose.CallBack = function() self:Close() end +end + +function XUiInfestorExploreContract:OnClickBtnBuy() + local shopEventId = self.SelectShopEventId + + local cost = XFubenInfestorExploreConfigs.GetEventGoodsCost(shopEventId) + if not XDataCenter.FubenInfestorExploreManager.CheckActionPointEnough(cost) then + XUiManager.TipText("InfestorExploreShopNodeActionPointNotEnuogh") + return + end + + local callBack = function() + self.PanelBuy.gameObject:SetActiveEx(false) + self.LastSelectId = nil + self:UpdateView() + end + XDataCenter.FubenInfestorExploreManager.RequestBuyEventGoods(shopEventId, callBack) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreCore.lua b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreCore.lua new file mode 100644 index 00000000..6b1a2b04 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreCore.lua @@ -0,0 +1,216 @@ +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate + +local XUiGridInfestorExploreCore = require("XUi/XUiFubenInfestorExplore/XUiGridInfestorExploreCore") +local MAX_WEARING_NUM = 6 + +local XUiInfestorExploreCore = XLuaUiManager.Register(XLuaUi, "UiInfestorExploreCore") + +function XUiInfestorExploreCore:OnAwake() + self:AutoAddListener() + self.GridCore.gameObject:SetActiveEx(false) + self.GridWearingCore.gameObject:SetActiveEx(false) + for i = 1, MAX_WEARING_NUM do + self["ImgSelect" .. i].gameObject:SetActiveEx(false) + self["PanelEffect" .. i].gameObject:SetActiveEx(false) + end + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) +end + +function XUiInfestorExploreCore:OnStart() + self.SelectPos = 1 + self.WearingCoreGrids = {} + self:InitDynamicTable() +end + +function XUiInfestorExploreCore:OnEnable() + self:RefreshView() +end + +function XUiInfestorExploreCore:OnGetEvents() + return { XEventId.EVENT_INFESTOREXPLORE_CORE_PUTON + , XEventId.EVENT_INFESTOREXPLORE_CORE_TAKEOFF + , XEventId.EVENT_INFESTOREXPLORE_CORE_DECOMPOESE + , XEventId.EVENT_INFESTOREXPLORE_RESET + } +end + +function XUiInfestorExploreCore:OnNotify(evt, ...) + local args = { ... } + if evt == XEventId.EVENT_INFESTOREXPLORE_CORE_PUTON then + local pos = args[1] + local panelEffect = self["PanelEffect" .. pos] + panelEffect.gameObject:SetActiveEx(false) + panelEffect.gameObject:SetActiveEx(true) + self:RefreshView() + elseif evt == XEventId.EVENT_INFESTOREXPLORE_CORE_TAKEOFF + or evt == XEventId.EVENT_INFESTOREXPLORE_CORE_DECOMPOESE then + self:RefreshView() + elseif evt == XEventId.EVENT_INFESTOREXPLORE_RESET then + XDataCenter.FubenInfestorExploreManager.Reset() + end +end + +function XUiInfestorExploreCore:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelEquipScroll) + self.DynamicTable:SetProxy(XUiGridInfestorExploreCore) + self.DynamicTable:SetDelegate(self) +end + +function XUiInfestorExploreCore:RefreshView() + local isShow = XDataCenter.FubenInfestorExploreManager.IsInSectionOne() + self.BtnDecomposion.gameObject:SetActiveEx(isShow) + + local coreIds = XDataCenter.FubenInfestorExploreManager.GetCoreIds() + self.CoreIds = coreIds + + local num = #coreIds + self.TxtNumber.text = num + self.PanelNoEquip.gameObject:SetActiveEx(num <= 0) + + self.DynamicTable:SetDataSource(coreIds) + self.DynamicTable:ReloadDataASync() + + self:UpdateWearingCores() +end + +function XUiInfestorExploreCore:UpdateWearingCores() + local wearingCoreIdDic = XDataCenter.FubenInfestorExploreManager.GetWearingCoreIdDic() + for pos = XFubenInfestorExploreConfigs.MaxWearingCoreNum, 1, -1 do + local panelNoEquip = self["PanelNoEquip" .. pos] + local coreId = wearingCoreIdDic[pos] + local isWearing = coreId and coreId > 0 + local grid = self.WearingCoreGrids[pos] + if isWearing then + if not grid then + local parent = self["PanelPos" .. pos] + local go = CSUnityEngineObjectInstantiate(self.GridWearingCore, parent) + go.transform:SetAsFirstSibling() + local clickCb = function() + self:OnSelectPos(pos) + end + grid = XUiGridInfestorExploreCore.New(go, self, clickCb) + self.WearingCoreGrids[pos] = grid + end + grid:Refresh(coreId) + grid.GameObject:SetActiveEx(true) + + panelNoEquip.gameObject:SetActiveEx(false) + else + self.SelectPos = pos + if grid then + grid.GameObject:SetActiveEx(false) + end + + panelNoEquip.gameObject:SetActiveEx(true) + end + end + + self:OnSelectPos(self.SelectPos, true) +end + +function XUiInfestorExploreCore:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:InitRootUi(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local coreId = self.CoreIds[index] + grid:Refresh(coreId) + + local isSelect = coreId == self.SelectCoreId + grid:SetSelect(isSelect) + if isSelect then + self.LastSelectGrid = grid + end + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + if self.LastSelectGrid then + self.LastSelectGrid:SetSelect(false) + end + self.LastSelectGrid = grid + + local coreId = self.CoreIds[index] + self.SelectCoreId = coreId + + grid:SetSelect(true) + + self:OnSelectCorePopUp(coreId) + end +end + +function XUiInfestorExploreCore:OnSelectCorePopUp(coreId) + local selectPos = self.SelectPos + if not XLuaUiManager.IsUiShow("UiInfestorExploreCorePopup") then + self.BtnClosePopup.gameObject:SetActiveEx(true) + local closeCb = function() + self.BtnClosePopup.gameObject:SetActiveEx(false) + end + XLuaUiManager.Open("UiInfestorExploreCorePopup", coreId, selectPos, closeCb) + else + CsXGameEventManager.Instance:Notify(XEventId.EVENT_INFESTOREXPLORE_SELECT_CORE, coreId, selectPos) + end +end + +function XUiInfestorExploreCore:OnSelectPos(pos, isInit) + self.SelectPos = pos + + if self.LastSelectPosGo then + self.LastSelectPosGo.gameObject:SetActiveEx(false) + end + local imgSelect = self["ImgSelect" .. pos] + imgSelect.gameObject:SetActiveEx(true) + self.LastSelectPosGo = imgSelect + + local wearingCoreIdDic = XDataCenter.FubenInfestorExploreManager.GetWearingCoreIdDic() + local coreId = wearingCoreIdDic[pos] + local isWearing = coreId and coreId > 0 + if isWearing then + if not isInit then + self:OnSelectCorePopUp(coreId) + end + else + self:OnClickBtnClosePopup() + end +end + +function XUiInfestorExploreCore:AutoAddListener() + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + self.BtnDecomposion.CallBack = function() self:OnClickBtnDecomposion() end + self.BtnClosePopup.CallBack = function() self:OnClickBtnClosePopup() end + for index = 1, MAX_WEARING_NUM do + self["BtnPos" .. index].CallBack = function() + self:OnSelectPos(index) + end + end + self:RegisterClickEvent(self.PanelEquipScroll, self.OnPanelEquipScrollClick) +end + +function XUiInfestorExploreCore:OnBtnBackClick() + self:OnClickBtnClosePopup() + self:Close() +end + +function XUiInfestorExploreCore:OnPanelEquipScrollClick() + self:OnClickBtnClosePopup() +end + +function XUiInfestorExploreCore:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiInfestorExploreCore:OnClickBtnClosePopup() + if not XLuaUiManager.IsUiShow("UiInfestorExploreCorePopup") then + return + end + + if self.LastSelectGrid then + self.LastSelectGrid:SetSelect(false) + self.LastSelectGrid = nil + end + self.SelectCoreId = nil + + XLuaUiManager.Close("UiInfestorExploreCorePopup") +end + +function XUiInfestorExploreCore:OnClickBtnDecomposion() + self:OnClickBtnClosePopup() + self:OpenChildUi("UiInfestorExploreCoreDecompose") +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreCoreDecompose.lua b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreCoreDecompose.lua new file mode 100644 index 00000000..e6025a82 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreCoreDecompose.lua @@ -0,0 +1,118 @@ +local next = next +local tableInsert = table.insert + +local XUiGridInfestorExploreCore = require("XUi/XUiFubenInfestorExplore/XUiGridInfestorExploreCore") + +local XUiInfestorExploreCoreDecompose = XLuaUiManager.Register(XLuaUi, "UiInfestorExploreCoreDecompose") + +function XUiInfestorExploreCoreDecompose:OnAwake() + self:AutoAddListener() + self.GridCore.gameObject:SetActiveEx(false) +end + +function XUiInfestorExploreCoreDecompose:OnStart() + self.RImgItem:SetRawImage(XDataCenter.FubenInfestorExploreManager.GetMoneyIcon()) + self:InitDynamicTable() +end + +function XUiInfestorExploreCoreDecompose:OnEnable() + self:Refresh() +end + +function XUiInfestorExploreCoreDecompose:OnGetEvents() + return { XEventId.EVENT_INFESTOREXPLORE_CORE_DECOMPOESE } +end + +function XUiInfestorExploreCoreDecompose:OnNotify(evt, ...) + if evt == XEventId.EVENT_INFESTOREXPLORE_CORE_DECOMPOESE then + self:Refresh() + end +end + +function XUiInfestorExploreCoreDecompose:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelEquipScroll) + self.DynamicTable:SetProxy(XUiGridInfestorExploreCore) + self.DynamicTable:SetDelegate(self) +end + +function XUiInfestorExploreCoreDecompose:Refresh() + local coreIds = XTool.ReverseList(XDataCenter.FubenInfestorExploreManager.GetCoreIds()) + self.CoreIds = coreIds + + local num = #coreIds + self.TxtHaveNumber.text = num + self.PanelNoEquip.gameObject:SetActiveEx(num <= 0) + + self.SelectCoreIdCheckTable = {} + self.DynamicTable:SetDataSource(coreIds) + self.DynamicTable:ReloadDataASync() + self:OnSelectCoreChange() +end + +function XUiInfestorExploreCoreDecompose:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:InitRootUi(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local coreId = self.CoreIds[index] + grid:Refresh(coreId) + + local isSelect = self.SelectCoreIdCheckTable[coreId] + grid:SetSelect(isSelect) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + local coreId = self.CoreIds[index] + local isSelect = self.SelectCoreIdCheckTable[coreId] + + if not isSelect then + grid:SetSelect(true) + self.SelectCoreIdCheckTable[coreId] = coreId + else + grid:SetSelect(false) + self.SelectCoreIdCheckTable[coreId] = nil + end + + self:OnSelectCoreChange() + end +end + +function XUiInfestorExploreCoreDecompose:OnSelectCoreChange() + local selectCoreIds = self:GetSelectCoreIdList() + + local selectNum = #selectCoreIds + self.TxtSelected.text = selectNum + + local rewardMoneyCount = XDataCenter.FubenInfestorExploreManager.GetCoreDecomposeMoney(selectCoreIds) + self.TxtNumber.text = rewardMoneyCount +end + +function XUiInfestorExploreCoreDecompose:AutoAddListener() + self:RegisterClickEvent(self.BtnClosePopup, self.Close) + self.BtnTanchuangClose.CallBack = function() self:Close() end + self.BtnDecompose.CallBack = function() self:OnClickBtnDecompose() end + self.BtnRImgItem.CallBack = function() self:OnClickRImgCostBack() end +end + +function XUiInfestorExploreCoreDecompose:OnClickBtnDecompose() + local coreIds = self:GetSelectCoreIdList() + if not next(coreIds) then + XUiManager.TipText("InfestorExploreCoreDecomposeEmpty") + return + end + + XDataCenter.FubenInfestorExploreManager.RequestInfestorExploreDecomposeCore(coreIds) +end + +function XUiInfestorExploreCoreDecompose:GetSelectCoreIdList() + local selectCoreIds = {} + for id in pairs(self.SelectCoreIdCheckTable) do + tableInsert(selectCoreIds, id) + end + return selectCoreIds +end + +function XUiInfestorExploreCoreDecompose:OnClickRImgCostBack() + local data = { + Id = XDataCenter.ItemManager.ItemId.InfestorMoney, + Count = XDataCenter.FubenInfestorExploreManager.GetMoneyCount() + } + XLuaUiManager.Open("UiTip", data) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreCoreLevelUp.lua b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreCoreLevelUp.lua new file mode 100644 index 00000000..3c30b24b --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreCoreLevelUp.lua @@ -0,0 +1,33 @@ +local XUiGridInfestorExploreCore = require("XUi/XUiFubenInfestorExplore/XUiGridInfestorExploreCore") + +local XUiInfestorExploreCoreLevelUp = XLuaUiManager.Register(XLuaUi, "UiInfestorExploreCoreLevelUp") + +function XUiInfestorExploreCoreLevelUp:OnAwake() + self:AutoAddListener() +end + +function XUiInfestorExploreCoreLevelUp:OnStart(coreId, oldLevel, newLevel, closeCb) + self.CoreId = coreId + self.CloseCb = closeCb + self.OldLevel = oldLevel + self.NewLevel = newLevel +end + +function XUiInfestorExploreCoreLevelUp:OnEnable() + self.GridCore = self.GridCore or XUiGridInfestorExploreCore.New(self.GridInfestorExploreCore, self) + self.GridCore:Refresh(self.CoreId, nil, true) + + local oldLevel = self.OldLevel + local newLevel = self.NewLevel + for index = oldLevel + 1, newLevel do + self["Timeline" .. index]:PlayTimelineAnimation() + end +end + +function XUiInfestorExploreCoreLevelUp:OnDestroy() + if self.CloseCb then self.CloseCb() end +end + +function XUiInfestorExploreCoreLevelUp:AutoAddListener() + self.BtnClose.CallBack = function() self:Close() end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreCoreObtain.lua b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreCoreObtain.lua new file mode 100644 index 00000000..121cb824 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreCoreObtain.lua @@ -0,0 +1,26 @@ +local XUiGridInfestorExploreCore = require("XUi/XUiFubenInfestorExplore/XUiGridInfestorExploreCore") + +local XUiInfestorExploreCoreObtain = XLuaUiManager.Register(XLuaUi, "UiInfestorExploreCoreObtain") + +function XUiInfestorExploreCoreObtain:OnAwake() + self:AutoAddListener() +end + +function XUiInfestorExploreCoreObtain:OnStart(coreId, coreLevel, closeCb) + self.CoreId = coreId + self.CoreLevel = coreLevel + self.CloseCb = closeCb +end + +function XUiInfestorExploreCoreObtain:OnEnable() + self.GridCore = self.GridCore or XUiGridInfestorExploreCore.New(self.GridInfestorExploreCore, self) + self.GridCore:Refresh(self.CoreId, self.CoreLevel, true) +end + +function XUiInfestorExploreCoreObtain:OnDestroy() + if self.CloseCb then self.CloseCb() end +end + +function XUiInfestorExploreCoreObtain:AutoAddListener() + self.BtnClose.CallBack = function() self:Close() end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreCorePopup.lua b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreCorePopup.lua new file mode 100644 index 00000000..c2559b77 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreCorePopup.lua @@ -0,0 +1,103 @@ +local XUiGridInfestorExploreCore = require("XUi/XUiFubenInfestorExplore/XUiGridInfestorExploreCore") + +local XUiInfestorExploreCorePopup = XLuaUiManager.Register(XLuaUi, "UiInfestorExploreCorePopup") + +function XUiInfestorExploreCorePopup:OnAwake() + self:AutoAddListener() +end + +function XUiInfestorExploreCorePopup:OnStart(coreId, wearingCoreId, closeCb) + self.CoreId = coreId + self.WearingCoreId = wearingCoreId + self.CloseCb = closeCb +end + +function XUiInfestorExploreCorePopup:OnEnable() + self:Refresh(self.CoreId, self.WearingCoreId) +end + +function XUiInfestorExploreCorePopup:OnDestroy() + if self.CloseCb then + self.CloseCb() + end +end + +function XUiInfestorExploreCorePopup:OnGetEvents() + return { XEventId.EVENT_INFESTOREXPLORE_SELECT_CORE } +end + +function XUiInfestorExploreCorePopup:OnNotify(evt, ...) + local args = { ... } + + if evt == XEventId.EVENT_INFESTOREXPLORE_SELECT_CORE then + local coreId = args[1] + local selectPos = args[2] + self:Refresh(coreId, selectPos) + end +end + +function XUiInfestorExploreCorePopup:Refresh(coreId, selectPos) + self.SelectPos = selectPos + local wearingCoreId = XDataCenter.FubenInfestorExploreManager.GetWearingCoreId(selectPos) + + local isShowUsingPanel = (coreId and coreId > 0 and wearingCoreId and wearingCoreId > 0 and coreId ~= wearingCoreId) and true or false + self.PanelUsing.gameObject:SetActiveEx(isShowUsingPanel) + + self:UpdateSelectPanel(coreId) + self:UpdateUsingPanel(wearingCoreId) +end + +function XUiInfestorExploreCorePopup:UpdateSelectPanel(coreId) + if not coreId then return end + self.CoreId = coreId + + local grid = self.SelectCoreGrid + if not grid then + grid = XUiGridInfestorExploreCore.New(self.GridSelectCore, self) + self.SelectCoreGrid = grid + end + grid:Refresh(coreId) + + local isWearing = XDataCenter.FubenInfestorExploreManager.IsCoreWearing(coreId) + self.BtnPutOn.gameObject:SetActiveEx(not isWearing) + self.BtnTakeOff.gameObject:SetActiveEx(isWearing) +end + +function XUiInfestorExploreCorePopup:UpdateUsingPanel(wearingCoreId) + if not wearingCoreId or wearingCoreId <= 0 then return end + + local grid = self.UsingCoreGrid + if not grid then + grid = XUiGridInfestorExploreCore.New(self.GridUsingCore, self) + self.UsingCoreGrid = grid + end + grid:Refresh(wearingCoreId) +end + +function XUiInfestorExploreCorePopup:AutoAddListener() + self:RegisterClickEvent(self.BtnPutOn, self.OnBtnPutOnClick) + self:RegisterClickEvent(self.BtnTakeOff, self.OnBtnTakeOffClick) +end + +function XUiInfestorExploreCorePopup:OnBtnPutOnClick() + local coreId = self.CoreId + local pos = self.SelectPos + local callBack = function() + if not XLuaUiManager.IsUiShow("UiInfestorExploreCorePopup") then + return + end + self:Close() + end + XDataCenter.FubenInfestorExploreManager.RequestInfestorExplorePutOnCore(coreId, pos, callBack) +end + +function XUiInfestorExploreCorePopup:OnBtnTakeOffClick() + local pos = self.SelectPos + local callBack = function() + if not XLuaUiManager.IsUiShow("UiInfestorExploreCorePopup") then + return + end + self:Close() + end + XDataCenter.FubenInfestorExploreManager.RequestInfestorExploreTakeOffCore(pos, callBack) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreCoreShow.lua b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreCoreShow.lua new file mode 100644 index 00000000..92e62769 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreCoreShow.lua @@ -0,0 +1,76 @@ +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate +local CSXScheduleManagerScheduleOnce = XScheduleManager.ScheduleOnce +local CSXScheduleManagerUnSchedule = XScheduleManager.UnSchedule +local CLOSE_TIME = XScheduleManager.SECOND * 3 + +local XUiGridInfestorExploreCore = require("XUi/XUiFubenInfestorExplore/XUiGridInfestorExploreCore") + +local XUiInfestorExploreCoreShow = XLuaUiManager.Register(XLuaUi, "UiInfestorExploreCoreShow") + +function XUiInfestorExploreCoreShow:OnAwake() + self.GridWearingCore.gameObject:SetActiveEx(false) + self:CountDownClose() +end + +function XUiInfestorExploreCoreShow:OnStart() + self.WearingCoreGrids = {} +end + +function XUiInfestorExploreCoreShow:OnEnable() + self:RefreshView() +end + +function XUiInfestorExploreCoreShow:OnDestroy() + self:ClearTimer() +end + +function XUiInfestorExploreCoreShow:RefreshView() + self:UpdateWearingCores() +end + +function XUiInfestorExploreCoreShow:UpdateWearingCores() + local wearingCoreIdDic = XDataCenter.FubenInfestorExploreManager.GetWearingCoreIdDic() + for pos = 1, XFubenInfestorExploreConfigs.MaxWearingCoreNum do + local panelNoEquip = self["PanelNoEquip" .. pos] + local coreId = wearingCoreIdDic[pos] + local isWearing = coreId and coreId > 0 + local grid = self.WearingCoreGrids[pos] + if isWearing then + if not grid then + local parent = self["PanelPos" .. pos] + local go = CSUnityEngineObjectInstantiate(self.GridWearingCore, parent) + go.transform:SetAsFirstSibling() + grid = XUiGridInfestorExploreCore.New(go, self) + self.WearingCoreGrids[pos] = grid + end + grid:Refresh(coreId) + grid.GameObject:SetActiveEx(true) + panelNoEquip.gameObject:SetActiveEx(false) + else + if grid then + grid.GameObject:SetActiveEx(false) + end + panelNoEquip.gameObject:SetActiveEx(true) + end + end +end + +function XUiInfestorExploreCoreShow:CountDownClose() + if self.TimerId then + self:ClearTimer() + end + + self.TimerId = CSXScheduleManagerScheduleOnce(function() + if not XTool.UObjIsNil(self.UiInfestorExploreCoreShow) then + self:ClearTimer() + self:Close() + end + end, CLOSE_TIME) +end + +function XUiInfestorExploreCoreShow:ClearTimer() + if self.TimerId then + CSXScheduleManagerUnSchedule(self.TimerId) + self.TimerId = nil + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreDebuff.lua b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreDebuff.lua new file mode 100644 index 00000000..f92622f7 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreDebuff.lua @@ -0,0 +1,32 @@ +local XUiGridInfestorExploreBuff = require("XUi/XUiFubenInfestorExplore/XUiGridInfestorExploreBuff") + +local XUiInfestorExploreDebuff = XLuaUiManager.Register(XLuaUi, "UiInfestorExploreDebuff") + +function XUiInfestorExploreDebuff:OnAwake() + self.BtnClose.CallBack = function() self:Close() end + self.BtnTanchuangClose.CallBack = function() self:Close() end + self.GridBuff.gameObject:SetActiveEx(false) + + self.DynamicTable = XDynamicTableNormal.New(self.PanelSelectList.gameObject) + self.DynamicTable:SetProxy(XUiGridInfestorExploreBuff) + self.DynamicTable:SetDelegate(self) +end + +function XUiInfestorExploreDebuff:OnStart() + local buffIds = XDataCenter.FubenInfestorExploreManager.GetBuffIds() + self.BuffIds = buffIds + + local num = #buffIds + self.TxtOwnBuff.text = num + self.ImgEmpty.gameObject:SetActiveEx(num <= 0) + + self.DynamicTable:SetDataSource(buffIds) + self.DynamicTable:ReloadDataASync() +end + +function XUiInfestorExploreDebuff:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local buffId = self.BuffIds[index] + grid:Refresh(buffId) + end +end diff --git a/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreFightResult.lua b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreFightResult.lua new file mode 100644 index 00000000..3dfcfb49 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreFightResult.lua @@ -0,0 +1,91 @@ +local CSXTextManagerGetText = CS.XTextManager.GetText + +local XUiInfestorExploreFightResult = XLuaUiManager.Register(XLuaUi, "UiInfestorExploreFightResult") + +function XUiInfestorExploreFightResult:OnAwake() + self:AutoAddListener() +end + +function XUiInfestorExploreFightResult:OnStart(stageId, result, isNewScore) + self.StageId = stageId + + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + self.TxtTile.text = stageCfg.Name + + local SetMaxTextDesc = function(text, ponit) + if ponit > 0 then + text.text = CSXTextManagerGetText("ArenaMaxSingleScore", ponit) + else + text.text = CSXTextManagerGetText("ArenaMaxSingleNoScore") + end + end + SetMaxTextDesc(self.TxtHitSocreMax, result.DamageMaxScore) + SetMaxTextDesc(self.TxtRemainHpScoreMax, result.HpMaxScore) + SetMaxTextDesc(self.TxtRemainTimeScoreMax, result.UseTimeMaxScore) + + self.PanelNewRecord.gameObject:SetActiveEx(isNewScore) + + local result = result + local bossSingleAnimaTime = CS.XGame.ClientConfig:GetFloat("BossSingleAnimaTime") + -- 播放音效 + self.AudioInfo = CS.XAudioManager.PlaySound(XSoundManager.UiBasicsMusic.UiSettle_Win_Number) + XUiHelper.Tween(bossSingleAnimaTime, function(f) + if XTool.UObjIsNil(self.Transform) then + return + end + + local time = result.UseTime + + -- 歼敌奖励 + local hitCombo = math.floor(f * result.Damage) + local hitScore = '+' .. math.floor(f * result.DamageScore) + self.TxtHitCombo.text = hitCombo + self.TxtHitScore.text = hitScore + + -- 我方血量 + local remainHp = math.floor(f * result.HpLeftPer) .. "%" + local remainHpScore = '+' .. math.floor(f * result.HpScore) + self.TxtRemainHp.text = remainHp + self.TxtRemainHpScore.text = remainHpScore + + -- 剩余时间 + local remainTime = XUiHelper.GetTime(math.floor(f * time), XUiHelper.TimeFormatType.SHOP) + local remainTimeSacore = '+' .. math.floor(f * result.UseTimeScore) + self.TxtRemainTime.text = remainTime + self.TxtRemainTimeScore.text = remainTimeSacore + + -- 通关时间 + local costTime = XUiHelper.GetTime(math.floor(f * time), XUiHelper.TimeFormatType.SHOP) + self.TxtCostTime.text = costTime + + -- 当前总分 + local point = math.floor(f * result.TotalScore) + self.TxtPoint.text = point + + -- 历史最高分 + local highScore = math.floor(f * result.TotalHighScore) + self.TxtHighScore.text = highScore + end, function() + self:StopAudio() + end) +end + +function XUiInfestorExploreFightResult:AutoAddListener() + self.BtnReFight.CallBack = function() self:OnClickBtnReFight() end + self.BtnExitFight.CallBack = function() self:OnClickBtnExitFight() end +end + +function XUiInfestorExploreFightResult:OnClickBtnReFight() + self:Close() + XLuaUiManager.Open("UiNewRoomSingle", self.StageId) +end + +function XUiInfestorExploreFightResult:OnClickBtnExitFight() + self:Close() +end + +function XUiInfestorExploreFightResult:StopAudio() + if self.AudioInfo then + self.AudioInfo:Stop() + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreGuestbook.lua b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreGuestbook.lua new file mode 100644 index 00000000..109ea004 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreGuestbook.lua @@ -0,0 +1,74 @@ +local XUiGridInfestorExplorePlayerMessage = require("XUi/XUiFubenInfestorExplore/XUiGridInfestorExplorePlayerMessage") + +local XUiInfestorExploreGuestbook = XLuaUiManager.Register(XLuaUi, "UiInfestorExploreGuestbook") + +function XUiInfestorExploreGuestbook:OnAwake() + self:AutoAddListener() + self.GridGuestbook.gameObject:SetActiveEx(false) +end + +function XUiInfestorExploreGuestbook:OnStart(chapterId) + self.ChapterId = chapterId + self:InitDynamicTable() +end + +function XUiInfestorExploreGuestbook:OnEnable() + self:RefreshView() +end + +function XUiInfestorExploreGuestbook:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelSelectList) + self.DynamicTable:SetDelegate(self) + self.DynamicTable:SetProxy(XUiGridInfestorExplorePlayerMessage) +end + +function XUiInfestorExploreGuestbook:RefreshView() + local msgs = XDataCenter.FubenInfestorExploreManager.GetAllChapterMsgs(self.ChapterId) + self.Msgs = msgs + + if next(msgs) then + self.ImgEmpty.gameObject:SetActiveEx(false) + self.PanelSelectList.gameObject:SetActiveEx(true) + + self.DynamicTable:SetDataSource(self.Msgs) + self.DynamicTable:ReloadDataSync() + else + self.ImgEmpty.gameObject:SetActiveEx(true) + self.PanelSelectList.gameObject:SetActiveEx(false) + end +end + +function XUiInfestorExploreGuestbook:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local chapterId = self.ChapterId + local msg = self.Msgs[index] + grid:Refresh(msg) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + local msg = self.Msgs[index] + local playerId = msg.Id + if playerId and playerId ~= XPlayer.Id then + XDataCenter.PersonalInfoManager.ReqShowInfoPanel(playerId) + end + end +end + +function XUiInfestorExploreGuestbook:AutoAddListener() + self.BtnClose.CallBack = function() self:Close() end + self.BtnTanchuangClose.CallBack = function() self:Close() end + self.BtnSend.CallBack = function() self:OnClickBtnSend() end +end + +function XUiInfestorExploreGuestbook:OnClickBtnSend() + local msg = self.InputFieldMsg.text + if string.IsNilOrEmpty(msg) then + XUiManager.TipText("InfestorExploreChapterMessageEmpty") + return + end + + local chapterId = self.ChapterId + local callBack = function() + XUiManager.TipText("InfestorExploreChapterMessageSuc") + self:RefreshView() + end + XDataCenter.FubenInfestorExploreManager.RequestChapterLeaveMsg(chapterId, msg, callBack) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreLevelDetail.lua b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreLevelDetail.lua new file mode 100644 index 00000000..647aad24 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreLevelDetail.lua @@ -0,0 +1,85 @@ +local XUiGridArenaLevel = require("XUi/XUiArenaLevelDetail/ArenaLevelDetailCommon/XUiGridArenaLevel") +local XUiGridRegion = require("XUi/XUiArenaLevelDetail/ArenaLevelDetailCommon/XUiGridRegion") + +local MAX_GRID_NUM = 3 + +local XUiInfestorExploreLevelDetail = XLuaUiManager.Register(XLuaUi, "UiInfestorExploreLevelDetail") + +function XUiInfestorExploreLevelDetail:OnAwake() + self:AutoAddListener() + self.GridArenaLevel.gameObject:SetActive(false) +end + +function XUiInfestorExploreLevelDetail:OnStart(...) + self.GridRegionList = {} + for i = 1, MAX_GRID_NUM do + local regionGrid = XUiGridRegion.New(self["GridRegion" .. i], self) + table.insert(self.GridRegionList, regionGrid) + end + + self.DynamicTable = XDynamicTableNormal.New(self.SViewArenaLevel.transform) + self.DynamicTable:SetProxy(XUiGridArenaLevel) + self.DynamicTable:SetDelegate(self) +end + +function XUiInfestorExploreLevelDetail:UpdateView() + self.DiffConfigs = XDataCenter.FubenInfestorExploreManager.GetCurGroupDiffConfigs() + + local minLevel, maxLevel = XDataCenter.FubenInfestorExploreManager.GetCurGroupLevelBorder() + self.TxtGrade.text = "Lv" .. minLevel .. "-" .. maxLevel + + local selectDiff = XDataCenter.FubenInfestorExploreManager.GetCurDiff() + self:RefreshSelect(selectDiff) + + self.DynamicTable:SetDataSource(self.DiffConfigs) + self.DynamicTable:ReloadDataSync() +end + +function XUiInfestorExploreLevelDetail:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.DiffConfigs[index] + local diff = index + local curDiff = XDataCenter.FubenInfestorExploreManager.GetCurDiff() + local icon = XDataCenter.FubenInfestorExploreManager.GetDiffIcon(diff) + local name = XDataCenter.FubenInfestorExploreManager.GetDiffName(diff) + grid:ResetData(diff, curDiff, icon, name) + grid:SetSelect(index == self.SelectDiff) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + if index == self.SelectDiff then + return + end + + local lastGrid = self.DynamicTable:GetGridByIndex(self.SelectDiff) + if lastGrid then + lastGrid:SetSelect(false) + end + grid:SetSelect(true) + + self:RefreshSelect(index) + end +end + +function XUiInfestorExploreLevelDetail:RefreshSelect(selectDiff) + self.SelectDiff = selectDiff + + for region, grid in ipairs(self.GridRegionList) do + local isNotBorder = not ((selectDiff == 1 and region == XFubenInfestorExploreConfigs.Region.DownRegion) or + (selectDiff == #self.DiffConfigs and region == XFubenInfestorExploreConfigs.Region.UpRegion)) + + local des = isNotBorder and XDataCenter.FubenInfestorExploreManager.GetCurGroupRankRegionDescText(selectDiff, region) + or XFubenInfestorExploreConfigs.GetRankNotRegionDescText(region) + + local title = XFubenInfestorExploreConfigs.GetRankRegionColorText(region) + local rewardId = XDataCenter.FubenInfestorExploreManager.GetCurGroupRankRegionRewardList(selectDiff, region) + + grid:SetMetaData(title, des, isNotBorder, rewardId) + end +end + +function XUiInfestorExploreLevelDetail:AutoAddListener() + self:RegisterClickEvent(self.BtnBg, self.OnBtnBgClick) +end + +function XUiInfestorExploreLevelDetail:OnBtnBgClick(eventData) + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreOutpost.lua b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreOutpost.lua new file mode 100644 index 00000000..0474c93b --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreOutpost.lua @@ -0,0 +1,275 @@ +local XUiGridFubenInfestorExploreMember = require("XUi/XUiFubenInfestorExplore/XUiGridFubenInfestorExploreMember") +local XUiGridInfestorExploreOutPostStory = require("XUi/XUiFubenInfestorExplore/XUiGridInfestorExploreOutPostStory") + +local stringGsub = string.gsub +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate +local CSXTextManagerGetText = CS.XTextManager.GetText +local CSXScheduleManagerScheduleForever = XScheduleManager.ScheduleForever +local CSXScheduleManagerUnSchedule = XScheduleManager.UnSchedule + +local MAX_OPTION_NUM = 2 +local MAX_MEMBER_NUM = 3 +local STORY_CD = 1 +local EVENT_NAME_STR = CS.XTextManager.GetText("InfestorExploreOutPostNodeName") + +local XUiInfestorExploreOutpost = XLuaUiManager.Register(XLuaUi, "UiInfestorExploreOutpost") + +function XUiInfestorExploreOutpost:OnAwake() + self.GridMember.gameObject:SetActiveEx(false) + self.GridDescribe.gameObject:SetActiveEx(false) + self:AutoAddListener() +end + +function XUiInfestorExploreOutpost:OnStart(chapterId, nodeId) + self.ChapterId = chapterId + self.NodeId = nodeId + self.CharacterIds = XDataCenter.FubenInfestorExploreManager.GetChapterTeamCharacterIds(chapterId) + self.MemberGrids = {} + self.StoryGrids = {} + + self:InitView() +end + +function XUiInfestorExploreOutpost:OnDestroy() + self:ClearTimer() + + if XDataCenter.FubenInfestorExploreManager.IsFightRewadsExist() then + XLuaUiManager.Open("UiInfestorExploreChoose") + end +end + +function XUiInfestorExploreOutpost:OnGetEvents() + return { XEventId.EVENT_INFESTOREXPLORE_CHARACTER_HP_CHANGE + , XEventId.EVENT_INFESTOREXPLORE_RESET + } +end + +function XUiInfestorExploreOutpost:OnNotify(evt, ...) + if evt == XEventId.EVENT_INFESTOREXPLORE_CHARACTER_HP_CHANGE then + self.DelayChangeHp = true + elseif evt == XEventId.EVENT_INFESTOREXPLORE_RESET then + XDataCenter.FubenInfestorExploreManager.Reset() + end +end + +function XUiInfestorExploreOutpost:InitView() + local defaultSelectPos + local characterIds = self.CharacterIds + for pos = 1, MAX_MEMBER_NUM do + local characterId = characterIds[pos] + local grid = self.MemberGrids[pos] + if characterId > 0 then + if not grid then + local go = CSUnityEngineObjectInstantiate(self.GridMember, self.PanelRole) + local clickCb = function() + self:OnSelectMember(pos) + end + grid = XUiGridFubenInfestorExploreMember.New(go, clickCb) + self.MemberGrids[pos] = grid + end + grid:Refresh(characterId) + grid.GameObject:SetActiveEx(true) + + defaultSelectPos = defaultSelectPos or pos + else + if grid then + grid.GameObject:SetActiveEx(false) + end + end + end + + self.TxtTile.text = EVENT_NAME_STR + self.Panel01.gameObject:SetActiveEx(true) + self.Panel02.gameObject:SetActiveEx(false) + self.Panel03.gameObject:SetActiveEx(false) + + self:OnSelectMember(defaultSelectPos) +end + +function XUiInfestorExploreOutpost:OnSelectMember(pos) + local grid = self.MemberGrids[pos] + if self.LastSelectMemberGrid then + self.LastSelectMemberGrid:SetSelect(false) + end + self.LastSelectMemberGrid = grid + grid:SetSelect(true) + + local characterId = self.CharacterIds[pos] + self.SelectCharacterId = characterId + + local icon = XDataCenter.CharacterManager.GetCharHalfBodyBigImage(characterId) + self.RImgRole:SetRawImage(icon) + + local fullName = XCharacterConfigs.GetCharacterFullNameStr(characterId) + self.TxtName.text = fullName + + self:UpdateCharacterHp() +end + +function XUiInfestorExploreOutpost:UpdateCharacterHp() + local characterId = self.SelectCharacterId + if not characterId then return end + local hpPercent = XDataCenter.FubenInfestorExploreManager.GetCharacterHpPrecent(characterId) + self.TxtBlood.text = CSXTextManagerGetText("InfestorExploreCharacterHpPercent", hpPercent) +end + +function XUiInfestorExploreOutpost:OnSelectHowToFight(rewardMoney, subHpList) + self.RewardMoney = rewardMoney + self.SubHpList = subHpList + + self.Panel01.gameObject:SetActiveEx(false) + self.Panel02.gameObject:SetActiveEx(true) + self.Panel03.gameObject:SetActiveEx(false) + + --写换名字逻辑 --now + local chapterId = self.ChapterId + local nodeId = self.NodeId + self.BtnOption1:SetName(XDataCenter.FubenInfestorExploreManager.GetOutPostOption1Txt(chapterId, nodeId)) + self.BtnOption2:SetName(XDataCenter.FubenInfestorExploreManager.GetOutPostOption2Txt(chapterId, nodeId)) + + self:PlayAnimationWithMask("Panel02Enable") +end + +function XUiInfestorExploreOutpost:OnFightStory() + local chapterId = self.ChapterId + local nodeId = self.NodeId + + local characterId = self.SelectCharacterId + local characterName = XCharacterConfigs.GetCharacterFullNameStr(characterId) + + local gridIndex = 1 + local option = self.SelectOption + local subHpList = self.SubHpList + local totalSubHp = 0 + local timeStamp = XTime.GetServerNowTimestamp() + for _, subHp in ipairs(subHpList) do + local myTurnDes = XDataCenter.FubenInfestorExploreManager.GetOutPostNodeMyTurnDes(chapterId, nodeId, option, characterName) + local grid = self.StoryGrids[gridIndex] + if not grid then + local go = CSUnityEngineObjectInstantiate(self.GridDescribe, self.PanelFightContent) + grid = XUiGridInfestorExploreOutPostStory.New(go) + self.StoryGrids[gridIndex] = grid + end + timeStamp = timeStamp + STORY_CD + grid:Refresh(myTurnDes, timeStamp) + grid.GameObject:SetActiveEx(false) + gridIndex = gridIndex + 1 + + local isHurt = subHp > 0 + local hisTurnDes = XDataCenter.FubenInfestorExploreManager.GetOutPostNodeHisTurnDes(chapterId, nodeId, option, isHurt, characterName, subHp) + local grid = self.StoryGrids[gridIndex] + if not grid then + local go = CSUnityEngineObjectInstantiate(self.GridDescribe, self.PanelFightContent) + grid = XUiGridInfestorExploreOutPostStory.New(go) + self.StoryGrids[gridIndex] = grid + end + timeStamp = timeStamp + STORY_CD + grid:Refresh(hisTurnDes, timeStamp) + grid.GameObject:SetActiveEx(false) + gridIndex = gridIndex + 1 + + totalSubHp = totalSubHp + subHp + end + + local endDes = XDataCenter.FubenInfestorExploreManager.GetOutPostNodeEndDes(chapterId, nodeId, characterName, totalSubHp) + local grid = self.StoryGrids[gridIndex] + if not grid then + local go = CSUnityEngineObjectInstantiate(self.GridDescribe, self.PanelFightContent) + grid = XUiGridInfestorExploreOutPostStory.New(go) + self.StoryGrids[gridIndex] = grid + end + timeStamp = timeStamp + STORY_CD + grid:Refresh(endDes, timeStamp) + grid.GameObject:SetActiveEx(false) + + self.Panel01.gameObject:SetActiveEx(false) + self.Panel02.gameObject:SetActiveEx(false) + self.Panel03.gameObject:SetActiveEx(true) + self.BtnSkip.gameObject:SetActiveEx(true) + + self:PlayAnimationWithMask("Panel03Enable") + self:BeginStoryAnim() +end + +function XUiInfestorExploreOutpost:BeginStoryAnim() + self.StageOngoing.gameObject:SetActiveEx(true) + self.StageCease.gameObject:SetActiveEx(false) + self.BtnBack.gameObject:SetActiveEx(false) + + local gridIndex = 1 + self:ClearTimer() + self.TimerId = CSXScheduleManagerScheduleForever(function() + if XTool.UObjIsNil(self.GameObject) then self:ClearTimer() return end + local grid = self.StoryGrids[gridIndex] + if not grid then + self:OnStoryEnd() + return + end + grid.GameObject:SetActiveEx(true) + gridIndex = gridIndex + 1 + end, STORY_CD * XScheduleManager.SECOND) +end + +function XUiInfestorExploreOutpost:ClearTimer() + if self.TimerId then + CSXScheduleManagerUnSchedule(self.TimerId) + self.TimerId = nil + end +end + +function XUiInfestorExploreOutpost:OnStoryEnd() + self:ClearTimer() + self.StageOngoing.gameObject:SetActiveEx(false) + self.StageCease.gameObject:SetActiveEx(true) + self.BtnSkip.gameObject:SetActiveEx(false) + self.BtnBack.gameObject:SetActiveEx(true) + + if XDataCenter.FubenInfestorExploreManager.IsFightRewadsExist() then + XLuaUiManager.Open("UiInfestorExploreChoose") + end + + if self.RewardMoney then + XDataCenter.FubenInfestorExploreManager.OnGetMoneyTip(self.RewardMoney) + self.RewardMoney = nil + end + + if self.DelayChangeHp then + self.DelayChangeHp = nil + self:UpdateCharacterHp() + end +end + +function XUiInfestorExploreOutpost:AutoAddListener() + self.BtnBack.CallBack = function() self:OnClickBack() end + self.BtnSkip.CallBack = function() self:OnClickBtnSkip() end + self.BtnSend.CallBack = function() self:OnClickBtnSend() end + for index = 1, MAX_OPTION_NUM do + self["BtnOption" .. index].CallBack = function() self:OnClickBtnOption(index) end + end +end + +function XUiInfestorExploreOutpost:OnClickBack() + XDataCenter.FubenInfestorExploreManager.RequestFinishAction() + self:Close() +end + +function XUiInfestorExploreOutpost:OnClickBtnSkip() + self:OnStoryEnd() + for _, grid in pairs(self.StoryGrids) do + grid.GameObject:SetActiveEx(true) + end +end + +function XUiInfestorExploreOutpost:OnClickBtnSend() + local nodeId = self.NodeId + local characterId = self.SelectCharacterId + local function callBack(rewardMoney, subHpList) + self:OnSelectHowToFight(rewardMoney, subHpList) + end + XDataCenter.FubenInfestorExploreManager.RequestOutPostSend(nodeId, characterId, callBack) +end + +function XUiInfestorExploreOutpost:OnClickBtnOption(index) + self.SelectOption = index + self:OnFightStory() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreRank.lua b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreRank.lua new file mode 100644 index 00000000..de5b2e2b --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreRank.lua @@ -0,0 +1,151 @@ +local XUiPanelInfestorExploreBossRank = require("XUi/XUiFubenInfestorExplore/XUiPanelInfestorExploreBossRank") +local XUiGridInfestorExploreRank = require("XUi/XUiFubenInfestorExplore/XUiGridInfestorExploreRank") + +local CSXTextManagerGetText = CS.XTextManager.GetText + +local XUiInfestorExploreRank = XLuaUiManager.Register(XLuaUi, "UiInfestorExploreRank") + +function XUiInfestorExploreRank:OnAwake() + self:AutoAddListener() + self.GridArenaTeamRank.gameObject:SetActiveEx(false) + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self.BossRank = XUiPanelInfestorExploreBossRank.New(self.PanelRank2) + self.BtnShop.gameObject:SetActiveEx(false) + self.BtnChat.gameObject:SetActiveEx(false) +end + +function XUiInfestorExploreRank:OnStart() + self:InitView() + self:InitDynamicTable() +end + +function XUiInfestorExploreRank:OnEnable() + self:RefreshView() + + XDataCenter.FubenInfestorExploreManager.CheckNewDiff() +end + +function XUiInfestorExploreRank:OnDisable() + XCountDown.UnBindTimer(self, XCountDown.GTimerName.FubenInfestorExplore) +end + +function XUiInfestorExploreRank:OnGetEvents() + return { XEventId.EVENT_INFESTOREXPLORE_REFRESH_PALYER_RANK } +end + +function XUiInfestorExploreRank:OnNotify(evt, ...) + local args = { ... } + if evt == XEventId.EVENT_INFESTOREXPLORE_REFRESH_PALYER_RANK then + self:UpdateRank() + end +end + +function XUiInfestorExploreRank:InitView() + self.TxtTitle.text = CSXTextManagerGetText("InfestorExploreName") +end + +function XUiInfestorExploreRank:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.SViewRank) + self.DynamicTable:SetDelegate(self) + self.DynamicTable:SetProxy(XUiGridInfestorExploreRank) +end + +function XUiInfestorExploreRank:RefreshView() + self:UpdateSectionInfo() + self:UpdateLevel() + self:UpdateRank() +end + +function XUiInfestorExploreRank:UpdateSectionInfo() + self.TxtSection.text = XDataCenter.FubenInfestorExploreManager.GetCurSectionName() + XCountDown.BindTimer(self, XCountDown.GTimerName.FubenInfestorExplore, function(time) + time = time > 0 and time or 0 + local timeText = XUiHelper.GetTime(time, XUiHelper.TimeFormatType.CHALLENGE) + self.TxtTime.text = CSXTextManagerGetText("InfestorExploreSectionLeftTime", timeText) + end) +end + +function XUiInfestorExploreRank:UpdateLevel() + self.TxtArenaName.text = XDataCenter.FubenInfestorExploreManager.GetDiffName() + + local icon = XDataCenter.FubenInfestorExploreManager.GetDiffIcon() + self.RImgArenaLevel:SetRawImage(icon) + + local minLevel, maxLevel = XDataCenter.FubenInfestorExploreManager.GetCurGroupLevelBorder() + self.TxtLevelRegion.text = CSXTextManagerGetText("InfestorExploreDiffLevelBorder", minLevel, maxLevel) +end + +function XUiInfestorExploreRank:UpdateRank() + if XDataCenter.FubenInfestorExploreManager.IsInSectionOne() then + self:UpdateRank1() + elseif XDataCenter.FubenInfestorExploreManager.IsInSectionTwo() then + self:UpdateRank2() + end +end + +function XUiInfestorExploreRank:UpdateRank1() + self.RankIndexList = XDataCenter.FubenInfestorExploreManager.GetPlayerRankIndexList() + self.DynamicTable:SetDataSource(self.RankIndexList) + self.DynamicTable:ReloadDataSync() + + self.PanelRank1.gameObject:SetActiveEx(true) + self.BossRank.GameObject:SetActiveEx(false) +end + +function XUiInfestorExploreRank:UpdateRank2() + self.BossRank:Refresh() + self.PanelRank1.gameObject:SetActiveEx(false) + self.BossRank.GameObject:SetActiveEx(true) +end + +function XUiInfestorExploreRank:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local rankIndex = self.RankIndexList[index] + grid:Refresh(rankIndex) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + local rankIndex = self.RankIndexList[index] + local playerId = XDataCenter.FubenInfestorExploreManager.GetRankPlayerId(rankIndex) + if playerId and playerId ~= XPlayer.Id then + XDataCenter.PersonalInfoManager.ReqShowInfoPanel(playerId) + end + end +end + +function XUiInfestorExploreRank:AutoAddListener() + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + self:BindHelpBtn(self.BtnHelp, "InfestorExplore") + self.BtnDetails.CallBack = function() self:OnClickBtnDetails() end + self.BtnFight.CallBack = function() self:OnClickBtnFight() end + self.BtnChat.CallBack = function() self:OnClickBtnChat() end + self.BtnShop.CallBack = function() self:OnClickBtnShop() end +end + +function XUiInfestorExploreRank:OnBtnBackClick() + self:Close() +end + +function XUiInfestorExploreRank:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiInfestorExploreRank:OnClickBtnDetails() + self:OpenChildUi("UiInfestorExploreLevelDetail") + self:FindChildUiObj("UiInfestorExploreLevelDetail"):UpdateView() +end + +function XUiInfestorExploreRank:OnClickBtnFight() + if XDataCenter.FubenInfestorExploreManager.IsInSectionOne() then + XLuaUiManager.Open("UiInfestorExploreChapter") + elseif XDataCenter.FubenInfestorExploreManager.IsInSectionTwo() then + XLuaUiManager.Open("UiInfestorExploreChapterPart2") + end +end + +function XUiInfestorExploreRank:OnClickBtnChat() + +end + +function XUiInfestorExploreRank:OnClickBtnShop() + +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreShop.lua b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreShop.lua new file mode 100644 index 00000000..9031c948 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreShop.lua @@ -0,0 +1,164 @@ +local XUiGridInfestorExploreShopGoods = require("XUi/XUiFubenInfestorExplore/XUiGridInfestorExploreShopGoods") + +local CSXTextManagerGetText = CS.XTextManager.GetText +local DialogTitle = CSXTextManagerGetText("InfestorExploreShopNodeLeaveTitle") +local DialogContent = CSXTextManagerGetText("InfestorExploreShopNodeLeaveContent") +local CONDITION_COLOR = { + [true] = CS.UnityEngine.Color.black, + [false] = CS.UnityEngine.Color.red, +} + +local XUiInfestorExploreShop = XLuaUiManager.Register(XLuaUi, "UiInfestorExploreShop") + +function XUiInfestorExploreShop:OnAwake() + self:AutoAddListener() + self.GridShop.gameObject:SetActiveEx(false) + self.PanelBuy.gameObject:SetActiveEx(false) +end + +function XUiInfestorExploreShop:OnStart(chapterId) + local icon = XDataCenter.FubenInfestorExploreManager.GetMoneyIcon() + self.RImgIconCost:SetRawImage(icon) + self.RImgSpecialTool1:SetRawImage(icon) + self:InitDynamicTable() +end + +function XUiInfestorExploreShop:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelItemList) + self.DynamicTable:SetDelegate(self) + self.DynamicTable:SetProxy(XUiGridInfestorExploreShopGoods) +end + +function XUiInfestorExploreShop:OnEnable() + self:UpdateView() +end + +function XUiInfestorExploreShop:UpdateView() + self:UpdateDynamicTable() + self:UpdateMoney() +end + +function XUiInfestorExploreShop:UpdateDynamicTable() + local goodIds = XDataCenter.FubenInfestorExploreManager.GetGoodsIds() + self.GoodsIds = goodIds + + local isEmpty = not next(goodIds) + if isEmpty then + self.ImgEmpty.gameObject:SetActiveEx(true) + self.PanelItemList.gameObject:SetActiveEx(false) + else + self.ImgEmpty.gameObject:SetActiveEx(false) + self.PanelItemList.gameObject:SetActiveEx(true) + self.DynamicTable:SetDataSource(goodIds) + self.DynamicTable:ReloadDataSync() + end +end + +function XUiInfestorExploreShop:UpdateMoney() + self.TxtSpecialTool1.text = XDataCenter.FubenInfestorExploreManager.GetMoneyCount() + + local cost = XDataCenter.FubenInfestorExploreManager.GetShopRefreshCost() + local isMoneyEnough = XDataCenter.FubenInfestorExploreManager.CheckMoneyEnough(cost) + self.TxtRefreshCost.text = cost + self.TxtRefreshCost.color = CONDITION_COLOR[isMoneyEnough] +end + +function XUiInfestorExploreShop:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:InitRootUi(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local goodsId = self.GoodsIds[index] + grid:Refresh(goodsId) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + if self.LastSelectGrid then + self.LastSelectGrid:SetSelect(false) + end + self.LastSelectGrid = grid + grid:SetSelect(true) + + local goodsId = self.GoodsIds[index] + self:ShowBuyPanel(goodsId) + end +end + +function XUiInfestorExploreShop:ShowBuyPanel(goodsId) + if self.SelectGoodsId and self.SelectGoodsId == goodsId then + return + end + + self.SelectGoodsId = goodsId + self.PanelBuy.gameObject:SetActiveEx(true) + + local cost = XFubenInfestorExploreConfigs.GetGoodsCost(goodsId) + local goodsName = XFubenInfestorExploreConfigs.GetGoodsName(goodsId) + self.TxtTips.text = CSXTextManagerGetText("InfestorExploreShopNodeBuyTips", cost, goodsName) +end + +function XUiInfestorExploreShop:HideBuyPanel() + self.SelectGoodsId = nil + if self.LastSelectGrid then + self.LastSelectGrid:SetSelect(false) + end + self.LastSelectGrid = nil + self.PanelBuy.gameObject:SetActiveEx(false) +end + +function XUiInfestorExploreShop:AutoAddListener() + self.BtnTanchuangClose.CallBack = function() self:OnClickBtnClose() end + self.BtnRefresh.CallBack = function() self:OnClickBtnRefresh() end + self.BtnBuy.CallBack = function() self:OnClickBtnBuy() end + self.BtnSpecialTool1.CallBack = function() self:OnClickRImgCostBack() end + self.BtnRImgIconCost.CallBack = function() self:OnClickRImgCostBack() end +end + +function XUiInfestorExploreShop:OnClickRImgCostBack() + local data = { + Id = XDataCenter.ItemManager.ItemId.InfestorMoney, + Count = XDataCenter.FubenInfestorExploreManager.GetMoneyCount() + } + XLuaUiManager.Open("UiTip", data) +end + +function XUiInfestorExploreShop:OnClickBtnBuy() + local goodsId = self.SelectGoodsId + + local cost = XFubenInfestorExploreConfigs.GetGoodsCost(goodsId) + if not XDataCenter.FubenInfestorExploreManager.CheckMoneyEnough(cost) then + XUiManager.TipText("InfestorExploreShopNodeMoneyNotEnuogh") + return + end + + if XDataCenter.FubenInfestorExploreManager.IsGoodsSellOut(goodsId) then + XUiManager.TipText("InfestorExploreShopNodeSellOut") + return + end + + local callBack = function() + self:HideBuyPanel() + self:UpdateView() + end + XDataCenter.FubenInfestorExploreManager.RequestBuyGoods(goodsId, callBack) +end + +function XUiInfestorExploreShop:OnClickBtnRefresh() + local cost = XDataCenter.FubenInfestorExploreManager.GetShopRefreshCost() + local isMoneyEnough = XDataCenter.FubenInfestorExploreManager.CheckMoneyEnough(cost) + if not isMoneyEnough then + XUiManager.TipText("InfestorExploreShopNodeMoneyNotEnuoghRefresh") + return + end + + local callBack = function() + self:HideBuyPanel() + self:UpdateView() + end + XDataCenter.FubenInfestorExploreManager.RequestRefreshShop(callBack) +end + +function XUiInfestorExploreShop:OnClickBtnClose() + local sureCallback = function() + XDataCenter.FubenInfestorExploreManager.RequestFinishAction() + self:Close() + end + XUiManager.DialogTip(DialogTitle, DialogContent, XUiManager.DialogType.Normal, nil, sureCallback) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreStage.lua b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreStage.lua new file mode 100644 index 00000000..f88a34d1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreStage.lua @@ -0,0 +1,269 @@ +local XUiGridFubenInfestorExploreMember = require("XUi/XUiFubenInfestorExplore/XUiGridFubenInfestorExploreMember") +local XUiPanelFubenInfestorExploreStages = require("XUi/XUiFubenInfestorExplore/XUiPanelFubenInfestorExploreStages") + +local CSXTextManagerGetText = CS.XTextManager.GetText +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate + +local MAX_MEMBER_NUM = 3 + +local XUiInfestorExploreStage = XLuaUiManager.Register(XLuaUi, "UiInfestorExploreStage") + +function XUiInfestorExploreStage:OnAwake() + self:AutoAddListener() + self.GridCharacter.gameObject:SetActiveEx(false) + self.PanelFullFinish.gameObject:SetActiveEx(false) + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) +end + +function XUiInfestorExploreStage:OnStart(chapterId) + self.ChapterId = chapterId + self.MemberGrids = {} + self:InitView() + self:InitStagesMap() +end + +function XUiInfestorExploreStage:OnEnable() + self:RefreshView() + + self:InitCacheMoneyCount() + + local newChapterAnimFunc = function() + if XDataCenter.FubenInfestorExploreManager.CheckNewChapterNeedShowAnim() then + self:PlayChapterFinishedAnimation() + XDataCenter.FubenInfestorExploreManager.ClearNewChapterNeedShowAnim() + end + end + + if XDataCenter.FubenInfestorExploreManager.IsFightRewadsExist() then + XLuaUiManager.Open("UiInfestorExploreChoose", newChapterAnimFunc) + else + newChapterAnimFunc() + end +end + +function XUiInfestorExploreStage:OnDestroy() + XDataCenter.FubenInfestorExploreManager.SetOpenInfestorExploreCoreDelay(0) + XCountDown.UnBindTimer(self, XCountDown.GTimerName.FubenInfestorExplore) +end + +function XUiInfestorExploreStage:OnGetEvents() + return { XEventId.EVENT_INFESTOREXPLORE_MOVE_TO_NEXT_NODE + , XEventId.EVENT_ITEM_COUNT_UPDATE_PREFIX .. XDataCenter.ItemManager.ItemId.InfestorActionPoint + , XEventId.EVENT_ITEM_COUNT_UPDATE_PREFIX .. XDataCenter.ItemManager.ItemId.InfestorMoney + , XEventId.EVENT_INFESTOREXPLORE_CHARACTER_HP_CHANGE + , XEventId.EVENT_INFESTOREXPLORE_RESET + } +end + +function XUiInfestorExploreStage:OnNotify(evt, ...) + if evt == XEventId.EVENT_INFESTOREXPLORE_MOVE_TO_NEXT_NODE then + self:UpdateStagesMap() + elseif evt == XEventId.EVENT_ITEM_COUNT_UPDATE_PREFIX .. XDataCenter.ItemManager.ItemId.InfestorActionPoint then + self:UpdateActionPoint() + elseif evt == XEventId.EVENT_ITEM_COUNT_UPDATE_PREFIX .. XDataCenter.ItemManager.ItemId.InfestorMoney then + self:UpdateMoney() + elseif evt == XEventId.EVENT_INFESTOREXPLORE_CHARACTER_HP_CHANGE then + self:UpdateCharacters() + elseif evt == XEventId.EVENT_INFESTOREXPLORE_RESET then + XDataCenter.FubenInfestorExploreManager.Reset() + end +end + +function XUiInfestorExploreStage:InitView() + local chapterId = self.ChapterId + + self.TxtTitle.text = XFubenInfestorExploreConfigs.GetChapterName(chapterId) + + local icon = XDataCenter.FubenInfestorExploreManager.GetMoneyIcon() + self.RImgCost:SetRawImage(icon) + + local isHard = XDataCenter.FubenInfestorExploreManager.IsChapterRequireIsomer(chapterId) + self.ImgHard.gameObject:SetActiveEx(isHard) + self.ImgEasy.gameObject:SetActiveEx(not isHard) + + local actionPoint = XDataCenter.FubenInfestorExploreManager.GetActionPoint() + self.TxtActionPoint.text = CSXTextManagerGetText("InfestorExploreActionPointDes", actionPoint) + + local isPassed = XDataCenter.FubenInfestorExploreManager.IsChapterPassed(chapterId) + self.PanelCharacterGroup.gameObject:SetActiveEx(not isPassed) + + XCountDown.BindTimer(self, XCountDown.GTimerName.FubenInfestorExplore, function(time) + time = time > 0 and time or 0 + local timeText = XUiHelper.GetTime(time, XUiHelper.TimeFormatType.CHALLENGE) + self.TxtTime.text = CSXTextManagerGetText("InfestorExploreLeftTime", timeText) + end) + + self.TxtEffectPosition.text = XDataCenter.FubenInfestorExploreManager.GetBuffDes() +end + +function XUiInfestorExploreStage:InitStagesMap() + local chapterId = self.ChapterId + local parentPrefabPath = XFubenInfestorExploreConfigs.GetChapterPrefabPath(chapterId) + local parentPrefab = self.PanelStages:LoadPrefab(parentPrefabPath) + local clickStageCb = function(chapterId, paramNodeId, paramGrid) + if XDataCenter.FubenInfestorExploreManager.IsNodeCurrentShop(chapterId, paramNodeId) then + --商店节点类型特殊判断 + if XDataCenter.FubenInfestorExploreManager.IsNodeCurrentFinished(chapterId, paramNodeId) then + XUiManager.TipText("InfestorExploreShopNodeCurrentFinshed") + else + if XDataCenter.FubenInfestorExploreManager.CheckShopExist() then + XLuaUiManager.Open("UiInfestorExploreShop") + else + local callBack = function() + XLuaUiManager.Open("UiInfestorExploreShop") + end + XDataCenter.FubenInfestorExploreManager.RequestShopInfo(paramNodeId, callBack) + end + end + else + local nodeUiName = XDataCenter.FubenInfestorExploreManager.GetNodeTypeDetailUiName(chapterId, paramNodeId) + if nodeUiName then + self:OnOpenStageDetail() + local grid = paramGrid --magical upvalue! + local closeCb = function() + self:OnCloseStageDetail() + grid:SetSelect(false) + self.PanelStagesParent.ScrollRect.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Elastic + + if XDataCenter.FubenInfestorExploreManager.CheckNewChapterNeedShowAnim() then + self:PlayChapterFinishedAnimation() + XDataCenter.FubenInfestorExploreManager.ClearNewChapterNeedShowAnim() + end + end + self:OpenChildUi(nodeUiName, closeCb) + self:FindChildUiObj(nodeUiName):Refresh(chapterId, paramNodeId) + end + end + end + self.PanelStagesParent = XUiPanelFubenInfestorExploreStages.New(parentPrefab, self, chapterId, clickStageCb) +end + +function XUiInfestorExploreStage:RefreshView() + self:UpdateActionPoint() + self:UpdateMoney() + self:UpdateCharacters() + self:UpdateStagesMap() +end + +function XUiInfestorExploreStage:UpdateActionPoint() + local actionPoint = XDataCenter.FubenInfestorExploreManager.GetActionPoint() + self.TxtActionPoint.text = CSXTextManagerGetText("InfestorExploreCurActionPoint", actionPoint) +end + +function XUiInfestorExploreStage:UpdateMoney() + local count = XDataCenter.FubenInfestorExploreManager.GetMoneyCount() + self:RefreshCacheMoneyCount(count) + self.TxtCost.text = "x" .. count +end + +function XUiInfestorExploreStage:InitCacheMoneyCount() + local count = XDataCenter.FubenInfestorExploreManager.GetMoneyCount() + XDataCenter.FubenInfestorExploreManager.RefreshCacheMoneyCount(count, count) +end + +function XUiInfestorExploreStage:RefreshCacheMoneyCount(newMoneyCount) + XDataCenter.FubenInfestorExploreManager.RefreshCacheMoneyCount(newMoneyCount) +end + +function XUiInfestorExploreStage:UpdateCharacters() + local chapterId = self.ChapterId + local characterIds = XDataCenter.FubenInfestorExploreManager.GetChapterTeamCharacterIds(chapterId) + local captainPos = XDataCenter.FubenInfestorExploreManager.GetChapterTeamCaptainPos(chapterId) + for pos = 1, MAX_MEMBER_NUM do + local characterId = characterIds[pos] + local isCaptain = pos == captainPos + local grid = self.MemberGrids[pos] + if characterId > 0 then + if not grid then + local go = CSUnityEngineObjectInstantiate(self.GridCharacter, self.PanelCharacterContent) + local clickCb = function() + XUiManager.TipText("InfestorExploreCharacterReplaceTip") + end + grid = XUiGridFubenInfestorExploreMember.New(go, clickCb) + self.MemberGrids[pos] = grid + end + grid:Refresh(characterId, isCaptain) + grid.GameObject:SetActiveEx(true) + else + if grid then + grid.GameObject:SetActiveEx(false) + end + end + end +end + +function XUiInfestorExploreStage:UpdateStagesMap() + self.PanelStagesParent:UpdateStagesMap() +end + +function XUiInfestorExploreStage:AutoAddListener() + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + self:BindHelpBtn(self.BtnHelp, "InfestorExplore") + self.BtnNegativeEffects.CallBack = function() self:OnClickBtnNegativeEffects() end + self.BtnTacticalCore.CallBack = function() self:OnClickBtnTacticalCore() end + self.BtnContract.CallBack = function() self:OnClickBtnContract() end + self.BtnMessage.CallBack = function() self:OnClickBtnGuestbook() end + self.BtnRImgCost.CallBack = function() self:OnClickRImgCostBack() end +end + +function XUiInfestorExploreStage:OnBtnBackClick() + self:Close() +end + +function XUiInfestorExploreStage:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiInfestorExploreStage:OnClickBtnNegativeEffects() + XLuaUiManager.Open("UiInfestorExploreDebuff") +end + +function XUiInfestorExploreStage:OnClickBtnTacticalCore() + XLuaUiManager.Open("UiInfestorExploreCore") +end + +function XUiInfestorExploreStage:OnClickBtnContract() + XLuaUiManager.Open("UiInfestorExploreContract") +end + +function XUiInfestorExploreStage:OnOpenStageDetail() + self.LeftGroup.gameObject:SetActiveEx(false) + self.BtnNegativeEffects.gameObject:SetActiveEx(false) + self.BtnTacticalCore.gameObject:SetActiveEx(false) + self.BtnMessage.gameObject:SetActiveEx(false) +end + +function XUiInfestorExploreStage:OnCloseStageDetail() + self.LeftGroup.gameObject:SetActiveEx(true) + self.BtnNegativeEffects.gameObject:SetActiveEx(true) + self.BtnTacticalCore.gameObject:SetActiveEx(true) + self.BtnMessage.gameObject:SetActiveEx(true) + self:PlayAnimation("QieHuan") +end + +function XUiInfestorExploreStage:PlayChapterFinishedAnimation() + if self.IsPlayingAnim then return end + self.IsPlayingAnim = true + + self.PanelFullFinish.gameObject:SetActiveEx(true) + + XDataCenter.FubenInfestorExploreManager.SetOpenInfestorExploreCoreDelay(2000) + XDataCenter.FubenInfestorExploreManager.OpenGetNewCoreUi() + self:PlayAnimation("PanelFullFinishEnable", function() + self.IsPlayingAnim = nil + self:Close() + end) +end + +function XUiInfestorExploreStage:OnClickBtnGuestbook() + XDataCenter.FubenInfestorExploreManager.OpenGuestBook(self.ChapterId) +end + +function XUiInfestorExploreStage:OnClickRImgCostBack() + local data = { + Id = XDataCenter.ItemManager.ItemId.InfestorMoney, + Count = XDataCenter.FubenInfestorExploreManager.GetMoneyCount() + } + XLuaUiManager.Open("UiTip", data) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreStageDetailEvent.lua b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreStageDetailEvent.lua new file mode 100644 index 00000000..1ec99cf2 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreStageDetailEvent.lua @@ -0,0 +1,149 @@ +local next = next +local stringGsub = string.gsub + +local MAX_OPTION_NUM = 3 + +local XUiInfestorExploreStageDetailEvent = XLuaUiManager.Register(XLuaUi, "UiInfestorExploreStageDetailEvent") + +function XUiInfestorExploreStageDetailEvent:OnAwake() + self:AutoAddListener() +end + +function XUiInfestorExploreStageDetailEvent:OnStart(closeCb) + self.CloseCb = closeCb +end + +function XUiInfestorExploreStageDetailEvent:OnDisable() + self.CloseCb() +end + +function XUiInfestorExploreStageDetailEvent:Refresh(chapterId, nodeId) + self.ChapterId = chapterId + self.NodeId = nodeId + + local poolId = XDataCenter.FubenInfestorExploreManager.GetNodeEventPoolId(chapterId, nodeId) + + self.TxtName.text = XFubenInfestorExploreConfigs.GetEventPoolName(poolId) + self.TxtDes.text = XFubenInfestorExploreConfigs.GetEventPoolDes(poolId) + + local bg = XDataCenter.FubenInfestorExploreManager.GetNodeStageBg(chapterId, nodeId) + self.RImgIcon:SetRawImage(bg) + + if XDataCenter.FubenInfestorExploreManager.IsNodeSelectEvent(chapterId, nodeId) then + for i = 1, MAX_OPTION_NUM do + local btn = self["BtnOption" .. i] + local desList = XFubenInfestorExploreConfigs.GetEventPoolMultiOptionDesList(poolId, i) + if next(desList) then + local des + for _, desStr in pairs(desList) do + des = des and des .. desStr or desStr + end + des = stringGsub(des, "\\n", "\n") + btn:SetNameByGroup(0, des) + btn.gameObject:SetActiveEx(true) + else + btn.gameObject:SetActiveEx(false) + end + end + self.PanelOptionList.gameObject:SetActiveEx(false) + self.BtnConfirm.gameObject:SetActiveEx(false) + self.PanelOption.gameObject:SetActiveEx(true) + elseif XDataCenter.FubenInfestorExploreManager.IsNodeAutoEvent(chapterId, nodeId) then + for i = 1, MAX_OPTION_NUM do + local txt = self["TxtOption" .. i] + local desList = XFubenInfestorExploreConfigs.GetEventPoolMultiOptionDesList(poolId, i) + if next(desList) then + local des + for _, desStr in pairs(desList) do + des = des and des .. ", " .. desStr or desStr + end + txt.text = des + txt.gameObject:SetActiveEx(true) + else + txt.gameObject:SetActiveEx(false) + end + end + + local btnName = XFubenInfestorExploreConfigs.GetEventPoolBtnName(poolId) + self.BtnConfirm:SetNameByGroup(0, btnName) + + self.PanelOption.gameObject:SetActiveEx(false) + self.BtnConfirm.gameObject:SetActiveEx(true) + self.PanelOptionList.gameObject:SetActiveEx(true) + end +end + +function XUiInfestorExploreStageDetailEvent:AutoAddListener() + self.BtnCloseMask.CallBack = function() self:Close() end + self.BtnConfirm.CallBack = function() self:OnClickBtnConfirm() end + self.BtnGuestbook.CallBack = function() self:OnClickBtnGuestbook() end + for index = 1, MAX_OPTION_NUM do + self["BtnOption" .. index].CallBack = function() self:OnSelectOption(index) end + end +end + +function XUiInfestorExploreStageDetailEvent:OnClickBtnConfirm() + local chapterId = self.ChapterId + local nodeId = self.NodeId + + if XDataCenter.FubenInfestorExploreManager.IsNodePassed(chapterId, nodeId) then + XUiManager.TipText("InfestorExploreEventNodePassed") + return + end + + if XDataCenter.FubenInfestorExploreManager.IsNodeUnReach(chapterId, nodeId) then + XUiManager.TipText("InfestorExploreEventNodeNotReach") + return + end + + if XDataCenter.FubenInfestorExploreManager.IsNodeCurrentFinished(chapterId, nodeId) then + XUiManager.TipText("InfestorExploreEventNodeCurrent") + return + end + + if not XDataCenter.FubenInfestorExploreManager.CheckActionPoint(chapterId, nodeId) then + XUiManager.TipText("InfestorExploreActionPointNotEnough") + return + end + + local callBack = function() + self:Close() + end + XDataCenter.FubenInfestorExploreManager.RequestInfestorExploreAutoEvent(nodeId, callBack) +end + +function XUiInfestorExploreStageDetailEvent:OnSelectOption(index) + local chapterId = self.ChapterId + local nodeId = self.NodeId + + if XDataCenter.FubenInfestorExploreManager.IsNodePassed(chapterId, nodeId) then + XUiManager.TipText("InfestorExploreEventNodePassed") + return + end + + if XDataCenter.FubenInfestorExploreManager.IsNodeUnReach(chapterId, nodeId) then + XUiManager.TipText("InfestorExploreEventNodeNotReach") + return + end + + if XDataCenter.FubenInfestorExploreManager.IsNodeCurrentFinished(chapterId, nodeId) then + XUiManager.TipText("InfestorExploreEventNodeCurrent") + return + end + + if not XDataCenter.FubenInfestorExploreManager.CheckActionPoint(chapterId, nodeId) then + XUiManager.TipText("InfestorExploreActionPointNotEnough") + return + end + + local poolId = XDataCenter.FubenInfestorExploreManager.GetNodeEventPoolId(chapterId, nodeId) + local eventIds = XFubenInfestorExploreConfigs.GetEventPoolMultiOptionEventIds(poolId, index) + local callBack = function() + self:Close() + end + XDataCenter.FubenInfestorExploreManager.RequestInfestorExploreSelectEvent(nodeId, eventIds, callBack) +end + +function XUiInfestorExploreStageDetailEvent:OnClickBtnGuestbook() + XDataCenter.FubenInfestorExploreManager.OpenGuestBook(self.ChapterId) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreStageDetailFight.lua b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreStageDetailFight.lua new file mode 100644 index 00000000..fdd22cf9 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreStageDetailFight.lua @@ -0,0 +1,119 @@ +local stringGsub = string.gsub + +local XUiInfestorExploreStageDetailFight = XLuaUiManager.Register(XLuaUi, "UiInfestorExploreStageDetailFight") + +function XUiInfestorExploreStageDetailFight:OnAwake() + self.GridItem.gameObject:SetActiveEx(false) + self:AutoAddListener() +end + +function XUiInfestorExploreStageDetailFight:OnStart(closeCb) + self.CloseCb = closeCb + self.GridList = {} +end + +function XUiInfestorExploreStageDetailFight:OnDisable() + self.CloseCb() +end + +function XUiInfestorExploreStageDetailFight:Refresh(chapterId, nodeId) + self.ChapterId = chapterId + self.NodeId = nodeId + + local fightStageId = XDataCenter.FubenInfestorExploreManager.GetNodeFightStageId(chapterId, nodeId) + + self.TxtName.text = XDataCenter.FubenManager.GetStageName(fightStageId) + local des = XDataCenter.FubenManager.GetStageDes(fightStageId) + self.TxtDes.text = stringGsub(des, "\\n", "\n") + + local bg = XDataCenter.FubenInfestorExploreManager.GetNodeStageBg(chapterId, nodeId) + self.RImgIcon:SetRawImage(bg) + + local isUnReach = XDataCenter.FubenInfestorExploreManager.IsNodeUnReach(chapterId, nodeId) + local isPassed = XDataCenter.FubenInfestorExploreManager.IsNodePassed(chapterId, nodeId) + self.BtnFight.gameObject:SetActiveEx(not isUnReach and not isPassed) + + local rewardId = XDataCenter.FubenInfestorExploreManager.GetNodeShowRewardId(chapterId, nodeId) + if not rewardId or rewardId == 0 then + self.PanelReward.gameObject:SetActiveEx(false) + else + local rewards = XRewardManager.GetRewardListNotCount(rewardId) + if rewards then + for i, item in ipairs(rewards) do + local grid + if self.GridList[i] then + grid = self.GridList[i] + else + local ui = CS.UnityEngine.Object.Instantiate(self.GridItem, self.PanelReward) + grid = XUiGridCommon.New(self, ui) + self.GridList[i] = grid + end + grid:Refresh(item) + grid.GameObject:SetActive(true) + end + end + + local rewardsCount = 0 + if rewards then + rewardsCount = #rewards + end + + for j = 1, #self.GridList do + if j > rewardsCount then + self.GridList[j].GameObject:SetActive(false) + end + end + + self.PanelReward.gameObject:SetActiveEx(true) + end +end + +function XUiInfestorExploreStageDetailFight:AutoAddListener() + self.BtnCloseMask.CallBack = function() self:Close() end + self.BtnGuestbook.CallBack = function() self:OnClickBtnGuestbook() end + self.BtnFight.CallBack = function() self:OnClickBtnFight() end +end + +function XUiInfestorExploreStageDetailFight:OnClickBtnFight() + local chapterId = self.ChapterId + local nodeId = self.NodeId + + if XDataCenter.FubenInfestorExploreManager.IsNodePassed(chapterId, nodeId) then + XUiManager.TipText("InfestorExploreFightNodePassed") + return + end + + if XDataCenter.FubenInfestorExploreManager.IsNodeUnReach(chapterId, nodeId) then + XUiManager.TipText("InfestorExploreFightNodeNotReach") + return + end + + if XDataCenter.FubenInfestorExploreManager.IsNodeCurrentFinished(chapterId, nodeId) then + XUiManager.TipText("InfestorExploreFightNodeCurrent") + return + end + + if not XDataCenter.FubenInfestorExploreManager.CheckActionPoint(chapterId, nodeId) then + XUiManager.TipText("InfestorExploreActionPointNotEnough") + return + end + + local characterIds = XDataCenter.FubenInfestorExploreManager.GetChapterTeamCharacterIds(chapterId) + local captainPos = XDataCenter.FubenInfestorExploreManager.GetChapterTeamCaptainPos(chapterId) + local firstFightPos = XDataCenter.FubenInfestorExploreManager.GetChapterTeamFirstFightPos(chapterId) + local saveCallBack = function(cacheCharacterIds, cacheCaptainPos, cacheFirstFightPos) + XDataCenter.FubenInfestorExploreManager.SaveChapterTeam(chapterId, cacheCharacterIds, cacheCaptainPos, cacheFirstFightPos) + end + local enterCallBack = function() + XDataCenter.FubenInfestorExploreManager.RequestEnterFight(chapterId, nodeId) + self:Close() + end + local forbitReplaceCharacter = true + local characterLimitType = XFubenInfestorExploreConfigs.GetChapterCharacterLimitType(chapterId) + local limitBuffId = XFubenInfestorExploreConfigs.GetChapterLimitBuffId(chapterId) + XLuaUiManager.Open("UiInfestorExploreTeamEdit", characterLimitType, limitBuffId, characterIds, captainPos, saveCallBack, enterCallBack, forbitReplaceCharacter, firstFightPos) +end + +function XUiInfestorExploreStageDetailFight:OnClickBtnGuestbook() + XDataCenter.FubenInfestorExploreManager.OpenGuestBook(self.ChapterId) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreStageDetailOutPost.lua b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreStageDetailOutPost.lua new file mode 100644 index 00000000..44825f15 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreStageDetailOutPost.lua @@ -0,0 +1,107 @@ +local stringGsub = string.gsub + +local EVENT_NAME_STR = CS.XTextManager.GetText("InfestorExploreOutPostNodeName") + +local XUiInfestorExploreStageDetailOutPost = XLuaUiManager.Register(XLuaUi, "UiInfestorExploreStageDetailOutPost") + +function XUiInfestorExploreStageDetailOutPost:OnAwake() + self.GridItem.gameObject:SetActiveEx(false) + self:AutoAddListener() +end + +function XUiInfestorExploreStageDetailOutPost:OnStart(closeCb) + self.CloseCb = closeCb + self.GridList = {} +end + +function XUiInfestorExploreStageDetailOutPost:Refresh(chapterId, nodeId) + self.ChapterId = chapterId + self.NodeId = nodeId + + self.TxtName.text = EVENT_NAME_STR + local des = XDataCenter.FubenInfestorExploreManager.GetOutPostNodeStartDes(chapterId, nodeId) + self.TxtDes.text = stringGsub(des, "\\n", "\n") + + local bg = XDataCenter.FubenInfestorExploreManager.GetNodeStageBg(chapterId, nodeId) + self.RImgIcon:SetRawImage(bg) + + local isUnReach = XDataCenter.FubenInfestorExploreManager.IsNodeUnReach(chapterId, nodeId) + local isPassed = XDataCenter.FubenInfestorExploreManager.IsNodePassed(chapterId, nodeId) + self.BtnFight.gameObject:SetActiveEx(not isUnReach and not isPassed) + + local rewardId = XDataCenter.FubenInfestorExploreManager.GetNodeShowRewardId(chapterId, nodeId) + if not rewardId or rewardId == 0 then + self.PanelReward.gameObject:SetActiveEx(false) + else + local rewards = XRewardManager.GetRewardListNotCount(rewardId) + if rewards then + for i, item in ipairs(rewards) do + local grid + if self.GridList[i] then + grid = self.GridList[i] + else + local ui = CS.UnityEngine.Object.Instantiate(self.GridItem, self.PanelReward) + grid = XUiGridCommon.New(self, ui) + self.GridList[i] = grid + end + grid:Refresh(item) + grid.GameObject:SetActive(true) + end + end + + local rewardsCount = 0 + if rewards then + rewardsCount = #rewards + end + + for j = 1, #self.GridList do + if j > rewardsCount then + self.GridList[j].GameObject:SetActive(false) + end + end + + self.PanelReward.gameObject:SetActiveEx(true) + end +end + +function XUiInfestorExploreStageDetailOutPost:OnDisable() + self.CloseCb() +end + +function XUiInfestorExploreStageDetailOutPost:AutoAddListener() + self.BtnCloseMask.CallBack = function() self:Close() end + self.BtnGuestbook.CallBack = function() self:OnClickBtnGuestbook() end + self.BtnFight.CallBack = function() self:OnClickBtnFight() end +end + +function XUiInfestorExploreStageDetailOutPost:OnClickBtnFight() + local chapterId = self.ChapterId + local nodeId = self.NodeId + + if XDataCenter.FubenInfestorExploreManager.IsNodePassed(chapterId, nodeId) then + XUiManager.TipText("InfestorExploreOutPostNodePassed") + return + end + + if XDataCenter.FubenInfestorExploreManager.IsNodeUnReach(chapterId, nodeId) then + XUiManager.TipText("InfestorExploreOutPostNodeNotReach") + return + end + + if XDataCenter.FubenInfestorExploreManager.IsNodeCurrentFinished(chapterId, nodeId) then + XUiManager.TipText("InfestorExploreOutPostNodeCurrent") + return + end + + if not XDataCenter.FubenInfestorExploreManager.CheckActionPoint(chapterId, nodeId) then + XUiManager.TipText("InfestorExploreActionPointNotEnough") + return + end + + self:Close() + XLuaUiManager.Open("UiInfestorExploreOutpost", chapterId, nodeId) +end + +function XUiInfestorExploreStageDetailOutPost:OnClickBtnGuestbook() + XDataCenter.FubenInfestorExploreManager.OpenGuestBook(self.ChapterId) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreStageDetailRest.lua b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreStageDetailRest.lua new file mode 100644 index 00000000..98332450 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreStageDetailRest.lua @@ -0,0 +1,163 @@ +local XUiGridFubenInfestorExploreMember = require("XUi/XUiFubenInfestorExplore/XUiGridFubenInfestorExploreMember") + +local CSXTextManagerGetText = CS.XTextManager.GetText +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate + +local TipTitle = CSXTextManagerGetText("InfestorExploreRestNodeSucTitle") +local TipContent = CSXTextManagerGetText("InfestorExploreRestNodeSucContent") +local EVENT_NAME_STR = CS.XTextManager.GetText("InfestorExploreRestNodeName") +local EVENT_DES_STR = CS.XTextManager.GetText("InfestorExploreRestNodeDes") +local MAX_MEMBER_NUM = 3 + +local XUiInfestorExploreStageDetailRest = XLuaUiManager.Register(XLuaUi, "UiInfestorExploreStageDetailRest") + +function XUiInfestorExploreStageDetailRest:OnAwake() + self.GridHead.gameObject:SetActiveEx(false) + self:AutoAddListener() +end + +function XUiInfestorExploreStageDetailRest:OnStart(closeCb) + self.CloseCb = closeCb + self.MemberGrids = {} +end + +function XUiInfestorExploreStageDetailRest:Refresh(chapterId, nodeId) + self.ChapterId = chapterId + self.NodeId = nodeId + + self.TxtName.text = EVENT_NAME_STR + self.TxtDes.text = EVENT_DES_STR + + local bg = XDataCenter.FubenInfestorExploreManager.GetNodeStageBg(chapterId, nodeId) + self.RImgIcon:SetRawImage(bg) + + local isUnReach = XDataCenter.FubenInfestorExploreManager.IsNodeUnReach(chapterId, nodeId) + local isPassed = XDataCenter.FubenInfestorExploreManager.IsNodePassed(chapterId, nodeId) + local isShowBtn = not isUnReach and not isPassed + self.BtnConfirm.gameObject:SetActiveEx(isShowBtn) + + self:UpdateView() +end + +function XUiInfestorExploreStageDetailRest:OnDisable() + self.CloseCb() +end + +function XUiInfestorExploreStageDetailRest:UpdateView() + local chapterId = self.ChapterId + local nodeId = self.NodeId + + local characterIds = XDataCenter.FubenInfestorExploreManager.GetChapterTeamCharacterIds(chapterId) + local captainPos = XDataCenter.FubenInfestorExploreManager.GetChapterTeamCaptainPos(chapterId) + local firstFightPos = XDataCenter.FubenInfestorExploreManager.GetChapterTeamFirstFightPos(chapterId) + for pos = 1, MAX_MEMBER_NUM do + local characterId = characterIds[pos] + local isCaptain = pos == captainPos + local isFirstFight = pos == firstFightPos + local grid = self.MemberGrids[pos] + if characterId > 0 then + if not grid then + local go = CSUnityEngineObjectInstantiate(self.GridHead, self.PanelThemeHead) + grid = XUiGridFubenInfestorExploreMember.New(go) + self.MemberGrids[pos] = grid + end + grid:Refresh(characterId, isCaptain, isFirstFight) + grid.GameObject:SetActiveEx(true) + else + if grid then + grid.GameObject:SetActiveEx(false) + end + end + end +end + +function XUiInfestorExploreStageDetailRest:AutoAddListener() + self.BtnCloseMask.CallBack = function() self:OnClickBtnClose() end + self.BtnGuestbook.CallBack = function() self:OnClickBtnGuestbook() end + self.BtnConfirm.CallBack = function() self:OnClickBtnConfirm() end + self.BtnChange.CallBack = function() self:OnClickBtnChange() end +end + +function XUiInfestorExploreStageDetailRest:OnClickBtnClose() + local chapterId = self.ChapterId + local nodeId = self.NodeId + + if not XDataCenter.FubenInfestorExploreManager.IsNodeReach(chapterId, nodeId) + or not XDataCenter.FubenInfestorExploreManager.IsTeamChanged() + then + self:Close() + else + self:OnClickBtnConfirm() + end +end + +function XUiInfestorExploreStageDetailRest:OnClickBtnConfirm() + local chapterId = self.ChapterId + local nodeId = self.NodeId + + if XDataCenter.FubenInfestorExploreManager.IsNodePassed(chapterId, nodeId) then + XUiManager.TipText("InfestorExploreRestNodePassed") + return + end + + if XDataCenter.FubenInfestorExploreManager.IsNodeUnReach(chapterId, nodeId) then + XUiManager.TipText("InfestorExploreRestNodeNotReach") + return + end + + if XDataCenter.FubenInfestorExploreManager.IsNodeCurrentFinished(chapterId, nodeId) then + XUiManager.TipText("InfestorExploreRestNodeCurrent") + return + end + + if not XDataCenter.FubenInfestorExploreManager.CheckActionPoint(chapterId, nodeId) then + XUiManager.TipText("InfestorExploreActionPointNotEnough") + return + end + + local callBack = function() + XDataCenter.FubenInfestorExploreManager.ClearTeamChangedFlag() + XUiManager.DialogTip(TipTitle, TipContent, XUiManager.DialogType.Normal) + self:Close() + end + XDataCenter.FubenInfestorExploreManager.RequestRest(chapterId, nodeId, callBack) +end + +function XUiInfestorExploreStageDetailRest:OnClickBtnChange() + local chapterId = self.ChapterId + local nodeId = self.NodeId + + if XDataCenter.FubenInfestorExploreManager.IsNodeCurrentFinished(chapterId, nodeId) then + XUiManager.TipText("InfestorExploreRestNodeCurrent") + return + end + + local isUnReach = XDataCenter.FubenInfestorExploreManager.IsNodeUnReach(chapterId, nodeId) + local isPassed = XDataCenter.FubenInfestorExploreManager.IsNodePassed(chapterId, nodeId) + local isShowBtn = not isUnReach and not isPassed + if not isShowBtn then + XUiManager.TipText("InfestorExploreRestNodeNotReach") + return + end + + if not XDataCenter.FubenInfestorExploreManager.CheckActionPoint(chapterId, nodeId) then + XUiManager.TipText("InfestorExploreActionPointNotEnough") + return + end + + local characterIds = XDataCenter.FubenInfestorExploreManager.GetChapterTeamCharacterIds(chapterId) + local captainPos = XDataCenter.FubenInfestorExploreManager.GetChapterTeamCaptainPos(chapterId) + local firstFightPos = XDataCenter.FubenInfestorExploreManager.GetChapterTeamFirstFightPos(chapterId) + local saveCallBack = function(cacheCharacterIds, cacheCaptainPos, cacheFirstFightPos) + XDataCenter.FubenInfestorExploreManager.SaveChapterTeam(chapterId, cacheCharacterIds, cacheCaptainPos, cacheFirstFightPos) + XDataCenter.FubenInfestorExploreManager.SetTeamChangedFlag() + self:UpdateView() + end + local characterLimitType = XFubenInfestorExploreConfigs.GetChapterCharacterLimitType(chapterId) + local limitBuffId = XFubenInfestorExploreConfigs.GetChapterLimitBuffId(chapterId) + XLuaUiManager.Open("UiInfestorExploreTeamEdit", characterLimitType, limitBuffId, characterIds, captainPos, saveCallBack, nil, nil, firstFightPos) +end + +function XUiInfestorExploreStageDetailRest:OnClickBtnGuestbook() + XDataCenter.FubenInfestorExploreManager.OpenGuestBook(self.ChapterId) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreStageDetailReward.lua b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreStageDetailReward.lua new file mode 100644 index 00000000..a48c8fbb --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreStageDetailReward.lua @@ -0,0 +1,82 @@ +local CSXTextManagerGetText = CS.XTextManager.GetText +local EVENT_NAME_STR = CSXTextManagerGetText("InfestorExploreRewardNodeName") +local EVENT_DES_STR = CSXTextManagerGetText("InfestorExploreRewardNodeDes") + +local XUiInfestorExploreStageDetailReward = XLuaUiManager.Register(XLuaUi, "UiInfestorExploreStageDetailReward") + +function XUiInfestorExploreStageDetailReward:OnAwake() + self:AutoAddListener() +end + +function XUiInfestorExploreStageDetailReward:OnStart(closeCb) + self.CloseCb = closeCb +end + +function XUiInfestorExploreStageDetailReward:Refresh(chapterId, nodeId) + self.ChapterId = chapterId + self.NodeId = nodeId + + self.TxtName.text = EVENT_NAME_STR + self.TxtDes.text = EVENT_DES_STR + + local bg = XDataCenter.FubenInfestorExploreManager.GetNodeStageBg(chapterId, nodeId) + self.RImgIcon:SetRawImage(bg) + + local playerHeadIcon = XDataCenter.FubenInfestorExploreManager.GetSelectRewardPlayerHeadIcon(chapterId, nodeId)-----zhangshuang + if playerHeadIcon then + self.RImgHead:SetRawImage(playerHeadIcon) + end + + local effctPath = XDataCenter.FubenInfestorExploreManager.GetSelectRewardPlayerHeadEffectPath(chapterId, nodeId) + if effctPath then + self.EffectHead:LoadUiEffect(effctPath) + end + + self.TxtRoleName.text = XDataCenter.FubenInfestorExploreManager.GetSelectRewardPlayerName(chapterId, nodeId) + self.TxtWord.text = XDataCenter.FubenInfestorExploreManager.GetSelectRewardMessage(chapterId, nodeId) +end + +function XUiInfestorExploreStageDetailReward:OnDisable() + self.CloseCb() +end + +function XUiInfestorExploreStageDetailReward:AutoAddListener() + self.BtnCloseMask.CallBack = function() self:Close() end + self.BtnGuestbook.CallBack = function() self:OnClickBtnGuestbook() end + self.BtnReward.CallBack = function() self:OnClickBtnReward() end +end + +function XUiInfestorExploreStageDetailReward:OnClickBtnReward() + local chapterId = self.ChapterId + local nodeId = self.NodeId + + if XDataCenter.FubenInfestorExploreManager.IsNodePassed(chapterId, nodeId) then + XUiManager.TipText("InfestorExploreRewardNodePassed") + return + end + + if XDataCenter.FubenInfestorExploreManager.IsNodeCurrentFinished(chapterId, nodeId) then + XUiManager.TipText("InfestorExploreRewardNodePassed") + return + end + + if XDataCenter.FubenInfestorExploreManager.IsNodeUnReach(chapterId, nodeId) then + XUiManager.TipText("InfestorExploreRewardNodeNotReach") + return + end + + if not XDataCenter.FubenInfestorExploreManager.CheckActionPoint(chapterId, nodeId) then + XUiManager.TipText("InfestorExploreActionPointNotEnough") + return + end + + local rewardCallBack = function(selectRewardIdList) + self:Close() + XLuaUiManager.Open("UiInfestorExploreStageDetailRewardGive", selectRewardIdList, chapterId, nodeId) + end + XDataCenter.FubenInfestorExploreManager.RequestGetSelectReward(nodeId, rewardCallBack) +end + +function XUiInfestorExploreStageDetailReward:OnClickBtnGuestbook() + XDataCenter.FubenInfestorExploreManager.OpenGuestBook(self.ChapterId) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreStageDetailRewardGive.lua b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreStageDetailRewardGive.lua new file mode 100644 index 00000000..44e85494 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreStageDetailRewardGive.lua @@ -0,0 +1,86 @@ +local XUiGridInfestorShopReward = require("XUi/XUiFubenInfestorExplore/XUiGridInfestorShopReward") + +local CSXTextManagerGetText = CS.XTextManager.GetText + +local DialogTitle = CSXTextManagerGetText("InfestorExploreRewardNodeCloseTipTitle") +local DialogContent = CSXTextManagerGetText("InfestorExploreRewardNodeCloseTipContent") + +local XUiInfestorExploreStageDetailRewardGive = XLuaUiManager.Register(XLuaUi, "UiInfestorExploreStageDetailRewardGive") + +function XUiInfestorExploreStageDetailRewardGive:OnAwake() + self:AutoAddListener() + self.GridInfestorShopReward.gameObject:SetActiveEx(false) +end + +function XUiInfestorExploreStageDetailRewardGive:OnStart(rewardIdList, chapterId, nodeId) + self.RewardIdList = rewardIdList + self.ChapterId = chapterId + self.NodeId = nodeId + + self:InitDynamicTable() + self.DynamicTable:SetDataSource(rewardIdList) + self.DynamicTable:ReloadDataASync() +end + +function XUiInfestorExploreStageDetailRewardGive:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelSelectList) + self.DynamicTable:SetProxy(XUiGridInfestorShopReward) + self.DynamicTable:SetDelegate(self) +end + +function XUiInfestorExploreStageDetailRewardGive:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:InitRootUi(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local rewardId = self.RewardIdList[index] + local chapterId = self.ChapterId + local nodeId = self.NodeId + grid:Refresh(rewardId, chapterId, nodeId) + + local isSelect = self.SelectRewardId and rewardId == self.SelectRewardId + grid:SetSelect(isSelect) + if isSelect then + self.LastSelectGrid = grid + end + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + if self.LastSelectGrid then + self.LastSelectGrid:SetSelect(false) + end + self.LastSelectGrid = grid + + local rewardId = self.RewardIdList[index] + self.SelectRewardId = rewardId + + grid:SetSelect(true) + end +end + +function XUiInfestorExploreStageDetailRewardGive:AutoAddListener() + self.BtnClose.CallBack = function() self:OnClickBtnClose() end + self.BtnTanchuangClose.CallBack = function() self:OnClickBtnClose() end + self.BtnConfirm.CallBack = function() self:OnClickBtnConfirm() end +end + +function XUiInfestorExploreStageDetailRewardGive:OnClickBtnClose() + local sureCallBack = function() + XDataCenter.FubenInfestorExploreManager.RequestFinishAction(function() + self:Close() + end) + end + XUiManager.DialogTip(DialogTitle, DialogContent, XUiManager.DialogType.Normal, nil, sureCallBack) +end + +function XUiInfestorExploreStageDetailRewardGive:OnClickBtnConfirm() + local rewardId = self.SelectRewardId + if not rewardId then + XUiManager.TipText("InfestorExploreRewardNodeNotSelectReward") + return + end + + local msg = self.InputFiedMsg.text + local callBack = function() + XUiManager.TipText("InfestorExploreRewardNodeSelectRewardSuc") + self:Close() + end + XDataCenter.FubenInfestorExploreManager.RequestSetSelectReward(rewardId, msg, callBack) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreStageDetailShop.lua b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreStageDetailShop.lua new file mode 100644 index 00000000..6ab9bda8 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreStageDetailShop.lua @@ -0,0 +1,75 @@ +local CSXTextManagerGetText = CS.XTextManager.GetText +local EVENT_NAME_STR = CSXTextManagerGetText("InfestorExploreShopNodeName") +local EVENT_DES_STR = CSXTextManagerGetText("InfestorExploreShopNodeDes") + +local XUiInfestorExploreStageDetailShop = XLuaUiManager.Register(XLuaUi, "UiInfestorExploreStageDetailShop") + +function XUiInfestorExploreStageDetailShop:OnAwake() + self:AutoAddListener() + self.BtnLeave.gameObject:SetActiveEx(false) +end + +function XUiInfestorExploreStageDetailShop:OnStart(closeCb) + self.CloseCb = closeCb +end + +function XUiInfestorExploreStageDetailShop:OnDisable() + self.CloseCb() +end + +function XUiInfestorExploreStageDetailShop:Refresh(chapterId, nodeId) + self.ChapterId = chapterId + self.NodeId = nodeId + + self.TxtName.text = EVENT_NAME_STR + self.TxtDes.text = EVENT_DES_STR + + local bg = XDataCenter.FubenInfestorExploreManager.GetNodeStageBg(chapterId, nodeId) + self.RImgIcon:SetRawImage(bg) +end + +function XUiInfestorExploreStageDetailShop:AutoAddListener() + self.BtnCloseMask.CallBack = function() self:Close() end + self.BtnGuestbook.CallBack = function() self:OnClickBtnGuestbook() end + self.BtnEnter.CallBack = function() self:OnClickBtnEnter() end +end + +function XUiInfestorExploreStageDetailShop:OnClickBtnEnter() + local chapterId = self.ChapterId + local nodeId = self.NodeId + + if XDataCenter.FubenInfestorExploreManager.IsNodePassed(chapterId, nodeId) then + XUiManager.TipText("InfestorExploreShopNodePassed") + return + end + + if XDataCenter.FubenInfestorExploreManager.IsNodeCurrentFinished(chapterId, nodeId) then + XUiManager.TipText("InfestorExploreShopNodeCurrentFinshed") + return + end + + if XDataCenter.FubenInfestorExploreManager.IsNodeUnReach(chapterId, nodeId) then + XUiManager.TipText("InfestorExploreShopNodeNotReach") + return + end + + if not XDataCenter.FubenInfestorExploreManager.CheckActionPoint(chapterId, nodeId) then + XUiManager.TipText("InfestorExploreActionPointNotEnough") + return + end + + if XDataCenter.FubenInfestorExploreManager.CheckShopExist() then + XLuaUiManager.Open("UiInfestorExploreShop") + else + local callBack = function() + XLuaUiManager.Open("UiInfestorExploreShop") + end + XDataCenter.FubenInfestorExploreManager.RequestShopInfo(nodeId, callBack) + end + + self:Close() +end + +function XUiInfestorExploreStageDetailShop:OnClickBtnGuestbook() + XDataCenter.FubenInfestorExploreManager.OpenGuestBook(self.ChapterId) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreStageDetailSupply.lua b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreStageDetailSupply.lua new file mode 100644 index 00000000..05621004 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreStageDetailSupply.lua @@ -0,0 +1,78 @@ +local MAX_OPTION_NUM = 3 +local EVENT_NAME_STR = CS.XTextManager.GetText("InfestorExploreSupplyNodeName") +local EVENT_DES_STR = CS.XTextManager.GetText("InfestorExploreSupplyNodeDes") + +local XUiInfestorExploreStageDetailSupply = XLuaUiManager.Register(XLuaUi, "UiInfestorExploreStageDetailSupply") + +function XUiInfestorExploreStageDetailSupply:OnAwake() + self:AutoAddListener() +end + +function XUiInfestorExploreStageDetailSupply:OnStart(closeCb) + self.CloseCb = closeCb +end + +function XUiInfestorExploreStageDetailSupply:Refresh(chapterId, nodeId) + self.NodeId = nodeId + self.ChapterId = chapterId + + self.TxtName.text = EVENT_NAME_STR + self.TxtDes.text = EVENT_DES_STR + + local bg = XDataCenter.FubenInfestorExploreManager.GetNodeStageBg(chapterId, nodeId) + self.RImgIcon:SetRawImage(bg) + + local desList = XDataCenter.FubenInfestorExploreManager.GetSupplyNodeDesList(chapterId, nodeId) + for i = 1, MAX_OPTION_NUM do + local btn = self["BtnOption" .. i] + local des = desList[i] + btn:SetNameByGroup(0, des) + btn.gameObject:SetActiveEx(true) + end +end + +function XUiInfestorExploreStageDetailSupply:OnDisable() + self.CloseCb() +end + +function XUiInfestorExploreStageDetailSupply:AutoAddListener() + self.BtnCloseMask.CallBack = function() self:Close() end + self.BtnGuestbook.CallBack = function() self:OnClickBtnGuestbook() end + for index = 1, MAX_OPTION_NUM do + self["BtnOption" .. index].CallBack = function() self:OnSelectOption(index) end + end +end + +function XUiInfestorExploreStageDetailSupply:OnSelectOption(index) + local chapterId = self.ChapterId + local nodeId = self.NodeId + + if XDataCenter.FubenInfestorExploreManager.IsNodePassed(chapterId, nodeId) then + XUiManager.TipText("InfestorExploreSupplyNodePassed") + return + end + + if XDataCenter.FubenInfestorExploreManager.IsNodeUnReach(chapterId, nodeId) then + XUiManager.TipText("InfestorExploreSupplyNodeNotReach") + return + end + + if XDataCenter.FubenInfestorExploreManager.IsNodeCurrentFinished(chapterId, nodeId) then + XUiManager.TipText("InfestorExploreSupplyNodeCurrent") + return + end + + if not XDataCenter.FubenInfestorExploreManager.CheckActionPoint(chapterId, nodeId) then + XUiManager.TipText("InfestorExploreActionPointNotEnough") + return + end + + local callBack = function() + self:Close() + end + XDataCenter.FubenInfestorExploreManager.RequestSupply(chapterId, nodeId, callBack) +end + +function XUiInfestorExploreStageDetailSupply:OnClickBtnGuestbook() + XDataCenter.FubenInfestorExploreManager.OpenGuestBook(self.ChapterId) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreTeamEdit.lua b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreTeamEdit.lua new file mode 100644 index 00000000..536d77ba --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiInfestorExploreTeamEdit.lua @@ -0,0 +1,415 @@ +local CSXTextManagerGetText = CS.XTextManager.GetText +local PlatForm = CS.UnityEngine.Application.platform +local IsWindows = PlatForm == CS.UnityEngine.RuntimePlatform.WindowsEditor or PlatForm == CS.UnityEngine.RuntimePlatform.WindowsPlayer + +local XUiInfestorExploreTeamEdit = XLuaUiManager.Register(XLuaUi, "UiInfestorExploreTeamEdit") + +local CHAR_POS1 = 1 +local CHAR_POS2 = 2 +local CHAR_POS3 = 3 +local MAX_CHAR_COUNT = 3 +local LONG_CLICK_TIME = 0 +local TIMER = 1 +local LOAD_TIME = 10 + +function XUiInfestorExploreTeamEdit:OnAwake() + self:AutoAddListener() + self.RectTransform = self.Transform:GetComponent("RectTransform") + self.PanelTip.gameObject:SetActiveEx(false) + self.ImgRoleRepace.gameObject:SetActiveEx(false) + self.BtnTeamPrefab.gameObject:SetActiveEx(false) + self:InitFirstFightTabBtns() +end + +function XUiInfestorExploreTeamEdit:OnStart(characterLimitType, limitBuffId, characterIds, captainPos, saveCallBack, enterCallBack, forbitReplaceCharacter, firstFightPos) + self.CharacterLimitType = characterLimitType + self.LimitBuffId = limitBuffId + self.ChangeCharIndex = 0 + self.CaptainPos = captainPos or 1 + self.FirstFightPos = firstFightPos or 1 + self.CharacterIds = characterIds + self.SaveCallBack = saveCallBack + self.EnterCallBack = enterCallBack + self.ForbitReplaceCharacter = forbitReplaceCharacter + self.IsShowCharacterInfo = false + self:InitSceneRoot() + self:InitCharacterLimit() +end + +function XUiInfestorExploreTeamEdit:OnEnable() + self:UpdateTeamInfo() + + self:OnClickTabCaptainCallBack(self.CaptainPos) + self.PanelTabCaptain:SelectIndex(self.FirstFightPos) +end + +function XUiInfestorExploreTeamEdit:OnDisable() + self:RemoveTimer() + self.SaveCallBack(self.CharacterIds, self.CaptainPos, self.FirstFightPos) +end + +function XUiInfestorExploreTeamEdit:InitCharacterLimit() + local characterLimitType = self.CharacterLimitType + + if not XFubenConfigs.IsStageCharacterLimitConfigExist(characterLimitType) then + self.PanelRequireCharacter.gameObject:SetActiveEx(false) + return + else + self.PanelRequireCharacter.gameObject:SetActiveEx(true) + end + + local icon = XFubenConfigs.GetStageCharacterLimitImageTeamEdit(characterLimitType) + self.ImgRequireCharacter:SetSprite(icon) +end + +function XUiInfestorExploreTeamEdit:GetCurTeamCharacterType() + for _, characterId in pairs(self.CharacterIds) do + if characterId > 0 then + return XCharacterConfigs.GetCharacterType(characterId) + end + end +end + +function XUiInfestorExploreTeamEdit:RefreshCharacterTypeTips() + local characterLimitType = self.CharacterLimitType + local limitBuffId = self.LimitBuffId + local characterType = self:GetCurTeamCharacterType() + local defaultCharacterType = XDataCenter.FubenManager.GetDefaultCharacterTypeByCharacterLimitType(characterLimitType) + local text = XFubenConfigs.GetStageCharacterLimitTextTeamEdit(characterLimitType, characterType, limitBuffId) + self.TxtRequireCharacter.text = text + + local buffDes = XDataCenter.FubenInfestorExploreManager.GetBuffDes() + if buffDes ~= "" then + self.TxtEffectPosition.text = buffDes + self.PanelBuffDes.gameObject:SetActiveEx(true) + else + self.PanelBuffDes.gameObject:SetActiveEx(false) + end +end + +function XUiInfestorExploreTeamEdit:InitFirstFightTabBtns() + local tabGroup = { + self.BtnRed, + self.BtnBlue, + self.BtnYellow, + } + self.PanelTabCaptain:Init(tabGroup, function(tabIndex) self:OnFirstFightTabClick(tabIndex) end) +end + +function XUiInfestorExploreTeamEdit:InitSceneRoot() + local sceneRoot = self.UiSceneInfo.Transform + self.PanelRoleEffect = { + [CHAR_POS1] = sceneRoot.transform:FindTransform("PanelRoleEffect1"), + [CHAR_POS2] = sceneRoot.transform:FindTransform("PanelRoleEffect2"), + [CHAR_POS3] = sceneRoot.transform:FindTransform("PanelRoleEffect3"), + } + self.RoleModelPanel = { + [CHAR_POS1] = XUiPanelRoleModel.New(sceneRoot.transform:FindTransform("PanelRoleModel1"), self.Name, nil, true, nil, true, true), + [CHAR_POS2] = XUiPanelRoleModel.New(sceneRoot.transform:FindTransform("PanelRoleModel2"), self.Name, nil, true, nil, true, true), + [CHAR_POS3] = XUiPanelRoleModel.New(sceneRoot.transform:FindTransform("PanelRoleModel3"), self.Name, nil, true, nil, true, true), + } +end + +-- 设置首次出场 +function XUiInfestorExploreTeamEdit:OnFirstFightTabClick(tabIndex) + self.FirstFightPos = tabIndex + for i = 1, MAX_CHAR_COUNT do + self["PanelFirstRole" .. i].gameObject:SetActiveEx(i == tabIndex) + end +end + +-- 设置队长技能 +function XUiInfestorExploreTeamEdit:OnClickTabCaptainCallBack(tabIndex) + local captainPos = tabIndex + + -- 隐藏全部队长标签 + for i = 1, MAX_CHAR_COUNT do + self["PanelLeader" .. i].gameObject:SetActiveEx(false) + end + + self:UpdateCaptainSkill(captainPos) +end + +function XUiInfestorExploreTeamEdit:UpdateTeamInfo() + self.LoadModelCount = 0 + local characterIds = self.CharacterIds + for i = 1, MAX_CHAR_COUNT do + local characterId = characterIds[i] + + if characterId > 0 then + self.LoadModelCount = self.LoadModelCount + 1 + end + + self["Timer" .. i] = XScheduleManager.ScheduleOnce(function() + if XTool.UObjIsNil(self.Transform) or not self.GameObject.activeSelf then + return + end + + if characterId > 0 then + self:UpdateRoleModel(characterId, self.RoleModelPanel[i], i) + self["ImgAdd" .. i].gameObject:SetActiveEx(false) + self:UpdateRoleStanmina(characterId, i) + else + self.RoleModelPanel[i]:HideRoleModel() + self["PanelStaminaBar" .. i].gameObject:SetActiveEx(false) + self["ImgAdd" .. i].gameObject:SetActiveEx(true) + end + end, i * LOAD_TIME) + end + self.BtnEnterFight.gameObject:SetActiveEx(false) + + self:UpdateCharacterInfo() + self:UpdateCaptainSkill(self.CaptainPos) + self:RefreshCharacterTypeTips() +end + +--更新模型 +function XUiInfestorExploreTeamEdit:UpdateRoleModel(characterId, roleModelPanel, pos) + roleModelPanel:ShowRoleModel() -- 先Active 再加载模型以及播放动画 + local callback = function(model) + self.LoadModelCount = self.LoadModelCount - 1 + if self.LoadModelCount <= 0 then + self.BtnEnterFight.gameObject:SetActiveEx(true) + end + end + roleModelPanel:UpdateCharacterModel(characterId, nil, nil, nil, callback) +end + +function XUiInfestorExploreTeamEdit:UpdateRoleStanmina(characterId, index) + local hpPercent = XDataCenter.FubenInfestorExploreManager.GetCharacterHpPrecent(characterId) + self["TxtMyStamina" .. index].text = CSXTextManagerGetText("InfestorExploreCharacterHpPercent", hpPercent) + self["ImgStaminaExpFill" .. index].fillAmount = hpPercent * 0.01 + self["PanelStaminaBar" .. index].gameObject:SetActiveEx(true) +end + +function XUiInfestorExploreTeamEdit:UpdateCaptainSkill(captainPos) + if not captainPos then return end + self.CaptainPos = captainPos + + -- 开启技能面板、队长头像、技能描述 + self.PanelSkill.gameObject:SetActiveEx(true) + self.PanelRole.gameObject:SetActiveEx(true) + self.TxtSkillDesc.gameObject:SetActiveEx(true) + + local teamMemberNum = self:GetCurTeamMemberNum() + local captainId = self.CharacterIds[self.CaptainPos] + + -- 队长位没有角色 + if captainId <= 0 then + if teamMemberNum <= 0 then + -- 队伍内没有角色,隐藏技能面板 + self.PanelSkill.gameObject:SetActiveEx(false) + else + -- 队伍内还有其他角色,隐藏队长头像与技能描述 + self.PanelRole.gameObject:SetActiveEx(false) + self.TxtSkillDesc.gameObject:SetActiveEx(false) + + -- 队长技能名称更改为未选择队长 + self.TxtSkillName.text = CS.XTextManager.GetText("TeamDoNotChooseCaptain") + end + return + end + + local captianSkillInfo = XDataCenter.CharacterManager.GetCaptainSkillInfo(captainId) + self.RImgCapIcon:SetRawImage(XDataCenter.CharacterManager.GetCharSmallHeadIcon(captainId)) + self:SetUiSprite(self.ImgSkillIcon, captianSkillInfo.Icon) + self.TxtSkillName.text = captianSkillInfo.Name + self.TxtSkillDesc.text = captianSkillInfo.Level > 0 and captianSkillInfo.Intro or CS.XTextManager.GetText("CaptainSkillLock") +end + +--更新战斗信息 +function XUiInfestorExploreTeamEdit:UpdateCharacterInfo() + if self.IsShowCharacterInfo then + self.BtnShowInfoToggle:SetButtonState(XUiButtonState.Select) + for i = 1, #self.CharacterIds do + local character = XDataCenter.CharacterManager.GetCharacter(self.CharacterIds[i]) + if character == nil then + self["CharacterInfo" .. i].gameObject:SetActiveEx(false) + else + self["CharacterInfo" .. i].gameObject:SetActiveEx(true) + self["TxtFight" .. i].text = math.floor(character.Ability) + self["RImgType" .. i]:SetRawImage(XCharacterConfigs.GetNpcTypeIcon(character.Type)) + end + end + else + self.BtnShowInfoToggle:SetButtonState(XUiButtonState.Normal) + for i = 1, MAX_CHAR_COUNT do + self["CharacterInfo" .. i].gameObject:SetActiveEx(false) + end + end +end + +function XUiInfestorExploreTeamEdit:RemoveTimer() + for i = 1, MAX_CHAR_COUNT do + if self["Timer" .. i] then + XScheduleManager.UnSchedule(self["Timer" .. i]) + self["Timer" .. i] = nil + end + end +end + +function XUiInfestorExploreTeamEdit:AutoAddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:RegisterClickEvent(self.BtnEnterFight, self.OnBtnEnterFightClick) + self.BtnShowInfoToggle.CallBack = function(val) self:OnBtnShowInfoToggle(val) end + self.BtnGo.CallBack = function() self:OnPanelBtnLeaderClick() end + for i = 1, MAX_CHAR_COUNT do + local btnChar = self["BtnChar" .. i] + btnChar.CallBack = function() self:OnBtnCharClick(i) end + + local btnLongClick = btnChar:GetComponent("XUiPointer") + local longClickCallback = function(_, time) self:OnBtnUnLockLongClick(i, time) end + XUiButtonLongClick.New(btnLongClick, 10, self, nil, longClickCallback, self.OnBtnUnLockLongUp, false) + end +end + +function XUiInfestorExploreTeamEdit:OnPanelBtnLeaderClick() + XLuaUiManager.Open("UiNewRoomSingleTip", self, self.CharacterIds, self.CaptainPos, function(index) + self:OnClickTabCaptainCallBack(index) + end) +end + +function XUiInfestorExploreTeamEdit:OnBtnShowInfoToggle(val) + self.IsShowCharacterInfo = val ~= 0 and true or false + self:UpdateCharacterInfo() +end + +function XUiInfestorExploreTeamEdit:OnBtnUnLockLongUp() + self.ImgRoleRepace.gameObject:SetActiveEx(false) + self.IsUp = not self.IsUp + LONG_CLICK_TIME = 0 + + if self.ChangeCharIndex > 0 then + local targetX = math.floor(self:GetPisont().x + self.RectTransform.rect.width / 2) + local targetIndex = 0 + if targetX <= self.RectTransform.rect.width / 3 then + targetIndex = CHAR_POS2 + elseif targetX > self.RectTransform.rect.width / 3 and targetX <= self.RectTransform.rect.width / 3 * 2 then + targetIndex = CHAR_POS1 + else + targetIndex = CHAR_POS3 + end + + if targetIndex > 0 and targetIndex ~= self.ChangeCharIndex then + local teamData = XTool.Clone(self.CharacterIds) + local targetId = teamData[targetIndex] + teamData[targetIndex] = teamData[self.ChangeCharIndex] + teamData[self.ChangeCharIndex] = targetId + self:UpdateTeam(teamData) + end + self.ChangeCharIndex = 0 + end +end + +function XUiInfestorExploreTeamEdit:OnBtnUnLockLongClick(index, time) + if self.CharacterIds[index] <= 0 then + self.IsUp = true + return + end + + LONG_CLICK_TIME = LONG_CLICK_TIME + time / 1000 + if self.IsUp then + self.IsUp = false + return + end + if LONG_CLICK_TIME > TIMER and not self.IsUp then + self.IsUp = false + self.ImgRoleRepace.gameObject:SetActiveEx(true) + self.ImgRoleRepace.gameObject.transform.localPosition = self:GetPisont() + end + if self.ChangeCharIndex <= 0 then + self.ChangeCharIndex = index + end +end + +function XUiInfestorExploreTeamEdit:GetPisont() + local screenPoint + if IsWindows then + screenPoint = CS.UnityEngine.Vector2(CS.UnityEngine.Input.mousePosition.x, CS.UnityEngine.Input.mousePosition.y) + else + screenPoint = CS.UnityEngine.Input.GetTouch(0).position + end + + -- 设置拖拽 + local hasValue, v2 = CS.UnityEngine.RectTransformUtility.ScreenPointToLocalPointInRectangle(self.RectTransform, screenPoint, CS.XUiManager.Instance.UiCamera) + if hasValue then + return CS.UnityEngine.Vector3(v2.x, v2.y, 0) + else + return CS.UnityEngine.Vector3.zero + end +end + +function XUiInfestorExploreTeamEdit:OnBtnBackClick() + if self:IsCaptainEmpty() or self:IsFirstFightEmpty() then return end + self:Close() +end + +function XUiInfestorExploreTeamEdit:OnBtnMainUiClick() + if self:IsCaptainEmpty() or self:IsFirstFightEmpty() then return end + XLuaUiManager.RunMain() +end + +function XUiInfestorExploreTeamEdit:OnBtnCharClick(index) + if self.ForbitReplaceCharacter then + XUiManager.TipText("InfestorExploreTeamForbitReplaceCharacter") + return + end + + local teamData = XTool.Clone(self.CharacterIds) + XLuaUiManager.Open("UiRoomCharacter", teamData, index, function(resTeam) + self:UpdateTeam(resTeam) + end, XDataCenter.FubenManager.StageType.InfestorExplore, self.CharacterLimitType, { LimitBuffId = self.LimitBuffId }) +end + +-- 更新队伍 +function XUiInfestorExploreTeamEdit:UpdateTeam(teamData) + self.CharacterIds = XTool.Clone(teamData) + self:UpdateTeamInfo() +end + +function XUiInfestorExploreTeamEdit:GetCurTeamMemberNum() + local count = 0 + for _, id in pairs(self.CharacterIds) do + if id > 0 then + count = count + 1 + end + end + return count +end + +function XUiInfestorExploreTeamEdit:OnBtnEnterFightClick() + if self:IsCaptainEmpty() or self:IsFirstFightEmpty() then return end + + self:Close() + if self.EnterCallBack then self.EnterCallBack() end +end + +function XUiInfestorExploreTeamEdit:PlayTips(key, isOn) + local msg = CSXTextManagerGetText(key) + self.TxtTips1.text = isOn and msg or "" + self.TxtTips2.text = isOn and "" or msg + self.PanelTip.gameObject:SetActiveEx(true) + + self:PlayAnimation("PanelTipEnable", handler(self, function() + self.PanelTip.gameObject:SetActiveEx(false) + end)) +end + +function XUiInfestorExploreTeamEdit:IsCaptainEmpty() + local captainId = self.CharacterIds[self.CaptainPos] + if captainId <= 0 then + XUiManager.TipText("TeamManagerCheckCaptainNil") + return true + end + return false +end + +function XUiInfestorExploreTeamEdit:IsFirstFightEmpty() + local firstFightId = self.CharacterIds[self.FirstFightPos] + if firstFightId <= 0 then + XUiManager.TipText("TeamManagerCheckFirstFightNil") + return true + end + return false +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiPanelFubenInfestorExploreStages.lua b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiPanelFubenInfestorExploreStages.lua new file mode 100644 index 00000000..66fb505f --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiPanelFubenInfestorExploreStages.lua @@ -0,0 +1,134 @@ +local XUiGridFubenInfestorExploreStage = require("XUi/XUiFubenInfestorExplore/XUiGridFubenInfestorExploreStage") +local XUiGridFubenInfestorExploreOccupiedPlayer = require("XUi/XUiFubenInfestorExplore/XUiGridFubenInfestorExploreOccupiedPlayer") +local OccupiedPlayerPreafabPath = CS.XGame.ClientConfig:GetString("GridFubenInfestorExploreOccupiedPlayerPreafab") + +local ipairs = ipairs +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate +local TWEE_DURATION = 0.2 + +local XUiPanelFubenInfestorExploreStages = XClass(nil, "XUiPanelFubenInfestorExploreStages") + +function XUiPanelFubenInfestorExploreStages:Ctor(ui, rootUi, chapterId, clickStageCb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.ChapterId = chapterId + self.ClickStageCb = clickStageCb + self.RootUi = rootUi + + XTool.InitUiObject(self) + self.ScrollRect = self.Transform:Find("PaneStageList"):GetComponent("ScrollRect") + self.MarkX = self.Transform:Find("PaneStageList/ViewPort"):GetComponent("RectTransform").rect.width * 0.3 + self.InitPosX = self.PanelStageContent.localPosition.x + + self:InitStagesMap() +end + +function XUiPanelFubenInfestorExploreStages:InitStagesMap() + local chapterId = self.ChapterId + + local bg = XFubenInfestorExploreConfigs.GetChapterBg(chapterId) + self.RImgChapterBg:SetRawImage(bg) + + self.LastSelectGrid = nil + local clickCb = function(grid, paramNodeId) + if self.LastSelectGrid then + self.LastSelectGrid:SetSelect(false) + end + grid:SetSelect(true) + self.LastSelectGrid = grid + + --当打开了详情界面时才进行滑动定位 + if not XDataCenter.FubenInfestorExploreManager.IsNodeStart(chapterId, paramNodeId) + and not XDataCenter.FubenInfestorExploreManager.IsNodeCurrentShop(chapterId, paramNodeId) then + self:PlayScrollViewMove(grid) + end + + self.ClickStageCb(chapterId, paramNodeId, grid) + end + self.GridStages = {} + local mapNodeIds = XDataCenter.FubenInfestorExploreManager.GetMapNodeIds(chapterId) + for nodeId in ipairs(mapNodeIds) do + self.GridStages[nodeId] = XUiGridFubenInfestorExploreStage.New(self.RootUi, chapterId, nodeId, clickCb) + end + + self.GridPlayers = {} +end + +function XUiPanelFubenInfestorExploreStages:UpdateStagesMap() + for _, grid in pairs(self.GridPlayers) do + grid.GameObject:SetActiveEx(false) + end + + local chapterId = self.ChapterId + for nodeId, grid in pairs(self.GridStages) do + local stageParent = self["Stage" .. nodeId] + if XTool.UObjIsNil(stageParent) then + local mapId = XFubenInfestorExploreConfigs.GetMapId(chapterId) + local parentPrefabPath = XFubenInfestorExploreConfigs.GetChapterPrefabPath(chapterId) + XLog.Error("XUiPanelFubenInfestorExploreStages:InitStagesMap Error:感染体玩法地图配置节点数量与UI不一致, 地图Id: " .. mapId .. ", UI路径: " .. parentPrefabPath) + return + end + + local prefabPath = XDataCenter.FubenInfestorExploreManager.GetNodePrefabPath(chapterId, nodeId) + local go = stageParent:LoadPrefab(prefabPath) + grid:Refresh(go) + + --刷新小队成员所在位置 + local playerId = XDataCenter.FubenInfestorExploreManager.GetNodeShowOccupiedPlayerId(chapterId, nodeId) + if playerId > 0 then + --在起点或终点的非自己小队成员头像不显示 + -- if not (playerId ~= XPlayer.Id and (XDataCenter.FubenInfestorExploreManager.IsNodeStart(chapterId, nodeId) + -- or XDataCenter.FubenInfestorExploreManager.IsNodeEnd(chapterId, nodeId)) + -- ) then + local palyerGrid = self.GridPlayers[playerId] + if not palyerGrid then + local go = self:CreatePlayerGo() + palyerGrid = XUiGridFubenInfestorExploreOccupiedPlayer.New(go, playerId) + self.GridPlayers[playerId] = palyerGrid + end + + palyerGrid.Transform:SetParent(stageParent, false) + palyerGrid.GameObject:SetActiveEx(true) + --end + end + + if playerId == XPlayer.Id then + self:PlayScrollViewMove(grid, true) + end + end +end + +function XUiPanelFubenInfestorExploreStages:CreatePlayerGo(parent) + local go = self.PlayerGo + if not go then + go = self.PanelStageContent:LoadPrefab(OccupiedPlayerPreafabPath) + self.PlayerGo = go + else + go = CSUnityEngineObjectInstantiate(self.PlayerGo) + end + return go +end + +function XUiPanelFubenInfestorExploreStages:PlayScrollViewMove(grid, ignoreAnim) + local gridX = grid.Transform.parent:GetComponent("RectTransform").localPosition.x + local contentPos = self.PanelStageContent.localPosition + local markX = self.MarkX + local diffX = gridX - markX + if diffX ~= 0 then + local targetPosX = self.InitPosX - diffX + local tarPos = contentPos + tarPos.x = targetPosX + + if not ignoreAnim then + XLuaUiManager.SetMask(true) + self.ScrollRect.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Unrestricted + XUiHelper.DoMove(self.PanelStageContent, tarPos, TWEE_DURATION, XUiHelper.EaseType.Sin, function() + XLuaUiManager.SetMask(false) + end) + else + self.PanelStageContent.localPosition = tarPos + end + end +end + +return XUiPanelFubenInfestorExploreStages \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiPanelInfestorExploreBossRank.lua b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiPanelInfestorExploreBossRank.lua new file mode 100644 index 00000000..aa766b63 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenInfestorExplore/XUiPanelInfestorExploreBossRank.lua @@ -0,0 +1,120 @@ +local XUiGridInfestorExploreRank = require("XUi/XUiFubenInfestorExplore/XUiGridInfestorExploreRank") +local XUiGridInfestorExploreRegionTitle = require("XUi/XUiFubenInfestorExplore/XUiGridInfestorExploreRegionTitle") + +local tableInsert = table.insert +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate + +local XUiPanelInfestorExploreBossRank = XClass(nil, "XUiPanelInfestorExploreBossRank") + +function XUiPanelInfestorExploreBossRank:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RankGrids = {} + XTool.InitUiObject(self) + self.GridRegionTitle.gameObject:SetActiveEx(false) + self.GridArenaTeamRank.gameObject:SetActiveEx(false) +end + +function XUiPanelInfestorExploreBossRank:Refresh(rewardId, chapterId, nodeId) + local upList = {} + local keepList = {} + local downList = {} + + local upNum = XDataCenter.FubenInfestorExploreManager.GetDiffUpNum() + local keepNum = XDataCenter.FubenInfestorExploreManager.GetDiffKeepNum() + local downNum = XDataCenter.FubenInfestorExploreManager.GetDiffDownNum() + local upIndex = upNum + local keepIndex = upNum + keepNum + local rankIndexList = XDataCenter.FubenInfestorExploreManager.GetPlayerRankIndexList() + for _, index in ipairs(rankIndexList) do + local player = XDataCenter.FubenInfestorExploreManager.GetPlayerRankData(index) + if player:GetScore() == 0 then + if downNum > 0 then + tableInsert(downList, index) + else + tableInsert(keepList, index) + end + else + if index <= upIndex then + tableInsert(upList, index) + elseif index <= keepIndex then + tableInsert(keepList, index) + else + tableInsert(downList, index) + end + end + end + + local gridIndex = 0 + + --晋级区 + local region = XFubenInfestorExploreConfigs.Region.UpRegion + self.UpGrid = self.UpGrid or XUiGridInfestorExploreRegionTitle.New(CSUnityEngineObjectInstantiate(self.GridRegionTitle, self.PanelContent)) + if upNum == 0 then + self.UpGrid.GameObject:SetActiveEx(false) + else + local rewardId = XDataCenter.FubenInfestorExploreManager.GetCurGroupRankRegionRewardList(_, region) + self.UpGrid:Refresh(region, rewardId) + self.UpGrid.GameObject:SetActiveEx(true) + self.UpGrid.Transform:SetAsLastSibling() + for _, rankIndex in ipairs(upList) do + gridIndex = gridIndex + 1 + local rankGrid = self.RankGrids[gridIndex] + if not rankGrid then + rankGrid = XUiGridInfestorExploreRank.New(CSUnityEngineObjectInstantiate(self.GridArenaTeamRank, self.PanelContent)) + self.RankGrids[gridIndex] = rankGrid + end + rankGrid:Refresh(rankIndex) + rankGrid.GameObject:SetActiveEx(true) + rankGrid.Transform:SetAsLastSibling() + end + end + + --保级区 + local region = XFubenInfestorExploreConfigs.Region.KeepRegion + local rewardId = XDataCenter.FubenInfestorExploreManager.GetCurGroupRankRegionRewardList(_, region) + self.KeepGrid = self.KeepGrid or XUiGridInfestorExploreRegionTitle.New(CSUnityEngineObjectInstantiate(self.GridRegionTitle, self.PanelContent)) + self.KeepGrid:Refresh(region, rewardId) + self.KeepGrid.GameObject:SetActiveEx(true) + self.KeepGrid.Transform:SetAsLastSibling() + for _, rankIndex in ipairs(keepList) do + gridIndex = gridIndex + 1 + local rankGrid = self.RankGrids[gridIndex] + if not rankGrid then + rankGrid = XUiGridInfestorExploreRank.New(CSUnityEngineObjectInstantiate(self.GridArenaTeamRank, self.PanelContent)) + self.RankGrids[gridIndex] = rankGrid + end + rankGrid:Refresh(rankIndex) + rankGrid.GameObject:SetActiveEx(true) + rankGrid.Transform:SetAsLastSibling() + end + + --降级区 + local region = XFubenInfestorExploreConfigs.Region.DownRegion + self.DownGrid = self.DownGrid or XUiGridInfestorExploreRegionTitle.New(CSUnityEngineObjectInstantiate(self.GridRegionTitle, self.PanelContent)) + if downNum == 0 then + self.DownGrid.GameObject:SetActiveEx(false) + else + local rewardId = XDataCenter.FubenInfestorExploreManager.GetCurGroupRankRegionRewardList(_, region) + self.DownGrid.GameObject:SetActiveEx(true) + self.DownGrid:Refresh(region, rewardId) + self.DownGrid.Transform:SetAsLastSibling() + for _, rankIndex in ipairs(downList) do + gridIndex = gridIndex + 1 + local rankGrid = self.RankGrids[gridIndex] + if not rankGrid then + rankGrid = XUiGridInfestorExploreRank.New(CSUnityEngineObjectInstantiate(self.GridArenaTeamRank, self.PanelContent)) + self.RankGrids[gridIndex] = rankGrid + end + rankGrid:Refresh(rankIndex) + rankGrid.GameObject:SetActiveEx(true) + rankGrid.Transform:SetAsLastSibling() + end + end + + for index = gridIndex + 1, #self.RankGrids do + self.RankGrids.GameObject:SetActiveEx(false) + end +end + +return XUiPanelInfestorExploreBossRank \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenMainLineBanner/XUiFubenMainLineBanner.lua b/Resources/Scripts/XUi/XUiFubenMainLineBanner/XUiFubenMainLineBanner.lua new file mode 100644 index 00000000..c7de62dd --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenMainLineBanner/XUiFubenMainLineBanner.lua @@ -0,0 +1,499 @@ +local XUiPanelChapterBfrt = require("XUi/XUiFubenMainLineBanner/XUiPanelChapterBfrt") +local XUiPanelChapterExtra = require("XUi/XUiFubenMainLineBanner/XUiPanelChapterExtra") +local XUiFubenMainLineBanner = XLuaUiManager.Register(XLuaUi, "UiFubenMainLineBanner") + +local CSGameConfig = CS.XGame.ClientConfig + +local TAB_BTN_INDEX = { + MAINLINE = 1, + DZ = 2, + BFRT = 3, + EXTRA = 4, +} + +--grid里的itme定位X坐标偏移量 +local GRID_ITEM_OFFSET_X = 1.7 + + +function XUiFubenMainLineBanner:OnAwake() + self:InitAutoScript() + self.DynamicTable = XDynamicTableNormal.New(self.PanelChapterList) + self.DynamicTable:SetProxy(XUiGridMainLineBanner) + self.DynamicTable:SetDelegate(self) + self.GridMainLineBanner.gameObject:SetActiveEx(false) + self.ChapterDz = XUiPanelChapterDz.New(self.PanelChapterDz, self) + self.ChapterBfrt = XUiPanelChapterBfrt.New(self.PanelChapterBfrt, self.ParentUi) + self.ChapterExtra = XUiPanelChapterExtra.New(self.PanelChapterEX, self.ParentUi, self) + self.IsShowDifficultPanel = false + XEventManager.AddEventListener(XEventId.EVENT_NOTICE_SELECTCOVER_CHANGE, self.OnCoverChapterChanged, self) + self:InitTabBtnGroup() + + --副本类型:普通,隐藏 + self.TYPE = { + NORMAL = XDataCenter.FubenManager.DifficultNormal, + HARD = XDataCenter.FubenManager.DifficultHard, + } +end + +function XUiFubenMainLineBanner:OnDestroy() + XEventManager.RemoveEventListener(XEventId.EVENT_NOTICE_SELECTCOVER_CHANGE, self.OnCoverChapterChanged) +end + +function XUiFubenMainLineBanner:OnEnable() + self.CurDiff = XDataCenter.FubenMainLineManager.GetCurDifficult() + self.CurExtraDifficult = XDataCenter.ExtraChapterManager.GetCurDiffcult() + self:SetPlayerPrefsPosX() + self:Refresh(false) + self:PlayAnimation("QIEHuan") +end + +function XUiFubenMainLineBanner:OnStart(defaultTab) + self.PanelTab:SelectIndex(defaultTab or TAB_BTN_INDEX.MAINLINE) +end + +function XUiFubenMainLineBanner:Refresh(playAnimation) + if self.CurrentSelect == TAB_BTN_INDEX.MAINLINE then + self:RefreshMainLine(playAnimation) + elseif self.CurrentSelect == TAB_BTN_INDEX.DZ then + self:RefreshPrequel(playAnimation) + elseif self.CurrentSelect == TAB_BTN_INDEX.BFRT then + self:RefreshBfrt(playAnimation) + elseif self.CurrentSelect == TAB_BTN_INDEX.EXTRA then + self:RefreshExtra(playAnimation) + end + + -- 难度toggle + self:UpdateDifficultToggles() +end + +function XUiFubenMainLineBanner:OnCoverChapterChanged() + -- if self.ChapterDz then + -- self.ChapterDz:OnCoverChanged(chooseInfo) + -- end +end + +--动态列表事件 +function XUiFubenMainLineBanner:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:UpdateChapterGrid(self.PageDatas[index], self.CurDiff) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + self:ClickChapterGrid(self.PageDatas[index], index) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_RELOAD_COMPLETED then + if not XDataCenter.GuideManager.CheckIsInGuide() then + self:AutoScroll() + end + end +end + +--设置动态列表 +function XUiFubenMainLineBanner:SetupDynamicTable(index) + if not self.CurDiff then return end + self.PageDatas = XDataCenter.FubenMainLineManager.GetChapterMainTemplates(self.CurDiff) + + -- 远程配置屏蔽,只保留第一关 + if XUiManager.IsHideFunc then + local temp = self.PageDatas[1] + self.PageDatas = {} + self.PageDatas[1] = temp + end + + self.DynamicTable:SetDataSource(self.PageDatas) + self.DynamicTable:ReloadDataSync(index) +end + +--@region 动态列表自动跳转 +function XUiFubenMainLineBanner:SetPlayerPrefsPosX() + self.PlayerPrefsPosX = {} + + for _, type in pairs(self.TYPE) do + local keyX = self:GetPlayerPrefsKey(type) + if CS.UnityEngine.PlayerPrefs.HasKey(keyX) then + self.PlayerPrefsPosX[type] = CS.UnityEngine.PlayerPrefs.GetFloat(keyX) + end + end +end + +--优先选择上一次操作的界面,否则选择最新的章节 +function XUiFubenMainLineBanner:AutoScroll() + local rt = self.PanelChapterContent:GetComponent("RectTransform") + local posX = self.PlayerPrefsPosX[self.CurDiff] + + if not posX then + posX = self:GetTheLatestChapterPosX() + end + + rt:DOAnchorPosX(posX, 0.5) +end + +function XUiFubenMainLineBanner:GetTheLatestChapterPosX() + if self.PageDatas then + local index = 0 + for i, pageDatas in ipairs(self.PageDatas) do + local chapterInfo = XDataCenter.FubenMainLineManager.GetChapterInfoByChapterMain(pageDatas.Id, self.CurDiff) + if chapterInfo.Unlock then + index = i + end + end + + return self:GetChapterPosXByIndex_X(index) + else + return 0 + end +end + +--获取grid里对应item的坐标X轴 +function XUiFubenMainLineBanner:GetChapterPosXByIndex_X(index) + if index >= 2 then + --使其贴近最右侧显示 + index = index - GRID_ITEM_OFFSET_X + else + index = 0 + end + + local dynamicTableNormal = self.PanelChapterList.gameObject:GetComponent(typeof(CS.XDynamicTableNormal)) + return -1 * (dynamicTableNormal.GridSize.x + dynamicTableNormal.Spacing.x) * index +end + +function XUiFubenMainLineBanner:SaveScrollPos(index) + local keyX = self:GetPlayerPrefsKey(self.CurDiff) + CS.UnityEngine.PlayerPrefs.SetFloat(keyX, self:GetChapterPosXByIndex_X(index)) +end + +function XUiFubenMainLineBanner:GetPlayerPrefsKey(curDiff) + --CurDiff:普通副本或隐藏副本 + return string.format("%s-%s-%s", "DynamicTable_MainLineChapterPosX", tostring(XPlayer.Id), curDiff) +end + +--@endregion +-- auto +-- Automatic generation of code, forbid to edit +function XUiFubenMainLineBanner:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiFubenMainLineBanner:AutoInitUi() + self.PanelChapterList = self.Transform:Find("FullScreenBackground/MainLineChapter3d/PanelChapterList") + self.PanelChapterContent = self.Transform:Find("FullScreenBackground/MainLineChapter3d/PanelChapterList/Viewport/PanelChapterContent") + self.GridMainLineBanner = self.Transform:Find("FullScreenBackground/MainLineChapter3d/PanelChapterList/Viewport/GridMainLineBanner") + self.PanelChapterDz = self.Transform:Find("FullScreenBackground/MainLineChapter3d/PanelChapterDz") + self.BtnCloseDifficult = self.Transform:Find("FullScreenBackground/MainLineChapter3d/BtnCloseDifficult"):GetComponent("Button") + self.PanelTopDifficult = self.Transform:Find("FullScreenBackground/MainLineChapter3d/PanelTopDifficult") + self.BtnNormal = self.Transform:Find("FullScreenBackground/MainLineChapter3d/PanelTopDifficult/BtnNormal"):GetComponent("Button") + self.PanelNormalOn = self.Transform:Find("FullScreenBackground/MainLineChapter3d/PanelTopDifficult/BtnNormal/PanelNormalOn") + self.PanelNormalOff = self.Transform:Find("FullScreenBackground/MainLineChapter3d/PanelTopDifficult/BtnNormal/PanelNormalOff") + self.BtnHard = self.Transform:Find("FullScreenBackground/MainLineChapter3d/PanelTopDifficult/BtnHard"):GetComponent("Button") + self.PanelHardOn = self.Transform:Find("FullScreenBackground/MainLineChapter3d/PanelTopDifficult/BtnHard/PanelHardOn") + self.PanelHardOff = self.Transform:Find("FullScreenBackground/MainLineChapter3d/PanelTopDifficult/BtnHard/PanelHardOff") +end + +function XUiFubenMainLineBanner:AutoAddListener() + self:RegisterClickEvent(self.BtnCloseDifficult, self.OnBtnCloseDifficultClick) + self:RegisterClickEvent(self.BtnNormal, self.OnBtnNormalClick) + self:RegisterClickEvent(self.BtnHard, self.OnBtnHardClick) + self.BtnHelp.CallBack = function() + self:OnBtnHelpClick() + end +end +-- auto +function XUiFubenMainLineBanner:InitTabBtnGroup() + local tabGroup = { + self.BtnTabZX, + self.BtnTabDZ, + self.BtnTabJD, + self.BtnTabFW, + } + self.BtnTabDZ:SetDisable(not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.Prequel)) + self.BtnTabJD:SetDisable(not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.FubenNightmare)) + self.BtnTabFW:SetDisable(not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.Extra)) + self.PanelTab:Init(tabGroup, function(tabIndex) self:OnClickTabCallBack(tabIndex) end) + + -- 功能屏蔽 + self.BtnTabDZ.gameObject:SetActiveEx(not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.Prequel)) + if XUiManager.IsHideFunc then + self:HideFunc() + end +end + +--- +--- 隐藏外篇、间章、据点按钮 +function XUiFubenMainLineBanner:HideFunc() + self.BtnTabFW.gameObject:SetActiveEx(false) + self.BtnTabDZ.gameObject:SetActiveEx(false) + self.BtnTabJD.gameObject:SetActiveEx(false) +end + +function XUiFubenMainLineBanner:OnClickTabCallBack(tabIndex) + if self.CurrentSelect and self.CurrentSelect == tabIndex then + return + end + + if tabIndex == TAB_BTN_INDEX.MAINLINE then + self:RefreshMainLine(true) + elseif tabIndex == TAB_BTN_INDEX.DZ then + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.Prequel) then + return + end + self:RefreshPrequel(true) + elseif tabIndex == TAB_BTN_INDEX.BFRT then + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.FubenNightmare) then + return + end + self:RefreshBfrt(true) + elseif tabIndex == TAB_BTN_INDEX.EXTRA then + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.Extra) then + return + end + self:RefreshExtra(true) + end + self.CurrentSelect = tabIndex +end + +-- 断章 +function XUiFubenMainLineBanner:RefreshPrequel(playAnimation) + self.PanelTopDifficult.gameObject:SetActiveEx(false) + self.PanelChapterList.gameObject:SetActiveEx(false) + self.PanelChapterBfrt.gameObject:SetActiveEx(false) + self.PanelChapterEX.gameObject:SetActiveEx(false) + self.PanelChapterDz.gameObject:SetActiveEx(true) + self.BtnHelp.gameObject:SetActive(false) + self.ChapterDz:SetupCoverDatas(self.DefaultCoverId, self.DefaultChapterId) + if playAnimation and (not self.DefaultCoverId) then + self:PlayAnimation("DzQieHuanEnable") + end + self.DefaultCoverId = nil + self.DefaultChapterId = nil +end + +function XUiFubenMainLineBanner:RefreshBfrt() + self.PanelTopDifficult.gameObject:SetActiveEx(false) + self.PanelChapterList.gameObject:SetActiveEx(false) + self.PanelChapterDz.gameObject:SetActiveEx(false) + self.PanelChapterBfrt.gameObject:SetActiveEx(true) + self.PanelChapterEX.gameObject:SetActiveEx(false) + self.BtnHelp.gameObject:SetActive(true) + self.ChapterBfrt:SetupBfrtChapters() +end + +function XUiFubenMainLineBanner:RefreshMainLine(playAnimation) + self:UpdateMainLineDifficultToggles() + if XUiManager.IsHideFunc then + self.PanelTopDifficult.gameObject:SetActiveEx(false) + else + self.PanelTopDifficult.gameObject:SetActiveEx(true) + end + self.PanelChapterList.gameObject:SetActiveEx(true) + self.PanelChapterBfrt.gameObject:SetActiveEx(false) + self.PanelChapterDz.gameObject:SetActiveEx(false) + self.PanelChapterEX.gameObject:SetActiveEx(false) + self.BtnHelp.gameObject:SetActive(false) + self:SetupDynamicTable() + if playAnimation then + self:PlayAnimation("ListQieHuanEnable") + end +end + +function XUiFubenMainLineBanner:RefreshExtra(playAnimation) + self:UpdateExtraDifficultToggles() + self.PanelChapterDz.gameObject:SetActiveEx(false) + if XUiManager.IsHideFunc then + self.PanelTopDifficult.gameObject:SetActiveEx(false) + else + self.PanelTopDifficult.gameObject:SetActiveEx(true) + end + self.PanelChapterList.gameObject:SetActiveEx(false) + self.PanelChapterBfrt.gameObject:SetActiveEx(false) + self.PanelChapterEX.gameObject:SetActiveEx(true) + self.BtnHelp.gameObject:SetActive(false) + self.ChapterExtra:UpdateCoverData(self.CurExtraDifficult) + if playAnimation then + self:PlayAnimation("EXQieHuanEnable") + end +end + +function XUiFubenMainLineBanner:OnBtnCloseDifficultClick() + self:UpdateDifficultToggles() +end + +function XUiFubenMainLineBanner:OnBtnNormalClick() + if self.IsShowDifficultPanel then + if self.CurrentSelect == TAB_BTN_INDEX.MAINLINE then + self:SetCurMainLineDifficult(self.TYPE.NORMAL) + elseif self.CurrentSelect == TAB_BTN_INDEX.EXTRA then + self:SetCurExtraDifficult(self.TYPE.NORMAL) + end + self:UpdateDifficultToggles() + else + self:UpdateDifficultToggles(true) + end +end + +function XUiFubenMainLineBanner:OnBtnHardClick() + if self.IsShowDifficultPanel then + if self.CurrentSelect == TAB_BTN_INDEX.MAINLINE then + self:SetCurMainLineDifficult(self.TYPE.HARD) + elseif self.CurrentSelect == TAB_BTN_INDEX.EXTRA then + self:SetCurExtraDifficult(self.TYPE.HARD) + end + self:UpdateDifficultToggles() + else + self:UpdateDifficultToggles(true) + end +end + +function XUiFubenMainLineBanner:SetCurMainLineDifficult(difficult) + if self.CurDiff == difficult then return end + -- 检查困难开启 + if difficult == self.TYPE.HARD and not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.FubenDifficulty) then + return + end + self.CurDiff = difficult + XDataCenter.FubenMainLineManager.SetCurDifficult(self.CurDiff) + self:RefreshForChangeDiff() +end + +function XUiFubenMainLineBanner:SetCurExtraDifficult(difficult) + if self.CurExtraDifficult == difficult then return end + -- 检查困难开启 + if difficult == self.TYPE.HARD and not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.FubenDifficulty) then + return + end + self.CurExtraDifficult = difficult + XDataCenter.ExtraChapterManager.SetCurDifficult(self.CurExtraDifficult) + self:RefreshForChangeDiff() +end + +-- 选中一个 chapter grid,需要设置层级、状态 +function XUiFubenMainLineBanner:ClickChapterGrid(chapterMain, index) + local chapter = XDataCenter.FubenMainLineManager.GetChapterCfgByChapterMain(chapterMain.Id, self.CurDiff) + local chapterInfo = XDataCenter.FubenMainLineManager.GetChapterInfoByChapterMain(chapterMain.Id, self.CurDiff) + if chapterInfo.Unlock then + self.ParentUi:PushUi(function() + if chapterMain.Id == XDataCenter.FubenMainLineManager.TRPGChapterId then + local uiName = XDataCenter.TRPGManager.GetMainName() + XLuaUiManager.Open(uiName) + else + XLuaUiManager.Open("UiFubenMainLineChapter", chapter) + end + end) + + self:SaveScrollPos(index) + elseif chapterInfo.IsActivity then + local chapterId = XDataCenter.FubenMainLineManager.GetChapterIdByChapterMain(chapterMain.Id, self.CurDiff) + local ret, desc = XDataCenter.FubenMainLineManager.CheckActivityCondition(chapterId) + if not ret then + XUiManager.TipError(desc) + end + else + if self.CurDiff == XDataCenter.FubenManager.DifficultNightmare then + XUiManager.TipMsg(CS.XTextManager.GetText("BfrtChapterUnlockCondition")) + elseif chapterMain.Id == XDataCenter.FubenMainLineManager.TRPGChapterId then + XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.MainLineTRPG) + else + local chapterId = XDataCenter.FubenMainLineManager.GetChapterIdByChapterMain(chapterMain.Id, self.CurDiff) + local isOpen, desc = XDataCenter.FubenMainLineManager.CheckOpenCondition(chapterId) + if not isOpen then + XUiManager.TipMsg(desc) + return + end + self:ChapterLockTipMsg(chapterInfo) + end + end +end + +function XUiFubenMainLineBanner:ChapterLockTipMsg(chapterInfo) + local tipMsg = XDataCenter.FubenManager.GetFubenOpenTips(chapterInfo.FirstStage) + XUiManager.TipMsg(tipMsg) +end + +function XUiFubenMainLineBanner:UpdateDifficultToggles(showAll) + if showAll then + self:SetBtnTogleActive(true, true, true) + self.BtnCloseDifficult.gameObject:SetActiveEx(true) + else + if self.CurrentSelect == TAB_BTN_INDEX.MAINLINE then + self:UpdateMainLineDifficultToggles() + elseif self.CurrentSelect == TAB_BTN_INDEX.EXTRA then + self:UpdateExtraDifficultToggles() + end + self.BtnCloseDifficult.gameObject:SetActiveEx(false) + end + + self.IsShowDifficultPanel = showAll +end + +function XUiFubenMainLineBanner:UpdateMainLineDifficultToggles() + if self.CurDiff == self.TYPE.NORMAL then + self:SetBtnTogleActive(true, false, false) + self.BtnNormal.transform:SetAsFirstSibling() + elseif self.CurDiff == self.TYPE.HARD then + self:SetBtnTogleActive(false, true, false) + self.BtnHard.transform:SetAsFirstSibling() + else + self:SetBtnTogleActive(false, false, true) + end +end + +function XUiFubenMainLineBanner:UpdateExtraDifficultToggles() + if self.CurExtraDifficult == self.TYPE.NORMAL then + self:SetBtnTogleActive(true, false, false) + self.BtnNormal.transform:SetAsFirstSibling() + elseif self.CurExtraDifficult == self.TYPE.HARD then + self:SetBtnTogleActive(false, true, false) + self.BtnHard.transform:SetAsFirstSibling() + else + self:SetBtnTogleActive(false, false, true) + end +end + +function XUiFubenMainLineBanner:SetBtnTogleActive(isNormal, isHard) + self.BtnNormal.gameObject:SetActiveEx(isNormal) + + self.BtnHard.gameObject:SetActiveEx(isHard) + if isHard then + local hardOpen = XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.FubenDifficulty) + self.PanelHardOn.gameObject:SetActiveEx(hardOpen) + self.PanelHardOff.gameObject:SetActiveEx(not hardOpen) + end +end + +function XUiFubenMainLineBanner:RefreshForChangeDiff() + self:PlayAnimation("ListQieHuanEnable") + self:Refresh(true) +end + +function XUiFubenMainLineBanner:OnGetEvents() + return { XEventId.EVENT_FUBEN_PREQUEL_AUTOSELECT, XEventId.EVENT_FUBEN_MAINLINE_TAB_SELECT, XEventId.EVENT_FUBEN_MAINLINE_DIFFICUTY_SELECT } +end + +function XUiFubenMainLineBanner:OnNotify(evt, ...) + local args = { ... } + + if evt == XEventId.EVENT_FUBEN_PREQUEL_AUTOSELECT then + self.DefaultCoverId = args[1] + self.DefaultChapterId = args[2] + self.PanelTab:SelectIndex(TAB_BTN_INDEX.DZ) + + elseif evt == XEventId.EVENT_FUBEN_MAINLINE_TAB_SELECT then + self.PanelTab:SelectIndex(args[1]) + + elseif evt == XEventId.EVENT_FUBEN_MAINLINE_DIFFICUTY_SELECT then + self.CurrentSelect = nil + self.CurDiff = self.TYPE.HARD + XDataCenter.FubenMainLineManager.SetCurDifficult(self.CurDiff) + self.PanelTab:SelectIndex(TAB_BTN_INDEX.MAINLINE) + self:UpdateDifficultToggles() + elseif evt == XEventId.EVENT_FUBEN_EXTRA_DIFFICUTY_SELECT then + self.CurrentSelect = nil + self.CurExtraDifficult = self.TYPE.HARD + XDataCenter.ExtraChapterManager.SetCurDifficult(self.CurExtraDifficult) + self.PanelTab:SelectIndex(TAB_BTN_INDEX.EXTRA) + self:UpdateDifficultToggles() + end +end + +--据点点击了帮助按钮 +function XUiFubenMainLineBanner:OnBtnHelpClick() + local helpContent = CSGameConfig:GetString("BfrtShowHelpTip01") + XUiManager.ShowHelpTip(helpContent) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenMainLineBanner/XUiGridChapterBfrt.lua b/Resources/Scripts/XUi/XUiFubenMainLineBanner/XUiGridChapterBfrt.lua new file mode 100644 index 00000000..ab7f3b4e --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenMainLineBanner/XUiGridChapterBfrt.lua @@ -0,0 +1,59 @@ +local CSGetText = CS.XTextManager.GetText + +local XUiGridChapterBfrt = XClass(nil, "XUiGridChapterBfrt") + +function XUiGridChapterBfrt:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + self.BtnUnlockCover.CallBack = function() + local chapterId = self.ChapterId + local chapterCfg = XDataCenter.BfrtManager.GetChapterCfg(chapterId) + local chapterInfo = XDataCenter.BfrtManager.GetChapterInfo(chapterId) + + local conditionId = chapterCfg.ActivityCondition + if conditionId ~= 0 then + local ret, des = XConditionManager.CheckCondition(chapterCfg.ActivityCondition) + if not ret then + XUiManager.TipMsg(des) + return + end + end + + if not chapterInfo.Unlock then + XUiManager.TipMsg(CSGetText("BfrtChapterUnlockCondition")) + return + end + end +end + +function XUiGridChapterBfrt:RefreshDatas(chapterId) + self.ChapterId = chapterId + + local chapterCfg = XDataCenter.BfrtManager.GetChapterCfg(chapterId) + self.RImgIcon:SetRawImage(chapterCfg.Cover) + self.TxtOrder.text = chapterCfg.ChapterName + self.TxtName.text = chapterCfg.ChapterEn + + local passCount = XDataCenter.BfrtManager.GetChapterPassCount(chapterId) + local totalCount = XDataCenter.BfrtManager.GetGroupCount(chapterId) + self.TxtProgress.text = CSGetText("BfrtChapterProgress", passCount, totalCount) + + local chapterInfo = XDataCenter.BfrtManager.GetChapterInfo(chapterId) + if chapterInfo.Unlock then + self.BtnUnlockCover.gameObject:SetActiveEx(false) + else + self.TxtUnlockCondition.text = CSGetText("BfrtChpaterLocked", passCount, totalCount) + self.BtnUnlockCover.gameObject:SetActiveEx(true) + end + + self.ImgActivityTab.gameObject:SetActiveEx(chapterInfo.IsActivity) + XRedPointManager.CheckOnce(self.OnCheckRedPoint, self, { XRedPointConditions.Types.CONDITION_BFRT_CHAPTER_REWARD }, chapterId) +end + +function XUiGridChapterBfrt:OnCheckRedPoint(count) + self.ImgRedDot.gameObject:SetActiveEx(count >= 0) +end + +return XUiGridChapterBfrt \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenMainLineBanner/XUiGridChapterDz.lua b/Resources/Scripts/XUi/XUiFubenMainLineBanner/XUiGridChapterDz.lua new file mode 100644 index 00000000..a07b4b06 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenMainLineBanner/XUiGridChapterDz.lua @@ -0,0 +1,83 @@ +XUiGridChapterDz = XClass(nil, "XUiGridChapterDz") + +function XUiGridChapterDz:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self:InitAutoScript() +end + +function XUiGridChapterDz:InitRoot(rootUi) + self.RootUi = rootUi +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiGridChapterDz:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiGridChapterDz:AutoInitUi() + self.RImgDz = self.Transform:Find("RImgDz"):GetComponent("RawImage") + self.TxtProgress = self.Transform:Find("TxtProgress"):GetComponent("Text") + self.TxtName = self.Transform:Find("TxtName"):GetComponent("Text") + self.Txt3 = self.Transform:Find("Txt3"):GetComponent("Text") + self.Txt4 = self.Transform:Find("Txt4"):GetComponent("Text") + self.ImgActivityTab = self.Transform:Find("ImgActivityTab"):GetComponent("Image") + self.BtnUnlockCover = self.Transform:Find("BtnUnlockCover"):GetComponent("Button") + self.TxtUnlockCondition = self.Transform:Find("BtnUnlockCover/TxtUnlockCondition"):GetComponent("Text") +end + +function XUiGridChapterDz:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiGridChapterDz:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiGridChapterDz:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiGridChapterDz:AutoAddListener() + self:RegisterClickEvent(self.BtnUnlockCover, self.OnBtnUnlockCoverClick) +end +-- auto +function XUiGridChapterDz:OnBtnUnlockCoverClick() + if self.CoverInfo then + XUiManager.TipMsg(XDataCenter.PrequelManager.GetChapterUnlockDescription(self.CoverInfo.ShowChapter)) + end +end + +function XUiGridChapterDz:RefreshDatas(coverDatas) + self.CoverInfo = coverDatas + --local coverInfo = XPrequelConfigs.GetPrequelCoverInfoById(coverDatas.CoverId) + local showChapterInfo = XPrequelConfigs.GetPrequelChapterById(coverDatas.ShowChapter) + self.TxtName.text = showChapterInfo.ChapterName + -- self.RootUi:SetUiSprite(self.ImgDz, coverInfo.CoverBg) + self.RImgDz:SetRawImage(showChapterInfo.Bg) + + local finishedNum, totalNum = XDataCenter.PrequelManager.GetChapterProgress(coverDatas.ShowChapter) + self.TxtProgress.text = CS.XTextManager.GetText("PrequelCompletion", finishedNum, totalNum) + + self.ImgActivityTab.gameObject:SetActive(false) + -- 全部未解锁,优先级低于活动 + local unlockDescription = XDataCenter.PrequelManager.GetChapterUnlockDescription(coverDatas.ShowChapter) + self.BtnUnlockCover.gameObject:SetActive(unlockDescription ~= nil) + self.TxtUnlockCondition.text = unlockDescription + -- 有活动 + if coverDatas.IsActivity or coverDatas.IsActivityNotOpen then + self.ImgActivityTab.gameObject:SetActive(true) + if coverDatas.IsActivityNotOpen then + self.TxtUnlockCondition.text = unlockDescription + end + end +end + +return XUiGridChapterDz \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenMainLineBanner/XUiGridChapterExtra.lua b/Resources/Scripts/XUi/XUiFubenMainLineBanner/XUiGridChapterExtra.lua new file mode 100644 index 00000000..5f336ef7 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenMainLineBanner/XUiGridChapterExtra.lua @@ -0,0 +1,91 @@ +local XUiGridChapterExtra = XClass(nil, "XUiGridChapterExtra") + +function XUiGridChapterExtra:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.LockTxt = self.TxtLock.text +end + +function XUiGridChapterExtra:RefreshDatas(chapterCfg, difficulty) + self.ChapterId = chapterCfg.ChapterId[difficulty] + local chapterInfo = XDataCenter.ExtraChapterManager.GetChapterInfo(self.ChapterId) + local isActivity = chapterInfo and chapterInfo.IsActivity + self.PanelActivityTag.gameObject:SetActive(isActivity) + local extraTitle = XDataCenter.ExtraChapterManager.GetChapterDetailsStageTitle(self.ChapterId) + -- 红点&判断新关卡 + if isActivity then + self.PanelNewEffect.gameObject:SetActive(false) + end + --初始状态 + self.PanelDegree1.gameObject:SetActive(false) + self.PanelDegree2.gameObject:SetActive(false) + self.PanelDegree3.gameObject:SetActive(false) + + --进度展示 + if difficulty == XDataCenter.FubenManager.DifficultNormal then + self.PanelDegree1.gameObject:SetActive(true) + XRedPointManager.CheckOnce(self.OnCheckRedPoint, self, { XRedPointConditions.Types.CONDITION_EXTRA_CHAPTER_REWARD }, chapterCfg.ChapterId[1]) + local checkNew = XDataCenter.ExtraChapterManager.CheckChapterNew(chapterCfg.ChapterId[1]) + self.PanelNewEffect.gameObject:SetActive(checkNew) + elseif difficulty == XDataCenter.FubenManager.DifficultHard then + self.PanelDegree2.gameObject:SetActive(true) + XRedPointManager.CheckOnce(self.OnCheckRedPoint, self, { XRedPointConditions.Types.CONDITION_EXTRA_CHAPTER_REWARD }, chapterCfg.ChapterId[2]) + local checkNew = XDataCenter.ExtraChapterManager.CheckChapterNew(chapterCfg.ChapterId[2]) + self.PanelNewEffect.gameObject:SetActive(checkNew) + end + + -- icon&标题 + self.RImgChapter:SetRawImage(chapterCfg.Icon) + self.TxtEN.text = chapterCfg.ChapterEn + self.TxtNum.text = string.format("%s", extraTitle) + -- 普通关卡 + local progress = XDataCenter.ExtraChapterManager.GetProgressByChapterId(chapterCfg.ChapterId[1]) + self.TxtPercentNormal.text = progress .. "%" + self.ImgPercentNormal.fillAmount = progress / 100 + + -- 困难关卡 + progress = XDataCenter.ExtraChapterManager.GetProgressByChapterId(chapterCfg.ChapterId[2]) + self.TxtPercentHard.text = progress .. "%" + self.ImgPercentHard.fillAmount = progress / 100 + + -- 周目挑战标记 + local zhouMuNumber = XDataCenter.FubenZhouMuManager.GetZhouMuNumber(chapterCfg.ZhouMuId) + if zhouMuNumber <= 0 then + self.PanelMultipleWeeksTag.gameObject:SetActiveEx(false) + else + self.PanelMultipleWeeksTag.gameObject:SetActiveEx(true) + self.TextWeekNum.text = zhouMuNumber + end + + --未解锁 + if chapterInfo.Unlock then + self.PanelChapterLock.gameObject:SetActive(false) + else + if isActivity then + local isUnLock, desc = XDataCenter.ExtraChapterManager.CheckActivityCondition(chapterCfg.ChapterId[difficulty]) + self.TxtLock.text = desc + self.PanelChapterLock.gameObject:SetActiveEx(not isUnLock) + if isUnLock then + XDataCenter.ExtraChapterManager.UnlockChapterViaActivity(chapterCfg.ChapterId[difficulty]) + end + else + self.TxtLock.text = self.LockTxt + self.PanelChapterLock.gameObject:SetActiveEx(true) + end + end +end + +function XUiGridChapterExtra:OnCheckRedPoint(count) + if self.ImgRedDot then + self.ImgRedDot.gameObject:SetActive(count >= 0) + end +end + +function XUiGridChapterExtra:OnCheckRewards(count, chapterId) + if self.ImgRewards and chapterId == self.Chapter.ChapterId then + self.ImgRewards.gameObject:SetActive(count >= 0) + end +end + +return XUiGridChapterExtra \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenMainLineBanner/XUiGridMainLineBanner.lua b/Resources/Scripts/XUi/XUiFubenMainLineBanner/XUiGridMainLineBanner.lua new file mode 100644 index 00000000..955e59e7 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenMainLineBanner/XUiGridMainLineBanner.lua @@ -0,0 +1,113 @@ +XUiGridMainLineBanner = XClass(nil, "XUiGridMainLineBanner") + +function XUiGridMainLineBanner:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Transform3d = ui.transform + XTool.InitUiObject(self) + self.LockTxt = self.TxtLock.text +end + +function XUiGridMainLineBanner:OnCheckRewards(count, chapterId) + if self.ImgRewards and chapterId == self.Chapter.ChapterId then + self.ImgRewards.gameObject:SetActive(count >= 0) + end +end + +function XUiGridMainLineBanner:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiGridMainLineBanner:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiGridMainLineBanner:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +-- auto +-- chapter 组件内容更新 +function XUiGridMainLineBanner:UpdateChapterGrid(chapterMain, difficulty) + --初始状态 + self.PanelDegree1.gameObject:SetActive(false) + self.PanelDegree2.gameObject:SetActive(false) + self.PanelDegree3.gameObject:SetActive(false) + + local chapterInfo + local isActivity + + --判断活动关卡 + chapterInfo = XDataCenter.FubenMainLineManager.GetChapterInfoByChapterMain(chapterMain.Id, difficulty) + isActivity = chapterInfo.IsActivity + self.PanelActivityTag.gameObject:SetActive(isActivity) + + -- 红点&判断新关卡 + if isActivity then + self.PanelNewEffect.gameObject:SetActive(false) + end + + --进度展示 + if difficulty == XDataCenter.FubenMainLineManager.DifficultNormal then + self.PanelDegree1.gameObject:SetActive(true) + XRedPointManager.CheckOnce(self.OnCheckRedPoint, self, { XRedPointConditions.Types.CONDITION_MAINLINE_CHAPTER_REWARD }, chapterMain.ChapterId[1]) + local checkNew = XDataCenter.FubenMainLineManager.CheckChapterNew(chapterMain.ChapterId[1]) + self.PanelNewEffect.gameObject:SetActive(checkNew) + elseif difficulty == XDataCenter.FubenMainLineManager.DifficultHard then + self.PanelDegree2.gameObject:SetActive(true) + XRedPointManager.CheckOnce(self.OnCheckRedPoint, self, { XRedPointConditions.Types.CONDITION_MAINLINE_CHAPTER_REWARD }, chapterMain.ChapterId[2]) + local checkNew = XDataCenter.FubenMainLineManager.CheckChapterNew(chapterMain.ChapterId[2]) + self.PanelNewEffect.gameObject:SetActive(checkNew) + end + + -- icon&标题 + self.RImgChapter:SetRawImage(chapterMain.Icon) + self.TxtEN.text = chapterMain.ChapterEn + self.TxtNum.text = string.format("%02d", chapterMain.OrderId) + + -- 普通关卡 + local progress = XDataCenter.FubenMainLineManager.GetProgressByChapterId(chapterMain.ChapterId[1]) + self.TxtPercentNormal.text = progress .. "%" + self.ImgPercentNormal.fillAmount = progress / 100 + + -- 困难关卡 + if chapterMain.ChapterId[2] and chapterMain.ChapterId[2] > 0 then + progress = XDataCenter.FubenMainLineManager.GetProgressByChapterId(chapterMain.ChapterId[2]) + self.TxtPercentHard.text = progress .. "%" + self.ImgPercentHard.fillAmount = progress / 100 + end + + -- 周目挑战标记 + local zhouMuNumber = XDataCenter.FubenZhouMuManager.GetZhouMuNumber(chapterMain.ZhouMuId) + if zhouMuNumber <= 0 then + self.PanelMultipleWeeksTag.gameObject:SetActiveEx(false) + else + self.PanelMultipleWeeksTag.gameObject:SetActiveEx(true) + self.TextWeekNum.text = zhouMuNumber + end + + --未解锁 + if chapterInfo and chapterInfo.Unlock then + self.PanelChapterLock.gameObject:SetActive(false) + else + if isActivity then + local chapterId = XDataCenter.FubenMainLineManager.GetChapterIdByChapterMain(chapterMain.Id, difficulty) + local _, desc = XDataCenter.FubenMainLineManager.CheckActivityCondition(chapterId) + self.TxtLock.text = desc + else + self.TxtLock.text = self.LockTxt + end + self.PanelChapterLock.gameObject:SetActive(true) + end +end + +function XUiGridMainLineBanner:OnCheckRedPoint(count) + if self.ImgRedDot then + self.ImgRedDot.gameObject:SetActive(count >= 0) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenMainLineBanner/XUiPanelChapterBfrt.lua b/Resources/Scripts/XUi/XUiFubenMainLineBanner/XUiPanelChapterBfrt.lua new file mode 100644 index 00000000..53f28a1c --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenMainLineBanner/XUiPanelChapterBfrt.lua @@ -0,0 +1,48 @@ +local XUiGridChapterBfrt = require("XUi/XUiFubenMainLineBanner/XUiGridChapterBfrt") + +local XUiPanelChapterBfrt = XClass(nil, "XUiPanelChapterBfrt") + +function XUiPanelChapterBfrt:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + + XTool.InitUiObject(self) + self:InitDynamicTable() +end + +function XUiPanelChapterBfrt:InitDynamicTable() + self.ChapterDynamicTable = XDynamicTableNormal.New(self.GameObject) + self.ChapterDynamicTable:SetProxy(XUiGridChapterBfrt) + self.ChapterDynamicTable:SetDelegate(self) +end + +--动态列表事件 +function XUiPanelChapterBfrt:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + if self.ChapterIds[index] then + grid:RefreshDatas(self.ChapterIds[index]) + end + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + self:OnChapterCoverClick(self.ChapterIds[index]) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_RELOAD_COMPLETED then + XEventManager.DispatchEvent(XEventId.EVENT_GUIDE_STEP_OPEN_EVENT) + end +end + +-- 章节点击事件 +function XUiPanelChapterBfrt:OnChapterCoverClick(chapterId) + local chapterCfg = XDataCenter.BfrtManager.GetChapterCfg(chapterId) + self.RootUi:PushUi(function() + XLuaUiManager.Open("UiFubenMainLineChapter", chapterCfg, nil, true) + end) +end + +-- 设置数据 +function XUiPanelChapterBfrt:SetupBfrtChapters() + self.ChapterIds = self.ChapterIds or XDataCenter.BfrtManager.GetChapterList() + self.ChapterDynamicTable:SetDataSource(self.ChapterIds) + self.ChapterDynamicTable:ReloadDataASync() +end + +return XUiPanelChapterBfrt \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenMainLineBanner/XUiPanelChapterDz.lua b/Resources/Scripts/XUi/XUiFubenMainLineBanner/XUiPanelChapterDz.lua new file mode 100644 index 00000000..b5966d77 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenMainLineBanner/XUiPanelChapterDz.lua @@ -0,0 +1,100 @@ +XUiPanelChapterDz = XClass(nil, "XUiPanelChapterDz") + +function XUiPanelChapterDz:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self:InitAutoScript() + + self.ChapterDynamicTable = XDynamicTableNormal.New(self.PanelChapterDz) + self.ChapterDynamicTable:SetProxy(XUiGridChapterDz) + self.ChapterDynamicTable:SetDelegate(self) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelChapterDz:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiPanelChapterDz:AutoInitUi() + self.PanelChapterDz = self.Transform:Find("PanelChapterDz") + self.PanelChapterContent = self.Transform:Find("PanelChapterDz/Viewport/PanelChapterContent") + self.GridChapterDz = self.Transform:Find("PanelChapterDz/Viewport/GridChapterDz") +end + +function XUiPanelChapterDz:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelChapterDz:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelChapterDz:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelChapterDz:AutoAddListener() +end +-- auto +--动态列表事件 +function XUiPanelChapterDz:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:InitRoot(self.RootUi) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + if self.Covers[index] then + grid:RefreshDatas(self.Covers[index]) + end + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + self.CurrentCover = self.Covers[index] + self:OnChapterCoverClick(grid, self.CurrentCover) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_RELOAD_COMPLETED then + XEventManager.DispatchEvent(XEventId.EVENT_GUIDE_STEP_OPEN_EVENT) + end +end + +-- 章节点击事件 +function XUiPanelChapterDz:OnChapterCoverClick(grid, coverData) + -- 跳转到新界面 + XLuaUiManager.Open("UiPrequel", coverData) +end + +-- 设置数据 +function XUiPanelChapterDz:SetupCoverDatas(defaultCoverId, defaultChapterId) + self.Covers = XDataCenter.PrequelManager.GetListCovers() + self.ChapterDynamicTable:SetDataSource(self.Covers) + self.ChapterDynamicTable:ReloadDataASync() + + if defaultCoverId then + self:OnOpenCoverById(defaultCoverId, defaultChapterId) + end +end + +function XUiPanelChapterDz:OnOpenCoverById(coverId, defaultChapterId) + if self.Covers then + local index = 0 + for k, v in pairs(self.Covers) do + if v.CoverId == coverId then + index = k + break + end + end + if self.Covers[index] then + if self.Covers[index].IsAllChapterLock and (not self.Covers[index].IsActivity) then + XUiManager.TipMsg(XDataCenter.PrequelManager.GetChapterUnlockDescription(self.Covers[index].ShowChapter)) + return + end + self.CurrentCover = self.Covers[index] + XLuaUiManager.Open("UiPrequel", self.CurrentCover, nil, defaultChapterId) + end + end +end + +return XUiPanelChapterDz \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenMainLineBanner/XUiPanelChapterExtra.lua b/Resources/Scripts/XUi/XUiFubenMainLineBanner/XUiPanelChapterExtra.lua new file mode 100644 index 00000000..6ff25c12 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenMainLineBanner/XUiPanelChapterExtra.lua @@ -0,0 +1,75 @@ +local XUiGridChapterExtra = require("XUi/XUiFubenMainLineBanner/XUiGridChapterExtra") +local XUiPanelChapterExtra = XClass(nil, "XUiPanelChapterExtra") + +function XUiPanelChapterExtra:Ctor(ui, rootUi, parentUi) + self.gameObject = ui.gameObject + self.transform = ui.transform + self.rootUi = rootUi + self.parent = parentUi + self.GridMainLineBanner = self.transform:Find("Viewport/GridMainLineBanner") + self.GridMainLineBanner.gameObject:SetActiveEx(false) + self:InitDynamicTable() +end + +function XUiPanelChapterExtra:OnEnable() + XEventManager.AddEventListener(XEventId.EVENT_FUBEN_CHANGE_EXTRA_CHAPTER_DIFFICULT, self.UpdateCoverData, self) +end + +function XUiPanelChapterExtra:InitDynamicTable() + self.ChapterDynamicTable = XDynamicTableNormal.New(self.gameObject) + self.ChapterDynamicTable:SetProxy(XUiGridChapterExtra) + self.ChapterDynamicTable:SetDelegate(self) +end + + +--动态列表事件 +function XUiPanelChapterExtra:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + if self.ChapterIds[index] then + grid:RefreshDatas(self.ChapterIds[index], self.currentDifficult) + end + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + self:OnChapterCoverClick(self.ChapterIds[index]) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_RELOAD_COMPLETED then + XEventManager.DispatchEvent(XEventId.EVENT_GUIDE_STEP_OPEN_EVENT) + end +end + +-- 章节点击事件 +function XUiPanelChapterExtra:OnChapterCoverClick(chapterCfg) + if not chapterCfg then return end + local chapterId = chapterCfg.ChapterId[self.currentDifficult] + local chapterInfo = XDataCenter.ExtraChapterManager.GetChapterInfo(chapterId) + local chapterCfg = XDataCenter.ExtraChapterManager.GetChapterDetailsCfgByChapterIdAndDifficult(chapterInfo.ChapterMainId, self.currentDifficult) + if chapterInfo.Unlock then + self.rootUi:PushUi(function() + XLuaUiManager.Open("UiFubenMainLineChapterFw", chapterCfg, nil, false) + end) + elseif chapterInfo.IsActivity then + local ret, desc = XDataCenter.ExtraChapterManager.CheckActivityCondition(chapterId) + if not ret then + XUiManager.TipError(desc) + end + else + local ret, desc = XDataCenter.ExtraChapterManager.CheckOpenCondition(chapterId) + if not ret then + XUiManager.TipError(desc) + return + end + local tipMsg = XDataCenter.FubenManager.GetFubenOpenTips(chapterInfo.FirstStage) + XUiManager.TipMsg(tipMsg) + end +end + +function XUiPanelChapterExtra:UpdateCoverData(difficult) + self.currentDifficult = difficult + self.ChapterIds = XDataCenter.ExtraChapterManager.GetChapterExtraCfgs(difficult) + self.ChapterDynamicTable:SetDataSource(self.ChapterIds) + self.ChapterDynamicTable:ReloadDataASync() +end + +function XUiPanelChapterExtra:OnDisable() + XEventManager.RemoveEventListener(XEventId.EVENT_FUBEN_CHANGE_EXTRA_CHAPTER_DIFFICULT, self.UpdateCoverData, self) +end + +return XUiPanelChapterExtra \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiFubenExItemTip.lua b/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiFubenExItemTip.lua new file mode 100644 index 00000000..be914a72 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiFubenExItemTip.lua @@ -0,0 +1,60 @@ +local XUiFubenExItemTip = XLuaUiManager.Register(XLuaUi, "UiFubenExItemTip") + +function XUiFubenExItemTip:OnStart(base) + self.Base = base + self:SetButtonCallBack() + self:InitDynamicTable() + self:SetItemCount() +end + +function XUiFubenExItemTip:OnEnable() + self:SetupDynamicTable() +end + +function XUiFubenExItemTip:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelItemList) + self.DynamicTable:SetProxy(XUiGridExploreItem) + self.DynamicTable:SetDelegate(self) + self.PanelItemPortrait.gameObject:SetActiveEx(false) +end + +function XUiFubenExItemTip:SetupDynamicTable() + self.PageDatas = XDataCenter.FubenMainLineManager.GetChapterExploreItemList(self.Base.MainChapterId) + self.DynamicTable:SetDataSource(self.PageDatas) + self.DynamicTable:ReloadDataSync(1) +end + +function XUiFubenExItemTip:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:UpdateGrid(self.PageDatas[index], self, index) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:UpdateGrid(self.PageDatas[index], self) + end +end + +function XUiFubenExItemTip:SetButtonCallBack() + self.BtnClose.CallBack = function() + self:OnBtCloseClick() + end +end + +function XUiFubenExItemTip:SetItemData(itemId) + local info = XFubenMainLineConfigs.GetExploreItemCfgById(itemId) + if (info ~= nil) then + self.RImgPlayerIcon:SetRawImage(info.Icon) + self.TxtHeadName.text = info.Name + self.TxtDesc.text = info.Desc + self.TxtCondition.text = info.Hint + self.SelectCharacterId = itemId + end +end + +function XUiFubenExItemTip:SetItemCount() + local itemMaxCount = XDataCenter.FubenMainLineManager.GetChapterExploreItemMaxCount(self.Base.MainChapterId) + local itemCurCount = #XDataCenter.FubenMainLineManager.GetChapterExploreItemList(self.Base.MainChapterId) + self.TextNum.text = string.format("%d/%d", itemCurCount, itemMaxCount) +end + +function XUiFubenExItemTip:OnBtCloseClick() + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiFubenExploreDetail.lua b/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiFubenExploreDetail.lua new file mode 100644 index 00000000..c76d9fd3 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiFubenExploreDetail.lua @@ -0,0 +1,281 @@ +local XUiFubenExploreDetail = XLuaUiManager.Register(XLuaUi, "UiFubenExploreDetail") +local StarMaxCount = 3 + +function XUiFubenExploreDetail:OnStart(base, stageCfg, cb, stageType) + self.Base = base + self.StageCfg = stageCfg + self.CallBack = cb + self.GridList = {} + self.StageType = stageType or XDataCenter.FubenManager.StageType.Mainline + self:SetButtonCallback() + + if stageCfg.StageType == XFubenConfigs.STAGETYPE_STORY or + stageCfg.StageType == XFubenConfigs.STAGETYPE_STORYEGG then + self:ShowStoryDialog() + elseif stageCfg.StageType == XFubenConfigs.STAGETYPE_FIGHT or + stageCfg.StageType == XFubenConfigs.STAGETYPE_FIGHTEGG or + stageCfg.StageType == XFubenConfigs.STAGETYPE_COMMON then + self:ShowFightDialog() + end + + self:InitStarPanels() + self:UpdateReward() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) +end + +function XUiFubenExploreDetail:OnEnable() + self:UpdateReward() + self:AddEventListener() +end + +function XUiFubenExploreDetail:OnDisable() + self:RemoveEventListener() +end + +function XUiFubenExploreDetail:InitStarPanels() + self.GridStarList = {} + self.GridStarObjList = { self.GridStageStar1, self.GridStageStar2, self.GridStageStar3 } + for i = 1, StarMaxCount do + local ui = self.GridStarObjList[i] + ui.gameObject:SetActiveEx(true) + local grid = XUiGridStageStar.New(ui) + self.GridStarList[i] = grid + end +end + +function XUiFubenExploreDetail:SetButtonCallback() + self.BtnMask.CallBack = function() + self:OnBtnMaskClick() + end + self.BtnEnterStory.CallBack = function() + self:OnBtnEnterStoryClick() + end + self.BtnEnterSub.CallBack = function() + self:OnBtnEnterFightClick() + end + self.BtnEnterFight.CallBack = function() + self:OnBtnEnterFightClick() + end + self.BtnMWEnterFight.CallBack = function() + self:OnBtnEnterFightClick() + end + self.BtnAutoFight.CallBack = function() + self:OnBtnAutoFightClick() + end + self.BtnAutoFightComplete.CallBack = function() + self:OnBtnAutoFightCompleteClick() + end +end + +function XUiFubenExploreDetail:OnBtnMaskClick() + if self.CallBack then + self.CallBack() + end + self:Close() +end + +function XUiFubenExploreDetail:SetAutoFightActive(value) + self.PanelAutoFightButton.gameObject:SetActive(value) + self.BtnEnterFight.gameObject:SetActive(not value) +end + +function XUiFubenExploreDetail:SetAutoFightState(value) + local state = XDataCenter.AutoFightManager.State + self.BtnAutoFight.gameObject:SetActive(value == state.None) + self.ImgAutoFighting.gameObject:SetActive(value == state.Fighting) + self.BtnAutoFightComplete.gameObject:SetActive(value == state.Complete) +end + +function XUiFubenExploreDetail:ShowStoryDialog() + local titleName + local stageInfo = XDataCenter.FubenManager.GetStageInfo(self.StageCfg.StageId) + if self.StageType == XDataCenter.FubenManager.StageType.ExtraChapter then + titleName = XDataCenter.ExtraChapterManager.GetChapterDetailsStageTitle(stageInfo.ChapterId) + else + titleName = XDataCenter.FubenMainLineManager.GetChapterOrderIdByStageId(self.StageCfg.StageId) + end + self.PanelStory.gameObject:SetActiveEx(true) + self.PanelFight.gameObject:SetActiveEx(false) + self.PanelFightMW.gameObject:SetActiveEx(false) + + self.TxtStoryName.text = string.format("%s-%d %s", tostring(titleName), self.StageCfg.OrderId, self.StageCfg.Name) + self.TxtStoryDec.text = self.StageCfg.Description + + if self.StageCfg.Icon then + self.RImgStory:SetRawImage(self.StageCfg.Icon) + end + self:PlayAnimation("StoryAnimEnable") +end + +function XUiFubenExploreDetail:ShowFightDialog() + if self.Base.IsOnZhouMu then + self.PanelFight.gameObject:SetActiveEx(false) + self.PanelStory.gameObject:SetActiveEx(false) + self.PanelFightMW.gameObject:SetActiveEx(true) + + self.TxtMWFightName.text = self.StageCfg.Name + self.TxtMWFightDec.text = self.StageCfg.Description + self.RImgMWFightIcon:SetRawImage(self.StageCfg.Icon) + else + local stageInfo = XDataCenter.FubenManager.GetStageInfo(self.StageCfg.StageId) + local stageData = XDataCenter.FubenManager.GetStageData(self.StageCfg.StageId) + local maxChallengeNum = XDataCenter.FubenManager.GetStageMaxChallengeNums(self.StageCfg.StageId) + local chanllengeNum = stageData and stageData.PassTimesToday or 0 + + self.PanelNums.gameObject:SetActive(maxChallengeNum > 0) + self.PanelFight.gameObject:SetActiveEx(true) + self.PanelStory.gameObject:SetActiveEx(false) + self.PanelFightMW.gameObject:SetActiveEx(false) + + if self.StageCfg.StoryIcon then + self.RImgFight:SetRawImage(self.StageCfg.StoryIcon) + end + local titleName, chapterOrderId + if self.StageType == XDataCenter.FubenManager.StageType.ExtraChapter then + chapterOrderId = XDataCenter.ExtraChapterManager.GetChapterOrderIdByStageId(self.StageCfg.StageId) + titleName = XDataCenter.ExtraChapterManager.GetChapterDetailsStageTitle(stageInfo.ChapterId) + self.TxtFightName.text = string.format("%s-%d %s", titleName, self.StageCfg.OrderId, self.StageCfg.Name) + elseif self.StageType == XDataCenter.FubenManager.StageType.Mainline then + chapterOrderId = XDataCenter.FubenMainLineManager.GetChapterOrderIdByStageId(self.StageCfg.StageId) + self.TxtFightName.text = string.format("%s-%d %s", chapterOrderId, self.StageCfg.OrderId, self.StageCfg.Name) + else + self.TxtFightName.text = string.format("%s %s", self.StageCfg.Name, self.StageCfg.Description) + end + + self.TxtATNums.text = self.StageCfg.RequireActionPoint + + if maxChallengeNum > 0 then + self.TextName.text = CS.XTextManager.GetText("MainLineExploreChallengeCount", maxChallengeNum - chanllengeNum, maxChallengeNum) + else + self.TextName.text = "" + end + end + self:PlayAnimation("FightAnimEnable") +end + +function XUiFubenExploreDetail:UpdateReward() + local stageInfo = XDataCenter.FubenManager.GetStageInfo(self.StageCfg.StageId) + self.Grid128.gameObject:SetActiveEx(false) + -- 获取显示奖励Id + local rewardId = 0 + local IsFirst = false + local HaveReward = true + local cfg = XDataCenter.FubenManager.GetStageLevelControl(self.StageCfg.StageId) + if not stageInfo.Passed then + rewardId = cfg and cfg.FirstRewardShow or self.StageCfg.FirstRewardShow + if cfg and cfg.FirstRewardShow > 0 or self.StageCfg.FirstRewardShow > 0 then + IsFirst = true + end + end + if rewardId == 0 then + rewardId = cfg and cfg.FinishRewardShow or self.StageCfg.FinishRewardShow + end + if rewardId == 0 then + for j = 1, #self.GridList do + self.GridList[j].GameObject:SetActiveEx(false) + end + HaveReward = false + -- return + end + + local rewards + if HaveReward then + rewards = IsFirst and XRewardManager.GetRewardList(rewardId) or XRewardManager.GetRewardListNotCount(rewardId) + end + if rewards then + for i, item in ipairs(rewards) do + local grid + if self.GridList[i] then + grid = self.GridList[i] + else + local ui = CS.UnityEngine.Object.Instantiate(self.Grid128) + grid = XUiGridCommon.New(self, ui) + grid.Transform:SetParent(self.PanelRewardContent, false) + self.GridList[i] = grid + end + grid:Refresh(item) + grid.GameObject:SetActiveEx(true) + end + end + + local rewardsCount = 0 + if rewards then + rewardsCount = #rewards + end + + for j = 1, #self.GridList do + if j > rewardsCount then + self.GridList[j].GameObject:SetActiveEx(false) + end + end + + self.TxtFirstDrop.gameObject:SetActiveEx(HaveReward and IsFirst) + self.TxtDrop.gameObject:SetActiveEx(HaveReward and not IsFirst) + + for i = 1, StarMaxCount do + self.GridStarList[i]:Refresh(self.StageCfg.StarDesc[i], stageInfo.StarsMap[i]) + end + + local showAutoFightBtn = XDataCenter.AutoFightManager.CheckAutoFightAvailable(self.StageCfg.StageId) == XCode.Success + if showAutoFightBtn then + self:SetAutoFightState(XDataCenter.AutoFightManager.State.None) + end + self:SetAutoFightActive(showAutoFightBtn) +end + +function XUiFubenExploreDetail:OnBtnEnterStoryClick() + local stageInfo = XDataCenter.FubenManager.GetStageInfo(self.StageCfg.StageId) + self:OnBtnMaskClick() + if stageInfo.Passed then + XDataCenter.MovieManager.PlayMovie(self.StageCfg.BeginStoryId) + else + XDataCenter.FubenManager.FinishStoryRequest(self.StageCfg.StageId, function() + XDataCenter.MovieManager.PlayMovie(self.StageCfg.BeginStoryId, function() + self.Base:RefreshForChangeDiff(true) + end) + end) + end +end + +function XUiFubenExploreDetail:OnBtnEnterFightClick() + if XDataCenter.FubenManager.CheckPreFight(self.StageCfg) then + self:OnBtnMaskClick() + XLuaUiManager.Open("UiNewRoomSingle", self.StageCfg.StageId) + end +end + +function XUiFubenExploreDetail:OnBtnAutoFightClick() + XDataCenter.AutoFightManager.CheckOpenDialog(self.StageCfg.StageId, self.StageCfg) +end + +function XUiFubenExploreDetail:OnBtnAutoFightCompleteClick() + local index = XDataCenter.AutoFightManager.GetIndexByStageId(self.StageCfg.StageId) + XDataCenter.AutoFightManager.ObtainRewards(index) +end + +function XUiFubenExploreDetail:OnAutoFightStart(stageId) +end + +function XUiFubenExploreDetail:OnAutoFightRemove(stageId) + if self.StageCfg.StageId == stageId then + self:SetAutoFightState(XDataCenter.AutoFightManager.State.None) + end +end + +function XUiFubenExploreDetail:OnAutoFightComplete(stageId) + if self.StageCfg.StageId == stageId then + self:SetAutoFightState(XDataCenter.AutoFightManager.State.Complete) + end +end + +function XUiFubenExploreDetail:AddEventListener() + XEventManager.AddEventListener(XEventId.EVENT_AUTO_FIGHT_START, self.OnAutoFightStart, self) + XEventManager.AddEventListener(XEventId.EVENT_AUTO_FIGHT_REMOVE, self.OnAutoFightRemove, self) + XEventManager.AddEventListener(XEventId.EVENT_AUTO_FIGHT_COMPLETE, self.OnAutoFightComplete, self) +end + +function XUiFubenExploreDetail:RemoveEventListener() + XEventManager.RemoveEventListener(XEventId.EVENT_AUTO_FIGHT_START, self.OnAutoFightStart, self) + XEventManager.RemoveEventListener(XEventId.EVENT_AUTO_FIGHT_REMOVE, self.OnAutoFightRemove, self) + XEventManager.RemoveEventListener(XEventId.EVENT_AUTO_FIGHT_COMPLETE, self.OnAutoFightComplete, self) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiFubenMainLineChapter.lua b/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiFubenMainLineChapter.lua new file mode 100644 index 00000000..6504eddf --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiFubenMainLineChapter.lua @@ -0,0 +1,1159 @@ +local XUiGridChapter = require("XUi/XUiFubenMainLineChapter/XUiGridChapter") +local XUiGridExploreChapter = require("XUi/XUiFubenMainLineChapter/XUiGridExploreChapter") + +local XUiFubenMainLineChapter = XLuaUiManager.Register(XLuaUi, "UiFubenMainLineChapter") + +function XUiFubenMainLineChapter:OnAwake() + self:InitAutoScript() +end + +function XUiFubenMainLineChapter:OnStart(chapter, stageId, hideDiffTog) + self.UnderBg = self.Transform:Find("SafeAreaContentPane/ImageUnder") + self.SafeAreaContentPane = self.Transform:Find("SafeAreaContentPane") + self.Camera = self.Transform:GetComponent("Canvas").worldCamera + self.Chapter = chapter + self.StageId = stageId + if self.LastData then + self.Chapter = self.LastData.Chapter or chapter + self.StageId = self.LastData.StageId or stageId + self.HideDiffTog = self.LastData.HideDiffTog or hideDiffTog + self.LastData = nil + else + self.Chapter = chapter + self.StageId = stageId + self.HideDiffTog = hideDiffTog + end + self.Opened = false + self.IsOnZhouMu = false + self.GridTreasureList = {} + self.GridMultipleWeeksTaskList = {} + self.GridChapterList = {} --存的是各种Chapter的预制体实例列表 + self.QuickJumpBtnList = {} + self.PanelExploreBottom = {} + self.CurChapterGrid = nil + self.CurChapterGridName = "" + self.PanelStageDetailInst = nil + self.PanelBfrtStageDetailInst = nil + self.CurDiff = self.Chapter.Difficult or XDataCenter.FubenManager.DifficultNightmare --据点战Chapter没有难度配置 + self.PanelTreasure.gameObject:SetActiveEx(false) + self.ImgRedProgress.gameObject:SetActiveEx(false) + self.IsExploreMod = XDataCenter.FubenMainLineManager.CheckChapterTypeIsExplore(self.Chapter) + + local chapterInfo = XDataCenter.FubenMainLineManager.GetChapterInfo(self.Chapter.ChapterId) + self.MainChapterId = chapterInfo and chapterInfo.ChapterMainId or 0 + self.ZhouMuId = XFubenMainLineConfigs.GetZhouMuId(self.MainChapterId) + + -- 注册红点事件 + XEventManager.AddEventListener(XEventId.EVENT_BOUNTYTASK_TASK_COMPLETE_NOTIFY, self.SetupBountyTask, self) + self.RedPointId = XRedPointManager.AddRedPointEvent(self.ImgRedProgress, self.OnCheckRewards, self, { XRedPointConditions.Types.CONDITION_MAINLINE_TREASURE }, self.Chapter.ChapterId, false) + self.RedPointZhouMuId = XRedPointManager.AddRedPointEvent(self.ImgRedProgress, self.OnCheckRewards, self, { XRedPointConditions.Types.CONDITION_ZHOUMU_TASK }, self.ZhouMuId, false) + + self.RedPointBfrtId = XRedPointManager.AddRedPointEvent(self.ImgRedProgressA, self.OnCheckBfrtRewards, self, { XRedPointConditions.Types.CONDITION_BFRT_CHAPTER_REWARD }, nil, false) + XRedPointManager.AddRedPointEvent(self.BtnExItem, self.OnCheckExploreItemNews, self, { XRedPointConditions.Types.CONDITION_EXPLORE_ITEM_GET }, self.MainChapterId) + + -- 注册stage事件 + XEventManager.AddEventListener(XEventId.EVENT_FUBEN_STAGE_SYNC, self.OnSyncStage, self) + XEventManager.AddEventListener(XEventId.EVENT_AUTO_FIGHT_START, self.OnAutoFightStart, self) + + -- 难度toggle + if not self.HideDiffTog then + self.IsShowDifficultPanel = false + self:UpdateDifficultToggles() + if XUiManager.IsHideFunc then + self.PanelTopDifficult.gameObject:SetActiveEx(false) + end + else + self.PanelTopDifficult.gameObject:SetActiveEx(false) + end + if self.BtnHelp then + self.BtnHelp.gameObject:SetActiveEx(hideDiffTog ~= nil) + end + -- 赏金任务 + self:InitBountyTask() + self:SetupBountyTask() + + self:InitPanelBottom() +end + +function XUiFubenMainLineChapter:OnEnable() + -- 是否显示周目挑战按钮 + self.PanelMultipleWeeksInfo.gameObject:SetActiveEx(false) + if not self:CheckIsBfrtType() then + self.ZhouMuNumber = XDataCenter.FubenZhouMuManager.GetZhouMuNumber(self.ZhouMuId) + self.PanelMultipleWeeksInfo.gameObject:SetActiveEx(self.ZhouMuNumber ~= 0) + end + if self.GridChapterList then + for _, v in pairs(self.GridChapterList) do + v:OnEnable() + end + end + + self:UpdateDifficultToggles() + self:OnOpenInit() + self:UpdateCurChapter(self.Chapter) + + self:SetupBountyTask() + + self:GoToLastPassStage() +end + +function XUiFubenMainLineChapter:OnDisable() + if self.GridChapterList then + for _, v in pairs(self.GridChapterList) do + v:OnDisable() + end + end + + if not self.IsExploreMod then + local childUi = self:GetCurDetailChildUi() + self:CloseChildUi(childUi) + self:OnCloseStageDetail() + end +end + +function XUiFubenMainLineChapter:OnDestroy() + self:DestroyActivityTimer() + XDataCenter.FubenManager.UiFubenMainLineChapterInst = nil + XEventManager.RemoveEventListener(XEventId.EVENT_FUBEN_STAGE_SYNC, self.OnSyncStage, self) + XEventManager.RemoveEventListener(XEventId.EVENT_BOUNTYTASK_TASK_COMPLETE_NOTIFY, self.SetupBountyTask, self) + XEventManager.RemoveEventListener(XEventId.EVENT_AUTO_FIGHT_START, self.OnAutoFightStart, self) +end + +function XUiFubenMainLineChapter:OnOpenInit() + XDataCenter.FubenManager.UiFubenMainLineChapterInst = self +end + +function XUiFubenMainLineChapter:InitPanelBottom() + self.PanelExploreBottom.Transform = self.PanelExploreBottomObj.transform + self.PanelExploreBottom.GameObject = self.PanelExploreBottomObj.gameObject + XTool.InitUiObject(self.PanelExploreBottom) + + self.PanelExploreBottom.BtnNormalJump.gameObject:SetActiveEx(false) + self.PanelExploreBottom.BtnHardlJump.gameObject:SetActiveEx(false) +end + +function XUiFubenMainLineChapter:GoToLastPassStage() + if self.CurChapterGrid then + + if self.IsExploreMod then + if self.IsCanGoNearestStage or not self.Opened then + self.CurChapterGrid:GoToNearestStage() + self.Opened = true + self.IsCanGoNearestStage = false + end + else + if not self.Opened then + local lastPassStageId = XDataCenter.FubenMainLineManager.GetLastPassStage(self.Chapter.ChapterId) + self.CurChapterGrid:GoToStage(lastPassStageId) + self.Opened = true + end + end + end +end + +function XUiFubenMainLineChapter:StageLevelChangeAutoMove() + if self.CurChapterGrid then + if self.IsExploreMod then + self.CurChapterGrid:GoToNearestStage() + else + local lastPassStageId = XDataCenter.FubenMainLineManager.GetLastPassStage(self.Chapter.ChapterId) + self.CurChapterGrid:GoToStage(lastPassStageId) + end + end +end + +-- 打开关卡详情 +function XUiFubenMainLineChapter:OpenStage(stageId, needRefreshChapter) + local orderId + if XDataCenter.BfrtManager.CheckStageTypeIsBfrt(stageId) then + local groupId = XDataCenter.BfrtManager.GetGroupIdByStageId(stageId) + orderId = XDataCenter.BfrtManager.GetGroupOrderId(groupId) + self.CurDiff = XDataCenter.FubenManager.DifficultNightmare + XDataCenter.FubenMainLineManager.SetCurDifficult(self.CurDiff) + else + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + orderId = stageInfo.OrderId + self.CurDiff = stageInfo.Difficult + XDataCenter.FubenMainLineManager.SetCurDifficult(self.CurDiff) + end + + self:UpdateDifficultToggles() + + if needRefreshChapter then + local chapter = self:GetChapterCfgByStageId(stageId) + self:UpdateCurChapter(chapter) + end + self.CurChapterGrid:ClickStageGridByIndex(orderId) +end + +function XUiFubenMainLineChapter:EnterFight(stage) + if not XDataCenter.FubenManager.CheckPreFight(stage) then + return + end + + if XDataCenter.BfrtManager.CheckStageTypeIsBfrt(stage.StageId) then + --据点战副本类型先跳转到作战部署界面 + local groupId = XDataCenter.BfrtManager.GetGroupIdByBaseStage(stage.StageId) + XLuaUiManager.Open("UiBfrtDeploy", groupId) + else + XLuaUiManager.Open("UiNewRoomSingle", stage.StageId) + end +end + +-- 是否显示红点 +function XUiFubenMainLineChapter:OnCheckRewards(count, chapterId) + if self.IsOnZhouMu then + if self.ImgRedProgress and chapterId == self.ZhouMuId then + self.ImgRedProgress.gameObject:SetActiveEx(count >= 0) + end + else + if self.ImgRedProgress and chapterId == self.Chapter.ChapterId then + self.ImgRedProgress.gameObject:SetActiveEx(count >= 0) + end + end +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiFubenMainLineChapter:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiFubenMainLineChapter:AutoInitUi() + self.PanelTreasure = self.Transform:Find("SafeAreaContentPane/PanelTreasure") + self.BtnTreasureBg = self.Transform:Find("SafeAreaContentPane/PanelTreasure/BtnTreasureBg"):GetComponent("Button") + self.PanelReward = self.Transform:Find("SafeAreaContentPane/PanelTreasure/PanelReward") + self.TxtTreasureTitle = self.Transform:Find("SafeAreaContentPane/PanelTreasure/PanelReward/TxtTreasureTitle"):GetComponent("Text") + self.PanelTreasureGrade = self.Transform:Find("SafeAreaContentPane/PanelTreasure/PanelReward/PanelTreasureGrade") + self.PanelGradeContent = self.Transform:Find("SafeAreaContentPane/PanelTreasure/PanelReward/PanelTreasureGrade/Viewport/PanelGradeContent") + self.GridTreasureGrade = self.Transform:Find("SafeAreaContentPane/PanelTreasure/PanelReward/PanelTreasureGrade/Viewport/PanelGradeContent/GridTreasureGrade") + self.Scrollbar = self.Transform:Find("SafeAreaContentPane/PanelTreasure/PanelReward/PanelTreasureGrade/Scrollbar"):GetComponent("Scrollbar") + self.PanelMainlineChapter = self.Transform:Find("SafeAreaContentPane/PanelMainlineChapter") + self.PanelTop = self.Transform:Find("SafeAreaContentPane/PanelMainlineChapter/PanelTop") + self.BtnBack = self.Transform:Find("SafeAreaContentPane/PanelMainlineChapter/PanelTop/BtnBack"):GetComponent("Button") + self.BtnMainUi = self.Transform:Find("SafeAreaContentPane/PanelMainlineChapter/PanelTop/BtnMainUi"):GetComponent("Button") + self.PanelChapterName = self.Transform:Find("SafeAreaContentPane/PanelMainlineChapter/PanelChapterName") + self.TxtChapter = self.Transform:Find("SafeAreaContentPane/PanelMainlineChapter/PanelChapterName/TxtChapter"):GetComponent("Text") + self.TxtChapterName = self.Transform:Find("SafeAreaContentPane/PanelMainlineChapter/PanelChapterName/TxtChapterName"):GetComponent("Text") + self.PanelTopDifficult = self.Transform:Find("SafeAreaContentPane/PanelMainlineChapter/PanelTopDifficult") + self.BtnNormal = self.Transform:Find("SafeAreaContentPane/PanelMainlineChapter/PanelTopDifficult/BtnNormal"):GetComponent("Button") + self.PanelNormalOn = self.Transform:Find("SafeAreaContentPane/PanelMainlineChapter/PanelTopDifficult/BtnNormal/PanelNormalOn") + self.PanelNormalOff = self.Transform:Find("SafeAreaContentPane/PanelMainlineChapter/PanelTopDifficult/BtnNormal/PanelNormalOff") + self.BtnHard = self.Transform:Find("SafeAreaContentPane/PanelMainlineChapter/PanelTopDifficult/BtnHard"):GetComponent("Button") + self.PanelHardOn = self.Transform:Find("SafeAreaContentPane/PanelMainlineChapter/PanelTopDifficult/BtnHard/PanelHardOn") + self.PanelHardOff = self.Transform:Find("SafeAreaContentPane/PanelMainlineChapter/PanelTopDifficult/BtnHard/PanelHardOff") + self.PanelMoney = self.Transform:Find("SafeAreaContentPane/PanelMainlineChapter/PanelMoney") + self.PanelMoenyGroup = self.Transform:Find("SafeAreaContentPane/PanelMainlineChapter/PanelMoney/PanelMoenyGroup") + self.PanelBountyTask = self.Transform:Find("SafeAreaContentPane/PanelMainlineChapter/PanelMoney/PanelMoenyGroup/PanelBountyTask") + self.PanelStart = self.Transform:Find("SafeAreaContentPane/PanelMainlineChapter/PanelMoney/PanelMoenyGroup/PanelBountyTask/PanelStart") + self.BtnSkip = self.Transform:Find("SafeAreaContentPane/PanelMainlineChapter/PanelMoney/PanelMoenyGroup/PanelBountyTask/PanelStart/BtnSkip"):GetComponent("Button") + self.TxtLevel = self.Transform:Find("SafeAreaContentPane/PanelMainlineChapter/PanelMoney/PanelMoenyGroup/PanelBountyTask/PanelStart/TxtLevel"):GetComponent("Text") + self.PanelComplete = self.Transform:Find("SafeAreaContentPane/PanelMainlineChapter/PanelMoney/PanelMoenyGroup/PanelBountyTask/PanelComplete") + self.BtnBountyTask = self.Transform:Find("SafeAreaContentPane/PanelMainlineChapter/PanelMoney/PanelMoenyGroup/PanelBountyTask/PanelComplete/BtnBountyTask"):GetComponent("Button") + self.PanelChapter = self.Transform:Find("SafeAreaContentPane/PanelMainlineChapter/PanelChapter") + self.BtnCloseDifficult = self.Transform:Find("SafeAreaContentPane/PanelMainlineChapter/BtnCloseDifficult"):GetComponent("Button") + self.BtnCloseDetail = self.Transform:Find("SafeAreaContentPane/PanelMainlineChapter/BtnCloseDetail"):GetComponent("Button") +end + +function XUiFubenMainLineChapter:AutoAddListener() + self:RegisterClickEvent(self.BtnTreasureBg, self.OnBtnTreasureBgClick) + self:RegisterClickEvent(self.Scrollbar, self.OnScrollbarClick) + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:RegisterClickEvent(self.BtnTreasure, self.OnBtnTreasureClick) + self:RegisterClickEvent(self.BtnSkip, self.OnBtnSkipClick) + self:RegisterClickEvent(self.BtnBountyTask, self.OnBtnBountyTaskClick) + self:RegisterClickEvent(self.BtnCloseDifficult, self.OnBtnCloseDifficultClick) + self:RegisterClickEvent(self.BtnCloseDetail, self.OnBtnCloseDetailClick) + + self.BtnExItem.CallBack = function() + self:OnBtnExItemClick() + end + self.BtnNormal.CallBack = function() + self:OnBtnNormalClick(true) + end + self.BtnHard.CallBack = function() + self:OnBtnHardClick(true) + end + self.BtnSwitch1MultipleWeeks.CallBack = function() + self:OnBtnSwitch1MultipleWeeksClick() + end + self.BtnSwitch2Normal.CallBack = function() + self:OnBtnSwitch2NormalClidk() + end + + if self.BtnHelp then + self.BtnHelp.CallBack = function() + self:OnBtnHelpClick() + end + end +end +-- auto +function XUiFubenMainLineChapter:OnBtnCloseDetailClick() + self:OnCloseStageDetail() +end + +function XUiFubenMainLineChapter:OnBtnCloseDifficultClick() + self:UpdateDifficultToggles() +end + +function XUiFubenMainLineChapter:OnScrollbarClick() + +end + +function XUiFubenMainLineChapter:OnBtnSkipClick() + +end + +function XUiFubenMainLineChapter:OnBtnBountyTaskClick() + +end + +function XUiFubenMainLineChapter:OnBtnExItemClick() + XLuaUiManager.Open("UiFubenExItemTip", self) +end + +function XUiFubenMainLineChapter:OnBtnHelpClick() + local helpContent = CS.XGame.ClientConfig:GetString("BfrtShowHelpTip02") + XUiManager.ShowHelpTip(helpContent) +end + +function XUiFubenMainLineChapter:OnBtnBackClick() + if self:CloseStageDetail() then + return + end + self:Close() +end + +function XUiFubenMainLineChapter:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiFubenMainLineChapter:OpenDifficultPanel() + +end + +function XUiFubenMainLineChapter:OnBtnNormalClick(IsAutoMove) + if self.IsShowDifficultPanel then + if self.CurDiff ~= XDataCenter.FubenManager.DifficultNormal then + local chapterInfo = XDataCenter.FubenMainLineManager.GetChapterInfoForOrderId(XDataCenter.FubenManager.DifficultNormal, self.Chapter.OrderId) + if not (chapterInfo and chapterInfo.Unlock) then + XUiManager.TipMsg(XDataCenter.FubenManager.GetFubenOpenTips(chapterInfo.FirstStage), XUiManager.UiTipType.Wrong) + return false + end + self.CurDiff = XDataCenter.FubenManager.DifficultNormal + XDataCenter.FubenMainLineManager.SetCurDifficult(self.CurDiff) + self:RefreshForChangeDiff(IsAutoMove) + end + self:UpdateDifficultToggles() + else + self:UpdateDifficultToggles(true) + end + return true +end + +function XUiFubenMainLineChapter:OnBtnHardClick(IsAutoMove) + if self.IsShowDifficultPanel then + if self.CurDiff ~= XDataCenter.FubenManager.DifficultHard then + -- 检查困难开启 + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.FubenDifficulty) then + return false + end + + -- 检查主线副本活动 + local chapterInfo = XDataCenter.FubenMainLineManager.GetChapterInfoForOrderId(XDataCenter.FubenManager.DifficultHard, self.Chapter.OrderId) + if chapterInfo.IsActivity then + local chapterId = XDataCenter.FubenMainLineManager.GetChapterIdByChapterMain(chapterInfo.ChapterMainId, XDataCenter.FubenManager.DifficultHard) + local ret, desc = XDataCenter.FubenMainLineManager.CheckActivityCondition(chapterId) + if not ret then + XUiManager.TipMsg(desc, XUiManager.UiTipType.Wrong) + return false + end + end + + -- 检查困难这个章节解锁 + if not chapterInfo or not chapterInfo.IsOpen then + local chapterId = XDataCenter.FubenMainLineManager.GetChapterIdByChapterMain(chapterInfo.ChapterMainId, XDataCenter.FubenManager.DifficultHard) + local isOpen, desc = XDataCenter.FubenMainLineManager.CheckOpenCondition(chapterId) + if not isOpen then + XUiManager.TipMsg(desc) + return false + end + local tipMsg = XDataCenter.FubenManager.GetFubenOpenTips(chapterInfo.FirstStage) + XUiManager.TipMsg(tipMsg) + --XUiManager.TipMsg(CS.XTextManager.GetText("FubenNeedComplatePreChapter"), XUiManager.UiTipType.Wrong) + return false + end + self.CurDiff = XDataCenter.FubenManager.DifficultHard + XDataCenter.FubenMainLineManager.SetCurDifficult(self.CurDiff) + self:RefreshForChangeDiff(IsAutoMove) + end + self:UpdateDifficultToggles() + else + self:UpdateDifficultToggles(true) + end + return true +end + +-- 点击切换到周目模式 +function XUiFubenMainLineChapter:OnBtnSwitch1MultipleWeeksClick() + self.IsOnZhouMu = true + self.TxtCurMWNum.text = self.ZhouMuNumber + local zhouMuChapter = XDataCenter.FubenZhouMuManager.GetZhouMuChapterData(self.MainChapterId, false) + + for _, v in pairs(self.GridChapterList) do + v:Hide() + end + + local data = { + Chapter = zhouMuChapter, + HideStageCb = handler(self, self.HideStageDetail), + ShowStageCb = handler(self, self.ShowStageDetail), + } + data.StageList = XFubenZhouMuConfigs.GetZhouMuChapterStages(zhouMuChapter.Id) + + local grid = self.CurChapterGrid + local prefabName = zhouMuChapter.PrefabName + if self.CurChapterGridName ~= prefabName then + local gameObject = self.PanelChapter:LoadPrefab(prefabName) + if gameObject == nil or not gameObject:Exist() then + return + end + + grid = XUiGridChapter.New(self, gameObject, nil, true) + grid.Transform:SetParent(self.PanelChapter, false) + self.CurChapterGridName = prefabName + self.CurChapterGrid = grid + self.GridChapterList[prefabName] = grid + end + + if self:CheckDetailOpen() then + self:HideStageDetail() + end + + grid:UpdateChapterGrid(data) + grid:Show() + + self:UpdateChapterStars() + self:UpdateChapterTxt() + self:SetPanelBottomActive(true) + + self.BtnSwitch1MultipleWeeks.gameObject:SetActiveEx(false) + self.BtnSwitch2Normal.gameObject:SetActiveEx(true) + self.TxtCurMWNum.gameObject:SetActiveEx(true) + self.PanelTopDifficult.gameObject:SetActiveEx(false) + self:PlayAnimation("AnimEnable2") +end + +function XUiFubenMainLineChapter:OnBtnSwitch2NormalClidk() + self.IsOnZhouMu = false + self:RefreshForChangeDiff(true) + + self.BtnSwitch1MultipleWeeks.gameObject:SetActiveEx(true) + self.BtnSwitch2Normal.gameObject:SetActiveEx(false) + self.TxtCurMWNum.gameObject:SetActiveEx(false) + if XUiManager.IsHideFunc then + self.PanelTopDifficult.gameObject:SetActiveEx(false) + else + self.PanelTopDifficult.gameObject:SetActiveEx(true) + end +end + +function XUiFubenMainLineChapter:UpdateDifficultToggles(showAll) + if showAll then + self:SetBtnTogleActive(true, true, true) + self.BtnCloseDifficult.gameObject:SetActiveEx(true) + else + if self.CurDiff == XDataCenter.FubenManager.DifficultNormal then + self:SetBtnTogleActive(true, false, false) + self.BtnNormal.transform:SetAsFirstSibling() + elseif self.CurDiff == XDataCenter.FubenManager.DifficultHard then + self:SetBtnTogleActive(false, true, false) + self.BtnHard.transform:SetAsFirstSibling() + else + self:SetBtnTogleActive(false, false, true) + end + self.BtnCloseDifficult.gameObject:SetActiveEx(false) + end + self.IsShowDifficultPanel = showAll + --progress + local pageDatas = XDataCenter.FubenMainLineManager.GetChapterMainTemplates(self.CurDiff) + local chapterIds = {} + for _, v in pairs(pageDatas) do + if v.OrderId == self.Chapter.OrderId then + chapterIds = v.ChapterId + break + end + end + self.TxtNormalProgress.text = XDataCenter.FubenMainLineManager.GetProgressByChapterId(chapterIds[1]) + self.TxtHardProgress.text = XDataCenter.FubenMainLineManager.GetProgressByChapterId(chapterIds[2]) + -- 抢先体验活动倒计时 + self:UpdateActivityTime() +end + +function XUiFubenMainLineChapter:UpdateChapterTxt() + local orderId = self.Chapter.OrderId + self.TxtChapter.text = orderId < 10 and "0" .. orderId or orderId + self.TxtChapterName.text = self.Chapter.ChapterEn +end + +function XUiFubenMainLineChapter:SetBtnTogleActive(isNormal, isHard) + self.BtnNormal.gameObject:SetActiveEx(isNormal) + + self.BtnHard.gameObject:SetActiveEx(isHard) + if isHard then + local hardOpen = XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.FubenDifficulty) + local chapterInfo = XDataCenter.FubenMainLineManager.GetChapterInfoForOrderId(XDataCenter.FubenManager.DifficultHard, self.Chapter.OrderId) + hardOpen = hardOpen and chapterInfo and chapterInfo.IsOpen + self.PanelHardOn.gameObject:SetActiveEx(hardOpen) + self.PanelHardOff.gameObject:SetActiveEx(not hardOpen) + end +end + +function XUiFubenMainLineChapter:RefreshForChangeDiff(IsAutoMove) + XDataCenter.FubenMainLineManager.SetCurDifficult(self.CurDiff) + local chapter + if self:CheckIsBfrtType() then + return + else + local chapterList = XDataCenter.FubenMainLineManager.GetChapterList(self.CurDiff) + chapter = XDataCenter.FubenMainLineManager.GetChapterCfg(chapterList[self.Chapter.OrderId]) + end + + self:UpdateCurChapter(chapter) + if IsAutoMove then + self:StageLevelChangeAutoMove() + end + self:PlayAnimation("AnimEnable2") +end + +function XUiFubenMainLineChapter:SetPanelBottomActive(isActive) + + local panelParent = self.IsExploreMod and self.ExPanel or self.NorPanel + self.PanelBottom.gameObject:SetActiveEx(isActive) + self.PanelExploreBottom.GameObject:SetActiveEx(isActive and self.IsExploreMod) + self.PanelBottom.transform:SetParent(panelParent, false) + self.PanelBottom.transform.localPosition = CS.UnityEngine.Vector3.zero + self.FubenEx.gameObject:SetActiveEx(self.IsExploreMod) +end + +function XUiFubenMainLineChapter:UpdateCurChapter(chapter) + if self.IsOnZhouMu then + -- 切换到周目模式 + self:OnBtnSwitch1MultipleWeeksClick() + return + end + + if not chapter then + return + end + self.Chapter = chapter + self.IsExploreMod = XDataCenter.FubenMainLineManager.CheckChapterTypeIsExplore(self.Chapter) + + local chapterInfo = XDataCenter.FubenMainLineManager.GetChapterInfo(chapter.ChapterId) + self.MainChapterId = chapterInfo and chapterInfo.ChapterMainId or 0 + for _, v in pairs(self.GridChapterList) do + v:Hide() + end + + local data = { + Chapter = self.Chapter, + HideStageCb = handler(self, self.HideStageDetail), + ShowStageCb = handler(self, self.ShowStageDetail), + } + + if self:CheckIsBfrtType() then + data.StageList = XDataCenter.BfrtManager.GetBaseStageList(self.Chapter.ChapterId) + else + data.StageList = XDataCenter.FubenMainLineManager.GetStageList(self.Chapter.ChapterId) + end + + local grid = self.CurChapterGrid + local prefabName = self.Chapter.PrefabName + if self.CurChapterGridName ~= prefabName then + local gameObject = self.PanelChapter:LoadPrefab(prefabName) + if gameObject == nil or not gameObject:Exist() then + return + end + + if self.IsExploreMod then + grid = XUiGridExploreChapter.New(self, gameObject) + else + grid = XUiGridChapter.New(self, gameObject) + end + grid.Transform:SetParent(self.PanelChapter, false) + self.CurChapterGridName = prefabName + self.CurChapterGrid = grid + self.GridChapterList[prefabName] = grid + end + + grid:UpdateChapterGrid(data) + grid:Show() + if self:CheckIsBfrtType() then + self:UpdatePanelBfrtTask() + else + self:UpdateChapterStars() + end + + if self.StageId then + self:OpenStage(self.StageId) + self.StageId = nil + end + + XEventManager.DispatchEvent(XEventId.EVENT_GUIDE_STEP_OPEN_EVENT) + self:UpdateChapterTxt() + self:UpdateExploreBottom() + self:SetPanelBottomActive(true) + self:UpdateFubenExploreItem() +end + +function XUiFubenMainLineChapter:UpdateExploreBottom() + if not self.IsExploreMod then + return + end + self.CanPlayList = {} + + local chapterList = XDataCenter.FubenMainLineManager.GetChapterList(XDataCenter.FubenManager.DifficultNormal) + local normalChapter = XDataCenter.FubenMainLineManager.GetChapterCfg(chapterList[self.Chapter.OrderId]) + + chapterList = XDataCenter.FubenMainLineManager.GetChapterList(XDataCenter.FubenManager.DifficultHard) + local hardChapter = XDataCenter.FubenMainLineManager.GetChapterCfg(chapterList[self.Chapter.OrderId]) + + self:SetCanPlayStageList(normalChapter, XDataCenter.FubenManager.DifficultNormal) + self:SetCanPlayStageList(hardChapter, XDataCenter.FubenManager.DifficultHard) + + self:ReSetQuickJumpButton(normalChapter, XDataCenter.FubenManager.DifficultNormal, self.PanelExploreBottom.BtnNormalJump) + self:ReSetQuickJumpButton(hardChapter, XDataCenter.FubenManager.DifficultHard, self.PanelExploreBottom.BtnHardlJump) + + if self.CurChapterGrid then + self.CurChapterGrid:SetCanPlayList(self.CanPlayList[self.CurDiff]) + end +end + +function XUiFubenMainLineChapter:SetCanPlayStageList(chapter, diff) + for index, stageId in pairs(chapter.StageId) do + if not self.CanPlayList[diff] then + self.CanPlayList[diff] = {} + end + + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + local IsEgg = stageCfg.StageType == XFubenConfigs.STAGETYPE_FIGHTEGG or stageCfg.StageType == XFubenConfigs.STAGETYPE_STORYEGG + local exploreInfoList = XDataCenter.FubenMainLineManager.GetExploreGroupInfoByGroupId(chapter.ExploreGroupId) + local exploreInfo = exploreInfoList[index] or {} + local IsShow = true + for _, idx in pairs(exploreInfo.PreShowIndex or {}) do + local Info = XDataCenter.FubenManager.GetStageInfo(chapter.StageId[idx]) + if not Info or not Info.Passed then + IsShow = IsShow and false + end + end + + if stageInfo.Unlock and IsShow then + if not stageInfo.Passed and not IsEgg then + table.insert(self.CanPlayList[diff], index) + end + end + end +end + +function XUiFubenMainLineChapter:ReSetQuickJumpButton(chapter, diff, jumpButton) + if not self.QuickJumpBtnList[diff] then + self.QuickJumpBtnList[diff] = {} + end + + local canPlayList = self.CanPlayList[diff] + local quickJumpBtnList = self.QuickJumpBtnList[diff] + local lenght = #canPlayList + + for i = 1, lenght do + local stageId = chapter.StageId[canPlayList[i]] + local quickJumpBtn = quickJumpBtnList[i] + if not quickJumpBtn then + local tempBtn = CS.UnityEngine.Object.Instantiate(jumpButton) + tempBtn.gameObject:SetActiveEx(true) + + quickJumpBtn = XUiFubenMainLineQuickJumpBtn.New(tempBtn, canPlayList[i], chapter, + function(index, clickStageId) + self:OnQuickJumpClick(diff, index) + XDataCenter.FubenMainLineManager.MarkNewJumpStageButtonEffectByStageId(clickStageId) + quickJumpBtn.Transform:GetComponent("XUiButton"):ShowTag(false) + end) + quickJumpBtnList[i] = quickJumpBtn + else + quickJumpBtn:UpdateNode(canPlayList[i], chapter) + quickJumpBtn.GameObject:SetActiveEx(true) + end + + quickJumpBtn.Transform:SetParent(self.transform, false) + quickJumpBtn.Transform:SetParent(self.PanelExploreBottom.PanelNodeList, false) + + XDataCenter.FubenMainLineManager.SaveNewJumpStageButtonEffect(stageId) + local IsHaveNew = XDataCenter.FubenMainLineManager.CheckHaveNewJumpStageButtonByStageId(stageId) + quickJumpBtn.Transform:GetComponent("XUiButton"):ShowTag(IsHaveNew) + end + + lenght = #quickJumpBtnList + for i = #canPlayList + 1, lenght do + quickJumpBtnList[i].GameObject:SetActiveEx(false) + end +end + +function XUiFubenMainLineChapter:OnQuickJumpClick(diff, index) + if diff ~= self.CurDiff then + local IsLock = false + self.IsShowDifficultPanel = true + if diff == XDataCenter.FubenManager.DifficultNormal then + IsLock = self:OnBtnNormalClick(false) + elseif diff == XDataCenter.FubenManager.DifficultHard then + IsLock = self:OnBtnHardClick(false) + end + + if IsLock then + self.CurChapterGrid:OnQuickJumpClick(index) + end + else + self.CurChapterGrid:OnQuickJumpClick(index) + end +end + +function XUiFubenMainLineChapter:CheckDetailOpen() + local childUi = self:GetCurDetailChildUi() + return XLuaUiManager.IsUiShow(childUi) +end + +function XUiFubenMainLineChapter:ShowStageDetail(stage) + self.PanelMoney.gameObject:SetActiveEx(false) + self.Stage = stage + if self.IsExploreMod or self.IsOnZhouMu then + self:OpenExploreDetail() + else + local childUi = self:GetCurDetailChildUi() + self:OpenOneChildUi(childUi, self) + end +end + +function XUiFubenMainLineChapter:OnEnterStory(stageId) + self.Stage = XDataCenter.FubenManager.GetStageCfg(stageId) + local childUi = self:GetCurDetailChildUi() + self:OpenOneChildUi(childUi, self) +end + +function XUiFubenMainLineChapter:HideStageDetail() + if not self.Stage then + return + end + + local childUi = self:GetCurDetailChildUi() + local childUiObj = self:FindChildUiObj(childUi) + if childUiObj then + childUiObj:Hide() + end +end + +function XUiFubenMainLineChapter:OnCloseStageDetail() + if self.BountyInfo and #self.BountyInfo.TaskCards > 0 then + local taskCards = self.BountyInfo.TaskCards + for i = 1, XDataCenter.BountyTaskManager.MAX_BOUNTY_TASK_COUNT do + if taskCards[i] and taskCards[i].Status ~= XDataCenter.BountyTaskManager.BountyTaskStatus.AcceptReward then + self.PanelMoney.gameObject:SetActiveEx(true and not self.IsExploreMod) + end + end + end + if self.CurChapterGrid then + self.CurChapterGrid:CancelSelect() + end +end + +function XUiFubenMainLineChapter:UpdateBfrtRewards() + local chapterId = self.Chapter.ChapterId + local taskId = XDataCenter.BfrtManager.GetBfrtTaskId(chapterId) + local taskConfig = XDataCenter.TaskManager.GetTaskTemplate(taskId) + local rewardId = taskConfig.RewardId + local rewards = XRewardManager.GetRewardList(rewardId) + + self.BfrtRewardGrids = self.BfrtRewardGrids or {} + local rewardsNum = #rewards + for i = 1, rewardsNum do + local grid = self.BfrtRewardGrids[i] + if not grid then + local go = i == 1 and self.GridCommonPopUp or CS.UnityEngine.Object.Instantiate(self.GridCommonPopUp) + grid = XUiGridCommon.New(self, go) + self.BfrtRewardGrids[i] = grid + end + grid:Refresh(rewards[i]) + grid.Transform:SetParent(self.PanelBfrtRewrds, false) + grid.GameObject:SetActiveEx(true) + end + for i = rewardsNum + 1, #self.BfrtRewardGrids do + self.BfrtRewardGrids[i].GameObject:SetActiveEx(false) + end +end + +function XUiFubenMainLineChapter:OnCheckBfrtRewards(count) + self.ImgRedProgressA.gameObject:SetActiveEx(count >= 0) +end + +function XUiFubenMainLineChapter:UpdatePanelBfrtTask() + local chapterId = self.Chapter.ChapterId + self.ImgJindu.gameObject:SetActiveEx(false) + self.ImgLingqu.gameObject:SetActiveEx(XDataCenter.BfrtManager.CheckAllTaskRewardHasGot(chapterId)) + self.PanelDesc.gameObject:SetActiveEx(false) + self.PanelBfrtTask.gameObject:SetActiveEx(true) + + self:UpdateBfrtRewards() + XRedPointManager.Check(self.RedPointBfrtId, self.Chapter.ChapterId) +end + +-- 更新左下角的奖励按钮的状态 +function XUiFubenMainLineChapter:UpdateChapterStars() + local curStars + local totalStars + local received = true + + self.PanelBfrtTask.gameObject:SetActiveEx(false) + self.PanelDesc.gameObject:SetActiveEx(true) + + if self.IsOnZhouMu then + -- 周目奖励 + self.MultipleWeeksTxet.gameObject:SetActiveEx(true) + self.TxtDesc.gameObject:SetActiveEx(false) + self.ImgStarIcon.gameObject:SetActiveEx(false) + + curStars, totalStars = XDataCenter.FubenZhouMuManager.GetZhouMuTaskProgress(self.ZhouMuId) + received = XDataCenter.FubenZhouMuManager.ZhouMuTaskIsAllFinish(self.ZhouMuId) + + XRedPointManager.Check(self.RedPointZhouMuId, self.ZhouMuId) + else + -- 主线收集奖励 + curStars, totalStars = XDataCenter.FubenMainLineManager.GetChapterStars(self.Chapter.ChapterId) + local chapterTemplate = XDataCenter.FubenMainLineManager.GetChapterCfg(self.Chapter.ChapterId) + + for _, v in pairs(chapterTemplate.TreasureId) do + if not XDataCenter.FubenMainLineManager.IsTreasureGet(v) then + received = false + break + end + end + + self.MultipleWeeksTxet.gameObject:SetActiveEx(false) + self.TxtDesc.gameObject:SetActiveEx(true) + self.ImgStarIcon.gameObject:SetActiveEx(true) + + XRedPointManager.Check(self.RedPointId, self.Chapter.ChapterId) + end + + self.ImgJindu.fillAmount = totalStars > 0 and curStars / totalStars or 0 + self.ImgJindu.gameObject:SetActiveEx(true) + self.TxtStarNum.text = CS.XTextManager.GetText("Fract", curStars, totalStars) + self.ImgLingqu.gameObject:SetActiveEx(received) +end + +function XUiFubenMainLineChapter:OnBtnTreasureClick() + if self:CloseStageDetail() then + return + end + if self:CheckIsBfrtType() then + local chapterId = self.Chapter.ChapterId + if XDataCenter.BfrtManager.CheckAllTaskRewardHasGot(chapterId) then + XUiManager.TipText("TaskAlreadyFinish") + return + elseif not XDataCenter.BfrtManager.CheckAnyTaskRewardCanGet(chapterId) then + XUiManager.TipText("TaskDoNotFinish") + return + end + + local taskId = XDataCenter.BfrtManager.GetBfrtTaskId(chapterId) + XDataCenter.TaskManager.FinishTask(taskId, function(rewardGoodsList) + XUiManager.OpenUiObtain(rewardGoodsList) + self:UpdatePanelBfrtTask() + end) + else + self:InitTreasureGrade() + self.PanelTreasure.gameObject:SetActiveEx(true) + self.PanelTop.gameObject:SetActiveEx(true) + self:SetPanelBottomActive(true) + end + self:PlayAnimation("TreasureEnable") +end + +function XUiFubenMainLineChapter:CloseStageDetail() + if self:CheckDetailOpen() then + if self.CurChapterGrid then + self.CurChapterGrid:ScrollRectRollBack() + end + self:HideStageDetail() + return true + end + return false +end + +function XUiFubenMainLineChapter:OnBtnTreasureBgClick() + self:PlayAnimation("TreasureDisable", handler(self, function() + self.PanelTreasure.gameObject:SetActiveEx(false) + self.PanelTop.gameObject:SetActiveEx(true) + self:SetPanelBottomActive(true) + if not self:CheckIsBfrtType() then + self:UpdateChapterStars() + end + end)) +end + +-- 初始化 treasure grade grid panel,填充数据 +-- 周目奖励和进度奖励使用不同的Grid模板,用GridTreasureList、GridMultipleWeeksTaskList分别存储 +function XUiFubenMainLineChapter:InitTreasureGrade() + local baseItem = self.IsOnZhouMu and self.GridMultipleWeeksTask or self.GridTreasureGrade + self.GridMultipleWeeksTask.gameObject:SetActiveEx(false) + self.GridTreasureGrade.gameObject:SetActiveEx(false) + + -- 先把所有的格子隐藏 + for j = 1, #self.GridTreasureList do + self.GridTreasureList[j].GameObject:SetActiveEx(false) + end + for j = 1, #self.GridMultipleWeeksTaskList do + self.GridMultipleWeeksTaskList[j].GameObject:SetActiveEx(false) + end + + local targetList + if self.IsOnZhouMu then + targetList = XFubenZhouMuConfigs.GetZhouMuTasks(self.ZhouMuId) + else + targetList = self.Chapter.TreasureId + end + if not targetList then + return + end + + local offsetValue = 260 + local gridCount = #targetList + + for i = 1, gridCount do + local offerY = (1 - i) * offsetValue + local grid + if self.IsOnZhouMu then + grid = self.GridMultipleWeeksTaskList[i] + else + grid = self.GridTreasureList[i] + end + + if not grid then + local item = CS.UnityEngine.Object.Instantiate(baseItem) -- 复制一个item + grid = XUiGridTreasureGrade.New(self, item) + grid.Transform:SetParent(self.PanelGradeContent, false) + grid.Transform.localPosition = CS.UnityEngine.Vector3(item.transform.localPosition.x, item.transform.localPosition.y + offerY, item.transform.localPosition.z) + if self.IsOnZhouMu then + self.GridMultipleWeeksTaskList[i] = grid + else + self.GridTreasureList[i] = grid + end + + end + + if self.IsOnZhouMu then + grid:UpdateGradeGridTask(targetList[i]) + else + local treasureCfg = XDataCenter.FubenMainLineManager.GetTreasureCfg(targetList[i]) + local chapterInfo = XDataCenter.FubenMainLineManager.GetChapterInfo(self.Chapter.ChapterId) + grid:UpdateGradeGrid(chapterInfo.Stars, treasureCfg, self.Chapter.ChapterId) + end + + grid:InitTreasureList() + grid.GameObject:SetActiveEx(true) + end +end + +function XUiFubenMainLineChapter:OnSyncStage(stageId) + if not stageId then + return + end + local stageData = XDataCenter.FubenManager.GetStageData(stageId) + if not stageData then + return + end + if stageData.PassTimesToday > 1 then + return + end + if not self.CurDiff or self.CurDiff < 0 then + return + end + + local chapter = self:GetChapterCfgByStageId(stageId) + if chapter then + self:UpdateCurChapter(chapter) + end + + if self.CurChapterGrid then + if self.CurChapterGrid.IsNotPassedFightStage then + self.IsCanGoNearestStage = true + end + end + +end + +--设置任务卡 +function XUiFubenMainLineChapter:InitBountyTask() + self.TaskGrid = {} + self.TaskGrid[1] = XUiPanelBountyTask.New(self.PanelBountyTask, self) + self.PanelMoney.gameObject:SetActiveEx(false) + + for i = 2, XDataCenter.BountyTaskManager.MAX_BOUNTY_TASK_COUNT do + local ui = CS.UnityEngine.Object.Instantiate(self.PanelBountyTask) + self.TaskGrid[i] = XUiPanelBountyTask.New(ui, self) + self.TaskGrid[i].Transform:SetParent(self.PanelMoenyGroup, false) + self.TaskGrid[i].GameObject:SetActiveEx(false) + end +end + +--设置赏金任务标签 +function XUiFubenMainLineChapter:SetupBountyTask() + self.PanelMoney.gameObject:SetActiveEx(false) + + self.BountyInfo = XDataCenter.BountyTaskManager.GetBountyTaskInfo() + if not self.BountyInfo or #self.BountyInfo.TaskCards <= 0 then + self.PanelMoney.gameObject:SetActiveEx(false) + return + end + + local taskCards = self.BountyInfo.TaskCards + for i = 1, XDataCenter.BountyTaskManager.MAX_BOUNTY_TASK_COUNT do + if taskCards[i] and taskCards[i].Status ~= XDataCenter.BountyTaskManager.BountyTaskStatus.AcceptReward then + self.TaskGrid[i]:SetupContent(taskCards[i]) + self.TaskGrid[i].GameObject:SetActiveEx(true) + self.PanelMoney.gameObject:SetActiveEx(true and not self.IsExploreMod) + + else + self.TaskGrid[i]:SetActiveEx(false) + end + end +end + +function XUiFubenMainLineChapter:CheckIsBfrtType() + return self.CurDiff and self.CurDiff == XDataCenter.FubenManager.DifficultNightmare +end + +function XUiFubenMainLineChapter:GetChapterCfgByStageId(stageId) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + local chapter + if XDataCenter.BfrtManager.CheckStageTypeIsBfrt(stageId) then + chapter = XDataCenter.BfrtManager.GetChapterCfg(stageInfo.ChapterId) + elseif stageInfo.Type == XDataCenter.FubenManager.StageType.Mainline then + chapter = XDataCenter.FubenMainLineManager.GetChapterCfg(stageInfo.ChapterId) + else + return + end + + return chapter +end + +function XUiFubenMainLineChapter:OnGetEvents() + return { XEventId.EVENT_FUBEN_CLOSE_FUBENSTAGEDETAIL, XEventId.EVENT_FUBEN_ENTERFIGHT } +end + +--事件监听 +function XUiFubenMainLineChapter:OnNotify(evt, ...) + if evt == XEventId.EVENT_FUBEN_CLOSE_FUBENSTAGEDETAIL then + self:OnCloseStageDetail() + elseif evt == XEventId.EVENT_FUBEN_ENTERFIGHT then + self:EnterFight(...) + end +end + +function XUiFubenMainLineChapter:UpdateActivityTime() + if self:CheckIsBfrtType() or not XDataCenter.FubenMainLineManager.IsMainLineActivityOpen() then + self:DestroyActivityTimer() + self.PanelActivityTime.gameObject:SetActiveEx(false) + return + end + + self:CreateActivityTimer() + + local curDiffHasActivity = XDataCenter.FubenMainLineManager.CheckDiffHasAcitivity(self.Chapter) + self.PanelActivityTime.gameObject:SetActiveEx(curDiffHasActivity) +end + +function XUiFubenMainLineChapter:UpdateFubenExploreItem() + local itemCurCount = #XDataCenter.FubenMainLineManager.GetChapterExploreItemList(self.MainChapterId) + self.PanelFubenExItem.gameObject:SetActiveEx(itemCurCount > 0 and self.IsExploreMod) +end + +function XUiFubenMainLineChapter:CreateActivityTimer() + self:DestroyActivityTimer() + + local time = XTime.GetServerNowTimestamp() + local endTime = XDataCenter.FubenMainLineManager.GetActivityEndTime() + self.TxtLeftTime.text = XUiHelper.GetTime(endTime - time, XUiHelper.TimeFormatType.ACTIVITY) + self.ActivityTimer = XScheduleManager.ScheduleForever(function() + if XTool.UObjIsNil(self.TxtLeftTime) then + self:DestroyActivityTimer() + return + end + + local leftTime = endTime - time + time = time + 1 + + if leftTime >= 0 then + self.TxtLeftTime.text = XUiHelper.GetTime(leftTime, XUiHelper.TimeFormatType.ACTIVITY) + else + self:DestroyActivityTimer() + XDataCenter.FubenMainLineManager.OnActivityEnd() + end + end, XScheduleManager.SECOND, 0) +end + +function XUiFubenMainLineChapter:DestroyActivityTimer() + if self.ActivityTimer then + XScheduleManager.UnSchedule(self.ActivityTimer) + self.ActivityTimer = nil + end +end + +function XUiFubenMainLineChapter:GetCurDetailChildUi() + local stageCfg = self.Stage + if not stageCfg then return "" end + + if XDataCenter.BfrtManager.CheckStageTypeIsBfrt(stageCfg.StageId) then + return "UiBfrtStageDetail" + elseif stageCfg.StageType == XFubenConfigs.STAGETYPE_STORY or stageCfg.StageType == XFubenConfigs.STAGETYPE_STORYEGG then + return "UiStoryStageDetail" + else + return "UiFubenMainLineDetail" + end +end + +function XUiFubenMainLineChapter:GoToStage(stageId) + if self.CurChapterGrid then + self.CurChapterGrid:GoToStage(stageId) + end +end + +function XUiFubenMainLineChapter:OpenExploreDetail() + XLuaUiManager.Open("UiFubenExploreDetail", self, self.Stage, function() + if (self.CurChapterGrid or {}).ScaleBack then + self.CurChapterGrid:ScaleBack() + end + self:OnCloseStageDetail() + end) +end + +function XUiFubenMainLineChapter:OnCheckExploreItemNews(count) + self.BtnExItem:ShowReddot(count >= 0) +end + +function XUiFubenMainLineChapter:OnAutoFightStart(stageId) + if self.Stage.StageId == stageId and self.IsExploreMod then + if self.CurChapterGrid then + self.CurChapterGrid:ScaleBack() + end + self:OnCloseStageDetail() + XLuaUiManager.Remove("UiFubenExploreDetail") + end +end + +function XUiFubenMainLineChapter:OnReleaseInst() + return {Chapter = self.Chapter, StageId = self.StageId, HideDiffTog = self.HideDiffTog} +end + +function XUiFubenMainLineChapter:OnResume(data) + self.LastData = data +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiFubenMainLineQuickJumpBtn.lua b/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiFubenMainLineQuickJumpBtn.lua new file mode 100644 index 00000000..3b46964c --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiFubenMainLineQuickJumpBtn.lua @@ -0,0 +1,31 @@ +XUiFubenMainLineQuickJumpBtn = XClass(nil, "XUiFubenMainLineQuickJumpBtn") +function XUiFubenMainLineQuickJumpBtn:Ctor(ui, index, chapter, cb, stageType) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Index = index + self.Cb = cb + self.StageType = stageType or XDataCenter.FubenManager.StageType.Mainline + XTool.InitUiObject(self) + self.BtnNormalDot.CallBack = function() self:OnBtnNodeClick() end + self:UpdateNode(self.Index, chapter) +end + +function XUiFubenMainLineQuickJumpBtn:OnBtnNodeClick() + self.Cb(self.Index,self.StageId) +end + +function XUiFubenMainLineQuickJumpBtn:UpdateNode(index, chapter) + self.StageId = chapter.StageId[index] + local stageCfg = XDataCenter.FubenManager.GetStageCfg(self.StageId) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(self.StageId) + self.Index = index + local title + if stageInfo.Type == XDataCenter.FubenManager.StageType.ExtraChapter then + title = XDataCenter.ExtraChapterManager.GetChapterDetailsStageTitle(stageInfo.ChapterId) + title = string.gsub(title, "EX", "") + else + title = chapter.OrderId + end + title = title or "" + self.TxtName.text = string.format("%s-%d", tostring(title), stageCfg.OrderId) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiGridChapter.lua b/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiGridChapter.lua new file mode 100644 index 00000000..c6799b4a --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiGridChapter.lua @@ -0,0 +1,588 @@ +local XUiGridStage = require("XUi/XUiFubenMainLineChapter/XUiGridStage") + +local XUiGridChapter = XClass(nil, "XUiGridChapter") + +local MAX_STAGE_COUNT = CS.XGame.ClientConfig:GetInt("MainLineStageMaxCount") + +function XUiGridChapter:Ctor(rootUi, ui, autoChangeBgArgs, isOnZhouMu) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.IsOnZhouMu = isOnZhouMu + self.RectTransform = self.Transform:GetComponent("RectTransform") + self.GridStageList = {} + self.GridEggStageList = {} + self.LineList = {} + XTool.InitUiObject(self) + self:InitAutoScript() + + -- 周目模式,记录当前周目章节最后一关的初始通关状态 + if self.IsOnZhouMu then + self.zhouMuChapterId = XDataCenter.FubenZhouMuManager.GetZhouMuChapterIdByZhouMuId(self.RootUi.ZhouMuId) + + local lastStage = XFubenZhouMuConfigs.GetZhouMuChapterLastStage(self.zhouMuChapterId) + self.OriLastStageIsPass = XDataCenter.FubenManager.CheckStageIsPass(lastStage) + end + + --配置的格子位移超过某个阀值时,更换背景图片 + if not XTool.IsTableEmpty(autoChangeBgArgs) then + self.AutoChangeBgArgs = autoChangeBgArgs + local behaviour = self.GameObject:AddComponent(typeof(CS.XLuaBehaviour)) + if self.Update then + behaviour.LuaUpdate = function() self:Update() end + end + end + + -- ScrollRect的点击和拖拽会触发关闭详细面板 + self:RegisterClickEvent(self.ScrollRect, handler(self, self.CancelSelect)) + local dragProxy = self.ScrollRect.gameObject:AddComponent(typeof(CS.XUguiDragProxy)) + dragProxy:RegisterHandler(handler(self, self.OnDragProxy)) + self:OnEnable() + + --读取自定义颜色数据 + self.Colors = { + TxtChapterNameColor = self.TxtChapterNameColor ~= nil and self.TxtChapterNameColor.color, + TxtLeftTimeTipColor = self.TxtLeftTimeTipColor ~= nil and self.TxtLeftTimeTipColor.color, + TxtLeftTimeColor = self.TxtLeftTimeColor ~= nil and self.TxtLeftTimeColor.color, + StarColor = self.StarColor ~= nil and self.StarColor.color, + StarDisColor = self.StarDisColor ~= nil and self.StarDisColor.color, + ImageBottomColor = self.ImageBottomColor ~= nil and self.ImageBottomColor.color, + TxtStarNumColor = self.TxtStarNumColor ~= nil and self.TxtStarNumColor.color, + TxtDescrColor = self.TxtDescrColor ~= nil and self.TxtDescrColor.color, + Triangle0Color = self.Triangle0Color ~= nil and self.Triangle0Color.color, + Triangle1Color = self.Triangle1Color ~= nil and self.Triangle1Color.color, + Triangle2Color = self.Triangle2Color ~= nil and self.Triangle2Color.color, + Triangle3Color = self.Triangle3Color ~= nil and self.Triangle3Color.color + } + if self.PanelColors then + self.PanelColors.gameObject:SetActiveEx(false) + end +end + +function XUiGridChapter:GetColors() + return self.Colors +end + +function XUiGridChapter:InitAutoChangeBgComponents() + if XTool.IsTableEmpty(self.AutoChangeBgArgs) then return end + + local datumLinePrecent = self.AutoChangeBgArgs.DatumLinePrecent + if not datumLinePrecent or datumLinePrecent == 0 then return end + + --阀值为滚动容器去掉自适应扩展的padding宽度之后的实际宽度/2 + -- local padding = self.BoundSizeFitter.padding + -- local contentWidth = self.PanelStageContent.rect.width + -- local realWidth = contentWidth - padding.left - padding.right + --阀值修改为可视区中心 + local viewPortRect = XUiHelper.TryGetComponent(self.Transform, "PaneStageList/ViewPort", "RectTransform") + if not viewPortRect then return end + local realWidth = viewPortRect.rect.width + self.LimitPosX = realWidth * datumLinePrecent +end + +function XUiGridChapter:RefreshAutoChangeBgStageIndex() + if not self.LimitPosX then return end + + --关卡格子相对于阀值点的位置 + local stageIndex = self.AutoChangeBgArgs.StageIndex + if not stageIndex or stageIndex == 0 then return end + + local stageTransform = self.PanelStageContent.transform:Find("Stage" .. stageIndex) + if XTool.UObjIsNil(stageTransform) then + XLog.Error("XUiGridChapter:RefreshAutoChangeBgStageIndex error:stage not exist,stageIndex is:" .. stageIndex) + return + end + + local stageParent = stageTransform:GetComponent("RectTransform") + if XTool.UObjIsNil(stageParent) then + XLog.Error("XUiGridChapter:RefreshAutoChangeBgStageIndex error:stage parent not exist,stageIndex is:" .. stageIndex) + return + end + + if not stageParent.gameObject.activeSelf then self.FirstSetBg = true return end + self.StagePosX = stageParent.anchoredPosition.x + + --滚动容器移动距离 + local delta = self.PanelStageContent.anchoredPosition.x + -- delta = self.StagePosX > self.LimitPosX and -delta or delta + --标记是否满足超过阀值的条件 + self.AutoChangeBgFlag = self.StagePosX + delta > self.LimitPosX + self.FirstSetBg = self.AutoChangeBgFlag +end + +--配置的格子滑动位移超过某个阀值时触发一次回调 +function XUiGridChapter:Update() + if self.AutoChangeBgFlag == nil then return end + + local cbParamFlag = self.AutoChangeBgFlag--回调参数 + local delta = self.PanelStageContent.anchoredPosition.x--滚动容器移动距离 + local fitCondition = self.StagePosX + delta > self.LimitPosX--滑动距离条件判断 + + + --配置的格子在阀值左边还是右边 + local moveDirectLeft = self.StagePosX > self.LimitPosX + if moveDirectLeft then + cbParamFlag = not cbParamFlag + --delta = -delta + fitCondition = not fitCondition + end + + --滑动距离条件判断 + if fitCondition then + if self.AutoChangeBgFlag then + --位移正向超过阀值回调 + self.AutoChangeBgArgs.AutoChangeBgCb(cbParamFlag) + self.AutoChangeBgFlag = false + end + else + if not self.AutoChangeBgFlag then + --位移反向超过阀值回调 + self.AutoChangeBgArgs.AutoChangeBgCb(cbParamFlag) + self.AutoChangeBgFlag = true + end + end +end + +function XUiGridChapter:OnDragProxy(dragType) + if dragType == 0 then + self:OnScrollRectBeginDrag() + elseif dragType == 2 then + self:OnScrollRectEndDrag() + end +end + +function XUiGridChapter:OnScrollRectBeginDrag() + if self:CancelSelect() then + self.ScrollRect.enabled = false + end +end + +function XUiGridChapter:OnScrollRectEndDrag() + self.ScrollRect.enabled = true +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiGridChapter:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiGridChapter:AutoInitUi() + self.PanelStageContent = XUiHelper.TryGetComponent(self.Transform, "PaneStageList/ViewPort/PanelStageContent", "RectTransform") + self.BoundSizeFitter = XUiHelper.TryGetComponent(self.Transform, "PaneStageList/ViewPort/PanelStageContent", "XBoundSizeFitter") + self.SViewStageList = XUiHelper.TryGetComponent(self.Transform, "SViewStageList", "ScrollRect") + self.ScrollRect = XUiHelper.TryGetComponent(self.Transform, "PaneStageList", "ScrollRect") + -- 连线 + for i = 1, MAX_STAGE_COUNT do + if not self.LineList[i] then + local line = self.PanelStageContent.transform:Find("Line" .. i) + self.LineList[i] = not XTool.UObjIsNil(line) and line + end + end +end + +function XUiGridChapter:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiGridChapter:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiGridChapter:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiGridChapter:AutoAddListener() + --self:RegisterClickEvent(self.SViewStageList, self.OnSViewStageListClick) +end +-- auto +function XUiGridChapter:ScrollRectRollBack() + -- 滚动容器回弹 + local width = self.RectTransform.rect.width + local innerWidth = self.PanelStageContent.rect.width + innerWidth = innerWidth < width and width or innerWidth + local diff = innerWidth - width + local tarPosX + if self.PanelStageContent.localPosition.x < -width / 2 - diff then + tarPosX = -width / 2 - diff + elseif self.PanelStageContent.localPosition.x > -width / 2 then + tarPosX = -width / 2 + else + -- self.ScrollRect.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Unrestricted + self.ScrollRect.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Elastic + return false + end + + self:PlayScrollViewMoveBack(tarPosX) + return true +end + +function XUiGridChapter:PlayScrollViewMoveBack(tarPosX) + local tarPos = self.PanelStageContent.localPosition + tarPos.x = tarPosX + XLuaUiManager.SetMask(true) + + XUiHelper.DoMove(self.PanelStageContent, tarPos, XDataCenter.FubenMainLineManager.UiGridChapterMoveDuration, XUiHelper.EaseType.Sin, function() + -- self.ScrollRect.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Unrestricted + self.ScrollRect.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Elastic + XLuaUiManager.SetMask(false) + end) +end + +function XUiGridChapter:GetGridByStageId(stageId) + if self.NormalStageList then + for k, v in pairs(self.NormalStageList) do + if v == stageId then + return self.GridStageList[k] + end + end + end + if self.EggStageList then + for k, v in pairs(self.EggStageList) do + if v == stageId then + return self.GridEggStageList[k] + end + end + end + return nil +end + +function XUiGridChapter:GoToStage(stageId) + local grid = self:GetGridByStageId(stageId) + if not grid then + return + end + local gridTf = grid.Parent.gameObject:GetComponent("RectTransform") + --local posX = self.PanelStageContent.localPosition.x + local posX = gridTf.localPosition.x - self.RectTransform.rect.width / 2 + self.ScrollRect.horizontalNormalizedPosition = 0 + -- local diff = (self.ScrollRect.content.rect.width - self.RectTransform.rect.width) + self.ScrollRect.horizontalNormalizedPosition = posX / (1 * self.ScrollRect.content.rect.width - self.RectTransform.rect.width) +end + +-- chapter 组件内容更新 +function XUiGridChapter:UpdateChapterGrid(data) + self.Chapter = data.Chapter + self.HideStageCb = data.HideStageCb + self.ShowStageCb = data.ShowStageCb + + self.EggStageList = {} + self.NormalStageList = {} + for _, v in pairs(data.StageList) do + local stageCfg = XDataCenter.FubenManager.GetStageCfg(v) + if self:IsEggStage(stageCfg) then + local eggNum = self:GetEggNum(data.StageList, stageCfg) + if eggNum ~= 0 then + local egg = { Id = v, Num = eggNum } + table.insert(self.EggStageList, egg) + end + else + table.insert(self.NormalStageList, v) + end + end + + self:SetStageList() + self:InitAutoChangeBgComponents() + + CS.XTool.WaitForEndOfFrame(function() + self:RefreshAutoChangeBgStageIndex() + end) +end + +-- 根据stageId选中 +function XUiGridChapter:ClickStageGridByStageId(selectStageId) + if not selectStageId then return end + local IsEggStage = false + local stageInfo = XDataCenter.FubenManager.GetStageInfo(selectStageId) + if not stageInfo.IsOpen then return end + + local index = 0 + for i = 1, #self.NormalStageList do + local stageId = self.NormalStageList[i] + if selectStageId == stageId then + index = i + break + end + end + for i = 1, #self.EggStageList do + local stageId = self.EggStageList[i] + if selectStageId == stageId then + index = i + IsEggStage = true + break + end + end + + if index ~= 0 then + if IsEggStage then + self:ClickEggStageGridByIndex(index) + else + self:ClickStageGridByIndex(index) + end + end +end + +function XUiGridChapter:GetEggNum(stageList, eggStageCfg) + for k, v in pairs(stageList) do + if v == eggStageCfg.PreStageId[1] then --1为1号前置关卡 + return k + end + end + return 0 +end + +function XUiGridChapter:SetStageList() + if self.NormalStageList == nil then + XLog.Error("Chapter have no id " .. self.Chapter.ChapterId) + return + end + + -- 初始化副本显示列表,i作为order id,从1开始 + for i = 1, #self.NormalStageList do + local stageId = self.NormalStageList[i] + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + + if stageInfo.IsOpen or self.IsOnZhouMu then + local grid = self.GridStageList[i] + if not grid then + local uiName + if stageInfo.Type == XDataCenter.FubenManager.StageType.ActivtityBranch then + uiName = "GridBranchStage" + elseif stageInfo.Type == XDataCenter.FubenManager.StageType.ActivityBossSingle then + uiName = "GridActivityBossSingleStage" + elseif stageInfo.Type == XDataCenter.FubenManager.StageType.RepeatChallenge then + uiName = "GridRepeatChallengeStage" + else + uiName = "GridStage" + end + uiName = stageCfg.StageGridStyle and uiName .. stageCfg.StageGridStyle or uiName + + local parent = self.PanelStageContent.transform:Find("Stage" .. i) + local prefabName = CS.XGame.ClientConfig:GetString(uiName) + local prefab = parent:LoadPrefab(prefabName) + + grid = XUiGridStage.New(self.RootUi, prefab, handler(self, self.ClickStageGrid), XFubenConfigs.FUBENTYPE_NORMAL, false, self.IsOnZhouMu) + grid.Parent = parent + self.GridStageList[i] = grid + end + + grid:UpdateStageMapGrid(stageCfg, self.Chapter.OrderId) + grid.Parent.gameObject:SetActive(true) + + self:SetLineActive(i, true) + end + end + + for i = 1, #self.EggStageList do + local stageId = self.EggStageList[i].Id + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + + if stageInfo.IsOpen then + if XDataCenter.FubenManager.GetUnlockHideStageById(stageId) then + local grid = self.GridEggStageList[i] + if not grid then + local uiName = "GridStageSquare" + local parentsParent = self.PanelStageContent.transform:Find("Stage" .. self.EggStageList[i].Num) + local parent = self.PanelStageContent.transform:Find("Stage" .. self.EggStageList[i].Num .. "/EggStage") + local prefabName = CS.XGame.ClientConfig:GetString(uiName) + local prefab = parent:LoadPrefab(prefabName) + grid = XUiGridStage.New(self.RootUi, prefab, handler(self, self.ClickStageGrid), XFubenConfigs.FUBENTYPE_NORMAL) + grid.Parent = parentsParent + self.GridEggStageList[i] = grid + end + grid:UpdateStageMapGrid(stageCfg, self.Chapter.OrderId) + end + end + end + + local activeStageCount = #self.GridStageList + for i = activeStageCount + 1, MAX_STAGE_COUNT do + local parent = self.PanelStageContent.transform:Find("Stage" .. i) + if parent then + parent.gameObject:SetActive(false) + end + + self:SetLineActive(i, false) + end + + -- 移动至ListView正确的位置 + if self.BoundSizeFitter then + self.BoundSizeFitter:SetLayoutHorizontal() + end +end + +function XUiGridChapter:SetLineActive(index, active) + local line = self.LineList[index - 1] + if line then + line.gameObject:SetActive(active) + end +end + +-- 选中一个 stage grid +function XUiGridChapter:ClickStageGrid(grid) + local curGrid = self.CurStageGrid + if curGrid and curGrid.Stage.StageId == grid.Stage.StageId then + return + end + + local stageInfo = XDataCenter.FubenManager.GetStageInfo(grid.Stage.StageId) + if not stageInfo.Unlock then + XUiManager.TipMsg(XDataCenter.FubenManager.GetFubenOpenTips(grid.Stage.StageId)) + return + end + + -- 选中回调 + if self.ShowStageCb then + self.ShowStageCb(grid.Stage, grid.ChapterOrderId) + end + + if stageInfo.Type == XDataCenter.FubenManager.StageType.ActivityBossSingle then + return + end + + -- 取消上一个选择 + if curGrid then + curGrid:SetStageActive() + curGrid:SetStoryStageActive() + end + + -- 选中当前选择 + grid:SetStageSelect() + + grid:SetStoryStageSelect() + + if not self.IsOnZhouMu then + -- 滚动容器自由移动 + self.ScrollRect.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Unrestricted + -- 面板移动 + self:PlayScrollViewMove(grid) + end + + self.CurStageGrid = grid +end + +-- 返回滚动容器是否动画回弹 +function XUiGridChapter:CancelSelect() + if not self.CurStageGrid then + return false + end + + self.CurStageGrid:SetStageActive() + self.CurStageGrid:SetStoryStageActive() + self.CurStageGrid = nil + + if self.HideStageCb then + self.HideStageCb() + end + return self:ScrollRectRollBack() +end + +function XUiGridChapter:PlayScrollViewMove(grid) + -- 动画 + local gridTf = grid.Parent.gameObject:GetComponent("RectTransform") + local diffX = gridTf.localPosition.x + self.PanelStageContent.localPosition.x + if diffX < XDataCenter.FubenMainLineManager.UiGridChapterMoveMinX or diffX > XDataCenter.FubenMainLineManager.UiGridChapterMoveMaxX then + local tarPosX = XDataCenter.FubenMainLineManager.UiGridChapterMoveTargetX - gridTf.localPosition.x + local tarPos = self.PanelStageContent.localPosition + tarPos.x = tarPosX + XLuaUiManager.SetMask(true) + XUiHelper.DoMove(self.PanelStageContent, tarPos, XDataCenter.FubenMainLineManager.UiGridChapterMoveDuration, XUiHelper.EaseType.Sin, function() + XLuaUiManager.SetMask(false) + end) + end +end + +function XUiGridChapter:IsEggStage(stageCfg) + return stageCfg.StageType == XFubenConfigs.STAGETYPE_STORYEGG or stageCfg.StageType == XFubenConfigs.STAGETYPE_FIGHTEGG +end + +-- 模拟点击一个关卡 +function XUiGridChapter:ClickStageGridByIndex(index) + local grid = self.GridStageList[index] + self:ClickStageGrid(grid) +end + +function XUiGridChapter:ClickEggStageGridByIndex(index) + local grid = self.GridEggStageList[index] + self:ClickStageGrid(grid) +end + +function XUiGridChapter:Show() + if self.GameObject.activeSelf == true then return end + self.GameObject:SetActive(true) +end + +function XUiGridChapter:Hide() + if not self.GameObject:Exist() or self.GameObject.activeSelf == false then return end + self.GameObject:SetActive(false) +end + +function XUiGridChapter:OnEnable() + if self.IsOnZhouMu then + local animaState = XDataCenter.FubenZhouMuManager.CheckPlayTipAnima(self.RootUi.ZhouMuId, self.zhouMuChapterId, self.OriLastStageIsPass) + + if animaState == XFubenZhouMuConfigs.EnumZhouMuTipAnima.PlayStart then + -- 新周目开启动画 + self.RootUi:PlayAnimation("MultipleWeekBegin") + + elseif animaState == XFubenZhouMuConfigs.EnumZhouMuTipAnima.PlayEndStart then + -- 先播放当前周目结束动画,然后切换到新周目,再播放新周目开启动画 + self.RootUi:PlayAnimation("MultipleWeekEnd", function() + self.RootUi:OnBtnSwitch1MultipleWeeksClick() + self.RootUi:PlayAnimation("MultipleWeekBegin") + end) + + elseif animaState == XFubenZhouMuConfigs.EnumZhouMuTipAnima.PlayEnd then + -- 周目结束动画 + self.RootUi:PlayAnimation("MultipleWeekEnd") + end + + -- 在检查完是否播放动画后更新标志 + self.zhouMuChapterId = XDataCenter.FubenZhouMuManager.GetZhouMuChapterIdByZhouMuId(self.RootUi.ZhouMuId) + local lastStage = XFubenZhouMuConfigs.GetZhouMuChapterLastStage(self.zhouMuChapterId) + self.OriLastStageIsPass = XDataCenter.FubenManager.CheckStageIsPass(lastStage) + end + + if self.Enabled then + return + end + if self.GridStageList then + for _, v in pairs(self.GridStageList) do + v:OnEnable() + end + end + if self.GridEggStageList then + for _, v in pairs(self.GridEggStageList) do + v:OnEnable() + end + end + self.Enabled = true +end + +function XUiGridChapter:OnDisable() + if not self.Enabled then + return + end + if self.GridStageList then + for _, v in pairs(self.GridStageList) do + v:OnDisable() + end + end + if self.GridEggStageList then + for _, v in pairs(self.GridEggStageList) do + v:OnDisable() + end + end + self.Enabled = false +end + +return XUiGridChapter \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiGridExploreChapter.lua b/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiGridExploreChapter.lua new file mode 100644 index 00000000..c8abbd96 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiGridExploreChapter.lua @@ -0,0 +1,357 @@ +local XUiGridStage = require("XUi/XUiFubenMainLineChapter/XUiGridStage") + +local XUiGridExploreChapter = XClass(nil, "XUiGridExploreChapter") +local MAX_STAGE_COUNT = CS.XGame.ClientConfig:GetInt("MainLineExploreStageMaxCount") +local FocusTime = 0.5 +local ScaleLevel = {} + +function XUiGridExploreChapter:Ctor(rootUi, ui, stageType) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.StageType = stageType or XDataCenter.FubenManager.StageType.Mainline + XTool.InitUiObject(self) + self.GridStageList = {} + self.GridEggStageList = {} + self.LineList = {} + self.CanPlayList = {} + self:OnEnable() + + ScaleLevel = { + Small = self.PanelDrag.MinScale, + Big = self.PanelDrag.MaxScale, + Normal = (self.PanelDrag.MinScale + self.PanelDrag.MaxScale) / 2, + } + self.Mask.gameObject:SetActiveEx(false) + + --读取自定义颜色数据 + self.Colors = { + TxtChapterNameColor = self.TxtChapterNameColor ~= nil and self.TxtChapterNameColor.color, --章节名称 + TxtLeftTimeTipColor = self.TxtLeftTimeTipColor ~= nil and self.TxtLeftTimeTipColor.color, --剩余时间描述 + TxtLeftTimeColor = self.TxtLeftTimeColor ~= nil and self.TxtLeftTimeColor.color, --剩余时间 + StarColor = self.StarColor ~= nil and self.StarColor.color, --星星 + StarDisColor = self.StarDisColor ~= nil and self.StarDisColor.color, + ImageBottomColor = self.ImageBottomColor ~= nil and self.ImageBottomColor.color, + TxtStarNumColor = self.TxtStarNumColor ~= nil and self.TxtStarNumColor.color, + TxtDescrColor = self.TxtDescrColor ~= nil and self.TxtDescrColor.color, + Triangle0Color = self.Triangle0Color ~= nil and self.Triangle0Color.color, + Triangle1Color = self.Triangle1Color ~= nil and self.Triangle1Color.color, + Triangle2Color = self.Triangle2Color ~= nil and self.Triangle2Color.color, + Triangle3Color = self.Triangle3Color ~= nil and self.Triangle3Color.color + } + if self.PanelColors then + self.PanelColors.gameObject:SetActiveEx(false) + end +end + +function XUiGridExploreChapter:GetColors() + return self.Colors +end + +function XUiGridExploreChapter:GoToNearestStage() + if #self.CanPlayList > 0 then + local firstCanPlayId = self.CanPlayList[1] + local firstGridStage = self.GridStageList[firstCanPlayId] + if not firstGridStage then + XLog.Error("ExploreGroup's setting is Error by stageIndex:" .. firstCanPlayId) + return + end + + local nearestTransform = firstGridStage.Transform + local minDis = CS.UnityEngine.Vector3.Distance(nearestTransform.position, self.PanelDrag.gameObject.transform.position) + for i = 2, #self.CanPlayList do + local canPlayId = self.CanPlayList[i] + local gridStage = self.GridStageList[canPlayId] + if not gridStage then + XLog.Error("ExploreGroup's setting is Error by stageIndex:" .. canPlayId) + break + end + local tempDis = CS.UnityEngine.Vector3.Distance(gridStage.Transform.position, self.PanelDrag.gameObject.transform.position) + if tempDis < minDis then + nearestTransform = gridStage.Transform + minDis = tempDis + end + end + self.PanelDrag:FocusTarget(nearestTransform, ScaleLevel.Normal, FocusTime, CS.UnityEngine.Vector3.zero) + end +end + +function XUiGridExploreChapter:SetCanPlayList(canPlayList) + self.CanPlayList = canPlayList +end + +-- chapter 组件内容更新 +function XUiGridExploreChapter:UpdateChapterGrid(data) + self.Chapter = data.Chapter + self.HideStageCb = data.HideStageCb + self.ShowStageCb = data.ShowStageCb + self.EggStageList = {} + self.NormalStageList = {} + for _, v in pairs(data.StageList) do + local stageCfg = XDataCenter.FubenManager.GetStageCfg(v) + if self:IsEggStage(stageCfg) then + local eggNum = self:GetEggNum(data.StageList, stageCfg) + if eggNum ~= 0 then + local egg = { Id = v, Num = eggNum } + table.insert(self.EggStageList, egg) + end + else + table.insert(self.NormalStageList, v) + end + end + + self:SetStageList() +end + +-- 根据stageId选中 +function XUiGridExploreChapter:ClickStageGridByStageId(selectStageId) + if not selectStageId then return end + local IsEggStage = false + local stageInfo = XDataCenter.FubenManager.GetStageInfo(selectStageId) + if not stageInfo.IsOpen then return end + + local index = 0 + for i = 1, #self.NormalStageList do + local stageId = self.NormalStageList[i] + if selectStageId == stageId then + index = i + break + end + end + for i = 1, #self.EggStageList do + local stageId = self.EggStageList[i] + if selectStageId == stageId then + index = i + IsEggStage = true + break + end + end + + if index ~= 0 then + if IsEggStage then + self:ClickEggStageGridByIndex(index) + else + self:ClickStageGridByIndex(index) + end + end +end + +function XUiGridExploreChapter:GetEggNum(stageList, eggStageCfg) + for k, v in pairs(stageList) do + if v == eggStageCfg.PreStageId[1] then --1为1号前置关卡 + return k + end + end + return 0 +end + +function XUiGridExploreChapter:SetStageList() + if XTool.UObjIsNil(self.GameObject) then return end + + if self.NormalStageList == nil then + XLog.Error("Chapter have no id " .. self.Chapter.ChapterId) + return + end + + -- 初始化副本显示列表,i作为order id,从1开始 + for i = 1, #self.NormalStageList do + local stageId = self.NormalStageList[i] + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + local exploreInfoList + if self.StageType == XDataCenter.FubenManager.StageType.Mainline then + exploreInfoList = XDataCenter.FubenMainLineManager.GetExploreGroupInfoByGroupId(self.Chapter.ExploreGroupId) + else + exploreInfoList = XDataCenter.ExtraChapterManager.GetExploreGroupInfoByGroupId(self.Chapter.ExploreGroupId) + end + local exploreInfo = exploreInfoList[i] or {} + local IsShow = true + for _, index in pairs(exploreInfo.PreShowIndex or {}) do + local stageInfo = XDataCenter.FubenManager.GetStageInfo(self.NormalStageList[index]) + if not stageInfo or not stageInfo.Passed then + IsShow = IsShow and false + end + end + if IsShow then + local grid = self.GridStageList[i] + if not grid then + local uiName = "GridStage" + uiName = stageCfg.StageGridStyle and string.format("%s%s", uiName, stageCfg.StageGridStyle) or uiName + + local parent = self.PanelStageContent.transform:Find(string.format("Stage%d", i)) + local prefabName = CS.XGame.ClientConfig:GetString(uiName) + local prefab = parent:LoadPrefab(prefabName) + + grid = XUiGridStage.New(self.RootUi, prefab, handler(self, self.ClickStageGrid), XFubenConfigs.FUBENTYPE_NORMAL, true) + grid.Parent = parent + self.GridStageList[i] = grid + end + + grid:UpdateStageMapGrid(stageCfg, self.Chapter.OrderId) + if not XTool.UObjIsNil(grid.Parent.gameObject) then + grid.Parent.gameObject:SetActiveEx(true) + end + end + end + + for i = 1, #self.EggStageList do + local stageId = self.EggStageList[i].Id + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + + if stageInfo.IsOpen then + if XDataCenter.FubenManager.GetUnlockHideStageById(stageId) then + local grid = self.GridEggStageList[i] + if not grid then + local uiName = "GridStageSquare" + local parentsParent = self.PanelStageContent.transform:Find(string.format("Stage%d", self.EggStageList[i].Num)) + local parent = self.PanelStageContent.transform:Find(string.format("Stage%d/EggStage", self.EggStageList[i].Num)) + local prefabName = CS.XGame.ClientConfig:GetString(uiName) + local prefab = parent:LoadPrefab(prefabName) + grid = XUiGridStage.New(self.RootUi, prefab, handler(self, self.ClickStageGrid), XFubenConfigs.FUBENTYPE_NORMAL) + grid.Parent = parentsParent + self.GridEggStageList[i] = grid + end + grid:UpdateStageMapGrid(stageCfg, self.Chapter.OrderId) + end + end + end + + for i = 1, MAX_STAGE_COUNT do + if not self.GridStageList[i] then + local parent = self.PanelStageContent.transform:Find(string.format("Stage%d", i)) + if parent then + parent.gameObject:SetActiveEx(false) + end + end + end + + if self.MoveArea then + self.MoveArea:UpdateAreaSize() + end +end + +-- 选中一个 stage grid +function XUiGridExploreChapter:ClickStageGrid(grid) + local curGrid = self.CurStageGrid + if curGrid and curGrid.Stage.StageId == grid.Stage.StageId then + return + end + + local stageInfo = XDataCenter.FubenManager.GetStageInfo(grid.Stage.StageId) + if not stageInfo.Unlock then + XUiManager.TipMsg(XDataCenter.FubenManager.GetFubenOpenTips(grid.Stage.StageId)) + return + end + + -- 取消上一个选择 + if curGrid then + curGrid:SetStageActive() + end + + -- 选中当前选择 + grid:SetStageSelect() + grid:SetStoryStageSelect() + + self.CurStageGrid = grid + self.IsNotPassedFightStage = false + + local stageCfg = XDataCenter.FubenManager.GetStageCfg(grid.Stage.StageId) + if stageCfg.StageType == XFubenConfigs.STAGETYPE_FIGHT or + stageCfg.StageType == XFubenConfigs.STAGETYPE_COMMON then + self.IsNotPassedFightStage = not stageInfo.Passed + end + + self.Mask.gameObject:SetActiveEx(true) + XScheduleManager.ScheduleOnce(function() + self.PanelDrag:FocusTarget(grid.Transform, ScaleLevel.Big, FocusTime, CS.UnityEngine.Vector3.zero, function() + -- 选中回调 + if self.ShowStageCb then + self.ShowStageCb(grid.Stage, grid.ChapterOrderId) + end + self.Mask.gameObject:SetActiveEx(false) + end) + end, 0) +end + +function XUiGridExploreChapter:IsEggStage(stageCfg) + return stageCfg.StageType == XFubenConfigs.STAGETYPE_STORYEGG or stageCfg.StageType == XFubenConfigs.STAGETYPE_FIGHTEGG +end + +-- 模拟点击一个关卡 +function XUiGridExploreChapter:ClickStageGridByIndex(index) + local grid = self.GridStageList[index] + self:ClickStageGrid(grid) +end + +function XUiGridExploreChapter:ClickEggStageGridByIndex(index) + local grid = self.GridEggStageList[index] + self:ClickStageGrid(grid) +end + +function XUiGridExploreChapter:Show() + if self.GameObject.activeSelf == true then return end + self.GameObject:SetActiveEx(true) +end + +function XUiGridExploreChapter:Hide() + if not self.GameObject:Exist() or self.GameObject.activeSelf == false then return end + self.GameObject:SetActiveEx(false) +end + +function XUiGridExploreChapter:OnEnable() + if self.Enabled then + return + end + if self.GridStageList then + for _, v in pairs(self.GridStageList) do + v:OnEnable() + end + end + if self.GridEggStageList then + for _, v in pairs(self.GridEggStageList) do + v:OnEnable() + end + end + self.Enabled = true +end + +function XUiGridExploreChapter:OnDisable() + if not self.Enabled then + return + end + if self.GridStageList then + for _, v in pairs(self.GridStageList) do + v:OnDisable() + end + end + if self.GridEggStageList then + for _, v in pairs(self.GridEggStageList) do + v:OnDisable() + end + end + self.Enabled = false +end + +function XUiGridExploreChapter:CancelSelect() + if not self.CurStageGrid then + return false + end + + self.CurStageGrid:SetStageActive() + self.CurStageGrid:SetStoryStageActive() + self.CurStageGrid = nil + + if self.HideStageCb then + self.HideStageCb() + end +end + +function XUiGridExploreChapter:OnQuickJumpClick(index) + self:ClickStageGridByIndex(index) +end + +function XUiGridExploreChapter:ScaleBack() + self.PanelDrag:FocusTarget(self.CurStageGrid.Transform, ScaleLevel.Normal, FocusTime, CS.UnityEngine.Vector3.zero, nil) +end + +return XUiGridExploreChapter \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiGridExploreItem.lua b/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiGridExploreItem.lua new file mode 100644 index 00000000..1a8f500c --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiGridExploreItem.lua @@ -0,0 +1,60 @@ +XUiGridExploreItem = XClass(nil, "XUiGridExploreItem") +local FirstIndex = 1 + +function XUiGridExploreItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:SetButtonCallBack() +end + +function XUiGridExploreItem:SetButtonCallBack() + self.BtnRole.CallBack = function() + self:OnBtnRoleClick() + end +end + +function XUiGridExploreItem:OnBtnRoleClick() + self.Base:SetItemData(self.CharacterId) + self:SetSelectShow(self.Base) + self.Base.OldSelectGrig:SetSelectShow(self.Base) + self.Base.OldSelectGrig = self + self:ClearRedPoint() +end + +function XUiGridExploreItem:UpdateGrid(chapter, parent, index) + self.Base = parent + self.CharacterId = chapter.Id + if chapter.Icon ~= nil then + self.RItemImg:SetRawImage(chapter.Icon) + end + if index and index == FirstIndex then + self:OnBtnRoleClick() + end + self:SetSelectShow(parent) + self:CheckRedPoint() +end + +function XUiGridExploreItem:SetSelectShow(parent) + if parent.SelectCharacterId == self.CharacterId then + self:ShowSelect(true) + else + self:ShowSelect(false) + end + if not self.Base.OldSelectGrig then + self.Base.OldSelectGrig = self + end +end + +function XUiGridExploreItem:ShowSelect(bShow) + self.ImgRoleSelect.gameObject:SetActiveEx(bShow) +end + +function XUiGridExploreItem:CheckRedPoint() + self.BtnRole:ShowReddot(XDataCenter.FubenMainLineManager.CheckHaveNewExploreItemByItemId(self.CharacterId)) +end + +function XUiGridExploreItem:ClearRedPoint() + XDataCenter.FubenMainLineManager.MarkNewExploreItemRedPointByItemId(self.CharacterId) + self.BtnRole:ShowReddot(false) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiGridStage.lua b/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiGridStage.lua new file mode 100644 index 00000000..cf56790c --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiGridStage.lua @@ -0,0 +1,556 @@ +local ComponentScriptPath = "XUi/XUiFubenMainLineChapter/%s" + +local stringFormat = string.format + +local XUiGridStage = XClass(nil, "XUiGridStage") + +function XUiGridStage:Ctor(rootUi, ui, cb, fubenType, IsMainLineExplore, isOnZhouMu) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.ClickCb = cb + self.Components = {} + self.FubenType = fubenType + self.IsMainLineExplore = IsMainLineExplore + self.IsOnZhouMu = isOnZhouMu + self:InitAutoScript() + self:OnEnable() +end + +function XUiGridStage:OnEnable() + if self.Stage then + self:UpdateFightControl() + end + + if self.Enabled then + return + end + + self.Enabled = true +end + +function XUiGridStage:OnDisable() + if not self.Enabled then + return + end + + for _, component in pairs(self.Components) do + if component.OnDisable then component:OnDisable() end + end + + self.Enabled = false +end + +--[[设置组件显隐,第一次设置显示时若组件不存在则加载组件prefab]] +--componentName:组件名称字符串 +--isActive:是否显示 +--notScript:是否不需要加载组件脚本 +function XUiGridStage:SetComponentActive(componentName, isActive, notScript, ...) + local component = self.Components[componentName] + local go = component and (component.GameObject or component.gameObject) + if not XTool.UObjIsNil(go) then + go:SetActiveEx(isActive) + + if isActive then + if component.OnEnable then component:OnEnable(...) end + if self.Stage and component.UpdateStageId then + component:UpdateStageId(self.Stage.StageId) + end + else + if component.OnDisable then component:OnDisable() end + end + elseif isActive then + local parent = self[componentName .. "Parent"] + if XTool.UObjIsNil(parent) then return end + local prefab = self.Obj:Instantiate(componentName, parent.gameObject) + if XTool.UObjIsNil(prefab) then return end + + local scriptPath = stringFormat(ComponentScriptPath, "XUi" .. componentName) + if notScript then + self.Components[componentName] = prefab + else + component = require(scriptPath).New(prefab, ...) + self.Components[componentName] = component + if component.OnEnable then component:OnEnable(...) end + end + end +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiGridStage:InitAutoScript() + XTool.InitUiObject(self) + self:AutoAddListener() +end + +function XUiGridStage:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiGridStage:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiGridStage:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiGridStage:AutoAddListener() + self:RegisterClickEvent(self.BtnStage, self.OnBtnStageClick) +end +-- auto +function XUiGridStage:OnBtnStageClick() + if self.ClickCb then + self.ClickCb(self) + end + + local stageId = self.Stage.StageId + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + + -- if self.FubenType == XFubenConfigs.FUBENTYPE_NORMAL then + -- self:NormalStageClick(stageId, stageCfg, stageInfo) + -- else + if self.FubenType == XFubenConfigs.FUBENTYPE_PREQUEL then + self:PrequelStageClick(stageId, stageCfg, stageInfo) + end +end + +-- function XUiGridStage:NormalStageClick(stageId, stageCfg, stageInfo) +-- if stageCfg.StageType == XFubenConfigs.STAGETYPE_STORY or stageCfg.StageType == XFubenConfigs.STAGETYPE_STORYEGG then +-- elseif stageCfg.StageType == XFubenConfigs.STAGETYPE_FIGHT or stageCfg.StageType == XFubenConfigs.STAGETYPE_FIGHTEGG then +-- end +-- end +function XUiGridStage:PrequelStageClick(stageId, stageCfg, stageInfo) + --普通副本格子点击 + if stageCfg.StageType == XFubenConfigs.STAGETYPE_STORY or stageCfg.StageType == XFubenConfigs.STAGETYPE_STORYEGG then + if not XDataCenter.PrequelManager.CheckPrequelStageOpen(stageId) then + if stageCfg.RequireLevel > 0 and XPlayer.Level < stageCfg.RequireLevel then + XUiManager.TipError(CS.XTextManager.GetText("TeamLevelToOpen", stageCfg.RequireLevel)) + return + end + for _, conditionId in pairs(stageCfg.ForceConditionId or {}) do + local ret, desc = XConditionManager.CheckCondition(conditionId) + if not ret then + XUiManager.TipError(desc) + return + end + end + return + end + + if stageInfo.Passed then + self.RootUi:OnEnterStory(stageId, function() + XDataCenter.MovieManager.PlayMovie(stageCfg.BeginStoryId, function() + XDataCenter.PrequelManager.UpdateShowChapter(stageId) + end) + end) + else + self.RootUi:OnEnterStory(stageId, function() + XDataCenter.PrequelManager.FinishStoryRequest(stageId, function() + XDataCenter.MovieManager.PlayMovie(stageCfg.BeginStoryId, function() + self.RootUi:RefreshRegional() + XDataCenter.PrequelManager.UpdateShowChapter(stageId) + end) + end) + end) + end + --前传战斗点击 + elseif stageCfg.StageType == XFubenConfigs.STAGETYPE_FIGHT or stageCfg.StageType == XFubenConfigs.STAGETYPE_FIGHTEGG then + if not XDataCenter.PrequelManager.CheckPrequelStageOpen(stageId) then + if stageCfg.RequireLevel > 0 and XPlayer.Level < stageCfg.RequireLevel then + XUiManager.TipError(CS.XTextManager.GetText("TeamLevelToOpen", stageCfg.RequireLevel)) + return + end + for _, conditionId in pairs(stageCfg.ForceConditionId or {}) do + local ret, desc = XConditionManager.CheckCondition(conditionId) + if not ret then + XUiManager.TipError(desc) + return + end + end + return + end + + self.RootUi:OnEnterFight(stageId, function() + XDataCenter.FubenManager.EnterPrequelFight(stageId) + end) + end +end + +function XUiGridStage:UpdateStageMapGrid(stage, chapterOrderId) + self.Stage = stage + self.ChapterOrderId = chapterOrderId + self:Refresh() +end + +function XUiGridStage:Refresh() + if not self.Enabled then return end + + local stageId = self.Stage.StageId + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + local nextStageInfo = XDataCenter.FubenManager.GetStageInfo(stageInfo.NextStageId) + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + local txtName = self.Transform.parent:Find("TxtName") + if txtName then + txtName:GetComponent("Text").text = stageCfg.Name + end + if stageCfg.StageType == XFubenConfigs.STAGETYPE_COMMON then + self:SetNormalStage(stageInfo, nextStageInfo, stageCfg, stageId, stageCfg.StageType) + else + if self.FubenType == XFubenConfigs.FUBENTYPE_NORMAL then + --[主线副本/据点战/支线活动] + self:SetNormalStage(stageInfo, nextStageInfo, stageCfg, stageId, stageCfg.StageType) + elseif self.FubenType == XFubenConfigs.FUBENTYPE_PREQUEL then + --[前传] + self:SetPrequelStage(stageId, stageInfo, stageCfg.StageType, stageCfg.StoryUiStyle) + end + end +end + +function XUiGridStage:SetPrequelStage(stageId, stageInfo, stageType, storyUiStyle) + if stageType == XFubenConfigs.STAGETYPE_STORY then + local isStageUnlock = XDataCenter.PrequelManager.CheckPrequelStageOpen(stageId) + self:SetPrequelStageComponent("PanelFightActive", false) + self:SetPrequelStageComponent("PanelFightUnactive", false) + self:SetPrequelStageComponent("PanelStoryActive", isStageUnlock, nil, storyUiStyle, stageId, self.ChapterOrderId) + self:SetPrequelStageComponent("PanelStoryUnactive", not isStageUnlock, nil, storyUiStyle, stageId, self.ChapterOrderId) + self:SetPrequelStageComponent("PanelHideTagNor", false) + self:SetPrequelStageComponent("PanelHideTagLock", false) + self:SetPrequelStageComponent("PanelKill", stageInfo.Passed, true) + self:SetPrequelStageComponent("PanelHideStageNor", false) + + -- 迁移位置测试 + self:AdjustStoryPanelKillPosition(self.Components["PanelStoryActive"], self.Components["PanelKill"]) + + elseif stageType == XFubenConfigs.STAGETYPE_FIGHT then + local isStageUnlock = XDataCenter.PrequelManager.CheckPrequelStageOpen(stageId) + self:SetPrequelStageComponent("PanelStoryActive", false) + self:SetPrequelStageComponent("PanelStoryUnactive", false) + self:SetPrequelStageComponent("PanelFightActive", isStageUnlock, nil, storyUiStyle, stageId, function() + self:OnBtnStageClick() + end) + self:SetPrequelStageComponent("PanelFightUnactive", not isStageUnlock, true, storyUiStyle) + self:SetPrequelStageComponent("PanelHideTagNor", false) + self:SetPrequelStageComponent("PanelHideTagLock", false) + self:SetPrequelStageComponent("PanelKill", stageInfo.Passed, true) + self:SetPrequelStageComponent("PanelHideStageNor", false) + + -- 迁移位置测试 + self:AdjustFightPanelKillPosition(self.Components["PanelFightActive"], self.Components["PanelKill"]) + + elseif stageType == XFubenConfigs.STAGETYPE_FIGHTEGG then + local isStageUnlock = XDataCenter.PrequelManager.CheckPrequelStageOpen(stageId) + self:SetPrequelStageComponent("PanelHideStageNor", isStageUnlock, nil, storyUiStyle, stageId, self.RootUi) + self:SetPrequelStageComponent("PanelHideTagNor", false) + self:SetPrequelStageComponent("PanelHideTagLock", false) + self:SetPrequelStageComponent("PanelStoryActive", false) + self:SetPrequelStageComponent("PanelStoryUnactive", false) + self:SetPrequelStageComponent("PanelFightActive", false) + self:SetPrequelStageComponent("PanelFightUnactive", false) + + elseif stageType == XFubenConfigs.STAGETYPE_STORYEGG then + local isStageUnlock = XDataCenter.PrequelManager.CheckPrequelStageOpen(stageId) + self:SetPrequelStageComponent("PanelHideTagNor", isStageUnlock, false, storyUiStyle, stageId, self.RootUi) + self:SetPrequelStageComponent("PanelHideTagLock", not isStageUnlock, true, storyUiStyle, stageId, self.RootUi) + self:SetPrequelStageComponent("PanelStoryActive", false) + self:SetPrequelStageComponent("PanelStoryUnactive", false) + self:SetPrequelStageComponent("PanelFightActive", false) + self:SetPrequelStageComponent("PanelFightUnactive", false) + self:SetPrequelStageComponent("PanelHideStageNor", false) + end +end + +function XUiGridStage:SetPrequelStageComponent(componentName, isActive, notScript, uiStyle, ...) + local component = self.Components[componentName] + local go = component and (component.GameObject or component.gameObject) + if not XTool.UObjIsNil(go) then + go:SetActiveEx(isActive) + + if isActive then + if component.OnEnable then component:OnEnable(...) end + if self.Stage and component.UpdateStageId then + component:UpdateStageId(self.Stage.StageId) + end + else + if component.OnDisable then component:OnDisable() end + end + elseif isActive then + local parent = self[componentName .. "Parent"] + if XTool.UObjIsNil(parent) then return end + local prefab + local prefabName = componentName + if uiStyle and uiStyle > 1 then + prefabName = prefabName .. tostring(uiStyle) + prefab = self.Obj:Instantiate(prefabName, parent.gameObject) + else + prefab = self.Obj:Instantiate(componentName, parent.gameObject) + end + if XTool.UObjIsNil(prefab) then return end + + local scriptPath = stringFormat(ComponentScriptPath, "XUi" .. componentName) + if notScript then + self.Components[componentName] = prefab + else + component = require(scriptPath).New(prefab, ...) + self.Components[componentName] = component + if component.OnEnable then component:OnEnable(...) end + end + end +end + +function XUiGridStage:AdjustStoryPanelKillPosition(storyUi, panelkillUi) + if not storyUi or not panelkillUi then return end + if storyUi["GetKillPos"] then + panelkillUi.transform.position = storyUi:GetKillPos() + end +end + +function XUiGridStage:AdjustFightPanelKillPosition(fightUi, panelkillUi) + if not fightUi or not panelkillUi then return end + if fightUi["GetKillPos"] then + panelkillUi.transform.position = fightUi:GetKillPos() + end +end + +function XUiGridStage:SetNormalStage(stageInfo, nextStageInfo, stageCfg, stageId, stageType) + local IsEgg = false + if stageType == XFubenConfigs.STAGETYPE_FIGHTEGG or stageType == XFubenConfigs.STAGETYPE_STORYEGG then + IsEgg = true + end + local isExtra = XDataCenter.ExtraChapterManager.IfChapterIsExtraChapter(stageInfo.ChapterId) + local chapter + if isExtra then + chapter = XDataCenter.ExtraChapterManager.GetChapterDetailsCfg(stageInfo.ChapterId) + else + chapter = XDataCenter.FubenMainLineManager.GetChapterCfg(stageInfo.ChapterId) + end + if stageType == XFubenConfigs.STAGETYPE_STORY or stageType == XFubenConfigs.STAGETYPE_STORYEGG then + if stageInfo.Unlock then + self:SetStoryStageActive() + if (not (nextStageInfo and nextStageInfo.Unlock or stageInfo.Passed)) and not IsEgg then + if not self.IsMainLineExplore then + self:SetComponentActive("PanelEffect", true, true) + end + else + self:SetComponentActive("PanelEffect", false) + end + else + self:SetStoryStageLock() + end + + if chapter or self.IsOnZhouMu then + local stagePassed = stageInfo.Passed + self:SetComponentActive("PanelKill", stagePassed, true) + end + + elseif stageType == XFubenConfigs.STAGETYPE_FIGHT or stageType == XFubenConfigs.STAGETYPE_FIGHTEGG or stageType == XFubenConfigs.STAGETYPE_COMMON then + if stageInfo.Unlock then + self:SetStageActive() + if (not (nextStageInfo and nextStageInfo.Unlock or stageInfo.Passed)) and not IsEgg then + if not self.IsMainLineExplore then + self:SetComponentActive("PanelEffect", true, true) + end + else + self:SetComponentActive("PanelEffect", false) + end + elseif stageInfo.IsOpen or self.IsMainLineExplore or self.IsOnZhouMu then + self:SetStageLock() + end + + local stagePassed + if XDataCenter.BfrtManager.CheckStageTypeIsBfrt(stageId) then + stagePassed = XDataCenter.BfrtManager.IsGroupPassedByStageId(stageId) + self:SetComponentActive("PanelKill", stagePassed, true) + else + stagePassed = stageInfo.Passed + if chapter or self.IsOnZhouMu then + self:SetComponentActive("PanelKill", stagePassed, true) + end + end + if stageInfo.Type == XDataCenter.FubenManager.StageType.ActivtityBranch then + self:SetComponentActive("PanelKill", stagePassed, true) + elseif stageInfo.Type == XDataCenter.FubenManager.StageType.RepeatChallenge then + -- 复刷关拦截已结束章节 + local isFinished = XDataCenter.FubenRepeatChallengeManager.IsStageFinished(stageId) + self:SetComponentActive("PanelStageClose", isFinished, true) + self:SetComponentActive("PanelKill", stagePassed and not isFinished, true) + elseif stageInfo.Type == XDataCenter.FubenManager.StageType.ActivityBossSingle then + self:SetComponentActive("PanelKill", XDataCenter.FubenActivityBossSingleManager.IsChallengePassedByStageId(stageId), true) + if not XDataCenter.FubenActivityBossSingleManager.IsChallengeUnlockByStageId(stageId) then + self:SetStageLock() + end + end + + local rewardTipId = stageCfg.RewardTipId or 0 + self:SetComponentActive("PanelRewardTips", rewardTipId ~= 0, nil, self.RootUi, stageId) + self:SetComponentActive("PanelAutoFight", stageCfg.AutoFightId > 0, nil, stageId) + self:SetComponentActive("PanelStoryActive", false) + self:SetComponentActive("PanelStoryUnactive", false) + + --赏金任务 + local IsBountyTaskPreFight, task = XDataCenter.BountyTaskManager.CheckBountyTaskPreFight(stageId) + self:SetComponentActive("PanelBountyTaskInGrid", IsBountyTaskPreFight and task.Status ~= XDataCenter.BountyTaskManager.BountyTaskStatus.AcceptReward, nil, task) + + --战力警告 + self:UpdateFightControl() + end + + if not IsEgg then + if self.ImageNorHideBg then + self.ImageNorHideBg.gameObject:SetActive(false) + end + if self.Line then + self.Line.gameObject:SetActive(false) + end + end +end + +function XUiGridStage:UpdateFightControl() + local stageId = self.Stage.StageId + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + + local clearFightControl = true + if stageInfo.Unlock and not stageInfo.Passed then + if stageCfg.FightControlId > 0 then + local data = XFubenConfigs.GetStageFightControl(stageCfg.FightControlId) + local charlist = XDataCenter.CharacterManager.GetCharacterList() + local maxAbility = 0 + for _, v in pairs(charlist) do + if v.Ability and v.Ability > maxAbility then + maxAbility = v.Ability + end + end + if maxAbility < data.RecommendFight then + self:SetComponentActive("PanelStageFightControlHard", false) + self:SetComponentActive("PanelStageFightControlEx", true, true) + clearFightControl = false + elseif maxAbility >= data.RecommendFight and maxAbility < data.ShowFight then + self:SetComponentActive("PanelStageFightControlHard", true, true) + self:SetComponentActive("PanelStageFightControlEx", false) + clearFightControl = false + end + end + end + if clearFightControl then + self:SetComponentActive("PanelStageFightControlEx", false) + self:SetComponentActive("PanelStageFightControlHard", false) + end +end + +function XUiGridStage:SetStageTypePanelActive(isActive) + if isActive then + local stageId = self.Stage.StageId + if XDataCenter.BfrtManager.CheckStageTypeIsBfrt(stageId) then + self:SetComponentActive("PanelEchelon", true, nil, stageId) + self:SetComponentActive("PanelStars", false) + else + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + if self.IsOnZhouMu then + self:SetComponentActive("PanelStars", false) + else + self:SetComponentActive("PanelStars", true, nil, stageInfo.StarsMap, self.RootUi.StarColor, self.RootUi.StarDisColor) + end + self:SetComponentActive("PanelEchelon", false) + end + else + self:SetComponentActive("PanelStars", false) + self:SetComponentActive("PanelEchelon", false) + end +end + +function XUiGridStage:SetStoryStageSelect() + local tmp_2 = self.Stage.StageType == XFubenConfigs.STAGETYPE_STORY + or self.Stage.StageType == XFubenConfigs.STAGETYPE_STORYEGG + and self.FubenType == XFubenConfigs.FUBENTYPE_NORMAL + + if not (tmp_2) then return end + self:SetComponentActive("PanelStorySelected", true, nil, self.Stage.StageId, self.ChapterOrderId) + self:SetComponentActive("PanelStoryActive", false) + self:SetComponentActive("PanelStoryUnactive", false) + --self:SetComponentActive("PanelEffect", false) +end + +function XUiGridStage:SetStoryStageActive() + local tmp_2 = self.Stage.StageType == XFubenConfigs.STAGETYPE_STORY + or self.Stage.StageType == XFubenConfigs.STAGETYPE_STORYEGG + and self.FubenType == XFubenConfigs.FUBENTYPE_NORMAL + + if not (tmp_2) then return end + self:SetComponentActive("PanelStoryActive", true, nil, self.Stage.StageId, self.ChapterOrderId) + self:SetComponentActive("PanelStoryUnactive", false) + self:SetComponentActive("PanelStorySelected", false) + --self:SetComponentActive("PanelEffect", false) +end + +function XUiGridStage:SetStoryStageLock() + local tmp_2 = self.Stage.StageType == XFubenConfigs.STAGETYPE_STORY + or self.Stage.StageType == XFubenConfigs.STAGETYPE_STORYEGG + and self.FubenType == XFubenConfigs.FUBENTYPE_NORMAL + + if not (tmp_2) then return end + self:SetComponentActive("PanelStoryUnactive", true, nil, self.Stage.StageId, self.ChapterOrderId) + self:SetComponentActive("PanelStoryActive", false) + self:SetComponentActive("PanelStorySelected", false) + self:SetComponentActive("PanelEffect", false) +end + +function XUiGridStage:SetStageSelect() + local tmp_1 = self.Stage.StageType == XFubenConfigs.STAGETYPE_COMMON + local tmp_2 = self.Stage.StageType == XFubenConfigs.STAGETYPE_FIGHT + or self.Stage.StageType == XFubenConfigs.STAGETYPE_FIGHTEGG + and self.FubenType == XFubenConfigs.FUBENTYPE_NORMAL + + if not (tmp_1 or tmp_2) then return end + + local stageInfo = XDataCenter.FubenManager.GetStageInfo(self.Stage.StageId) + if stageInfo.Type == XDataCenter.FubenManager.StageType.ActivtityBranch + or stageInfo.Type == XDataCenter.FubenManager.StageType.ActivityBossSingle + or stageInfo.Type == XDataCenter.FubenManager.StageType.RepeatChallenge + then return end + + self:SetComponentActive("PanelStageSelected", true, nil, self.Stage.StageId, self.ChapterOrderId) + self:SetComponentActive("PanelStageActive", false) + self:SetComponentActive("PanelStageLock", false) + --self:SetComponentActive("PanelEffect", false) + self:SetStageTypePanelActive(true) +end + +function XUiGridStage:SetStageActive() + local tmp_1 = self.Stage.StageType == XFubenConfigs.STAGETYPE_COMMON + local tmp_2 = self.Stage.StageType == XFubenConfigs.STAGETYPE_FIGHT + or self.Stage.StageType == XFubenConfigs.STAGETYPE_FIGHTEGG + and self.FubenType == XFubenConfigs.FUBENTYPE_NORMAL + + if not (tmp_1 or tmp_2) then return end + + self:SetComponentActive("PanelStageActive", true, nil, self.Stage.StageId, self.ChapterOrderId) + self:SetComponentActive("PanelStageLock", false) + self:SetComponentActive("PanelStageSelected", false) + --self:SetComponentActive("PanelEffect", false) + self:SetStageTypePanelActive(true) +end + +function XUiGridStage:SetStageLock() + local tmp_1 = self.Stage.StageType == XFubenConfigs.STAGETYPE_COMMON + local tmp_2 = self.Stage.StageType == XFubenConfigs.STAGETYPE_FIGHT + or self.Stage.StageType == XFubenConfigs.STAGETYPE_FIGHTEGG + and self.FubenType == XFubenConfigs.FUBENTYPE_NORMAL + + if not (tmp_1 or tmp_2) then return end + + self:SetComponentActive("PanelStageLock", true, nil, self.Stage.StageId, self.ChapterOrderId) + self:SetComponentActive("PanelStageActive", false) + self:SetComponentActive("PanelStageSelected", false) + self:SetComponentActive("PanelRewardTips", false) + self:SetComponentActive("PanelEffect", false) + self:SetStageTypePanelActive(false) +end + +return XUiGridStage \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiGridTreasureGrade.lua b/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiGridTreasureGrade.lua new file mode 100644 index 00000000..12b38651 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiGridTreasureGrade.lua @@ -0,0 +1,257 @@ +XUiGridTreasureGrade = XClass(nil, "XUiGridTreasureGrade") + +function XUiGridTreasureGrade:Ctor(rootUi, ui, treasureType) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.TreasureType = treasureType or XDataCenter.FubenManager.StageType.Mainline + self:InitAutoScript() + self.GridCommonItem = self.Transform:Find("PanelTreasureList/Viewport/PanelTreasureContent/GridCommon") + self.GridCommonItem.gameObject:SetActive(false) + self.PanelMultipleWeeksJindu.gameObject:SetActiveEx(false) + self.GridList = {} +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiGridTreasureGrade:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiGridTreasureGrade:AutoInitUi() + self.ImgGradeLine = self.Transform:Find("ImgGradeLine"):GetComponent("Image") + self.TxtGrade = self.Transform:Find("TxtGrade"):GetComponent("Text") + self.TxtGradeStarNums = self.Transform:Find("TxtGradeStarNums"):GetComponent("Text") + self.ImgGradeStarActive = self.Transform:Find("ImgGradeStarActive"):GetComponent("Image") + self.ImgGradeStarUnactive = self.Transform:Find("ImgGradeStarUnactive"):GetComponent("Image") + self.BtnReceive = self.Transform:Find("BtnReceive"):GetComponent("Button") + self.ImgCannotReceive = self.Transform:Find("ImgCannotReceive"):GetComponent("Image") + self.ImgAlreadyReceived = self.Transform:Find("ImgAlreadyReceived"):GetComponent("Image") + self.PanelTreasureList = self.Transform:Find("PanelTreasureList") + self.PanelTreasureContent = self.Transform:Find("PanelTreasureList/Viewport/PanelTreasureContent") + self.GridCommon = self.Transform:Find("PanelTreasureList/Viewport/PanelTreasureContent/GridCommon") + self.RImgIcon = self.Transform:Find("PanelTreasureList/Viewport/PanelTreasureContent/GridCommon/RImgIcon"):GetComponent("RawImage") + self.ImgQuality = self.Transform:Find("PanelTreasureList/Viewport/PanelTreasureContent/GridCommon/ImgQuality"):GetComponent("Image") + self.BtnClick = self.Transform:Find("PanelTreasureList/Viewport/PanelTreasureContent/GridCommon/BtnClick"):GetComponent("Button") + self.TxtCount = self.Transform:Find("PanelTreasureList/Viewport/PanelTreasureContent/GridCommon/TxtCount"):GetComponent("Text") + self.PanelMultipleWeeksJindu = self.Transform:Find("PanelMultipleWeeksJindu") + self.TxtTaskDescribe = self.Transform:Find("PanelMultipleWeeksJindu/TxtTaskDescribe"):GetComponent("Text") + self.TxtTaskNumQian = self.Transform:Find("PanelMultipleWeeksJindu/TxtTaskNumQian"):GetComponent("Text") + self.ProgressBg = self.Transform:Find("PanelMultipleWeeksJindu/ProgressBg") + self.ImgProgress = self.Transform:Find("PanelMultipleWeeksJindu/ProgressBg/ImgProgress"):GetComponent("Image") + + --保存初始颜色 + self.OriginalColors = { + starColor = self.ImgGradeStarActive.color, + starDisColor = self.ImgGradeStarUnactive.color + } +end + +function XUiGridTreasureGrade:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiGridTreasureGrade:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiGridTreasureGrade:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiGridTreasureGrade:AutoAddListener() + self:RegisterClickEvent(self.BtnReceive, self.OnBtnReceiveClick) + -- self:RegisterClickEvent(self.BtnClick, self.OnBtnClickClick) +end +-- auto +function XUiGridTreasureGrade:OnBtnReceiveClick() + if self.IsOnZhouMu then + local TaskData = XDataCenter.TaskManager.GetTaskDataById(self.TaskId) + local config = XDataCenter.TaskManager.GetTaskTemplate(self.TaskId) + local rewards = XRewardManager.GetRewardList(config.RewardId) + local weaponCount = 0 + local chipCount = 0 + + for i = 1, #rewards do + local rewardsId = rewards[i].TemplateId + if XDataCenter.EquipManager.IsClassifyEqualByTemplateId(rewardsId, XEquipConfig.Classify.Weapon) then + weaponCount = weaponCount + 1 + elseif XDataCenter.EquipManager.IsClassifyEqualByTemplateId(rewardsId, XEquipConfig.Classify.Awareness) then + chipCount = chipCount + 1 + end + end + if weaponCount > 0 and XDataCenter.EquipManager.CheckBagCount(weaponCount, XEquipConfig.Classify.Weapon) == false or + chipCount > 0 and XDataCenter.EquipManager.CheckBagCount(chipCount, XEquipConfig.Classify.Awareness) == false then + return + end + + XDataCenter.TaskManager.FinishTask(TaskData.Id, function(rewardGoodsList) + XUiManager.OpenUiObtain(rewardGoodsList) + self:Refresh() + end) + else + if self.CurStars < self.TreasureCfg.RequireStar then + return + end + + if self.TreasureType == XDataCenter.FubenManager.StageType.Mainline then + XDataCenter.FubenMainLineManager.ReceiveTreasureReward(function(reward) + XUiManager.OpenUiObtain(reward, CS.XTextManager.GetText("Award")) + self:Refresh() + end, self.TreasureCfg.TreasureId) + elseif self.TreasureType == XDataCenter.FubenManager.StageType.ExtraChapter then + XDataCenter.ExtraChapterManager.ReceiveTreasureReward(function(reward) + XUiManager.OpenUiObtain(reward, CS.XTextManager.GetText("Award")) + self:Refresh() + end, self.TreasureCfg.TreasureId) + elseif self.TreasureType == XDataCenter.FubenManager.StageType.NewCharAct then + XDataCenter.FubenNewCharActivityManager.GetStarReward(self.TreasureCfg.TreasureId, function(reward) + XUiManager.OpenUiObtain(reward, CS.XTextManager.GetText("Award")) + self:Refresh() + end) + end + end +end + +function XUiGridTreasureGrade:UpdateGradeGrid(curStars, treasureCfg, chapterId, starColor, starDisColor) + self.IsOnZhouMu = false + self.CurStars = curStars + self.TreasureCfg = treasureCfg + self.ChapterId = chapterId + self.ImgGradeStarActive.color = starColor or self.OriginalColors.starColor + self.ImgGradeStarUnactive.color = starDisColor or self.OriginalColors.starDisColor + self:Refresh() +end + +-- 显示多周目挑战任务 +function XUiGridTreasureGrade:UpdateGradeGridTask(taskId) + self.IsOnZhouMu = true + self.TaskId = taskId + self:Refresh() +end + +function XUiGridTreasureGrade:Refresh() + if self.IsOnZhouMu then + self.ImgGradeStarActive.gameObject:SetActiveEx(false) + self.ImgGradeStarUnactive.gameObject:SetActiveEx(false) + self.TxtGradeStarNums.gameObject:SetActiveEx(false) + self.PanelMultipleWeeksJindu.gameObject:SetActiveEx(true) + self.ProgressBg.gameObject:SetActive(false) + + local config = XDataCenter.TaskManager.GetTaskTemplate(self.TaskId) + local TaskData = XDataCenter.TaskManager.GetTaskDataById(self.TaskId) + + if #config.Condition < 2 then--显示进度 + self.ProgressBg.gameObject:SetActive(true) + self.TxtTaskNumQian.gameObject:SetActive(true) + + local result = config.Result > 0 and config.Result or 1 + self.TxtTaskDescribe.text = config.Desc + + XTool.LoopMap(TaskData.Schedule, function(_, pair) + self.ImgProgress.fillAmount = pair.Value / result + pair.Value = (pair.Value >= result) and result or pair.Value + self.TxtTaskNumQian.text = CS.XTextManager.GetText("AlreadyobtainedCount", pair.Value, result) + end) + end + + if TaskData.State == XDataCenter.TaskManager.TaskState.Achieved then + self:SetBtnActive() + elseif TaskData.State == XDataCenter.TaskManager.TaskState.Finish then + self:SetBtnAlreadyReceive() + else + self:SetBtnCannotReceive() + end + + else + local requireStars = self.TreasureCfg.RequireStar + local curStars = self.CurStars > requireStars and requireStars or self.CurStars + + self.PanelMultipleWeeksJindu.gameObject:SetActiveEx(false) + self.TxtGradeStarNums.gameObject:SetActiveEx(true) + self.TxtGradeStarNums.text = CS.XTextManager.GetText("GradeStarNum", curStars, requireStars) + + if requireStars > 0 and self.CurStars >= requireStars then + self:SetStarsActive(true) + local isGet + if self.TreasureType == XDataCenter.FubenManager.StageType.Mainline then + isGet = XDataCenter.FubenMainLineManager.IsTreasureGet(self.TreasureCfg.TreasureId) + elseif self.TreasureType == XDataCenter.FubenManager.StageType.ExtraChapter then + isGet = XDataCenter.ExtraChapterManager.IsTreasureGet(self.TreasureCfg.TreasureId) + elseif self.TreasureType == XDataCenter.FubenManager.StageType.NewCharAct then + isGet = XDataCenter.FubenNewCharActivityManager.IsTreasureGet(self.TreasureCfg.TreasureId) + end + if isGet then + self:SetBtnAlreadyReceive() + else + self:SetBtnActive() + end + else + self:SetStarsActive(false) + self:SetBtnCannotReceive() + end + end +end + +function XUiGridTreasureGrade:SetBtnActive() + self.BtnReceive.gameObject:SetActive(true) + self.ImgAlreadyReceived.gameObject:SetActive(false) + self.ImgCannotReceive.gameObject:SetActive(false) +end + +function XUiGridTreasureGrade:SetBtnCannotReceive() + self.BtnReceive.gameObject:SetActive(false) + self.ImgAlreadyReceived.gameObject:SetActive(false) + self.ImgCannotReceive.gameObject:SetActive(true) +end + +function XUiGridTreasureGrade:SetBtnAlreadyReceive() + self.BtnReceive.gameObject:SetActive(false) + self.ImgAlreadyReceived.gameObject:SetActive(true) + self.ImgCannotReceive.gameObject:SetActive(false) +end + +function XUiGridTreasureGrade:SetStarsActive(flag) + self.ImgGradeStarActive.gameObject:SetActiveEx(flag) + self.ImgGradeStarUnactive.gameObject:SetActiveEx(not flag) +end + +-- 初始化 treasure grid panel,填充数据 +function XUiGridTreasureGrade:InitTreasureList() + local rewards + if self.IsOnZhouMu then + local config = XDataCenter.TaskManager.GetTaskTemplate(self.TaskId) + rewards = XRewardManager.GetRewardList(config.RewardId) + else + if self.TreasureCfg == nil or self.TreasureCfg.RewardId == 0 then + XLog.Error("treasure have no RewardId ") + return + end + rewards = XRewardManager.GetRewardList(self.TreasureCfg.RewardId) + end + + for i, item in ipairs(rewards) do + local grid = self.GridList[i] + if not grid then + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommonItem) + grid = XUiGridCommon.New(self.RootUi, ui) + grid.Transform:SetParent(self.PanelTreasureContent, false) + self.GridList[i] = grid + end + grid:Refresh(item) + grid.GameObject:SetActive(true) + -- i = i + 1 + end + + for j = 1, #self.GridList do + if j > #rewards then + self.GridList[j].GameObject:SetActive(false) + end + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiPanelAutoFight.lua b/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiPanelAutoFight.lua new file mode 100644 index 00000000..1549dbf6 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiPanelAutoFight.lua @@ -0,0 +1,123 @@ +local XUiPanelAutoFight = XClass(nil, "XUiPanelAutoFight") + +function XUiPanelAutoFight:Ctor(ui, stageId) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.StageId = stageId + self:InitAutoScript() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelAutoFight:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiPanelAutoFight:AutoInitUi() + self.TxtCountdown = self.Transform:Find("TxtCountdown"):GetComponent("Text") +end + +function XUiPanelAutoFight:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelAutoFight:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelAutoFight:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelAutoFight:AutoAddListener() +end +-- auto +function XUiPanelAutoFight:OnAutoFightStart(stageId) + if self.StageId == stageId then + self.AutoFightRecord = XDataCenter.AutoFightManager.GetRecordByStageId(stageId) + self:BindTimer() + self.GameObject:SetActiveEx(true) + end +end + +function XUiPanelAutoFight:OnAutoFightRemove(stageId) + if self.StageId == stageId then + self:RemoveTimer() + if not XTool.UObjIsNil(self.GameObject) then + self.GameObject:SetActiveEx(false) + end + end +end + +function XUiPanelAutoFight:BindTimer() + local stageId = self.StageId + if not self.AutoFightRecord then return end + local now = XTime.GetServerNowTimestamp() + local leftTime = self.AutoFightRecord.CompleteTime - now + if leftTime < 0 then + leftTime = 0 + end + local complete = false + self:RemoveTimer() + self.TimerName = "XUiPanelAutoFight" .. stageId + XCountDown.CreateTimer(self.TimerName, leftTime, now) + XCountDown.BindTimer(self.GameObject, self.TimerName, function(v) + if v == 0 and not complete then + XEventManager.DispatchEvent(XEventId.EVENT_AUTO_FIGHT_COMPLETE, stageId) + complete = true + end + self.TxtCountdown.text = XUiHelper.GetTime(v) + end) +end + +function XUiPanelAutoFight:RemoveTimer() + if not self.TimerName then + return + end + XCountDown.RemoveTimer(self.TimerName) + self.TimerName = nil +end + +function XUiPanelAutoFight:AddEventListener() + XEventManager.AddEventListener(XEventId.EVENT_AUTO_FIGHT_START, self.OnAutoFightStart, self) + XEventManager.AddEventListener(XEventId.EVENT_AUTO_FIGHT_REMOVE, self.OnAutoFightRemove, self) +end + +function XUiPanelAutoFight:RemoveEventListener() + XEventManager.RemoveEventListener(XEventId.EVENT_AUTO_FIGHT_START, self.OnAutoFightStart, self) + XEventManager.RemoveEventListener(XEventId.EVENT_AUTO_FIGHT_REMOVE, self.OnAutoFightRemove, self) +end + +function XUiPanelAutoFight:OnEnable(stageId) + self.StageId = stageId + self.AutoFightRecord = XDataCenter.AutoFightManager.GetRecordByStageId(stageId) + self.GameObject:SetActiveEx(self.AutoFightRecord ~= nil) + + if self.Enabled then + return + end + + self:BindTimer() + self:AddEventListener() + + self.Enabled = true +end + +function XUiPanelAutoFight:OnDisable() + if not self.Enabled then + return + end + + self:RemoveTimer() + self:RemoveEventListener() + + self.Enabled = false +end + +return XUiPanelAutoFight \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiPanelBountyTask.lua b/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiPanelBountyTask.lua new file mode 100644 index 00000000..4f3c5a11 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiPanelBountyTask.lua @@ -0,0 +1,148 @@ +XUiPanelBountyTask = XClass(nil, "XUiPanelBountyTask") + +function XUiPanelBountyTask:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self:InitAutoScript() +end + +--激活 +function XUiPanelBountyTask:SetActiveEx(active) + self.GameObject:SetActiveEx(active) +end + +function XUiPanelBountyTask:SetupContent(taskData) + self.PanelComplete.gameObject:SetActiveEx(false) + self.PanelStart.gameObject:SetActiveEx(false) + + self.BountyTask = taskData + + if self.BountyTask == nil then + return + end + + + local bountyTaskStatus = XDataCenter.BountyTaskManager.BountyTaskStatus + --根据状态显示按钮状态 + if self.BountyTask.Status == bountyTaskStatus.AcceptReward or self.BountyTask.Status == bountyTaskStatus.Complete then + self.PanelComplete.gameObject:SetActiveEx(true) + else + self.PanelStart.gameObject:SetActiveEx(true) + end + + local taskConfig = XDataCenter.BountyTaskManager.GetBountyTaskConfig(self.BountyTask.Id) + if not taskConfig then + local path = XBountyTaskConfigs.GetBountyTaskPath() + XLog.ErrorTableDataNotFound("XUiPanelTaskCard:SetupTaskCard", "taskConfig", path, "Id", tostring(self.BountyTask.Id)) + return + end + + self.DifficultStageCfg = XDataCenter.BountyTaskManager.GetBountyTaskDifficultStageConfig(self.BountyTask.DifficultStageId) + self.TxtLevel.text = string.format(taskConfig.TextColor, self.DifficultStageCfg.Name) +end + +--设置任务数据 +function XUiPanelBountyTask:SetupTask() + if not self.BountyTask then + return + end + + self.BtnGet.gameObject:SetActiveEx(false) + self.BtnGo.gameObject:SetActiveEx(false) + self.PanelTask.gameObject:SetActiveEx(true) + + --根据状态显示按钮状态 + if self.BountyTask.Status == XDataCenter.BountyTaskManager.BountyTaskStatus.AcceptReward then + self.PanelDone.gameObject:SetActiveEx(true) + elseif self.BountyTask.Status == XDataCenter.BountyTaskManager.BountyTaskStatus.Complete then + self.BtnGet.gameObject:SetActiveEx(true) + else + self.BtnGo.gameObject:SetActiveEx(true) + end + + local taskConfig = XDataCenter.BountyTaskManager.GetBountyTaskConfig(self.BountyTask.Id) + if not taskConfig then + local path = XBountyTaskConfigs.GetBountyTaskPath() + XLog.ErrorTableDataNotFound("XUiPanelTaskCard:SetupTaskCard", "taskConfig", path, "Id", tostring(self.BountyTask.Id)) + return + end + + self.DifficultStageCfg = XDataCenter.BountyTaskManager.GetBountyTaskDifficultStageConfig(self.BountyTask.DifficultStageId) + + self.TxtLevel.text = self.DifficultStageCfg.Name + self.Parent:SetUiSprite(self.ImgPic, taskConfig.MonsterIcon, function() + self.ImgPic:SetNativeSize() + end) + self:SetupReward(self.BountyTask.RewardId) +end + + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelBountyTask:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiPanelBountyTask:AutoInitUi() + self.PanelStart = self.Transform:Find("PanelStart") + self.BtnSkip = self.Transform:Find("PanelStart/BtnSkip"):GetComponent("Button") + self.TxtLevel = self.Transform:Find("PanelStart/TxtLevel"):GetComponent("Text") + self.PanelComplete = self.Transform:Find("PanelComplete") + self.BtnBountyTask = self.Transform:Find("PanelComplete/BtnBountyTask"):GetComponent("Button") +end + +function XUiPanelBountyTask:GetAutoKey(uiNode, eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiPanelBountyTask:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiPanelBountyTask:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiPanelBountyTask:AutoAddListener() + self.AutoCreateListeners = {} + XUiHelper.RegisterClickEvent(self, self.BtnSkip, self.OnBtnSkipClick) + XUiHelper.RegisterClickEvent(self, self.BtnBountyTask, self.OnBtnBountyTaskClick) +end +-- auto +--跳轉 +function XUiPanelBountyTask:OnBtnSkipClick() + if not self.BountyTask then + return + end + + XDataCenter.FubenManager.GoToCurrentMainLine(self.BountyTask.DifficultStageId) +end + +--去任务界面 +function XUiPanelBountyTask:OnBtnBountyTaskClick() + if XDataCenter.MaintainerActionManager.IsStart()then + XDataCenter.FunctionalSkipManager.OnOpenMaintainerAction() + else + XLuaUiManager.Open("UiMoneyReward") + end +end + +return XUiPanelBountyTask \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiPanelBountyTaskInGrid.lua b/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiPanelBountyTaskInGrid.lua new file mode 100644 index 00000000..03ad648d --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiPanelBountyTaskInGrid.lua @@ -0,0 +1,50 @@ +local XUiPanelBountyTaskInGrid = XClass(nil, "XUiPanelBountyTaskInGrid") + +function XUiPanelBountyTaskInGrid:Ctor(ui, task) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Task = task + self:InitAutoScript() + self:Refresh() +end + +function XUiPanelBountyTaskInGrid:Refresh() + local task = self.Task + local config = XDataCenter.BountyTaskManager.GetBountyTaskConfig(task.Id) + self.RImgRole:SetRawImage(config.SmallRoleIcon) + self.PanelKill.gameObject:SetActive(task.Status == XDataCenter.BountyTaskManager.BountyTaskStatus.Complete or task.Status == XDataCenter.BountyTaskManager.BountyTaskStatus.AcceptReward) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelBountyTaskInGrid:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiPanelBountyTaskInGrid:AutoInitUi() + self.PanelKill = self.Transform:Find("PanelKill") + self.RImgRole = self.Transform:Find("ImageMask/RImgRole"):GetComponent("RawImage") +end + +function XUiPanelBountyTaskInGrid:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelBountyTaskInGrid:RegisterClickEvent函数错误, 参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelBountyTaskInGrid:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelBountyTaskInGrid:AutoAddListener() +end +-- auto +return XUiPanelBountyTaskInGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiPanelEchelon.lua b/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiPanelEchelon.lua new file mode 100644 index 00000000..f0a6febe --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiPanelEchelon.lua @@ -0,0 +1,48 @@ +local MAX_ECHELON_NUM = 5 + +local XUiPanelEchelon = XClass(nil, "XUiPanelEchelon") + +function XUiPanelEchelon:Ctor(ui, stageId) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.StageId = stageId + + XTool.InitUiObject(self) + self:Refresh() +end + +function XUiPanelEchelon:Refresh() + local groupId = XDataCenter.BfrtManager.GetGroupIdByBaseStage(self.StageId) + + local fightInfoList = XDataCenter.BfrtManager.GetFightInfoIdList(groupId) + local echelonNum = #fightInfoList + for i = 1, echelonNum do + local go = self["ImgEchelon" .. i] + if go then + go.gameObject:SetActiveEx(true) + end + end + for i = echelonNum + 1, MAX_ECHELON_NUM do + local go = self["ImgEchelon" .. i] + if go then + go.gameObject:SetActiveEx(false) + end + end + + local logisticsInfoList = XDataCenter.BfrtManager.GetLogisticsInfoIdList(groupId) + local logisticsNum = #logisticsInfoList + for i = 1, logisticsNum do + local go = self["ImgEchelonLogiistics" .. i] + if go then + go.gameObject:SetActiveEx(true) + end + end + for i = logisticsNum + 1, MAX_ECHELON_NUM do + local go = self["ImgEchelonLogiistics" .. i] + if go then + go.gameObject:SetActiveEx(false) + end + end +end + +return XUiPanelEchelon \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiPanelFightActive.lua b/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiPanelFightActive.lua new file mode 100644 index 00000000..dcba9bf6 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiPanelFightActive.lua @@ -0,0 +1,73 @@ +local XUiPanelFightActive = XClass(nil, "XUiPanelFightActive") + +function XUiPanelFightActive:Ctor(ui, stageId, clickCb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.StageId = stageId + self.ClickCb = clickCb + self:InitAutoScript() + self:Refresh() +end + +function XUiPanelFightActive:Refresh() + local stagecfg = XDataCenter.FubenManager.GetStageCfg(self.StageId) + + self.RImgFightActiveNor:SetRawImage(stagecfg.Icon) + self.TxtFightNameNor.text = stagecfg.Name +end + +function XUiPanelFightActive:UpdateStageId(stageId) + if self.StageId ~= stageId then + self.StageId = stageId + self:Refresh() + end +end + +function XUiPanelFightActive:GetKillPos() + if self.KillPos then + return self.KillPos.position + else + return self.Transform.position + end +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelFightActive:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiPanelFightActive:AutoInitUi() + self.RImgFightActiveNor = self.Transform:Find("RImgFightActiveNor"):GetComponent("RawImage") + self.TxtFightNameNor = self.Transform:Find("ImageFightTitleBgNor/TxtFightNameNor"):GetComponent("Text") + self.BtnStage = self.Transform:Find("BtnStage"):GetComponent("Button") + self.KillPos = self.Transform:Find("KillPos") +end + +function XUiPanelFightActive:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelFightActive:RegisterClickEvent函数错误, 参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelFightActive:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelFightActive:AutoAddListener() + self:RegisterClickEvent(self.BtnStage, self.OnBtnStageClick) +end +-- auto +function XUiPanelFightActive:OnBtnStageClick() + if self.ClickCb then self.ClickCb() end +end + +return XUiPanelFightActive \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiPanelHideStageNor.lua b/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiPanelHideStageNor.lua new file mode 100644 index 00000000..8ef13f78 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiPanelHideStageNor.lua @@ -0,0 +1,70 @@ +local XUiPanelHideStageNor = XClass(nil, "XUiPanelHideStageNor") + +function XUiPanelHideStageNor:Ctor(ui, stageId, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.StageId = stageId + self.RootUi = rootUi + XTool.InitUiObject(self) + self.BtnOnHideLock.CallBack = function() self:OnBtnOnHideLockClick() end + self:Refresh() +end + +function XUiPanelHideStageNor:Refresh() + local stagecfg = XDataCenter.FubenManager.GetStageCfg(self.StageId) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(self.StageId) + self.RImgHideStageNor:SetRawImage(stagecfg.Icon) + self.TxtHideStageNor.text = stagecfg.Name + self.PanelPass.gameObject:SetActiveEx(stageInfo.Passed) +end + +function XUiPanelHideStageNor:UpdateStageId(stageId) + self.StageId = stageId + self:Refresh() +end + +function XUiPanelHideStageNor:OnBtnOnHideLockClick() + if not self.StageId then return end + + local stageCfg = XDataCenter.FubenManager.GetStageCfg(self.StageId) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(self.StageId) + + if not XDataCenter.PrequelManager.CheckPrequelStageOpen(self.StageId) then + if stageCfg.RequireLevel > 0 and XPlayer.Level < stageCfg.RequireLevel then + XUiManager.TipError(CS.XTextManager.GetText("TeamLevelToOpen", stageCfg.RequireLevel)) + return + end + XUiManager.TipError(CS.XTextManager.GetText("PrequelUnTrigger")) + return + end + + if stageCfg.StageType == XFubenConfigs.STAGETYPE_STORYEGG then + if stageInfo.Passed then + self.RootUi:OnEnterStory(self.StageId, function() + XDataCenter.MovieManager.PlayMovie(stageCfg.BeginStoryId) + end) + else + self.RootUi:OnEnterStory(self.StageId, function() + XDataCenter.PrequelManager.FinishStoryRequest(self.StageId, function() + XDataCenter.MovieManager.PlayMovie(stageCfg.BeginStoryId, function() + self.RootUi:RefreshRegional() + end) + end) + end) + end + XDataCenter.PrequelManager.UpdateShowChapter(self.StageId) + end + + if stageCfg.StageType == XFubenConfigs.STAGETYPE_FIGHTEGG then + if not stageCfg then + XLog.ErrorTableDataNotFound("XUiPanelHideStageNor:OnBtnOnHideLockClick", + "stageCfg", "Share/Fuben/Stage.tab", "StageId", tostring(self.StageId)) + return + end + self.RootUi:OnEnterFight(self.StageId, function() + XDataCenter.FubenManager.EnterPrequelFight(self.StageId) + end) + end +end + +return XUiPanelHideStageNor \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiPanelHideTagNor.lua b/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiPanelHideTagNor.lua new file mode 100644 index 00000000..116f43dd --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiPanelHideTagNor.lua @@ -0,0 +1,103 @@ +local XUiPanelHideTagNor = XClass(nil, "XUiPanelHideTagNor") + +function XUiPanelHideTagNor:Ctor(ui, stageId, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.StageId = stageId + self.RootUi = rootUi + self:InitAutoScript() + self:Refresh() +end + +function XUiPanelHideTagNor:Refresh() + local stageInfo = XDataCenter.FubenManager.GetStageInfo(self.StageId) + if self.PanelPass then + self.PanelPass.gameObject:SetActiveEx(stageInfo.Passed) + end +end + +function XUiPanelHideTagNor:UpdateStageId(stageId) + self.StageId = stageId + self:Refresh() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelHideTagNor:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiPanelHideTagNor:AutoInitUi() + self.BtnOnHideLock = self.Transform:Find("BtnOnHideLock"):GetComponent("Button") + self.PanelPass = self.Transform:Find("ImageHideTagNor/PanelPass") +end + +function XUiPanelHideTagNor:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelHideTagNor:RegisterClickEvent函数错误, 参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelHideTagNor:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelHideTagNor:AutoAddListener() + self:RegisterClickEvent(self.BtnOnHideLock, self.OnBtnOnHideLockClick) +end +-- auto +function XUiPanelHideTagNor:OnBtnOnHideLockClick() + if not self.StageId then return end + + local stageCfg = XDataCenter.FubenManager.GetStageCfg(self.StageId) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(self.StageId) + + if not XDataCenter.PrequelManager.CheckPrequelStageOpen(self.StageId) then + if stageCfg.RequireLevel > 0 and XPlayer.Level < stageCfg.RequireLevel then + XUiManager.TipError(CS.XTextManager.GetText("TeamLevelToOpen", stageCfg.RequireLevel)) + return + end + XUiManager.TipError(CS.XTextManager.GetText("PrequelUnTrigger")) + return + end + + if stageCfg.StageType == XFubenConfigs.STAGETYPE_STORYEGG then + if stageInfo.Passed then + self.RootUi:OnEnterStory(self.StageId, function() + XDataCenter.MovieManager.PlayMovie(stageCfg.BeginStoryId, function() + XDataCenter.PrequelManager.UpdateShowChapter(self.StageId) + end) + end) + else + self.RootUi:OnEnterStory(self.StageId, function() + XDataCenter.PrequelManager.FinishStoryRequest(self.StageId, function() + XDataCenter.MovieManager.PlayMovie(stageCfg.BeginStoryId, function() + self.RootUi:RefreshRegional() + XDataCenter.PrequelManager.UpdateShowChapter(self.StageId) + end) + end) + end) + end + end + + if stageCfg.StageType == XFubenConfigs.STAGETYPE_FIGHTEGG then + if not stageCfg then + XLog.ErrorTableDataNotFound("XUiPanelHideTagNor:OnBtnOnHideLockClick", + "stageCfg", "Share/Fuben/Stage.tab", "StageId", tostring(self.StageId)) + return + end + self.RootUi:OnEnterFight(self.StageId, function() + XDataCenter.FubenManager.EnterPrequelFight(self.StageId) + end) + end +end + +return XUiPanelHideTagNor \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiPanelRewardTips.lua b/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiPanelRewardTips.lua new file mode 100644 index 00000000..c1450881 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiPanelRewardTips.lua @@ -0,0 +1,60 @@ +local XUiPanelRewardTips = XClass(nil, "XUiPanelRewardTips") + +function XUiPanelRewardTips:Ctor(ui,parent,stageId) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Parent = parent + self.StageId = stageId + self:InitAutoScript() + self:Refresh() +end + +function XUiPanelRewardTips:Refresh() + local stageCfg = XDataCenter.FubenManager.GetstageCfg(self.StageId) + local rewardTipId = stageCfg.RewardTipId + local rewardTipIcon, rewardTipQuality = self:GetIconById(rewardTipId) + if rewardTipIcon then + self.RImgIcon:SetRawImage(rewardTipIcon) + XUiHelper.SetQualityIcon(self.Parent, self.ImgQuality, rewardTipQuality) + end +end + +function XUiPanelRewardTips:GetIconById(id) + if not id or id == 0 then return nil end + return XGoodsCommonManager.GetGoodsIcon(id), XGoodsCommonManager.GetGoodsDefaultQuality(id) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelRewardTips:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiPanelRewardTips:AutoInitUi() + self.RImgIcon = self.Transform:Find("RImgIcon"):GetComponent("RawImage") + self.ImgQuality = self.Transform:Find("ImgQuality"):GetComponent("Image") +end + +function XUiPanelRewardTips:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelRewardTips:RegisterClickEvent函数错误, 参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelRewardTips:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelRewardTips:AutoAddListener() +end +-- auto + +return XUiPanelRewardTips diff --git a/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiPanelStageActive.lua b/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiPanelStageActive.lua new file mode 100644 index 00000000..6c134359 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiPanelStageActive.lua @@ -0,0 +1,70 @@ +local XUiPanelStageActive = XClass(nil, "XUiPanelStageActive") + +function XUiPanelStageActive:Ctor(ui, stageId, chapterOrderId) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.StageId = stageId + self.ChapterOrderId = chapterOrderId + self:InitAutoScript() + self:Refresh() +end + +function XUiPanelStageActive:Refresh() + local stageId = self.StageId + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + --文字 + if not XTool.UObjIsNil(self.TxtStage) then + local strTxtStage + + if XDataCenter.BfrtManager.CheckStageTypeIsBfrt(stageId) then + strTxtStage = self.ChapterOrderId .. "-" .. XDataCenter.BfrtManager.GetGroupOrderIdByStageId(stageId) + elseif stageInfo.Type == XDataCenter.FubenManager.StageType.ExtraChapter then + local stageTitle = XDataCenter.ExtraChapterManager.GetChapterDetailsStageTitle(stageInfo.ChapterId) + strTxtStage = stageTitle .. "-" .. stageCfg.OrderId + else + strTxtStage = self.ChapterOrderId .. "-" .. stageCfg.OrderId + end + self.TxtStage.text = strTxtStage + end + + --图标 + if not XTool.UObjIsNil(self.RImgNor) then + local icon = stageCfg.Icon + if icon then self.RImgNor:SetRawImage(icon) end + end +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelStageActive:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiPanelStageActive:AutoInitUi() + self.TxtStage = XUiHelper.TryGetComponent(self.Transform, "TxtStage", "Text") + self.RImgNor = XUiHelper.TryGetComponent(self.Transform, "RImgNor", "RawImage") +end + +function XUiPanelStageActive:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelStageActive:RegisterClickEvent函数错误, 参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelStageActive:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelStageActive:AutoAddListener() +end +-- auto +return XUiPanelStageActive \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiPanelStageLock.lua b/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiPanelStageLock.lua new file mode 100644 index 00000000..7b663a4f --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiPanelStageLock.lua @@ -0,0 +1,66 @@ +local XUiPanelStageLock = XClass(nil, "XUiPanelStageLock") + +function XUiPanelStageLock:Ctor(ui, stageId, chapterOrderId) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.StageId = stageId + self.ChapterOrderId = chapterOrderId + self:InitAutoScript() + self:Refresh() +end + +function XUiPanelStageLock:Refresh() + local stageId = self.StageId + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + + if not XTool.UObjIsNil(self.TxtStage) then + local strTxtStage + + if XDataCenter.BfrtManager.CheckStageTypeIsBfrt(stageId) then + strTxtStage = self.ChapterOrderId .. "-" .. XDataCenter.BfrtManager.GetGroupOrderIdByStageId(stageId) + else + strTxtStage = self.ChapterOrderId .. "-" .. stageCfg.OrderId + end + self.TxtStage.text = strTxtStage + end + + --图标 + if not XTool.UObjIsNil(self.RImgNor) then + local icon = stageCfg.Icon + if icon then self.RImgNor:SetRawImage(icon) end + end +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelStageLock:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiPanelStageLock:AutoInitUi() + self.TxtStage = XUiHelper.TryGetComponent(self.Transform, "TxtStage", "Text") + self.RImgNor = XUiHelper.TryGetComponent(self.Transform, "RImgNor", "RawImage") +end + +function XUiPanelStageLock:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelStageLock:RegisterClickEvent函数错误, 参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelStageLock:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelStageLock:AutoAddListener() +end +-- auto +return XUiPanelStageLock \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiPanelStageSelected.lua b/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiPanelStageSelected.lua new file mode 100644 index 00000000..f55ef6cb --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiPanelStageSelected.lua @@ -0,0 +1,65 @@ +local XUiPanelStageSelected = XClass(nil, "XUiPanelStageSelected") + +function XUiPanelStageSelected:Ctor(ui, stageId, chapterOrderId) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.StageId = stageId + self.ChapterOrderId = chapterOrderId + self:InitAutoScript() + self:Refresh() +end + +function XUiPanelStageSelected:Refresh() + local stageId = self.StageId + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + --文字 + local strTxtStage + if XDataCenter.BfrtManager.CheckStageTypeIsBfrt(stageId) then + strTxtStage = self.ChapterOrderId .. "-" .. XDataCenter.BfrtManager.GetGroupOrderIdByStageId(stageId) + elseif stageInfo.Type == XDataCenter.FubenManager.StageType.ExtraChapter then + local stageTitle = XDataCenter.ExtraChapterManager.GetChapterDetailsStageTitle(stageInfo.ChapterId) + strTxtStage = stageTitle .. "-" .. stageCfg.OrderId + else + strTxtStage = self.ChapterOrderId .. "-" .. stageCfg.OrderId + end + self.TxtStage.text = strTxtStage + + --图标 + local icon = stageCfg.Icon + if icon then self.RImgNor:SetRawImage(icon) end +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelStageSelected:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiPanelStageSelected:AutoInitUi() + self.TxtStage = self.Transform:Find("TxtStage"):GetComponent("Text") + self.RImgNor = self.Transform:Find("RImgNor"):GetComponent("RawImage") +end + +function XUiPanelStageSelected:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelStageSelected:RegisterClickEvent函数错误, 参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelStageSelected:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelStageSelected:AutoAddListener() +end +-- auto +return XUiPanelStageSelected \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiPanelStars.lua b/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiPanelStars.lua new file mode 100644 index 00000000..db0b9132 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiPanelStars.lua @@ -0,0 +1,62 @@ +local MaxStarCount = 3 + +local XUiPanelStars = XClass(nil, "XUiPanelStars") + +function XUiPanelStars:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self:InitAutoScript() +end + +function XUiPanelStars:OnEnable(starsMap, starColor, starDisColor) + self:SetStarActive(starsMap, starColor, starDisColor) +end + +function XUiPanelStars:SetStarActive(starsMap, starColor, starDisColor) + for i = 1, MaxStarCount do + local isShow = starsMap[i] + self["Img" .. i].gameObject:SetActive(isShow) + self["ImgDis" .. i].gameObject:SetActive(not isShow) + + if (starColor) then self["Img" .. i].color = starColor end + if (starDisColor) then self["ImgDis" .. i].color = starDisColor end + end +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelStars:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiPanelStars:AutoInitUi() + self.ImgDis2 = self.Transform:Find("Star2/ImgDis2"):GetComponent("Image") + self.Img1 = self.Transform:Find("Star1/Img1"):GetComponent("Image") + self.ImgDis1 = self.Transform:Find("Star1/ImgDis1"):GetComponent("Image") + self.Img2 = self.Transform:Find("Star2/Img2"):GetComponent("Image") + self.ImgDis3 = self.Transform:Find("Star3/ImgDis3"):GetComponent("Image") + self.Img3 = self.Transform:Find("Star3/Img3"):GetComponent("Image") +end + +function XUiPanelStars:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelStars:RegisterClickEvent函数错误, 参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelStars:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelStars:AutoAddListener() +end +-- auto +return XUiPanelStars \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiPanelStoryActive.lua b/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiPanelStoryActive.lua new file mode 100644 index 00000000..b1b6c7ac --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiPanelStoryActive.lua @@ -0,0 +1,89 @@ +local XUiPanelStoryActive = XClass(nil, "XUiPanelStoryActive") + +function XUiPanelStoryActive:Ctor(ui, stageId, chapterOrderId) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.StageId = stageId + self.ChapterOrderId = chapterOrderId + self:InitAutoScript() + self:Refresh() +end + +function XUiPanelStoryActive:Refresh() + local stageId = self.StageId + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + if stageInfo.Type == XDataCenter.FubenManager.StageType.Mainline or stageInfo.Type == XDataCenter.FubenManager.StageType.RepeatChallenge + or stageInfo.Type == XDataCenter.FubenManager.StageType.ExtraChapter then + local strTxtStage + if XDataCenter.BfrtManager.CheckStageTypeIsBfrt(stageId) then + strTxtStage = self.ChapterOrderId .. "-" .. XDataCenter.BfrtManager.GetGroupOrderIdByStageId(stageId) + elseif stageInfo.Type == XDataCenter.FubenManager.StageType.ExtraChapter then + local stageTitle = XDataCenter.ExtraChapterManager.GetChapterDetailsStageTitle(stageInfo.ChapterId) + strTxtStage = stageTitle .. "-" .. stageCfg.OrderId + else + strTxtStage = self.ChapterOrderId .. "-" .. stageCfg.OrderId + end + if self.TxtStage then + self.TxtStage.text = strTxtStage + end + + if self.ImgStageOrder then + self.ImgStageOrder.gameObject:SetActive(true) + end + else + if self.ImgStageOrder then + self.ImgStageOrder.gameObject:SetActive(false) + end + end +end + +function XUiPanelStoryActive:UpdateStageId(stageId) + if self.StageId ~= stageId then + self.StageId = stageId + self:Refresh() + end +end + +function XUiPanelStoryActive:GetKillPos() + if self.KillPos then + return self.KillPos.position + else + return self.Transform.position + end +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelStoryActive:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiPanelStoryActive:AutoInitUi() + self.ImgStageOrder = XUiHelper.TryGetComponent(self.Transform, "ImgStageOrder", "Image") + self.TxtStage = XUiHelper.TryGetComponent(self.Transform, "TxtStage", "Text") + self.KillPos = XUiHelper.TryGetComponent(self.Transform, "KillPos", "Transform") +end + +function XUiPanelStoryActive:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelStoryActive:RegisterClickEvent函数错误, 参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelStoryActive:RegisterClickEvent函数错误, 参数func需要是function类型") + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelStoryActive:AutoAddListener() +end +-- auto +return XUiPanelStoryActive \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiPanelStorySelected.lua b/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiPanelStorySelected.lua new file mode 100644 index 00000000..47fa0157 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiPanelStorySelected.lua @@ -0,0 +1,88 @@ +local XUiPanelStorySelected = XClass(nil, "XUiPanelStorySelected") + +function XUiPanelStorySelected:Ctor(ui, stageId, chapterOrderId) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.StageId = stageId + self.ChapterOrderId = chapterOrderId + self:InitAutoScript() + self:Refresh() +end + +function XUiPanelStorySelected:Refresh() + local stageId = self.StageId + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + if stageInfo.Type == XDataCenter.FubenManager.StageType.Mainline or stageInfo.Type == XDataCenter.FubenManager.StageType.RepeatChallenge + or stageInfo.Type == XDataCenter.FubenManager.StageType.ExtraChapter then + local strTxtStage + if XDataCenter.BfrtManager.CheckStageTypeIsBfrt(stageId) then + strTxtStage = self.ChapterOrderId .. "-" .. XDataCenter.BfrtManager.GetGroupOrderIdByStageId(stageId) + elseif stageInfo.Type == XDataCenter.FubenManager.StageType.ExtraChapter then + local stageTitle = XDataCenter.ExtraChapterManager.GetChapterDetailsStageTitle(stageInfo.ChapterId) + strTxtStage = stageTitle .. "-" .. stageCfg.OrderId + else + strTxtStage = self.ChapterOrderId .. "-" .. stageCfg.OrderId + end + if self.TxtStage then + self.TxtStage.text = strTxtStage + end + if self.ImgStageOrder then + self.ImgStageOrder.gameObject:SetActive(true) + end + else + if self.ImgStageOrder then + self.ImgStageOrder.gameObject:SetActive(false) + end + end +end + +function XUiPanelStorySelected:UpdateStageId(stageId) + if self.StageId ~= stageId then + self.StageId = stageId + self:Refresh() + end +end + +function XUiPanelStorySelected:GetKillPos() + if self.KillPos then + return self.KillPos.position + else + return self.Transform.position + end +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelStorySelected:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiPanelStorySelected:AutoInitUi() + self.ImgStageOrder = XUiHelper.TryGetComponent(self.Transform, "ImgStageOrder", "Image") + self.TxtStage = XUiHelper.TryGetComponent(self.Transform, "TxtStage", "Text") + self.KillPos = XUiHelper.TryGetComponent(self.Transform, "KillPos", "Transform") +end + +function XUiPanelStorySelected:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelStorySelected:RegisterClickEvent函数错误, 参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelStorySelected:RegisterClickEvent函数错误, 参数func需要是function类型") + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelStorySelected:AutoAddListener() +end +-- auto +return XUiPanelStorySelected \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiPanelStoryUnactive.lua b/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiPanelStoryUnactive.lua new file mode 100644 index 00000000..122b513f --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenMainLineChapter/XUiPanelStoryUnactive.lua @@ -0,0 +1,72 @@ +local XUiPanelStoryUnactive = XClass(nil, "XUiPanelStoryUnactive") + +function XUiPanelStoryUnactive:Ctor(ui, stageId, chapterOrderId) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.StageId = stageId + self.ChapterOrderId = chapterOrderId + self:InitAutoScript() + self:Refresh() +end + +function XUiPanelStoryUnactive:Refresh() + local stageId = self.StageId + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + if stageInfo.Type == XDataCenter.FubenManager.StageType.Mainline then + local strTxtStage + if XDataCenter.BfrtManager.CheckStageTypeIsBfrt(stageId) then + strTxtStage = self.ChapterOrderId .. "-" .. XDataCenter.BfrtManager.GetGroupOrderIdByStageId(stageId) + elseif stageInfo.Type == XDataCenter.FubenManager.StageType.ExtraChapter then + local stageTitle = XDataCenter.ExtraChapterManager.GetChapterDetailsStageTitle(stageInfo.ChapterId) + strTxtStage = stageTitle .. "-" .. stageCfg.OrderId + else + strTxtStage = self.ChapterOrderId .. "-" .. stageCfg.OrderId + end + self.TxtStage.text = strTxtStage + self.ImgStageOrder.gameObject:SetActive(true) + else + self.ImgStageOrder.gameObject:SetActive(false) + end +end + +function XUiPanelStoryUnactive:UpdateStageId(stageId) + if self.StageId ~= stageId then + self.StageId = stageId + self:Refresh() + end +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelStoryUnactive:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiPanelStoryUnactive:AutoInitUi() + self.ImgStageOrder = self.Transform:Find("ImgStageOrder"):GetComponent("Image") + self.TxtStage = self.Transform:Find("ImgStageOrder/TxtStage"):GetComponent("Text") +end + +function XUiPanelStoryUnactive:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelStoryUnactive:RegisterClickEvent函数错误, 参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelStoryUnactive:RegisterClickEvent函数错误, 参数func需要是function类型") + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelStoryUnactive:AutoAddListener() +end +-- auto +return XUiPanelStoryUnactive \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenMainLineDetail/XUiFubenMainLineDetail.lua b/Resources/Scripts/XUi/XUiFubenMainLineDetail/XUiFubenMainLineDetail.lua new file mode 100644 index 00000000..c857fcf0 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenMainLineDetail/XUiFubenMainLineDetail.lua @@ -0,0 +1,283 @@ +local XUiFubenMainLineDetail = XLuaUiManager.Register(XLuaUi, "UiFubenMainLineDetail") + +function XUiFubenMainLineDetail:OnAwake() + self:InitAutoScript() + self.GridStageStar.gameObject:SetActive(false) + self.GridCommon.gameObject:SetActive(false) + self:InitStarPanels() +end + +function XUiFubenMainLineDetail:OnStart(rootUi) + self.GridList = {} + self.RootUi = rootUi + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) +end + +function XUiFubenMainLineDetail:OnEnable() + -- 动画 + self.IsPlaying = true + self:PlayAnimation("AnimBegin", handler(self, function() + self.IsPlaying = false + end)) + + self:AddEventListener() + self.IsOpen = true + + self:Refresh(self.RootUi.Stage) +end + +function XUiFubenMainLineDetail:OnDisable() + self:RemoveEventListener() + self.IsOpen = false +end + +function XUiFubenMainLineDetail:InitStarPanels() + self.GridStarList = {} + for i = 1, 3 do + local ui = self.Transform:Find("SafeAreaContentPane/PanelDetail/PanelTargetList/GridStageStar" .. i) + ui.gameObject:SetActive(true) + local grid = XUiGridStageStar.New(ui) + self.GridStarList[i] = grid + end +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiFubenMainLineDetail:InitAutoScript() + self:AutoAddListener() +end + +function XUiFubenMainLineDetail:AutoAddListener() + self:RegisterClickEvent(self.BtnAddNum, self.OnBtnAddNumClick) + self:RegisterClickEvent(self.BtnEnter, self.OnBtnEnterClick) + self:RegisterClickEvent(self.BtnEnterB, self.OnBtnEnterBClick) + self:RegisterClickEvent(self.BtnAutoFight, self.OnBtnAutoFightClick) + self:RegisterClickEvent(self.BtnAutoFightComplete, self.OnBtnAutoFightCompleteClick) +end +-- auto +function XUiFubenMainLineDetail:OnBtnEnterBClick() + self:OnBtnEnterClick() +end + +function XUiFubenMainLineDetail:OnBtnAutoFightClick() + XDataCenter.AutoFightManager.CheckOpenDialog(self.Stage.StageId, self.Stage) +end + +function XUiFubenMainLineDetail:OnBtnAutoFightCompleteClick() + local index = XDataCenter.AutoFightManager.GetIndexByStageId(self.Stage.StageId) + XDataCenter.AutoFightManager.ObtainRewards(index) +end + +function XUiFubenMainLineDetail:OnBtnCloseClick() + self:Hide() +end + +function XUiFubenMainLineDetail:OnBtnAddNumClick() + local challengeData = XDataCenter.FubenMainLineManager.GetStageBuyChallengeData(self.Stage.StageId) + XLuaUiManager.Open("UiBuyAsset", 1, function() + self:UpdateCommon() + end, challengeData) +end + +function XUiFubenMainLineDetail:OnBtnEnterClick() + if self.IsPlaying then + return + end + + if self.Stage == nil then + XLog.Error("XUiFubenMainLineDetail.OnBtnEnterClick: Can not find stage!") + return + end + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_FUBEN_ENTERFIGHT, self.Stage) +end + +function XUiFubenMainLineDetail:Hide() + if self.IsPlaying or not self.IsOpen then + return + end + + self.IsPlaying = true + self:PlayAnimation("AnimEnd", handler(self, function() + if XTool.UObjIsNil(self.GameObject) then + return + end + self.IsPlaying = false + self:Close() + end)) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_FUBEN_CLOSE_FUBENSTAGEDETAIL) +end + +function XUiFubenMainLineDetail:Refresh(stage) + self.Stage = stage or self.Stage + self:UpdateCommon() + self:UpdateRewards() + self:UpdateDifficulty() + self:UpdateStageFightControl()--更新战力限制提示 +end + +function XUiFubenMainLineDetail:UpdateCommon() + local stageCfg = XDataCenter.FubenManager.GetStageCfg(self.Stage.StageId) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(self.Stage.StageId) + local chapterOrderId = XDataCenter.FubenMainLineManager.GetChapterOrderIdByStageId(self.Stage.StageId) + + self.TxtTitle.text = chapterOrderId .. "-" .. stageCfg.OrderId .." "..self.Stage.Name + self.TxtDesc.text = self.Stage.Description + self.TxtATNums.text = self.Stage.RequireActionPoint + + local maxChallengeNum = XDataCenter.FubenManager.GetStageMaxChallengeNums(self.Stage.StageId) + local buyChallengeCount = XDataCenter.FubenManager.GetStageBuyChallengeCount(self.Stage.StageId) + + self.PanelNums.gameObject:SetActive(maxChallengeNum > 0) + self.PanelNoLimitCount.gameObject:SetActive(maxChallengeNum <= 0) + self.BtnAddNum.gameObject:SetActive(buyChallengeCount > 0) + local showAutoFightBtn = false + if stageCfg.AutoFightId > 0 then + local autoFightAvailable = XDataCenter.AutoFightManager.CheckAutoFightAvailable(self.Stage.StageId) == XCode.Success + if autoFightAvailable then + self:SetAutoFightState(XDataCenter.AutoFightManager.State.None) + showAutoFightBtn = true + end + end + self:SetAutoFightActive(showAutoFightBtn) + + if maxChallengeNum > 0 then + local stageData = XDataCenter.FubenManager.GetStageData(self.Stage.StageId) + local chanllengeNum = stageData and stageData.PassTimesToday or 0 + self.TxtAllNums.text = "/" .. maxChallengeNum + self.TxtLeftNums.text = maxChallengeNum - chanllengeNum + end + + local firstDrop = false + if not stageInfo.Passed then + local cfg = XDataCenter.FubenManager.GetStageLevelControl(self.Stage.StageId) + if cfg and cfg.FirstRewardShow > 0 or self.Stage.FirstRewardShow > 0 then + firstDrop = true + end + end + self.TxtFirstDrop.gameObject:SetActive(firstDrop) + self.TxtDrop.gameObject:SetActive(not firstDrop) + + for i = 1, 3 do + self.GridStarList[i]:Refresh(self.Stage.StarDesc[i], stageInfo.StarsMap[i]) + end +end + +function XUiFubenMainLineDetail:UpdateDifficulty() + local nanDuIcon = XDataCenter.FubenManager.GetDifficultIcon(self.Stage.StageId) + --赏金任务 + local IsBountyTaskPreFight, task = XDataCenter.BountyTaskManager.CheckBountyTaskPreFight(self.Stage.StageId) + if IsBountyTaskPreFight then + local config = XDataCenter.BountyTaskManager.GetBountyTaskConfig(task.Id) + nanDuIcon = config.StageIcon + end + self.RImgNandu:SetRawImage(nanDuIcon) +end + +function XUiFubenMainLineDetail:UpdateRewards() + local stage = self.Stage + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stage.StageId) + + -- 获取显示奖励Id + local rewardId = 0 + local IsFirst = false + local cfg = XDataCenter.FubenManager.GetStageLevelControl(stage.StageId) + if not stageInfo.Passed then + rewardId = cfg and cfg.FirstRewardShow or stage.FirstRewardShow + if cfg and cfg.FirstRewardShow > 0 or stage.FirstRewardShow > 0 then + IsFirst = true + end + end + if rewardId == 0 then + rewardId = cfg and cfg.FinishRewardShow or stage.FinishRewardShow + end + if rewardId == 0 then + for j = 1, #self.GridList do + self.GridList[j].GameObject:SetActive(false) + end + return + end + + local rewards = IsFirst and XRewardManager.GetRewardList(rewardId) or XRewardManager.GetRewardListNotCount(rewardId) + if rewards then + for i, item in ipairs(rewards) do + local grid + if self.GridList[i] then + grid = self.GridList[i] + else + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommon) + grid = XUiGridCommon.New(self, ui) + grid.Transform:SetParent(self.PanelDropContent, false) + self.GridList[i] = grid + end + grid:Refresh(item) + grid.GameObject:SetActive(true) + end + end + + local rewardsCount = 0 + if rewards then + rewardsCount = #rewards + end + + for j = 1, #self.GridList do + if j > rewardsCount then + self.GridList[j].GameObject:SetActive(false) + end + end +end + +function XUiFubenMainLineDetail:UpdateStageFightControl() + local stageInfo = XDataCenter.FubenManager.GetStageInfo(self.Stage.StageId) + if self.StageFightControl == nil then + self.StageFightControl = XUiStageFightControl.New(self.PanelStageFightControl, self.Stage.FightControlId) + end + if not stageInfo.Passed and stageInfo.Unlock then + self.StageFightControl.GameObject:SetActive(true) + self.StageFightControl:UpdateInfo(self.Stage.FightControlId) + else + self.StageFightControl.GameObject:SetActive(false) + end +end + +function XUiFubenMainLineDetail:SetAutoFightActive(value) + self.PanelAutoFightButton.gameObject:SetActive(value) + self.BtnEnter.gameObject:SetActive(not value) +end + +function XUiFubenMainLineDetail:SetAutoFightState(value) + local state = XDataCenter.AutoFightManager.State + self.BtnAutoFight.gameObject:SetActive(value == state.None) + self.ImgAutoFighting.gameObject:SetActive(value == state.Fighting) + self.BtnAutoFightComplete.gameObject:SetActive(value == state.Complete) +end + +function XUiFubenMainLineDetail:OnAutoFightStart(stageId) + if self.Stage.StageId == stageId then + self.ParentUi:CloseStageDetail() + end +end + +function XUiFubenMainLineDetail:OnAutoFightRemove(stageId) + if self.Stage.StageId == stageId then + self:SetAutoFightState(XDataCenter.AutoFightManager.State.None) + end +end + +function XUiFubenMainLineDetail:OnAutoFightComplete(stageId) + if self.Stage.StageId == stageId then + self:SetAutoFightState(XDataCenter.AutoFightManager.State.Complete) + end +end + +function XUiFubenMainLineDetail:AddEventListener() + XEventManager.AddEventListener(XEventId.EVENT_AUTO_FIGHT_START, self.OnAutoFightStart, self) + XEventManager.AddEventListener(XEventId.EVENT_AUTO_FIGHT_REMOVE, self.OnAutoFightRemove, self) + XEventManager.AddEventListener(XEventId.EVENT_AUTO_FIGHT_COMPLETE, self.OnAutoFightComplete, self) +end + +function XUiFubenMainLineDetail:RemoveEventListener() + XEventManager.RemoveEventListener(XEventId.EVENT_AUTO_FIGHT_START, self.OnAutoFightStart, self) + XEventManager.RemoveEventListener(XEventId.EVENT_AUTO_FIGHT_REMOVE, self.OnAutoFightRemove, self) + XEventManager.RemoveEventListener(XEventId.EVENT_AUTO_FIGHT_COMPLETE, self.OnAutoFightComplete, self) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenMainLineDetail/XUiGridStageStar.lua b/Resources/Scripts/XUi/XUiFubenMainLineDetail/XUiGridStageStar.lua new file mode 100644 index 00000000..9071850e --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenMainLineDetail/XUiGridStageStar.lua @@ -0,0 +1,56 @@ +XUiGridStageStar = XClass(nil, "XUiGridStageStar") + +function XUiGridStageStar:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self:InitAutoScript() +end + +function XUiGridStageStar:Refresh(desc, active) + self.TxtUnActive.text = desc + self.TxtActive.text = desc + local isDescNotEmpty = desc == nil or desc == "" + if isDescNotEmpty then + self.PanelUnActive.gameObject:SetActive(false) + self.PanelActive.gameObject:SetActive(false) + else + self.PanelUnActive.gameObject:SetActive(not active) + self.PanelActive.gameObject:SetActive(active) + end +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiGridStageStar:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiGridStageStar:AutoInitUi() + self.PanelUnActive = self.Transform:Find("PanelUnActive") + self.TxtUnActive = self.Transform:Find("PanelUnActive/TxtUnActive"):GetComponent("Text") + self.PanelActive = self.Transform:Find("PanelActive") + self.TxtActive = self.Transform:Find("PanelActive/TxtActive"):GetComponent("Text") +end + +function XUiGridStageStar:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiGridStageStar:RegisterClickEvent函数错误, 参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiGridStageStar:RegisterClickEvent函数错误, 参数func需要是function类型") + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiGridStageStar:AutoAddListener() +end +-- auto +return XUiGridStageStar \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenPartnerTeaching/XUiGridPartnerTeachingBanner.lua b/Resources/Scripts/XUi/XUiFubenPartnerTeaching/XUiGridPartnerTeachingBanner.lua new file mode 100644 index 00000000..84556d95 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenPartnerTeaching/XUiGridPartnerTeachingBanner.lua @@ -0,0 +1,92 @@ +local XUiGridPartnerTeachingBanner = XClass(nil, "XUiGridPartnerTeachingBanner") + +function XUiGridPartnerTeachingBanner:Ctor(ui, parent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Parent = parent + XTool.InitUiObject(self) +end + +function XUiGridPartnerTeachingBanner:Refresh(chapterId) + self.ChapterId = chapterId + + -- 图标 + self.RImgBg:SetRawImage(XPartnerTeachingConfigs.GetChapterBannerIcon(chapterId)) + + -- 名称 + self.TxtName.text = XPartnerTeachingConfigs.GetChapterName(chapterId) + + -- 关卡进度 + local progressRateTip = CS.XTextManager.GetText("PartnerTeachingProgressRate") + local passNum, totalNum = XDataCenter.PartnerTeachingManager.GetChapterProgress(chapterId) + self.TxtProgressRate.text = string.format(progressRateTip, tostring(passNum), tostring(totalNum)) + + -- 活动标签 + local whetherInActivity = XDataCenter.PartnerTeachingManager.WhetherInActivity(chapterId) + self.PanelActivityTag.gameObject:SetActiveEx(whetherInActivity) + + -- 活动剩余时间 + self.PanelLeftTime.gameObject:SetActiveEx(whetherInActivity) + if whetherInActivity then + self:RefreshTimer() + end + + -- 解锁状态 + self.IsUnlock, self.LockTip = XDataCenter.PartnerTeachingManager.WhetherUnLockChapter(chapterId) + if self.IsUnlock then + self.ImgLock.gameObject:SetActiveEx(false) + else + self.ImgLock.gameObject:SetActiveEx(true) + self.TxtLock.text = self.LockTip + end +end + +--- +--- 刷新注册的计时器函数 +function XUiGridPartnerTeachingBanner:RefreshTimer() + local leftTime = XDataCenter.PartnerTeachingManager.GetLeftTimeStamp(self.ChapterId) + + -- 刷新剩余时间 + local func = function() + leftTime = leftTime > 0 and leftTime or 0 + + local dataTime = XUiHelper.GetTime(leftTime, XUiHelper.TimeFormatType.ACTIVITY) + if self.TextLeftTime then + local leftTimeTip = CS.XTextManager.GetText("PartnerTeachingActivityLeftTime") + self.TextLeftTime.text = string.format(leftTimeTip, dataTime) + end + + if leftTime <= 0 then + self:RemoveTimer() + self:Refresh(self.ChapterId) + end + end + + func() + self.Parent:RegisterTimerFun(self.ChapterId, function() + leftTime = leftTime - 1 + func() + end) +end + +--- +--- 格子回收时移除计时器函数 +function XUiGridPartnerTeachingBanner:OnRecycle() + self:RemoveTimer() +end + +--- +--- 移除计时器函数 +function XUiGridPartnerTeachingBanner:RemoveTimer() + self.Parent:RemoveTimerFun(self.ChapterId) +end + +function XUiGridPartnerTeachingBanner:OnClick() + if self.IsUnlock then + XLuaUiManager.Open("UiPartnerTeachingChapter", self.ChapterId) + else + XUiManager.TipMsg(self.LockTip) + end +end + +return XUiGridPartnerTeachingBanner \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenPartnerTeaching/XUiGridPartnerTeachingStage.lua b/Resources/Scripts/XUi/XUiFubenPartnerTeaching/XUiGridPartnerTeachingStage.lua new file mode 100644 index 00000000..a4ff8f6d --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenPartnerTeaching/XUiGridPartnerTeachingStage.lua @@ -0,0 +1,111 @@ +local XUiGridPartnerTeachingStage = XClass(nil, "XUiGridPartnerTeachingStage") + +function XUiGridPartnerTeachingStage:Ctor(ui, index, setLineCb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Index = index + self.SetLineCb = setLineCb + + self.IsOpen = false +end + +--- +--- 加载关卡预制体 +function XUiGridPartnerTeachingStage:LoadStagePrefab(chapterId, stageId) + if chapterId and stageId then + self.ChapterId = chapterId + self.StageId = stageId + local prefabName + local stageType = XFubenConfigs.GetStageType(stageId) + + -- 选择对应StageType的关卡预制体 + if stageType == XFubenConfigs.STAGETYPE_FIGHT or stageType == XFubenConfigs.STAGETYPE_FIGHTEGG + or stageType == XFubenConfigs.STAGETYPE_COMMON then + prefabName = XPartnerTeachingConfigs.GetChapterFightStagePrefab(chapterId) + elseif stageType == XFubenConfigs.STAGETYPE_STORY or stageType == XFubenConfigs.STAGETYPE_STORYEGG then + prefabName = XPartnerTeachingConfigs.GetChapterStoryStagePrefab(chapterId) + else + XLog.Error(string.format("XUiGridPartnerTeachingStage.Refresh函数错误,没有对应StageType的处理逻辑,关卡:%s,StageType:%s", stageId, stageType)) + return + end + self.StagePrefab = self.Transform:LoadPrefab(prefabName) + + -- 加载预制体的UiObject + local uiObj = self.StagePrefab.transform:GetComponent("UiObject") + for i = 0, uiObj.NameList.Count - 1 do + self[uiObj.NameList[i]] = uiObj.ObjList[i] + end + else + self.ChapterId = nil + self.StageId = nil + end +end + +--------------------------------------------------------刷新------------------------------------------------------------- +function XUiGridPartnerTeachingStage:Refresh() + if self.ChapterId and self.StageId then + self.IsOpen = XDataCenter.FubenManager.CheckStageOpen(self.StageId) + self.IsUnlock = XDataCenter.FubenManager.CheckStageIsUnlock(self.StageId) + self.IsPassed = XDataCenter.FubenManager.CheckStageIsPass(self.StageId) + self:RefreshStagePrefab() + else + self.IsOpen = false + self.IsUnlock = false + end + + -- 刷新关卡前的线条 + self.GameObject:SetActiveEx(self.IsOpen and self.IsUnlock) + self.SetLineCb(self.Index, self.IsOpen and self.IsUnlock) + + return self.IsOpen and self.IsUnlock +end + +--- +--- 刷新关卡预制体 +function XUiGridPartnerTeachingStage:RefreshStagePrefab() + -- 编号名称 + if self.TxtStageOrder then + self.TxtStageOrder.text = XDataCenter.PartnerTeachingManager.GetOrderName(self.ChapterId, self.StageId) + end + -- 图标 + if self.RImgBg then + self.RImgBg:SetRawImage(XFubenConfigs.GetStageIcon(self.StageId)) + end + -- 通关标志 + if self.PanelStagePass then + self.PanelStagePass.gameObject:SetActiveEx(self.IsPassed) + end + -- 点击响应 + if self.BtnStage then + self.BtnStage.CallBack = function() + self:OnBtnStageClick() + end + end +end + +-------------------------------------------------------选择关卡---------------------------------------------------------- +function XUiGridPartnerTeachingStage:OnBtnStageClick() + if self.IsOpen and self.IsUnlock then + XEventManager.DispatchEvent(XEventId.EVENT_PARTNER_TEACHING_OPEN_STAGE_DETAIL, self.StageId) + else + XUiManager.TipMsg(CSXTextManagerGetText("FubenNotUnlock")) + end +end + +--- +--- 是否显示选中框 +function XUiGridPartnerTeachingStage:SetSelect(isSelect) + self.ImageSelected.gameObject:SetActiveEx(isSelect) +end +------------------------------------------------------------------------------------------------------------------------ + + +function XUiGridPartnerTeachingStage:GetIndex() + return self.Index +end + +function XUiGridPartnerTeachingStage:GetStageId() + return self.StageId +end + +return XUiGridPartnerTeachingStage \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenPartnerTeaching/XUiPartnerTeachingBanner.lua b/Resources/Scripts/XUi/XUiFubenPartnerTeaching/XUiPartnerTeachingBanner.lua new file mode 100644 index 00000000..f45b909b --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenPartnerTeaching/XUiPartnerTeachingBanner.lua @@ -0,0 +1,105 @@ +local XUiPartnerTeachingBanner = XLuaUiManager.Register(XLuaUi, "UiPartnerTeachingBanner") + +local XUiGridPartnerTeachingBanner = require("XUi/XUiFubenPartnerTeaching/XUiGridPartnerTeachingBanner") +local CurrentSchedule + +function XUiPartnerTeachingBanner:OnStart() + self.TimerFunctions = {} + + self:InitComponent() + self:AddListener() +end + +function XUiPartnerTeachingBanner:OnEnable() + self.DataSource = XDataCenter.PartnerTeachingManager.GetSortedChapterList() + self.DynamicTable:SetDataSource(self.DataSource) + self.DynamicTable:ReloadDataASync() +end + +function XUiPartnerTeachingBanner:OnDestroy() + self:DestroyTimer() +end + +function XUiPartnerTeachingBanner:InitComponent() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, + XDataCenter.ItemManager.ItemId.FreeGem, + XDataCenter.ItemManager.ItemId.ActionPoint, + XDataCenter.ItemManager.ItemId.Coin) + + self.GridPartnerTeachingBanner.gameObject:SetActiveEx(false) + self:InitDynamicTable() + self:StartTimer() +end + +function XUiPartnerTeachingBanner:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelBannerList) + self.DynamicTable:SetProxy(XUiGridPartnerTeachingBanner, self) + self.DynamicTable:SetDelegate(self) +end + +function XUiPartnerTeachingBanner:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:Refresh(self.DataSource[index]) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + grid:OnClick() + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_RECYCLE then + grid:OnRecycle() + end +end + +-----------------------------------------------按钮响应函数--------------------------------------------------------------- +function XUiPartnerTeachingBanner:AddListener() + self.BtnBack.CallBack = function() + self:OnBtnBackClick() + end + self.BtnMainUi.CallBack = function() + self:OnBtnMainUiClick() + end +end + +function XUiPartnerTeachingBanner:OnBtnBackClick() + self:Close() +end + +function XUiPartnerTeachingBanner:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +---------------------------------------------------计时器---------------------------------------------------------------- +function XUiPartnerTeachingBanner:StartTimer() + if self.IsStart then + return + end + + self.IsStart = true + CurrentSchedule = XScheduleManager.ScheduleForever(function() + self:UpdateTimer() + end, 1000) +end + +function XUiPartnerTeachingBanner:UpdateTimer() + if next(self.TimerFunctions) then + for _, timerFun in pairs(self.TimerFunctions) do + if timerFun then + timerFun() + end + end + end +end + +function XUiPartnerTeachingBanner:RegisterTimerFun(id, fun) + self.TimerFunctions[id] = fun +end + +function XUiPartnerTeachingBanner:RemoveTimerFun(id) + self.TimerFunctions[id] = nil +end + +function XUiPartnerTeachingBanner:DestroyTimer() + if CurrentSchedule then + self.IsStart = false + XScheduleManager.UnSchedule(CurrentSchedule) + CurrentSchedule = nil + self.TimerFunctions = {} + end +end diff --git a/Resources/Scripts/XUi/XUiFubenPartnerTeaching/XUiPartnerTeachingChapter.lua b/Resources/Scripts/XUi/XUiFubenPartnerTeaching/XUiPartnerTeachingChapter.lua new file mode 100644 index 00000000..d283b556 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenPartnerTeaching/XUiPartnerTeachingChapter.lua @@ -0,0 +1,119 @@ +local XUiPartnerTeachingChapter = XLuaUiManager.Register(XLuaUi, "UiPartnerTeachingChapter") + +local XUiPartnerTeachingChapterContent = require("XUi/XUiFubenPartnerTeaching/XUiPartnerTeachingChapterContent") +local FIGHT_DETAIL = "UiPartnerTeachingFightDetail" +local STORY_DETAIL = "UiPartnerTeachingStoryDetail" + +function XUiPartnerTeachingChapter:OnAwake() + self.BtnCloseDetail.gameObject:SetActiveEx(false) + self:AddListener() + XEventManager.AddEventListener(XEventId.EVENT_PARTNER_TEACHING_OPEN_STAGE_DETAIL, self.OpenStageDetail, self) + XEventManager.AddEventListener(XEventId.EVENT_PARTNER_TEACHING_CLOSE_STAGE_DETAIL, self.CloseStageDetail, self) + XEventManager.AddEventListener(XEventId.EVENT_PARTNER_TEACHING_STAGE_REFRESH, self.Refresh, self) +end + +function XUiPartnerTeachingChapter:OnStart(chapterId) + self.ChapterId = chapterId + self:LoadChapter(chapterId) +end + +function XUiPartnerTeachingChapter:OnEnable() + self:Refresh() +end + +function XUiPartnerTeachingChapter:OnDestroy() + XEventManager.RemoveEventListener(XEventId.EVENT_PARTNER_TEACHING_OPEN_STAGE_DETAIL, self.OpenStageDetail, self) + XEventManager.RemoveEventListener(XEventId.EVENT_PARTNER_TEACHING_CLOSE_STAGE_DETAIL, self.CloseStageDetail, self) + XEventManager.RemoveEventListener(XEventId.EVENT_PARTNER_TEACHING_STAGE_REFRESH, self.Refresh, self) +end + +----------------------------------------------------初始化--------------------------------------------------------------- +--- +--- 加载章节 +function XUiPartnerTeachingChapter:LoadChapter(chapterId) + -- 背景 + local bg = XPartnerTeachingConfigs.GetChapterBackground(chapterId) + if bg then + self.RImgFestivalBg:SetRawImage(bg) + end + + -- 预制体 + local prefabPath = XPartnerTeachingConfigs.GetChapterFubenPrefab(chapterId) + if prefabPath then + local go = self.PanelChapter:LoadPrefab(prefabPath) + self.ChapterContent = XUiPartnerTeachingChapterContent.New(go, self.ChapterId) + end +end + +---------------------------------------------------刷新------------------------------------------------------------------ +function XUiPartnerTeachingChapter:Refresh() + if self.ChapterContent then + self.ChapterContent:Refresh() + end +end + +-----------------------------------------------按钮响应函数-------------------------------------------------------------- +function XUiPartnerTeachingChapter:AddListener() + self.SceneBtnBack.CallBack = function() + self:OnBtnBackClick() + end + self.SceneBtnMainUi.CallBack = function() + self:OnBtnMainUiClick() + end + self.BtnCloseDetail.CallBack = function() + self:CloseStageDetail() + end +end + +function XUiPartnerTeachingChapter:OnBtnBackClick() + if XLuaUiManager.IsUiShow(FIGHT_DETAIL) or XLuaUiManager.IsUiShow(STORY_DETAIL) then + self:CloseStageDetail() + else + self:Close() + end +end + +function XUiPartnerTeachingChapter:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +-------------------------------------------------关卡详情----------------------------------------------------------------- +--- +--- 打开关卡详情界面 +function XUiPartnerTeachingChapter:OpenStageDetail(stageId) + -- 选择关卡 + self.ChapterContent:SelectStage(stageId) + + local detailType + local stageType = XFubenConfigs.GetStageType(stageId) + if stageType == XFubenConfigs.STAGETYPE_FIGHT or stageType == XFubenConfigs.STAGETYPE_FIGHTEGG + or stageType == XFubenConfigs.STAGETYPE_COMMON then + detailType = FIGHT_DETAIL + elseif stageType == XFubenConfigs.STAGETYPE_STORY or stageType == XFubenConfigs.STAGETYPE_STORYEGG then + detailType = STORY_DETAIL + else + XLog.Error(string.format("XUiPartnerTeachingChapter.OpenStageDetail函数错误,没有对应StageType的处理逻辑,关卡:%s,StageType:%s", + stageId, stageType)) + return + end + self:OpenOneChildUi(detailType, handler(self, self.Close)) + self:FindChildUiObj(detailType):Refresh(stageId, self.ChapterId) + + self.BtnCloseDetail.gameObject:SetActiveEx(true) +end + +--- +--- 关闭关卡详情界面 +function XUiPartnerTeachingChapter:CloseStageDetail() + -- 取消关卡选择 + self.ChapterContent:CancelSelectStage() + + if XLuaUiManager.IsUiShow(FIGHT_DETAIL) then + self:FindChildUiObj(FIGHT_DETAIL):CloseDetailWithAnimation() + end + if XLuaUiManager.IsUiShow(STORY_DETAIL) then + self:FindChildUiObj(STORY_DETAIL):CloseDetailWithAnimation() + end + + self.BtnCloseDetail.gameObject:SetActiveEx(false) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenPartnerTeaching/XUiPartnerTeachingChapterContent.lua b/Resources/Scripts/XUi/XUiFubenPartnerTeaching/XUiPartnerTeachingChapterContent.lua new file mode 100644 index 00000000..67f43ed6 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenPartnerTeaching/XUiPartnerTeachingChapterContent.lua @@ -0,0 +1,185 @@ +local XUiPartnerTeachingChapterContent = XClass(nil, "XUiPartnerTeachingChapterContent") + +local XUiGridPartnerTeachingStage = require("XUi/XUiFubenPartnerTeaching/XUiGridPartnerTeachingStage") + +function XUiPartnerTeachingChapterContent:Ctor(ui, chapterId) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.ChapterId = chapterId + + self.LastOpenStage = nil + + self.StageItemList = {} -- 关卡数组 + self.LineItemList = {} -- 关卡线数组 + + self.StageClassList = {} -- 关卡类实例数组 + self.StageIdList = XPartnerTeachingConfigs.GetChapterStageIds(chapterId) -- 关卡Id数组 + + XTool.InitUiObject(self) + self:InitComponent() +end + +function XUiPartnerTeachingChapterContent:InitComponent() + -- 章节名称 + self.TxtChapterName.text = XPartnerTeachingConfigs.GetChapterName(self.ChapterId) + + -- 保存关卡与关卡线物体 + self:FindItem("Stage%d", self.StageItemList) + self:FindItem("Line%d", self.LineItemList) + + -- 实例化关卡类 + local setLineCb = handler(self, self.SetLineActive) + for i, stageItem in ipairs(self.StageItemList) do + local stageClass = XUiGridPartnerTeachingStage.New(stageItem, i, setLineCb) + self.StageClassList[i] = stageClass + end + + self:LoadAllStages() +end + +--- +--- 设置第 'index' 条关卡线的显隐 +function XUiPartnerTeachingChapterContent:SetLineActive(index, isActive) + local line = self.LineItemList[index - 1] + if line then + line.gameObject:SetActiveEx(isActive) + end +end + +--- +--- 寻找'PanelStageContent'下的 'itemName+index' 物体,并保存在'saveList' +function XUiPartnerTeachingChapterContent:FindItem(itemName, saveList) + local i = 1 + local item = self.PanelStageContent:Find(string.format(itemName, i)) + while item do + table.insert(saveList, item) + i = i + 1 + item = self.PanelStageContent:Find(string.format(itemName, i)) + end +end + +--- +--- 关卡类根据 StageIdList 来加载对应的关卡预制 +function XUiPartnerTeachingChapterContent:LoadAllStages() + local stageClassNum = #self.StageClassList + local stageIdNum = #self.StageIdList + if stageIdNum > stageClassNum then + XLog.Error(string.format("XUiPartnerTeachingChapterContent:LoadAllStages函数错误,PanelStageContent下的关卡数量少于%s个", + stageIdNum)) + end + + -- 如果stageClassNum > stageIdNum,多余的stageClass会拿到空的stageId,然后隐藏关卡与线条 + for i, stageClass in ipairs(self.StageClassList) do + stageClass:LoadStagePrefab(self.ChapterId, self.StageIdList[i]) + end +end + +--------------------------------------------------------刷新------------------------------------------------------------- +function XUiPartnerTeachingChapterContent:Refresh() + -- 通关进度 + local passNum, totalNum = XDataCenter.PartnerTeachingManager.GetChapterProgress(self.ChapterId) + self.TxtProgressNumber.text = string.format("%d/%d", passNum, totalNum) + + for i, stageClass in ipairs(self.StageClassList) do + local isOpen = stageClass:Refresh() + if isOpen then + self.LastOpenStage = i + end + end + if self.PanelStageContentSizeFitter then + self.PanelStageContentSizeFitter:SetLayoutHorizontal() + end + self:MoveToLastStage() +end + +--- +--- 滑动到最后一个关卡 +function XUiPartnerTeachingChapterContent:MoveToLastStage() + if self.LastOpenStage then + local gridRect = self.StageItemList[self.LastOpenStage] + local diffX = gridRect.localPosition.x + self.PanelStageContent.localPosition.x + + if diffX > CS.XResolutionManager.OriginWidth / 2 then + local tarPosX = (CS.XResolutionManager.OriginWidth / 4) - gridRect.localPosition.x + local tarPos = self.PanelStageContent.localPosition + tarPos.x = tarPosX + + XLuaUiManager.SetMask(true) + self.PanelStageList.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Unrestricted + + XUiHelper.DoMove(self.PanelStageContent, tarPos, XDataCenter.FubenMainLineManager.UiGridChapterMoveDuration, XUiHelper.EaseType.Sin, function() + XLuaUiManager.SetMask(false) + self.PanelStageList.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Elastic + + end) + end + end +end + +-------------------------------------------------------选择关卡---------------------------------------------------------- +--- +--- 选择关卡 +function XUiPartnerTeachingChapterContent:SelectStage(stageId) + local index = self:FindStageIndex(stageId) + self:SetStageSelect(index, true) + self:PlayScrollViewMove(self.StageItemList[index]) +end + +--- +--- 滑动关卡列表,使选择的关卡到达合适位置 +function XUiPartnerTeachingChapterContent:PlayScrollViewMove(gridRect) + local diffX = gridRect.localPosition.x + self.PanelStageContent.localPosition.x + + if diffX < XDataCenter.FubenMainLineManager.UiGridChapterMoveMinX or diffX > XDataCenter.FubenMainLineManager.UiGridChapterMoveMaxX then + local tarPosX = XDataCenter.FubenMainLineManager.UiGridChapterMoveTargetX - gridRect.localPosition.x + local tarPos = self.PanelStageContent.localPosition + tarPos.x = tarPosX + + XLuaUiManager.SetMask(true) + self.PanelStageList.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Unrestricted + + XUiHelper.DoMove(self.PanelStageContent, tarPos, XDataCenter.FubenMainLineManager.UiGridChapterMoveDuration, XUiHelper.EaseType.Sin, function() + XLuaUiManager.SetMask(false) + end) + end +end + +--- +--- 得到关卡 'stageId' 的索引 +function XUiPartnerTeachingChapterContent:FindStageIndex(stageId) + for _, stageClass in ipairs(self.StageClassList) do + local classStageId = stageClass:GetStageId() + if classStageId == stageId then + return stageClass:GetIndex() + end + end +end + +--- +--- 取消选择关卡 +function XUiPartnerTeachingChapterContent:CancelSelectStage() + if self.SelectStageIndex then + self:SetStageSelect(self.SelectStageIndex, false) + self.SelectStageIndex = nil + end + self:EndScrollViewMove() +end + +--- +--- 结束关卡列表滑动 +function XUiPartnerTeachingChapterContent:EndScrollViewMove() + self.PanelStageList.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Elastic +end + +--- +--- 设置关卡的选择效果 +function XUiPartnerTeachingChapterContent:SetStageSelect(index, isActive) + if not self.StageClassList[index] then + XLog.Error(string.format("XUiPartnerTeachingChapterContent:SetStageSelect函数错误,没有第%s个关卡的类实例", tostring(index))) + return + end + self.StageClassList[index]:SetSelect(isActive) + self.SelectStageIndex = index +end + +return XUiPartnerTeachingChapterContent \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenPartnerTeaching/XUiPartnerTeachingFightDetail.lua b/Resources/Scripts/XUi/XUiFubenPartnerTeaching/XUiPartnerTeachingFightDetail.lua new file mode 100644 index 00000000..fba1da52 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenPartnerTeaching/XUiPartnerTeachingFightDetail.lua @@ -0,0 +1,118 @@ +local XUiPartnerTeachingFightDetail = XLuaUiManager.Register(XLuaUi, "UiPartnerTeachingFightDetail") + +local MAX_STAR = 3 + +function XUiPartnerTeachingFightDetail:OnAwake() + self.StarGridList = {} + self.CommonGridList = {} + self.GridList = {} + + self:InitComponent() + self:AddListener() +end + +function XUiPartnerTeachingFightDetail:OnStart(closeParentCb) + self.CloseParentCb = closeParentCb +end + +function XUiPartnerTeachingFightDetail:InitComponent() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, + XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint) + + for i = 1, MAX_STAR do + self.StarGridList[i] = XUiGridStageStar.New(self[string.format("GridStageStar%d", i)]) + end +end + +-----------------------------------------------按钮响应函数--------------------------------------------------------------- +function XUiPartnerTeachingFightDetail:AddListener() + self.BtnEnter.CallBack = function() + self:OnBtnEnterClick() + end +end + +function XUiPartnerTeachingFightDetail:OnBtnEnterClick() + local isUnlockChapter = XDataCenter.PartnerTeachingManager.WhetherUnLockChapter(self.ChapterId) + if not isUnlockChapter then + XUiManager.TipMsg(CSXTextManagerGetText("PartnerTeachingActivityEnd")) + self.CloseParentCb() + return + end + + local stageCfg = XDataCenter.FubenManager.GetStageCfg(self.StageId) + if XDataCenter.FubenManager.CheckPreFight(stageCfg) then + XEventManager.DispatchEvent(XEventId.EVENT_PARTNER_TEACHING_CLOSE_STAGE_DETAIL) + XLuaUiManager.Open("UiNewRoomSingle", self.StageId) + end +end + +---------------------------------------------------刷新------------------------------------------------------------------ +function XUiPartnerTeachingFightDetail:Refresh(stageId, chapterId) + self.StageId = stageId + self.ChapterId = chapterId + + -- 名称 + self.TxtTitle.text = XDataCenter.FubenManager.GetStageName(stageId) + + -- 关卡通关描述 + local starDescList = XFubenConfigs.GetStarDesc(stageId) + for i = 1, MAX_STAR do + self.StarGridList[i]:Refresh(starDescList[i], false) + end + + -- 需要的消耗体力 + self.ImgCostIcon:SetRawImage(XDataCenter.ItemManager.GetItemIcon(XDataCenter.ItemManager.ItemId.ActionPoint)) + self.TxtATNums.text = XFubenConfigs.GetRequireActionPoint(stageId) + + self:UpdateRewards() +end + +--- +--- 刷新掉落奖励 +function XUiPartnerTeachingFightDetail:UpdateRewards() + local rewardId + local isFirst = not XDataCenter.FubenManager.CheckStageIsPass(self.StageId) + if isFirst then + rewardId = XFubenConfigs.GetFirstRewardShow(self.StageId) + else + rewardId = XFubenConfigs.GetFinishRewardShow(self.StageId) + end + + -- 可能掉落 + self.TxtDrop.gameObject:SetActiveEx(not isFirst) + -- 首通奖励 + self.TxtFirstDrop.gameObject:SetActiveEx(isFirst) + + -- 刷新奖励格子 + local rewards + if rewardId > 0 then + rewards = isFirst and XRewardManager.GetRewardList(rewardId) or XRewardManager.GetRewardListNotCount(rewardId) + end + if rewards then + for i, item in ipairs(rewards) do + local grid + if self.GridList[i] then + grid = self.GridList[i] + else + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommon) + grid = XUiGridCommon.New(self, ui) + grid.Transform:SetParent(self.PanelDropContent, false) + self.GridList[i] = grid + end + grid:Refresh(item) + grid.GameObject:SetActiveEx(true) + end + end + + -- 隐藏多余的奖励格子 + local rewardCount = rewards and #rewards or 0 + for j = rewardCount + 1, #self.GridList do + self.GridList[j].GameObject:SetActiveEx(false) + end +end + +function XUiPartnerTeachingFightDetail:CloseDetailWithAnimation() + self:PlayAnimation("AnimDisableEnd", function() + self:Close() + end) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenPartnerTeaching/XUiPartnerTeachingStoryDetail.lua b/Resources/Scripts/XUi/XUiFubenPartnerTeaching/XUiPartnerTeachingStoryDetail.lua new file mode 100644 index 00000000..2f275098 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenPartnerTeaching/XUiPartnerTeachingStoryDetail.lua @@ -0,0 +1,88 @@ +local XUiPartnerTeachingStoryDetail = XLuaUiManager.Register(XLuaUi, "UiPartnerTeachingStoryDetail") + +function XUiPartnerTeachingStoryDetail:OnAwake() + self:InitComponent() + self:AddListener() +end + +function XUiPartnerTeachingStoryDetail:OnStart(closeParentCb) + self.CloseParentCb = closeParentCb +end + +function XUiPartnerTeachingStoryDetail:InitComponent() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, + XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint) +end + +-----------------------------------------------按钮响应函数--------------------------------------------------------------- +function XUiPartnerTeachingStoryDetail:AddListener() + self.BtnEnter.CallBack = function() + self:OnBtnEnterClick() + end +end + +function XUiPartnerTeachingStoryDetail:OnBtnEnterClick() + local isUnlockChapter = XDataCenter.PartnerTeachingManager.WhetherUnLockChapter(self.ChapterId) + if not isUnlockChapter then + XUiManager.TipMsg(CSXTextManagerGetText("PartnerTeachingActivityEnd")) + self.CloseParentCb() + return + end + + if not self.StageId then + return + end + + local beginStoryId = XFubenConfigs.GetBeginStoryId(self.StageId) + if not beginStoryId then + XLog.Error(string.format("XUiPartnerTeachingStoryDetail:OnBtnEnterClick函数错误,关卡:%s的剧情Id为空", + tostring(self.StageId))) + return + end + + local playStory = function() + XDataCenter.MovieManager.PlayMovie(beginStoryId, function() + XEventManager.DispatchEvent(XEventId.EVENT_PARTNER_TEACHING_CLOSE_STAGE_DETAIL) + end) + self:Close() + end + + local isPassed = XDataCenter.FubenManager.CheckStageIsPass(self.StageId) + if isPassed then + playStory() + else + XDataCenter.FubenManager.FinishStoryRequest(self.StageId, function() + XEventManager.DispatchEvent(XEventId.EVENT_PARTNER_TEACHING_STAGE_REFRESH) + playStory() + end) + end +end + +-----------------------------------------------------刷新--------------------------------------------------------------- +function XUiPartnerTeachingStoryDetail:Refresh(stageId, chapterId) + self.StageId = stageId + self.ChapterId = chapterId + + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + self.TxtTitle.text = stageCfg.Name + self.TxtStoryDes.text = stageCfg.Description + + local titleBg = XPartnerTeachingConfigs.GetChapterStoryStageDetailBg(chapterId) + local enterIcon = XPartnerTeachingConfigs.GetChapterStoryStageDetailIcon(chapterId) + if titleBg then + self.RImgTitleBg:SetRawImage(titleBg) + else + self.RImgTitleBg.gameObject:SetActiveEx(false) + end + if enterIcon then + self.RImgNandu:SetRawImage(enterIcon) + else + self.RImgNandu.gameObject:SetActiveEx(false) + end +end + +function XUiPartnerTeachingStoryDetail:CloseDetailWithAnimation() + self:PlayAnimation("AnimDisableEnd", function() + self:Close() + end) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenPractice/UiPracticeSingleDetail.lua b/Resources/Scripts/XUi/XUiFubenPractice/UiPracticeSingleDetail.lua new file mode 100644 index 00000000..98f1f1e6 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenPractice/UiPracticeSingleDetail.lua @@ -0,0 +1,93 @@ +-- 家具建造主界面 +local XUiPracticeSingleDetail = XLuaUiManager.Register(XLuaUi, "UiPracticeSingleDetail") + +function XUiPracticeSingleDetail:OnAwake() + self:InitViews() + self:AddBtnsListeners() +end + +function XUiPracticeSingleDetail:AddBtnsListeners() + self:RegisterClickEvent(self.BtnEnter, self.OnBtnEnterClick) +end + +function XUiPracticeSingleDetail:InitViews() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self.PanelNums.gameObject:SetActive(false) + self.GridList = {} + self.GridListTag = {} +end + +function XUiPracticeSingleDetail:Refresh(stageId) + self.StageId = stageId + + self:UpdateCommon() + self:UpdateReward() +end + +function XUiPracticeSingleDetail:UpdateCommon() + local stageCfg = XDataCenter.FubenManager.GetStageCfg(self.StageId) + local nanDuIcon = XDataCenter.FubenManager.GetDifficultIcon(self.StageId) + + self.TxtTitle.text = stageCfg.Name + self.RImgNandu:SetRawImage(nanDuIcon) + + for i = 1, 3 do + self[string.format("TxtActive%d", i)].text = stageCfg.StarDesc[i] + end + + self.TxtATNums.text = stageCfg.RequireActionPoint or 0 +end + +function XUiPracticeSingleDetail:OnBtnEnterClick() + local stageCfg = XDataCenter.FubenManager.GetStageCfg(self.StageId) + if XDataCenter.FubenManager.CheckPreFight(stageCfg) then + XLuaUiManager.Open("UiNewRoomSingle", stageCfg.StageId) + self:Close() + end +end + +function XUiPracticeSingleDetail:CloseWithAnimation() + self:PlayAnimation("AnimDisableEnd", function() + self:Close() + end) +end + +function XUiPracticeSingleDetail:UpdateReward() + local stageCfg = XDataCenter.FubenManager.GetStageCfg(self.StageId) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(self.StageId) + local stageLevelControl = XDataCenter.FubenManager.GetStageLevelControl(self.StageId) + + local rewardId = stageLevelControl and stageLevelControl.FirstRewardShow or stageCfg.FirstRewardShow + + if rewardId == 0 then + for i = 1, #self.GridList do + self.GridList[i].GameObject:SetActive(false) + end + return + end + + local rewards = XRewardManager.GetRewardList(rewardId) + if rewards then + for i, item in ipairs(rewards) do + local grid + if self.GridList[i] then + grid = self.GridList[i] + else + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommon) + grid = XUiGridCommon.New(self, ui) + grid.Transform:SetParent(self.PanelDropContent, false) + self.GridList[i] = grid + self.GridListTag[i] = grid.Transform:Find("Received") + end + grid:Refresh(item) + grid.GameObject:SetActive(true) + if self.GridListTag[i] then + self.GridListTag[i].gameObject:SetActive(stageInfo.Passed) + end + end + end + + for i = #rewards + 1, #self.GridList do + self.GridList[i].GameObject:SetActive(false) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenPractice/XUiFubenPractice.lua b/Resources/Scripts/XUi/XUiFubenPractice/XUiFubenPractice.lua new file mode 100644 index 00000000..325ee6ac --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenPractice/XUiFubenPractice.lua @@ -0,0 +1,177 @@ +local XUiFubenPractice = XLuaUiManager.Register(XLuaUi, "UiFubenPractice") + +local ChildDetailUi = "UiPracticeSingleDetail" + +function XUiFubenPractice:OnAwake() + self:InitViews() + self:AddBtnsListeners() + + XEventManager.AddEventListener(XEventId.EVENT_PRACTICE_ON_DATA_REFRESH, self.RefreshSelectPanel, self) +end + +function XUiFubenPractice:InitViews() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + + self.PracticeBasics = XUiPanelPracticeBasics.New(self, self.PanelBasics) + self.PracticeAdvanced = XUiPanelPracticeAdvanced.New(self, self.PanelAdvanced) + self.PracticeCharacter = XUiPanelPracticeCharacter.New(self, self.PanelCharacter) + + -- 初始化tabGroup + self.BtnTabList = {} + self.ChapterDetailList = XPracticeConfigs.GetPracticeChapterDetails() + for id, chapterDetail in pairs(self.ChapterDetailList) do + local chapter = XPracticeConfigs.GetPracticeChapterById(id) + if not self.BtnTabList[id] then + local tabGo = CS.UnityEngine.Object.Instantiate(self.BtnTabShortNew.gameObject) + tabGo.transform:SetParent(self.UiContent, false) + self.BtnTabList[id] = tabGo.transform:GetComponent("XUiButton") + end + self.BtnTabList[id].gameObject:SetActive(chapter.IsOpen == 1) + self.BtnTabList[id]:SetNameByGroup(0, chapterDetail.Name) + end + self.BtnTabShortNew.gameObject:SetActive(false) + + self.BtnGroupList:Init(self.BtnTabList, function(id) self:SelectPanel(id) end) +end + +function XUiFubenPractice:AddBtnsListeners() + self:BindHelpBtn(self.BtnHelp, "Practice") + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + self.BtnMaskDetail.CallBack = function() self:OnBtnMaskDetailClick() end +end + +function XUiFubenPractice:OnResume(data) + self.CurrentSelect = data +end + +function XUiFubenPractice:OnStart(tabType) + self:CheckTabConditions() + self:SetAssetPanelActive(true) + + self.CurrentSelect = self.CurrentSelect or tabType or self:GetDefaultOpen() + self.BtnGroupList:SelectIndex(self.CurrentSelect) + --self.AnimEnable:PlayTimelineAnimation() +end + +function XUiFubenPractice:OnReleaseInst() + return self.CurrentSelect +end + +function XUiFubenPractice:SetAssetPanelActive(isActive) + self.AssetPanel.GameObject:SetActiveEx(isActive) +end + +function XUiFubenPractice:GetDefaultOpen() + local chapterDetailList = XPracticeConfigs.GetPracticeChapterDetails() + local default = XPracticeConfigs.PracticeType.Basics + for id, _ in ipairs(chapterDetailList) do + local chapter = XPracticeConfigs.GetPracticeChapterById(id) + if chapter.IsOpen == 1 then + default = id + break + end + end + return default +end + +function XUiFubenPractice:OnEnable() +end + +function XUiFubenPractice:OnDisable() + if not self.CurrentSelect then return end + self:OnPracticeDetailClose() +end + +function XUiFubenPractice:OnDestroy() + XEventManager.RemoveEventListener(XEventId.EVENT_PRACTICE_ON_DATA_REFRESH, self.RefreshSelectPanel, self) +end + +function XUiFubenPractice:OnBtnBackClick() + self:Close() +end + +function XUiFubenPractice:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiFubenPractice:OnBtnMaskDetailClick() + self:CloseStageDetail() +end + +function XUiFubenPractice:CheckTabConditions() + if not self.ChapterDetailList then return end + for id, _ in pairs(self.ChapterDetailList) do + local conditionId = XPracticeConfigs.GetPracticeChapterConditionById(id) + self.BtnTabList[id]:SetButtonState(CS.UiButtonState.Normal) + if conditionId ~= nil and conditionId > 0 then + local ret = XConditionManager.CheckCondition(conditionId) + if not ret then + self.BtnTabList[id]:SetButtonState(CS.UiButtonState.Disable) + end + end + end +end + +function XUiFubenPractice:SelectPanel(id) + local chapterDetail = self.ChapterDetailList[id] + if chapterDetail then + local conditionId = XPracticeConfigs.GetPracticeChapterConditionById(chapterDetail.Id) + if conditionId ~= nil and conditionId > 0 then + local ret, desc = XConditionManager.CheckCondition(conditionId) + if not ret then + XUiManager.TipMsg(desc) + return + end + end + end + + self:CloseStageDetail() + self.CurrentSelect = id + self.CurrentType = XPracticeConfigs.GetPracticeChapterTypeById(id) + + self.PracticeBasics:SetPanelActive(self.CurrentType == XPracticeConfigs.PracticeType.Basics, id) + self.PracticeAdvanced:SetPanelActive(self.CurrentType == XPracticeConfigs.PracticeType.Advanced, id) + self.PracticeCharacter:SetPanelActive(self.CurrentType == XPracticeConfigs.PracticeType.Character, id) +end + +function XUiFubenPractice:RefreshSelectPanel() + if not self.CurrentSelect then return end + if XPracticeConfigs.PracticeType.Basics == self.CurrentType then + self.PracticeBasics:ShowPanelDetail() + elseif XPracticeConfigs.PracticeType.Advanced == self.CurrentType then + self.PracticeAdvanced:ShowPanelDetail() + elseif XPracticeConfigs.PracticeType.Character == self.CurrentType then + self.PracticeCharacter:ShowPanelDetail() + end +end + +function XUiFubenPractice:OpenStageDetail(stageId) + self:OpenOneChildUi(ChildDetailUi, self) + self:FindChildUiObj(ChildDetailUi):Refresh(stageId) + self:SetAssetPanelActive(false) +end + +function XUiFubenPractice:CloseStageDetail() + if XLuaUiManager.IsUiShow(ChildDetailUi) then + self:FindChildUiObj(ChildDetailUi):CloseWithAnimation() + self:OnPracticeDetailClose() + self:SetAssetPanelActive(true) + end +end + +function XUiFubenPractice:OnPracticeDetailClose() + if XPracticeConfigs.PracticeType.Basics == self.CurrentType then + self.PracticeBasics:OnPracticeDetailClose() + elseif XPracticeConfigs.PracticeType.Advanced == self.CurrentType then + self.PracticeAdvanced:OnPracticeDetailClose() + elseif XPracticeConfigs.PracticeType.Character == self.CurrentType then + self.PracticeCharacter:OnPracticeDetailClose() + end +end + +function XUiFubenPractice:SwitchBg(mode) + local details = XPracticeConfigs.GetPracticeChapterDetailById(mode) + if not details then return end + self.RImgBg:SetRawImage(details.BgPath) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenPractice/XUiPanelPracticeAdvanced.lua b/Resources/Scripts/XUi/XUiFubenPractice/XUiPanelPracticeAdvanced.lua new file mode 100644 index 00000000..9b16b45c --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenPractice/XUiPanelPracticeAdvanced.lua @@ -0,0 +1,119 @@ +XUiPanelPracticeAdvanced = XClass(nil, "XUiPanelPracticeAdvanced") +local XUguiDragProxy = CS.XUguiDragProxy + +function XUiPanelPracticeAdvanced:Ctor(rootUi, ui) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + self:AddBtnsListeners() +end + +function XUiPanelPracticeAdvanced:AddBtnsListeners() + self.BtnActDesc.CallBack = function() self:OnBtnActDescClick() end +end + +function XUiPanelPracticeAdvanced:InitViews(id) + self.AdvancedDetail = XPracticeConfigs.GetPracticeChapterDetailById(id) + self.AdvancedChapter = XPracticeConfigs.GetPracticeChapterById(id) + self.ChapterId = id + + self.AdvancedChapterGO = self.PanelPrequelStages:LoadPrefab(self.AdvancedDetail.PracticeContentPrefab) + local uiObj = self.AdvancedChapterGO.transform:GetComponent("UiObject") + for i = 0, uiObj.NameList.Count - 1 do + self[uiObj.NameList[i]] = uiObj.ObjList[i] + end + + self.AdvancedStages = {} + + for i = 1, #self.AdvancedChapter.StageId do + local advancedStage = self.AdvancedContent:Find(string.format("Stage%d", i)) + if not advancedStage then + XLog.Error("XUiPanelPracticeAdvance:InitViews() 函数错误: 游戏物体BasicsContent下找不到名字为: " .. string.format("Stage%d", i) .. "的游戏物体") + return + end + local gridStageGO = advancedStage:LoadPrefab(self.AdvancedDetail.PracticeGridPrefab) + self.AdvancedStages[i] = XUiPracticeBasicsStage.New(self.RootUi, gridStageGO, self) + end + + -- 隐藏多余的组件 + local indexChapter = #self.AdvancedChapter.StageId + 1 + local extraStage = self.AdvancedContent:Find(string.format("Stage%d", indexChapter)) + while extraStage do + extraStage.gameObject:SetActive(false) + indexChapter = indexChapter + 1 + extraStage = self.AdvancedContent:Find(string.format("Stage%d", indexChapter)) + end + + local dragProxy = self.AdvancedScrollRect:GetComponent(typeof(XUguiDragProxy)) + if not dragProxy then + dragProxy = self.AdvancedScrollRect.gameObject:AddComponent(typeof(XUguiDragProxy)) + end + dragProxy:RegisterHandler(handler(self, self.OnDragProxy)) +end + +function XUiPanelPracticeAdvanced:OnDragProxy(dragType) + if dragType == 0 then + self.RootUi:CloseStageDetail() + end +end + +function XUiPanelPracticeAdvanced:SetPanelActive(value, id) + self.GameObject:SetActiveEx(false) -- 打开之前要先关一次(要不复用这个界面PanelStageContent大小会有问题) + if value then + self:InitViews(id) + self:ShowPanelDetail() + self.RootUi:PlayAnimation("PanelAdvancedQieHuan") + end +end + +function XUiPanelPracticeAdvanced:OnBtnActDescClick() + XUiManager.UiFubenDialogTip(CS.XTextManager.GetText("DormDes"), XPracticeConfigs.GetPracticeDescriptionById(id)) +end + +function XUiPanelPracticeAdvanced:ShowPanelDetail() + self.TxtMode.text = self.AdvancedDetail.Name + + self:UpdateNodes() + self.RootUi:SwitchBg(id) +end + +function XUiPanelPracticeAdvanced:UpdateNodes() + for i = 1, #self.AdvancedChapter.StageId do + local stageId = self.AdvancedChapter.StageId[i] + self.AdvancedStages[i].GameObject:SetActive(true) + self.AdvancedStages[i]:UpdateNode(stageId, XPracticeConfigs.PracticeType.Advanced) + end + for i = #self.AdvancedChapter.StageId + 1, #self.AdvancedStages do + self.AdvancedStages[i].GameObject:SetActive(false) + end + + if self.AdvancedScrollRect then + self.AdvancedScrollRect.horizontalNormalizedPosition = 0 + end +end + +function XUiPanelPracticeAdvanced:PlayScrollViewMove(gridTransform) + self.AdvancedScrollRect.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Unrestricted + local gridRect = gridTransform:GetComponent("RectTransform") + self.AdvancedViewport.raycastTarget = false + local diffX = gridRect.localPosition.x + self.AdvancedContent.localPosition.x + if diffX < XDataCenter.FubenMainLineManager.UiGridChapterMoveMinX or diffX > XDataCenter.FubenMainLineManager.UiGridChapterMoveMaxX then + local tarPosX = XDataCenter.FubenMainLineManager.UiGridChapterMoveTargetX - gridRect.localPosition.x + local tarPos = self.AdvancedContent.localPosition + tarPos.x = tarPosX + XLuaUiManager.SetMask(true) + XUiHelper.DoMove(self.AdvancedContent, tarPos, XDataCenter.FubenMainLineManager.UiGridChapterMoveDuration, XUiHelper.EaseType.Sin, function() + XLuaUiManager.SetMask(false) + end) + end +end + +function XUiPanelPracticeAdvanced:OnPracticeDetailClose() + self.AdvancedScrollRect.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Elastic + self.AdvancedViewport.raycastTarget = true +end + + +return XUiPanelPracticeAdvanced \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenPractice/XUiPanelPracticeBasics.lua b/Resources/Scripts/XUi/XUiFubenPractice/XUiPanelPracticeBasics.lua new file mode 100644 index 00000000..0fbc2922 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenPractice/XUiPanelPracticeBasics.lua @@ -0,0 +1,171 @@ +XUiPanelPracticeBasics = XClass(nil, "XUiPanelPracticeBasics") +local XUguiDragProxy = CS.XUguiDragProxy + +function XUiPanelPracticeBasics:Ctor(rootUi, ui) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + self:AddBtnsListeners() +end + +function XUiPanelPracticeBasics:AddBtnsListeners() + self.BtnActDesc.CallBack = function() self:OnBtnActDescClick() end +end + +function XUiPanelPracticeBasics:InitViews(id) + self.BasicsDetail = XPracticeConfigs.GetPracticeChapterDetailById(id) + self.BasicsChapter = XPracticeConfigs.GetPracticeChapterById(id) + self.ChapterId = id + self.BasicsChapterGO = self.PanelPracticeStages:LoadPrefab(self.BasicsDetail.PracticeContentPrefab) + local uiObj = self.BasicsChapterGO.transform:GetComponent("UiObject") + + for i = 0, uiObj.NameList.Count - 1 do + self[uiObj.NameList[i]] = uiObj.ObjList[i] + end + + self.BasicsStages = {} + self.BasicsLines = {} + + for i = 1, #self.BasicsChapter.StageId do + local basicsStage = self.BasicsContent:Find(string.format("Stage%d", i)) + if not basicsStage then + XLog.Error("XUiPanelPracticeBasics:InitViews() 函数错误: 游戏物体BasicsContent下找不到名字为: " .. string.format("Stage%d", i) .. "的游戏物体") + return + end + local gridStageGO = basicsStage:LoadPrefab(self.BasicsDetail.PracticeGridPrefab) + self.BasicsStages[i] = XUiPracticeBasicsStage.New(self.RootUi, gridStageGO, self) + if i ~= #self.BasicsChapter.StageId then + self.BasicsLines[i] = self.BasicsContent:Find(string.format("Line%d", i)) + if not self.BasicsLines[i] then + XLog.Error("XUiPanelPracticeBasics:InitViews() 函数错误: 游戏物体BasicsContent下找不到名字为: " .. string.format("Line%d", i) .. "的游戏物体") + return + end + end + end + + -- 隐藏多余的组件 + local indexChapter = #self.BasicsChapter.StageId + 1 + local extraStage = self.BasicsContent:Find(string.format("Stage%d", indexChapter)) + while extraStage do + extraStage.gameObject:SetActive(false) + indexChapter = indexChapter + 1 + extraStage = self.BasicsContent:Find(string.format("Stage%d", indexChapter)) + end + + local indexLine = #self.BasicsChapter.StageId + local extraLine = self.BasicsContent:Find(string.format("Line%d", indexLine)) + while extraLine do + extraLine.gameObject:SetActive(false) + indexLine = indexLine + 1 + extraLine = self.BasicsContent:Find(string.format("Line%d", indexLine)) + end + + local dragProxy = self.BasicsScrollRect:GetComponent(typeof(XUguiDragProxy)) + if not dragProxy then + dragProxy = self.BasicsScrollRect.gameObject:AddComponent(typeof(XUguiDragProxy)) + end + dragProxy:RegisterHandler(handler(self, self.OnDragProxy)) +end + +function XUiPanelPracticeBasics:OnDragProxy(dragType) + if dragType == 0 then + self.RootUi:CloseStageDetail() + end +end + +function XUiPanelPracticeBasics:SetPanelActive(value, id) + self.GameObject:SetActiveEx(false) -- 打开之前要先关一次(要不复用这个界面PanelStageContent大小会有问题) + self.GameObject:SetActive(value) + if value then + self:InitViews(id) + self:ShowPanelDetail() + self.RootUi:PlayAnimation("PanelBasicsQieHuan") + end +end + +function XUiPanelPracticeBasics:OnBtnActDescClick() + XUiManager.UiFubenDialogTip("", XPracticeConfigs.GetPracticeDescriptionById(self.ChapterId)) +end + +function XUiPanelPracticeBasics:ShowPanelDetail() + self.TxtMode.text = self.BasicsDetail.Name + + self:UpdateNodes() + self.RootUi:SwitchBg(self.ChapterId) +end + +function XUiPanelPracticeBasics:UpdateNodes() + for i = 1, #self.BasicsChapter.StageId do + local stageId = self.BasicsChapter.StageId[i] + -- 是否开始 + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + + if stageInfo.Unlock then + -- 显示 + self:UpdateBasicsLine(i, true) + self.BasicsStages[i].GameObject:SetActive(true) + self.BasicsStages[i].Transform.parent.gameObject:SetActive(true) + self.BasicsStages[i]:UpdateNode(stageId, XPracticeConfigs.PracticeType.Basics) + else + local isActive = false + for _, preStageId in pairs(stageCfg.PreStageId) do + local preStageInfo = XDataCenter.FubenManager.GetStageInfo(preStageId) + if preStageInfo.Passed then + -- 显示 + self:UpdateBasicsLine(i, true) + self.BasicsStages[i].GameObject:SetActive(true) + self.BasicsStages[i].Transform.parent.gameObject:SetActive(true) + self.BasicsStages[i]:UpdateNode(stageId, XPracticeConfigs.PracticeType.Basics) + isActive = true + break + end + end + + if not isActive then + -- 隐藏 + self:UpdateBasicsLine(i, false) + self.BasicsStages[i].GameObject:SetActive(false) + self.BasicsStages[i].Transform.parent.gameObject:SetActive(false) + end + + end + + end + + if self.BasicsScrollRect then + self.BasicsScrollRect.horizontalNormalizedPosition = 1 + end +end + +function XUiPanelPracticeBasics:UpdateBasicsLine(index, isActive) + if self.BasicsLines[index - 1] then + self.BasicsLines[index - 1].gameObject:SetActive(isActive) + end +end + +function XUiPanelPracticeBasics:PlayScrollViewMove(gridTransform) + self.BasicsScrollRect.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Unrestricted + local gridRect = gridTransform:GetComponent("RectTransform") + self.BasicsViewPort.raycastTarget = false + local diffX = gridRect.localPosition.x + self.BasicsContent.localPosition.x + if diffX < XDataCenter.FubenMainLineManager.UiGridChapterMoveMinX or diffX > XDataCenter.FubenMainLineManager.UiGridChapterMoveMaxX then + local tarPosX = XDataCenter.FubenMainLineManager.UiGridChapterMoveTargetX - gridRect.localPosition.x + local tarPos = self.BasicsContent.localPosition + tarPos.x = tarPosX + XLuaUiManager.SetMask(true) + XUiHelper.DoMove(self.BasicsContent, tarPos, XDataCenter.FubenMainLineManager.UiGridChapterMoveDuration, XUiHelper.EaseType.Sin, function() + XLuaUiManager.SetMask(false) + end) + end +end + +function XUiPanelPracticeBasics:OnPracticeDetailClose() + self.BasicsScrollRect.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Elastic + self.BasicsViewPort.raycastTarget = true +end + + +return XUiPanelPracticeBasics \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenPractice/XUiPanelPracticeCharacter.lua b/Resources/Scripts/XUi/XUiFubenPractice/XUiPanelPracticeCharacter.lua new file mode 100644 index 00000000..72797b79 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenPractice/XUiPanelPracticeCharacter.lua @@ -0,0 +1,120 @@ +XUiPanelPracticeCharacter = XClass(nil, "XUiPanelPracticeCharacter") +local XUguiDragProxy = CS.XUguiDragProxy + +function XUiPanelPracticeCharacter:Ctor(rootUi, ui) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:AddBtnsListeners() +end + +function XUiPanelPracticeCharacter:AddBtnsListeners() + self.BtnActDesc.CallBack = function() self:OnBtnActDescClick() end +end + +function XUiPanelPracticeCharacter:InitViews(id) + self.CharacterDetail = XPracticeConfigs.GetPracticeChapterDetailById(id) + self.CharacterChapter = XPracticeConfigs.GetPracticeChapterById(id) + self.ChapterId = id + self.CharacterChapterGO = self.PanelPrequelStages:LoadPrefab(self.CharacterDetail.PracticeContentPrefab) + local uiObj = self.CharacterChapterGO.transform:GetComponent("UiObject") + for i = 0, uiObj.NameList.Count - 1 do + self[uiObj.NameList[i]] = uiObj.ObjList[i] + end + + self.CharacterStages = {} + for i = 1, #self.CharacterChapter.StageId do + local characterStage = self.CharacterContent:Find(string.format("Stage%d", i)) + if not characterStage then + XLog.Error("XUiPanelPracticeChapter:InitViews() 函数错误: 游戏物体CharacterContent下找不到名字为:" .. string.format("Stage%d", i) .. "的游戏物体") + return + end + characterStage.gameObject:SetActiveEx(true) + local gridStageGO = characterStage:LoadPrefab(self.CharacterDetail.PracticeGridPrefab) + self.CharacterStages[i] = XUiPracticeBasicsStage.New(self.RootUi, gridStageGO, self) + end + + local indexChapter = #self.CharacterChapter.StageId + 1 + local extraStage = self.CharacterContent:Find(string.format("Stage%d", indexChapter)) + while extraStage do + extraStage.gameObject:SetActive(false) + indexChapter = indexChapter + 1 + extraStage = self.CharacterContent:Find(string.format("Stage%d", indexChapter)) + end + + local dragProxy = self.CharacterScrollRect:GetComponent(typeof(XUguiDragProxy)) + if not dragProxy then + dragProxy = self.CharacterScrollRect.gameObject:AddComponent(typeof(XUguiDragProxy)) + end + dragProxy:RegisterHandler(handler(self, self.OnDragProxy)) +end + +function XUiPanelPracticeCharacter:OnDragProxy(dragType) + if dragType == 0 then + self.RootUi:CloseStageDetail() + end +end + +function XUiPanelPracticeCharacter:SetPanelActive(value, id) + self.GameObject:SetActiveEx(false) -- 打开之前要先关一次(要不复用这个界面PanelStageContent大小会有问题) + self.GameObject:SetActive(value) + if value then + self:InitViews(id) + self:ShowPanelDetail() + self.RootUi:PlayAnimation("PanelCharacterQieHuan") + end +end + +function XUiPanelPracticeCharacter:OnBtnActDescClick() + XUiManager.UiFubenDialogTip(CS.XTextManager.GetText("DormDes"), XPracticeConfigs.GetPracticeDescriptionById(self.ChapterId)) +end + +function XUiPanelPracticeCharacter:ShowPanelDetail() + self.TxtMode.text = self.CharacterDetail.Name + + self:UpdateNodes() + self.RootUi:SwitchBg(self.ChapterId) +end + +function XUiPanelPracticeCharacter:UpdateNodes() + self.Nodes = XDataCenter.PracticeManager.GetSortedChapterStage(self.ChapterId) + --self:SortCharacterChapterStages(self.CharacterChapter.StageId) + + for i = 1, #self.Nodes do + local node = self.Nodes[i] + self.CharacterStages[i].GameObject:SetActive(true) + self.CharacterStages[i]:UpdateNode(node.StageId, XPracticeConfigs.PracticeType.Character) + end + + for i = #self.Nodes + 1, #self.CharacterStages do + self.CharacterStages[i].GameObject:SetActive(false) + end + + if self.CharacterScrollRect then + self.CharacterScrollRect.horizontalNormalizedPosition = 0 + end +end + +function XUiPanelPracticeCharacter:PlayScrollViewMove(gridTransform) + self.CharacterScrollRect.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Unrestricted + local gridRect = gridTransform:GetComponent("RectTransform") + self.CharacterViewport.raycastTarget = false + local diffX = gridRect.localPosition.x + self.CharacterContent.localPosition.x + if diffX < XDataCenter.FubenMainLineManager.UiGridChapterMoveMinX or diffX > XDataCenter.FubenMainLineManager.UiGridChapterMoveMaxX then + local tarPosX = XDataCenter.FubenMainLineManager.UiGridChapterMoveTargetX - gridRect.localPosition.x + local tarPos = self.CharacterContent.localPosition + tarPos.x = tarPosX + XLuaUiManager.SetMask(true) + XUiHelper.DoMove(self.CharacterContent, tarPos, XDataCenter.FubenMainLineManager.UiGridChapterMoveDuration, XUiHelper.EaseType.Sin, function() + XLuaUiManager.SetMask(false) + end) + end +end + +function XUiPanelPracticeCharacter:OnPracticeDetailClose() + self.CharacterScrollRect.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Elastic + self.CharacterViewport.raycastTarget = true +end + +return XUiPanelPracticeCharacter \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenPractice/XUiPracticeBasicsStage.lua b/Resources/Scripts/XUi/XUiFubenPractice/XUiPracticeBasicsStage.lua new file mode 100644 index 00000000..ef930541 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenPractice/XUiPracticeBasicsStage.lua @@ -0,0 +1,73 @@ +XUiPracticeBasicsStage = XClass(nil, "XUiPracticeBasicsStage") + +function XUiPracticeBasicsStage:Ctor(rootUi, ui, parent) + self.RootUi = rootUi + self.Parent = parent + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + self:AddBtnsListeners() +end + +function XUiPracticeBasicsStage:AddBtnsListeners() + XUiHelper.RegisterClickEvent(self, self.BtnStage, self.OnBtnStageClick) +end + +function XUiPracticeBasicsStage:SetNormalStage(isLock, stageId) + self.PanelStageNormal.gameObject:SetActive(not isLock) + if not isLock then + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + self.TxtFightNameNor.text = stageCfg.Name + self.RImgFightActiveNor:SetRawImage(stageCfg.Icon) + end + if self.PanelActivityTag then + local inActivity = XDataCenter.PracticeManager.CheckStageInActivity(stageId) + self.PanelActivityTag.gameObject:SetActiveEx(inActivity) + end +end + +function XUiPracticeBasicsStage:SetLockStage(isLock, stageId, stageMode) + self.PanelStageLock.gameObject:SetActive(isLock) + if isLock and stageMode == XPracticeConfigs.PracticeType.Character then + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + self.TxtFightNameLock.text = stageCfg.Name + self.RImgFightActiveLock:SetRawImage(stageCfg.Icon) + end +end + +function XUiPracticeBasicsStage:SetPassStage(isPass) + self.PanelStagePass.gameObject:SetActive(isPass) +end + +function XUiPracticeBasicsStage:UpdateNode(stageId, stageMode) + self.StageId = stageId + self.StageMode = stageMode + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + if self.StageMode == XPracticeConfigs.PracticeType.Basics then + self.IsLock = stageInfo.IsOpen ~= true + else + local isOpen = XDataCenter.PracticeManager.CheckPracticeStageOpen(stageId) + self.IsLock = not isOpen + end + + self:SetNormalStage(self.IsLock, stageId) + self:SetLockStage(self.IsLock, stageId, stageMode) + self:SetPassStage(stageInfo.Passed) +end + +function XUiPracticeBasicsStage:OnBtnStageClick() + if not self.StageId then return end + --local stageInfo = XDataCenter.FubenManager.GetStageInfo(self.StageId) + if self.IsLock then + local _, description = XDataCenter.PracticeManager.CheckPracticeStageOpen(self.StageId) + XUiManager.TipMsg(description) + else + if self.Parent then + self.Parent:PlayScrollViewMove(self.Transform.parent) + end + self.RootUi:OpenStageDetail(self.StageId) + end +end + +return XUiPracticeBasicsStage \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenPractice/XUiPracticeSkillDetail.lua b/Resources/Scripts/XUi/XUiFubenPractice/XUiPracticeSkillDetail.lua new file mode 100644 index 00000000..fac111b6 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenPractice/XUiPracticeSkillDetail.lua @@ -0,0 +1,37 @@ +-- 家具建造主界面 +local XUiPracticeSkillDetail = XLuaUiManager.Register(XLuaUi, "UiPracticeSkillDetail") + +function XUiPracticeSkillDetail:OnAwake() + self:AddBtnsListeners() +end + +function XUiPracticeSkillDetail:AddBtnsListeners() + self:RegisterClickEvent(self.BtnDarkBg, self.OnBtnDarkBgClick) +end + + +function XUiPracticeSkillDetail:OnStart(stageId) + local skillDetail = XPracticeConfigs.GetPracticeSkillDetailById(stageId) + self.TxtSkillName.text = skillDetail.Title + self.RImgSkill:SetRawImage(skillDetail.Icon) + self.TxtSkillDesc.text = skillDetail.Description +end + +function XUiPracticeSkillDetail:OnEnable() + if CS.XFight.IsRunning then + CS.XFight.Instance:Pause() + end +end + +function XUiPracticeSkillDetail:OnDisable() + if CS.XFight.Instance then + CS.XFight.Instance:Resume() + end +end + +function XUiPracticeSkillDetail:OnBtnDarkBgClick() + self:Close() +end + +function XUiPracticeSkillDetail:OnDestroy() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenRepeatchallenge/XUiFubenRepeatChallengeNewChapter.lua b/Resources/Scripts/XUi/XUiFubenRepeatchallenge/XUiFubenRepeatChallengeNewChapter.lua new file mode 100644 index 00000000..94245761 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenRepeatchallenge/XUiFubenRepeatChallengeNewChapter.lua @@ -0,0 +1,47 @@ + +local UIRepeatChallengeNewChapterNumIconPath = { + [1] = CS.XGame.ClientConfig:GetString("UIRepeatChallengeNewChapterNumIconPath1"), + [2] = CS.XGame.ClientConfig:GetString("UIRepeatChallengeNewChapterNumIconPath2"), + [3] = CS.XGame.ClientConfig:GetString("UIRepeatChallengeNewChapterNumIconPath3"), + [4] = CS.XGame.ClientConfig:GetString("UIRepeatChallengeNewChapterNumIconPath4"), + [5] = CS.XGame.ClientConfig:GetString("UIRepeatChallengeNewChapterNumIconPath5"), +} + +local XUiFubenRepeatChallengeNewChapter = XLuaUiManager.Register(XLuaUi, "UiFubenRepeatChallengeNewChapter") + +function XUiFubenRepeatChallengeNewChapter:OnAwake() + self:AutoAddListener() +end + +function XUiFubenRepeatChallengeNewChapter:OnStart(oldIndex, newIndex) + self:Refresh(oldIndex, newIndex) +end + +function XUiFubenRepeatChallengeNewChapter:Refresh(oldIndex, newIndex) + + local oldPath = UIRepeatChallengeNewChapterNumIconPath[oldIndex] + local newPath = UIRepeatChallengeNewChapterNumIconPath[newIndex] + + if oldPath then + self:SetUiSprite(self.ImgOldChpaterOrder,oldPath) + end + + if newPath then + self:SetUiSprite(self.ImgOldChpaterOrder,newPath) + end + + local level = XDataCenter.FubenRepeatChallengeManager.GetLevel() + local exp = XDataCenter.FubenRepeatChallengeManager.GetExp() + local levelConfig = XFubenRepeatChallengeConfigs.GetLevelConfig(level) + local curLevelMaxExp = levelConfig.UpExp + self.TxtLevel.text = level + self.ImgExp.fillAmount = exp / curLevelMaxExp +end + +function XUiFubenRepeatChallengeNewChapter:AutoAddListener() + self:RegisterClickEvent(self.BtnClose, self.OnBtnCloseClick) +end + +function XUiFubenRepeatChallengeNewChapter:OnBtnCloseClick() + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenRepeatchallenge/XUiFubenRepeatChallengeStageDetail.lua b/Resources/Scripts/XUi/XUiFubenRepeatchallenge/XUiFubenRepeatChallengeStageDetail.lua new file mode 100644 index 00000000..edffa938 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenRepeatchallenge/XUiFubenRepeatChallengeStageDetail.lua @@ -0,0 +1,224 @@ +local CsXTextManagerGetText = CS.XTextManager.GetText + +local XUiFubenRepeatChallengeStageDetail = XLuaUiManager.Register(XLuaUi, "UiFubenRepeatChallengeStageDetail") + +function XUiFubenRepeatChallengeStageDetail:OnAwake() + self:InitAutoScript() + self.GridCommon.gameObject:SetActiveEx(false) + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) +end + +function XUiFubenRepeatChallengeStageDetail:OnStart(parent) + self.GridList = {} + self.Parent = parent +end + +function XUiFubenRepeatChallengeStageDetail:OnEnable() + self.Parent.PanelAsset.gameObject:SetActiveEx(false) +end + +function XUiFubenRepeatChallengeStageDetail:OnDisable() + self.Parent.PanelAsset.gameObject:SetActiveEx(true) +end + +function XUiFubenRepeatChallengeStageDetail:Refresh(stage) + self.Stage = stage + + if stage.StageType == XFubenConfigs.STAGETYPE_STORY or stage.StageType == XFubenConfigs.STAGETYPE_STORYEGG then + self:UpdateStory() + else + self:UpdateCommon() + self:UpdateRewards() + end +end + +function XUiFubenRepeatChallengeStageDetail:UpdateStory() + local stageId = self.Stage.StageId + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + + self.TxtTitleStory.text = stageCfg.Name + self.TxtStoryDes.text = stageCfg.Description + + self.PanelFight.gameObject:SetActiveEx(false) + self.PanelStory.gameObject:SetActiveEx(true) +end + +function XUiFubenRepeatChallengeStageDetail:UpdateCommon() + local stageId = self.Stage.StageId + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + local nanDuIcon = XDataCenter.FubenManager.GetDifficultIcon(stageId) + local maxChallengeNum = XDataCenter.FubenManager.GetStageMaxChallengeNums(stageId) + local buyChallengeCount = XDataCenter.FubenManager.GetStageBuyChallengeCount(stageId) + + self.RImgNandu:SetRawImage(nanDuIcon) + self.TxtTitle.text = self.Stage.Name + self.TxtLevelVal.text = self.Stage.RecommandLevel + self.TxtATNums.text = self.Stage.RequireActionPoint + self.PanelNums.gameObject:SetActiveEx(maxChallengeNum > 0) + self.PanelNoLimitCount.gameObject:SetActiveEx(maxChallengeNum <= 0) + self.BtnAddNum.gameObject:SetActiveEx(buyChallengeCount > 0) + for i = 1, 3 do + self["TxtActive" .. i].text = stageCfg.StarDesc[i] + end + + if maxChallengeNum > 0 then + local stageData = XDataCenter.FubenManager.GetStageData(stageId) + local chanllengeNum = stageData and stageData.PassTimesToday or 0 + self.TxtAllNums.text = "/" .. maxChallengeNum + self.TxtLeftNums.text = maxChallengeNum - chanllengeNum + end + + + local firstDrop = false + local cfg = XDataCenter.FubenManager.GetStageLevelControl(stageId) + if cfg and cfg.FirstRewardShow > 0 or self.Stage.FirstRewardShow > 0 then + firstDrop = true + end + self.TxtFirstDrop.gameObject:SetActiveEx(firstDrop) + self.TxtDrop.gameObject:SetActiveEx(not firstDrop) + + local firstPass = firstDrop and not stageInfo.Passed + self.BtnFirstEnter.gameObject:SetActiveEx(firstPass) + self.BtnEnter.gameObject:SetActiveEx(not firstPass) + + local exConsumeId, exConsumeNum = XDataCenter.FubenManager.GetStageExCost(stageId) + if exConsumeId ~= 0 and exConsumeNum ~= 0 then + self.RawImgCostIcon:SetRawImage(XDataCenter.ItemManager.GetItemIcon(exConsumeId)) + self.TxtCostNum.text = exConsumeNum + self.PanelCostEx.gameObject:SetActiveEx(true) + else + self.PanelCostEx.gameObject:SetActiveEx(false) + end + + self.PanelFight.gameObject:SetActiveEx(true) + self.PanelStory.gameObject:SetActiveEx(false) +end + +function XUiFubenRepeatChallengeStageDetail:UpdateRewards() + local stage = self.Stage + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stage.StageId) + + -- 获取显示奖励Id + local rewardId = 0 + local IsFirst = false + local cfg = XDataCenter.FubenManager.GetStageLevelControl(stage.StageId) + if not stageInfo.Passed then + rewardId = cfg and cfg.FirstRewardShow or stage.FirstRewardShow + if cfg and cfg.FirstRewardShow > 0 or stage.FirstRewardShow > 0 then + IsFirst = true + end + end + if rewardId == 0 then + rewardId = cfg and cfg.FinishRewardShow or stage.FinishRewardShow + end + if rewardId == 0 then + for j = 1, #self.GridList do + self.GridList[j].GameObject:SetActiveEx(false) + end + return + end + + local rewards = IsFirst and XRewardManager.GetRewardList(rewardId) or XRewardManager.GetRewardListNotCount(rewardId) + if rewards then + for i, item in ipairs(rewards) do + local grid + if self.GridList[i] then + grid = self.GridList[i] + else + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommon) + grid = XUiGridCommon.New(self, ui) + grid.Transform:SetParent(self.PanelDropContent, false) + self.GridList[i] = grid + end + grid:Refresh(item) + grid.GameObject:SetActiveEx(true) + end + end + + local rewardsCount = 0 + if rewards then + rewardsCount = #rewards + end + + for j = 1, #self.GridList do + if j > rewardsCount then + self.GridList[j].GameObject:SetActiveEx(false) + end + end +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiFubenRepeatChallengeStageDetail:InitAutoScript() + self:AutoAddListener() +end + +function XUiFubenRepeatChallengeStageDetail:AutoAddListener() + self:RegisterClickEvent(self.BtnAddNum, self.OnBtnAddNumClick) + self:RegisterClickEvent(self.BtnFirstEnter, self.OnBtnFirstEnterClick) + self:RegisterClickEvent(self.BtnClose, self.OnBtnCloseClick) + self:RegisterClickEvent(self.BtnEnter, self.OnBtnEnterClick) + self:RegisterClickEvent(self.BtnEnterStory, self.OnBtnEnterStoryClick) +end + +function XUiFubenRepeatChallengeStageDetail:OnBtnCloseClick() + self:CloseWithAnimDisable() +end +-- auto +function XUiFubenRepeatChallengeStageDetail:OnBtnAddNumClick() + local challengeData = XDataCenter.FubenMainLineManager.GetStageBuyChallengeData(self.Stage.StageId) + XLuaUiManager.Open("UiBuyAsset", 1, function() + self:UpdateCommon() + end, challengeData) +end + +function XUiFubenRepeatChallengeStageDetail:OnBtnFirstEnterClick() + local chapterId = self.Parent.SelectChapterId + local isFinished = XDataCenter.FubenRepeatChallengeManager.IsChapterFinished(chapterId) + if isFinished then + XUiManager.TipError(CsXTextManagerGetText("ActivityRepeatChallengeChapterFinished")) + return + end + + if XDataCenter.FubenManager.CheckPreFight(self.Stage) then + self.Parent:CloseStageDetail() + XLuaUiManager.Open("UiNewRoomSingle", self.Stage.StageId) + end +end + +function XUiFubenRepeatChallengeStageDetail:OnBtnEnterClick() + local chapterId = self.Parent.SelectChapterId + local isFinished = XDataCenter.FubenRepeatChallengeManager.IsChapterFinished(chapterId) + if isFinished then + XUiManager.TipError(CsXTextManagerGetText("ActivityRepeatChallengeChapterFinished")) + return + end + + self.Parent:CloseStageDetail() + XLuaUiManager.Open("UiRepeatChallengeEnter", self.Stage) +end + +function XUiFubenRepeatChallengeStageDetail:OnBtnEnterStoryClick() + local stageId = self.Stage.StageId + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + if not stageCfg or not stageInfo then return end + + if stageInfo.Passed then + XDataCenter.MovieManager.PlayMovie(stageCfg.BeginStoryId) + else + XDataCenter.FubenManager.FinishStoryRequest(stageId, function() + XDataCenter.MovieManager.PlayMovie(stageCfg.BeginStoryId, function() + XDataCenter.FubenRepeatChallengeManager.PassStage(stageId) + self.Parent:RefreshChapterList() + end) + end) + end +end + +function XUiFubenRepeatChallengeStageDetail:CloseWithAnimDisable() + self:PlayAnimation("AnimEnd", function() + self:Close() + end) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenRepeatchallenge/XUiFubenRepeatchallenge.lua b/Resources/Scripts/XUi/XUiFubenRepeatchallenge/XUiFubenRepeatchallenge.lua new file mode 100644 index 00000000..b10fe694 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenRepeatchallenge/XUiFubenRepeatchallenge.lua @@ -0,0 +1,462 @@ +local tableInsert = table.insert +local CsXTextManagerGetText = CS.XTextManager.GetText +local TimeFormat = "yyyy-MM-dd" +local CsXScheduleManager = XScheduleManager +local XUiGridChapter = require("XUi/XUiFubenMainLineChapter/XUiGridChapter") + +local ChildDetailUi = "UiFubenRepeatChallengeStageDetail" +local ChapterBtnNum = 5 + +local XUiFubenRepeatchallenge = XLuaUiManager.Register(XLuaUi, "UiFubenRepeatchallenge") + +function XUiFubenRepeatchallenge:OnAwake() + local tabGroup = {} + for i = 1, ChapterBtnNum do + tableInsert(tabGroup, self["BtnChapter" .. i]) + end + self.TxtBtnExtraList = { + self.TxtBtnExtra1, + self.TxtBtnExtra2, + self.TxtBtnExtra3, + self.TxtBtnExtra4, + self.TxtBtnExtra5 + } + self.PanelTabChapterGroup:Init(tabGroup, function(tabIndex) self:OnClickTabCallBack(tabIndex) end) + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self:AutoAddListener() + --XFunctionManager.CheckSkipInDuration(id) +end + +function XUiFubenRepeatchallenge:OnStart(difficultType, stageId) + difficultType = difficultType or XDataCenter.FubenRepeatChallengeManager.DifficultType.Normal + self.DefaultStageId = stageId + self.ChapterList = {} + + XDataCenter.FubenRepeatChallengeManager.SelectDifficult(difficultType) + self.RedPointId = XRedPointManager.AddRedPointEvent(self.BtnTreasure, self.OnCheckRewards, self, { XRedPointConditions.Types.CONDITION_REPEAT_CHALLENGE_CHAPTER_REWARD }, nil, false) +end + +function XUiFubenRepeatchallenge:OnEnable() + local newChapterTip = XDataCenter.FubenRepeatChallengeManager.GetNewChapterTipInfo() + if next(newChapterTip) then + XLuaUiManager.Open("UiFubenRepeatChallengeNewChapter", newChapterTip.OldIndex, newChapterTip.NewIndex) + XDataCenter.FubenRepeatChallengeManager.ResetNewChapterTipInfo() + end + + self:Refresh() +end + +function XUiFubenRepeatchallenge:OnDisable() + self:DestroyActivityTimer() +end + +function XUiFubenRepeatchallenge:Refresh() + local difficultType = XDataCenter.FubenRepeatChallengeManager.GetSelectDifficult() + self.DifficultType = difficultType + + self:CreateActivityTimer() + self:RefreshLevel() + self:RefreshChapterBtns() +end + +function XUiFubenRepeatchallenge:RefreshChapterBtns() + local difficultType = self.DifficultType + local selectChapterIndex = XDataCenter.FubenRepeatChallengeManager.GetCurChapterIndex(difficultType) + if not selectChapterIndex then return end + + local chapterNum = XDataCenter.FubenRepeatChallengeManager.GetChapterNum(difficultType) + for i = 1, ChapterBtnNum do + local btn = self["BtnChapter" .. i] + local txtBtnExtra = self.TxtBtnExtraList[i] + if i <= chapterNum then + local chapterId = XDataCenter.FubenRepeatChallengeManager.GetChapterId(difficultType, i) + local isRed = XDataCenter.FubenRepeatChallengeManager.CheckChapterRewardCanGetReal(chapterId) + if i > selectChapterIndex then + local onlyShowNextCondition = CsXTextManagerGetText("ActivityRepeatChallengeChapterLockBtn1") + txtBtnExtra.gameObject:SetActiveEx(true) + txtBtnExtra.text = onlyShowNextCondition + btn:ShowReddot(false) + btn:ShowTag(false) + btn:SetDisable(true) + elseif i < selectChapterIndex then + btn:ShowReddot(isRed) + txtBtnExtra.gameObject:SetActiveEx(false) + btn:ShowTag(true) + btn:SetDisable(false) + else + if XDataCenter.FubenRepeatChallengeManager.IsStatusEqualFightEnd() then + btn:ShowTag(true) + txtBtnExtra.gameObject:SetActiveEx(false) + else + btn:ShowTag(false) + local time = XTime.GetServerNowTimestamp() + local endTime = XDataCenter.FubenRepeatChallengeManager.GetChapterEndTime(chapterId) + local timeStr = XUiHelper.GetTime(endTime - time, XUiHelper.TimeFormatType.ACTIVITY) + txtBtnExtra.text = CsXTextManagerGetText("ActivityRepeatChallengeChapterCurBtn", timeStr) + txtBtnExtra.gameObject:SetActiveEx(true) + end + btn:ShowReddot(isRed) + btn:SetDisable(false) + end + local chapterConfig = XFubenRepeatChallengeConfigs.GetChapterCfg(chapterId) + btn:SetName(chapterConfig.Name) + btn.gameObject:SetActiveEx(true) + else + btn.gameObject:SetActiveEx(false) + txtBtnExtra.gameObject:SetActiveEx(false) + end + end + self.PanelTabChapterGroup:SelectIndex(selectChapterIndex) + self.PanelTabChapterGroup.gameObject:SetActiveEx(difficultType == XDataCenter.FubenRepeatChallengeManager.DifficultType.Normal) +end + +function XUiFubenRepeatchallenge:RefreshCurChapter() + local difficultType = self.DifficultType + local chapterId = self.SelectChapterId + if not chapterId then + local firstChapterId = XDataCenter.FubenRepeatChallengeManager.GetChapterIds(difficultType)[1] + local time = XTime.GetServerNowTimestamp() + local beginTime = XDataCenter.FubenRepeatChallengeManager.GetChapterBeginTime(firstChapterId) + local timeStr = XUiHelper.GetTime(beginTime - time, XUiHelper.TimeFormatType.ACTIVITY) + XUiManager.TipError(CsXTextManagerGetText("ActivityRepeatChallengeChapterLock", timeStr)) + return + end + + local activityCfg = XDataCenter.FubenRepeatChallengeManager.GetActivityConfig() + local chapterCfg = XFubenRepeatChallengeConfigs.GetChapterCfg(chapterId) + self.RImgBg:SetRawImage(chapterCfg.Bg) + self.TxtName.text = activityCfg.Name + --self.TxtTitle.text = chapterCfg.Name + local titlePath = chapterCfg.TitlePath + if titlePath then + self.RImgTitle.gameObject:SetActiveEx(true) + self.RImgTitle:SetRawImage(titlePath) + else + self.RImgTitle.gameObject:SetActiveEx(false) + end + + self.PanelEffect.gameObject:LoadUiEffect(chapterCfg.EffectPath) + + local isSelectDifficult = difficultType == XDataCenter.FubenRepeatChallengeManager.DifficultType.Difficult + -- self.BtnSwitch2Fight.gameObject:SetActiveEx(not isSelectDifficult) + self.BtnSwitch2Fight.gameObject:SetActiveEx(false) + self.BtnSwitch2Regional.gameObject:SetActiveEx(isSelectDifficult) + + local buffDes = XDataCenter.FubenRepeatChallengeManager.GetBuffDes(chapterCfg.BuffId) + if buffDes then + self.TxtBuff.text = CsXTextManagerGetText("ActivityRepeatChallengeBuffDes", buffDes) + self.TxtBuff.gameObject:SetActiveEx(true) + else + self.TxtBuff.gameObject:SetActiveEx(false) + end + + self.GridCostItem.gameObject:SetActiveEx(false) + local exConsumeId = XDataCenter.FubenRepeatChallengeManager.ExCostItemId + if exConsumeId ~= 0 then + self.CommonGrid = self.CommonGrid or XUiGridCommon.New(self, self.GridCostItem) + self.CommonGrid:Refresh({ TemplateId = exConsumeId, Count = XDataCenter.ItemManager.GetCount(exConsumeId) }) + self.CommonGrid.GameObject:SetActiveEx(true) + end +end + +function XUiFubenRepeatchallenge:RefreshLevel() + local level = XDataCenter.FubenRepeatChallengeManager.GetLevel() + local exp = XDataCenter.FubenRepeatChallengeManager.GetExp() + local levelConfig = XFubenRepeatChallengeConfigs.GetLevelConfig(level) + local curLevelMaxExp = levelConfig.UpExp + local isMaxLv = level == XFubenRepeatChallengeConfigs.GetMaxLevel() + + self.ImgExp.fillAmount = isMaxLv and 1 or (exp / curLevelMaxExp) + self.TxtBuffDes.gameObject:SetActiveEx(not isMaxLv) + self.TxtLevel.text = CsXTextManagerGetText("ActivityRepeatChallengeLevel", level) + local nextShowLevel = XDataCenter.FubenRepeatChallengeManager.GetNextShowLevel() + if nextShowLevel then + local nextLvCfg = XFubenRepeatChallengeConfigs.GetLevelConfig(nextShowLevel) + self.TxtBuffDes.text = nextLvCfg.SimpleDesc + self.TxtExp.text = CsXTextManagerGetText("ActivityRepeatChallengeNextLevelDesc", nextShowLevel) + else + self.TxtBuffDes.gameObject:SetActiveEx(false) + self.TxtExp.transform.position = CS.UnityEngine.Vector3.Lerp(self.TxtExp.transform.position, self.TxtBuffDes.transform.position, 0.5) + if isMaxLv then + self.TxtExp.text = CsXTextManagerGetText("ActivityRepeatChallengeMaxLevelTip") + else + self.TxtExp.text = CsXTextManagerGetText("ActivityRepeatChallengeExp", exp, curLevelMaxExp) + end + end + -- TxtExpMax -> "(已达每日上限)" + self.TxtExpMax.gameObject:SetActiveEx(false) +end + +function XUiFubenRepeatchallenge:SelectChapter(chapterId) + self.SelectChapterId = chapterId + self:CloseChildUi(ChildDetailUi) + self:RefreshCurChapter() + self:RefreshChapterList() + self:RefreshChapterReward(chapterId) +end + +function XUiFubenRepeatchallenge:RefreshChapterList() + local chapterId = self.SelectChapterId + local chapterCfg = XFubenRepeatChallengeConfigs.GetChapterCfg(chapterId) + local data = { + Chapter = chapterCfg, + StageList = chapterCfg.StageId, + HideStageCb = handler(self, self.CloseStageDetailCb), + ShowStageCb = handler(self, self.ShowStageDetail), + } + local prefabName = chapterCfg.Prefab + local grid = self.ChapterList[prefabName] + if not grid or XTool.UObjIsNil(grid.GameObject) then + local go = self.PanelChapter:LoadPrefab(prefabName) + if not XTool.UObjIsNil(go) then + grid = XUiGridChapter.New(self, go) + self.ChapterList[prefabName] = grid + end + end + grid:UpdateChapterGrid(data) + self.CurGrid = grid + + if self.DefaultStageId then + grid:ClickStageGridByStageId(self.DefaultStageId) + self.DefaultStageId = nil + end +end + +function XUiFubenRepeatchallenge:RefreshChapterReward(chapterId) + self.ChapterRewardGrids = self.ChapterRewardGrids or {} + local rewardId = XDataCenter.FubenRepeatChallengeManager.GetChapterRewardId(chapterId) + local rewards = XRewardManager.GetRewardList(rewardId) + + local rewardsNum = #rewards + for i = 1, rewardsNum do + local grid = self.ChapterRewardGrids[i] + if not grid then + local go = i == 1 and self.GridCommonPopUp or CS.UnityEngine.Object.Instantiate(self.GridCommonPopUp) + grid = XUiGridCommon.New(self, go) + self.ChapterRewardGrids[i] = grid + end + grid:Refresh(rewards[i]) + grid.Transform:SetParent(self.PanelRewrds, false) + grid.GameObject:SetActiveEx(true) + end + for i = rewardsNum + 1, #self.ChapterRewardGrids do + self.ChapterRewardGrids[i].GameObject:SetActiveEx(false) + end + + local canGet, des = XDataCenter.FubenRepeatChallengeManager.CheckChapterRewardCanGet(chapterId) + local hasGot = XDataCenter.FubenRepeatChallengeManager.CheckChapterRewardGot(chapterId) + if hasGot then + self.BtnTreasure:SetDisable(true) + self.TxtCondition.gameObject:SetActiveEx(false) + self.BtnTreasure.gameObject:SetActiveEx(true) + else + if not canGet then + self.TxtCondition.text = des + self.TxtCondition.gameObject:SetActiveEx(true) + self.BtnTreasure.gameObject:SetActiveEx(false) + else + self.TxtCondition.gameObject:SetActiveEx(false) + self.BtnTreasure:SetDisable(false) + self.BtnTreasure.gameObject:SetActiveEx(true) + end + end + + XRedPointManager.Check(self.RedPointId, chapterId) +end + +function XUiFubenRepeatchallenge:OnCheckRewards(count) + local isRed = count >= 0 + local chapterIndex = self.CurChapterIndex + if chapterIndex then + self["BtnChapter" .. chapterIndex]:ShowReddot(isRed) + end +end + +function XUiFubenRepeatchallenge:ShowStageDetail(stage) + -- 复刷关拦截已结束章节 + local isFinished = XDataCenter.FubenRepeatChallengeManager.IsStageFinished(stage.StageId) + if isFinished then + XUiManager.TipError(CsXTextManagerGetText("ActivityRepeatChallengeChapterFinished")) + return + end + + CS.XAudioManager.PlaySound(XSoundManager.UiBasicsMusic.Main_huge) + + if XDataCenter.FubenRepeatChallengeManager.IsStatusEqualFightEnd() then + XUiManager.TipText("ActivityRepeatChallengeFightEnd") + return + end + + self:OpenOneChildUi(ChildDetailUi, self) + self:FindChildUiObj(ChildDetailUi):Refresh(stage) +end + +function XUiFubenRepeatchallenge:CloseStageDetailCb() + if XLuaUiManager.IsUiShow(ChildDetailUi) then + self:FindChildUiObj(ChildDetailUi):CloseWithAnimDisable() + end +end + +function XUiFubenRepeatchallenge:CloseStageDetail() + if self.CurGrid then + self.CurGrid:CancelSelect() + end +end + +function XUiFubenRepeatchallenge:CreateActivityTimer() + self:DestroyActivityTimer() + + local time = XTime.GetServerNowTimestamp() + local fightEndTime = XDataCenter.FubenRepeatChallengeManager.GetFightEndTime() + local activityEndTime = XDataCenter.FubenRepeatChallengeManager.GetActivityEndTime() + local shopStr = CsXTextManagerGetText("ActivityBranchShopLeftTime") + local fightStr = CsXTextManagerGetText("ActivityBranchFightLeftTime") + + if XDataCenter.FubenRepeatChallengeManager.IsStatusEqualFightEnd() then + self.TxtResetDesc.text = shopStr + self.TxtLeftTime.text = XUiHelper.GetTime(activityEndTime - time, XUiHelper.TimeFormatType.ACTIVITY) + else + self.TxtResetDesc.text = fightStr + self.TxtLeftTime.text = XUiHelper.GetTime(fightEndTime - time, XUiHelper.TimeFormatType.ACTIVITY) + end + + self.ActivityTimer = CsXScheduleManager.ScheduleForever(function() + if XTool.UObjIsNil(self.TxtLeftTime) then + self:DestroyActivityTimer() + return + end + + time = time + 1 + + if time >= activityEndTime then + self:DestroyActivityTimer() + XDataCenter.FubenRepeatChallengeManager.OnActivityEnd() + elseif fightEndTime <= time then + local leftTime = activityEndTime - time + if leftTime > 0 then + self.TxtResetDesc.text = shopStr + self.TxtLeftTime.text = XUiHelper.GetTime(leftTime, XUiHelper.TimeFormatType.ACTIVITY) + end + else + local leftTime = fightEndTime - time + if leftTime > 0 then + self.TxtResetDesc.text = fightStr + self.TxtLeftTime.text = XUiHelper.GetTime(leftTime, XUiHelper.TimeFormatType.ACTIVITY) + else + self:DestroyActivityTimer() + self:CreateActivityTimer() + end + end + end, CsXScheduleManager.SECOND, 0) +end + +function XUiFubenRepeatchallenge:DestroyActivityTimer() + if self.ActivityTimer then + CsXScheduleManager.UnSchedule(self.ActivityTimer) + self.ActivityTimer = nil + end +end + +function XUiFubenRepeatchallenge:AutoAddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:RegisterClickEvent(self.BtnActDesc, self.OnBtnActDescClick) + self:RegisterClickEvent(self.BtnSwitch2Fight, self.OnBtnSwitch2FightClick) + self:RegisterClickEvent(self.BtnSwitch2Regional, self.OnBtnSwitch2RegionalClick) + self:RegisterClickEvent(self.BtnLevelDes, self.OnBtnLevelDesClick) + self:RegisterClickEvent(self.BtnTreasure, self.OnBtnTreasureClick) + self.BtnShop.CallBack = function() self:OnBtnShopClick() end +end + +function XUiFubenRepeatchallenge:OnBtnBackClick() + if XLuaUiManager.IsUiShow(ChildDetailUi) then + self:CloseStageDetail() + else + self:Close() + end +end + +function XUiFubenRepeatchallenge:OnBtnCloseDetailClick() + self:CloseStageDetail() +end + +function XUiFubenRepeatchallenge:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiFubenRepeatchallenge:OnBtnActDescClick() + XUiManager.UiFubenDialogTip("", XDataCenter.FubenRepeatChallengeManager.GetActDescription()) +end + +function XUiFubenRepeatchallenge:OnBtnSwitch2FightClick() + if not XDataCenter.FubenRepeatChallengeManager.IsStatusEqualChallengeBegin() + or not XDataCenter.FubenRepeatChallengeManager.GetCurChapterIndex(XDataCenter.FubenRepeatChallengeManager.DifficultType.Difficult) then + local chanllengeBeginTime = XDataCenter.FubenRepeatChallengeManager.GetActivityChallengeBeginTime() + local timeStr = XTime.TimestampToGameDateTimeString(chanllengeBeginTime, TimeFormat) + local desc = CsXTextManagerGetText("ActivityRepeatChallengeHideBeginTime", timeStr) + XUiManager.TipError(desc) + return + end + + local ret, desc = XDataCenter.FubenRepeatChallengeManager.IsDifficultModeOpen() + if not ret then + XUiManager.TipError(desc) + return + end + + XDataCenter.FubenRepeatChallengeManager.SelectDifficult(XDataCenter.FubenRepeatChallengeManager.DifficultType.Difficult) + self.PanelTabChapterGroup.gameObject:SetActiveEx(false) + self:CloseStageDetail() + self:Refresh() +end + +function XUiFubenRepeatchallenge:OnBtnSwitch2RegionalClick() + XDataCenter.FubenRepeatChallengeManager.SelectDifficult(XDataCenter.FubenRepeatChallengeManager.DifficultType.Normal) + self.PanelTabChapterGroup.gameObject:SetActiveEx(true) + self:CloseStageDetail() + self:Refresh() +end + +function XUiFubenRepeatchallenge:OnBtnLevelDesClick() + XLuaUiManager.Open("UiFubenRepeatchallengeLevelDes") +end + +function XUiFubenRepeatchallenge:OnClickTabCallBack(tabIndex) + local chapterId = XDataCenter.FubenRepeatChallengeManager.GetChapterId(self.DifficultType, tabIndex) + local isFinished = XDataCenter.FubenRepeatChallengeManager.IsChapterFinished(chapterId) + local isUnlock = XDataCenter.FubenRepeatChallengeManager.IsChapterUnlock(chapterId) + if not isFinished and not isUnlock then + local time = XTime.GetServerNowTimestamp() + local beginTime = XDataCenter.FubenRepeatChallengeManager.GetChapterBeginTime(chapterId) + local timeStr = XUiHelper.GetTime(beginTime - time, XUiHelper.TimeFormatType.ACTIVITY) + XUiManager.TipError(CsXTextManagerGetText("ActivityRepeatChallengeChapterLock", timeStr)) + return + end + + self.CurChapterIndex = tabIndex + self:CloseStageDetail() + self:PlayAnimation("AnimBeijingQieHuan") + self:SelectChapter(chapterId) +end + +function XUiFubenRepeatchallenge:OnBtnTreasureClick() + local chapterId = self.SelectChapterId + if XDataCenter.FubenRepeatChallengeManager.CheckChapterRewardGot(chapterId) then + XUiManager.TipText("ActivityRepeatChallengeTaskAlreadyFinish") + return + end + + XDataCenter.FubenRepeatChallengeManager.RequesetGetReward(chapterId, function(rewardGoodsList) + XUiManager.OpenUiObtain(rewardGoodsList) + local exConsumeId = XDataCenter.FubenRepeatChallengeManager.ExCostItemId + if exConsumeId and exConsumeId ~= 0 and self.CommonGrid then + self.CommonGrid:Refresh({ TemplateId = exConsumeId, Count = XDataCenter.ItemManager.GetCount(exConsumeId) }) + end + self:RefreshChapterReward(chapterId) + end) +end + +function XUiFubenRepeatchallenge:OnBtnShopClick() + local skipId = XDataCenter.FubenRepeatChallengeManager.GetActivityConfig().ShopSkipId + XFunctionManager.SkipInterface(skipId) +end diff --git a/Resources/Scripts/XUi/XUiFubenRepeatchallenge/XUiFubenRepeatchallengeLevelDes.lua b/Resources/Scripts/XUi/XUiFubenRepeatchallenge/XUiFubenRepeatchallengeLevelDes.lua new file mode 100644 index 00000000..de84f974 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenRepeatchallenge/XUiFubenRepeatchallengeLevelDes.lua @@ -0,0 +1,45 @@ +local XUiGridFubenRepeatchallengeLevel = require("XUi/XUiFubenRepeatchallenge/XUiGridFubenRepeatchallengeLevel") + +local XUiFubenRepeatchallengeLevelDes = XLuaUiManager.Register(XLuaUi, "UiFubenRepeatchallengeLevelDes") + +function XUiFubenRepeatchallengeLevelDes:OnAwake() + self:AutoAddListener() + self:InitDynamicTable() + + self.TxtDayExp.gameObject:SetActiveEx(false) +end + +function XUiFubenRepeatchallengeLevelDes:OnEnable() + self:Refresh() +end + +function XUiFubenRepeatchallengeLevelDes:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelDynamicTable) + self.DynamicTable:SetDelegate(self) + self.DynamicTable:SetProxy(XUiGridFubenRepeatchallengeLevel) + self.GridRepeatChallengeLevel.gameObject:SetActiveEx(false) +end + +function XUiFubenRepeatchallengeLevelDes:Refresh() + self:UpdateDynamicTable() +end + +function XUiFubenRepeatchallengeLevelDes:UpdateDynamicTable() + self.LevelList = XFubenRepeatChallengeConfigs.GetLevelConfigs() + self.DynamicTable:SetDataSource(self.LevelList) + self.DynamicTable:ReloadDataSync(-1) +end + +function XUiFubenRepeatchallengeLevelDes:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:Refresh(index) + end +end + +function XUiFubenRepeatchallengeLevelDes:AutoAddListener() + self:RegisterClickEvent(self.BtnClose, self.OnBtnCloseClick) +end + +function XUiFubenRepeatchallengeLevelDes:OnBtnCloseClick() + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenRepeatchallenge/XUiGridFubenRepeatchallengeLevel.lua b/Resources/Scripts/XUi/XUiFubenRepeatchallenge/XUiGridFubenRepeatchallengeLevel.lua new file mode 100644 index 00000000..23d5ba1f --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenRepeatchallenge/XUiGridFubenRepeatchallengeLevel.lua @@ -0,0 +1,24 @@ +local XUiGridFubenRepeatchallengeLevel = XClass(nil, "XUiGridFubenRepeatchallengeLevel") + +function XUiGridFubenRepeatchallengeLevel:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiGridFubenRepeatchallengeLevel:Refresh(level) + local levelConfig = XFubenRepeatChallengeConfigs.GetLevelConfig(level) + local buffDes = XDataCenter.FubenRepeatChallengeManager.GetBuffDes(levelConfig.BuffId[1]) + for i = 1, 2 do + self["TxtLevel" .. i].text = level + self["TxtPoint" .. i].text = levelConfig.UpExp + if buffDes then self["TxtBuff" .. i].text = buffDes end + end + + local curLevel = XDataCenter.FubenRepeatChallengeManager.GetLevel() + local isSelect = curLevel >= level + self.PanelSelect.gameObject:SetActiveEx(isSelect) + self.PanelNormal.gameObject:SetActiveEx(not isSelect) +end + +return XUiGridFubenRepeatchallengeLevel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenRepeatchallenge/XUiGridRewardLine.lua b/Resources/Scripts/XUi/XUiFubenRepeatchallenge/XUiGridRewardLine.lua new file mode 100644 index 00000000..e6bb36d2 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenRepeatchallenge/XUiGridRewardLine.lua @@ -0,0 +1,36 @@ +local XUiGridRewardLine = XClass(nil, "XUiGridRewardLine") + +function XUiGridRewardLine:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.GridReward.gameObject:SetActiveEx(false) + self.RewardGrids = {} +end + +function XUiGridRewardLine:InitRootUi(rootUi) + self.RootUi = rootUi +end + +function XUiGridRewardLine:Refresh(rewardGoodsList, index) + self.TxtOrder.text = index < 10 and "0" .. index or index + rewardGoodsList = rewardGoodsList or {} + local rewards = XRewardManager.MergeAndSortRewardGoodsList(rewardGoodsList) + for idx, item in ipairs(rewards) do + local grid = self.RewardGrids[idx] + if not grid then + local ui = CS.UnityEngine.Object.Instantiate(self.GridReward) + grid = XUiGridCommon.New(self.RootUi, ui) + grid.Transform:SetParent(self.PanelRewardContent, false) + grid.GameObject:SetActiveEx(true) + self.RewardGrids[idx] = grid + end + grid:Refresh(item, nil, nil, true) + end + + for i = #rewards + 1, #self.RewardGrids do + self.RewardGrids[i].GameObject:SetActiveEx(false) + end +end + +return XUiGridRewardLine \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenRepeatchallenge/XUiRepeatChallengeEnter.lua b/Resources/Scripts/XUi/XUiFubenRepeatchallenge/XUiRepeatChallengeEnter.lua new file mode 100644 index 00000000..c877d63d --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenRepeatchallenge/XUiRepeatChallengeEnter.lua @@ -0,0 +1,133 @@ +local CONDITION_COLOR = { + [true] = CS.UnityEngine.Color.black, + [false] = CS.UnityEngine.Color.red, +} + +local XUiRepeatChallengeEnter = XLuaUiManager.Register(XLuaUi, "UiRepeatChallengeEnter") + +function XUiRepeatChallengeEnter:OnAwake() + self:AutoAddListener() + self.GridCommon.gameObject:SetActive(false) +end + +function XUiRepeatChallengeEnter:OnStart(stage) + self.Stage = stage + self.StageId = stage.StageId + self.GridList = {} + self:ChangeChallengeCount(1) +end + +function XUiRepeatChallengeEnter:OnEnable() + self:Refresh() +end + +function XUiRepeatChallengeEnter:Refresh() + self:UpdateRewards() +end + +function XUiRepeatChallengeEnter:ChangeChallengeCount(newCount) + local stageId = self.StageId + if not XDataCenter.FubenManager.CheckChallengeCount(stageId, newCount) then + return + end + + self.ChallengeCount = newCount + self.TxtChallengeNum.text = newCount + self.TxtRewardNum.text = "X" .. newCount + + local canSub = XDataCenter.FubenManager.CheckChallengeCount(stageId, newCount - 1) + self.BtnSub.gameObject:SetActiveEx(canSub) + self.ImgCantSub.gameObject:SetActiveEx(not canSub) + + local canAdd = XDataCenter.FubenManager.CheckChallengeCount(stageId, newCount + 1) + self.BtnAdd.gameObject:SetActiveEx(canAdd) + self.ImgCantAdd.gameObject:SetActiveEx(not canAdd) + + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + self.TxtATNums.text = stageCfg.RequireActionPoint * newCount + + local exConsumeId, exConsumeNum = XDataCenter.FubenManager.GetStageExCost(stageId) + if exConsumeId ~= 0 and exConsumeNum ~= 0 then + local exHaveNum = XDataCenter.ItemManager.GetCount(exConsumeId) + self.TxtCostNum.color = CONDITION_COLOR[exHaveNum >= exConsumeNum] + self.TxtCostNum.text = exConsumeNum * newCount + self.RawImgCostIcon:SetRawImage(XDataCenter.ItemManager.GetItemIcon(exConsumeId)) + self.PanelCostEx.gameObject:SetActiveEx(true) + else + self.PanelCostEx.gameObject:SetActiveEx(false) + end +end + +function XUiRepeatChallengeEnter:UpdateRewards() + local stageId = self.StageId + local cfg = XDataCenter.FubenManager.GetStageLevelControl(stageId) + local rewardId = cfg and cfg.FinishRewardShow + + if not rewardId or rewardId == 0 then + self.PanelRewards.gameObject:SetActiveEx(false) + return + else + self.PanelRewards.gameObject:SetActiveEx(true) + end + + local rewards = XRewardManager.GetRewardListNotCount(rewardId) + if rewards then + for i, item in ipairs(rewards) do + local grid + if self.GridList[i] then + grid = self.GridList[i] + else + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommon) + grid = XUiGridCommon.New(self, ui) + grid.Transform:SetParent(self.PanelRewards, false) + self.GridList[i] = grid + end + grid:Refresh(item) + grid.GameObject:SetActive(true) + end + end + + local rewardsCount = 0 + if rewards then + rewardsCount = #rewards + end + + for j = 1, #self.GridList do + if j > rewardsCount then + self.GridList[j].GameObject:SetActive(false) + end + end +end + +function XUiRepeatChallengeEnter:AutoAddListener() + self:RegisterClickEvent(self.BtnEnter, self.OnBtnEnterClick) + self:RegisterClickEvent(self.BtnClose, self.OnBtnCloseClick) + self:RegisterClickEvent(self.BtnSub, self.OnClickBtnSub) + self:RegisterClickEvent(self.BtnMax, self.OnClickBtnMax) + self:RegisterClickEvent(self.BtnAdd, self.OnClickBtnAdd) +end + +function XUiRepeatChallengeEnter:OnBtnCloseClick() + self:Close() +end + +function XUiRepeatChallengeEnter:OnBtnEnterClick() + CS.XAudioManager.PlaySound(XSoundManager.UiBasicsMusic.Main_huge) + self:Close() + if XDataCenter.FubenManager.CheckPreFight(self.Stage, self.ChallengeCount) then + local data = {ChallengeCount = self.ChallengeCount} + XLuaUiManager.Open("UiNewRoomSingle", self.StageId, data) + end +end + +function XUiRepeatChallengeEnter:OnClickBtnSub() + self:ChangeChallengeCount(self.ChallengeCount - 1) +end + +function XUiRepeatChallengeEnter:OnClickBtnAdd() + self:ChangeChallengeCount(self.ChallengeCount + 1) +end + +function XUiRepeatChallengeEnter:OnClickBtnMax() + self:ChangeChallengeCount(XDataCenter.FubenManager.GetStageMaxChallengeCount(self.StageId)) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenRepeatchallenge/XUiRepeatChallengeSettleWin.lua b/Resources/Scripts/XUi/XUiFubenRepeatchallenge/XUiRepeatChallengeSettleWin.lua new file mode 100644 index 00000000..98d41dce --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenRepeatchallenge/XUiRepeatChallengeSettleWin.lua @@ -0,0 +1,295 @@ +local XUiPanelExpBar = require("XUi/XUiSettleWinMainLine/XUiPanelExpBar") +local XUiGridRewardLine = require("XUi/XUiFubenRepeatchallenge/XUiGridRewardLine") + +local CsXTextManagerGetText = CS.XTextManager.GetText + +local XUiRepeatChallengeSettleWin = XLuaUiManager.Register(XLuaUi, "UiRepeatChallengeSettleWin") + +function XUiRepeatChallengeSettleWin:OnAwake() + self:InitAutoScript() + self:InitDynamicTable() +end + +function XUiRepeatChallengeSettleWin:OnStart(data, addLevelTip) + self.WinData = data + self.StageInfos = XDataCenter.FubenManager.GetStageInfo(data.StageId) + self.StageCfg = XDataCenter.FubenManager.GetStageCfg(data.StageId) + self.CurrentStageId = data.StageId + self.CurrAssistInfo = data.ClientAssistInfo + self.WinCount = data.SettleData.ChallengeCount or 1 + self:InitInfo(data) + XDataCenter.FunctionEventManager.UnLockFunctionEvent() + + if addLevelTip then + XUiManager.TipMsg(CsXTextManagerGetText("ActivityRepeatChallengeAddExpTip", addLevelTip)) + XDataCenter.FubenRepeatChallengeManager.ClearAddLevelTip() + end +end + +function XUiRepeatChallengeSettleWin:OnDestroy() + XDataCenter.AntiAddictionManager.EndFightAction() +end + +function XUiRepeatChallengeSettleWin:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelRewards) + self.DynamicTable:SetDelegate(self) + self.DynamicTable:SetProxy(XUiGridRewardLine) + self.GridRewardLine.gameObject:SetActiveEx(false) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiRepeatChallengeSettleWin:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiRepeatChallengeSettleWin:AutoInitUi() + self.PanelBtns = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelBtn/PanelBtns") + self.BtnLeft = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelBtn/PanelBtns/BtnLeft"):GetComponent("Button") + self.TxtLeft = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelBtn/PanelBtns/BtnLeft/TxtLeft"):GetComponent("Text") + self.BtnRight = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelBtn/PanelBtns/BtnRight"):GetComponent("Button") + self.TxtRight = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelBtn/PanelBtns/BtnRight/TxtRight"):GetComponent("Text") + self.PanelTouch = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelBtn/PanelTouch") + self.BtnBlock = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelBtn/PanelTouch/BtnBlock"):GetComponent("Button") + self.PanelRight = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelRight") + self.PanelFriend = self.Transform:Find("SafeAreaContentPane/PanelFriend") + self.PanelInf = self.Transform:Find("SafeAreaContentPane/PanelFriend/PanelInf") + self.PanelHead = self.Transform:Find("SafeAreaContentPane/PanelFriend/PanelInf/PanelHead") + self.ImgHead = self.Transform:Find("SafeAreaContentPane/PanelFriend/PanelInf/PanelHead/ImgHead"):GetComponent("Image") + self.TxtName = self.Transform:Find("SafeAreaContentPane/PanelFriend/PanelInf/TxtName"):GetComponent("Text") + self.TxtLv = self.Transform:Find("SafeAreaContentPane/PanelFriend/PanelInf/TxtLv"):GetComponent("Text") + self.BtnFriClose = self.Transform:Find("SafeAreaContentPane/PanelFriend/BtnFriClose"):GetComponent("Button") + self.BtnFriAdd = self.Transform:Find("SafeAreaContentPane/PanelFriend/BtnFriAdd"):GetComponent("Button") +end + +function XUiRepeatChallengeSettleWin:AutoAddListener() + self:RegisterClickEvent(self.BtnLeft, self.OnBtnLeftClick) + self:RegisterClickEvent(self.BtnRight, self.OnBtnRightClick) + self:RegisterClickEvent(self.BtnBlock, self.OnBtnBlockClick) + self:RegisterClickEvent(self.BtnFriClose, self.OnBtnFriCloseClick) + self:RegisterClickEvent(self.BtnFriAdd, self.OnBtnFriAddClick) +end +-- auto +function XUiRepeatChallengeSettleWin:OnBtnLeftClick() + self:SetBtnByType(self.StageCfg.FunctionLeftBtn) +end + +function XUiRepeatChallengeSettleWin:OnBtnFriCloseClick() + self.PanelFriend.gameObject:SetActive(false) +end + +function XUiRepeatChallengeSettleWin:OnBtnFriAddClick() + if not self.CurrAssistInfo then + return + end + + XDataCenter.SocialManager.ApplyFriend(self.CurrAssistInfo.Id) + + self.CurrAssistInfo = nil + self.PanelFriend.gameObject:SetActive(false) +end + +function XUiRepeatChallengeSettleWin:InitInfo(data) + self.PanelFriend.gameObject:SetActive(false) + XTipManager.Execute() + + self:SetBtnsInfo(data) + self:SetStageInfo(data) + self:UpdatePlayerInfo(data) + self:InitRewardCharacterList(data) + self:UpdateDynamicTable(data.SettleData.MultiRewardGoodsList) + + XTipManager.Add(function() + if data.UrgentId > 0 then + XLuaUiManager.Open("UiSettleUrgentEvent", data.UrgentId) + end + end) +end + +function XUiRepeatChallengeSettleWin:SetBtnsInfo(data) + local stageData = XDataCenter.FubenManager.GetStageData(data.StageId) + + if self.StageCfg.HaveFirstPass and stageData and stageData.PassTimesToday < 2 then + self.PanelTouch.gameObject:SetActive(true) + self.PanelBtns.gameObject:SetActive(false) + else + local leftType = self.StageCfg.FunctionLeftBtn + local rightType = self.StageCfg.FunctionRightBtn + + self.BtnLeft.gameObject:SetActive(leftType > 0) + self.BtnRight.gameObject:SetActive(rightType > 0) + self.TxtLeft.text = XRoomSingleManager.GetBtnText(leftType) + self.TxtRight.text = XRoomSingleManager.GetBtnText(rightType) + + self.PanelTouch.gameObject:SetActive(false) + self.PanelBtns.gameObject:SetActive(true) + end +end + +function XUiRepeatChallengeSettleWin:SetStageInfo(data) + local _, stageName = XDataCenter.FubenManager.GetFubenNames(data.StageId) + self.TxtStageName.text = stageName +end + +-- 角色奖励列表 +function XUiRepeatChallengeSettleWin:InitRewardCharacterList(data) + self.GridWinRole.gameObject:SetActive(false) + if self.StageCfg.RobotId and #self.StageCfg.RobotId > 0 then + for i = 1, #self.StageCfg.RobotId do + if self.StageCfg.RobotId[i] > 0 then + local ui = CS.UnityEngine.Object.Instantiate(self.GridWinRole) + local grid = XUiGridWinRole.New(self, ui) + grid.Transform:SetParent(self.PanelRoleContent, false) + grid:UpdateRobotInfo(self.StageCfg.RobotId[i]) + grid.GameObject:SetActive(true) + end + end + else + local charExp = data.CharExp + local count = #charExp + if count <= 0 then + return + end + + -- 原先机制只加一次经验,而且读的本地表,多重挑战需要乘以次数 + local winCount = self.WinCount + for i = 1, count do + local ui = CS.UnityEngine.Object.Instantiate(self.GridWinRole) + local grid = XUiGridWinRole.New(self, ui) + grid.Transform:SetParent(self.PanelRoleContent, false) + grid:UpdateRoleInfo(charExp[i], self.StageCfg.CardExp * winCount) + grid.GameObject:SetActive(true) + end + end +end + +-- 玩家经验 +function XUiRepeatChallengeSettleWin:UpdatePlayerInfo(data) + if not data or not next(data) then return end + + local lastLevel = data.RoleLevel + local lastExp = data.RoleExp + local lastMaxExp = XPlayerManager.GetMaxExp(lastLevel, XPlayer.IsHonorLevelOpen()) + local curLevel = XPlayer.GetLevelOrHonorLevel() + local curExp = XPlayer.Exp + local curMaxExp = XPlayerManager.GetMaxExp(curLevel, XPlayer.IsHonorLevelOpen()) + local txtLevelName = XPlayer.IsHonorLevelOpen() and CS.XTextManager.GetText("HonorLevel") or nil + + + -- 原先机制只加一次经验,而且读的本地表,多重挑战需要乘以次数 + local winCount = self.WinCount + local addExp = self.StageCfg.TeamExp * winCount + self.PlayerExpBar = self.PlayerExpBar or XUiPanelExpBar.New(self.PanelPlayerExpBar) + self.PlayerExpBar:LetsRoll(lastLevel, lastExp, lastMaxExp, curLevel, curExp, curMaxExp, addExp, txtLevelName) +end + +function XUiRepeatChallengeSettleWin:UpdateDynamicTable(rewardLineList) + self.RewardLineList = rewardLineList + self.DynamicTable:SetDataSource(self.RewardLineList) + self.DynamicTable:ReloadDataSync(-1) +end + +function XUiRepeatChallengeSettleWin:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:InitRootUi(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local rewardGoodsList = self.RewardLineList[index] + grid:Refresh(rewardGoodsList, index) + end +end + +function XUiRepeatChallengeSettleWin:OnBtnRightClick() + self:SetBtnByType(self.StageCfg.FunctionRightBtn) +end + +function XUiRepeatChallengeSettleWin:SetBtnByType(btnType) + if btnType == XRoomSingleManager.BtnType.SelectStage then + self:OnBtnBackClick(false) + elseif btnType == XRoomSingleManager.BtnType.Again then + -- 多重挑战需要传递上次挑战的次数 + local data = { ChallengeCount = XDataCenter.FubenManager.GetFightChallengeCount() } + XLuaUiManager.PopThenOpen("UiNewRoomSingle", self.StageCfg.StageId, data) + elseif btnType == XRoomSingleManager.BtnType.Next then + self:OnBtnEnterNextClick() + elseif btnType == XRoomSingleManager.BtnType.Main then + self:OnBtnBackClick(true) + end +end + +function XUiRepeatChallengeSettleWin:OnBtnEnterNextClick() + if self.StageInfos.Type == XDataCenter.FubenManager.StageType.Tower then + local stageId = XDataCenter.TowerManager.GetTowerData().CurrentStageId + if XDataCenter.TowerManager.CheckStageCanEnter(stageId) then + XLuaUiManager.PopThenOpen("UiNewRoomSingle", stageId) + else + local text = CS.XTextManager.GetText("TowerCannotEnter") + XUiManager.TipMsg(text, XUiManager.UiTipType.Tip) + end + else + if self.StageInfos.NextStageId then + local nextStageCfg = XDataCenter.FubenManager.GetStageCfg(self.StageInfos.NextStageId) + self:HidePanel() + XDataCenter.FubenManager.OpenRoomSingle(nextStageCfg) + else + local text = CS.XTextManager.GetText("BattleWinMainCannotEnter") + XUiManager.TipMsg(text, XUiManager.UiTipType.Tip) + end + end +end + +function XUiRepeatChallengeSettleWin:OnBtnBackClick(isRunMain) + if self.StageInfos.Type == XDataCenter.FubenManager.StageType.Tower then + if XDataCenter.TowerManager.GetChapterLastMapId(self.CurrentStageId) == self.CurrentStageId then + XDataCenter.TowerManager.GetTowerChapterReward(function() + if isRunMain then + XLuaUiManager.RunMain() + else + self:HidePanel() + end + end, self.CurrentStageId) + else + if isRunMain then + XLuaUiManager.RunMain() + else + self:HidePanel() + end + end + elseif self.StageInfos.Type == XDataCenter.FubenManager.StageType.BossSingle then + if isRunMain then + XLuaUiManager.RunMain() + else + self:HidePanel() + end + elseif self.StageInfos.Type == XDataCenter.FubenManager.StageType.Urgent then + if isRunMain then + XLuaUiManager.RunMain() + else + -- 跳转到挑战界面 + XLuaUiManager.RunMain() + XFunctionManager.SkipInterface(600) + end + else + if isRunMain then + XLuaUiManager.RunMain() + else + self:HidePanel() + end + end +end + +function XUiRepeatChallengeSettleWin:OnBtnBlockClick() + self:HidePanel() + if self.StageCfg.FirstGotoSkipId > 0 then + XFunctionManager.SkipInterface(self.StageCfg.FirstGotoSkipId) + end +end + +function XUiRepeatChallengeSettleWin:HidePanel() + self:Close() +end + +-- function XUiRepeatChallengeSettleWin:PlayReward(index, cb) +-- self.GridRewardList[index].GameObject:SetActive(true) +-- self:PlayAnimation("GridReward", cb) +-- end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenResourceDetail/XUiFubenResourceDetail.lua b/Resources/Scripts/XUi/XUiFubenResourceDetail/XUiFubenResourceDetail.lua new file mode 100644 index 00000000..7da4cf93 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenResourceDetail/XUiFubenResourceDetail.lua @@ -0,0 +1,251 @@ + +local XUiFubenResourceDetail = XLuaUiManager.Register(XLuaUi, "UiFubenResourceDetail") + +function XUiFubenResourceDetail:OnAwake() + self:InitAutoScript() +end + + +function XUiFubenResourceDetail:OnStart(params) + self.Params = params + + self.IsPlaying = false + self.Stage = nil + + self.StarItemsList = { self.GridStar1, self.GridStar2, self.GridStar3 } + self.StarGridList = {} + self.GridList = {} + self.GridCommonItem = self.Transform:Find("SafeAreaContentPane/PanelDropList/DropList/Viewport/PanelDropContent/GridCommon") + self.GridCommonItem.gameObject:SetActive(false) + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiFubenResourceDetail:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiFubenResourceDetail:AutoInitUi() + self.BtnClose = self.Transform:Find("SafeAreaContentPane/BtnClose"):GetComponent("Button") + self.PanelDropList = self.Transform:Find("SafeAreaContentPane/PanelDropList") + self.PanelDrop = self.Transform:Find("SafeAreaContentPane/PanelDropList/PanelDrop") + self.TxtDrop = self.Transform:Find("SafeAreaContentPane/PanelDropList/PanelDrop/TxtDrop"):GetComponent("Text") + self.TxtDropEn = self.Transform:Find("SafeAreaContentPane/PanelDropList/PanelDrop/TxtDropEn"):GetComponent("Text") + self.PanelDropContent = self.Transform:Find("SafeAreaContentPane/PanelDropList/DropList/Viewport/PanelDropContent") + self.GridCommon = self.Transform:Find("SafeAreaContentPane/PanelDropList/DropList/Viewport/PanelDropContent/GridCommon") + self.PanelNums = self.Transform:Find("SafeAreaContentPane/PanelNums") + self.TxtAllNums = self.Transform:Find("SafeAreaContentPane/PanelNums/TxtAllNums"):GetComponent("Text") + self.TxtLeftNums = self.Transform:Find("SafeAreaContentPane/PanelNums/TxtLeftNums"):GetComponent("Text") + self.BtnAddNum = self.Transform:Find("SafeAreaContentPane/PanelNums/BtnAddNum"):GetComponent("Button") + self.PanelBottom = self.Transform:Find("SafeAreaContentPane/PanelBottom") + self.TxtATNums = self.Transform:Find("SafeAreaContentPane/PanelBottom/TxtATNums"):GetComponent("Text") + self.BtnEnter = self.Transform:Find("SafeAreaContentPane/PanelBottom/BtnEnter"):GetComponent("Button") + self.PanelDesc = self.Transform:Find("SafeAreaContentPane/PanelDesc") + self.TxtTitle = self.Transform:Find("SafeAreaContentPane/PanelDesc/TxtTitle"):GetComponent("Text") + self.TxtLevelVal = self.Transform:Find("SafeAreaContentPane/PanelDesc/TxtLevelVal"):GetComponent("Text") + self.RImgNandu = self.Transform:Find("SafeAreaContentPane/PanelDesc/RImgNandu"):GetComponent("RawImage") + self.TxtDesc = self.Transform:Find("SafeAreaContentPane/PanelDesc/TxtDesc"):GetComponent("Text") + self.PanelTargetList = self.Transform:Find("SafeAreaContentPane/PanelTargetList") + self.TxtActive3 = self.Transform:Find("SafeAreaContentPane/PanelTargetList/TxtActive3"):GetComponent("Text") + self.TxtActive2 = self.Transform:Find("SafeAreaContentPane/PanelTargetList/TxtActive2"):GetComponent("Text") + self.TxtActive1 = self.Transform:Find("SafeAreaContentPane/PanelTargetList/TxtActive1"):GetComponent("Text") + self.PanelAsset = self.Transform:Find("SafeAreaContentPane/PanelAsset") + self.PanelItem = self.Transform:Find("SafeAreaContentPane/PanelItem") + self.PanelFubenTab = self.Transform:Find("SafeAreaContentPane/PanelItem/PanelFubenTab") + self.PanelBg = self.Transform:Find("SafeAreaContentPane/PanelBg") +end + +function XUiFubenResourceDetail:AutoAddListener() + self:RegisterClickEvent(self.BtnClose, self.OnBtnCloseClick) + self:RegisterClickEvent(self.BtnAddNum, self.OnBtnAddNumClick) + self:RegisterClickEvent(self.BtnEnter, self.OnBtnEnterClick) +end +-- auto + +function XUiFubenResourceDetail:GetAutoKey(uiNode, eventName) + if not uiNode then + return + end + return eventName .. uiNode:GetHashCode() +end + +function XUiFubenResourceDetail:OnBtnCloseClick() + if self.IsPlaying then + return + end + + XUiHelper.StopAnimation() + self.IsPlaying = true + -- local End = function() + -- if XTool.UObjIsNil(self.GameObject) then + -- return + -- end + -- self.GameObject:SetActive(false) + -- self.IsPlaying = false + + -- self:Close() + + -- if self.Params and self.Params.closeCb then + -- self.Params.closeCb() + -- end + -- end +end + +function XUiFubenResourceDetail:OnBtnAddNumClick() + local challengeData = XDataCenter.FubenMainLineManager.GetStageBuyChallengeData(self.Stage.StageId) + local func = function() + self:UpdateDetailText() + end + XLuaUiManager.Open("UiBuyAsset",1, func, challengeData) +end + +function XUiFubenResourceDetail:OnBtnEnterClick() + if self.Stage == nil then + XLog.Error("OnBtnEnterClick: Can not find stage!") + return + end + + self:Close() + + if self.Params and self.Params.fightCb then + self.Params.fightCb(self.Stage) + end +end + +-- 初始化 stage detail Ui +function XUiFubenResourceDetail:InitStageDetail(chapterOrderId, stage, data) + self.ChapterOrderId = chapterOrderId + self.Stage = stage + + self.FocusPanelTab = XUiPanelFubenTab.New(self, self.PanelFubenTab) + self.FocusPanelTab:SetData(data) + + self:UpdateRewards() + self:UpdateDetailText() + self:UpdateDifficulty() +end + +function XUiFubenResourceDetail:UpdateRewards() + local stage = self.Stage + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stage.StageId) + local rewardId + local IsFirst = false + if stageInfo.Passed then + -- 判断副本玩家等级调控 + local cfg = XDataCenter.FubenManager.GetStageLevelControl(stage.StageId) + rewardId = cfg and cfg.FinishRewardShow or stage.FinishRewardShow + else + -- 判断副本玩家等级调控 + local cfg = XDataCenter.FubenManager.GetStageLevelControl(stage.StageId) + rewardId = cfg and cfg.FirstRewardShow or stage.FirstRewardShow + IsFirst = true + end + + if rewardId == 0 then + for j = 1, #self.GridList do + self.GridList[j].GameObject:SetActive(false) + end + return + end + + local rewards = IsFirst and XRewardManager.GetRewardList(rewardId) or XRewardManager.GetRewardListNotCount(rewardId) + if rewards then + for i, item in ipairs(rewards) do + local grid + if self.GridList[i] then + grid = self.GridList[i] + else + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommonItem) + grid = XUiGridCommon.New(self, ui) + grid.Transform:SetParent(self.PanelDropContent, false) + self.GridList[i] = grid + end + grid:Refresh(item) + grid.GameObject:SetActive(true) + end + end + + local rewardsCount = 0 + if rewards then + rewardsCount = #rewards + end + + for j = 1, #self.GridList do + if j > rewardsCount then + self.GridList[j].GameObject:SetActive(false) + end + end +end + +function XUiFubenResourceDetail:UpdateDetailText() + self.TxtTitle.text = self.Stage.Name + self.TxtLevelVal.text = self.Stage.RecommandLevel + self.TxtDesc.text = self.Stage.Description + self.TxtATNums.text = self.Stage.RequireActionPoint + + -- local stageData = XDataCenter.FubenManager.GetStageData(self.Stage.StageId) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(self.Stage.StageId) + + local leftNum = XDataCenter.FubenResourceManager.GetSectionDataByTypeId(stageInfo.ResourceType).LeftCount + self.TxtAllNums.text = "/" .. XDataCenter.FubenResourceManager.GetSectionDataByTypeId(stageInfo.ResourceType).MaxCount + self.TxtLeftNums.text = leftNum + + + local cfg = XDataCenter.FubenManager.GetStageCfg(self.Stage.StageId) + for i = 1, 3 do + self["TxtActive" .. i].text = cfg.StarDesc[i] or "" + end +end + +function XUiFubenResourceDetail:UpdateDifficulty() + local nanDuIcon = XDataCenter.FubenManager.GetDifficultIcon(self.Stage.StageId) + self.RImgNandu:SetRawImage(nanDuIcon) +end + +function XUiFubenResourceDetail:HideEnterBtn() + if self.BtnEnter then + self.BtnEnter.gameObject:SetActive(false) + end +end + +function XUiFubenResourceDetail:ShowEnterBtn() + if self.BtnEnter then + self.BtnEnter.gameObject:SetActive(true) + end +end + +function XUiFubenResourceDetail:Show() + XUiHelper.StopAnimation() + + self:ResetSize() + + self.IsPlaying = true + self.GameObject:SetActive(true) + +end + + +function XUiFubenResourceDetail:OnEnable() + local data = XDataCenter.FubenResourceManager.GetSectionDataByTypeId(self.Params.typeId or 1) + local stageCfg = XDataCenter.FubenManager.GetStageCfg(data.StageId) + + self:Show() + self:InitStageDetail(stageCfg.OrderId, stageCfg, data) + + self:UpdateRewards() + self:UpdateDetailText() +end + +function XUiFubenResourceDetail:ResetSize() + self.PanelAsset.transform.localScale = CS.UnityEngine.Vector3.one + self.PanelTargetList.transform.localScale = CS.UnityEngine.Vector3.one + self.PanelDesc.transform.localScale = CS.UnityEngine.Vector3.one + self.PanelBottom.transform.localScale = CS.UnityEngine.Vector3.one + self.PanelNums.transform.localScale = CS.UnityEngine.Vector3.one + self.PanelDropList.transform.localScale = CS.UnityEngine.Vector3.one + self.PanelBg.transform.localScale = CS.UnityEngine.Vector3.one +end + + diff --git a/Resources/Scripts/XUi/XUiFubenRogueLike/XUiBlackShopBuyDetails.lua b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiBlackShopBuyDetails.lua new file mode 100644 index 00000000..9211e249 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiBlackShopBuyDetails.lua @@ -0,0 +1,77 @@ +local XUiBlackShopBuyDetails = XClass(nil, "XUiBlackShopBuyDetails") + +function XUiBlackShopBuyDetails:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + + XTool.InitUiObject(self) + + self.BtnTanchuangClose.CallBack = function() self:CloseBlackShopDetails() end + self.BtnBlock.CallBack = function() self:CloseBlackShopDetails() end + + self.BtnAddSelect.CallBack = function() self:OnBtnAddSelectClick() end + self.BtnMinusSelect.CallBack = function() self:OnBtnMinusSelectClick() end + self.BtnUse.CallBack = function() self:OnBtnUseClick() end +end + +function XUiBlackShopBuyDetails:ShowBlackShopDetails(shopItem) + self.ShopItemDatas = shopItem + self.GameObject:SetActiveEx(true) + self.ShopItemTemplate = XFubenRogueLikeConfig.GetShopItemTemplateById(self.ShopItemDatas.ShopItemId) + if not self.ShopItemTemplate then return end + + if self.ShopItemTemplate.Type == XFubenRogueLikeConfig.XRLShopItemType.Buff then + self.ShopItemBuffConfig = XFubenRogueLikeConfig.GetBuffConfigById(self.ShopItemTemplate.Param[1]) + self.RImgBuffIcon:SetRawImage(self.ShopItemBuffConfig.Icon) + self.TxtName.text = self.ShopItemBuffConfig.Name + end + local item = XDataCenter.ItemManager.GetItem(self.ShopItemTemplate.ConsumeId[1]) + if not item then + XLog.ErrorTableDataNotFound("XUiBlackShopBuyDetails:ShowBlackShopDetails", + "item", " Share/Item/Item.tab", "Id", tostring(self.ShopItemTemplate.ConsumeId[1])) + return + end + self.RImgCostIcon1:SetRawImage(item.Template.Icon) + self.TxtCostCount1.text = self.ShopItemTemplate.ConsumeNum[1] + self.TxtCanBuy.text = self.ShopItemDatas.BuyCount + + local defaultNum = (self.ShopItemDatas.BuyCount <= 0) and 0 or 1 + self:UpdateSelectNum(defaultNum) +end + +function XUiBlackShopBuyDetails:UpdateSelectNum(num) + self.CurrentSelectNum = num + self.TxtSelect.text = self.CurrentSelectNum + self:UpdateCostCount() +end + +function XUiBlackShopBuyDetails:UpdateCostCount() + self.TxtCostCount1.text = self.ShopItemTemplate.ConsumeNum[1] * self.CurrentSelectNum +end + +function XUiBlackShopBuyDetails:CloseBlackShopDetails() + self.GameObject:SetActiveEx(false) +end + +function XUiBlackShopBuyDetails:OnBtnAddSelectClick() + if self.ShopItemDatas and self.CurrentSelectNum + 1 <= self.ShopItemDatas.BuyCount then + self:UpdateSelectNum(self.CurrentSelectNum + 1) + end +end + +function XUiBlackShopBuyDetails:OnBtnMinusSelectClick() + if self.CurrentSelectNum - 1 > 0 then + self:UpdateSelectNum(self.CurrentSelectNum - 1) + end +end + +function XUiBlackShopBuyDetails:OnBtnUseClick() + if not self.ShopItemDatas then return end + XDataCenter.FubenRogueLikeManager.BuyBlackShopItem(self.ShopItemDatas.ShopId, self.ShopItemDatas.ShopItemId, self.CurrentSelectNum, function() + self.UiRoot:RefreshShopItems() + self.GameObject:SetActiveEx(false) + end) +end + +return XUiBlackShopBuyDetails \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenRogueLike/XUiDayTopicCharacter.lua b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiDayTopicCharacter.lua new file mode 100644 index 00000000..71bcadee --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiDayTopicCharacter.lua @@ -0,0 +1,33 @@ +local XUiDayTopicCharacter = XClass(nil, "XUiDayTopicCharacter") + +function XUiDayTopicCharacter:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + + XTool.InitUiObject(self) +end + +function XUiDayTopicCharacter:SetTopicInfo(characterInfo) + self.RImgHead:SetRawImage(XDataCenter.CharacterManager.GetCharRoundnessHeadIcon(characterInfo.Id)) + self.TxtName.text = XCharacterConfigs.GetCharacterFullNameStr(characterInfo.Id) + if self.IconUp then + self.IconUp.gameObject:SetActiveEx(XDataCenter.FubenRogueLikeManager.IsTeamEffectCharacter(characterInfo.Id)) + end + if self.TxtBlood then + self.TxtBlood.text = string.format("%s%%", tostring(characterInfo.HpLeft)) + end + if self.Slider then + self.Slider.value = characterInfo.HpLeft * 1.0 / 100 + end +end + +function XUiDayTopicCharacter:SetTopicInfoById(charId) + self.RImgHead:SetRawImage(XDataCenter.CharacterManager.GetCharRoundnessHeadIcon(charId)) + self.TxtName.text = XCharacterConfigs.GetCharacterFullNameStr(charId) + if self.IconUp then + self.IconUp.gameObject:SetActiveEx(true) + end +end + +return XUiDayTopicCharacter \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenRogueLike/XUiGridBlackShopItem.lua b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiGridBlackShopItem.lua new file mode 100644 index 00000000..60e95290 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiGridBlackShopItem.lua @@ -0,0 +1,83 @@ +local XUiGridBlackShopItem = XClass(nil, "XUiGridBlackShopItem") + +function XUiGridBlackShopItem:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + + XTool.InitUiObject(self) +end +-- SupportId = v.Id, +-- TotalBuyCount = totalBuyCount, +-- BuyCount = totalBuyCount - v.Count, +-- IsSelect = false, +function XUiGridBlackShopItem:SetItemData(shopItem) + self.ShopItemDatas = shopItem + + self.SupportTemplate = XFubenRogueLikeConfig.GetSupportStationTemplateById(self.ShopItemDatas.SupportId) + self.SupportConfig = XFubenRogueLikeConfig.GetSupportStationConfigById(self.ShopItemDatas.SupportId) + + self.RImgBuffIcon:SetRawImage(self.SupportConfig.Icon) + self.TxtName.text = self.SupportConfig.Title + self.Txtdetails.text = self.SupportConfig.Description + + if self.SupportTemplate.NeedPoint == 0 then + local specialEventId = self.SupportTemplate.SpecialEvent + local specialEventTemplate = XFubenRogueLikeConfig.GetSpecialEventTemplateById(specialEventId) + if specialEventTemplate then + local shopItemId = specialEventTemplate.Param[1] + local shopItemTemplate = XFubenRogueLikeConfig.GetShopItemTemplateById(shopItemId) + if shopItemTemplate then + local itemId = shopItemTemplate.ConsumeId[1] + local needCount = shopItemTemplate.ConsumeNum[1] + local ownCount = XDataCenter.ItemManager.GetCount(itemId) + self.TxtNewPrice1.text = needCount + self.RImgPrice1:SetRawImage(XDataCenter.ItemManager.GetItemIcon(itemId)) + self:UpdatePriceColor(needCount, ownCount) + end + end + + self.RImgPrice1.gameObject:SetActiveEx(true) + self.TxtXdcs.gameObject:SetActiveEx(false) + else + self.RImgPrice1.gameObject:SetActiveEx(false) + self.TxtXdcs.gameObject:SetActiveEx(true) + self.TxtNewPrice1.text = self.SupportTemplate.NeedPoint + local ownActionPoint = XDataCenter.FubenRogueLikeManager.GetRogueLikeActionPoint() + self:UpdatePriceColor(self.SupportTemplate.NeedPoint, ownActionPoint) + end + + self:SetItemSellOut(self.ShopItemDatas.BuyCount <= 0) + self:SetItemSelect(self.ShopItemDatas.IsSelect) +end + +function XUiGridBlackShopItem:UpdatePriceColor(needPoint, ownPoint) + if ownPoint >= needPoint then + self.TxtNewPrice1.color = CS.UnityEngine.Color(1, 1, 1) + else + self.TxtNewPrice1.color = CS.UnityEngine.Color(1, 0, 0) + end +end + +-- 打折 +function XUiGridBlackShopItem:SetSaleRate(saleRate) + local isShowSaleRate = saleRate ~= nil and saleRate ~= 0 + self.Tab.gameObject:SetActiveEx(isShowSaleRate) + if isShowSaleRate then + local snap = CS.XTextManager.GetText("Snap") + self.TxtSaleRate.text = string.format("%d%s", saleRate, snap) + end +end + +-- 是否买完了 +function XUiGridBlackShopItem:SetItemSellOut(isSellOut) + self.ImgSellOut.gameObject:SetActiveEx(isSellOut) +end + +function XUiGridBlackShopItem:SetItemSelect(isSelect) + if self.ImgSelect then + self.ImgSelect.gameObject:SetActiveEx(isSelect) + end +end + +return XUiGridBlackShopItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenRogueLike/XUiGridBuffDetailItem.lua b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiGridBuffDetailItem.lua new file mode 100644 index 00000000..0bf64a4c --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiGridBuffDetailItem.lua @@ -0,0 +1,33 @@ +local XUiGridBuffDetailItem = XClass(nil, "XUiGridBuffDetailItem") + +function XUiGridBuffDetailItem:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + + XTool.InitUiObject(self) +end + + +function XUiGridBuffDetailItem:SetBuffInfo(buff) + self.BuffData = buff + local buffTemplate = XFubenRogueLikeConfig.GetBuffConfigById(self.BuffData.BuffId) + + self.TxtName.text = buffTemplate.Name + self.TxtDetails.text = buffTemplate.Description + self.RImgBuffIcon:SetRawImage(buffTemplate.Icon) + if self.ImgDebuffKuang then + self.ImgDebuffKuang.gameObject:SetActiveEx(self.BuffData.BuffType == XFubenRogueLikeConfig.BuffType.NegativeBuff) + end + if self.ImgNew then + self.ImgNew.gameObject:SetActiveEx(XDataCenter.FubenRogueLikeManager.IsBuffNew(self.BuffData.BuffId)) + end + self:SetSelected(self.BuffData.IsSelect) +end + +function XUiGridBuffDetailItem:SetSelected(isSelect) + self.ImgSelect.gameObject:SetActiveEx(isSelect) +end + + +return XUiGridBuffDetailItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenRogueLike/XUiGridBuffInfoItem.lua b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiGridBuffInfoItem.lua new file mode 100644 index 00000000..21dc2d3d --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiGridBuffInfoItem.lua @@ -0,0 +1,32 @@ +local XUiGridBuffInfoItem = XClass(nil, "XUiGridBuffInfoItem") + +function XUiGridBuffInfoItem:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + + XTool.InitUiObject(self) +end + +function XUiGridBuffInfoItem:SetBuffInfo(buffData) + local buffId = buffData.Id + local buffConfig = XFubenRogueLikeConfig.GetBuffConfigById(buffId) + if self.RImgBuffIcon then + self.RImgBuffIcon:SetRawImage(buffConfig.Icon) + end + if self.TxtName then + self.TxtName.text = buffConfig.Name + end + if self.TxtDetails then + self.TxtDetails.text = buffConfig.Description + end +end + +function XUiGridBuffInfoItem:SetBuffInfoById(buffId) + local buffData = {} + buffData.Id = buffId + self:SetBuffInfo(buffData) +end + + +return XUiGridBuffInfoItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenRogueLike/XUiGridHelpRoleItem.lua b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiGridHelpRoleItem.lua new file mode 100644 index 00000000..92b0885f --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiGridHelpRoleItem.lua @@ -0,0 +1,20 @@ +local XUiGridHelpRoleItem = XClass(nil, "XUiGridHelpRoleItem") + +function XUiGridHelpRoleItem:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + + XTool.InitUiObject(self) +end + +function XUiGridHelpRoleItem:UpdateHelpRoleInfo(robotId) + local characterId = XRobotManager.GetCharacterId(robotId) + self.RImgRole:SetRawImage(XDataCenter.CharacterManager.GetCharHalfBodyImage(characterId)) + self.TxtName.text = XCharacterConfigs.GetCharacterFullNameStr(characterId) + self.ImgNew.gameObject:SetActiveEx(XDataCenter.FubenRogueLikeManager.IsRobotNew(robotId)) +end + + + +return XUiGridHelpRoleItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenRogueLike/XUiGridNodeShopItem.lua b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiGridNodeShopItem.lua new file mode 100644 index 00000000..05fe242a --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiGridNodeShopItem.lua @@ -0,0 +1,107 @@ +local XUiGridNodeShopItem = XClass(nil, "XUiGridNodeShopItem") +local XUiGridBuffInfoItem = require("XUi/XUiFubenRogueLike/XUiGridBuffInfoItem") +local XUiGridRoleInfoItem = require("XUi/XUiFubenRogueLike/XUiGridRoleInfoItem") + +function XUiGridNodeShopItem:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + + XTool.InitUiObject(self) + + self.RoleItem = XUiGridRoleInfoItem.New(self.GridRole) + self.BuffItem = XUiGridBuffInfoItem.New(self.UiRoot, self.GridBuff) + + -- self.BtnBuy.CallBack = function() self:OnBtnBuyClick() end +end + +function XUiGridNodeShopItem:SetItemData(shopItem) + self.ShopItemDatas = shopItem + self.ShopItemTemplate = XFubenRogueLikeConfig.GetShopItemTemplateById(self.ShopItemDatas.ShopItemId) + if self.ShopItemTemplate.Type == XFubenRogueLikeConfig.XRLShopItemType.Buff then + self.ShopItemBuffConfig = XFubenRogueLikeConfig.GetBuffConfigById(self.ShopItemTemplate.Param[1]) + self.BuffItem:SetBuffInfoById(self.ShopItemTemplate.Param[1]) + self.TxtDetails.text = self.ShopItemBuffConfig.Description + elseif self.ShopItemTemplate.Type == XFubenRogueLikeConfig.XRLShopItemType.Item then + if not self.ItemInfo then + self.ItemInfo = XUiGridCommon.New(self.RootUi, self.GridCommon) + end + local itemId = self.ShopItemTemplate.Param[1] + self.ItemInfo:Refresh(itemId) + self.TxtDetails.text = XDataCenter.ItemManager.GetItemDescription(itemId) + elseif self.ShopItemTemplate.Type == XFubenRogueLikeConfig.XRLShopItemType.Robot then + -- local robotId = self.ShopItemTemplate.Param[1] + --local characterId = XRobotManager.GetCharacterId(robotId) + self.RoleItem:SetRandomRoleInfo() + self.TxtDetails.text = CS.XTextManager.GetText("RogueLikeRandomRobotDetails") + end + + self.GridBuff.gameObject:SetActiveEx(self.ShopItemTemplate.Type == XFubenRogueLikeConfig.XRLShopItemType.Buff) + self.GridCommon.gameObject:SetActiveEx(self.ShopItemTemplate.Type == XFubenRogueLikeConfig.XRLShopItemType.Item) + self.GridRole.gameObject:SetActiveEx(self.ShopItemTemplate.Type == XFubenRogueLikeConfig.XRLShopItemType.Robot) + + self.RImgPrice1:SetRawImage(XDataCenter.ItemManager.GetItemIcon(self.ShopItemTemplate.ConsumeId[1])) + local cost = math.ceil(self.ShopItemTemplate.ConsumeNum[1] * (self.ShopItemDatas.Discount * 1 / 100)) + self.TxtNewPrice1.text = cost + self:UpdatePriceColor(self.ShopItemTemplate.ConsumeId[1], cost) + + self:SetItemSellOut(self.ShopItemDatas.BuyCount <= 0) + self:SetSaleRate(self.ShopItemDatas.Discount) + self:SetItemSelect(self.ShopItemDatas.IsSelect) +end + +function XUiGridNodeShopItem:UpdatePriceByDiscount(discount) + if not self.ShopItemDatas then return end + --local shopItemTemplate = XFubenRogueLikeConfig.GetShopItemTemplateById(self.ShopItemDatas.ShopItemId) + local cost = math.ceil(self.ShopItemTemplate.ConsumeNum[1] * (discount * 1.0 / 100)) + self.TxtNewPrice1.text = cost + self:UpdatePriceColor(self.ShopItemTemplate.ConsumeId[1], cost) +end + +function XUiGridNodeShopItem:UpdatePriceColor(itemId, needCoin) + local ownCount = XDataCenter.ItemManager.GetCount(itemId) + if ownCount >= needCoin then + self.TxtNewPrice1.color = CS.UnityEngine.Color(1, 1, 1) + else + self.TxtNewPrice1.color = CS.UnityEngine.Color(1, 0, 0) + end +end + +-- 打折 +function XUiGridNodeShopItem:SetSaleRate(saleRate) + local isShowSaleRate = saleRate ~= nil and saleRate ~= 0 and saleRate ~= 100 + + local discount + if saleRate % 10 == 0 then + discount = 100 - saleRate + else + discount = 100 - saleRate + end + self.Tab.gameObject:SetActiveEx(isShowSaleRate) + if isShowSaleRate then + local snap = CS.XTextManager.GetText("Snap", discount) + self.TxtSaleRate.text = snap + end +end + +-- 是否买完了 +function XUiGridNodeShopItem:SetItemSellOut(isSellOut) + self.ImgSellOut.gameObject:SetActiveEx(isSellOut) +end + +function XUiGridNodeShopItem:SetItemSelect(isSelect) + if self.ImgSelect then + self.ImgSelect.gameObject:SetActiveEx(isSelect) + end +end + +-- function XUiGridNodeShopItem:OnBtnBuyClick() +-- if self.RootUi and self.ShopItemDatas then +-- if self.ShopItemDatas.BuyCount <= 0 then +-- XUiManager.TipMsg(CS.XTextManager.GetText("RogueLikeShopItemSellOut")) +-- return +-- end +-- self.RootUi:OpenBuyDetails(self.ShopItemDatas) +-- end +-- end +return XUiGridNodeShopItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenRogueLike/XUiGridRogueLikeCharacter.lua b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiGridRogueLikeCharacter.lua new file mode 100644 index 00000000..1a3718ff --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiGridRogueLikeCharacter.lua @@ -0,0 +1,166 @@ +local XUiGridRogueLikeCharacter = XClass(nil, "XUiGridRogueLikeCharacter") + +function XUiGridRogueLikeCharacter:Ctor(rootUi, ui, clickCallback, templateId, templateType) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.ClickCallback = clickCallback + self.RectTransform = ui:GetComponent("RectTransform") + self.TemplateId = templateId + self.TemplateType = templateType + self.IsCharacterType = self.TemplateType == XFubenRogueLikeConfig.SelectCharacterType.Character + + if self.IsCharacterType then + self.Template = XDataCenter.CharacterManager.GetCharacter(self.TemplateId) + else + self.Template = XRobotManager.GetRobotTemplate(self.TemplateId) + end + + XTool.InitUiObject(self) + + self.BtnCharacter.CallBack = function() self:OnBtnCharacterClick() end + if self.PanelStaminaBar then + self.PanelStaminaBar.gameObject:SetActive(false) + end + self:SetSelect(false) + self:SetInTeam(false) + + self:UpdateGrid(self.Template) +end + + +function XUiGridRogueLikeCharacter:OnBtnCharacterClick() + if self.ClickCallback then + + if self.IsCharacterType then + if XCharacterConfigs.IsCharacterForeShow(self.TemplateId) then + self.ClickCallback(self.Template) + else + XUiManager.TipMsg(CS.XTextManager.GetText("ComingSoon"), XUiManager.UiTipType.Tip) + end + + else + self.ClickCallback(self.Template) + end + end +end + +-- 做啥子用的? +function XUiGridRogueLikeCharacter:UpdateStamina(curStamina, maxStamina) + if self.PanelStaminaBar then + self.PanelStaminaBar.gameObject:SetActive(true) + end + self.ImgStaminaExpFill.fillAmount = curStamina / maxStamina +end + +function XUiGridRogueLikeCharacter:UpdateGrid(template) + if template then + self.Template = template + end + + if self.TxtLevel then + local level = self.IsCharacterType and self.Template.Level or self.Template.CharacterLevel + self.TxtLevel.text = level + end + + if self.RImgGrade then + if self.IsCharacterType then + self.RImgGrade:SetRawImage(XCharacterConfigs.GetCharGradeIcon(self.TemplateId, self.Template.Grade)) + else + self.RImgGrade:SetRawImage(XCharacterConfigs.GetCharGradeIcon(self.TemplateId, self.Template.CharacterGrade)) + end + end + + if self.RImgQuality then + local quality = self.IsCharacterType and self.Template.Quality or self.Template.CharacterQuality + self.RImgQuality:SetRawImage(XCharacterConfigs.GetCharacterQualityIcon(quality)) + end + + if self.RImgHeadIcon then + local characterId = self.IsCharacterType and self.Template.Id or self.Template.CharacterId + self.RImgHeadIcon:SetRawImage(XDataCenter.CharacterManager.GetCharSmallHeadIcon(characterId)) + end + + if self.TxtTradeName then + local characterId = self.IsCharacterType and self.Template.Id or self.Template.CharacterId + self.TxtTradeName.text = XCharacterConfigs.GetCharacterTradeName(characterId) + end + + if self.PanelFight then + self.PanelFight.gameObject:SetActiveEx(self.IsCharacterType) + local ability = self.IsCharacterType and math.floor(self.Template.Ability) or "" + self.TxtFight.text = ability + end + + if self.PanelCharElement then + local characterId = self.IsCharacterType and self.Template.Id or self.Template.CharacterId + local detailConfig = XCharacterConfigs.GetCharDetailTemplate(characterId) + local elementList = detailConfig.ObtainElementList + for i = 1, 3 do + local rImg = self["RImgCharElement" .. i] + if elementList[i] then + rImg.gameObject:SetActiveEx(true) + local elementConfig = XCharacterConfigs.GetCharElement(elementList[i]) + rImg:SetRawImage(elementConfig.Icon) + else + rImg.gameObject:SetActiveEx(false) + end + end + end + +end + +function XUiGridRogueLikeCharacter:OnCheckCharacterRedPoint(count) + if self.ImgRedPoint then + self.ImgRedPoint.gameObject:SetActive(count >= 0) + end +end + +function XUiGridRogueLikeCharacter:SetSelect(isSelect) + if self.ImgSelected then + self.ImgSelected.gameObject:SetActive(isSelect) + end +end + +function XUiGridRogueLikeCharacter:SetInTeam(isInTeam, inTeamText) + if self.ImgInTeam then + if isInTeam then + if inTeamText and self.TxtInTeam then + self.TxtInTeam.text = inTeamText + end + self.ImgInTeam.gameObject:SetActiveEx(true) + else + self.ImgInTeam.gameObject:SetActiveEx(false) + end + end +end + +function XUiGridRogueLikeCharacter:SetIsLock(isLock) + if self.ImgLock then + self.ImgLock.gameObject:SetActiveEx(isLock) + end +end + +function XUiGridRogueLikeCharacter:SetLimited(isLimited) + if self.ImgLimited then + self.ImgLimited.gameObject:SetActiveEx(isLimited) + end +end + +function XUiGridRogueLikeCharacter:SetArrowUp(isUp) + if self.PanelRogueLikeTheme then + self.PanelRogueLikeTheme.gameObject:SetActiveEx(isUp) + end +end + +function XUiGridRogueLikeCharacter:Reset() + self.GameObject:SetActive(false) + self:SetSelect(false) + self:SetInTeam(false) +end + +function XUiGridRogueLikeCharacter:SetPosition(x, y) + self.RectTransform.anchoredPosition = CS.UnityEngine.Vector2(x, y) +end + +return XUiGridRogueLikeCharacter \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenRogueLike/XUiGridRoleInfoItem.lua b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiGridRoleInfoItem.lua new file mode 100644 index 00000000..c144e18a --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiGridRoleInfoItem.lua @@ -0,0 +1,20 @@ +local XUiGridRoleInfoItem = XClass(nil, "XUiGridRoleInfoItem") + +function XUiGridRoleInfoItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) +end + +function XUiGridRoleInfoItem:SetRoleInfo(characterId) + self.RImgRoleIcon:SetRawImage(XDataCenter.CharacterManager.GetCharRoundnessHeadIcon(characterId)) + self.TxtName.text = XCharacterConfigs.GetCharacterFullNameStr(characterId) +end + +function XUiGridRoleInfoItem:SetRandomRoleInfo() + self.RImgRoleIcon:SetRawImage(XFubenRogueLikeConfig.UNKNOW_ROBOT) + self.TxtName.text = CS.XTextManager.GetText("RogueLikeRandomRobotTitle") +end + +return XUiGridRoleInfoItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenRogueLike/XUiGridTopicInfo.lua b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiGridTopicInfo.lua new file mode 100644 index 00000000..75a6369d --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiGridTopicInfo.lua @@ -0,0 +1,18 @@ +local XUiGridTopicInfo = XClass(nil, "XUiGridTopicInfo") + +function XUiGridTopicInfo:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + + XTool.InitUiObject(self) +end + +function XUiGridTopicInfo:SetTopicInfo(topic) + local buffTemplate = XFubenRogueLikeConfig.GetBuffConfigById(topic.BuffId) + self.TxtUnActive.text = buffTemplate.Description + self.TxtActive.text = buffTemplate.Description + self.PanelActive.gameObject:SetActiveEx(topic.IsActive) +end + +return XUiGridTopicInfo \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenRogueLike/XUiNodeShopBuyDetails.lua b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiNodeShopBuyDetails.lua new file mode 100644 index 00000000..76c90fd1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiNodeShopBuyDetails.lua @@ -0,0 +1,103 @@ +local XUiNodeShopBuyDetails = XClass(nil, "XUiNodeShopBuyDetails") +local XUiGridBuffInfoItem = require("XUi/XUiFubenRogueLike/XUiGridBuffInfoItem") +local XUiGridRoleInfoItem = require("XUi/XUiFubenRogueLike/XUiGridRoleInfoItem") + +function XUiNodeShopBuyDetails:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + + XTool.InitUiObject(self) + + self.BtnTanchuangClose.CallBack = function() self:CloseBlackShopDetails() end + self.BtnBlock.CallBack = function() self:CloseBlackShopDetails() end + + self.BtnAddSelect.CallBack = function() self:OnBtnAddSelectClick() end + self.BtnMinusSelect.CallBack = function() self:OnBtnMinusSelectClick() end + self.BtnUse.CallBack = function() self:OnBtnUseClick() end + + self.RoleItem = XUiGridRoleInfoItem.New(self.GridRole) + self.BuffItem = XUiGridBuffInfoItem.New(self.UiRoot, self.GridBuff) + self.ItemInfo = XUiGridCommon.New(self.UiRoot, self.GridBuyCommon) +end + +-- table.insert(self.BlackItemList, { +-- ShopItemId = shopItemId, +-- TotalBuyCount = buyCount, +-- BuyCount = buyCount - (self.BlackShopBuyItemInfos[shopItemId] or 0) +-- }) +function XUiNodeShopBuyDetails:ShowBlackShopDetails(shopItem, node) + self.ShopItemDatas = shopItem + self.Node = node + self.GameObject:SetActiveEx(true) + self.ShopItemTemplate = XFubenRogueLikeConfig.GetShopItemTemplateById(self.ShopItemDatas.ShopItemId) + self.TxtOwnCount.text = "" + if self.ShopItemTemplate.Type == XFubenRogueLikeConfig.XRLShopItemType.Buff then + self.BuffItem:SetBuffInfoById(self.ShopItemTemplate.Param[1]) + + elseif self.ShopItemTemplate.Type == XFubenRogueLikeConfig.XRLShopItemType.Item then + local itemId = self.ShopItemTemplate.Param[1] + self.ItemInfo:Refresh(itemId) + local itemCount = XDataCenter.ItemManager.GetCount(itemId) + self.TxtOwnCount.text = CS.XTextManager.GetText("CurrentlyHas", itemCount) + elseif self.ShopItemTemplate.Type == XFubenRogueLikeConfig.XRLShopItemType.Robot then + -- local robotId = self.ShopItemTemplate.Param[1] + --local characterId = XRobotManager.GetCharacterId(robotId) + self.RoleItem:SetRandomRoleInfo() + end + + self.BuffItem.GameObject:SetActiveEx(self.ShopItemTemplate.Type == XFubenRogueLikeConfig.XRLShopItemType.Buff) + self.ItemInfo.GameObject:SetActiveEx(self.ShopItemTemplate.Type == XFubenRogueLikeConfig.XRLShopItemType.Item) + self.RoleItem.GameObject:SetActiveEx(self.ShopItemTemplate.Type == XFubenRogueLikeConfig.XRLShopItemType.Robot) + + local item = XDataCenter.ItemManager.GetItem(self.ShopItemTemplate.ConsumeId[1]) + self.RImgCostIcon1:SetRawImage(item.Template.Icon) + self.TxtCanBuy.text = self.ShopItemDatas.BuyCount + local defaultNum = (self.ShopItemDatas.BuyCount <= 0) and 0 or 1 + self:UpdateSelectNum(defaultNum) +end + +function XUiNodeShopBuyDetails:UpdateSelectNum(num) + self.CurrentSelectNum = num + self.TxtSelect.text = self.CurrentSelectNum + self:UpdateCostCount() +end + +function XUiNodeShopBuyDetails:UpdateCostCount() + self.TxtCostCount1.text = math.ceil(self.ShopItemTemplate.ConsumeNum[1] * self.CurrentSelectNum * (self.ShopItemDatas.Discount / 100)) +end + +function XUiNodeShopBuyDetails:UpdateCostCountByDiscount(discount) + if self.ShopItemTemplate and self.CurrentSelectNum then + self.TxtCostCount1.text = math.ceil(self.ShopItemTemplate.ConsumeNum[1] * self.CurrentSelectNum * (discount / 100)) + end +end + +function XUiNodeShopBuyDetails:CloseBlackShopDetails() + self.GameObject:SetActiveEx(false) +end + +function XUiNodeShopBuyDetails:OnBtnAddSelectClick() + if self.ShopItemDatas and self.CurrentSelectNum + 1 <= self.ShopItemDatas.BuyCount then + self:UpdateSelectNum(self.CurrentSelectNum + 1) + end +end + +function XUiNodeShopBuyDetails:OnBtnMinusSelectClick() + if self.CurrentSelectNum - 1 > 0 then + self:UpdateSelectNum(self.CurrentSelectNum - 1) + end +end + +function XUiNodeShopBuyDetails:OnBtnUseClick() + if self.Node and self.ShopItemDatas and self.CurrentSelectNum > 0 then + XDataCenter.FubenRogueLikeManager.NodeBuy(self.Node.Id, self.ShopItemDatas.ShopItemId, self.CurrentSelectNum, function() + self:CloseBlackShopDetails() + -- 弹获得东西的页面 + -- 更新商品界面 + self.UiRoot:RefreshShopItems() + end) + end +end + +return XUiNodeShopBuyDetails \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeBoxEntrance.lua b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeBoxEntrance.lua new file mode 100644 index 00000000..d7306728 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeBoxEntrance.lua @@ -0,0 +1,31 @@ +local XUiRogueLikeBoxEntrance = XClass(nil, "XUiRogueLikeBoxEntrance") + +function XUiRogueLikeBoxEntrance:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + + XTool.InitUiObject(self) + self.BtnOpen.CallBack = function() self:OnBtnOpenClick() end +end + +function XUiRogueLikeBoxEntrance:UpdateByNode(node, eventNode) + self.Node = node + self.EventNode = (eventNode == nil) and node or eventNode + self.NodeTemplate = XFubenRogueLikeConfig.GetNodeTemplateById(self.EventNode.Id) + self.NodeConfig = XFubenRogueLikeConfig.GetNodeConfigteById(self.EventNode.Id) + + self.TxtName.text = self.NodeConfig.Name + self.RImgIcon:SetRawImage(self.NodeConfig.Icon) + self.TxtRest.text = self.NodeConfig.Description + +end + +function XUiRogueLikeBoxEntrance:OnBtnOpenClick() + XDataCenter.FubenRogueLikeManager.OpenBox(self.Node.Id, self.EventNode, function() + -- 刷新操作 + self.UiRoot:Close() + end) +end + +return XUiRogueLikeBoxEntrance \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeBuffStrengthen.lua b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeBuffStrengthen.lua new file mode 100644 index 00000000..af4c5184 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeBuffStrengthen.lua @@ -0,0 +1,164 @@ +local XUiRogueLikeBuffStrengthen = XLuaUiManager.Register(XLuaUi, "UiRogueLikeBuffStrengthen") +local XUiGridBuffDetailItem = require("XUi/XUiFubenRogueLike/XUiGridBuffDetailItem") + +function XUiRogueLikeBuffStrengthen:OnAwake() + self.BtnClose.CallBack = function() self:OnBtnCloseClick() end + self.BtnTanchuangClose.CallBack = function() self:OnBtnTanchuangCloseClick() end + self.BtnCancel.CallBack = function() self:OnBtnCancelClick() end + self.BtnConfirm.CallBack = function() self:OnBtnConfirmClick() end + + self.RogueLikeActivityAsset = XUiPanelAsset.New(self, self.PanelActivityAsset, XFubenRogueLikeConfig.ChallengeCoin, XFubenRogueLikeConfig.PumpkinCoin, XFubenRogueLikeConfig.KeepsakeCoin) + + self.BtnLvUpClose.CallBack = function() self:OnBtnLvUpCloseClick() end + self.DynamicTable = XDynamicTableNormal.New(self.PanelSelectList.gameObject) + self.DynamicTable:SetProxy(XUiGridBuffDetailItem) + self.DynamicTable:SetDelegate(self) + + self.TxtBuy.gameObject:SetActiveEx(false) +end + +--动态列表事件 +function XUiRogueLikeBuffStrengthen:OnDynamicTableEvent(event, index, grid) + + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.Buffs[index] + if not data then + return + end + grid.RootUi = self + grid:SetBuffInfo(data) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + for i = 1, #self.Buffs do + self.Buffs[i].IsSelect = index == i + local lastGrid = self.DynamicTable:GetGridByIndex(i) + if lastGrid then + lastGrid:SetSelected(index == i) + end + end + self.CurrentIndex = index + self:UpdateConstSupportPoint() + end + +end + +function XUiRogueLikeBuffStrengthen:UpdateConstSupportPoint() + if not self.CurrentIndex then + self.TxtBuy.gameObject:SetActiveEx(false) + return + end + local data = self.Buffs[self.CurrentIndex] + local constId = XFubenRogueLikeConfig.GetBuffConstItemIdById(data.BuffId) + local itemCount = XDataCenter.ItemManager.GetCount(constId) + local constCount = XFubenRogueLikeConfig.GetBuffConstItemCountById(data.BuffId) + if not constId or constId == 0 or not constCount or constCount == 0 then + self.TxtBuy.gameObject:SetActiveEx(false) + else + self.TxtBuy.gameObject:SetActiveEx(true) + if itemCount < constCount then + self.TxtBuy.text = string.format("%s",constCount) + else + self.TxtBuy.text = constCount + end + + self.RImgMoney:SetRawImage(XItemConfigs.GetItemIconById(constId)) + end +end + +function XUiRogueLikeBuffStrengthen:OnStart(node) + self.Node = node + local myBuffs = XDataCenter.FubenRogueLikeManager.GetMyBuffs() + self.Buffs = {} + for _, v in pairs(myBuffs) do + if not XFubenRogueLikeConfig.IsBuffMaxLevel(v.BuffId) then + table.insert(self.Buffs, v) + end + end + + self.DynamicTable:SetDataSource(self.Buffs) + self.DynamicTable:ReloadDataASync() + self.ImgEmpty.gameObject:SetActiveEx(#self.Buffs <= 0) + + XEventManager.AddEventListener(XEventId.EVENT_ROGUELIKE_BUFFIDS_CHANGES, self.UpdateBuffList, self) +end + + +function XUiRogueLikeBuffStrengthen:OnDestroy() + XEventManager.RemoveEventListener(XEventId.EVENT_ROGUELIKE_BUFFIDS_CHANGES, self.UpdateBuffList, self) +end + +function XUiRogueLikeBuffStrengthen:UpdateBuffList() + local myBuffs = XDataCenter.FubenRogueLikeManager.GetMyBuffs() + self.Buffs = {} + for _, v in pairs(myBuffs) do + if not XFubenRogueLikeConfig.IsBuffMaxLevel(v.BuffId) then + table.insert(self.Buffs, v) + end + end + + self.DynamicTable:SetDataSource(self.Buffs) + self.DynamicTable:ReloadDataASync() + self.ImgEmpty.gameObject:SetActiveEx(#self.Buffs <= 0) + + self.CurrentIndex = nil + self:UpdateConstSupportPoint() +end + +function XUiRogueLikeBuffStrengthen:OnBtnCloseClick() + self:Close() +end + +function XUiRogueLikeBuffStrengthen:OnBtnTanchuangCloseClick() + self:Close() +end + +function XUiRogueLikeBuffStrengthen:OnBtnCancelClick() + self:Close() +end + +function XUiRogueLikeBuffStrengthen:OnBtnConfirmClick() + if not self.CurrentIndex then + XUiManager.TipMsg(CS.XTextManager.GetText("RogueLikeSelectABuff")) + return + end + if self.Node and self.CurrentIndex then + local data = self.Buffs[self.CurrentIndex] + XDataCenter.FubenRogueLikeManager.IntensifyBuff(self.Node.Id, data.BuffId, function() + -- 刷新,弹窗 + self:ShowBuffLevelUp(data.BuffId) + end) + end +end + +function XUiRogueLikeBuffStrengthen:ShowBuffLevelUp(buffId) + local buffTemplate = XFubenRogueLikeConfig.GetBuffTemplateById(buffId) + local intensifyTemplate = XFubenRogueLikeConfig.GetBuffTemplateById(buffTemplate.IntensifyId) + local buffConfig = XFubenRogueLikeConfig.GetBuffConfigById(buffId) + local intensifyConfig = XFubenRogueLikeConfig.GetBuffConfigById(buffTemplate.IntensifyId) + + if not intensifyTemplate then + XLog.ErrorTableDataNotFound("XFubenRogueLikeConfig.GetBuffConfigById", + "RogueLikeBuffDetails", "Client/Fuben/RogueLike/RogueLikeBuffDetails.tab", "Id", tostring(buffId)) + self:OnBtnLvUpCloseClick() + return + end + + self:PlayAnimation("PanelBuffLvUpEnable", function() + XLuaUiManager.SetMask(false) + end, + function() + XLuaUiManager.SetMask(true) + end) + + self.RImgLeftBuffIcon:SetRawImage(buffConfig.Icon) + self.TxtLeftBuffDetails.text = buffConfig.Description + self.RImgRightBuffIcon:SetRawImage(intensifyConfig.Icon) + self.TxtRightBuffDetails.text = intensifyConfig.Description + self.PanelBuffLvUp.gameObject:SetActiveEx(true) + + +end + +function XUiRogueLikeBuffStrengthen:OnBtnLvUpCloseClick() + self.PanelBuffLvUp.gameObject:SetActiveEx(false) + --self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeCharItem.lua b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeCharItem.lua new file mode 100644 index 00000000..3b7d0af9 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeCharItem.lua @@ -0,0 +1,70 @@ +local XUiRogueLikeCharItem = XClass(nil, "XUiRogueLikeCharItem") + +function XUiRogueLikeCharItem:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + + XTool.InitUiObject(self) +end + +function XUiRogueLikeCharItem:UpdateCharacterInfos(charInfo) + self.CharacterInfo = charInfo + if not self.CharacterInfo then + self:Reset() + return + end + self.RImgRoleHead.gameObject:SetActiveEx(true) + self.Locked.gameObject:SetActiveEx(true) + self.RImgRoleHead:SetRawImage(XDataCenter.CharacterManager.GetCharRoundnessHeadIcon(self.CharacterInfo.Id)) + self.Slider.value = self.CharacterInfo.HpLeft * 1.0 / 100 + + self:SetTxtBlood(string.format("%s%%", tostring(self.CharacterInfo.HpLeft))) + self:SetIconUp(XDataCenter.FubenRogueLikeManager.IsTeamEffectCharacter(self.CharacterInfo.Id)) + + if charInfo.EffectUp and self.PanelEffect then + if self.PanelEffect.gameObject.activeSelf then + self.PanelEffect.gameObject:SetActiveEx(false) + end + self.PanelEffect.gameObject:SetActiveEx(true) + + charInfo.EffectUp = false + end + self:CheckEffectNull() +end + +function XUiRogueLikeCharItem:CheckEffectNull() + if self.PanelEffectNull then + local characters = XDataCenter.FubenRogueLikeManager.GetCharacterInfos() + self.PanelEffectNull.gameObject:SetActiveEx(#characters <= 0) + end +end + +function XUiRogueLikeCharItem:StopFx() + if self.PanelEffect then + self.PanelEffect.gameObject:SetActiveEx(false) + end +end + +function XUiRogueLikeCharItem:Reset() + self.RImgRoleHead.gameObject:SetActiveEx(false) + self.Locked.gameObject:SetActiveEx(false) + self.Slider.value = 0 + self:SetTxtBlood("") + self:SetIconUp(false) + self:CheckEffectNull() +end + +function XUiRogueLikeCharItem:SetTxtBlood(blood) + if self.TxtBlood then + self.TxtBlood.text = blood + end +end + +function XUiRogueLikeCharItem:SetIconUp(isUp) + if self.IconUp then + self.IconUp.gameObject:SetActiveEx(isUp) + end +end + +return XUiRogueLikeCharItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeClearance.lua b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeClearance.lua new file mode 100644 index 00000000..9765a715 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeClearance.lua @@ -0,0 +1,44 @@ +local XUiRogueLikeClearance = XLuaUiManager.Register(XLuaUi, "UiRogueLikeClearance") +local XUiRogueLikeClearanceScoreItem = require("XUi/XUiFubenRogueLike/XUiRogueLikeClearanceScoreItem") +function XUiRogueLikeClearance:OnAwake() + + self.BtnClose.CallBack = function() self:Close() end + self.BtnTanchuangClose.CallBack = function() self:Close() end + + self.DynamicTable = XDynamicTableNormal.New(self.PanelDynamicTable) + self.DynamicTable:SetProxy(XUiRogueLikeClearanceScoreItem) + self.DynamicTable:SetDelegate(self) + + self.ScoreItem.gameObject:SetActiveEx(false) +end + +function XUiRogueLikeClearance:OnStart(rootUi) + self.RootUi = rootUi + +end + +function XUiRogueLikeClearance:OnEnable() + XDataCenter.FubenRogueLikeManager.SetNeedShowTrialPointView(false) + self:InitDynamicTable() +end + +function XUiRogueLikeClearance:InitDynamicTable() + self.ScoreDatas = XDataCenter.FubenRogueLikeManager.GetRogueLikeTrialPointDatas() + local scoreTatol = 0 + for _, data in ipairs(self.ScoreDatas) do + scoreTatol = scoreTatol + data.Point + end + self.TextFraction.text = scoreTatol + self.DynamicTable:SetDataSource(self.ScoreDatas) + self.DynamicTable:ReloadDataASync(-1) +end + +--动态列表事件 +function XUiRogueLikeClearance:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init() + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.ScoreDatas[index] + grid:UpdateViewByData(data) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeClearanceScoreItem.lua b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeClearanceScoreItem.lua new file mode 100644 index 00000000..14198a39 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeClearanceScoreItem.lua @@ -0,0 +1,19 @@ +local XUiRogueLikeClearanceScoreItem = XClass(nil, "XUiRogueLikeClearanceScoreItem") + +function XUiRogueLikeClearanceScoreItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiRogueLikeClearanceScoreItem:Init() + self.GameObject:SetActiveEx(true) +end + +function XUiRogueLikeClearanceScoreItem:UpdateViewByData(data) + self.TextValue.text = data.Point + self.TextTitle.text = XFubenRogueLikeConfig.GetRogueLikePurgatoryScoreTitleByType(data.PointType) + self.TextDesc.text = XFubenRogueLikeConfig.GetRogueLikePurgatoryScoreDescriptionByType(data.PointType) +end + +return XUiRogueLikeClearanceScoreItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeFightEntrance.lua b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeFightEntrance.lua new file mode 100644 index 00000000..e4db2729 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeFightEntrance.lua @@ -0,0 +1,128 @@ +local XUiRogueLikeFightEntrance = XClass(nil, "XUiRogueLikeFightEntrance") +local STAR_LENGTH = 3 + +function XUiRogueLikeFightEntrance:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + + XTool.InitUiObject(self) + self.BtnFightNormal.CallBack = function() self:OnBtnFightNormalClick() end + self.BtnFightHard.CallBack = function() self:OnBtnFightHardClick() end + self.GridList = {} + self.StarList = {} + self.StarGridList = {} + for i = 1, STAR_LENGTH do + self.StarList[i] = self[string.format("TxtStarActive%d", i)] + self.StarGridList[i] = self[string.format("GridStageStar%d", i)] + end +end + +function XUiRogueLikeFightEntrance:UpdateByNode(node, eventNode) + self.Node = node + self.EventNode = (eventNode == nil) and node or eventNode + self.NodeTemplate = XFubenRogueLikeConfig.GetNodeTemplateById(self.EventNode.Id) + self.NodeConfig = XFubenRogueLikeConfig.GetNodeConfigteById(self.EventNode.Id) + + self.NormalStageId = self.NodeTemplate.Param[1] + self.HardStageId = self.NodeTemplate.Param[2] + + local stageCfg = XDataCenter.FubenManager.GetStageCfg(self.NormalStageId) + + self.TxtName.text = self.NodeConfig.Name + self.RImgIcon:SetRawImage(self.NodeConfig.Icon) + self.TxtTarget.text = self.NodeConfig.Description + + self.RImgFightCost:SetRawImage(XDataCenter.ItemManager.GetItemIcon(XDataCenter.ItemManager.ItemId.ActionPoint)) + local requireNum = stageCfg.RequireActionPoint + local ownNum = XDataCenter.ItemManager.GetCount(XDataCenter.ItemManager.ItemId.ActionPoint) + local color = (requireNum > ownNum) and "#FF0000" or "#0E70BD" + self.TxtOwn.text = string.format("%d/", ownNum) + self.TxtConsumeAmount.text = string.format("%d", color, requireNum) + + self.BtnFightHard.gameObject:SetActiveEx(self.HardStageId ~= nil and self.HardStageId > 0) + + self:UpdateNodeReward(stageCfg) + for i = 1, STAR_LENGTH do + local starDesc = (stageCfg.StarDesc[i] == nil) and "" or stageCfg.StarDesc[i] + self.StarList[i].text = starDesc + self.StarGridList[i].gameObject:SetActiveEx(starDesc ~= "") + end +end + +function XUiRogueLikeFightEntrance:UpdateNodeReward(stageCfg) + local rewardId = 0 + local controlCfg = XDataCenter.FubenManager.GetStageLevelControl(stageCfg.NormalStageId) + if controlCfg and controlCfg.FinishRewardShow > 0 then + rewardId = controlCfg.FinishRewardShow + elseif stageCfg.FinishRewardShow > 0 then + rewardId = stageCfg.FinishRewardShow + end + local rewards = {} + if rewardId > 0 then + rewards = XRewardManager.GetRewardList(rewardId) + end + + if rewards then + for i, item in ipairs(rewards) do + local grid + if self.GridList[i] then + grid = self.GridList[i] + else + local ui = CS.UnityEngine.Object.Instantiate(self.Grid128) + grid = XUiGridCommon.New(self.UiRoot, ui) + grid.Transform:SetParent(self.PanelReward, false) + self.GridList[i] = grid + end + grid:Refresh(item) + grid:ShowCount(false) + grid.GameObject:SetActive(true) + end + end + + local rewardsCount = 0 + if rewards then + rewardsCount = #rewards + end + + for j = 1, #self.GridList do + if j > rewardsCount then + self.GridList[j].GameObject:SetActive(false) + end + end +end + +function XUiRogueLikeFightEntrance:OnBtnFightNormalClick() + self:OnFightClick(self.NormalStageId) +end + +function XUiRogueLikeFightEntrance:OnBtnFightHardClick() + self:OnFightClick(self.HardStageId) +end + +function XUiRogueLikeFightEntrance:OnFightClick(stageId) + if not stageId or stageId <= 0 or not self.Node then return end + -- 行动点是否足够 + local actionPoint = XDataCenter.FubenRogueLikeManager.GetRogueLikeActionPoint() + + local assistRobots = XDataCenter.FubenRogueLikeManager.GetAssistRobots() + local hasAssist = #assistRobots >= XDataCenter.FubenRogueLikeManager.GetTeamMemberCount() + + if false and actionPoint <= 0 and not hasAssist then + XUiManager.TipMsg(CS.XTextManager.GetText("RogueLikeNotEnoughActionPoint")) + return + end + + -- 是否在挑战时间内 + if not XDataCenter.FubenRogueLikeManager.IsInFight() then + XUiManager.TipMsg(CS.XTextManager.GetText("RogueLikeNotInActivityFightTime")) + return + end + + self.UiRoot:Close() + local data = {NodeId = self.Node.Id} + XLuaUiManager.Open("UiNewRoomSingle", stageId, data) +end + + +return XUiRogueLikeFightEntrance \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeFightTips.lua b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeFightTips.lua new file mode 100644 index 00000000..d5820850 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeFightTips.lua @@ -0,0 +1,167 @@ +local XUiRogueLikeFightTips = XLuaUiManager.Register(XLuaUi, "UiRogueLikeFightTips") + +local XUiRogueLikeFightEntrance = require("XUi/XUiFubenRogueLike/XUiRogueLikeFightEntrance") +local XUiRogueLikeStoryEntrance = require("XUi/XUiFubenRogueLike/XUiRogueLikeStoryEntrance") +local XUiRogueLikeRestEntrance = require("XUi/XUiFubenRogueLike/XUiRogueLikeRestEntrance") +local XUiRogueLikeShopEntrance = require("XUi/XUiFubenRogueLike/XUiRogueLikeShopEntrance") +local XUiRogueLikeBoxEntrance = require("XUi/XUiFubenRogueLike/XUiRogueLikeBoxEntrance") + +-- 重新计算位置间隔 +local FRAME_GAP = 10 + + +function XUiRogueLikeFightTips:OnAwake() + + self.EntranceFight = XUiRogueLikeFightEntrance.New(self.PanelEnterFight, self) + self.EntranceStory = XUiRogueLikeStoryEntrance.New(self.PanelStory, self) + self.EntranceRest = XUiRogueLikeRestEntrance.New(self.PanelRest, self) + self.EntranceShop = XUiRogueLikeShopEntrance.New(self.PanelShop, self) + self.EntranceBox = XUiRogueLikeBoxEntrance.New(self.PanelBaoxiang, self) + + self.BtnCloseMask.CallBack = function() self:OnBtnCloseMask() end + + local behaviour = self.GameObject:GetComponent(typeof(CS.XLuaBehaviour)) + if not behaviour then + behaviour = self.GameObject:AddComponent(typeof(CS.XLuaBehaviour)) + end + if self.Update then + behaviour.LuaUpdate = function() self:Update() end + end +end + +function XUiRogueLikeFightTips:Update() + + if self.FrameCount % FRAME_GAP ~= 0 then return end + + local nodePosition = self.GetNodePosition and self.GetNodePosition() or CS.UnityEngine.Vector3.zero + if XFubenRogueLikeConfig.XRLNodeType.Fight == self.NodeType then + self.EntranceFight.Transform.position = nodePosition + end + + if XFubenRogueLikeConfig.XRLNodeType.Event == self.NodeType then + self.EntranceStory.Transform.position = nodePosition + end + + if XFubenRogueLikeConfig.XRLNodeType.Rest == self.NodeType then + self.EntranceRest.Transform.position = nodePosition + end + + if XFubenRogueLikeConfig.XRLNodeType.Shop == self.NodeType then + self.EntranceShop.Transform.position = nodePosition + end + + if XFubenRogueLikeConfig.XRLNodeType.Box == self.NodeType then + self.EntranceBox.Transform.position = nodePosition + end +end + +function XUiRogueLikeFightTips:OnStart(args, get_node_position) + self.Args = args + self.GetNodePosition = get_node_position + self.FrameCount = 0 + self.NodeInfo = self.Args.NodeInfo + local nodeId = self.NodeInfo.NodeId + self.NodeTemplate = XFubenRogueLikeConfig.GetNodeTemplateById(nodeId) + self.NodeType = self.NodeTemplate.Type + + local isStoryType = XFubenRogueLikeConfig.XRLNodeType.Event == self.NodeType + if isStoryType then + local sectionInfo = XDataCenter.FubenRogueLikeManager.GetCurSectionInfo() + local selectionNode = sectionInfo.SelectNodeInfo[nodeId] + local eventTemplate = XFubenRogueLikeConfig.GetEventTemplateById(selectionNode.EventId) + if eventTemplate.Type == XFubenRogueLikeConfig.XRLEventType.Other then + self.NodeType = XFubenRogueLikeConfig.XRLNodeType.Event + else + local selectNodeInfo = sectionInfo.SelectNodeInfo[nodeId] + local targetNodeId = selectNodeInfo.Value + self.EventNodeTemplate = XFubenRogueLikeConfig.GetNodeTemplateById(targetNodeId) + self.NodeType = self.EventNodeTemplate.Type + end + end + + self:ShowFightEntrance() + self:ShowRestEntrance() + self:ShowShopEntrance() + self:ShowBoxEntrance() + self:ShowStoryEntrance() +end + +function XUiRogueLikeFightTips:OnEnable() + XDataCenter.FubenRogueLikeManager.CheckRogueLikeDayResetOnUi("UiRogueLikeFightTips") +end + +function XUiRogueLikeFightTips:OnDisable() + XEventManager.DispatchEvent(XEventId.EVENT_ROGUELIKE_NODE_ADJUSTION) +end + +function XUiRogueLikeFightTips:ShowFightEntrance() + local isFightType = XFubenRogueLikeConfig.XRLNodeType.Fight == self.NodeType + self.EntranceFight.GameObject:SetActiveEx(isFightType) + if isFightType then + self.EntranceFight:UpdateByNode(self.NodeTemplate, self.EventNodeTemplate, self.NodeInfo.Index) + self:PlaySaftyAnimation("PanelEnterFightEnable") + + end +end + +function XUiRogueLikeFightTips:ShowStoryEntrance() + local isStoryType = XFubenRogueLikeConfig.XRLNodeType.Event == self.NodeType + self.EntranceStory.GameObject:SetActiveEx(isStoryType) + if isStoryType then + self.EntranceStory:UpdateByNode(self.NodeTemplate) + self:PlaySaftyAnimation("PanelStoryEnable") + + end +end + +function XUiRogueLikeFightTips:ShowRestEntrance() + local isRestType = XFubenRogueLikeConfig.XRLNodeType.Rest == self.NodeType + self.EntranceRest.GameObject:SetActiveEx(isRestType) + if isRestType then + self.EntranceRest:UpdateByNode(self.NodeTemplate, self.EventNodeTemplate) + self:PlaySaftyAnimation("PanelRestEnable") + + end +end + +function XUiRogueLikeFightTips:ShowShopEntrance() + local isShopType = XFubenRogueLikeConfig.XRLNodeType.Shop == self.NodeType + self.EntranceShop.GameObject:SetActiveEx(isShopType) + if isShopType then + self.EntranceShop:UpdateByNode(self.NodeTemplate, self.EventNodeTemplate) + self:PlaySaftyAnimation("PanelShopEnable") + + end +end + +function XUiRogueLikeFightTips:ShowBoxEntrance() + local isBoxType = XFubenRogueLikeConfig.XRLNodeType.Box == self.NodeType + self.EntranceBox.GameObject:SetActiveEx(isBoxType) + if isBoxType then + self.EntranceBox:UpdateByNode(self.NodeTemplate, self.EventNodeTemplate) + self:PlaySaftyAnimation("PanelBaoxiangEnable") + end +end + +function XUiRogueLikeFightTips:OnBtnCloseMask() + self:Close() +end + +function XUiRogueLikeFightTips:PlaySaftyAnimation(animName, endCb, startCb) + self:PlayAnimation(animName, function() + if endCb then + endCb() + end + XLuaUiManager.SetMask(false) + end, + function() + if startCb then + startCb() + end + XLuaUiManager.SetMask(true) + end) +end + +function XUiRogueLikeFightTips:OnDestroy() + +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeHelpRole.lua b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeHelpRole.lua new file mode 100644 index 00000000..454ef12f --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeHelpRole.lua @@ -0,0 +1,61 @@ +local XUiRogueLikeHelpRole = XLuaUiManager.Register(XLuaUi, "UiRogueLikeHelpRole") +local XUiGridHelpRoleItem = require("XUi/XUiFubenRogueLike/XUiGridHelpRoleItem") + +function XUiRogueLikeHelpRole:OnAwake() + self.BtnClose.CallBack = function() self:OnBtnCloseClick() end + self.BtnTanchuangClose.CallBack = function() self:OnBtnCloseClick() end + self.HelpRoleList = {} +end + +function XUiRogueLikeHelpRole:OnDestroy() + +end + +function XUiRogueLikeHelpRole:OnEnable() + XDataCenter.FubenRogueLikeManager.CheckRogueLikeDayResetOnUi("UiRogueLikeHelpRole") +end + +function XUiRogueLikeHelpRole:OnDisable() + XDataCenter.FubenRogueLikeManager.ResetNewRobots() + XEventManager.DispatchEvent(XEventId.EVENT_ROGUELIKE_ASSISTROBOT_CHANGED) +end + +function XUiRogueLikeHelpRole:OnStart() + local assistRobots = XDataCenter.FubenRogueLikeManager.GetAssistRobots() + self.TxtHavet.text = #assistRobots + self.TxtTotal.text = string.format("/%d", XDataCenter.FubenRogueLikeManager.GetMaxRobotCount()) + self.SortedAssistRobots = {} + local index = 0 + for _, v in pairs(assistRobots) do + index = index + 1 + table.insert(self.SortedAssistRobots, { + RobotId = v.Id, + Priority = index, + IsNew = XDataCenter.FubenRogueLikeManager.IsRobotNew(v) and 1 or 0 + }) + end + table.sort(self.SortedAssistRobots, function(robotA, robotB) + if robotA.IsNew == robotB.IsNew then + return robotA.Priority < robotB.Priority + end + return robotA.IsNew > robotB.IsNew + end) + + for i = 1, #self.SortedAssistRobots do + local robotId = self.SortedAssistRobots[i].RobotId + if not self.HelpRoleList[i] then + local ui = CS.UnityEngine.Object.Instantiate(self.HelpRole.gameObject) + ui.transform:SetParent(self.PanelHelpHead, false) + self.HelpRoleList[i] = XUiGridHelpRoleItem.New(ui, self) + end + self.HelpRoleList[i].GameObject:SetActiveEx(true) + self.HelpRoleList[i]:UpdateHelpRoleInfo(robotId) + end + for i = #self.SortedAssistRobots + 1, #self.HelpRoleList do + self.HelpRoleList[i].GameObject:SetActiveEx(false) + end +end + +function XUiRogueLikeHelpRole:OnBtnCloseClick() + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeIllegalShop.lua b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeIllegalShop.lua new file mode 100644 index 00000000..1bcb45ed --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeIllegalShop.lua @@ -0,0 +1,271 @@ +local XUiRogueLikeIllegalShop = XLuaUiManager.Register(XLuaUi, "UiRogueLikeIllegalShop") +local XUiGridBlackShopItem = require("XUi/XUiFubenRogueLike/XUiGridBlackShopItem") +local XUiBlackShopBuyDetails = require("XUi/XUiFubenRogueLike/XUiBlackShopBuyDetails") +local XUiShopSpecialTool = require("XUi/XUiFubenRogueLike/XUiShopSpecialTool") + +function XUiRogueLikeIllegalShop:OnAwake() + self.BtnClose.CallBack = function() self:OnBtnCloseClick() end + self.BtnTanchuangClose.CallBack = function() self:OnBtnTanchuangClose() end + self.BtnBuy.CallBack = function() self:OnBtnBuyClick() end + + self.BlackShopBuyDetails = XUiBlackShopBuyDetails.New(self.PanelShopItem, self) + self.DynamicTable = XDynamicTableNormal.New(self.PanelItemList.gameObject) + self.DynamicTable:SetProxy(XUiGridBlackShopItem) + self.DynamicTable:SetDelegate(self) + + -- 支援终端发送事件 + self.SpecialToolList = {} + XEventManager.AddEventListener(XEventId.EVENT_ROGUELIKE_ILLEGAL_SHOP_RESET, self.ResetShop, self) +end + +function XUiRogueLikeIllegalShop:OnDestroy() + XEventManager.RemoveEventListener(XEventId.EVENT_ROGUELIKE_ILLEGAL_SHOP_RESET, self.ResetShop, self) +end + +function XUiRogueLikeIllegalShop:ResetShop() + if XLuaUiManager.IsUiShow("UiRogueLikeIllegalShop") then + XLuaUiManager.Close("UiRogueLikeIllegalShop") + end +end + +--动态列表事件 +function XUiRogueLikeIllegalShop:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.BlackItemList[index] + if not data then + return + end + grid.RootUi = self + grid:SetItemData(data) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + for i = 1, #self.BlackItemList do + local data = self.BlackItemList[i] + data.IsSelect = i == index + local lastGrid = self.DynamicTable:GetGridByIndex(i) + if lastGrid then + lastGrid:SetItemSelect(data.IsSelect) + end + end + self.CurrentSelectIndex = index + self:UpdateBuyShopItemInfo() + end +end + +function XUiRogueLikeIllegalShop:OnStart() + self:RefreshShopItems() + self:StartCountDown() +end + +function XUiRogueLikeIllegalShop:OnEnable() + XDataCenter.FubenRogueLikeManager.CheckRogueLikeDayResetOnUi("UiRogueLikeIllegalShop") +end + +function XUiRogueLikeIllegalShop:RefreshShopItems() + + local supportInfos = XDataCenter.FubenRogueLikeManager.GetSupportInfos() + local allSupports = XFubenRogueLikeConfig.GetAllSupports() + self.BlackItemList = {} + + for _, v in pairs(allSupports or {}) do + local totalBuyCount = v.Count + local canBuyCount = totalBuyCount - (supportInfos[v.Id] or 0) + canBuyCount = (canBuyCount > 0) and canBuyCount or 0 + table.insert(self.BlackItemList, { + SupportId = v.Id, + TotalBuyCount = totalBuyCount, + BuyCount = canBuyCount, + IsSelect = false, + }) + end + + table.sort(self.BlackItemList, function(itemA, itemB) + if itemA.BuyCount == itemB.BuyCount then + return itemA.SupportId < itemB.SupportId + end + return itemA.BuyCount > itemB.BuyCount + end) + + self.DynamicTable:SetDataSource(self.BlackItemList) + self.DynamicTable:ReloadDataASync() + self.ImgEmpty.gameObject:SetActiveEx(#self.BlackItemList <= 0) + self:InitChallengeCoin() + self.PanelBuy.gameObject:SetActiveEx(false) +end + +function XUiRogueLikeIllegalShop:InitChallengeCoin() + local hasActionPoint + local noneActionList = {} + for _, v in pairs(self.BlackItemList) do + local supportTemplate = XFubenRogueLikeConfig.GetSupportStationTemplateById(v.SupportId) + if supportTemplate.NeedPoint == 0 then + local specialEventId = supportTemplate.SpecialEvent + local specialEventTemplate = XFubenRogueLikeConfig.GetSpecialEventTemplateById(specialEventId) + if specialEventTemplate then + local shopItemTemplate = XFubenRogueLikeConfig.GetShopItemTemplateById(specialEventTemplate.Param[1]) + if shopItemTemplate then + local itemId = shopItemTemplate.ConsumeId[1] + table.insert(noneActionList, { + ItemId = itemId, + IsActionPoint = false, + }) + end + end + else + hasActionPoint = true + end + end + if hasActionPoint then + table.insert(noneActionList, { + IsActionPoint = true + }) + end + + for i = 1, #noneActionList do + if not self.SpecialToolList[i] then + local ui = CS.UnityEngine.Object.Instantiate(self.PanelSpecialTool.gameObject) + ui.transform:SetParent(self.PanelSpecialToolContent, false) + self.SpecialToolList[i] = XUiShopSpecialTool.New(ui, self) + end + if noneActionList[i].IsActionPoint then + local ownActionPoint = XDataCenter.FubenRogueLikeManager.GetRogueLikeActionPoint() + self.SpecialToolList[i]:SetSpecialToolNum(ownActionPoint) + else + self.SpecialToolList[i]:SetSpecialTool(noneActionList[i].ItemId) + end + self.SpecialToolList[i].GameObject:SetActiveEx(true) + end + + for i = #noneActionList + 1, #self.SpecialToolList do + self.SpecialToolList[i].GameObject:SetActiveEx(false) + end +end + +function XUiRogueLikeIllegalShop:OnDestroy() + self:StopCountDown() +end + +-- 打开购买详情 +function XUiRogueLikeIllegalShop:OpenBuyDetails(shopItem) + self.BlackShopBuyDetails:ShowBlackShopDetails(shopItem) +end + +-- 购买信息 +function XUiRogueLikeIllegalShop:UpdateBuyShopItemInfo() + if self.CurrentSelectIndex and self.BlackItemList and self.BlackItemList[self.CurrentSelectIndex] then + self.PanelBuy.gameObject:SetActiveEx(true) + local shopItem = self.BlackItemList[self.CurrentSelectIndex] + local supportTemplate = XFubenRogueLikeConfig.GetSupportStationTemplateById(shopItem.SupportId) + local supportConfig = XFubenRogueLikeConfig.GetSupportStationConfigById(shopItem.SupportId) + if supportTemplate.NeedPoint == 0 then + local specialEventId = supportTemplate.SpecialEvent + local specialEventTemplate = XFubenRogueLikeConfig.GetSpecialEventTemplateById(specialEventId) + if specialEventTemplate then + local shopItemId = specialEventTemplate.Param[1] + local shopItemTemplate = XFubenRogueLikeConfig.GetShopItemTemplateById(shopItemId) + if shopItemTemplate then + local itemId = shopItemTemplate.ConsumeId[1] + local needCount = shopItemTemplate.ConsumeNum[1] + local itemName = XDataCenter.ItemManager.GetItemName(itemId) + --local ownCount = XDataCenter.ItemManager.GetCount(itemId) + self.TxtTips.text = CS.XTextManager.GetText("RogueLikeShopBuyItemTips", needCount, itemName, supportConfig.Title) + end + end + else + -- 更新信息 + local itemNum = supportTemplate.NeedPoint + self.TxtTips.text = CS.XTextManager.GetText("RogueLikeShopBuyTips", itemNum, supportConfig.Title) + end + end +end + +-- 购买按钮 +function XUiRogueLikeIllegalShop:OnBtnBuyClick() + if self.CurrentSelectIndex and self.BlackItemList and self.BlackItemList[self.CurrentSelectIndex] then + local shopItem = self.BlackItemList[self.CurrentSelectIndex] + if shopItem.BuyCount <= 0 then + XUiManager.TipMsg(CS.XTextManager.GetText("RogueLikeShopItemSellOut")) + return + end + + local supportTemplate = XFubenRogueLikeConfig.GetSupportStationTemplateById(shopItem.SupportId) + if supportTemplate then + local needPoint = supportTemplate.NeedPoint + if needPoint == 0 then + local specialEventId = supportTemplate.SpecialEvent + local specialEventTemplate = XFubenRogueLikeConfig.GetSpecialEventTemplateById(specialEventId) + if specialEventTemplate then + local shopItemId = specialEventTemplate.Param[1] + local shopItemTemplate = XFubenRogueLikeConfig.GetShopItemTemplateById(shopItemId) + if shopItemTemplate then + local itemId = shopItemTemplate.ConsumeId[1] + local needCount = shopItemTemplate.ConsumeNum[1] + local itemName = XDataCenter.ItemManager.GetItemName(itemId) + local ownCount = XDataCenter.ItemManager.GetCount(itemId) + if ownCount < needCount then + XUiManager.TipMsg(CS.XTextManager.GetText("RogueLikeBuySupportNotEnough", itemName)) + return + end + end + end + + else + local ownPoint = XDataCenter.FubenRogueLikeManager.GetRogueLikeActionPoint() + if ownPoint < needPoint then + XUiManager.TipMsg(CS.XTextManager.GetText("RogueLikeSupportStationCost")) + return + end + end + + -- 购买机器人特殊判断 + local specialEventId = supportTemplate.SpecialEvent + local specialEventTemplate = XFubenRogueLikeConfig.GetSpecialEventTemplateById(specialEventId) + if specialEventTemplate.Type == XFubenRogueLikeConfig.XRLOtherEventType.AddRobot then + if XDataCenter.FubenRogueLikeManager.IsAssistRobotFull() then + XUiManager.TipMsg(CS.XTextManager.GetText("RogueLikeSupportCharFull")) + return + end + end + end + + XDataCenter.FubenRogueLikeManager.RequestSupportCall(shopItem.SupportId, 1, function() + self:RefreshShopItems() + end) + end +end + +function XUiRogueLikeIllegalShop:StartCountDown() + self:StopCountDown() + + local now = XTime.GetServerNowTimestamp() + local endTime = XDataCenter.FubenRogueLikeManager.GetDayRefreshTime() + if not endTime then return end + self.TxtResetTime.text = XUiHelper.GetTime(endTime - now, XUiHelper.TimeFormatType.ACTIVITY) + + self.CountTimer = XScheduleManager.ScheduleForever(function() + now = XTime.GetServerNowTimestamp() + if now > endTime then + self:StopCountDown() + return + end + self.TxtResetTime.text = XUiHelper.GetTime(endTime - now, XUiHelper.TimeFormatType.ACTIVITY) + end, XScheduleManager.SECOND, 0) +end + +function XUiRogueLikeIllegalShop:StopCountDown() + if self.CountTimer ~= nil then + XScheduleManager.UnSchedule(self.CountTimer) + self.CountTimer = nil + end +end + +function XUiRogueLikeIllegalShop:OnBtnCloseClick() + if XLuaUiManager.IsUiShow("UiRogueLikeIllegalShop") then + XLuaUiManager.Close("UiRogueLikeIllegalShop") + end +end + +function XUiRogueLikeIllegalShop:OnBtnTanchuangClose() + if XLuaUiManager.IsUiShow("UiRogueLikeIllegalShop") then + XLuaUiManager.Close("UiRogueLikeIllegalShop") + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeMain.lua b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeMain.lua new file mode 100644 index 00000000..31ae4d99 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeMain.lua @@ -0,0 +1,807 @@ +local XUiRogueLikeMain = XLuaUiManager.Register(XLuaUi, "UiRogueLikeMain") +local XUiRogueLikeCharItem = require("XUi/XUiFubenRogueLike/XUiRogueLikeCharItem") +local XUiRogueLikeNode = require("XUi/XUiFubenRogueLike/XUiRogueLikeNode") + +local XUiRogueLikeSetTeam = require("XUi/XUiFubenRogueLike/XUiRogueLikeSetTeam") + +local NodeAnimTime = CS.XGame.ClientConfig:GetInt("RogueLikeNodeAnimTime") +local vectorOffset = CS.UnityEngine.Vector3(-2, 0, 0) +local lastSectionId + +function XUiRogueLikeMain:OnAwake() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + -- self.TopicGroup.CallBack = function() self:OnTopicGroupClick() end + self.BtnIllegalShop.CallBack = function() self:OnBtnIllegalShopClick() end + + if self.CharacterGroup then + self.CharacterGroup.CallBack = function() self:OnTopicGroupClick() end + end + self:BindHelpBtn(self.BtnHelp, "RogueLike") + + self.BtnReset.CallBack = function () self:OnBtnResetClick() end + + self.BtnGroupLevel.CallBack = function () self:OnBtnGroupLevelClick() end + + self.BtnActionPoint.CallBack = function () self:OnBtnGroupLevelClick() end + + self.TopicList = {} + self.CharacterList = {} + self.HelpCHaracterList = {} + + self.BtnActivityTask.CallBack = function() self:OnBtnActivityTaskClick() end + self.BtnBuff.CallBack = function() self:OnBtnBuffClick() end + self.BtnHelpRole.CallBack = function() self:OnBtnHelpRoleClick() end + + self.TeamTips = XUiRogueLikeSetTeam.New(self.PanelTeamTips, self) + + self.RogueLikeNodeList = {} + XEventManager.AddEventListener(XEventId.EVENT_ROGUELIKE_ACTIONPOINT_CHARACTER_CHANGED, self.OnActionPointAndCharacterChanged, self) + XEventManager.AddEventListener(XEventId.EVENT_ROGUELIKE_ASSISTROBOT_CHANGED, self.OnAssistRobotChanged, self) + XEventManager.AddEventListener(XEventId.EVENT_ROGUELIKE_REFRESH_ALLNODES, self.RefreshNodes, self) + XEventManager.AddEventListener(XEventId.EVENT_ROGUELIKE_BUFFIDS_CHANGES, self.OnBuffIdsChanged, self) + XEventManager.AddEventListener(XEventId.EVENT_ROGUELIKE_TEAMEFFECT_CHANGES, self.SetRogueLikeDayBuffs, self) + XEventManager.AddEventListener(XEventId.EVENT_ROGUELIKE_NODE_ADJUSTION, self.FocusOnNewest, self) + XEventManager.AddEventListener(XEventId.EVENT_ROGUELIKE_SECTIONTYPE_CHANGE, self.CheckTrialOpens, self) + XEventManager.AddEventListener(XEventId.EVENT_ROGUELIKE_SECTION_REFRESH, self.OnSectionRefresh, self) + XEventManager.AddEventListener(XEventId.EVENT_ROGUELIKE_TRIALPOINT_CHANGE, self.CheckClearanceOpen, self) +end + +function XUiRogueLikeMain:OnDestroy() + if self.TempNodeResource then + self.TempNodeResource:Release() + end + if self.TempNodeBossResource then + self.TempNodeBossResource:Release() + end + + if self.DelayTimer then + XScheduleManager.UnSchedule(self.DelayTimer) + self.DelayTimer = nil + end + + if self.TweenAnim then + XScheduleManager.UnSchedule(self.TweenAnim) + self.TweenAnim = nil + end + + self:StopCounter() + XEventManager.RemoveEventListener(XEventId.EVENT_ROGUELIKE_ACTIONPOINT_CHARACTER_CHANGED, self.OnActionPointAndCharacterChanged, self) + XEventManager.RemoveEventListener(XEventId.EVENT_ROGUELIKE_ASSISTROBOT_CHANGED, self.OnAssistRobotChanged, self) + XEventManager.RemoveEventListener(XEventId.EVENT_ROGUELIKE_REFRESH_ALLNODES, self.RefreshNodes, self) + XEventManager.RemoveEventListener(XEventId.EVENT_ROGUELIKE_BUFFIDS_CHANGES, self.OnBuffIdsChanged, self) + XEventManager.RemoveEventListener(XEventId.EVENT_ROGUELIKE_TEAMEFFECT_CHANGES, self.SetRogueLikeDayBuffs, self) + XEventManager.RemoveEventListener(XEventId.EVENT_ROGUELIKE_NODE_ADJUSTION, self.FocusOnNewest, self) + XEventManager.RemoveEventListener(XEventId.EVENT_ROGUELIKE_SECTIONTYPE_CHANGE, self.CheckTrialOpens, self) + XEventManager.RemoveEventListener(XEventId.EVENT_ROGUELIKE_SECTION_REFRESH, self.OnSectionRefresh, self) + XEventManager.RemoveEventListener(XEventId.EVENT_ROGUELIKE_TRIALPOINT_CHANGE, self.CheckClearanceOpen, self) +end + +function XUiRogueLikeMain:OnStart() + self.CurrentActivityId = XDataCenter.FubenRogueLikeManager.GetRogueLikeActivityId() + self.ActivityTemplate = XFubenRogueLikeConfig.GetRougueLikeTemplateById(self.CurrentActivityId) + local showBuffId = XFubenConfigs.GetLimitShowBuffId(self.ActivityTemplate.LimitBuffId) + self.TeamTips:SetCharacterType(self.ActivityTemplate.CharacterLimitType, showBuffId) + self.ActivityConfig = XFubenRogueLikeConfig.GetRogueLikeConfigById(self.CurrentActivityId) + self.CurrentSecionInfo = XDataCenter.FubenRogueLikeManager.GetCurSectionInfo() + if not self.CurrentSecionInfo then + XLog.Error("CurrentSectionInfo is nil") + return + end + self.CurrentSectionId = self.CurrentSecionInfo.Id + self.GroupId = self.CurrentSecionInfo.Group + lastSectionId = self.CurrentSectionId + + self.CurSectionTierType = XFubenRogueLikeConfig.GetTierSectionTierTypeById(self.CurrentSectionId) + + self:SetActivityInfo() + self:SetRogueLikeDayBuffs() + self:SetActivityAssistRobots() + self:InitDragPanel() + self:StartCounter() + + XRedPointManager.AddRedPointEvent(self.RedTask, self.RefreshRogueLikeTaskRedDot, self, { XRedPointConditions.Types.CONDITION_TASK_TYPE }, XDataCenter.TaskManager.TaskType.RogueLike) +end + +function XUiRogueLikeMain:CheckTrialOpens() + if self:IsSectionPurgatory() and XDataCenter.FubenRogueLikeManager.GetNeedShowTrialTips() and self.GameObject and self.GameObject.activeInHierarchy then + self:OpenChildUi("UiRogueLikeTrialOpens", self) + end +end + +function XUiRogueLikeMain:CheckClearanceOpen() + if XDataCenter.FubenRogueLikeManager.GetNeedShowTrialPointView() and self.GameObject and self.GameObject.activeInHierarchy then + self:OpenChildUi("UiRogueLikeClearance", self) + end +end + +function XUiRogueLikeMain:IsSectionPurgatory() + return XDataCenter.FubenRogueLikeManager.IsSectionPurgatory() +end + +function XUiRogueLikeMain:RefreshRogueLikeTaskRedDot(count) + self.RedTask.gameObject:SetActive(count >= 0) +end + +function XUiRogueLikeMain:OnEnable() + self:CheckActivityEnd() + self:CheckSectionIdChanged() + self:CheckSetTeam() + + self:SetActivityInfo() +end + +function XUiRogueLikeMain:OnDisable() + self.PanelActionPointEffect.gameObject:SetActiveEx(false) + for i = 1, #self.CharacterList do + if self.CharacterList[i] then + self.CharacterList[i]:StopFx() + end + end +end + +function XUiRogueLikeMain:CheckSetTeam() + XDataCenter.FubenRogueLikeManager.ShowRogueLikeTipsOnce() +end + +function XUiRogueLikeMain:IsSectionChanged() + if lastSectionId and self.CurrentSectionId and lastSectionId ~= self.CurrentSectionId then + return true + end + return false +end + +function XUiRogueLikeMain:CheckSectionIdChanged() + + if self:IsSectionChanged() then + lastSectionId = self.CurrentSectionId + self.PanelFullExplore.gameObject:SetActiveEx(true) + self:PlayAnimation("PanelFullFinishEnable", function() + self.PanelFullExplore.gameObject:SetActiveEx(false) + self:RefreshNewChapter() + XLuaUiManager.SetMask(false) + self:PlayAnimation("BeiJingQieHuan", function() + XLuaUiManager.SetMask(false) + end, function() + XLuaUiManager.SetMask(true) + end) + self:CheckTrialOpens() + end, + function() + XLuaUiManager.SetMask(true) + end) + else + if XDataCenter.FubenRogueLikeManager.IsFinalTier() then + self.PanelFullExplore.gameObject:SetActiveEx(true) + self:PlayAnimation("PanelFullFinishEnable", function() + self.PanelFullExplore.gameObject:SetActiveEx(false) + XLuaUiManager.SetMask(false) + end, + function() + XLuaUiManager.SetMask(true) + end) + XDataCenter.FubenRogueLikeManager.ResetIsFinalTier() + + self:CheckClearanceOpen() + end + self:FocusOnNewest() + end +end + +function XUiRogueLikeMain:InitDragPanel() + -- 初始化层级,需要考虑更新层级 + local sectionConfig = XFubenRogueLikeConfig.GetTierSectionConfigById(self.CurrentSecionInfo.Id) + local prefabName = "" + for i = 1, #sectionConfig.GroupId do + if sectionConfig.GroupId[i] == self.CurrentSecionInfo.Group then + prefabName = sectionConfig.GroupPrefab[i] + break + end + end + if prefabName == "" then + XLog.Error("RogueLikeMain prefab not exist") + return + end + + self.CurrentPrefabName = prefabName + self.DragPanel = self.PanelMap:LoadPrefab(self.CurrentPrefabName) + self.PanelDragArea = self.DragPanel:GetComponentInChildren(typeof(CS.XDragArea)) + self.LayerLevel = self.PanelDragArea.gameObject.transform:Find("LayerLevel") + + -- 初始化节点,需要考虑更新节点信息 + self:InitNodes() +end + +function XUiRogueLikeMain:InitNodes() + self.AllNodeList, self.NodeIndexMap = XFubenRogueLikeConfig.GetNodesByGroupId(self.GroupId) + self:GenerateChildNodeMap() + + if not self.TempNodeResource then + self.TempNodeResource = CS.XResourceManager.Load(XFubenRogueLikeConfig.NORMAL_NODE) + end + if not self.TempNodeBossResource then + self.TempNodeBossResource = CS.XResourceManager.Load(XFubenRogueLikeConfig.BOSS_NODE) + end + + self.Curlen = 1 + self.Totallen = #self.AllNodeList + self:LoadNodePerFrame(self.Curlen) + +end + +function XUiRogueLikeMain:LoadNodePerFrame(index) + CS.XTool.WaitNativeCoroutine(CS.UnityEngine.WaitForEndOfFrame(), function() + local endIndex = index + 5 + endIndex = (endIndex > self.Totallen) and self.Totallen or endIndex + for i = index, endIndex do + self:Loadfun(i) + end + if endIndex < self.Totallen then + self:LoadNodePerFrame(endIndex + 1) + end + end) +end + +function XUiRogueLikeMain:Loadfun(index) + if not self.RogueLikeNodeList[index] then + local nodeId = self.AllNodeList[index].NodeId + local nodeConfig = XFubenRogueLikeConfig.GetNodeConfigteById(nodeId) + local isBoss = nodeConfig.Param[1] == 1 + local tempNodeObj + if isBoss then + tempNodeObj = CS.UnityEngine.Object.Instantiate(self.TempNodeBossResource.Asset) + else + tempNodeObj = CS.UnityEngine.Object.Instantiate(self.TempNodeResource.Asset) + end + local tempParentTransform = self.LayerLevel.transform:Find(tostring(index)) + tempNodeObj.transform:SetParent(tempParentTransform, false) + self.RogueLikeNodeList[index] = XUiRogueLikeNode.New(tempNodeObj, tempParentTransform, self) + end + self.RogueLikeNodeList[index]:UpdateNode(self.AllNodeList[index]) + if index == self.Totallen then + -- self:CheckPossiblePath() + self:FocusOnNewest() + end +end + +function XUiRogueLikeMain:CheckPossiblePath() + self.PossibleNodes = {} + self.UnpossibleNodes = {} + + for nodeId, _ in pairs(self.CurrentSecionInfo.FinishNode or {}) do + local childNodes = self:GetChildNode(nodeId) + + local hasFinishChildNode = false + + local hasSelectChildNode = false + local selectChildNodeId = 0 + + for childNodeId, _ in pairs(childNodes or {}) do + -- 是否有子节点是已完成的 + if self.CurrentSecionInfo.FinishNode[childNodeId] then + hasFinishChildNode = true + end + -- 是否有子节点选中 + local selectNodeTemplate = XFubenRogueLikeConfig.GetNodeTemplateById(childNodeId) + if self.CurrentSecionInfo.SelectNodeInfo[childNodeId] and + (selectNodeTemplate.Type == XFubenRogueLikeConfig.XRLNodeType.Shop or + selectNodeTemplate.Type == XFubenRogueLikeConfig.XRLNodeType.Event or + selectNodeTemplate.Type == XFubenRogueLikeConfig.XRLNodeType.Rest) then + hasSelectChildNode = true + selectChildNodeId = childNodeId + end + end + + -- 这个节点是最后完成的节点,需要查看有没有选中的子节点 + if not hasFinishChildNode then + if hasSelectChildNode and selectChildNodeId > 0 then + -- 有选中不可更改的子节点 + self:GetPossibleNodes(selectChildNodeId) + else + -- 没有选中不可更改的子节点 + self:GetPossibleNodes(nodeId) + end + end + self.PossibleNodes[nodeId] = true + end + -- 选中了节点,应当使用这个子节点, + for _, nodeInfo in pairs(self.AllNodeList or {}) do + if not self.PossibleNodes[nodeInfo.NodeId] then + self.UnpossibleNodes[nodeInfo.NodeId] = true + end + end + + -- 没有完成节点,return + if not next(self.CurrentSecionInfo.FinishNode) then return end + + for index, nodeInfo in pairs(self.AllNodeList or {}) do + self.RogueLikeNodeList[index].GameObject:SetActiveEx(self.PossibleNodes[nodeInfo.NodeId]) + if self.UnpossibleNodes[nodeInfo.NodeId] then + self.RogueLikeNodeList[index]:HideAllLines() + else + local childNodes = self:GetChildNode(nodeInfo.NodeId) + for childNodeId, _ in pairs(childNodes or {}) do + if self.UnpossibleNodes[childNodeId] then + self.RogueLikeNodeList[index]:HideTargetLines(childNodeId) + end + end + end + end +end + +function XUiRogueLikeMain:GetPossibleNodes(nodeId) + if not nodeId then return end + if not self.PossibleNodes[nodeId] then + self.PossibleNodes[nodeId] = true + + local childNodes = self:GetChildNode(nodeId) + for childNodeId, _ in pairs(childNodes or {}) do + self:GetPossibleNodes(childNodeId) + end + end +end + +-- 当前章节关键路线检查 +function XUiRogueLikeMain:CheckAllLines() + for i = 1, #self.AllNodeList do + local curNode = self.AllNodeList[i] + local childNodes = self:GetChildNode(curNode.NodeId) + local curNodeIndex = curNode.Index + for childNodeId, _ in pairs(childNodes or {}) do + local childNodeIndex = self:GetNodeIndex(childNodeId) + local cur2ChildLine = string.format("Line%d_%d", curNodeIndex, childNodeIndex) + local nodeParent = self.LayerLevel.transform:Find(tostring(curNodeIndex)) + local needLine = nodeParent:Find(cur2ChildLine) + local hasLine = needLine ~= nil + local hasCanvasGroup = false + if needLine then + local lineCanvasGroup = needLine:GetComponent("CanvasGroup") + hasCanvasGroup = lineCanvasGroup ~= nil + end + if (not hasLine) or (not hasCanvasGroup) then + XLog.Error(string.format("层数:%d, 节点%d[%d] -> 节点%d[%d] 是否有连接线%s:%s,连接线是否有CanvasGroup组件:%s", + curNode.TierIndex, curNode.NodeId, curNodeIndex, childNodeId, childNodeIndex, cur2ChildLine, tostring(hasLine), tostring(hasCanvasGroup))) + end + end + end +end + +function XUiRogueLikeMain:GetNodeIndex(nodeId) + return self.NodeIndexMap[nodeId] +end + +function XUiRogueLikeMain:GetChildNode(nodeId) + return self.ChildNodeMap[nodeId] +end + +function XUiRogueLikeMain:GenerateChildNodeMap() + self.ChildNodeMap = {} + for i = 1, #self.AllNodeList do + local node = self.AllNodeList[i] + for _, fatherNodeId in pairs(node.FatherNodes) do + if not self.ChildNodeMap[fatherNodeId] then + self.ChildNodeMap[fatherNodeId] = {} + end + self.ChildNodeMap[fatherNodeId][node.NodeId] = true + end + end +end + +-- 当章节出现变化 +function XUiRogueLikeMain:RefreshDragPanel() + local sectionConfig = XFubenRogueLikeConfig.GetTierSectionConfigById(self.CurrentSecionInfo.Id) + local prefabName = "" + for i = 1, #sectionConfig.GroupId do + if sectionConfig.GroupId[i] == self.CurrentSecionInfo.Group then + prefabName = sectionConfig.GroupPrefab[i] + break + end + end + if prefabName == "" then + XLog.Error("RogueLikeMain prefab not exist") + return + end + if self.CurrentPrefabName and self.CurrentPrefabName ~= prefabName then + self.DragPanel = self.PanelMap:LoadPrefab(prefabName) + self.PanelDragArea = self.DragPanel:GetComponentInChildren(typeof(CS.XDragArea)) + self.LayerLevel = self.PanelDragArea.gameObject.transform:Find("LayerLevel") + end + self.CurrentPrefabName = prefabName + self:InitNodes() +end + +function XUiRogueLikeMain:RefreshNewChapter() + self.RogueLikeNodeList = {} + self:RefreshDragPanel() + + -- 主界面信息刷新 + self:SetActivityInfo() + self:SetRogueLikeDayBuffs() + self:SetActivityAssistRobots() +end + +function XUiRogueLikeMain:OnSectionRefresh() + + if self:IsSectionChanged() then + self:RefreshNewChapter() + else + self:FocusOnNewest() + end +end + +function XUiRogueLikeMain:RefreshNodes() + local currentSectionInfo = XDataCenter.FubenRogueLikeManager.GetCurSectionInfo() + local sectionId = currentSectionInfo.Id + if sectionId ~= self.CurrentSectionId then + self.CurrentSecionInfo = currentSectionInfo + self.CurrentSectionId = self.CurrentSecionInfo.Id + self.GroupId = self.CurrentSecionInfo.Group + -- 章节刷新/放到开头 + self.CurSectionTierType = XFubenRogueLikeConfig.GetTierSectionTierTypeById(self.CurrentSectionId) + + else + self.CurrentSecionInfo = currentSectionInfo + self.CurrentSectionId = self.CurrentSecionInfo.Id + self.GroupId = self.CurrentSecionInfo.Group + -- 节点刷新 + if self.AllNodeList then + for i = 1, #self.AllNodeList do + if self.RogueLikeNodeList[i] then + self.RogueLikeNodeList[i]:UpdateNode(self.AllNodeList[i]) + end + end + end + -- self:CheckPossiblePath() + local index = XDataCenter.FubenRogueLikeManager.GetRogueLikeLevel() + local maxTier = XDataCenter.FubenRogueLikeManager.GetMaxTier() + self.TxtLevel.text = index + self.TxtMaxTier.text = string.format("/%d", maxTier) + self.Slider.value = index * 1.0 / maxTier + end +end + +function XUiRogueLikeMain:SetActivityInfo() + if not self.GameObject.activeInHierarchy then return end + self.TxtTitle.text = self.ActivityConfig.Name + local index = XDataCenter.FubenRogueLikeManager.GetRogueLikeLevel() + local maxTier = XDataCenter.FubenRogueLikeManager.GetMaxTier() + self.TxtLevel.text = index + self.TxtMaxTier.text = string.format("/%d", maxTier) + self.Slider.value = index * 1.0 / maxTier + + if self:IsSectionPurgatory() then + self.BtnIllegalShop.gameObject:SetActiveEx(false) + self.BtnHelpRole.gameObject:SetActiveEx(false) + self.BtnReset.gameObject:SetActiveEx(true) + self.BtnGroupLevel.enabled = true + self.BtnActionPoint.enabled = true + self.TextLevelTitle1.gameObject:SetActiveEx(true) + self.TextLevelTitle2.gameObject:SetActiveEx(false) + local trialPoint = XDataCenter.FubenRogueLikeManager.GetRogueLikeTrialPoint() + + local startTweenPoint = XDataCenter.FubenRogueLikeManager.GetRogueLikeTrialPointShowByTween() + + if startTweenPoint ~= 0 then + XDataCenter.FubenRogueLikeManager.SetRogueLikeTrialPointShowByTween(0) + local time = CS.XGame.ClientConfig:GetFloat("RogueLikeTrialPointAnimaTime") + local pointDifference = trialPoint - startTweenPoint + local realTime = pointDifference / 30 + if realTime < 1 then + realTime = 1 + elseif realTime > time then + realTime = time + end + self.TweenAnim = XUiHelper.Tween(realTime, function(f) + if XTool.UObjIsNil(self.Transform) then + return + end + local allPoint = startTweenPoint + math.floor(f * pointDifference) + self.TxtActionPoint.text = CS.XTextManager.GetText("RogueLikeTrialPoint", allPoint) + + end, function() + if XTool.UObjIsNil(self.Transform) then + return + end + self.TxtActionPoint.text = CS.XTextManager.GetText("RogueLikeTrialPoint", trialPoint) + end) + else + self.TxtActionPoint.text = CS.XTextManager.GetText("RogueLikeTrialPoint", trialPoint) + end + + self.BtnReset:SetNameByGroup(0, 1 - XDataCenter.FubenRogueLikeManager.GetRogueLikeResetNum()) + else + self.BtnIllegalShop.gameObject:SetActiveEx(true) + self.BtnHelpRole.gameObject:SetActiveEx(true) + self.BtnReset.gameObject:SetActiveEx(false) + self.BtnGroupLevel.enabled = false + self.BtnActionPoint.enabled = false + self.TextLevelTitle1.gameObject:SetActiveEx(false) + self.TextLevelTitle2.gameObject:SetActiveEx(true) + + local totalActionPoint = self.ActivityTemplate.ActionPoint + local actionPoint = XDataCenter.FubenRogueLikeManager.GetRogueLikeActionPoint() + self.TxtActionPoint.text = CS.XTextManager.GetText("RogueLikeCurretnActionPoint", tostring(actionPoint), tostring(totalActionPoint)) + end + + -- 锁定构造体 + local characterInfos = XDataCenter.FubenRogueLikeManager.GetCharacterInfos() + for i = 1, XDataCenter.FubenRogueLikeManager.GetTeamMemberCount() do + local charInfo = characterInfos[i] + if not self.CharacterList[i] then + local ui = CS.UnityEngine.Object.Instantiate(self.CharacterItem.gameObject) + ui.gameObject:SetActiveEx(true) + ui.transform:SetParent(self.CharacterContent, false) + self.CharacterList[i] = XUiRogueLikeCharItem.New(ui, self) + end + self.CharacterList[i]:UpdateCharacterInfos(charInfo) + end + + self:OnBuffIdsChanged() + +end + + +function XUiRogueLikeMain:SetRogueLikeDayBuffs() + +end + +function XUiRogueLikeMain:OpenSetTeamView() + local characters = XDataCenter.FubenRogueLikeManager.GetCharacterInfos() + if #characters <= 0 then + self.TeamTips:ShowSetTeamView() + self:PlayAnimation("TeamTipsEnable", function() + XLuaUiManager.SetMask(false) + end, function() + XLuaUiManager.SetMask(true) + end) + return true + end + return false +end + +function XUiRogueLikeMain:OnTopicGroupClick() + if self:OpenSetTeamView() then + return + end + XLuaUiManager.Open("UiRogueLikeThemeTips") +end + +function XUiRogueLikeMain:OnBtnResetClick() + -- if self:OpenSetTeamView() then + -- return + -- end + XLuaUiManager.Open("UiRogueLikeReset", CS.XTextManager.GetText("RogueLikePurgatoryResetTitle"), CS.XTextManager.GetText("RogueLikePurgatoryResetValue")) +end + +function XUiRogueLikeMain:OnBtnGroupLevelClick() + if self:IsSectionPurgatory() then + XDataCenter.FubenRogueLikeManager.OpenTrialPoint(function() + self:OpenChildUi("UiRogueLikeClearance", self) + end) + end +end + +-- 获得的支援 +function XUiRogueLikeMain:SetActivityAssistRobots() + local assistRobots = XDataCenter.FubenRogueLikeManager.GetAssistRobots() + self.BtnHelpRole:SetNameByGroup(0, #assistRobots) + self.BtnHelpRole:SetNameByGroup(1, string.format("/%d", XDataCenter.FubenRogueLikeManager.GetMaxRobotCount())) + self.HelpRoleRed.gameObject:SetActiveEx(XDataCenter.FubenRogueLikeManager.HasNewRobots()) +end + +function XUiRogueLikeMain:StartCounter() + self:StopCounter() + + if not self.ActivityTemplate then return end + local now = XTime.GetServerNowTimestamp() + local endTime = XDataCenter.FubenRogueLikeManager.GetActivityEndTime() + local weekEndTime = XDataCenter.FubenRogueLikeManager.GetWeekRefreshTime() + if not endTime then return end + + local leftTimeDesc = CS.XTextManager.GetText("BabelTowerLeftTimeDesc") + self.TxtTime.text = string.format("%s%s", leftTimeDesc, XUiHelper.GetTime(endTime - now, XUiHelper.TimeFormatType.ACTIVITY)) + self.TxtTaskTime.text = CS.XTextManager.GetText("RogueLikeTaskLeftTime", XUiHelper.GetTime(weekEndTime - now, XUiHelper.TimeFormatType.ACTIVITY)) + self.CountTimer = XScheduleManager.ScheduleForever( + + function() + now = XTime.GetServerNowTimestamp() + local rootIsNil = XTool.UObjIsNil(self.Transform) + if not self.CountTimer or now > endTime or rootIsNil then + self:StopCounter() + self:CheckActivityEnd() + return + end + self.TxtTime.text = string.format( + "%s%s", + leftTimeDesc, + XUiHelper.GetTime(endTime - now, XUiHelper.TimeFormatType.ACTIVITY) + ) + -- 周任务时间 + local weekTime = XDataCenter.FubenRogueLikeManager.GetWeekRefreshTime() + if weekTime then + self.TxtTaskTime.text = CS.XTextManager.GetText("RogueLikeTaskLeftTime", XUiHelper.GetTime(weekTime - now, XUiHelper.TimeFormatType.ACTIVITY)) + end + -- 日更新时间 + local dayEndTime = XDataCenter.FubenRogueLikeManager.GetDayRefreshTime() + if dayEndTime then + self.TeamTips:UpdateResetTime(XUiHelper.GetTime(dayEndTime - now, XUiHelper.TimeFormatType.ACTIVITY)) + end + end, + + XScheduleManager.SECOND, 0) +end + +function XUiRogueLikeMain:CheckActivityEnd() + if not XDataCenter.FubenRogueLikeManager.IsInActivity() and XLuaUiManager.IsUiShow("UiRogueLikeMain") then + XUiManager.TipMsg(CS.XTextManager.GetText("RougeLikeNotInActivityTime")) + XLuaUiManager.RunMain() + end +end + +function XUiRogueLikeMain:StopCounter() + if self.CountTimer ~= nil then + XScheduleManager.UnSchedule(self.CountTimer) + self.CountTimer = nil + end +end + +function XUiRogueLikeMain:OnBtnIllegalShopClick() + if not XDataCenter.FubenRogueLikeManager.IsInActivity() then + XUiManager.TipMsg(CS.XTextManager.GetText("RougeLikeNotInActivityTime")) + return + end + if self:OpenSetTeamView() then + return + end + XLuaUiManager.Open("UiRogueLikeIllegalShop") +end + +function XUiRogueLikeMain:OnBtnActivityTaskClick() + if not XDataCenter.FubenRogueLikeManager.IsInActivity() then + XUiManager.TipMsg(CS.XTextManager.GetText("RougeLikeNotInActivityTime")) + return + end + if self:OpenSetTeamView() then + return + end + XLuaUiManager.Open("UiRogueLikeTask") +end + +function XUiRogueLikeMain:OnBtnBuffClick() + if not XDataCenter.FubenRogueLikeManager.IsInActivity() then + XUiManager.TipMsg(CS.XTextManager.GetText("RougeLikeNotInActivityTime")) + return + end + if #XDataCenter.FubenRogueLikeManager.GetMyBuffs() <= 0 then + XUiManager.TipMsg(CS.XTextManager.GetText("RogueLikeNoneBuff")) + return + end + + XLuaUiManager.Open("UiRogueLikeMyBuff") +end + +function XUiRogueLikeMain:OnBtnHelpRoleClick() + local assistRobots = XDataCenter.FubenRogueLikeManager.GetAssistRobots() + if #assistRobots <= 0 then + XUiManager.TipMsg(CS.XTextManager.GetText("RogueLikeNoneSupport")) + return + end + if self:OpenSetTeamView() then + return + end + XLuaUiManager.Open("UiRogueLikeHelpRole") +end + +function XUiRogueLikeMain:OnBtnBackClick() + self:Close() +end + +function XUiRogueLikeMain:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiRogueLikeMain:SelectNodeAnimation(nodeTransform, finishCallBack) + + XLuaUiManager.SetMask(true) + self.PanelDragArea:FocusTarget(nodeTransform, 1, NodeAnimTime / 10, vectorOffset, function() + XLuaUiManager.SetMask(false) + end) + XScheduleManager.ScheduleOnce(function() + if finishCallBack then + finishCallBack() + end + end, NodeAnimTime / 10 - 0.1) + +end + +function XUiRogueLikeMain:OnActionPointAndCharacterChanged(isAddActionPoint) + self:SetActivityInfo() + self:SetRogueLikeDayBuffs() + + if isAddActionPoint then + if self.PanelActionPointEffect.gameObject.activeSelf then + self.PanelActionPointEffect.gameObject:SetActiveEx(false) + end + self.PanelActionPointEffect.gameObject:SetActiveEx(true) + end +end + +function XUiRogueLikeMain:OnAssistRobotChanged() + self:SetActivityAssistRobots() + for i = 1, #self.AllNodeList do + if self.RogueLikeNodeList[i] then + self.RogueLikeNodeList[i]:UpdateNodeTab() + end + end +end + +function XUiRogueLikeMain:OnBuffIdsChanged() + self.BuffRed.gameObject:SetActiveEx(XDataCenter.FubenRogueLikeManager.HasNewBuffs() > 0) + self.BtnBuff:SetNameByGroup(0, #XDataCenter.FubenRogueLikeManager.GetMyBuffs()) + self.TeamTips:UpdateBuffs() +end + +-- 时机:节点完成,初始化完成 +function XUiRogueLikeMain:FocusOnNewest() + if self.PanelDragArea and self.AllNodeList and self.CurrentSecionInfo then + if next(self.CurrentSecionInfo.FinishNode) then + local focusNodeId + for nodeId, _ in pairs(self.CurrentSecionInfo.FinishNode) do + local childNodes = self:GetChildNode(nodeId) + if childNodes then + local hasFinish = false + local hasSelect = false + for childNodeId, _ in pairs(childNodes or {}) do + if self.CurrentSecionInfo.FinishNode[childNodeId] then + hasFinish = true + break + end + if self.CurrentSecionInfo.SelectNodeInfo[childNodeId] then + hasSelect = true + focusNodeId = childNodeId + break + end + end + -- 存在完成的,下一个 + -- 存在选中的,居中选中节点 + -- 都不存在,默认第一个子节点 + + if not hasFinish and not hasSelect then + local key = next(childNodes) + if key then + focusNodeId = key + end + end + end + end + + if focusNodeId then + for i = 1, #self.AllNodeList do + if self.AllNodeList[i].NodeId == focusNodeId and self.RogueLikeNodeList[i] then + self:FocusTargetDelay(self.RogueLikeNodeList[i].Transform) + break + end + end + end + else + -- 没有完成的节点 + for i = 1, #self.AllNodeList do + local nodeInfo = self.AllNodeList[i] + if #nodeInfo.FatherNodes <= 0 and self.RogueLikeNodeList[i] then + + self:FocusTargetDelay(self.RogueLikeNodeList[i].Transform) + break + end + end + end + end +end + +function XUiRogueLikeMain:FocusTargetDelay(transform) + self.DelayTimer = XScheduleManager.ScheduleOnce(function() + self.PanelDragArea:FocusTarget(transform, 1, 1, CS.UnityEngine.Vector3.zero, function() + XScheduleManager.UnSchedule(self.DelayTimer) + end) + end, 50) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeMemberHead.lua b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeMemberHead.lua new file mode 100644 index 00000000..9b07c193 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeMemberHead.lua @@ -0,0 +1,55 @@ +local XUiRogueLikeMemberHead = XClass(nil, "XUiRogueLikeMemberHead") + +function XUiRogueLikeMemberHead:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + self.UiButtonComp = self.Transform:GetComponent("XUiButton") +end + +function XUiRogueLikeMemberHead:ClearMemberHead() + self.RImgRole.gameObject:SetActiveEx(false) + self.ImgSword.gameObject:SetActiveEx(false) + self.TxtSword.text = "" + self.ImgIconUp.gameObject:SetActiveEx(false) +end + +function XUiRogueLikeMemberHead:SetMemberInfo(characterId, isHalf, isRobot) + self.CharacterId = characterId + if not characterId or characterId == 0 then + self:ClearMemberHead() + return + end + + if isRobot then + self.CharacterId = XRobotManager.GetCharacterId(self.CharacterId) + if not self.CharacterId or self.CharacterId == 0 then + self:ClearMemberHead() + return + end + end + self.RImgRole.gameObject:SetActiveEx(true) + self.ImgSword.gameObject:SetActiveEx(true) + + if isHalf then + self.RImgRole:SetRawImage(XDataCenter.CharacterManager.GetCharHalfBodyImage(self.CharacterId)) + else + self.RImgRole:SetRawImage(XDataCenter.CharacterManager.GetCharSmallHeadIcon(self.CharacterId)) + end + if isRobot then + self.TxtSword.text = "" + else + local character = XDataCenter.CharacterManager.GetCharacter(self.CharacterId) + self.TxtSword.text = math.floor(character.Ability) + end + self.ImgIconUp.gameObject:SetActiveEx(XDataCenter.FubenRogueLikeManager.IsTeamEffectCharacter(characterId)) +end + +function XUiRogueLikeMemberHead:SetMemberCallBack(cb) + if cb and self.UiButtonComp then + self.UiButtonComp.CallBack = function() cb() end + end +end + +return XUiRogueLikeMemberHead \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeMyBuff.lua b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeMyBuff.lua new file mode 100644 index 00000000..46422fe5 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeMyBuff.lua @@ -0,0 +1,66 @@ +local XUiRogueLikeMyBuff = XLuaUiManager.Register(XLuaUi, "UiRogueLikeMyBuff") +local XUiGridBuffDetailItem = require("XUi/XUiFubenRogueLike/XUiGridBuffDetailItem") + +function XUiRogueLikeMyBuff:OnAwake() + self.BtnClose.CallBack = function() self:OnBtnCloseClick() end + self.BtnTanchuangClose.CallBack = function() self:OnBtnTanchuangCloseClick() end + + self.DynamicTable = XDynamicTableNormal.New(self.PanelSelectList.gameObject) + self.DynamicTable:SetProxy(XUiGridBuffDetailItem) + self.DynamicTable:SetDelegate(self) +end + +--动态列表事件 +function XUiRogueLikeMyBuff:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.MyBuffs[index] + if not data then + return + end + grid.RootUi = self + grid:SetBuffInfo(data) + end +end + +function XUiRogueLikeMyBuff:OnStart() + self:RefreshMyBuffs() +end + +function XUiRogueLikeMyBuff:RefreshMyBuffs() + self.MyBuffs = XDataCenter.FubenRogueLikeManager.GetMyBuffs() + + table.sort(self.MyBuffs, function(buffA, buffB) + if buffA.SortWeight == buffB.SortWeight then + if buffA.Priority == buffB.Priority then + return buffA.BuffId < buffB.BuffId + end + return buffA.Priority > buffB.Priority + end + return buffA.SortWeight > buffB.SortWeight + end) + + self.TxtOwnBuff.text = #self.MyBuffs + self.ImgEmpty.gameObject:SetActiveEx(#self.MyBuffs <= 0) + self.DynamicTable:SetDataSource(self.MyBuffs) + self.DynamicTable:ReloadDataASync() +end + +function XUiRogueLikeMyBuff:OnEnable() +end + +function XUiRogueLikeMyBuff:OnDisable() + XDataCenter.FubenRogueLikeManager.ResetNewBuffs() + XEventManager.DispatchEvent(XEventId.EVENT_ROGUELIKE_BUFFIDS_CHANGES) +end + +function XUiRogueLikeMyBuff:OnDestroy() + +end + +function XUiRogueLikeMyBuff:OnBtnCloseClick() + self:Close() +end + +function XUiRogueLikeMyBuff:OnBtnTanchuangCloseClick() + self:Close() +end diff --git a/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeNode.lua b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeNode.lua new file mode 100644 index 00000000..5c8fad6b --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeNode.lua @@ -0,0 +1,279 @@ +local XUiRogueLikeNode = XClass(nil, "XUiRogueLikeNode") +local half_alpha = 0.3 +local full_alpha = 1 + +function XUiRogueLikeNode:Ctor(ui, uiParent, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + self.UiParent = uiParent + self.Transform.localPosition = CS.UnityEngine.Vector3.zero + + XTool.InitUiObject(self) + self.BtnNode = self.Transform:GetComponent("XUiButton") + self.BtnNode.CallBack = function() self:PlaySelectNodeAnimation() end + self.LineList = {} + self.LineCanvasGroupList = {} +end + +-- Finish节点 +-- 记下历史节点 +-- 上次选中的节点 +function XUiRogueLikeNode:UpdateNode(nodeInfo) + self.NodeInfo = nodeInfo + self.NodeTemplate = XFubenRogueLikeConfig.GetNodeTemplateById(self.NodeInfo.NodeId) + self.NodeConfig = XFubenRogueLikeConfig.GetNodeConfigteById(self.NodeInfo.NodeId) + local sectionInfo = XDataCenter.FubenRogueLikeManager.GetCurSectionInfo() + + -- 自己已经完成 + self.PanelComplete.gameObject:SetActiveEx(sectionInfo.FinishNode[self.NodeInfo.NodeId]) + if sectionInfo.FinishNode[self.NodeInfo.NodeId] then + self.BtnNode:SetButtonState(XUiButtonState.Normal) + self.NodeUsable = true + else + self.BtnNode:SetButtonState(XUiButtonState.Disable) + self.NodeUsable = false + end + -- 父节点已经完成 + for i = 1, #self.NodeInfo.FatherNodes do + local fatherNodeId = self.NodeInfo.FatherNodes[i] + if sectionInfo.FinishNode[fatherNodeId] then + self.BtnNode:SetButtonState(XUiButtonState.Normal) + self.NodeUsable = true + break + end + end + -- 首节点 + if #self.NodeInfo.FatherNodes <= 0 then + self.BtnNode:SetButtonState(XUiButtonState.Normal) + self.NodeUsable = true + end + -- 同级节点判断,如果有同级节点完成/不可逆节点选中 + local tierDatas = XFubenRogueLikeConfig.GetGroup2TierMapDatas(self.NodeInfo.Group, self.NodeInfo.TierIndex) + local hasSameTier = false + + + for _, v in pairs(tierDatas and tierDatas.Nodes or {}) do + + if v ~= self.NodeInfo.NodeId then + if sectionInfo.FinishNode[v] then + hasSameTier = true + end + + if sectionInfo.SelectNodeInfo[v] then + -- 类型是随机事件、商店需要处理 + local selectNodeTemplate = XFubenRogueLikeConfig.GetNodeTemplateById(v) + if selectNodeTemplate.Type == XFubenRogueLikeConfig.XRLNodeType.Shop or + selectNodeTemplate.Type == XFubenRogueLikeConfig.XRLNodeType.Event or + selectNodeTemplate.Type == XFubenRogueLikeConfig.XRLNodeType.Rest then + hasSameTier = true + end + end + end + end + + if hasSameTier then + self.BtnNode:SetButtonState(XUiButtonState.Disable) + self.NodeUsable = false + end + + -- 特效 + if self.PanelEffect then + self.PanelEffect.gameObject:SetActiveEx(self.NodeUsable and (not sectionInfo.FinishNode[self.NodeInfo.NodeId])) + end + + self:UpdateNodeTab() + + -- 界面显示 + self:UpdateNodeUi() + + self:UpdateNodeLines() +end + +function XUiRogueLikeNode:UpdateNodeTab() + if self.ImgTab and self.NodeTemplate then + local sectionInfo = XDataCenter.FubenRogueLikeManager.GetCurSectionInfo() + self.ImgTab.gameObject:SetActiveEx(self.NodeUsable and (not sectionInfo.FinishNode[self.NodeInfo.NodeId]) + and self.NodeTemplate.Type == XFubenRogueLikeConfig.XRLNodeType.Fight + and XDataCenter.FubenRogueLikeManager.CanSwitch2Assist()) + end +end + +function XUiRogueLikeNode:UpdateNodeUi() + -- 界面显示 + if self.NodeTemplate.Type ~= XFubenRogueLikeConfig.XRLNodeType.Fight then + self.RogueLikeTabNor:SetRawImage(XFubenRogueLikeConfig.NodeTabBg[self.NodeTemplate.Type]) + else + local fightType = self.NodeConfig.Param[1] or 0 + self.RogueLikeTabNor:SetRawImage(XFubenRogueLikeConfig.NodeFightTabBg[fightType]) + end + + self.TxtNumber.text = self.NodeConfig.Name + + if not self.NodeUsable then + if self.NodeTemplate.Type ~= XFubenRogueLikeConfig.XRLNodeType.Fight then + self.RogueLikeTabDis:SetRawImage(XFubenRogueLikeConfig.NodeTabDisBg[self.NodeTemplate.Type], function() + self.RogueLikeTabDis:SetNativeSize() + end) + else + local fightType = self.NodeConfig.Param[1] or 0 + self.RogueLikeTabDis:SetRawImage(XFubenRogueLikeConfig.NodeFightTabDisBg[fightType], function() + self.RogueLikeTabDis:SetNativeSize() + end) + end + end +end + +function XUiRogueLikeNode:HideAllLines() + for _, line in pairs(self.LineList or {}) do + if line then + line.gameObject:SetActiveEx(false) + end + end +end + +function XUiRogueLikeNode:HideTargetLines(targetNodeId) + if not self.NodeInfo then return end + local curNdoeIndex = self.UiRoot:GetNodeIndex(self.NodeInfo.NodeId) + local targetNodeIndex = self.UiRoot:GetNodeIndex(targetNodeId) + local cur2TargetLine = string.format("Line%d_%d", curNdoeIndex, targetNodeIndex) + if self.LineList[cur2TargetLine] then + self.LineList[cur2TargetLine].gameObject:SetActiveEx(false) + end +end + + +function XUiRogueLikeNode:UpdateNodeLines() + local childNodes = self.UiRoot:GetChildNode(self.NodeInfo.NodeId) + local curNdoeIndex = self.UiRoot:GetNodeIndex(self.NodeInfo.NodeId) + for childNodeId, _ in pairs(childNodes or {}) do + -- 缓存 + local childNodeIndex = self.UiRoot:GetNodeIndex(childNodeId) + local cur2ChildLine = string.format("Line%d_%d", curNdoeIndex, childNodeIndex) + if not self.LineList[cur2ChildLine] then + self.LineList[cur2ChildLine] = self.UiParent:Find(cur2ChildLine) + if self.LineList[cur2ChildLine] then + self.LineCanvasGroupList[cur2ChildLine] = self.LineList[cur2ChildLine]:GetComponent("CanvasGroup") + if not self.LineCanvasGroupList[cur2ChildLine] then + XLog.Error(string.format("%s 不存在", cur2ChildLine)) + end + self.LineCanvasGroupList[cur2ChildLine].interactable = false + self.LineCanvasGroupList[cur2ChildLine].blocksRaycasts = false + end + end + -- 默认,当前节点还没有完成,全部子节点低透明度显示 + if self.LineList[cur2ChildLine] then + self.LineCanvasGroupList[cur2ChildLine].alpha = half_alpha + self.LineCanvasGroupList[cur2ChildLine].gameObject:SetActiveEx(true) + end + end + local sectionInfo = XDataCenter.FubenRogueLikeManager.GetCurSectionInfo() + -- 看子节点、如果有子节点完成,那么只有一条线高透明度显示,如果没有子节点完成,则全部显示 + if sectionInfo.FinishNode[self.NodeInfo.NodeId] then + local hasChildFinishOrSelected = false + local finishOrSelectedChildNodeId = 0 + for childNodeId, _ in pairs(childNodes or {}) do + local hasSelect = false + local selectNodeTemplate = XFubenRogueLikeConfig.GetNodeTemplateById(childNodeId) + if sectionInfo.SelectNodeInfo[childNodeId] and + (selectNodeTemplate.Type == XFubenRogueLikeConfig.XRLNodeType.Shop or + selectNodeTemplate.Type == XFubenRogueLikeConfig.XRLNodeType.Event or + selectNodeTemplate.Type == XFubenRogueLikeConfig.XRLNodeType.Rest ) then + hasSelect = true + end + if sectionInfo.FinishNode[childNodeId] or hasSelect then + hasChildFinishOrSelected = true + finishOrSelectedChildNodeId = childNodeId + break + end + end + if hasChildFinishOrSelected and finishOrSelectedChildNodeId > 0 then + for childNodeId, _ in pairs(childNodes or {}) do + local childNodeIndex = self.UiRoot:GetNodeIndex(childNodeId) + local cur2ChildLine = string.format("Line%d_%d", curNdoeIndex, childNodeIndex) + if self.LineCanvasGroupList[cur2ChildLine] then + if childNodeId == finishOrSelectedChildNodeId then + self.LineCanvasGroupList[cur2ChildLine].alpha = full_alpha + -- self.LineCanvasGroupList[cur2ChildLine].gameObject:SetActiveEx(true) + else + self.LineCanvasGroupList[cur2ChildLine].alpha = half_alpha + -- self.LineCanvasGroupList[cur2ChildLine].gameObject:SetActiveEx(false) + end + end + end + else + for childNodeId, _ in pairs(childNodes or {}) do + local childNodeIndex = self.UiRoot:GetNodeIndex(childNodeId) + local cur2ChildLine = string.format("Line%d_%d", curNdoeIndex, childNodeIndex) + if self.LineCanvasGroupList[cur2ChildLine] then + self.LineCanvasGroupList[cur2ChildLine].alpha = full_alpha + -- self.LineCanvasGroupList[cur2ChildLine].gameObject:SetActiveEx(true) + end + end + end + end +end + +function XUiRogueLikeNode:PlaySelectNodeAnimation() + if self.UiRoot:OpenSetTeamView() then + return + end + local sectionInfo = XDataCenter.FubenRogueLikeManager.GetCurSectionInfo() + if sectionInfo.FinishNode[self.NodeInfo.NodeId] then + XUiManager.TipMsg(CS.XTextManager.GetText("RogueLikeCurrentNodeFinish")) + return + end + + if not self.NodeUsable then + return + end + + if not self:CheckActionPointEnouth() and false then + XUiManager.TipMsg(CS.XTextManager.GetText("RogueLikeNotActionPoint")) + return + end + + self.UiRoot:SelectNodeAnimation(self.Transform, function() + self:OnBtnNodeClick() + end) +end + +function XUiRogueLikeNode:CheckActionPointEnouth() + + if XFubenRogueLikeConfig.NoNeedCheckActionPointType(self.NodeTemplate.Type) then + return true + end + + local actionPoint = XDataCenter.FubenRogueLikeManager.GetRogueLikeActionPoint() + return actionPoint > 0 + +end + +function XUiRogueLikeNode:OnBtnNodeClick() + + if not XDataCenter.FubenRogueLikeManager.IsInActivity() then + XUiManager.TipMsg(CS.XTextManager.GetText("RougeLikeNotInActivityTime")) + return + end + + local args = {} + args.NodeInfo = self.NodeInfo + local sectionInfo = XDataCenter.FubenRogueLikeManager.GetCurSectionInfo() + local hasSelectNode = sectionInfo.SelectNodeInfo[self.NodeInfo.NodeId] ~= nil + hasSelectNode = hasSelectNode or (XDataCenter.FubenRogueLikeManager.GetShowSelectNodeById(self.NodeInfo.NodeId) ~= nil) + local getNodePositionFunc = function() return self:GetNodePosition() end + if hasSelectNode or XFubenRogueLikeConfig.IsRequestBeforeSelectType(self.NodeTemplate.Type) then + XLuaUiManager.Open("UiRogueLikeFightTips", args, getNodePositionFunc) + else + XDataCenter.FubenRogueLikeManager.SelectNode(self.NodeInfo.NodeId, function() + -- 选择节点成功打开界面 + XLuaUiManager.Open("UiRogueLikeFightTips", args, getNodePositionFunc) + end) + end +end + +function XUiRogueLikeNode:GetNodePosition() + return self.Transform.position +end + +return XUiRogueLikeNode \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeObtainBuff.lua b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeObtainBuff.lua new file mode 100644 index 00000000..3c80cf15 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeObtainBuff.lua @@ -0,0 +1,23 @@ +local XUiRogueLikeObtainBuff = XLuaUiManager.Register(XLuaUi, "UiRogueLikeObtainBuff") +local XUiGridBuffInfoItem = require("XUi/XUiFubenRogueLike/XUiGridBuffInfoItem") + +function XUiRogueLikeObtainBuff:OnAwake() + + self.BtnSure.CallBack = function() self:OnObtainClose() end + self.BtnCancel.CallBack = function() self:OnObtainClose() end + self.BtnBack.CallBack = function() self:OnObtainClose() end + self.BuffInfo = XUiGridBuffInfoItem.New(self, self.GridBuff) +end + +function XUiRogueLikeObtainBuff:OnStart(buffIds) + self.BuffIds = buffIds + self.BuffInfo:SetBuffInfo(self.BuffIds[1]) +end + +function XUiRogueLikeObtainBuff:OnEnable() + XDataCenter.FubenRogueLikeManager.CheckRogueLikeDayResetOnUi("UiRogueLikeObtainBuff") +end + +function XUiRogueLikeObtainBuff:OnObtainClose() + self:Close() +end diff --git a/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeReset.lua b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeReset.lua new file mode 100644 index 00000000..6dcc237b --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeReset.lua @@ -0,0 +1,33 @@ +local XUiRogueLikeReset = XLuaUiManager.Register(XLuaUi, "UiRogueLikeReset") + +function XUiRogueLikeReset:OnAwake() + self.BtnClose.CallBack = function () self:Close() end + self.BtnTanchuangClose.CallBack = function () self:Close() end + self.BtnResetAll.CallBack = function () self:OnBtnResetAllClick() end + self.BtnSingleReset.CallBack = function () self:OnBtnSingleResetClick() end +end + +function XUiRogueLikeReset:OnStart(title, content) + if title ~= nil and title ~= "" then + self.TitleLabel.text = title + else + self.TitleLabel.text = CS.XTextManager.GetText("RogueLikePurgatoryResetTitle") + end + + self.ContentText.text = string.gsub(content, "\\n", "\n") +end + +function XUiRogueLikeReset:OnBtnResetAllClick() + self:RealReset(1) +end + +function XUiRogueLikeReset:OnBtnSingleResetClick() + self:RealReset(2) +end + +function XUiRogueLikeReset:RealReset(resetType) + XDataCenter.FubenRogueLikeManager.ResetHardNode(resetType, function() + self:Close() + end) +end + diff --git a/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeRestEntrance.lua b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeRestEntrance.lua new file mode 100644 index 00000000..c538f2a1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeRestEntrance.lua @@ -0,0 +1,73 @@ +local XUiRogueLikeRestEntrance = XClass(nil, "XUiRogueLikeRestEntrance") + +function XUiRogueLikeRestEntrance:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + + XTool.InitUiObject(self) + self.OptionsList = {} +end + + +function XUiRogueLikeRestEntrance:UpdateByNode(node, eventNode) + self.Node = node + self.EventNode = (eventNode == nil) and node or eventNode + + self.NodeTemplate = XFubenRogueLikeConfig.GetNodeTemplateById(self.EventNode.Id) + self.NodeConfig = XFubenRogueLikeConfig.GetNodeConfigteById(self.EventNode.Id) + + self.TxtName.text = self.NodeConfig.Name + self.RImgIcon:SetRawImage(self.NodeConfig.Icon) + self.TxtRest.text = self.NodeConfig.Description + + for i = 1, XFubenRogueLikeConfig.ClientRestCount do + if not self.OptionsList[i] then + local optionUi = CS.UnityEngine.Object.Instantiate(self.BtnOption) + optionUi.transform:SetParent(self.PanelOption.transform, false) + self.OptionsList[i] = optionUi.transform:GetComponent("XUiButton") + self.OptionsList[i].CallBack = function() self:OnOptionsClick(i) end + end + self.OptionsList[i].gameObject:SetActiveEx(true) + self.OptionsList[i]:SetNameByGroup(0, XFubenRogueLikeConfig.ClientRestClickName[i]) + end + + -- 检查强化buff + local myBuffs = XDataCenter.FubenRogueLikeManager.GetMyBuffs() + if not next(myBuffs) then + self.OptionsList[XFubenRogueLikeConfig.ClientRestClickType.IntensifyBuff].gameObject:SetActiveEx(false) + end +end + +function XUiRogueLikeRestEntrance:OnOptionsClick(index) + if index == XFubenRogueLikeConfig.ClientRestClickType.Recover then + + local needConst = XFubenRogueLikeConfig.GetRecoverCostSupportPointById(self.Node.Param[1]) + local hpPercent = XFubenRogueLikeConfig.GetRecoverHpPercentById(self.Node.Param[1]) + XUiManager.DialogTip(CS.XTextManager.GetText("TipTitle"), CS.XTextManager.GetText("RogueLikeReFreshBlood", needConst, hpPercent), XUiManager.DialogType.Normal, nil, function() + XDataCenter.FubenRogueLikeManager.Recover(self.Node.Id, function() + --self.UiRoot:Close() + end) + end, {ItemId1 = XFubenRogueLikeConfig.ChallengeCoin}) + + elseif index == XFubenRogueLikeConfig.ClientRestClickType.IntensifyBuff then + + --self.UiRoot:Close() + XLuaUiManager.Open("UiRogueLikeBuffStrengthen", self.Node) + + elseif index == XFubenRogueLikeConfig.ClientRestClickType.Leave then + local title = CS.XTextManager.GetText("RogueLikeLeaveRestTitle") + local content = CS.XTextManager.GetText("RogueLikeLeaveShopContent") + XUiManager.DialogTip(title, content, XUiManager.DialogType.Normal, function() + end, function() + XDataCenter.FubenRogueLikeManager.FinishNode(self.Node.Id, function(res) + self.UiRoot:Close() + if res and res.RewardGoodsList and next(res.RewardGoodsList) ~= nil then + XUiManager.OpenUiObtain(res.RewardGoodsList or {}) + end + end) + end) + end +end + +return XUiRogueLikeRestEntrance \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeRoomCharacter.lua b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeRoomCharacter.lua new file mode 100644 index 00000000..98aef2b3 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeRoomCharacter.lua @@ -0,0 +1,530 @@ +local XUiGridRogueLikeCharacter = require("XUi/XUiFubenRogueLike/XUiGridRogueLikeCharacter") + +local CSXTextManagerGetText = CS.XTextManager.GetText + +local TabBtnIndex = { + Normal = 1, + Isomer = 2, +} +local CharacterTypeConvert = { + [TabBtnIndex.Normal] = XCharacterConfigs.CharacterType.Normal, + [TabBtnIndex.Isomer] = XCharacterConfigs.CharacterType.Isomer, +} +local TabBtnIndexConvert = { + [XCharacterConfigs.CharacterType.Normal] = TabBtnIndex.Normal, + [XCharacterConfigs.CharacterType.Isomer] = TabBtnIndex.Isomer, +} + +local XUiRogueLikeRoomCharacter = XLuaUiManager.Register(XLuaUi, "UiRogueLikeRoomCharacter") + +function XUiRogueLikeRoomCharacter:OnAwake() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + + self.BtnFashion.CallBack = function() self:OnBtnFashionClick() end + self.BtnConsciousness.CallBack = function() self:OnBtnConsciousnessClick() end + self.BtnWeapon.CallBack = function() self:OnBtnWeaponClick() end + self.BtnJoinTeam.CallBack = function() self:OnBtnJoinTeamClick() end + self.BtnQuitTeam.CallBack = function() self:OnBtnQuitTeamClick() end + self.BtnFilter.CallBack = function() + self:OnBtnFilterClick() + end + + self.GridIndex = {} + self.TagCacheDic = {} + self.SortFunction = {} + self.SortFunction[XRoomCharFilterTipsConfigs.EnumSortTag.Default] = function(leftCharacter, rightCharacter) + local leftInTeam = self:IsInTeam(leftCharacter.Id) + local leftAbility = leftCharacter.Ability + local leftLevel = leftCharacter.Level + local leftQuality = leftCharacter.Quality + local leftPriority = XCharacterConfigs.GetCharacterPriority(leftCharacter.Id) + + local rightInTeam = self:IsInTeam(rightCharacter.Id) + local rightAbility = rightCharacter.Ability + local rightLevel = rightCharacter.Level + local rightQuality = rightCharacter.Quality + local rightPriority = XCharacterConfigs.GetCharacterPriority(rightCharacter.Id) + + if leftInTeam ~= rightInTeam then + return leftInTeam + end + + if leftAbility ~= rightAbility then + return leftAbility > rightAbility + end + + if leftLevel ~= rightLevel then + return leftLevel > rightLevel + end + + if leftQuality ~= rightQuality then + return leftQuality > rightQuality + end + + return leftPriority < rightPriority + end + self.SortFunction[XRoomCharFilterTipsConfigs.EnumSortTag.Quality] = function(leftCharacter, rightCharacter) + local leftQuality = leftCharacter.Quality + local rightQuality = rightCharacter.Quality + if leftQuality ~= rightQuality then + return leftQuality > rightQuality + end + return self.SortFunction[XRoomCharFilterTipsConfigs.EnumSortTag.Default](leftCharacter, rightCharacter) + end + self.SortFunction[XRoomCharFilterTipsConfigs.EnumSortTag.Level] = function(leftCharacter, rightCharacter) + local leftLevel = leftCharacter.Level + local rightLevel = rightCharacter.Level + if leftLevel ~= rightLevel then + return leftLevel > rightLevel + end + return self.SortFunction[XRoomCharFilterTipsConfigs.EnumSortTag.Default](leftCharacter, rightCharacter) + end + self.SortFunction[XRoomCharFilterTipsConfigs.EnumSortTag.Ability] = function(leftCharacter, rightCharacter) + local leftAbility = leftCharacter.Ability + local rightAbility = rightCharacter.Ability + if leftAbility ~= rightAbility then + return leftAbility > rightAbility + end + return self.SortFunction[XRoomCharFilterTipsConfigs.EnumSortTag.Default](leftCharacter, rightCharacter) + end + + local root = self.UiModelGo.transform + self.PanelRoleModel = root:FindTransform("PanelRoleModel") + self.ImgEffectHuanren = root:FindTransform("ImgEffectHuanren") + self.ImgEffectHuanren1 = root:FindTransform("ImgEffectHuanren1") + + self.GridCharacter.gameObject:SetActiveEx(false) +end + +-- 选择角色 +-- 选择机器人 +function XUiRogueLikeRoomCharacter:OnStart(args) + self.RoleModelPanel = XUiPanelRoleModel.New(self.PanelRoleModel, nil, nil, true) + local teamSelectPos = self.TeamSelectPos + self.TeamSelectPos = args.TeamSelectPos + self.TeamCharIdMap = args.TeamCharIdMap + self.Type = args.Type + self.CharacterLimitType = args.CharacterLimitType + self.LimitBuffId = args.LimitBuffId + self.CallBack = args.CallBack + self.CancelCallBack = args.CancelCallBack + self.CharacterGrids = {} + + self:InitRequireCharacterInfo() + self:InitCharacterTypeBtns() + self:SetBtnStates() +end + +function XUiRogueLikeRoomCharacter:OnEnable() + if self:IsCharacterType() and self.CharacterGrids then + self:OnCharacterClick() + end +end + +function XUiRogueLikeRoomCharacter:SetBtnStates() + local isCharacter = self:IsCharacterType() + self.BtnFashion.gameObject:SetActiveEx(isCharacter) + self.BtnConsciousness.gameObject:SetActiveEx(isCharacter) + self.BtnWeapon.gameObject:SetActiveEx(isCharacter) +end + +function XUiRogueLikeRoomCharacter:InitRequireCharacterInfo() + local characterLimitType = self.CharacterLimitType + + if not XFubenConfigs.IsStageCharacterLimitConfigExist(characterLimitType) then + self.PanelRequireCharacter.gameObject:SetActiveEx(false) + return + else + self.PanelRequireCharacter.gameObject:SetActiveEx(true) + end + + local icon = XFubenConfigs.GetStageCharacterLimitImageTeamEdit(characterLimitType) + self.ImgRequireCharacter:SetSprite(icon) +end + +function XUiRogueLikeRoomCharacter:RefreshCharacterTypeTips() + local limitBuffId = self.LimitBuffId + local characterType = CharacterTypeConvert[self.SelectTabBtnIndex] + local characterLimitType = self.CharacterLimitType + local text = XFubenConfigs.GetStageCharacterLimitTextSelectCharacter(characterLimitType, characterType, limitBuffId) + self.TxtRequireCharacter.text = text +end + +function XUiRogueLikeRoomCharacter:InitCharacterTypeBtns() + self.BtnTabShougezhe.gameObject:SetActiveEx(not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.Isomer)) + + local tabBtns = { self.BtnTabGouzaoti, self.BtnTabShougezhe } + self.PanelCharacterTypeBtns:Init(tabBtns, function(index) self:TrySelectCharacterType(index) end) + + local characterLimitType = self.CharacterLimitType + local lockGouzaoti = characterLimitType == XFubenConfigs.CharacterLimitType.Isomer + local lockShougezhe = not XFunctionManager.JudgeOpen(XFunctionManager.FunctionName.Isomer) or characterLimitType == XFubenConfigs.CharacterLimitType.Normal + self.BtnTabGouzaoti:SetDisable(lockGouzaoti) + self.BtnTabShougezhe:SetDisable(lockShougezhe) + + --检查选择角色类型是否和副本限制类型冲突 + local characterType = XDataCenter.FubenManager.GetDefaultCharacterTypeByCharacterLimitType(self.CharacterLimitType) + local tempCharacterType = self:GetTeamCharacterType() + if tempCharacterType and not (tempCharacterType == XCharacterConfigs.CharacterType.Normal and lockGouzaoti + or tempCharacterType == XCharacterConfigs.CharacterType.Isomer and lockShougezhe) then + characterType = tempCharacterType + end + self.PanelCharacterTypeBtns:SelectIndex(TabBtnIndexConvert[characterType]) +end + +function XUiRogueLikeRoomCharacter:TrySelectCharacterType(index) + local characterType = CharacterTypeConvert[index] + if characterType == XCharacterConfigs.CharacterType.Isomer and not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.Isomer) then return end + + local characterLimitType = self.CharacterLimitType + if characterLimitType == XFubenConfigs.CharacterLimitType.Normal then + if characterType == XCharacterConfigs.CharacterType.Isomer then + XUiManager.TipText("TeamSelectCharacterTypeLimitTipNormal") + return + end + elseif characterLimitType == XFubenConfigs.CharacterLimitType.Isomer then + if characterType == XCharacterConfigs.CharacterType.Normal then + XUiManager.TipText("TeamSelectCharacterTypeLimitTipIsomer") + return + end + elseif characterLimitType == XFubenConfigs.CharacterLimitType.IsomerDebuff then + if characterType == XCharacterConfigs.CharacterType.Isomer then + -- local buffDes = XFubenConfigs.GetBuffDes(self.LimitBuffId) + -- local content = CSXTextManagerGetText("TeamSelectCharacterTypeLimitTipIsomerDebuff", buffDes) + -- local sureCallBack = function() + -- self:OnSelectCharacterType(index) + -- end + -- local closeCallback = function() + -- self.PanelCharacterTypeBtns:SelectIndex(TabBtnIndexConvert[XCharacterConfigs.CharacterType.Normal]) + -- end + -- XUiManager.DialogTip(nil, content, XUiManager.DialogType.Normal, closeCallback, sureCallBack) + -- return + end + elseif characterLimitType == XFubenConfigs.CharacterLimitType.NormalDebuff then + if characterType == XCharacterConfigs.CharacterType.Normal then + -- local buffDes = XFubenConfigs.GetBuffDes(self.LimitBuffId) + -- local content = CSXTextManagerGetText("TeamSelectCharacterTypeLimitTipNormalDebuff", buffDes) + -- local sureCallBack = function() + -- self:OnSelectCharacterType(index) + -- end + -- local closeCallback = function() + -- self.PanelCharacterTypeBtns:SelectIndex(TabBtnIndexConvert[XCharacterConfigs.CharacterType.Isomer]) + -- end + -- XUiManager.DialogTip(nil, content, XUiManager.DialogType.Normal, closeCallback, sureCallBack) + -- return + end + end + + self:OnSelectCharacterType(index) +end + +function XUiRogueLikeRoomCharacter:OnSelectCharacterType(index) + if self.SelectTabBtnIndex == index then return end + self.SelectTabBtnIndex = index + + XDataCenter.RoomCharFilterTipsManager.Reset() + + local charlist + local characterType = CharacterTypeConvert[index] + if self:IsCharacterType() then + charlist = XDataCenter.CharacterManager.GetOwnCharacterList(characterType) + table.sort(charlist,self.SortFunction[XRoomCharFilterTipsConfigs.EnumSortTag.Default]) + else + charlist = XDataCenter.FubenRogueLikeManager.GetAssistRobots(characterType) + end + + self:RefreshCharacterTypeTips() + self:UpdateCharacterList(charlist) +end + +function XUiRogueLikeRoomCharacter:SetPanelEmptyList(isEmpty) + self.BtnQuitTeam.gameObject:SetActiveEx(false) + self.BtnJoinTeam.gameObject:SetActiveEx(false) + + self.BtnConsciousness.gameObject:SetActiveEx(not isEmpty) + self.BtnFashion.gameObject:SetActiveEx(not isEmpty) + self.BtnWeapon.gameObject:SetActiveEx(not isEmpty) + + self.PanelRoleContent.gameObject:SetActiveEx(not isEmpty) + self.PanelRoleModel.gameObject:SetActiveEx(not isEmpty) + self.PanelEmptyList.gameObject:SetActiveEx(isEmpty) + self:SetBtnStates() +end + +function XUiRogueLikeRoomCharacter:UpdateCharacterList(charlist) + if not next(charlist) then + self:SetPanelEmptyList(true) + return + end + self:SetPanelEmptyList(false) + + for _, item in pairs(self.CharacterGrids) do + item:Reset() + end + + self.CharacterGrids = {} + local charDic = {} + for i = 1, #charlist do + local characterId = charlist[i].Id + charDic[characterId] = charlist[i] + + local grid = self.GridIndex[i] + if not grid then + local item = CS.UnityEngine.Object.Instantiate(self.GridCharacter) + grid = XUiGridRogueLikeCharacter.New(self, item, function(character) + self:OnCharacterClick(character) + end, characterId, self.Type) + grid.Transform:SetParent(self.PanelRoleContent, false) + self.GridIndex[i] = grid + end + if self:IsCharacterType() then + grid:UpdateGrid(XDataCenter.CharacterManager.GetCharacter(characterId)) + grid:SetArrowUp(XDataCenter.FubenRogueLikeManager.IsTeamEffectCharacter(characterId)) + else + grid:UpdateGrid(XRobotManager.GetRobotTemplate(characterId)) + grid:SetArrowUp(false) + end + grid:SetInTeam(self:IsInTeam(characterId)) + grid.GameObject:SetActiveEx(true) + self.CharacterGrids[characterId] = grid + end + + local teamCharIdMap = self.TeamCharIdMap + local teamSelectPos = self.TeamSelectPos + local selectId = teamCharIdMap[teamSelectPos] + local characterType = CharacterTypeConvert[self.SelectTabBtnIndex] + + if not selectId or selectId == 0 + or not self.CharacterGrids[selectId] + or characterType ~= XCharacterConfigs.GetCharacterType(selectId) + or not charDic[selectId] + then + selectId = charlist[1].Id + end + self:SelectCharacter(selectId) +end + +function XUiRogueLikeRoomCharacter:OnCharacterClick(character) + if character then + self.CurCharacter = character + end + if not self.CurCharacter then return end + + if self.CurCharacterItem then + self.CurCharacterItem:SetSelect(false) + end + + local characterId = self.CurCharacter.Id + self.CurCharacterItem = self.CharacterGrids[characterId] + self.CurCharacterItem:UpdateGrid() + self.CurCharacterItem:SetSelect(true) + self.CurCharacterItem:SetInTeam(self:IsInTeam(characterId)) + + -- 更新按钮状态 + self:UpdateBtns(characterId) + self:CenterToGrid(self.CurCharacterItem) + local fashioId = (not self:IsCharacterType()) and character.FashionId or nil + self:UpdateRoleMode(characterId, fashioId) + self.CurCharacterItem:SetArrowUp(self:IsCharacterType() and XDataCenter.FubenRogueLikeManager.IsTeamEffectCharacter(characterId)) +end + +-- 更新按钮状态 +function XUiRogueLikeRoomCharacter:UpdateBtns(curCharacterId) + local isJoin = true + for k, v in pairs(self.TeamCharIdMap) do + if v == curCharacterId then + isJoin = false + end + end + + self.BtnJoinTeam.gameObject:SetActiveEx(isJoin) + self.BtnQuitTeam.gameObject:SetActiveEx(not isJoin) +end + +--更新模型 +function XUiRogueLikeRoomCharacter:UpdateRoleMode(characterId, fashionId) + self.ImgEffectHuanren.gameObject:SetActiveEx(false) + self.ImgEffectHuanren1.gameObject:SetActiveEx(false) + self.RoleModelPanel:UpdateCharacterModel(characterId, self.PanelRoleModel, XModelManager.MODEL_UINAME.XUiRogueLikeRoomCharacter, function(model) + if not model then return end + self.PanelDrag.Target = model.transform + if self.SelectTabBtnIndex == TabBtnIndex.Normal then + self.ImgEffectHuanren.gameObject:SetActiveEx(true) + elseif self.SelectTabBtnIndex == TabBtnIndex.Isomer then + self.ImgEffectHuanren1.gameObject:SetActiveEx(true) + end + end, nil, fashionId) +end + +-- 选一个角色 +function XUiRogueLikeRoomCharacter:SelectCharacter(id) + local grid = self.CharacterGrids[id] + local character = grid and grid.Template + self:OnCharacterClick(character) +end + +function XUiRogueLikeRoomCharacter:CenterToGrid(grid) + -- local normalizedPosition + -- local count = self.SViewCharacterList.content.transform.childCount + -- local index = grid.Transform:GetSiblingIndex() + -- if index > count / 2 then + -- normalizedPosition = (index + 1) / count + -- else + -- normalizedPosition = (index - 1) / count + -- end + -- self.SViewCharacterList.verticalNormalizedPosition = math.max(0, math.min(1, (1 - normalizedPosition))) +end + +function XUiRogueLikeRoomCharacter:IsCharacterType() + return self.Type == XFubenRogueLikeConfig.SelectCharacterType.Character +end + +function XUiRogueLikeRoomCharacter:IsInTeam(characterId) + for _, v in pairs(self.TeamCharIdMap) do + if v == characterId then + return true + end + end + return false +end + +function XUiRogueLikeRoomCharacter:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiRogueLikeRoomCharacter:OnBtnFashionClick() + if not self.CurCharacter then return end + XLuaUiManager.Open("UiFashion", self.CurCharacter.Id) +end + +function XUiRogueLikeRoomCharacter:OnBtnConsciousnessClick() + if not self.CurCharacter then return end + XLuaUiManager.Open("UiEquipAwarenessReplace", self.CurCharacter.Id, nil, true) +end + +function XUiRogueLikeRoomCharacter:OnBtnWeaponClick() + if not self.CurCharacter then return end + XLuaUiManager.Open("UiEquipReplaceNew", self.CurCharacter.Id, nil, true) +end + +-- 加入队伍 +function XUiRogueLikeRoomCharacter:OnBtnJoinTeamClick() + if not self.CurCharacter then return end + + local selectId = self.CurCharacter.Id + local joinFunc = function(isReset) + if self.CallBack then self.CallBack(selectId, true, isReset) end + self:Close() + end + + -- 角色类型不一致拦截 + local inTeamCharacterType = self:GetTeamCharacterType() + if inTeamCharacterType then + local characterType = XCharacterConfigs.GetCharacterType(selectId) + if characterType and characterType ~= inTeamCharacterType then + local content = CSXTextManagerGetText("TeamCharacterTypeNotSame") + local sureCallBack = function() + local isReset = true + joinFunc(isReset) + end + XUiManager.DialogTip(nil, content, XUiManager.DialogType.Normal, nil, sureCallBack) + return + end + end + + joinFunc() +end + +-- 移出队伍 +function XUiRogueLikeRoomCharacter:OnBtnQuitTeamClick() + if not self.CurCharacter then return end + if self.CallBack then + self.CallBack(self.CurCharacter.Id, false) + end + self:Close() +end + +function XUiRogueLikeRoomCharacter:OnBtnBackClick() + self:Close() + if self.CancelCallBack then + self.CancelCallBack() + end +end + +function XUiRogueLikeRoomCharacter:OnBtnFilterClick() + local characterType = CharacterTypeConvert[self.SelectTabBtnIndex] + XLuaUiManager.Open("UiRoomCharacterFilterTips", + self, + XRoomCharFilterTipsConfigs.EnumFilterType.RogueLike, + XRoomCharFilterTipsConfigs.EnumSortType.RogueLike, + characterType, false, not self:IsCharacterType()) +end + +function XUiRogueLikeRoomCharacter:GetTeamCharacterType() + for k, v in pairs(self.TeamCharIdMap) do + if v ~= 0 then + return XCharacterConfigs.GetCharacterType(v) + end + end +end + +function XUiRogueLikeRoomCharacter:Filter(selectTagGroupDic, sortTagId, isThereFilterDataCb) + local judgeCb = function(groupId, tagValue, character) + local detailConfig + if self:IsCharacterType() then + detailConfig = XCharacterConfigs.GetCharDetailTemplate(character.Id) + else + local robotTemplate = XRobotManager.GetRobotTemplate(character.Id) + detailConfig = XCharacterConfigs.GetCharDetailTemplate(robotTemplate.CharacterId) + end + + local compareValue + if groupId == XRoomCharFilterTipsConfigs.EnumFilterTagGroup.Career then + compareValue = detailConfig.Career + if compareValue == tagValue then + -- 当前角色满足该标签 + return true + end + elseif groupId == XRoomCharFilterTipsConfigs.EnumFilterTagGroup.Element then + compareValue = detailConfig.ObtainElementList + for _, element in pairs(compareValue) do + if element == tagValue then + -- 当前角色满足该标签 + return true + end + end + else + XLog.Error(string.format("XUiBfrtRoomCharacter:Filter函数错误,没有处理排序组:%s的逻辑", groupId)) + return + end + end + + local allChar + local characterType = CharacterTypeConvert[self.SelectTabBtnIndex] + if self:IsCharacterType() then + allChar = XDataCenter.CharacterManager.GetOwnCharacterList(characterType) + else + allChar = XDataCenter.FubenRogueLikeManager.GetAssistRobots(characterType) + end + + XDataCenter.RoomCharFilterTipsManager.Filter(self.TagCacheDic, selectTagGroupDic, allChar, judgeCb, + function(filteredData) + self:FilterRefresh(filteredData, sortTagId) + end, + isThereFilterDataCb) +end + +function XUiRogueLikeRoomCharacter:FilterRefresh(filteredData, sortTagId) + if self:IsCharacterType() then + if self.SortFunction[sortTagId] then + table.sort(filteredData, self.SortFunction[sortTagId]) + else + XLog.Error(string.format("XUiBfrtRoomCharacter:FilterRefresh函数错误,没有定义标签:%s的排序函数", sortTagId)) + return + end + end + + self:UpdateCharacterList(filteredData) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeSetTeam.lua b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeSetTeam.lua new file mode 100644 index 00000000..f360ed95 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeSetTeam.lua @@ -0,0 +1,229 @@ +local XUiRogueLikeSetTeam = XClass(nil, "XUiRogueLikeSetTeam") +local XUiGridTopicInfo = require("XUi/XUiFubenRogueLike/XUiGridTopicInfo") +local XUiDayTopicCharacter = require("XUi/XUiFubenRogueLike/XUiDayTopicCharacter") +local XUiRogueLikeMemberHead = require("XUi/XUiFubenRogueLike/XUiRogueLikeMemberHead") +local MaxMemberCount = 3 + +function XUiRogueLikeSetTeam:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + + XTool.InitUiObject(self) + self.BtnTanchuangClose.CallBack = function() self:OnBtnCloseClick() end + self.BtnCancel.CallBack = function() self:OnBtnCloseClick() end + self.BtnConfirm.CallBack = function() self:OnBtnConfirmClick() end + self.BtnBuff.CallBack = function() self:OnBtnBuffClick() end + + self.MemberView = {} + self.GridMemberList = {} + for i = 1, MaxMemberCount do + self.MemberView[i] = self[string.format("TeamMember%d", i)] + self.GridMemberList[i] = XUiRogueLikeMemberHead.New(self.MemberView[i]) + self.GridMemberList[i]:ClearMemberHead() + self.GridMemberList[i]:SetMemberCallBack(function() + self:OnTeamMemberClick(i) + end) + end + + self.GridTopicList = {} + self.GridHeadList = {} + self.ChooseCharList = {} +end + +function XUiRogueLikeSetTeam:ShowSetTeamView() + self.GameObject:SetActiveEx(true) + + self:UpdateThemeHeads() + self:UpdateBuffs() +end + +function XUiRogueLikeSetTeam:CloseSetTeamView() + self.GameObject:SetActiveEx(false) + self.ChooseCharList = {} + for i = 1, MaxMemberCount do + self.GridMemberList[i]:ClearMemberHead() + end +end + +function XUiRogueLikeSetTeam:SetCharacterType(characterLimitType, limitBuffId) + self.CharacterLimitType = characterLimitType + self.LimitBuffId = limitBuffId +end + +function XUiRogueLikeSetTeam:UpdateBuffs() + self.BuffRed.gameObject:SetActiveEx(XDataCenter.FubenRogueLikeManager.HasNewBuffs() > 0) + self.BtnBuff:SetNameByGroup(0, #XDataCenter.FubenRogueLikeManager.GetMyBuffs()) +end + +function XUiRogueLikeSetTeam:GetDayBuffs() + +end + +-- teamEffectId变化 +function XUiRogueLikeSetTeam:UpdateThemeHeads() + local teamEffectId = XDataCenter.FubenRogueLikeManager.GetTeamEffectId() + if XDataCenter.FubenRogueLikeManager.IsSectionPurgatory() then + self.PanelTheme.gameObject:SetActiveEx(false) + self.PanelResetTime.gameObject:SetActiveEx(false) + self.TitleText.text = CS.XTextManager.GetText("RogueLikeSetTeamTitlePurgatory") + self.PanelThemeTrial.gameObject:SetActiveEx(true) + self.TxtTheme1.text = string.gsub(CS.XTextManager.GetText("RogueLikeSetTeamPurRuleValue"), "\\n", "\n") + return + else + self.PanelTheme.gameObject:SetActiveEx(true) + self.PanelResetTime.gameObject:SetActiveEx(true) + self.TitleText.text = CS.XTextManager.GetText("RogueLikeSetTeamTitleNormal") + self.PanelThemeTrial.gameObject:SetActiveEx(false) + end + if teamEffectId <= 0 then return end + local teamEffectTemplate = XFubenRogueLikeConfig.GetTeamEffectTemplateById(teamEffectId) + if not teamEffectTemplate then return end + local dayBuffs = {} + local lock_character = {} + for _, id in pairs(self.ChooseCharList or {}) do + lock_character[id] = true + end + local buff_count = 0 + for _, characterId in pairs(teamEffectTemplate.CharacterId) do + if lock_character[characterId] then + buff_count = buff_count + 1 + end + end + for i, buffId in pairs(teamEffectTemplate.BuffId) do + table.insert(dayBuffs, { + BuffId = buffId, + IsActive = i <= buff_count + }) + end + + -- 今日主题 + for i = 1, #dayBuffs do + if not self.GridTopicList[i] then + local ui = CS.UnityEngine.Object.Instantiate(self.GridThemeBuff.gameObject) + ui.transform:SetParent(self.PanelThemeBuff, false) + ui.gameObject:SetActiveEx(true) + self.GridTopicList[i] = XUiGridTopicInfo.New(ui, self) + end + self.GridTopicList[i].GameObject:SetActiveEx(true) + self.GridTopicList[i]:SetTopicInfo(dayBuffs[i]) + end + for i = #dayBuffs + 1, #self.GridTopicList do + self.GridTopicList[i].GameObject:SetActiveEx(false) + end + + -- 今日角色 + local characterIds = teamEffectTemplate.CharacterId + for i = 1, #characterIds do + local characterId = characterIds[i] + if not self.GridHeadList[i] then + local ui = CS.UnityEngine.Object.Instantiate(self.GridHead.gameObject) + ui.transform:SetParent(self.PanelThemeHead, false) + self.GridHeadList[i] = XUiDayTopicCharacter.New(ui, self) + end + self.GridHeadList[i].GameObject:SetActiveEx(true) + self.GridHeadList[i]:SetTopicInfoById(characterId) + end + for i = #characterIds + 1, #self.GridHeadList do + self.GridHeadList[i].GameObject:SetActiveEx(false) + end +end + +function XUiRogueLikeSetTeam:UpdateResetTime(resetTime) + self.TxtResetTime.text = resetTime +end + +function XUiRogueLikeSetTeam:OnBtnBuffClick() + if #XDataCenter.FubenRogueLikeManager.GetMyBuffs() <= 0 then + XUiManager.TipMsg(CS.XTextManager.GetText("RogueLikeNoneBuff")) + return + end + + XLuaUiManager.Open("UiRogueLikeMyBuff") +end + +function XUiRogueLikeSetTeam:OnTeamMemberClick(index) + local args = {} + args.TeamSelectPos = index + args.TeamCharIdMap = self.ChooseCharList + args.Type = XFubenRogueLikeConfig.SelectCharacterType.Character + args.CharacterLimitType = self.CharacterLimitType + args.LimitBuffId = self.LimitBuffId + args.CallBack = function(selectId, isJoin, isReset) + self:HandleSelectRole(index, selectId, isJoin, isReset) + end + args.CancelCallBack = function() + for i = 1, MaxMemberCount do + self.GridMemberList[i]:SetMemberInfo(self.ChooseCharList[i], true, false) + end + end + XLuaUiManager.Open("UiRogueLikeRoomCharacter", args) +end + +function XUiRogueLikeSetTeam:HandleSelectRole(index, selectId, isJoin, isReset) + if isReset then + self.ChooseCharList = {} + end + + if isJoin then + local oldIndex + local oldMember + for k, v in pairs(self.ChooseCharList) do + if k ~= index and v == selectId then + oldIndex = k + oldMember = v + break + end + end + if oldIndex and oldMember then + self.ChooseCharList[oldIndex] = self.ChooseCharList[index] + self.ChooseCharList[index] = selectId + else + self.ChooseCharList[index] = selectId + end + + else + self.ChooseCharList[index] = nil + end + + for i = 1, MaxMemberCount do + self.GridMemberList[i]:SetMemberInfo(self.ChooseCharList[i], true, false) + end + self:UpdateThemeHeads() +end + +function XUiRogueLikeSetTeam:IsInTeam(characterId) + for _, v in pairs(self.ChooseCharList) do + if v == characterId then + return true + end + end + return false +end + +function XUiRogueLikeSetTeam:OnBtnConfirmClick() + if #self.ChooseCharList < 3 then + XUiManager.TipMsg(CS.XTextManager.GetText("RogueLikeTeamMaxMember")) + return + end + + local title = CS.XTextManager.GetText("RogueLikeSetTeamTitle") + local content = CS.XTextManager.GetText("RogueLikeSetTeamContent") + local sureFunc = function() + XDataCenter.FubenRogueLikeManager.RogueLikeSetTeam(self.ChooseCharList, function() + self:CloseSetTeamView() + end) + end + + XUiManager.DialogTip(title, content, XUiManager.DialogType.Normal, function() + end, function() + sureFunc() + end) + +end + +function XUiRogueLikeSetTeam:OnBtnCloseClick() + self:CloseSetTeamView() +end + +return XUiRogueLikeSetTeam \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeShop.lua b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeShop.lua new file mode 100644 index 00000000..299da55c --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeShop.lua @@ -0,0 +1,220 @@ +local XUiRogueLikeShop = XLuaUiManager.Register(XLuaUi, "UiRogueLikeShop") +local XUiGridNodeShopItem = require("XUi/XUiFubenRogueLike/XUiGridNodeShopItem") +local XUiNodeShopBuyDetails = require("XUi/XUiFubenRogueLike/XUiNodeShopBuyDetails") + +function XUiRogueLikeShop:OnAwake() + + self.NodeShopBuyDetails = XUiNodeShopBuyDetails.New(self.PanelShopItem, self) + self.DynamicTable = XDynamicTableNormal.New(self.PanelItemList.gameObject) + self.DynamicTable:SetProxy(XUiGridNodeShopItem) + self.DynamicTable:SetDelegate(self) + + + self.BtnClose.CallBack = function() self:OnBtnCloseClick() end + self.BtnTanchuangClose.CallBack = function() self:OnBtnTanchuangClose() end + + self.BtnBuy.CallBack = function() self:OnBtnBuyClick() end + self.Discount = 100 + + self.RogueLikeActivityAsset = XUiPanelAsset.New(self, self.PanelActivityAsset, XFubenRogueLikeConfig.ChallengeCoin, XFubenRogueLikeConfig.PumpkinCoin, XFubenRogueLikeConfig.KeepsakeCoin) + + XEventManager.AddEventListener(XEventId.EVENT_ROGUELIKE_ACTIONPOINT_CHARACTER_CHANGED, self.CheckDiscoountChanged, self) + XEventManager.AddEventListener(XEventId.EVENT_ROGUELIKE_BUFFIDS_CHANGES, self.CheckDiscoountChanged, self) + XEventManager.AddEventListener(XEventId.EVENT_ROGUELIKE_TEAMEFFECT_CHANGES, self.CheckDiscoountChanged, self) + XEventManager.AddEventListener(XEventId.EVENT_ROGUELIKE_ILLEGAL_SHOP_RESET, self.OnShopReset, self) +end + +function XUiRogueLikeShop:OnDestroy() + XEventManager.RemoveEventListener(XEventId.EVENT_ROGUELIKE_ACTIONPOINT_CHARACTER_CHANGED, self.CheckDiscoountChanged, self) + XEventManager.RemoveEventListener(XEventId.EVENT_ROGUELIKE_BUFFIDS_CHANGES, self.CheckDiscoountChanged, self) + XEventManager.RemoveEventListener(XEventId.EVENT_ROGUELIKE_TEAMEFFECT_CHANGES, self.CheckDiscoountChanged, self) + XEventManager.RemoveEventListener(XEventId.EVENT_ROGUELIKE_ILLEGAL_SHOP_RESET, self.OnShopReset, self) +end + +function XUiRogueLikeShop:OnShopReset() + if XLuaUiManager.IsUiShow("UiRogueLikeShop") then + XLuaUiManager.Close("UiRogueLikeShop") + end + if XLuaUiManager.IsUiShow("UiRogueLikeFightTips") then + XLuaUiManager.Close("UiRogueLikeFightTips") + end +end + +function XUiRogueLikeShop:CheckDiscoountChanged() + local discount = XDataCenter.FubenRogueLikeManager.GetNodeShopDiscount() + if self.Discount ~= discount then + self.Discount = discount + -- 刷新商品 + if self.NodeItemList then + for i = 1, #self.NodeItemList do + self.NodeItemList[i].Discount = self.Discount + local grid = self.DynamicTable:GetGridByIndex(i) + if grid then + grid:UpdatePriceByDiscount(self.Discount) + grid:SetSaleRate(self.Discount) + end + end + end + -- 刷新详情 + self:UpdateBuyShopItemInfo() + end +end + +-- 打开购买详情 +function XUiRogueLikeShop:OpenBuyDetails(shopItem) + self.NodeShopBuyDetails:ShowBlackShopDetails(shopItem, self.Node) +end + +function XUiRogueLikeShop:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.NodeItemList[index] + if not data then + return + end + grid.RootUi = self + grid:SetItemData(data) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + for i = 1, #self.NodeItemList do + local data = self.NodeItemList[i] + data.IsSelect = i == index + local lastGrid = self.DynamicTable:GetGridByIndex(i) + if lastGrid then + lastGrid:SetItemSelect(data.IsSelect) + end + end + self.CurrentSelectIndex = index + self:UpdateBuyShopItemInfo() + + end +end + +function XUiRogueLikeShop:OnStart(node, eventNode) + self.Node = node + self.EventNode = eventNode + + self.NodeTemplate = XFubenRogueLikeConfig.GetNodeTemplateById(self.Node.Id) + self.ShopId = self.NodeTemplate.Param[1] + + if self.EventNode then + self.EventNodeTemplate = XFubenRogueLikeConfig.GetNodeTemplateById(self.EventNode.Id) + self.ShopId = self.EventNodeTemplate.Param[1] + end + + self:RefreshShopItems() +end + +function XUiRogueLikeShop:OnEnable() + XDataCenter.FubenRogueLikeManager.CheckRogueLikeDayResetOnUi("UiRogueLikeShop") +end + +function XUiRogueLikeShop:RefreshShopItems() + self.NodeShopInfo = XDataCenter.FubenRogueLikeManager.GetNodeShopInfoById(self.ShopId) + self.NodeShopIds = {} + self.NodeShopBuyItemInfos = {} + if self.NodeShopInfo then + for _, itemId in pairs(self.NodeShopInfo.ShopItems or {}) do + self.NodeShopIds[itemId] = true + end + + for _, itemInfo in pairs(self.NodeShopInfo.ItemsInfos or {}) do + self.NodeShopBuyItemInfos[itemInfo.Id] = itemInfo.BuyCount + end + end + + -- 填充数据 + self.NodeShopTemplate = XFubenRogueLikeConfig.GetShopTemplateById(self.ShopId) + if not self.NodeShopTemplate then return end + + self.Discount = XDataCenter.FubenRogueLikeManager.GetNodeShopDiscount() + self.NodeItemList = {} + for i = 1, #self.NodeShopTemplate.ShopItemId do + local shopItemId = self.NodeShopTemplate.ShopItemId[i] + local buyCount = self.NodeShopTemplate.BuyCount[i] + + if self.NodeShopIds[shopItemId] then + table.insert(self.NodeItemList, { + ShopItemId = shopItemId, + TotalBuyCount = buyCount, + BuyCount = buyCount - (self.NodeShopBuyItemInfos[shopItemId] or 0), + Discount = self.Discount, + IsSelect = false, + }) + end + end + self.DynamicTable:SetDataSource(self.NodeItemList) + self.DynamicTable:ReloadDataASync() + self.ImgEmpty.gameObject:SetActiveEx(#self.NodeItemList <= 0) + self.PanelBuy.gameObject:SetActiveEx(false) +end + + +function XUiRogueLikeShop:OnBtnCloseClick() + self:Close() +end + +function XUiRogueLikeShop:OnBtnTanchuangClose() + self:Close() +end + +function XUiRogueLikeShop:UpdateBuyShopItemInfo() + if self.CurrentSelectIndex and self.NodeItemList and self.NodeItemList[self.CurrentSelectIndex] then + self.PanelBuy.gameObject:SetActiveEx(true) + local shopItem = self.NodeItemList[self.CurrentSelectIndex] + -- 更新信息 + local shopItemTemplate = XFubenRogueLikeConfig.GetShopItemTemplateById(shopItem.ShopItemId) + if not shopItemTemplate then return end + local itemId = shopItemTemplate.ConsumeId[1] + local itemNum = math.ceil(shopItemTemplate.ConsumeNum[1] * (self.Discount * 1.0 / 100)) + local itemName = XDataCenter.ItemManager.GetItemName(itemId) + + local buyItemName + -- 这里购买的是buff,不存在说明配表有问题 + if shopItemTemplate.Type == XFubenRogueLikeConfig.XRLShopItemType.Buff then + local buffConfig = XFubenRogueLikeConfig.GetBuffConfigById(shopItemTemplate.Param[1]) + buyItemName = buffConfig.Name + elseif shopItemTemplate.Type == XFubenRogueLikeConfig.XRLShopItemType.Item then + local id = shopItemTemplate.Param[1] + buyItemName = XDataCenter.ItemManager.GetItemName(id) + + elseif shopItemTemplate.Type == XFubenRogueLikeConfig.XRLShopItemType.Robot then + buyItemName = CS.XTextManager.GetText("RogueLikeRandomRobotTitle") + end + self.TxtTips.text = CS.XTextManager.GetText("RogueLikeShopBuyItemTips", itemNum, itemName, buyItemName) + end +end + +function XUiRogueLikeShop:OnBtnBuyClick() + if self.CurrentSelectIndex and self.NodeItemList and self.NodeItemList[self.CurrentSelectIndex] then + local shopItem = self.NodeItemList[self.CurrentSelectIndex] + if shopItem.BuyCount <= 0 then + XUiManager.TipMsg(CS.XTextManager.GetText("RogueLikeShopItemSellOut")) + return + end + + local shopItemTemplate = XFubenRogueLikeConfig.GetShopItemTemplateById(shopItem.ShopItemId) + if shopItemTemplate then + + -- 机器人满了,不可以继续购买 + if shopItemTemplate.Type == XFubenRogueLikeConfig.XRLShopItemType.Robot then + if XDataCenter.FubenRogueLikeManager.IsAssistRobotFull() then + XUiManager.TipMsg(CS.XTextManager.GetText("RogueLikeSupportCharFull")) + return + end + end + + local itemId = shopItemTemplate.ConsumeId[1] + local itemNum = math.ceil(shopItemTemplate.ConsumeNum[1] * (self.Discount * 1.0 / 100)) + local ownCount = XDataCenter.ItemManager.GetCount(itemId) + if ownCount < itemNum then + XUiManager.TipMsg(CS.XTextManager.GetText("RogueLikeBuyNotEnough")) + return + end + end + -- 花费RogueLikeBuyNotEnough + XDataCenter.FubenRogueLikeManager.NodeBuy(self.Node.Id, shopItem.ShopItemId, 1, function() + -- 更新商品界面 + self:RefreshShopItems() + end) + end +end + diff --git a/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeShopEntrance.lua b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeShopEntrance.lua new file mode 100644 index 00000000..d19d1812 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeShopEntrance.lua @@ -0,0 +1,45 @@ +local XUiRogueLikeShopEntrance = XClass(nil, "XUiRogueLikeShopEntrance") + +function XUiRogueLikeShopEntrance:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + + XTool.InitUiObject(self) + self.BtnOpen.CallBack = function() self:OnBtnOpenClick() end + self.BtnBack.CallBack = function() self:OnBtnBackClick() end +end + + +function XUiRogueLikeShopEntrance:UpdateByNode(node, eventNode) + self.Node = node + self.EventNode = (eventNode == nil) and node or eventNode + self.NodeTemplate = XFubenRogueLikeConfig.GetNodeTemplateById(self.EventNode.Id) + self.NodeConfig = XFubenRogueLikeConfig.GetNodeConfigteById(self.EventNode.Id) + + self.TxtName.text = self.NodeConfig.Name + self.RImgIcon:SetRawImage(self.NodeConfig.Icon) + self.TxtRest.text = self.NodeConfig.Description +end + +function XUiRogueLikeShopEntrance:OnBtnOpenClick() + if self.Node then + XLuaUiManager.Open("UiRogueLikeShop", self.Node, self.EventNode) + end +end + +function XUiRogueLikeShopEntrance:OnBtnBackClick() + if not self.Node then return end + local title = CS.XTextManager.GetText("RogueLikeLeaveShopTitle") + local content = CS.XTextManager.GetText("RogueLikeLeaveShopContent") + + XUiManager.DialogTip(title, content, XUiManager.DialogType.Normal, function() + end, function() + XDataCenter.FubenRogueLikeManager.FinishNode(self.Node.Id, function() + self.UiRoot:Close() + end) + end) + +end + +return XUiRogueLikeShopEntrance \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeStoryEntrance.lua b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeStoryEntrance.lua new file mode 100644 index 00000000..a5c3ca1e --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeStoryEntrance.lua @@ -0,0 +1,268 @@ +local XUiRogueLikeStoryEntrance = XClass(nil, "XUiRogueLikeStoryEntrance") + +function XUiRogueLikeStoryEntrance:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + + XTool.InitUiObject(self) + self.OptionsList = {} +end + +function XUiRogueLikeStoryEntrance:UpdateByNode(node) + self.Node = node + self.NodeTemplate = XFubenRogueLikeConfig.GetNodeTemplateById(self.Node.Id) + self.NodeConfig = XFubenRogueLikeConfig.GetNodeConfigteById(self.Node.Id) + local sectionInfo = XDataCenter.FubenRogueLikeManager.GetCurSectionInfo() + local selectNodeInfo = sectionInfo.SelectNodeInfo[self.Node.Id] + if not selectNodeInfo then return end + self.EventId = selectNodeInfo.EventId + self.EventTemplate = XFubenRogueLikeConfig.GetEventTemplateById(self.EventId) + if not self.EventTemplate then return end + + self.TxtName.text = self.NodeConfig.Name + self.RImgIcon:SetRawImage(self.NodeConfig.Icon) + self.TxtStory.text = self.NodeConfig.Description + + self:ShowSpecialEventGroupView() +--[[不存在单个事件组、统一当成多个事件组 + -- 根据事件类型收集 + if XFubenRogueLikeConfig.IsSpecialGroupType(self.NodeTemplate.Type) then + self:ShowSpecialEventGroupView() + else + -- 展示event表中的选项,拱玩家选择 + self:ShowSpecialEventView() + end + --]] +end + +-- 显示事件组特殊事件 +function XUiRogueLikeStoryEntrance:ShowSpecialEventGroupView() + -- self.SpecailEventGroupTemplate = XFubenRogueLikeConfig.GetSepcialEventGroupTemplateById(self.EventId) + self.SpecialEventGroupConfig = XFubenRogueLikeConfig.GetSpecialEventGroupConfigById(self.EventId) + + self.CurrentGroupItemConfig = XFubenRogueLikeConfig.GetSpecialEventGroupItemConfigById(self.SpecialEventGroupConfig.GroupItemId) + self:UpdateSpecialEventGroupItem() +end + +-- 更新跳转页面 +function XUiRogueLikeStoryEntrance:UpdateSpecialEventGroupItem() + self.SpecialEventGroupList = {} + if self.SpecialEventGroupConfig.IsEnd == 1 then + self.TxtName.text = self.NodeConfig.Name + self.RImgIcon:SetRawImage(self.NodeConfig.Icon) + self.TxtStory.text = self.NodeConfig.Description + + for i = 1, #self.EventTemplate.Param do + local groupId = self.EventTemplate.Param[i] + + table.insert(self.SpecialEventGroupList, { + OptionId = groupId, + IsEnd = true, + Title = self.SpecialEventGroupConfig.OptionDesc[i], + }) + end + if self.SpecialEventGroupConfig.HasLeave == 1 then + table.insert(self.SpecialEventGroupList, { + IsEnd = false, + IsLeave = true, + Title = CS.XTextManager.GetText("RogueLikeOptionLeave") + }) + end + elseif self.CurrentGroupItemConfig.IsEnd == 1 then + self.TxtName.text = self.CurrentGroupItemConfig.Title + self.RImgIcon:SetRawImage(self.CurrentGroupItemConfig.Icon) + self.TxtStory.text = self.CurrentGroupItemConfig.Description + + for i = 1, #self.CurrentGroupItemConfig.OptionId do + local optionIdx = self.CurrentGroupItemConfig.OptionId[i] + local groupId = self.EventTemplate.Param[optionIdx] + table.insert(self.SpecialEventGroupList, { + OptionId = groupId, + IsEnd = true, + Title = self.SpecialEventGroupConfig.OptionDesc[optionIdx], + }) + end + if self.SpecialEventGroupConfig.HasLeave == 1 then + table.insert(self.SpecialEventGroupList, { + IsEnd = false, + IsLeave = true, + Title = CS.XTextManager.GetText("RogueLikeOptionLeave") + }) + end + else + self.TxtName.text = self.CurrentGroupItemConfig.Title + self.RImgIcon:SetRawImage(self.CurrentGroupItemConfig.Icon) + self.TxtStory.text = self.CurrentGroupItemConfig.Description + for i = 1, #self.CurrentGroupItemConfig.OptionId do + local optionId = self.CurrentGroupItemConfig.OptionId[i] + table.insert(self.SpecialEventGroupList, { + OptionId = optionId, + IsEnd = false, + Title = self.CurrentGroupItemConfig.OptionDesc[i] + }) + end + if self.CurrentGroupItemConfig.HasLeave == 1 then + table.insert(self.SpecialEventGroupList, { + IsEnd = false, + IsLeave = true, + Title = CS.XTextManager.GetText("RogueLikeOptionLeave") + }) + end + end + for i = 1, #self.SpecialEventGroupList do + local specialEventGroupItem = self.SpecialEventGroupList[i] + if not self.OptionsList[i] then + local optionUi = CS.UnityEngine.Object.Instantiate(self.BtnOption) + optionUi.transform:SetParent(self.PanelOption.transform, false) + self.OptionsList[i] = optionUi.transform:GetComponent("XUiButton") + self.OptionsList[i].CallBack = function() self:OnSubOptionsClick(i) end + end + self.OptionsList[i].gameObject:SetActiveEx(true) + self.OptionsList[i]:SetNameByGroup(0, specialEventGroupItem.Title) + end + for i = #self.SpecialEventGroupList + 1, #self.OptionsList do + self.OptionsList[i].gameObject:SetActiveEx(false) + end +end + +-- 点击特殊事件的子选项 +function XUiRogueLikeStoryEntrance:OnSubOptionsClick(index) + if self.SpecialEventGroupList and self.SpecialEventGroupList[index] and self.Node then + local specialEventGroupItem = self.SpecialEventGroupList[index] + -- 离开选项 + if specialEventGroupItem.IsLeave then + XDataCenter.FubenRogueLikeManager.FinishNode(self.Node.Id, function() + self.UiRoot:Close() + end) + else + -- 非离开选项 + -- 结束 + if specialEventGroupItem.IsEnd then + -- 检查兑换物品选项 + local specialEventGroupTemplate = XFubenRogueLikeConfig.GetSepcialEventGroupTemplateById(specialEventGroupItem.OptionId) + for i = 1, #specialEventGroupTemplate.EventId do + local currentEventId = specialEventGroupTemplate.EventId[i] + local specialEventTemplate = XFubenRogueLikeConfig.GetSpecialEventTemplateById(currentEventId) + if self:CheckExchangeItem(specialEventTemplate) then + return + end + end + XDataCenter.FubenRogueLikeManager.SelectSpecialEventGroup(self.Node.Id, specialEventGroupItem.OptionId, function() + self.UiRoot:Close() + end) + else + -- 更新选项 + self.CurrentGroupItemConfig = XFubenRogueLikeConfig.GetSpecialEventGroupItemConfigById(specialEventGroupItem.OptionId) + self:UpdateSpecialEventGroupItem() + end + end + end +end + +-- 显示一般的特殊事件 +function XUiRogueLikeStoryEntrance:ShowSpecialEventView() + local eventId = self.NodeTemplate.Param[1] + self.EventTemplate = XFubenRogueLikeConfig.GetEventTemplateById(eventId) + if not self.EventTemplate then + XLog.ErrorTableDataNotFound("XFubenRogueLikeConfig.GetEventTemplateById", + "RogueLikeEvent", "Share/Fuben/RogueLike/RogueLikeEvent.tab", "Id", tostring(eventId)) + return + end + + self.SpecitalEventList = {} + for i = 1, #self.EventTemplate.Param do + local specialEventId = self.EventTemplate.Param[i] + local specialTemplate = XFubenRogueLikeConfig.GetSpecialEventTemplateById(specialEventId) + local specialConfig = XFubenRogueLikeConfig.GetSpecialEventConfigById(specialEventId) + table.insert(self.SpecitalEventList, { + SpecitalEventId = specialEventId, + SpecialTemplate = specialTemplate, + SpecialConfig = specialConfig, + }) + end + + for i = 1, #self.SpecitalEventList do + local specailEventItems = self.SpecitalEventList[i] + if not self.OptionsList[i] then + local optionUi = CS.UnityEngine.Object.Instantiate(self.BtnOption) + optionUi.transform:SetParent(self.PanelOption.transform, false) + self.OptionsList[i] = optionUi.transform:GetComponent("XUiButton") + self.OptionsList[i].CallBack = function() self:OnOptionsClick(i) end + end + self.OptionsList[i].gameObject:SetActiveEx(true) + self.OptionsList[i]:SetNameByGroup(0, specailEventItems.SpecialConfig.Title) + end + -- 处理多余的 + for i = #self.SpecitalEventList + 1, #self.OptionsList do + self.OptionsList[i].gameObject:SetActiveEx(false) + end +end + + +-- 点击选项 +function XUiRogueLikeStoryEntrance:OnOptionsClick(index) + if self.SpecitalEventList and self.SpecitalEventList[index] and self.Node then + local specialEventId = self.SpecitalEventList[index].SpecitalEventId + local specialTemplate = self.SpecitalEventList[index].SpecialTemplate + + -- 检查兑换物品 + -- 兑换所需{0}{1}不足 + if self:CheckExchangeItem(specialTemplate) then + return + end + + XDataCenter.FubenRogueLikeManager.SelectSpecialEvent(self.Node.Id, specialEventId, function() + -- 打开获得界面 + self.UiRoot:Close() + XLuaUiManager.Open("UiRogueLikeStoryResult", specialEventId, XFubenRogueLikeConfig.SpecialResultType.SingleEvent) + end) + end +end + +-- 检查减少行动点 +function XUiRogueLikeStoryEntrance:CheckCostActionPoint(specialTemplate) + if specialTemplate.Type == XFubenRogueLikeConfig.XRLOtherEventType.ActionPoint then + local needActionPoint = specialTemplate.Param[1] + local ownActionPoint = XDataCenter.FubenRogueLikeManager.GetRogueLikeActionPoint() + if needActionPoint > ownActionPoint then + XUiManager.TipMsg(CS.XTextManager.GetText("RogueLikeOutOfActionPoint", needActionPoint)) + return true + end + end + return false +end + +-- 检查消耗物品 +function XUiRogueLikeStoryEntrance:CheckConsumeItem(specialTemplate) + if specialTemplate.Type == XFubenRogueLikeConfig.XRLOtherEventType.ConsumeItem then + local itemId = specialTemplate.Param[1] + local itemName = XDataCenter.ItemManager.GetItemName(itemId) + local itemNum = specialTemplate.Param[2] + local ownCount = XDataCenter.ItemManager.GetCount(itemId) + if itemNum > ownCount then + XUiManager.TipMsg(CS.XTextManager.GetText("RogueLikeCostItemTips", itemNum, itemName)) + return true + end + end + return false +end + +-- 兑换物品检查 +function XUiRogueLikeStoryEntrance:CheckExchangeItem(specialTemplate) + if specialTemplate.Type == XFubenRogueLikeConfig.XRLOtherEventType.ExchangeItem then + local shopItemId = specialTemplate.Param[1] + local shopItemTemplate = XFubenRogueLikeConfig.GetShopItemTemplateById(shopItemId) + local itemId = shopItemTemplate.ConsumeId[1] + local itemName = XDataCenter.ItemManager.GetItemName(itemId) + local itemNum = shopItemTemplate.ConsumeNum[1] + local ownCount = XDataCenter.ItemManager.GetCount(itemId) + if itemNum > ownCount then + XUiManager.TipMsg(CS.XTextManager.GetText("RogueLikeExchangeItemTips", itemNum, itemName)) + return true + end + end + return false +end + +return XUiRogueLikeStoryEntrance \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeStoryResult.lua b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeStoryResult.lua new file mode 100644 index 00000000..d0e2a79f --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeStoryResult.lua @@ -0,0 +1,311 @@ +local XUiRogueLikeStoryResult = XLuaUiManager.Register(XLuaUi, "UiRogueLikeStoryResult") +local XUiGridBuffInfoItem = require("XUi/XUiFubenRogueLike/XUiGridBuffInfoItem") + +function XUiRogueLikeStoryResult:OnAwake() + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnConfirm.CallBack = function() self:OnBtnConfirmClick() end + + self.CommonList = {} + self.BuffList = {} + +end + +function XUiRogueLikeStoryResult:OnStart(specialEventId, specialEventType) + self.SpecialEventId = specialEventId + self.SpecialEventType = specialEventType + self:HandleSingleSpecialEvent() + self:HandleMultipleSpecialEvents() +end + +function XUiRogueLikeStoryResult:OnEnable() + XDataCenter.FubenRogueLikeManager.CheckRogueLikeDayResetOnUi("UiRogueLikeStoryResult") +end + +-- 单个特殊事件 +function XUiRogueLikeStoryResult:HandleSingleSpecialEvent() + if self.SpecialEventType ~= XFubenRogueLikeConfig.SpecialResultType.SingleEvent then return end + self.SpecialEventTemplate = XFubenRogueLikeConfig.GetSpecialEventTemplateById(self.SpecialEventId) + self.SpecialEventConfig = XFubenRogueLikeConfig.GetSpecialEventConfigById(self.SpecialEventId) + self.SpecialEventType = self.SpecialEventTemplate.Type + + self.TxtResult.text = self.SpecialEventConfig.Description + + self:HandleAddBuff() + self:HandleRemoveBuff() + self:HandleAddRobot() + self:HandleAddHp() + self:HandleAddActionPoint() + self:HandleRemoveActionPoint() + self:HandleGainItem() + self:HandleExchangeItem() + self:HandleConsumeItem() + self:HandleReduceHp() + self:HandleGainItemRate() + self:HandleConsumeItemRate() +end + +-- 多个特殊事件 +function XUiRogueLikeStoryResult:HandleMultipleSpecialEvents() + if self.SpecialEventType ~= XFubenRogueLikeConfig.SpecialResultType.MultipleEvent then return end + self.SpecialEventResultInfos = self.SpecialEventId + local result = "" + local resultCount = #self.SpecialEventResultInfos + + local commonReward = {} + local buffReward = {} + + for i = 1, resultCount do + local resultInfo = self.SpecialEventResultInfos[i] + local specialEventTemplate = XFubenRogueLikeConfig.GetSpecialEventTemplateById(resultInfo.Id) + local specialEventConfig = XFubenRogueLikeConfig.GetSpecialEventConfigById(resultInfo.Id) + + local perResult = CS.XTextManager.FormatString(specialEventConfig.Description, resultInfo.Value) + if specialEventTemplate.Type == XFubenRogueLikeConfig.XRLOtherEventType.AddRobot then + if XDataCenter.FubenRogueLikeManager.IsAssistRobotFull() then + perResult = CS.XTextManager.GetText("RogueLikeEventFullRobot") + end + end + if result == "" then + result = perResult + else + result = string.format("%s%s", result, perResult) + end + + -- 收集道具、buff奖励 + if specialEventTemplate.Type == XFubenRogueLikeConfig.XRLOtherEventType.ExchangeItem then + local shopItemId = specialEventTemplate.Param[1] + local shopItemTemplate = XFubenRogueLikeConfig.GetShopItemTemplateById(shopItemId) + if shopItemTemplate.Type == XFubenRogueLikeConfig.XRLShopItemType.Item then + table.insert(commonReward, { + Id = shopItemTemplate.Param[1], + Count = shopItemTemplate.Param[2] or 1, + }) + elseif shopItemTemplate.Type == XFubenRogueLikeConfig.XRLShopItemType.Buff then + table.insert(buffReward, shopItemTemplate.Param[1]) + end + elseif specialEventTemplate.Type == XFubenRogueLikeConfig.XRLOtherEventType.GainItem then + local paramCount = #specialEventTemplate.Param + local itemCount = paramCount / 2 + for idx = 1, itemCount do + table.insert(commonReward, { + Id = specialEventTemplate.Param[(idx - 1) * 2 + 1], + Count = specialEventTemplate.Param[idx * 2], + }) + end + elseif specialEventTemplate.Type == XFubenRogueLikeConfig.XRLOtherEventType.AddBuff then + for index = 1, #specialEventTemplate.Param do + table.insert(buffReward, specialEventTemplate.Param[index]) + end + end + + end + self.TxtResult.text = result + -- 展示特殊事件组收集到的奖励 + self:ShowBothTypeReward(commonReward, buffReward) +end + +-- 消耗物品百分比 +function XUiRogueLikeStoryResult:HandleConsumeItemRate() + if self.SpecialEventType == XFubenRogueLikeConfig.XRLOtherEventType.ConsumeItemRate then + self:DontShowReward() + end +end + +-- 获得物品百分比 +function XUiRogueLikeStoryResult:HandleGainItemRate() + if self.SpecialEventType == XFubenRogueLikeConfig.XRLOtherEventType.GainItemRate then + self:DontShowReward() + end +end + +-- 减少血量 +function XUiRogueLikeStoryResult:HandleReduceHp() + if self.SpecialEventType == XFubenRogueLikeConfig.XRLOtherEventType.ReduceHp then + self:DontShowReward() + end +end + +-- 消耗物品 +function XUiRogueLikeStoryResult:HandleConsumeItem() + if self.SpecialEventType == XFubenRogueLikeConfig.XRLOtherEventType.ConsumeItem then + self:DontShowReward() + end +end + +-- 兑换物品 +function XUiRogueLikeStoryResult:HandleExchangeItem() + if self.SpecialEventType == XFubenRogueLikeConfig.XRLOtherEventType.ExchangeItem then + local shopItemId = self.SpecialEventTemplate.Param[1] + local shopItemTemplate = XFubenRogueLikeConfig.GetShopItemTemplateById(shopItemId) + if shopItemTemplate.Type == XFubenRogueLikeConfig.XRLShopItemType.Item then + local items = {} + table.insert(items, { + Id = shopItemTemplate.Param[1], + Count = shopItemTemplate.Param[2] or 1, + }) + self:ShowRewardCommon(items) + elseif shopItemTemplate.Type == XFubenRogueLikeConfig.XRLShopItemType.Buff then + local buffs = {} + table.insert(buffs, shopItemTemplate.Param[1]) + self:ShowRewardBuff(buffs) + + elseif shopItemTemplate.Type == XFubenRogueLikeConfig.XRLShopItemType.Robot then + self:DontShowReward() + else + self:DontShowReward() + end + end +end + +-- 获得物品 +function XUiRogueLikeStoryResult:HandleGainItem() + if self.SpecialEventType == XFubenRogueLikeConfig.XRLOtherEventType.GainItem then + local items = {} + local paramCount = #self.SpecialEventTemplate.Param + local itemCount = paramCount / 2 + for i = 1, itemCount do + table.insert(items, { + Id = self.SpecialEventTemplate.Param[(i - 1) * 2 + 1], + Count = self.SpecialEventTemplate.Param[i * 2], + }) + end + self:ShowRewardCommon(items) + end +end + +-- 减少行动点 +function XUiRogueLikeStoryResult:HandleRemoveActionPoint() + if self.SpecialEventType == XFubenRogueLikeConfig.XRLOtherEventType.ActionPoint then + self:DontShowReward() + end +end + +-- 增加行动点 +function XUiRogueLikeStoryResult:HandleAddActionPoint() + if self.SpecialEventType == XFubenRogueLikeConfig.XRLOtherEventType.AddActionPoint then + self:DontShowReward() + end +end + +-- 血量恢复 +function XUiRogueLikeStoryResult:HandleAddHp() + if self.SpecialEventType == XFubenRogueLikeConfig.XRLOtherEventType.AddHp then + self:DontShowReward() + end +end + +-- 获得助战机器人 +function XUiRogueLikeStoryResult:HandleAddRobot() + if self.SpecialEventType == XFubenRogueLikeConfig.XRLOtherEventType.AddRobot then + self:DontShowReward() + end +end + +-- 移出buff +function XUiRogueLikeStoryResult:HandleRemoveBuff() + if self.SpecialEventType == XFubenRogueLikeConfig.XRLOtherEventType.RemoveBuff then + self:DontShowReward() + end +end + +-- 获得buff +function XUiRogueLikeStoryResult:HandleAddBuff() + if self.SpecialEventType == XFubenRogueLikeConfig.XRLOtherEventType.AddBuff then + self:ShowRewardBuff(self.SpecialEventTemplate.Param) + end +end + +function XUiRogueLikeStoryResult:DontShowReward() + self.TextTitle.gameObject:SetActiveEx(false) + + for i = 1, #self.CommonList do + self.CommonList[i].GameObject:SetActiveEx(false) + end + + for i = 1, #self.BuffList do + self.BuffList[i].GameObject:SetActiveEx(false) + end +end + +-- 同时拥有两种奖励 +function XUiRogueLikeStoryResult:ShowBothTypeReward(items, buffIds) + self.TextTitle.gameObject:SetActiveEx(#items > 0 or #buffIds > 0) + + for i = 1, #items do + if not self.CommonList[i] then + local ui = CS.UnityEngine.Object.Instantiate(self.Grid128) + ui.transform:SetParent(self.GridReward, false) + self.CommonList[i] = XUiGridCommon.New(self, ui) + end + self.CommonList[i].GameObject:SetActiveEx(true) + self.CommonList[i]:Refresh(items[i]) + end + + for i = #items + 1, #self.CommonList do + self.CommonList[i].GameObject:SetActiveEx(false) + end + + for i = 1, #buffIds do + if not self.BuffList[i] then + local ui = CS.UnityEngine.Object.Instantiate(self.GridBuff) + ui.transform:SetParent(self.GridReward, false) + self.BuffList[i] = XUiGridBuffInfoItem.New(self, ui) + end + self.BuffList[i].GameObject:SetActiveEx(true) + self.BuffList[i]:SetBuffInfoById(buffIds[i]) + end + + for i = #buffIds + 1, #self.BuffList do + self.BuffList[i].GameObject:SetActiveEx(false) + end + +end + +function XUiRogueLikeStoryResult:ShowRewardBuff(buffIds) + for i = 1, #self.CommonList do + self.CommonList[i].GameObject:SetActiveEx(false) + end + self.TextTitle.gameObject:SetActiveEx(#buffIds > 0) + for i = 1, #buffIds do + if not self.BuffList[i] then + local ui = CS.UnityEngine.Object.Instantiate(self.GridBuff) + ui.transform:SetParent(self.GridReward, false) + self.BuffList[i] = XUiGridBuffInfoItem.New(self, ui) + end + self.BuffList[i].GameObject:SetActiveEx(true) + self.BuffList[i]:SetBuffInfoById(buffIds[i]) + end + + for i = #buffIds + 1, #self.BuffList do + self.BuffList[i].GameObject:SetActiveEx(false) + end +end + +-- {Id,Count} +function XUiRogueLikeStoryResult:ShowRewardCommon(items) + for i = 1, #self.BuffList do + self.BuffList[i].GameObject:SetActiveEx(false) + end + self.TextTitle.gameObject:SetActiveEx(#items > 0) + for i = 1, #items do + if not self.CommonList[i] then + local ui = CS.UnityEngine.Object.Instantiate(self.Grid128) + ui.transform:SetParent(self.GridReward, false) + self.CommonList[i] = XUiGridCommon.New(self, ui) + end + self.CommonList[i].GameObject:SetActiveEx(true) + self.CommonList[i]:Refresh(items[i]) + end + + for i = #items + 1, #self.CommonList do + self.CommonList[i].GameObject:SetActiveEx(false) + end +end + +function XUiRogueLikeStoryResult:OnBtnBackClick() + self:Close() +end + +function XUiRogueLikeStoryResult:OnBtnConfirmClick() + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeSupportCharItem.lua b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeSupportCharItem.lua new file mode 100644 index 00000000..919232d1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeSupportCharItem.lua @@ -0,0 +1,25 @@ +local XUiRogueLikeSupportCharItem = XClass(nil, "XUiRogueLikeSupportCharItem") + +function XUiRogueLikeSupportCharItem:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + + XTool.InitUiObject(self) +end + + +function XUiRogueLikeSupportCharItem:UpdateCharacterInfos(robotId) + self.RobotId = robotId + self.GameObject:SetActiveEx(self.RobotId ~= nil) + if self.RobotId ~= nil then + local characterId = XRobotManager.GetCharacterId(robotId) + if characterId == nil then + self.GameObject:SetActiveEx(false) + return + end + self.RImgRoleHead:SetRawImage(XDataCenter.CharacterManager.GetCharRoundnessHeadIcon(characterId)) + end +end + +return XUiRogueLikeSupportCharItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeTask.lua b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeTask.lua new file mode 100644 index 00000000..64b98b48 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeTask.lua @@ -0,0 +1,106 @@ +local XUiRogueLikeTask = XLuaUiManager.Register(XLuaUi, "UiRogueLikeTask") + +function XUiRogueLikeTask:OnAwake() + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + + self.DynamicTable = XDynamicTableNormal.New(self.PanelTaskStoryList.gameObject) + self.DynamicTable:SetProxy(XDynamicGridTask) + self.DynamicTable:SetDelegate(self) + + XEventManager.AddEventListener(XEventId.EVENT_TASK_SYNC, self.OnTaskChangeSync, self) + XEventManager.AddEventListener(XEventId.EVENT_ROGUELIKE_TASK_RESET, self.OnTaskChangeSync, self) +end + +function XUiRogueLikeTask:OnTaskChangeSync() + self.RogueLikeTasks = XDataCenter.TaskManager.GetRogueLikeFullTaskList() + for _, v in pairs(self.RogueLikeTasks or {}) do + v.SortWeight = 2 + if v.State == XDataCenter.TaskManager.TaskState.Achieved then + v.SortWeight = 1 + elseif v.State == XDataCenter.TaskManager.TaskState.Finish or v.State == XDataCenter.TaskManager.TaskState.Invalid then + v.SortWeight = 3 + end + end + + table.sort(self.RogueLikeTasks, function(taskA, taskB) + if taskA.SortWeight == taskB.SortWeight then + return taskA.Id < taskB.Id + end + return taskA.SortWeight < taskB.SortWeight + end) + self.DynamicTable:SetDataSource(self.RogueLikeTasks) + self.DynamicTable:ReloadDataASync() + self:StartCountDown() +end + +--动态列表事件 +function XUiRogueLikeTask:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.RogueLikeTasks[index] + if not data then + return + end + grid.RootUi = self + grid:ResetData(data) + end +end + +function XUiRogueLikeTask:OnStart() + self.ActivityId = XDataCenter.FubenRogueLikeManager.GetRogueLikeActivityId() + self:OnTaskChangeSync() +end + +function XUiRogueLikeTask:OnEnable() + self:CheckActivityEnd() + XDataCenter.FubenRogueLikeManager.CheckRogueLikeDayResetOnUi("UiRogueLikeTask") +end + +function XUiRogueLikeTask:OnDestroy() + self:StopCountDown() + XEventManager.RemoveEventListener(XEventId.EVENT_TASK_SYNC, self.OnTaskChangeSync, self) + XEventManager.RemoveEventListener(XEventId.EVENT_ROGUELIKE_TASK_RESET, self.OnTaskChangeSync, self) +end + +function XUiRogueLikeTask:StartCountDown() + self:StopCountDown() + + local now = XTime.GetServerNowTimestamp() + local endTime = XDataCenter.FubenRogueLikeManager.GetWeekRefreshTime() + if not endTime then return end + + local leftTimeDesc = CS.XTextManager.GetText("RogueLikeQuestResetTime") + self.TxtTime.text = string.format("%s%s", leftTimeDesc, XUiHelper.GetTime(endTime - now, XUiHelper.TimeFormatType.ACTIVITY)) + + self.CountTimer = XScheduleManager.ScheduleForever( + function() + now = XTime.GetServerNowTimestamp() + if now > endTime then + self:StopCountDown() + self:CheckActivityEnd() + return + end + self.TxtTime.text = string.format( + "%s%s", + leftTimeDesc, + XUiHelper.GetTime(endTime - now, XUiHelper.TimeFormatType.ACTIVITY) + ) + end, XScheduleManager.SECOND, 0) +end + +function XUiRogueLikeTask:CheckActivityEnd() + if not XDataCenter.FubenRogueLikeManager.IsInActivity() and XLuaUiManager.IsUiShow("UiRogueLikeMain") then + XUiManager.TipMsg(CS.XTextManager.GetText("RougeLikeNotInActivityTime")) + XLuaUiManager.RunMain() + end +end + +function XUiRogueLikeTask:StopCountDown() + if self.CountTimer ~= nil then + XScheduleManager.UnSchedule(self.CountTimer) + self.CountTimer = nil + end +end + +function XUiRogueLikeTask:OnBtnBackClick() + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeThemeTips.lua b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeThemeTips.lua new file mode 100644 index 00000000..41d4dc7b --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeThemeTips.lua @@ -0,0 +1,119 @@ +local XUiRogueLikeThemeTips = XLuaUiManager.Register(XLuaUi, "UiRogueLikeThemeTips") +local XUiGridTopicInfo = require("XUi/XUiFubenRogueLike/XUiGridTopicInfo") +local XUiDayTopicCharacter = require("XUi/XUiFubenRogueLike/XUiDayTopicCharacter") + +function XUiRogueLikeThemeTips:OnAwake() + self.GridHeadList = {} + self.GridTopicList = {} + self.BtnTanchuangClose.CallBack = function() self:OnBtnTanchuagnClose() end + if self.BtnClose then + self.BtnClose.CallBack = function() self:OnBtnTanchuagnClose() end + end + XEventManager.AddEventListener(XEventId.EVENT_ROGUELIKE_TEAMEFFECT_CHANGES, self.RefreshTeamEffect, self) +end + +function XUiRogueLikeThemeTips:OnDestroy() + self:StopCounter() + XEventManager.RemoveEventListener(XEventId.EVENT_ROGUELIKE_TEAMEFFECT_CHANGES, self.RefreshTeamEffect, self) +end + +function XUiRogueLikeThemeTips:RefreshTeamEffect() + local teamEffectId = XDataCenter.FubenRogueLikeManager.GetTeamEffectId() + if teamEffectId <= 0 then return end + local teamEffectTemplate = XFubenRogueLikeConfig.GetTeamEffectTemplateById(teamEffectId) + if not teamEffectTemplate then return end + local dayBuffs = XDataCenter.FubenRogueLikeManager.GetRogueLikeDayBuffs() + + if XDataCenter.FubenRogueLikeManager.IsSectionPurgatory() then + self.Text.gameObject:SetActiveEx(false) + self.PanelThemeBuff.gameObject:SetActiveEx(false) + self.PanelResetTime.gameObject:SetActiveEx(false) + else + self.Text.gameObject:SetActiveEx(true) + self.PanelThemeBuff.gameObject:SetActiveEx(true) + self.PanelResetTime.gameObject:SetActiveEx(true) + -- 今日主题 + for i = 1, #dayBuffs do + if not self.GridTopicList[i] then + local ui = CS.UnityEngine.Object.Instantiate(self.GridThemeBuff.gameObject) + ui.transform:SetParent(self.PanelThemeBuff, false) + ui.gameObject:SetActiveEx(true) + self.GridTopicList[i] = XUiGridTopicInfo.New(ui, self) + end + self.GridTopicList[i].GameObject:SetActiveEx(true) + self.GridTopicList[i]:SetTopicInfo(dayBuffs[i]) + end + for i = #dayBuffs + 1, #self.GridTopicList do + self.GridTopicList[i].GameObject:SetActiveEx(false) + end + end + + + -- 角色 + local characterInfos = XDataCenter.FubenRogueLikeManager.GetCharacterInfos() + for i = 1, #characterInfos do + local characterInfo = characterInfos[i] + if not self.GridHeadList[i] then + local ui = CS.UnityEngine.Object.Instantiate(self.GridHead.gameObject) + ui.transform:SetParent(self.PanelThemeHead, false) + ui.gameObject:SetActiveEx(true) + self.GridHeadList[i] = XUiDayTopicCharacter.New(ui, self) + end + self.GridHeadList[i].GameObject:SetActiveEx(true) + self.GridHeadList[i]:SetTopicInfo(characterInfo) + end + -- 调换队长位置 + for i = #characterInfos + 1, #self.GridHeadList do + self.GridHeadList[i].GameObject:SetActiveEx(false) + end + + self:StartCounter() +end + +function XUiRogueLikeThemeTips:OnStart() + self:RefreshTeamEffect() +end + +function XUiRogueLikeThemeTips:OnEnable() + XDataCenter.FubenRogueLikeManager.CheckRogueLikeDayResetOnUi("UiRogueLikeThemeTips") +end + +function XUiRogueLikeThemeTips:StartCounter() + self:StopCounter() + + local now = XTime.GetServerNowTimestamp() + local endTime = XDataCenter.FubenRogueLikeManager.GetDayRefreshTime() + if not endTime then return end + + self.TxtResetTime.text = XUiHelper.GetTime(endTime - now, XUiHelper.TimeFormatType.ACTIVITY) + if not XDataCenter.FubenRogueLikeManager.IsInActivity() then + self.TxtResetTime.text = CS.XTextManager.GetText("RogueLikeOutOfDate") + end + + self.CountTimer = XScheduleManager.ScheduleForever( + function() + now = XTime.GetServerNowTimestamp() + if now > endTime then + self:StopCounter() + return + end + self.TxtResetTime.text = XUiHelper.GetTime(endTime - now, XUiHelper.TimeFormatType.ACTIVITY) + if not XDataCenter.FubenRogueLikeManager.IsInActivity() then + self.TxtResetTime.text = CS.XTextManager.GetText("RogueLikeOutOfDate") + end + end, + XScheduleManager.SECOND, + 0 + ) +end + +function XUiRogueLikeThemeTips:StopCounter() + if self.CountTimer ~= nil then + XScheduleManager.UnSchedule(self.CountTimer) + self.CountTimer = nil + end +end + +function XUiRogueLikeThemeTips:OnBtnTanchuagnClose() + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeTrialOpens.lua b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeTrialOpens.lua new file mode 100644 index 00000000..ea256976 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiRogueLikeTrialOpens.lua @@ -0,0 +1,22 @@ +local XUiRogueLikeTrialOpens = XLuaUiManager.Register(XLuaUi, "UiRogueLikeTrialOpens") + +function XUiRogueLikeTrialOpens:OnAwake() + + self.BtnClose.CallBack = function() self:Close() end +end + +function XUiRogueLikeTrialOpens:OnStart(rootUi) + self.RootUi = rootUi + XDataCenter.FubenRogueLikeManager.SetNeedShowTrialTips(false) +end + +function XUiRogueLikeTrialOpens:SetupStarReward() + +end + + +function XUiRogueLikeTrialOpens:OnEnable() + +end + + diff --git a/Resources/Scripts/XUi/XUiFubenRogueLike/XUiShopSpecialTool.lua b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiShopSpecialTool.lua new file mode 100644 index 00000000..708af38d --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenRogueLike/XUiShopSpecialTool.lua @@ -0,0 +1,52 @@ +local XUiShopSpecialTool = XClass(nil, "XUiShopSpecialTool") + +function XUiShopSpecialTool:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + + XTool.InitUiObject(self) + -- if self.BtnSpecialTool then + -- self.BtnSpecialTool.CallBack = function() self:OnBtnSpecialToolClick() end + -- end +end + +function XUiShopSpecialTool:SetSpecialTool(itemId) + if not itemId then + self.GameObject:SetActiveEx(false) + return + end + local itemIcon = XDataCenter.ItemManager.GetItemIcon(itemId) + local itemCount = XDataCenter.ItemManager.GetCount(itemId) + + if self.RImgSpecialTool then + self.RImgSpecialTool.gameObject:SetActiveEx(true) + self.RImgSpecialTool:SetRawImage(itemIcon) + end + + if self.TxtSpecialTool then + self.TxtSpecialTool.text = itemCount + end + + if self.TxtXdcs then + self.TxtXdcs.gameObject:SetActiveEx(false) + end +end + +function XUiShopSpecialTool:SetSpecialToolNum(num) + if self.TxtSpecialTool then + self.TxtSpecialTool.text = num + end + + if self.TxtXdcs then + self.TxtXdcs.gameObject:SetActiveEx(true) + end + + if self.RImgSpecialTool then + self.RImgSpecialTool.gameObject:SetActiveEx(false) + end +end + +-- function XUiShopSpecialTool:OnBtnSpecialToolClick() +-- end +return XUiShopSpecialTool \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenSimulatedCombat/ChildItem/XUiBuffTipsItem.lua b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/ChildItem/XUiBuffTipsItem.lua new file mode 100644 index 00000000..ddf74e16 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/ChildItem/XUiBuffTipsItem.lua @@ -0,0 +1,20 @@ +--词缀展示界面:词缀详细显示控件 +local XUiBuffTipsItem = XClass(nil, "XUiBuffTipsItem") +function XUiBuffTipsItem:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiBuffTipsItem:RefreshData(buffId) + self.Cfg = XFubenConfigs.GetStageFightEventDetailsByStageFightEventId(buffId) + self:RefreshStageType() +end + +function XUiBuffTipsItem:RefreshStageType() + self.RImgIcon:SetRawImage(self.Cfg.Icon) + self.TxtName.text = self.Cfg.Name + self.TxtDesc.text = self.Cfg.Description +end + +return XUiBuffTipsItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenSimulatedCombat/ChildItem/XUiGridPointReward.lua b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/ChildItem/XUiGridPointReward.lua new file mode 100644 index 00000000..9636545a --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/ChildItem/XUiGridPointReward.lua @@ -0,0 +1,85 @@ +local XUiGridPointReward = XClass(nil, "XUiGridPointReward") + +function XUiGridPointReward:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + + self.BtnClick.CallBack = function() self:OnBtnRewardClick() end +end + +function XUiGridPointReward:UpdateData(data, nextData, pointCounts) + self.PointRewardId = data.Id + self.NeedPoint = data.NeedPoint + self.RewardId = data.RewardId + self.ShowItem = data.ShowItem + self.TxtCurStage.text = self.NeedPoint + self.PointCounts = pointCounts + if nextData then + self.NextNeedPoint = nextData.NeedPoint + end + + if self.ShowItem and self.ShowItem ~= 0 then + local item = {} + item.Id = self.ShowItem + item.Count = data.ShowItemNum + self.GridCommon.gameObject:SetActiveEx(true) + self.ImgActive.gameObject:SetActiveEx(false) + self.Grid = XUiGridCommon.New(self.RootUi, self.GridCommon) + self.Grid:Refresh(item) + else + self.GridCommon.gameObject:SetActiveEx(false) + self.ImgActive.gameObject:SetActiveEx(true) + end + self:UpdateState() +end + +function XUiGridPointReward:UpdateState() + + self.Red.gameObject:SetActiveEx(false) + self.PanelFinish.gameObject:SetActiveEx(false) + if self.PointCounts >= self.NeedPoint then + if not XDataCenter.FubenSimulatedCombatManager.CheckPointRewardGet(self.PointRewardId) then + self.Red.gameObject:SetActiveEx(true) + else + self.PanelFinish.gameObject:SetActiveEx(true) + end + if not self.NextNeedPoint then + self.PanelPassedLine.fillAmount = (self.PointCounts - self.NeedPoint) > 0 and 1 or 0 + elseif self.PointCounts < self.NextNeedPoint then + self.PanelPassedLine.fillAmount = (self.PointCounts - self.NeedPoint) / (self.NextNeedPoint - self.NeedPoint) + else + self.PanelPassedLine.fillAmount = 1 + end + else + self.PanelPassedLine.fillAmount = 0 + end +end + +function XUiGridPointReward:OnBtnRewardClick() + local itemList = XRewardManager.GetRewardList(self.RewardId) + + if self.PointCounts >= self.NeedPoint then + if not XDataCenter.FubenSimulatedCombatManager.CheckPointRewardGet(self.PointRewardId) then + XDataCenter.FubenSimulatedCombatManager.GetPointReward(self.PointRewardId, function(reward) + XUiManager.OpenUiObtain(reward, CS.XTextManager.GetText("Award")) + self:UpdateState() + end) + else + XUiManager.TipError(CS.XTextManager.GetText("SpecialPointRewardIsGet")) + end + elseif self.ShowItem and self.ShowItem ~= 0 then + -- local item = XDataCenter.ItemManager.GetItem(self.ShowItem) + -- local data = { + -- Id = item.Id, + -- Count = item ~= nil and tostring(item.Count) or "0" + -- } + -- XLuaUiManager.Open("UiTip", data) + self.Grid:OnBtnClickClick() + else + XUiManager.OpenUiTipReward(itemList) + end +end + +return XUiGridPointReward \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenSimulatedCombat/ChildItem/XUiGridRes.lua b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/ChildItem/XUiGridRes.lua new file mode 100644 index 00000000..03497289 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/ChildItem/XUiGridRes.lua @@ -0,0 +1,92 @@ +local XUiGridRes = XClass(nil, "XUiGridRes") + +function XUiGridRes:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + XUiHelper.RegisterClickEvent(self, self.BtnSelect, self.OnBtnSelectClick) + XUiHelper.RegisterClickEvent(self, self.BtnCancelSelect, self.OnBtnSelectClick) + XUiHelper.RegisterClickEvent(self, self.BtnDetail, self.OnBtnDetailClick) + self.BtnClose.CallBack = function() self:OnBtnCancelBuyClick() end +end + +function XUiGridRes:Init(uiRoot, isChallengeMode, isPassed, stageInterId) + self.UiRoot = uiRoot + self.IsChallengeMode = isChallengeMode + self.isPassed = isPassed + self.StageInterId = stageInterId +end + +function XUiGridRes:UpdateState() + self.PanelSelect.gameObject:SetActiveEx(self.Data.IsSelect) + self.PanelBuy.gameObject:SetActiveEx(self.Data.BuyMethod) +end + +function XUiGridRes:Refresh(data) + self.Id = data.Id + self.Type = data.Type + self.Data = data + + self.PanelMember.gameObject:SetActiveEx(self.Type == XFubenSimulatedCombatConfig.ResType.Member) + self.PanelBuff.gameObject:SetActiveEx(self.Type == XFubenSimulatedCombatConfig.ResType.Addition) + if self.Type == XFubenSimulatedCombatConfig.ResType.Member then + self.ResInfo = XFubenSimulatedCombatConfig.GetMemberById(data.Id) + self.RImgMember:SetRawImage(XRobotManager.GetRobotSmallHeadIcon(self.ResInfo.RobotId)) + self.TxtName.text = XCharacterConfigs.GetCharacterFullNameStr(XRobotManager.GetCharacterId(self.ResInfo.RobotId)) + elseif self.Type == XFubenSimulatedCombatConfig.ResType.Addition then + self.ResInfo = XFubenSimulatedCombatConfig.GetAdditionById(data.Id) + self.RImgBuff:SetRawImage(self.ResInfo.Icon) + self.TxtName.text = self.ResInfo.Name + end + self.TxtStarNum.text = self.ResInfo.Star + self:ShowPrice() + self:UpdateState() +end + +function XUiGridRes:ShowPrice() + local price1 = XDataCenter.FubenSimulatedCombatManager.CheckCurrencyFree() and 0 or self.ResInfo.ConsumeCounts[1] + self.TxtPrice1.text = price1 + if XDataCenter.FubenSimulatedCombatManager.GetCurrencyByNo(1) < price1 then + self.TxtPrice1.color = XFubenSimulatedCombatConfig.Color.INSUFFICIENT + else + self.TxtPrice1.color = XFubenSimulatedCombatConfig.Color.NORMAL + end + + self.RImgIcon1:SetRawImage(XDataCenter.FubenSimulatedCombatManager.GetCurrencyIcon(1)) + self.Consume2.gameObject:SetActiveEx(not self.IsChallengeMode) + self.TxtBuyMethodSplit.gameObject:SetActiveEx(not self.IsChallengeMode) + if not self.IsChallengeMode then + local price2 = self.isPassed and 0 or self.ResInfo.ConsumeCounts[2] + self.TxtPrice2.text = price2 + self.RImgIcon2:SetRawImage(XDataCenter.FubenSimulatedCombatManager.GetCurrencyIcon(2)) + if XDataCenter.FubenSimulatedCombatManager.GetCurrencyByNo(2) < price2 then + self.TxtPrice2.color = XFubenSimulatedCombatConfig.Color.INSUFFICIENT + else + self.TxtPrice2.color = XFubenSimulatedCombatConfig.Color.NORMAL + end + end +end + +function XUiGridRes:OnBtnSelectClick() + local result, desc = XDataCenter.FubenSimulatedCombatManager.SelectGridRes(self.Data) + if result then + self:UpdateState() + else + XUiManager.TipMsg(desc) + end +end + +function XUiGridRes:OnBtnDetailClick() + if self.Type == XFubenSimulatedCombatConfig.ResType.Member then + XLuaUiManager.Open("UiSimulatedCombatRoleList", self.Id, self.StageInterId) + elseif self.Type == XFubenSimulatedCombatConfig.ResType.Addition then + XLuaUiManager.Open("UiSimulatedCombatBuffTip", self.Id) + end +end + +function XUiGridRes:OnBtnCancelBuyClick() + XDataCenter.FubenSimulatedCombatManager.CancelBuyGridRes(self.Data) + self:UpdateState() +end + +return XUiGridRes \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenSimulatedCombat/ChildItem/XUiGridResAlloBuff.lua b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/ChildItem/XUiGridResAlloBuff.lua new file mode 100644 index 00000000..0e53cafe --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/ChildItem/XUiGridResAlloBuff.lua @@ -0,0 +1,24 @@ +--资源购买界面,右上角加成图标 +local XUiGridStageBuffIcon = XClass(nil, "XUiGridStageBuffIcon") + +function XUiGridStageBuffIcon:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) +end + +function XUiGridStageBuffIcon:Refresh(data) + self.RImgIcon:SetRawImage(data.Icon) + self.TxtStar.text = data.Star +end + +function XUiGridStageBuffIcon:Show() + self.GameObject:SetActiveEx(true) +end + +function XUiGridStageBuffIcon:Hide() + self.GameObject:SetActiveEx(false) +end + +return XUiGridStageBuffIcon \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenSimulatedCombat/ChildItem/XUiGridStageBuffIcon.lua b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/ChildItem/XUiGridStageBuffIcon.lua new file mode 100644 index 00000000..11261a9d --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/ChildItem/XUiGridStageBuffIcon.lua @@ -0,0 +1,24 @@ +--关卡详细页面:关卡增益图标控件 +local XUiGridStageBuffIcon = XClass(nil, "XUiGridStageBuffIcon") + +function XUiGridStageBuffIcon:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) +end + +function XUiGridStageBuffIcon:RefreshData(eventId) + local buffCfg = XFubenConfigs.GetStageFightEventDetailsByStageFightEventId(eventId) + self.RImgIcon:SetRawImage(buffCfg.Icon) +end + +function XUiGridStageBuffIcon:Show() + self.GameObject:SetActiveEx(true) +end + +function XUiGridStageBuffIcon:Hide() + self.GameObject:SetActiveEx(false) +end + +return XUiGridStageBuffIcon \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenSimulatedCombat/ChildItem/XUiGridStarReward.lua b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/ChildItem/XUiGridStarReward.lua new file mode 100644 index 00000000..dda0ea4f --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/ChildItem/XUiGridStarReward.lua @@ -0,0 +1,100 @@ +local XUiGridStarReward = XClass(nil, "XUiGridStarReward") + +function XUiGridStarReward:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + self.GridCommon.gameObject:SetActive(false) + + self.GridList = {} + + self.BtnReceive.CallBack = function() self:OnBtnReceiveClick() end +end + +-- auto +function XUiGridStarReward:OnBtnReceiveClick() + + if not self.Data.IsFinish then + return + end + + XDataCenter.FubenSimulatedCombatManager.GetStarReward(self.Data.Id, function(reward) + XUiManager.OpenUiObtain(reward, CS.XTextManager.GetText("Award")) + self:SetBtnAlreadyReceive() + end) +end + +function XUiGridStarReward:Refresh(data) + self.Data = data + local ownStars = XDataCenter.FubenSimulatedCombatManager.GetStarProgress() + local requireStars = data.RequireStar + local curStars = ownStars > requireStars and requireStars or ownStars + self.TxtGradeStarNums.text = CS.XTextManager.GetText("GradeStarNum", curStars, requireStars) + if data.IsFinish then + self:SetStarsActive(true) + local isGet = XDataCenter.FubenSimulatedCombatManager.CheckStarRewardGet(data.Id) + if isGet then + self:SetBtnAlreadyReceive() + else + self:SetBtnActive() + end + else + self:SetStarsActive(false) + self:SetBtnCannotReceive() + end + + self:SetupTreasureList() +end + +function XUiGridStarReward:SetBtnActive() + self.BtnReceive.gameObject:SetActive(true) + self.ImgAlreadyReceived.gameObject:SetActive(false) + self.ImgCannotReceive.gameObject:SetActive(false) +end + +function XUiGridStarReward:SetBtnCannotReceive() + self.BtnReceive.gameObject:SetActive(false) + self.ImgAlreadyReceived.gameObject:SetActive(false) + self.ImgCannotReceive.gameObject:SetActive(true) +end + +function XUiGridStarReward:SetBtnAlreadyReceive() + self.BtnReceive.gameObject:SetActive(false) + self.ImgAlreadyReceived.gameObject:SetActive(true) + self.ImgCannotReceive.gameObject:SetActive(false) +end + +function XUiGridStarReward:SetStarsActive(flag) + self.ImgGradeStarActive.gameObject:SetActive(flag) + self.ImgGradeStarUnactive.gameObject:SetActive(not flag) +end + +-- 初始化 +function XUiGridStarReward:SetupTreasureList() + if self.Data == nil or self.Data.RewardId == 0 then + XLog.Error("treasure have no RewardId ") + return + end + + local rewards = XRewardManager.GetRewardList(self.Data.RewardId) + for i, item in ipairs(rewards) do + local grid = self.GridList[i] + if not grid then + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommon) + grid = XUiGridCommon.New(self.RootUi, ui) + grid.Transform:SetParent(self.PanelTreasureContent, false) + self.GridList[i] = grid + end + grid:Refresh(item) + grid.GameObject:SetActive(true) + end + + for j = 1, #self.GridList do + if j > #rewards then + self.GridList[j].GameObject:SetActive(false) + end + end +end + +return XUiGridStarReward \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenSimulatedCombat/ChildItem/XUiGridTask.lua b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/ChildItem/XUiGridTask.lua new file mode 100644 index 00000000..19e91116 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/ChildItem/XUiGridTask.lua @@ -0,0 +1,199 @@ +local XUiGridTask = XClass(nil, "XUiGridTask") + +function XUiGridTask:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RewardPanelList = {} + self:InitAutoScript() + self.GridCommon.gameObject:SetActive(false) + self.ImgComplete.gameObject:SetActive(false) + self.PanelAnimation.gameObject:SetActive(true) +end + +function XUiGridTask:PlayAnimation() + if self.IsAnimation then + return + end + + self.IsAnimation = true + self.GridTaskTimeline:PlayTimelineAnimation() +end + +function XUiGridTask:ResetData(data) + self.ImgComplete.gameObject:SetActive(data.State == XDataCenter.TaskManager.TaskState.Finish) + self.Data = data + + local config = XDataCenter.TaskManager.GetTaskTemplate(self.Data.Id) + self.tableData = config + self.TxtTaskName.text = config.Title + self.TxtTaskDescribe.text = config.Desc + self.TxtSubTypeTip.text = config.Suffix or "" + self.RImgTaskType:SetRawImage(config.Icon) + self:UpdateProgress(self.Data) + local rewards = XRewardManager.GetRewardList(config.RewardId) + for i = 1, #self.RewardPanelList do + self.RewardPanelList[i]:Refresh() + end + + if not rewards then + return + end + + for i = 1, #rewards do + local panel = self.RewardPanelList[i] + if not panel then + if #self.RewardPanelList == 0 then + panel = XUiGridCommon.New(self.RootUi, self.GridCommon) + else + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommon) + ui.transform:SetParent(self.GridCommon.parent, false) + panel = XUiGridCommon.New(self.RootUi, ui) + end + table.insert(self.RewardPanelList, panel) + end + + panel:Refresh(rewards[i]) + end + if self.PanelAnimationGroup then + self.PanelAnimationGroup.alpha = 1 + end + +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiGridTask:InitAutoScript() + XTool.InitUiObject(self) + self.SpecialSoundMap = {} + self:AutoAddListener() +end + + + +function XUiGridTask:GetAutoKey(uiNode, eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiGridTask:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiGridTask:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiGridTask:AutoAddListener() + self.AutoCreateListeners = {} + + local finishXUiBtn = self.BtnFinish:GetComponent("XUiButton") + if not finishXUiBtn then + XUiHelper.RegisterClickEvent(self, self.BtnFinish, self.OnBtnFinishClick) + else + self.BtnFinish = finishXUiBtn + self.BtnFinish.CallBack = function() self:OnBtnFinishClick() end + end + + local skipXUiBtn = self.BtnSkip:GetComponent("XUiButton") + if not skipXUiBtn then + XUiHelper.RegisterClickEvent(self, self.BtnSkip, self.OnBtnSkipClick) + else + self.BtnSkip = skipXUiBtn + self.BtnSkip.CallBack = function() self:OnBtnSkipClick() end + end +end + +function XUiGridTask:OnBtnFinishClick() + local weaponCount = 0 + local chipCount = 0 + for i = 1, #self.RewardPanelList do + local rewardsId = self.RewardPanelList[i].TemplateId + if XDataCenter.EquipManager.IsClassifyEqualByTemplateId(rewardsId, XEquipConfig.Classify.Weapon) then + weaponCount = weaponCount + 1 + elseif XDataCenter.EquipManager.IsClassifyEqualByTemplateId(rewardsId, XEquipConfig.Classify.Awareness) then + chipCount = chipCount + 1 + end + end + if weaponCount > 0 and XDataCenter.EquipManager.CheckBagCount(weaponCount, XEquipConfig.Classify.Weapon) == false or + chipCount > 0 and XDataCenter.EquipManager.CheckBagCount(chipCount, XEquipConfig.Classify.Awareness) == false then + return + end + XDataCenter.TaskManager.FinishTask(self.Data.Id, function(rewardGoodsList) + XUiManager.OpenUiObtain(rewardGoodsList) + XEventManager.DispatchEvent(XEventId.EVENT_FUBEN_SIMUCOMBAT_UPDATE) + end) +end + +function XUiGridTask:OnBtnSkipClick() + if XDataCenter.RoomManager.RoomData ~= nil then + local title = CS.XTextManager.GetText("TipTitle") + local cancelMatchMsg = CS.XTextManager.GetText("OnlineInstanceQuitRoom") + XUiManager.DialogTip(title, cancelMatchMsg, XUiManager.DialogType.Normal, nil, function() + XLuaUiManager.RunMain() + local skipId = XDataCenter.TaskManager.GetTaskTemplate(self.Data.Id).SkipId + XFunctionManager.SkipInterface(skipId) + end) + else + local skipId = XDataCenter.TaskManager.GetTaskTemplate(self.Data.Id).SkipId + XFunctionManager.SkipInterface(skipId) + end +end + +function XUiGridTask:UpdateProgress(data) + self.Data = data + local config = XDataCenter.TaskManager.GetTaskTemplate(data.Id) + if #config.Condition < 2 then--显示进度 + self.ImgProgress.transform.parent.gameObject:SetActive(true) + self.TxtTaskNumQian.gameObject:SetActive(true) + local result = config.Result > 0 and config.Result or 1 + XTool.LoopMap(self.Data.Schedule, function(_, pair) + self.ImgProgress.fillAmount = pair.Value / result + pair.Value = (pair.Value >= result) and result or pair.Value + self.TxtTaskNumQian.text = pair.Value .. "/" .. result + end) + else + self.ImgProgress.transform.parent.gameObject:SetActive(false) + self.TxtTaskNumQian.gameObject:SetActive(false) + end + + self.BtnFinish.gameObject:SetActive(false) + self.BtnSkip.gameObject:SetActive(false) + if self.BtnReceiveHave then + self.BtnReceiveHave.gameObject:SetActive(false) + end + if self.Data.State == XDataCenter.TaskManager.TaskState.Achieved then + self.BtnFinish.gameObject:SetActive(true) + elseif self.Data.State ~= XDataCenter.TaskManager.TaskState.Achieved and self.Data.State ~= XDataCenter.TaskManager.TaskState.Finish then + self.BtnSkip.gameObject:SetActive(true) + + if self.BtnSkip["SetButtonState"] then + local skipId = XDataCenter.TaskManager.GetTaskTemplate(self.Data.Id).SkipId + if skipId == nil or skipId == 0 then + self.BtnSkip:SetButtonState(CS.UiButtonState.Disable) + else + self.BtnSkip:SetButtonState(CS.UiButtonState.Normal) + end + end + elseif self.Data.State == XDataCenter.TaskManager.TaskState.Finish then + if self.BtnReceiveHave then + self.BtnReceiveHave.gameObject:SetActive(true) + end + end +end + +return XUiGridTask \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenSimulatedCombat/ChildItem/XUiRoomCharListGrid.lua b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/ChildItem/XUiRoomCharListGrid.lua new file mode 100644 index 00000000..209b8e6e --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/ChildItem/XUiRoomCharListGrid.lua @@ -0,0 +1,56 @@ +--战斗成员选择界面 成员列表 +local XUiSimulatedCombatRoomCharListGrid = XClass(nil, "XUiExpeditionRoomCharacterGrid") +function XUiSimulatedCombatRoomCharListGrid:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiSimulatedCombatRoomCharListGrid:Init(ui, rootUi) + self.RootUi = rootUi + self.PanelSelected.gameObject:SetActiveEx(false) + self:SetInTeam(false) +end + +function XUiSimulatedCombatRoomCharListGrid:Refresh(charId) + local data = XDataCenter.FubenSimulatedCombatManager.GetCurStageMemberDataByCharId(charId) + if not data then + XLog.Error("无法找到data, charId = ", charId) + return + end + self.Data = data + self.RobotId = data.RobotId + self.CharacterId = charId + + self.RImgHeadIcon:SetRawImage(XRobotManager.GetRobotSmallHeadIcon(self.RobotId)) + self.TxtFight.text = XRobotManager.GetRobotAbility(self.RobotId) + self.TxtLevel.text = data.Star + self:RefreshElements() +end + +function XUiSimulatedCombatRoomCharListGrid:SetSelect(isSelect) + self.PanelSelected.gameObject:SetActiveEx(isSelect) + self.IsSelect = isSelect + if isSelect and self.Data then self.RootUi:Refresh(self.CharacterId, self.RobotId) end +end + +function XUiSimulatedCombatRoomCharListGrid:SetInTeam(isInTeam) + self.ImgInTeam.gameObject:SetActiveEx(isInTeam) +end + +function XUiSimulatedCombatRoomCharListGrid:RefreshElements() + local detailConfig = XCharacterConfigs.GetCharDetailTemplate(self.CharacterId) + local elementList = detailConfig.ObtainElementList + for i = 1, 3 do + local rImg = self["RImgCharElement" .. i] + if rImg and elementList[i] then + rImg.transform.gameObject:SetActiveEx(true) + local elementConfig = XCharacterConfigs.GetCharElement(elementList[i]) + rImg:SetRawImage(elementConfig.Icon) + elseif rImg and not elementList[i] then + rImg.transform.gameObject:SetActiveEx(false) + end + end +end + +return XUiSimulatedCombatRoomCharListGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenSimulatedCombat/ChildItem/XUiStageItem.lua b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/ChildItem/XUiStageItem.lua new file mode 100644 index 00000000..e9d4f350 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/ChildItem/XUiStageItem.lua @@ -0,0 +1,93 @@ +local XUiStageItem = XClass(nil, "XUiStageItem") + +local XUiPanelStars = require("XUi/XUiFubenMainLineChapter/XUiPanelStars") + +function XUiStageItem:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) +end + +function XUiStageItem:SetNormalStage(stageId, stagePrefix, stageName) + self.PanelStageNormal.gameObject:SetActiveEx(not self.IsLock) + if self.Data.IconPath then + --local stageCfg = XDataCenter.FubenManager.GetStageCfg(self.StageId) + self.RImgFightActiveNor:SetRawImage(self.Data.IconPath) + self.RImgFightActiveLock:SetRawImage(self.Data.IconPath) + end + + --self.TxtStageTitle.text = stageName + --self.TxtStagePrefix.text = stagePrefix + self.TxtStageOrder.text = stagePrefix..stageName + -- SetLockStage + self.PanelStageLock.gameObject:SetActiveEx(self.IsLock) + --self.PanelChallenging.gameObject:SetActiveEx(false) +end + +function XUiStageItem:SetChallengingStage(value) + local isChallenging = value and not self.IsPass + self.PanelChallenging.gameObject:SetActiveEx(isChallenging) +end + +function XUiStageItem:SetPassStage() + self.PanelStagePass.gameObject:SetActiveEx(XDataCenter.FubenManager.CheckStageIsPass(stageId)) +end + +function XUiStageItem:UpdateNode(data) + self.StageId = data.StageId + local stageInfo = XDataCenter.FubenManager.GetStageInfo(self.StageId) + self.Data = data + local stagePrefabName = data.PrefabPath + + local isOpen, description = stageInfo.IsOpen, CS.XTextManager.GetText("FubenPreStageNotPass") + self.GameObject:SetActiveEx(isOpen) + local gridGo = self.Transform:LoadPrefab(stagePrefabName) + local uiObj = gridGo.transform:GetComponent("UiObject") + for i = 0, uiObj.NameList.Count - 1 do + self[uiObj.NameList[i]] = uiObj.ObjList[i] + end + self.BtnStage.CallBack = function() self:OnBtnStageClick() end + + self.IsLock = not stageInfo.Unlock + self.Description = description + local stagePrefix = XDataCenter.FubenManager.GetStageName(data.StageId) + local stageName = XDataCenter.FubenManager.GetStageDes(data.StageId) + self:SetNormalStage(self.StageId, stagePrefix or "", stageName or "") + self.IsPass = stageInfo.Passed + self.PanelStagePass.gameObject:SetActiveEx(self.IsPass) + + self.PanelStarMap = self.PanelStarMap or XUiPanelStars.New(self.PanelStars) + self.PanelStars.gameObject:SetActiveEx(data.Type == XFubenSimulatedCombatConfig.StageType.Challenge) + local starsMap = XDataCenter.FubenSimulatedCombatManager.GetPlainStarMap(self.StageId) + self.PanelStarMap:OnEnable(starsMap) +end + +function XUiStageItem:OnBtnStageClick() + if self.StageId then + if not self.IsLock then + self.RootUi:UpdateNodesSelect(self.StageId) + -- 打开详细界面 + self.RootUi:OpenStageDetails(self.Data.Id) + self.RootUi:PlayScrollViewMove(self.Transform) + else + XUiManager.TipMsg(self.Description) + end + + end +end + +function XUiStageItem:SetNodeSelect(isSelect) + if not self.IsLock then + self.ImageSelected.gameObject:SetActiveEx(isSelect) + end +end + +function XUiStageItem:ResetItemPosition(pos) + if self.ImgHideLine then + local rect = self.ImgHideLine:GetComponent("RectTransform").rect + self.Transform.localPosition = CS.UnityEngine.Vector3(pos.x, pos.y - rect.height, pos.z) + end +end + +return XUiStageItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenSimulatedCombat/RoleList/CharacterDetail/XUiCharProperty.lua b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/RoleList/CharacterDetail/XUiCharProperty.lua new file mode 100644 index 00000000..e784963a --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/RoleList/CharacterDetail/XUiCharProperty.lua @@ -0,0 +1,43 @@ +--成员列表界面:角色展示页面: 角色状态栏 +local XUiSimulatedCombatCharProperty = XClass(nil, "XUiSimulatedCombatCharProperty") + +function XUiSimulatedCombatCharProperty:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiSimulatedCombatCharProperty:ShowPanel(robotData) + self.RobotCfg = robotData + self.CharacterId = self.RobotCfg.CharacterId + self.IsShow = true + self.GameObject:SetActive(true) + self.PanelLeveInfo.gameObject:SetActive(true) + self.BtnLiberation = self.PanelLeveInfo.transform:Find("BtnLiberation") + self.ExpBar = self.PanelLeveInfo.transform:Find("ExpBar") + self.LeveInfoQiehuan:PlayTimelineAnimation() + self:UpdatePanel() + self.BtnLevelUpButton.gameObject:SetActive(false) + self.ImgMaxLevel.gameObject:SetActive(self.RobotCfg.CharacterLevel == XCharacterConfigs.GetCharMaxLevel(self.CharacterId)) +end + +function XUiSimulatedCombatCharProperty:HidePanel() + self.IsShow = false + self.GameObject:SetActive(false) +end + +function XUiSimulatedCombatCharProperty:UpdatePanel() + self.ExpBar.gameObject:SetActiveEx(false) + self.BtnLiberation.gameObject:SetActiveEx(false) + self.TxtCurLevel.text = self.RobotCfg.CharacterLevel + self.TxtMaxLevel.text = "/" .. XCharacterConfigs.GetCharMaxLevel(self.CharacterId) + self.TxtExp.text = "-" + self.ImgFill.fillAmount = 1 + self.CharacterAttributes = XRobotManager.GetRobotAttribs(self.RobotCfg.Id) + self.TxtAttack.text = FixToInt(self.CharacterAttributes[XNpcAttribType.AttackNormal]) + self.TxtLife.text = FixToInt(self.CharacterAttributes[XNpcAttribType.Life]) + self.TxtDefense.text = FixToInt(self.CharacterAttributes[XNpcAttribType.DefenseNormal]) + self.TxtCrit.text = FixToInt(self.CharacterAttributes[XNpcAttribType.Crit]) +end + +return XUiSimulatedCombatCharProperty \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenSimulatedCombat/RoleList/CharacterDetail/XUiCharaInfo.lua b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/RoleList/CharacterDetail/XUiCharaInfo.lua new file mode 100644 index 00000000..8e72ff9e --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/RoleList/CharacterDetail/XUiCharaInfo.lua @@ -0,0 +1,128 @@ +--成员列表人物详细子页面 +local XUiSimulatedCombatListCharaInfo = XLuaUiManager.Register(XLuaUi, "UiSimulatedCombatListCharaInfo") +local XUiSimulatedCombatEquipGrid = require("XUi/XUiFubenSimulatedCombat/RoleList/EquipDetail/XUiEquipGrid") +function XUiSimulatedCombatListCharaInfo:OnAwake() + self:AddListener() +end +function XUiSimulatedCombatListCharaInfo:OnStart(rootUi) + self.BtnLevelUp.gameObject:SetActive(true) + self.BtnJoin.gameObject:SetActive(false) + self.BtnSupport.gameObject:SetActive(false) + self.ImgRedPoint.gameObject:SetActive(false) + self.RootUi = rootUi + --self.RootUi.CharaInfo = self + self.WearingAwarenessGrids = {} + local BtnText = self.BtnLevelUp.transform:Find("Text"):GetComponent("Text") + if BtnText then + BtnText.text = CS.XTextManager.GetText("ExpeditionRoleListRoleButtonText") + end +end + +function XUiSimulatedCombatListCharaInfo:OnEnable() + +end + +function XUiSimulatedCombatListCharaInfo:UpdateView(robotId) + self.RobotId = robotId + self.CharacterId = XRobotManager.GetCharacterId(robotId) + self.RobotCfg = XRobotManager.GetRobotTemplate(self.RobotId) + + local charConfig = XCharacterConfigs.GetCharacterTemplate(self.CharacterId) + self.TxtName.text = charConfig.Name + self.TxtNameOther.text = charConfig.TradeName + local jobType = XRobotManager.GetRobotJobType(self.RobotId) + self.RImgTypeIcon:SetRawImage(XCharacterConfigs.GetNpcTypeIcon(jobType)) + self.TxtLv.text = XRobotManager.GetRobotAbility(self.RobotId) + self.WeaponGrid = self.WeaponGrid or XUiSimulatedCombatEquipGrid.New(self.GridWeapon, nil, self) + local usingWeaponId = self.RobotCfg.WeaponId + if usingWeaponId then + self.WeaponGrid:Refresh(usingWeaponId, self.RobotCfg.WeaponBeakThrough, 0, true, self.RobotCfg.WeaponLevel) + end + + for i = 1, 6 do + self.WearingAwarenessGrids[i] = self.WearingAwarenessGrids[i] or XUiSimulatedCombatEquipGrid.New(CS.UnityEngine.Object.Instantiate(self.GridAwareness), nil, self) + self.WearingAwarenessGrids[i].Transform:SetParent(self["PanelAwareness" .. i], false) + local equipId = self.RobotCfg.WaferId[i] + if not equipId then + self.WearingAwarenessGrids[i].GameObject:SetActive(false) + self["PanelNoAwareness" .. i].gameObject:SetActive(true) + else + self.WearingAwarenessGrids[i].GameObject:SetActive(true) + self["BtnAwarenessReplace" .. i].transform:SetAsLastSibling() + self["PanelNoAwareness" .. i].gameObject:SetActive(false) + self.WearingAwarenessGrids[i]:Refresh(equipId, self.RobotCfg.WaferBreakThrough[i], i, false, self.RobotCfg.WaferLevel[i]) + end + end + + local detailConfig = XCharacterConfigs.GetCharDetailTemplate(self.CharacterId) + local elementList = detailConfig.ObtainElementList + for i = 1, 3 do + local rImg = self["RImgCharElement" .. i] + if elementList[i] then + rImg.gameObject:SetActive(true) + local elementConfig = XCharacterConfigs.GetCharElement(elementList[i]) + rImg:SetRawImage(elementConfig.Icon) + else + rImg.gameObject:SetActive(false) + end + end +end + +function XUiSimulatedCombatListCharaInfo:AddListener() + self:RegisterClickEvent(self.BtnLevelUp, self.OnBtnLevelUpClick) + self:RegisterClickEvent(self.BtnAwarenessReplace6, self.OnBtnAwarenessReplace6Click) + self:RegisterClickEvent(self.BtnAwarenessReplace5, self.OnBtnAwarenessReplace5Click) + self:RegisterClickEvent(self.BtnAwarenessReplace4, self.OnBtnAwarenessReplace4Click) + self:RegisterClickEvent(self.BtnAwarenessReplace3, self.OnBtnAwarenessReplace3Click) + self:RegisterClickEvent(self.BtnAwarenessReplace2, self.OnBtnAwarenessReplace2Click) + self:RegisterClickEvent(self.BtnAwarenessReplace1, self.OnBtnAwarenessReplace1Click) + self:RegisterClickEvent(self.BtnWeaponReplace, self.OnBtnWeaponReplaceClick) + self:RegisterClickEvent(self.BtnCareerTips, self.OnBtnCareerTipsClick) + self:RegisterClickEvent(self.BtnLevelUp, self.OnBtnLevelUpClick) + self.BtnElementDetail.CallBack = function() self:OnBtnElementDetailClick() end +end + +function XUiSimulatedCombatListCharaInfo:OnBtnAwarenessReplace5Click() + self:OnAwarenessClick(5) +end + +function XUiSimulatedCombatListCharaInfo:OnBtnAwarenessReplace4Click() + self:OnAwarenessClick(4) +end + +function XUiSimulatedCombatListCharaInfo:OnBtnAwarenessReplace3Click() + self:OnAwarenessClick(3) +end + +function XUiSimulatedCombatListCharaInfo:OnBtnAwarenessReplace2Click() + self:OnAwarenessClick(2) +end + +function XUiSimulatedCombatListCharaInfo:OnBtnAwarenessReplace1Click() + self:OnAwarenessClick(1) +end + +function XUiSimulatedCombatListCharaInfo:OnBtnAwarenessReplace6Click() + self:OnAwarenessClick(6) +end + +function XUiSimulatedCombatListCharaInfo:OnBtnLevelUpClick() + self.RootUi:OpenChild(self.RootUi.ChildUiName.UiSimulatedCombatViewRole) +end + +function XUiSimulatedCombatListCharaInfo:OnAwarenessClick(site) + if not self.RobotCfg.WaferId[site] then return end + XLuaUiManager.Open("UiSimulatedCombatEquipDetail", self.RobotCfg.WaferId[site], self.RobotCfg.WaferBreakThrough[site], self.RobotCfg.WaferLevel[site]) +end + +function XUiSimulatedCombatListCharaInfo:OnBtnCareerTipsClick() + XLuaUiManager.Open("UiCharacterCarerrTips") +end + +function XUiSimulatedCombatListCharaInfo:OnBtnWeaponReplaceClick() + XLuaUiManager.Open("UiSimulatedCombatEquipDetail", self.RobotCfg.WeaponId, self.RobotCfg.WeaponBeakThrough, self.RobotCfg.WeaponLevel) +end + +function XUiSimulatedCombatListCharaInfo:OnBtnElementDetailClick() + XLuaUiManager.Open("UiCharacterElementDetail", self.CharacterId) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenSimulatedCombat/RoleList/CharacterDetail/XUiViewRole.lua b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/RoleList/CharacterDetail/XUiViewRole.lua new file mode 100644 index 00000000..bf7316ac --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/RoleList/CharacterDetail/XUiViewRole.lua @@ -0,0 +1,88 @@ +--成员列表界面:角色展示页面 +local XUiSimulatedCombatViewRole = XLuaUiManager.Register(XLuaUi, "UiSimulatedCombatViewRole") +local XUiSimulatedCombatCharProperty = require("XUi/XUiFubenSimulatedCombat/RoleList/CharacterDetail/XUiCharProperty") + +local PANEL_INDEX = { + Property = 1, + Skill = 2, +} +local COMPONENT_NAME = "UiPanelCharProperty" +function XUiSimulatedCombatViewRole:OnAwake() + +end + +function XUiSimulatedCombatViewRole:OnStart(parent) + --XRobotManager.GetRobotTemplate() + self.Parent = parent + self.CharacterId = self.Parent.CharacterId + self.RobotCfg = self.Parent.RobotCfg + self:InitChildUiInfos() + self:InitBtnTabGroup() + self.PanelPropertyButtons:SelectIndex(PANEL_INDEX.Property) + self.BtnTabSkill.gameObject:SetActiveEx(false) +end + +function XUiSimulatedCombatViewRole:OnEnable() + self.CharacterId = self.Parent.CharacterId + self.RobotCfg = self.Parent.RobotCfg + self.Parent.CharacterList.GameObject:SetActiveEx(false) +end + +function XUiSimulatedCombatViewRole:OnDisable() + self.Parent.CharacterList.GameObject:SetActiveEx(true) +end + +function XUiSimulatedCombatViewRole:InitChildUiInfos() + self.PanelsMap = {} + self.ChildUiInitInfos = { + [PANEL_INDEX.Property] = { + ChildClass = XUiSimulatedCombatCharProperty, + UiParent = self.PanelCharLevel, + AssetPath = XUiConfigs.GetComponentUrl(string.format(COMPONENT_NAME .. PANEL_INDEX.Property)), + }, + --[PANEL_INDEX.Skill] = { + -- ChildClass = XUiSimulatedCombatCharSkill, + -- UiParent = self.PanelCharSkill, + -- AssetPath = XUiConfigs.GetComponentUrl(string.format(COMPONENT_NAME .. PANEL_INDEX.Skill)), + --}, + } +end + +function XUiSimulatedCombatViewRole:InitBtnTabGroup() + local tabGroup = { + [PANEL_INDEX.Property] = self.BtnTabLevel, + --[PANEL_INDEX.Skill] = self.BtnTabSkill, + } + self.PanelPropertyButtons:Init(tabGroup, function(tabIndex) self:OnClickTabCallBack(tabIndex) end) +end + +function XUiSimulatedCombatViewRole:OnClickTabCallBack(tabIndex) + if tabIndex == PANEL_INDEX.Property then + self.Parent:PlayAnimation("LevelBegan") + self.PreCameraType = XCharacterConfigs.XUiCharacter_Camera.LEVEL + elseif tabIndex == PANEL_INDEX.Skill then + self.PreCameraType = XCharacterConfigs.XUiCharacter_Camera.SKILL + self.Parent:PlayAnimation("SkillBegan") + end + self.SelectedIndex = tabIndex + self:UpdateShowPanel() +end + +function XUiSimulatedCombatViewRole:UpdateShowPanel() + self.Parent:UpdateCamera(self.PreCameraType) + local index = self.SelectedIndex + for k, panel in pairs(self.PanelsMap) do + if k ~= index then + panel:HidePanel() + end + end + + local panel = self.PanelsMap[index] + if not panel then + local childUiInfo = self.ChildUiInitInfos[index] + local ui = childUiInfo.UiParent:LoadPrefab(childUiInfo.AssetPath) + panel = childUiInfo.ChildClass.New(ui, self) + self.PanelsMap[index] = panel + end + panel:ShowPanel(self.RobotCfg) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenSimulatedCombat/RoleList/CharacterPanel/XUiCharacterGrid.lua b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/RoleList/CharacterPanel/XUiCharacterGrid.lua new file mode 100644 index 00000000..02732bc3 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/RoleList/CharacterPanel/XUiCharacterGrid.lua @@ -0,0 +1,75 @@ +--成员列表页面角色列表:角色控件 +local XUiSimulatedCombatListCharacterGrid = XClass(nil, "XUiSimulatedCombatListCharacterGrid") +function XUiSimulatedCombatListCharacterGrid:Ctor(ui, rootUi, gridIndex, onSelectCb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.RootUi = rootUi + self.GridIndex = gridIndex + self.SelectCb = onSelectCb + self:AddListener() + self.ImgInTeam.gameObject:SetActiveEx(false) + self.PanelSelected.gameObject:SetActiveEx(false) +end + +function XUiSimulatedCombatListCharacterGrid:AddListener() + self.RootUi:RegisterClickEvent(self.BtnCharacter, function() self:OnClick() end) +end + +function XUiSimulatedCombatListCharacterGrid:RefreshDatas(data) + if not data then + return + end + self.Data = data + self.RobotId = data.RobotId + self.CharacterId = XRobotManager.GetCharacterId(self.RobotId) + + + --self.RImgMember:SetRawImage(XRobotManager.GetRobotSmallHeadIcon(self.ResInfo.RobotId)) + --self.TxtName.text = XCharacterConfigs.GetCharacterName() + + + self.RImgHeadIcon:SetRawImage(XRobotManager.GetRobotSmallHeadIcon(self.RobotId)) + self.TxtFight.text = XRobotManager.GetRobotAbility(self.RobotId) + self.TxtLevel.text = data.Star + self:RefreshElements() +end + +function XUiSimulatedCombatListCharacterGrid:Show() + self.GameObject:SetActiveEx(true) +end + +function XUiSimulatedCombatListCharacterGrid:Hide() + self.GameObject:SetActiveEx(false) +end + +function XUiSimulatedCombatListCharacterGrid:OnClick() + self:SetSelect(true) +end + +function XUiSimulatedCombatListCharacterGrid:SetSelect(isSelect) + if self.IsSelected == isSelect then return end + self.PanelSelected.gameObject:SetActiveEx(isSelect) + self.IsSelected = isSelect + if self.SelectCb and isSelect then + self.RootUi:Refresh(self.CharacterId, self.RobotId) + self.SelectCb(self.GridIndex) + end +end + +function XUiSimulatedCombatListCharacterGrid:RefreshElements() + local detailConfig = XCharacterConfigs.GetCharDetailTemplate(self.CharacterId) + local elementList = detailConfig.ObtainElementList + for i = 1, 3 do + local rImg = self["RImgCharElement" .. i] + if rImg and elementList[i] then + rImg.transform.gameObject:SetActiveEx(true) + local elementConfig = XCharacterConfigs.GetCharElement(elementList[i]) + rImg:SetRawImage(elementConfig.Icon) + elseif rImg and not elementList[i] then + rImg.transform.gameObject:SetActiveEx(false) + end + end +end + +return XUiSimulatedCombatListCharacterGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenSimulatedCombat/RoleList/CharacterPanel/XUiCharacterList.lua b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/RoleList/CharacterPanel/XUiCharacterList.lua new file mode 100644 index 00000000..fe0a7c30 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/RoleList/CharacterPanel/XUiCharacterList.lua @@ -0,0 +1,47 @@ +--成员列表页面:角色列表 +local XUiSimulatedCombatListCharacterList = XClass(nil, "XUiSimulatedCombatListCharacterList") +local XUiSimulatedCombatListCharacterGrid = require("XUi/XUiFubenSimulatedCombat/RoleList/CharacterPanel/XUiCharacterGrid") + +function XUiSimulatedCombatListCharacterList:Ctor(ui, rootUi, gridTemplate) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.RootUi = rootUi + self.GridTemplate = gridTemplate + self.GridTemplate.gameObject:SetActiveEx(false) + --self:UpdateData() +end + +function XUiSimulatedCombatListCharacterList:UpdateData(firstMemberId) + self.MemberList = XDataCenter.FubenSimulatedCombatManager.GetCurStageMember(firstMemberId) + self.CurrentSelect = 1 + if not self.GridCharacter then self.GridCharacter = {} end + for i = 1, #self.MemberList do + if not self.GridCharacter[i] then + local prefab = CS.UnityEngine.Object.Instantiate(self.GridTemplate.gameObject) + prefab.transform:SetParent(self.Transform, false) + self.GridCharacter[i] = XUiSimulatedCombatListCharacterGrid.New(prefab, self.RootUi, i, function(index) self:SetSelect(index) end) + end + end + for i = 1, #self.GridCharacter do + if self.MemberList[i] then + self.GridCharacter[i]:Show() + self.GridCharacter[i]:RefreshDatas(self.MemberList[i]) + else + self.GridCharacter[i]:Hide() + end + end + if self.GridCharacter[self.CurrentSelect] then + self.GridCharacter[self.CurrentSelect]:SetSelect(true) + end +end + +function XUiSimulatedCombatListCharacterList:SetSelect(index) + if self.CurrentSelect == index then return end + if self.CurrentSelect and self.GridCharacter[self.CurrentSelect] then + self.GridCharacter[self.CurrentSelect]:SetSelect(false) + end + self.CurrentSelect = index +end + +return XUiSimulatedCombatListCharacterList \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenSimulatedCombat/RoleList/EquipDetail/XUiEquipDetail.lua b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/RoleList/EquipDetail/XUiEquipDetail.lua new file mode 100644 index 00000000..e9be4c24 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/RoleList/EquipDetail/XUiEquipDetail.lua @@ -0,0 +1,132 @@ +--成员列表装备详情 +local XUiSimulatedCombatEquipDetail = XLuaUiManager.Register(XLuaUi, "UiSimulatedCombatEquipDetail") +local CSTextManager = CS.XTextManager +function XUiSimulatedCombatEquipDetail:OnAwake() + self:InitAutoScript() + XUiSimulatedCombatEquipDetail.BtnTabIndex = XEquipConfig.EquipDetailBtnTabIndex + self.PanelAsset.gameObject:SetActiveEx(false) +end + +--参数isPreview为true时是装备详情预览,传templateId进来 +--characterId只有需要判断武器共鸣特效时才传 +function XUiSimulatedCombatEquipDetail:OnStart(templateId, breakthroughTimes, level) + self.TemplateId = templateId + self.BreakThroughTime = breakthroughTimes + self.Level = level + local sceneRoot = self.UiSceneInfo.Transform + local root = self.UiModelGo.transform + self.PanelWeapon = root:FindTransform("PanelWeapon") + self.PanelWeaponPlane = sceneRoot:FindTransform("Plane") + self.PanelWeaponPlane.gameObject:SetActiveEx(false) + + self:InitTabBtnState() + + self.BtnStrengthenMax.CallBack = function() + XUiManager.TipMsg(CSTextManager.GetText("EquipStrengthenMaxLevel")) + end + self:ShowPanelRole(true) + self:OpenOneChildUi("UiSimulatedCombatEquipDetailChild", self.TemplateId, self.BreakThroughTime, self.Level) + self:RegisterHelpBtn() +end + +function XUiSimulatedCombatEquipDetail:OnEnable() + self:InitClassifyPanel() +end + +function XUiSimulatedCombatEquipDetail:OnDestroy() + self.PanelWeaponPlane.gameObject:SetActiveEx(true) + if self.Resource then + CS.XResourceManager.Unload(self.Resource) + self.Resource = nil + end +end + +function XUiSimulatedCombatEquipDetail:InitClassifyPanel() + self.FxUiLihuiChuxian01.gameObject:SetActiveEx(false) + if XDataCenter.EquipManager.IsClassifyEqualByTemplateId(self.TemplateId, XEquipConfig.Classify.Weapon) then + local resonanceCount = 0 + local modelConfig = XDataCenter.EquipManager.GetWeaponModelCfg(self.TemplateId, "UiEquipDetail", self.BreakThroughTime, resonanceCount) + if modelConfig then + XModelManager.LoadWeaponModel(modelConfig.ModelId, self.PanelWeapon, modelConfig.TransformConfig, "UiEquipDetail", nil, { gameObject = self.GameObject }) + end + self.PanelWeapon.gameObject:SetActiveEx(true) + self.ImgLihuiMask.gameObject:SetActiveEx(false) + elseif XDataCenter.EquipManager.IsClassifyEqualByTemplateId(self.TemplateId, XEquipConfig.Classify.Awareness) then + local resource = CS.XResourceManager.Load(XDataCenter.EquipManager.GetEquipLiHuiPath(self.TemplateId, self.BreakThroughTime)) + local texture = resource.Asset + self.MeshLihui.sharedMaterial:SetTexture("_MainTex", texture) + if self.Resource then + CS.XResourceManager.Unload(self.Resource) + end + self.Resource = resource + XScheduleManager.ScheduleOnce(function() + self.FxUiLihuiChuxian01.gameObject:SetActiveEx(true) + end, 500) + self.PanelWeapon.gameObject:SetActiveEx(false) + end +end + +function XUiSimulatedCombatEquipDetail:InitTabBtnState() + self.PanelTabGroup.gameObject:SetActiveEx(false) +end + +function XUiSimulatedCombatEquipDetail:InitAutoScript() + self:AutoAddListener() +end + +function XUiSimulatedCombatEquipDetail:AutoAddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainClick) +end + +function XUiSimulatedCombatEquipDetail:OnBtnBackClick() + self:Close() +end + +function XUiSimulatedCombatEquipDetail:OnBtnMainClick() + XLuaUiManager.RunMain() +end + +function XUiSimulatedCombatEquipDetail:RegisterHelpBtn() + --local isClassifyEqual = XDataCenter.EquipManager.IsClassifyEqualByTemplateId(self.TemplateId, XEquipConfig.Classify.Weapon) + --local keyStr = isClassifyEqual and "EquipWeapon" or "EquipAwareness" + self:BindHelpBtn(self.BtnHelp, "SimulatedCombat") +end + +function XUiSimulatedCombatEquipDetail:SetPanelRole() + if XArrangeConfigs.GetType(self.TemplateId) == XArrangeConfigs.Types.Weapon then + local weaponUsers = XDataCenter.EquipManager.GetWeaponUserTemplateIds(self.TemplateId) + for _, v in pairs(weaponUsers) do + local go = CS.UnityEngine.Object.Instantiate(self.PanelText, self.PaneContent) + local tmpObj = {} + tmpObj.Transform = go.transform + tmpObj.GameObject = go.gameObject + XTool.InitUiObject(tmpObj) + tmpObj.Text.text = v.Name .. "-" .. v.TradeName + self:CheckShowRoleTag(v.Id, tmpObj) + tmpObj.GameObject:SetActiveEx(true) + end + self.IsPanelRoleCanShow = weaponUsers and #weaponUsers > 0 + end +end + +function XUiSimulatedCombatEquipDetail:ShowPanelRole(IsShow) + if XArrangeConfigs.GetType(self.TemplateId) == XArrangeConfigs.Types.Weapon and self.IsPreview then + self.PanelRole.gameObject:SetActiveEx(IsShow and self.IsPanelRoleCanShow) + else + self.PanelRole.gameObject:SetActiveEx(false) + end +end + +function XUiSimulatedCombatEquipDetail:OnGetEvents() + return { XEventId.EVENT_ACTIVITY_ON_RESET } +end + +function XUiSimulatedCombatEquipDetail:OnNotify(evt, ...) + local args = { ... } + if evt == XEventId.EVENT_ACTIVITY_ON_RESET then + if args[1] ~= XDataCenter.FubenManager.StageType.Expedition then return end + XLuaUiManager.RunMain() + XUiManager.TipMsg(CS.XTextManager.GetText("ExpeditionOnClose")) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenSimulatedCombat/RoleList/EquipDetail/XUiEquipDetailChild.lua b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/RoleList/EquipDetail/XUiEquipDetailChild.lua new file mode 100644 index 00000000..344efec2 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/RoleList/EquipDetail/XUiEquipDetailChild.lua @@ -0,0 +1,123 @@ +--装备详细子页面 +local XUiSimulatedCombatEquipDetailChild = XLuaUiManager.Register(XLuaUi, "UiSimulatedCombatEquipDetailChild") +local CsXTextManager = CS.XTextManager +local MAX_AWARENESS_ATTR_COUNT = 2 --不包括共鸣属性,最大有2条 + +function XUiSimulatedCombatEquipDetailChild:OnAwake() + self.BtnSuitSkill.gameObject:SetActiveEx(false) + self.BtnResonanceSkill.gameObject:SetActiveEx(false) + self.BtnLaJi.gameObject:SetActiveEx(false) + self.BtnUnLaJi.gameObject:SetActiveEx(false) +end + +function XUiSimulatedCombatEquipDetailChild:OnStart(equipId, breakthrough, level) + self.TemplateId = equipId + self.BreakThrough = breakthrough + self.Level = level + self:InitClassifyPanel() + self:InitEquipInfo() +end + +function XUiSimulatedCombatEquipDetailChild:OnEnable() + self:UpdateEquipAttr() + self:UpdateEquipLevel() + self:UpdateEquipBreakThrough() + self:UpdateEquipLock() + self:UpdateEquipSkillDes() +end + +function XUiSimulatedCombatEquipDetailChild:InitClassifyPanel() + if XDataCenter.EquipManager.IsClassifyEqualByTemplateId(self.TemplateId, XEquipConfig.Classify.Weapon) then + self.TxtTitle.text = CsXTextManager.GetText("WeaponDetailTitle") + self.PanelPainter.gameObject:SetActive(false) + else + self.TxtPainter.text = XDataCenter.EquipManager.GetEquipPainterName(self.TemplateId, self.BreakThrough) + self.PanelPainter.gameObject:SetActive(true) + self.TxtTitle.text = CsXTextManager.GetText("AwarenessDetailTitle") + end +end + +function XUiSimulatedCombatEquipDetailChild:UpdateEquipSkillDes() + if XDataCenter.EquipManager.IsClassifyEqualByTemplateId(self.TemplateId, XEquipConfig.Classify.Weapon) then + local weaponSkillInfo = XDataCenter.EquipManager.GetOriginWeaponSkillInfo(self.TemplateId) + local noWeaponSkill = not weaponSkillInfo.Name and not weaponSkillInfo.Description + self.TxtSkillName.text = weaponSkillInfo.Name + self.TxtSkillDes.text = weaponSkillInfo.Description + self.PanelAwarenessSkillDes.gameObject:SetActive(false) + self.PanelNoAwarenessSkill.gameObject:SetActive(false) + self.PanelWeaponSkillDes.gameObject:SetActive(not noWeaponSkill) + self.PanelNoWeaponSkill.gameObject:SetActive(noWeaponSkill) + elseif XDataCenter.EquipManager.IsClassifyEqualByTemplateId(self.TemplateId, XEquipConfig.Classify.Awareness) then + local suitId = XDataCenter.EquipManager.GetSuitIdByTemplateId(self.TemplateId) + local skillDesList = XDataCenter.EquipManager.GetSuitSkillDesList(suitId) + local noSuitSkill = true + for i = 1, XEquipConfig.MAX_SUIT_SKILL_COUNT do + if skillDesList[i * 2] then + self["TxtSkillDes" .. i].text = skillDesList[i * 2] + self["TxtSkillDes" .. i].gameObject:SetActive(true) + noSuitSkill = false + else + self["TxtSkillDes" .. i].gameObject:SetActive(false) + end + end + self.PanelNoAwarenessSkill.gameObject:SetActive(noSuitSkill) + self.PanelAwarenessSkillDes.gameObject:SetActive(not noSuitSkill) + self.PanelWeaponSkillDes.gameObject:SetActive(false) + self.PanelNoWeaponSkill.gameObject:SetActive(false) + end +end + +function XUiSimulatedCombatEquipDetailChild:UpdateEquipLock() + self.BtnUnlock.gameObject:SetActive(false) + self.BtnLock.gameObject:SetActive(false) +end + +function XUiSimulatedCombatEquipDetailChild:UpdateEquipLevel() + local levelLimit = XEquipConfig.GetEquipBreakthroughCfg(self.TemplateId, self.BreakThrough).LevelLimit + self.TxtLevel.text = CsXTextManager.GetText("EquipLevelText", self.Level, levelLimit) +end + +function XUiSimulatedCombatEquipDetailChild:UpdateEquipBreakThrough() + self:SetUiSprite(self.ImgBreakThrough, XEquipConfig.GetEquipBreakThroughIcon(self.BreakThrough)) +end + +function XUiSimulatedCombatEquipDetailChild:InitEquipInfo() + local star = XDataCenter.EquipManager.GetEquipStar(self.TemplateId) + for i = 1, XEquipConfig.MAX_STAR_COUNT do + if i <= star then + self["ImgStar" .. i].gameObject:SetActive(true) + else + self["ImgStar" .. i].gameObject:SetActive(false) + end + end + + self.TxtEquipName.text = XDataCenter.EquipManager.GetEquipName(self.TemplateId) + + local equipSite = XDataCenter.EquipManager.GetEquipSiteByTemplateId(self.TemplateId) + if equipSite ~= XEquipConfig.EquipSite.Weapon then + self.RImgIcon:SetRawImage(XDataCenter.EquipManager.GetEquipIconBagPath(self.TemplateId, self.BreakThrough)) + self.TxtPos.text = "0" .. equipSite + self.PanelPos.gameObject:SetActive(true) + self.RImgType.gameObject:SetActive(false) + else + self.RImgType:SetRawImage(XEquipConfig.GetWeaponTypeIconPath(self.TemplateId)) + self.RImgType.gameObject:SetActive(true) + self.PanelPos.gameObject:SetActive(false) + end + self.PanelSpecialCharacter.gameObject:SetActive(false) +end + +function XUiSimulatedCombatEquipDetailChild:UpdateEquipAttr() + local attrMap = XDataCenter.EquipManager.ConstructTemplateEquipAttrMap(self.TemplateId, self.BreakThrough, self.Level) + local attrCount = 1 + for _, attrInfo in pairs(attrMap) do + if attrCount > MAX_AWARENESS_ATTR_COUNT then break end + self["TxtName" .. attrCount].text = attrInfo.Name + self["TxtAttr" .. attrCount].text = attrInfo.Value + self["PanelAttr" .. attrCount].gameObject:SetActive(true) + attrCount = attrCount + 1 + end + for i = attrCount, MAX_AWARENESS_ATTR_COUNT do + self["PanelAttr" .. i].gameObject:SetActive(false) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenSimulatedCombat/RoleList/EquipDetail/XUiEquipGrid.lua b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/RoleList/EquipDetail/XUiEquipGrid.lua new file mode 100644 index 00000000..5a0ac384 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/RoleList/EquipDetail/XUiEquipGrid.lua @@ -0,0 +1,101 @@ +--成员列表装备展示控件 +local XUiSimulatedCombatEquipGrid = XClass(nil, "XUiSimulatedCombatEquipGrid") + +function XUiSimulatedCombatEquipGrid:Ctor(ui, clickCb, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self.ClickCb = clickCb + self:InitAutoScript() + self:SetSelected(false) +end + +function XUiSimulatedCombatEquipGrid:Refresh(templateId, breakNum, equipSite, isWeapon, level) + if self.RImgIcon and self.RImgIcon:Exist() then + self.RImgIcon:SetRawImage(XDataCenter.EquipManager.GetEquipIconBagPath(templateId, breakNum), nil, true) + end + + --通用的横条品质色 + if self.ImgQuality then + self.RootUi:SetUiSprite(self.ImgQuality, XDataCenter.EquipManager.GetEquipQualityPath(templateId)) + end + + --装备专用的竖条品质色 + if self.ImgEquipQuality then + self.RootUi:SetUiSprite(self.ImgEquipQuality, XDataCenter.EquipManager.GetEquipBgPath(templateId)) + end + + if self.TxtName then + self.TxtName.text = XDataCenter.EquipManager.GetEquipName(templateId) + end + + if self.TxtLevel then + self.TxtLevel.text = level + end + + if self.PanelSite and self.TxtSite then + if equipSite and not isWeapon then + self.TxtSite.text = "0" .. equipSite + self.PanelSite.gameObject:SetActiveEx(true) + else + self.PanelSite.gameObject:SetActiveEx(false) + end + end + + for i = 1, XEquipConfig.MAX_STAR_COUNT do + if self["ImgGirdStar" .. i] then + if i <= XDataCenter.EquipManager.GetEquipStar(templateId) then + self["ImgGirdStar" .. i].transform.parent.gameObject:SetActiveEx(true) + else + self["ImgGirdStar" .. i].transform.parent.gameObject:SetActiveEx(false) + end + end + end + for i = 1, XEquipConfig.MAX_RESONANCE_SKILL_COUNT do + local obj = self["ImgResonance" .. i] + if obj then + obj.gameObject:SetActiveEx(false) + end + end + self:UpdateBreakthrough(breakNum) +end + +function XUiSimulatedCombatEquipGrid:SetSelected(status) + if XTool.UObjIsNil(self.ImgSelect) then + return + end + self.ImgSelect.gameObject:SetActiveEx(status) +end + +function XUiSimulatedCombatEquipGrid:IsSelected() + return not XTool.UObjIsNil(self.ImgSelect) and self.ImgSelect.gameObject.activeSelf +end + + +function XUiSimulatedCombatEquipGrid:UpdateBreakthrough(breakthroughNum) + if XTool.UObjIsNil(self.ImgBreakthrough) then + return + end + if breakthroughNum > 0 then + local icon = XEquipConfig.GetEquipBreakThroughSmallIcon(breakthroughNum) + if icon then + self.RootUi:SetUiSprite(self.ImgBreakthrough, icon) + self.ImgBreakthrough.gameObject:SetActiveEx(true) + end + else + self.ImgBreakthrough.gameObject:SetActiveEx(false) + end +end + +function XUiSimulatedCombatEquipGrid:InitAutoScript() + XTool.InitUiObject(self) + CsXUiHelper.RegisterClickEvent(self.BtnClick, function() self:OnBtnClickClick() end) +end + +function XUiSimulatedCombatEquipGrid:OnBtnClickClick() + if self.ClickCb then + self.ClickCb(self.EquipId, self) + end +end + +return XUiSimulatedCombatEquipGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenSimulatedCombat/RoleList/XUiRoleList.lua b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/RoleList/XUiRoleList.lua new file mode 100644 index 00000000..725948dd --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/RoleList/XUiRoleList.lua @@ -0,0 +1,141 @@ +--成员列表页面 +local CSXTextManagerGetText = CS.XTextManager.GetText +local XUiSimulatedCombatList = XLuaUiManager.Register(XLuaUi, "UiSimulatedCombatRoleList") +local XUiCharacterList = require("XUi/XUiFubenSimulatedCombat/RoleList/CharacterPanel/XUiCharacterList") +local CAMERA_NUM = 5 +XUiSimulatedCombatList.ChildUiName = { + UiSimulatedCombatListCharaInfo = "UiSimulatedCombatListCharaInfo", + UiSimulatedCombatViewRole = "UiSimulatedCombatViewRole" +} +function XUiSimulatedCombatList:OnAwake() + XTool.InitUiObject(self) + --XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self:AddListener() +end + +function XUiSimulatedCombatList:OnStart(memberId, stageInterId) + self.MemberId = memberId + self.StageInterId = stageInterId + self:OpenChild(XUiSimulatedCombatList.ChildUiName.UiSimulatedCombatListCharaInfo) + self.CharaInfo = self:FindChildUiObj(XUiSimulatedCombatList.ChildUiName.UiSimulatedCombatListCharaInfo) + self:InitModel() + self:InitCharacterList() +end + +function XUiSimulatedCombatList:AddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:BindHelpBtn(self.BtnHelp, "SimulatedCombat") +end + +function XUiSimulatedCombatList:OnBtnBackClick() + if self.OpenChildName == XUiSimulatedCombatList.ChildUiName.UiSimulatedCombatViewRole then + self:OpenChild(XUiSimulatedCombatList.ChildUiName.UiSimulatedCombatListCharaInfo) + self.CharaInfo = self:FindChildUiObj(XUiSimulatedCombatList.ChildUiName.UiSimulatedCombatListCharaInfo) + self:UpdateCamera(XCharacterConfigs.XUiCharacter_Camera.MAIN) + self.TextRoleList.gameObject:SetActiveEx(true) + return + else + self:Close() + end +end + +function XUiSimulatedCombatList:OnBtnMainUiClick() + -- 二次弹窗确认 + local title = CSXTextManagerGetText("TipTitle") + local content = CSXTextManagerGetText("SimulatedCombatBackConfirm") + XUiManager.DialogTip(title, content, XUiManager.DialogType.Normal, nil, function() + XLuaUiManager.RunMain() + end) +end + +function XUiSimulatedCombatList:Refresh(characterId, robotId) + self.RobotId = robotId + self.CharacterId = characterId + self.RobotCfg = XRobotManager.GetRobotTemplate(robotId) + self:UpdateModel(characterId, robotId) + self.CharaInfo:UpdateView(robotId) +end + +function XUiSimulatedCombatList:InitModel() + local root = self.UiModelGo.transform + self.PanelRoleModel = root:FindTransform("PanelRoleModel") + self.ImgEffectHuanren = root:FindTransform("ImgEffectHuanren") + self.ImgEffectHuanren1 = root:FindTransform("ImgEffectHuanren1") + self.ImgEffectLogoGouzao = root:FindTransform("ImgEffectLogoGouzao") + self.ImgEffectLogoGanran = root:FindTransform("ImgEffectLogoGanran") + self.CameraFar = { + root:FindTransform("UiCamFarLv"), + root:FindTransform("UiCamFarGrade"), + root:FindTransform("UiCamFarQuality"), + root:FindTransform("UiCamFarSkill"), + root:FindTransform("UiCamFarrExchange"), + } + self.CameraNear = { + root:FindTransform("UiCamNearLv"), + root:FindTransform("UiCamNearGrade"), + root:FindTransform("UiCamNearQuality"), + root:FindTransform("UiCamNearSkill"), + root:FindTransform("UiCamNearrExchange"), + } + self.RoleModelPanel = XUiPanelRoleModel.New(self.PanelRoleModel, self.Name, nil, true, nil, true) +end + +function XUiSimulatedCombatList:OnGetEvents() + return { XEventId.EVENT_ACTIVITY_ON_RESET } +end + +function XUiSimulatedCombatList:OnNotify(evt, ...) + local args = { ... } + if evt == XEventId.EVENT_ACTIVITY_ON_RESET then + if args[1] ~= XDataCenter.FubenManager.StageType.SimulatedCombat then return end + XDataCenter.FubenSimulatedCombatManager.OnActivityEnd() + end +end + +function XUiSimulatedCombatList:UpdateCamera(index) + self.CurCameraIndex = index + for i = 1, CAMERA_NUM do + if self.CurCameraIndex ~= i then + self.CameraFar[i].gameObject:SetActiveEx(false) + self.CameraNear[i].gameObject:SetActiveEx(false) + end + end + + if self.CameraFar[self.CurCameraIndex] then + self.CameraFar[self.CurCameraIndex].gameObject:SetActiveEx(true) + end + if self.CameraNear[self.CurCameraIndex] then + self.CameraNear[self.CurCameraIndex].gameObject:SetActiveEx(true) + end +end + +function XUiSimulatedCombatList:InitCharacterList() + -- 加载左侧角色列表 + self.CharacterList = XUiCharacterList.New(self.PanelRoleContent, self, self.GridCharacter) + self.CharacterList:UpdateData(self.MemberId) +end + +function XUiSimulatedCombatList:UpdateModel(characterId, robotId) + self.ImgEffectHuanren.gameObject:SetActiveEx(false) + local cb = function(model) + self.PanelDrag.Target = model.transform + self.ImgEffectHuanren.gameObject:SetActiveEx(true) + end + local robotCfg = XRobotManager.GetRobotTemplate(robotId) + self.RoleModelPanel:UpdateRobotModel(robotId, characterId, nil, robotCfg and robotCfg.FashionId, robotCfg and robotCfg.WeaponId, cb) +end + +function XUiSimulatedCombatList:OpenChild(childName) + if self.OpenChildName == childName then return end + self.OpenChildName = childName + self:OpenOneChildUi(childName, self) + if childName == XUiSimulatedCombatList.ChildUiName.UiSimulatedCombatViewRole then + self.TextRoleList.gameObject:SetActiveEx(false) + local propertyChildUi = self:FindChildUiObj(childName) + propertyChildUi:UpdateShowPanel() + end + +end + +return XUiSimulatedCombatList \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenSimulatedCombat/XUiResAllo/XUiPanelCombatAdditions.lua b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/XUiResAllo/XUiPanelCombatAdditions.lua new file mode 100644 index 00000000..dc4d399a --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/XUiResAllo/XUiPanelCombatAdditions.lua @@ -0,0 +1,66 @@ +local XUiPanelCombatAdditions = XClass(nil, "XUiPanelCombatAdditions") +local XUiGridResAlloBuff = require("XUi/XUiFubenSimulatedCombat/ChildItem/XUiGridResAlloBuff") +local BOUNDARY = 3 +function XUiPanelCombatAdditions:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self.AdditionList = XDataCenter.FubenSimulatedCombatManager.GetCurrentResList(XFubenSimulatedCombatConfig.ResType.Addition) + XTool.InitUiObject(self) + self.GridBuff.gameObject:SetActiveEx(false) + self:InitView() + self:UpdateView() +end + +function XUiPanelCombatAdditions:InitView() + self.BuffCenterList = {} + self.BuffLeftList = {} +end + +function XUiPanelCombatAdditions:UpdateView() + self.ResInfo = {} + self.PanelAdditionCenter.gameObject:SetActiveEx(false) + self.PanelAdditionLeft.gameObject:SetActiveEx(false) + self.PanelAdditionNone.gameObject:SetActiveEx(false) + + local count = 0 + for _,v in ipairs(self.AdditionList) do + if v.BuyMethod then + count = count + 1 + self.ResInfo[count] = XFubenSimulatedCombatConfig.GetAdditionById(v.Id) + end + end + if count == 0 then + self.PanelAdditionNone.gameObject:SetActiveEx(true) + elseif count > 0 and count <= BOUNDARY then + self.PanelAdditionCenter.gameObject:SetActiveEx(true) + for i = 1, count do + if not self.BuffCenterList[i] then + local prefab = CS.UnityEngine.GameObject.Instantiate(self.GridBuff.gameObject) + prefab.transform:SetParent(self.AdditionCenter, false) + self.BuffCenterList[i] = XUiGridResAlloBuff.New(prefab, self.RootUi) + end + self.BuffCenterList[i]:Show() + self.BuffCenterList[i]:Refresh(self.ResInfo[i]) + end + for i = count + 1, #self.BuffCenterList do + self.BuffCenterList[i]:Hide() + end + elseif count > BOUNDARY then + self.PanelAdditionLeft.gameObject:SetActiveEx(true) + for i = 1, count do + if not self.BuffLeftList[i] then + local prefab = CS.UnityEngine.GameObject.Instantiate(self.GridBuff.gameObject) + prefab.transform:SetParent(self.AdditionLeft, false) + self.BuffLeftList[i] = XUiGridResAlloBuff.New(prefab, self.RootUi) + end + self.BuffLeftList[i]:Show() + self.BuffLeftList[i]:Refresh(self.ResInfo[i]) + end + for i = count + 1, #self.BuffLeftList do + self.BuffLeftList[i]:Hide() + end + end +end + +return XUiPanelCombatAdditions \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenSimulatedCombat/XUiResAllo/XUiPanelCombatMembers.lua b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/XUiResAllo/XUiPanelCombatMembers.lua new file mode 100644 index 00000000..97fdd790 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/XUiResAllo/XUiPanelCombatMembers.lua @@ -0,0 +1,51 @@ +local XUiPanelCombatMembers = XClass(nil, "XUiPanelCombatMembers") + +local MAX_CHAR_COUNT = 3 + +function XUiPanelCombatMembers:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + self.MemberList = XDataCenter.FubenSimulatedCombatManager.GetCurrentResList(XFubenSimulatedCombatConfig.ResType.Member) + self:InitView() + self:UpdateView() +end + +function XUiPanelCombatMembers:InitView() + self.MemberNoneList = {} + self.MemberGridList = {} + self.IconList = {} + self.TxtStarList = {} + + for i = 1, MAX_CHAR_COUNT do + self.MemberNoneList[i] = self.Transform:Find("Member"..i.."/None") + self.MemberGridList[i] = self.Transform:Find("Member"..i.."/Member") + self.IconList[i] = self.MemberGridList[i]:Find("RImg"):GetComponent("RawImage") + self.TxtStarList[i] = self.MemberGridList[i]:Find("StarInformation"):GetComponent("Text") + end + +end + +function XUiPanelCombatMembers:UpdateView() + for i = 1, MAX_CHAR_COUNT do + self.MemberNoneList[i].gameObject:SetActiveEx(false) + self.MemberGridList[i].gameObject:SetActiveEx(false) + end + + local index = 0 + for _,v in ipairs(self.MemberList) do + if v.BuyMethod and index < MAX_CHAR_COUNT then + index = index + 1 + self.MemberGridList[index].gameObject:SetActiveEx(true) + local resInfo = XFubenSimulatedCombatConfig.GetMemberById(v.Id) + self.IconList[index]:SetRawImage(XRobotManager.GetRobotSmallHeadIcon(resInfo.RobotId)) + self.TxtStarList[index].text = resInfo.Star + end + end + for i = index + 1, MAX_CHAR_COUNT do + self.MemberNoneList[i].gameObject:SetActiveEx(true) + end +end + +return XUiPanelCombatMembers \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenSimulatedCombat/XUiResAllo/XUiSimulatedCombatResAllo.lua b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/XUiResAllo/XUiSimulatedCombatResAllo.lua new file mode 100644 index 00000000..877d48c1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/XUiResAllo/XUiSimulatedCombatResAllo.lua @@ -0,0 +1,217 @@ +local XUiGridRes = require("XUi/XUiFubenSimulatedCombat/ChildItem/XUiGridRes") +local XUiPanelCombatMembers = require("XUi/XUiFubenSimulatedCombat/XUiResAllo/XUiPanelCombatMembers") +local XUiPanelCombatAdditions = require("XUi/XUiFubenSimulatedCombat/XUiResAllo/XUiPanelCombatAdditions") + +local XUiSimulatedCombatResAllo = XLuaUiManager.Register(XLuaUi, "UiSimulatedCombatResAllo") + +local CSXTextManagerGetText = CS.XTextManager.GetText + +local PageIndex = { + Member = 1, + Addition = 2, +} +local CurrencyType = { + Base = 1, + Extra = 2, +} + +function XUiSimulatedCombatResAllo:OnAwake() + self.PayMethod = { + [PageIndex.Member] = 1, + [PageIndex.Addition] = 1, + } + self.TabBtns = {} + self.SwitchEffect = {} +end + +function XUiSimulatedCombatResAllo:OnEnable() + XDataCenter.FubenSimulatedCombatManager.UpdateShopMapCache() + self:Refresh() +end + +function XUiSimulatedCombatResAllo:OnStart(stageInterId) + self.StageInterId = stageInterId + self.StageInterCfg = XFubenSimulatedCombatConfig.GetStageInterData(stageInterId) + self.IsChallengeMode = self.StageInterCfg.Type == XFubenSimulatedCombatConfig.StageType.Challenge + self.ActTemplate = XDataCenter.FubenSimulatedCombatManager.GetCurrentActTemplate() + self.StageInfo = XDataCenter.FubenManager.GetStageInfo(self.StageInterCfg.StageId) + self.IsPassed = self.StageInfo and self.StageInfo.Passed + XDataCenter.FubenSimulatedCombatManager.SelectStageInter(stageInterId) + + self.ConsumeId1 = XDataCenter.FubenSimulatedCombatManager.GetCurrencyIdByNo(CurrencyType.Base) + self.ConsumeId2 = XDataCenter.FubenSimulatedCombatManager.GetCurrencyIdByNo(CurrencyType.Extra) + + self:InitUiView() + self.AssetActivityPanel = XUiPanelActivityAsset.New(self.PanelSpecialTool, true, nil, nil, true) + self.AssetActivityPanel:SetQueryFunc(XDataCenter.FubenSimulatedCombatManager.GetCurrencyByItem) + self.BtnGrpTab:Init({self.BtnMember,self.BtnBuff},function(index) self:SwitchTab(index) end) + self.BtnGrpTab:SelectIndex(PageIndex.Member, false) + self:SwitchTab(PageIndex.Member, true) +end + +function XUiSimulatedCombatResAllo:OnGetEvents() + return { XEventId.EVENT_FUBEN_SIMUCOMBAT_UPDATE, + XEventId.EVENT_ACTIVITY_ON_RESET} +end + +function XUiSimulatedCombatResAllo:OnNotify(evt, ...) + local args = { ... } + if evt == XEventId.EVENT_FUBEN_SIMUCOMBAT_UPDATE then + self:Refresh(...) + elseif evt == XEventId.EVENT_ACTIVITY_ON_RESET then + if args[1] ~= XDataCenter.FubenManager.StageType.SimulatedCombat then return end + XDataCenter.FubenSimulatedCombatManager.OnActivityEnd() + end +end + +function XUiSimulatedCombatResAllo:SwitchTab(index, isFromOtherUi) + if self.CurrentView == index then + return + else + if not isFromOtherUi then + self:PlayAnimation("QieHuan") + end + self.CurrentView = index + + self.ResList = XDataCenter.FubenSimulatedCombatManager.GetCurrentResList(self.CurrentView) + self.DynamicTable:SetDataSource(self.ResList) + self.DynamicTable:ReloadDataASync(1) + + self.PanelCombatAdditions.gameObject:SetActiveEx(index ~= PageIndex.Addition) + self.PanelCombatMembers.gameObject:SetActiveEx(index ~= PageIndex.Member) + if index == PageIndex.Member then + self.PanelMemberTip.gameObject:SetActiveEx(true) + self.TxtMemberTip.gameObject:SetActiveEx(not self.IsChallengeMode) + self.PanelBuffTip.gameObject:SetActiveEx(false) + self.PanelBuyAddition:UpdateView() + elseif index == PageIndex.Addition then + self.PanelMemberTip.gameObject:SetActiveEx(false) + self.PanelBuffTip.gameObject:SetActiveEx(true) + self.PanelBuyMember:UpdateView() + end + self:Refresh() + end +end + +function XUiSimulatedCombatResAllo:Refresh(isFullReload) + if isFullReload then + self.DynamicTable:ReloadDataASync() + else + for _, grid in pairs(self.DynamicTable:GetGrids()) do + grid:ShowPrice() + end + end + + local cur, max = XDataCenter.FubenSimulatedCombatManager.GetMemberCount() + if cur == max or self.IsChallengeMode then + self.TxtMemberCount.text = CS.XTextManager.GetText("SimulatedCombatMemberSelection", cur, max) + else + self.TxtMemberCount.text = CS.XTextManager.GetText("SimulatedCombatMemberSeleNotEnough", cur, max) + end + + local checkEnter = XDataCenter.FubenSimulatedCombatManager.CheckEnterRoom() + self.BtnEnterRoom:SetButtonState(checkEnter and XUiButtonState.Normal or XUiButtonState.Disable) + local checkBuy = XDataCenter.FubenSimulatedCombatManager.CheckBuyRes(self.CurrentView) + self.BtnConfirm:SetButtonState(checkBuy and XUiButtonState.Normal or XUiButtonState.Disable) + + self.AssetActivityPanel:Refresh(self.ActTemplate.ConsumeIds) + self:UpdatePayBill() +end + +function XUiSimulatedCombatResAllo:UpdatePayBill() + local togs = { self.BtnConsume1 } + local bill = XDataCenter.FubenSimulatedCombatManager.CalcPriceCount(self.CurrentView) + self.BtnConsume1:SetRawImage(XDataCenter.FubenSimulatedCombatManager.GetCurrencyIcon(CurrencyType.Base)) + local enough1 = XDataCenter.FubenSimulatedCombatManager.GetCurrencyByNo(CurrencyType.Base) >= bill[self.ConsumeId1] + self.BtnConsume1:SetNameAndColorByGroup(1, bill[self.ConsumeId1], enough1 and XFubenSimulatedCombatConfig.Color.NORMAL or XFubenSimulatedCombatConfig.Color.INSUFFICIENT) + self.BtnConsume2.gameObject:SetActiveEx(not self.IsChallengeMode) + self.TxtBuyMethodSplit.gameObject:SetActiveEx(not self.IsChallengeMode) + if not self.IsChallengeMode then + table.insert(togs, self.BtnConsume2) + local enough2 = XDataCenter.FubenSimulatedCombatManager.GetCurrencyByNo(CurrencyType.Extra) >= bill[self.ConsumeId2] + self.BtnConsume2:SetRawImage(XDataCenter.FubenSimulatedCombatManager.GetCurrencyIcon(CurrencyType.Extra)) + self.BtnConsume2:SetNameAndColorByGroup(1, bill[self.ConsumeId2], enough2 and XFubenSimulatedCombatConfig.Color.NORMAL or XFubenSimulatedCombatConfig.Color.INSUFFICIENT) + end + self.BtnGrpConsume:Init(togs, function(index) self:SwitchPayment(index) end) + self.BtnGrpConsume:SelectIndex(self.PayMethod[self.CurrentView], false) +end + +function XUiSimulatedCombatResAllo:SwitchPayment(index) + self.PayMethod[self.CurrentView] = index +end + +function XUiSimulatedCombatResAllo:InitUiView() + self.DynamicTable = XDynamicTableNormal.New(self.PanelItemList) + self.DynamicTable:SetProxy(XUiGridRes) + self.DynamicTable:SetDelegate(self) + + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + self.BtnEnterRoom.CallBack = function() self:OnBtnEnterRoomClick() end + self.BtnConfirm.CallBack = function() self:OnBtnConfirmClick() end + self:BindHelpBtn(self.BtnHelp, "SimulatedCombat") + + self.TxtTitle.text = XDataCenter.FubenManager.GetStageName(self.StageInterCfg.StageId) + self.TxtMode.text = self.IsChallengeMode and CS.XTextManager.GetText("SimulatedCombatHardMode") or CS.XTextManager.GetText("SimulatedCombatNormalMode") + self.TxtBackOrFailTip.text = CS.XTextManager.GetText("SimulatedCombatBackOrFailTip") + self.TxtChallengeLevel.gameObject:SetActiveEx(self.IsChallengeMode) + local _, clgStar = XDataCenter.FubenSimulatedCombatManager.GetClgMap(self.StageInterCfg.StageId) + self.TxtChallengeLevel.text = CS.XTextManager.GetText("SimulatedCombatStarChallenge", clgStar) + self.TxtMemberTip.text = CS.XTextManager.GetText("SimulatedCombatChallengeMemberTip") + self.BtnMember:SetNameByGroup(0, CS.XTextManager.GetText("SimulatedCombatChallengeBuyMember")) + self.BtnBuff:SetNameByGroup(0, CS.XTextManager.GetText("SimulatedCombatChallengeBuyBuff")) + self.PanelBuyAddition = XUiPanelCombatAdditions.New(self.PanelCombatAdditions, self) + self.PanelBuyMember = XUiPanelCombatMembers.New(self.PanelCombatMembers, self) + self.GridShop.gameObject:SetActiveEx(false) +end + +--动态列表事件 +function XUiSimulatedCombatResAllo:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self.RootUi, self.IsChallengeMode, self.IsPassed, self.StageInterId) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.ResList[index] + if not data then return end + grid:Refresh(data) + end +end + +function XUiSimulatedCombatResAllo:OnBtnBackClick() + local title = CSXTextManagerGetText("TipTitle") + local content = CSXTextManagerGetText("SimulatedCombatBackConfirm") + XUiManager.DialogTip(title, content, XUiManager.DialogType.Normal,nil, function() + self:Close() + end) +end + +function XUiSimulatedCombatResAllo:OnBtnMainUiClick() + local title = CSXTextManagerGetText("TipTitle") + local content = CSXTextManagerGetText("SimulatedCombatBackConfirm") + XUiManager.DialogTip(title, content, XUiManager.DialogType.Normal,nil, function() + XLuaUiManager.RunMain() + end) +end + +function XUiSimulatedCombatResAllo:OnBtnEnterRoomClick() + if not XDataCenter.FubenSimulatedCombatManager.CheckEnterRoom() then + if self.IsChallengeMode then + XUiManager.TipText("SimulatedCombatHardModeMinChar") + else + XUiManager.TipText("SimulatedCombatNormalModeMinChar") + end + return + end + XDataCenter.FubenSimulatedCombatManager.SaveShopMap() + XDataCenter.FubenSimulatedCombatManager.SendPreFightRequest(function() + XLuaUiManager.Open("UiNewRoomSingle", self.StageInterCfg.StageId) + end) +end + +function XUiSimulatedCombatResAllo:OnBtnConfirmClick() + local result, desc = XDataCenter.FubenSimulatedCombatManager.BuySelectedGridRes(self.CurrentView, self.PayMethod[self.CurrentView]) + if result then + XUiManager.TipText("SimulatedCombatBuySucc") + else + XUiManager.TipMsg(desc) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenSimulatedCombat/XUiSettleWin/XUiGridCond.lua b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/XUiSettleWin/XUiGridCond.lua new file mode 100644 index 00000000..37cbed3b --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/XUiSettleWin/XUiGridCond.lua @@ -0,0 +1,15 @@ +local XUiGridCond = XClass(nil, "XUiGridCond") + +function XUiGridCond:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiGridCond:Refresh(desc, active) + self.TxtDesc.text = desc + self.TxtLoaded.gameObject:SetActive(active) + self.TxtNotLoaded.gameObject:SetActive(not active) +end + +return XUiGridCond \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenSimulatedCombat/XUiSettleWin/XUiGridWinRole.lua b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/XUiSettleWin/XUiGridWinRole.lua new file mode 100644 index 00000000..68b82cce --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/XUiSettleWin/XUiGridWinRole.lua @@ -0,0 +1,20 @@ +local XUiGridWinRole = XClass(nil, "XUiGridWinRole") + +function XUiGridWinRole:Ctor(rootUi, ui) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +-- 机器人 +function XUiGridWinRole:UpdateRobotInfo(robotId, starNum) + local data = XRobotManager.GetRobotTemplate(robotId) + self.TxtStar.text = starNum + local icon = XDataCenter.CharacterManager.GetCharBigHeadIcon(data.CharacterId) + if icon then + self.RImgIcon:SetRawImage(icon) + end +end + +return XUiGridWinRole \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenSimulatedCombat/XUiSettleWin/XUiSimulatedCombatSettleWin.lua b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/XUiSettleWin/XUiSimulatedCombatSettleWin.lua new file mode 100644 index 00000000..2b612063 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/XUiSettleWin/XUiSimulatedCombatSettleWin.lua @@ -0,0 +1,344 @@ +local XUiPanelExpBar = require("XUi/XUiSettleWinMainLine/XUiPanelExpBar") +local XUiGridWinRole = require("XUi/XUiFubenSimulatedCombat/XUiSettleWin/XUiGridWinRole") +local XUiGridCond = require("XUi/XUiFubenSimulatedCombat/XUiSettleWin/XUiGridCond") + +local XUiSimulatedCombatSettleWin = XLuaUiManager.Register(XLuaUi, "UiSimulatedCombatSettleWin") + +function XUiSimulatedCombatSettleWin:OnAwake() + self:InitAutoScript() + self.GridReward.gameObject:SetActive(false) +end + +function XUiSimulatedCombatSettleWin:OnStart(data, stageInterInfo, cb, closeCb, onlyTouchBtn) + self.WinData = data + self.StageInfos = XDataCenter.FubenManager.GetStageInfo(data.StageId) + self.StageCfg = XDataCenter.FubenManager.GetStageCfg(data.StageId) + self.StageId = data.StageId + self.StageInterInfo = stageInterInfo + self.Cb = cb + self.CloseCb = closeCb + self.OnlyTouchBtn = onlyTouchBtn + self.IsFirst = true; + self:InitInfo(data) + XLuaUiManager.SetMask(true) + self:PlayRewardAnimation() +end + +function XUiSimulatedCombatSettleWin:OnEnable() + if not self.IsFirst then + XLuaUiManager.SetMask(true) + XScheduleManager.ScheduleOnce(function() + self:PlaySecondAnimation() + end, 0) + end +end + +function XUiSimulatedCombatSettleWin:OnDestroy() + XDataCenter.AntiAddictionManager.EndFightAction() +end + +-- 奖励动画 +function XUiSimulatedCombatSettleWin:PlayRewardAnimation() + local delay = XDataCenter.FubenManager.SettleRewardAnimationDelay + local interval = XDataCenter.FubenManager.SettleRewardAnimationInterval + local this = self + + -- 没有奖励则直接播放第二个动画 + if not self.GridRewardList or #self.GridRewardList == 0 then + XScheduleManager.ScheduleOnce(function() + this:PlaySecondAnimation() + end, delay) + return + end + + self.RewardAnimationIndex = 1 + XScheduleManager.Schedule(function() + if this.RewardAnimationIndex == #self.GridRewardList then + this:PlayReward(this.RewardAnimationIndex, function() + this:PlaySecondAnimation() + end) + else + this:PlayReward(this.RewardAnimationIndex) + end + this.RewardAnimationIndex = this.RewardAnimationIndex + 1 + end, interval, #self.GridRewardList, delay) +end + +-- 第二个动画 +function XUiSimulatedCombatSettleWin:PlaySecondAnimation() + local this = self + self:PlayAnimation("AnimEnable2", function() + XLuaUiManager.SetMask(false) + this:PlayTipMission() + XDataCenter.FunctionEventManager.UnLockFunctionEvent() + self.IsFirst = false; + end) +end + +function XUiSimulatedCombatSettleWin:PlayTipMission() + if XDataCenter.TaskForceManager.ShowMaxTaskForceTeamCountChangeTips then + local missionData = XDataCenter.TaskForceManager.GetTaskForeInfo() + local taskForeCfg = XDataCenter.TaskForceManager.GetTaskForceConfigById(missionData.ConfigIndex) + XUiManager.TipMsg(string.format(CS.XTextManager.GetText("MissionTaskTeamCountContent"), taskForeCfg.MaxTaskForceCount), nil, handler(self, self.PlayShowFriend)) + XDataCenter.TaskForceManager.ShowMaxTaskForceTeamCountChangeTips = false + else + self:PlayShowFriend() + end +end + +function XUiSimulatedCombatSettleWin:PlayShowFriend() + if not (self.CurrAssistInfo ~= nil and self.CurrAssistInfo.Id ~= 0 and self.CurrAssistInfo.Id ~= XPlayer.Id) then + if self.Cb then + self.Cb() + end + return + end + + if XDataCenter.SocialManager.CheckIsApplyed(self.CurrAssistInfo.Id) or XDataCenter.SocialManager.CheckIsFriend(self.CurrAssistInfo.Id) then + if self.Cb then + self.Cb() + end + return + end + + self.TxtName.text = self.CurrAssistInfo.Name + self.TxtLv.text = self.CurrAssistInfo.Level + + XUiPLayerHead.InitPortrait(self.CurrAssistInfo.HeadPortraitId, self.CurrAssistInfo.HeadFrameId, self.Head) + + self.PanelFriend.gameObject:SetActive(true) + self:PlayAnimation("PanelFriendEnable", self.Cb) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiSimulatedCombatSettleWin:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiSimulatedCombatSettleWin:AutoInitUi() + self.PanelNorWinInfo = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo") + self.PanelNor = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor") + self.PanelBtn = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelBtn") + self.PanelBtns = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelBtn/PanelBtns") + self.BtnLeft = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelBtn/PanelBtns/BtnLeft"):GetComponent("Button") + self.TxtLeft = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelBtn/PanelBtns/BtnLeft/TxtLeft"):GetComponent("Text") + self.BtnRight = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelBtn/PanelBtns/BtnRight"):GetComponent("Button") + self.TxtRight = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelBtn/PanelBtns/BtnRight/TxtRight"):GetComponent("Text") + self.PanelTouch = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelBtn/PanelTouch") + self.BtnBlock = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelBtn/PanelTouch/BtnBlock"):GetComponent("Button") + self.TxtLeftA = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelBtn/PanelTouch/BtnBlock/TxtLeft"):GetComponent("Text") + self.PanelLeft = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelLeft") + self.PanelCond = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelLeft/PanelCond") + self.PanelCondContent = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelLeft/PanelCond/PanelCondContent") + self.GridCond = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelLeft/PanelCond/PanelCondContent/GridCond") + self.PanelRoleContent = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelLeft/Team/PanelRoleContent") + self.GridWinRole = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelLeft/Team/PanelRoleContent/GridWinRole") + self.PanelRight = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelRight") + self.TxtChapterName = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelRight/StageInfo/TxtChapterName"):GetComponent("Text") + self.TxtStageName = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelRight/StageInfo/TxtStageName"):GetComponent("Text") + self.PanelRewardContent = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelRight/RewardList/Viewport/PanelRewardContent") + self.GridReward = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelRight/RewardList/Viewport/PanelRewardContent/GridReward") + self.PanelFriend = self.Transform:Find("SafeAreaContentPane/PanelFriend") + self.PanelInf = self.Transform:Find("SafeAreaContentPane/PanelFriend/PanelInf") + self.PanelHead = self.Transform:Find("SafeAreaContentPane/PanelFriend/PanelInf/PanelHead") + self.TxtName = self.Transform:Find("SafeAreaContentPane/PanelFriend/PanelInf/TxtName"):GetComponent("Text") + self.TxtLv = self.Transform:Find("SafeAreaContentPane/PanelFriend/PanelInf/TxtLv"):GetComponent("Text") + self.BtnFriClose = self.Transform:Find("SafeAreaContentPane/PanelFriend/BtnFriClose"):GetComponent("Button") + self.BtnFriAdd = self.Transform:Find("SafeAreaContentPane/PanelFriend/BtnFriAdd"):GetComponent("Button") + self.PanelPlayerExpBar = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelLeft/PlayerExp/PanelPlayerExpBar") + self.PanelFirst = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelFirst") + self.PanelRewardList = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelRight/RewardList") + self.PanelAssist = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelRight/PanelAssist") + self.TxtAssist = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelRight/PanelAssist/TxtAssist"):GetComponent("Text") +end + +function XUiSimulatedCombatSettleWin:AutoAddListener() + self:RegisterClickEvent(self.BtnLeft, self.OnBtnLeftClick) + self:RegisterClickEvent(self.BtnRight, self.OnBtnRightClick) + self:RegisterClickEvent(self.BtnBlock, self.OnBtnBlockClick) + self:RegisterClickEvent(self.BtnFriClose, self.OnBtnFriCloseClick) + self:RegisterClickEvent(self.BtnFriAdd, self.OnBtnFriAddClick) +end +-- auto + +function XUiSimulatedCombatSettleWin:InitInfo(data) + XTipManager.Execute() + self:UpdateConditions(data.StageId, data.StarsMap) + self:SetBtnsInfo(data) + self:SetStageInfo(data) + self:UpdatePlayerInfo(data) + self:InitRobotList(data) + self:InitRewardList(data.RewardGoodsList) + XTipManager.Add(function() + if data.UrgentId > 0 then + XLuaUiManager.Open("UiSettleUrgentEvent", data.UrgentId) + end + end) +end + +function XUiSimulatedCombatSettleWin:SetBtnsInfo(data) + local canGetReward = false + if self.StageInterInfo.Type == XFubenSimulatedCombatConfig.StageType.Challenge then + self.PanelRewardInfo.gameObject:SetActiveEx(true) + local remainTime = XDataCenter.FubenSimulatedCombatManager.GetDailyRewardRemainCount() + self.TxtRewardTime.text = remainTime + if remainTime > 0 then + canGetReward = true + end + elseif self.StageInterInfo.Type == XFubenSimulatedCombatConfig.StageType.Normal then + self.PanelRewardInfo.gameObject:SetActiveEx(false) + end + self.PanelTouch.gameObject:SetActive(not canGetReward) + self.PanelBtns.gameObject:SetActive(canGetReward) +end + +function XUiSimulatedCombatSettleWin:SetStageInfo(data) + self.PanelFirst.gameObject:SetActiveEx(false) + + local chapterName, stageName = XDataCenter.FubenManager.GetFubenNames(data.StageId) + self.TxtChapterName.text = chapterName + self.TxtStageName.text = stageName +end + +-- 角色奖励列表 +function XUiSimulatedCombatSettleWin:InitRobotList(data) + self.GridWinRole.gameObject:SetActive(false) + + for i, v in ipairs(data.NpcInfo) do + if v.CharacterId > 0 then + local ui = CS.UnityEngine.Object.Instantiate(self.GridWinRole) + local grid = XUiGridWinRole.New(self, ui) + grid.Transform:SetParent(self.PanelRoleContent, false) + local data = XDataCenter.FubenSimulatedCombatManager.GetCurStageMemberDataByCharId(v.CharacterId) + grid:UpdateRobotInfo(data.RobotId ,data.Star) + grid.GameObject:SetActive(true) + end + end +end + +-- 玩家经验 +function XUiSimulatedCombatSettleWin:UpdatePlayerInfo(data) + if not data or not next(data) then return end + + local lastLevel = data.RoleLevel + local lastExp = data.RoleExp + local lastMaxExp = XPlayerManager.GetMaxExp(lastLevel, XPlayer.IsHonorLevelOpen()) + local curLevel = XPlayer.GetLevelOrHonorLevel() + local curExp = XPlayer.Exp + local curMaxExp = XPlayerManager.GetMaxExp(curLevel, XPlayer.IsHonorLevelOpen()) + local txtLevelName = XPlayer.IsHonorLevelOpen() and CS.XTextManager.GetText("HonorLevel") or CS.XTextManager.GetText("PlayerLevelShort") + local addExp = self.StageCfg.TeamExp + self.PlayerExpBar = self.PlayerExpBar or XUiPanelExpBar.New(self.PanelPlayerExpBar) + self.PlayerExpBar:LetsRoll(lastLevel, lastExp, lastMaxExp, curLevel, curExp, curMaxExp, addExp, txtLevelName) +end + +-- 物品奖励列表 +function XUiSimulatedCombatSettleWin:InitRewardList(rewardGoodsList) + self.PanelAssist.gameObject:SetActiveEx(false) + self.PanelRewardList.gameObject:SetActiveEx(true) + + if self.StageInterInfo.Type == XFubenSimulatedCombatConfig.StageType.Challenge then + local remainTime = XDataCenter.FubenSimulatedCombatManager.GetDailyRewardRemainCount() + if remainTime <= 0 then + self.TxtRewardTimeTitle.gameObject:SetActiveEx(true) + self.TxtRewardTimeTitle.text = CS.XTextManager.GetText("SimulatedCombatNoRewardTodayTip") + return + end + end + + rewardGoodsList = rewardGoodsList or {} + self.GridRewardList = {} + local rewards = XRewardManager.MergeAndSortRewardGoodsList(rewardGoodsList) + for _, item in ipairs(rewards) do + local ui = CS.UnityEngine.Object.Instantiate(self.GridReward) + local grid = XUiGridCommon.New(self, ui) + grid.Transform:SetParent(self.PanelRewardContent, false) + grid:Refresh(item, nil, nil, true) + grid.GameObject:SetActive(false) + table.insert(self.GridRewardList, grid) + end +end + +-- 显示胜利满足的条件 +function XUiSimulatedCombatSettleWin:UpdateConditions(stageId, starMap) + self.GridCond.gameObject:SetActive(false) + if starMap == nil then + self.PanelCond.gameObject:SetActiveEx(false) + return + end + + self.GridCondList = {} + for i = 1, #starMap do + local ui = CS.UnityEngine.Object.Instantiate(self.GridCond) + local grid = XUiGridCond.New(ui) + grid.Transform:SetParent(self.PanelCondContent, false) + local clgInfo = XFubenSimulatedCombatConfig.GetChallengeById(self.StageInterInfo.ChallengeIds[i]) + if clgInfo then + grid:Refresh(clgInfo.Description, starMap[i]) + grid.GameObject:SetActive(true) + end + self.GridCondList[i] = grid + end +end + +function XUiSimulatedCombatSettleWin:OnBtnLeftClick() + self:Close() +end + +function XUiSimulatedCombatSettleWin:OnBtnRightClick() + XDataCenter.FubenSimulatedCombatManager.GetStageReward(function() + XUiManager.TipText("SimulatedCombatGetRewardSucc") + self:Close() + end) +end + +function XUiSimulatedCombatSettleWin:OnBtnEnterNextClick() + if self.StageInfos.Type == XDataCenter.FubenManager.StageType.Tower then + local stageId = XDataCenter.TowerManager.GetTowerData().CurrentStageId + if XDataCenter.TowerManager.CheckStageCanEnter(stageId) then + XLuaUiManager.PopThenOpen("UiNewRoomSingle", stageId) + else + local text = CS.XTextManager.GetText("TowerCannotEnter") + XUiManager.TipMsg(text, XUiManager.UiTipType.Tip) + end + else + if self.StageInfos.NextStageId then + local nextStageCfg = XDataCenter.FubenManager.GetStageCfg(self.StageInfos.NextStageId) + self:HidePanel() + XDataCenter.FubenManager.OpenRoomSingle(nextStageCfg) + else + local text = CS.XTextManager.GetText("BattleWinMainCannotEnter") + XUiManager.TipMsg(text, XUiManager.UiTipType.Tip) + end + end +end + +function XUiSimulatedCombatSettleWin:OnBtnBackClick(isRunMain) + if isRunMain then + XLuaUiManager.RunMain() + else + self:HidePanel() + end +end + +function XUiSimulatedCombatSettleWin:OnBtnBlockClick() + self:HidePanel() + if self.CloseCb then + self:CloseCb() + end +end + +function XUiSimulatedCombatSettleWin:HidePanel() + self:Close() +end + +function XUiSimulatedCombatSettleWin:PlayCondition(index, cb) + self:PlayAnimation("GirdCond", cb) +end + +function XUiSimulatedCombatSettleWin:PlayReward(index, cb) + self.GridRewardList[index].GameObject:SetActive(true) + self:PlayAnimation("GridReward", cb) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenSimulatedCombat/XUiSimulatedCombatBossBuffTips.lua b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/XUiSimulatedCombatBossBuffTips.lua new file mode 100644 index 00000000..29db362a --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/XUiSimulatedCombatBossBuffTips.lua @@ -0,0 +1,33 @@ +--词缀展示页面 +local XUiSimulatedCombatBossBuffTips = XLuaUiManager.Register(XLuaUi, "UiSimulatedCombatBossBuffTips") +local XUiBuffTipsItem = require("XUi/XUiFubenSimulatedCombat/ChildItem/XUiBuffTipsItem") +function XUiSimulatedCombatBossBuffTips:OnAwake() + XTool.InitUiObject(self) + self.GridBuff.gameObject:SetActiveEx(false) + self:RegisterUiButtonEvent() +end + +function XUiSimulatedCombatBossBuffTips:OnStart(buffList) + if not buffList then return end + self.BuffList = buffList + self:RefreshStageType() + --self.TxtTitle.text = "" +end + +function XUiSimulatedCombatBossBuffTips:RegisterUiButtonEvent() + self.BtnClose.CallBack = function() self:OnBtnCloseClick() end +end + +function XUiSimulatedCombatBossBuffTips:OnBtnCloseClick() + self:Close() +end + +function XUiSimulatedCombatBossBuffTips:RefreshStageType() + for _, buffId in pairs(self.BuffList) do + local prefab = CS.UnityEngine.Object.Instantiate(self.GridBuff.gameObject) + prefab.transform:SetParent(self.PanelContent.transform, false) + local tipItem = XUiBuffTipsItem.New(prefab, self) + tipItem:RefreshData(buffId) + tipItem.GameObject:SetActiveEx(true) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenSimulatedCombat/XUiSimulatedCombatBuffTip.lua b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/XUiSimulatedCombatBuffTip.lua new file mode 100644 index 00000000..8e4e717b --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/XUiSimulatedCombatBuffTip.lua @@ -0,0 +1,54 @@ +local XUiSimulatedCombatBuffTip = XLuaUiManager.Register(XLuaUi, "UiSimulatedCombatBuffTip") + +function XUiSimulatedCombatBuffTip:OnAwake() + self.SpecialSoundMap = {} + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnOk, self.OnBtnOkClick) +end + +function XUiSimulatedCombatBuffTip:OnStart(additionId) + local musicKey = self:GetAutoKey(self.BtnBack, "onClick") + self.SpecialSoundMap[musicKey] = XSoundManager.UiBasicsMusic.Return + self.Data = XFubenSimulatedCombatConfig.GetAdditionById(additionId) + self:PlayAnimation("AnimStart") +end + +function XUiSimulatedCombatBuffTip:OnEnable() + self:Refresh(self.Data) +end + +function XUiSimulatedCombatBuffTip:GetAutoKey(uiNode, eventName) + if not uiNode then + return + end + return eventName .. uiNode:GetHashCode() +end + +-- auto +function XUiSimulatedCombatBuffTip:OnBtnBackClick() + self:Close() +end + +function XUiSimulatedCombatBuffTip:OnBtnOkClick() + self:Close() +end + +function XUiSimulatedCombatBuffTip:Refresh(data) + self.Data = data + if not data then + XLog.Error("XUiSimulatedCombatBuffTip:Refresh错误: 参数data不能为空") + return + end + + -- 名称 + self.TxtName.text = data.Name + + -- 图标 + self.RImgIcon:SetRawImage(data.Icon) + + -- 星级 + self.TxtStarCount.text = data.Star + + -- 描述 + self.TxtDescription.text = CS.XTextManager.GetText("SimulatedCombatBuffTipPrefix")..data.Description +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenSimulatedCombat/XUiSimulatedCombatChapter.lua b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/XUiSimulatedCombatChapter.lua new file mode 100644 index 00000000..34708ff1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/XUiSimulatedCombatChapter.lua @@ -0,0 +1,320 @@ +local XUiSimulatedCombatChapter = XClass(nil, "XUiSimulatedCombatChapter") +local XUiStageItem = require("XUi/XUiFubenSimulatedCombat/ChildItem/XUiStageItem") + +local FUBEN_FIGHT_DETAIL = "UiSimulatedCombatStageDetail" +local XUguiDragProxy = CS.XUguiDragProxy + +function XUiSimulatedCombatChapter:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + + self.StageGroup = {} + self.NeedReset = false +end + +function XUiSimulatedCombatChapter:OnEnable() + if self.PanelStageList and self.NeedReset then + self:SetPanelStageListMovementType(CS.UnityEngine.UI.ScrollRect.MovementType.Elastic) + self:ReopenAssetPanel() + else + self.NeedReset = true + end + + -- 线条处理 + self:HandleStageLines() + -- 关卡处理 + self:HandleStages() + -- 彩蛋处理 + --self:HandleEggStage() +end + +function XUiSimulatedCombatChapter:OnDestroy() + self.IsOpenDetails = nil + self:StopActivityTimer() +end + +function XUiSimulatedCombatChapter:OpenDefaultStage(stageId) + if self.StageInterDatas and self.ChapterStages then + for i = 2, #self.StageInterDatas do + if self.StageInterDatas[i].StageId == stageId and self.ChapterStages[i] then + self.ChapterStages[i]:OnBtnStageClick() + break + end + end + end +end + +function XUiSimulatedCombatChapter:SetUiData(chapterType) + self.LastUnlockStage = 1 + self.ChapterType = chapterType + self.ChapterTemplate = XDataCenter.FubenSimulatedCombatManager.GetCurrentActTemplate() + if not self.ChapterTemplate then return end + self.StageInterDatas = XFubenSimulatedCombatConfig.GetStageInterDataByType(chapterType) + -- 初始化prefab组件 + local chapterGameObject = self.Transform:LoadPrefab(self.ChapterTemplate.ChapterPrefab[chapterType]) + --XTool.InitUiObjectByUi(self, chapterGameObject) + + local uiObj = chapterGameObject.transform:GetComponent("UiObject") + for i = 0, uiObj.NameList.Count - 1 do + self[uiObj.NameList[i]] = uiObj.ObjList[i] + end + + if self.PaneStageList then + local dragProxy = self.PaneStageList:GetComponent(typeof(XUguiDragProxy)) + if not dragProxy then + dragProxy = self.PaneStageList.gameObject:AddComponent(typeof(XUguiDragProxy)) + end + dragProxy:RegisterHandler(handler(self, self.OnDragProxy)) + end + --self.StageInterDatas = self:GetFakeStages() + -- 线条处理 + self:HandleStageLines() + + self:UpdateNodeLines() + -- 关卡处理 + self:HandleStages() + -- 彩蛋处理 + --self:HandleEggStage() + -- 界面信息 + --self:SwitchFestivalBg(chapterTemplate) + -- 加载特效 + --self:LoadEffect(chapterTemplate.EffectUrl) + + self:MoveIntoStage(self.LastUnlockStage) +end + +function XUiSimulatedCombatChapter:HandleStages() + self.ChapterStages = {} + for i = 1, #self.StageInterDatas do + local itemStage = self.PanelStageContent:Find(string.format("Stage%d", i+1)) + if not itemStage then + XLog.Error("XUiSimulatedCombatChapter:HandleStages() 函数错误: 游戏物体PanelStageContent下找不到名字为:" .. string.format("Stage%d", i) .. "的游戏物体") + return + else + --XLog.Warning("itemStage",itemStage, i) + end + -- 组件初始化 + itemStage.gameObject:SetActiveEx(true) + self.StageGroup[i] = itemStage + self.ChapterStages[i] = XUiStageItem.New(self, itemStage) + self.ChapterStages[i]:UpdateNode(self.StageInterDatas[i]) + self.ChapterStages[i]:SetChallengingStage(i == self.LastUnlockStage) + end + + -- 隐藏多余组件 + --local indexStage = #self.StageInterDatas + 2 + --local extraStage = self.PanelStageContent:Find(string.format("Stage%d", indexStage)) + --while extraStage do + -- extraStage.gameObject:SetActiveEx(false) + -- indexStage = indexStage + 1 + -- extraStage = self.PanelStageContent:Find(string.format("Stage%d", indexStage)) + --end +end + +function XUiSimulatedCombatChapter:HandleStageLines() + self.ChapterStageLine = {} + for i = 1, #self.StageInterDatas do + local itemLine = self.PanelStageContent:Find(string.format("Line%d", i)) + if not itemLine then + XLog.Error("XUiSimulatedCombatChapter:SetUiData() error: prefab not found a child name:" .. string.format("Line%d", i)) + return + end + itemLine.gameObject:SetActiveEx(false) + self.ChapterStageLine[i] = itemLine + end + + -- 隐藏多余组件 + local indexLine = #self.ChapterStageLine + local extraLine = self.PanelStageContent:Find(string.format("Line%d", indexLine)) + while extraLine do + extraLine.gameObject:SetActiveEx(false) + indexLine = indexLine + 1 + extraLine = self.PanelStageContent:Find(string.format("Line%d", indexLine)) + end +end + +-- 更新节点线条 +function XUiSimulatedCombatChapter:UpdateNodeLines() + if not self.StageInterDatas then return end + local stageLength = #self.StageInterDatas + + for i = 2, stageLength do + local isOpen = XDataCenter.FubenManager.CheckStageOpen(self.StageInterDatas[i].StageId) + self:SetStageLineActive(i, isOpen) + local isUnlock = XDataCenter.FubenManager.CheckStageIsUnlock(self.StageInterDatas[i].StageId) + if isUnlock then + self.LastUnlockStage = i + end + end + self:SetStageLineActive(1, false) + self:SetStageLineActive(stageLength + 1, true) +end + +function XUiSimulatedCombatChapter:SetStageLineActive(index, isActive) + if self.ChapterStageLine[index] then + self.ChapterStageLine[index].gameObject:SetActiveEx(isActive) + end +end + +--function XUiSimulatedCombatChapter:HandleEggStage() +-- self.ChapterStageLine[1].gameObject:SetActiveEx(false) +-- local eggStageIndex = 1 +-- local eggStageId = self.FestivalStageIds[eggStageIndex] +-- if XDataCenter.FubenFestivalActivityManager.IsEgg(eggStageId) then +-- -- 彩蛋处理 +-- local isUnlock = XDataCenter.FubenFestivalActivityManager.CheckFestivalStageOpen(eggStageId) +-- self.FestivalStages[eggStageIndex].GameObject:SetActiveEx(isUnlock) +-- local stageCfg = XDataCenter.FubenManager.GetStageCfg(eggStageId) +-- if isUnlock and stageCfg then +-- if stageCfg.PreStageId and stageCfg.PreStageId[1] then +-- for i = 1, #self.FestivalStageIds do +-- if stageCfg.PreStageId[1] == self.FestivalStageIds[i] then +-- self.FestivalStages[eggStageIndex]:ResetItemPosition(self.FestivalStages[i].Transform.localPosition) +-- break +-- end +-- end +-- end +-- end +-- else +-- -- 非彩蛋 +-- self.FestivalStages[eggStageIndex].GameObject:SetActiveEx(false) +-- end +-- self.FestivalStageLine[eggStageIndex].gameObject:SetActiveEx(false) +--end + +-- 选中关卡 +function XUiSimulatedCombatChapter:UpdateNodesSelect(stageId) + for i = 1, #self.StageInterDatas do + if self.ChapterStages[i] then + self.ChapterStages[i]:SetNodeSelect(self.StageInterDatas[i].StageId == stageId) + end + end +end + +-- 取消选中 +function XUiSimulatedCombatChapter:ClearNodesSelect() + for i = 1, #self.StageInterDatas do + if self.ChapterStages[i] then + self.ChapterStages[i]:SetNodeSelect(false) + end + end + self.IsOpenDetails = false +end + +-- 没有彩蛋则增加一个假彩蛋 +function XUiSimulatedCombatChapter:GetFakeStages() + local stageIds = {} + for i = 1, #self.ChapterStages do + stageIds[i] = self.ChapterStages[i] + end + table.insert(stageIds, 1, stageIds[1]) + return stageIds +end + +-- 打开剧情,战斗详情 +function XUiSimulatedCombatChapter:OpenStageDetails(stageInterId) + self.IsOpenDetails = true + self.BtnCloseDetail.gameObject:SetActiveEx(true) + self.RootUi:OpenOneChildUi(FUBEN_FIGHT_DETAIL, self) + self.RootUi:FindChildUiObj(FUBEN_FIGHT_DETAIL):SetStageDetail(stageInterId) + + if self.AssetPanel then + self.AssetPanel.GameObject:SetActiveEx(false) + end + self.PanelStageContentRaycast.raycastTarget = false +end + +-- 关闭剧情,战斗详情 +function XUiSimulatedCombatChapter:CloseStageDetails() + self.IsOpenDetails = false + self.BtnCloseDetail.gameObject:SetActiveEx(false) + self.PanelStageContentRaycast.raycastTarget = true + self:ClearNodesSelect() + self:ReopenAssetPanel() + self:SetPanelStageListMovementType(CS.UnityEngine.UI.ScrollRect.MovementType.Elastic) +end + +function XUiSimulatedCombatChapter:OnBtnCloseDetailClick() + self:CloseStageDetails() +end + +function XUiSimulatedCombatChapter:OnDragProxy(dragType) + if self.IsOpenDetails and dragType == 0 then + self:CloseStageDetails() + end +end + +function XUiSimulatedCombatChapter:PlayScrollViewMove(gridTransform) + self:SetPanelStageListMovementType(CS.UnityEngine.UI.ScrollRect.MovementType.Unrestricted) + local gridRect = gridTransform:GetComponent("RectTransform") + local diffX = gridRect.localPosition.x + self.PanelStageContent.localPosition.x + if diffX < XDataCenter.FubenMainLineManager.UiGridChapterMoveMinX or diffX > XDataCenter.FubenMainLineManager.UiGridChapterMoveMaxX then + local tarPosX = XDataCenter.FubenMainLineManager.UiGridChapterMoveTargetX - gridRect.localPosition.x + local tarPos = self.PanelStageContent.localPosition + tarPos.x = tarPosX + XLuaUiManager.SetMask(true) + XUiHelper.DoMove(self.PanelStageContent, tarPos, XDataCenter.FubenMainLineManager.UiGridChapterMoveDuration, XUiHelper.EaseType.Sin, function() + XLuaUiManager.SetMask(false) + end) + end +end + +function XUiSimulatedCombatChapter:MoveIntoStage(stageIndex) + local gridRect = self.StageGroup[stageIndex] + local diffX = gridRect.localPosition.x + self.PanelStageContent.localPosition.x + --XLog.Warning("diffX", diffX, CS.XResolutionManager.OriginWidth / 2) + if diffX > CS.XResolutionManager.OriginWidth / 2 then + local tarPosX = (CS.XResolutionManager.OriginWidth / 4) - gridRect.localPosition.x + local tarPos = self.PanelStageContent.localPosition + tarPos.x = tarPosX + XLuaUiManager.SetMask(true) + self:SetPanelStageListMovementType(CS.UnityEngine.UI.ScrollRect.MovementType.Unrestricted) + XUiHelper.DoMove(self.PanelStageContent, tarPos, XDataCenter.FubenMainLineManager.UiGridChapterMoveDuration, XUiHelper.EaseType.Sin, function() + XLuaUiManager.SetMask(false) + self:SetPanelStageListMovementType(CS.UnityEngine.UI.ScrollRect.MovementType.Elastic) + end) + end +end + +function XUiSimulatedCombatChapter:EndScrollViewMove() + self:SetPanelStageListMovementType(CS.UnityEngine.UI.ScrollRect.MovementType.Elastic) + self:ReopenAssetPanel() +end + +function XUiSimulatedCombatChapter:ReopenAssetPanel() + if self.IsOpenDetails then + return + end + if self.AssetPanel then + self.AssetPanel.GameObject:SetActiveEx(true) + end +end + +-- 背景 +function XUiSimulatedCombatChapter:SwitchFestivalBg(festivalTemplate) + if not festivalTemplate or not festivalTemplate.MainBackgound then + self.RImgFestivalBg.gameObject:SetActiveEx(false) + return + end + self.RImgFestivalBg:SetRawImage(festivalTemplate.MainBackgound) +end + +-- 加载特效 +function XUiSimulatedCombatChapter:LoadEffect(effectUrl) + if not effectUrl or effectUrl == "" then + self.PanelEffect.gameObject:SetActiveEx(false) + return + end + + self.PanelEffect.gameObject:LoadUiEffect(effectUrl) + self.PanelEffect.gameObject:SetActiveEx(true) +end + +function XUiSimulatedCombatChapter:SetPanelStageListMovementType(movementType) + if not self.PanelStageList then return end + self.PanelStageList.movementType = movementType +end + +return XUiSimulatedCombatChapter \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenSimulatedCombat/XUiSimulatedCombatMain.lua b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/XUiSimulatedCombatMain.lua new file mode 100644 index 00000000..44de634f --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/XUiSimulatedCombatMain.lua @@ -0,0 +1,298 @@ +local XUiGridPointReward = require("XUi/XUiFubenSimulatedCombat/ChildItem/XUiGridPointReward") +local XUiSimulatedCombatChapter = require("XUi/XUiFubenSimulatedCombat/XUiSimulatedCombatChapter") +local Lerp = CS.UnityEngine.Mathf.Lerp + +local XUiSimulatedCombatMain = XLuaUiManager.Register(XLuaUi, "UiSimulatedCombatMain") + +local StageType = XFubenSimulatedCombatConfig.StageType +local ChildUiType = { + Task = 1, + Star = 2, +} +local ChildUiName = { + [ChildUiType.Task] = "UiSimulatedCombatTaskReward", + [ChildUiType.Star] = "UiSimulatedCombatStarReward", +} + +function XUiSimulatedCombatMain:OnAwake() + self.TabBtns = {} + self.SwitchEffect = {} +end + +function XUiSimulatedCombatMain:OnEnable() + if not XLuaUiManager.IsUiLoad("UiSimulatedCombatResAllo") then + XDataCenter.FubenSimulatedCombatManager.ResetChange() + end + + if self.RedPointActive then + XRedPointManager.Check(self.RedPointActive) + end + + if self.RedPointStarReward then + XRedPointManager.Check(self.RedPointStarReward) + end + + if self.RedPointTask then + XRedPointManager.Check(self.RedPointTask) + end + + self:Refresh() +end + +function XUiSimulatedCombatMain:OnStart(defaultView, childUiType) + self.CurrentView = defaultView or StageType.Normal + self.ActTemplate = XDataCenter.FubenSimulatedCombatManager.GetCurrentActTemplate() + if not self.ActTemplate then + self:Close() + end + + self:CreateActivityTimer(XDataCenter.FubenSimulatedCombatManager.GetEndTime()) + self.TxtChapterName.text = self.ActTemplate.Name + + self:InitUiView() + self.AssetActivityPanel = XUiPanelActivityAsset.New(self.PanelSpecialTool, true) + self.AssetActivityPanel:SetQueryFunc(XDataCenter.FubenSimulatedCombatManager.GetCurrencyByItem) + self.PointRewardGridList = {} + + self:OnSwitchView(self.CurrentView, true) + if childUiType then + self:OpenOneChildUi(ChildUiName[childUiType], self) + end + self.RedPointActive = XRedPointManager.AddRedPointEvent(self.BtnSwitchHard, self.OnCheckChallenge, self, { XRedPointConditions.Types.CONDITION_SIMULATED_COMBAT_CHALLENGE }, nil, true) + self.RedPointStarReward = XRedPointManager.AddRedPointEvent(self.BtnStarReward, self.OnCheckStarReward, self, { XRedPointConditions.Types.CONDITION_SIMULATED_COMBAT_STAR }, nil, true) + self.RedPointTask = XRedPointManager.AddRedPointEvent(self.BtnTask, self.OnCheckTask, self, { XRedPointConditions.Types.CONDITION_SIMULATED_COMBAT_TASK }, nil, true) +end + +function XUiSimulatedCombatMain:OnGetEvents() + return { XEventId.EVENT_FUBEN_SIMUCOMBAT_UPDATE, + XEventId.EVENT_FUBEN_SIMUCOMBAT_REWARD, + XEventId.EVENT_ACTIVITY_ON_RESET} +end + +function XUiSimulatedCombatMain:OnNotify(evt, ...) + local args = { ... } + if evt == XEventId.EVENT_FUBEN_SIMUCOMBAT_UPDATE then + self:Refresh(args) + elseif evt == XEventId.EVENT_FUBEN_SIMUCOMBAT_REWARD then + self:SetupPointReward() + elseif evt == XEventId.EVENT_ACTIVITY_ON_RESET then + if args[1] ~= XDataCenter.FubenManager.StageType.SimulatedCombat then return end + XDataCenter.FubenSimulatedCombatManager.OnActivityEnd() + end +end + +function XUiSimulatedCombatMain:OnCheckChallenge(count) + self.BtnSwitchHard:ShowReddot(count >= 0) + self.BtnSwitchNormal:ShowReddot(false) +end + +function XUiSimulatedCombatMain:OnCheckStarReward(count) + self.BtnStarReward:ShowReddot(count >= 0) +end + +function XUiSimulatedCombatMain:OnCheckTask(count) + self.BtnTask:ShowReddot(count >= 0) +end + +function XUiSimulatedCombatMain:Refresh() + self.BtnSwitchNormal.gameObject:SetActiveEx(self.CurrentView == StageType.Challenge) + self.BtnSwitchHard.gameObject:SetActiveEx(self.CurrentView == StageType.Normal) + self.PanelStage:SetUiData(self.CurrentView) + self.AssetActivityPanel:Refresh(self.ActTemplate.ConsumeIds) + self:SetupReward() + self.TxtChllengeRewardTime.text = XDataCenter.FubenSimulatedCombatManager.GetDailyRewardRemainCount() + + local isOpen = XConditionManager.CheckCondition(self.ActTemplate.HardConditionId) + self.BtnSwitchHard:SetButtonState(isOpen and XUiButtonState.Normal or XUiButtonState.Disable) +end + +function XUiSimulatedCombatMain:OnDestroy() + self:StopActivityTimer() +end + +--设置奖励 +function XUiSimulatedCombatMain:SetupReward() + if self.ActTemplate.PointId ~= 0 then + XDataCenter.ItemManager.AddCountUpdateListener(self.ActTemplate.PointId, function () + self:SetupPointReward() + end, self.GameObject) + self:SetupPointReward() + end + self:SetupStarReward() +end + +function XUiSimulatedCombatMain:SetupPointReward() + local pointCount = XDataCenter.ItemManager.GetCount(self.ActTemplate.PointId) + local pointRewardCfg = XFubenSimulatedCombatConfig.GetPointReward() + self.TxtPoint.text = pointCount + local defaultIndex + for index in ipairs(pointRewardCfg) do + local tmpPointCfg = XFubenSimulatedCombatConfig.GetPointRewardById(index) + local nextPointCfg = XFubenSimulatedCombatConfig.GetPointRewardById(index + 1) or nil + local grid + if not self.PointRewardGridList[index] then + if index == 1 then + grid = XUiGridPointReward.New(self.GridCourse, self) + self.GridCourse.gameObject:SetActiveEx(true) + self.GridCourse.transform:SetParent(self.PanelCourseContainer, false) + else + local ui = CS.UnityEngine.Object.Instantiate(self.GridCourse) + ui.gameObject:SetActiveEx(true) + ui.transform:SetParent(self.PanelCourseContainer, false) + grid = XUiGridPointReward.New(ui, self) + end + self.PointRewardGridList[index] = grid + else + grid = self.PointRewardGridList[index] + end + + -- 从0开始的第一段 特殊处理 + if index == 1 then + if pointCount < tmpPointCfg.NeedPoint then + self.ImgFirstPassedLine.fillAmount = pointCount / tmpPointCfg.NeedPoint + else + self.ImgFirstPassedLine.fillAmount = 1 + end + end + + grid:UpdateData(tmpPointCfg, nextPointCfg, pointCount) + if not defaultIndex and not XDataCenter.FubenSimulatedCombatManager.CheckPointRewardGet(index) then + defaultIndex = index + end + end + -- 针对全部领取的情况处理滑动 + if not defaultIndex then + defaultIndex = #pointRewardCfg + --如果最后一个没有被领取则不是全部被领取 + if not XDataCenter.FubenSimulatedCombatManager.CheckPointRewardGet(defaultIndex) then + defaultIndex = nil + end + end + + if defaultIndex then + self:SetSViewIndex(defaultIndex) + end +end + +function XUiSimulatedCombatMain:SetSViewIndex(defaultIndex) + local pointRewardCfg = XFubenSimulatedCombatConfig.GetPointReward() + local length = #pointRewardCfg or 0 + local percentage = 0 + + if defaultIndex then + if defaultIndex <= 5 then + defaultIndex = -1 + end + + if length > 0 then + percentage = (defaultIndex + 1) / (length + 1) + end + CS.UnityEngine.Canvas.ForceUpdateCanvases() + end + + self.AnimTimer = XUiHelper.Tween(0.7, function(f) + local tempPercentage = Lerp(self.SViewCourse.horizontalNormalizedPosition, percentage, f) + self.SViewCourse.horizontalNormalizedPosition = tempPercentage + end, nil, function(t) + return XUiHelper.Evaluate(XUiHelper.EaseType.Sin, t) + end) +end + +function XUiSimulatedCombatMain:SetupStarReward() + local totalStars = 0 + local isRed = false + local curStars = XDataCenter.FubenSimulatedCombatManager.GetStarProgress() + local starRewardList = XDataCenter.FubenSimulatedCombatManager.GetStarRewardList() + + for i, v in ipairs(starRewardList) do + totalStars = totalStars < v.RequireStar and v.RequireStar or totalStars + if v.IsFinish and not v.IsReward then + isRed = true + end + end + + self.ImgJindu.fillAmount = totalStars > 0 and curStars / totalStars or 0 + self.ImgJindu.gameObject:SetActiveEx(true) + --self.ImgLingqu.gameObject:SetActiveEx(totalStars <= curStars and (not isRed)) + self.BtnStarReward:ShowReddot(isRed) + + self.TxtStarNum.text = string.format("%d/%d", curStars, totalStars) +end + +function XUiSimulatedCombatMain:InitUiView() + self.BtnTask.CallBack = function() self:OpenOneChildUi(ChildUiName[ChildUiType.Task], self) end + self.BtnStarReward.CallBack = function() self:OpenOneChildUi(ChildUiName[ChildUiType.Star], self) end + + self.SceneBtnBack.CallBack = function() self:OnBtnBackClick() end + self.SceneBtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + + self.BtnSwitchNormal.CallBack = function() self:OnSwitchView(StageType.Normal) end + self.BtnSwitchHard.CallBack = function() self:OnSwitchView(StageType.Challenge) end + self.BtnChllengeRewardHelp.CallBack = function() self:OnBtnChllengeRewardHelpClick() end + + self:BindHelpBtn(self.BtnHelp, "SimulatedCombat") + self.PanelStage = XUiSimulatedCombatChapter.New(self.PanelChapter, self) +end + +function XUiSimulatedCombatMain:OnBtnBackClick() + self:Close() +end + +function XUiSimulatedCombatMain:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiSimulatedCombatMain:OnBtnChllengeRewardHelpClick() + XUiManager.UiFubenDialogTip(CsXTextManagerGetText("SimulatedCombatChallengeRewardHelpTitle"), CsXTextManagerGetText("SimulatedCombatChallengeRewardHelpContent")) +end + +function XUiSimulatedCombatMain:OnSwitchView(type, isFromOtherUi) + local isOpen, desc = XDataCenter.FubenSimulatedCombatManager.CheckModeOpen(type) + if not isOpen then + XUiManager.TipMsg(desc) + return + end + + if not isFromOtherUi then + self:PlayAnimation("QieHuan") + end + self.CurrentView = type + + self.RImgBgNor.gameObject:SetActiveEx(type == StageType.Normal) + self.RImgBgHard.gameObject:SetActiveEx(type == StageType.Challenge) + self.PanelHard.gameObject:SetActiveEx(type == StageType.Challenge) + self:Refresh() +end + +-- 背景 +function XUiSimulatedCombatMain:SwitchBg(actTemplate) + if not actTemplate or not actTemplate.MainBackgound then return end + self.RImgFestivalBg:SetRawImage(actTemplate.MainBackgound) +end + +-- 计时器 +function XUiSimulatedCombatMain:CreateActivityTimer(endTime) + local time = XTime.GetServerNowTimestamp() + self.TxtDay.text = XUiHelper.GetTime(endTime - time, XUiHelper.TimeFormatType.ACTIVITY) + self:StopActivityTimer() + self.ActivityTimer = XScheduleManager.ScheduleForever(function() + time = XTime.GetServerNowTimestamp() + if time > endTime then + --self:StopActivityTimer() + return + end + self.TxtDay.text = XUiHelper.GetTime(endTime - time, XUiHelper.TimeFormatType.ACTIVITY) + end, XScheduleManager.SECOND, 0) +end + +function XUiSimulatedCombatMain:StopActivityTimer() + if self.ActivityTimer then + XScheduleManager.UnSchedule(self.ActivityTimer) + self.ActivityTimer = nil + end + + if self.AnimTimer then + XScheduleManager.UnSchedule(self.AnimTimer) + self.AnimTimer = nil + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenSimulatedCombat/XUiSimulatedCombatNewRoomSingle.lua b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/XUiSimulatedCombatNewRoomSingle.lua new file mode 100644 index 00000000..42456e32 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/XUiSimulatedCombatNewRoomSingle.lua @@ -0,0 +1,77 @@ +-- 模拟战斗出战界面代理 +local XUiSimulatedCombatNewRoomSingle = {} +local CSXTextManagerGetText = CS.XTextManager.GetText + +function XUiSimulatedCombatNewRoomSingle.InitEditBattleUi(newRoomSingle) + newRoomSingle.BtnTeamPrefab.gameObject:SetActiveEx(false) + newRoomSingle.PanelCharacterLimit.gameObject:SetActiveEx(false) +end + +function XUiSimulatedCombatNewRoomSingle.InitEditBattleUiCharacterInfo(newRoomSingle) + newRoomSingle.BtnShowInfoToggle.gameObject:SetActiveEx(false) + newRoomSingle.IsShowCharacterInfo = 0 +end + +function XUiSimulatedCombatNewRoomSingle.GetBattleTeamData(newRoomSingle) + local curTeam = XDataCenter.FubenSimulatedCombatManager.GetTeam() + XDataCenter.TeamManager.SaveTeamLocal(curTeam, newRoomSingle.CurrentStageId) + XDataCenter.TeamManager.SetPlayerTeam(curTeam, false) + return curTeam +end + +function XUiSimulatedCombatNewRoomSingle.HandleCharClick(newRoomSingle, charPos) + XLuaUiManager.Open("UiSimulatedCombatRoomCharacter", XTool.Clone(newRoomSingle.CurTeam.TeamData), charPos, function(resTeam) + newRoomSingle:UpdateTeam(resTeam) + end) +end + +function XUiSimulatedCombatNewRoomSingle.HandleBtnMainUiClick() + local title = CSXTextManagerGetText("TipTitle") + local content = CSXTextManagerGetText("SimulatedCombatBackConfirm") + XUiManager.DialogTip(title, content, XUiManager.DialogType.Normal, nil, function() + XLuaUiManager.RunMain() + end) +end + +function XUiSimulatedCombatNewRoomSingle.UpdateTeam(newRoomSingle) + XDataCenter.TeamManager.SaveTeamLocal(newRoomSingle.CurTeam, newRoomSingle.CurrentStageId) + XDataCenter.TeamManager.SetPlayerTeam(newRoomSingle.CurTeam, false) +end + +function XUiSimulatedCombatNewRoomSingle.UpdateRoleModel(newRoomSingle, charId, roleModelPanel, pos) + roleModelPanel:ShowRoleModel() + local callback = function() + newRoomSingle.LoadModelCount = newRoomSingle.LoadModelCount - 1 + if newRoomSingle.LoadModelCount <= 0 then + newRoomSingle.BtnEnterFight:SetDisable(false) + end + end + + local data = XDataCenter.FubenSimulatedCombatManager.GetCurStageMemberDataByCharId(charId) + if not data then + XLog.Error("no data ", charId) + return + end + local robotCfg = XRobotManager.GetRobotTemplate(data.RobotId) + roleModelPanel:UpdateRobotModel(data.RobotId, charId, callback, robotCfg.FashionId, robotCfg.WeaponId) +end + +function XUiSimulatedCombatNewRoomSingle.OnResetEvent(newRoomSingle) + XLuaUiManager.RunMain() + XUiManager.TipMsg(CS.XTextManager.GetText("ActivityMainLineEnd")) +end + +function XUiSimulatedCombatNewRoomSingle.GetRealCharData(newRoomSingle) + local teamData = newRoomSingle.CurTeam.TeamData + local teamIdData = {} + for pos, charId in pairs(teamData) do + if charId and charId > 0 then + local data = XDataCenter.FubenSimulatedCombatManager.GetCurStageMemberDataByCharId(charId) + teamIdData[pos] = data and data.RobotId or 0 + else + teamIdData[pos] = 0 + end + end + return teamIdData +end +return XUiSimulatedCombatNewRoomSingle \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenSimulatedCombat/XUiSimulatedCombatRoomCharacter.lua b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/XUiSimulatedCombatRoomCharacter.lua new file mode 100644 index 00000000..6a21e244 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/XUiSimulatedCombatRoomCharacter.lua @@ -0,0 +1,206 @@ +--角色选择界面 +local XUiSimulatedCombatRoomCharacter = XLuaUiManager.Register(XLuaUi, "UiSimulatedCombatRoomCharacter") +local XUiSimulatedCombatRoomCharListGrid = require("XUi/XUiFubenSimulatedCombat/ChildItem/XUiRoomCharListGrid") + +local CSXTextManagerGetText = CS.XTextManager.GetText + +function XUiSimulatedCombatRoomCharacter:OnAwake() + XTool.InitUiObject(self) + self.AssetActivityPanel = XUiPanelActivityAsset.New(self.PanelSpecialTool, true) + self.AssetActivityPanel:SetQueryFunc(XDataCenter.FubenSimulatedCombatManager.GetCurrencyByItem) + local root = self.UiModelGo.transform + self.PanelRoleModel = root:FindTransform("PanelRoleModel") + self.ImgEffectHuanren = root:FindTransform("ImgEffectHuanren") + self.GridCharacter.gameObject:SetActiveEx(false) + self.RoleModelPanel = XUiPanelRoleModel.New(self.PanelRoleModel, self.Name, nil, true, nil, true) + self.DynamicTable = XDynamicTableNormal.New(self.SViewCharacterList) + self.DynamicTable:SetProxy(XUiSimulatedCombatRoomCharListGrid) + self.DynamicTable:SetDelegate(self) + + self:AddListener() +end + +function XUiSimulatedCombatRoomCharacter:OnStart(teamData, changePos, cb) + self.TeamData = teamData + self.ChangePos = changePos + self.ActTemplate = XDataCenter.FubenSimulatedCombatManager.GetCurrentActTemplate() + self.MemberList = XDataCenter.FubenSimulatedCombatManager.GetRoomMemberList() + -- XLog.Warning("RoomCharacter", teamData, "- split - ", self.MemberList) + local charId = teamData[changePos] + if charId ~= 0 then + for i, v in pairs(self.MemberList) do + if v == charId then + self.CurrentSelect = i + end + end + self.CurrentSelect = self.CurrentSelect or 1 + else + self.CurrentSelect = 1 + end + self:UpdateList() + self.CallBack = cb +end + +function XUiSimulatedCombatRoomCharacter:OnEnable() + CS.XGraphicManager.UseUiLightDir = true + self:UpdateList() +end + +function XUiSimulatedCombatRoomCharacter:Refresh(charId, robotId) + if not self.ActTemplate then return end + self.RobotId = robotId + self:UpdateModel(charId, robotId) + self:SetTeamBtns(charId) + + self.AssetActivityPanel:Refresh(self.ActTemplate.ConsumeIds) +end + +function XUiSimulatedCombatRoomCharacter:UpdateModel(characterId, robotId) + if not characterId then return end + self.ImgEffectHuanren.gameObject:SetActiveEx(false) + self.ImgEffectHuanren.gameObject:SetActiveEx(true) + local callback = function() + self.ModelReady = true + end + self.ModelReady = false + local robotCfg = XRobotManager.GetRobotTemplate(robotId) + if not robotCfg then return end + self.RoleModelPanel:UpdateRobotModel(robotId, characterId, callback, robotCfg and robotCfg.FashionId, robotCfg and robotCfg.WeaponId) +end + +function XUiSimulatedCombatRoomCharacter:OnDisable() + CS.XGraphicManager.UseUiLightDir = false +end + +function XUiSimulatedCombatRoomCharacter:OnDestroy() + if self.CallBack then + self.CallBack(self.TeamData) + self.CallBack = nil + end +end +function XUiSimulatedCombatRoomCharacter:SetTeamBtns(charId) + local isInTeam = self:IsInTeam(charId) + self.BtnJoinTeam.gameObject:SetActiveEx(not isInTeam) + self.BtnQuitTeam.gameObject:SetActiveEx(isInTeam) +end + +function XUiSimulatedCombatRoomCharacter:OnGetEvents() + return { XEventId.EVENT_ACTIVITY_ON_RESET } +end + +function XUiSimulatedCombatRoomCharacter:OnNotify(evt, ...) + local args = { ... } + if evt == XEventId.EVENT_ACTIVITY_ON_RESET then + if args[1] ~= XDataCenter.FubenManager.StageType.SimulatedCombat then return end + XDataCenter.FubenSimulatedCombatManager.OnActivityEnd() + end +end +function XUiSimulatedCombatRoomCharacter:AddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:RegisterClickEvent(self.BtnJoinTeam, self.OnBtnJoinClick) + self:RegisterClickEvent(self.BtnQuitTeam, self.OnBtnQuitClick) +end + +function XUiSimulatedCombatRoomCharacter:OnBtnBackClick() + self:Close() +end + +function XUiSimulatedCombatRoomCharacter:OnBtnMainUiClick() + local title = CSXTextManagerGetText("TipTitle") + local content = CSXTextManagerGetText("SimulatedCombatBackConfirm") + XUiManager.DialogTip(title, content, XUiManager.DialogType.Normal, nil, function() + XLuaUiManager.RunMain() + end) +end + +function XUiSimulatedCombatRoomCharacter:OnBtnJoinClick() + local id = self.MemberList[self.CurrentSelect] + for k, v in pairs(self.TeamData) do + if v == id then + self.TeamData[k] = 0 + break + end + end + + self.TeamData[self.ChangePos] = id + if self.CallBack then + self.CallBack(self.TeamData) + self.CallBack = nil + end + self:Close() +end + +function XUiSimulatedCombatRoomCharacter:OnBtnQuitClick() + local count = 0 + for _, v in pairs(self.TeamData) do + if v > 0 then + count = count + 1 + end + end + + local id = self.MemberList[self.CurrentSelect] + for k, v in pairs(self.TeamData) do + if v == id then + self.TeamData[k] = 0 + break + end + end + + if self.CallBack then + self.CallBack(self.TeamData) + self.CallBack = nil + end + self:Close() +end + +function XUiSimulatedCombatRoomCharacter:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(grid.DynamicGrid.gameObject, self) + if self.CurrentSelect == index then + self:SetSelectCharacter(grid) + end + local charId = self.MemberList[index] + grid:SetInTeam(self:IsInTeam(charId)) + grid:Refresh(charId) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:SetSelect(false) + grid:SetInTeam(false) + if self.CurrentSelect == index then + self:SetSelectCharacter(grid) + end + local charId = self.MemberList[index] + grid:SetInTeam(self:IsInTeam(charId)) + grid:Refresh(charId) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + self.CurrentSelect = index + self:SetSelectCharacter(grid) + end +end + +function XUiSimulatedCombatRoomCharacter:UpdateList() + self.DynamicTable:SetDataSource(self.MemberList) + if #self.MemberList > 0 then + self.DynamicTable:ReloadDataSync(self.CurrentSelect) + end +end + +--选中 +function XUiSimulatedCombatRoomCharacter:SetSelectCharacter(grid) + if self.CurCharacterGrid then + self.CurCharacterGrid:SetSelect(false) + end + self.CurCharacterGrid = grid + self.CurCharacterGrid:SetSelect(true) +end + +function XUiSimulatedCombatRoomCharacter:IsInTeam(id) + for _, v in pairs(self.TeamData) do + if v == id then + return true + end + end + return false +end + +return XUiSimulatedCombatRoomCharacter \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenSimulatedCombat/XUiSimulatedCombatStageDetail.lua b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/XUiSimulatedCombatStageDetail.lua new file mode 100644 index 00000000..0ba8b8a0 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/XUiSimulatedCombatStageDetail.lua @@ -0,0 +1,238 @@ +--玩法关卡点击后的关卡详细 +local XUiGridStageBuffIcon = require("XUi/XUiFubenSimulatedCombat/ChildItem/XUiGridStageBuffIcon") +local XUiSimulatedCombatStageDetail = XLuaUiManager.Register(XLuaUi, "UiSimulatedCombatStageDetail") +function XUiSimulatedCombatStageDetail:OnAwake() + XTool.InitUiObject(self) + self.AssetActivityPanel = XUiPanelActivityAsset.New(self.PanelSpecialTool, true) + self.AssetActivityPanel:SetQueryFunc(XDataCenter.FubenSimulatedCombatManager.GetCurrencyByItem) +end + +function XUiSimulatedCombatStageDetail:OnStart(chapter) + self.Chapter = chapter + self.RootUi = chapter.RootUi +end + +function XUiSimulatedCombatStageDetail:SetStageDetail(stageInterId) + self.Data = XFubenSimulatedCombatConfig.GetStageInterData(stageInterId) + self.StageId = self.Data.StageId + self.StageCfg = XDataCenter.FubenManager.GetStageCfg(self.StageId) + self.ActTemplate = XDataCenter.FubenSimulatedCombatManager.GetCurrentActTemplate() + self.StageType = self.Data.Type + self.StageInfo = XDataCenter.FubenManager.GetStageInfo(self.StageId) + self.IsPassed = self.StageInfo and self.StageInfo.Passed + self.ClgMap = XDataCenter.FubenSimulatedCombatManager.GetClgMap(self.StageId) + + self:SetUi() +end + +function XUiSimulatedCombatStageDetail:SetUi() + local panelDetail + if self.StageType == XFubenSimulatedCombatConfig.StageType.Normal then + panelDetail = self.PanelDetailNor + elseif self.StageType == XFubenSimulatedCombatConfig.StageType.Challenge then + panelDetail = self.PanelDetailHard + end + + XTool.InitUiObjectByUi(self, panelDetail) + self.PanelDetailNor.gameObject:SetActiveEx(self.StageType == XFubenSimulatedCombatConfig.StageType.Normal) + self.PanelDetailHard.gameObject:SetActiveEx(self.StageType == XFubenSimulatedCombatConfig.StageType.Challenge) + + self:SetDropList() + self:SetBuffList() + self:SetNormalStage() + self:SetHardStage() + + self.TxtTitle.text = self.StageCfg.Name + --ImgCostIcon + self.TxtATNums.text = self.IsPassed and 0 or self.StageCfg.RequireActionPoint + self.BtnClose.CallBack = function() self:OnBtnClose() end + self.BtnEnter.CallBack = function() self:OnBtnEnter() end + self.AssetActivityPanel:Refresh(self.ActTemplate.ConsumeIds) + +end + +function XUiSimulatedCombatStageDetail:SetNormalStage() + if self.StageType ~= XFubenSimulatedCombatConfig.StageType.Normal then return end + local target = self.StageCfg.StarDesc + local gridStage = {} + for i = 1, 3 do + gridStage[i] = self["GridStageStar" .. i] + gridStage[i].gameObject:SetActiveEx(false) + end + for i = 1, #target do + if target[i] then + gridStage[i].gameObject:SetActiveEx(true) + gridStage[i]:Find("TxtTip"):GetComponent("Text").text = string.gsub(target[i], "【Consume%d】", " ") + local currencyNo = string.match(string.match(target[i], "【Consume%d】") or "", "%d") + local currencyIcon = XDataCenter.FubenSimulatedCombatManager.GetCurrencyIcon(currencyNo) + local rImgCurrencyIcon = gridStage[i]:Find("RImgCurrencyIcon") + if currencyIcon then + rImgCurrencyIcon.gameObject:SetActiveEx(true) + rImgCurrencyIcon:GetComponent("RawImage"):SetRawImage(currencyIcon) + else + rImgCurrencyIcon.gameObject:SetActiveEx(false) + end + end + end + + -- 掉落特殊处理 + self.PanelDropNone.gameObject:SetActiveEx(self.IsPassed) + if self.IsPassed then + for j = 1, #self.GridList do + self.GridList[j].GameObject:SetActiveEx(false) + end + return + end + -------- +end + +function XUiSimulatedCombatStageDetail:SetHardStage() + if self.StageType ~= XFubenSimulatedCombatConfig.StageType.Challenge then return end + -- 进阶挑战 + self.BtnClgList = {} + -- 读取上一次状态 + for i, passed in ipairs(self.StageInfo.StarsMap) do + local grid = self["GridStage"..i] + grid:Find("IconStar").gameObject:SetActiveEx(passed) + grid:Find("IconStarNone").gameObject:SetActiveEx(not passed) + local clgCfg = XFubenSimulatedCombatConfig.GetChallengeById(self.Data.ChallengeIds[i]) + local btn = grid:Find("BtnCondition"):GetComponent("XUiButton") + self.BtnClgList[i] = btn + if clgCfg then + grid.gameObject:SetActiveEx(true) + btn:SetNameByGroup(0, clgCfg.Description) + btn:SetButtonState(self.ClgMap[i] and XUiButtonState.Select or XUiButtonState.Normal) + btn.CallBack = function(value) self:OnSelectIndex(i, value) end + else + grid.gameObject:SetActiveEx(false) + end + end + local star = XDataCenter.FubenSimulatedCombatManager.GetStageStar(self.StageId) + if star then + self.TxtFinishChallengeStar.text = CS.XTextManager.GetText("SimulatedCombatStarChallengeFinish", star) + else + self.TxtFinishChallengeStar.text = CS.XTextManager.GetText("SimulatedCombatStarChallengeNotFinish") + end + local remainTime = XDataCenter.FubenSimulatedCombatManager.GetDailyRewardRemainCount() + self.TxtDropTime.text = CS.XTextManager.GetText("SimulatedCombatRewardTime", remainTime) +end + +function XUiSimulatedCombatStageDetail:OnSelectIndex(i, value) + self.ClgMap[i] = value == 1 + self:SetDropList() +end + +function XUiSimulatedCombatStageDetail:OnBtnClose() + self:Close() + self.Chapter:CloseStageDetails() +end + +function XUiSimulatedCombatStageDetail:OnBtnEnter() + if self.StageType == XFubenSimulatedCombatConfig.StageType.Challenge and self.StarCount == 0 then + local title = CSXTextManagerGetText("TipTitle") + local content = CSXTextManagerGetText("SimulatedCombatStarChallengeNoneConfirm") + XUiManager.DialogTip(title, content, XUiManager.DialogType.Normal,nil, function() + self:EnterShop() + end) + else + self:EnterShop() + end +end + +function XUiSimulatedCombatStageDetail:EnterShop() + XDataCenter.FubenSimulatedCombatManager.SaveClgMap(self.StageId, self.ClgMap) + -- 保存当前选中的状态 + if not XDataCenter.FubenManager.CheckPreFight(self.StageCfg) then + return + end + self:OnBtnClose() + XLuaUiManager.Remove("UiSimulatedCombatResAllo") + XLuaUiManager.Open("UiSimulatedCombatResAllo", self.Data.Id) +end + +function XUiSimulatedCombatStageDetail:SetDropList() + if not self.GridList then self.GridList = {} end + --由当前模式和星级确定奖励id + local rewardId = self.StageCfg.FirstRewardId + if self.StageType == XFubenSimulatedCombatConfig.StageType.Challenge then + self.StarCount = 0 + for _, v in ipairs(self.ClgMap) do + if v then + self.StarCount = self.StarCount + 1 + end + end + self.TxtFirstDrop.text = CS.XTextManager.GetText("SimulatedCombatRewardStar", self.StarCount) + rewardId = self.Data.StarRewardIds[self.StarCount] + end + if not rewardId or rewardId == 0 then + for j = 1, #self.GridList do + self.GridList[j].GameObject:SetActiveEx(false) + end + return + end + + self.GridCommon.gameObject:SetActive(false) + local rewards = XRewardManager.GetRewardList(rewardId) or XRewardManager.GetRewardListNotCount(rewardId) + if rewards then + for i, item in ipairs(rewards) do + local grid + if self.GridList[i] then + grid = self.GridList[i] + else + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommon) + grid = XUiGridCommon.New(self.RootUi, ui) + self.GridList[i] = grid + end + grid.Transform.localScale = self.GridCommon.localScale + grid.Transform:SetParent(self.PanelDropContent, false) + grid:Refresh(item) + grid.GameObject:SetActiveEx(true) + end + end + local rewardsCount = 0 + if rewards then + rewardsCount = #rewards + end + for j = 1, #self.GridList do + if j > rewardsCount then + self.GridList[j].GameObject:SetActiveEx(false) + end + end +end + +function XUiSimulatedCombatStageDetail:SetBuffList() + if not self.BuffList then self.BuffList = {} end + local buffList = self.Data.ShowFightEventIds + self.GridBuff.gameObject:SetActiveEx(false) + self.StageBuffCfgList = {} + for i = 1, #buffList do + if not self.BuffList[i] then + local prefab = CS.UnityEngine.GameObject.Instantiate(self.GridBuff.gameObject) + self.BuffList[i] = XUiGridStageBuffIcon.New(prefab, self.RootUi) + end + end + for i = 1, #self.BuffList do + self.BuffList[i].Transform:SetParent(self.PanelBuffContent, false) + if buffList[i] then + self.BuffList[i]:RefreshData(buffList[i]) + self.BuffList[i]:Show() + table.insert(self.StageBuffCfgList, buffList[i]) + else + self.BuffList[i]:Hide() + end + end + + self.BtnBuffTip.CallBack = function() + self:OnBtnBuffTip() + end + self.PanelBuffNone.gameObject:SetActiveEx(#buffList == 0) +end + +function XUiSimulatedCombatStageDetail:OnBtnBuffTip() + local buffList = self.Data.ShowFightEventIds + if buffList and next(buffList) then + XLuaUiManager.Open("UiSimulatedCombatBossBuffTips", buffList) + end +end + +return XUiSimulatedCombatStageDetail \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenSimulatedCombat/XUiSimulatedCombatStarReward.lua b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/XUiSimulatedCombatStarReward.lua new file mode 100644 index 00000000..4f895cfc --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/XUiSimulatedCombatStarReward.lua @@ -0,0 +1,52 @@ +local XUiSimulatedCombatStarReward = XLuaUiManager.Register(XLuaUi, "UiSimulatedCombatStarReward") + +local XUiGridStarReward = require("XUi/XUiFubenSimulatedCombat/ChildItem/XUiGridStarReward") +function XUiSimulatedCombatStarReward:OnAwake() + + self.GridTreasureGrade.gameObject:SetActive(false) + + self.DynamicTable = XDynamicTableNormal.New(self.PanelTreasureGrade) + self.DynamicTable:SetDelegate(self) + self.DynamicTable:SetProxy(XUiGridStarReward) + + CsXUiHelper.RegisterClickEvent(self.BtnTreasureBg, handler(self, self.Close)) + self.BtnTanchuangCloseBig.CallBack = function() self:Close() end +end + +function XUiSimulatedCombatStarReward:OnEnable() + self:SetupStarReward(true) +end + +function XUiSimulatedCombatStarReward:OnStart(rootUi) + self.RootUi = rootUi +end + +function XUiSimulatedCombatStarReward:OnGetEvents() + return { XEventId.EVENT_FUBEN_SIMUCOMBAT_UPDATE } +end +function XUiSimulatedCombatStarReward:OnNotify(evt, ...) + if evt == XEventId.EVENT_FUBEN_SIMUCOMBAT_UPDATE then + self:SetupStarReward(...) + end +end + +function XUiSimulatedCombatStarReward:SetupStarReward(isFullReload) + local starRewardList, _, startIndex = XDataCenter.FubenSimulatedCombatManager.GetStarRewardList() + + self.StarRewardList = starRewardList + + self.DynamicTable:SetDataSource(self.StarRewardList) + if isFullReload then + self.DynamicTable:ReloadDataSync(startIndex) + end +end + +function XUiSimulatedCombatStarReward:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid.RootUi = self + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.StarRewardList[index] + if not data then return end + grid:Refresh(data) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenSimulatedCombat/XUiSimulatedCombatTaskReward.lua b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/XUiSimulatedCombatTaskReward.lua new file mode 100644 index 00000000..11d8925c --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenSimulatedCombat/XUiSimulatedCombatTaskReward.lua @@ -0,0 +1,125 @@ +local XUiSimulatedCombatTaskReward = XLuaUiManager.Register(XLuaUi, "UiSimulatedCombatTaskReward") + +local XUiGridTask = require("XUi/XUiFubenSimulatedCombat/ChildItem/XUiGridTask") + +function XUiSimulatedCombatTaskReward:OnAwake() + self.DynamicTable = XDynamicTableNormal.New(self.PanelTaskList) + self.DynamicTable:SetDelegate(self) + self.DynamicTable:SetProxy(XUiGridTask) + + CsXUiHelper.RegisterClickEvent(self.BtnBg, handler(self, self.Close)) + self.BtnClose.CallBack = function() self:Close() end + self.GridTask.gameObject:SetActiveEx(false) +end + +function XUiSimulatedCombatTaskReward:OnStart(rootUi) + self.RootUi = rootUi +end + +--停止计时器 +function XUiSimulatedCombatTaskReward:StopTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end + +--活动时间倒计时 +function XUiSimulatedCombatTaskReward:SetTimer() + local endTimeSecond = XTime.GetSeverTomorrowFreshTime() + local now = XTime.GetServerNowTimestamp() + if now <= endTimeSecond then + self:StopTimer() + if now <= endTimeSecond then + self.TxtTime.text = string.format("%s", XUiHelper.GetTime(endTimeSecond - now, XUiHelper.TimeFormatType.DAILY_TASK)) + else + self.TxtTime.text = "" + end + + self.Timer = XScheduleManager.ScheduleForever(function() + now = XTime.GetServerNowTimestamp() + if now > endTimeSecond then + self:StopTimer() + return + end + if now <= endTimeSecond then + self.TxtTime.text = string.format("%s", XUiHelper.GetTime(endTimeSecond - now, XUiHelper.TimeFormatType.DAILY_TASK)) + else + self.TxtTime.text = "" + end + end, XScheduleManager.SECOND, 0) + end +end + +function XUiSimulatedCombatTaskReward:OnDisable() + self:StopTimer() +end + +function XUiSimulatedCombatTaskReward:SetupStarReward() + local taskList = XDataCenter.TaskManager.GetSimulatedCombatTaskList() + if not taskList then + return + end + + table.sort(taskList, function(a, b) + local priorityA = 0 + local priorityB = 0 + + + local taskA = a + local taskB = b + + if taskA.State == XDataCenter.TaskManager.TaskState.Achieved then + priorityA = priorityA + 2 + end + + if taskA.State == XDataCenter.TaskManager.TaskState.Finish then + priorityA = priorityA - 3 + end + + if taskB.State == XDataCenter.TaskManager.TaskState.Achieved then + priorityB = priorityB + 2 + end + + if taskB.State == XDataCenter.TaskManager.TaskState.Finish then + priorityB = priorityB - 3 + end + if priorityA > priorityB then + return true + elseif priorityA == priorityB then + return a.Id < b.Id + end + return false + end) + + self.TaskList = taskList + + self.DynamicTable:SetDataSource(self.TaskList) + self.DynamicTable:ReloadDataSync() +end + +function XUiSimulatedCombatTaskReward:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid.RootUi = self + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local task = self.TaskList[index] + grid:ResetData(task) + end +end + +function XUiSimulatedCombatTaskReward:OnEnable() + self:SetupStarReward() + self:SetTimer() +end + + +function XUiSimulatedCombatTaskReward:OnNotify(evt, ...) + if evt == XEventId.EVENT_TASK_SYNC then + self:SetupStarReward() + self:SetTimer() + end +end + +function XUiSimulatedCombatTaskReward:OnGetEvents() + return { XEventId.EVENT_TASK_SYNC } +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenStageDetail/XUiFubenStageDetail.lua b/Resources/Scripts/XUi/XUiFubenStageDetail/XUiFubenStageDetail.lua new file mode 100644 index 00000000..5ac430cd --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenStageDetail/XUiFubenStageDetail.lua @@ -0,0 +1,368 @@ +local XUiFubenStageDetail = XLuaUiManager.Register(XLuaUi, "UiFubenStageDetail") + +local MAX_STAR = 3 +local ANIMATION_OPEN = "AniFubenStageDetail" +local ANIMATION_END = "AniFubenStageDetailEnd" + +function XUiFubenStageDetail:OnAwake() + self:InitAutoScript() +end + +function XUiFubenStageDetail:OnStart(stage, cb, onlyEnterBtn) + if cb then + self.CallBack = cb + end + self.Stage = stage + self.OnlyEnterBtn = onlyEnterBtn + self.StarGridList = {} + self.GridList = {} + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) +end + +function XUiFubenStageDetail:OnEnable() + -- self.ChapterOrderId = self.FubenMainLineChapter.ChapterOrderId + self.IsShow = true + self.IsPlaying = false + self.StarItemsList = { self.GridStar1, self.GridStar2, self.GridStar3 } + self.GridCommonItem = self.Transform:Find("SafeAreaContentPane/PanelDropList/DropList/Viewport/PanelDropContent/GridCommon") + self.GridCommonItem.gameObject:SetActive(false) + + self:PlayAnimation(ANIMATION_OPEN) + self:UpdatePanelTargetList() + self:UpdateRewards() + self:UpdateDetailText() + self:UpdateRepeatChallenge() + self:UpdateDifficulty() + self:UpdateStageFightControl()--更新战力限制提示 +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiFubenStageDetail:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiFubenStageDetail:AutoInitUi() + self.PanelNoLimitCount = self.Transform:Find("SafeAreaContentPane/PanelNoLimitCount") + self.PanelTargetList = self.Transform:Find("SafeAreaContentPane/PanelTargetList") + self.GridStar3 = self.Transform:Find("SafeAreaContentPane/PanelTargetList/GridStar3") + self.ImgStarB = self.Transform:Find("SafeAreaContentPane/PanelTargetList/GridStar3/ImgStar"):GetComponent("Image") + self.GridStar2 = self.Transform:Find("SafeAreaContentPane/PanelTargetList/GridStar2") + self.ImgStarA = self.Transform:Find("SafeAreaContentPane/PanelTargetList/GridStar2/ImgStar"):GetComponent("Image") + self.TxtStarActiveB = self.Transform:Find("SafeAreaContentPane/PanelTargetList/GridStar2/TxtStarActive"):GetComponent("Text") + self.GridStar1 = self.Transform:Find("SafeAreaContentPane/PanelTargetList/GridStar1") + self.ImgStar = self.Transform:Find("SafeAreaContentPane/PanelTargetList/GridStar1/ImgStar"):GetComponent("Image") + self.PanelDropList = self.Transform:Find("SafeAreaContentPane/PanelDropList") + self.PanelDrop = self.Transform:Find("SafeAreaContentPane/PanelDropList/PanelDrop") + self.TxtDrop = self.Transform:Find("SafeAreaContentPane/PanelDropList/PanelDrop/TxtDrop"):GetComponent("Text") + self.TxtDropEn = self.Transform:Find("SafeAreaContentPane/PanelDropList/PanelDrop/TxtDropEn"):GetComponent("Text") + self.TxtFirstDrop = self.Transform:Find("SafeAreaContentPane/PanelDropList/PanelDrop/TxtFirstDrop"):GetComponent("Text") + self.PanelDropContent = self.Transform:Find("SafeAreaContentPane/PanelDropList/DropList/Viewport/PanelDropContent") + self.PanelNums = self.Transform:Find("SafeAreaContentPane/PanelNums") + self.TxtAllNums = self.Transform:Find("SafeAreaContentPane/PanelNums/TxtAllNums"):GetComponent("Text") + self.BtnAddNum = self.Transform:Find("SafeAreaContentPane/PanelNums/BtnAddNum"):GetComponent("Button") + self.TxtLeftNums = self.Transform:Find("SafeAreaContentPane/PanelNums/TxtLeftNums"):GetComponent("Text") + self.PanelDesc = self.Transform:Find("SafeAreaContentPane/PanelDesc") + self.RImgNandu = self.Transform:Find("SafeAreaContentPane/PanelDesc/RImgNandu"):GetComponent("RawImage") + self.TxtTitle = self.Transform:Find("SafeAreaContentPane/PanelDesc/TxtTitle"):GetComponent("Text") + self.TxtLevelVal = self.Transform:Find("SafeAreaContentPane/PanelDesc/TxtLevelVal"):GetComponent("Text") + self.TxtDesc = self.Transform:Find("SafeAreaContentPane/PanelDesc/TxtDesc"):GetComponent("Text") + self.PanelBottom = self.Transform:Find("SafeAreaContentPane/PanelBottom") + self.TxtATNums = self.Transform:Find("SafeAreaContentPane/PanelBottom/TxtATNums"):GetComponent("Text") + self.BtnEnter = self.Transform:Find("SafeAreaContentPane/PanelBottom/BtnEnter"):GetComponent("Button") + self.PanelAsset = self.Transform:Find("SafeAreaContentPane/PanelAsset") + self.BtnClose = self.Transform:Find("SafeAreaContentPane/BtnClose"):GetComponent("Button") + self.BtnRepeatEnter = self.Transform:Find("SafeAreaContentPane/PanelBottom/BtnRepeatEnter"):GetComponent("Button") +end + +function XUiFubenStageDetail:AutoAddListener() + self:RegisterClickEvent(self.BtnAddNum, self.OnBtnAddNumClick) + self:RegisterClickEvent(self.BtnEnter, self.OnBtnEnterClick) + self:RegisterClickEvent(self.BtnClose, self.OnBtnCloseClick) + self:RegisterClickEvent(self.BtnRepeatEnter, self.OnBtnRepeatEnterClick) + self.BtnAutoFight.CallBack = function() self:OnBtnAutoFightClick() end +end +-- auto +--初始化音效 +function XUiFubenStageDetail:OnBtnCloseClick() + if self.IsPlaying then + return + end + CsXGameEventManager.Instance:Notify(XEventId.EVENT_FUBEN_CLOSE_FUBENSTAGEDETAIL) + self:PlayHideAnimation() + if self.CallBack then + self.CallBack() + end +end + +function XUiFubenStageDetail:OnBtnAddNumClick() + local challengeData = XDataCenter.FubenMainLineManager.GetStageBuyChallengeData(self.Stage.StageId) + local func = function() + self:UpdateDetailText() + self:UpdateRepeatChallenge() + end + XLuaUiManager.Open("UiBuyAsset", 1, func, challengeData) +end + +function XUiFubenStageDetail:OnBtnEnterClick() + if self.IsPlaying then + return + end + + if self.Stage == nil then + XLog.Error("OnBtnEnterClick: Can not find stage!") + return + end + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_FUBEN_ENTERFIGHT, self.Stage) +end + +-- 显示首通还是多重奖励按钮 +function XUiFubenStageDetail:OnBtnRepeatEnterClick() + if self.IsPlaying then + return + end + + if self.Stage == nil then + XLog.Error("OnBtnRepeatEnterClick: Can not find stage!") + return + end + XLuaUiManager.Open("UiRepeatChallengeEnter", self.Stage) +end + +function XUiFubenStageDetail:OnBtnAutoFightClick() + XDataCenter.AutoFightManager.CheckOpenDialog(self.Stage.StageId, self.Stage) +end + +function XUiFubenStageDetail:UpdatePanelTargetList() + local stage = self.Stage + for i = 1, MAX_STAR do + local grid = self.StarGridList[i] + if not grid then + local item = self.StarItemsList[i] + grid = XUiGridFubenStageDetailStar.New(item) + self.StarGridList[i] = grid + end + grid:Refresh(stage.StarDesc[i]) + end +end + +function XUiFubenStageDetail:UpdateRewards() + local stage = self.Stage + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stage.StageId) + + -- 获取显示奖励Id + local rewardId = 0 + local IsFirst = false + local cfg = XDataCenter.FubenManager.GetStageLevelControl(stage.StageId) + if not stageInfo.Passed then + rewardId = cfg and cfg.FirstRewardShow or stage.FirstRewardShow + if cfg and cfg.FirstRewardShow > 0 or stage.FirstRewardShow > 0 then + IsFirst = true + end + end + if rewardId == 0 then + rewardId = cfg and cfg.FinishRewardShow or stage.FinishRewardShow + end + if rewardId == 0 then + for j = 1, #self.GridList do + self.GridList[j].GameObject:SetActive(false) + end + return + end + + local rewards = IsFirst and XRewardManager.GetRewardList(rewardId) or XRewardManager.GetRewardListNotCount(rewardId) + if rewards then + for i, item in ipairs(rewards) do + local grid + if self.GridList[i] then + grid = self.GridList[i] + else + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommonItem) + grid = XUiGridCommon.New(self, ui) + grid.Transform:SetParent(self.PanelDropContent, false) + self.GridList[i] = grid + end + grid:Refresh(item) + grid.GameObject:SetActive(true) + end + end + + local rewardsCount = 0 + if rewards then + rewardsCount = #rewards + end + + for j = 1, #self.GridList do + if j > rewardsCount then + self.GridList[j].GameObject:SetActive(false) + end + end +end + +function XUiFubenStageDetail:UpdateDetailText() + self.TxtTitle.text = self.Stage.Name + self.TxtLevelVal.text = self.Stage.RecommandLevel + self.TxtDesc.text = self.Stage.Description + self.TxtATNums.text = XDataCenter.FubenManager.GetStageActionPointConsume(self.Stage.StageId) + self.PanelNums.gameObject:SetActive(false) + self.PanelNoLimitCount.gameObject:SetActive(true) + + -- local stageData = XDataCenter.FubenManager.GetStageData(self.Stage.StageId) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(self.Stage.StageId) + + -- 是否首通奖励显示 + local firstDrop = false + if not stageInfo.Passed then + local cfg = XDataCenter.FubenManager.GetStageLevelControl(self.Stage.StageId) + if cfg and cfg.FirstRewardShow > 0 or self.Stage.FirstRewardShow > 0 then + firstDrop = true + end + end + self.TxtFirstDrop.gameObject:SetActive(firstDrop) + self.TxtDrop.gameObject:SetActive(not firstDrop) +end + + +function XUiFubenStageDetail:OldUpdateDetailText() + local id = "" + if self.ChapterOrderId then + id = self.ChapterOrderId .. "-" .. self.Stage.OrderId + end + + self.TxtTitle.text = id .. self.Stage.Name + self.TxtLevelVal.text = self.Stage.RecommandLevel + self.TxtDesc.text = self.Stage.Description + self.TxtATNums.text = XDataCenter.FubenManager.GetStageActionPointConsume(self.Stage.StageId) + + local stageData = XDataCenter.FubenManager.GetStageData(self.Stage.StageId) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(self.Stage.StageId) + + if stageInfo.Type == XDataCenter.FubenManager.StageType.Mainline then + local chanllengeNum = stageData and stageData.PassTimesToday or 0 + self.PanelNums.gameObject:SetActive(self.Stage.MaxChallengeNums > 0) + self.PanelNoLimitCount.gameObject:SetActive(self.Stage.MaxChallengeNums <= 0) + + if self.Stage.MaxChallengeNums > 0 then + self.TxtAllNums.text = "/" .. self.Stage.MaxChallengeNums + self.TxtLeftNums.text = self.Stage.MaxChallengeNums - chanllengeNum + end + elseif stageInfo.Type == XDataCenter.FubenManager.StageType.Daily then + local sectionCfg = XDataCenter.FubenDailyManager.GetDailySection(stageInfo.DailySectionId) + local sectionData = XDataCenter.FubenDailyManager.GetDailySectionData(stageInfo.DailySectionId) + local chanllengeNum = sectionData and sectionData.PassTimesToday or 0 + self.PanelNums.gameObject:SetActive(sectionCfg.DefaultChallengeCount > 0) + self.PanelNoLimitCount.gameObject:SetActive(sectionCfg.DefaultChallengeCount <= 0) + + self.BtnAddNum.gameObject:SetActive(false) + if sectionCfg.DefaultChallengeCount > 0 then + self.TxtAllNums.text = "/" .. sectionCfg.DefaultChallengeCount + self.TxtLeftNums.text = sectionCfg.DefaultChallengeCount - chanllengeNum + end + --elseif stageInfo.Type == XDataCenter.FubenManager.StageType.Activity then + elseif stageInfo.Type == XDataCenter.FubenManager.StageType.Resource then + self.PanelNoLimitCount.gameObject:SetActive(false) + self.BtnAddNum.gameObject:SetActive(false) + local leftNum = XDataCenter.FubenResourceManager.GetSectionDataByTypeId(stageInfo.ResourceType).LeftCount + self.TxtAllNums.text = "/" .. XDataCenter.FubenResourceManager.GetSectionDataByTypeId(stageInfo.ResourceType).MaxCount + self.TxtLeftNums.text = leftNum + elseif stageInfo.Type == XDataCenter.FubenManager.StageType.Urgent then + self.PanelNums.gameObject:SetActive(false) + self.PanelNoLimitCount.gameObject:SetActive(true) + end + + -- 是否首通奖励显示 + local firstDrop = false + if not stageInfo.Passed then + local cfg = XDataCenter.FubenManager.GetStageLevelControl(self.Stage.StageId) + if cfg and cfg.FirstRewardShow > 0 or self.Stage.FirstRewardShow > 0 then + firstDrop = true + end + end + self.TxtFirstDrop.gameObject:SetActive(firstDrop) + self.TxtDrop.gameObject:SetActive(not firstDrop) +end + +function XUiFubenStageDetail:UpdateDifficulty() + local nanDuIcon = XDataCenter.FubenManager.GetDifficultIcon(self.Stage.StageId) + self.RImgNandu:SetRawImage(nanDuIcon) +end + +function XUiFubenStageDetail:UpdateStageFightControl() + local stageInfo = XDataCenter.FubenManager.GetStageInfo(self.Stage.StageId) + if self.StageFightControl == nil then + self.StageFightControl = XUiStageFightControl.New(self.PanelStageFightControl, self.Stage.FightControlId) + end + if not stageInfo.Passed and stageInfo.Unlock then + self.StageFightControl.GameObject:SetActive(true) + self.StageFightControl:UpdateInfo(self.Stage.FightControlId) + else + self.StageFightControl.GameObject:SetActive(false) + end +end + +-- 显示多重挑战 +function XUiFubenStageDetail:UpdateRepeatChallenge() + local stageInfo = XDataCenter.FubenManager.GetStageInfo(self.Stage.StageId) + local firstDrop = false + if not stageInfo.Passed then + local cfg = XDataCenter.FubenManager.GetStageLevelControl(self.Stage.StageId) + if cfg and cfg.FirstRewardShow > 0 or self.Stage.FirstRewardShow > 0 then + firstDrop = true + end + end + + if self.OnlyEnterBtn then + self.BtnEnter.gameObject:SetActiveEx(true) + self.BtnRepeatEnter.gameObject:SetActiveEx(false) + else + self.BtnEnter.gameObject:SetActiveEx(firstDrop) + self.BtnRepeatEnter.gameObject:SetActiveEx(not firstDrop) + end + + if stageInfo.Passed then + local stageCfg = XDataCenter.FubenManager.GetStageCfg(self.Stage.StageId) + self.BtnAutoFight.gameObject:SetActiveEx(stageCfg.AutoFightId > 0) + else + self.BtnAutoFight.gameObject:SetActiveEx(false) + end +end + +function XUiFubenStageDetail:HideEnterBtn() + if self.BtnEnter then + self.BtnEnter.gameObject:SetActive(false) + end +end + +function XUiFubenStageDetail:ShowEnterBtn() + if self.BtnEnter then + self.BtnEnter.gameObject:SetActive(true) + end +end + +function XUiFubenStageDetail:PlayHideAnimation(callback) + XUiHelper.StopAnimation() + self.IsPlaying = true + + local End = function() + if XTool.UObjIsNil(self.GameObject) then + return + end + + self.IsShow = false + self.IsPlaying = false + + self:Close() + + if callback then + callback(self) + end + end + + self:PlayAnimation(ANIMATION_END, End) +end + +function XUiFubenStageDetail:ActiveSelf() + return self.IsShow +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenStageDetail/XUiGridFubenStageDetailStar.lua b/Resources/Scripts/XUi/XUiFubenStageDetail/XUiGridFubenStageDetailStar.lua new file mode 100644 index 00000000..042b9837 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenStageDetail/XUiGridFubenStageDetailStar.lua @@ -0,0 +1,64 @@ +XUiGridFubenStageDetailStar = XClass(nil, "XUiGridFubenStageDetailStar") + +function XUiGridFubenStageDetailStar:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self:InitAutoScript() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiGridFubenStageDetailStar:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiGridFubenStageDetailStar:AutoInitUi() + self.TxtStarActive = XUiHelper.TryGetComponent(self.Transform, "TxtStarActive", "Text") + self.ImgStarActive = XUiHelper.TryGetComponent(self.Transform, "ImgStarActive", "Image") +end + +function XUiGridFubenStageDetailStar:GetAutoKey(uiNode,eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiGridFubenStageDetailStar:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiGridFubenStageDetailStar:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key],eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiGridFubenStageDetailStar:AutoAddListener() + self.AutoCreateListeners = {} +end +-- auto + +function XUiGridFubenStageDetailStar:Refresh(desc) + if desc == nil or desc =="" then + desc = "-" + end + + self.ImgStarActive.gameObject:SetActive(true) + local text = XUiHelper.TryGetComponent(self.Transform, "ImgStarActive/Text", "Text") + self.TxtStarActive.text = desc + text.text = desc +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenTaskReward/XUiFubenTaskReward.lua b/Resources/Scripts/XUi/XUiFubenTaskReward/XUiFubenTaskReward.lua new file mode 100644 index 00000000..267987bd --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenTaskReward/XUiFubenTaskReward.lua @@ -0,0 +1,135 @@ +local XUiFubenTaskReward = XLuaUiManager.Register(XLuaUi, "UiFubenTaskReward") + +local XUiGridTask = require("XUi/XUiFubenTaskReward/XUiGridTask") + +function XUiFubenTaskReward:OnAwake() + self.DynamicTable = XDynamicTableNormal.New(self.PanelTaskList) + self.DynamicTable:SetDelegate(self) + self.DynamicTable:SetProxy(XUiGridTask) + + CsXUiHelper.RegisterClickEvent(self.BtnBg, handler(self, self.Close)) + self.BtnClose.CallBack = function() self:OnBtnCloseClick() end + self.GridTask.gameObject:SetActiveEx(false) +end + +function XUiFubenTaskReward:OnStart(taskType, groupId, closeCb) + self.TaskType = taskType + -- 值为空则取该Type下的所有task + self.GroupId = groupId + self.CloseCb = closeCb + self:SetupStarReward() + --self:SetTimer() +end + +function XUiFubenTaskReward:OnBtnCloseClick() + self:Close() + if self.CloseCb then + self.CloseCb() + end +end + +--停止计时器 +function XUiFubenTaskReward:StopTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end + +--活动时间倒计时 +function XUiFubenTaskReward:SetTimer() + local endTimeSecond = XTime.GetSeverTomorrowFreshTime() + local now = XTime.GetServerNowTimestamp() + if now <= endTimeSecond then + self:StopTimer() + if now <= endTimeSecond then + self.TxtTime.text = string.format("%s", XUiHelper.GetTime(endTimeSecond - now, XUiHelper.TimeFormatType.DAILY_TASK)) + else + self.TxtTime.text = "" + end + + self.Timer = XScheduleManager.ScheduleForever(function() + now = XTime.GetServerNowTimestamp() + if now > endTimeSecond then + self:StopTimer() + return + end + if now <= endTimeSecond then + self.TxtTime.text = string.format("%s", XUiHelper.GetTime(endTimeSecond - now, XUiHelper.TimeFormatType.DAILY_TASK)) + else + self.TxtTime.text = "" + end + end, XScheduleManager.SECOND, 0) + end +end + +function XUiFubenTaskReward:OnDisable() + --self:StopTimer() +end + +function XUiFubenTaskReward:SetupStarReward() + local taskList = XDataCenter.TaskManager.GetTaskList(self.TaskType, self.GroupId) + if not taskList then + return + end + + table.sort(taskList, function(a, b) + local priorityA = 0 + local priorityB = 0 + + + local taskA = a + local taskB = b + + if taskA.State == XDataCenter.TaskManager.TaskState.Achieved then + priorityA = priorityA + 2 + end + + if taskA.State == XDataCenter.TaskManager.TaskState.Finish then + priorityA = priorityA - 3 + end + + if taskB.State == XDataCenter.TaskManager.TaskState.Achieved then + priorityB = priorityB + 2 + end + + if taskB.State == XDataCenter.TaskManager.TaskState.Finish then + priorityB = priorityB - 3 + end + if priorityA > priorityB then + return true + elseif priorityA == priorityB then + return a.Id < b.Id + end + return false + end) + + self.TaskList = taskList + + self.DynamicTable:SetDataSource(self.TaskList) + self.DynamicTable:ReloadDataSync() +end + +function XUiFubenTaskReward:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid.RootUi = self + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local task = self.TaskList[index] + grid:ResetData(task) + end +end + +function XUiFubenTaskReward:OnEnable() +end + + +function XUiFubenTaskReward:OnNotify(evt, ...) + if evt == XEventId.EVENT_TASK_SYNC then + self:SetupStarReward() + --self:SetTimer() + end +end + +function XUiFubenTaskReward:OnGetEvents() + return { XEventId.EVENT_TASK_SYNC } +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenTaskReward/XUiGridTask.lua b/Resources/Scripts/XUi/XUiFubenTaskReward/XUiGridTask.lua new file mode 100644 index 00000000..3573ce68 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenTaskReward/XUiGridTask.lua @@ -0,0 +1,199 @@ +local XUiGridTask = XClass(nil, "XUiGridTask") + +function XUiGridTask:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RewardPanelList = {} + self:InitAutoScript() + self.GridCommon.gameObject:SetActive(false) + self.ImgComplete.gameObject:SetActive(false) + self.PanelAnimation.gameObject:SetActive(true) +end + +function XUiGridTask:PlayAnimation() + if self.IsAnimation then + return + end + + self.IsAnimation = true + self.GridTaskTimeline:PlayTimelineAnimation() +end + +function XUiGridTask:ResetData(data) + self.ImgComplete.gameObject:SetActive(data.State == XDataCenter.TaskManager.TaskState.Finish) + self.Data = data + + local config = XDataCenter.TaskManager.GetTaskTemplate(self.Data.Id) + self.tableData = config + self.TxtTaskName.text = config.Title + self.TxtTaskDescribe.text = config.Desc + self.TxtSubTypeTip.text = config.Suffix or "" + self.RImgTaskType:SetRawImage(config.Icon) + self:UpdateProgress(self.Data) + local rewards = XRewardManager.GetRewardList(config.RewardId) + for i = 1, #self.RewardPanelList do + self.RewardPanelList[i]:Refresh() + end + + if not rewards then + return + end + + for i = 1, #rewards do + local panel = self.RewardPanelList[i] + if not panel then + if #self.RewardPanelList == 0 then + panel = XUiGridCommon.New(self.RootUi, self.GridCommon) + else + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommon) + ui.transform:SetParent(self.GridCommon.parent, false) + panel = XUiGridCommon.New(self.RootUi, ui) + end + table.insert(self.RewardPanelList, panel) + end + + panel:Refresh(rewards[i]) + end + if self.PanelAnimationGroup then + self.PanelAnimationGroup.alpha = 1 + end + +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiGridTask:InitAutoScript() + XTool.InitUiObject(self) + self.SpecialSoundMap = {} + self:AutoAddListener() +end + + + +function XUiGridTask:GetAutoKey(uiNode, eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiGridTask:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiGridTask:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiGridTask:AutoAddListener() + self.AutoCreateListeners = {} + + local finishXUiBtn = self.BtnFinish:GetComponent("XUiButton") + if not finishXUiBtn then + XUiHelper.RegisterClickEvent(self, self.BtnFinish, self.OnBtnFinishClick) + else + self.BtnFinish = finishXUiBtn + self.BtnFinish.CallBack = function() self:OnBtnFinishClick() end + end + + local skipXUiBtn = self.BtnSkip:GetComponent("XUiButton") + if not skipXUiBtn then + XUiHelper.RegisterClickEvent(self, self.BtnSkip, self.OnBtnSkipClick) + else + self.BtnSkip = skipXUiBtn + self.BtnSkip.CallBack = function() self:OnBtnSkipClick() end + end +end + +function XUiGridTask:OnBtnFinishClick() + local weaponCount = 0 + local chipCount = 0 + for i = 1, #self.RewardPanelList do + local rewardsId = self.RewardPanelList[i].TemplateId + if XDataCenter.EquipManager.IsClassifyEqualByTemplateId(rewardsId, XEquipConfig.Classify.Weapon) then + weaponCount = weaponCount + 1 + elseif XDataCenter.EquipManager.IsClassifyEqualByTemplateId(rewardsId, XEquipConfig.Classify.Awareness) then + chipCount = chipCount + 1 + end + end + if weaponCount > 0 and XDataCenter.EquipManager.CheckBagCount(weaponCount, XEquipConfig.Classify.Weapon) == false or + chipCount > 0 and XDataCenter.EquipManager.CheckBagCount(chipCount, XEquipConfig.Classify.Awareness) == false then + return + end + XDataCenter.TaskManager.FinishTask(self.Data.Id, function(rewardGoodsList) + XUiManager.OpenUiObtain(rewardGoodsList) + --XEventManager.DispatchEvent(XEventId.EVENT_FUBEN_SIMUCOMBAT_UPDATE) + end) +end + +function XUiGridTask:OnBtnSkipClick() + if XDataCenter.RoomManager.RoomData ~= nil then + local title = CS.XTextManager.GetText("TipTitle") + local cancelMatchMsg = CS.XTextManager.GetText("OnlineInstanceQuitRoom") + XUiManager.DialogTip(title, cancelMatchMsg, XUiManager.DialogType.Normal, nil, function() + XLuaUiManager.RunMain() + local skipId = XDataCenter.TaskManager.GetTaskTemplate(self.Data.Id).SkipId + XFunctionManager.SkipInterface(skipId) + end) + else + local skipId = XDataCenter.TaskManager.GetTaskTemplate(self.Data.Id).SkipId + XFunctionManager.SkipInterface(skipId) + end +end + +function XUiGridTask:UpdateProgress(data) + self.Data = data + local config = XDataCenter.TaskManager.GetTaskTemplate(data.Id) + if #config.Condition < 2 then--显示进度 + self.ImgProgress.transform.parent.gameObject:SetActive(true) + self.TxtTaskNumQian.gameObject:SetActive(true) + local result = config.Result > 0 and config.Result or 1 + XTool.LoopMap(self.Data.Schedule, function(_, pair) + self.ImgProgress.fillAmount = pair.Value / result + pair.Value = (pair.Value >= result) and result or pair.Value + self.TxtTaskNumQian.text = pair.Value .. "/" .. result + end) + else + self.ImgProgress.transform.parent.gameObject:SetActive(false) + self.TxtTaskNumQian.gameObject:SetActive(false) + end + + self.BtnFinish.gameObject:SetActive(false) + self.BtnSkip.gameObject:SetActive(false) + if self.BtnReceiveHave then + self.BtnReceiveHave.gameObject:SetActive(false) + end + if self.Data.State == XDataCenter.TaskManager.TaskState.Achieved then + self.BtnFinish.gameObject:SetActive(true) + elseif self.Data.State ~= XDataCenter.TaskManager.TaskState.Achieved and self.Data.State ~= XDataCenter.TaskManager.TaskState.Finish then + self.BtnSkip.gameObject:SetActive(true) + + if self.BtnSkip["SetButtonState"] then + local skipId = XDataCenter.TaskManager.GetTaskTemplate(self.Data.Id).SkipId + if skipId == nil or skipId == 0 then + self.BtnSkip:SetButtonState(CS.UiButtonState.Disable) + else + self.BtnSkip:SetButtonState(CS.UiButtonState.Normal) + end + end + elseif self.Data.State == XDataCenter.TaskManager.TaskState.Finish then + if self.BtnReceiveHave then + self.BtnReceiveHave.gameObject:SetActive(true) + end + end +end + +return XUiGridTask \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenUnionKill/XUiGridUnionBuffItem.lua b/Resources/Scripts/XUi/XUiFubenUnionKill/XUiGridUnionBuffItem.lua new file mode 100644 index 00000000..da60c079 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenUnionKill/XUiGridUnionBuffItem.lua @@ -0,0 +1,24 @@ +local XUiGridUnionBuffItem = XClass(nil, "XUiGridUnionBuffItem") + +function XUiGridUnionBuffItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + +end + +function XUiGridUnionBuffItem:Init(rootUi) + self.RootUi = rootUi +end + +function XUiGridUnionBuffItem:Refresh(buffId) + local buffConfig = XFubenUnionKillConfigs.GetUnionEventConfigById(buffId) + if not buffConfig then return end + self.RImgBuffIcon:SetRawImage(buffConfig.Icon) + self.TxtTitle.text = buffConfig.Name + self.TxtLevel.text = buffConfig.Level + self.TxtDescription.text = buffConfig.Description +end + +return XUiGridUnionBuffItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenUnionKill/XUiGridUnionCharacterItem.lua b/Resources/Scripts/XUi/XUiFubenUnionKill/XUiGridUnionCharacterItem.lua new file mode 100644 index 00000000..9defadd7 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenUnionKill/XUiGridUnionCharacterItem.lua @@ -0,0 +1,153 @@ +local XUiGridUnionCharacterItem = XClass(nil, "XUiGridUnionCharacterItem") + +function XUiGridUnionCharacterItem:Ctor(rootUi, ui, character, clickCallback) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.ItemData = character + -- 区分自己的和共享的角色 + self.Character = XDataCenter.CharacterManager.GetCharacter(self.ItemData.Id) + self.ClickCallback = clickCallback + self.RectTransform = ui:GetComponent("RectTransform") + + XTool.InitUiObject(self) + + self.BtnCharacter.CallBack = function() self:OnBtnCharacterClick() end + + self:SetSelect(false) + self:SetInTeam(false) + self:UpdateGrid() +end + +function XUiGridUnionCharacterItem:OnBtnCharacterClick() + if self.ClickCallback then + if XCharacterConfigs.IsCharacterForeShow(self.ItemData.Id) then + self.ClickCallback(self.ItemData) + else + XUiManager.TipMsg(CS.XTextManager.GetText("ComingSoon"), XUiManager.UiTipType.Tip) + end + end +end + +function XUiGridUnionCharacterItem:UpdateOwnInfo(character) + if self.TxtLevel then + self.TxtLevel.text = character.Level + end + + if self.RImgQuality then + self.RImgQuality:SetRawImage(XCharacterConfigs.GetCharacterQualityIcon(character.Quality)) + end + + if self.RImgHeadIcon then + self.RImgHeadIcon:SetRawImage(XDataCenter.CharacterManager.GetCharSmallHeadIcon(character.Id)) + end + + if self.TxtTradeName then + self.TxtTradeName.text = XCharacterConfigs.GetCharacterTradeName(character.Id) + end +end + +-- 废弃 +function XUiGridUnionCharacterItem:UpdateUnOwnInfo() + if self.RImgHeadIcon then + self.RImgHeadIcon:SetRawImage(XDataCenter.CharacterManager.GetCharSmallHeadIcon(self.ItemData.Id)) + end +end + +function XUiGridUnionCharacterItem:UpdateGrid(itemData) + if itemData then + self.ItemData = itemData + -- 区分自己的和共享的角色 + self.Character = XDataCenter.CharacterManager.GetCharacter(self.ItemData.Id) + end + + self.PanelLevel.gameObject:SetActive(true) + self.RImgQuality.gameObject:SetActive(true) + + local characterId = self.ItemData.Id + if self.ItemData.Flag == XFubenUnionKillConfigs.UnionKillCharType.Share then + local shareNpcData = self.ItemData.OwnerInfo.ShareNpcData + if self.PanelFight then + self.TxtFight.text = math.floor(shareNpcData.Character.Ability) + end + self:UpdateOwnInfo(shareNpcData.Character) + self:SetShareFlag(true) + + local playerInfo = self.ItemData.OwnerInfo + if playerInfo then + XUiPLayerHead.InitPortrait(playerInfo.HeadPortraitId, playerInfo.HeadFrameId, self.Head) + end + else + if self.PanelFight then + self.TxtFight.text = math.floor(self.Character.Ability) + end + self:UpdateOwnInfo(self.Character) + self:SetShareFlag(false) + end + + + if self.PanelCharElement then + local detailConfig = XCharacterConfigs.GetCharDetailTemplate(characterId) + local elementList = detailConfig.ObtainElementList + for i = 1, 3 do + local rImg = self["RImgCharElement" .. i] + if elementList[i] then + rImg.gameObject:SetActiveEx(true) + local elementConfig = XCharacterConfigs.GetCharElement(elementList[i]) + rImg:SetRawImage(elementConfig.Icon) + else + rImg.gameObject:SetActiveEx(false) + end + end + end + +end + +function XUiGridUnionCharacterItem:SetSelect(isSelect) + if self.ImgSelected then + self.ImgSelected.gameObject:SetActive(isSelect) + end +end + +function XUiGridUnionCharacterItem:SetInTeam(isInTeam, inTeamText) + if self.ImgInTeam then + if isInTeam then + if inTeamText and self.TxtInTeam then + self.TxtInTeam.text = inTeamText + end + self.ImgInTeam.gameObject:SetActiveEx(true) + else + self.ImgInTeam.gameObject:SetActiveEx(false) + end + end +end + +function XUiGridUnionCharacterItem:SetIsLock(isLock) + if self.ImgLock then + self.ImgLock.gameObject:SetActiveEx(isLock) + end +end + +function XUiGridUnionCharacterItem:SetShareFlag(isShare) + if self.PanelShareCard then + self.PanelShareCard.gameObject:SetActiveEx(isShare) + end +end + +function XUiGridUnionCharacterItem:SetHasSameCard(hasSame) + if self.TipSameCard then + self.TipSameCard.gameObject:SetActiveEx(hasSame) + end +end + +function XUiGridUnionCharacterItem:Reset() + self.GameObject:SetActive(false) + self:SetSelect(false) + self:SetInTeam(false) +end + +function XUiGridUnionCharacterItem:SetPosition(x, y) + self.RectTransform.anchoredPosition = CS.UnityEngine.Vector2(x, y) +end + +return XUiGridUnionCharacterItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenUnionKill/XUiGridUnionDamageItem.lua b/Resources/Scripts/XUi/XUiFubenUnionKill/XUiGridUnionDamageItem.lua new file mode 100644 index 00000000..f52d3dac --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenUnionKill/XUiGridUnionDamageItem.lua @@ -0,0 +1,36 @@ +local XUiGridUnionDamageItem = XClass(nil, "XUiGridUnionDamageItem") + +function XUiGridUnionDamageItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) +end + +function XUiGridUnionDamageItem:Init(rootUi) + self.RootUi = rootUi +end + +function XUiGridUnionDamageItem:Refresh(damageInfo) + local playerName = damageInfo.PlayerName + local playerHeadPortraitId = damageInfo.HeadPortraitId + local playerHeadFrameId = damageInfo.HeadFrameId + local damageHp = damageInfo.KillBossHp + + XUiPLayerHead.InitPortrait(playerHeadPortraitId, playerHeadFrameId, self.Head) + + self.TxtPlayerName.text = playerName + self.TxtLevel.text = damageInfo.Position + + self.TxtDescriptionLeft.text = CS.XTextManager.GetText("UnionDamageToBoss") + + if damageInfo.IsMax then + local maxColor = CS.XTextManager.GetText("UnionDamageMax") + self.TxtDescriptionRight.text = string.format("%d", maxColor, damageHp) + else + local notmaxColor = CS.XTextManager.GetText("UnionDamageNotMax") + self.TxtDescriptionRight.text = string.format("%d", notmaxColor, damageHp) + end +end + +return XUiGridUnionDamageItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenUnionKill/XUiGridUnionEventHead.lua b/Resources/Scripts/XUi/XUiFubenUnionKill/XUiGridUnionEventHead.lua new file mode 100644 index 00000000..2d7f66a1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenUnionKill/XUiGridUnionEventHead.lua @@ -0,0 +1,18 @@ +local XUiGridUnionEventHead = XClass(nil, "XUiGridUnionEventHead") + +function XUiGridUnionEventHead:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) +end + +function XUiGridUnionEventHead:Refresh(playerInfo) + self.GameObject:SetActiveEx(true) + local playerHeadPortraitId = playerInfo.PlayerHeadPortraitId + local playerHeadFrameId = playerInfo.PlayerHeadFrameId + XUiPLayerHead.InitPortrait(playerHeadPortraitId, playerHeadFrameId, self.Head) + self.TxtLevel.text = playerInfo.Position +end + +return XUiGridUnionEventHead \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenUnionKill/XUiGridUnionEventStageItem.lua b/Resources/Scripts/XUi/XUiFubenUnionKill/XUiGridUnionEventStageItem.lua new file mode 100644 index 00000000..d7e3e0c5 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenUnionKill/XUiGridUnionEventStageItem.lua @@ -0,0 +1,160 @@ +local XUiGridUnionEventStageItem = XClass(nil, "XUiGridUnionEventStageItem") +local XUiGridUnionEventHead = require("XUi/XUiFubenUnionKill/XUiGridUnionEventHead") + + +function XUiGridUnionEventStageItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + self.Challengers = {} + -- BgBuff + self.BtnUnlock.CallBack = function() self:OnBtnUnlockClick() end + self.BtnStageLock.CallBack = function() self:OnBtnStageLockClick() end +end + +function XUiGridUnionEventStageItem:Refresh(eventStageId, sectionTemplate) + self.GameObject:SetActiveEx(true) + self.EventStageId = eventStageId + self.CurSectionTemplate = sectionTemplate + self.EventStageLimit = self.CurSectionTemplate.EventStageLimit + + local stageCfg = XDataCenter.FubenManager.GetStageCfg(eventStageId) + self.TxtEventStageName.text = stageCfg.Name + self.TxtEventStageLock.text = stageCfg.Name + + self.RoomFightData = XDataCenter.FubenUnionKillManager.GetCurRoomData() + if not self.RoomFightData then return end + local finishNum = self:GetFinishStageNum(self.RoomFightData.UnionKillStageInfos) + local isUnlock = self.EventStageLimit > finishNum + + self:RefreshBuffView(isUnlock) + self:RefreshChallengeView() +end + +function XUiGridUnionEventStageItem:RefreshBuffView(isUnlock) + local stageInfos = self.RoomFightData.UnionKillStageInfos + local eventStageTemplate = XFubenUnionKillConfigs.GetUnionEventStageById(self.EventStageId) + local curStageInfo = stageInfos[self.EventStageId] + -- 解锁条件:打过的关卡没有超过限制数量 + -- 已经打过(不可重复挑战)、还没打过(可以挑战) + -- 锁住:打过的关卡超过了限制数量 + -- 已经打过(不可挑战)、还没打过(置灰) + local hasMeFinish = XDataCenter.FubenUnionKillManager.IsMeFinish(curStageInfo) + local hasOthersFinish = XDataCenter.FubenUnionKillManager.IsOthersFinish(curStageInfo) + + if isUnlock then--没有超过 + self.PanelEventStageNor.gameObject:SetActiveEx(true) + self.PanelEventStageLock.gameObject:SetActiveEx(false) + else--超过限制的关卡数量 + self.PanelEventStageNor.gameObject:SetActiveEx(hasMeFinish) + self.PanelEventStageLock.gameObject:SetActiveEx(not hasMeFinish) + end + self.ImgBuffFirstLevel.gameObject:SetActiveEx(hasMeFinish) + self.ImgBuffSecondLevel.gameObject:SetActiveEx(hasMeFinish and hasOthersFinish) + -- 图标 + local buffId = eventStageTemplate.EventId[1] + local buffConfig = XFubenUnionKillConfigs.GetUnionEventConfigById(buffId) + self.RImgBuff:SetRawImage(buffConfig.Icon) + self.RImgBuffLcok:SetRawImage(buffConfig.Icon) + + self:UpdateEffect() +end + +function XUiGridUnionEventStageItem:UpdateEffect() + if self.RoomFightData and self.EventStageId and self.EventStageId > 0 then + local challengeStages = self.RoomFightData.ChallengeStage + local stageInfos = self.RoomFightData.UnionKillStageInfos + local curStageInfo = stageInfos[self.EventStageId] + local hasMeFinish = XDataCenter.FubenUnionKillManager.IsMeFinish(curStageInfo) + if not hasMeFinish and challengeStages and challengeStages[self.EventStageId] then + if not XTool.UObjIsNil(self.Effect) then + self.Effect.gameObject:SetActiveEx(true) + end + else + if not XTool.UObjIsNil(self.Effect) then + self.Effect.gameObject:SetActiveEx(false) + end + end + end +end + +-- 玩家通了多少关卡 +function XUiGridUnionEventStageItem:GetFinishStageNum(stageInfos) + local count = 0 + for _, stageInfo in pairs(stageInfos or {}) do + for _, playerId in pairs(stageInfo.PlayerIds or {}) do + if playerId == XPlayer.Id then + count = count + 1 + end + end + end + return count +end + +-- 设置挑战过的玩家 +function XUiGridUnionEventStageItem:RefreshChallengeView() + self.UnionKillStageClear.gameObject:SetActiveEx(false) + local playerInfos = self.RoomFightData.UnionKillPlayerInfos + local headInfos = {} + if playerInfos then + for id, playerInfo in pairs(playerInfos) do + for _, eventId in pairs(playerInfo.FinishEventStage or {}) do + if id == XPlayer.Id and self.EventStageId == eventId then + self.UnionKillStageClear.gameObject:SetActiveEx(true) + end + if eventId == self.EventStageId then + table.insert(headInfos, { + PlayerId = id, + PlayerLevel = playerInfo.PlayerLevel, + PlayerHeadPortraitId = playerInfo.HeadPortraitId, + PlayerHeadFrameId = playerInfo.HeadFrameId, + Position = playerInfo.Position + }) + break + end + end + end + + end + table.sort(headInfos, function(head1, head2) + return head1.Position < head2.Position + end) + -- 通关的玩家 + for i = 1, #headInfos do + if not self.Challengers[i] then + local ui = CS.UnityEngine.Object.Instantiate(self.Head) + ui.transform:SetParent(self.HeadGroup, false) + self.Challengers[i] = XUiGridUnionEventHead.New(ui) + end + self.Challengers[i]:Refresh(headInfos[i]) + end + for i = #headInfos + 1, #self.Challengers do + self.Challengers[i].GameObject:SetActiveEx(false) + end +end + +function XUiGridUnionEventStageItem:OnBtnUnlockClick() + if not self.EventStageId then return end + XLuaUiManager.Open("UiUnionKillEnterFight", self.EventStageId, self.CurSectionTemplate, XFubenUnionKillConfigs.UnionKillStageType.EventStage) +end + +function XUiGridUnionEventStageItem:OnBtnStageLockClick() + if not self.RoomFightData then return end + local finishNum = self:GetFinishStageNum(self.RoomFightData.UnionKillStageInfos) + local stageInfos = self.RoomFightData.UnionKillStageInfos + local curStageInfo = stageInfos[self.EventStageId] + local hasMeFinish = XDataCenter.FubenUnionKillManager.IsMeFinish(curStageInfo) + if hasMeFinish then + XUiManager.TipMsg(CS.XTextManager.GetText("UnionHadFightEventStage")) + return + end + -- 我打过,不可以再打 + -- 数量限制,不可打 + if finishNum >= self.EventStageLimit then + XUiManager.TipMsg(CS.XTextManager.GetText("UnionEventStageOverLimited", self.EventStageLimit)) + return + end +end + +return XUiGridUnionEventStageItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenUnionKill/XUiGridUnionRankItem.lua b/Resources/Scripts/XUi/XUiFubenUnionKill/XUiGridUnionRankItem.lua new file mode 100644 index 00000000..5156cf82 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenUnionKill/XUiGridUnionRankItem.lua @@ -0,0 +1,62 @@ +local XUiGridUnionRankItem = XClass(nil, "XUiGridUnionRankItem") +local XUiGridUnionRankMember = require("XUi/XUiFubenUnionKill/XUiGridUnionRankMember") + +local MAX_SPECIAL_NUM = 3 +local MAX_MEMBER_NUM = 3 + +function XUiGridUnionRankItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RankType = XFubenUnionKillConfigs.UnionRankType.KillNumber--by default + + XTool.InitUiObject(self) + self.TeamMember = {} + + for i = 1, MAX_MEMBER_NUM do + if not self.TeamMember[i] then + self.TeamMember[i] = XUiGridUnionRankMember.New(self[string.format("Team%d", i)]) + end + end +end + +function XUiGridUnionRankItem:Init(rootUi, rankType) + self.RootUi = rootUi + self.RankType = rankType +end + +function XUiGridUnionRankItem:Refresh(rankInfo) + self.TxtPlayerName.text = XDataCenter.SocialManager.GetPlayerRemark(rankInfo.Id, rankInfo.Name) + self.TxtRankNormal.text = rankInfo.Rank + local icon = XFubenBabelTowerConfigs.RankIcon[rankInfo.Rank] + + if rankInfo.Rank <= MAX_SPECIAL_NUM then + self.RootUi:SetUiSprite(self.ImgRankSpecial, icon) + end + self.TxtRankNormal.gameObject:SetActiveEx(rankInfo.Rank > MAX_SPECIAL_NUM) + self.ImgRankSpecial.gameObject:SetActiveEx(rankInfo.Rank <= MAX_SPECIAL_NUM) + + XUiPLayerHead.InitPortrait(rankInfo.HeadPortraitId, rankInfo.HeadFrameId, self.Head) + + local charLength = 0 + if rankInfo.CharacterInfos then + charLength = #rankInfo.CharacterInfos + end + if self.RankType == XFubenUnionKillConfigs.UnionRankType.KillNumber then + self.TxtRankScore.text = CS.XTextManager.GetText("UnionBlackFightPoint", rankInfo.Score) + for i = 1, charLength do + self.TeamMember[i]:RefreshKillRank(rankInfo.CharacterInfos[i], rankInfo.Id) + end + end + + if self.RankType == XFubenUnionKillConfigs.UnionRankType.ThumbsUp then + self.TxtRankScore.text = CS.XTextManager.GetText("UnionBlackPraiseNum", rankInfo.Score) + for i = 1, charLength do + self.TeamMember[i]:RefreshPraiseRank(rankInfo.CharacterInfos[i]) + end + end + for i = charLength + 1, MAX_MEMBER_NUM do + self.TeamMember[i].GameObject:SetActiveEx(false) + end +end + +return XUiGridUnionRankItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenUnionKill/XUiGridUnionRankMember.lua b/Resources/Scripts/XUi/XUiFubenUnionKill/XUiGridUnionRankMember.lua new file mode 100644 index 00000000..3d1f9c99 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenUnionKill/XUiGridUnionRankMember.lua @@ -0,0 +1,25 @@ +local XUiGridUnionRankMember = XClass(nil, "XUiGridUnionRankMember") + +function XUiGridUnionRankMember:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) +end + +function XUiGridUnionRankMember:RefreshKillRank(info, playerId) + self.GameObject:SetActiveEx(true) + self.RImgTeam:SetRawImage(XDataCenter.CharacterManager.GetCharSmallHeadIcon(info.Id, info.LiberateLv)) + self.LikeNum.gameObject:SetActiveEx(false) + self.HelperIcon.gameObject:SetActiveEx(playerId ~= info.SharerId) +end + +function XUiGridUnionRankMember:RefreshPraiseRank(info) + self.GameObject:SetActiveEx(true) + self.RImgTeam:SetRawImage(XDataCenter.CharacterManager.GetCharSmallHeadIcon(info.Id, info.LiberateLv)) + self.LikeNum.gameObject:SetActiveEx(true) + self.HelperIcon.gameObject:SetActiveEx(false) + self.TxtPraiseNum.text = info.PraiseCount or 0 +end + +return XUiGridUnionRankMember \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenUnionKill/XUiGridUnionRankTab.lua b/Resources/Scripts/XUi/XUiFubenUnionKill/XUiGridUnionRankTab.lua new file mode 100644 index 00000000..bb4e9e5b --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenUnionKill/XUiGridUnionRankTab.lua @@ -0,0 +1,22 @@ +local XUiGridUnionRankTab = XClass(nil, "XUiGridUnionRankTab") + +function XUiGridUnionRankTab:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + + XTool.InitUiObject(self) +end + +function XUiGridUnionRankTab:Refresh(rankLevelTemplate) + local levelDesc = CS.XTextManager.GetText("UnionRankLevel", rankLevelTemplate.MinLevel, rankLevelTemplate.MaxLevel) + self.GridRankLevel:SetNameByGroup(0, levelDesc) + self.GridRankLevel:SetNameByGroup(1, rankLevelTemplate.Name) + self.RImgRankIcon:SetRawImage(rankLevelTemplate.Icon) +end + +function XUiGridUnionRankTab:GetUiButton() + return self.GridRankLevel +end + +return XUiGridUnionRankTab \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenUnionKill/XUiGridUnionRewardItem.lua b/Resources/Scripts/XUi/XUiFubenUnionKill/XUiGridUnionRewardItem.lua new file mode 100644 index 00000000..64164328 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenUnionKill/XUiGridUnionRewardItem.lua @@ -0,0 +1,54 @@ +local XUiGridUnionRewardItem = XClass(nil, "XUiGridUnionRewardItem") + +function XUiGridUnionRewardItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + self.MailRewardList = {} + XTool.InitUiObject(self) + self.BtnReceive.gameObject:SetActiveEx(false) +end + +function XUiGridUnionRewardItem:Init(uiRoot) + self.UiRoot = uiRoot +end + +-- 刷新排名奖励 +function XUiGridUnionRewardItem:Refresh(rewardInfo, rankLevel) + local minRank = rewardInfo.MinRank * 100 + local maxRank = rewardInfo.MaxRank * 100 + if minRank <= 0 then + self.TxtScore.text = string.format("%d%%", maxRank) + else + self.TxtScore.text = string.format("%d%%-%d%%", minRank, maxRank) + end + + local killRankInfos = XDataCenter.FubenUnionKillManager.GetKillRankInfosByLevel(rankLevel) + if not killRankInfos then return end + local _, curRank, totalRank = killRankInfos.Score, killRankInfos.Rank, killRankInfos.TotalRank + + local playerRank = 0 + if totalRank ~= 0 then + playerRank = (curRank * 1.0) / totalRank * 100 + end + self.PanelCurRank.gameObject:SetActiveEx(playerRank > minRank and playerRank <= maxRank) + + local rewardList = XDataCenter.MailManager.GetRewardList(rewardInfo.MailId) + + for i, reward in pairs(rewardList or {}) do + if not self.MailRewardList[i] then + local ui = CS.UnityEngine.Object.Instantiate(self.GridReward) + ui.transform:SetParent(self.PanelRewardContent, false) + local common = XUiGridCommon.New(self.UiRoot, ui) + self.MailRewardList[i] = common + end + + self.MailRewardList[i]:Refresh(reward) + end + for i = #rewardList + 1, #self.MailRewardList do + self.MailRewardList[i].GameObject:SetActiveEx(false) + end +end + + +return XUiGridUnionRewardItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenUnionKill/XUiGridUnionShareCharItem.lua b/Resources/Scripts/XUi/XUiFubenUnionKill/XUiGridUnionShareCharItem.lua new file mode 100644 index 00000000..4f7b7c53 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenUnionKill/XUiGridUnionShareCharItem.lua @@ -0,0 +1,25 @@ +local XUiGridUnionShareCharItem = XClass(nil, "XUiGridUnionShareCharItem") + +function XUiGridUnionShareCharItem:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + + XTool.InitUiObject(self) +end + +function XUiGridUnionShareCharItem:Init(rootUi) + self.RootUi = rootUi +end + +function XUiGridUnionShareCharItem:Refresh(shareInfos) + local character = shareInfos.Character + local characterId = character.Id + + self.RImgHeadIcon:SetRawImage(XDataCenter.CharacterManager.GetCharSmallHeadIcon(characterId)) + self.TxtLevel.text = character.Level + self.TxtFight.text = math.floor(character.Ability) + self.RImgQuality:SetRawImage(XCharacterConfigs.GetCharacterQualityIcon(character.Quality)) +end + +return XUiGridUnionShareCharItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenUnionKill/XUiGridUnionStageMember.lua b/Resources/Scripts/XUi/XUiFubenUnionKill/XUiGridUnionStageMember.lua new file mode 100644 index 00000000..dc1f8fde --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenUnionKill/XUiGridUnionStageMember.lua @@ -0,0 +1,133 @@ +local XUiGridUnionStageMember = XClass(nil, "XUiGridUnionStageMember") + +function XUiGridUnionStageMember:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + self.IsTiping = false + self.BtnHead.CallBack = function() self:OnBtnHeadClick() end +end + +function XUiGridUnionStageMember:UpdateByCache() + if self.PlayerInfo then + self:Refresh(self.PlayerInfo) + end +end + +function XUiGridUnionStageMember:OnBtnHeadClick() + if self.PlayerInfo and self.PlayerInfo.Id ~= XPlayer.Id then + XDataCenter.PersonalInfoManager.ReqShowInfoPanel(self.PlayerInfo.Id) + end +end + +function XUiGridUnionStageMember:Refresh(playerInfo) + self.GameObject:SetActiveEx(true) + self.PlayerInfo = playerInfo + self.PlayerId = playerInfo.Id + local playerName = XDataCenter.SocialManager.GetPlayerRemark(self.PlayerId, playerInfo.PlayerName) + local playerOnline = playerInfo.Status == 1 + local playerHeadPortraitId = playerInfo.HeadPortraitId + local playerHeadFrameId = playerInfo.HeadFrameId + + XUiPLayerHead.InitPortrait(playerHeadPortraitId, playerHeadFrameId, self.Head) + + self.TxtPlayerName.text = playerName + self.TxtNum.text = playerInfo.Position + self.ImgState.gameObject:SetActiveEx(false) + if not playerOnline then + self.TxtMessage.text = "" + end +end + +function XUiGridUnionStageMember:RefreshFightStatus(playerId, stageId) + if self.PlayerInfo and self.PlayerInfo.Id == playerId then + if stageId then + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + if not stageCfg then + self.TxtMessage.text = "" + else + self.TxtMessage.text = CS.XTextManager.GetText("UnionKillFightStatus", stageCfg.Name) + end + else + self.TxtMessage.text = "" + end + end +end + +--[[表情、聊天、提示]] +function XUiGridUnionStageMember:ClearUnuseTimer() + self:EndProcessTipMsg() +end + +function XUiGridUnionStageMember:ProcessTipMsg(tip_msg) + if self.IsTiping then return end + self:EndProcessTipMsg() + + self.IsTiping = true + if tip_msg.IsChatMsg then + -- 聊天弹条 + if tip_msg.ChatData.MsgType == ChatMsgType.Normal then + self:TipTalk(tip_msg.ChatData.Content) + elseif tip_msg.ChatData.MsgType == ChatMsgType.Emoji then + self:TipEmoji(tostring(tip_msg.ChatData.Content)) + end + else + -- tip_msg + if tip_msg.TipsType == XFubenUnionKillConfigs.TipsMessageType.FightBrrow then + local fullMsg = "" + local characterName = XCharacterConfigs.GetCharacterFullNameStr(tip_msg.ShareCharacterInfos.CharacterId) + if tip_msg.ShareCharacterInfos.PlayerId == XPlayer.Id then + fullMsg = CS.XTextManager.GetText(XFubenUnionKillConfigs.FightBorrowMine, characterName) + else + local fightInfo = XDataCenter.FubenUnionKillManager.GetCurRoomData() + if fightInfo and fightInfo.UnionKillPlayerInfos[tip_msg.ShareCharacterInfos.PlayerId] then + local playerName = fightInfo.UnionKillPlayerInfos[tip_msg.ShareCharacterInfos.PlayerId].PlayerName + playerName = XDataCenter.SocialManager.GetPlayerRemark(tip_msg.ShareCharacterInfos.PlayerId, playerName) + fullMsg = CS.XTextManager.GetText(XFubenUnionKillConfigs.FightBorrowOthers, playerName, characterName) + end + end + self:TipTalk(fullMsg) + end + end + self.TipMsgTimer = XScheduleManager.ScheduleOnce(function() + self:EndProcessTipMsg() + end, 3000) +end + +function XUiGridUnionStageMember:EndProcessTipMsg() + if self.TipMsgTimer then + XScheduleManager.UnSchedule(self.TipMsgTimer) + self.TipMsgTimer = nil + end + self.IsTiping = false + self:EndTipEmoji() + self:EndTipTalk() +end + +function XUiGridUnionStageMember:TipEmoji(emoji) + self.EmojiGroup.gameObject:SetActiveEx(true) + local icon = XDataCenter.ChatManager.GetEmojiIcon(emoji) + if icon then + self.RImgEmoji:SetRawImage(icon) + end +end + +function XUiGridUnionStageMember:EndTipEmoji() + self.EmojiGroup.gameObject:SetActiveEx(false) +end + +function XUiGridUnionStageMember:TipTalk(talkContent) + self.TalkGroup.gameObject:SetActiveEx(true) + self.TxtTalk.text = talkContent +end + +function XUiGridUnionStageMember:EndTipTalk() + self.TalkGroup.gameObject:SetActiveEx(false) +end + +function XUiGridUnionStageMember:ResetTiping() + self.IsTiping = false +end + +return XUiGridUnionStageMember \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenUnionKill/XUiPanelUnionBuffDetails.lua b/Resources/Scripts/XUi/XUiFubenUnionKill/XUiPanelUnionBuffDetails.lua new file mode 100644 index 00000000..15ccf634 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenUnionKill/XUiPanelUnionBuffDetails.lua @@ -0,0 +1,40 @@ +local XUiPanelUnionBuffDetails = XClass(nil, "XUiPanelUnionBuffDetails") +local XUiGridUnionBuffItem = require("XUi/XUiFubenUnionKill/XUiGridUnionBuffItem") + +function XUiPanelUnionBuffDetails:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + + XTool.InitUiObject(self) + self.BtnTanchuangClose.CallBack = function() self:OnCloseClick() end + self.DynamicTableBuff = XDynamicTableNormal.New(self.ScrollBuff.gameObject) + self.DynamicTableBuff:SetProxy(XUiGridUnionBuffItem) + self.DynamicTableBuff:SetDelegate(self) +end + +function XUiPanelUnionBuffDetails:Refresh(buffInfos) + self.BuffInfos = buffInfos + self.GameObject:SetActiveEx(true) + -- 收集增益数据 + self.DynamicTableBuff:Clear() + self.DynamicTableBuff:SetDataSource(self.BuffInfos) + self.DynamicTableBuff:ReloadDataASync() + self.ImgEmpty.gameObject:SetActiveEx(#self.BuffInfos <= 0) +end + +function XUiPanelUnionBuffDetails:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self.UiRoot) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local buffId = self.BuffInfos[index] + if not buffId then return end + grid:Refresh(buffId) + end +end + +function XUiPanelUnionBuffDetails:OnCloseClick() + self.GameObject:SetActiveEx(false) +end + +return XUiPanelUnionBuffDetails \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenUnionKill/XUiPanelUnionDamageDetails.lua b/Resources/Scripts/XUi/XUiFubenUnionKill/XUiPanelUnionDamageDetails.lua new file mode 100644 index 00000000..c7efe340 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenUnionKill/XUiPanelUnionDamageDetails.lua @@ -0,0 +1,44 @@ +local XUiPanelUnionDamageDetails = XClass(nil, "XUiPanelUnionDamageDetails") +local XUiGridUnionDamageItem = require("XUi/XUiFubenUnionKill/XUiGridUnionDamageItem") + +function XUiPanelUnionDamageDetails:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = rootUi + + XTool.InitUiObject(self) + self.BtnTanchuangClose.CallBack = function() self:OnCloseClick() end + self.DynamicTableDamage = XDynamicTableNormal.New(self.ScrollDamage.gameObject) + self.DynamicTableDamage:SetProxy(XUiGridUnionDamageItem) + self.DynamicTableDamage:SetDelegate(self) +end + +function XUiPanelUnionDamageDetails:Refresh(damageInfos) + self.DamageInfos = damageInfos + self.GameObject:SetActiveEx(true) + -- 收集增益数据 + if #self.DamageInfos >= 1 then + self.DamageInfos[1].IsMax = true + end + + self.DynamicTableDamage:Clear() + self.DynamicTableDamage:SetDataSource(self.DamageInfos) + self.DynamicTableDamage:ReloadDataASync() + self.ImgEmpty.gameObject:SetActiveEx(#self.DamageInfos <= 0) +end + +function XUiPanelUnionDamageDetails:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self.UiRoot) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local damageInfo = self.DamageInfos[index] + if not damageInfo then return end + grid:Refresh(damageInfo) + end +end + +function XUiPanelUnionDamageDetails:OnCloseClick() + self.GameObject:SetActiveEx(false) +end + +return XUiPanelUnionDamageDetails \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenUnionKill/XUiPanelUnionKillMainRank.lua b/Resources/Scripts/XUi/XUiFubenUnionKill/XUiPanelUnionKillMainRank.lua new file mode 100644 index 00000000..df391935 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenUnionKill/XUiPanelUnionKillMainRank.lua @@ -0,0 +1,206 @@ +local XUiPanelUnionKillMainRank = XClass(nil, "XUiPanelUnionKillMainRank") +local XUiPanelUnionKillMyRank = require("XUi/XUiFubenUnionKill/XUiPanelUnionKillMyRank") +local XUiGridUnionRankItem = require("XUi/XUiFubenUnionKill/XUiGridUnionRankItem") +local XUiGridUnionRankTab = require("XUi/XUiFubenUnionKill/XUiGridUnionRankTab") + +function XUiPanelUnionKillMainRank:Ctor(ui, root) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = root + + XTool.InitUiObject(self) + self.BtnRankReward.CallBack = function() self:OnBtnRankRewardClick() end + self.MyRank = XUiPanelUnionKillMyRank.New(self.PanelMyBossRank, self.RootUi) + + self.DynamicTableRank = XDynamicTableNormal.New(self.BossRankList.gameObject) + self.DynamicTableRank:SetProxy(XUiGridUnionRankItem) + self.DynamicTableRank:SetDelegate(self) + + self.RankTabs = {} + self.RankTabBtns = {} + +end + +function XUiPanelUnionKillMainRank:Refresh(rankType) + self.RankType = rankType + local isKillRankType = rankType == XFubenUnionKillConfigs.UnionRankType.KillNumber + local isPraiseRankType = not isKillRankType + + if isKillRankType then + self.TxtTime.text = CS.XTextManager.GetText("UnionKillRankDesc") + self:StartSectionCounter() + else + local unionKillInfo = XDataCenter.FubenUnionKillManager.GetUnionKillInfo() + if unionKillInfo then + local beginTime, endTime = XFubenUnionKillConfigs.GetUnionActivityTimes(unionKillInfo.Id) + local dayFormat = "yyyy/MM/dd" + local beginTimeStr = XTime.TimestampToGameDateTimeString(beginTime, dayFormat) + local endTimeStr = XTime.TimestampToGameDateTimeString(endTime, dayFormat) + + self.TxtTime.text = CS.XTextManager.GetText("UnionPraiseRankDesc", beginTimeStr, endTimeStr) + end + self.TxtCurTime.text = "" + end + + self.BtnRankReward.gameObject:SetActiveEx(isKillRankType) + self.PanelTags.gameObject:SetActiveEx(isKillRankType) + + if isKillRankType then + self:InitRankLevelTab() + self.TxtTitle.text = CS.XTextManager.GetText("UnionKillRankTitle") + end + + if isPraiseRankType then + local praiseDatas = XDataCenter.FubenUnionKillManager.GetPraiseRankInfos() + if not praiseDatas then + self:SetNoneRankView() + return + end + self.TxtTitle.text = CS.XTextManager.GetText("UnionPraiseRankTitle") + self.RankList = praiseDatas.PlayerList + + self:UpdateRankView(self.RankList) + end + + self.MyRank:Refresh(self.RankType, self.CurRankLevel) +end + +function XUiPanelUnionKillMainRank:SetNoneRankView() + self.DynamicTableRank:SetDataSource({}) + self.DynamicTableRank:ReloadDataASync() + self.PanelNoRank.gameObject:SetActiveEx(false) +end + +function XUiPanelUnionKillMainRank:UpdateRankView() + if self.RankList ~= nil then + self.DynamicTableRank:Clear() + self.DynamicTableRank:SetDataSource(self.RankList) + self.DynamicTableRank:ReloadDataASync() + end + self.PanelNoRank.gameObject:SetActiveEx(self.RankList == nil or #self.RankList <= 0) + self.MyRank:Refresh(self.RankType, self.CurRankLevel) +end + +function XUiPanelUnionKillMainRank:InitRankLevelTab() + self.CurRankLevel = self.CurRankLevel or 1 + local unionKillInfo = XDataCenter.FubenUnionKillManager.GetUnionKillInfo() + if unionKillInfo then + local sectionId = unionKillInfo.CurSectionId + local sectionInfo = XDataCenter.FubenUnionKillManager.GetSectionInfoById(sectionId) + if sectionInfo then + self.CurRankLevel = sectionInfo.RankLevel + end + end + + self.AllRankLevels = XFubenUnionKillConfigs.GetAllRankLevel() + local defaultIdx = 1 + for i = 1, #self.AllRankLevels do + if not self.RankTabs[i] then + local tab = CS.UnityEngine.Object.Instantiate(self.GridRankLevel.gameObject) + tab.transform:SetParent(self.PanelTags.transform, false) + self.RankTabs[i] = XUiGridUnionRankTab.New(tab, self.RootUi) + self.RankTabBtns[i] = self.RankTabs[i]:GetUiButton() + end + if self.CurRankLevel == self.AllRankLevels[i].Id then + defaultIdx = i + end + self.RankTabs[i].GameObject:SetActiveEx(true) + self.RankTabs[i]:Refresh(self.AllRankLevels[i]) + end + + -- 初始化 + self.PanelTags:Init(self.RankTabBtns, function(index) self:OnRankLevelChanged(index) end) + self.PanelTags:SelectIndex(defaultIdx) +end + +-- 切换排行榜 +function XUiPanelUnionKillMainRank:OnRankLevelChanged(index) + if not self.AllRankLevels[index] then return end + local rankLevel = self.AllRankLevels[index].Id + self.CurRankLevel = rankLevel + + -- 缓存以及限时请求 + local rankLevelInfos = XDataCenter.FubenUnionKillManager.GetKillRankInfosByLevel(rankLevel) + local now = XTime.GetServerNowTimestamp() + if not rankLevelInfos or now - rankLevelInfos.LastModify > XFubenUnionKillConfigs.RankRequestInterval then + XDataCenter.FubenUnionKillManager.GetUnionKillRankData(rankLevel, function() + local killDatas = XDataCenter.FubenUnionKillManager.GetKillRankInfosByLevel(rankLevel) + if not killDatas then + self:SetNoneRankView() + return + end + self.RankList = killDatas.PlayerList + self:UpdateRankView(self.RankList) + end) + else + self.RankList = rankLevelInfos.PlayerList + self:UpdateRankView(self.RankList) + end +end + +function XUiPanelUnionKillMainRank:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self.RootUi, self.RankType) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.RankList[index] + if not data then return end + grid:Refresh(data) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + self:OnRankItemClick(index) + end +end + +function XUiPanelUnionKillMainRank:OnBtnRankRewardClick() + self.RootUi:OpenRankReward(self.CurRankLevel) +end + +function XUiPanelUnionKillMainRank:OnRankItemClick(index) + local data = self.RankList[index] + if not data then return end + XDataCenter.PersonalInfoManager.ReqShowInfoPanel(data.Id) +end + +-- 启动活动结束倒计时 +function XUiPanelUnionKillMainRank:StartSectionCounter() + self:EndSectionCounter() + + local unionKillInfo = XDataCenter.FubenUnionKillManager.GetUnionKillInfo() + if not unionKillInfo then return end + + + local now = XTime.GetServerNowTimestamp() + local _, endTime = XFubenUnionKillConfigs.GetUnionSectionTimes(unionKillInfo.CurSectionId) + + local invalidTime = CS.XTextManager.GetText("UnionMainOverdue") + if now <= endTime then + self.TxtCurTime.text = CS.XTextManager.GetText("UnionKillResetDesc", XUiHelper.GetTime(endTime - now, XUiHelper.TimeFormatType.ACTIVITY)) + else + self.TxtCurTime.text = invalidTime + end + + self.UnionKillTimer = XScheduleManager.ScheduleForever(function() + now = XTime.GetServerNowTimestamp() + if now > endTime then + self:EndSectionCounter() + + return + end + + if now <= endTime then + self.TxtCurTime.text = CS.XTextManager.GetText("UnionKillResetDesc", XUiHelper.GetTime(endTime - now, XUiHelper.TimeFormatType.ACTIVITY)) + else + self.TxtCurTime.text = invalidTime + end + + end, XScheduleManager.SECOND, 0) +end + +-- 关闭活动结束倒计时 +function XUiPanelUnionKillMainRank:EndSectionCounter() + if self.UnionKillTimer ~= nil then + XScheduleManager.UnSchedule(self.UnionKillTimer) + self.UnionKillTimer = nil + end +end + +return XUiPanelUnionKillMainRank \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenUnionKill/XUiPanelUnionKillMyRank.lua b/Resources/Scripts/XUi/XUiFubenUnionKill/XUiPanelUnionKillMyRank.lua new file mode 100644 index 00000000..ca74dd44 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenUnionKill/XUiPanelUnionKillMyRank.lua @@ -0,0 +1,83 @@ +local XUiPanelUnionKillMyRank = XClass(nil, "XUiPanelUnionKillMyRank") + +function XUiPanelUnionKillMyRank:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + + XTool.InitUiObject(self) +end + +function XUiPanelUnionKillMyRank:Refresh(rankType, rankLevel) + self.RankType = rankType + self.RankLevel = rankLevel + self:RefreshMyPraiseRank() + self:RefreshMyKillRank() + self.TxtHighistRank.gameObject:SetActiveEx(self.RankType == XFubenUnionKillConfigs.UnionRankType.KillNumber) +end + +function XUiPanelUnionKillMyRank:RefreshMyPraiseRank() + if XFubenUnionKillConfigs.UnionRankType.ThumbsUp == self.RankType then + local praiseDatas = XDataCenter.FubenUnionKillManager.GetPraiseRankInfos() + local percent = (praiseDatas.TotalRank == nil or praiseDatas.TotalRank == 0) + and "0" or tostring(math.ceil(praiseDatas.Rank * 1.0 / praiseDatas.TotalRank * 100)) + + if praiseDatas.Rank == 0 then + self.TxtRankNormal.text = CS.XTextManager.GetText("UnionUnRank") + elseif praiseDatas.Rank <= 100 then + self.TxtRankNormal.text = praiseDatas.Rank + else + self.TxtRankNormal.text = string.format("%s%%", percent) + end + self.TxtRankScore.text = CS.XTextManager.GetText("UnionWhitePraiseNum", praiseDatas.Score) + self.TxtPlayerName.text = XPlayer.Name + + XUiPLayerHead.InitPortrait(XPlayer.CurrHeadPortraitId, XPlayer.CurrHeadFrameId, self.Head) + + self.TxtHighistRank.text = praiseDatas.HistoryRank + end +end + +function XUiPanelUnionKillMyRank:RefreshMyKillRank() + if XFubenUnionKillConfigs.UnionRankType.KillNumber == self.RankType then + local myRankLevel + local unionKillInfo = XDataCenter.FubenUnionKillManager.GetUnionKillInfo() + if unionKillInfo then + local sectionId = unionKillInfo.CurSectionId + local sectionInfo = XDataCenter.FubenUnionKillManager.GetSectionInfoById(sectionId) + if sectionInfo then + myRankLevel = sectionInfo.RankLevel + end + end + if not myRankLevel or not self.RankLevel or myRankLevel ~= self.RankLevel then + self.GameObject:SetActiveEx(false) + return + end + + if myRankLevel then + local rankLevelInfos = XDataCenter.FubenUnionKillManager.GetKillRankInfosByLevel(myRankLevel) + if rankLevelInfos then + self.GameObject:SetActiveEx(true) + local percent = (rankLevelInfos.TotalRank == nil or rankLevelInfos.TotalRank == 0) + and "0" or tostring(math.ceil(rankLevelInfos.Rank * 1.0 / rankLevelInfos.TotalRank * 100)) + + if rankLevelInfos.Rank == 0 then + self.TxtRankNormal.text = CS.XTextManager.GetText("UnionUnRank") + elseif rankLevelInfos.Rank <= 100 then + self.TxtRankNormal.text = rankLevelInfos.Rank + else + self.TxtRankNormal.text = string.format("%s%%", percent) + end + self.TxtRankScore.text = CS.XTextManager.GetText("UnionWhiteFightPoint", rankLevelInfos.Score) + self.TxtPlayerName.text = XPlayer.Name + + XUiPLayerHead.InitPortrait(XPlayer.CurrHeadPortraitId, XPlayer.CurrHeadFrameId, self.Head) + + self.TxtHighistRank.text = rankLevelInfos.HistoryRank + end + end + + end +end + +return XUiPanelUnionKillMyRank \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenUnionKill/XUiPanelUnionKillRankReward.lua b/Resources/Scripts/XUi/XUiFubenUnionKill/XUiPanelUnionKillRankReward.lua new file mode 100644 index 00000000..af499441 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenUnionKill/XUiPanelUnionKillRankReward.lua @@ -0,0 +1,57 @@ +local XUiPanelUnionKillRankReward = XClass(nil, "XUiPanelUnionKillRankReward") +local XUiGridUnionRewardItem = require("XUi/XUiFubenUnionKill/XUiGridUnionRewardItem") + +function XUiPanelUnionKillRankReward:Ctor(ui, root) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = root + + XTool.InitUiObject(self) + self.BtnTanchuangClose.CallBack = function() self:OnBtnCloseClick() end + self.BtnBlock.CallBack = function() self:OnBtnBlockClick() end + + self.DynamicTableReward = XDynamicTableNormal.New(self.BossScoreList.gameObject) + self.DynamicTableReward:SetProxy(XUiGridUnionRewardItem) + self.DynamicTableReward:SetDelegate(self) + +end + +function XUiPanelUnionKillRankReward:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self.RootUi) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.RankRewards[index] + if not data then return end + grid:Refresh(data, self.CurRankLevel) + end +end + +function XUiPanelUnionKillRankReward:Refresh(rankSelectLevel) + self.GameObject:SetActiveEx(true) + + self.CurRankLevel = 1 + local unionKillInfo = XDataCenter.FubenUnionKillManager.GetUnionKillInfo() + if unionKillInfo then + local sectionId = unionKillInfo.CurSectionId + local sectionInfo = XDataCenter.FubenUnionKillManager.GetSectionInfoById(sectionId) + if sectionInfo then + self.CurRankLevel = sectionInfo.RankLevel + end + end + self.CurRankLevel = rankSelectLevel or self.CurRankLevel + self.RankRewards = XFubenUnionKillConfigs.GetUnionRewardListByLevel(self.CurRankLevel) + + self.DynamicTableReward:Clear() + self.DynamicTableReward:SetDataSource(self.RankRewards) + self.DynamicTableReward:ReloadDataASync() +end + +function XUiPanelUnionKillRankReward:OnBtnBlockClick() + self.GameObject:SetActiveEx(false) +end + +function XUiPanelUnionKillRankReward:OnBtnCloseClick() + self.GameObject:SetActiveEx(false) +end + +return XUiPanelUnionKillRankReward \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenUnionKill/XUiPanelUnionSectionEnd.lua b/Resources/Scripts/XUi/XUiFubenUnionKill/XUiPanelUnionSectionEnd.lua new file mode 100644 index 00000000..5bc6e024 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenUnionKill/XUiPanelUnionSectionEnd.lua @@ -0,0 +1,21 @@ +local XUiPanelUnionSectionEnd = XClass(nil, "XUiPanelUnionSectionEnd") + +function XUiPanelUnionSectionEnd:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + + XTool.InitUiObject(self) + self.BtnTongBlack.CallBack = function() self:OnBackClick() end + self.BtnTongBlack:SetNameByGroup(0, CS.XTextManager.GetText("UnionSectionSureCount", 10)) +end + +function XUiPanelUnionSectionEnd:Refresh(sec) + self.BtnTongBlack:SetNameByGroup(0, CS.XTextManager.GetText("UnionSectionSureCount", sec)) +end + +function XUiPanelUnionSectionEnd:OnBackClick() + self.RootUi:LeaveRoomCheckFightState() +end + +return XUiPanelUnionSectionEnd \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenUnionKill/XUiUnionKillDifficulty.lua b/Resources/Scripts/XUi/XUiFubenUnionKill/XUiUnionKillDifficulty.lua new file mode 100644 index 00000000..1650e64c --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenUnionKill/XUiUnionKillDifficulty.lua @@ -0,0 +1,36 @@ +local XUiUnionKillDifficulty = XLuaUiManager.Register(XLuaUi, "UiUnionKillDifficulty") + +function XUiUnionKillDifficulty:OnAwake() + self.BtnBg.CallBack = function() self:OnBtnBgClick() end + self.BtnTongBlack.CallBack = function() self:OnBtnTongBlackClick() end + self.BtnTongBlue.CallBack = function() self:OnBtnTongBlueClick() end + +end + +function XUiUnionKillDifficulty:OnDestroy() +end + + +function XUiUnionKillDifficulty:OnStart(sectionConfig, quitCb, hardModeCb) + self.QuitCb = quitCb + self.HardModeCb = hardModeCb + self.RImgBadgeShiLian:SetRawImage(sectionConfig.TrialIcon) +end + +function XUiUnionKillDifficulty:OnBtnBgClick() + self:Close() +end + +function XUiUnionKillDifficulty:OnBtnTongBlackClick() + self:Close() + if self.QuitCb then + self.QuitCb() + end +end + +function XUiUnionKillDifficulty:OnBtnTongBlueClick() + self:Close() + if self.HardModeCb then + self.HardModeCb() + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenUnionKill/XUiUnionKillEnterFight.lua b/Resources/Scripts/XUi/XUiFubenUnionKill/XUiUnionKillEnterFight.lua new file mode 100644 index 00000000..092b02d0 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenUnionKill/XUiUnionKillEnterFight.lua @@ -0,0 +1,141 @@ +local XUiUnionKillEnterFight = XLuaUiManager.Register(XLuaUi, "UiUnionKillEnterFight") +local greyColor = CS.UnityEngine.Color(152 / 255, 152 / 255, 152 / 255, 1) +local blueColor = CS.UnityEngine.Color(15 / 255, 112 / 255, 188 / 255, 1) +local redColor = CS.UnityEngine.Color(208 / 255, 107 / 255, 33 / 255, 1) + +function XUiUnionKillEnterFight:OnAwake() + self.BtnMask.CallBack = function() self:OnBtnMaskClick() end + self.BtnEnterFight.CallBack = function() self:OnBtnEnterFightClick() end + self.BtnBossEnterFight.CallBack = function() self:OnBtnBossEnterFightClick() end +end + +function XUiUnionKillEnterFight:OnDestroy() +end + +function XUiUnionKillEnterFight:OnStart(stageId, sectionTemplate, stageType) + self.StageId = stageId + self.CurSectionTemplate = sectionTemplate + self.StageType = stageType + + if self.StageType == XFubenUnionKillConfigs.UnionKillStageType.EventStage then + self:PlayAnimation("GuanQiaFightEnable", function() + XLuaUiManager.SetMask(false) + end, function() + XLuaUiManager.SetMask(true) + end) + self:OnOpenEventStageDetails() + else + self:PlayAnimation("BossFightEnable", function() + XLuaUiManager.SetMask(false) + end, function() + XLuaUiManager.SetMask(true) + end) + self:OnOpenBossStageDetails() + end +end + +-- 事件关 +function XUiUnionKillEnterFight:OnOpenEventStageDetails() + self.PanelGuanQiaFight.gameObject:SetActiveEx(true) + self.PanelBossFight.gameObject:SetActiveEx(false) + local stageCfg = XDataCenter.FubenManager.GetStageCfg(self.StageId) + + self.TxtFightName.text = stageCfg.Name + local eventStageTemplate = XFubenUnionKillConfigs.GetUnionEventStageById(self.StageId) + if not eventStageTemplate then return end + + local buffId = eventStageTemplate.EventId[1] + local buffConfig = XFubenUnionKillConfigs.GetUnionEventConfigById(buffId) + self.RImgBuff:SetRawImage(buffConfig.Icon) + self.TxtBuffDescription1.text = buffConfig.Description + self.TxtBuffName.text = buffConfig.Name + + local extraBuffId = eventStageTemplate.EventId[2] + local extraBuffConfig = XFubenUnionKillConfigs.GetUnionEventConfigById(extraBuffId) + self.TxtBuffDescription2.text = extraBuffConfig.Description + + self.RoomFightData = XDataCenter.FubenUnionKillManager.GetCurRoomData() + if not self.RoomFightData then + self.TxtBuffDescription1.color = greyColor + self.TxtBuffDescription2.color = greyColor + else + local stageInfos = self.RoomFightData.UnionKillStageInfos + local curStageInfo = stageInfos[self.StageId] + + local meFinish = XDataCenter.FubenUnionKillManager.IsMeFinish(curStageInfo) + local othersFinish = XDataCenter.FubenUnionKillManager.IsOthersFinish(curStageInfo) + + self.TxtBuffDescription1.color = meFinish and blueColor or greyColor + self.TxtBuffDescription2.color = (meFinish and othersFinish) and blueColor or greyColor + + local textManager = CS.XTextManager + -- 一级生效 + if meFinish then + self.TxtBuffCondition1.color = blueColor + self.TxtBuffCondition1.text = textManager.GetText("UnionEffectiveText") + else + self.TxtBuffCondition1.color = redColor + self.TxtBuffCondition1.text = textManager.GetText("UnionMeFinishText") + end + + -- 二级生效 + if meFinish and othersFinish then + self.TxtBuffCondition1.color = greyColor + self.TxtBuffDescription1.color = greyColor + self.TxtBuffCondition1.text = textManager.GetText("UnionInvalidText") + + self.TxtBuffCondition2.color = blueColor + self.TxtBuffCondition2.text = textManager.GetText("UnionEffectiveText") + else + if not meFinish then + self.TxtBuffCondition1.color = redColor + end + self.TxtBuffCondition2.color = redColor + self.TxtBuffCondition2.text = textManager.GetText("UnionTeamFinishText") + end + end +end + +-- boss关 + 试炼关 +function XUiUnionKillEnterFight:OnOpenBossStageDetails() + self.PanelGuanQiaFight.gameObject:SetActiveEx(false) + self.PanelBossFight.gameObject:SetActiveEx(true) + + local stageCfg = XDataCenter.FubenManager.GetStageCfg(self.StageId) + local sectionConfig = XFubenUnionKillConfigs.GetUnionSectionConfigById(self.CurSectionTemplate.Id) + self.TxtBossFightName.text = stageCfg.Name + if self.StageType == XFubenUnionKillConfigs.UnionKillStageType.BossStage then + self.RImgBossShiLian:SetRawImage(sectionConfig.BossIcon) + else + self.RImgBossShiLian:SetRawImage(sectionConfig.TrialIcon) + end + self.TxtAttributeTitle.text = sectionConfig.BossBuffName + self.TxtAttributeDescription.text = sectionConfig.BossBuffText +end + +function XUiUnionKillEnterFight:OnBtnMaskClick() + self:Close() +end + +-- 事件关 +function XUiUnionKillEnterFight:OnBtnEnterFightClick() + -- 是否重复打 + if not self.RoomFightData or not self.StageId then return end + local stageInfos = self.RoomFightData.UnionKillStageInfos + local curStageInfo = stageInfos[self.StageId] + local meFinish = XDataCenter.FubenUnionKillManager.IsMeFinish(curStageInfo) + if meFinish then + XUiManager.TipMsg(CS.XTextManager.GetText("UnionHadFightEventStage")) + return + end + + self:Close() + XLuaUiManager.Open("UiNewRoomSingle", self.StageId) +end + +function XUiUnionKillEnterFight:OnBtnBossEnterFightClick() + if not self.StageId then return end + -- 根据类型处理 + self:Close() + XLuaUiManager.Open("UiNewRoomSingle", self.StageId) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenUnionKill/XUiUnionKillGrade.lua b/Resources/Scripts/XUi/XUiFubenUnionKill/XUiUnionKillGrade.lua new file mode 100644 index 00000000..0dcbba6a --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenUnionKill/XUiUnionKillGrade.lua @@ -0,0 +1,97 @@ +local XUiUnionKillGrade = XLuaUiManager.Register(XLuaUi, "UiUnionKillGrade") +local XUiUnionKillGridTeamCard = require("XUi/XUiFubenUnionKill/XUiUnionKillGridTeamCard") + +function XUiUnionKillGrade:OnAwake() + self.BtnContinue.CallBack = function() self:OnBtnContinueClick() end + + self.PanelCountDown.gameObject:SetActiveEx(true) + self.TeamCards = {} +end + +function XUiUnionKillGrade:OnDestroy() + self:EndCountDown() +end + +function XUiUnionKillGrade:OnStart(winData) + self.WinData = winData + self.StageId = self.WinData.SettleData.StageId + + local unionKillResult = self.WinData.SettleData.UnionKillResult + if unionKillResult then + local shareResults = unionKillResult.ShareResultInfos + self:UpdateShareInfos(shareResults) + end + + self:EndCountDown() + -- 开启倒计时、倒计时结束开始可以退出 + local now = XTime.GetServerNowTimestamp() + local endSecond = now + XFubenUnionKillConfigs.PraiseInterval + + self.TxtContinue.gameObject:SetActiveEx(false) + -- self.BtnContinue.enabled = false + self.TxtCountDown.text = CS.XTextManager.GetText("UnionGradeCountDown", endSecond - now) + self.UnionGradeTimer = XScheduleManager.ScheduleForever(function() + now = XTime.GetServerNowTimestamp() + if now > endSecond then + self:EndCountDown() + self:BeforeGradeClose() + return + end + self.TxtCountDown.text = CS.XTextManager.GetText("UnionGradeCountDown", endSecond - now) + end, XScheduleManager.SECOND, 0) +end + +function XUiUnionKillGrade:UpdateShareInfos(shareResults) + if not shareResults then return end + for i = 1, #shareResults do + if not self.TeamCards[i] then + local ui = CS.UnityEngine.Object.Instantiate(self.GridFightGradeItem.gameObject) + ui.transform:SetParent(self.PanelFightGradeContainer, false) + self.TeamCards[i] = XUiUnionKillGridTeamCard.New(ui, self) + end + self.TeamCards[i].GameObject:SetActiveEx(true) + self.TeamCards[i]:Refresh(shareResults[i]) + end + for i = #shareResults + 1, #self.TeamCards do + self.TeamCards[i].GameObject:SetActiveEx(false) + end +end + +function XUiUnionKillGrade:EndCountDown() + if self.UnionGradeTimer ~= nil then + XScheduleManager.UnSchedule(self.UnionGradeTimer) + self.UnionGradeTimer = nil + end + self.TxtCountDown.text = "" + self.TxtContinue.gameObject:SetActiveEx(true) + -- self.BtnContinue.enabled = true +end + +function XUiUnionKillGrade:BeforeGradeClose() + + if XLuaUiManager.IsUiShow("UiPlayerInfo") then + XLuaUiManager.Close("UiPlayerInfo") + end + + self:Close() + + -- 打开其他界面 + -- 事件关卡 + if XDataCenter.FubenUnionKillManager.IsEventStage(self.StageId) then + XLuaUiManager.Open("UiSettleWin", self.WinData) + return + end + + -- boss、试炼关卡 + if XDataCenter.FubenUnionKillManager.IsBossStage(self.StageId) or XDataCenter.FubenUnionKillManager.IsTrialStage(self.StageId) then + if self.WinData.SettleData.UnionKillResult then + XLuaUiManager.Open("UiArenaFightResult", self.WinData) + return + end + end + +end + +function XUiUnionKillGrade:OnBtnContinueClick() + self:BeforeGradeClose() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenUnionKill/XUiUnionKillGridTeamCard.lua b/Resources/Scripts/XUi/XUiFubenUnionKill/XUiUnionKillGridTeamCard.lua new file mode 100644 index 00000000..9f1b3fa4 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenUnionKill/XUiUnionKillGridTeamCard.lua @@ -0,0 +1,82 @@ +local XUiUnionKillGridTeamCard = XClass(nil, "XUiUnionKillGridTeamCard") + +function XUiUnionKillGridTeamCard:Ctor(ui, root) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = root + + XTool.InitUiObject(self) + + self.BtnLike.CallBack = function() self:OnBtnLikeClick() end + self.BtnAddFriend.CallBack = function() self:OnBtnAddFriendClick() end + self.BtnReport.CallBack = function() self:OnBtnReportClick() end + self.BtnHead.CallBack = function() self:OnBtnHeadClick() end +end + +function XUiUnionKillGridTeamCard:Refresh(shareInfo) + self.ShareInfo = shareInfo + -- 玩家相关 + local playerId = shareInfo.Id + local playerName = shareInfo.Name + local playerLevel = shareInfo.Level + local playerHeadPortraitId = shareInfo.HeadPortraitId + local playerHeadFrameId = shareInfo.HeadFrameId + + self.TxtName.text = XDataCenter.SocialManager.GetPlayerRemark(playerId, playerName) + + XUiPLayerHead.InitPortrait(playerHeadPortraitId, playerHeadFrameId, self.Head) + + if shareInfo.MedalId and shareInfo.MedalId > 0 then + local medalConfig = XMedalConfigs.GetMeadalConfigById(shareInfo.MedalId) + self.ImgMedalIcon.gameObject:SetActiveEx(true) + self.ImgMedalIcon:SetRawImage(medalConfig.MedalIcon) + else + self.ImgMedalIcon.gameObject:SetActiveEx(false) + end + self.TxtPlayerLevel.text = playerLevel + local characterId = shareInfo.Character.Id + local character = shareInfo.Character + self.RImgCharacterHead:SetRawImage(XDataCenter.CharacterManager.GetCharSmallHeadIcon(characterId)) + self.TxtCharacterName.text = XCharacterConfigs.GetCharacterFullNameStr(characterId) + self.TxtCharacterLevel.text = character.Level + self.TxtCharacterAbilibty.text = math.floor(character.Ability) + self.RImgQuality:SetRawImage(XCharacterConfigs.GetCharacterQualityIcon(character.Quality)) + + self.BtnAddFriend.gameObject:SetActiveEx(not XDataCenter.SocialManager.CheckIsFriend(playerId)) + self.IsPraise = false + self.ImgLikeDisabled.gameObject:SetActiveEx(self.IsPraise) + self.ImgLikeAlready.gameObject:SetActiveEx(self.IsPraise) +end + +function XUiUnionKillGridTeamCard:OnBtnLikeClick() + if not self.ShareInfo then return end + if self.IsPraise then return end + + XDataCenter.FubenUnionKillManager.PraisePlayerCharacters(self.ShareInfo.Id, self.ShareInfo.Character.Id, function() + self.IsPraise = true + + self.ImgLikeDisabled.gameObject:SetActiveEx(self.IsPraise) + self.ImgLikeAlready.gameObject:SetActiveEx(self.IsPraise) + end) +end + +function XUiUnionKillGridTeamCard:OnBtnAddFriendClick() + if not self.ShareInfo then return end + + XDataCenter.SocialManager.ApplyFriend(self.ShareInfo.Id, function() + self.BtnAddFriend.gameObject:SetActiveEx(false) + end) +end + +function XUiUnionKillGridTeamCard:OnBtnReportClick() + if not self.ShareInfo then return end + + XLuaUiManager.Open("UiReport", self.ShareInfo.Id, self.ShareInfo.Name, self.ShareInfo.Level) +end + +function XUiUnionKillGridTeamCard:OnBtnHeadClick() + if not self.ShareInfo then return end + XDataCenter.PersonalInfoManager.ReqShowInfoPanel(self.ShareInfo.Id) +end + +return XUiUnionKillGridTeamCard \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenUnionKill/XUiUnionKillMain.lua b/Resources/Scripts/XUi/XUiFubenUnionKill/XUiUnionKillMain.lua new file mode 100644 index 00000000..4a5a51bf --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenUnionKill/XUiUnionKillMain.lua @@ -0,0 +1,507 @@ +local XUiUnionKillMain = XLuaUiManager.Register(XLuaUi, "UiUnionKillMain") + +function XUiUnionKillMain:OnAwake() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self.BtnBack.CallBack = function() + self:OnBtnBackClick() + end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + + self.BtnMatch.CallBack = function() self:OnBtnMatchClick() end + self.BtnCancelMatch.CallBack = function() self:OnBtnCancelMatchClick() end + self.BtnCreateRoom.CallBack = function() self:OnBtnCreateRoomClick() end + self.BtnThumbsUp.CallBack = function() self:OnBtnThumbsUpClick() end + self.BtnKillNumber.CallBack = function() self:OnBtnKillNumberClick() end + self.BtnBlackSquare.CallBack = function() self:OnBtnBlackSquareClick() end + self.BtnReward.CallBack = function() self:OnBtnRewardClick() end + self.BtnHelp.CallBack = function() self:OnBtnHelpClick() end + self:BindHelpBtnOnly(self.BtnHelp) + + self.RewardCommon = {} + + self:AddEventListeners() +end + +function XUiUnionKillMain:OnDestroy() + self:StopActivityCountDown() + self:RemoveEventListeners() +end + +function XUiUnionKillMain:AddEventListeners() + XEventManager.AddEventListener(XEventId.EVENT_UNIONKILL_BOSSCOUNTCHANGE, self.SyncBossCountChanged, self) + XEventManager.AddEventListener(XEventId.EVENT_UNIONKILLROOM_MATCHRESULT, self.OnMatchResult, self) + XEventManager.AddEventListener(XEventId.EVENT_UNIONKILL_ACTIVITYINFO, self.OnActivityInfoChanged, self) + +end + +function XUiUnionKillMain:RemoveEventListeners() + XEventManager.RemoveEventListener(XEventId.EVENT_UNIONKILL_BOSSCOUNTCHANGE, self.SyncBossCountChanged, self) + XEventManager.RemoveEventListener(XEventId.EVENT_UNIONKILLROOM_MATCHRESULT, self.OnMatchResult, self) + XEventManager.RemoveEventListener(XEventId.EVENT_UNIONKILL_ACTIVITYINFO, self.OnActivityInfoChanged, self) +end + +-- 击杀boss次数变化 +function XUiUnionKillMain:SyncBossCountChanged() + if not self.UnionKillInfo then return end + local sectionId = self.UnionKillInfo.CurSectionId + local curSectionInfo = XDataCenter.FubenUnionKillManager.GetSectionInfoById(sectionId) + local curSectionTemplate = XFubenUnionKillConfigs.GetUnionSectionById(sectionId) + if not curSectionTemplate then return end + + self.TxtCondition.gameObject:SetActiveEx(false) + self.BtnReward.gameObject:SetActiveEx(false) + self.TxtTaskProgress.gameObject:SetActiveEx(false) + + local syncCount = XDataCenter.FubenUnionKillManager.GetBossKillCount(sectionId) + if not curSectionInfo then + self.TxtTaskProgress.text = CS.XTextManager.GetText("UnionResetText", syncCount, curSectionTemplate.KillBossCount) + -- 可领取 + if syncCount >= curSectionTemplate.KillBossCount then + self.BtnReward:ShowReddot(true) + self.BtnReward:ShowTag(false) + self.BtnReward.gameObject:SetActiveEx(true) + else + -- 不可领取 + self.BtnReward:ShowReddot(false) + self.BtnReward:ShowTag(true) + self.TxtTaskProgress.gameObject:SetActiveEx(true) + end + else + local killBossCount = curSectionInfo.KillBoss or 0 + syncCount = killBossCount > syncCount and killBossCount or syncCount + self.TxtTaskProgress.text = CS.XTextManager.GetText("UnionResetText", syncCount, curSectionTemplate.KillBossCount) + -- 未领取 + if curSectionInfo.RewardStatus == 0 then + -- 可领取 + if syncCount >= curSectionTemplate.KillBossCount then + self.BtnReward:ShowReddot(true) + self.BtnReward.gameObject:SetActiveEx(true) + else + -- 不可领取 + self.BtnReward:ShowReddot(false) + self.TxtTaskProgress.gameObject:SetActiveEx(true) + end + self.BtnReward:ShowTag(false) + else + -- 已领取 + self.BtnReward:ShowReddot(false) + self.BtnReward:ShowTag(true) + self.TxtCondition.gameObject:SetActiveEx(true) + end + end +end + +function XUiUnionKillMain:OnStart() + self.UnionKillInfo = XDataCenter.FubenUnionKillManager.GetUnionKillInfo() + if self.UnionKillInfo == nil then return end + if self.UnionKillInfo.Id == nil or self.UnionKillInfo.Id == 0 then return end + self.CurrentUnionActivityConfig = XFubenUnionKillConfigs.GetUnionActivityConfigById(self.UnionKillInfo.Id) + self.CurrentUnionActivityTemplate = XFubenUnionKillConfigs.GetUnionActivityById(self.UnionKillInfo.Id) + + self:InitUnionSectionView() + self:SetMainInfo() + self:SyncBossCountChanged() + + local firstShowKey = string.format("%s_%s_%d", XFubenUnionKillConfigs.FirstShowHelp, tostring(XPlayer.Id), self.UnionKillInfo.Id) + self:PlayAnimation("AnimStartEnable", function() + XLuaUiManager.SetMask(false) + + -- 首次弹帮助说明 + local cacheValue = XDataCenter.FubenUnionKillManager.GetUnionKillStringPrefs(firstShowKey, "0") + if cacheValue == "0" then + XUiManager.ShowHelpTip("UnionKillMainHelp") + XDataCenter.FubenUnionKillManager.SaveUnionKillStringPrefs(firstShowKey, "1") + end + end, function() + XLuaUiManager.SetMask(true) + end) + XRedPointManager.AddRedPointEvent(self.RedTask, self.RefreshTaskLimited, self, { XRedPointConditions.Types.CONDITION_TASK_LIMIT_TYPE }, self.CurrentUnionActivityTemplate.TaskLimitId) +end + +function XUiUnionKillMain:RefreshTaskLimited(count) + self.RedTask.gameObject:SetActiveEx(count >= 0) +end + +function XUiUnionKillMain:OnEnable() + self:CheckActivityEnd(false) +end + +function XUiUnionKillMain:SetMainInfo() + self.TxtTitle.text = self.CurrentUnionActivityConfig.Name + + local weatherConfig = XFubenUnionKillConfigs.GetUnionWeatherConfigById(self.UnionKillInfo.WeatherId) + self.TxtShuXing.text = string.format("(%s:%s)", weatherConfig.Name, weatherConfig.Description) + + self:StartActivityCountDown() +end + +-- 启动活动结束倒计时 +function XUiUnionKillMain:StartActivityCountDown() + self:StopActivityCountDown() + + local _, endTime = XFubenUnionKillConfigs.GetUnionActivityTimes(self.UnionKillInfo.Id) + local _, tmpSectionEndTime = XFubenUnionKillConfigs.GetUnionSectionTimes(self.UnionKillInfo.CurSectionId) + local now = XTime.GetServerNowTimestamp() + if not endTime then return end + + self.TxtDay.text = XUiHelper.GetTime(endTime - now, XUiHelper.TimeFormatType.ACTIVITY) + local invalidTime = CS.XTextManager.GetText("UnionMainOverdue") + if now <= tmpSectionEndTime then + self.TxtSectionDay.text = CS.XTextManager.GetText("UnionRewardResetTime", XUiHelper.GetTime(tmpSectionEndTime - now, XUiHelper.TimeFormatType.ACTIVITY)) + else + self.TxtSectionDay.text = CS.XTextManager.GetText("UnionRewardResetTime", invalidTime) + end + + self.UnionKillTimer = + XScheduleManager.ScheduleForever(function() + now = XTime.GetServerNowTimestamp() + if now > endTime then + self:StopActivityCountDown() + self:CheckActivityEnd(true) + return + end + self.TxtDay.text = XUiHelper.GetTime(endTime - now, XUiHelper.TimeFormatType.ACTIVITY) + if now <= tmpSectionEndTime then + self.TxtSectionDay.text = CS.XTextManager.GetText("UnionRewardResetTime", XUiHelper.GetTime(tmpSectionEndTime - now, XUiHelper.TimeFormatType.ACTIVITY)) + else + self.TxtSectionDay.text = CS.XTextManager.GetText("UnionRewardResetTime", invalidTime) + end + + if self.IsMatching and self.BeginMatchingTime then + local tmpNow = XTime.GetServerNowTimestamp() + self.TxtMatchTime.text = XUiHelper.GetTime(tmpNow - self.BeginMatchingTime) + end + + end, XScheduleManager.SECOND, 0) +end + +-- 关闭活动结束倒计时 +function XUiUnionKillMain:StopActivityCountDown() + if self.UnionKillTimer ~= nil then + XScheduleManager.UnSchedule(self.UnionKillTimer) + self.UnionKillTimer = nil + end +end + +function XUiUnionKillMain:OnBtnHelpClick() + if XDataCenter.FubenUnionKillRoomManager.IsMatching() then + return + end + + XUiManager.ShowHelpTip("UnionKillMainHelp") +end + +-- 活动任务 +function XUiUnionKillMain:OnBtnBlackSquareClick() + if XDataCenter.FubenUnionKillRoomManager.IsMatching() then + return + end + + XLuaUiManager.Open("UiUnionKillTask") +end + +-- 奖励 +function XUiUnionKillMain:OnBtnRewardClick() + if XDataCenter.FubenUnionKillRoomManager.IsMatching() then + return + end + + -- 获得奖励逻辑 + if not self.UnionKillInfo then return end + local sectionId = self.UnionKillInfo.CurSectionId + local curSectionInfo = XDataCenter.FubenUnionKillManager.GetSectionInfoById(sectionId) + local curSectionTemplate = XFubenUnionKillConfigs.GetUnionSectionById(sectionId) + if not curSectionInfo then return end + if not curSectionTemplate then return end + if curSectionInfo.RewardStatus == 1 then + XUiManager.TipMsg(CS.XTextManager.GetText("UnionMainRewardHasClick")) + return + end + local syncCount = XDataCenter.FubenUnionKillManager.GetBossKillCount(sectionId) + local killBossCount = curSectionInfo and curSectionInfo.KillBoss or 0 + syncCount = killBossCount > syncCount and killBossCount or syncCount + if syncCount < curSectionTemplate.KillBossCount then + XUiManager.TipMsg(CS.XTextManager.GetText("UnionMainKillLimited")) + return + end + + XDataCenter.FubenUnionKillManager.GetUnionBoxReward(sectionId, function() + curSectionInfo.RewardStatus = 1 + self:SyncBossCountChanged() + end) +end + +-- 击杀排行 +function XUiUnionKillMain:OnBtnKillNumberClick() + if not self.UnionKillInfo then return end + if XDataCenter.FubenUnionKillRoomManager.IsMatching() then + return + end + + local sectionId = self.UnionKillInfo.CurSectionId + local sectionInfo = XDataCenter.FubenUnionKillManager.GetSectionInfoById(sectionId) + if not sectionInfo then return end + + local rankLevel = sectionInfo.RankLevel + local rankLevelInfos = XDataCenter.FubenUnionKillManager.GetKillRankInfosByLevel(rankLevel) + local now = XTime.GetServerNowTimestamp() + + if not rankLevelInfos or now - rankLevelInfos.LastModify > XFubenUnionKillConfigs.RankRequestInterval then + XDataCenter.FubenUnionKillManager.GetUnionKillRankData(sectionInfo.RankLevel, function() + XLuaUiManager.Open("UiUnionKillRank", XFubenUnionKillConfigs.UnionRankType.KillNumber) + end) + else + XLuaUiManager.Open("UiUnionKillRank", XFubenUnionKillConfigs.UnionRankType.KillNumber) + end + +end + +-- 点赞排行 +function XUiUnionKillMain:OnBtnThumbsUpClick() + if XDataCenter.FubenUnionKillRoomManager.IsMatching() then + return + end + + local rankPraiseInfos = XDataCenter.FubenUnionKillManager.GetPraiseRankInfos() + local now = XTime.GetServerNowTimestamp() + if not rankPraiseInfos or now - rankPraiseInfos.LastModify > XFubenUnionKillConfigs.RankRequestInterval then + XDataCenter.FubenUnionKillManager.GetPraiseRankData(function() + XLuaUiManager.Open("UiUnionKillRank", XFubenUnionKillConfigs.UnionRankType.ThumbsUp) + end) + else + XLuaUiManager.Open("UiUnionKillRank", XFubenUnionKillConfigs.UnionRankType.ThumbsUp) + end +end + +-- 创建房间 +function XUiUnionKillMain:OnBtnCreateRoomClick() + if XDataCenter.FubenUnionKillRoomManager.IsMatching() then + XUiManager.TipMsg(CS.XTextManager.GetText("UnionInMatching")) + return + end + XDataCenter.FubenUnionKillRoomManager.CreateUnionRoom(true, function() + XLuaUiManager.Open("UiUnionKillRoom") + end) +end + +-- 匹配 +function XUiUnionKillMain:OnBtnMatchClick() + XDataCenter.FubenUnionKillRoomManager.MatchUnionRoom(function() + self.IsMatching = true + self.BeginMatchingTime = XTime.GetServerNowTimestamp() + self.TxtMatchTime.text = XUiHelper.GetTime(0) + + self.PiPeiGroup.gameObject:SetActiveEx(true) + self.BtnMatch.gameObject:SetActiveEx(false) + self.BtnMatching.gameObject:SetActiveEx(true) + end) +end + +-- 取消匹配 +function XUiUnionKillMain:OnBtnCancelMatchClick() + XDataCenter.FubenUnionKillRoomManager.CancelUnionMatch(function() + self.IsMatching = false + + self.PiPeiGroup.gameObject:SetActiveEx(false) + self.BtnMatch.gameObject:SetActiveEx(true) + self.BtnMatching.gameObject:SetActiveEx(false) + end) + +end + +-- 匹配到结果 +function XUiUnionKillMain:OnMatchResult() + self.IsMatching = false + + self.PiPeiGroup.gameObject:SetActiveEx(false) + self.BtnMatch.gameObject:SetActiveEx(true) + self.BtnMatching.gameObject:SetActiveEx(false) +end + +-- 天气、章节变化 +function XUiUnionKillMain:OnActivityInfoChanged() + if not self.UnionKillInfo then return end + if not self.CurrentUnionActivityTemplate then return end + + -- 天气 + local weatherConfig = XFubenUnionKillConfigs.GetUnionWeatherConfigById(self.UnionKillInfo.WeatherId) + self.TxtWeather.text = weatherConfig.Name + self.TxtShuXing.text = weatherConfig.Description + if weatherConfig.Icon ~= "" then + self:SetUiSprite(self.ImgWeatherIcon, weatherConfig.Icon) + end + + -- 章节切换 + local sectionId = self.UnionKillInfo.CurSectionId + local selectIndex = self.CurrentSelectedSection + local allSectionIds = self.CurrentUnionActivityTemplate.SectionId + for index, id in pairs(allSectionIds) do + if id == sectionId then + selectIndex = index + break + end + end + self:OnSectionSelected(selectIndex) + + -- boss条件 + self:SyncBossCountChanged() +end + +-- 右切 +function XUiUnionKillMain:OnBtnBgQiehuanRightClcik() +end + +-- 左切 +function XUiUnionKillMain:OnBtnBgQiehuanLeftClick() +end + +-- 初始化切换点 +function XUiUnionKillMain:InitUnionSectionView() + + if not self.CurrentUnionActivityTemplate then return end + if not self.UnionKillInfo then return end + local sectionId = self.UnionKillInfo.CurSectionId + -- Switch + self.CurrentSelectedSection = 1 + local allSectionIds = self.CurrentUnionActivityTemplate.SectionId + for i = 1, #allSectionIds do + if allSectionIds[i] == sectionId then + self.CurrentSelectedSection = i + end + end + + self:OnSectionSelected(self.CurrentSelectedSection) +end + +function XUiUnionKillMain:OnSectionSelected(index) + + self.CurrentSelectedSection = index + self:UpdateSectionInfo(self.CurrentSelectedSection) +end + + +-- 更新当前选中的章节 +function XUiUnionKillMain:UpdateSectionInfo(index) + if not self.CurrentUnionActivityTemplate then return end + if not self.UnionKillInfo then return end + + local selectSectoinId = self.CurrentUnionActivityTemplate.SectionId[index] + + local selectSectionTemplate = XFubenUnionKillConfigs.GetUnionSectionById(selectSectoinId) + if not selectSectionTemplate or not selectSectoinId or selectSectoinId <= 0 then return end + + local sectionConfig = XFubenUnionKillConfigs.GetUnionSectionConfigById(selectSectoinId) + self:SwitchBackground(sectionConfig) + + -- 过期、时间未到 + local sectionId = self.UnionKillInfo.CurSectionId + local curOpenIndex = 1 + for i = 1, #self.CurrentUnionActivityTemplate.SectionId do + if self.CurrentUnionActivityTemplate.SectionId[i] == sectionId then + curOpenIndex = i + break + end + end + + self.PassPanel.gameObject:SetActiveEx(curOpenIndex ~= index) + self.TxtWeiKaiQi.gameObject:SetActiveEx(curOpenIndex < index) + self.TxtYiTongGuo.gameObject:SetActiveEx(curOpenIndex > index) + if curOpenIndex < index then + local now = XTime.GetServerNowTimestamp() + local beginTime = XFubenUnionKillConfigs.GetUnionSectionTimes(selectSectoinId) + self.TxtWeiKaiQi.text = CS.XTextManager.GetText("UnionSectionIsComing", XUiHelper.GetTime(beginTime - now, XUiHelper.TimeFormatType.ACTIVITY)) + end + + -- 隐藏多余数据 + local isOpen = curOpenIndex == index + self.RewardGroup.gameObject:SetActiveEx(isOpen) + self.BtnBlackSquare.gameObject:SetActiveEx(isOpen) + self.BtnBottomRight.gameObject:SetActiveEx(isOpen) + self.WeatherGroup.gameObject:SetActiveEx(isOpen) + self.BtnRight.gameObject:SetActiveEx(isOpen) + + -- 显示奖励 + local rewards = XRewardManager.GetRewardList(selectSectionTemplate.BoxRewardId) + for i = 1, #rewards do + if not self.RewardCommon[i] then + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommonPopUp) + ui.transform:SetParent(self.PanelRewrds, false) + self.RewardCommon[i] = XUiGridCommon.New(self, ui) + end + self.RewardCommon[i]:Refresh(rewards[i]) + end + for i = #rewards + 1, #self.RewardCommon do + self.RewardCommon[i].GameObject:SetActiveEx(false) + end +end + +function XUiUnionKillMain:CheckActivityEnd(isCheckPanel) + + if not self.UnionKillInfo or self.UnionKillInfo.Id <= 0 then + XLuaUiManager.RunMain() + XUiManager.TipMsg(CS.XTextManager.GetText("UnionKillMainNotInActivity")) + -- 退出 + return + end + + if not XFubenUnionKillConfigs.UnionKillInActivity(self.UnionKillInfo.Id) and not CS.XFight.IsRunning then + if isCheckPanel and XLuaUiManager.IsUiShow("UiUnionKillMain") then + -- 退出 + XLuaUiManager.RunMain() + XUiManager.TipMsg(CS.XTextManager.GetText("UnionKillMainNotInActivity")) + return + end + -- 退出 + XLuaUiManager.RunMain() + XUiManager.TipMsg(CS.XTextManager.GetText("UnionKillMainNotInActivity")) + end +end + +function XUiUnionKillMain:SwitchBackground(sectionConfig) + if not sectionConfig then return end + + for i = 1, #sectionConfig.SectionIcon do + self[string.format("RImgBg%d", i)]:SetRawImage(sectionConfig.SectionIcon[i]) + end + +end + +function XUiUnionKillMain:OnBtnBackClick() + if XDataCenter.FubenUnionKillRoomManager.IsMatching() then + local title = CS.XTextManager.GetText("TipTitle") + local cancelMatchMsg = CS.XTextManager.GetText("OnlineInstanceCancelMatch") + XUiManager.DialogTip(title, cancelMatchMsg, XUiManager.DialogType.Normal, nil, function() + XDataCenter.FubenUnionKillRoomManager.CancelUnionMatch(function() + self.IsMatching = false + + self.PiPeiGroup.gameObject:SetActiveEx(false) + self.BtnMatch.gameObject:SetActiveEx(true) + self.BtnMatching.gameObject:SetActiveEx(false) + self:Close() + end) + end) + else + self:Close() + end +end + +function XUiUnionKillMain:OnBtnMainUiClick() + if XDataCenter.FubenUnionKillRoomManager.IsMatching() then + local title = CS.XTextManager.GetText("TipTitle") + local cancelMatchMsg = CS.XTextManager.GetText("OnlineInstanceCancelMatch") + XUiManager.DialogTip(title, cancelMatchMsg, XUiManager.DialogType.Normal, nil, function() + XDataCenter.FubenUnionKillRoomManager.CancelUnionMatch(function() + self.IsMatching = false + + self.PiPeiGroup.gameObject:SetActiveEx(false) + self.BtnMatch.gameObject:SetActiveEx(true) + self.BtnMatching.gameObject:SetActiveEx(false) + XLuaUiManager.RunMain() + end) + end) + + else + XLuaUiManager.RunMain() + end + +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenUnionKill/XUiUnionKillMember.lua b/Resources/Scripts/XUi/XUiFubenUnionKill/XUiUnionKillMember.lua new file mode 100644 index 00000000..4b54e7ba --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenUnionKill/XUiUnionKillMember.lua @@ -0,0 +1,280 @@ +local XUiUnionKillMember = XClass(nil, "XUiUnionKillMember") + +function XUiUnionKillMember:Ctor(ui, rootUi, index) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self.Index = index + + XTool.InitUiObject(self) + + self.InformationCard.CallBack = function() self:OnShareCardClick() end + + -- 准备、倒计时 + -- 作战、离线 + self.CountDownGroup.gameObject:SetActiveEx(false) + + -- 邀请 + self.BtnHead.CallBack = function() self:OnBtnHeadClick() end + self.BtnRoomInvite.CallBack = function() self:OnBtnRoomInviteClick() end + self.BtnInviteMask.CallBack = function() self:OnBtnInviteMaskClick() end + self.BtnFriend.CallBack = function() self:OnBtnFriendClick() end + + -- 成员操作 + self.BtnDetailInfo.CallBack = function() self:OnBtnDetailInfoClick() end + self.BtnAddFriend.CallBack = function() self:OnBtnAddFriendClick() end + self.BtnChangeLeader.CallBack = function() self:OnBtnChangeLeaderClick() end + self.BtnKick.CallBack = function() self:OnBtnKickClick() end + self.BtnOperationMask.CallBack = function() self:OnBtnOperationMaskClick() end + +end + +function XUiUnionKillMember:UpdateAllReadyCountDown(sec) + -- 是队长,并且是玩家自己 + if self.PlayerDataList then + local playerId = self.PlayerDataList.Id + local isLeader = XDataCenter.FubenUnionKillRoomManager.IsLeader(playerId) + if isLeader then + self.CountDownGroup.gameObject:SetActiveEx(true) + self.TxtCountDown.text = sec + end + end +end + +function XUiUnionKillMember:HideAllReadyCountDown() + self.CountDownGroup.gameObject:SetActiveEx(false) +end + +-- 没有玩家状态 +function XUiUnionKillMember:InitNonePlayerView() + self.InformationGroup.gameObject:SetActiveEx(false) + self.UnionKillRoomPanelInvite.gameObject:SetActiveEx(true) + self.PlayerDataList = nil +end + +-- 有玩家的状态 +function XUiUnionKillMember:InitPlayerView(playerInfo) + self.PlayerDataList = playerInfo + if not self.PlayerDataList then + self:InitNonePlayerView() + end + self.InformationGroup.gameObject:SetActiveEx(true) + self.UnionKillRoomPanelInvite.gameObject:SetActiveEx(false) + -- 有玩家可以先初始化玩家信息 + self:SetLeaderFlag(self.PlayerDataList.Leader) + self.TxtThumbsUp.text = self.PlayerDataList.PraiseCount + self.TxtName.text = XDataCenter.SocialManager.GetPlayerRemark(self.PlayerDataList.Id, self.PlayerDataList.Name) + self.TxtLvShuZi.text = self.PlayerDataList.Level + + XUiPLayerHead.InitPortrait(self.PlayerDataList.HeadPortraitId, self.PlayerDataList.HeadFrameId, self.Head) + + self.UiUnionKillOffline.gameObject:SetActiveEx(false) + self.UiUnionKillFighting.gameObject:SetActiveEx(false) + + -- 初始化角色信息:可能没有 + self:UpdateShareCharacter(self.PlayerDataList.FightNpcData) + self:UpdatePlayerState() +end + +function XUiUnionKillMember:UpdateShareCharacter(npcData) + -- 不一定是自己拥有的 + local isCharacter = npcData and npcData.Character + self.RImgShareChar.gameObject:SetActiveEx(isCharacter) + self.RImgQuality.gameObject:SetActiveEx(isCharacter) + self.ShareBgLv.gameObject:SetActiveEx(isCharacter) + self.BgSeKuai.gameObject:SetActiveEx(isCharacter) + self.BgAdd.gameObject:SetActiveEx(not isCharacter) + if isCharacter then + local character = npcData.Character + self.RImgShareChar:SetRawImage(XDataCenter.CharacterManager.GetCharHalfBodyImage(character.Id)) + self.RImgQuality:SetRawImage(XCharacterConfigs.GetCharacterQualityIcon(character.Quality)) + self.TxtLvCardShuZi.text = character.Level + end +end + +-- 更新指定玩家的角色 +function XUiUnionKillMember:UpdateShareCharacterById(playerId, npcData) + if self.PlayerDataList and self.PlayerDataList.Id == playerId then + self:UpdateShareCharacter(npcData) + end +end + +-- 更新玩家队长标记 +function XUiUnionKillMember:SetLeaderFlag(isLeader) + self.BgFangZhu.gameObject:SetActiveEx(isLeader) +end + +function XUiUnionKillMember:UpdatePlayerState() + if not self.PlayerDataList then return end + local playerState = self.PlayerDataList.State + + self.UiUnionKillFighting.gameObject:SetActiveEx(XFubenUnionKillConfigs.UnionRoomPlayerState.Fight == playerState) + self.UnionKillRoomZhunBei.gameObject:SetActiveEx(XFubenUnionKillConfigs.UnionRoomPlayerState.Ready == playerState) + self.UnionKillRoomBianJi.gameObject:SetActiveEx(XFubenUnionKillConfigs.UnionRoomPlayerState.Select == playerState) + + if self.PlayerDataList.Leader then + self.UnionKillRoomZhunBei.gameObject:SetActiveEx(false) + end + +end +----------------------------------------------------------------------出站角色 +function XUiUnionKillMember:OnShareCardClick() + -- 自由自己的能修改,如果不是队长并且已经准备、不可以修改 + if self.PlayerDataList and self.PlayerDataList.Id == XPlayer.Id then + if not self.PlayerDataList.Leader and self.PlayerDataList.State == XFubenUnionKillConfigs.UnionRoomPlayerState.Ready then + XUiManager.TipMsg(CS.XTextManager.GetText("UnionRoomHadReady")) + return + end + + XDataCenter.FubenUnionKillRoomManager.ChangePlayerState(XFubenUnionKillConfigs.UnionRoomPlayerState.Select, function() + XLuaUiManager.Open("UiCharacter", self.PlayerDataList.FightNpcData.Character.Id, nil, nil, nil, nil, true) + self.PlayerDataList.State = XFubenUnionKillConfigs.UnionRoomPlayerState.Select + end) + end + -- 没有角色、已有角色、已经准备、还没准备 +end + +---------------------------------------------------------------------- +----------------------------------------------------------------------好友邀请 +function XUiUnionKillMember:OnBtnRoomInviteClick() + self.RootUi:OnInviteClick(self.Index) +end + +function XUiUnionKillMember:ChangeInviteView(isInvite) + self.PanelInvite.gameObject:SetActiveEx(isInvite) +end + +function XUiUnionKillMember:OnBtnInviteMaskClick() + self:ChangeInviteView(false) +end + +function XUiUnionKillMember:OnBtnFriendClick() + XLuaUiManager.Open("UiMultiplayerInviteFriend", MultipleRoomType.UnionKill) +end + +---------------------------------------------------------------------- +----------------------------------------------------------------------成员操作 +function XUiUnionKillMember:OnBtnHeadClick() + -- 玩家是leader,并且当前查看的不是玩家 + if self.PlayerDataList and self.PlayerDataList.Id ~= XPlayer.Id then + self.RootUi:OnOperateClick(self.Index)--点击操作 + end +end + +function XUiUnionKillMember:OnBtnOperationMaskClick() + self:ChangeOperationView(false) +end + +function XUiUnionKillMember:ChangeOperationView(isOperate) + self.UnionKillRoomPanelOperation.gameObject:SetActiveEx(isOperate) + if isOperate then + if self.PlayerDataList then + local isFriend = XDataCenter.SocialManager.CheckIsFriend(self.PlayerDataList.Id) + self.BtnAddFriend.gameObject:SetActiveEx(not isFriend) + local isLeader = XDataCenter.FubenUnionKillRoomManager.IsLeader(XPlayer.Id) + self.BtnChangeLeader.gameObject:SetActiveEx(isLeader) + self.BtnKick.gameObject:SetActiveEx(isLeader) + end + end +end + +function XUiUnionKillMember:OnBtnDetailInfoClick() + if not self.PlayerDataList then return end + XDataCenter.PersonalInfoManager.ReqShowInfoPanel(self.PlayerDataList.Id) +end + +function XUiUnionKillMember:OnBtnAddFriendClick() + if not self.PlayerDataList then return end + XDataCenter.SocialManager.ApplyFriend(self.PlayerDataList.Id) +end + +function XUiUnionKillMember:OnBtnChangeLeaderClick() + if not self.PlayerDataList then return end + XDataCenter.FubenUnionKillRoomManager.ChangeUnionLeader(self.PlayerDataList.Id, function() + -- 刷新主界面的队长标志 + self:ChangeOperationView(false) + self.RootUi:OnTeamLeaderChanged() + self.RootUi:OnAllPlayerChanged() + end) +end + +function XUiUnionKillMember:OnBtnKickClick() + if not self.PlayerDataList then return end + XDataCenter.FubenUnionKillRoomManager.KickOutUnionTeam(self.PlayerDataList.Id, function() + -- 刷新人数 + self:ChangeOperationView(false) + self.RootUi:OnPlayerChanged() + end) +end +------------------------------------------------------------------------------- +-------------------------------------------------------------------------------聊天相关 +function XUiUnionKillMember:ClearUnuseTImer() + self:EndProcessTipEmoji() + self:EndProcessTipTalk() + self:EndTipEmoji() + self:EndTipTalk() +end + +function XUiUnionKillMember:ProcessTipEmoji(senderId, emoji) + if not self.PlayerDataList or self.PlayerDataList.Id ~= senderId then return end + + self:EndProcessTipEmoji() + self:EndProcessTipTalk() + + self:TipEmoji(emoji) + self.EmojiTimer = XScheduleManager.ScheduleOnce(function() + self:EndTipEmoji() + end, 3000) +end + +function XUiUnionKillMember:EndProcessTipEmoji() + if self.EmojiTimer then + XScheduleManager.UnSchedule(self.EmojiTimer) + self.EmojiTimer = nil + self:EndTipEmoji() + end +end + +function XUiUnionKillMember:ProcessTipTalk(senderId, talkContent) + if not self.PlayerDataList or self.PlayerDataList.Id ~= senderId then return end + + self:EndProcessTipTalk() + self:EndProcessTipEmoji() + + self:TipTalk(talkContent) + self.TalkTimer = XScheduleManager.ScheduleOnce(function() + self:EndTipTalk() + end, 3000) +end + +function XUiUnionKillMember:EndProcessTipTalk() + if self.TalkTimer then + XScheduleManager.UnSchedule(self.TalkTimer) + self.TalkTimer = nil + self:EndTipTalk() + end +end + +function XUiUnionKillMember:TipEmoji(emoji) + self.ExpressionGroup.gameObject:SetActiveEx(true) + local icon = XDataCenter.ChatManager.GetEmojiIcon(emoji) + if icon then + self.RImgEmoji:SetRawImage(icon) + end +end + +function XUiUnionKillMember:EndTipEmoji() + self.ExpressionGroup.gameObject:SetActiveEx(false) +end + +function XUiUnionKillMember:TipTalk(talkContent) + self.UnionKillRoomBgChat.gameObject:SetActiveEx(true) + self.TxtRoomChat.text = talkContent +end + +function XUiUnionKillMember:EndTipTalk() + self.UnionKillRoomBgChat.gameObject:SetActiveEx(false) +end + +------------------------------------------------------------------------------- +return XUiUnionKillMember \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenUnionKill/XUiUnionKillRank.lua b/Resources/Scripts/XUi/XUiFubenUnionKill/XUiUnionKillRank.lua new file mode 100644 index 00000000..0e65beff --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenUnionKill/XUiUnionKillRank.lua @@ -0,0 +1,64 @@ +local XUiUnionKillRank = XLuaUiManager.Register(XLuaUi, "UiUnionKillRank") +local XUiPanelUnionKillMainRank = require("XUi/XUiFubenUnionKill/XUiPanelUnionKillMainRank") +local XUiPanelUnionKillRankReward = require("XUi/XUiFubenUnionKill/XUiPanelUnionKillRankReward") + +function XUiUnionKillRank:OnAwake() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, + XDataCenter.ItemManager.ItemId.FreeGem, + XDataCenter.ItemManager.ItemId.ActionPoint, + XDataCenter.ItemManager.ItemId.Coin) + self.BtnBack.CallBack = function() + self:OnBtnBackClick() + end + self.BtnMainUi.CallBack = function() + self:OnBtnMainUiClick() + end + self.BtnHelp.CallBack = function() + self:OnBtnHelpClick() + end + self:BindHelpBtnOnly(self.BtnHelp) + + local root = self.UiModelGo.transform + self.PanelRoleModel = root:FindTransform("PanelRoleModel") + self.ImgEffectHuanren = root:FindTransform("ImgEffectHuanren") + + self.MainRankInfo = XUiPanelUnionKillMainRank.New(self.PanelBossRankInfo, self) + self.RankReward = XUiPanelUnionKillRankReward.New(self.PanelRankReward, self) +end + +function XUiUnionKillRank:OnDestroy() + self.MainRankInfo:EndSectionCounter() +end + +function XUiUnionKillRank:OnStart(rankType) + self.RankType = rankType + + self.MainRankInfo:Refresh(rankType) +end + +function XUiUnionKillRank:OpenRankReward(rankSelectLevel) + if self.RankType == XFubenUnionKillConfigs.UnionRankType.KillNumber then + self:PlayAnimation("RankRewardEnable", function() + XLuaUiManager.SetMask(false) + end, function() + XLuaUiManager.SetMask(true) + end) + self.RankReward:Refresh(rankSelectLevel) + end +end + +function XUiUnionKillRank:OnBtnHelpClick() + if self.RankType == XFubenUnionKillConfigs.UnionRankType.KillNumber then + XUiManager.ShowHelpTip("UnionKillRankHelp") + else + XUiManager.ShowHelpTip("UnionPraiseRankHelp") + end +end + +function XUiUnionKillRank:OnBtnBackClick() + self:Close() +end + +function XUiUnionKillRank:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenUnionKill/XUiUnionKillRoom.lua b/Resources/Scripts/XUi/XUiFubenUnionKill/XUiUnionKillRoom.lua new file mode 100644 index 00000000..5478f63b --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenUnionKill/XUiUnionKillRoom.lua @@ -0,0 +1,489 @@ +local XUiUnionKillRoom = XLuaUiManager.Register(XLuaUi, "UiUnionKillRoom") +local XUiUnionKillMember = require("XUi/XUiFubenUnionKill/XUiUnionKillMember") +local MAX_CHAT_WIDTH = 450 +local CHAT_SUB_LENGTH = 18 + +function XUiUnionKillRoom:OnAwake() + + self.BtnBack.CallBack = function() + self:OnBtnBackClick() + end + self.BtnMainUi.CallBack = function() + self:OnBtnMainUiClick() + end + self:InitMembers() + + self.BtnChat.CallBack = function() self:OnBtnChatClick() end + self.BtnAutoMatch.CallBack = function(args) self:OnBtnAutoMatchClick(args) end + self.BtnWaiting.CallBack = function() self:OnBtnWaitingClick() end + self.BtnTongBlack.CallBack = function() self:OnBtnTongBlackClick() end + self.BtnReady.CallBack = function() self:OnBtnReadyClick() end + self.BtnCancelReady.CallBack = function() self:OnBtnCancelReadyClick() end + + XEventManager.AddEventListener(XEventId.EVENT_CHAT_RECEIVE_ROOM_MSG, self.OnReceRoomMsg, self) + + -- 组队同步信息 + XEventManager.AddEventListener(XEventId.EVENT_CHARACTER_SUPPORT, self.OnChangeMyShareRole, self) + XEventManager.AddEventListener(XEventId.EVENT_UNIONKILLROOM_LEADER_CHANGED, self.OnTeamLeaderChanged, self) + XEventManager.AddEventListener(XEventId.EVENT_UNIONKILLROOM_PLAYERSTATE_CHANGED, self.OnPlayerStageChanged, self) + XEventManager.AddEventListener(XEventId.EVENT_UNIONKILLROOM_FIGHTNPC_CHANGED, self.OnFightNpcChanged, self) + XEventManager.AddEventListener(XEventId.EVENT_UNIONKILLROOM_PLAYERENTER, self.OnPlayerEnter, self) + XEventManager.AddEventListener(XEventId.EVENT_UNIONKILLROOM_PLAYERLEAVE, self.OnPlayerLeave, self) + + -- 关卡同步信息 + XEventManager.AddEventListener(XEventId.EVENT_UNIONKILL_ROOMDATANOTIFY, self.OnStageRoomDataNotify, self) + XEventManager.AddEventListener(XEventId.EVENT_UNIONKILLROOM_KICKOUT, self.OnPlayerKickOut, self) + XEventManager.AddEventListener(XEventId.EVENT_UNIONKILLROOM_AUTOMATCHCHANGE, self.OnAutuMatchChanged, self) + XEventManager.AddEventListener(XEventId.EVENT_UNIONKILL_ACTIVITYINFO, self.OnWeatherChanged, self) + + + self.TxtMessageContent.text = "" +end + +function XUiUnionKillRoom:OnDestroy() + for i = 1, XFubenUnionKillConfigs.MaxTeamCount do + if self.Members[i] then + self.Members[i]:ClearUnuseTImer() + end + end + + self:EndAllReadyCountDown() + XDataCenter.ChatManager.ResetRoomChat() + + XEventManager.RemoveEventListener(XEventId.EVENT_CHAT_RECEIVE_ROOM_MSG, self.OnReceRoomMsg, self) + + XEventManager.RemoveEventListener(XEventId.EVENT_CHARACTER_SUPPORT, self.OnChangeMyShareRole, self) + XEventManager.RemoveEventListener(XEventId.EVENT_UNIONKILLROOM_LEADER_CHANGED, self.OnTeamLeaderChanged, self) + XEventManager.RemoveEventListener(XEventId.EVENT_UNIONKILLROOM_PLAYERSTATE_CHANGED, self.OnPlayerStageChanged, self) + XEventManager.RemoveEventListener(XEventId.EVENT_UNIONKILLROOM_FIGHTNPC_CHANGED, self.OnFightNpcChanged, self) + XEventManager.RemoveEventListener(XEventId.EVENT_UNIONKILLROOM_PLAYERENTER, self.OnPlayerEnter, self) + XEventManager.RemoveEventListener(XEventId.EVENT_UNIONKILLROOM_PLAYERLEAVE, self.OnPlayerLeave, self) + + XEventManager.RemoveEventListener(XEventId.EVENT_UNIONKILL_ROOMDATANOTIFY, self.OnStageRoomDataNotify, self) + XEventManager.RemoveEventListener(XEventId.EVENT_UNIONKILLROOM_KICKOUT, self.OnPlayerKickOut, self) + XEventManager.RemoveEventListener(XEventId.EVENT_UNIONKILLROOM_AUTOMATCHCHANGE, self.OnAutuMatchChanged, self) + XEventManager.RemoveEventListener(XEventId.EVENT_UNIONKILL_ACTIVITYINFO, self.OnWeatherChanged, self) +end + +function XUiUnionKillRoom:InitMembers() + self.Members = {} + for i = 1, XFubenUnionKillConfigs.MaxTeamCount do + if not self.Members[i] then + local ui = CS.UnityEngine.Object.Instantiate(self.InforGroup.gameObject) + ui.transform:SetParent(self.Content, false) + self.Members[i] = XUiUnionKillMember.New(ui, self, i) + end + self.Members[i].GameObject:SetActiveEx(true) + self.Members[i]:InitNonePlayerView() + end +end + +function XUiUnionKillRoom:OnInviteClick(index) + for i = 1, XFubenUnionKillConfigs.MaxTeamCount do + if self.Members[i] then + self.Members[i]:ChangeInviteView(index == i) + end + end +end + +function XUiUnionKillRoom:OnOperateClick(index) + for i = 1, XFubenUnionKillConfigs.MaxTeamCount do + if self.Members[i] then + self.Members[i]:ChangeOperationView(index == i) + end + end +end + +function XUiUnionKillRoom:OnStart() + self.RoomData = XDataCenter.FubenUnionKillRoomManager.GetUnionRoomData() + if not self.RoomData then return end + self:OnPlayerChanged() + self:OnChangeQuickMatch() + + self.UnionKillInfo = XDataCenter.FubenUnionKillManager.GetUnionKillInfo() + if not self.UnionKillInfo or not self.UnionKillInfo.CurSectionId then return end + self.SectionTemplate = XFubenUnionKillConfigs.GetUnionSectionById(self.UnionKillInfo.CurSectionId) + self.SectionConfig = XFubenUnionKillConfigs.GetUnionSectionConfigById(self.UnionKillInfo.CurSectionId) + self.WeatherConfig = XFubenUnionKillConfigs.GetUnionWeatherConfigById(self.UnionKillInfo.WeatherId) + + local activityConfig = XFubenUnionKillConfigs.GetUnionActivityConfigById(self.UnionKillInfo.Id) + self.TxtTitle.text = activityConfig.Name + self.TxtEnvBuff.text = CS.XTextManager.GetText("UnionRoomEnvTitle", self.WeatherConfig.Name) + +end + +function XUiUnionKillRoom:OnEnable() + if not self.RoomData then return end + local playerData = self.RoomData.PlayerDataList[XPlayer.Id] + if not playerData then return end + if XFubenUnionKillConfigs.UnionRoomPlayerState.Select == playerData.State then + XDataCenter.FubenUnionKillRoomManager.ChangePlayerState(XFubenUnionKillConfigs.UnionRoomPlayerState.Normal, function() + playerData.State = XFubenUnionKillConfigs.UnionRoomPlayerState.Normal + self:OnAllPlayerChanged() + self:UpdateBottomButtons() + end) + else + self:OnAllPlayerChanged() + self:UpdateBottomButtons() + end +end + +function XUiUnionKillRoom:UpdateBottomButtons() + local isLeader = XDataCenter.FubenUnionKillRoomManager.IsLeader(XPlayer.Id) + + local isAllReady = XDataCenter.FubenUnionKillRoomManager.IsAllMemberReady() + if isLeader then + self.BtnReady.gameObject:SetActiveEx(not isLeader) + self.BtnCancelReady.gameObject:SetActiveEx(not isLeader) + self.BtnWaiting.gameObject:SetActiveEx(not isAllReady) + self.BtnTongBlack.gameObject:SetActiveEx(isAllReady) + + else + self.BtnWaiting.gameObject:SetActiveEx(isLeader) + self.BtnTongBlack.gameObject:SetActiveEx(isLeader) + + local player_state = XDataCenter.FubenUnionKillRoomManager.GetPlayerState(XPlayer.Id) + self.BtnReady.gameObject:SetActiveEx(player_state ~= XFubenUnionKillConfigs.UnionRoomPlayerState.Ready) + self.BtnCancelReady.gameObject:SetActiveEx(player_state == XFubenUnionKillConfigs.UnionRoomPlayerState.Ready) + end +end + +function XUiUnionKillRoom:UpdateBtnsStatus(playerId, playerLastState) + self:UpdateBottomButtons() + + -- local isLeader = XDataCenter.FubenUnionKillRoomManager.IsLeader(XPlayer.Id) + local isAllReady = XDataCenter.FubenUnionKillRoomManager.IsAllMemberReady() + -- 开启队长死亡倒计时 + if not self.RoomData then return end + local teammateCount = 0 + local leaderIsSelecting = false + for id, playerData in pairs(self.RoomData.PlayerDataList or {}) do + if id ~= XPlayer.Id then + teammateCount = teammateCount + 1 + end + if playerData.Leader and playerId and playerData.Id == playerId then + leaderIsSelecting = true + if playerLastState and playerLastState == XFubenUnionKillConfigs.UnionRoomPlayerState.Fight then + leaderIsSelecting = false + end + end + end + + -- 队伍中不止队长一人 + if not leaderIsSelecting then + if isAllReady and teammateCount == 3 then + self:StartAllReadyCountDown() + else + self:EndAllReadyCountDown() + end + end +end + +function XUiUnionKillRoom:OnPlayerChanged() + self:InitPlayerList() + self:SetTeammates() + self:UpdateBtnsStatus() +end + +function XUiUnionKillRoom:InitPlayerList() + self.PlayerList = {} + for id, _ in pairs(self.RoomData.PlayerDataList or {}) do + if id == XPlayer.Id then + table.insert(self.PlayerList, 1, { + PlayerId = id + }) + else + table.insert(self.PlayerList, { + PlayerId = id + }) + end + end +end + +function XUiUnionKillRoom:SetTeammates() + for i = 1, XFubenUnionKillConfigs.MaxTeamCount do + if self.PlayerList[i] then + local memberId = self.PlayerList[i].PlayerId + self.Members[i]:InitPlayerView(self.RoomData.PlayerDataList[memberId]) + else + self.Members[i]:InitNonePlayerView() + end + end +end + +function XUiUnionKillRoom:OnReceRoomMsg(chatData) + -- 弹tips + if chatData.MsgType == ChatMsgType.Normal then + for i = 1, XFubenUnionKillConfigs.MaxTeamCount do + if self.Members[i] then + self.Members[i]:ProcessTipTalk(chatData.SenderId, chatData.Content) + end + end + elseif chatData.MsgType == ChatMsgType.Emoji then + for i = 1, XFubenUnionKillConfigs.MaxTeamCount do + if self.Members[i] then + self.Members[i]:ProcessTipEmoji(chatData.SenderId, tonumber(chatData.Content)) + end + end + end + -- 显示当前说的话 + self:RefreshChatMsg(chatData) +end + +function XUiUnionKillRoom:RefreshChatMsg(chatDataLua) + local senderName = XDataCenter.SocialManager.GetPlayerRemark(chatDataLua.SenderId, chatDataLua.NickName) + if chatDataLua.MsgType == ChatMsgType.Emoji then + self.TxtMessageContent.text = string.format("%s:%s", senderName, CS.XTextManager.GetText("EmojiText")) + else + self.TxtMessageContent.text = string.format("%s:%s", senderName, chatDataLua.Content) + end + + if not string.IsNilOrEmpty(chatDataLua.CustomContent) then + self.TxtMessageContent.supportRichText = true + else + self.TxtMessageContent.supportRichText = false + end + + if XUiHelper.CalcTextWidth(self.TxtMessageContent) > MAX_CHAT_WIDTH then + self.TxtMessageContent.text = string.Utf8Sub(self.TxtMessageContent.text, 1, CHAT_SUB_LENGTH) .. [[......]] + end +end + +-- 切换角色 +function XUiUnionKillRoom:OnChangeMyShareRole(characterId) + -- 只更新我的,我的界面只有我自己能更改 + XDataCenter.FubenUnionKillRoomManager.SelectUnionRole(characterId, function() + if not self.RoomData then return end + local playerData = self.RoomData.PlayerDataList[XPlayer.Id] + for i = 1, XFubenUnionKillConfigs.MaxTeamCount do + if self.Members[i] then + self.Members[i]:UpdateShareCharacterById(XPlayer.Id, playerData.FightNpcData) + end + end + end) +end + +-- 快速匹配变化 +function XUiUnionKillRoom:OnChangeQuickMatch() + if not self.RoomData then return end + self.BtnAutoMatch.ButtonState = self.RoomData.AutoMatch and CS.UiButtonState.Select or CS.UiButtonState.Normal +end + +-- 队长变化 +function XUiUnionKillRoom:OnTeamLeaderChanged() + if not self.RoomData then return end + + for i = 1, XFubenUnionKillConfigs.MaxTeamCount do + if self.PlayerList[i] then + local memberId = self.PlayerList[i].PlayerId + local playerData = self.RoomData.PlayerDataList[memberId] + + self.Members[i]:SetLeaderFlag(playerData.Leader) + else + self.Members[i]:SetLeaderFlag(false) + end + end + + self:OnAllPlayerChanged() + self:UpdateBtnsStatus() +end + +-- 玩家状态改变 +function XUiUnionKillRoom:OnPlayerStageChanged(playerId, playerLastState) + if not self.RoomData then return end + for i = 1, XFubenUnionKillConfigs.MaxTeamCount do + if self.PlayerList[i] then + local memberId = self.PlayerList[i].PlayerId + if playerId == memberId then + self.Members[i]:UpdatePlayerState() + end + end + end + self:UpdateBtnsStatus(playerId, playerLastState) +end + +function XUiUnionKillRoom:OnAllPlayerChanged() + if not self.RoomData then return end + for i = 1, XFubenUnionKillConfigs.MaxTeamCount do + if self.PlayerList[i] then + self.Members[i]:UpdatePlayerState() + end + end +end + +-- 出战角色改变 +function XUiUnionKillRoom:OnFightNpcChanged(playerId) + if not self.RoomData then return end + for i = 1, XFubenUnionKillConfigs.MaxTeamCount do + if self.PlayerList[i] then + local memberId = self.PlayerList[i].PlayerId + if playerId == memberId then + local playerData = self.RoomData.PlayerDataList[memberId] + self.Members[i]:UpdateShareCharacterById(playerId, playerData.FightNpcData) + end + end + end +end + +-- 其他玩家进入 +function XUiUnionKillRoom:OnPlayerEnter() + self:OnPlayerChanged() +end + +-- 其他玩家离开 +function XUiUnionKillRoom:OnPlayerLeave() + self:OnPlayerChanged() + + self:OnTeamLeaderChanged() +end + +-- 收到了关卡房间信息 +function XUiUnionKillRoom:OnStageRoomDataNotify() + XLuaUiManager.Open("UiUnionKillStage") +end + +-- 踢出 +function XUiUnionKillRoom:OnPlayerKickOut() + XLuaUiManager.Remove("UiDialog") + XLuaUiManager.Remove("UiReport") + XLuaUiManager.Remove("UiCharacter") + XLuaUiManager.Remove("UiPlayerInfo") + XLuaUiManager.Remove("UiPurchase") + XLuaUiManager.Remove("UiChatServeMain") + XLuaUiManager.Remove("UiMultiplayerInviteFriend") + + if XUiManager.CheckTopUi(CsXUiType.Normal, "UiUnionKillRoom") then + self:Close() + else + self:Remove() + end + +end + +function XUiUnionKillRoom:OnBtnTongBlackClick() + -- 开始作战 + XDataCenter.FubenUnionKillRoomManager.EnterUnionRoomFihgt(function() + end) +end + +function XUiUnionKillRoom:OnBtnWaitingClick() +end + +function XUiUnionKillRoom:OnBtnCancelReadyClick() + local playerData = self.RoomData.PlayerDataList[XPlayer.Id] + if not playerData then return end + if XFubenUnionKillConfigs.UnionRoomPlayerState.Ready == playerData.State then + XDataCenter.FubenUnionKillRoomManager.ChangePlayerState(XFubenUnionKillConfigs.UnionRoomPlayerState.Normal, function() + playerData.State = XFubenUnionKillConfigs.UnionRoomPlayerState.Normal + self:OnPlayerStageChanged(XPlayer.Id) + end) + end +end + +function XUiUnionKillRoom:OnBtnReadyClick() + local playerData = self.RoomData.PlayerDataList[XPlayer.Id] + if not playerData then return end + + if XFubenUnionKillConfigs.UnionRoomPlayerState.Normal == playerData.State then + XDataCenter.FubenUnionKillRoomManager.ChangePlayerState(XFubenUnionKillConfigs.UnionRoomPlayerState.Ready, function() + playerData.State = XFubenUnionKillConfigs.UnionRoomPlayerState.Ready + self:OnPlayerStageChanged(XPlayer.Id) + end) + end +end + + +function XUiUnionKillRoom:OnBtnAutoMatchClick() + if not XDataCenter.FubenUnionKillRoomManager.IsLeader(XPlayer.Id) then + if not self.RoomData then + self.BtnAutoMatch.ButtonState = CS.UiButtonState.Normal + else + self.BtnAutoMatch.ButtonState = self.RoomData.AutoMatch and CS.UiButtonState.Select or CS.UiButtonState.Normal + end + XUiManager.TipMsg(CS.XTextManager.GetText("MultiplayerRoomCanNotChangeAutoMatch")) + return + end + if self.RoomData then + XDataCenter.FubenUnionKillRoomManager.SetUnionQuickMatch(not self.RoomData.AutoMatch) + end +end + +function XUiUnionKillRoom:OnAutuMatchChanged() + self.BtnAutoMatch.ButtonState = self.RoomData.AutoMatch and CS.UiButtonState.Select or CS.UiButtonState.Normal +end + +function XUiUnionKillRoom:OnWeatherChanged() + self.UnionKillInfo = XDataCenter.FubenUnionKillManager.GetUnionKillInfo() + if not self.UnionKillInfo then return end + self.WeatherConfig = XFubenUnionKillConfigs.GetUnionWeatherConfigById(self.UnionKillInfo.WeatherId) + self.TxtEnvBuff.text = CS.XTextManager.GetText("UnionRoomEnvTitle", self.WeatherConfig.Name) +end + +function XUiUnionKillRoom:OnBtnChatClick() + XLuaUiManager.Open("UiChatServeMain", false, ChatChannelType.Room, ChatChannelType.World) +end + +function XUiUnionKillRoom:OnBtnBackClick() + local title = CS.XTextManager.GetText("UnionRoomDialogTitle") + local content = CS.XTextManager.GetText("UnionKillExitRoom") + + XUiManager.DialogTip(title, content, XUiManager.DialogType.Normal, function() + end, function() + -- 发送通知 + XDataCenter.FubenUnionKillRoomManager.LeaveUnionTeamRoom(function() + self:Close() + end) + end) + +end + +function XUiUnionKillRoom:OnBtnMainUiClick() + XLuaUiManager.RunMain() + -- local title = CS.XTextManager.GetText("UnionRoomDialogTitle") + -- local content = CS.XTextManager.GetText("UnionRoomExitRoom") + -- XUiManager.DialogTip(title, content, XUiManager.DialogType.Normal, function() + -- end, function() + -- -- 发送通知 + -- XDataCenter.FubenUnionKillRoomManager.LeaveUnionTeamRoom(function() + -- end) + -- end) +end + +-- 全部准备倒计时 +function XUiUnionKillRoom:StartAllReadyCountDown() + self:EndAllReadyCountDown() + + local now = XTime.GetServerNowTimestamp() + self.AllReadyEndTime = now + XFubenUnionKillConfigs.AllReadyCount + for i = 1, XFubenUnionKillConfigs.MaxTeamCount do + if self.Members[i] then + self.Members[i]:UpdateAllReadyCountDown(self.AllReadyEndTime - now) + end + end + + self.AllReadyTimer = XScheduleManager.ScheduleForever(function() + now = XTime.GetServerNowTimestamp() + if now > self.AllReadyEndTime then + self:EndAllReadyCountDown() + return + end + + for i = 1, XFubenUnionKillConfigs.MaxTeamCount do + if self.Members[i] then + self.Members[i]:UpdateAllReadyCountDown(self.AllReadyEndTime - now) + end + end + end, XScheduleManager.SECOND, 0) +end + +function XUiUnionKillRoom:EndAllReadyCountDown() + if self.AllReadyTimer ~= nil then + XScheduleManager.UnSchedule(self.AllReadyTimer) + self.AllReadyTimer = nil + end + for i = 1, XFubenUnionKillConfigs.MaxTeamCount do + if self.Members[i] then + self.Members[i]:HideAllReadyCountDown() + end + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenUnionKill/XUiUnionKillSelectRole.lua b/Resources/Scripts/XUi/XUiFubenUnionKill/XUiUnionKillSelectRole.lua new file mode 100644 index 00000000..5ec7bd96 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenUnionKill/XUiUnionKillSelectRole.lua @@ -0,0 +1,255 @@ +local XUiUnionKillSelectRole = XLuaUiManager.Register(XLuaUi, "UiUnionKillXuanRen") +local XUiGridUnionCharacterItem = require("XUi/XUiFubenUnionKill/XUiGridUnionCharacterItem") + +function XUiUnionKillSelectRole:OnAwake() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, + XDataCenter.ItemManager.ItemId.FreeGem, + XDataCenter.ItemManager.ItemId.ActionPoint, + XDataCenter.ItemManager.ItemId.Coin) + self.BtnBack.CallBack = function() + self:OnBtnBackClick() + end + self.BtnMainUi.CallBack = function() + self:OnBtnMainUiClick() + end + + self.BtnFashion.CallBack = function() self:OnBtnFashionClick() end + self.BtnConsciousness.CallBack = function() self:OnBtnConsciousnessClick() end + self.BtnWeapon.CallBack = function() self:OnBtnWeaponClick() end + self.BtnJoinTeam.CallBack = function() self:OnBtnJoinTeamClick() end + self.BtnQuitTeam.CallBack = function() self:OnBtnQuitTeamClick() end + + local root = self.UiModelGo.transform + self.PanelRoleModel = root:FindTransform("PanelRoleModel") + self.ImgEffectHuanren = root:FindTransform("ImgEffectHuanren") + + self.CharacterItemList = {} +end + +function XUiUnionKillSelectRole:OnDestroy() +end + + +function XUiUnionKillSelectRole:OnStart(args) + self.RoleModelPanel = XUiPanelRoleModel.New(self.PanelRoleModel, nil, nil, true) + self.StageId = args.StageId + self.Index = args.Index + self.DefaultSelectId = args.DefaultSelectId + self.DefaultSelectOwner = args.DefaultSelectOwner + self.InTeamList = args.InTeamList + self.CharacterInTeamList = args.CharacterInTeamList + self.CallBack = args.CallBack + + self.SelectableList = args.CharacterList + table.sort(self.SelectableList, function(char1, char2) + local flagWeight1 = char1.Flag == XFubenUnionKillConfigs.UnionKillCharType.Share and 1 or 0 + local flagWeight2 = char2.Flag == XFubenUnionKillConfigs.UnionKillCharType.Share and 1 or 0 + if flagWeight1 == flagWeight2 then + return char1.Ability > char2.Ability + end + return flagWeight1 > flagWeight2 + end) + + self:SelectCharacterList() +end + +function XUiUnionKillSelectRole:OnEnable() + if self.SelectableList then + for i = 1, #self.SelectableList do + local characterItem = self.SelectableList[i] + self.CharacterItemList[i]:UpdateGrid(characterItem) + end + if self.CurCharacter then + local fashionId + if self.CurCharacter.Flag == XFubenUnionKillConfigs.UnionKillCharType.Share then + local shareNpcData = self.CurCharacter.OwnerInfo.ShareNpcData + if shareNpcData then + fashionId = shareNpcData.Character.FashionId + end + else + local characterInfo = XDataCenter.CharacterManager.GetCharacter(self.CurCharacter.Id) + fashionId = characterInfo.FashionId + end + self:UpdateRoleModel(self.CurCharacter, fashionId) + end + end +end + +function XUiUnionKillSelectRole:SelectCharacterList() + -- local defaultCharacterId = self.SelectableList[1] and self.SelectableList[1].Id + local defaultIndex = 1 + for i = 1, #self.SelectableList do + local characterItem = self.SelectableList[i] + if self.DefaultSelectId and characterItem.Id == self.DefaultSelectId then + if self.DefaultSelectOwner and self.DefaultSelectOwner == characterItem.OwnerId then + --defaultCharacterId = self.DefaultSelectId + defaultIndex = i + end + end + + if not self.CharacterItemList[i] then + local item = CS.UnityEngine.Object.Instantiate(self.GridMainLineCharacter) + local grid = XUiGridUnionCharacterItem.New(self, item, characterItem, function(character) + self:OnCharacterClick(character, i) + end) + grid.GameObject:SetActiveEx(true) + grid.Transform:SetParent(self.PanelRoleContent, false) + self.CharacterItemList[i] = grid + end + + self.CharacterItemList[i]:UpdateGrid(characterItem) + local key = string.format("%s_%s", tostring(characterItem.OwnerId), tostring(characterItem.Id)) + self.CharacterItemList[i]:SetInTeam(self.InTeamList[key]) + self.CharacterItemList[i]:SetHasSameCard(not self.InTeamList[key] and self.CharacterInTeamList[tostring(characterItem.Id)]) + end + for i = #self.SelectableList + 1, #self.CharacterItemList do + self.CharacterItemList[i].GameObject:SetActiveEx(false) + end + + if defaultIndex > 0 then + self:SetlectCharacter(defaultIndex) + end +end + +function XUiUnionKillSelectRole:OnCharacterClick(character, index) + if self.CurCharacter and self.CurCharacter == character then + return + end + if character then + self.CurCharacter = character + end + if self.CurCharacterItem then + self.CurCharacterItem:SetSelect(false) + end + + -- local characterId = character.Id + local fashionId + if character.Flag == XFubenUnionKillConfigs.UnionKillCharType.Share then + local shareNpcData = self.CurCharacter.OwnerInfo.ShareNpcData + if shareNpcData then + fashionId = shareNpcData.Character.FashionId + end + else + local characterInfo = XDataCenter.CharacterManager.GetCharacter(self.CurCharacter.Id) + fashionId = characterInfo.FashionId + end + self.CurCharacterItem = self.CharacterItemList[index] + self.CurCharacterItem:UpdateGrid(self.CurCharacter) + self.CurCharacterItem:SetSelect(true) + local key = string.format("%s_%s", tostring(self.CurCharacter.OwnerId), tostring(self.CurCharacter.Id)) + self.CurCharacterItem:SetInTeam(self.InTeamList[key]) + self.CurCharacterItem:SetHasSameCard(not self.InTeamList[key] and self.CharacterInTeamList[tostring(self.CurCharacter.Id)]) + + -- 更新按钮状态 + self:UpdateFunctionalBtns(self.CurCharacter) + -- 更新角色模型 + self:UpdateRoleModel(self.CurCharacter, fashionId) +end + +-- 更新按钮状态 +function XUiUnionKillSelectRole:UpdateFunctionalBtns(characterItem) + + self.BtnFashion.gameObject:SetActiveEx(characterItem.Flag == XFubenUnionKillConfigs.UnionKillCharType.Own) + self.BtnConsciousness.gameObject:SetActiveEx(characterItem.Flag == XFubenUnionKillConfigs.UnionKillCharType.Own) + self.BtnWeapon.gameObject:SetActiveEx(characterItem.Flag == XFubenUnionKillConfigs.UnionKillCharType.Own) + + local teamCache = XDataCenter.FubenUnionKillManager.GetCacheTeam() + local isJoin = false + for k, v in pairs(teamCache or {}) do + if k == self.Index and v.PlayerId == characterItem.OwnerId and v.CharacterId == characterItem.Id then + isJoin = true + break + end + end + + self.BtnJoinTeam.gameObject:SetActiveEx(not isJoin) + self.BtnQuitTeam.gameObject:SetActiveEx(isJoin) +end + +-- 更换模型 +function XUiUnionKillSelectRole:UpdateRoleModel(character, fashionId) + self.RoleModelPanel:UpdateCharacterModel(character.Id, self.PanelRoleModel, XModelManager.MODEL_UINAME.XUiUnionKillSelectRole, function(model) + self.ImgEffectHuanren.gameObject:SetActiveEx(false) + self.ImgEffectHuanren.gameObject:SetActiveEx(true) + if not model then return end + self.PanelDrag.Target = model.transform + + if character.Flag == XFubenUnionKillConfigs.UnionKillCharType.Share then + self.RoleModelPanel:UpdateEquipsModelsByFightNpcData(model, character.OwnerInfo.ShareNpcData) + end + end, nil, fashionId) +end + +function XUiUnionKillSelectRole:SetlectCharacter(index) + local grid = self.CharacterItemList[index] + if grid then + self:Adjust2Center(grid) + end + + local characterItem = self.SelectableList[index] + self:OnCharacterClick(characterItem, index) +end + +function XUiUnionKillSelectRole:OnBtnBackClick() + if self.CallBack then + self.CallBack(nil, false) + end + self:Close() +end + +function XUiUnionKillSelectRole:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiUnionKillSelectRole:OnBtnFashionClick() + -- 共享角色返回 + if not self.CurCharacter then return end + XLuaUiManager.Open("UiFashion", self.CurCharacter.Id) +end + +function XUiUnionKillSelectRole:OnBtnConsciousnessClick() + -- 共享角色返回 + if not self.CurCharacter then return end + XLuaUiManager.Open("UiEquipAwarenessReplace", self.CurCharacter.Id, nil, true) +end + +function XUiUnionKillSelectRole:OnBtnWeaponClick() + -- 共享角色返回 + if not self.CurCharacter then return end + XLuaUiManager.Open("UiEquipReplaceNew", self.CurCharacter.Id, nil, true) +end + +function XUiUnionKillSelectRole:OnBtnJoinTeamClick() + if not self.CurCharacter then return end + -- 出现选中的角色已经存在队伍中 + local key = string.format("%s_%s", tostring(self.CurCharacter.OwnerId), tostring(self.CurCharacter.Id)) + if not self.InTeamList[key] and self.CharacterInTeamList[tostring(self.CurCharacter.Id)] then + XUiManager.TipMsg(CS.XTextManager.GetText("UnionSelectSameRole")) + return + end + + if self.CallBack then + self.CallBack(self.CurCharacter, true) + end + self:Close() +end + +function XUiUnionKillSelectRole:OnBtnQuitTeamClick() + if not self.CurCharacter then return end + if self.CallBack then + self.CallBack(self.CurCharacter, false) + end + self:Close() +end + +function XUiUnionKillSelectRole:Adjust2Center(grid) + local normalizedPosition + local count = self.SViewCharacterList.content.transform.childCount + local index = grid.Transform:GetSiblingIndex() + if index > count / 2 then + normalizedPosition = (index + 1) / count + else + normalizedPosition = (index - 1) / count + end + self.SViewCharacterList.verticalNormalizedPosition = math.max(0, math.min(1, (1 - normalizedPosition))) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenUnionKill/XUiUnionKillStage.lua b/Resources/Scripts/XUi/XUiFubenUnionKill/XUiUnionKillStage.lua new file mode 100644 index 00000000..422d0176 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenUnionKill/XUiUnionKillStage.lua @@ -0,0 +1,605 @@ +local XUiUnionKillStage = XLuaUiManager.Register(XLuaUi, "UiUnionKillStage") +local XUiGridUnionStageMember = require("XUi/XUiFubenUnionKill/XUiGridUnionStageMember") +local XUiPanelUnionBuffDetails = require("XUi/XUiFubenUnionKill/XUiPanelUnionBuffDetails") +local XUiPanelUnionDamageDetails = require("XUi/XUiFubenUnionKill/XUiPanelUnionDamageDetails") +local XUiPanelUnionSectionEnd = require("XUi/XUiFubenUnionKill/XUiPanelUnionSectionEnd") +local XUiGridUnionEventStageItem = require("XUi/XUiFubenUnionKill/XUiGridUnionEventStageItem") + +local MAX_CHAT_WIDTH = 470 +local CHAT_SUB_LENGTH = 18 +local WARN_LAST_SEC = 10 + +function XUiUnionKillStage:OnAwake() + self:BindHelpBtn(self.BtnHelp, "UnionKillStageHelp") + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + self.BtnBuff.CallBack = function() self:OnBtnBuffClick() end + self.BtnChat.CallBack = function() self:OnBtnChatClick() end + self.BtnBossLcok.CallBack = function() self:OnBtnBossClick() end + self.BtnTcanchaungBlack.CallBack = function() self:OnBtnDamageDetailClick() end + self.BtnNotShowToday.CallBack = function() self:OnBtnNotShowTodayClick() end + + self.TxtMessageContent.text = "" + self.StageTeamMembers = {} + + self.EventStages = {} + self.IsNotifying = false + + self.BuffDetails = XUiPanelUnionBuffDetails.New(self.PanelTanchuangBuff, self) + self.DamageDetails = XUiPanelUnionDamageDetails.New(self.PanelTanchuangTongJi, self) + self.SectionEnd = XUiPanelUnionSectionEnd.New(self.PanelTanChuangEnd, self) + + XEventManager.AddEventListener(XEventId.EVENT_CHAT_RECEIVE_ROOM_MSG, self.RefreshRoomChatMsg, self) + XEventManager.AddEventListener(XEventId.EVENT_UNIONKILL_BOSSHPCHANGE, self.OnBossHpChanged, self) + XEventManager.AddEventListener(XEventId.EVENT_UNIONKILL_PLAYERINFOCHANGE, self.OnPlayerInfoChanged, self) + XEventManager.AddEventListener(XEventId.EVENT_UNIONKILL_STAGEINFOCHANGE, self.OnSectionInfoChanged, self) + XEventManager.AddEventListener(XEventId.EVENT_UNIONKILL_LEAVEROOM, self.OnPlayerLeaveRoom, self) + XEventManager.AddEventListener(XEventId.EVENT_UNIONKILL_FIGHTSTATUS, self.OnPlayerFightStatusChanged, self) +end + +function XUiUnionKillStage:OnDestroy() + for i = 1, XFubenUnionKillConfigs.MaxTeamCount do + if self.StageTeamMembers[i] then + self.StageTeamMembers[i]:ClearUnuseTimer() + end + end + if self.TempItemResource then + self.TempItemResource:Release() + end + self:StopRoomCountDown() + self:EndProcessTipMessage() + + XEventManager.RemoveEventListener(XEventId.EVENT_CHAT_RECEIVE_ROOM_MSG, self.RefreshRoomChatMsg, self) + XEventManager.RemoveEventListener(XEventId.EVENT_UNIONKILL_BOSSHPCHANGE, self.OnBossHpChanged, self) + XEventManager.RemoveEventListener(XEventId.EVENT_UNIONKILL_PLAYERINFOCHANGE, self.OnPlayerInfoChanged, self) + XEventManager.RemoveEventListener(XEventId.EVENT_UNIONKILL_STAGEINFOCHANGE, self.OnSectionInfoChanged, self) + XEventManager.RemoveEventListener(XEventId.EVENT_UNIONKILL_LEAVEROOM, self.OnPlayerLeaveRoom, self) + XEventManager.RemoveEventListener(XEventId.EVENT_UNIONKILL_FIGHTSTATUS, self.OnPlayerFightStatusChanged, self) +end + +function XUiUnionKillStage:RefreshRoomChatMsg(chatDataLua) + if not chatDataLua then return end + local playerId = chatDataLua.SenderId + XDataCenter.FubenUnionKillManager.Add2TipQueue(true, playerId, chatDataLua) + self:RefreshChatMsg(chatDataLua) +end + +function XUiUnionKillStage:RefreshChatMsg(chatDataLua) + local senderName = XDataCenter.SocialManager.GetPlayerRemark(chatDataLua.SenderId, chatDataLua.NickName) + if chatDataLua.MsgType == ChatMsgType.Emoji then + self.TxtMessageContent.text = string.format("%s:%s", senderName, CS.XTextManager.GetText("EmojiText")) + else + self.TxtMessageContent.text = string.format("%s:%s", senderName, chatDataLua.Content) + end + + if not string.IsNilOrEmpty(chatDataLua.CustomContent) then + self.TxtMessageContent.supportRichText = true + else + self.TxtMessageContent.supportRichText = false + end + + if XUiHelper.CalcTextWidth(self.TxtMessageContent) > MAX_CHAT_WIDTH then + self.TxtMessageContent.text = string.Utf8Sub(self.TxtMessageContent.text, 1, CHAT_SUB_LENGTH) .. [[......]] + end +end + +-- boss血量变化 +function XUiUnionKillStage:OnBossHpChanged() + self:SetBossStageView() + self:CheckTrialOpen(true) +end + +-- 玩家状态变化UpdateByCache +function XUiUnionKillStage:OnPlayerInfoChanged() + self:SetTeamMembers() + self:SetEventStagesView() +end + +-- 章节变化 +function XUiUnionKillStage:OnSectionInfoChanged() + self:SetEventStagesView() +end + +-- 玩家离开房间 +function XUiUnionKillStage:OnPlayerLeaveRoom() + self:CheckStageOver(true) +end + +-- 玩家战斗状态 +function XUiUnionKillStage:OnPlayerFightStatusChanged(playerId, stageId) + for i = 1, #self.StageTeamMembers do + if self.StageTeamMembers[i] then + self.StageTeamMembers[i]:RefreshFightStatus(playerId, stageId) + end + end +end + +function XUiUnionKillStage:OnStart() + self.RoomFightData = XDataCenter.FubenUnionKillManager.GetCurRoomData() + self.UnionKillInfo = XDataCenter.FubenUnionKillManager.GetUnionKillInfo() + + if self.UnionKillInfo == nil then return end + if self.UnionKillInfo.CurSectionId == nil or self.UnionKillInfo.CurSectionId == 0 then return end + self.CurSectionId = self.UnionKillInfo.CurSectionId + self.CurSectionTemplate = XFubenUnionKillConfigs.GetUnionSectionById(self.CurSectionId) + self.CurSectionConfig = XFubenUnionKillConfigs.GetUnionSectionConfigById(self.CurSectionId) + + self:SetTeamMembers() + self:SetEventStagesView() + self:StartRoomCountDown() + self:PlaySaftyAnimation("AnimStartEnable") +end + +function XUiUnionKillStage:OnEnable() + self:CheckTrialOpen(false) + self:CheckStageOver(false) + + if self.EventStages then + for i = 1, #self.EventStages do + self.EventStages[i]:UpdateEffect() + end + end +end + +function XUiUnionKillStage:SetTeamMembers() + if not self.RoomFightData then return end + local playerInfos = {} + for _, playerInfo in pairs(self.RoomFightData.UnionKillPlayerInfos or {}) do + table.insert(playerInfos, playerInfo) + end + table.sort(playerInfos, function(playerInfo1, playerInof2) + return playerInfo1.Position < playerInof2.Position + end) + + local index = 0 + for _, playerInfo in pairs(playerInfos) do + index = index + 1 + + if not self.StageTeamMembers[index] then + local ui = CS.UnityEngine.Object.Instantiate(self.PanelHeadPor) + ui.transform:SetParent(self.TeamItemContent, false) + self.StageTeamMembers[index] = XUiGridUnionStageMember.New(ui) + end + self.StageTeamMembers[index]:Refresh(playerInfo) + end + for i = index + 1, #self.StageTeamMembers do + self.StageTeamMembers[i].GameObject:SetActiveEx(false) + end +end + +-- 设置关卡 +function XUiUnionKillStage:SetEventStagesView() + if not self.CurSectionTemplate then return end + local prefabPath = self.CurSectionConfig.MainPrefabName + local itemPrefabPath = self.CurSectionConfig.ItemPrefabName + self.StagePanel = self.PanelStages:LoadPrefab(prefabPath) + if self.TempItemResource then + self.TempItemResource:Release() + end + self.TempItemResource = CS.XResourceManager.Load(itemPrefabPath) + -- 事件关 + local event_length = #self.CurSectionTemplate.EventStageId + for i = 1, event_length do + local eventStageId = self.CurSectionTemplate.EventStageId[i] + if not self.EventStages[i] then + local parentObj = self.StagePanel.transform:Find(string.format("GuanQia%d", i)) + local tempItemObj = CS.UnityEngine.Object.Instantiate(self.TempItemResource.Asset) + tempItemObj.transform:SetParent(parentObj, false) + self.EventStages[i] = XUiGridUnionEventStageItem.New(tempItemObj) + end + self.EventStages[i]:Refresh(eventStageId, self.CurSectionTemplate) + end + for i = event_length + 1, #self.EventStages do + self.EventStages[i].GameObject:SetActiveEx(false) + end + + -- boss关 + self:SetBossStageView() +end + +-- 设置boss关 +function XUiUnionKillStage:SetBossStageView() + if not self.RoomFightData then return end + if not self.CurSectionTemplate then return end + + local isTrialBoss = self.RoomFightData.BossHpLeft <= 0 + + self.CurSectionId = self.UnionKillInfo.CurSectionId + self.CurSectionTemplate = XFubenUnionKillConfigs.GetUnionSectionById(self.CurSectionId) + self.CurSectionConfig = XFubenUnionKillConfigs.GetUnionSectionConfigById(self.CurSectionId) + + local bossIcon = isTrialBoss and self.CurSectionConfig.TrialIcon or self.CurSectionConfig.BossIcon + self.RImgUnionKillStageBoss:SetRawImage(bossIcon) + + -- 通关限制 + -- 玩家信息 + local isLock = false + local unlockBossLimit = self.CurSectionTemplate.UnlockBossStageLimit + local finishEventCount = 0 + local playerInfos = self.RoomFightData.UnionKillPlayerInfos + if playerInfos and playerInfos[XPlayer.Id] then + local myPlayerInfo = playerInfos[XPlayer.Id] + finishEventCount = #myPlayerInfo.FinishEventStage + isLock = finishEventCount < unlockBossLimit + end + + self.Locked.gameObject:SetActiveEx(isLock) + self.UnLocked.gameObject:SetActiveEx(not isLock) + if self.BossHpGroup then + self.BossHpGroup.gameObject:SetActiveEx(not isTrialBoss) + end + if isLock then + self.TxtNumber.text = string.format("%d/%d", finishEventCount, unlockBossLimit) + self.TxtTask.text = CS.XTextManager.GetText("UnionStageCondition", unlockBossLimit) + else + -- 分boss关、试炼关 + local totalHp = self.CurSectionTemplate.BossTotalHp + local leftHp = self.RoomFightData.BossHpLeft or 0 + local hpPercent = leftHp * 1 / totalHp + self.ImgProgress.fillAmount = hpPercent + self.TxtProgress.text = leftHp + end +end + +function XUiUnionKillStage:OnBtnBackClick() + local title = CS.XTextManager.GetText("UnionRoomDialogTitle") + local content = CS.XTextManager.GetText("UnionRoomExitStage") + + XUiManager.DialogTip(title, content, XUiManager.DialogType.Normal, function() + end, function() + -- 发送通知 + self:LeaveRoomCheckFightState() + end) + +end + +function XUiUnionKillStage:OnBtnMainUiClick() + local title = CS.XTextManager.GetText("UnionRoomDialogTitle") + local content = CS.XTextManager.GetText("UnionRoomExitStage") + + XUiManager.DialogTip(title, content, XUiManager.DialogType.Normal, function() + end, function() + -- 发送通知 + self:LeaveRoomCheckFightState() + end) +end + +function XUiUnionKillStage:OnBtnBuffClick() + if not self.RoomFightData then return end + local buffInfos = {} + local playerInfo = self.RoomFightData.UnionKillPlayerInfos[XPlayer.Id] + local stageInfos = self.RoomFightData.UnionKillStageInfos + if playerInfo then + local finishEventStages = playerInfo.FinishEventStage + for _, eventStageId in pairs(finishEventStages or {}) do + local eventStageTemplate = XFubenUnionKillConfigs.GetUnionEventStageById(eventStageId) + local curStageInfo = stageInfos[eventStageId] + if curStageInfo then + local totalEventNum = #eventStageTemplate.EventId + local realEventNum = #curStageInfo.PlayerIds + local buffIndex = realEventNum > totalEventNum and totalEventNum or realEventNum + table.insert(buffInfos, eventStageTemplate.EventId[buffIndex]) + end + end + end + self:PlayAnimation("TanchuangBuffEnable") + self.BuffDetails:Refresh(buffInfos) +end + +function XUiUnionKillStage:OnBtnChatClick() + XLuaUiManager.Open("UiChatServeMain", false, ChatChannelType.Room, ChatChannelType.World) +end + +function XUiUnionKillStage:OnBtnBossClick() + if not self.UnionKillInfo then return end + if not self.RoomFightData then return end + + self.CurSectionId = self.UnionKillInfo.CurSectionId + self.CurSectionTemplate = XFubenUnionKillConfigs.GetUnionSectionById(self.CurSectionId) + if not self.CurSectionTemplate then return end + + -- 通关限制 + local isLock = false + local unlockBossLimit = self.CurSectionTemplate.UnlockBossStageLimit + local playerInfos = self.RoomFightData.UnionKillPlayerInfos + if playerInfos and playerInfos[XPlayer.Id] then + local myPlayerInfo = playerInfos[XPlayer.Id] + local finishEventCount = #myPlayerInfo.FinishEventStage + isLock = finishEventCount < unlockBossLimit + end + + if isLock then + XUiManager.TipMsg(CS.XTextManager.GetText("UnionStageCondition", unlockBossLimit)) + return + end + + if self.RoomFightData.BossHpLeft <= 0 then + -- 试炼关 + XLuaUiManager.Open("UiUnionKillEnterFight", self.CurSectionTemplate.TrialStage, self.CurSectionTemplate, XFubenUnionKillConfigs.UnionKillStageType.TrialStage) + else + -- Boss关 + XLuaUiManager.Open("UiUnionKillEnterFight", self.CurSectionTemplate.BossStage, self.CurSectionTemplate, XFubenUnionKillConfigs.UnionKillStageType.BossStage) + end +end + +function XUiUnionKillStage:OnBtnDamageDetailClick() + if not self.RoomFightData then return end + local damageInfos = {} + local playerInfos = self.RoomFightData.UnionKillPlayerInfos + if playerInfos then + for _, playerInfo in pairs(playerInfos) do + if playerInfo.KillBossHp > 0 then + table.insert(damageInfos, { + PlayerId = playerInfo.Id, + PlayerName = playerInfo.PlayerName, + HeadPortraitId = playerInfo.HeadPortraitId, + HeadFrameId = playerInfo.HeadFrameId, + PlayerLevel = playerInfo.PlayerLevel, + KillBossHp = playerInfo.KillBossHp, + Online = playerInfo.Status == 1, + Position = playerInfo.Position + }) + end + end + table.sort(damageInfos, function(damage1, damage2) + return damage1.KillBossHp > damage2.KillBossHp + end) + end + self:PlaySaftyAnimation("TanchuangTongJiEnable") + self.DamageDetails:Refresh(damageInfos) +end + +--[[提示相关]] +-- 每秒检查是否需要提示 +function XUiUnionKillStage:CheckTipQueuePerSecond() + for i = 1, XFubenUnionKillConfigs.MaxTeamCount do + if self.StageTeamMembers[i] then + local playerId = self.StageTeamMembers[i].PlayerId + if playerId and not self.StageTeamMembers[i].IsTiping then + local tipMsg = XDataCenter.FubenUnionKillManager.GetTipQueueById(playerId) + if tipMsg then + self.StageTeamMembers[i]:ProcessTipMsg(tipMsg) + end + end + end + end + + if not self.IsNotifying then + local tip_all_msg = XDataCenter.FubenUnionKillManager.GetTipQueueAll() + if tip_all_msg and self:IsShowTipMsg() then + self:ProcessTipMessage(tip_all_msg) + end + end +end + +-- 不需要计时器,用房间界面的计时器就可以 +function XUiUnionKillStage:ProcessTipMessage(allTipMsg) + self:EndProcessTipMessage() + self.IsNotifying = true + ---显示 + local fullMsg = "" + local playerName = "" + if allTipMsg.TipsType == XFubenUnionKillConfigs.TipsMessageType.Praise then + -- 点赞 + local characterName = XCharacterConfigs.GetCharacterFullNameStr(allTipMsg.CharacterId) + fullMsg = CS.XTextManager.GetText(XFubenUnionKillConfigs.PraiseWords, characterName) + elseif allTipMsg.TipsType == XFubenUnionKillConfigs.TipsMessageType.ResultBorrow then + -- 刷新纪录 + fullMsg = CS.XTextManager.GetText(XFubenUnionKillConfigs.RefreshHighestPoint) + end + fullMsg = XUiHelper.ConvertLineBreakSymbol(fullMsg) + local fightInfo = XDataCenter.FubenUnionKillManager.GetCurRoomData() + if fightInfo then + local playerInfo = fightInfo.UnionKillPlayerInfos[allTipMsg.PlayerId] + if playerInfo then + playerName = XDataCenter.SocialManager.GetPlayerRemark(playerInfo.Id, playerInfo.PlayerName) + end + end + self:TipMessage(fullMsg, playerName) + + self.TipMsgTimer = XScheduleManager.ScheduleOnce(function() + self:EndProcessTipMessage() + end, 3000) +end + +function XUiUnionKillStage:EndProcessTipMessage() + if self.TipMsgTimer then + XScheduleManager.UnSchedule(self.TipMsgTimer) + self.TipMsgTimer = nil + end + self:EndTipMessage() + self.IsNotifying = false +end + +function XUiUnionKillStage:TipMessage(msg, playerName) + self.TipsGroup.gameObject:SetActiveEx(true) + self.TxtTipContent.text = playerName + self.TxtTipText.text = msg + if XLuaUiManager.IsUiShow("UiUnionKillStage") then + self:PlaySaftyAnimation("TipsGroupEnable") + end +end + +function XUiUnionKillStage:EndTipMessage() + self.TipsGroup.gameObject:SetActiveEx(false) +end + +function XUiUnionKillStage:OnBtnNotShowTodayClick() + self:EndTipMessage() + local now = XTime.GetServerNowTimestamp() + XDataCenter.FubenUnionKillManager.SaveUnionKillStringPrefs(XFubenUnionKillConfigs.NotShowToday, tostring(now)) +end + +function XUiUnionKillStage:IsShowTipMsg() + local recordTime = XDataCenter.FubenUnionKillManager.GetUnionKillStringPrefs(XFubenUnionKillConfigs.NotShowToday, "") + if recordTime == "" then return true end + + local recored = tonumber(recordTime) + local dt = CS.XDateUtil.GetGameDateTime(recored + 1 * 60 * 60 * 24) + dt = dt.Date + local unlockTime = dt:ToTimestamp() + 5 * 60 * 60 + local now = XTime.GetServerNowTimestamp() + return now > unlockTime +end + + +--[[房间开始倒计时]] +function XUiUnionKillStage:StartRoomCountDown() + self:StopRoomCountDown() + if not self.RoomFightData then return end + + local now = XTime.GetServerNowTimestamp() + local endTime = self.RoomFightData.EndTime + if not endTime then return end + + self.TxtSectionTime.text = XUiHelper.GetTime(endTime - now) + + self.UnionRoomTimer = XScheduleManager.ScheduleForever(function() + now = XTime.GetServerNowTimestamp() + if now > endTime then + self:StopRoomCountDown() + return + end + self:CheckTipQueuePerSecond() + local sec = endTime - now + self.TxtSectionTime.text = XUiHelper.GetTime(sec) + + if sec == WARN_LAST_SEC then + if XLuaUiManager.IsUiShow("UiUnionKillEnterFight") then + XLuaUiManager.Close("UiUnionKillEnterFight") + end + + if XLuaUiManager.IsUiShow("UiUnionKillDifficulty") then + XLuaUiManager.Close("UiUnionKillDifficulty") + end + + if XLuaUiManager.IsUiShow("UiUnionKillStage") then + self:PlaySaftyAnimation("TanChuangEndEnable") + end + self.SectionEnd.GameObject:SetActiveEx(true) + elseif sec < WARN_LAST_SEC then + self.SectionEnd:Refresh(sec) + end + + end, XScheduleManager.SECOND, 0) +end + +-- 关闭房间倒计时 +function XUiUnionKillStage:StopRoomCountDown() + if self.UnionRoomTimer ~= nil then + XScheduleManager.UnSchedule(self.UnionRoomTimer) + self.UnionRoomTimer = nil + end +end + +-- 试炼关开启 +function XUiUnionKillStage:CheckTrialOpen(isCheckPanel) + if not self.RoomFightData then return end + if self.RoomFightData.FirstKillBoss and not CS.XFight.IsRunning then + + if isCheckPanel then + if not XLuaUiManager.IsUiShow("UiUnionKillStage") then + return + end + end + + local quitCb = function() + self:LeaveRoomCheckFightState() + end + + local goTrial = function() + self:OnBtnBossClick() + end + + if XLuaUiManager.IsUiShow("UiUnionKillEnterFight") then + XLuaUiManager.Close("UiUnionKillEnterFight") + end + + XLuaUiManager.Open("UiUnionKillDifficulty", self.CurSectionConfig, quitCb, goTrial) + + self.RoomFightData.FirstKillBoss = nil + end +end + +function XUiUnionKillStage:RestorePlayerState() + local teamData = XDataCenter.FubenUnionKillRoomManager.GetUnionRoomData() + if teamData and teamData.PlayerDataList then + local playerData = teamData.PlayerDataList[XPlayer.Id] + if playerData then + playerData.State = XFubenUnionKillConfigs.UnionRoomPlayerState.Normal + end + + end +end + +-- 本局挑战是否结束 +function XUiUnionKillStage:CheckStageOver(isCheckPanel) + if not self.RoomFightData then + self:RestorePlayerState() + self:Close() + XUiManager.TipMsg(CS.XTextManager.GetText("UnionLeaveMiddle")) + return + end + + if self.RoomFightData.LeaveReson and self.RoomFightData.LeaveReson > 0 and not CS.XFight.IsRunning then + self:RestorePlayerState() + + if XLuaUiManager.IsUiShow("UiUnionKillEnterFight") then + XLuaUiManager.Close("UiUnionKillEnterFight") + end + + if XLuaUiManager.IsUiShow("UiUnionKillDifficulty") then + XLuaUiManager.Close("UiUnionKillDifficulty") + end + + local leaveReson = self.RoomFightData.LeaveReson + if isCheckPanel and XLuaUiManager.IsUiShow("UiUnionKillStage") then + XDataCenter.FubenUnionKillManager.TipsPlayerleaveReson(leaveReson) + if XLuaUiManager.IsUiShow("UiChatServeMain") then + XLuaUiManager.Close("UiChatServeMain") + end + XLuaUiManager.Close("UiUnionKillStage") + return + end + XLuaUiManager.Close("UiUnionKillStage") + XDataCenter.FubenUnionKillManager.TipsPlayerleaveReson(leaveReson) + end +end + +function XUiUnionKillStage:LeaveRoomCheckFightState() + local teamData = XDataCenter.FubenUnionKillRoomManager.GetUnionRoomData() + local hasLeaveRoom = self.RoomFightData and self.RoomFightData.LeaveReson and self.RoomFightData.LeaveReson > 0 + if teamData and teamData.PlayerDataList and not hasLeaveRoom then + local playerData = teamData.PlayerDataList[XPlayer.Id] + XDataCenter.FubenUnionKillManager.LeaveFightRoom(function() + local playerLastState = playerData.State + playerData.State = XFubenUnionKillConfigs.UnionRoomPlayerState.Normal + XEventManager.DispatchEvent(XEventId.EVENT_UNIONKILLROOM_PLAYERSTATE_CHANGED, playerData.Id, playerLastState) + self:Close() + end) + else + -- 特殊情况刷新 + if teamData and teamData.PlayerDataList then + local playerData = teamData.PlayerDataList[XPlayer.Id] + if playerData then + XEventManager.DispatchEvent(XEventId.EVENT_UNIONKILLROOM_PLAYERSTATE_CHANGED, playerData.Id, playerData.State) + end + end + self:Close() + end +end + +function XUiUnionKillStage:PlaySaftyAnimation(animName, endCb, startCb) + self:PlayAnimation(animName, function() + if endCb then + endCb() + end + XLuaUiManager.SetMask(false) + end, + function() + if startCb then + startCb() + end + XLuaUiManager.SetMask(true) + end) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFubenUnionKill/XUiUnionKillTask.lua b/Resources/Scripts/XUi/XUiFubenUnionKill/XUiUnionKillTask.lua new file mode 100644 index 00000000..de8f7851 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenUnionKill/XUiUnionKillTask.lua @@ -0,0 +1,71 @@ +local XUiUnionKillTask = XLuaUiManager.Register(XLuaUi, "UiUnionKillTask") + +function XUiUnionKillTask:OnAwake() + self.AssetPanel = XUiPanelAsset.New(self,self.PanelAsset, + XDataCenter.ItemManager.ItemId.FreeGem, + XDataCenter.ItemManager.ItemId.ActionPoint, + XDataCenter.ItemManager.ItemId.Coin) + self.BtnBack.CallBack = function() + self:OnBtnBackClick() + end + self.BtnMainUi.CallBack = function() + self:OnBtnMainUiClick() + end + + self.DynamicTable = XDynamicTableNormal.New(self.SViewTask.gameObject) + self.DynamicTable:SetProxy(XDynamicGridTask) + self.DynamicTable:SetDelegate(self) + + XEventManager.AddEventListener(XEventId.EVENT_TASK_SYNC, self.RefreshUnionKillTasks, self) +end + +function XUiUnionKillTask:OnDestroy() + XEventManager.RemoveEventListener(XEventId.EVENT_TASK_SYNC, self.RefreshUnionKillTasks, self) +end + +function XUiUnionKillTask:OnStart() + self:RefreshUnionKillTasks() +end + +function XUiUnionKillTask:RefreshUnionKillTasks() + local unionInfo = XDataCenter.FubenUnionKillManager.GetUnionKillInfo() + if not unionInfo then return end + + local activityId = unionInfo.Id + if activityId == nil or activityId == 0 then return end + self.CurrentUnionActivityConfig = XFubenUnionKillConfigs.GetUnionActivityConfigById(activityId) + self.CurrentUnionActivityTemplate = XFubenUnionKillConfigs.GetUnionActivityById(activityId) + + local tasklimitedIds = self.CurrentUnionActivityTemplate.TaskLimitId + + self.UnionKillTasks = {} + for _, tasklimitedId in pairs(tasklimitedIds or {}) do + local tasks = XDataCenter.TaskManager.GetTimeLimitTaskListByGroupId(tasklimitedId) + for _, task in pairs(tasks or {}) do + table.insert(self.UnionKillTasks, task) + end + end + + self.DynamicTable:SetDataSource(self.UnionKillTasks) + self.DynamicTable:ReloadDataASync() +end + +--动态列表事件 +function XUiUnionKillTask:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.UnionKillTasks[index] + if not data then + return + end + grid.RootUi = self + grid:ResetData(data) + end +end + +function XUiUnionKillTask:OnBtnBackClick() + self:Close() +end + +function XUiUnionKillTask:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end diff --git a/Resources/Scripts/XUi/XUiFubenUnionKill/XUiUnionKillTipCardShare.lua b/Resources/Scripts/XUi/XUiFubenUnionKill/XUiUnionKillTipCardShare.lua new file mode 100644 index 00000000..b86a4699 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFubenUnionKill/XUiUnionKillTipCardShare.lua @@ -0,0 +1,40 @@ +local XUiUnionKillTipCardShare = XLuaUiManager.Register(XLuaUi, "UiUnionKillTipCardShare") +local XUiGridUnionShareCharItem = require("XUi/XUiFubenUnionKill/XUiGridUnionShareCharItem") + + +function XUiUnionKillTipCardShare:OnAwake() + self.BtnMask.CallBack = function() self:OnBtnMaskClick() end + + self.ShareCharacters = {} +end + +function XUiUnionKillTipCardShare:OnDestroy() + if self.EndTimer then + XScheduleManager.UnSchedule(self.EndTimer) + self.EndTimer = nil + end +end + +function XUiUnionKillTipCardShare:OnStart(shareInfos) + for i = 1, #shareInfos do + if not self.ShareCharacters[i] then + local ui = CS.UnityEngine.Object.Instantiate(self.GridMainLineCharacter.gameObject) + ui.transform:SetParent(self.GridCharacterContent, false) + self.ShareCharacters[i] = XUiGridUnionShareCharItem.New(ui, self) + end + self.ShareCharacters[i].GameObject:SetActiveEx(true) + self.ShareCharacters[i]:Refresh(shareInfos[i]) + end + -- 超出的隐藏 + for i = #shareInfos + 1, #self.ShareCharacters do + self.ShareCharacters[i].GameObject:SetActiveEx(false) + end + + self.EndTimer = XScheduleManager.ScheduleOnce(function() + self:Close() + end, 3000) +end + +function XUiUnionKillTipCardShare:OnBtnMaskClick() + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFunctionalOpen/XUiFunctionalOpen.lua b/Resources/Scripts/XUi/XUiFunctionalOpen/XUiFunctionalOpen.lua new file mode 100644 index 00000000..124979e8 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFunctionalOpen/XUiFunctionalOpen.lua @@ -0,0 +1,388 @@ +local CommunicateReplaceStr = CS.XGame.ClientConfig:GetString("CommunicateReplaceStr") + +local XUiFunctionalOpen = XLuaUiManager.Register(XLuaUi, "UiFunctionalOpen") + +local UiType = { Normal = 1, Special = 2 } + +function XUiFunctionalOpen:OnAwake() + self:InitAutoScript() + self.BtnClear.gameObject:SetActiveEx(false) + self.TxtTalk.text = "" + self.OptionBtnList = {} + self.OptionBtnList[1] = self.BtnCheck +end + +function XUiFunctionalOpen:OnStart(actionList,IsDoEventEnd,IsDoNext,OnDisableCallBack) + self:RemovePresentTimer() + self:RefreshTime() + self:PlayAnimation("ComOpen", function() + self:SetupContent(actionList) + end) + self.IsEnd = false + self.IsDoEventEnd = IsDoEventEnd + self.IsDoNext = IsDoNext + self.OnDisableCallBack = OnDisableCallBack + self:OffButton() +end + +function XUiFunctionalOpen:OnEnable() + CS.XAudioManager.PlaySound(XSoundManager.UiBasicsMusic.Common_UiFunctionalOpen) +end + +function XUiFunctionalOpen:SetupContent(actionList) + self:PlayAnimation("ComLoop") + self.Content = 1 + self.Index = 1 + self.CanClick = true + self.CurCharIndex = 0 + self.Interval = 0.5 + self.Timer = nil + self.ActionList = actionList + + -- if self.ActionList.NpcHalfIcon then + -- self:SetUiSprite(self.ImgNpcHalf, self.ActionList.NpcHalfIcon) + -- end + + self:Init() +end + +function XUiFunctionalOpen:OnDisable() + self:CvStop() + if self.OnDisableCallBack then + local callBack = self.OnDisableCallBack + self.OnDisableCallBack = nil + callBack() + end +end + +function XUiFunctionalOpen:OnDestroy() +end + + + +function XUiFunctionalOpen:Init() + + self.TxtNameHand.text = self.ActionList.NpcName + if self.ActionList.BtnContent then + self.TextBtnClear.text = self.ActionList.BtnContent + end + if self.ActionList.NpcHandIcon then + self:SetUiSprite(self.ImgNpcHand, self.ActionList.NpcHandIcon) + end + + self.TxtNameHalf.text = self.ActionList.NpcName + self.TxtTalk.text = "" + + self.ImgNpcHand.gameObject:SetActiveEx(true) + self.PanelHintCommunication.gameObject:SetActiveEx(true) + self.PanelHintAction.gameObject:SetActiveEx(false) + + if self.ActionList.UiType == UiType.Normal then + self.BtnOpenCommunication.gameObject:SetActiveEx(true) + self.BtnOpenCommunicationOfMedal.gameObject:SetActiveEx(false) + self.BtnRefuse.gameObject:SetActiveEx(true) + self.BtnRefuseOfMedal.gameObject:SetActiveEx(false) + else + self.BtnOpenCommunication.gameObject:SetActiveEx(false) + self.BtnOpenCommunicationOfMedal.gameObject:SetActiveEx(true) + self.BtnRefuse.gameObject:SetActiveEx(false) + self.BtnRefuseOfMedal.gameObject:SetActiveEx(true) + end +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiFunctionalOpen:InitAutoScript() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiFunctionalOpen:AutoAddListener() + self:RegisterClickEvent(self.BtnOpenCommunication, self.OnBtnOpenCommunicationClick) + self:RegisterClickEvent(self.BtnRefuse, self.OnBtnRefuseClick) + self:RegisterClickEvent(self.BtnOpenCommunicationOfMedal, self.OnBtnOpenCommunicationClick) + self:RegisterClickEvent(self.BtnRefuseOfMedal, self.OnBtnRefuseClick) + self:RegisterClickEvent(self.BtnDirty, self.OnBtnDirtyClick) + self:RegisterClickEvent(self.BtnClear, self.OnBtnClearClick) + self:RegisterClickEvent(self.BtnInputOn, self.OnBtnInputOnClick) + self:RegisterClickEvent(self.BtnOnAction, self.OnBtnOnActionClick) +end + +-- auto +function XUiFunctionalOpen:OnBtnDirtyClick() + +end + + +function XUiFunctionalOpen:OnBtnOnActionClick() + self.BtnOnAction.gameObject:SetActiveEx(false) + self.BtnInputOn.gameObject:SetActiveEx(true) + self.PanelHintCommunication.gameObject:SetActiveEx(false) + self.PanelHintAction.gameObject:SetActiveEx(true) + self.BtnClear.gameObject:SetActiveEx(false) + local onEnd = function() + XUiHelper.StopAnimation() + + self:PlayAnimation("TongxinLoop") + self.Content = self.Content - 1 + self.CurrCharTab = string.CharsConvertToCharTab(self.ActionList.Repulse)--这里其实是废弃的 但是不知道为什么没有删除 + local interval = math.floor(self.Interval * 1000 / #self.CurrCharTab) + self.Timer = XScheduleManager.Schedule(function(...) + self:PlayDialog(...) + end, interval, #self.CurrCharTab + 2, 0) + end + XUiHelper.StopAnimation() + + self:PlayAnimation("TongxinBegan", onEnd) +end + +function XUiFunctionalOpen:OnBtnOpenCommunicationClick() + local onEnd = function() + XUiHelper.StopAnimation() + self:PlayAnimation("TongxinLoop") + self:HintActionInit() + end + self.PanelHintCommunication.gameObject:SetActiveEx(false) + self.BtnOnAction.gameObject:SetActiveEx(false) + self.BtnInputOn.gameObject:SetActiveEx(true) + self.BtnClear.gameObject:SetActiveEx(false) + + self.PanelHintAction.gameObject:SetActiveEx(true) + XUiHelper.StopAnimation() + + self:PlayAnimation("TongxinBegan", onEnd) +end + +function XUiFunctionalOpen:OnBtnRefuseClick() + self:OnBtnClearClick() +end + +function XUiFunctionalOpen:OnBtnClearClick() + if self.IsEnd then + return + end + + local data = self.IsDoNext and XDataCenter.CommunicationManager.GetNextCommunication(self.ActionList.Type) or nil + XUiHelper.StopAnimation() + + if data then + local onEnd = function() + self:SetupContent(data) + end + self.ImgNpcHand.gameObject:SetActiveEx(false) + self:PlayAnimation("ComOpen", onEnd) + self:OffButton() + else + local onEnd = function() + self:RemovePresentTimer() + self:RemoveTimer() + + local axtionSkipId = self.ActionList.SkipId + + XTipManager.Execute() + + self.PanelHintCommunication.gameObject:SetActiveEx(false) + self.PanelHintAction.gameObject:SetActiveEx(false) + XDataCenter.CommunicationManager.SetCommunicating(false) + + self:Close() + + + if axtionSkipId then + XFunctionManager.SkipInterface(axtionSkipId) + end + + if self.IsDoEventEnd then + XEventManager.DispatchEvent(XEventId.EVENT_FUNCTION_EVENT_COMPLETE) + end + + end + + self:PlayAnimation("TongxinClose", onEnd) + self.IsEnd = true + end +end + +function XUiFunctionalOpen:OnBtnInputOnClick() + if self.PanelBtnGroupShow then return end + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + self.TxtTalk.text = "" + self.TxtTalk.text = table.concat(self.CurrCharTab) + self.CurCharIndex = 0 + self:ShowOptionBtn() + self:TypewritingFinish() + else + self:RemoveTimer() + + if self.CurFuntionalContentsInfo and self.CurFuntionalContentsInfo.ContentsSkip ~= 0 then + self.CurFuntionalContentsInfo = XCommunicationConfig.GetFunctionalContentsInfoById(self.CurFuntionalContentsInfo.ContentsSkip) + else + self.CurFuntionalContentsInfo = XCommunicationConfig.GetFunctionalContentsGroupFirstInfoByGroupId(self.ActionList.ContentsGroupId) + end + self:Typewriting() + end +end + +function XUiFunctionalOpen:ShowOptionBtn() + if self.PanelBtnGroupShow then return end + if self.CurFuntionalContentsInfo and XCommunicationConfig.ComminictionType.OptionType == self.CurFuntionalContentsInfo.Type then + self.PanelBtnGroup.gameObject:SetActiveEx(true) + self.PanelBtnGroupShow = true + else + self.PanelBtnGroup.gameObject:SetActiveEx(false) + self.PanelBtnGroupShow = false + return + end + + for index , option in ipairs(self.CurFuntionalContentsInfo.OptionTitle) do + local checkBtn = false + if not self.OptionBtnList[index] then + checkBtn = CS.UnityEngine.Object.Instantiate(self.BtnCheck, self.PanelBtnGroup.transform) + self.OptionBtnList[index] = checkBtn + else + checkBtn = self.OptionBtnList[index] + end + checkBtn.gameObject:SetActiveEx(true) + local checkBtnLabel = XUiHelper.TryGetComponent(checkBtn.transform, "Text", "Text") + checkBtnLabel.text = option + checkBtn.CallBack = function() + self:OnOptionBtnClick(index) + end + end + if #self.OptionBtnList > #self.CurFuntionalContentsInfo.OptionTitle then + for i = #self.CurFuntionalContentsInfo.OptionTitle, #self.OptionBtnList, 1 do + self.OptionBtnList[i].gameObject:SetActiveEx(false) + end + end +end + +function XUiFunctionalOpen:OnOptionBtnClick(index) + + if self.CurFuntionalContentsInfo and self.CurFuntionalContentsInfo.Optionskip[index] and self.CurFuntionalContentsInfo.Optionskip[index] ~= 0 then + self.CurFuntionalContentsInfo = XCommunicationConfig.GetFunctionalContentsInfoById(self.CurFuntionalContentsInfo.Optionskip[index]) + end + self.PanelBtnGroup.gameObject:SetActiveEx(false) + self.PanelBtnGroupShow = false + self:Typewriting() + +end + +function XUiFunctionalOpen:OffButton() + self.BtnOpenCommunication.gameObject:SetActiveEx(false) + self.BtnOpenCommunicationOfMedal.gameObject:SetActiveEx(false) + self.BtnRefuse.gameObject:SetActiveEx(false) + self.BtnRefuseOfMedal.gameObject:SetActiveEx(false) +end + +function XUiFunctionalOpen:HintActionInit() + self.CurFuntionalContentsInfo = XCommunicationConfig.GetFunctionalContentsGroupFirstInfoByGroupId(self.ActionList.ContentsGroupId) + self:Typewriting() +end + +function XUiFunctionalOpen:Typewriting() + self:RemoveTimer() + self.TxtTalk.text = "" + local content = self.CurFuntionalContentsInfo.Contents + + if self.CurFuntionalContentsInfo.NpcHalfIconPath then + self:SetUiSprite(self.ImgNpcHalf, self.CurFuntionalContentsInfo.NpcHalfIconPath) + end + + if self.CurFuntionalContentsInfo.NpcName then + self.TxtNameHalf.text = self.CurFuntionalContentsInfo.NpcName + end + + local temp = XUiHelper.ReplaceWithPlayerName(content, CommunicateReplaceStr) + self.CurrCharTab = {} + if temp and type(temp) == "string" then + self.CurrCharTab = string.CharsConvertToCharTab(temp) + end + + local interval = math.floor(self.Interval * 1000 / #self.CurrCharTab) + self.Timer = XScheduleManager.Schedule(function(...) + self:PlayDialog(...) + end, interval, #self.CurrCharTab + 2, 0) + + if self.CurFuntionalContentsInfo.CueId ~= 0 then + if self.CurPlayingCvId and self.CurPlayingCvId == self.CurFuntionalContentsInfo.CueId then + else + self:PlayCv(self.CurFuntionalContentsInfo.CueId) + end + else + self:CvStop() + end +end + +--播放CV +function XUiFunctionalOpen:PlayCv(cvId) + self:CvStop() + self.PlayingCv = CS.XAudioManager.PlayCv(cvId) + self.CurPlayingCvId = cvId +end + +--停止 +function XUiFunctionalOpen:CvStop() + if self.PlayingCv then + self.PlayingCv:Stop() + self.PlayingCv = nil + end +end + +function XUiFunctionalOpen:TypewritingFinish() + if self.CurFuntionalContentsInfo and self.CurFuntionalContentsInfo.ContentsSkip == 0 and self.CurFuntionalContentsInfo.Type ~= XCommunicationConfig.ComminictionType.OptionType then + self.BtnInputOn.gameObject:SetActiveEx(false) + self.CanClick = true + self.BtnClear.gameObject:SetActiveEx(true) + end +end + +function XUiFunctionalOpen:PlayDialog(timer) + if not timer or self.Timer == nil then + return + end + if self.CurCharIndex + 1 > #self.CurrCharTab then + self.CurCharIndex = 0 + self:RemoveTimer() + self:ShowOptionBtn() + if self.CurFuntionalContentsInfo.ContentsSkip == 0 then + self:TypewritingFinish() + end + return + end + + -- if not self.TxtTalk then + -- return + -- end + self.CurCharIndex = self.CurCharIndex + 1 + self.TxtTalk.text = self.TxtTalk.text .. self.CurrCharTab[self.CurCharIndex] +end + +function XUiFunctionalOpen:RefreshTime() + local refreshFunc = function() + if XTool.UObjIsNil(self.GameObject) then + return + end + self.getTime = XTime.TimestampToGameDateTimeString(XTime.GetServerNowTimestamp(), "HH:mm:ss") + self.TxtTimeHand.text = self.getTime + self.TxtTimeHalf.text = self.getTime + end + refreshFunc() + self.PresentTimer = XScheduleManager.ScheduleForever(refreshFunc, 1000, 0) +end + +function XUiFunctionalOpen:RemoveTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end + +function XUiFunctionalOpen:RemovePresentTimer() + if self.PresentTimer then + XScheduleManager.UnSchedule(self.PresentTimer) + self.PresentTimer = nil + end +end + diff --git a/Resources/Scripts/XUi/XUiFunctionalOpen/XUiHintFunctional.lua b/Resources/Scripts/XUi/XUiFunctionalOpen/XUiHintFunctional.lua new file mode 100644 index 00000000..9bfd5282 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFunctionalOpen/XUiHintFunctional.lua @@ -0,0 +1,101 @@ +local XUiHintFunctional = XLuaUiManager.Register(XLuaUi, "UiHintFunctional") + +function XUiHintFunctional:OnAwake() + self:InitAutoScript() +end + +function XUiHintFunctional:OnStart(openId) + self.PanelHintBox.gameObject:SetActive(true) + self.BtnBox.gameObject:SetActive(true) + self.OpenList = openId + self.Index = 1 + self:NextHint() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiHintFunctional:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiHintFunctional:AutoInitUi() + self.PanelHintBox = self.Transform:Find("SafeAreaContentPane/PanelHintBox") + self.TxtBox = self.Transform:Find("SafeAreaContentPane/PanelHintBox/TxtBox"):GetComponent("Text") + self.BtnBox = self.Transform:Find("SafeAreaContentPane/PanelHintBox/BtnBox"):GetComponent("Button") +end + +function XUiHintFunctional:GetAutoKey(uiNode, eventName) + if not uiNode then + return + end + return eventName .. uiNode:GetHashCode() +end + +function XUiHintFunctional:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then + return + end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiHintFunctional:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiHintFunctional:AutoAddListener() + self.AutoCreateListeners = {} + self:RegisterClickEvent(self.BtnBox, self.OnBtnBoxClick) +end +-- auto + +function XUiHintFunctional:OnBtnBoxClick() + self.Index = self.Index + 1 + if self.Index > #self.OpenList then + self:Close() + -- XTipManager.Execute() + -- XFunctionManager.IsOpen = false + XEventManager.DispatchEvent(XEventId.EVENT_FUNCTION_EVENT_COMPLETE) + return nil + else + if XFunctionConfig.GetOpenHint(self.OpenList[self.Index]) == 1 then + self:NextHint() + -- elseif XFunctionConfig.GetOpenHint(self.OpenList[self.Index]) == 2 then + -- local remainId = {} + -- for i = self.Index, #self.OpenList do + -- table.insert(remainId, self.OpenList[i]) + -- end + -- --CS.XUiManager.TipsManager:Pop() + -- self:Close() + -- --CS.XUiManager.TipsManager:Push("UiFunctionalOpen",true, false, remainId) + -- XLuaUiManager.Open("UiFunctionalOpen", remainId) + end + end +end + +function XUiHintFunctional:NextHint() + if XFunctionManager.JudgeOpen(self.OpenList[self.Index]) == false then + XPlayer.ChangeMarks(self.OpenList[self.Index]) + end + self.TxtBox.text = "" + if XFunctionConfig.GetFunctionalType(self.OpenList[self.Index]) == XFunctionManager.FunctionType.System then + self.TxtBox.text = CS.XTextManager.GetText("FunctionOpen", XFunctionConfig.GetFunctionalName(self.OpenList[self.Index])) + elseif XFunctionConfig.GetFunctionalType(self.OpenList[self.Index]) == XFunctionManager.FunctionType.Stage then + self.TxtBox.text = CS.XTextManager.GetText("FunctionOpenStage", XFunctionConfig.GetFunctionalName(self.OpenList[self.Index])) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFurnitureDetail/XUiFurnitureDetail.lua b/Resources/Scripts/XUi/XUiFurnitureDetail/XUiFurnitureDetail.lua new file mode 100644 index 00000000..70166811 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFurnitureDetail/XUiFurnitureDetail.lua @@ -0,0 +1,259 @@ +local XUiFurnitureDetail = XLuaUiManager.Register(XLuaUi, "UiFurnitureDetail") +local attrRed = XFurnitureConfigs.AttrType.AttrA +local attrYellow = XFurnitureConfigs.AttrType.AttrB +local attrBule = XFurnitureConfigs.AttrType.AttrC + +function XUiFurnitureDetail:OnAwake() + self:AddListener() + self:InitLockButtons() +end + +function XUiFurnitureDetail:OnEnable() + XEventManager.AddEventListener(XEventId.EVENT_DORM_CLOSE_DETAIL, self.OnBtnCloseClick, self) +end + +function XUiFurnitureDetail:OnDisable() + XEventManager.RemoveEventListener(XEventId.EVENT_DORM_CLOSE_DETAIL, self.OnBtnCloseClick, self) +end + +function XUiFurnitureDetail:OnStart(furnitureId, furnitureConfigId, furnitureRewardId, recycleCallBack, isCloseRecycle, isCloseSuit) + self.FurnitureId = furnitureId + self.FurnitureConfigId = furnitureConfigId + self.FurnitureRewardId = furnitureRewardId + self.RecycleCallBack = recycleCallBack + + -- 是否显示回收按钮 + if isCloseRecycle ~= nil and isCloseRecycle then + self.BtnRecovery.gameObject:SetActive(not isCloseRecycle) + end + + if isCloseSuit ~= nil and isCloseSuit then + self.BtnSuitInfo.gameObject:SetActive(not isCloseSuit) + end + + self:InitConfigInfo() + + if self.FurnitureId then + self:InitOwerInfoByObjectId() + else + self:InitOwerInfoByConfigId() + end +end + +function XUiFurnitureDetail:AddListener() + self:RegisterClickEvent(self.BtnClose, self.OnBtnCloseClick) + self:RegisterClickEvent(self.BtnBg, self.OnBtnCloseClick) + self:RegisterClickEvent(self.BtnSuitInfo, self.OnBtnSuitInfoClick) + self:RegisterClickEvent(self.BtnRecovery, self.OnBtnRecoveryClick) +end + +function XUiFurnitureDetail:InitLockButtons() + if self.BtnLock then + self.BtnLock.gameObject:SetActiveEx(false) + XUiHelper.RegisterClickEvent(self, self.BtnLock, function() self:OnBtnLock() end) + end + if self.BtnUnlock then + self.BtnUnlock.gameObject:SetActiveEx(false) + XUiHelper.RegisterClickEvent(self, self.BtnUnlock, function() self:OnBtnUnlock() end) + end +end + +function XUiFurnitureDetail:OnBtnCloseClick() + self:Close() + XEventManager.DispatchEvent(XEventId.EVENT_DORM_BAG_REFRESH) +end + +function XUiFurnitureDetail:OnBtnSuitInfoClick() + local tp = XFurnitureConfigs.GetFurnitureTemplateById(self.FurnitureConfigId) + XLuaUiManager.Open("UiDormFieldGuide", tp.SuitId) + self:Close() +end + +-- 确认回收 +function XUiFurnitureDetail:OnBtnRecoveryClick() + if XDataCenter.FurnitureManager.GetFurnitureIsLocked(self.FurnitureId) then + XUiManager.TipMsg(CS.XTextManager.GetText("DormCannotRecycleLockFurniture")) + return + end + local funitureRecycleList = { self.FurnitureId } + + -- 屏蔽使用中的家具 + for i = 1, #funitureRecycleList do + local isUseing = XDataCenter.FurnitureManager.CheckFurnitureUsing(funitureRecycleList[i]) + if isUseing then + XUiManager.TipText("DormFurnitureRecycelUsingTip") + return + end + end + + XLuaUiManager.Open("UiFurnitureRecycleObtain", funitureRecycleList, function() + XDataCenter.FurnitureManager.DecomposeFurniture(funitureRecycleList, function(rewardItems, successIds) + -- 打开回收界面 + XLuaUiManager.Open("UiDormBagRecycle", successIds, rewardItems, function() + -- 将分解成功的家具从缓存中移除 + for _, id in ipairs(successIds) do + XDataCenter.FurnitureManager.RemoveFurniture(id) + end + + -- 回收回调 + if self.RecycleCallBack then + self.RecycleCallBack() + end + end) + end) + end) +end + +function XUiFurnitureDetail:OnBtnLock() + XDataCenter.FurnitureManager.SetFurnitureLock(self.FurnitureId, false, function() self:SetLocked() end) +end + +function XUiFurnitureDetail:OnBtnUnlock() + XDataCenter.FurnitureManager.SetFurnitureLock(self.FurnitureId, true, function() self:SetLocked() end) +end + +function XUiFurnitureDetail:SetLocked() + if not self.FurnitureId then return end + local isLocked = XDataCenter.FurnitureManager.GetFurnitureIsLocked(self.FurnitureId) + if self.BtnLock then self.BtnLock.gameObject:SetActiveEx(isLocked) end + if self.BtnUnlock then self.BtnUnlock.gameObject:SetActiveEx(not isLocked) end +end + +function XUiFurnitureDetail:InitConfigInfo() + local furnitureConfig = XFurnitureConfigs.GetFurnitureTemplateById(self.FurnitureConfigId) + local furnitureTypConfig = XFurnitureConfigs.GetFurnitureTypeById(furnitureConfig.TypeId) + self.TxtName.text = CS.XTextManager.GetText("DormFurnitureName", furnitureConfig.Name, furnitureTypConfig.MinorName, furnitureTypConfig.CategoryName) + self.TxtScore.text = "???" + self.TxtFurnitureDesc.text = furnitureConfig.Desc + local furnitureIcon = furnitureConfig.Icon + if self.FurnitureId then + furnitureIcon = XDataCenter.FurnitureManager.GetFurnitureIconById(self.FurnitureId, XDormConfig.DormDataType.Self) + end + self.RImgIcon:SetRawImage(furnitureIcon, nil, true) + + -- 套装 + local tp = XFurnitureConfigs.GetFurnitureTemplateById(self.FurnitureConfigId) + self.BtnSuitInfo.gameObject:SetActive(tp.SuitId ~= nil and tp.SuitId > 0) + + local suitInfo = nil + + if tp.SuitId > 0 then + suitInfo = XFurnitureConfigs.GetFurnitureSuitTemplatesById(tp.SuitId) + end + + if tp.SuitId > 0 and suitInfo then + self.TxtSuitName.text = suitInfo.SuitName + else + self.TxtSuitName.text = CS.XTextManager.GetText("DormFurnitureNotSuit") + end + + -- 家具属性 + self.TxtRedScore.text = "??" + self.TxtYellowScore.text = "??" + self.TxtBlueScore.text = "??" + + -- 特殊效果 + self.TxtEffectDesc.text = "???" + self.TxtEffectScore.gameObject:SetActive(false) +end + +function XUiFurnitureDetail:InitOwerInfoByObjectId() + local redTypeName = XFurnitureConfigs.GetDormFurnitureTypeName(attrRed) + local yoellowTypeName = XFurnitureConfigs.GetDormFurnitureTypeName(attrYellow) + local blueTypeName = XFurnitureConfigs.GetDormFurnitureTypeName(attrBule) + + local redTypeIcon = XFurnitureConfigs.GetDormFurnitureTypeIcon(attrRed) + local yoellowTypeIcon = XFurnitureConfigs.GetDormFurnitureTypeIcon(attrYellow) + local blueTypeIcon = XFurnitureConfigs.GetDormFurnitureTypeIcon(attrBule) + + self:SetUiSprite(self.ImgRed, redTypeIcon) + self:SetUiSprite(self.ImgYellow, yoellowTypeIcon) + self:SetUiSprite(self.ImgBlue, blueTypeIcon) + + local redScore = XDataCenter.FurnitureManager.GetFurnitureRedScore(self.FurnitureId) + local yellowScore = XDataCenter.FurnitureManager.GetFurnitureYellowScore(self.FurnitureId) + local blueScore = XDataCenter.FurnitureManager.GetFurnitureBlueScore(self.FurnitureId) + + local furnitureType = XDataCenter.FurnitureManager.GetFurnitureConfigByUniqueId(self.FurnitureId).TypeId + local totalScore = XDataCenter.FurnitureManager.GetFurnitureScore(self.FurnitureId) + local totalDesc = XFurnitureConfigs.GetFurnitureTotalAttrLevelDescription(furnitureType, totalScore) + local redScoreDesc = XFurnitureConfigs.GetFurnitureAttrLevelDescription(furnitureType, attrRed, redScore) + local yellowScoreDesc = XFurnitureConfigs.GetFurnitureAttrLevelDescription(furnitureType, attrYellow, yellowScore) + local blueScoreDesc = XFurnitureConfigs.GetFurnitureAttrLevelDescription(furnitureType, attrBule, blueScore) + + self.TxtRedScore.text = CS.XTextManager.GetText("DormFurnitureScoreDesc", redTypeName, redScoreDesc) + self.TxtYellowScore.text = CS.XTextManager.GetText("DormFurnitureScoreDesc", yoellowTypeName, yellowScoreDesc) + self.TxtBlueScore.text = CS.XTextManager.GetText("DormFurnitureScoreDesc", blueTypeName, blueScoreDesc) + self.TxtScore.text = CS.XTextManager.GetText("DormFurnitureScoreDesc", CS.XTextManager.GetText("DormTotalScore"), totalDesc) + local furnitureData = XDataCenter.FurnitureManager.GetFurnitureById(self.FurnitureId) + self:SetLocked() + local additionId = furnitureData.Addition + local additionScoreDesc = "" + if additionId > 0 then + self.TxtEffectScore.gameObject:SetActive(true) + additionScoreDesc = XFurnitureConfigs.GetAdditionalRandomEntry(additionId, true) + end + self.TxtEffectDesc.text = XDataCenter.FurnitureManager.GetFurnitureEffectDesc(self.FurnitureId) + self.TxtEffectScore.text = additionScoreDesc + + local tp = XFurnitureConfigs.GetFurnitureTemplateById(self.FurnitureConfigId) + self.TxtSuitEffectDesc.gameObject:SetActiveEx(false) + + if tp.SuitId > 0 then + local suitBgmInfo = XDormConfig.GetDormSuitBgmInfo(tp.SuitId) + if suitBgmInfo then + self.TxtSuitEffectDesc.gameObject:SetActiveEx(true) + self.TxtSuitEffectDesc.text = string.format(CS.XGame.ClientConfig:GetString("DormSuitBgmDesc"), suitBgmInfo.SuitNum, "\n", suitBgmInfo.Name) + self.TxtSuit.text = CS.XGame.ClientConfig:GetString("DormSuitBgmTitleDesc") + end + end +end + +function XUiFurnitureDetail:InitOwerInfoByConfigId() + local template = XFurnitureConfigs.GetFurnitureReward(self.FurnitureRewardId) + if not template then + return + end + + local redScore, yellowScore, blueScore = XDataCenter.FurnitureManager.GetRewardFurnitureAttr(template.ExtraAttrId) + if not redScore or not yellowScore or not blueScore then + return + end + + local redTypeName = XFurnitureConfigs.GetDormFurnitureTypeName(attrRed) + local yoellowTypeName = XFurnitureConfigs.GetDormFurnitureTypeName(attrYellow) + local blueTypeName = XFurnitureConfigs.GetDormFurnitureTypeName(attrBule) + + local redTypeIcon = XFurnitureConfigs.GetDormFurnitureTypeIcon(attrRed) + local yoellowTypeIcon = XFurnitureConfigs.GetDormFurnitureTypeIcon(attrYellow) + local blueTypeIcon = XFurnitureConfigs.GetDormFurnitureTypeIcon(attrBule) + + self:SetUiSprite(self.ImgRed, redTypeIcon) + self:SetUiSprite(self.ImgYellow, yoellowTypeIcon) + self:SetUiSprite(self.ImgBlue, blueTypeIcon) + + local furnitureType = XFurnitureConfigs.GetFurnitureTemplateById(self.FurnitureConfigId).TypeId + local totalScore = XDataCenter.FurnitureManager.GetRewardFurnitureScore(self.FurnitureRewardId) + local totalDesc = XFurnitureConfigs.GetFurnitureTotalAttrLevelDescription(furnitureType, totalScore) + + local redScoreDesc = XFurnitureConfigs.GetFurnitureAttrLevelDescription(furnitureType, attrRed, redScore) + local yellowScoreDesc = XFurnitureConfigs.GetFurnitureAttrLevelDescription(furnitureType, attrYellow, yellowScore) + local blueScoreDesc = XFurnitureConfigs.GetFurnitureAttrLevelDescription(furnitureType, attrBule, blueScore) + + + self.TxtRedScore.text = CS.XTextManager.GetText("DormFurnitureScoreDesc", redTypeName, redScoreDesc) + self.TxtYellowScore.text = CS.XTextManager.GetText("DormFurnitureScoreDesc", yoellowTypeName, yellowScoreDesc) + self.TxtBlueScore.text = CS.XTextManager.GetText("DormFurnitureScoreDesc", blueTypeName, blueScoreDesc) + self.TxtBlueScore.text = CS.XTextManager.GetText("DormFurnitureScoreDesc", blueTypeName, blueScoreDesc) + self.TxtScore.text = CS.XTextManager.GetText("DormFurnitureScoreDesc", CS.XTextManager.GetText("DormTotalScore"), totalDesc) + + local additionId = XDataCenter.FurnitureManager.GetRewardFurnitureEffectId(self.FurnitureRewardId) + local additionScoreDesc = "" + if additionId and additionId > 0 then + self.TxtEffectScore.gameObject:SetActive(true) + additionScoreDesc = XFurnitureConfigs.GetAdditionalRandomEntry(additionId, true) + end + + self.TxtEffectDesc.text = XFurnitureConfigs.GetAdditionalRandomIntroduce(additionId) + self.TxtEffectScore.text = additionScoreDesc +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFurnitureRecycleObtain/XUiFurnitureObtain.lua b/Resources/Scripts/XUi/XUiFurnitureRecycleObtain/XUiFurnitureObtain.lua new file mode 100644 index 00000000..62c954ee --- /dev/null +++ b/Resources/Scripts/XUi/XUiFurnitureRecycleObtain/XUiFurnitureObtain.lua @@ -0,0 +1,468 @@ +local XUiGridObtain = require("XUi/XUiFurnitureRecycleObtain/XUiGridObtain") +local XUiFurnitureObtain = XLuaUiManager.Register(XLuaUi, "UiFurnitureObtain") +local FurnitureState + +function XUiFurnitureObtain:OnAwake() + self:AddListener() + FurnitureState = XFurnitureConfigs.FURNITURE_STATE +end + +function XUiFurnitureObtain:AddListener() + self:RegisterClickEvent(self.BtnClose, self.OnBtnCloseClick) + self:RegisterClickEvent(self.BtnReset, self.OnBtnResetClick) + self:RegisterClickEvent(self.BtnRecovery, self.OnBtnRecoveryClick) + self:RegisterClickEvent(self.BtnRefit, self.OnBtnRefitClick) + self:RegisterClickEvent(self.BtnBatchReset, self.OnBtnBatchResetClick) + self:RegisterClickEvent(self.BtnBatchRecovery, self.OnBtnBatchRecoveryClick) + self:RegisterClickEvent(self.BtnBatchRefit, self.OnBtnBatchRefitClick) + self:RegisterClickEvent(self.TogLevelA, self.OnTogLevelAClick) + self:RegisterClickEvent(self.TogLevelB, self.OnTogLevelBClick) + self:RegisterClickEvent(self.TogLevelC, self.OnTogLevelCClick) +end + +function XUiFurnitureObtain:OnStart(gainType, furnitueList, refitCallBack, createCoinCount, createPos, resetCallBack) + self.ResetCallBack = resetCallBack + self.RefitCallBack = refitCallBack + self.FurnitureState = FurnitureState.DETAILS + self.IsRecovery = false + self.GainType = gainType + self.CreateCoinCount = createCoinCount or 0 + self.CreatePos = createPos or 0 + + self:InitFurnitureDatas(furnitueList) + self:InitDynamicTable() + self:InitBtnState() +end + +function XUiFurnitureObtain:OnEnable() + XEventManager.AddEventListener(XEventId.EVENT_CLICKFURNITURE_GRID, self.OnObtainGridClick, self) +end + +function XUiFurnitureObtain:OnDisable() + XEventManager.RemoveEventListener(XEventId.EVENT_CLICKFURNITURE_GRID, self.OnObtainGridClick, self) +end + +function XUiFurnitureObtain:InitFurnitureDatas(furnitueList) + self.FurnitureIds = {} + self.FurnitureLevelDic = {} + + if not furnitueList or #furnitueList <= 0 then + return + end + + local white = XGoodsCommonManager.QualityType.White + local greed = XGoodsCommonManager.QualityType.Greed + local blue = XGoodsCommonManager.QualityType.Blue + local purple = XGoodsCommonManager.QualityType.Purple + local gold = XGoodsCommonManager.QualityType.Gold + + for _, furniture in ipairs(furnitueList) do + table.insert(self.FurnitureIds, furniture.Id) + + local furnitureType = XDataCenter.FurnitureManager.GetFurnitureConfigByUniqueId(furniture.Id).TypeId + local totalScore = XDataCenter.FurnitureManager.GetFurnitureScore(furniture.Id) + local quality = XFurnitureConfigs.GetFurnitureTotalAttrLevel(furnitureType, totalScore) + + local insert = function(color, id) + if not self.FurnitureLevelDic[color] then + self.FurnitureLevelDic[color] = {} + end + table.insert(self.FurnitureLevelDic[color], id) + end + + if quality == white then + insert(white, furniture.Id) + elseif quality == greed then + insert(greed, furniture.Id) + elseif quality == blue then + insert(blue, furniture.Id) + elseif quality == purple then + insert(purple, furniture.Id) + elseif quality >= gold then + insert(gold, furniture.Id) + end + end +end + +function XUiFurnitureObtain:InitDynamicTable() + self.ObtainGrid.gameObject:SetActiveEx(false) + self.DynamicTable = XDynamicTableNormal.New(self.PanelDynamic) + self.DynamicTable:SetProxy(XUiGridObtain) + self.DynamicTable:SetDelegate(self) +end + +--动态列表事件 +function XUiFurnitureObtain:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.FurnitureIds[index] + grid:Refresh(data, self.SelectQualityList) + end +end + +function XUiFurnitureObtain:UpdateDynamicTable() + self.DynamicTable:SetDataSource(self.FurnitureIds) + self.DynamicTable:ReloadDataASync(1) +end + +function XUiFurnitureObtain:InitBtnState() + local isCreate = self.GainType == XFurnitureConfigs.GainType.Create + self.BtnBatchReset.gameObject:SetActiveEx(isCreate) + self.BtnBatchRefit.gameObject:SetActiveEx(not isCreate) + local icon = XDataCenter.ItemManager.GetItemIcon(XDataCenter.ItemManager.ItemId.FurnitureCoin) + self.RImgIcon:SetRawImage(icon) + + self:ChangeUiState() +end + +function XUiFurnitureObtain:ChangeUiState() + self.FurnitureSelectList = {} + self.FurnitureSelectCount = 0 + self.SelectQualityList = {} + + if self.FurnitureState == FurnitureState.DETAILS then + self.PanelBatch.gameObject:SetActiveEx(true) + self.PanelEdit.gameObject:SetActiveEx(false) + elseif self.FurnitureState == FurnitureState.SELECT then + self.PanelBatch.gameObject:SetActiveEx(false) + self.PanelEdit.gameObject:SetActiveEx(true) + self.TogLevelA.isOn = false + self.TogLevelB.isOn = false + self.TogLevelC.isOn = false + + local isCreate = self.GainType == XFurnitureConfigs.GainType.Create + self.BtnReset.gameObject:SetActiveEx(not self.IsRecovery and isCreate) + self.BtnRefit.gameObject:SetActiveEx(not self.IsRecovery and not isCreate) + self.TxtDesc.gameObject:SetActiveEx(self.IsRecovery or isCreate) + self.BtnRecovery.gameObject:SetActiveEx(self.IsRecovery) + + if self.IsRecovery or isCreate then + local text = self.IsRecovery and CS.XTextManager.GetText("DormObtainRecovery") or CS.XTextManager.GetText("DormObtainReset") + self.TxtDesc.text = text + end + self:SetCoinCount() + end + + self:UpdateDynamicTable() +end + +function XUiFurnitureObtain:SetCoinCount() + self.IsRefitCoinEnough = true + if self.FurnitureSelectCount <= 0 then + self.TxtCoin.text = 0 + return + end + + local isCreate = self.GainType == XFurnitureConfigs.GainType.Create + local getRewardCount = function() + local count = 0 + local rewards = XDataCenter.FurnitureManager.GetRecycleRewards(self:GetFurnitureList()) + local coinId = XDataCenter.ItemManager.ItemId.FurnitureCoin + for _, reward in ipairs(rewards) do + local templateId = (reward.TemplateId and reward.TemplateId > 0) and reward.TemplateId or reward.Id + if templateId == coinId then + count = count + reward.Count + end + end + return count + end + if self.IsRecovery then + self.TxtCoin.text = getRewardCount() + elseif isCreate then + local rewardCount = getRewardCount() + local createCount = self.CreateCoinCount * self.FurnitureSelectCount + local count = (createCount - rewardCount) > 0 and createCount - rewardCount or 0 + local currentOwn = XDataCenter.ItemManager.GetCount(XDataCenter.ItemManager.ItemId.FurnitureCoin) + rewardCount + self.IsRefitCoinEnough = currentOwn >= createCount + self.TxtCoin.text = self.IsRefitCoinEnough and CS.XTextManager.GetText("DormBuildEnoughCount", count) + or CS.XTextManager.GetText("DormBuildNoEnoughCount", count) + end +end + +function XUiFurnitureObtain:CheckIncludeLevelS() + for id, _ in pairs(self.FurnitureSelectList) do + local furnitureType = XDataCenter.FurnitureManager.GetFurnitureConfigByUniqueId(id).TypeId + local totalScore = XDataCenter.FurnitureManager.GetFurnitureScore(id) + local quality = XFurnitureConfigs.GetFurnitureTotalAttrLevel(furnitureType, totalScore) + + if quality >= XGoodsCommonManager.QualityType.Gold then + return true + end + end + + return false +end + +function XUiFurnitureObtain:GetGridSelected(id) + if self.FurnitureState == XFurnitureConfigs.FURNITURE_STATE.SELECT then + if self.FurnitureSelectCount <= 0 then + return false + end + + for myId, _ in pairs(self.FurnitureSelectList) do + if myId == id then + return true + end + end + + return false + end + + return false +end + +function XUiFurnitureObtain:GetFurnitureList() + local list = {} + for id, _ in pairs(self.FurnitureSelectList) do + table.insert(list, id) + end + return list +end + +function XUiFurnitureObtain:RemoveSelectQuality(quality, closeTog) + local removeIndex + for i, k in ipairs(self.SelectQualityList) do + if k == quality then + removeIndex = i + break + end + end + + if removeIndex then + table.remove(self.SelectQualityList, removeIndex) + end + + if not closeTog then return end + local white = XGoodsCommonManager.QualityType.White + local greed = XGoodsCommonManager.QualityType.Greed + local blue = XGoodsCommonManager.QualityType.Blue + local purple = XGoodsCommonManager.QualityType.Purple + + if (quality == white or quality == greed) and self.TogLevelC.isOn then + self.TogLevelC.isOn = false + elseif quality == blue and self.TogLevelB.isOn then + self.TogLevelB.isOn = false + elseif quality == purple and self.TogLevelA.isOn then + self.TogLevelA.isOn = false + end +end + +--------------------------------- 点击事件相关(Start) --------------------------------- +function XUiFurnitureObtain:OnObtainGridClick(furnitureId, furnitureConfigId, grid) + if self.FurnitureState == FurnitureState.DETAILS then + XLuaUiManager.Open("UiFurnitureDetail", furnitureId, furnitureConfigId, nil, nil, true, true) + elseif self.FurnitureState == FurnitureState.SELECT then + grid:SetSelected(not grid:IsSelected()) + for myId, _ in pairs(self.FurnitureSelectList) do + if myId == furnitureId then + self.FurnitureSelectCount = self.FurnitureSelectCount - 1 + self.FurnitureSelectList[myId] = nil + self:RemoveSelectQuality(grid.Quality, true) + self:SetCoinCount() + return + end + end + + self.FurnitureSelectList[furnitureId] = true + self.FurnitureSelectCount = self.FurnitureSelectCount + 1 + self:SetCoinCount() + end +end + +function XUiFurnitureObtain:OnBtnCloseClick() + if self.FurnitureState == FurnitureState.DETAILS then + self:Close() + elseif self.FurnitureState == FurnitureState.SELECT then + self.FurnitureState = FurnitureState.DETAILS + self:ChangeUiState() + end +end + +function XUiFurnitureObtain:OnBtnBatchResetClick() + self.IsRecovery = false + self.FurnitureState = FurnitureState.SELECT + self:ChangeUiState() +end + +function XUiFurnitureObtain:OnBtnBatchRefitClick() + self.IsRecovery = false + self.FurnitureState = FurnitureState.SELECT + self:ChangeUiState() +end + +function XUiFurnitureObtain:OnBtnBatchRecoveryClick() + self.IsRecovery = true + self.FurnitureState = FurnitureState.SELECT + self:ChangeUiState() +end + +function XUiFurnitureObtain:OnTogLevelAClick() + local purple = XGoodsCommonManager.QualityType.Purple + self:OnTogLevelClick(self.TogLevelA, purple, true) +end + +function XUiFurnitureObtain:OnTogLevelBClick() + local blue = XGoodsCommonManager.QualityType.Blue + self:OnTogLevelClick(self.TogLevelB, blue, true) +end + +function XUiFurnitureObtain:OnTogLevelCClick() + local greed = XGoodsCommonManager.QualityType.Greed + local white = XGoodsCommonManager.QualityType.White + self:OnTogLevelClick(self.TogLevelC, white) + self:OnTogLevelClick(self.TogLevelC, greed, true) +end + +function XUiFurnitureObtain:OnTogLevelClick(tog, quality, isFresh) + if not tog.isOn then + self:RemoveSelectQuality(quality) + + -- 从选择列表中移除 + local levelIdList = self.FurnitureLevelDic[quality] or {} + for _, id in ipairs(levelIdList) do + if self.FurnitureSelectList[id] then + self.FurnitureSelectCount = self.FurnitureSelectCount - 1 + self.FurnitureSelectList[id] = nil + end + end + else + table.insert(self.SelectQualityList, quality) + + -- 添加到选择列表 + local levelIdList = self.FurnitureLevelDic[quality] or {} + for _, id in ipairs(levelIdList) do + if not self.FurnitureSelectList[id] then + self.FurnitureSelectList[id] = true + self.FurnitureSelectCount = self.FurnitureSelectCount + 1 + end + end + end + + if not isFresh then return end + self:UpdateDynamicTable() + self:SetCoinCount() +end + +-- 重新建造 +function XUiFurnitureObtain:OnBtnResetClick() + if not self.IsRefitCoinEnough then + XUiManager.TipMsg(CS.XTextManager.GetText("FurnitureZeroCoin")) + return + end + + local func = function() + local furnitureList = self:GetFurnitureList() + if #furnitureList <= 0 then + XUiManager.TipMsg(CS.XTextManager.GetText("DormFurnitureRecycelNull"), XUiManager.UiTipType.Tip) + return + end + + if #furnitureList > XFurnitureConfigs.MaxCreateCount then + XUiManager.TipMsg(CS.XTextManager.GetText("DormBuildMaxCount", XFurnitureConfigs.MaxCreateCount)) + return + end + for _, furnitureId in pairs(furnitureList) do + if XDataCenter.FurnitureManager.GetFurnitureIsLocked(furnitureId) then + XUiManager.TipMsg(CS.XTextManager.GetText("DormCannotRemakeLockFurniture")) + return + end + end + XDataCenter.FurnitureManager.FurnitureRemake(self.CreatePos, furnitureList, function() + self:Close() + + if self.ResetCallBack then + self.ResetCallBack(self.CreatePos) + end + end) + end + + if self:CheckIncludeLevelS() then + local titletext = CS.XTextManager.GetText("TipTitle") + local contenttext = CS.XTextManager.GetText("DormObtainLevelSReset") + + XUiManager.DialogTip(titletext, contenttext, XUiManager.DialogType.Normal, nil, function() + func() + end) + else + func() + end +end + +-- 回收 +function XUiFurnitureObtain:OnBtnRecoveryClick() + local func = function() + local furnitureList = self:GetFurnitureList() + if #furnitureList <= 0 then + XUiManager.TipMsg(CS.XTextManager.GetText("DormFurnitureRecycelNull"), XUiManager.UiTipType.Tip) + return + end + for _, furnitureId in pairs(furnitureList) do + if XDataCenter.FurnitureManager.GetFurnitureIsLocked(furnitureId) then + XUiManager.TipMsg(CS.XTextManager.GetText("DormCannotRecycleLockFurniture")) + return + end + end + + XDataCenter.FurnitureManager.DecomposeFurniture(furnitureList, function(rewardItems, successIds) + -- 打开回收界面 + XLuaUiManager.Open("UiDormBagRecycle", furnitureList, rewardItems, nil, function() + self:Close() + end) + + -- 将分解成功的家具从缓存中移除 + for _, id in ipairs(successIds) do + -- local configId = XDataCenter.FurnitureManager.GetFurnitureConfigId(id) + XDataCenter.FurnitureManager.RemoveFurniture(id) + end + + -- 删除红点 + XDataCenter.FurnitureManager.DeleteNewHint(successIds) + end) + end + + if self:CheckIncludeLevelS() then + local titletext = CS.XTextManager.GetText("TipTitle") + local contenttext = CS.XTextManager.GetText("DormObtainLevelSRecovery") + + XUiManager.DialogTip(titletext, contenttext, XUiManager.DialogType.Normal, nil, function() + func() + end) + else + func() + end +end + +-- 重新改造 +function XUiFurnitureObtain:OnBtnRefitClick() + local func = function() + self:Close() + + if self.RefitCallBack then + local furnitureList = self:GetFurnitureList() + if #furnitureList <= 0 then + XUiManager.TipMsg(CS.XTextManager.GetText("DormFurnitureRecycelNull"), XUiManager.UiTipType.Tip) + return + end + + self.RefitCallBack(furnitureList) + end + end + for id, _ in pairs(self.FurnitureSelectList) do + if XDataCenter.FurnitureManager.GetFurnitureIsLocked(id) then + XUiManager.TipMsg(CS.XTextManager.GetText("DormCannotRemakeLockFurniture")) + return + end + end + if self:CheckIncludeLevelS() then + local titletext = CS.XTextManager.GetText("TipTitle") + local contenttext = CS.XTextManager.GetText("DormObtainLevelSRefit") + + XUiManager.DialogTip(titletext, contenttext, XUiManager.DialogType.Normal, nil, function() + func() + end) + else + func() + end +end +--------------------------------- 点击事件相关(End) --------------------------------- \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFurnitureRecycleObtain/XUiFurnitureRecycleObtain.lua b/Resources/Scripts/XUi/XUiFurnitureRecycleObtain/XUiFurnitureRecycleObtain.lua new file mode 100644 index 00000000..06db4bbd --- /dev/null +++ b/Resources/Scripts/XUi/XUiFurnitureRecycleObtain/XUiFurnitureRecycleObtain.lua @@ -0,0 +1,49 @@ +local XUiFurnitureRecycleObtain = XLuaUiManager.Register(XLuaUi, "UiFurnitureRecycleObtain") + +function XUiFurnitureRecycleObtain:OnAwake() + self:AddListener() +end + +function XUiFurnitureRecycleObtain:OnStart(furnitureIds, comfirmCb) + self.Items = {} + self.ComfirmCb = comfirmCb + self:Refresh(furnitureIds) +end + +function XUiFurnitureRecycleObtain:Refresh(furnitureIds) + local hintText = CS.XTextManager.GetText("DormFurnitureRecycelComfirm") + for i = 1, #furnitureIds do + local isUseing = XDataCenter.FurnitureManager.CheckFurnitureUsing(furnitureIds[i]) + if isUseing then + hintText = CS.XTextManager.GetText("DormFurnitureRecycelUsingComfirm") + break + end + end + + self.TxtTitle.text = hintText + local rewards = XDataCenter.FurnitureManager.GetRecycleRewards(furnitureIds) + XUiHelper.CreateTemplates(self, self.Items, rewards, XUiGridCommon.New, self.GridCommon, self.PanelContent, function(grid, data) + grid:Refresh(data) + end) + self.GridCommon.gameObject:SetActive(false) +end + +function XUiFurnitureRecycleObtain:AddListener() + self:RegisterClickEvent(self.BtnClose, self.OnBtnCloseClick) + self:RegisterClickEvent(self.BtnCancel, self.OnBtnCloseClick) + self:RegisterClickEvent(self.BtnSure, self.OnBtnSureClick) +end + +function XUiFurnitureRecycleObtain:OnBtnCloseClick() + self:Close() +end + +function XUiFurnitureRecycleObtain:OnBtnSureClick() + self:Close() + if self.ComfirmCb then + self.ComfirmCb() + end + XEventManager.DispatchEvent(XEventId.EVENT_DORM_CLOSE_DETAIL) +end + +return XUiFurnitureRecycleObtain \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFurnitureRecycleObtain/XUiGridObtain.lua b/Resources/Scripts/XUi/XUiFurnitureRecycleObtain/XUiGridObtain.lua new file mode 100644 index 00000000..438e38c7 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFurnitureRecycleObtain/XUiGridObtain.lua @@ -0,0 +1,80 @@ +local XUiGridObtain = XClass(nil, "XUiGridObtain") + +function XUiGridObtain:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:AutoAddListener() + self:SetSelected(false) +end + +function XUiGridObtain:Init(rootUi) + self.RootUi = rootUi +end + +function XUiGridObtain:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiGridObtain:RegisterClickEvent函数错误, 参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiGridObtain:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiGridObtain:AutoAddListener() + self:RegisterClickEvent(self.BtnClick, self.OnBtnClickClick) +end + +function XUiGridObtain:OnBtnClickClick() + local furnitureConfigId = XDataCenter.FurnitureManager.GetFurnitureConfigId(self.FurnitureId) + XEventManager.DispatchEvent(XEventId.EVENT_CLICKFURNITURE_GRID, self.FurnitureId, furnitureConfigId, self) +end + +function XUiGridObtain:SetSelected(status) + self.PanelSelect.gameObject:SetActiveEx(status) +end + +function XUiGridObtain:IsSelected() + return self.PanelSelect and self.PanelSelect.gameObject.activeSelf +end + +-- 传入家具的唯一Id +function XUiGridObtain:Refresh(furnitureId, selectQualityList) + self.FurnitureId = furnitureId + + local furnitureConfig = XDataCenter.FurnitureManager.GetFurnitureConfigByUniqueId(furnitureId) + if not furnitureConfig then + return + end + self:SetSelected(self.RootUi:GetGridSelected(furnitureId)) + + local icon = XDataCenter.FurnitureManager.GetFurnitureIconById(furnitureId, XDormConfig.DormDataType.Self) + self.RImgIcon:SetRawImage(icon, nil, true) + + local furnitureType = XDataCenter.FurnitureManager.GetFurnitureConfigByUniqueId(furnitureId).TypeId + local totalScore = XDataCenter.FurnitureManager.GetFurnitureScore(furnitureId) + local totalDesc = XFurnitureConfigs.GetFurnitureTotalAttrLevelDescription(furnitureType, totalScore) + self.TxtScore.text = totalDesc + self.Quality = XFurnitureConfigs.GetFurnitureTotalAttrLevel(furnitureType, totalScore) + + if self:IsSelected() then + return + end + for _, selectQuality in ipairs(selectQualityList) do + if self.Quality == selectQuality then + self:SetSelected(true) + break + end + end + +end + +return XUiGridObtain \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFurnitureTypeSelect/XUiFurnitureTypeSelect.lua b/Resources/Scripts/XUi/XUiFurnitureTypeSelect/XUiFurnitureTypeSelect.lua new file mode 100644 index 00000000..bd6ac2d3 --- /dev/null +++ b/Resources/Scripts/XUi/XUiFurnitureTypeSelect/XUiFurnitureTypeSelect.lua @@ -0,0 +1,443 @@ +local XUiFurnitureTypeSelect = XLuaUiManager.Register(XLuaUi, "UiFurnitureTypeSelect") +local XUiGridCategory = require("XUi/XUiFurnitureTypeSelect/XUiGridCategory") + +local SelectState = { + SINGLE = 1, + MULTIP = 2, +} + +local PanelState = { + FURNITURE = 1, + SUIT = 2, +} + +function XUiFurnitureTypeSelect:OnAwake() + self:AddListener() + + XEventManager.AddEventListener(XEventId.EVENT_CLICKCATEGORY_GRID, self.OnCategoryGridClick, self) +end + +function XUiFurnitureTypeSelect:OnStart(selectIds, selectSuitIds, isBuild, comfirmCb) + self.SelectIds = {} + self.SelectSuitIds = {} + + if selectIds then + for _, k in pairs(selectIds) do + table.insert(self.SelectIds, k) + end + end + + if selectSuitIds then + for _, k in pairs(selectSuitIds) do + table.insert(self.SelectSuitIds, k) + end + end + + self.CategoryGrids = {} + self.CategorySuitGrids = {} + self.PageRecord = PanelState.FURNITURE + self.IsBuild = isBuild + + self.ComfirmCb = comfirmCb + self.FurnitureTypeAllId = XFurnitureConfigs.FURNITURE_CATEGORY_ALL_ID + self.FurnitureTypeSuitAllId = XFurnitureConfigs.FURNITURE_SUIT_CATEGORY_ALL_ID + self:InitTabGroup() + self:Init() +end + +function XUiFurnitureTypeSelect:OnDestroy() + self.SelectIds = nil + self.SelectSuitIds = nil + self.CategoryGrids = nil + self.CategorySuitGrids = nil + self.CurSelectState = nil + self.FurnitureTypeAllId = 0 + + XEventManager.RemoveEventListener(XEventId.EVENT_CLICKCATEGORY_GRID, self.OnCategoryGridClick, self) +end + +function XUiFurnitureTypeSelect:InitTabGroup() + self.BtnList = {} + table.insert(self.BtnList, self.BtnFurnitureType) + table.insert(self.BtnList, self.BtnFurnitureSuitType) + + self.FurnitureTypeBtnGroup:Init(self.BtnList, function(index) + self:RefreshSelectedPanel(index) + end) + + -- 设置默认开启 + self.FurnitureTypeBtnGroup:SelectIndex(self.PageRecord) +end + +function XUiFurnitureTypeSelect:RefreshSelectedPanel(index) + self.PageRecord = index + self.PanelFurnitureTypeScroll.gameObject:SetActiveEx(self.PageRecord == PanelState.FURNITURE) + self.PanelFurnitureSuitTypeScroll.gameObject:SetActiveEx(self.PageRecord == PanelState.SUIT) +end + +-- 检查是否筛选过Grid +function XUiFurnitureTypeSelect:CheckCategoryGridSelect(id) + if not self.SelectIds or #self.SelectIds <= 0 then + return false + end + + for i = 1, #self.SelectIds do + if self.SelectIds[i] == id or self.SelectIds[i] == self.FurnitureTypeAllId then + return true + end + end + + return false +end + +-- 检查套装是否筛选过Grid +function XUiFurnitureTypeSelect:CheckSuitCategoryGridSelect(id) + if not self.SelectSuitIds or #self.SelectSuitIds <= 0 then + return false + end + + for i = 1, #self.SelectSuitIds do + if self.SelectSuitIds[i] == id or self.SelectSuitIds[i] == self.FurnitureTypeSuitAllId then + return true + end + end + + return false +end + +function XUiFurnitureTypeSelect:Init() + self.GridSuitCategory.gameObject:SetActiveEx(false) + self.PanelNotEnoughCoin.gameObject:SetActiveEx(false) + self.PanelMaxEnoughTip.gameObject:SetActiveEx(false) + self.PanelMinEnoughTip.gameObject:SetActiveEx(false) + self.PanelTip.gameObject:SetActiveEx(self.IsBuild) + + if self.IsBuild then + self.CurSelectState = SelectState.MULTIP + self:InitMultipleSelect() + self.PanelFurnitureSuitTypeScroll.gameObject:SetActiveEx(false) + self.BtnFurnitureSuitType.gameObject:SetActiveEx(false) + self:UpdateCoinTip() + return + end + + if self.SelectIds and #self.SelectIds > 0 then + self.CurSelectState = SelectState.MULTIP + self:InitMultipleSelect() + self:InitSuitPart() + return + end + + self.CurSelectState = SelectState.SINGLE + self.PanelFurnitureSuitTypeScroll.gameObject:SetActiveEx(false) + self.BtnFurnitureSuitType.gameObject:SetActiveEx(false) + self:InitSingleSelect() +end + +-- 初始化套装 +function XUiFurnitureTypeSelect:InitSuitPart() + local suitCfg = XFurnitureConfigs.GetFurnitureSuitTemplates() + self.GridAllSuitCategory = XUiGridCategory.New(self.GridAllSuitCategory) + local isSelected = self:CheckSuitCategoryGridSelect(self.FurnitureTypeSuitAllId) + self.GridAllSuitCategory:RefreshSuit(suitCfg[1], isSelected) + + for i = 2, #suitCfg do + local grid = CS.UnityEngine.Object.Instantiate(self.GridSuitCategory) + local gridCategory = XUiGridCategory.New(grid) + grid.transform:SetParent(self.PanelSuitContent, false) + local tmpIsSelected = self:CheckSuitCategoryGridSelect(suitCfg[i].Id) + gridCategory:RefreshSuit(suitCfg[i], tmpIsSelected) + gridCategory.GameObject:SetActiveEx(true) + + table.insert(self.CategorySuitGrids, gridCategory) + end +end + +-- 单选模式 +function XUiFurnitureTypeSelect:InitSingleSelect() + self.GridCategory.gameObject:SetActiveEx(false) + self.GridAllCategory.gameObject:SetActiveEx(false) + self:InitFurniturePart() +end + +-- 多选模式 +function XUiFurnitureTypeSelect:InitMultipleSelect() + self.GridCategory.gameObject:SetActiveEx(false) + self.GridAllCategory.gameObject:SetActiveEx(true) + + self.GridAllCategory = XUiGridCategory.New(self.GridAllCategory) + + -- 全部类型 + local isSelected = self:CheckCategoryGridSelect(self.FurnitureTypeAllId) + local categoryInfos = {} + categoryInfos.Id = XFurnitureConfigs.FURNITURE_CATEGORY_ALL_ID + categoryInfos.CategoryName = CS.XTextManager.GetText("DormAllDesc") + self.GridAllCategory:Refresh(categoryInfos, isSelected) + + self:InitFurniturePart() +end + +function XUiFurnitureTypeSelect:InitFurniturePart() + self.GridPartSelect.gameObject:SetActiveEx(false) + local parts = XFurnitureConfigs.GetFurnitureTemplatePartType() + local setPartInfoFunction = function(categoryInfos, minorName) + local part = CS.UnityEngine.Object.Instantiate(self.GridPartSelect) + part.transform:SetParent(self.PanelPartContent, false) + + local content = XUiHelper.TryGetComponent(part, "PanelCategoryContent", "Transform") + local name = XUiHelper.TryGetComponent(part, "TxtMinorName", "Text") + + name.text = minorName + part.gameObject:SetActiveEx(true) + + for _, categoryInfo in pairs(categoryInfos) do + local grid = CS.UnityEngine.Object.Instantiate(self.GridCategory) + local gridCategory = XUiGridCategory.New(grid) + + local isSelected = self:CheckCategoryGridSelect(categoryInfo.Id) + gridCategory:Refresh(categoryInfo, isSelected) + grid.transform:SetParent(content, false) + gridCategory.GameObject:SetActiveEx(true) + + table.insert(self.CategoryGrids, gridCategory) + end + end + + for _, part in pairs(parts) do + setPartInfoFunction(part.Categorys, part.MinorName) + end +end + +function XUiFurnitureTypeSelect:OnCategoryGridClick(furnitureTypeId, grid) + -- 处理套装 + if self.PageRecord == PanelState.SUIT then + self:OnCategorySuitGridClick(furnitureTypeId, grid) + return + end + + -- 处理单选 + if self.CurSelectState == SelectState.SINGLE then + if furnitureTypeId == self.SelectId then + return + end + + grid:SetSelected(not grid:IsSelected()) + self.SelectId = furnitureTypeId + if self.FurnitureSelectTypeGrid then + self.FurnitureSelectTypeGrid:SetSelected(false) + end + --记录选择得Grid + self.FurnitureSelectTypeGrid = grid + return + end + + -- 处理已经是再全选状态下再点击全选不能取消全选 + if self.GridAllCategory:IsSelected() and furnitureTypeId == self.FurnitureTypeAllId then + for _, categoryGrid in ipairs(self.CategoryGrids) do + categoryGrid:SetSelected(false) + end + self.GridAllCategory:SetSelected(false) + self.SelectIds = {} + self:UpdateCoinTip() + return + end + + grid:SetSelected(not grid:IsSelected()) + -- 处理全选类型逻辑 + if furnitureTypeId == self.FurnitureTypeAllId then + for _, categoryGrid in ipairs(self.CategoryGrids) do + categoryGrid:SetSelected(true) + end + + self.SelectIds = {} + local typeList = XFurnitureConfigs.GetFurnitureTemplateTypeList() + for _, furnitureType in ipairs(typeList) do + table.insert(self.SelectIds, furnitureType.Id) + end + self:UpdateCoinTip() + return + end + + -- 处理多选其他类型 + self.GridAllCategory:SetSelected(false) + + -- 移除全选 + for i = 1, #self.SelectIds do + if self.SelectIds[i] == self.FurnitureTypeAllId then + table.remove(self.SelectIds, i) + break + end + end + + -- 移除点击过的类型 + for i = 1, #self.SelectIds do + if self.SelectIds[i] == furnitureTypeId then + table.remove(self.SelectIds, i) + self:UpdateCoinTip() + return + end + end + + -- 加入未点击过的类型 + table.insert(self.SelectIds, furnitureTypeId) + self:UpdateCoinTip() +end + +function XUiFurnitureTypeSelect:OnCategorySuitGridClick(furnitureTypeId, grid) + if self.GridAllSuitCategory:IsSelected() and furnitureTypeId == self.FurnitureTypeSuitAllId then + for _, categoryGrid in ipairs(self.CategorySuitGrids) do + categoryGrid:SetSelected(false) + end + self.GridAllSuitCategory:SetSelected(false) + self.SelectSuitIds = {} + return + end + + grid:SetSelected(not grid:IsSelected()) + if furnitureTypeId == self.FurnitureTypeSuitAllId then + for _, categoryGrid in ipairs(self.CategorySuitGrids) do + categoryGrid:SetSelected(true) + end + + self.SelectSuitIds = {} + local suitList = XFurnitureConfigs.GetFurnitureSuitTemplates() + for _, suit in pairs(suitList) do + if suit.Id ~= self.FurnitureTypeSuitAllId then + table.insert(self.SelectSuitIds, suit.Id) + end + end + return + end + + self.GridAllSuitCategory:SetSelected(false) + -- 移除全选 + for i = 1, #self.SelectSuitIds do + if self.SelectSuitIds[i] == self.FurnitureTypeSuitAllId then + table.remove(self.SelectSuitIds, i) + break + end + end + + -- 移除点击过的类型 + for i = 1, #self.SelectSuitIds do + if self.SelectSuitIds[i] == furnitureTypeId then + table.remove(self.SelectSuitIds, i) + return + end + end + + table.insert(self.SelectSuitIds, furnitureTypeId) +end + +function XUiFurnitureTypeSelect:AddListener() + self:RegisterClickEvent(self.BtnClose, self.OnBtnCloseClick) + self:RegisterClickEvent(self.BtnCancel, self.OnBtnCloseClick) + self:RegisterClickEvent(self.BtnSelcet, self.OnBtnSelcetClick) +end + +function XUiFurnitureTypeSelect:OnBtnCloseClick() + self:Close() +end + +function XUiFurnitureTypeSelect:OnBtnSelcetClick() + if self.ComfirmCb then + local data + if self.CurSelectState == SelectState.SINGLE then + data = self.SelectId + else + data = self.SelectIds + end + + if not data then + XUiManager.TipMsg(CS.XTextManager.GetText("DormFurnitureSelectNull")) + return + end + + if type(data) == "table" and #data <= 0 then + XUiManager.TipMsg(CS.XTextManager.GetText("DormFurnitureSelectNull")) + return + end + + if not self:CheckBuildCoin() then + XUiManager.TipMsg(CS.XTextManager.GetText("FurnitureZeroCoin")) + return + end + data = self:SetBulidAllType(data) + + if not self.IsBuild and #self.SelectSuitIds <= 0 then + XUiManager.TipMsg(CS.XTextManager.GetText("DormFurnitureSelectSuitNull")) + return + end + + self.ComfirmCb(data, self.SelectSuitIds) + end + self:Close() +end + +-- 获得当前消耗家具币数量 +function XUiFurnitureTypeSelect:GetCostFurnitureCoin() + local minConsume, maxConsume = XFurnitureConfigs.GetFurnitureCreateMinAndMax() + + local typeCount = self.SelectIds and #self.SelectIds or 0 + for _, selectId in ipairs(self.SelectIds) do + if selectId == self.FurnitureTypeAllId then + typeCount = XFurnitureConfigs.GetFurnitureTemplateTypeCount() + break + end + end + + local maxCostCount = maxConsume * typeCount + local minCostCount = minConsume * typeCount + local currentOwn = XDataCenter.ItemManager.GetCount(XDataCenter.ItemManager.ItemId.FurnitureCoin) + local isMaxEnough = currentOwn >= maxCostCount + local isMinEnough = currentOwn >= minCostCount + return isMaxEnough, isMinEnough +end + +function XUiFurnitureTypeSelect:UpdateCoinTip() + if not self.IsBuild then + self.PanelMaxEnoughTip.gameObject:SetActiveEx(false) + self.PanelMinEnoughTip.gameObject:SetActiveEx(false) + return + end + + local _, isMinEnough = self:GetCostFurnitureCoin() + self.PanelMaxEnoughTip.gameObject:SetActiveEx(false) + self.PanelMinEnoughTip.gameObject:SetActiveEx(not isMinEnough) +end + +function XUiFurnitureTypeSelect:CheckBuildCoin() + if not self.IsBuild then + return true + end + + local _, isMinEnough = self:GetCostFurnitureCoin() + return isMinEnough +end + +function XUiFurnitureTypeSelect:SetBulidAllType(datas) + if not self.IsBuild then + return datas + end + + local isAll = false + for _, id in ipairs(datas) do + if id == self.FurnitureTypeAllId then + isAll = true + break + end + end + + if isAll then + local list = {} + local typeList = XFurnitureConfigs.GetFurnitureTemplateTypeList() + for _, furnitureType in ipairs(typeList) do + table.insert(list, furnitureType.Id) + end + return list + end + + return datas +end + +return XUiFurnitureTypeSelect \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiFurnitureTypeSelect/XUiGridCategory.lua b/Resources/Scripts/XUi/XUiFurnitureTypeSelect/XUiGridCategory.lua new file mode 100644 index 00000000..a0fb70dc --- /dev/null +++ b/Resources/Scripts/XUi/XUiFurnitureTypeSelect/XUiGridCategory.lua @@ -0,0 +1,60 @@ +local XUiGridCategory = XClass(nil, "XUiGridCategory") + +function XUiGridCategory:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:AutoAddListener() +end + +function XUiGridCategory:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiGridCategory:RegisterClickEvent函数错误, 参数fun不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiGridCategory:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiGridCategory:AutoAddListener() + self:RegisterClickEvent(self.BtnClick, self.OnBtnClickClick) +end + +function XUiGridCategory:OnBtnClickClick() + XEventManager.DispatchEvent(XEventId.EVENT_CLICKCATEGORY_GRID, self.CategoryInfo.Id, self) +end + +function XUiGridCategory:SetSelected(status) + self.PanelSelect.gameObject:SetActiveEx(status) +end + +function XUiGridCategory:IsSelected() + return self.PanelSelect.gameObject.activeSelf +end + +function XUiGridCategory:Refresh(categoryInfo, isSelected) + self.CategoryInfo = categoryInfo + + self:SetSelected(isSelected) + self.TxtCategoryName.text = categoryInfo.CategoryName + self.TxtCategoryNameSelect.text = categoryInfo.CategoryName +end + +function XUiGridCategory:RefreshSuit(categoryInfo, isSelected) + self.CategoryInfo = categoryInfo + + self:SetSelected(isSelected) + self.TxtCategoryName.text = categoryInfo.SuitName + self.TxtCategoryNameSelect.text = categoryInfo.SuitName +end + + +return XUiGridCategory \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGacha/XUiDrawActivity.lua b/Resources/Scripts/XUi/XUiGacha/XUiDrawActivity.lua new file mode 100644 index 00000000..bf7ec784 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGacha/XUiDrawActivity.lua @@ -0,0 +1,240 @@ +local XUiDrawActivity = XLuaUiManager.Register(XLuaUi, "UiDrawActivity") +local drawActivityControl = require("XUi/XUiGacha/XUiDrawActivityControl") +local LevelMax = 6 +local type = { IN = 1, OUT = 2 } +function XUiDrawActivity:OnStart(gachaId) + self.PreviewList = {} + self.GachaId = gachaId + self.GachaCfg = XGachaConfigs.GetGachaCfgById(self.GachaId) + self.GachaRule = XGachaConfigs.GetGachaRuleCfgById(self.GachaId) + self.DrawActivityControl = drawActivityControl.New(self, self.GachaCfg, function() + self:UpdateItemCount() + end, self) + self.Is3DSceneLoadFinish = false + self.ImgMask.gameObject:SetActiveEx(false) + + --self:UpdateInfo() + self:SetBtnCallBack() + self:InitPanelPreview() + self:LoadModelScene() +end + +function XUiDrawActivity:SetBtnCallBack() + self.BtnBack.CallBack = function() + self:OnBtnBackClick() + end + self.BtnMainUi.CallBack = function() + self:OnBtnMainUiClick() + end + self.BtnMore.CallBack = function() + self:OnBtnMore() + end + self.BtnUseItem.CallBack = function() + self:OnBtnUseItemClick() + end + self.BtnDrawRule.CallBack = function() + self:OnBtnDrawRuleClick() + end +end + +function XUiDrawActivity:OnEnable() + if self.Is3DSceneLoadFinish then + self:UIReset() + end + self:UpdateInfo() +end + +function XUiDrawActivity:UIReset() + self.IsReadyForGacha = false + XUiHelper.SetDelayPopupFirstGet(true) + self.ImgMask.gameObject:SetActiveEx(true) + self:PlayAnimation("DrawBegan", function() self.ImgMask.gameObject:SetActiveEx(false) end) + self.PlayableDirector = self.BackGround:GetComponent("PlayableDirector") + self.PlayableDirector:Stop() + self.PlayableDirector:Evaluate() + + --self:PlayLoopAnime() +end + +--function XUiDrawActivity:PlayLoopAnime() +-- self.PlayableDirector = XUiHelper.TryGetComponent(self.BackGround.transform, "TimeLine/Loop", "PlayableDirector") +-- if self.PlayableDirector then +-- self.PlayableDirector.gameObject:SetActiveEx(true) +-- self.PlayableDirector:Play() +-- self.PlayGachaAnim = true +-- local behaviour = self.GameObject:AddComponent(typeof(CS.XLuaBehaviour)) +-- if self.Update then +-- behaviour.LuaUpdate = function() self:Update() end +-- end +-- end +--end + +--function XUiDrawActivity:Update() +-- if self.PlayGachaAnim then +-- if self.PlayableDirector.time >= self.PlayableDirector.duration - 0.1 then +-- if self.IsReadyForGacha then +-- self.DrawActivityControl:ShowGacha() +-- end +-- end +-- end +--end + +function XUiDrawActivity:OnDisable() + XUiHelper.SetDelayPopupFirstGet() +end + +function XUiDrawActivity:OnBtnBackClick() + self:Close() +end + +function XUiDrawActivity:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiDrawActivity:OnBtnMore() + self.PanelPreview.gameObject:SetActiveEx(true) + self:PlayAnimation("PanelPreviewEnable") +end + +function XUiDrawActivity:OnBtnUseItemClick() + local data = XDataCenter.ItemManager.GetItem(self.GachaCfg.ConsumeId) + XLuaUiManager.Open("UiTip", data) +end + +function XUiDrawActivity:OnBtnDrawRuleClick() + XLuaUiManager.Open("UiDrawActivityLog",self.GachaId) +end + +function XUiDrawActivity:InitPanelPreview() + self.AllPreviewPanel = {} + self.PreviewList[type.IN] = {} + self.PreviewList[type.OUT] = {} + self.AllPreviewPanel.Transform = self.PanelPreview.transform + XTool.InitUiObject(self.AllPreviewPanel) + self.AllPreviewPanel.BtnPreviewConfirm.CallBack = function() + self.PanelPreview.gameObject:SetActiveEx(false) + end + self.AllPreviewPanel.BtnPreviewClose.CallBack = function() + self.PanelPreview.gameObject:SetActiveEx(false) + end + local gachaRewardInfo = XDataCenter.GachaManager.GetGachaRewardInfoById(self.GachaId) + self.AllPreviewPanel.GridDrawActivity.gameObject:SetActiveEx(false) + self.GridDrawActivity.gameObject:SetActiveEx(false) + self:SetPreviewData(gachaRewardInfo, self.AllPreviewPanel.GridDrawActivity, self.AllPreviewPanel.PanelDrawItemSP, self.AllPreviewPanel.PanelDrawItemNA, self.PreviewList[type.IN], type.IN) + self:SetPreviewData(gachaRewardInfo, self.GridDrawActivity, self.PreviewContent, nil, self.PreviewList[type.OUT], type.OUT, self.GachaRule.PreviewShowCount) + + local countStr = CS.XTextManager.GetText("AlreadyobtainedCount", XDataCenter.GachaManager.GetCurCountOfAll(), XDataCenter.GachaManager.GetMaxCountOfAll()) + self.AllPreviewPanel.PanelTxt.gameObject:SetActiveEx(not XDataCenter.GachaManager.GetIsInfinite()) + self.PanelNumber.gameObject:SetActiveEx(not XDataCenter.GachaManager.GetIsInfinite()) + self.AllPreviewPanel.TxetFuwenben.text = countStr + self.TxtNumber.text = countStr + + self.HintText.text = self.GachaRule.RuleHint or "" + self.TextName.text = self.GachaRule.GachaName or "" + self.BtnDrawRule.gameObject:SetActiveEx(self.GachaRule.UiType == XGachaConfigs.UiType.Pay) +end + +function XUiDrawActivity:UpdateInfo() + local icon = XDataCenter.ItemManager.GetItemBigIcon(self.GachaCfg.ConsumeId) + self.ImgUseItemIcon:SetRawImage(icon) + self:UpdateItemCount() +end + +function XUiDrawActivity:UpdateItemCount() + self.TxtUseItemCount.text = XDataCenter.ItemManager.GetItem(self.GachaCfg.ConsumeId).Count +end + +function XUiDrawActivity:LoadModelScene() + local sceneUrl = XSceneModelConfigs.GetScenePathById(self.GachaRule.SceneModelId) + local modelUrl = XSceneModelConfigs.GetModelPathById(self.GachaRule.SceneModelId) + sceneUrl = (sceneUrl and sceneUrl ~= "") and sceneUrl or self:GetDefaultSceneUrl() + modelUrl = (modelUrl and modelUrl ~= "") and modelUrl or self:GetDefaultUiModelUrl() + + self:LoadUiScene(sceneUrl, modelUrl, function () + self:SetGameObject() + self.Is3DSceneLoadFinish = true + local groupBaseObj = self.UiSceneInfo.Transform:Find("GroupBase").gameObject + XTool.DestroyChildren(groupBaseObj) + --XTool.DestroyChildren() + local root = self.UiModelGo.transform + root.position = CS.UnityEngine.Vector3(0,300,0) + self.BackGround = root + self:UIReset() + end, false) +end + +function XUiDrawActivity:PushShow(rewardList) + self:OpenChildUi("UiDrawActivityShow") + self:FindChildUiObj("UiDrawActivityShow"):SetData(rewardList, function() + if self.OpenSound then + self.OpenSound:Stop() + end + self:PushResult(rewardList) + self:UpdateInfo() + end, self.BackGround) + if self.CurLoop and not XTool.UObjIsNil(self.CurLoop.gameObject) then + self.CurLoop.gameObject:SetActiveEx(false) + end + --self.PlayableDirector:Stop() +end + +function XUiDrawActivity:PushResult(rewardList) + XLuaUiManager.Open("UiDrawResult", nil, rewardList, function() end) +end + +function XUiDrawActivity:SetPreviewData(gachaRewardInfo, obj, parentSP, parentNA, previewList, previewType, maxCount) + local count = 1 + for k, v in pairs(gachaRewardInfo) do + local go = nil + if previewType == type.IN then + if v.Rare and parentSP then + go = CS.UnityEngine.Object.Instantiate(obj, parentSP) + elseif (not v.Rare) and parentNA then + go = CS.UnityEngine.Object.Instantiate(obj, parentNA) + end + else + if v.Rare and parentSP then + if not maxCount or count <= maxCount then + go = CS.UnityEngine.Object.Instantiate(obj, parentSP) + count = count + 1 + else + break + end + end + end + + if go then + local item = XUiGridCommon.New(self, go) + local tmpData = {} + previewList[k] = item + tmpData.TemplateId = v.TemplateId + tmpData.Count = v.Count + local curCount = nil + if v.RewardType == XGachaConfigs.RewardType.Count then + curCount = v.CurCount + end + item:Refresh(tmpData, nil, nil, nil, curCount) + item.GameObject:SetActiveEx(true) + end + end +end + +function XUiDrawActivity:UpDataPreviewData() + local gachaRewardInfo = XDataCenter.GachaManager.GetGachaRewardInfoById(self.GachaId) + for i = 1, 2 do + for k, v in pairs(self.PreviewList[i] or {}) do + local tmpData = {} + tmpData.TemplateId = gachaRewardInfo[k].TemplateId + tmpData.Count = gachaRewardInfo[k].Count + local curCount = nil + if gachaRewardInfo[k].RewardType == XGachaConfigs.RewardType.Count then + curCount = gachaRewardInfo[k].CurCount + end + v:Refresh(tmpData, nil, nil, nil, curCount) + end + end + + local countStr = CS.XTextManager.GetText("AlreadyobtainedCount", XDataCenter.GachaManager.GetCurCountOfAll(), XDataCenter.GachaManager.GetMaxCountOfAll()) + self.AllPreviewPanel.TxetFuwenben.text = countStr + self.TxtNumber.text = countStr +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGacha/XUiDrawActivityControl.lua b/Resources/Scripts/XUi/XUiGacha/XUiDrawActivityControl.lua new file mode 100644 index 00000000..244dd18c --- /dev/null +++ b/Resources/Scripts/XUi/XUiGacha/XUiDrawActivityControl.lua @@ -0,0 +1,116 @@ +local XUiDrawActivityControl = XClass(nil, "XUiDrawActivityControl") +local characterRecord = require("XUi/XUiDraw/XUiDrawTools/XUiDrawCharacterRecord") + +local MAX_GACHA_BTN_COUNT = 2 + +function XUiDrawActivityControl:Ctor(rootUi, gachaCfg, gachaCb, uiGacha) + self.RootUi = rootUi + self.GachaCfg = gachaCfg + self.GachaCb = gachaCb + self.UiGacha = uiGacha + self.IsCanGacha = true + self:InitRes() + self:InitButtons() + return self +end + +function XUiDrawActivityControl:InitRes() + self.UseItemIcon = XDataCenter.ItemManager.GetItemBigIcon(self.GachaCfg.ConsumeId) +end + +function XUiDrawActivityControl:InitButtons() + for i = 1, MAX_GACHA_BTN_COUNT do + local btnName = "BtnDraw" .. i + local btn = XUiHelper.TryGetComponent(self.RootUi.PanelDrawButtons, btnName) + if btn then + self:InitButton(btn, i) + end + end +end + +function XUiDrawActivityControl:InitButton(btn, index) + --@DATA + local gachaCount = self.GachaCfg.BtnGachaCount[index] + btn.transform:Find("TxtDrawDesc"):GetComponent("Text").text = CS.XTextManager.GetText("DrawCount", gachaCount) + local itemIcon = btn.transform:Find("ImgUseItemIcon"):GetComponent("RawImage") + itemIcon:SetRawImage(self.UseItemIcon) + btn.transform:Find("TxtUseItemCount"):GetComponent("Text").text = gachaCount * self.GachaCfg.ConsumeCount + + self.RootUi:RegisterClickEvent(btn:GetComponent("Button"), function() + self.UiGacha:UpdateItemCount() + self:OnDraw(gachaCount) + end) +end + +function XUiDrawActivityControl:ShowGacha() + + XDataCenter.AntiAddictionManager.BeginDrawCardAction() + self.UiGacha.OpenSound = CS.XAudioManager.PlaySound(XSoundManager.UiBasicsMusic.UiDrawCard_GachaOpen) + + if self.GachaCb then + self.GachaCb() + end + + if self.RewardList and #self.RewardList > 0 then + self.IsCanGacha = true + self.UiGacha:PushShow(self.RewardList) + else + self.UiGacha:PushShow(self.RewardList) + end + + self.UiGacha:UpDataPreviewData() + self.UiGacha.IsReadyForGacha = false +end + + +function XUiDrawActivityControl:OnDraw(gachaCount) + if XDataCenter.EquipManager.CheckBoxOverLimitOfDraw() then + return + end + + local ownItemCount = XDataCenter.ItemManager.GetItem(self.GachaCfg.ConsumeId).Count + local lackItemCount = self.GachaCfg.ConsumeCount * gachaCount - ownItemCount + local gachaRule = XGachaConfigs.GetGachaRuleCfgById(self.GachaCfg.Id) + + if lackItemCount > 0 then + if gachaRule.ItemNotEnoughSkipId > 0 then + self:TipDialog(nil,function () + XFunctionManager.SkipInterface(gachaRule.ItemNotEnoughSkipId) + end,"GachaNotEnoughSkipHint") + else + XUiManager.TipError(CS.XTextManager.GetText("DrawNotEnoughError")) + end + return + end + local dtCount = XDataCenter.GachaManager.GetMaxCountOfAll() - XDataCenter.GachaManager.GetCurCountOfAll() + if dtCount < gachaCount and not XDataCenter.GachaManager.GetIsInfinite()then + XUiManager.TipMsg(CS.XTextManager.GetText("GachaIsNotEnough")) + return + end + if not XDataCenter.GachaManager.CheckGachaIsOpenById(self.GachaCfg.Id, true) then + return + end + if self.IsCanGacha then + self.IsCanGacha = false + + characterRecord.Record() + self.UiGacha.ImgMask.gameObject:SetActiveEx(true) + + XDataCenter.GachaManager.DoGacha(self.GachaCfg.Id, gachaCount, function(rewardList) + self.RewardList = rewardList + self.UiGacha:PlayAnimation("DrawRetract", function() + --self.UiGacha.IsReadyForGacha = true + self:ShowGacha() + end) + end,function () + self.UiGacha.ImgMask.gameObject:SetActiveEx(false) + end) + end +end + +function XUiDrawActivityControl:TipDialog(cancelCb, confirmCb,TextKey) + CsXUiManager.Instance:Open("UiDialog", CS.XTextManager.GetText("TipTitle"), CS.XTextManager.GetText(TextKey), + XUiManager.DialogType.Normal, cancelCb, confirmCb) +end + +return XUiDrawActivityControl \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGacha/XUiDrawActivityLog.lua b/Resources/Scripts/XUi/XUiGacha/XUiDrawActivityLog.lua new file mode 100644 index 00000000..83eea5f8 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGacha/XUiDrawActivityLog.lua @@ -0,0 +1,246 @@ +local XUiDrawActivityLog = XLuaUiManager.Register(XLuaUi, "UiDrawActivityLog") +local BtnMaxCount = 3 +local ProbMax = 5 +local TypeText = {} +local IsInit = {} +local AnimeNames = {} +local InitFunctionList = {} +local TimestampToGameDateTimeString = XTime.TimestampToGameDateTimeString +local DrawLogLimit = CS.XGame.ClientConfig:GetInt("DrawLogLimit") +function XUiDrawActivityLog:OnStart(gachaId, selectIndex, organizeRule) + self.GachaId = gachaId + self.SelectIndex = selectIndex or 1 + self.OrganizeRule = organizeRule + self.BtnTanchuangClose.CallBack = function() + self:OnBtnTanchuangClose() + end + self.BtnClose.CallBack = function() + self:OnBtnTanchuangClose() + end + InitFunctionList = { + function() + self:InitBaseRulePanel() + end, + function() + self:InitDrawPreview() + end, + function() + self:InitDrawLogListPanel() + end, + } + IsInit = {false, false, false, false } + AnimeNames = { "QieHuanOne", "QieHuanTwo", "QieHuanThree", "QieHuanFour" } + self:SetTypeText() + self:InitBtnTab() +end + +function XUiDrawActivityLog:SetTypeText() + TypeText[XArrangeConfigs.Types.Item] = CS.XTextManager.GetText("TypeItem") + TypeText[XArrangeConfigs.Types.Character] = function(templateId) + local characterType = XCharacterConfigs.GetCharacterType(templateId) + if characterType == XCharacterConfigs.CharacterType.Normal then + return CS.XTextManager.GetText("TypeCharacter") + elseif characterType == XCharacterConfigs.CharacterType.Isomer then + return CS.XTextManager.GetText("TypeIsomer") + end + end + TypeText[XArrangeConfigs.Types.Weapon] = CS.XTextManager.GetText("TypeWeapon") + TypeText[XArrangeConfigs.Types.Wafer] = CS.XTextManager.GetText("TypeWafer") + TypeText[XArrangeConfigs.Types.Fashion] = CS.XTextManager.GetText("TypeFashion") + TypeText[XArrangeConfigs.Types.Furniture] = CS.XTextManager.GetText("TypeFurniture") + TypeText[XArrangeConfigs.Types.HeadPortrait] = CS.XTextManager.GetText("TypeHeadPortrait") + TypeText[XArrangeConfigs.Types.ChatEmoji] = CS.XTextManager.GetText("TypeChatEmoji") +end + +function XUiDrawActivityLog:InitDrawLogListPanel() + local Rules = self.OrganizeRule or XGachaConfigs.GetGachaRuleCfgById(self.GachaId) + local gachaLogList = XDataCenter.GachaManager.GetGachaLogById(self.GachaId) + local name + local quality + local fromName + local time + local type + + local PanelObj = {} + PanelObj.Transform = self.Panel3.transform + XTool.InitUiObject(PanelObj) + + PanelObj.GridLogHigh.gameObject:SetActiveEx(false) + PanelObj.GridLogMid.gameObject:SetActiveEx(false) + PanelObj.GridLogLow.gameObject:SetActiveEx(false) + PanelObj.TxtEnsureCount.gameObject:SetActiveEx(false)--此处在加上逻辑以后改为根据是否抽干有限道具判断 + PanelObj.TxtLogCount.text = CS.XTextManager.GetText("DrawLogCpunt", DrawLogLimit) + --if Rules.SpecialBottomMin > 0 and Rules.SpecialBottomMax > 0 then + -- PanelObj.TxtEnsureCount.text = Rules.BottomText .. " " .. self.DrawInfo.BottomTimes .. "/(" .. Rules.SpecialBottomMin .. "~" .. Rules.SpecialBottomMax .. ")" + --else + -- PanelObj.TxtEnsureCount.text = Rules.BottomText .. " " .. self.DrawInfo.BottomTimes .. "/" .. self.DrawInfo.MaxBottomTimes + --end + + for _, v in pairs(gachaLogList) do + if v.RewardGoods.ConvertFrom ~= 0 then + local fromGoods = XGoodsCommonManager.GetGoodsShowParamsByTemplateId(v.RewardGoods.ConvertFrom) + local Goods = XGoodsCommonManager.GetGoodsShowParamsByTemplateId(v.RewardGoods.TemplateId) + quality = fromGoods.Quality + quality = quality or 1 + fromName = fromGoods.Name + if fromGoods.TradeName then + fromName = string.format("%s.%s", fromName,fromGoods.TradeName) + end + name = Goods.Name + time = TimestampToGameDateTimeString(v.GachaTime) + self:SetLogData(PanelObj, fromName, v.RewardGoods.ConvertFrom, name, time, quality) + else + local Goods = XGoodsCommonManager.GetGoodsShowParamsByTemplateId(v.RewardGoods.TemplateId) + quality = Goods.Quality + quality = quality or 1 + name = Goods.Name + if Goods.TradeName then + name = string.format("%s.%s", name,Goods.TradeName) + end + time = TimestampToGameDateTimeString(v.GachaTime) + self:SetLogData(PanelObj, name, v.RewardGoods.TemplateId, nil, time, quality) + end + end +end + +function XUiDrawActivityLog:SetLogData(obj, name, templateId, from, time, quality) + local itemType = XArrangeConfigs.GetType(templateId) + local go + if itemType == XArrangeConfigs.Types.Character then + if quality >= XItemConfigs.Quality.Three then + go = CS.UnityEngine.Object.Instantiate(obj.GridLogHigh, obj.PanelContent) + else + go = CS.UnityEngine.Object.Instantiate(obj.GridLogMid, obj.PanelContent) + end + else + if quality == XItemConfigs.Quality.Six then + go = CS.UnityEngine.Object.Instantiate(obj.GridLogHigh, obj.PanelContent) + elseif quality == XItemConfigs.Quality.Five then + go = CS.UnityEngine.Object.Instantiate(obj.GridLogMid, obj.PanelContent) + else + go = CS.UnityEngine.Object.Instantiate(obj.GridLogLow, obj.PanelContent) + end + end + + local tmpObj = {} + tmpObj.Transform = go.transform + tmpObj.GameObject = go.gameObject + XTool.InitUiObject(tmpObj) + tmpObj.TxtName.text = name + + if type(TypeText[itemType]) == "function" then + tmpObj.TxtType.text = TypeText[itemType](templateId) + else + tmpObj.TxtType.text = TypeText[itemType] + end + + if not from then + tmpObj.TxtTo.gameObject:SetActiveEx(false) + else + tmpObj.TxtTo.text = CS.XTextManager.GetText("ToOtherThing", from) + end + tmpObj.TxtTime.text = time + tmpObj.GameObject:SetActiveEx(true) +end + +function XUiDrawActivityLog:InitBaseRulePanel() + local rule = self.OrganizeRule or XGachaConfigs.GetGachaRuleCfgById(self.GachaId) + local baseRules = rule.BaseRules + local baseRuleTitles = rule.BaseRuleTitles + self:SetRuleData(baseRules, baseRuleTitles, self.Panel1) +end + +function XUiDrawActivityLog:SetRuleData(rules, ruleTitles, panel) + local PanelObj = {} + PanelObj.Transform = panel.transform + XTool.InitUiObject(PanelObj) + PanelObj.PanelTxt.gameObject:SetActiveEx(false) + for k, _ in pairs(rules) do + local go = CS.UnityEngine.Object.Instantiate(PanelObj.PanelTxt, PanelObj.PanelContent) + local tmpObj = {} + tmpObj.Transform = go.transform + tmpObj.GameObject = go.gameObject + XTool.InitUiObject(tmpObj) + tmpObj.TxtRuleTittle.text = ruleTitles[k] + rules[k] = string.gsub(rules[k], "\\n", "\n") + tmpObj.TxtRule.text = rules[k] + tmpObj.GameObject:SetActiveEx(true) + end +end + +function XUiDrawActivityLog:InitDrawPreview() + local PanelObj = {} + PanelObj.Transform = self.Panel2.transform + XTool.InitUiObject(PanelObj) + + PanelObj.TxtSp.gameObject:SetActiveEx(false) + PanelObj.TxtNor.gameObject:SetActiveEx(false) + + local list = XDataCenter.GachaManager.GetGachaProbShowById(self.GachaId) + if not list then + return + end + for i = 1, #list do + local go + if list[i].IsRare then + go = CS.UnityEngine.Object.Instantiate(PanelObj.TxtSp, PanelObj.PanelSpTxtParent) + else + go = CS.UnityEngine.Object.Instantiate(PanelObj.TxtNor, PanelObj.PanelNorTxtParent) + end + + local tmpObj = {} + tmpObj.Transform = go.transform + tmpObj.GameObject = go.gameObject + XTool.InitUiObject(tmpObj) + tmpObj.GameObject:SetActiveEx(true) + + if list[i].IsRare then + tmpObj.TxtName.text = list[i].Name + for index = 1, ProbMax do + local txtProbability = tmpObj[string.format("TxtProbability%d", index)] + if list[i].ProbShow[index] then + txtProbability.text = list[i].ProbShow[index] + txtProbability.gameObject:SetActiveEx(true) + else + txtProbability.gameObject:SetActiveEx(false) + end + end + else + tmpObj.TxtName.text = list[i].Name + tmpObj.TxtProbability.text = list[i].ProbShow[1] + end + + end + XScheduleManager.ScheduleOnce(function() + CS.UnityEngine.UI.LayoutRebuilder.ForceRebuildLayoutImmediate(PanelObj.PanelCardParent); + end, 0) +end + +function XUiDrawActivityLog:InitBtnTab() + self.TabGroup = self.TabGroup or {} + for i = 1, BtnMaxCount do + if not self.TabGroup[i] then + self.TabGroup[i] = self[string.format("BtnTab%d", i)] + end + end + self.PanelTabTc:Init(self.TabGroup, function(tabIndex) self:OnSelectedTog(tabIndex) end) + self.PanelTabTc:SelectIndex(self.SelectIndex) +end + +function XUiDrawActivityLog:OnBtnTanchuangClose() + self:Close() +end + +function XUiDrawActivityLog:OnSelectedTog(index) + for i = 1, BtnMaxCount do + self[string.format("Panel%d", i)].gameObject:SetActiveEx(false) + end + + self[string.format("Panel%d", index)].gameObject:SetActiveEx(true) + if not IsInit[index] then + InitFunctionList[index]() + IsInit[index] = true + end + + self:PlayAnimation(AnimeNames[index]) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGacha/XUiDrawActivityShow.lua b/Resources/Scripts/XUi/XUiGacha/XUiDrawActivityShow.lua new file mode 100644 index 00000000..338bd26c --- /dev/null +++ b/Resources/Scripts/XUi/XUiGacha/XUiDrawActivityShow.lua @@ -0,0 +1,502 @@ +local XUiDrawActivityShow = XLuaUiManager.Register(XLuaUi, "UiDrawActivityShow") +-- local drawShowWeapon = require("XUi/XUiDraw/XUiDrawTools/XUiDrawWeapon") +local drawShowEffect = require("XUi/XUiDraw/XUiDrawTools/XUiDrawShowEffect") +local drawScene = require("XUi/XUiDraw/XUiDrawTools/XUiDrawScene") +local QualityFive = 5 +local QualitySix = 6 + +function XUiDrawActivityShow:OnAwake() + self:InitAutoScript() +end + +function XUiDrawActivityShow:OnStart() + self.Animation = self.Transform:GetComponent("Animation") + self:InitImgRewards() +end + +function XUiDrawActivityShow:SetData(rewardList, resultCb, backGround) + self.BackGround = backGround + self.RewardList = rewardList + self.ResultCb = resultCb + + self:ResetState() + self:InitTools() + self.ShowIndex = 1 + self.IsOpening = false + self.CurLight = {} + self.PlayBoxAnim = false + self.BtnClick.gameObject:SetActiveEx(false) + self:InitDrawBackGround() + XUiHelper.SetDelayPopupFirstGet(true) +end + +function XUiDrawActivityShow:OnDisable() + self:HideAllEffect() + XUiHelper.SetDelayPopupFirstGet() +end + +function XUiDrawActivityShow:Update() + if self.PlayBoxAnim then + if self.PlayableDirector.time >= self.PlayableDirector.duration - 0.1 then + self:BoxAnimEnd() + end + end +end + +function XUiDrawActivityShow:InitImgRewards() + self.ImgRewards = {} + self.ImgRewards[XArrangeConfigs.Types.Character] = self.ImgCharacter + self.ImgRewards[XArrangeConfigs.Types.Fashion] = self.ImgItem + self.ImgRewards[XArrangeConfigs.Types.Item] = self.ImgItem + self.ImgRewards[XArrangeConfigs.Types.Wafer] = self.ImgWafer + self.ImgRewards[XArrangeConfigs.Types.Weapon] = self.ImgEquip + self.ImgRewards[XArrangeConfigs.Types.Furniture] = self.ImgItem + self.ImgRewards[XArrangeConfigs.Types.HeadPortrait] = self.ImgItem + self.ImgRewards[XArrangeConfigs.Types.ChatEmoji] = self.ImgItem +end + +function XUiDrawActivityShow:ResetState() + self.ImgCharacter.gameObject:SetActiveEx(false) + self.ImgItem.gameObject:SetActiveEx(false) + self.ImgWafer.gameObject:SetActiveEx(false) + self.ImgEquip.gameObject:SetActiveEx(false) + self.ImageItemPack.gameObject:SetActiveEx(false) + self.ImageWeaponPack.gameObject:SetActiveEx(false) + self.ImageCharacterPack.gameObject:SetActiveEx(false) + self.ImageWaferPack.gameObject:SetActiveEx(false) +end + +function XUiDrawActivityShow:InitTools() + --drawScene.AddObject(self.PanelWeapon, drawScene.Types.WEAPON) + --drawShowWeapon.SetNode(self.PanelAnim, self.PanelWeapon) + drawScene.SetActive(drawScene.Types.BOX, false) + drawScene.SetActive(drawScene.Types.BG, false) + XRTextureManager.SetTextureCache(self.RImgDrawCardShow) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiDrawActivityShow:InitAutoScript() + self:AutoAddListener() +end + +function XUiDrawActivityShow:AutoAddListener() + self:RegisterClickEvent(self.BtnClick, self.OnBtnClickClick) + self:RegisterClickEvent(self.BtnSkip, self.OnBtnSkipClick) +end +-- auto +function XUiDrawActivityShow:OnBtnClickClick() + if self.IsOpening then + self:ShowResult() + else + self:HideAllEffect() + self:NextPack() + end +end + +function XUiDrawActivityShow:OnBtnSkipClick() + self:ClearLastModel() + self:PlayEnd() +end + +function XUiDrawActivityShow:ShowWeapon() + drawScene.SetActive(drawScene.Types.WEAPON, true) +end + +function XUiDrawActivityShow:ShowResult() + XUiHelper.StopAnimation(false) + + local id = self:GetRewardId(self.ShowIndex) + local Type = self:GetRewardType(id) + local quality = self:GetQuality(id, Type) + + local showTable = XDataCenter.DrawManager.GetDrawShow(Type) + local skipEffect = XDrawConfigs.GetSkipEffect(showTable.DrawEffectGroupId[quality]) + self.CurPanelOpenUpEffect = self.PanelOpenUp:LoadPrefab(skipEffect) + self.CurPanelOpenUpEffect.gameObject.name = skipEffect + self.CurPanelOpenUpEffect.gameObject:SetActiveEx(true) + + self.IsOpening = false + self.Animation:Play(showTable.UiResultAnim) + -- if Type == XArrangeConfigs.Types.Weapon then + -- drawShowWeapon.PlayResultAnim() + -- end + + self.ShowIndex = self.ShowIndex + 1 +end + +function XUiDrawActivityShow:ClearLastModel() + if self.LastCharacterModel then + self.LastCharacterModel.gameObject:SetActiveEx(false) + self.LastCharacterModel = nil + end + + if self.LastWeaponModel then + self.LastWeaponModel.gameObject:SetActiveEx(false) + self.LastWeaponModel = nil + end +end + +function XUiDrawActivityShow:NextPack() + self.BtnClick.gameObject:SetActiveEx(false) + self:ClearLastModel() + if self.ShowIndex > #self.RewardList then + self:PlayEnd() + return + end + + if self.CvInfo then + self.CvInfo:Stop() + self.CvInfo = nil + end + self.Plane.gameObject:SetActiveEx(false) + local reward = self.RewardList[self.ShowIndex] + local id = reward.Id and reward.Id > 0 and reward.Id or reward.TemplateId + if reward.ConvertFrom > 0 then + id = reward.ConvertFrom + end + local Type = XTypeManager.GetTypeById(id) + local quality + local templateIdData = XGoodsCommonManager.GetGoodsShowParamsByTemplateId(id) + if Type == XArrangeConfigs.Types.Wafer then + quality = templateIdData.Star + elseif Type == XArrangeConfigs.Types.Weapon then + quality = templateIdData.Star + elseif Type == XArrangeConfigs.Types.Character then + quality = XCharacterConfigs.GetCharMinQuality(id) + else + quality = XTypeManager.GetQualityById(id) + end + + + local soundType = XSoundManager.UiBasicsMusic.UiDrawCard_Type.Normal + + if quality then + if quality == QualityFive then + soundType = XSoundManager.UiBasicsMusic.UiDrawCard_Type.FiveStar + elseif quality == QualitySix then + soundType = XSoundManager.UiBasicsMusic.UiDrawCard_Type.SixStar + end + end + + local icon + if Type == XArrangeConfigs.Types.Weapon or Type == XArrangeConfigs.Types.Furniture or Type == XArrangeConfigs.Types.HeadPortrait then + local goodsShowParams = XGoodsCommonManager.GetGoodsShowParamsByTemplateId(id) + icon = goodsShowParams.BigIcon + + if Type ~= XArrangeConfigs.Types.Weapon then + self.ImgRewards[Type]:SetRawImage(icon) + self.BtnClick.gameObject:SetActiveEx(true) + end + else + if Type == XArrangeConfigs.Types.Character then + icon = XDataCenter.CharacterManager.GetCharHalfBodyImage(id) + if quality < 3 then + soundType = XSoundManager.UiBasicsMusic.UiDrawCard_Type.FiveStar + elseif quality > 2 then + soundType = XSoundManager.UiBasicsMusic.UiDrawCard_Type.SixStar + end + elseif Type == XArrangeConfigs.Types.Wafer then + icon = XDataCenter.EquipManager.GetEquipLiHuiPath(id) + elseif Type == XArrangeConfigs.Types.Item then + icon = XDataCenter.ItemManager.GetItemBigIcon(id) + elseif Type == XArrangeConfigs.Types.Fashion then + icon = XDataCenter.FashionManager.GetFashionIcon(id) + elseif Type == XArrangeConfigs.Types.ChatEmoji then + icon = XDataCenter.ChatManager.GetEmojiIcon(id) + end + + if Type ~= XArrangeConfigs.Types.Character then + self.ImgRewards[Type]:SetRawImage(icon) + self.BtnClick.gameObject:SetActiveEx(true) + end + end + local curShowNum = self.ShowIndex + local showTable = XDataCenter.DrawManager.GetDrawShow(Type) + self.IsOpening = true + XUiHelper.StopAnimation(false) + XUiHelper.PlayAnimation(self, showTable.UiAnim, nil, function() + self.PanelCardShowOff.gameObject:SetActiveEx(true) + if self.GameObject.activeInHierarchy then + if curShowNum == self.ShowIndex then + local effect = XDrawConfigs.GetOpenUpEffect(showTable.DrawEffectGroupId[quality]) + self.CurPanelOpenUpEffect = self.PanelOpenUp.transform:Find(effect) + if self.CurPanelOpenUpEffect then + self.CurPanelOpenUpEffect.gameObject:SetActiveEx(false) + self.CurPanelOpenUpEffect.gameObject:SetActiveEx(true) + else + self.CurPanelOpenUpEffect = self.PanelOpenUp:LoadPrefab(effect) + self.CurPanelOpenUpEffect.gameObject.name = effect + self.CurPanelOpenUpEffect.gameObject:SetActiveEx(false) + self.CurPanelOpenUpEffect.gameObject:SetActiveEx(true) + end + end + if Type == XArrangeConfigs.Types.Character then + self:ShowCharacterModel(id) + elseif Type == XArrangeConfigs.Types.Weapon then + self:ShowWeaponModel(id) + end + XUiHelper.PlayAnimation(self, showTable.UiAnim .. "Item", nil, function() + if curShowNum == self.ShowIndex then + self.IsOpening = false + self.ShowIndex = self.ShowIndex + 1 + end + end) + end + + CS.XAudioManager.PlaySound(soundType.Show) + end) + + CS.XAudioManager.PlaySound(soundType.Start) + + local templeid = id + if XArrangeConfigs.Types.Furniture == reward.RewardType then + local cfg = XFurnitureConfigs.GetFurnitureReward(id) + if cfg and cfg.FurnitureId then + templeid = cfg.FurnitureId + end + end + self.TxtName.text = XTypeManager.GetNameById(templeid) + self.TxtType.text = showTable.TypeText + self.TxtQuality.text = showTable.QualityText[quality] + + --effect + self.PanelOpenUp.gameObject:SetActiveEx(true) + self.PanelOpenDown.gameObject:SetActiveEx(true) + + local effect = XDrawConfigs.GetOpenDownEffect(showTable.DrawEffectGroupId[quality]) + self.CurPanelOpenDownEffect = self.PanelOpenDown.transform:Find(effect) + if self.CurPanelOpenDownEffect then + self.CurPanelOpenDownEffect.gameObject:SetActiveEx(true) + else + self.CurPanelOpenDownEffect = self.PanelOpenDown:LoadPrefab(effect) + self.CurPanelOpenDownEffect.gameObject.name = effect + self.CurPanelOpenDownEffect.gameObject:SetActiveEx(true) + end +end + +function XUiDrawActivityShow:ShowWeaponModel(templateId) + local modelConfig = XDataCenter.EquipManager.GetWeaponModelCfg(templateId, self.Name, 0) + if modelConfig then + XModelManager.LoadWeaponModel(modelConfig.ModelId, self.WeaponRoot, modelConfig.TransformConfig, self.Name, function(model) + model.gameObject:SetActiveEx(true) + self.LastWeaponModel = model + self.BtnClick.gameObject:SetActiveEx(true) + end, { gameObject = self.GameObject }) + end +end + + +function XUiDrawActivityShow:ShowWeaponFashionModel(templateId) + local fashionId = XDataCenter.ItemManager.GetWeaponFashionId(templateId) + local modelConfig = XDataCenter.WeaponFashionManager.GetWeaponModelCfg(fashionId, nil, self.Name) + if modelConfig then + XModelManager.LoadWeaponModel(modelConfig.ModelId, self.WeaponRoot, modelConfig.TransformConfig, self.Name, function(model) + model.gameObject:SetActiveEx(true) + self.LastWeaponModel = model + self.BtnClick.gameObject:SetActiveEx(true) + end, { gameObject = self.GameObject }) + end +end + +function XUiDrawActivityShow:ShowCharacterModel(templateId,fashtionId) + if not templateId and not fashtionId then + return + end + + if not self.InitRoleMode then + self.InitRoleMode = true + self.RoleModelPanel = XUiPanelRoleModel.New(self.CharacterRoot, self.Name, true, false, false) + end + + local curCharacterId = templateId or XDataCenter.FashionManager.GetCharacterId(fashtionId) + local curFashtionId = fashtionId or XCharacterConfigs.GetCharacterTemplate(curCharacterId).DefaultNpcFashtionId + XDataCenter.DisplayManager.UpdateRoleModel(self.RoleModelPanel, curCharacterId, nil, curFashtionId) + + self.RoleModelPanel:UpdateCharacterModel(curCharacterId, self.CharacterRoot, XModelManager.MODEL_UINAME.XUiDrawShow, function(model) + CS.XAudioManager.PlaySound(XSoundManager.UiBasicsMusic.UiDrawCard_Chouka_Name) + model.gameObject:SetActiveEx(true) + + local animeID = XDataCenter.DrawManager.GetDrawShowCharacter(curCharacterId).AnimeID + local voiceId = XDataCenter.DrawManager.GetDrawShowCharacter(curCharacterId).VoiceId + + if animeID then + self.RoleModelPanel:PlayAnima(animeID) + end + + if voiceId then + self.CvInfo = CS.XAudioManager.PlayCv(voiceId) + end + + self.LastCharacterModel = model + self.BtnClick.gameObject:SetActiveEx(true) + end, nil, curFashtionId) +end + +function XUiDrawActivityShow:HideAllEffect() + if not XTool.UObjIsNil(self.PanelOpenUp) then + self.PanelOpenUp.gameObject:SetActiveEx(false) + end + if not XTool.UObjIsNil(self.PanelOpenDown) then + self.PanelOpenDown.gameObject:SetActiveEx(false) + end + if not XTool.UObjIsNil(self.PanelCardShowOff) then + self.PanelCardShowOff.gameObject:SetActiveEx(false) + end + if not XTool.UObjIsNil(self.CurPanelOpenUpEffect) then + self.CurPanelOpenUpEffect.gameObject:SetActiveEx(false) + end + if not XTool.UObjIsNil(self.CurPanelOpenDownEffect) then + self.CurPanelOpenDownEffect.gameObject:SetActiveEx(false) + end + if not XTool.UObjIsNil(self.CurPanelCardShowOffEffect) then + self.CurPanelCardShowOffEffect.gameObject:SetActiveEx(false) + end +end + +function XUiDrawActivityShow:PlayEnd() + XUiHelper.StopAnimation() + self.Plane.gameObject:SetActiveEx(true) + self.BtnClick.gameObject:SetActiveEx(true) + drawScene.SetActive(drawScene.Types.BOX, true) + if self.CurLight.gameObject then + self.CurLight.gameObject:SetActiveEx(false) + end + if self.CurLightLock and not XTool.UObjIsNil(self.CurLightLock.gameObject) then + self.CurLightLock.gameObject:SetActiveEx(false) + end + if self.CvInfo then + self.CvInfo:Stop() + self.CvInfo = nil + end + self:Close() + self.ResultCb() +end + +function XUiDrawActivityShow:OnDestroy() + drawScene.DestroyObject(drawScene.Types.EFFECT) + drawScene.DestroyObject(drawScene.Types.WEAPON) + drawScene.DestroyObject(drawScene.Types.SHOWBG) + drawShowEffect.Dispose() +end + +--wind +function XUiDrawActivityShow:InitDrawBackGround() + self.TxtType.text = "" + self.TxtName.text = "" + self.TxtQuality.text = "" + self.PanelInfo.gameObject:GetComponent("CanvasGroup").alpha = 0 + + self:PlayBoxAnimStart() +end + +function XUiDrawActivityShow:PlayBoxAnimStart() + self.PanelOpenUp = self.BackGround.transform:Find("ModelRoot/UiNearRoot/EffectRoot/PanelOpenUp") + self.PanelOpenDown = self.BackGround.transform:Find("ModelRoot/UiNearRoot/EffectRoot/PanelOpenDown") + self.PanelCardShowOff = self.BackGround.transform:Find("ModelRoot/UiNearRoot/EffectRoot/PanelCardShowOff") + self.WeaponRoot = self.BackGround.transform:Find("ModelRoot/UiNearRoot/WeaponRoot") + self.CharacterRoot = self.BackGround.transform:Find("ModelRoot/UiNearRoot/CharacterRoot") + self.Plane = self.BackGround.transform:Find("ModelRoot/UiFarRoot/Plane") + + local behaviour = self.GameObject:AddComponent(typeof(CS.XLuaBehaviour)) + if self.Update then + behaviour.LuaUpdate = function() self:Update() end + end + self.PlayableDirector = self.BackGround:GetComponent("PlayableDirector") + self.PlayableDirector:Play() + self.PlayBoxAnim = true + self.PanelBoxLight = self.BackGround.transform:Find("ModelRoot/UiNearRoot/PanelBox/PanelBoxLight") + self.PanelBoxLock = self.BackGround.transform:Find("ModelRoot/UiNearRoot/PanelBox/PanelBoxLock") + self.CurLight = self.PanelBoxLight:LoadPrefab(self:GetMaxQualityEffectName()) + self.CurLight.gameObject:SetActiveEx(true) + + if self.PanelBoxLock then + self.CurLightLock = self.PanelBoxLock:LoadPrefab(XUiConfigs.GetComponentUrl("UiDrawOpenBoxPre")) + self.CurLightLock.gameObject:SetActiveEx(true) + end +end + +function XUiDrawActivityShow:BoxAnimEnd() + self.PlayBoxAnim = false + self:NextPack() +end + +function XUiDrawActivityShow:GetQuality(id, type) + local quality + local templateIdData = XGoodsCommonManager.GetGoodsShowParamsByTemplateId(id) + if type == XArrangeConfigs.Types.Wafer then + quality = templateIdData.Star + elseif type == XArrangeConfigs.Types.Weapon then + quality = templateIdData.Star + elseif type == XArrangeConfigs.Types.Character then + quality = XCharacterConfigs.GetCharMinQuality(id) + else + quality = XTypeManager.GetQualityById(id) + end + return quality +end + +function XUiDrawActivityShow:GetRewardType(id) + local IsWeaponFashion = XDataCenter.ItemManager.IsWeaponFashion(id) + local Type = IsWeaponFashion and XArrangeConfigs.Types.WeaponFashion or XTypeManager.GetTypeById(id) + + return Type +end + +function XUiDrawActivityShow:GetRewardId(showIndex) + local reward = self.RewardList[showIndex] + local id = reward.Id and reward.Id > 0 and reward.Id or reward.TemplateId + if reward.ConvertFrom > 0 then + id = reward.ConvertFrom + end + return id +end + +--获取最高品级效果,按类型取每一类最大值,最后比较大小得出最大的类型和值 +function XUiDrawActivityShow:GetMaxQualityEffectName() + local maxByType = {} + + for k, v in pairs(XArrangeConfigs.Types) do + local maxQuality = 0 + for i = 1, #self.RewardList do + local id = self:GetRewardId(i) + local type = self:GetRewardType(id) + if type == v then + local tempQuality = self:GetQuality(id, type) + if tempQuality > maxQuality then + maxQuality = tempQuality + end + end + end + maxByType[k] = maxQuality + end + local maxEffectLevel = 1 + local maxEffectPath + for k, v in pairs(XArrangeConfigs.Types) do + if maxByType[k] > 0 then + local showTable = XDataCenter.DrawManager.GetDrawShow(v) + local effect = XDrawConfigs.GetOpenBoxEffect(showTable.DrawEffectGroupId[maxByType[k]]) + if tonumber(string.sub(effect, -8, -8)) > maxEffectLevel then + maxEffectLevel = tonumber(string.sub(effect, -8, -8)) + maxEffectPath = effect + end + end + end + return maxEffectPath +end + +function XUiDrawActivityShow:SetWeaponPos(target, config) + if not target or not config then + return + end + target.transform.localPosition = CS.UnityEngine.Vector3(config.PositionX, config.PositionY, config.PositionZ) + --检查数据 模型旋转 + target.transform.localEulerAngles = CS.UnityEngine.Vector3(config.RotationX, config.RotationY, config.RotationZ) + --检查数据 模型大小 + target.transform.localScale = CS.UnityEngine.Vector3( + config.ScaleX == 0 and 1 or config.ScaleX, + config.ScaleY == 0 and 1 or config.ScaleY, + config.ScaleZ == 0 and 1 or config.ScaleZ + ) +end +--windEnd \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGacha/XUiGachaOrganize/XUiGachaOrganize.lua b/Resources/Scripts/XUi/XUiGacha/XUiGachaOrganize/XUiGachaOrganize.lua new file mode 100644 index 00000000..ee62af68 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGacha/XUiGachaOrganize/XUiGachaOrganize.lua @@ -0,0 +1,432 @@ +local XUiGachaOrganize = XLuaUiManager.Register(XLuaUi, "UiGachaOrganize") + +local XUiGridGacha = require("XUi/XUiGacha/XUiGachaOrganize/XUiGridGacha") + +local MAX_GACHA_BTN_COUNT = 2 -- 抽卡按钮的数量 + +local NewUnlockGachaId -- 新解锁卡池的Id + +function XUiGachaOrganize:OnAwake() + self.IsCanGacha = true + + self.PreviewGridPool = {} -- XUiGridCommon池子 + self.UsePreviewGrid = {} -- 正在使用的XUiGridCommon + self.DrawButtonComponent = {} -- 抽卡按钮的控件{ Btn, TxtDrawDesc, TxtUseItemCount, ImgUseItemIcon} + + self:InitComponent() + self:AddListener() +end + +function XUiGachaOrganize:OnStart(organizeId, curGachaId, organizeRule) + self.OrganizeId = organizeId + self.OrganizeRule = organizeRule + self.TextName.text = organizeRule.GachaName or "" + self.TextName2.text = organizeRule.GachaName2 or "" + self.BtnDrawRule.gameObject:SetActiveEx(organizeRule.UiType == XGachaConfigs.UiType.Pay) + + self:GenerateGachas(curGachaId) + self:ChangeGacha(curGachaId) +end + +function XUiGachaOrganize:InitComponent() + for i = 1, MAX_GACHA_BTN_COUNT do + local btnName = "BtnDraw" .. i + local btn = XUiHelper.TryGetComponent(self.PanelDrawButtons, btnName, "Button") + if btn then + if not self.DrawButtonComponent[i] then + self.DrawButtonComponent[i] = {} + end + self.DrawButtonComponent[i].Btn = btn + self.DrawButtonComponent[i].TxtDrawDesc = btn.transform:Find("TxtDrawDesc"):GetComponent("Text") + self.DrawButtonComponent[i].TxtUseItemCount = btn.transform:Find("TxtUseItemCount"):GetComponent("Text") + self.DrawButtonComponent[i].ImgUseItemIcon = btn.transform:Find("ImgUseItemIcon"):GetComponent("RawImage") + end + end + self.TextTip.text = CS.XTextManager.GetText("GachaOrganizeRankTip") + + self.PanelGet.gameObject:SetActiveEx(false) + self.GridGacha.gameObject:SetActiveEx(false) + self.GridDrawActivity.gameObject:SetActiveEx(false) + self:InitDynamicTable() +end + +function XUiGachaOrganize:InitDynamicTable() + self.DynamicTable = XDynamicTableCurve.New(self.PanelGachaList) + self.DynamicTable:SetProxy(XUiGridGacha) + self.DynamicTable:SetDelegate(self) +end + + +-----------------------------------------------按钮响应函数--------------------------------------------------------------- + +function XUiGachaOrganize:AddListener() + self.BtnBack.CallBack = function() + self:OnBtnBackClick() + end + self.BtnMainUi.CallBack = function() + self:OnBtnMainUiClick() + end + self.BtnMore.CallBack = function() + self:OnBtnMore() + end + self.BtnUseItem.CallBack = function() + self:OnBtnUseItemClick() + end + self.BtnDrawRule.CallBack = function() + self:OnBtnDrawRuleClick() + end + if self.BtnSwitchNext then + self.BtnSwitchNext.CallBack = function() + self:OnSwitchGachaClick(true) + end + end + if self.BtnSwitchPre then + self.BtnSwitchPre.CallBack = function() + self:OnSwitchGachaClick() + end + end + for i, btnComponent in ipairs(self.DrawButtonComponent) do + btnComponent.Btn.CallBack = function() + self:OnDrawClick(i) + end + end +end + +function XUiGachaOrganize:OnBtnBackClick() + self:Close() +end + +function XUiGachaOrganize:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiGachaOrganize:OnBtnMore() + XLuaUiManager.Open("UiGachaPanelPreview", self.CurGachaId) +end + +function XUiGachaOrganize:OnBtnUseItemClick() + local data = XDataCenter.ItemManager.GetItem(self.GachaCfg.ConsumeId) + XLuaUiManager.Open("UiTip", data) +end + +function XUiGachaOrganize:OnBtnDrawRuleClick() + XLuaUiManager.Open("UiDrawActivityLog", self.CurGachaId, nil, self.OrganizeRule) +end + +function XUiGachaOrganize:OnSwitchGachaClick(isNext) + local index + if isNext then + index = self.SelectedIndex + else + index = self.SelectedIndex - 2 + end + self.DynamicTable.Imp:TweenToIndex(index) +end + +--- +--- 'btnIndex'是抽卡按钮在DrawButtonComponent上的索引,用来获取配置表上的抽卡次数配置 +function XUiGachaOrganize:OnDrawClick(btnIndex) + -- 卡池是否处于开放时间 + if not XDataCenter.GachaManager.CheckGachaIsOpenById(self.GachaCfg.Id, true, true) then + return + end + + -- 卡池状态是否正常 + local status = XDataCenter.GachaManager.GetOrganizeGachaStatus(self.OrganizeId, self.CurGachaId) + if status ~= XGachaConfigs.OrganizeGachaStatus.Normal then + if self.DrawButtonComponent[btnIndex].Btn.ButtonState == CS.UiButtonState.Normal then + XLog.Error("XUiGachaOrganize:OnDrawClick函数错误,卡池的状态为非正常,抽卡按钮的状态不应该是Normal") + end + if status == XGachaConfigs.OrganizeGachaStatus.Lock then + XUiManager.TipText("GachaOrganizeLockNotDraw") + elseif status == XGachaConfigs.OrganizeGachaStatus.SoldOut then + XUiManager.TipText("GachaOrganizeSoldOutNotDraw") + end + return + end + + -- 武器意识的背包容量是否足够 + if XDataCenter.EquipManager.CheckBoxOverLimitOfDraw() then + return + end + + local gachaCount = self.GachaCfg.BtnGachaCount[btnIndex] + local ownItemCount = XDataCenter.ItemManager.GetItem(self.GachaCfg.ConsumeId).Count + local lackItemCount = self.GachaCfg.ConsumeCount * gachaCount - ownItemCount + + -- 剩余次数是否足够 + local dtCount = XDataCenter.GachaManager.GetMaxCountOfAll() - XDataCenter.GachaManager.GetCurCountOfAll() + if dtCount < gachaCount and not XDataCenter.GachaManager.GetIsInfinite() then + XUiManager.TipMsg(CS.XTextManager.GetText("GachaIsNotEnough")) + return + end + + -- 货币是否足够 + if lackItemCount > 0 then + if self.OrganizeRule.ItemNotEnoughSkipId > 0 then + CsXUiManager.Instance:Open("UiDialog", CS.XTextManager.GetText("TipTitle"), + CS.XTextManager.GetText("GachaOrganizeNotEnoughSkipHint"), XUiManager.DialogType.Normal, nil, function() + XFunctionManager.SkipInterface(self.OrganizeRule.ItemNotEnoughSkipId) + end) + else + XUiManager.TipError(CS.XTextManager.GetText("GachaOrganizeDrawNotEnoughError")) + end + return + end + + if self.IsCanGacha then + self.IsCanGacha = false + XLuaUiManager.SetMask(true) + + local asyncPlayAnim = asynTask(self.PlayAnimation, self) + local cb = function(rewardList, newUnlockGachaId) + XDataCenter.AntiAddictionManager.BeginDrawCardAction() + RunAsyn(function() + asyncPlayAnim("PanelGetEnable") + + XLuaUiManager.Open("UiGachaOrganizeDrawResult", rewardList, function() + self:WhetherUnLockNewGacha() + end) + + NewUnlockGachaId = newUnlockGachaId + self.IsCanGacha = true + XLuaUiManager.SetMask(false) + self:RefreshItemCount() + self:RefreshGachaAfterDraw() + self:RefreshPreviewData() + self:RefreshDrawButton() + end) + end + local errorCb = function() + XLuaUiManager.SetMask(false) + self.IsCanGacha = true + end + + XDataCenter.GachaManager.DoGacha(self.GachaCfg.Id, gachaCount, cb, errorCb, self.OrganizeId) + end +end +------------------------------------------------------------------------------------------------------------------------ + + +--- +--- 设置动态列表的DataSource,生成卡池 +function XUiGachaOrganize:GenerateGachas(curGachaId) + self.DataSource = XGachaConfigs.GetOrganizeGahcaIdList(self.OrganizeId) + + -- SelectedIndex为打开时默认选择的卡池在DataSource中的索引 + for index, id in ipairs(self.DataSource) do + if id == curGachaId then + self.SelectedIndex = index + break + end + end + if not self.SelectedIndex then + self.SelectedIndex = 1 + end + + self.DynamicTable:SetDataSource(self.DataSource) + self.DynamicTable:ReloadData(#self.DataSource > 0 and (self.SelectedIndex - 1) or -1) +end + + +-----------------------------------------------刷新界面------------------------------------------------------------------ + +--- +--- 动态列表的index从0开始 +--- self.SelectedIndex从1开始 +function XUiGachaOrganize:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local i = index + 1 + grid:Refresh(self.OrganizeId, self.DataSource[i]) + + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + self.DynamicTable.Imp:TweenToIndex(index) + + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_TWEEN_OVER then + -- 切换卡池时请求卡池的奖励库存与掉落信息 + local startIndex = self.DynamicTable.Imp.StartIndex + local selectIndex = startIndex + 1 + XDataCenter.GachaManager.GetGachaRewardInfoRequest(self.DataSource[selectIndex], function() + -- 先更改SelectIndex,再更改CurGachaId,最后刷新界面,有GET_GACHA_DATA_INTERVAL秒的间隔时间限制 + if self.SelectedIndex ~= selectIndex then + self.SelectedIndex = selectIndex + self:ChangeGacha(self.DataSource[selectIndex]) + end + end) + end +end + +--- +--- 抽卡后检测是否解锁了新卡池 +function XUiGachaOrganize:WhetherUnLockNewGacha() + if NewUnlockGachaId then + -- SelectedIndex比动态列表的Index多1,所以会跳去下一个新解锁的卡池中 + self.DynamicTable.Imp:TweenToIndex(self.SelectedIndex) + NewUnlockGachaId = nil + end +end + +--- +--- 切换卡池,刷新界面 +---@param gachaId number +function XUiGachaOrganize:ChangeGacha(gachaId) + self.CurGachaId = gachaId + self.GachaCfg = XGachaConfigs.GetGachaCfgById(gachaId) + + -- 刷新序号 + local index + if self.SelectedIndex < 10 then + index = string.format("%s%s", "0", tostring(self.SelectedIndex)) + else + index.tostring(self.SelectedIndex) + end + self.TxtRank.text = index + + if self.BtnSwitchNext then + self.BtnSwitchNext.gameObject:SetActiveEx(not (self.SelectedIndex >= #self.DataSource)) + end + + if self.BtnSwitchPre then + self.BtnSwitchPre.gameObject:SetActiveEx(not (self.SelectedIndex <= 1)) + end + + -- 刷新代币 + local icon = XDataCenter.ItemManager.GetItemBigIcon(self.GachaCfg.ConsumeId) + self.ImgUseItemIcon:SetRawImage(icon) + self:RefreshItemCount() + + -- 刷新抽奖按钮 + self:RefreshDrawButton() + + -- 生成奖励 + self:GeneratePreview() + self:PlayAnimation("QieHuan") +end + +--- +--- 刷新代币数量 +--- 抽卡、切换卡池时刷新 +function XUiGachaOrganize:RefreshItemCount() + self.TxtUseItemCount.text = XDataCenter.ItemManager.GetItem(self.GachaCfg.ConsumeId).Count +end + +--- +--- 刷新抽奖按钮 +--- 抽卡、切换卡池时刷新 +function XUiGachaOrganize:RefreshDrawButton() + local isLock = false + local status = XDataCenter.GachaManager.GetOrganizeGachaStatus(self.OrganizeId, self.CurGachaId) + if status ~= XGachaConfigs.OrganizeGachaStatus.Normal then + isLock = true + end + for i, btnComponent in ipairs(self.DrawButtonComponent) do + local gachaCount = self.GachaCfg.BtnGachaCount[i] + btnComponent.TxtDrawDesc.text = CS.XTextManager.GetText("GachaOrganizeDrawCount", gachaCount) + btnComponent.TxtUseItemCount.text = gachaCount * self.GachaCfg.ConsumeCount + + local useItemIcon = XDataCenter.ItemManager.GetItemBigIcon(self.GachaCfg.ConsumeId) + btnComponent.ImgUseItemIcon:SetRawImage(useItemIcon) + btnComponent.Btn:SetDisable(isLock) + end +end + +--- +--- 生成预览奖励 +--- 更换卡池时刷新 +function XUiGachaOrganize:GeneratePreview() + -- 回收格子 + for _, grid in pairs(self.UsePreviewGrid) do + local gridGO = grid.GameObject + if gridGO.activeSelf then + gridGO:SetActiveEx(false) + table.insert(self.PreviewGridPool, grid) + end + end + self.UsePreviewGrid = {} + + -- 生成奖励预览 + local count = 1 + local gachaRewardInfo = XDataCenter.GachaManager.GetGachaRewardInfoById(self.CurGachaId) + for k, v in pairs(gachaRewardInfo) do + if count > self.OrganizeRule.PreviewShowCount then + break + end + + if v.Rare then + -- 取出格子 + local grid + if next(self.PreviewGridPool) then + grid = table.remove(self.PreviewGridPool, 1) + else + local obj = CS.UnityEngine.Object.Instantiate(self.GridDrawActivity, self.PreviewContent) + grid = XUiGridCommon.New(self, obj) + end + + -- 刷新信息 + if grid then + local tmpData = {} + tmpData.TemplateId = v.TemplateId + tmpData.Count = v.Count + + local curCount + if v.RewardType == XGachaConfigs.RewardType.Count then + curCount = v.CurCount + end + grid:Refresh(tmpData, nil, nil, nil, curCount) + grid.GameObject:SetActiveEx(true) + + self.UsePreviewGrid[k] = grid + count = count + 1 + end + end + end + + -- 刷新次数 + self:RefreshPreviewCount() + self.PanelNumber.gameObject:SetActiveEx(not XDataCenter.GachaManager.GetIsInfinite()) +end + +--- +--- 刷新奖励库存 +--- 抽卡时刷新 +function XUiGachaOrganize:RefreshPreviewData() + local gachaRewardInfo = XDataCenter.GachaManager.GetGachaRewardInfoById(self.CurGachaId) + + -- 刷新奖励格子 + for k, v in pairs(self.UsePreviewGrid or {}) do + local tmpData = {} + tmpData.TemplateId = gachaRewardInfo[k].TemplateId + tmpData.Count = gachaRewardInfo[k].Count + + local curCount + if gachaRewardInfo[k].RewardType == XGachaConfigs.RewardType.Count then + curCount = gachaRewardInfo[k].CurCount + end + v:Refresh(tmpData, nil, nil, nil, curCount) + end + + -- 刷新次数 + self:RefreshPreviewCount() +end + +--- +--- 刷新卡池奖励进度 +--- 抽卡、切换卡池时刷新 +function XUiGachaOrganize:RefreshPreviewCount() + local curCount = XDataCenter.GachaManager.GetCurCountOfAll() + local maxCount = XDataCenter.GachaManager.GetMaxCountOfAll() + local countStr = CS.XTextManager.GetText("GachaAlreadyobtainedCount", curCount, maxCount) + + self.TxtNumber.text = countStr + self.ImgJd.fillAmount = curCount / maxCount +end + +--- +--- 刷新所有卡池 +--- 抽卡时刷新 +function XUiGachaOrganize:RefreshGachaAfterDraw() + local grids = self.DynamicTable:GetGrids() + for _, grid in pairs(grids) do + grid:AfterDrawRefresh() + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGacha/XUiGachaOrganize/XUiGachaOrganizeDrawResult.lua b/Resources/Scripts/XUi/XUiGacha/XUiGachaOrganize/XUiGachaOrganizeDrawResult.lua new file mode 100644 index 00000000..774dc310 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGacha/XUiGachaOrganize/XUiGachaOrganizeDrawResult.lua @@ -0,0 +1,165 @@ +local XUiGachaOrganizeDrawResult = XLuaUiManager.Register(XLuaUi, "UiGachaOrganizeDrawResult") + +local MODE_LOOP = 1 + +function XUiGachaOrganizeDrawResult:OnAwake() + self.SpecialSoundMap = {} + self.AutoCreateListeners = {} + self:AddListener() +end + +function XUiGachaOrganizeDrawResult:AddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) +end + +function XUiGachaOrganizeDrawResult:OnStart(rewardList, backCb) + local behaviour = self.GameObject:AddComponent(typeof(CS.XLuaBehaviour)) + if self.Update then + behaviour.LuaUpdate = function() self:Update() end + end + self.ShowInterval = 0.2 + self.StartShow = false + self.LastShowTime = 0 + self.ShowIndex = 1 + + self.TarnsInterval = 0.4 + self.StartTrans = false + self.LastTarnsTime = 0 + self.TransIndex = 1 + self.TransNum = 0 + self.GridObj = {} + + self.GridGain.gameObject:SetActiveEx(false) + self.PanelTrans.gameObject:SetActiveEx(false) + self.RewardList = rewardList + self:SetupRewards() + self.BackCb = backCb + self.IsFinish = false + self.BtnBack.gameObject.transform:SetAsLastSibling() + self:PlayAnimation("AniResultGridGain", function() + self:PlayAnimation("AniResultGridGainLoop") + self.AniResultGridGainLoop.extrapolationMode = MODE_LOOP + self.StartShow = true + end) +end + +function XUiGachaOrganizeDrawResult:Update() + if self.StartShow then + if self.ShowIndex > #self.RewardList then + self.StartShow = false + self.StartTrans = true + self.LastTarnsTime = CS.UnityEngine.Time.time + else + if CS.UnityEngine.Time.time - self.LastShowTime > self.ShowInterval then + self:ShowResult() + end + end + elseif self.StartTrans then + if CS.UnityEngine.Time.time - self.LastShowTime > self.ShowInterval then + if self.TransIndex > self.TransNum then + self.IsFinish = true + self.StartTrans = false + self.BtnBack.gameObject.transform:SetAsFirstSibling() + else + if CS.UnityEngine.Time.time - self.LastTarnsTime > self.TarnsInterval then + self:ShowTrans() + end + end + end + end +end + +function XUiGachaOrganizeDrawResult:OnEnable() + XUiHelper.PopupFirstGet() +end + +function XUiGachaOrganizeDrawResult:OnDisable() + XDataCenter.AntiAddictionManager.EndDrawCardAction() +end + +function XUiGachaOrganizeDrawResult:GetAutoKey(uiNode, eventName) + if not uiNode then + return + end + return eventName .. uiNode:GetHashCode() +end + +function XUiGachaOrganizeDrawResult:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then + return + end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiGachaOrganizeDrawResult:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiGachaOrganizeDrawResult:OnBtnBackClick() + if self.IsFinish then + XUiHelper.StopAnimation(self, "AniResultGridGainLoop") + if self.BackCb then + self.BackCb() + end + self:Close() + end +end + +function XUiGachaOrganizeDrawResult:SetupRewards() + for i = 1, #self.RewardList do + local ui = CS.UnityEngine.Object.Instantiate(self.GridGain) + local grid = XUiGridCommon.New(self, ui) + grid.Transform:SetParent(self.PanelGainList, false) + --被转化物品 + if self.RewardList[i].ConvertFrom ~= 0 then + self.TransNum = self.TransNum + 1 + grid:Refresh(self.RewardList[i].ConvertFrom) + else + grid:Refresh(self.RewardList[i]) + end + table.insert(self.GridObj, grid) + grid.GameObject:SetActiveEx(false) + end +end + +function XUiGachaOrganizeDrawResult:ShowResult() + self.GridObj[self.ShowIndex].GameObject:SetActiveEx(true) + self.GridObj[self.ShowIndex].GameObject:PlayTimelineAnimation() + CS.XAudioManager.PlaySound(XSoundManager.UiBasicsMusic.UiDrawCard_Reward_Normal) + self.LastShowTime = CS.UnityEngine.Time.time + self.ShowIndex = self.ShowIndex + 1 +end + +--已经拥有的角色转换碎片过程 +function XUiGachaOrganizeDrawResult:ShowTrans() + local count = 0 + for i = 1, #self.RewardList do + if self.RewardList[i].ConvertFrom ~= 0 then + count = count + 1 + if count == self.TransIndex then + self.GridObj[i]:Refresh(self.RewardList[i]) + local tempTransEffect = CS.UnityEngine.Object.Instantiate(self.PanelTrans) + tempTransEffect.transform:SetParent(self.PanelContent, false) + tempTransEffect.gameObject:SetActiveEx(true) + tempTransEffect.transform.localPosition = self.GridObj[i].GameObject.transform.localPosition + self.PanelGainList.transform.localPosition + CS.XAudioManager.PlaySound(XSoundManager.UiBasicsMusic.UiDrawCard_Reward_Suipian) + end + end + end + self.LastTarnsTime = CS.UnityEngine.Time.time + self.TransIndex = self.TransIndex + 1 +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGacha/XUiGachaOrganize/XUiGachaPanelPreview.lua b/Resources/Scripts/XUi/XUiGacha/XUiGachaOrganize/XUiGachaPanelPreview.lua new file mode 100644 index 00000000..59808fe5 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGacha/XUiGachaOrganize/XUiGachaPanelPreview.lua @@ -0,0 +1,67 @@ +local XUiGachaPanelPreview = XLuaUiManager.Register(XluaUi,"UiGachaPanelPreview") + +function XUiGachaPanelPreview:OnAwake() + self.PreviewList = {} + + self:AddListener() + self:InitComponent() +end + +function XUiGachaPanelPreview:InitComponent() + self.GridDrawActivity.gameObject:SetActiveEx(false) +end + +function XUiGachaPanelPreview:OnStart(gachaId) + local gachaRewardInfo = XDataCenter.GachaManager.GetGachaRewardInfoById(gachaId) + + -- 生成奖励格子 + for k, v in pairs(gachaRewardInfo) do + local go + local parent + + -- 实例化控件 + if v.Rare and self.PanelDrawItemSP then + parent = self.PanelDrawItemSP + elseif (not v.Rare) and self.PanelDrawItemNA then + parent = self.PanelDrawItemNA + end + if parent then + go = CS.UnityEngine.Object.Instantiate(self.GridDrawActivity, parent) + end + + -- 实例化脚本 + if go then + local item = XUiGridCommon.New(self, go) + self.PreviewList[k] = item + + local tmpData = {} + tmpData.TemplateId = v.TemplateId + tmpData.Count = v.Count + + local curCount + if v.RewardType == XGachaConfigs.RewardType.Count then + curCount = v.CurCount + end + item:Refresh(tmpData, nil, nil, nil, curCount) + item.GameObject:SetActiveEx(true) + end + end + + -- 刷新次数 + local countStr = CS.XTextManager.GetText("GachaAlreadyobtainedCount", + XDataCenter.GachaManager.GetCurCountOfAll(), XDataCenter.GachaManager.GetMaxCountOfAll()) + self.TxetFuwenben.text = countStr + self.PanelTxt.gameObject:SetActiveEx(not XDataCenter.GachaManager.GetIsInfinite()) +end + + +-----------------------------------------------按钮响应函数------------------------------------------------------ + +function XUiGachaPanelPreview:AddListener() + self.BtnPreviewConfirm.CallBack = function() + self:Close() + end + self.BtnPreviewClose.CallBack = function() + self:Close() + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGacha/XUiGachaOrganize/XUiGridGacha.lua b/Resources/Scripts/XUi/XUiGacha/XUiGachaOrganize/XUiGridGacha.lua new file mode 100644 index 00000000..1cea48bc --- /dev/null +++ b/Resources/Scripts/XUi/XUiGacha/XUiGachaOrganize/XUiGridGacha.lua @@ -0,0 +1,66 @@ +local XUiGridGacha = XClass(nil, "XUiGridGacha") + +function XUiGridGacha:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + self:InitComponent() +end + +function XUiGridGacha:InitComponent() + self.Normal.gameObject:SetActiveEx(false) + self.Disable.gameObject:SetActiveEx(true) + + self.ImgSuo.gameObject:SetActiveEx(true) + self.GridCondition.gameObject:SetActiveEx(false) + self.TxtKcbz.gameObject:SetActiveEx(false) + + local text = CS.XTextManager.GetText("GachaOrganizeUnlockTips") + self.TxtCondition.text = string.gsub(text, "\\n", "\n") +end + +function XUiGridGacha:Refresh(organizeId, gachaId) + self.OrganizeId = organizeId + self.GachaId = gachaId + + local icon = XGachaConfigs.GetOrganizeGachaIcon(gachaId) + if icon then + self.RImgCoverSelect:SetRawImage(icon) + self.RImgCoverNotSelect:SetRawImage(icon) + end + + local status = XDataCenter.GachaManager.GetOrganizeGachaStatus(organizeId, gachaId) + if status == XGachaConfigs.OrganizeGachaStatus.Normal then + -- 正常,可抽卡 + self.Normal.gameObject:SetActiveEx(true) + self.Disable.gameObject:SetActiveEx(false) + else + -- 不可抽卡 + self.Normal.gameObject:SetActiveEx(false) + self.Disable.gameObject:SetActiveEx(true) + + if status == XGachaConfigs.OrganizeGachaStatus.Lock then + -- 锁定 + self.ImgSuo.gameObject:SetActiveEx(true) + self.GridCondition.gameObject:SetActiveEx(true) + self.TxtKcbz.gameObject:SetActiveEx(false) + + elseif status == XGachaConfigs.OrganizeGachaStatus.SoldOut then + -- 售罄 + self.ImgSuo.gameObject:SetActiveEx(false) + self.GridCondition.gameObject:SetActiveEx(false) + self.TxtKcbz.gameObject:SetActiveEx(true) + else + XLog.Error(string.format("XUiGridGacha:Refresh函数错误,%s不属于XGachaConfigs.OrganizeGachaStatuso类型", + tostring(status))) + return + end + end +end + +function XUiGridGacha:AfterDrawRefresh() + self:Refresh(self.OrganizeId, self.GachaId) +end + +return XUiGridGacha \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGameNotice/XHtmlHandler.lua b/Resources/Scripts/XUi/XUiGameNotice/XHtmlHandler.lua new file mode 100644 index 00000000..221bc204 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGameNotice/XHtmlHandler.lua @@ -0,0 +1,464 @@ +local strlen = string.len +local strFormat = string.format +local strFind = string.find +local mathFloor = math.floor +local tableInsert = table.insert +local next = next + +local MdediumFontSize = CS.XGame.ClientConfig:GetInt("NoticeMediumFontSize") + +local NodeType = { + Head = 1, + Tail = 2, +} + +local ParagraphType = { + Pic = 1, + Text = 2, +} + +local FontSizeMap = { + ["xx-small"] = mathFloor(MdediumFontSize * 0.6), + ["x-small"] = mathFloor(MdediumFontSize * 0.75), + ["small"] = mathFloor(MdediumFontSize * 0.89), + ["medium"] = MdediumFontSize, + ["large"] = mathFloor(MdediumFontSize * 1.2), + ["x-large"] = mathFloor(MdediumFontSize * 1.5), + ["xx-large"] = mathFloor(MdediumFontSize * 2), +} + +local FontSizeNumMap = { + [1] = mathFloor(MdediumFontSize * 0.6), + [2] = mathFloor(MdediumFontSize * 0.75), + [3] = mathFloor(MdediumFontSize * 0.89), + [4] = MdediumFontSize, + [5] = mathFloor(MdediumFontSize * 1.2), + [6] = mathFloor(MdediumFontSize * 1.5), + [7] = mathFloor(MdediumFontSize * 2), +} + +local HtmlCharMap = { + ["""] = "\"", + ["&"] = "&", + ["<"] = "<", + [">"] = ">", + [" "] = " ", + ["
"] = "\n", +} + +local AlignMap = { + ["center"] = CS.UnityEngine.TextAnchor.MiddleCenter, + ["left"] = CS.UnityEngine.TextAnchor.MiddleLeft, + ["right"] = CS.UnityEngine.TextAnchor.MiddleRight, + ["justify"] = CS.UnityEngine.TextAnchor.MiddleLeft, +} + + +local function FilterSpecialSymbol(content) + if not content then + return + end + return content:gsub("[%(%)%.%%%+%-%*%?%[%]%^%$]", function(symbol) + return "%" .. symbol + end) +end + +local function RemoveBlank(content) + if not content then + return + end + return content:gsub("^[ \t\n\r]+", ""):gsub("[ \t\n\r]+$", "") +end + +local function RemoveNewLine(content) + return content:gsub("\n", " ") +end + +local function RemoveInvalidChar(content) + if not content then + return "" + end + + return content:gsub("", ""):gsub("", ""):gsub("", "") +end + +local function GetBody(content) + local i, _, _, subContent = strFind(content, "]-)>(.-)") + if not i then + return "" + end + + return subContent +end + +local function GetImg(content) + local _, _, _, imgType, imgData = strFind(content, "%s]+)(%s-)(.-)>") + if tag then + local nodeType + if tag:sub(1, 1) == "/" then + nodeType = NodeType.Tail + tag = tag:sub(2) + else + nodeType = NodeType.Head + end + + tableInsert(tagList, { NodeType = nodeType, BeginPos = i + nextOffset, EndPos = j + nextOffset, Tag = tag, Param = param }) + + if j == #tempContent then + return + end + + nextOffset = nextOffset + j + tempContent = tempContent:sub(j + 1) + else + return + end + count = count + 1 + end +end + +local function Match(tagList, matchedList) + -- 构建tag匹配关系 + local matchingList = {} + for _, v in ipairs(tagList) do + if v.NodeType == NodeType.Head then + tableInsert(matchingList, v) + elseif v.NodeType == NodeType.Tail then + for j = #matchingList, 1, -1 do + local head = matchingList[j] + table.remove(matchingList, j) + if v.Tag == head.Tag then + tableInsert(matchedList, { Head = head, Tail = v }) + break + end + end + end + end + + table.sort(matchedList, function(l, r) + return l.Head.BeginPos < r.Head.BeginPos + end) +end + +local CreateChilds +CreateChilds = function(parent, matchedList) + if not parent then + return + end + + local count = 0 + while #matchedList > 0 or count > 10000 do + local curNode = matchedList[1] + if parent.Tail.EndPos > curNode.Tail.EndPos then + parent.Childs = parent.Childs or {} + table.remove(matchedList, 1) + tableInsert(parent.Childs, curNode) + CreateChilds(curNode, matchedList) + else + return + end + count = count + 1 + end +end + +local function CreateTree(matchedList, tagTree) + local count = 0 + while #matchedList > 0 or count > 10000 do + local curNode = matchedList[1] + table.remove(matchedList, 1) + CreateChilds(curNode, matchedList) + tableInsert(tagTree, curNode) + count = count + 1 + end + + return tagTree +end + +local function GetNodeStyle(node, content, defaultStyle) + local style = {} + + local nodeParam = content:sub(node.Head.BeginPos, node.Head.EndPos) + local tag = FilterSpecialSymbol(node.Head.Tag) + local _, _, _, paramStr = strFind(nodeParam, "<" .. tag .. "(%s-)(.-)>") + + local findColor = false + local findSize = false + if not string.IsNilOrEmpty(paramStr) then + local _, _, styleParamStr = strFind(paramStr, "style=\"(.-)\"") + if not string.IsNilOrEmpty(styleParamStr) then + local _, _, _, colorR, _, colorG, _, colorB = strFind(styleParamStr, "color:(%s-)rgb%((%d+),(%s-)(%d+),(%s-)(%d+)%)") + if colorR and colorG and colorB then + findColor = true + style.ColorStr = ConverRGB2Hex(colorR, colorG, colorB) + end + + local _, _, _, fontSize = strFind(styleParamStr, "font%-size:(%s-)(.-);") + if fontSize then + findSize = true + style.FontSize = RemoveBlank(fontSize) + end + + local isBlod = strFind(styleParamStr, "font%-weight:(%s-)bold") + if isBlod then + style.IsBlod = isBlod + end + end + + if node.Head.Tag == "font" then + if not findColor then + local _, _, colorStr = strFind(paramStr, "color=\"#(.-)\"") + style.ColorStr = colorStr + end + + if not findSize and node.Head.Tag == "font" then + local _, _, fontSize = strFind(paramStr, "size=\"(.-)\"") + style.FontSize = fontSize + end + end + end + + style.ColorStr = style.ColorStr or defaultStyle.ColorStr + style.FontSize = style.FontSize or defaultStyle.FontSize + style.IsBlod = defaultStyle.IsBlod or style.IsBlod or node.Head.Tag == "b" + + if node.Head.Tag == "a" then + style.IsHref = true + local _, _, hrefParam = string.find(paramStr, "href=\"(.-)\"") + if hrefParam then + style.HrefParam = hrefParam + end + else + style.IsHref = defaultStyle.IsHref + end + + return style +end + +local InitTextNode +InitTextNode = function(node, content, defaultStyle, textNodes) + local style = GetNodeStyle(node, content, defaultStyle) + + local lastEndPos = node.Head.EndPos + if node.Childs then + for _, child in ipairs(node.Childs) do + if child.Head.BeginPos - lastEndPos > 1 then + local text = content:sub(lastEndPos + 1, child.Head.BeginPos - 1) + text = RemoveNewLine(text) + if not string.IsNilOrEmpty(text) then + tableInsert(textNodes, { Text = text, Style = style }) + end + end + + lastEndPos = child.Tail.EndPos + InitTextNode(child, content, style, textNodes) + end + end + + if node.Tail.BeginPos - lastEndPos > 1 then + local text = content:sub(lastEndPos + 1, node.Tail.BeginPos - 1) + text = RemoveNewLine(text) + if not string.IsNilOrEmpty(text) then + tableInsert(textNodes, { Text = text, Style = style }) + end + end +end + +local function CreateTextNode(paragraph, content) + local textNodes = {} + local tagTree = paragraph.Childs or {} + + if #tagTree <= 0 then + if paragraph.Tail.BeginPos - paragraph.Head.EndPos > 1 then + table.insert(textNodes, { Text = content:sub(paragraph.Head.EndPos + 1, paragraph.Tail.BeginPos - 1) }) + end + end + + for i = 1, #tagTree do + if i == 1 then + if tagTree[i].Head.BeginPos - paragraph.Head.EndPos > 1 then + local tempText = content:sub(paragraph.Head.EndPos + 1, tagTree[i].Head.BeginPos - 1) + if not string.IsNilOrEmpty(tempText) then + table.insert(textNodes, { Text = tempText }) + end + end + else + if tagTree[i].Head.BeginPos - tagTree[i - 1].Head.EndPos > 1 then + local tempText = content:sub(tagTree[i - 1].Tail.EndPos + 1, tagTree[i].Head.BeginPos - 1) + if not string.IsNilOrEmpty(tempText) then + table.insert(textNodes, { Text = tempText }) + end + end + end + + InitTextNode(tagTree[i], content, {}, textNodes) + end + + if #tagTree > 0 then + if paragraph.Tail.BeginPos - tagTree[#tagTree].Tail.EndPos > 1 then + local tempText = content:sub(tagTree[#tagTree].Tail.EndPos + 1, paragraph.Tail.BeginPos - 1) + if not string.IsNilOrEmpty(tempText) then + table.insert(textNodes, { Text = tempText }) + end + end + end + + return textNodes +end + +local function GenerateText(textNodes) + local lastNode = textNodes[#textNodes] + lastNode.Text = RemoveNewLine(lastNode.Text) + + if lastNode.Text:sub(-4) == "
" then + if lastNode.Text == "
" then + lastNode.Text = "" + else + lastNode.Text = lastNode.Text:sub(1, -5) + end + end + + local fontSize + local str = "" + local sourceStr = "" + for _, v in ipairs(textNodes) do + local tempStr = CS.XTool.ReplaceNoBreakingSpace(RemoveNewLine(v.Text)) + sourceStr = sourceStr .. tempStr + if v.Style then + if v.Style.IsHref then + local hrefParam = v.Style.HrefParam or "" + tempStr = "
" .. tempStr .. "" + end + + if v.Style.FontSize then + local fontSizePx = FontSizeMap[v.Style.FontSize] or FontSizeNumMap[tonumber(v.Style.FontSize)] + if fontSizePx then + tempStr = "" .. tempStr .. "" + + if not fontSize then + fontSize = fontSizePx + else + if fontSizePx > fontSize then + fontSize = fontSizePx + end + end + end + end + + if v.Style.IsBlod then + tempStr = "" .. tempStr .. "" + end + + if v.Style.ColorStr and not v.Style.IsHref then + tempStr = "" .. tempStr .. "" + end + end + + str = str .. tempStr + end + + for k, v in pairs(HtmlCharMap) do + str = str:gsub(k, v) + sourceStr = sourceStr:gsub(k, v) + end + + return str, sourceStr, fontSize or FontSizeMap["xx-large"] +end + +local function CreateParagraph(paragraph, content) + local tempContent = content:sub(paragraph.Head.EndPos + 1, paragraph.Tail.BeginPos - 1) + local _, imgData = GetImg(tempContent) + if imgData then + local texture = CS.UnityEngine.Texture2D(1, 1) + texture:LoadImage(CS.System.Convert.FromBase64String(imgData)) + return { Type = ParagraphType.Pic, Data = texture } + end + + -- 文本段落 + local textNodes = CreateTextNode(paragraph, content) + if not textNodes or not next(textNodes) then + return + end + + local text, sourceText, fontSize = GenerateText(textNodes) + + return { Type = ParagraphType.Text, + Data = text, + SourceData = sourceText, + FontSize = fontSize, + Param = content:sub(paragraph.Head.BeginPos + 1, paragraph.Head.EndPos - 1) } +end + +local function Deserilize(html) + local content = RemoveInvalidChar(html) + if string.IsNilOrEmpty(content) then + return + end + + local bodyContent = GetBody(content) + if string.IsNilOrEmpty(bodyContent) then + return + end + + local tagList = {} + InitAllTagList(bodyContent, tagList) + + local matchedList = {} + Match(tagList, matchedList) + + local tagTree = {} + CreateTree(matchedList, tagTree) + + local paragraphObjs = {} + for _, v in ipairs(tagTree) do + local paragraphObj = CreateParagraph(v, bodyContent) + if paragraphObj then + table.insert(paragraphObjs, paragraphObj) + end + end + + return paragraphObjs +end + +local XHtmlHandler = { + Deserilize = Deserilize, + RemoveBlank = RemoveBlank, + ParagraphType = ParagraphType, + FontSizeMap = FontSizeMap, + AlignMap = AlignMap, + FilterSpecialSymbol = FilterSpecialSymbol, +} + +return XHtmlHandler \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGameNotice/XUiGameNotice.lua b/Resources/Scripts/XUi/XUiGameNotice/XUiGameNotice.lua new file mode 100644 index 00000000..ce0a9e0e --- /dev/null +++ b/Resources/Scripts/XUi/XUiGameNotice/XUiGameNotice.lua @@ -0,0 +1,396 @@ +local next = next +local tableInsert = table.insert +local TagTextPrefix = "NoticeTag" +local XHtmlHandler = require("XUi/XUiGameNotice/XHtmlHandler") +local mathFloor = math.floor +local mathCeil = math.ceil +local strFind = string.find + +local HtmlParagraphs = {} +local BTN_INDEX = { + First = 1, + Second = 2, +} + +local XUiGameNotice = XLuaUiManager.Register(XLuaUi, "UiGameNotice") +function XUiGameNotice:OnStart(rootUi, selectIdx, selectId, type) + self.RootUi = rootUi + self.HttpTextures = {} + self.HtmlIndexDic = {} + self.TabBtns = {} + self.Type = type + self.SelectIndex = selectIdx + self.SelectId = selectId + self:InitAutoScript() +end + +function XUiGameNotice:OnDisable() + self.CurUrl = nil + if self.WebViewPanel then + CS.UnityEngine.Object.DestroyImmediate(self.WebViewPanel.gameObject) + self.WebViewPanel = nil + end + + self:ClearTabBtns() + self:ClearAllChildren() + + LuaGC() +end + +function XUiGameNotice:InitAutoScript() + self.SpecialSoundMap = {} + self.AutoCreateListeners = {} +end + +function XUiGameNotice:GetAutoKey(uiNode, eventName) + if not uiNode then + return + end + return eventName .. uiNode:GetHashCode() +end + +function XUiGameNotice:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then + return + end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiPanelWorldChatMyMsgItem:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiGameNotice:OnEnable() + self:UpdateLeftTabBtns(self.SelectIndex, self.SelectId, self.Type) + self:OnSelectedTog() +end + +function XUiGameNotice:OnDestroy() + for index, httpTexture in pairs(self.HttpTextures) do + if httpTexture:Exist() then + CS.UnityEngine.Object.Destroy(httpTexture) + self.HttpTextures[index] = nil + end + end +end + +function XUiGameNotice:OnGetEvents() + return { XEventId.EVENT_UIDIALOG_VIEW_ENABLE, XEventId.EVENT_NOTICE_TYPE_CHANAGE, XEventId.EVENT_NOTICE_CONTENT_RESP } +end + +function XUiGameNotice:OnNotify(evt, ...) + if evt == XEventId.EVENT_UIDIALOG_VIEW_ENABLE then + self.RootUi:Close() + elseif evt == XEventId.EVENT_NOTICE_TYPE_CHANAGE then + local arg = {...} + self:UpdateLeftTabBtns(nil,nil, arg[1]) + self:OnSelectedTog() + elseif evt == XEventId.EVENT_NOTICE_CONTENT_RESP then + local args = {...} + self:OnNoticeContentResp(args[1]) + end +end + +function XUiGameNotice:GetCertainBtnModel(index, hasChild, pos, totalNum) + if index == BTN_INDEX.First then + if hasChild then + return self.BtnFirstHasSnd + else + return self.BtnFirst + end + elseif index == BTN_INDEX.Second then + if totalNum == 1 then + return self.BtnSecondAll + end + + if pos == 1 then + return self.BtnSecondTop + elseif pos == totalNum then + return self.BtnSecondBottom + else + return self.BtnSecond + end + end +end + +function XUiGameNotice:ClearTabBtns() + if not self.TabBtns then + return + end + + for _, v in pairs(self.TabBtns) do + CS.UnityEngine.GameObject.Destroy(v.gameObject) + end + + self.TabBtns = {} +end + +function XUiGameNotice:UpdateLeftTabBtns(selectIdx, selectId, type) + self.NoticeMap = XDataCenter.NoticeManager.GetInGameNoticeMap(type) + local noticeInfos = self.NoticeMap + if not noticeInfos then return end + + self.HtmlIndexDic = {} + + self:ClearTabBtns() + local btnIndex = 0 + local firstRedPointIndex + + --一级标题 + for groupIndex, data in ipairs(noticeInfos) do + local htmlList = data.Content + local totalNum = #htmlList + + local btnModel = self:GetCertainBtnModel(BTN_INDEX.First, totalNum > 1) + local btn = CS.UnityEngine.Object.Instantiate(btnModel) + btn.transform:SetParent(self.PanelNoticeTitleBtnGroup.transform, false) + btn.gameObject:SetActiveEx(true) + btn:SetName(data.Title) + + if not data.Tag or data.Tag == 0 then + btn:ShowTag(false) + else + local txtTag = btn.transform:Find("Tag/ImgTag/Text"):GetComponent("Text") + txtTag.text = CS.XTextManager.GetText(TagTextPrefix .. data.Tag) + btn:ShowTag(true) + end + + local uiButton = btn:GetComponent("XUiButton") + tableInsert(self.TabBtns, uiButton) + btnIndex = btnIndex + 1 + + --二级标题 + local needRedPoint = false + local firstIndex = btnIndex + local onlyOne = totalNum == 1 + for htmlIndex, htmlCfg in ipairs(htmlList) do + needRedPoint = XDataCenter.NoticeManager.CheckInGameNoticeRedPointIndividual(data, htmlIndex) + if needRedPoint and not firstRedPointIndex then + firstRedPointIndex = btnIndex + end + if not onlyOne then + local tmpBtnModel = self:GetCertainBtnModel(BTN_INDEX.Second, nil, htmlIndex, totalNum) + local tmpBtn = CS.UnityEngine.Object.Instantiate(tmpBtnModel) + tmpBtn:SetName(htmlCfg.Title) + tmpBtn.transform:SetParent(self.PanelNoticeTitleBtnGroup.transform, false) + + local tmpUiButton = tmpBtn:GetComponent("XUiButton") + tmpUiButton.SubGroupIndex = firstIndex + tableInsert(self.TabBtns, tmpUiButton) + btnIndex = btnIndex + 1 + + if needRedPoint then + tmpUiButton:ShowReddot(true) + else + tmpUiButton:ShowReddot(false) + end + end + + local indexInfo = { + HtmlReadKey = XDataCenter.NoticeManager.GetGameNoticeReadDataKey(data, htmlIndex), + HtmlUrl = htmlCfg.Url, + HtmlUrlSlave = htmlCfg.UrlSlave, + GroupIndex = groupIndex + } + self.HtmlIndexDic[btnIndex] = indexInfo + if selectId and selectId == tonumber(htmlCfg.Order) then + selectIdx = btnIndex + end + end + + uiButton:ShowReddot(needRedPoint) + end + + local selectIndex = selectIdx or firstRedPointIndex or 1 + self.PanelNoticeTitleBtnGroup:Init(self.TabBtns, function(index) self:OnSelectedTog(index) end) + self.PanelNoticeTitleBtnGroup:SelectIndex(selectIndex, false) + self.SelectIndex = selectIndex + self.SelectId = nil +end + +function XUiGameNotice:OnSelectedTog(index) + if self.SelectIndex and self.SelectIndex == index then return end + index = index or self.SelectIndex + self.SelectIndex = index + + local indexInfo = self.HtmlIndexDic[index] + if not indexInfo or not next(indexInfo) then + return + end + + --刷新右边UI + self:UpdateWebView(indexInfo.HtmlUrl) + + --取消小红点 + XDataCenter.NoticeManager.ChangeInGameNoticeReadStatus(indexInfo.HtmlReadKey, true) + local uiButton = self.TabBtns[index] + uiButton:ShowReddot(false) + + --判断一级按钮小红点 + local subGroupIndex = uiButton.SubGroupIndex + if subGroupIndex and self.TabBtns[subGroupIndex] then + local needRed = false + for _, btn in pairs(self.TabBtns) do + if btn.SubGroupIndex and btn.SubGroupIndex == subGroupIndex + and btn.ReddotObj.activeSelf then + needRed = true + break + end + end + if not needRed then + self.TabBtns[subGroupIndex]:ShowReddot(false) + end + end +end + +function XUiGameNotice:CreateImgObj(texture) + local parent = self.Img.transform.parent.transform + local newImgObj = CS.UnityEngine.Object.Instantiate(self.Img, parent) + newImgObj.gameObject:SetActiveEx(true) + newImgObj.texture = texture + + local width = parent.rect.width + local height = mathFloor(width * texture.height / texture.width) + newImgObj.rectTransform.sizeDelta = CS.UnityEngine.Vector2(width, height) + + return newImgObj +end + +function XUiGameNotice:CreateTextObj(params, textData, sourceTextData, fontSize) + local parent = self.Txt.transform.parent.transform + local newTextObj = CS.UnityEngine.Object.Instantiate(self.Txt, parent):GetComponent("XUiHrefText") + newTextObj.gameObject:SetActiveEx(true) + newTextObj.fontSize = fontSize or XHtmlHandler.FontSizeMap["xx-large"] + newTextObj.lineSpacing = 1.5 + + local width = parent.rect.width + local tg = newTextObj.cachedTextGeneratorForLayout + local set = newTextObj:GetGenerationSettings(CS.UnityEngine.Vector2(width, 0)) + local height = mathCeil(tg:GetPreferredHeight(CS.XTool.ReplaceNoBreakingSpace(sourceTextData), set) / newTextObj.pixelsPerUnit) + newTextObj.fontSize * (newTextObj.lineSpacing - 1) + + newTextObj.rectTransform.sizeDelta = CS.UnityEngine.Vector2(width, height) + newTextObj.text = textData + + local align + local _, _, styleParam = strFind(params, "style=\"(.-)\"") + if styleParam then + _, _, align = strFind(styleParam, "text%-align:(.-);") + if align then + align = XHtmlHandler.RemoveBlank(align) + newTextObj.alignment = XHtmlHandler.AlignMap[align] + end + end + + if not align then + _, _, align = strFind(params, "align=\"(.-)\"") + if align then + align = XHtmlHandler.RemoveBlank(align) + newTextObj.alignment = XHtmlHandler.AlignMap[align] + end + end + + return newTextObj +end + + +function XUiGameNotice:ShowHtml(paragraphs) + self:ClearAllChildren() + + for _, v in ipairs(paragraphs) do + if v.Type == XHtmlHandler.ParagraphType.Text then + v.Obj = self:CreateTextObj(v.Param, v.Data, v.SourceData, v.FontSize) + self:RegisterListener(v.Obj, "onHrefClick", self.OnBtnHrefClick) + else + v.Obj = self:CreateImgObj(v.Data) + end + end + + self.CurParagraphs = paragraphs +end + +function XUiGameNotice:OnBtnHrefClick(str) + if string.find(str, "suikawari") ~= nil or string.find(str, "thelastspark") ~= nil then -- 1.5周年和黄金周的 + local uid = XLoginManager.GetUserId() + if uid and uid ~= "" then + CS.UnityEngine.Application.OpenURL(str.."?uid="..uid) + return + end + elseif string.find(str, "seeed") ~= nil or string.find(str, "rooot") ~= nil then -- rooot活动的 + XDataCenter.ActivityManager.OpenRoootUrl(str) + else + if string.find(str, "eden") ~= nil then -- 萌战网页活动接入需求 + local uid = XUserManager.UserId + local serverId = CS.XHeroBdcAgent.ServerId + if uid and serverId then + CS.UnityEngine.Application.OpenURL(str.."?uid="..uid.."&serverId="..serverId) + end + else + CS.UnityEngine.Application.OpenURL(str) + end + end + CS.UnityEngine.Application.OpenURL(str) +end + +function XUiGameNotice:UpdateWebView(url) + if self.CurUrl == url then + return + end + + self.CurUrl = url + + if HtmlParagraphs[url] then + self:ShowHtml(HtmlParagraphs[url]) + return + end + + self.ImgLoading.gameObject:SetActiveEx(true) + + local request = CS.XUriPrefixRequest.Get(url) + CS.XTool.WaitCoroutine(request:SendWebRequest(), function() + if request.isNetworkError or request.isHttpError then + return + end + + local content = request.downloadHandler.text + if string.IsNilOrEmpty(content) then + return + end + request:Dispose() + + HtmlParagraphs[url] = XHtmlHandler.Deserilize(content) + if not HtmlParagraphs[url] then + XLog.Error("content deserilized is nil, url:" .. tostring(url)) + return + end + CsXGameEventManager.Instance:Notify(XEventId.EVENT_NOTICE_CONTENT_RESP, HtmlParagraphs[url]) + end) +end + +function XUiGameNotice:OnNoticeContentResp(content) + self:ShowHtml(content) + self.ImgLoading.gameObject:SetActiveEx(false) +end + +function XUiGameNotice:ClearAllChildren() + if self.CurParagraphs then + for _, v in ipairs(self.CurParagraphs) do + CS.UnityEngine.Object.DestroyImmediate(v.Obj.gameObject) + end + end + + self.CurParagraphs = {} +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuardCamp/XUiChongzhiTanchuang.lua b/Resources/Scripts/XUi/XUiGuardCamp/XUiChongzhiTanchuang.lua new file mode 100644 index 00000000..f407fbf3 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuardCamp/XUiChongzhiTanchuang.lua @@ -0,0 +1,443 @@ +local TextManager = CS.XTextManager +local DropdownOptionData = CS.UnityEngine.UI.Dropdown.OptionData +local RestTypeConfig +local LBGetTypeConfig +local Next = _G.next +local UpdateTimerTypeEnum = { + SettOff = 1, + SettOn = 2 +} + +local XUiChongzhiTanchuangListItem = require("XUi/XUiGuardCamp/XUiChongzhiTanchuangListItem") + +local XUiChongzhiTanchuang = XLuaUiManager.Register(XLuaUi, "UiChongzhiTanchuang") + +function XUiChongzhiTanchuang:OnStart(data, buyCb, dropDownCb) + RestTypeConfig = XPurchaseConfigs.RestTypeConfig + LBGetTypeConfig = XPurchaseConfigs.LBGetTypeConfig + self.CurState = false + self.TitleGoPool = {} + self.ItemPool = {} + self.OpenBuyTipsList = {} + self.BuyCb = buyCb + self.DropDownCb = dropDownCb + self.Data = data + self:AutoAddListener() +end + +function XUiChongzhiTanchuang:OnEnable() + self:OnRefresh(self.Data) +end + +function XUiChongzhiTanchuang:OnDisable() + self:StopUpdateTimer() +end + +function XUiChongzhiTanchuang:AutoAddListener() + local closefun = function() self:Close() end + self:RegisterClickEvent(self.BtnBgClick, self.Close) + self:RegisterClickEvent(self.BtnCloseBg, self.Close) + self:RegisterClickEvent(self.BtnBuy, self.OnBtnBuy) + self.DrdSort.onValueChanged:RemoveAllListeners() + self.DrdSort.onValueChanged:AddListener(function(index) + if self.DropDownCb then + self.DropDownCb(index) + end + end) +end + +function XUiChongzhiTanchuang:OnDestroy() + for _, v in pairs(self.ItemPool) do + v.Transform:SetParent(self.PoolGo) + v.GameObject:SetActive(false) + end + + for _, v in pairs(self.TitleGoPool) do + v:SetParent(self.PoolGo) + v.gameObject:SetActive(false) + end +end + +-- 更新数据 +function XUiChongzhiTanchuang:OnRefresh(data) + if not data then + return + end + CS.XAudioManager.PlaySound(1100) + self.RetimeSec = 0 + self.UpdateTimerType = nil + local curtime = XTime.GetServerNowTimestamp() + + self.Data = data + + -- 直接获得的道具 + self.ListDirData = {} + self.ListDayData = {} + local rewards0 = data.RewardGoodsList or {} + for _, v in pairs(rewards0) do + v.LBGetType = LBGetTypeConfig.Direct + table.insert(self.ListDirData, v) + end + -- 每日获得的道具 + local rewards1 = data.DailyRewardGoodsList or {} + for _, v in pairs(rewards1) do + v.LBGetType = LBGetTypeConfig.Day + table.insert(self.ListDayData, v) + end + local isUseMail = self.Data.IsUseMail or false + self.TxtContinue.gameObject:SetActive(isUseMail) + self:SetList() + + if data.TimeToInvalid and data.TimeToInvalid > 0 then + self.RetimeSec = data.TimeToInvalid - curtime + self.UpdateTimerType = UpdateTimerTypeEnum.SettOff + if self.RetimeSec > 0 then + self.TXtTime.gameObject:SetActive(true) + self:StartUpdateTimer() + self.TXtTime.text = TextManager.GetText("PurchaseSetOffTime", XUiHelper.GetTime(self.RetimeSec)) + else + self.TXtTime.gameObject:SetActive(false) + self:StopUpdateTimer() + end + else + if (data.TimeToShelve == nil or data.TimeToShelve == 0) and (data.TimeToUnShelve == nil or data.TimeToUnShelve == 0) then + self.TXtTime.gameObject:SetActive(false) + else + self.TXtTime.gameObject:SetActive(true) + if data.TimeToUnShelve > 0 then + self.RetimeSec = data.TimeToUnShelve - curtime + self.UpdateTimerType = UpdateTimerTypeEnum.SettOff + self.TXtTime.text = TextManager.GetText("PurchaseSetOffTime", XUiHelper.GetTime(self.RetimeSec)) + else + self.RetimeSec = data.TimeToShelve - curtime + self.UpdateTimerType = UpdateTimerTypeEnum.SettOn + self.TXtTime.text = TextManager.GetText("PurchaseSetOnTime", XUiHelper.GetTime(self.RetimeSec)) + end + if self.RetimeSec > 0 then + self:StartUpdateTimer() + else + self:StopUpdateTimer() + end + end + end + + self.TxtName.text = data.Name + local assetpath = XPurchaseConfigs.GetIconPathByIconName(data.Icon) + if assetpath and assetpath.AssetPath then + self.RawImageIcon:SetRawImage(assetpath.AssetPath) + end + self:SetBuyDes() + local disCountValue = XDataCenter.PurchaseManager.GetLBDiscountValue(data) + if data.ConsumeCount == 0 then + self.TxtPrice.gameObject:SetActiveEx(false) + self.RawImageConsume.gameObject:SetActive(false) + self.BtnBuy:SetName(TextManager.GetText("PurchaseFreeText")) + elseif XPurchaseConfigs.GetTagType(data.Tag) == XPurchaseConfigs.PurchaseTagType.Discount and disCountValue < 1 then -- 打折的 + self.RawImageConsume.gameObject:SetActive(true) + self.BtnBuy:SetName(math.modf(data.ConsumeCount * disCountValue)) + local icon = XDataCenter.ItemManager.GetItemIcon(data.ConsumeId) + if icon then + self.RawImageConsume:SetRawImage(icon) + end + self.TxtPrice.gameObject:SetActiveEx(true) + self.TxtPrice.text = data.ConsumeCount + else + self.TxtPrice.gameObject:SetActiveEx(false) + self.RawImageConsume.gameObject:SetActive(true) + self.BtnBuy:SetName(data.ConsumeCount) + local icon = XDataCenter.ItemManager.GetItemIcon(data.ConsumeId) + if icon then + self.RawImageConsume:SetRawImage(icon) + end + end + + --是否已拥有 + local isHave, isLimitTime = XRewardManager.CheckRewardGoodsListIsOwn(data.RewardGoodsList) + local isShowHave = isHave and not isLimitTime + self.TxtHave.gameObject:SetActive(isShowHave) + if isShowHave then + if #data.RewardGoodsList > 1 then + self.TxtHave.text = TextManager.GetText("PurchaseLBHaveFashion") + self.BtnBuy:SetDisable(not isShowHave) + else + self.TxtHave.text = TextManager.GetText("PurchaseLBHaveFashionCantBuy") + self.BtnBuy:SetDisable(isShowHave, not isShowHave) + end + else + self.BtnBuy:SetDisable(false) + if (data.BuyLimitTimes > 0 and data.BuyTimes == data.BuyLimitTimes) or (data.TimeToShelve > 0 and data.TimeToShelve <= curtime) or (data.TimeToUnShelve > 0 and data.TimeToUnShelve <= curtime) then --卖完了,不管。 + self.TXtTime.text = "" + if self.UpdateTimerType then + self:StopUpdateTimer() + end + self.TxtPrice.gameObject:SetActiveEx(false) + self.BtnBuy:SetButtonState(XUiButtonState.Disable) + else + self.BtnBuy:SetButtonState(XUiButtonState.Normal) + end + end + + if data.DiscountCouponInfos and #data.DiscountCouponInfos > 0 then + self.DrdSort.gameObject:SetActiveEx(true) + self.DrdSort:ClearOptions() + local od = DropdownOptionData(TextManager.GetText("UnUsedCouponDiscount")) + self.DrdSort.options:Add(od) + self.DrdSort.captionText.text = TextManager.GetText("UnUsedCouponDiscount") + self.AllCoupouMaxEndTime = 0 + for _, optionData in ipairs(data.DiscountCouponInfos) do + local itemId = optionData.ItemId + local itemName = XDataCenter.ItemManager.GetItemName(itemId) + local count = XDataCenter.ItemManager.GetCount(itemId) + local od = DropdownOptionData(itemName .. TextManager.GetText("DiscountCouponRemain", count)) + self.DrdSort.options:Add(od) + if optionData.EndTime > self.AllCoupouMaxEndTime then + self.AllCoupouMaxEndTime = optionData.EndTime + end + end + self.DrdSort.value = 0 + local nowTime = XTime.GetServerNowTimestamp() + self.TxtTimeCoupon.text = TextManager.GetText("CouponEndTime", XUiHelper.GetTime(self.AllCoupouMaxEndTime - nowTime, XUiHelper.TimeFormatType.SHOP)) + self.IsHasCoupon = true + else + self.DrdSort.gameObject:SetActiveEx(false) + self.IsHasCoupon = false + end +end + +function XUiChongzhiTanchuang:StartUpdateTimer() + self:StopUpdateTimer() + self.Timer = XScheduleManager.ScheduleForever(function() + self:UpdateTimer() + end, XScheduleManager.SECOND, 0) +end + +function XUiChongzhiTanchuang:StopUpdateTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end + +-- 更新倒计时 +function XUiChongzhiTanchuang:UpdateTimer() + self:UpdateCouponRemainTime() + + self.RetimeSec = self.RetimeSec - 1 + + if self.RetimeSec <= 0 then + self:StopUpdateTimer(self.Data.Id) + if self.UpdateTimerType == UpdateTimerTypeEnum.SettOff then + self.TXtTime.text = TextManager.GetText("PurchaseLBSettOff") + return + end + + self.TXtTime.text = "" + return + end + + if self.UpdateTimerType == UpdateTimerTypeEnum.SettOff then + self.TXtTime.text = TextManager.GetText("PurchaseSetOffTime", XUiHelper.GetTime(self.RetimeSec)) + return + end + + self.TXtTime.text = TextManager.GetText("PurchaseSetOnTime", XUiHelper.GetTime(self.RetimeSec)) +end + +function XUiChongzhiTanchuang:UpdateCouponRemainTime() -- 打折券倒计时更新 + if not self.IsHasCoupon then + return + end + + local nowTime = XTime.GetServerNowTimestamp() + local remainTime = self.AllCoupouMaxEndTime - nowTime + if remainTime > 0 then + self.TxtTimeCoupon.text = TextManager.GetText("CouponEndTime", XUiHelper.GetTime(remainTime, XUiHelper.TimeFormatType.SHOP)) + else + self.DrdSort.value = 0 + self.TxtTimeCoupon.text = "" + self.DrdSort.gameObject:SetActiveEx(false) + self.IsHasCoupon = false + end +end + +function XUiChongzhiTanchuang:SetList() + local index1 = 1 + local index2 = 1 + + if Next(self.ListDirData) ~= nil then + local obj = self:GetTitleGo(index1) + index1 = index1 + 1 + obj.transform:Find("TxtTitle"):GetComponent("Text").text = TextManager.GetText("PurchaseDirGet") + for _, v in pairs(self.ListDirData) do + local item = self:GetItemObj(index2) + item:OnRefresh(v) + index2 = index2 + 1 + end + end + + if Next(self.ListDayData) ~= nil then + local obj = self:GetTitleGo(index1) + obj.transform:Find("TxtTitle"):GetComponent("Text").text = self.Data.Desc or "" + for _, v in pairs(self.ListDayData) do + local item = self:GetItemObj(index2) + item:OnRefresh(v) + index2 = index2 + 1 + end + end +end + +function XUiChongzhiTanchuang:GetTitleGo(index) + if self.TitleGoPool[index] then + self.TitleGoPool[index].gameObject:SetActive(true) + self.TitleGoPool[index]:SetParent(self.PanelReward) + return self.TitleGoPool[index] + end + + local obj = CS.UnityEngine.Object.Instantiate(self.ImgTitle, self.PanelReward) + obj.gameObject:SetActive(true) + obj:SetParent(self.PanelReward) + table.insert(self.TitleGoPool, obj) + return obj +end + +function XUiChongzhiTanchuang:GetItemObj(index) + if self.ItemPool[index] then + self.ItemPool[index].GameObject:SetActive(true) + self.ItemPool[index].Transform:SetParent(self.PanelReward) + return self.ItemPool[index] + end + + local itemobj = CS.UnityEngine.Object.Instantiate(self.PanelPropItem, self.PanelReward) + itemobj.gameObject:SetActive(true) + itemobj:SetParent(self.PanelReward) + local item = XUiChongzhiTanchuangListItem.New(itemobj) + item:Init(self) + table.insert(self.ItemPool, item) + return item +end + +-- [监听动态列表事件] +-- function XUiChongzhiTanchuang:OnDynamicTableEvent(event, index, grid) +-- if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then +-- grid:Init(self, self) +-- elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then +-- local data = self.ListData[index] +-- grid:OnRefresh(data) +-- end +-- end + +function XUiChongzhiTanchuang:SetBuyDes() + local clientResetInfo = self.Data.ClientResetInfo or {} + if Next(clientResetInfo) == nil then + self.TxtLimitBuy.gameObject:SetActiveEx(false) + self.TxtLimitBuy.text = "" + return + end + + local textKey = nil + if clientResetInfo.ResetType == RestTypeConfig.Interval then + self.TxtLimitBuy.gameObject:SetActiveEx(true) + self.TxtLimitBuy.text = TextManager.GetText("PurchaseRestTypeInterval", clientResetInfo.DayCount, self.Data.BuyTimes, self.Data.BuyLimitTimes) + return + elseif clientResetInfo.ResetType == RestTypeConfig.Day then + textKey = "PurchaseRestTypeDay" + elseif clientResetInfo.ResetType == RestTypeConfig.Week then + textKey = "PurchaseRestTypeWeek" + elseif clientResetInfo.ResetType == RestTypeConfig.Month then + textKey = "PurchaseRestTypeMonth" + end + + if not textKey then + self.TxtLimitBuy.text = "" + self.TxtLimitBuy.gameObject:SetActiveEx(false) + return + end + self.TxtLimitBuy.gameObject:SetActiveEx(true) + self.TxtLimitBuy.text = TextManager.GetText(textKey, self.Data.BuyTimes, self.Data.BuyLimitTimes) +end + +function XUiChongzhiTanchuang:OnBtnBuy() + if self.Data.BuyLimitTimes and self.Data.BuyTimes and self.Data.BuyLimitTimes > 0 and self.Data.BuyTimes == self.Data.BuyLimitTimes then --卖完了,不管。 + XUiManager.TipText("PurchaseLiSellOut") + return + end + + if self.Data.TimeToShelve and self.Data.TimeToShelve > 0 and self.Data.TimeToShelve > XTime.GetServerNowTimestamp() then --没有上架 + XUiManager.TipText("PurchaseBuyNotSet") + return + end + + if self.Data.TimeToUnShelve and self.Data.TimeToUnShelve > 0 and self.Data.TimeToUnShelve < XTime.GetServerNowTimestamp() then --下架了 + XUiManager.TipText("PurchaseSettOff") + return + end + + if self.Data.TimeToInvalid and self.Data.TimeToInvalid > 0 and self.Data.TimeToInvalid < XTime.GetServerNowTimestamp() then --失效了 + XUiManager.TipText("PurchaseSettOff") + return + end + + local consumeCount = self.Data.ConsumeCount + if consumeCount and self.Data.Tag and XPurchaseConfigs.GetTagType(self.Data.Tag) == XPurchaseConfigs.PurchaseTagType.Discount then -- 计算打折后的钱 + local disCountValue = XDataCenter.PurchaseManager.GetLBDiscountValue(self.Data) + consumeCount = math.floor(disCountValue * consumeCount) + end + if consumeCount and self.Data.ConsumeId and consumeCount > 0 and consumeCount > XDataCenter.ItemManager.GetCount(self.Data.ConsumeId) then --钱不够 + local name = XDataCenter.ItemManager.GetItemName(self.Data.ConsumeId) or "" + local tips = CS.XTextManager.GetText("PurchaseBuyKaCountTips", name) + XUiManager.TipMsg(tips,XUiManager.UiTipType.Wrong) + if self.Data.ConsumeId == XDataCenter.ItemManager.ItemId.PaidGem then + XLuaUiManager.Open("UiPurchase", XPurchaseConfigs.TabsConfig.HK, false) + elseif self.Data.ConsumeId == XDataCenter.ItemManager.ItemId.HongKa then + XLuaUiManager.Open("UiPurchase", XPurchaseConfigs.TabsConfig.Pay, false) + end + return + end + + if self:CheckIsOpenBuyTips(self.Data.RewardGoodsList) then + return + end + + self:PurchaseRequest() +end + +function XUiChongzhiTanchuang:CheckIsOpenBuyTips(rewardGoodsList) + if not rewardGoodsList then return false end + for k, v in pairs(rewardGoodsList) do + if XRewardManager.CheckRewardOwn(v.RewardType, v.TemplateId) then + local tipContent = {} + tipContent["title"] = CSXTextManagerGetText("PurchaseFashionRepeatTipsTitle") + tipContent["content"] = CSXTextManagerGetText("PurchaseFashionRepeatTipsContent") + table.insert(self.OpenBuyTipsList, tipContent) + end + end + if #self.OpenBuyTipsList > 0 then + self:OpenBuyTips() + return true + end + return false +end + +function XUiChongzhiTanchuang:OpenBuyTips() + if #self.OpenBuyTipsList > 0 then + local tipContent = table.remove(self.OpenBuyTipsList, 1) + local sureCallback = function () + if #self.OpenBuyTipsList > 0 then + self:OpenBuyTips() + else + self:PurchaseRequest() + end + end + local closeCallback = function() + self.OpenBuyTipsList = {} + end + XUiManager.DialogTip(tipContent["title"], tipContent["content"], XUiManager.DialogType.Normal, closeCallback, sureCallback) + end +end + +function XUiChongzhiTanchuang:PurchaseRequest() + if self.Data and self.Data.Id then + XDataCenter.PurchaseManager.PurchaseRequest(self.Data.Id, self.BuyCb) + self:Close() + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuardCamp/XUiChongzhiTanchuangListItem.lua b/Resources/Scripts/XUi/XUiGuardCamp/XUiChongzhiTanchuangListItem.lua new file mode 100644 index 00000000..d67e99f1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuardCamp/XUiChongzhiTanchuangListItem.lua @@ -0,0 +1,23 @@ +local XUiChongzhiTanchuangListItem = XClass(nil, "XUiChongzhiTanchuangListItem") + +function XUiChongzhiTanchuangListItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +-- 更新数据 +function XUiChongzhiTanchuangListItem:OnRefresh(itemdata) + if not itemdata then + return + end + + self.ItemData = itemdata + self.GridItemUI:Refresh(itemdata) +end + +function XUiChongzhiTanchuangListItem:Init(root) + self.GridItemUI = XUiGridCommon.New(root,self.GridItem) +end + +return XUiChongzhiTanchuangListItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuardCamp/XUiGuardCampMain.lua b/Resources/Scripts/XUi/XUiGuardCamp/XUiGuardCampMain.lua new file mode 100644 index 00000000..37e461b9 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuardCamp/XUiGuardCampMain.lua @@ -0,0 +1,365 @@ +local CSXTextManagerGetText = CS.XTextManager.GetText +local mathFloor = math.floor +local stringFormat = string.format +local TenThousand = 10000 +local Billion = 100000000 + +local S = 60 +local H = 3600 +local D = 3600 * 24 +local W = 3600 * 24 * 7 +local M = 3600 * 24 * 30 +local STR_HOUR = CS.XTextManager.GetText("Hour") +local STR_MINUTE = CS.XTextManager.GetText("Minute") + +--炸服押注活动 +local XUiGuardCampMain = XLuaUiManager.Register(XLuaUi, "UiGuardCampMain") + +function XUiGuardCampMain:OnAwake() + self:CheckAutoOpenHelp() + XDataCenter.GuardCampManager.CheckUpdateRedPointTimeStamp() + self:AutoAddListener() +end + +function XUiGuardCampMain:OnStart() + XDataCenter.PurchaseManager.GetPurchaseListRequest(XPurchaseConfigs.GetLBUiTypesList()) + self:InitData() + self:InitJoinNum() + self:InitPondAdd() + self:InitCampName() + self:InitIcon() +end + +function XUiGuardCampMain:OnEnable() + if self:CheckActivityIsClose() then + return + end + self:RequestGetGuardCampGlobalDataSend() + self:Refresh() +end + +function XUiGuardCampMain:OnDisable() + self:RemoveTimer() +end + +function XUiGuardCampMain:OnDestroy() + XDataCenter.PurchaseManager.ClearData() +end + +function XUiGuardCampMain:CheckAutoOpenHelp() + local isFirstOpenView = XDataCenter.GuardCampManager.IsFirstOpenView() + if isFirstOpenView then + XUiManager.ShowHelpTip("GuardCamp") + end +end + +function XUiGuardCampMain:AutoAddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:BindHelpBtn(self.BtnHelp, "GuardCamp") + self:RegisterClickEvent(self.BtnBuyJump2, self.OnBtnBuyJumpClick) + self:RegisterClickEvent(self.KachiButton, self.OnKachiButtonClick) + self:RegisterClickEvent(self.PanelBtnJiazhuTudou, self.OnPanelBtnJiazhuTudouClick) + self:RegisterClickEvent(self.PanelBtnJiazhuSolon, self.OnPanelBtnJiazhuSolonClick) + self:RegisterClickEvent(self.PanelBtnYingyuanTudou, self.OnPanelBtnYingyuanTudouClick) + self:RegisterClickEvent(self.PanelBtnYingyuanSolon, self.OnPanelBtnYingyuanSolonClick) + self:RegisterClickEvent(self.PanelBtnTingzhTudou, self.OnPanelBtnTingzhiClick) + self:RegisterClickEvent(self.PanelBtnTingzhSolon, self.OnPanelBtnTingzhiClick) + self:RegisterClickEvent(self.BtnClosePanelTips, self.OnKachiButtonClick) + self.PanelBtnLingquDetail.CallBack = function() self:OnPanelBtnLingquDetailClick() end +end + +function XUiGuardCampMain:InitData() + self.ActivityId = XGuardCampConfig.GetActivityId() + self.LeftCampId = XGuardCampConfig.GetCampId(1) + self.RightCampId = XGuardCampConfig.GetCampId(2) + self.SupportItemId = XGuardCampConfig.GetActivitySupportItemId(self.ActivityId) + XDataCenter.ItemManager.AddCountUpdateListener(self.SupportItemId, function() + self:RefreshSupportItemNum() + end, self.TxtTool2) + self.IsOverPlayWinAnima = false +end + +function XUiGuardCampMain:InitJoinNum() + local activityId = XGuardCampConfig.GetActivityId() + local joinNumList = XGuardCampConfig.GetActivityJoinNumList(activityId) + local num + for i, joinNum in ipairs(joinNumList) do + self["TxtRenshu" .. i].text = self:GetNumConver(joinNum) + end +end + +function XUiGuardCampMain:InitPondAdd() + local activityId = XGuardCampConfig.GetActivityId() + local pondAddList = XGuardCampConfig.GetActivityPondAddList(activityId) + local num + for i, pondAdd in ipairs(pondAddList) do + self["PanelJiangliText" .. i].text = self:GetNumConver(pondAdd) + end +end + +function XUiGuardCampMain:GetNumConver(num) + if num % Billion == 0 then + return stringFormat("%d%s", num / Billion, CSXTextManagerGetText("AHundredMillion")) + end + if num % TenThousand == 0 then + return stringFormat("%d%s", num / TenThousand, CSXTextManagerGetText("TenThousand")) + end + + local numTemp = num / TenThousand + return stringFormat("%.1f%s", numTemp, CSXTextManagerGetText("TenThousand")) +end + +function XUiGuardCampMain:InitIcon() + local supportItemId = XGuardCampConfig.GetActivitySupportItemId(self.ActivityId) + local supportItemIcon = XDataCenter.ItemManager.GetItemIcon(supportItemId) + self.RImgTool2:SetRawImage(supportItemIcon) + self.TudouYingyuanRawImage:SetRawImage(supportItemIcon) + self.SolonYingyuanRawImage:SetRawImage(supportItemIcon) + + local joinNumList = XGuardCampConfig.GetActivityJoinNumList(self.ActivityId) + for i in ipairs(joinNumList) do + self["PanelJiangliRawImage" .. i]:SetRawImage(supportItemIcon) + end + self.KachiRawImage:SetRawImage(supportItemIcon) +end + +function XUiGuardCampMain:InitCampName() + self.TudouTitleText.text = XGuardCampConfig.GetCampName(self.LeftCampId) + self.SolonTitleText.text = XGuardCampConfig.GetCampName(self.RightCampId) +end + +function XUiGuardCampMain:RequestGetGuardCampGlobalDataSend() + XDataCenter.GuardCampManager.RequestGetGuardCampGlobalDataSend(self.ActivityId, function() self:Refresh() end) +end + +function XUiGuardCampMain:Refresh() + if self:CheckActivityIsClose() then + return + end + local state, timeStr, title, endTimestamp = XDataCenter.GuardCampManager.GetActivityState(self.ActivityId) + local selectCampId = XDataCenter.GuardCampManager.GetSelectCampIdByActivityId(self.ActivityId) + local isSelectCamp = selectCampId ~= XGuardCampConfig.NotGuardId + local isGetReward = XDataCenter.GuardCampManager.IsGetReward(self.ActivityId) + if self.MyZhenyingTudou then + self.MyZhenyingTudou.gameObject:SetActiveEx(selectCampId == self.LeftCampId) + end + if self.MyZhenyingSolon then + self.MyZhenyingSolon.gameObject:SetActiveEx(selectCampId == self.RightCampId) + end + self.PanelBtnYingyuanDetail.gameObject:SetActiveEx(not isSelectCamp and (state == XGuardCampConfig.ActivityState.UnOpen or state == XGuardCampConfig.ActivityState.SupportOpen)) + self.PanelBtnJiazhuDetail.gameObject:SetActiveEx(isSelectCamp and state == XGuardCampConfig.ActivityState.SupportOpen) + self.PanelBtnTingzhiDetail.gameObject:SetActiveEx(state == XGuardCampConfig.ActivityState.SupportClose) + self.TxtWeikaishi.gameObject:SetActiveEx(state == XGuardCampConfig.ActivityState.UnOpen) + self.PanelKachiDtail.gameObject:SetActiveEx(state ~= XGuardCampConfig.ActivityState.UnOpen) + self.PaneJiesuoJindu.gameObject:SetActiveEx(state ~= XGuardCampConfig.ActivityState.DrawLottery) + self.PanelYingyuanCountTudouDetail.gameObject:SetActiveEx(state ~= XGuardCampConfig.ActivityState.UnOpen) + self.PaneTudouZhenying.gameObject:SetActiveEx(state ~= XGuardCampConfig.ActivityState.UnOpen) + self.PanelYingyuanCountSolonDetail.gameObject:SetActiveEx(state ~= XGuardCampConfig.ActivityState.UnOpen) + self.PaneSolonZhenying.gameObject:SetActiveEx(state ~= XGuardCampConfig.ActivityState.UnOpen) + + self.PanelBtnLingquDetail.gameObject:SetActiveEx(isSelectCamp and state == XGuardCampConfig.ActivityState.DrawLottery) + self.PanelBtnLingquDetail:SetDisable(isGetReward, not isGetReward) + + self:RefreshSupportCount(selectCampId) + self:RefreshJoinCount() + self:RefreshJoinPercent() + self:RefreshSupportItemNum() + self:RefreshWinImg(state) + + self.KachiText.text = XDataCenter.GuardCampManager.GetPondCountByActivityId(self.ActivityId) + self.PanelTipsText.text = XGuardCampConfig.GetCaption(state) + + self:RefreshTimer(timeStr, title, endTimestamp) +end + +function XUiGuardCampMain:RefreshTimer(timeStr, title, endTimestamp) + local serverTimestamp = XTime.GetServerNowTimestamp() + self.EndTimestamp = endTimestamp + self.Title = title + self.TimeStr = timeStr + if not self.Timer then + self.Timer = XScheduleManager.ScheduleForever(function() + serverTimestamp = XTime.GetServerNowTimestamp() + if self.EndTimestamp <= serverTimestamp then + self:Refresh() + else + self:RequestGetGuardCampGlobalDataSend() + self:RefreshTimeStr(self.TimeStr, self.Title, self.EndTimestamp - serverTimestamp) + end + end, XScheduleManager.SECOND) + end + self:RefreshTimeStr(timeStr, title, endTimestamp - serverTimestamp) +end + +function XUiGuardCampMain:RefreshTimeStr(timeStr, title, endLastTimestamp) + local hours = mathFloor(endLastTimestamp / H) + local minutes = mathFloor((endLastTimestamp % H) / S) + minutes = minutes > 0 and minutes or 1 --小于1分钟显示1分钟 + self.TxtTitle.text = title + self.TxtTime.text = timeStr ~= "" and timeStr or stringFormat("%d%s%d%s", hours, STR_HOUR, minutes, STR_MINUTE) +end + +function XUiGuardCampMain:RemoveTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end + +function XUiGuardCampMain:RefreshSupportItemNum() + self.TxtTool2.text = XDataCenter.ItemManager.GetCount(self.SupportItemId) +end + +function XUiGuardCampMain:RefreshJoinPercent() + local percent = XDataCenter.GuardCampManager.GetJoinPercent(self.ActivityId) + self.ImgPercent.fillAmount = percent + + local joinNumList = XGuardCampConfig.GetActivityJoinNumList(self.ActivityId) + local totalNum = XDataCenter.GuardCampManager.GetJoinTotalNum(self.ActivityId) + for i, joinNum in ipairs(joinNumList) do + self["ZhuangtaidianRawImage" .. i].gameObject:SetActiveEx(totalNum >= joinNum) + end +end + +function XUiGuardCampMain:RefreshSupportCount(selectCampId) + local perSupportNum = XGuardCampConfig.GetActivityPerSupportNum(self.ActivityId) + local supporNum = XDataCenter.GuardCampManager.GetSupportCount(self.ActivityId, self.LeftCampId) + local selectCampNeedCount = XGuardCampConfig.GetActivitySelectCampNeedCount(self.ActivityId) + local addSelectCampNeedCount = selectCampId == self.LeftCampId and selectCampNeedCount or 0 + self.TudouYingyuanCount.text = supporNum * perSupportNum + addSelectCampNeedCount + addSelectCampNeedCount = selectCampId == self.RightCampId and selectCampNeedCount or 0 + supporNum = XDataCenter.GuardCampManager.GetSupportCount(self.ActivityId, self.RightCampId) + self.SolonYingyuanCount.text = supporNum * perSupportNum + addSelectCampNeedCount +end + +function XUiGuardCampMain:RefreshJoinCount() + self.TudouZhenyingText.text = XDataCenter.GuardCampManager.GetJoinNum(self.ActivityId, self.LeftCampId) + self.SolonZhenyingText.text = XDataCenter.GuardCampManager.GetJoinNum(self.ActivityId, self.RightCampId) +end + +function XUiGuardCampMain:RefreshWinImg(state) + local winCampId = XDataCenter.GuardCampManager.GetWinCampIdByActivityId(self.ActivityId) + local tudouLose = state == XGuardCampConfig.ActivityState.DrawLottery and winCampId ~= 0 and self.LeftCampId ~= winCampId + local solonLose = state == XGuardCampConfig.ActivityState.DrawLottery and winCampId ~= 0 and self.RightCampId ~= winCampId + self.ImgTudouLose.gameObject:SetActiveEx(tudouLose) + self.ImgSolonLose.gameObject:SetActiveEx(solonLose) + self.ImgWin.gameObject:SetActiveEx(state == XGuardCampConfig.ActivityState.DrawLottery and winCampId ~= 0) + + if not self.IsOverPlayWinAnima then + if tudouLose then + self:PlayAnimation("SolonWin") + self.IsOverPlayWinAnima = true + elseif solonLose then + self:PlayAnimation("TuDouWin") + self.IsOverPlayWinAnima = true + end + end +end + +function XUiGuardCampMain:CheckActivityIsClose() + if XDataCenter.GuardCampManager.IsActivityClose() then + XUiManager.TipText("ActivityAlreadyOver") + self:Close() + return true + end +end + +function XUiGuardCampMain:OnPanelBtnJiazhuTudouClick() + self:OnJiaZhuClick(self.LeftCampId) +end + +function XUiGuardCampMain:OnPanelBtnJiazhuSolonClick() + self:OnJiaZhuClick(self.RightCampId) +end + +function XUiGuardCampMain:OnJiaZhuClick(selectCampId) + local maxSupportCount = XDataCenter.GuardCampManager.GetMaxSupportCount(self.ActivityId) + if maxSupportCount == 0 then + XUiManager.TipText("GuardCampSupportCampMax") + return + end + + local perSupportNum = XGuardCampConfig.GetActivityPerSupportNum(self.ActivityId) + local itemCount = XDataCenter.ItemManager.GetCount(self.SupportItemId) + if itemCount < perSupportNum then + self:OnBtnBuyJumpClick() + return + end + + XLuaUiManager.Open("UiGuardCampTips", self.ActivityId, selectCampId) +end + +function XUiGuardCampMain:OnPanelBtnYingyuanTudouClick() + self:OnYingyuan(self.LeftCampId) +end + +function XUiGuardCampMain:OnPanelBtnYingyuanSolonClick() + self:OnYingyuan(self.RightCampId) +end + +function XUiGuardCampMain:OnYingyuan(selectCampId) + local state, timeStr = XDataCenter.GuardCampManager.GetActivityState(self.ActivityId) + if state == XGuardCampConfig.ActivityState.UnOpen then + local errorDesc = CS.XTextManager.GetText("GuardCampUnopenTipDesc", timeStr) + XUiManager.TipError(errorDesc) + return + end + + local selectCampNeedCount = XGuardCampConfig.GetActivitySelectCampNeedCount(self.ActivityId) + local itemCount = XDataCenter.ItemManager.GetCount(self.SupportItemId) + if itemCount < selectCampNeedCount then + self:OnBtnBuyJumpClick() + return + end + + local itemId = XGuardCampConfig.GetActivitySupportItemId(self.ActivityId) + local itemName = XDataCenter.ItemManager.GetItemName(itemId) + local campName = XGuardCampConfig.GetCampName(selectCampId) + local content = CS.XTextManager.GetText("GuardCampSelectCampTipDesc", selectCampNeedCount, itemName, campName) + XUiManager.DialogTip("", content, XUiManager.DialogType.Normal, nil, function() + XDataCenter.GuardCampManager.RequestSelectGuardCampSend(self.ActivityId, selectCampId) + end) +end + +function XUiGuardCampMain:OnPanelBtnLingquDetailClick() + local selectCampId = XDataCenter.GuardCampManager.GetSelectCampIdByActivityId(self.ActivityId) + XDataCenter.GuardCampManager.RequestGetGuardCampRewardSend(self.ActivityId, function() self:Refresh() end) +end + +function XUiGuardCampMain:OnBtnBuyJumpClick() + local data = XDataCenter.GuardCampManager.GetActivityPurchasePackageData(self.ActivityId) + if not data or data.IsSelloutHide then + XUiManager.TipText("NotPurchaseData") + return + end + XLuaUiManager.Open("UiChongzhiTanchuang", data) +end + +--奖池说明弹窗 +function XUiGuardCampMain:OnKachiButtonClick() + local activeSelf = self.PanelTipsDetail.gameObject.activeSelf + self.PanelTipsDetail.gameObject:SetActiveEx(not activeSelf) +end + +function XUiGuardCampMain:OnPanelBtnTingzhiClick() + XUiManager.TipText("GuardCampSupportCloseTipDesc") +end + +function XUiGuardCampMain:OnBtnBackClick() + self:Close() +end + +function XUiGuardCampMain:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiGuardCampMain:OnGetEvents() + return {XEventId.EVENT_GUARD_CAMP_ACTIVITY_DATA_CHANGE} +end + +function XUiGuardCampMain:OnNotify(evt, ...) + if evt == XEventId.EVENT_GUARD_CAMP_ACTIVITY_DATA_CHANGE then + self:Refresh() + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuardCamp/XUiGuardCampTips.lua b/Resources/Scripts/XUi/XUiGuardCamp/XUiGuardCampTips.lua new file mode 100644 index 00000000..1a716fb9 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuardCamp/XUiGuardCampTips.lua @@ -0,0 +1,101 @@ +local CSXTextManagerGetText = CS.XTextManager.GetText +local stringGsub = string.gsub +local MinSupportCount = 1 +local CAN_SUPPORT_COLOR = { + [true] = XUiHelper.Hexcolor2Color("0f70bcff"), + [false] = CS.UnityEngine.Color.red, +} + +local XUiGuardCampTips = XLuaUiManager.Register(XLuaUi, "UiGuardCampTips") + +function XUiGuardCampTips:OnAwake() + self.BtnClose.gameObject:SetActiveEx(false) + local btnName = CSXTextManagerGetText("GuardCampSupportTipsBtnName") + self.BtnTongBlack:SetName(btnName) + self:AutoAddListener() +end + +function XUiGuardCampTips:OnStart(activityId, campId, cb) + self.ActivityId = activityId + self.CampId = campId + self.Cb = cb + self:InitData() + self:Refresh() +end + +function XUiGuardCampTips:InitData() + self.PerSupportNumCfg = XGuardCampConfig.GetActivityPerSupportNum(self.ActivityId) + self.MaxSupportCount = XDataCenter.GuardCampManager.GetMaxSupportCount(self.ActivityId) + self.SelectSupportCount = 1 + + local itemId = XGuardCampConfig.GetActivitySupportItemId(self.ActivityId) + local iconPath = XDataCenter.ItemManager.GetItemIcon(itemId) + self.RawImage:SetRawImage(iconPath) +end + +function XUiGuardCampTips:AutoAddListener() + self:RegisterClickEvent(self.BtnTanchuangClose, self.Close) + self:RegisterClickEvent(self.BtnReduce, self.OnBtnReduceClick) + self:RegisterClickEvent(self.BtnAdd, self.OnBtnAddClick) + self:RegisterClickEvent(self.BtnTongBlack, self.OnBtnTongBlackClick) +end + +function XUiGuardCampTips:Refresh() + local campName = XGuardCampConfig.GetCampName(self.CampId) + local tipsDesc = CSXTextManagerGetText("GuardCampSupportTipsDesc", campName) + self.Text.text = stringGsub(tipsDesc, "\\n", "\n") + + local supportItemId = XGuardCampConfig.GetActivitySupportItemId(self.ActivityId) + local itemCount = XDataCenter.ItemManager.GetCount(supportItemId) + self.Count.text = itemCount + + self:RefreshTextSelectCount(itemCount) +end + +function XUiGuardCampTips:RefreshTextSelectCount(itemCount) + local supportNum = self.SelectSupportCount * self.PerSupportNumCfg + local isCanSupport = itemCount >= supportNum + self.TextSelectCount.text = supportNum + self.TextSelectCount.color = CAN_SUPPORT_COLOR[isCanSupport] +end + +function XUiGuardCampTips:OnBtnReduceClick() + local supportItemId = XGuardCampConfig.GetActivitySupportItemId(self.ActivityId) + if self.SelectSupportCount - 1 < MinSupportCount then + local itemName = XDataCenter.ItemManager.GetItemName(supportItemId) + local tipsDesc = CSXTextManagerGetText("GuardCampMinSupport", MinSupportCount * self.PerSupportNumCfg, itemName) + XUiManager.TipError(tipsDesc) + return + end + self.SelectSupportCount = self.SelectSupportCount - 1 + local itemCount = XDataCenter.ItemManager.GetCount(supportItemId) + self:RefreshTextSelectCount(itemCount) +end + +function XUiGuardCampTips:OnBtnAddClick() + local supportItemId = XGuardCampConfig.GetActivitySupportItemId(self.ActivityId) + if self.SelectSupportCount + 1 > self.MaxSupportCount then + local totalSupportCountCfg = XGuardCampConfig.GetActivityTotalSupportCount(self.ActivityId) + local itemName = XDataCenter.ItemManager.GetItemName(supportItemId) + local tipsDesc = CSXTextManagerGetText("GuardCampMaxSupport", totalSupportCountCfg * self.PerSupportNumCfg, itemName) + XUiManager.TipError(tipsDesc) + return + end + self.SelectSupportCount = self.SelectSupportCount + 1 + local itemCount = XDataCenter.ItemManager.GetCount(supportItemId) + self:RefreshTextSelectCount(itemCount) +end + +function XUiGuardCampTips:OnBtnTongBlackClick() + local supportItemId = XGuardCampConfig.GetActivitySupportItemId(self.ActivityId) + local itemCount = XDataCenter.ItemManager.GetCount(supportItemId) + local supportNum = self.SelectSupportCount * self.PerSupportNumCfg + local isCanSupport = itemCount >= supportNum + if not isCanSupport then + XUiManager.TipText("GuardCampSupportInsufficientQuantity") + return + end + + XDataCenter.GuardCampManager.RequestSupportGuardCampSend(self.ActivityId, self.CampId, self.SelectSupportCount, self.Cb) + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuide/XUiGuideNew.lua b/Resources/Scripts/XUi/XUiGuide/XUiGuideNew.lua new file mode 100644 index 00000000..a682f821 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuide/XUiGuideNew.lua @@ -0,0 +1,197 @@ +local XUiGuideNew = XLuaUiManager.Register(XLuaUi, "UiGuide") + +function XUiGuideNew:OnAwake() + self:AutoAddListener() + self.PanelInfoRect = self.PanelInfo + self.PanelWarning.gameObject:SetActive(false) + self.BtnSkip.gameObject:SetActive(false) + self.BtnPass.gameObject:SetActive(false) + self.PanelInfo.gameObject:SetActive(false) + + self.LastClickTime = 0 + self.ContinueClickTimes = 0 + self.ClickInterval = 0.5 +end + +function XUiGuideNew:OnStart(targetImg, isWeakGuide, guideDesc, icon, name, callback) + + self.Guide = self.BtnPanelMaskGuide:GetComponent("XGuide") + if (not self.Guide) then + self.Guide = self.BtnPanelMaskGuide.gameObject:AddComponent(typeof(CS.XGuide)) + end + self.Guide:SetPass(false) + self.Guide:SetTimeText(self.TxtTime) + + self.Callback = callback + self.IsWeakGuide = isWeakGuide + if targetImg then + CS.XGuideEventPass.IsPassEvent = true + CS.XGuideEventPass.IsFightGuide = true + self.IsFight = true + self:ShowMark(true, true) + self:ShowDialog(icon, name, guideDesc, 0) + self:FocuOnFightPanel(targetImg) + self.UiWidget = self.Transform:Find("FullScreenBackground/BtnPanelMaskGuide/BtnPass").gameObject:AddComponent(typeof(CS.XUiWidget)) + self.UiWidget:AddPointerDownListener(function(eventData) + self.Transform:Find("SafeAreaContentPane").gameObject:SetActive(false) + self.Transform:Find("FullScreenBackground/BtnPanelMaskGuide"):GetComponent("Image").enabled = false + self.Transform:Find("FullScreenBackground/BtnPanelMaskGuide/BtnPass/Bg").gameObject:SetActive(false) + end) + self.UiWidget:AddPointerUpListener(function(eventData) + self:OnBtnPassClick() + end) + end + + -- CsXGameEventManager.Instance:RegisterEvent(CS.XEventId.EVENT_GUIDE_FIGHT_BTNDOWN, function(evt, args) + -- if self.Callback and not self.IsWeakGuide then + -- self.Callback() + -- self.Callback = nil + -- end + -- end) + +end + +function XUiGuideNew:OnDestroy() + -- CsXGameEventManager.Instance:RemoveEvent(XEventId.EVENT_GUIDE_FIGHT_BTNDOWN, function(evt, args) + -- if self.Callback and not self.IsWeakGuide then + -- self.Callback = nil + -- end + -- end) +end + + +-- auto +-- Automatic generation of code, forbid to edit +function XUiGuideNew:InitAutoScript() + self:AutoInitUi() +end + +function XUiGuideNew:AutoInitUi() + self.PanelMaskAll = self.Transform:Find("FullScreenBackground/PanelMaskAll") + self.BtnPanelMaskGuide = self.Transform:Find("FullScreenBackground/BtnPanelMaskGuide"):GetComponent("Button") + self.BtnPass = self.Transform:Find("FullScreenBackground/BtnPanelMaskGuide/BtnPass"):GetComponent("Button") + self.PanelInfo = self.Transform:Find("FullScreenBackground/BtnPanelMaskGuide/PanelInfo") + self.PanelHead = self.Transform:Find("FullScreenBackground/BtnPanelMaskGuide/PanelInfo/PanelHead") + self.ImgRole = self.Transform:Find("FullScreenBackground/BtnPanelMaskGuide/PanelInfo/PanelHead/FxUiguide005/ImgRole"):GetComponent("Image") + self.PanelTime = self.Transform:Find("FullScreenBackground/BtnPanelMaskGuide/PanelInfo/PanelHead/PanelTime") + self.TxtTime = self.Transform:Find("FullScreenBackground/BtnPanelMaskGuide/PanelInfo/PanelHead/PanelTime/TxtTime"):GetComponent("Text") + self.PanelTxt = self.Transform:Find("FullScreenBackground/BtnPanelMaskGuide/PanelInfo/PanelTxt") + self.TxtName = self.Transform:Find("FullScreenBackground/BtnPanelMaskGuide/PanelInfo/PanelTxt/TxtName"):GetComponent("Text") + self.TxtDesc = self.Transform:Find("FullScreenBackground/BtnPanelMaskGuide/PanelInfo/PanelTxt/TxtDesc"):GetComponent("Text") + self.PanelBtn = self.Transform:Find("SafeAreaContentPane/PanelBtn") + self.BtnSkip = self.Transform:Find("SafeAreaContentPane/PanelBtn/BtnSkip"):GetComponent("Button") + self.PanelWarning = self.Transform:Find("SafeAreaContentPane/PanelWarning") + self.BtnConfrim = self.Transform:Find("SafeAreaContentPane/PanelWarning/BtnConfrim"):GetComponent("Button") + self.BtnCancel = self.Transform:Find("SafeAreaContentPane/PanelWarning/BtnCancel"):GetComponent("Button") +end + +function XUiGuideNew:AutoAddListener() + + + self:RegisterClickEvent(self.BtnPanelMaskGuide, self.OnBtnPanelMaskGuideClick) + self:RegisterClickEvent(self.BtnPass, self.OnBtnPassClick) + self:RegisterClickEvent(self.BtnSkip, self.OnBtnSkipClick) + self:RegisterClickEvent(self.BtnConfrim, self.OnBtnConfrimClick) + self:RegisterClickEvent(self.BtnCancel, self.OnBtnCancelClick) +end +-- auto +function XUiGuideNew:OnBtnSkipClick() + self.PanelWarning.gameObject:SetActive(true) +end + +function XUiGuideNew:OnBtnConfrimClick() + XDataCenter.GuideManager.ReqCompleteGuideGroup(function() + XDataCenter.GuideManager.ResetGuide() + XEventManager.DispatchEvent(XEventId.EVENT_FUNCTION_EVENT_COMPLETE) + end) +end + +function XUiGuideNew:CheckDouble() + if XTime.GetServerNowTimestamp() - self.LastClickTime > self.ClickInterval then + self.ContinueClickTimes = 0 + else + self.ContinueClickTimes = self.ContinueClickTimes + 1 + end + + if self.ContinueClickTimes == 3 then + self.ContinueClickTimes = 0 + self.BtnSkip.gameObject:SetActive(true) + end + + self.LastClickTime = XTime.GetServerNowTimestamp() +end + +function XUiGuideNew:OnBtnCancelClick() + self.PanelWarning.gameObject:SetActive(false) +end + +function XUiGuideNew:OnBtnPassClick() + self.Guide:Reset() + + if self.Callback and not self.IsWeakGuide then + self.Callback() + self.Callback = nil + end +end + +function XUiGuideNew:OnBtnPanelMaskGuideClick() + if not XDataCenter.GuideManager.CheckIsFightGuide() and not CS.XGuideEventPass.IsFightGuide then + self:CheckDouble() + end + + CsXGameEventManager.Instance:Notify(CS.XEventId.EVENT_GUIDE_ANYCLICK) +end + +--显示头像 +function XUiGuideNew:ShowDialog(icon, name, content, pos) + self.PanelInfo.gameObject:SetActive(true) + self:SetUiSprite(self.ImgRole, icon) + self.TxtName.text = name or "" + self.TxtDesc.text = content + + if pos == 0 then + self.PanelInfoRect.anchorMax = CS.UnityEngine.Vector2(0, 1) + self.PanelInfoRect.anchorMin = CS.UnityEngine.Vector2(0, 1) + self.PanelInfoRect.anchoredPosition = CS.UnityEngine.Vector2(500, -380) + else + self.PanelInfoRect.anchorMax = CS.UnityEngine.Vector2(1, 1) + self.PanelInfoRect.anchorMin = CS.UnityEngine.Vector2(1, 1) + self.PanelInfoRect.anchoredPosition = CS.UnityEngine.Vector2(-500, -380) + end +end + +--隐藏头像 +function XUiGuideNew:HideDialog() + self.PanelInfo.gameObject:SetActive(false) +end + +--聚焦panel +function XUiGuideNew:FocuOnPanel(panel, eulerAngles, passEvent) + eulerAngles = eulerAngles or CS.UnityEngine.Vector3.zero + self.BtnPass.gameObject:SetActive(true) + self.BtnPass.gameObject.transform.eulerAngles = eulerAngles + self.Guide:SetTarget(panel) + + if not XTool.UObjIsNil(panel.gameObject) then + CS.XGuideEventPass.Target = panel.gameObject + end + + CS.XGuideEventPass.IsPassEvent = passEvent + if self.AniGuideJiaoLoop then + self.AniGuideJiaoLoop.gameObject:SetActive(false) + self.AniGuideJiaoLoop.gameObject:SetActive(true) + end +end + +function XUiGuideNew:FocuOnFightPanel(panel) + self.BtnPass.gameObject:SetActive(true) + self.Guide:SetTarget(panel) + CS.XGuideEventPass.Target = nil +end + +--显示遮罩 +function XUiGuideNew:ShowMark(isShowMask) + self.PanelMaskAll.gameObject:SetActive(isShowMask) + self.BtnPanelMaskGuide.gameObject:SetActive(true) + self.Guide:SetPass(not isShowMask) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridChallengeItem.lua b/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridChallengeItem.lua new file mode 100644 index 00000000..1b88fa15 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridChallengeItem.lua @@ -0,0 +1,60 @@ +local XUiGridChallengeItem = XClass(nil, "XUiGridChallengeItem") +local ShowTaskNum = 4 +local blue = "#3582BF" +local black = "#000000" + +function XUiGridChallengeItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) +end + +function XUiGridChallengeItem:Init(uiRoot) + self.UiRoot = uiRoot +end + +function XUiGridChallengeItem:SetChallengeItem(data) + -- 通用 + self.TxtTitleNor.text = data.Name + self.TxtTitlePress.text = data.Name + + local isTaskChallenge = data.ChallengeType == XGuildConfig.GuildChallengeEnter.GuildTask + self.PanelTaskNorBg.gameObject:SetActiveEx(isTaskChallenge) + self.PanelTaskPressBg.gameObject:SetActiveEx(disTaskChallenge) + self.PanelTask.gameObject:SetActiveEx(isTaskChallenge) + if isTaskChallenge then + self:HandleChallengeTask() + end + -- 敬请期待 + self.PanelCommon.gameObject:SetActiveEx(data.ChallengeType == XGuildConfig.GuildChallengeEnter.GuildBoss or data.ChallengeType == XGuildConfig.GuildChallengeEnter.GuildPet) +end + +function XUiGridChallengeItem:HandleChallengeTask() + local alltasks = XDataCenter.GuildManager.GetSortedGuildDailyTasks() + local totalTaskCount = #alltasks + local finishTaskCount = 0 + for i = 1, totalTaskCount do + local task = alltasks[i] + local isBlue = false + + if task.State == XDataCenter.TaskManager.TaskState.Finish or task.State == XDataCenter.TaskManager.TaskState.Invalid then + finishTaskCount = finishTaskCount + 1 + isBlue = true + elseif task.State == XDataCenter.TaskManager.TaskState.Achieved then + isBlue = true + end + local txtColor = isBlue and blue or black + local taskTemplate = XDataCenter.TaskManager.GetTaskTemplate(task.Id) + if i <= ShowTaskNum then + self[string.format("TxtTask%d", i)].text = string.format("%s", txtColor, taskTemplate.Desc) + end + end + self.TxtTaskNum.text = string.format("%d/%d", finishTaskCount, totalTaskCount) + + for i = totalTaskCount + 1, ShowTaskNum do + self[string.format("TxtTask%d", i)].text = "" + end +end + +return XUiGridChallengeItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridChannelItem.lua b/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridChannelItem.lua new file mode 100644 index 00000000..f9579db1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridChannelItem.lua @@ -0,0 +1,34 @@ +local XUiGridChannelItem = XClass(nil, "XUiGridChannelItem") + +function XUiGridChannelItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.OriginSize = self.Transform.sizeDelta + + XTool.InitUiObject(self) +end + +function XUiGridChannelItem:Init(uiRoot) + self.UiRoot = uiRoot +end + +function XUiGridChannelItem:SetNewsInfo(chat) + local nameRemark = XDataCenter.SocialManager.GetPlayerRemark(chat.SenderId, chat.NickName) + if chat.MsgType == ChatMsgType.System then + self.TxtInfo.text = string.format("%s:%s", CS.XTextManager.GetText("GuildChannelTypeAll"), chat.Content) + else + local content = chat.Content + if chat.MsgType == ChatMsgType.Emoji then + content = CS.XTextManager.GetText("GuildEmojiReplace") + end + self.TxtInfo.text = string.format("【%s】:%s", nameRemark, content) + end + self:Resize() +end + +function XUiGridChannelItem:Resize() + self.Transform.sizeDelta = CS.UnityEngine.Vector2(self.OriginSize.x, self.TxtInfo.preferredHeight) +end + + +return XUiGridChannelItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridChannelVistorItem.lua b/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridChannelVistorItem.lua new file mode 100644 index 00000000..a61f6570 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridChannelVistorItem.lua @@ -0,0 +1,33 @@ +local XUiGridChannelVistorItem = XClass(nil, "XUiGridChannelVistorItem") + +function XUiGridChannelVistorItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.OriginSize = self.Transform.sizeDelta + XTool.InitUiObject(self) +end + +function XUiGridChannelVistorItem:Init(uiRoot) + self.UiRoot = uiRoot +end + +-- 更新数据 +function XUiGridChannelVistorItem:OnRefresh(itemdata) + if not itemdata then + return + end + + local nameRemark = XDataCenter.SocialManager.GetPlayerRemark(itemdata.SenderId, itemdata.NickName) + if itemdata.MsgType == ChatMsgType.System then + self.TxtInfo.text = string.format("%s:%s", CS.XTextManager.GetText("GuildChannelTypeAll"), itemdata.Content) + else + self.TxtInfo.text = string.format("【%s】:%s", nameRemark, itemdata.Content) + end + + self:Resize() +end + +function XUiGridChannelVistorItem:Resize() + self.Transform.sizeDelta = CS.UnityEngine.Vector2(self.OriginSize.x, self.TxtInfo.preferredHeight) +end +return XUiGridChannelVistorItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridCustomNameItem.lua b/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridCustomNameItem.lua new file mode 100644 index 00000000..1d03d1d6 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridCustomNameItem.lua @@ -0,0 +1,37 @@ +local XUiGridCustomNameItem = XClass(nil, "XUiGridCustomNameItem") + +function XUiGridCustomNameItem:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + XTool.InitUiObject(self) + self.BtnName.CallBack = function() self:OnBtnName() end +end + +function XUiGridCustomNameItem:SetItemData(itemData) + if not itemData then return end + self.CustomData = itemData + self.InputField.text = "" + local rankName = XDataCenter.GuildManager.GetRankNameByLevel(self.CustomData.Id) + self.InputField.placeholder.text = rankName +end + +function XUiGridCustomNameItem:GetInputName() + local inputName = self.InputField.text + return tostring(inputName) +end + +function XUiGridCustomNameItem:SetName(name) + if self.InputField.placeholder.text ~= name then + self.InputField.text = name + else + self.InputField.text = "" + end +end + +function XUiGridCustomNameItem:OnBtnName() + local oldName = self.InputField.text == "" and self.InputField.placeholder.text or self.InputField.text + self.UiRoot:OpenNameSelectPanel(self.CustomData.Id, oldName) +end + +return XUiGridCustomNameItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridGuildBoxItem.lua b/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridGuildBoxItem.lua new file mode 100644 index 00000000..e312ac40 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridGuildBoxItem.lua @@ -0,0 +1,102 @@ +XUiGridGuildBoxItem = XClass(nil, "XUiGridGuildBoxItem") + +function XUiGridGuildBoxItem:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + self.BtnActive.CallBack = function() self:OnBtnActiveClick() end +end + +function XUiGridGuildBoxItem:RefreshGift(giftTemplate, index, maxContribute) + self.GiftTemplate = giftTemplate + self.Index = index + + self.TxtValue.text = giftTemplate.GiftContribute + local totalLength = self.Transform.parent.rect.width + local localposition = self.Transform.localPosition + local adjustX = totalLength * giftTemplate.GiftContribute / maxContribute + self.Transform.localPosition = CS.UnityEngine.Vector3(adjustX - totalLength / 2, localposition.y, localposition.z) + + self.ImgRe.gameObject:SetActiveEx(false) + self.PanelEffect.gameObject:SetActiveEx(false) + + local lastGuildId = XDataCenter.GuildManager.GetGiftGuildGot() + local curGuildId = XDataCenter.GuildManager.GetGuildId() + + local giftLevelGots = XDataCenter.GuildManager.GetGiftLevelGot() + local giftContribute = XDataCenter.GuildManager.GetGiftContribute() + local giftGuildLevel = XDataCenter.GuildManager.GetGiftGuildLevel() + + if XDataCenter.GuildManager.IsGuildTourist() then + return + end + + if lastGuildId > 0 and lastGuildId ~= curGuildId then + return + end + + local giftData = XGuildConfig.GetGuildGiftByGuildLevelAndGiftLevel(giftGuildLevel, giftTemplate.GiftLevel) + if not giftData then + return + end + + if giftContribute < giftData.GiftContribute then + return + end + + if giftLevelGots[giftTemplate.GiftLevel] then + self.ImgRe.gameObject:SetActiveEx(true) + return + end + + self.PanelEffect.gameObject:SetActiveEx(true) + +end + +function XUiGridGuildBoxItem:OnBtnActiveClick() + if self.RootUi:ChecKickOut() then return end + if not self.GiftTemplate then return end + + local lastGuildId = XDataCenter.GuildManager.GetGiftGuildGot() + local curGuildId = XDataCenter.GuildManager.GetGuildId() + + local giftLevelGots = XDataCenter.GuildManager.GetGiftLevelGot() + local giftContribute = XDataCenter.GuildManager.GetGiftContribute() + local giftGuildLevel = XDataCenter.GuildManager.GetGiftGuildLevel() + + -- 游客 + if XDataCenter.GuildManager.IsGuildTourist() then + XUiManager.TipMsg(CS.XTextManager.GetText("GuildTourstAccess")) + return + end + + -- 本周换过公会 + if lastGuildId > 0 and lastGuildId ~= curGuildId then + XUiManager.TipMsg(CS.XTextManager.GetText("GuildGiftChangeGuildCondition")) + return + end + + local giftData = XGuildConfig.GetGuildGiftByGuildLevelAndGiftLevel(giftGuildLevel, self.GiftTemplate.GiftLevel) + if not giftData then + XUiManager.TipMsg(CS.XTextManager.GetText("GuildGiftMaxLevel")) + return + end + + if giftContribute < giftData.GiftContribute then + XUiManager.OpenUiTipRewardByRewardId(self.GiftTemplate.GiftReward, CS.XTextManager.GetText("DailyActiveRewardTitle")) + return + end + + -- 已领取:活显示奖励 + if giftLevelGots[self.GiftTemplate.GiftLevel] then + XUiManager.OpenUiTipRewardByRewardId(self.GiftTemplate.GiftReward, CS.XTextManager.GetText("DailyActiveRewardTitle")) + return + end + + XDataCenter.GuildManager.GuildGetGift(self.GiftTemplate.GiftLevel, function() + end) + +end + +return XUiGridGuildBoxItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridGuildEnlistItem.lua b/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridGuildEnlistItem.lua new file mode 100644 index 00000000..aeb48b3a --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridGuildEnlistItem.lua @@ -0,0 +1,96 @@ +local XUiGridGuildEnlistItem = XClass(nil, "XUiGridGuildEnlistItem") + +function XUiGridGuildEnlistItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + + if self.BtnRecruit then + self.BtnRecruit.CallBack = function() self:OnBtnRecruitClick() end + end + + if self.BtnAccept then + self.BtnAccept.CallBack = function() self:OnBtnAcceptClick() end + end + + if self.BtnRefuse then + self.BtnRefuse.CallBack = function() self:OnBtnRefuseClick() end + end + + if self.BtnHead then + self.BtnHead.CallBack = function() self:OnBtnHeadClick() end + end +end + +function XUiGridGuildEnlistItem:Init(uiParent, uiRoot) + self.UiParent = uiParent + self.UiRoot = uiRoot +end + +-- PlayerId, +-- PlayerName +-- Level +-- HeadPortraitId +-- GuildCoin +-- LastLoginTime +function XUiGridGuildEnlistItem:SetItemData(itemData) + self.ItemData = itemData + self.TxtName.text = XDataCenter.SocialManager.GetPlayerRemark(itemData.PlayerId, itemData.PlayerName) + if itemData.OnlineFlag == 1 then + self.TxtOnline.text = CS.XTextManager.GetText("GuildMemberOnline") + else + self.TxtOnline.text = XUiHelper.CalcLatelyLoginTime(itemData.LastLoginTime) + end + + XUiPlayerLevel.UpdateLevel(itemData.Level, self.TxtLv, CS.XTextManager.GetText("GuildMemberLevel", itemData.Level)) + + self.TxtNum.text = itemData.GuildCoin + self.RImgContribute:SetRawImage(XDataCenter.ItemManager.GetItemIcon(XGuildConfig.GuildCoin)) + XUiPLayerHead.InitPortrait(itemData.HeadPortraitId, itemData.HeadFrameId, self.Head) +end + +function XUiGridGuildEnlistItem:OnBtnRecruitClick() + if self.ItemData then + if not XDataCenter.GuildManager.IsGuildAdminister() then + XUiManager.TipMsg(CS.XTextManager.GetText("GuildNotAdministor")) + self.UiRoot:Close() + return + end + XDataCenter.GuildManager.GuildRecruit(self.ItemData.PlayerId, function() + self.UiParent:RefreshEnlists() + end) + end +end + +function XUiGridGuildEnlistItem:OnBtnAcceptClick() + if self.ItemData and self.UiRoot and self.UiParent then + if not XDataCenter.GuildManager.IsGuildAdminister() then + XUiManager.TipMsg(CS.XTextManager.GetText("GuildNotAdministor")) + self.UiRoot:Close() + return + end + XDataCenter.GuildManager.AcceptGuildRequest(self.ItemData.PlayerId, self.ItemData.PlayerName, function() + self.UiParent:RefreshEnlists() + end) + end +end + +function XUiGridGuildEnlistItem:OnBtnRefuseClick() + if self.ItemData and self.UiRoot and self.UiParent then + if not XDataCenter.GuildManager.IsGuildAdminister() then + XUiManager.TipMsg(CS.XTextManager.GetText("GuildNotAdministor")) + self.UiRoot:Close() + return + end + XDataCenter.GuildManager.RefuseGuildRequest(self.ItemData.PlayerId, function() + self.UiParent:RefreshEnlists() + end) + end +end + +function XUiGridGuildEnlistItem:OnBtnHeadClick() + if not self.ItemData then return end + XDataCenter.PersonalInfoManager.ReqShowInfoPanel(self.ItemData.PlayerId) +end +return XUiGridGuildEnlistItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridGuildGiftItem.lua b/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridGuildGiftItem.lua new file mode 100644 index 00000000..05c48f18 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridGuildGiftItem.lua @@ -0,0 +1,54 @@ +local XUiGridGuildGiftItem = XClass(nil, "XUiGridGuildGiftItem") +local GuildWillRequestTips +local GuildWillRequestDesTips +local TotalReqcount + +function XUiGridGuildGiftItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + GuildWillRequestTips = CS.XTextManager.GetText("GuildWillRequestTips") + GuildWillRequestDesTips = CS.XTextManager.GetText("GuildWillRequestDesTips") + TotalReqcount = XGuildConfig.GetGuildWishMaxCountByLevel(XDataCenter.GuildManager.GetGuildLevel()) + XTool.InitUiObject(self) +end + +function XUiGridGuildGiftItem:Init(uiRoot) + self.UiRoot = uiRoot + self.GridItemUI = XUiGridCommon.New(uiRoot,self.GridItem) + self:InitFun() +end + +function XUiGridGuildGiftItem:OnBtnSetClick() + XLuaUiManager.Open("UiDialog", GuildWillRequestTips, GuildWillRequestDesTips, XUiManager.DialogType.Normal, nil, function () + self:PublishWishRequest() + end) +end + +function XUiGridGuildGiftItem:PublishWishRequest() + local curcount = XDataCenter.GuildManager.GetCurWishReqCount() + if curcount == TotalReqcount then + XUiManager.TipText("GuildDonationPublishTips") + return + end + + XDataCenter.GuildManager.PublishWishRequest(self.ItemData.Id,function() + self.UiRoot:SetCurGiftReqCount() + XUiManager.TipText("GuildDonationPublishSuccessTips") + end) +end + +function XUiGridGuildGiftItem:InitFun() + XUiHelper.RegisterClickEvent(self.GridItemUI, self.GridItemUI.BtnClick, function()self:OnBtnSetClick()end) +end + +-- 更新数据 +function XUiGridGuildGiftItem:OnRefresh(itemdata) + if not itemdata then + return + end + + self.ItemData = itemdata + self.GridItemUI:Refresh(itemdata.Id) +end + +return XUiGridGuildGiftItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridGuildHornorMemberGroup.lua b/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridGuildHornorMemberGroup.lua new file mode 100644 index 00000000..980f7f54 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridGuildHornorMemberGroup.lua @@ -0,0 +1,32 @@ +local XUiGridGuildHornorMemberGroup = XClass(nil, "XUiGridGuildHornorMemberGroup") +local XUiGridGuildMemberCard = require("XUi/XUiGuild/XUiChildItem/XUiGridGuildMemberCard") + +function XUiGridGuildHornorMemberGroup:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.PageMemberList = {} +end + +function XUiGridGuildHornorMemberGroup:Init(uiRoot) + self.UiRoot = uiRoot +end + +function XUiGridGuildHornorMemberGroup:Refresh(memberPageList) + self.MemberList = memberPageList + for i = 1, XGuildConfig.RankBottomPageCount do + if not self.PageMemberList[i] then + local ui = CS.UnityEngine.Object.Instantiate(self.UiGuildRank) + local grid = XUiGridGuildMemberCard.New(ui, self.UiRoot) + grid.Transform:SetParent(self.Transform, false) + self.PageMemberList[i] = grid + end + self.PageMemberList[i].GameObject:SetActiveEx(true) + self.PageMemberList[i]:RefreshNormalMember(self.MemberList[i]) + end + -- for i = #self.MemberList + 1, #self.PageMemberList do + -- self.PageMemberList[i].GameObject:SetActiveEx(false) + -- end +end + +return XUiGridGuildHornorMemberGroup \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridGuildLogItem.lua b/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridGuildLogItem.lua new file mode 100644 index 00000000..2044873d --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridGuildLogItem.lua @@ -0,0 +1,27 @@ +local XUiGridGuildLogItem = XClass(nil, "XUiGridGuildLogItem") + +function XUiGridGuildLogItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.OldSizeDelta = self.Transform.sizeDelta + XTool.InitUiObject(self) +end + +function XUiGridGuildLogItem:Init(uiRoot) + self.UiRoot = uiRoot +end + +function XUiGridGuildLogItem:SetItemData(itemData, newsType) + local newsConfig = XGuildConfig.GetGuildNewsById(itemData.MsgId) + self.PanelContent.text = CS.XTextManager.FormatString(newsConfig.Content, itemData.Params[1], itemData.Params[2], itemData.Params[3], itemData.Params[4], itemData.Params[5]) + self.TxtInfo.text = CS.XTextManager.GetText("GuildLogItemType", XGuildConfig.NewsName[newsConfig.Group]) + self.TxtInfoTime1.text = XTime.TimestampToGameDateTimeString(itemData.Time, "HH:mm") + self.TxtInfoTime2.text = XTime.TimestampToGameDateTimeString(itemData.Time, "MM/dd") + self:OnResize() +end + +function XUiGridGuildLogItem:OnResize() + self.Transform.sizeDelta = CS.UnityEngine.Vector2(self.OldSizeDelta.x, self.PanelContent.preferredHeight + 30) +end + +return XUiGridGuildLogItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridGuildMemberCard.lua b/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridGuildMemberCard.lua new file mode 100644 index 00000000..506cf3cb --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridGuildMemberCard.lua @@ -0,0 +1,106 @@ +local XUiGridGuildMemberCard = XClass(nil, "XUiGridGuildMemberCard") +local XUiButtonState = CS.UiButtonState +-- dataformat +-- "Id" = 14757703, +-- "LastLoginTime" = 1591250815, +-- "ContributeHistory" = 0, +-- "ContributeAct" = 28, +-- "Name" = "指挥官08650", +-- "Popularity" = 0, +-- "RankLevel" = 4, +-- "HeadPortraitId" = 9000002, +-- "OnlineFlag" = 0, +-- "Level" = 28, +-- "ContributeRank" = 1, +-- "ContributeIn7Days" = 0, + +function XUiGridGuildMemberCard:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + self.BtnGift.CallBack = function() self:OnBtnGiftClick() end + if self.UiGuildRank then + self.UiGuildRank.CallBack = function() self:OnBtnMemberClick() end + end + self:SetBlank() +end + +function XUiGridGuildMemberCard:OnBtnGiftClick() + local memberList = XDataCenter.GuildManager.GetMemberList() + local memberInfo = memberList[self.MemberCard.Id] + if self.MemberCard.Id == XPlayer.Id then return end + if memberInfo then + XLuaUiManager.Open("UiGuildGift", memberInfo) + end +end + +function XUiGridGuildMemberCard:OnBtnMemberClick() + if not self.MemberCard then return end + if self.MemberCard.Id ~= XPlayer.Id then + XDataCenter.PersonalInfoManager.ReqShowInfoPanel(self.MemberCard.Id) + end +end + +function XUiGridGuildMemberCard:RefreshNormalMember(card) + if not card then + self:SetBlank() + return + end + self:RefreshCommonInfo(card) + self.TxtRankNum.text = card.ContributeRank + self.TxtRankNumPress.text = card.ContributeRank +end + +function XUiGridGuildMemberCard:RefreshTop5Member(card) + if not card then + self:SetBlank() + return + end + self:RefreshCommonInfo(card) + local rankIcon = CS.XGame.ClientConfig:GetString("GuildContributeRankFlag"..card.ContributeRank) + self.RImgRankNormal:SetRawImage(rankIcon) + self.RImgRankPress:SetRawImage(rankIcon) +end + +function XUiGridGuildMemberCard:RefreshCommonInfo(card) + self.BtnMember:SetButtonState(CS.UiButtonState.Normal) + self.MemberCard = card + local remarkName = XDataCenter.SocialManager.GetPlayerRemark(card.Id, card.Name) + self.TxtPlayerName.text = remarkName + self.TxtPlayerNamePress.text = remarkName + + local contributeVal = card.ContributeAct --本期活动贡献 + local contributeDes = CS.XTextManager.GetText("GuildContributeDesc", contributeVal) + self.TxtContribute.text = contributeDes + self.TxtContributePress.text = contributeDes + + local popularityVal = card.Popularity -- 人气值 + local popularityDes = CS.XTextManager.GetText("GuildPopularityDesc", popularityVal) + self.TxtPopularity.text = popularityDes + self.TxtPopularityPress.text = popularityDes + + local headPortraitId = card.HeadPortraitId + local headFrameIdId = card.HeadFrameId + + XUiPLayerHead.InitPortrait(headPortraitId, headFrameIdId, self.HeadNormal) + XUiPLayerHead.InitPortrait(headPortraitId, headFrameIdId, self.HeadPress) + + local isMember = card.RankLevel <= XGuildConfig.GuildRankLevel.Member + if isMember then + self.PanelRank.gameObject:SetActiveEx(true) + self.TxtRankName.text = XDataCenter.GuildManager.GetRankNameByLevel(card.RankLevel) + end + + local btnStatus = card.Id == XPlayer.Id and XUiButtonState.Disable or XUiButtonState.Normal + self.BtnGift.gameObject:SetActiveEx(true) + self.BtnGift:SetButtonState(btnStatus) +end + +function XUiGridGuildMemberCard:SetBlank() + self.BtnMember:SetButtonState(CS.UiButtonState.Disable) + self.PanelRank.gameObject:SetActiveEx(false) + self.BtnGift.gameObject:SetActiveEx(false) +end + +return XUiGridGuildMemberCard \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridGuildPersonItem.lua b/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridGuildPersonItem.lua new file mode 100644 index 00000000..3a614aeb --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridGuildPersonItem.lua @@ -0,0 +1,48 @@ +local XUiGridGuildPersonItem = XClass(nil, "XUiGridGuildPersonItem") + +function XUiGridGuildPersonItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) +end + +function XUiGridGuildPersonItem:Init(uiRoot) + self.UiRoot = uiRoot +end + +-- 更新数据 +function XUiGridGuildPersonItem:OnRefresh(itemdata) + if not itemdata then + return + end + + self.ItemData = itemdata + self.CurId = itemdata.Id + --构造体头像 + local path = XCharacterConfigs.GetCharacterEmotionIcon(itemdata.Id) + self.ImgIcon:SetRawImage(path) + --名字1 + self.TxtName1.text = XCharacterConfigs.GetCharacterTradeName(itemdata.Id) + --名字2 + self.TxtName2.text = XCharacterConfigs.GetCharacterName(itemdata.Id) + self.CurStatus = itemdata.Status or false + self:SetSeleStatus(self.CurStatus) +end + +function XUiGridGuildPersonItem:OnClickSeleStatus() + self.CurStatus = not self.CurStatus + self.ItemData.Status = self.CurStatus + self:SetSeleStatus(self.CurStatus) +end + +function XUiGridGuildPersonItem:SetSeleStatus(status) + self.ImgSelect.gameObject:SetActiveEx(status) + if status then + self.UiRoot:RecordSeleId(self.CurId) + else + self.UiRoot:RemoveRecordSeleId(self.CurId) + end +end + +return XUiGridGuildPersonItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridGuildPresentItem.lua b/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridGuildPresentItem.lua new file mode 100644 index 00000000..329e6eb2 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridGuildPresentItem.lua @@ -0,0 +1,88 @@ +local XUiGridGuildPresentItem = XClass(nil, "XUiGridGuildPresentItem") + +function XUiGridGuildPresentItem:Ctor(ui, uiRoot, callback) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + XTool.InitUiObject(self) + self.ClickCallback = callback + self.BtnGiftDetail.CallBack = function() self:OnBtnGiftDetailsClick() end + + XUiHelper.RegisterClickEvent(self, self.BtnSelect, self.OnBtnSelectClick) +end + +-- ItemId = itemId, +-- ItemCount = itemCount, +-- Popularity = present.Popularity, +function XUiGridGuildPresentItem:RefreshGiftItem(gift, gridIndex) + self.Gift = gift + self.CurSelectNum = 0 + self.GridIndex = gridIndex + self:SetSelectNum(self.CurSelectNum) + + local itemId = self.Gift.ItemId + self.RImgIcon:SetRawImage(XDataCenter.ItemManager.GetItemIcon(itemId)) + + local itemQuality = XDataCenter.ItemManager.GetItemQuality(itemId) + XUiHelper.SetQualityIcon(self.UiRoot, self.ImgIconQuality, itemQuality) + + self.TxtName.text = XDataCenter.ItemManager.GetItemName(itemId) + self.TxtOwnCount.text = self.Gift.ItemCount +end + + +function XUiGridGuildPresentItem:SetSelectState(isSelected, forceRefresh) + if isSelected ~= self.SelectState then + self.SelectState = isSelected + self:RefreshSelectState() + else + if forceRefresh then + self:RefreshSelectState() + end + end +end + +function XUiGridGuildPresentItem:RefreshSelectState() + if self.ImgSelect then + self.ImgSelect.gameObject:SetActive(self.SelectState) + end +end + +function XUiGridGuildPresentItem:GetSelectNums() + local selectNum = self.CurSelectNum or 0 + local totalPopularity = 0 + totalPopularity = selectNum * self.Gift.Popularity + return self.Gift.ItemId, selectNum, totalPopularity +end + +function XUiGridGuildPresentItem:SetSelectNum(num) + self.CurSelectNum = num +end + +function XUiGridGuildPresentItem:OnBtnGiftDetailsClick() + if not self.Gift then return end + XLuaUiManager.Open("UiTip", self.Gift.ItemId) +end + +function XUiGridGuildPresentItem:OnBtnSelectClick() + if self.ClickCallback then + self.ClickCallback({ Data = self.Gift, GridIndex = self.GridIndex, CurSelectNum = self.CurSelectNum }, self) + end +end + +function XUiGridGuildPresentItem:OnBtnAddSelectClick() + if not self.Gift then return end + if self.CurSelectNum + 1 <= self.Gift.ItemCount then + self.CurSelectNum = self.CurSelectNum + 1 + self:SetSelectNum(self.CurSelectNum) + end +end + +function XUiGridGuildPresentItem:OnBtnMinusSelectClick() + if self.CurSelectNum - 1 >= 0 then + self.CurSelectNum = self.CurSelectNum - 1 + self:SetSelectNum(self.CurSelectNum) + end +end + +return XUiGridGuildPresentItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridGuildTaskItem.lua b/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridGuildTaskItem.lua new file mode 100644 index 00000000..48a61f0c --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridGuildTaskItem.lua @@ -0,0 +1,74 @@ +local XUiGridGuildTaskItem = XClass(nil, "XUiGridGuildTaskItem") + +function XUiGridGuildTaskItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + self.RewardList = {} + self.GridCommon.gameObject:SetActiveEx(false) +end + +function XUiGridGuildTaskItem:Init(uiRoot) + self.UiRoot = uiRoot +end + +function XUiGridGuildTaskItem:SetItemData(itemData) + self.Data = itemData + local config = XDataCenter.TaskManager.GetTaskTemplate(self.Data.Id) + self.TxtGrade.text = config.Desc + + self:UpdateProgress(self.Data) + + -- 领取状态 + self.BtnReceive.gameObject:SetActiveEx(false) + self.ImgCannotReceive.gameObject:SetActiveEx(false) + self.ImgAlreadyReceived.gameObject:SetActiveEx(false) + if self.Data.State == XDataCenter.TaskManager.TaskState.Achieved then + self.BtnReceive.gameObject:SetActiveEx(true) + elseif self.Data.State == XDataCenter.TaskManager.TaskState.Finish or self.Data.State == XDataCenter.TaskManager.TaskState.Invalid then + self.ImgAlreadyReceived.gameObject:SetActiveEx(true) + else + self.ImgCannotReceive.gameObject:SetActiveEx(true) + end + + -- 奖励 + local rewards = XRewardManager.GetRewardList(config.RewardId) + for i = 1, #self.RewardList do + self.RewardList[i]:Refresh() + end + + for i = 1, #rewards do + local panel = self.RewardList[i] + if not panel then + if #self.RewardList == 0 then + panel = XUiGridCommon.New(self.UiRoot, self.GridCommon) + else + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommon) + ui.transform:SetParent(self.PanelTreasureContent, false) + panel = XUiGridCommon.New(self.UiRoot, ui) + end + table.insert(self.RewardList, panel) + end + + panel:Refresh(rewards[i]) + end + +end + +function XUiGridGuildTaskItem:UpdateProgress(data) + local config = XDataCenter.TaskManager.GetTaskTemplate(data.Id) + if #config.Condition < 2 then + local result = config.Result > 0 and config.Result or 1 + XTool.LoopMap(self.Data.Schedule, function(_, pair) + pair.Value = (pair.Value >= result) and result or pair.Value + self.TxtGradeStarNums.text = string.format("%d/%d", pair.Value, result) + self.ImgGradeStarActive.gameObject:SetActiveEx(pair.Value >= result) + end) + else + self.ImgGradeStarActive.gameObject:SetActiveEx(false) + self.TxtGradeStarNums.text = "" + end +end + +return XUiGridGuildTaskItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridMemberItem.lua b/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridMemberItem.lua new file mode 100644 index 00000000..06b4b0f9 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridMemberItem.lua @@ -0,0 +1,169 @@ +local XUiGridMemberItem = XClass(nil, "XUiGridMemberItem") + +function XUiGridMemberItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.CanSet = false + self.BtnDismiss.CallBack = function() self:OnBtnDismissClick() end + self.BtnGift.CallBack = function() self:OnBtnGiftClick() end + self.BtnKickOut.CallBack = function() self:OnBtnKickOut() end + self.BtnChangePosition.CallBack = function() self:OnBtnChangePosition() end + self.BtnSet.CallBack = function() self:OnBtnSet() end +end + +function XUiGridMemberItem:Init(uiRoot) + self.UiRoot = uiRoot +end + +function XUiGridMemberItem:SetMemberInfo(memberInfo, selectIndex) + self.MemberInfo = memberInfo + self.IsSetPanel = memberInfo.IsSetPanel + self.Index = memberInfo.Index + self:UpdateGuildInfo() + local setBtnStatus = (selectIndex and self.Index == selectIndex) + if self.CanSet then + self.BtnSet:SetButtonState(setBtnStatus and CS.UiButtonState.Select or CS.UiButtonState.Normal) + end + if self.IsSetPanel then + -- self.PanelMemberInfo.gameObject:SetActiveEx(true) + self.PanelMemberSet.gameObject:SetActiveEx(true) + else + -- self.PanelMemberInfo.gameObject:SetActiveEx(true) + self.PanelMemberSet.gameObject:SetActiveEx(false) + end + + self.TxtName.text = XDataCenter.SocialManager.GetPlayerRemark(memberInfo.Id, memberInfo.Name) + XUiPlayerLevel.UpdateLevel(memberInfo.Level, self.TextLv, CS.XTextManager.GetText("GuildMemberLevel", memberInfo.Level)) + local jobName = XDataCenter.GuildManager.GetRankNameByLevel(memberInfo.RankLevel) + self.TxtJob.text = jobName + self.TxtContribution.text = memberInfo.ContributeAct or 0 + self.TxtHistoryContribution.text = memberInfo.ContributeHistory or 0 + if memberInfo.OnlineFlag == 1 then + self.TxtLastLogin.text = CS.XTextManager.GetText("GuildMemberOnline") + else + self.TxtLastLogin.text = XUiHelper.CalcLatelyLoginTime(memberInfo.LastLoginTime) + end + self.TxtPopulation.text = memberInfo.Popularity + self:UpdateDissmissState(self.MemberInfo) + XUiPLayerHead.InitPortrait(memberInfo.HeadPortraitId, memberInfo.HeadFrameId, self.Head) + local isPlayer = memberInfo.Id == XPlayer.Id + self.BtnGift:SetDisable(isPlayer, not isPlayer) + + self.LayoutNode:SetDirty() +end + +function XUiGridMemberItem:UpdateDissmissState(memberInfo) + if not memberInfo then return end + + local hasImpeach = XDataCenter.GuildManager.HasImpeachLeader() + local canImpeach = XDataCenter.GuildManager.CanImpeachLeader() + local isLeaderMyself = XDataCenter.GuildManager.IsGuildLeader() + local memberIsLeader = memberInfo.RankLevel == XGuildConfig.GuildRankLevel.Leader + self.BtnDismiss.gameObject:SetActiveEx(canImpeach and not hasImpeach and not isLeaderMyself and memberIsLeader) +end + +function XUiGridMemberItem:UpdateMemberJobInfo(memberInfo) + self.TxtJob.text = XDataCenter.GuildManager.GetRankNameByLevel(memberInfo.RankLevel) + self.TxtPopulation.text = memberInfo.Popularity +end + +function XUiGridMemberItem:OnBtnDismissClick() + if self:CheckKickOut() then return end + self.DissmissCallBack = function() + XDataCenter.GuildManager.GuildImpeachLeader(function() + XDataCenter.GuildManager.SetImpeachLeader() + self:UpdateDissmissState(self.MemberInfo) + end) + end + XLuaUiManager.Open("UiGuildAsset", self.DissmissCallBack) +end + +function XUiGridMemberItem:OnBtnGiftClick() + if self:CheckKickOut() then return end + XLuaUiManager.Open("UiGuildGift", self.MemberInfo) +end + +function XUiGridMemberItem:UpdateGuildInfo() + -- 管理级别大于该成员则设置按钮可用:更换职位、踢出公会 + self:ResetGuildBtns() + if not self.MemberInfo then return end + local targetRankLevel = self.MemberInfo.RankLevel + local isAdministor = XDataCenter.GuildManager.IsGuildAdminister() + local myRankLevel = XDataCenter.GuildManager.GetCurRankLevel() + local myGuildId = XDataCenter.GuildManager.GetGuildId() + if isAdministor then + self.BtnSet.gameObject:SetActiveEx(true) + if targetRankLevel ~= nil and targetRankLevel > 0 and myRankLevel < targetRankLevel then + self.CanSet = true + self.BtnKickOut.gameObject:SetActiveEx(true) + self.BtnChangePosition.gameObject:SetActiveEx(true) + self.BtnSet:SetButtonState(CS.UiButtonState.Normal) + else + self.CanSet = false + self.BtnSet:SetButtonState(CS.UiButtonState.Disable) + end + end +end + +function XUiGridMemberItem:ResetGuildBtns() + self.BtnSet.gameObject:SetActiveEx(false) + self.BtnKickOut.gameObject:SetActiveEx(false) + self.BtnChangePosition.gameObject:SetActiveEx(false) +end + + +function XUiGridMemberItem:OnBtnKickOut() + -- 中途被踢出公会 + if self:CheckKickOut() then return end + -- 职位变更 + if self:HasModifyGuildAccess() then return end + + local title = CS.XTextManager.GetText("GuildDialogTitle") + local content = CS.XTextManager.GetText("GuildIsKickMember") + + XUiManager.DialogTip(title, content, XUiManager.DialogType.Normal, function() + end, function() + XDataCenter.GuildManager.GuildKickMember(self.MemberInfo.Id, function() + XUiManager.TipMsg(CS.XTextManager.GetText("GuildKickMemberSuccess")) + end) + end) +end + +function XUiGridMemberItem:OnBtnChangePosition() + -- 中途被踢出公会 + if self:CheckKickOut() then return end + -- 职位变更 + if self:HasModifyGuildAccess() then return end + -- 是否有更换职位的权利 + local memberList = XDataCenter.GuildManager.GetMemberList() + local memberInfo = memberList[self.MemberInfo.Id] + if memberInfo then + XLuaUiManager.Open("UiGuildChangePosition", XGuildConfig.TipsType.ChangePosition, memberInfo) + end +end + +function XUiGridMemberItem:OnBtnSet() + if not self.CanSet then return end + XEventManager.DispatchEvent(XEventId.EVENT_GUILD_MEMBER_SET ,self.Index) +end + +function XUiGridMemberItem:CheckKickOut() + -- 中途被踢出公会 + if not XDataCenter.GuildManager.IsJoinGuild() then + XUiManager.TipMsg(CS.XTextManager.GetText("GuildKickOutByAdministor")) + self.UiRoot:Close() + return true + end + return false +end + +function XUiGridMemberItem:HasModifyGuildAccess() + if not XDataCenter.GuildManager.IsGuildAdminister() then + XUiManager.TipMsg(CS.XTextManager.GetText("GuildNotAdministor")) + return true + end + return false +end + +return XUiGridMemberItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridMemberVistorItem.lua b/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridMemberVistorItem.lua new file mode 100644 index 00000000..f991d631 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridMemberVistorItem.lua @@ -0,0 +1,45 @@ +local XUiGridMemberVistorItem = XClass(nil, "XUiGridMemberVistorItem") +function XUiGridMemberVistorItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiGridMemberVistorItem:Init(uiRoot) + self.UiRoot = uiRoot + self.HeadBtn.CallBack = function() self:OnHeadBtn()end +end + +function XUiGridMemberVistorItem:OnHeadBtn() + -- if not self.PlayId then + -- return + -- end + + -- 查看个人信息 + -- XDataCenter.PlayerInfoManager.RequestPlayerInfoData(self.PlayId, function(data) + -- XLuaUiManager.Open("UiPlayerInfo", data, chatContent) + -- if loadCompleteCB then + -- loadCompleteCB() + -- end + -- end) +end + +-- 更新数据 +function XUiGridMemberVistorItem:OnRefresh(itemdata) + if not itemdata then + return + end + + self.ItemData = itemdata + self.PlayId = itemdata.PlayId + XUiPLayerHead.InitPortrait(itemdata.HeadPortraitId, itemdata.HeadFrameId, self.Head) + self.TxtName.text = XDataCenter.SocialManager.GetPlayerRemark(itemdata.PlayId, itemdata.Name) + self.TextLv.text = itemdata.Level + self.TxtJob.text = XDataCenter.GuildManager.GetRankNameByLevel(itemdata.RankLevel) + self.TxtContribution.text = itemdata.ContributeAct + self.TxtHistoryContribution.text = itemdata.ContributeHistory + self.TxtLastLogin.text = XUiHelper.CalcLatelyLoginTime(itemdata.LastLoginTime) + self.TxtPopulation.text = itemdata.Popularity +end + +return XUiGridMemberVistorItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridNewsItem.lua b/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridNewsItem.lua new file mode 100644 index 00000000..38318509 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridNewsItem.lua @@ -0,0 +1,61 @@ +local XUiGridNewsItem = XClass(nil, "XUiGridNewsItem") +function XUiGridNewsItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiGridNewsItem:Init(uiRoot) + self.UiRoot = uiRoot + self:InitFun() +end + +--同意 +function XUiGridNewsItem:OnBtnAcceptClick() + if not self.ItemData then return end + XDataCenter.GuildManager.GuildAckRecruitRequest(self.ItemData.GuildId, true, self.ItemData.PlayerId, function() + self.UiRoot:OnRefresh() + end) +end + +--拒绝 +function XUiGridNewsItem:OnBtnRefuseClick() + if not self.ItemData then return end + XDataCenter.GuildManager.GuildAckRecruitRequest(self.ItemData.GuildId, false, self.ItemData.PlayerId, function() + self.UiRoot:OnRefresh() + end) +end + +--详情 +function XUiGridNewsItem:OnBtnSetClick() + if not self.ItemData then return end + local guildId = self.ItemData.GuildId + local guildInfo = XDataCenter.GuildManager.GetVistorGuildDetailsById(guildId) + if not guildInfo then + XDataCenter.GuildManager.GetVistorGuildDetailsReq(guildId, function() + XLuaUiManager.Open("UiGuildRankingList", guildId) + end) + else + XLuaUiManager.Open("UiGuildRankingList", guildId) + end +end + +function XUiGridNewsItem:InitFun() + self.BtnAccept.CallBack = function() self:OnBtnAcceptClick() end + self.BtnRefuse.CallBack = function() self:OnBtnRefuseClick() end + self.BtnSet.CallBack = function() self:OnBtnSetClick() end +end + +-- 更新数据 +function XUiGridNewsItem:OnRefresh(itemdata) + if not itemdata then + return + end + + self.ItemData = itemdata + self.TxtPlayerName.text = XDataCenter.SocialManager.GetPlayerRemark(itemdata.PlayerId, itemdata.PlayerName) + self.TxtEnter.text = itemdata.GuildName + XUiPLayerHead.InitPortrait(itemdata.HeadPortraitId, itemdata.HeadFrameId, self.Head) +end + +return XUiGridNewsItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridParticularsItem.lua b/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridParticularsItem.lua new file mode 100644 index 00000000..00891043 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridParticularsItem.lua @@ -0,0 +1,23 @@ +local XUiGridParticularsItem = XClass(nil, "XUiGridParticularsItem") + +function XUiGridParticularsItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiGridParticularsItem:Init(uiRoot) + self.UiRoot = uiRoot +end + +-- 更新数据 +function XUiGridParticularsItem:OnRefresh(itemdata) + if not itemdata then + return + end + + self.ItemData = itemdata + self:SetData() +end + +return XUiGridParticularsItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridRankItem.lua b/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridRankItem.lua new file mode 100644 index 00000000..b75f81ad --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridRankItem.lua @@ -0,0 +1,35 @@ +local XUiGridRankItem = XClass(nil, "XUiGridRankItem") + +function XUiGridRankItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) +end + +function XUiGridRankItem:Init(uiRoot) + self.UiRoot = uiRoot +end + +-- 更新数据 +function XUiGridRankItem:OnRefresh(itemdata) + if not itemdata then + return + end + self.TxtPosition.text = self.UiRoot:GetRankName(itemdata.RankLevel) + if itemdata.OnlineFlag == 1 then + self.TxtLastLanding.text = CS.XTextManager.GetText("GuildMemberOnline") + else + self.TxtLastLanding.text = XUiHelper.CalcLatelyLoginTimeWithDefault(itemdata.LastLoginTime, XGuildConfig.GuildDefaultDay) + end + + XUiPlayerLevel.UpdateLevel(itemdata.Level, self.TxtLevel, CS.XTextManager.GetText("GuildMemberLevel", itemdata.Level)) + + self.TxtPlayerName.text = itemdata.Name + self.TxtSevenDay.text = itemdata.ContributeIn7Days + + XUiPLayerHead.InitPortrait(itemdata.HeadPortraitId, itemdata.HeadFrameId, self.Head) + +end + +return XUiGridRankItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridRankingListSwitchItem.lua b/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridRankingListSwitchItem.lua new file mode 100644 index 00000000..dba9a4e8 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridRankingListSwitchItem.lua @@ -0,0 +1,35 @@ +local XUiGridRankingListSwitchItem = XClass(nil, "XUiGridRankingListSwitchItem") + +function XUiGridRankingListSwitchItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiGridRankingListSwitchItem:Init(uiRoot) + self.UiRoot = uiRoot +end + +-- 更新数据 +function XUiGridRankingListSwitchItem:OnRefresh(itemdata, index) + if not itemdata then + return + end + + self.TxtPlayerName.text = itemdata.GuildName + -- TxtLastLanding 是列表里的【成员数】 + self.TxtLastLanding.text = itemdata.MemberCount + self.TxtRankNum.text = index + self.TxtSevenDay.text = itemdata.Score + self.TxtTitleScore.text = XGuildConfig.GuildSortName[itemdata.Type] + + local path = XGuildConfig.GetGuildHeadPortraitIconById(itemdata.IconId) + self.ImgHead:SetRawImage(path) + self:SetSelect(itemdata.IsSelect) +end + +function XUiGridRankingListSwitchItem:SetSelect(status) + self.Btn:SetButtonState(status and CS.UiButtonState.Select or CS.UiButtonState.Normal) +end + +return XUiGridRankingListSwitchItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridRecommendationItem.lua b/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridRecommendationItem.lua new file mode 100644 index 00000000..5267ea76 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridRecommendationItem.lua @@ -0,0 +1,52 @@ +local XUiGridRecommendationItem = XClass(nil, "XUiGridRecommendationItem") + +function XUiGridRecommendationItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiGridRecommendationItem:Init(uiRoot) + self.UiRoot = uiRoot +end + +function XUiGridRecommendationItem:OnClickStatus() + self.CurStatus = not self.CurStatus + self:SetSeleStatus(self.CurStatus) +end + +function XUiGridRecommendationItem:SetSeleStatus(status) + self.ItemData.Status = status + self.SeleBgImg.gameObject:SetActiveEx(true) + if status then + self.UiRoot:RecordSeleId(self.ItemData.GuildId) + else + self.UiRoot:RemoveRecordSeleId(self.ItemData.GuildId) + end +end + +-- 更新数据 +function XUiGridRecommendationItem:OnRefresh(itemdata) + if not itemdata then + return + end + + self.ItemData = itemdata + self.ItemData.GuildId = itemdata.Id + self.TxtLv.text = itemdata.Level + self.TxtName.text = itemdata.Name + self.TextContributionNum.text = itemdata.ContributeIn7Days + self.TextMemberNum.text = itemdata.MemberCount + local config = XGuildConfig.GetGuildHeadPortraitById(itemdata.IconId) + if config then + local path = config.Icon + self.ImgIcon:SetRawImage(path) + end + self.CurStatus = self.ItemData.Status or false + self:SetSeleStatus(self.CurStatus) +end + +function XUiGridRecommendationItem:SetApplyTag(bool) + self.PanelApplyTag.gameObject:SetActiveEx(bool) +end +return XUiGridRecommendationItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridTalentItem.lua b/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridTalentItem.lua new file mode 100644 index 00000000..ea2ef144 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridTalentItem.lua @@ -0,0 +1,100 @@ +local XUiGridTalentItem = XClass(nil, "XUiGridTalentItem") +local blueColor = CS.UnityEngine.Color(30 / 255, 142 / 255, 232 / 255, 1) +local blackColor = CS.UnityEngine.Color(219 / 255, 224 / 255, 229 / 255, 1) + +function XUiGridTalentItem:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + + XTool.InitUiObject(self) + self.Select = self.Transform:Find("Select") + self.IsInit = false +end + +function XUiGridTalentItem:Refresh(talentConfig) + self.TalentData = talentConfig + self.TalentTemplate = XGuildConfig.GetGuildTalentById(self.TalentData.Id) + self.TalentConfig = XGuildConfig.GetGuildTalentConfigById(self.TalentData.Id) + local curTalentLevel = XDataCenter.GuildManager.GetTalentLevel(self.TalentData.Id) + + -- 初始化prefab组件, 初始化一次 + if not self.TalentPrefab and not self.IsInit then + self.IsInit = true + self.TalentPrefab = self.Transform:LoadPrefab(self.TalentConfig.PrefabPath) + local uiObj = self.TalentPrefab.transform:GetComponent("UiObject") + for i = 0, uiObj.NameList.Count - 1 do + self[uiObj.NameList[i]] = uiObj.ObjList[i] + end + self.BtnGuildSkillPoint.CallBack = function() self:OnBtnTalentPointClick() end + -- 获得所有线路 + self.AllLines = {} + for childId, childIndex in pairs(self.TalentData.ChildNodes or {}) do + local key = string.format("Line%d_%d", self.TalentData.IndexInMap, childIndex) + self.AllLines[key] = {} + local lineObj = self.Transform:Find(key) + local imgList = lineObj.gameObject:GetComponentsInChildren(typeof(CS.UnityEngine.UI.Image)) + for i = 0, imgList.Length - 1 do + table.insert(self.AllLines[key], imgList[i]) + end + end + end + + -- 是否解锁 + -- 解锁、非解锁 + local isUnlock = XDataCenter.GuildManager.IsTalentUnlock(self.TalentData.Id) + if isUnlock then + -- 最高级 + local pointStr = string.format("%d/%d", curTalentLevel, #self.TalentTemplate.CostPoint) + if XDataCenter.GuildManager.IsTalentMaxLevel(self.TalentData.Id) then + pointStr = "MAX" + end + self.TxtPointNumNormal.text = pointStr + self.TxtPointNumPress.text = pointStr + self.TxtPointNumDisable.text = pointStr + self.BtnGuildSkillPoint:SetDisable(false) + else + local pointStr = string.format("0/%d", #self.TalentTemplate.CostPoint) + self.TxtPointNumNormal.text = pointStr + self.TxtPointNumPress.text = pointStr + self.TxtPointNumDisable.text = pointStr + self.BtnGuildSkillPoint:SetDisable(true) + end + + self.RImgSkillIconNormal:SetRawImage(self.TalentConfig.TalentIcon) + self.RImgSkillIconPress:SetRawImage(self.TalentConfig.TalentIcon) + self.RImgSkillIconDisable:SetRawImage(self.TalentConfig.TalentIcon) + self:SetSelect(self.TalentData.IsSelect) + self:UpdateLines() +end + +function XUiGridTalentItem:SetSelect(isSelect) + self.Select.gameObject:SetActiveEx(isSelect) +end + +-- 路线 +function XUiGridTalentItem:UpdateLines() + if not self.TalentData then return end + local isUnlock = XDataCenter.GuildManager.IsTalentUnlock(self.TalentData.Id) + + local color = isUnlock and blueColor or blackColor + for key, lines in pairs(self.AllLines) do + for _, line in pairs(lines or {}) do + line.color = color + end + end + +end + +function XUiGridTalentItem:OnBtnTalentPointClick() + if not self.TalentData then return end + local isUnlock = XDataCenter.GuildManager.IsTalentUnlock(self.TalentData.Id) + + self.UiRoot:OnTalentPointSelect(self.TalentData.IndexInMap) + -- self.UiRoot:FocusTargetDelay(self.Transform) + XLuaUiManager.Open("UiGuildSkillDetail", self.TalentData.Id, function() + self.UiRoot:ResetTalentPointSelect() + end) +end + +return XUiGridTalentItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridTalentListItem.lua b/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridTalentListItem.lua new file mode 100644 index 00000000..99170cde --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridTalentListItem.lua @@ -0,0 +1,18 @@ +local XUiGridTalentListItem = XClass(nil, "XUiGridTalentListItem") + +function XUiGridTalentListItem:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + XTool.InitUiObject(self) +end + +function XUiGridTalentListItem:Refresh(talentConfig) + self.TalentData = talentConfig + self.TalentConfig = XGuildConfig.GetGuildTalentConfigById(talentConfig.Id) + self.TxtTalentName.text = self.TalentConfig.Name + self.TxtTalentDes.text = self.TalentConfig.Descriptions[#self.TalentConfig.Descriptions] + self.RImgTalent:SetRawImage(self.TalentConfig.TalentIcon) +end + +return XUiGridTalentListItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridWelfareItem.lua b/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridWelfareItem.lua new file mode 100644 index 00000000..d433d6bf --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGridWelfareItem.lua @@ -0,0 +1,48 @@ +local XUiGridWelfareItem = XClass(nil, "XUiGridWelfareItem") +local SkipTalentType = 1 +local SkipShopType = 2 + +function XUiGridWelfareItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + self.BtnWelfareItem.CallBack = function() self:OnBtnWelfareClick() end +end + +function XUiGridWelfareItem:Init(uiRoot) + self.UiRoot = uiRoot +end + +function XUiGridWelfareItem:SetItemData() +end + +function XUiGridWelfareItem:Refresh(welfareConfig) + self.WelfareConfig = welfareConfig + self.RImgWelfareNormal:SetRawImage(self.WelfareConfig.WelfareBg) + self.RImgWelfarePress:SetRawImage(self.WelfareConfig.WelfareBg) +end + +function XUiGridWelfareItem:OnBtnWelfareClick() + if not self.WelfareConfig then return end + + if self.WelfareConfig.Condition > 0 then + local isOpen, desc = XConditionManager.CheckCondition(self.WelfareConfig.Condition) + if not isOpen then + XUiManager.TipMsg(desc) + return + end + end + + if not XDataCenter.GuildManager.IsJoinGuild() then return end + if self.WelfareConfig.SkipId == SkipShopType then + if XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.ShopCommon) then + -- 4001 是绩点商店的id + XLuaUiManager.Open("UiShop", XShopManager.ShopType.Guild, nil, 4001) + end + elseif self.WelfareConfig.SkipId == SkipTalentType then + XDataCenter.GuildManager.EnterGuildTalent() + end + +end +return XUiGridWelfareItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGuildDonationItem.lua b/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGuildDonationItem.lua new file mode 100644 index 00000000..4bf4c199 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGuildDonationItem.lua @@ -0,0 +1,71 @@ +local XUiGuildDonationItem = XClass(nil, "XUiGuildDonationItem") + +function XUiGuildDonationItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + local str = CS.XTextManager.GetText("GuildDonationBtnDes") + self.BtnSkip:SetNameByGroup(0,str) +end + +function XUiGuildDonationItem:InitFun() + self.BtnSkip.CallBack = function() self:OnBtnDonateRequest() end +end + +function XUiGuildDonationItem:Init(uiRoot) + self.UiRoot = uiRoot + self.GridItemUI = XUiGridCommon.New(uiRoot,self.GridItem) + self:InitFun() +end + +-- 更新数据 +function XUiGuildDonationItem:OnRefresh(itemdata) + if not itemdata or not next(itemdata)then + return + end + + self.ItemData = itemdata + self.GridItemUI:Refresh(itemdata.ItemId) + self.TxtName.text = itemdata.Name + self.TxtNum.text = CS.XTextManager.GetText("GuildDonationHaveDes",XDataCenter.ItemManager.GetCount(itemdata.ItemId)) + self.TxtProNum.text = CS.XTextManager.GetText("GuildDonationProDes", itemdata.GotCount,itemdata.MaxCount) + self.TxtDelegationName.text = CS.XTextManager.GetText("GuildDonationDeleDes", itemdata.Name) + self.TxtPostName.text = CS.XTextManager.GetText("GuildDonationPosDes", XDataCenter.GuildManager.GetRankNameByLevel(itemdata.RankLevel)) + if itemdata.GotCount < itemdata.MaxCount then + self.ImgBlack.gameObject:SetActiveEx(false) + self.BtnSkip:SetButtonState(XUiButtonState.Normal) + else + self.BtnSkip:SetButtonState(XUiButtonState.Disable) + self.ImgBlack.gameObject:SetActiveEx(true) + end + self.ImgProgress.fillAmount = math.floor(itemdata.GotCount/ itemdata.MaxCount) + -- local info = XPlayerManager.GetHeadPortraitInfoById(rankInfo.HeadPortraitId) + -- if info ~= nil then + -- self.RImgPlayerHead:SetRawImage(info.ImgSrc) + -- end +end + +--捐赠 +function XUiGuildDonationItem:OnBtnDonateRequest() + local itemId = self.ItemData.ItemId + if XDataCenter.ItemManager.GetCount(itemId) == 0 then + XUiManager.TipText("GuildDonationNotEnoughCount",XUiManager.UiTipType.Wrong) + return + end + + local seq = self.ItemData.Seq + local playerId = self.ItemData.Id + XDataCenter.GuildManager.DonateRequest(playerId,seq,itemId,function() + local tem = self.ItemData.GotCount + 1 + self.TxtNum.text = CS.XTextManager.GetText("GuildDonationHaveDes",XDataCenter.ItemManager.GetCount(itemId) - 1) + self.TxtProNum.text = CS.XTextManager.GetText("GuildDonationProDes", tem,self.ItemData.MaxCount) + self.ImgProgress.fillAmount = math.floor(tem / self.ItemData.MaxCount) + if tem == self.ItemData.MaxCount then + self.BtnSkip:SetButtonState(XUiButtonState.Disable) + self.ImgBlack.gameObject:SetActiveEx(true) + end + XUiManager.TipText("GuildDonationSuccess") + end) +end + +return XUiGuildDonationItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGuildGridShop.lua b/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGuildGridShop.lua new file mode 100644 index 00000000..88dbd338 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGuildGridShop.lua @@ -0,0 +1,381 @@ +local XUiGuildGridShop = XClass(nil, "XUiGuildGridShop") +function XUiGuildGridShop:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:InitAutoScript() + self.PanelPrice = { + self.PanelPrice1, + self.PanelPrice2, + self.PanelPrice3 + } + self.Timer = nil +end + +function XUiGuildGridShop:Init(parent, rootUi) + self.Parent = parent + self.RootUi = rootUi or parent + self.Grid = XUiGridCommon.New(self.RootUi, self.GridCommon) +end + +function XUiGuildGridShop:OnRecycle() + self:RemoveTimer() + self:RemoveOnSaleTimer() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiGuildGridShop:InitAutoScript() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiGuildGridShop:GetAutoKey(uiNode, eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiGuildGridShop:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiGuildGridShop:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiGuildGridShop:AutoAddListener() + self.AutoCreateListeners = {} + XUiHelper.RegisterClickEvent(self, self.BtnCondition, self.OnBtnConditionClick) + XUiHelper.RegisterClickEvent(self, self.BtnBuy, self.OnBtnBuyClick) +end +-- auto +function XUiGuildGridShop:OnBtnConditionClick() + if self.ConditionDesc then + XUiManager.TipError(self.ConditionDesc) + end +end + +function XUiGuildGridShop:OnBtnBuyClick() + if not self.IsShopLock and not self.IsShopOnSaleLock then + self.Parent:UpdateBuy(self.Data, function() + self:RefreshSellOut() + self:RefreshCondition() + self:RefreshOnSales() + self:RefreshPrice() + self:RefreshBuyCount() + end) + else + if self.ShopLockDecs and self.IsShopLock then + XUiManager.TipError(self.ShopLockDecs) + return + end + if self.ShopOnSaleLockDecs and self.IsShopOnSaleLock then + XUiManager.TipError(self.ShopOnSaleLockDecs) + return + end + end +end + +function XUiGuildGridShop:UpdateData(data,shopItemTextColor) + self.Data = data + self.ShopItemTextColor = shopItemTextColor + self:RefreshSellOut() + self:RefreshCondition() + self:RefreshCommon() + self:RefreshOnSales() + self:RefreshPrice() + self:RemoveTimer() + self:RemoveOnSaleTimer() + self:RefreshBuyCount() + self:RefreshTimer(self.Data.SelloutTime) + self:RefreshOnSaleTime(self.Data.OnSaleTime) +end + +function XUiGuildGridShop:RefreshBuyCount() + if not self.ImgLimitLable then + return + end + + if not self.TxtLimitLable then + return + end + + if self.Data.BuyTimesLimit <= 0 then + self.TxtLimitLable.gameObject:SetActiveEx(false) + self.ImgLimitLable.gameObject:SetActiveEx(false) + else + local buynumber = self.Data.BuyTimesLimit - self.Data.TotalBuyTimes + local limitLabel = XShopConfigs.GetBuyLimitLabel(self.Data.AutoResetClockId) + local text = string.format(limitLabel, buynumber) + + self.TxtLimitLable.text = text + self.TxtLimitLable.gameObject:SetActiveEx(true) + self.ImgLimitLable.gameObject:SetActiveEx(true) + end +end + +function XUiGuildGridShop:RefreshCondition() + if not self.BtnCondition then return end + self.BtnCondition.gameObject:SetActiveEx(false) + self.ConditionDesc = nil + local conditionIds = self.Data.ConditionIds + if not conditionIds or #conditionIds <= 0 then return end + + for _, id in pairs(conditionIds) do + local ret, desc = XConditionManager.CheckCondition(id) + if not ret then + self.BtnCondition.gameObject:SetActiveEx(true) + self.ImgSellOut.gameObject:SetActiveEx(false) + self.ConditionDesc = desc + return + end + end +end + +function XUiGuildGridShop:RefreshSellOut() + if not self.ImgSellOut then + return + end + + if self.Data.BuyTimesLimit <= 0 then + self.ImgSellOut.gameObject:SetActiveEx(false) + else + if self.Data.TotalBuyTimes >= self.Data.BuyTimesLimit then + self.ImgSellOut.gameObject:SetActiveEx(true) + else + self.ImgSellOut.gameObject:SetActiveEx(false) + end + end +end + + +function XUiGuildGridShop:RemoveTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end + +function XUiGuildGridShop:RemoveOnSaleTimer() + if self.OnSaleTimer then + XScheduleManager.UnSchedule(self.OnSaleTimer) + self.OnSaleTimer = nil + end +end + +function XUiGuildGridShop:RefreshCommon() + if self.RImgType then + self.RImgType.gameObject:SetActiveEx(false) + end + + -- local rewardGoods = self.Data.RewardGoods + self.Grid:Refresh(self.Data.RewardGoods, nil, true) +end + +function XUiGuildGridShop:RefreshPrice() + local panelCount = #self.PanelPrice + for i = 1, panelCount do + self.PanelPrice[i].gameObject:SetActiveEx(false) + end + + local index = 1 + for _, count in pairs(self.Data.ConsumeList) do + if index > panelCount then + return + end + + if self["TxtOldPrice" .. index] then + if self.Sales == 100 then + self["TxtOldPrice" .. index].gameObject:SetActiveEx(false) + else + self["TxtOldPrice" .. index].text = count.Count + self["TxtOldPrice" .. index].gameObject:SetActiveEx(true) + end + end + + if self["RImgPrice" .. index] and self["RImgPrice" .. index]:Exist() then + local icon = XDataCenter.ItemManager.GetItemIcon(count.Id) + if icon ~= nil then + self["RImgPrice" .. index]:SetRawImage(icon) + end + end + + if self["TxtNewPrice" .. index] then + local needCount = math.floor(count.Count * self.Sales / 100) + self["TxtNewPrice" .. index].text = needCount + local itemCount = XDataCenter.ItemManager.GetCount(count.Id) + if itemCount < needCount then + if not self.ShopItemTextColor then + self["TxtNewPrice" .. index].color = CS.UnityEngine.Color(1, 0, 0) + else + self["TxtNewPrice" .. index].color = XUiHelper.Hexcolor2Color(self.ShopItemTextColor.CanNotBuyColor) + end + else + if not self.ShopItemTextColor then + self["TxtNewPrice" .. index].color = CS.UnityEngine.Color(0, 0, 0) + else + self["TxtNewPrice" .. index].color = XUiHelper.Hexcolor2Color(self.ShopItemTextColor.CanBuyColor) + end + end + end + + self.PanelPrice[index].gameObject:SetActiveEx(true) + index = index + 1 + end +end + +function XUiGuildGridShop:RefreshOnSales() + self.OnSales = {} + self.OnSalesLongTest = {} + XTool.LoopMap(self.Data.OnSales, function(k, sales) + self.OnSales[k] = sales + table.insert(self.OnSalesLongTest, sales) + end) + + self.Sales = 100 + + if #self.OnSalesLongTest ~= 0 then + local sortedKeys = {} + for k, _ in pairs(self.OnSales) do + table.insert(sortedKeys, k) + end + table.sort(sortedKeys) + + for i = 1, #sortedKeys do + if self.Data.TotalBuyTimes >= sortedKeys[i] - 1 then + self.Sales = self.OnSales[sortedKeys[i]] + end + end + end + self:RefreshPanelSale() +end + +function XUiGuildGridShop:RefreshPanelSale() + local hideSales = false + if self.TxtSaleRate then + if self.Data.Tags == XShopManager.ShopTags.DisCount then + if self.Sales < 100 then + self.TxtSaleRate.text = self.Sales / 10 .. CS.XTextManager.GetText("Snap") + else + hideSales = true + end + end + if self.Data.Tags == XShopManager.ShopTags.TimeLimit then + self.TxtSaleRate.text = CS.XTextManager.GetText("TimeLimit") + end + if self.Data.Tags == XShopManager.ShopTags.Recommend then + self.TxtSaleRate.text = CS.XTextManager.GetText("Recommend") + end + if self.Data.Tags == XShopManager.ShopTags.HotSale then + self.TxtSaleRate.text = CS.XTextManager.GetText("HotSell") + end + if self.Data.Tags == XShopManager.ShopTags.Not or hideSales then + self.TxtSaleRate.gameObject:SetActiveEx(false) + self.TxtSaleRate.gameObject.transform.parent.gameObject:SetActiveEx(false) + else + self.TxtSaleRate.gameObject:SetActiveEx(true) + self.TxtSaleRate.gameObject.transform.parent.gameObject:SetActiveEx(true) + + end + end +end + +function XUiGuildGridShop:RefreshTimer(time) + if not self.ImgLeftTime then + return + end + + if not self.TxtLeftTime then + return + end + + if time <= 0 then + self.TxtLeftTime.gameObject:SetActiveEx(false) + self.ImgLeftTime.gameObject:SetActiveEx(false) + return + end + + self.TxtLeftTime.gameObject:SetActiveEx(true) + self.ImgLeftTime.gameObject:SetActiveEx(true) + + local leftTime = XShopManager.GetLeftTime(time) + + local func = function() + leftTime = leftTime > 0 and leftTime or 0 + local dataTime = XUiHelper.GetTime(leftTime, XUiHelper.TimeFormatType.SHOP) + if self.TxtLeftTime then + self.TxtLeftTime.text = CS.XTextManager.GetText("TimeSoldOut", dataTime) + end + if leftTime <= 0 then + self:RemoveTimer() + if self.ImgSellOut then + self.ImgSellOut.gameObject:SetActiveEx(true) + end + end + end + + func() + + self.Timer = XScheduleManager.ScheduleForever(function() + leftTime = leftTime - 1 + func() + end, 1000) +end + + +function XUiGuildGridShop:RefreshOnSaleTime(time) + if not self.TxtOnSaleTime then + return + end + + if time <= 0 then + self.TxtOnSaleTime.gameObject:SetActiveEx(false) + return + end + + self.TxtOnSaleTime.gameObject:SetActiveEx(true) + self.ShopOnSaleLockDecs = CS.XTextManager.GetText("ActivityBriefShopOnSaleLock") + + local SaleTime = XShopManager.GetLeftTime(time) + + local func = function() + SaleTime = SaleTime > 0 and SaleTime or 0 + local dataTime = XUiHelper.GetTime(SaleTime, XUiHelper.TimeFormatType.ACTIVITY) + if self.TxtOnSaleTime then + self.TxtOnSaleTime.text = CS.XTextManager.GetText("TimeOnSale", dataTime) + end + if SaleTime <= 0 then + self:RemoveOnSaleTimer() + if self.TxtOnSaleTime then + self.TxtOnSaleTime.gameObject:SetActiveEx(false) + end + self.IsShopOnSaleLock = false + else + self.IsShopOnSaleLock = true + end + end + + func() + + self.OnSaleTimer = XScheduleManager.ScheduleForever(function() + SaleTime = SaleTime - 1 + func() + end, 1000) +end + +return XUiGuildGridShop \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGuildHeadPortraitItem.lua b/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGuildHeadPortraitItem.lua new file mode 100644 index 00000000..fd85279b --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGuildHeadPortraitItem.lua @@ -0,0 +1,33 @@ +local XUiGuildHeadPortraitItem = XClass(nil, "XUiGuildHeadPortraitItem") + +function XUiGuildHeadPortraitItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiGuildHeadPortraitItem:Init(parent) + self.Parent = parent +end + +function XUiGuildHeadPortraitItem:SetStatus(status) + self.ImgRoleSelect.gameObject:SetActiveEx(status) +end + +function XUiGuildHeadPortraitItem:OnRefresh(itemdata) + if not itemdata then + return + end + + self.GuildId = itemdata.Id + self.GuildDescribe = itemdata.Describe + self.GuildIcon = itemdata.Icon + self.UnLockImgHeadImg:SetRawImage(self.GuildIcon) + local flag = self.Parent:IsSeleId(self.GuildId) + self:SetStatus(flag) + if flag then + self.Parent:RecordFirstSeleItem(self) + end +end + +return XUiGuildHeadPortraitItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGuildWelcomeWordItem.lua b/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGuildWelcomeWordItem.lua new file mode 100644 index 00000000..ee1d1312 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiChildItem/XUiGuildWelcomeWordItem.lua @@ -0,0 +1,37 @@ +local XUiGuildWelcomeWordItem = XClass(nil, "XUiGuildWelcomeWordItem") +local Select = CS.UiButtonState.Select +local Normal = CS.UiButtonState.Normal + +function XUiGuildWelcomeWordItem:Ctor(ui, parent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:Init(parent) +end + +function XUiGuildWelcomeWordItem:Init(parent) + self.Parent = parent +end + +-- 更新数据 +function XUiGuildWelcomeWordItem:OnRefresh(data) + self.InputField.text = data.WelcomeWord or "" + self.BtnSelect:SetButtonState(data.Select and Select or Normal) +end + +-- 话术 +function XUiGuildWelcomeWordItem:GetInitPutText() + local text = self.InputField.text + return text +end + +-- 勾选状态 +function XUiGuildWelcomeWordItem:GetSelect() + return self.BtnSelect:GetToggleState() +end + +function XUiGuildWelcomeWordItem:SetSelect(bool) + return self.BtnSelect:SetButtonState(bool and Select or Normal) +end + +return XUiGuildWelcomeWordItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildAdministration.lua b/Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildAdministration.lua new file mode 100644 index 00000000..bf3d9776 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildAdministration.lua @@ -0,0 +1,345 @@ +local XUiGuildAdministration = XClass(nil, "XUiGuildAdministration") +local XUiGuildViewSetHeadPortrait = require("XUi/XUiGuild/XUiChildView/XUiGuildViewSetHeadPortrait") + +function XUiGuildAdministration:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + + XTool.InitUiObject(self) + self.BtnRecruit.CallBack = function() self:OnBtnRecruitClick() end + self:InitChildView() +end + +function XUiGuildAdministration:UpdateGuildLevel() + self.GuildLevel = XDataCenter.GuildManager.GetGuildLevel() + self.GuildLevelTemplate = XGuildConfig.GetGuildLevelDataBylevel(self.GuildLevel) + + self:UpdateMainInfo() +end + +function XUiGuildAdministration:UpdateMainInfo() + -- 贡献度 + local build = XDataCenter.GuildManager.GetBuild() + if self.TxtGuildLv then + self.TxtGuildLv.text = self.GuildLevel + end + + -- 刷新倒计时 + self.TextRefresh.text = CS.XTextManager.GetText("GuildMainRefreshCountDown", self:GetNextMonthRefreshTime()) + -- 贡献度/升级所需 + if not self.GuildLevelTemplate then + -- local guildLevel = self.GuildLevel - 1 + -- local guildLevelTemplate = XGuildConfig.GetGuildLevelDataBylevel(self.GuildLevel) + self.TextNum.text = "-/-" + self.ImgProgress.fillAmount = 1 + self.BtnLevelUp:SetDisable(true, false) + else + if XDataCenter.GuildManager.IsGuildLevelMax(self.GuildLevel) then + self.TextNum.text = "-/-" + else + self.TextNum.text = string.format("%d/%d", build, self.GuildLevelTemplate.Build) + end + self.ImgProgress.fillAmount = build / self.GuildLevelTemplate.Build + if build >= self.GuildLevelTemplate.Build and (not XDataCenter.GuildManager.IsGuildLevelMax(self.GuildLevel)) then + self.BtnLevelUp:SetDisable(false, true) + else + self.BtnLevelUp:SetDisable(true, false) + end + end + -- 正常、紧急 + self.PanelNor.gameObject:SetActiveEx(true) + self.ImgGuildIconNor:SetRawImage(XDataCenter.GuildManager.GetGuildIconId()) + self.TxtGuildNameNor.text = XDataCenter.GuildManager.GetGuildName() + -- 日常维护 + self.TxtDailyCountNor.text = self.GuildLevelTemplate and self.GuildLevelTemplate.Contribution or 0 + self.ImgDailyIconNor:SetRawImage(XDataCenter.ItemManager.GetItemIcon(XGuildConfig.GuildContributeCoin)) + -- 紧急维护 + self.TxtUrgentCountNor.text = self.GuildLevelTemplate and self.GuildLevelTemplate.EmergencyMaintenance or 0 + self.ImgUrgentCountNor:SetRawImage(XDataCenter.ItemManager.GetItemIcon(XGuildConfig.GuildContributeCoin)) + self.TextGuildLvNor.text = XDataCenter.GuildManager.GetGuildLevel() + + + self.PanelUrgent.gameObject:SetActiveEx(false) + self.ImgGuildIconUrgent:SetRawImage(XDataCenter.GuildManager.GetGuildIconId()) + self.TxtGuildNameUrgent.text = XDataCenter.GuildManager.GetGuildName() + -- 日常维护 + self.TxtDailyCountUrgent.text = self.GuildLevelTemplate and self.GuildLevelTemplate.Contribution or 0 + self.ImgDailyIconUrgent:SetRawImage(XDataCenter.ItemManager.GetItemIcon(XGuildConfig.GuildContributeCoin)) + -- 紧急维护 + self.TxtUrgentCountUrgent.text = self.GuildLevelTemplate and self.GuildLevelTemplate.EmergencyMaintenance or 0 + self.ImgUrgentCountUrgent:SetRawImage(XDataCenter.ItemManager.GetItemIcon(XGuildConfig.GuildContributeCoin)) + self.TextGuildLvUrgent.text = XDataCenter.GuildManager.GetGuildLevel() + + self.PanelUrgent.gameObject:SetActiveEx(XDataCenter.GuildManager.IsUrgentMaintainState()) + self.BtnAddUrgentCoin.gameObject:SetActiveEx(XDataCenter.GuildManager.IsUrgentMaintainState()) +end + +function XUiGuildAdministration:OnEnable() + self.GameObject:SetActiveEx(true) + self.GuildLevel = XDataCenter.GuildManager.GetGuildLevel() + self.GuildLevelTemplate = XGuildConfig.GetGuildLevelDataBylevel(self.GuildLevel) + + self:UpdateMainInfo() + + -- 管理层才能做得操作 + self.BtnLevelUp.gameObject:SetActiveEx(XDataCenter.GuildManager.IsGuildAdminister()) + self.BtnOut.gameObject:SetActiveEx(not XDataCenter.GuildManager.IsGuildLeader()) + self.BtnRecruit.gameObject:SetActiveEx(XDataCenter.GuildManager.IsGuildAdminister()) + self.BtnCustom.gameObject:SetActiveEx(XDataCenter.GuildManager.IsGuildAdminister()) + + self.IconCoinNor1:SetRawImage(XDataCenter.ItemManager.GetItemIcon(XGuildConfig.GuildCoin)) + self.IconCoinNor2:SetRawImage(XDataCenter.ItemManager.GetItemIcon(XGuildConfig.GuildContributeCoin)) + self.TxtCoinNor1.text = XDataCenter.ItemManager.GetCount(XGuildConfig.GuildCoin) + self.TxtCoinNor2.text = XDataCenter.GuildManager.GetGuildContributeLeft() + + self.IconCoinUrgent1:SetRawImage(XDataCenter.ItemManager.GetItemIcon(XGuildConfig.GuildCoin)) + self.IconCoinUrgent2:SetRawImage(XDataCenter.ItemManager.GetItemIcon(XGuildConfig.GuildContributeCoin)) + self.TxtCoinUrgent1.text = XDataCenter.ItemManager.GetCount(XGuildConfig.GuildCoin) + self.TxtCoinUrgent2.text = XDataCenter.GuildManager.GetGuildContributeLeft() + + self:StartBuildRefreshCounter() + self:StartUrgentRefreshCounter() +end + +-- 获取下次刷新时间 +function XUiGuildAdministration:GetNextMonthRefreshTime() + local now = XTime.GetServerNowTimestamp() + local dateTime = CS.XDateUtil.GetGameDateTime(now) + local monthZero = CS.XDateUtil.GetFirstDayOfThisMonth(dateTime):ToTimestamp() + local firstDayOfMonthOfFive = monthZero + 5 * 60 * 60 + + if now <= firstDayOfMonthOfFive then + return XUiHelper.GetTime(firstDayOfMonthOfFive - now, XUiHelper.TimeFormatType.ACTIVITY) + end + + local nextMonth = dateTime:AddMonths(1) + local nextmonthZero = CS.XDateUtil.GetFirstDayOfThisMonth(nextMonth):ToTimestamp() + local firstDayOfNextMonthOfFive = nextmonthZero + 5 * 60 * 60 + + if now <= firstDayOfNextMonthOfFive then + return XUiHelper.GetTime(firstDayOfNextMonthOfFive - now, XUiHelper.TimeFormatType.ACTIVITY) + end + + return "" +end + +function XUiGuildAdministration:OnDisable() + self:StopBuildRefreshCounter() + self:StopUrgentRefreshCounter() + self.GameObject:SetActiveEx(false) +end + +function XUiGuildAdministration:OnViewDestroy() + self:StopBuildRefreshCounter() + self:StopUrgentRefreshCounter() +end + +function XUiGuildAdministration:InitChildView() + self.BtnOut.CallBack = function() self:OnBtnOutClick() end + self.BtnRecruit.CallBack = function() self:OnBtnRecruitClick() end + self.BtnCustom.CallBack = function() self:OnBtnCustomClick() end + self.BtnLevelUp.CallBack = function() self:OnBtnLevelUpClick() end + + self.BtnAddUrgentCoin.CallBack = function() self:OnBtnAddUrgentCoinClick() end + self.BtnAddNor.CallBack = function() self:OnBtnAddNorClick() end + self.BtnAddUrgent.CallBack = function() self:OnBtnAddUrgentClick() end + self.BtnHeadIconClick.CallBack = function() self:OnBtnHeadIconClick() end + + XDataCenter.ItemManager.AddCountUpdateListener(XGuildConfig.GuildCoin, function() + self.TxtCoinNor1.text = XDataCenter.ItemManager.GetCount(XGuildConfig.GuildCoin) + self.TxtCoinUrgent1.text = XDataCenter.ItemManager.GetCount(XGuildConfig.GuildCoin) + end, self.TxtCoinNor1) + + self.GuildViewSetHeadPortrait = XUiGuildViewSetHeadPortrait.New(self.PanelSetHeadPotrait,self) + XRedPointManager.AddRedPointEvent(self.RedRecruit, self.RefreshApplyList, self, { XRedPointConditions.Types.CONDITION_GUILD_APPLYLIST }) +end + +function XUiGuildAdministration:RefreshApplyList(count) + self.RedRecruit.gameObject:SetActiveEx(count >= 0) +end + +function XUiGuildAdministration:RefreshGuildContribute() + self.TxtCoinNor2.text = XDataCenter.GuildManager.GetGuildContributeLeft() + self.TxtCoinUrgent2.text = XDataCenter.GuildManager.GetGuildContributeLeft() +end + +function XUiGuildAdministration:StartUrgentRefreshCounter() + self:StopUrgentRefreshCounter() + local guildLevel = XDataCenter.GuildManager.GetGuildLevel() + local guildLevelTemplate = XGuildConfig.GetGuildLevelDataBylevel(guildLevel) + if not guildLevelTemplate then return end + local beginTime = XDataCenter.GuildManager.GetEmergenceTime() + local endTime = guildLevelTemplate.EmergencyDay * 23 * 60 * 60 + beginTime + local now = XTime.GetServerNowTimestamp() + self.TxtUrgentRefreshTime.text = XUiHelper.GetTime(endTime - now, XUiHelper.TimeFormatType.ACTIVITY) + self.UrgentRefreshTimer = XScheduleManager.ScheduleForever(function() + now = XTime.GetServerNowTimestamp() + if now > endTime then + self:StopUrgentRefreshCounter() + return + end + self.TxtUrgentRefreshTime.text = XUiHelper.GetTime(endTime - now, XUiHelper.TimeFormatType.ACTIVITY) + end, XScheduleManager.SECOND, 0) +end + +function XUiGuildAdministration:StopUrgentRefreshCounter() + if self.UrgentRefreshTimer then + XScheduleManager.UnSchedule(self.UrgentRefreshTimer) + self.UrgentRefreshTimer = nil + end +end + +function XUiGuildAdministration:StartBuildRefreshCounter() + self:StopBuildRefreshCounter() + self.BuildRefreshTimer = XScheduleManager.ScheduleForever(function() + self.TextRefresh.text = CS.XTextManager.GetText("GuildMainRefreshCountDown", self:GetNextMonthRefreshTime()) + end, XScheduleManager.SECOND, 0) +end + +function XUiGuildAdministration:StopBuildRefreshCounter() + if self.BuildRefreshTimer then + XScheduleManager.UnSchedule(self.BuildRefreshTimer) + self.BuildRefreshTimer = nil + end +end + +-- 招募 +function XUiGuildAdministration:OnBtnRecruitClick() + if self:ChecKickOut() then return end + if self:HasModifyAccess() then return end + + local currentPageNo = XDataCenter.GuildManager.GetRecommendPageNo() + XDataCenter.GuildManager.GuildRecruitRecommendRequest(currentPageNo, function() + XLuaUiManager.Open("UiGuildRecruit") + end) +end + +-- 退出 +function XUiGuildAdministration:OnBtnOutClick() + if self:ChecKickOut() then return end + local title = CS.XTextManager.GetText("GuildDialogTitle") + local content = CS.XTextManager.GetText("GuildQuitContent") + + XUiManager.DialogTip(title, content, XUiManager.DialogType.Normal, function() + end, function() + XDataCenter.GuildManager.QuitGuild(function() + if XLuaUiManager.IsUiShow("UiGuildMain") then + XLuaUiManager.Close("UiGuildMain") + end + end) + end) +end + +-- 升级 +function XUiGuildAdministration:OnBtnLevelUpClick() + if self:ChecKickOut() then return end + if self:HasModifyAccess() then return end + local guildLevel = XDataCenter.GuildManager.GetGuildLevel() + local guildTemplate = XGuildConfig.GetGuildLevelDataBylevel(guildLevel) + if not guildTemplate then return end + local build = XDataCenter.GuildManager.GetBuild() + if build < guildTemplate.Build then + XUiManager.TipMsg(CS.XTextManager.GetText("GuildBuildNotEnough")) + return + end + + if not XDataCenter.GuildManager.IsGuildAdminister() then + XUiManager.TipMsg(CS.XTextManager.GetText("GuildNotAccessLevelUp")) + return + end + + -- 已经到达最高级 + if XDataCenter.GuildManager.IsGuildLevelMax(guildLevel) then + XUiManager.TipMsg(CS.XTextManager.GetText("GuildLevelIsMax")) + return + end + + local nextGuildLevel = guildLevel + 1 + local nextGuildTemplate = XGuildConfig.GetGuildLevelDataBylevel(nextGuildLevel) + if not nextGuildTemplate then return end + + local title = CS.XTextManager.GetText("GuildDialogTitle") + local content = CS.XTextManager.GetText("GuildLevelUpContent", nextGuildLevel, nextGuildTemplate.Contribution) + local sureCallBack = function() + XDataCenter.GuildManager.GuildLevelUp(function() + self:OnEnable() + end) + end + + XUiManager.DialogTip(title, content, XUiManager.DialogType.Normal, function() + end, sureCallBack) +end + +-- 自定义职位 +function XUiGuildAdministration:OnBtnCustomClick() + if self:ChecKickOut() then return end + if self:HasModifyAccess() then return end + XLuaUiManager.Open("UiGuildCustomName") +end + +-- 紧急维护 +function XUiGuildAdministration:OnBtnAddUrgentCoinClick() + -- 判断是否足够维护 + if self:ChecKickOut() then return end + if self:HasModifyAccess() then return end + + local title = CS.XTextManager.GetText("GuildDialogTitle") + local content = CS.XTextManager.GetText("GuildUrgentMaintain") + + XUiManager.DialogTip(title, content, XUiManager.DialogType.Normal, function() + end, function() + XDataCenter.GuildManager.GuildPayMaintain(function() + self:OnEnable() + end) + end) + +end + +-- 增加贡献 +function XUiGuildAdministration:OnBtnAddNorClick() + if self:ChecKickOut() then return end + XLuaUiManager.Open("UiBuyAsset", XGuildConfig.GuildContributeCoin, function() + end) +end + +-- 增加贡献 +function XUiGuildAdministration:OnBtnAddUrgentClick() + if self:ChecKickOut() then return end + XLuaUiManager.Open("UiBuyAsset", XGuildConfig.GuildContributeCoin, function() + end) +end + +function XUiGuildAdministration:OnBtnHeadIconClick() + self.PanelSetHeadPotrait.gameObject:SetActiveEx(true) + self.GuildViewSetHeadPortrait:OnRefresh() +end + +function XUiGuildAdministration:HasModifyAccess() + if not XDataCenter.GuildManager.IsGuildAdminister() then + XUiManager.TipMsg(CS.XTextManager.GetText("GuildNotAdministor")) + return true + end + return false +end + +function XUiGuildAdministration:ChecKickOut() + if not XDataCenter.GuildManager.IsJoinGuild() then + XUiManager.TipMsg(CS.XTextManager.GetText("GuildKickOutByAdministor")) + self.UiRoot:Close() + return true + end + return false +end + +function XUiGuildAdministration:RecordGuildIconId(iconId) + if self.CurGuildIconId ~= self.PreGuildIconId then + local cfg = XGuildConfig.GetGuildHeadPortraitById(iconId) + if cfg then + self.ImgGuildIconNor:SetRawImage(cfg.Icon) + self.PreGuildIconId = self.CurGuildIconId + end + end +end + +return XUiGuildAdministration \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildEnlistNews.lua b/Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildEnlistNews.lua new file mode 100644 index 00000000..a9b85b89 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildEnlistNews.lua @@ -0,0 +1,79 @@ +local XUiGuildEnlistNews = XClass(nil, "XUiGuildEnlistNews") +local XUiGridGuildEnlistItem = require("XUi/XUiGuild/XUiChildItem/XUiGridGuildEnlistItem") + +function XUiGuildEnlistNews:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + + XTool.InitUiObject(self) + self:InitChildView() +end + +function XUiGuildEnlistNews:InitChildView() + self.DynamicTable = XDynamicTableNormal.New(self.PanelTreasureGrade.gameObject) + self.DynamicTable:SetProxy(XUiGridGuildEnlistItem) + self.DynamicTable:SetDelegate(self) + self.BtnSet.CallBack = function() self:OnBtnSetClick() end +end + +function XUiGuildEnlistNews:UpdateEnlists() + if not XDataCenter.GuildManager.IsGuildAdminister() then + return + end + XDataCenter.GuildManager.GetGuildListApply(function() + local applyList = XDataCenter.GuildManager.GetGuildApplyList() + self.ApplyList = {} + for _, v in pairs(applyList) do + table.insert(self.ApplyList, v) + end + table.sort(self.ApplyList, function(applyA, applyB) + if applyA.OnlineFlag == applyB.OnlineFlag then + return applyA.LastLoginTime > applyB.LastLoginTime + end + return applyA.OnlineFlag > applyB.OnlineFlag + end) + if self.ImgEmpty then + self.ImgEmpty.gameObject:SetActiveEx(#self.ApplyList <= 0) + end + self.DynamicTable:Clear() + self.DynamicTable:SetDataSource(self.ApplyList) + self.DynamicTable:ReloadDataASync() + end) +end + +function XUiGuildEnlistNews:RefreshEnlists() + self.ApplyList = {} + local applyList = XDataCenter.GuildManager.GetGuildApplyList() + for _, v in pairs(applyList) do + table.insert(self.ApplyList, v) + end + if self.ImgEmpty then + self.ImgEmpty.gameObject:SetActiveEx(#self.ApplyList <= 0) + end + table.sort(self.ApplyList, function(applyA, applyB) + if applyA.OnlineFlag == applyB.OnlineFlag then + return applyA.LastLoginTime > applyB.LastLoginTime + end + return applyA.OnlineFlag > applyB.OnlineFlag + end) + self.DynamicTable:Clear() + self.DynamicTable:SetDataSource(self.ApplyList) + self.DynamicTable:ReloadDataASync() +end + +function XUiGuildEnlistNews:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self, self.UiRoot) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.ApplyList[index] + if not data then return end + grid:SetItemData(data) + end +end + +function XUiGuildEnlistNews:OnBtnSetClick() + XLuaUiManager.Open("UiGuildChangePosition", XGuildConfig.TipsType.ApplySetting) +end + +return XUiGuildEnlistNews \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildEnlistRecruit.lua b/Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildEnlistRecruit.lua new file mode 100644 index 00000000..be3d5f32 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildEnlistRecruit.lua @@ -0,0 +1,79 @@ +local XUiGuildEnlistRecruit = XClass(nil, "XUiGuildEnlistRecruit") +local XUiGridGuildEnlistItem = require("XUi/XUiGuild/XUiChildItem/XUiGridGuildEnlistItem") +local LastRefreshTime = 0 + +function XUiGuildEnlistRecruit:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + + XTool.InitUiObject(self) + self:InitChildView() +end + +function XUiGuildEnlistRecruit:InitChildView() + self.DynamicTable = XDynamicTableNormal.New(self.PanelTreasureGrade.gameObject) + self.DynamicTable:SetProxy(XUiGridGuildEnlistItem) + self.DynamicTable:SetDelegate(self) + + self.UiRoot:BindHelpBtn(self.BtnInformation, "GuildRecruit") + self.BtnRefresh.CallBack = function() self:OnBtnRefreshClick() end +end + +function XUiGuildEnlistRecruit:UpdateEnlists() + local reconmendDatas = XDataCenter.GuildManager.GetRandomRecommendPlayers() + self.ReconmendDatas = {} + for _, recruitInfo in pairs(reconmendDatas) do + table.insert(self.ReconmendDatas, recruitInfo) + end + + table.sort(self.ReconmendDatas, function(recruitA, recruitB) + if recruitA.OnlineFlag == recruitB.OnlineFlag then + if recruitA.Level == recruitB.Level then + return recruitA.LastLoginTime > recruitB.LastLoginTime + end + return recruitA.Level > recruitB.Level + end + return recruitA.OnlineFlag > recruitB.OnlineFlag + end) + + self.DynamicTable:Clear() + if self.ImgEmpty then + self.ImgEmpty.gameObject:SetActiveEx(#self.ReconmendDatas <= 0) + end + self.DynamicTable:SetDataSource(self.ReconmendDatas) + self.DynamicTable:ReloadDataASync() +end + +function XUiGuildEnlistRecruit:RefreshEnlists() + self:UpdateEnlists() +end + +function XUiGuildEnlistRecruit:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self, self.UiRoot) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.ReconmendDatas[index] + if not data then return end + grid:SetItemData(data) + -- elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + end +end + +function XUiGuildEnlistRecruit:OnBtnRefreshClick() + if not XDataCenter.GuildManager.IsGuildAdminister() then + return + end + local now = XTime.GetServerNowTimestamp() + if now - LastRefreshTime >= XGuildConfig.GUildRefreshCDTime then + local currentPageNo = XDataCenter.GuildManager.GetRecommendPageNo() + XDataCenter.GuildManager.GuildRecruitRecommendRequest(currentPageNo, function() + self:RefreshEnlists() + end) + LastRefreshTime = now + else + XUiManager.TipMsg(CS.XTextManager.GetText("GuildRefreshRecruitInCd", XGuildConfig.GUildRefreshCDTime - (now - LastRefreshTime))) + end +end + +return XUiGuildEnlistRecruit \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildMainInfo.lua b/Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildMainInfo.lua new file mode 100644 index 00000000..01975b1e --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildMainInfo.lua @@ -0,0 +1,122 @@ +local XUiGuildMainInfo = XClass(nil, "XUiGuildMainInfo") + +function XUiGuildMainInfo:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + + XTool.InitUiObject(self) + self:InitChildView() +end + +function XUiGuildMainInfo:UpdateMainInfo() + self.TxtMemberCount.text = string.format("%s/%s", tostring(XDataCenter.GuildManager.GetMemberCount()), tostring(XDataCenter.GuildManager.GetMemberMaxCount())) + self.TextLvNum.text = XDataCenter.GuildManager.GetGuildLevel() +end + +function XUiGuildMainInfo:OnEnable() + self.GameObject:SetActiveEx(true) + self.GuildId = XDataCenter.GuildManager.GetGuildId() + + self.ImgGuildIcon:SetRawImage(XDataCenter.GuildManager.GetGuildIconId()) + self.TxtGuildName.text = XDataCenter.GuildManager.GetGuildName() + self.TxtLeader.text = XDataCenter.GuildManager.GetGuildLeaderName() + self.TxtMemberCount.text = string.format("%s/%s", tostring(XDataCenter.GuildManager.GetMemberCount()), tostring(XDataCenter.GuildManager.GetMemberMaxCount())) + self.TextLvNum.text = XDataCenter.GuildManager.GetGuildLevel() + self.TextInfo.text = XDataCenter.GuildManager.GetGuildDeclaration() + + self.IconCoin1:SetRawImage(XDataCenter.ItemManager.GetItemIcon(XGuildConfig.GuildCoin)) + self.IconCoin2:SetRawImage(XDataCenter.ItemManager.GetItemIcon(XGuildConfig.GuildContributeCoin)) + self.TxtCoin1.text = XDataCenter.ItemManager.GetCount(XGuildConfig.GuildCoin) + self.TxtCoin2.text = XDataCenter.GuildManager.GetGuildContributeLeft() + + self.BtnWords.gameObject:SetActiveEx(XDataCenter.GuildManager.IsGuildAdminister()) +end + +function XUiGuildMainInfo:OnDisable() + self.GameObject:SetActiveEx(false) +end + +function XUiGuildMainInfo:OnViewDestroy() + +end + +function XUiGuildMainInfo:InitChildView() + XDataCenter.ItemManager.AddCountUpdateListener(XGuildConfig.GuildCoin, function() + self.TxtCoin1.text = XDataCenter.ItemManager.GetCount(XGuildConfig.GuildCoin) + end, self.TxtCoin1) + + self.BtnAdd.CallBack = function() self:OnBtnAddClick() end + self.BtnDynamic.CallBack = function() self:OnBtnDynamicClick() end + self.BtnRanking.CallBack = function() self:OnBtnRankingClick() end + self.BtnWords.CallBack = function() self:OnBtnWordsClick() end +end + +function XUiGuildMainInfo:RefreshGuildContribute() + self.TxtCoin2.text = XDataCenter.GuildManager.GetGuildContributeLeft() +end + + +function XUiGuildMainInfo:OnBtnAddClick() + -- 中途被踢出公会 + if self:ChecKickOut() then + return + end + + XLuaUiManager.Open("UiBuyAsset", XGuildConfig.GuildContributeCoin, function() + end) +end + +function XUiGuildMainInfo:OnBtnDynamicClick() + -- 中途被踢出公会 + if self:ChecKickOut() then + return + end + + XLuaUiManager.Open("UiGuildLog") +end + +function XUiGuildMainInfo:OnBtnRankingClick() + -- 中途被踢出公会 + if self:ChecKickOut() then + return + end + + XDataCenter.GuildManager.GuildListRankRequest(function() + XLuaUiManager.Open("UiGuildRankingListSwitch") + end) +end + +function XUiGuildMainInfo:OnBtnWordsClick() + -- 中途被踢出公会 + if self:ChecKickOut() then + return + end + -- 职位变更 + if self:HasModifyAccess() then + return + end + + XLuaUiManager.Open("UiGuildInformation", XGuildConfig.InformationType.Announcement, function() + self.TextInfo.text = XDataCenter.GuildManager.GetGuildDeclaration() + end) +end + +function XUiGuildMainInfo:HasModifyAccess() + if not XDataCenter.GuildManager.IsGuildAdminister() then + XUiManager.TipMsg(CS.XTextManager.GetText("GuildNotAdministor")) + return true + end + return false +end + +function XUiGuildMainInfo:ChecKickOut() + if not XDataCenter.GuildManager.IsJoinGuild() then + XUiManager.TipMsg(CS.XTextManager.GetText("GuildKickOutByAdministor")) + self.UiRoot:Close() + return true + end + return false +end + +return XUiGuildMainInfo \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildMemberHornor.lua b/Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildMemberHornor.lua new file mode 100644 index 00000000..91d39c42 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildMemberHornor.lua @@ -0,0 +1,143 @@ +local XUiGuildMemberHornor = XClass(nil, "XUiGuildMemberHornor") +local XUiGridGuildHornorMemberGroup = require("XUi/XUiGuild/XUiChildItem/XUiGridGuildHornorMemberGroup") +local XUiGridGuildMemberCard = require("XUi/XUiGuild/XUiChildItem/XUiGridGuildMemberCard") + +function XUiGuildMemberHornor:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + + XTool.InitUiObject(self) + self:InitChildView() +end + +function XUiGuildMemberHornor:InitChildView() + self.DynamicTable = XDynamicTableCurve.New(self.PanelGuildMember.gameObject) + self.DynamicTable:SetProxy(XUiGridGuildHornorMemberGroup) + self.DynamicTable:SetDelegate(self) + + self.BtnArrowRight.CallBack = function() self:OnBtnArrowRightClick() end + self.BtnArrowLeft.CallBack = function() self:OnBtnArrowLeftClick() end + + self.TopMemberList = {} +end + +function XUiGuildMemberHornor:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self.UiRoot) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.BottomList[index + 1] + if not data then return end + grid:Refresh(data) + end +end + +-- 打开 +function XUiGuildMemberHornor:OnEnable() + -- 中途被踢出公会 + if not XDataCenter.GuildManager.IsJoinGuild() then + XUiManager.TipMsg(CS.XTextManager.GetText("GuildKickOutByAdministor")) + self.UiRoot:Close() + return + end + + self.GameObject:SetActiveEx(true) + self:UpdateMemberInfo() +end + +function XUiGuildMemberHornor:UpdateMemberInfo() + self:SetupMemberList() + self:SetupTop5Member() + self:SetupRestMembers() +end + +-- 除去最高贡献剩下的成员 +function XUiGuildMemberHornor:SetupRestMembers() + self.DynamicTable:SetDataSource(self.BottomList) + self.DynamicTable:ReloadData(-1) +end + +-- 最高5名 +function XUiGuildMemberHornor:SetupTop5Member() + for i = 1, XGuildConfig.RankTopListCount do + if not self.TopMemberList[i] then + local ui = CS.UnityEngine.Object.Instantiate(self.UiGuildRank) + local grid = XUiGridGuildMemberCard.New(ui, self.UiRoot) + grid.Transform:SetParent(self.RankTop5, false) + self.TopMemberList[i] = grid + end + self.TopMemberList[i].GameObject:SetActiveEx(true) + self.TopMemberList[i]:RefreshTop5Member(self.Top5List[i]) + end + -- for i = #self.Top5List + 1, #self.TopMemberList do + -- self.TopMemberList[i].GameObject:SetActiveEx(false) + -- end +end + +-- 初始化队员数据 +function XUiGuildMemberHornor:SetupMemberList() + local allMemberList = XDataCenter.GuildManager.GetMemberList() + + self.AllMemberList = {} + for _, v in pairs(allMemberList or {}) do + table.insert(self.AllMemberList, v) + end + + table.sort(self.AllMemberList, function(memberA, memberB) + if memberA.ContributeAct == memberB.ContributeAct then + if memberA.Level == memberB.Level then + return memberA.RankLevel < memberB.RankLevel + end + return memberA.Level > memberB.Level + end + return memberA.ContributeAct > memberB.ContributeAct + end) + + self.Top5List = {} + self.BottomList = {} + local pageNo = 1 + for i = 1, #self.AllMemberList do + local memberItem = self.AllMemberList[i] + memberItem.ContributeRank = i + if i <= XGuildConfig.RankTopListCount then + table.insert(self.Top5List, memberItem) + else + if not self.BottomList[pageNo] then + self.BottomList[pageNo] = {} + end + if #self.BottomList[pageNo] < XGuildConfig.RankBottomPageCount then + table.insert(self.BottomList[pageNo], memberItem) + end + if #self.BottomList[pageNo] == XGuildConfig.RankBottomPageCount then + pageNo = pageNo + 1 + end + end + end + -- 如果下方列表没有数据,则构造一个空表 + if #self.AllMemberList <= XGuildConfig.RankTopListCount then + self.BottomList[1] = {} + end +end + +-- 关闭 +function XUiGuildMemberHornor:OnDisable() + self.GameObject:SetActiveEx(false) +end + +-- 上一页 +function XUiGuildMemberHornor:OnBtnArrowLeftClick() + local startIndex = self.DynamicTable.Imp.StartIndex + if startIndex - 1 >= 0 then + self.DynamicTable.Imp:TweenToIndex(startIndex - 1) + end +end + +-- 下一页 +function XUiGuildMemberHornor:OnBtnArrowRightClick() + local startIndex = self.DynamicTable.Imp.StartIndex + if startIndex + 1 <= #self.BottomList then + self.DynamicTable.Imp:TweenToIndex(startIndex + 1) + end +end + +return XUiGuildMemberHornor \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildTaskDaily.lua b/Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildTaskDaily.lua new file mode 100644 index 00000000..3c28e6b0 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildTaskDaily.lua @@ -0,0 +1,41 @@ +local XUiGuildTaskDaily = XClass(nil, "XUiGuildTaskDaily") +local XUiGridGuildTaskItem = require("XUi/XUiGuild/XUiChildItem/XUiGridGuildTaskItem") + +function XUiGuildTaskDaily:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + + XTool.InitUiObject(self) + self:InitChildView() +end +-- PaneDlailyTask +-- PanelGradeContent +-- PaneTaskCompleted + +function XUiGuildTaskDaily:InitChildView() + self.DynamicTable = XDynamicTableNormal.New(self.PaneDlailyTask.gameObject) + self.DynamicTable:SetProxy(XUiGridGuildTaskItem) + self.DynamicTable:SetDelegate(self) + +end + +function XUiGuildTaskDaily:UpdateTasks() + self.GuildTasks = XDataCenter.GuildManager.GetSortedGuildDailyTasks() + + self.DynamicTable:SetDataSource(self.GuildTasks) + self.DynamicTable:ReloadDataASync() + self.PaneTaskCompleted.gameObject:SetActiveEx(#self.GuildTasks <= 0) +end + +function XUiGuildTaskDaily:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self.UiRoot) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.GuildTasks[index] + if not data then return end + grid:SetItemData(data) + end +end + +return XUiGuildTaskDaily \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildTaskMainly.lua b/Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildTaskMainly.lua new file mode 100644 index 00000000..ade87cc4 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildTaskMainly.lua @@ -0,0 +1,54 @@ +local XUiGuildTaskMainly = XClass(nil, "XUiGuildTaskMainly") +local XUiGridGuildTaskItem = require("XUi/XUiGuild/XUiChildItem/XUiGridGuildTaskItem") + +function XUiGuildTaskMainly:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + + XTool.InitUiObject(self) + self:InitChildView() +end + +function XUiGuildTaskMainly:InitChildView() + self.DynamicTable = XDynamicTableNormal.New(self.PaneDlailyTask.gameObject) + self.DynamicTable:SetProxy(XUiGridGuildTaskItem) + self.DynamicTable:SetDelegate(self) + +end + +function XUiGuildTaskMainly:UpdateTasks() + self.GuildTasks = XDataCenter.TaskManager.GetGuildMainlyFullTaskList() + -- 是否需要排序 + for _, v in pairs(self.GuildTasks or {}) do + v.SortWeight = 2 + if v.State == XDataCenter.TaskManager.TaskState.Achieved then + v.SortWeight = 1 + elseif v.State == XDataCenter.TaskManager.TaskState.Finish or v.State == XDataCenter.TaskManager.TaskState.Invalid then + v.SortWeight = 3 + end + end + + table.sort(self.GuildTasks,function(taskA, taskB) + if taskA.SortWeight == taskB.SortWeight then + return taskA.Id < taskB.Id + end + return taskA.SortWeight < taskB.SortWeight + end) + + self.DynamicTable:SetDataSource(self.GuildTasks) + self.DynamicTable:ReloadDataASync() + self.PaneTaskCompleted.gameObject:SetActiveEx(#self.GuildTasks <= 0) +end + +function XUiGuildTaskMainly:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self.UiRoot) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.GuildTasks[index] + if not data then return end + grid:SetItemData(data) + end +end + +return XUiGuildTaskMainly \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildViewChallenge.lua b/Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildViewChallenge.lua new file mode 100644 index 00000000..3abeacfd --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildViewChallenge.lua @@ -0,0 +1,73 @@ +local XUiGuildViewChallenge = XClass(nil, "XUiGuildViewChallenge") +local XUiGridChallengeItem = require("XUi/XUiGuild/XUiChildItem/XUiGridChallengeItem") + +function XUiGuildViewChallenge:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + + XTool.InitUiObject(self) + self:InitChildView() +end + +function XUiGuildViewChallenge:OnEnable() + self.GameObject:SetActiveEx(true) + self:RefreshChallenges() +end + +function XUiGuildViewChallenge:OnDisable() + self.GameObject:SetActiveEx(false) +end + +function XUiGuildViewChallenge:InitChildView() + if not self.DynamicChallengeTable then + self.DynamicChallengeTable = XDynamicTableNormal.New(self.PanelChallenge.gameObject) + self.DynamicChallengeTable:SetProxy(XUiGridChallengeItem) + self.DynamicChallengeTable:SetDelegate(self) + end + +end + +function XUiGuildViewChallenge:OnViewDestroy() + +end + +function XUiGuildViewChallenge:RefreshChallenges() + self.AllChallenges = XGuildConfig.GetGuildChallenges() + self.DynamicChallengeTable:SetDataSource(self.AllChallenges) + self.DynamicChallengeTable:ReloadDataASync() +end + +function XUiGuildViewChallenge:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self.UiRoot) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.AllChallenges[index] + if not data then return end + grid:SetChallengeItem(data) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + self:OnChallengeClick(index) + end +end + +function XUiGuildViewChallenge:OnChallengeClick(index) + -- 中途被踢出公会 + if not XDataCenter.GuildManager.IsJoinGuild() then + XUiManager.TipMsg(CS.XTextManager.GetText("GuildKickOutByAdministor")) + self.UiRoot:Close() + return + end + + -- 暂时这样处理 + local data = self.AllChallenges[index] + if not data then return end + if XDataCenter.GuildManager.IsGuildTourist() then + XUiManager.TipMsg(CS.XTextManager.GetText("GuildTourstAccess")) + return + end + if data.ChallengeType == XGuildConfig.GuildChallengeEnter.GuildTask then + XLuaUiManager.Open("UiGuildTask") + end +end + +return XUiGuildViewChallenge \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildViewCharacterFilter.lua b/Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildViewCharacterFilter.lua new file mode 100644 index 00000000..518e573c --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildViewCharacterFilter.lua @@ -0,0 +1,99 @@ +local XUiGuildViewCharacterFilter = XClass(nil, "XUiGuildViewCharacterFilter") +local XUiGridGuildPersonItem = require("XUi/XUiGuild/XUiChildItem/XUiGridGuildPersonItem") + + +function XUiGuildViewCharacterFilter:Ctor(ui,uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + XTool.InitUiObject(self) + self.ListData = {} + self.CurRecordIds = {} + self:Init() +end + +function XUiGuildViewCharacterFilter:OnStart() +end + +function XUiGuildViewCharacterFilter:OnEnable() + self.GameObject:SetActiveEx(true) + self:OnRefreshListData() +end + +function XUiGuildViewCharacterFilter:OnDisable() + self.CurRecordIds = {} +end + +function XUiGuildViewCharacterFilter:OnDestroy() + +end + +function XUiGuildViewCharacterFilter:Init() + self:InitList() + self:InitFun() +end + +function XUiGuildViewCharacterFilter:InitList() + self.DynamicShopTable = XDynamicTableNormal.New(self.PanelList.gameObject) + self.DynamicShopTable:SetProxy(XUiGridGuildPersonItem) + self.DynamicShopTable:SetDelegate(self) +end + +function XUiGuildViewCharacterFilter:OnRefreshListData() + self.ListData = XGuildConfig.GetTrustCharacterIds() or {} + self.DynamicShopTable:SetDataSource(self.ListData) + self.DynamicShopTable:ReloadDataASync() + local flag = #self.ListData <= 0 + self.ImgNonePerson.gameObject:SetActiveEx(flag) +end + +function XUiGuildViewCharacterFilter:InitFun() + self.BtnTanchuangClose.CallBack = function() self:OnBtnTanchuangClose() end + self.BtnConfirm.CallBack = function() self:OnBtnConfirm() end + self.BtnAll.CallBack = function() self:OnBtnAll() end +end + +function XUiGuildViewCharacterFilter:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:OnRefresh(self.ListData[index]) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + grid:OnClickSeleStatus() + end +end + +function XUiGuildViewCharacterFilter:OnBtnAll() + for gridIndex,griddata in pairs(self.ListData)do + local grid = self.DynamicShopTable:GetGridByIndex(gridIndex) + if grid then + grid:SetSeleStatus(true) + end + griddata.Status = true + end + self:AllRecordSeleId(true) +end + +function XUiGuildViewCharacterFilter:OnBtnTanchuangClose() + self.GameObject:SetActiveEx(false) + self.UiRoot.PanelRewards.gameObject:SetActiveEx(true) + self.UiRoot:OnRefresh() +end + +function XUiGuildViewCharacterFilter:OnBtnConfirm() + self:OnBtnTanchuangClose() +end + +function XUiGuildViewCharacterFilter:RecordSeleId(id) + self.UiRoot:RecordSeleId(id) +end + +function XUiGuildViewCharacterFilter:RemoveRecordSeleId(id) + self.UiRoot:RemoveRecordSeleId(id) +end + +function XUiGuildViewCharacterFilter:AllRecordSeleId() + self.UiRoot:AllRecordSeleId() +end + +return XUiGuildViewCharacterFilter \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildViewInformation.lua b/Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildViewInformation.lua new file mode 100644 index 00000000..f6339276 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildViewInformation.lua @@ -0,0 +1,233 @@ +local XUiGuildViewInformation = XClass(nil, "XUiGuildViewInformation") +local MainType = { + Info = 1, + Admin = 2, +} + +local XUiGuildMainInfo = require("XUi/XUiGuild/XUiChildView/XUiGuildMainInfo") +local XUiGuildAdministration = require("XUi/XUiGuild/XUiChildView/XUiGuildAdministration") +local XUiGridChannelItem = require("XUi/XUiGuild/XUiChildItem/XUiGridChannelItem") + +local LastRefreshMainTime = 0 + +function XUiGuildViewInformation:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + XTool.InitUiObject(self) + self:InitChildView() + self.IsFirstRequest = true +end + +function XUiGuildViewInformation:OnEnable() + self.GameObject:SetActiveEx(true) + self:UpdateGuildNews() + self:UpdateGuildGift() + self:OnAllRefresh() + + self:RequestMainInfo() +end + +-- 更新重置、职位变更 +function XUiGuildViewInformation:OnAllRefresh() + if self.LastSelect and self.tabViews[self.LastSelect] then + self.tabViews[self.LastSelect]:OnEnable() + end +end + +function XUiGuildViewInformation:OnDisable() + self.GameObject:SetActiveEx(false) +end + +function XUiGuildViewInformation:OnViewDestroy() + for _, view in pairs(self.tabViews or {}) do + view:OnViewDestroy() + end +end + +function XUiGuildViewInformation:InitChildView() + self.tabViews = {} + self.tabViews[MainType.Info] = XUiGuildMainInfo.New(self.PanelInformation, self.UiRoot) + self.tabViews[MainType.Admin] = XUiGuildAdministration.New(self.PanelAdministration, self.UiRoot) + + self.mainTabs = {} + self.mainTabs[MainType.Info] = self.BtnInformation + self.mainTabs[MainType.Admin] = self.BtnAdministration + self.PanelRightBtn:Init(self.mainTabs, function(index) self:OnMainTypeClick(index) end) + self.PanelRightBtn:SelectIndex(MainType.Info) + + -- Gift + self.BtnActiveBox.CallBack = function() self:OnBtnActiveBoxClick() end + -- Channel + self:InitChannelView() + + XRedPointManager.AddRedPointEvent(self.RedActiveGift, self.RefreshActiveGift, self, { XRedPointConditions.Types.CONDITION_GUILD_ACTIVEGIFT }) + XRedPointManager.AddRedPointEvent(self.RedAdminTab, self.RefreshApplyList, self, { XRedPointConditions.Types.CONDITION_GUILD_APPLYLIST }) + +end + +function XUiGuildViewInformation:RefreshApplyList(count) + self.RedAdminTab.gameObject:SetActiveEx(count >= 0) +end + +function XUiGuildViewInformation:RefreshActiveGift(count) + self.RedActiveGift.gameObject:SetActiveEx(count >= 0) +end + +function XUiGuildViewInformation:UpdateInformationInfo() + self:UpdateInfoMain() + self:UpdateInfoAdmin() +end + +function XUiGuildViewInformation:UpdateInfoMain() + if self.tabViews[MainType.Info] then + self.tabViews[MainType.Info]:UpdateMainInfo() + end +end + +function XUiGuildViewInformation:UpdateInfoAdmin() + if self.tabViews[MainType.Admin] then + self.tabViews[MainType.Admin]:UpdateGuildLevel() + end +end + +function XUiGuildViewInformation:InitChannelView() + self.DynamicChannelTable = XDynamicTableIrregular.New(self.ScrollChannel) + self.DynamicChannelTable:SetProxy("XUiGridChannelItem", XUiGridChannelItem, self.GridChannelItem.gameObject) + self.DynamicChannelTable:SetDelegate(self) + +end + +-- 更新公会贡献 +function XUiGuildViewInformation:UpdateGuildContribute() + if self.tabViews[MainType.Info] then + self.tabViews[MainType.Info]:RefreshGuildContribute() + end + if self.tabViews[MainType.Admin] then + self.tabViews[MainType.Admin]:RefreshGuildContribute() + end +end + +-- 公会礼包 +function XUiGuildViewInformation:UpdateGuildGift() + + local giftLevelGot = XDataCenter.GuildManager.GetGiftLevelGot() + local giftContribute = XDataCenter.GuildManager.GetGiftContribute() + local giftGuildLevel = XDataCenter.GuildManager.GetGiftGuildLevel() + local giftLevel = giftLevelGot + 1 + + local giftData = XGuildConfig.GetGuildGiftByGuildLevelAndGiftLevel(giftGuildLevel, giftLevel) + if not giftData then + self.ImgProgress.fillAmount = 1 + giftLevel = giftLevel - 1 + giftData = XGuildConfig.GetGuildGiftByGuildLevelAndGiftLevel(giftGuildLevel, giftLevel) + self.TextProgressValue.text = string.format("%d/%d", giftData.GiftContribute, giftData.GiftContribute) + else + self.ImgProgress.fillAmount = giftContribute / giftData.GiftContribute + self.TextProgressValue.text = string.format("%d/%d", giftContribute, giftData.GiftContribute) + end + self.TextNumber.text = giftLevel + self.RImgActiveBox:SetRawImage(giftData.GiftIcon) +end + +-- 领取礼包 +function XUiGuildViewInformation:OnBtnActiveBoxClick() + -- 中途被踢出公会 + if not XDataCenter.GuildManager.IsJoinGuild() then + XUiManager.TipMsg(CS.XTextManager.GetText("GuildKickOutByAdministor")) + self.UiRoot:Close() + return + end + + local lastGuildId = XDataCenter.GuildManager.GetGiftGuildGot() + local curGuildId = XDataCenter.GuildManager.GetGuildId() + + local giftLevelGot = XDataCenter.GuildManager.GetGiftLevelGot() + local giftContribute = XDataCenter.GuildManager.GetGiftContribute() + local giftGuildLevel = XDataCenter.GuildManager.GetGiftGuildLevel() + local giftLevel = giftLevelGot + 1 + + if XDataCenter.GuildManager.IsGuildTourist() then + XUiManager.TipMsg(CS.XTextManager.GetText("GuildTourstAccess")) + return + end + + -- 本周换过公会 + if lastGuildId > 0 and lastGuildId ~= curGuildId then + XUiManager.TipMsg(CS.XTextManager.GetText("GuildGiftChangeGuildCondition")) + return + end + + local giftData = XGuildConfig.GetGuildGiftByGuildLevelAndGiftLevel(giftGuildLevel, giftLevel) + if not giftData then + XUiManager.TipMsg(CS.XTextManager.GetText("GuildGiftMaxLevel")) + return + end + + if giftContribute < giftData.GiftContribute then + XUiManager.TipMsg(CS.XTextManager.GetText("GuildGiftProgressNotEnough")) + return + end + + XDataCenter.GuildManager.GuildGetGift(giftLevel, function() + self:UpdateGuildGift() + end) +end + +-- 公会频道 +function XUiGuildViewInformation:UpdateGuildNews() + local chatList = XDataCenter.ChatManager.GetGuildChatList() + self.GuildNewsList = {} + for i = 1, XGuildConfig.GuildNewsMaxCount do + if chatList[i] then + table.insert(self.GuildNewsList, 1, chatList[i]) + end + end + + self.DynamicChannelTable:SetDataSource(self.GuildNewsList) + self.DynamicChannelTable:ReloadDataASync() + self.ScrollChannel.verticalNormalizedPosition = 0 +end + +function XUiGuildViewInformation:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self.UiRoot) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.GuildNewsList[index] + if not data then return end + grid:SetNewsInfo(data) + end +end + +function XUiGuildViewInformation:GetProxyType() + return "XUiGridChannelItem" +end + +function XUiGuildViewInformation:OnMainTypeClick(index) + if self.LastSelect and self.tabViews[self.LastSelect] then + self.tabViews[self.LastSelect]:OnDisable() + end + self.tabViews[index]:OnEnable() + self.LastSelect = index +end + +-- 切换的时候重新请求主界面信息 +function XUiGuildViewInformation:RequestMainInfo() + local cd = XGuildConfig.GuildMainRefreshCD + local now = XTime.GetServerNowTimestamp() + if now - LastRefreshMainTime >= cd and not self.IsFirstRequest then + if not XDataCenter.GuildManager.IsGuildTourist() then + XDataCenter.GuildManager.GetGuildDetails(0, function() + self:UpdateGuildNews() + self:UpdateGuildGift() + self:OnAllRefresh() + end) + end + LastRefreshMainTime = now + end + if self.IsFirstRequest then + self.IsFirstRequest = false + end +end + +return XUiGuildViewInformation \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildViewMember.lua b/Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildViewMember.lua new file mode 100644 index 00000000..a948db2c --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildViewMember.lua @@ -0,0 +1,186 @@ +local XUiGuildViewMember = XClass(nil, "XUiGuildViewMember") +local XUiGridMemberItem = require("XUi/XUiGuild/XUiChildItem/XUiGridMemberItem") +local RequestMemberGap = 5 + +function XUiGuildViewMember:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + + XTool.InitUiObject(self) + self:InitChildView() + self.LastRequestMember = 0 + self.LastSetPanelIndex = 0 +end + +function XUiGuildViewMember:OnEnable() + XEventManager.AddEventListener(XEventId.EVENT_GUILD_MEMBER_SET, self.OnMemberSet, self) + -- 中途被踢出公会 + if not XDataCenter.GuildManager.IsJoinGuild() then + XUiManager.TipMsg(CS.XTextManager.GetText("GuildKickOutByAdministor")) + self.UiRoot:Close() + return + end + self.GameObject:SetActiveEx(true) + self.GridMemberItem.gameObject:SetActiveEx(false) + local updateMemberFunc = function() + self.CurSortIndex = self.CurSortIndex or 0 + self:UpdateMemberInfo() + + local allMember = XDataCenter.GuildManager.GetMemberList() + for _, memberInfo in pairs(allMember or {}) do + if memberInfo.Id == XPlayer.Id then + self.TxtName.text = XDataCenter.SocialManager.GetPlayerRemark(memberInfo.Id, memberInfo.Name) + + XUiPlayerLevel.UpdateLevel(memberInfo.Level, self.TxtLv,CS.XTextManager.GetText("GuildMemberLevel", memberInfo.Level)) + + self.TxtJob.text = XDataCenter.GuildManager.GetRankNameByLevel(memberInfo.RankLevel) + self.TxtContribution.text = memberInfo.ContributeAct or 0 + self.TxtHistoryContribution.text = memberInfo.ContributeHistory or 0 + if memberInfo.OnlineFlag == 1 then + self.TxtLastLogin.text = CS.XTextManager.GetText("GuildMemberOnline") + else + self.TxtLastLogin.text = XUiHelper.CalcLatelyLoginTime(memberInfo.LastLoginTime) + end + self.TxtPopulation.text = memberInfo.Popularity + XUiPLayerHead.InitPortrait(memberInfo.HeadPortraitId, memberInfo.HeadFrameId, self.Head) + + break + end + end + local likeItemCount = XDataCenter.ItemManager.GetCount(XGuildConfig.LikeItemId) + self.TextZan.text = string.format("x%d", likeItemCount) + local isAdministor = XDataCenter.GuildManager.IsGuildAdminister() + self.PanelSet.gameObject:SetActiveEx(isAdministor) + end + + local guildId = XDataCenter.GuildManager.GetGuildId() + local now = XTime.GetServerNowTimestamp() + if now - self.LastRequestMember >= RequestMemberGap then + self.LastRequestMember = now + XDataCenter.GuildManager.GetGuildMembers(guildId, function() + updateMemberFunc() + end) + else + updateMemberFunc() + end +end + +function XUiGuildViewMember:OnDisable() + self.GameObject:SetActiveEx(false) + XEventManager.RemoveEventListener(XEventId.EVENT_GUILD_MEMBER_SET, self.OnMemberSet, self) +end + +function XUiGuildViewMember:OnMemberSet(index) + local tempIndex = self.LastSetPanelIndex + -- 取消以前的设置面板(如果有) + if self.LastSetPanelIndex ~= 0 and self.AllMemberList[self.LastSetPanelIndex].IsSetPanel then + self.AllMemberList[self.LastSetPanelIndex].IsSetPanel = false + self.LastSetPanelIndex = 0 + end + -- 加入新的设置面板 + if tempIndex ~= index then + self.AllMemberList[index].IsSetPanel = true + self.LastSetPanelIndex = index + end + self.DynamicMemberTable:SetDataSource(self.AllMemberList) + self.DynamicMemberTable:ReloadDataASync() +end + +function XUiGuildViewMember:OnLeaderDissmissChange() + if not self.AllMemberList then return end + for i = 1, #self.AllMemberList do + local memberInfo = self.AllMemberList[i] + local grid = self.DynamicMemberTable:GetGridByIndex(i) + if grid then + grid:UpdateDissmissState(memberInfo) + end + end +end + +function XUiGuildViewMember:UpdateMemberJobInfo() + if not self.AllMemberList then return end + for i = 1, #self.AllMemberList do + local memberInfo = self.AllMemberList[i] + local grid = self.DynamicMemberTable:GetGridByIndex(i) + if grid then + grid:UpdateMemberJobInfo(memberInfo) + end + end + + local rankLevel = XDataCenter.GuildManager.GetCurRankLevel() + self.TxtJob.text = XDataCenter.GuildManager.GetRankNameByLevel(rankLevel) +end + +function XUiGuildViewMember:UpdateMemberInfo() + self.LastSetPanelIndex = 0 + local allMember = XDataCenter.GuildManager.GetMemberList() + self.AllMemberList = {} + for _, memberInfo in pairs(allMember or {}) do + table.insert(self.AllMemberList, XTool.Clone(memberInfo)) + end + + table.sort(self.AllMemberList, function(memberA, memberB) + if memberA.OnlineFlag == memberB.OnlineFlag then + if memberA.RankLevel == memberB.RankLevel then + if memberA.ContributeAct == memberB.ContributeAct then + return memberA.Level > memberB.Level + end + return memberA.ContributeAct > memberB.ContributeAct + end + return memberA.RankLevel < memberB.RankLevel + end + return memberA.OnlineFlag > memberB.OnlineFlag + end) + for index, memberInfo in pairs(self.AllMemberList) do + memberInfo.Index = index + memberInfo.IsSetPanel = false + end + self.DynamicMemberTable:SetDataSource(self.AllMemberList) + self.DynamicMemberTable:ReloadDataASync() +end + +function XUiGuildViewMember:OnViewDestroy() + +end + +function XUiGuildViewMember:InitChildView() + if not self.DynamicMemberTable then + self.DynamicMemberTable = XDynamicTableIrregular.New(self.MemberList.gameObject) + self.DynamicMemberTable:SetProxy("XUiGridMemberItem", XUiGridMemberItem, self.GridMemberItem.gameObject) + self.DynamicMemberTable:SetDelegate(self) + end + + XDataCenter.ItemManager.AddCountUpdateListener(XGuildConfig.LikeItemId, function() + local likeItemCount = XDataCenter.ItemManager.GetCount(XGuildConfig.LikeItemId) + self.TextZan.text = string.format("x%d", likeItemCount) + end, self.TextZan) +end + +function XUiGuildViewMember:GetProxyType() + return "XUiGridMemberItem" +end + +function XUiGuildViewMember:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self.UiRoot) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.AllMemberList[index] + if not data then return end + grid:SetMemberInfo(data, self.LastSetPanelIndex) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + self:OnMemberItemClick(index) + end +end + +function XUiGuildViewMember:OnMemberItemClick(index) + local data = self.AllMemberList[index] + if not data then return end + + if data.Id ~= XPlayer.Id then + XDataCenter.PersonalInfoManager.ReqShowInfoPanel(data.Id) + end +end + + +return XUiGuildViewMember \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildViewParticulars.lua b/Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildViewParticulars.lua new file mode 100644 index 00000000..c3b8f5d0 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildViewParticulars.lua @@ -0,0 +1,41 @@ +local XUiGuildViewParticulars = XClass(nil, "XUiGuildViewParticulars") +local XUiGridRecommendationItem = require("XUi/XUiGuild/XUiChildItem/XUiGridRecommendationItem") + +function XUiGuildViewParticulars:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + + XTool.InitUiObject(self) + self:InitChildView() +end + +function XUiGuildViewParticulars:OnEnable() + self.GameObject:SetActiveEx(true) +end + +function XUiGuildViewParticulars:OnDisable() + self.GameObject:SetActiveEx(false) +end + +function XUiGuildViewParticulars:InitChildView() + if not self.DynamicTable then + self.DynamicTable = XDynamicTableNormal.New(self.MemberList.gameObject) + self.DynamicTable:SetProxy(XUiGridRecommendationItem) + end + + self.DynamicTable:SetDataSource({{},{},{},{},{},{},{},{}}) + self.DynamicTable:ReloadDataASync() +end + +function XUiGuildViewParticulars:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self.UiRoot) + -- elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + + -- elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + + end +end + +return XUiGuildViewParticulars \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildViewSetHeadPortrait.lua b/Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildViewSetHeadPortrait.lua new file mode 100644 index 00000000..838bd1d8 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildViewSetHeadPortrait.lua @@ -0,0 +1,87 @@ +local XUiGuildViewSetHeadPortrait = XClass(nil, "XUiGuildViewSetHeadPortrait") +local XUiGuildHeadPortraitItem = require("XUi/XUiGuild/XUiChildItem/XUiGuildHeadPortraitItem") +function XUiGuildViewSetHeadPortrait:Ctor(ui, parent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Parent = parent + XTool.InitUiObject(self) + self:AddListener() + self.CurHeadPortraitId = -1 + self.InitHeadPortraitId = 1 + self:InitDynamicTable() +end + +function XUiGuildViewSetHeadPortrait:AddListener() + self.BtnHeadSure.CallBack = function() self:OnBtnHeadSureClick() end + self.BtnHeadCancel.CallBack = function() self:OnBtnHeadCancelClick() end + self.BtnClose.CallBack = function() self:OnBtnHeadCancelClick() end +end + +function XUiGuildViewSetHeadPortrait:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.ScrollView) + self.DynamicTable:SetProxy(XUiGuildHeadPortraitItem) + self.DynamicTable:SetDelegate(self) + self.GameObject:SetActiveEx(false) +end + +function XUiGuildViewSetHeadPortrait:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:OnRefresh(self.ListDatas[index]) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + if self.CurSeleGridItem then + self.CurSeleGridItem:SetStatus(false) + end + + local data = self.ListDatas[index] + grid:SetStatus(true) + self.CurSeleGridItem = grid + self:UpdateInfo(data.Id) + end +end + +function XUiGuildViewSetHeadPortrait:OnRefresh(defaultHeadPortriatId) + if defaultHeadPortriatId then + self.InitHeadPortraitId = defaultHeadPortriatId + end + self:SetListDatas() + self:UpdateInfo(self.InitHeadPortraitId) +end + + +function XUiGuildViewSetHeadPortrait:IsSeleId(id) + return self.CurHeadPortraitId == id +end + +function XUiGuildViewSetHeadPortrait:UpdateInfo(id) + if self.CurHeadPortraitId == id then + return + end + + self.CurHeadPortraitId = id + local config = XGuildConfig.GetGuildHeadPortraitById(id) + self.RImgPlayerIcon:SetRawImage(config.Icon) + self.TxtHeadName.text = config.Name + self.TxtDecs.text = config.Describe +end + +function XUiGuildViewSetHeadPortrait:SetListDatas() + self.ListDatas = XGuildConfig.GetGuildHeadPortraitDatas() + self.DynamicTable:SetDataSource(self.ListDatas) + self.DynamicTable:ReloadDataSync(1) +end + +function XUiGuildViewSetHeadPortrait:OnBtnHeadSureClick() + self.Parent:RecordGuildIconId(self.CurHeadPortraitId) + self:OnBtnHeadCancelClick() +end + +function XUiGuildViewSetHeadPortrait:RecordFirstSeleItem(item) + self.CurSeleGridItem = item +end + +function XUiGuildViewSetHeadPortrait:OnBtnHeadCancelClick() + self.GameObject:SetActiveEx(false) +end +return XUiGuildViewSetHeadPortrait \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildViewVistorInformation.lua b/Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildViewVistorInformation.lua new file mode 100644 index 00000000..29a375c1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildViewVistorInformation.lua @@ -0,0 +1,107 @@ +local XUiGuildViewVistorInformation = XClass(nil, "XUiGuildViewVistorInformation") +local XUiGuildVistorInfo = require("XUi/XUiGuild/XUiChildView/XUiGuildVistorInfo") +local XUiGridChannelVistorItem = require("XUi/XUiGuild/XUiChildItem/XUiGridChannelVistorItem") + +function XUiGuildViewVistorInformation:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + XTool.InitUiObject(self) + self:InitChildView() +end + +function XUiGuildViewVistorInformation:OnEnable() + self.GameObject:SetActiveEx(true) + self.UiGuildVistorInfo:OnEnable() + self:UpdateGuildNews() + self:OnRefresh() +end + +function XUiGuildViewVistorInformation:OnDisable() + self.GameObject:SetActiveEx(false) +end + +function XUiGuildViewVistorInformation:InitChildView() + self.UiGuildVistorInfo = XUiGuildVistorInfo.New(self.PanelInformation, self.UiRoot) + self:InitChannelView() + +end + +-- 公会礼包 +function XUiGuildViewVistorInformation:UpdateGuildGift() + self.CurguildId = XDataCenter.GuildManager.GetGuildId() + local info = XDataCenter.GuildManager.GetVistorGuildDetailsById(self.CurguildId) + if info then + local giftLevelGot = info.GiftGuildGot + local giftContribute = info.GiftContribute + local giftGuildLevel = info.GiftGuildLevel + local giftLevel = giftLevelGot + 1 + local giftData = XGuildConfig.GetGuildGiftByGuildLevelAndGiftLevel(giftGuildLevel, giftLevel) + if not giftData then + self.ImgProgress.fillAmount = 1 + giftLevel = giftLevel - 1 + giftData = XGuildConfig.GetGuildGiftByGuildLevelAndGiftLevel(giftGuildLevel, giftLevel) + self.TextProgressValue.text = string.format("%d/%d", giftData.GiftContribute, giftData.GiftContribute) + else + + self.ImgProgress.fillAmount = giftContribute / giftData.GiftContribute + self.TextProgressValue.text = string.format("%d/%d", giftContribute, giftData.GiftContribute) + end + self.TextNumber.text = giftLevel + self.RImgActiveBox:SetRawImage(giftData.GiftIcon) + end +end + +function XUiGuildViewVistorInformation:InitChannelView() + if not self.DynamicChannelTable then + self.DynamicChannelTable = XDynamicTableIrregular.New(self.ScrollChannel) + self.DynamicChannelTable:SetProxy("XUiGridChannelVistorItem", XUiGridChannelVistorItem, self.GridChannelItem.gameObject) + self.DynamicChannelTable:SetDelegate(self) + end +end + +function XUiGuildViewVistorInformation:OnRefresh() + self.CurguildId = XDataCenter.GuildManager.GetGuildId() + local flag = XDataCenter.GuildManager.IsHaveVistorGuildDetailsById(self.CurguildId) + if flag then + self.UiGuildVistorInfo:OnRefresh() + self:UpdateGuildGift() + else + XDataCenter.GuildManager.GetVistorGuildDetailsReq(self.CurguildId,function() + self.UiGuildVistorInfo:OnRefresh() + self:UpdateGuildGift() + end) + end +end + +-- 公会频道 +function XUiGuildViewVistorInformation:UpdateGuildNews() + local chatList = XDataCenter.ChatManager.GetGuildChatList() + self.GuildNewsList = {} + for i = 1, XGuildConfig.GuildNewsMaxCount do + if chatList[i] then + table.insert(self.GuildNewsList, 1, chatList[i]) + end + end + + self.DynamicChannelTable:SetDataSource(self.GuildNewsList) + self.DynamicChannelTable:ReloadDataASync() + self.ScrollChannel.verticalNormalizedPosition = 0 +end + +function XUiGuildViewVistorInformation:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self.UiRoot) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.GuildNewsList[index] + if not data then return end + grid:OnRefresh(data) + -- elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + end +end + +function XUiGuildViewVistorInformation:GetProxyType() + return "XUiGridChannelVistorItem" +end + +return XUiGuildViewVistorInformation \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildViewVistorMember.lua b/Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildViewVistorMember.lua new file mode 100644 index 00000000..de60fbcc --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildViewVistorMember.lua @@ -0,0 +1,59 @@ +local XUiGuildViewVistorMember = XClass(nil, "XUiGuildViewVistorMember") +local XUiGridMemberVistorItem = require("XUi/XUiGuild/XUiChildItem/XUiGridMemberVistorItem") + +function XUiGuildViewVistorMember:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + XTool.InitUiObject(self) + + self:InitList() +end + +function XUiGuildViewVistorMember:OnEnable() + self.GameObject:SetActiveEx(true) + self:OnRefreshData() +end + +function XUiGuildViewVistorMember:OnDisable() + self.GameObject:SetActiveEx(false) +end + +function XUiGuildViewVistorMember:InitList() + self.DynamicMemberTable = XDynamicTableNormal.New(self.MemberList.gameObject) + self.DynamicMemberTable:SetProxy(XUiGridMemberVistorItem) + self.DynamicMemberTable:SetDelegate(self) +end + +function XUiGuildViewVistorMember:OnRefreshData() + local guildId = XDataCenter.GuildManager.GetGuildId() + local data = XDataCenter.GuildManager.GetVistorMemberList(guildId) or {} + self.ListData = {} + if next(data) then + for _,v in pairs(data) do + table.insert(self.ListData, v) + end + self.DynamicMemberTable:SetDataSource(self.ListData) + self.DynamicMemberTable:ReloadDataASync() + else + XDataCenter.GuildManager.GetVistorGuildMembers(guildId,function() + data = XDataCenter.GuildManager.GetVistorMemberList(guildId) or {} + for _,v in pairs(data) do + table.insert(self.ListData, v) + end + self.DynamicMemberTable:SetDataSource(self.ListData) + self.DynamicMemberTable:ReloadDataASync() + end) + end +end + +function XUiGuildViewVistorMember:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self.UiRoot) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:OnRefresh(self.ListData[index]) + -- elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + end +end + +return XUiGuildViewVistorMember \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildViewWelfare.lua b/Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildViewWelfare.lua new file mode 100644 index 00000000..1331e8d2 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildViewWelfare.lua @@ -0,0 +1,124 @@ +local XUiGuildViewWelfare = XClass(nil, "XUiGuildViewWelfare") + +local XUiGridWelfareItem = require("XUi/XUiGuild/XUiChildItem/XUiGridWelfareItem") + +function XUiGuildViewWelfare:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + + XTool.InitUiObject(self) + self:InitChildView() +end + +function XUiGuildViewWelfare:OnEnable() + self.GameObject:SetActiveEx(true) + + self:SetChildViewDatas() +end + +function XUiGuildViewWelfare:OnDisable() + self.GameObject:SetActiveEx(false) +end + +function XUiGuildViewWelfare:OnViewDestroy() + +end + +function XUiGuildViewWelfare:InitChildView() + if not self.DynamicWelfareTable then + self.DynamicWelfareTable = XDynamicTableNormal.New(self.PanelWelfare.gameObject) + self.DynamicWelfareTable:SetProxy(XUiGridWelfareItem) + self.DynamicWelfareTable:SetDelegate(self) + end + +end + +function XUiGuildViewWelfare:SetChildViewDatas() + if not self.WelfareDatas then + + self.WelfareDatas = XGuildConfig.GetGuildWelfares() + if self.WelfareDatas then + self.DynamicWelfareTable:SetDataSource(self.WelfareDatas) + self.DynamicWelfareTable:ReloadDataASync() + + end + end +end + +function XUiGuildViewWelfare:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self.UiRoot) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local welfareItem = self.WelfareDatas[index] + if welfareItem then + grid:SetItemData(welfareItem) + end + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + local welfareItem = self.WelfareDatas[index] + if welfareItem then + self:OnWelfareItemClick(welfareItem) + end + end +end + +function XUiGuildViewWelfare:OnWelfareItemClick(welfareItem) + -- 中途被踢出公会 + if not XDataCenter.GuildManager.IsJoinGuild() then + XUiManager.TipMsg(CS.XTextManager.GetText("GuildKickOutByAdministor")) + self.UiRoot:Close() + return + end + + -- condition + local welfareCondition = welfareItem.Condition + if welfareCondition > 0 then + local result, desc = XConditionManager.CheckCondition(welfareCondition) + if not result then + XUiManager.TipMsg(desc) + return + end + end + + if welfareItem.SkipId == 2 then + if XDataCenter.GuildManager.IsGuildTourist() then + XUiManager.TipMsg(CS.XTextManager.GetText("GuildTourstAccess")) + return + end + if XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.ShopCommon) then + local targetShopId = XGuildConfig.GuildPersonalShop + XShopManager.GetShopInfo(targetShopId, function() + XLuaUiManager.Open("UiGuildShop", targetShopId) + end) + end + elseif welfareItem.SkipId == 3 then + XLuaUiManager.Open("UiGuildDonation") + elseif welfareItem.SkipId == 1 then + if XDataCenter.GuildManager.IsGuildTourist() then + XUiManager.TipMsg(CS.XTextManager.GetText("GuildTourstAccess")) + return + end + if not XDataCenter.GuildManager.IsGuildAdminister() then + XUiManager.TipMsg(CS.XTextManager.GetText("GuildNotAdministor")) + return + end + XLuaUiManager.Open("UiGuildWelcomeWord") + elseif welfareItem.SkipId == 4 then + if XDataCenter.GuildManager.IsGuildTourist() then + XUiManager.TipMsg(CS.XTextManager.GetText("GuildTourstAccess")) + return + end + if not XDataCenter.GuildManager.IsGuildAdminister() then + XUiManager.TipMsg(CS.XTextManager.GetText("GuildNotAdministor")) + return + end + if XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.ShopCommon) then + local targetShopId = XGuildConfig.GuildPurchaseShop + XShopManager.GetShopInfo(targetShopId, function() + XLuaUiManager.Open("UiGuildShop", targetShopId) + end) + end + end +end + +return XUiGuildViewWelfare \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildVistorInfo.lua b/Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildVistorInfo.lua new file mode 100644 index 00000000..873123a7 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiChildView/XUiGuildVistorInfo.lua @@ -0,0 +1,93 @@ +local XUiGuildVistorInfo = XClass(nil, "XUiGuildVistorInfo") + +function XUiGuildVistorInfo:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + XTool.InitUiObject(self) + self:Init() +end + +function XUiGuildVistorInfo:OnEnable() + self.GameObject:SetActiveEx(true) + self:OnRefresh() +end + +function XUiGuildVistorInfo:OnDisable() + self.GameObject:SetActiveEx(false) +end + +function XUiGuildVistorInfo:Init() + self.BtnRanking:SetNameByGroup(0,CS.XTextManager.GetText("GuidVistorRankBtnDes")) + self.BtnApplay:SetNameByGroup(0,CS.XTextManager.GetText("GuidVistorApplyBtnDes")) + -- self.BtnChannel:SetNameByGroup(0,CS.XTextManager.GetText("GuidVistorChannelBtnDes")) + self.BtnExit:SetNameByGroup(0,CS.XTextManager.GetText("GuidVistorExitBtnDes")) + self.IconCoin1:SetRawImage(XDataCenter.ItemManager.GetItemIcon(XGuildConfig.GuildCoin)) + self.IconCoin2:SetRawImage(XDataCenter.ItemManager.GetItemIcon(XGuildConfig.GuildContributeCoin)) + self:InitFun() +end + +function XUiGuildVistorInfo:InitFun() + self.BtnExit.CallBack = function() self:OnBtnExitClick() end + self.BtnRanking.CallBack = function() self:OnBtnRankingClick() end + -- self.BtnChannel.CallBack = function() self:OnBtnChannelClick() end + self.BtnApplay.CallBack = function() self:OnBtnApplayClick() end + self.BtnAdd.CallBack = function() self:OnBtnAddClick() end + XDataCenter.ItemManager.AddCountUpdateListener(XGuildConfig.GuildCoin, function() + self.TxtCoin1.text = XDataCenter.ItemManager.GetCount(XGuildConfig.GuildCoin) + end, self.TxtCoin1) +end + +function XUiGuildVistorInfo:OnBtnAddClick() + XLuaUiManager.Open("UiBuyAsset", XGuildConfig.GuildContributeCoin, function() + end) +end + +function XUiGuildVistorInfo:OnBtnExitClick() + XDataCenter.GuildManager.GuildQuitTouristRequest(function() + XDataCenter.GuildManager.QuitVistorClean() + -- self.UiRoot:Close() + XLuaUiManager.RunMain() + end) +end + +function XUiGuildVistorInfo:OnBtnRankingClick() + XDataCenter.GuildManager.GuildListRankRequest(function() + XLuaUiManager.Open("UiGuildRankingListSwitch") + end) +end + +--申请加入公会 +function XUiGuildVistorInfo:OnBtnApplayClick() + XDataCenter.GuildManager.ApplyToJoinGuildRequest(self.CurguildId,function() + XUiManager.TipText("GuildApplyRequestSuccess") + end) +end + +function XUiGuildVistorInfo:OnBtnChannelClick() + +end + +-- 更新数据 +function XUiGuildVistorInfo:OnRefresh() + self.CurguildId = XDataCenter.GuildManager.GetGuildId() + self:SetData() +end + +function XUiGuildVistorInfo:SetData() + local info = XDataCenter.GuildManager.GetVistorGuildDetailsById(self.CurguildId) + if info then + local path = XGuildConfig.GetGuildHeadPortraitIconById(info.GuildIconId) + self.ImgGuildIcon:SetRawImage(path) + self.TxtGuildName.text = info.GuildName or "" + self.TxtLeader.text = info.GuildLeaderName or "" + self.TxtMemberCount.text = CS.XTextManager.GetText("GuildRankYoukuDes", info.GuildMemberCount,info.GuildMemberMaxCount) + self.TextLvNum.text = info.GuildLevel or "" + self.TxtCoin1.text = XDataCenter.ItemManager.GetCount(XGuildConfig.GuildCoin) + self.TxtCoin2.text = info.GuildContributeIn7Days or "" + --公告 + self.TextInfo.text = info.GuildDeclaration or "" + end +end + +return XUiGuildVistorInfo \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuild/XUiGuildAsset.lua b/Resources/Scripts/XUi/XUiGuild/XUiGuildAsset.lua new file mode 100644 index 00000000..c5f853da --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiGuildAsset.lua @@ -0,0 +1,64 @@ +local XUiGuildAsset = XLuaUiManager.Register(XLuaUi, "UiGuildAsset") +local blackColor = CS.UnityEngine.Color.black +local redColor = CS.UnityEngine.Color.red + +function XUiGuildAsset:OnAwake() + self.BtnConfirm.CallBack = function() self:OnBtnConfirmClick() end + self.BtnCancel.CallBack = function() self:OnBtnCancelClick() end + self.BtnTanchuangClose.CallBack = function() self:OnBtnCancelClick() end +end + +function XUiGuildAsset:OnDestroy() + +end + +function XUiGuildAsset:OnStart(confirmCallBack) + self.ConfirmCallBack = confirmCallBack + self.TxtTitle.text = CS.XTextManager.GetText("GuildDissmissLeader") + self.TxtDissmiss.text = string.gsub(CS.XTextManager.GetText("GuildDissmissDes"), "\\n", "\n") + + local coins = CS.XGame.Config:GetString("GuildImpeachCostItem") + local costs = CS.XGame.Config:GetString("GuildImpeachCostCount") + + self.AllCoins = string.Split(coins, "|") + self.AllCosts = string.Split(costs, "|") + + local coin1 = tonumber(self.AllCoins[1]) + local coin2 = tonumber(self.AllCoins[2]) + local needNum1 = tonumber(self.AllCosts[1]) + local needNum2 = tonumber(self.AllCosts[2]) + + local ownNum1 = XDataCenter.ItemManager.GetCount(coin1) + local ownNum2 = XDataCenter.ItemManager.GetCount(coin2) + + self.RImgCoin1:SetRawImage(XDataCenter.ItemManager.GetItemIcon(coin1)) + self.TxtCostNum1.text = needNum1 + self.RImgCoin2:SetRawImage(XDataCenter.ItemManager.GetItemIcon(coin2)) + self.TxtCostNum2.text = needNum2 + self.TxtCostNum1.color = (ownNum1 >= needNum1) and blackColor or redColor + self.TxtCostNum2.color = (ownNum2 >= needNum2) and blackColor or redColor + +end + +function XUiGuildAsset:OnBtnConfirmClick() + local coin1 = tonumber(self.AllCoins[1]) + local coin2 = tonumber(self.AllCoins[2]) + local needNum1 = tonumber(self.AllCosts[1]) + local needNum2 = tonumber(self.AllCosts[2]) + + local ownNum1 = XDataCenter.ItemManager.GetCount(coin1) + local ownNum2 = XDataCenter.ItemManager.GetCount(coin2) + if ownNum1 < needNum1 or ownNum2 < needNum2 then + XUiManager.TipMsg(CS.XTextManager.GetText("GuildDissmissCostNotEnough")) + return + end + + if self.ConfirmCallBack then + self.ConfirmCallBack() + end + self:Close() +end + +function XUiGuildAsset:OnBtnCancelClick() + self:Close() +end diff --git a/Resources/Scripts/XUi/XUiGuild/XUiGuildBuild.lua b/Resources/Scripts/XUi/XUiGuild/XUiGuildBuild.lua new file mode 100644 index 00000000..8f2bf75a --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiGuildBuild.lua @@ -0,0 +1,181 @@ +local XUiGuildBuild = XLuaUiManager.Register(XLuaUi, "UiGuildBuild") +local XUiGuildViewSetHeadPortrait = require("XUi/XUiGuild/XUiChildView/XUiGuildViewSetHeadPortrait") +local NameLenMinLimit +local NameLenMaxLimit +local GuildDeclarMaxLen +local greyColor = CS.XTextManager.GetText("GuildBuildEnoughColor") +local redColor = CS.XTextManager.GetText("GuildBuildNotEnoughColor") + +function XUiGuildBuild:OnAwake() + NameLenMinLimit = CS.XGame.Config:GetInt("GuildNameMinLen") + NameLenMaxLimit = CS.XGame.Config:GetInt("GuildNameMaxLen") + GuildDeclarMaxLen = CS.XGame.Config:GetInt("GuildDeclarationMaxLen") + self.CurGuildIconId = 1 + local coins = CS.XGame.Config:GetString("GuildImpeachCostItem") + local costs = CS.XGame.Config:GetString("GuildImpeachCostCount") + + self.AllCoins = string.Split(coins, "|") + self.AllCosts = string.Split(costs, "|") + + self.GuildViewSetHeadPortrait = XUiGuildViewSetHeadPortrait.New(self.PanelSetHeadPotrait,self) + self:InitFun() +end + +function XUiGuildBuild:OnGetEvents() + return { + XEventId.EVENT_GUILD_FILTER_FINISH, + } +end + +function XUiGuildBuild:OnNotify(evt, ...) + if evt == XEventId.EVENT_GUILD_FILTER_FINISH then + self:OnGuildFilterFinish(...) + end +end + +function XUiGuildBuild:OnEnable() + self:OnRefresh() + + for i = 1, #self.AllCoins do + local coin = tonumber(self.AllCoins[i]) + local needNum = tonumber(self.AllCosts[i]) + local ownNum = XDataCenter.ItemManager.GetCount(coin) + + local color = (ownNum >= needNum) and greyColor or redColor + self[string.format("TxtSpend%d", i)].text = string.format("%d", color, needNum) + self[string.format("RImgSpend%d", i)]:SetRawImage(XDataCenter.ItemManager.GetItemIcon(coin)) + end + self.TxtHint.text = CS.XTextManager.GetText("GuildDeclarationHintText") +end + +function XUiGuildBuild:OnDisable() + + if self.IsBuildSuccess then + self.IsBuildSuccess = false + XLuaUiManager.Close("UiGuildRecommendation") + end +end + +function XUiGuildBuild:InitFun() + self.BtnCancel.CallBack = function() self:OnBtnCancelClick() end + self.BtnConfirm.CallBack = function() self:OnBtnConfirmClick() end + self.BtnHeadIcon.CallBack = function() self:OnBtnHeadIconClick() end +end + +function XUiGuildBuild:OnBtnHeadIconClick() + self.GuildViewSetHeadPortrait:OnRefresh(self.CurGuildIconId) + self.PanelSetHeadPotrait.gameObject:SetActiveEx(true) +end + +function XUiGuildBuild:OnGuildFilterFinish(guildName, guilaDecl) + self.GuidNameInputField.text = guildName + self.GuildDeclarationInputField.text = guilaDecl +end +function XUiGuildBuild:OnBtnConfirmClick() + if not self.GuidNameInputField or not self.GuidNameInputField.textComponent then + return + end + + local guildName = self.GuidNameInputField.text + + --if string.match(guildName,"%s") then + -- XUiManager.TipText("GuildNameSpecialTips",XUiManager.UiTipType.Wrong) + -- return + --end + + if not string.match(guildName,"%S") then --防止出现纯空白字符串 + XUiManager.TipText("GuildNameEmptyText",XUiManager.UiTipType.Wrong) + return + end + + local utf8Count = self.GuidNameInputField.textComponent.cachedTextGenerator.characterCount - 1 + if utf8Count < NameLenMinLimit then + local text = CS.XTextManager.GetText("GuildNameMinNameLengthTips",NameLenMinLimit) + XUiManager.TipMsg(text, XUiManager.UiTipType.Wrong) + return + end + + if utf8Count > NameLenMaxLimit then + local text = CS.XTextManager.GetText("GuildNameMaxNameLengthTips",NameLenMaxLimit) + XUiManager.TipMsg(text, XUiManager.UiTipType.Wrong) + return + end + + if not self.GuildDeclarationInputField or not self.GuildDeclarationInputField.textComponent then + return + end + + local declaration = self.GuildDeclarationInputField.text + local tmpUtf8Count = self.GuildDeclarationInputField.textComponent.cachedTextGenerator.characterCount - 1 + if tmpUtf8Count > GuildDeclarMaxLen then + local text = CS.XTextManager.GetText("GuildDelarationMaxNameLengthTips",GuildDeclarMaxLen) + XUiManager.TipMsg(text, XUiManager.UiTipType.Wrong) + return + end + + --if string.match(declaration,"%s") then + -- XUiManager.TipText("GuildDeclarationSpecialTips",XUiManager.UiTipType.Wrong) + -- return + --end + if not string.match(declaration,"%S") then --防止出现纯空白字符串 + XUiManager.TipText("GuildDeclarationEmptyText",XUiManager.UiTipType.Wrong) + return + end + if declaration == "" then + declaration = CS.XTextManager.GetText("GuildDeclarationDefaultText") + end + + -- 消耗判断 + local costStr = "" + for i = 1, #self.AllCoins do + local coin = tonumber(self.AllCoins[i]) + local needNum = tonumber(self.AllCosts[i]) + local ownNum = XDataCenter.ItemManager.GetCount(coin) + local coinName = XDataCenter.ItemManager.GetItemName(coin) + if i == #self.AllCoins then + costStr = string.format("%s%d %s", costStr, needNum, coinName) + else + costStr = string.format("%s%d %s, ", costStr, needNum, coinName) + end + --costStr = string.format("%s%d%s,", costStr, needNum, coinName) -- 海外文本间要加空格,见上 ↑ + if needNum > ownNum then + XUiManager.TipText("GuildBuildNotEnoughCosts",XUiManager.UiTipType.Wrong) + return + end + end + + local title = CS.XTextManager.GetText("GuildBuildGuildTitle") + local content = CS.XTextManager.GetText("GuildBuildGuildContent", costStr) + XUiManager.DialogTip(title, content, XUiManager.DialogType.Normal, nil, function() + XDataCenter.GuildManager.BuildGuildRequest(guildName, declaration, self.CurGuildIconId, function() + self.IsBuildSuccess = true + self:Close() + XLuaUiManager.Remove("UiGuildBuild") + + XUiManager.TipText("GuildBuildSuccessTips") + XDataCenter.GuildManager.GetGuildDetails(0, function() + XLuaUiManager.Open("UiGuildMain") + end) + end) + end) +end + +function XUiGuildBuild:OnBtnCancelClick() + self:Close() +end + +function XUiGuildBuild:RecordGuildIconId(iconId) + self.CurGuildIconId = iconId + self:OnRefresh() +end + +-- 更新数据 +function XUiGuildBuild:OnRefresh() + if self.CurGuildIconId ~= self.PreGuildIconId then + local cfg = XGuildConfig.GetGuildHeadPortraitById(self.CurGuildIconId) + if cfg then + self.GuildFaceIcon:SetRawImage(cfg.Icon) + self.PreGuildIconId = self.CurGuildIconId + end + end +end diff --git a/Resources/Scripts/XUi/XUiGuild/XUiGuildChangePosition.lua b/Resources/Scripts/XUi/XUiGuild/XUiGuildChangePosition.lua new file mode 100644 index 00000000..e749abc5 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiGuildChangePosition.lua @@ -0,0 +1,268 @@ +-- 职位变更、审批设置、改名 +local XUiGuildChangePosition = XLuaUiManager.Register(XLuaUi, "UiGuildChangePosition") +local NameLenMinLimit +local NameLenMaxLimit +local CSXTextManagerGetText = CS.XTextManager.GetText + +function XUiGuildChangePosition:OnStart(tipsType, targetMember) + self.TargetMember = targetMember + self.TipsType = tipsType + self.PanelApply.gameObject:SetActiveEx(false) + self.PanelPosition.gameObject:SetActiveEx(false) + self.PanelSetName.gameObject:SetActiveEx(false) + self:InitChildView() +end + +function XUiGuildChangePosition:OnGetEvents() + return { + XEventId.EVENT_GUILD_FILTER_FINISH, + } +end + +function XUiGuildChangePosition:OnNotify(evt, ...) + if evt == XEventId.EVENT_GUILD_FILTER_FINISH then + self:OnGuildFilterFinish(...) + end +end + +function XUiGuildChangePosition:OnGuildFilterFinish(text) + if self.IsSetName then + self.InFGuildName.text = text + end +end + +function XUiGuildChangePosition:InitChildView() + -- common component -- + self.BtnClose.CallBack = function() self:OnBtnCloseClick() end + self.BtnCancel.CallBack = function() self:OnBtnCancelClick() end + self.BtnConfirm.CallBack = function() self:OnBtnConfirmClick() end + -- end -- + + self:HandleChangePosition() + self:HandleApplySetting() + self:HandleSetName() +end + +function XUiGuildChangePosition:OnBtnCloseClick() + self:Close() +end + +function XUiGuildChangePosition:OnBtnCancelClick() + self:Close() +end + +function XUiGuildChangePosition:OnBtnConfirmClick() + if not XDataCenter.GuildManager.IsGuildAdminister() then + XUiManager.TipMsg(CSXTextManagerGetText("GuildNotAdministor")) + self:Close() + return + end + + self:ConfirmChangePosition() + self:ConfirmApplySetting() + self:ConfirmSetName() +end + +-- 修改职位 +function XUiGuildChangePosition:HandleChangePosition() + if self.TipsType ~= XGuildConfig.TipsType.ChangePosition then return end + self.PanelPosition.gameObject:SetActiveEx(true) + + local myRankLevel = XDataCenter.GuildManager.GetCurRankLevel() + local level = XDataCenter.GuildManager.GetGuildLevel() + local positions = XGuildConfig.GetAllGuildPositions() + -- 当前职位的人数 + local curPosAmount = XDataCenter.GuildManager.GetMyGuildPosCount() + + self.MemberPosition = {} + -- 会长可以转移自己的职位 + if XDataCenter.GuildManager.IsGuildLeader() then + local id = XGuildConfig.GuildRankLevel.Leader + table.insert(self.MemberPosition,{ + Id = id, + Name = positions[id].Name, + RankName = XDataCenter.GuildManager.GetRankNameByLevel(id), + CurAmount = curPosAmount[id], + MaxAmount = XDataCenter.GuildManager.GetGuildPosCapacity(level,id), + }) + end + for _, v in pairs(positions) do + if myRankLevel < v.Id then + local data = { + Id = v.Id, + Name = v.Name, + RankName = XDataCenter.GuildManager.GetRankNameByLevel(v.Id), + CurAmount = curPosAmount[v.Id], + MaxAmount = XDataCenter.GuildManager.GetGuildPosCapacity(level,v.Id), + } + table.insert(self.MemberPosition, data) + end + end + self.TabPositions = {} + local defaultSelect = 0 + local targetRankLevel = self.TargetMember.RankLevel or 0 + for i=1, #self.MemberPosition do + if not self.TabPositions[i] then + local tabUi = CS.UnityEngine.Object.Instantiate(self.BtnPosition.gameObject) + tabUi.transform:SetParent(self.PanelPositionBtn.transform, false) + local tabBtn = tabUi.transform:GetComponent("XUiButton") + self.TabPositions[i] = tabBtn + end + self.TabPositions[i].gameObject:SetActiveEx(true) + local name = (self.MemberPosition[i].RankName ~= nil) and self.MemberPosition[i].RankName or self.MemberPosition[i].Name + self.TabPositions[i]:SetNameByGroup(0,name) + if self.MemberPosition[i].Id <= XGuildConfig.GuildRankLevel.Member then + local state = string.format("%d/%d", self.MemberPosition[i].CurAmount, self.MemberPosition[i].MaxAmount) + self.TabPositions[i]:SetNameByGroup(1,state)end + if targetRankLevel == self.MemberPosition[i].Id then + defaultSelect = i + end + end + for i = #self.MemberPosition + 1, #self.TabPositions do + self.TabPositions[i].gameObject:SetActiveEx(false) + end + -- 职位列表(BtnGrp) + self.PanelPositionBtn:Init(self.TabPositions, function(index) self:OnChangePositionClick(index) end) + if defaultSelect > 0 then + self.PanelPositionBtn:SelectIndex(defaultSelect) + end +end + +function XUiGuildChangePosition:ConfirmChangePosition() + if self.TipsType ~= XGuildConfig.TipsType.ChangePosition then return end + + local positionData = self.MemberPosition[self.SelectPositionIndex] + if not (self.SelectPositionIndex and positionData and self.TargetMember )then return end + local targetRankLevel = self.TargetMember.RankLevel or 0 + if targetRankLevel == positionData.Id then + XUiManager.TipMsg(CSXTextManagerGetText("GuildPositionIsSame", XDataCenter.GuildManager.GetRankNameByLevel(positionData.Id))) + return + end + local dialogTitle = CSXTextManagerGetText("GuildDialogTitle") + local hint = nil + if XGuildConfig.GuildRankLevel.Leader == positionData.Id then + hint = "GuildPositionChangeAdminContent" + else + hint = "GuildPositionChangedContent" + end + local dialogContent = CSXTextManagerGetText(hint, XDataCenter.GuildManager.GetRankNameByLevel(positionData.Id)) + XUiManager.DialogTip(dialogTitle, dialogContent, XUiManager.DialogType.Normal, nil, function() + XDataCenter.GuildManager.GuildChangeRank(self.TargetMember.Id, positionData.Id, function() + self:Close() + end) + end) +end + +-- 公会改名 +function XUiGuildChangePosition:HandleSetName() + if self.TipsType ~= XGuildConfig.TipsType.SetName then return end + self.PanelSetName.gameObject:SetActiveEx(true) + + NameLenMinLimit = CS.XGame.Config:GetInt("GuildNameMinLen") + NameLenMaxLimit = CS.XGame.Config:GetInt("GuildNameMaxLen") + self.BtnShop.CallBack = function() self:OnBtnShop() end + local isFree = XDataCenter.GuildManager.GetFreeChangeGuildName() + self.BtnShop.gameObject:SetActiveEx(not isFree) + self.TxtFreeTip.gameObject:SetActiveEx(isFree) + self.TxtSetNameTitle.text = CSXTextManagerGetText("GuildSetNameTitle") + self.TxtSetNameLength.text = CSXTextManagerGetText("GuildSetNameLength", NameLenMinLimit, NameLenMaxLimit) + self.TxtFreeTip.text = CSXTextManagerGetText("GuildSetNameFree") + self.TxtSetNameHint.text = CSXTextManagerGetText("GuildSetNameHint") +end + +function XUiGuildChangePosition:ConfirmSetName() + if self.TipsType ~= XGuildConfig.TipsType.SetName then return end + + local oldName = XDataCenter.GuildManager.GetGuildName() + local guildName = self.InFGuildName.text + + -- 检测与原来名字是否相同 + if oldName == guildName then + local typeTitle = CSXTextManagerGetText("GuildNameTitle") + XUiManager.TipMsg(CSXTextManagerGetText("GuildChangeInformationIsSame", typeTitle)) + return + end + if string.match(guildName,"%g") then -- 不能全为空格 + else + XUiManager.TipText("GuildNameSpecialTips",XUiManager.UiTipType.Wrong) + return + end + + local utf8Count = self.InFGuildName.textComponent.cachedTextGenerator.characterCount - 1 + if utf8Count < NameLenMinLimit then + local text = CSXTextManagerGetText("GuildNameMinNameLengthTips",NameLenMinLimit) + XUiManager.TipMsg(text, XUiManager.UiTipType.Wrong) + return + end + + if utf8Count > NameLenMaxLimit then + local text = CSXTextManagerGetText("GuildNameMaxNameLengthTips",NameLenMaxLimit) + XUiManager.TipMsg(text, XUiManager.UiTipType.Wrong) + return + end + + XDataCenter.GuildManager.GuildChangeName(guildName, function() + self:Close() + XUiManager.TipText("GuildSetNameSuccessTips") + CsXGameEventManager.Instance:Notify(XEventId.EVENT_GUILD_NAME_CHANGED) + if XDataCenter.GuildManager.GetFreeChangeGuildName() then + XDataCenter.GuildManager.SetFreeChangeGuildNameCount() + end + end) + return +end + +-- 审批设置 +function XUiGuildChangePosition:HandleApplySetting() + if self.TipsType ~= XGuildConfig.TipsType.ApplySetting then return end + self.PanelApply.gameObject:SetActiveEx(true) + + self.TabSettings = {} + table.insert(self.TabSettings, self.BtnNot) + table.insert(self.TabSettings, self.BtnSubmission) + table.insert(self.TabSettings, self.BtnStop) + -- 审批选项(BtnGrp) + self.PanelApplyBtn:Init(self.TabSettings, function(index) self:OnApplySettingClick(index) end) + local oldOption = XDataCenter.GuildManager.GetApplyOption() + self.PanelApplyBtn:SelectIndex(oldOption) + self.InFLimitLevel.placeholder.text = XDataCenter.GuildManager.GetMinLevelOption() +end + +function XUiGuildChangePosition:ConfirmApplySetting() + if self.TipsType ~= XGuildConfig.TipsType.ApplySetting then return end + if not self.SelectApplySettingIndex then return end + + local minLevelInput = self.InFLimitLevel.text + if not minLevelInput or minLevelInput == "" then + minLevelInput = XDataCenter.GuildManager.GetMinLevelOption() + end + if tonumber(minLevelInput) <= 0 then + XUiManager.TipMsg(CSXTextManagerGetText("GuildSettingLevelLessThanZero")) + return + end + if tonumber(minLevelInput) > XPlayerManager.PlayerMaxLevel then + XUiManager.TipMsg(CSXTextManagerGetText("GuildSettingLevelMoreThanMax", XPlayerManager.PlayerMaxLevel)) + return + end + + XDataCenter.GuildManager.GuildChangeApplyOption(self.SelectApplySettingIndex, tonumber(minLevelInput), function() + XUiManager.TipMsg(CSXTextManagerGetText("GuildSettingModifySucceed")) + self:Close() + end) +end + +function XUiGuildChangePosition:OnBtnShop() + if not XDataCenter.GuildManager.IsJoinGuild() then return end + if XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.ShopCommon) then + -- 4001 是绩点商店的id + XLuaUiManager.Open("UiShop", XShopManager.ShopType.Guild, nil, 4001) + end +end + +function XUiGuildChangePosition:OnApplySettingClick(index) + self.SelectApplySettingIndex = index +end + +function XUiGuildChangePosition:OnChangePositionClick(index) + self.SelectPositionIndex = index +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuild/XUiGuildCustomName.lua b/Resources/Scripts/XUi/XUiGuild/XUiGuildCustomName.lua new file mode 100644 index 00000000..68fd8a81 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiGuildCustomName.lua @@ -0,0 +1,162 @@ +local XUiGuildCustomName = XLuaUiManager.Register(XLuaUi, "UiGuildCustomName") +local Json = require("XCommon/Json") +local XUiGridCustomNameItem = require("XUi/XUiGuild/XUiChildItem/XUiGridCustomNameItem") +local Type = { + Main = 1, + NameSelect = 2, +} + +function XUiGuildCustomName:OnAwake() + self.CustomName.gameObject:SetActiveEx(false) + self.GridName.gameObject:SetActiveEx(false) + self.BtnTanchuangClose.CallBack = function() self:OnBtnTanchuangClose() end + self.BtnNo.CallBack = function() self:OnBtnNoClick() end + self.BtnYse.CallBack = function() self:OnBtnYseClick() end + self.CustomNameList = {} +end + +function XUiGuildCustomName:OnStart() + self:SwitchPanel(Type.Main) + self:RefreshAllPosition() + self.NameSelectIndex = 0 + self.RankSelectIndex = 0 + self.TabBtns = {} + self.NameItems = {} + self.GuildCustomName = XDataCenter.GuildManager.GetGuildCustomName() +end + +function XUiGuildCustomName:SwitchPanel(type) + self.Type = type + self.PanelMain.gameObject:SetActiveEx(type == Type.Main) + self.PanelNameSelect.gameObject:SetActiveEx(type == Type.NameSelect) + if type == Type.Main then + self.TxtTitle.text = CS.XTextManager.GetText("GuildCustomRankTitle") + elseif type == Type.NameSelect then + self.TxtTitle.text = CS.XTextManager.GetText("GuildCustomRankSelectTitle") + end +end + +function XUiGuildCustomName:RefreshAllPosition() + local allPositions = XGuildConfig.GetAllGuildPositions() + self.PositionConfigs = {} + for id, positionData in pairs(allPositions) do + table.insert(self.PositionConfigs, { + Id = id, + Name = positionData.Name, + Priority = positionData.Priority, + Authority = positionData.Authority, + }) + end + table.sort(self.PositionConfigs, function(positionA, positionB) + return positionA.Priority < positionB.Priority + end) + + for i = 1, #self.PositionConfigs do + if not self.CustomNameList[i] then + local ui = CS.UnityEngine.Object.Instantiate(self.CustomName) + ui.transform:SetParent(self.PanelCustomName, false) + self.CustomNameList[i] = XUiGridCustomNameItem.New(ui, self) + end + self.CustomNameList[i].GameObject:SetActiveEx(true) + self.CustomNameList[i]:SetItemData(self.PositionConfigs[i]) + end + for i = #self.PositionConfigs + 1, #self.CustomNameList do + self.CustomNameList[i].GameObject:SetActiveEx(false) + end +end + +function XUiGuildCustomName:OpenNameSelectPanel(rank, oldName) + self.RankSelectIndex = rank + self:SwitchPanel(Type.NameSelect) + self.NameSelectIndex = 1 + for index, name in ipairs(self.GuildCustomName[rank]) do + if not self.TabBtns[index] then + local tmpGrid = CS.UnityEngine.Object.Instantiate(self.GridName) + tmpGrid.transform:SetParent(self.PanelNameGrp, false) + tmpGrid.gameObject:SetActiveEx(true) + local tmpObj = {Transform = tmpGrid.transform, GameObject = tmpGrid.gameObject} + XTool.InitUiObject(tmpObj) + tmpObj.BtnSelect.SubGroupIndex = -1 + tmpObj.BtnSelect:SetName(name) + table.insert(self.NameItems, tmpObj) + table.insert(self.TabBtns, tmpObj.BtnSelect) + else + self.NameItems[index].GameObject:SetActiveEx(true) + self.TabBtns[index]:SetName(name) + end + if name == oldName then + self.NameSelectIndex = index + end + end + for i = #self.GuildCustomName[rank] + 1, #self.TabBtns do + self.NameItems[i].GameObject:SetActiveEx(false) + end + self.BtnGrpCustomName:Init(self.TabBtns, function(index) self:OnSelectedName(index) end) + self.BtnGrpCustomName:SelectIndex(self.NameSelectIndex, true) + return +end + +function XUiGuildCustomName:OnSelectedName(index) + self.NameSelectIndex = index +end + +function XUiGuildCustomName:OnBtnYseClick() + if self.Type == Type.Main then + local customNameTable = {} + local customNameCount = {} + local hasModify = false --是否跟上次一样 + for i = 1, #self.PositionConfigs do + local positionData = self.PositionConfigs[i] + local customName = self.CustomNameList[i]:GetInputName() + local oldName = XDataCenter.GuildManager.GetRankNameByLevel(positionData.Id) + customName = (customName == "") and oldName or customName + table.insert(customNameTable,{ + Id = positionData.Id, + Name = customName + }) + if customName ~= oldName then + hasModify = true + end + if not customNameCount[customName] then + customNameCount[customName] = 0 + end + customNameCount[customName] = customNameCount[customName] + 1 + end + if not hasModify then + XUiManager.TipMsg(CS.XTextManager.GetText("GuildRankNameHasNotChanged")) + return + end + + for _, count in pairs(customNameCount or {}) do + if count > 1 then + XUiManager.TipMsg(CS.XTextManager.GetText("GuildCustomRankHasSame")) + return + end + end + + local encode_custom = Json.encode(customNameTable) + XDataCenter.GuildManager.ChangeRankName(encode_custom, function() + self:RefreshAllPosition() + self:Close() + end) + elseif self.Type == Type.NameSelect then + if self.RankSelectIndex == 0 or self.NameSelectIndex == 0 then return end + local rank = self.RankSelectIndex + self.CustomNameList[rank]:SetName(self.GuildCustomName[rank][self.NameSelectIndex]) + self:SwitchPanel(Type.Main) + end +end + +function XUiGuildCustomName:OnBtnNoClick() + if self.Type == Type.Main then + self:OnBtnTanchuangClose() + elseif self.Type == Type.NameSelect then + self.NameSelectIndex = 0 + self:SwitchPanel(Type.Main) + end +end + +function XUiGuildCustomName:OnBtnTanchuangClose() + self:Close() +end + diff --git a/Resources/Scripts/XUi/XUiGuild/XUiGuildDonation.lua b/Resources/Scripts/XUi/XUiGuild/XUiGuildDonation.lua new file mode 100644 index 00000000..55b2bad4 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiGuildDonation.lua @@ -0,0 +1,101 @@ +local XUiGuildDonation = XLuaUiManager.Register(XLuaUi, "UiGuildDonation") +local XUiGuildDonationItem = require("XUi/XUiGuild/XUiChildItem/XUiGuildDonationItem") + +function XUiGuildDonation:OnAwake() + self:Init() +end + +function XUiGuildDonation:OnStart() + XDataCenter.GuildManager.GuildListWishRequest(function () + self:OnRefresh() + end) +end + +function XUiGuildDonation:Init() + self:InitList() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + self.TextDes.text = CS.XTextManager.GetText("GuildDonationDes") + self.BtnTongBlue.CallBack = function() self:OnBtnPublishWishRequest() end +end + +--发布心愿 +function XUiGuildDonation:OnBtnPublishWishRequest() + XLuaUiManager.Open("UiGuildPerson") +end + +function XUiGuildDonation:OnBtnBackClick() + self:Close() +end + +function XUiGuildDonation:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiGuildDonation:InitList() + self.DynamicTable = XDynamicTableNormal.New(self.PanelList) + self.DynamicTable:SetProxy(XUiGuildDonationItem) + self.DynamicTable:SetDelegate(self) +end + +-- [监听动态列表事件] +function XUiGuildDonation:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.ListData[index] + grid:OnRefresh(data) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + local data = self.ListData[index] + if not data then + return + end + -- if grid then + -- grid:SetSeleStatus(true) + -- ends + -- data.Status = true + end +end + +-- 更新数据 +function XUiGuildDonation:OnRefresh() + self.ListData = XDataCenter.GuildManager.GetGuildWishList() or {} + self.DynamicTable:SetDataSource(self.ListData) + self.DynamicTable:ReloadDataASync(1) + if #self.ListData == 0 then + self.TxtEmpty.gameObject:SetActiveEx(true) + else + self.TxtEmpty.gameObject:SetActiveEx(false) + end + self:SetDonationCount() +end + +function XUiGuildDonation:OnEnable() + self:SetDonationCount() +end + +--设置今日捐赠次数 +function XUiGuildDonation:SetDonationCount() + local cur = XDataCenter.GuildManager.GetCurDonationCount() + local total = XDataCenter.GuildManager.GetTotalDonationCount(XDataCenter.GuildManager.GetGuildLevel()) + self.TextNum.text = CS.XTextManager.GetText("GuildDonationrCountFormDes", cur,total) +end + +function XUiGuildDonation:OnDisable() + +end + +function XUiGuildDonation:OnDestroy() + +end + +function XUiGuildDonation:OnGetEvents() + return { } +end + +function XUiGuildDonation:OnNotify() + +end + + diff --git a/Resources/Scripts/XUi/XUiGuild/XUiGuildGift.lua b/Resources/Scripts/XUi/XUiGuild/XUiGuildGift.lua new file mode 100644 index 00000000..b46167c1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiGuildGift.lua @@ -0,0 +1,242 @@ +local XUiGuildGift = XLuaUiManager.Register(XLuaUi, "UiGuildGift") +local XUiGridGuildPresentItem = require("XUi/XUiGuild/XUiChildItem/XUiGridGuildPresentItem") + +local IsLockBtnAdd = false + +function XUiGuildGift:OnAwake() + self:AddListener() +end + +function XUiGuildGift:OnStart(targetMember) + self.PresentList = {} + self.SelectCount = 0 + self.DefaultMinSelectCount = 1 + self.SupposedCount = 1 + + self.WgtBtnAddSelect = self.BtnAddSelect.gameObject:GetComponent("XUiPointer") + self.WgtBtnMinusSelect = self.BtnMinusSelect.gameObject:GetComponent("XUiPointer") + -- 默认隐藏数量选择界面 + self:SetPanelNumVisable(false) + self.BtnAddSelect.CallBack = function() self:OnBtnAddSelectClick() end + self.BtnMinusSelect.CallBack = function() self:OnBtnMinusSelectClick() end + XUiButtonLongClick.New(self.WgtBtnMinusSelect, 100, self, nil, self.BtnMinusSelectLongClickCallback, nil, true) + XUiButtonLongClick.New(self.WgtBtnAddSelect, 100, self, nil, self.BtnAddSelectLongClickCallback, nil, true) + + self:RefreshGift(targetMember) +end + +function XUiGuildGift:AddListener() + self.BtnMax.CallBack = function() self:OnBtnMaxClick() end + self.BtnClose.CallBack = function() self:OnBtnCloseClick() end + self.BtnCancel.CallBack = function() self:OnBtnCloseClick() end + self.BtnConfirm.CallBack = function() self:OnBtnConfirmClick() end +end + +function XUiGuildGift:RefreshGift(targetMember) + self.TargetMember = targetMember + local allPresent = XGuildConfig.GetAllGuildPresent() + self.PresentDatas = {} + self.SelectGridIndexs = {} + self.currentIndex = -1 + local index = 1 + for _, present in pairs(allPresent) do + local itemId = present.PresentId + local itemCount = XDataCenter.ItemManager.GetCount(itemId) + if itemCount > 0 then + table.insert(self.PresentDatas, { + ItemId = itemId, + ItemCount = itemCount, + Popularity = present.Popularity, + Index = index + 1 + }) + index = index + 1 + end + end + + self.ImgEmpty.gameObject:SetActiveEx(#self.PresentDatas <= 0) + -- XUiHelper.CreateTemplates(self.RootUi, self.GridRewardItem, PresentDatas, XUiGridGuildPresentItem.New, self.PanelExpItem.gameObject, self.PanelContent) + for i = 1, #self.PresentDatas do + if not self.PresentList[i] then + local grid = CS.UnityEngine.Object.Instantiate(self.GridRewardItem) + grid.transform:SetParent(self.PanelGiftSelect, false) + self.PresentList[i] = XUiGridGuildPresentItem.New(grid, self, function(gridData, grid) + self:SelectRewardGrid(gridData, grid) + end) + end + self.PresentList[i]:SetSelectState(false) + self.PresentList[i].GameObject:SetActiveEx(true) + self.PresentList[i]:RefreshGiftItem(self.PresentDatas[i], i) + end + + for i = #self.PresentDatas + 1, #self.PresentList do + self.PresentList[i].GameObject:SetActiveEx(false) + end + self.LastSelectGrid = nil + self:SetPanelNumVisable(self.currentIndex ~= -1) +end + +function XUiGuildGift:SelectRewardGrid(gridData, grid) + local id = gridData.Data.ItemId + if not self.SelectGridIndexs[id] then + if self.LastSelectGrid then + self.SelectGridIndexs = {} + self.LastSelectGrid:SetSelectState(false) + self.SelectCount = gridData.CurSelectNum + end + grid:SetSelectState(true) + if gridData.CurSelectNum == 0 and grid.SelectState then + grid:SetSelectNum(self.SupposedCount) + end + self.LastSelectGrid = grid + self.SelectGridIndexs[id] = gridData.GridIndex + else + grid:SetSelectState(false) + grid:SetSelectNum(0) + self.SelectGridIndexs[id] = nil + end + self.currentIndex = grid.SelectState and gridData.GridIndex or -1 + self:SetPanelNumVisable(self.currentIndex ~= -1) + --self.TxtSelect.text = CS.XTextManager.GetText("ItemHaveSelectedCount", self.SelectCount, self.SupposedCount) +end + +function XUiGuildGift:SetPanelNumVisable(bool) + self.PanelNum.gameObject:SetActiveEx(bool) + if bool then + self:SetSelectCount(self.LastSelectGrid.CurSelectNum) + end +end + +function XUiGuildGift:OnBtnAddSelectClick() + if self.SelectCount >= self:GetGridCount() then + return + end + if IsLockBtnAdd then + return + end + self:SetSelectCount(self.SelectCount + 1) + self:SetBtnShowOfActionPointOverLimit() +end + +function XUiGuildGift:OnBtnMinusSelectClick() + if self.SelectCount <= 1 then + return + end + self:SetSelectCount(self.SelectCount - 1) + self:SetBtnShowOfActionPointOverLimit() +end + +function XUiGuildGift:OnBtnMaxClick() + local maxCount = self:GetMaxCount() + if maxCount and self.SelectCount >= maxCount then + return + end + + self:SetSelectCount(maxCount) + self:SetBtnShowOfActionPointOverLimit() +end + +function XUiGuildGift:OnBtnCloseClick() + self:Close() +end + +function XUiGuildGift:BtnMinusSelectLongClickCallback(time) + if self.SelectCount == 0 then + return + end + + local delta = math.max(0, math.floor(time / 150)) + local count = self.SelectCount - delta + if count <= 0 then + count = 0 + end + self:SetSelectCount(count) + self:SetBtnShowOfActionPointOverLimit() +end + +function XUiGuildGift:BtnAddSelectLongClickCallback(time) + local maxCount = self:GetGridCount() + if maxCount and self.SelectCount >= maxCount then + return + end + if IsLockBtnAdd then + XUiManager.TipMsg(CS.XTextManager.GetText("OverLimitCanNotUse")) + return + end + local delta = math.max(0, math.floor(time / 150)) + local count = self.SelectCount + delta + if maxCount and count >= maxCount then + count = maxCount + end + + self:SetSelectCount(count) + self:SetBtnShowOfActionPointOverLimit() +end + +function XUiGuildGift:SetSelectCount(newCount) + if not self.LastSelectGrid then return end + self.SelectCount = math.max(newCount, self.DefaultMinSelectCount) + if self.BtnUse then + self.BtnUse.interactable = newCount > 0 + end + self.TxtGiftSelect.text = tostring(self.SelectCount) + self.LastSelectGrid:SetSelectNum(self.SelectCount) + IsLockBtnAdd = newCount == self:GetMaxCount() +end + +function XUiGuildGift:OnBtnConfirmClick() + if not self.TargetMember then return end + local giftIds = {} + local giftCounts = {} + local totalPopularity = 0 + local notSelect = true + + for i = 1, #self.PresentList do + local itemId, selectNum, popularity = self.PresentList[i]:GetSelectNums() + if selectNum > 0 then + notSelect = false + table.insert(giftIds, itemId) + table.insert(giftCounts, selectNum) + totalPopularity = totalPopularity + popularity + end + end + + if notSelect then + XUiManager.TipMsg(CS.XTextManager.GetText("GuildNoneSelectPresent")) + return + end + + XDataCenter.GuildManager.GuildGiveLike(self.TargetMember.Id, giftIds, giftCounts, function() + local memberList = XDataCenter.GuildManager.GetMemberList() + local memberInfo = memberList[self.TargetMember.Id] + if memberInfo then + memberInfo.Popularity = memberInfo.Popularity + totalPopularity + end + + XUiManager.TipMsg(CS.XTextManager.GetText("GuildSendGiftSuccess", XDataCenter.SocialManager.GetPlayerRemark(self.TargetMember.Id, self.TargetMember.Name))) + self:RefreshGift(self.TargetMember) + XEventManager.DispatchEvent(XEventId.EVENT_GUILD_ALLRANKNAME_UPDATE) + end) +end + + +function XUiGuildGift:SetBtnShowOfActionPointOverLimit() + IsLockBtnAdd = false + local GoodsNum = 1 + local RewardIndex = 2 + local ActionPoint = XDataCenter.ItemManager.GetItem(XDataCenter.ItemManager.ItemId.ActionPoint) +end + +function XUiGuildGift:GetMaxCount() + local maxCount = self:GetGridCount() or 0 + if maxCount == 0 then + return maxCount + end + local tmpMaxCount = 1 + return maxCount +end + +--获取当前道具的数量包括堆叠显示 +function XUiGuildGift:GetGridCount() + if not self.LastSelectGrid then return end + return self.LastSelectGrid.Gift.ItemCount +end diff --git a/Resources/Scripts/XUi/XUiGuild/XUiGuildGloryLevel.lua b/Resources/Scripts/XUi/XUiGuild/XUiGuildGloryLevel.lua new file mode 100644 index 00000000..b176cf6d --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiGuildGloryLevel.lua @@ -0,0 +1,74 @@ +local XUiGuildGloryLevel = XLuaUiManager.Register(XLuaUi, "UiGuildGloryLevel") +local XUiGridTalentListItem = require("XUi/XUiGuild/XUiChildItem/XUiGridTalentListItem") + +local ShowGuildTalentHelp = "ShowGuildTalentHelp" + +function XUiGuildGloryLevel:OnAwake() + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + self:BindHelpBtn(self.BtnHelp, "GuildTalentHelp") + self.BtnViewTalent.CallBack = function() self:OnBtnViewTalentClick() end + self.TalentPointList = {} + self:SetGuildInfo() +end + +function XUiGuildGloryLevel:OnDestroy() +end + +function XUiGuildGloryLevel:OnStart() + self.DynamicTable = XDynamicTableNormal.New(self.PanelTalent) + self.DynamicTable:SetProxy(XUiGridTalentListItem) + self.DynamicTable:SetDelegate(self) + self.TalentPoints = XGuildConfig.GetSortedTalentPoints() + self.DynamicTable:SetDataSource(self.TalentPoints) + self.DynamicTable:ReloadDataASync(1) +end + +function XUiGuildGloryLevel:SetGuildInfo() + local pointTotal = XDataCenter.GuildManager.GetTalentPointFromBuild() + local pointLevelNeed = CS.XGame.Config:GetInt("GuildGloryPointsPerLevel") + local gloryLevel = XDataCenter.GuildManager.GetGloryLevel() + local pointOwn = pointTotal % pointLevelNeed + local pointNeed = pointLevelNeed - pointOwn + -- self.ImgProgress.fillAmount = pointOwn / pointLevelNeed + -- self.TxtTalentPoint.text = CS.XTextManager.GetText("GuildTalentPointProgress", pointOwn, pointNeed) + self.TxtGloryLevel.text = gloryLevel + self.TxtGloryDescription.text = CS.XTextManager.GetText("GuildTalentGloryDescription") + + -- 暂时隐藏 + self.ImgProgress.gameObject:SetActiveEx(false) + self.TxtTalentPoint.gameObject:SetActiveEx(false) + self.PanelLine.gameObject:SetActiveEx(false) +end + +function XUiGuildGloryLevel:Refresh(bReload) + self:UpdateDynamicTable(bReload) +end + +--设置动态列表 +function XUiGuildGloryLevel:UpdateDynamicTable(bReload) + --刷新数据 + self.DynamicTable:ReloadDataASync(bReload and 1 or -1) +end + +--动态列表事件 +function XUiGuildGloryLevel:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.TalentPoints[index] + grid:Refresh(data) + end +end + +function XUiGuildGloryLevel:OnBtnBackClick() + self:Close() +end + +function XUiGuildGloryLevel:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiGuildGloryLevel:OnBtnViewTalentClick() + XDataCenter.GuildManager.GuildTalentListReq(function() + XLuaUiManager.Open("UiGuildSkill") + end) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuild/XUiGuildInformation.lua b/Resources/Scripts/XUi/XUiGuild/XUiGuildInformation.lua new file mode 100644 index 00000000..0792471f --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiGuildInformation.lua @@ -0,0 +1,100 @@ +local XUiGuildInformation = XLuaUiManager.Register(XLuaUi, "UiGuildInformation") +local CsXTextManagerGetText = CS.XTextManager.GetText + +function XUiGuildInformation:OnAwake() + self.BtnTanchuangClose.CallBack = function() self:OnBtnCloseClick() end + self.BtnClose.CallBack = function() self:OnBtnCloseClick() end + self.BtnSignSure.CallBack = function() self:OnBtnSignSureClick() end + self.BtnSignCancel.CallBack = function() self:OnBtnSignCancelClick() end +end + +function XUiGuildInformation:OnStart(type) + self.InfoType = type + self:SetText() +end + +function XUiGuildInformation:OnGetEvents() + return { + XEventId.EVENT_GUILD_FILTER_FINISH, + } +end + +function XUiGuildInformation:OnNotify(evt, ...) + if evt == XEventId.EVENT_GUILD_FILTER_FINISH then + self:OnGuildFilterFinish(...) + end +end + +function XUiGuildInformation:OnGuildFilterFinish(text) + self.InFContent.text = text +end + +function XUiGuildInformation:SetText() + -- 指挥局公告 + if self.InfoType == XGuildConfig.InformationType.Announcement then + self.typeText = CsXTextManagerGetText("GuildAnnouncementTitle") + self.wordMaxCount = XGuildConfig.AnnouncementWordMaxCount + self.InFContent.placeholder.text = CsXTextManagerGetText("GuildAnnouncementDes") + self.oldContent = XDataCenter.GuildManager.GetGuildDeclaration() + -- 内部通讯 + elseif self.InfoType == XGuildConfig.InformationType.InternalCommunication then + self.typeText = CsXTextManagerGetText("GuildInterComTitle") + self.wordMaxCount = XGuildConfig.InterComWordMaxCount + self.InFContent.placeholder.text = CsXTextManagerGetText("GuildInterComDes") + self.oldContent = XDataCenter.GuildManager.GetGuildInterCom() + end + self.InFContent.text = self.oldContent + self.TxtTitle.text = self.typeText + self.TxtNum.text = CsXTextManagerGetText("GuildInfoTextRange", self.wordMaxCount) +end + +function XUiGuildInformation:OnBtnCloseClick() + self:Close() +end + +function XUiGuildInformation:OnBtnSignSureClick() + -- 权限判断 + if not XDataCenter.GuildManager.IsGuildAdminister() then + XUiManager.TipMsg(CS.XTextManager.GetText("GuildInformationLimited", self.typeText)) + return + end + + local newContent = self.InFContent.text + if string.len(newContent) > 0 then + if newContent == self.oldContent then + XUiManager.TipMsg(CS.XTextManager.GetText("GuildChangeInformationIsSame", self.typeText)) + return + end + local utf8Count = self.InFContent.textComponent.cachedTextGenerator.characterCount - 1 + if utf8Count > self.wordMaxCount then + XUiManager.TipMsg(CS.XTextManager.GetText("GuildInformationOverCount", self.wordMaxCount, self.typeText)) + return + end + --if string.match(newContent,"%s") then -- 海外空格合法 + -- XUiManager.TipText("GuildDeclarationSpecialTips",XUiManager.UiTipType.Wrong) + -- return + --end + if string.match(newContent,"%g") then -- 不能全为空格 + else + XUiManager.TipText("GuildDeclarationSpecialTips",XUiManager.UiTipType.Wrong) + return + end + if self.InfoType == XGuildConfig.InformationType.Announcement then + XDataCenter.GuildManager.GuildChangeDeclaration(newContent, function() + self:Close() + CsXGameEventManager.Instance:Notify(XEventId.EVENT_GUILD_DECLARATION_CHANGED) + end) + else + XDataCenter.GuildManager.GuildChangeNotice(newContent, function() + self:Close() + CsXGameEventManager.Instance:Notify(XEventId.EVENT_GUILD_INTERCOM_CHANGED) + end) + end + else + XUiManager.TipMsg(CS.XTextManager.GetText("GuildInformationNotEmpty", self.typeText)) + end +end + +function XUiGuildInformation:OnBtnSignCancelClick() + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuild/XUiGuildLevelUp.lua b/Resources/Scripts/XUi/XUiGuild/XUiGuildLevelUp.lua new file mode 100644 index 00000000..f6b37ca7 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiGuildLevelUp.lua @@ -0,0 +1,42 @@ +local XUiGuildLevelUp = XLuaUiManager.Register(XLuaUi, "UiGuildLevelUp") + +function XUiGuildLevelUp:OnStart(lastLevel, curLevel, cb) + self.LastLevel = lastLevel + self.CurLevel = curLevel + self.Cb = cb + self.PresentList = {} + self.BtnClose.CallBack = function() self:OnBtnCloseClick() end + self.BtnViewSkill.CallBack = function() self:OnBtnViewSkillClick() end + self:RefreshLevel() +end + +function XUiGuildLevelUp:RefreshLevel() + -- local curLevel = XDataCenter.GuildManager.GetGuildLevel() + -- local lastLevel = XDataCenter.GuildManager.GetLastLevel() or curLevel-1 + -- if lastLevel == -1 or lastLevel >= curLevel then + -- lastLevel = curLevel-1 + -- end + self.TxtLastLevel.text = self.LastLevel + self.TxtCurrentLevel.text = self.CurLevel + self.TxtLevelUp.text = CS.XTextManager.GetText("GuildLevelUpHint", self.CurLevel) + self.BtnViewSkill.gameObject:SetActiveEx(XDataCenter.GuildManager.IsGuildAdminister()) + self.ImgHead:SetRawImage(XDataCenter.GuildManager.GetGuildIconId()) +end + +function XUiGuildLevelUp:OnBtnCloseClick() + self:Close() +end + +function XUiGuildLevelUp:OnBtnViewSkillClick() + self:Close() + XDataCenter.GuildManager.EnterGuildTalent() +end + +function XUiGuildLevelUp:OnDestroy() + if self.Cb then + self.Cb() + end + XEventManager.DispatchEvent(XEventId.EVENT_FUNCTION_EVENT_COMPLETE) +end + +return XUiGuildLevelUp \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuild/XUiGuildLog.lua b/Resources/Scripts/XUi/XUiGuild/XUiGuildLog.lua new file mode 100644 index 00000000..54f9e5c8 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiGuildLog.lua @@ -0,0 +1,134 @@ +local XUiGuildLog = XLuaUiManager.Register(XLuaUi, "UiGuildLog") + +local XUiGridGuildLogItem = require("XUi/XUiGuild/XUiChildItem/XUiGridGuildLogItem") +local Dropdown = CS.UnityEngine.UI.Dropdown +local MaxCount = { + [XGuildConfig.NewsType.Guild] = CS.XGame.Config:GetInt("GuildNewsMaxCount"), + [XGuildConfig.NewsType.Member] = CS.XGame.Config:GetInt("GuildPlayerNewsMaxCount") +} +-- local GuildNewsMaxCount = CS.XGame.Config:GetInt("GuildNewsMaxCount") +-- local GuildPlayerNewsMaxCount = CS.XGame.Config:GetInt("GuildPlayerNewsMaxCount") + +function XUiGuildLog:OnAwake() + self:InitChildView() + self:InitDropdown() +end + +function XUiGuildLog:OnStart() + MaxCount[XGuildConfig.NewsType.All] = MaxCount[XGuildConfig.NewsType.Guild] + MaxCount[XGuildConfig.NewsType.Member] +end + +function XUiGuildLog:OnDestroy() + +end + +function XUiGuildLog:InitDropdown() + self.NewsTypes = {} + for _, v in ipairs(XGuildConfig.NewsList) do + local type = XGuildConfig.NewsType[v] + table.insert(self.NewsTypes, { + -- NewsType = i, + -- TypeName = CS.XTextManager.GetText("GuildNews"..v), + NewsType = type, + TypeName = XGuildConfig.NewsName[type], + }) + end + + local defaultIndex = 1 + self.DrdSort:ClearOptions() + self.DrdSort.captionText.text = self.NewsTypes[defaultIndex].TypeName + for i = 1, #self.NewsTypes do + local op = Dropdown.OptionData() + op.text = self.NewsTypes[i].TypeName + self.DrdSort.options:Add(op) + end + self.DrdSort.onValueChanged:AddListener(function(value) + self:OnNewsTypeChangedIndex(value + 1) + end) + self:OnNewsTypeChangedIndex(defaultIndex) +end + +function XUiGuildLog:InitChildView() + self.BtnTanchuangClose.CallBack = function() self:OnBtnTanchuangClose() end + self.BtnYes.CallBack = function() self:OnBtnTanchuangClose() end + + if not self.DynamicCustomTable then + self.DynamicCustomTable = XDynamicTableIrregular.New(self.ScrollChannel.gameObject) + self.DynamicCustomTable:SetProxy("XUiGridGuildLogItem", XUiGridGuildLogItem, self.GridChannelItem.gameObject) + self.DynamicCustomTable:SetDelegate(self) + end + +end + +function XUiGuildLog:GetProxyType() + return "XUiGridGuildLogItem" +end + +function XUiGuildLog:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:SetItemData(self.AllGuildNews[index], self.CurrentNewsType) + -- 拉到顶端了 + if index == 1 and self.LookBackwardPage > 0 then + XDataCenter.GuildManager.GetGuildListNews(self.CurrentNewsType, self.LookBackwardPage, function() + self.LookBackwardPage = self.LookBackwardPage - 1 + self:RefreshLogs(self.CurrentNewsType) + end) + end + end +end + +-- 切换动态类型 +function XUiGuildLog:OnNewsTypeChangedIndex(index) + if not self.NewsTypes[index] then return end + self.CurrentNewsType = self.NewsTypes[index].NewsType + self:GetLogs(self.CurrentNewsType) +end + +function XUiGuildLog:GetLogs(type) + XDataCenter.GuildManager.GetGuildListNews(type, 0, function() + self.CurrentMaxPage = XDataCenter.GuildManager.GetGuildLogMaxPage(type) + self.LookBackwardPage = self.CurrentMaxPage - 1 + self:RefreshLogs(type) + -- self:GetLastPage() + end) +end + +-- function XUiGuildLog:GetLastPage() +-- if self.LookBackwardPage > 0 then +-- XDataCenter.GuildManager.GetGuildListNews(self.CurrentNewsType, self.LookBackwardPage, function() +-- self.LookBackwardPage = self.LookBackwardPage - 1 +-- self:RefreshLogs(self.CurrentNewsType) +-- self:GetLastPage() +-- end) +-- end +-- end + +function XUiGuildLog:RefreshLogs(type) + local allGuildNews = XDataCenter.GuildManager.GetGuildLogListByType(type) + local sortNews = {} + for k, v in pairs(allGuildNews or {}) do + table.insert(sortNews, v) + end + table.sort(sortNews, function(newA, newB) + return newA.Time > newB.Time + end) + self.AllGuildNews = {} + local totalLength = #sortNews + local begin = totalLength - MaxCount[type] + 1 + begin = (begin <= 0) and 1 or begin + local endIndex = totalLength + for i = begin, endIndex do + table.insert(self.AllGuildNews, sortNews[i]) + end + + self.DynamicCustomTable:SetDataSource(self.AllGuildNews) + -- if self.LookBackwardPage == 0 then + self.DynamicCustomTable:ReloadDataASync() + -- end +end + +function XUiGuildLog:OnBtnTanchuangClose() + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuild/XUiGuildMain.lua b/Resources/Scripts/XUi/XUiGuild/XUiGuildMain.lua new file mode 100644 index 00000000..7c779e74 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiGuildMain.lua @@ -0,0 +1,549 @@ +local XUiGuildMain = XLuaUiManager.Register(XLuaUi, "UiGuildMain") + +local CSXTextManagerGetText = CS.XTextManager.GetText + +local RequestMemberGap = 10 +local MAX_CHAT_WIDTH = 470 +local CHAT_SUB_LENGTH = 18 + +local XUiGuildViewSetHeadPortrait = require("XUi/XUiGuild/XUiChildView/XUiGuildViewSetHeadPortrait") +local XUiGridGuildBoxItem = require("XUi/XUiGuild/XUiChildItem/XUiGridGuildBoxItem") +local GuildBuildIntervalWhenMaxLevel = CS.XGame.Config:GetInt("GuildBuildIntervalWhenMaxLevel") +local GlobalLastRequestMember = 0 +local GlobalRequestGap = CS.XGame.ClientConfig:GetInt("GuildGlobalRequestMember") + +function XUiGuildMain:OnAwake() + self.GiftBoxes = {} + self.LastRequestMember = 0 + self:InitChildView() +end + +function XUiGuildMain:OnDestroy() +end + +function XUiGuildMain:OnStart(defaultIndex) + self:SetGuildInfo() + self:SetUiVisable() + self:SetActiveGift() + self:UpdateGuildNews() + self:OnDeclarationChanged() + self:OnInterComChanged() + self:UpdateGuildMemberCount() + + -- 获取成员,测试要求 + local now = XTime.GetServerNowTimestamp() + -- 第一次进入的时候AsyncGuildData会派发更新 + if GlobalLastRequestMember == 0 then + GlobalLastRequestMember = now + end + if now - GlobalLastRequestMember >= GlobalRequestGap then + GlobalLastRequestMember = now + local guildId = XDataCenter.GuildManager.GetGuildId() + XDataCenter.GuildManager.GetGuildMembers(guildId) + end +end + +function XUiGuildMain:OnEnable() + self.BtnTabChallenge:ShowReddot(XDataCenter.GuildBossManager.IsReward()) + local timeLeft = XDataCenter.GuildManager.GuildBossEndTime() - XTime.GetServerNowTimestamp() + if timeLeft < 0 then + timeLeft = 0 + end + local timeStr = XUiHelper.GetTime(timeLeft, XUiHelper.TimeFormatType.MAINBATTERY) + self.BtnTabChallenge:SetNameByGroup(1, CS.XTextManager.GetText("GuildBossCountDown", timeStr)) +end + +function XUiGuildMain:OnGetEvents() + return { + XEventId.EVENT_GUILD_RECEIVE_CHAT, + XEventId.EVENT_GUILD_RANKLEVEL_CHANGED, + XEventId.EVENT_GUILD_WEEKLY_RESET, + XEventId.EVENT_GUILD_LEVEL_CHANGED, + XEventId.EVENT_GUILD_GIFT_CONTRIBUTE_CHANGED, + XEventId.EVENT_GUILD_CONTRIBUTE_CHANGED, + XEventId.EVNET_GUILD_LEADER_NAME_CHANGED, + XEventId.EVENT_GUILD_MEMBERCOUNT_CHANGED, + XEventId.EVENT_GUILD_NAME_CHANGED, + XEventId.EVENT_GUILD_DECLARATION_CHANGED, + XEventId.EVENT_GUILD_INTERCOM_CHANGED, + } +end + +function XUiGuildMain:OnNotify(evt, ...) + if evt == XEventId.EVENT_GUILD_RECEIVE_CHAT then + self:OnGuildChannelDispatchChat() + elseif evt == XEventId.EVENT_GUILD_RANKLEVEL_CHANGED then + self:OnGuildRankLevelChanged() + elseif evt == XEventId.EVENT_GUILD_WEEKLY_RESET then + self:OnGuildWeeklyReset() + elseif evt == XEventId.EVENT_GUILD_CONTRIBUTE_CHANGED or + evt == XEventId.EVENT_GUILD_GIFT_CONTRIBUTE_CHANGED then + self:UpdateGuildGiftContribute() + elseif evt == XEventId.EVENT_GUILD_LEVEL_CHANGED then + self:UpdateInformationInfo() + elseif evt == XEventId.EVNET_GUILD_LEADER_NAME_CHANGED then + self:OnLeaderChanged() + elseif evt == XEventId.EVENT_GUILD_MEMBERCOUNT_CHANGED then + self:UpdateGuildMemberCount() + elseif evt == XEventId.EVENT_GUILD_NAME_CHANGED then + self:OnGuildNameChanged() + elseif evt == XEventId.EVENT_GUILD_DECLARATION_CHANGED then + self:OnDeclarationChanged() + elseif evt == XEventId.EVENT_GUILD_INTERCOM_CHANGED then + self:OnInterComChanged() + end +end + +-- 周重置 +function XUiGuildMain:OnGuildWeeklyReset() + self:SetGuildInfo() + self:SetActiveGift() + self:UpdateGuildMemberCount() +end + +-- 玩家职位变化 +function XUiGuildMain:OnGuildRankLevelChanged() + self:SetGuildInfo() + self:UpdateGuildMemberCount() +end + +-- 公会频道消息 +function XUiGuildMain:OnGuildChannelDispatchChat() + self:UpdateGuildNews() +end + +-- 更新礼包建设度 +function XUiGuildMain:UpdateGuildGiftContribute() + self:SetGuildInfo() + self:SetActiveGift() +end + +-- 更新主界面信息 +function XUiGuildMain:UpdateInformationInfo() + self:SetGuildInfo() +end + +-- 更新紧急维护状态 +function XUiGuildMain:UpdateMaintainState() + if self.tabViews[XDataCenter.GuildManager.GuildFunctional.Info] then + self.tabViews[XDataCenter.GuildManager.GuildFunctional.Info]:UpdateInformationInfo() + end +end + +-- custom method + +function XUiGuildMain:InitChildView() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + self:BindHelpBtn(self.BtnHelp, "GuildMainHelp") + + XRedPointManager.AddRedPointEvent(self.RedSetting, self.RefreshSettingRed, self, { XRedPointConditions.Types.CONDITION_GUILD_APPLYLIST }) + XRedPointManager.AddRedPointEvent(self.RedNews, self.RefreshNewsRed, self, { XRedPointConditions.Types.CONDITION_GUILD_APPLYLIST }) + + -- 设置面板 --- + self.BtnAdministration.CallBack = function() + self.GuildSet.gameObject:SetActiveEx(true) + end + self.BtnDarkCloseBg.CallBack = function() + self.GuildSet.gameObject:SetActiveEx(false) + end + -- 退出公会 + self.BtnGuildTuchu.CallBack = function() self:OnQuickGuildClick() end + -- 职位自定义名称 + self.BtnGuildZhiwei.CallBack = function() self:OnJobChangeClick() end + -- 招募设置 + self.BtnGuildZhaomu.CallBack = function() self:OnRecruitClick() end + -- 申请函 + self.BtnGuildShenqinghan.CallBack = function() self:OnApplyClick() end + -- 设置 + self.BtnGuildShezhi.CallBack = function() self:OnSettingClick() end + -- 改名 + self.BtnGuildSetName.CallBack = function() self:OnSetGuildName() end + --- end --- + + -- 公会宣言 + self.BtnAnnounce.CallBack = function() self:OnBtnAnnounceClick() end + -- 内部通讯 + self.BtnInterCom.CallBack = function() self:OnBtnInterComClick() end + -- 三个按钮 + self.BtnRanking.CallBack = function() self:OnBtnRaningClick() end + self.BtnJournal.CallBack = function() self:OnBtnJournalClick() end + self.BtnDeclaration.CallBack = function() self:OnBtnDeclarationClick() end + + -- 更换头像 + self.GuildViewSetHeadPortrait = XUiGuildViewSetHeadPortrait.New(self.PanelSetHeadPotrait,self) + self.BtnSetFace.CallBack = function() self:OnBtnSetFaceClick() end + + -- 其他模块 + self.BtnTabMember.CallBack = function() self:OnBtnTabMemberClick() end + self.BtnTabChallenge.CallBack = function() self:OnBtnChallengeClick() end + self.BtnTabGift.CallBack = function() self:OnBtnTabGiftClick() end + self.BtnChat.CallBack = function() self:OnBtnChatClick() end +end + +function XUiGuildMain:RefreshSettingRed(count) + self.RedSetting.gameObject:SetActiveEx(count >= 0) +end + +function XUiGuildMain:RefreshNewsRed(count) + self.RedNews.gameObject:SetActiveEx(count >= 0) +end + +function XUiGuildMain:OnBtnBackClick() + self:Close() +end + +function XUiGuildMain:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +-- 退出公会 +function XUiGuildMain:OnQuickGuildClick() + if self:ChecKickOut() then return end + + self.GuildSet.gameObject:SetActiveEx(false) + local isLeader = XDataCenter.GuildManager.IsGuildLeader() + if isLeader then + local memberCount = XDataCenter.GuildManager.GetMemberCount() + if memberCount > 1 then + XUiManager.TipMsg(CS.XTextManager.GetText("GuildQuitRemovePosition")) + return + else + local title = CS.XTextManager.GetText("GuildDialogTitle") + local content = CS.XTextManager.GetText("GuildQuitLastMember") + XUiManager.DialogTip(title, content, XUiManager.DialogType.Normal, function() + end, function() + XDataCenter.GuildManager.QuitGuild(function() + if XLuaUiManager.IsUiShow("UiGuildMain") then + XLuaUiManager.Close("UiGuildMain") + end + end) + end) + end + else + local title = CS.XTextManager.GetText("GuildDialogTitle") + local content = CS.XTextManager.GetText("GuildQuitMemberQuit") + XUiManager.DialogTip(title, content, XUiManager.DialogType.Normal, function() + end, function() + XDataCenter.GuildManager.QuitGuild(function() + if XLuaUiManager.IsUiShow("UiGuildMain") then + XLuaUiManager.Close("UiGuildMain") + end + end) + end) + end +end + +-- 职位 +function XUiGuildMain:OnJobChangeClick() + if self:ChecKickOut() then return end + if self:HasModifyAccess() then return end + + XLuaUiManager.Open("UiGuildCustomName") + self.GuildSet.gameObject:SetActiveEx(false) +end + +-- 招募 +function XUiGuildMain:OnRecruitClick() + if self:ChecKickOut() then return end + if self:HasModifyAccess() then return end + + local currentPageNo = XDataCenter.GuildManager.GetRecommendPageNo() + XDataCenter.GuildManager.GuildRecruitRecommendRequest(currentPageNo, function() + XLuaUiManager.Open("UiGuildRecruit", XGuildConfig.EnlistType.Recruit) + self.GuildSet.gameObject:SetActiveEx(false) + end) +end + +-- 邀请函 +function XUiGuildMain:OnApplyClick() + if self:ChecKickOut() then return end + if self:HasModifyAccess() then return end + + local currentPageNo = XDataCenter.GuildManager.GetRecommendPageNo() + XDataCenter.GuildManager.GuildRecruitRecommendRequest(currentPageNo, function() + XLuaUiManager.Open("UiGuildRecruit", XGuildConfig.EnlistType.News) + self.GuildSet.gameObject:SetActiveEx(false) + end) +end + +-- 招募设置 +function XUiGuildMain:OnSettingClick() + if self:ChecKickOut() then return end + if self:HasModifyAccess() then return end + + XLuaUiManager.Open("UiGuildChangePosition", XGuildConfig.TipsType.ApplySetting) + self.GuildSet.gameObject:SetActiveEx(false) +end + +-- 公会改名 +function XUiGuildMain:OnSetGuildName() + if self:ChecKickOut() then return end + if not XDataCenter.GuildManager.IsGuildLeader() then + local leaderName = XDataCenter.GuildManager.GetRankNameByLevel(XGuildConfig.GuildRankLevel.Leader) + XUiManager.TipMsg(CS.XTextManager.GetText("GuildNotAccessSetName", leaderName)) + return + end + + XLuaUiManager.Open("UiGuildChangePosition", XGuildConfig.TipsType.SetName) + self.GuildSet.gameObject:SetActiveEx(false) +end + + +-- 公会排名 +function XUiGuildMain:OnBtnRaningClick() + XLuaUiManager.Open("UiGuildRankingListSwitch") +end + +-- 成员 +function XUiGuildMain:OnBtnTabMemberClick() + local guildId = XDataCenter.GuildManager.GetGuildId() + local now = XTime.GetServerNowTimestamp() + if now - self.LastRequestMember >= RequestMemberGap then + self.LastRequestMember = now + XDataCenter.GuildManager.GetGuildMembers(guildId, function() + XLuaUiManager.Open("UiGuildRongyu") + end) + else + XLuaUiManager.Open("UiGuildRongyu") + end +end + +-- 挑战 +function XUiGuildMain:OnBtnChallengeClick() + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.GuildBoss) then + return + end + XDataCenter.GuildBossManager.SetFirstEnterMark(true) + XDataCenter.GuildBossManager.OpenGuildBossHall() +end + +-- 福利 +function XUiGuildMain:OnBtnTabGiftClick() + XLuaUiManager.Open("UiGuildPanelWelfare") +end + +-- 聊天 +function XUiGuildMain:OnBtnChatClick() + XLuaUiManager.Open("UiChatServeMain", false, ChatChannelType.Guild, ChatChannelType.World) +end + +-- 日志、动态 +function XUiGuildMain:OnBtnJournalClick() + -- 中途被踢出公会 + if self:ChecKickOut() then + return + end + + XLuaUiManager.Open("UiGuildLog") +end + +-- 迎新 +function XUiGuildMain:OnBtnDeclarationClick() + if XDataCenter.GuildManager.IsGuildTourist() then + XUiManager.TipMsg(CS.XTextManager.GetText("GuildTourstAccess")) + return + end + XLuaUiManager.Open("UiGuildWelcomeWord") +end + +-- 切换公会图标 +function XUiGuildMain:OnBtnSetFaceClick() + if not XDataCenter.GuildManager.IsGuildAdminister() then + XUiManager.TipMsg(CS.XTextManager.GetText("GuildNotAdministor")) + return + end + self.PanelSetHeadPotrait.gameObject:SetActiveEx(true) + local curHeadPortrait = XDataCenter.GuildManager.GetGuildHeadPortrait() + self.GuildViewSetHeadPortrait:OnRefresh(curHeadPortrait) +end + +-- 新图标 +function XUiGuildMain:RecordGuildIconId(selectHeadPortraitId) + local curHeadPortrait = XDataCenter.GuildManager.GetGuildHeadPortrait() + if selectHeadPortraitId ~= curHeadPortrait then + XDataCenter.GuildManager.GuildChangeIconRequest(selectHeadPortraitId, function() + local cfg = XGuildConfig.GetGuildHeadPortraitById(selectHeadPortraitId) + if cfg then + self.RImgGuildIcon:SetRawImage(cfg.Icon) + end + end) + end +end + +-- 新名字 +function XUiGuildMain:OnGuildNameChanged() + self.TxtGuildName.text = XDataCenter.GuildManager.GetGuildName() +end + +-- 新宣言 +function XUiGuildMain:OnDeclarationChanged() + self.TxtAnnounce.text = XDataCenter.GuildManager.GetGuildDeclaration() +end + +-- 新内部通讯 +function XUiGuildMain:OnInterComChanged() + local notice = XDataCenter.GuildManager.GetGuildInterCom() + if notice == nil or notice == "" then + self.TxtInterCom.text = CS.XTextManager.GetText("GuildInterComDes") + else + self.TxtInterCom.text = notice + end +end + +-- 修改公会宣言 +function XUiGuildMain:OnBtnAnnounceClick() + -- 中途被踢出公会 + if self:ChecKickOut() then + return + end + -- 职位变更 + if self:HasModifyAccess() then + return + end + + XLuaUiManager.Open("UiGuildInformation", XGuildConfig.InformationType.Announcement) +end + +-- 修改内部通讯 +function XUiGuildMain:OnBtnInterComClick() + -- 中途被踢出公会 + if self:ChecKickOut() then + return + end + -- 职位变更 + if self:HasModifyAccess() then + return + end + + XLuaUiManager.Open("UiGuildInformation", XGuildConfig.InformationType.InternalCommunication) +end + +-- 公会信息 +function XUiGuildMain:SetGuildInfo() + local guildId = XDataCenter.GuildManager.GetGuildId() + local guildLevel = XDataCenter.GuildManager.GetGuildLevel() + local curBuild = XDataCenter.GuildManager.GetBuild() + self.RImgGuildIcon:SetRawImage(XDataCenter.GuildManager.GetGuildIconId()) + self.TxtGuildName.text = XDataCenter.GuildManager.GetGuildName() + self.TxtLeader.text = XDataCenter.GuildManager.GetGuildLeaderName() + + self.GuildLevelTemplate = XGuildConfig.GetGuildLevelDataBylevel(guildLevel) + if XDataCenter.GuildManager.CheckAllTalentLevelMax() then + local gloryLevel = XDataCenter.GuildManager.GetGloryLevel() + self.TxtLvNum.text = string.format("%d(%d)", guildLevel, gloryLevel) + else + self.TxtLvNum.text = string.format("%d", guildLevel) + end + if XDataCenter.GuildManager.IsGuildLevelMax(guildLevel) then + -- 达到最高等级 + self.ImgProgress.fillAmount = curBuild * 1.0 / GuildBuildIntervalWhenMaxLevel + self.TxtNum.text = string.format("%s/%s", tostring(curBuild), tostring(GuildBuildIntervalWhenMaxLevel)) + else + -- 未到达最高等级 + self.TxtLvNum.text = guildLevel + self.ImgProgress.fillAmount = curBuild * 1.0 / self.GuildLevelTemplate.Build + self.TxtNum.text = string.format("%s/%s", tostring(curBuild), tostring(self.GuildLevelTemplate.Build)) + end +end + +-- 隐藏非管理员图标 +function XUiGuildMain:SetUiVisable() + if not XDataCenter.GuildManager.IsGuildAdminister() then + self.BtnInterCom.gameObject:SetActiveEx(false) + self.BtnAnnounce.gameObject:SetActiveEx(false) + self.BtnSetFace.gameObject:SetActiveEx(false) + end +end + +function XUiGuildMain:OnLeaderChanged() + self.TxtLeader.text = XDataCenter.GuildManager.GetGuildLeaderName() +end + +-- 公会频道 +function XUiGuildMain:UpdateGuildNews() + local chatList = XDataCenter.ChatManager.GetGuildChatList() + if not chatList then return end + local lastChat = chatList[1] + if not lastChat then return end + if not string.IsNilOrEmpty(lastChat.CustomContent) then + self.TxtMessageContent.supportRichText = true + else + self.TxtMessageContent.supportRichText = false + end + + local nameRemark = XDataCenter.SocialManager.GetPlayerRemark(lastChat.SenderId, lastChat.NickName) + local content = lastChat.Content + if lastChat.MsgType == ChatMsgType.System then + content = string.format("%s:%s", CS.XTextManager.GetText("GuildChannelTypeAll"), lastChat.Content) + self.TxtMessageContent.text = content + else + content = lastChat.Content + if lastChat.MsgType == ChatMsgType.Emoji then + content = CS.XTextManager.GetText("GuildEmojiReplace") + end + self.TxtMessageContent.text = string.format("%s:%s", nameRemark, content) + end + + if XUiHelper.CalcTextWidth(self.TxtMessageContent) > MAX_CHAT_WIDTH then + self.TxtMessageContent.text = string.Utf8Sub(self.TxtMessageContent.text, 1, CHAT_SUB_LENGTH) .. [[...]] + end +end + +-- 活跃度礼包 +function XUiGuildMain:SetActiveGift() + local giftContribute = XDataCenter.GuildManager.GetGiftContribute() + local giftGuildLevel = XDataCenter.GuildManager.GetGiftGuildLevel() + + self.AllBoxesConfig = XGuildConfig.GetGuildGiftByGuildLevel(giftGuildLevel) + if not self.AllBoxesConfig then return end + self.MaxContribute = 0 + for _, v in pairs(self.AllBoxesConfig) do + if v.GiftContribute > self.MaxContribute then + self.MaxContribute = v.GiftContribute + end + end + + for i = 1, #self.AllBoxesConfig do + if not self.GiftBoxes[i] then + local ui = CS.UnityEngine.Object.Instantiate(self.PanelActive) + local grid = XUiGridGuildBoxItem.New(ui, self) + grid.Transform:SetParent(self.PanelGift, false) + self.GiftBoxes[i] = grid + end + self.GiftBoxes[i].GameObject:SetActiveEx(true) + self.GiftBoxes[i]:RefreshGift(self.AllBoxesConfig[i], i, self.MaxContribute) + end + for i = #self.AllBoxesConfig + 1, #self.GiftBoxes do + self.GiftBoxes[i].GameObject:SetActiveEx(false) + end + self.TxtDailyActive.text = giftContribute + if self.MaxContribute > 0 then + self.ImgDaylyActiveProgress.fillAmount = giftContribute * 1.0 / self.MaxContribute + end +end + +-- 公会人数 +function XUiGuildMain:UpdateGuildMemberCount() + local curCount = XDataCenter.GuildManager.GetOnlineMemberCount() + --local maxCount = XDataCenter.GuildManager.GetMemberMaxCount() + self.BtnTabMember:SetNameByGroup(1, CSXTextManagerGetText("GuildMemberOnlineCount", curCount)) +end + +function XUiGuildMain:HasModifyAccess() + if not XDataCenter.GuildManager.IsGuildAdminister() then + XUiManager.TipMsg(CS.XTextManager.GetText("GuildNotAdministor")) + return true + end + return false +end + +function XUiGuildMain:ChecKickOut() + if not XDataCenter.GuildManager.IsJoinGuild() then + XUiManager.TipMsg(CS.XTextManager.GetText("GuildKickOutByAdministor")) + self:Close() + return true + end + return false +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuild/XUiGuildNews.lua b/Resources/Scripts/XUi/XUiGuild/XUiGuildNews.lua new file mode 100644 index 00000000..3b51478b --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiGuildNews.lua @@ -0,0 +1,54 @@ +local XUiGuildNews = XLuaUiManager.Register(XLuaUi, "UiGuildNews") +local XUiGridNewsItem = require("XUi/XUiGuild/XUiChildItem/XUiGridNewsItem") + +function XUiGuildNews:OnAwake() + self.BtnClose.CallBack = function() self:OnBtnBackClick() end + self.BtnTanchuangClose.CallBack = function() self:OnBtnBackClick() end + self:InitList() +end + +function XUiGuildNews:OnEnable() + self:OnRefresh() +end + +function XUiGuildNews:InitList() + self.DynamicTable = XDynamicTableNormal.New(self.PanelTreasureGrade) + self.DynamicTable:SetProxy(XUiGridNewsItem) + self.DynamicTable:SetDelegate(self) +end + +function XUiGuildNews:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.ListData[index] + if not data then + return + end + grid:OnRefresh(data) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + -- grid:CurStatus() + end +end + +function XUiGuildNews:OnDisable() +end + +function XUiGuildNews:OnBtnBackClick() + self:Close() +end + +-- 更新数据 +function XUiGuildNews:OnRefresh() + self.ListData = XDataCenter.GuildManager.GetGuildListRecruitDatas() or {} + if next(self.ListData) == nil then + self.DynamicTable:SetDataSource({}) + self.DynamicTable:ReloadDataASync(1) + self.TxtNoNew.gameObject:SetActiveEx(true) + return + end + + self.TxtNoNew.gameObject:SetActiveEx(false) + self.DynamicTable:SetDataSource(self.ListData) + self.DynamicTable:ReloadDataASync(1) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuild/XUiGuildPanelWelfare.lua b/Resources/Scripts/XUi/XUiGuild/XUiGuildPanelWelfare.lua new file mode 100644 index 00000000..5928d328 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiGuildPanelWelfare.lua @@ -0,0 +1,32 @@ +local XUiGuildPanelWelfare = XLuaUiManager.Register(XLuaUi, "UiGuildPanelWelfare") +local XUiGridWelfareItem = require("XUi/XUiGuild/XUiChildItem/XUiGridWelfareItem") + + +function XUiGuildPanelWelfare:OnAwake() + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self:BindHelpBtn(self.BtnHelp, "GuildWelfareHelp") + self.WelfareItemList = {} +end + +function XUiGuildPanelWelfare:OnStart() + self.WelfareConf = XGuildConfig.GetGuildWelfares() + for _, config in pairs(self.WelfareConf or {}) do + local ui = self[string.format("GridWelfareItem%d", config.Id)] + self.WelfareItemList[config.Id] = XUiGridWelfareItem.New(ui) + self.WelfareItemList[config.Id]:Init(self) + self.WelfareItemList[config.Id]:Refresh(config) + end +end + +function XUiGuildPanelWelfare:OnDestroy() +end + +function XUiGuildPanelWelfare:OnBtnBackClick() + self:Close() +end + +function XUiGuildPanelWelfare:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuild/XUiGuildPerson.lua b/Resources/Scripts/XUi/XUiGuild/XUiGuildPerson.lua new file mode 100644 index 00000000..d5512689 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiGuildPerson.lua @@ -0,0 +1,149 @@ +local XUiGuildPerson = XLuaUiManager.Register(XLuaUi, "UiGuildPerson") +local XUiGridGuildGiftItem = require("XUi/XUiGuild/XUiChildItem/XUiGridGuildGiftItem") +local XUiGuildViewCharacterFilter = require("XUi/XUiGuild/XUiChildView/XUiGuildViewCharacterFilter") +local TextManager = CS.XTextManager +function XUiGuildPerson:OnAwake() + self.ListData = {} + self.CurRecordIds = {} + self:Init() +end + +function XUiGuildPerson:OnStart() +end + +function XUiGuildPerson:OnEnable() + self.CurIdCount = 0 + self:OnRefresh() +end + + +function XUiGuildPerson:OnDisable() + self.CurRecordIds = {} + self.IsAllRecord = false +end + +function XUiGuildPerson:OnDestroy() +end + +function XUiGuildPerson:OnRefresh() + self:OnRefreshListData() + self:SetCurGiftName() +end + +function XUiGuildPerson:Init() + self:InitList() + self:InitFun() + self.UiGuildViewCharacterFilter = XUiGuildViewCharacterFilter.New(self.PanelCharacterFiltrate,self) + local text = TextManager.GetText("GuildGiftBtnDes") + self.BtnFilter:SetNameByGroup(0,text) + self.TxtNone.text = TextManager.GetText("GuildGiftEmptyDes") + self.TotalReqcount = XGuildConfig.GetGuildWishMaxCountByLevel(XDataCenter.GuildManager.GetGuildLevel()) + self:SetCurGiftReqCount() +end + +function XUiGuildPerson:InitList() + self.DynamicShopTable = XDynamicTableNormal.New(self.PanelList) + self.DynamicShopTable:SetProxy(XUiGridGuildGiftItem) + self.DynamicShopTable:SetDelegate(self) +end + +-- 设置当前角色礼物请求数 +function XUiGuildPerson:SetCurGiftReqCount() + local curcount = XDataCenter.GuildManager.GetCurWishReqCount() + self.RequestCountTxt.text = TextManager.GetText("GuildGiftReqTxtDes",curcount,self.TotalReqcount) +end + +-- 设置当前角色礼物对应名字 +function XUiGuildPerson:SetCurGiftName() + if next(self.CurRecordIds) and self.CurIdCount == 1 then + self.ShowScreen.gameObject:SetActiveEx(true) + local name = XCharacterConfigs.GetCharacterName(self.CurSeleId) + self.TxtName.text = TextManager.GetText("GuildGiftNameDes",name) + else + self.ShowScreen.gameObject:SetActiveEx(false) + end +end + +function XUiGuildPerson:OnRefreshListData() + if next(self.CurRecordIds) and not self.IsAllRecord then + self.ListData = {} + local dic = {} + for _,charId in pairs(self.CurRecordIds)do + local d = XGuildConfig.GetTrustItemsByCharacterId(charId) or {} + if next(d) then + for _,id in pairs(d)do + dic[id] = id + end + end + end + for _,itemid in pairs(dic)do + table.insert( self.ListData, {Id = itemid}) + end + + for index,v in pairs(self.ListData)do + if self.CurRecordIds[v.Id] then + table.remove(self.ListData, index) + end + end + else + self.ListData = XGuildConfig.GetGuildTrustItemsList() or {} + end + + + self.DynamicShopTable:SetDataSource(self.ListData) + self.DynamicShopTable:ReloadDataASync() + local flag = #self.ListData <= 0 + self.ImgNonePerson.gameObject:SetActiveEx(flag) +end + +function XUiGuildPerson:InitFun() + self.BtnTanchuangClose.CallBack = function() self:OnBtnTanchuangClose() end + self.BtnFilter.CallBack = function() self:OnBtnFilter() end +end + +function XUiGuildPerson:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:OnRefresh(self.ListData[index]) + -- elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + end +end + +function XUiGuildPerson:OnBtnAll() + for gridIndex,griddata in pairs(self.ListData)do + local grid = self.DynamicShopTable:GetGridByIndex(gridIndex) + if grid then + grid:SetSeleStatus(true) + end + griddata.Status = true + end +end + +function XUiGuildPerson:OnBtnTanchuangClose() + self:Close() +end + +function XUiGuildPerson:OnBtnFilter() + self.PanelRewards.gameObject:SetActiveEx(false) + self.UiGuildViewCharacterFilter:OnEnable() +end + +function XUiGuildPerson:RecordSeleId(id) + if id and not self.CurRecordIds[id] then + self.CurSeleId = id + self.CurRecordIds[id] = id + self.CurIdCount = self.CurIdCount + 1 + end +end + +function XUiGuildPerson:RemoveRecordSeleId(id) + if id and self.CurRecordIds[id] then + self.CurRecordIds[id] = nil + self.CurIdCount = self.CurIdCount - 1 + end +end + +function XUiGuildPerson:AllRecordSeleId() + self.IsAllRecord = true +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuild/XUiGuildRankingList.lua b/Resources/Scripts/XUi/XUiGuild/XUiGuildRankingList.lua new file mode 100644 index 00000000..053ca78b --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiGuildRankingList.lua @@ -0,0 +1,190 @@ +-- 公会详情界面 +local XUiGuildRankingList = XLuaUiManager.Register(XLuaUi, "UiGuildRankingList") +local XUiGridRankItem = require("XUi/XUiGuild/XUiChildItem/XUiGridRankItem") +local TextManager = CS.XTextManager + +function XUiGuildRankingList:OnAwake() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + self.BtnHelp.CallBack = function() self:OnBtnHelpClick() end + self.BtnGuildRankYouku.CallBack = function() self:OnBtnGuildRankYoukuClick() end + self.BtnGuildRankShenqing.CallBack = function() self:OnBtnGuildRankShenqingClick() end + self:InitList() +end + +function XUiGuildRankingList:OnStart(guildId) + self.CurGuild = guildId + self:OnRefresh() +end + +function XUiGuildRankingList:OnEnable() + if XDataCenter.GuildManager.IsGuildTourist() then + self.BtnGuildRankShenqing.gameObject:SetActiveEx(true) + elseif XDataCenter.GuildManager.IsJoinGuild() then + self.BtnGuildRankShenqing.gameObject:SetActiveEx(false) + else + self.BtnGuildRankShenqing.gameObject:SetActiveEx(true) + end + self.BtnGuildRankYouku.gameObject:SetActiveEx(false) + -- XEventManager.AddEventListener(XEventId.EVENT_GUILD_NOTICE, self.UpdateGuildInfo, self) +end + +function XUiGuildRankingList:OnDisable() + -- XEventManager.RemoveEventListener(XEventId.EVENT_GUILD_NOTICE, self.UpdateGuildInfo, self) +end + +function XUiGuildRankingList:UpdateGuildInfo() + -- XDataCenter.GuildManager.GetGuildDetails(0, function() + -- XLuaUiManager.Open("UiGuildMain") + -- end) +end + +function XUiGuildRankingList:SetVistorCount() + local cur = self.GuildInfo.GuildTouristCount + local total = self.GuildInfo.GuildTouristMaxCount + local str = CS.XTextManager.GetText("GuildVistorModeDes", cur,total) + self.BtnGuildRankYouku:SetNameByGroup(0, str) +end + +function XUiGuildRankingList:InitList() + self.DynamicTable = XDynamicTableNormal.New(self.MemberRankList) + self.DynamicTable:SetProxy(XUiGridRankItem) + self.DynamicTable:SetDelegate(self) +end + +-- 更新数据 +function XUiGuildRankingList:OnRefresh() + self.GuildInfo = XDataCenter.GuildManager.GetVistorGuildDetailsById(self.CurGuild) + local path = XGuildConfig.GetGuildHeadPortraitIconById(self.GuildInfo.GuildIconId) + self.RImgGuildIcon:SetRawImage(path) + self.TxtGuildName.text = self.GuildInfo.GuildName + self.TxtGuildLevel.text = self.GuildInfo.GuildLevel + self.TxtGuildLeaderName.text = self.GuildInfo.GuildLeaderName + self.TxtContributionNumber.text = self.GuildInfo.GuildContributeIn7Days + self.TxtNoticeText.text = self.GuildInfo.GuildDeclaration + --人数 + self.TxtGuildNumber.text = CS.XTextManager.GetText("GuildPersonCountDes", self.GuildInfo.GuildMemberCount,self.GuildInfo.GuildMemberMaxCount) + self:SetVistorCount() + self:OnRefreshList() +end + +function XUiGuildRankingList:GetRankName(rankLevel) + if not self.GuildInfo or not self.GuildInfo.DecodeRankNames then return "" end + local rankName = self.GuildInfo.DecodeRankNames[rankLevel] + if rankName == nil or rankName == "" then + local rankTemplate = XGuildConfig.GetGuildPositionById(rankLevel) + if rankTemplate then + return rankTemplate.Name + end + return "" + else + return rankName + end +end + +-- 更新列表 +function XUiGuildRankingList:OnRefreshList() + local data = XDataCenter.GuildManager.GetVistorMemberList(self.CurGuild) or {} + self.ListData = {} + if next(data) then + for _,v in pairs(data) do + table.insert(self.ListData, v) + end + self:SortMemberList() + self.DynamicTable:SetDataSource(self.ListData) + self.DynamicTable:ReloadDataASync() + else + XDataCenter.GuildManager.GetVistorGuildMembers(self.CurGuild,function() + data = XDataCenter.GuildManager.GetVistorMemberList(self.CurGuild) or {} + for _,v in pairs(data) do + table.insert(self.ListData, v) + end + self:SortMemberList() + self.DynamicTable:SetDataSource(self.ListData) + self.DynamicTable:ReloadDataASync() + end) + end +end + +function XUiGuildRankingList:SortMemberList() + table.sort(self.ListData, function(memberA, memberB) + if memberA.RankLevel == memberB.RankLevel then + if memberA.OnlineFlag == memberB.OnlineFlag then + if memberA.ContributeIn7Days == memberB.ContributeIn7Days then + return memberA.Level > memberB.Level + end + return memberA.ContributeIn7Days > memberB.ContributeIn7Days + end + return memberA.OnlineFlag > memberB.OnlineFlag + end + return memberA.RankLevel < memberB.RankLevel + end) +end + +function XUiGuildRankingList:OnBtnBackClick() + self:Close() +end + +function XUiGuildRankingList:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiGuildRankingList:OnBtnHelpClick() + XUiManager.UiFubenDialogTip("", TextManager.GetText("GuildDetailsDes") or "") +end + +function XUiGuildRankingList:OnBtnGuildRankYoukuClick() + if XDataCenter.GuildManager.IsGuildTourist() then + XUiManager.TipText("GuildNowVistorModeTips") + return + end + local curguildId = self.CurGuild + if XDataCenter.GuildManager.IsFullGuildVistor(curguildId) then + local text = TextManager.GetText("GuildFullVistorGuildDes") + XUiManager.TipMsg(text, XUiManager.UiTipType.Wrong) + return + end + + + XDataCenter.GuildManager.GuildTouristRequest(self.CurGuild,function () + XLuaUiManager.Open("UiGuildVistor") + self:Close() + end) +end + +function XUiGuildRankingList:OnBtnGuildRankShenqingClick() + local guidId = self.CurGuild + if XDataCenter.GuildManager.IsFullGuild(guidId) then + local text = TextManager.GetText("GuildFullVistorGuildDes") + XUiManager.TipMsg(text, XUiManager.UiTipType.Wrong) + return + end + + XDataCenter.GuildManager.ApplyToJoinGuildRequest(guidId,function() + XUiManager.TipText("GuildApplyRequestSuccess") + end) +end + +function XUiGuildRankingList:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.ListData[index] + if not data then + return + end + grid:OnRefresh(data) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + self:OnMemberItemClick(index) + end +end + +function XUiGuildRankingList:OnMemberItemClick(index) + local data = self.ListData[index] + if not data then return end + + if data.Id ~= XPlayer.Id then + XDataCenter.PersonalInfoManager.ReqShowInfoPanel(data.Id) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuild/XUiGuildRankingListSwitch.lua b/Resources/Scripts/XUi/XUiGuild/XUiGuildRankingListSwitch.lua new file mode 100644 index 00000000..fea90088 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiGuildRankingListSwitch.lua @@ -0,0 +1,291 @@ +-- 公会排行榜界面 +local XUiGuildRankingListSwitch = XLuaUiManager.Register(XLuaUi, "UiGuildRankingListSwitch") +local XUiGridRankingListSwitchItem = require("XUi/XUiGuild/XUiChildItem/XUiGridRankingListSwitchItem") +local TextManager = CS.XTextManager +local Dropdown = CS.UnityEngine.UI.Dropdown +local GuildSortConfig = {} +local LastReqTime = {} + +function XUiGuildRankingListSwitch:OnAwake() + self:InitEvent() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, + XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + local optionsDataList = Dropdown.OptionDataList() + + local optionContribute = Dropdown.OptionData() + optionsDataList.options:Add(optionContribute) + optionContribute.text = CS.XTextManager.GetText("GuildSortByContribute") + + local optionLevel = Dropdown.OptionData() + optionsDataList.options:Add(optionLevel) + optionLevel.text = CS.XTextManager.GetText("GuildSortByLevel") + + self.DrdSort:AddOptions(optionsDataList.options) + + GuildSortConfig[0] = XGuildConfig.GuildSortType.SortByContribute + GuildSortConfig[1] = XGuildConfig.GuildSortType.SortByLevel + LastReqTime[XGuildConfig.GuildSortType.SortByContribute] = 0 + LastReqTime[XGuildConfig.GuildSortType.SortByLevel] = 0 + + self.CurSortIndex = 0 + self:InitList() +end + +function XUiGuildRankingListSwitch:InitEvent() + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + self:BindHelpBtn(self.BtnHelp, "GuildRecommendHelp") + -- 右侧公会的查看详情按钮 + self.BtnGuildRankYouku.CallBack = function() self:OnBtnGuildRankYoukuClick() end + self.BtnGuildRankShenqing.CallBack = function() self:OnBtnGuildRankShenqingClick() end + + self.DrdSort.onValueChanged:AddListener(function(index) + if self.CurSortIndex == index then + return + end + self.CurSortIndex = index + self:RefreshSelectedPanel(self.CurSortIndex) + end) +end + +function XUiGuildRankingListSwitch:InitList() + self.DynamicTable = XDynamicTableNormal.New(self.MemberRankList) + self.DynamicTable:SetProxy(XUiGridRankingListSwitchItem) + self.DynamicTable:SetDelegate(self) +end + +function XUiGuildRankingListSwitch:OnStart() + XDataCenter.GuildManager.GuildListRankRequest(XGuildConfig.GuildSortType.SortByContribute, function() + XDataCenter.GuildManager.SaveMyGuildCurRank(XGuildConfig.GuildSortType.SortByContribute) + self:OnRefreshList() + end) + + if not XDataCenter.GuildManager.IsJoinGuild() or XDataCenter.GuildManager.IsGuildTourist() then + self.BtnGuildRankShenqing.gameObject:SetActiveEx(true) + else + self.BtnGuildRankShenqing.gameObject:SetActiveEx(false) + end +end + +function XUiGuildRankingListSwitch:OnRefreshBaseData(guildId, rank, iconId) + self.CurGuildId = guildId + local data = XDataCenter.GuildManager.GetVistorGuildDetailsById(guildId) + if data then + -- 保持两边头像相同(采用排行榜数据) + data.GuildIconId = iconId or data.GuildIconId + self:OnSetRefreshInfo(data, rank) + else + XDataCenter.GuildManager.GetVistorGuildDetailsReq(guildId, function() + local guildData = XDataCenter.GuildManager.GetVistorGuildDetailsById(guildId) + -- 保持两边头像相同(采用排行榜数据) + if guildData and guildData.GuildIconId then + guildData.GuildIconId = iconId or guildData.GuildIconId + end + self:OnSetRefreshInfo(guildData, rank) + end) + end +end + +function XUiGuildRankingListSwitch:OnSetRefreshInfo(data, rank) + if self.ListData and #self.ListData > 0 then + for i = 1, #self.ListData do + local data = self.ListData[i] + data.IsSelect = rank == i + local grid = self.DynamicTable:GetGridByIndex(i) + if grid then + grid:SetSelect(data.IsSelect) + -- XLog.Warning("OnSetRefreshInfo", rank, i, data) + end + end + end + + if data then + --公会名字 + self.TxtGuildlName.text = data.GuildName + --公会等级 + self.TxtGuildLevel.text = data.GuildLevel + --会长名字 + self.TxtLeaderName.text = data.GuildLeaderName + --公告 + self.TxtNoticeText.text = data.GuildDeclaration + --公会头像 + local path = XGuildConfig.GetGuildHeadPortraitIconById(data.GuildIconId) + self.ImgIcon:SetRawImage(path) + end +end + +function XUiGuildRankingListSwitch:UpdateMyGuildView() + -- 右侧默认展示第一名信息 + local info = self.ListData[1] + if info and info.GuildId then + self:OnRefreshBaseData(info.GuildId, 1) + end + -- 底部 + local type = GuildSortConfig[self.CurSortIndex] + local isJoinGuild = XDataCenter.GuildManager.IsJoinGuild() + local guildId = XDataCenter.GuildManager.GetGuildId() + self.PanelMyRank.gameObject:SetActiveEx(isJoinGuild) + if isJoinGuild then + local curCount = XDataCenter.GuildManager.GetMemberCount() + local maxCount = XDataCenter.GuildManager.GetMemberMaxCount() + self.TxtRenShu.text = CS.XTextManager.GetText("GuildPersonCountDes", curCount, maxCount) + self.TxtGuildName.text = XDataCenter.GuildManager.GetGuildName() + --贡献 + if type == XGuildConfig.GuildSortType.SortByContribute then + self.TxtSevenDayScore.text = XDataCenter.GuildManager.GetGuildContributeIn7Days() + else + self.TxtSevenDayScore.text = XDataCenter.GuildManager.GetGuildLevel() + end + local scoreFromList = nil + for index, guildData in pairs(self.ListData) do + if guildData.GuildId == guildId then + scoreFromList = guildData.Score + end + end + -- 如果服务端有则优先用服务端的(分数) + if scoreFromList then + self.TxtSevenDayScore.text = scoreFromList + end + -- 排行 + local rank = XDataCenter.GuildManager.GetMyGuildRank(type) + if rank >= 1 then + self.TxtRankNormal.text = math.modf(rank) + self.TxtRankNormal.gameObject:SetActiveEx(true) + self.TxtNotRankNormal.gameObject:SetActiveEx(false) + elseif rank > 0 and rank < 1 then + local rankNum = rank * 100 + self.TxtRankNormal.text = string.format("%0.2f%%",rankNum ) + self.TxtRankNormal.gameObject:SetActiveEx(true) + self.TxtNotRankNormal.gameObject:SetActiveEx(false) + else + self.TxtRankNormal.gameObject:SetActiveEx(false) + self.TxtNotRankNormal.gameObject:SetActiveEx(true) + end + + -- 获取上次打开时的排行,与今日对比,决定是否显示以及显示百分比还是名次 + local lastRank = XDataCenter.GuildManager.GetMyGuildLastRank(type) or 0 + --XLog.Warning("type:"..type.." lastRank:"..lastRank.." rank:"..rank) + if lastRank >= 1 and rank >= 1 then + local deltaRank = lastRank - rank + if deltaRank <= 0 then + self.PanelUp.gameObject:SetActiveEx(false) + else + self.PanelUp.gameObject:SetActiveEx(true) + self.TxtUp.text = deltaRank + self.TxtUp.text = string.format("%d",deltaRank ) + end + elseif rank > 0 and rank < 1 and lastRank > 0 and lastRank < 1 then + local deltaRank = lastRank - rank + if deltaRank <= 0 then + self.PanelUp.gameObject:SetActiveEx(false) + else + self.PanelUp.gameObject:SetActiveEx(true) + self.TxtUp.text = string.format("%.2f%%",deltaRank * 100 ) + end + else + self.PanelUp.gameObject:SetActiveEx(false) + end + end +end + +function XUiGuildRankingListSwitch:OnClickItemRefreshInfo(data, rank) + if data and data.GuildId then + self:OnRefreshBaseData(data.GuildId, rank, data.IconId) + end +end + +function XUiGuildRankingListSwitch:RefreshSelectedPanel(index) + -- 重新请求,超时的时候 + local type = GuildSortConfig[index] + local lastReqTime = LastReqTime[type] + local now = XTime.GetServerNowTimestamp() + if now - lastReqTime > XGuildConfig.GuildRequestRankTime then + -- 重新请求 + XDataCenter.GuildManager.GuildListRankRequest(type, function() + self.ListData = XDataCenter.GuildManager.GetListRankDatas(type) or {} + self:CheckNoneRank() + self.DynamicTable:SetDataSource(self.ListData) + self.DynamicTable:ReloadDataASync() + XDataCenter.GuildManager.SaveMyGuildCurRank(type) + self:UpdateMyGuildView() + end) + else + self.ListData = XDataCenter.GuildManager.GetListRankDatas(type) or {} + self:CheckNoneRank() + self.DynamicTable:SetDataSource(self.ListData) + self.DynamicTable:ReloadDataASync() + self:UpdateMyGuildView() + end + self.TxtMyTitleScore.text = XGuildConfig.GuildSortName[type] +end + +-- 更新列表 +function XUiGuildRankingListSwitch:OnRefreshList() + local type = GuildSortConfig[self.CurSortIndex] + self.ListData = XDataCenter.GuildManager.GetListRankDatas(type) or {} + self.TxtMyTitleScore.text = XGuildConfig.GuildSortName[type] + for k, v in pairs(self.ListData) do + v.IsSelect = false + end + self:CheckNoneRank() + self.DynamicTable:SetDataSource(self.ListData) + self.DynamicTable:ReloadDataASync() + self:UpdateMyGuildView() + if not next(self.ListData) then + self.GuildInformation.gameObject:SetActiveEx(false) + else + self.GuildInformation.gameObject:SetActiveEx(true) + end +end + +function XUiGuildRankingListSwitch:CheckNoneRank() + local isEmpty = #self.ListData <= 0 + if self.ImgEmpty then + self.ImgEmpty.gameObject:SetActiveEx(isEmpty) + end + if self.NotEmpty then + self.NotEmpty.gameObject:SetActiveEx(not isEmpty) + end +end + +function XUiGuildRankingListSwitch:OnBtnBackClick() + self:Close() +end + +function XUiGuildRankingListSwitch:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiGuildRankingListSwitch:OnBtnGuildRankYoukuClick() + XDataCenter.GuildManager.GetVistorGuildDetailsReq(self.CurGuildId, function() + XLuaUiManager.Open("UiGuildRankingList", self.CurGuildId) + self:Close() + end) +end + +function XUiGuildRankingListSwitch:OnBtnGuildRankShenqingClick() + local guidId = self.CurGuildId + if XDataCenter.GuildManager.IsFullGuild(guidId) then + local text = TextManager.GetText("GuildFullVistorGuildDes") + XUiManager.TipMsg(text, XUiManager.UiTipType.Wrong) + return + end + + XDataCenter.GuildManager.ApplyToJoinGuildRequest(guidId, function() + XUiManager.TipText("GuildApplyRequestSuccess") + end) +end + +function XUiGuildRankingListSwitch:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self.UiRoot) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.ListData[index] + if not data then return end + grid:OnRefresh(data, index) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + local data = self.ListData[index] + if not data then return end + self:OnClickItemRefreshInfo(data, index) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuild/XUiGuildRecommendation.lua b/Resources/Scripts/XUi/XUiGuild/XUiGuildRecommendation.lua new file mode 100644 index 00000000..1e8979ea --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiGuildRecommendation.lua @@ -0,0 +1,287 @@ +local XUiGuildRecommendation = XLuaUiManager.Register(XLuaUi, "UiGuildRecommendation") +local XUiGridRecommendationItem = require("XUi/XUiGuild/XUiChildItem/XUiGridRecommendationItem") +local RefreshTime = 1000 +local Dropdown = CS.UnityEngine.UI.Dropdown +local GuildAllLevels +local GuildLevelConfig = {} +local ShowGuildRecommendHelp = "ShowGuildRecommendHelp" +local NowTime = XTime.GetServerNowTimestamp + +function XUiGuildRecommendation:OnAwake() + self.CurRecordIds = {} + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + GuildAllLevels = CS.XTextManager.GetText("GuildAllLevels") + self:InitList() + self:InitFun() +end + +function XUiGuildRecommendation:OnDestroy() + XDataCenter.GuildManager.ResetGuildRecommendDatas() +end + +function XUiGuildRecommendation:InitFun() + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + self.BtnRanking.CallBack = function() self:OnBtnRankingClick() end + self.BtnRefresh.CallBack = function() self:OnBtnRefreshClick() end + self.BtnSearchOffice.CallBack = function() self:OnBtnSearchOfficeClick() end + self.BtnEstablish.CallBack = function() self:OnBtnEstablishClick() end + self.BtnNews.CallBack = function() self:OnBtnNewsClick() end + self.BtnApply.CallBack = function() self:OnBtnApplyClick() end + self:BindHelpBtn(self.BtnHelp, "GuildRecommendHelp") + local optionsDataList = Dropdown.OptionDataList() + local optionDataContribute = Dropdown.OptionData() + GuildLevelConfig[0] = XGuildConfig.GuildSortType.SortByContribute + optionDataContribute.text = CS.XTextManager.GetText("GuildSortByContribute") + optionsDataList.options:Add(optionDataContribute) + + local optionLevel = Dropdown.OptionData() + GuildLevelConfig[1] = XGuildConfig.GuildSortType.SortByLevel + optionLevel.text = CS.XTextManager.GetText("GuildSortByLevel") + optionsDataList.options:Add(optionLevel) + self.DrdSort:AddOptions(optionsDataList.options) + self.DrdSort.onValueChanged:AddListener(function(index) + if self.CurIndex == index then + return + end + self.CurIndex = index + self:RefreshSelectedPanel(index) + end) + self.CurIndex = 0 + self.RefreshTimerCb = function() self:RefreshTimerFun() end + self:OnRefresh() + + XRedPointManager.AddRedPointEvent(self.RedNews, self.OnCheckGuildRecruitList, self, { XRedPointConditions.Types.CONDITION_GUILD_NEWS }) +end + +function XUiGuildRecommendation:OnCheckGuildRecruitList(count) + self.RedNews.gameObject:SetActiveEx(count >= 0) +end + +function XUiGuildRecommendation:InitList() + self.DynamicTable = XDynamicTableNormal.New(self.PanelList) + self.DynamicTable:SetProxy(XUiGridRecommendationItem) + self.DynamicTable:SetDelegate(self) +end + +function XUiGuildRecommendation:OnStart() + self.CooldownTimeStamp = XDataCenter.GuildManager.GetGuildJoinCdEnd() + self:UpdateCoolDownTimer() + self.FirstRefresh = true + --首次进入展示帮助 + if not XSaveTool.GetData(ShowGuildRecommendHelp) then + XSaveTool.SaveData(ShowGuildRecommendHelp, true) + XUiManager.ShowHelpTip("GuildRecommendHelp") + end +end + +function XUiGuildRecommendation:OnEnable() + self.CoolDownTimeScheduleId = XScheduleManager.ScheduleForever(function() + self:UpdateCoolDownTimer() + end, 1000) +end + +function XUiGuildRecommendation:OnDisable() + self:UnScheduleCoolDownTime() + self.CurRecordIds = {} + XDataCenter.GuildManager.RecordGuildRecommend(-1) +end + +function XUiGuildRecommendation:OnBtnBackClick() + self:Close() +end + +function XUiGuildRecommendation:OnBtnApplyClick() + -- 如果已经加入公会 + if XDataCenter.GuildManager.IsJoinGuild() then + XUiManager.TipMsg(CS.XTextManager.GetText("GuildAlreadyInGuild")) + return + end + + if self.RemainTime > 0 then + XUiManager.TipCode(XCode.GuildApplyInCd) + return + end + + for _, item in pairs(self.DynamicTable:GetGrids())do + if item and item.ItemData then + XDataCenter.GuildManager.ApplyToJoinGuildRequest(item.ItemData.GuildId, function() + item:SetApplyTag(true) + end) + end + end + + XUiManager.TipText("GuildApplyRequestSuccess") +end + +function XUiGuildRecommendation:RecordSeleId(id) + if id then + self.CurRecordIds[id] = id + end +end + +function XUiGuildRecommendation:RemoveRecordSeleId(id) + if id and self.CurRecordIds[id] then + self.CurRecordIds[id] = nil + end +end +function XUiGuildRecommendation:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiGuildRecommendation:OnBtnRankingClick() + XDataCenter.GuildManager.GuildListRankRequest(XGuildConfig.GuildSortType.SortByContribute, function() + XLuaUiManager.Open("UiGuildRankingListSwitch") + end) +end + +function XUiGuildRecommendation:OnBtnRefreshClick() + if self.FirstRefresh then + XDataCenter.GuildManager.ResetPreRequestRecommendTime() + self.FirstRefresh = false + end + if not XDataCenter.GuildManager.IsNeedRequestRecommendData() then + XUiManager.TipMsg(CS.XTextManager.GetText("GuildRecommendInCd")) + return + end + + self.CurPage = self.CurPage + 1 + local data = XDataCenter.GuildManager.GetGuildRecommendDatas(self.CurPage) + if not data or not next(data) then + self.CurPage = 1 + data = XDataCenter.GuildManager.GetGuildRecommendDatas(self.CurPage) + end + self.ListData = data + self.RawListData = self.ListData + self.CurDataLen = #self.ListData + self:RefreshItems(self.CurIndex) + +end + +function XUiGuildRecommendation:RefreshTimerFun() + self.IsDelayIng = false + XScheduleManager.UnSchedule(self.RefreshTimer) +end + +function XUiGuildRecommendation:OnBtnSearchOfficeClick() + if self.CurRefreshIndex == self.CurIndex then + if self.IsDelayIng then + return + end + end + + self.RefreshTimer = XScheduleManager.ScheduleOnce(self.RefreshTimerCb,RefreshTime) + self.IsDelayIng = true + local str = self.InputField.text + if str == "" then + XUiManager.TipText("GuildRecommErrorTipsDes",XUiManager.UiTipType.Wrong) + return + end + self.CurRefreshIndex = self.CurIndex + XDataCenter.GuildManager.GuildFind(str,function() + local datas = XDataCenter.GuildManager.GetGuildFindDatas(str) + if #datas <= 0 then + XUiManager.TipMsg(CS.XTextManager.GetText("GuildSearchGuildNotFound")) + end + self.ListData = datas + self.DynamicTable:SetDataSource(datas) + self.DynamicTable:ReloadDataASync(1) + end) +end + +function XUiGuildRecommendation:OnBtnEstablishClick() + XLuaUiManager.Open("UiGuildBuild") +end + +function XUiGuildRecommendation:OnBtnNewsClick() + XDataCenter.GuildManager.ResetGuildRecruit() + XDataCenter.GuildManager.GuildListRecruitRequest(function() + XLuaUiManager.Open("UiGuildNews") + end) +end + +function XUiGuildRecommendation:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.ListData[index] + if not data then + return + end + grid:OnRefresh(data) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + grid:OnClickStatus() + local data = self.ListData[index] + XDataCenter.GuildManager.GetVistorGuildDetailsReq(data.GuildId,function () + XLuaUiManager.Open("UiGuildRankingList",data.GuildId) + end) + end +end + +function XUiGuildRecommendation:RefreshSelectedPanel(index) + self:RefreshItems(index) +end +function XUiGuildRecommendation:RefreshItems(index) + local type = GuildLevelConfig[index] + self:FiltrateListData(type) +end + +function XUiGuildRecommendation:FiltrateListData(type) + + if type == XGuildConfig.GuildSortType.SortByContribute then + table.sort(self.RawListData, function(raw1, raw2) + if raw1.ContributeIn7Days == raw2.ContributeIn7Days then + if raw1.Level == raw2.Level then + return raw1.Id < raw2.Id + end + return raw1.Level > raw2.Level + end + return raw1.ContributeIn7Days > raw2.ContributeIn7Days + end) + end + + if type == XGuildConfig.GuildSortType.SortByLevel then + table.sort(self.RawListData, function(raw1, raw2) + if raw1.Level == raw2.Level then + if raw1.ContributeIn7Days == raw2.ContributeIn7Days then + return raw1.Id < raw2.Id + end + return raw1.ContributeIn7Days > raw2.ContributeIn7Days + end + return raw1.Level > raw2.Level + end) + end + + self.ListData = self.RawListData + self.DynamicTable:Clear() + self.DynamicTable:SetDataSource(self.ListData) + self.DynamicTable:ReloadDataASync() +end + +-- 更新数据 +function XUiGuildRecommendation:OnRefresh() + self.CurPage = 1 + self.ListData = XDataCenter.GuildManager.GetGuildRecommendDatas(self.CurPage) + self.RawListData = self.ListData + self.CurDataLen = #self.ListData + self:RefreshSelectedPanel(self.CurIndex or 0) +end + +--更新冷却时间 +function XUiGuildRecommendation:UpdateCoolDownTimer() + if XTool.UObjIsNil(self.TxtCoolDownTime) then return end + self.RemainTime = self.CooldownTimeStamp - NowTime() + if self.RemainTime <= 0 then + self:UnScheduleCoolDownTime() + end + self.PanelTimeCd.gameObject:SetActiveEx(self.RemainTime > 0) + self.TxtCoolDownTime.text = XUiHelper.GetTime(self.RemainTime, XUiHelper.TimeFormatType.GUILDCD) +end + + +function XUiGuildRecommendation:UnScheduleCoolDownTime() + if self.CoolDownTimeScheduleId then + XScheduleManager.UnSchedule(self.CoolDownTimeScheduleId) + self.CoolDownTimeScheduleId = nil + end +end diff --git a/Resources/Scripts/XUi/XUiGuild/XUiGuildRecruit.lua b/Resources/Scripts/XUi/XUiGuild/XUiGuildRecruit.lua new file mode 100644 index 00000000..3ebbc0a2 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiGuildRecruit.lua @@ -0,0 +1,59 @@ +local XUiGuildRecruit = XLuaUiManager.Register(XLuaUi, "UiGuildRecruit") +local XUiGuildEnlistRecruit = require("XUi/XUiGuild/XUiChildView/XUiGuildEnlistRecruit") +local XUiGuildEnlistNews = require("XUi/XUiGuild/XUiChildView/XUiGuildEnlistNews") + + +function XUiGuildRecruit:OnAwake() + self:InitTaskView() +end + +function XUiGuildRecruit:InitTaskView() + self.GuildAllEnlist = {} + self.GuildAllEnlist[XGuildConfig.EnlistType.Recruit] = XUiGuildEnlistRecruit.New(self.PanelRecruit, self) + self.GuildAllEnlist[XGuildConfig.EnlistType.News] = XUiGuildEnlistNews.New(self.PanelNews, self) + + self.BtnEnlistTabs = {} + table.insert(self.BtnEnlistTabs, self.BtnTabRecruit) + table.insert(self.BtnEnlistTabs, self.BtnTabNews) + + self.PanelTab:Init(self.BtnEnlistTabs, function(index) self:OnGuildTaskTabClick(index) end) + self.BtnTanchuangClose.CallBack = function() self:OnBtnCloseClick() end + XRedPointManager.AddRedPointEvent(self.Red, self.RefreshApplyList, self, { XRedPointConditions.Types.CONDITION_GUILD_APPLYLIST }) +end + +function XUiGuildRecruit:RefreshApplyList(count) + self.Red.gameObject:SetActiveEx(count >= 0) +end + +function XUiGuildRecruit:OnStart(defaultType) + self.PanelTab:SelectIndex(defaultType or XGuildConfig.EnlistType.News) +end + +function XUiGuildRecruit:OnDestroy() + +end + +function XUiGuildRecruit:OnGuildTaskTabClick(index) + if self.LastSelect and self.LastSelect == index then + return + end + self.LastSelect = index + self.PanelRecruit.gameObject:SetActiveEx(index == XGuildConfig.EnlistType.Recruit) + local isHandleApplyList = index == XGuildConfig.EnlistType.News + self.PanelNews.gameObject:SetActiveEx(isHandleApplyList) + + if self.GuildAllEnlist[index] then + self.GuildAllEnlist[index]:UpdateEnlists() + end + + if isHandleApplyList then + XDataCenter.GuildManager.ResetApplyMemberList() + end +end + +function XUiGuildRecruit:OnBtnCloseClick() + self:Close() +end + + + diff --git a/Resources/Scripts/XUi/XUiGuild/XUiGuildRongyu.lua b/Resources/Scripts/XUi/XUiGuild/XUiGuildRongyu.lua new file mode 100644 index 00000000..2b0c8696 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiGuildRongyu.lua @@ -0,0 +1,114 @@ +local XUiGuildRongyu = XLuaUiManager.Register(XLuaUi, "UiGuildRongyu") + +local XUiGuildViewMember = require("XUi/XUiGuild/XUiChildView/XUiGuildViewMember") +local XUiGuildMemberHornor = require("XUi/XUiGuild/XUiChildView/XUiGuildMemberHornor") + + +local MemberTypeHornor = 1 +local MemberTypeNormal = 2 + +function XUiGuildRongyu:OnAwake() + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + self:BindHelpBtn(self.BtnHelp, "GuildRongyuHelp") + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + + self.MemberView = {} + self.MemberView[MemberTypeHornor] = XUiGuildMemberHornor.New(self.PanelHornor, self) + self.MemberView[MemberTypeNormal] = XUiGuildViewMember.New(self.PanelMemberInfo, self) + + self.MemberTab = {} + self.MemberTab[MemberTypeHornor] = self.TogHornor + self.MemberTab[MemberTypeNormal] = self.TogMember + self.TabPanelGroup:Init(self.MemberTab, function(index) self:OnMemberTabClick(index) end) + + XEventManager.AddEventListener(XEventId.EVENT_GUILD_ALLRANKNAME_UPDATE, self.OnMemberInfoSync, self) + XEventManager.AddEventListener(XEventId.EVNET_GUILD_LEADER_CHANGED, self.OnMemberInfoSync, self) + XEventManager.AddEventListener(XEventId.EVENT_GUILD_UPDATE_MEMBER_INFO, self.OnMemberChangeSync, self) + XEventManager.AddEventListener(XEventId.EVENT_GUILD_LEADER_DISSMISS, self.OnLeaderDissmissChangeSync, self) + XEventManager.AddEventListener(XEventId.EVENT_GUILD_MEMBERCOUNT_CHANGED, self.OnMemberCountChanged, self) +end + +function XUiGuildRongyu:OnDestroy() + XEventManager.RemoveEventListener(XEventId.EVENT_GUILD_ALLRANKNAME_UPDATE, self.OnMemberInfoSync, self) + XEventManager.RemoveEventListener(XEventId.EVNET_GUILD_LEADER_CHANGED, self.OnMemberInfoSync, self) + XEventManager.RemoveEventListener(XEventId.EVENT_GUILD_UPDATE_MEMBER_INFO, self.OnMemberChangeSync, self) + XEventManager.RemoveEventListener(XEventId.EVENT_GUILD_LEADER_DISSMISS, self.OnLeaderDissmissChangeSync, self) + XEventManager.RemoveEventListener(XEventId.EVENT_GUILD_MEMBERCOUNT_CHANGED, self.OnMemberCountChanged, self) + if self.LastView then + self.LastView:OnDisable() + end +end + +function XUiGuildRongyu:OnStart(memberType) + self.TabPanelGroup:SelectIndex(memberType or MemberTypeHornor) + + self:OnMemberCountChanged() +end + +function XUiGuildRongyu:OnEnable() -- 解决修改玩家职位返回后不刷新问题(海外) + if self.CurrentView then + self.CurrentView:OnEnable() + end +end + +function XUiGuildRongyu:OnMemberCountChanged() + local curCount = XDataCenter.GuildManager.GetMemberCount() + local onlineCount = XDataCenter.GuildManager.GetOnlineMemberCount() + local maxCount = XDataCenter.GuildManager.GetMemberMaxCount() + self.TogMember:SetNameByGroup(1, string.format("%d/%d", curCount, maxCount)) + self.TxtOnlineMember.text = string.format("%d", onlineCount) +end + +function XUiGuildRongyu:OnMemberTabClick(index) + if self.LastView then + if self.LastView == self.MemberView[index] then return end + self.LastView:OnDisable() + self.LastView = nil + end + if self.MemberView[index] then + self.MemberView[index]:OnEnable() + self.LastView = self.MemberView[index] + self.CurrentView = self.MemberView[index] -- 解决修改玩家职位返回后不刷新问题(海外) + end +end + +-- 人气值、自定义职位变化 +function XUiGuildRongyu:OnMemberInfoSync() + -- 荣誉室职位变化 + if self.MemberView[MemberTypeHornor] then + self.MemberView[MemberTypeHornor]:UpdateMemberInfo() + end + + -- 成员界面 + if self.MemberView[MemberTypeNormal] then + self.MemberView[MemberTypeNormal]:UpdateMemberJobInfo() + end +end + +-- 人数变化 +function XUiGuildRongyu:OnMemberChangeSync() + -- 荣誉室职位变化 + if self.MemberView[MemberTypeHornor] then + self.MemberView[MemberTypeHornor]:UpdateMemberInfo() + end + + -- 成员界面 + if self.MemberView[MemberTypeNormal] then + self.MemberView[MemberTypeNormal]:UpdateMemberInfo() + end +end + +function XUiGuildRongyu:OnLeaderDissmissChangeSync() + if self.MemberView[MemberTypeNormal] then + self.MemberView[MemberTypeNormal]:OnLeaderDissmissChange() + end +end + +function XUiGuildRongyu:OnBtnBackClick() + self:Close() +end + +function XUiGuildRongyu:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuild/XUiGuildShop.lua b/Resources/Scripts/XUi/XUiGuild/XUiGuildShop.lua new file mode 100644 index 00000000..cee5b241 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiGuildShop.lua @@ -0,0 +1,189 @@ +local XUiGuildShop = XLuaUiManager.Register(XLuaUi, "UiGuildShop") +local XUiGuildGridShop = require("XUi/XUiGuild/XUiChildItem/XUiGuildGridShop") + + +function XUiGuildShop:OnAwake() + self:InitChildView() + + + XEventManager.AddEventListener(XEventId.EVENT_GUILD_CONTRIBUTE_CHANGED, self.RefreshComsumeCoin, self) +end + +function XUiGuildShop:OnDestroy() + self:StopCountDown() + XEventManager.RemoveEventListener(XEventId.EVENT_GUILD_CONTRIBUTE_CHANGED, self.RefreshComsumeCoin, self) +end + +function XUiGuildShop:OnStart(shopId) + self.ShopItemList = XShopManager.GetShopGoodsList(shopId) + self.ShopId = shopId + + self:RefreshShopList() + self:RefreshComsumeCoin() + if self.ShopId == XGuildConfig.GuildPurchaseShop then + self.RImgConsume:SetRawImage(XDataCenter.ItemManager.GetItemIcon(XGuildConfig.GuildContributeCoin)) + self.TxtShopName.text = CS.XTextManager.GetText("GuildPurchaseShopTitle") + else + self.RImgConsume:SetRawImage(XDataCenter.ItemManager.GetItemIcon(XGuildConfig.GuildCoin)) + self.TxtShopName.text = CS.XTextManager.GetText("GuildNormalShopTitle") + end + self:StartCountDown() +end + +-- 花费的货币变化 +function XUiGuildShop:RefreshComsumeCoin() + if self.ShopId == XGuildConfig.GuildPurchaseShop then + self.TxtConsumeCoin.text = XDataCenter.GuildManager.GetGuildContributeLeft() + else + self.TxtConsumeCoin.text = XDataCenter.ItemManager.GetCount(XGuildConfig.GuildCoin) + end +end + +function XUiGuildShop:RefreshShopList() + self.DynamicShopTable:SetDataSource(self.ShopItemList) + self.DynamicShopTable:ReloadDataASync() +end + + +function XUiGuildShop:InitChildView() + self.BtnTanchuangClose.CallBack = function() self:OnBtnTanchuangClose() end + + self.DynamicShopTable = XDynamicTableNormal.New(self.PanelList.gameObject) + self.DynamicShopTable:SetProxy(XUiGuildGridShop) + self.DynamicShopTable:SetDelegate(self) + + XDataCenter.ItemManager.AddCountUpdateListener(XGuildConfig.GuildCoin, function() + self:RefreshComsumeCoin() + end, self.TxtConsumeCoin) +end + +function XUiGuildShop:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.ShopItemList[index] + if not data then return end + + grid:UpdateData(data) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + + local data = self.ShopItemList[index] + if not data then return end + + self:OnGridItemClick(data) + + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_RECYCLE then + grid:OnRecycle() + end +end + +function XUiGuildShop:OnGridItemClick(data) + local title = CS.XTextManager.GetText("GuildDialogTitle") + + local goodsParams = XGoodsCommonManager.GetGoodsShowParamsByTemplateId(data.RewardGoods.TemplateId) + local rewardName = goodsParams.Name + if goodsParams.RewardType == XArrangeConfigs.Types.Character then + rewardName = goodsParams.TradeName + end + + local consumeStr = "" + for _, consume in pairs(data.ConsumeList or {}) do + local consumeName = XDataCenter.ItemManager.GetItemName(consume.Id) + local consumeCount = consume.Count + local perConsume = string.format("%d%s", consumeCount, consumeName) + if consumeStr == "" then + consumeStr = perConsume + else + consumeStr = string.forma("%s,%s", consumeStr, perConsume) + end + end + local content = CS.XTextManager.GetText("GuildShopIsCostBuy", consumeStr, rewardName) + -- 次数是否足够 + local totalBuyTimes = data.TotalBuyTimes + local totalCanBuyTimes = data.RewardGoods.Count + if totalBuyTimes >= totalCanBuyTimes then + XUiManager.TipMsg(CS.XTextManager.GetText("GuildShopNotEnoughBuyCount")) + return + end + -- 购买材料是否足够 + for _, consume in pairs(data.ConsumeList or {}) do + if not XDataCenter.ItemManager.DoNotEnoughBuyAsset(consume.Id, consume.Count, 1, function() + self:OnGridItemClick(data) + end, "BuyNeedItemInsufficient") then + return + end + end + + local func = function() + XUiManager.TipText("BuySuccess") + XShopManager.GetShopInfo(self.ShopId, function() + self.ShopItemList = XShopManager.GetShopGoodsList(self.ShopId) + self:RefreshShopList() + end) + end + + local err_func = function() + XShopManager.GetShopInfo(self.ShopId, function() + self.ShopItemList = XShopManager.GetShopGoodsList(self.ShopId) + self:RefreshShopList() + self:RefreshComsumeCoin() + end) + end + + XUiManager.DialogTip(title, content, XUiManager.DialogType.Normal, function() + end, function() + -- 判断是否具有权限 + if not XDataCenter.GuildManager.CheckShopBuyAccess(self.ShopId) then + XUiManager.TipMsg(CS.XTextManager.GetText("GuildNotAdministor")) + self:Close() + return + end + + XShopManager.BuyShop(self.ShopId, data.Id, 1, func, err_func) + end) +end + +function XUiGuildShop:UpdateBuy() +end + +function XUiGuildShop:StartCountDown() + self:StopCountDown() + if not self.ShopId then return end + + local timeInfo = XShopManager.GetShopTimeInfo(self.ShopId) + if not timeInfo or not next(timeInfo) then + return + end + + local dataTime = XUiHelper.GetTime(timeInfo.RefreshLeftTime, XUiHelper.TimeFormatType.SHOP) + self.TextTime.text = dataTime + + self.CountTimer = XScheduleManager.ScheduleForever(function() + if timeInfo.RefreshLeftTime <= 0 then + self:StopCountDown() + XShopManager.GetShopInfo(self.ShopId, function() + self.ShopItemList = XShopManager.GetShopGoodsList(self.ShopId) + self:RefreshShopList() + self:StartCountDown() + end) + return + end + timeInfo.RefreshLeftTime = timeInfo.RefreshLeftTime - 1 + local tmpDataTime = XUiHelper.GetTime(timeInfo.RefreshLeftTime, XUiHelper.TimeFormatType.SHOP) + self.TextTime.text = tmpDataTime + + end, XScheduleManager.SECOND, 0) +end + +function XUiGuildShop:StopCountDown() + if self.CountTimer ~= nil then + XScheduleManager.UnSchedule(self.CountTimer) + self.CountTimer = nil + end +end + +function XUiGuildShop:OnBtnTanchuangClose() + self:Close() +end + + diff --git a/Resources/Scripts/XUi/XUiGuild/XUiGuildSkill.lua b/Resources/Scripts/XUi/XUiGuild/XUiGuildSkill.lua new file mode 100644 index 00000000..fda641c7 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiGuildSkill.lua @@ -0,0 +1,102 @@ +local XUiGuildSkill = XLuaUiManager.Register(XLuaUi, "UiGuildSkill") + +local XUiGridTalentItem = require("XUi/XUiGuild/XUiChildItem/XUiGridTalentItem") +local vectorOffset = CS.UnityEngine.Vector3.zero --(-2, 0, 0) +local ShowGuildTalentHelp = "ShowGuildTalentHelp" + +function XUiGuildSkill:OnAwake() + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + self:BindHelpBtn(self.BtnHelp, "GuildTalentHelp") + + self.TalentPointList = {} +end + +function XUiGuildSkill:OnGetEvents() + return { + XEventId.EVENT_GUILD_TALENT_ASYNC, + } +end + +function XUiGuildSkill:OnNotify(evt, ...) + if evt == XEventId.EVENT_GUILD_TALENT_ASYNC then + self:OnTalentAsync() + end +end + +function XUiGuildSkill:OnDestroy() + if self.DelayTimer then + XScheduleManager.UnSchedule(self.DelayTimer) + self.DelayTimer = nil + end +end + +function XUiGuildSkill:OnStart() + --首次进入展示帮助 + if not XSaveTool.GetData(ShowGuildTalentHelp) then + XSaveTool.SaveData(ShowGuildTalentHelp, true) + XUiManager.ShowHelpTip("GuildTalentHelp") + end + + -- PanelDrag + self.TalentPoints = XGuildConfig.GetSortedTalentPoints() + for i = 1, #self.TalentPoints do + local talentPoint = self.TalentPoints[i] + talentPoint.IsSelect = false + if not self.TalentPointList[i] then + local ui = self.LayerLevel:Find(string.format("%d", i)) + self.TalentPointList[i] = XUiGridTalentItem.New(ui, self) + end + self.TalentPointList[i]:Refresh(talentPoint) + end + + -- by default + -- if self.TalentPointList[1] then + -- self:FocusTargetDelay(self.TalentPointList[1].Transform) + -- end +end + +function XUiGuildSkill:OnTalentAsync() + if not self.TalentPoints or not self.TalentPointList then return end + if XDataCenter.GuildManager.CheckAllTalentLevelMax() then + XLuaUiManager.Close("UiGuildSkillDetail") + XLuaUiManager.PopThenOpen("UiGuildGloryLevel") + return + end + for i = 1, #self.TalentPoints do + local talentPoint = self.TalentPoints[i] + if self.TalentPointList[i] then + self.TalentPointList[i]:Refresh(talentPoint) + end + end +end + +function XUiGuildSkill:OnTalentPointSelect(indexInMap) + for i = 1, #self.TalentPointList do + if self.TalentPointList[i] and self.TalentPoints[i] then + local talentPoint = self.TalentPoints[i] + talentPoint.IsSelect = talentPoint.IndexInMap == indexInMap + self.TalentPointList[i]:SetSelect(talentPoint.IsSelect) + end + end +end + +function XUiGuildSkill:ResetTalentPointSelect() + self:OnTalentPointSelect(0) +end + +function XUiGuildSkill:FocusTargetDelay(transform) + self.DelayTimer = XScheduleManager.ScheduleOnce(function() + self.PanelDrag:FocusTarget(transform, 1, 1, vectorOffset, function() + XScheduleManager.UnSchedule(self.DelayTimer) + end) + end, 50) +end + +function XUiGuildSkill:OnBtnBackClick() + self:Close() +end + +function XUiGuildSkill:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuild/XUiGuildSkillDetail.lua b/Resources/Scripts/XUi/XUiGuild/XUiGuildSkillDetail.lua new file mode 100644 index 00000000..8811bffb --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiGuildSkillDetail.lua @@ -0,0 +1,110 @@ +local XUiGuildSkillDetail = XLuaUiManager.Register(XLuaUi, "UiGuildSkillDetail") +local blueColor = CS.UnityEngine.Color(59 / 255, 170 / 255, 1, 1) +local redColor = CS.UnityEngine.Color(1, 0, 0, 1) + +function XUiGuildSkillDetail:OnAwake() + -- PanelAsset + self.BtnLevelEnter.CallBack = function() self:OnBtnLevelClick() end + self.BtnMask.CallBack = function() self:OnBtnMaskClick() end + + self.GuildLevelCondition = XUiGridStageStar.New(self.GridStageStar1) + self.TalentParentConditoin = XUiGridStageStar.New(self.GridStageStar2) +end +function XUiGuildSkillDetail:OnGetEvents() + return { + XEventId.EVENT_GUILD_TALENT_ASYNC, + } +end + +function XUiGuildSkillDetail:OnNotify(evt, ...) + if evt == XEventId.EVENT_GUILD_TALENT_ASYNC then + self:RefreshTalent() + end +end + +function XUiGuildSkillDetail:OnStart(talentId, callback) + self.TalentId = talentId + self.OnCloseCallBack = callback + + self:RefreshTalent() +end + +function XUiGuildSkillDetail:RefreshTalent() + if not self.TalentId then return end + + self.TalentTemplate = XGuildConfig.GetGuildTalentById(self.TalentId) + self.TalentConfig = XGuildConfig.GetGuildTalentConfigById(self.TalentId) + + local curTalentLevel = XDataCenter.GuildManager.GetTalentLevel(self.TalentId) + local isCurMax = XDataCenter.GuildManager.IsTalentMaxLevel(self.TalentId) + local isCurUnlock = XDataCenter.GuildManager.IsTalentUnlock(self.TalentId) + + self.RImgSkillIcon:SetRawImage(self.TalentConfig.TalentIcon) + self.TxtSkillName.text = self.TalentConfig.Name + self.TxtSkillNum.text = string.format("%d/%d", curTalentLevel, #self.TalentTemplate.CostPoint) + + self.TxtCurLevel.text = curTalentLevel + self.TxtCurDescription.text = self.TalentConfig.Descriptions[curTalentLevel+1] + + self.PanelNextLevel.gameObject:SetActiveEx(not isCurMax) + if not isCurMax then + local nextLevel = curTalentLevel + 1 + self.TxtNextLevel.text = nextLevel + self.TxtNextDescription.text = self.TalentConfig.Descriptions[nextLevel + 1] + end + + self.PanelLevelBtnMax.gameObject:SetActiveEx(isCurMax) + self.PanelLevelBtnLock.gameObject:SetActiveEx(not isCurUnlock) + self.PanelLevelBtn.gameObject:SetActiveEx(not isCurMax and isCurUnlock) + self.PanelCondition.gameObject:SetActiveEx(not isCurMax) + self.UnlockTitle.gameObject:SetActiveEx(isCurUnlock) + self.LockTitle.gameObject:SetActiveEx(not isCurUnlock) + if not isCurMax then + self.RImgCostIcon:SetRawImage(XDataCenter.ItemManager.GetItemIcon(XGuildConfig.GuildTalent)) + local ownNum = XDataCenter.GuildManager.GetTalentPoint() + local needNum = self.TalentTemplate.CostPoint[curTalentLevel + 1] or 0 + self.TxtNeedNums.text = ownNum + self.TxtTotalNums.text = string.format("/%d", needNum) + local color = (ownNum >= needNum) and blueColor or redColor + self.TxtNeedNums.color = color + + self.GuildLevelCondition:Refresh(CS.XTextManager.GetText("GuildTalentConditionLevel", self.TalentTemplate.GuildLevel), isCurUnlock) + self.TalentParentConditoin.GameObject:SetActiveEx(not XDataCenter.GuildManager.IsTalentParentAllZero(self.TalentId)) + self.TalentParentConditoin:Refresh(CS.XTextManager.GetText("GuildTalentConditionPoint", curTalentLevel + 1), XDataCenter.GuildManager.CheckParentTalent(self.TalentId)) + end + + self.PanelTips.gameObject:SetActiveEx(not XDataCenter.GuildManager.IsGuildAdminister()) +end + +function XUiGuildSkillDetail:OnBtnLevelClick() + if not XDataCenter.GuildManager.IsGuildAdminister() then + XUiManager.TipMsg(CS.XTextManager.GetText("GuildNotAdministor")) + return + end + -- 前置条件 + local curTalentLevel = XDataCenter.GuildManager.GetTalentLevel(self.TalentId) + if not XDataCenter.GuildManager.CheckParentTalent(self.TalentId) then + XUiManager.TipMsg(CS.XTextManager.GetText("GuildTalentConditionPoint", curTalentLevel + 1)) + return + end + -- 消耗数量 + local ownNum = XDataCenter.GuildManager.GetTalentPoint() + self.TalentTemplate = XGuildConfig.GetGuildTalentById(self.TalentId) + local needNum = self.TalentTemplate.CostPoint[curTalentLevel + 1] or 0 + if ownNum < needNum then + XUiManager.TipMsg(CS.XTextManager.GetText("GuildTalentPointNotEnough")) + return + end + + XDataCenter.GuildManager.GuildUpgradeTalent(self.TalentId, function() + XUiManager.TipMsg(CS.XTextManager.GetText("GuildTalentUpgradeComplete")) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_GUILD_TALENT_ASYNC) + end) +end + +function XUiGuildSkillDetail:OnBtnMaskClick() + if self.OnCloseCallBack then + self.OnCloseCallBack() + end + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuild/XUiGuildTask.lua b/Resources/Scripts/XUi/XUiGuild/XUiGuildTask.lua new file mode 100644 index 00000000..353203d1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiGuildTask.lua @@ -0,0 +1,63 @@ +local XUiGuildTask = XLuaUiManager.Register(XLuaUi, "UiGuildTask") +local XUiGuildTaskDaily = require("XUi/XUiGuild/XUiChildView/XUiGuildTaskDaily") +local XUiGuildTaskMainly = require("XUi/XUiGuild/XUiChildView/XUiGuildTaskMainly") + +function XUiGuildTask:OnAwake() + self:InitTaskView() +end + +function XUiGuildTask:InitTaskView() + self.GuildAllTask = {} + self.GuildAllTask[XGuildConfig.GuildTaskType.Daily] = XUiGuildTaskDaily.New(self.PaneDlailyTask, self) + self.GuildAllTask[XGuildConfig.GuildTaskType.Mainly] = XUiGuildTaskMainly.New(self.PaneThreadTask, self) + + self.BtnTaskTabs = {} + table.insert(self.BtnTaskTabs, self.BtnTabDlaily) + table.insert(self.BtnTaskTabs, self.BtnTabThread) + + self.PanelTab:Init(self.BtnTaskTabs, function(index) self:OnGuildTaskTabClick(index) end) + self.PanelTab:SelectIndex(XGuildConfig.GuildTaskType.Daily) + self.BtnClose.CallBack = function() self:OnBtnCloseClick() end + + XRedPointManager.AddRedPointEvent(self.RedDaily, self.RefreshTaskDaily, self, { XRedPointConditions.Types.CONDITION_TASK_TYPE }, XDataCenter.TaskManager.TaskType.GuildDaily) + XRedPointManager.AddRedPointEvent(self.RedMainly, self.RefresTaskMainly, self, { XRedPointConditions.Types.CONDITION_TASK_TYPE }, XDataCenter.TaskManager.TaskType.GuildMainly) +end + +function XUiGuildTask:RefreshTaskDaily(count) + self.RedDaily.gameObject:SetActiveEx(count >= 0) +end + +function XUiGuildTask:RefresTaskMainly(count) + self.RedMainly.gameObject:SetActiveEx(count >= 0) +end + +function XUiGuildTask:OnStart() +end + +function XUiGuildTask:OnEnable() + +end + +function XUiGuildTask:OnDisable() + +end + +function XUiGuildTask:OnDestroy() + +end + +function XUiGuildTask:OnGuildTaskTabClick(index) + self.PaneDlailyTask.gameObject:SetActiveEx(index == XGuildConfig.GuildTaskType.Daily) + self.PaneThreadTask.gameObject:SetActiveEx(index == XGuildConfig.GuildTaskType.Mainly) + + if self.GuildAllTask[index] then + self.GuildAllTask[index]:UpdateTasks() + end +end + +function XUiGuildTask:OnBtnCloseClick() + self:Close() +end + + + diff --git a/Resources/Scripts/XUi/XUiGuild/XUiGuildVistor.lua b/Resources/Scripts/XUi/XUiGuild/XUiGuildVistor.lua new file mode 100644 index 00000000..e7c814b2 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiGuildVistor.lua @@ -0,0 +1,84 @@ +local XUiGuildVistor = XLuaUiManager.Register(XLuaUi, "UiGuildVistor") + +local XUiGuildViewVistorInformation = require("XUi/XUiGuild/XUiChildView/XUiGuildViewVistorInformation") +local XUiGuildViewVistorMember = require("XUi/XUiGuild/XUiChildView/XUiGuildViewVistorMember") + +function XUiGuildVistor:OnAwake() + self:InitChildView() +end + +function XUiGuildVistor:OnStart(defaultIndex) + self.BtnTapGroup:SelectIndex(defaultIndex or XDataCenter.GuildManager.GuildFunctional.Info) +end + +function XUiGuildVistor:OnEnable() + self:AddEventListeners() +end + +function XUiGuildVistor:OnDisable() + self:RemoveEventListeners() +end + +function XUiGuildVistor:OnDestroy() + +end + +function XUiGuildVistor:OnGetEvents() + return { } +end + +function XUiGuildVistor:OnNotify() + +end + +-- custom method + +function XUiGuildVistor:InitChildView() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + self:BindHelpBtn(self.BtnHelp, "RogueLike") + + self.btnTabs = {} + self.btnTabs[XDataCenter.GuildManager.GuildFunctional.Info] = self.BtnTabInformation + self.btnTabs[XDataCenter.GuildManager.GuildFunctional.Member] = self.BtnTabMember + self.BtnTapGroup:Init(self.btnTabs, function(index) self:OnBtnTabListClick(index) end) + + self.tabViews = {} + self.tabViews[XDataCenter.GuildManager.GuildFunctional.Info] = XUiGuildViewVistorInformation.New(self.PanelInformation, self) + self.tabViews[XDataCenter.GuildManager.GuildFunctional.Member] = XUiGuildViewVistorMember.New(self.PanelMemberInfo, self) +end + +function XUiGuildVistor:OnBtnBackClick() + XLuaUiManager.RunMain() +end + +function XUiGuildVistor:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiGuildVistor:OnBtnTabListClick(index) + if index == self.LastSelect then + return + end + + if self.LastSelect and self.tabViews[self.LastSelect] then + self.tabViews[self.LastSelect]:OnDisable() + end + self.tabViews[index]:OnEnable() + self.LastSelect = index +end + +function XUiGuildVistor:AddEventListeners() + XEventManager.AddEventListener(XEventId.EVENT_GUILD_RECEIVE_CHAT, self.OnGuildChannelDispatchChat, self) +end + +function XUiGuildVistor:RemoveEventListeners() + XEventManager.RemoveEventListener(XEventId.EVENT_GUILD_RECEIVE_CHAT, self.OnGuildChannelDispatchChat, self) +end + +-- 公会频道消息 +function XUiGuildVistor:OnGuildChannelDispatchChat() + self.tabViews[XDataCenter.GuildManager.GuildFunctional.Info]:UpdateGuildNews() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuild/XUiGuildWelcomeWord.lua b/Resources/Scripts/XUi/XUiGuild/XUiGuildWelcomeWord.lua new file mode 100644 index 00000000..79adfbf7 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuild/XUiGuildWelcomeWord.lua @@ -0,0 +1,70 @@ +local XUiGuildWelcomeWord = XLuaUiManager.Register(XLuaUi, "UiGuildWelcomeWord") +local XUiGuildWelcomeWordItem = require("XUi/XUiGuild/XUiChildItem/XUiGuildWelcomeWordItem") + +function XUiGuildWelcomeWord:OnAwake() + self:InitFun() + self.WelcomeWords = {} + for i = 1, XGuildConfig.GuildDefaultWelcomeWord do + self.WelcomeWords[i] = XUiGuildWelcomeWordItem.New(self["WelcomeWord"..i],self) + end +end + +function XUiGuildWelcomeWord:InitFun() + self.BtnCancel.CallBack = function() self:OnBtnCancelClick() end + self.BtnConfirm.CallBack = function() self:OnBtnConfirmClick() end + self.BtnTanchuangClose.CallBack = function() self:OnBtnCancelClick() end +end + +function XUiGuildWelcomeWord:OnEnable() + self:OnRefresh() +end + +function XUiGuildWelcomeWord:OnDisable() +end + +function XUiGuildWelcomeWord:OnBtnConfirmClick() + local scripts = {} + local selects = {} + for _, item in pairs(self.WelcomeWords) do + local text = self:trim(item:GetInitPutText()) + table.insert(scripts, text) + table.insert(selects, item:GetSelect()) + end + + self.DisableFun = self.BtnReportType:GetToggleState() + for index, data in pairs(scripts) do + if data == "" and selects[index] == true then + XUiManager.TipMsg(CS.XTextManager.GetText("GuildNoneWelcomeWord")) + return + end + if string.Utf8Len(data) > CS.XGame.Config:GetInt("GuildScriptLength") then + XUiManager.TipMsg(CS.XTextManager.GetText("GuildChangeScriptErrorLength")) + return + end + end + XDataCenter.GuildManager.GuildChangeScriptRequest(scripts, selects, not self.DisableFun, function () + self:Close() + end) +end + +function XUiGuildWelcomeWord:trim(s) + return (string.gsub(s, "^%s*(.-)%s*$", "%1")) +end + +function XUiGuildWelcomeWord:OnBtnCancelClick() + self:Close() +end + +-- 更新数据 +function XUiGuildWelcomeWord:OnRefresh() + local datas = XDataCenter.GuildManager.GetGuildScriptDatas() or {} + for index, v in pairs(datas)do + local item = self.WelcomeWords[index] + if item then + item:OnRefresh(v) + end + end + + self.DisableFun = not XDataCenter.GuildManager.GetGuildScriptAutoChat() + self.BtnReportType:SetButtonState(self.DisableFun and CS.UiButtonState.Select or CS.UiButtonState.Normal) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuildBoss/ChildView/XUiGuildBossHpReward.lua b/Resources/Scripts/XUi/XUiGuildBoss/ChildView/XUiGuildBossHpReward.lua new file mode 100644 index 00000000..b80ba925 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuildBoss/ChildView/XUiGuildBossHpReward.lua @@ -0,0 +1,44 @@ +local XUiGuildBossHpReward = XClass(nil, "XUiGuildBossHpReward") +local XUiGuildBossHpRewardItem = require("XUi/XUiGuildBoss/Component/XUiGuildBossHpRewardItem") + +function XUiGuildBossHpReward:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + self:InitComponent() +end + +function XUiGuildBossHpReward:InitComponent() + self.BtnClose.CallBack = function() self:Close() end + + self.GridReward.gameObject:SetActiveEx(false) + self.RewardDynamicTable = XDynamicTableNormal.New(self.RewardDynamicTable) + self.RewardDynamicTable:SetProxy(XUiGuildBossHpRewardItem, self.RootUi) + self.RewardDynamicTable:SetDelegate(self) +end + +function XUiGuildBossHpReward:Show() + self.GameObject:SetActiveEx(true) + self:Refresh() +end + +function XUiGuildBossHpReward:Close() + self.GameObject:SetActiveEx(false) +end + + +function XUiGuildBossHpReward:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:Refresh(self.RewardIdList[index], index) + end +end + +-- override +function XUiGuildBossHpReward:Refresh() + self.RewardIdList = XGuildBossConfig.GeHpRewardIdList() + self.RewardDynamicTable:SetDataSource(self.RewardIdList) + self.RewardDynamicTable:ReloadDataASync() +end + +return XUiGuildBossHpReward \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuildBoss/Component/XUiGuildBossGuildRankItem.lua b/Resources/Scripts/XUi/XUiGuildBoss/Component/XUiGuildBossGuildRankItem.lua new file mode 100644 index 00000000..ec477a1d --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuildBoss/Component/XUiGuildBossGuildRankItem.lua @@ -0,0 +1,39 @@ +--工会boss工会排行榜组件 +local XUiGuildBossGuildRankItem = XClass(nil, "XUiGuildBossGuildRankItem") + +function XUiGuildBossGuildRankItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + if self.BtnInfo then + self.BtnInfo.CallBack = function() self:OnBtnInfoClick() end + end +end + +function XUiGuildBossGuildRankItem:Init(data, rank) + self.Id = data.Id + self.TxtName.text = data.Name + if rank >= 1 then + self.TxtRank.text = "No." .. math.modf(rank) + elseif rank == 0 then + self.TxtRank.text = CS.XTextManager.GetText("GuildBossRankNone") + else + local rankNum = 1 + if rank * 100 > 1 then + rankNum = math.modf(rank * 100) + end + + self.TxtRank.text = "No." .. rankNum .. "%" + end + self.TxtScore.text = XUiHelper.GetLargeIntNumText(data.Score) + local headPortrait = XGuildConfig.GetGuildHeadPortraitById(data.IconId) + self.ImgIcon:SetRawImage(headPortrait.Icon) +end + +function XUiGuildBossGuildRankItem:OnBtnInfoClick() + XDataCenter.GuildManager.GetVistorGuildDetailsReq(self.Id,function () + XLuaUiManager.Open("UiGuildRankingList",self.Id) + end) +end + +return XUiGuildBossGuildRankItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuildBoss/Component/XUiGuildBossHpRewardItem.lua b/Resources/Scripts/XUi/XUiGuildBoss/Component/XUiGuildBossHpRewardItem.lua new file mode 100644 index 00000000..28142daa --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuildBoss/Component/XUiGuildBossHpRewardItem.lua @@ -0,0 +1,25 @@ +--工会boss个人排行榜组件 +local XUiGuildBossHpRewardItem = XClass(nil, "XUiGuildBossHpRewardItem") + +function XUiGuildBossHpRewardItem:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + + self.RewardItems = {} + self.GridCommon.gameObject:SetActiveEx(false) + self.OnGridCreateCB = function(grid, data) self:OnGridCreate(grid, data) end +end + +function XUiGuildBossHpRewardItem:Refresh(id) + self.TxtTaskName.text = CS.XTextManager.GetText("GuildBossHpRewardName", XGuildBossConfig.GetHpPercent(id)) -- Boss生命值降至{0}%可领取 + local datas = XRewardManager.GetRewardList(XDataCenter.GuildBossManager.GetHpRewardId(id)) + XUiHelper.CreateTemplates(self.RootUi, self.RewardItems, datas, XUiGridCommon.New, self.GridCommon, self.PanelReward, self.OnGridCreateCB) +end + +function XUiGuildBossHpRewardItem:OnGridCreate(grid, data) + grid:Refresh(data) +end + +return XUiGuildBossHpRewardItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuildBoss/Component/XUiGuildBossLevelGrid.lua b/Resources/Scripts/XUi/XUiGuildBoss/Component/XUiGuildBossLevelGrid.lua new file mode 100644 index 00000000..6ed3886e --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuildBoss/Component/XUiGuildBossLevelGrid.lua @@ -0,0 +1,62 @@ +--选择难度的难度grid +local XUiGuildBossLevelGrid = XClass(nil, "XUiGuildBossLevelGrid") + +function XUiGuildBossLevelGrid:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.BtnSelect.CallBack = function() self:OnBtnSelectClick() end +end + +function XUiGuildBossLevelGrid:Init(data, curLevel, nextLevel, rankLevel, highScore) + self.Data = data + self.TxtLv.text = CS.XTextManager.GetText("GuildBossDiffLv", data.Level) + self.TxtBossHp.text = CS.XTextManager.GetText("GuildBossDiffHp", XUiHelper.GetLargeIntNumText(data.BossHp)) + self.TxtUnlockScore.text = CS.XTextManager.GetText("GuildBossDiffUnlock", XUiHelper.GetLargeIntNumText(data.UnlockScore)) + self.TxtAdditionPercent.text = CS.XTextManager.GetText("GuildBossDiffScoreAdd", data.AdditionPercent) + --当前这一期所使用的Level标记 + if curLevel == data.Level then + self.CurMark.gameObject:SetActiveEx(true) + else + self.CurMark.gameObject:SetActiveEx(false) + end + --只有会长和副会长能操作 + if rankLevel <= XGuildConfig.GuildRankLevel.CoLeader then + --如果已解锁 + if highScore >= data.UnlockScore then + self.FunctionGroup.gameObject:SetActiveEx(true) + self.TxtGroup.alpha = 1 + --如果是下次选择的level + if data.Level == nextLevel then + self.NextSelectMark.gameObject:SetActiveEx(true) + self.BtnSelect.gameObject:SetActiveEx(false) + else + self.NextSelectMark.gameObject:SetActiveEx(false) + self.BtnSelect.gameObject:SetActiveEx(true) + end + --未解锁 + else + self.TxtGroup.alpha = 0.8 + self.FunctionGroup.gameObject:SetActiveEx(false) + end + else + self.FunctionGroup.gameObject:SetActiveEx(false) + if highScore >= data.UnlockScore then + self.TxtGroup.alpha = 1 + if data.Level == nextLevel then + self.FunctionGroup.gameObject:SetActiveEx(true) + self.NextSelectMark.gameObject:SetActiveEx(true) + self.BtnSelect.gameObject:SetActiveEx(false) + end + else + self.TxtGroup.alpha = 0.8 + end + end +end + +--更换下期level +function XUiGuildBossLevelGrid:OnBtnSelectClick() + XDataCenter.GuildBossManager.GuildBossLevelRequest(self.Data.Level) +end + +return XUiGuildBossLevelGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuildBoss/Component/XUiGuildBossLog.lua b/Resources/Scripts/XUi/XUiGuildBoss/Component/XUiGuildBossLog.lua new file mode 100644 index 00000000..2749bc14 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuildBoss/Component/XUiGuildBossLog.lua @@ -0,0 +1,29 @@ +--工会boss日志组件 +local XUiGuildBossLog = XClass(nil, "XUiGuildBossLog") + +function XUiGuildBossLog:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.GetText = CS.XTextManager.GetText +end + +function XUiGuildBossLog:Init(data) + self.NameText.text = data.PlayerName + self.DescText.text = string.format(self.GetText("GuildBossLogLine1"), + XTime.TimestampToGameDateTimeString(data.Time, "MM-dd HH:mm"), + XGuildBossConfig.GetBossStageInfo(data.StageId).Name) .. "\n" + self.DescText.text = self.DescText.text .. string.format(self.GetText("GuildBossLogLine2"), data.SubHp) + if data.EffectValue > 0 then + self.DescText.text = self.DescText.text .. "\n" .. string.format(self.GetText("GuildBossLogLine3"), data.EffectValue) + end + + if data.EffectValue == 100 then + self.DescText.text = self.DescText.text .. string.format(self.GetText("GuildBossLogLine4")) + self.DescText.text = self.DescText.text .. "\n" .. string.format(self.GetText("GuildBossLogLine5"), data.EffectHp) + end + + self.LayoutNode:SetDirty() +end + +return XUiGuildBossLog \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuildBoss/Component/XUiGuildBossPlayerRankItem.lua b/Resources/Scripts/XUi/XUiGuildBoss/Component/XUiGuildBossPlayerRankItem.lua new file mode 100644 index 00000000..c1a61c90 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuildBoss/Component/XUiGuildBossPlayerRankItem.lua @@ -0,0 +1,36 @@ +--工会boss个人排行榜组件 +local XUiGuildBossPlayerRankItem = XClass(nil, "XUiGuildBossPlayerRankItem") + +function XUiGuildBossPlayerRankItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + if self.BtnInfo then + self.BtnInfo.CallBack = function() self:OnBtnInfoClick() end + end +end + +function XUiGuildBossPlayerRankItem:Init(data, rank) + self.Id = data.Id + self.TxtName.text = data.Name + if rank == 0 then + self.TxtRank.text = CS.XTextManager.GetText("GuildBossRankNone") + self.TxtRankName.text = "" + else + self.TxtRank.text = "No." .. rank + self.TxtRankName.text = XDataCenter.GuildManager.GetRankNameByLevel(data.RankLevel) + end + if self.TxtScore then + self.TxtScore.text = XUiHelper.GetLargeIntNumText(data.Score) + end + XUiPLayerHead.InitPortrait(data.HeadPortraitId, data.HeadFrameId, self.UObjHead) + --data.RankLevel 职位 +end + +function XUiGuildBossPlayerRankItem:OnBtnInfoClick() + if self.Id ~= XPlayer.Id then + XDataCenter.PersonalInfoManager.ReqShowInfoPanel(self.Id) + end +end + +return XUiGuildBossPlayerRankItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuildBoss/Component/XUiGuildBossRankItem.lua b/Resources/Scripts/XUi/XUiGuildBoss/Component/XUiGuildBossRankItem.lua new file mode 100644 index 00000000..c692cdb5 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuildBoss/Component/XUiGuildBossRankItem.lua @@ -0,0 +1,31 @@ +--工会boss排行榜中的grid +local XUiGuildBossTeamList = require("XUi/XUiGuildBoss/Component/XUiGuildBossTeamList") +local XUiGuildBossRankItem = XClass(nil, "XUiGuildBossRankItem") + +function XUiGuildBossRankItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.BtnDetail.CallBack = function() self:OnBtnDetailClick() end +end + +function XUiGuildBossRankItem:Init(data, rank) + self.Id = data.Id + self.TxtScore.text = data.Score + self.TxtName.text = data.Name + self.TxtRank.text = rank + if self.Team == nil then + self.Team = XUiGuildBossTeamList.New(self.TeamObj) + end + XUiPLayerHead.InitPortrait(data.HeadPortraitId, data.HeadFrameId, self.UObjHead) + self.TxtRankName.text = XDataCenter.GuildManager.GetRankNameByLevel(data.RankLevel) + self.Team:Init(data.CardIds, data.LiberateLvs, false) +end + +function XUiGuildBossRankItem:OnBtnDetailClick() + if self.Id ~= XPlayer.Id then + XDataCenter.PersonalInfoManager.ReqShowInfoPanel(self.Id) + end +end + +return XUiGuildBossRankItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuildBoss/Component/XUiGuildBossRankPanel.lua b/Resources/Scripts/XUi/XUiGuildBoss/Component/XUiGuildBossRankPanel.lua new file mode 100644 index 00000000..744dbb0f --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuildBoss/Component/XUiGuildBossRankPanel.lua @@ -0,0 +1,34 @@ +--各个关卡页面的rank组件 +local XUiGuildBossStageRankItem = require("XUi/XUiGuildBoss/Component/XUiGuildBossStageRankItem") +local XUiGuildBossRankPanel = XClass(nil, "XUiGuildBossRankPanel") + +function XUiGuildBossRankPanel:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.BtnRank.CallBack = function() self:OnBtnRankClick() end + self.RankList = {} + self.RankNum = 3 +end + +function XUiGuildBossRankPanel:Init(stageId) + self.StageId = stageId + self.Data = XDataCenter.GuildBossManager.GetDetailLevelData(stageId) + for i = 1, self.RankNum do + if i <= #self.Data.TopPlayers then + if self.RankList[i] == nil then + self.RankList[i] = XUiGuildBossStageRankItem.New(self["RankItem" .. i]) + end + self["RankItem" .. i].gameObject:SetActiveEx(true) + self.RankList[i]:Init(self.Data.TopPlayers[i], i) + else + self["RankItem" .. i].gameObject:SetActiveEx(false) + end + end +end + +function XUiGuildBossRankPanel:OnBtnRankClick() + XLuaUiManager.Open("UiGuildBossRank", self.StageId) +end + +return XUiGuildBossRankPanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuildBoss/Component/XUiGuildBossRankRewardItem.lua b/Resources/Scripts/XUi/XUiGuildBoss/Component/XUiGuildBossRankRewardItem.lua new file mode 100644 index 00000000..673e8d0b --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuildBoss/Component/XUiGuildBossRankRewardItem.lua @@ -0,0 +1,25 @@ +--工会boss个人排行榜组件 +local XUiGuildBossRankRewardItem = XClass(nil, "XUiGuildBossRankRewardItem") + +function XUiGuildBossRankRewardItem:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + + self.RewardItems = {} + self.GridReward.gameObject:SetActiveEx(false) + self.OnGridCreateCB = function(grid, data) self:OnGridCreate(grid, data) end +end + +function XUiGuildBossRankRewardItem:Refresh(id) + self.TxtRank.text = XGuildBossConfig.GetRankPercentName(id) -- 1%-5% + local datas = XRewardManager.GetRewardList(XGuildBossConfig.GetRankRewardId(id)) + XUiHelper.CreateTemplates(self.RootUi, self.RewardItems, datas, XUiGridCommon.New, self.GridReward, self.PanelRewardList, self.OnGridCreateCB) +end + +function XUiGuildBossRankRewardItem:OnGridCreate(grid, data) + grid:Refresh(data) +end + +return XUiGuildBossRankRewardItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuildBoss/Component/XUiGuildBossRewardItem.lua b/Resources/Scripts/XUi/XUiGuildBoss/Component/XUiGuildBossRewardItem.lua new file mode 100644 index 00000000..e10121e0 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuildBoss/Component/XUiGuildBossRewardItem.lua @@ -0,0 +1,88 @@ +--工会boss 奖励按钮组件 +local XUiGuildBossRewardItem = XClass(nil, "XUiGuildBossRewardItem") +local Vector2 = CS.UnityEngine.Vector2 + +function XUiGuildBossRewardItem:Ctor(ui, parentUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.ParentUi = parentUi + XTool.InitUiObject(self) + self.BtnReward.CallBack = function() self:OnBtnRewardClick() end + + self.EnableIconPath = CS.XGame.ClientConfig:GetString("GuildBossRewardEnableIcon") + self.DisableIconPath = CS.XGame.ClientConfig:GetString("GuildBossRewardDisableIcon") + + self.ImgProgress.gameObject:SetActiveEx(false) + self.ProgressRT = self.ImgProgress.transform:GetComponent("RectTransform") + self.ProgressSize = self.ProgressRT.sizeDelta + + self.MyRewardType = GuildBossRewardType.Disable +end + +--self.ScoreBoxGot 已领取的id list +function XUiGuildBossRewardItem:Init(data, lastScore) + self.Data = data + self.MyTotalScore = XDataCenter.GuildBossManager.GetMyTotalScore() + self.ScoreBoxGot = XDataCenter.GuildBossManager.GetScoreBoxGot() + --是否已领取 + self.IsGet = false + for _,val in pairs(self.ScoreBoxGot) do + if val == self.Data.Id then + self.IsGet = true + break + end + end + self.TxtScore.text = XUiHelper.GetLargeIntNumText(self.Data.Score) + --三种情况 + --未达到分数要求不能领取 + if self.MyTotalScore < self.Data.Score then + self.MyRewardType = GuildBossRewardType.Disable + --达到分数但未领取 + elseif not self.IsGet then + self.MyRewardType = GuildBossRewardType.Available + --已领取 + else + self.MyRewardType = GuildBossRewardType.Acquired + end + + local itemScore = self.MyTotalScore - lastScore + local gapScore = (self.Data.Score - lastScore) + local progress = math.min(math.max(0, itemScore / gapScore), 1) + self.ProgressRT.sizeDelta = Vector2(self.ProgressSize.x, progress * self.ProgressSize.y) + self.ImgProgress.gameObject:SetActiveEx(true) + + self:UpdateUi() +end + +function XUiGuildBossRewardItem:UpdateUi() + if self.MyRewardType == GuildBossRewardType.Disable then + self.ImgIcon:SetSprite(self.DisableIconPath) + self.ImgIsGet.gameObject:SetActiveEx(false) + self.Red.gameObject:SetActiveEx(false) + elseif self.MyRewardType == GuildBossRewardType.Available then + self.ImgIcon:SetSprite(self.EnableIconPath) + self.ImgIsGet.gameObject:SetActiveEx(false) + self.Red.gameObject:SetActiveEx(true) + elseif self.MyRewardType == GuildBossRewardType.Acquired then + self.ImgIcon:SetSprite(self.DisableIconPath) + self.ImgIsGet.gameObject:SetActiveEx(true) + self.Red.gameObject:SetActiveEx(false) + end +end + +function XUiGuildBossRewardItem:OnBtnRewardClick() + if self.MyRewardType == GuildBossRewardType.Disable then + self:ShowRewardUi() + elseif self.MyRewardType == GuildBossRewardType.Available then + self.ParentUi:OnBtnRewardClick(self.Data) + elseif self.MyRewardType == GuildBossRewardType.Acquired then + self:ShowRewardUi() + end +end + +function XUiGuildBossRewardItem:ShowRewardUi() + local rewardId = XDataCenter.GuildBossManager.GetScoreRewardId(self.Data.Id) + XUiManager.OpenUiTipRewardByRewardId(rewardId, CS.XTextManager.GetText("DailyActiveRewardTitle")) +end + +return XUiGuildBossRewardItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuildBoss/Component/XUiGuildBossSkillGrid.lua b/Resources/Scripts/XUi/XUiGuildBoss/Component/XUiGuildBossSkillGrid.lua new file mode 100644 index 00000000..3b8a104c --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuildBoss/Component/XUiGuildBossSkillGrid.lua @@ -0,0 +1,31 @@ +--工会boss技能grid组件 +local XUiGuildBossSkillGrid = XClass(nil, "XUiGuildBossSkillGrid") + +function XUiGuildBossSkillGrid:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +--levelData Type is XTableGuildBossStageInfo +function XUiGuildBossSkillGrid:Init(levelData, progress, order) + self.LevelData = levelData + local buffInfo = XGuildBossConfig.GetBuff(self.LevelData.BuffId) + local levelInfo = XGuildBossConfig.GetBossStageInfo(self.LevelData.Id) + self.RImgIcon:SetRawImage(levelInfo.Icon) + self.TxtName.text = buffInfo.Name + self.ImgProgress.fillAmount = progress / 100 + self.TxtProgress.text = progress .. "%" + self.TxtDis.text = buffInfo.Dis + if order then + self.TxtCode.text = self.LevelData.Code .. order + end + + if progress >= 100 then + self.IsGet.gameObject:SetActiveEx(true) + else + self.IsGet.gameObject:SetActiveEx(false) + end +end + +return XUiGuildBossSkillGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuildBoss/Component/XUiGuildBossStageLevel.lua b/Resources/Scripts/XUi/XUiGuildBoss/Component/XUiGuildBossStageLevel.lua new file mode 100644 index 00000000..2986eecb --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuildBoss/Component/XUiGuildBossStageLevel.lua @@ -0,0 +1,70 @@ +--工会boss关卡stage控件 +local XUiGuildBossStageLevel = XClass(nil, "XUiGuildBossStageLevel") + +local GuildBossStageLevelStatus = +{ + Normal = 1,--未选择状态 + Lock = 2,--未解锁状态(等级不满足条件) + UnSelect = 3, --未选中(不能打) +} + +function XUiGuildBossStageLevel:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.BtnClick.CallBack = function() self:OnBtnClick() end + self.CurStatus = GuildBossStageLevelStatus.Normal +end + +function XUiGuildBossStageLevel:Init(data, parentUi, status) + self.Data = data + self.ParentUi = parentUi + local info = XGuildBossConfig.GetBossStageInfo(self.Data.StageId) + self.ImgBG:SetRawImage(info.BackGround) + self.RImgIcon:SetRawImage(info.Icon) + self.TxtCode.text = info.Code .. self.Data.NameOrder + self.ImgPoint.fillAmount = self.Data.BuffNeed / 100 + --剩余0说明技能已发动 + if self.Data.BuffNeed == 0 then + end + self:UpdateStatus(status) + self:HideOrder() + self:SetOrderMark(false) +end + +function XUiGuildBossStageLevel:UpdateStatus(status) + if status == GuildBossStageLevelStatus.Normal then + + elseif status == GuildBossStageLevelStatus.Lock then + + elseif status == GuildBossStageLevelStatus.UnSelect then + + end + self.CurStatus = status +end + +--设置是否显示优先标记 +function XUiGuildBossStageLevel:SetOrderMark(isOrder) + self.ImgOrder.gameObject:SetActiveEx(isOrder) +end + +--设置战术布局显示数字 +function XUiGuildBossStageLevel:SetOrder(num) + if num == 0 then + self:HideOrder() + else + self.OrderNum.gameObject:SetActiveEx(true) + self.TxtOrder.text = num + end +end + +--隐藏战术布局 +function XUiGuildBossStageLevel:HideOrder() + self.OrderNum.gameObject:SetActiveEx(false) +end + +function XUiGuildBossStageLevel:OnBtnClick() + self.ParentUi:OnStageLevelClick(self.Data, self) +end + +return XUiGuildBossStageLevel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuildBoss/Component/XUiGuildBossStageRankItem.lua b/Resources/Scripts/XUi/XUiGuildBoss/Component/XUiGuildBossStageRankItem.lua new file mode 100644 index 00000000..64512914 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuildBoss/Component/XUiGuildBossStageRankItem.lua @@ -0,0 +1,26 @@ +--工会boss关卡上排行榜组件 +local XUiGuildBossStageRankItem = XClass(nil, "XUiGuildBossStageRankItem") + +function XUiGuildBossStageRankItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + if self.BtnInfo then + self.BtnInfo.CallBack = function() self:OnBtnInfoClick() end + end +end + +function XUiGuildBossStageRankItem:Init(data, rank) + self.Id = data.Id + self.TxtName.text = data.PlayerName + self.TxtRank.text = "No." .. rank + XUiPLayerHead.InitPortrait(data.HeadPortraitId, data.HeadFrameId, self.UObjHead) + --data.RankLevel 职位 + self.TxtScore.text = CS.XTextManager.GetText("GuildBossTopPlayerScoreName", XUiHelper.GetLargeIntNumText(data.Score or 0)) +end + +function XUiGuildBossStageRankItem:OnBtnInfoClick() + XDataCenter.PersonalInfoManager.ReqShowInfoPanel(self.Id) +end + +return XUiGuildBossStageRankItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuildBoss/Component/XUiGuildBossTeamList.lua b/Resources/Scripts/XUi/XUiGuildBoss/Component/XUiGuildBossTeamList.lua new file mode 100644 index 00000000..cfc89670 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuildBoss/Component/XUiGuildBossTeamList.lua @@ -0,0 +1,42 @@ +--工会boss队员头像组件 +local XUiGuildBossTeamList = XClass(nil, "XUiGuildBossTeamList") + +function XUiGuildBossTeamList:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.MaxHeadNum = 3 +end + +function XUiGuildBossTeamList:Init(data, liberateLvs, needBigHead) + for i = 1, self.MaxHeadNum do + if data[i] <= 0 then + self["TeamHeadObj" .. i].gameObject:SetActiveEx(false) + else + self["TeamHeadObj" .. i].gameObject:SetActiveEx(true) + if i <= #data then + self["TryMarkObj" .. i].gameObject:SetActiveEx(data[i] < 1000000) + --Head + local characterId + if XRobotManager.CheckIsRobotId(data[i]) then + characterId = XRobotManager.GetCharacterId(data[i]) + else + characterId = data[i] + end + local iconPath + if needBigHead then + iconPath = XDataCenter.CharacterManager.GetCharBigHeadIcon(characterId, liberateLvs[i], true) + else + iconPath = XDataCenter.CharacterManager.GetCharSmallHeadIcon(characterId, liberateLvs[i], true) + end + self["ImgHead" .. i]:SetRawImage(iconPath) + + self["TeamHeadObj" .. i].gameObject:SetActiveEx(true) + else + self["TeamHeadObj" .. i].gameObject:SetActiveEx(false) + end + end + end +end + +return XUiGuildBossTeamList \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuildBoss/XUiGuildBossCurSubLevelInfo.lua b/Resources/Scripts/XUi/XUiGuildBoss/XUiGuildBossCurSubLevelInfo.lua new file mode 100644 index 00000000..19189223 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuildBoss/XUiGuildBossCurSubLevelInfo.lua @@ -0,0 +1,158 @@ +--工会boss普通关卡详细信息页面 +local XUiGuildBossLog = require("XUi/XUiGuildBoss/Component/XUiGuildBossLog") +local XUiGuildBossSkillGrid = require("XUi/XUiGuildBoss/Component/XUiGuildBossSkillGrid") +local XUiGuildBossRankPanel = require("XUi/XUiGuildBoss/Component/XUiGuildBossRankPanel") +local XUiGuildBossCurSubLevelInfo = XLuaUiManager.Register(XLuaUi, "UiGuildBossCurSubLevelInfo") +local GUILD_BOSS_NEED_BUFF = 100 + +function XUiGuildBossCurSubLevelInfo:OnAwake() + self.Instantiate = CS.UnityEngine.GameObject.Instantiate + self.VectorOne = CS.UnityEngine.Vector3.one + self.VectorZero = CS.UnityEngine.Vector3.zero + self.BtnStart.CallBack = function() self:OnBtnStartClick() end + self.MaxCount = CS.XGame.Config:GetInt("GuildBossStageUploadCount") + self.Skill = XUiGuildBossSkillGrid.New(self.SkillGrid) + self.RankPanel = XUiGuildBossRankPanel.New(self.PanelRankObj) + self.EnterWarningTitleStr = CS.XTextManager.GetText("GuildBossEnterWarningTitleStr") + self.EnterLowWarningStr = CS.XTextManager.GetText("GuildBossEnterLowWarningStr") + self.EnterHighWarningStr = CS.XTextManager.GetText("GuildBossEnterHighWarningStr") + + --Log相关 + self.BtnCloseFullRecord.CallBack = function() self:OnBtnCloseFullRecordClick() end + self.BtnOpenRecord.CallBack = function() self:OnBtnOpenRecordClick() end + self.LogDynamicTable = XDynamicTableIrregular.New(self.PanelRecordView) + self.LogDynamicTable:SetProxy("XUiGuildBossLog",XUiGuildBossLog, self.RecordItem.gameObject) + self.LogDynamicTable:SetDelegate(self) +end + +function XUiGuildBossCurSubLevelInfo:GetProxyType() + return "XUiGuildBossLog" +end + +function XUiGuildBossCurSubLevelInfo:OnStart(ui) + self.ParentUi = ui +end + +--参数data XXDataCenter.GuildBossManager.GuildBossActivityRequest->GuildBossLevelData +function XUiGuildBossCurSubLevelInfo:OnEnable() + self:UpdateAllInfo() +end + +function XUiGuildBossCurSubLevelInfo:UpdateAllInfo() + self.Data = self.ParentUi.CurSelectLevelData + self.DetailData = XDataCenter.GuildBossManager.GetDetailLevelData(self.Data.StageId) + + self.ConfigData = XGuildBossConfig.GetBossStageInfo(self.Data.StageId) + self.TxtCode.text = self.ConfigData.Code .. self.Data.NameOrder + self.TxtName.text = self.ConfigData.Name + self.TxtLimit.text = self.ConfigData.Limit + self.ImgIcon:SetSprite(self.ConfigData.DetailIcon) + self.OrderMark.gameObject:SetActiveEx(false) + self.TxtIsDone.gameObject:SetActiveEx(self.Data.Score > 0) + self.GroupScore.gameObject:SetActiveEx(self.Data.Score > 0) + self.GroupOne.gameObject:SetActiveEx(self.Data.Score == 0) + self.TxtScore.text = XUiHelper.GetLargeIntNumText(self.Data.Score) + self.TxtCount.text = CS.XTextManager.GetText("GuildBossCount", self.Data.UploadCount, self.MaxCount) + --buff + self.Skill:Init(self.ConfigData, self.Data.BuffNeed) + --Rank + self.RankPanel:Init(self.Data.StageId) + --log + + self:RefreshLogList(true) +end + +function XUiGuildBossCurSubLevelInfo:RefreshLogList(reloadData) + if reloadData then + self.LogData = {} + local allLogData = XDataCenter.GuildBossManager.GetLogs() + if allLogData then + for i = 1, #allLogData do + if allLogData[i].StageId == self.Data.StageId then + table.insert(self.LogData, allLogData[i]) + end + end + end + self.LogDynamicTable:SetDataSource(self.LogData) + end + self.LogDynamicTable:ReloadDataASync(#self.LogData) +end + +function XUiGuildBossCurSubLevelInfo:OnBtnCloseClick() + self:Close() +end + +--Log动态列表事件 +function XUiGuildBossCurSubLevelInfo:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:Init(self.LogData[index]) + end +end + + +--展开详细记录 +function XUiGuildBossCurSubLevelInfo:OnBtnOpenRecordClick() + self.BtnOpenRecord.gameObject:SetActiveEx(false) + self.BtnCloseFullRecord.gameObject:SetActiveEx(true) + self.ImgUnfoldBack.gameObject:SetActiveEx(true) + self.PanelRecordViewRect.sizeDelta = CS.UnityEngine.Vector2(410, 900) + self.PanelRecordViewRect.anchoredPosition = CS.UnityEngine.Vector2(30, 950) + self:RefreshLogList() +end + +--关闭详细记录 +function XUiGuildBossCurSubLevelInfo:OnBtnCloseFullRecordClick() + self.BtnOpenRecord.gameObject:SetActiveEx(true) + self.BtnCloseFullRecord.gameObject:SetActiveEx(false) + self.ImgUnfoldBack.gameObject:SetActiveEx(false) + self.PanelRecordViewRect.sizeDelta = CS.UnityEngine.Vector2(410, 163) + self.PanelRecordViewRect.anchoredPosition = CS.UnityEngine.Vector2(30, 250) + self:RefreshLogList() +end + +function XUiGuildBossCurSubLevelInfo:OnBtnStartClick() + if self.Data.UploadCount == self.MaxCount then + XUiManager.TipError(CS.XTextManager.GetText("GuildBossCountFull")) + return + end + + XDataCenter.GuildBossManager.GuildBossStageRequest(self.Data.StageId, function() + local tmpDetailLevelData = XDataCenter.GuildBossManager.GetDetailLevelData(self.Data.StageId) + if self.DetailData.BuffLeft ~= tmpDetailLevelData.BuffLeft then + self.DetailData = tmpDetailLevelData + + XDataCenter.GuildBossManager.GuildBossActivityRequest(function() + if self.ParentUi then + self.ParentUi:UpdatePage(0) + self.ParentUi:UpdateCurSelectLevelData() + self:UpdateAllInfo() + else + self:Close() + end + end) + end + self:RealOnBtnStartClick() + end) +end + +function XUiGuildBossCurSubLevelInfo:RealOnBtnStartClick() + + if self.DetailData.BuffLeft >= GUILD_BOSS_NEED_BUFF then + CsXUiManager.Instance:Open("UiDialog", self.EnterWarningTitleStr, CS.XTextManager.GetText("GuildBossBuffActive"), XUiManager.DialogType.Normal, nil, function() + XLuaUiManager.Open("UiNewRoomSingle", self.Data.StageId) + end) + elseif self.Data.UploadCount == 0 then + local context = nil + if self.Data.Type == GuildBossLevelType.Low then + context = self.EnterLowWarningStr + else + context = self.EnterHighWarningStr + end + CsXUiManager.Instance:Open("UiDialog", self.EnterWarningTitleStr, context, XUiManager.DialogType.Normal, nil, function() + XLuaUiManager.Open("UiNewRoomSingle", self.Data.StageId) + end) + else + XLuaUiManager.Open("UiNewRoomSingle", self.Data.StageId) + end + +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuildBoss/XUiGuildBossDetail.lua b/Resources/Scripts/XUi/XUiGuildBoss/XUiGuildBossDetail.lua new file mode 100644 index 00000000..a996ece6 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuildBoss/XUiGuildBossDetail.lua @@ -0,0 +1,53 @@ +--工会boss自己详细分数页面 +local XUiGuildBossTeamList = require("XUi/XUiGuildBoss/Component/XUiGuildBossTeamList") +local XUiGuildBossDetail = XLuaUiManager.Register(XLuaUi, "UiGuildBossDetail") + +function XUiGuildBossDetail:OnAwake() + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + + self.TeamLow = XUiGuildBossTeamList.New(self.TeamLowObj) + self.TeamHigh = XUiGuildBossTeamList.New(self.TeamHighObj) + self.TeamBoss = XUiGuildBossTeamList.New(self.TeamBossObj) +end + +function XUiGuildBossDetail:OnStart() + self.TxtSumScore.text = XUiHelper.GetLargeIntNumText(XDataCenter.GuildBossManager.GetMyTotalScore()) + self.TxtScoreLow.text = XUiHelper.GetLargeIntNumText(XDataCenter.GuildBossManager.GetLowScore()) + self.TxtScoreHigh.text = XUiHelper.GetLargeIntNumText(XDataCenter.GuildBossManager.GetHighScore()) + self.TxtScoreBoss.text = XUiHelper.GetLargeIntNumText(XDataCenter.GuildBossManager.GetBossScore()) + self.TxtAddSorce.text = XUiHelper.GetLargeIntNumText(XDataCenter.GuildBossManager.GetAdditionalScore()) + self.TxtAddDis.text = string.format(CS.XTextManager.GetText("GuildBossDeathDis"), XDataCenter.GuildBossManager.GetAdditionalScore()) + self.TxtFinish.gameObject:SetActiveEx(XDataCenter.GuildBossManager.GetCurBossHp() <= 0 and XDataCenter.GuildBossManager.GetMyTotalScore() > 0) + + local lowLevelData = XDataCenter.GuildBossManager.GetLowLevelInfo() + local highLevelData = XDataCenter.GuildBossManager.GetHighLevelInfo() + local bossLevelData = XDataCenter.GuildBossManager.GetBossLevelInfo() + + if lowLevelData ~= nil then + self.TeamLow:Init(lowLevelData.CardIds, lowLevelData.LiberateLvs, true) + self.TeamLow.GameObject:SetActiveEx(true) + else + self.TeamLow.GameObject:SetActiveEx(false) + end + if highLevelData ~= nil then + self.TeamHigh:Init(highLevelData.CardIds, highLevelData.LiberateLvs, true) + self.TeamHigh.GameObject:SetActiveEx(true) + else + self.TeamHigh.GameObject:SetActiveEx(false) + end + if bossLevelData ~= nil and bossLevelData.CardIds ~= nil then + self.TeamBoss:Init(bossLevelData.CardIds, bossLevelData.LiberateLvs, true) + self.TeamBoss.GameObject:SetActiveEx(true) + else + self.TeamBoss.GameObject:SetActiveEx(false) + end +end + +function XUiGuildBossDetail:OnBtnBackClick() + self:Close() +end + +function XUiGuildBossDetail:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end diff --git a/Resources/Scripts/XUi/XUiGuildBoss/XUiGuildBossDiff.lua b/Resources/Scripts/XUi/XUiGuildBoss/XUiGuildBossDiff.lua new file mode 100644 index 00000000..4e1d8c9f --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuildBoss/XUiGuildBossDiff.lua @@ -0,0 +1,40 @@ +--工会boss设置难度页面 +local XUiGuildBossLevelGrid = require("XUi/XUiGuildBoss/Component/XUiGuildBossLevelGrid") +local XUiGuildBossDiff = XLuaUiManager.Register(XLuaUi, "UiGuildBossDiff") + +function XUiGuildBossDiff:OnAwake() + self.DynamicTable = XDynamicTableNormal.New(self.BossScoreList) + self.DynamicTable:SetProxy(XUiGuildBossLevelGrid) + self.DynamicTable:SetDelegate(self) + self.BtnBack.CallBack = function() self:OnBtnBackClick() end +end + +function XUiGuildBossDiff:OnEnable() + XEventManager.AddEventListener(XEventId.EVENT_GUILDBOSS_UPDATEDIFF, self.UpdateDynamicTable, self) +end + +function XUiGuildBossDiff:OnDisable() + XEventManager.RemoveEventListener(XEventId.EVENT_GUILDBOSS_UPDATEDIFF, self.UpdateDynamicTable, self) +end + +function XUiGuildBossDiff:OnStart() + self.TxtTotalScore.text = XUiHelper.GetLargeIntNumText(XDataCenter.GuildBossManager.GetTotalScore()) + self.LevelData = XGuildBossConfig.GetBossLevel() + self:UpdateDynamicTable() +end + +function XUiGuildBossDiff:UpdateDynamicTable() + self.DynamicTable:SetDataSource(self.LevelData) + self.DynamicTable:ReloadDataASync() +end + +--动态列表事件 +function XUiGuildBossDiff:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:Init(self.LevelData[index], XDataCenter.GuildBossManager.GetCurBossLevel(), XDataCenter.GuildBossManager.GetNextBossLevel(), XDataCenter.GuildManager.GetCurRankLevel(), XDataCenter.GuildBossManager.GetScoreSumBest()) + end +end + +function XUiGuildBossDiff:OnBtnBackClick() + self:Close() +end diff --git a/Resources/Scripts/XUi/XUiGuildBoss/XUiGuildBossFightResult.lua b/Resources/Scripts/XUi/XUiGuildBoss/XUiGuildBossFightResult.lua new file mode 100644 index 00000000..1d1e4ac0 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuildBoss/XUiGuildBossFightResult.lua @@ -0,0 +1,65 @@ +--工会boss战斗结算页面 +local XUiGuildBossFightResult = XLuaUiManager.Register(XLuaUi, "UiGuildBossFightResult") + +function XUiGuildBossFightResult:OnAwake() + self.BtnExitFight.CallBack = function() self:OnBtnExitFightClick() end + self.BtnSave.CallBack = function() self:OnBtnSaveClick() end +end + +function XUiGuildBossFightResult:OnStart(data) + self.StageId = data.StageId + local guildBossStageInfo = XGuildBossConfig.GetBossStageInfo(data.StageId) + self.Data = data.GuildBossFightResult + self.TxtTile.text = guildBossStageInfo.Name + self.TxtRemainHpScoreMax.text = CS.XTextManager.GetText("ArenaMaxSingleScore", self.Data.HpMaxScore) + self.PanelNewRecord.gameObject:SetActiveEx(self.Data.TotalScore > self.Data.TotalHighScore) + + --总积分以及历史最高 + self.TxtPoint.text = CS.XTextManager.GetText("ArenaMaxAllScore", self.Data.TotalScore) + self.TxtHighScore.text = CS.XTextManager.GetText("ArenaMaxAllHistoryScore", self.Data.TotalHighScore) + local time = CS.XGame.ClientConfig:GetFloat("BossSingleAnimaTime") + + -- 通关时间 + local costTime = XUiHelper.GetTime(self.Data.UseTime, XUiHelper.TimeFormatType.SHOP) + self.TxtCostTime.text = costTime + + self.TweenAnim = XUiHelper.Tween(time, function(f) + --伤害量 + self.TxtDamage.text = math.floor(f * self.Data.Damage) + self.TxtDamageScore.text = '+' .. math.floor(f * self.Data.DamageScore) + + --剩余血量 + self.TxtRemainHp.text = math.floor(f * self.Data.HpLeftPer) .. "%" + self.TxtRemainHpScore.text = '+' .. math.floor(f * self.Data.HpScore) + + --参与积分 + self.TxtAddScore.text = '+' .. math.floor(f * self.Data.Base) + + --总积分以及历史最高 + self.TxtPoint.text = math.floor(f * self.Data.TotalScore) + self.TxtHighScore.text = math.floor(f * self.Data.TotalHighScore) + + end, nil) + + XDataCenter.GuildBossManager.SetNeedUpdateStageInfo(true) +end + +function XUiGuildBossFightResult:OnDestroy() + if self.TweenAnim then + XScheduleManager.UnSchedule(self.TweenAnim) + self.TweenAnim = nil + end +end + +function XUiGuildBossFightResult:OnBtnExitFightClick() + if XDataCenter.GuildManager.GetGuildId() <= 0 then + XUiManager.TipMsg(CS.XTextManager.GetText("GuildKickOutByAdministor")) + XLuaUiManager.RunMain() + else + self:Close() + end +end + +function XUiGuildBossFightResult:OnBtnSaveClick() + XDataCenter.GuildBossManager.GuildBossUploadRequest(self.StageId, function() self:Close() end) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuildBoss/XUiGuildBossHall.lua b/Resources/Scripts/XUi/XUiGuildBoss/XUiGuildBossHall.lua new file mode 100644 index 00000000..6a82914d --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuildBoss/XUiGuildBossHall.lua @@ -0,0 +1,235 @@ +--工会boss战入口窗口 +local XUiGuildBossLog = require("XUi/XUiGuildBoss/Component/XUiGuildBossLog") +local XUiGuildBossPlayerRankItem = require("XUi/XUiGuildBoss/Component/XUiGuildBossPlayerRankItem") +local XUiGuildBossGuildRankItem = require("XUi/XUiGuildBoss/Component/XUiGuildBossGuildRankItem") +local XUiGuildBossHall = XLuaUiManager.Register(XLuaUi, "UiGuildBossHall") + +local GuildRankType = { + Player = 1, --个人排行 + Guild = 2, --工会排行 +} + +function XUiGuildBossHall:OnAwake() + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + self:BindHelpBtn(self.BtnHelp, "GuildBossHelp") + self.BtnStart.CallBack = function() self:OnBtnStartClick() end + self.BtnCloseFullRecord.CallBack = function() self:OnBtnCloseFullRecordClick() end + self.BtnOpenRecord.CallBack = function() self:OnBtnOpenRecordClick() end + self.BtnChange.CallBack = function() self:OnBtnChangeClick() end + self.BtnRankReward.CallBack = function() self:OnBtnRankRewardClick() end + + self.LogDynamicTable = XDynamicTableIrregular.New(self.PanelRecordView) + self.LogDynamicTable:SetProxy("XUiGuildBossLog",XUiGuildBossLog, self.RecordItem.gameObject) + self.LogDynamicTable:SetDelegate(self) + + self.ImgEmptyPlayerRank.gameObject:SetActiveEx(false) + self.ImgEmptyGuildRank.gameObject:SetActiveEx(false) + self.GUildDynamicTable = XDynamicTableNormal.New(self.PanelGuildRankList) + self.GUildDynamicTable:SetProxy(XUiGuildBossGuildRankItem) + self.GUildDynamicTable:SetDelegate(self) + self.GUildDynamicTable:SetDynamicEventDelegate(function(event, index, grid) + self:OnGUildDynamicTableEvent(event, index, grid) + end) + self.GuildRankItem.gameObject:SetActiveEx(false) + self.MyGuildRankObj.gameObject:SetActiveEx(false) + + self.PlayerDynamicTable = XDynamicTableNormal.New(self.PanelRankList) + self.PlayerDynamicTable:SetProxy(XUiGuildBossPlayerRankItem) + self.PlayerDynamicTable:SetDelegate(self) + self.PlayerDynamicTable:SetDynamicEventDelegate(function(event, index, grid) + self:OnPlayerDynamicTableEvent(event, index, grid) + end) + self.RankItem.gameObject:SetActiveEx(false) + self.MyRankObj.gameObject:SetActiveEx(false) + self.GuildBossChangeGuildRankStr = CS.XTextManager.GetText("GuildBossChangeGuildRankStr") + self.GuildBossChangePlayerRankStr = CS.XTextManager.GetText("GuildBossChangePlayerRankStr") + + self.RankType = GuildRankType.Player + self.BtnChange:SetName(self.GuildBossChangeGuildRankStr) + + self.PlayerRankList = {} + self.GuildRankList = {} + self.MyRank = nil + self.PlayerRankNum = 5 + self.GuildRankNum = 9 + self.IsFirstTimeOpen = true +end + +function XUiGuildBossHall:GetProxyType() + return "XUiGuildBossLog" +end + +function XUiGuildBossHall:OnStart() + --首次进入展示帮助 + if not XSaveTool.GetData("ShowGuildBossHallHelp" .. XPlayer.Id) then + XSaveTool.SaveData("ShowGuildBossHallHelp" .. XPlayer.Id, true) + XUiManager.ShowHelpTip("GuildBossHelp") + end +end + +function XUiGuildBossHall:OnEnable() + if self.IsFirstTimeOpen then + self:UpdateInfo() + self.IsFirstTimeOpen = false + else + XDataCenter.GuildBossManager.GuildBossInfoRequest(function() self:UpdateInfo() end) + end + self.BtnStart:ShowReddot(XDataCenter.GuildBossManager.IsReward()) +end + +--整体更新窗口数据入口 +function XUiGuildBossHall:UpdateInfo() + self.TxtLeftTime.text = XUiHelper.GetTime(XDataCenter.GuildBossManager.GetEndTime() - XTime.GetServerNowTimestamp(), XUiHelper.TimeFormatType.MAINBATTERY) + self.TxtTotalGuildScore.text = XUiHelper.GetLargeIntNumText(XDataCenter.GuildBossManager.GetTotalScore()) + self.TxtGuildRank.text = XDataCenter.GuildBossManager.MyGuildRank + self.RImgGuildHead:SetRawImage(XDataCenter.GuildManager.GetGuildIconId()) + self.GuildRankItemObj.gameObject:SetActiveEx(false) + + self:UpdateBossHp(0) + self.LogData = XDataCenter.GuildBossManager.GetLogs() + self:UpdateLogs() + self:UpdateRank() +end + +function XUiGuildBossHall:UpdateBossHp(damage) + --更新中间boss相关信息 + local bossMaxHp = XDataCenter.GuildBossManager.GetMaxBossHp() + local bossCurHp = XDataCenter.GuildBossManager.GetCurBossHp() - damage + local leftHpNum = math.floor(bossCurHp / (bossMaxHp / 100)) --剩余血量管数 + self.ImgBossHp.fillAmount = (bossCurHp - (leftHpNum * (bossMaxHp / 100))) / (bossMaxHp / 100) + self.TxtBossCurHp.text = XUiHelper.GetLargeIntNumText(bossCurHp) + self.PanelBossBack.gameObject:SetActiveEx(bossCurHp > 0) + self.PanelFinsh.gameObject:SetActiveEx(bossCurHp == 0) + self.TxtBossHpNum.text = leftHpNum + self.TxtBossHp.text = XUiHelper.GetLargeIntNumText(bossMaxHp) +end + +--更新左边作战日志 +function XUiGuildBossHall:UpdateLogs() + self:UpdateDynamicTable() +end + +function XUiGuildBossHall:UpdateDynamicTable() + self.LogDynamicTable:SetDataSource(self.LogData) + self.LogDynamicTable:ReloadDataASync(#self.LogData) +end + +--更新右边排行榜 +function XUiGuildBossHall:UpdateRank() + if self.RankType == GuildRankType.Player then + self.PlayerRankObj.gameObject:SetActiveEx(true) + self.GuildRankObj.gameObject:SetActiveEx(false) + XDataCenter.GuildBossManager.GuildBossPlayerRankRequest(function() self:UpdatePlayerRank() end) + elseif self.RankType == GuildRankType.Guild then + self.PlayerRankObj.gameObject:SetActiveEx(false) + self.GuildRankObj.gameObject:SetActiveEx(true) + local isSend = XDataCenter.GuildBossManager.GuildBossGuildRankRequest(function() self:UpdateGuildRank() end) + if isSend then + XDataCenter.GuildBossManager.GuildBossPlayerRankRequest(function() self:UpdatePlayerRankItem() end, true) -- 以保证本公会和排名上信息一致 + end + end +end + +--更新个人排行榜 +function XUiGuildBossHall:UpdatePlayerRank() + self.RankData = XDataCenter.GuildBossManager.GetAllRankList() + self.PlayerDynamicTable:SetDataSource(self.RankData) + self.PlayerDynamicTable:ReloadDataASync() + self.ImgEmptyPlayerRank.gameObject:SetActiveEx(#self.RankData == 0) + self:UpdatePlayerRankItem() +end + +function XUiGuildBossHall:UpdatePlayerRankItem() + --我的个人排行 + if self.MyRank == nil then + self.MyRank = XUiGuildBossPlayerRankItem.New(self.MyRankObj) + self.MyRank.GameObject:SetActiveEx(true) + end + local myRankData = XDataCenter.GuildBossManager.GetMyRankData() + local myRankNum = XDataCenter.GuildBossManager.GetMyRankNum() + self.MyRank:Init(myRankData, myRankNum) +end + +--更新工会排行榜 +function XUiGuildBossHall:UpdateGuildRank() + self.GuildRankData = XDataCenter.GuildBossManager.GetAllGuildRankList() + self.GUildDynamicTable:SetDataSource(self.GuildRankData) + self.GUildDynamicTable:ReloadDataASync() + self.ImgEmptyGuildRank.gameObject:SetActiveEx(#self.GuildRankData == 0) + --我工会的排行 + if self.MyGuildRank == nil then + self.MyGuildRank = XUiGuildBossGuildRankItem.New(self.MyGuildRankObj) + self.MyGuildRank.GameObject:SetActiveEx(true) + end + local myGuildRankData = XDataCenter.GuildBossManager.GetMyGuildRankData() + local myGuildRankNum = XDataCenter.GuildBossManager.GetMyGuildRankNum() + self.MyGuildRank:Init(myGuildRankData, myGuildRankNum) +end + +function XUiGuildBossHall:OnBtnBackClick() + self:Close() +end + +function XUiGuildBossHall:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiGuildBossHall:OnBtnStartClick() + XDataCenter.GuildBossManager.GuildBossActivityRequest(function() XLuaUiManager.Open("UiGuildBossStage") end) +end + +--切换排行榜 +function XUiGuildBossHall:OnBtnChangeClick() + if self.RankType == GuildRankType.Player then + self.BtnChange:SetName(self.GuildBossChangePlayerRankStr) + self.RankType = GuildRankType.Guild + elseif self.RankType == GuildRankType.Guild then + self.BtnChange:SetName(self.GuildBossChangeGuildRankStr) + self.RankType = GuildRankType.Player + end + self:UpdateRank() +end + +--展开详细记录 +function XUiGuildBossHall:OnBtnOpenRecordClick() + self.BtnOpenRecord.gameObject:SetActiveEx(false) + self.BtnCloseFullRecord.gameObject:SetActiveEx(true) + self.ImgUnfoldBack.gameObject:SetActiveEx(true) + self.PanelRecordViewRect.sizeDelta = CS.UnityEngine.Vector2(364, 780) + self:UpdateLogs() +end + +--关闭详细记录 +function XUiGuildBossHall:OnBtnCloseFullRecordClick() + self.BtnOpenRecord.gameObject:SetActiveEx(true) + self.BtnCloseFullRecord.gameObject:SetActiveEx(false) + self.ImgUnfoldBack.gameObject:SetActiveEx(false) + self.PanelRecordViewRect.sizeDelta = CS.UnityEngine.Vector2(364, 526) + self:UpdateLogs() +end + +function XUiGuildBossHall:OnBtnRankRewardClick() + XLuaUiManager.Open("UiGuildBossRankReward") +end + +--工会日志动态列表事件 +function XUiGuildBossHall:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:Init(self.LogData[index]) + end +end + +--工会排行榜动态列表事件 +function XUiGuildBossHall:OnGUildDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:Init(self.GuildRankData[index], index) + end +end + +--工会内部排行榜动态列表事件 +function XUiGuildBossHall:OnPlayerDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:Init(self.RankData[index], index) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuildBoss/XUiGuildBossMainLevelInfo.lua b/Resources/Scripts/XUi/XUiGuildBoss/XUiGuildBossMainLevelInfo.lua new file mode 100644 index 00000000..817d2e98 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuildBoss/XUiGuildBossMainLevelInfo.lua @@ -0,0 +1,110 @@ +--工会boss Boss关卡详细信息页面 +local XUiGuildBossLog = require("XUi/XUiGuildBoss/Component/XUiGuildBossLog") +local XUiGuildBossRankPanel = require("XUi/XUiGuildBoss/Component/XUiGuildBossRankPanel") +local XUiGuildBossMainLevelInfo = XLuaUiManager.Register(XLuaUi, "UiGuildBossMainLevelInfo") + +function XUiGuildBossMainLevelInfo:OnAwake() + self.BtnStart.CallBack = function() self:OnBtnStartClick() end + self.Instantiate = CS.UnityEngine.GameObject.Instantiate + self.VectorOne = CS.UnityEngine.Vector3.one + self.VectorZero = CS.UnityEngine.Vector3.zero + self.MaxCount = CS.XGame.Config:GetInt("GuildBossStageUploadCount") + self.GuildBossDeathAddScore = CS.XGame.Config:GetInt("GuildBossDeathAddScore") + self.RankPanel = XUiGuildBossRankPanel.New(self.PanelRankObj) + --Log相关 + self.BtnCloseFullRecord.CallBack = function() self:OnBtnCloseFullRecordClick() end + self.BtnOpenRecord.CallBack = function() self:OnBtnOpenRecordClick() end + self.LogDynamicTable = XDynamicTableIrregular.New(self.PanelRecordView) + self.LogDynamicTable:SetProxy("XUiGuildBossLog",XUiGuildBossLog, self.RecordItem.gameObject) + self.LogDynamicTable:SetDelegate(self) +end + +function XUiGuildBossMainLevelInfo:GetProxyType() + return "XUiGuildBossLog" +end + +function XUiGuildBossMainLevelInfo:OnStart(ui) + self.ParentUi = ui +end + +function XUiGuildBossMainLevelInfo:OnEnable() + self.Data = self.ParentUi.CurSelectLevelData + self.ConfigData = XGuildBossConfig.GetBossStageInfo(self.Data.StageId) + self.TxtCode.text = self.ConfigData.Code + self.TxtName.text = self.ConfigData.Name + self.TxtLimit.text = self.ConfigData.Limit + self.ImgIcon:SetSprite(self.ConfigData.Icon) + self.OrderMark.gameObject:SetActiveEx(false) + self.TxtIsDone.gameObject:SetActiveEx(self.Data.Score > 0) + self.GroupScore.gameObject:SetActiveEx(self.Data.Score > 0) + self.TxtScore.text = XUiHelper.GetLargeIntNumText(self.Data.Score) + self.TxtCount.text = CS.XTextManager.GetText("GuildBossCount", self.Data.UploadCount, self.MaxCount) + --bossHp + local bossMaxHp = XDataCenter.GuildBossManager.GetMaxBossHp() + local bossCurHp = XDataCenter.GuildBossManager.GetCurBossHp() + self.TxtCur.text = XUiHelper.GetLargeIntNumText(bossCurHp) + self.TxtMax.text = "/ " .. XUiHelper.GetLargeIntNumText(bossMaxHp) + self.ImgBossHp.fillAmount = bossCurHp / bossMaxHp + self.TxtBossDie.text = CS.XTextManager.GetText("GuildBossDie", self.GuildBossDeathAddScore) + self.PanelActive.gameObject:SetActiveEx(bossCurHp <= 0) + --Rank + self.RankPanel:Init(self.Data.StageId) + --log + self:RefreshLogList(true) +end + +function XUiGuildBossMainLevelInfo:RefreshLogList(reloadData) + if reloadData then + self.LogData = {} + local allLogData = XDataCenter.GuildBossManager.GetLogs() + if allLogData then + for i = 1, #allLogData do + if allLogData[i].StageId == self.Data.StageId then + table.insert(self.LogData, allLogData[i]) + end + end + end + self.LogDynamicTable:SetDataSource(self.LogData) + end + self.LogDynamicTable:ReloadDataASync(#self.LogData) +end + +function XUiGuildBossMainLevelInfo:OnBtnCloseClick() + self:Close() +end + +--Log动态列表事件 +function XUiGuildBossMainLevelInfo:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:Init(self.LogData[index]) + end +end + + +--展开详细记录 +function XUiGuildBossMainLevelInfo:OnBtnOpenRecordClick() + self.BtnOpenRecord.gameObject:SetActiveEx(false) + self.BtnCloseFullRecord.gameObject:SetActiveEx(true) + self.ImgUnfoldBack.gameObject:SetActiveEx(true) + self.PanelRecordViewRect.sizeDelta = CS.UnityEngine.Vector2(410, 900) + self.PanelRecordViewRect.anchoredPosition = CS.UnityEngine.Vector2(30, 950) + self:RefreshLogList() +end + +--关闭详细记录 +function XUiGuildBossMainLevelInfo:OnBtnCloseFullRecordClick() + self.BtnOpenRecord.gameObject:SetActiveEx(true) + self.BtnCloseFullRecord.gameObject:SetActiveEx(false) + self.ImgUnfoldBack.gameObject:SetActiveEx(false) + self.PanelRecordViewRect.sizeDelta = CS.UnityEngine.Vector2(410, 163) + self.PanelRecordViewRect.anchoredPosition = CS.UnityEngine.Vector2(30, 250) + self:RefreshLogList() +end + +function XUiGuildBossMainLevelInfo:OnBtnStartClick() + if self.Data.UploadCount == self.MaxCount then + XUiManager.TipError(CS.XTextManager.GetText("GuildBossCountFull")) + return + end + XLuaUiManager.Open("UiNewRoomSingle", self.Data.StageId) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuildBoss/XUiGuildBossNewRoomSingle.lua b/Resources/Scripts/XUi/XUiGuildBoss/XUiGuildBossNewRoomSingle.lua new file mode 100644 index 00000000..b7750af2 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuildBoss/XUiGuildBossNewRoomSingle.lua @@ -0,0 +1,78 @@ +-- 教学关出战界面代理 +local XUiGuildBossNewRoomSingle = {} +local CSXTextManagerGetText = CS.XTextManager.GetText + +function XUiGuildBossNewRoomSingle.InitEditBattleUi(newRoomSingle) + newRoomSingle.BtnTeamPrefab.gameObject:SetActiveEx(false) + --newRoomSingle.BtnTeamPrefab:SetButtonState(XUiButtonState.Disable) +end + +--function XUiGuildBossNewRoomSingle.InitEditBattleUiCharacterInfo(newRoomSingle) +-- newRoomSingle.BtnShowInfoToggle.gameObject:SetActiveEx(false) +-- newRoomSingle.IsShowCharacterInfo = 0 +--end + +function XUiGuildBossNewRoomSingle.GetBattleTeamData(newRoomSingle) + local typeId + local type = XDataCenter.GuildBossManager.GetCurSelectStageType() + if type == GuildBossLevelType.Low then + typeId = CS.XGame.Config:GetInt("TypeIdGuildBossLow") + elseif type == GuildBossLevelType.High then + typeId = CS.XGame.Config:GetInt("TypeIdGuildBossHigh") + elseif type == GuildBossLevelType.Boss then + typeId = CS.XGame.Config:GetInt("TypeIdGuildBossBoss") + end + local robotList = XDataCenter.GuildBossManager.GetStageRobotTab(newRoomSingle.CurrentStageId) + --所有合法的角色ID + local characterList = {} + for i = 1, #robotList do + table.insert(characterList, XRobotManager.GetCharacterId(robotList[i])) + table.insert(characterList, robotList[i]) + end + + local curTeam = XDataCenter.TeamManager.GetPlayerTeam(typeId) + --清除不符合规则的 + for i = 1, #curTeam.TeamData do + if curTeam.TeamData[i] > 0 then + local isOk = false + for j = 1, #characterList do + if curTeam.TeamData[i] == characterList[j] then + isOk = true + break + end + end + if not isOk then + curTeam.TeamData[i] = 0 + end + end + end + + return curTeam +end + +function XUiGuildBossNewRoomSingle.HandleCharClick(newRoomSingle, charPos) + local teamData = XTool.Clone(newRoomSingle.CurTeam.TeamData) + local robotList = XDataCenter.GuildBossManager.GetStageRobotTab(newRoomSingle.CurrentStageId) + XLuaUiManager.Open("UiSelectCharacterWin", function(resTeam) + newRoomSingle:UpdateTeam(resTeam) + end, UiSelectCharacterType.LimitedByCharacterAndRobot, teamData, charPos, robotList) +end + +function XUiGuildBossNewRoomSingle.UpdateTeam(newRoomSingle) + XDataCenter.TeamManager.SetPlayerTeam(newRoomSingle.CurTeam, false) +end + +function XUiGuildBossNewRoomSingle.GetIsCheckCaptainIdAndFirstFightId() + return true +end + +function XUiGuildBossNewRoomSingle.OnResetEvent(newRoomSingle) + XLuaUiManager.RunMain() + XUiManager.TipMsg(CSXTextManagerGetText("ArenaOnlineTimeOut")) +end + +function XUiGuildBossNewRoomSingle.UpdateFightControl(newRoomSingle, curTeam) + return XUiFightControlState.Normal +end + +return XUiGuildBossNewRoomSingle \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuildBoss/XUiGuildBossOtherSubLevelInfo.lua b/Resources/Scripts/XUi/XUiGuildBoss/XUiGuildBossOtherSubLevelInfo.lua new file mode 100644 index 00000000..cd198373 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuildBoss/XUiGuildBossOtherSubLevelInfo.lua @@ -0,0 +1,61 @@ +--工会boss普通其他关卡详细信息页面 +local XUiGuildBossLog = require("XUi/XUiGuildBoss/Component/XUiGuildBossLog") +local XUiGuildBossSkillGrid = require("XUi/XUiGuildBoss/Component/XUiGuildBossSkillGrid") +local XUiGuildBossRankPanel = require("XUi/XUiGuildBoss/Component/XUiGuildBossRankPanel") +local XUiGuildBossOtherSubLevelInfo = XLuaUiManager.Register(XLuaUi, "UiGuildBossOtherSubLevelInfo") + +function XUiGuildBossOtherSubLevelInfo:OnAwake() + --self.BtnClose.CallBack = function() self:OnBtnCloseClick() end + self.Instantiate = CS.UnityEngine.GameObject.Instantiate + self.VectorOne = CS.UnityEngine.Vector3.one + self.VectorZero = CS.UnityEngine.Vector3.zero + + self.Skill = XUiGuildBossSkillGrid.New(self.SkillGrid) + self.RankPanel = XUiGuildBossRankPanel.New(self.PanelRankObj) + + --Log相关 + self.LogDynamicTable = XDynamicTableIrregular.New(self.PanelRecordView) + self.LogDynamicTable:SetProxy("XUiGuildBossLog",XUiGuildBossLog, self.RecordItem.gameObject) + self.LogDynamicTable:SetDelegate(self) +end + +function XUiGuildBossOtherSubLevelInfo:GetProxyType() + return "XUiGuildBossLog" +end + +function XUiGuildBossOtherSubLevelInfo:OnStart(ui) + self.ParentUi = ui +end + +function XUiGuildBossOtherSubLevelInfo:OnEnable() + self.Data = self.ParentUi.CurSelectLevelData + self.ConfigData = XGuildBossConfig.GetBossStageInfo(self.Data.StageId) + --buff + self.Skill:Init(self.ConfigData, self.Data.BuffNeed) + --Rank + self.RankPanel:Init(self.Data.StageId) + --log + self.LogData = {} + local allLogData = XDataCenter.GuildBossManager.GetLogs() + if allLogData then + for i = 1, #allLogData do + if allLogData[i].StageId == self.Data.StageId then + table.insert(self.LogData, allLogData[i]) + end + end + end + self.LogDynamicTable:SetDataSource(self.LogData) + self.LogDynamicTable:ReloadDataASync() + self.PanelNull.gameObject:SetActiveEx(#self.LogData == 0) +end + +--Log动态列表事件 +function XUiGuildBossOtherSubLevelInfo:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:Init(self.LogData[index]) + end +end + +function XUiGuildBossOtherSubLevelInfo:OnBtnCloseClick() + self:Close() +end diff --git a/Resources/Scripts/XUi/XUiGuildBoss/XUiGuildBossRank.lua b/Resources/Scripts/XUi/XUiGuildBoss/XUiGuildBossRank.lua new file mode 100644 index 00000000..006159f8 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuildBoss/XUiGuildBossRank.lua @@ -0,0 +1,56 @@ +--工会boss关卡排行榜页面 +local XUiGuildBossRankItem = require("XUi/XUiGuildBoss/Component/XUiGuildBossRankItem") +local XUiGuildBossRank = XLuaUiManager.Register(XLuaUi, "UiGuildBossRank") + +function XUiGuildBossRank:OnAwake() + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + self:BindHelpBtn(self.BtnHelp, "GuildBossHelp") + self.DynamicTable = XDynamicTableNormal.New(self.BossRankList) + self.DynamicTable:SetProxy(XUiGuildBossRankItem) + self.DynamicTable:SetDelegate(self) + self.GridBossRank.gameObject:SetActiveEx(false) +end + +function XUiGuildBossRank:OnStart(stageId) + self.StageId = stageId + XDataCenter.GuildBossManager.GuildBossPlayerStageRankRequest(stageId, function() self:UpdateInfo() end) +end + +function XUiGuildBossRank:UpdateInfo() + self.RankData = XDataCenter.GuildBossManager.GetDetailLevelRankData(self.StageId) + self.DynamicTable:SetDataSource(self.RankData) + self.DynamicTable:ReloadDataASync() + self.PanelNoRank.gameObject:SetActiveEx(#self.RankData == 0) + + --我自己 + self.MyData = nil + for i = 1, #self.RankData do + if self.RankData[i].Id == XPlayer.Id then + self.MyData = self.RankData[i] + self.MyData.Rank = i + end + end + if self.MyData ~= nil then + self.TxtRank.text = self.MyData.Rank + self.TxtScore.text = self.MyData.Score + self.TxtName.text = self.MyData.Name + self.TxtRankName.text = XDataCenter.GuildManager.GetRankNameByLevel(self.MyData.RankLevel) + XUiPLayerHead.InitPortrait(self.MyData.HeadPortraitId, self.MyData.HeadFrameId, self.UObjHead) + end + self.PanelMyBossRank.gameObject:SetActiveEx(self.MyData ~= nil) +end + +function XUiGuildBossRank:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:Init(self.RankData[index], index) + end +end + +function XUiGuildBossRank:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiGuildBossRank:OnBtnBackClick() + self:Close() +end diff --git a/Resources/Scripts/XUi/XUiGuildBoss/XUiGuildBossRankReward.lua b/Resources/Scripts/XUi/XUiGuildBoss/XUiGuildBossRankReward.lua new file mode 100644 index 00000000..02dcf0a9 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuildBoss/XUiGuildBossRankReward.lua @@ -0,0 +1,49 @@ +local XUiGuildBossRankReward = XLuaUiManager.Register(XLuaUi, "UiGuildBossRankReward") +local XUiGuildBossRankRewardItem = require("XUi/XUiGuildBoss/Component/XUiGuildBossRankRewardItem") + +function XUiGuildBossRankReward:OnAwake() + self:InitComponent() +end + +function XUiGuildBossRankReward:OnStart() + +end + +function XUiGuildBossRankReward:OnDestroy() + +end + +function XUiGuildBossRankReward:InitComponent() + self.TxtTitle.text = CS.XTextManager.GetText("GuildBossRankRewardTitle") + self.TxtDesc.text = CS.XTextManager.GetText("GuildBossRankRewardDesc") + + self.BtnClose.CallBack = function() self:Close() end + + self.GridRankReward.gameObject:SetActiveEx(false) + self.RewardDynamicTable = XDynamicTableNormal.New(self.RankRewardList) + self.RewardDynamicTable:SetProxy(XUiGuildBossRankRewardItem, self) + self.RewardDynamicTable:SetDelegate(self) +end + +function XUiGuildBossRankReward:OnEnable() + self:Refresh() +end + +function XUiGuildBossRankReward:OnDisable() +end + + +function XUiGuildBossRankReward:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:Refresh(self.RankRewardData[index], index) + end +end + +-- override +function XUiGuildBossRankReward:Refresh() + self.RankRewardData = XGuildBossConfig.GeRankRewardIdList() + self.RewardDynamicTable:SetDataSource(self.RankRewardData) + self.RewardDynamicTable:ReloadDataASync() +end + +return XUiGuildBossRankReward \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuildBoss/XUiGuildBossSkill.lua b/Resources/Scripts/XUi/XUiGuildBoss/XUiGuildBossSkill.lua new file mode 100644 index 00000000..3b233a3c --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuildBoss/XUiGuildBossSkill.lua @@ -0,0 +1,40 @@ +--工会bossBuff页面 +local XUiGuildBossSkillGrid = require("XUi/XUiGuildBoss/Component/XUiGuildBossSkillGrid") +local XUiGuildBossSkill = XLuaUiManager.Register(XLuaUi, "UiGuildBossSkill") + +function XUiGuildBossSkill:OnAwake() + self.BtnClose.CallBack = function() self:OnBtnCloseClick() end + self.Instantiate = CS.UnityEngine.GameObject.Instantiate + self.VectorOne = CS.UnityEngine.Vector3.one + self.VectorZero = CS.UnityEngine.Vector3.zero + + self.Buffs = {} +end + +function XUiGuildBossSkill:OnStart() + self.LevelData = XDataCenter.GuildBossManager.GetLevelData() + for i = 1, #self.LevelData do + if self.LevelData[i].Type ~= GuildBossLevelType.Boss and self.Buffs[i] == nil then + self.Buffs[i] = XUiGuildBossSkillGrid.New(self.Instantiate(self.SkillGrid)) + --关卡类型 参考GuildBossData.tab + if self.LevelData[i].Type == GuildBossLevelType.Low then + self.Buffs[i].Transform:SetParent(self.SkillGroup1) + elseif self.LevelData[i].Type == GuildBossLevelType.High then + self.Buffs[i].Transform:SetParent(self.SkillGroup2) + end + + self.Buffs[i]:Init(XGuildBossConfig.GetBossStageInfo(self.LevelData[i].StageId), self.LevelData[i].BuffNeed, self.LevelData[i].NameOrder) + self.Buffs[i].Transform.localScale = self.VectorOne + self.Buffs[i].Transform.localPosition = self.VectorZero + self.Buffs[i].GameObject:SetActiveEx(true) + end + end +end + +function XUiGuildBossSkill:OnDestroy() + self.Buffs = {} +end + +function XUiGuildBossSkill:OnBtnCloseClick() + self:Close() +end diff --git a/Resources/Scripts/XUi/XUiGuildBoss/XUiGuildBossStage.lua b/Resources/Scripts/XUi/XUiGuildBoss/XUiGuildBossStage.lua new file mode 100644 index 00000000..44471bb2 --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuildBoss/XUiGuildBossStage.lua @@ -0,0 +1,569 @@ +--工会boss选关页面 +local XUiGuildBossStageLevel = require("XUi/XUiGuildBoss/Component/XUiGuildBossStageLevel") +local XUiGuildBossRewardItem = require("XUi/XUiGuildBoss/Component/XUiGuildBossRewardItem") +local XUiGuildBossHpReward = require("XUi/XUiGuildBoss/ChildView/XUiGuildBossHpReward") +local XUiGuildBossStage = XLuaUiManager.Register(XLuaUi, "UiGuildBossStage") + +function XUiGuildBossStage:OnAwake() + self.PanelHpReward = XUiGuildBossHpReward.New(self, self.PanelHpReward) + self.PanelHpReward:Close() + + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + self:BindHelpBtn(self.BtnHelp, "GuildBossHelp") + self.BtnDiff.CallBack = function() self:OnBtnDiffClick() end + self.BtnSkill.CallBack = function() self:OnBtnSkillClick() end + self.BtnBoss.CallBack = function() self:OnBtnBossClick() end + self.BtnDetail.CallBack = function() self:OnBtnDetailClick() end + self.BtnLayout.CallBack = function() self:OnBtnLayoutClick() end + self.BtnConfirm.CallBack = function() self:OnBtnConfirmClick() end + self.BtnBossHpRewardGet.CallBack = function() self:OnBtnBossHpRewardGetClick() end + self.BtnExitDetail.CallBack = function() self:OnBtnExitDetailClick() end + self.HpAnimationCB = function() end + + self.BtnBossHpRewardGet.gameObject:SetActiveEx(true) + self.BtnBossHpRewardGet:ShowReddot(false) + self.BtnReward.gameObject:SetActiveEx(false) + self.StageLevelObj.gameObject:SetActiveEx(false) + self.Instantiate = CS.UnityEngine.GameObject.Instantiate + self.VectorOne = CS.UnityEngine.Vector3.one + self.VectorSmall = CS.UnityEngine.Vector3(0.8, 0.8, 1) + self.VectorZero = CS.UnityEngine.Vector3.zero + self.Vector2 = CS.UnityEngine.Vector2 + self.Levels = {} + self.Rewards = {} + self.WindowMode = + { + Normal = 1, + Order = 2, --战术布局中 + LevelDetail = 3, --显示关卡详情 + } + self.CurWindowMode = self.WindowMode.Normal + self.Pos = {self.Pos1,self.Pos2,self.Pos3,self.Pos4,self.Pos5,self.Pos6,self.Pos7} + self.BtnExitDetail.gameObject:SetActiveEx(false) + self.PanelBattleInfo.gameObject:SetActiveEx(false) + self.IsFirstOpen = true + self.CurStageData = nil + self.hasHpReward = nil -- 是否有hp奖励 +end + +function XUiGuildBossStage:OnResume(data) + self.CurWindowMode = data.curWindowMode + self.CurStageData = data.curStageData +end + +function XUiGuildBossStage:OnReleaseInst() + return {curWindowMode = self.CurWindowMode, curStageData = self.CurStageData} +end + +function XUiGuildBossStage:OnEnable() + if self.IsFirstOpen then + self.IsFirstOpen = false + self:UpdatePage(0) + end + XEventManager.AddEventListener(XEventId.EVENT_GUILDBOSS_UPDATEORDER, self.UpdateAllOrderMark, self) +end + +function XUiGuildBossStage:OnDisable() + if self.AnimTimer then + XScheduleManager.UnSchedule(self.AnimTimer) + self.AnimTimer = nil + end + if self.AnimTimer2 then + XScheduleManager.UnSchedule(self.AnimTimer2) + self.AnimTimer2 = nil + end + XEventManager.RemoveEventListener(XEventId.EVENT_GUILDBOSS_UPDATEORDER, self.UpdateAllOrderMark, self) +end + +function XUiGuildBossStage:OnNotify(evt, ...) + local args = { ... } + + if evt == CS.XEventId.EVENT_UI_ALLOWOPERATE and args[1] == self.Ui then + if XDataCenter.GuildManager.GetGuildId() <= 0 then + XUiManager.TipMsg(CS.XTextManager.GetText("GuildKickOutByAdministor")) + XLuaUiManager.RunMain() + return + end + if not self.IsFirstOpen then + self:PlayBossAnimation() + end + end +end + +function XUiGuildBossStage:OnGetEvents() + return { CS.XEventId.EVENT_UI_ALLOWOPERATE } +end + +function XUiGuildBossStage:UpdateBossHp(damage) + --更新中间boss相关信息 + local bossMaxHp = XDataCenter.GuildBossManager.GetMaxBossHp() + local bossCurHp = XDataCenter.GuildBossManager.GetCurBossHp() + damage + local leftHpNum = math.floor(bossCurHp / (bossMaxHp / 100)) --剩余血量管数 + self.ImgBossHp.fillAmount = (bossCurHp - (leftHpNum * (bossMaxHp / 100))) / (bossMaxHp / 100) + self.TxtBossCurHp.text = XUiHelper.GetLargeIntNumText(bossCurHp) + self.PanelHpInfo.gameObject:SetActiveEx(bossCurHp > 0) + self.PanelFinish.gameObject:SetActiveEx(bossCurHp == 0) + self.TxtBossHpNum.text = leftHpNum + self.TxtBossLv.text = "Lv." .. XDataCenter.GuildBossManager.GetCurBossLevel() + self.TxtBossHp.text = XUiHelper.GetLargeIntNumText(bossMaxHp) +end + +--如果damage>0则需要播放boss扣血动画 +function XUiGuildBossStage:UpdatePage(damage) + + self:UpdateBossHp(damage) + + --更新显示关卡 + self.LevelData = XDataCenter.GuildBossManager.GetLevelData() + local lowLevelInfo = XDataCenter.GuildBossManager.GetLowLevelInfo() + local highLevelInfo = XDataCenter.GuildBossManager.GetHighLevelInfo() + for i = 1, #self.LevelData do + if self.LevelData[i].Type ~= GuildBossLevelType.Boss then + if self.Levels[i] == nil then + self.Levels[i] = XUiGuildBossStageLevel.New(self.Instantiate(self.StageLevelObj)) + end + self.Levels[i].Transform:SetParent(self.Pos[i].transform) + self.Levels[i]:Init(self.LevelData[i], self) + self.Levels[i].Transform.localPosition = self.VectorZero + self.Levels[i].Transform.localEulerAngles = self.VectorZero + self.Levels[i].OrderNum.transform.eulerAngles = self.VectorZero + self.Levels[i].GameObject:SetActiveEx(true) + + local curLevelInfo + if self.LevelData[i].Type == GuildBossLevelType.Low then + curLevelInfo = lowLevelInfo + else + curLevelInfo = highLevelInfo + end + if curLevelInfo ~= nil then + if curLevelInfo.StageId == self.LevelData[i].StageId then + self.Levels[i].Transform.localScale = self.VectorOne + self.Levels[i].ImgBlack.gameObject:SetActiveEx(false) + else + self.Levels[i].Transform.localScale = self.VectorSmall + self.Levels[i].ImgBlack.gameObject:SetActiveEx(true) + end + else + self.Levels[i].Transform.localScale = self.VectorOne + self.Levels[i].ImgBlack.gameObject:SetActiveEx(false) + end + end + end + + self:UpdatePanelReward() + self:XUiGuildBossHpReward() + self:UpdateAllOrderMark() +end + +--更新左边累计分数奖励及总分 +function XUiGuildBossStage:UpdatePanelReward() + local rewardData = XGuildBossConfig.ScoreRewards() + local lastScore = 0 -- 用于控制每段的进度条长度 + for i = 1, #rewardData do + if self.Rewards[i] == nil then + self.Rewards[i] = XUiGuildBossRewardItem.New(self.Instantiate(self.BtnReward.gameObject), self) + end + self.Rewards[i].Transform:SetParent(self.PanelRewardBtn.transform) + self.Rewards[i]:Init(rewardData[i], lastScore) + lastScore = rewardData[i].Score + self.Rewards[i].Transform.localScale = self.VectorOne + self.Rewards[i].Transform.position = self.BtnReward.transform.position + --self.Rewards[i].RectTransform.anchoredPosition = self.Vector2(self.Rewards[i].RectTransform.anchoredPosition.x, 100 * i) + self.Rewards[i].Transform.localEulerAngles = self.VectorZero + self.Rewards[i].GameObject:SetActiveEx(true) + end + self.PanelRewardLayout:SetDirty() + self.BtnDetail:SetName(XUiHelper.GetLargeIntNumText(XDataCenter.GuildBossManager.GetMyTotalScore())) +end + +function XUiGuildBossStage:OnBtnRewardClick(rewardData) + XDataCenter.GuildBossManager.GuildBossScoreBoxRequest(rewardData.Id, function() self:UpdatePanelReward() end) +end + +--更新右上boss血量阶段奖励 +function XUiGuildBossStage:XUiGuildBossHpReward() + --当前领到第几阶段 + self.CurBossHpReward = XDataCenter.GuildBossManager.GetHpBoxGot() + --奖励数据 + local hpRewardData = XGuildBossConfig.HpRewards() + --全部领完 + if self.CurBossHpReward >= #hpRewardData then + self.RewardGrids.gameObject:SetActiveEx(false) + self.TxtBossRewardDone.gameObject:SetActiveEx(true) + -- self.BtnBossHpRewardGet.gameObject:SetActiveEx(false) + self.hasHpReward = false + self.TxtTargetBlood.text = hpRewardData[self.CurBossHpReward].HpPercent + else + self.RewardGrids.gameObject:SetActiveEx(true) + self.TxtBossRewardDone.gameObject:SetActiveEx(false) + local curHpPrecent = XDataCenter.GuildBossManager.GetCurBossHp() / XDataCenter.GuildBossManager.GetMaxBossHp() * 100 + self.TxtTargetBlood.text = hpRewardData[self.CurBossHpReward + 1].HpPercent + --可以领下一档 + if curHpPrecent <= hpRewardData[self.CurBossHpReward + 1].HpPercent then + -- self.BtnBossHpRewardGet.gameObject:SetActiveEx(true) + self.hasHpReward = true + --不能领 + else + -- self.BtnBossHpRewardGet.gameObject:SetActiveEx(false) + self.hasHpReward = false + end + --下一档的奖励Grid + local rewardList = XRewardManager.GetRewardList(XDataCenter.GuildBossManager.GetHpRewardId(self.CurBossHpReward + 1)) + self.GuildBossHpRewardGrid1 = XUiGridCommon.New(self, self.BossHpRewardGrid1Obj) + self.GuildBossHpRewardGrid1:Refresh(rewardList[1]) + self.GuildBossHpRewardGrid2 = XUiGridCommon.New(self, self.BossHpRewardGrid2Obj) + self.GuildBossHpRewardGrid2:Refresh(rewardList[2]) + end + self.BtnBossHpRewardGet:ShowReddot(self.hasHpReward) +end + +function XUiGuildBossStage:OnBtnBossHpRewardGetClick() + if self.hasHpReward then + XDataCenter.GuildBossManager.GuildBossHpBoxRequest(self.CurBossHpReward + 1, function() self:XUiGuildBossHpReward() end) + else + self:PlayAnimation("PanelHpRewardEnable", self.HpAnimationCB) + self.PanelHpReward:Show() + end +end + +function XUiGuildBossStage:ResetToNormal(cb) + self:ChangeMode(self.WindowMode.Normal, cb) + if self.ChildName then + self:CloseChildUi(self.ChildName) + end + --清除所有选中效果 + for i = 1, #self.Levels do + self.Levels[i].ImgSelect.gameObject:SetActiveEx(false) + end + self.ImgBossSelect.gameObject:SetActiveEx(false) +end + +function XUiGuildBossStage:OnBtnBackClick() + if self.CurWindowMode == self.WindowMode.LevelDetail then + self:ResetToNormal() + elseif self.CurWindowMode == self.WindowMode.Order then + self:ChangeMode(self.WindowMode.Normal) + else + self:Close() + end +end + +function XUiGuildBossStage:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiGuildBossStage:OnBtnDiffClick() + XLuaUiManager.Open("UiGuildBossDiff") +end + +function XUiGuildBossStage:OnBtnSkillClick() + XLuaUiManager.Open("UiGuildBossSkill") +end + +function XUiGuildBossStage:OnBtnDetailClick() + XLuaUiManager.Open("UiGuildBossDetail") +end + +--点击关卡回调 +function XUiGuildBossStage:OnStageLevelClick(data, btnStage) + self.CurStageData = data + XDataCenter.GuildBossManager.SetCurSelectStageType(self.CurStageData.Type) + if self.CurWindowMode == self.WindowMode.Normal or self.CurWindowMode == self.WindowMode.LevelDetail then + XDataCenter.GuildBossManager.GuildBossStageRequest(data.StageId, function() self:OpenStageDetail(data) end) + --指挥模式下点击关卡设置优先度 + elseif self.CurWindowMode == self.WindowMode.Order then + local curOrderPos = XDataCenter.GuildBossManager.GetStageDataPos(data) + local allLevelData = XDataCenter.GuildBossManager.GetLevelData() + if data.Type == GuildBossLevelType.Low then + if self.OrderData[curOrderPos] == 0 then + self.OrderData[curOrderPos] = self.ToSetLowNum + btnStage:SetOrder(self.ToSetLowNum) + self.ToSetLowNum = self.ToSetLowNum + 1 + else + self.ToSetLowNum = self.OrderData[curOrderPos] + for i = 1, #self.OrderData do + if allLevelData[i].Type == GuildBossLevelType.Low then + if self.OrderData[i] >= self.ToSetLowNum then + self.OrderData[i] = 0 + end + self:GetLevelByStageId(allLevelData[i].StageId):SetOrder(self.OrderData[i]) + end + end + end + elseif data.Type == GuildBossLevelType.High then + if self.OrderData[curOrderPos] == 0 then + self.OrderData[curOrderPos] = self.ToSetHighNum + btnStage:SetOrder(self.ToSetHighNum) + self.ToSetHighNum = self.ToSetHighNum + 1 + else + self.ToSetHighNum = self.OrderData[curOrderPos] + for i = 1, #self.OrderData do + if allLevelData[i].Type == GuildBossLevelType.High then + if self.OrderData[i] >= self.ToSetHighNum then + self.OrderData[i] = 0 + end + self:GetLevelByStageId(allLevelData[i].StageId):SetOrder(self.OrderData[i]) + end + end + end + end + end +end + +function XUiGuildBossStage:OpenStageDetail(data) + --选中效果 + self.ImgBossSelect.gameObject:SetActiveEx(false) + if self.CurSelectLevelData ~= nil then + local curLevel = self:GetLevelByStageId(self.CurSelectLevelData.StageId) + if curLevel then + curLevel.ImgSelect.gameObject:SetActiveEx(false) + end + end + self:GetLevelByStageId(data.StageId).ImgSelect.gameObject:SetActiveEx(true) + + self.CurSelectLevelData = data + self:ChangeMode(self.WindowMode.LevelDetail) + --如果是boss关卡 + if data.Type == GuildBossLevelType.Boss then + XLuaUiManager.Open("UiGuildBossMainLevelInfo", self) + self.ChildName = "UiGuildBossMainLevelInfo" + else + --普通关卡有两种情况,如果某个区打过关卡A,选中关卡A和非关卡A打开页面不同 + --如果是低浓度区 + if data.Type == GuildBossLevelType.Low then + local lowLevelInfo = XDataCenter.GuildBossManager.GetLowLevelInfo() + if lowLevelInfo ~= nil then + if lowLevelInfo.StageId == data.StageId then + self:OpenOneChildUi("UiGuildBossCurSubLevelInfo", self) + self.ChildName = "UiGuildBossCurSubLevelInfo" + else + self:OpenOneChildUi("UiGuildBossOtherSubLevelInfo", self) + self.ChildName = "UiGuildBossOtherSubLevelInfo" + end + else + self:OpenOneChildUi("UiGuildBossCurSubLevelInfo", self) + self.ChildName = "UiGuildBossCurSubLevelInfo" + end + --如果是重灾区 + elseif data.Type == GuildBossLevelType.High then + local highLevelInfo = XDataCenter.GuildBossManager.GetHighLevelInfo() + if highLevelInfo ~= nil then + if highLevelInfo.StageId == data.StageId then + self:OpenOneChildUi("UiGuildBossCurSubLevelInfo", self) + self.ChildName = "UiGuildBossCurSubLevelInfo" + else + self:OpenOneChildUi("UiGuildBossOtherSubLevelInfo", self) + self.ChildName = "UiGuildBossOtherSubLevelInfo" + end + else + self:OpenOneChildUi("UiGuildBossCurSubLevelInfo", self) + self.ChildName = "UiGuildBossCurSubLevelInfo" + end + end + end +end + +function XUiGuildBossStage:GetLevelByStageId(stageId) + for i = 1, #self.Levels do + if self.Levels[i].Data.StageId == stageId then + return self.Levels[i] + end + end + return nil +end + +--点击中间的boss关卡 +function XUiGuildBossStage:OnBtnBossClick() + if self.CurWindowMode == self.WindowMode.Order then + return + end + --选中效果 + + self.ImgBossSelect.gameObject:SetActiveEx(true) + if self.CurSelectLevelData ~= nil then + local curLevel = self:GetLevelByStageId(self.CurSelectLevelData.StageId) + if curLevel then + curLevel.ImgSelect.gameObject:SetActiveEx(false) + end + end + + self.CurSelectLevelData = XDataCenter.GuildBossManager.GetBossLevelInfo() + self.CurStageData = self.CurSelectLevelData + XDataCenter.GuildBossManager.SetCurSelectStageType(self.CurStageData.Type) + XDataCenter.GuildBossManager.GuildBossStageRequest(self.CurSelectLevelData.StageId, function() + self:OpenOneChildUi("UiGuildBossMainLevelInfo", self) + self.ChildName = "UiGuildBossMainLevelInfo" + self:ChangeMode(self.WindowMode.LevelDetail) + end) +end + +--详情模式下点击空白出退出 +function XUiGuildBossStage:OnBtnExitDetailClick() + if self.CurWindowMode == self.WindowMode.LevelDetail then + self:ResetToNormal() + end +end + +--确认发布战术布局 +function XUiGuildBossStage:OnBtnConfirmClick() + if self.CurWindowMode == self.WindowMode.Order then + --判断是否设置完全 + for key, value in pairs(self.OrderData) do + if value == 0 then + XUiManager.TipError(CS.XTextManager.GetText("GuildBossLayoutError")) + return + end + end + --保存设置并退出布局模式 + local orderStr = "" + for i = 1, #self.OrderData do + orderStr = orderStr .. tostring(self.OrderData[i]) + end + XDataCenter.GuildBossManager.GuildBossSetOrderRequest(orderStr, self:ChangeMode(self.WindowMode.Normal)) + end +end + +--点击布局按钮,开始布局模式 +function XUiGuildBossStage:OnBtnLayoutClick() + --判断模式 + if self.CurWindowMode == self.WindowMode.Normal then + --判断权限 + local curRank = XDataCenter.GuildManager.GetCurRankLevel() + if curRank == XGuildConfig.GuildRankLevel.CoLeader or curRank == XGuildConfig.GuildRankLevel.Leader then + --切换模式 + self:ChangeMode(self.WindowMode.Order) + else + local leaderStr = XDataCenter.GuildManager.GetRankNameByLevel(XGuildConfig.GuildRankLevel.Leader) + local coleaderStr = XDataCenter.GuildManager.GetRankNameByLevel(XGuildConfig.GuildRankLevel.CoLeader) + XUiManager.TipError(CS.XTextManager.GetText("GuildBossLayoutRankLevelError", leaderStr, coleaderStr)) + end + end +end + +--切换模式:普通模式/战术布局 +function XUiGuildBossStage:ChangeMode(mode, cb) + --退出布局的时候 + if self.CurWindowMode == self.WindowMode.Order and mode == self.WindowMode.Normal then + self:PlayAnimation("AniConfirmLayoutDisable", cb) + --清除布局标签 + for i = 1, #self.Levels do + self.Levels[i]:HideOrder() + end + self.BtnExitDetail.gameObject:SetActiveEx(false) + self:UpdateAllOrderMark() + --进入布局的时候 + elseif self.CurWindowMode == self.WindowMode.Normal and mode == self.WindowMode.Order then + self:PlayAnimation("AniConfirmLayoutEnable", cb) + self.OrderData = {} + for i = 1, XDataCenter.GuildBossManager.GetStageCount() do + table.insert(self.OrderData, i, 0) + end + self.ToSetLowNum = 1 + self.ToSetHighNum = 1 + self.BtnExitDetail.gameObject:SetActiveEx(false) + --从普通状态进入关卡详情 + elseif self.CurWindowMode == self.WindowMode.Normal and mode == self.WindowMode.LevelDetail then + self:PlayAnimation("AniMainStageEnable", cb) + self.BtnExitDetail.gameObject:SetActiveEx(true) + --退出关卡详情到普通状态 + elseif self.CurWindowMode == self.WindowMode.LevelDetail and mode == self.WindowMode.Normal then + self:PlayAnimation("AniMainStageDisable", cb) + self.BtnExitDetail.gameObject:SetActiveEx(false) + end + self.CurWindowMode = mode +end + +--设置优先标签 +function XUiGuildBossStage:UpdateAllOrderMark() + self:UpdateOrderMark(GuildBossLevelType.Low) + self:UpdateOrderMark(GuildBossLevelType.High) +end + +function XUiGuildBossStage:UpdateOrderMark(type) + self.LevelData = XDataCenter.GuildBossManager.GetLevelData() + local minLevel = nil + for i = 1, #self.LevelData do + if self.LevelData[i].Type == type then + local levelComponent = self:GetLevelByStageId(self.LevelData[i].StageId) + levelComponent:SetOrderMark(false) + if self.LevelData[i].BuffNeed < 100 and self.LevelData[i].Order ~= 0 then + if minLevel == nil then + minLevel = levelComponent + else + if minLevel.Data.Order > self.LevelData[i].Order then + minLevel = levelComponent + end + end + end + end + end + if minLevel ~= nil then + minLevel:SetOrderMark(true) + end +end + +function XUiGuildBossStage:PlayBossAnimation() + --本次战斗造成的伤害 + local damage = XDataCenter.GuildBossManager.GetCurFightBossHp() + local contribute = XDataCenter.GuildBossManager.GetCurFightContribute() + + if XDataCenter.GuildBossManager.IsNeedUpdateStageInfo() then + XDataCenter.GuildBossManager.SetNeedUpdateStageInfo(false) + XDataCenter.GuildBossManager.GuildBossActivityRequest(function() self:UpdatePage(damage) end, true) + self:ResetToNormal(function() + if damage > 0 then + self.TxtBossDamage.text = damage + self.TxtContribute.text = CS.XTextManager.GetText("GuildBossContribute", contribute) + self.PanelBattleInfo.gameObject:SetActiveEx(true) + local bossHpAnimTime = CS.XGame.ClientConfig:GetFloat("GuildBossHpAnimTime") + local bossHpEffectTime = CS.XGame.ClientConfig:GetFloat("GuildBossHpEffectTime") + + self.CurStageObj = self:GetLevelByStageId(self.CurStageData.StageId) + if self.CurStageData.Type == GuildBossLevelType.Boss then + self.PanelBossHpEffect.gameObject:SetActiveEx(false) + self.PanelBossHpEffect.gameObject:SetActiveEx(true) + self.PanelBossStageEffect.gameObject:SetActiveEx(false) + self.PanelBossStageEffect.gameObject:SetActiveEx(true) + else + self.CurStageObj.PaneStagelEffect.gameObject:SetActiveEx(false) + self.CurStageObj.PaneStagelEffect.gameObject:SetActiveEx(true) + self.PanelBossHpEffect.gameObject:SetActiveEx(false) + self.PanelBossHpEffect.gameObject:SetActiveEx(true) + end + self.AnimTimer = XScheduleManager.ScheduleOnce(function() + --刷新数据 + self.CurStageData = XDataCenter.GuildBossManager.GetLevelDataByStageId(self.CurStageData.StageId) + if self.CurStageData.BuffNeed >= 100 then + local activityId = XSaveTool.GetData("GuildBossStageSkill" .. self.CurStageData.StageId .. XPlayer.Id) + if not activityId or activityId ~= XDataCenter.GuildBossManager.GetActivityId() then + XSaveTool.SaveData("GuildBossStageSkill" .. self.CurStageData.StageId .. XPlayer.Id, XDataCenter.GuildBossManager.GetActivityId()) + self.CurStageObj.PaneStagelSkillEffect.gameObject:SetActiveEx(false) + self.CurStageObj.PaneStagelSkillEffect.gameObject:SetActiveEx(true) + end + end + self.AnimTimer2 = XUiHelper.Tween(bossHpAnimTime, function(f) self:UpdateBossHp(math.floor(damage * (1 - f))) end, + function() + self.PanelBossHpEffect.gameObject:SetActiveEx(false) + if self.CurStageObj then + self.CurStageObj.PaneStagelEffect.gameObject:SetActiveEx(false) + self.CurStageObj.PaneStagelSkillEffect.gameObject:SetActiveEx(false) + end + self.PanelBossStageEffect.gameObject:SetActiveEx(false) + self.PanelBattleInfo.gameObject:SetActiveEx(false) + end) + end, math.floor(bossHpEffectTime * 1000)) + XDataCenter.GuildBossManager.SetCurFightBossHp(0) + end + end) + end +end + +function XUiGuildBossStage:UpdateCurSelectLevelData() + self.LevelData = XDataCenter.GuildBossManager.GetLevelData() + for i = 1, #LevelData do + if self.CurSelectLevelData.StageId == self.LevelData[i].StageId then + self.CurSelectLevelData = self.LevelData[i] + end + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiGuildBoss/XUiGuildBossTip.lua b/Resources/Scripts/XUi/XUiGuildBoss/XUiGuildBossTip.lua new file mode 100644 index 00000000..9bc8a28e --- /dev/null +++ b/Resources/Scripts/XUi/XUiGuildBoss/XUiGuildBossTip.lua @@ -0,0 +1,29 @@ +--工会boss击败boss弹窗 +local UiGuildBossTip = XLuaUiManager.Register(XLuaUi, "UiGuildBossTip") + +function UiGuildBossTip:OnAwake() + self.BtnClose.CallBack = function() + self:Close() + end + self.BtnGo.CallBack = function() + self:Close() + XDataCenter.GuildBossManager.OpenGuildBossHall() + end +end + +function UiGuildBossTip:OnEnable() + self:RefreshView() +end + +function UiGuildBossTip:OnDestroy() + XEventManager.DispatchEvent(XEventId.EVENT_FUNCTION_EVENT_COMPLETE) +end + +function UiGuildBossTip:OnStart() + self.TxtTitle.text = CS.XTextManager.GetText("GuildBossTipTitle") + self.TxtDesc.text = CS.XTextManager.GetText("GuildBossTipDesc") +end + +function UiGuildBossTip:RefreshView() + self.TxtBossLv.text = "Lv." .. XDataCenter.GuildBossManager.GetKilledBossLv() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiHelpCourse/XUiGridHelpCourse.lua b/Resources/Scripts/XUi/XUiHelpCourse/XUiGridHelpCourse.lua new file mode 100644 index 00000000..243d72bd --- /dev/null +++ b/Resources/Scripts/XUi/XUiHelpCourse/XUiGridHelpCourse.lua @@ -0,0 +1,16 @@ +local XUiGridHelpCourse = XClass(nil, "XUiGridHelpCourse") + +function XUiGridHelpCourse:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiGridHelpCourse:Refresh(icon, index, length) + self.GridHelp:SetRawImage(icon) + self.ImgArrowNext.gameObject:SetActive(length > index) + self.TxtPages.text = tostring(length) + self.TxtNumber.text = tostring(index) +end + +return XUiGridHelpCourse \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiHelpCourse/XUiHelp.lua b/Resources/Scripts/XUi/XUiHelpCourse/XUiHelp.lua new file mode 100644 index 00000000..adae928a --- /dev/null +++ b/Resources/Scripts/XUi/XUiHelpCourse/XUiHelp.lua @@ -0,0 +1,43 @@ +local XUiHelp = XLuaUiManager.Register(XLuaUi, "UiHelp") +local XUiGridHelpCourse = require("XUi/XUiHelpCourse/XUiGridHelpCourse") + +function XUiHelp:OnAwake() + +end + +function XUiHelp:OnStart(config, cb) + self.Config = config + self.Cb = cb + self:RegisterClickEvent(self.BtnMask, self.OnBtnMaskClick) + self:InitDynamicTable() +end + +function XUiHelp:InitDynamicTable() + self.DynamicTable = XDynamicTableCurve.New(self.PanelHelp.gameObject) + self.DynamicTable:SetProxy(XUiGridHelpCourse) + self.DynamicTable:SetDelegate(self) +end + +function XUiHelp:OnEnable() + if not self.Config then + return + end + self.Icons = self.Config.ImageAsset + self.Length = #self.Icons + self.DynamicTable:SetDataSource(self.Config.ImageAsset) + self.DynamicTable:ReloadData() +end + +--动态列表事件 +function XUiHelp:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:Refresh(self.Icons[index + 1], index + 1, self.Length) + end +end + +function XUiHelp:OnBtnMaskClick() + if self.Cb then + self.Cb() + end + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiHelpCourse/XUiHelpNew.lua b/Resources/Scripts/XUi/XUiHelpCourse/XUiHelpNew.lua new file mode 100644 index 00000000..3226b172 --- /dev/null +++ b/Resources/Scripts/XUi/XUiHelpCourse/XUiHelpNew.lua @@ -0,0 +1,107 @@ +local XUiHelpNew = XLuaUiManager.Register(XLuaUi, "UiHelpNew") +local XUiGridHelpCourse = require("XUi/XUiHelpCourse/XUiGridHelpCourse") + +function XUiHelpNew:OnAwake() + self.TabPool = {} + +end + +function XUiHelpNew:OnStart(configs, cb) + self.Configs = configs + self.Cb = cb + self.CurIndex = 1 + self.Tab.gameObject:SetActiveEx(false) + + self:SetupTab() + self:RegisterClickEvent(self.BtnMask, self.OnBtnMaskClick) + self.BtnClose.CallBack = function() self:OnBtnCloseClick() end + + self:InitDynamicTable() +end + +function XUiHelpNew:InitDynamicTable() + self.DynamicTable = XDynamicTableCurve.New(self.PanelHelp.gameObject) + self.DynamicTable:SetProxy(XUiGridHelpCourse) + self.DynamicTable:SetDelegate(self) +end + +function XUiHelpNew:OnEnable() + self:ReloadData() +end + +function XUiHelpNew:ReloadData() + if not self.Configs then + return + end + + local config = self.Configs[self.CurIndex] + + self.Icons = config.ImageAsset + self.Length = #self.Icons + self.DynamicTable:SetDataSource(config.ImageAsset) + self.DynamicTable:ReloadData() +end + +--动态列表事件 +function XUiHelpNew:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:Refresh(self.Icons[index + 1], index + 1, self.Length) + end +end + +function XUiHelpNew:OnBtnMaskClick() + if self.Cb then + self.Cb() + end + self:Close() +end + + +function XUiHelpNew:OnBtnCloseClick() + self:Close() +end + +--设置章节 +function XUiHelpNew:SetupTab() + if not self.Configs then + return + end + + --小型缓冲池 + if self.BtnTabList and #self.BtnTabList then + for i, v in ipairs(self.BtnTabList) do + table.insert(self.TabPool, v) + v.gameObject:SetActive(false) + end + end + + self.BtnTabList = {} + for i, v in ipairs(self.Configs) do + if not self.TabPool or #self.TabPool <= 0 then + local go = CS.UnityEngine.GameObject.Instantiate(self.Tab.gameObject) + go.transform:SetParent(self.TabGroup.transform, false) + local btn = go:GetComponent("XUiButton") + table.insert(self.TabPool, btn) + end + + local tab = table.remove(self.TabPool, 1) + tab.gameObject:SetActive(true) + table.insert(self.BtnTabList, tab) + + tab:SetName(v.Name) + end + + -- 初始化按钮 + self.TabGroup:Init(self.BtnTabList, function(index) self:OnBtnTabListClick(index) end) + self.TabGroup:SelectIndex(self.CurIndex) +end + + +function XUiHelpNew:OnBtnTabListClick(index) + if self.CurIndex == index then + return + end + + self.CurIndex = index + self:ReloadData() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiHomeMain/XUiHomeMain.lua b/Resources/Scripts/XUi/XUiHomeMain/XUiHomeMain.lua new file mode 100644 index 00000000..42de30d8 --- /dev/null +++ b/Resources/Scripts/XUi/XUiHomeMain/XUiHomeMain.lua @@ -0,0 +1,160 @@ +local XUiHomeMain = XLuaUiManager.Register(XLuaUi, "UiHomeMain") + +function XUiHomeMain:OnAwake() + self:InitAutoScript() +end + +function XUiHomeMain:OnStart(type) + + self.Type = type + self:ChangeBtnList() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.Coin, XDataCenter.ItemManager.ItemId.HostelElectric, XDataCenter.ItemManager.ItemId.HostelMat) + --CS.XUiManager.DialogManager:Pop() + XLuaUiManager.Close("UiLoading") + self:ShowMenu(false) + --CS.XUiManager.UiModelCamera.gameObject:SetActive(false) + self.PanelMain.gameObject:SetActive(false)--暂时屏蔽 + self.PanelAsset.gameObject:SetActive(false)--暂时屏蔽 +end + +function XUiHomeMain:OnEnable() + self:ShowMenu(false) +end + +function XUiHomeMain:OnDestroy() + XHomeSceneManager.LeaveScene() + --CS.XUiManager.UiModelCamera.gameObject:SetActive(true) +end + +function XUiHomeMain:OnDisable() + -- +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiHomeMain:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiHomeMain:AutoInitUi() + self.PanelBg = self.Transform:Find("FullScreenBackground/PanelBg") + self.PanelMenu = self.Transform:Find("SafeAreaContentPane/PanelMenu") + self.BtnVisitFriend = self.Transform:Find("SafeAreaContentPane/PanelMenu/BtnVisitFriend"):GetComponent("Button") + self.BtnFuncArea = self.Transform:Find("SafeAreaContentPane/PanelMenu/BtnFuncArea"):GetComponent("Button") + self.BtnFloorOne = self.Transform:Find("SafeAreaContentPane/PanelMenu/BtnFloorOne"):GetComponent("Button") + self.BtnFloorTwo = self.Transform:Find("SafeAreaContentPane/PanelMenu/BtnFloorTwo"):GetComponent("Button") + self.BtnFloorThree = self.Transform:Find("SafeAreaContentPane/PanelMenu/BtnFloorThree"):GetComponent("Button") + self.PanelMain = self.Transform:Find("SafeAreaContentPane/PanelMain") + self.BtnJumpMenu = self.Transform:Find("SafeAreaContentPane/PanelMain/BtnJumpMenu"):GetComponent("Button") + self.BtnAssignChar = self.Transform:Find("SafeAreaContentPane/PanelMain/BtnAssignChar"):GetComponent("Button") + self.PanelAsset = self.Transform:Find("SafeAreaContentPane/PanelAsset") + self.PanelTool1 = self.Transform:Find("SafeAreaContentPane/PanelAsset/PanelTool1") + self.PanelTool2 = self.Transform:Find("SafeAreaContentPane/PanelAsset/PanelTool2") + self.PanelTool3 = self.Transform:Find("SafeAreaContentPane/PanelAsset/PanelTool3") + self.PanelCharTopButton = self.Transform:Find("SafeAreaContentPane/PanelCharTopButton") + self.BtnBack = self.Transform:Find("SafeAreaContentPane/PanelCharTopButton/BtnBack"):GetComponent("Button") + self.BtnMainUi = self.Transform:Find("SafeAreaContentPane/PanelCharTopButton/BtnMainUi"):GetComponent("Button") +end + +function XUiHomeMain:GetAutoKey(uiNode, eventName) + if not uiNode then + return + end + return eventName .. uiNode:GetHashCode() +end + +function XUiHomeMain:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then + return + end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiHomeMain:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiHomeMain:AutoAddListener() + self.AutoCreateListeners = {} + self:RegisterClickEvent(self.BtnVisitFriend, self.OnBtnVisitFriendClick) + self:RegisterClickEvent(self.BtnFuncArea, self.OnBtnFuncAreaClick) + self:RegisterClickEvent(self.BtnFloorOne, self.OnBtnFloorOneClick) + self:RegisterClickEvent(self.BtnFloorTwo, self.OnBtnFloorTwoClick) + self:RegisterClickEvent(self.BtnFloorThree, self.OnBtnFloorThreeClick) + self:RegisterClickEvent(self.BtnJumpMenu, self.OnBtnJumpMenuClick) + self:RegisterClickEvent(self.BtnAssignChar, self.OnBtnAssignCharClick) + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) +end +-- auto + +function XUiHomeMain:OnBtnVisitFriendClick() + +end + +function XUiHomeMain:OnBtnFuncAreaClick() + XHomeInfrastructureManager.EnterInfrastructure() +end + +function XUiHomeMain:OnBtnFloorOneClick() + +end + +function XUiHomeMain:OnBtnFloorTwoClick() + +end + +function XUiHomeMain:OnBtnFloorThreeClick() + +end + +function XUiHomeMain:OnBtnJumpMenuClick() + local show = not self.IsShowMenu + self:ShowMenu(show) +end + +function XUiHomeMain:OnBtnAssignCharClick() + XLuaUiManager.Open("UiHostelRest") + self:ShowMenu(false) +end + +function XUiHomeMain:OnBtnBackClick() + -- if not XHomeSceneManager.ChangeBackToOverView() then + -- CS.XUiManager.ViewManager:Pop() + -- end + + XHomeInfrastructureManager.ChangeCameraToScene() + XLuaUiManager.RunMain()--临时返回主界面 +end + +function XUiHomeMain:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiHomeMain:ShowMenu(show) + show = show or false + self.IsShowMenu = show + self.PanelMenu.gameObject:SetActive(show) +end + +function XUiHomeMain:ChangeBtnList() + if self.Type == XDataCenter.HostelManager.SceneType.Function then + self.BtnFuncArea.gameObject:SetActive(false) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiHostelCharacterWork/XUiHostelCharacterWork.lua b/Resources/Scripts/XUi/XUiHostelCharacterWork/XUiHostelCharacterWork.lua new file mode 100644 index 00000000..9feb8ef8 --- /dev/null +++ b/Resources/Scripts/XUi/XUiHostelCharacterWork/XUiHostelCharacterWork.lua @@ -0,0 +1,245 @@ +local XUiHostelCharacterWork = XUiManager.Register("UiHostelCharacterWork") +local table_insert = table.insert +-- auto +-- Automatic generation of code, forbid to edit +function XUiHostelCharacterWork:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiHostelCharacterWork:AutoInitUi() + self.PanelAsset = self.Transform:Find("SafeAreaContentPane/PanelAsset") + self.PanelTool1 = self.Transform:Find("SafeAreaContentPane/PanelAsset/PanelTool1") + self.ImgTool1 = self.Transform:Find("SafeAreaContentPane/PanelAsset/PanelTool1/ImgTool1"):GetComponent("Image") + self.TxtTool1 = self.Transform:Find("SafeAreaContentPane/PanelAsset/PanelTool1/TxtTool1"):GetComponent("Text") + self.PanelTool2 = self.Transform:Find("SafeAreaContentPane/PanelAsset/PanelTool2") + self.ImgTool2 = self.Transform:Find("SafeAreaContentPane/PanelAsset/PanelTool2/ImgTool2"):GetComponent("Image") + self.TxtTool2 = self.Transform:Find("SafeAreaContentPane/PanelAsset/PanelTool2/TxtTool2"):GetComponent("Text") + self.PanelCharTopButton = self.Transform:Find("SafeAreaContentPane/PanelCharTopButton") + self.BtnBack = self.Transform:Find("SafeAreaContentPane/PanelCharTopButton/BtnBack"):GetComponent("Button") + self.BtnMainUi = self.Transform:Find("SafeAreaContentPane/PanelCharTopButton/BtnMainUi"):GetComponent("Button") + self.PanelSelectWork = self.Transform:Find("SafeAreaContentPane/PanelSelectWork") + self.PanelSlotInfo = self.Transform:Find("SafeAreaContentPane/PanelSelectWork/PanelSlotInfo") + self.TxtSlotName = self.Transform:Find("SafeAreaContentPane/PanelSelectWork/PanelSlotInfo/TxtSlotName"):GetComponent("Text") + self.TxtProductName = self.Transform:Find("SafeAreaContentPane/PanelSelectWork/PanelSlotInfo/TxtProductName"):GetComponent("Text") + self.TxtProductValue = self.Transform:Find("SafeAreaContentPane/PanelSelectWork/PanelSlotInfo/TxtProductValue"):GetComponent("Text") + self.PanelRight = self.Transform:Find("SafeAreaContentPane/PanelSelectWork/PanelRight") + self.SViewIdleCharList = self.Transform:Find("SafeAreaContentPane/PanelSelectWork/PanelRight/SViewIdleCharList"):GetComponent("ScrollRect") + self.PanelIdleCharContent = self.Transform:Find("SafeAreaContentPane/PanelSelectWork/PanelRight/SViewIdleCharList/Viewport/PanelIdleCharContent") + self.GridIdleCharacter = self.Transform:Find("SafeAreaContentPane/PanelSelectWork/PanelRight/SViewIdleCharList/Viewport/PanelIdleCharContent/GridIdleCharacter") + self.TxtCostVitality = self.Transform:Find("SafeAreaContentPane/PanelSelectWork/PanelRight/TxtCostVitality"):GetComponent("Text") + self.TxtCostTime = self.Transform:Find("SafeAreaContentPane/PanelSelectWork/PanelRight/TxtCostTime"):GetComponent("Text") + self.BtnCharWork = self.Transform:Find("SafeAreaContentPane/PanelSelectWork/PanelRight/BtnCharWork"):GetComponent("Button") +end + +function XUiHostelCharacterWork:GetAutoKey(uiNode,eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiHostelCharacterWork:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiHostelCharacterWork:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key],eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiHostelCharacterWork:AutoAddListener() + self.AutoCreateListeners = {} + XUiHelper.RegisterClickEvent(self, self.BtnBack, self.OnBtnBackClick) + XUiHelper.RegisterClickEvent(self, self.BtnMainUi, self.OnBtnMainUiClick) + XUiHelper.RegisterClickEvent(self, self.BtnCharWork, self.OnBtnCharWorkClick) +end +-- auto + +function XUiHostelCharacterWork:OnOpen(slotType, deveiceObj, fCloseCallBack) + self:InitAutoScript() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.HostelElectric, XDataCenter.ItemManager.ItemId.HostelMat) + self.DeviceObj = deveiceObj + self.GridIdleCharacter.gameObject:SetActive(false) + self.SlotType = slotType + self.FCloseCallBack = fCloseCallBack + self.CurSelectIndex = 0 + self.IdleCharUiItem = {} + self:UpdateView() +end + +function XUiHostelCharacterWork:OnBtnBackClick() + CS.XUiManager.ViewManager:Pop() + if self.FCloseCallBack then + self.FCloseCallBack() + end +end + +function XUiHostelCharacterWork:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiHostelCharacterWork:OnBtnCharWorkClick() + if self.CurSelectIndex == 0 then + XUiManager.TipText("HostelSelectCharWork") + return + end + local charId = self.IdleCharUiItem[self.CurSelectIndex]:GetCharId() + if charId == 0 then + return + end + + local fSucCallBack = function () + self.CurSelectIndex = 0 + self:UpdateView() + self.DeviceObj:CheckShowHud() + end + XDataCenter.HostelManager.ReqWorkInFunctionDevice(charId, self.SlotType, fSucCallBack) +end + +function XUiHostelCharacterWork:UpdateView() + self.SlotBelongType = 0 + local slotConfig = XDataCenter.HostelManager.GetFuncDeviceSlotTemplate(self.SlotType) + if not slotConfig then + return + end + self.SlotBelongType = slotConfig.BelongType + + if self:IsWorkSlotEmpty() then + self.PanelRight.gameObject:SetActive(true) + self:UpdateIdleList() + if self.CurSelectIndex == 0 then + local hud = self.DeviceObj:GetDisplayHud() + if hud then + hud:ShowJiantou() + end + end + else + self.PanelRight.gameObject:SetActive(false) + end + + + if self.SlotBelongType == XDataCenter.HostelManager.FunctionDeviceType.PowerStation then + self:UpdatePowerStationSlotInfo(slotConfig) + elseif self.SlotBelongType == XDataCenter.HostelManager.FunctionDeviceType.Factory then + self:UpdateFactorySlotInfo(slotConfig) + end + +end + +function XUiHostelCharacterWork:IsWorkSlotEmpty() + ---发电站槽位 + if self.SlotBelongType == XDataCenter.HostelManager.FunctionDeviceType.PowerStation then + return XDataCenter.HostelManager.CheckWorkSlotIsEmpty(self.SlotType) + elseif self.SlotBelongType == XDataCenter.HostelManager.FunctionDeviceType.Factory then + return XDataCenter.HostelManager.CheckWorkSlotIsIdle(self.SlotType) + --TODO elseif 其他槽位 + end + return true +end + + +---发电站信息 +function XUiHostelCharacterWork:UpdatePowerStationSlotInfo(slotConfig) + self.TxtCostVitality.text = CS.XTextManager.GetText("CharacterVitality",slotConfig.FunctionParam[2]) + local dataTime = XUiHelper.GetTime(slotConfig.FunctionParam[1] * slotConfig.FunctionParam[3], XUiHelper.TimeFormatType.SHOP) + self.TxtCostTime.text = dataTime + self.TxtSlotName.text = slotConfig.Name + self.TxtProductName.text = CS.XTextManager.GetText("HostelProductElectric") + local deviceConfig = XDataCenter.HostelManager.GetFuncDeviceCurLvlTemplate(XDataCenter.HostelManager.FunctionDeviceType.PowerStation) + if not deviceConfig then return end + local slotData = XDataCenter.HostelManager.GetWorkCharBySlot(self.SlotType) + if slotData and slotData.BeginTime > 0 then + self.PanelRight.gameObject:SetActive(false) + local curTime = XTime.GetServerNowTimestamp() + local passTime = curTime - slotData.BeginTime + local electric = math.floor(passTime/slotConfig.FunctionParam[3]) *(slotConfig.FunctionParam[4] + deviceConfig.FunctionParam[4]) + if electric < 0 then + electric = 0 + end + self.TxtProductValue.text = tostring(electric).."/"..tostring(slotConfig.FunctionParam[1] *(slotConfig.FunctionParam[4] + deviceConfig.FunctionParam[4])) + else + self.PanelRight.gameObject:SetActive(true) + self.TxtProductValue.text = CS.XTextManager.GetText("HostelPerSlot",slotConfig.FunctionParam[1] *(slotConfig.FunctionParam[4] + deviceConfig.FunctionParam[4])) + end +end + +---工厂信息 +function XUiHostelCharacterWork:UpdateFactorySlotInfo(slotConfig) + self.TxtCostVitality.text = CS.XTextManager.GetText("CharacterVitality",slotConfig.FunctionParam[2]) + local dataTime = XUiHelper.GetTime(slotConfig.FunctionParam[1], XUiHelper.TimeFormatType.SHOP) + self.TxtCostTime.text = dataTime + self.TxtSlotName.text = slotConfig.Name + self.TxtProductName.text = CS.XTextManager.GetText("HostelSlotProduct", XDataCenter.ItemManager.GetItemName(slotConfig.FunctionParam[3])) + + local deviceConfig = XDataCenter.HostelManager.GetFuncDeviceCurLvlTemplate(XDataCenter.HostelManager.FunctionDeviceType.Factory) + if not deviceConfig then return end + local count = slotConfig.FunctionParam[4] + deviceConfig.FunctionParam[1] + self.TxtProductValue.text = CS.XTextManager.GetText("HostelPerSlot",count) +end + + +function XUiHostelCharacterWork:UpdateIdleList() + local charList = XDataCenter.CharacterManager.GetOwnCharacterList() or {} + local idleCharList = {} + for _,v in ipairs(charList) do + if XDataCenter.HostelManager.IsCharacterInRest(v.Id) and not XDataCenter.HostelManager.IsCharacterInWork(v.Id) then + table_insert(idleCharList,v) + end + end + + + table.sort(idleCharList, function (a,b) + return a.Id > b.Id + end ) + + local datas = {} + for i,v in ipairs(idleCharList) do + table_insert(datas,{Index = i, Id = v.Id}) + end + local callback = function (index) + self:OnSelectIdleItem(index) + end + local onCreate = function(item, data) + item:SetData(data.Index,data.Id) + item:SetClickCallBack(callback) + end + XUiHelper.CreateTemplates(self, self.IdleCharUiItem, datas, XUiGridIdleCharacter.New, self.GridIdleCharacter.gameObject, self.PanelIdleCharContent, onCreate) + if #datas > 0 and self.CurSelectIndex == 0 then + self:OnSelectIdleItem(1) + end +end + +function XUiHostelCharacterWork:OnSelectIdleItem(index) + if self.CurSelectIndex > 0 then + self.IdleCharUiItem[self.CurSelectIndex]:SetSelect(false) + end + self.CurSelectIndex = index + if self.CurSelectIndex > 0 then + self.IdleCharUiItem[self.CurSelectIndex]:SetSelect(true) + local charId = self.IdleCharUiItem[self.CurSelectIndex]:GetCharId() + self:UpdateSceneCharModel(charId) + end +end + +function XUiHostelCharacterWork:UpdateSceneCharModel() + local hud = self.DeviceObj:GetDisplayHud() + if hud then + hud:HideContent() + end + -- body + -- 现在选择模型 +end diff --git a/Resources/Scripts/XUi/XUiHostelDelegate/XUiHostelDelegate.lua b/Resources/Scripts/XUi/XUiHostelDelegate/XUiHostelDelegate.lua new file mode 100644 index 00000000..8b8ce5e5 --- /dev/null +++ b/Resources/Scripts/XUi/XUiHostelDelegate/XUiHostelDelegate.lua @@ -0,0 +1,194 @@ +local XUiHostelDelegate = XUiManager.Register("UiHostelDelegate") +local table_insert = table.insert +-- auto +-- Automatic generation of code, forbid to edit +function XUiHostelDelegate:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiHostelDelegate:AutoInitUi() + self.PanelBg = self.Transform:Find("FullScreenBackground/PanelBg") + self.PanelCharTopButton = self.Transform:Find("SafeAreaContentPane/PanelCharTopButton") + self.BtnBack = self.Transform:Find("SafeAreaContentPane/PanelCharTopButton/BtnBack"):GetComponent("Button") + self.PanelLeft = self.Transform:Find("SafeAreaContentPane/PanelLeft") + self.ScrollView = self.Transform:Find("SafeAreaContentPane/PanelLeft/ScrollView"):GetComponent("Scrollbar") + self.PanelTabGroup = self.Transform:Find("SafeAreaContentPane/PanelLeft/ScrollView/Viewport/PanelTabGroup") + self.BtnTab1 = self.Transform:Find("SafeAreaContentPane/PanelLeft/ScrollView/Viewport/PanelTabGroup/BtnTab1"):GetComponent("Button") + self.TxtNormal = self.Transform:Find("SafeAreaContentPane/PanelLeft/ScrollView/Viewport/PanelTabGroup/BtnTab1/TxtNormal"):GetComponent("Text") + self.TxtSelected = self.Transform:Find("SafeAreaContentPane/PanelLeft/ScrollView/Viewport/PanelTabGroup/BtnTab1/TxtSelected"):GetComponent("Text") + self.PanelReport = self.Transform:Find("SafeAreaContentPane/PanelLeft/PanelReport") + self.BtnReport = self.Transform:Find("SafeAreaContentPane/PanelLeft/PanelReport/BtnReport"):GetComponent("Button") + self.TxtReleaseCount = self.Transform:Find("SafeAreaContentPane/PanelLeft/PanelReport/TxtReleaseCount"):GetComponent("Text") + self.TxtCompleteCount = self.Transform:Find("SafeAreaContentPane/PanelLeft/PanelReport/TxtCompleteCount"):GetComponent("Text") + self.PanelContent = self.Transform:Find("SafeAreaContentPane/PanelContent") + self.TxtTitle = self.Transform:Find("SafeAreaContentPane/PanelContent/TxtTitle"):GetComponent("Text") + self.TxtDesc = self.Transform:Find("SafeAreaContentPane/PanelContent/TxtDesc"):GetComponent("Text") + self.ImgRewardIcon = self.Transform:Find("SafeAreaContentPane/PanelContent/ImgRewardIcon"):GetComponent("Image") + self.TxtRewardCount = self.Transform:Find("SafeAreaContentPane/PanelContent/TxtRewardCount"):GetComponent("Text") + self.PanelBottom = self.Transform:Find("SafeAreaContentPane/PanelBottom") + self.PanelRelease = self.Transform:Find("SafeAreaContentPane/PanelBottom/PanelRelease") + self.BtnAdd = self.Transform:Find("SafeAreaContentPane/PanelBottom/PanelRelease/BtnAdd"):GetComponent("Button") + self.BtnMinus = self.Transform:Find("SafeAreaContentPane/PanelBottom/PanelRelease/BtnMinus"):GetComponent("Button") + self.TxtCount = self.Transform:Find("SafeAreaContentPane/PanelBottom/PanelRelease/TxtCount"):GetComponent("Text") + self.BtnRelease = self.Transform:Find("SafeAreaContentPane/PanelBottom/PanelRelease/BtnRelease"):GetComponent("Button") + self.TxtRemainCount = self.Transform:Find("SafeAreaContentPane/PanelBottom/PanelRelease/TxtRemainCount"):GetComponent("Text") + self.PanelMission = self.Transform:Find("SafeAreaContentPane/PanelBottom/PanelMission") + self.BtnCancel = self.Transform:Find("SafeAreaContentPane/PanelBottom/PanelMission/BtnCancel"):GetComponent("Button") + self.BtnHelp = self.Transform:Find("SafeAreaContentPane/PanelBottom/PanelMission/BtnHelp"):GetComponent("Button") +end + +function XUiHostelDelegate:GetAutoKey(uiNode,eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiHostelDelegate:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiHostelDelegate:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key],eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiHostelDelegate:AutoAddListener() + self.AutoCreateListeners = {} + XUiHelper.RegisterClickEvent(self, self.BtnBack, self.OnBtnBackClick) + XUiHelper.RegisterClickEvent(self, self.BtnReport, self.OnBtnReportClick) + XUiHelper.RegisterClickEvent(self, self.BtnAdd, self.OnBtnAddClick) + XUiHelper.RegisterClickEvent(self, self.BtnMinus, self.OnBtnMinusClick) + XUiHelper.RegisterClickEvent(self, self.BtnRelease, self.OnBtnReleaseClick) + XUiHelper.RegisterClickEvent(self, self.BtnCancel, self.OnBtnCancelClick) + XUiHelper.RegisterClickEvent(self, self.BtnHelp, self.OnBtnHelpClick) +end +-- auto + +function XUiHostelDelegate:OnOpen(deviceType) + + self:InitAutoScript() + self.BtnDelegateTypeList = {} + table_insert(self.BtnDelegateTypeList,self.BtnTab1) + self.DeviceType = deviceType + self:UpdateView() +end + +function XUiHostelDelegate:UpdateView() + local bRes, playerId = XDataCenter.HostelManager.IsInVisitFriendHostel() + if bRes then + self.IsVisitPlayer = true + self.PanelMission.gameObject:SetActive(true) + self.PanelReport.gameObject:SetActive(false) + self.PanelRelease.gameObject:SetActive(false) + self.VisitPlayerId = playerId + else + self.PanelMission.gameObject:SetActive(false) + self.PanelReport.gameObject:SetActive(true) + self.PanelRelease.gameObject:SetActive(true) + end + self:UpdateTabGroup() +end + +function XUiHostelDelegate:UpdateTabGroup() + local delegateTypeList = XDataCenter.HostelDelegateManager.GetDelegateListByDeviceType(self.DeviceType) + if not delegateTypeList or #delegateTypeList == 0 then + return + end + self.DelegateTypeList = delegateTypeList + for i,_ in ipairs(delegateTypeList) do + local btn = self.BtnDelegateTypeList[i] + if not btn then + btn = CS.UnityEngine.Object.Instantiate(self.BtnTab1) + btn.transform:SetParent(self.PanelTabGroup, false) + table.insert(self.BtnDelegateTypeList, btn) + end + end + if self.TabBtnGroup then + self.TabBtnGroup:Dispose() + end + self.TabBtnGroup = XUiTabBtnGroup.New(self.BtnDelegateTypeList, function(index) self:OnSeletDelegateType(index) end) + for i,btn in ipairs(self.TabBtnGroup.TabBtnList) do + local config = XDataCenter.HostelDelegateManager.GetDelegateTemplateByType(delegateTypeList[i]) + if config then + btn:SetName(config.DelegateName) + end + end + self.TabBtnGroup:SelectIndex(1) + +end + +function XUiHostelDelegate:OnSeletDelegateType(index) + local delegateType = self.DelegateTypeList[index] + self:UpdeteDelegateDes(delegateType) + if self.IsVisitPlayer then + self:UpdateMissonView(delegateType) + else + self:UpdatePublishView(delegateType) + end +end + +function XUiHostelDelegate:UpdeteDelegateDes(delegateType) + local config = XDataCenter.HostelDelegateManager.GetDelegateTemplateByType(delegateType) + if not config then return end + self.TxtTitle.text = config.DelegateName + self.TxtDesc.text = config.ReportDes +end + +function XUiHostelDelegate:UpdatePublishView(delegateType) + local config = XDataCenter.HostelDelegateManager.GetDelegateTemplateByType(delegateType) + if not config then return end + local Id, count = XDataCenter.HostelManager.GetDevieWorkSlotPruduct(config.SlotType) + self:SetUiSprite(self.ImgRewardIcon, XDataCenter.ItemManager.GetItemIcon(Id)) + self.TxtRewardCount.text = math.floor(count * config.PublishAwardPercent / 100 ) +end + +function XUiHostelDelegate:UpdateMissonView(delegateType) + local config = XDataCenter.HostelDelegateManager.GetDelegateTemplateByType(delegateType) + if not config then return end + local Id, count = XDataCenter.HostelManager.GetDevieWorkSlotPruduct(config.SlotType) + self:SetUiSprite(self.ImgRewardIcon, XDataCenter.ItemManager.GetItemIcon(Id)) + self.TxtRewardCount.text = math.floor(count * config.AssistAwardPercent / 100 ) +end + +function XUiHostelDelegate:OnBtnBackClick() + +end + +function XUiHostelDelegate:OnBtnReportClick() + +end + +function XUiHostelDelegate:OnBtnAddClick() + +end + +function XUiHostelDelegate:OnBtnMinusClick() + +end + +function XUiHostelDelegate:OnBtnReleaseClick() + +end + +function XUiHostelDelegate:OnBtnCancelClick() + +end + +function XUiHostelDelegate:OnBtnHelpClick() + +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiHostelDelegateReporter/XUiGridDelegateReporter.lua b/Resources/Scripts/XUi/XUiHostelDelegateReporter/XUiGridDelegateReporter.lua new file mode 100644 index 00000000..1b6a7175 --- /dev/null +++ b/Resources/Scripts/XUi/XUiHostelDelegateReporter/XUiGridDelegateReporter.lua @@ -0,0 +1,58 @@ +XUiGridDelegateReporter = XClass(nil, "XUiGridDelegateReporter") + +function XUiGridDelegateReporter:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self:InitAutoScript() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiGridDelegateReporter:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiGridDelegateReporter:AutoInitUi() + self.TxtDesc = XUiHelper.TryGetComponent(self.Transform, "TxtDesc", "Text") + self.TxtDelegateType = XUiHelper.TryGetComponent(self.Transform, "TxtDelegateType", "Text") + self.TxtNickname = XUiHelper.TryGetComponent(self.Transform, "TxtNickname", "Text") + self.ImgHeadIcon = XUiHelper.TryGetComponent(self.Transform, "ImgHeadIcon", "Image") + self.ImgRewardIcon = XUiHelper.TryGetComponent(self.Transform, "ImgRewardIcon", "Image") + self.TxtRewardCount = XUiHelper.TryGetComponent(self.Transform, "TxtRewardCount", "Text") + self.TxtContent = XUiHelper.TryGetComponent(self.Transform, "ImageBg/TxtContent", "Text") +end + +function XUiGridDelegateReporter:GetAutoKey(uiNode,eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiGridDelegateReporter:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiGridDelegateReporter:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key],eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiGridDelegateReporter:AutoAddListener() + self.AutoCreateListeners = {} +end +-- auto diff --git a/Resources/Scripts/XUi/XUiHostelDelegateReporter/XUiHostelDelegateReporter.lua b/Resources/Scripts/XUi/XUiHostelDelegateReporter/XUiHostelDelegateReporter.lua new file mode 100644 index 00000000..a83c5df7 --- /dev/null +++ b/Resources/Scripts/XUi/XUiHostelDelegateReporter/XUiHostelDelegateReporter.lua @@ -0,0 +1,71 @@ +local XUiHostelDelegateReporter = XUiManager.Register("UiHostelDelegateReporter") + +function XUiHostelDelegateReporter:OnOpen() + self:InitAutoScript() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiHostelDelegateReporter:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiHostelDelegateReporter:AutoInitUi() + self.PanelBg = self.Transform:Find("FullScreenBackground/PanelBg") + self.PanelTopButton = self.Transform:Find("SafeAreaContentPane/PanelTopButton") + self.BtnBack = self.Transform:Find("SafeAreaContentPane/PanelTopButton/BtnBack"):GetComponent("Button") + self.PanelLeft = self.Transform:Find("SafeAreaContentPane/PanelLeft") + self.PanelReport = self.Transform:Find("SafeAreaContentPane/PanelLeft/PanelReport") + self.BtnReport = self.Transform:Find("SafeAreaContentPane/PanelLeft/PanelReport/BtnReport"):GetComponent("Button") + self.TxtReleaseCount = self.Transform:Find("SafeAreaContentPane/PanelLeft/PanelReport/TxtReleaseCount"):GetComponent("Text") + self.TxtCompleteCount = self.Transform:Find("SafeAreaContentPane/PanelLeft/PanelReport/TxtCompleteCount"):GetComponent("Text") + self.PanelRight = self.Transform:Find("SafeAreaContentPane/PanelRight") + self.SViewReporter = self.Transform:Find("SafeAreaContentPane/PanelRight/SViewReporter"):GetComponent("ScrollRect") + self.PanelContent = self.Transform:Find("SafeAreaContentPane/PanelRight/SViewReporter/Viewport/PanelContent") + self.GridDelegateReporter = self.Transform:Find("SafeAreaContentPane/PanelRight/SViewReporter/Viewport/PanelContent/GridDelegateReporter") +end + +function XUiHostelDelegateReporter:GetAutoKey(uiNode,eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiHostelDelegateReporter:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiHostelDelegateReporter:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key],eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiHostelDelegateReporter:AutoAddListener() + self.AutoCreateListeners = {} + XUiHelper.RegisterClickEvent(self, self.BtnBack, self.OnBtnBackClick) + XUiHelper.RegisterClickEvent(self, self.BtnReport, self.OnBtnReportClick) +end +-- auto + +function XUiHostelDelegateReporter:OnBtnBackClick() + +end + +function XUiHostelDelegateReporter:OnBtnReportClick() + +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiHostelDeviceDetail/XUiGridFuncUpgradeInfoItem.lua b/Resources/Scripts/XUi/XUiHostelDeviceDetail/XUiGridFuncUpgradeInfoItem.lua new file mode 100644 index 00000000..cc86937d --- /dev/null +++ b/Resources/Scripts/XUi/XUiHostelDeviceDetail/XUiGridFuncUpgradeInfoItem.lua @@ -0,0 +1,61 @@ +XUiGridFuncUpgradeInfoItem = XClass(nil, "XUiGridFuncUpgradeInfoItem") + +function XUiGridFuncUpgradeInfoItem:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self:InitAutoScript() + self.GameObject:SetActive(true) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiGridFuncUpgradeInfoItem:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiGridFuncUpgradeInfoItem:AutoInitUi() + self.TxtName = self.Transform:Find("TxtName"):GetComponent("Text") + self.TxtCurValue = self.Transform:Find("TxtCurValue"):GetComponent("Text") + self.TxtNextValue = self.Transform:Find("TxtNextValue"):GetComponent("Text") +end + +function XUiGridFuncUpgradeInfoItem:GetAutoKey(uiNode,eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiGridFuncUpgradeInfoItem:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiGridFuncUpgradeInfoItem:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key],eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiGridFuncUpgradeInfoItem:AutoAddListener() + self.AutoCreateListeners = {} +end +-- auto + +function XUiGridFuncUpgradeInfoItem:SetData(name, curValue, nextValue) + self.TxtName.text = name + self.TxtCurValue.text = curValue + self.TxtNextValue.text = nextValue +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiHostelDeviceDetail/XUiGridFunctionContenItem.lua b/Resources/Scripts/XUi/XUiHostelDeviceDetail/XUiGridFunctionContenItem.lua new file mode 100644 index 00000000..f6797141 --- /dev/null +++ b/Resources/Scripts/XUi/XUiHostelDeviceDetail/XUiGridFunctionContenItem.lua @@ -0,0 +1,60 @@ +XUiGridFunctionContenItem = XClass(nil, "XUiGridFunctionContenItem") + +function XUiGridFunctionContenItem:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self:InitAutoScript() + self.GameObject:SetActive(true) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiGridFunctionContenItem:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiGridFunctionContenItem:AutoInitUi() + self.TxtName = self.Transform:Find("TxtName"):GetComponent("Text") + self.TxtValue = self.Transform:Find("TxtValue"):GetComponent("Text") +end + +function XUiGridFunctionContenItem:GetAutoKey(uiNode,eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiGridFunctionContenItem:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiGridFunctionContenItem:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key],eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiGridFunctionContenItem:AutoAddListener() + self.AutoCreateListeners = {} +end +-- auto + +function XUiGridFunctionContenItem:SetData(name, value) + self.GameObject:SetActive(true) + self.TxtName.text = name + self.TxtValue.text = value +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiHostelDeviceDetail/XUiHostelDeviceDetail.lua b/Resources/Scripts/XUi/XUiHostelDeviceDetail/XUiHostelDeviceDetail.lua new file mode 100644 index 00000000..f9281bc6 --- /dev/null +++ b/Resources/Scripts/XUi/XUiHostelDeviceDetail/XUiHostelDeviceDetail.lua @@ -0,0 +1,204 @@ +local XUiHostelDeviceDetail = XLuaUiManager.Register(XLuaUi, "UiHostelDeviceDetail") + +local table_insert = table.insert +-- auto +-- Automatic generation of code, forbid to edit +function XUiHostelDeviceDetail:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiHostelDeviceDetail:AutoInitUi() + self.PanelCharTopButton = self.Transform:Find("SafeAreaContentPane/PanelCharTopButton") + self.BtnBack = self.Transform:Find("SafeAreaContentPane/PanelCharTopButton/BtnBack"):GetComponent("Button") + self.BtnMainUi = self.Transform:Find("SafeAreaContentPane/PanelCharTopButton/BtnMainUi"):GetComponent("Button") + self.PanelDeviceUpgradeInfo = self.Transform:Find("SafeAreaContentPane/PanelDeviceUpgradeInfo") + self.PanelDeviceUpgradeMain = self.Transform:Find("SafeAreaContentPane/PanelDeviceUpgradeMain") + self.PanelBtnInfo = self.Transform:Find("SafeAreaContentPane/PanelDeviceUpgradeMain/PanelBtnInfo") + self.BtnShowInfo = self.Transform:Find("SafeAreaContentPane/PanelDeviceUpgradeMain/PanelBtnInfo/BtnShowInfo"):GetComponent("Button") + self.PanelSysInfo = self.Transform:Find("SafeAreaContentPane/PanelDeviceUpgradeMain/ContentInfo/PanelSysInfo") + self.PanelFixInfo = self.Transform:Find("SafeAreaContentPane/PanelDeviceUpgradeMain/ContentInfo/PanelSysInfo/PanelFixInfo") + self.TxtFunctionDeviceName = self.Transform:Find("SafeAreaContentPane/PanelDeviceUpgradeMain/ContentInfo/PanelSysInfo/PanelFixInfo/TxtFunctionDeviceName"):GetComponent("Text") + self.PanelFunctionContent = self.Transform:Find("SafeAreaContentPane/PanelDeviceUpgradeMain/ContentInfo/PanelSysInfo/PanelFunctionContent") + self.GridFunctionContenItem = self.Transform:Find("SafeAreaContentPane/PanelDeviceUpgradeMain/ContentInfo/PanelSysInfo/PanelFunctionContent/GridFunctionContenItem") + self.PanelSysDes = self.Transform:Find("SafeAreaContentPane/PanelDeviceUpgradeMain/ContentInfo/PanelSysDes") + self.TxtSysDes = self.Transform:Find("SafeAreaContentPane/PanelDeviceUpgradeMain/ContentInfo/PanelSysDes/TxtSysDes"):GetComponent("Text") + self.PanelUpInfo = self.Transform:Find("SafeAreaContentPane/PanelDeviceUpgradeMain/PanelUpInfo") + self.ImgCost = self.Transform:Find("SafeAreaContentPane/PanelDeviceUpgradeMain/PanelUpInfo/ImgCost"):GetComponent("Image") + self.TxtCostCount = self.Transform:Find("SafeAreaContentPane/PanelDeviceUpgradeMain/PanelUpInfo/TxtCostCount"):GetComponent("Text") + self.TxtCostTime = self.Transform:Find("SafeAreaContentPane/PanelDeviceUpgradeMain/PanelUpInfo/TxtCostTime"):GetComponent("Text") + self.BtnIntoUpgrade = self.Transform:Find("SafeAreaContentPane/PanelDeviceUpgradeMain/BtnIntoUpgrade"):GetComponent("Button") + self.BtnQuest = self.Transform:Find("SafeAreaContentPane/PanelDeviceUpgradeMain/BtnQuest"):GetComponent("Button") + self.PanelAsset = self.Transform:Find("SafeAreaContentPane/PanelAsset") + self.PanelTool1 = self.Transform:Find("SafeAreaContentPane/PanelAsset/PanelTool1") + self.ImgTool1 = self.Transform:Find("SafeAreaContentPane/PanelAsset/PanelTool1/ImgTool1"):GetComponent("Image") + self.TxtTool1 = self.Transform:Find("SafeAreaContentPane/PanelAsset/PanelTool1/TxtTool1"):GetComponent("Text") + self.PanelTool2 = self.Transform:Find("SafeAreaContentPane/PanelAsset/PanelTool2") + self.ImgTool2 = self.Transform:Find("SafeAreaContentPane/PanelAsset/PanelTool2/ImgTool2"):GetComponent("Image") + self.TxtTool2 = self.Transform:Find("SafeAreaContentPane/PanelAsset/PanelTool2/TxtTool2"):GetComponent("Text") + self.ImgBg = self.Transform:Find("FullScreenBackground/ImgBg"):GetComponent("Image") +end + +function XUiHostelDeviceDetail:GetAutoKey(uiNode, eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiHostelDeviceDetail:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiHostelDeviceDetail:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiHostelDeviceDetail:AutoAddListener() + self.AutoCreateListeners = {} + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:RegisterClickEvent(self.BtnShowInfo, self.OnBtnShowInfoClick) + self:RegisterClickEvent(self.BtnIntoUpgrade, self.OnBtnIntoUpgradeClick) + self:RegisterClickEvent(self.BtnQuest, self.OnBtnQuestClick) +end +-- auto +function XUiHostelDeviceDetail:OnOpen(type, deveiceObj, fCloseCallBack) + self:InitAutoScript() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.HostelElectric, XDataCenter.ItemManager.ItemId.HostelMat) + self.GridFunctionContenItem.gameObject:SetActive(false) + self.UiContentList = {} + self.CurFuncType = type + self.FCloseCallBack = fCloseCallBack + local funcBackUpgarding = function() + XHomeSceneManager.ChangeBackToOverView() + XHomeInfrastructureManager.ChangeCameraToScene() + end + self.PanelUpgardeInfo = XUiPanelDeviceUpgradeInfo.New(self, self.PanelDeviceUpgradeInfo, type, funcBackUpgarding) + self.PanelUpgardeInfo:SetActive(false) + self.ImgBg.gameObject:SetActive(false) + self:UpdateView() +end + +function XUiHostelDeviceDetail:OnBtnBackClick() + if self.PanelUpgardeInfo.GameObject.activeSelf then + self.PanelUpgardeInfo:SetActive(false) + self.ImgBg.gameObject:SetActive(false) + self.PanelDeviceUpgradeMain.gameObject:SetActive(true) + else + self.FCloseCallBack() + CS.XUiManager.ViewManager:Pop() + end +end + +function XUiHostelDeviceDetail:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiHostelDeviceDetail:UpdateView() + local deveice = XDataCenter.HostelManager.GetFunctionDeviceData(self.CurFuncType) + if not deveice then return end + local config = XDataCenter.HostelManager.GetHostelFunctionDeviceLevelTemplate(self.CurFuncType, deveice.Level) + if not config then return end + if config.Type == XDataCenter.HostelManager.FunctionDeviceType.MainComputer then + self.BtnQuest.gameObject:SetActive(false) + else + self.BtnQuest.gameObject:SetActive(true) + end + self:UpdateFuncDeviceContent(deveice, config) + local rectTf = self.PanelBtnInfo.gameObject:GetComponent("RectTransform") + local width = rectTf.sizeDelta.x + rectTf.sizeDelta = CS.UnityEngine.Vector2(width, 110 + #self.UiContentList * 65) + + + self.TxtFunctionDeviceName.text = config.Name + self.TxtSysDes.text = config.Des + local nextConfig = XDataCenter.HostelManager.GetHostelFunctionDeviceLevelTemplate(self.CurFuncType, deveice.Level + 1) + if not nextConfig then + self.PanelUpInfo.gameObject:SetActive(false) + self.BtnIntoUpgrade.gameObject:SetActive(false) + else + self.PanelUpInfo.gameObject:SetActive(true) + self.BtnIntoUpgrade.gameObject:SetActive(true) + if nextConfig.CostId > 0 then + self:SetUiSprite(self.ImgCost, XDataCenter.ItemManager.GetItemIcon(nextConfig.CostId)) + self.TxtCostCount.text = nextConfig.CostCount + self.ImgCost.gameObject:SetActive(true) + self.TxtCostCount.gameObject:SetActive(true) + else + self.ImgCost.gameObject:SetActive(false) + self.TxtCostCount.gameObject:SetActive(false) + end + local dataTime = XUiHelper.GetTime(nextConfig.CostTime, XUiHelper.TimeFormatType.HOSTEL) + self.TxtCostTime.text = dataTime + end +end + +function XUiHostelDeviceDetail:UpdateFuncDeviceContent(deveice, config) + local datas = {} + table_insert(datas, { CS.XTextManager.GetText("HostelDeviceLevel"), deveice.Level }) + if config.Type == XDataCenter.HostelManager.FunctionDeviceType.PowerStation then + self:GetPowerStationContent(datas, config) + elseif config.Type == XDataCenter.HostelManager.FunctionDeviceType.Factory then + self:GetFactoryContent(datas, config) + end + + local onCreate = function(item, data) + item:SetData(data[1], data[2]) + end + XUiHelper.CreateTemplates(self, self.UiContentList, datas, XUiGridFunctionContenItem.New, self.GridFunctionContenItem.gameObject, self.PanelFunctionContent, onCreate) + +end + +--发电站 +function XUiHostelDeviceDetail:GetPowerStationContent(datas, config) + table_insert(datas, { CS.XTextManager.GetText("HostelMaxElectric"), config.FunctionParam[3] }) + table_insert(datas, { CS.XTextManager.GetText("HostelPerElectric"), config.FunctionParam[2] .. "/" .. XUiHelper.GetTimeDesc(config.FunctionParam[1], 1) }) +end +--发电站 +--工厂 +function XUiHostelDeviceDetail:GetFactoryContent(datas, config) + local curSlotData = XDataCenter.HostelManager.GetCurDeviceWorkSlot(XDataCenter.HostelManager.FunctionDeviceType.Factory) + local curWorkProduct = {} + for _, v in ipairs(curSlotData) do + local slotConfig = XDataCenter.HostelManager.GetFuncDeviceSlotTemplate(v) + local Id = slotConfig.FunctionParam[3] + if not curWorkProduct[Id] then + curWorkProduct[Id] = slotConfig.FunctionParam[4] + config.FunctionParam[1] + end + end + + for Id, count in pairs(curWorkProduct) do + table_insert(datas, { CS.XTextManager.GetText("HostelSlotProduct", XDataCenter.ItemManager.GetItemName(Id)), CS.XTextManager.GetText("HostelPerSlot", count) }) + end +end + +function XUiHostelDeviceDetail:OnBtnShowInfoClick() + local active = self.PanelSysDes.gameObject.activeSelf + self.PanelSysDes.gameObject:SetActive(not active) +end + +function XUiHostelDeviceDetail:OnBtnIntoUpgradeClick() + self.PanelUpgardeInfo:SetActive(true) + self.ImgBg.gameObject:SetActive(true) + self.PanelUpgardeInfo:UpdateView() + self.PanelDeviceUpgradeMain.gameObject:SetActive(false) +end + +function XUiHostelDeviceDetail:OnBtnQuestClick() + +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiHostelDeviceDetail/XUiPanelDeviceUpgradeInfo.lua b/Resources/Scripts/XUi/XUiHostelDeviceDetail/XUiPanelDeviceUpgradeInfo.lua new file mode 100644 index 00000000..3b630440 --- /dev/null +++ b/Resources/Scripts/XUi/XUiHostelDeviceDetail/XUiPanelDeviceUpgradeInfo.lua @@ -0,0 +1,191 @@ +XUiPanelDeviceUpgradeInfo = XClass(nil, "XUiPanelDeviceUpgradeInfo") +local table_insert = table.insert + +function XUiPanelDeviceUpgradeInfo:Ctor(rootUi, ui, type, funcBackUpgarding) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + self:InitAutoScript() + self.CurFuncType = type + self.FuncBackUpgarding = funcBackUpgarding + self.UiContentList = {} + self:SetActive(false) + self.GridFuncUpgradeInfoItem.gameObject:SetActive(false) +end + +function XUiPanelDeviceUpgradeInfo:SetActive(value) + self.GameObject:SetActive(value) +end +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelDeviceUpgradeInfo:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiPanelDeviceUpgradeInfo:AutoInitUi() + self.Panel = self.Transform:Find("Panel") + self.TxtDeviceName = self.Transform:Find("Panel/TxtDeviceName"):GetComponent("Text") + self.TxtCurLevel = self.Transform:Find("Panel/TxtCurLevel"):GetComponent("Text") + self.TxtNextLevel = self.Transform:Find("Panel/TxtNextLevel"):GetComponent("Text") + self.PanelContent = self.Transform:Find("Panel/PanelContent") + self.GridFuncUpgradeInfoItem = self.Transform:Find("Panel/PanelContent/GridFuncUpgradeInfoItem") + self.ImgUpgradeCost = self.Transform:Find("GrpUpInfo/ImgUpgradeCost"):GetComponent("Image") + self.TxtUpgradeCostCount = self.Transform:Find("GrpUpInfo/TxtUpgradeCostCount"):GetComponent("Text") + self.TxtUpgradeCostTime = self.Transform:Find("GrpUpInfo/TxtUpgradeCostTime"):GetComponent("Text") + self.BtnUpgrade = self.Transform:Find("GrpUpInfo/BtnUpgrade"):GetComponent("Button") +end + +function XUiPanelDeviceUpgradeInfo:GetAutoKey(uiNode, eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiPanelDeviceUpgradeInfo:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiPanelDeviceUpgradeInfo:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiPanelDeviceUpgradeInfo:AutoAddListener() + self.AutoCreateListeners = {} + XUiHelper.RegisterClickEvent(self, self.BtnUpgrade, self.OnBtnUpgradeClick) +end +-- auto +function XUiPanelDeviceUpgradeInfo:OnBtnUpgradeClick() + local deveice = XDataCenter.HostelManager.GetFunctionDeviceData(self.CurFuncType) + if not deveice then return end + local nextConfig = XDataCenter.HostelManager.GetHostelFunctionDeviceLevelTemplate(self.CurFuncType, deveice.Level + 1) + if not nextConfig then return end + if nextConfig.CostId > 0 then + local isItemEnough = XDataCenter.ItemManager.CheckItemCountById(nextConfig.CostId, nextConfig.CostCount) + if not isItemEnough then + local itemName = XDataCenter.ItemManager.GetItemName(nextConfig.CostId) + local text = CS.XTextManager.GetText("HostelDeviceNeedEle", nextConfig.CostCount, itemName) + XUiManager.TipMsg(text, XUiManager.UiTipType.Tip) + return + end + end + if nextConfig.ConditionId > 0 then + local ret, desc = XConditionManager.CheckCondition(nextConfig.ConditionId) + if not ret then + XUiManager.TipError(desc) + return + end + end + XDataCenter.HostelManager.ReqFuncDeviceUpgrade(self.CurFuncType, function() + --CS.XUiManager.DialogManager:Push("UiHostelDeviceUpgrading", false, false,self.CurFuncType,self.FuncBackUpgarding) + CS.XUiManager.ViewManager:Pop() + self.FuncBackUpgarding() + end) +end + +function XUiPanelDeviceUpgradeInfo:UpdateView() + self:SetActive(true) + local deveice = XDataCenter.HostelManager.GetFunctionDeviceData(self.CurFuncType) + if not deveice then return end + local config = XDataCenter.HostelManager.GetHostelFunctionDeviceLevelTemplate(self.CurFuncType, deveice.Level) + if not config then return end + self.TxtDeviceName.text = config.Name + self.TxtCurLevel.text = deveice.Level + self.TxtNextLevel.text = deveice.Level + 1 + local nextConfig = XDataCenter.HostelManager.GetHostelFunctionDeviceLevelTemplate(self.CurFuncType, deveice.Level + 1) + if nextConfig then + self:UpdateFuncDeviceContent(deveice, config, nextConfig) + if nextConfig.CostId > 0 then + self.RootUi:SetUiSprite(self.ImgUpgradeCost, XDataCenter.ItemManager.GetItemIcon(nextConfig.CostId)) + self.TxtUpgradeCostCount.text = nextConfig.CostCount + self.ImgUpgradeCost.gameObject:SetActive(true) + self.TxtUpgradeCostCount.gameObject:SetActive(true) + else + self.ImgUpgradeCost.gameObject:SetActive(false) + self.TxtUpgradeCostCount.gameObject:SetActive(false) + end + local dataTime = XUiHelper.GetTime(nextConfig.CostTime, XUiHelper.TimeFormatType.HOSTEL) + self.TxtUpgradeCostTime.text = dataTime + end +end + +function XUiPanelDeviceUpgradeInfo:UpdateFuncDeviceContent(deveice, config, nextConfig) + local datas = {} + if config.Type == XDataCenter.HostelManager.FunctionDeviceType.PowerStation then + self:GetPowerStationContent(datas, deveice, config, nextConfig) + elseif config.Type == XDataCenter.HostelManager.FunctionDeviceType.Factory then + self:GetFactoryContent(datas, deveice, config, nextConfig) + end + + local onCreate = function(item, data) + item:SetData(data[1], data[2], data[3]) + end + XUiHelper.CreateTemplates(self.RootUi, self.UiContentList, datas, XUiGridFuncUpgradeInfoItem.New, self.GridFuncUpgradeInfoItem.gameObject, self.PanelContent, onCreate) +end + +---发电站内容 +function XUiPanelDeviceUpgradeInfo:GetPowerStationContent(datas, deveice, config, nextConfig) + local nextsLotData = XDataCenter.HostelManager.CalcDeviceSlotLevel(XDataCenter.HostelManager.FunctionDeviceType.PowerStation, deveice.Level + 1) + local curSlotData = XDataCenter.HostelManager.GetCurDeviceWorkSlot(XDataCenter.HostelManager.FunctionDeviceType.PowerStation) + table_insert(datas, { CS.XTextManager.GetText("HostelMaxElectric"), config.FunctionParam[3], nextConfig.FunctionParam[3] }) + table_insert(datas, { CS.XTextManager.GetText("HostelPerElectric"), config.FunctionParam[2] .. "/" .. XUiHelper.GetTimeDesc(config.FunctionParam[1], 1), nextConfig.FunctionParam[2] .. "/" .. XUiHelper.GetTimeDesc(nextConfig.FunctionParam[1], 1) }) + local curWorkEle = 0 + for _, v in ipairs(curSlotData) do + local slotConfig = XDataCenter.HostelManager.GetFuncDeviceSlotTemplate(v) + curWorkEle = curWorkEle + slotConfig.FunctionParam[1] * (slotConfig.FunctionParam[4] + config.FunctionParam[4]) + break + end + local nextWorkEle = 0 + for _, v in ipairs(nextsLotData) do + local slotConfig = XDataCenter.HostelManager.GetFuncDeviceSlotTemplate(v) + nextWorkEle = nextWorkEle + slotConfig.FunctionParam[1] * (slotConfig.FunctionParam[4] + nextConfig.FunctionParam[4]) + break + end + + table_insert(datas, { CS.XTextManager.GetText("HostelWorkElectric"), CS.XTextManager.GetText("HostelPerSlot", curWorkEle), CS.XTextManager.GetText("HostelPerSlot", nextWorkEle) }) + table_insert(datas, { CS.XTextManager.GetText("HostelWorkSlot"), #curSlotData, #nextsLotData }) +end +--发电站内容 +--工厂内容 +function XUiPanelDeviceUpgradeInfo:GetFactoryContent(datas, deveice, config, nextConfig) + local nextsLotData = XDataCenter.HostelManager.CalcDeviceSlotLevel(XDataCenter.HostelManager.FunctionDeviceType.Factory, deveice.Level + 1) + local curSlotData = XDataCenter.HostelManager.GetCurDeviceWorkSlot(XDataCenter.HostelManager.FunctionDeviceType.Factory) + local curWorkProduct = {} + for _, v in ipairs(curSlotData) do + local slotConfig = XDataCenter.HostelManager.GetFuncDeviceSlotTemplate(v) + local Id = slotConfig.FunctionParam[3] + if not curWorkProduct[Id] then + curWorkProduct[Id] = slotConfig.FunctionParam[4] + config.FunctionParam[1] + end + end + + local nextWorkProduct = {} + for _, v in ipairs(nextsLotData) do + local slotConfig = XDataCenter.HostelManager.GetFuncDeviceSlotTemplate(v) + local Id = slotConfig.FunctionParam[3] + if not nextWorkProduct[Id] then + nextWorkProduct[Id] = slotConfig.FunctionParam[4] + nextConfig.FunctionParam[1] + end + end + + for Id, count in pairs(curWorkProduct) do + table_insert(datas, { CS.XTextManager.GetText("HostelSlotProduct", XDataCenter.ItemManager.GetItemName(Id)), CS.XTextManager.GetText("HostelPerSlot", count), CS.XTextManager.GetText("HostelPerSlot", nextWorkProduct[Id] or 0) }) + end + + table_insert(datas, { CS.XTextManager.GetText("HostelWorkSlot"), #curSlotData, #nextsLotData }) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiHostelDeviceUpgradeResult/XUiGridFuncUpgradeResItem.lua b/Resources/Scripts/XUi/XUiHostelDeviceUpgradeResult/XUiGridFuncUpgradeResItem.lua new file mode 100644 index 00000000..55a2b3c5 --- /dev/null +++ b/Resources/Scripts/XUi/XUiHostelDeviceUpgradeResult/XUiGridFuncUpgradeResItem.lua @@ -0,0 +1,58 @@ +XUiGridFuncUpgradeResItem = XClass(nil, "XUiGridFuncUpgradeResItem") + +function XUiGridFuncUpgradeResItem:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self:InitAutoScript() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiGridFuncUpgradeResItem:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiGridFuncUpgradeResItem:AutoInitUi() + self.TxtName = self.Transform:Find("TxtName"):GetComponent("Text") + self.TxtValue = self.Transform:Find("TxtValue"):GetComponent("Text") +end + +function XUiGridFuncUpgradeResItem:GetAutoKey(uiNode,eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiGridFuncUpgradeResItem:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiGridFuncUpgradeResItem:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key],eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiGridFuncUpgradeResItem:AutoAddListener() + self.AutoCreateListeners = {} +end +-- auto +function XUiGridFuncUpgradeResItem:SetData(name, value) + self.GameObject:SetActive(true) + self.TxtName.text = name + self.TxtValue.text = value +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiHostelDeviceUpgradeResult/XUiHostelDeviceUpgradeResult.lua b/Resources/Scripts/XUi/XUiHostelDeviceUpgradeResult/XUiHostelDeviceUpgradeResult.lua new file mode 100644 index 00000000..84c75c7a --- /dev/null +++ b/Resources/Scripts/XUi/XUiHostelDeviceUpgradeResult/XUiHostelDeviceUpgradeResult.lua @@ -0,0 +1,121 @@ +local XUiHostelDeviceUpgradeResult = XUiManager.Register("UiHostelDeviceUpgradeResult") +local table_insert = table.insert + +-- auto +-- Automatic generation of code, forbid to edit +function XUiHostelDeviceUpgradeResult:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiHostelDeviceUpgradeResult:AutoInitUi() + self.PanelFuncUpgradeResult = self.Transform:Find("SafeAreaContentPane/PanelFuncUpgradeResult") + self.PanelInfo = self.Transform:Find("SafeAreaContentPane/PanelFuncUpgradeResult/PanelInfo") + self.PanelContent = self.Transform:Find("SafeAreaContentPane/PanelFuncUpgradeResult/PanelInfo/PanelContent") + self.GridFuncUpgradeResItem = self.Transform:Find("SafeAreaContentPane/PanelFuncUpgradeResult/PanelInfo/PanelContent/GridFuncUpgradeResItem") + self.BtnClick = self.Transform:Find("SafeAreaContentPane/PanelFuncUpgradeResult/BtnClick"):GetComponent("Button") +end + +function XUiHostelDeviceUpgradeResult:GetAutoKey(uiNode,eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiHostelDeviceUpgradeResult:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiHostelDeviceUpgradeResult:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key],eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiHostelDeviceUpgradeResult:AutoAddListener() + self.AutoCreateListeners = {} + XUiHelper.RegisterClickEvent(self, self.BtnClick, self.OnBtnClickClick) +end +-- auto + +function XUiHostelDeviceUpgradeResult:OnBtnClickClick() + CS.XUiManager.DialogManager:Pop() +end + +function XUiHostelDeviceUpgradeResult:OnOpen(type) + self:InitAutoScript() + self.GridFuncUpgradeResItem.gameObject:SetActive(false) + self.CurFuncType = type + self.UiContentList = {} + self:UpdateView() +end + +function XUiHostelDeviceUpgradeResult:UpdateView() + local deveice = XDataCenter.HostelManager.GetFunctionDeviceData(self.CurFuncType) + if not deveice then return end + local config = XDataCenter.HostelManager.GetHostelFunctionDeviceLevelTemplate(self.CurFuncType,deveice.Level) + if not config then return end + self:UpdateFuncDeviceContent(deveice,config) + +end + +function XUiHostelDeviceUpgradeResult:UpdateFuncDeviceContent(deveice,config) + local datas = {} + table_insert(datas,{CS.XTextManager.GetText("HostelDeviceLevel")..CS.XTextManager.GetText("HostelDeviceUp"),deveice.Level}) + if config.Type == XDataCenter.HostelManager.FunctionDeviceType.PowerStation then + self:GetPowerStationContent(datas,deveice,config) + elseif config.Type == XDataCenter.HostelManager.FunctionDeviceType.Factory then + self:GetFactoryContent(datas,deveice,config) + end + + local onCreate = function(item, data) + item:SetData(data[1],data[2]) + end + XUiHelper.CreateTemplates(self, self.UiContentList, datas, XUiGridFuncUpgradeResItem.New, self.GridFuncUpgradeResItem.gameObject, self.PanelContent, onCreate) +end + +--发电站内容 +function XUiHostelDeviceUpgradeResult:GetPowerStationContent(datas,deveice,config) + local str = CS.XTextManager.GetText("HostelDeviceUp") + table_insert(datas,{CS.XTextManager.GetText("HostelMaxElectric")..str,config.FunctionParam[3]}) + table_insert(datas,{CS.XTextManager.GetText("HostelPerElectric")..str,config.FunctionParam[2].."/"..XUiHelper.GetTimeDesc(config.FunctionParam[1],1)}) + local curSlotData = XDataCenter.HostelManager.GetCurDeviceWorkSlot(XDataCenter.HostelManager.FunctionDeviceType.PowerStation) + local curWorkEle = 0 + for _,v in ipairs(curSlotData) do + local slotConfig = XDataCenter.HostelManager.GetFuncDeviceSlotTemplate(v) + curWorkEle = curWorkEle + slotConfig.FunctionParam[1] * (slotConfig.FunctionParam[4] + config.FunctionParam[4]) + break + end + table_insert(datas,{CS.XTextManager.GetText("HostelWorkElectric")..str,CS.XTextManager.GetText("HostelPerSlot",curWorkEle)}) + table_insert(datas,{CS.XTextManager.GetText("HostelWorkSlot")..str,#curSlotData}) +end + +function XUiHostelDeviceUpgradeResult:GetFactoryContent(datas,deveice,config) + local curSlotData = XDataCenter.HostelManager.GetCurDeviceWorkSlot(XDataCenter.HostelManager.FunctionDeviceType.Factory) + local curWorkProduct = {} + for _,v in ipairs(curSlotData) do + local slotConfig = XDataCenter.HostelManager.GetFuncDeviceSlotTemplate(v) + local Id = slotConfig.FunctionParam[3] + if not curWorkProduct[Id] then + curWorkProduct[Id] = slotConfig.FunctionParam[4] + config.FunctionParam[1] + end + end + + for Id,count in pairs(curWorkProduct) do + table_insert(datas,{CS.XTextManager.GetText("HostelSlotProduct",XDataCenter.ItemManager.GetItemName(Id)),CS.XTextManager.GetText("HostelPerSlot",count)}) + end + table_insert(datas,{CS.XTextManager.GetText("HostelWorkSlot"),#curSlotData}) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiHostelDeviceUpgrading/XUiHostelDeviceUpgrading.lua b/Resources/Scripts/XUi/XUiHostelDeviceUpgrading/XUiHostelDeviceUpgrading.lua new file mode 100644 index 00000000..10b2cdd3 --- /dev/null +++ b/Resources/Scripts/XUi/XUiHostelDeviceUpgrading/XUiHostelDeviceUpgrading.lua @@ -0,0 +1,88 @@ +local XUiHostelDeviceUpgrading = XUiManager.Register("UiHostelDeviceUpgrading") +-- auto +-- Automatic generation of code, forbid to edit +function XUiHostelDeviceUpgrading:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiHostelDeviceUpgrading:AutoInitUi() + self.PanelFuncUpgrading = self.Transform:Find("SafeAreaContentPane/PanelFuncUpgrading") + self.TxtSysName = self.Transform:Find("SafeAreaContentPane/PanelFuncUpgrading/TxtSysName"):GetComponent("Text") + self.TxtUpgradeLeftTime = self.Transform:Find("SafeAreaContentPane/PanelFuncUpgrading/TxtUpgradeLeftTime"):GetComponent("Text") + self.PanelCharTopButton = self.Transform:Find("SafeAreaContentPane/PanelCharTopButton") + self.BtnBack = self.Transform:Find("SafeAreaContentPane/PanelCharTopButton/BtnBack"):GetComponent("Button") +end + +function XUiHostelDeviceUpgrading:GetAutoKey(uiNode,eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiHostelDeviceUpgrading:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiHostelDeviceUpgrading:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key],eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiHostelDeviceUpgrading:AutoAddListener() + self.AutoCreateListeners = {} + XUiHelper.RegisterClickEvent(self, self.BtnBack, self.OnBtnBackClick) +end +-- auto + +function XUiHostelDeviceUpgrading:OnOpen(type,funcBackUpgarding) + self:InitAutoScript() + self.CurFuncType = type + self.FuncBackUpgarding = funcBackUpgarding + local behaviour = self.GameObject:AddComponent(typeof(CS.XLuaBehaviour)) + behaviour.LuaUpdate = function() self:Update() end + self:UpdateView() +end + +function XUiHostelDeviceUpgrading:OnBtnBackClick() + CS.XUiManager.DialogManager:Pop() + if self.FuncBackUpgarding then + self.FuncBackUpgarding() + end +end + +function XUiHostelDeviceUpgrading:UpdateView() + local deveice = XDataCenter.HostelManager.GetFunctionDeviceData(self.CurFuncType) + if not deveice then return end + local nextConfig = XDataCenter.HostelManager.GetHostelFunctionDeviceLevelTemplate(self.CurFuncType,deveice.Level + 1) + if not nextConfig then return end + self.TxtSysName.text = nextConfig.Name + if deveice.UpgradeBeginTime > 0 then + self.EndUpgradTime = deveice.UpgradeBeginTime + nextConfig.CostTime + end +end + +function XUiHostelDeviceUpgrading:Update() + if self.EndUpgradTime and self.EndUpgradTime > 0 then + local curTime = XTime.GetServerNowTimestamp() + local leftTime = self.EndUpgradTime - curTime + if leftTime < 0 then + leftTime = 0 + end + self.TxtUpgradeLeftTime.text = XUiHelper.GetTime(leftTime, XUiHelper.TimeFormatType.SHOP) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiHostelMissionComplete/XUiHostelMissionComplete.lua b/Resources/Scripts/XUi/XUiHostelMissionComplete/XUiHostelMissionComplete.lua new file mode 100644 index 00000000..2b7c539d --- /dev/null +++ b/Resources/Scripts/XUi/XUiHostelMissionComplete/XUiHostelMissionComplete.lua @@ -0,0 +1,89 @@ +local XUiHostelMissionComplete = XLuaUiManager.Register(XLuaUi, "UiHostelMissionComplete") + +function XUiHostelMissionComplete:OnAwake() + self:InitAutoScript() +end + +function XUiHostelMissionComplete:OnStart(charId, rewards) + + self.CharId = charId + self.Rewards = rewards + self:Refresh() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiHostelMissionComplete:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiHostelMissionComplete:AutoInitUi() + self.BtnOk = self.Transform:Find("FullScreenBackground/BtnOk"):GetComponent("Button") + self.ImgHeadIcon = self.Transform:Find("SafeAreaContentPane/ImgHeadIcon"):GetComponent("Image") + self.TxtName = self.Transform:Find("SafeAreaContentPane/TxtName"):GetComponent("Text") + self.TxtDesc = self.Transform:Find("SafeAreaContentPane/TxtDesc"):GetComponent("Text") + self.ImgRewardIcon = self.Transform:Find("SafeAreaContentPane/ImgRewardIcon"):GetComponent("Image") + self.TxtRewardCount = self.Transform:Find("SafeAreaContentPane/TxtRewardCount"):GetComponent("Text") + self.TxtMsg = self.Transform:Find("SafeAreaContentPane/TxtMsg"):GetComponent("Text") +end + +function XUiHostelMissionComplete:GetAutoKey(uiNode, eventName) + if not uiNode then + return + end + return eventName .. uiNode:GetHashCode() +end + +function XUiHostelMissionComplete:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then + return + end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiHostelMissionComplete:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiHostelMissionComplete:AutoAddListener() + self.AutoCreateListeners = {} + self:RegisterClickEvent(self.BtnOk, self.OnBtnOkClick) +end +-- auto + +function XUiHostelMissionComplete:OnBtnOkClick() + --CS.XUiManager.DialogManager:Pop() + self:Close() +end + +function XUiHostelMissionComplete:Refresh() + local data = {} + local collectData = function(_, value) + data = value + end + XTool.LoopMap(self.Rewards.Items, collectData) + + -- local char = XDataCenter.CharacterManager.GetCharacter(self.CharId) + self:SetUiSprite(self.ImgHeadIcon, XDataCenter.CharacterManager.GetCharBigHeadIcon(self.CharId)) + self.TxtName.text = XCharacterConfigs.GetCharacterName(self.CharId) + + self.TxtDesc.text = CS.XTextManager.GetText("HostelWorkReward") + self:SetUiSprite(self.ImgRewardIcon, XDataCenter.ItemManager.GetItemIcon(data.Id)) + self.TxtRewardCount.text = data.Count +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiHostelQte/XUiHostelQte.lua b/Resources/Scripts/XUi/XUiHostelQte/XUiHostelQte.lua new file mode 100644 index 00000000..87a65692 --- /dev/null +++ b/Resources/Scripts/XUi/XUiHostelQte/XUiHostelQte.lua @@ -0,0 +1,65 @@ +local XUiHostelQte = XUiManager.Register("UiHostelQte") + +function XUiHostelQte:OnOpen() + self:InitAutoScript() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiHostelQte:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiHostelQte:AutoInitUi() + self.ImgHitArea = self.Transform:Find("FullScreenBackground/ImgHitArea"):GetComponent("Image") + self.ImgSuperHitArea = self.Transform:Find("FullScreenBackground/ImgSuperHitArea"):GetComponent("Image") + self.ImgLine = self.Transform:Find("FullScreenBackground/ImgLine"):GetComponent("Image") + self.BtnOk = self.Transform:Find("FullScreenBackground/BtnOk"):GetComponent("Button") + self.TxtRemainTime = self.Transform:Find("SafeAreaContentPane/TxtRemainTime"):GetComponent("Text") + self.SliTime = self.Transform:Find("SafeAreaContentPane/SliTime"):GetComponent("Slider") +end + +function XUiHostelQte:GetAutoKey(uiNode,eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiHostelQte:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiHostelQte:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key],eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiHostelQte:AutoAddListener() + self.AutoCreateListeners = {} + XUiHelper.RegisterClickEvent(self, self.BtnOk, self.OnBtnOkClick) + self:RegisterListener(self.SliTime, "onValueChanged", self.OnSliTimeValueChanged) +end +-- auto + +function XUiHostelQte:OnBtnOkClick() + +end + +function XUiHostelQte:OnSliTimeValueChanged() + +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiHostelRest/XUiGridFloorItem.lua b/Resources/Scripts/XUi/XUiHostelRest/XUiGridFloorItem.lua new file mode 100644 index 00000000..51c94da8 --- /dev/null +++ b/Resources/Scripts/XUi/XUiHostelRest/XUiGridFloorItem.lua @@ -0,0 +1,98 @@ +XUiGridFloorItem = XClass(nil, "XUiGridFloorItem") + +function XUiGridFloorItem:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self:InitAutoScript() + self.Floor = 0 + self.Select = false + self.CallBack = nil +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiGridFloorItem:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiGridFloorItem:AutoInitUi() + self.BtnFloor = self.Transform:Find("BtnFloor"):GetComponent("Button") + self.TxtFloor = self.Transform:Find("BtnFloor/TxtFloor"):GetComponent("Text") + self.PanelLock = self.Transform:Find("PanelLock") + self.BtnLock = self.Transform:Find("PanelLock/BtnLock"):GetComponent("Button") +end + +function XUiGridFloorItem:GetAutoKey(uiNode,eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiGridFloorItem:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiGridFloorItem:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key],eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiGridFloorItem:AutoAddListener() + self.AutoCreateListeners = {} + XUiHelper.RegisterClickEvent(self, self.BtnFloor, self.OnBtnFloorClick) + XUiHelper.RegisterClickEvent(self, self.BtnLock, self.OnBtnLockClick) +end +-- auto + +function XUiGridFloorItem:SetData(data) + self.GameObject:SetActive(true) + self.Floor = data.Floor + self.CallBack = data.CallBack + self:RefreshItem() +end + +function XUiGridFloorItem:RefreshItem() + if not XDataCenter.HostelManager.IsHostelFloorOpen(self.Floor) then + self.PanelLock.gameObject:SetActive(true) + return + end + self.PanelLock.gameObject:SetActive(false) + local config = XDataCenter.HostelManager.GetHostelRestTemplate(self.Floor) + if not config then return end + self.TxtFloor.text = config.Name +end + +function XUiGridFloorItem:SetSelect(value) + self.Select = value + if self.Select then + self.BtnFloor.interactable = false + else + self.BtnFloor.interactable = true + end +end + +function XUiGridFloorItem:OnBtnLockClick() + XUiManager.TipText("HostelFloorLock") +end + +function XUiGridFloorItem:OnBtnFloorClick() + if not XDataCenter.HostelManager.IsHostelFloorOpen(self.Floor) then + return + end + self.CallBack(self.Floor) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiHostelRest/XUiGridIdleCharacter.lua b/Resources/Scripts/XUi/XUiHostelRest/XUiGridIdleCharacter.lua new file mode 100644 index 00000000..443e50be --- /dev/null +++ b/Resources/Scripts/XUi/XUiHostelRest/XUiGridIdleCharacter.lua @@ -0,0 +1,129 @@ +XUiGridIdleCharacter = XClass(nil, "XUiGridIdleCharacter") + +function XUiGridIdleCharacter:Ctor(rootUi, ui) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + self:InitAutoScript() + self.Index = 0 + self.CharId = 0 + self.ClickCallBack = nil +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiGridIdleCharacter:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiGridIdleCharacter:AutoInitUi() + self.BtnItem = self.Transform:Find("BtnItem"):GetComponent("Button") + self.ImgIcon = self.Transform:Find("ImgIcon"):GetComponent("Image") + self.PanelCondition = self.Transform:Find("PanelCondition") + self.BtnCondition = self.Transform:Find("PanelCondition/BtnCondition"):GetComponent("Button") + self.TxtCondition = self.Transform:Find("PanelCondition/TxtCondition"):GetComponent("Text") + self.PanelVitality = self.Transform:Find("PanelVitality") + self.TxtVitality = self.Transform:Find("PanelVitality/TxtVitality"):GetComponent("Text") + self.PanelInSlot = self.Transform:Find("PanelInSlot") + self.ImgInSlot = self.Transform:Find("PanelInSlot/ImgInSlot"):GetComponent("Image") + self.TxtInSlot = self.Transform:Find("PanelInSlot/TxtInSlot"):GetComponent("Text") + self.PanelTag = self.Transform:Find("PanelTag") + self.TxtTag = self.Transform:Find("PanelTag/TxtTag"):GetComponent("Text") + self.ImgWorking = self.Transform:Find("PanelTag/ImgWorking"):GetComponent("Image") + self.ImgSelect = self.Transform:Find("ImgSelect"):GetComponent("Image") +end + +function XUiGridIdleCharacter:GetAutoKey(uiNode,eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiGridIdleCharacter:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiGridIdleCharacter:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key],eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiGridIdleCharacter:AutoAddListener() + self.AutoCreateListeners = {} + XUiHelper.RegisterClickEvent(self, self.BtnItem, self.OnBtnItemClick) + XUiHelper.RegisterClickEvent(self, self.BtnCondition, self.OnBtnConditionClick) +end +-- auto + +function XUiGridIdleCharacter:OnBtnItemClick() + if self.ClickCallBack then + self.ClickCallBack(self.Index, self.CharId) + end +end + +function XUiGridIdleCharacter:OnSliVitalityValueChanged() + +end + +function XUiGridIdleCharacter:OnBtnConditionClick() + +end + +function XUiGridIdleCharacter:SetClickCallBack(funcCallBack) + self.ClickCallBack = funcCallBack +end + +function XUiGridIdleCharacter:SetData(index, charId, showFloor) + self.ImgSelect.gameObject:SetActive(false) + self.GameObject:SetActive(true) + self.PanelCondition.gameObject:SetActive(false) + self.Index = index + self.CharId = charId + local character = XDataCenter.CharacterManager.GetCharacter(self.CharId) + if not character then return end + if character.Vitality >= XDataCenter.HostelManager.GetMaxCharacterVitality() or not character.InitVittality then + self.TxtVitality.text = CS.XTextManager.GetText("HostelFullVitality") + else + self.TxtVitality.text = character.Vitality .."/"..XDataCenter.HostelManager.GetMaxCharacterVitality() + end + + self.RootUi:SetUiSprite(self.ImgIcon, XDataCenter.CharacterManager.GetCharSmallHeadIcon(character.Id)) + local isRest, floor = XDataCenter.HostelManager.IsCharacterInRest(self.CharId) + if isRest and showFloor then + local config = XDataCenter.HostelManager.GetHostelRestTemplate(floor) + if not config then return end + self.TxtInSlot.text = config.Name + self.PanelInSlot.gameObject:SetActive(true) + else + self.PanelInSlot.gameObject:SetActive(false) + end + local isInWork = XDataCenter.HostelManager.IsCharacterInWork(self.CharId) + if isInWork then + self.PanelTag.gameObject:SetActive(true) + else + self.PanelTag.gameObject:SetActive(false) + end +end + +function XUiGridIdleCharacter:GetCharId() + return self.CharId +end + +function XUiGridIdleCharacter:SetSelect(value) + self.ImgSelect.gameObject:SetActive(value) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiHostelRest/XUiGridRestCharItem.lua b/Resources/Scripts/XUi/XUiHostelRest/XUiGridRestCharItem.lua new file mode 100644 index 00000000..f420189a --- /dev/null +++ b/Resources/Scripts/XUi/XUiHostelRest/XUiGridRestCharItem.lua @@ -0,0 +1,85 @@ +XUiGridRestCharItem = XClass(nil, "XUiGridRestCharItem") + +function XUiGridRestCharItem:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self:InitAutoScript() + self.Slot = 0 + self.CharId = 0 +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiGridRestCharItem:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiGridRestCharItem:AutoInitUi() + self.BtnItem = self.Transform:Find("BtnItem"):GetComponent("Button") + self.PanelInfo = self.Transform:Find("PanelInfo") + self.PanelWorking = self.Transform:Find("PanelInfo/PanelWorking") +end + +function XUiGridRestCharItem:GetAutoKey(uiNode,eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiGridRestCharItem:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiGridRestCharItem:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key],eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiGridRestCharItem:AutoAddListener() + self.AutoCreateListeners = {} + XUiHelper.RegisterClickEvent(self, self.BtnItem, self.OnBtnItemClick) +end +-- auto + +function XUiGridRestCharItem:SetData(data) + self.GameObject:SetActive(true) + self.Slot = data.Slot + self.CharId = data.CharId + if self.CharId == 0 then + self.PanelWorking.gameObject:SetActive(false) + return + end + -- local character = XDataCenter.CharacterManager.GetCharacter(self.CharId) + if XDataCenter.HostelManager.IsCharacterInWork(self.CharId) then + self.PanelWorking.gameObject:SetActive(true) + else + self.PanelWorking.gameObject:SetActive(false) + end +end + +function XUiGridRestCharItem:OnBtnItemClick() + +end + +function XUiGridRestCharItem:GetCharId() + return self.CharId +end + +function XUiGridRestCharItem:GetRectTransform() + return self.GameObject:GetComponent("RectTransform") +end diff --git a/Resources/Scripts/XUi/XUiHostelRest/XUiHostelRest.lua b/Resources/Scripts/XUi/XUiHostelRest/XUiHostelRest.lua new file mode 100644 index 00000000..4152b8a7 --- /dev/null +++ b/Resources/Scripts/XUi/XUiHostelRest/XUiHostelRest.lua @@ -0,0 +1,393 @@ +local XUiHostelRest = XLuaUiManager.Register(XLuaUi, "UiHostelRest") +local table_insert = table.insert + +-- auto +-- Automatic generation of code, forbid to edit +function XUiHostelRest:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiHostelRest:AutoInitUi() + self.PanelCharacterRest = self.Transform:Find("SafeAreaContentPane/PanelCharacterRest") + self.PanelLeftInfo = self.Transform:Find("SafeAreaContentPane/PanelCharacterRest/PanelLeftInfo") + self.SViewFloor = self.Transform:Find("SafeAreaContentPane/PanelCharacterRest/PanelLeftInfo/SViewFloor"):GetComponent("ScrollRect") + self.PanelFloorContent = self.Transform:Find("SafeAreaContentPane/PanelCharacterRest/PanelLeftInfo/SViewFloor/Viewport/PanelFloorContent") + self.GridFloorItem = self.Transform:Find("SafeAreaContentPane/PanelCharacterRest/PanelLeftInfo/SViewFloor/Viewport/PanelFloorContent/GridFloorItem") + self.RImgCharRest = self.Transform:Find("SafeAreaContentPane/PanelCharacterRest/PanelLeftInfo/RImgCharRest"):GetComponent("RawImage") + self.GridRestCharItem = self.Transform:Find("SafeAreaContentPane/PanelCharacterRest/PanelLeftInfo/GridRestCharItem") + self.PanelRestContent = self.Transform:Find("SafeAreaContentPane/PanelCharacterRest/PanelLeftInfo/PanelRestContent") + self.UiSlot1 = self.Transform:Find("SafeAreaContentPane/PanelCharacterRest/PanelLeftInfo/PanelRestContent/UiSlot1") + self.UiRestModelPos1 = self.Transform:Find("SafeAreaContentPane/PanelCharacterRest/PanelLeftInfo/PanelRestContent/UiSlot1/UiRestModelPos1") + self.UiSlot2 = self.Transform:Find("SafeAreaContentPane/PanelCharacterRest/PanelLeftInfo/PanelRestContent/UiSlot2") + self.UiRestModelPos2 = self.Transform:Find("SafeAreaContentPane/PanelCharacterRest/PanelLeftInfo/PanelRestContent/UiSlot2/UiRestModelPos2") + self.UiSlot3 = self.Transform:Find("SafeAreaContentPane/PanelCharacterRest/PanelLeftInfo/PanelRestContent/UiSlot3") + self.UiRestModelPos3 = self.Transform:Find("SafeAreaContentPane/PanelCharacterRest/PanelLeftInfo/PanelRestContent/UiSlot3/UiRestModelPos3") + self.UiSlot4 = self.Transform:Find("SafeAreaContentPane/PanelCharacterRest/PanelLeftInfo/PanelRestContent/UiSlot4") + self.UiRestModelPos4 = self.Transform:Find("SafeAreaContentPane/PanelCharacterRest/PanelLeftInfo/PanelRestContent/UiSlot4/UiRestModelPos4") + self.UiSlot5 = self.Transform:Find("SafeAreaContentPane/PanelCharacterRest/PanelLeftInfo/PanelRestContent/UiSlot5") + self.UiRestModelPos5 = self.Transform:Find("SafeAreaContentPane/PanelCharacterRest/PanelLeftInfo/PanelRestContent/UiSlot5/UiRestModelPos5") + self.UiSlot6 = self.Transform:Find("SafeAreaContentPane/PanelCharacterRest/PanelLeftInfo/PanelRestContent/UiSlot6") + self.UiRestModelPos6 = self.Transform:Find("SafeAreaContentPane/PanelCharacterRest/PanelLeftInfo/PanelRestContent/UiSlot6/UiRestModelPos6") + self.TxtTitle = self.Transform:Find("SafeAreaContentPane/PanelCharacterRest/PanelLeftInfo/TxtTitle"):GetComponent("Text") + self.TxtTitleFloor = self.Transform:Find("SafeAreaContentPane/PanelCharacterRest/PanelLeftInfo/TxtTitleFloor"):GetComponent("Text") + self.PanelRightInfo = self.Transform:Find("SafeAreaContentPane/PanelCharacterRest/PanelRightInfo") + self.SViewIdleCharList = self.Transform:Find("SafeAreaContentPane/PanelCharacterRest/PanelRightInfo/SViewIdleCharList"):GetComponent("ScrollRect") + self.PanelIdleCharContent = self.Transform:Find("SafeAreaContentPane/PanelCharacterRest/PanelRightInfo/SViewIdleCharList/Viewport/PanelIdleCharContent") + self.GridIdleCharacter = self.Transform:Find("SafeAreaContentPane/PanelCharacterRest/PanelRightInfo/SViewIdleCharList/Viewport/PanelIdleCharContent/GridIdleCharacter") + self.RImgCharDrag = self.Transform:Find("SafeAreaContentPane/PanelCharacterRest/RImgCharDrag"):GetComponent("RawImage") + self.PanelCharTopButton = self.Transform:Find("SafeAreaContentPane/PanelCharTopButton") + self.BtnBack = self.Transform:Find("SafeAreaContentPane/PanelCharTopButton/BtnBack"):GetComponent("Button") + self.BtnMainUi = self.Transform:Find("SafeAreaContentPane/PanelCharTopButton/BtnMainUi"):GetComponent("Button") + self.PanelAsset = self.Transform:Find("SafeAreaContentPane/PanelAsset") + self.PanelTool1 = self.Transform:Find("SafeAreaContentPane/PanelAsset/PanelTool1") + self.ImgTool1 = self.Transform:Find("SafeAreaContentPane/PanelAsset/PanelTool1/ImgTool1"):GetComponent("Image") + self.TxtTool1 = self.Transform:Find("SafeAreaContentPane/PanelAsset/PanelTool1/TxtTool1"):GetComponent("Text") + self.PanelTool2 = self.Transform:Find("SafeAreaContentPane/PanelAsset/PanelTool2") + self.ImgTool2 = self.Transform:Find("SafeAreaContentPane/PanelAsset/PanelTool2/ImgTool2"):GetComponent("Image") + self.TxtTool2 = self.Transform:Find("SafeAreaContentPane/PanelAsset/PanelTool2/TxtTool2"):GetComponent("Text") + self.PanelRestModel = self.Transform:Find("FullScreenBackground/PanelRestModel") + self.UiCharRestModel = self.Transform:Find("FullScreenBackground/PanelRestModel/UiCharRestModel") + self.PanelModelRest1 = self.Transform:Find("FullScreenBackground/PanelRestModel/UiCharRestModel/PanelModelRest1") + self.PanelModelRest2 = self.Transform:Find("FullScreenBackground/PanelRestModel/UiCharRestModel/PanelModelRest2") + self.PanelModelRest3 = self.Transform:Find("FullScreenBackground/PanelRestModel/UiCharRestModel/PanelModelRest3") + self.PanelModelRest4 = self.Transform:Find("FullScreenBackground/PanelRestModel/UiCharRestModel/PanelModelRest4") + self.PanelModelRest5 = self.Transform:Find("FullScreenBackground/PanelRestModel/UiCharRestModel/PanelModelRest5") + self.PanelModelRest6 = self.Transform:Find("FullScreenBackground/PanelRestModel/UiCharRestModel/PanelModelRest6") + self.PanelModelReste = self.Transform:Find("FullScreenBackground/PanelRestModel/UiCharRestModel/PanelModelReste") + self.UiCharRestDrag = self.Transform:Find("FullScreenBackground/PanelRestModel/UiCharRestDrag") + self.UiCameraRestDrag = self.Transform:Find("FullScreenBackground/PanelRestModel/UiCharRestDrag/UiCameraRestDrag") + self.PanelModelRestDrag = self.Transform:Find("FullScreenBackground/PanelRestModel/UiCharRestDrag/PanelModelRestDrag") +end + +function XUiHostelRest:GetAutoKey(uiNode, eventName) + if not uiNode then + return + end + return eventName .. uiNode:GetHashCode() +end + +function XUiHostelRest:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then + return + end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiHostelRest:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiHostelRest:AutoAddListener() + self.AutoCreateListeners = {} + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) +end +-- auto + +function XUiHostelRest:OnAwake() + self:InitAutoScript() +end + +function XUiHostelRest:OnStart() + + self:Init() + self.CurFloor = 0 + self.FloorUiItem = {} + self.RestCharUiItem = {} + self.IdleCharUiItem = {} + self:UpdateView() +end + +function XUiHostelRest:Init() + self.RctF = self.GameObject:GetComponent("RectTransform") + self.GridFloorItem.gameObject:SetActive(false) + self.GridRestCharItem.gameObject:SetActive(false) + self.GridIdleCharacter.gameObject:SetActive(false) + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.HostelElectric, XDataCenter.ItemManager.ItemId.HostelMat) + local tabScreenPosition = {} + for i = 1, 6 do + local pos = CS.XUiManager.UiCamera:WorldToViewportPoint(self["UiRestModelPos" .. i].transform.position) + table_insert(tabScreenPosition, pos) + end + self.ShowModel = XUiPanelRestModel.New(self.PanelRestModel, self.RImgCharRest, self.RImgCharDrag, tabScreenPosition, self.Name) +end + +function XUiHostelRest:OnBtnBackClick() + self:Close() +end + +function XUiHostelRest:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiHostelRest:OnBtnBuyJump1Click() + +end + +function XUiHostelRest:OnBtnBuyJump2Click() + +end + +function XUiHostelRest:OnBtnBuyJump3Click() + +end + +function XUiHostelRest:UpdateView() + self:UpdateFloorList() + self:UpdateIdleList() +end + +function XUiHostelRest:UpdateFloorList() + local maxFloor = XDataCenter.HostelManager.GetHostelMaxFloor() + local datas = {} + local callback = function(floor) + self:OnSelectFloor(floor) + end + for i = 1, maxFloor do + table_insert(datas, { Floor = i, CallBack = callback }) + end + local onCreate = function(item, data) + item:SetData(data) + end + XUiHelper.CreateTemplates(self, self.FloorUiItem, datas, XUiGridFloorItem.New, self.GridFloorItem.gameObject, self.PanelFloorContent, onCreate) + if self.CurFloor == 0 then + self:OnSelectFloor(1) + end +end + +function XUiHostelRest:OnSelectFloor(floor) + if self.CurFloor > 0 then + self.FloorUiItem[self.CurFloor]:SetSelect(false) + end + self.CurFloor = floor + if self.CurFloor > 0 then + self.FloorUiItem[self.CurFloor]:SetSelect(true) + end + self:UpdateRestList() + local config = XDataCenter.HostelManager.GetHostelRestTemplate(self.CurFloor) + if not config then + return + end + self.TxtTitleFloor.text = config.Name + self.TxtTitle.text = config.AreaName +end + +function XUiHostelRest:UpdateRestList() + local datas = {} + local restCount = XDataCenter.HostelManager.GetHostelFloorRestCount(self.CurFloor) + local charIdList = {} + for i = 1, restCount do + local restData = XDataCenter.HostelManager.GetHostelRestData(self.CurFloor, i) + local Id = restData and restData.CharacterId or 0 + table_insert(datas, { Slot = i, CharId = Id }) + table_insert(charIdList, Id) + end + local onCreate = function(item, data) + item:SetData(data) + self:SetRestItemDragFunc(item, data.Slot) + item.GameObject.transform:SetParent(self["UiSlot" .. data.Slot], false) + item:GetRectTransform().anchoredPosition = CS.UnityEngine.Vector2.zero + end + + self.RImgCharRest.gameObject:SetActive(true) + XUiHelper.CreateTemplates(self, self.RestCharUiItem, datas, XUiGridRestCharItem.New, self.GridRestCharItem.gameObject, nil, onCreate) + + self.ShowModel:UpdateShowCharRest(charIdList) +end + +function XUiHostelRest:SetRestItemDragFunc(item, slot) + if self["RestItem" .. slot] then + return + end + local dragItem = item.GameObject:AddComponent(typeof(CS.XUiWidget)) + dragItem:AddBeginDragListener(function(eventData) + self:OnRestItemBeginDrag(eventData, slot) + end) + dragItem:AddEndDragListener(function(eventData) + self:OnRestItemEndDrag(eventData, slot) + end) + dragItem:AddDragListener(function(eventData) + self:OnRestItemDrag(eventData, slot) + end) + self["RestItem" .. slot] = dragItem +end + +function XUiHostelRest:OnRestItemBeginDrag(eventData, slot) + local charId = self.RestCharUiItem[slot]:GetCharId() + if not charId or charId == 0 then + return + end + self.ShowModel:UpdateDragModel(charId) +end + +function XUiHostelRest:OnRestItemDrag(eventData, slot) + local charId = self.RestCharUiItem[slot]:GetCharId() + if not charId or charId == 0 then + return + end + -- local rectTransform = self.RImgCharDrag:GetComponent("RectTransform") + local _, position = CS.UnityEngine.RectTransformUtility.ScreenPointToLocalPointInRectangle(self.Transform, eventData.position, eventData.pressEventCamera) + self.RImgCharDrag.transform.localPosition = CS.UnityEngine.Vector3(position.x, position.y, 0) +end + +function XUiHostelRest:OnRestItemEndDrag(eventData, slot) + local charId = self.RestCharUiItem[slot]:GetCharId() + if not charId or charId == 0 then + return + end + self.ShowModel:HideDragModel() + local restSlot + for i, v in ipairs(self.RestCharUiItem) do + local isInRest = CS.UnityEngine.RectTransformUtility.RectangleContainsScreenPoint(v:GetRectTransform(), eventData.position, eventData.pressEventCamera) + if isInRest then + restSlot = i + break + end + end + if restSlot then + XDataCenter.HostelManager.ReqRestCharacter(charId, self.CurFloor, restSlot, function() + self:UpdateRestList() + self:UpdateIdleList() + end) + return + else + if XDataCenter.HostelManager.IsCharacterInWork(charId) then + return + end + end + + local isInRest = CS.UnityEngine.RectTransformUtility.RectangleContainsScreenPoint(self.PanelRestContent:GetComponent("RectTransform"), eventData.position, eventData.pressEventCamera) + if isInRest then + return + end + XDataCenter.HostelManager.ReqUnRestCharacter(self.CurFloor, slot, function() + self:UpdateRestList() + self:UpdateIdleList() + end) +end + +function XUiHostelRest:UpdateIdleList() + local charList = XDataCenter.CharacterManager.GetOwnCharacterList() or {} + table.sort(charList, function(a, b) + local aIsRest = XDataCenter.HostelManager.IsCharacterInRest(a.Id) + local bIsRest = XDataCenter.HostelManager.IsCharacterInRest(b.Id) + if aIsRest == bIsRest then + if aIsRest then + return a.Id > b.Id + else + -- 判断条件暂时没有 + return a.Id > b.Id + end + else + return bIsRest + end + end) + + local datas = {} + for i, v in ipairs(charList) do + table_insert(datas, { Index = i, Id = v.Id }) + end + local onCreate = function(item, data) + item:SetData(data.Index, data.Id, true) + self:SetIdleItemDragFunc(item, data.Index) + end + XUiHelper.CreateTemplates(self, self.IdleCharUiItem, datas, XUiGridIdleCharacter.New, self.GridIdleCharacter.gameObject, self.PanelIdleCharContent, onCreate) +end + +function XUiHostelRest:SetIdleItemDragFunc(item, index) + if self["IdleItem" .. index] then + return + end + local dragItem = item.GameObject:AddComponent(typeof(CS.XUiWidget)) + dragItem:AddBeginDragListener(function() + self:OnIdleItemBeginDrag(index) + end) + dragItem:AddEndDragListener(function(eventData) + self:OnIdleItemEndDrag(eventData, index) + end) + dragItem:AddDragListener(function(eventData) + self:OnIdleItemDrag(eventData, index) + end) + self["IdleItem" .. index] = dragItem +end + +function XUiHostelRest:OnIdleItemBeginDrag(index) + local charId = self.IdleCharUiItem[index]:GetCharId() + if not charId or charId == 0 then + return + end + if XDataCenter.HostelManager.IsCharacterInWork(charId) then + return + end + self.ShowModel:UpdateDragModel(charId) +end + +function XUiHostelRest:OnIdleItemDrag(eventData, index) + local charId = self.IdleCharUiItem[index]:GetCharId() + if not charId or charId == 0 then + return + end + -- local rectTransform = self.RImgCharDrag:GetComponent("RectTransform") + local _, position = CS.UnityEngine.RectTransformUtility.ScreenPointToLocalPointInRectangle(self.Transform, eventData.position, eventData.pressEventCamera) + self.RImgCharDrag.transform.localPosition = CS.UnityEngine.Vector3(position.x, position.y, 0) +end + +function XUiHostelRest:OnIdleItemEndDrag(eventData, index) + local charId = self.IdleCharUiItem[index]:GetCharId() + if not charId or charId == 0 then + return + end + self.ShowModel:HideDragModel() + local isInRest = CS.UnityEngine.RectTransformUtility.RectangleContainsScreenPoint(self.PanelRestContent:GetComponent("RectTransform"), eventData.position, eventData.pressEventCamera) + if not isInRest then + return + end + local emptySlot = self:GetEmptySlot() + local restSlot = 0 + local isCharRest = XDataCenter.HostelManager.IsCharacterInRest(charId) + if emptySlot and not isCharRest then + restSlot = emptySlot + else + for i, v in ipairs(self.RestCharUiItem) do + local tmpIsInRest = CS.UnityEngine.RectTransformUtility.RectangleContainsScreenPoint(v:GetRectTransform(), eventData.position, eventData.pressEventCamera) + if tmpIsInRest then + restSlot = i + break + end + end + end + if restSlot == 0 then + return + end + XDataCenter.HostelManager.ReqRestCharacter(charId, self.CurFloor, restSlot, function() + self:UpdateRestList() + self:UpdateIdleList() + end) + +end + +function XUiHostelRest:GetEmptySlot() + local restCount = XDataCenter.HostelManager.GetHostelFloorRestCount(self.CurFloor) + for i = 1, restCount do + local restData = XDataCenter.HostelManager.GetHostelRestData(self.CurFloor, i) + if not restData or restData.CharacterId == 0 then + return i + end + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiHostelRest/XUiPanelRestModel.lua b/Resources/Scripts/XUi/XUiHostelRest/XUiPanelRestModel.lua new file mode 100644 index 00000000..56931eac --- /dev/null +++ b/Resources/Scripts/XUi/XUiHostelRest/XUiPanelRestModel.lua @@ -0,0 +1,125 @@ +XUiPanelRestModel = XClass(nil, "XUiPanelRestModel") + +function XUiPanelRestModel:Ctor(ui,rawImgRest, rawImgDrag, tScreenPos, refName) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Transform3d = ui.transform + self.RawImgRest = rawImgRest + self.RawImgDrag = rawImgDrag + self.RefName = refName + self:InitAutoScript() + self:InitRes(tScreenPos) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelRestModel:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiPanelRestModel:AutoInitUi() + self.UiCharRestDrag = self.Transform:Find("UiCharRestDrag") + self.UiCameraRestDrag = self.Transform:Find("UiCharRestDrag/UiCameraRestDrag") + self.PanelModelRestDrag = self.Transform:Find("UiCharRestDrag/PanelModelRestDrag") + self.UiCharRestModel = self.Transform:Find("UiCharRestModel") + self.PanelModelRest1 = self.Transform:Find("UiCharRestModel/PanelModelRest1") + self.PanelModelRest2 = self.Transform:Find("UiCharRestModel/PanelModelRest2") + self.PanelModelRest3 = self.Transform:Find("UiCharRestModel/PanelModelRest3") + self.PanelModelRest4 = self.Transform:Find("UiCharRestModel/PanelModelRest4") + self.PanelModelRest5 = self.Transform:Find("UiCharRestModel/PanelModelRest5") + self.PanelModelRest6 = self.Transform:Find("UiCharRestModel/PanelModelRest6") + self.PanelModelReste = self.Transform:Find("UiCharRestModel/PanelModelReste") +end + +function XUiPanelRestModel:GetAutoKey(uiNode,eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiPanelRestModel:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiPanelRestModel:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key],eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiPanelRestModel:AutoAddListener() + self.AutoCreateListeners = {} +end +-- auto + +function XUiPanelRestModel:InitRes(tScreenPos) + XRTextureManager.SetTextureCache(self.RawImgRest) + local cameraRest = CS.XUiManager.UiModelCamera + cameraRest.gameObject:SetActive(true) + for i,v in ipairs(tScreenPos) do + self["PanelModelRest"..i].transform.position = cameraRest:ViewportToWorldPoint(v) + end + + local renderTextureDrag = CS.UnityEngine.RenderTexture(512,512,0) + self.RawImgDrag.texture = renderTextureDrag + local cameraDrag = self.UiCameraRestDrag:GetComponent("Camera") + cameraDrag.targetTexture = renderTextureDrag + local rtf = self.RawImgDrag:GetComponent("RectTransform") + rtf.sizeDelta = CS.UnityEngine.Vector2(512,512) + + + for i=1,6 do + self["RoleModel"..i] = XUiPanelRoleModel.New(self["PanelModelRest"..i], self.RefName) + end + self.RoleDrag = XUiPanelRoleModel.New(self.PanelModelRestDrag, self.RefName) + +end + + +function XUiPanelRestModel:UpdateShowCharRest(charList) + for i=1,6 do + self["RoleModel"..i]:HideRoleModel() + end + local func = function(model) + if not model then return end + local oldpos = model.transform.position + model.transform.position = CS.UnityEngine.Vector3(oldpos.x,oldpos.y - 1,oldpos.z) + model.transform.localScale = CS.UnityEngine.Vector3(1.3,1.3,1.3) + model.transform.localEulerAngles = CS.UnityEngine.Vector3(0,180,0) + end + + for i,v in ipairs(charList) do + if v ~= 0 then + self["RoleModel"..i]:UpdateCharacterModel(v,nil,nil,func) + self["RoleModel"..i]:ShowRoleModel() + end + end +end + +function XUiPanelRestModel:UpdateDragModel(charId) + local func = function(model) + if not model then return end + -- local oldpos = model.transform.position + model.transform.localEulerAngles = CS.UnityEngine.Vector3(0,180,0) + end + self.RoleDrag:UpdateCharacterModel(charId,nil,nil,func) + self.RawImgDrag.gameObject:SetActive(true) +end + +function XUiPanelRestModel:HideDragModel() + self.RawImgDrag.gameObject:SetActive(false) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiHostelRoom/XUiHostelRoom.lua b/Resources/Scripts/XUi/XUiHostelRoom/XUiHostelRoom.lua new file mode 100644 index 00000000..c0b3ab67 --- /dev/null +++ b/Resources/Scripts/XUi/XUiHostelRoom/XUiHostelRoom.lua @@ -0,0 +1,80 @@ +local XUiHostelRoom = XLuaUiManager.Register(XLuaUi, "UiHostelRoom") + +function XUiHostelRoom:OnAwake() + self:InitAutoScript() +end + +function XUiHostelRoom:OnStart() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.HostelElectric, XDataCenter.ItemManager.ItemId.HostelMat) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiHostelRoom:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiHostelRoom:AutoInitUi() + self.PanelDeviceUpgradeInfo = self.Transform:Find("SafeAreaContentPane/PanelDeviceUpgradeInfo") + self.PanelCharTopButton = self.Transform:Find("SafeAreaContentPane/PanelCharTopButton") + self.BtnBack = self.Transform:Find("SafeAreaContentPane/PanelCharTopButton/BtnBack"):GetComponent("Button") + self.BtnMainUi = self.Transform:Find("SafeAreaContentPane/PanelCharTopButton/BtnMainUi"):GetComponent("Button") + self.PanelAsset = self.Transform:Find("SafeAreaContentPane/PanelAsset") + self.PanelTool1 = self.Transform:Find("SafeAreaContentPane/PanelAsset/PanelTool1") + self.ImgTool1 = self.Transform:Find("SafeAreaContentPane/PanelAsset/PanelTool1/ImgTool1"):GetComponent("Image") + self.TxtTool1 = self.Transform:Find("SafeAreaContentPane/PanelAsset/PanelTool1/TxtTool1"):GetComponent("Text") + self.PanelTool2 = self.Transform:Find("SafeAreaContentPane/PanelAsset/PanelTool2") + self.ImgTool2 = self.Transform:Find("SafeAreaContentPane/PanelAsset/PanelTool2/ImgTool2"):GetComponent("Image") + self.TxtTool2 = self.Transform:Find("SafeAreaContentPane/PanelAsset/PanelTool2/TxtTool2"):GetComponent("Text") +end + +function XUiHostelRoom:GetAutoKey(uiNode, eventName) + if not uiNode then + return + end + return eventName .. uiNode:GetHashCode() +end + +function XUiHostelRoom:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then + return + end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiHostelRoom:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiHostelRoom:AutoAddListener() + self.AutoCreateListeners = {} + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) +end +-- auto + +function XUiHostelRoom:OnBtnBackClick() + XHomeSceneManager.ChangeBackToOverView() + XHomeInfrastructureManager.ChangeCameraToScene() + self:Close() +end + +function XUiHostelRoom:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiHud/XUiGridCoolTime.lua b/Resources/Scripts/XUi/XUiHud/XUiGridCoolTime.lua new file mode 100644 index 00000000..985db791 --- /dev/null +++ b/Resources/Scripts/XUi/XUiHud/XUiGridCoolTime.lua @@ -0,0 +1,145 @@ +local XUiGridCoolTime = XClass(XLuaBehaviour, "XUiGridCoolTime") + +local RemainTimerName = "XUiGridCoolTime_RemainTimer" + +function XUiGridCoolTime:Ctor(rootUi, ui, hudType) + self.RootUi = rootUi + self.InstId = 0 + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.IsShow = false + self.HudType = hudType + + self:InitAutoScript() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiGridCoolTime:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiGridCoolTime:AutoInitUi() + self.TxtTime = XUiHelper.TryGetComponent(self.Transform, "TxtTime", "Text") +end + +function XUiGridCoolTime:GetAutoKey(uiNode,eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiGridCoolTime:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiGridCoolTime:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key],eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiGridCoolTime:AutoAddListener() + self.AutoCreateListeners = {} +end +-- auto + +function XUiGridCoolTime:Update() + if (not XTool.UObjIsNil(self.FollowTarget) and not XTool.UObjIsNil(self.Camera)) then + local followPos = self.FollowTarget.position + if self.Data.Cfg then + followPos = followPos + CS.UnityEngine.Vector3(self.Data.Cfg.HudX or 0,self.Data.Cfg.HudY or 0,0) + end + local viewportPos = self.Camera:WorldToViewportPoint(followPos) + self.Transform.anchoredPosition = CS.UnityEngine.Vector2(viewportPos.x * XGlobalVar.UiDesignSize.Width, viewportPos.y * XGlobalVar.UiDesignSize.Height) + end +end + +function XUiGridCoolTime:SetMetaData(data) + self.IsShow = true + self.GameObject:SetActive(true) + self.Data = data + self:InitSizeAndScale() + self.RemainTime = data.Time + self.TimeOutCb = data.CallBack + self:InitTime() +end + +function XUiGridCoolTime:InitSizeAndScale() + if not self.Data.Cfg then + return + end + local cfgHei = self.Data.Cfg.HudHeight or 0 + local cfgWid = self.Data.Cfg.HudWidth or 0 + local cfgScale = self.Data.Cfg.HudScale or 0 + local sizeX = (cfgWid > 0) and cfgWid or self.Transform.sizeDelta.x + local sizeY = (cfgHei > 0) and cfgHei or self.Transform.sizeDelta.y + self.Transform.sizeDelta = CS.UnityEngine.Vector2(sizeX,sizeY) + local scale = (cfgScale > 0) and cfgScale or 1 + self.Transform.localScale = CS.UnityEngine.Vector3(scale,scale,scale) +end + +function XUiGridCoolTime:SetFollowTarget(transform, camera) + self.FollowTarget = transform + self.Camera = camera +end + +function XUiGridCoolTime:Refresh() + -- +end + +function XUiGridCoolTime:GetTimerName() + if not self.TimerName then + self.TimerName = RemainTimerName..self.InstId + end + return self.TimerName +end + +function XUiGridCoolTime:Dispose() + XCountDown.RemoveTimer(self:GetTimerName()) + self.RemainTime = nil + self.FollowTarget = nil + self.Camera = nil +end + +function XUiGridCoolTime:Hide() + self:Dispose() + self.IsShow = false + self.GameObject:SetActive(false) + XHudManager.ReturnHud(self) +end + +function XUiGridCoolTime:InitTime() + XCountDown.CreateTimer(self:GetTimerName(), self.RemainTime) + XCountDown.BindTimer(self, self:GetTimerName(), function(v) + if v > 0 then + if not XTool.UObjIsNil(self.TxtTime) then + self.TxtTime.text = XUiHelper.GetTime(v, XUiHelper.TimeFormatType.HOSTEL) + end + else + if not XTool.UObjIsNil(self.TxtTime) then + self.TxtTime.text = "" + end + self:Hide() + if self.TimeOutCb then + self.TimeOutCb() + end + end + end) +end + +return XUiGridCoolTime \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiHud/XUiGridDeviceState.lua b/Resources/Scripts/XUi/XUiHud/XUiGridDeviceState.lua new file mode 100644 index 00000000..a38ec685 --- /dev/null +++ b/Resources/Scripts/XUi/XUiHud/XUiGridDeviceState.lua @@ -0,0 +1,155 @@ +local XUiGridDeviceState = XClass(XLuaBehaviour, "XUiGridDeviceState") + +function XUiGridDeviceState:Ctor(rootUi, ui, hudType) + self.RootUi = rootUi + self.InstId = 0 + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.IsShow = false + self.HudType = hudType + self.IsInViewPort = true + + self:InitAutoScript() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiGridDeviceState:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiGridDeviceState:AutoInitUi() + self.TxtDesc = XUiHelper.TryGetComponent(self.Transform, "ImageTextBg/TxtDesc", "Text") + self.ImgIcon = XUiHelper.TryGetComponent(self.Transform, "ImgIcon", "Image") + self.BtnOk = XUiHelper.TryGetComponent(self.Transform, "BtnOk", "Button") +end + +function XUiGridDeviceState:GetAutoKey(uiNode,eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiGridDeviceState:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiGridDeviceState:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key],eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiGridDeviceState:AutoAddListener() + self.AutoCreateListeners = {} + XUiHelper.RegisterClickEvent(self, self.BtnOk, self.OnBtnOkClick) +end +-- auto + +function XUiGridDeviceState:Update() + if (not XTool.UObjIsNil(self.FollowTarget) and not XTool.UObjIsNil(self.Camera)) then + if self.IsInViewPort then + local followPos = self.FollowTarget.position + if self.Data.Cfg then + followPos = followPos + CS.UnityEngine.Vector3(self.Data.Cfg.HudX or 0,self.Data.Cfg.HudY or 0,0) + end + local viewportPos = self.Camera:WorldToViewportPoint(followPos) + self.Transform.anchoredPosition = CS.UnityEngine.Vector2(viewportPos.x * XGlobalVar.UiDesignSize.Width, viewportPos.y * XGlobalVar.UiDesignSize.Height) + end + self:Refresh() + end +end + +function XUiGridDeviceState:OnBtnOkClick() + if self.DeviceType == XDataCenter.HostelManager.FunctionDeviceType.PowerStation then + local curVlue = XDataCenter.HostelManager.GetPowerStationSaveElectric() + if curVlue > 0 then + XDataCenter.HostelManager.ReqCollectPowerStationElectric(function () + local rewards = {} + table.insert(rewards, {TemplateId = XDataCenter.ItemManager.ItemId.HostelElectric, Count = curVlue}) + XUiManager.OpenUiObtain(rewards) + end) + end + end +end + +function XUiGridDeviceState:SetMetaData(data) + self.GameObject:SetActive(true) + self.IsShow = true + self.Data = data + self:InitSizeAndScale() + self.DeviceType = data.Type + self.Func = data.Func + self.DeviceConfig = XDataCenter.HostelManager.GetFuncDeviceCurLvlTemplate(self.DeviceType) + if self.DeviceType == XDataCenter.HostelManager.FunctionDeviceType.PowerStation then + self.RootUi:SetUiSprite(self.ImgIcon, XDataCenter.ItemManager.GetItemIcon(XDataCenter.ItemManager.ItemId.HostelElectric)) + end +end + +function XUiGridDeviceState:InitSizeAndScale() + if not self.Data.Cfg then + return + end + local cfgHei = self.Data.Cfg.HudHeight or 0 + local cfgWid = self.Data.Cfg.HudWidth or 0 + local cfgScale = self.Data.Cfg.HudScale or 0 + local sizeX = (cfgWid > 0) and cfgWid or self.Transform.sizeDelta.x + local sizeY = (cfgHei > 0) and cfgHei or self.Transform.sizeDelta.y + self.Transform.sizeDelta = CS.UnityEngine.Vector2(sizeX,sizeY) + local scale = (cfgScale > 0) and cfgScale or 1 + self.Transform.localScale = CS.UnityEngine.Vector3(scale,scale,scale) +end + +function XUiGridDeviceState:SetFollowTarget(transform, camera) + self.FollowTarget = transform + self.Camera = camera +end + +function XUiGridDeviceState:Refresh() + if self.DeviceType == XDataCenter.HostelManager.FunctionDeviceType.PowerStation then + local curVlue = XDataCenter.HostelManager.GetPowerStationSaveElectric() + local isRoomView = XHomeSceneManager.GetCurrentView() == HomeSceneViewType.RoomView + self:SetInViewPort(curVlue > 0 and isRoomView) + if curVlue >= self.DeviceConfig.FunctionParam[3] then + self.TxtDesc.text = CS.XTextManager.GetText("HostelFullElectric") + else + self.TxtDesc.text = curVlue.."/"..self.DeviceConfig.FunctionParam[3] + end + end +end + +function XUiGridDeviceState:Dispose() + self.DeviceType = nil + self.FollowTarget = nil + self.Camera = nil +end + +function XUiGridDeviceState:Hide() + self:Dispose() + self.IsShow = false + self.GameObject:SetActive(false) + XHudManager.ReturnHud(self) +end + +function XUiGridDeviceState:SetInViewPort(value) + self.IsInViewPort = value + if not value then + self.Transform.anchoredPosition = CS.UnityEngine.Vector2(10000,10000) + end +end + +return XUiGridDeviceState \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiHud/XUiGridRoomUpgrade.lua b/Resources/Scripts/XUi/XUiHud/XUiGridRoomUpgrade.lua new file mode 100644 index 00000000..b7accf47 --- /dev/null +++ b/Resources/Scripts/XUi/XUiHud/XUiGridRoomUpgrade.lua @@ -0,0 +1,160 @@ +local XUiGridRoomUpgrade = XClass(XLuaBehaviour, "XUiGridRoomUpgrade") + +local RemainTimerName = "XUiGridRoomUpgrade_RemainTimer" + +function XUiGridRoomUpgrade:Ctor(rootUi, ui, hudType) + self.RootUi = rootUi + self.InstId = 0 + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.IsShow = false + self.HudType = hudType + + self:InitAutoScript() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiGridRoomUpgrade:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiGridRoomUpgrade:AutoInitUi() + self.PanelUpgrading = XUiHelper.TryGetComponent(self.Transform, "PanelUpgrading", nil) + self.TxtTime = XUiHelper.TryGetComponent(self.Transform, "PanelUpgrading/TxtTime", "Text") + self.PanelComplete = XUiHelper.TryGetComponent(self.Transform, "PanelComplete", nil) +end + +function XUiGridRoomUpgrade:GetAutoKey(uiNode,eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiGridRoomUpgrade:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiGridRoomUpgrade:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key],eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiGridRoomUpgrade:AutoAddListener() + self.AutoCreateListeners = {} +end +-- auto + +function XUiGridRoomUpgrade:Update() + if (not XTool.UObjIsNil(self.FollowTarget) and not XTool.UObjIsNil(self.Camera)) then + local followPos = self.FollowTarget.position + if self.Data.Cfg then + followPos = followPos + CS.UnityEngine.Vector3(self.Data.Cfg.HudX or 0,self.Data.Cfg.HudY or 0,0) + end + local viewportPos = self.Camera:WorldToViewportPoint(followPos) + self.Transform.anchoredPosition = CS.UnityEngine.Vector2(viewportPos.x * XGlobalVar.UiDesignSize.Width, viewportPos.y * XGlobalVar.UiDesignSize.Height) + end +end + +function XUiGridRoomUpgrade:SetMetaData(data) + self.IsShow = true + self.GameObject:SetActive(true) + self.Data = data + self:InitSizeAndScale() + self:InitTime() +end + +function XUiGridRoomUpgrade:InitSizeAndScale() + if not self.Data.Cfg then + return + end + local cfgHei = self.Data.Cfg.HudHeight or 0 + local cfgWid = self.Data.Cfg.HudWidth or 0 + local cfgScale = self.Data.Cfg.HudScale or 0 + local sizeX = (cfgWid > 0) and cfgWid or self.Transform.sizeDelta.x + local sizeY = (cfgHei > 0) and cfgHei or self.Transform.sizeDelta.y + self.Transform.sizeDelta = CS.UnityEngine.Vector2(sizeX,sizeY) + local scale = (cfgScale > 0) and cfgScale or 1 + self.Transform.localScale = CS.UnityEngine.Vector3(scale,scale,scale) +end + +function XUiGridRoomUpgrade:SetFollowTarget(transform, camera) + self.FollowTarget = transform + self.Camera = camera +end + +function XUiGridRoomUpgrade:Refresh() + -- +end + +function XUiGridRoomUpgrade:Dispose() + XCountDown.RemoveTimer(RemainTimerName) + self.Data = nil + self.State = nil + self.FollowTarget = nil + self.Camera = nil +end + +function XUiGridRoomUpgrade:Hide() + self:Dispose() + self.State = XDataCenter.HostelManager.DeviceUpgradeState.Normal + self.GameObject:SetActive(false) + XHudManager.ReturnHud(self) +end + +function XUiGridRoomUpgrade:InitTime() + local state, remainTime = XDataCenter.HostelManager.GetFuncDeviceUpgradeState(self.Data.Type) + self.State = state + + if not XTool.UObjIsNil(self.PanelUpgrading) then + self.PanelUpgrading.gameObject:SetActive(state == XDataCenter.HostelManager.DeviceUpgradeState.Upgrading) + end + + if not XTool.UObjIsNil(self.PanelComplete) then + self.PanelComplete.gameObject:SetActive(state == XDataCenter.HostelManager.DeviceUpgradeState.Complete) + end + + if state == XDataCenter.HostelManager.DeviceUpgradeState.Complete then + return + end + + XCountDown.CreateTimer(RemainTimerName, remainTime) + XCountDown.BindTimer(self, RemainTimerName, function(v) + if not XTool.UObjIsNil(self.PanelUpgrading) then + self.PanelUpgrading.gameObject:SetActive(v > 0) + end + + if not XTool.UObjIsNil(self.PanelComplete) then + self.PanelComplete.gameObject:SetActive(v <= 0) + end + + if v > 0 then + if not XTool.UObjIsNil(self.TxtTime) then + self.TxtTime.text = XUiHelper.GetTime(v, XUiHelper.TimeFormatType.HOSTEL) + end + self.State = XDataCenter.HostelManager.DeviceUpgradeState.Upgrading + else + if not XTool.UObjIsNil(self.TxtTime) then + self.TxtTime.text = "" + end + self.State = XDataCenter.HostelManager.DeviceUpgradeState.Complete + end + end) +end + +return XUiGridRoomUpgrade \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiHud/XUiGridWorkSlotState.lua b/Resources/Scripts/XUi/XUiHud/XUiGridWorkSlotState.lua new file mode 100644 index 00000000..1622aa62 --- /dev/null +++ b/Resources/Scripts/XUi/XUiHud/XUiGridWorkSlotState.lua @@ -0,0 +1,152 @@ +local XUiGridWorkSlotState = XClass(XLuaBehaviour, "XUiGridWorkSlotState") + +function XUiGridWorkSlotState:Ctor(rootUi, ui, hudType) + self.RootUi = rootUi + self.InstId = 0 + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.IsShow = false + self.HudType = hudType + + self:InitAutoScript() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiGridWorkSlotState:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiGridWorkSlotState:AutoInitUi() + self.BtnComplete = XUiHelper.TryGetComponent(self.Transform, "BtnComplete", "Button") + self.BtnAdd = XUiHelper.TryGetComponent(self.Transform, "BtnAdd", "Button") + self.ImgJiantou = XUiHelper.TryGetComponent(self.Transform, "ImgJiantou", "Image") +end + +function XUiGridWorkSlotState:GetAutoKey(uiNode,eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiGridWorkSlotState:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiGridWorkSlotState:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key],eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiGridWorkSlotState:AutoAddListener() + self.AutoCreateListeners = {} + XUiHelper.RegisterClickEvent(self, self.BtnComplete, self.OnBtnCompleteClick) + XUiHelper.RegisterClickEvent(self, self.BtnAdd, self.OnBtnAddClick) +end +-- auto + +function XUiGridWorkSlotState:OnBtnCompleteClick() + local cb = self.Data.fClickComplete + if cb then + cb() + end +end + +function XUiGridWorkSlotState:OnBtnAddClick() + local cb = self.Data.fClickAdd + if cb then + cb() + end +end + +function XUiGridWorkSlotState:Update() + if (not XTool.UObjIsNil(self.FollowTarget) and not XTool.UObjIsNil(self.Camera)) then + local followPos = self.FollowTarget.position + if self.Data.Cfg then + followPos = followPos + CS.UnityEngine.Vector3(self.Data.Cfg.HudX or 0,self.Data.Cfg.HudY or 0,0) + end + local viewportPos = self.Camera:WorldToViewportPoint(followPos) + self.Transform.anchoredPosition = CS.UnityEngine.Vector2(viewportPos.x * XGlobalVar.UiDesignSize.Width, viewportPos.y * XGlobalVar.UiDesignSize.Height) + end +end + +function XUiGridWorkSlotState:SetMetaData(data) + self.IsShow = true + self.GameObject:SetActive(true) + self.Data = data + self:InitSizeAndScale() + self:Refresh() +end + +function XUiGridWorkSlotState:InitSizeAndScale() + if not self.Data.Cfg then + return + end + local cfgHei = self.Data.Cfg.HudHeight or 0 + local cfgWid = self.Data.Cfg.HudWidth or 0 + local cfgScale = self.Data.Cfg.HudScale or 0 + local sizeX = (cfgWid > 0) and cfgWid or self.Transform.sizeDelta.x + local sizeY = (cfgHei > 0) and cfgHei or self.Transform.sizeDelta.y + self.Transform.sizeDelta = CS.UnityEngine.Vector2(sizeX,sizeY) + local scale = (cfgScale > 0) and cfgScale or 1 + self.Transform.localScale = CS.UnityEngine.Vector3(scale,scale,scale) +end + +function XUiGridWorkSlotState:SetFollowTarget(transform, camera) + self.FollowTarget = transform + self.Camera = camera +end + +function XUiGridWorkSlotState:Refresh() + local state = self.Data.State + self.BtnComplete.gameObject:SetActive(false) + self.BtnAdd.gameObject:SetActive(false) + self.ImgJiantou.gameObject:SetActive(false) + if state == XDataCenter.HostelManager.WorkSlotState.Idle then + self.BtnAdd.gameObject:SetActive(true) + elseif state == XDataCenter.HostelManager.WorkSlotState.Complete then + self.BtnComplete.gameObject:SetActive(true) + end +end + +function XUiGridWorkSlotState:ShowJiantou() + self.BtnComplete.gameObject:SetActive(false) + self.BtnAdd.gameObject:SetActive(false) + self.ImgJiantou.gameObject:SetActive(true) +end + +function XUiGridWorkSlotState:HideContent() + self.BtnComplete.gameObject:SetActive(false) + self.BtnAdd.gameObject:SetActive(false) + self.ImgJiantou.gameObject:SetActive(false) +end + +function XUiGridWorkSlotState:Dispose() + self.Data = nil + self.FollowTarget = nil + self.Camera = nil +end + +function XUiGridWorkSlotState:Hide() + self:Dispose() + self.GameObject:SetActive(false) + self.IsShow = false + XHudManager.ReturnHud(self) +end + +return XUiGridWorkSlotState \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiHud/XUiHud.lua b/Resources/Scripts/XUi/XUiHud/XUiHud.lua new file mode 100644 index 00000000..437f7ddf --- /dev/null +++ b/Resources/Scripts/XUi/XUiHud/XUiHud.lua @@ -0,0 +1,151 @@ +local XUiGridCoolTime = require("XUi/XUiHud/XUiGridCoolTime") +local XUiGridDeviceState = require("XUi/XUiHud/XUiGridDeviceState") +local XUiGridWorkSlotState = require("XUi/XUiHud/XUiGridWorkSlotState") +local XUiGridRoomUpgrade = require("XUi/XUiHud/XUiGridRoomUpgrade") + +local HudInstId = 1 + +local XUiHud = XLuaUiManager.Register(XLuaUi, "UiHud") + +function XUiHud:OnAwake() + +end + +function XUiHud:OnStart() + self:InitAutoScript() + + self:InitHudPool() + XHudManager.AddHudFunc(function(hudType) + return self:GetHudFromPool(hudType) + end, + function(hud) + self:ReturnHudToPool(hud) + end) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiHud:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiHud:AutoInitUi() + self.PanelCoolTime = self.Transform:Find("FullScreenBackground/PanelCoolTime") + self.GridCoolTime = self.Transform:Find("FullScreenBackground/PanelCoolTime/GridCoolTime") + self.PanelDeviceState = self.Transform:Find("FullScreenBackground/PanelDeviceState") + self.GridDeviceState = self.Transform:Find("FullScreenBackground/PanelDeviceState/GridDeviceState") + self.PanelWorkSlotState = self.Transform:Find("FullScreenBackground/PanelWorkSlotState") + self.GridWorkSlotState = self.Transform:Find("FullScreenBackground/PanelWorkSlotState/GridWorkSlotState") + self.PanelRoomUpgrade = self.Transform:Find("FullScreenBackground/PanelRoomUpgrade") + self.GridRoomUpgrade = self.Transform:Find("FullScreenBackground/PanelRoomUpgrade/GridRoomUpgrade") +end + +function XUiHud:GetAutoKey(uiNode, eventName) + if not uiNode then + return + end + return eventName .. uiNode:GetHashCode() +end + +function XUiHud:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then + return + end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiHud:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiHud:AutoAddListener() + self.AutoCreateListeners = {} +end +-- auto + +function XUiHud:HideTemplateGrids() + for _, config in pairs(self.HudConfig) do + config.go.gameObject:SetActive(false) + end +end + +-- Init Hud Pool +function XUiHud:InitHudPool() + -- generate config + self.HudConfig = { + [UiHudType.CoolTime] = { root = self.PanelCoolTime, go = self.GridCoolTime, luaCtor = XUiGridCoolTime.New }, + [UiHudType.DeviceState] = { root = self.PanelDeviceState, go = self.GridDeviceState, luaCtor = XUiGridDeviceState.New }, + [UiHudType.WorkSlotState] = { root = self.PanelWorkSlotState, go = self.GridWorkSlotState, luaCtor = XUiGridWorkSlotState.New }, + [UiHudType.RoomUpgrade] = { root = self.PanelRoomUpgrade, go = self.GridRoomUpgrade, luaCtor = XUiGridRoomUpgrade.New }, + } + + self:HideTemplateGrids() + + HudInstId = 1 + + -- init pool + self.Pool = {} + for i, _ in pairs(self.HudConfig) do + self.Pool[i] = {} + end +end + +-- Get the type of HUD from the pool +function XUiHud:GetHudFromPool(hudType) + local hud = nil + local pool = self.Pool[hudType] + + if pool then + for _, v in pairs(pool) do + hud = v + break + end + if hud then + pool[hud] = nil + end + end + + if not hud then + local config = self.HudConfig[hudType] + + local go = CS.UnityEngine.Object.Instantiate(config.go) + go.transform:SetParent(config.root, false) + + hud = config.luaCtor(self, go, hudType) + end + + hud.InstId = HudInstId + HudInstId = HudInstId + 1 + + XHudManager.AddDisplayHud(hud.InstId, hud) + + return hud +end + +-- Return the HUD to the pool +function XUiHud:ReturnHudToPool(hud) + if hud and hud.HudType then + XHudManager.RemoveDisplayHud(hud.InstId) + hud.InstId = 0 + local pool = self.Pool[hud.HudType] + if pool then + pool[hud] = hud + end + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiInvertCardGame/XUiInvertCardGame.lua b/Resources/Scripts/XUi/XUiInvertCardGame/XUiInvertCardGame.lua new file mode 100644 index 00000000..97377807 --- /dev/null +++ b/Resources/Scripts/XUi/XUiInvertCardGame/XUiInvertCardGame.lua @@ -0,0 +1,241 @@ +local tableInsert = table.insert +local tablepack = table.pack +local tableUnpack = table.unpack +local CSXTextManagerGetText = CS.XTextManager.GetText + +local XUiInvertCardGame = XLuaUiManager.Register(XLuaUi, "UiInvertCardGame") + +local XUiInvertCardGamePanel = require("XUi/XUiInvertCardGame/XUiInvertCardGamePanel") +local XUiInvertCardRewardPanel = require("XUi/XUiInvertCardGame/XUiInvertCardRewardPanel") + +function XUiInvertCardGame:OnAwake() + if not XDataCenter.InvertCardGameManager.CheckHasServerData() then + XUiManager.TipText("InvertCardGameNotHaveSeverData") + self:Close() + end + + self.GamePanel = XUiInvertCardGamePanel.New(self, self.PanelGame) + self.RewardPanel = XUiInvertCardRewardPanel.New(self, self.PanelReward) +end + +function XUiInvertCardGame:OnStart() + self.RedPointIds = {} + self:AutoRegisterBtn() + self.AssetPanel = XUiPanelActivityAsset.New(self.PanelActivityAsset, true) + self.AssetPanel:Refresh({ XDataCenter.InvertCardGameManager.GetConsumeItemId() }) + self:InitBtnGroup() + self:RefreshBtnTab() + local defaultSelectIdx = XDataCenter.InvertCardGameManager.FindDefaultSelectTabIndex() + if defaultSelectIdx and defaultSelectIdx ~= 0 then + self.BtnGroup:SelectIndex(defaultSelectIdx) + end + self:InitSKipRedPoint() +end + +function XUiInvertCardGame:OnEnable() + self:StartActivityTimer() + self:CheckHitFaceHelp() +end + +function XUiInvertCardGame:OnDisable() + self:StopActivityTimer() +end + +function XUiInvertCardGame:OnDestroy() + self:RemoveRedPoints() +end + +function XUiInvertCardGame:OnGetEvents() + return { + XEventId.EVENT_INVERT_CARD_GAME_CARD_CHANGED, + XEventId.EVENT_INVERT_CARD_GAME_GET_REWARD, + } +end + +function XUiInvertCardGame:OnNotify(evt, ...) + local args = tablepack(...) + local stageEntity = args[1] + if evt == XEventId.EVENT_INVERT_CARD_GAME_CARD_CHANGED then + self.AssetPanel:Refresh({ XDataCenter.InvertCardGameManager.GetConsumeItemId() }) + self.GamePanel:PlayCardsChangedAnimation(args[1], args[2], args[3], args[4]) + XRedPointManager.Check(self.SkipRedPointId) + elseif evt == XEventId.EVENT_INVERT_CARD_GAME_GET_REWARD then + self.RewardPanel:Refresh(stageEntity) + end +end + +function XUiInvertCardGame:AutoRegisterBtn() + self.BtnBack.CallBack = function () self:Close() end + self.BtnMainUi.CallBack = function () XLuaUiManager.RunMain() end + self.BtnStart.CallBack = function () self:OnBtnStartClick() end + local skipId = XDataCenter.InvertCardGameManager.GetStorySkipId() + if skipId and skipId ~= 0 then + self.BtnStory.gameObject:SetActiveEx(true) + self.BtnStory.CallBack = function () XFunctionManager.SkipInterface(skipId) end + else + self.BtnStory.gameObject:SetActiveEx(false) + end + self:RegisterHelpBtn() +end + +function XUiInvertCardGame:RegisterHelpBtn() + local helpId = XDataCenter.InvertCardGameManager.GetHelpId() + local template = XHelpCourseConfig.GetHelpCourseTemplateById(helpId) + self:BindHelpBtn(self.BtnHelp, template.Function) +end + +function XUiInvertCardGame:OnBtnStartClick() + XDataCenter.InvertCardGameManager.SetStartStage(self.CurStage) + self:SetStartCoverActiveEx(false) + self:SetFullCoverActiveEx(true) + self.GamePanel:PlayStartAnimation() +end + +function XUiInvertCardGame:InitBtnGroup() + local togBtns = {} + for i = 1, 4 do + if self["BtnTog"..i] then + tableInsert(togBtns, self["BtnTog"..i]) + end + end + self.BtnTabs = {} + local stageIds = XDataCenter.InvertCardGameManager.GetStageEntityList() + for i=1, #togBtns, 1 do + if i <= #stageIds then + togBtns[i].gameObject:SetActiveEx(true) + tableInsert(self.BtnTabs, togBtns[i]) + else + togBtns[i].gameObject:SetActiveEx(false) + end + end + self.BtnGroup:Init(self.BtnTabs, function (index) self:OnBtnTabClick(index) end) + for index, togBtn in ipairs(self.BtnTabs) do + local redId = XRedPointManager.AddRedPointEvent(togBtn.ReddotObj, nil, nil, {XRedPointConditions.Types.CONDITION_INVERTCARDGAME_TOG}, index, true) + tableInsert(self.RedPointIds, redId) + end +end + +function XUiInvertCardGame:OnBtnTabClick(index) + if index == self.CurrentSelectIndex then + return + end + + local stageList = XDataCenter.InvertCardGameManager.GetStageEntityList() + if XDataCenter.InvertCardGameManager.CheckStageIsOpen(index) then + self.CurrentSelectIndex = index + local curStage = XDataCenter.InvertCardGameManager.GetStageEntityList()[index] + if curStage then + self.CurStage = curStage + self.RewardPanel:Refresh(curStage) + self.GamePanel:Refresh(curStage) + self:RefreshStartCover(curStage) + self:PlayAnimation("QieHuan") + end + else + self.BtnGroup:SelectIndex(self.CurrentSelectIndex) + if stageList[index-1] then + XUiManager.TipError(CSXTextManagerGetText("InvertCardGameStageNotOpen", stageList[index-1]:GetName())) + end + end +end + +function XUiInvertCardGame:RefreshBtnTab() + local stageList = XDataCenter.InvertCardGameManager.GetStageEntityList() + + for index, btnTab in pairs(self.BtnTabs) do + if stageList[index] then + btnTab:SetNameByGroup(0, stageList[index]:GetName()) + local isOpen = XDataCenter.InvertCardGameManager.CheckStageIsOpen(index) + btnTab:SetDisable(not isOpen) + local isFinish = stageList[index]:GetStatus() == XInvertCardGameConfig.InvertCardGameStageStatusType.Finish + btnTab:ShowTag(isFinish) + if self.CurrentSelectIndex and self.CurrentSelectIndex == index then + btnTab:SetButtonState(XUiButtonState.Select) + end + end + end +end + +function XUiInvertCardGame:RefreshRewardProcess() + local takeNum, count = XDataCenter.CoupletGameManager.GetRewardProcess() + self.TxtRewardPorcess.text = string.format("%s%s%s", takeNum, "/", count) +end + +function XUiInvertCardGame:CheckHitFaceHelp() + local hitFaceData = XSaveTool.GetData(string.format( "%s%s%s", XInvertCardGameConfig.INVERT_CARD_GAME_HELP_HIT_KEY, XPlayer.Id, XDataCenter.InvertCardGameManager.ActId)) + if not hitFaceData or hitFaceData == XInvertCardGameConfig.HitFaceHelpState.NotHit then + local helpId = XDataCenter.InvertCardGameManager.GetHelpId() + local template = XHelpCourseConfig.GetHelpCourseTemplateById(helpId) + XUiManager.ShowHelpTip(template.Function) + XSaveTool.SaveData(string.format( "%s%s%s", XInvertCardGameConfig.INVERT_CARD_GAME_HELP_HIT_KEY, XPlayer.Id, XDataCenter.InvertCardGameManager.ActId), XInvertCardGameConfig.HitFaceHelpState.Hited) + end +end + +function XUiInvertCardGame:InitSKipRedPoint() + local curSkipId = XDataCenter.InvertCardGameManager.GetStorySkipId() + if not curSkipId or curSkipId == 0 then + return + end + local skipTemplate = XFunctionConfig.GetSkipList(curSkipId) + local redId = XRedPointManager.AddRedPointEvent(self.BtnStory.ReddotObj, nil, nil, {XRedPointConditions.Types.CONDITION_MOVIE_ASSEMBLE_RED}, skipTemplate.CustomParams[1], true) + self.SkipRedPointId = redId + tableInsert(self.RedPointIds, redId) +end + +function XUiInvertCardGame:RefreshStartCover(stageEntity) + local startState = XDataCenter.InvertCardGameManager.GetStartStage(stageEntity) + if not startState or startState == XInvertCardGameConfig.InvertCardGameStartStage.NotStart then + self:SetStartCoverActiveEx(true) + else + self:SetStartCoverActiveEx(false) + end +end + +function XUiInvertCardGame:SetStartCoverActiveEx(bool) + self.StartCover.gameObject:SetActiveEx(bool) + self.BtnStart.gameObject:SetActiveEx(bool) +end + +function XUiInvertCardGame:SetFullCoverActiveEx(bool) + self.FullCover.gameObject:SetActiveEx(bool) +end + +function XUiInvertCardGame:RemoveRedPoints() + if self.RedPointIds and next(self.RedPointIds) then + for _, redId in ipairs(self.RedPointIds) do + XRedPointManager.RemoveRedPointEvent(redId) + end + end +end + +function XUiInvertCardGame:StartActivityTimer() + local timeId = XDataCenter.InvertCardGameManager.GetActivityTimeId() + local startTime, endTime = XFunctionManager.GetTimeByTimeId(timeId) + local nowTime = XTime.GetServerNowTimestamp() + self.TxtTime.text = XUiHelper.GetTime(endTime - nowTime, XUiHelper.TimeFormatType.ACTIVITY) + if nowTime < startTime then + XUiManager.TipText("InvertCardGameTimeNotOpen") + self:Close() + elseif nowTime > endTime then + XUiManager.TipText("InvertCardGameTimeEnd") + self:Close() + else + self.ActivityTimer = XScheduleManager.ScheduleForever(function() + local time = XTime.GetServerNowTimestamp() + if time > endTime then + XUiManager.TipError(CSXTextManagerGetText("InvertCardGameTimeEnd")) + self:StopActivityTimer() + XLuaUiManager.RunMain() + return + end + self.TxtTime.text = XUiHelper.GetTime(endTime - time, XUiHelper.TimeFormatType.ACTIVITY) + end, XScheduleManager.SECOND, 0) + end +end + +function XUiInvertCardGame:StopActivityTimer() + if self.ActivityTimer then + XScheduleManager.UnSchedule(self.ActivityTimer) + self.ActivityTimer = nil + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiInvertCardGame/XUiInvertCardGamePanel.lua b/Resources/Scripts/XUi/XUiInvertCardGame/XUiInvertCardGamePanel.lua new file mode 100644 index 00000000..cd204959 --- /dev/null +++ b/Resources/Scripts/XUi/XUiInvertCardGame/XUiInvertCardGamePanel.lua @@ -0,0 +1,326 @@ +local tableInsert = table.insert +local Vector2 = CS.UnityEngine.Vector2 +local CSTextManagerGetText = CS.XTextManager.GetText + +local XUiInvertGamePanel = XClass(nil, "XUiInvertGamePanel") +local XUiInvertGameCardItem = require("XUi/XUiInvertCardGame/XUiInvertGameCardItem") + +function XUiInvertGamePanel:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RectTransform = ui + self.RootUi = rootUi + XTool.InitUiObject(self) + + self:Init() +end + +function XUiInvertGamePanel:Init() + self.CardWidth = self.GridDraw.rect.width + self.CardHeight = self.GridDraw.rect.height + self.GamePanelWidth = self.Transform.rect.width + self.GamePanelHeight = self.Transform.rect.height + self.HalfGamePanelWidth = self.GamePanelWidth / 2 + self.HalfGamePanelHeight = self.GamePanelHeight / 2 + self.CardPool = {} + self.CardItems = {} +end + +function XUiInvertGamePanel:Refresh(stageEntity) + if stageEntity then + self.StageEntity = stageEntity + self.StageId = self.StageEntity:GetId() + local stageStatus = self.StageEntity:GetStatus() + if stageStatus == XInvertCardGameConfig.InvertCardGameStageStatusType.Lock then + return + elseif stageStatus == XInvertCardGameConfig.InvertCardGameStageStatusType.Process then + local startState = XDataCenter.InvertCardGameManager.GetStartStage(self.StageEntity) + if startState == XInvertCardGameConfig.InvertCardGameStartStage.NotStart then + self:RefreshGamePanelWithFinish() -- 没开始的时候用配置卡牌顺序刷新面板 + self:RefreshMessagePanel() + return + end + local cardList = stageEntity:GetRandomCardList() + local datas = {} + for index, data in ipairs(cardList) do + local creatData = { + StageId = self.StageId, + Index = index, + CardId = data.CardId, + IsFinish = data.IsFinish, + } + tableInsert(datas, creatData) + end + self:RefreshLayout(self.StageEntity:GetRowAndColumnCount()) + self:CreateTemplates(datas) + elseif stageStatus == XInvertCardGameConfig.InvertCardGameStageStatusType.Finish then + self:RefreshGamePanelWithFinish() + end + self:RefreshMessagePanel() + end +end + +function XUiInvertGamePanel:RefreshGamePanelWithFinish(isBack) + if self.StageEntity then + local containCards = self.StageEntity:GetContainCards() + local datas = {} + for index, cardId in ipairs(containCards) do + local creatData = { + StageId = self.StageId, + Index = index, + CardId = cardId, + IsFinish = true, + IsBack = isBack, + } + tableInsert(datas, creatData) + end + self:RefreshLayout(self.StageEntity:GetRowAndColumnCount()) + self:CreateTemplates(datas) + end +end + +function XUiInvertGamePanel:RefreshMessagePanel() + local stageStatus = self.StageEntity:GetStatus() + local startState = XDataCenter.InvertCardGameManager.GetStartStage(self.StageEntity) + if startState == XInvertCardGameConfig.InvertCardGameStartStage.NotStart then + self.PanelMessage.gameObject:SetActiveEx(false) + return + end + if stageStatus == XInvertCardGameConfig.InvertCardGameStageStatusType.Lock or stageStatus == XInvertCardGameConfig.InvertCardGameStageStatusType.Finish then + self.PanelMessage.gameObject:SetActiveEx(false) + elseif stageStatus == XInvertCardGameConfig.InvertCardGameStageStatusType.Process then + self.PanelMessage.gameObject:SetActiveEx(true) + if self.StageEntity:GetTotalCounts() < self.StageEntity:GetMaxCostNum() then + self.TxtCount01.text = CSTextManagerGetText("InvertCardGameMaxInvertConutTextBlue", self.StageEntity:GetMaxCostNum(), self.StageEntity:GetTotalCounts(), self.StageEntity:GetMaxCostNum()) + if XDataCenter.InvertCardGameManager.CheckHasEnoughItem(self.StageEntity) then + self.TxtSpend.text = CSTextManagerGetText("InvertCardGameConstomCountBlue", self.StageEntity:GetCostCoinNum()) + else + self.TxtSpend.text = CSTextManagerGetText("InvertCardGameConstomCountRed", self.StageEntity:GetCostCoinNum()) + end + else + local maxCostNum = self.StageEntity:GetMaxCostNum() + self.TxtCount01.text = CSTextManagerGetText("InvertCardGameMaxInvertConutTextNormal", maxCostNum, maxCostNum, maxCostNum) + self.TxtSpend.text = CSTextManagerGetText("InvertCardGameConstomCountBlue", 0) + end + self.TxtCount02.text = CSTextManagerGetText("InvertCardGameCurInvertConutText", #self.StageEntity:GetInvertList(), self.StageEntity:GetMaxOnCardsNum()) + + self.RImgIcon:SetRawImage(XDataCenter.ItemManager.GetItem(XDataCenter.InvertCardGameManager.GetConsumeItemId()).Template.Icon) + end +end + +function XUiInvertGamePanel:RefreshLayout(rowCount, columnCount) + local spacingRow = (self.GamePanelWidth - columnCount * self.CardWidth) / (columnCount + 1) + self.CardWidth + local spacingColumn = (self.GamePanelHeight - rowCount * self.CardHeight) / (rowCount + 1) + self.CardHeight + if spacingRow < self.CardWidth or spacingColumn < self.CardHeight then + XLog.Error("Invert Card Game Refresh Layout Error") + return + end + self.LayoutGroup.spacing = Vector2(spacingRow, spacingColumn) + self.LayoutGroup.constraintCount = columnCount +end + +function XUiInvertGamePanel:CreateTemplates(datas) + self.CardItems = {} + local onCreat = function(cardItem, data) + cardItem:SetActiveEx(true) + cardItem:OnCreat(data, self) + tableInsert(self.CardItems, cardItem) + end + + XUiHelper.CreateTemplates(self.RootUi, self.CardPool, datas, XUiInvertGameCardItem.New, self.GridDrawRoot, + self.LayoutGroup.transform, onCreat) +end + +function XUiInvertGamePanel:PlayAllTurnOnAnimation(cb) + for index, cardItem in ipairs(self.CardItems) do + if index == #self.CardItems then + cardItem:DORotate(function() + cardItem:SetCardState(XInvertCardGameConfig.InvertCardGameCardState.Front) + end, function() + if cb then + cb() + end + end) + else + cardItem:DORotate(function() + cardItem:SetCardState(XInvertCardGameConfig.InvertCardGameCardState.Front) + end) + end + end +end + +function XUiInvertGamePanel:PlayAllTurnOffAnimation(cb) + for index, cardItem in ipairs(self.CardItems) do + if index == #self.CardItems then + cardItem:DORotate(function() + cardItem:SetCardState(XInvertCardGameConfig.InvertCardGameCardState.Back) + end, function() + if cb then + cb() + end + end) + else + cardItem:DORotate(function() + cardItem:SetCardState(XInvertCardGameConfig.InvertCardGameCardState.Back) + end) + end + end +end + +function XUiInvertGamePanel:PlayCardGatherAnimation(cb) + for index, cardItem in ipairs(self.CardItems) do + if index == #self.CardItems then + cardItem:DOMoveToCenter(function() + if cb then + cb() + end + end) + else + cardItem:DOMoveToCenter() + end + end +end + +function XUiInvertGamePanel:PlayCardDisperseAnimation(cb) + for index, cardItem in ipairs(self.CardItems) do + if index == #self.CardItems then + cardItem:DOMoveFromCenter(function() + if cb then + cb() + end + end) + else + cardItem:DOMoveFromCenter() + end + end +end + +function XUiInvertGamePanel:PlayUpsetCardAnimation(cb) + self.RootUi:PlayAnimation("Refresh", cb) +end + +function XUiInvertGamePanel:PlayStartAnimation() + local AsynPlayAllTurnOnAnimation = asynTask(self.PlayAllTurnOnAnimation, self) + local AsynPlayAllTurnOffAnimation = asynTask(self.PlayAllTurnOffAnimation, self) + local AsynPlayCardGatherAnimation = asynTask(self.PlayCardGatherAnimation, self) + local AsynPlayCardDisperseAnimation = asynTask(self.PlayCardDisperseAnimation, self) + local AsynPlayUpsetCardAnimation = asynTask(self.PlayUpsetCardAnimation, self) + RunAsyn(function() + AsynPlayAllTurnOnAnimation() -- 播放转到正面动画 + asynWaitSecond(1) -- 延迟1秒 + AsynPlayAllTurnOffAnimation() -- 播放转回背面动画 + self:SetLayoutGroupEnableEx(false) -- 关闭布局 + asynWaitSecond(1) -- 延迟1秒 + AsynPlayCardGatherAnimation() -- 播放集中卡牌动画 + self.GameObject:SetActiveEx(false) + -- 播放异步洗牌动画 + AsynPlayUpsetCardAnimation() -- 洗牌动画 + self.GameObject:SetActiveEx(true) -- 打开游戏面板 + -- asynWaitSecond(0.1) + AsynPlayCardDisperseAnimation() -- 播放分散动画 + self:SetLayoutGroupEnableEx(true) -- 打开布局 + self:Refresh(self.StageEntity) -- 重新用服务器生成的随机卡牌刷新 + self.RootUi:SetFullCoverActiveEx(false) -- 关闭全局遮罩 + end) +end + +function XUiInvertGamePanel:PlayCardsChangedAnimation(stageEntity, invertCardIdx, punishCardIdxs, clearCardIdxs) + local AsynPlayTurnOnAnimation = asynTask(self.PlayTurnOnAnimation, self) + local AsynPlayPunishAnimation = asynTask(self.PlayPunishAnimation, self) + local AsynPlayClearCardAnimation = asynTask(self.PlayClearCardAnimation, self) + local AsynPlayFinishStageAnimation = asynTask(self.PlayFinishStageAnimation, self) + RunAsyn(function() + self.RootUi:SetFullCoverActiveEx(true) -- 打开全局遮罩 + AsynPlayTurnOnAnimation(invertCardIdx) + if punishCardIdxs and next(punishCardIdxs) then + AsynPlayPunishAnimation(punishCardIdxs) + end + if clearCardIdxs and next(clearCardIdxs) then + AsynPlayClearCardAnimation(clearCardIdxs) + end + --self:PlayClearCardAnimation(clearCardIdxs) + if stageEntity:GetStatus() == XInvertCardGameConfig.InvertCardGameStageStatusType.Finish then + self:RefreshGamePanelWithFinish(true) + AsynPlayFinishStageAnimation() + end + self:RefreshMessagePanel() + self.RootUi:RefreshBtnTab() + self.RootUi.RewardPanel:Refresh(stageEntity) + self.RootUi:SetFullCoverActiveEx(false) -- 关闭全局遮罩 + end) +end + +function XUiInvertGamePanel:PlayTurnOnAnimation(cardIndex, cb) + if cardIndex and cardIndex ~= 0 and self.CardItems[cardIndex] then + self.CardItems[cardIndex]:DORotate(function() + self.CardItems[cardIndex]:SetCardState(XInvertCardGameConfig.InvertCardGameCardState.Front) + end, function() + if cb then + cb() + end + end) + else + if cb then + cb() + end + end +end + +function XUiInvertGamePanel:PlayPunishAnimation(cardIdxs, cb) + for index, cardIndex in ipairs(cardIdxs) do + if index == #cardIdxs then + self.CardItems[cardIndex]:DORotate(function() + self.CardItems[cardIndex]:SetCardState(XInvertCardGameConfig.InvertCardGameCardState.Back) + end, function() + if cb then + cb() + end + end) + else + self.CardItems[cardIndex]:DORotate(function() + self.CardItems[cardIndex]:SetCardState(XInvertCardGameConfig.InvertCardGameCardState.Back) + end) + end + end +end + +function XUiInvertGamePanel:PlayClearCardAnimation(cardIdxs, cb) + for index, cardIndex in ipairs(cardIdxs) do + if index == #cardIdxs then + self.CardItems[cardIndex]:PlayClearEffectAnimation(function() + self.CardItems[cardIndex]:SetCardState(XInvertCardGameConfig.InvertCardGameCardState.Finish) + if cb then + cb() + end + end) + else + self.CardItems[cardIndex]:PlayClearEffectAnimation(function() + self.CardItems[cardIndex]:SetCardState(XInvertCardGameConfig.InvertCardGameCardState.Finish) + end) + end + end +end + +function XUiInvertGamePanel:PlayFinishStageAnimation(cb) + for index, cardItem in ipairs(self.CardItems) do + if index == #self.CardItems then + cardItem:DORotate(function() + cardItem:SetCardState(XInvertCardGameConfig.InvertCardGameCardState.Front) + end, function() + if cb then + cb() + end + end) + else + cardItem:DORotate(function() + cardItem:SetCardState(XInvertCardGameConfig.InvertCardGameCardState.Front) + end) + end + end +end + +function XUiInvertGamePanel:SetLayoutGroupEnableEx(bool) + self.LayoutGroup.enabled = bool +end + +return XUiInvertGamePanel diff --git a/Resources/Scripts/XUi/XUiInvertCardGame/XUiInvertCardRewardItem.lua b/Resources/Scripts/XUi/XUiInvertCardGame/XUiInvertCardRewardItem.lua new file mode 100644 index 00000000..d285bb08 --- /dev/null +++ b/Resources/Scripts/XUi/XUiInvertCardGame/XUiInvertCardRewardItem.lua @@ -0,0 +1,50 @@ +local XUiInvertCardRewardItem = XClass(nil, "XUiInvertCardRewardItem") + +function XUiInvertCardRewardItem:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RectTransform = ui + self.RootUi = rootUi + XTool.InitUiObject(self) + + self:Init() +end + +function XUiInvertCardRewardItem:Init() + self.CommonGrid = XUiGridCommon.New(self.RootUi, self.GridCommon) + self.BtnActive.CallBack = function () + if self.BtnActiveCb then self.BtnActiveCb() end + end +end + +function XUiInvertCardRewardItem:OnCreat(data) + local rewardItemId = XRewardManager.GetRewardList(data.RewardId)[1] + self.CommonGrid:Refresh(rewardItemId) + self.TxtValue.text = XInvertCardGameConfig.GetStageFinishProgressById(data.StageId)[data.Index] +end + +function XUiInvertCardRewardItem:SetTakedState(rewardState) + if rewardState == XInvertCardGameConfig.InvertCardGameRewardTookState.NotFinish then + self.BtnActive.gameObject:SetActiveEx(false) + self.ImgRe.gameObject:SetActiveEx(false) + self.PanelEffect.gameObject:SetActiveEx(false) + elseif rewardState == XInvertCardGameConfig.InvertCardGameRewardTookState.NotTook then + self.BtnActive.gameObject:SetActiveEx(true) + self.ImgRe.gameObject:SetActiveEx(false) + self.PanelEffect.gameObject:SetActiveEx(true) + elseif rewardState == XInvertCardGameConfig.InvertCardGameRewardTookState.Took then + self.BtnActive.gameObject:SetActiveEx(false) + self.ImgRe.gameObject:SetActiveEx(true) + self.PanelEffect.gameObject:SetActiveEx(false) + end +end + +function XUiInvertCardRewardItem:SetBtnActiveCallBack(cb) + self.BtnActiveCb = cb +end + +function XUiInvertCardRewardItem:SetActiveEx(bool) + self.GameObject:SetActiveEx(bool) +end + +return XUiInvertCardRewardItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiInvertCardGame/XUiInvertCardRewardPanel.lua b/Resources/Scripts/XUi/XUiInvertCardGame/XUiInvertCardRewardPanel.lua new file mode 100644 index 00000000..5399fdfb --- /dev/null +++ b/Resources/Scripts/XUi/XUiInvertCardGame/XUiInvertCardRewardPanel.lua @@ -0,0 +1,93 @@ +local tableInsert = table.insert + +local XUiInvertCardRewardPanel = XClass(nil, "XUiInvertCardRewardPanel") +local XUiInvertCardRewardItem = require("XUi/XUiInvertCardGame/XUiInvertCardRewardItem") + +function XUiInvertCardRewardPanel:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RectTransform = ui + self.RootUi = rootUi + XTool.InitUiObject(self) + + self:Init() +end + +function XUiInvertCardRewardPanel:Init() + self.TextProgressDesc.gameObject:SetActiveEx(true) + self.TextProgressDesc.text = "" + self.ImgProgress.gameObject:SetActiveEx(true) + self.ImgProgress.fillAmount = 0 + self.RewardTmp.gameObject:SetActiveEx(false) + + self.RewardsPool = {} +end + +function XUiInvertCardRewardPanel:Refresh(stageEntity) + self.StageEntity = stageEntity + self.Rewards = stageEntity:GetRewards() + self.Process = self.StageEntity:GetProgress() + self:RefreashDescText() + self:RefreashReward() + self:RefreashProcessImg() +end + +function XUiInvertCardRewardPanel:RefreashDescText() + if not self.StageEntity then + return + end + + local desc = self.StageEntity:GetClearConditionDesc() + self.TextProgressDesc.text = XUiHelper.ConvertLineBreakSymbol(desc) +end + +function XUiInvertCardRewardPanel:RefreashReward() + if not self.Rewards then + return + end + + local rewardDatas = {} + local stageId = self.StageEntity:GetId() + for index, rewardId in ipairs(self.Rewards) do + local data = { + StageId = stageId, + Index = index, + RewardId = rewardId, + } + tableInsert(rewardDatas, data) + end + + local onCreatCb = function (item, data) + item:SetActiveEx(true) + item:OnCreat(data) + item:SetTakedState(XDataCenter.InvertCardGameManager.CheckRewardState(self.StageEntity:GetId(), data.Index)) + item:SetBtnActiveCallBack(function () self:TakeReward() end) + end + + XUiHelper.CreateTemplates(self.RootUi, self.RewardsPool, rewardDatas, XUiInvertCardRewardItem.New, self.RewardTmp, self.RewardContent, onCreatCb) +end + +function XUiInvertCardRewardPanel:RefreashProcessImg() + if not self.StageEntity then + return + end + local finishedRewardCount = 0 + local finishProcess = XInvertCardGameConfig.GetStageFinishProgressById(self.StageEntity:GetId()) + for _, finishProcessNum in ipairs(finishProcess) do + if self.Process >= finishProcessNum then + finishedRewardCount = finishedRewardCount + 1 + end + end + local ratioProcess = finishedRewardCount/#self.Rewards + if ratioProcess < 0 then ratioProcess = 0 end + if ratioProcess > 1 then ratioProcess = 1 end + self.ImgProgress.fillAmount = ratioProcess +end + +function XUiInvertCardRewardPanel:TakeReward() + if self.StageEntity then + XDataCenter.InvertCardGameManager.InvertCardsRewardRequest(self.StageEntity:GetId()) + end +end + +return XUiInvertCardRewardPanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiInvertCardGame/XUiInvertGameCardItem.lua b/Resources/Scripts/XUi/XUiInvertCardGame/XUiInvertGameCardItem.lua new file mode 100644 index 00000000..85bdc45f --- /dev/null +++ b/Resources/Scripts/XUi/XUiInvertCardGame/XUiInvertGameCardItem.lua @@ -0,0 +1,102 @@ +local XUiInvertGameCardItem = XClass(nil, "XUiInvertGameCardItem") +local RotateDuringTime = 0.2 -- 卡牌翻转时间 +local MoveCenterDuringTime = 0.25 -- 卡牌移动到中心的时间 +local ClearEffectDuriation = 850 -- 卡牌消失特效时间(毫秒) +local Vector3 = CS.UnityEngine.Vector3 +local Vector2 = CS.UnityEngine.Vector2 + +function XUiInvertGameCardItem:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RectTransform = ui + self.RootUi = rootUi + XTool.InitUiObject(self) + + self:Init() +end + +function XUiInvertGameCardItem:Init() + self.BtnCard.CallBack = function () self:OnClickBtnCard() end + self.AsynRotate = asynTask(self.DORotate, self) +end + +function XUiInvertGameCardItem:OnCreat(data, parent) + self.Data = data + self.Parent = parent + self:Refresh() +end + +function XUiInvertGameCardItem:Refresh() + if self.Data then + local baseIcon = XInvertCardGameConfig.GetCardBaseIconById(self.Data.CardId) + if baseIcon and baseIcon ~= "" then + self.RImgPeople:SetRawImage(baseIcon) + end + + if self.Data.IsBack then + self:SetCardState(XInvertCardGameConfig.InvertCardGameCardState.Back) + else + self:SetCardState(XDataCenter.InvertCardGameManager.CheckCardState(self.Data.StageId, self.Data.Index)) + end + end +end + +function XUiInvertGameCardItem:OnClickBtnCard() + if self.Data then + XDataCenter.InvertCardGameManager.InvertCardRequest(self.Data.StageId, self.Data.Index) + end +end + +function XUiInvertGameCardItem:SetActiveEx(bool) + self.GameObject:SetActiveEx(bool) +end + +function XUiInvertGameCardItem:SetFinish(bool) + self.GridDraw.gameObject:SetActiveEx(not bool) +end + +function XUiInvertGameCardItem:SetCardState(cardState) + if cardState == XInvertCardGameConfig.InvertCardGameCardState.Back then + self.GridDraw.gameObject:SetActiveEx(true) + self.RImg.gameObject:SetActiveEx(true) + self.RImgPeople.gameObject:SetActiveEx(false) + elseif cardState == XInvertCardGameConfig.InvertCardGameCardState.Front then + self.GridDraw.gameObject:SetActiveEx(true) + self.RImg.gameObject:SetActiveEx(false) + self.RImgPeople.gameObject:SetActiveEx(true) + elseif cardState == XInvertCardGameConfig.InvertCardGameCardState.Finish then + self.GridDraw.gameObject:SetActiveEx(false) + end +end + +function XUiInvertGameCardItem:DORotate(turningCb, cb) + self.GridDraw.transform:DOScaleX(0, RotateDuringTime):OnComplete(function () + if turningCb then turningCb() end + self.GridDraw.transform:DOScaleX(1, RotateDuringTime):OnComplete(function () + if cb then cb() end + end) + end) +end + +function XUiInvertGameCardItem:DOMoveToCenter(cb) + self.OldAnchoredPos = self.RectTransform.anchoredPosition + self.RectTransform:DOAnchorPos(Vector2(self.Parent.HalfGamePanelWidth, -self.Parent.HalfGamePanelHeight), MoveCenterDuringTime):OnComplete(function () + if cb then cb() end + end) +end + +function XUiInvertGameCardItem:DOMoveFromCenter(cb) + self.RectTransform:DOAnchorPos(self.OldAnchoredPos, MoveCenterDuringTime):OnComplete(function () + if cb then cb() end + end) +end + +function XUiInvertGameCardItem:PlayClearEffectAnimation(cb) + self.ClearEffect.gameObject:SetActiveEx(true) + XScheduleManager.ScheduleOnce(function () + self.ClearEffect.gameObject:SetActiveEx(false) + if cb then cb() end + end, ClearEffectDuriation) +end + +return XUiInvertGameCardItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiKillZone/XUiGridKillZonePlugin.lua b/Resources/Scripts/XUi/XUiKillZone/XUiGridKillZonePlugin.lua new file mode 100644 index 00000000..e3dbc10e --- /dev/null +++ b/Resources/Scripts/XUi/XUiKillZone/XUiGridKillZonePlugin.lua @@ -0,0 +1,32 @@ +local XUiGridKillZonePlugin = XClass(nil, "XUiGridKillZonePlugin") + +function XUiGridKillZonePlugin:Ctor(ui, clickCb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + + if self.BtnClick then self.BtnClick.CallBack = clickCb end + + self.Effect.gameObject:SetActiveEx(false) +end + +function XUiGridKillZonePlugin:Refresh(plugin, isAllPluginEmpty, doNotShowEffect) + self.Plugin = plugin + + self.PanelEmpty.gameObject:SetActiveEx(isAllPluginEmpty) + self.PanelPlugin.gameObject:SetActiveEx(not isAllPluginEmpty) + + local icon = plugin:GetIcon() + self.RImgIcon:SetRawImage(icon) + + local count = plugin:GetCount() + self.TxtNum.text = "x" .. count + + if not doNotShowEffect and not isAllPluginEmpty then + self.Effect.gameObject:SetActiveEx(false) + self.Effect.gameObject:SetActiveEx(true) + end +end + +return XUiGridKillZonePlugin \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiKillZone/XUiGridKillZonePluginSlot.lua b/Resources/Scripts/XUi/XUiKillZone/XUiGridKillZonePluginSlot.lua new file mode 100644 index 00000000..3630a82f --- /dev/null +++ b/Resources/Scripts/XUi/XUiKillZone/XUiGridKillZonePluginSlot.lua @@ -0,0 +1,37 @@ +local XUiGridKillZonePluginSlot = XClass(nil, "XUiGridKillZonePluginSlot") + +function XUiGridKillZonePluginSlot:Ctor(ui, clickCb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + + if self.BtnClick then self.BtnClick.CallBack = function() clickCb(self.Slot) end end + + self:SetSelect(false) +end + +function XUiGridKillZonePluginSlot:Refresh(slot) + self.Slot = slot + + local isLock = not XDataCenter.KillZoneManager.IsPluginSlotUnlock(slot) + self.BtnClick:SetDisable(isLock) + + if not isLock then + local pluginId = XDataCenter.KillZoneManager.GetSlotWearingPluginId(slot) + if XTool.IsNumberValid(pluginId) then + local icon = XKillZoneConfigs.GetPluginIcon(pluginId) + self.RImgBuffIcon:SetRawImage(icon) + + self.RImgBuffIcon.gameObject:SetActiveEx(true) + else + self.RImgBuffIcon.gameObject:SetActiveEx(false) + end + end +end + +function XUiGridKillZonePluginSlot:SetSelect(value) + self.BuffSelect.gameObject:SetActiveEx(value) +end + +return XUiGridKillZonePluginSlot \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiKillZone/XUiGridKillZoneStage.lua b/Resources/Scripts/XUi/XUiKillZone/XUiGridKillZoneStage.lua new file mode 100644 index 00000000..23fcbef0 --- /dev/null +++ b/Resources/Scripts/XUi/XUiKillZone/XUiGridKillZoneStage.lua @@ -0,0 +1,56 @@ +local XUiGridKillZoneStage = XClass(nil, "XUiGridKillZoneStage") + +function XUiGridKillZoneStage:Ctor(ui, clickCb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + self.StarGrids = {} + + XTool.InitUiObject(self) + self:SetSelect(false) + + if self.BtnClick then self.BtnClick.CallBack = function() clickCb(self.StageId) end end + + self.GridStar.gameObject:SetActiveEx(false) +end + +function XUiGridKillZoneStage:Refresh(stageId) + self.StageId = stageId + + local bg = XKillZoneConfigs.GetStageBg(stageId) + self.RImgBg:SetRawImage(bg) + + local name = XKillZoneConfigs.GetStageName(stageId) + self.TxtName.text = name + + local order = XKillZoneConfigs.GetStageOrder(stageId) + self.TxtOrder.text = order + + local maxKillNum = XDataCenter.KillZoneManager.GetStageMaxKillNum(stageId) + self.TxtMaxDefeatNum.text = CsXTextManagerGetText("KillZoneStageMaxKillNum", maxKillNum) + + local star, maxStar = XDataCenter.KillZoneManager.GetStageStar(stageId) + for index = 1, maxStar do + local grid = self.StarGrids[index] + if not grid then + local go = CS.UnityEngine.Object.Instantiate(self.GridStar.gameObject, self.PanelStars) + grid = XTool.InitUiObjectByUi({}, go) + self.StarGrids[index] = grid + end + + grid.IconStar.gameObject:SetActiveEx(index <= star) + grid.GameObject:SetActiveEx(true) + end + for index = maxStar + 1, #self.StarGrids do + self.StarGrids[index].GameObject:SetActiveEx(false) + end + + local isLock = not XDataCenter.KillZoneManager.IsStageUnlock(stageId) + self.PanelStageLock.gameObject:SetActiveEx(isLock) +end + +function XUiGridKillZoneStage:SetSelect(value) + self.ImgSelect.gameObject:SetActiveEx(value) +end + +return XUiGridKillZoneStage \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiKillZone/XUiKillZoneBuffTips.lua b/Resources/Scripts/XUi/XUiKillZone/XUiKillZoneBuffTips.lua new file mode 100644 index 00000000..d98b45d1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiKillZone/XUiKillZoneBuffTips.lua @@ -0,0 +1,48 @@ +local CsXTextManagerGetText = CsXTextManagerGetText +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate + +local XUiKillZoneBuffTips = XLuaUiManager.Register(XLuaUi, "UiKillZoneBuffTips") + +function XUiKillZoneBuffTips:OnAwake() + self:AutoAddListener() + self.GridBuff.gameObject:SetActiveEx(false) +end + +function XUiKillZoneBuffTips:OnStart(stageId) + self.StageId = stageId + self.BuffGrids = {} +end + +function XUiKillZoneBuffTips:OnEnable() + self:UpdateView() +end + +function XUiKillZoneBuffTips:UpdateView() + local buffIds = XKillZoneConfigs.GetStageBuffIds(self.StageId) + for index, buffId in ipairs(buffIds) do + local grid = self.BuffGrids[index] + if not grid then + local go = index == 1 and self.GridBuff or CSUnityEngineObjectInstantiate(self.GridBuff, self.PanelContent) + grid = XTool.InitUiObjectByUi({}, go) + self.BuffGrids[index] = grid + end + + local icon = XKillZoneConfigs.GetBuffIcon(buffId) + grid.RImgIcon:SetRawImage(icon) + + local name = XKillZoneConfigs.GetBuffName(buffId) + grid.TxtName.text = name + + local desc = XKillZoneConfigs.GetBuffDesc(buffId) + grid.TxtDesc.text = desc + + grid.GameObject:SetActiveEx(true) + end + for index = #buffIds + 1, #self.BuffGrids do + self.BuffGrids[index].GameObject:SetActiveEx(false) + end +end + +function XUiKillZoneBuffTips:AutoAddListener() + self.BtnTanchuangCloseBig.CallBack = function() self:Close() end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiKillZone/XUiKillZoneMain.lua b/Resources/Scripts/XUi/XUiKillZone/XUiKillZoneMain.lua new file mode 100644 index 00000000..da36ce76 --- /dev/null +++ b/Resources/Scripts/XUi/XUiKillZone/XUiKillZoneMain.lua @@ -0,0 +1,386 @@ +local XUiGridKillZoneStage = require("XUi/XUiKillZone/XUiGridKillZoneStage") +local XUiGridKillZonePluginSlot = require("XUi/XUiKillZone/XUiGridKillZonePluginSlot") + +local CsXTextManagerGetText = CsXTextManagerGetText + +local XUiKillZoneMain = XLuaUiManager.Register(XLuaUi, "UiKillZoneMain") + +function XUiKillZoneMain:OnAwake() + self:AutoAddListener() + + self.AssetActivityPanel = XUiPanelActivityAsset.New(self.PanelSpecialTool) + XDataCenter.ItemManager.AddCountUpdateListener( + { + XDataCenter.ItemManager.ItemId.Coin, + XKillZoneConfigs.ItemIdCoinA, + XKillZoneConfigs.ItemIdCoinB, + }, handler(self, self.UpdateAssets), self.AssetActivityPanel) + + self.GridStage.gameObject:SetActiveEx(false) + self.PanelTxtRewardTime.gameObject:SetActiveEx(false) + self.BtnSwitchNormal:ShowReddot(false) +end + +function XUiKillZoneMain:OnStart() + self.Diff, self.ChapterId = XDataCenter.KillZoneManager.GetCookieDiffAndChapterId() + if not self.Diff then + self.Diff = XKillZoneConfigs.Difficult.Normal + end + + self.TabBtns = {} + self.StageGrids = {} + self.PluginSlotGrids = {} + + self:InitView() +end + +function XUiKillZoneMain:OnEnable() + if self.IsEnd then return end + if XDataCenter.KillZoneManager.OnActivityEnd() then + self.IsEnd = true + return + end + + self:UpdateAssets() + self:UpdateDiff() + self:UpdateLeftTime() + self:UpdateFarmRewards() + self:UpdatePlugins() +end + +function XUiKillZoneMain:OnDisable() + XCountDown.UnBindTimer(self, XCountDown.GTimerName.KillZone) +end + +function XUiKillZoneMain:OnGetEvents() + return { + XEventId.EVENT_KILLZONE_FARM_REWARD_OBTAIN_COUNT_CHANGE, + XEventId.EVENT_KILLZONE_STAR_REWARD_OBTAIN_RECORD_CHANGE, + XEventId.EVENT_KILLZONE_STAGE_CHANGE, + XEventId.EVENT_KILLZONE_ACTIVITY_END, + } +end + +function XUiKillZoneMain:OnNotify(evt, ...) + if self.IsEnd then return end + + local args = { ... } + if evt == XEventId.EVENT_KILLZONE_FARM_REWARD_OBTAIN_COUNT_CHANGE then + self:UpdateFarmRewards() + elseif evt == XEventId.EVENT_KILLZONE_STAR_REWARD_OBTAIN_RECORD_CHANGE then + self:UpdateStarRewards() + elseif evt == XEventId.EVENT_KILLZONE_STAGE_CHANGE then + self:UpdateStages() + elseif evt == XEventId.EVENT_KILLZONE_ACTIVITY_END then + if XDataCenter.KillZoneManager.OnActivityEnd() then + self.IsEnd = true + return + end + end +end + +function XUiKillZoneMain:InitView() + self.TxtTitleName.text = XDataCenter.KillZoneManager.GetActivityName() +end + +function XUiKillZoneMain:UpdateAssets() + self.AssetActivityPanel:Refresh({ + XDataCenter.ItemManager.ItemId.Coin, + XKillZoneConfigs.ItemIdCoinA, + XKillZoneConfigs.ItemIdCoinB, + }) +end + +function XUiKillZoneMain:UpdateDiff() + if self.Diff == XKillZoneConfigs.Difficult.Normal then + local isLock = not XDataCenter.KillZoneManager.IsDiffHardUnlock() + self.BtnSwitchHard:SetDisable(isLock) + + XRedPointManager.AddRedPointEvent(self.BtnSwitchHard, function(_, count) + self.BtnSwitchHard:ShowReddot(count >= 0) + end, self, { XRedPointConditions.Types.XRedPointConditionKillZoneNewDiff }) + + self.BtnSwitchNormal.gameObject:SetActiveEx(false) + self.BtnSwitchHard.gameObject:SetActiveEx(true) + self.PanelTabChapterGroup.gameObject:SetActiveEx(true) + elseif self.Diff == XKillZoneConfigs.Difficult.Hard then + self.BtnSwitchNormal.gameObject:SetActiveEx(true) + self.BtnSwitchHard.gameObject:SetActiveEx(false) + self.PanelTabChapterGroup.gameObject:SetActiveEx(false) + + XDataCenter.KillZoneManager.SetCookieNewDiffClicked(self.ChapterId) + end + + self:UpdateChapters() +end + +function XUiKillZoneMain:UpdateChapters() + self.ChapterIds = XDataCenter.KillZoneManager.GetChapterIds(self.Diff) + + local firstUnlockIndex, selectIndex + + for index, chapterId in ipairs(self.ChapterIds) do + local btn = self.TabBtns[index] + if not btn then + local go = index == 1 and self.BtnChapter.gameObject or CS.UnityEngine.Object.Instantiate(self.BtnChapter.gameObject, self.PanelTabChapterGroup.transform) + btn = go:GetComponent("XUiButton") + self.TabBtns[index] = btn + end + + local isLock = not XDataCenter.KillZoneManager.IsChapterUnlock(chapterId) + btn:SetDisable(isLock) + + local name = XKillZoneConfigs.GetChapterName(chapterId) + btn:SetNameByGroup(0, name) + + if not isLock then + firstUnlockIndex = firstUnlockIndex or index + if chapterId == self.ChapterId then + selectIndex = index + end + + btn:SetNameByGroup(1, "") + else + local leftTime = XDataCenter.KillZoneManager.GetChpaterOpenLeftTime(chapterId) + btn:SetNameByGroup(1, CsXTextManagerGetText("KillZoneChapterLeftTime", XUiHelper.GetTime(leftTime, XUiHelper.TimeFormatType.ACTIVITY))) + end + + local isFinished = XDataCenter.KillZoneManager.IsChpaterFinished(chapterId) + btn:ShowTag(isFinished) + + XRedPointManager.AddRedPointEvent(btn, function(_, count) + btn:ShowReddot(count >= 0) + end, self, { XRedPointConditions.Types.XRedPointConditionKillZoneNewChapter }, chapterId) + + btn.gameObject:SetActiveEx(true) + end + + for index = #self.ChapterIds + 1, #self.TabBtns do + self.TabBtns[index].gameObject:SetActiveEx(false) + end + + selectIndex = selectIndex or firstUnlockIndex + if not selectIndex then + XLog.Error("XUiKillZoneMain:UpdateChapters error:默认选中的章节(上次挑战过/普通区域第一关)未处于开放时间,请检查配置:" .. XKillZoneConfigs.GetChapterConfigPath()) + return + end + + self.PanelTabChapterGroup:Init(self.TabBtns, function(tabIndex) self:OnClickTabCallBack(tabIndex) end) + self.PanelTabChapterGroup:SelectIndex(selectIndex) +end + +function XUiKillZoneMain:OnClickTabCallBack(tabIndex) + local chapterId = self.ChapterIds[tabIndex] + + local isLock = not XDataCenter.KillZoneManager.IsChapterUnlock(chapterId) + if isLock then + local leftTime = XDataCenter.KillZoneManager.GetChpaterOpenLeftTime(chapterId) + local msg = CsXTextManagerGetText("KillZoneChapterUnlockLeftTime", XUiHelper.GetTime(leftTime, XUiHelper.TimeFormatType.ACTIVITY)) + XUiManager.TipMsg(msg) + return + end + + self.ChapterId = chapterId + + self:UpdateChapter() + + XDataCenter.KillZoneManager.SetCookieNewChapterClicked(chapterId) + XDataCenter.KillZoneManager.SetCookieDiffAndChapterId(self.Diff, self.ChapterId) + + self:PlayAnimationWithMask("QieHuan1") +end + +function XUiKillZoneMain:UpdateChapter() + local chapterId = self.ChapterId + + local bg = XKillZoneConfigs.GetChapterBg(chapterId) + self.RImgBg:SetRawImage(bg) + + self:UpdateStages() +end + +function XUiKillZoneMain:UpdateStages() + local chapterId = self.ChapterId + + local stageIds = XKillZoneConfigs.GetChapterStageIds(chapterId) + self.StageIds = stageIds + for index, stageId in pairs(stageIds) do + local grid = self.StageGrids[index] + if not grid then + local go = CS.UnityEngine.Object.Instantiate(self.GridStage.gameObject, self.PanelStage) + local clickCb = handler(self, self.OnClickStage) + grid = XUiGridKillZoneStage.New(go, clickCb) + self.StageGrids[index] = grid + end + + grid:Refresh(stageId) + grid.GameObject:SetActiveEx(true) + end + for index = #stageIds + 1, #self.StageGrids do + self.StageGrids[index].GameObject:SetActiveEx(false) + end + + self:UpdateStarRewards() +end + +function XUiKillZoneMain:OnClickStage(stageId) + local isLock = not XDataCenter.KillZoneManager.IsStageUnlock(stageId) + if isLock then + local preStageId = XKillZoneConfigs.GetStagePreStageId(stageId) + local stageName = XKillZoneConfigs.GetStageName(preStageId) + local msg = CsXTextManagerGetText("KillZoneStageUnlockTip", stageName) + XUiManager.TipMsg(msg) + return + end + + local gridStageId + for index, grid in pairs(self.StageGrids) do + gridStageId = self.StageIds[index] + grid:SetSelect(gridStageId == stageId) + end + + local closeCb = function() + for _, grid in pairs(self.StageGrids) do + grid:SetSelect(false) + end + end + XLuaUiManager.Open("UiKillZoneStageDetail", stageId, closeCb) +end + +function XUiKillZoneMain:UpdateLeftTime() + XCountDown.UnBindTimer(self, XCountDown.GTimerName.KillZone) + XCountDown.BindTimer(self, XCountDown.GTimerName.KillZone, function(time) + time = time > 0 and time or 0 + local timeText = XUiHelper.GetTime(time, XUiHelper.TimeFormatType.KillZone) + self.TxtLeftTime.text = timeText + end) +end + +function XUiKillZoneMain:UpdateFarmRewards() + local leftCount = XDataCenter.KillZoneManager.GetLeftFarmRewardObtainCount() + self.TxtChllengeRewardTime.text = leftCount +end + +function XUiKillZoneMain:UpdateStarRewards() + local diff = self.Diff + self.TxtDescDiff.text = XKillZoneConfigs.GetStarRewardTitleByDiff(diff) + + local star, maxStar = XDataCenter.KillZoneManager.GetTotalStageStarByDiff(diff) + self.TxtStarNum.text = CsXTextManagerGetText("KillZoneTotalStarProcess", star, maxStar) + self.ImgJindu.fillAmount = maxStar == 0 and 0 or star / maxStar + self.ImgLingqu.gameObject:SetActiveEx(XDataCenter.KillZoneManager.IsStarRewardObtainedByDiff(diff)) + + XRedPointManager.AddRedPointEvent(self.ImgRedProgress, function(_, count) + self.ImgRedProgress.gameObject:SetActiveEx(count >= 0) + end, self, { XRedPointConditions.Types.XRedPointConditionKillZoneStarReward }, diff) + + XRedPointManager.AddRedPointEvent(self.BtnDailyReward, function(_, count) + self.BtnDailyReward:ShowReddot(count >= 0) + end, self, { XRedPointConditions.Types.XRedPointConditionKillZoneDailyStarReward }) +end + +function XUiKillZoneMain:UpdatePlugins() + local maxSlotNum = XKillZoneConfigs.GetMaxPluginSlotNum() + for index = 1, maxSlotNum do + local grid = self.PluginSlotGrids[index] + if not grid then + local go = index == 1 and self.GridPlugin or CS.UnityEngine.Object.Instantiate(self.GridPlugin, self.PanelPlugin) + local clickCb = handler(self, self.OnClickPluginSlot) + grid = XUiGridKillZonePluginSlot.New(go, clickCb) + self.PluginSlotGrids[index] = grid + end + + grid:Refresh(index) + grid:SetSelect(self.SelectSlot == index) + + grid.GameObject:SetActiveEx(true) + end + + XRedPointManager.AddRedPointEvent(self.BtnPlugin, function(_, count) + self.BtnPlugin:ShowReddot(count >= 0) + end, self, { XRedPointConditions.Types.XRedPointConditionKillZonePluginOperate }) +end + +function XUiKillZoneMain:OnClickPluginSlot(slot) + local isLock = not XDataCenter.KillZoneManager.IsPluginSlotUnlock(slot) + if isLock then + local msg = XKillZoneConfigs.GetPluginSlotConditionDesc(slot) + XUiManager.TipMsg(msg) + else + local pluginId = XDataCenter.KillZoneManager.GetSlotWearingPluginId(slot) + if XTool.IsNumberValid(pluginId) then + self.SelectSlot = slot + for index, grid in pairs(self.PluginSlotGrids) do + grid:SetSelect(self.SelectSlot == index) + end + local closeCb = function() + self.SelectSlot = nil + for index, grid in pairs(self.PluginSlotGrids) do + grid:SetSelect(self.SelectSlot == index) + end + end + XLuaUiManager.Open("UiKillZonePluginPopup", slot, pluginId, true, closeCb, nil, true) + else + XUiManager.TipText("KillZoneSelectPlguinEmpty") + end + end +end + +function XUiKillZoneMain:AutoAddListener() + self:BindHelpBtn(self.BtnHelp, "KillZoneMain") + self.BtnBack.CallBack = function() self:OnClickBtnBack() end + self.BtnMainUi.CallBack = function() self:OnClickBtnMainUi() end + self.BtnPlugin.CallBack = function() self:OnClickBtnPlugin() end + self.BtnSwitchHard.CallBack = function() self:SelectDiff(XKillZoneConfigs.Difficult.Hard) end + self.BtnSwitchNormal.CallBack = function() self:SelectDiff(XKillZoneConfigs.Difficult.Normal) end + self.BtnTreasure.CallBack = function() self:OnClickBtnTreasure() end + self.BtnChllengeRewardHelp.CallBack = function() self:OnBtnChllengeRewardHelpClick() end + self.BtnDailyReward.CallBack = function() self:OnClickBtnDailyReward() end +end + +function XUiKillZoneMain:OnClickBtnDailyReward() + XLuaUiManager.Open("UiKillZoneDaily") +end + +function XUiKillZoneMain:OnClickBtnBack() + self:Close() +end + +function XUiKillZoneMain:OnClickBtnMainUi() + XLuaUiManager.RunMain() +end + +function XUiKillZoneMain:OnClickBtnPlugin() + XLuaUiManager.Open("UiKillZonePlugin") +end + +function XUiKillZoneMain:OnClickBtnTreasure() + XLuaUiManager.Open("UiKillZoneReward", self.Diff) +end + +function XUiKillZoneMain:OnBtnChllengeRewardHelpClick() + local title = CsXTextManagerGetText("KillZoneFarmRewardTipTitle") + local content = XUiHelper.ConvertLineBreakSymbol(CsXTextManagerGetText("KillZoneFarmRewardTipContent")) + XUiManager.UiFubenDialogTip(title, content) +end + +function XUiKillZoneMain:SelectDiff(diff) + if diff == XKillZoneConfigs.Difficult.Hard then + local isUnlock, preStageId = XDataCenter.KillZoneManager.IsDiffHardUnlock() + if not isUnlock then + local chapterId = XKillZoneConfigs.GetChapterIdByStageId(preStageId) + local msg = CsXTextManagerGetText("KillZoneDiffHardLockTip" + , XKillZoneConfigs.GetChapterName(chapterId) + , XKillZoneConfigs.GetStageName(preStageId) + ) + XUiManager.TipMsg(msg) + return + end + self:PlayAnimationWithMask("QieHuan2") + else + self:PlayAnimationWithMask("AnimEnable") + end + + self.Diff = diff + self:UpdateDiff() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiKillZone/XUiKillZoneNewRoomSingle.lua b/Resources/Scripts/XUi/XUiKillZone/XUiKillZoneNewRoomSingle.lua new file mode 100644 index 00000000..757b5949 --- /dev/null +++ b/Resources/Scripts/XUi/XUiKillZone/XUiKillZoneNewRoomSingle.lua @@ -0,0 +1,54 @@ +--杀戮无双玩法出战界面代理 +local XUiKillZoneNewRoomSingle = {} + +function XUiKillZoneNewRoomSingle.HandleCharClick(newRoomSingle, charPos, stageId) + local teamData = XTool.Clone(newRoomSingle.CurTeam.TeamData) + local robotIdList = XKillZoneConfigs.GetStageRobotIds(stageId) + XLuaUiManager.Open("UiRoomCharacter", teamData, charPos, function(resTeam) + newRoomSingle:UpdateTeam(resTeam) + end, XDataCenter.FubenManager.StageType.KillZone, nil, { RobotAndCharacter = true, RobotIdList = robotIdList }) +end + +function XUiKillZoneNewRoomSingle.GetBattleTeamData(newRoomSingle) + local team = XDataCenter.KillZoneManager.LoadTeamLocal() + + local lookupTable = {} + local stageId = newRoomSingle.CurrentStageId + local robotIdList = XKillZoneConfigs.GetStageRobotIds(stageId) + for _, id in pairs(robotIdList) do + lookupTable[id] = id + end + + for index, id in pairs(team.TeamData) do + if XRobotManager.CheckIsRobotId(id) then + if not XTool.IsNumberValid(lookupTable[id]) then + team.TeamData[index] = 0 + end + else + --清库之后本地缓存角色失效 + if not XDataCenter.CharacterManager.IsOwnCharacter(id) then + team.TeamData[index] = 0 + end + end + end + + return team +end + +function XUiKillZoneNewRoomSingle.UpdateTeam(newRoomSingle) + XDataCenter.KillZoneManager.SaveTeamLocal(newRoomSingle.CurTeam) +end + +function XUiKillZoneNewRoomSingle.GetIsCheckCaptainIdAndFirstFightId() + return false +end + +function XUiKillZoneNewRoomSingle.OnResetEvent(newRoomSingle) + XDataCenter.KillZoneManager.OnActivityEnd() +end + +function XUiKillZoneNewRoomSingle.GetIsSaveTeamData() + return false +end + +return XUiKillZoneNewRoomSingle \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiKillZone/XUiKillZonePlugin/XUiGridKillZonePluginDesc.lua b/Resources/Scripts/XUi/XUiKillZone/XUiKillZonePlugin/XUiGridKillZonePluginDesc.lua new file mode 100644 index 00000000..41564f7c --- /dev/null +++ b/Resources/Scripts/XUi/XUiKillZone/XUiKillZonePlugin/XUiGridKillZonePluginDesc.lua @@ -0,0 +1,28 @@ +local XUiGridKillZonePluginDesc = XClass(nil, "XUiGridKillZonePluginDesc") + +function XUiGridKillZonePluginDesc:Ctor(ui, clickCb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) +end + +function XUiGridKillZonePluginDesc:Refresh(desc, level, currentLevel) + local isCurrent = level == currentLevel + + if isCurrent then + self.TxtLevelCur.text = CsXTextManagerGetText("KillZonePlguinMaxLevelSuffix", level) + self.TxtSkillDesCur.text = desc + + else + self.TxtLevel.text = CsXTextManagerGetText("KillZonePlguinMaxLevelSuffix", level) + self.TxtSkillDes.text = desc + end + + self.TxtLevel.gameObject:SetActiveEx(not isCurrent) + self.TxtSkillDes.gameObject:SetActiveEx(not isCurrent) + self.TxtLevelCur.gameObject:SetActiveEx(isCurrent) + self.TxtSkillDesCur.gameObject:SetActiveEx(isCurrent) +end + +return XUiGridKillZonePluginDesc \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiKillZone/XUiKillZonePlugin/XUiGridKillZonePluginGroup.lua b/Resources/Scripts/XUi/XUiKillZone/XUiKillZonePlugin/XUiGridKillZonePluginGroup.lua new file mode 100644 index 00000000..d34212ab --- /dev/null +++ b/Resources/Scripts/XUi/XUiKillZone/XUiKillZonePlugin/XUiGridKillZonePluginGroup.lua @@ -0,0 +1,53 @@ +local XUiGridKillZonePluginOperate = require("XUi/XUiKillZone/XUiKillZonePlugin/XUiGridKillZonePluginOperate") + +local XUiGridKillZonePluginGroup = XClass(nil, "XUiGridKillZonePluginGroup") + +function XUiGridKillZonePluginGroup:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + self.PluginGrids = {} + + XTool.InitUiObject(self) + + self.GridPlugin.gameObject:SetActiveEx(false) +end + +function XUiGridKillZonePluginGroup:SetClickCb(clickCb) + self.ClickCb = clickCb +end + +function XUiGridKillZonePluginGroup:Refresh(groupId) + self.GroupId = groupId + + local name = XKillZoneConfigs.GetPluginGroupName(groupId) + self.TxtLevelName.text = name + + local pluginIds = XKillZoneConfigs.GetPluginIdsByGroupId(groupId) + self.PluginIds = pluginIds + for index, pluginId in ipairs(pluginIds) do + local grid = self.PluginGrids[index] + if not grid then + local go = CS.UnityEngine.Object.Instantiate(self.GridPlugin, self.PanelPlugin) + grid = XUiGridKillZonePluginOperate.New(go, self.ClickCb) + self.PluginGrids[index] = grid + end + + grid:Refresh(pluginId) + grid.GameObject:SetActiveEx(true) + end + for index = #pluginIds + 1, #self.PluginGrids do + self.PluginGrids[index].GameObject:SetActiveEx(false) + end +end + +function XUiGridKillZonePluginGroup:SetSelectPlugin(selectPluginId) + for index, pluginId in pairs(self.PluginIds) do + local grid = self.PluginGrids[index] + if grid then + grid:SetSelect(pluginId == selectPluginId) + end + end +end + +return XUiGridKillZonePluginGroup \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiKillZone/XUiKillZonePlugin/XUiGridKillZonePluginOperate.lua b/Resources/Scripts/XUi/XUiKillZone/XUiKillZonePlugin/XUiGridKillZonePluginOperate.lua new file mode 100644 index 00000000..d32b424a --- /dev/null +++ b/Resources/Scripts/XUi/XUiKillZone/XUiKillZonePlugin/XUiGridKillZonePluginOperate.lua @@ -0,0 +1,90 @@ +local XUiGridKillZonePluginOperate = XClass(nil, "XUiGridKillZonePluginOperate") + +function XUiGridKillZonePluginOperate:Ctor(ui, clickCb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + + self:SetSelect(false) + if self.BtnClick then self.BtnClick.CallBack = function() clickCb(self.PluginId, self.Transform) end end +end + +function XUiGridKillZonePluginOperate:Refresh(pluginId) + self.PluginId = pluginId + + local icon = XKillZoneConfigs.GetPluginIcon(pluginId) + self.RImgIcon:SetRawImage(icon) + + local name = XKillZoneConfigs.GetPluginName(pluginId) + self.TxtName.text = name + + local levelStr = XDataCenter.KillZoneManager.GetPluginShowLevelStr(pluginId) + self.TxtLevel.text = levelStr + + self.PanelUnAcitve.gameObject:SetActiveEx(false) + self.PanelLock.gameObject:SetActiveEx(false) + self.PanelNormal.gameObject:SetActiveEx(false) + + local isLock = XDataCenter.KillZoneManager.IsPluginLock(pluginId) + local isUnActive = XDataCenter.KillZoneManager.IsPluginUnActive(pluginId) + if isLock then + self:UpdateLock() + elseif isUnActive then + self:UpdateUnActive() + else + self:UpdateNormal() + end +end + +function XUiGridKillZonePluginOperate:UpdateNormal() + local pluginId = self.PluginId + + local canLevelUp = XDataCenter.KillZoneManager.IsPluginCanLevelUp(pluginId) + self.IconUp.gameObject:SetActiveEx(canLevelUp) + + --此处的数目标记是该插件升到下1记得【B货币】消耗的数目,若已升到满级,则显示玩家在此插件消耗的总数目 + if XDataCenter.KillZoneManager.IsPluginMaxLevel(pluginId) then + local itemId, itemCount = XKillZoneConfigs.GetPluginLevelUpCostTotal(pluginId) + local icon = XItemConfigs.GetItemIconById(itemId) + self.RImgCost:SetRawImage(icon) + self.TxtCost.text = itemCount + else + local itemId, itemCount = XDataCenter.KillZoneManager.GetPluginLevelUpCost(pluginId) + local icon = XItemConfigs.GetItemIconById(itemId) + self.RImgCost:SetRawImage(icon) + self.TxtCost.text = itemCount + end + + local isWearing = XDataCenter.KillZoneManager.IsPluginWearing(pluginId) + self.PanelWearing.gameObject:SetActiveEx(isWearing) + + self.PanelNormal.gameObject:SetActiveEx(true) +end + +function XUiGridKillZonePluginOperate:UpdateLock() + local pluginId = self.PluginId + + local name = XKillZoneConfigs.GetPluginName(pluginId) + self.TxtNameLock.text = name + + local itemId, itemCount = XKillZoneConfigs.GetPluginUnlockCost(pluginId) + local icon = XItemConfigs.GetItemIconById(itemId) + self.RImgCostLock:SetRawImage(icon) + self.TxtCostLock.text = itemCount + + self.TxtLevel.gameObject:SetActiveEx(false) + self.PanelLock.gameObject:SetActiveEx(true) +end + +function XUiGridKillZonePluginOperate:UpdateUnActive() + self.TxtLevel.gameObject:SetActiveEx(true) + self.PanelUnAcitve.gameObject:SetActiveEx(true) +end + +function XUiGridKillZonePluginOperate:SetSelect(value) + self.TxtLevel.gameObject:SetActiveEx(true) + self.PanelSelect.gameObject:SetActiveEx(value) +end + +return XUiGridKillZonePluginOperate \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiKillZone/XUiKillZonePlugin/XUiGridKillZonePluginSlotOperate.lua b/Resources/Scripts/XUi/XUiKillZone/XUiKillZonePlugin/XUiGridKillZonePluginSlotOperate.lua new file mode 100644 index 00000000..5047c4d1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiKillZone/XUiKillZonePlugin/XUiGridKillZonePluginSlotOperate.lua @@ -0,0 +1,52 @@ +local XUiGridKillZonePluginSlotOperate = XClass(nil, "XUiGridKillZonePluginSlotOperate") + +function XUiGridKillZonePluginSlotOperate:Ctor(ui, clickCb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + + self:SetSelect(false) + if self.BtnClick then self.BtnClick.CallBack = function() clickCb(self.Slot) end end +end + +function XUiGridKillZonePluginSlotOperate:Refresh(slot) + self.Slot = slot + + local isLock = not XDataCenter.KillZoneManager.IsPluginSlotUnlock(slot) + if not isLock then + local pluginId = XDataCenter.KillZoneManager.GetSlotWearingPluginId(slot) + if XTool.IsNumberValid(pluginId) then + local icon = XKillZoneConfigs.GetPluginIcon(pluginId) + self.RImgIcon:SetRawImage(icon) + + local name = XKillZoneConfigs.GetPluginName(pluginId) + self.TxtName.text = name + + local level = XDataCenter.KillZoneManager.GetPluginLevel(pluginId) + + self.TxtLevel.text = level + + self.ContainerEmpty.gameObject:SetActiveEx(false) + self.ContainerItem.gameObject:SetActiveEx(true) + self.ContainerLock.gameObject:SetActiveEx(false) + else + self.ContainerEmpty.gameObject:SetActiveEx(true) + self.ContainerItem.gameObject:SetActiveEx(false) + self.ContainerLock.gameObject:SetActiveEx(false) + end + else + local conditionDes = XKillZoneConfigs.GetPluginSlotConditionDesc(slot) + self.TxtUnlockCondition.text = conditionDes + + self.ContainerLock.gameObject:SetActiveEx(true) + self.ContainerItem.gameObject:SetActiveEx(false) + self.ContainerEmpty.gameObject:SetActiveEx(false) + end +end + +function XUiGridKillZonePluginSlotOperate:SetSelect(value) + self.PanelSelect.gameObject:SetActiveEx(value) +end + +return XUiGridKillZonePluginSlotOperate \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiKillZone/XUiKillZonePlugin/XUiKillZonePlugin.lua b/Resources/Scripts/XUi/XUiKillZone/XUiKillZonePlugin/XUiKillZonePlugin.lua new file mode 100644 index 00000000..9cf686e6 --- /dev/null +++ b/Resources/Scripts/XUi/XUiKillZone/XUiKillZonePlugin/XUiKillZonePlugin.lua @@ -0,0 +1,175 @@ +local XUiGridKillZonePluginGroup = require("XUi/XUiKillZone/XUiKillZonePlugin/XUiGridKillZonePluginGroup") +local XUiGridKillZonePluginSlotOperate = require("XUi/XUiKillZone/XUiKillZonePlugin/XUiGridKillZonePluginSlotOperate") + +local CsXTextManagerGetText = CsXTextManagerGetText + +local XUiKillZonePlugin = XLuaUiManager.Register(XLuaUi, "UiKillZonePlugin") + +function XUiKillZonePlugin:OnAwake() + self:AutoAddListener() + self:InitDynamicTable() + + self.AssetActivityPanel = XUiPanelActivityAsset.New(self.PanelSpecialTool) + XDataCenter.ItemManager.AddCountUpdateListener( + { + XDataCenter.ItemManager.ItemId.Coin, + XKillZoneConfigs.ItemIdCoinA, + XKillZoneConfigs.ItemIdCoinB, + }, handler(self, self.UpdateAssets), self.AssetActivityPanel) + + self.GridPluginGroup.gameObject:SetActiveEx(false) + self.GridSlot.gameObject:SetActiveEx(false) +end + +function XUiKillZonePlugin:OnStart() + self.SelectSlot = XDataCenter.KillZoneManager.GetNextEmptySlot() + self.PluginSlotGrids = {} + + XDataCenter.KillZoneManager.ClearCookiePluginOperate() +end + +function XUiKillZonePlugin:OnEnable() + if self.IsEnd then return end + if XDataCenter.KillZoneManager.OnActivityEnd() then + self.IsEnd = true + return + end + + self:UpdateAssets() + self:UpdatePluginSlots() + self:UpdatePluginGroups() +end + +function XUiKillZonePlugin:OnGetEvents() + return { + XEventId.EVENT_KILLZONE_PLUGIN_CHANGE, + XEventId.EVENT_KILLZONE_PLUGIN_SLOT_CHANGE, + XEventId.EVENT_KILLZONE_ACTIVITY_END, + } +end + +function XUiKillZonePlugin:OnNotify(evt, ...) + if self.IsEnd then return end + + local args = { ... } + if evt == XEventId.EVENT_KILLZONE_PLUGIN_CHANGE then + self:UpdatePluginSlots() + self:UpdatePluginGroups() + elseif evt == XEventId.EVENT_KILLZONE_PLUGIN_SLOT_CHANGE then + self:UpdatePluginSlots() + elseif evt == XEventId.EVENT_KILLZONE_ACTIVITY_END then + if XDataCenter.KillZoneManager.OnActivityEnd() then + self.IsEnd = true + return + end + end +end + +function XUiKillZonePlugin:UpdateAssets() + self.AssetActivityPanel:Refresh({ + XDataCenter.ItemManager.ItemId.Coin, + XKillZoneConfigs.ItemIdCoinA, + XKillZoneConfigs.ItemIdCoinB, + }) +end + +function XUiKillZonePlugin:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelPluginList) + self.DynamicTable:SetProxy(XUiGridKillZonePluginGroup) + self.DynamicTable:SetDelegate(self) + self.PluginGroupIds = XKillZoneConfigs.GetPluginGroupIds() + self.DynamicTable:SetDataSource(self.PluginGroupIds) +end + +function XUiKillZonePlugin:UpdatePluginGroups() + self.DynamicTable:ReloadDataSync() +end + +function XUiKillZonePlugin:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + local clickCb = handler(self, self.OnClickPlugin) + grid:SetClickCb(clickCb) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local groupId = self.PluginGroupIds[index] + grid:Refresh(groupId) + grid:SetSelectPlugin(self.SelectPluginId) + end +end + +function XUiKillZonePlugin:OnClickPlugin(pluginId, gridTransform) + self.SelectPluginId = pluginId + self:UpdatePluginGroups() + local closeCb = function() + self.SelectPluginId = nil + self:UpdatePluginGroups() + end + + + local worldPos = gridTransform.position + local localPos = self.PanelPluginList.transform:InverseTransformPoint(worldPos) + local specialPosition = localPos.x < 0 + XLuaUiManager.Open("UiKillZonePluginPopup", self.SelectSlot, pluginId, false, closeCb, specialPosition) +end + +function XUiKillZonePlugin:UpdatePluginSlots() + local maxSlotNum = XKillZoneConfigs.GetMaxPluginSlotNum() + + for index = 1, maxSlotNum do + local grid = self.PluginSlotGrids[index] + if not grid then + local go = index == 1 and self.GridSlot or CS.UnityEngine.Object.Instantiate(self.GridSlot, self.PanelSlotContent) + local clickCb = handler(self, self.OnClickPluginSlot) + grid = XUiGridKillZonePluginSlotOperate.New(go, clickCb) + self.PluginSlotGrids[index] = grid + end + + grid:Refresh(index) + grid:SetSelect(index == self.SelectSlot) + grid.GameObject:SetActiveEx(true) + end +end + +function XUiKillZonePlugin:OnClickPluginSlot(slot) + local isLock = not XDataCenter.KillZoneManager.IsPluginSlotUnlock(slot) + if isLock then + local msg = XKillZoneConfigs.GetPluginSlotConditionDesc(slot) + XUiManager.TipMsg(msg) + return + end + + local pluginId = XDataCenter.KillZoneManager.GetSlotWearingPluginId(slot) + if XTool.IsNumberValid(pluginId) then + XLuaUiManager.Open("UiKillZonePluginPopup", slot, pluginId, true) + else + XUiManager.TipText("KillZoneSelectPlguinEmptyOperate") + end + + --选中对应孔位 + self.SelectSlot = slot + + self:UpdatePluginSlots() +end + +function XUiKillZonePlugin:AutoAddListener() + self:BindHelpBtn(self.BtnHelp, "KillZoneMain") + self.BtnBack.CallBack = function() self:OnClickBtnBack() end + self.BtnMainUi.CallBack = function() self:OnClickBtnMainUi() end + self.BtnReset.CallBack = function() self:OnClickBtnReset() end +end + +function XUiKillZonePlugin:OnClickBtnBack() + self:Close() +end + +function XUiKillZonePlugin:OnClickBtnMainUi() + XLuaUiManager.RunMain() +end + +function XUiKillZonePlugin:OnClickBtnReset() + local pluginIds = XDataCenter.KillZoneManager.GetCanResetPluginIds() + if XTool.IsTableEmpty(pluginIds) then + XUiManager.TipText("KillZoneResetPlguinEmpty") + return + end + XLuaUiManager.Open("UiKillZonePluginReset", pluginIds) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiKillZone/XUiKillZonePlugin/XUiKillZonePluginPopup.lua b/Resources/Scripts/XUi/XUiKillZone/XUiKillZonePlugin/XUiKillZonePluginPopup.lua new file mode 100644 index 00000000..99323176 --- /dev/null +++ b/Resources/Scripts/XUi/XUiKillZone/XUiKillZonePlugin/XUiKillZonePluginPopup.lua @@ -0,0 +1,224 @@ +local XUiGridKillZonePluginDesc = require("XUi/XUiKillZone/XUiKillZonePlugin/XUiGridKillZonePluginDesc") + +local Vector2 = CS.UnityEngine.Vector2 +local CsXTextManagerGetText = CsXTextManagerGetText + +local XUiKillZonePluginPopup = XLuaUiManager.Register(XLuaUi, "UiKillZonePluginPopup") + +function XUiKillZonePluginPopup:OnAwake() + self:AutoAddListener() + self:InitDynamicTable() + + self.GridDesc.gameObject:SetActiveEx(false) + self.PanelSelect = self:FindTransform("PanelSelect"):GetComponent("RectTransform") + self.Bg = self:FindTransform("Bg"):GetComponent("RectTransform") +end + +function XUiKillZonePluginPopup:OnStart(slot, pluginId, isPreview, closeCb, specialPosition, hideAllBtns) + self.Slot = slot + self.PluginId = pluginId + self.IsPreview = isPreview + self.CloseCb = closeCb + self.HideAllBtns = hideAllBtns + + if specialPosition then + self.PanelSelect.anchorMax = Vector2(0, 0.5) + self.PanelSelect.anchorMin = Vector2(0, 0.5) + self.PanelSelect.anchoredPosition = Vector2(self.PanelSelect.rect.width / 2, 0) + self.Bg.rotation = CS.UnityEngine.Quaternion.Euler(0, 0, 180) + else + self.PanelSelect.anchorMax = Vector2(1, 0.5) + self.PanelSelect.anchorMin = Vector2(1, 0.5) + self.PanelSelect.anchoredPosition = Vector2(self.PanelSelect.rect.width / -2, 0) + self.Bg.rotation = CS.UnityEngine.Quaternion.Euler(0, 0, 0) + end +end + +function XUiKillZonePluginPopup:OnEnable() + self:UpdateView() +end + +function XUiKillZonePluginPopup:OnDestroy() + if self.CloseCb then self.CloseCb() end +end + +function XUiKillZonePluginPopup:OnGetEvents() + return { + XEventId.EVENT_KILLZONE_PLUGIN_CHANGE, + } +end + +function XUiKillZonePluginPopup:OnNotify(evt, ...) + if self.IsEnd then return end + + local args = { ... } + if evt == XEventId.EVENT_KILLZONE_PLUGIN_CHANGE then + self:UpdateView() + end +end + +function XUiKillZonePluginPopup:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PaneSkillDes) + self.DynamicTable:SetProxy(XUiGridKillZonePluginDesc) + self.DynamicTable:SetDelegate(self) +end + +function XUiKillZonePluginPopup:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local level = index + local currentLevel = XDataCenter.KillZoneManager.GetPluginLevel(self.PluginId) + local desc = self.DescList[level] + grid:Refresh(desc, level, currentLevel) + end +end + +function XUiKillZonePluginPopup:UpdateView() + local pluginId = self.PluginId + local isPreview = self.IsPreview + local hideAllBtns = self.HideAllBtns + + self.TxtCost.gameObject:SetActiveEx(false) + self.TxtCostUnlock.gameObject:SetActiveEx(false) + self.TxtCostActive.gameObject:SetActiveEx(false) + self.TxtRemind.gameObject:SetActiveEx(hideAllBtns) + + local icon = XKillZoneConfigs.GetPluginIcon(pluginId) + self.RImgIcon:SetRawImage(icon) + + local name = XKillZoneConfigs.GetPluginName(pluginId) + self.TxtName.text = name + + local level = XDataCenter.KillZoneManager.GetPluginShowLevelStr(pluginId) + self.TxtLevel.text = level + + --解锁 + local isLock = XDataCenter.KillZoneManager.IsPluginLock(pluginId) + if not hideAllBtns and not isPreview and isLock then + local itemId, count = XKillZoneConfigs.GetPluginUnlockCost(pluginId) + local icon = XItemConfigs.GetItemIconById(itemId) + self.RImgCostUnlock:SetRawImage(icon) + self.TxtCostUnlock.text = count + self.TxtCostUnlock.gameObject:SetActiveEx(true) + self.BtnUnlock.gameObject:SetActiveEx(true) + else + self.BtnUnlock.gameObject:SetActiveEx(false) + end + + --激活 + local isUnAcitve = XDataCenter.KillZoneManager.IsPluginUnActive(pluginId) + if not hideAllBtns and not isPreview and isUnAcitve then + local itemId, count = XKillZoneConfigs.GetPluginUnActiveCost(pluginId) + local icon = XItemConfigs.GetItemIconById(itemId) + self.RImgCostActive:SetRawImage(icon) + self.TxtCostActive.text = count + self.TxtCostActive.gameObject:SetActiveEx(true) + self.BtnActive.gameObject:SetActiveEx(true) + else + self.BtnActive.gameObject:SetActiveEx(false) + end + + --升级 + local canLevelUp = XDataCenter.KillZoneManager.CheckPluginCanLevelUp(pluginId) + if not hideAllBtns and not isPreview and canLevelUp then + local itemId, count = XDataCenter.KillZoneManager.GetPluginLevelUpCost(pluginId) + local icon = XItemConfigs.GetItemIconById(itemId) + self.RImgCost:SetRawImage(icon) + self.TxtCost.text = count + self.TxtCost.gameObject:SetActiveEx(true) + self.BtnStrengthen.gameObject:SetActiveEx(true) + else + self.BtnStrengthen.gameObject:SetActiveEx(false) + end + + --重置 + if not hideAllBtns then + local canReset = XDataCenter.KillZoneManager.IsPluginCanReset(pluginId) + self.BtnReset.gameObject:SetActiveEx(canReset) + else + self.BtnReset.gameObject:SetActiveEx(false) + end + + local isWearing = XDataCenter.KillZoneManager.IsPluginWearing(pluginId) + self.PanelWearing.gameObject:SetActiveEx(isWearing) + self.BtnTakeOffOnly.gameObject:SetActiveEx(not hideAllBtns and isWearing and isPreview) --预览模式的卸下按钮 + self.BtnTakeOff.gameObject:SetActiveEx(not hideAllBtns and isWearing and not isPreview) --卸下 + self.BtnPutOn.gameObject:SetActiveEx(not hideAllBtns and not isWearing and not isUnAcitve and not isLock and not isPreview) --穿戴 + + --技能描述 + local level = XDataCenter.KillZoneManager.GetPluginLevel(pluginId) + local selectIndex = XMath.Clamp(level, -1, level) + self.DescList = XKillZoneConfigs.GetPluginLevelSkillDescList(pluginId) + self.DynamicTable:SetDataSource(self.DescList) + self.DynamicTable:ReloadDataASync(selectIndex) +end + +function XUiKillZonePluginPopup:AutoAddListener() + self.BtnTakeOff.CallBack = function() self:OnClickBtnTakeOff() end + self.BtnTakeOffOnly.CallBack = function() self:OnClickBtnTakeOff() end + self.BtnPutOn.CallBack = function() self:OnClickBtnPutOn() end + self.BtnActive.CallBack = function() self:OnClickBtnActive() end + self.BtnUnlock.CallBack = function() self:OnClickBtnUnlock() end + self.BtnStrengthen.CallBack = function() self:OnClickBtnStrengthen() end + self.BtnReset.CallBack = function() self:OnClickBtnReset() end + self.BtnClose.CallBack = function() self:Close() end +end + +--卸下 +function XUiKillZonePluginPopup:OnClickBtnTakeOff() + local pluginId = self.PluginId + local slot = self.Slot + + XDataCenter.KillZoneManager.KillZoneUsePluginRequest(slot, pluginId, true) +end + +--穿戴 +function XUiKillZonePluginPopup:OnClickBtnPutOn() + local pluginId = self.PluginId + local slot = self.Slot + + XDataCenter.KillZoneManager.KillZoneUsePluginRequest(slot, pluginId, false) +end + +--解锁 +function XUiKillZonePluginPopup:OnClickBtnUnlock() + local pluginId = self.PluginId + + local itemId, count = XKillZoneConfigs.GetPluginUnlockCost(pluginId) + if not XDataCenter.ItemManager.CheckItemCountById(itemId, count) then + XUiManager.TipText("KillZonePlguinUnlockCostLack") + return + end + + XDataCenter.KillZoneManager.KillZoneUnlockPluginRequest(pluginId) +end + +--激活 +function XUiKillZonePluginPopup:OnClickBtnActive() + local pluginId = self.PluginId + + local itemId, count = XKillZoneConfigs.GetPluginUnActiveCost(pluginId) + if not XDataCenter.ItemManager.CheckItemCountById(itemId, count) then + XUiManager.TipText("KillZonePlguinActiveCostLack") + return + end + + XDataCenter.KillZoneManager.KillZoneUpgradePluginRequest(pluginId) +end + +--升级 +function XUiKillZonePluginPopup:OnClickBtnStrengthen() + local pluginId = self.PluginId + + local itemId, count = XDataCenter.KillZoneManager.GetPluginLevelUpCost(pluginId) + if not XDataCenter.ItemManager.CheckItemCountById(itemId, count) then + XUiManager.TipText("KillZonePlguinLevelUpCostLack") + return + end + + XDataCenter.KillZoneManager.KillZoneUpgradePluginRequest(pluginId) +end + +--重置 +function XUiKillZonePluginPopup:OnClickBtnReset() + XLuaUiManager.Open("UiKillZonePluginReset", { self.PluginId }) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiKillZone/XUiKillZonePlugin/XUiKillZonePluginReset.lua b/Resources/Scripts/XUi/XUiKillZone/XUiKillZonePlugin/XUiKillZonePluginReset.lua new file mode 100644 index 00000000..0f796f67 --- /dev/null +++ b/Resources/Scripts/XUi/XUiKillZone/XUiKillZonePlugin/XUiKillZonePluginReset.lua @@ -0,0 +1,77 @@ +local CsXTextManagerGetText = CsXTextManagerGetText + +local XUiKillZonePluginReset = XLuaUiManager.Register(XLuaUi, "UiKillZonePluginReset") + +function XUiKillZonePluginReset:OnAwake() + self:AutoAddListener() +end + +function XUiKillZonePluginReset:OnStart(pluginIds) + self.PluginIds = pluginIds + self.CoinGrids = {} +end + +function XUiKillZonePluginReset:OnEnable() + self:UpdateView() +end + +function XUiKillZonePluginReset:UpdateView() + local pluginIds = self.PluginIds + local pluginNum = #pluginIds + + local desc = "" + if pluginNum > 1 then + desc = CsXTextManagerGetText("KillZoneResetPlguinsTips", pluginNum) + else + local pluginId = pluginIds[1] + local name = XKillZoneConfigs.GetPluginName(pluginId) + local level = XDataCenter.KillZoneManager.GetPluginLevel(pluginId) + desc = CsXTextManagerGetText("KillZoneResetPlguinTips", name, level) + end + self.TxtDesc.text = desc + + local itemId, itemCount = XDataCenter.KillZoneManager.GetPluginsResetCost(pluginIds) + local icon = XItemConfigs.GetItemIconById(itemId) + self.RImgCost:SetRawImage(icon) + self.TxtCost.text = itemCount + + local obtainList = XDataCenter.KillZoneManager.GetPluginsResetObtainList(pluginIds) + for index, item in ipairs(obtainList) do + local grid = self.CoinGrids[index] + if not grid then + local ui = index == 1 and self.GridCoin or CS.UnityEngine.Object.Instantiate(self.GridCoin, self.PanelCoin) + grid = XUiGridCommon.New(self, ui) + self.CoinGrids[index] = grid + end + + grid:Refresh(item) + grid.GameObject:SetActiveEx(true) + end + for index = #obtainList + 1, #self.CoinGrids do + self.CoinGrids[index].GameObject:SetActiveEx(false) + end +end + +function XUiKillZonePluginReset:AutoAddListener() + self.BtnConfirm.CallBack = function() self:OnClickBtnConfirm() end + self.BtnCancel.CallBack = function() self:Close() end + self.BtnTanchuangClose.CallBack = function() self:Close() end +end + +function XUiKillZonePluginReset:OnClickBtnConfirm() + local pluginIds = self.PluginIds + + local callFunc = function() + XDataCenter.KillZoneManager.KillZoneResetRequest(pluginIds, function(rewardGoods) + if not XTool.IsTableEmpty(rewardGoods) then + XUiManager.OpenUiObtain(rewardGoods) + end + end) + self:Close() + end + + local itemId, itemCount = XDataCenter.KillZoneManager.GetPluginsResetCost(pluginIds) + if XDataCenter.ItemManager.DoNotEnoughBuyAsset(itemId, itemCount, 1, callFunc, "KillZonePlguinResetCostLack") then + callFunc() + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiKillZone/XUiKillZoneReward/XUiGridDailyReward.lua b/Resources/Scripts/XUi/XUiKillZone/XUiKillZoneReward/XUiGridDailyReward.lua new file mode 100644 index 00000000..3057a3bf --- /dev/null +++ b/Resources/Scripts/XUi/XUiKillZone/XUiKillZoneReward/XUiGridDailyReward.lua @@ -0,0 +1,62 @@ +local handler = handler +local CsXTextManagerGetText = CsXTextManagerGetText +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate + +local XUiGridDailyReward = XClass(nil, "XUiGridDailyReward") + +function XUiGridDailyReward:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + + self.GridCommon.gameObject:SetActiveEx(false) + + self.RewardGrids = {} +end + +function XUiGridDailyReward:InitRootUi(rootUi) + self.RootUi = rootUi +end + +function XUiGridDailyReward:RefreshCommon(id) + local star = XKillZoneConfigs.GetDailyStarRewardStar(id) + self.TxtStarNum1.text = "x" .. star + + local rewardGoodsId = XKillZoneConfigs.GetDailyStarRewardGoodsId(id) + local rewards = XRewardManager.GetRewardList(rewardGoodsId) or {} + for index, reward in ipairs(rewards or {}) do + local grid = self.RewardGrids[index] + if not grid then + local ui = index == 1 and self.GridCommon or CSUnityEngineObjectInstantiate(self.GridCommon, self.Layout) + grid = XUiGridCommon.New(self.RootUi, ui) + self.RewardGrids[index] = grid + end + + grid:Refresh(reward) + grid.GameObject:SetActiveEx(true) + end + for index = #rewards + 1, #self.RewardGrids do + local grid = self.RewardGrids[index] + if grid then + grid.GameObject:SetActiveEx(false) + end + end +end + +function XUiGridDailyReward:Refresh(id) + local curStar = XDataCenter.KillZoneManager.GetYesterdayStar() + local targetStar = XKillZoneConfigs.GetDailyStarRewardStar(id) + + for index = 1, 3 do + self["TxtStarNum" .. index].text = "x" .. targetStar + end + + self.PanelDisable.gameObject:SetActiveEx(curStar < targetStar) + self.PanelCur.gameObject:SetActiveEx(curStar == targetStar) + self.PanelNormal.gameObject:SetActiveEx(curStar > targetStar) + + self:RefreshCommon(id) +end + +return XUiGridDailyReward \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiKillZone/XUiKillZoneReward/XUiGridReward.lua b/Resources/Scripts/XUi/XUiKillZone/XUiKillZoneReward/XUiGridReward.lua new file mode 100644 index 00000000..5cd4eb21 --- /dev/null +++ b/Resources/Scripts/XUi/XUiKillZone/XUiKillZoneReward/XUiGridReward.lua @@ -0,0 +1,68 @@ +local handler = handler +local CsXTextManagerGetText = CsXTextManagerGetText +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate + +local XUiGridRewardTip = XClass(nil, "XUiGridRewardTip") + +function XUiGridRewardTip:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + + self.BtnReceive.CallBack = handler(self, self.OnClickBtnReceive) + self.GridCommon.gameObject:SetActiveEx(false) + + self.RewardGrids = {} +end + +function XUiGridRewardTip:InitRootUi(rootUi) + self.RootUi = rootUi +end + +function XUiGridRewardTip:Refresh(starRewardId, diff) + self.StarRewardId = starRewardId + + local requireStar = XKillZoneConfigs.GetStarRewardStar(starRewardId) + local curStar = XDataCenter.KillZoneManager.GetTotalStageStarByDiff(diff) + curStar = XMath.Clamp(curStar, curStar, requireStar) + self.TxtGradeStarNums.text = CsXTextManagerGetText("KillZoneStarRewardProcess", curStar, requireStar) + + local canGet = XDataCenter.KillZoneManager.IsStarRewardCanGet(starRewardId) + local hasGot = XDataCenter.KillZoneManager.IsStarRewardObtained(starRewardId) + self.ImgCannotReceive.gameObject:SetActiveEx(not canGet and not hasGot) + self.ImgAlreadyReceived.gameObject:SetActiveEx(hasGot) + self.BtnReceive.gameObject:SetActiveEx(canGet and not hasGot) + + local rewardGoodsId = XKillZoneConfigs.GetStarRewardGoodsId(starRewardId) + local rewards = XRewardManager.GetRewardList(rewardGoodsId) or {} + for index, reward in ipairs(rewards or {}) do + local grid = self.RewardGrids[index] + if not grid then + local ui = index == 1 and self.GridCommon or CSUnityEngineObjectInstantiate(self.GridCommon, self.PanelTreasureContent) + grid = XUiGridCommon.New(self.RootUi, ui) + self.RewardGrids[index] = grid + end + + grid:Refresh(reward) + grid.GameObject:SetActiveEx(true) + end + for index = #rewards + 1, #self.RewardGrids do + local grid = self.RewardGrids[index] + if grid then + grid.GameObject:SetActiveEx(false) + end + end +end + +function XUiGridRewardTip:OnClickBtnReceive() + local starRewardId = self.StarRewardId + local cb = function(rewardGoods) + if not XTool.IsTableEmpty(rewardGoods) then + XUiManager.OpenUiObtain(rewardGoods) + end + end + XDataCenter.KillZoneManager.KillZoneTakeDiffStarRewardRequest(starRewardId, cb) +end + +return XUiGridRewardTip \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiKillZone/XUiKillZoneReward/XUiKillZoneDaily.lua b/Resources/Scripts/XUi/XUiKillZone/XUiKillZoneReward/XUiKillZoneDaily.lua new file mode 100644 index 00000000..d6a600e9 --- /dev/null +++ b/Resources/Scripts/XUi/XUiKillZone/XUiKillZoneReward/XUiKillZoneDaily.lua @@ -0,0 +1,90 @@ +local XUiGridDailyReward = require("XUi/XUiKillZone/XUiKillZoneReward/XUiGridDailyReward") + +local CsXTextManagerGetText = CsXTextManagerGetText + +local XUiKillZoneDaily = XLuaUiManager.Register(XLuaUi, "UiKillZoneDaily") + +function XUiKillZoneDaily:OnAwake() + self:AutoAddListener() + self:InitDynamicTable() + + self.GridDailyReward.gameObject:SetActiveEx(false) +end + +function XUiKillZoneDaily:OnStart() + self.TxtTips.text = CsXTextManagerGetText("KillZoneDailyRewardTips") +end + +function XUiKillZoneDaily:OnEnable() + self:UpdateRewards() +end + +function XUiKillZoneDaily:OnGetEvents() + return { + XEventId.EVENT_KILLZONE_DAILYSTARREWARDINDEX_CHANGE, + } +end + +function XUiKillZoneDaily:OnNotify(evt, ...) + if evt == XEventId.EVENT_KILLZONE_DAILYSTARREWARDINDEX_CHANGE then + self:UpdateRewards() + end +end + +function XUiKillZoneDaily:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.SView) + self.DynamicTable:SetProxy(XUiGridDailyReward) + self.DynamicTable:SetDelegate(self) +end + +function XUiKillZoneDaily:UpdateRewards() + self.RewardIds = XDataCenter.KillZoneManager.GetAllDailyStarRewardIds() + + local currentId, selectIndex = 0, -1 + + local yesterdayStar = XDataCenter.KillZoneManager.GetYesterdayStar() + for index, id in pairs(self.RewardIds) do + if yesterdayStar == XKillZoneConfigs.GetDailyStarRewardStar(id) then + currentId, selectIndex = id, index + break + end + end + + if not XTool.IsNumberValid(currentId) then + XLog.Error("XUiKillZoneDaily:UpdateRewards error: 找不到当前星级对应奖励配置, yesterdayStar: ", yesterdayStar.." ,配置路径: " .. XKillZoneConfigs.GetDailyStarRewardConfigPath()) + return + end + + self.DynamicTable:SetDataSource(self.RewardIds) + self.DynamicTable:ReloadDataASync(selectIndex) + + self.GridReward = self.GridReward or XUiGridDailyReward.New(self.GridDailyRewardBottom) + self.GridReward:InitRootUi(self) + self.GridReward:RefreshCommon(currentId) + + local hasGot = XDataCenter.KillZoneManager.IsDailyStarRewardObtained() + self.BtnReceive:SetDisable(hasGot, not hasGot) +end + +function XUiKillZoneDaily:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:InitRootUi(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local rewardId = self.RewardIds[index] + grid:Refresh(rewardId) + end +end + +function XUiKillZoneDaily:AutoAddListener() + self.BtnTanchuangCloseBig.CallBack = function() self:Close() end + self.BtnReceive.CallBack = handler(self, self.OnClickBtnReceive) +end + +function XUiKillZoneDaily:OnClickBtnReceive() + local cb = function(rewardGoods) + if not XTool.IsTableEmpty(rewardGoods) then + XUiManager.OpenUiObtain(rewardGoods) + end + end + XDataCenter.KillZoneManager.KillZoneTakeDailyStarRewardRequest(cb) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiKillZone/XUiKillZoneReward/XUiKillZoneReward.lua b/Resources/Scripts/XUi/XUiKillZone/XUiKillZoneReward/XUiKillZoneReward.lua new file mode 100644 index 00000000..b58756d2 --- /dev/null +++ b/Resources/Scripts/XUi/XUiKillZone/XUiKillZoneReward/XUiKillZoneReward.lua @@ -0,0 +1,90 @@ +local XUiGridReward = require("XUi/XUiKillZone/XUiKillZoneReward/XUiGridReward") + +local CsXTextManagerGetText = CsXTextManagerGetText + +local XUiKillZoneReward = XLuaUiManager.Register(XLuaUi, "UiKillZoneReward") + +function XUiKillZoneReward:OnAwake() + self:AutoAddListener() + self:InitDynamicTable() + + self.GridTreasureGrade.gameObject:SetActiveEx(false) +end + +function XUiKillZoneReward:OnStart(diff) + self.Diff = diff + + self.TxtTreasureTitle.text = XKillZoneConfigs.GetStarRewardTitleByDiff(diff) +end + +function XUiKillZoneReward:OnEnable() + self:UpdateRewards() +end + +function XUiKillZoneReward:OnGetEvents() + return { + XEventId.EVENT_KILLZONE_STAR_REWARD_OBTAIN_RECORD_CHANGE, + } +end + +function XUiKillZoneReward:OnNotify(evt, ...) + if evt == XEventId.EVENT_KILLZONE_STAR_REWARD_OBTAIN_RECORD_CHANGE then + self:UpdateRewards() + end +end + +function XUiKillZoneReward:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelTreasureGrade) + self.DynamicTable:SetProxy(XUiGridReward) + self.DynamicTable:SetDelegate(self) +end + +function XUiKillZoneReward:UpdateRewards() + self.RewardIds = XKillZoneConfigs.GetAllStarRewardIdsByDiff(self.Diff) + + local selectIndex + + --若有奖励可领取时,则按钮任务排列顺序,优先滑动至序号id较小的可领取奖励的任务处 + local minCanGetIndex + for index, starRewardId in ipairs(self.RewardIds) do + if XDataCenter.KillZoneManager.IsStarRewardCanGet(starRewardId) + and not XDataCenter.KillZoneManager.IsStarRewardObtained(starRewardId) + then + minCanGetIndex = index + break + end + end + + --若无奖励可领取时,则自动下滑至当前星数距离星级数目要求最少的任务处 + if not minCanGetIndex then + local curStar = XDataCenter.KillZoneManager.GetTotalStageStarByDiff(self.Diff) + for index = #self.RewardIds, 1, -1 do + local starRewardId = self.RewardIds[index] + local star = XKillZoneConfigs.GetStarRewardStar(starRewardId) + if curStar >= star then + break + end + + selectIndex = index + end + else + selectIndex = minCanGetIndex + end + + self.DynamicTable:SetDataSource(self.RewardIds) + self.DynamicTable:ReloadDataASync(selectIndex) +end + +function XUiKillZoneReward:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:InitRootUi(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local rewardId = self.RewardIds[index] + grid:Refresh(rewardId, self.Diff) + end +end + +function XUiKillZoneReward:AutoAddListener() + self.BtnTanchuangClose.CallBack = function() self:Close() end + self.BtnClose.CallBack = function() self:Close() end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiKillZone/XUiKillZoneSettleWin.lua b/Resources/Scripts/XUi/XUiKillZone/XUiKillZoneSettleWin.lua new file mode 100644 index 00000000..8ea82725 --- /dev/null +++ b/Resources/Scripts/XUi/XUiKillZone/XUiKillZoneSettleWin.lua @@ -0,0 +1,202 @@ +local XUiPanelExpBar = require("XUi/XUiSettleWinMainLine/XUiPanelExpBar") +local XUiGridRewardLine = require("XUi/XUiStronghold/XUiGridRewardLine") + +local handler = handler +local CsXTextManagerGetText = CsXTextManagerGetText +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate + +local XUiKillZoneSettleWin = XLuaUiManager.Register(XLuaUi, "UiKillZoneSettleWin") + +function XUiKillZoneSettleWin:OnAwake() + self:AutoAddListener() + + self.GridReward.gameObject:SetActiveEx(false) + self.GridCond.gameObject:SetActiveEx(false) + self.GridWinRole.gameObject:SetActiveEx(false) + + self.BtnRight.gameObject:SetActiveEx(false) + self.BtnLeft.gameObject:SetActiveEx(false) + self.PanelRewardInfo.gameObject:SetActiveEx(false) + self.TxtRewardEmpty.gameObject:SetActiveEx(false) +end + +function XUiKillZoneSettleWin:OnStart(data, closeCb) + self.WinData = data + self.StageId = data.StageId + self.CloseCb = closeCb + + self.RewardGrids = {} + self.StarDescGrids = {} + self.RewardTeamGrids = {} +end + +function XUiKillZoneSettleWin:OnEnable() + self:UpdateView() + XScheduleManager.ScheduleOnce(function() + self:PlayAnimationWithMask("AnimEnable2") + end, 0) +end + +function XUiKillZoneSettleWin:OnDestroy() + if self.CloseCb then self.CloseCb() end + XDataCenter.AntiAddictionManager.EndFightAction() +end + +function XUiKillZoneSettleWin:OnGetEvents() + return { + XEventId.EVENT_KILLZONE_FARM_REWARD_OBTAIN_COUNT_CHANGE, + } +end + +function XUiKillZoneSettleWin:OnNotify(evt, ...) + if self.IsEnd then return end + + local args = { ... } + if evt == XEventId.EVENT_KILLZONE_FARM_REWARD_OBTAIN_COUNT_CHANGE then + self:UpdateRewards() + end +end + +function XUiKillZoneSettleWin:UpdateView() + local stageId = self.StageId + + local name = XKillZoneConfigs.GetStageName(stageId) + self.TxtStageName.text = name + + self:UpdateRewards() + self:UpdateStarDescs() + self:UpdatePlayerInfo() + self:UpdateTeamInfo() +end + +-- 玩家经验 +function XUiKillZoneSettleWin:UpdatePlayerInfo() + local data = self.WinData + if not data or not next(data) then return end + + local lastLevel = data.RoleLevel + local lastExp = data.RoleExp + local lastMaxExp = XPlayerManager.GetMaxExp(lastLevel, XPlayer.IsHonorLevelOpen()) + local curLevel = XPlayer.GetLevelOrHonorLevel() + local curExp = XPlayer.Exp + local curMaxExp = XPlayerManager.GetMaxExp(curLevel, XPlayer.IsHonorLevelOpen()) + local txtLevelName = XPlayer.IsHonorLevelOpen() and CS.XTextManager.GetText("HonorLevel") or nil + local addExp = XDataCenter.FubenManager.GetStageCfg(data.StageId).TeamExp + + self.PlayerExpBar = self.PlayerExpBar or XUiPanelExpBar.New(self.PanelPlayerExpBar) + self.PlayerExpBar:LetsRoll(lastLevel, lastExp, lastMaxExp, curLevel, curExp, curMaxExp, addExp, txtLevelName) +end + +function XUiKillZoneSettleWin:UpdateTeamInfo() + local data = self.WinData + local charExp = data.CharExp + local count = #charExp + if count <= 0 then + return + end + + local cardExp = XDataCenter.FubenManager.GetStageCfg(data.StageId).CardExp + for index = 1, count do + local grid = self.RewardTeamGrids[index] + if not grid then + local ui = CS.UnityEngine.Object.Instantiate(self.GridWinRole, self.PanelRoleContent) + grid = XUiGridWinRole.New(self, ui) + self.RewardTeamGrids[index] = grid + end + + local charId = charExp[index].Id + local isRobot = XRobotManager.CheckIsRobotId(charId) + if isRobot then + grid:UpdateRobotInfo(charId) + else + grid:UpdateRoleInfo(charExp[index], cardExp) + end + + grid.GameObject:SetActiveEx(true) + end +end + +function XUiKillZoneSettleWin:UpdateRewards() + local stageId = self.StageId + + local isPassed = XDataCenter.KillZoneManager.IsStageFinished(stageId) + self.PanelFirst.gameObject:SetActiveEx(not isPassed) + self.BtnBlock.gameObject:SetActiveEx(true) + + if not isPassed then + local rewardId = XFubenConfigs.GetFirstRewardShow(stageId) + local rewards = XRewardManager.GetRewardList(rewardId) + if rewards then + for index, item in ipairs(rewards) do + local grid = self.RewardGrids[index] + + if not grid then + local ui = CSUnityEngineObjectInstantiate(self.GridReward, self.PanelRewardContent) + grid = XUiGridCommon.New(self, ui) + self.RewardGrids[index] = grid + end + + grid:Refresh(item) + grid.GameObject:SetActiveEx(true) + end + end + for index = #rewards + 1, #self.RewardGrids do + self.RewardGrids[index].GameObject:SetActiveEx(false) + end + + self.TxtRewardBeat.gameObject:SetActiveEx(false) + self.PanelRewardContent.gameObject:SetActiveEx(true) + else + local killCount = self.WinData.SettleData.KillZoneStageResult.CurKillCount or 0 + self.TxtRewardBeat.text = CsXTextManagerGetText("KillZoneSettleWinKillEnemyCount", killCount) + + self.TxtRewardBeat.gameObject:SetActiveEx(true) + self.PanelRewardContent.gameObject:SetActiveEx(false) + end + + -- local leftCount = XDataCenter.KillZoneManager.GetLeftFarmRewardObtainCount() + -- self.TxtRewardTime.text = leftCount .. "/" .. XKillZoneConfigs.MaxFarmRewardCount + -- local isEmpty = leftCount <= 0 + -- self.TxtRewardEmpty.gameObject:SetActiveEx(isEmpty) + -- self.PanelRewardContent.gameObject:SetActiveEx(not isEmpty) +end + +function XUiKillZoneSettleWin:UpdateStarDescs() + local stageId = self.StageId + local currentStar = self.WinData.SettleData.KillZoneStageResult.CurStar + + local starDescList = XKillZoneConfigs.GetStageStarDescList(stageId) + for star, desc in ipairs(starDescList) do + local grid = self.StarDescGrids[star] + if not grid then + local go = star == 1 and self.GridCond or CSUnityEngineObjectInstantiate(self.GridCond, self.PanelCondContent) + grid = XTool.InitUiObjectByUi({}, go) + self.StarDescGrids[star] = grid + end + + grid.TxtDesc.text = desc + + local isPassed = currentStar >= star + grid.TxtLoaded.gameObject:SetActiveEx(isPassed) + grid.TxtNotLoaded.gameObject:SetActiveEx(not isPassed) + + grid.GameObject:SetActiveEx(true) + end +end + +function XUiKillZoneSettleWin:AutoAddListener() + self.BtnLeft.CallBack = handler(self, self.Close) + self.BtnBlock.CallBack = handler(self, self.Close) + self.BtnRight.CallBack = handler(self, self.OnClickBtnRight) +end + +function XUiKillZoneSettleWin:OnClickBtnRight() + local stageId = self.StageId + local cb = function(rewardGoods) + if not XTool.IsTableEmpty(rewardGoods) then + XUiManager.OpenUiObtain(rewardGoods) + end + end + XDataCenter.KillZoneManager.KillZoneTakeFarmRewardRequest(stageId, cb) + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiKillZone/XUiKillZoneStageDetail.lua b/Resources/Scripts/XUi/XUiKillZone/XUiKillZoneStageDetail.lua new file mode 100644 index 00000000..d140365f --- /dev/null +++ b/Resources/Scripts/XUi/XUiKillZone/XUiKillZoneStageDetail.lua @@ -0,0 +1,156 @@ +local CsXTextManagerGetText = CsXTextManagerGetText +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate + +local XUiKillZoneStageDetail = XLuaUiManager.Register(XLuaUi, "UiKillZoneStageDetail") + +function XUiKillZoneStageDetail:OnAwake() + self:AutoAddListener() + + self.AssetActivityPanel = XUiPanelActivityAsset.New(self.PanelSpecialTool) + XDataCenter.ItemManager.AddCountUpdateListener( + { + XKillZoneConfigs.ItemIdCoinA, + XKillZoneConfigs.ItemIdCoinB, + }, handler(self, self.UpdateAssets), self.AssetActivityPanel) + + self.GridBuff.gameObject:SetActiveEx(false) +end + +function XUiKillZoneStageDetail:OnStart(stageId, closeCb) + self.StageId = stageId + self.CloseCb = closeCb + + self.BuffGrids = {} + self.StarDescGrids = {} + self.RewardGrids = {} +end + +function XUiKillZoneStageDetail:OnEnable() + self:UpdateAssets() + self:UpdateView() +end + +function XUiKillZoneStageDetail:OnDestroy() + if self.CloseCb then self.CloseCb() end +end + +function XUiKillZoneStageDetail:UpdateAssets() + self.AssetActivityPanel:Refresh({ + XKillZoneConfigs.ItemIdCoinA, + XKillZoneConfigs.ItemIdCoinB, + }) +end + +function XUiKillZoneStageDetail:UpdateView() + local stageId = self.StageId + + local name = XKillZoneConfigs.GetStageName(stageId) + self.TxtTitle.text = name + + --关卡词缀 + local buffIds = XKillZoneConfigs.GetStageBuffIds(stageId) + for index, buffId in ipairs(buffIds) do + local grid = self.BuffGrids[index] + if not grid then + local go = index == 1 and self.GridBuff or CSUnityEngineObjectInstantiate(self.GridBuff, self.PanelBuffContent) + grid = XTool.InitUiObjectByUi({}, go) + self.BuffGrids[index] = grid + end + + local icon = XKillZoneConfigs.GetBuffIcon(buffId) + grid.RImgIcon:SetRawImage(icon) + + grid.GameObject:SetActiveEx(true) + end + for index = #buffIds + 1, #self.BuffGrids do + self.BuffGrids[index].GameObject:SetActiveEx(false) + end + + local isBuffEmpty = #buffIds <= 0 + self.PanelBuffNone.gameObject:SetActiveEx(isBuffEmpty) + self.BtnBuffTip.gameObject:SetActiveEx(not isBuffEmpty) + + --通关条件 + local passDesc = XKillZoneConfigs.GetStagePassDesc(stageId) + self.TxtTip.text = passDesc + self.TxtTipNone.text = passDesc + + local isPassed = XDataCenter.KillZoneManager.IsStageFinished(stageId) + self.TxtTip.gameObject:SetActiveEx(isPassed) + self.TxtTipNone.gameObject:SetActiveEx(not isPassed) + + --星级条件 + local currentStar = XDataCenter.KillZoneManager.GetStageStar(stageId) + local starDescList = XKillZoneConfigs.GetStageStarDescList(stageId) + for star, desc in ipairs(starDescList) do + local grid = self.StarDescGrids[star] + if not grid then + local go = star == 1 and self.GridStageStar or CSUnityEngineObjectInstantiate(self.GridStageStar, self.PanelTargetList) + grid = XTool.InitUiObjectByUi({}, go) + self.StarDescGrids[star] = grid + end + + if currentStar < star then + grid.TxtTipNone.text = desc + grid.IconStarNone.gameObject:SetActiveEx(true) + grid.TxtTipNone.gameObject:SetActiveEx(true) + grid.IconStar.gameObject:SetActiveEx(false) + grid.TxtTip.gameObject:SetActiveEx(false) + else + grid.TxtTip.text = desc + grid.IconStar.gameObject:SetActiveEx(true) + grid.TxtTip.gameObject:SetActiveEx(true) + grid.IconStarNone.gameObject:SetActiveEx(false) + grid.TxtTipNone.gameObject:SetActiveEx(false) + end + + grid.GameObject:SetActiveEx(true) + end + + --首通奖励 + if not isPassed then + local rewardId = XFubenConfigs.GetFirstRewardShow(stageId) + local rewards = XRewardManager.GetRewardList(rewardId) + if rewards then + for index, item in ipairs(rewards) do + local grid = self.RewardGrids[index] + + if not grid then + local ui = index == 1 and self.GridCommon or CSUnityEngineObjectInstantiate(self.GridCommon, self.PanelDropContent) + grid = XUiGridCommon.New(self, ui) + self.RewardGrids[index] = grid + end + + grid:Refresh(item) + grid.GameObject:SetActiveEx(true) + end + end + for index = #rewards + 1, #self.RewardGrids do + self.RewardGrids[index].GameObject:SetActiveEx(false) + end + + self.PanelDropNone.gameObject:SetActiveEx(false) + self.PanelDropContent.gameObject:SetActiveEx(true) + else + self.PanelDropContent.gameObject:SetActiveEx(false) + self.PanelDropNone.gameObject:SetActiveEx(true) + end +end + +function XUiKillZoneStageDetail:AutoAddListener() + self.BtnEnter.CallBack = function() self:OnClickBtnEnter() end + self.BtnBuffTip.CallBack = function() self:OnClickBtnBuffTip() end + self.BtnClose.CallBack = function() self:Close() end +end + +function XUiKillZoneStageDetail:OnClickBtnEnter() + local stageId = self.StageId + XLuaUiManager.Open("UiNewRoomSingle", stageId) +end + +function XUiKillZoneStageDetail:OnClickBtnBuffTip() + local buffIds = XKillZoneConfigs.GetStageBuffIds(self.StageId) + if not XTool.IsTableEmpty(buffIds) then + XLuaUiManager.Open("UiKillZoneBuffTips", self.StageId) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiLeftPopupTip/UiLeftPopupTip.lua b/Resources/Scripts/XUi/XUiLeftPopupTip/UiLeftPopupTip.lua new file mode 100644 index 00000000..c5c4a09d --- /dev/null +++ b/Resources/Scripts/XUi/XUiLeftPopupTip/UiLeftPopupTip.lua @@ -0,0 +1,23 @@ +local XUiLeftPopupTip = XLuaUiManager.Register(XLuaUi, "UiLeftPopupTip") + +function XUiLeftPopupTip:OnStart(title, content, closeCb) + self.Title = title + self.Content = content + self.CloseCb = closeCb + self:InitView() +end + +function XUiLeftPopupTip:OnEnable() + self:PlayAnimation("AniUnlockTip", function() + self:Close() + end) +end + +function XUiLeftPopupTip:OnDestroy() + if self.CloseCb then self.CloseCb() end +end + +function XUiLeftPopupTip:InitView() + self.TxtTitle.text = self.Title + self.TxtContent.text = self.Content +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiLogin/XLoginAttentionPanel.lua b/Resources/Scripts/XUi/XUiLogin/XLoginAttentionPanel.lua new file mode 100644 index 00000000..dab6d45e --- /dev/null +++ b/Resources/Scripts/XUi/XUiLogin/XLoginAttentionPanel.lua @@ -0,0 +1,44 @@ +--- +--- Generated by EmmyLua(https://github.com/EmmyLua) +--- Created by admin. +--- DateTime: 2020/7/15 16:03 +--- + +local this = {} + +function this.OnAwake(rootUi) + this.GameObject = rootUi.gameObject + this.Transform = rootUi.transform + XTool.InitUiObject(this) + this.AutoAddListeners() +end + +function this.AutoAddListeners() + this.BtnTanchuangClose.onClick:AddListener(this.CloseLoginType) + this.BtnConfirm.onClick:AddListener(this.OnConfirm) + this.BtnClose.onClick:AddListener(this.OnCancel) +end + +function this.Open(callback) + this.GameObject:SetActiveEx(true) + this.ConfirmCallback = callback +end + +function this.OnConfirm() + if this.ConfirmCallback ~= nil then + this.ConfirmCallback() + this.ConfirmCallback = nil + end + this.CloseLoginType() +end + +function this.OnCancel() + this.ConfirmCallback = nil + this.CloseLoginType() +end + +function this.CloseLoginType() + this.GameObject:SetActiveEx(false) +end + +return this \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiLogin/XLoginNoticePanel.lua b/Resources/Scripts/XUi/XUiLogin/XLoginNoticePanel.lua new file mode 100644 index 00000000..2988ce8c --- /dev/null +++ b/Resources/Scripts/XUi/XUiLogin/XLoginNoticePanel.lua @@ -0,0 +1,40 @@ +local this = {} + +function this.OnAwake(rootUi) + this.GameObject = rootUi.gameObject + this.Transform = rootUi.transform + this.LinkConfigs = XTableManager.ReadByIntKey("Client/Activity/ActivityLink.tab", XTable.XTableActivityLink, "Id") + XTool.InitUiObject(this) + this.AutoAddListeners() +end + +function this.AutoAddListeners() + this.BtnTanchuangClose.onClick:AddListener(this.CloseMenu) + this.BtnNotice.onClick:AddListener(this.OpenNotice) + for i = 1, 3 do + this["BtnLink" .. i].onClick:AddListener(function() + this.OpenLink(i) + end) + this["MenuInfoText" .. i].text = this.LinkConfigs[i].LinkName + end +end + +function this.OpenLink(index) + if this.LinkConfigs[index] == nil then return end + local url = this.LinkConfigs[index].LinkUrl + CS.UnityEngine.Application.OpenURL(url) +end + +function this.OpenNotice() + local hasNotice = XDataCenter.NoticeManager.OpenLoginNotice() + if not hasNotice then + XUiManager.TipError("No notice") + end +end + +function this.CloseMenu() + this.GameObject:SetActiveEx(false) + XLuaUiManager.Close("UiLoginDialog") +end + +return this \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiLogin/XLoginSwitchAccountPanel.lua b/Resources/Scripts/XUi/XUiLogin/XLoginSwitchAccountPanel.lua new file mode 100644 index 00000000..df84cea3 --- /dev/null +++ b/Resources/Scripts/XUi/XUiLogin/XLoginSwitchAccountPanel.lua @@ -0,0 +1,185 @@ +--- +--- Generated by EmmyLua(https://github.com/EmmyLua) +--- Created by admin. +--- DateTime: 2020/7/15 15:25 +--- + +local this = {} + +function this.OnAwake(rootUi) + this.GameObject = rootUi.gameObject + this.Transform = rootUi.transform + XTool.InitUiObject(this) + this.InitUI() + this.AutoAddListeners() +end + +function this.InitUI() + --苹果端菜显示苹果专用登录选项 + this.AppleGroup.gameObject:SetActiveEx(CS.UnityEngine.Application.platform == CS.UnityEngine.RuntimePlatform.IPhonePlayer); + this.HuaweiGroup.gameObject:SetActiveEx(CS.XHgSdkAgent.IsHuaiwei()) + this.OppoGroup.gameObject:SetActiveEx(CS.XHgSdkAgent.IsOppo()) + --TODO 华为屏蔽 +end + +function this.AutoAddListeners() + this.BtnTanchuangClose.onClick:AddListener(this.CloseLoginType) + this.LoginGoogleBtn.onClick:AddListener(this.GoogleLoginAgent) + this.LoginFacebookBtn.onClick:AddListener(this.FacebookLoginAgent) + this.LoginTwitterBtn.onClick:AddListener(this.TwitterLoginAgent) + this.LoginAppleBtn.onClick:AddListener(this.AppleLoginAgent) + this.LoginHuaweiBtn.onClick:AddListener(this.HuaweiLoginAgent) + this.LoginOppoBtn.onClick:AddListener(this.OppoLoginAgent) + this.LoginVisitorBtn.onClick:AddListener(this.VisitorLoginAgent) + this.LoginTwitterBtn.transform.parent.gameObject:SetActiveEx(false) +end + +function this.SwitchAccountAgent(loginCall) + if XUserManager.Channel == XUserManager.CHANNEL.Android or XUserManager.Channel == XUserManager.CHANNEL.IOS then + if XUserManager.UserId == "" or XUserManager.UserId == nil then + loginCall() + return + end + XUiManager.SystemDialogTip(CS.XTextManager.GetText("TipTitle"), "Confirm to switch account? \nThe account you are currently logged in is\nID:" .. (XUserManager.UserId or ""), + XUiManager.DialogType.Normal, nil, loginCall) + end +end + + +function this.OnAppleLogin() + --XHgSdkManager.Logout() + XHgSdkManager.SwitchAccount(XHgSdkManager.UserType.Apple) + this.CloseLoginType() +end + +function this.AppleLoginAgent() + if this.CheckBind() then + this.SwitchAccountAgent(this.OnAppleLogin) + else + XEventManager.DispatchEvent(XEventId.EVENT_LOGIN_ATTENTION, this.OnAppleLogin) + end +end + +--function this.SidLoginAgent() +-- if this.CheckBind() then +-- this.SwitchAccountAgent(this.OnSidLogin) +-- else +-- XEventManager.DispatchEvent(XEventId.EVENT_LOGIN_ATTENTION, this.OnSidLogin) +-- end +--end +-- +--function this.OnSidLogin() +-- XLuaUiManager.Open("UiAccountSign", function(account, pass) +-- --XHgSdkManager.Logout() +-- XHgSdkManager.LoginSuid(account, pass) +-- this.CloseLoginType() +-- end, nil) +--end + +function this.HuaweiLoginAgent() + if this.CheckBind() then + this.SwitchAccountAgent(this.OnHuaweiLogin) + else + XEventManager.DispatchEvent(XEventId.EVENT_LOGIN_ATTENTION, this.OnHuaweiLogin) + end +end + +function this.OnHuaweiLogin() + --XHgSdkManager.Logout() + XHgSdkManager.SwitchAccount(XHgSdkManager.UserType.Huawei) + this.CloseLoginType() +end + +function this.OppoLoginAgent() + if this.CheckBind() then + this.SwitchAccountAgent(this.OnOppoLogin) + else + XEventManager.DispatchEvent(XEventId.EVENT_LOGIN_ATTENTION, this.OnOppoLogin) + end +end + +function this.OnOppoLogin() + XHgSdkManager.SwitchAccount(XHgSdkManager.UserType.Oppo) + this.CloseLoginType() +end + +function this.GoogleLoginAgent() + if this.CheckBind() then + this.SwitchAccountAgent(this.OnGoogleLogin) + else + XEventManager.DispatchEvent(XEventId.EVENT_LOGIN_ATTENTION, this.OnGoogleLogin) + end +end + +function this.OnGoogleLogin() + --XHgSdkManager.Logout() + XHgSdkManager.SwitchAccount(XHgSdkManager.UserType.Google) + this.CloseLoginType() +end + +function this.FacebookLoginAgent() + if this.CheckBind() then + this.SwitchAccountAgent(this.OnFacebookLogin) + else + XEventManager.DispatchEvent(XEventId.EVENT_LOGIN_ATTENTION, this.OnFacebookLogin) + end +end + +function this.OnFacebookLogin() + --XHgSdkManager.Logout() + XHgSdkManager.SwitchAccount(XHgSdkManager.UserType.FaceBook) + this.CloseLoginType() +end + +function this.TwitterLoginAgent() + if this.CheckBind() then + this.SwitchAccountAgent(this.OnTwitterLogin) + else + XEventManager.DispatchEvent(XEventId.EVENT_LOGIN_ATTENTION, this.OnTwitterLogin) + end +end + +function this.OnTwitterLogin() + --XHgSdkManager.Logout() + XHgSdkManager.SwitchAccount(XHgSdkManager.UserType.Twitter) + this.CloseLoginType() +end + +function this.VisitorLoginAgent() + this.SwitchAccountAgent(this.OnVisitorLogin) +end + +function this.OnVisitorLogin() + if this.CheckIsLoginWithVisitor() then + XUiManager.TipText("AlreadySignedGuestAccount") + return + end + XHgSdkManager.SwitchAccount(XHgSdkManager.UserType.Vistor) + this.CloseLoginType() +end + +function this.CheckBind() -- 修改了逻辑(当前存在登录账号且是游客账号时 return false,其余 return true) + if XUserManager.Channel == XUserManager.CHANNEL.Android or XUserManager.Channel == XUserManager.CHANNEL.IOS then + if XUserManager.UserId ~= nil and XUserManager.UserId ~= "" and XUserManager.UserType == XHgSdkManager.UserType.Vistor then + return false + end + end + + return true +end + +function this.CloseLoginType() + XLuaUiManager.Close("UiLoginDialog") +end + +function this.CheckIsLoginWithVisitor() -- 检查当前是否已经以游客账户登录 + if XUserManager.Channel == XUserManager.CHANNEL.Android or XUserManager.Channel == XUserManager.CHANNEL.IOS then + if not XHgSdkManager.IsNeedLogin() and XUserManager.UserType == XHgSdkManager.UserType.Vistor then + return true + end + end + + return false +end + +return this \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiLogin/XUiAccountSign.lua b/Resources/Scripts/XUi/XUiLogin/XUiAccountSign.lua new file mode 100644 index 00000000..a215ec4d --- /dev/null +++ b/Resources/Scripts/XUi/XUiLogin/XUiAccountSign.lua @@ -0,0 +1,74 @@ +--- +--- Generated by EmmyLua(https://github.com/EmmyLua) +--- Created by admin. +--- DateTime: 2020/7/23 17:18 +--- + +local this = XLuaUiManager.Register(XLuaUi, "UiAccountSign") + +local LookStatus = { + Clear = 1, + Pass = 2, + Switch = 3 +} + +function this:OnAwake() + XTool.InitUiObject(self) + XUiHelper.RegisterClickEvent(self, self.BtnTanchuangClose, self.OnCloseLogin) + XUiHelper.RegisterClickEvent(self, self.BtnLook, self.OnLookPassword) + XUiHelper.RegisterClickEvent(self, self.BtnConfirm, self.OnLogin) +end + +function this:OnStart(loginCallback, cancelCallback) + self.LookStatus = LookStatus.Pass; + self.InFPassword.text = "" + self.ImgLook.gameObject:SetActiveEx(false) + self.ImgUnlook.gameObject:SetActiveEx(true) + self.InFID.text = "" + self.ClearPassword = "" + self:SetLookStatus() + self.LoginCallback = loginCallback + self.CancelCallback = cancelCallback +end + +function this:OnLogin() + local account = self.InFID.text + local pass = self.InFPassword.text + local callback = self.LoginCallback + + if #account < 1 or #pass < 1 then + XUiManager.TipError("アカウントまたはパスワードは空です") + return + end + + XLuaUiManager.Close("UiAccountSign") + if callback then + callback(account, pass) + end +end + + +function this:OnCloseLogin() + XLuaUiManager.Close("UiAccountSign") + if self.CancelCallback then + self.cancelCallback() + end +end + +function this:OnLookPassword() + self.LookStatus = LookStatus.Switch - self.LookStatus + self:SetLookStatus() +end + +function this:SetLookStatus() + if self.LookStatus == LookStatus.Clear then + self.InFPassword.contentType = CS.UnityEngine.UI.InputField.ContentType.Standard + else + self.InFPassword.contentType = CS.UnityEngine.UI.InputField.ContentType.Password + end + self.ImgLook.gameObject:SetActiveEx(self.LookStatus == LookStatus.Clear) + self.ImgUnlook.gameObject:SetActiveEx(self.LookStatus == LookStatus.Pass) + self.ClearPassword = self.InFPassword.text + self.InFPassword.text = "" + self.InFPassword.text = self.ClearPassword +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiLogin/XUiGridServer.lua b/Resources/Scripts/XUi/XUiLogin/XUiGridServer.lua new file mode 100644 index 00000000..8f61ae7b --- /dev/null +++ b/Resources/Scripts/XUi/XUiLogin/XUiGridServer.lua @@ -0,0 +1,84 @@ +XUiGridServer = XClass(nil, "XUiGridServer") + +local CSUiButtonStateSelect = CS.UiButtonState.Select +local CSUiButtonStateNormal = CS.UiButtonState.Normal + +function XUiGridServer:Ctor(ui, server, cb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.SelectCb = cb + self:InitAutoScript() + self:InitServerName(server.Name) + self:UpdateServer(server) +end + +function XUiGridServer:InitServerName(name) + self.BtnServer:SetName(name) +end + +function XUiGridServer:UpdateServer(server) + self.Server = server + self:UpdateServerSelect() +end + +function XUiGridServer:UpdateServerSelect() + if self.Server.Id == XServerManager.Id then + self.BtnServer:SetButtonState(CSUiButtonStateSelect) + else + self.BtnServer:SetButtonState(CSUiButtonStateNormal) + end +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiGridServer:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiGridServer:AutoInitUi() + self.BtnServer = self.Transform:Find("BtnServer"):GetComponent("XUiButton") +end + +function XUiGridServer:GetAutoKey(uiNode,eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiGridServer:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiGridServer:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key],eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiGridServer:AutoAddListener() + self.AutoCreateListeners = {} + self.BtnServer.CallBack = function() + self:OnBtnServerClick() + end +end +-- auto + +function XUiGridServer:OnBtnServerClick() + if self.SelectCb then + self.SelectCb(self.Server.Id) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiLogin/XUiLogin.lua b/Resources/Scripts/XUi/XUiLogin/XUiLogin.lua new file mode 100644 index 00000000..4a759de2 --- /dev/null +++ b/Resources/Scripts/XUi/XUiLogin/XUiLogin.lua @@ -0,0 +1,464 @@ +local XUiLoginNetworkModePanel = require("XUi/XUiLogin/XUiLoginNetworkModePanel") + +local XUiLogin = XLuaUiManager.Register(XLuaUi, "UiLogin") + +local HasRequestNotice = false + +function XUiLogin:OnAwake() + self:InitAutoScript() + self.GridServer.gameObject:SetActive(false) + + self.PanelLogin.gameObject:SetActive(true) + self.PanelServerList.gameObject:SetActive(false) + self.ServerList = {} + self.SyncServer = false + + self.VerificationWaitInterval = CS.XGame.ClientConfig:GetInt("VerificationWaitInterval") + self.SyncServerListInterval = CS.XGame.ClientConfig:GetInt("SyncServerListInterval") + self.TxtNewVersion.text = CS.XRemoteConfig.DocumentVersion .. " (DocumentVersion)" + self.TxtOldVersion.text = CS.XRemoteConfig.ApplicationVersion .. " (ApplicationVersion)" + + self:InitServerList() + + -- self.TxtUser.text = XUserManager.UserId + + -- XEventManager.BindEvent(self.TxtUser, XEventId.EVENT_USERID_CHANGE, function(userName) + -- self.TxtUser.text = userName or "" + -- XLog.Warning("XEventId.EVENT_USERID_CHANGE") + -- --self.PanelServerList.gameObject:SetActive(true) + -- end) + + XLoginManager.SetStartGuide(false) + + self.NeedAutoLoginByDeepLink = CS.XRemoteConfig.DeepLinkEnabled and not string.IsNilOrEmpty(CS.XAppsflyerEvent.GetDeepLinkValue()) + + + XEventManager.AddEventListener(XEventId.EVNET_HGSDKLOGIN_SUCCESS, self.OnHgSdkLoginSuccess, self) + XEventManager.AddEventListener(XEventId.EVENT_AGREEMENT_LOAD_FINISH, self.OnLoadAgreementFinish, self) + XEventManager.AddEventListener(XEventId.EVENT_WHEN_CLOSE_LOGIN_NOTICE, self.OnCloseLoginNotice, self) +end + +function XUiLogin:OnUserIDChange() + self.TxtUser.text = XUserManager.UserId or "" + -- XLog.Debug("XEventId.EVENT_USERID_CHANGE") +end + +function XUiLogin:OnCloseLoginNotice() + if XAgreementManager.CheckNeedShow() then + if not XLuaUiManager.IsUiShow("UiLoginAgreement") then + XLuaUiManager.Open("UiLoginAgreement") + end + end +end + +function XUiLogin:OnLoadAgreementFinish() + if XLuaUiManager.IsUiShow("UiLoginNotice") then + return + end + if XAgreementManager.CheckNeedShow() then + if not XLuaUiManager.IsUiShow("UiLoginAgreement") then + XLuaUiManager.Open("UiLoginAgreement") + end + end +end + +function XUiLogin:OnDestroy() + -- XEventManager.UnBindEvent(self.TxtUser) + XEventManager.RemoveEventListener(XEventId.EVNET_HGSDKLOGIN_SUCCESS, self.OnHgSdkLoginSuccess, self) + XEventManager.RemoveEventListener(XEventId.EVENT_AGREEMENT_LOAD_FINISH, self.OnLoadAgreementFinish, self) + XEventManager.RemoveEventListener(XEventId.EVENT_WHEN_CLOSE_LOGIN_NOTICE, self.OnCloseLoginNotice, self) +end + +function XUiLogin:OnDisable() + self.IsInLogin = false +end + +function XUiLogin:OnStart(...) + if self.BlackMask then + self.BlackMask.color = CS.UnityEngine.Color(0.0, 0.0, 0.0, 0.0) + self.BlackMask.gameObject:SetActive(false) + end + + --CS.XAudioManager.PlayMusic(CS.XAudioManager.LOGIN_BGM) + + self:ShowLoginPanel() + if XUserManager.Channel ~= XUserManager.CHANNEL.KuroPC then + self.TxtUser.text = XUserManager.UserId or "" + else + self.TxtUser.text = "" + end + self.GameObject:ScheduleOnce(function() + --释放启动界面的资源 + CS.UnityEngine.Resources.UnloadUnusedAssets() + end,100) + + XAgreementManager.LoadAgreeInfo() + + self:RequestLoginNotice() + --self.IsRequestNotice = true +end + +function XUiLogin:ShowLoginPanel() + self.PanelLogin.gameObject:SetActive(true) + self.PanelServerList.gameObject:SetActive(false) +end + +function XUiLogin:ShowActivatePanel() + self.PanelActivate.gameObject:SetActive(true) +end + +function XUiLogin:HideActivatePanel() + self.PanelActivate.gameObject:SetActive(false) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiLogin:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiLogin:AutoInitUi() + self.PanelLogin = self.Transform:Find("SafeAreaContentPane/PanelLogin") + self.BtnStart = self.Transform:Find("SafeAreaContentPane/PanelLogin/BtnStart"):GetComponent("Button") + self.PanelLoginServer = self.Transform:Find("SafeAreaContentPane/PanelLogin/PanelLoginServer") + self.BtnServer = self.Transform:Find("SafeAreaContentPane/PanelLogin/PanelLoginServer/BtnServer"):GetComponent("XUiButton") + self.PanelUser = self.Transform:Find("SafeAreaContentPane/PanelLogin/PanelUser") + self.BtnUser = self.Transform:Find("SafeAreaContentPane/PanelLogin/PanelUser/BtnUser"):GetComponent("Button") + self.TxtUser = self.Transform:Find("SafeAreaContentPane/PanelLogin/PanelUser/BtnUser/TxtUser"):GetComponent("Text") + self.TxtNewVersion = self.Transform:Find("SafeAreaContentPane/PanelLogin/TxtNewVersion"):GetComponent("Text") + self.PanelServerList = self.Transform:Find("SafeAreaContentPane/PanelLogin/PanelServerList") + self.PanelServer = self.Transform:Find("SafeAreaContentPane/PanelLogin/PanelServerList/PanelServer") + self.SViewServer = self.Transform:Find("SafeAreaContentPane/PanelLogin/PanelServerList/PanelServer/SViewServer"):GetComponent("ScrollRect") + self.PanelServerContent = self.Transform:Find("SafeAreaContentPane/PanelLogin/PanelServerList/PanelServer/SViewServer/Viewport/PanelServerContent") + self.GridServer = self.Transform:Find("SafeAreaContentPane/PanelLogin/PanelServerList/PanelServer/SViewServer/Viewport/PanelServerContent/GridServer") + self.BtnHideServerList = self.Transform:Find("SafeAreaContentPane/PanelLogin/PanelServerList/PanelServer/BtnHideServerList"):GetComponent("Button") + self.TxtOldVersion = self.Transform:Find("SafeAreaContentPane/PanelLogin/TxtOldVersion"):GetComponent("Text") + self.ImgLogo = self.Transform:Find("SafeAreaContentPane/ImgLogo"):GetComponent("Image") + self.BtnLoginNotice = self.Transform:Find("SafeAreaContentPane/BtnLoginNotice"):GetComponent("Button") + --LoginAgreePanel.OnAwake(self.Transform:Find("SafeAreaContentPane/PanelAgreement").gameObject) + --LoginTypePanel.OnAwake(self.Transform:Find("SafeAreaContentPane/PanelLoginType").gameObject) + self.PanelLoginNetworkMode = XUiLoginNetworkModePanel.New(self, self.PanelNetworkModeTip) +end + +function XUiLogin:AutoAddListener() + self:RegisterClickEvent(self.BtnStart, self.OnBtnStartClick) + self:RegisterClickEvent(self.BtnServer, self.OnBtnServerClick) + self:RegisterClickEvent(self.BtnUser, self.OnBtnUserClick) + self:RegisterClickEvent(self.BtnHideServerList, self.OnBtnHideServerListClick) + self:RegisterClickEvent(self.SwitchAccount, self.OnSwitchAccountClick) + self:RegisterClickEvent(self.PanelAgree, self.OnAgreePanelClick) + self:RegisterClickEvent(self.BtnMenu, self.OnBtnMenuClick) + self.BtnNetworkMode.CallBack = function() self:OnBtnNetworkModeClick() end +end + +function XUiLogin:SwitchServer() + XLog.Warning("XUiLogin.SwitchServer") + self.PanelServerList.gameObject:SetActive(true) +end + +function XUiLogin:OnBtnMenuClick() + XLuaUiManager.Open("UiLoginDialog", "Menu") +end + +function XUiLogin:OnAgreePanelClick() + XLuaUiManager.Open("UiLoginAgreement") +end + +function XUiLogin:OnBtnNetworkModeClick() + self.PanelLoginNetworkMode:Show() +end + +function XUiLogin:OnHgSdkLoginSuccess() + self.PanelUser.gameObject:SetActiveEx(true) + self.BtnStart.gameObject:SetActiveEx(true) + self:OnUserIDChange() + if XUserManager.UserId then -- 海外修改 + local user_ServerId = XSaveTool.GetData(XPrefs.User_ServerId..XUserManager.UserId) + local user_ServerId_Num = tonumber(user_ServerId) + XLog.Debug("User_ServerId:"..XPrefs.User_ServerId..XUserManager.UserId..":"..tostring(user_ServerId)) + self.TxtUser.text = XUserManager.UserId; + local serverDataList = XServerManager.GetServerList() + -- user_ServerId_Num 才是真实的serverId + if user_ServerId and user_ServerId_Num then + local currentServer; + for _, server in pairs(serverDataList) do + if server.Id == user_ServerId_Num then + currentServer = server; + end + end + if currentServer then + XServerManager.Select(currentServer); + self:UpdateSelectServer(currentServer); + end + else + self.PanelServerList.gameObject:SetActive(true) + end + end + --XAppEventManager.ApplogEvent(CS.XHgSdkEventConfig.SDK_Login); +end + +function XUiLogin:OnSwitchAccountClick(eventData) + if XUserManager.Channel == XUserManager.CHANNEL.Android or XUserManager.Channel == XUserManager.CHANNEL.IOS then + XAppEventManager.AppLogEvent(XAppEventManager.CommonEventNameConfig.Change_account) + XLuaUiManager.Open("UiLoginDialog", "Account") + elseif XUserManager.Channel == XUserManager.CHANNEL.KuroPC then + XUserManager.Logout() + else + CsXUiManager.Instance:Open("UiRegister") + end +end + +function XUiLogin:OnBtnUserClick(...) + --注释 JP分支通过切换用户来登录,不需要退出账号行为 + --XUserManager.ShowLogout() + --仅仅用来调试 + if self.ClickCount == nil then + self.ClickCount = 0 + return + end + self.ClickCount = self.ClickCount + 1 + if self.ClickCount == 10 then + local type = CS.XRemoteConfig.Channel + type = type + 1 + if type == 5 then + type = 1 + end + CS.XRemoteConfig.Channel = type + XUiManager.TipError("Network connect Type changed to " .. type) + self.ClickCount = 0 + end +end + +function XUiLogin:OnBtnStartClick(...) + if XLoginManager.GetSDKAccountStatus() == XLoginManager.SDKAccountStatus.Cancellation then -- 检测sdk账号是否已经申请注销 + XUiManager.DialogTip(CS.XGame.ClientConfig:GetString("AccountUnCancellationTitle"), CS.XGame.ClientConfig:GetString("AccountUnCancellationContent"), XUiManager.DialogType.Normal, function() end, function() + XHgSdkManager.AccountUnCancellation() + end) + return + end + --如果默认的用户没有同意协议,则弹出用户协议 + --当用户成功登录后,将同意协议存储在本地,不再需要同意协议 + if XLoginManager.GetSDKAccountStatus() == XLoginManager.SDKAccountStatus.Cancellation then + XUiManager.DialogTip(CS.XGame.ClientConfig:GetString("AccountUnCancellationTitle"), CS.XGame.ClientConfig:GetString("AccountUnCancellationContent"), nil, function() end, function() + XHgSdkManager.AccountUnCancellation() + end) + return + end + if XAgreementManager.CheckNeedShow() then + XLuaUiManager.Open("UiLoginAgreement") + return + end + + if not self.IsRequestNotice then + return + end + + XAppEventManager.AppLogEvent(XAppEventManager.CommonEventNameConfig.SDK_Login) + + if XUserManager.IsNeedLogin() then + XUserManager.ShowLogin() + else + self:DoLogin() + end +end + +-------------------------------------获取公告-------------------------------------------- + +function XUiLogin:RequestLoginNotice() + XLuaUiManager.SetAnimationMask(true) + XDataCenter.NoticeManager.RequestLoginNotice(function(invalid) + self.IsRequestNotice = true + XLuaUiManager.SetAnimationMask(false) + XDataCenter.NoticeManager.AutoOpenLoginNotice() + end) +end + +----------------------------------- 登录到服务器 ------------------------------------------ + +function XUiLogin:DoLogin(...) + if self.IsInLogin then + return + end + self.IsInLogin = true + XLuaUiManager.SetAnimationMask(true) + local loginProfiler = CS.XProfiler.Create("login") + loginProfiler:Start() + XLoginManager.Login(function(code) + XLuaUiManager.SetAnimationMask(false) + if code and code ~= XCode.Success then + if code == XCode.Fail then + self.IsInLogin = false + return + end + if code == XCode.LoginServiceInvalidToken then + self.IsInLogin = false + XUserManager.SignOut() + XUserManager.ShowLogin() + end + self.IsInLogin = false + return + end + + --CS.XAudioManager.PlayMusic(CS.XAudioManager.MAIN_BGM) + + local runMainProfiler = loginProfiler:CreateChild("RunMain") + runMainProfiler:Start() + + --BDC + CS.XHeroBdcAgent.BdcAfterSdkLoginPage() + + XDataCenter.PurchaseManager.YKInfoDataReq(function() + if self.BlackMask then + self.BlackMask.color = CS.UnityEngine.Color(0.0, 0.0, 0.0, 0.0) + self.BlackMask.gameObject:SetActive(true) + self.BlackMask:DOFade(1.1, 0.3):OnComplete(function() + local guideFight = XDataCenter.GuideManager.GetNextGuideFight() + if guideFight then + self:Close() + + XAppEventManager.AppLogEvent(XAppEventManager.CommonEventNameConfig.Anime_Start) + XAppEventManager.AppLogEvent(XAppEventManager.CommonEventNameConfig.Completed_Registration) + + local movieId = CS.XGame.ClientConfig:GetString("NewUserMovieId") + CS.Movie.XMovieManager.Instance:PlayById(movieId, function() + XDataCenter.FubenManager.EnterGuideFight(guideFight.Id, guideFight.StageId, guideFight.NpcId, guideFight.Weapon) + end) + else + XLoginManager.SetFirstOpenMainUi(true) + XLuaUiManager.RunMain() + end + end) + else + local guideFight = XDataCenter.GuideManager.GetNextGuideFight() + if guideFight then + self:Close() + + XAppEventManager.AppLogEvent(XAppEventManager.CommonEventNameConfig.Anime_Start) + XAppEventManager.AppLogEvent(XAppEventManager.CommonEventNameConfig.Completed_Registration) + + local movieId = CS.XGame.ClientConfig:GetString("NewUserMovieId") + CS.Movie.XMovieManager.Instance:PlayById(movieId, function() + XDataCenter.FubenManager.EnterGuideFight(guideFight.Id, guideFight.StageId, guideFight.NpcId, guideFight.Weapon) + end) + else + XLoginManager.SetFirstOpenMainUi(true) + XLuaUiManager.RunMain() + end + end + -- self:OnCheckBindTask() + end) + + XDataCenter.SetManager.SetOwnFontSizeByCache() + runMainProfiler:Stop() + + loginProfiler:Stop() + XLog.Debug(loginProfiler) + end) +end + +----------------------------------- 获取服务器列表 ---------------------------------------- +---实际上功能上去掉了一部分功能,登录界面上并没有当前选择的服务器状态,low high 和 maintain都是失效的 + +function XUiLogin:OnBtnHideServerListClick(...) + self.PanelServerList.gameObject:SetActive(false) +end + +function XUiLogin:OnBtnServerClick(...) + self.PanelServerList.gameObject:SetActive(true) +end + +function XUiLogin:UpdateSelectServer(server) + self.BtnServer:SetName(server.Name) +end + +function XUiLogin:UpdateServerListSelect() + for _, server in pairs(self.ServerList) do + server:UpdateServerSelect() + end +end + +function XUiLogin:InitServerList() + local list = XServerManager.GetServerList() + + if list then + self.BtnServer.gameObject:SetActiveEx(#list > 1) + end + + local currentServer; + + for _, server in pairs(list) do + local serverGrid = XUiGridServer.New(CS.UnityEngine.Object.Instantiate(self.GridServer), server, function() + XServerManager.Select(server) + self:UpdateSelectServer(server) + self:UpdateServerListSelect() + self.PanelServerList.gameObject:SetActive(false) + end) + + if server.Id == XServerManager.Id then + currentServer = server; + end + + serverGrid.Transform:SetParent(self.PanelServerContent, false) + serverGrid.GameObject:SetActive(true) + self.ServerList[server.Id] = serverGrid + end + + self:UpdateSelectServer(currentServer) +end + +--------------------------------------------------------------------------Recycle------------------------------------------------------------------------------- + +-- --似乎暂时也不用了 +-- function XUiLogin:StopSyncServerList() +-- if self.SyncServerTimer then +-- CS.XScheduleManager.UnSchedule(self.SyncServerTimer) +-- self.SyncServer = false +-- self.SyncServerTimer = null +-- end +-- end + +-- --没有地方用到 +-- function XUiLogin:SyncServerList(cb) +-- if not self.SyncServer then +-- self.SyncServer = true +-- self.SyncServerTimer = CS.XScheduleManager.ScheduleForever(function(...) +-- self:SyncServerList() +-- end, self.SyncServerListInterval, 0) +-- end + +-- local baseGrid = self.GridServer +-- XServerManager.GetServerData(function(serverData) +-- XTool.LoopMap(serverData.ServerTable, function(key, value) +-- if value.Id == XServerManager.Id then +-- self:UpdateSelectServer(value) +-- end + +-- if self.ServerList[value.Id] then +-- self.ServerList[value.Id]:UpdateServer(value) +-- else +-- local serverGrid = XUiGridServer.New(CS.UnityEngine.Object.Instantiate(baseGrid), value, function() +-- XServerManager.Select(value) +-- self:UpdateSelectServer(value) +-- self:UpdateServerListSelect() +-- self.PanelServerList.gameObject:SetActive(false) +-- end) + +-- serverGrid.Transform:SetParent(self.PanelServerContent, false) +-- serverGrid.GameObject:SetActive(true) +-- self.ServerList[value.Id] = serverGrid +-- end +-- end) + +-- if cb then +-- cb() +-- end +-- end) +-- end + +-- function XUiLogin:OnCheckBindTask() +-- if XUserManager.UserType == XHgSdkManager.UserType.FaceBook or XUserManager.UserType == XHgSdkManager.UserType.Apple or XUserManager.UserType == XHgSdkManager.UserType.Google +-- or XUserManager.UserType == XHgSdkManager.UserType.Twitter then +-- XHgSdkManager.OnBindTaskFinished() +-- end +-- end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiLogin/XUiLoginAgreePanel.lua b/Resources/Scripts/XUi/XUiLogin/XUiLoginAgreePanel.lua new file mode 100644 index 00000000..3b7fb22d --- /dev/null +++ b/Resources/Scripts/XUi/XUiLogin/XUiLoginAgreePanel.lua @@ -0,0 +1,91 @@ +local this = {} +local LOCAL_SAVE_AGREE = "LOCAL_SAVE_AGREE" +local LOCAL_SAVE_PRIVE = "LOCAL_SAVE_PRIVE" + +function this.OnAwake(rootUi, parent) + this.GameObject = rootUi.gameObject + this.Transform = rootUi.transform + this.Init = false; + this.Parent = parent; + XTool.InitUiObject(this) + this.InitUI() + this.AutoAddListeners() +end + +--第一次登录默认不勾选用户协议 +function this.InitUI() + this.AgreeToggle.isOn = false + this.UserAgreeLicence = false +end + +function this.SaveToLocal() + local saveAgree = XSaveTool.GetData(LOCAL_SAVE_AGREE) + local savePrive = XSaveTool.GetData(LOCAL_SAVE_PRIVE) + if saveAgree == nil or savePrive == nil then + XSaveTool.SaveData(LOCAL_SAVE_AGREE, XAgreementManager.CurAgree) + XSaveTool.SaveData(LOCAL_SAVE_PRIVE, XAgreementManager.CurPriva) + return + end + + if XAgreementManager.CurAgree == nil or XAgreementManager.CurPriva == nil then + return + end + + if XAgreementManager.CurAgree ~= saveAgree or XAgreementManager.CurPriva ~= savePrive then + XSaveTool.SaveData(LOCAL_SAVE_AGREE, XAgreementManager.CurAgree) + XSaveTool.SaveData(LOCAL_SAVE_PRIVE, XAgreementManager.CurPriva) + end +end + + +function this.AutoAddListeners() + if this.Init then return end + this.ConfirmAgree.onClick:AddListener(this.OnCancelAgree) + this.CancelAgree.onClick:AddListener(this.OnConfirmAgree) + this.AgreeToggle.onValueChanged:AddListener(this.OnAgreeValueChanged) + this.Init = true +end + +function this.OnConfirmAgree() + if this.UserAgreeLicence == false then + --XUiManager.SystemDialogTip("TIPS", "利用規約及びプライバシーポリシーに同意いただけない場合、ゲーム登録できません。", XUiManager.DialogType.OnlySure, nil, nil) + XUiManager.TipError("Please read and agree to the terms of service and privacy before starting the game") + else + --CheckPoint: APPEVENT_GAME_PRIVACY + XAppEventManager.AppLogEvent(XAppEventManager.CommonEventNameConfig.Game_Privacy) + this.SaveToLocal() + if this.Parent and this.Parent.CloseCallBack then + this.Parent.CloseCallBack() + end + this.Hide() + end +end + +function this.OnAgreeValueChanged(isOn) + this.UserAgreeLicence = isOn + XAgreementManager.SetUserAgreeLicence(isOn) +end + +function this.OnCancelAgree() + if this.SavedAgree ~= nil then + XAgreementManager.SetUserAgreeLicence(this.SavedAgree); + end + this.Hide() +end + +function this.Show() + local str1, str2 = XAgreementManager.SplitLongText(XAgreementManager.CurAgree) + this.AgreeTxt1.text = str1 + this.AgreeTxt2.text = str2 + this.PrivTxt2.text = XAgreementManager.CurPriva + if XAgreementManager.GetUserAgreeLicence() ~= nil then + this.AgreeToggle.isOn = XAgreementManager.GetUserAgreeLicence() + this.SavedAgree = XAgreementManager.GetUserAgreeLicence() + end +end + +function this.Hide() + XLuaUiManager.Close("UiLoginAgreement") +end + +return this \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiLogin/XUiLoginAgreement.lua b/Resources/Scripts/XUi/XUiLogin/XUiLoginAgreement.lua new file mode 100644 index 00000000..923cdec2 --- /dev/null +++ b/Resources/Scripts/XUi/XUiLogin/XUiLoginAgreement.lua @@ -0,0 +1,16 @@ +--- +--- Generated by EmmyLua(https://github.com/EmmyLua) +--- Created by admin. +--- DateTime: 2020/7/15 15:04 +--- +local this = XLuaUiManager.Register(XLuaUi, "UiLoginAgreement") +local LoginAgreePanel = require("XUi/XUiLogin/XUiLoginAgreePanel") + +function this:OnAwake() + LoginAgreePanel.OnAwake(self.Transform:Find("SafeAreaContentPane/PanelAgreement").gameObject, self) +end + +function this:OnStart(cb) + LoginAgreePanel.Show() + self.CloseCallBack = cb +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiLogin/XUiLoginDialog.lua b/Resources/Scripts/XUi/XUiLogin/XUiLoginDialog.lua new file mode 100644 index 00000000..54576c19 --- /dev/null +++ b/Resources/Scripts/XUi/XUiLogin/XUiLoginDialog.lua @@ -0,0 +1,27 @@ +--- +--- Generated by EmmyLua(https://github.com/EmmyLua) +--- Created by admin. +--- DateTime: 2020/7/15 15:04 +--- +local this = XLuaUiManager.Register(XLuaUi, "UiLoginDialog") +local SwitchPanel = require("XUi/XUiLogin/XLoginSwitchAccountPanel") +local AttentionPanel = require("XUi/XUiLogin/XLoginAttentionPanel") +local NoticePanel = require("XUi/XUiLogin/XLoginNoticePanel") + +function this:OnAwake() + SwitchPanel.OnAwake(self.PanelAccountSwich.gameObject) + AttentionPanel.OnAwake(self.PanelAttention.gameObject) + NoticePanel.OnAwake(self.PanelMenu.gameObject) +end + +function this:OnStart(panelType) + self.PanelAccountSwich.gameObject:SetActiveEx(panelType == "Account") + self.PanelAttention.gameObject:SetActiveEx(panelType == "Tip") + self.PanelMenu.gameObject:SetActiveEx(panelType == "Menu") + XEventManager.RemoveEventListener(XEventId.EVENT_LOGIN_ATTENTION, self.OpenAttention, self) + XEventManager.AddEventListener(XEventId.EVENT_LOGIN_ATTENTION, self.OpenAttention, self) +end + +function this:OpenAttention(callback) + AttentionPanel.Open(callback) +end diff --git a/Resources/Scripts/XUi/XUiLogin/XUiLoginNetworkModePanel.lua b/Resources/Scripts/XUi/XUiLogin/XUiLoginNetworkModePanel.lua new file mode 100644 index 00000000..f7cd4621 --- /dev/null +++ b/Resources/Scripts/XUi/XUiLogin/XUiLoginNetworkModePanel.lua @@ -0,0 +1,67 @@ +local XUiLoginNetworkModePanel = XClass(nil, "XUiLoginNetworkModePanel") + +function XUiLoginNetworkModePanel:Ctor(rootUi, ui) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:Init() +end + +function XUiLoginNetworkModePanel:Init() + self:AutoRegisterListener() + self:InitBtnGroup() +end + +function XUiLoginNetworkModePanel:AutoRegisterListener() + self.BtnExit.CallBack = function() self:Hide() end + self.BtnSave.CallBack = function() self:OnBtnSaveClick() end +end + +function XUiLoginNetworkModePanel:InitBtnGroup() + self.BtnGroup:Init({self.TogMode1, self.TogMode2, self.TogMode3}, function(index) + self:OnBtnModeClick(index) + end) +end + +function XUiLoginNetworkModePanel:OnBtnModeClick(index) + if index then + if index == 1 then + self.CurNetworkMode = XNetwork.NetworkMode.Auto + elseif index == 2 then + self.CurNetworkMode = XNetwork.NetworkMode.Ipv4 + elseif index == 3 then + self.CurNetworkMode = XNetwork.NetworkMode.Ipv6 + end + end +end + +function XUiLoginNetworkModePanel:Refresh() + self.CurNetworkMode = XSaveTool.GetData(XNetwork.NetworkModeKey) or XNetwork.NetworkMode.Auto + if self.CurNetworkMode == XNetwork.NetworkMode.Auto then + self.BtnGroup:SelectIndex(1, false) + elseif self.CurNetworkMode == XNetwork.NetworkMode.Ipv4 then + self.BtnGroup:SelectIndex(2, false) + elseif self.CurNetworkMode == XNetwork.NetworkMode.Ipv6 then + self.BtnGroup:SelectIndex(3, false) + end +end + +function XUiLoginNetworkModePanel:OnBtnSaveClick() + if self.CurNetworkMode then + XSaveTool.SaveData(XNetwork.NetworkModeKey, self.CurNetworkMode) + XUiManager.TipMsg("Changing Network Mode Succeed.") + self:Hide() + end +end + +function XUiLoginNetworkModePanel:Show() + self:Refresh() + self.GameObject:SetActiveEx(true) +end + +function XUiLoginNetworkModePanel:Hide() + self.GameObject:SetActiveEx(false) +end + +return XUiLoginNetworkModePanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiLogin/XUiLoginTypePanel.lua b/Resources/Scripts/XUi/XUiLogin/XUiLoginTypePanel.lua new file mode 100644 index 00000000..884be097 --- /dev/null +++ b/Resources/Scripts/XUi/XUiLogin/XUiLoginTypePanel.lua @@ -0,0 +1,56 @@ +local this = {} + +function this.OnAwake(rootUi) + this.GameObject = rootUi.gameObject + this.Transform = rootUi.transform + XTool.InitUiObject(this) + this.InitUI() + this.AutoAddListeners() +end + +function this.InitUI() + --苹果端菜显示苹果专用登录选项 + this.AppleGroup.gameObject:SetActiveEx(CS.UnityEngine.Application.platform == CS.UnityEngine.RuntimePlatform.IPhonePlayer); +end + +function this.AutoAddListeners() + this.CloseLoginTypeBtn.onClick:AddListener(this.CloseLoginType) + this.LoginTwitterBtn.onClick:AddListener(this.OnTwitterLogin) + this.LoginLineBtn.onClick:AddListener(this.OnLineLogin) + this.LoginAppleBtn.onClick:AddListener(this.OnAppleLogin) + this.LoginSidBtn.onClick:AddListener(this.OnSidLogin) +end + +function this.OnAppleLogin() + XHgSdkManager.Logout() + XHgSdkManager.Login(XHgSdkManager.UserType.Apple) +end + +function this.OnSidLogin() + XHgSdkManager.Logout() + XHgSdkManager.Login(XHgSdkManager.UserType.Suid) +end + +function this.OnTwitterLogin() + XHgSdkManager.Logout() + XHgSdkManager.Login(XHgSdkManager.UserType.Twitter) +end + +function this.OnLineLogin() + XHgSdkManager.Logout() + XHgSdkManager.Login(XHgSdkManager.UserType.Line) +end + +function this.CloseLoginType() + this.GameObject:SetActiveEx(false) +end + +function this.Show() + this.GameObject:SetActiveEx(true) +end + +function this.Hide() + this.GameObject:SetActiveEx(false) +end + +return this \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiLogin/XUiSetAccount.lua b/Resources/Scripts/XUi/XUiLogin/XUiSetAccount.lua new file mode 100644 index 00000000..87fb395c --- /dev/null +++ b/Resources/Scripts/XUi/XUiLogin/XUiSetAccount.lua @@ -0,0 +1,100 @@ +--- +--- Generated by EmmyLua(https://github.com/EmmyLua) +--- Created by admin. +--- DateTime: 2020/7/23 17:18 +--- + +local this = XLuaUiManager.Register(XLuaUi, "UiSetAccount") + +local LookStatus = { + Clear = 1, + Pass = 2, + Switch = 3 +} + +function this:OnAwake() + XTool.InitUiObject(self) + XUiHelper.RegisterClickEvent(self, self.BtnTanchuangClose, self.OnCloseSetAccount) + XUiHelper.RegisterClickEvent(self, self.BtnLook, self.OnLookPassword) + XUiHelper.RegisterClickEvent(self, self.BtnConfirm, self.OnConfirm) + XUiHelper.RegisterClickEvent(self, self.BtnConfirmChange, self.OnConfirm) +end + +function this:OnStart(loginCallback, cancelCallback) + self.LookStatus = LookStatus.Pass; + self.InFPassword.text = "" + self.ImgLook.gameObject:SetActiveEx(false) + self.ImgUnlook.gameObject:SetActiveEx(true) + self.BtnConfirm.gameObject:SetActiveEx(XUserManager.PasswordStatus == 0) + self.BtnConfirmChange.gameObject:SetActiveEx(XUserManager.PasswordStatus == 1) + self.InFID.text = XUserManager.UserId + self.ClearPassword = "" + self:SetLookStatus() + self.LoginCallback = loginCallback + self.CancelCallback = cancelCallback +end + +function this:CheckValid() + local str = self.InFPassword.text + if #str < 8 or #str > 20 then + return false + end + local numCount = 0 + local alphaCount = 0 + + for i = 1, #str do + local c = string.byte(str, i) + if c >= string.byte('a') and c <= string.byte('z') or c >= string.byte('A') and c <= string.byte('Z') then + alphaCount = alphaCount + 1 + elseif c >= string.byte('0') and c <= string.byte('9') then + numCount = numCount + 1 + end + end + + if numCount + alphaCount ~= #str then + return false + end + + if numCount == 0 or alphaCount == 0 then + return false + end + + return true +end + +function this:OnConfirm() + if self.LoginCallback then + if not self:CheckValid() then + XUiManager.TipError("半角英数字8~20文字以内で設定して下さい") + else + self.LoginCallback(self.InFID.text, self.InFPassword.text) + end + end + XLuaUiManager.Close("UiSetAccount") +end + + +function this:OnCloseSetAccount() + XLuaUiManager.Close("UiSetAccount") + if self.CancelCallback then + self.cancelCallback() + end +end + +function this:OnLookPassword() + self.LookStatus = LookStatus.Switch - self.LookStatus + self:SetLookStatus() +end + +function this:SetLookStatus() + if self.LookStatus == LookStatus.Clear then + self.InFPassword.contentType = CS.UnityEngine.UI.InputField.ContentType.Standard + else + self.InFPassword.contentType = CS.UnityEngine.UI.InputField.ContentType.Password + end + self.ImgLook.gameObject:SetActiveEx(self.LookStatus == LookStatus.Clear) + self.ImgUnlook.gameObject:SetActiveEx(self.LookStatus == LookStatus.Pass) + self.ClearPassword = self.InFPassword.text + self.InFPassword.text = "" + self.InFPassword.text = self.ClearPassword +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiLoginNotice/XUiLoginNotice.lua b/Resources/Scripts/XUi/XUiLoginNotice/XUiLoginNotice.lua new file mode 100644 index 00000000..17453931 --- /dev/null +++ b/Resources/Scripts/XUi/XUiLoginNotice/XUiLoginNotice.lua @@ -0,0 +1,125 @@ +local XUiLoginNotice = XLuaUiManager.Register(XLuaUi, "UiLoginNotice") + +function XUiLoginNotice:OnAwake() + self:InitAutoScript() +end + + +function XUiLoginNotice:OnStart(loginNotice) + if XLuaUiManager.IsUiShow("UiLoginAgreement") then + XLuaUiManager.Close("UiLoginAgreement") + end + + if not loginNotice or not loginNotice.HtmlUrl then + return + end + + if loginNotice.isFullUrl then + self:SendWebRequestForCustom(loginNotice) + else + self:SendWebRequestForLogin(loginNotice) + end + + self.TxtTitle.text = loginNotice.Title +end + +function XUiLoginNotice:SendWebRequestForLogin(loginNotice) + local request = CS.XUriPrefixRequest.Get(loginNotice.HtmlUrl) + + CS.XRecord.Record("24030", "LoginNoticeRequestStart") + CS.XTool.WaitCoroutine(request:SendWebRequest(), function() + if request.isNetworkError or request.isHttpError then + local msgTab = {} + msgTab.error = request.error + CS.XRecord.Record(msgTab, "24001", "LoginNoticeError") + return + elseif not request.downloadHandler then + local msgTab = {} + msgTab.error = "request.downloadHandler is nil" + CS.XRecord.Record(msgTab, "24002", "LoginNoticeError") + return + end + + self:LoadByHtml(request, loginNotice) + end) +end + +function XUiLoginNotice:SendWebRequestForCustom(loginNotice) + local request = CS.XUriPrefixRequest.Get(loginNotice.HtmlUrl) + + CS.XTool.WaitCoroutine(request:SendWebRequest(loginNotice.HtmlUrl), function() + self:LoadByHtml(request, loginNotice) + end) +end + +function XUiLoginNotice:LoadByHtml(request, loginNotice) + if request.isNetworkError or request.isHttpError or not request.downloadHandler then + return + end + + if CS.UnityEngine.Application.platform == CS.UnityEngine.RuntimePlatform.WindowsEditor or + CS.UnityEngine.Application.platform == CS.UnityEngine.RuntimePlatform.WindowsPlayer then + --PC上,直接加载网页 + self.PCPanelWebView.gameObject:SetActiveEx(true); + CS.XWebView.PCLoadHTML(self.PCPanelWebView.gameObject, request.downloadHandler.text) + else + -- 手机上暂时使用旧方法,将HTML文本显示上去 + --此WEB VIEW仅会在手机平台上显示 + self.PCPanelWebView.gameObject:SetActiveEx(false) + local html = request.downloadHandler.text + CS.XWebView.LoadByHtml(self.PanelWebView.gameObject, html) + end + + -- --此WEB VIEW仅会在手机平台上显示 + -- local html = request.downloadHandler.text + -- CS.XWebView.LoadByHtml(self.PanelWebView.gameObject, html) +end + + +function XUiLoginNotice:OnEnable() +end + + +function XUiLoginNotice:OnDisable() +end + + +function XUiLoginNotice:OnDestroy() +end + + +function XUiLoginNotice:OnGetEvents() + return {XEventId.EVENT_UIDIALOG_VIEW_ENABLE} +end + + +function XUiLoginNotice:OnNotify(evt) + if evt == XEventId.EVENT_UIDIALOG_VIEW_ENABLE then + self:Close() + end +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiLoginNotice:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiLoginNotice:AutoInitUi() + self.PanelWebView = self.Transform:Find("Animator/SafeAreaContentPane/PanelWebView") + self.PCPanelWebView = self.Transform:Find("Animator/SafeAreaContentPane/PCPanelWebView") + self.TxtTitle = self.Transform:Find("Animator/SafeAreaContentPane/TxtTitle"):GetComponent("Text") + self.BtnClose = self.Transform:Find("Animator/SafeAreaContentPane/BtnClose"):GetComponent("Button") + self.TxtClose = self.Transform:Find("Animator/SafeAreaContentPane/BtnClose/TxtClose"):GetComponent("Text") +end + +function XUiLoginNotice:AutoAddListener() + self:RegisterClickEvent(self.BtnClose, self.OnBtnCloseClick) +end +-- auto + +function XUiLoginNotice:OnBtnCloseClick() + self:Close() + XEventManager.DispatchEvent(XEventId.EVENT_WHEN_CLOSE_LOGIN_NOTICE) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiLoginVerification/XUiLoginVerification.lua b/Resources/Scripts/XUi/XUiLoginVerification/XUiLoginVerification.lua new file mode 100644 index 00000000..91bfa461 --- /dev/null +++ b/Resources/Scripts/XUi/XUiLoginVerification/XUiLoginVerification.lua @@ -0,0 +1,143 @@ +local XUiLoginVerification = XLuaUiManager.Register(XLuaUi, "UiLoginVerification") + +local SelectionSerial = {'A','B','C','D','E','F'} +local SplitChar = CsXTextManagerGetText("LoginUserAgreeItemAnd") +--local LimitedLoginQuizState = { +-- UnAnswered = 0, +-- Correct = 1, +-- InCorrect = 2, +--} + +function XUiLoginVerification:OnAwake() + self:AutoAddListener() + self:InitUiView() + self.GridOptionNoImageList = {} + self.GridOptionList = {} +end + +function XUiLoginVerification:OnStart(quizList) + self.QuizList = quizList + self.QuizIndex = 1 + self:Refresh() +end + +function XUiLoginVerification:OnEnable() +end + +function XUiLoginVerification:AutoAddListener() + self:RegisterClickEvent(self.BtnClose, self.OnBtnCloseClick) + self.BtnConfirm.CallBack = function() self:OnBtnConfirmClick() end +end + +function XUiLoginVerification:InitUiView() + self.TxtTip.text = XUiHelper.ReadTextWithNewLine("LoginLimitTip") +end + +function XUiLoginVerification:Refresh() + self.LastTime = XTime.GetServerNowTimestamp() + local quiz = self.QuizList[self.QuizIndex] + --while quiz and quiz.State == LimitedLoginQuizState.Correct do + -- self.QuizIndex = self.QuizIndex + 1 + -- quiz = self.QuizList[self.QuizIndex] + --end + + if not quiz then + self:Close() + return + end + + self.TxtNo.text = self.QuizIndex .. SplitChar + self.TxtQuestion.text = quiz.Title + self.TxtProgress.text = CsXTextManagerGetText("LoginLimitProgress", self.QuizIndex, #self.QuizList) + local noImage = string.IsNilOrEmpty(quiz.ImagePath) + self.PanelOptionNoImage.gameObject:SetActiveEx(noImage) + self.PanelOptionWithImage.gameObject:SetActiveEx(not noImage) + + self:MessUpOptions(quiz.Answers) + if noImage then + self:ShowOption(self.PanelOptionNoImage, self.GridOptionNoImageList) + else + self.RImgIcon:SetRawImage(quiz.ImagePath) + self:ShowOption(self.PanelOption, self.GridOptionList) + end +end + +function XUiLoginVerification:MessUpOptions(answers) + self.SelectIndex = nil + self.OptionList = {} + for i, v in ipairs(answers) do + self.OptionList[i] = {Index = i, Content = v} + end + + XTool.RandomBreakTableOrder(self.OptionList) +end + +function XUiLoginVerification:ShowOption(panel, gridList) + local gridOption = panel:Find("GridOption") + local btnList = {} + for i, v in ipairs(self.OptionList) do + local item = gridList[i] + if not item then + item = CS.UnityEngine.GameObject.Instantiate(gridOption, panel) + gridList[i] = item + end + item:Find("TxtOption"):GetComponent("Text").text = SelectionSerial[i] .. SplitChar .. v.Content + btnList[i] = item:Find("BtnOption"):GetComponent("XUiButton") + btnList[i]:SetButtonState(XUiButtonState.Normal) + item.gameObject:SetActiveEx(true) + end + + for i = #self.OptionList + 1, #gridList do + gridList[i].gameObject:SetActiveEx(false) + end + gridOption.gameObject:SetActiveEx(false) + + self.BtnGroup:Init(btnList, function(index) self:OnSelectOption(index) end) +end + +function XUiLoginVerification:OnSelectOption(index) + self.SelectIndex = index +end + +function XUiLoginVerification:OnAnswerRight() + if self.QuizIndex >= #self.QuizList then + XUiManager.TipText("LoginLimitPass") + self:Close() + XScheduleManager.ScheduleOnce(function() + XLoginManager.ClearLimitLogin() + end, 1500) + else + XUiManager.TipText("LoginLimitRightAnswer") + self.QuizIndex = self.QuizIndex + 1 + self:Refresh() + end +end + +function XUiLoginVerification:OnAnswerWrong() + XUiManager.TipText("LoginLimitWrongAnswer") + XScheduleManager.ScheduleOnce(function() + self:Close() + XLoginManager.DoDisconnect() + end, 1500) +end + +-- auto +function XUiLoginVerification:OnBtnCloseClick() + self:Close() +end + +function XUiLoginVerification:OnBtnConfirmClick() + if not self.SelectIndex then + XUiManager.TipText("LoginLimitNoSelection") + return + end + + local nowTime = XTime.GetServerNowTimestamp() + XLoginManager.SendLoginVerify(self.QuizIndex, self.OptionList[self.SelectIndex].Index, nowTime - self.LastTime,function(result) + if result == true then + self:OnAnswerRight() + else + self:OnAnswerWrong() + end + end) +end diff --git a/Resources/Scripts/XUi/XUiLotto/XUiGridTicket.lua b/Resources/Scripts/XUi/XUiLotto/XUiGridTicket.lua new file mode 100644 index 00000000..2d77c799 --- /dev/null +++ b/Resources/Scripts/XUi/XUiLotto/XUiGridTicket.lua @@ -0,0 +1,65 @@ +local XUiGridTicket = XClass(nil, "XUiGridTicket") + +function XUiGridTicket:Ctor(ui, data, buyCb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.TicketData = data + self.BuyCb = buyCb + XTool.InitUiObject(self) + self:SetButtonCallBack() + self:ShowPanel() +end + +function XUiGridTicket:SetButtonCallBack() + if self.BtnBuy then + self.BtnBuy.CallBack = function() + self:OnBtnBuyClick() + end + end + if self.ImgBtn then + self.ImgBtn.CallBack = function() + self:OnImgBtnClick() + end + end +end + +function XUiGridTicket:ShowPanel() + if self.Sale then + self.Sale.gameObject:SetActiveEx(self.TicketData.Sale) + end + + if self.SaleText then + self.SaleText.text = self.TicketData.Sale + end + + if self.CostNum then + self.CostNum.text = self.TicketData.ItemCount + end + + if self.CurNum then + self.CurNum.text = XDataCenter.ItemManager.GetItem(self.TicketData.ItemId).Count + end + + if self.CardImg then + local goods = XGoodsCommonManager.GetGoodsShowParamsByTemplateId(self.TicketData.ItemId) + local icon = self.TicketData.ItemImg or goods.BigIcon or goods.Icon + self.CardImg:SetRawImage(icon) + end +end + +function XUiGridTicket:OnBtnBuyClick() + if self.BuyCb then + self.BuyCb() + end +end + +function XUiGridTicket:OnImgBtnClick() + -- if self.TicketData.ItemId == 5 then -- 英文服有虹卡 + -- XLuaUiManager.Open("UiPurchase", XPurchaseConfigs.TabsConfig.LB, nil, 1) + -- return + -- end + local data = XDataCenter.ItemManager.GetItem(self.TicketData.ItemId) + XLuaUiManager.Open("UiTip", data) +end + +return XUiGridTicket \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiLotto/XUiLotto.lua b/Resources/Scripts/XUi/XUiLotto/XUiLotto.lua new file mode 100644 index 00000000..2b33aa87 --- /dev/null +++ b/Resources/Scripts/XUi/XUiLotto/XUiLotto.lua @@ -0,0 +1,170 @@ +local XUiLotto = XLuaUiManager.Register(XLuaUi, "UiLotto") +local XUiPanelLottoPreview = require("XUi/XUiLotto/XUiPanelLottoPreview") +local characterRecord = require("XUi/XUiDraw/XUiDrawTools/XUiDrawCharacterRecord") +local CSTextManagerGetText = CS.XTextManager.GetText +function XUiLotto:OnStart(groupData, closeCb, backGround) + self.LottoGroupData = groupData + self.CloseCb = closeCb + self.BackGroundPath = backGround + self.TxtTitle.text = groupData:GetName() + self.IsCanDraw = true + XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self.PanelLottoPreview = XUiPanelLottoPreview.New(self.PanelPreview, self, groupData) + self:SetBtnCallBack() + self:InitDrawBackGround(self.BackGroundPath) + +end + +function XUiLotto:OnDestroy() + if self.CloseCb then + self.CloseCb() + end +end + +function XUiLotto:OnEnable() + XLuaUiManager.SetMask(true) + self:PlayAnimation("DrawBegan", function() + XLuaUiManager.SetMask(false) + self:ShowExtraReward() + end) + self:UpdateAllPanel() + self.PlayableDirector = self.BackGround:GetComponent("PlayableDirector") + self.PlayableDirector:Stop() + self.PlayableDirector:Evaluate() +end + + +function XUiLotto:SetBtnCallBack() + self.BtnBack.CallBack = function() + self:OnBtnBackClick() + end + self.BtnMainUi.CallBack = function() + self:OnBtnMainUiClick() + end + self.PanelUseItem:GetObject("BtnUseItem").CallBack = function() + self:OnBtnUseItemClick() + end + self.BtnDrawRule.CallBack = function() + self:OnBtnDrawRuleClick() + end + self.PanelDrawButtons:GetObject("BtnDraw").CallBack = function() + self:OnBtnDrawClick() + end +end + +function XUiLotto:OnBtnBackClick() + self:Close() +end + +function XUiLotto:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiLotto:OnBtnUseItemClick() + local drawData = self.LottoGroupData:GetDrawData() + local data = XDataCenter.ItemManager.GetItem(drawData:GetConsumeId()) + XLuaUiManager.Open("UiTip", data) +end + +function XUiLotto:OnBtnDrawRuleClick() + XLuaUiManager.Open("UiLottoLog",self.LottoGroupData) +end + +function XUiLotto:OnBtnDrawClick() + self:OnDraw() +end + +function XUiLotto:InitDrawBackGround(backgroundName) + local root = self.UiSceneInfo.Transform + self.BackGround = root:FindTransform("GroupBase"):LoadPrefab(backgroundName) + CS.XShadowHelper.AddShadow(self.BackGround:FindTransform("BoxModeParent").gameObject) +end + +function XUiLotto:UpdateAllPanel() + self:UpdatePanelPreview() + self:UpdatePanelDrawButtons() + self:UpdatePanelUseItem() +end + +function XUiLotto:UpdatePanelPreview() + self.PanelLottoPreview:UpdatePanel() +end + +function XUiLotto:UpdatePanelDrawButtons() + local drawData = self.LottoGroupData:GetDrawData() + local icon = XDataCenter.ItemManager.GetItemBigIcon(drawData:GetConsumeId()) + self.PanelDrawButtons:GetObject("BtnDraw").gameObject:SetActiveEx(not drawData:IsLottoCountFinish()) + self.PanelDrawButtons:GetObject("ImgUseItemIcon"):SetRawImage(icon) + self.PanelDrawButtons:GetObject("TxtUseItemCount").text = drawData:GetConsumeCount() > 0 and + drawData:GetConsumeCount() or CSTextManagerGetText("LottoDrawFreeText") +end + +function XUiLotto:UpdatePanelUseItem() + local drawData = self.LottoGroupData:GetDrawData() + local icon = XDataCenter.ItemManager.GetItemBigIcon(drawData:GetConsumeId()) + + self.PanelUseItem:GetObject("ImgUseItemIcon"):SetRawImage(icon) + self.PanelUseItem:GetObject("TxtUseItemCount").text = XDataCenter.ItemManager.GetItem(drawData:GetConsumeId()).Count +end + +function XUiLotto:ShowExtraReward(cb) + if self.ExtraRewardList and next(self.ExtraRewardList) then + XUiManager.OpenUiObtain(self.ExtraRewardList, nil, function () + if cb then cb() end + end) + self.ExtraRewardList = nil + else + if cb then cb() end + end +end + +function XUiLotto:OnDraw() + if XDataCenter.EquipManager.CheckBoxOverLimitOfDraw() then + return + end + local drawData = self.LottoGroupData:GetDrawData() + local curItemCount = XDataCenter.ItemManager.GetItem(drawData:GetConsumeId()).Count + local needItemCount = drawData:GetConsumeCount() + if needItemCount > curItemCount then + XUiManager.TipMsg(CSTextManagerGetText("DrawNotEnoughSkipText")) + XLuaUiManager.Open("UiLottoTanchuang", drawData, function () + self:UpdateAllPanel() + end) + return + end + + if self.IsCanDraw then + self.IsCanDraw = false + characterRecord.Record() + local drawData = self.LottoGroupData:GetDrawData() + XDataCenter.LottoManager.DoLotto(drawData:GetId(), function(rewardList, extraRewardList) + XDataCenter.AntiAddictionManager.BeginDrawCardAction() + self.ExtraRewardList = extraRewardList + self:HideUiView(rewardList) + end, function () + self.IsCanDraw = true + end) + end +end + +function XUiLotto:HideUiView(rewardList) + self.OpenSound = CS.XAudioManager.PlaySound(XSoundManager.UiBasicsMusic.UiDrawCard_BoxOpen) + XLuaUiManager.SetMask(true) + self:PlayAnimation("DrawRetract", function() + if rewardList and next(rewardList) then + self.IsCanDraw = true + self:PushShow(rewardList) + end + XLuaUiManager.SetMask(false) + end) +end + +function XUiLotto:PushShow(rewardList) + self:OpenChildUi("UiLottoShow") + self:FindChildUiObj("UiLottoShow"):SetData(rewardList, function() + if self.OpenSound then + self.OpenSound:Stop() + end + XLuaUiManager.Open("UiDrawResult", nil, rewardList, function() end) + end, self.BackGround) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiLotto/XUiLottoLog.lua b/Resources/Scripts/XUi/XUiLotto/XUiLottoLog.lua new file mode 100644 index 00000000..36f20e68 --- /dev/null +++ b/Resources/Scripts/XUi/XUiLotto/XUiLottoLog.lua @@ -0,0 +1,242 @@ +local XUiLottoLog = XLuaUiManager.Register(XLuaUi, "UiLottoLog") +local BtnMaxCount = 3 +local TypeText = {} +local IsInit = {} +local AnimeNames = {} +local InitFunctionList = {} +local TimestampToGameDateTimeString = XTime.TimestampToGameDateTimeString +local DrawLogLimit = CS.XGame.ClientConfig:GetInt("DrawLogLimit") +function XUiLottoLog:OnStart(data, selectIndex) + self.LottoGroupData = data + self.SelectIndex = selectIndex or 1 + self.BtnTanchuangClose.CallBack = function() + self:OnBtnTanchuangClose() + end + self.BtnClose.CallBack = function() + self:OnBtnTanchuangClose() + end + InitFunctionList = { + function() + self:InitBaseRulePanel() + end, + function() + self:InitDrawPreview() + end, + function() + self:InitDrawLogListPanel() + end, + } + IsInit = {false, false, false, false } + AnimeNames = { "QieHuanOne", "QieHuanTwo", "QieHuanThree", "QieHuanFour" } + self:SetTypeText() + self:InitBtnTab() +end + +function XUiLottoLog:SetTypeText() + TypeText[XArrangeConfigs.Types.Item] = CS.XTextManager.GetText("TypeItem") + TypeText[XArrangeConfigs.Types.Character] = function(templateId) + local characterType = XCharacterConfigs.GetCharacterType(templateId) + if characterType == XCharacterConfigs.CharacterType.Normal then + return CS.XTextManager.GetText("TypeCharacter") + elseif characterType == XCharacterConfigs.CharacterType.Isomer then + return CS.XTextManager.GetText("TypeIsomer") + end + end + TypeText[XArrangeConfigs.Types.Weapon] = CS.XTextManager.GetText("TypeWeapon") + TypeText[XArrangeConfigs.Types.Wafer] = CS.XTextManager.GetText("TypeWafer") + TypeText[XArrangeConfigs.Types.Fashion] = CS.XTextManager.GetText("TypeFashion") + TypeText[XArrangeConfigs.Types.Furniture] = CS.XTextManager.GetText("TypeFurniture") + TypeText[XArrangeConfigs.Types.HeadPortrait] = CS.XTextManager.GetText("TypeHeadPortrait") + TypeText[XArrangeConfigs.Types.ChatEmoji] = CS.XTextManager.GetText("TypeChatEmoji") +end + +function XUiLottoLog:InitDrawLogListPanel() + local drawData = self.LottoGroupData:GetDrawData() + local lottoLogList = drawData:GetLottoRecordList() + local name + local quality + local fromName + local time + + local PanelObj = {} + PanelObj.Transform = self.Panel3.transform + XTool.InitUiObject(PanelObj) + + PanelObj.GridLogHigh.gameObject:SetActiveEx(false) + PanelObj.GridLogMid.gameObject:SetActiveEx(false) + PanelObj.GridLogLow.gameObject:SetActiveEx(false) + PanelObj.TxtLogCount.text = CS.XTextManager.GetText("DrawLogCpunt", DrawLogLimit) + + local bottomText = CS.XTextManager.GetText("NewDrawMainBottomText") + PanelObj.TxtEnsureCount.text = string.format("%s %s/%s", bottomText, drawData:GetCurRewardCount(), drawData:GetMaxRewardCount()) + + for _, v in pairs(lottoLogList) do + if v.RewardGoods.ConvertFrom ~= 0 then + local fromGoods = XGoodsCommonManager.GetGoodsShowParamsByTemplateId(v.RewardGoods.ConvertFrom) + local Goods = XGoodsCommonManager.GetGoodsShowParamsByTemplateId(v.RewardGoods.TemplateId) + quality = fromGoods.Quality + quality = quality or 1 + fromName = fromGoods.Name + if fromGoods.TradeName then + fromName = string.format("%s.%s", fromName,fromGoods.TradeName) + end + name = Goods.Name + time = TimestampToGameDateTimeString(v.LottoTime) + self:SetLogData(PanelObj, fromName, v.RewardGoods.ConvertFrom, name, time, quality) + else + local Goods = XGoodsCommonManager.GetGoodsShowParamsByTemplateId(v.RewardGoods.TemplateId) + quality = Goods.Quality + quality = quality or 1 + name = Goods.Name + if Goods.TradeName then + name = string.format("%s.%s", name,Goods.TradeName) + end + time = TimestampToGameDateTimeString(v.LottoTime) + self:SetLogData(PanelObj, name, v.RewardGoods.TemplateId, nil, time, quality) + end + end +end + +function XUiLottoLog:SetLogData(obj, name, templateId, from, time, quality) + local itemType = XArrangeConfigs.GetType(templateId) + local go + if itemType == XArrangeConfigs.Types.Character then + if quality >= XItemConfigs.Quality.Three then + go = CS.UnityEngine.Object.Instantiate(obj.GridLogHigh, obj.PanelContent) + else + go = CS.UnityEngine.Object.Instantiate(obj.GridLogMid, obj.PanelContent) + end + else + if quality == XItemConfigs.Quality.Six then + go = CS.UnityEngine.Object.Instantiate(obj.GridLogHigh, obj.PanelContent) + elseif quality == XItemConfigs.Quality.Five then + go = CS.UnityEngine.Object.Instantiate(obj.GridLogMid, obj.PanelContent) + else + go = CS.UnityEngine.Object.Instantiate(obj.GridLogLow, obj.PanelContent) + end + end + + local tmpObj = {} + tmpObj.Transform = go.transform + tmpObj.GameObject = go.gameObject + XTool.InitUiObject(tmpObj) + tmpObj.TxtName.text = name + + if type(TypeText[itemType]) == "function" then + tmpObj.TxtType.text = TypeText[itemType](templateId) + else + tmpObj.TxtType.text = TypeText[itemType] + end + + if not from then + tmpObj.TxtTo.gameObject:SetActiveEx(false) + else + tmpObj.TxtTo.text = CS.XTextManager.GetText("ToOtherThing", from) + end + tmpObj.TxtTime.text = time + tmpObj.GameObject:SetActiveEx(true) +end + +function XUiLottoLog:InitBaseRulePanel() + local baseRules = self.LottoGroupData:GetBaseRulesList() + local baseRuleTitles = self.LottoGroupData:GetBaseRuleTitleList() + self:SetRuleData(baseRules, baseRuleTitles, self.Panel1) +end + +function XUiLottoLog:SetRuleData(rules, ruleTitles, panel) + local PanelObj = {} + PanelObj.Transform = panel.transform + XTool.InitUiObject(PanelObj) + PanelObj.PanelTxt.gameObject:SetActiveEx(false) + for k, _ in pairs(rules) do + local go = CS.UnityEngine.Object.Instantiate(PanelObj.PanelTxt, PanelObj.PanelContent) + local tmpObj = {} + tmpObj.Transform = go.transform + tmpObj.GameObject = go.gameObject + XTool.InitUiObject(tmpObj) + tmpObj.TxtRuleTitle.text = ruleTitles[k] + tmpObj.TxtRule.text = rules[k] + tmpObj.GameObject:SetActiveEx(true) + end +end + +function XUiLottoLog:InitDrawPreview() + local PanelObj = {} + PanelObj.Transform = self.Panel2.transform + XTool.InitUiObject(PanelObj) + + PanelObj.RewardSp.gameObject:SetActiveEx(false) + PanelObj.RewardNor.gameObject:SetActiveEx(false) + + local drawData = self.LottoGroupData:GetDrawData() + local rewardDataList = drawData:GetRewardDataList() + + if not rewardDataList then + return + end + for i = 1, #rewardDataList do + local obj + if rewardDataList[i]:GetRareLevel() == XLottoConfigs.RareLevel.One then + obj = CS.UnityEngine.Object.Instantiate(PanelObj.RewardSp, PanelObj.Content) + else + obj = CS.UnityEngine.Object.Instantiate(PanelObj.RewardNor, PanelObj.Content) + end + + self:InitDrawProb(obj,rewardDataList[i]) + + end + XScheduleManager.ScheduleOnce(function() + CS.UnityEngine.UI.LayoutRebuilder.ForceRebuildLayoutImmediate(PanelObj.Content); + end, 0) +end + +function XUiLottoLog:InitDrawProb(obj, rewardData) + local rewardObj = {} + rewardObj.Transform = obj.transform + rewardObj.GameObject = obj.gameObject + XTool.InitUiObject(rewardObj) + rewardObj.GameObject:SetActiveEx(true) + + local itemObj = rewardObj.RewardItem:GetObject("GridCostItem") + local item = XUiGridCommon.New(self, itemObj) + local tmpData = {TemplateId = rewardData:GetTemplateId(), Count = rewardData:GetCount()} + item:Refresh(tmpData) + + rewardObj.RewardProb.gameObject:SetActiveEx(false) + local probShowList = rewardData:GetProbShowList() + for index = 1, #probShowList do + local probObj = CS.UnityEngine.Object.Instantiate(rewardObj.RewardProb, rewardObj.PanelDropTitleContent) + probObj.gameObject:SetActiveEx(true) + local prob = probObj.transform:GetComponent("UiObject") + prob:GetObject("TxtCount").text = probShowList[index] + end +end + +function XUiLottoLog:InitBtnTab() + self.TabGroup = self.TabGroup or {} + for i = 1, BtnMaxCount do + if not self.TabGroup[i] then + self.TabGroup[i] = self[string.format("BtnTab%d", i)] + end + end + self.PanelTabTc:Init(self.TabGroup, function(tabIndex) self:OnSelectedTog(tabIndex) end) + self.PanelTabTc:SelectIndex(self.SelectIndex) +end + +function XUiLottoLog:OnBtnTanchuangClose() + self:Close() +end + +function XUiLottoLog:OnSelectedTog(index) + for i = 1, BtnMaxCount do + self[string.format("Panel%d", i)].gameObject:SetActiveEx(false) + end + + self[string.format("Panel%d", index)].gameObject:SetActiveEx(true) + if not IsInit[index] then + InitFunctionList[index]() + IsInit[index] = true + end + + self:PlayAnimation(AnimeNames[index]) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiLotto/XUiLottoShow.lua b/Resources/Scripts/XUi/XUiLotto/XUiLottoShow.lua new file mode 100644 index 00000000..e4186e22 --- /dev/null +++ b/Resources/Scripts/XUi/XUiLotto/XUiLottoShow.lua @@ -0,0 +1,495 @@ +local XUiLottoShow = XLuaUiManager.Register(XLuaUi, "UiLottoShow") +-- local drawShowWeapon = require("XUi/XUiDraw/XUiDrawTools/XUiDrawWeapon") +local drawShowEffect = require("XUi/XUiDraw/XUiDrawTools/XUiDrawShowEffect") +local drawScene = require("XUi/XUiDraw/XUiDrawTools/XUiDrawScene") + +function XUiLottoShow:OnAwake() + self:InitAutoScript() +end + +function XUiLottoShow:OnStart() + self.Animation = self.Transform:GetComponent("Animation") + self:InitImgRewards() +end + +function XUiLottoShow:SetData(rewardList, resultCb, backGround) + self.BackGround = backGround + self.RewardList = rewardList + self.ResultCb = resultCb + + self:ResetState() + self:InitTools() + self.ShowIndex = 1 + self.IsOpening = false + self.CurLight = {} + self.PlayBoxAnim = false + self.BtnClick.gameObject:SetActiveEx(false) + self:InitDrawBackGround() + XUiHelper.SetDelayPopupFirstGet(true) +end + +function XUiLottoShow:OnDisable() + self:HideAllEffect() + XUiHelper.SetDelayPopupFirstGet() +end + +function XUiLottoShow:Update() + if self.PlayBoxAnim then + if self.PlayableDirector.time >= self.PlayableDirector.duration - 0.1 then + self:BoxAnimEnd() + end + end +end + +function XUiLottoShow:InitImgRewards() + self.ImgRewards = {} + self.ImgRewards[XArrangeConfigs.Types.Character] = self.ImgCharacter + self.ImgRewards[XArrangeConfigs.Types.Fashion] = self.ImgItem + self.ImgRewards[XArrangeConfigs.Types.Item] = self.ImgItem + self.ImgRewards[XArrangeConfigs.Types.Wafer] = self.ImgWafer + self.ImgRewards[XArrangeConfigs.Types.Weapon] = self.ImgEquip + self.ImgRewards[XArrangeConfigs.Types.Furniture] = self.ImgItem + self.ImgRewards[XArrangeConfigs.Types.HeadPortrait] = self.ImgItem + self.ImgRewards[XArrangeConfigs.Types.ChatEmoji] = self.ImgItem +end + +function XUiLottoShow:ResetState() + self.ImgCharacter.gameObject:SetActiveEx(false) + self.ImgItem.gameObject:SetActiveEx(false) + self.ImgWafer.gameObject:SetActiveEx(false) + self.ImgEquip.gameObject:SetActiveEx(false) + self.ImageItemPack.gameObject:SetActiveEx(false) + self.ImageWeaponPack.gameObject:SetActiveEx(false) + self.ImageCharacterPack.gameObject:SetActiveEx(false) + self.ImageWaferPack.gameObject:SetActiveEx(false) +end + +function XUiLottoShow:InitTools() + --drawScene.AddObject(self.PanelWeapon, drawScene.Types.WEAPON) + --drawShowWeapon.SetNode(self.PanelAnim, self.PanelWeapon) + drawScene.SetActive(drawScene.Types.BOX, false) + drawScene.SetActive(drawScene.Types.BG, false) + XRTextureManager.SetTextureCache(self.RImgDrawCardShow) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiLottoShow:InitAutoScript() + self:AutoAddListener() +end + +function XUiLottoShow:AutoAddListener() + self:RegisterClickEvent(self.BtnClick, self.OnBtnClickClick) + self:RegisterClickEvent(self.BtnSkip, self.OnBtnSkipClick) +end +-- auto +function XUiLottoShow:OnBtnClickClick() + if self.IsOpening then + self:ShowResult() + else + self:HideAllEffect() + self:NextPack() + end +end + +function XUiLottoShow:OnBtnSkipClick() + self:ClearLastModel() + self:PlayEnd() +end + +function XUiLottoShow:ShowWeapon() + drawScene.SetActive(drawScene.Types.WEAPON, true) +end + +function XUiLottoShow:ShowResult() + XUiHelper.StopAnimation(false) + + local id = self:GetRewardId(self.ShowIndex) + local Type = self:GetRewardType(id) + local quality = self:GetQuality(id, Type) + + local showTable = XDataCenter.DrawManager.GetDrawShow(Type) + local skipEffect = XDrawConfigs.GetSkipEffect(showTable.DrawEffectGroupId[quality]) + self.CurPanelOpenUpEffect = self.PanelOpenUp:LoadPrefab(skipEffect) + self.CurPanelOpenUpEffect.gameObject.name = skipEffect + self.CurPanelOpenUpEffect.gameObject:SetActiveEx(true) + + self.Plane.gameObject:SetActiveEx(false) + + self.IsOpening = false + self.Animation:Play(showTable.UiResultAnim) + -- if Type == XArrangeConfigs.Types.Weapon then + -- drawShowWeapon.PlayResultAnim() + -- end + + self.ShowIndex = self.ShowIndex + 1 +end + +function XUiLottoShow:ClearLastModel() + if self.LastCharacterModel then + self.LastCharacterModel.gameObject:SetActiveEx(false) + self.LastCharacterModel = nil + end + + if self.LastWeaponModel then + self.LastWeaponModel.gameObject:SetActiveEx(false) + self.LastWeaponModel = nil + end +end + +function XUiLottoShow:NextPack() + self.BtnClick.gameObject:SetActiveEx(false) + self:ClearLastModel() + if self.ShowIndex > #self.RewardList then + self:PlayEnd() + return + end + + if self.CvInfo then + self.CvInfo:Stop() + self.CvInfo = nil + end + self.Plane.gameObject:SetActiveEx(false) + local reward = self.RewardList[self.ShowIndex] + local id = self:GetRewardId(self.ShowIndex) + local Type = self:GetRewardType(id) + local quality = self:GetQuality(id, Type) + + local soundType = XSoundManager.UiBasicsMusic.UiDrawCard_Type.Normal + + if quality then + if quality == 5 then + soundType = XSoundManager.UiBasicsMusic.UiDrawCard_Type.FiveStar + elseif quality == 6 then + soundType = XSoundManager.UiBasicsMusic.UiDrawCard_Type.SixStar + end + end + + local icon + if Type == XArrangeConfigs.Types.Weapon or + Type == XArrangeConfigs.Types.Furniture or + Type == XArrangeConfigs.Types.HeadPortrait or + XDataCenter.ItemManager.IsWeaponFashion(id)then + + local goodsShowParams = XGoodsCommonManager.GetGoodsShowParamsByTemplateId(id) + icon = goodsShowParams.BigIcon + + if Type ~= XArrangeConfigs.Types.Weapon and not XDataCenter.ItemManager.IsWeaponFashion(id) then + self.ImgRewards[Type]:SetRawImage(icon) + self.BtnClick.gameObject:SetActiveEx(true) + end + else + if Type == XArrangeConfigs.Types.Character then + icon = XDataCenter.CharacterManager.GetCharHalfBodyImage(id) + if quality < 3 then + soundType = XSoundManager.UiBasicsMusic.UiDrawCard_Type.FiveStar + elseif quality > 2 then + soundType = XSoundManager.UiBasicsMusic.UiDrawCard_Type.SixStar + end + elseif Type == XArrangeConfigs.Types.Wafer then + icon = XDataCenter.EquipManager.GetEquipLiHuiPath(id) + elseif Type == XArrangeConfigs.Types.Item then + icon = XDataCenter.ItemManager.GetItemBigIcon(id) + elseif Type == XArrangeConfigs.Types.Fashion then + icon = XDataCenter.FashionManager.GetFashionIcon(id) + elseif Type == XArrangeConfigs.Types.ChatEmoji then + icon = XDataCenter.ChatManager.GetEmojiIcon(id) + end + + if Type ~= XArrangeConfigs.Types.Character and Type ~= XArrangeConfigs.Types.Fashion then + self.ImgRewards[Type]:SetRawImage(icon) + self.BtnClick.gameObject:SetActiveEx(true) + end + end + local curShowNum = self.ShowIndex + local showTable = XDataCenter.DrawManager.GetDrawShow(Type) + self.IsOpening = true + XUiHelper.StopAnimation(false) + XUiHelper.PlayAnimation(self, showTable.UiAnim, nil, function() + self.PanelCardShowOff.gameObject:SetActiveEx(true) + if self.GameObject.activeInHierarchy then + if curShowNum == self.ShowIndex then + local effect = XDrawConfigs.GetOpenUpEffect(showTable.DrawEffectGroupId[quality]) + self.CurPanelOpenUpEffect = self.PanelOpenUp.transform:Find(effect) + if self.CurPanelOpenUpEffect then + self.CurPanelOpenUpEffect.gameObject:SetActiveEx(true) + else + self.CurPanelOpenUpEffect = self.PanelOpenUp:LoadPrefab(effect) + self.CurPanelOpenUpEffect.gameObject.name = effect + self.CurPanelOpenUpEffect.gameObject:SetActiveEx(true) + end + end + if Type == XArrangeConfigs.Types.Character then + self:ShowCharacterModel(id, nil) + elseif Type == XArrangeConfigs.Types.Fashion then + self:ShowCharacterModel(nil, id) + elseif Type == XArrangeConfigs.Types.Weapon then + self:ShowWeaponModel(id) + elseif XDataCenter.ItemManager.IsWeaponFashion(id) then + self:ShowWeaponFashionModel(id) + end + XUiHelper.PlayAnimation(self, showTable.UiAnim .. "Item", nil, function() + if curShowNum == self.ShowIndex then + self.IsOpening = false + self.ShowIndex = self.ShowIndex + 1 + end + end) + end + + CS.XAudioManager.PlaySound(soundType.Show) + end) + + CS.XAudioManager.PlaySound(soundType.Start) + + local templeid = id + if XArrangeConfigs.Types.Furniture == reward.RewardType then + local cfg = XFurnitureConfigs.GetFurnitureReward(id) + if cfg and cfg.FurnitureId then + templeid = cfg.FurnitureId + end + end + self.TxtName.text = XTypeManager.GetNameById(templeid) + self.TxtType.text = showTable.TypeText + self.TxtQuality.text = showTable.QualityText[quality] + + --effect + self.PanelOpenUp.gameObject:SetActiveEx(true) + self.PanelOpenDown.gameObject:SetActiveEx(true) + + local effect = XDrawConfigs.GetOpenDownEffect(showTable.DrawEffectGroupId[quality]) + self.CurPanelOpenDownEffect = self.PanelOpenDown.transform:Find(effect) + if self.CurPanelOpenDownEffect then + self.CurPanelOpenDownEffect.gameObject:SetActiveEx(true) + else + self.CurPanelOpenDownEffect = self.PanelOpenDown:LoadPrefab(effect) + self.CurPanelOpenDownEffect.gameObject.name = effect + self.CurPanelOpenDownEffect.gameObject:SetActiveEx(true) + end + +end + +function XUiLottoShow:ShowWeaponFashionModel(templateId) + local fashionId = XDataCenter.ItemManager.GetWeaponFashionId(templateId) + local modelConfig = XDataCenter.WeaponFashionManager.GetWeaponModelCfg(fashionId, nil, self.Name) + if modelConfig then + XModelManager.LoadWeaponModel(modelConfig.ModelId, self.WeaponRoot, modelConfig.TransformConfig, self.Name, function(model) + model.gameObject:SetActiveEx(true) + self.LastWeaponModel = model + self.BtnClick.gameObject:SetActiveEx(true) + end, { gameObject = self.GameObject }) + end +end + +function XUiLottoShow:ShowWeaponModel(templateId) + local modelConfig = XDataCenter.EquipManager.GetWeaponModelCfg(templateId, self.Name, 0) + if modelConfig then + XModelManager.LoadWeaponModel(modelConfig.ModelId, self.WeaponRoot, modelConfig.TransformConfig, self.Name, function(model) + model.gameObject:SetActiveEx(true) + self.LastWeaponModel = model + self.BtnClick.gameObject:SetActiveEx(true) + end, { gameObject = self.GameObject }) + end +end + +function XUiLottoShow:ShowCharacterModel(templateId,fashtionId) + if not templateId and not fashtionId then + return + end + + if not self.InitRoleMode then + self.InitRoleMode = true + self.RoleModelPanel = XUiPanelRoleModel.New(self.CharacterRoot, self.Name, true, false, false) + end + + local curCharacterId = templateId or XDataCenter.FashionManager.GetCharacterId(fashtionId) + local curFashtionId = fashtionId or XCharacterConfigs.GetCharacterTemplate(curCharacterId).DefaultNpcFashtionId + XDataCenter.DisplayManager.UpdateRoleModel(self.RoleModelPanel, curCharacterId, nil, curFashtionId) + + self.RoleModelPanel:UpdateCharacterModel(curCharacterId, self.CharacterRoot, XModelManager.MODEL_UINAME.XUiDrawShow, function(model) + CS.XAudioManager.PlaySound(XSoundManager.UiBasicsMusic.UiDrawCard_Chouka_Name) + model.gameObject:SetActiveEx(true) + + local animeID = XDataCenter.DrawManager.GetDrawShowCharacter(curCharacterId).AnimeID + local voiceId = XDataCenter.DrawManager.GetDrawShowCharacter(curCharacterId).VoiceId + + if animeID then + self.RoleModelPanel:PlayAnima(animeID) + end + + if voiceId then + self.CvInfo = CS.XAudioManager.PlayCv(voiceId) + end + + self.LastCharacterModel = model + self.BtnClick.gameObject:SetActiveEx(true) + end, nil, curFashtionId) +end + +function XUiLottoShow:HideAllEffect() + if not XTool.UObjIsNil(self.PanelOpenUp) then + self.PanelOpenUp.gameObject:SetActiveEx(false) + end + if not XTool.UObjIsNil(self.PanelOpenDown) then + self.PanelOpenDown.gameObject:SetActiveEx(false) + end + if not XTool.UObjIsNil(self.PanelCardShowOff) then + self.PanelCardShowOff.gameObject:SetActiveEx(false) + end + if not XTool.UObjIsNil(self.CurPanelOpenUpEffect) then + self.CurPanelOpenUpEffect.gameObject:SetActiveEx(false) + end + if not XTool.UObjIsNil(self.CurPanelOpenDownEffect) then + self.CurPanelOpenDownEffect.gameObject:SetActiveEx(false) + end + if not XTool.UObjIsNil(self.CurPanelCardShowOffEffect) then + self.CurPanelCardShowOffEffect.gameObject:SetActiveEx(false) + end +end + +function XUiLottoShow:PlayEnd() + XUiHelper.StopAnimation() + self.Plane.gameObject:SetActiveEx(true) + self.BtnClick.gameObject:SetActiveEx(true) + drawScene.SetActive(drawScene.Types.BOX, true) + if self.CurLight.gameObject then + self.CurLight.gameObject:SetActiveEx(false) + end + if self.CurLightLock and not XTool.UObjIsNil(self.CurLightLock.gameObject) then + self.CurLightLock.gameObject:SetActiveEx(false) + end + if self.CvInfo then + self.CvInfo:Stop() + self.CvInfo = nil + end + self:Close() + self.ResultCb() +end + +function XUiLottoShow:OnDestroy() + drawScene.DestroyObject(drawScene.Types.EFFECT) + drawScene.DestroyObject(drawScene.Types.WEAPON) + drawScene.DestroyObject(drawScene.Types.SHOWBG) + drawShowEffect.Dispose() +end + +--wind +function XUiLottoShow:InitDrawBackGround() + self.TxtType.text = "" + self.TxtName.text = "" + self.TxtQuality.text = "" + self.PanelInfo.gameObject:GetComponent("CanvasGroup").alpha = 0 + + self:PlayBoxAnimStart() +end + +function XUiLottoShow:PlayBoxAnimStart() + self.PanelOpenUp = self.BackGround.transform:Find("ModelRoot/UiNearRoot/EffectRoot/PanelOpenUp") + self.PanelOpenDown = self.BackGround.transform:Find("ModelRoot/UiNearRoot/EffectRoot/PanelOpenDown") + self.PanelCardShowOff = self.BackGround.transform:Find("ModelRoot/UiNearRoot/EffectRoot/PanelCardShowOff") + self.WeaponRoot = self.BackGround.transform:Find("ModelRoot/UiNearRoot/WeaponRoot") + self.CharacterRoot = self.BackGround.transform:Find("ModelRoot/UiNearRoot/CharacterRoot") + self.Plane = self.BackGround.transform:Find("ModelRoot/UiFarRoot/Plane") + + local behaviour = self.GameObject:AddComponent(typeof(CS.XLuaBehaviour)) + if self.Update then + behaviour.LuaUpdate = function() self:Update() end + end + self.PlayableDirector = self.BackGround:GetComponent("PlayableDirector") + self.PlayableDirector:Play() + self.PlayBoxAnim = true + self.PanelBoxLight = self.BackGround.transform:Find("ModelRoot/UiNearRoot/PanelBox/PanelBoxLight") + self.PanelBoxLock = self.BackGround.transform:Find("ModelRoot/UiNearRoot/PanelBox/PanelBoxLock") + self.CurLight = self.PanelBoxLight:LoadPrefab(self:GetMaxQualityEffectName()) + self.CurLight.gameObject:SetActiveEx(true) + + if self.PanelBoxLock then + self.CurLightLock = self.PanelBoxLock:LoadPrefab(XUiConfigs.GetComponentUrl("UiDrawOpenBoxPre")) + self.CurLightLock.gameObject:SetActiveEx(true) + end +end + +function XUiLottoShow:BoxAnimEnd() + self.PlayBoxAnim = false + self:NextPack() +end + +function XUiLottoShow:GetQuality(id, type) + local quality + local templateIdData = XGoodsCommonManager.GetGoodsShowParamsByTemplateId(id) + if type == XArrangeConfigs.Types.Wafer then + quality = templateIdData.Star + elseif type == XArrangeConfigs.Types.Weapon then + quality = templateIdData.Star + elseif type == XArrangeConfigs.Types.Character then + quality = XCharacterConfigs.GetCharMinQuality(id) + else + quality = XTypeManager.GetQualityById(id) + end + return quality +end + +function XUiLottoShow:GetRewardId(showIndex) + local reward = self.RewardList[showIndex] + local id = reward.Id and reward.Id > 0 and reward.Id or reward.TemplateId + if reward.ConvertFrom > 0 then + id = reward.ConvertFrom + end + return id +end + +function XUiLottoShow:GetRewardType(id) + local IsWeaponFashion = XDataCenter.ItemManager.IsWeaponFashion(id) + local type = IsWeaponFashion and XArrangeConfigs.Types.WeaponFashion or XTypeManager.GetTypeById(id) + return type +end + +--获取最高品级效果,按类型取每一类最大值,最后比较大小得出最大的类型和值 +function XUiLottoShow:GetMaxQualityEffectName() + local maxByType = {} + + for k, v in pairs(XArrangeConfigs.Types) do + local maxQuality = 0 + for i = 1, #self.RewardList do + local id = self:GetRewardId(i) + local type = self:GetRewardType(id) + if type == v then + local tempQuality = self:GetQuality(id, type) + if tempQuality > maxQuality then + maxQuality = tempQuality + end + end + end + maxByType[k] = maxQuality + end + + local maxEffectLevel = 1 + local maxEffectPath + for k, v in pairs(XArrangeConfigs.Types) do + if maxByType[k] > 0 then + local showTable = XDataCenter.DrawManager.GetDrawShow(v) + local effect = XDrawConfigs.GetOpenBoxEffect(showTable.DrawEffectGroupId[maxByType[k]]) + + if tonumber(string.sub(effect, -8, -8)) > maxEffectLevel then + maxEffectLevel = tonumber(string.sub(effect, -8, -8)) + maxEffectPath = effect + end + end + end + return maxEffectPath +end + +function XUiLottoShow:SetWeaponPos(target, config) + if not target or not config then + return + end + target.transform.localPosition = CS.UnityEngine.Vector3(config.PositionX, config.PositionY, config.PositionZ) + --检查数据 模型旋转 + target.transform.localEulerAngles = CS.UnityEngine.Vector3(config.RotationX, config.RotationY, config.RotationZ) + --检查数据 模型大小 + target.transform.localScale = CS.UnityEngine.Vector3( + config.ScaleX == 0 and 1 or config.ScaleX, + config.ScaleY == 0 and 1 or config.ScaleY, + config.ScaleZ == 0 and 1 or config.ScaleZ + ) +end +--windEnd \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiLotto/XUiLottoTanchuang.lua b/Resources/Scripts/XUi/XUiLotto/XUiLottoTanchuang.lua new file mode 100644 index 00000000..6b3292da --- /dev/null +++ b/Resources/Scripts/XUi/XUiLotto/XUiLottoTanchuang.lua @@ -0,0 +1,76 @@ +local XUiLottoTanchuang = XLuaUiManager.Register(XLuaUi, "UiLottoTanchuang") +local XUiGridTicket = require("XUi/XUiLotto/XUiGridTicket") +local UseItemMax = 2 +function XUiLottoTanchuang:OnStart(data, cb) + self.DrawData = data + self.CallBack = cb + self:SetButtonCallBack() + self.UseItem = {} + self.TargetItem = {} + self.UseCard = {self.Card1,self.Card2} + self:ShowPanel() +end + +function XUiLottoTanchuang:OnEnable() + self:RefreshCount() +end + +function XUiLottoTanchuang:SetButtonCallBack() + self.BtnTanchuangClose.CallBack = function() + self:OnBtnCloseClick() + end + self.BtnClose.CallBack = function() + self:OnBtnCloseClick() + end +end + +function XUiLottoTanchuang:OnBtnCloseClick() + self:Close() +end + +function XUiLottoTanchuang:ShowPanel() + local ruleCfg = XLottoConfigs.GetLottoBuyTicketRuleById(self.DrawData:GetBuyTicketRuleId()) + if not ruleCfg then + self:Close() + return + end + + for key=1,UseItemMax do + local useItemData = {} + useItemData.ItemId = ruleCfg.UseItemId[key] + useItemData.Sale = ruleCfg.Sale[key] + useItemData.ItemCount = ruleCfg.UseItemCount[key] + useItemData.ItemImg = ruleCfg.UseItemImg[key] + self.UseItem[key] = XUiGridTicket.New(self.UseCard[key], useItemData, function() + -- if useItemData.ItemId and useItemData.ItemId == 3 then --这里的3是指黑卡 + self:BuyTicket(self.DrawData:GetId(), self.DrawData:GetBuyTicketRuleId(), key) + -- else + -- XLuaUiManager.Open("UiPurchase", XPurchaseConfigs.TabsConfig.LB, nil, 1) + -- end + + end) + end + + local targetItemData = {} + targetItemData.ItemId = self.DrawData:GetConsumeId() + targetItemData.ItemCount = ruleCfg.TargetItemCount + targetItemData.ItemImg = ruleCfg.TargetItemImg + self.TargetItem = XUiGridTicket.New(self.TargetCard, targetItemData) +end + +function XUiLottoTanchuang:RefreshCount() --海外修改,购买黑卡后刷新黑卡数量 + for key=1,UseItemMax do + if self.UseItem and self.UseItem[key] then + self.UseItem[key]:ShowPanel() + end + end +end + +function XUiLottoTanchuang:BuyTicket(lottoId, BuyTicketRuleId, ticketKey) + XDataCenter.LottoManager.BuyTicket(lottoId, BuyTicketRuleId, ticketKey, function (rewardList) + XUiManager.OpenUiObtain(rewardList, nil, function () + self:OnBtnCloseClick() + if self.CallBack then self.CallBack() end + end) + end) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiLotto/XUiPanelLottoPreview.lua b/Resources/Scripts/XUi/XUiLotto/XUiPanelLottoPreview.lua new file mode 100644 index 00000000..65250e71 --- /dev/null +++ b/Resources/Scripts/XUi/XUiLotto/XUiPanelLottoPreview.lua @@ -0,0 +1,76 @@ +local XUiPanelLottoPreview = XClass(nil, "XUiPanelLottoPreview") +local CSTextManagerGetText = CS.XTextManager.GetText + +function XUiPanelLottoPreview:Ctor(ui, base, data) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.Base = base + self.LottoGroupData = data + self.RewardCore = {} + self.RewardFirst = {} + self.RewardSecond = {} + self.RewardThird = {} +end + +function XUiPanelLottoPreview:UpdatePanel() + self:UpdatePanelTips() + self:UpdatePanelReward(self.PanelCore, self.RewardCore, XLottoConfigs.RareLevel.One) + self:UpdatePanelReward(self.PanelFirst, self.RewardFirst, XLottoConfigs.RareLevel.Two) + self:UpdatePanelReward(self.PanelSecond, self.RewardSecond, XLottoConfigs.RareLevel.Three) + self:UpdatePanelReward(self.PanelThird, self.RewardThird, XLottoConfigs.RareLevel.Four) + self:UpdateExReward() +end + +function XUiPanelLottoPreview:UpdatePanelTips() + local hintText = self.LottoGroupData:GetRuleHint() + self.PanelTips.gameObject:SetActiveEx(hintText) + self.PanelTips:GetObject("Text").text = hintText or "" +end + +function XUiPanelLottoPreview:UpdatePanelReward(panel, rewardDic, rareLevel) + local drawData = self.LottoGroupData:GetDrawData() + local rewardDataList = drawData:GetRewardDataList() + local gridObj = panel:GetObject("GridRewards") + local Contents = panel:GetObject("GridContents") + + gridObj.gameObject:SetActiveEx(false) + for _,rewardData in pairs(rewardDataList) do + if rewardData:GetRareLevel() == rareLevel then + local reward = rewardDic[rewardData:GetId()] + if not reward then + local obj = CS.UnityEngine.Object.Instantiate(gridObj, Contents) + obj.gameObject:SetActiveEx(true) + reward = XUiGridCommon.New(self.Base, obj) + rewardDic[rewardData:GetId()] = reward + end + if reward then + local tmpData = {TemplateId = rewardData:GetTemplateId(), Count = rewardData:GetCount()} + reward:Refresh(tmpData, nil, nil, nil, rewardData:GetIsGeted() and 0 or 1) + end + end + end +end + +function XUiPanelLottoPreview:UpdateExReward() + local drawData = self.LottoGroupData:GetDrawData() + local ExtraRewardId = drawData:GetExtraRewardId() + self.ExReward.gameObject:SetActiveEx(ExtraRewardId) + if ExtraRewardId then + local processText = CS.XTextManager.GetText("LottoExtraRewardProcessText") + local curCount = math.min(drawData:GetCurRewardCount(),drawData:GetExtraRewardCount()) + local extraCount = drawData:GetExtraRewardCount() + local textCount = self.ExReward:GetObject("TxtCount") + local obj = self.ExReward:GetObject("GridRewards") + + local grid = XUiGridCommon.New(self.Base, obj) + local IsGeted = drawData:GetExtraRewardState() == XLottoConfigs.ExtraRewardState.Geted + local rewardList = XRewardManager.GetRewardList(ExtraRewardId) + grid:Refresh(rewardList[1], nil, nil, nil, IsGeted and 0 or 1) + + textCount.text = string.format("%s%d/%d", processText, curCount, extraCount) + end + +end + +return XUiPanelLottoPreview \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMail/XUiGridItem.lua b/Resources/Scripts/XUi/XUiMail/XUiGridItem.lua new file mode 100644 index 00000000..afebd768 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMail/XUiGridItem.lua @@ -0,0 +1,62 @@ +XUiGridItem = XClass(nil, "XUiGridItem") + +function XUiGridItem:Ctor(rootUi, ui) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + self:InitAutoScript() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiGridItem:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiGridItem:AutoInitUi() + self.ImgItemCountBg = self.Transform:Find("ImgItemCountBg"):GetComponent("Image") + self.ImgItemIcon = self.Transform:Find("ImgItemIcon"):GetComponent("Image") + self.ImgItemBg = self.Transform:Find("ImgItemBg"):GetComponent("Image") + self.TxtItemCount = self.Transform:Find("TxtItemCount"):GetComponent("Text") +end + +function XUiGridItem:GetAutoKey(uiNode,eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiGridItem:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiGridItem:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key],eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiGridItem:AutoAddListener() + self.AutoCreateListeners = {} +end +-- auto + +function XUiGridItem:UpdateItemGrid(itemInfo) + local itemTemplate = XDataCenter.ItemManager.GetItemTemplate(itemInfo.Id) + self.RootUi:SetUiSprite(self.ImgItemIcon, itemTemplate.Icon) + self.TxtItemCount.text = itemInfo.Count +end diff --git a/Resources/Scripts/XUi/XUiMail/XUiGridTitle.lua b/Resources/Scripts/XUi/XUiMail/XUiGridTitle.lua new file mode 100644 index 00000000..b7b64cdd --- /dev/null +++ b/Resources/Scripts/XUi/XUiMail/XUiGridTitle.lua @@ -0,0 +1,93 @@ +XUiGridTitle = XClass(nil, "XUiGridTitle") + +function XUiGridTitle:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:InitAutoScript() + self:SetTitleBg(false) +end + +function XUiGridTitle:InitAutoScript() + self:AutoAddListener() +end + +function XUiGridTitle:AutoAddListener() + self.BtnTitle.CallBack = function() + self:OnBtnTitleClick() + end +end + +function XUiGridTitle:OnBtnTitleClick() + self.Base.CurMailInfo = self.MailInfo + self:OpenMail(true) +end + +function XUiGridTitle:OpenMail(IsPlayAnim) + if self.Base.CurMailInfo.Id == self.MailInfo.Id then + self.Base.GetItemCallBack = function() + self:SetMailStatus(true) + end + self.Base:ClickMailGrid(self.MailInfo,IsPlayAnim) + if self.Base.OldTitle then + self.Base.OldTitle:SetTitleBg(false) + end + self.Base.OldTitle = self + self:SetMailStatus(true) + self:SetTitleBg(true) + self:SetUnread(false) + else + self:SetTitleBg(false) + end +end + +function XUiGridTitle:SetUnread(IsUnread) + self.TxtUnread.gameObject:SetActiveEx(IsUnread) + self.ImgBgUnread.gameObject:SetActiveEx(IsUnread) +end + +function XUiGridTitle:UpdateMailGrid(base,mailInfo) + self.Base = base + self.MailInfo = mailInfo + -- local mailId = mailInfo.Id + self.TxtTitleRead.text = mailInfo.Title + -- self.TxtDateRead.text = XTime.TimestampToGameDateTimeString(mailInfo.CreateTime) + self.TxtDateRead.gameObject:SetActiveEx(false) + self.TxtTitleUnread.text = mailInfo.Title + -- self.TxtDateUnread.text = XTime.TimestampToGameDateTimeString(mailInfo.CreateTime) + self.TxtDateUnread.gameObject:SetActiveEx(false) + self:SetMailStatusByStatu() + self:OpenMail(false) +end + +function XUiGridTitle:SetMailStatusByStatu() + local isRead = XDataCenter.MailManager.IsRead(self.MailInfo.Status) + self:SetMailStatus(isRead) + self:SetUnread(not isRead) +end + +function XUiGridTitle:SetMailStatus(isRead) + self.ImgIconRead.gameObject:SetActiveEx(false) + self.ImgIconUnRead.gameObject:SetActiveEx(false) + self.ImgIconReadgift.gameObject:SetActiveEx(false) + self.ImgIconUnReadgift.gameObject:SetActiveEx(false) + --self.ImgRedDot.gameObject:SetActive(not isRead) + local isHasReward = XDataCenter.MailManager.HasMailReward(self.MailInfo.Id) + local isGetReward = XDataCenter.MailManager.IsMailGetReward(self.MailInfo.Id) + + + if isHasReward and not isGetReward then + + self.ImgIconUnReadgift.gameObject:SetActiveEx(not isRead) + self.ImgIconReadgift.gameObject:SetActiveEx(isRead) + + else + self.ImgIconUnRead.gameObject:SetActiveEx(not isRead) + self.ImgIconRead.gameObject:SetActiveEx(isRead) + + end +end + +function XUiGridTitle:SetTitleBg(flag) + self.ImgTitleBg.gameObject:SetActiveEx(flag) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMail/XUiMail.lua b/Resources/Scripts/XUi/XUiMail/XUiMail.lua new file mode 100644 index 00000000..7215aea0 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMail/XUiMail.lua @@ -0,0 +1,296 @@ +local XUiMail = XLuaUiManager.Register(XLuaUi, "UiMail") +local MailMaxCount = CS.XGame.Config:GetInt("MailCountLimit") +local CSGetText = CS.XTextManager.GetText +function XUiMail:OnAwake() + self:InitAutoScript() + + self.DynamicTable = XDynamicTableNormal.New(self.PanelTitleList) + self.DynamicTable:SetProxy(XUiGridTitle) + self.DynamicTable:SetDelegate(self) + self.GridTitle.gameObject:SetActive(false) +end + +function XUiMail:OnStart() + + self.CurMailInfo = nil + self.SelectTitle = nil + self.RewardGrids = {} + + self.HtmlText = self.GridContent:GetComponent("XHtmlText") + self.HtmlText.HrefListener = function(link) + self:ClickLink(link) + end + + self:Reset() + + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + -- local musicKey = self:GetAutoKey(self.BtnBack, "onClick") + -- self.SpecialSoundMap[musicKey] = XSoundManager.UiBasicsMusic.Return +end + +function XUiMail:OnEnable() + self:ReLoadMailData(false) +end + +function XUiMail:OnDisable() + self:RemoveTimer() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiMail:InitAutoScript() + self:AutoAddListener() +end + +--动态列表事件 +function XUiMail:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:UpdateMailGrid(self,self.PageDatas[index]) + end +end + +function XUiMail:SetupDynamicTable(IsNotSync) + if not IsNotSync then + self.PageDatas = XDataCenter.MailManager.GetMailList() + end + self.CurMailInfo = self.PageDatas[1] + self.DynamicTable:SetDataSource(self.PageDatas) + self.DynamicTable:ReloadDataSync(1) +end + +function XUiMail:AutoAddListener() + self.BtnDelete.CallBack = function() + self:OnBtnDeleteClick() + end + self.BtnGet.CallBack = function() + self:OnBtnGetClick() + end + self.BtnGetReward.CallBack = function() + self:OnBtnGetRewardClick() + end + self.BtnMainUi.CallBack = function() + self:OnBtnMainUiClick() + end + self.BtnBack.CallBack = function() + self:OnBtnBackClick() + end + +end +-- auto + +function XUiMail:Reset() + self.PanelMailContent.gameObject:SetActive(false) + --self.ImgBgUn.gameObject:SetActive(true) + self.BtnGetReward.gameObject:SetActive(false) + self.ImgGetReward.gameObject:SetActive(false) + self.PanelItemContent.gameObject:SetActive(false) +end + +function XUiMail:ReLoadMailData(IsNotSync) + self:SetupDynamicTable(IsNotSync) + self:UpdateMailList() +end + +function XUiMail:ResetReward() + if self.CurMailInfo and self.CurMailInfo.Id then + self:Reset() + self:SetRewardBtnStatus(self.CurMailInfo.Id) + self:InitRewardList(self.CurMailInfo.Id) + end +end + +function XUiMail:UpdateMailList() + + self.PanelUnGet.gameObject:SetActive(false) + self.TxtMailCount.text = CSGetText("MailCountText",#self.PageDatas,MailMaxCount) + if #self.PageDatas == 0 then + self.PanelUnGet.gameObject:SetActive(true) + return + end +end + +function XUiMail:ShowMailInfo(mailInfo) + self.TxtContentTitle.text = mailInfo.Title + local content = mailInfo.Content or "" + local sendName = mailInfo.SendName or "" + self.HtmlText.text = content .. "\n\n" .. CSGetText("ComeFrom") .. ": " .. sendName .. "\n" + self.PanelMailContent.gameObject:SetActive(true) + self:RemoveTimer() + + if not mailInfo.ExpireTime then + self.TxtContentDateNum.gameObject:SetActive(false) + return + end + + self.TxtForbidDelete.gameObject:SetActiveEx(mailInfo.IsForbidDelete) + + local refreshFunc + local restTime = mailInfo.ExpireTime - XTime.GetServerNowTimestamp() + if restTime and restTime > 0 then + refreshFunc = function () + local dataTime = XUiHelper.GetTime(restTime) + if XTool.UObjIsNil(self.TxtContentDateNum) then + return + end + self.TxtContentDateNum.text = CSGetText("EmailExpireTime",dataTime) + restTime = restTime - 1 + + if restTime < 0 then + refreshFunc = nil + end + end + else + if mailInfo.ExpireTime == 0 then + self.TxtContentDateNum.text = CSGetText("EmailForever") + else + self.TxtContentDateNum.text = CSGetText("EmailExpireTime",XUiHelper.GetTime(0)) + end + + end + + if refreshFunc then + refreshFunc() + else + return + end + + self.Timer = XScheduleManager.ScheduleForever(function() + if not refreshFunc then + self:RemoveTimer() + return + end + + if refreshFunc then + refreshFunc() + end + end, 1000) +end + +function XUiMail:RemoveTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end + +function XUiMail:ClickMailGrid(mailInfo,IsPlayAnim) + --self.ImgBgUn.gameObject:SetActive(false) + XDataCenter.MailManager.ReadMail(mailInfo.Id) + self:ShowMailInfo(mailInfo) + self:SetRewardBtnStatus(mailInfo.Id) + self:InitRewardList(mailInfo.Id) + if IsPlayAnim then + self:PlayAnimation("AnimYouJianEnable") + end +end + +function XUiMail:InitRewardList(mailId) + local baseItem = self.GridItem + baseItem.gameObject:SetActive(false) + self.PanelItemContent.gameObject:SetActive(false) + + if not XDataCenter.MailManager.HasMailReward(mailId) then + return + end + + for _, grid in pairs(self.RewardGrids) do + grid:Refresh() + end + + local mail = XDataCenter.MailManager.GetMailCache(mailId) + local isGetReward = XDataCenter.MailManager.IsGetReward(mail.Status) + local index = 1 + local function refreshReward(value) + if not self.RewardGrids[index] then + local item = CS.UnityEngine.Object.Instantiate(baseItem) + local grid = XUiGridCommon.New(self, item) + grid.Transform:SetParent(self.PanelItemContent, false) + self.RewardGrids[index] = grid + end + + self.RewardGrids[index]:Refresh(value, { ["ShowReceived"] = isGetReward }) + index = index + 1 + end + + local rewards = XRewardManager.MergeAndSortRewardGoodsList(mail.RewardGoodsList) + + for i = 1, #rewards do + refreshReward(rewards[i]) + end + + self.PanelItemContent.gameObject:SetActive(true) +end + +function XUiMail:OnBtnDeleteClick() + XDataCenter.MailManager.DeleteMail(function() + self:ResetReward() + self:ReLoadMailData(false) + end) +end + +function XUiMail:OnBtnGetClick() + XDataCenter.MailManager.GetAllMailReward(function() + self:ResetReward() + self:ReLoadMailData(true) + end) +end + +function XUiMail:OnBtnGetRewardClick() + if self.CurMailInfo then + XDataCenter.MailManager.GetMailReward(self.CurMailInfo.Id, function() + self:ResetReward() + if self.GetItemCallBack then + self.GetItemCallBack() + end + self:ClickMailGrid(self.CurMailInfo,true) + end) + end +end + +function XUiMail:OnBtnBackClick() + self:Close() + XDataCenter.MailManager.SyncMailEvent() +end + +function XUiMail:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiMail:SetRewardBtnStatus(mailId) + mailId = mailId and mailId or self.CurMailInfo.Id + self.BtnGetReward.gameObject:SetActive(false) + self.ImgGetReward.gameObject:SetActive(false) + + if not mailId then + return + end + + local mail = XDataCenter.MailManager.GetMailCache(mailId) + if mail and XDataCenter.MailManager.HasMailReward(mailId) then + if not XDataCenter.MailManager.IsGetReward(mail.Status) then + self.BtnGetReward.gameObject:SetActive(true) + else + self.ImgGetReward.gameObject:SetActive(true) + end + end +end + +function XUiMail:SetRewardStatus(mailId) + mailId = mailId and mailId or self.CurMailInfo.Id + + if not mailId then + return + end + + if XDataCenter.MailManager.HasMailReward(mailId) then + self.PanelItemContent.gameObject:SetActive(true) + local isGetReward = XDataCenter.MailManager.IsMailGetReward(mailId) + for _, grid in pairs(self.RewardGrids) do + grid:SetReceived(isGetReward) + end + end +end + +function XUiMail:ClickLink(url) + CS.UnityEngine.Application.OpenURL(url) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMain/XUiChildItem/XUiGridSubMenuItem.lua b/Resources/Scripts/XUi/XUiMain/XUiChildItem/XUiGridSubMenuItem.lua new file mode 100644 index 00000000..c2f0acaa --- /dev/null +++ b/Resources/Scripts/XUi/XUiMain/XUiChildItem/XUiGridSubMenuItem.lua @@ -0,0 +1,46 @@ +-- 主界面二级菜单按钮 +local XUiGridSubMenuItem = XClass(nil, "XUiGridSubMenuItem") + +local JumpType = { + Web = 1, + Game = 2, +} + +function XUiGridSubMenuItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiGridSubMenuItem:Init(uiRoot) + self.UiRoot = uiRoot +end + +function XUiGridSubMenuItem:OnRefresh(data) + self.Data = data + self.BtnType1.gameObject:SetActiveEx(tonumber(data.StyleType) == 1) + self.BtnType2.gameObject:SetActiveEx(tonumber(data.StyleType) == 2) + + self.Btn = self["BtnType"..data.StyleType] or self.BtnType1 + self.Btn:SetNameByGroup(0, data.Title) + self.Btn:SetNameByGroup(1, data.SubTitle) + self.Btn.CallBack = function() self:OnBtn() end + + local isShow = XDataCenter.NoticeManager.CheckSubMenuRedPointIndividual(data.Id) + self.Btn:ShowReddot(isShow) +end + +function XUiGridSubMenuItem:OnBtn() + local data = self.Data + if not data.JumpAddr then return end + if tonumber(data.JumpType) == JumpType.Web then + CS.UnityEngine.Application.OpenURL(data.JumpAddr) + elseif tonumber(data.JumpType) == JumpType.Game then + XFunctionManager.SkipInterface(tonumber(data.JumpAddr)) + end + -- 设置已读 + XDataCenter.NoticeManager.ChangeSubMenuReadStatus(data.Id) + self.Btn:ShowReddot(false) +end + +return XUiGridSubMenuItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMain/XUiChildView/XUiPanelAd.lua b/Resources/Scripts/XUi/XUiMain/XUiChildView/XUiPanelAd.lua new file mode 100644 index 00000000..455cedd1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMain/XUiChildView/XUiPanelAd.lua @@ -0,0 +1,284 @@ +XUiPanelAd = XClass(XLuaBehaviour, "XUiPanelAd") + +local MISTAKE_DISTANCE = 5 +local DefaultPicScrollInterval = 5 +local PITCH_ON = CS.XGame.ClientConfig:GetString("UiMainPitchOn") +local PITCH_OFF = CS.XGame.ClientConfig:GetString("UiMainPitchOff") +local JumpType = { + Web = 1, + Game = 2, + Sign = 3, +} + +function XUiPanelAd:Ctor(rootUi, ui) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + self:InitAutoScript() + self.ChildPosXs = {} --广告坐标 + self.AdPrefab = {} --广告图片 + self.PageNum = {} --小白点表 + self.CurIndex = 1 --当前为第几图片 + + self:AddPointerClickListener() + self:UpdateAdList() + + XEventManager.AddEventListener(XEventId.EVENT_PLAYER_LEVEL_CHANGE, self.UpdateAdList, self) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelAd:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} +end + +function XUiPanelAd:AutoInitUi() + self.Panelpicture = self.Transform:Find("Map/Panelpicture") + self.PanelSwitchover = self.Transform:Find("Map/PanelSwitchover") + self.PanelSw = self.Transform:Find("Map/PanelSwitchover/PanelSw") + self.CenterScroll = self.Transform:GetComponent("XUiCenterScroll") + + self:InitCenterScroll() +end + +function XUiPanelAd:Update() + if #self.AdList <= 1 then + return + end + + if not self.ChildPosXs or not self.AdList then + return + end + + if not self.ChildPosXs[self.CurIndex] or not self.AdList[self.CurIndex] then + return + end + + local nowPosX = self.Panelpicture.anchoredPosition.x + local targetPosX = -self.ChildPosXs[self.CurIndex] + + if self.CurIndex == 1 and math.abs(nowPosX - targetPosX) <= MISTAKE_DISTANCE then + self:ForceMoveToIndex(#self.AdList - 2) + elseif self.CurIndex == #self.AdList and math.abs(nowPosX - targetPosX) <= MISTAKE_DISTANCE then + self:ForceMoveToIndex(1) + end +end + +function XUiPanelAd:InitCenterScroll() + self.CenterScroll:RegisterEndDragCallBack(function (index) + local nowIndex = index + 1 + if self.CurIndex == nowIndex then + return + end + + local interval = DefaultPicScrollInterval + if self.AdList and self.AdList[self.CurIndex] and self.AdList[self.CurIndex].Interval then + interval = self.AdList[self.CurIndex].Interval + end + + self:ClearTimer() + self.Timer = XScheduleManager.ScheduleOnce(function () + self.CenterScroll:NextPage() + end, interval * 1000) + + self.CurIndex = nowIndex + self:UpdatePage() + end) +end + +function XUiPanelAd:ClearTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end + +function XUiPanelAd:AddPointerClickListener() + self.UiPanelAd = self.GameObject:AddComponent(typeof(CS.XUiWidget)) + self.UiPanelAd:AddPointerClickListener(function () + self:OnPointerClick() + end) + self.UiPanelAd:AddEndDragListener(function() + self:OnEndDrag() + end) + self.UiPanelAd:AddDragListener(function () + self:OnDrag() + end) +end + +function XUiPanelAd:OnDrag() + self.IsDraging = true +end + +--停止拖动 +function XUiPanelAd:OnEndDrag() + self.IsDraging = false +end + +function XUiPanelAd:ForceMoveToIndex(index) + self.CenterScroll:SetIndex(index) +end + +function XUiPanelAd:OnPointerClick() + if self.IsDraging then + return + end + + if not self.AdList or not self.AdList[self.CurIndex] then + return + end + + local data = self.AdList[self.CurIndex] + + local jumpAddr = data.JumpAddr + if not jumpAddr then + return + end + + if tonumber(data.JumpType) == JumpType.Web then + if jumpAddr and #jumpAddr > 0 then + if string.find(jumpAddr, "eden") ~= nil then -- 伊甸文化跳转 + local uid = XUserManager.UserId + local serverId = CS.XHeroBdcAgent.ServerId + if uid and uid ~= "" then + if serverId and serverId ~= "" then + CS.UnityEngine.Application.OpenURL(jumpAddr.."?uid="..uid.."&serverId="..serverId) + else + CS.UnityEngine.Application.OpenURL(jumpAddr.."?uid="..uid) + end + return + end + elseif string.find(jumpAddr, "seeed") ~= nil or string.find(jumpAddr, "rooot") ~= nil then -- rooot活动的 + XDataCenter.ActivityManager.OpenRoootUrl(jumpAddr) + return + end + CS.UnityEngine.Application.OpenURL(jumpAddr) + end + elseif tonumber(data.JumpType) == JumpType.Game then + XFunctionManager.SkipInterface(tonumber(jumpAddr)) + elseif tonumber(data.JumpType) == JumpType.Sign then + if jumpAddr and #jumpAddr > 0 then + local signAddr = XDataCenter.MarketingActivityManager.GetSignUrl(jumpAddr) + CS.UnityEngine.Application.OpenURL(signAddr) + end + end +end + +--小球变色 +function XUiPanelAd:UpdatePage() + local index = self.CurIndex + if index == #self.AdList then + index = 2 + elseif self.CurIndex == 1 then + index = #self.AdList - 1 + end + for k, rawImage in pairs(self.PageNum) do + rawImage:SetRawImage(PITCH_OFF) + if k == index then + rawImage:SetRawImage(PITCH_ON) + end + end +end + +function XUiPanelAd:UpdateAdList() + self.AdList = {} + self.ChildPosXs = {} + local dataList = XDataCenter.NoticeManager.GetScrollPicList() or {} + if #dataList > 1 then + table.insert(self.AdList, dataList[#dataList]) + for _, v in ipairs(dataList) do + table.insert(self.AdList, v) + end + table.insert(self.AdList, self.AdList[2]) + else + self.AdList = dataList + end + + self:UpdateAdvertising() + self:UpdatePage() +end + +function XUiPanelAd:Addadvertising(index) + local advertising = self.Panelpicture:GetChild(0).gameObject + advertising:SetActiveEx(false) + + local smallSp = self.PanelSw.gameObject + smallSp:SetActiveEx(false) + + local adPrefab = CS.UnityEngine.Object.Instantiate(advertising, self.Panelpicture) + adPrefab.gameObject:SetActiveEx(true) + self.AdPrefab[index] = adPrefab + + if index > 1 and index < #self.AdList then + local pageNum = CS.UnityEngine.Object.Instantiate(smallSp, self.PanelSwitchover) + pageNum.gameObject:SetActiveEx(true) + self.PageNum[index] = pageNum:GetComponent("RawImage") + end + + self.ChildPosXs[index] = (index - 1) * self.Panelpicture:GetComponent("GridLayoutGroup").cellSize.x + self:LoadWebTexture(index) +end + +function XUiPanelAd:LoadWebTexture(index, isBackUp) + local picAddr + if isBackUp then + picAddr = self.AdList[index].PicAddrSlave + else + picAddr = self.AdList[index].PicAddr + end + + XDataCenter.NoticeManager.LoadPicFromLocal(picAddr, function(texture) + if XTool.UObjIsNil(self.AdPrefab[index]) then + return + end + + self.AdPrefab[index]:GetComponent("RawImage").texture = texture + end) +end + +--动态获得广告个数 +function XUiPanelAd:UpdateAdvertising() + self:ClearAdvertsing() + + if #self.AdList <= 0 then + local advertising = self.Panelpicture:GetChild(0).gameObject + advertising:SetActiveEx(true) + local smallSp = self.PanelSw.gameObject + smallSp:SetActiveEx(false) + return + end + + for i = 1, #self.AdList do + self:Addadvertising(i) + end + + self.CenterScroll:UpdatePages() + + if #self.ChildPosXs > 1 then + self:ForceMoveToIndex(1) + end + + self.Panelpicture:SetSizeWithCurrentAnchors(CS.UnityEngine.RectTransform.Axis.Horizontal, #self.ChildPosXs * 467) +end + +-- 清空广告节点 +function XUiPanelAd:ClearAdvertsing() + for _, v in pairs(self.AdPrefab) do + CS.UnityEngine.Object.DestroyImmediate(v) + end + self.AdPrefab = {} + + for _, v in pairs(self.PageNum) do + CS.UnityEngine.Object.Destroy(v.gameObject) + end + + self.PageNum = {} +end + +function XUiPanelAd:OnDestroy() + XEventManager.RemoveEventListener(XEventId.EVENT_PLAYER_LEVEL_CHANGE, self.UpdateAdList, self) + XEventManager.RemoveEventListener(XEventId.EVENT_MAINUI_ENABLE, self.UpdateAdList, self) +end + +return XUiPanelAd \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMain/XUiChildView/XUiPanelArenaOnline.lua b/Resources/Scripts/XUi/XUiMain/XUiChildView/XUiPanelArenaOnline.lua new file mode 100644 index 00000000..85fa2b5d --- /dev/null +++ b/Resources/Scripts/XUi/XUiMain/XUiChildView/XUiPanelArenaOnline.lua @@ -0,0 +1,133 @@ +local XUiPanelArenaOnline = XClass(nil, "XUiPanelArenaOnline") + +function XUiPanelArenaOnline:Ctor(uiRoot, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + + XTool.InitUiObject(self) + self:AutoAddListener() + self:Hide() + self.ToggleShow:SetButtonState(CS.UiButtonState.Normal) +end + +function XUiPanelArenaOnline:AutoAddListener() + self.BtnSure.CallBack = function() self:OnBtnSureClick() end + self.BtnCancel.CallBack = function() self:OnBtnCancelClick() end +end + +function XUiPanelArenaOnline:OnBtnCancelClick() + self:StopTimer() + self:Hide(true) + self:CheckSetInviteTip() +end + +function XUiPanelArenaOnline:OnBtnSureClick() + local stageInfo = XDataCenter.FubenManager.GetStageInfo(self.StageId) + local fubenName = "" + if stageInfo.Type == XDataCenter.FubenManager.StageType.BossOnline then + fubenName = XFunctionManager.FunctionName.FubenActivity + elseif stageInfo.Type == XDataCenter.FubenManager.StageType.Daily then + local challengeCfg = XDataCenter.FubenDailyManager.GetDailyCfgBySectionId(stageInfo.DailySectionId) + if challengeCfg and challengeCfg.Type == XDataCenter.FubenManager.ChapterType.EMEX then + fubenName = XFunctionManager.FunctionName.FubenDailyEMEX + end + elseif stageInfo.Type == XDataCenter.FubenManager.StageType.ArenaOnline then + fubenName = XFunctionManager.FunctionName.ArenaOnline + end + + if not XFunctionManager.DetectionFunction(fubenName) then + self:Hide(true) + self:CheckSetInviteTip() + return + end + + if stageInfo.Type == XDataCenter.FubenManager.StageType.ArenaOnline then + XDataCenter.RoomManager.ArenaOnlineEnterTargetRoom(self.RoomId, self.StageId, self.CreateTime) + else + XDataCenter.RoomManager.NormalEnterTargetRoom(self.RoomId, self.StageId, self.CreateTime) + end + + self:Hide(true) + self:CheckSetInviteTip() +end + +function XUiPanelArenaOnline:CheckSetInviteTip() + if not self.ToggleShow:GetToggleState() then + return + end + + XDataCenter.ArenaOnlineManager.SetInviteTip() +end + +function XUiPanelArenaOnline:Show(chatData) + if not XDataCenter.ArenaOnlineManager.CheckInviteTipShow() then + return + end + + if chatData.MsgType ~= ChatMsgType.RoomMsg then + return + end + + local contentData = XChatData.DecodeRoomMsg(chatData.Content) + if not contentData then + return + end + + self.ToggleShow:SetButtonState(CS.UiButtonState.Normal) + self.StageId = tonumber(contentData[3]) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(self.StageId) + if not stageInfo or stageInfo.Type ~= XDataCenter.FubenManager.StageType.ArenaOnline then + return + end + + self:StopTimer() + local senderId = chatData.SenderId + local remark = XDataCenter.SocialManager.GetFriendRemark(senderId) + if remark ~= "" then + self.TxtName.text = remark + else + self.TxtName.text = chatData.NickName + end + self.RoomId = contentData[4] + self.CreateTime = chatData.CreateTime + + + local name = XArenaOnlineConfigs.GetFirstChapterName() + self.TxtChpaterName.text = CS.XTextManager.GetText("ArenaOnlineInviteShow", name) + + self.LeftTime = XArenaOnlineConfigs.SHOW_TIME + self.Timer = XScheduleManager.ScheduleForever(function() + self.LeftTime = self.LeftTime - 1 + if self.LeftTime <= 0 then + self:StopTimer() + self:Hide(true) + return + end + end, XScheduleManager.SECOND, 0) + self.GameObject:SetActiveEx(true) + self.UiRoot:PlayAnimation("AnimArenaOnlineEnable") +end + +function XUiPanelArenaOnline:StopTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end + +function XUiPanelArenaOnline:OnDestroy() + self:StopTimer() +end + +function XUiPanelArenaOnline:Hide(isAnima) + if isAnima then + self.UiRoot:PlayAnimation("AnimArenaOnlineDisable", function() + self.GameObject:SetActiveEx(false) + end) + else + self.GameObject:SetActiveEx(false) + end +end + +return XUiPanelArenaOnline \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMain/XUiChildView/XUiPanelSignBoard.lua b/Resources/Scripts/XUi/XUiMain/XUiChildView/XUiPanelSignBoard.lua new file mode 100644 index 00000000..d4b1f23a --- /dev/null +++ b/Resources/Scripts/XUi/XUiMain/XUiChildView/XUiPanelSignBoard.lua @@ -0,0 +1,543 @@ +XUiPanelSignBoard = XClass(nil, "XUiPanelSignBoard") + +XUiPanelSignBoard.SignBoardOpenType = { + MAIN = 1, + FAVOR = 2 +} + +local DEFAULT_CV_TYPE = CS.XGame.Config:GetInt("DefaultCvType") + +function XUiPanelSignBoard:Ctor(ui, parent, openType) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.Parent = parent + self.OpenType = openType + + self.ClickTrigger = true + self.CanBreakTrigger = false + + self.OperateTrigger = true + self.DialogTrigger = true + self.CvTrigger = true + + self:InitAutoScript() + self:Init() +end + +function XUiPanelSignBoard:Init() + --模型 + local clearUiChildren = self.OpenType == XUiPanelSignBoard.SignBoardOpenType.MAIN + self.RoleModel = XUiPanelRoleModel.New(self.Parent.UiModel.UiModelParent, self.Parent.Name, true, false, false, nil, nil, function() + if self.Parent.PlayChangeActionEffect then + self.Parent:PlayChangeActionEffect() + end + end, clearUiChildren) + + self.DisplayCharacterId = -1 + self.AutoPlay = true + --播放器 + self.Acceleration = self.GameObject:GetComponent(typeof(CS.XInputAcceleration)) + if not self.Acceleration then + self.Acceleration = self.GameObject:AddComponent(typeof(CS.XInputAcceleration)) + end + self.Acceleration.EndAction = handler(self, self.OnRoll) + local signBoardPlayer = require("XCommon/XSignBoardPlayer").New(self, CS.XGame.ClientConfig:GetInt("SignBoardPlayInterval"), CS.XGame.ClientConfig:GetFloat("SignBoardDelayInterval")) + local playerData = XDataCenter.SignBoardManager.GetSignBoardPlayerData() + signBoardPlayer:SetPlayerData(playerData) + self.SignBoardPlayer = signBoardPlayer + + local signBoardClickInterval = CS.XGame.ClientConfig:GetFloat("SignBoardClickInterval") + local signBoardMultClickCountLimit = CS.XGame.ClientConfig:GetInt("SignBoardMultClickCountLimit") + + local multClickHelper = require("XUi/XUiCommon/XUiMultClickHelper").New(self, signBoardClickInterval, signBoardMultClickCountLimit) + self.MultClickHelper = multClickHelper + self.PanelLayout.gameObject:SetActiveEx(false) + if XUiManager.IsHideFunc then + self.BtnCommunication.gameObject:SetActiveEx(false) + end + + -- 播放队列只播放权重最高的动画 + self:SetPlayOne(true) + + --用于驱动播放器和连点检测 + --事件 + CsXGameEventManager.Instance:RegisterEvent(XEventId.EVENT_FIGHT_RESULT, handler(self, self.OnNotify)) + CsXGameEventManager.Instance:RegisterEvent(XEventId.EVENT_FAVORABILITY_GIFT, handler(self, self.OnNotify)) + +end + +function XUiPanelSignBoard:SetDisplayCharacterId(displayCharacterId) + self.DisplayCharacterId = displayCharacterId + self.IdleTab = XSignBoardConfigs.GetSignBoardConfigByRoldIdAndCondition(self.DisplayCharacterId, XSignBoardEventType.IDLE) + + self.IdleTab = XDataCenter.SignBoardManager.FitterPlayElementByFavorLimit(self.IdleTab, displayCharacterId) + self.IdleTab = XDataCenter.SignBoardManager.FitterCurLoginPlayed(self.IdleTab) + self.IdleTab = XDataCenter.SignBoardManager.FitterDailyPlayed(self.IdleTab) +end + +function XUiPanelSignBoard:RefreshCharModel() + self.DisplayState = XDataCenter.DisplayManager.UpdateRoleModel(self.RoleModel, self.DisplayCharacterId) +end + +function XUiPanelSignBoard:RefreshCharacterModelById(templateId) + XDataCenter.DisplayManager.UpdateRoleModel(self.RoleModel, templateId) +end + +function XUiPanelSignBoard:OnNotify(event, ...) + XDataCenter.SignBoardManager.OnNotify(event, ...) +end + +--晃动手机 +function XUiPanelSignBoard:OnRoll(time) + if self.SignBoardPlayer:IsPlaying() and not self.CanBreakTrigger then + return + end + + self.CanBreakTrigger = false + + local config = XDataCenter.SignBoardManager.GetRandomPlayElementsByRoll(time, self.DisplayCharacterId) + self.SignBoardPlayer:ForcePlay(config, nil, true) +end + +function XUiPanelSignBoard:ResetPlayList() + + local playList = XDataCenter.SignBoardManager.GetPlayElements(self.DisplayCharacterId) + if not playList then + return + end + + self.SignBoardPlayer:SetPlayList(playList) +end + +function XUiPanelSignBoard:OnEnable() + + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end + + self.Timer = XScheduleManager.ScheduleForever(function() + self:Update() + end, 0) + + self:RefreshCharModel() + + if self.SignBoardPlayer then + self.SignBoardPlayer:OnEnable() + end + + if self.MultClickHelper then + self.MultClickHelper:OnEnable() + end + + local playList = XDataCenter.SignBoardManager.GetPlayElements(self.DisplayCharacterId) + if not playList then + return + end + + self.SignBoardPlayer:SetPlayList(playList) + + self.Enable = true +end + +function XUiPanelSignBoard:OnDisable() + + if self.Timer ~= nil then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end + + if self.SignBoardPlayer then + self.SignBoardPlayer:OnDisable() + end + + if self.MultClickHelper then + self.MultClickHelper:OnDisable() + end + + if self.PlayingCv then + self.PlayingCv:Stop() + self.PlayingCv = nil + end + + XDataCenter.SignBoardManager.SetStandType(0) + + self.Enable = false +end + +function XUiPanelSignBoard:OnDestroy() + if self.Timer ~= nil then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end + + if self.SignBoardPlayer then + self.SignBoardPlayer:OnDestroy() + end + + if self.MultClickHelper then + self.MultClickHelper:OnDestroy() + end + + self.Enable = false +end + +function XUiPanelSignBoard:Update() + if not self.Enable then + return + end + + local dt = CS.UnityEngine.Time.deltaTime + if self.SignBoardPlayer then + self.SignBoardPlayer:Update(dt) + end + + if self.IdleTab and self.IdleTab[1] then + local idle = self.IdleTab[1] + local bBeyondignBoardWaitInterval = XTime.GetServerNowTimestamp() - self.SignBoardPlayer.LastPlayTime >= idle.ConditionParam + local standType = XDataCenter.SignBoardManager.GetStandType() + + if self.SignBoardPlayer.Status == 0 and self.SignBoardPlayer.LastPlayTime > 0 and standType == 0 and bBeyondignBoardWaitInterval and self.AutoPlay then + self.SignBoardPlayer:ForcePlay(idle, nil, true) + + if idle.ShowType ~= XDataCenter.SignBoardManager.ShowType.Normal then + -- 该idle动作限制每次登录或者每天只播放一次 + table.remove(self.IdleTab, 1) + end + + self.SignBoardPlayer.LastPlayTime = -1 + self.CanBreakTrigger = true + end + end + + if self.MultClickHelper then + self.MultClickHelper:Update(dt) + end +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelSignBoard:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiPanelSignBoard:AutoInitUi() + --self.BtnRole = self.Transform:Find("BtnRole"):GetComponent("Button") + self.PanelLayout = self.Transform:Find("PanelLayout") + self.PanelChat = self.Transform:Find("PanelLayout/PanelChat") + self.TxtContent = self.Transform:Find("PanelLayout/PanelChat/Image/TxtContent"):GetComponent("Text") + self.PanelOpration = self.Transform:Find("PanelLayout/PanelOpration") + self.BtnReplace = self.Transform:Find("PanelLayout/PanelOpration/BtnReplace"):GetComponent("Button") + self.BtnCoating = self.Transform:Find("PanelLayout/PanelOpration/BtnCoating"):GetComponent("Button") + self.BtnCommunication = self.Transform:Find("PanelLayout/PanelOpration/BtnCommunication"):GetComponent("Button") +end + +function XUiPanelSignBoard:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelSignBoard:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelSignBoard:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelSignBoard:AutoAddListener() + self:RegisterClickEvent(self.BtnRole, self.OnBtnRoleClick) + self:RegisterClickEvent(self.BtnReplace, self.OnBtnReplaceClick) + self:RegisterClickEvent(self.BtnCoating, self.OnBtnCoatingClick) + self:RegisterClickEvent(self.BtnCommunication, self.OnBtnCommunicationClick) +end +-- auto +function XUiPanelSignBoard:OnBtnReplaceClick() + XLuaUiManager.OpenWithCallback("UiFavorabilityLineRoomCharacter", function() + self.SignBoardPlayer:Stop() + end) +end + +function XUiPanelSignBoard:OnBtnCoatingClick() + if XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.FavorabilityMain) then + XUiManager.TipMsg(CS.XTextManager.GetText("FunctionalMaintain")) + return + end + XLuaUiManager.OpenWithCallback("UiFashion", function() + self.SignBoardPlayer:Stop() + end, self.DisplayCharacterId) +end + +function XUiPanelSignBoard:OnBtnCommunicationClick() + if XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.FavorabilityMain) then + XUiManager.TipMsg(CS.XTextManager.GetText("FunctionalMaintain")) + return + end + self.PanelLayout.gameObject:SetActiveEx(false) + XLuaUiManager.Open("UiFavorabilityNew") +end + +--播放 +function XUiPanelSignBoard:Play(element) + if not element then + return + end + + --用CvId与CvType来索引Cv.tab,从而获得Content + local content + if element.CvType then + --播放动作页签下的动作,使用页签选择的语言类型 + content = XFavorabilityConfigs.GetCvContentByIdAndType(element.SignBoardConfig.CvId, element.CvType) + else + --播放看板交互的动作,使用设置项的语言 + local cvType = CS.UnityEngine.PlayerPrefs.GetInt("CV_TYPE", DEFAULT_CV_TYPE) + content = XFavorabilityConfigs.GetCvContentByIdAndType(element.SignBoardConfig.CvId, cvType) + end + self.TxtContent.text = content + + self:ShowNormalContent(element.SignBoardConfig.Content ~= nil and self.DialogTrigger) + self.PanelOpration.gameObject:SetActiveEx(element.SignBoardConfig.ShowButton ~= nil and self.OperateTrigger) + + --self.BtnPhoto.gameObject:SetActiveEx(false) + --self.BtnInteractive.gameObject:SetActiveEx(false) + -- self.BtnActivity.gameObject:SetActiveEx(false) + -- if element.SignBoardConfig.ShowButton ~= nil then + -- local btnIds = string.Split(element.SignBoardConfig.ShowButton, "|") + -- if btnIds and #btnIds > 0 then + -- for i, v in ipairs(btnIds) do + -- if v == "1" then + -- self.BtnPhoto.gameObject:SetActiveEx(not self.DisplayPanel.IsShow and self.OpenType == XUiPanelSignBoard.SignBoardOpenType.MAIN) + -- end + -- if v == "2" then + -- self.BtnInteractive.gameObject:SetActiveEx(self.OpenType == XUiPanelSignBoard.SignBoardOpenType.MAIN) + -- end + -- if v == "3" then + -- self.BtnActivity.gameObject:SetActiveEx(true) + -- end + -- end + -- end + -- end + if element.SignBoardConfig.CvId and element.SignBoardConfig.CvId > 0 and self.CvTrigger then + if element.CvType then + self:PlayCvWithCvType(element.SignBoardConfig.CvId, element.CvType) + else + self:PlayCv(element.SignBoardConfig.CvId) + end + end + + local actionId = element.SignBoardConfig.ActionId + if actionId then + self:PlayAnima(actionId) + self.RoleModel:LoadCharacterUiEffect(tonumber(element.SignBoardConfig.RoleId), actionId) + end + + if self.OpenType == XUiPanelSignBoard.SignBoardOpenType.MAIN then + self.Parent:PlayAnimation("AnimOprationBegan") + end +end + +--显示对白 +function XUiPanelSignBoard:ShowNormalContent(show) + self.PanelLayout.gameObject:SetActiveEx(show) + if show then -- 海外修改(打开操作看板操作按钮时,重置按钮转态,规避长按按钮消失BUG) + self.BtnReplace:SetButtonState(0) + self.BtnCoating:SetButtonState(0) + self.BtnCommunication:SetButtonState(0) + end +end + + +--显示操作按钮 +function XUiPanelSignBoard:ShowOprationBtn() + self.PanelOpration.gameObject:SetActiveEx(self.OperateTrigger) +end + +--显示对白 +function XUiPanelSignBoard:ShowContent(content) + self.PanelLayout.gameObject:SetActiveEx(content ~= nil) + self.TxtContent.text = content +end + +--播放CV +function XUiPanelSignBoard:PlayCv(cvId) + self.PlayingCv = CS.XAudioManager.PlayCv(cvId) +end + +function XUiPanelSignBoard:PlayCvWithCvType(cvId, cvType) + if self.PlayingAudio then + --正在播放语音页签下的语音,播放新动作需要打断语音并播放打断特效 + self.Parent.FavorabilityMain.FavorabilityAudio:UnScheduleAudio() + self.Parent:PlayChangeActionEffect() + self.PlayingAudio = false + end + + self.PlayingCv = CS.XAudioManager.PlayCvWithCvType(cvId, cvType) +end + +--是否在播放看板系统下语音页签的语音 +function XUiPanelSignBoard:SetPlayingAudio(value) + self.PlayingAudio = value +end + +--播放动作 +function XUiPanelSignBoard:PlayAnima(actionId) + self.RoleModel:PlayAnima(actionId, self.FromBegin) + self.FromBegin = nil +end + +--暂停 +function XUiPanelSignBoard:Pause() + if self.SignBoardPlayer then + self.SignBoardPlayer:Pause() + end +end + +--冻结 +function XUiPanelSignBoard:Freeze() + if self.SignBoardPlayer then + self.SignBoardPlayer:Freeze() + end +end + +--恢复播放 +function XUiPanelSignBoard:Resume() + if self.SignBoardPlayer then + self.SignBoardPlayer:Resume() + end +end + +--停止 +function XUiPanelSignBoard:Stop() + if self.SignBoardPlayer then + self.SignBoardPlayer:Stop() + end +end + +--停止 +function XUiPanelSignBoard:CvStop() + + if self.SignBoardPlayer then + self.SignBoardPlayer:Stop() + end + + if self.PlayingCv then + self.PlayingCv:Stop() + self.PlayingCv = nil + end + + self:ShowNormalContent(false) +end + +--停止 +function XUiPanelSignBoard:OnStop(playingElement) + if self.OpenType == XUiPanelSignBoard.SignBoardOpenType.MAIN then + if not self.Parent.GameObject.activeSelf then + return + end + self.Parent:PlayAnimation("AnimOprationEnd") + end + + if self.PlayingCv then + self.PlayingCv:Stop() + self.PlayingCv = nil + end + + self:ShowNormalContent(false) + + if playingElement then + local isChanged = XDataCenter.SignBoardManager.ChangeStandType(playingElement.SignBoardConfig.ChangeToStandType) + if isChanged then + self:ResetPlayList() + end + self.RoleModel:StopAnima(playingElement.SignBoardConfig.ActionId) + self.RoleModel:LoadCurrentCharacterDefaultUiEffect() + end +end + +--点击 +function XUiPanelSignBoard:OnBtnRoleClick() + if self.ClickTrigger then + self.MultClickHelper:Click() + end +end + +-- 强制播放 +-- 当动作页签调用时,会传入当前选择的CvType +-- isRecord决定是否记录当前播放的动作 +function XUiPanelSignBoard:ForcePlay(playId, cvType, fromBegin, isRecord) + local config = XSignBoardConfigs.GetSignBoardConfigById(playId) + + -- 从头开始播放动画,避免重复播放同一动画时继承上一个动画的进度 + self.FromBegin = fromBegin + self.SignBoardPlayer:ForcePlay(config, cvType, isRecord) +end + +function XUiPanelSignBoard:IsPlaying() + return self.SignBoardPlayer:IsPlaying() +end + +--多点回调 +function XUiPanelSignBoard:OnMultClick(clickTimes) + + local config + if self.SignBoardPlayer:IsPlaying() and not self.CanBreakTrigger then + return + end + + self.CanBreakTrigger = false + + config = XDataCenter.SignBoardManager.GetRandomPlayElementsByClick(clickTimes, self.DisplayCharacterId) + + -- 从头开始播放动画,避免重复播放同一动画时继承上一个动画的进度 + self.FromBegin = true + self.SignBoardPlayer:ForcePlay(config, nil, true) +end + +--设置自动播放 +function XUiPanelSignBoard:SetAutoPlay(bAutoPlay) + self.AutoPlay = bAutoPlay + self.SignBoardPlayer:SetAutoPlay(bAutoPlay) +end + +-- 播放队列是否只播放权重最高的动画 +function XUiPanelSignBoard:SetPlayOne(bPlayOne) + self.PlayOne = bPlayOne + self.SignBoardPlayer:SetPlayOne(bPlayOne) +end + +--操作开关 +function XUiPanelSignBoard:SetOperateTrigger(bTriggeer) + self.OperateTrigger = bTriggeer + if not bTriggeer then + self.PanelOpration.gameObject:SetActiveEx(false) + end +end + +--对话开关 +function XUiPanelSignBoard:SetDialogTrigger(bTriggeer) + self.DialogTrigger = bTriggeer + if not bTriggeer then + self.PanelLayout.gameObject:SetActiveEx(false) + end +end + +--点击开关 +function XUiPanelSignBoard:SetClickTrigger(bTriggeer) + self.ClickTrigger = bTriggeer +end + +---==================== +--- 设置是否检测陀螺仪摇晃 +---@param value boolean +---==================== +function XUiPanelSignBoard:SetRoll(value) + self.Acceleration.enabled = value +end + +return XUiPanelSignBoard \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMain/XUiMain.lua b/Resources/Scripts/XUi/XUiMain/XUiMain.lua new file mode 100644 index 00000000..b2180c3f --- /dev/null +++ b/Resources/Scripts/XUi/XUiMain/XUiMain.lua @@ -0,0 +1,344 @@ +local XUiMainDown = require("XUi/XUiMain/XUiMainDown") + +local XUiMain = XLuaUiManager.Register(XLuaUi, "UiMain") + +local CameraIndex = { + Main = 1, + MainEnter = 2, + MainChatEnter = 3, +} + +local MenuType = { + Main = 1, + Second = 2, +} + +XUiMain.LowPowerState = { + Full = 1, + Low = 2, + LowToFull = 3, + FullToLow = 4, +} + +local RightMidType = MenuType.Main + +function XUiMain:OnAwake() + --BDC + CS.XHeroBdcAgent.BdcIntoGame(CS.UnityEngine.Time.time) + + self.RightTop = XUiMainRightTop.New(self) --右上角组件(资源、电量、时间、设置、邮件……) + self.RightMid = XUiMainRightMid.New(self) --右中角组件(各种功能……) + + self.RightMidSecond = XUiMainRightMidSecond.New(self) -- 右中角二级菜单 + self.RightBottom = XUiMainRightBottom.New(self) --右下角组件(各个大功能入口……) + + self.LeftTop = XUiMainLeftTop.New(self) --左上角组件(玩家信息……) + self.LeftMid = XUiMainLeftMid.New(self) --左中角组件(自动战斗、过期提醒……) + self.LeftBottom = XUiMainLeftBottom.New(self) --左下角组件(公告、好友、福利、AD、聊天……) + self.Other = XUiMainOther.New(self) --其他组件(角色触摸、截图……) + self.Down = XUiMainDown.New(self, self.PanelDown) --底部组件(战斗通行证……) + -- self.AreanOnline = XUiPanelArenaOnline.New(self, self.PanelArenaOnline) --屏蔽合众战局 + + self.PreEnterFightCallback = function() self:OnPreEnterFight() end + XEventManager.AddEventListener(XEventId.EVENT_PRE_ENTER_FIGHT, self.PreEnterFightCallback) +end + +function XUiMain:OnStart() + -- 注销后重新登录 主界面默认不显示二级菜单 + if XLoginManager.IsFirstOpenMainUi() then + RightMidType = MenuType.Main + end + + -- 二级菜单切换按钮 + self.BtnMain.CallBack = function() self:OnBtnMain() end + self.BtnSecond.CallBack = function() self:OnBtnSecond() end + +end + +function XUiMain:OnEnable() + if XDataCenter.GuideManager.CheckIsInGuide() then + RightMidType = MenuType.Main + end + if XDataCenter.PokemonManager then + XDataCenter.PokemonManager.ResetSpeed() + end + + -- 刷新二级菜单 + self:UpdateRightMenu() + + -- 每次打开的时候重新加载一下场景 + local curSceneId = XDataCenter.PhotographManager.GetCurSceneId() + local curSceneTemplate = XDataCenter.PhotographManager.GetSceneTemplateById(curSceneId) + local curSceneUrl, _ = XSceneModelConfigs.GetSceneAndModelPathById(curSceneTemplate.SceneModelId) + local modelUrl = self:GetDefaultUiModelUrl() + self:LoadUiScene(curSceneUrl, modelUrl, function() self:OnUiSceneLoaded(curSceneTemplate.ParticleGroupName) end, false) + + self:PlayEnterAnim() + XRedPointManager.AutoReleseRedPointEvent() + self.LeftTop:OnEnable() + self.LeftMid:OnEnable() + self.LeftBottom:OnEnable() + self.RightMid:OnEnable() + self.RightMidSecond:OnEnable() + self.RightTop:OnEnable() + self.RightBottom:OnEnable() + self.Other:OnEnable() + self:SetCacheFight() + self:SetScreenAdaptorCache() + XDataCenter.SetManager.SetSceneUIType() + self:AreanOnlineInviteNotify() + self.Down:OnEnable() +end + +function XUiMain:OnDisable() + self.LeftTop:OnDisable() + self.LeftMid:OnDisable() + self.LeftBottom:OnDisable() + self.RightMid:OnDisable() + self.RightMidSecond:OnDisable() + self.Other:OnDisable() + self.RightBottom:OnDisable() + self.RightTop:OnDisable() + self.Down:OnDisable() +end + +function XUiMain:OnDestroy() + self.LeftBottom:OnDestroy() + self.Other:OnDestroy() + self.RightTop:OnDestroy() + XEventManager.RemoveEventListener(XEventId.EVENT_PRE_ENTER_FIGHT, self.PreEnterFightCallback) +end + +function XUiMain:OnNotify(evt, ...) + if evt == XEventId.EVENT_CHAT_OPEN then + --打开聊天界面 + self:PlayMainChatIn() + elseif evt == XEventId.EVENT_CHAT_CLOSE then + --聊天界面关闭 + self:PlayMainChatOut() + elseif evt == XEventId.EVENT_CHAT_RECEIVE_PRIVATECHAT then + -- self.AreanOnline:Show(...) + elseif evt == XEventId.EVENT_GUIDE_START then + -- 进行新手引导时,切换显示为主菜单 + self:OnBtnMain() + end + + self.LeftBottom:OnNotify(evt) + self.RightMid:OnNotify(evt) + self.RightTop:OnNotify(evt) +end + +function XUiMain:OnPreEnterFight() + self:LoadUiScene("" , "") -- 释放主界面角色场景 +end + +function XUiMain:AreanOnlineInviteNotify() + local chatdata = XDataCenter.ArenaOnlineManager.GetPrivateChatData() + if not chatdata or not next(chatdata)then + return + end + + XLuaUiManager.Open("UiArenaOnlineInvitation") +end + +function XUiMain:OnGetEvents() + return { + XEventId.EVENT_CHAT_OPEN, + XEventId.EVENT_CHAT_CLOSE, + XEventId.EVENT_NOTICE_PIC_CHANGE, + XEventId.EVENT_TASKFORCE_INFO_NOTIFY, + XEventId.EVENT_ACTIVITY_MAINLINE_STATE_CHANGE, + XEventId.EVENT_MAIL_COUNT_CHANGE, + XEventId.EVENT_CHAT_RECEIVE_PRIVATECHAT, + XEventId.EVENT_GUIDE_START, + } +end + +--初始化摄像机 +function XUiMain:InitSceneRoot(particleGroupName) + local root = self.UiModelGo.transform + self.CameraFar = { + [CameraIndex.Main] = self:FindVirtualCamera("CamFarMain"), + [CameraIndex.MainEnter] = self:FindVirtualCamera("CamFarMainEnter"), + [CameraIndex.MainChatEnter] = self:FindVirtualCamera("CamFarMainChatEnter"), + } + self.CameraNear = { + [CameraIndex.Main] = self:FindVirtualCamera("CamNearMain"), + [CameraIndex.MainEnter] = self:FindVirtualCamera("CamNearMainEnter"), + [CameraIndex.MainChatEnter] = self:FindVirtualCamera("CamNearMainChatEnter"), + } + + --主页面电量特效相关 + local sceneRoot = self.UiSceneInfo.Transform + if particleGroupName and particleGroupName ~= "" then + self.ChargeAnimator = sceneRoot:FindTransform(particleGroupName):GetComponent("Animator") + else + self.ChargeAnimator = nil + end + self.ToChargePD = sceneRoot:Find("Animations/ToChargeTimeLine") + self.ToFullPD = sceneRoot:Find("Animations/ToFullTimeLine") + self.FullPD = sceneRoot:Find("Animations/FullTimeLine") + self.ChargePD = sceneRoot:Find("Animations/ChargeTimeLine") +end + +function XUiMain:ChangeLowPowerPartical(state) + if self.ChargeAnimator then + if state == self.LowPowerState.Full then + self.ChargeAnimator:Play("Full") + elseif state == self.LowPowerState.Low then + self.ChargeAnimator:Play("Low") + elseif state == self.LowPowerState.LowToFull then + self.ChargeAnimator:Play("LowToFull") + elseif state == self.LowPowerState.FullToLow then + self.ChargeAnimator:Play("FullToLow") + end + end +end + +function XUiMain:ChangeLowPowerTimeLine(state) + if self.ToChargePD then self.ToChargePD.gameObject:SetActiveEx(false) end + if self.ToFullPD then self.ToFullPD.gameObject:SetActiveEx(false) end + if self.FullPD then self.FullPD.gameObject:SetActiveEx(false) end + if self.ChargePD then self.ChargePD.gameObject:SetActiveEx(false) end + + if state == self.LowPowerState.Full then + if self.FullPD then self.FullPD.gameObject:SetActiveEx(true) end + elseif state == self.LowPowerState.Low then + if self.ChargePD then self.ChargePD.gameObject:SetActiveEx(true) end + elseif state == self.LowPowerState.LowToFull then + if self.ToFullPD then self.ToFullPD.gameObject:SetActiveEx(true) end + elseif state == self.LowPowerState.FullToLow then + if self.ToChargePD then self.ToChargePD.gameObject:SetActiveEx(true) end + end +end + +function XUiMain:ChangeLowPowerState(state) + self:ChangeLowPowerPartical(state) + self:ChangeLowPowerTimeLine(state) +end + +function XUiMain:UpdateCamera(camera) + for _, cameraIndex in pairs(CameraIndex) do + self.CameraNear[cameraIndex].gameObject:SetActive(cameraIndex == camera) + self.CameraFar[cameraIndex].gameObject:SetActive(cameraIndex == camera) + end +end + +function XUiMain:UpdateRightMenu() + -- 根据状态控制右侧面板的显隐 + + self.BtnSecond.gameObject:SetActiveEx(RightMidType == MenuType.Main) + self.PanelRightBottom.gameObject:SetActiveEx(RightMidType == MenuType.Main) + self.PanelRightMid.gameObject:SetActiveEx(RightMidType == MenuType.Main) + + self.BtnMain.gameObject:SetActiveEx(RightMidType == MenuType.Second) + self.PanelRightMidSecond.gameObject:SetActiveEx(RightMidType == MenuType.Second) + + if RightMidType == MenuType.Second then + self.RightMidSecond:RefreshMenu() + end +end + +--播放主界面打开动画 +function XUiMain:PlayEnterAnim() + local anim, endCb + if XLoginManager.IsFirstOpenMainUi() then + anim = "AnimEnter" + else + anim = "AnimReenter" + end + XLuaUiManager.SetMask(true) + endCb = function() + if XLoginManager.IsFirstOpenMainUi() then + anim = "AnimEnter2" + self:PlayAnimation(anim, endCb) + self:UpdateCamera(CameraIndex.Main) + XLoginManager.SetFirstOpenMainUi(false) + else + XLoginManager.SetStartGuide(true) + XEventManager.DispatchEvent(XEventId.EVENT_MAINUI_ENABLE) + XEventManager.DispatchEvent(XEventId.EVENT_CARD_REFRESH_WELFARE_BTN) + XLuaUiManager.SetMask(false) + end + end + self:PlayAnimation(anim, endCb) +end + +--播放关闭聊天动画 +function XUiMain:PlayMainChatOut() + self:UpdateCamera(CameraIndex.Main) + self:PlayAnimation("AnimChatIn") +end + +--播放打开聊天动画 +function XUiMain:PlayMainChatIn() + self:UpdateCamera(CameraIndex.MainChatEnter) + self:PlayAnimation("AnimChatOut") +end + +function XUiMain:SetCacheFight() + if not self.IsFirstSetFight then + self.IsFirstSetFight = true + XDataCenter.SetManager.SetAllyDamageByCache() + XDataCenter.SetManager.SetAllyEffectByCache() + XDataCenter.SetManager.SetOwnFontSizeByCache() + XDataCenter.SetManager.SetDefaultFontSize() + XDataCenter.SetManager.SetScreenOff() + end +end + +function XUiMain:SetScreenAdaptorCache() + if XDataCenter.SetManager.IsAdaptorScreen() and not XTool.UObjIsNil(self.SafeAreaContentPane) then + self.SafeAreaContentPane:UpdateSpecialScreenOff() + end +end + +-- 设置福利按钮特效可见性 +function XUiMain:SetBtnWelfareTagActive(active) + self.LeftBottom:SetBtnWelfareTagActive(active) +end + +-- 回到主页按钮 +function XUiMain:OnBtnMain() + if RightMidType == MenuType.Main then return end + + RightMidType = MenuType.Main + + self.BtnSecond.gameObject:SetActiveEx(true) + self.BtnMain.gameObject:SetActiveEx(false) + + self.PanelRightBottom.gameObject:SetActiveEx(true) + self.PanelRightMid.gameObject:SetActiveEx(true) + + self:PlayAnimationWithMask("AnimPanelRightMid", function() + self.PanelRightMidSecond.gameObject:SetActiveEx(false) + end) +end + +-- 下一页按钮(主界面二级菜单) +function XUiMain:OnBtnSecond() + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.SubMenu) then return end + RightMidType = MenuType.Second + self.RightMidSecond:RefreshMenu() + + self.BtnMain.gameObject:SetActiveEx(true) + self.BtnSecond.gameObject:SetActiveEx(false) + self.PanelRightMidSecond.gameObject:SetActiveEx(true) + + self:PlayAnimationWithMask("AnimPanelRightMidSecond", function() + self.PanelRightMid.gameObject:SetActiveEx(false) + self.PanelRightBottom.gameObject:SetActiveEx(false) + end) +end + +function XUiMain:OnUiSceneLoaded(particleGroupName) + self:SetGameObject() + self:InitSceneRoot(particleGroupName) + self.Other.SignBoard = XUiPanelSignBoard.New(self.Other.PanelSignBoard, self, XUiPanelSignBoard.SignBoardOpenType.MAIN) + if XLoginManager.IsFirstOpenMainUi() then + self:SetBtnWelfareTagActive(false) + self:UpdateCamera(CameraIndex.MainEnter) + else + self:UpdateCamera(CameraIndex.Main) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMain/XUiMainDown.lua b/Resources/Scripts/XUi/XUiMain/XUiMainDown.lua new file mode 100644 index 00000000..70321940 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMain/XUiMainDown.lua @@ -0,0 +1,69 @@ +local XUiMainDown = XClass(nil, "XUiMainDown") + +function XUiMainDown:Ctor(rootUi, ui) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + if self.BtnPassport then + self.BtnPassport.CallBack = function() self:OnBtnPassportClick() end + end + + --RedPoint + XRedPointManager.AddRedPointEvent(self.BtnPassport.ReddotObj, self.OnCheckPassportRedPoint, self, { XRedPointConditions.Types.CONDITION_PASSPORT_RED }) +end + +function XUiMainDown:OnEnable() + self:OnPassportOpenStatusUpdate() +end + +function XUiMainDown:OnDisable() + self:StopPassportTimer() +end + +--战斗通行证 +function XUiMainDown:OnBtnPassportClick() + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.Passport) then + return + end + XLuaUiManager.Open("UiPassport") +end + +function XUiMainDown:OnPassportOpenStatusUpdate() + if XDataCenter.PassportManager.IsActivityClose() then + self.BtnPassport.gameObject:SetActiveEx(false) + else + self:StopPassportTimer() + self:UpdatePassportLeftTime() + self.PassportTimer = XScheduleManager.ScheduleForever(function() + self:UpdatePassportLeftTime() + end, XScheduleManager.SECOND, 0) + end +end + +function XUiMainDown:StopPassportTimer() + if self.PassportTimer then + XScheduleManager.UnSchedule(self.PassportTimer) + self.PassportTimer = nil + end +end + +function XUiMainDown:UpdatePassportLeftTime() + local timeId = XPassportConfigs.GetPassportActivityTimeId() + if XFunctionManager.CheckInTimeByTimeId(timeId) then + self.BtnPassport.gameObject:SetActiveEx(true) + elseif XDataCenter.PassportManager.IsActivityClose() then + self:StopPassportTimer() + self:OnPassportOpenStatusUpdate() + else + self.BtnPassport.gameObject:SetActiveEx(false) + end +end + +--战斗通行证红点 +function XUiMainDown:OnCheckPassportRedPoint(count) + self.BtnPassport:ShowReddot(count >= 0) +end + +return XUiMainDown \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMain/XUiMainLeftBottom.lua b/Resources/Scripts/XUi/XUiMain/XUiMainLeftBottom.lua new file mode 100644 index 00000000..d3e94273 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMain/XUiMainLeftBottom.lua @@ -0,0 +1,231 @@ +local XUiPanelAd = require("XUi/XUiMain/XUiChildView/XUiPanelAd") +XUiMainLeftBottom = XClass(nil, "XUiMainLeftBottom") +local CSXTextManagerGetText = CS.XTextManager.GetText +local MAX_CHAT_WIDTH = 395 +-- local CHAT_SUB_LENGTH = 18 + +function XUiMainLeftBottom:Ctor(rootUi) + self.Transform = rootUi.PanelLeftBottom.gameObject.transform + XTool.InitUiObject(self) + --ClickEvent + self.BtnNotice.CallBack = function() self:OnBtnNotice() end + self.BtnSocial.CallBack = function() self:OnBtnSocial() end + self.BtnMentor.CallBack = function() self:OnBtnMentor() end + self.BtnWelfare.CallBack = function() self:OnBtnWelfare() end + self.BtnChat.CallBack = function() self:OnBtnChat() end + self.BtnWelfare:ShowTag(false) -- 海外修改 + --RedPoint + XRedPointManager.AddRedPointEvent(self.BtnSocial.ReddotObj, self.OnCheckSocialNews, self, { XRedPointConditions.Types.CONDITION_MAIN_FRIEND }) + XRedPointManager.AddRedPointEvent(self.BtnMentor.ReddotObj, self.OnCheckMentorNews, self, { XRedPointConditions.Types.CONDITION_MENTOR_APPLY_RED, XRedPointConditions.Types.CONDITION_MENTOR_REWARD_RED, XRedPointConditions.Types.CONDITION_MENTOR_TASK_RED}) + self.RedPoinWelfareId = XRedPointManager.AddRedPointEvent(self.BtnWelfare.ReddotObj, self.OnCheckWalfarelNews, self, { XRedPointConditions.Types.CONDITION_PURCHASE_GET_RERARGE, XRedPointConditions.Types.CONDITION_PURCHASE_GET_CARD, XRedPointConditions.Types.CONDITION_NEWYEARDIVINING_NOTGET, XRedPointConditions.Types.CONDITION_FIREWORKS_AVAILABLE}) + self.RedPoinFirstRechargeId = XRedPointManager.AddRedPointEvent(self.BtnWelfare.TagObj, self.OnCheckFirstRecharge, self, { XRedPointConditions.Types.CONDITION_PURCHASE_GET_RERARGE }) + self.BtnNoticeRedId = XRedPointManager.AddRedPointEvent(self.BtnNotice.ReddotObj, self.OnCheckNoticeNews, self, { XRedPointConditions.Types.CONDITION_MAIN_NOTICE }) + self:InitChatMsg() + + --Filter + self:CheckFilterFunctions() +end + +function XUiMainLeftBottom:OnEnable() + + XEventManager.AddEventListener(XEventId.EVENT_CHAT_RECEIVE_WORLD_MSG, self.RefreshChatMsg, self) + XEventManager.AddEventListener(XEventId.EVENT_GUILD_RECEIVE_CHAT, self.RefreshChatMsg, self) + XEventManager.AddEventListener(XEventId.EVENT_CHAT_RECEIVE_MENTOR_MSG, self.RefreshChatMsg, self) + XEventManager.AddEventListener(XEventId.EVENT_CARD_REFRESH_WELFARE_BTN, self.OnRefreshWalfareId, self) + XEventManager.AddEventListener(XEventId.EVENT_CARD_REFRESH_WELFARE_BTN, self.OnRefreshFirstRechargeId, self) + self:UpdatePanelAd() + self:OnRefreshNoticeId() + self:OnRefreshWalfareId() + self:OnRefreshFirstRechargeId() + + self.BtnWelfare:SetDisable(not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.Welfare)) + + -- 每次进入主界面,满足条件后可以获取邀请码信息,用来刷新活动公告按钮的红点状态 + XDataCenter.RegressionManager.HandleGetInvitationCodeInfoRequest() + self:RefreshChatMsg(XDataCenter.ChatManager.GetLatestChatData()) + + XDataCenter.MentorSystemManager.ShowMentorShipComplete()--进入主界面时检测有无新师徒关系建立 +end + +function XUiMainLeftBottom:OnDisable() + XEventManager.RemoveEventListener(XEventId.EVENT_CHAT_RECEIVE_WORLD_MSG, self.RefreshChatMsg, self) + XEventManager.RemoveEventListener(XEventId.EVENT_GUILD_RECEIVE_CHAT, self.RefreshChatMsg, self) + XEventManager.RemoveEventListener(XEventId.EVENT_CHAT_RECEIVE_MENTOR_MSG, self.RefreshChatMsg, self) + XEventManager.RemoveEventListener(XEventId.EVENT_CARD_REFRESH_WELFARE_BTN, self.OnRefreshWalfareId, self) + XEventManager.RemoveEventListener(XEventId.EVENT_CARD_REFRESH_WELFARE_BTN, self.OnRefreshFirstRechargeId, self) +end + +function XUiMainLeftBottom:OnDestroy() + if self.PanelAdObj then + self.PanelAdObj:OnDestroy() + end +end + +function XUiMainLeftBottom:OnNotify(evt) + if evt == XEventId.EVENT_NOTICE_PIC_CHANGE then + self:UpdatePanelAd() + end +end + +function XUiMainLeftBottom:CheckFilterFunctions() + self.PanelAd.gameObject:SetActiveEx(not XUiManager.IsHideFunc) + self.BtnNotice.gameObject:SetActiveEx(not XUiManager.IsHideFunc) + self.BtnSocial.gameObject:SetActiveEx(not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.SocialFriend)) + self.BtnMentor.gameObject:SetActiveEx(not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.MentorSystem)) + self.BtnWelfare.gameObject:SetActiveEx(not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.Welfare)) + self.BtnChat.gameObject:SetActiveEx(not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.SocialChat)) +end + +--公告入口 +function XUiMainLeftBottom:OnBtnNotice() + XLuaUiManager.OpenWithCallback("UiActivityBase", function () + if XLuaUiManager.IsUiLoad("UiDialog") or XLuaUiManager.IsUiLoad("UiBuyAsset") or XLuaUiManager.IsUiLoad("UiSystemDialog") or XLuaUiManager.IsUiLoad("UiUsePackage") then + XLuaUiManager.Close("UiActivityBase") + end + end) +end + +--好友入口 +function XUiMainLeftBottom:OnBtnSocial() + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.SocialFriend) then + return + end + XLuaUiManager.Open("UiSocial") +end + +--福利入口 +function XUiMainLeftBottom:OnBtnWelfare() + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.Welfare) then + return + end + self:OnRefreshWalfareId() + CS.XHeroBdcAgent.BdcWelfareClick()--新增打点记录 + XLuaUiManager.Open("UiSign") +end + +--师徒入口 +function XUiMainLeftBottom:OnBtnMentor() + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.MentorSystem) then + return + end + XLuaUiManager.Open("UiMentorMain") +end + +--聊天入口 +function XUiMainLeftBottom:OnBtnChat() + if XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.SocialChat) then + self.BtnWelfare:ShowTag(false) + XLuaUiManager.Open("UiChatServeMain", true, ChatChannelType.World) + end +end + +-- 设置福利按钮特效可见性 +function XUiMainLeftBottom:SetBtnWelfareTagActive(active) + self.BtnWelfare:ShowTag(active) +end + +--更新聊天 +function XUiMainLeftBottom:RefreshChatMsg(chatDataLua) + if not chatDataLua then return end + if not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.SocialChat) then + return + end + + if chatDataLua.ChannelType == ChatChannelType.World then + self.TxtMessageType.text = CSXTextManagerGetText("ChatWorldMsg") + elseif chatDataLua.ChannelType == ChatChannelType.Private then + self.TxtMessageType.text = CSXTextManagerGetText("ChatPrivateMsg") + elseif chatDataLua.ChannelType == ChatChannelType.System then + self.TxtMessageType.text = CSXTextManagerGetText("ChatSystemMsg") + elseif chatDataLua.ChannelType == ChatChannelType.Guild then + self.TxtMessageType.text = CSXTextManagerGetText("ChatGuildMsg") + elseif chatDataLua.ChannelType == ChatChannelType.Mentor then + self.TxtMessageType.text = CSXTextManagerGetText("ChatMentorMsg") + end + + local name = XDataCenter.SocialManager.GetPlayerRemark(chatDataLua.SenderId, chatDataLua.NickName) + if chatDataLua.MsgType == ChatMsgType.Emoji then + self.TxtMessageContent.text = string.format("%s:%s", name, CSXTextManagerGetText("EmojiText")) + elseif chatDataLua.MsgType == ChatMsgType.System and chatDataLua.ChannelType == ChatChannelType.Guild then + local content = string.format("%s:%s", CSXTextManagerGetText("GuildChannelTypeAll"), chatDataLua.Content) + self.TxtMessageContent.text = content + else + self.TxtMessageContent.text = string.format("%s:%s", name, chatDataLua.Content) + end + self.TxtMessageLabel.gameObject:SetActiveEx(XUiHelper.CalcTextWidth(self.TxtMessageContent) > MAX_CHAT_WIDTH) +end + +function XUiMainLeftBottom:InitChatMsg() + self.TxtMessageType.text = "" + self.TxtMessageContent.text = "" +end + +--更新福利红点 +function XUiMainLeftBottom:OnRefreshWalfareId() + if self.RedPoinWelfareId then + XRedPointManager.Check(self.RedPoinWelfareId) + end +end + +function XUiMainLeftBottom:OnRefreshNoticeId() + if self.BtnNoticeRedId then + XRedPointManager.Check(self.BtnNoticeRedId) + end +end + + +--更新首充特效 +function XUiMainLeftBottom:OnRefreshFirstRechargeId() + if XLoginManager.IsFirstOpenMainUi() then + return + end + + if self.RedPoinFirstRechargeId then + XRedPointManager.Check(self.RedPoinFirstRechargeId) + end +end + +--更新滚动广告 +function XUiMainLeftBottom:UpdatePanelAd() + if XUiManager.IsHideFunc then return end + if self.PanelAdObj then + self.PanelAdObj:UpdateAdList() + else + self.PanelAdObj = XUiPanelAd.New(self, self.PanelAd) + end +end + +--好友红点 +function XUiMainLeftBottom:OnCheckSocialNews(count) + self.BtnSocial:ShowReddot(count >= 0 and XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.SocialFriend)) +end + +--师徒红点 +function XUiMainLeftBottom:OnCheckMentorNews(count) + self.BtnMentor:ShowReddot(count >= 0 and XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.MentorSystem)) +end + +--福利红点 +function XUiMainLeftBottom:OnCheckWalfarelNews(count) + self.BtnWelfare:ShowReddot(count >= 0) +end + +--首充特效 +function XUiMainLeftBottom:OnCheckFirstRecharge(count) -- 海外修改 + local showTag = count >= 0 + if showTag then + CS.XScheduleManager.ScheduleOnce(function() + self.BtnWelfare:ShowTag(showTag) + end, 1) + else + self.BtnWelfare:ShowTag(showTag) + end + if XLuaUiManager.IsUiShow("UiChatServeMain") then --防止聊天时点击头像跳转指挥官界面再返回出现特效覆盖在聊天界面上问题 + self.BtnWelfare:ShowTag(false) + end +end + +--公告红点 +function XUiMainLeftBottom:OnCheckNoticeNews(count) + self.BtnNotice:ShowReddot(count >= 0) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMain/XUiMainLeftMid.lua b/Resources/Scripts/XUi/XUiMain/XUiMainLeftMid.lua new file mode 100644 index 00000000..01be6aa7 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMain/XUiMainLeftMid.lua @@ -0,0 +1,113 @@ +XUiMainLeftMid = XClass(nil, "XUiMainLeftMid") +local TextManager = CS.XTextManager + +function XUiMainLeftMid:Ctor(rootUi) + self.Transform = rootUi.PanelLeftMid.gameObject.transform + XTool.InitUiObject(self) + self.RootUi = rootUi + --ClickEvent + self.BtnGiftExpire.CallBack = function() self:OnBtnGiftExpire() end + self.BtnYKExpire.CallBack = function() self:OnBtnYKExpire() end + self.BtnAutoFight.CallBack = function() self:OnBtnAutoFight() end + --RedPoint + --Filter + self:CheckFilterFunctions() + self.BtnYKExpire:SetNameByGroup(0,CS.XTextManager.GetText("PurchaseYKExpireDes")) +end + +function XUiMainLeftMid:OnEnable() + self.PanelAutoFight.gameObject:SetActive(XDataCenter.AutoFightManager.GetRecordCount() > 0) + XEventManager.AddEventListener(XEventId.EVENT_AUTO_FIGHT_START, self.OnAutoFightStart, self) + XEventManager.AddEventListener(XEventId.EVENT_AUTO_FIGHT_CHANGE, self.OnAutoFightChange, self) + XEventManager.AddEventListener(XEventId.EVENT_AUTO_FIGHT_REMOVE, self.OnAutoFightRemove, self) + XEventManager.AddEventListener(XEventId.EVENT_PURCAHSE_YKMAINREFRESH, self.UpdateYKExpire, self) + -- XEventManager.AddEventListener(XEventId.EVENT_LB_EXPIRE_NOTIFY, self.UpdatePurchaseGift, self) + self:SetPurchaseGiftExpire() + self:UpdateYKExpire() +end + +function XUiMainLeftMid:OnDisable() + XEventManager.RemoveEventListener(XEventId.EVENT_AUTO_FIGHT_START, self.OnAutoFightStart, self) + XEventManager.RemoveEventListener(XEventId.EVENT_AUTO_FIGHT_CHANGE, self.OnAutoFightChange, self) + XEventManager.RemoveEventListener(XEventId.EVENT_AUTO_FIGHT_REMOVE, self.OnAutoFightRemove, self) + XEventManager.RemoveEventListener(XEventId.EVENT_PURCAHSE_YKMAINREFRESH, self.UpdateYKExpire, self) + -- XEventManager.RemoveEventListener(XEventId.EVENT_LB_EXPIRE_NOTIFY, self.UpdatePurchaseGift, self) + self.PanelGiftExpire.gameObject:SetActiveEx(false) +end + +function XUiMainLeftMid:CheckFilterFunctions() + self.BtnGiftExpire.gameObject:SetActiveEx(not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.Deposit)) +end + +function XUiMainLeftMid:OnBtnGiftExpire() + XLuaUiManager.Open("UiPurchase", XPurchaseConfigs.TabsConfig.LB) +end + +function XUiMainLeftMid:OnBtnYKExpire() + XLuaUiManager.Open("UiPurchase", XPurchaseConfigs.TabsConfig.YK) +end + +function XUiMainLeftMid:OnBtnAutoFight() + XLuaUiManager.Open("UiAutoFightList") +end + +--自动战斗 +function XUiMainLeftMid:OnAutoFightStart() + if not self.PanelAutoFight.gameObject.activeSelf then + self.PanelAutoFight.gameObject:SetActive(true) + end +end + +--自动战斗 +function XUiMainLeftMid:OnAutoFightChange(count) + local active = count > 0 + local go = self.ImgAutoFightRedPoint.gameObject + if go.activeSelf == active then + return + end + go:SetActive(active) +end + +--自动战斗 +function XUiMainLeftMid:OnAutoFightRemove() + local cnt = XDataCenter.AutoFightManager.GetRecordCount() + if cnt > 0 then + return + end + local go = self.PanelAutoFight.gameObject + if go.activeSelf == false then + return + end + go:SetActive(false) +end + +-- 礼包 +function XUiMainLeftMid:UpdatePurchaseGift(count) + if count == 0 or count == nil then + self.PanelGiftExpire.gameObject:SetActiveEx(false) + else + self.PanelGiftExpire.gameObject:SetActiveEx(true) + if count == 1 then + self.BtnGiftExpire:SetName(TextManager.GetText("PurchaseGiftValitimeTips1")) + else + self.BtnGiftExpire:SetName(TextManager.GetText("PurchaseGiftValitimeTips2")) + end + end +end + +-- 月卡 +function XUiMainLeftMid:UpdateYKExpire() + XDataCenter.PurchaseManager.SetYKLoaclCache() + local flag = XDataCenter.PurchaseManager.CheckYKContinueBuy() + self.PanelYKExpire.gameObject:SetActiveEx(flag) +end + +function XUiMainLeftMid:SetPurchaseGiftExpire() + if self.IsFirstExpire then + return + end + + self.IsFirstExpire = true + local count = XDataCenter.PurchaseManager.ExpireCount + self:UpdatePurchaseGift(count) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMain/XUiMainLeftTop.lua b/Resources/Scripts/XUi/XUiMain/XUiMainLeftTop.lua new file mode 100644 index 00000000..8795e19c --- /dev/null +++ b/Resources/Scripts/XUi/XUiMain/XUiMainLeftTop.lua @@ -0,0 +1,127 @@ +XUiMainLeftTop = XClass(nil, "XUiMainLeftTop") + +local Vector3 = CS.UnityEngine.Vector3 +local DOTween = CS.DG.Tweening.DOTween + +local MusicPlayerTextMoveSpeed = CS.XGame.ClientConfig:GetFloat("MusicPlayerMainViewTextMoveSpeed") +local MusicPlayerTextMovePauseInterval = CS.XGame.ClientConfig:GetFloat("MusicPlayerMainViewTextMovePauseInterval") + +function XUiMainLeftTop:Ctor(rootUi) + self.Transform = rootUi.PanelLeftTop.gameObject.transform + XTool.InitUiObject(self) + self:UpdateInfo() + --ClickEvent + self.BtnRoleInfo.CallBack = function() self:OnBtnRoleInfo() end + self.BtnMusicPlayer.CallBack = function() self:OnBtnMusicPlayer() end + --RedPoint + XRedPointManager.AddRedPointEvent(self.BtnRoleInfo.ReddotObj, self.OnCheckRoleNews, self, { XRedPointConditions.Types.CONDITION_PLAYER_ACHIEVE, XRedPointConditions.Types.CONDITION_PLAYER_SETNAME, XRedPointConditions.Types.CONDITION_EXHIBITION_NEW, XRedPointConditions.Types.CONDITION_HEADPORTRAIT_RED, XRedPointConditions.Types.CONDITION_MEDAL_RED,}) + + --Filter + self:CheckFilterFunctions() +end + +function XUiMainLeftTop:OnEnable() + self:UpdateInfo() + if not self.TweenSequenceTxtMusicPlayer then + self:UpdateMusicPlayerText() + elseif self.IsNeedRefreshTweenSequence then + self.TweenSequenceTxtMusicPlayer:Kill() + self:UpdateMusicPlayerText() + self.IsNeedRefreshTweenSequence = false + else + self.TweenSequenceTxtMusicPlayer:Play() + end + if XUiManager.IsHideFunc then + self.BtnMusicPlayer.gameObject:SetActiveEx(false) + end + XEventManager.AddEventListener(XEventId.EVENT_PLAYER_LEVEL_CHANGE, self.UpdateInfo, self) +end + +function XUiMainLeftTop:OnDisable() + if self.TweenSequenceTxtMusicPlayer then + self.TweenSequenceTxtMusicPlayer:Pause() + end + XEventManager.RemoveEventListener(XEventId.EVENT_PLAYER_LEVEL_CHANGE, self.UpdateInfo, self) +end + +function XUiMainLeftTop:OnDestroy() + if self.TweenSequenceTxtMusicPlayer then + self.TweenSequenceTxtMusicPlayer:Kill() + self.TweenSequenceTxtMusicPlayer = nil + end +end + +function XUiMainLeftTop:CheckFilterFunctions() + self.BtnRoleInfo.gameObject:SetActiveEx(not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.Player)) +end + +--个人详情入口 +function XUiMainLeftTop:OnBtnRoleInfo() + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.Player) then + return + end + XLuaUiManager.Open("UiPlayer") +end + +function XUiMainLeftTop:OnBtnMusicPlayer() + XLuaUiManager.Open("UiMusicPlayer", function() self:OnUiMusicPlayerCloseCallback() end) +end + +--@region 更新等级经验等 + +function XUiMainLeftTop:UpdateInfo() + local curExp = XPlayer.Exp + local maxExp = XPlayer:GetMaxExp() + local fillAmount = curExp / maxExp + self.ImgExpSlider.fillAmount = fillAmount + + local name = XPlayer.Name or "" + self.TxtName.text = name + + local level = XPlayer.GetLevelOrHonorLevel() + self.TxtLevel.text = level + self.TxtId.text = XPlayer.Id + self.Rankt.text = self:GetLevelTxt() +end + +function XUiMainLeftTop:GetLevelTxt() + self.PanelGlory.gameObject:SetActiveEx(XPlayer.IsHonorLevelOpen()) + if XPlayer.IsHonorLevelOpen() then + return CS.XTextManager.GetText("HonorLevelShort") .. "/" + else + return CS.XTextManager.GetText("HostelDeviceLevel") .. "/" + end +end + +--@endregion + +--角色红点 +function XUiMainLeftTop:OnCheckRoleNews(count) + self.BtnRoleInfo:ShowReddot(count >= 0) +end + +function XUiMainLeftTop:UpdateMusicPlayerText() + local albumId = XDataCenter.MusicPlayerManager.GetUiMainNeedPlayedAlbumId() + local template = XMusicPlayerConfigs.GetAlbumTemplateById(albumId) + if not template then return end + self.MaskMusicPlayer.gameObject:SetActiveEx(true) + self.TxtMusicName.text = template.Name + + local txtDescWidth = XUiHelper.CalcTextWidth(self.TxtMusicDesc) + local txtNameWidth = XUiHelper.CalcTextWidth(self.TxtMusicName) + local txtWidth = txtDescWidth + txtNameWidth + local maskWidth = self.MaskMusicPlayer.sizeDelta.x + local txtDescTransform = self.TxtMusicDesc.transform + local txtLocalPosition = txtDescTransform.localPosition + txtDescTransform.localPosition = Vector3(maskWidth, txtLocalPosition.y, txtLocalPosition.z) + local distance = txtWidth + maskWidth + local sequence = DOTween.Sequence() + self.TweenSequenceTxtMusicPlayer = sequence + sequence:Append(txtDescTransform:DOLocalMoveX(-txtWidth, distance/MusicPlayerTextMoveSpeed)) + sequence:AppendInterval(MusicPlayerTextMovePauseInterval) + sequence:SetLoops(-1) +end + +function XUiMainLeftTop:OnUiMusicPlayerCloseCallback() + self.IsNeedRefreshTweenSequence = true +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMain/XUiMainOther.lua b/Resources/Scripts/XUi/XUiMain/XUiMainOther.lua new file mode 100644 index 00000000..59ef60b8 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMain/XUiMainOther.lua @@ -0,0 +1,43 @@ +local XUiPanelSignBoard = require("XUi/XUiMain/XUiChildView/XUiPanelSignBoard") + +XUiMainOther = XClass(nil, "XUiMainOther") + +function XUiMainOther:Ctor(rootUi) + self.Transform = rootUi.PanelOther.gameObject.transform + XTool.InitUiObject(self) + self.RootUi = rootUi + self.SignBoard = XUiPanelSignBoard.New(self.PanelSignBoard, self.RootUi, XUiPanelSignBoard.SignBoardOpenType.MAIN) + + --ClickEvent + self.BtnScreenShot.CallBack = function() self:OnBtnScreenShot() end + --RedPoint +end + +function XUiMainOther:OnEnable() + self.BtnScreenShot.gameObject:SetActiveEx(not XUiManager.IsHideFunc) + + if self.SignBoard then + local displayCharacterId = XDataCenter.DisplayManager.GetDisplayChar().Id + self.SignBoard:SetDisplayCharacterId(displayCharacterId) + self.SignBoard:OnEnable() + end +end + +function XUiMainOther:OnDisable() + if self.SignBoard then + self.SignBoard:OnDisable() + end +end + +function XUiMainOther:OnDestroy() + if self.SignBoard then + self.SignBoard:OnDestroy() + end +end + +--拍照分享按钮 +function XUiMainOther:OnBtnScreenShot() + if XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.Photograph) then + XLuaUiManager.Open("UiPhotograph") + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMain/XUiMainRightBottom.lua b/Resources/Scripts/XUi/XUiMain/XUiMainRightBottom.lua new file mode 100644 index 00000000..49c4928c --- /dev/null +++ b/Resources/Scripts/XUi/XUiMain/XUiMainRightBottom.lua @@ -0,0 +1,82 @@ +XUiMainRightBottom = XClass(nil, "XUiMainRightBottom") + +function XUiMainRightBottom:Ctor(rootUi) + self.Transform = rootUi.PanelRightBottom.gameObject.transform + XTool.InitUiObject(self) + --ClickEvent + self.BtnMember.CallBack = function() self:OnBtnMember() end + self.BtnBag.CallBack = function() self:OnBtnBag() end + self.BtnStore.CallBack = function() self:OnBtnStore() end + self.BtnRecharge.CallBack = function() self:OnBtnRecharge() end + --RedPoint + XRedPointManager.AddRedPointEvent(self.BtnMember.ReddotObj, self.OnCheckMemberNews, self, { XRedPointConditions.Types.CONDITION_MAIN_MEMBER }) + --XRedPointManager.AddRedPointEvent(self.BtnRecharge.ReddotObj, self.OnCheckRechargeNews, self, { XRedPointConditions.Types.CONDITION_PURCHASE_RED }) + + --Filter + self:CheckFilterFunctions() +end + +function XUiMainRightBottom:OnEnable() + -- 充值红点 + -- XDataCenter.PurchaseManager.LBInfoDataReq() + self:OnCheckRechargeNews() + XRedPointManager.CheckByNode(self.BtnMember.ReddotObj) + --商店 + local isOpen = XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.ShopCommon) + or XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.ShopActive) + self.BtnStore:SetDisable(not isOpen) + + XEventManager.AddEventListener(XEventId.EVENT_DAYLY_REFESH_RECHARGE_BTN, self.OnCheckRechargeNews, self) +end + +function XUiMainRightBottom:OnDisable() + XEventManager.RemoveEventListener(XEventId.EVENT_DAYLY_REFESH_RECHARGE_BTN, self.OnCheckRechargeNews, self) +end + +function XUiMainRightBottom:CheckFilterFunctions() + self.BtnMember.gameObject:SetActiveEx(not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.Character)) + self.BtnBag.gameObject:SetActiveEx(not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.Bag)) + self.BtnStore.gameObject:SetActiveEx(not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.ShopCommon) + and not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.ShopActive)) + self.BtnRecharge.gameObject:SetActiveEx(not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.Deposit)) +end + +--成员入口 +function XUiMainRightBottom:OnBtnMember() + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.Character) then + return + end + XLuaUiManager.Open("UiCharacter") +end + +--仓库入口 +function XUiMainRightBottom:OnBtnBag() + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.Bag) then + return + end + XLuaUiManager.Open("UiBag") +end + +--商店入口 +function XUiMainRightBottom:OnBtnStore() + if XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.ShopCommon) + or XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.ShopActive) then + XLuaUiManager.Open("UiShop", XShopManager.ShopType.Common) + end +end + +--充值入口 +function XUiMainRightBottom:OnBtnRecharge() + XLuaUiManager.Open("UiPurchase", XPurchaseConfigs.TabsConfig.LB) +end + +--成员红点 +function XUiMainRightBottom:OnCheckMemberNews(count) + self.BtnMember:ShowReddot(count >= 0) +end + +--充值红点 +function XUiMainRightBottom:OnCheckRechargeNews() + local isShowRedPoint = XDataCenter.PurchaseManager.FreeLBRed() or XDataCenter.PurchaseManager.AccumulatePayRedPoint() or XDataCenter.PurchaseManager.CheckYKContinueBuy() + self.BtnRecharge:ShowReddot(isShowRedPoint) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMain/XUiMainRightMid.lua b/Resources/Scripts/XUi/XUiMain/XUiMainRightMid.lua new file mode 100644 index 00000000..4bcb8b9a --- /dev/null +++ b/Resources/Scripts/XUi/XUiMain/XUiMainRightMid.lua @@ -0,0 +1,563 @@ +local CSXTextManagerGetText = CS.XTextManager.GetText +local DefaultType = 1 +local tableInsert = table.insert +local BtnActivityEntryMaxCount = 3 + +local RegressionMainViewFreshTimeInterval = CS.XGame.ClientConfig:GetInt("RegressionMainViewFreshTimeInterval") + +XUiMainRightMid = XClass(nil, "XUiMainRightMid") + +function XUiMainRightMid:Ctor(rootUi) + self.Transform = rootUi.PanelRightMid.gameObject.transform + XTool.InitUiObject(self) + --ClickEvent + self.BtnFight.CallBack = function() self:OnBtnFight() end + self.BtnTask.CallBack = function() self:OnBtnTask() end + self.BtnBuilding.CallBack = function() self:OnBtnBuilding() end + self.BtnReward.CallBack = function() self:OnBtnReward() end + self.BtnSkipTask.CallBack = function() self:OnBtnSkipTask() end + self.BtnActivityBrief.CallBack = function() self:OnBtnActivityBrief() end + self.BtnPartner.CallBack = function() self:OnBtnPartner() end + self.BtnGuild.CallBack = function() self:OnBtnGuildClick() end + self.BtnGuild.gameObject:SetActiveEx(true) + -- 已经移到 PanelDown 区域中 + self.BtnTarget.CallBack = function() self:OnBtnTarget() end + self.BtnRegression.CallBack = function() self:OnBtnRegression() end + + if self.BtnSpecialShop then + self.BtnSpecialShop.CallBack = function() self:OnBtnSpecialShop() end + end + + --RedPoint + XRedPointManager.AddRedPointEvent(self.BtnTask.ReddotObj, self.OnCheckTaskNews, self, { XRedPointConditions.Types.CONDITION_MAIN_TASK }) + XRedPointManager.AddRedPointEvent(self.BtnTarget.ReddotObj, self.OnCheckTargetNews, self, { XRedPointConditions.Types.CONDITION_MAIN_NEWPLAYER_TASK }) + XRedPointManager.AddRedPointEvent(self.BtnBuilding.ReddotObj, self.OnCheckBuildingNews, self, { XRedPointConditions.Types.CONDITION_DORM_RED }) + --XRedPointManager.AddRedPointEvent(self.BtnReward.ReddotObj, self.OnCheckARewardNews, self, { XRedPointConditions.Types.CONDITION_ACTIVITYDRAW_RED }) + -- XRedPointManager.AddRedPointEvent(self.BtnActivityBrief, self.OnCheckActivityBriefRedPoint, self, { XRedPointConditions.Types.CONDITION_ACTIVITY_NEW_MAINENTRY }) + XRedPointManager.AddRedPointEvent(self.BtnRegression.ReddotObj, nil, self, { XRedPointConditions.Types.CONDITION_REGRESSION }) + XRedPointManager.AddRedPointEvent(self.ImgBuldingRedDot, self.OnCheckGuildRedPoint, self, + { + XRedPointConditions.Types.CONDITION_GUILD_APPLYLIST, + XRedPointConditions.Types.CONDITION_GUILD_ACTIVEGIFT, + XRedPointConditions.Types.CONDITION_GUILD_NEWS, + XRedPointConditions.Types.CONDITION_GUILDBOSS_BOSSHP, + XRedPointConditions.Types.CONDITION_GUILDBOSS_SCORE, + }) + + XRedPointManager.AddRedPointEvent(self.BtnPartner, self.OnCheckPartnerRedPoint, self, + { + XRedPointConditions.Types.CONDITION_PARTNER_COMPOSE_RED, + XRedPointConditions.Types.CONDITION_PARTNER_NEWSKILL_RED, + }) + + self.SpecialShopRed = XRedPointManager.AddRedPointEvent(self.BtnSpecialShop.ReddotObj, self.OnCheckSpecialShopRedPoint, self, { XRedPointConditions.Types.CONDITION_MAIN_SPECIAL_SHOP }) + + + --Filter + self:CheckFilterFunctions() + self:InitBtnActivityEntry() +end + +function XUiMainRightMid:OnEnable() + XEventManager.AddEventListener(XEventId.EVENT_NOTICE_TASKINITFINISHED, self.OnInitTaskFinished, self) + XEventManager.AddEventListener(XEventId.EVENT_DRAW_ACTIVITYCOUNT_CHANGE, self.CheckDrawTag, self) + --XEventManager.AddEventListener(XEventId.EVENT_TASKFORCE_INFO_NOTIFY, self.SetupDispatch, self) + XEventManager.AddEventListener(XEventId.EVENT_REGRESSION_OPEN_STATUS_UPDATE, self.OnRegressionOpenStatusUpdate, self) + self:RefreshFubenProgress() + self:UpdateStoryTaskBtn() + self:UpdateBtnActivityBrief() + self:UpdateBtnActivityEntry() + self:CheckDrawTag() + self:OnRegressionOpenStatusUpdate() + self:BtnSpecialShopUpdate() + if XDataCenter.RegressionManager.IsHaveOneRegressionActivityOpen() then + self:UpdateRegressionLeftTime() + if not self.RegressionTimeSchedule then + self.RegressionTimeSchedule = XScheduleManager.ScheduleForever(function() + self:UpdateRegressionLeftTime() + end, RegressionMainViewFreshTimeInterval * XScheduleManager.SECOND) + end + else + self.TxtRegressionLeftTime.gameObject:SetActiveEx(false) + end + + local livingQuarters = XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.Dorm) + local drawCard = XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.DrawCard) + local partner = XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.Partner) + --初始化是否锁定 + self.BtnBuilding:SetDisable(not livingQuarters) + self.BtnReward:SetDisable(not drawCard) + self.BtnPartner:SetDisable(not partner) + + if self.BtnTarget and (not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.Target)) then + self.BtnTarget.gameObject:SetActive(XDataCenter.TaskManager.CheckNewbieTaskAvailable()) + end + + self:CheckGuildOpen() + XDataCenter.DormManager.StartDormRedTimer() -- 优化 + + self:CheckStartActivityEntryTimer() + self:CheckBtnActivityEntryRedPoint() +end + +function XUiMainRightMid:CheckGuildOpen() + local guildOpen = XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.Guild) + self.BtnGuild:SetDisable(not guildOpen) + + local guildIsDuringTime = XFunctionManager.IsDuringTime(XFunctionManager.FunctionName.Guild) + self.BtnGuild.gameObject:SetActiveEx(guildIsDuringTime) +end + +function XUiMainRightMid:OnDisable() + XEventManager.RemoveEventListener(XEventId.EVENT_NOTICE_TASKINITFINISHED, self.OnInitTaskFinished, self) + XEventManager.RemoveEventListener(XEventId.EVENT_DRAW_ACTIVITYCOUNT_CHANGE, self.CheckDrawTag, self) + --XEventManager.RemoveEventListener(XEventId.EVENT_TASKFORCE_INFO_NOTIFY, self.SetupDispatch, self) + XEventManager.RemoveEventListener(XEventId.EVENT_REGRESSION_OPEN_STATUS_UPDATE, self.OnRegressionOpenStatusUpdate, self) + + if self.guildTimer then + XScheduleManager.UnSchedule(self.guildTimer) + self.guildTimer = nil + end + + if self.RegressionTimeSchedule then + XScheduleManager.UnSchedule(self.RegressionTimeSchedule) + self.RegressionTimeSchedule = nil + end + XDataCenter.DormManager.StopDormRedTimer() + self:StopActivityEntryTimer() +end + +function XUiMainRightMid:OnNotify(evt) + if evt == XEventId.EVENT_TASKFORCE_INFO_NOTIFY then + --更新派遣 + self:SetupDispatch() + end +end + +function XUiMainRightMid:UpdateRegressionLeftTime() + local targetTime = XDataCenter.RegressionManager.GetTaskEndTime() + if not targetTime then + if self.RegressionTimeSchedule then + XScheduleManager.UnSchedule(self.RegressionTimeSchedule) + self.RegressionTimeSchedule = nil + end + self.TxtRegressionLeftTime.gameObject:SetActiveEx(false) + return + end + local leftTime = targetTime - XTime.GetServerNowTimestamp() + if leftTime > 0 then + self.TxtRegressionLeftTime.text = XUiHelper.GetTime(leftTime, XUiHelper.TimeFormatType.MAINBATTERY) + self.TxtRegressionLeftTime.gameObject:SetActiveEx(true) + elseif self.RegressionTimeSchedule then + self.TxtRegressionLeftTime.gameObject:SetActiveEx(false) + if self.RegressionTimeSchedule then + XScheduleManager.UnSchedule(self.RegressionTimeSchedule) + end + self.RegressionTimeSchedule = nil + end +end + +function XUiMainRightMid:CheckFilterFunctions() + self.BtnTarget.gameObject:SetActiveEx(not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.Target)) + self.BtnTask.gameObject:SetActiveEx(not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.Task)) + self.BtnBuilding.gameObject:SetActiveEx(not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.Dorm)) + self.BtnReward.gameObject:SetActiveEx(not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.DrawCard)) + self.BtnSkipTask.gameObject:SetActiveEx(not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.TaskStory)) + self.BtnActivityBrief.gameObject:SetActiveEx(not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.ActivityBrief)) + self.BtnPartner.gameObject:SetActiveEx(not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.Partner)) +end + +--新手目标入口 +function XUiMainRightMid:OnBtnTarget() + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.Target) then + return + end + XLuaUiManager.Open("UiNewPlayerTask") +end + +--- +--- 特殊商店入口点击 +function XUiMainRightMid:OnBtnSpecialShop() + XSaveTool.SaveData(string.format("%d%s", XPlayer.Id, "SpecialShopAlreadyIn"), true) + + if XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.ShopCommon) + or XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.ShopActive) then + + local shopId = XSpecialShopConfigs.GetShopId() + XShopManager.GetShopInfo(shopId, function() + XLuaUiManager.Open("UiSpecialFashionShop", shopId) + end) + end + + XRedPointManager.Check(self.SpecialShopRed) +end + +--副本入口 +function XUiMainRightMid:OnBtnFight() + XLuaUiManager.Open("UiFuben") +end + +--任务入口 +function XUiMainRightMid:OnBtnTask() + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.Task) then + return + end + XLuaUiManager.Open("UiTask") +end + +--任务跳转按钮点击 +function XUiMainRightMid:OnBtnSkipTask() + if not self.ShowTaskId or self.ShowTaskId <= 0 then + XLuaUiManager.Open("UiTask", XDataCenter.TaskManager.TaskType.Story) + else + local taskData = XDataCenter.TaskManager.GetTaskDataById(self.ShowTaskId) + local needSkip = taskData and taskData.State < XDataCenter.TaskManager.TaskState.Achieved + if needSkip then + if XDataCenter.RoomManager.RoomData ~= nil then + local title = CSXTextManagerGetText("TipTitle") + local cancelMatchMsg = CSXTextManagerGetText("OnlineInstanceQuitRoom") + XUiManager.DialogTip(title, cancelMatchMsg, XUiManager.DialogType.Normal, nil, function() + XLuaUiManager.RunMain() + local skipId = XDataCenter.TaskManager.GetTaskTemplate(self.ShowTaskId).SkipId + XFunctionManager.SkipInterface(skipId) + end) + else + local skipId = XDataCenter.TaskManager.GetTaskTemplate(self.ShowTaskId).SkipId + XFunctionManager.SkipInterface(skipId) + end + else + XLuaUiManager.Open("UiTask", XDataCenter.TaskManager.TaskType.Story) + end + end +end + +--宿舍入口 +function XUiMainRightMid:OnBtnBuilding() + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.Dorm) then + return + end + XHomeDormManager.EnterDorm() +end + +--研发入口 +function XUiMainRightMid:OnBtnReward() + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.DrawCard) then + return + end + XDataCenter.DrawManager.MarkActivityDraw() + XLuaUiManager.Open("UiNewDrawMain", DefaultType) +end + +--伙伴入口 +function XUiMainRightMid:OnBtnPartner() + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.Partner) then + return + end + XLuaUiManager.Open("UiPartnerMain", DefaultType) +end + +function XUiMainRightMid:CheckDrawTag() + self:OnCheckDrawActivityTag(XDataCenter.DrawManager.CheckDrawActivityCount()) +end + +--副本入口进度更新 +function XUiMainRightMid:RefreshFubenProgress() + local progressOrder = 1 + local curChapterOrderId = 1 + local curStageOrderId + local curStageOrderIdForShow = 1 + local curStageCount = 1 + local chapterNew + local extraClear = false + local extraLock = false + -- 普通 + local curDifficult = XDataCenter.FubenManager.DifficultNormal + local chapterList = XDataCenter.FubenMainLineManager.GetChapterList(XDataCenter.FubenManager.DifficultNormal) + for _, v in ipairs(chapterList) do + local chapterInfo = XDataCenter.FubenMainLineManager.GetChapterInfo(v) + if chapterInfo then --不知道什么情况偶现的没有副本数据,暂时加个保护 + if chapterInfo.Unlock then + if v == XDataCenter.FubenMainLineManager.TRPGChapterId then + curChapterOrderId = v + else + local activeStageId = chapterInfo.ActiveStage + if not activeStageId then break end + local stageInfo = XDataCenter.FubenManager.GetStageInfo(activeStageId) + local stageCfg = XDataCenter.FubenManager.GetStageCfg(activeStageId) + local chapter = XDataCenter.FubenMainLineManager.GetChapterCfg(v) + curStageOrderId = stageInfo.OrderId + curStageOrderIdForShow = stageCfg.OrderId + curChapterOrderId = chapter.OrderId + curStageCount = #XDataCenter.FubenMainLineManager.GetStageList(v) + progressOrder = chapterInfo.PassStageNum + end + --[[ if curStageOrderId == curStageCount and stageInfo.Passed then + --当前章节打完,下一章节未解锁时进度更为100% + progressOrder = curStageOrderId + else + progressOrder = curStageOrderId - 1 + end]] + end + if not chapterInfo.Passed then + break + end + end + end + local mainLineClear = self:IsMainLineClear(curChapterOrderId, progressOrder, curStageCount, #chapterList) + if mainLineClear then + local clearData = XDataCenter.ExtraChapterManager.GetChapterClearData() + if clearData and clearData.ChapterId then + extraClear = clearData.IsClear and clearData.AllChapterClear + chapterNew = not clearData.IsClear + progressOrder = clearData.PassStageNum + self.TxtCurChapter.text = clearData.StageTitle .. "-" .. clearData.LastStageOrder + self.TxtCurDifficult.text = CSXTextManagerGetText("DifficultMode") .. CSXTextManagerGetText("Difficult" .. curDifficult) + curStageCount = #XDataCenter.ExtraChapterManager.GetStageList(clearData.ChapterId) + else + extraLock = true + end + end + -- 主线与外章普通全部完成时改为显示据点战 + if XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.FubenNightmare) and extraClear then + local chapterId = XDataCenter.BfrtManager.GetActiveChapterId() + local chapterCfg = XDataCenter.BfrtManager.GetChapterCfg(chapterId) + progressOrder = XDataCenter.BfrtManager.GetChapterPassCount(chapterId) + curStageCount = XDataCenter.BfrtManager.GetGroupCount(chapterId) + chapterNew = XDataCenter.BfrtManager.CheckChapterNew(chapterId) + self.TxtCurChapter.text = chapterCfg.ChapterEn + local chapterPassedStr = progressOrder == curStageCount and CSXTextManagerGetText("BfrtStatePassed") or CSXTextManagerGetText("BfrtStateNotPassed") + self.TxtCurDifficult.text = chapterPassedStr + elseif not mainLineClear or (mainLineClear and extraLock) then + chapterNew = XDataCenter.FubenMainLineManager.CheckNewChapter() + local difficultTxt = CSXTextManagerGetText("Difficult" .. curDifficult) + self.TxtCurDifficult.text = CSXTextManagerGetText("DifficultMode") .. difficultTxt + if curChapterOrderId == XDataCenter.FubenMainLineManager.TRPGChapterId then + self.TxtCurChapter.text = XFubenMainLineConfigs.GetChapterMainChapterEn(curChapterOrderId) + else + self.TxtCurChapter.text = curChapterOrderId .. "-" .. curStageOrderIdForShow + end + end + + local progress + if curChapterOrderId == XDataCenter.FubenMainLineManager.TRPGChapterId then + progress = XDataCenter.TRPGManager.GetProgress() + progress = progress / 100 + else + progress = progressOrder / curStageCount + end + self.ImgCurProgress.fillAmount = progress + self.TxtCurProgress.text = CSXTextManagerGetText("MainFubenProgress", math.ceil(progress * 100)) + self.PanelBtnFightEffect.gameObject:SetActive(chapterNew) +end + +function XUiMainRightMid:IsMainLineClear(curChapterOrderId, progressOrder, curStageCount, chapterListTotal) + if curChapterOrderId == XDataCenter.FubenMainLineManager.TRPGChapterId then + return XDataCenter.TRPGManager.IsTRPGClear() + else + return curChapterOrderId == chapterListTotal and progressOrder == curStageCount + end +end + +--更新任务按钮描述 +function XUiMainRightMid:UpdateStoryTaskBtn() + self.ShowTaskId = XDataCenter.TaskManager.GetStoryTaskShowId() + local white = "#ffffff" + local blue = "#34AFF8" + if self.ShowTaskId > 0 then + local taskTemplates = XDataCenter.TaskManager.GetTaskTemplate(self.ShowTaskId) + self.BtnSkipTask:SetDisable(false, true) + local taskData = XDataCenter.TaskManager.GetTaskDataById(self.ShowTaskId) + local hasRed = taskData and taskData.State == XDataCenter.TaskManager.TaskState.Achieved + self.BtnSkipTask:ShowReddot(hasRed) + local color = hasRed and blue or white + self.BtnSkipTask:SetName(string.format("%s", color, taskTemplates.Desc)) + else + self.BtnSkipTask:SetDisable(true, true) + self.BtnSkipTask:SetName(string.format("%s", white, CSXTextManagerGetText("TaskStoryNoTask"))) + end +end + +--更新任务标签 +function XUiMainRightMid:OnInitTaskFinished() + self:UpdateStoryTaskBtn() +end + +-------------活动简介 Begin------------------- +function XUiMainRightMid:UpdateBtnActivityBrief() + local isOpen = XDataCenter.ActivityBriefManager.CheckActivityBriefOpen() + isOpen = isOpen and not XUiManager.IsHideFunc + self.BtnActivityBrief.gameObject:SetActiveEx(isOpen) +end + +function XUiMainRightMid:OnBtnActivityBrief() + XLuaUiManager.Open("UiActivityBriefBase") +end +-------------活动简介 End------------------- +-------------活动入口 Begin------------------- +function XUiMainRightMid:InitBtnActivityEntry() + self:SetBtnActivityEntryHide() + self:InitBtnActivityEntryRedPointEventIds() + if XUiManager.IsHideFunc then return end + + local configs = XDataCenter.ActivityBriefManager.GetNowActivityEntryConfig() + for index, config in ipairs(configs) do + local btn = self["BtnActivityEntry" .. index] + if btn then + btn:SetSprite(config.Bg) + btn.CallBack = function() self:OnClickBtnActivityEntry(config.Id) end + btn.gameObject:SetActiveEx(true) + + local redPointConditions = XActivityBriefConfigs.GetRedPointConditionsBySkipId(config.SkipId) + if redPointConditions then + local redPointEventId = XRedPointManager.AddRedPointEvent(btn, self["OnCheckActivityEntryRedPoint" .. index], self, redPointConditions) + tableInsert(self.BtnActivityEntryRedPointEventIds, redPointEventId) + end + end + end +end + +function XUiMainRightMid:InitBtnActivityEntryRedPointEventIds() + for _, redPointEventId in ipairs(self.BtnActivityEntryRedPointEventIds or {}) do + XRedPointManager.RemoveRedPointEvent(redPointEventId) + end + self.BtnActivityEntryRedPointEventIds = {} +end + +function XUiMainRightMid:UpdateBtnActivityEntry() + local _, isNewActivity = XDataCenter.ActivityBriefManager.GetNowActivityEntryConfig() + if isNewActivity then + self:InitBtnActivityEntry() + end +end + +function XUiMainRightMid:SetBtnActivityEntryHide() + for index = 1, BtnActivityEntryMaxCount do + self["BtnActivityEntry" .. index].gameObject:SetActiveEx(false) + end +end + +function XUiMainRightMid:OnClickBtnActivityEntry(id) + local skipId = XActivityBriefConfigs.GetActivityEntrySkipId(id) + XFunctionManager.SkipInterface(skipId) +end + +function XUiMainRightMid:CheckBtnActivityEntryRedPoint() + for _, redPointEventId in ipairs(self.BtnActivityEntryRedPointEventIds) do + XRedPointManager.Check(redPointEventId) + end +end + +function XUiMainRightMid:OnCheckActivityEntryRedPoint1(count) + self.BtnActivityEntry1:ShowReddot(count >= 0) +end + +function XUiMainRightMid:OnCheckActivityEntryRedPoint2(count) + self.BtnActivityEntry2:ShowReddot(count >= 0) +end + +function XUiMainRightMid:OnCheckActivityEntryRedPoint3(count) + self.BtnActivityEntry3:ShowReddot(count >= 0) +end + +function XUiMainRightMid:CheckStartActivityEntryTimer() + self:StopActivityEntryTimer() + local serverTimestamp + local endTimeStamp = XDataCenter.ActivityBriefManager.GetSpecialActivityMaxEndTime() + self.ActivityEntryTimer = XScheduleManager.ScheduleForever(function() + serverTimestamp = XTime.GetServerNowTimestamp() + self:UpdateBtnActivityEntry() + self:CheckBtnActivityEntryRedPoint() + if endTimeStamp <= serverTimestamp then + self:StopActivityEntryTimer() + end + end, XScheduleManager.SECOND) +end + +function XUiMainRightMid:StopActivityEntryTimer() + if self.ActivityEntryTimer then + XScheduleManager.UnSchedule(self.ActivityEntryTimer) + self.ActivityEntryTimer = nil + end +end +-------------活动入口 End------------------- +-------------回归活动入口 Begin------------- +function XUiMainRightMid:OnRegressionOpenStatusUpdate() + local isOpen = XDataCenter.RegressionManager.IsHaveOneRegressionActivityOpen() + self.BtnRegression.gameObject:SetActiveEx(isOpen) + if not isOpen and self.RegressionTimeSchedule then + XScheduleManager.UnSchedule(self.RegressionTimeSchedule) + self.RegressionTimeSchedule = nil + self.TxtRegressionLeftTime.gameObject:SetActiveEx(false) + end +end + +function XUiMainRightMid:OnBtnRegression() + XLuaUiManager.Open("UiRegression") +end + +-- 公会 +function XUiMainRightMid:OnBtnGuildClick() + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.Guild) then + return + end + + XDataCenter.GuildManager.EnterGuild() +end + +function XUiMainRightMid:OnCheckGuildRedPoint(count) + self.ImgBuldingRedDot.gameObject:SetActiveEx(count >= 0) +end +-------------回归活动入口 End------------- + +--- +--- 更新特殊商店入口状态 +function XUiMainRightMid:BtnSpecialShopUpdate() + if self.BtnSpecialShop then + local isShow = XDataCenter.SpecialShopManager:IsShowEntrance() + self.BtnSpecialShop.gameObject:SetActiveEx(isShow) + end +end + +--伙伴红点 +function XUiMainRightMid:OnCheckPartnerRedPoint(count) + self.BtnPartner:ShowReddot(count >= 0) +end + +--任务红点 +function XUiMainRightMid:OnCheckTaskNews(count) + self.BtnTask:ShowReddot(count >= 0) +end + +--新手目标红点 +function XUiMainRightMid:OnCheckTargetNews(count) + self.BtnTarget:ShowReddot(count >= 0) +end + +-- 特殊商店红点 +function XUiMainRightMid:OnCheckSpecialShopRedPoint(count) + self.BtnSpecialShop:ShowReddot(count >= 0) +end + +--宿舍红点 +function XUiMainRightMid:OnCheckBuildingNews(count) + self.BtnBuilding:ShowReddot(count >= 0) +end + +--活动简介红点 +function XUiMainRightMid:OnCheckActivityBriefRedPoint(count) + self.BtnActivityBrief:ShowReddot(count >= 0) +end + +--研发红点 +function XUiMainRightMid:OnCheckARewardNews(count) + self.BtnReward:ShowReddot(count >= 0) +end + +--研发活动标签 +function XUiMainRightMid:OnCheckDrawActivityTag(IsShow) + if XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.DrawCard) then + self.BtnReward:ShowTag(IsShow) + else + self.BtnReward:ShowTag(false) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMain/XUiMainRightMidSecond.lua b/Resources/Scripts/XUi/XUiMain/XUiMainRightMidSecond.lua new file mode 100644 index 00000000..df0bf954 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMain/XUiMainRightMidSecond.lua @@ -0,0 +1,104 @@ +local XUiGridSubMenuItem = require("XUi/XUiMain/XUiChildItem/XUiGridSubMenuItem") +XUiMainRightMidSecond = XClass(nil, "XUiMainRightMidSecond") + +function XUiMainRightMidSecond:Ctor(rootUi, Ui) + self.Transform = rootUi.PanelRightMidSecond.gameObject.transform + XTool.InitUiObject(self) + self:InitList() + + XRedPointManager.AddRedPointEvent(self.ImgRedTargetSub, self.OnCheckSubMenuRedPoint, self, + { + XRedPointConditions.Types.CONDITION_SUBMENU_NEW_NOTICES, + }) +end + +function XUiMainRightMidSecond:OnEnable() + -- 主页相关红点 + self.MainRedId = XRedPointManager.AddRedPointEvent(self.ImgRedTargetMain, self.OnCheckMainRedPoint, self, + { + ---- 公会相关 ---- + XRedPointConditions.Types.CONDITION_GUILD_APPLYLIST, + XRedPointConditions.Types.CONDITION_GUILD_ACTIVEGIFT, + XRedPointConditions.Types.CONDITION_GUILD_NEWS, + XRedPointConditions.Types.CONDITION_GUILDBOSS_BOSSHP, + XRedPointConditions.Types.CONDITION_GUILDBOSS_SCORE, + ------ 其他 ------ + XRedPointConditions.Types.CONDITION_REGRESSION, + XRedPointConditions.Types.CONDITION_DORM_RED, + XRedPointConditions.Types.CONDITION_MAIN_NEWPLAYER_TASK, + XRedPointConditions.Types.CONDITION_MAIN_TASK + }) + + self:UpdateSubMenuList() + self:UpdateTime() + -- 每分钟更新一次日期显示 + self.InfoUpdateTimer = XScheduleManager.ScheduleForever(function() + self:UpdateTime() + end, 60 * 1000, XTime.GetServerNowTimestamp() % 60 * 1000) +end + +function XUiMainRightMidSecond:OnDisable() + if self.InfoUpdateTimer then + XScheduleManager.UnSchedule(self.InfoUpdateTimer) + self.InfoUpdateTimer = nil + end + + if self.MainRedId then + XRedPointManager.RemoveRedPointEvent(self.MainRedId) + self.MainRedId = nil + end +end + +function XUiMainRightMidSecond:UpdateSubMenuList() + self.SubMenuList = {} + local dataList = XDataCenter.NoticeManager.GetMainUiSubMenu() or {} + if #dataList > 0 then + for _, v in ipairs(dataList) do + table.insert(self.SubMenuList, v) + end + else + -- 当未加载成功时显示loading占位符 + self.SubMenuList = {{Id = -1,Title = "Loading", SubTitle = "...", StyleType = 1}} + end +end + +function XUiMainRightMidSecond:UpdateTime() + local dayOfWeek = os.date("%A", XTime.GetServerNowTimestamp()) + self.TxtDate.text = os.date("%m/%d", XTime.GetServerNowTimestamp()) + self.TxtWeekday.text = CS.XTextManager.GetText(dayOfWeek) +end + +function XUiMainRightMidSecond:InitList() + self.DynamicTable = XDynamicTableNormal.New(self.ScrollView) + self.DynamicTable:SetProxy(XUiGridSubMenuItem) + self.DynamicTable:SetDelegate(self) +end + +-- 更新菜单 +function XUiMainRightMidSecond:RefreshMenu() + self.DynamicTable:SetDataSource(self.SubMenuList) + self.DynamicTable:ReloadDataASync() +end + +function XUiMainRightMidSecond:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.SubMenuList[index] + if not data then + return + end + grid:OnRefresh(data) + end +end + +--更新菜单按钮红点显示 +function XUiMainRightMidSecond:OnCheckSubMenuRedPoint(count) + self.ImgRedTargetSub.gameObject:SetActiveEx(count >= 0) + self:UpdateSubMenuList() +end + +--更新主页按钮红点显示 +function XUiMainRightMidSecond:OnCheckMainRedPoint(count) + self.ImgRedTargetMain.gameObject:SetActiveEx(count >= 0) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMain/XUiMainRightTop.lua b/Resources/Scripts/XUi/XUiMain/XUiMainRightTop.lua new file mode 100644 index 00000000..fdf80059 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMain/XUiMainRightTop.lua @@ -0,0 +1,254 @@ +local CSXTextManagerGetText = CS.XTextManager.GetText +local MailMaxCount = CS.XGame.Config:GetInt("MailCountLimit") +local MailWillFullCount = CS.XGame.ClientConfig:GetInt("MailWillFullCount") --邮箱将满 +local TipTimeLimitItemsLeftTime = CS.XGame.ClientConfig:GetInt("TipTimeLimitItemsLeftTime") -- 限时道具提示时间 +local TipBatteryLeftTime = CS.XGame.ClientConfig:GetInt("TipBatteryLeftTime") -- 限时血清道具提示时间 +local TipBatteryRefreshGap = 30 -- 限时血清道具刷新间隔 +local XQualityManager = CS.XQualityManager.Instance +local LastMainUiChargeState = XUiMainChargeState.None +local BatteryComponent = CS.XUiBattery + +XUiMainRightTop = XClass(nil, "XUiMainRightTop") + +function XUiMainRightTop:Ctor(rootUi) + self.RootUi = rootUi + self.LastTipBatteryRefreshTime = 0 + self.Transform = rootUi.PanelRightTop.gameObject.transform + XTool.InitUiObject(self) + self:UpdateTimeLimitItemTipTimer() + self.LowPowerValue = CS.XGame.ClientConfig:GetFloat("UiMainLowPowerValue") + + XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + --ClickEvent + self.BtnSet.CallBack = function() self:OnBtnSet() end + self.BtnMail.CallBack = function() self:OnBtnMail() end + self.BtnPic.CallBack = function() self:OnBtnPic() end + self.BtnWindows.CallBack = function() self:OnBtnWindows() end + --RedPoint + XRedPointManager.AddRedPointEvent(self.BtnSet, self.OnCheckSetNews, self, { XRedPointConditions.Types.CONDITION_MAIN_SET }) + XRedPointManager.AddRedPointEvent(self.BtnMail, self.OnCheckMailNews, self, { XRedPointConditions.Types.CONDITION_MAIN_MAIL }) + XRedPointManager.AddRedPointEvent(self.BtnPic, self.OnCheckPicNews, self, { XRedPointConditions.Types.CONDITION_PIC_COMPOSITION_TASK_FINISHED }) + XRedPointManager.AddRedPointEvent(self.BtnWindows, self.OnCheckWindowsNews, self, { XRedPointConditions.Types.CONDITION_WINDOWS_COMPOSITION_DAILY }) + + + XEventManager.AddEventListener(XEventId.EVENT_TIMELIMIT_ITEM_USE, function() + self.LastTipBatteryRefreshTime = 0 + end) + + --Filter + self:CheckFilterFunctions() + self:CheckActivityInTime() +end + +--事件监听 +function XUiMainRightTop:OnNotify(evt) + if evt == XEventId.EVENT_MAIL_COUNT_CHANGE then + self:OnCheckMailWillFull() + end +end + +function XUiMainRightTop:OnEnable() + self:UpdateChargeState() + self:OnCheckMailWillFull() + + self.BatteryEffectSchedule = XScheduleManager.ScheduleForever(function() + self:UpdateChargeState() + end, 5 * XScheduleManager.SECOND) + + self:UpdateNowTimeTimer() + self.LastTipBatteryRefreshTime = 0 + self.BatteryTimeSchedule = XScheduleManager.ScheduleForever(function() + self:UpdateNowTimeTimer() + self:UpdateTimeLimitItemTipTimer() + end, XScheduleManager.SECOND) + + XEventManager.AddEventListener(XEventId.EVENT_PICCOMPOSITION_GET_MYDATA, self.OpenUiPicComposition, self) +end + +function XUiMainRightTop:OnDisable() + XScheduleManager.UnSchedule(self.BatteryEffectSchedule) + XScheduleManager.UnSchedule(self.BatteryTimeSchedule) + LastMainUiChargeState = XUiMainChargeState.None + XEventManager.RemoveEventListener(XEventId.EVENT_PICCOMPOSITION_GET_MYDATA, self.OpenUiPicComposition, self) +end + +function XUiMainRightTop:OnDestroy() +end + +function XUiMainRightTop:CheckFilterFunctions() + self.BtnSet.gameObject:SetActiveEx(not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.Setting)) + self.BtnMail.gameObject:SetActiveEx(not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.Mail)) + self.IsBtnPicCanOpen = not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.PicComposition) + self.IsBtnWindowsCanOpen = not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.WindowsInlay) +end + +function XUiMainRightTop:CheckActivityInTime() + local windowsInlayActivityList = XDataCenter.MarketingActivityManager.GetWindowsInlayInTimeActivityList() + local IsPicCompositionInTime = XDataCenter.MarketingActivityManager.CheckIsIntime() + local picComposition = CS.XRemoteConfig.PicComposition + + self.BtnWindows.gameObject:SetActiveEx(#windowsInlayActivityList > 0 and self.IsBtnWindowsCanOpen) + self.BtnPic.gameObject:SetActiveEx(#picComposition > 0 and IsPicCompositionInTime and self.IsBtnPicCanOpen) +end + +--设置入口 +function XUiMainRightTop:OnBtnSet() + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.Setting) then + return + end + XLuaUiManager.Open("UiSet", false) +end + +--邮件入口 +function XUiMainRightTop:OnBtnMail() + XLuaUiManager.Open("UiMail") +end + +--内嵌浏览器入口 +function XUiMainRightTop:OnBtnWindows() + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.WindowsInlay) then + return + end + self.BtnWindows:ShowReddot(false) + XLuaUiManager.Open("UiWindowsInlay") + XDataCenter.MarketingActivityManager.MarkWindowsInlayRedPoint() +end + +--看图作文入口 +function XUiMainRightTop:OnBtnPic() + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.PicComposition) then + return + end + XDataCenter.MarketingActivityManager.DelectTimeOverMemoDialogue() + XDataCenter.MarketingActivityManager.InitMyCompositionDataList() +end + +function XUiMainRightTop:OpenUiPicComposition(IsOpen) + if IsOpen then + XLuaUiManager.Open("UiPicComposition") + else + XUiManager.TipText("PicCompositionNetError") + end +end + +--更新时间 +function XUiMainRightTop:UpdateNowTimeTimer() + if XTool.UObjIsNil(self.TxtPhoneTime) then return end + self.TxtPhoneTime.text = XTime.TimestampToGameDateTimeString(XTime.GetServerNowTimestamp(), "HH:mm") +end + +-- 限时道具提示 +function XUiMainRightTop:UpdateTimeLimitItemTipTimer() + local nowTime = XTime.GetServerNowTimestamp() + if nowTime - self.LastTipBatteryRefreshTime < TipBatteryRefreshGap then + return + end + self.LastTipBatteryRefreshTime = nowTime + + -- 血清道具 + if not XTool.UObjIsNil(self.TxtBatteryLeftTime) then + local leftTime = XDataCenter.ItemManager.GetBatteryMinLeftTime() + if leftTime > 0 and leftTime <= TipBatteryLeftTime then + self.TxtBatteryLeftTime.text = CSXTextManagerGetText("BatteryLeftTime", XUiHelper.GetTime(leftTime, XUiHelper.TimeFormatType.MAINBATTERY)) + self.TxtBatteryLeftTime.gameObject:SetActiveEx(true) + else + self.TxtBatteryLeftTime.gameObject:SetActiveEx(false) + end + end + + --背包道具 + if not XTool.UObjIsNil(self.TxtItemLeftTime) then + local leftTime = XDataCenter.ItemManager.GetTimeLimitItemsMinLeftTime() + if leftTime > 0 and leftTime <= TipTimeLimitItemsLeftTime then + local timeStr = XUiHelper.GetBagTimeLimitTimeStrAndBg(leftTime) + self.TxtItemLeftTime.text = CSXTextManagerGetText("TimeLimitItemLeftTime", timeStr) + self.TxtItemLeftTime.gameObject:SetActiveEx(true) + else + self.TxtItemLeftTime.gameObject:SetActiveEx(false) + end + end +end + +function XUiMainRightTop:OnCheckPicNews(count)--看图作文 + self.BtnPic:ShowReddot(count >= 0 and XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.PicComposition)) +end + +function XUiMainRightTop:OnCheckWindowsNews(count)--内嵌浏览器 + self.BtnWindows:ShowReddot(count >= 0 and XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.WindowsInlay)) +end + +--设置红点(自定义按键冲突) +function XUiMainRightTop:OnCheckSetNews(count) + self.BtnSet:ShowReddot(count >= 0) +end + +--邮件红点 +function XUiMainRightTop:OnCheckMailNews(count) + self.BtnMail:ShowReddot(count >= 0) +end + +--邮件将满 +function XUiMainRightTop:OnCheckMailWillFull() + local count = XDataCenter.MailManager.GetMailCount() + self.TxtMailWillFull.gameObject:SetActiveEx(count >= MailWillFullCount) + if count >= MailMaxCount then + self.TxtMailWillFull.text = CSXTextManagerGetText("MailIsFull") + else + self.TxtMailWillFull.text = CSXTextManagerGetText("MailWillFull") + end +end + +function XUiMainRightTop:UpdateChargeMark() + if LastMainUiChargeState == XUiMainChargeState.Charge then + self.LowPowerMarkFight.gameObject:SetActiveEx(false) + self.LowPowerMarkBuilding.gameObject:SetActiveEx(false) + elseif LastMainUiChargeState == XUiMainChargeState.Enough then + self.LowPowerMarkFight.gameObject:SetActiveEx(false) + self.LowPowerMarkBuilding.gameObject:SetActiveEx(false) + elseif LastMainUiChargeState == XUiMainChargeState.LowPower then + self.LowPowerMarkFight.gameObject:SetActiveEx(true) + self.LowPowerMarkBuilding.gameObject:SetActiveEx(true) + end +end + +--更新主页面低电量状态效果 +--打开窗口电量状态判断 +function XUiMainRightTop:UpdateChargeState() + if XQualityManager.IsSimulator and not BatteryComponent.DebugMode then + return + end + + local curMainUiChargeState = XUiMainChargeState.None + if BatteryComponent.IsCharging then + curMainUiChargeState = XUiMainChargeState.Charge + else + if BatteryComponent.BatteryLevel > self.LowPowerValue then + curMainUiChargeState = XUiMainChargeState.Enough + else + curMainUiChargeState = XUiMainChargeState.LowPower + end + end + + if LastMainUiChargeState == XUiMainChargeState.None then --初始状态 + if curMainUiChargeState == XUiMainChargeState.Charge or curMainUiChargeState == XUiMainChargeState.Enough then -- 从无状态到指定状态 + self.RootUi:ChangeLowPowerState(self.RootUi.LowPowerState.Full) + elseif curMainUiChargeState == XUiMainChargeState.LowPower then + self.RootUi:ChangeLowPowerState(self.RootUi.LowPowerState.Low) + end + elseif LastMainUiChargeState == XUiMainChargeState.Charge or LastMainUiChargeState == XUiMainChargeState.Enough then -- 从电量充足或者充电到低电量 + if curMainUiChargeState == XUiMainChargeState.LowPower then + self.RootUi:ChangeLowPowerState(self.RootUi.LowPowerState.FullToLow) + else + self.RootUi:ChangeLowPowerState(self.RootUi.LowPowerState.Full) + end + elseif LastMainUiChargeState == XUiMainChargeState.LowPower then -- 从低电量到充电或者电量充足 + if curMainUiChargeState == XUiMainChargeState.Charge or curMainUiChargeState == XUiMainChargeState.Enough then + self.RootUi:ChangeLowPowerState(self.RootUi.LowPowerState.LowToFull) + else + self.RootUi:ChangeLowPowerState(self.RootUi.LowPowerState.Low) + end + end + + LastMainUiChargeState = curMainUiChargeState + self:UpdateChargeMark() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMaintainerAction/XUiFubenMaintaineraction.lua b/Resources/Scripts/XUi/XUiMaintainerAction/XUiFubenMaintaineraction.lua new file mode 100644 index 00000000..f400af7a --- /dev/null +++ b/Resources/Scripts/XUi/XUiMaintainerAction/XUiFubenMaintaineraction.lua @@ -0,0 +1,134 @@ +local XUiFubenMaintaineraction = XLuaUiManager.Register(XLuaUi, "UiFubenMaintaineraction") +local XUiPanelBelow = require("XUi/XUiMaintainerAction/XUiPanelBelow") +local XUiPanelIntermediate = require("XUi/XUiMaintainerAction/XUiPanelIntermediate") +local MapNodeMaxIndex = 15 +local CSTextManagerGetText = CS.XTextManager.GetText + +function XUiFubenMaintaineraction:OnStart() + self.CardRouteList = {} + self.BelowPanel = XUiPanelBelow.New(self.PanelBelow,self) + self.IntermediatePanel = XUiPanelIntermediate.New(self.PanelIntermediate,self) + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self:SetButtonCallBack() + --self:PlayStory() + + self.BelowPanel:DisableAllCard(false) + self.PanelIntermediate.gameObject:SetActiveEx(true) + self.PanelMissioncompleted.gameObject:SetActiveEx(false) +end + +function XUiFubenMaintaineraction:OnDestroy() + +end + +function XUiFubenMaintaineraction:OnEnable() + if not self:CheckWeekUpdateMessage() then + local player = XDataCenter.MaintainerActionManager.GetPlayerMySelf() + + self:UpdatePanel() + self:CheckEvent(player:GetPosNodeId(), false, function () + self:UpdatePanel() + end) + + local nowTime = XTime.GetServerNowTimestamp() + local gameData = XDataCenter.MaintainerActionManager.GetGameData() + self.TxtTime.text = XUiHelper.GetTime(gameData:GetResetTime() - nowTime, XUiHelper.TimeFormatType.ACTIVITY) + + XEventManager.AddEventListener(XEventId.EVENT_MAINTAINERACTION_DAY_UPDATA, self.UpdatePanel, self) + XEventManager.AddEventListener(XEventId.EVENT_MAINTAINERACTION_WEEK_UPDATA, self.CheckWeekUpdateMessage, self) + XEventManager.AddEventListener(XEventId.EVENT_MAINTAINERACTION_USECARD, self.UsedCard, self) + XEventManager.AddEventListener(XEventId.EVENT_MAINTAINERACTION_SELECTCARD, self.SelectCard, self) + XEventManager.AddEventListener(XEventId.EVENT_MAINTAINERACTION_NODE_CHANGE, self.UpdatePanel, self) + end +end + +function XUiFubenMaintaineraction:OnDisable() + XEventManager.RemoveEventListener(XEventId.EVENT_MAINTAINERACTION_DAY_UPDATA, self.UpdatePanel, self) + XEventManager.RemoveEventListener(XEventId.EVENT_MAINTAINERACTION_WEEK_UPDATA, self.CheckWeekUpdateMessage, self) + XEventManager.RemoveEventListener(XEventId.EVENT_MAINTAINERACTION_USECARD, self.UsedCard, self) + XEventManager.RemoveEventListener(XEventId.EVENT_MAINTAINERACTION_SELECTCARD, self.SelectCard, self) + XEventManager.RemoveEventListener(XEventId.EVENT_MAINTAINERACTION_NODE_CHANGE, self.UpdatePanel, self) + self.IntermediatePanel:StopPlayerTween() + self.BelowPanel:StopCardTween() +end + +function XUiFubenMaintaineraction:SetButtonCallBack() + self.BtnBack.CallBack = function() + self:OnBtnBackClick() + end + self.BtnMainUi.CallBack = function() + self:OnBtnMainUiClick() + end + self:BindHelpBtn(self.BtnHelp, "MaintainerActionHelp") +end + +function XUiFubenMaintaineraction:OnBtnBackClick() + self:Close() +end + +function XUiFubenMaintaineraction:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiFubenMaintaineraction:PlayStory() + local gameData = XDataCenter.MaintainerActionManager.GetGameData() + local storyId = gameData:GetStoryId() + if storyId and #storyId > 1 then + local IsCanPlay = XDataCenter.MaintainerActionManager.CheckIsNewStoryID(storyId) + if IsCanPlay then + XDataCenter.MovieManager.PlayMovie(storyId)--一次 + XDataCenter.MaintainerActionManager.MarkStoryID(storyId) + end + end +end + +function XUiFubenMaintaineraction:SelectCard(cradNum) + self.IntermediatePanel:ShowCardSelectRoute(cradNum) +end + +function XUiFubenMaintaineraction:CheckDayUpdateMessage() + XDataCenter.MaintainerActionManager.CheckDayUpdateMessage() +end + +function XUiFubenMaintaineraction:CheckWeekUpdateMessage() + return XDataCenter.MaintainerActionManager.CheckWeekUpdateMessage() +end + +function XUiFubenMaintaineraction:CheckEventComplete() + XDataCenter.MaintainerActionManager.CheckEventCompleteMessage(function () + XDataCenter.MaintainerActionManager.CheckFightCompleteMessage(function () + XDataCenter.MaintainerActionManager.CheckMentorCompleteMessage() + end) + end) +end + +function XUiFubenMaintaineraction:UpdatePanel() + self:CheckDayUpdateMessage() + self.IntermediatePanel:CreateCardRouteList() + self.IntermediatePanel:UpdatePanel() + self.IntermediatePanel:SetCurNodeNameTag(XPlayer.Id) + self.BelowPanel:UpdatePanel() + self:CheckEventComplete() +end + +function XUiFubenMaintaineraction:UsedCard(targetNodeId) + self.BelowPanel:GetNewCard() + self.IntermediatePanel:MovePlayerById(XPlayer.Id,targetNodeId,function () + self:CheckEvent(targetNodeId, true, function () + self:UpdatePanel() + end) + end) +end + +function XUiFubenMaintaineraction:CheckEvent(targetNodeId, IsDoTriggeredCb, cb) + local mapNodeList = XDataCenter.MaintainerActionManager.GetMapNodeList() + local player = XDataCenter.MaintainerActionManager.GetPlayerMySelf() + local node = mapNodeList[targetNodeId] + if player:GetIsNodeTriggered() then + if IsDoTriggeredCb and cb then cb() end + return + end + + node:EventRequest(self, player, cb) +end + diff --git a/Resources/Scripts/XUi/XUiMaintainerAction/XUiFubenMaintaineractionDetailsTips.lua b/Resources/Scripts/XUi/XUiMaintainerAction/XUiFubenMaintaineractionDetailsTips.lua new file mode 100644 index 00000000..38dac282 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMaintainerAction/XUiFubenMaintaineractionDetailsTips.lua @@ -0,0 +1,49 @@ +local XUiFubenMaintaineractionDetailsTips = XLuaUiManager.Register(XLuaUi, "UiFubenMaintaineractionDetailsTips") +local CSTextManagerGetText = CS.XTextManager.GetText + +function XUiFubenMaintaineractionDetailsTips:OnStart(node,IsReward) + self:SetButtonCallBack() + self.GridCommon.gameObject:SetActiveEx(false) + self:ShowInfo(node, IsReward) +end + +function XUiFubenMaintaineractionDetailsTips:SetButtonCallBack() + self.BtnBack.CallBack = function() + self:OnBtnBackClick() + end +end + +function XUiFubenMaintaineractionDetailsTips:OnBtnBackClick() + self:Close() +end + +function XUiFubenMaintaineractionDetailsTips:ShowInfo(node, IsReward) + self.PanelTreasureChest.gameObject:SetActiveEx(IsReward) + self.PanelRandom.gameObject:SetActiveEx(not IsReward) + if IsReward then + local rewards + + if node.GetRewardId then + rewards = XRewardManager.GetRewardList(node:GetRewardId()) + elseif node.GetRewardList then + rewards = node:GetRewardList() + end + + if rewards then + for i, item in pairs(rewards) do + local obj = CS.UnityEngine.Object.Instantiate(self.GridCommon,self.PanelContent) + local grid = XUiGridCommon.New(self, obj) + grid:Refresh(item) + grid.GameObject:SetActiveEx(true) + end + end + + self.TxtRewardTitle.text = node:GetRewardTitle() + + self.TxtMentorTitle.gameObject:SetActiveEx(node:GetIsMentor()) + self.TxtMentorTitle.text = node:GetDesc() + else + self.TxtDescTitle.text = node:GetName() + self.TxtDescription.text = node:GetDesc() + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMaintainerAction/XUiFubenMaintaineractionFighting.lua b/Resources/Scripts/XUi/XUiMaintainerAction/XUiFubenMaintaineractionFighting.lua new file mode 100644 index 00000000..0d4177f3 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMaintainerAction/XUiFubenMaintaineractionFighting.lua @@ -0,0 +1,68 @@ +local XUiFubenMaintaineractionFighting = XLuaUiManager.Register(XLuaUi, "UiFubenMaintaineractionFighting") +local CSTextManagerGetText = CS.XTextManager.GetText +function XUiFubenMaintaineractionFighting:OnStart(stageId) + self:SetButtonCallBack() + self.GridCommon.gameObject:SetActiveEx(false) + self.StageId = stageId + self:ShowInfo() +end + +function XUiFubenMaintaineractionFighting:OnEnable() + self:PlayAnimation("AnimBegin") +end + +function XUiFubenMaintaineractionFighting:SetButtonCallBack() + self.BtnEnter.CallBack = function() + self:OnBtnEnterClick() + end + self.BtnRun.CallBack = function() + self:OnBtnRunClick() + end + self.BtnClose.CallBack= function() + self:OnBtnRunClick() + end +end + +function XUiFubenMaintaineractionFighting:OnBtnEnterClick() + local IsFightComplete = XDataCenter.MaintainerActionManager.CheckIsFightComplete() + if IsFightComplete then + XUiManager.TipText("MaintainerActionFightCompleteText") + return + end + XLuaUiManager.PopThenOpen("UiNewRoomSingle", self.StageId) +end + +function XUiFubenMaintaineractionFighting:OnBtnRunClick() + XLuaUiManager.SetMask(true) + self:PlayAnimation("AnimEnd",function () + XLuaUiManager.SetMask(false) + self:Close() + end) +end + +function XUiFubenMaintaineractionFighting:ShowInfo() + local stageCfg = XDataCenter.FubenManager.GetStageCfg(self.StageId) + local stageLevelcfg = XDataCenter.FubenManager.GetStageLevelControl(self.StageId) + local rewardId = (stageLevelcfg and stageLevelcfg.FinishRewardShow > 0 and stageLevelcfg.FinishRewardShow) or + (stageCfg and stageCfg.FinishRewardShow > 0 and stageCfg.FinishRewardShow) or 0 + + self.TxtTitle.text = stageCfg.Name + self.TextDesc.text = stageCfg.Description + + local rewards = XRewardManager.GetRewardList(rewardId) + if rewards then + for i, item in pairs(rewards) do + local obj = CS.UnityEngine.Object.Instantiate(self.GridCommon,self.PanelDropContent) + local grid = XUiGridCommon.New(self, obj) + grid:Refresh(item) + grid.GameObject:SetActive(true) + end + end +end + +function XUiFubenMaintaineractionFighting:TipDialog(cancelCb, confirmCb) + local tipTitle = CSTextManagerGetText("TipTitle") + local content = CSTextManagerGetText("MaintainerActionFightHint") + + CsXUiManager.Instance:Open("UiDialog", tipTitle, content, XUiManager.DialogType.Normal, cancelCb, confirmCb) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMaintainerAction/XUiFubenMaintaineractionRecording.lua b/Resources/Scripts/XUi/XUiMaintainerAction/XUiFubenMaintaineractionRecording.lua new file mode 100644 index 00000000..842698a6 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMaintainerAction/XUiFubenMaintaineractionRecording.lua @@ -0,0 +1,37 @@ +local XUiFubenMaintaineractionRecording = XLuaUiManager.Register(XLuaUi, "UiFubenMaintaineractionRecording") +local XUiGridRecord = require("XUi/XUiMaintainerAction/XUiGridRecord") +local CSTextManagerGetText = CS.XTextManager.GetText + +function XUiFubenMaintaineractionRecording:OnStart() + self:InitDynamicTable() + self:SetButtonCallBack() +end + +function XUiFubenMaintaineractionRecording:OnEnable() + self:SetupDynamicTable() +end + +function XUiFubenMaintaineractionRecording:SetButtonCallBack() + self.BtnClose.CallBack = function() + self:Close() + end +end + +function XUiFubenMaintaineractionRecording:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelRecordingScroll) + self.DynamicTable:SetProxy(XUiGridRecord) + self.GridRecording.gameObject:SetActiveEx(false) + self.DynamicTable:SetDelegate(self) +end + +function XUiFubenMaintaineractionRecording:SetupDynamicTable() + self.PageDatas = XDataCenter.MaintainerActionManager.GetRecordData() + self.DynamicTable:SetDataSource(self.PageDatas) + self.DynamicTable:ReloadDataSync(#self.PageDatas) +end + +function XUiFubenMaintaineractionRecording:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:UpdateGrid(self.PageDatas[index], self) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMaintainerAction/XUiFubenMaintaineractionTipLayer.lua b/Resources/Scripts/XUi/XUiMaintainerAction/XUiFubenMaintaineractionTipLayer.lua new file mode 100644 index 00000000..177677ae --- /dev/null +++ b/Resources/Scripts/XUi/XUiMaintainerAction/XUiFubenMaintaineractionTipLayer.lua @@ -0,0 +1,78 @@ +local XUiFubenMaintaineractionTipLayer = XLuaUiManager.Register(XLuaUi, "UiFubenMaintaineractionTipLayer") + +local TIP_MSG_SHOW_TIME = 5000 + +function XUiFubenMaintaineractionTipLayer:OnStart(hintText, msgList, type, cb) + self.Cb = cb + self.closeState = false + XUiHelper.StopAnimation() + self:PlayAnimation("PanelTip") + + self.BtnClose.CallBack = function() + self:OnBtnCloseClick() + end + + local pop = function() + self:Close() + end + + self.CloseFunc = function() + if not XTool.UObjIsNil(self.GameObject) then + self:PlayAnimation("PanelTipEnd", pop) + end + end + + self.Timer = XScheduleManager.ScheduleOnce(function() + if not self.closeState then + self.closeState = true + self.CloseFunc() + end + end, TIP_MSG_SHOW_TIME) + + local msg1 = msgList and msgList[1] + local msg2 = msgList and msgList[2] + local msg3 = msgList and msgList[3] + + self.TxtDesc1.text = msg1 or "" + self.TxtDesc2.text = msg2 or "" + self.TxtDesc3.text = msg3 or "" + + self.TxtDesc1.gameObject:SetActiveEx(msg1) + self.TxtDesc2.gameObject:SetActiveEx(msg2) + self.TxtDesc3.gameObject:SetActiveEx(msg3) + + self.TxtInfoFight.text = hintText or "" + self.TxtInfoMentor.text = hintText or "" + self.TxtInfoTask.text = hintText or "" + + self.PaneFightinglTip.gameObject:SetActiveEx(type == XMaintainerActionConfigs.TipType.FightComplete) + self.PaneTaskTip.gameObject:SetActiveEx(type == XMaintainerActionConfigs.TipType.EventComplete) + self.PaneMentorTip.gameObject:SetActiveEx(type == XMaintainerActionConfigs.TipType.MentorComplete) +end + +function XUiFubenMaintaineractionTipLayer:OnBtnCloseClick() + + if self.closeState then + return + end + + self.closeState = true + XScheduleManager.UnSchedule(self.Timer) + self.BtnClose.interactable = false + if self.CloseFunc then + self:CloseFunc() + else + --CS.XUiManager.TipsManager:Pop() + self:Close() + end +end + +function XUiFubenMaintaineractionTipLayer:OnDestroy() + if self.Cb then + self.Cb() + end + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMaintainerAction/XUiFubenMaintaineractionTreasurechest.lua b/Resources/Scripts/XUi/XUiMaintainerAction/XUiFubenMaintaineractionTreasurechest.lua new file mode 100644 index 00000000..f6a54eda --- /dev/null +++ b/Resources/Scripts/XUi/XUiMaintainerAction/XUiFubenMaintaineractionTreasurechest.lua @@ -0,0 +1,36 @@ +local XUiFubenMaintaineractionTreasurechest = XLuaUiManager.Register(XLuaUi, "UiFubenMaintaineractionTreasurechest") +local CSTextManagerGetText = CS.XTextManager.GetText + +function XUiFubenMaintaineractionTreasurechest:OnStart(rewardId, rewardList, title, subTitle, curCount, maxCount, closeCb) + self:SetButtonCallBack() + self.Grid256.gameObject:SetActiveEx(false) + self.CloseCb = closeCb + self:ShowInfo(rewardId, rewardList, title, subTitle, curCount, maxCount) +end + +function XUiFubenMaintaineractionTreasurechest:SetButtonCallBack() + self.BtnClose.CallBack = function() + self:OnBtnCloseClick() + end +end + +function XUiFubenMaintaineractionTreasurechest:OnBtnCloseClick() + self.CloseCb() + self:Close() +end + +function XUiFubenMaintaineractionTreasurechest:ShowInfo(rewardId, rewardList, title, subTitle, curCount, maxCount) + local rewards = rewardId and XRewardManager.GetRewardList(rewardId) or rewardList + + if rewards then + for i, item in pairs(rewards) do + local obj = CS.UnityEngine.Object.Instantiate(self.Grid256,self.PanelDetails) + local grid = XUiGridCommon.New(self, obj) + grid:Refresh(item) + grid.GameObject:SetActiveEx(true) + end + end + self.TxtTitle.text = title + self.TxtSubTitle.text = subTitle + self.BoxCount.text = string.format("%d/%d", curCount, maxCount) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMaintainerAction/XUiGridCard.lua b/Resources/Scripts/XUi/XUiMaintainerAction/XUiGridCard.lua new file mode 100644 index 00000000..f85ed052 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMaintainerAction/XUiGridCard.lua @@ -0,0 +1,144 @@ +local XUiGridCard = XClass(nil, "XUiGridCard") + +local TweenSpeed = 0.5 +local StartAlpha = 0 +local EndAlpha = 1 +local NewCardPosId = 4 +local CardStateCount = 3 + +function XUiGridCard:Ctor(ui,base) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Base = base + self.State = XMaintainerActionConfigs.CardState.Normal + XTool.InitUiObject(self) + self:SetButtonCallBack() +end + +function XUiGridCard:SetButtonCallBack() + self.BtnCard.CallBack = function() + self:OnBtnCardClick() + end +end + +function XUiGridCard:OnBtnCardClick() + if self.State == XMaintainerActionConfigs.CardState.Disable then + return + elseif self.State == XMaintainerActionConfigs.CardState.Select then + self:UseCard() + else + self.Base:UnSelectAllCard() + self:SetCardState(XMaintainerActionConfigs.CardState.Select) + XEventManager.DispatchEvent(XEventId.EVENT_MAINTAINERACTION_SELECTCARD,self.CurNum) + end +end + +function XUiGridCard:SetCardState(state) + self.State = state + if state == XMaintainerActionConfigs.CardState.Disable then + self.BtnCard:SetButtonState(CS.UiButtonState.Disable) + elseif state == XMaintainerActionConfigs.CardState.Select then + self.BtnCard:SetButtonState(CS.UiButtonState.Select) + elseif state == XMaintainerActionConfigs.CardState.Normal then + self.BtnCard:SetButtonState(CS.UiButtonState.Normal) + self.BtnCard.TempState = CS.UiButtonState.Normal + end +end + +function XUiGridCard:SetCardNum(num) + self.CurNum = num + self.BtnCard:SetName(num) +end + +function XUiGridCard:SetCardPosId(posId) + self.CurPosId = posId +end + +function XUiGridCard:ShowTag(IsShow) + for i = 1,CardStateCount do + self.TagGroup:GetObject(string.format("Tag%d",i)).gameObject:SetActiveEx(IsShow) + end +end + +function XUiGridCard:UseCard() + local IsOver = XDataCenter.MaintainerActionManager.CheckIsActionPointOver() + if IsOver then + XUiManager.TipText("MaintainerActionPowerOver") + return + end + + local gameData = XDataCenter.MaintainerActionManager.GetGameData() + XDataCenter.MaintainerActionManager.PlayerMoveRequest(self.CurNum, self.CurPosId, function (data) + local tmpData = {} + tmpData.UsedActionCount = gameData:GetUsedActionCount() + 1 + + gameData:CardChange(self.CurNum,data.NewCard) + gameData:UpdateData(tmpData) + + local tagPos = self.Base.CardPos[NewCardPosId] + self.Base.UsedCardPosId = self.CurPosId + self.CurPosId = NewCardPosId + XLuaUiManager.SetMask(true) + self.UseCardAlphaTimer = XUiHelper.DoAlpha(self.BtnCardCanvaGroup, EndAlpha, StartAlpha, TweenSpeed, XUiHelper.EaseType.Sin, function () + XLuaUiManager.SetMask(false) + self.UseCardAlphaTimer = nil + self.Transform.localPosition = tagPos + self.BtnCardCanvaGroup.alpha = EndAlpha + XEventManager.DispatchEvent(XEventId.EVENT_MAINTAINERACTION_USECARD,data.NodeId) + self:SetCardNum(data.NewCard) + self:SetCardState(XMaintainerActionConfigs.CardState.Normal) + end) + end) +end + +function XUiGridCard:Change(newCard, cb) + local gameData = XDataCenter.MaintainerActionManager.GetGameData() + gameData:CardChange(self.CurNum,newCard) + + local tagPos = self.Base.CardPos[NewCardPosId] + self.Base.UsedCardPosId = self.CurPosId + self.CurPosId = NewCardPosId + XLuaUiManager.SetMask(true) + self.ChangeCardAlphaTimer = XUiHelper.DoAlpha(self.BtnCardCanvaGroup, EndAlpha, StartAlpha, TweenSpeed, XUiHelper.EaseType.Sin, function () + XLuaUiManager.SetMask(false) + self.ChangeCardAlphaTimer = nil + self.Transform.localPosition = tagPos + self.BtnCardCanvaGroup.alpha = EndAlpha + self:SetCardNum(newCard) + self:SetCardState(XMaintainerActionConfigs.CardState.Normal) + if cb then cb() end + end) +end + +function XUiGridCard:GetCard() + local posId = self.Base.UsedCardPosId + if self.CurPosId > posId then + local tagPos = self.Base.CardPos[self.CurPosId - 1] + self.CurPosId = self.CurPosId - 1 + XLuaUiManager.SetMask(true) + self.GetCardMoveTimer = XUiHelper.DoMove(self.Transform, tagPos, TweenSpeed, XUiHelper.EaseType.Sin, function () + XLuaUiManager.SetMask(false) + self.GetCardMoveTimer = nil + end) + end +end + +function XUiGridCard:StopTween() + if self.UseCardAlphaTimer then + XScheduleManager.UnSchedule(self.UseCardAlphaTimer) + XLuaUiManager.SetMask(false) + self.UseCardAlphaTimer = nil + end + if self.ChangeCardAlphaTimer then + XScheduleManager.UnSchedule(self.ChangeCardAlphaTimer) + XLuaUiManager.SetMask(false) + self.ChangeCardAlphaTimer = nil + end + if self.GetCardMoveTimer then + XScheduleManager.UnSchedule(self.GetCardMoveTimer) + XLuaUiManager.SetMask(false) + self.GetCardMoveTimer = nil + end +end + +return XUiGridCard \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMaintainerAction/XUiGridMapNote.lua b/Resources/Scripts/XUi/XUiMaintainerAction/XUiGridMapNote.lua new file mode 100644 index 00000000..c144f7ae --- /dev/null +++ b/Resources/Scripts/XUi/XUiMaintainerAction/XUiGridMapNote.lua @@ -0,0 +1,151 @@ +local XUiGridMapNote = XClass(nil, "XUiGridMapNote") +local MapNodeMaxCount = 16 + +local TweenSpeed ={ + High = 0.3, + Low = 0.5, +} +local StartAlpha = 0 +local EndAlpha = 1 + +function XUiGridMapNote:Ctor(ui,base) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.Base = base + self.IsPlayerIn = false + self.CurState = XMaintainerActionConfigs.NodeState.Normal + self.EventShowAnime.gameObject:SetActiveEx(false) + + self:SetButtonCallBack() +end + +function XUiGridMapNote:SetButtonCallBack() + self.BtnIattice.CallBack = function() + self:OnBtnIatticeClick() + end +end + +function XUiGridMapNote:OnBtnIatticeClick() + if not self.NoteEntity then + return + end + local player = XDataCenter.MaintainerActionManager.GetPlayerMySelf() + if self.NoteEntity:GetIsFight() and not player:GetIsNodeTriggered() and + player:GetPosNodeId() == self.NoteEntity:GetId() then + self.NoteEntity:DoEvent({})--参数不能为空 + else + self.NoteEntity:OpenDescTip() + end +end + +function XUiGridMapNote:UpdateNote(entity) + self.NoteEntity = entity + if entity then + self:ShowEvent(entity) + self:SetEventData(entity) + self:CheckNodeState() + end +end + +function XUiGridMapNote:CheckNodeState() + local player = XDataCenter.MaintainerActionManager.GetPlayerMySelf() + local IsUnKonwn = self.NoteEntity:GetIsUnKonwn() + local nodeId = self:GetLineId() + self.NormalEventBg.gameObject:SetActiveEx(false) + self.RandomEventBg.gameObject:SetActiveEx(false) + self.OnRouteBg.gameObject:SetActiveEx(false) + self.TargetBg.gameObject:SetActiveEx(false) + self.Base.LineList[nodeId].gameObject:SetActiveEx(false) + if self.CurState == XMaintainerActionConfigs.NodeState.Normal then + if player:GetPosNodeId() == self.NoteEntity:GetId() then + self.TargetBg.gameObject:SetActiveEx(true) + else + self.NormalEventBg.gameObject:SetActiveEx(not IsUnKonwn) + self.RandomEventBg.gameObject:SetActiveEx(IsUnKonwn) + end + elseif self.CurState == XMaintainerActionConfigs.NodeState.OnRoute then + self.OnRouteBg.gameObject:SetActiveEx(true) + self.Base.LineList[nodeId].gameObject:SetActiveEx(true) + elseif self.CurState == XMaintainerActionConfigs.NodeState.Target then + self.TargetBg.gameObject:SetActiveEx(true) + end +end + +function XUiGridMapNote:GetLineId() + local playerDic = XDataCenter.MaintainerActionManager.GetPlayerDic() + local player = playerDic[XPlayer.Id] + if not player:GetIsReverse() then + return self.NoteEntity:GetId() + 1 + else + local id = self.NoteEntity:GetId() + return id > 0 and id or (id + MapNodeMaxCount) + end +end + +function XUiGridMapNote:SetNodeState(state) + self.CurState = state + self:CheckNodeState() +end + +function XUiGridMapNote:SetEventData(entity) + local icon = entity:GetEventIcon() + if icon then + self.EventIcon:SetSprite(icon) + else + self.EventText.text = entity:GetName() + end + self.EventIcon.gameObject:SetActiveEx(icon) + self.EventText.gameObject:SetActiveEx(not icon) +end + +function XUiGridMapNote:ShowEvent(entity) + local IsUnKonwn = entity:GetIsUnKonwn() + local IsNone = entity:GetIsNone() + self.Event.gameObject:SetActiveEx(not IsUnKonwn and not IsNone) + self.Unknown.gameObject:SetActiveEx(IsUnKonwn) +end + +function XUiGridMapNote:PlayerInShow(IsIn,IsAnime) + if self.IsPlayerIn ~= IsIn then + self.IsPlayerIn = IsIn + if IsAnime then + self:SetEventAnimeHide(IsIn) + else + self:SetEventHide(IsIn) + end + + end +end + +function XUiGridMapNote:SetEventAnimeHide(IsIn) + self:StopTween() + self.CurEventAlpha = self.EventInfoCanvasGroup.alpha + if IsIn then + self.AlphaTimer = XUiHelper.DoAlpha(self.EventInfoCanvasGroup, self.CurEventAlpha, StartAlpha, TweenSpeed.High, XUiHelper.EaseType.Sin, nil) + else + self.AlphaTimer = XUiHelper.DoAlpha(self.EventInfoCanvasGroup, self.CurEventAlpha, EndAlpha, TweenSpeed.Low, XUiHelper.EaseType.Sin, nil) + end +end + +function XUiGridMapNote:SetEventHide(IsIn) + self:StopTween() + if IsIn then + self.EventInfoCanvasGroup.alpha = StartAlpha + else + self.EventInfoCanvasGroup.alpha = EndAlpha + end +end + +function XUiGridMapNote:StopTween() + if self.AlphaTimer then + XScheduleManager.UnSchedule(self.AlphaTimer) + self.AlphaTimer = nil + end +end + +function XUiGridMapNote:PlayEventAnime() + self.EventShowAnime.gameObject:SetActiveEx(true) +end + +return XUiGridMapNote \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMaintainerAction/XUiGridPlayer.lua b/Resources/Scripts/XUi/XUiMaintainerAction/XUiGridPlayer.lua new file mode 100644 index 00000000..14e87c02 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMaintainerAction/XUiGridPlayer.lua @@ -0,0 +1,89 @@ +local XUiGridPlayer = XClass(nil, "XUiGridPlayer") + +local TweenSpeed = 0.3 + +function XUiGridPlayer:Ctor(ui,base) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Base = base + self.IsPlayerIn = false + self.CurInNodeId = 1 + self.CurOutNodeId = 1 + self.CurState = XMaintainerActionConfigs.NodeState.Normal + XTool.InitUiObject(self) + self:SetButtonCallBack() +end + +function XUiGridPlayer:SetButtonCallBack() + +end + +function XUiGridPlayer:OnBtnIatticeClick() + +end + +function XUiGridPlayer:SetPlayerData(entity) + self.PlayerEntity = entity + if entity then + local startNode = self.Base.NodeList[entity:GetPosNodeId()] + self.CurNodeText.text = startNode.NoteEntity:GetName() + self.Transform.position = startNode.Transform.position + XUiPLayerHead.InitPortrait(entity:GetHeadPortraitId(), entity:GetHeadFrameId(), self.Head) + self.CurOutNodeId = entity:GetPosNodeId() + self.CurInNodeId = entity:GetPosNodeId() + self.Base.NodeList[self.CurOutNodeId]:PlayerInShow(true, false) + self.Description.gameObject:SetActiveEx(true) + end +end + +function XUiGridPlayer:Move(routeIdList, cb) + if not routeIdList then return end + local tagId = routeIdList[1] + local lastId = routeIdList[#routeIdList] + + local tagPos = tagId and self.Base.NodeList[tagId].Transform.position + if tagPos and lastId then + local CurPosId = self.PlayerEntity:GetPosNodeId() + self.PlayerEntity:MoveTo(lastId) + self.PlayerEntity:UnMarkNodeEvent() + self.CurInNodeId = tagId + + self.Base.NodeList[self.CurOutNodeId]:PlayerInShow(false, true) + self.Base.NodeList[self.CurInNodeId]:PlayerInShow(true, true) + self.Base.NodeList[self.CurOutNodeId]:SetNodeState(XMaintainerActionConfigs.NodeState.Normal) + + self.Description.gameObject:SetActiveEx(false) + XLuaUiManager.SetMask(true) + self.PlayerMoveTimer = XUiHelper.DoWorldMove(self.Transform, tagPos, TweenSpeed, XUiHelper.EaseType.Linear, function () + XLuaUiManager.SetMask(false) + self.PlayerMoveTimer = nil + self.Base.NodeList[self.CurInNodeId]:SetNodeState(XMaintainerActionConfigs.NodeState.Normal) + self.CurOutNodeId = tagId + local nextRoute = routeIdList + table.remove(nextRoute,1) + self:Move(nextRoute, cb) + end) + else + self:SetCurNodeNameTag() + self.Description.gameObject:SetActiveEx(true) + if cb then cb() end + end +end + +function XUiGridPlayer:SetCurNodeNameTag() + self.CurNodeText.text = self.Base.NodeList[self.CurInNodeId].NoteEntity:GetName() +end + +function XUiGridPlayer:DoChangeDirection() + self.PlayerEntity:DoChangeDirection() +end + +function XUiGridPlayer:StopTween() + if self.PlayerMoveTimer then + XScheduleManager.UnSchedule(self.PlayerMoveTimer) + self.PlayerMoveTimer = nil + XLuaUiManager.SetMask(false) + end +end + +return XUiGridPlayer \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMaintainerAction/XUiGridRecord.lua b/Resources/Scripts/XUi/XUiMaintainerAction/XUiGridRecord.lua new file mode 100644 index 00000000..1250e873 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMaintainerAction/XUiGridRecord.lua @@ -0,0 +1,27 @@ +local XUiGridRecord = XClass(nil, "XUiGridRecord") +local DefaultIndex = 1 + +function XUiGridRecord:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiGridRecord:UpdateGrid(data) + self.Data = data + if data then + self.TextTime.text = XTime.TimestampToGameDateTimeString(data.Time, "MM-dd HH:mm") + local eventInfo = XMaintainerActionConfigs.GetMaintainerActionEventTemplateById(data.EventId) + + if XMaintainerActionConfigs.IsFightEvent(data.EventId) then + local stageCfg = XDataCenter.FubenManager.GetStageCfg(data.EventValues[DefaultIndex]) + local tmpStr = string.format(eventInfo.RecordText,stageCfg.Name) + self.TextRecording.text = string.format("%s%s", XPlayer.Name, tmpStr) + else + local tmpStr = string.format(eventInfo.RecordText,table.unpack(data.EventValues)) + self.TextRecording.text = string.format("%s%s", XPlayer.Name, tmpStr) + end + end +end + +return XUiGridRecord \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMaintainerAction/XUiPanelBelow.lua b/Resources/Scripts/XUi/XUiMaintainerAction/XUiPanelBelow.lua new file mode 100644 index 00000000..b8cb1653 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMaintainerAction/XUiPanelBelow.lua @@ -0,0 +1,157 @@ +local XUiPanelBelow = XClass(nil, "XUiPanelBelow") +local XUiGridCard = require("XUi/XUiMaintainerAction/XUiGridCard") +local CSTextManagerGetText = CS.XTextManager.GetText +local MaxCardCount = 3 +local MaxMentorCount = 1 +function XUiPanelBelow:Ctor(ui,base) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Base = base + XTool.InitUiObject(self) + self:CreatePanel() + self:SetButtonCallBack() + self:UnSelectAllCard() +end + +function XUiPanelBelow:SetButtonCallBack() + self.BtnRecording.CallBack = function() + self:OnBtnRecordingClick() + end +end + +function XUiPanelBelow:OnBtnRecordingClick() + XDataCenter.MaintainerActionManager.PlayerRecordRequest(function () + XLuaUiManager.Open("UiFubenMaintaineractionRecording") + end) +end + +function XUiPanelBelow:CreatePanel() + self.BattleCount:GetObject("Title").text = CSTextManagerGetText("MaintainerActionWinCount") + self.BattleFinish:GetObject("Title").text = CSTextManagerGetText("MaintainerActionWinCount") + + self.BoxCount:GetObject("Title").text = CSTextManagerGetText("MaintainerActionBoxCount") + self.BoxFinish:GetObject("Title").text = CSTextManagerGetText("MaintainerActionBoxCount") + + self.MentorCount:GetObject("Title").text = CSTextManagerGetText("MaintainerActionMentorCount") + self.MentorFinish:GetObject("Title").text = CSTextManagerGetText("MaintainerActionMentorCount") + + self.WarehouseCount:GetObject("Title").text = CSTextManagerGetText("MaintainerActionWarehouseCount") + self.WarehouseFinish:GetObject("Title").text = CSTextManagerGetText("MaintainerActionWarehouseCount") + + self.ActionCount:GetObject("Title").text = CSTextManagerGetText("MaintainerActionDayPower") + + self.CardPos = {[1] = self.PanelOperating:GetObject("Pos1").transform.localPosition, + [2] = self.PanelOperating:GetObject("Pos2").transform.localPosition, + [3] = self.PanelOperating:GetObject("Pos3").transform.localPosition, + [4] = self.PanelOperating:GetObject("PosNew").transform.localPosition} + + local btnCard = self.PanelOperating:GetObject("BtnCard") + btnCard.gameObject:SetActiveEx(false) + + local gameData = XDataCenter.MaintainerActionManager.GetGameData() + self.CardList = {} + for index=1, MaxCardCount do + local obj = CS.UnityEngine.Object.Instantiate(btnCard) + obj.gameObject:SetActiveEx(true) + obj.transform:SetParent(self.PanelOperating.transform, false) + obj.transform.localPosition = self.CardPos[index] + local grid = XUiGridCard.New(obj,self) + local cardNums = gameData:GetCards() + grid:SetCardNum(cardNums[index] or 0) + grid:SetCardPosId(index) + table.insert(self.CardList, grid) + end +end + +function XUiPanelBelow:UnSelectAllCard() + for _,card in pairs(self.CardList) do + card:SetCardState(XMaintainerActionConfigs.CardState.Normal) + end +end + +function XUiPanelBelow:UpdatePanel() + local gameData = XDataCenter.MaintainerActionManager.GetGameData() + local mapNodeList = XDataCenter.MaintainerActionManager.GetMapNodeList() + + self.BattleCount:GetObject("Count").text = gameData:GetFightWinCount() + self.BattleCount:GetObject("CountMax").text = string.format("/%d", gameData:GetMaxFightWinCount()) + self.BattleCount.gameObject:SetActiveEx(not gameData:IsFightOver()) + self.BattleFinish.gameObject:SetActiveEx(gameData:IsFightOver()) + + self.BoxCount:GetObject("Count").text = gameData:GetBoxCount() + self.BoxCount:GetObject("CountMax").text = string.format("/%d", gameData:GetMaxBoxCount()) + self.BoxCount.gameObject:SetActiveEx(not gameData:IsBoxOver()) + self.BoxFinish.gameObject:SetActiveEx(gameData:IsBoxOver()) + + self.ActionCount:GetObject("Count").text = gameData:GetUsedActionCount() + self.ActionCount:GetObject("CountMax").text = string.format("/%d",gameData:GetMaxDailyActionCount() + gameData:GetExtraActionCount()) + + self.PanelWarehouse.gameObject:SetActiveEx(gameData:GetHasWarehouseNode()) + if gameData:GetHasWarehouseNode() then + self.WarehouseCount.gameObject:SetActiveEx(not gameData:IsWarehouseOver()) + self.WarehouseFinish.gameObject:SetActiveEx(gameData:IsWarehouseOver()) + self.WarehouseCount:GetObject("Count").text = gameData:GetWarehouseFinishCount() + self.WarehouseCount:GetObject("CountMax").text = string.format("/%d", gameData:GetMaxWarehouseFinishCount()) + end + + self.PanelMentor.gameObject:SetActiveEx(gameData:GetHasMentorNode()) + if gameData:GetHasMentorNode() then + self.MentorCount.gameObject:SetActiveEx(not gameData:IsMentorOver()) + self.MentorFinish.gameObject:SetActiveEx(gameData:IsMentorOver()) + self.MentorCount:GetObject("Count").text = gameData:IsMentorOver() and 1 or 0 + self.MentorCount:GetObject("CountMax").text = string.format("/%d", MaxMentorCount) + end + + for _,card in pairs(self.CardList) do + local route = self.Base.CardRouteList[card.CurNum] + if route then + local node = mapNodeList[route[#route]] + card:ShowTag(node:GetIsFight()) + end + end +end + +function XUiPanelBelow:GetNewCard() + for _,card in pairs(self.CardList) do + card:GetCard() + card:ShowTag(false) + end +end + +function XUiPanelBelow:ChangeCard(oldCard, newCard, cb) + local targetCard = nil + for _,card in pairs(self.CardList) do + if card.CurNum == oldCard then + targetCard = card + end + end + if not targetCard then + XLog.Error("Card Is Not Exist Id:" .. oldCard) + return + end + targetCard:Change(newCard, function () + for _,card in pairs(self.CardList) do + card:GetCard() + card:ShowTag(false) + end + if cb then cb() end + end) +end + +function XUiPanelBelow:DisableAllCard(IsComplete) + if not IsComplete then + return + end + for _,card in pairs(self.CardList) do + card:SetCardState(XMaintainerActionConfigs.CardState.Disable) + card:ShowTag(false) + end +end + +function XUiPanelBelow:StopCardTween() + for _,card in pairs(self.CardList) do + card:StopTween() + end +end + +return XUiPanelBelow \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMaintainerAction/XUiPanelIntermediate.lua b/Resources/Scripts/XUi/XUiMaintainerAction/XUiPanelIntermediate.lua new file mode 100644 index 00000000..ffa2d401 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMaintainerAction/XUiPanelIntermediate.lua @@ -0,0 +1,166 @@ +local XUiPanelIntermediate = XClass(nil, "XUiPanelIntermediate") +local XUiGridMapNote = require("XUi/XUiMaintainerAction/XUiGridMapNote") +local XUiGridPlayer = require("XUi/XUiMaintainerAction/XUiGridPlayer") +local MapNodeMaxCount = 16 +local RouteType = { + MoveRoute = 1, + CradRoute = 2, +} +function XUiPanelIntermediate:Ctor(ui,base) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Base = base + XTool.InitUiObject(self) + self.GridMap.gameObject:SetActiveEx(false) + self.Avatar.gameObject:SetActiveEx(false) + self:CreatStageMap() +end + +function XUiPanelIntermediate:CreatStageMap() + local mapNodeList = XDataCenter.MaintainerActionManager.GetMapNodeList() + local playerDic = XDataCenter.MaintainerActionManager.GetPlayerDic() + self.LineList = {} + self.IatticeList = {} + self.NodeList = {} + self.PlayerList = {} + for i = 1, MapNodeMaxCount do + local line = self.PanelLine:GetObject(string.format("Line%d",i)) + local Iattice = self.PanelIattice:GetObject(string.format("Iattice%d",i)) + if not line or not Iattice then + break + else + table.insert(self.LineList, line) + table.insert(self.IatticeList, Iattice) + line.gameObject:SetActiveEx(false) + end + end + + for _,mapNode in pairs(mapNodeList)do + local ui = CS.UnityEngine.Object.Instantiate(self.GridMap,self.IatticeList[mapNode:GetId() + 1]) + ui.gameObject:SetActiveEx(true) + local grid = XUiGridMapNote.New(ui,self) + grid:UpdateNote(mapNode) + --if mapNode:GetIsNeedPlayAnime() then + -- grid:PlayEventAnime() + --end + self.NodeList[mapNode:GetId()] = grid + end + + for key,player in pairs(playerDic)do + local ui = CS.UnityEngine.Object.Instantiate(self.Avatar,self.Transform) + ui.gameObject:SetActiveEx(true) + local grid = XUiGridPlayer.New(ui,self) + grid:SetPlayerData(player) + self.PlayerList[key] = grid + end +end + +function XUiPanelIntermediate:UpdatePanel() + local mapNodeList = XDataCenter.MaintainerActionManager.GetMapNodeList() + for _,mapNode in pairs(mapNodeList)do + self.NodeList[mapNode:GetId()]:UpdateNote(mapNode) + end +end + +function XUiPanelIntermediate:SetCurNodeNameTag(id) + local player = self.PlayerList[id] + if player then + player:SetCurNodeNameTag() + end +end + +function XUiPanelIntermediate:MovePlayerById(id,targetNodeId,cb) + local player = self.PlayerList[id] + if player then + local route = self:CreateRoute(id,nil,targetNodeId,RouteType.MoveRoute) + player:Move(route,cb) + end +end + +function XUiPanelIntermediate:ReverseMovePlayerById(id,targetNodeId,cb) + local player = self.PlayerList[id] + if player then + player:DoChangeDirection() + local route = self:CreateRoute(id,nil,targetNodeId,RouteType.MoveRoute) + player:DoChangeDirection() + player:Move(route,cb) + end +end + +function XUiPanelIntermediate:CreateRoute(id,cardNum,targetNodeId,type) + local playerDic = XDataCenter.MaintainerActionManager.GetPlayerDic() + local player = playerDic[id] + if not player then return nil end + + local route = {} + local curNodeId = player:GetPosNodeId() + local IsInStartNode = (curNodeId == 0) + if type == RouteType.MoveRoute then + local IsFirst = true + for index = 1 , MapNodeMaxCount do + if not IsFirst then + table.insert(route,curNodeId) + end + if curNodeId == targetNodeId then + break + end + if not player:GetIsReverse() then + curNodeId = curNodeId < MapNodeMaxCount - 1 and curNodeId + 1 or 0 + else + curNodeId = curNodeId > 0 and curNodeId - 1 or MapNodeMaxCount - 1 + end + IsFirst = false + end + elseif type == RouteType.CradRoute then + local IsFirst = true + for index = 1 , cardNum + 1 do + table.insert(route,curNodeId) + if not IsFirst then + if curNodeId == 0 then + break + end + end + if not player:GetIsReverse() then + curNodeId = curNodeId < MapNodeMaxCount - 1 and curNodeId + 1 or 0 + else + curNodeId = curNodeId > 0 and curNodeId - 1 or (not IsInStartNode and 0 or MapNodeMaxCount - 1) + end + IsFirst = false + end + end + return route +end + +function XUiPanelIntermediate:ShowCardSelectRoute(cardNum) + local route = self.Base.CardRouteList[cardNum] + if not route then + return + end + + for _,node in pairs(self.NodeList)do + node:SetNodeState(XMaintainerActionConfigs.NodeState.Normal) + end + + for _,routeId in pairs(route) do + self.NodeList[routeId]:SetNodeState(XMaintainerActionConfigs.NodeState.OnRoute) + end + self.NodeList[route[#route]]:SetNodeState(XMaintainerActionConfigs.NodeState.Target) +end + +function XUiPanelIntermediate:CreateCardRouteList() + local gameData = XDataCenter.MaintainerActionManager.GetGameData() + self.Base.CardRouteList = {} + for _,card in pairs(gameData:GetCards()) do + local route = self:CreateRoute(XPlayer.Id,card,nil,RouteType.CradRoute) + self.Base.CardRouteList[card] = route + end +end + +function XUiPanelIntermediate:StopPlayerTween() + for _,player in pairs(self.PlayerList) do + player:StopTween() + end +end + + +return XUiPanelIntermediate \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMedal/XUiCollectionStyle.lua b/Resources/Scripts/XUi/XUiMedal/XUiCollectionStyle.lua new file mode 100644 index 00000000..2c480af4 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMedal/XUiCollectionStyle.lua @@ -0,0 +1,60 @@ +-- 收藏品样式脚本,负责不同布局样式的收藏品 + +local XUiCollectionStyle = XClass(nil, "XUiCollectionStyle") + +function XUiCollectionStyle:Ctor(ui, chapter) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Chapter = chapter + XTool.InitUiObject(self) + + self:Refresh() +end + +function XUiCollectionStyle:Refresh() + self:SetIcon() + self:SetScore() +end + +function XUiCollectionStyle:SetIcon() + if self.RImIcon then + if self.Chapter.MedalImg ~= nil and not self.Chapter.IsLock then + self.RImIcon:SetRawImage(self.Chapter.MedalImg) + self.RImIcon.gameObject:SetActiveEx(true) + else + self.RImIcon.gameObject:SetActiveEx(false) + end + end +end + +function XUiCollectionStyle:SetScore() + if self.TextScore then + local showScore = self.Chapter.ShowScore ~= XMedalConfigs.ShowScore.OFF + self.TextScore.gameObject:SetActiveEx(self.Chapter.Score > 0 and showScore) + + if self.Chapter.Type == XMedalConfigs.MedalType.Experience then + local curLevel, _ = XMedalConfigs.GetSpecialCollectionCurLevelAndNextScoreByScore(self.Chapter.Id, self.Chapter.Score) + self.TextScore.text = curLevel + if showScore then + self:SetScoreTextSize(curLevel) + end + else + self.TextScore.text = self.Chapter.Score + if showScore then + self:SetScoreTextSize(self.Chapter.Score) + end + end + end +end + +--- +--- 根据'score'的位数设置self.ScoreTxt的字体大小 +---@param score number +function XUiCollectionStyle:SetScoreTextSize(score) + local fontSize = XDataCenter.MedalManager.GetScoreSize(score, self.RImIcon.rectTransform.rect.width) + if fontSize then + self.TextScore.fontSize = fontSize + end +end + +return XUiCollectionStyle \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMedal/XUiCollectionTip.lua b/Resources/Scripts/XUi/XUiMedal/XUiCollectionTip.lua new file mode 100644 index 00000000..90d3e430 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMedal/XUiCollectionTip.lua @@ -0,0 +1,125 @@ +local XUiCollectionTip = XLuaUiManager.Register(XLuaUi, "UiCollectionTip") +local HintColor = CS.XGame.ClientConfig:GetString("CollectionHintColor") +local Json = require("XCommon/Json") +local XUiCollectionStyle = require("XUi/XUiMedal/XUiCollectionStyle") + +function XUiCollectionTip:OnStart(data, inType) + self.Data = data + self.InType = inType + self.CollectionStyleDic = {} -- Key:收藏品Id Value:XUiCollectionStyle脚本 + + self.BtnClose.CallBack = function() + self:Close() + end + self.TxtHint = { self.TxtHint1, self.TxtHint2, self.TxtHint3, self.TxtHint4 } + self:SetDetail() +end + +function XUiCollectionTip:OnEnable() + +end + +function XUiCollectionTip:SetDetail() + if self.InType ~= XDataCenter.MedalManager.InType.OtherPlayer then + XDataCenter.MedalManager.SetMedalForOld(self.Data.Id, self.Data.Type) + end + self:SetDetailData() + self:ShowLock(self.Data.IsLock) +end + +function XUiCollectionTip:ShowLock(IsLock) + self.RImgIconLock.gameObject:SetActiveEx(IsLock) + self.ImgConditionUnlock.gameObject:SetActiveEx(not IsLock) +end + +function XUiCollectionTip:SetDetailData() + self.TxtCollectionName.text = self.Data.Name + self.TxtInfo.text = self.Data.WorldDesc + self.TxtCondition.text = self.Data.GetDesc + + local styleObj = self.CollectionStyleNode.gameObject:LoadPrefab(self.Data.PrefabPath) + self.CollectionStyleDic[self.Data.Id] = XUiCollectionStyle.New(styleObj, self.Data) + + if self.Data.MedalImg ~= nil then + self.RImgIconLock:SetRawImage(self.Data.MedalImg) + end + + local levelIcon = XDataCenter.MedalManager.GetLevelIcon(self.Data.Id, self.Data.Quality) + if levelIcon then + self:SetUiSprite(self.IconLevel, levelIcon) + self.IconLevel.gameObject:SetActiveEx(true) + else + self.IconLevel.gameObject:SetActiveEx(false) + end + + if self.Data.ExpandInfo then + -- 拥有服务器下发的扩展信息 + for _, text in pairs(self.TxtHint) do + text.gameObject:SetActiveEx(false) + end + + if self.Data.Type == XMedalConfigs.MedalType.Anniversary then + -- 周年庆收藏品 + local jsonFormatData = Json.decode(self.Data.ExpandInfo) + + for index, text in pairs(self.TxtHint) do + if self.Data.ExpandInfoId[index] then + local hintText + local serverKey = XMedalConfigs.GetExpandInfoStrServerKeyById(self.Data.ExpandInfoId[index]) + local data = jsonFormatData[serverKey] + if data == 0 then + -- 数据为空 + hintText = XMedalConfigs.GetExpandInfoEmptyDescById(self.Data.ExpandInfoId[index]) + else + -- 解析数据 + local dataTxt + if serverKey == XMedalConfigs.ExpandInfoType.CreateTime then + -- 首次进入游戏的时间 + dataTxt = XTime.TimestampToLocalDateTimeString(data, "yyyy/MM/dd") + elseif serverKey == XMedalConfigs.ExpandInfoType.MaxAssignChapter then + -- 边界公约最高通关章节 + local chapterData = XDataCenter.FubenAssignManager.GetChapterDataById(data) + dataTxt = chapterData:GetName() + elseif serverKey == XMedalConfigs.ExpandInfoType.MaxCharacterLiberateLvCount then + -- 解放角色数 + dataTxt = data + elseif serverKey == XMedalConfigs.ExpandInfoType.MaxFubenBfrt then + -- 据点最高通关章节 + dataTxt = XDataCenter.BfrtManager.GetChapterName(data) + else + XLog.Error("XUiCollectionTip:SetDetailData函数错误,serverKey没有对应的类型") + return + end + hintText = string.format(XMedalConfigs.GetExpandInfoDescById(self.Data.ExpandInfoId[index]), dataTxt) + end + text.text = hintText + text.gameObject:SetActiveEx(true) + else + text.gameObject:SetActiveEx(false) + end + end + end + else + for index, text in pairs(self.TxtHint) do + if self.Data.Hint[index] then + text.text = self.Data.Hint[index] + text.gameObject:SetActiveEx(true) + if self.Data.Quality - self.Data.InitQuality >= index then + text.color = XUiHelper.Hexcolor2Color(HintColor) + end + else + text.gameObject:SetActiveEx(false) + end + end + end + + if self.Data.Type == XMedalConfigs.MedalType.Experience then + local curLevel, nextExp, exScore = XMedalConfigs.GetSpecialCollectionCurLevelAndNextScoreByScore(self.Data.Id, self.Data.Score) + self.TextLevel.text = CS.XTextManager.GetText("SpecialCollectionLevel", curLevel) + self.TextNum.text = string.format("%d/%d", math.min((self.Data.Score - exScore), nextExp), nextExp) + self.ImageExp.fillAmount = math.min((self.Data.Score - exScore), nextExp) / nextExp + self.PanelLevel.gameObject:SetActiveEx(true) + else + self.PanelLevel.gameObject:SetActiveEx(false) + end +end diff --git a/Resources/Scripts/XUi/XUiMedal/XUiGridCollection.lua b/Resources/Scripts/XUi/XUiMedal/XUiGridCollection.lua new file mode 100644 index 00000000..6581e230 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMedal/XUiGridCollection.lua @@ -0,0 +1,73 @@ +XUiGridCollection = XClass(nil, "XUiGridCollection") + +local XUiCollectionStyle = require("XUi/XUiMedal/XUiCollectionStyle") + +function XUiGridCollection:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.CollectionStyleDic = {} -- Key:收藏品Id Value:XUiCollectionStyle脚本 + + XTool.InitUiObject(self) + self:AutoAddListener() +end + +function XUiGridCollection:AutoAddListener() + self.BtnSelect.CallBack = function() + self:OnBtnSelect() + end +end + +function XUiGridCollection:OnBtnSelect() + XLuaUiManager.Open("UiCollectionTip", self.Chapter, self.InType) +end + +function XUiGridCollection:UpdateGrid(chapter, parent, inType) + self.Chapter = chapter + self.InType = inType + + local styleObj = self.CollectionStyleNode.gameObject:LoadPrefab(chapter.PrefabPath) + self.CollectionStyleDic[chapter.Id] = XUiCollectionStyle.New(styleObj, chapter) + + if chapter.MedalImg ~= nil then + self.ImgMedalIconlock:SetRawImage(chapter.MedalImg) + end + + self.TxtMedalName.text = chapter.Name + + local IsLock = chapter.IsLock + local rootUi = parent.Base or parent.RootUi + + local qualityImg = XArrangeConfigs.GeQualityPath(chapter.Quality) + if qualityImg then + rootUi:SetUiSprite(self.ImgQuality, qualityImg) + self.ImgQuality.gameObject:SetActiveEx(true) + else + self.ImgQuality.gameObject:SetActiveEx(false) + end + + local levelIcon = XDataCenter.MedalManager.GetLevelIcon(chapter.Id, chapter.Quality) + if levelIcon then + rootUi:SetUiSprite(self.ImgLevel, levelIcon) + self.ImgLevel.gameObject:SetActiveEx(true) + else + self.ImgLevel.gameObject:SetActiveEx(false) + end + + self:ShowLock(IsLock) + self:ShowRedPoint(XDataCenter.MedalManager.CheckIsNewMedalById(chapter.Id, chapter.Type)) +end + + +function XUiGridCollection:ShowUesing(bShow) + self.LabelPress.gameObject:SetActiveEx(bShow) +end + +function XUiGridCollection:ShowLock(Lock) + self.LabelLock.gameObject:SetActiveEx(Lock) +end + +function XUiGridCollection:ShowRedPoint(bShow) + if self.Red then + self.Red.gameObject:SetActiveEx(bShow) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMedal/XUiGridMedal.lua b/Resources/Scripts/XUi/XUiMedal/XUiGridMedal.lua new file mode 100644 index 00000000..af7e96f3 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMedal/XUiGridMedal.lua @@ -0,0 +1,47 @@ +XUiGridMedal = XClass(nil, "XUiGridMedal") + +function XUiGridMedal:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:AutoAddListener() +end + +function XUiGridMedal:AutoAddListener() + self.BtnSelect.CallBack = function() + self:OnBtnSelect() + end +end + +function XUiGridMedal:OnBtnSelect() + XLuaUiManager.Open("UiMeadalDetail", self.Chapter, self.InType) +end + +function XUiGridMedal:UpdateGrid(chapter,parent) + self.Parent = parent + self.Chapter = chapter + if chapter.MedalImg ~= nil then + self.ImgMedalIcon:SetRawImage(chapter.MedalImg) + self.ImgMedalIconlock:SetRawImage(chapter.MedalImg) + end + + self.TxtMedalName.text = chapter.Name + local IsLock = not XPlayer.IsMedalUnlock(self.Chapter.Id) + self:ShowUesing(XPlayer.CurrMedalId == self.Chapter.Id) + + self:ShowLock(IsLock) + self:ShowRedPoint(XDataCenter.MedalManager.CheckIsNewMedalById(self.Chapter.Id,XMedalConfigs.MedalType.Normal)) +end + +function XUiGridMedal:ShowUesing(bShow) + self.LabelPress.gameObject:SetActiveEx(bShow) +end + +function XUiGridMedal:ShowLock(Lock) + self.LabelLock.gameObject:SetActiveEx(Lock) + self.ImgMedalIcon.gameObject:SetActiveEx(not Lock) +end + +function XUiGridMedal:ShowRedPoint(bShow) + self.Red.gameObject:SetActiveEx(bShow) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMedal/XUiMeadalDetail.lua b/Resources/Scripts/XUi/XUiMedal/XUiMeadalDetail.lua new file mode 100644 index 00000000..8e134bbb --- /dev/null +++ b/Resources/Scripts/XUi/XUiMedal/XUiMeadalDetail.lua @@ -0,0 +1,93 @@ +local XUiMeadalDetail = XLuaUiManager.Register(XLuaUi, "UiMeadalDetail") + +local TextManager = CS.XTextManager +local UiButtonState = CS.UiButtonState +local TimestampToGameDateTimeString = XTime.TimestampToGameDateTimeString + +function XUiMeadalDetail:OnStart(data,inType) + self.Data = data + self.InType = inType + + self.BtnWear.CallBack = function() + self:OnBtnWear() + end + self.BtnUnload.CallBack = function() + self:OnBtnUnload() + end + self.BtnBack.CallBack = function() + self:Close() + end + self.BtnMainUi.CallBack = function() + XLuaUiManager.RunMain() + end + self:SetDetail() +end + +function XUiMeadalDetail:OnEnable() + self:PlayAnimation("MdealDetailsEnable") +end + +function XUiMeadalDetail:OnDestroy() + XDataCenter.GuideManager.ResetGuide() + XEventManager.DispatchEvent(XEventId.EVENT_FUNCTION_EVENT_COMPLETE) +end + +function XUiMeadalDetail:SetDetail() + if self.InType ~= XDataCenter.MedalManager.InType.OtherPlayer then + XDataCenter.MedalManager.SetMedalForOld(self.Data.Id,XMedalConfigs.MedalType.Normal) + end + + self:SetDetailData() + self:ShowLock(self.Data.IsLock) +end + +function XUiMeadalDetail:ShowLock(IsLock) + self.ImgLock.gameObject:SetActiveEx(IsLock) + self.ImgConditionUnlock.gameObject:SetActiveEx(not IsLock) + self.DisableHavent.gameObject:SetActiveEx(IsLock) + self.DisableUsed.gameObject:SetActiveEx(not IsLock) + self.PanelUnlock.gameObject:SetActiveEx(not IsLock) + + self.BtnWear.gameObject:SetActiveEx(true) + self.BtnUnload.gameObject:SetActiveEx(false) + + if self.InType ~= XDataCenter.MedalManager.InType.OtherPlayer then + if IsLock then + self.BtnWear:SetButtonState(UiButtonState.Disable) + else + if XPlayer.CurrMedalId == self.Data.Id then + self.BtnWear.gameObject:SetActiveEx(false) + self.BtnUnload.gameObject:SetActiveEx(true) + end + self.BtnWear:SetButtonState(UiButtonState.Normal) + end + else + self.BtnWear.gameObject:SetActiveEx(false) + end +end + +function XUiMeadalDetail:SetDetailData() + self.TxtMedalName.text = self.Data.Name + self.TxtMedaDetails.text = self.Data.Desc + self.TxtCondition.text = self.Data.UnlockDesc + if self.Data.MedalImg ~= nil then + self.RawImage:SetRawImage(self.Data.MedalImg) + end + + self.TxtUnlockTime.text = TextManager.GetText("DayOfGetMedal", TimestampToGameDateTimeString(self.Data.Time)) +end + +function XUiMeadalDetail:OnBtnWear() + if self.BtnWear.ButtonState == UiButtonState.Disable then + return + end + XPlayer.ChangeMedal(self.Data.Id, function() + self:ShowLock(false) + end) +end + +function XUiMeadalDetail:OnBtnUnload() + XPlayer.ChangeMedal(0, function() + self:ShowLock(false) + end) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMedal/XUiMedalUnlock.lua b/Resources/Scripts/XUi/XUiMedal/XUiMedalUnlock.lua new file mode 100644 index 00000000..5c961fd1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMedal/XUiMedalUnlock.lua @@ -0,0 +1,64 @@ +local XUiMedalUnlock = XLuaUiManager.Register(XLuaUi, "UiMedalUnlock") +local CLOSE_TIME = 2 +local IsInClose +function XUiMedalUnlock:OnStart() + + if XPlayer.NewMedalInfo then + self.TxtMedalName.text = XMedalConfigs.GetMeadalConfigById(XPlayer.NewMedalInfo.Id).Name + self.TxtUid.text = XPlayer.Id + self.TxtName.text = XPlayer.Name + self.BtnSkip.CallBack = function() + self:OnBtnSkip() + end + self:AddBtnUnlockCallBack() + IsInClose = false + else + local function action() + self:OnOpenMedalDetail() + end + XScheduleManager.ScheduleOnce(action, 0) + end +end + +function XUiMedalUnlock:OnDestroy() + +end + +function XUiMedalUnlock:AddBtnUnlockCallBack() + self.BtnUnlock.CallBack = function() + self:OnBtnUnlock() + end +end + +function XUiMedalUnlock:OnBtnSkip() + self:OnOpenMedalDetail() +end + +function XUiMedalUnlock:OnBtnUnlock() + if not IsInClose then + self:AddCloseTimer() + self:PlayAnimation("AnimEnableTwo") + end +end + +function XUiMedalUnlock:AddCloseTimer() + IsInClose = true + local time = 0 + local function action() + time = time + 1 + if time == CLOSE_TIME then + self:OnOpenMedalDetail() + end + end + XScheduleManager.Schedule(action, XScheduleManager.SECOND, CLOSE_TIME, 0) +end + +function XUiMedalUnlock:OnOpenMedalDetail() + local info = XPlayer.NewMedalInfo and XDataCenter.MedalManager.GetMedalById(XPlayer.NewMedalInfo.Id) or nil + if info then + XLuaUiManager.Open("UiMeadalDetail",info , XDataCenter.MedalManager.InType.Normal) + XLuaUiManager.Remove( "UiMedalUnlock") + else + XLuaUiManager.Remove( "UiMedalUnlock") + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMedal/XUiMedalUnlockTips.lua b/Resources/Scripts/XUi/XUiMedal/XUiMedalUnlockTips.lua new file mode 100644 index 00000000..1d1690e0 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMedal/XUiMedalUnlockTips.lua @@ -0,0 +1,29 @@ +local CLOSE_TIME = 2 + +local XUiMedalUnlockTips = XLuaUiManager.Register(XLuaUi, "UiMedalUnlockTips") + +function XUiMedalUnlockTips:OnStart(Id) + local meadalConfig = XMedalConfigs.GetMeadalConfigById(Id) + self.TextMedalName.text = meadalConfig.Name + if meadalConfig.MedalImg ~= nil then + self.ImgMedalIcon:SetRawImage(meadalConfig.MedalImg) + end + XLuaUiManager.SetMask(true) + self:AddCloseTimer() +end + +function XUiMedalUnlockTips:OnDestroy() + XLuaUiManager.SetMask(false) + XEventManager.DispatchEvent(XEventId.EVENT_MEDAL_TIPSOVER) +end + +function XUiMedalUnlockTips:AddCloseTimer() + local time = 0 + local function action() + time = time + 1 + if time == CLOSE_TIME then + XLuaUiManager.Remove( "UiMedalUnlockTips") + end + end + XScheduleManager.Schedule(action, XScheduleManager.SECOND, CLOSE_TIME, 0) +end diff --git a/Resources/Scripts/XUi/XUiMedal/XUiObtainCollection.lua b/Resources/Scripts/XUi/XUiMedal/XUiObtainCollection.lua new file mode 100644 index 00000000..624c7479 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMedal/XUiObtainCollection.lua @@ -0,0 +1,43 @@ +local XUiObtainCollection = XLuaUiManager.Register(XLuaUi, "UiObtainCollection") +local VIEW_MAX = 5 +function XUiObtainCollection:OnStart(rewardGoodsList) + self.Items = {} + self.GridCommon.gameObject:SetActive(false) + self:Refresh(rewardGoodsList) + self:AutoAddListener() +end + +function XUiObtainCollection:OnEnable() + self:PlayAnimation("AniObtain") + CS.XAudioManager.PlaySound(XSoundManager.UiBasicsMusic.Common_UiObtain) +end + +function XUiObtainCollection:OnDestroy() + XEventManager.DispatchEvent(XEventId.EVENT_FUNCTION_EVENT_COMPLETE) +end + +function XUiObtainCollection:AutoAddListener() + self.BtnCancel.CallBack = function() + self:OnBtnCancelClick() + end +end + +function XUiObtainCollection:OnBtnCancelClick() + self:Close() +end + +function XUiObtainCollection:Refresh(rewardGoodsList) + rewardGoodsList = XRewardManager.MergeAndSortRewardGoodsList(rewardGoodsList) + XUiHelper.CreateTemplates(self, self.Items, rewardGoodsList, XUiGridCommon.New, self.GridCommon, self.PanelContent, function(grid, data) + local quality = XDataCenter.MedalManager.GetQuality(data.TemplateId) + local levelIcon = XDataCenter.MedalManager.GetLevelIcon(data.TemplateId,quality) + grid:SetSyncQuality(quality) + grid:SetSyncLevelIcon(levelIcon) + grid:Refresh(data, nil, nil, false) + end) + if #self.Items < VIEW_MAX then + self.ScrView.enabled = false + else + self.ScrView.enabled = true + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMedal/XUiOtherPlayerGridMedal.lua b/Resources/Scripts/XUi/XUiMedal/XUiOtherPlayerGridMedal.lua new file mode 100644 index 00000000..cc21cf02 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMedal/XUiOtherPlayerGridMedal.lua @@ -0,0 +1,53 @@ +XUiOtherPlayerGridMedal = XClass(nil, "XUiOtherPlayerGridMedal") + +function XUiOtherPlayerGridMedal:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:AutoAddListener() + self.IsLock = false +end + +function XUiOtherPlayerGridMedal:AutoAddListener() + self.BtnMedal.CallBack = function() + self:OnBtnMedal() + end +end + +function XUiOtherPlayerGridMedal:OnBtnMedal() + if not self.IsLock then + self:OnOpenMedalDetail(self.MedalId) + end +end + +function XUiOtherPlayerGridMedal:UpdateGrid(chapter, medalInfos) + self.MedalId = chapter.Id + self.MedalInfos = medalInfos + if chapter.MedalImg ~= nil then + self.IconMedalUnLock:SetRawImage(chapter.MedalImg) + self.IconMedalLock:SetRawImage(chapter.MedalImg) + end + self:ShowLock(self:CheckMedalUnlock(self.MedalId)) +end + +function XUiOtherPlayerGridMedal:ShowLock(unLock) + self.IconMedalUnLock.gameObject:SetActiveEx(unLock) + self.IsLock = not unLock +end + +function XUiOtherPlayerGridMedal:CheckMedalUnlock(id) + for _, v in pairs(self.MedalInfos) do + if v.Id == id then + return true + end + end + return false +end + +function XUiOtherPlayerGridMedal:OnOpenMedalDetail(id) + local infoList = XDataCenter.MedalManager.CreateOtherPlayerMedalList(self.MedalInfos) + local info = infoList[id] + if info then + XLuaUiManager.Open("UiMeadalDetail", info, XDataCenter.MedalManager.InType.OtherPlayer) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMedal/XUiPanelMedal.lua b/Resources/Scripts/XUi/XUiMedal/XUiPanelMedal.lua new file mode 100644 index 00000000..2309161e --- /dev/null +++ b/Resources/Scripts/XUi/XUiMedal/XUiPanelMedal.lua @@ -0,0 +1,219 @@ +local XUiPanelMedal = XLuaUiManager.Register(XLuaUi, "UiPanelMedal") +local Dropdown = CS.UnityEngine.UI.Dropdown +local None = -1 +function XUiPanelMedal:OnStart(viewlType) + self.MedalView = XUiPanelMedalListView.New(self.PanelMedalScroll,XMedalConfigs.ViewType.Medal,self) + self.CollectionView = XUiPanelMedalListView.New(self.PanelCollectionScroll,XMedalConfigs.ViewType.Collection,self) + self.NameplateView = XUiPanelMedalListView.New(self.PanelNameplateScroll,XMedalConfigs.ViewType.Nameplate,self) + + self:InitDropdown() + self:InitButtonGroup(viewlType) + self:OnCheckBtnIsNotShow() + + XEventManager.AddEventListener(XEventId.EVENT_MEDAL_NOTIFY, self.ShowPanelMdeal, self) + XEventManager.AddEventListener(XEventId.EVENT_SCORETITLE_CHANGE, self.ShowPanelMdeal, self) + XEventManager.AddEventListener(XEventId.EVENT_MEDAL_REDPOINT_CHANGE, self.CheckRedPoint, self) + XEventManager.AddEventListener(XEventId.EVENT_MEDAL_USE, self.ShowPanelMdeal, self) + XEventManager.AddEventListener(XEventId.EVENT_NAMEPLATE_CHANGE, self.CheckRedPoint, self) +end + + +function XUiPanelMedal:OnEnable() + if self.NeedPlayMedalListEnable then + self:PlayAnimation("MedalListEnable") + end + self.NeedPlayMedalListEnable = true + self:SetTypeTagShowRed() + self:ShowPanelMdeal() +end + +function XUiPanelMedal:OnDisable() + self:ClearAllRedPoint() + if self.NameplateIsSel then + XDataCenter.MedalManager.SetNameplateRedPointDic() + end +end + +function XUiPanelMedal:SetTypeTagShowRed() + self.BtnXunzhang:ShowReddot(XDataCenter.MedalManager.CheckHaveNewMedalByType(XMedalConfigs.ViewType.Medal)) + self.BtnShoucangpin:ShowReddot(XDataCenter.MedalManager.CheckHaveNewMedalByType(XMedalConfigs.ViewType.Collection))--这里要改成类型检查 + self.BtnNameplate:ShowReddot(XDataCenter.MedalManager.CkeckHaveNewNameplate()) +end + +function XUiPanelMedal:OnDestroy() + XEventManager.RemoveEventListener(XEventId.EVENT_MEDAL_NOTIFY, self.ShowPanelMdeal, self) + XEventManager.RemoveEventListener(XEventId.EVENT_SCORETITLE_CHANGE, self.ShowPanelMdeal, self) + XEventManager.RemoveEventListener(XEventId.EVENT_MEDAL_REDPOINT_CHANGE, self.CheckRedPoint, self) + XEventManager.RemoveEventListener(XEventId.EVENT_MEDAL_USE, self.ShowPanelMdeal, self) + XEventManager.RemoveEventListener(XEventId.EVENT_NAMEPLATE_CHANGE, self.CheckRedPoint, self) +end + +function XUiPanelMedal:OnCheckBtnIsNotShow() + if XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.Medal) then + self.BtnXunzhang.gameObject:SetActive(false) + end + if XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.Medal) then + self.BtnShoucangpin.gameObject:SetActive(false) + end + if XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.Medal) then + self.BtnNameplate.gameObject:SetActive(false) + end +end + +function XUiPanelMedal:InitDropdown() + local screenTagList = XMedalConfigs.GetScoreScreenTagConfigs() + + self.BtnSort:ClearOptions() + self.BtnSort.captionText.text = CS.XTextManager.GetText("ScreenAll") + + local firstOp = Dropdown.OptionData() + firstOp.text = CS.XTextManager.GetText("ScreenAll") + self.BtnSort.options:Add(firstOp) + + for _,v in pairs(screenTagList) do + local op = Dropdown.OptionData() + op.text = v.Name or "" + self.BtnSort.options:Add(op) + end + self.CurScreenType = 0 + self.BtnSort.value = 0 + + self.BtnSort.onValueChanged:AddListener(function() + self.CurScreenType = self.BtnSort.value + self.CollectionView:Refresh(self.BtnSort.value) + end) +end + +function XUiPanelMedal:InitButtonGroup(viewType) + self.BtnXunzhang:SetDisable(not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.Medal)) + self.BtnShoucangpin:SetDisable(not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.Collection)) + self.BtnNameplate:SetDisable(not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.Nameplate)) + + self.TypeBtn = {self.BtnXunzhang,self.BtnShoucangpin, self.BtnNameplate} + self.CurType = None + self.BtnGroup:Init(self.TypeBtn, function(index) self:SelectType(index) end) + if viewType ~= None then + self.BtnGroup:SelectIndex(viewType) + end +end + +function XUiPanelMedal:SelectType(index) + local IsOpen = false + if index == XMedalConfigs.ViewType.Medal then + if XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.Medal) then + IsOpen = true + if not XDataCenter.MedalManager.CheckMedalStoryIsPlayed() then + XDataCenter.MovieManager.PlayMovie(XDataCenter.MedalManager.MedalStroyId) + XDataCenter.MedalManager.MarkMedalStory() + end + self:PlayAnimation("MedalListEnable") + end + elseif index == XMedalConfigs.ViewType.Collection then + if XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.Collection) then + IsOpen = true + self:PlayAnimation("CollectionScrollQieHuan",function () + XDataCenter.MedalManager.CheckQualityUpCollection() + end) + end + elseif index == XMedalConfigs.ViewType.Nameplate then + if XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.Nameplate) then + IsOpen = true + self:PlayAnimation("NameplateScrollEnable",function () + + end) + end + self.NameplateIsSel = true + end + if IsOpen then + self:ClearAllRedPoint(index) + self.CurType = index + else + if self.CurType ~= None then + local exType = self.CurType + self.CurType = None + self.BtnGroup:SelectIndex(exType) + end + end + self.PanelNone.gameObject:SetActiveEx(self.CurType == None) + self.EmptyText.text = CS.XTextManager.GetText("NotOpenCollection") + + if self.NameplateIsSel and self.CurType ~= XMedalConfigs.ViewType.Nameplate then + XDataCenter.MedalManager.SetNameplateRedPointDic() + end + + self:ShowPanelMdeal() +end + +function XUiPanelMedal:ClearAllRedPoint(index) + local medaldatas = XDataCenter.MedalManager.GetMedals() + local ScoreTitledatas = XDataCenter.MedalManager.GetScoreTitle() + if index then + if self.CurType ~= index then + if self.CurType == XMedalConfigs.ViewType.Medal then + self:DoClearRedPoint(medaldatas) + elseif self.CurType == XMedalConfigs.ViewType.Collection then + self:DoClearRedPoint(ScoreTitledatas) + end + end + else + self:DoClearRedPoint(medaldatas) + self:DoClearRedPoint(ScoreTitledatas) + end +end + +function XUiPanelMedal:DoClearRedPoint(datas) + for _,data in pairs(datas) do + if not data.IsLock then + XDataCenter.MedalManager.SetMedalForOld(data.Id,data.Type) + end + end +end + +function XUiPanelMedal:SetMedalCount() + if self.CurType ~= XMedalConfigs.ViewType.Medal then + self.PanelAchvReach.gameObject:SetActiveEx(false) + return + end + + local maxCount = 0 + local nowCount = 0 + local medalsList = XDataCenter.MedalManager.GetMedals() + for _, medal in pairs(medalsList or {}) do + maxCount = maxCount + 1 + if not medal.IsLock then + nowCount = nowCount + 1 + end + end + self.PanelAchvReach.gameObject:SetActiveEx(true) + self.TxtAchvGetCount.text = string.format("%d%s%d", nowCount, "/", maxCount) +end + +function XUiPanelMedal:RefreshMedalListView() + self.MedalView.GameObject:SetActiveEx(false) + self.CollectionView.GameObject:SetActiveEx(false) + self.NameplateView.GameObject:SetActiveEx(false) + + if self.CurType == XMedalConfigs.ViewType.Medal then + self.BtnSort.gameObject:SetActiveEx(false) + self.MedalView.GameObject:SetActiveEx(true) + self.MedalView:Refresh() + elseif self.CurType == XMedalConfigs.ViewType.Collection then + self.BtnSort.gameObject:SetActiveEx(true) + self.CollectionView.GameObject:SetActiveEx(true) + self.CollectionView:Refresh(self.CurScreenType) + elseif self.CurType == XMedalConfigs.ViewType.Nameplate then + self.BtnSort.gameObject:SetActiveEx(false) + self.NameplateView.GameObject:SetActiveEx(true) + self.NameplateView:Refresh() + end +end + +function XUiPanelMedal:ShowPanelMdeal() + self:RefreshMedalListView() + self:SetMedalCount() +end + +function XUiPanelMedal:CheckRedPoint() + self:RefreshMedalListView() + self:SetTypeTagShowRed() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMedal/XUiPanelMedalListView.lua b/Resources/Scripts/XUi/XUiMedal/XUiPanelMedalListView.lua new file mode 100644 index 00000000..beff3d72 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMedal/XUiPanelMedalListView.lua @@ -0,0 +1,79 @@ +XUiPanelMedalListView = XClass(nil, "XUiPanelMedalListView") +local XUiGridNameplate = require("XUi/XUiNameplate/XUiGridNameplate") +function XUiPanelMedalListView:Ctor(ui, type, base) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Type = type + self.Base = base + XTool.InitUiObject(self) + + self:AddListener() + self:InitDynamicTable() +end + +function XUiPanelMedalListView:Refresh(screenType) + self:SetupDynamicTable(screenType) +end + + +function XUiPanelMedalListView:AddListener() + if self.Type == XMedalConfigs.ViewType.Collection then + self.BtnEnterCollectionWall.CallBack = function() + self:OnBtnEnterCollectionWallClick() + end + end +end + +function XUiPanelMedalListView:OnBtnEnterCollectionWallClick() + XLuaUiManager.Open("UiCollectionWall") +end + + +function XUiPanelMedalListView:InitDynamicTable() + if self.Type == XMedalConfigs.ViewType.Medal then + self.DynamicTable = XDynamicTableNormal.New(self.PanelMedalScroll) + self.DynamicTable:SetProxy(XUiGridMedal) + self.GridMedal.gameObject:SetActiveEx(false) + elseif self.Type == XMedalConfigs.ViewType.Collection then + self.DynamicTable = XDynamicTableNormal.New(self.PanelCollectionScroll) + self.DynamicTable:SetProxy(XUiGridCollection) + self.GridCollection.gameObject:SetActiveEx(false) + elseif self.Type == XMedalConfigs.ViewType.Nameplate then + self.DynamicTable = XDynamicTableNormal.New(self.PanelNameplateScroll) + self.DynamicTable:SetProxy(XUiGridNameplate) + self.GridNameplate.gameObject:SetActiveEx(false) + end + + self.DynamicTable:SetDelegate(self) +end + +function XUiPanelMedalListView:SetupDynamicTable(screenType) + if self.Type == XMedalConfigs.ViewType.Medal then + self.PageDatas = XDataCenter.MedalManager.GetMedals() + self.Base.EmptyText.text = CS.XTextManager.GetText("NotHaveMedal") + elseif self.Type == XMedalConfigs.ViewType.Collection then + self.PageDatas = XDataCenter.MedalManager.GetScoreTitleByScreenType(screenType) + self.Base.EmptyText.text = CS.XTextManager.GetText("NotHaveCollection") + elseif self.Type == XMedalConfigs.ViewType.Nameplate then + self.PageDatas = XDataCenter.MedalManager.GetNameplateGroupList() + self.Base.EmptyText.text = CS.XTextManager.GetText("NotHaveNameplate") + else + return + end + + self.DynamicTable:SetDataSource(self.PageDatas) + self.DynamicTable:ReloadDataSync(1) + self.Base.PanelNone.gameObject:SetActiveEx(not next(self.PageDatas)) +end + +function XUiPanelMedalListView:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + if self.Type == XMedalConfigs.ViewType.Medal then + grid:UpdateGrid(self.PageDatas[index], self) + elseif self.Type == XMedalConfigs.ViewType.Collection then + grid:UpdateGrid(self.PageDatas[index], self, XDataCenter.MedalManager.InType.Normal) + elseif self.Type == XMedalConfigs.ViewType.Nameplate then + grid:UpdateData(self.PageDatas[index], true, true) + end + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMedal/XUiUpgradeCollection.lua b/Resources/Scripts/XUi/XUiMedal/XUiUpgradeCollection.lua new file mode 100644 index 00000000..9a517343 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMedal/XUiUpgradeCollection.lua @@ -0,0 +1,23 @@ +local XUiUpgradeCollection = XLuaUiManager.Register(XLuaUi, "UiUpgradeCollection") + +function XUiUpgradeCollection:OnStart(collectionId,qualityData,cb) + self.BtnCancel.CallBack = function() + self:Close() + XScheduleManager.ScheduleOnce(function() + if cb then cb() end + end, 1) + end + + local rewardGoods = XRewardManager.CreateRewardGoods(collectionId) + + self:Refresh(rewardGoods,self.GridCommonBefore,qualityData.BeforeQuality) + self:Refresh(rewardGoods,self.GridCommonAfter,qualityData.AfterQuality) +end + +function XUiUpgradeCollection:Refresh(rewardGoods,gridCommon,quality) + local grid = XUiGridCommon.New(self,gridCommon) + local levelIcon = XDataCenter.MedalManager.GetLevelIcon(rewardGoods.TemplateId,quality) + grid:SetSyncQuality(quality) + grid:SetSyncLevelIcon(levelIcon) + grid:Refresh(rewardGoods, nil, nil, false) +end diff --git a/Resources/Scripts/XUi/XUiMentorSystem/MentorAnnouncement/XUiMentorAnnouncement.lua b/Resources/Scripts/XUi/XUiMentorSystem/MentorAnnouncement/XUiMentorAnnouncement.lua new file mode 100644 index 00000000..3c8adfcc --- /dev/null +++ b/Resources/Scripts/XUi/XUiMentorSystem/MentorAnnouncement/XUiMentorAnnouncement.lua @@ -0,0 +1,47 @@ +local XUiMentorAnnouncement = XLuaUiManager.Register(XLuaUi, "UiMentorAnnouncement") +local CSXTextManagerGetText = CS.XTextManager.GetText + +function XUiMentorAnnouncement:OnStart(oldMessage) + self:SetButtonCallBack() + local maxLength = XMentorSystemConfigs.GetMentorSystemData("MessageBoardMaxLen") + self.TxtNum.text = CSXTextManagerGetText("GuildInfoTextRange", maxLength) + self.InFContent.text = oldMessage or "" + self.OldMessage = oldMessage +end + +function XUiMentorAnnouncement:SetButtonCallBack() + self.BtnClose.CallBack = function() + self:Close() + end + self.BtnTanchuangClose.CallBack = function() + self:Close() + end + self.BtnSignCancel.CallBack = function() + self:Close() + end + self.BtnSignSure.CallBack = function() + self:OnBtnMessageSure() + end +end + +function XUiMentorAnnouncement:OnBtnMessageSure() + local messageText = string.gsub(self.InFContent.text, "^%s*(.-)%s*$", "%1") + local maxLength = XMentorSystemConfigs.GetMentorSystemData("MessageBoardMaxLen") + if string.len(messageText) > 0 then + local utf8Count = self.InFContent.textComponent.cachedTextGenerator.characterCount - 1 + if utf8Count > maxLength then + XUiManager.TipError(CSXTextManagerGetText("MentorMessageLengthTips", maxLength)) + return + end + if messageText == self.OldMessage then + XUiManager.TipText("MentorTeacherSameMessageHint") + return + end + XDataCenter.MentorSystemManager.MentorPublishMessageBoardRequest(messageText, function () + XUiManager.TipText("MentorMessageSendCompleteHint") + self:Close() + end) + else + XUiManager.TipText("MentorMessageIsEmpty") + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMentorSystem/MentorAwarenessGiveaway/XUiMentorAwarenessGiveaway.lua b/Resources/Scripts/XUi/XUiMentorSystem/MentorAwarenessGiveaway/XUiMentorAwarenessGiveaway.lua new file mode 100644 index 00000000..5998f6e5 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMentorSystem/MentorAwarenessGiveaway/XUiMentorAwarenessGiveaway.lua @@ -0,0 +1,402 @@ +local XUiMentorAwarenessGiveaway = XLuaUiManager.Register(XLuaUi, "UiMentorAwarenessGiveaway") +local XUiPanelEquipScroll = require("XUi/XUiEquipAwarenessReplace/XUiPanelEquipScroll") +local XUiPanelSuitSimpleScroll = require("XUi/XUiEquipAwarenessReplace/XUiPanelSuitSimpleScroll") +local XUiGridEquip = require("XUi/XUiEquipAwarenessReplace/XUiGridEquip") + +local type = type +local tableInsert = table.insert +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate +local CSXTextManagerGetText = CS.XTextManager.GetText +local CSXScheduleManagerUnSchedule = XScheduleManager.UnSchedule +local CSXScheduleManagerScheduleOnce = XScheduleManager.ScheduleOnce + +local MAX_MERGE_ATTR_COUNT = 4 +local MAX_RESONANCE_SKILL_COUNT = 6 +local GIVE_COUNT = 2 + +local ViewPattern = { + Suit = 1, + Quick = 2, +} + +function XUiMentorAwarenessGiveaway:OnAwake() + self:AutoAddListener() + self:InitComponentStatus() +end + +function XUiMentorAwarenessGiveaway:OnStart(studentId, taskId, callBack) + self.IsAscendOrder = false --初始降序 + self.LastViewPattern = ViewPattern.Suit + self.SelectedSuitStar = 5 + self.SelectedEquipSite = "Total" + self.SelectedEquipIdList = {} + self.TempSpriteList = {} + self.IsSending = false + self.StudentId = studentId + self.TaskId = taskId + self.CallBack = callBack + self.PanelTabBtns:Init({ + self.BtnSuit, + }, function(tabIndex) self:OnSelectViewPattern(tabIndex) end) + + self.PanelTogPos:Init({ + self.Tog1, + self.Tog2, + self.Tog3, + self.Tog4, + self.Tog5, + self.Tog6, + }, function(tabIndex) self:OnSelectEquipSite(tabIndex) end) + + self.PanelTogPosStar:Init({ + self.TogStar1, + self.TogStar2, + self.TogStar3, + self.TogStar4, + self.TogStar5, + }, function(tabIndex) self:OnSelectSuitStar(tabIndex) end) + + self:InitScrollPanel() + self:InitCurEquipGrids() +end + +function XUiMentorAwarenessGiveaway:OnEnable() + self:ResetPanel() +end + +function XUiMentorAwarenessGiveaway:OnDestroy() + for _, info in pairs(self.TempSpriteList) do + CS.UnityEngine.Object.Destroy(info.Sprite) + CS.XResourceManager.Unload(info.Resource) + end +end + + +function XUiMentorAwarenessGiveaway:OnGetEvents() + return { + XEventId.EVENT_EQUIP_RECYCLE_NOTIFY, + } +end + +function XUiMentorAwarenessGiveaway:OnNotify(evt, ...) + local args = { ... } + + if evt == XEventId.EVENT_EQUIP_RECYCLE_NOTIFY then + --有意识被回收时直接关闭界面 + XLuaUiManager.Close("UiMentorAwarenessPopup") + self:Close() + end +end + +function XUiMentorAwarenessGiveaway:ResetPanel() + self:UpdateCurEquipGrids() + self:UpdateViewData() + if self.LastViewPattern ~= ViewPattern.Quick then + self.PanelTabBtns:SelectIndex(self.LastViewPattern) + else + self:UpdateSuitDrdOptionList() + self:OnSelectSortType(XEquipConfig.PriorSortType.Star, true) + end +end + +function XUiMentorAwarenessGiveaway:InitComponentStatus() + self.GridSuitSimple.gameObject:SetActive(false) + self.Verticallayout = self.PanelAdapter:GetComponent("VerticalLayoutGroup") + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self.DrdSuit.onValueChanged:AddListener(function() + self:OnDrdSuitValueChanged() + end) +end + +function XUiMentorAwarenessGiveaway:UpdateViewData() + self.SiteToEquipIdsDic = XDataCenter.EquipManager.ConstructAwarenessSiteToEquipIdsDic(nil, true) + self.StarToSiteToSuitIdsDic = XDataCenter.EquipManager.ConstructAwarenessStarToSiteToSuitIdsDic(nil, true) + self.SuitIdToEquipIdsDic = XDataCenter.EquipManager.ConstructAwarenessSuitIdToEquipIdsDic(nil, true) +end + +function XUiMentorAwarenessGiveaway:UpdateSuitDrdOptionList() + self.DrdSuit:ClearOptions() + local optionDataList = CS.UnityEngine.UI.Dropdown.OptionDataList() + for _, suitId in pairs(self.StarToSiteToSuitIdsDic[self.SelectedSuitStar][self.SelectedEquipSite]) do + local optionData = CS.UnityEngine.UI.Dropdown.OptionData() + optionData.text = XDataCenter.EquipManager.GetSuitName(suitId) + + local resource = CS.XResourceManager.Load(XDataCenter.EquipManager.GetSuitIconBagPath(suitId)) + local texture = resource.Asset + local sprite = CS.UnityEngine.Sprite.Create(texture, + CS.UnityEngine.Rect(0, 0, texture.width, texture.height), + CS.UnityEngine.Vector2.zero) + optionData.image = sprite + optionDataList.options:Add(optionData) + + local info = { + Sprite = sprite, + Resource = resource, + } + tableInsert(self.TempSpriteList, info) + end + self.DrdSuit:AddOptions(optionDataList.options) +end + +function XUiMentorAwarenessGiveaway:InitScrollPanel() + local equipTouchCb = function(equipId) + self:OnSelectEquip(equipId) + end + + local suitTouchCb = function(suitId) + self:OnSelectViewPattern(ViewPattern.Quick) + self:UpdateSuitDrdOptionList() + self:UpdateDrdSuitValue(suitId) + end + + self.EquipScroll = XUiPanelEquipScroll.New(self, self.PanelEquipScroll, equipTouchCb) + self.SuitSimpleScroll = XUiPanelSuitSimpleScroll.New(self, self.PanelSuitSimpleScroll, suitTouchCb) +end + +function XUiMentorAwarenessGiveaway:InitCurEquipGrids() + self.CurEquipGirds = {} + + for index = 1, GIVE_COUNT, 1 do + local item = CSUnityEngineObjectInstantiate(self.GridCurAwareness) + self.CurEquipGirds[index] = XUiGridEquip.New(item, function() + local curId = self.SelectedEquipIdList[index] + if curId then + self:OnSelectEquip(curId) + end + end) + self.CurEquipGirds[index]:InitRootUi(self) + self.CurEquipGirds[index].Transform:SetParent(self[string.format("%s%d", "PanelPos", index)], false) + end +end + +function XUiMentorAwarenessGiveaway:UpdateCurEquipGrids() + for index = 1, GIVE_COUNT, 1 do + self:UpdateCurEquipGrid(index) + end +end + +function XUiMentorAwarenessGiveaway:UpdateCurEquipGrid(index) + local equipId = self.SelectedEquipIdList[index] + if not equipId then + self.CurEquipGirds[index].GameObject:SetActive(false) + self[string.format("%s%d", "PanelNoEquip", index)].gameObject:SetActive(true) + else + self.CurEquipGirds[index]:Refresh(equipId) + self.CurEquipGirds[index].GameObject:SetActive(true) + self[string.format("%s%d", "PanelNoEquip", index)].gameObject:SetActive(false) + end +end + +function XUiMentorAwarenessGiveaway:OnSelectSortType(sortType, doNotResetSelect, onlyUpdate) + if not onlyUpdate then + for key, list in pairs(self.SiteToEquipIdsDic) do + XDataCenter.EquipManager.SortEquipIdListByPriorType(list, sortType) + if self.IsAscendOrder then + XTool.ReverseList(list) + end + end + + for _, lists in pairs(self.SuitIdToEquipIdsDic) do + for key, list in pairs(lists) do + XDataCenter.EquipManager.SortEquipIdListByPriorType(list, sortType) + if self.IsAscendOrder then + XTool.ReverseList(list) + end + end + end + end + self:UpdateScroll(doNotResetSelect) +end + +function XUiMentorAwarenessGiveaway:OnSelectViewPattern(viewPattern) + self.LastViewPattern = viewPattern + + if viewPattern == ViewPattern.Suit then + self.PanelEquipScroll.gameObject:SetActive(false) + self.PanelSuitDropDown.gameObject:SetActive(false) + self.PanelTabBtns.gameObject:SetActive(true) + self.PanelTogPos.gameObject:SetActive(false) + self.PanelTogPosStar.gameObject:SetActive(true) + self.PanelTogPos.CanDisSelect = true + self.PanelSuitSimpleScroll.gameObject:SetActive(true) + + if type(self.SelectedEquipSite) == "number" then + self.PanelTogPos:SelectIndex(self.SelectedEquipSite) --重置位置选择 + end + self:PlayAnimation("SuitSimpleScrollQieHuan") + self:PlayAnimation("LeftEnableTwo") + + self.PanelTogPosStar:SelectIndex(self.SelectedSuitStar) + + elseif viewPattern == ViewPattern.Quick then + self.PanelEquipScroll.gameObject:SetActive(true) + self:PlayAnimation("LeftEnableOne") + self.PanelSuitSimpleScroll.gameObject:SetActive(false) + self.PanelSuitDropDown.gameObject:SetActive(true) + self.PanelTabBtns.gameObject:SetActive(false) + self.PanelTogPosStar.gameObject:SetActive(false) + self.PanelTogPos.CanDisSelect = true + self.PanelTogPos.gameObject:SetActive(true) + end +end + +function XUiMentorAwarenessGiveaway:OnSelectEquipSite(equipSite) + self.SelectedEquipSite = self.PanelTogPos.CanDisSelect and equipSite == self.SelectedEquipSite and "Total" or equipSite + + if self.LastViewPattern == ViewPattern.Quick then + self:UpdateSuitDrdOptionList() + self:UpdateDrdSuitValue(self.QuickLastSelectSuitId) + end + + self:OnSelectSortType(XEquipConfig.PriorSortType.Star) + self:PlayAnimation("EquipScrollQieHuan") +end + +function XUiMentorAwarenessGiveaway:OnSelectSuitStar(star) + self.SelectedSuitStar = star + self:OnSelectSortType(XEquipConfig.PriorSortType.Star) + self:PlayAnimation("EquipScrollQieHuan") +end + +function XUiMentorAwarenessGiveaway:OnSelectDrdSuit(suitId) + if not suitId then + return + end + self.SelectedSuitId = suitId + + self.PanelTogPosStar:SelectIndex(XDataCenter.EquipManager.GetSuitStar(suitId)) +end + +function XUiMentorAwarenessGiveaway:UpdateDrdSuitValue(suitId) + local findSuitInDrd = false + for k, v in pairs(self.StarToSiteToSuitIdsDic[self.SelectedSuitStar][self.SelectedEquipSite]) do + if v == suitId then + self.DrdSuit.value = k - 1 + findSuitInDrd = true + break + end + end + + -- 如果当前位置没有对应套装ID,那么也调用调度函数刷到下个套装显示 + if not findSuitInDrd then + if self.DrdSuit.value == 0 then + self:OnDrdSuitValueChanged() + else + self.DrdSuit.value = 0 + end + else + self:OnDrdSuitValueChanged() + end +end + +function XUiMentorAwarenessGiveaway:UpdateScroll(doNotResetSelect) + if not self.LastViewPattern then + return + end + + local scroll, idList + if self.LastViewPattern == ViewPattern.Suit then + + idList = self.StarToSiteToSuitIdsDic[self.SelectedSuitStar] and self.StarToSiteToSuitIdsDic[self.SelectedSuitStar][self.SelectedEquipSite] or {} + + scroll = self.SuitSimpleScroll + self.PanelNoSuitSimple.gameObject:SetActive(not next(idList)) + + elseif self.LastViewPattern == ViewPattern.Quick then + scroll = self.EquipScroll + idList = self.SuitIdToEquipIdsDic[self.SelectedSuitId] + and self.SuitIdToEquipIdsDic[self.SelectedSuitId][self.SelectedEquipSite] or {} + self.PanelNoEquip.gameObject:SetActive(not next(idList)) + end + + if scroll then + XLuaUiManager.Close("UiMentorAwarenessPopup") + + --NEVER DELETE ME! + CS.UnityEngine.UI.LayoutRebuilder.ForceRebuildLayoutImmediate(self.PanelAdapter) + if self.TimerId then + CSXScheduleManagerUnSchedule(self.TimerId) + self.TimerId = nil + end + self.TimerId = CSXScheduleManagerScheduleOnce(function() + if XTool.UObjIsNil(scroll.GameObject) then return end + scroll:UpdateEquipGridList(idList, doNotResetSelect, self.SelectedEquipSite) + end, 0) + end +end + +function XUiMentorAwarenessGiveaway:OnSelectEquip(equipId, needFixPopUpPos) + self.SelectEquipId = equipId + self:OpenChildUi() +end + +function XUiMentorAwarenessGiveaway:AutoAddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainClick) + self:RegisterClickEvent(self.BtnClosePopup, self.OnBtnClosePopupClick) + self:RegisterClickEvent(self.PanelEquipScroll, self.OnPanelEquipScrollClick) + self.BtnStand.CallBack = function() + self:OnBtnStandClick() + end +end + +function XUiMentorAwarenessGiveaway:OpenChildUi()--打开详情界面 + if not self.IsSending then + XLuaUiManager.Close("UiMentorAwarenessPopup") + XLuaUiManager.Open("UiMentorAwarenessPopup", self) + end +end + +function XUiMentorAwarenessGiveaway:OnPanelEquipScrollClick() + XLuaUiManager.Close("UiMentorAwarenessPopup") +end + +function XUiMentorAwarenessGiveaway:OnBtnClosePopupClick() + self.EquipScroll:ResetSelectGrid() + XLuaUiManager.Close("UiMentorAwarenessPopup") +end + +function XUiMentorAwarenessGiveaway:OnBtnStandClick() + if self:CheckUiPopupIsOpen() then + XLuaUiManager.Close("UiMentorAwarenessPopup") + return + end + + if not (self.SelectedEquipIdList and next(self.SelectedEquipIdList)) then + XUiManager.TipText("MentorTeacherGiftEmpeyHint") + return + end + + self.IsSending = true + XDataCenter.MentorSystemManager.MentorGiveRewardRequest(self.StudentId, self.TaskId, function() + self.SelectedEquipIdList = {} + self:ResetPanel() + self:Close() + self.CallBack() + end, function() + self.IsSending = false + end) +end + +function XUiMentorAwarenessGiveaway:OnBtnBackClick() + XLuaUiManager.Close("UiMentorAwarenessPopup") + if self.LastViewPattern == ViewPattern.Quick then + self.PanelTabBtns:SelectIndex(ViewPattern.Suit) + else + self:Close() + end +end + +function XUiMentorAwarenessGiveaway:OnBtnMainClick() + XLuaUiManager.RunMain() +end + +function XUiMentorAwarenessGiveaway:OnDrdSuitValueChanged() + local suitId = self.StarToSiteToSuitIdsDic[self.SelectedSuitStar][self.SelectedEquipSite][self.DrdSuit.value + 1] + self.QuickLastSelectSuitId = suitId + self:OnSelectDrdSuit(suitId) +end + +function XUiMentorAwarenessGiveaway:CheckUiPopupIsOpen() + return XLuaUiManager.IsUiLoad("UiMentorAwarenessPopup") or XLuaUiManager.IsUiShow("UiMentorAwarenessPopup") +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMentorSystem/MentorAwarenessGiveaway/XUiMentorAwarenessPopup.lua b/Resources/Scripts/XUi/XUiMentorSystem/MentorAwarenessGiveaway/XUiMentorAwarenessPopup.lua new file mode 100644 index 00000000..e620f3ad --- /dev/null +++ b/Resources/Scripts/XUi/XUiMentorSystem/MentorAwarenessGiveaway/XUiMentorAwarenessPopup.lua @@ -0,0 +1,112 @@ +local XUiMentorAwarenessPopup = XLuaUiManager.Register(XLuaUi, "UiMentorAwarenessPopup") +local XUiGridEquip = require("XUi/XUiEquipAwarenessReplace/XUiGridEquip") +local CSXTextManagerGetText = CS.XTextManager.GetText +local MAX_AWARENESS_ATTR_COUNT = 2 +local ButtonState = { + Select = 1, + UnSelect = 2, + } +local ButtonName = { + [1] = CSXTextManagerGetText("MentorSelectStudentGiveText"), + [2] = CSXTextManagerGetText("MentorUnSelectStudentGiveText"), +} +function XUiMentorAwarenessPopup:OnAwake() + self:AutoAddListener() +end + +function XUiMentorAwarenessPopup:OnStart(rootUi) + self.RootUi = rootUi +end + +function XUiMentorAwarenessPopup:OnEnable() + self.EquipId = self.RootUi.SelectEquipId + self:Refresh() + if self.RootUi.BtnClosePopup then + self.RootUi.BtnClosePopup.gameObject:SetActiveEx(true) + end +end + +function XUiMentorAwarenessPopup:OnDisable() + if self.RootUi.BtnClosePopup then + self.RootUi.BtnClosePopup.gameObject:SetActiveEx(false) + end +end + +function XUiMentorAwarenessPopup:Refresh() + self.UsingAttrMap = XDataCenter.EquipManager.GetEquipAttrMap(self.EquipId) + self:UpdateUsingPanel() +end + + +function XUiMentorAwarenessPopup:UpdateUsingPanel() + if not self.UsingEquipGrid then + self.UsingEquipGrid = XUiGridEquip.New(self.GridEquipUsing) + self.UsingEquipGrid:InitRootUi(self) + end + self.UsingEquipGrid:Refresh(self.EquipId) + + local equip = XDataCenter.EquipManager.GetEquip(self.EquipId) + self.TxtName.text = XDataCenter.EquipManager.GetEquipName(equip.TemplateId) + + local attrCount = 1 + local attrMap = self.UsingAttrMap + for _, attrInfo in pairs(attrMap or {}) do + if attrCount > MAX_AWARENESS_ATTR_COUNT then break end + + self["TxtUsingAttrName" .. attrCount].text = attrInfo.Name + self["TxtUsingAttrValue" .. attrCount].text = attrInfo.Value + self["PanelUsingAttr" .. attrCount].gameObject:SetActiveEx(true) + + attrCount = attrCount + 1 + end + for i = attrCount, MAX_AWARENESS_ATTR_COUNT do + self["PanelUsingAttr" .. i].gameObject:SetActiveEx(false) + end + + --是否激活颜色不同 + local suitId = XDataCenter.EquipManager.GetSuitId(equip.Id) + local skillDesList = XDataCenter.EquipManager.GetSuitActiveSkillDesList(suitId, 0) + + for i = 1, XEquipConfig.MAX_SUIT_SKILL_COUNT do + local componentText = self["TxtSkillDes" .. i] + if not skillDesList[i] then + componentText.gameObject:SetActiveEx(false) + else + componentText.text = skillDesList[i].SkillDes + componentText.gameObject:SetActiveEx(true) + end + end + + self:CheckButtonState() + local IsUnSelect = self.CurButtonState == ButtonState.UnSelect + self.BtnGift:SetName(ButtonName[self.CurButtonState]) + self.BtnGift.gameObject:SetActiveEx(IsUnSelect or (not IsUnSelect and #self.RootUi.SelectedEquipIdList < 2)) +end + +function XUiMentorAwarenessPopup:CheckButtonState() + self.CurButtonState = ButtonState.Select + for index,id in pairs(self.RootUi.SelectedEquipIdList or {}) do + if self.EquipId == id then + self.SelectIndex = index + self.CurButtonState = ButtonState.UnSelect + break + end + end +end + +function XUiMentorAwarenessPopup:AutoAddListener() + self.BtnGift.CallBack = function() + self:OnBtnGiftClick() + end +end + +function XUiMentorAwarenessPopup:OnBtnGiftClick() + if self.CurButtonState == ButtonState.UnSelect then + table.remove(self.RootUi.SelectedEquipIdList,self.SelectIndex) + else + table.insert(self.RootUi.SelectedEquipIdList,self.EquipId) + end + + self.RootUi:UpdateCurEquipGrids() + self.RootUi:OnSelectSortType(XEquipConfig.PriorSortType.Star, true, true) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMentorSystem/MentorFile/XUiGridPlayer.lua b/Resources/Scripts/XUi/XUiMentorSystem/MentorFile/XUiGridPlayer.lua new file mode 100644 index 00000000..9356b7d6 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMentorSystem/MentorFile/XUiGridPlayer.lua @@ -0,0 +1,34 @@ +local XUiGridPlayer = XClass(nil, "XUiGridPlayer") +local CSTextManagerGetText = CS.XTextManager.GetText +function XUiGridPlayer:Ctor(ui,IsTeacher) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.IsTeacher = IsTeacher + XTool.InitUiObject(self) + self:SetButtonCallBack() +end + +function XUiGridPlayer:SetButtonCallBack() + self.BtnPlayerInfo.CallBack = function() + self:OnBtnPlayerInfoClick() + end +end + +function XUiGridPlayer:OnBtnPlayerInfoClick() + if self.Data and self.Data.PlayerId and self.Data.PlayerId > 0 then + XDataCenter.PersonalInfoManager.ReqShowInfoPanel(self.Data.PlayerId) + end +end + +function XUiGridPlayer:UpdateGrid(data) + self.Data = data + if data and data.PlayerId and data.PlayerId > 0 then + self.TextName.text = data.PlayerName + self.TeacherLabel.gameObject:SetActiveEx(false) + self.TextState.text = self.IsTeacher and CSTextManagerGetText("MentorPlayerStateNoneText") or + (data.IsGraduate and CSTextManagerGetText("MentorPlayerStateGraduateText") or CSTextManagerGetText("MentorPlayerStateStudyText")) + XUiPLayerHead.InitPortrait(data.HeadPortraitId, data.HeadFrameId, self.Head) + end +end + +return XUiGridPlayer \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMentorSystem/MentorFile/XUiMentorFile.lua b/Resources/Scripts/XUi/XUiMentorSystem/MentorFile/XUiMentorFile.lua new file mode 100644 index 00000000..9413af94 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMentorSystem/MentorFile/XUiMentorFile.lua @@ -0,0 +1,61 @@ +local XUiMentorFile = XLuaUiManager.Register(XLuaUi, "UiMentorFile") +local XUiPanelTeacher = require("XUi/XUiMentorSystem/MentorFile/XUiPanelTeacher") +local XUiPanelStudent = require("XUi/XUiMentorSystem/MentorFile/XUiPanelStudent") +local CSTextManagerGetText = CS.XTextManager.GetText + +function XUiMentorFile:OnStart() + self:SetButtonCallBack() + self:InitPanel() + self.GridPlayer.gameObject:SetActiveEx(false) +end + +function XUiMentorFile:OnDestroy() + +end + +function XUiMentorFile:OnEnable() + self:UpdatePanel() +end + +function XUiMentorFile:OnDisable() + +end + +function XUiMentorFile:SetButtonCallBack() + self.BtnBack.CallBack = function() + self:OnBtnBackClick() + end + self.BtnMainUi.CallBack = function() + self:OnBtnMainUiClick() + end + self:BindHelpBtn(self.BtnHelp, "MentorSystemHelp") +end + +function XUiMentorFile:InitPanel() + local nameList = XDataCenter.MentorSystemManager.GetMentorShipNameList() + self.TeacherPanel = XUiPanelTeacher.New(self.PanelTeacher) + self.StudentPanel = XUiPanelStudent.New(self.PanelStudent) + self.GrandsonStudentPanel = XUiPanelStudent.New(self.PanelGrandsonStudent) +end + +function XUiMentorFile:UpdatePanel() + local nameList = XDataCenter.MentorSystemManager.GetMentorShipNameList() + self.TeacherPanel:UpdatePanel(nameList.MyTeacher) + self.StudentPanel:UpdatePanel(nameList.MySchoolmate) + self.GrandsonStudentPanel:UpdatePanel(nameList.MyStudents) + + local myIndex = self.StudentPanel:GetMyIndex() + local studentNode = self.TeacherPanel:GetParentNode() + local grandsonStudentNode = self.StudentPanel:GetParentNode(myIndex) + + self.StudentPanel:SetParentNode(studentNode) + self.GrandsonStudentPanel:SetParentNode(grandsonStudentNode) +end + +function XUiMentorFile:OnBtnBackClick() + self:Close() +end + +function XUiMentorFile:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMentorSystem/MentorFile/XUiPanelStudent.lua b/Resources/Scripts/XUi/XUiMentorSystem/MentorFile/XUiPanelStudent.lua new file mode 100644 index 00000000..6377e8d1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMentorSystem/MentorFile/XUiPanelStudent.lua @@ -0,0 +1,66 @@ +local XUiPanelStudent = XClass(nil, "XUiPanelStudent") +local XUiGridPlayer = require("XUi/XUiMentorSystem/MentorFile/XUiGridPlayer") +local Vector3 = CS.UnityEngine.Vector3 +function XUiPanelStudent:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.StudentGridList = {} + self.NodeList = { + self.Node1, + self.Node2, + self.Node3, + self.Node4, + } +end + +function XUiPanelStudent:UpdatePanel(data) + self.Data = data + if data and next(data) then + self.StudentGridList = self.StudentGridList or {} + for _,node in pairs(self.NodeList or {}) do + node.gameObject:SetActiveEx(false) + end + for index,student in pairs(data or {}) do + local node = self.NodeList[index] + if node then + node.gameObject:SetActiveEx(true) + if not self.StudentGridList[index] then + local obj = CS.UnityEngine.Object.Instantiate(self.GridPlayer) + obj.transform:SetParent(node:GetObject("PanelPlayer"), false) + obj.transform.localPosition = Vector3(0, 0, 0) + obj.gameObject:SetActiveEx(true) + local grid = XUiGridPlayer.New(obj,false) + table.insert(self.StudentGridList, grid) + end + self.StudentGridList[index]:UpdateGrid(student) + end + end + else + self.GameObject:SetActiveEx(false) + end +end + +function XUiPanelStudent:SetParentNode(parent) + self.Transform:SetParent(parent, false) + self.Transform.localPosition = Vector3(0, 0, 0) +end + +function XUiPanelStudent:GetParentNode(index) + local node = self.NodeList[index] + if node then + return node:GetObject("PanelNext") + end + return nil +end + +function XUiPanelStudent:GetMyIndex() + for index,student in pairs(self.Data or {}) do + if student.PlayerId == XPlayer.Id then + return index + end + end + return 0 +end + +return XUiPanelStudent \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMentorSystem/MentorFile/XUiPanelTeacher.lua b/Resources/Scripts/XUi/XUiMentorSystem/MentorFile/XUiPanelTeacher.lua new file mode 100644 index 00000000..422162ed --- /dev/null +++ b/Resources/Scripts/XUi/XUiMentorSystem/MentorFile/XUiPanelTeacher.lua @@ -0,0 +1,30 @@ +local XUiPanelTeacher = XClass(nil, "XUiPanelTeacher") +local XUiGridPlayer = require("XUi/XUiMentorSystem/MentorFile/XUiGridPlayer") +local Vector3 = CS.UnityEngine.Vector3 +function XUiPanelTeacher:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.TeacherGrid = {} +end + +function XUiPanelTeacher:UpdatePanel(data) + self.Data = data + self.TeacherGrid = self.TeacherGrid or {} + if not next(self.TeacherGrid) then + local obj = CS.UnityEngine.Object.Instantiate(self.GridPlayer) + obj.gameObject:SetActiveEx(true) + obj.transform:SetParent(self.PanelPlayer, false) + obj.transform.localPosition = Vector3(0, 0, 0) + self.TeacherGrid = XUiGridPlayer.New(obj,true) + end + if data then + self.TeacherGrid:UpdateGrid(data) + end +end + +function XUiPanelTeacher:GetParentNode() + return self.PanelNext +end + +return XUiPanelTeacher \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMentorSystem/MentorGiftTisp/XUiMentorGiftTisp.lua b/Resources/Scripts/XUi/XUiMentorSystem/MentorGiftTisp/XUiMentorGiftTisp.lua new file mode 100644 index 00000000..220adfc7 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMentorSystem/MentorGiftTisp/XUiMentorGiftTisp.lua @@ -0,0 +1,49 @@ +local XUiMentorGiftTisp = XLuaUiManager.Register(XLuaUi, "UiMentorGiftTisp") + +local CSXTextManagerGetText = CS.XTextManager.GetText + +function XUiMentorGiftTisp:OnStart() + self:SetButtonCallBack() + self:ShowPanel() +end + +function XUiMentorGiftTisp:SetButtonCallBack() + self.BtnClose.CallBack = function() + self:Close() + end + self.BtnTanchuangClose.CallBack = function() + self:Close() + end + self.BtnTask.CallBack = function() + self:OnBtnTaskClick() + end +end + +function XUiMentorGiftTisp:OnBtnTaskClick() + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.Task) then + return + end + XLuaUiManager.Open("UiTask") +end + +function XUiMentorGiftTisp:ShowPanel() + local activationItemId = XMentorSystemConfigs.GetMentorSystemData("ActivationItemId") + local itemCount = XMentorSystemConfigs.GetMentorSystemData("ActivationRewardCount") + + local activExpMaxCount = XMentorSystemConfigs.GetMentorSystemData("ActivationCount") + local activExpId = XDataCenter.ItemManager.ItemId.DailyActiveness + + local activExp = XDataCenter.ItemManager.GetItem(activExpId) + local activExpCount = activExp and math.min(activExp:GetCount(), activExpMaxCount) or 0 + local activationPercent = activExpCount/activExpMaxCount + + local giftReward = XRewardManager.CreateRewardGoods(activationItemId, itemCount) + local gridGift = XUiGridCommon.New(self, self.GridGift) + gridGift:Refresh(giftReward) + + self.TxtCurCount.text = activExpCount + self.TxtNeedCount.text = string.format("/%d",activExpMaxCount) + self.ImgProgress.fillAmount = activationPercent + self.TxtDescription.text = CSXTextManagerGetText("MentorTeacherGiftDesc") + self.TxtWorldDesc.text = CSXTextManagerGetText("MentorTeacherGiftHint") +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMentorSystem/MentorMain/XUiGridStudent.lua b/Resources/Scripts/XUi/XUiMentorSystem/MentorMain/XUiGridStudent.lua new file mode 100644 index 00000000..aa9a17c3 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMentorSystem/MentorMain/XUiGridStudent.lua @@ -0,0 +1,91 @@ +local XUiGridStudent = XClass(nil, "XUiGridStudent") +local DefaultIndex = 1 + +function XUiGridStudent:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:SetButtonCallBack() +end + +function XUiGridStudent:SetButtonCallBack() + self.PanelPlayer:GetObject("BtnInfo").CallBack = function() + self:OnBtnInfoClick() + end + + self.PanelPlayer:GetObject("BtnRecording").CallBack = function() + self:OnBtnRecordingClick() + end + + self.BtnStudentRecruit.CallBack = function() + self:OnBtnRecruitClick() + end +end + +function XUiGridStudent:OnBtnInfoClick() + XDataCenter.PersonalInfoManager.ReqShowInfoPanel(self.Data.PlayerId) +end + +function XUiGridStudent:OnBtnRecordingClick() + XLuaUiManager.Open("UiMentorRecording", self.Data, false) +end + +function XUiGridStudent:OnBtnRecruitClick() + XDataCenter.MentorSystemManager.GetMentorRecommendPlayerListRequest(function () + XLuaUiManager.Open("UiMentorRecommendation") + end) +end + +function XUiGridStudent:UpdateGrid(data) + self.Data = data + if data then + self:SetStudentInfo(data) + self:ShowStudent(true) + else + self:ShowStudent(false) + end + self:ShowMySelfTag(data) +end + +function XUiGridStudent:ShowMySelfTag(data) + self.PanelMy.gameObject:SetActiveEx(data and data.PlayerId == XPlayer.Id or false) +end + +function XUiGridStudent:ShowStudent(IsShow, IsTeacher) + local mentorData = XDataCenter.MentorSystemManager.GetMentorData() + self.PanelPlayer.gameObject:SetActiveEx(IsShow) + self.PanelNone.gameObject:SetActiveEx(not IsShow) + self.PanelNone:GetObject("TextStudent").gameObject:SetActiveEx(not IsShow and not mentorData:IsTeacher()) + self.PanelNone:GetObject("BtnStudentRecruit").gameObject:SetActiveEx(not IsShow and mentorData:IsTeacher()) + self.PanelPlayer:GetObject("BtnRecording").gameObject:SetActiveEx(mentorData:IsTeacher()) +end + +function XUiGridStudent:SetStudentInfo(data) + local tmpData = data + if data.PlayerId == XPlayer.Id then + tmpData.HeadPortraitId = XPlayer.CurrHeadPortraitId + tmpData.HeadFrameId = XPlayer.CurrHeadFrameId + tmpData.Level = XPlayer.Level + tmpData.PlayerName = XPlayer.Name + end + + local headObj = {} + if tmpData.IsOnline then + headObj = self.PanelPlayer:GetObject("HeadOnLine") + else + headObj = self.PanelPlayer:GetObject("HeadOffLine") + end + + XUiPLayerHead.InitPortrait(tmpData.HeadPortraitId, tmpData.HeadFrameId, headObj) + self.PanelPlayer:GetObject("HeadOnLine").gameObject:SetActiveEx(tmpData.IsOnline) + self.PanelPlayer:GetObject("HeadOffLine").gameObject:SetActiveEx(not tmpData.IsOnline) + + XUiPlayerLevel.UpdateLevel(tmpData.Level, self.PanelPlayer:GetObject("TxtLevel")) + self.PanelPlayer:GetObject("TxtName").text = tmpData.PlayerName +end + +function XUiGridStudent:ShowReddot(IsShow) + self.PanelNone:GetObject("BtnStudentRecruit"):ShowReddot(IsShow) +end + +return XUiGridStudent \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMentorSystem/MentorMain/XUiGridTeacher.lua b/Resources/Scripts/XUi/XUiMentorSystem/MentorMain/XUiGridTeacher.lua new file mode 100644 index 00000000..f8646538 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMentorSystem/MentorMain/XUiGridTeacher.lua @@ -0,0 +1,89 @@ +local XUiGridTeacher = XClass(nil, "XUiGridTeacher") +local DefaultIndex = 1 + +function XUiGridTeacher:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + self:SetButtonCallBack() +end + +function XUiGridTeacher:SetButtonCallBack() + self.PanelPlayer:GetObject("BtnInfo").CallBack = function() + self:OnBtnInfoClick() + end + + self.PanelPlayer:GetObject("BtnRecording").CallBack = function() + self:OnBtnRecordingClick() + end + + self.PanelRobot:GetObject("BtnTecherRecruit").CallBack = function() + self:OnBtnRecruitClick() + end + +end + +function XUiGridTeacher:OnBtnInfoClick() + XDataCenter.PersonalInfoManager.ReqShowInfoPanel(self.Data.PlayerId) +end + +function XUiGridTeacher:OnBtnRecordingClick() + XLuaUiManager.Open("UiMentorRecording", self.Data, true) +end + +function XUiGridTeacher:OnBtnRecruitClick() + XDataCenter.MentorSystemManager.GetMentorRecommendPlayerListRequest(function () + XLuaUiManager.Open("UiMentorRecommendation") + end) +end + +function XUiGridTeacher:UpdateGrid(data) + self.Data = data + if data and data.PlayerId and data.PlayerId > 0 then + self:ShowMentorTag(true) + self:SetMentorInfo(data) + else + self:ShowMentorTag(false) + end + self.TutorLabel.gameObject:SetActiveEx(true) +end + +function XUiGridTeacher:ShowMentorTag(IsShow) + self.PanelPlayer.gameObject:SetActiveEx(IsShow) + self.PanelRobot.gameObject:SetActiveEx(not IsShow) +end + +function XUiGridTeacher:SetMentorInfo(data) + local mentorData = XDataCenter.MentorSystemManager.GetMentorData() + self.PanelMy.gameObject:SetActiveEx(mentorData:IsTeacher()) + local tmpData = data + if data.PlayerId == XPlayer.Id then + tmpData.HeadPortraitId = XPlayer.CurrHeadPortraitId + tmpData.HeadFrameId = XPlayer.CurrHeadFrameId + tmpData.Level = XPlayer.Level + tmpData.PlayerName = XPlayer.Name + end + + local headObj = {} + if tmpData.IsOnline then + headObj = self.PanelPlayer:GetObject("HeadOnLine") + else + headObj = self.PanelPlayer:GetObject("HeadOffLine") + end + + XUiPLayerHead.InitPortrait(tmpData.HeadPortraitId, tmpData.HeadFrameId, headObj) + self.PanelPlayer:GetObject("HeadOnLine").gameObject:SetActiveEx(tmpData.IsOnline) + self.PanelPlayer:GetObject("HeadOffLine").gameObject:SetActiveEx(not tmpData.IsOnline) + + XUiPlayerLevel.UpdateLevel(tmpData.Level, self.PanelPlayer:GetObject("TxtLevel")) + self.PanelPlayer:GetObject("TxtName").text = tmpData.PlayerName + + self.PanelPlayer:GetObject("BtnRecording").gameObject:SetActiveEx(mentorData:IsStudent()) +end + +function XUiGridTeacher:ShowReddot(IsShow) + self.PanelRobot:GetObject("BtnTecherRecruit"):ShowReddot(IsShow) +end + +return XUiGridTeacher \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMentorSystem/MentorMain/XUiMentorMain.lua b/Resources/Scripts/XUi/XUiMentorSystem/MentorMain/XUiMentorMain.lua new file mode 100644 index 00000000..60cef18b --- /dev/null +++ b/Resources/Scripts/XUi/XUiMentorSystem/MentorMain/XUiMentorMain.lua @@ -0,0 +1,243 @@ +local XUiMentorMain = XLuaUiManager.Register(XLuaUi, "UiMentorMain") +local XUiGridTeacher = require("XUi/XUiMentorSystem/MentorMain/XUiGridTeacher") +local XUiGridStudent = require("XUi/XUiMentorSystem/MentorMain/XUiGridStudent") +local CSTextManagerGetText = CS.XTextManager.GetText +local MAX_CHAT_WIDTH = 395 +function XUiMentorMain:OnStart() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self:SetButtonCallBack() + self:InitMentorShip() + self:InitChatMsg() + XRedPointManager.AddRedPointEvent(self.PanelInfo, self.OnCheckMentorApplyNews, self, { XRedPointConditions.Types.CONDITION_MENTOR_APPLY_RED}) + XRedPointManager.AddRedPointEvent(self.BtnReward.ReddotObj, self.OnCheckMentorRewardNews, self, { XRedPointConditions.Types.CONDITION_MENTOR_REWARD_RED}) + XRedPointManager.AddRedPointEvent(self.BtnTask.ReddotObj, self.OnCheckMentorTaskNews, self, { XRedPointConditions.Types.CONDITION_MENTOR_TASK_RED}) +end + +function XUiMentorMain:OnDestroy() + +end + +function XUiMentorMain:OnEnable() + self:UpdateMentorShip() + XDataCenter.MentorSystemManager.ShowMentorShipComplete() + XEventManager.AddEventListener(XEventId.EVENT_CHAT_RECEIVE_MENTOR_MSG, self.RefreshChatMsg, self) + XEventManager.AddEventListener(XEventId.EVENT_MENTOR_TEACHERORSTUDENT_CHANGE, self.UpdateMentorShip, self) + XEventManager.AddEventListener(XEventId.EVENT_MENTOR_MEMBERLEVEL_CHANGE, self.UpdateMentorShip, self) + XEventManager.AddEventListener(XEventId.EVENT_MENTOR_MESSAGE_UPDATE, self.UpdateMentorShip, self) +end + +function XUiMentorMain:OnDisable() + XEventManager.RemoveEventListener(XEventId.EVENT_CHAT_RECEIVE_MENTOR_MSG, self.RefreshChatMsg, self) + XEventManager.RemoveEventListener(XEventId.EVENT_MENTOR_TEACHERORSTUDENT_CHANGE, self.UpdateMentorShip, self) + XEventManager.RemoveEventListener(XEventId.EVENT_MENTOR_MEMBERLEVEL_CHANGE, self.UpdateMentorShip, self) + XEventManager.RemoveEventListener(XEventId.EVENT_MENTOR_MESSAGE_UPDATE, self.UpdateMentorShip, self) +end + +function XUiMentorMain:SetButtonCallBack() + self.BtnTask.CallBack = function() + self:OnBtnTaskClick() + end + self.BtnReward.CallBack = function() + self:OnBtnRewardClick() + end + self.BtnContents.CallBack = function() + self:OnBtnContentsClick() + end + self.BtnRecruit.CallBack = function() + self:OnBtnRecruitClick() + end + self.BtnChat.CallBack = function() + self:OnBtnChatClick() + end + self.BtnBack.CallBack = function() + self:OnBtnBackClick() + end + self.BtnMainUi.CallBack = function() + self:OnBtnMainUiClick() + end + self.PanelMessage:GetObject("BtnOpen").CallBack = function() + self:OnBtnPanelOpenClick() + end + self.PanelMessage:GetObject("BtnClose").CallBack = function() + self:OnBtnPanelCloseClick() + end + self.PanelMessage:GetObject("BtnAnnounce").CallBack = function() + self:OnBtnCreateMessageClick() + end + self:BindHelpBtn(self.BtnHelp, "MentorSystemHelp") +end + +function XUiMentorMain:InitMentorShip() + self.GridStudentObj = { + [1] = self.GridStudentObj1, + [2] = self.GridStudentObj2, + [3] = self.GridStudentObj3, + } + + self.GridStudent = {} + for index,obj in pairs(self.GridStudentObj or {}) do + self.GridStudent[index] = XUiGridStudent.New(obj) + end + + self.GridTutor = XUiGridTeacher.New(self.GridTutorObj) +end + +function XUiMentorMain:UpdateMentorShip() + local mentorData = XDataCenter.MentorSystemManager.GetMentorData() + local curChangeTaskCount = mentorData:GetDailyChangeTaskCount() + local maxChangeTaskCount = XMentorSystemConfigs.GetMentorSystemData("ChangeTaskCount") + local IsTeacher = mentorData:IsTeacher() + local IsStudent = mentorData:IsStudent() + local IsHasQualification = mentorData:CheckIdentity(false) + local IsShowMessage = IsTeacher or ( IsStudent and mentorData:IsHasTeacher()) + local IsCanUseChat = mentorData:CheckCanUseChat(false) and + XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.SocialChat) + + self.PanelLeft.gameObject:SetActiveEx(IsHasQualification) + self.PanelRight.gameObject:SetActiveEx(IsHasQualification) + self.PanelLeftBottom.gameObject:SetActiveEx(IsHasQualification) + self.PanelMessage.gameObject:SetActiveEx(IsShowMessage) + self.PanelChangeCount.gameObject:SetActiveEx(false) + self.PanelChangeCount:GetObject("TitleText").text = CSTextManagerGetText("MentorTeacherDayCanChangeTask") + self.PanelChangeCount:GetObject("CountText").text = maxChangeTaskCount - curChangeTaskCount + self.PanelMessage:GetObject("BtnAnnounce").gameObject:SetActiveEx(IsTeacher) + self.BtnChat:SetDisable(not IsCanUseChat) + self.GridTutor:UpdateGrid(mentorData:GetTeacherData())--师父信息更新 + + self:UpdatePanelMessage(mentorData) + + for index,grid in pairs(self.GridStudent or {}) do--徒弟信息更新 + grid:UpdateGrid(mentorData:GetNotGraduateStudentDataByIndex(index)) + end +end + +function XUiMentorMain:UpdatePanelMessage(mentorData) + local messageData = mentorData:GetMessageData() + self.MessageText = messageData and messageData.MessageText + local messageTime = messageData and messageData.PublishTime or 0 + local IsNewMessage = XDataCenter.MentorSystemManager.CheckHasNewMessage(messageTime) + local IsHasMessage = not string.IsNilOrEmpty(self.MessageText) + + self:SetPanelMessageState(IsNewMessage) + self.PanelMessage:GetObject("TextMessage").text = IsHasMessage and self.MessageText or "" + self.PanelMessage:GetObject("TextMessage").gameObject:SetActiveEx(IsHasMessage) + self.PanelMessage:GetObject("TextNone").gameObject:SetActiveEx(not IsHasMessage) +end + +function XUiMentorMain:SetPanelMessageState(IsOpen) + self.PanelMessage:GetObject("PanelShow").gameObject:SetActiveEx(IsOpen) + self.PanelMessage:GetObject("BtnOpen").gameObject:SetActiveEx(not IsOpen) +end + +function XUiMentorMain:OnBtnTaskClick() + local mentorData = XDataCenter.MentorSystemManager.GetMentorData() + if not mentorData:IsTeacher() then + local studentData = mentorData:GetStudentDataByIndex(XMentorSystemConfigs.MySelfIndex) + if not studentData.SystemTask or not next(studentData.SystemTask) then + XUiManager.TipText("MentorStudentLevelLimitHInt") + return + end + end + XLuaUiManager.Open("UiMentorTask") +end + +function XUiMentorMain:OnBtnRewardClick() + local mentorData = XDataCenter.MentorSystemManager.GetMentorData() + if mentorData:IsTeacher() then + XDataCenter.MentorSystemManager.MentorRefreshGraduateTaskRequest(function () + XLuaUiManager.Open("UiMentorReward") + end,false) + elseif mentorData:IsStudent() then + XLuaUiManager.Open("UiMentorReward") + end +end + +function XUiMentorMain:OnBtnContentsClick() + XDataCenter.MentorSystemManager.MentorGetNameListRequest(function () + XLuaUiManager.Open("UiMentorFile") + end) +end + +function XUiMentorMain:OnBtnRecruitClick() + XDataCenter.MentorSystemManager.GetMentorRecommendPlayerListRequest(function () + XLuaUiManager.Open("UiMentorRecommendation") + end) +end + +function XUiMentorMain:OnBtnChatClick() + local mentorData = XDataCenter.MentorSystemManager.GetMentorData() + local IsCanUseChat = mentorData:CheckCanUseChat(false) + + if not IsCanUseChat then + XUiManager.TipText("MentorCanNotUseChatText") + return + end + + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.SocialChat) then + return + end + + XLuaUiManager.Open("UiChatServeMain", false, ChatChannelType.Mentor, ChatChannelType.World) +end + +function XUiMentorMain:OnBtnBackClick() + self:Close() +end + +function XUiMentorMain:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiMentorMain:OnBtnPanelOpenClick() + self:SetPanelMessageState(true) +end + +function XUiMentorMain:OnBtnPanelCloseClick() + self:SetPanelMessageState(false) +end + +function XUiMentorMain:OnBtnCreateMessageClick() + XLuaUiManager.Open("UiMentorAnnouncement", self.MessageText) +end + +--更新聊天 +function XUiMentorMain:RefreshChatMsg(chatDataLua) + if not chatDataLua then return end + if not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.SocialChat) then + return + end + + self.TxtMessageType.text = CSTextManagerGetText("ChatMentorMsg") + + local name = XDataCenter.SocialManager.GetPlayerRemark(chatDataLua.SenderId, chatDataLua.NickName) + if chatDataLua.MsgType == ChatMsgType.Emoji then + self.TxtMessageContent.text = string.format("%s:%s", name, CSTextManagerGetText("EmojiText")) + else + self.TxtMessageContent.text = string.format("%s:%s", name, chatDataLua.Content) + end + self.TxtMessageLabel.gameObject:SetActiveEx(XUiHelper.CalcTextWidth(self.TxtMessageContent) > MAX_CHAT_WIDTH) +end + +function XUiMentorMain:InitChatMsg() + self.TxtMessageType.text = "" + self.TxtMessageContent.text = "" +end + +function XUiMentorMain:OnCheckMentorApplyNews(count) + local mentorData = XDataCenter.MentorSystemManager.GetMentorData() + if mentorData:IsTeacher() then + for index,grid in pairs(self.GridStudent or {}) do + grid:ShowReddot(count >= 0) + end + else + self.GridTutor:ShowReddot(count >= 0) + end +end + +function XUiMentorMain:OnCheckMentorRewardNews(count) + self.BtnReward:ShowReddot(count >= 0) +end + +function XUiMentorMain:OnCheckMentorTaskNews(count) + self.BtnTask:ShowReddot(count >= 0) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMentorSystem/MentorRecommendation/MentorApplication/XUiGridGotManifesto.lua b/Resources/Scripts/XUi/XUiMentorSystem/MentorRecommendation/MentorApplication/XUiGridGotManifesto.lua new file mode 100644 index 00000000..7d38549a --- /dev/null +++ b/Resources/Scripts/XUi/XUiMentorSystem/MentorRecommendation/MentorApplication/XUiGridGotManifesto.lua @@ -0,0 +1,105 @@ +local XUiGridGotManifesto = XClass(nil, "XUiGridGotManifesto") +local CSTextManagerGetText = CS.XTextManager.GetText + +function XUiGridGotManifesto:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + self:SetButtonCallBack() + + self.TagObjs = { + self.Label1, + self.Label2, + } + self.TimeTagObjs = { + self.Label3, + } +end + +function XUiGridGotManifesto:SetButtonCallBack() + self.BtnTcanchaungEnter.CallBack = function() + self:OnBtnTcanchaungEnterClick() + end + self.BtnTcanchaungCancel.CallBack = function() + self:OnBtnTcanchaungCancelClick() + end + self.BtnHead.CallBack = function() + self:OnBtnHeadClick() + end +end + +function XUiGridGotManifesto:OnBtnTcanchaungEnterClick() + local mentorData = XDataCenter.MentorSystemManager.GetMentorData() + if not mentorData:IsCanDoApply(true) then + return + end + XDataCenter.MentorSystemManager.OperationApplyMentorRequest({self.Data.PlayerId}, true, false, function () + self.Base:UpdatePanel() + end) +end + +function XUiGridGotManifesto:OnBtnTcanchaungCancelClick() + XDataCenter.MentorSystemManager.OperationApplyMentorRequest({self.Data.PlayerId}, false, false, function () + self.Base:UpdatePanel() + end) +end + +function XUiGridGotManifesto:OnBtnHeadClick() + XDataCenter.PersonalInfoManager.ReqShowInfoPanel(self.Data.PlayerId) +end + +function XUiGridGotManifesto:UpdateGrid(data, base) + self.Data = data + self.Base = base + if data then + self:InitTags(self.TagObjs) + self:InitTags(self.TimeTagObjs) + self:SetManifestoInfo(data) + end +end + +function XUiGridGotManifesto:SetManifestoInfo(data) + local mentorData = XDataCenter.MentorSystemManager.GetMentorData() + if mentorData:IsTeacher() then + self.IconMember.gameObject:SetActiveEx(false) + else + local maxStudentCount = XMentorSystemConfigs.GetMentorSystemData("MaxStudentCount") + self.TextMemberNum.text = string.format("%d/%d",data.StudentCount,maxStudentCount) + self.IconMember.gameObject:SetActiveEx(true) + end + + self.TxtName.text = data.PlayerName + self.ManifestoTxt.text = data.Announcement + XUiPlayerLevel.UpdateLevel(data.Level, self.TxtLevel) + XUiPLayerHead.InitPortrait(data.HeadPortraitId, data.HeadFrameId, self.Head) + self:SetTagList(self.TagObjs, data.Tag, XMentorSystemConfigs.TagType.Normal) + self:SetTagList(self.TimeTagObjs, data.OnlineTag, XMentorSystemConfigs.TagType.Time) +end + +function XUiGridGotManifesto:InitTags(objs) + for _,obj in pairs(objs or {}) do + obj.gameObject:SetActiveEx(false) + end +end + +function XUiGridGotManifesto:SetTagList(objs, tags, type) + for index,tagId in pairs(tags or {}) do + local tagCfg + if type == XMentorSystemConfigs.TagType.Normal then + tagCfg = XMentorSystemConfigs.GetManifestoTagById(tagId) + elseif type == XMentorSystemConfigs.TagType.Time then + tagCfg = XMentorSystemConfigs.GetOnlineTagById(tagId) + end + + if objs[index] then + objs[index].gameObject:SetActiveEx(true) + objs[index]:GetObject("Bg"):SetSprite(tagCfg.Bg) + objs[index]:GetObject("Text").text = tagCfg.Tab + else + XLog.Error("Tag's Count Is OverFlow") + end + end +end + +return XUiGridGotManifesto \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMentorSystem/MentorRecommendation/MentorApplication/XUiMentorApplication.lua b/Resources/Scripts/XUi/XUiMentorSystem/MentorRecommendation/MentorApplication/XUiMentorApplication.lua new file mode 100644 index 00000000..9f3d07af --- /dev/null +++ b/Resources/Scripts/XUi/XUiMentorSystem/MentorRecommendation/MentorApplication/XUiMentorApplication.lua @@ -0,0 +1,97 @@ +local XUiMentorApplication = XLuaUiManager.Register(XLuaUi, "UiMentorApplication") +local XUiGridGotManifesto = require("XUi/XUiMentorSystem/MentorRecommendation/MentorApplication/XUiGridGotManifesto") +local CSTextManagerGetText = CS.XTextManager.GetText + +function XUiMentorApplication:OnStart() + self:SetButtonCallBack() + self:InitDynamicTable() +end + +function XUiMentorApplication:OnDestroy() + +end + +function XUiMentorApplication:OnEnable() + self:UpdatePanel() + self:ShowRefreshRedPoint(false) + XDataCenter.MentorSystemManager.ShowMentorShipComplete() + XEventManager.AddEventListener(XEventId.EVENT_MENTOR_GET_APPLY, self.ShowRefreshRedPoint, self) + XEventManager.AddEventListener(XEventId.EVENT_MENTOR_GET_STUDENT, self.UpdateHintText, self) + XEventManager.AddEventListener(XEventId.EVENT_MENTOR_LOSE_STUDENT, self.UpdateHintText, self) + XEventManager.AddEventListener(XEventId.EVENT_BLACK_DATA_CHANGE, self.OnBtnRefreshClick, self) +end + +function XUiMentorApplication:OnDisable() + XEventManager.RemoveEventListener(XEventId.EVENT_MENTOR_GET_APPLY, self.ShowRefreshRedPoint, self) + XEventManager.RemoveEventListener(XEventId.EVENT_MENTOR_GET_STUDENT, self.UpdateHintText, self) + XEventManager.RemoveEventListener(XEventId.EVENT_MENTOR_LOSE_STUDENT, self.UpdateHintText, self) + XEventManager.RemoveEventListener(XEventId.EVENT_BLACK_DATA_CHANGE, self.OnBtnRefreshClick, self) +end + +function XUiMentorApplication:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelAddContactView) + self.DynamicTable:SetProxy(XUiGridGotManifesto) + self.DynamicTable:SetDelegate(self) + self.GridAddContact.gameObject:SetActiveEx(false) +end + +function XUiMentorApplication:SetupDynamicTable() + self.PageDatas = XDataCenter.MentorSystemManager.GetApplyPlayerList() or {} + self.DynamicTable:SetDataSource(self.PageDatas) + self.DynamicTable:ReloadDataSync() + self.PanelNoneDailyTask.gameObject:SetActiveEx(not next(self.PageDatas)) +end + +function XUiMentorApplication:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:UpdateGrid(self.PageDatas[index], self) + end +end + +function XUiMentorApplication:SetButtonCallBack() + self.BtnClose.CallBack = function() + self:OnBtnCloseClick() + end + self.BtnRefresh.CallBack = function() + self:OnBtnRefreshClick() + end + self.BtnApply.CallBack = function() + self:OnBtnApplyClick() + end +end + +function XUiMentorApplication:UpdatePanel() + self:SetupDynamicTable() + self:UpdateHintText() +end + +function XUiMentorApplication:UpdateHintText() + local mentorData = XDataCenter.MentorSystemManager.GetMentorData() + self.HintText.text = mentorData:IsTeacher() and CSTextManagerGetText("MentorStudentCountText",mentorData:GetLeftStudentCount()) or "" +end + +function XUiMentorApplication:OnBtnCloseClick() + self:Close() +end + +function XUiMentorApplication:OnBtnRefreshClick() + local mentorData = XDataCenter.MentorSystemManager.GetMentorData() + if not mentorData:IsCanDoApply(true) then + return + end + XDataCenter.MentorSystemManager.GetMentorPlayerInfoListRequest(mentorData:GetApplyIdList(), function () + self:UpdatePanel() + end) + self:ShowRefreshRedPoint(false) +end + +function XUiMentorApplication:OnBtnApplyClick() + local mentorData = XDataCenter.MentorSystemManager.GetMentorData() + XDataCenter.MentorSystemManager.OperationApplyMentorRequest(mentorData:GetApplyIdList(), false, true, function () + self:UpdatePanel() + end) +end + +function XUiMentorApplication:ShowRefreshRedPoint(IsShow) + self.BtnRefresh:ShowReddot(IsShow) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMentorSystem/MentorRecommendation/MentorDeclaration/XUiGridMentorLabel.lua b/Resources/Scripts/XUi/XUiMentorSystem/MentorRecommendation/MentorDeclaration/XUiGridMentorLabel.lua new file mode 100644 index 00000000..ff3708d9 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMentorSystem/MentorRecommendation/MentorDeclaration/XUiGridMentorLabel.lua @@ -0,0 +1,51 @@ +local XUiGridMentorLabel = XClass(nil, "XUiGridMentorLabel") +local Select = CS.UiButtonState.Select +local Normal = CS.UiButtonState.Normal +local CSTextManagerGetText = CS.XTextManager.GetText +function XUiGridMentorLabel:Ctor(ui, base) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Base = base + XTool.InitUiObject(self) + + self:SetButtonCallBack() +end + +function XUiGridMentorLabel:SetButtonCallBack() + self.BtnLabel.CallBack = function() + self:OnBtnLabelClick() + end +end + +function XUiGridMentorLabel:OnBtnLabelClick() + local IsIdInList = self.Base:CheckLabelIdInList(self.Data.Id, self.Type) + if IsIdInList then + self.Base:RemoveLabelId(self.Data.Id, self.Type) + else + if self.Base:CheckLabelCount(self.Type) then + self.Base:AddLabelId(self.Data.Id, self.Type) + else + XUiManager.TipText("MentorLabelMaxText") + end + end + self.Base:UpdateLabelCount() + self:CheckSelect() +end + +function XUiGridMentorLabel:SetLabelInfo(data, type) + self.Data = data + self.Type = type + if data then + self.BtnLabel:SetName(data.Tab) + self.BtnLabel:SetSprite(data.Bg) + --self.BgTest:SetSprite(data.Bg) + self:CheckSelect() + end +end + +function XUiGridMentorLabel:CheckSelect() + local IsIdInList = self.Base:CheckLabelIdInList(self.Data.Id, self.Type) + self.BtnLabel:SetButtonState(IsIdInList and Select or Normal) +end + +return XUiGridMentorLabel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMentorSystem/MentorRecommendation/MentorDeclaration/XUiMentorDeclaration.lua b/Resources/Scripts/XUi/XUiMentorSystem/MentorRecommendation/MentorDeclaration/XUiMentorDeclaration.lua new file mode 100644 index 00000000..d619909d --- /dev/null +++ b/Resources/Scripts/XUi/XUiMentorSystem/MentorRecommendation/MentorDeclaration/XUiMentorDeclaration.lua @@ -0,0 +1,179 @@ +local XUiMentorDeclaration = XLuaUiManager.Register(XLuaUi, "UiMentorDeclaration") +local CSTextManagerGetText = CS.XTextManager.GetText +local XUiGridMentorLabel = require("XUi/XUiMentorSystem/MentorRecommendation/MentorDeclaration/XUiGridMentorLabel") +function XUiMentorDeclaration:OnStart() + local NormalLabelInfos = XMentorSystemConfigs.GetManifestoTags() + local TimeLabelInfos = XMentorSystemConfigs.GetOnlineTags() + local textMaxCount = XMentorSystemConfigs.GetMentorSystemData("AnnouncementMaxLength") + + self:SetButtonCallBack() + self:InitLabelDic() + self:InitLabel(NormalLabelInfos, self.PanelNormalLabel, self.BtnNormalLabel, self.NormalLabelBtnList, XMentorSystemConfigs.TagType.Normal) + self:InitLabel(TimeLabelInfos, self.PanelTimeLabel, self.BtnTimeLabel, self.TimeLabelBtnList, XMentorSystemConfigs.TagType.Time) + self:UpdateLabelCount() + self.InputField.placeholder.text = CSTextManagerGetText("MentorManifestoMaxText",textMaxCount) +end + +function XUiMentorDeclaration:OnDestroy() + +end + +function XUiMentorDeclaration:OnEnable() + +end + +function XUiMentorDeclaration:OnDisable() + +end + +function XUiMentorDeclaration:SetButtonCallBack() + self.BtnClose.CallBack = function() + self:OnBtnCloseClick() + end + + self.BtnFinish.CallBack = function() + self:OnBtnFinishClick() + end +end + +function XUiMentorDeclaration:InitLabel(labelInfos, parentObj, labelObj, btnList, type) + labelObj.gameObject:SetActiveEx(false) + for _,info in pairs(labelInfos or {}) do + local btn = CS.UnityEngine.Object.Instantiate(labelObj, parentObj) + btn.gameObject:SetActiveEx(true) + btn = XUiGridMentorLabel.New(btn, self) + btn:SetLabelInfo(info, type) + table.insert(btnList,btn) + end +end + +function XUiMentorDeclaration:InitLabelDic() + local mentorData = XDataCenter.MentorSystemManager.GetMentorData() + + self.NormalLabelIdDic = {} + self.TimeLabelIdDic= {} + self.OldNormalLabelIdDic = {} + self.OldTimeLabelIdDic= {} + for _,id in pairs(mentorData:GetTag() or {}) do + self.NormalLabelIdDic[id] = id + self.OldNormalLabelIdDic[id] = id + end + for _,id in pairs(mentorData:GetOnlineTag() or {}) do + self.TimeLabelIdDic[id] = id + self.OldTimeLabelIdDic[id] = id + end + + self.InputField.text = mentorData:GetAnnouncement() + self.OldAnnouncement = mentorData:GetAnnouncement() + self.NormalLabelBtnList = {} + self.TimeLabelBtnList = {} +end + +function XUiMentorDeclaration:CheckDifferent() + local IsDifferent = self.InputField.text ~= self.OldAnnouncement + + IsDifferent = IsDifferent or (#self.OldNormalLabelIdDic ~= #self.NormalLabelIdDic) + IsDifferent = IsDifferent or (#self.OldNormalLabelIdDic ~= #self.NormalLabelIdDic) + + for key,lable in pairs(self.OldNormalLabelIdDic) do + if lable ~= self.NormalLabelIdDic[key] then + IsDifferent = true + break + end + end + + for key,lable in pairs(self.OldTimeLabelIdDic) do + if lable ~= self.TimeLabelIdDic[key] then + IsDifferent = true + break + end + end + return IsDifferent +end + +function XUiMentorDeclaration:CheckLabelIdInList(id, type) + if type == XMentorSystemConfigs.TagType.Normal then + return self.NormalLabelIdDic[id] and true or false + elseif type == XMentorSystemConfigs.TagType.Time then + return self.TimeLabelIdDic[id] and true or false + end + return false +end + +function XUiMentorDeclaration:AddLabelId(id, type) + if type == XMentorSystemConfigs.TagType.Normal then + self.NormalLabelIdDic[id] = id + elseif type == XMentorSystemConfigs.TagType.Time then + self.TimeLabelIdDic[id] = id + end +end + +function XUiMentorDeclaration:RemoveLabelId(id, type) + if type == XMentorSystemConfigs.TagType.Normal then + self.NormalLabelIdDic[id] = self.NormalLabelIdDic[id] and nil + elseif type == XMentorSystemConfigs.TagType.Time then + self.TimeLabelIdDic[id] = self.TimeLabelIdDic[id] and nil + end +end + +function XUiMentorDeclaration:CheckLabelCount(type) + if type == XMentorSystemConfigs.TagType.Normal then + return self:GetLabelCount(self.NormalLabelIdDic) < XMentorSystemConfigs.GetMentorSystemData("NormalLabelMaxCount") + elseif type == XMentorSystemConfigs.TagType.Time then + return self:GetLabelCount(self.TimeLabelIdDic) < XMentorSystemConfigs.GetMentorSystemData("TimeLabelMaxCount") + end +end + +function XUiMentorDeclaration:UpdateLabelCount() + self.NormalLabelText.text = string.format("%d/%d", self:GetLabelCount(self.NormalLabelIdDic), XMentorSystemConfigs.GetMentorSystemData("NormalLabelMaxCount")) + self.TimeLabelText.text = string.format("%d/%d", self:GetLabelCount(self.TimeLabelIdDic), XMentorSystemConfigs.GetMentorSystemData("TimeLabelMaxCount")) +end + +function XUiMentorDeclaration:GetLabelCount(idList) + local count = 0 + for _,_ in pairs(idList or {}) do + count = count + 1 + end + return count +end + +function XUiMentorDeclaration:GetLabelList(dic) + local list = {} + for _,id in pairs(dic or {}) do + table.insert(list,id) + end + return list +end + +function XUiMentorDeclaration:OnBtnCloseClick() + if self:CheckDifferent() then + self:TipDialog(nil,function () + self:Close() + end,"MentorDoCancelDeclarationHint") + else + self:Close() + end +end + +function XUiMentorDeclaration:OnBtnFinishClick() + local mentorData = XDataCenter.MentorSystemManager.GetMentorData() + if not mentorData:IsCanDoApply(true) then + return + end + local normalTag = self:GetLabelList(self.NormalLabelIdDic) + local timeTag = self:GetLabelList(self.TimeLabelIdDic) + local manifestoText = self.InputField.text + if string.IsNilOrEmpty(manifestoText) then + XUiManager.TipText("MentorEmptyManifestoHint") + return + end + XDataCenter.MentorSystemManager.PublishAnnouncementRequest(normalTag, timeTag, manifestoText, function () + self:Close() + XUiManager.TipText("MentorFinishManifestoText") + end) +end + +function XUiMentorDeclaration:TipDialog(cancelCb, confirmCb,TextKey) + CsXUiManager.Instance:Open("UiDialog", CSTextManagerGetText("TipTitle"), CSTextManagerGetText(TextKey), + XUiManager.DialogType.Normal, cancelCb, confirmCb) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMentorSystem/MentorRecommendation/XUiGridManifesto.lua b/Resources/Scripts/XUi/XUiMentorSystem/MentorRecommendation/XUiGridManifesto.lua new file mode 100644 index 00000000..334b0c0c --- /dev/null +++ b/Resources/Scripts/XUi/XUiMentorSystem/MentorRecommendation/XUiGridManifesto.lua @@ -0,0 +1,108 @@ +local XUiGridManifesto = XClass(nil, "XUiGridManifesto") +local CSTextManagerGetText = CS.XTextManager.GetText + +function XUiGridManifesto:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + + self:SetButtonCallBack() + + self.TagObjs = { + self.Label1, + self.Label2, + } + self.TimeTagObjs = { + self.Label3, + } +end + +function XUiGridManifesto:SetButtonCallBack() + self.BtnRecycleConfirm.CallBack = function() + self:OnBtnRecycleConfirmClick() + end + self.HearStudent:GetObject("BtnHead").CallBack = function() + self:OnBtnHeadClick() + end + self.HearMentor:GetObject("BtnHead").CallBack = function() + self:OnBtnHeadClick() + end +end + +function XUiGridManifesto:OnBtnRecycleConfirmClick() + local mentorData = XDataCenter.MentorSystemManager.GetMentorData() + if not mentorData:IsCanDoApply(true) then + return + end + if self.IsApplyed then return end + XDataCenter.MentorSystemManager.ApplyMentorRequest({self.Data.PlayerId}, function () + self.Base:UpdatePanel()--self:SetManifestoInfo(self.Data) + end) +end + +function XUiGridManifesto:OnBtnHeadClick() + XDataCenter.PersonalInfoManager.ReqShowInfoPanel(self.Data.PlayerId) +end + +function XUiGridManifesto:UpdateGrid(data, base) + self.Data = data + self.Base = base + if data then + self:InitTags(self.TagObjs) + self:InitTags(self.TimeTagObjs) + self:SetManifestoInfo(data) + end +end + +function XUiGridManifesto:SetManifestoInfo(data) + local mentorData = XDataCenter.MentorSystemManager.GetMentorData() + self.HearMentor.gameObject:SetActiveEx(mentorData:IsStudent()) + self.HearStudent.gameObject:SetActiveEx(mentorData:IsTeacher()) + + if mentorData:IsTeacher() then + XUiPLayerHead.InitPortrait(data.HeadPortraitId, data.HeadFrameId, self.HearStudent:GetObject("Head")) + else + local maxStudentCount = XMentorSystemConfigs.GetMentorSystemData("MaxStudentCount") + XUiPLayerHead.InitPortrait(data.HeadPortraitId, data.HeadFrameId, self.HearMentor:GetObject("Head")) + self.HearMentor:GetObject("TextMemberNum").text = string.format("%d/%d",data.StudentCount,maxStudentCount) + end + + self.TextName.text = data.PlayerName + self.ManifestoTxt.text = data.Announcement + XUiPlayerLevel.UpdateLevel(data.Level, self.TxtLevel) + + self:SetTagList(self.TagObjs, data.Tag, XMentorSystemConfigs.TagType.Normal) + self:SetTagList(self.TimeTagObjs, data.OnlineTag, XMentorSystemConfigs.TagType.Time) + + self.IsApplyed = XDataCenter.MentorSystemManager.IsApplyed(data.PlayerId) + self.BtnRecycleConfirm:SetName(self.IsApplyed and CSTextManagerGetText("MentorShipApplyedText") or CSTextManagerGetText("MentorShipNotApplyedText")) + self.BtnRecycleConfirm:SetDisable(self.IsApplyed) +end + +function XUiGridManifesto:InitTags(objs) + for _,obj in pairs(objs or {}) do + obj.gameObject:SetActiveEx(false) + end +end + +function XUiGridManifesto:SetTagList(objs, tags, type) + for index,tagId in pairs(tags or {}) do + local tagCfg + if type == XMentorSystemConfigs.TagType.Normal then + tagCfg = XMentorSystemConfigs.GetManifestoTagById(tagId) + elseif type == XMentorSystemConfigs.TagType.Time then + tagCfg = XMentorSystemConfigs.GetOnlineTagById(tagId) + end + + if objs[index] then + objs[index].gameObject:SetActiveEx(true) + objs[index]:GetObject("Bg"):SetSprite(tagCfg.Bg) + objs[index]:GetObject("Text").text = tagCfg.Tab + else + XLog.Error("Tag's Count Is OverFlow") + end + end +end + +return XUiGridManifesto \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMentorSystem/MentorRecommendation/XUiMentorRecommendation.lua b/Resources/Scripts/XUi/XUiMentorSystem/MentorRecommendation/XUiMentorRecommendation.lua new file mode 100644 index 00000000..8047cb71 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMentorSystem/MentorRecommendation/XUiMentorRecommendation.lua @@ -0,0 +1,150 @@ +local XUiMentorRecommendation = XLuaUiManager.Register(XLuaUi, "UiMentorRecommendation") +local XUiGridManifesto = require("XUi/XUiMentorSystem/MentorRecommendation/XUiGridManifesto") +local CSTextManagerGetText = CS.XTextManager.GetText + +function XUiMentorRecommendation:OnStart() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self:SetButtonCallBack() + self:InitDynamicTable() + self.InputField.placeholder.text = CSTextManagerGetText("MentorPlayerSearchText") +end + +function XUiMentorRecommendation:OnDestroy() + +end + +function XUiMentorRecommendation:OnEnable() + self:UpdatePanel() + XDataCenter.MentorSystemManager.ShowMentorShipComplete() + XEventManager.AddEventListener(XEventId.EVENT_MENTOR_TEACHER_MONTHLYSTUDENTCOUNT_UPDATE, self.UpdatePanel, self) + XEventManager.AddEventListener(XEventId.EVENT_MENTOR_GET_APPLY, self.CheckRedPoint, self) + XEventManager.AddEventListener(XEventId.EVENT_BLACK_DATA_CHANGE, self.OnBtnRefreshClick, self) +end + +function XUiMentorRecommendation:OnDisable() + XEventManager.RemoveEventListener(XEventId.EVENT_MENTOR_TEACHER_MONTHLYSTUDENTCOUNT_UPDATE, self.UpdatePanel, self) + XEventManager.RemoveEventListener(XEventId.EVENT_MENTOR_GET_APPLY, self.CheckRedPoint, self) + XEventManager.RemoveEventListener(XEventId.EVENT_BLACK_DATA_CHANGE, self.OnBtnRefreshClick, self) +end + +function XUiMentorRecommendation:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelList) + self.DynamicTable:SetProxy(XUiGridManifesto) + self.DynamicTable:SetDelegate(self) + self.GridManifesto.gameObject:SetActiveEx(false) +end + +function XUiMentorRecommendation:SetupDynamicTable(data) + self.PageDatas = data and data or XDataCenter.MentorSystemManager.GetRecommendPlayerList() + self.DynamicTable:SetDataSource(self.PageDatas) + self.DynamicTable:ReloadDataSync() + self.PanelNoneStudentTask.gameObject:SetActiveEx(#self.PageDatas == 0) + +end + +function XUiMentorRecommendation:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:UpdateGrid(self.PageDatas[index],self) + end +end + +function XUiMentorRecommendation:SetButtonCallBack() + self.BtnBack.CallBack = function() + self:OnBtnBackClick() + end + self.BtnMainUi.CallBack = function() + self:OnBtnMainUiClick() + end + self:BindHelpBtn(self.BtnHelp, "MentorSystemHelp") + self.BtnEstablish.CallBack = function() + self:OnBtnEstablishClick() + end + self.BtnNews.CallBack = function() + self:OnBtnNewsClick() + end + self.BtnApply.CallBack = function() + self:OnBtnApplyClick() + end + self.BtnRefresh.CallBack = function() + self:OnBtnRefreshClick() + end + self.BtnSearchOffice.CallBack = function() + self:OnBtnSearchOfficeClick() + end +end + +function XUiMentorRecommendation:UpdatePanel(data) + local mentorData = XDataCenter.MentorSystemManager.GetMentorData() + self:SetupDynamicTable(data) + self.TitleText.text = mentorData:IsTeacher() and + CSTextManagerGetText("MentorRecommendStudentText") or + CSTextManagerGetText("MentorRecommendTeacherText") + self:CheckRedPoint() + self.BtnEstablish:SetName(mentorData:IsTeacher() and + CSTextManagerGetText("MentorTeacherEstablishText") or + CSTextManagerGetText("MentorStudentEstablishText")) + + self.TxtNone.text = mentorData:IsTeacher() and + CSTextManagerGetText("MentorRecommendStudentEmptyHint") or + CSTextManagerGetText("MentorRecommendTeacherEmptyHint") + + local count = string.format("%d/%d", mentorData:GetMonthlyStudentCount(), XMentorSystemConfigs.GetMentorSystemData("MonthlyStudentCount")) + self.StudentLimitText.text = CSTextManagerGetText("MentorMonthlyStudentCountHInt",count) + self.StudentLimitText.gameObject:SetActiveEx(mentorData:IsTeacher()) + +end + +function XUiMentorRecommendation:OnBtnBackClick() + self:Close() +end + +function XUiMentorRecommendation:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiMentorRecommendation:OnBtnRefreshClick() + XDataCenter.MentorSystemManager.ClearRecommendPlayerList() + XDataCenter.MentorSystemManager.GetMentorRecommendPlayerListRequest(function () + self:UpdatePanel() + end) +end + +function XUiMentorRecommendation:OnBtnEstablishClick() + XLuaUiManager.Open("UiMentorDeclaration") +end + +function XUiMentorRecommendation:OnBtnNewsClick() + local mentorData = XDataCenter.MentorSystemManager.GetMentorData() + XDataCenter.MentorSystemManager.GetMentorPlayerInfoListRequest(mentorData:GetApplyIdList(), function () + XLuaUiManager.Open("UiMentorApplication") + end) +end + +function XUiMentorRecommendation:OnBtnApplyClick() + local mentorData = XDataCenter.MentorSystemManager.GetMentorData() + if not mentorData:IsCanDoApply(true) then + return + end + + local idList = {} + for _,data in pairs(self.PageDatas or {}) do + table.insert(idList, data.PlayerId) + end + + XDataCenter.MentorSystemManager.ApplyMentorRequest(idList, function () + self:UpdatePanel() + end) +end + +function XUiMentorRecommendation:OnBtnSearchOfficeClick() + local id = tonumber(self.InputField.text) + XDataCenter.MentorSystemManager.GetMentorSpecifyPlayerInfoRequest(id, function () + local data = {XDataCenter.MentorSystemManager.GetSpecifyPlayer()} + self:UpdatePanel(data) + end) +end + +function XUiMentorRecommendation:CheckRedPoint() + local mentorData = XDataCenter.MentorSystemManager.GetMentorData() + self.BtnNews:ShowReddot(mentorData:IsHasApply()) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMentorSystem/MentorRecording/XUiMentorRecording.lua b/Resources/Scripts/XUi/XUiMentorSystem/MentorRecording/XUiMentorRecording.lua new file mode 100644 index 00000000..5c7aa235 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMentorSystem/MentorRecording/XUiMentorRecording.lua @@ -0,0 +1,35 @@ +local XUiMentorRecording = XLuaUiManager.Register(XLuaUi, "UiMentorRecording") + +local CSXTextManagerGetText = CS.XTextManager.GetText + +function XUiMentorRecording:OnStart(data, IsTeacher) + self:SetButtonCallBack() + self:ShowPanel(data, IsTeacher) +end + +function XUiMentorRecording:SetButtonCallBack() + self.BtnClose.CallBack = function() + self:Close() + end +end + +function XUiMentorRecording:ShowPanel(data, IsTeacher) + XUiPLayerHead.InitPortrait(data.HeadPortraitId, data.HeadFrameId, self.Head) + XUiPlayerLevel.UpdateLevel(data.Level, self.TxtLevel) + + self.TxtName.text = data.PlayerName + self.TxtLastLoginTime.text = CSXTextManagerGetText("LastLoginTimeText",self:CheckTime(data.LastLoginTime)) + + self.PanelBuildTime:GetObject("TxtTime").text = self:CheckTime(data.JoinTime) + self.PanelLevelTime:GetObject("TxtTime").text = self:CheckTime(data.ReachTime) + + self.PanelLevelTime.gameObject:SetActiveEx(not IsTeacher) +end + +function XUiMentorRecording:CheckTime(time) + if time == 0 then + return "--" + else + return XTime.TimestampToGameDateTimeString(time, "yyyy-MM-dd") + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMentorSystem/MentorReward/MentorGraduation/XUiMentorGraduation.lua b/Resources/Scripts/XUi/XUiMentorSystem/MentorReward/MentorGraduation/XUiMentorGraduation.lua new file mode 100644 index 00000000..875a56af --- /dev/null +++ b/Resources/Scripts/XUi/XUiMentorSystem/MentorReward/MentorGraduation/XUiMentorGraduation.lua @@ -0,0 +1,52 @@ +local XUiMentorGraduation = XLuaUiManager.Register(XLuaUi, "UiMentorGraduation") +local CSTextManagerGetText = CS.XTextManager.GetText + +function XUiMentorGraduation:OnStart(rewardGoodsList, callBack) + self.CallBack = callBack + self:SetButtonCallBack() + self:InitPanel(rewardGoodsList) +end + +function XUiMentorGraduation:OnDestroy() + +end + +function XUiMentorGraduation:OnEnable() + +end + +function XUiMentorGraduation:OnDisable() + if self.CallBack then + self.CallBack() + end +end + +function XUiMentorGraduation:SetButtonCallBack() + self.BtnClose.CallBack = function() + self:OnBtnCloseClick() + end + self.BtnMask.CallBack = function() + self:OnBtnCloseClick() + end +end + +function XUiMentorGraduation:InitPanel(rewardGoodsList) + self.TxtTitle.text = CSTextManagerGetText("MentorStudentGraduateTipTittle") + self.TxtInfo.text = CSTextManagerGetText("MentorStudentGraduateTipInfo") + local rewardGoods = XRewardManager.MergeAndSortRewardGoodsList(rewardGoodsList) + self.GridCommon.gameObject:SetActiveEx(false) + if rewardGoods then + for _, item in pairs(rewardGoods or {}) do + local obj = CS.UnityEngine.Object.Instantiate(self.GridCommon,self.PanelRewardContainer) + local grid = XUiGridCommon.New(self, obj) + grid:Refresh(item) + grid.GameObject:SetActiveEx(true) + end + end + +end + + +function XUiMentorGraduation:OnBtnCloseClick() + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMentorSystem/MentorReward/XUiGridPhasesReward.lua b/Resources/Scripts/XUi/XUiMentorSystem/MentorReward/XUiGridPhasesReward.lua new file mode 100644 index 00000000..30e67c40 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMentorSystem/MentorReward/XUiGridPhasesReward.lua @@ -0,0 +1,64 @@ +local XUiGridPhasesReward = XClass(nil, "XUiGridPhasesReward") +local CSTextManagerGetText = CS.XTextManager.GetText +local DefaultIndex = 1 + +function XUiGridPhasesReward:Ctor(ui, base, root) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Base = base + self.Root = root + XTool.InitUiObject(self) + + self:SetButtonCallBack() +end + +function XUiGridPhasesReward:SetButtonCallBack() + self.BtnActive.CallBack = function() + self:OnBtnActiveClick() + end +end + +function XUiGridPhasesReward:OnBtnActiveClick() + local mentorData = XDataCenter.MentorSystemManager.GetMentorData() + local IsCanGet = mentorData:CheckTeacherStageRewardCanGetByCount(self.Data.Count) + local IsGeted = mentorData:CheckTeacherStageRewardGetedByCount(self.Data.Count) + if IsCanGet then + if IsGeted then + return + end + + XDataCenter.MentorSystemManager.MentorGetStageRewardRequest(self.Data.Count, function (rewardGoodsList) + self.Base:UpdatePanelPhasesReward() + XUiManager.OpenUiObtain(rewardGoodsList) + end) + end +end + +function XUiGridPhasesReward:UpdateData(data) + self.Data = data + if data then + local rewardData = XRewardManager.GetRewardList(self.Data.RewardId) + local mentorData = XDataCenter.MentorSystemManager.GetMentorData() + local IsCanGet = mentorData:CheckTeacherStageRewardCanGetByCount(data.Count) + local IsGeted = mentorData:CheckTeacherStageRewardGetedByCount(data.Count) + + if IsCanGet then + self.PanelEffect.gameObject:SetActiveEx(not IsGeted) + self.PanelFinish.gameObject:SetActiveEx(IsGeted) + self.BtnActive.gameObject:SetActiveEx(not IsGeted) + else + self.PanelEffect.gameObject:SetActiveEx(false) + self.PanelFinish.gameObject:SetActiveEx(false) + self.BtnActive.gameObject:SetActiveEx(false) + end + + if not self.RewardGrid then + self.RewardGrid = XUiGridCommon.New(self.Root, self.GridCommon) + end + + self.RewardGrid:Refresh(rewardData[DefaultIndex]) + self.TxtValue.text = string.format("%d",data.Count) + end +end + +return XUiGridPhasesReward \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMentorSystem/MentorReward/XUiGridTeacherTask.lua b/Resources/Scripts/XUi/XUiMentorSystem/MentorReward/XUiGridTeacherTask.lua new file mode 100644 index 00000000..ea13ec47 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMentorSystem/MentorReward/XUiGridTeacherTask.lua @@ -0,0 +1,127 @@ +local XUiGridTeacherTask = XClass(nil, "XUiGridTeacherTask") + +function XUiGridTeacherTask:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RewardPanelList = {} + XTool.InitUiObject(self) + self:SetButtonCallBack() + self.GridCommon.gameObject:SetActiveEx(false) + self.ImgComplete.gameObject:SetActiveEx(false) + self.PanelAnimation.gameObject:SetActiveEx(true) +end + +function XUiGridTeacherTask:PlayAnimation() + if self.IsAnimation then + return + end + + self.IsAnimation = true + self.GridTaskTimeline:PlayTimelineAnimation() +end + +function XUiGridTeacherTask:ResetData(data, student) + self.ImgComplete.gameObject:SetActiveEx(data.State == XDataCenter.TaskManager.TaskState.Finish) + self.Data = data + self.StudentId = student.PlayerId + self.IsGraduate = student.IsGraduate + local config = XDataCenter.TaskManager.GetTaskTemplate(self.Data.TaskId) + self.tableData = config + self.TxtTaskName.text = config.Title + self.TxtTaskDescribe.text = config.Desc + self.TxtSubTypeTip.text = config.Suffix or "" + self.RImgTaskType:SetRawImage(config.Icon) + self:UpdateProgress(self.Data) + local rewardId = XMentorSystemConfigs.GetTeacherChallengeRewardById(self.Data.TaskId).RewardId + local rewards = XRewardManager.GetRewardList(rewardId) + + for i = 1, #self.RewardPanelList do + self.RewardPanelList[i]:Refresh() + end + + if not rewards then + return + end + + for i = 1, #rewards do + + local panel = self.RewardPanelList[i] + if not panel then + if #self.RewardPanelList == 0 then + panel = XUiGridCommon.New(self.RootUi, self.GridCommon) + else + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommon) + ui.transform:SetParent(self.GridCommon.parent, false) + panel = XUiGridCommon.New(self.RootUi, ui) + end + table.insert(self.RewardPanelList, panel) + end + panel:Refresh(rewards[i]) + + end + if self.PanelAnimationGroup then + self.PanelAnimationGroup.alpha = 1 + end + +end + +function XUiGridTeacherTask:SetButtonCallBack() + self.BtnFinish.CallBack = function() self:OnBtnFinishClick() end +end + +function XUiGridTeacherTask:OnBtnFinishClick() + local weaponCount = 0 + local chipCount = 0 + if self.Data.State ~= XDataCenter.TaskManager.TaskState.Achieved or not self.IsGraduate then + XUiManager.TipText("MentorTeacherTaskHintText") + return + end + for i = 1, #self.RewardPanelList do + local rewardsId = self.RewardPanelList[i].TemplateId + if XDataCenter.EquipManager.IsClassifyEqualByTemplateId(rewardsId, XEquipConfig.Classify.Weapon) then + weaponCount = weaponCount + 1 + elseif XDataCenter.EquipManager.IsClassifyEqualByTemplateId(rewardsId, XEquipConfig.Classify.Awareness) then + chipCount = chipCount + 1 + end + end + if weaponCount > 0 and XDataCenter.EquipManager.CheckBagCount(weaponCount, XEquipConfig.Classify.Weapon) == false or + chipCount > 0 and XDataCenter.EquipManager.CheckBagCount(chipCount, XEquipConfig.Classify.Awareness) == false then + return + end + XDataCenter.MentorSystemManager.MentorGetChallengeRewardRequest(self.StudentId, self.Data.TaskId, function(rewardGoodsList) + XUiManager.OpenUiObtain(rewardGoodsList) + end) +end + +function XUiGridTeacherTask:UpdateProgress(data) + self.Data = data + local config = XDataCenter.TaskManager.GetTaskTemplate(data.TaskId) + if #config.Condition < 2 then--显示进度 + self.ImgProgress.transform.parent.gameObject:SetActiveEx(true) + self.TxtTaskNumQian.gameObject:SetActiveEx(true) + local result = config.Result > 0 and config.Result or 1 + XTool.LoopMap(self.Data.Schedule, function(_, pair) + self.ImgProgress.fillAmount = pair.Value / result + pair.Value = (pair.Value >= result) and result or pair.Value + self.TxtTaskNumQian.text = string.format("%d/%d", pair.Value, result) + end) + else + self.ImgProgress.transform.parent.gameObject:SetActiveEx(false) + self.TxtTaskNumQian.gameObject:SetActiveEx(false) + end + + self.BtnFinish.gameObject:SetActiveEx(false) + self.BtnReceiveHave.gameObject:SetActiveEx(false) + + if self.Data.State == XDataCenter.TaskManager.TaskState.Achieved and self.IsGraduate then + self.BtnFinish.gameObject:SetActiveEx(true) + self.BtnFinish:SetDisable(false) + elseif self.Data.State == XDataCenter.TaskManager.TaskState.Finish and self.IsGraduate then + self.BtnReceiveHave.gameObject:SetActiveEx(true) + else + self.BtnFinish.gameObject:SetActiveEx(true) + self.BtnFinish:SetDisable(true) + end +end + +return XUiGridTeacherTask \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMentorSystem/MentorReward/XUiMentorReward.lua b/Resources/Scripts/XUi/XUiMentorSystem/MentorReward/XUiMentorReward.lua new file mode 100644 index 00000000..71beddfc --- /dev/null +++ b/Resources/Scripts/XUi/XUiMentorSystem/MentorReward/XUiMentorReward.lua @@ -0,0 +1,70 @@ +local XUiMentorReward = XLuaUiManager.Register(XLuaUi, "UiMentorReward") +local XUiPanelTeacherReward = require("XUi/XUiMentorSystem/MentorReward/XUiPanelTeacherReward") +local XUiPanelStudentReward = require("XUi/XUiMentorSystem/MentorReward/XUiPanelStudentReward") + +function XUiMentorReward:OnStart() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self:SetButtonCallBack() + + local mentorData = XDataCenter.MentorSystemManager.GetMentorData() + self.PanelTeacherReward = {} + self.PanelStudentReward = {} + + if mentorData:IsTeacher() then + self.PanelTeacherReward = XUiPanelTeacherReward.New(self.PanelMentor, self) + elseif mentorData:IsStudent() then + self.PanelStudentReward = XUiPanelStudentReward.New(self.PanelStudent, self) + end +end + +function XUiMentorReward:OnDestroy() + +end + +function XUiMentorReward:OnEnable() + self:UpdatePanel() + XDataCenter.MentorSystemManager.ShowMentorShipComplete() + XEventManager.AddEventListener(XEventId.EVENT_MENTOR_STUDENT_TASKCOUNT_CHANGE, self.UpdatePanel, self) + XEventManager.AddEventListener(XEventId.EVENT_MENTOR_TEACHERORSTUDENT_CHANGE, self.UpdatePanel, self) + XEventManager.AddEventListener(XEventId.EVENT_FINISH_TASK, self.UpdatePanel, self) + XEventManager.AddEventListener(XEventId.EVENT_MENTOR_GETREWARD, self.UpdatePanel, self) +end + +function XUiMentorReward:OnDisable() + XEventManager.RemoveEventListener(XEventId.EVENT_MENTOR_STUDENT_TASKCOUNT_CHANGE, self.UpdatePanel, self) + XEventManager.RemoveEventListener(XEventId.EVENT_MENTOR_TEACHERORSTUDENT_CHANGE, self.UpdatePanel, self) + XEventManager.RemoveEventListener(XEventId.EVENT_FINISH_TASK, self.UpdatePanel, self) + XEventManager.RemoveEventListener(XEventId.EVENT_MENTOR_GETREWARD, self.UpdatePanel, self) +end + +function XUiMentorReward:SetButtonCallBack() + self.BtnBack.CallBack = function() + self:OnBtnBackClick() + end + self.BtnMainUi.CallBack = function() + self:OnBtnMainUiClick() + end + self:BindHelpBtn(self.BtnHelp, "MentorSystemRewardHelp") +end + +function XUiMentorReward:UpdatePanel() + local mentorData = XDataCenter.MentorSystemManager.GetMentorData() + self.PanelMentor.gameObject:SetActiveEx(mentorData:IsTeacher()) + self.PanelStudent.gameObject:SetActiveEx(mentorData:IsStudent()) + + if mentorData:IsTeacher() then + self.PanelTeacherReward:UpdatePanel() + self:PlayAnimation("PanelMentorQieHuan") + elseif mentorData:IsStudent() then + self.PanelStudentReward:UpdatePanel() + self:PlayAnimation("PanelStudentQieHuan") + end +end + +function XUiMentorReward:OnBtnBackClick() + self:Close() +end + +function XUiMentorReward:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMentorSystem/MentorReward/XUiMentorRewardTisp.lua b/Resources/Scripts/XUi/XUiMentorSystem/MentorReward/XUiMentorRewardTisp.lua new file mode 100644 index 00000000..8b43c8ea --- /dev/null +++ b/Resources/Scripts/XUi/XUiMentorSystem/MentorReward/XUiMentorRewardTisp.lua @@ -0,0 +1,41 @@ +local XUiMentorRewardTisp = XLuaUiManager.Register(XLuaUi, "UiMentorRewardTisp") + +local CSXTextManagerGetText = CS.XTextManager.GetText + +function XUiMentorRewardTisp:OnStart(mailId, cb) + self:SetButtonCallBack() + self:ShowPanel(mailId) + self.CallBack = cb +end + +function XUiMentorRewardTisp:SetButtonCallBack() + self.BtnClose.CallBack = function() + self:Close() + end + self.BtnStand.CallBack = function() + self:OnBtnStandClick() + end +end + +function XUiMentorRewardTisp:OnBtnStandClick() + local mentorData = XDataCenter.MentorSystemManager.GetMentorData() + local teacher = mentorData:GetTeacherData() + XDataCenter.MentorSystemManager.MentorStudentSendRewardRequest(teacher.PlayerId, function () + XUiManager.TipText("MentorStudentGiftCompletHint") + self:Close() + if self.CallBack then self.CallBack() end + end) +end + +function XUiMentorRewardTisp:ShowPanel(mailId) + local rewards = XMailConfigs.GetRewardList(mailId) + self.GridGift.gameObject:SetActiveEx(false) + if rewards then + for _, item in pairs(rewards or {}) do + local obj = CS.UnityEngine.Object.Instantiate(self.GridGift,self.PanelGift) + local grid = XUiGridCommon.New(self, obj) + grid:Refresh(item) + grid.GameObject:SetActive(true) + end + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMentorSystem/MentorReward/XUiPanelStudentGraduateReward.lua b/Resources/Scripts/XUi/XUiMentorSystem/MentorReward/XUiPanelStudentGraduateReward.lua new file mode 100644 index 00000000..bf5c9685 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMentorSystem/MentorReward/XUiPanelStudentGraduateReward.lua @@ -0,0 +1,58 @@ +local XUiPanelStudentGraduateReward = XClass(nil, "XUiPanelStudentGraduateReward") +local CSTextManagerGetText = CS.XTextManager.GetText + +function XUiPanelStudentGraduateReward:Ctor(ui,base) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Base = base + XTool.InitUiObject(self) + self:InitPanel() + self:SetButtonCallBack() +end + +function XUiPanelStudentGraduateReward:SetButtonCallBack() + self.PanelClostTask:GetObject("BtnGift").CallBack = function() + self:OnBtnGiftClick() + end +end + +function XUiPanelStudentGraduateReward:OnBtnGiftClick() + local mailId = XMentorSystemConfigs.GetMentorSystemData("GiftMailId") + XLuaUiManager.Open("UiMentorRewardTisp", mailId, function () + self:UpdatePanel() + end) +end + +function XUiPanelStudentGraduateReward:InitPanel() + local rewardId = XMentorSystemConfigs.GetMentorSystemData("GraduateRewardId") + local rewards = XRewardManager.GetRewardList(rewardId) + self.GridCommon.gameObject:SetActiveEx(false) + if rewards then + for _, item in pairs(rewards or {}) do + local obj = CS.UnityEngine.Object.Instantiate(self.GridCommon,self.RewaedContent) + local grid = XUiGridCommon.New(self.Base, obj) + grid:Refresh(item) + grid.GameObject:SetActive(true) + end + end +end + +function XUiPanelStudentGraduateReward:UpdatePanel() + local graduateLv = XMentorSystemConfigs.GetMentorSystemData("GraduateLv") + local autoGraduateLv = XMentorSystemConfigs.GetMentorSystemData("AutoGraduateLv") + local IsCanGraduate = XDataCenter.MentorSystemManager.CheckStudentCanGraduate() + local IsCanSendGift = XDataCenter.MentorSystemManager.CheckStudentCanSendGift() + + self.PanelCurLevel:GetObject("Text").text = CSTextManagerGetText("MentorStudentCurLevelText", CSTextManagerGetText("MentorLevelText", XPlayer.Level)) + self.PanelUnClostTask:GetObject("Text").text = CSTextManagerGetText("MentorLevelText", graduateLv) + self.PanelClostTask:GetObject("Text").text = CSTextManagerGetText("MentorLevelText", graduateLv) + self.PanelUnGraduate:GetObject("Text").text = CSTextManagerGetText("MentorLevelText", autoGraduateLv) + + self.PanelUnClostTask.gameObject:SetActiveEx(not IsCanGraduate) + self.PanelClostTask.gameObject:SetActiveEx(IsCanGraduate) + + self.PanelClostTask:GetObject("BtnGift").gameObject:SetActiveEx(IsCanSendGift) + self.PanelClostTask:GetObject("BtnDisable").gameObject:SetActiveEx(not IsCanSendGift) +end + +return XUiPanelStudentGraduateReward \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMentorSystem/MentorReward/XUiPanelStudentReward.lua b/Resources/Scripts/XUi/XUiMentorSystem/MentorReward/XUiPanelStudentReward.lua new file mode 100644 index 00000000..d4280286 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMentorSystem/MentorReward/XUiPanelStudentReward.lua @@ -0,0 +1,85 @@ +local XUiPanelStudentReward = XClass(nil, "XUiPanelStudentReward") +local XUiPanelStudentGraduateReward = require("XUi/XUiMentorSystem/MentorReward/XUiPanelStudentGraduateReward") +local CSTextManagerGetText = CS.XTextManager.GetText + +function XUiPanelStudentReward:Ctor(ui, base) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Base = base + XTool.InitUiObject(self) + + self:SetButtonCallBack() + self:InitDynamicTable() + self:InitTaskGroup() + self:InitGraduateReward() +end + +function XUiPanelStudentReward:SetButtonCallBack() + +end + +function XUiPanelStudentReward:InitGraduateReward() + self.GraduateReward = XUiPanelStudentGraduateReward.New(self.PanelRewaed, self.Base) + self.GraduateReward:UpdatePanel() +end + +function XUiPanelStudentReward:InitTaskGroup() + self.TaskTabList = { + [1] = self.BtnPayTab1, + [2] = self.BtnPayTab2, + } + + local mentorData = XDataCenter.MentorSystemManager.GetMentorData() + self.CurTaskType = XMentorSystemConfigs.StudentRewardType.Grow + self.PanelTopTabGroup:Init(self.TaskTabList, function(index) self:SelectTaskType(index) end) + self.PanelTopTabGroup:SelectIndex(self.CurTaskType) +end + +function XUiPanelStudentReward:SelectTaskType(index) + self.CurTaskType = index + self:SetupDynamicTable() + self.PanelPrompt:GetObject("Grow").gameObject:SetActiveEx(index == XMentorSystemConfigs.StudentRewardType.Grow) + self.PanelPrompt:GetObject("Graduate").gameObject:SetActiveEx(index == XMentorSystemConfigs.StudentRewardType.Graduate) +end + +function XUiPanelStudentReward:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelTaskDailyList) + self.DynamicTable:SetProxy(XDynamicGridTask) + self.DynamicTable:SetDelegate(self) + self.GridTask.gameObject:SetActiveEx(false) +end + +function XUiPanelStudentReward:SetupDynamicTable() + self.PageDatas = {} + if self.CurTaskType == XMentorSystemConfigs.StudentRewardType.Grow then + self.PageDatas = XDataCenter.TaskManager.GetMentorGrowFullTaskList() or {} + elseif self.CurTaskType == XMentorSystemConfigs.StudentRewardType.Graduate then + self.PageDatas = XDataCenter.TaskManager.GetMentorGraduateFullTaskList() or {} + end + + self.PanelNoneDailyTask.gameObject:SetActiveEx(not next(self.PageDatas)) + self.DynamicTable:SetDataSource(self.PageDatas) + self.DynamicTable:ReloadDataSync() +end + +function XUiPanelStudentReward:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid.RootUi = self.Base + grid:ResetData(self.PageDatas[index]) + end +end + +function XUiPanelStudentReward:UpdatePanel() + self.GraduateReward:UpdatePanel() + self:SetupDynamicTable() + self:CheckRedDot() +end + +function XUiPanelStudentReward:CheckRedDot() + local IsGrowShow = XDataCenter.TaskManager.GetIsRewardFor(XDataCenter.TaskManager.TaskType.MentorShipGrow) + local IsGraduateShow = XDataCenter.TaskManager.GetIsRewardFor(XDataCenter.TaskManager.TaskType.MentorShipGraduate) + self.TaskTabList[XMentorSystemConfigs.StudentRewardType.Grow]:ShowReddot(IsGrowShow) + self.TaskTabList[XMentorSystemConfigs.StudentRewardType.Graduate]:ShowReddot(IsGraduateShow) +end + +return XUiPanelStudentReward \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMentorSystem/MentorReward/XUiPanelTeacherPhasesReward.lua b/Resources/Scripts/XUi/XUiMentorSystem/MentorReward/XUiPanelTeacherPhasesReward.lua new file mode 100644 index 00000000..ac84890c --- /dev/null +++ b/Resources/Scripts/XUi/XUiMentorSystem/MentorReward/XUiPanelTeacherPhasesReward.lua @@ -0,0 +1,82 @@ +local XUiPanelTeacherPhasesReward = XClass(nil, "XUiPanelTeacherPhasesReward") +local XUiGridPhasesReward = require("XUi/XUiMentorSystem/MentorReward/XUiGridPhasesReward") +local CSTextManagerGetText = CS.XTextManager.GetText +local Vector2 = CS.UnityEngine.Vector2 + +function XUiPanelTeacherPhasesReward:Ctor(ui, root) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Root = root + XTool.InitUiObject(self) + self:SetButtonCallBack() + self.CollectionId = XMentorSystemConfigs.GetMentorSystemData("GraduateCollectionId") +end + +function XUiPanelTeacherPhasesReward:SetButtonCallBack() + self.BtnMedal.CallBack = function() + self:OnBtnMedalClick() + end +end + +function XUiPanelTeacherPhasesReward:OnBtnMedalClick() + local data = XDataCenter.MedalManager.GetMedalData(self.CollectionId) + XLuaUiManager.Open("UiCollectionTip", data, XDataCenter.MedalManager.InType.Normal) +end + +function XUiPanelTeacherPhasesReward:InitPhasesRewardGrid() + self.PhasesRewardGrids = {} + self.PhasesRewardGridRects = {} + self.GridActive.gameObject:SetActiveEx(false) + local mentorData = XDataCenter.MentorSystemManager.GetMentorData() + local rewardList = mentorData:GetTeacherStageRewardList() + local rewardCount = #rewardList + for i = 1,rewardCount do + local grid = self.PhasesRewardGrids[i] + if not grid then + local obj = CS.UnityEngine.Object.Instantiate(self.GridActive) + obj.gameObject:SetActiveEx(true) + obj.transform:SetParent(self.PanelContent, false) + grid = XUiGridPhasesReward.New(obj, self, self.Root) + self.PhasesRewardGrids[i] = grid + self.PhasesRewardGridRects[i] = grid.Transform:GetComponent("RectTransform") + end + end +end + +function XUiPanelTeacherPhasesReward:UpdatePanelPhasesReward() + local mentorData = XDataCenter.MentorSystemManager.GetMentorData() + + local icon = XDataCenter.MedalManager.GetMedalImg(self.CollectionId) + local quality = XDataCenter.MedalManager.GetQuality(self.CollectionId) + + local levelIcon = XDataCenter.MedalManager.GetLevelIcon(self.CollectionId, quality) + if levelIcon then + self.IconLevel:SetSprite(levelIcon) + end + self.IconLevel.gameObject:SetActiveEx(levelIcon) + + self.IconMedal:SetRawImage(icon) + self.TxtDailyActive.text = mentorData:GetGraduateStudentCount() + self.TxtMax.text = string.format("/%d",mentorData:GetLastTeacherStageRewardCount()) + self.TextActive.text = CSTextManagerGetText("MentorTeacherPhasesRewardText") + + local rewardList = mentorData:GetTeacherStageRewardList() + local rewardCount = #rewardList + for i = 1, rewardCount do + self.PhasesRewardGrids[i]:UpdateData(rewardList[i]) + end + + -- 自适应 + self.DaylyActiveProgressBg.sizeDelta = Vector2(rewardCount * self.GridActive.rect.width, self.DaylyActiveProgressBg.sizeDelta.y) + self.PanelContent.sizeDelta = Vector2(rewardCount * self.GridActive.rect.width + self.GridActive.rect.width / 2, self.PanelContent.sizeDelta.y) + self.ImgDaylyActiveProgress.fillAmount = mentorData:GetTeacherStageRewardAVGTotalPercent() + + local activeProgressRectSize = self.PanelContent.transform.rect.size + for i = 1, #self.PhasesRewardGrids do + local reward = rewardList[i] + local valOffset = mentorData:GetTeacherStageRewardPercentByIndex(i) + local adjustPosition = CS.UnityEngine.Vector3((activeProgressRectSize.x - self.GridActive.rect.width / 2) * valOffset, self.GridActive.anchoredPosition3D.y, 0) + self.PhasesRewardGridRects[i].anchoredPosition3D = adjustPosition + end +end +return XUiPanelTeacherPhasesReward \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMentorSystem/MentorReward/XUiPanelTeacherReward.lua b/Resources/Scripts/XUi/XUiMentorSystem/MentorReward/XUiPanelTeacherReward.lua new file mode 100644 index 00000000..4004d6f8 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMentorSystem/MentorReward/XUiPanelTeacherReward.lua @@ -0,0 +1,130 @@ +local XUiPanelTeacherReward = XClass(nil, "XUiPanelTeacherReward") +local XUiGridTeacherTask = require("XUi/XUiMentorSystem/MentorReward/XUiGridTeacherTask") +local XUiPanelTeacherPhasesReward = require("XUi/XUiMentorSystem/MentorReward/XUiPanelTeacherPhasesReward") +local CSTextManagerGetText = CS.XTextManager.GetText +local DefaultIndex = 1 +local tableSort = table.sort +function XUiPanelTeacherReward:Ctor(ui, base) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Base = base + XTool.InitUiObject(self) + + self.BtnStudent.gameObject:SetActiveEx(false) + self:SetButtonCallBack() + self:InitDynamicTable() + self:InitStudentGroup() + self:InitPhasesReward() +end + +function XUiPanelTeacherReward:InitPhasesReward() + self.PhasesReward = XUiPanelTeacherPhasesReward.New(self.PanelReward, self.Base) + self.PhasesReward:InitPhasesRewardGrid() +end + +function XUiPanelTeacherReward:InitStudentGroup() + local mentorData = XDataCenter.MentorSystemManager.GetMentorData() + local studentList = mentorData:GetStudentDataList() + self.PanelNoneStudent.gameObject:SetActiveEx(not next(studentList)) + self.PanelDaily.gameObject:SetActiveEx(next(studentList)) + if not(studentList and next(studentList)) then + return + end + self.StudentBtnList = self.StudentBtnList or {} + for index,student in pairs(studentList or {}) do + local btncs = self.StudentBtnList[index] + if not btncs then + local btn = CS.UnityEngine.Object.Instantiate(self.BtnStudent) + btn.transform:SetParent(self.PanelStudentContainer, false) + btncs = btn:GetComponent("XUiButton") + table.insert(self.StudentBtnList, btncs) + end + btncs.gameObject:SetActiveEx(true) + btncs:SetName(student.PlayerName or "") + btncs:ShowTag(student.IsGraduate) + local btnUiObj = btncs.transform:GetComponent("UiObject") + XUiPLayerHead.InitPortrait(student.HeadPortraitId, student.HeadFrameId, btnUiObj:GetObject("NormalHead")) + XUiPlayerLevel.UpdateLevel(student.Level, btnUiObj:GetObject("NormalLevel")) + XUiPLayerHead.InitPortrait(student.HeadPortraitId, student.HeadFrameId, btnUiObj:GetObject("SelectHead")) + XUiPlayerLevel.UpdateLevel(student.Level, btnUiObj:GetObject("SelectLevel")) + end + self.PanelStudentGroup:Init(self.StudentBtnList, function(index) self:SelectStudent(index) end) + self.PanelStudentGroup:SelectIndex(DefaultIndex) + self.CurStudentIndex = DefaultIndex +end + +function XUiPanelTeacherReward:SelectStudent(index) + self.CurStudentIndex = index + self:SetupDynamicTable() + self.Base:PlayAnimation("PanelDailyRefresh") +end + +function XUiPanelTeacherReward:SetButtonCallBack() + +end + +function XUiPanelTeacherReward:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelTaskList) + self.DynamicTable:SetProxy(XUiGridTeacherTask) + self.DynamicTable:SetDelegate(self) + self.GridTask.gameObject:SetActiveEx(false) +end + +function XUiPanelTeacherReward:SetupDynamicTable() + local mentorData = XDataCenter.MentorSystemManager.GetMentorData() + self.CurStudent = mentorData:GetStudentDataByIndex(self.CurStudentIndex) + self.PageDatas = self.CurStudent and self:TaskSort(self.CurStudent.StudentTask) or {} + self.PanelNoneDailyTask.gameObject:SetActiveEx(not next(self.PageDatas)) + self.DynamicTable:SetDataSource(self.PageDatas) + self.DynamicTable:ReloadDataSync() +end + +function XUiPanelTeacherReward:TaskSort(tasks) + local taskTemplate = XTaskConfig.GetTaskTemplate() + local list = {} + for _,task in pairs(tasks or {}) do + table.insert(list,task) + end + tableSort(list, function(a, b) + local pa, pb = taskTemplate[a.TaskId].Priority, taskTemplate[b.TaskId].Priority + if a.State == b.State then + if pa ~= pb then + return pa > pb + else + return a.TaskId > b.TaskId + end + else + if a.State < XDataCenter.TaskManager.TaskState.Finish and b.State < XDataCenter.TaskManager.TaskState.Finish then + return a.State > b.State + else + return b.State == XDataCenter.TaskManager.TaskState.Finish + end + end + end) + return list +end + +function XUiPanelTeacherReward:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid.RootUi = self.Base + grid:ResetData(self.PageDatas[index], self.CurStudent) + end +end + +function XUiPanelTeacherReward:UpdatePanel() + self.PhasesReward:UpdatePanelPhasesReward() + self:SetupDynamicTable() + self:CheckRedDotAndTag() +end + +function XUiPanelTeacherReward:CheckRedDotAndTag() + local mentorData = XDataCenter.MentorSystemManager.GetMentorData() + local studentList = mentorData:GetStudentDataList() + for index,student in pairs(studentList or {}) do + local IsShowRed = XDataCenter.MentorSystemManager.CheckTeacherCanGetStudentTaskRewardByStudent(student) + self.StudentBtnList[index]:ShowReddot(IsShowRed) + self.StudentBtnList[index]:ShowTag(student.IsGraduate) + end +end + +return XUiPanelTeacherReward \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMentorSystem/MentorShare/XUiGridSelectTask.lua b/Resources/Scripts/XUi/XUiMentorSystem/MentorShare/XUiGridSelectTask.lua new file mode 100644 index 00000000..480bba8b --- /dev/null +++ b/Resources/Scripts/XUi/XUiMentorSystem/MentorShare/XUiGridSelectTask.lua @@ -0,0 +1,79 @@ +local XUiGridSelectTask = XClass(nil, "XUiGridSelectTask") +local DefaultIndex = 1 +local CSTextManagerGetText = CS.XTextManager.GetText +function XUiGridSelectTask:Ctor(ui, base, oldTaskId, studentId) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Base = base + XTool.InitUiObject(self) + self.OldTaskId = oldTaskId + self.StudentId = studentId + self:SetButtonCallBack() +end + +function XUiGridSelectTask:SetButtonCallBack() + self.BtnSelect.CallBack = function() + self:OnBtnSelectClick() + end +end + +function XUiGridSelectTask:OnBtnSelectClick() + if not self.Data then return end + local mentorData = XDataCenter.MentorSystemManager.GetMentorData() + + if self.IsTeacher then + if not self.OldTaskId or not self.StudentId then return end + XDataCenter.MentorSystemManager.MentorChangeDailyTaskRequest(self.OldTaskId, self.Data, self.StudentId,function () + mentorData:PlusDailyChangeTaskCount() + end) + else + XDataCenter.MentorSystemManager.StudentReceiveDailyTaskRequest(self.Data.TaskId,function () + local studentData = mentorData:GetNotGraduateStudentDataByIndex(XMentorSystemConfigs.MySelfIndex) + local weeklyTaskList = studentData and studentData.WeeklyTask + for _,weeklyTask in pairs(weeklyTaskList or {}) do + if weeklyTask.TaskId == self.Data.TaskId then + if weeklyTask.Status == XMentorSystemConfigs.TaskStatus.Completed then + XUiManager.TipText("MentorTaskCompletedHint") + end + break + end + end + end) + end + self.Base:OnBtnCloseClick() +end + +function XUiGridSelectTask:UpdateGrid(data,IsTeacher) + self.Data = data + self.IsTeacher = IsTeacher + if data then + if IsTeacher then + local taskCfg = XDataCenter.TaskManager.GetTaskTemplate(data) + self.TitleText.text = taskCfg.Title + self.TextDesc.text = taskCfg.Desc + + self.TagText.gameObject:SetActiveEx(false) + self.BtnSelect.gameObject:SetActiveEx(true) + self.BtnSelected.gameObject:SetActiveEx(false) + + self.BtnSelect:SetName(CSTextManagerGetText("MentorTeacherChangeTaskText")) + else + local taskCfg = XDataCenter.TaskManager.GetTaskTemplate(data.TaskId) + self.TitleText.text = taskCfg.Title + self.TextDesc.text = taskCfg.Desc + + self.BtnSelect.gameObject:SetActiveEx(self:IsCanSelect()) + self.BtnSelected.gameObject:SetActiveEx(not self:IsCanSelect()) + self.TagText.gameObject:SetActiveEx(data.HasChange) + + self.BtnSelect:SetName(CSTextManagerGetText("MentorStudentSelectTaskText")) + end + + end +end + +function XUiGridSelectTask:IsCanSelect() + return self.Data.Status == XMentorSystemConfigs.TaskStatus.Init +end + +return XUiGridSelectTask \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMentorSystem/MentorShare/XUiMentorSelectTask.lua b/Resources/Scripts/XUi/XUiMentorSystem/MentorShare/XUiMentorSelectTask.lua new file mode 100644 index 00000000..dceeff7d --- /dev/null +++ b/Resources/Scripts/XUi/XUiMentorSystem/MentorShare/XUiMentorSelectTask.lua @@ -0,0 +1,91 @@ +local XUiMentorSelectTask = XLuaUiManager.Register(XLuaUi, "UiMentorSelectTask") +local XUiGridSelectTask = require("XUi/XUiMentorSystem/MentorShare/XUiGridSelectTask") +local CSTextManagerGetText = CS.XTextManager.GetText +function XUiMentorSelectTask:OnStart(IsTeacher, oldTaskId, student) + self:SetButtonCallBack() + self.IsTeacher = IsTeacher + self.Student = student + self.OldTaskId = oldTaskId + self:InitPanel() +end + +function XUiMentorSelectTask:OnDestroy() + +end + +function XUiMentorSelectTask:OnEnable() + self:UpdatePanel() +end + +function XUiMentorSelectTask:OnDisable() + +end + +function XUiMentorSelectTask:SetButtonCallBack() + self.BtnClose.CallBack = function() + self:OnBtnCloseClick() + end +end + +function XUiMentorSelectTask:OnBtnCloseClick() + self:Close() +end + +function XUiMentorSelectTask:InitPanel() + local mentorData = XDataCenter.MentorSystemManager.GetMentorData() + local studentId = self.Student and self.Student.PlayerId + + local taskCount = 0 + if self.IsTeacher then + taskCount = XMentorSystemConfigs.GetMentorSystemData("MentorChangeTaskDisplayCount") + else + taskCount = XMentorSystemConfigs.GetMentorSystemData("SysReleaseTaskCount") + end + + self.GridTask.gameObject:SetActiveEx(false) + self.TaskGridList = {} + + for i = 1, taskCount ,1 do + local taskObj = CS.UnityEngine.Object.Instantiate(self.GridTask) + taskObj.transform:SetParent(self.PanelCombinationContent, false) + self.TaskGridList[i] = XUiGridSelectTask.New(taskObj, self, self.OldTaskId, studentId) + end +end + +function XUiMentorSelectTask:UpdatePanel() + local mentorData = XDataCenter.MentorSystemManager.GetMentorData() + local taskList = {} + + if self.IsTeacher then + taskList = XDataCenter.MentorSystemManager.GetTeacherChangeTaskList() + local maxCount = XMentorSystemConfigs.GetMentorSystemData("ChangeTaskCount") + local curCount = mentorData:GetDailyChangeTaskCount() + self.CanGetText.text = CSTextManagerGetText("MentorTeacherDayCanChangeTask") + self.CanGetCount.text = string.format("%d/%d",maxCount - curCount , maxCount) + else + taskList = self.Student.SystemTask + local maxCount = XMentorSystemConfigs.GetMentorSystemData("GetTaskCount") + local curCount = mentorData:GetStudentSystemTaskCountByIndex(XMentorSystemConfigs.MySelfIndex) + self.CanGetText.text = CSTextManagerGetText("MentorStudentDayCanGetTask") + self.CanGetCount.text = string.format("%d/%d",maxCount - curCount , maxCount) + end + + local taskCount = XMentorSystemConfigs.GetMentorSystemData("MentorChangeTaskDisplayCount") + + for i = 1, taskCount ,1 do + local grid = self.TaskGridList[i] + if grid then + local task = taskList[i] + if task then + grid:UpdateGrid(task, self.IsTeacher) + grid.GameObject:SetActiveEx(true) + else + grid.GameObject:SetActiveEx(false) + end + end + end +end + +function XUiMentorSelectTask:OnBtnBackClick() + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMentorSystem/MentorTask/XUiGridPhasesTask.lua b/Resources/Scripts/XUi/XUiMentorSystem/MentorTask/XUiGridPhasesTask.lua new file mode 100644 index 00000000..c2c601af --- /dev/null +++ b/Resources/Scripts/XUi/XUiMentorSystem/MentorTask/XUiGridPhasesTask.lua @@ -0,0 +1,61 @@ +local XUiGridPhasesTask = XClass(nil, "XUiGridPhasesTask") +local CSTextManagerGetText = CS.XTextManager.GetText +function XUiGridPhasesTask:Ctor(ui,base) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Base = base + XTool.InitUiObject(self) + + self:SetButtonCallBack() +end + +function XUiGridPhasesTask:SetButtonCallBack() + self.BtnActive.CallBack = function() + self:OnBtnActiveClick() + end +end + + +function XUiGridPhasesTask:OnBtnActiveClick() + local mentorData = XDataCenter.MentorSystemManager.GetMentorData() + local rewardData = XRewardManager.GetRewardList(self.Data.RewardId) + local IsCanGet = mentorData:CheckStudentWeeklyRewardCanGetByCount(self.Data.Count) + local IsGeted = mentorData:CheckStudentWeeklyRewardGetedByCount(self.Data.Count) + if IsCanGet then + if IsGeted then + return + end + + XDataCenter.MentorSystemManager.StudentGetTaskProgressRewardRequest(self.Data.Count, function (rewardGoodsList) + self.Base:UpdatePanelPhasesTask() + if rewardGoodsList then + XUiManager.OpenUiObtain(rewardGoodsList) + else + XLog.Error("rewardGoodsList Is NULL!") + end + end) + else + XUiManager.OpenUiTipReward(rewardData, CSTextManagerGetText("DailyActiveRewardTitle")) + end +end + +function XUiGridPhasesTask:UpdateData(data) + self.Data = data + if data then + local mentorData = XDataCenter.MentorSystemManager.GetMentorData() + local IsCanGet = mentorData:CheckStudentWeeklyRewardCanGetByCount(data.Count) + local IsGeted = mentorData:CheckStudentWeeklyRewardGetedByCount(data.Count) + if IsCanGet then + self.ImgActive:SetSprite(CS.XGame.ClientConfig:GetString("TaskDailyActiveReach1")) + self.PanelEffect.gameObject:SetActiveEx(not IsGeted) + self.ImgRe.gameObject:SetActiveEx(IsGeted) + else + self.ImgActive:SetSprite(CS.XGame.ClientConfig:GetString("TaskDailyActiveNotReach1")) + self.PanelEffect.gameObject:SetActiveEx(false) + self.ImgRe.gameObject:SetActiveEx(false) + end + self.TxtValue.text = string.format("%d",data.Count) + end +end + +return XUiGridPhasesTask \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMentorSystem/MentorTask/XUiGridStudentWeeklyTask.lua b/Resources/Scripts/XUi/XUiMentorSystem/MentorTask/XUiGridStudentWeeklyTask.lua new file mode 100644 index 00000000..d677b38b --- /dev/null +++ b/Resources/Scripts/XUi/XUiMentorSystem/MentorTask/XUiGridStudentWeeklyTask.lua @@ -0,0 +1,162 @@ +local XUiGridStudentWeeklyTask = XClass(nil, "XUiGridStudentWeeklyTask") +local CSTextManagerGetText = CS.XTextManager.GetText +function XUiGridStudentWeeklyTask:Ctor(ui, root) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Root = root + XTool.InitUiObject(self) + self:SetButtonCallBack() + self.RewardList = {} +end + +function XUiGridStudentWeeklyTask:SetButtonCallBack() + self.BtnVacancy.CallBack = function() + self:OnBtnVacancyClick() + end + self.PanelUndone:GetObject("BtnDelect").CallBack = function() + self:OnBtnDelectClick() + end + self.PanelFinishHasReward:GetObject("BtnGet").CallBack = function() + self:OnBtnGetClick() + end +end + +function XUiGridStudentWeeklyTask:UpdateGrid(index) + local mentorData = XDataCenter.MentorSystemManager.GetMentorData() + local curGetedCount = mentorData:GetStudentWeeklyTaskCountByIndex(XMentorSystemConfigs.MySelfIndex) + local curDaliyCount = mentorData:GetStudentSystemTaskCountByIndex(XMentorSystemConfigs.MySelfIndex) + local maxDaliyCount = XMentorSystemConfigs.GetMentorSystemData("GetTaskCount") + + self.StudentData = mentorData:GetNotGraduateStudentDataByIndex(XMentorSystemConfigs.MySelfIndex) + self.Task = self.StudentData and self.StudentData.WeeklyTask[index] + if self.Task then + self.PanelUndone.gameObject:SetActiveEx(self:IsUnDone()) + self.PanelFinishNoReward.gameObject:SetActiveEx(self:IsNoReward()) + self.PanelFinishHasReward.gameObject:SetActiveEx(self:IsHasReward() or self:IsGetedReward()) + self.BtnVacancy.gameObject:SetActiveEx(false) + + if self:IsUnDone() then + self:ShowPanelUndone() + elseif self:IsNoReward() then + self:ShowPanelFinishNoReward() + elseif self:IsHasReward() or self:IsGetedReward()then + self:ShowPanelFinishHasReward() + end + else + local emptyIndex = index - curGetedCount + local emptyCount = maxDaliyCount - curDaliyCount + + self.PanelUndone.gameObject:SetActiveEx(false) + self.PanelFinishNoReward.gameObject:SetActiveEx(false) + self.PanelFinishHasReward.gameObject:SetActiveEx(false) + self.BtnVacancy.gameObject:SetActiveEx(emptyIndex <= emptyCount) + end +end + +function XUiGridStudentWeeklyTask:ShowPanelUndone() + local taskCfg = XDataCenter.TaskManager.GetTaskTemplate(self.Task.TaskId) + local txtTaskNumQian = self.PanelUndone:GetObject("TxtTaskNumQian") + local imgProgress = self.PanelUndone:GetObject("ImgProgress") + + self.PanelUndone:GetObject("TaskText").text = taskCfg.Title + self.PanelUndone:GetObject("TxtTaskDescribe").text = taskCfg.Desc + + if #taskCfg.Condition < 2 then + imgProgress.transform.parent.gameObject:SetActiveEx(true) + txtTaskNumQian.gameObject:SetActiveEx(true) + local result = taskCfg.Result > 0 and taskCfg.Result or 1 + XTool.LoopMap(self.Task.Schedule, function(_, pair) + imgProgress.fillAmount = pair.Value / result + pair.Value = (pair.Value >= result) and result or pair.Value + txtTaskNumQian.text = string.format("%d/%d", pair.Value, result) + end) + else + imgProgress.transform.parent.gameObject:SetActiveEx(false) + txtTaskNumQian.gameObject:SetActiveEx(false) + end +end + +function XUiGridStudentWeeklyTask:ShowPanelFinishNoReward() + self.PanelFinishNoReward:GetObject("TextHint").text = CSTextManagerGetText("MentorStudentFinishTaskNoRewardHint") +end + +function XUiGridStudentWeeklyTask:ShowPanelFinishHasReward() + local mentorData = XDataCenter.MentorSystemManager.GetMentorData() + local teacher = mentorData:GetTeacherData() + local gridCommon = self.PanelFinishHasReward:GetObject("GridCommon") + local textHint = self.PanelFinishHasReward:GetObject("TextHint") + local Content = self.PanelFinishHasReward:GetObject("Content") + + textHint.text = CSTextManagerGetText("MentorStudentFinishTaskHasRewardHint",teacher.PlayerName) + local rewardId = self.Task.RewardId > 0 and self.Task.RewardId or XMentorSystemConfigs.GetMentorSystemData("ActivationRewardId") + local rewards = XRewardManager.GetRewardList(rewardId) + gridCommon.gameObject:SetActiveEx(false) + + for i = 1, #self.RewardList do + self.RewardList[i]:Refresh() + end + + if rewards then + for i = 1, #rewards do + local grid = self.RewardList[i] + if not grid then + local ui = CS.UnityEngine.Object.Instantiate(gridCommon) + ui.transform:SetParent(Content, false) + ui.gameObject:SetActiveEx(true) + grid = XUiGridCommon.New(self.Root, ui) + table.insert(self.RewardList, grid) + end + grid:Refresh(rewards[i]) + end + end + + self.PanelFinishHasReward:GetObject("BtnGet").gameObject:SetActiveEx(self:IsHasReward()) + self.PanelFinishHasReward:GetObject("BtnGeted").gameObject:SetActiveEx(self:IsGetedReward()) +end + +function XUiGridStudentWeeklyTask:OnBtnVacancyClick() + XLuaUiManager.Open("UiMentorSelectTask", false, nil, self.StudentData)---要在里面加即时刷新 +end + +function XUiGridStudentWeeklyTask:OnBtnDelectClick() + self:TipDialog(nil,function () + XDataCenter.MentorSystemManager.StudentDeleteDailyTaskRequest(self.Task.TaskId, function () + self.Root:UpdatePanel() + end) + end,"MentorStudentDeleteTaskHint") +end + +function XUiGridStudentWeeklyTask:OnBtnGetClick() + --local IsOverLimit = XDataCenter.EquipManager.CheckBoxOverLimitOfGetAwareness() + --if IsOverLimit then + -- return + --end + XDataCenter.MentorSystemManager.StudentReceiveRewardRequest(self.Task.TaskId, function (rewardGoodsList) + XUiManager.OpenUiObtain(rewardGoodsList) + self.Root:UpdatePanel() + end) +end + +function XUiGridStudentWeeklyTask:IsUnDone() + return self.Task.Status == XMentorSystemConfigs.TaskStatus.Received +end + +function XUiGridStudentWeeklyTask:IsNoReward() + return self.Task.Status == XMentorSystemConfigs.TaskStatus.Completed or + self.Task.Status == XMentorSystemConfigs.TaskStatus.GetReward +end + +function XUiGridStudentWeeklyTask:IsHasReward() + return self.Task.Status == XMentorSystemConfigs.TaskStatus.GiveEquip +end + +function XUiGridStudentWeeklyTask:IsGetedReward() + return self.Task.Status == XMentorSystemConfigs.TaskStatus.ReceiveEquip +end + +function XUiGridStudentWeeklyTask:TipDialog(cancelCb, confirmCb,TextKey) + CsXUiManager.Instance:Open("UiDialog", CSTextManagerGetText("TipTitle"), CSTextManagerGetText(TextKey), + XUiManager.DialogType.Normal, cancelCb, confirmCb) +end + +return XUiGridStudentWeeklyTask \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMentorSystem/MentorTask/XUiGridTaskAssist.lua b/Resources/Scripts/XUi/XUiMentorSystem/MentorTask/XUiGridTaskAssist.lua new file mode 100644 index 00000000..c682c020 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMentorSystem/MentorTask/XUiGridTaskAssist.lua @@ -0,0 +1,76 @@ +local XUiGridTaskAssist = XClass(nil, "XUiGridTaskAssist") +local CSTextManagerGetText = CS.XTextManager.GetText +function XUiGridTaskAssist:Ctor(ui, root) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Root = root + XTool.InitUiObject(self) + self.RewardPanelList = {} + self:SetButtonCallBack() +end + +function XUiGridTaskAssist:SetButtonCallBack() + self.BtnStand.CallBack = function() + self:OnBtnStandClick() + end +end + +function XUiGridTaskAssist:OnBtnStandClick() + local mentorData = XDataCenter.MentorSystemManager.GetMentorData() + local maxCount = XMentorSystemConfigs.GetMentorSystemData("ChangeTaskCount") + local curCount = maxCount - mentorData:GetDailyChangeTaskCount() + if curCount <= 0 then + XUiManager.TipText("MentorCantChangeTaskHint") + return + end + XDataCenter.MentorSystemManager.MentorGetChangeDailyTaskRequest(self.Student.PlayerId, function () + XLuaUiManager.Open("UiMentorSelectTask", true, self.Data.TaskId, self.Student) + end) +end + +function XUiGridTaskAssist:UpdateGrid(data,student) + self.Data = data + self.Student = student + if data then + local IsInit = data.Status == XMentorSystemConfigs.TaskStatus.Init + local taskCfg = XDataCenter.TaskManager.GetTaskTemplate(data.TaskId) + local rewardId = XMentorSystemConfigs.GetTeacherWeeklyTaskRewardById(data.TaskId).RewardId + local rewards = XRewardManager.GetRewardList(rewardId) + + self:ShowReward(rewards) + self.TextName.text = taskCfg.Title + self.TextDesc.text = taskCfg.Desc + + self.BtnStand.gameObject:SetActiveEx(IsInit and not data.HasChange) + self.BtnChanged.gameObject:SetActiveEx(IsInit and data.HasChange) + self.BtnReceived.gameObject:SetActiveEx(not IsInit) + end +end + +function XUiGridTaskAssist:ShowReward(rewards) + + self.GridCommon.gameObject:SetActiveEx(false) + + for i = 1, #self.RewardPanelList do + self.RewardPanelList[i]:Refresh() + end + + if not rewards then + return + end + + for i = 1, #rewards do + local panel = self.RewardPanelList[i] + if not panel then + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommon) + ui.transform:SetParent(self.Content, false) + ui.gameObject:SetActiveEx(true) + panel = XUiGridCommon.New(self.Root, ui) + table.insert(self.RewardPanelList, panel) + end + panel:Refresh(rewards[i]) + end +end + + +return XUiGridTaskAssist \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMentorSystem/MentorTask/XUiGridTaskReward.lua b/Resources/Scripts/XUi/XUiMentorSystem/MentorTask/XUiGridTaskReward.lua new file mode 100644 index 00000000..014ea150 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMentorSystem/MentorTask/XUiGridTaskReward.lua @@ -0,0 +1,144 @@ +local XUiGridTaskReward = XClass(nil, "XUiGridTaskReward") +local CSTextManagerGetText = CS.XTextManager.GetText +function XUiGridTaskReward:Ctor(ui,root) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Root = root + XTool.InitUiObject(self) + self.AccomplishRewardGridList = {} + self.UndoneRewardGridList = {} + self:SetButtonCallBack() +end + +function XUiGridTaskReward:SetButtonCallBack() + self.PanelUndone:GetObject("BtnStand").CallBack = function() + self:OnBtnStandClick() + end + self.PanelAccomplish:GetObject("BtnStand").CallBack = function() + self:OnBtnStandClick() + end +end + +function XUiGridTaskReward:OnBtnStandClick() + if not self.Data or not self.Student then + return + end + + if self:IsCanGive() then + if self:IsGiven() then return end + + local mentorData = XDataCenter.MentorSystemManager.GetMentorData() + local gift = mentorData:GetTeacherGift() + if gift.Count <= 0 then + XUiManager.TipText("MentorTeacherGiftEmptyHint") + return + end + XDataCenter.MentorSystemManager.MentorGiveRewardRequest(self.Student.PlayerId, self.Data.TaskId, function() + XUiManager.TipText("MentorTeacherGiftCompletHint") + self:UpdateGrid(self.Data,self.Student) + end) + else + if not self:IsCanGet() then return end + XDataCenter.MentorSystemManager.MentorGetWeeklyTaskRewardRequest(self.Student.PlayerId, self.Data.TaskId, function (rewardGoodsList) + XUiManager.OpenUiObtain(rewardGoodsList) + end) + end +end + +function XUiGridTaskReward:UpdateGrid(data,student) + self.Data = data + self.Student = student + if data then + self.PanelUndone.gameObject:SetActiveEx(not self:IsCanGive()) + self.PanelAccomplish.gameObject:SetActiveEx(self:IsCanGive()) + if self:IsCanGive() then + self:UpdatePanelAccomplish(data) + else + self:UpdatePanelUndone(data) + end + end +end + +function XUiGridTaskReward:UpdatePanelAccomplish(data) + local taskCfg = XDataCenter.TaskManager.GetTaskTemplate(data.TaskId) + local grid = self.PanelAccomplish:GetObject("GridCommon") + local parent = self.PanelAccomplish:GetObject("TaskGridList") + local itemId = XMentorSystemConfigs.GetMentorSystemData("ActivationItemId") + local rewards + if self:IsGiven() then + rewards = {XRewardManager.CreateRewardGoods(itemId)} + end + + self.PanelAccomplish:GetObject("TextName").text = taskCfg.Title + self.PanelAccomplish:GetObject("TextHint").text = CSTextManagerGetText("MentorTeacherGiveItemHint") + self.PanelAccomplish:GetObject("BtnStand"):SetDisable(self:IsGiven()) + + self:ShowReward(rewards, self.AccomplishRewardGridList, grid, parent) +end + +function XUiGridTaskReward:UpdatePanelUndone(data) + local taskCfg = XDataCenter.TaskManager.GetTaskTemplate(data.TaskId) + local rewardId = XMentorSystemConfigs.GetTeacherWeeklyTaskRewardById(data.TaskId).RewardId + local rewards = XRewardManager.GetRewardList(rewardId) + local grid = self.PanelUndone:GetObject("GridCommon") + local parent = self.PanelUndone:GetObject("TaskGridList") + local curCount = self.PanelUndone:GetObject("CurCount") + local maxCount = self.PanelUndone:GetObject("MaxCount") + local schedule = self.PanelUndone:GetObject("Schedule") + + self.PanelUndone:GetObject("TextName").text = taskCfg.Title + self.PanelUndone:GetObject("TextDesc").text = taskCfg.Desc + self.PanelUndone:GetObject("BtnStand"):SetDisable(not self:IsCanGet()) + + if #taskCfg.Condition < 2 then--显示进度 + schedule.gameObject:SetActiveEx(true) + schedule.gameObject:SetActiveEx(true) + local result = taskCfg.Result > 0 and taskCfg.Result or 1 + XTool.LoopMap(data.Schedule, function(_, pair) + pair.Value = (pair.Value >= result) and result or pair.Value + curCount.text = pair.Value + maxCount.text = string.format("/%d",result) + end) + else + schedule.gameObject:SetActiveEx(false) + end + + self:ShowReward(rewards, self.UndoneRewardGridList, grid, parent) +end + +function XUiGridTaskReward:ShowReward(rewards, rewardList, grid, parent) + grid.gameObject:SetActiveEx(false) + for i = 1, #rewardList do + rewardList[i]:Refresh() + end + + if not rewards then + return + end + + for i = 1, #rewards do + local panel = rewardList[i] + if not panel then + local ui = CS.UnityEngine.Object.Instantiate(grid) + ui.transform:SetParent(parent, false) + ui.gameObject:SetActiveEx(true) + panel = XUiGridCommon.New(self.Root, ui) + table.insert(rewardList, panel) + end + panel:Refresh(rewards[i]) + end +end + +function XUiGridTaskReward:IsCanGive() + return self.Data.Status >= XMentorSystemConfigs.TaskStatus.GetReward +end + +function XUiGridTaskReward:IsGiven() + return self.Data.Status >= XMentorSystemConfigs.TaskStatus.GiveEquip +end + +function XUiGridTaskReward:IsCanGet() + return self.Data.Status == XMentorSystemConfigs.TaskStatus.Completed +end +--------------------------------------------------------------------------- +return XUiGridTaskReward \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMentorSystem/MentorTask/XUiMentorTask.lua b/Resources/Scripts/XUi/XUiMentorSystem/MentorTask/XUiMentorTask.lua new file mode 100644 index 00000000..b7e86329 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMentorSystem/MentorTask/XUiMentorTask.lua @@ -0,0 +1,88 @@ +local XUiMentorTask = XLuaUiManager.Register(XLuaUi, "UiMentorTask") +local XUiPanelTeacherTask = require("XUi/XUiMentorSystem/MentorTask/XUiPanelTeacherTask") +local XUiPanelStudentTask = require("XUi/XUiMentorSystem/MentorTask/XUiPanelStudentTask") + +function XUiMentorTask:OnStart() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self:SetButtonCallBack() + + local mentorData = XDataCenter.MentorSystemManager.GetMentorData() + self.PanelTeacherTask = {} + self.PanelStudentTask = {} + + if mentorData:IsTeacher() then + self.PanelTeacherTask = XUiPanelTeacherTask.New(self.PanelMentor, self) + elseif mentorData:IsStudent() then + self.PanelStudentTask = XUiPanelStudentTask.New(self.PanelStudent, self) + end + + XDataCenter.MentorSystemManager.MarkFirstShowTaskGetRedDot() + XEventManager.DispatchEvent(XEventId.EVENT_MENTOR_INTASKUI) +end + +function XUiMentorTask:OnDestroy() + +end + +function XUiMentorTask:OnEnable() + self:UpdatePanel() + XDataCenter.MentorSystemManager.ShowMentorShipComplete() + XEventManager.AddEventListener(XEventId.EVENT_MENTOR_TEACHER_STUDENTSYSTEMTASK_CHANGE, self.UpdatePanel, self) + XEventManager.AddEventListener(XEventId.EVENT_MENTOR_TEACHER_STUDENTWEEKLYTASK_CHANGE, self.UpdatePanel, self) + XEventManager.AddEventListener(XEventId.EVENT_MENTOR_STUDENT_WEEKLYTASK_CHANGE, self.UpdatePanel, self) + XEventManager.AddEventListener(XEventId.EVENT_MENTOR_STUDENT_SYSTEMTASK_CHANGE, self.UpdatePanel, self) + XEventManager.AddEventListener(XEventId.EVENT_MENTOR_TEACHER_CHANGECOUNT_PLUS, self.UpdatePanel, self) + XEventManager.AddEventListener(XEventId.EVENT_MENTOR_DAY_RESET, self.UpdatePanel, self) + XEventManager.AddEventListener(XEventId.EVENT_MENTOR_WEEK_RESET, self.UpdatePanel, self) + XEventManager.AddEventListener(XEventId.EVENT_MENTOR_GETREWARD, self.UpdatePanel, self) +end + +function XUiMentorTask:OnDisable() + XEventManager.RemoveEventListener(XEventId.EVENT_MENTOR_TEACHER_STUDENTSYSTEMTASK_CHANGE, self.UpdatePanel, self) + XEventManager.RemoveEventListener(XEventId.EVENT_MENTOR_TEACHER_STUDENTWEEKLYTASK_CHANGE, self.UpdatePanel, self) + XEventManager.RemoveEventListener(XEventId.EVENT_MENTOR_STUDENT_WEEKLYTASK_CHANGE, self.UpdatePanel, self) + XEventManager.RemoveEventListener(XEventId.EVENT_MENTOR_STUDENT_SYSTEMTASK_CHANGE, self.UpdatePanel, self) + XEventManager.RemoveEventListener(XEventId.EVENT_MENTOR_TEACHER_CHANGECOUNT_PLUS, self.UpdatePanel, self) + XEventManager.RemoveEventListener(XEventId.EVENT_MENTOR_DAY_RESET, self.UpdatePanel, self) + XEventManager.RemoveEventListener(XEventId.EVENT_MENTOR_WEEK_RESET, self.UpdatePanel, self) + XEventManager.RemoveEventListener(XEventId.EVENT_MENTOR_GETREWARD, self.UpdatePanel, self) +end + +function XUiMentorTask:SetButtonCallBack() + self.BtnBack.CallBack = function() + self:OnBtnBackClick() + end + self.BtnMainUi.CallBack = function() + self:OnBtnMainUiClick() + end + self:BindHelpBtn(self.BtnHelp, "MentorSystemTaskHelp") +end + +function XUiMentorTask:UpdatePanel() + local mentorData = XDataCenter.MentorSystemManager.GetMentorData() + self.PanelMentor.gameObject:SetActiveEx(mentorData:IsTeacher()) + self.PanelStudent.gameObject:SetActiveEx(mentorData:IsStudent()) + + if mentorData:IsTeacher() then + self.PanelTeacherTask:UpdatePanel() + self:CheckTeacherGift() + elseif mentorData:IsStudent() then + self.PanelStudentTask:UpdatePanel() + end +end + +function XUiMentorTask:OnBtnBackClick() + self:Close() +end + +function XUiMentorTask:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiMentorTask:CheckTeacherGift() + local giftData = XDataCenter.MentorSystemManager.ShowTeacherGift() + if giftData then + local reward = XRewardManager.CreateRewardGoods(giftData.ItemId, giftData.Count) + XUiManager.OpenUiObtain({reward}) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMentorSystem/MentorTask/XUiPanelStudentPhasesTask.lua b/Resources/Scripts/XUi/XUiMentorSystem/MentorTask/XUiPanelStudentPhasesTask.lua new file mode 100644 index 00000000..90ef2655 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMentorSystem/MentorTask/XUiPanelStudentPhasesTask.lua @@ -0,0 +1,55 @@ +local XUiPanelStudentPhasesTask = XClass(nil, "XUiPanelStudentPhasesTask") +local XUiGridPhasesTask = require("XUi/XUiMentorSystem/MentorTask/XUiGridPhasesTask") +local CSTextManagerGetText = CS.XTextManager.GetText + +function XUiPanelStudentPhasesTask:Ctor(ui, root) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Root = root + XTool.InitUiObject(self) + +end + +function XUiPanelStudentPhasesTask:InitPhasesTaskGrid() + self.PhasesTaskGrids = {} + self.PhasesTaskGridRects = {} + self.GridActive.gameObject:SetActiveEx(false) + local mentorData = XDataCenter.MentorSystemManager.GetMentorData() + local taskList = mentorData:GetStudentWeeklyRewardList() + local taskCount = #taskList + for i = 1,taskCount do + local grid = self.PhasesTaskGrids[i] + if not grid then + local obj = CS.UnityEngine.Object.Instantiate(self.GridActive) + obj.gameObject:SetActiveEx(true) + obj.transform:SetParent(self.PanelContent, false) + grid = XUiGridPhasesTask.New(obj, self) + self.PhasesTaskGrids[i] = grid + self.PhasesTaskGridRects[i] = grid.Transform:GetComponent("RectTransform") + end + end +end + +function XUiPanelStudentPhasesTask:UpdatePanelPhasesTask() + local mentorData = XDataCenter.MentorSystemManager.GetMentorData() + self.ImgDaylyActiveProgress.fillAmount = mentorData:GetStudentWeeklyRewardTotalPercent() + self.TxtDailyActive.text = mentorData:GetWeeklyTaskCompleteCount() + self.TextMax.text = string.format("/%d",mentorData:GetLastStudentWeeklyRewardCount()) + self.TextActive.text = CSTextManagerGetText("MentorTeacherPhasesTaskText") + + local taskList = mentorData:GetStudentWeeklyRewardList() + local taskCount = #taskList + for i = 1, taskCount do + self.PhasesTaskGrids[i]:UpdateData(taskList[i]) + end + + -- 自适应 + local activeProgressRectSize = self.ImgDaylyActiveProgress.transform.rect.size + for i = 1, #self.PhasesTaskGrids do + local task = taskList[i] + local valOffset = mentorData:GetStudentWeeklyRewardPercentByCount(task.Count) + local adjustPosition = CS.UnityEngine.Vector3(activeProgressRectSize.x * valOffset, 0, 0) + self.PhasesTaskGridRects[i].anchoredPosition3D = adjustPosition + end +end +return XUiPanelStudentPhasesTask \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMentorSystem/MentorTask/XUiPanelStudentTask.lua b/Resources/Scripts/XUi/XUiMentorSystem/MentorTask/XUiPanelStudentTask.lua new file mode 100644 index 00000000..c5bdce79 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMentorSystem/MentorTask/XUiPanelStudentTask.lua @@ -0,0 +1,68 @@ +local XUiPanelStudentTask = XClass(nil, "XUiPanelStudentTask") +local XUiGridStudentWeeklyTask = require("XUi/XUiMentorSystem/MentorTask/XUiGridStudentWeeklyTask") +local XUiPanelStudentPhasesTask = require("XUi/XUiMentorSystem/MentorTask/XUiPanelStudentPhasesTask") + +local CSTextManagerGetText = CS.XTextManager.GetText +local DefaultIndex = 1 + +function XUiPanelStudentTask:Ctor(ui, root) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Root = root + XTool.InitUiObject(self) + self:SetButtonCallBack() + self:InitPanelTask() + self:InitPhasesTask() +end + +function XUiPanelStudentTask:SetButtonCallBack() + +end + +function XUiPanelStudentTask:InitPanelTask() + local maxGetedCount = XMentorSystemConfigs.GetMentorSystemData("CompleteTaskCount") + self.GridTask.gameObject:SetActiveEx(false) + self.TaskGridList = {} + for i = 1, maxGetedCount, 1 do + local obj = CS.UnityEngine.Object.Instantiate(self.GridTask) + obj.gameObject:SetActiveEx(true) + obj.transform:SetParent(self.TaskContent, false) + self.TaskGridList[i] = XUiGridStudentWeeklyTask.New(obj, self.Root) + end +end + +function XUiPanelStudentTask:InitPhasesTask() + self.PhasesTask = XUiPanelStudentPhasesTask.New(self.PanelReward) + self.PhasesTask:InitPhasesTaskGrid() +end + +function XUiPanelStudentTask:UpdatePanelTask() + local maxGetedCount = XMentorSystemConfigs.GetMentorSystemData("CompleteTaskCount") + for i = 1, maxGetedCount, 1 do + self.TaskGridList[i]:UpdateGrid(i) + end +end + +function XUiPanelStudentTask:UpdatePanel() + local mentorData = XDataCenter.MentorSystemManager.GetMentorData() + local curGetedCount = mentorData:GetStudentWeeklyTaskCountByIndex(XMentorSystemConfigs.MySelfIndex) + local maxGetedCount = XMentorSystemConfigs.GetMentorSystemData("CompleteTaskCount") + local maxDaliyCount = XMentorSystemConfigs.GetMentorSystemData("GetTaskCount") + local curDaliyCount = mentorData:GetStudentSystemTaskCountByIndex(XMentorSystemConfigs.MySelfIndex) + + self.TextGetTask:GetObject("TextGetTask").text = CSTextManagerGetText("MentorStudentWeekCanGetTask") + self.TextGetTask:GetObject("TaskCount").text = string.format("%d/%d", maxGetedCount - curGetedCount, maxGetedCount) + self.TextDaliyTask:GetObject("TextDaliyTask").text = CSTextManagerGetText("MentorStudentDayCanGetTask") + self.TextDaliyTask:GetObject("TaskCount").text = string.format("%d/%d", maxDaliyCount - curDaliyCount, maxDaliyCount) + + self.PhasesTask:UpdatePanelPhasesTask() + self:UpdatePanelTask() +end + +return XUiPanelStudentTask + + + + + + diff --git a/Resources/Scripts/XUi/XUiMentorSystem/MentorTask/XUiPanelTeacherTask.lua b/Resources/Scripts/XUi/XUiMentorSystem/MentorTask/XUiPanelTeacherTask.lua new file mode 100644 index 00000000..f4244877 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMentorSystem/MentorTask/XUiPanelTeacherTask.lua @@ -0,0 +1,157 @@ +local XUiPanelTeacherTask = XClass(nil, "XUiPanelTeacherTask") +local XUiPanelTeacherTaskAssist = require("XUi/XUiMentorSystem/MentorTask/XUiPanelTeacherTaskAssist") +local XUiPanelTeacherTaskReward = require("XUi/XUiMentorSystem/MentorTask/XUiPanelTeacherTaskReward") +local CSTextManagerGetText = CS.XTextManager.GetText +local DefaultIndex = 1 +local NameIndex = 0 +local ScheduleIndex = 2 +function XUiPanelTeacherTask:Ctor(ui, root) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Root = root + XTool.InitUiObject(self) + self.TaskTabList = { + [1] = self.BtnTaskType1, + [2] = self.BtnTaskType2, + } + self.IsHasStudent = false + self:SetButtonCallBack() + self:InitPanel() + self:InitStudentGroup() + self:InitTaskGroup() +end + +function XUiPanelTeacherTask:SetButtonCallBack() + self.PanelGift:GetObject("BtnClick").CallBack = function() + self:OnBtnGiftClick() + end + + self.PanelNoneStudent:GetObject("BtnClick").CallBack = function() + self:OnBtnGiftClick() + end +end + +function XUiPanelTeacherTask:OnBtnGiftClick() + XLuaUiManager.Open("UiMentorGiftTisp") +end + +function XUiPanelTeacherTask:InitPanel() + self.PanelTeacherTaskAssist = XUiPanelTeacherTaskAssist.New(self.PanelAssist, self.Root) + self.PanelTeacherTaskReward = XUiPanelTeacherTaskReward.New(self.PanelReward, self.Root) +end + +function XUiPanelTeacherTask:InitTaskGroup() + self.CurTaskType = XMentorSystemConfigs.TeacherTaskType.Assist + self.PanelTaskTypeGroup:Init(self.TaskTabList, function(index) self:SelectTaskType(index) end) + self.PanelTaskTypeGroup:SelectIndex(self.CurTaskType) +end + +function XUiPanelTeacherTask:InitStudentGroup() + local mentorData = XDataCenter.MentorSystemManager.GetMentorData() + local studentList = mentorData:GetNotGraduateStudentDataList() + self.BtnStudent.gameObject:SetActiveEx(false) + if not(studentList and next(studentList)) then + return + end + + self.StudentBtnList = self.StudentBtnList or {} + for index,student in pairs(studentList or {}) do + local btncs = self.StudentBtnList[index] + if not btncs then + local btn = CS.UnityEngine.Object.Instantiate(self.BtnStudent) + btn.transform:SetParent(self.PanelStudentContainer, false) + btncs = btn:GetComponent("XUiButton") + table.insert(self.StudentBtnList, btncs) + end + btncs.gameObject:SetActiveEx(true) + btncs:SetNameByGroup(NameIndex,student.PlayerName or "") + local taskCount = mentorData:GetStudentWeeklyTaskCompleteCountByIndex(index) + local maxCount = XMentorSystemConfigs.GetMentorSystemData("CompleteTaskCount") + btncs:SetNameByGroup(ScheduleIndex,string.format("%d/%d", taskCount, maxCount)) + btncs:ShowTag(student.IsGraduate) + local btnUiObj = btncs.transform:GetComponent("UiObject") + XUiPLayerHead.InitPortrait(student.HeadPortraitId, student.HeadFrameId, btnUiObj:GetObject("NormalHead")) + XUiPlayerLevel.UpdateLevel(student.Level, btnUiObj:GetObject("NormalLevel")) + XUiPLayerHead.InitPortrait(student.HeadPortraitId, student.HeadFrameId, btnUiObj:GetObject("SelectHead")) + XUiPlayerLevel.UpdateLevel(student.Level, btnUiObj:GetObject("SelectLevel")) + end + self.IsHasStudent = #self.StudentBtnList > 0 + self.PanelStudentGroup:Init(self.StudentBtnList, function(index) self:SelectStudent(index) end) + self.PanelStudentGroup:SelectIndex(DefaultIndex) + self.CurStudentIndex = DefaultIndex +end + +function XUiPanelTeacherTask:SelectStudent(index) + self.CurStudentIndex = index + self:UpdatePanel() +end + +function XUiPanelTeacherTask:SelectTaskType(index) + self.CurTaskType = index + self:UpdatePanel() +end + +function XUiPanelTeacherTask:UpdatePanel() + local mentorData = XDataCenter.MentorSystemManager.GetMentorData() + local IsTypeAssist = self.CurTaskType == XMentorSystemConfigs.TeacherTaskType.Assist + local IsTypeReward = self.CurTaskType == XMentorSystemConfigs.TeacherTaskType.Reward + local student = mentorData:GetNotGraduateStudentDataByIndex(self.CurStudentIndex) + local IsHasSystemTask = mentorData:CheckStudentSystemTaskIsEnmtyByIndex(self.CurStudentIndex) + local IsGraduateLevel = student and student.Level >= XMentorSystemConfigs.GetMentorSystemData("GraduateLv") or false + + self.PanelNoneStudent.gameObject:SetActiveEx(not self.IsHasStudent) + self.PanelTaskTypeGroup.gameObject:SetActiveEx(self.IsHasStudent) + self.PanelStudentGroup.gameObject:SetActiveEx(self.IsHasStudent) + self.PanelGift.gameObject:SetActiveEx(self.IsHasStudent) + self.PanelCloseTask.gameObject:SetActiveEx(self.IsHasStudent and not IsHasSystemTask and IsGraduateLevel) + self.PanelNoneDailyTask.gameObject:SetActiveEx(self.IsHasStudent and not IsHasSystemTask and not IsGraduateLevel) + + self.PanelTeacherTaskAssist.GameObject:SetActiveEx(IsTypeAssist and self.IsHasStudent and IsHasSystemTask) + self.PanelTeacherTaskReward.GameObject:SetActiveEx(IsTypeReward and self.IsHasStudent and IsHasSystemTask) + + if IsTypeAssist then + local taskList = student and student.SystemTask + self.PanelTeacherTaskAssist:UpdatePanel(taskList, student) + elseif IsTypeReward then + local taskList = student and student.WeeklyTask + self.PanelTeacherTaskReward:UpdatePanel(taskList, student) + end + + local gift = mentorData:GetTeacherGift() + local giftReward = XRewardManager.CreateRewardGoods(gift.Id, gift.Count) + self:UpdateGiftPanel(giftReward) + self:UpdateNoneStudentPanel(giftReward) + + self.Root:PlayAnimation("PanelMentorQieHuan") + self:CheckStudentState() +end + +function XUiPanelTeacherTask:UpdateGiftPanel(giftReward) + local gridGift = XUiGridCommon.New(self.Root, self.PanelGift:GetObject("GridItem")) + gridGift:Refresh(giftReward) +end + +function XUiPanelTeacherTask:UpdateNoneStudentPanel(giftReward) + local gridGift = XUiGridCommon.New(self.Root, self.PanelNoneStudent:GetObject("GridItem")) + gridGift:Refresh(giftReward) + self.PanelNoneStudent:GetObject("TextCount").text = giftReward.Count +end + +function XUiPanelTeacherTask:CheckStudentState() + local mentorData = XDataCenter.MentorSystemManager.GetMentorData() + local studentList = mentorData:GetNotGraduateStudentDataList() + for index,student in pairs(studentList or {}) do + local taskCount = mentorData:GetStudentWeeklyTaskCompleteCountByIndex(index) + local maxCount = XMentorSystemConfigs.GetMentorSystemData("CompleteTaskCount") + local IsShowRed = XDataCenter.MentorSystemManager.CheckTeacherCanGetStudentWeeklyRewardByStudent(student) + + self.StudentBtnList[index]:SetNameByGroup(ScheduleIndex,string.format("%d/%d", taskCount, maxCount)) + self.StudentBtnList[index]:ShowReddot(IsShowRed) + end + + local student = mentorData:GetNotGraduateStudentDataByIndex(self.CurStudentIndex) + local IsTabRedShow = XDataCenter.MentorSystemManager.CheckTeacherCanGetStudentWeeklyRewardByStudent(student) + self.TaskTabList[XMentorSystemConfigs.TeacherTaskType.Reward]:ShowReddot(IsTabRedShow) +end + +return XUiPanelTeacherTask \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMentorSystem/MentorTask/XUiPanelTeacherTaskAssist.lua b/Resources/Scripts/XUi/XUiMentorSystem/MentorTask/XUiPanelTeacherTaskAssist.lua new file mode 100644 index 00000000..08474904 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMentorSystem/MentorTask/XUiPanelTeacherTaskAssist.lua @@ -0,0 +1,47 @@ +local XUiPanelTeacherTaskAssist = XClass(nil, "XUiPanelTeacherTaskAssist") +local XUiGridTaskAssist = require("XUi/XUiMentorSystem/MentorTask/XUiGridTaskAssist") +local CSTextManagerGetText = CS.XTextManager.GetText + +function XUiPanelTeacherTaskAssist:Ctor(ui, root) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Root = root + XTool.InitUiObject(self) + + self:SetButtonCallBack() + self.GridTask.gameObject:SetActiveEx(false) + self.GridTaskList = {} +end + +function XUiPanelTeacherTaskAssist:SetButtonCallBack() + +end + +function XUiPanelTeacherTaskAssist:UpdatePanel(taskList, student) + self.Student = student + if taskList then + for i = 1, #taskList ,1 do + local grid = self.GridTaskList[i] + if not grid then + local taskObj = CS.UnityEngine.Object.Instantiate(self.GridTask) + taskObj.transform:SetParent(self.PanelTask, false) + grid = XUiGridTaskAssist.New(taskObj, self.Root) + self.GridTaskList[i] = grid + end + grid:UpdateGrid(taskList[i], self.Student) + grid.GameObject:SetActiveEx(true) + end + for i = #taskList + 1, #self.GridTaskList, 1 do + self.GridTaskList[i].GameObject:SetActiveEx(false) + end + end + + local mentorData = XDataCenter.MentorSystemManager.GetMentorData() + local maxCount = XMentorSystemConfigs.GetMentorSystemData("ChangeTaskCount") + local curCount = mentorData:GetDailyChangeTaskCount() + self.TextTitle.text = CSTextManagerGetText("MentorTeacherDayCanChangeTask") + self.TextCount.text = string.format("%d/%d",maxCount - curCount , maxCount) + self.TxtHint.text = CSTextManagerGetText("MentorTeacherChangeTaskHint") +end + +return XUiPanelTeacherTaskAssist \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMentorSystem/MentorTask/XUiPanelTeacherTaskReward.lua b/Resources/Scripts/XUi/XUiMentorSystem/MentorTask/XUiPanelTeacherTaskReward.lua new file mode 100644 index 00000000..6d0c3dd8 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMentorSystem/MentorTask/XUiPanelTeacherTaskReward.lua @@ -0,0 +1,41 @@ +local XUiPanelTeacherTaskReward = XClass(nil, "XUiPanelTeacherTaskReward") +local XUiGridTaskReward = require("XUi/XUiMentorSystem/MentorTask/XUiGridTaskReward") +local CSTextManagerGetText = CS.XTextManager.GetText + +function XUiPanelTeacherTaskReward:Ctor(ui, root) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Root = root + XTool.InitUiObject(self) + + self:SetButtonCallBack() + self.GridTask.gameObject:SetActiveEx(false) + self.GridTaskList = {} +end + +function XUiPanelTeacherTaskReward:SetButtonCallBack() + +end + +function XUiPanelTeacherTaskReward:UpdatePanel(taskList, student) + self.Student = student + if taskList then + for i = 1, #taskList ,1 do + local grid = self.GridTaskList[i] + if not grid then + local taskObj = CS.UnityEngine.Object.Instantiate(self.GridTask) + taskObj.transform:SetParent(self.PanelTask, false) + grid = XUiGridTaskReward.New(taskObj, self.Root) + self.GridTaskList[i] = grid + end + grid:UpdateGrid(taskList[i], self.Student) + grid.GameObject:SetActiveEx(true) + end + for i = #taskList + 1, #self.GridTaskList, 1 do + self.GridTaskList[i].GameObject:SetActiveEx(false) + end + end + self.PanelNoneDailyTask.gameObject:SetActiveEx(not (taskList and next(taskList))) +end + +return XUiPanelTeacherTaskReward \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMineSweeping/XUiGridMine.lua b/Resources/Scripts/XUi/XUiMineSweeping/XUiGridMine.lua new file mode 100644 index 00000000..de676f1a --- /dev/null +++ b/Resources/Scripts/XUi/XUiMineSweeping/XUiGridMine.lua @@ -0,0 +1,90 @@ +local XUiGridMine = XClass(nil, "XUiGridMine") +local CSTextManagerGetText = CS.XTextManager.GetText +local Vector3 = CS.UnityEngine.Vector3 +function XUiGridMine:Ctor(ui, root) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Root = root + XTool.InitUiObject(self) + self:SetButtonCallBack() + self.Win.gameObject:SetActiveEx(false) + self.IsOpendShow = false +end + +function XUiGridMine:SetButtonCallBack() + self.BtnClick.CallBack = function() + self:OnBtnClick() + end +end + +function XUiGridMine:OnBtnClick() + local xIndex, yIndex = self.Data:GetPosIndex() + XDataCenter.MineSweepingManager.MineSweepingOpenRequest(self.ChapterId, self.StageId, xIndex, yIndex, function (rewardGoodsList) + local chapterEntity = XDataCenter.MineSweepingManager.GetChapterByChapterId(self.ChapterId) + local stageEntity = chapterEntity:GetStageEntityById(self.StageId) + if stageEntity:IsFinish() then + if chapterEntity:IsFinish() then + self.Root:SetSpecialState(XMineSweepingConfigs.SpecialState.ChapterWin, self.ChapterId, self.StageId) + else + self.Root:SetSpecialState(XMineSweepingConfigs.SpecialState.StageWin, self.ChapterId, self.StageId) + end + self.Root:ShowStageWinEffect() + end + if stageEntity:IsFailed() then + self.Root:SetSpecialState(XMineSweepingConfigs.SpecialState.StageLose, self.ChapterId, self.StageId) + end + self.Root:SetFinishReward(rewardGoodsList) + self.IsOpendShow = true + end) +end + +function XUiGridMine:UpdateGrid(data, chapterId, stageId) + self.Data = data + self.ChapterId = chapterId + self.StageId = stageId + if data then + self:ShowPanel() + self:UpdatePanelNumber() + self:UpdatePanelMine() + end +end + +function XUiGridMine:ShowPanel() + self.Number.gameObject:SetActiveEx(self.Data:IsSafe()) + self.NorNumber.gameObject:SetActiveEx(self.Data:IsSafe()) + self.Mine.gameObject:SetActiveEx(self.Data:IsMine()) + self.BtnClick.gameObject:SetActiveEx(self.Data:IsUnknown()) +end + +function XUiGridMine:UpdatePanelNumber() + local num = self.Data:GetRoundMineNumber() + self.Number:GetObject("Text").text = num + self.Number.gameObject:SetActiveEx(num > 0) + self.NorNumber.gameObject:SetActiveEx(num <= 0) +end + +function XUiGridMine:UpdatePanelMine() + local chapterEntity = XDataCenter.MineSweepingManager.GetChapterByChapterId(self.ChapterId) + local icon = chapterEntity:GetMineIcon() + self.Mine:GetObject("Image"):SetSprite(icon) + self.Mine:GetObject("MineEffect").gameObject:SetActiveEx(false) + if self.Data:IsMine() and self.IsOpendShow then + self.Mine:GetObject("MineEffect"):LoadUiEffect(chapterEntity:GetMineEffect()) + self.Mine:GetObject("MineEffect").gameObject:SetActiveEx(true) + self.IsOpendShow = false + end +end + +function XUiGridMine:ShowEffect() + local chapterEntity = XDataCenter.MineSweepingManager.GetChapterByChapterId(self.ChapterId) + if self.Data:IsMine() or self.Data:IsUnknown() then + self.Win:GetObject("WinEffect"):LoadUiEffect(chapterEntity:GetWinGridEffect()) + self.Win.gameObject:SetActiveEx(true) + end +end + +function XUiGridMine:ResetEffect() + self.Win.gameObject:SetActiveEx(false) +end + +return XUiGridMine \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMineSweeping/XUiGridStageReward.lua b/Resources/Scripts/XUi/XUiMineSweeping/XUiGridStageReward.lua new file mode 100644 index 00000000..eb266c5b --- /dev/null +++ b/Resources/Scripts/XUi/XUiMineSweeping/XUiGridStageReward.lua @@ -0,0 +1,50 @@ +local XUiGridStageReward = XClass(nil, "XUiGridStageReward") +local CSTextManagerGetText = CS.XTextManager.GetText +function XUiGridStageReward:Ctor(ui, root) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Root = root + self.IsPlayedAnime = true + XTool.InitUiObject(self) +end + +function XUiGridStageReward:UpdateGrid(data) + self.Data = data + if data then + if not self.Reward then + self.Reward = XUiGridCommon.New(self.Root, self.GridCommon) + end + + local reward = XRewardManager.GetRewardList(data:GetRewardId())[1] + self.Reward:Refresh(reward) + + self.HintText.text = CSTextManagerGetText("MineStageUnLockHint", data:GetName()) + self:ShowGrid() + end +end + +function XUiGridStageReward:ShowGrid() + if not self.Data:IsFinish() then + self.GameObject:SetActiveEx(true) + self.GridCanvasGroup.alpha = 1 + self.IsPlayedAnime = false + else + if self.IsPlayedAnime or self.Root:IsChapterIndexChange() then + self.GameObject:SetActiveEx(false) + end + end +end + +function XUiGridStageReward:CheckPlayAnime() + if self.Data:IsFinish() and not self.IsPlayedAnime and self.GameObject.activeInHierarchy then + XLuaUiManager.SetMask(true) + self.GridStageRewardDisable:PlayTimelineAnimation(function () + self.IsPlayedAnime = true + XLuaUiManager.SetMask(false) + self.Root:ShowFinishReward() + self.GameObject:SetActiveEx(false) + end) + end +end + +return XUiGridStageReward \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMineSweeping/XUiMineSweepingMain.lua b/Resources/Scripts/XUi/XUiMineSweeping/XUiMineSweepingMain.lua new file mode 100644 index 00000000..bafc9dd1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMineSweeping/XUiMineSweepingMain.lua @@ -0,0 +1,264 @@ +local XUiMineSweepingMain = XLuaUiManager.Register(XLuaUi, "UiMineSweepingMain") + +local XUiPanelAllGrid = require("XUi/XUiMineSweeping/XUiPanelAllGrid") +local XUiPanelCondition = require("XUi/XUiMineSweeping/XUiPanelCondition") +local XUiPanelPlay = require("XUi/XUiMineSweeping/XUiPanelPlay") +local XUiPanelSequence = require("XUi/XUiMineSweeping/XUiPanelSequence") +local XUiPanelSequenceWin = require("XUi/XUiMineSweeping/XUiPanelSequenceWin") +local XUiPanelSettlement = require("XUi/XUiMineSweeping/XUiPanelSettlement") +local XUiPanelStart = require("XUi/XUiMineSweeping/XUiPanelStart") +local CSTextManagerGetText = CS.XTextManager.GetText +local Disable = CS.UiButtonState.Disable +local Normal = CS.UiButtonState.Normal +function XUiMineSweepingMain:OnStart() + self:SetButtonCallBack() + self:Init() +end + +function XUiMineSweepingMain:OnDestroy() + +end + +function XUiMineSweepingMain:OnEnable() + self:CreatrTimer() + self:CheckHitFaceHelp() + self:UpdatePanel() + + XEventManager.AddEventListener(XEventId.EVENT_MINESWEEPING_STAGESTART, self.UpdatePanel, self) + XEventManager.AddEventListener(XEventId.EVENT_MINESWEEPING_GRIDOPEN, self.UpdatePanel, self) + XEventManager.AddEventListener(XEventId.EVENT_MINESWEEPING_STORYPLAY, self.ShowRed, self) +end + +function XUiMineSweepingMain:OnDisable() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + end + if self.AllGridPanel:ResetEffect() then + XLuaUiManager.SetMask(false) + end + XEventManager.RemoveEventListener(XEventId.EVENT_MINESWEEPING_STAGESTART, self.UpdatePanel, self) + XEventManager.RemoveEventListener(XEventId.EVENT_MINESWEEPING_GRIDOPEN, self.UpdatePanel, self) + XEventManager.RemoveEventListener(XEventId.EVENT_MINESWEEPING_STORYPLAY, self.ShowRed, self) +end + +function XUiMineSweepingMain:Init() + self.SpecialState = {} + + self.AllGridPanel = XUiPanelAllGrid.New(self.PanelAllGrid, self) + self.ConditionPanel = XUiPanelCondition.New(self.PanelCondition, self) + self.PlayPanel = XUiPanelPlay.New(self.PanelPlay, self) + self.SequencePanel = XUiPanelSequence.New(self.PanelSequence, self) + self.SequenceWinPanel = XUiPanelSequenceWin.New(self.PanelSequenceWin, self) + self.SettlementPanel = XUiPanelSettlement.New(self.PanelSettlement, self) + self.StartPanel = XUiPanelStart.New(self.PanelStart, self) + + self.AssetActivityPanel = XUiPanelActivityAsset.New(self.PanelActivityAsset) + local itemId = XDataCenter.MineSweepingManager.GetMineSweepingCoinItemId() + XDataCenter.ItemManager.AddCountUpdateListener(itemId, function() + self.AssetActivityPanel:Refresh({ itemId }) + end, self.AssetActivityPanel) + self.AssetActivityPanel:Refresh({ itemId }) + self:InitChapterBtnGroup() +end + +function XUiMineSweepingMain:CreatrTimer() + if not self.Timer then + self.Timer = XScheduleManager.ScheduleForever(function() + self:CheckTime() + end, XScheduleManager.SECOND , 0) + end +end + +function XUiMineSweepingMain:SetButtonCallBack() + self.BtnBack.CallBack = function() + self:OnBtnBackClick() + end + + self.BtnMainUi.CallBack = function() + self:OnBtnMainUiClick() + end + + self:BindHelpBtn(self.BtnHelp, "MineSweepingGame") +end + +function XUiMineSweepingMain:OnBtnBackClick() + self:Close() +end + +function XUiMineSweepingMain:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiMineSweepingMain:InitChapterBtnGroup() + local btnObj = self.PanelTag:GetObject("BtnTog") + local btnGroup = self.PanelTag:GetObject("ChapterGroup") + local index = XDataCenter.MineSweepingManager.GetNewChapterIndex() + self.CurCharterIndex = index + + btnObj.gameObject:SetActiveEx(false) + self.CharterBtnList = {} + + local chapterIds = XDataCenter.MineSweepingManager.GetChapterIds() + + for chapterIndex,_ in pairs(chapterIds) do + local btn = CS.UnityEngine.Object.Instantiate(btnObj) + btn.gameObject:SetActiveEx(true) + btn.transform:SetParent(btnGroup.transform, false) + local btncs = btn:GetComponent("XUiButton") + local chapterEntity = XDataCenter.MineSweepingManager.GetChapterEntityByIndex(chapterIndex) + local name = chapterEntity:GetName() or "" + local nameEn = chapterEntity:GetNameEn() or "" + btncs:SetNameByGroup(0, name) + btncs:SetNameByGroup(1, nameEn) + btncs:SetDisable(chapterEntity:IsLock()) + table.insert(self.CharterBtnList, btncs) + self.SpecialState[chapterIndex] = XMineSweepingConfigs.SpecialState.None + end + btnGroup:Init(self.CharterBtnList, function(index) self:SelectTag(index) end) + self.OldIndex = index + btnGroup:SelectIndex(index) +end + +function XUiMineSweepingMain:SelectTag(index) + if self.CharterBtnList[index].ButtonState == Disable then + XUiManager.TipText("MineChapterLockHint") + return + end + self.OldIndex = self.CurCharterIndex + self.CurCharterIndex = index + self:RetSetSpecialState(self.OldIndex) + self:UpdatePanel() + self.OldIndex = self.CurCharterIndex +end + +function XUiMineSweepingMain:UpdatePanel() + self:UpdateChapterBtnGroup() + self.ConditionPanel:UpdatePanel(self.CurCharterIndex) + self.StartPanel:UpdatePanel(self.CurCharterIndex) + self.AllGridPanel:UpdatePanel(self.CurCharterIndex) + self.SettlementPanel:UpdatePanel() + self.SequenceWinPanel:UpdatePanel(self.CurCharterIndex) + self.PlayPanel:UpdatePanel(self.CurCharterIndex) + self.SequencePanel:UpdatePanel(self.CurCharterIndex) + self:PanelShow() + self:ShowRed() +end + +function XUiMineSweepingMain:PanelShow() + local chapterEntity = XDataCenter.MineSweepingManager.GetChapterEntityByIndex(self.CurCharterIndex) + self.ConditionPanel:ShowPanel(chapterEntity:IsSweeping() and self:IsSpecialStateNone()) + self.StartPanel:ShowPanel((chapterEntity:IsPrepare() or chapterEntity:IsFailed()) and self:IsSpecialStateNone()) + self.AllGridPanel:ShowPanel(chapterEntity:IsSweeping() or self:IsSpecialStateStageWin() or self:IsSpecialStateChapterWin()) + self.SettlementPanel:ShowPanel(self:IsSpecialStateStageWin() or self:IsSpecialStateStageLose()) + self.SequenceWinPanel:ShowPanel(false) + self.PlayPanel:ShowPanel(chapterEntity:IsFinish() and self:IsSpecialStateNone()) +end + +function XUiMineSweepingMain:UpdateChapterBtnGroup() + for index,btn in pairs(self.CharterBtnList) do + local chapterEntity = XDataCenter.MineSweepingManager.GetChapterEntityByIndex(index) + if chapterEntity:IsLock() then + btn:SetButtonState(Disable) + else + if btn.ButtonState == Disable then + btn:SetButtonState(Normal) + end + end + end +end + +function XUiMineSweepingMain:CheckHitFaceHelp() + local IsShowHelp = XDataCenter.MineSweepingManager.CheckShowHelp() + if IsShowHelp then + XUiManager.ShowHelpTip("MineSweepingGame") + end +end + +function XUiMineSweepingMain:CheckTime() + self.TimeLeft = XDataCenter.MineSweepingManager.GetMineSweepingTimeLeft() + self.PanelTitle:GetObject("TimeText").text = XUiHelper.GetTime(self.TimeLeft, XUiHelper.TimeFormatType.ACTIVITY) + + if self.TimeLeft <= 0 then + XUiManager.TipText("MineSweepingOverTimeHint") + self:OnBtnMainUiClick() + end +end + +function XUiMineSweepingMain:SetSpecialState(state, chapterId, stageId) + self.SpecialState[self.CurCharterIndex] = state + self.SpecialStateChapterId = chapterId + self.SpecialStateStageId = stageId + + self:UpdatePanel() +end + +function XUiMineSweepingMain:RetSetSpecialState(index) + self.SpecialState[index] = XMineSweepingConfigs.SpecialState.None +end + +function XUiMineSweepingMain:IsChapterIndexChange() + return self.CurCharterIndex ~= self.OldIndex +end + +function XUiMineSweepingMain:IsSpecialStateNone() + return self.SpecialState[self.CurCharterIndex] == XMineSweepingConfigs.SpecialState.None +end + +function XUiMineSweepingMain:IsSpecialStateStageWin() + return self.SpecialState[self.CurCharterIndex] == XMineSweepingConfigs.SpecialState.StageWin +end + +function XUiMineSweepingMain:IsSpecialStateStageLose() + return self.SpecialState[self.CurCharterIndex] == XMineSweepingConfigs.SpecialState.StageLose +end + +function XUiMineSweepingMain:IsSpecialStateChapterWin() + return self.SpecialState[self.CurCharterIndex] == XMineSweepingConfigs.SpecialState.ChapterWin +end + +function XUiMineSweepingMain:GetSpecialStateStageId() + return self.SpecialStateStageId +end + +function XUiMineSweepingMain:GetSpecialStateChapterId() + return self.SpecialStateChapterId +end + +function XUiMineSweepingMain:ShowStageWinEffect() + local IsFirst = false + XLuaUiManager.SetMask(true) + self.AllGridPanel:ShowEffect(function () + if not IsFirst then + self.SequencePanel:CheckPlayGridAnime() + IsFirst = true + XLuaUiManager.SetMask(false) + end + end) +end + +function XUiMineSweepingMain:SetFinishReward(rewardGoodsList) + self.RewardGoodsList = rewardGoodsList +end + +function XUiMineSweepingMain:ShowFinishReward() + if self.RewardGoodsList and next(self.RewardGoodsList) then + XUiManager.OpenUiObtain(self.RewardGoodsList, nil, function () + if self:IsSpecialStateStageWin() then + self.SettlementPanel:ShowWinPanel() + end + if self:IsSpecialStateChapterWin() then + self.SequenceWinPanel:ShowPanel(true) + end + end) + self.RewardGoodsList = nil + end +end + +function XUiMineSweepingMain:ShowRed() + local chapterIds = XDataCenter.MineSweepingManager.GetChapterIds() + for index, id in pairs(chapterIds) do + local IsShow = XDataCenter.MineSweepingManager.CheckHaveRedByChapterId(id) + self.CharterBtnList[index]:ShowReddot(IsShow) + end +end + diff --git a/Resources/Scripts/XUi/XUiMineSweeping/XUiPanelAllGrid.lua b/Resources/Scripts/XUi/XUiMineSweeping/XUiPanelAllGrid.lua new file mode 100644 index 00000000..666646d0 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMineSweeping/XUiPanelAllGrid.lua @@ -0,0 +1,92 @@ +local XUiPanelAllGrid = XClass(nil, "XUiPanelAllGrid") +local XUiGridMine = require("XUi/XUiMineSweeping/XUiGridMine") +local CSTextManagerGetText = CS.XTextManager.GetText +function XUiPanelAllGrid:Ctor(ui, base) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Base = base + XTool.InitUiObject(self) + self.AllGridList = {} + self.GridMine.gameObject:SetActiveEx(false) +end + +function XUiPanelAllGrid:UpdatePanel(curCharterIndex, IsSpecialStateWin) + if curCharterIndex and not IsSpecialStateWin then + local chapterEntity = XDataCenter.MineSweepingManager.GetChapterEntityByIndex(curCharterIndex) + local stageEntity = chapterEntity:GetCurStageEntity() + local rowCount = stageEntity:GetRowCount() + local columnCount = stageEntity:GetColumnCount() + + for y = 1, rowCount do + for x = 1, columnCount do + local gridEntity = chapterEntity:GetGridEntityByPos(x, y) + local key = XMineSweepingConfigs.GetGridKeyByPos(x, y) + if not self.AllGridList[key] then + local obj = CS.UnityEngine.Object.Instantiate(self.GridMine, self.PanelCase) + obj.gameObject:SetActiveEx(true) + self.AllGridList[key] = XUiGridMine.New(obj, self.Base) + end + self.AllGridList[key]:UpdateGrid(gridEntity, chapterEntity:GetChapterId(), stageEntity:GetStageId()) + end + end + + if chapterEntity:IsSweeping()then + if self.IsCanPlayAnime == nil then + self.IsCanPlayAnime = not self.Base:IsChapterIndexChange() + end + else + self.IsCanPlayAnime = nil + end + end +end + +function XUiPanelAllGrid:ShowPanel(IsShow) + self.GameObject:SetActiveEx(IsShow) + if IsShow then + if self.IsCanPlayAnime then + self.Base:PlayAnimationWithMask("GridMineEnable") + self.IsCanPlayAnime = false + end + else + self:ResetEffect() + end +end + +function XUiPanelAllGrid:ShowEffect(cb) + for _,grid in pairs(self.AllGridList) do + grid:ShowEffect() + end + + self.EffectTimer = XScheduleManager.ScheduleOnce(function() + self.EffectTimer = nil + self:ShowWinEffect(cb) + end, XScheduleManager.SECOND / 2) +end + +function XUiPanelAllGrid:ShowWinEffect(cb) + local SpecialStateChapterId = self.Base:GetSpecialStateChapterId() + local SpecialStateStageId = self.Base:GetSpecialStateStageId() + local chapterEntity = XDataCenter.MineSweepingManager.GetChapterEntityById(SpecialStateChapterId) + local stageEntity = chapterEntity:GetStageEntityById(SpecialStateStageId) + + self.WinEffect:LoadUiEffect(stageEntity:GetWinEffect()) + self.WinEffect.gameObject:SetActiveEx(true) + self.EffectTimer = XScheduleManager.ScheduleOnce(function() + self.EffectTimer = nil + self.WinEffect.gameObject:SetActiveEx(false) + if cb then cb() end + end, XScheduleManager.SECOND) +end + +function XUiPanelAllGrid:ResetEffect() + for _,grid in pairs(self.AllGridList) do + grid:ResetEffect() + end + if self.EffectTimer then + XScheduleManager.UnSchedule(self.EffectTimer) + return true + end + return false +end + +return XUiPanelAllGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMineSweeping/XUiPanelCondition.lua b/Resources/Scripts/XUi/XUiMineSweeping/XUiPanelCondition.lua new file mode 100644 index 00000000..10fd0cf2 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMineSweeping/XUiPanelCondition.lua @@ -0,0 +1,23 @@ +local XUiPanelCondition = XClass(nil, "XUiPanelCondition") +local CSTextManagerGetText = CS.XTextManager.GetText +function XUiPanelCondition:Ctor(ui, base) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Base = base + XTool.InitUiObject(self) +end + +function XUiPanelCondition:UpdatePanel(curCharterIndex) + if curCharterIndex then + local chapterEntity = XDataCenter.MineSweepingManager.GetChapterEntityByIndex(curCharterIndex) + local stageEntity = chapterEntity:GetCurStageEntity() + self.WinText.text = CSTextManagerGetText("MineSweepingStageWinHint", stageEntity:GetWhiteGridOpenNumber(), stageEntity:GetWhiteGridTotalNumber()) + self.LoseText.text = CSTextManagerGetText("MineSweepingStageLoseHint", stageEntity:GetAllowMineNumber(), stageEntity:GetMineGridOpenNumber(), stageEntity:GetAllowMineNumber()) + end +end + +function XUiPanelCondition:ShowPanel(IsShow) + self.GameObject:SetActiveEx(IsShow) +end + +return XUiPanelCondition \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMineSweeping/XUiPanelPlay.lua b/Resources/Scripts/XUi/XUiMineSweeping/XUiPanelPlay.lua new file mode 100644 index 00000000..fdb8601a --- /dev/null +++ b/Resources/Scripts/XUi/XUiMineSweeping/XUiPanelPlay.lua @@ -0,0 +1,48 @@ +local XUiPanelPlay = XClass(nil, "XUiPanelPlay") +local CSTextManagerGetText = CS.XTextManager.GetText +function XUiPanelPlay:Ctor(ui, base) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Base = base + XTool.InitUiObject(self) + self:SetButtonCallBack() +end + +function XUiPanelPlay:SetButtonCallBack() + self.BtnPlay.CallBack = function() + self:OnBtnPlayClick() + end +end + +function XUiPanelPlay:OnBtnPlayClick() + XDataCenter.MovieManager.PlayMovie(self.StoryId) + XDataCenter.MineSweepingManager.MarkStoryRed(self.ChapterId) + XEventManager.DispatchEvent(XEventId.EVENT_MINESWEEPING_STORYPLAY) +end + + +function XUiPanelPlay:UpdatePanel(curCharterIndex) + if curCharterIndex then + local chapterEntity = XDataCenter.MineSweepingManager.GetChapterEntityByIndex(curCharterIndex) + local img = chapterEntity:GetCompleteImg() + self.ChapterId = chapterEntity:GetChapterId() + self.RImgBg:SetRawImage(img) + self.StoryId = chapterEntity:GetCompleteStoryId() + self.PanelInfo.gameObject:SetActiveEx(self.StoryId ~= nil) + end +end + +function XUiPanelPlay:ShowPanel(IsShow) + self.GameObject:SetActiveEx(IsShow) + if IsShow then + if self.StoryId ~= nil then + self.Base:PlayAnimationWithMask("PanelPlayEnable",function () + self.Base:PlayAnimation("PanelPlayLoop", nil, nil, CS.UnityEngine.Playables.DirectorWrapMode.Loop) + end) + else + self.Base:PlayAnimationWithMask("PanelPlayEnable2") + end + end +end + +return XUiPanelPlay \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMineSweeping/XUiPanelSequence.lua b/Resources/Scripts/XUi/XUiMineSweeping/XUiPanelSequence.lua new file mode 100644 index 00000000..cad54d96 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMineSweeping/XUiPanelSequence.lua @@ -0,0 +1,59 @@ +local XUiPanelSequence = XClass(nil, "XUiPanelSequence") +local XUiGridStageReward = require("XUi/XUiMineSweeping/XUiGridStageReward") +local CSTextManagerGetText = CS.XTextManager.GetText +local Vector2 = CS.UnityEngine.Vector2 +local Vector3 = CS.UnityEngine.Vector3 +function XUiPanelSequence:Ctor(ui, base) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Base = base + XTool.InitUiObject(self) + self.RewardList = {} + self.GridStageReward.gameObject:SetActiveEx(false) +end + +function XUiPanelSequence:UpdatePanel(curCharterIndex) + if curCharterIndex then + local chapterEntity = XDataCenter.MineSweepingManager.GetChapterEntityByIndex(curCharterIndex) + local img = chapterEntity:GetAllMineImg() + self.MineSweepingRawImage:SetRawImage(img) + self:UpdateReward(chapterEntity) + end +end + +function XUiPanelSequence:UpdateReward(chapterEntity) + local stageList = chapterEntity:GetStageEntityDic() + local stageCount = chapterEntity:GetStageCount() + stageCount = math.max(stageCount, 1) + + local width = self.MineSweepingRawImage.transform:GetComponent("RectTransform").sizeDelta.x / stageCount + local high = self.MineSweepingRawImage.transform:GetComponent("RectTransform").sizeDelta.y + for index = 1, stageCount do + if not self.RewardList[index] then + local obj = CS.UnityEngine.Object.Instantiate(self.GridStageReward, self.PanelAward) + self.RewardList[index] = XUiGridStageReward.New(obj, self.Base) + end + local id = chapterEntity:GetShowActivityStageIdByIndex(index) + local entity = stageList[id] + self.RewardList[index].GameObject:SetActiveEx(true) + self.RewardList[index].Transform:GetComponent("RectTransform").sizeDelta = Vector2(width, high) + self.RewardList[index].Transform.localPosition = Vector3(width * index - width / 2, 0, 0) + self.RewardList[index]:UpdateGrid(entity) + end + + for index = stageCount + 1, #self.RewardList do + self.RewardList[index].GameObject:SetActiveEx(false) + end +end + +function XUiPanelSequence:CheckPlayGridAnime() + for _,grid in pairs(self.RewardList or {}) do + grid:CheckPlayAnime() + end +end + +function XUiPanelSequence:ShowPanel(IsShow) + self.GameObject:SetActiveEx(IsShow) +end + +return XUiPanelSequence \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMineSweeping/XUiPanelSequenceWin.lua b/Resources/Scripts/XUi/XUiMineSweeping/XUiPanelSequenceWin.lua new file mode 100644 index 00000000..260ba9dc --- /dev/null +++ b/Resources/Scripts/XUi/XUiMineSweeping/XUiPanelSequenceWin.lua @@ -0,0 +1,38 @@ +local XUiPanelSequenceWin = XClass(nil, "XUiPanelSequenceWin") +local CSTextManagerGetText = CS.XTextManager.GetText +function XUiPanelSequenceWin:Ctor(ui, base) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Base = base + XTool.InitUiObject(self) + self:SetButtonCallBack() +end + +function XUiPanelSequenceWin:SetButtonCallBack() + self.BtnClose.CallBack = function() + self:OnBtnCloseClick() + end +end + +function XUiPanelSequenceWin:OnBtnCloseClick() + self.Base:SetSpecialState(XMineSweepingConfigs.SpecialState.None) +end + +function XUiPanelSequenceWin:UpdatePanel() + local SpecialStateChapterId = self.Base:GetSpecialStateChapterId() + if SpecialStateChapterId then + local chapterEntity = XDataCenter.MineSweepingManager.GetChapterEntityById(SpecialStateChapterId) + self.HintText.text = CSTextManagerGetText("MineSweepingChapterWinHint",chapterEntity:GetChallengeCounts()) + end +end + +function XUiPanelSequenceWin:ShowPanel(IsShow) + self.GameObject:SetActiveEx(IsShow) + if IsShow then + self.Base:PlayAnimationWithMask("PanelSequenceWinEnable",function () + self.Base:PlayAnimation("PanelSequenceWinLoop", nil, nil, CS.UnityEngine.Playables.DirectorWrapMode.Loop) + end) + end +end + +return XUiPanelSequenceWin \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMineSweeping/XUiPanelSettlement.lua b/Resources/Scripts/XUi/XUiMineSweeping/XUiPanelSettlement.lua new file mode 100644 index 00000000..03a387a9 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMineSweeping/XUiPanelSettlement.lua @@ -0,0 +1,57 @@ +local XUiPanelSettlement = XClass(nil, "XUiPanelSettlement") +local CSTextManagerGetText = CS.XTextManager.GetText +function XUiPanelSettlement:Ctor(ui, base) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Base = base + XTool.InitUiObject(self) + self:SetButtonCallBack() +end + +function XUiPanelSettlement:SetButtonCallBack() + self.BtnClick.CallBack = function() + self:OnBtnClick() + end +end + +function XUiPanelSettlement:OnBtnClick() + self.Base:SetSpecialState(XMineSweepingConfigs.SpecialState.None) +end + +function XUiPanelSettlement:UpdatePanel() + local SpecialStateChapterId = self.Base:GetSpecialStateChapterId() + local SpecialStateStageId = self.Base:GetSpecialStateStageId() + if SpecialStateChapterId and SpecialStateStageId then + local chapterEntity = XDataCenter.MineSweepingManager.GetChapterEntityById(SpecialStateChapterId) + local stageEntity = chapterEntity:GetStageEntityById(SpecialStateStageId) + self.PanelWin.gameObject:SetActiveEx(self.Base:IsSpecialStateStageWin()) + self.PanelLose.gameObject:SetActiveEx(self.Base:IsSpecialStateStageLose()) + self.PanelWin:GetObject("TxtLevel").text = stageEntity:GetName() + self.PanelLose:GetObject("TxtLevel").text = stageEntity:GetName() + + local failedCount = stageEntity:GetFailedCounts() + local canFailedDifference = stageEntity:GetCanFailedCountByIndex(failedCount + 2) - stageEntity:GetCanFailedCountByIndex(failedCount + 1) + canFailedDifference = math.max(0, canFailedDifference) + + self.PanelLose:GetObject("TxtCount").text = CSTextManagerGetText("MineSweepingChallengePlusHint", canFailedDifference) + end +end + +function XUiPanelSettlement:ShowWinPanel() + self.GameObject:SetActiveEx(true) + self.Base:PlayAnimationWithMask("PanelWinEnable") + +end + +function XUiPanelSettlement:ShowPanel(IsShow) + if IsShow then + if self.Base:IsSpecialStateStageLose() then + self.Base:PlayAnimationWithMask("PanelLoseEnable") + self.GameObject:SetActiveEx(true) + end + else + self.GameObject:SetActiveEx(false) + end +end + +return XUiPanelSettlement \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMineSweeping/XUiPanelStart.lua b/Resources/Scripts/XUi/XUiMineSweeping/XUiPanelStart.lua new file mode 100644 index 00000000..41ff5325 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMineSweeping/XUiPanelStart.lua @@ -0,0 +1,58 @@ +local XUiPanelStart = XClass(nil, "XUiPanelStart") +local CSTextManagerGetText = CS.XTextManager.GetText +function XUiPanelStart:Ctor(ui, base) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Base = base + XTool.InitUiObject(self) + self:SetButtonCallBack() +end + +function XUiPanelStart:SetButtonCallBack() + self.BtnStart.CallBack = function() + self:OnBtnStartClick() + end +end + +function XUiPanelStart:OnBtnStartClick() + local chapterEntity = XDataCenter.MineSweepingManager.GetChapterEntityByIndex(self.CurCharterIndex) + local stageEntity = chapterEntity:GetCurStageEntity() + local curCoinCount = XDataCenter.MineSweepingManager.GetMineSweepingCoinItemCount() + + if curCoinCount < stageEntity:GetCostCoinNum() and not chapterEntity:IsFailed() then + XUiManager.TipText("MineSweepingNotCoinHint") + return + end + XDataCenter.MineSweepingManager.MineSweepingStartStageRequest(chapterEntity:GetChapterId(), stageEntity:GetStageId()) +end + +function XUiPanelStart:UpdatePanel(curCharterIndex) + self.CurCharterIndex = curCharterIndex + if curCharterIndex then + local chapterEntity = XDataCenter.MineSweepingManager.GetChapterEntityByIndex(curCharterIndex) + local stageEntity = chapterEntity:GetCurStageEntity() + local coinId = XDataCenter.MineSweepingManager.GetMineSweepingCoinItemId() + local coinIcon = XDataCenter.ItemManager.GetItemIcon(coinId) + self.TxtLevel.text = stageEntity:GetName() + self.TxtCount.text = stageEntity:GetCostCoinNum() + self.RawImage:SetRawImage(coinIcon) + self.PanelExpend.gameObject:SetActiveEx(not chapterEntity:IsFailed() and not chapterEntity:IsSweeping()) + end +end + +function XUiPanelStart:ShowPanel(IsShow) + if IsShow then + self.GameObject:SetActiveEx(true) + self.Base:PlayAnimationWithMask("PanelStartEnable") + else + if self.Base:IsChapterIndexChange() then + self.GameObject:SetActiveEx(false) + else + self.Base:PlayAnimationWithMask("PanelStartDisable",function () + self.GameObject:SetActiveEx(false) + end) + end + + end +end +return XUiPanelStart \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMiniGame/ComposeGame/XUiComposeGame.lua b/Resources/Scripts/XUi/XUiMiniGame/ComposeGame/XUiComposeGame.lua new file mode 100644 index 00000000..a1ddc5f0 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMiniGame/ComposeGame/XUiComposeGame.lua @@ -0,0 +1,191 @@ +-- 组合小游戏 +local XUiComposeGame = XLuaUiManager.Register(XLuaUi, "UiComposeGame") +local COMPOSE_ANIME_TIME = 500 +function XUiComposeGame:OnAwake() + XTool.InitUiObject(self) + self:InitButtons() +end + +function XUiComposeGame:OnStart(gameId) + self.Game = XDataCenter.ComposeGameManager.GetGameById(gameId) + local asset = XUiPanelAsset.New(self, self.PanelAsset, self.Game:GetCoinId()) + asset:RegisterJumpCallList({[1] = function() + XLuaUiManager.Open("UiTip", self.Game:GetCoinId()) + end}) + self:InitPanels() +end + +function XUiComposeGame:OnEnable() + self:SetTimer() + self:RefreshPanels() + if XDataCenter.ComposeGameManager.GetIsFirstIn(self.Game:GetGameId()) then + local storyId = self.Game:GetBeginStoryId() + if string.IsNilOrEmpty(storyId) then + XDataCenter.ComposeGameManager.DebugLog("已确认首次进入,但是取得StoryId失败!") + return + end + XDataCenter.MovieManager.PlayMovie(storyId) + end +end + +function XUiComposeGame:OnDisable() + self:StopTimer() +end +--================ +--设置页面计时器 +--================ +function XUiComposeGame:SetTimer() + self:StopTimer() + self:SetRefreshTime() + self.Timer = XScheduleManager.ScheduleForever(function() + self:SetRefreshTime() + self:SetGameTimer() + end, XScheduleManager.SECOND, 0) +end +--================ +--设置刷新时间 +--================ +function XUiComposeGame:SetRefreshTime() + local refreshTime = self.Game:GetRefreshTime() + local now = XTime.GetServerNowTimestamp() + local leftTime = refreshTime - now + if leftTime < 0 then leftTime = 0 end + local remainTime = XUiHelper.GetTime(leftTime, XUiHelper.TimeFormatType.DEFAULT) + self.RefreshPanel:SetRefreshTime(remainTime) +end +--================ +--设置活动倒计时 +--================ +function XUiComposeGame:SetGameTimer() + local endTimeSecond = self.Game:GetEndTime() + local now = XTime.GetServerNowTimestamp() + local leftTime = endTimeSecond - now + if leftTime <= 0 then + self:OnGameEnd() + end +end +--================ +--停止计时器 +--================ +function XUiComposeGame:StopTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end + if self.ComposeItemTimer then + if self.ComposingItem then self.ComposingItem:Empty() end + self.ComposingItem = nil + XScheduleManager.UnSchedule(self.ComposeItemTimer) + self.ComposeItemTimer = nil + end +end + +function XUiComposeGame:OnGetEvents() + return { XEventId.EVENT_COMPOSEGAME_RESET, + XEventId.EVENT_COMPOSEGAME_ITEM_COMPOSE, + XEventId.EVENT_COMPOSEGAME_BAGITEM_REFRESH, + XEventId.EVENT_COMPOSEGAME_SHOP_ITEM_REFRESH, + XEventId.EVENT_COMPOSEGAME_SHOP_REFRESH_TIME_CHANGE, + XEventId.EVENT_COMPOSEGAME_SCHEDULE_REFRESH, + XEventId.EVENT_COMPOSEGAME_TREASURE_GET, + } +end + +function XUiComposeGame:OnNotify(evt, ...) + local args = { ... } + if evt == XEventId.EVENT_COMPOSEGAME_RESET then + self:OnGameEnd() + elseif evt == XEventId.EVENT_COMPOSEGAME_ITEM_COMPOSE then + local item = args[1] + self.BagPanel:UpdateData() + self:ComposeItem(item) + elseif evt == XEventId.EVENT_COMPOSEGAME_BAGITEM_REFRESH then + self.BagPanel:UpdateData() + elseif evt == XEventId.EVENT_COMPOSEGAME_SHOP_ITEM_REFRESH then + self.ShopPanel:UpdateData() + elseif evt == XEventId.EVENT_COMPOSEGAME_SHOP_REFRESH_TIME_CHANGE then + self.RefreshPanel:RefreshRecruitNumber() + elseif evt == XEventId.EVENT_COMPOSEGAME_SCHEDULE_REFRESH then + self.SchedulePanel:OnScheduleRefresh() + elseif evt == XEventId.EVENT_COMPOSEGAME_TREASURE_GET then + self.SchedulePanel:RefreshBoxes() + end +end +--================ +--初始化按钮 +--================ +function XUiComposeGame:InitButtons() + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + self.BtnHelp.CallBack = function() self:OnBtnHelpClick() end +end +--================ +--返回按钮 +--================ +function XUiComposeGame:OnBtnBackClick() + self:Close() +end +--================ +--主界面按钮 +--================ +function XUiComposeGame:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end +--================ +--帮助按钮 +--================ +function XUiComposeGame:OnBtnHelpClick() + XUiManager.ShowHelpTip("ComposeGameHelp") +end + +function XUiComposeGame:InitPanels() + local XBag = require("XUi/XUiMiniGame/ComposeGame/XUiComposeGamePanelBag") + local XRefresh = require("XUi/XUiMiniGame/ComposeGame/XUiComposeGamePanelRefresh") + local XSchedule = require("XUi/XUiMiniGame/ComposeGame/XUiComposeGamePanelSchedule") + local XShop = require("XUi/XUiMiniGame/ComposeGame/XUiComposeGamePanelShop") + self.BagPanel = XBag.New(self, self.Game, self.PanelBagItemList) + self.RefreshPanel = XRefresh.New(self, self.Game, self.PanelRefresh) + self.SchedulePanel = XSchedule.New(self, self.Game, self.PanelGift) + self.ShopPanel = XShop.New(self, self.Game, self.PanelShop) + self.PanelCompose.gameObject:SetActiveEx(false) + self.GridTreasure.gameObject:SetActiveEx(false) + self.GridCommodity.gameObject:SetActiveEx(false) + self.GridBagItem.gameObject:SetActiveEx(false) +end + +function XUiComposeGame:RefreshPanels() + self.BagPanel:UpdateData() + self.ShopPanel:UpdateData() + self.SchedulePanel:UpdateData() + self.RefreshPanel:RefreshRecruitNumber() +end + +function XUiComposeGame:ComposeItem(item) + self.PanelCompose.gameObject:SetActiveEx(true) + self.RImgComposeItem:SetRawImage(item:GetBigIcon()) + self.ComposingItem = item + self.ComposeItemTimer = XScheduleManager.ScheduleOnce(function() + if self.PanelEffectTuowei then self.PanelEffectTuowei.gameObject:SetActiveEx(true) end + self.ComposeItemTimer = XScheduleManager.ScheduleOnce(function() + self:OnComposeEnd() + end, COMPOSE_ANIME_TIME) + end, COMPOSE_ANIME_TIME) +end + +function XUiComposeGame:OnComposeEnd() + self.ComposeItemTimer = nil + if self.PanelEffectTuowei then self.PanelEffectTuowei.gameObject:SetActiveEx(false) end + self.PanelCompose.gameObject:SetActiveEx(false) + if self.ComposingItem then self.ComposingItem:Empty() end + self.ComposingItem = nil + self.SchedulePanel:SetEffectActive(true) + self.BagPanel:UpdateData() +end + +function XUiComposeGame:OnGameEnd() + if self.IsReseting then return end + self.IsReseting = true + self:StopTimer() + XLuaUiManager.RunMain() + XUiManager.TipMsg(CS.XTextManager.GetText("ComposeGameEnd")) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMiniGame/ComposeGame/XUiComposeGameBagGrid.lua b/Resources/Scripts/XUi/XUiMiniGame/ComposeGame/XUiComposeGameBagGrid.lua new file mode 100644 index 00000000..8fff3ea0 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMiniGame/ComposeGame/XUiComposeGameBagGrid.lua @@ -0,0 +1,87 @@ +--组合小游戏背包动态列表组件 +local XUiComposeGameBagGrid = XClass(nil, "XUiComposeGameBagGrid") +--================ +--构造函数(动态列表组件初始化不在这里做) +--================ +function XUiComposeGameBagGrid:Ctor() + +end +--================ +--初始化 +--@param ui:组件的对象 +--================ +function XUiComposeGameBagGrid:Init(ui) + XTool.InitUiObjectByUi(self, ui) + self.PanelEffectCompose.gameObject:SetActiveEx(false) + self.PanelEffect.gameObject:SetActiveEx(false) + self:InitPanelStar() +end +--================ +--初始化星数面板 +--================ +function XUiComposeGameBagGrid:InitPanelStar() + local PanelStar = require("XUi/XUiMiniGame/ComposeGame/XUiComposeGameStarPanelLevel") + self.Star = PanelStar.New(self.PanelLevel) +end +--================ +--更新新内容数据 +--@param gridInfo:内容数据 +--================ +function XUiComposeGameBagGrid:RefreshData(gridInfo) + if not gridInfo then + return + end + self.GridInfo = gridInfo + self.Item = self.GridInfo:GetItem() + self:SetIsEmpty() + self:SetDisplayItem() + self:SetNewItemEffect() +end +--================ +--设置是否空背包 +--================ +function XUiComposeGameBagGrid:SetIsEmpty() + local isEmpty = self.Item:CheckIsEmpty() + self.Disable.gameObject:SetActiveEx(isEmpty) + self.Normal.gameObject:SetActiveEx(not isEmpty) +end +--================ +--设置展示道具 +--================ +function XUiComposeGameBagGrid:SetDisplayItem() + if not self.Item or (self.Item:CheckIsEmpty()) then return end + self.TxtName.text = self.Item:GetName() + self.RImgIcon:SetRawImage(self.Item:GetSmallIcon()) + self.Star:ShowStar(self.Item:GetStar()) +end +--================ +--设置新道具特效 +--================ +function XUiComposeGameBagGrid:SetNewItemEffect() + local noShowEffect = true + local finalItem = true + if not self.Item or self.Item:CheckIsEmpty() then + noShowEffect = true + finalItem = false + else + local isNew = XDataCenter.ComposeGameManager.GetItemIsNew(self.Item:GetGameId(), self.Item:GetId()) + noShowEffect = not isNew + finalItem = self.Item:GetIsFinalItem() + end + if noShowEffect then + self.PanelEffectCompose.gameObject:SetActiveEx(false) + self.PanelEffect.gameObject:SetActiveEx(false) + else + self.PanelEffectCompose.gameObject:SetActiveEx(finalItem) + self.PanelEffect.gameObject:SetActiveEx(not finalItem) + end +end +--================ +--被点击时事件 +--================ +function XUiComposeGameBagGrid:OnClick() + if not self.Item or (self.Item:CheckIsEmpty()) then return end + XLuaUiManager.Open("UiTip", self.Item:GetTempItemData()) +end + +return XUiComposeGameBagGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMiniGame/ComposeGame/XUiComposeGamePanelBag.lua b/Resources/Scripts/XUi/XUiMiniGame/ComposeGame/XUiComposeGamePanelBag.lua new file mode 100644 index 00000000..e72675ae --- /dev/null +++ b/Resources/Scripts/XUi/XUiMiniGame/ComposeGame/XUiComposeGamePanelBag.lua @@ -0,0 +1,43 @@ +--组合小游戏背包面板UI控件 +local XUiComposeGamePanelBag = XClass(nil, "XUiComposeGamePanelBag") +--================ +--构造函数 +--================ +function XUiComposeGamePanelBag:Ctor(rootUi, game, ui) + self.RootUi = rootUi + self.Game = game + XTool.InitUiObjectByUi(self, ui) + self:InitDynamicTable() +end +--================ +--初始化动态列表 +--================ +function XUiComposeGamePanelBag:InitDynamicTable() + local XGrid = require("XUi/XUiMiniGame/ComposeGame/XUiComposeGameBagGrid") + self.DynamicTable = XDynamicTableNormal.New(self.GameObject) + self.DynamicTable:SetProxy(XGrid) + self.DynamicTable:SetDelegate(self) +end + +--动态列表事件 +function XUiComposeGamePanelBag:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(grid.DynamicGrid.gameObject, self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + if self.BagList and self.BagList[index] then + grid:RefreshData(self.BagList[index]) + end + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + grid:OnClick() + end +end +--================ +--刷新控件 +--================ +function XUiComposeGamePanelBag:UpdateData() + self.BagList = self.Game:GetBagGrids() + self.DynamicTable:SetDataSource(self.BagList) + self.DynamicTable:ReloadDataASync(1) +end + +return XUiComposeGamePanelBag \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMiniGame/ComposeGame/XUiComposeGamePanelRefresh.lua b/Resources/Scripts/XUi/XUiMiniGame/ComposeGame/XUiComposeGamePanelRefresh.lua new file mode 100644 index 00000000..57eb992f --- /dev/null +++ b/Resources/Scripts/XUi/XUiMiniGame/ComposeGame/XUiComposeGamePanelRefresh.lua @@ -0,0 +1,46 @@ +--组合小游戏主界面刷新面板UI控件 +local XUiComposeGamePanelRefresh = XClass(nil, "XUiComposeGamePanelRefresh") +--================ +--构造函数 +--================ +function XUiComposeGamePanelRefresh:Ctor(rootUi, game, ui) + self.RootUi = rootUi + self.Game = game + XTool.InitUiObjectByUi(self, ui) + self.BtnRefresh.CallBack = function() self:OnClick() end +end +--================ +--设置刷新时间文本 +--================ +function XUiComposeGamePanelRefresh:SetRefreshTime(time) + self.TxtTime.text = string.format("%s%s", time, CS.XTextManager.GetText("ComposeShopRefreshCountDown")) +end +--================ +--设置招募次数文本 +--================ +function XUiComposeGamePanelRefresh:RefreshRecruitNumber() + local canRefresh = self.Game:CheckCanRefresh() + local canBuy = self.Game:CheckCanBuyRefresh() + self.TxtNumber.gameObject:SetActiveEx(canRefresh or not canBuy) + self.TxtBuy.gameObject:SetActiveEx((not canRefresh) and canBuy) + if canRefresh or not canBuy then + self.TxtNumber.text = self.Game:GetRefreshStr() + else + local price = self.Game:GetRefreshPrice() + local currentCoin = XDataCenter.ItemManager.GetCoinsNum() + if currentCoin and currentCoin < price then + self.TxtBuy.text = CS.XTextManager.GetText("ComposeGameNoCoinBuyDraw", price) + else + self.TxtBuy.text = price + end + end + self.TxtTime.gameObject:SetActiveEx(not self.Game:GetRefreshTimeIsMax()) +end +--================ +--点击刷新按钮时 +--================ +function XUiComposeGamePanelRefresh:OnClick() + XDataCenter.ComposeGameManager.RefreshShop(self.Game:GetGameId()) +end + +return XUiComposeGamePanelRefresh \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMiniGame/ComposeGame/XUiComposeGamePanelSchedule.lua b/Resources/Scripts/XUi/XUiMiniGame/ComposeGame/XUiComposeGamePanelSchedule.lua new file mode 100644 index 00000000..02540ee0 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMiniGame/ComposeGame/XUiComposeGamePanelSchedule.lua @@ -0,0 +1,156 @@ +--组合小游戏进度UI控件 +local XUiComposeGamePanelSchedule = XClass(nil, "XUiComposeGamePanelSchedule") +local XUiComposeGameTreasureBox = require("XUi/XUiMiniGame/ComposeGame/XUiComposeGameTreasureBox") +--动画时间 +local TWEEN_TIME = 2 +--================ +--构造函数 +--================ +function XUiComposeGamePanelSchedule:Ctor(rootUi, game, ui) + self.RootUi = rootUi + self.Game = game + XTool.InitUiObjectByUi(self, ui) + self:RefreshSchedule() + self:InitTreasureBoxes() + self:InitPanelEffect() +end +--================ +--刷新进度 +--================ +function XUiComposeGamePanelSchedule:RefreshSchedule() + self.MaxSchedule = self.Game:GetMaxSchedule() + self.CurrentSchedule = self.Game:GetCurrentSchedule() + self.TxtTotalProgress.text = string.format("/%d", self.MaxSchedule) + self.TxtProgress.text = self.CurrentSchedule + self:SetScheduleFillAmount(self.CurrentSchedule) +end +--================ +--初始化进度宝箱 +--================ +function XUiComposeGamePanelSchedule:InitTreasureBoxes() + self.TreasureBoxes = {} + table.insert(self.TreasureBoxes, XUiComposeGameTreasureBox.New(self.GridTreasure, self.Game:GetGameId())) + self:RefreshBoxes() +end +--================ +--初始化UI特效 +--================ +function XUiComposeGamePanelSchedule:InitPanelEffect() + self.PanelEffect.gameObject:SetActiveEx(false) +end +--================ +--刷新整个控件 +--================ +function XUiComposeGamePanelSchedule:UpdateData() + self:RefreshSchedule() + self:RefreshBoxes() +end +--================ +--接受到进度变化事件时 +--================ +function XUiComposeGamePanelSchedule:OnScheduleRefresh() + self:RefreshNewSchedule(self.Game:GetCurrentSchedule()) + self:RefreshBoxes() +end +--================ +--刷新进度宝箱 +--================ +function XUiComposeGamePanelSchedule:RefreshBoxes() + self.TreasureBoxesData = self.Game:GetTreasureBoxes() + for i = 1, #self.TreasureBoxesData do + if not self.TreasureBoxes[i] then + local box = CS.UnityEngine.GameObject.Instantiate(self.GridTreasure) + box.transform:SetParent(self.GiftContent.transform, false) + self.TreasureBoxes[i] = XUiComposeGameTreasureBox.New(box, self.Game:GetGameId()) + end + self.TreasureBoxes[i].GameObject:SetActiveEx(true) + self.TreasureBoxes[i]:RefreshData(self.TreasureBoxesData[i]) + end +end +--================ +--刷新新的进度 +--================ +function XUiComposeGamePanelSchedule:RefreshNewSchedule(targetSchedule) + if not targetSchedule or targetSchedule == self.CurrentSchedule then return end + local isAdd = targetSchedule > self.CurrentSchedule + if isAdd then + self.TargetSchedule = targetSchedule + self:TweenScheduleFillAmount() + else + self:SetScheduleFillAmount(targetSchedule) + end +end +--================ +--设置进度条的图片进度 +--================ +function XUiComposeGamePanelSchedule:SetScheduleFillAmount(targetSchedule) + if not self.ScheduleGroup then self:InitScheduleGroup() end + local targetPercent = self:GetTargetSchedulePercent(targetSchedule) + self.ImgDaylyActiveProgress.fillAmount = targetPercent +end +--================ +--初始化进度管理数据 +--================ +function XUiComposeGamePanelSchedule:InitScheduleGroup() + self.ScheduleGroup = {} + local Schedules = self.Game:GetSchedule() + self.ScheduleParagraph = 1 / #Schedules + for i = 1, #Schedules do + local scheduleGroup = { + Schedule = Schedules[i], + FillAmountPercent = i * self.ScheduleParagraph, + SchedulePercentValue = self.ScheduleParagraph / (Schedules[i] - (Schedules[i - 1] or 0)) + } + table.insert(self.ScheduleGroup, scheduleGroup) + end +end +--================ +--根据目标进度值获取现在的进度条百分比 +--@param targetSchedule:目标进度值 +--================ +function XUiComposeGamePanelSchedule:GetTargetSchedulePercent(targetSchedule) + for i = 1, #self.ScheduleGroup do + if targetSchedule <= self.ScheduleGroup[i].Schedule then + local basePercent = self.ScheduleGroup[i - 1] and self.ScheduleGroup[i - 1].FillAmountPercent or 0 + local baseSchedule = self.ScheduleGroup[i - 1] and self.ScheduleGroup[i - 1].Schedule or 0 + return basePercent + ((targetSchedule - baseSchedule) * self.ScheduleGroup[i].SchedulePercentValue) + end + end + return 1 +end +--================ +--设置进度条填充图片Tween动画 +--================ +function XUiComposeGamePanelSchedule:TweenScheduleFillAmount() + local delta = self.TargetSchedule - self.CurrentSchedule + XLuaUiManager.SetMask(true) + XUiHelper.Tween(TWEEN_TIME, function(f) + if XTool.UObjIsNil(self.Transform) then + return + end + -- 现进度 + local currentSchedule = self.CurrentSchedule + math.floor(f * delta) + self.TxtProgress.text = currentSchedule + if currentSchedule <= self.MaxSchedule then + self:SetScheduleFillAmount(currentSchedule) + end + end, function() + if XTool.UObjIsNil(self.Transform) then + return + end + self.CurrentSchedule = self.TargetSchedule + self.TxtProgress.text = self.CurrentSchedule + self:SetScheduleFillAmount(self.CurrentSchedule) + self:SetEffectActive(false) + XLuaUiManager.SetMask(false) + end) +end +--================ +--设置Tween时特效是否有效 +--@param effectActive:是否有效 +--================ +function XUiComposeGamePanelSchedule:SetEffectActive(effectActive) + self.PanelEffect.gameObject:SetActiveEx(effectActive) +end + +return XUiComposeGamePanelSchedule \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMiniGame/ComposeGame/XUiComposeGamePanelShop.lua b/Resources/Scripts/XUi/XUiMiniGame/ComposeGame/XUiComposeGamePanelShop.lua new file mode 100644 index 00000000..3c7a2dcc --- /dev/null +++ b/Resources/Scripts/XUi/XUiMiniGame/ComposeGame/XUiComposeGamePanelShop.lua @@ -0,0 +1,42 @@ +--组合小游戏商店UI控件 +local XUiComposeGamePanelShop = XClass(nil, "XUiComposeGamePanelShop") +--================ +--构造函数 +--================ +function XUiComposeGamePanelShop:Ctor(rootUi, game, ui) + self.RootUi = rootUi + self.Game = game + XTool.InitUiObjectByUi(self, ui) + self:InitDynamicTable() +end +--================ +--初始化动态列表 +--================ +function XUiComposeGamePanelShop:InitDynamicTable() + local XGrid = require("XUi/XUiMiniGame/ComposeGame/XUiComposeGameShopGrid") + self.DynamicTable = XDynamicTableNormal.New(self.GameObject) + self.DynamicTable:SetProxy(XGrid) + self.DynamicTable:SetDelegate(self) +end + +--动态列表事件 +function XUiComposeGamePanelShop:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(grid.DynamicGrid.gameObject, self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + if self.ShopList and self.ShopList[index] then + grid:RefreshData(self.ShopList[index]) + end + --elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + --grid:OnClick() + end +end +--================ +--刷新列表 +--================ +function XUiComposeGamePanelShop:UpdateData() + self.ShopList = self.Game:GetShopGrids() + self.DynamicTable:SetDataSource(self.ShopList) + self.DynamicTable:ReloadDataASync(1) +end +return XUiComposeGamePanelShop \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMiniGame/ComposeGame/XUiComposeGameShopGrid.lua b/Resources/Scripts/XUi/XUiMiniGame/ComposeGame/XUiComposeGameShopGrid.lua new file mode 100644 index 00000000..55dcf4b7 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMiniGame/ComposeGame/XUiComposeGameShopGrid.lua @@ -0,0 +1,67 @@ +--组合小游戏商店动态列表内容组件 +local XUiComposeGameShopGrid = XClass(nil, "XUiComposeGameShopGrid") +--================ +--构造函数(动态列表组件初始化不在这里做) +--================ +function XUiComposeGameShopGrid:Ctor() + +end +--================ +--初始化 +--================ +function XUiComposeGameShopGrid:Init(ui) + XTool.InitUiObjectByUi(self, ui) + self:InitPanelStar() + self.BtnItem.CallBack = function() self:OnClick() end +end + +function XUiComposeGameShopGrid:InitPanelStar() + local PanelStar = require("XUi/XUiMiniGame/ComposeGame/XUiComposeGameStarPanelLevel") + self.Star = PanelStar.New(self.PanelLevel) +end + +function XUiComposeGameShopGrid:RefreshData(gridInfo) + if not gridInfo then + return + end + self.Grid = gridInfo + self.Item = self.Grid:GetItem() + local gameId = self.Item:GetGameId() + self.Game = XDataCenter.ComposeGameManager.GetGameById(gameId) + self:SetIsSell() + self:SetDisplayItem() + self:SetIsLevelUp() +end + +function XUiComposeGameShopGrid:SetIsSell() + local isSell = self.Grid:CheckIsSell() + if isSell then + self.BtnItem:SetButtonState(CS.UiButtonState.Disable) + else + self.BtnItem:SetButtonState(CS.UiButtonState.Normal) + end +end + +function XUiComposeGameShopGrid:SetDisplayItem() + if not self.Item or (self.Item:CheckIsEmpty()) then return end + self.TxtName.text = self.Item:GetName() + self.BtnItem:SetName(self.Item:GetCostCoinNum()) + self.RImgShopItemIcon:SetRawImage(self.Item:GetBigIcon()) + self.RImgCostItemIcon:SetRawImage(XDataCenter.ItemManager.GetItemIcon(self.Game:GetCoinId())) + self.Star:ShowStar(self.Item:GetStar()) +end + +function XUiComposeGameShopGrid:SetIsLevelUp() + self.ImgLevel.gameObject:SetActiveEx(self.Item:CheckIsLevelUp()) +end + +function XUiComposeGameShopGrid:OnClick() + if not self.Grid then return end + if self.Grid:CheckIsSell() then + XUiManager.TipMsg(CS.XTextManager.GetText("ComposeGameShopItemIsSelled")) + return + end + XDataCenter.ComposeGameManager.BuyItem(self.Grid) +end + +return XUiComposeGameShopGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMiniGame/ComposeGame/XUiComposeGameStarPanelLevel.lua b/Resources/Scripts/XUi/XUiMiniGame/ComposeGame/XUiComposeGameStarPanelLevel.lua new file mode 100644 index 00000000..5a9e7d3e --- /dev/null +++ b/Resources/Scripts/XUi/XUiMiniGame/ComposeGame/XUiComposeGameStarPanelLevel.lua @@ -0,0 +1,36 @@ +--组合小游戏星级面板UI控件 +local XUiComposeGameStarPanelLevel = XClass(nil, "XUiComposeGameStarPanelLevel") +--================ +--构造函数 +--@param ui:星级面板GameObject +--================ +function XUiComposeGameStarPanelLevel:Ctor(ui) + XTool.InitUiObjectByUi(self, ui) + self.Stars = {} + table.insert(self.Stars, self.StarLevel) +end +--================ +--显示指定的星数 +--@param starNum:星数 +--================ +function XUiComposeGameStarPanelLevel:ShowStar(starNum) + self:HideStars() + for i = 1, starNum do + if not self.Stars[i] then + local ui = CS.UnityEngine.GameObject.Instantiate(self.StarLevel) + ui.transform:SetParent(self.Transform, false) + self.Stars[i] = ui + end + self.Stars[i].gameObject:SetActiveEx(true) + end +end +--================ +--隐藏所有星 +--================ +function XUiComposeGameStarPanelLevel:HideStars() + for _, star in pairs(self.Stars) do + star.gameObject:SetActiveEx(false) + end +end + +return XUiComposeGameStarPanelLevel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMiniGame/ComposeGame/XUiComposeGameTreasureBox.lua b/Resources/Scripts/XUi/XUiMiniGame/ComposeGame/XUiComposeGameTreasureBox.lua new file mode 100644 index 00000000..a907c8f1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMiniGame/ComposeGame/XUiComposeGameTreasureBox.lua @@ -0,0 +1,60 @@ +-- 组合小游戏进度宝箱控件 +local XUiComposeGameTreasureBox = XClass(nil, "XUiComposeGameTreasureBox") +--================ +--构造函数 +--@param ui:星级面板GameObject +--@gameId gameId:小游戏GameId ComposeGame表ID +--================ +function XUiComposeGameTreasureBox:Ctor(ui, gameId) + self.GameId = gameId + XTool.InitUiObjectByUi(self, ui) + self:InitUIs() +end +--================ +--初始化UI的基础组件 +--================ +function XUiComposeGameTreasureBox:InitUIs() + self.ImgReceived.gameObject:SetActiveEx(false) + self.PanelEffect.gameObject:SetActiveEx(false) + self.BtnTreasureBox.CallBack = function() self:OnClick() end +end +--================ +--更新控件数据 +--@param treasureBox:进度宝箱数据 +--================ +function XUiComposeGameTreasureBox:RefreshData(treasureBox) + self.Box = treasureBox + self.TxtValue.text = self.Box:GetSchedule() + self:SetIsReceive() + self:SetCanReceive() +end +--================ +--设置已领取UI状态 +--================ +function XUiComposeGameTreasureBox:SetIsReceive() + self.ImgReceived.gameObject:SetActiveEx(self.Box:CheckIsReceive()) +end +--================ +--设置宝箱领取状态UI +--================ +function XUiComposeGameTreasureBox:SetCanReceive() + self.PanelEffect.gameObject:SetActiveEx(self.Box:CheckCanReceive()) +end +--================ +--点击事件 +--================ +function XUiComposeGameTreasureBox:OnClick() + if not self.Box then return end + if self.Box:CheckCanReceive() then + XDataCenter.ComposeGameManager.GetReward(self.GameId, self.Box) + else + local rewardId = self.Box:GetRewardId() + if rewardId and rewardId > 0 then + local data = XRewardManager.GetRewardList(rewardId) + if not data then return end + XUiManager.OpenUiTipReward(data) + end + end +end + +return XUiComposeGameTreasureBox \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessFinger.lua b/Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessFinger.lua new file mode 100644 index 00000000..c8244257 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessFinger.lua @@ -0,0 +1,30 @@ +-- 出拳展示组件 +local XUiFingerGuessFinger = XClass(nil, "XUiFingerGuessFinger") +local INITIAL_NUM_TEXT = "?" +function XUiFingerGuessFinger:Ctor(gameObject, fingerId) + XTool.InitUiObjectByUi(self, gameObject) + self:InitFinger(fingerId) +end +--================ +--初始化面板 +--================ +function XUiFingerGuessFinger:InitFinger(fingerId) + self:RefreshFinger(fingerId, INITIAL_NUM_TEXT) +end +--================ +--刷新面板 +--================ +function XUiFingerGuessFinger:RefreshFinger(fingerId, text) + if self.FingerId ~= fingerId then + self.FingerId = fingerId + local config = XFingerGuessingConfig.GetFingerConfigById(fingerId) + self.ImgFingerIcon:SetSprite(config.Icon) + end + if type(text) ~= "number" then + self.TxtNum.text = text + else + self.TxtNum.text = "" .. text .. "" + end +end + +return XUiFingerGuessFinger \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessGamePanel.lua b/Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessGamePanel.lua new file mode 100644 index 00000000..22409776 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessGamePanel.lua @@ -0,0 +1,137 @@ +-- 猜拳小游戏游戏进行面板控件 +local XUiFingerGuessGamePanel = XClass(nil, "XUiFingerGuessGamePanel") +--================ +--构造函数 +--================ +function XUiFingerGuessGamePanel:Ctor(uiGameObject, rootUi) + self.RootUi = rootUi + XTool.InitUiObjectByUi(self, uiGameObject) + self:InitPanel() +end +--================ +--初始化面板 +--================ +function XUiFingerGuessGamePanel:InitPanel() + self:InitPanelPK() + self.PanelSelectFinger.gameObject:SetActiveEx(true) + self:InitFingerBtns() + self.ObjSelectRule.gameObject:SetActiveEx(true) + if self.TxtTurn then self.TxtTurn.text = CS.XTextManager.GetText("FingerGuessingTurnStr", self.RootUi.Stage:GetCurrentRound(), self.RootUi.Stage:GetRoundNum()) end +end +--================ +--初始化PK面板 +--================ +function XUiFingerGuessGamePanel:InitPanelPK() + local PanelPK = require("XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessPKPanel") + self.PKPanel = PanelPK.New(self.PanelPK, self.RootUi) + self.PKPanel.GameObject:SetActiveEx(false) +end +--================ +--初始化出拳按钮 +--================ +function XUiFingerGuessGamePanel:InitFingerBtns() + self.BtnRock.CallBack = function() self:OnClickBtnRock() end + self.BtnScissors.CallBack = function() self:OnClickBtnScissors() end + self.BtnPaper.CallBack = function() self:OnClickBtnPaper() end +end +--================ +--石头按钮 +--================ +function XUiFingerGuessGamePanel:OnClickBtnRock() + if self.IsPlayingFinger then return end + self.IsPlayingFinger = true + self:SavePreRound() + self.RootUi:PlayAnimation("ChooseStone",function() + XDataCenter.FingerGuessingManager.PlayFinger(XDataCenter.FingerGuessingManager.FINGER_TYPE.Rock) + end) +end +--================ +--剪刀按钮 +--================ +function XUiFingerGuessGamePanel:OnClickBtnScissors() + if self.IsPlayingFinger then return end + self.IsPlayingFinger = true + self:SavePreRound() + self.RootUi:PlayAnimation("ChooseScissors", function() + XDataCenter.FingerGuessingManager.PlayFinger(XDataCenter.FingerGuessingManager.FINGER_TYPE.Scissors) + end) +end +--================ +--布按钮 +--================ +function XUiFingerGuessGamePanel:OnClickBtnPaper() + if self.IsPlayingFinger then return end + self.IsPlayingFinger = true + self:SavePreRound() + self.RootUi:PlayAnimation("ChooseCloth",function() + XDataCenter.FingerGuessingManager.PlayFinger(XDataCenter.FingerGuessingManager.FINGER_TYPE.Paper) + end) +end + +function XUiFingerGuessGamePanel:SavePreRound() + self.PreRound = self.RootUi.Stage:GetCurrentRound() + self.PreActionId = self.RootUi.Stage:GetActionByRound(self.PreRound) + --self.PreActionImg = self.RootUi.Stage:GetActionImg() +end + +function XUiFingerGuessGamePanel:OnFingerPlay(fingerId, roundResult, isEnd) + self:HideSelectFinger() + self.PKPanel:ShowPanel(fingerId, self.PreRound, self.PreActionId, roundResult, isEnd, function() self:OnShowPKFinished(isEnd) end) +end + +function XUiFingerGuessGamePanel:HideSelectFinger() + self.ObjSelectRule.gameObject:SetActiveEx(false) + self.PanelSelectFinger.gameObject:SetActiveEx(false) +end + +function XUiFingerGuessGamePanel:OnShowPKFinished(isEnd) + if not isEnd then + self:ShowSelectFinger() + else + XLuaUiManager.Open("UiFingerGuessingResult", self.RootUi.Stage, function(result) self:OnShowResultEnd(result) end) + end + self.IsPlayingFinger = false +end + +function XUiFingerGuessGamePanel:ShowSelectFinger() + self.ObjSelectRule.gameObject:SetActiveEx(true) + self.TxtTurn.gameObject:SetActiveEx(true) + self.PanelSelectFinger.gameObject:SetActiveEx(true) + self:RefreshSelectFinger() +end + +function XUiFingerGuessGamePanel:RefreshSelectFinger() + self.RootUi:OnRefreshRound() + self.RootUi:PlayAnimation("GridEnable",function() + if self.TxtTurn then self.TxtTurn.text = CS.XTextManager.GetText("FingerGuessingTurnStr", self.RootUi.Stage:GetCurrentRound(), self.RootUi.Stage:GetRoundNum()) end + end) +end + +function XUiFingerGuessGamePanel:OnShowResultEnd(result) + XLuaUiManager.PopThenOpen("UiFingerGuessingSelectStage", result) +end + +function XUiFingerGuessGamePanel:OnEnable() + self:AddEventListeners() +end + +function XUiFingerGuessGamePanel:OnDisable() + self:RemoveEventListeners() +end +--================ +--注册事件 +--================ +function XUiFingerGuessGamePanel:AddEventListeners() + if self.EventAdded then return end + self.EventAdded = true + XEventManager.AddEventListener(XEventId.EVENT_FINGER_GUESS_PLAY_FINGER, self.OnFingerPlay, self) +end +--================ +--注销事件 +--================ +function XUiFingerGuessGamePanel:RemoveEventListeners() + if not self.EventAdded then return end + XEventManager.RemoveEventListener(XEventId.EVENT_FINGER_GUESS_PLAY_FINGER, self.OnFingerPlay, self) + self.EventAdded = false +end +return XUiFingerGuessGamePanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessPKPanel.lua b/Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessPKPanel.lua new file mode 100644 index 00000000..d15976cc --- /dev/null +++ b/Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessPKPanel.lua @@ -0,0 +1,150 @@ +-- 猜拳小游戏PK面板控件 +local XUiFingerGuessPKPanel = XClass(nil, "XUiFingerGuessPKPanel") +local RESULT_TEXT = { + WIN = "FingerGuessingResultWin", + LOSE = "FingerGuessingResultLose", + DRAW = "FingerGuessingResultDraw" + } +local SHOW_TYPE = { + Hero = "Hero", + Enemy = "Enemy", + } +local RESULT_TYPE +--================ +--构造函数 +--================ +function XUiFingerGuessPKPanel:Ctor(uiGameObject, rootUi) + self.RootUi = rootUi + XTool.InitUiObjectByUi(self, uiGameObject) + self:InitPanel() +end +--================ +--初始化面板 +--================ +function XUiFingerGuessPKPanel:InitPanel() + self.ObjNextRound.gameObject:SetActiveEx(false) + if not RESULT_TYPE then RESULT_TYPE = XDataCenter.FingerGuessingManager.DUEL_RESULT end + self:SetResult(RESULT_TEXT.DRAW, SHOW_TYPE.Hero) + self:SetResult(RESULT_TEXT.DRAW, SHOW_TYPE.Enemy) +end +--================ +--出拳 +--@param heroFingerId:我方出拳ID +--================ +function XUiFingerGuessPKPanel:PlayFinger(heroFingerId, enemyFingerId, resultType) + local heroIcon + local enemyIcon + if resultType == RESULT_TYPE.Win then + local fingerConfig = XFingerGuessingConfig.GetFingerConfigById(heroFingerId) + heroIcon = fingerConfig.Icon + enemyIcon = CS.XGame.ClientConfig:GetString("FingerGuessingLoseIcon" .. enemyFingerId) + elseif resultType == RESULT_TYPE.Draw then + local heroFingerConfig = XFingerGuessingConfig.GetFingerConfigById(heroFingerId) + heroIcon = heroFingerConfig.Icon + local enemyFingerConfig = XFingerGuessingConfig.GetFingerConfigById(enemyFingerId) + enemyIcon = enemyFingerConfig.Icon + else + heroIcon = CS.XGame.ClientConfig:GetString("FingerGuessingLoseIcon" .. heroFingerId) + local fingerConfig = XFingerGuessingConfig.GetFingerConfigById(enemyFingerId) + enemyIcon = fingerConfig.Icon + end + self.ImgHeroFinger:SetSprite(heroIcon) + self.ImgEnemyFinger:SetSprite(enemyIcon) +end +--================ +--设置结果文本 +--================ +function XUiFingerGuessPKPanel:SetResult(resultType, showType) + local name = "Txt" .. tostring(showType) .. "Result" + local component = self[name] + if component then + component.text = CS.XTextManager.GetText(resultType) + end +end + +function XUiFingerGuessPKPanel:SetTurnText(turn) + self.TxtTurnText.text = CS.XTextManager.GetText("FingerGuessingRoundStr", string.format("%02d", turn)) +end + +function XUiFingerGuessPKPanel:ShowPanel(fingerId, showRound, enemyFingerId, roundResult, isEnd, onFinishCallBack) + self.GameObject:SetActiveEx(true) + self.RootUi:PlayAnimation("PanelPKEnable") + self:SetMask() + self:SetTurnText(showRound) + if roundResult == RESULT_TYPE.Win then + self:SetResult(RESULT_TEXT.WIN, SHOW_TYPE.Hero) + self:SetResult(RESULT_TEXT.LOSE, SHOW_TYPE.Enemy) + self:PlayFinger(fingerId, enemyFingerId, roundResult) + elseif roundResult == RESULT_TYPE.Draw then + self:SetResult(RESULT_TEXT.DRAW, SHOW_TYPE.Hero) + self:SetResult(RESULT_TEXT.DRAW, SHOW_TYPE.Enemy) + self:PlayFinger(fingerId, enemyFingerId, roundResult) + else + self:SetResult(RESULT_TEXT.LOSE, SHOW_TYPE.Hero) + self:SetResult(RESULT_TEXT.WIN, SHOW_TYPE.Enemy) + self:PlayFinger(fingerId, enemyFingerId, roundResult) + end + local nextRoundFunc = function() + XScheduleManager.ScheduleOnce(function() + if XTool.UObjIsNil(self.Transform) then + return + end + if not isEnd then + self.ObjNextRound.gameObject:SetActiveEx(true) + self.RootUi:PlayAnimation("NextEnable") + end + XScheduleManager.ScheduleOnce(function() + if XTool.UObjIsNil(self.Transform) then + return + end + self.GameObject:SetActiveEx(false) + self.ObjNextRound.gameObject:SetActiveEx(false) + self.TxtHeroResult.gameObject:SetActiveEx(false) + self.TxtEnemyResult.gameObject:SetActiveEx(false) + if isEnd then + if self.FinishCallBack then self.FinishCallBack() end + self:HideMask() + else + XScheduleManager.ScheduleOnce(function() + if XTool.UObjIsNil(self.Transform) then + return + end + if self.FinishCallBack then self.FinishCallBack() end + self:HideMask() + end, 500) + end + end, 1250) + end, 0) + end + XScheduleManager.ScheduleOnce(function() + if XTool.UObjIsNil(self.Transform) then + return + end + self.TxtHeroResult.gameObject:SetActiveEx(true) + self.TxtEnemyResult.gameObject:SetActiveEx(true) + self.FinishCallBack = onFinishCallBack + self.RootUi:PlayAnimation("WinFailEnable") + XScheduleManager.ScheduleOnce(function() + if XTool.UObjIsNil(self.Transform) then + return + end + nextRoundFunc() + end, 500) + end, + 500 + ) +end + +function XUiFingerGuessPKPanel:SetMask() + if self.HaveMask then return end + self.HaveMask = true + XLuaUiManager.SetMask(true) +end + +function XUiFingerGuessPKPanel:HideMask() + if not self.HaveMask then return end + XLuaUiManager.SetMask(false) + self.HaveMask = false +end + +return XUiFingerGuessPKPanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessResult.lua b/Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessResult.lua new file mode 100644 index 00000000..a5cd3ba8 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessResult.lua @@ -0,0 +1,52 @@ +-- 猜拳小游戏得分结算界面 +local XUiFingerGuessResult = XLuaUiManager.Register(XLuaUi, "UiFingerGuessingResult") +local SCORE_TYPE = { + Hero = "Hero", + Enemy = "Enemy", +} +function XUiFingerGuessResult:OnAwake() + XTool.InitUiObject(self) + self.GameController = XDataCenter.FingerGuessingManager.GetGameController() +end + +function XUiFingerGuessResult:OnStart(stage, onCloseCallBack) + self.Stage = stage + self.CallBack = onCloseCallBack + self:InitPanel() +end + +function XUiFingerGuessResult:InitPanel() + self.BtnClose.CallBack = function() self:OnClickBtnClose() end + self:SetScore(self.Stage:GetHeroScore(), SCORE_TYPE.Hero) + self:SetScore(self.Stage:GetEnemyScore(), SCORE_TYPE.Enemy) + self.Result = self.Stage:GetHeroScore() >= self.Stage:GetEnemyScore() + if self.TxtResultTalk then self.TxtResultTalk.text = self.Result and self.Stage:GetWinTalk() or self.Stage:GetLoseTalk() end + if self.ObjWin then self.ObjWin.gameObject:SetActiveEx(self.Result) end + if self.ObjLose then self.ObjLose.gameObject:SetActiveEx(not self.Result) end + if self.ImgRole and self.Result then + self.ImgRole:SetSprite(self.GameController:GetPlayerPortraits()) + else + self.ImgRole:SetSprite(self.Stage:GetRobotPortraits()) + end +end +--================ +--设置分数 +--================ +function XUiFingerGuessResult:SetScore(score, setType) + local name = "Txt" .. tostring(setType) .. "Score" + local component = self[name] + if component then + component.text = CS.XTextManager.GetText("FingerGuessing" .. setType .. "ScoreStr", score) + end +end +--================ +--点击关闭按钮 +--================ +function XUiFingerGuessResult:OnClickBtnClose() + self:Close() + if self.CallBack then + local callBack = self.CallBack + self.CallBack = nil + callBack(self.Result) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessSSExplainPanel.lua b/Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessSSExplainPanel.lua new file mode 100644 index 00000000..1f01ad77 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessSSExplainPanel.lua @@ -0,0 +1,47 @@ +-- 选择关卡界面规则解说面板 +local XUiFingerGuessSSExplainPanel = XClass(nil, "XUiFingerGuessSSExplainPanel") +local CHINESE_NUMBER = { + [1] = "one", + [2] = "two", + [3] = "three", + [4] = "four", + [5] = "five", + [6] = "six", + [7] = "seven", + [8] = "eight", + [9] = "nine", + [10] = "ten", + [11] = "eleven", + [12] = "twelve" + } +local INITIAL_TEXT = "Text initial complete." +--================ +--构造函数 +--================ +function XUiFingerGuessSSExplainPanel:Ctor(gameObject, rootUi) + self.RootUi = rootUi + XTool.InitUiObjectByUi(self, gameObject) + self:InitPanel() +end +--================ +--初始化面板 +--================ +function XUiFingerGuessSSExplainPanel:InitPanel() + self:SetTxtTitle(0, 0) + self.TxtDescription.text = INITIAL_TEXT +end +--================ +--选择关卡时 +--================ +function XUiFingerGuessSSExplainPanel:OnStageSelected() + self:SetTxtTitle(self.RootUi.StageSelected:GetRoundNum(), self.RootUi.StageSelected:GetWinScore()) + self.TxtDescription.text = self.RootUi.StageSelected:GetDescription() +end +--================ +--设置规则Title +--================ +function XUiFingerGuessSSExplainPanel:SetTxtTitle(total, winPoint) + self.TxtTitle.text = CS.XTextManager.GetText("FingerGuessingRuleTitle", CHINESE_NUMBER[total] or total, CHINESE_NUMBER[winPoint] or winPoint) +end + +return XUiFingerGuessSSExplainPanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessSSLevelPanel.lua b/Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessSSLevelPanel.lua new file mode 100644 index 00000000..974a5495 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessSSLevelPanel.lua @@ -0,0 +1,96 @@ +-- 选择关卡界面关卡面板 +local XUiFingerGuessSSLevelPanel = XClass(nil, "XUiFingerGuessSSLevelPanel") + +function XUiFingerGuessSSLevelPanel:Ctor(gameObject, rootUi) + self.RootUi = rootUi + XTool.InitUiObjectByUi(self, gameObject) + self:InitPanel() +end +--================ +--初始化面板 +--================ +function XUiFingerGuessSSLevelPanel:InitPanel() + self.GridStage.gameObject:SetActiveEx(false) + self:InitStages() + self:RefreshProgress() + XUiHelper.RegisterClickEvent(self, self.RImgTreasure, self.OnClickTask, self) +end +--================ +--显示面板时 +--================ +function XUiFingerGuessSSLevelPanel:OnEnable() + self:AddEventListeners() + self:RefreshProgress() +end +--================ +--隐藏面板时 +--================ +function XUiFingerGuessSSLevelPanel:OnDisable() + self:RemoveEventListeners() +end +--================ +--初始化关卡进度 +--================ +function XUiFingerGuessSSLevelPanel:SetTxtStageProgress(current, total) + self.TxtStageProgress.text = string.format(tostring(current) .. "/" .. tostring(total)) +end +--================ +--初始化关卡 +--================ +function XUiFingerGuessSSLevelPanel:InitStages() + local StageScript = require("XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessStage") + self.Stages = {} + local lastStage + local isLast = false + local stageList = self.RootUi.GameController:GetAllStages() + for _, stage in pairs(stageList) do + local ui = CS.UnityEngine.GameObject.Instantiate(self.GridStage) + ui.transform:SetParent(self.PanelStage.transform, false) + ui.gameObject:SetActiveEx(true) + self.Stages[stage:GetId()] = StageScript.New(ui, stage, self.RootUi) + if not isLast then lastStage = self.Stages[stage:GetId()] end + if not stage:GetIsClear() then + isLast = true + end + end + lastStage:OnClickStageSelect() +end +--================ +--刷新关卡列表 +--================ +function XUiFingerGuessSSLevelPanel:RefreshStages() + for _, stage in pairs(self.Stages) do + stage:Refresh() + end + self:RefreshProgress() +end + +function XUiFingerGuessSSLevelPanel:RefreshProgress() + self.ImgRedProgress.gameObject:SetActiveEx(XDataCenter.TaskManager.GetFingerGuessingHaveAchievedTask()) + local achived, total = XDataCenter.TaskManager.GetFingerGuessingTaskNum() + self:SetTxtStageProgress(achived, total) + self.ImgJindu.fillAmount = achived / ((total and total > 0 and total) or 1) +end +--================ +--宝箱按钮点击 +--================ +function XUiFingerGuessSSLevelPanel:OnClickTask() + XLuaUiManager.Open("UiFingerGuessingTask") +end +--================ +--注册监听 +--================ +function XUiFingerGuessSSLevelPanel:AddEventListeners() + if self.ListenersAdded then return end + self.ListenersAdded = true + XEventManager.AddEventListener(XEventId.EVENT_TASK_SYNC, self.RefreshProgress, self) +end +--================ +--注销监听 +--================ +function XUiFingerGuessSSLevelPanel:RemoveEventListeners() + if not self.ListenersAdded then return end + XEventManager.RemoveEventListener(XEventId.EVENT_TASK_SYNC, self.RefreshProgress, self) + self.ListenersAdded = false +end +return XUiFingerGuessSSLevelPanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessSSRolePanel.lua b/Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessSSRolePanel.lua new file mode 100644 index 00000000..51405f0a --- /dev/null +++ b/Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessSSRolePanel.lua @@ -0,0 +1,28 @@ +--选择关卡界面角色展示面板 +local XUiFingerGuessSSRolePanel = XClass(nil, "XUiFingerGuessSSRolePanel") +local INITIAL_NAME_STR = "ENEMY_NAME" +--================ +--构造函数 +--================ +function XUiFingerGuessSSRolePanel:Ctor(gameObject, rootUi) + self.RootUi = rootUi + XTool.InitUiObjectByUi(self, gameObject) + self:InitPanel() +end +--================ +--初始化面板 +--================ +function XUiFingerGuessSSRolePanel:InitPanel() + self.RImgHero:SetRawImage(self.RootUi.GameController:GetHeroImage()) + self.TxtHeroName.text = self.RootUi.GameController:GetHeroName() + self.TxtEnemyName.text = INITIAL_NAME_STR +end +--================ +--选择关卡时 +--================ +function XUiFingerGuessSSRolePanel:OnStageSelected() + self.TxtEnemyName.text = self.RootUi.StageSelected:GetStageName() + self.RImgEnemy:SetRawImage(self.RootUi.StageSelected:GetRobotImage()) +end + +return XUiFingerGuessSSRolePanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessSSStartPanel.lua b/Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessSSStartPanel.lua new file mode 100644 index 00000000..0a57a191 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessSSStartPanel.lua @@ -0,0 +1,91 @@ +-- 选择关卡界面开始挑战面板控件 +local XUiFingerGuessSSStartPanel = XClass(nil, "XUiFingerGuessSSStartPanel") +local INITIAL_COST_NUM = 99999 +--================ +--构造函数 +--================ +function XUiFingerGuessSSStartPanel:Ctor(gameObject, rootUi) + self.RootUi = rootUi + XTool.InitUiObjectByUi(self, gameObject) + self:InitPanel() +end +--================ +--初始化面板 +--================ +function XUiFingerGuessSSStartPanel:InitPanel() + self.RImgCoinIcon:SetRawImage(self.RootUi.GameController:GetCoinItemIcon()) + self:SetTxtCostCoin(INITIAL_COST_NUM) + self.BtnStart.CallBack = function() self:OnClickBtnStart() end +end +--================ +--选择关卡时 +--================ +function XUiFingerGuessSSStartPanel:OnStageSelected() + local isClear = self.RootUi.StageSelected:GetIsClear() + self.TxtHistoryScore.gameObject:SetActiveEx(isClear) + self.ObjHistoryScoreTips.gameObject:SetActiveEx(isClear) + self.RImgCoinIcon.gameObject:SetActiveEx(not isClear) + self.TxtCostCoin.gameObject:SetActiveEx(not isClear) + self.ObjCostCoinTips.gameObject:SetActiveEx(not isClear) + if self.RootUi.StageSelected:GetIsClear() then + self.TxtHistoryScore.text = CS.XTextManager.GetText("FingerGuessingHighScore", self.RootUi.StageSelected:GetHighScore()) + elseif self.RootUi.StageSelected:CheckIsFirstEntry() then + self:SetTxtCostCoin(self.RootUi.StageSelected:GetCostItemCount()) + else + self:SetTxtCostCoin(0) + end +end +--================ +--设置消耗金币文本 +--================ +function XUiFingerGuessSSStartPanel:SetTxtCostCoin(cost) + if self.RootUi.GameController:CheckCoinEnough(cost) then + self.TxtCostCoin.text = cost + else + self.TxtCostCoin.text = CS.XTextManager.GetText("CommonRedText", cost) + end +end +--================ +--点击开始挑战按钮 +--================ +function XUiFingerGuessSSStartPanel:OnClickBtnStart() + if not self.RootUi.StageSelected then + XUiManager.TipMsg(CS.XTextManager.GetText("FingerGuessingStageNotSelect")) + elseif not self.RootUi.StageSelected:GetIsOpen() then + XUiManager.TipMsg(CS.XTextManager.GetText("FingerGuessingStageNotOpen")) + else + XDataCenter.FingerGuessingManager.StartGame(self.RootUi.StageSelected) + end +end +--================ +--开始游戏回调 +--================ +function XUiFingerGuessSSStartPanel:OnStartGame(stage) + XLuaUiManager.PopThenOpen("UiFingerGuessingGame", stage) +end + +function XUiFingerGuessSSStartPanel:OnEnable() + self:AddEventListeners() +end + +function XUiFingerGuessSSStartPanel:OnDisable() + self:RemoveEventListeners() +end +--================ +--注册事件 +--================ +function XUiFingerGuessSSStartPanel:AddEventListeners() + if self.EventAdded then return end + self.EventAdded = true + XEventManager.AddEventListener(XEventId.EVENT_FINGER_GUESS_GAME_START, self.OnStartGame, self) +end +--================ +--注销事件 +--================ +function XUiFingerGuessSSStartPanel:RemoveEventListeners() + if not self.EventAdded then return end + XEventManager.RemoveEventListener(XEventId.EVENT_FINGER_GUESS_GAME_START, self.OnStartGame, self) + self.EventAdded = false +end + +return XUiFingerGuessSSStartPanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessSSTitlePanel.lua b/Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessSSTitlePanel.lua new file mode 100644 index 00000000..352138e2 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessSSTitlePanel.lua @@ -0,0 +1,72 @@ +-- 选择关卡界面标题面板控件 +local XUiFingerGuessSSTitlePanel = XClass(nil, "XUiFingerGuessSSTitlePanel") +--================ +--构造函数 +--================ +function XUiFingerGuessSSTitlePanel:Ctor(gameObject, rootUi) + self.RootUi = rootUi + XTool.InitUiObjectByUi(self, gameObject) + self:InitPanel() +end +--================ +--初始化面板 +--================ +function XUiFingerGuessSSTitlePanel:InitPanel() + self.TxtTitle.text = self.RootUi.GameController:GetName() + self:RefreshTime() +end +--================ +--刷新活动倒计时 +--================ +function XUiFingerGuessSSTitlePanel:RefreshTime() + local endTimeSecond = self.RootUi.GameController:GetActivityEndTime() + local now = XTime.GetServerNowTimestamp() + local leftTime = endTimeSecond - now + self:SetTxtTime(XUiHelper.GetTime(leftTime, XUiHelper.TimeFormatType.ACTIVITY)) +end +--================ +--设置倒计时文本 +--================ +function XUiFingerGuessSSTitlePanel:SetTxtTime(text) + self.TxtTime.text = CS.XTextManager.GetText("CommonActivityTimeStr", text) +end +--================ +--OnEnable 显示面板时 +--================ +function XUiFingerGuessSSTitlePanel:OnEnable() + self:StopTimer() + self.Timer = XScheduleManager.ScheduleForever(function() + self:SetGameTimer() + end, XScheduleManager.SECOND, 0) +end +--================ +--OnDisable 隐藏面板时 +--================ +function XUiFingerGuessSSTitlePanel:OnDisable() + self:StopTimer() +end +--================ +--设置活动倒计时 +--================ +function XUiFingerGuessSSTitlePanel:SetGameTimer() + local endTimeSecond = self.RootUi.GameController:GetActivityEndTime() + local now = XTime.GetServerNowTimestamp() + local leftTime = endTimeSecond - now + self:SetTxtTime(XUiHelper.GetTime(leftTime, XUiHelper.TimeFormatType.ACTIVITY)) + if leftTime <= 0 then + if self.IsReseting then return end + self.IsReseting = true + self:StopTimer() + self.RootUi:OnGameEnd() + end +end +--================ +--停止计时器 +--================ +function XUiFingerGuessSSTitlePanel:StopTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end +return XUiFingerGuessSSTitlePanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessScorePanel.lua b/Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessScorePanel.lua new file mode 100644 index 00000000..2b7a69ca --- /dev/null +++ b/Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessScorePanel.lua @@ -0,0 +1,76 @@ +-- 猜拳小游戏得分面板控件 +local XUiFingerGuessScorePanel = XClass(nil, "XUiFingerGuessScorePanel") +local INITIAL_SCORE = 0 +local SCORE_TYPE = { + Hero = "Hero", + Enemy = "Enemy", + } +--================ +--构造函数 +--================ +function XUiFingerGuessScorePanel:Ctor(uiGameObject, rootUi) + self.RootUi = rootUi + XTool.InitUiObjectByUi(self, uiGameObject) + self:InitPanel() +end +--================ +--初始化面板 +--================ +function XUiFingerGuessScorePanel:InitPanel() + self.TxtHeroName.text = self.RootUi.GameController:GetHeroName() + self.TxtEnemyName.text = self.RootUi.Stage:GetStageName() + self.ImgHeroIcon:SetSprite(self.RootUi.GameController:GetPlayerPortraits()) + self.ImgEnemyIcon:SetSprite(self.RootUi.Stage:GetRobotPortraits()) + if self.TxtHeroScoreAnima then self.TxtHeroScoreAnima.gameObject:SetActiveEx(false) end + if self.TxtEnemyScoreAnima then self.TxtEnemyScoreAnima.gameObject:SetActiveEx(false) end + self:RefreshScore() +end +--================ +--关卡更新时 +--================ +function XUiFingerGuessScorePanel:OnStageRefresh() + self:RefreshScore(true) +end +--================ +--刷新得分 +--================ +function XUiFingerGuessScorePanel:RefreshScore(needAnima) + self:SetScore(self.RootUi.Stage:GetHeroScore(), SCORE_TYPE.Hero, needAnima) + self:SetScore(self.RootUi.Stage:GetEnemyScore(), SCORE_TYPE.Enemy, needAnima) +end +--================ +--设置面板 +--================ +function XUiFingerGuessScorePanel:SetScore(score, setType, needAnima) + if self["Pre" .. tostring(setType) .. "Score"] then + if self["Pre" .. tostring(setType) .. "Score"] < score then + if setType == SCORE_TYPE.Hero then + local obj = self["Txt" .. tostring(setType) .. "ScoreAnima"] + if obj then + obj.gameObject:SetActiveEx(true) + self.RootUi:PlayAnimation("TxtLeftEnable") + XScheduleManager.ScheduleOnce(function() + obj.gameObject:SetActiveEx(false) + end, 500) + end + elseif setType == SCORE_TYPE.Enemy then + local obj = self["Txt" .. tostring(setType) .. "ScoreAnima"] + if obj then + obj.gameObject:SetActiveEx(true) + self.RootUi:PlayAnimation("TxtRightEnable") + XScheduleManager.ScheduleOnce(function() + obj.gameObject:SetActiveEx(false) + end, 500) + end + end + end + end + local name = "Txt" .. tostring(setType) .. "Score" + local component = self[name] + if component then + component.text = CS.XTextManager.GetText("FingerGuessingScoreStr", score) + end + self["Pre" .. tostring(setType) .. "Score"] = score +end + +return XUiFingerGuessScorePanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessStage.lua b/Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessStage.lua new file mode 100644 index 00000000..036ca81a --- /dev/null +++ b/Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessStage.lua @@ -0,0 +1,37 @@ +-- 猜拳小游戏关卡组件 +local XUiFingerGuessStage = XClass(nil, "XUiFingerGuessStage") + +function XUiFingerGuessStage:Ctor(gameObject, stage, rootUi) + XTool.InitUiObjectByUi(self, gameObject) + self.RootUi = rootUi + self:InitPanel(stage) +end + +function XUiFingerGuessStage:InitPanel(stage) + if not stage then return end + self.Stage = stage + local isOpen = self.Stage:GetIsOpen() + self.PanelLock.gameObject:SetActiveEx(not isOpen) + self.PanelUnLock.gameObject:SetActiveEx(isOpen) + self.ImgEnemyIcon:SetSprite(self.Stage:GetRobotPortraits()) + self.ObjWinIcon.gameObject:SetActiveEx(self.Stage:GetIsClear()) + self.TxtEnemyName.text = self.Stage:GetStageName() + self.TxtLockEnemyName.text = self.Stage:GetLockStageName() + self.RImgLockEnemyIcon:SetRawImage(self.Stage:GetStageLockRobotPortraits()) + self.BtnStageSelect.CallBack = function() self:OnClickStageSelect() end +end + +function XUiFingerGuessStage:OnClickStageSelect() + if not self.Stage:GetIsOpen() then + XUiManager.TipMsg(CS.XTextManager.GetText("FingerGuessingStageNotOpen")) + return + end + self.BtnStageSelect:SetButtonState(CS.UiButtonState.Select) + self.RootUi:OnStageSelected(self, self.Stage) +end + +function XUiFingerGuessStage:OnOtherStageSelect() + self.BtnStageSelect:SetButtonState(CS.UiButtonState.Normal) +end + +return XUiFingerGuessStage \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessingEyePanel.lua b/Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessingEyePanel.lua new file mode 100644 index 00000000..86b68757 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessingEyePanel.lua @@ -0,0 +1,118 @@ +-- 选择关卡界面天眼面板 +local XUiFingerGuessingEyePanel = XClass(nil, "XUiFingerGuessingEyePanel") +local RULE_INITIAL_STR = "RULE_INITIAL" +local FINGER_TYPE +--================ +--构造函数 +--================ +function XUiFingerGuessingEyePanel:Ctor(gameObject, rootUi) + self.RootUi = rootUi + XTool.InitUiObjectByUi(self, gameObject) + self:InitPanel() +end +--================ +--初始化面板 +--================ +function XUiFingerGuessingEyePanel:InitPanel() + if self.TxtRule then self.TxtRule.text = RULE_INITIAL_STR end + if self.BtnOpenEye then + self.BtnOpenEye.CallBack = function() self:OnClickBtnOpenEye() end + self.BtnOpenEye.ButtonState = CS.UiButtonState.Disable + end + self:InitFingers() +end +--================ +--选择关卡时 +--================ +function XUiFingerGuessingEyePanel:OnStageSelected() + self:SetBtnOpenEyeStatus(self.RootUi.GameController:GetIsOpenEye()) + self:RefreshStageFingers() + self.TxtRule.text = CS.XTextManager.GetText("FingerGuessingOpenEyeRuleStr", self.RootUi.StageSelected:GetCheatCount()) +end +--================ +--关卡更新时 +--================ +function XUiFingerGuessingEyePanel:OnStageRefresh() + self:RefreshStageFingers() +end +--================ +--刷新出拳列表 +--================ +function XUiFingerGuessingEyePanel:RefreshStageFingers() + local stage = self.RootUi.StageSelected or self.RootUi.Stage + if not stage then return end + for _, fingerId in pairs(FINGER_TYPE) do + self.Fingers[fingerId]:RefreshFinger(fingerId, stage:GetFingerTextByFingerId(fingerId)) + end +end +--================ +--初始化猜拳控件 +--================ +function XUiFingerGuessingEyePanel:InitFingers() + local FingerScript = require("XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessFinger") + self.Fingers = {} + self.GridFinger.gameObject:SetActiveEx(false) + if not FINGER_TYPE then + FINGER_TYPE = {} + for _, fingerId in pairs(XDataCenter.FingerGuessingManager.FINGER_TYPE) do + FINGER_TYPE[fingerId + 1] = fingerId + end + end + for _, fingerId in pairs(FINGER_TYPE) do + local ui = CS.UnityEngine.GameObject.Instantiate(self.GridFinger) + ui.transform:SetParent(self.PanelFinger.transform, false) + ui.gameObject:SetActiveEx(true) + self.Fingers[fingerId] = FingerScript.New(ui, fingerId) + end + self:RefreshStageFingers() +end +--================ +--设置按钮状态 +--================ +function XUiFingerGuessingEyePanel:SetBtnOpenEyeStatus(isOpen) + if not self.BtnOpenEye then return end + if isOpen then + self.BtnOpenEye.ButtonState = CS.UiButtonState.Disable + else + self.BtnOpenEye.ButtonState = CS.UiButtonState.Normal + end +end +--================ +--点击开眼按钮 +--================ +function XUiFingerGuessingEyePanel:OnClickBtnOpenEye() + if self.BtnOpenEye.ButtonState == CS.UiButtonState.Disable then + XUiManager.TipMsg(CS.XTextManager.GetText("FingerGuessingEyeClose")) + XDataCenter.FingerGuessingManager.OpenEyes(self.RootUi.StageSelected) + return + else + local tipTitle = self.RootUi.StageSelected:GetOpenEyeTipsTitle() or CS.XTextManager.GetText("FingerGuessingEyeOpenTipsTitle") + local tipContent = self.RootUi.StageSelected:GetOpenEyeTipsContent() or CS.XTextManager.GetText("FingerGuessingEyeOpenTipsContent") + CsXUiManager.Instance:Open("UiDialog", tipTitle, tipContent, XUiManager.DialogType.Normal, nil, function() XDataCenter.FingerGuessingManager.OpenEyes(self.RootUi.StageSelected) end) + end +end + +function XUiFingerGuessingEyePanel:OnEnable() + self:AddEventListeners() +end + +function XUiFingerGuessingEyePanel:OnDisable() + self:RemoveEventListeners() +end +--================ +--注册事件 +--================ +function XUiFingerGuessingEyePanel:AddEventListeners() + if self.EventAdded then return end + self.EventAdded = true + XEventManager.AddEventListener(XEventId.EVENT_FINGER_GUESS_OPEN_EYE, self.OnStageSelected, self) +end +--================ +--注销事件 +--================ +function XUiFingerGuessingEyePanel:RemoveEventListeners() + if not self.EventAdded then return end + XEventManager.RemoveEventListener(XEventId.EVENT_FINGER_GUESS_OPEN_EYE, self.OnStageSelected, self) + self.EventAdded = false +end +return XUiFingerGuessingEyePanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessingGame.lua b/Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessingGame.lua new file mode 100644 index 00000000..650199e7 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessingGame.lua @@ -0,0 +1,125 @@ +-- 猜拳小游戏游戏进行界面 +local XUiFingerGuessingGame = XLuaUiManager.Register(XLuaUi, "UiFingerGuessingGame") + +--================ +--OnAwake 初始化UiObject +--================ +function XUiFingerGuessingGame:OnAwake() + XTool.InitUiObject(self) + self.GameController = XDataCenter.FingerGuessingManager.GetGameController() + self.BtnBack.CallBack = function() self:OnClickBtnBack() end + self.BtnMainUi.CallBack = function() self:OnClickBtnMainUi() end + if self.BtnHelp then self.BtnHelp.CallBack = function() self:OnClickBtnHelp() end end +end +--================ +--点击返回按钮 +--================ +function XUiFingerGuessingGame:OnClickBtnBack() + self:Close() +end +--================ +--点击主界面按钮 +--================ +function XUiFingerGuessingGame:OnClickBtnMainUi() + XLuaUiManager.RunMain() +end +--================ +--点击帮助按钮 +--================ +function XUiFingerGuessingGame:OnClickBtnHelp() + XUiManager.ShowHelpTip("FingerGuessingGameHelp") +end +--================ +--OnStart 加载关卡对象和初始化界面 +--@param currentStage:正在进行的关卡 +--================ +function XUiFingerGuessingGame:OnStart(currentStage) + self.Stage = currentStage + self:InitPanels() +end +--================ +--OnEnable 每次显示界面时注册事件 +--================ +function XUiFingerGuessingGame:OnEnable() + self:RunAllPanelsFunc("OnEnable") +end +--================ +--OnDisable 界面隐藏或销毁时注销事件 +--================ +function XUiFingerGuessingGame:OnDisable() + self:RunAllPanelsFunc("OnDisable") +end +--================ +--初始化所有面板控件 +--================ +function XUiFingerGuessingGame:InitPanels() + self.Panels = {} + self:InitPanelAsset() + self:InitPanelTitle() + self:InitPanelEye() + self:InitPanelUpper() + self:InitPanelLower() +end +--================ +--初始化资源代币面板 +--================ +function XUiFingerGuessingGame:InitPanelAsset() + local coinId = self.GameController:GetCoinItemId() + local asset = XUiPanelAsset.New(self, self.PanelAsset, coinId) + asset:RegisterJumpCallList({[1] = function() + XLuaUiManager.Open("UiTip", coinId) + end}) +end +--================ +--初始化标题面板 +--================ +function XUiFingerGuessingGame:InitPanelTitle() + local PanelTitle = require("XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessSSTitlePanel") + self.TitlePanel = PanelTitle.New(self.PanelTitle, self) + table.insert(self.Panels, self.TitlePanel) +end +--================ +--初始化天眼面板 +--================ +function XUiFingerGuessingGame:InitPanelEye() + local PanelEye = require("XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessingEyePanel") + self.EyePanel = PanelEye.New(self.PanelEye, self) + table.insert(self.Panels, self.EyePanel) +end +--================ +--初始化得分牌面板 +--================ +function XUiFingerGuessingGame:InitPanelUpper() + local PanelScore = require("XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessScorePanel") + self.ScorePanel = PanelScore.New(self.PanelUpper, self) + table.insert(self.Panels, self.ScorePanel) +end +--================ +--初始化猜拳面板 +--================ +function XUiFingerGuessingGame:InitPanelLower() + local PanelGame = require("XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessGamePanel") + self.GamePanel = PanelGame.New(self.PanelLower, self) + table.insert(self.Panels, self.GamePanel) +end +--================ +--运行所有面板指定方法 +--@param funcName:方法名 +--================ +function XUiFingerGuessingGame:RunAllPanelsFunc(funcName) + for _, panel in pairs(self.Panels) do + local func = panel[funcName] + if func then func(panel) end + end +end + +function XUiFingerGuessingGame:OnRefreshRound() + self:RunAllPanelsFunc("OnStageRefresh") +end +--================ +--活动结束时处理 +--================ +function XUiFingerGuessingGame:OnGameEnd() + XLuaUiManager.RunMain() + XUiManager.TipMsg(CS.XTextManager.GetText("CommonActivityEnd")) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessingSelectStage.lua b/Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessingSelectStage.lua new file mode 100644 index 00000000..417c0903 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessingSelectStage.lua @@ -0,0 +1,145 @@ +-- 猜拳选择关卡界面 +local XUiFingerGuessingSelectStage = XLuaUiManager.Register(XLuaUi, "UiFingerGuessingSelectStage") +--================ +--OnAwake 初始化界面 +--================ +function XUiFingerGuessingSelectStage:OnAwake() + XTool.InitUiObject(self) + self.GameController = XDataCenter.FingerGuessingManager.GetGameController() + self.BtnBack.CallBack = function() self:OnClickBtnBack() end + self.BtnMainUi.CallBack = function() self:OnClickBtnMainUi() end + if self.BtnHelp then self.BtnHelp.CallBack = function() self:OnClickBtnHelp() end end + self:InitPanels() +end + +function XUiFingerGuessingSelectStage:OnStart(result) + --如果是从一局游戏结束打开此界面的话,检查对局结果 + if result == false then + XUiManager.TipMsg(CS.XTextManager.GetText("FingerGuessingOpenEyeTips")) + end +end +--================ +--点击返回按钮 +--================ +function XUiFingerGuessingSelectStage:OnClickBtnBack() + self:Close() +end +--================ +--点击主界面按钮 +--================ +function XUiFingerGuessingSelectStage:OnClickBtnMainUi() + XLuaUiManager.RunMain() +end +--================ +--点击帮助按钮 +--================ +function XUiFingerGuessingSelectStage:OnClickBtnHelp() + XUiManager.ShowHelpTip("FingerGuessingGameHelp") +end +--================ +--初始化所有面板控件 +--================ +function XUiFingerGuessingSelectStage:InitPanels() + self.Panels = {} + self:InitPanelAsset() + self:InitPanelTitle() + self:InitPanelExplain() + self:InitPanelStart() + self:InitPanelRole() + self:InitPanelEye() + self:InitPanelLevel() +end +--================ +--OnEnable 调用所有子面板OnEnable方法 +--================ +function XUiFingerGuessingSelectStage:OnEnable() + self:RunAllPanelsFunc("OnEnable") + if XDataCenter.FingerGuessingManager.GetIsFirstIn() then + XUiManager.ShowHelpTip("FingerGuessingGameHelp") + end +end +--================ +--OnDisable 调用所有子面板OnDisable方法 +--================ +function XUiFingerGuessingSelectStage:OnDisable() + self:RunAllPanelsFunc("OnDisable") +end +--================ +--初始化资源代币面板 +--================ +function XUiFingerGuessingSelectStage:InitPanelAsset() + local coinId = self.GameController:GetCoinItemId() + local asset = XUiPanelAsset.New(self, self.PanelAsset, coinId) + asset:RegisterJumpCallList({[1] = function() + XLuaUiManager.Open("UiTip", coinId) + end}) +end +--================ +--初始化标题面板 +--================ +function XUiFingerGuessingSelectStage:InitPanelTitle() + local PanelTitle = require("XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessSSTitlePanel") + table.insert(self.Panels, PanelTitle.New(self.PanelTitle, self)) +end +--================ +--初始化规则解说面板 +--================ +function XUiFingerGuessingSelectStage:InitPanelExplain() + local PanelExplain = require("XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessSSExplainPanel") + table.insert(self.Panels, PanelExplain.New(self.PanelExplain, self)) +end +--================ +--初始化开始挑战面板 +--================ +function XUiFingerGuessingSelectStage:InitPanelStart() + local PanelStart = require("XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessSSStartPanel") + table.insert(self.Panels, PanelStart.New(self.PanelStart, self)) +end +--================ +--初始化角色画像面板 +--================ +function XUiFingerGuessingSelectStage:InitPanelRole() + local PanelRole = require("XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessSSRolePanel") + table.insert(self.Panels, PanelRole.New(self.PanelRole, self)) +end +--================ +--初始化天眼面板 +--================ +function XUiFingerGuessingSelectStage:InitPanelEye() + local PanelEye = require("XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessingEyePanel") + table.insert(self.Panels, PanelEye.New(self.PanelEye, self)) +end +--================ +--初始化关卡面板 +--================ +function XUiFingerGuessingSelectStage:InitPanelLevel() + local PanelLevel = require("XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessSSLevelPanel") + table.insert(self.Panels, PanelLevel.New(self.PanelLevel, self)) +end +--================ +--运行所有面板指定方法 +--@param funcName:方法名 +--================ +function XUiFingerGuessingSelectStage:RunAllPanelsFunc(funcName) + for _, panel in pairs(self.Panels) do + local func = panel[funcName] + if func then func(panel) end + end +end +--================ +--关卡选中时 +--================ +function XUiFingerGuessingSelectStage:OnStageSelected(component, stage) + if self.StageComponent == component then return end + if self.StageComponent then self.StageComponent:OnOtherStageSelect() end + self.StageComponent = component + self.StageSelected = stage + self:RunAllPanelsFunc("OnStageSelected") +end +--================ +--活动结束时处理 +--================ +function XUiFingerGuessingSelectStage:OnGameEnd() + XLuaUiManager.RunMain() + XUiManager.TipMsg(CS.XTextManager.GetText("CommonActivityEnd")) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessingTask.lua b/Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessingTask.lua new file mode 100644 index 00000000..ebe12adb --- /dev/null +++ b/Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessingTask.lua @@ -0,0 +1,125 @@ +-- 猜拳小游戏活动任务界面 +local XUiFingerGuessingTask = XLuaUiManager.Register(XLuaUi, "UiFingerGuessingTask") +local TaskList = require("XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessingTaskDynamicTable") + +function XUiFingerGuessingTask:OnAwake() + XTool.InitUiObject(self) + self.GridTask.gameObject:SetActiveEx(false) + self.GameController = XDataCenter.FingerGuessingManager.GetGameController() + self:InitButtons() + self:InitPanelAsset() + self:InitTaskList() +end +--================ +--初始化按钮 +--================ +function XUiFingerGuessingTask:InitButtons() + self.BtnBack.CallBack = function() self:OnClickBtnBack() end + self.BtnMainUi.CallBack = function() self:OnClickBtnMainUi() end +end +--================ +--点击返回按钮 +--================ +function XUiFingerGuessingTask:OnClickBtnBack() + self:StopTimer() + self:Close() +end +--================ +--点击主界面按钮 +--================ +function XUiFingerGuessingTask:OnClickBtnMainUi() + self:StopTimer() + XLuaUiManager.RunMain() +end +--================ +--初始化资源代币面板 +--================ +function XUiFingerGuessingTask:InitPanelAsset() + local coinId = self.GameController:GetCoinItemId() + local asset = XUiPanelAsset.New(self, self.PanelAsset, coinId) + asset:RegisterJumpCallList({[1] = function() + XLuaUiManager.Open("UiTip", coinId) + end}) +end +--================ +--初始化界面面板 +--================ +function XUiFingerGuessingTask:InitTaskList() + self.TaskList = TaskList.New(self.SViewTask, self) +end +--================ +--显示界面时 +--================ +function XUiFingerGuessingTask:OnShowPanel() + self.TaskList:UpdateData() +end +--================ +--OnEnable 显示面板时 +--================ +function XUiFingerGuessingTask:OnEnable() + self:StopTimer() + self.Timer = XScheduleManager.ScheduleForever(function() + self:SetGameTimer() + end, XScheduleManager.SECOND, 0) + self:AddEventListeners() + self:OnShowPanel() +end +--================ +--OnDisable 隐藏面板时 +--================ +function XUiFingerGuessingTask:OnDisable() + self:StopTimer() + self:RemoveEventListeners() +end +--================ +--设置活动倒计时 +--================ +function XUiFingerGuessingTask:SetGameTimer() + local endTimeSecond = self.GameController:GetActivityEndTime() + local now = XTime.GetServerNowTimestamp() + local leftTime = endTimeSecond - now + if leftTime <= 0 then + self:OnGameEnd() + end +end +--================ +--停止计时器 +--================ +function XUiFingerGuessingTask:StopTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end +--================ +--活动周期结束时弹回主界面 +--================ +function XUiFingerGuessingTask:OnGameEnd() + if self.IsReseting then return end + self.IsReseting = true + self:StopTimer() + XLuaUiManager.RunMain() + XUiManager.TipMsg(CS.XTextManager.GetText("CommonActivityEnd")) +end +--================ +--刷新任务列表 +--================ +function XUiFingerGuessingTask:RefreshTasks() + self.TaskList:UpdateData() +end +--================ +--增加事件监听 +--================ +function XUiFingerGuessingTask:AddEventListeners() + if self.AlreadyAddEvents then return end + self.AlreadyAddEvents = true + XEventManager.AddEventListener(XEventId.EVENT_TASK_SYNC, self.RefreshTasks, self) +end +--================ +--移除事件监听 +--================ +function XUiFingerGuessingTask:RemoveEventListeners() + if not self.AlreadyAddEvents then return end + self.AlreadyAddEvents = false + XEventManager.RemoveEventListener(XEventId.EVENT_TASK_SYNC, self.RefreshTasks, self) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessingTaskDynamicTable.lua b/Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessingTaskDynamicTable.lua new file mode 100644 index 00000000..7f914735 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMiniGame/FingerGuessing/XUiFingerGuessingTaskDynamicTable.lua @@ -0,0 +1,46 @@ +---@class XUiFingerGuessingTaskDynamicTable +local XUiFingerGuessingTaskDynamicTable = XClass(nil, "XUiFingerGuessingTaskDynamicTable") + +function XUiFingerGuessingTaskDynamicTable:Ctor(ui, rootUi) + XTool.InitUiObjectByUi(self, ui) + self.RootUi = rootUi + self.DynamicTable = XDynamicTableNormal.New(self.GameObject) + self.DynamicTable:SetProxy(XDynamicGridTask) + self.DynamicTable:SetDelegate(self) +end +--动态列表事件 +function XUiFingerGuessingTaskDynamicTable:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.TaskList[index] + if not data then + return + end + grid.RootUi = self.RootUi + grid:ResetData(data) + end +end +function XUiFingerGuessingTaskDynamicTable:UpdateData() + self.TaskList = self:GetTaskList() + self.DynamicTable:SetDataSource(self.TaskList) + self.DynamicTable:ReloadDataASync() +end + +function XUiFingerGuessingTaskDynamicTable:GetTaskList() + local taskList = XDataCenter.TaskManager.GetFingerGuessingFullTaskList() + for _, v in pairs(taskList or {}) do + v.SortWeight = 2 + if v.State == XDataCenter.TaskManager.TaskState.Achieved then + v.SortWeight = 1 + elseif v.State == XDataCenter.TaskManager.TaskState.Finish or v.State == XDataCenter.TaskManager.TaskState.Invalid then + v.SortWeight = 3 + end + end + table.sort(taskList, function(taskA, taskB) + if taskA.SortWeight == taskB.SortWeight then + return taskA.Id < taskB.Id + end + return taskA.SortWeight < taskB.SortWeight + end) + return taskList +end +return XUiFingerGuessingTaskDynamicTable \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenDispatchMemberDynamicGrid.lua b/Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenDispatchMemberDynamicGrid.lua new file mode 100644 index 00000000..5e782dc0 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenDispatchMemberDynamicGrid.lua @@ -0,0 +1,58 @@ +local XSuper = require("XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenInviteCharaGrid") +-- +local XUiWhiteValenDispatchMemberDynamicGrid = XClass(XSuper, "XUiWhiteValenDispatchMemberDynamicGrid") + +--================ +--构造函数(动态列表组件初始化时不在这里做) +--================ +function XUiWhiteValenDispatchMemberDynamicGrid:Ctor() + +end +--================ +--初始化 +--================ +function XUiWhiteValenDispatchMemberDynamicGrid:Init(dTable, ui) + self.DynamicTable = dTable + XTool.InitUiObjectByUi(self, ui) +end +--================ +--刷新数据 +--@param chara:活动角色对象 +--@param gridIndex:控件序号 +--================ +function XUiWhiteValenDispatchMemberDynamicGrid:RefreshData(chara, gridIndex) + if not chara then + return + end + self.Chara = chara + if gridIndex then self.GridIndex = gridIndex end + self:SetChara() + self:SetIsSelect(false) + self:SetDispatch() +end +--================ +--设置是否被派遣 +--@param isDispatch:是否被派遣 +--================ +function XUiWhiteValenDispatchMemberDynamicGrid:SetDispatch() + self.CharaDispatch.gameObject:SetActiveEx(self.Chara:GetDispatching()) +end +--================ +--设置是否被选择 +--@param isSelect:是否被选择 +--================ +function XUiWhiteValenDispatchMemberDynamicGrid:SetIsSelect(isSelect) + self.ItemSele.gameObject:SetActiveEx(isSelect) +end +--================ +--点击时 +--================ +function XUiWhiteValenDispatchMemberDynamicGrid:OnClick() + if self.Chara:GetDispatching() then + XUiManager.TipMsg(CS.XTextManager.GetText("WhiteValentineCharaIsDispatching")) + return + end + self.DynamicTable:SetSelect(self) + self:SetIsSelect(true) +end +return XUiWhiteValenDispatchMemberDynamicGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenDispatchMemberDynamicTable.lua b/Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenDispatchMemberDynamicTable.lua new file mode 100644 index 00000000..93b58e45 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenDispatchMemberDynamicTable.lua @@ -0,0 +1,68 @@ +-- +local XUiWhiteValenDispatchMemberDynamicTable = XClass(nil, "XUiWhiteValenDispatchMemberDynamicTable") +--================ +--构造函数 +--================ +function XUiWhiteValenDispatchMemberDynamicTable:Ctor(rootUi, ui) + self.RootUi = rootUi + XTool.InitUiObjectByUi(self, ui) + self.CharaManager = XDataCenter.WhiteValentineManager.GetCharaManager() + self:InitDynamicTable() +end +--================ +--初始化动态列表 +--================ +function XUiWhiteValenDispatchMemberDynamicTable:InitDynamicTable() + local XGrid = require("XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenDispatchMemberDynamicGrid") + self.DynamicTable = XDynamicTableNormal.New(self.GameObject) + self.DynamicTable:SetProxy(XGrid) + self.DynamicTable:SetDelegate(self) +end + +--动态列表事件 +function XUiWhiteValenDispatchMemberDynamicTable:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self, grid.DynamicGrid.gameObject) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + if self.MemberList and self.MemberList[index] then + grid:RefreshData(self.MemberList[index], index) + if self.CurrentIndex and self.CurrentIndex == index then + grid:SetIsSelect(true) + end + end + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + grid:OnClick() + end +end +--================ +--给动态列表赋值 +--================ +function XUiWhiteValenDispatchMemberDynamicTable:GuideGetDynamicTableIndex(id) + for index, member in pairs(self.MemberList) do + if member:GetCharaId() == tonumber(id) then + return index + end + end + return -1 +end +--================ +--刷新控件 +--================ +function XUiWhiteValenDispatchMemberDynamicTable:UpdateData(attrType) + self.MemberList = self.CharaManager:GetCharaListSortByDispatching(attrType) + self.DynamicTable:SetDataSource(self.MemberList) + self.DynamicTable:ReloadDataASync(1) +end +--================ +--列表项选中事件 +--================ +function XUiWhiteValenDispatchMemberDynamicTable:SetSelect(grid) + if self.CurGrid and self.CurGrid ~= grid then + self.CurGrid:SetIsSelect(false) + end + self.CurGrid = grid + self.CurrentIndex = grid.GridIndex + self.RootUi:SetDispatchChara(grid.Chara) +end + +return XUiWhiteValenDispatchMemberDynamicTable \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenDispatchPanelPlace.lua b/Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenDispatchPanelPlace.lua new file mode 100644 index 00000000..6347e6c9 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenDispatchPanelPlace.lua @@ -0,0 +1,18 @@ +-- +local XUiWhiteValenDispatchPanelPlace = XClass(nil, "") + +function XUiWhiteValenDispatchPanelPlace:Ctor(rootUi, ui, place) + self.RootUi = rootUi + XTool.InitUiObjectByUi(self, ui) + self.Place = place + self:InitPlace() +end + +function XUiWhiteValenDispatchPanelPlace:InitPlace() + self.RImgRank:SetSprite(self.Place:GetRankIcon()) + self.TxtEventName.text = self.Place:GetEventName() + self.TxtEventDescription.text = self.Place:GetEventDescription() + self.ImgBg:SetRawImage(self.Place:GetBgPath()) +end + +return XUiWhiteValenDispatchPanelPlace \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenDispatchPanelReward.lua b/Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenDispatchPanelReward.lua new file mode 100644 index 00000000..5284efbb --- /dev/null +++ b/Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenDispatchPanelReward.lua @@ -0,0 +1,32 @@ +-- +local XUiWhiteValenDispatchPanelReward = XClass(nil, "XUiWhiteValenDispatchPanelReward") + +function XUiWhiteValenDispatchPanelReward:Ctor(rootUi, ui, place) + self.RootUi = rootUi + XTool.InitUiObjectByUi(self, ui) + self.Place = place + self.GameController = XDataCenter.WhiteValentineManager.GetGameController() + self:InitReward() +end + +function XUiWhiteValenDispatchPanelReward:InitReward() + self.TxtCostTime.text = CS.XTextManager.GetText("WhiteValentineCostTimeStr", self.Place:GetCostTime()) + self.TxtCostEnergy.text = self.Place:GetCostEnergy() + self.TxtCutDownTime.text = "" + if self.RImgEnergyIcon then + self.RImgEnergyIcon:SetRawImage(self.GameController:GetEnergyIconPath()) + end + local grid = require("XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenItemGrid") + self.ContributionGrid = grid.New(self.GridContribution, self.GameController:GetContributionItemId()) + self.CoinGrid = grid.New(self.GridCoin, self.GameController:GetCoinItemId()) + self.CoinGrid:SetCount(self.Place:GetRankCoinReward()) + self.ContributionGrid:SetCount(self.Place:GetRankContributionReward()) +end + +function XUiWhiteValenDispatchPanelReward:RefreshChara(chara) + local isAttrActive = chara:GetAttrType() == self.Place:GetEventAttrType() + self.TxtCutDownTime.text = isAttrActive and CS.XTextManager.GetText("WhiteValentinePercentMinus", chara:GetCutDownTime()) or "" + self.ContributionGrid:SetContributionAdd(isAttrActive and chara:GetContributionBuff() or nil) +end + +return XUiWhiteValenDispatchPanelReward \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenInviteCharaGrid.lua b/Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenInviteCharaGrid.lua new file mode 100644 index 00000000..d24b3695 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenInviteCharaGrid.lua @@ -0,0 +1,32 @@ +-- 白色情人节约会活动成员资料牌UI控件 +local XUiWhiteValenInviteCharaGrid = XClass(nil, "XUiWhiteValenInviteCharaGrid") +--================ +--构造函数(作为动态列表组件初始化时不在这里做) +--================ +function XUiWhiteValenInviteCharaGrid:Ctor(ui, chara) + if ui then XTool.InitUiObjectByUi(self, ui) end + self:RefreshData(chara) +end +--================ +--刷新数据 +--@param chara:活动角色对象 +--@param gridIndex:控件序号 +--================ +function XUiWhiteValenInviteCharaGrid:RefreshData(chara) + if not chara then + return + end + self.Chara = chara + self:SetChara() +end +--================ +--设置角色数据 +--================ +function XUiWhiteValenInviteCharaGrid:SetChara() + self.TxtName.text = self.Chara:GetName() + self.RImgIcon:SetRawImage(self.Chara:GetIconPath()) + self.RImgAttr:SetRawImage(self.Chara:GetAttrIcon()) + self.TxtValues.text = self.Chara:GetAttrValue() +end + +return XUiWhiteValenInviteCharaGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenInviteMemberDynamicGrid.lua b/Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenInviteMemberDynamicGrid.lua new file mode 100644 index 00000000..6f0e7389 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenInviteMemberDynamicGrid.lua @@ -0,0 +1,46 @@ +local XSuper = require("XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenInviteCharaGrid") +-- 白色情人节约会活动邀约界面成员动态列表组件控件 +local XUiWhiteValenInviteMemberDynamicGrid = XClass(XSuper, "XUiWhiteValenInviteMemberDynamicGrid") +--================ +--构造函数(动态列表组件初始化时不在这里做) +--================ +function XUiWhiteValenInviteMemberDynamicGrid:Ctor() + +end +--================ +--初始化 +--================ +function XUiWhiteValenInviteMemberDynamicGrid:Init(dTable, ui) + self.DynamicTable = dTable + XTool.InitUiObjectByUi(self, ui) +end +--================ +--刷新数据 +--@param chara:活动角色对象 +--@param gridIndex:控件序号 +--================ +function XUiWhiteValenInviteMemberDynamicGrid:RefreshData(chara, gridIndex) + if not chara then + return + end + self.Chara = chara + if gridIndex then self.GridIndex = gridIndex end + self:SetChara() + self:SetIsSelect(false) +end +--================ +--设置是否被选择 +--@param isSelect:是否被选择 +--================ +function XUiWhiteValenInviteMemberDynamicGrid:SetIsSelect(isSelect) + self.ItemSele.gameObject:SetActiveEx(isSelect) +end +--================ +--点击时 +--================ +function XUiWhiteValenInviteMemberDynamicGrid:OnClick() + self.DynamicTable:SetSelect(self) + self:SetIsSelect(true) +end + +return XUiWhiteValenInviteMemberDynamicGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenInviteMemberDynamicTable.lua b/Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenInviteMemberDynamicTable.lua new file mode 100644 index 00000000..541e763c --- /dev/null +++ b/Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenInviteMemberDynamicTable.lua @@ -0,0 +1,56 @@ +-- 白色情人节约会活动邀约界面成员动态列表控件 +local XUiWhiteValenInviteMemberDynamicTable = XClass(nil, "XUiWhiteValenInviteMemberDynamicTable") + +--================ +--构造函数 +--================ +function XUiWhiteValenInviteMemberDynamicTable:Ctor(rootUi, ui) + self.RootUi = rootUi + XTool.InitUiObjectByUi(self, ui) + self:InitDynamicTable() +end +--================ +--初始化动态列表 +--================ +function XUiWhiteValenInviteMemberDynamicTable:InitDynamicTable() + local XGrid = require("XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenInviteMemberDynamicGrid") + self.DynamicTable = XDynamicTableNormal.New(self.GameObject) + self.DynamicTable:SetProxy(XGrid) + self.DynamicTable:SetDelegate(self) +end + +--动态列表事件 +function XUiWhiteValenInviteMemberDynamicTable:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self, grid.DynamicGrid.gameObject) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + if self.MemberList and self.MemberList[index] then + grid:RefreshData(self.MemberList[index], index) + if self.CurrentIndex and self.CurrentIndex == index then + grid:SetIsSelect(true) + end + end + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + grid:OnClick() + end +end +--================ +--刷新控件 +--================ +function XUiWhiteValenInviteMemberDynamicTable:UpdateData(memberList) + self.MemberList = memberList + self.DynamicTable:SetDataSource(self.MemberList) + self.DynamicTable:ReloadDataASync(1) +end +--================ +--列表项选中事件 +--================ +function XUiWhiteValenInviteMemberDynamicTable:SetSelect(grid) + if self.CurGrid and self.CurGrid ~= grid then + self.CurGrid:SetIsSelect(false) + end + self.CurGrid = grid + self.CurrentIndex = grid.GridIndex + self.RootUi:SetInviteChara(grid.Chara) +end +return XUiWhiteValenInviteMemberDynamicTable \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenItemGrid.lua b/Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenItemGrid.lua new file mode 100644 index 00000000..e6e69b11 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenItemGrid.lua @@ -0,0 +1,32 @@ +-- 白情 +local XUiWhiteValenItemGrid = XClass(nil, "XUiWhiteValenItemGrid") + +function XUiWhiteValenItemGrid:Ctor(uiGameObject, itemId) + XTool.InitUiObjectByUi(self, uiGameObject) + self:InitPanel(itemId) +end + +function XUiWhiteValenItemGrid:InitPanel(itemId) + if not itemId then return end + self.ItemId = itemId + self.RImgItemIcon:SetRawImage(XDataCenter.ItemManager.GetItemIcon(itemId)) + local quality = XDataCenter.ItemManager.GetItemQuality(itemId) + local qualityPath = XArrangeConfigs.GeQualityPath(quality) + self.ImgQuality:SetSprite(qualityPath) + self.TxtCount.text = "x0" + if self.ObjContributionAdd then self.ObjContributionAdd.gameObject:SetActiveEx(false) end + XUiHelper.RegisterClickEvent(self, self.BtnClick, function() + XLuaUiManager.Open("UiTip", self.ItemId, true, nil) + end) +end + +function XUiWhiteValenItemGrid:SetCount(count) + self.TxtCount.text = "x" .. count +end + +function XUiWhiteValenItemGrid:SetContributionAdd(contributionAdd) + self.ObjContributionAdd.gameObject:SetActiveEx(contributionAdd ~= nil and contributionAdd > 0) + self.TxtContributionAdd.text = CS.XTextManager.GetText("WhiteValentinePercentAdd", contributionAdd or 0) +end + +return XUiWhiteValenItemGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenMainButtonPanel.lua b/Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenMainButtonPanel.lua new file mode 100644 index 00000000..a6686ad7 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenMainButtonPanel.lua @@ -0,0 +1,179 @@ +-- 白色情人节约会活动主界面功能按钮面板 +local XUiWhiteValenMainButtonPanel = XClass(nil, "XUiWhiteValenMainButtonPanel") + +function XUiWhiteValenMainButtonPanel:Ctor(rootUi, ui) + self.RootUi = rootUi + XTool.InitUiObjectByUi(self, ui) + self.GameController = XDataCenter.WhiteValentineManager.GetGameController() + self:Init() + self:RefreshPanel() +end + +function XUiWhiteValenMainButtonPanel:Init() + self:InitTaskBtn() + self:InitPanelTaskBtn() + self:InitEncounterBtn() + self:InitInviteBtn() + self.RedEvents = {} + self:AddEventListeners() + self:AddRedPointEvents() +end +--================== +--初始化任务按钮 +--================== +function XUiWhiteValenMainButtonPanel:InitTaskBtn() + self.BtnTask.CallBack = function() + self:OnBtnTaskClick() + end +end +--================== +--初始化偶遇按钮 +--================== +function XUiWhiteValenMainButtonPanel:InitEncounterBtn() + self.IconCoin:SetRawImage(self.GameController:GetCoinItemIcon()) + self.BtnEncounter.CallBack = function() + self:OnBtnEncounterClick() + end + self:RefreshEncounterBtn() +end +--================== +--刷新偶遇按钮提示文本 +--================== +function XUiWhiteValenMainButtonPanel:RefreshEncounterBtn() + if self.GameController:GetCoin() >= self.GameController:GetRandomMeetCostCoin() then + self.TxtEncounterCost.text = self.GameController:GetRandomMeetCostCoin() + else + self.TxtEncounterCost.text = CS.XTextManager.GetText("WhiteValentineCoinNotEnoughStr", self.GameController:GetRandomMeetCostCoin()) + end +end +--================== +--初始化邀请按钮 +--================== +function XUiWhiteValenMainButtonPanel:InitInviteBtn() + self.BtnInvite.CallBack = function() + self:OnBtnInviteClick() + end + self:RefreshInviteBtn() +end +--================== +--刷新邀请按钮 +--================== +function XUiWhiteValenMainButtonPanel:RefreshInviteBtn() + self.TxtInviteCount.text = CS.XTextManager.GetText("WhiteValenDateInvite", self.GameController:GetInviteChance()) +end + +function XUiWhiteValenMainButtonPanel:InitPanelTaskBtn() + self.BtnPanelTask.CallBack = function() + self:OnBtnPanelTaskClick() + end +end + +function XUiWhiteValenMainButtonPanel:OnBtnTaskClick() + XLuaUiManager.Open("UiWhitedayTask") +end + +function XUiWhiteValenMainButtonPanel:OnBtnEncounterClick() + if not self.GameController:CheckEncounterCoinEnough() then + XUiManager.TipMsg(CS.XTextManager.GetText("WhiteValentineCoinNotEnough")) + return + end + XUiManager.TipMsg(CS.XTextManager.GetText("WhiteValentineEncounterPreTip"), nil, function() + if not self.GameController:CheckOutTeamCharaExist() then + XUiManager.TipMsgEnqueue(CS.XTextManager.GetText("WhiteValentineEncounterNoMemberTip")) + else + XDataCenter.WhiteValentineManager.EncounterChara() + end + end) +end + +function XUiWhiteValenMainButtonPanel:OnBtnInviteClick() + if self.GameController:CheckCanInviteChara() then + XLuaUiManager.Open("UiWhitedayInvite") + else + XUiManager.TipMsg(CS.XTextManager.GetText("WhiteValentineCantInvite")) + end +end + +function XUiWhiteValenMainButtonPanel:OnBtnPanelTaskClick() + XLuaUiManager.Open("UiWhitedayTask") +end + +function XUiWhiteValenMainButtonPanel:AddEventListeners() + if self.ListenersAdded then return end + self.ListenersAdded = true + self:AddRedPointEvents() + XEventManager.AddEventListener(XEventId.EVENT_WHITEVALENTINE_SHOW_PLACE, self.RefreshPanel, self) + XEventManager.AddEventListener(XEventId.EVENT_TASK_SYNC, self.RefreshMission, self) +end + +function XUiWhiteValenMainButtonPanel:RemoveEventListeners() + if not self.ListenersAdded then return end + self:RemoveRedPointEvents() + XEventManager.RemoveEventListener(XEventId.EVENT_WHITEVALENTINE_SHOW_PLACE, self.RefreshPanel, self) + XEventManager.RemoveEventListener(XEventId.EVENT_TASK_SYNC, self.RefreshMission, self) + self.ListenersAdded = false +end + +function XUiWhiteValenMainButtonPanel:RefreshMission() + local task = XDataCenter.TaskManager.GetWhiteValentineFirstNotAcheivedMission() + if task and task.State ~= XDataCenter.TaskManager.TaskState.Finish then + self.IconTaskComplete.gameObject:SetActiveEx(task.State == XDataCenter.TaskManager.TaskState.Achieved) + local config = XDataCenter.TaskManager.GetTaskTemplate(task.Id) + if task.State == XDataCenter.TaskManager.TaskState.Achieved then + self.BtnPanelTask:SetName(CS.XTextManager.GetText("WhiteValentineBlueStr", config.Desc)) + else + self.BtnPanelTask:SetName(config.Desc) + end + else + self.IconTaskComplete.gameObject:SetActiveEx(true) + self.BtnPanelTask:SetName(CS.XTextManager.GetText("WhiteValentineMissionComplete")) + end +end + +function XUiWhiteValenMainButtonPanel:RefreshPanel() + self:RefreshEncounterBtn() + self:RefreshInviteBtn() + self:RefreshMission() +end + +--================ +--注册页面红点事件 +--================ +function XUiWhiteValenMainButtonPanel:AddRedPointEvents() + if self.AlreadyAddRed then return end + self.AlreadyAddRed = true + table.insert(self.RedEvents, XRedPointManager.AddRedPointEvent(self.BtnInvite, self.CheckInviteRedDot, self, { XRedPointConditions.Types.CONDITION_WHITEVALENTINE2021_INVITE })) + table.insert(self.RedEvents, XRedPointManager.AddRedPointEvent(self.BtnEncounter, self.CheckEncounterRedDot, self, { XRedPointConditions.Types.CONDITION_WHITEVALENTINE2021_ENCOUNTER })) + table.insert(self.RedEvents, XRedPointManager.AddRedPointEvent(self.BtnTask, self.CheckTaskRedDot, self, { XRedPointConditions.Types.CONDITION_WHITEVALENTINE2021_TASK })) +end +--================ +--注销页面红点事件 +--================ +function XUiWhiteValenMainButtonPanel:RemoveRedPointEvents() + if not self.AlreadyAddRed then return end + for _, eventId in pairs(self.RedEvents) do + XRedPointManager.RemoveRedPointEvent(eventId) + end + self.RedEvents = {} + self.AlreadyAddRed = false +end +--================ +--检查邀约按钮红点 +--================ +function XUiWhiteValenMainButtonPanel:CheckInviteRedDot(count) + self.BtnInvite:ShowReddot(count >= 0) +end +--================ +--检查偶遇按钮红点 +--================ +function XUiWhiteValenMainButtonPanel:CheckEncounterRedDot(count) + self.BtnEncounter:ShowReddot(count >= 0) +end +--================ +--检查任务按钮红点 +--================ +function XUiWhiteValenMainButtonPanel:CheckTaskRedDot(count) + self.BtnTask:ShowReddot(count >= 0) + self:RefreshMission() +end +return XUiWhiteValenMainButtonPanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenMainEventPanel.lua b/Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenMainEventPanel.lua new file mode 100644 index 00000000..64f9bbd5 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenMainEventPanel.lua @@ -0,0 +1,66 @@ +-- 白色情人节约会活动主界面事件面板 +local XUiWhiteValenMainEventPanel = XClass(nil, "XUiWhiteValenMainEventPanel") + +function XUiWhiteValenMainEventPanel:Ctor(rootUi, ui) + XTool.InitUiObjectByUi(self, ui) + self.RootUi = rootUi + self.PlaceManager = XDataCenter.WhiteValentineManager.GetPlaceManager() + self:InitPlaces() +end + +function XUiWhiteValenMainEventPanel:InitPlaces() + self.Places = {} + local places = self.PlaceManager:GetPlaceList() + local XUiPlace = require("XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenPlace") + for _, place in pairs(places) do + local order = place:GetOrderId() + local ui = self["PanelGrid" .. order] + if ui then + local uiPlace = XUiPlace.New(self.RootUi, ui, place) + self.Places[order] = uiPlace + end + end +end + +function XUiWhiteValenMainEventPanel:RefreshPanel() + for _, place in pairs(self.Places) do + place:Refresh() + end +end + +function XUiWhiteValenMainEventPanel:RefreshPlaces(placeId) + local place = self.PlaceManager:GetPlaceByPlaceId(placeId) + local uiPlace = self.Places[place:GetOrderId()] + if uiPlace then uiPlace:Refresh() end + return uiPlace +end + +function XUiWhiteValenMainEventPanel:OpenNewPlaces(placeDatas) + if not placeDatas then return end + for _, placeData in pairs(placeDatas) do + local uiPlace = self:RefreshPlaces(placeData.Id) + if uiPlace.AnimOpen then uiPlace.AnimOpen:Play() end + if uiPlace.OpenEffect then uiPlace.OpenEffect.gameObject:SetActiveEx(true) end + end +end + +function XUiWhiteValenMainEventPanel:AddEventListeners() + if self.ListenersAdded then return end + self.ListenersAdded = true + XEventManager.AddEventListener(XEventId.EVENT_WHITEVALENTINE_SHOW_PLACE, self.RefreshPanel, self) + XEventManager.AddEventListener(XEventId.EVENT_WHITEVALENTINE_REFRESH_PLACE, self.RefreshPlaces, self) + XEventManager.AddEventListener(XEventId.EVENT_WHITEVALENTINE_OPEN_PLACE, self.OpenNewPlaces, self) +end + +function XUiWhiteValenMainEventPanel:RemoveEventListeners() + if not self.ListenersAdded then return end + XEventManager.RemoveEventListener(XEventId.EVENT_WHITEVALENTINE_SHOW_PLACE, self.RefreshPanel, self) + XEventManager.RemoveEventListener(XEventId.EVENT_WHITEVALENTINE_REFRESH_PLACE, self.RefreshPlaces, self) + XEventManager.RemoveEventListener(XEventId.EVENT_WHITEVALENTINE_OPEN_PLACE, self.OpenNewPlaces, self) + for _, place in pairs(self.Places) do + place:RemoveDispatchingTimer() + end + self.ListenersAdded = false +end + +return XUiWhiteValenMainEventPanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenPlace.lua b/Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenPlace.lua new file mode 100644 index 00000000..2c6cce81 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenPlace.lua @@ -0,0 +1,75 @@ +-- 白色情人节约会小游戏地点UI控件 +local XUiWhiteValenPlace = XClass(nil, "XUiWhiteValenPlace") + +function XUiWhiteValenPlace:Ctor(rootUi, ui, place) + XTool.InitUiObjectByUi(self, ui) + self.RootUi = rootUi + self.Place = place + self:Refresh() + self.BtnDispatch.CallBack = function() self:OnBtnDispatch() end + self.BtnReward.CallBack = function() self:OnBtnReward() end +end + +function XUiWhiteValenPlace:Refresh() + if not self.Place:GetIsOpen() then self.GameObject:SetActiveEx(false) return end + self.TxtRank.text = self.Place:GetEventRankName() + self.AttrIcon:SetRawImage(self.Place:GetEventAttrIcon()) + self.PanelReward.gameObject:SetActiveEx(self.Place:CheckCanFinishEvent()) + self.PanelTime.gameObject:SetActiveEx(self.Place:GetIsDispatching()) + self.TxtDispatchCountDown.text = self.Place:GetEventEndTimeString() + local dispatchingChara = self.Place:GetDispatchingChara() + self.RImgHead.gameObject:SetActiveEx(dispatchingChara ~= nil) + if dispatchingChara then self.RImgHead:SetRawImage(dispatchingChara:GetIconPath()) end + if self.Place:GetIsDispatching() then self:SetDispatchingTimer() end + self.BtnDispatch.gameObject:SetActiveEx(not self.Place:CheckCanFinishEvent()) + self.BtnReward.gameObject:SetActiveEx(self.Place:CheckCanFinishEvent()) + self.GameObject:SetActiveEx(true) +end + +function XUiWhiteValenPlace:SetDispatchingTimer() + self.Timer = XScheduleManager.ScheduleForever(function() + local checkExist + local gameObject = self.GameObject + if gameObject and gameObject.Exist then + checkExist = function() return gameObject:Exist() end + end + if checkExist() then + self.TxtDispatchCountDown.text = self.Place:GetEventEndTimeString() + self.PanelTime.gameObject:SetActiveEx(self.Place:GetIsDispatching()) + if not self.Place:GetIsDispatching() then + self:RemoveDispatchingTimer() + self:Refresh() + end + else + self:RemoveDispatchingTimer() + end + end, XScheduleManager.SECOND, 0) +end + +function XUiWhiteValenPlace:RemoveDispatchingTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end + +function XUiWhiteValenPlace:OnBtnDispatch() + if self.Place:GetIsDispatching() then + CsXUiManager.Instance:Open("UiDialog", + CS.XTextManager.GetText("WhiteValentineCancelConfirm"), + CS.XTextManager.GetText("WhiteValentineCancelConfirmContent"), + XUiManager.DialogType.Normal, + nil, + function() XDataCenter.WhiteValentineManager.CancelDispatch(self.Place) end) + else + XLuaUiManager.Open("UiWhitedayReady", self.Place) + end +end + +function XUiWhiteValenPlace:OnBtnReward() + if self.Place:CheckCanFinishEvent() then + XDataCenter.WhiteValentineManager.FinishEvent(self.Place) + end +end + +return XUiWhiteValenPlace \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenTaskDynamicTable.lua b/Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenTaskDynamicTable.lua new file mode 100644 index 00000000..614a89c4 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenTaskDynamicTable.lua @@ -0,0 +1,47 @@ +---@class XUiWhiteValenTaskDynamicTable +local XUiWhiteValenTaskDynamicTable = XClass(nil, "XUiWhiteValenTaskDynamicTable") + +function XUiWhiteValenTaskDynamicTable:Ctor(ui, rootUi) + XTool.InitUiObjectByUi(self, ui) + self.RootUi = rootUi + self.DynamicTable = XDynamicTableNormal.New(self.GameObject) + self.DynamicTable:SetProxy(XDynamicGridTask) + self.DynamicTable:SetDelegate(self) +end +--动态列表事件 +function XUiWhiteValenTaskDynamicTable:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.TaskList[index] + if not data then + return + end + grid.RootUi = self.RootUi + grid:ResetData(data) + end +end +function XUiWhiteValenTaskDynamicTable:UpdateData() + self.TaskList = self:GetTaskList() + self.DynamicTable:SetDataSource(self.TaskList) + self.DynamicTable:ReloadDataASync() + self.RootUi.ImgEmpty.gameObject:SetActiveEx(#self.TaskList <= 0) +end + +function XUiWhiteValenTaskDynamicTable:GetTaskList() + local taskList = XDataCenter.TaskManager.GetWhiteValentineFullTaskList() + for _, v in pairs(taskList or {}) do + v.SortWeight = 2 + if v.State == XDataCenter.TaskManager.TaskState.Achieved then + v.SortWeight = 1 + elseif v.State == XDataCenter.TaskManager.TaskState.Finish or v.State == XDataCenter.TaskManager.TaskState.Invalid then + v.SortWeight = 3 + end + end + table.sort(taskList, function(taskA, taskB) + if taskA.SortWeight == taskB.SortWeight then + return taskA.Id < taskB.Id + end + return taskA.SortWeight < taskB.SortWeight + end) + return taskList +end +return XUiWhiteValenTaskDynamicTable \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValentineDispatch.lua b/Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValentineDispatch.lua new file mode 100644 index 00000000..91040fef --- /dev/null +++ b/Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValentineDispatch.lua @@ -0,0 +1,64 @@ +-- 白色情人节约会活动派遣界面 +local XUiWhiteValentineDispatch = XLuaUiManager.Register(XLuaUi, "UiWhitedayReady") + +function XUiWhiteValentineDispatch:OnAwake() + XTool.InitUiObject(self) + self.BtnClose.CallBack = function() self:OnBtnClose() end + self.BtnStart.CallBack = function() self:OnBtnStart() end +end + +function XUiWhiteValentineDispatch:OnStart(place) + self.Place = place + self.AttrActive.gameObject:SetActiveEx(false) + if self.AttrInActive then self.AttrInActive.gameObject:SetActiveEx(true) end + self.ImgAttrIcon:SetRawImage(self.Place:GetEventAttrIcon()) + if self.ImgInActiveAttrIcon then self.ImgInActiveAttrIcon:SetRawImage(self.Place:GetEventAttrIcon()) end + self.GridChara.gameObject:SetActiveEx(false) + self:InitPanels() + self:RefreshPanel() +end + +function XUiWhiteValentineDispatch:InitPanels() + self:InitPanelPlace() + self:InitPanelReward() + self:InitPanelChara() +end + +function XUiWhiteValentineDispatch:InitPanelPlace() + local XPanelPlace = require("XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenDispatchPanelPlace") + self.PlacePanel = XPanelPlace.New(self, self.PanelLeft, self.Place) +end + +function XUiWhiteValentineDispatch:InitPanelReward() + local XPanelReward = require("XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenDispatchPanelReward") + self.RewardPanel = XPanelReward.New(self, self.PanelReward, self.Place) +end + +function XUiWhiteValentineDispatch:InitPanelChara() + local XPanelChara = require("XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenDispatchMemberDynamicTable") + self.CharaPanel = XPanelChara.New(self, self.MemberList) +end + +function XUiWhiteValentineDispatch:SetDispatchChara(chara) + self.RewardPanel:RefreshChara(chara) + local isAttrActive = chara:GetAttrType() == self.Place:GetEventAttrType() + self.AttrActive.gameObject:SetActiveEx(isAttrActive) + if self.AttrInActive then self.AttrInActive.gameObject:SetActiveEx(not isAttrActive) end + self.DispatchChara = chara +end + +function XUiWhiteValentineDispatch:RefreshPanel() + self.CharaPanel:UpdateData(self.Place:GetEventAttrType()) +end + +function XUiWhiteValentineDispatch:OnBtnClose() + self:Close() +end + +function XUiWhiteValentineDispatch:OnBtnStart() + if self.DispatchChara then + XDataCenter.WhiteValentineManager.CharaDispatch(self.Place, self.DispatchChara, function() self:Close() end) + else + XUiManager.TipMsg(CS.XTextManager.GetText("WhiteValentineNoSelectChara")) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValentineInvite.lua b/Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValentineInvite.lua new file mode 100644 index 00000000..fb5bc9a9 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValentineInvite.lua @@ -0,0 +1,60 @@ +--白色情人节约会邀约界面 +local XUiWhiteValentineInvite = XLuaUiManager.Register(XLuaUi, "UiWhitedayInvite") + +function XUiWhiteValentineInvite:OnAwake() + XTool.InitUiObject(self) + self.CharaManager = XDataCenter.WhiteValentineManager.GetCharaManager() + self:InitMemberList() + self:InitDropDown() + self:InitButtons() + self:OnDropDownValueChanged(0) +end + +function XUiWhiteValentineInvite:InitMemberList() + self.GridChara.gameObject:SetActiveEx(false) + local XDTable = require("XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenInviteMemberDynamicTable") + self.CharaDynamicTable = XDTable.New(self, self.MemberList) +end + +function XUiWhiteValentineInvite:InitDropDown() + local attrs = XWhiteValentineConfig.GetAllWhiteValentineAttr() + for id, attr in pairs(attrs) do + self.DropDownSort.options[id].text = attr.Name + end + self.DropDownSort.onValueChanged:AddListener(function(value) self:OnDropDownValueChanged(value) end) +end + +function XUiWhiteValentineInvite:InitButtons() + self.BtnCancel.CallBack = function() self:OnBtnClose() end + self.BtnTanchuangClose.CallBack = function() self:OnBtnClose() end + self.BtnStartWork.CallBack = function() self:OnBtnInvite() end +end + +function XUiWhiteValentineInvite:OnDropDownValueChanged(value) + if value == 0 then + local allChara = self.CharaManager:GetAllOutTeamChara() + self.CharaDynamicTable:UpdateData(allChara) + else + local charaList = self.CharaManager:GetOutTeamCharaByAttrType(value) + if charaList == nil or #charaList == 0 then + XUiManager.TipMsg(CS.XTextManager.GetText("WhiteValentineAttrCharaComplete")) + end + self.CharaDynamicTable:UpdateData(charaList) + end +end + +function XUiWhiteValentineInvite:OnBtnClose() + self:Close() +end + +function XUiWhiteValentineInvite:OnBtnInvite() + if self.InviteChara then + XDataCenter.WhiteValentineManager.InviteChara(self.InviteChara, function() self:OnBtnClose() end) + else + XUiManager.TipMsg(CS.XTextManager.GetText("WhiteValentineNoInviteChara")) + end +end + +function XUiWhiteValentineInvite:SetInviteChara(chara) + self.InviteChara = chara +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValentineMain.lua b/Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValentineMain.lua new file mode 100644 index 00000000..08ae8a52 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValentineMain.lua @@ -0,0 +1,197 @@ +--白色情人节约会活动主界面 +local XUiWhiteValentineMain = XLuaUiManager.Register(XLuaUi, "UiWhitedayMain") +local XUiCommonAsset = require("XUi/XUiCommon/XUiCommonAsset") +function XUiWhiteValentineMain:OnAwake() + XTool.InitUiObject(self) +end + +function XUiWhiteValentineMain:OnStart() + self.GameController = XDataCenter.WhiteValentineManager.GetGameController() + self:InitButtons() + self:InitPanels() +end + +function XUiWhiteValentineMain:OnEnable() + self:SetGameTimer() + self:SetTimer() + self:AddEventListeners() + XDataCenter.WhiteValentineManager.OnEnterActivity() +end + +function XUiWhiteValentineMain:OnDisable() + self:StopTimer() + self:RemoveEventListeners() +end + +function XUiWhiteValentineMain:OnDestroy() + self:StopTimer() + self:RemoveEventListeners() +end +--================ +--设置页面计时器 +--================ +function XUiWhiteValentineMain:SetTimer() + self:StopTimer() + self.Timer = XScheduleManager.ScheduleForever(function() + self:SetEnergyTimer() + self:SetGameTimer() + end, XScheduleManager.SECOND, 0) +end +--================ +--设置体力恢复计时器 +--================ +function XUiWhiteValentineMain:SetEnergyTimer() + if self.GameController:CheckIsMaxEnergy() then return end + local now = XTime.GetServerNowTimestamp() + if self.GameController:GetNextEnergyRecoveryTimeStamp() == 0 then + return + elseif self.GameController:GetNextEnergyRecoveryTimeStamp() == now then + self.GameController:AddOneEnergy() + self.GameController:CalculateNextEnergyRecoveryTimeStamp() + elseif self.GameController:GetNextEnergyRecoveryTimeStamp() < now then + self.GameController:CalculateDeltaEnergyRecoveryTimeStamp() + end +end +--================ +--设置活动倒计时 +--================ +function XUiWhiteValentineMain:SetGameTimer() + local endTimeSecond = self.GameController:GetActivityEndTime() + local now = XTime.GetServerNowTimestamp() + local leftTime = endTimeSecond - now + self.TxtTime.text = XUiHelper.GetTime(leftTime, XUiHelper.TimeFormatType.ACTIVITY) + if leftTime <= 0 then + self:OnGameEnd() + end +end +--================ +--停止计时器 +--================ +function XUiWhiteValentineMain:StopTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end + +function XUiWhiteValentineMain:OnGetEvents() + return { XEventId.EVENT_WHITEVALENTINE_ENCOUNTER_CHARA, + XEventId.EVENT_WHITEVALENTINE_INVITE_CHARA, + XEventId.EVENT_WHITEVALENTINE_REFRESH_PLACE, + XEventId.EVENT_WHITEVALENTINE_OPEN_PLACE } +end + +function XUiWhiteValentineMain:OnNotify(evt, ...) + local args = { ... } + if evt == XEventId.EVENT_WHITEVALENTINE_ENCOUNTER_CHARA then + self.ButtonPanel:RefreshPanel() + XLuaUiManager.Open("UiWhitedayObtain", args[1], XDataCenter.WhiteValentineManager.StoryType.Encounter) + elseif evt == XEventId.EVENT_WHITEVALENTINE_INVITE_CHARA then + self.ButtonPanel:RefreshPanel() + XLuaUiManager.Open("UiWhitedayObtain", args[1], XDataCenter.WhiteValentineManager.StoryType.Invite) + elseif evt == XEventId.EVENT_WHITEVALENTINE_REFRESH_PLACE then + self.ButtonPanel:RefreshPanel() + self.EventPanel:RefreshPlaces(args[1]) + elseif evt == XEventId.EVENT_WHITEVALENTINE_OPEN_PLACE then + self.EventPanel:OpenNewPlaces(args[1]) + end +end +--================ +--初始化按钮 +--================ +function XUiWhiteValentineMain:InitButtons() + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + self.BtnHelp.CallBack = function() self:OnBtnHelpClick() end +end +--================ +--返回按钮 +--================ +function XUiWhiteValentineMain:OnBtnBackClick() + self:Close() +end +--================ +--主界面按钮 +--================ +function XUiWhiteValentineMain:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end +--================ +--帮助按钮 +--================ +function XUiWhiteValentineMain:OnBtnHelpClick() + XUiManager.ShowHelpTip("WhiteValentine2021Help") +end +--================ +--初始化面板 +--================ +function XUiWhiteValentineMain:InitPanels() + self:InitButtonPanel() + self:InitEventPanel() + self:InitAssetPanel() +end +--================ +--初始化功能按钮面板 +--================ +function XUiWhiteValentineMain:InitButtonPanel() + local ButtonPanel = require("XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenMainButtonPanel") + self.ButtonPanel = ButtonPanel.New(self, self.PanelButton) +end +--================ +--初始化地点事件面板 +--================ +function XUiWhiteValentineMain:InitEventPanel() + local EventPanel = require("XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenMainEventPanel") + self.EventPanel = EventPanel.New(self, self.PanelEvent) +end +--================ +--初始化右上角的资源道具面板 +--================ +function XUiWhiteValentineMain:InitAssetPanel() + local AssetsList = {} + local assetItem1 = { + ShowType = XUiCommonAsset.ShowType.BagItem, + ItemId = self.GameController:GetContributionItemId(), + } + table.insert(AssetsList, assetItem1) + local assetItem2 = { + ShowType = XUiCommonAsset.ShowType.BagItem, + ItemId = self.GameController:GetCoinItemId() + } + table.insert(AssetsList, assetItem2) + local assetItem3 = { + ShowType = XUiCommonAsset.ShowType.RecoverPoint, + Icon = self.GameController:GetEnergyIconPath(), + GetCountFunc = function() return self.GameController:GetEnergy() end, + GetMaxCountFunc = function() return self.GameController:GetMaxEnergy() end, + ChangeEventId = XEventId.EVENT_WHITEVALENTINE_ENERGY_REFRESH + } + table.insert(AssetsList, assetItem3) + local AssetPanel = require("XUi/XUiCommon/XUiCommonAssetPanel") + self.AssetPanel = AssetPanel.New(self.PanelAsset, AssetsList) + self.TxtEnergyRecover.text = CS.XTextManager.GetText("WhiteValentineEnergyCountDown", XUiHelper.GetTime(self.GameController:GetEnergyRecoverySpeed(), XUiHelper.TimeFormatType.CHATEMOJITIMER)) +end +--================ +--活动结束时处理 +--================ +function XUiWhiteValentineMain:OnGameEnd() + if self.IsReseting then return end + self.IsReseting = true + self:StopTimer() + XLuaUiManager.RunMain() + XUiManager.TipMsg(CS.XTextManager.GetText("CommonActivityEnd")) +end +--================ +--添加事件 +--================ +function XUiWhiteValentineMain:AddEventListeners() + self.ButtonPanel:AddEventListeners() + self.EventPanel:AddEventListeners() +end +--================ +--移除事件 +--================ +function XUiWhiteValentineMain:RemoveEventListeners() + self.ButtonPanel:RemoveEventListeners() + self.EventPanel:RemoveEventListeners() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValentineStory.lua b/Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValentineStory.lua new file mode 100644 index 00000000..1b1998f2 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValentineStory.lua @@ -0,0 +1,36 @@ +-- 白色情人节约会活动邀约故事UI控件 +local XUiWhiteValentineStory = XLuaUiManager.Register(XLuaUi, "UiWhitedayObtain") + +function XUiWhiteValentineStory:OnAwake() + XTool.InitUiObject(self) + self:InitButtons() +end + +function XUiWhiteValentineStory:OnStart(chara, storyType) + self.Chara = chara + self.StoryType = storyType + self:InitStory() + self:InitChara() +end + +function XUiWhiteValentineStory:InitButtons() + self:RegisterClickEvent(self.BtnSure, function() self:OnBtnClose() end) +end + +function XUiWhiteValentineStory:OnBtnClose() + self:Close() +end + +function XUiWhiteValentineStory:InitStory() + local storyCfg = self.Chara:GetStoryByStoryType(self.StoryType) + if storyCfg then + self.TxtTitle.text = storyCfg.Title + self.TxtStory.text = storyCfg.StoryText + end +end + +function XUiWhiteValentineStory:InitChara() + local XCharaGrid = require("XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenInviteCharaGrid") + XCharaGrid.New(self.GridChara, self.Chara) +end + diff --git a/Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValentineTask.lua b/Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValentineTask.lua new file mode 100644 index 00000000..9c364aa5 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValentineTask.lua @@ -0,0 +1,135 @@ +-- 白色情人节约会活动任务界面 +local XUiWhiteValentineTask = XLuaUiManager.Register(XLuaUi, "UiWhitedayTask") +local TaskList = require("XUi/XUiMiniGame/WhiteValentine2021/XUiWhiteValenTaskDynamicTable") +local XUiCommonAsset = require("XUi/XUiCommon/XUiCommonAsset") +function XUiWhiteValentineTask:OnAwake() + XTool.InitUiObject(self) + self.GridTask.gameObject:SetActiveEx(false) + self.GameController = XDataCenter.WhiteValentineManager.GetGameController() + self:InitButtons() + self:InitAssetPanel() + self:InitTaskList() +end + +function XUiWhiteValentineTask:OnEnable() + self:AddEventListeners() + self:OnShowPanel() + self:SetTimer() +end + +function XUiWhiteValentineTask:OnDisable() + self:StopTimer() + self:RemoveEventListeners() +end + +function XUiWhiteValentineTask:OnDestroy() + self:StopTimer() + self:RemoveEventListeners() +end +--================ +--初始化按钮 +--================ +function XUiWhiteValentineTask:InitButtons() + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end +end +--================ +--返回按钮 +--================ +function XUiWhiteValentineTask:OnBtnBackClick() + self:Close() +end +--================ +--主界面按钮 +--================ +function XUiWhiteValentineTask:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end +--================ +--初始化右上角的资源道具面板 +--================ +function XUiWhiteValentineTask:InitAssetPanel() + local AssetsList = {} + local assetItem1 = { + ShowType = XUiCommonAsset.ShowType.BagItem, + ItemId = self.GameController:GetContributionItemId(), + } + table.insert(AssetsList, assetItem1) + local AssetPanel = require("XUi/XUiCommon/XUiCommonAssetPanel") + self.AssetPanel = AssetPanel.New(self.PanelAsset, AssetsList) +end +--================ +--初始化界面面板 +--================ +function XUiWhiteValentineTask:InitTaskList() + self.TaskList = TaskList.New(self.SViewTask, self) +end +--================ +--显示界面时 +--================ +function XUiWhiteValentineTask:OnShowPanel() + self.TaskList:UpdateData() +end +--================ +--设置界面计时器 +--================ +function XUiWhiteValentineTask:SetTimer() + self:StopTimer() + self:SetResetTime() + self.Timer = XScheduleManager.ScheduleForever(function() + self:SetResetTime() + end, XScheduleManager.SECOND, 0) +end +--================ +--显示倒计时与处理倒计时完成时事件 +--================ +function XUiWhiteValentineTask:SetResetTime() + local endTimeSecond = self.GameController:GetActivityEndTime() + local now = XTime.GetServerNowTimestamp() + local leftTime = endTimeSecond - now + if leftTime <= 0 then + self:OnActivityReset() + end +end +--================ +--停止界面计时器 +--================ +function XUiWhiteValentineTask:StopTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end + +--================ +--活动周期结束时弹回主界面 +--================ +function XUiWhiteValentineTask:OnActivityReset() + self:StopTimer() + XLuaUiManager.RunMain() + XUiManager.TipMsg(CS.XTextManager.GetText("CommonActivityEnd")) +end + +--================ +--刷新任务列表 +--================ +function XUiWhiteValentineTask:RefreshTasks() + self.TaskList:UpdateData() +end + +--================ +--增加事件监听 +--================ +function XUiWhiteValentineTask:AddEventListeners() + if self.AlreadyAddEvents then return end + self.AlreadyAddEvents = true + XEventManager.AddEventListener(XEventId.EVENT_TASK_SYNC, self.RefreshTasks, self) +end +--================ +--移除事件监听 +--================ +function XUiWhiteValentineTask:RemoveEventListeners() + if not self.AlreadyAddEvents then return end + self.AlreadyAddEvents = false + XEventManager.RemoveEventListener(XEventId.EVENT_TASK_SYNC, self.RefreshTasks, self) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMission/XUiGridConditionTxt.lua b/Resources/Scripts/XUi/XUiMission/XUiGridConditionTxt.lua new file mode 100644 index 00000000..0f728c4e --- /dev/null +++ b/Resources/Scripts/XUi/XUiMission/XUiGridConditionTxt.lua @@ -0,0 +1,79 @@ +local XUiGridConditionTxt = XClass(nil, "XUiGridConditionTxt") + +function XUiGridConditionTxt:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self:InitAutoScript() +end + + +function XUiGridConditionTxt:SetupExtraContent(menberCount,charIds) + + self.TxtDes.text = string.format(CS.XTextManager.GetText("MissionTaskTeamMember"),menberCount) + self.TxtDesAct.text = string.format(CS.XTextManager.GetText("MissionTaskTeamMember"),menberCount) + + local enough = #charIds >= menberCount + self.TxtDes.gameObject:SetActive(not enough) + self.TxtDesAct.gameObject:SetActive(enough) +end + +function XUiGridConditionTxt:SetupContent(conditionId,charIds) + local template = XConditionManager.GetConditionTemplate(conditionId) + if template then + self.TxtDes.text = template.Desc + self.TxtDesAct.text = template.Desc + end + + self.CharacterIds = charIds + local enough = XConditionManager.CheckCondition(conditionId, self.CharacterIds) + self.TxtDes.gameObject:SetActive(not enough) + self.TxtDesAct.gameObject:SetActive(enough) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiGridConditionTxt:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiGridConditionTxt:AutoInitUi() + self.TxtDesAct = XUiHelper.TryGetComponent(self.Transform, "TxtDesAct", "Text") + self.TxtDes = XUiHelper.TryGetComponent(self.Transform, "TxtDes", "Text") +end + +function XUiGridConditionTxt:GetAutoKey(uiNode,eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiGridConditionTxt:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiGridConditionTxt:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key],eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiGridConditionTxt:AutoAddListener() + self.AutoCreateListeners = {} +end +-- auto + +return XUiGridConditionTxt diff --git a/Resources/Scripts/XUi/XUiMission/XUiGridLimit.lua b/Resources/Scripts/XUi/XUiMission/XUiGridLimit.lua new file mode 100644 index 00000000..4118463b --- /dev/null +++ b/Resources/Scripts/XUi/XUiMission/XUiGridLimit.lua @@ -0,0 +1,74 @@ +XUiGridLimit = XClass(nil, "XUiGridLimit") + +function XUiGridLimit:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self:InitAutoScript() +end + +function XUiGridLimit:SetupContent(data,curId) + if not data then + return + end + + self.PanelLock.gameObject:SetActive(data.Id > curId) + self.PanelOpen.gameObject:SetActive(data.Id <= curId) + + local condition = XConditionManager.GetConditionTemplate(data.ConditionId) + self.Txt1.text = tostring(data.MaxTaskForceCount) + self.Txt1A.text = tostring(data.MaxTaskForceCount) + + self.Txt2A.text = tostring(condition.Desc) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiGridLimit:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiGridLimit:AutoInitUi() + self.PanelOpen = self.Transform:Find("PanelOpen") + self.Txt1 = self.Transform:Find("PanelOpen/Txt1"):GetComponent("Text") + self.Txt2 = self.Transform:Find("PanelOpen/Txt2"):GetComponent("Text") + self.PanelLock = self.Transform:Find("PanelLock") + self.Txt1A = self.Transform:Find("PanelLock/Txt1"):GetComponent("Text") + self.Txt2A = self.Transform:Find("PanelLock/Txt2"):GetComponent("Text") +end + +function XUiGridLimit:GetAutoKey(uiNode,eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiGridLimit:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiGridLimit:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key],eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiGridLimit:AutoAddListener() + self.AutoCreateListeners = {} +end +-- auto + +return XUiGridLimit \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMission/XUiGridMissionCommon.lua b/Resources/Scripts/XUi/XUiMission/XUiGridMissionCommon.lua new file mode 100644 index 00000000..52f7300b --- /dev/null +++ b/Resources/Scripts/XUi/XUiMission/XUiGridMissionCommon.lua @@ -0,0 +1,9 @@ +local XUiGridCommon = require("XUi/XUiObtain/XUiGridCommon") +local XUiGridMissionCommon = XClass(XUiGridCommon, "XUiGridMissionCommon") + +function XUiGridMissionCommon:Ctor(rootUi, ui) + self.ImgBig = XUiHelper.TryGetComponent(self.Transform, "ImgBig", "Image") + self.ImgAdditional = XUiHelper.TryGetComponent(self.Transform, "ImgAdditional", "Image") +end + +return XUiGridMissionCommon diff --git a/Resources/Scripts/XUi/XUiMission/XUiGridMisssionTeam.lua b/Resources/Scripts/XUi/XUiMission/XUiGridMisssionTeam.lua new file mode 100644 index 00000000..03d29d94 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMission/XUiGridMisssionTeam.lua @@ -0,0 +1,82 @@ +XUiGridMisssionTeam = XClass(nil, "XUiGridMisssionTeam") + +function XUiGridMisssionTeam:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self:InitAutoScript() +end + +function XUiGridMisssionTeam:Init(rootUi) + self.RootUi = rootUi + +end + +function XUiGridMisssionTeam:Reset() + self:SetSelect(false) +end + +function XUiGridMisssionTeam:UpdateGrid(character) + self.Character = character + self.ImgInTeam.gameObject:SetActive(self.Character.IsWorking and self.Character.IsWorking > 0) + self.TxtLevel.text = self.Character.Level + self.RootUi:SetUiSprite(self.ImgQuality, XCharacterConfigs.GetCharacterQualityIcon(self.Character.Quality)) + self.RootUi:SetUiSprite(self.ImgHeadIcon, XDataCenter.CharacterManager.GetCharSmallHeadIcon(self.Character.Id)) +end + +function XUiGridMisssionTeam:SetSelect(isSelect) + self.ImgSelected.gameObject:SetActive(isSelect) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiGridMisssionTeam:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiGridMisssionTeam:AutoInitUi() + self.PanelHead = self.Transform:Find("PanelHead") + self.ImgHeadIconBg = self.Transform:Find("PanelHead/ImgHeadIconBg"):GetComponent("Image") + self.ImgHeadIcon = self.Transform:Find("PanelHead/ImgHeadIcon"):GetComponent("Image") + self.PanelLevel = self.Transform:Find("PanelLevel") + self.TxtLevel = self.Transform:Find("PanelLevel/TxtLevel"):GetComponent("Text") + self.ImgQuality = self.Transform:Find("ImgQuality"):GetComponent("Image") + self.ImgInTeam = self.Transform:Find("ImgInTeam"):GetComponent("Image") + self.PanelSelected = self.Transform:Find("PanelSelected") + self.ImgSelected = self.Transform:Find("PanelSelected/ImgSelected"):GetComponent("Image") +end + +function XUiGridMisssionTeam:GetAutoKey(uiNode,eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiGridMisssionTeam:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiGridMisssionTeam:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key],eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiGridMisssionTeam:AutoAddListener() + self.AutoCreateListeners = {} +end +-- auto +return XUiGridMisssionTeam \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMission/XUiMission.lua b/Resources/Scripts/XUi/XUiMission/XUiMission.lua new file mode 100644 index 00000000..be13aaae --- /dev/null +++ b/Resources/Scripts/XUi/XUiMission/XUiMission.lua @@ -0,0 +1,332 @@ +local XUiMission = XLuaUiManager.Register(XLuaUi, "UiMission") + +function XUiMission:OnAwake() + self:InitAutoScript() +end + +function XUiMission:OnStart() + + self:Init() + self:SetupContent() + +end + +function XUiMission:OnEnable() + if self.DynamicTable then + self.DynamicTable:ReloadDataASync() + end + + self:PlayAnimation("AniMissionBegin") +end + +function XUiMission:Init() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + + self.DynamicTable = XDynamicTableNormal.New(self.PanelTaskList) + self.DynamicTable:SetProxy(XUiPanelMissionGrid) + self.DynamicTable:SetDelegate(self) + + self.Timer = nil + self.PanelPointRect = self.PanelPreview:GetComponent("RectTransform") + self.CompletetTaskList = {} + local sections = XDataCenter.TaskForceManager.GetTaskForceSectionConfig() + self.PanelArea.gameObject:SetActive(false) + self.ProgressPoint = {} + for _, v in pairs(sections) do + local point = CS.UnityEngine.Object.Instantiate(self.PanelArea) + point.transform:SetParent(self.PanelPreview, false) + point.gameObject:SetActive(true) + local area = XUiPanelArea.New(point, v, self) + table.insert(self.ProgressPoint, area) + end + + XEventManager.AddEventListener(XEventId.EVENT_TASKFORCE_REFRESH_REQUEST, self.SetupContent, self) + XEventManager.AddEventListener(XEventId.EVENT_TASKFORCE_ACCEPT_TASK_REQUEST, self.SetupContent, self) + XEventManager.AddEventListener(XEventId.EVENT_TASKFORCE_GIVEUP_TASK_REQUEST, self.SetupContent, self) + XEventManager.AddEventListener(XEventId.EVENT_TASKFORCE_ACCEPT_REWARD_REQUEST, self.SetupContent, self) + XEventManager.AddEventListener(XEventId.EVENT_TASKFORCE_COMPLETE_NOTIFY, self.OnTaskComplete, self) + XEventManager.AddEventListener(XEventId.EVENT_TASKFORCE_TASKFINISH_REQUEST, self.OnTaskComplete, self) + XEventManager.AddEventListener(XEventId.EVENT_TASKFORCE_SECTIONCHANGE_NOTIFY, self.SetupContent, self) + XEventManager.AddEventListener(XEventId.EVENT_TASKFORCE_INFO_NOTIFY, self.SetupContent, self) + + +end + +function XUiMission:OnDestroy() + XEventManager.RemoveEventListener(XEventId.EVENT_TASKFORCE_INFO_NOTIFY, self.SetupContent, self) + XEventManager.RemoveEventListener(XEventId.EVENT_TASKFORCE_REFRESH_REQUEST, self.SetupContent, self) + XEventManager.RemoveEventListener(XEventId.EVENT_TASKFORCE_ACCEPT_TASK_REQUEST, self.SetupContent, self) + XEventManager.RemoveEventListener(XEventId.EVENT_TASKFORCE_GIVEUP_TASK_REQUEST, self.SetupContent, self) + XEventManager.RemoveEventListener(XEventId.EVENT_TASKFORCE_ACCEPT_REWARD_REQUEST, self.SetupContent, self) + XEventManager.RemoveEventListener(XEventId.EVENT_TASKFORCE_COMPLETE_NOTIFY, self.OnTaskComplete, self) + XEventManager.RemoveEventListener(XEventId.EVENT_TASKFORCE_TASKFINISH_REQUEST, self.OnTaskComplete, self) + XEventManager.RemoveEventListener(XEventId.EVENT_TASKFORCE_SECTIONCHANGE_NOTIFY, self.SetupContent, self) + self:StopTimer() +end + + +--任务完成 +function XUiMission:OnTaskComplete(taskList) + if taskList then + for _, v in pairs(taskList) do + for index, task in ipairs(self.AllTasks) do + if task.Task.TaskId == v then + local grid = self.DynamicTable:GetGridByIndex(index) + if grid ~= nil then + grid:PlayCompletedAnimation(function() + grid:SetupContent(task) + end) + end + end + end + end + end +end + +--设置内容 +function XUiMission:SetupContent() + self.MissionData = XDataCenter.TaskForceManager.GetTaskForeInfo() + if not self.MissionData then + return + end + + self:SetupTaskPool() + self:SetupRefresh() + self:SetupTaskChapter() +end + +--设置任务 +function XUiMission:SetupTaskPool() + + local id = self.MissionData.ConfigIndex + local taskList = self.MissionData.TaskList + + local taskCount = 0 + for _, v in ipairs(taskList) do + if v.Status ~= XDataCenter.TaskForceManager.TaskForceTaskStatus.Normal then + taskCount = taskCount + 1 + end + end + + local taskForeCfg = XDataCenter.TaskForceManager.GetTaskForceConfigById(id) + if taskForeCfg then + self.TxtSending.text = tostring(taskForeCfg.MaxTaskForceCount) + end + + local taskPools = XDataCenter.TaskForceManager.GetTaskPoolInfo() + if not taskPools then + return + end + + self.AllTasks = taskPools + self.DynamicTable:SetDataSource(taskPools) + self.DynamicTable:ReloadDataASync(1) +end + +--设置刷新 +function XUiMission:SetupRefresh() + + local refreshCount = self.MissionData.RefreshCount + local refreshCfg = XDataCenter.TaskForceManager.GetRefreshInfoByTimes(refreshCount + 1) + self.RefeshCfg = refreshCfg + if refreshCfg then + local item = XDataCenter.ItemManager.GetItem(refreshCfg.ItemId) + --self:SetUiSprite(self.RImgCostIcon, item.Template.Icon) + self.RImgCostIcon:SetRawImage(item.Template.Icon) + self.TxtCost.text = tostring(refreshCfg.ItemCount) + end + + --剩余免费重置次数 + local totalFreeRefreshCount = XDataCenter.TaskForceManager.GetTotalFreeRefreshTimes() + local leftTimes = totalFreeRefreshCount - refreshCount + leftTimes = leftTimes >= 0 and leftTimes or 0 + + self.BtnRefreshFree.gameObject:SetActive(leftTimes > 0) + self.BtnRefresh.gameObject:SetActive(leftTimes <= 0) + -- self.TxtResetCount.text = tostring(leftTimes) + local nextRefreshTime = XDataCenter.TaskForceManager.GetNextRefreshTime() + local curTime = XTime.GetServerNowTimestamp() + + self:UpdateTime() + if nextRefreshTime > curTime then + self:StartTimer() + end + +end + +function XUiMission:StartTimer() + if self.Timer then + self:StopTimer() + end + + self.Timer = XScheduleManager.ScheduleForever(function() + self:UpdateTime() + end, XScheduleManager.SECOND) +end + +function XUiMission:StopTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end + +function XUiMission:UpdateTime() + + local curTime = XTime.GetServerNowTimestamp() + local nextRefreshTime = XDataCenter.TaskForceManager.GetNextRefreshTime() + + if not self.TxtTimeRefresh:Exist() then + return + end + + local offset = nextRefreshTime - curTime + if offset > 0 then + self.TxtTimeRefresh.text = CS.XDateUtil.SecondsToTimeString(math.ceil(offset)) + else + self.TxtTimeRefresh.text = "00:00:00" + self:StopTimer() + end +end + +--设置章节信息 +function XUiMission:SetupTaskChapter() + local sectionId = self.MissionData.SectionId + -- local sectionCount = XDataCenter.TaskForceManager.GetTotalTaskForeSectionCount() + local taskSectionCfg = XDataCenter.TaskForceManager.GetTaskForceSectionConfigById(sectionId) + + if not self.ProgressPoint then + return + end + + for _, v in pairs(self.ProgressPoint) do + v:SetCurSection(taskSectionCfg) + end + +end + +--动态列表事件 +function XUiMission:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.AllTasks[index] + grid:SetupContent(data) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_RECYCLE then + grid:OnRecycle() + end +end + + +-- auto +-- Automatic generation of code, forbid to edit +function XUiMission:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiMission:AutoInitUi() + -- self.PanelTopBtn = self.Transform:Find("SafeAreaContentPane/PanelTopBtn") + -- self.BtnBack = self.Transform:Find("SafeAreaContentPane/PanelTopBtn/BtnBack"):GetComponent("Button") + -- self.BtnMainUi = self.Transform:Find("SafeAreaContentPane/PanelTopBtn/BtnMainUi"):GetComponent("Button") + -- self.PanelAsset = self.Transform:Find("SafeAreaContentPane/PanelAsset") + -- self.PanelTask = self.Transform:Find("SafeAreaContentPane/PanelTask") + -- self.PanelTaskList = self.Transform:Find("SafeAreaContentPane/PanelTask/PanelTaskList") + -- self.PanelTop = self.Transform:Find("SafeAreaContentPane/PanelTop") + -- self.PanelTimeRefresh = self.Transform:Find("SafeAreaContentPane/PanelTop/PanelTimeRefresh") + -- self.TxtTimeRefresh = self.Transform:Find("SafeAreaContentPane/PanelTop/PanelTimeRefresh/TxtTimeRefresh"):GetComponent("Text") + -- self.PanelResetCount = self.Transform:Find("SafeAreaContentPane/PanelTop/PanelResetCount") + -- self.TxtResetCount = self.Transform:Find("SafeAreaContentPane/PanelTop/PanelResetCount/TxtResetCount"):GetComponent("Text") + -- self.PanelSending = self.Transform:Find("SafeAreaContentPane/PanelTop/PanelSending") + -- self.ImgRedTag = self.Transform:Find("SafeAreaContentPane/PanelTop/PanelSending/ImgRedTag"):GetComponent("Image") + -- self.TxtSending = self.Transform:Find("SafeAreaContentPane/PanelTop/PanelSending/TxtSending"):GetComponent("Text") + -- self.BtnTips = self.Transform:Find("SafeAreaContentPane/PanelTop/PanelSending/BtnTips"):GetComponent("Button") + -- self.BtnRefresh = self.Transform:Find("SafeAreaContentPane/PanelTop/BtnRefresh"):GetComponent("Button") + -- self.PanelRefresh = self.Transform:Find("SafeAreaContentPane/PanelTop/BtnRefresh/PanelRefresh") + -- self.RImgCostIcon = self.Transform:Find("SafeAreaContentPane/PanelTop/BtnRefresh/PanelRefresh/RImgCostIcon"):GetComponent("RawImage") + -- self.TxtCost = self.Transform:Find("SafeAreaContentPane/PanelTop/BtnRefresh/PanelRefresh/TxtCost"):GetComponent("Text") + -- self.BtnRefreshFree = self.Transform:Find("SafeAreaContentPane/PanelTop/BtnRefreshFree"):GetComponent("Button") + -- self.PanelDown = self.Transform:Find("SafeAreaContentPane/PanelDown") + -- self.PanelPreview = self.Transform:Find("SafeAreaContentPane/PanelDown/PanelPreview") + -- self.PanelArea = self.Transform:Find("SafeAreaContentPane/PanelDown/PanelPreview/PanelArea") + -- self.BtnPreview = self.Transform:Find("SafeAreaContentPane/PanelDown/BtnPreview"):GetComponent("Button") +end + +function XUiMission:GetAutoKey(uiNode, eventName) + if not uiNode then + return + end + return eventName .. uiNode:GetHashCode() +end + +function XUiMission:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then + return + end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiMission:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiMission:AutoAddListener() + self.AutoCreateListeners = {} + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:RegisterClickEvent(self.BtnTips, self.OnBtnTipsClick) + self:RegisterClickEvent(self.BtnRefresh, self.OnBtnRefreshClick) + self:RegisterClickEvent(self.BtnRefreshFree, self.OnBtnRefreshFreeClick) + self:RegisterClickEvent(self.BtnPreview, self.OnBtnPreviewClick) +end +-- auto +function XUiMission:OnBtnRefreshFreeClick() + self:OnBtnRefreshClick() +end +function XUiMission:OnBtnTipsClick() + XLuaUiManager.Open("UiMissionTeamLimit",self.MissionData.ConfigIndex) +end + +function XUiMission:OnBtnBackClick() + self:Close() +end + +function XUiMission:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiMission:OnBtnRefreshClick() + + local itemName = XDataCenter.ItemManager.GetItemName(self.RefeshCfg.ItemId) + XUiManager.DialogTip(CS.XTextManager.GetText("MissionTeamCountTipTile"), string.format(CS.XTextManager.GetText("MissionRefreshTaskContent"), self.RefeshCfg.ItemCount, itemName), XUiManager.DialogType.Normal, nil, function() + if XDataCenter.TaskForceManager.CheckCanRefresh(self.RefeshCfg.ItemId, self.RefeshCfg.ItemCount) then + XDataCenter.TaskForceManager.TaskForceRefreshRequest(function() + self:PlayAnimation("AniMissionTaskRefresh") + end) + end + end) + +end + +function XUiMission:OnSliderChapterValueChanged() + +end + +function XUiMission:OnBtnPreviewClick() + XLuaUiManager.Open("UiMissionChapter") +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMission/XUiMissionAddSpeedTip.lua b/Resources/Scripts/XUi/XUiMission/XUiMissionAddSpeedTip.lua new file mode 100644 index 00000000..52926ccd --- /dev/null +++ b/Resources/Scripts/XUi/XUiMission/XUiMissionAddSpeedTip.lua @@ -0,0 +1,110 @@ +local XUiMissionAddSpeedTip = XLuaUiManager.Register(XLuaUi, "UiMissionAddSpeedTip") + +function XUiMissionAddSpeedTip:OnAwake() + self:InitAutoScript() +end + +function XUiMissionAddSpeedTip:OnStart(taskData) + self.TaskData = taskData + self:SetupContent() +end + +function XUiMissionAddSpeedTip:SetupContent() + local costItemId = CS.XGame.Config:GetInt("TaskForceItemId") + local elapseMinutes = CS.XGame.Config:GetInt("TaskForceElapseMinutes") + + local curTime = XTime.GetServerNowTimestamp() + local completeTime = self.TaskData.Task.UtcFinishTime + local min = math.ceil((completeTime - curTime) / 60) + + local costCount = math.ceil(min / elapseMinutes) + local itemCount = XDataCenter.ItemManager.GetCount(costItemId) + local icon = XDataCenter.ItemManager.GetItemIcon(costItemId) + + self.TxtCostCount.text = costCount + self.TxtCount.text = itemCount + self:SetUiSprite(self.ImgIcon, icon) + + self.ItemCount = itemCount + self.CostCount = costCount +end + + +-- auto +-- Automatic generation of code, forbid to edit +function XUiMissionAddSpeedTip:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiMissionAddSpeedTip:AutoInitUi() + self.PanelContent = self.Transform:Find("SafeAreaContentPane/PanelContent") + self.TxtTitle = self.Transform:Find("SafeAreaContentPane/PanelContent/TxtTitle"):GetComponent("Text") + self.TxtCount = self.Transform:Find("SafeAreaContentPane/PanelContent/TxtCount"):GetComponent("Text") + self.BtnSure = self.Transform:Find("SafeAreaContentPane/PanelContent/BtnSure"):GetComponent("Button") + self.PanelCost = self.Transform:Find("SafeAreaContentPane/PanelContent/PanelCost") + self.ImgIcon = self.Transform:Find("SafeAreaContentPane/PanelContent/PanelCost/ImgIcon"):GetComponent("Image") + self.Txt = self.Transform:Find("SafeAreaContentPane/PanelContent/PanelCost/Txt"):GetComponent("Text") + self.TxtCostCount = self.Transform:Find("SafeAreaContentPane/PanelContent/PanelCost/TxtCostCount"):GetComponent("Text") + self.BtnCancel = self.Transform:Find("SafeAreaContentPane/PanelContent/BtnCancel"):GetComponent("Button") + self.BtnBg = self.Transform:Find("FullScreenBackground/BtnBg"):GetComponent("Button") +end + +function XUiMissionAddSpeedTip:GetAutoKey(uiNode, eventName) + if not uiNode then + return + end + return eventName .. uiNode:GetHashCode() +end + +function XUiMissionAddSpeedTip:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then + return + end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiMissionAddSpeedTip:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiMissionAddSpeedTip:AutoAddListener() + self.AutoCreateListeners = {} + self:RegisterClickEvent(self.BtnSure, self.OnBtnSureClick) + self:RegisterClickEvent(self.BtnCancel, self.OnBtnCancelClick) + self:RegisterClickEvent(self.BtnBg, self.OnBtnBgClick) +end +-- auto + +function XUiMissionAddSpeedTip:OnBtnCancelClick() + self:Close() +end + +function XUiMissionAddSpeedTip:OnBtnBgClick() + self:Close() +end + +function XUiMissionAddSpeedTip:OnBtnSureClick() + if self.ItemCount < self.CostCount then + XUiManager.TipText("EquipLevelUpItemNotEnough") + return + end + + XDataCenter.TaskForceManager.TaskForceTaskFinishRequest(self.TaskData.Task.TaskId) + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMission/XUiMissionChapter.lua b/Resources/Scripts/XUi/XUiMission/XUiMissionChapter.lua new file mode 100644 index 00000000..0f4f2b2d --- /dev/null +++ b/Resources/Scripts/XUi/XUiMission/XUiMissionChapter.lua @@ -0,0 +1,99 @@ +local XUiMissionChapter = XLuaUiManager.Register(XLuaUi, "UiMissionChapter") + +function XUiMissionChapter:OnAwake() + self:InitAutoScript() +end + +function XUiMissionChapter:OnStart() + self:Init() + self:SetupChapter() + self:PlayAnimation("AniMissionChapterBegin") +end + +function XUiMissionChapter:Init() + self.DynamicTable = XDynamicTableNormal.New(self.PanelScroll) + self.DynamicTable:SetProxy(XUiPanelMissionChapterGird) + self.DynamicTable:SetDelegate(self) +end + +function XUiMissionChapter:SetupChapter() + local chapters = XDataCenter.TaskForceManager.GetTaskForceSectionConfig() + if not chapters then + return + end + + local curSectionId = XDataCenter.TaskForceManager.GetCurTaskForceSectionId() + + self.Chapters = chapters + self.DynamicTable:SetDataSource(chapters) + self.DynamicTable:ReloadDataASync(curSectionId) +end + +--动态列表事件 +function XUiMissionChapter:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.Chapters[index] + grid.RootUi = self + grid:SetupContent(data) + end +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiMissionChapter:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiMissionChapter:AutoInitUi() + -- self.PanelChapter = self.Transform:Find("SafeAreaContentPane/PanelChapter") + -- self.PanelContent = self.Transform:Find("SafeAreaContentPane/PanelChapter/PanelContent") + -- self.PanelScroll = self.Transform:Find("SafeAreaContentPane/PanelChapter/PanelContent/PanelScroll") + -- self.PanelMissionChapterGird = self.Transform:Find("SafeAreaContentPane/PanelChapter/PanelContent/PanelScroll/Viewport/PanelMissionChapterGird") + -- self.BtnBg = self.Transform:Find("FullScreenBackground/BtnBg"):GetComponent("Button") +end + +function XUiMissionChapter:GetAutoKey(uiNode, eventName) + if not uiNode then + return + end + return eventName .. uiNode:GetHashCode() +end + +function XUiMissionChapter:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then + return + end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiMissionChapter:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiMissionChapter:AutoAddListener() + self.AutoCreateListeners = {} + self:RegisterClickEvent(self.BtnBg, self.OnBtnBgClick) +end +-- auto + +function XUiMissionChapter:OnBtnBgClick() + self:PlayAnimation("AniMissionChapterEnd", function() + self:Close() + end) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMission/XUiMissionCompleted.lua b/Resources/Scripts/XUi/XUiMission/XUiMissionCompleted.lua new file mode 100644 index 00000000..03bac70f --- /dev/null +++ b/Resources/Scripts/XUi/XUiMission/XUiMissionCompleted.lua @@ -0,0 +1,131 @@ +local XUiMissionCompleted = XLuaUiManager.Register(XLuaUi, "UiMissionCompleted") +local XUiPanelRewardSmall = require("XUi/XUiMission/XUiPanelRewardSmall") +local XUiPanelRewardBig = require("XUi/XUiMission/XUiPanelRewardBig") + +function XUiMissionCompleted:OnAwake() + self:InitAutoScript() +end + +function XUiMissionCompleted:OnStart(reslut, characterId) + + self.IsAnimation = true + self.RewardSmallPanel = XUiPanelRewardSmall.New(self.PanelRewardSmall, self) + self.RewardBigPanel = XUiPanelRewardBig.New(self.PanelRewardBig, self) + + self.MissionResult = reslut + self.CharacterId = characterId + self.GridList = {} + self:SetupMissionCompleted() + + if not self.MissionResult then + return + end + + if self.MissionResult.IsBigReward then + self:PlayAnimation("AniMissionRewardBigBegin", function() + self.IsAnimation = false + end) + else + self:PlayAnimation("AniMissionRewardSmallBegin", function() + self.IsAnimation = false + end) + end + + +end + +function XUiMissionCompleted:SetupMissionCompleted() + if not self.MissionResult then + return + end + + local isBigReward = self.MissionResult.IsBigReward + --self.PanelDesc.gameObject:SetActive(false) + --self.PanelBg.gameObject:SetActive(not isBigReward) + self.PanelRewardSmall.gameObject:SetActive(not isBigReward) + self.PanelRewardBig.gameObject:SetActive(isBigReward) + + local rewards = self.MissionResult + + if not rewards then + return + end + + if isBigReward then + self.RewardBigPanel:SetupCharacter(self.CharacterId) + self.RewardBigPanel:SetupReward(rewards) + else + self.RewardSmallPanel:SetupReward(rewards) + end + +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiMissionCompleted:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiMissionCompleted:AutoInitUi() + -- self.PanelRewardBig = self.Transform:Find("FullScreenBackground/PanelRewardBig") + -- self.PanelRewardSmall = self.Transform:Find("FullScreenBackground/PanelRewardSmall") + -- self.BtnBg = self.Transform:Find("FullScreenBackground/BtnBg"):GetComponent("Button") +end + +function XUiMissionCompleted:GetAutoKey(uiNode, eventName) + if not uiNode then + return + end + return eventName .. uiNode:GetHashCode() +end + +function XUiMissionCompleted:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then + return + end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiMissionCompleted:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiMissionCompleted:AutoAddListener() + self.AutoCreateListeners = {} + self:RegisterClickEvent(self.BtnBg, self.OnBtnBgClick) +end +-- auto +function XUiMissionCompleted:OnBtnBgClick() + + if self.IsAnimation then + return + end + + if self.MissionResult.IsBigReward then + self:PlayAnimation("AniMissionRewardBigEnd", function() + self:Close() + end) + else + self:PlayAnimation("AniMissionRewardSmallEnd", function() + self:Close() + end) + end + + +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMission/XUiMissionTeam.lua b/Resources/Scripts/XUi/XUiMission/XUiMissionTeam.lua new file mode 100644 index 00000000..eecc53a8 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMission/XUiMissionTeam.lua @@ -0,0 +1,265 @@ +local XUiMissionTeam = XLuaUiManager.Register(XLuaUi, "UiMissionTeam") + +local MissionQuality = +{ + [1] = CS.XGame.ClientConfig:GetString("MissionQuality1"), + [2] = CS.XGame.ClientConfig:GetString("MissionQuality2"), + [3] = CS.XGame.ClientConfig:GetString("MissionQuality3"), + [4] = CS.XGame.ClientConfig:GetString("MissionQuality4"), + [5] = CS.XGame.ClientConfig:GetString("MissionQuality5"), +} + +function XUiMissionTeam:OnAwake() + self:InitAutoScript() +end + +function XUiMissionTeam:OnStart(task) + + self.Task = task + self:Init() + self.CharacterIds = {} + self:SetupContent() + + self:PlayAnimation("UiMissionTeamBegin") +end + +function XUiMissionTeam:Init() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + + local characterGrid = {} + characterGrid[1] = XUiPanelMissionCharacter.New(self.PanelMissionCharacter, self, 1) + characterGrid[2] = XUiPanelMissionCharacter.New(self.PanelMissionCharacter1, self, 2) + characterGrid[3] = XUiPanelMissionCharacter.New(self.PanelMissionCharacter2, self, 3) + self.CharacterGrid = characterGrid + + self.GridConditions = {} + local XUiGridConditionTxt = require("XUi/XUiMission/XUiGridConditionTxt") + table.insert(self.GridConditions, XUiGridConditionTxt.New(self.GridConditionTxt)) + for _ = 1, 2, 1 do + local ui = CS.UnityEngine.Object.Instantiate(self.GridConditionTxt) + local gridCondition = XUiGridConditionTxt.New(ui) + gridCondition.Transform:SetParent(self.PanelLayoutAct, false) + table.insert(self.GridConditions, gridCondition) + end +end + +--设置内容 +function XUiMissionTeam:SetupContent() + if not self.Task then + return + end + + local taskCfg = self.Task.TaskCfg + if not taskCfg then + return + end + + self.TaskCfg = taskCfg + + self:SetupBaseInfo() + self:SetupExtraCondition() + self:SetupTeamCondition() + self:SetupTeamCharacter() +end + +function XUiMissionTeam:SetupBaseInfo() + local taskCfg = self.TaskCfg + self.TxtName.text = taskCfg.Name + self.TxtTime.text = CS.XDateUtil.SecondsToTimeString(taskCfg.Duration) + self:SetUiSprite(self.ImgQuality, MissionQuality[taskCfg.Quality]) + + local curSectionId = XDataCenter.TaskForceManager.GetCurTaskForceSectionId() + local data = XDataCenter.TaskForceManager.GetTaskForceSectionConfigById(curSectionId) + self:SetUiSprite(self.ImgZhangjie, data.SectionChapterIcon) +end + +function XUiMissionTeam:Refresh(ids) + self.CharacterIds = ids + self:SetupContent() +end + +function XUiMissionTeam:SetupTeamCharacter() + local taskCfg = self.TaskCfg + local memberCount = taskCfg.MemberCount + for i, v in ipairs(self.CharacterGrid) do + if not self.CharacterIds[i] then + if memberCount >= i then + v:SetEmpty() + else + v:SetLock() + end + else + v:SetCharacter(self.CharacterIds[i]) + end + + v:SetSelectData(memberCount, self.CharacterIds) + end +end + + +--设置额外条件 +function XUiMissionTeam:SetupExtraCondition() + local extraRewardConditionId = self.TaskCfg.ExtraRewardConditionId + self.PanelOtherReward.gameObject:SetActive(extraRewardConditionId ~= 0) + + if extraRewardConditionId and extraRewardConditionId > 0 then + + local template = XConditionManager.GetConditionTemplate(extraRewardConditionId) + if template then + self.TxtDesc.text = template.Desc + self.TxtDescA.text = template.Desc + end + + local enough = XConditionManager.CheckTeamCondition(extraRewardConditionId, self.CharacterIds) + self.PanelOn.gameObject:SetActive(enough) + self.PanelOff.gameObject:SetActive(not enough) + + local rewards = XRewardManager.GetRewardList(self.TaskCfg.ExtraRewardId) + local item = XDataCenter.ItemManager.GetItem(rewards[1].TemplateId) + + self.GoodsShowParams = XGoodsCommonManager.GetGoodsShowParamsByTemplateId(rewards[1].TemplateId) + + self.TxtCount.text = "x" .. tostring(rewards[1].Count) + self.TxtCountA.text = "x" .. tostring(rewards[1].Count) + + self:SetUiSprite(self.ImgRes, item.Template.Icon) + self:SetUiSprite(self.ImgResA, item.Template.Icon) + + end +end + + +--设置条件 +function XUiMissionTeam:SetupTeamCondition() + local conditionList = self.TaskCfg.ConditionList + + local ids = {} + + for _, v in pairs(self.CharacterIds) do + table.insert(ids, v) + end + + if conditionList then + for i = 1, 3, 1 do + if i == 1 then + self.GridConditions[i]:SetupExtraContent(self.TaskCfg.MemberCount, ids) + elseif conditionList[i - 1] then + self.GridConditions[i].GameObject:SetActive(true) + self.GridConditions[i]:SetupContent(conditionList[i - 1], ids) + else + self.GridConditions[i].GameObject:SetActive(false) + end + end + end +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiMissionTeam:InitAutoScript() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiMissionTeam:GetAutoKey(uiNode, eventName) + if not uiNode then + return + end + return eventName .. uiNode:GetHashCode() +end + +function XUiMissionTeam:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then + return + end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiMissionTeam:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiMissionTeam:AutoAddListener() + self.AutoCreateListeners = {} + self:RegisterClickEvent(self.BtnSend, self.OnBtnSendClick) + self:RegisterClickEvent(self.BtnAutoTeam, self.OnBtnAutoTeamClick) + self:RegisterClickEvent(self.BtnResOn, self.OnBtnResOnClick) + self:RegisterClickEvent(self.BtnResOff, self.OnBtnResOffClick) + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) +end +-- auto + +function XUiMissionTeam:OnBtnResOnClick() + self:OnBtnResOffClick() +end + +function XUiMissionTeam:OnBtnResOffClick() + local rewards = XRewardManager.GetRewardList(self.TaskCfg.ExtraRewardId) + local rewardData = rewards[1] + + if not rewardData then + return + end + + if self.GoodsShowParams.RewardType == XRewardManager.XRewardType.Character then + XLuaUiManager.Open("UiCharacterDetail", rewardData.TemplateId) + -- elseif self.GoodsShowParams.RewardType == XRewardManager.XRewardType.Equip then + --CS.XUiManager.ViewManager:Push("UiEquip", false, false, rewardData, XGlobalVar.EquipTabIndex.Detail, true) + -- XLuaUiManager.Open("UiEquip", rewardData, XGlobalVar.EquipTabIndex.Detail, true) + else + XLuaUiManager.Open("UiTip", rewardData and rewardData or rewardData.TemplateId) + end +end + +function XUiMissionTeam:OnBtnSendClick() + local enough, error = XDataCenter.TaskForceManager.CheckTeamCondition(self.TaskCfg.Id, self.CharacterIds) + if not enough then + XUiManager.TipMsg(error) + return + end + + XDataCenter.TaskForceManager.AcceptTaskForceTaskRequest(self.TaskCfg.Id, self.CharacterIds, function() + self:Close() + end) +end + +--一键选择 +function XUiMissionTeam:OnBtnAutoTeamClick() + if not self.TaskCfg then + return + end + + local characterIds = XDataCenter.TaskForceManager.AutoChoiceCharacter(self.TaskCfg.Id) + if #characterIds <= 0 then + XUiManager.TipMsg(CS.XTextManager.GetText("MissionAutoSelectFail")) + return + end + + self.CharacterIds = characterIds + + self:PlayAnimation("UiMissionTeamSlect") + + self:SetupContent() +end + +function XUiMissionTeam:OnBtnBackClick() + self:Close() +end + +function XUiMissionTeam:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMission/XUiMissionTeamLimit.lua b/Resources/Scripts/XUi/XUiMission/XUiMissionTeamLimit.lua new file mode 100644 index 00000000..58122960 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMission/XUiMissionTeamLimit.lua @@ -0,0 +1,101 @@ +local XUiMissionTeamLimit = XLuaUiManager.Register(XLuaUi, "UiMissionTeamLimit") + +function XUiMissionTeamLimit:OnAwake() + self:InitAutoScript() +end + +function XUiMissionTeamLimit:OnStart(curIndex) + self.CurIndex = curIndex + self:Init() + self:SetupContent() + self:PlayAnimation("AniMissionTeamLimitBegin") +end + +function XUiMissionTeamLimit:Init() + self.CurId = -1 + self.TaskForeData = {} + self.DynamicTable = XDynamicTableNormal.New(self.PanelScrollView) + self.DynamicTable:SetProxy(XUiGridLimit) + self.DynamicTable:SetDelegate(self) +end + +function XUiMissionTeamLimit:SetupContent() + local configs = XDataCenter.TaskForceManager.GetTaskForceConfigInfo() + if not configs then + return + end + + local curCfg = XDataCenter.TaskForceManager.GetTaskForceConfigById(self.CurIndex) + self.CurId = curCfg.Id + self.TaskForeData = configs + self.DynamicTable:SetDataSource(configs) + self.DynamicTable:ReloadDataASync(curCfg.Id) +end + +--动态列表事件 +function XUiMissionTeamLimit:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.TaskForeData[index] + grid:SetupContent(data, self.CurId) + end +end + + +-- auto +-- Automatic generation of code, forbid to edit +function XUiMissionTeamLimit:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiMissionTeamLimit:AutoInitUi() + -- self.BtnBg = self.Transform:Find("FullScreenBackground/BtnBg"):GetComponent("Button") + -- self.UiMissionTeamLimitA = self.Transform:Find("SafeAreaContentPane/UiMissionTeamLimit") + -- self.PanelScrollView = self.Transform:Find("SafeAreaContentPane/UiMissionTeamLimit/PanelScrollView") + -- self.GridLimit = self.Transform:Find("SafeAreaContentPane/UiMissionTeamLimit/PanelScrollView/Viewport/GridLimit") +end + +function XUiMissionTeamLimit:GetAutoKey(uiNode, eventName) + if not uiNode then + return + end + return eventName .. uiNode:GetHashCode() +end + +function XUiMissionTeamLimit:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then + return + end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiMissionTeamLimit:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiMissionTeamLimit:AutoAddListener() + self.AutoCreateListeners = {} + self:RegisterClickEvent(self.BtnBg, self.OnBtnBgClick) +end +-- auto + +function XUiMissionTeamLimit:OnBtnBgClick() + self:PlayAnimation("AniMissionTeamLimitEnd", function() + self:Close() + end) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMission/XUiMissionTeamSelect.lua b/Resources/Scripts/XUi/XUiMission/XUiMissionTeamSelect.lua new file mode 100644 index 00000000..724d165c --- /dev/null +++ b/Resources/Scripts/XUi/XUiMission/XUiMissionTeamSelect.lua @@ -0,0 +1,172 @@ +local XUiMissionTeamSelect = XLuaUiManager.Register(XLuaUi, "UiMissionTeamSelect") + +function XUiMissionTeamSelect:OnAwake() + self:InitAutoScript() +end + +function XUiMissionTeamSelect:OnStart(characterIds, memberCount, index, callback) + + self.Index = index + + self:Init(characterIds) + self.MemberLimit = memberCount + self.CallBack = callback + self.CurSelectGrid = nil + self:SetupCharacterList() + + self:PlayAnimation("AniMissionTeamSelectBegin") +end + +function XUiMissionTeamSelect:Init(characterIds) + --self.SelectCount = #characterIds + self.CharacterIds = {} + for i,v in pairs(characterIds) do + self.CharacterIds[i] = v + end + + self.SelectedIdMap = {} + for i, v in pairs(characterIds) do + if self.Index ~= i then + self.SelectedIdMap[v] = i + end + end + + self.DynamicTable = XDynamicTableNormal.New(self.PanelScrollView) + self.DynamicTable:SetProxy(XUiGridMisssionTeam) + self.DynamicTable:SetDelegate(self) +end + +-- 角色信息面板 begin -- +function XUiMissionTeamSelect:SetupCharacterList() + local charlist = XDataCenter.TaskForceManager.GetOwnCharacterList() + + if not charlist then + XLog.Error("XUiMissionTeamSelect:SetupCharacterList error: character list is nil") + return + end + + self.CharList = {} + for _, v in ipairs(charlist) do + if self.CharacterIds and self.CharacterIds[self.Index] and self.CharacterIds[self.Index] == v.Id then + table.insert(self.CharList, 1, v) + else + table.insert(self.CharList, v) + end + end + + self.DynamicTable:SetDataSource(self.CharList) + self.DynamicTable:ReloadDataASync() +end + +--动态列表事件 +function XUiMissionTeamSelect:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.CharList[index] + grid:Reset() + grid:UpdateGrid(data) + if self.CharacterIds[self.Index] and self.CharacterIds[self.Index] == data.Id then + self.CurSelectGrid = grid + grid:SetSelect(true) + else + grid:SetSelect(false) + end + + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + local charData = self.CharList[index] + + if charData.IsWorking and charData.IsWorking > 0 then + return + end + + if self.CharacterIds[self.Index] and self.CharacterIds[self.Index] == charData.Id then + self.CurSelectGrid:SetSelect(false) + self.CharacterIds[self.Index] = nil + return + end + + if self.CurSelectGrid then + self.CurSelectGrid:SetSelect(false) + end + + self.CharacterIds[self.Index] = charData.Id + self.CurSelectGrid = grid + self.CurSelectGrid:SetSelect(true) + end +end +-- auto +-- Automatic generation of code, forbid to edit +function XUiMissionTeamSelect:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiMissionTeamSelect:AutoInitUi() + -- self.BtnBg = self.Transform:Find("FullScreenBackground/BtnBg"):GetComponent("Button") + -- self.PanelMissionTeamSelect = self.Transform:Find("SafeAreaContentPane/PanelMissionTeamSelect") + -- self.PanelScrollView = self.Transform:Find("SafeAreaContentPane/PanelMissionTeamSelect/PanelScrollView") + -- self.GridMisssionTeam = self.Transform:Find("SafeAreaContentPane/PanelMissionTeamSelect/PanelScrollView/Viewport/GridMisssionTeam") + -- self.BtnSure = self.Transform:Find("SafeAreaContentPane/PanelMissionTeamSelect/BtnSure"):GetComponent("Button") +end + +function XUiMissionTeamSelect:GetAutoKey(uiNode, eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiMissionTeamSelect:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiMissionTeamSelect:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiMissionTeamSelect:AutoAddListener() + self.AutoCreateListeners = {} + self:RegisterClickEvent(self.BtnBg, self.OnBtnBgClick) + self:RegisterClickEvent(self.BtnSure, self.OnBtnSureClick) +end +-- auto +function XUiMissionTeamSelect:OnBtnBgClick() + self:PlayAnimation("AniMissionTeamSelectEnd", function() + self:Close() + end) +end + +function XUiMissionTeamSelect:OnBtnSureClick() + + local id = self.CharacterIds[self.Index] + if id then + local index = self.SelectedIdMap[id] + if index ~= nil then + self.CharacterIds[index] = nil + end + end + + self:PlayAnimation("AniMissionTeamSelectEnd", function() + if self.CallBack then + self.CallBack(self.CharacterIds) + end + + self:Close() + + end) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMission/XUiPanelArea.lua b/Resources/Scripts/XUi/XUiMission/XUiPanelArea.lua new file mode 100644 index 00000000..59264bf9 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMission/XUiPanelArea.lua @@ -0,0 +1,86 @@ +XUiPanelArea = XClass(nil, "XUiPanelArea") + +function XUiPanelArea:Ctor(ui,sectionData,parent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.SectionData = sectionData + self.RootUi = parent + XTool.InitUiObject(self) + self:InitAutoScript() + self:Init() +end + +function XUiPanelArea:Init() + if not self.SectionData then + return + end + + self.TxtAreaLock.text = self.SectionData.Name + self.TxtAreaNow.text = self.SectionData.Name + self.TxtAreaNor.text = self.SectionData.Name + --self.RootUi:SetUiSprite(self.RImgChapter,self.SectionData.SectionIcon) + self.RImgChapter:SetRawImage(self.SectionData.SectionIcon) +end + +function XUiPanelArea:SetCurSection(taskSectionCfg) + if not self.SectionData then + return + end + + self.PanelNow.gameObject:SetActive(self.SectionData.Id == taskSectionCfg.Id) + self.PanelLock.gameObject:SetActive(self.SectionData.Id > taskSectionCfg.Id) + self.PanelNor.gameObject:SetActive(self.SectionData.Id < taskSectionCfg.Id) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelArea:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiPanelArea:AutoInitUi() + -- self.PanelLock = self.Transform:Find("PanelLock") + -- self.TxtAreaLock = self.Transform:Find("PanelLock/TxtAreaLock"):GetComponent("Text") + -- self.PanelNow = self.Transform:Find("PanelNow") + -- self.RImgChapter = self.Transform:Find("PanelNow/RImgChapter"):GetComponent("RawImage") + -- self.TxtAreaNow = self.Transform:Find("PanelNow/TxtAreaNow"):GetComponent("Text") + -- self.PanelNor = self.Transform:Find("PanelNor") + -- self.TxtAreaNor = self.Transform:Find("PanelNor/TxtAreaNor"):GetComponent("Text") +end + +function XUiPanelArea:GetAutoKey(uiNode,eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiPanelArea:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiPanelArea:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key],eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiPanelArea:AutoAddListener() + self.AutoCreateListeners = {} +end +-- auto + +return XUiPanelArea diff --git a/Resources/Scripts/XUi/XUiMission/XUiPanelMissionChapterGird.lua b/Resources/Scripts/XUi/XUiMission/XUiPanelMissionChapterGird.lua new file mode 100644 index 00000000..fb213739 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMission/XUiPanelMissionChapterGird.lua @@ -0,0 +1,129 @@ +XUiPanelMissionChapterGird = XClass(nil, "XUiPanelMissionChapterGird") + +function XUiPanelMissionChapterGird:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:InitAutoScript() + for i = 1, 3, 1 do + self["Txt" .. tostring(i)].text = "" + self["Txt" .. tostring(i).."A"].text = "" + end +end + +function XUiPanelMissionChapterGird:SetupContent(data) + local curSectionId = XDataCenter.TaskForceManager.GetCurTaskForceSectionId() + self.PanelChapterHave.gameObject:SetActive(curSectionId > data.Id) + self.PanelChapterSlect.gameObject:SetActive(curSectionId == data.Id) + self.PanelChapterLock.gameObject:SetActive(curSectionId < data.Id) + + local sprite = data.SectionChapterIcon + + if curSectionId == data.Id then + self.TxtName.text = data.Name..CS.XTextManager.GetText("MissionCurContent") + --self.RootUi:SetUiSprite(self.RImgIcon, sprite) + self.RImgIcon:SetRawImage(sprite) + + for i = 1, 3, 1 do + if data.Desc[i] ~= nil and data.Desc[i] ~= "" then + self["Txt" .. tostring(i)].text = data.Desc[i] + else + self["Txt" .. tostring(i)].text = string.format(CS.XTextManager.GetText("MissionTaskCountContent"),data.TaskCount) + break + end + end + elseif curSectionId > data.Id then + self.TxtNameA.text = data.Name + --self.RootUi:SetUiSprite(self.RImgIconA, sprite) + self.RImgIconA:SetRawImage(sprite) + for i = 1, 3, 1 do + if data.Desc[i] ~= nil and data.Desc[i] ~= "" then + self["Txt" .. tostring(i).."A"].text = data.Desc[i] + else + self["Txt" .. tostring(i).."A"].text = string.format(CS.XTextManager.GetText("MissionTaskCountContent"),data.TaskCount) + break + end + end + elseif curSectionId < data.Id then + self.TxtNameB.text = data.Name + local template = XConditionManager.GetConditionTemplate(data.ConditionId) + if template then + self.Txt1B.text = template.Desc + end + end + + + + --local stageId = tostring(template.Params[1]) + --local chapterStr = string.sub(stageId, 4, 4) + + + + + -- self.ImgCondition.gameObject:SetActive(curSectionId < data.Id) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelMissionChapterGird:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiPanelMissionChapterGird:AutoInitUi() + -- self.PanelChapterSlect = self.Transform:Find("PanelChapterSlect") + -- self.ImgChapter = self.Transform:Find("PanelChapterSlect/ImgChapter"):GetComponent("Image") + -- self.RImgIcon = self.Transform:Find("PanelChapterSlect/ImgChapter/RImgIcon"):GetComponent("RawImage") + -- self.PanelTxt = self.Transform:Find("PanelChapterSlect/PanelTxt") + -- self.Txt1 = self.Transform:Find("PanelChapterSlect/PanelTxt/Txt1"):GetComponent("Text") + -- self.Txt2 = self.Transform:Find("PanelChapterSlect/PanelTxt/Txt2"):GetComponent("Text") + -- self.Txt3 = self.Transform:Find("PanelChapterSlect/PanelTxt/Txt3"):GetComponent("Text") + -- self.TxtName = self.Transform:Find("PanelChapterSlect/TxtName"):GetComponent("Text") + -- self.PanelChapterHave = self.Transform:Find("PanelChapterHave") + -- self.ImgChapterA = self.Transform:Find("PanelChapterHave/ImgChapter"):GetComponent("Image") + -- self.RImgIconA = self.Transform:Find("PanelChapterHave/ImgChapter/RImgIcon"):GetComponent("RawImage") + -- self.PanelTxtA = self.Transform:Find("PanelChapterHave/PanelTxt") + -- self.Txt1A = self.Transform:Find("PanelChapterHave/PanelTxt/Txt1"):GetComponent("Text") + -- self.Txt2A = self.Transform:Find("PanelChapterHave/PanelTxt/Txt2"):GetComponent("Text") + -- self.Txt3A = self.Transform:Find("PanelChapterHave/PanelTxt/Txt3"):GetComponent("Text") + -- self.TxtNameA = self.Transform:Find("PanelChapterHave/TxtName"):GetComponent("Text") + -- self.PanelChapterLock = self.Transform:Find("PanelChapterLock") + -- self.ImgLock = self.Transform:Find("PanelChapterLock/ImgLock"):GetComponent("Image") + -- self.Txt1B = self.Transform:Find("PanelChapterLock/Txt1"):GetComponent("Text") + -- self.TxtNameB = self.Transform:Find("PanelChapterLock/TxtName"):GetComponent("Text") +end + +function XUiPanelMissionChapterGird:GetAutoKey(uiNode, eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiPanelMissionChapterGird:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiPanelMissionChapterGird:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiPanelMissionChapterGird:AutoAddListener() + self.AutoCreateListeners = {} +end +-- auto +return XUiPanelMissionChapterGird \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMission/XUiPanelMissionCharacter.lua b/Resources/Scripts/XUi/XUiMission/XUiPanelMissionCharacter.lua new file mode 100644 index 00000000..0ad682a7 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMission/XUiPanelMissionCharacter.lua @@ -0,0 +1,120 @@ +XUiPanelMissionCharacter = XClass(nil, "XUiPanelMissionCharacter") + +local Status = { + Empty = 1, + Lock = 2, + Normal = 3 +} + +function XUiPanelMissionCharacter:Ctor(ui, parent, index) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:InitAutoScript() + self.Status = Status.Empty + self.Parent = parent + self.Index = index +end + +function XUiPanelMissionCharacter:SetEmpty() + self.PanelEmpty.gameObject:SetActive(true) + self.PanelLock.gameObject:SetActive(false) + self.PanelCha.gameObject:SetActive(false) + self.Status = Status.Empty +end + +function XUiPanelMissionCharacter:SetLock() + self.PanelEmpty.gameObject:SetActive(false) + self.PanelLock.gameObject:SetActive(true) + self.PanelCha.gameObject:SetActive(false) + self.Status = Status.Lock +end + +function XUiPanelMissionCharacter:SetCharacter(id) + self.PanelEmpty.gameObject:SetActive(false) + self.PanelLock.gameObject:SetActive(false) + self.PanelCha.gameObject:SetActive(true) + local character = XDataCenter.CharacterManager.GetCharacter(id) + self.TxtLevel.text = tostring(character.Level) + self.Parent:SetUiSprite(self.ImgType, XCharacterConfigs.GetNpcTypeIcon(character.Type)) + --self.Parent:SetUiSprite(self.RImgCharacter, XDataCenter.CharacterManager.GetCharHalfBodyBigImage(id)) + self.RImgCharacter:SetRawImage(XDataCenter.CharacterManager.GetCharHalfBodyBigImage(id)) + self.Status = Status.Normal +end + +function XUiPanelMissionCharacter:SetSelectData(memberCount, characterIds) + self.MemberCount = memberCount + self.CharacterIds = characterIds +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelMissionCharacter:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiPanelMissionCharacter:AutoInitUi() + -- self.PanelLock = self.Transform:Find("PanelLock") + -- self.PanelEmpty = self.Transform:Find("PanelEmpty") + -- self.PanelCha = self.Transform:Find("PanelCha") + -- self.ImgBg = self.Transform:Find("PanelCha/ImgBg"):GetComponent("Image") + -- self.PanelMask = self.Transform:Find("PanelCha/PanelMask") + -- self.RImgCharacter = self.Transform:Find("PanelCha/PanelMask/RImgCharacter"):GetComponent("RawImage") + -- self.ImgType = self.Transform:Find("PanelCha/Image/ImgType"):GetComponent("Image") + -- self.TxtLevel = self.Transform:Find("PanelCha/Image/TxtLevel"):GetComponent("Text") + -- self.BtnAdd = self.Transform:Find("BtnAdd"):GetComponent("Button") +end + +function XUiPanelMissionCharacter:GetAutoKey(uiNode, eventName) + if not uiNode then + return + end + return eventName .. uiNode:GetHashCode() +end + +function XUiPanelMissionCharacter:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then + return + end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiPanelMissionCharacter:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiPanelMissionCharacter:AutoAddListener() + self.AutoCreateListeners = {} + XUiHelper.RegisterClickEvent(self, self.BtnAdd, self.OnBtnAddClick) +end +-- auto +function XUiPanelMissionCharacter:OnBtnAddClick() + if self.Status == Status.Lock then + return + end + + XLuaUiManager.Open("UiMissionTeamSelect", self.CharacterIds, self.MemberCount, self.Index, function(ids) + if self.Parent then + self.Parent:Refresh(ids) + end + end) + +end + +return XUiPanelMissionCharacter \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMission/XUiPanelMissionGrid.lua b/Resources/Scripts/XUi/XUiMission/XUiPanelMissionGrid.lua new file mode 100644 index 00000000..22bc5f75 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMission/XUiPanelMissionGrid.lua @@ -0,0 +1,291 @@ +XUiPanelMissionGrid = XClass(nil, "XUiPanelMissionGrid") + +function XUiPanelMissionGrid:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.GridList = {} + XTool.InitUiObject(self) + self:InitAutoScript() + self.Timer = nil + self.ShowCompletedAnimation = false + self.TxtTimeRect = self.TxtTime.gameObject:GetComponent("RectTransform") + self.GridCommonA.gameObject:SetActive(false) +end + +function XUiPanelMissionGrid:OnRecycle() + self:StopTimer() +end + +function XUiPanelMissionGrid:StartTimer() + if self.Timer then + self:StopTimer() + end + + self.Timer = XScheduleManager.ScheduleForever(function() + self:UpdateTime() + end, XScheduleManager.SECOND) +end + +function XUiPanelMissionGrid:StopTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end + +function XUiPanelMissionGrid:UpdateTime() + if not self.TaskData or not self.TaskData.Task then + return + end + + local curTime = XTime.GetServerNowTimestamp() + local completeTime = self.TaskData.Task.UtcFinishTime + + if not self.TxtTime:Exist() then + return + end + + local offset = completeTime - curTime + if offset > 0 then + self.TxtTime.text = CS.XDateUtil.SecondsToTimeString(offset) + else + self.TxtTime.text = "00:00:00" + self:StopTimer() + end +end + +function XUiPanelMissionGrid:PlayCompletedAnimation(cb) + self:PlayAnimation("AniMissionTaskComplete", cb) +end + +function XUiPanelMissionGrid:Init(parent) + self.Parent = parent + self.MainRewardGrid = XUiGridCommon.New(self.Parent, self.GridCommon) +end + +function XUiPanelMissionGrid:SetupContent(taskData) + + + if not taskData then + return + end + + self.TaskData = taskData + self:SetupBaseInfo() + self:SetupTask() +end + +function XUiPanelMissionGrid:SetupTask() + + self:StopTimer() + + if self.TaskData.Status == XDataCenter.TaskForceManager.TaskForceTaskStatus.Normal then + return + end + + local task = self.TaskData.Task + if not task then + return + end + + self.BtnFinish.gameObject:SetActive(task.Status == XDataCenter.TaskForceManager.TaskForceTaskStatus.Complete) + self.PanelStop.gameObject:SetActive(task.Status == XDataCenter.TaskForceManager.TaskForceTaskStatus.Accept) + + if task.Status == XDataCenter.TaskForceManager.TaskForceTaskStatus.Accept then + self:UpdateTime() + self:StartTimer() + elseif task.Status == XDataCenter.TaskForceManager.TaskForceTaskStatus.Complete then + self.TxtTime.text = "00:00:00" + end +end + +--设置基础信息 +function XUiPanelMissionGrid:SetupBaseInfo() + local taskCfg = self.TaskData.TaskCfg + if not taskCfg then + return + end + self.TxtName.text = taskCfg.Name + self.TxtTime.text = CS.XDateUtil.SecondsToTimeString(taskCfg.Duration) + self.TxtTimeRect.anchoredPosition = CS.UnityEngine.Vector2(0, -16.2) + + self.BtnSend.gameObject:SetActive(self.TaskData.Task.Status == XDataCenter.TaskForceManager.TaskForceTaskStatus.Normal) + self.BtnFinish.gameObject:SetActive(false) + self.PanelStop.gameObject:SetActive(false) + --self.BtnTimeGo.gameObject:SetActive(false) + + self.Parent:SetUiSprite(self.ImgQuality, CS.XGame.ClientConfig:GetString("MissionQuality"..taskCfg.Quality)) + + self:SetupReward(taskCfg.ShowId, taskCfg.RewardId) +end + +--设置奖励 +function XUiPanelMissionGrid:SetupReward(mainRewardId, rewardId) + + --顯示奖励 + local rewards = XRewardManager.GetRewardList(mainRewardId) + if self.MainRewardGrid then + self.MainRewardGrid:Refresh(rewards[1]) + self.MainRewardGrid.TxtCount.gameObject:SetActive(false) + end + + rewards = XRewardManager.GetRewardList(rewardId) + if not rewards then + return + end + + --显示的奖励 + local start = 0 + if rewards then + for i, item in ipairs(rewards) do + start = i + local grid + if self.GridList[i] then + grid = self.GridList[i] + else + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommonA) + grid = XUiGridCommon.New(self.Parent, ui) + grid.Transform:SetParent(self.PanelLayoutReward, false) + self.GridList[i] = grid + end + grid:Refresh(item) + grid.GameObject:SetActive(true) + end + end + + for j = start + 1, #self.GridList do + self.GridList[j].GameObject:SetActive(false) + end +end + + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelMissionGrid:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiPanelMissionGrid:AutoInitUi() + -- self.PanelTime = self.Transform:Find("PanelTime") + -- self.TxtTime = self.Transform:Find("PanelTime/TxtTime"):GetComponent("Text") + -- self.PanelRaward = self.Transform:Find("PanelRaward") + -- self.PanelScrollView = self.Transform:Find("PanelRaward/PanelScrollView") + -- self.PanelLayoutReward = self.Transform:Find("PanelRaward/PanelScrollView/Viewport/PanelLayoutReward") + -- self.GridCommonA = self.Transform:Find("PanelRaward/PanelScrollView/Viewport/PanelLayoutReward/GridCommon") + -- self.PanelMainReward = self.Transform:Find("PanelMainReward") + -- self.GridCommon = self.Transform:Find("PanelMainReward/GridCommon") + -- self.PanelBase = self.Transform:Find("PanelBase") + -- self.BtnFinish = self.Transform:Find("PanelBase/BtnFinish"):GetComponent("Button") + -- self.PanelReceive = self.Transform:Find("PanelBase/BtnFinish/PanelReceive") + -- self.BtnSend = self.Transform:Find("PanelBase/BtnSend"):GetComponent("Button") + -- self.PanelStop = self.Transform:Find("PanelBase/PanelStop") + -- self.BtnTimeGo = self.Transform:Find("PanelBase/PanelStop/BtnTimeGo"):GetComponent("Button") + -- self.BtnStop = self.Transform:Find("PanelBase/PanelStop/BtnStop"):GetComponent("Button") + -- self.PanelTitle = self.Transform:Find("PanelTitle") + -- self.ImgQuality = self.Transform:Find("PanelTitle/ImgQuality"):GetComponent("Image") + -- self.TxtName = self.Transform:Find("PanelTitle/TxtName"):GetComponent("Text") +end + +function XUiPanelMissionGrid:GetAutoKey(uiNode, eventName) + if not uiNode then + return + end + return eventName .. uiNode:GetHashCode() +end + +function XUiPanelMissionGrid:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then + return + end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiPanelMissionGrid:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiPanelMissionGrid:AutoAddListener() + self.AutoCreateListeners = {} + XUiHelper.RegisterClickEvent(self, self.BtnFinish, self.OnBtnFinishClick) + XUiHelper.RegisterClickEvent(self, self.BtnSend, self.OnBtnSendClick) + XUiHelper.RegisterClickEvent(self, self.BtnTimeGo, self.OnBtnTimeGoClick) + XUiHelper.RegisterClickEvent(self, self.BtnStop, self.OnBtnStopClick) +end +-- auto +function XUiPanelMissionGrid:OnBtnTimeGoClick() + if not self.TaskData then + return + end + + local task = self.TaskData.Task + if not task then + return + end + + if task.Status ~= XDataCenter.TaskForceManager.TaskForceTaskStatus.Accept then + return + end + + XLuaUiManager.Open("UiMissionAddSpeedTip", self.TaskData) + +end + +function XUiPanelMissionGrid:OnBtnFinishClick() + if not self.TaskData then + return + end + + local task = self.TaskData.Task + if not task then + return + end + + if task.Status ~= XDataCenter.TaskForceManager.TaskForceTaskStatus.Complete then + return + end + + XDataCenter.TaskForceManager.AcceptTaskForceRewardRequest(task.TaskId, function(result) + XLuaUiManager.Open("UiMissionCompleted", result, task.Members[1]) + end) +end + +function XUiPanelMissionGrid:OnBtnSendClick() + XLuaUiManager.Open("UiMissionTeam", self.TaskData) +end + +function XUiPanelMissionGrid:OnBtnStopClick() + if not self.TaskData then + return + end + + local task = self.TaskData.Task + if not task then + return + end + + if task.Status ~= XDataCenter.TaskForceManager.TaskForceTaskStatus.Accept then + return + end + + XUiManager.DialogTip(CS.XTextManager.GetText("MissionTeamCountTipTile"), CS.XTextManager.GetText("MissionGiveupTaskContent"), XUiManager.DialogType.Normal, nil, function() + XDataCenter.TaskForceManager.GiveUpTaskForceTaskRequest(task.TaskId) + end) +end + +return XUiPanelMissionGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMission/XUiPanelRewardBig.lua b/Resources/Scripts/XUi/XUiMission/XUiPanelRewardBig.lua new file mode 100644 index 00000000..238a6307 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMission/XUiPanelRewardBig.lua @@ -0,0 +1,155 @@ +local XUiPanelRewardBig = XClass(nil, "XUiPanelRewardBig") + +function XUiPanelRewardBig:Ctor(ui, parent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Parent = parent + self.GridList = {} + XTool.InitUiObject(self) + self:InitAutoScript() + self.GridMissionCommon.gameObject:SetActive(false) +end + +function XUiPanelRewardBig:SetupCharacter(id) + local character = XCharacterConfigs.GetCharacterTemplate(id) + self.TxtDesc.text = character.MissionInfo + --self.Parent:SetUiSprite(self.RImgRole, XDataCenter.CharacterManager.GetCharHalfBodyImage(id)) + self.RImgRole:SetRawImage(XDataCenter.CharacterManager.GetCharHalfBodyImage(id)) +end + + +--设置奖励 +function XUiPanelRewardBig:SetupReward(result) + if not result then + return + end + local rewardBig = result.DropList + local rewardExtra = result.ExtraRewardList + local rewards = result.Rewards + + local XUiGridMissionCommon = require("XUi/XUiMission/XUiGridMissionCommon") + + local start = 0 + if rewardBig then + for _, item in ipairs(rewardBig) do + start = start + 1 + local grid + if self.GridList[start] then + grid = self.GridList[start] + else + local ui = CS.UnityEngine.Object.Instantiate(self.GridMissionCommon) + grid = XUiGridMissionCommon.New(self.Parent, ui) + grid.Transform:SetParent(self.PanelRewardBigA, false) + grid.ImgAdditional.gameObject:SetActive(false) + grid.ImgBig.gameObject:SetActive(true) + table.insert(self.GridList, grid) + end + grid:Refresh(item) + grid.GameObject:SetActive(true) + end + end + + + if rewardExtra then + for _, item in ipairs(rewardExtra) do + start = start + 1 + local grid + if self.GridList[start] then + grid = self.GridList[start] + else + local ui = CS.UnityEngine.Object.Instantiate(self.GridMissionCommon) + grid = XUiGridMissionCommon.New(self.Parent, ui) + grid.Transform:SetParent(self.PanelRewardBigA, false) + grid.ImgAdditional.gameObject:SetActive(true) + grid.ImgBig.gameObject:SetActive(false) + table.insert(self.GridList, grid) + end + grid:Refresh(item) + grid.GameObject:SetActive(true) + end + end + + --显示的奖励 + if rewards then + for _, item in ipairs(rewards) do + start = start + 1 + local grid + if self.GridList[start] then + grid = self.GridList[start] + else + local ui = CS.UnityEngine.Object.Instantiate(self.GridMissionCommon) + grid = XUiGridMissionCommon.New(self.Parent, ui) + grid.Transform:SetParent(self.PanelRewardBigA, false) + grid.ImgAdditional.gameObject:SetActive(false) + grid.ImgBig.gameObject:SetActive(false) + table.insert(self.GridList, grid) + end + grid:Refresh(item) + grid.GameObject:SetActive(true) + end + end + + for j = start + 1, #self.GridList do + self.GridList[j].GameObject:SetActive(false) + end +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelRewardBig:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiPanelRewardBig:AutoInitUi() + -- self.PanelRewardInfo = self.Transform:Find("GameObject/PanelRewardInfo") + -- self.ScrollView = self.Transform:Find("GameObject/PanelRewardInfo/ScrollView"):GetComponent("Scrollbar") + -- self.PanelRewardBigA = self.Transform:Find("GameObject/PanelRewardInfo/ScrollView/Viewport/PanelRewardBig") + -- self.GridMissionCommon = self.Transform:Find("GameObject/PanelRewardInfo/ScrollView/Viewport/PanelRewardBig/GridMissionCommon") + -- self.PanelRole = self.Transform:Find("GameObject/PanelRewardInfo/PanelRole") + -- self.RImgRole = self.Transform:Find("GameObject/PanelRewardInfo/PanelRole/RImgRole"):GetComponent("RawImage") + -- self.TxtDesc = self.Transform:Find("GameObject/PanelRewardInfo/Image/TxtDesc"):GetComponent("Text") +end + +function XUiPanelRewardBig:GetAutoKey(uiNode, eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiPanelRewardBig:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiPanelRewardBig:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiPanelRewardBig:AutoAddListener() + self.AutoCreateListeners = {} +end +-- auto +function XUiPanelRewardBig:OnScrollViewValueChanged() + +end +function XUiPanelRewardBig:OnScrollViewAValueChanged() + +end + + +return XUiPanelRewardBig \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMission/XUiPanelRewardSmall.lua b/Resources/Scripts/XUi/XUiMission/XUiPanelRewardSmall.lua new file mode 100644 index 00000000..af0cc38d --- /dev/null +++ b/Resources/Scripts/XUi/XUiMission/XUiPanelRewardSmall.lua @@ -0,0 +1,118 @@ +local XUiPanelRewardSmall = XClass(nil, "XUiPanelRewardSmall") + +function XUiPanelRewardSmall:Ctor(ui,parent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Parent = parent + XTool.InitUiObject(self) + self:InitAutoScript() + self.GridList = {} + self.GridMissionCommonA.gameObject:SetActive(false) +end + +--设置奖励 +function XUiPanelRewardSmall:SetupReward(result) + if not result then + return + end + local rewardExtra = result.ExtraRewardList + local rewards = result.Rewards + + local XUiGridMissionCommon = require("XUi/XUiMission/XUiGridMissionCommon") + + local start = 0 + if rewardExtra then + for _, item in ipairs(rewardExtra) do + start = start + 1 + local grid + if self.GridList[start] then + grid = self.GridList[start] + else + local ui = CS.UnityEngine.Object.Instantiate(self.GridMissionCommonA) + grid = XUiGridMissionCommon.New(self.Parent, ui) + grid.Transform:SetParent(self.PanelReward, false) + grid.ImgAdditional.gameObject:SetActive(true) + grid.ImgBig.gameObject:SetActive(false) + table.insert(self.GridList, grid) + end + grid:Refresh(item) + grid.GameObject:SetActive(true) + end + end + + --显示的奖励 + if rewards then + for _, item in ipairs(rewards) do + start = start + 1 + local grid + if self.GridList[start] then + grid = self.GridList[start] + else + local ui = CS.UnityEngine.Object.Instantiate(self.GridMissionCommonA) + grid = XUiGridMissionCommon.New(self.Parent, ui) + grid.Transform:SetParent(self.PanelReward, false) + grid.ImgAdditional.gameObject:SetActive(false) + grid.ImgBig.gameObject:SetActive(false) + table.insert(self.GridList, grid) + end + grid:Refresh(item) + grid.GameObject:SetActive(true) + end + end + + for j = start + 1, #self.GridList do + self.GridList[j].GameObject:SetActive(false) + end +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelRewardSmall:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiPanelRewardSmall:AutoInitUi() + -- self.PanelRewardSmallA = self.Transform:Find("PanelRewardSmall") + -- self.ScrollViewA = self.Transform:Find("PanelRewardSmall/ScrollView"):GetComponent("Scrollbar") + -- self.PanelReward = self.Transform:Find("PanelRewardSmall/ScrollView/Viewport/PanelReward") + -- self.GridMissionCommonA = self.Transform:Find("PanelRewardSmall/ScrollView/Viewport/PanelReward/GridMissionCommon") +end + +function XUiPanelRewardSmall:GetAutoKey(uiNode,eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiPanelRewardSmall:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiPanelRewardSmall:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key],eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiPanelRewardSmall:AutoAddListener() + self.AutoCreateListeners = {} +end +-- auto + + + +return XUiPanelRewardSmall \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMoeWar/ChildItem/XUiGridGroupList.lua b/Resources/Scripts/XUi/XUiMoeWar/ChildItem/XUiGridGroupList.lua new file mode 100644 index 00000000..d552d1a1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMoeWar/ChildItem/XUiGridGroupList.lua @@ -0,0 +1,28 @@ +local XUiGridGroupList = XClass(nil, "XUiGridGroupList") +local XUiGridPairGroup = require("XUi/XUiMoeWar/ChildItem/XUiGridPairGroup") +local tableInsert = table.insert + +function XUiGridGroupList:Ctor(ui, index) + ---@type UnityEngine.GameObject + self.GameObject = ui + self.Transform = self.GameObject.transform + self.GroupId = index + self.GroupConfig = XMoeWarConfig.GetInitPairsByGroupId(index) + XTool.InitUiObject(self) + local activityInfo = XDataCenter.MoeWarManager.GetActivityInfo() + self.TxtFirstTitle.text = activityInfo.GroupName[index] + self.TxtSecondTitle.text = activityInfo.GroupSecondName[index] + self:InitPairList() +end + +function XUiGridGroupList:InitPairList() + self.PairList = {} + for i = 1, #self.GroupConfig do + local obj = CS.UnityEngine.GameObject.Instantiate(self.BtnGroup, self.GroupList) + local gird = XUiGridPairGroup.New(obj, self.GroupConfig[i], i) + tableInsert(self.PairList, gird) + end + self.BtnGroup.gameObject:SetActiveEx(false) +end + +return XUiGridGroupList \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMoeWar/ChildItem/XUiGridPairGroup.lua b/Resources/Scripts/XUi/XUiMoeWar/ChildItem/XUiGridPairGroup.lua new file mode 100644 index 00000000..79fa308e --- /dev/null +++ b/Resources/Scripts/XUi/XUiMoeWar/ChildItem/XUiGridPairGroup.lua @@ -0,0 +1,51 @@ +local XUiGridPairGroup = XClass(nil,"XUiGridPairGroup") + +function XUiGridPairGroup:Ctor(ui,config,index) + ---@type UnityEngine.GameObject + self.GameObject = ui + self.Transform = self.GameObject.transform + self.Config = config + self.Index = index + XTool.InitUiObject(self) + CS.XScheduleManager.ScheduleOnce(function() + if XTool.UObjIsNil(self.GameObject) then + return + end + self:PlaySwitchAnimation() + self:InitUiView() + end,((self.Config.GroupId - 1) * 4 + index) * 80) +end + +function XUiGridPairGroup:InitUiView() + local leftPlayer = XDataCenter.MoeWarManager.GetPlayer(self.Config.PlayerId[1]) + local rightPlayer = XDataCenter.MoeWarManager.GetPlayer(self.Config.PlayerId[2]) + self.ImgLeftHead:SetRawImage(leftPlayer:GetCircleHead()) + self.ImgRightHead:SetRawImage(rightPlayer:GetCircleHead()) + self.TxtLeftName.text = leftPlayer:GetName() + self.TxtRightName.text = rightPlayer:GetName() + self.BtnGroup.CallBack = function() + self:OnClickBtnGroup() + end +end + +function XUiGridPairGroup:OnClickBtnGroup() + local key = string.format("%s_%s","MOE_WAR_VOTE_SHOW_MATCH_SCENE",tostring(XPlayer.Id)) + XSaveTool.SaveData(key,true) + local defaultSelectKey = string.format("%s_%s",XMoeWarConfig.DEFAULT_SELECT_KEY_PREFIX,tostring(XPlayer.Id)) + XSaveTool.SaveData(defaultSelectKey,self:CalculatePairId()) + XLuaUiManager.Open("UiMoeWarVote",self:CalculatePairId()) +end + +function XUiGridPairGroup:CalculatePairId() + return (self.Config.GroupId - 1) * 4 + self.Index +end + +function XUiGridPairGroup:PlaySwitchAnimation() + if self.AniRole1 and self.AniRole2 then + self.AniRole1.gameObject:SetActiveEx(true) + self.AniRole2.gameObject:SetActiveEx(true) + self.PlayableDirector:Play() + end +end + +return XUiGridPairGroup \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMoeWar/ChildItem/XUiGridRank.lua b/Resources/Scripts/XUi/XUiMoeWar/ChildItem/XUiGridRank.lua new file mode 100644 index 00000000..c33e02fd --- /dev/null +++ b/Resources/Scripts/XUi/XUiMoeWar/ChildItem/XUiGridRank.lua @@ -0,0 +1,52 @@ +local XUiGridRank = XClass(nil, "XUiGridRank") +local CSXTextManagerGetText = CS.XTextManager.GetText +local MAX_SPECIAL_NUM = 3 + +function XUiGridRank:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:AutoAddListener() +end + +function XUiGridRank:Init(uiRoot) + self.UiRoot = uiRoot +end + +function XUiGridRank:AutoAddListener() + XUiHelper.RegisterClickEvent(self, self.BtnDetail, self.OnBtnDetailClick) +end + +function XUiGridRank:Refresh(rankMetaData, rankType) + if rankMetaData then + self.RankMetaData = rankMetaData + else + return + end + + self.TxtRankNormal.gameObject:SetActive(self.RankMetaData.Rank > MAX_SPECIAL_NUM) + self.ImgRankSpecial.gameObject:SetActive(self.RankMetaData.Rank <= MAX_SPECIAL_NUM) + if self.RankMetaData.Rank <= MAX_SPECIAL_NUM then + local icon = XMoeWarConfig.RankIcon[self.RankMetaData.Rank] + self.UiRoot:SetUiSprite(self.ImgRankSpecial, icon) + else + self.TxtRankNormal.text = math.floor(self.RankMetaData.Rank) + end + + local textPrefix = "" + if rankType == XMoeWarConfig.RankType.Player then + textPrefix = CSXTextManagerGetText("MoeWarRankPlayer") + elseif rankType == XMoeWarConfig.RankType.Daily then + textPrefix = CSXTextManagerGetText("MoeWarRankDaily") + end + self.TxtRankScore.text = CSXTextManagerGetText("MoeWarRankScore", textPrefix, self.RankMetaData.Score) + self.TxtPlayerName.text = XDataCenter.SocialManager.GetPlayerRemark(self.RankMetaData.PlayerId, self.RankMetaData.Name) + + XUiPLayerHead.InitPortrait(self.RankMetaData.HeadPortraitId, self.RankMetaData.HeadFrameId, self.Head) +end + +function XUiGridRank:OnBtnDetailClick() + XDataCenter.PersonalInfoManager.ReqShowInfoPanel(self.RankMetaData.PlayerId) +end + +return XUiGridRank \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMoeWar/ChildItem/XUiGridVoteItem.lua b/Resources/Scripts/XUi/XUiMoeWar/ChildItem/XUiGridVoteItem.lua new file mode 100644 index 00000000..17e4402d --- /dev/null +++ b/Resources/Scripts/XUi/XUiMoeWar/ChildItem/XUiGridVoteItem.lua @@ -0,0 +1,199 @@ +local XUiGridVoteItem = XClass(nil, "XUiGridVoteItem") +local toString = tostring +local toNumber = tonumber +function XUiGridVoteItem:Ctor(ui, currPlayerId, voteId, valueChangeCallback, voteSuccessCallback, rootUi) + ---@type UnityEngine.GameObject + self.GameObject = ui + ---@type UnityEngine.Transform + self.Transform = self.GameObject.transform + self.RootUi = rootUi + self.CurrPlayerId = currPlayerId + self.ValueChangeCallback = valueChangeCallback + self.VoteSuccessCallback = voteSuccessCallback + self.VoteId = voteId + self.VoteItem = XDataCenter.MoeWarManager.GetVoteItem(voteId) + XTool.InitUiObject(self) + self:InitUiView() +end + +function XUiGridVoteItem:InitUiView() + local itemId = self.VoteItem:GetVoteItemId() + local itemTemplate = XDataCenter.ItemManager.GetItemTemplate(itemId) + self.GridComponent = XUiGridCommon.New(self.RootUi, self.GridIcon) + self.TxtName.text = XDataCenter.ItemManager.GetItemName(itemId) + self.GridComponent:Refresh(itemTemplate) + self.GridComponent:SetBtnNotClick(true)--临时屏蔽点击弹窗 + self.TxtNumber.text = XDataCenter.ItemManager.GetCount(itemId) + self.TxtEffectNumber = self.Transform:Find("PanelDetails/GridDetails/TxtDetails/TxtNumber"):GetComponent("Text") + self.GridReward.gameObject:SetActiveEx(self.VoteItem:IsLimitVote()) + XDataCenter.ItemManager.AddCountUpdateListener(itemId, function() + self.TxtNumber.text = XDataCenter.ItemManager.GetCount(self.VoteItem:GetVoteItemId()) + end, self.TxtNumber) + if self.ImgEffectIcon and self.ImgRewardIcon then + self.ImgEffectIcon:SetRawImage(CS.XGame.ClientConfig:GetString("MoeWarScheduleSupportIcon")) + self.ImgRewardIcon:SetRawImage(CS.XGame.ClientConfig:GetString("MoeWarVoteReawrdIcon")) + self.TxtRewardTitle.text = CS.XTextManager.GetText("MoeWarVoteRewardTitle") + self.TxtEffectTitle.text = CS.XTextManager.GetText("MoeWarVoteEffectTitle") + end + self.BtnPoll:SetName(CS.XTextManager.GetText("MoeWarVoteButtonName")) + if not self.AddInputHandler then + self.AddInputHandler = self.BtnAdd.gameObject:AddComponent(typeof(CS.XGoInputHandler)) + end + if not self.ReduceInputHandler then + self.ReduceInputHandler = self.BtnReduce.gameObject:AddComponent(typeof(CS.XGoInputHandler)) + end + self:RegisterButtonEvent() + self:SetVoteNumber(0) + self:UpdateLimitText() +end + +function XUiGridVoteItem:UpdateLimitText() + local itemName = XDataCenter.ItemManager.GetItemName(self.VoteItem:GetVoteItemId()) + local playerEntity = XDataCenter.MoeWarManager.GetPlayer(self.CurrPlayerId) + if self.VoteItem:IsLimitVote() then + self.TxtLimit.text = CS.XTextManager.GetText("MoeWarDailyLimitVoteTips", itemName, playerEntity:GetDailyVoteByItemId(self.VoteItem:GetVoteItemId()), self.VoteItem:GetDailyLimitCountByMatchId(XDataCenter.MoeWarManager.GetCurMatchId())) + else + self.TxtLimit.text = CS.XTextManager.GetText("MoeWarNotDailyLimitVoteTips", itemName) + end +end + +function XUiGridVoteItem:UpdateButtonState() + local currValue = toNumber(self.TxtVoteNumber.text) + self.BtnPoll:SetDisable(currValue == 0, currValue ~= 0) +end + +function XUiGridVoteItem:SetVoteNumber(value) + self.TxtVoteNumber.text = toString(value) + self.TxtEffectNumber.text = toString(value * self.VoteItem:GetVoteFactor()) + local rewardValue = value * self.VoteItem:GetCoinFactor() + if self.TxtRewardNumber then + self.TxtRewardNumber.text = toString(rewardValue) + end + self:UpdateButtonState() +end + +function XUiGridVoteItem:OnClickBtnAdd() + if not self:CheckIsCanVote() then return end + local currNumber = toNumber(self.TxtVoteNumber.text) + local multiple = self.VoteItem:GetMultiple() + local newValue = currNumber + multiple + local playerEntity = XDataCenter.MoeWarManager.GetPlayer(self.CurrPlayerId) + local match = XDataCenter.MoeWarManager.GetCurMatch() + local voteFactor = self.VoteItem:GetVoteFactor() + if self.VoteItem:IsLimitVote() then + local max = self.VoteItem:GetDailyLimitCountByMatchId(XDataCenter.MoeWarManager.GetCurMatchId()) - playerEntity:GetDailyVoteByItemId(self.VoteItem:GetVoteItemId()) + if max < 0 then + max = 0 + end + if newValue > max then newValue = max end + end + local itemCount = XDataCenter.ItemManager.GetCount(self.VoteItem:GetVoteItemId()) + if newValue > itemCount then newValue = itemCount end + + local dailyLimitCount = match:GetDailyLimitCount() + local currCount = XDataCenter.MoeWarManager.GetDailyVoteCount() + + if newValue * voteFactor > (dailyLimitCount - currCount) then + newValue = math.floor((dailyLimitCount - currCount) / (multiple * voteFactor)) * multiple + end + self:SetVoteNumber(newValue) + if self.ValueChangeCallback then + self.ValueChangeCallback(self.VoteId) + end +end + +function XUiGridVoteItem:OnClickBtnReduce() + local currNumber = toNumber(self.TxtVoteNumber.text) + local multiple = self.VoteItem:GetMultiple() + local newValue = currNumber - multiple + newValue = XMath.Clamp(newValue, 0, currNumber) + self:SetVoteNumber(newValue) + if self.ValueChangeCallback then + self.ValueChangeCallback(self.VoteId) + end +end + +function XUiGridVoteItem:OnClickBtnMax() + if not self:CheckIsCanVote() then return end + local newValue = 0 + local multiple = self.VoteItem:GetMultiple() + local voteItemId = self.VoteItem:GetVoteItemId() + local match = XDataCenter.MoeWarManager.GetCurMatch() + local voteFactor = self.VoteItem:GetVoteFactor() + local playerEntity = XDataCenter.MoeWarManager.GetPlayer(self.CurrPlayerId) + if self.VoteItem:IsLimitVote() then + newValue = self.VoteItem:GetDailyLimitCountByMatchId(XDataCenter.MoeWarManager.GetCurMatchId()) - playerEntity:GetDailyVoteByItemId(self.VoteItem:GetVoteItemId()) + local itemCount = XDataCenter.ItemManager.GetCount(voteItemId) + newValue = XMath.Clamp(newValue, 0, itemCount) + else + newValue = math.floor(XDataCenter.ItemManager.GetCount(voteItemId) / multiple) * multiple + end + + local dailyLimitCount = match:GetDailyLimitCount() + local currCount = XDataCenter.MoeWarManager.GetDailyVoteCount() + + if newValue * voteFactor > (dailyLimitCount - currCount) then + newValue = math.floor((dailyLimitCount - currCount) / (multiple * voteFactor)) * multiple + end + + self:SetVoteNumber(newValue) + if self.ValueChangeCallback then + self.ValueChangeCallback(self.VoteId) + end +end + +function XUiGridVoteItem:OnClickBtnVote() + local count = toNumber(self.TxtVoteNumber.text) + local ownCount = XDataCenter.ItemManager.GetCount(self.VoteItem:GetVoteItemId()) + if ownCount < count then + return + end + local playerEntity = XDataCenter.MoeWarManager.GetPlayer(self.CurrPlayerId) + playerEntity:RequestVote(self.VoteId, count, function(count) self.VoteSuccessCallback(tonumber(self.TxtEffectNumber.text), self.CurrPlayerId) end) +end + +function XUiGridVoteItem:RegisterButtonEvent() + --self.BtnAdd.CallBack = function() self:OnClickBtnAdd() end + self.BtnMax.CallBack = function() self:OnClickBtnMax() end + --self.BtnReduce.CallBack = function() self:OnClickBtnReduce() end + self.BtnPoll.CallBack = function() self:OnClickBtnVote() end + --增加特殊处理原长按是每帧执行一次,修改为每帧执行十次增加速度 + self.AddInputHandler:AddPressListener(function() for i = 1, 10 do self:OnClickBtnAdd() end end) + self.AddInputHandler:AddPointerClickListener(handler(self,self.OnClickBtnAdd)) + self.ReduceInputHandler:AddPressListener(function() for i = 1, 10 do self:OnClickBtnReduce() end end) + self.ReduceInputHandler:AddPointerClickListener(handler(self,self.OnClickBtnReduce)) +end + +function XUiGridVoteItem:CheckIsCanVote() + local voteItemId = self.VoteItem:GetVoteItemId() + local itemCount = XDataCenter.ItemManager.GetCount(voteItemId) + local voteFactor = self.VoteItem:GetVoteFactor() + local multiple = self.VoteItem:GetMultiple() + if itemCount == 0 then + XUiManager.TipMsg(CS.XTextManager.GetText("MoeWarDailyVoteItemNotEnoughTip", XDataCenter.ItemManager.GetItemName(voteItemId))) + return false + end + if self.VoteItem:IsLimitVote() then + local playerEntity = XDataCenter.MoeWarManager.GetPlayer(self.CurrPlayerId) + local canVoteCount = self.VoteItem:GetDailyLimitCountByMatchId(XDataCenter.MoeWarManager.GetCurMatchId()) - playerEntity:GetDailyVoteByItemId(self.VoteItem:GetVoteItemId()) + if canVoteCount == 0 then + XUiManager.TipText("MoeWarDailyVoteItemLimitTip") + return false + end + end + local match = XDataCenter.MoeWarManager.GetCurMatch() + local dailyLimitCount = match:GetDailyLimitCount() + local currCount = XDataCenter.MoeWarManager.GetDailyVoteCount() + if currCount >= dailyLimitCount then + XUiManager.TipText("MoeWarDailyVoteLimitTip") + return false + end + if dailyLimitCount - currCount < voteFactor * multiple then + XUiManager.TipText("MoeWarDailyVoteLimitTip2") + return false + end + + return true +end + +return XUiGridVoteItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMoeWar/ChildItem/XUiMessageGridAction.lua b/Resources/Scripts/XUi/XUiMoeWar/ChildItem/XUiMessageGridAction.lua new file mode 100644 index 00000000..abe7f2d2 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMoeWar/ChildItem/XUiMessageGridAction.lua @@ -0,0 +1,58 @@ +local XUiMessageGridAction = XClass(nil, "XUiMessageGridAction") + +local alphaSinScale = 10 + +function XUiMessageGridAction:Ctor(uiRoot, ui) + self.UiRoot = uiRoot + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.BtnClick.CallBack = function() self.UiRoot:OnActionClick(self.ActionData, self) end +end + +function XUiMessageGridAction:Refresh(actionData) + self.ImgCurProgress.fillAmount = 0 + if not actionData then + self:UpdatePlayStatus(false) + return + end + self.ActionData = actionData + self.UiRoot:SetUiSprite(self.ImgHead, actionData.HeadIcon) + if actionData.ActionType == XMoeWarConfig.ActionType.Intro then + self.TxtTitle.text = CS.XTextManager.GetText("MoeWarMessageIntro") + elseif actionData.ActionType == XMoeWarConfig.ActionType.Thank then + self.TxtTitle.text = CS.XTextManager.GetText("MoeWarMessageThank") + end + self:UpdatePlayStatus(self.ActionData.IsPlay) +end + +function XUiMessageGridAction:UpdatePlayStatus(isPlay) + self.ActionData.IsPlay = isPlay + self.IconPlay.gameObject:SetActiveEx(not isPlay) + self.IconPause.gameObject:SetActiveEx(isPlay) + self.IconAction.gameObject:SetActiveEx(isPlay) + self.IconActionCanvasGroup.alpha = 0 +end + +function XUiMessageGridAction:HidePlayStatus() + self.IconPlay.gameObject:SetActiveEx(false) + self.IconPause.gameObject:SetActiveEx(false) + self.IconAction.gameObject:SetActiveEx(false) +end + +function XUiMessageGridAction:UpdateProgress(progress) + progress = (progress >= 1) and 1 or progress + self.ImgCurProgress.fillAmount = progress +end + +function XUiMessageGridAction:UpdateActionAlpha(count) + local alpha = math.sin(count / alphaSinScale) + self.IconActionCanvasGroup.alpha = alpha +end + +function XUiMessageGridAction:GetActionType() + if not self.ActionData then return 0 end + return self.ActionData.ActionType +end + +return XUiMessageGridAction \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMoeWar/ChildItem/XUiMessageGridPlayer.lua b/Resources/Scripts/XUi/XUiMoeWar/ChildItem/XUiMessageGridPlayer.lua new file mode 100644 index 00000000..30543ec6 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMoeWar/ChildItem/XUiMessageGridPlayer.lua @@ -0,0 +1,48 @@ +--local handler = handler + +local XUiMessageGridPlayer = XClass(nil, "XUiMessageGridPlayer") + +function XUiMessageGridPlayer:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + + self:SetSelect(false) + + --self.BtnClick.CallBack = handler(self, self.OnClickBtnClick) +end + +function XUiMessageGridPlayer:Init(uiRoot) + self.UiRoot = uiRoot +end + +function XUiMessageGridPlayer:UpdateData(playerId) + if not playerId or playerId == self.PlayerId then return end + if XTool.UObjIsNil(self.GameObject) then return end + self.Entity = XDataCenter.MoeWarManager.GetPlayer(playerId) + self.Id = self.Entity.Id + self:Refresh(playerId) +end + +function XUiMessageGridPlayer:Refresh(playerId) + self.PlayerId = playerId + + self.TxtName.text = self.Entity:GetName() + self.TxtGroup.text = self.Entity:GetGroupName() + self.RImgHeadIcon:SetRawImage(self.Entity:GetSquareHead()) +end + +function XUiMessageGridPlayer:SetSelect(value) + if self.PanelSelected then + self.PanelSelected.gameObject:SetActiveEx(value) + end +end + +function XUiMessageGridPlayer:OnClickBtnClick() + if self.ClickCb then + self.ClickCb(self.PlayerId) + end +end + +return XUiMessageGridPlayer \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMoeWar/ChildItem/XUiScheduleGridPair.lua b/Resources/Scripts/XUi/XUiMoeWar/ChildItem/XUiScheduleGridPair.lua new file mode 100644 index 00000000..d6221e8d --- /dev/null +++ b/Resources/Scripts/XUi/XUiMoeWar/ChildItem/XUiScheduleGridPair.lua @@ -0,0 +1,82 @@ +local XUiScheduleGridPair = XClass(nil, "XUiScheduleGridPair") + +local XUiScheduleGridPlayer = require("XUi/XUiMoeWar/ChildItem/XUiScheduleGridPlayer") + +function XUiScheduleGridPair:Ctor(ui, teamNo, modelUpdater) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.TeamNo = teamNo + self.ModelUpdater = modelUpdater + + --XTool.InitUiObject(self) + self:AutoRegister() + self.BtnPlayBack.CallBack = function() self:OnBtnPlayBack() end + + self.Player1 = XUiScheduleGridPlayer.New(self.Player1Go) + self.Player2 = XUiScheduleGridPlayer.New(self.Player2Go) + self.PlayerWin = XUiScheduleGridPlayer.New(self.PlayerWinGo) +end + +function XUiScheduleGridPair:AutoRegister() + self.Player1Normal = self.Transform:Find("Line1/PanelNone") + self.Player1Win = self.Transform:Find("Line1/PanelWin") + self.Player2Normal = self.Transform:Find("Line2/PanelNone") + self.Player2Win = self.Transform:Find("Line2/PanelWin") + self.PlayerWinNormal = self.Transform:Find("LineWin/PanelNone") + self.PlayerWinWin = self.Transform:Find("LineWin/PanelWin") + self.BtnPlayBack = self.Transform:Find("BtnPlayBack"):GetComponent("XUiButton") + self.Player1Go = self.Transform:Find("PanelRole1") + self.Player2Go = self.Transform:Find("PanelRole2") + self.PlayerWinGo = self.Transform:Find("PanelRole3") + self.PanelNone = self.Transform:Find("PanelWenhao") +end + +function XUiScheduleGridPair:Refresh(pair, match) + self.PairInfo = pair + if pair.Players[1] < pair.Players[2] then + self.Player1Entity = XDataCenter.MoeWarManager.GetPlayer(pair.Players[1]) + self.Player2Entity = XDataCenter.MoeWarManager.GetPlayer(pair.Players[2]) + else + self.Player1Entity = XDataCenter.MoeWarManager.GetPlayer(pair.Players[2]) + self.Player2Entity = XDataCenter.MoeWarManager.GetPlayer(pair.Players[1]) + end + self.Match = match + self.Player1:Refresh(self.Player1Entity, match) + self.Player2:Refresh(self.Player2Entity, match) + if match:GetResultOut() then + local winner + if self.Player1Entity.MatchInfoDic[match.Id].IsWin then + winner = self.Player1Entity + elseif self.Player2Entity.MatchInfoDic[match.Id].IsWin then + winner = self.Player2Entity + end + self.Player1Win.gameObject:SetActiveEx(winner == self.Player1Entity) + self.Player1Normal.gameObject:SetActiveEx(winner ~= self.Player1Entity) + self.Player2Win.gameObject:SetActiveEx(winner == self.Player2Entity) + self.Player2Normal.gameObject:SetActiveEx(winner ~= self.Player2Entity) + self.PlayerWinNormal.gameObject:SetActiveEx(false) + self.PlayerWinWin.gameObject:SetActiveEx(true) + self.BtnPlayBack.gameObject:SetActiveEx(true) + self.PlayerWin:Refresh(winner, match) + if self.ModelUpdater then + self.ModelUpdater(self.TeamNo, winner) + self.PanelNone.gameObject:SetActiveEx(false) + end + else + self.PlayerWinNormal.gameObject:SetActiveEx(true) + self.PlayerWinWin.gameObject:SetActiveEx(false) + self.BtnPlayBack.gameObject:SetActiveEx(false) + self.PlayerWin:Refresh() + + if self.ModelUpdater then + self.ModelUpdater(self.TeamNo, nil) + self.PanelNone.gameObject:SetActiveEx(true) + end + end +end + +function XUiScheduleGridPair:OnBtnPlayBack() + XDataCenter.MoeWarManager.EnterAnimation(self.PairInfo, self.Match) +end + +return XUiScheduleGridPair \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMoeWar/ChildItem/XUiScheduleGridPlayer.lua b/Resources/Scripts/XUi/XUiMoeWar/ChildItem/XUiScheduleGridPlayer.lua new file mode 100644 index 00000000..fa0a3450 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMoeWar/ChildItem/XUiScheduleGridPlayer.lua @@ -0,0 +1,64 @@ +local XUiScheduleGridPlayer = XClass(nil, "XUiScheduleGridPlayer") + +function XUiScheduleGridPlayer:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + --XTool.InitUiObject(self) + self:AutoRegister() +end + +function XUiScheduleGridPlayer:AutoRegister() + self.RImgHeadIcon = self.Transform:Find("Head/StandIcon"):GetComponent("RawImage") + self.PanelLose = self.Transform:Find("Head/PanelLose") + self.PanelUnknown = self.Transform:Find("Head/PanelWenhao") + self.TxtName = self.Transform:Find("TextName"):GetComponent("Text") + self.RImgItemIcon = self.Transform:Find("PanelRoleNum/RawImage"):GetComponent("RawImage") + self.TxtItemCount = self.Transform:Find("PanelRoleNum/TextName"):GetComponent("Text") +end + +function XUiScheduleGridPlayer:Refresh(player, match) + self.Player = player + if not player then + self.RImgHeadIcon.gameObject:SetActiveEx(false) + self.PanelLose.gameObject:SetActiveEx(false) + self.RImgHeadIcon.gameObject:SetActiveEx(false) + self.RImgItemIcon.gameObject:SetActiveEx(false) + self.TxtItemCount.gameObject:SetActiveEx(false) + + self.PanelUnknown.gameObject:SetActiveEx(true) + self.TxtName.text = "-" + else + local matchInfo = player.MatchInfoDic[match.Id] + self.RImgHeadIcon.gameObject:SetActiveEx(true) + self.RImgHeadIcon:SetRawImage(self.Player:GetCircleHead()) + self.PanelLose.gameObject:SetActiveEx(matchInfo.IsOver and not matchInfo.IsWin) + self.PanelUnknown.gameObject:SetActiveEx(false) + self.TxtName.text = self.Player:GetName() + self.TxtName.color = matchInfo.IsWin and XMoeWarConfig.ScheNameColor.WIN or XMoeWarConfig.ScheNameColor.NORMAL + local scoreText = matchInfo.VoteCount + if match:GetVoteEnd() and not match:GetResultOut() then + scoreText = CsXTextManagerGetText("MoeWarMatchVoteNoResult") + elseif not match:GetVoteEnd() and matchInfo.VoteCount == 0 then + scoreText = CsXTextManagerGetText("MoeWarMatchVoteNotRefresh") + end + self.TxtItemCount.text = scoreText + self.TxtItemCount.color = matchInfo.IsWin and XMoeWarConfig.ScheNumColor.WIN or XMoeWarConfig.ScheNumColor.NORMAL + -- 应援道具图标 + self.RImgItemIcon:SetRawImage(CS.XGame.ClientConfig:GetString("MoeWarScheduleSupportIcon")) + end +end + +function XUiScheduleGridPlayer:SetFinalRank(rank) + if not self.RImgRankIcon then + self.RImgRankIcon = self.Transform:Find("RawImage"):GetComponent("RawImage") + end + + if rank > 0 then + self.RImgRankIcon:SetRawImage(XMoeWarConfig.ScheduleIcon[rank]) + else + self.RImgRankIcon.gameObject:SetActiveEx(false) + end +end + +return XUiScheduleGridPlayer \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMoeWar/Preparation/XUiMoeWarPreparation.lua b/Resources/Scripts/XUi/XUiMoeWar/Preparation/XUiMoeWarPreparation.lua new file mode 100644 index 00000000..3dca67d0 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMoeWar/Preparation/XUiMoeWarPreparation.lua @@ -0,0 +1,372 @@ +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate +local tableInsert = table.insert +local CSXTextManagerGetText = CS.XTextManager.GetText +local CSXScheduleManagerUnSchedule = XScheduleManager.UnSchedule + +local XUiMoeWarPreparationStageGrid = require("XUi/XUiMoeWar/Preparation/XUiMoeWarPreparationStageGrid") +local XUiMoeWarPreparationRewardGrid = require("XUi/XUiMoeWar/Preparation/XUiMoeWarPreparationRewardGrid") +local XUiMoeWarPreparationBtnTab = require("XUi/XUiMoeWar/Preparation/XUiMoeWarPreparationBtnTab") + +--赛事筹备 +local XUiMoeWarPreparation = XLuaUiManager.Register(XLuaUi, "UiMoeWarPreparation") + +function XUiMoeWarPreparation:OnAwake() + self:InitParamater() + self:InitCourseHeadPositionX() + self:AutoAddListener() + self:InitDynamicTable() + self:InitAssetPanel() + self:InitRedPoint() + self:AddCoinListener() +end + +function XUiMoeWarPreparation:OnStart() + self:InitPercentRewardGrid() + self:InitPanelTab() + self:RefreshAssetPanel() +end + +function XUiMoeWarPreparation:OnEnable() + self:PlayAnimation("AnimaOpen") + self:Refresh() + self:StartTimer() + self:CheckPreparationActivityIsOpen() + XDataCenter.MoeWarManager.JudgeGotoMainWhenFightOver() +end + +function XUiMoeWarPreparation:OnDisable() + self:StopTimer() + self:StopTweenTimer() + self:StopRefreshStageGridsTimer() +end + +function XUiMoeWarPreparation:AutoAddListener() + self:RegisterClickEvent(self.BtnBack, self.Close) + self:RegisterClickEvent(self.BtnMainUi, function() XLuaUiManager.RunMain() end) + self:RegisterClickEvent(self.BtnRecruit, self.OnBtnRecruitClick) + self:RegisterClickEvent(self.BtnSupport, self.OnBtnSupportClick) + self:BindHelpBtn(self.BtnHelp, "MoeWar") +end + +function XUiMoeWarPreparation:OnGetEvents() + return { + XEventId.EVENT_MOE_WAR_PREPARATION_UPDATE, + XEventId.EVENT_MOE_WAR_PREPARATION_DAILY_RESET, + } +end + +function XUiMoeWarPreparation:OnNotify(event, ...) + if event == XEventId.EVENT_MOE_WAR_PREPARATION_UPDATE then + self:Refresh() + elseif event == XEventId.EVENT_MOE_WAR_PREPARATION_DAILY_RESET then + self:Refresh() + end +end + +function XUiMoeWarPreparation:AddCoinListener() + local itemId = XDataCenter.ItemManager.ItemId.MoeWarPreparationItemId + XDataCenter.ItemManager.AddCountUpdateListener(itemId, function() + self:RefreshPercent() + self:UpdatePanelPhasesReward() + end, self.TxtPoint) +end + +function XUiMoeWarPreparation:InitRedPoint() + XRedPointManager.AddRedPointEvent(self.BtnRecruit, + self.OnRedPointEvent, self, + { XRedPointConditions.Types.CONDITION_MOEWAR_RECRUIT }) +end + +function XUiMoeWarPreparation:InitAssetPanel() + if not self.PanelSpecialTool then + return + end + local actInfo = XDataCenter.MoeWarManager.GetActivityInfo() + local currencyIdList = actInfo and actInfo.CurrencyId or {} + self.AssetActivityPanel = XUiPanelActivityAsset.New(self.PanelSpecialTool) + + XDataCenter.ItemManager.AddCountUpdateListener(currencyIdList, function() + self.AssetActivityPanel:Refresh(currencyIdList) + end, self.AssetActivityPanel) +end + +function XUiMoeWarPreparation:OnRedPointEvent(count) + self.BtnRecruit:ShowReddot(count >= 0) +end + +function XUiMoeWarPreparation:RefreshAssetPanel() + if not self.AssetActivityPanel then + return + end + local actInfo = XDataCenter.MoeWarManager.GetActivityInfo() + local currencyIdList = actInfo and actInfo.CurrencyId or {} + self.AssetActivityPanel:Refresh(currencyIdList) +end + +function XUiMoeWarPreparation:InitCourseHeadPositionX() + if not self.PreparationActivityId then return end + + self.CourseHeadPosition = self.CourseHead.transform.localPosition + self.CurrPanelCoursePercent = 0 + self.PreHavePreparationItemCount = XDataCenter.ItemManager.GetCount(XDataCenter.ItemManager.ItemId.MoeWarPreparationItemId) +end + +function XUiMoeWarPreparation:InitPercentRewardGrid() + self.ActiveProgressRect = self.PanelPassedLine:GetComponent("RectTransform") + if not self.PreparationActivityId then return end + + self.PercentRewardGrids = {} + self.PercentRewardGridRects = {} + local UpdatePanelPhasesRewardCb = function() + self:UpdatePanelPhasesReward() + end + + local gears = XMoeWarConfig.GetPreparationActivityPreparationGears(self.PreparationActivityId) + for i, gearId in ipairs(gears) do + local obj = i == 1 and self.GridCourse or CSUnityEngineObjectInstantiate(self.GridCourse, self.PanelGridCourse) + local grid = XUiMoeWarPreparationRewardGrid.New(obj, UpdatePanelPhasesRewardCb, gearId, self) + self.PercentRewardGrids[i] = grid + self.PercentRewardGridRects[i] = grid.Transform:GetComponent("RectTransform") + end + + -- 自适应调整 + self.OriginPosition = self.PercentRewardGrids[1] and self.PercentRewardGrids[1].Transform.localPosition +end + +function XUiMoeWarPreparation:UpdatePanelPhasesReward() + if not self.PreparationActivityId or XTool.UObjIsNil(self.ActiveProgressRect) then + return + end + + local activeProgressRectSize = self.ActiveProgressRect.rect.size + local haveCount = XDataCenter.ItemManager.GetCount(XDataCenter.ItemManager.ItemId.MoeWarPreparationItemId) + local maxCount = XMoeWarConfig.GetPreparationGearMaxNeedCount(self.PreparationActivityId) + local percent = maxCount > 0 and math.min(haveCount / maxCount, 1) or 0 + local headWidth = self.CourseHead.sizeDelta.x * 0.6 + local headPos = CS.UnityEngine.Vector3(activeProgressRectSize.x * percent + headWidth, self.CourseHeadPosition.y, self.CourseHeadPosition.z) + local percentRewardGridsCount = #self.PercentRewardGrids + + -- 自适应 + for i = 1, percentRewardGridsCount do + local grid = self.PercentRewardGrids[i] + if grid then + local gearId = grid:GetGearId() + local itemWidth = self.PercentRewardGridRects[i].sizeDelta.x / 2 + local needCount = gearId and XMoeWarConfig.GetPreparationGearNeedCount(gearId) or 0 + local rewardPercent = maxCount > 0 and needCount / maxCount or 0 + local adjustPosition = CS.UnityEngine.Vector3(activeProgressRectSize.x * rewardPercent + itemWidth, self.OriginPosition.y, self.OriginPosition.z) + self.PercentRewardGridRects[i].anchoredPosition3D = adjustPosition + end + end + + self:RefreshPercentRewardGrids() + + if self.CurrPanelCoursePercent ~= percent then + self.CourseHead.gameObject:SetActiveEx(true) + self.CurrPanelCoursePercent = percent + self:PlayHeadPercentMoveAnima(headPos, percent) + else + self.CourseHead.anchoredPosition3D = headPos + self.PanelPassedLine.fillAmount = percent + self.CourseHead.gameObject:SetActiveEx(haveCount == 0) + end +end + +function XUiMoeWarPreparation:RefreshPercentRewardGrids() + if XTool.UObjIsNil(self.GameObject) then + return + end + for _, grid in ipairs(self.PercentRewardGrids) do + grid:Refresh() + end +end + +function XUiMoeWarPreparation:PlayHeadPercentMoveAnima(endHeadPos, percent) + local headMoveAnimaTime = CS.XGame.ClientConfig:GetFloat("MoeWarPreparaHeadMoveAnimaTime") + local startPositionX = self.CourseHead.anchoredPosition3D.x + local pointDifference = endHeadPos.x - startPositionX + local haveCount = XDataCenter.ItemManager.GetCount(XDataCenter.ItemManager.ItemId.MoeWarPreparationItemId) + local preHaveCount = self.PreHavePreparationItemCount + self.PreHavePreparationItemCount = haveCount + if preHaveCount ~= 0 then + self:PlayAnimation("CourseHeadEnable") + end + + local currFillAmount = self.PanelPassedLine.fillAmount + local fillAmountDifference = percent - currFillAmount + + self:StopTweenTimer() + self.TweenTimer = XUiHelper.Tween(headMoveAnimaTime, function(f) + if XTool.UObjIsNil(self.Transform) then + return + end + self.PanelPassedLine.fillAmount = currFillAmount + f * fillAmountDifference + self.CourseHead.anchoredPosition3D = CS.UnityEngine.Vector3(startPositionX + f * pointDifference, endHeadPos.y, endHeadPos.z) + end, function () + if haveCount > 0 then + self:PlayAnimation("CourseHeadDisable") + end + self:RefreshPercentRewardGrids() + end) +end + +function XUiMoeWarPreparation:StopTweenTimer() + if self.TweenTimer then + CSXScheduleManagerUnSchedule(self.TweenTimer) + self.TweenTimer = nil + end +end + +function XUiMoeWarPreparation:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelItemList) + self.DynamicTable:SetDelegate(self) + self.DynamicTable:SetProxy(XUiMoeWarPreparationStageGrid, self) + self.GridShop.gameObject:SetActiveEx(false) +end + +function XUiMoeWarPreparation:InitParamater() + self.PreparationActivityId = XMoeWarConfig.GetPreparationActivityIdInTime() + if not self.PreparationActivityId then return end + + local timeId = XMoeWarConfig.GetPreparationActivityTimeId(self.PreparationActivityId) + self.PreparationActivityEndTime = XFunctionManager.GetEndTimeByTimeId(timeId) + + if self.TxtTitle then + self.TxtTitle.text = XMoeWarConfig.GetPreparationActivityName(self.PreparationActivityId) + end +end + +function XUiMoeWarPreparation:CheckPreparationActivityIsOpen() + if not self.PreparationActivityId then + self:Close() + end +end + +function XUiMoeWarPreparation:InitPanelTab() + if not self.PreparationActivityId then return end + + self.TabBtns = {} + local matchIds = XMoeWarConfig.GetPreparationActivityMatchIds(self.PreparationActivityId) + local tabBtn + for index, matchId in ipairs(matchIds) do + tabBtn = XTool.IsTableEmpty(self.TabBtns) and self.BtnFirst or CSUnityEngineObjectInstantiate(self.BtnFirst, self.TabBtnContent) + self.TabBtns[index] = XUiMoeWarPreparationBtnTab.New(tabBtn, matchId) + end +end + +function XUiMoeWarPreparation:StartTimer() + self:StopTimer() + self.Timer = XScheduleManager.ScheduleForever(function() + self:RefreshTabBtnTime() + end, XScheduleManager.SECOND) +end + +function XUiMoeWarPreparation:CheckStartRefreshStageGridsTimer() + self:StopRefreshStageGridsTimer() + + if XTool.IsTableEmpty(self.Stages) or not self.PreparationActivityId then + return + end + + local currOpenStageCount = XDataCenter.MoeWarManager.GetPreparationAllOpenStageCount() + local maxStageCount = XMoeWarConfig.GetPreparationActivityMaxStageCount(self.PreparationActivityId) + if maxStageCount == currOpenStageCount then + return + end + + self.RefreshStageGridsTimer = XScheduleManager.ScheduleForever(function() + self:CheckRefreshStageGrids() + end, XScheduleManager.SECOND) +end + +function XUiMoeWarPreparation:CheckRefreshStageGrids() + local stages = self.Stages + local lastStageIndex = #stages + local nowServerTime = XTime.GetServerNowTimestamp() + local reserveTime = XDataCenter.MoeWarManager.GetReserveStageTimeByIndex(lastStageIndex) + if nowServerTime >= reserveTime then + self:RefreshStage() + end +end + +function XUiMoeWarPreparation:StopRefreshStageGridsTimer() + if self.RefreshStageGridsTimer then + XScheduleManager.UnSchedule(self.RefreshStageGridsTimer) + self.RefreshStageGridsTimer = nil + end +end + +function XUiMoeWarPreparation:StopTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end + +function XUiMoeWarPreparation:Refresh() + self:RefreshTabBtnTime() + self:RefreshStage() + self:RefreshPercent() + self:RefreshAndCheckActivityTime() + XScheduleManager.ScheduleOnce(handler(self, self.UpdatePanelPhasesReward), 1) --异形屏适配需要 +end + +function XUiMoeWarPreparation:RefreshPercent() + local itemId = XDataCenter.ItemManager.ItemId.MoeWarPreparationItemId + local name = XDataCenter.ItemManager.GetItemName(itemId) + self.TxtPoint.text = XDataCenter.ItemManager.GetCount(itemId) + self.TextPointTitle.text = CSXTextManagerGetText("MoeWarGrandTotal", name) +end + +function XUiMoeWarPreparation:RefreshStage() + if not self.PreparationActivityId then return end + + self.Stages = XDataCenter.MoeWarManager.GetStagesAndOneReserveStage() + local maxStageCount = XMoeWarConfig.GetPreparationActivityMaxStageCount(self.PreparationActivityId) + local currOpenStageCount = XDataCenter.MoeWarManager.GetPreparationAllOpenStageCount() + self.TxtNum.text = CSXTextManagerGetText("MoeWarPreparationCount", currOpenStageCount, maxStageCount) + + self.DynamicTable:SetDataSource(self.Stages) + self.DynamicTable:ReloadDataSync() + + self:CheckStartRefreshStageGridsTimer() +end + +function XUiMoeWarPreparation:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local stageId = self.Stages[index] + grid:Refresh(stageId, index) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_RECYCLE then + grid:Delete() + end +end + +function XUiMoeWarPreparation:RefreshTabBtnTime() + if not self.PreparationActivityId or XTool.UObjIsNil(self.GameObject) then + return + end + + for _, tabBtn in ipairs(self.TabBtns) do + tabBtn:Refresh() + end +end + +function XUiMoeWarPreparation:RefreshAndCheckActivityTime() + local nowServerTime = XTime.GetServerNowTimestamp() + local lastTime = self.PreparationActivityEndTime and self.PreparationActivityEndTime - nowServerTime or 0 + if lastTime <= 0 then + self:StopTimer() + self:Close() + return + end + + self.TxtTime.text = XUiHelper.GetTime(self.PreparationActivityEndTime - nowServerTime, XUiHelper.TimeFormatType.ACTIVITY) +end + +function XUiMoeWarPreparation:OnBtnRecruitClick() + XLuaUiManager.Open("UiMoeWarRecruit") +end + +function XUiMoeWarPreparation:OnBtnSupportClick() + XLuaUiManager.Open("UiMoeWarSupport") +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMoeWar/Preparation/XUiMoeWarPreparationBtnTab.lua b/Resources/Scripts/XUi/XUiMoeWar/Preparation/XUiMoeWarPreparationBtnTab.lua new file mode 100644 index 00000000..907133a2 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMoeWar/Preparation/XUiMoeWarPreparationBtnTab.lua @@ -0,0 +1,65 @@ +local TAB_BTN_TEXT_GROUP = { + ["Title"] = 0, + ["Time"] = 1, + ["NumText"] = 2, +} + +local MatchStatePercent = { + [XMoeWarConfig.MatchState.NotOpen] = 0, + [XMoeWarConfig.MatchState.Open] = 0.5, + [XMoeWarConfig.MatchState.Over] = 1, +} + +local XUiMoeWarPreparationBtnTab = XClass(nil, "XUiMoeWarPreparationBtnTab") + +function XUiMoeWarPreparationBtnTab:Ctor(ui, matchId) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + self.BtnFirst = ui + self.MatchId = matchId + self:Init() +end + +function XUiMoeWarPreparationBtnTab:Init() + local tabBtnName = XMoeWarConfig.GetPreparationMatchName(self.MatchId) + local numText = XMoeWarConfig.GetPreparationMatchNumText(self.MatchId) + self.BtnFirst:SetNameByGroup(TAB_BTN_TEXT_GROUP["Title"], tabBtnName) + self.BtnFirst:SetNameByGroup(TAB_BTN_TEXT_GROUP["NumText"], numText) + self.GameObject:SetActiveEx(true) + + XUiHelper.RegisterClickEvent(self, self.BtnFirst, self.OnBtnFirstClick) +end + +function XUiMoeWarPreparationBtnTab:Refresh() + local timeId = XMoeWarConfig.GetPreparationMatchTimeId(self.MatchId) + local startTime, endTime = XFunctionManager.GetTimeByTimeId(timeId) + local timeStr = XUiHelper.GetInTimeDesc(startTime, endTime) + self.BtnFirst:SetNameByGroup(TAB_BTN_TEXT_GROUP["Time"], timeStr) + + local matchState = XDataCenter.MoeWarManager.GetPreparationMatchOpenState(self.MatchId) + self.Normal.gameObject:SetActiveEx(matchState == XMoeWarConfig.MatchState.Over) + self.Select.gameObject:SetActiveEx(matchState == XMoeWarConfig.MatchState.Open) + self.Disable.gameObject:SetActiveEx(matchState == XMoeWarConfig.MatchState.NotOpen) + + if self.ImgBar then + self.ImgBar.fillAmount = MatchStatePercent[matchState] + end +end + +function XUiMoeWarPreparationBtnTab:OnBtnFirstClick() + local matchState = XDataCenter.MoeWarManager.GetPreparationMatchOpenState(self.MatchId) + if matchState == XMoeWarConfig.MatchState.Over then + local tabBtnName = XMoeWarConfig.GetPreparationMatchName(self.MatchId) + local timeUpDesc = CS.XTextManager.GetText("TimeUp") + XUiManager.TipMsg(tabBtnName .. timeUpDesc) + elseif matchState == XMoeWarConfig.MatchState.NotOpen then + local timeId = XMoeWarConfig.GetPreparationMatchTimeId(self.MatchId) + local startTime, endTime = XFunctionManager.GetTimeByTimeId(timeId) + local timeStr = XUiHelper.GetInTimeDesc(startTime, endTime) + XUiManager.TipMsg(timeStr) + end +end + +return XUiMoeWarPreparationBtnTab \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMoeWar/Preparation/XUiMoeWarPreparationRewardGrid.lua b/Resources/Scripts/XUi/XUiMoeWar/Preparation/XUiMoeWarPreparationRewardGrid.lua new file mode 100644 index 00000000..cbe5da9a --- /dev/null +++ b/Resources/Scripts/XUi/XUiMoeWar/Preparation/XUiMoeWarPreparationRewardGrid.lua @@ -0,0 +1,63 @@ +local XUiMoeWarPreparationRewardGrid = XClass(nil, "XUiMoeWarPreparationRewardGrid") + +function XUiMoeWarPreparationRewardGrid:Ctor(ui, updatePanelPhasesRewardCb, gearId, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + self.RootUi = rootUi + self.UpdatePanelPhasesRewardCb = updatePanelPhasesRewardCb + self.GearId = gearId + self:Init() + XUiHelper.RegisterClickEvent(self, self.BtnClick, self.OnBtnReceiveClick) +end + +function XUiMoeWarPreparationRewardGrid:Init() + self.TxtCurStage.text = XMoeWarConfig.GetPreparationGearNeedCount(self.GearId) + local grid = XUiGridCommon.New(self.RootUi, self.GridCommon) + local rewardId = XMoeWarConfig.GetPreparationGearShowRewardId(self.GearId) + self.Rewards = rewardId > 0 and XRewardManager.GetRewardList(rewardId) or {} + if self.Rewards[1] then + grid:Refresh(self.Rewards[1]) + end +end + +function XUiMoeWarPreparationRewardGrid:Refresh() + local activityId = XMoeWarConfig.GetPreparationActivityIdInTime() + if not activityId then + return + end + + local preGearId = XMoeWarConfig.GetPreparationActivityPrePreparationGear(activityId, self.GearId) + local preGearNeedCount = preGearId and XMoeWarConfig.GetPreparationGearNeedCount(preGearId) or 0 + + local isGetReward = XDataCenter.MoeWarManager.IsPreparationGetRewardGears(self.GearId) + self.PanelFinish.gameObject:SetActiveEx(isGetReward) + + local needCount = XMoeWarConfig.GetPreparationGearNeedCount(self.GearId) - preGearNeedCount + local haveCount = XDataCenter.ItemManager.GetCount(XDataCenter.ItemManager.ItemId.MoeWarPreparationItemId) + haveCount = math.max(haveCount - preGearNeedCount, 0) + local isCanReward = haveCount >= needCount + + self.ImgEffect.gameObject:SetActiveEx(not isGetReward and isCanReward) +end + +function XUiMoeWarPreparationRewardGrid:OnBtnReceiveClick() + local isGetReward = XDataCenter.MoeWarManager.IsPreparationGetRewardGears(self.GearId) + local needCount = XMoeWarConfig.GetPreparationGearNeedCount(self.GearId) + local haveCount = XDataCenter.ItemManager.GetCount(XDataCenter.ItemManager.ItemId.MoeWarPreparationItemId) + local isCanReceive = haveCount >= needCount + + if not isCanReceive then + local templateId = self.Rewards[1] and self.Rewards[1].TemplateId + XLuaUiManager.Open("UiTip", templateId) + elseif (isGetReward) or not XDataCenter.MoeWarManager.CheckRespondItemIsMax() then --已领取的不检查道具是否满了 + XDataCenter.MoeWarManager.RequestMoeWarPreparationGearReward(self.GearId, handler(self, self.Refresh)) + end +end + +function XUiMoeWarPreparationRewardGrid:GetGearId() + return self.GearId +end + +return XUiMoeWarPreparationRewardGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMoeWar/Preparation/XUiMoeWarPreparationStageGrid.lua b/Resources/Scripts/XUi/XUiMoeWar/Preparation/XUiMoeWarPreparationStageGrid.lua new file mode 100644 index 00000000..545bc570 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMoeWar/Preparation/XUiMoeWarPreparationStageGrid.lua @@ -0,0 +1,132 @@ +local REWARD_GRID_MAX_COUNT = 3 +local LABEL_TEXT_MAX_COUNT = 3 +local stringFormat = string.format + +local XUiMoeWarPreparationStageGrid = XClass(nil, "XUiMoeWarPreparationStageGrid") + +function XUiMoeWarPreparationStageGrid:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + self.RootUi = rootUi + self.RewardGrids = {} + self:InitLabelText() + XUiHelper.RegisterClickEvent(self, self.BtnReceive, self.OnBtnReceiveClick) +end + +function XUiMoeWarPreparationStageGrid:Delete() + self:StopTimer() +end + +function XUiMoeWarPreparationStageGrid:InitLabelText() + for i = 1, LABEL_TEXT_MAX_COUNT do + self["LabelText" .. i] = XUiHelper.TryGetComponent(self["Label0" .. i], "Text", "Text") + end +end + +function XUiMoeWarPreparationStageGrid:OnBtnReceiveClick() + XLuaUiManager.Open("UiMoeWarPrepare", self.StageId, self.Index) +end + +function XUiMoeWarPreparationStageGrid:Refresh(stageId, index) + self.GameObject.name = stringFormat("GridShop%s", index) + + self.StageId = stageId + self.Index = index + local isOpenStage = XDataCenter.MoeWarManager.IsOpenPreparationStageByIndex(index) + + self.PrepareNormal.gameObject:SetActiveEx(isOpenStage) + self.PrepareDisable.gameObject:SetActiveEx(not isOpenStage) + + self:RefreshTitle(self.StageId, isOpenStage) + + if not isOpenStage then + self:StartTimer(index) + return + end + + self:RefreshReward(self.StageId) + self:RefreshTag(self.StageId) +end + +function XUiMoeWarPreparationStageGrid:RefreshTitle(stageId, isOpenStage) + if self.TxtTitle then + self.TxtTitle.text = isOpenStage and XFubenConfigs.GetStageName(stageId) or "" + end +end + +function XUiMoeWarPreparationStageGrid:RefreshTag(stageId) + local labelIds = XMoeWarConfig.GetPreparationStageLabelIds(stageId) + for i, labelId in ipairs(labelIds) do + if self["LabelText" .. i] then + self["LabelText" .. i].text = XMoeWarConfig.GetPreparationStageTagLabelById(labelId) + self["Label0" .. i].gameObject:SetActiveEx(true) + end + end + for i = #labelIds + 1, LABEL_TEXT_MAX_COUNT do + self["Label0" .. i].gameObject:SetActiveEx(false) + end +end + +function XUiMoeWarPreparationStageGrid:RefreshReward(stageId) + local rewardId = XMoeWarConfig.GetPreparationStageShowBaseRewardId(stageId) + local showAllRewardId = XMoeWarConfig.GetPreparationStageShowAllRewardId(stageId) + local showAllRewardRewards = showAllRewardId > 0 and XRewardManager.GetRewardList(showAllRewardId) or {} + + for i = 1, REWARD_GRID_MAX_COUNT do + local grid = self.RewardGrids[i] + if showAllRewardRewards[i] then + if not grid then + grid = XUiGridCommon.New(self.RootUi, self["Grid" .. i]) + self.RewardGrids[i] = grid + end + grid:Refresh(showAllRewardRewards[i]) + grid.GameObject:SetActiveEx(true) + else + self["Grid" .. i].gameObject:SetActiveEx(false) + end + end + + local showSpecialRewardId = XMoeWarConfig.GetPreparationStageShowSpecialRewardId(stageId) + local showSpecialRewardIds = showSpecialRewardId > 0 and XRewardManager.GetRewardList(showSpecialRewardId) or {} + local showSpecialItemId = showSpecialRewardIds[1] and showSpecialRewardIds[1].TemplateId + local showSpecialItemCount = showSpecialRewardIds[1] and showSpecialRewardIds[1].Count or 0 + self.Text.text = showSpecialItemId and XDataCenter.ItemManager.GetItemName(showSpecialItemId) or "" + + local goodsShowParams = showSpecialItemId and XGoodsCommonManager.GetGoodsShowParamsByTemplateId(showSpecialItemId) + if XTool.IsTableEmpty(goodsShowParams) then + self.RImgIcon.gameObject:SetActiveEx(false) + self.TxtNumber.text = "" + else + self.RImgIcon:SetRawImage(goodsShowParams.Icon) + self.RImgIcon.gameObject:SetActiveEx(true) + self.TxtNumber.text = "+" .. showSpecialItemCount + end +end + +function XUiMoeWarPreparationStageGrid:StartTimer(index) + self:StopTimer() + + local nowServerTime = XTime.GetServerNowTimestamp() + local reserveTime = XDataCenter.MoeWarManager.GetReserveStageTimeByIndex(index) + self.Timer = XScheduleManager.ScheduleForever(function() + nowServerTime = XTime.GetServerNowTimestamp() + if nowServerTime >= reserveTime then + self:StopTimer() + self:Refresh(self.StageId, self.Index) + return + end + self.TxtTime.text = XUiHelper.GetTime(reserveTime - nowServerTime, XUiHelper.TimeFormatType.DEFAULT) + end, XScheduleManager.SECOND) + self.TxtTime.text = XUiHelper.GetTime(reserveTime - nowServerTime, XUiHelper.TimeFormatType.DEFAULT) +end + +function XUiMoeWarPreparationStageGrid:StopTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end + +return XUiMoeWarPreparationStageGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMoeWar/Prepare/XUiMoeWarPrepare.lua b/Resources/Scripts/XUi/XUiMoeWar/Prepare/XUiMoeWarPrepare.lua new file mode 100644 index 00000000..adac5b24 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMoeWar/Prepare/XUiMoeWarPrepare.lua @@ -0,0 +1,377 @@ +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate +local CSXTextManagerGetText = CS.XTextManager.GetText +local GRID_CONDITION_MAX_COUNT = 3 +local IsNumberValid = XTool.IsNumberValid + +local XUiMoeWarPrepareConditionGrid = require("XUi/XUiMoeWar/Prepare/XUiMoeWarPrepareConditionGrid") + +--赛事筹备关卡 +local XUiMoeWarPrepare = XLuaUiManager.Register(XLuaUi, "UiMoeWarPrepare") + +function XUiMoeWarPrepare:OnAwake() + self.GridConditions = {} + self.RewardGrids = {} + self.ExtraRewardGrids = {} + self.GridCondition.gameObject:SetActiveEx(false) + self.RewardGrid.gameObject:SetActiveEx(false) + self.ExtraRewardGrid.gameObject:SetActiveEx(false) + self.FillConditionCount = 0 --当前选择的角色符合条件的数量 + self.FillConditionIndexDic = {} --当前选择的角色符合条件的index字典 + self:AutoAddListener() + XEventManager.AddEventListener(XEventId.EVENT_FIGHT_RESULT_WIN, self.HandlerFightResult, self) +end + +function XUiMoeWarPrepare:OnStart(stageId, currSelectStageIndex) + self.CurrSelectStageIndex = currSelectStageIndex + self.allOpenStageIdList = XDataCenter.MoeWarManager.GetPreparationAllOpenStageIdList() + self:UpdateStageId(stageId) +end + +function XUiMoeWarPrepare:OnEnable() + if self.IsFightWinCloseView then + self:Close() + return + end + self:CheckHelperOverExpiredHint() + XDataCenter.MoeWarManager.CheckAllOwnHelpersIsResetStatus() + self:Refresh() + XDataCenter.MoeWarManager.JudgeGotoMainWhenFightOver() +end + +function XUiMoeWarPrepare:OnDisable() + self:StopLastTimer() +end + +function XUiMoeWarPrepare:OnDestroy() + XDataCenter.MoeWarManager.ClearPrepareTeamData() + XEventManager.RemoveEventListener(XEventId.EVENT_FIGHT_RESULT_WIN, self.Close, self) +end + +function XUiMoeWarPrepare:OnGetEvents() + return { + XEventId.EVENT_MOE_WAR_PREPARATION_UPDATE, + } +end + +function XUiMoeWarPrepare:OnNotify(event, ...) + if event == XEventId.EVENT_MOE_WAR_PREPARATION_UPDATE then + self:Close() + end +end + +function XUiMoeWarPrepare:AutoAddListener() + self:RegisterClickEvent(self.BtnTanchuangClose, self.Close) + self:RegisterClickEvent(self.BtnChoubei, self.OnBtnChoubeiClick) + self:RegisterClickEvent(self.BtnJoin, self.OpenCharacter) + self:RegisterClickEvent(self.BtnOccupy, self.OpenCharacter) + self:RegisterClickEvent(self.BtnArrorLeft, self.OnBtnArrorLeftClick) + self:RegisterClickEvent(self.BtnArrorRight, self.OnBtnArrorRightClick) + if self.BtnAssist then + self:RegisterClickEvent(self.BtnAssist, self.OnBtnAssistClick) + end +end + +function XUiMoeWarPrepare:HandlerFightResult() + self.IsFightWinCloseView = true +end + +function XUiMoeWarPrepare:UpdateStageId(stageId) + self.StageId = stageId + self.IsFightWinCloseView = false + if self.TextTitle then + self.TextTitle.text = XFubenConfigs.GetStageName(stageId) + end +end + +function XUiMoeWarPrepare:OpenCharacter() + local robotIdList = XDataCenter.MoeWarManager.GetPreparationOwnHelperRobotIdList() + if XTool.IsTableEmpty(robotIdList) then + XUiManager.TipText("MoeWarPrepareNotHelpter") + return + end + + local teamCharIdMap = XDataCenter.MoeWarManager.GetPrepareTeamData(self.StageId) + local charPos = 1 + local stageInfo = XDataCenter.FubenManager.GetStageInfo(self.StageId) + local isHideQuitButton = false + local characterLimitType = XFubenConfigs.GetStageCharacterLimitType(self.StageId) + local limitBuffId = XFubenConfigs.GetStageCharacterLimitBuffId(self.StageId) + XLuaUiManager.Open("UiMoeWarCharacter", teamCharIdMap, charPos, function(resTeam) + XDataCenter.MoeWarManager.SetPrepareTeamData(resTeam) + self:Refresh() + end, stageInfo.Type, isHideQuitButton, characterLimitType, limitBuffId, nil, robotIdList, nil, self.StageId) +end + +--进入战斗 +function XUiMoeWarPrepare:OnBtnChoubeiClick() + if XDataCenter.MoeWarManager.CheckRespondItemIsMax() then + return + end + + local stage = XDataCenter.FubenManager.GetStageCfg(self.StageId) + local teamData = XDataCenter.MoeWarManager.GetPrepareTeamData(stage.StageId) + local charId = teamData[1] + if not charId or charId <= 0 then + XUiManager.TipText("MoeWarPrepareFightNotCharcter") + return + end + + local curTeam = { + TeamData = teamData, + CaptainPos = 1, + FirstFightPos = 1 + } + + local labelIds = XMoeWarConfig.GetPreparationStageLabelIds(self.StageId) + if #labelIds ~= self.FillConditionCount then + XUiManager.DialogTip(CSXTextManagerGetText("TipTitle"), CSXTextManagerGetText("MoeWarConditionNotAllComplete"), XUiManager.DialogType.Normal, nil, function() + XDataCenter.FubenManager.EnterMoeWarFight(stage, curTeam) + end) + return + end + + XDataCenter.FubenManager.EnterMoeWarFight(stage, curTeam) +end + +function XUiMoeWarPrepare:OnBtnArrorLeftClick() + self:OnBtnArrorClick(self.CurrSelectStageIndex - 1) +end + +function XUiMoeWarPrepare:OnBtnArrorRightClick() + self:OnBtnArrorClick(self.CurrSelectStageIndex + 1) +end + +function XUiMoeWarPrepare:OnBtnArrorClick(stageIndex) + if self:CheckStageIndexOutOfRange(stageIndex) then + return + end + self:PlayAnimation("QieHuan") + self.CurrSelectStageIndex = stageIndex + self:UpdateStageId(self.allOpenStageIdList[stageIndex]) + self:Refresh() +end + +function XUiMoeWarPrepare:OnBtnAssistClick() + XLuaUiManager.Open("UiMoeWarRecruit") +end + +function XUiMoeWarPrepare:CheckStageIndexOutOfRange(stageIndex) + if stageIndex <= 0 then + return true + end + + local maxStageCount = #self.allOpenStageIdList + if stageIndex > maxStageCount then + return true + end + + return false +end + +function XUiMoeWarPrepare:Refresh() + self:CheckClearPrepareTeamData() + self:RefreshBtnArror() + self:RefreshHelperId() + self:RefreshHelperCondition() + self:RefreshReward() + self:RefreshOccupy() + self:CheckLastTimer() +end + +function XUiMoeWarPrepare:RefreshBtnArror() + local maxStageCount = #self.allOpenStageIdList + self.BtnArrorLeft.gameObject:SetActiveEx(self.CurrSelectStageIndex > 1) + self.BtnArrorRight.gameObject:SetActiveEx(self.CurrSelectStageIndex < maxStageCount) +end + +function XUiMoeWarPrepare:RefreshHelperId() + local teamData = XDataCenter.MoeWarManager.GetPrepareTeamData(self.StageId) + local charId = teamData[1] + self.HelperId = XDataCenter.MoeWarManager.GetPrepareOwnHelperId(charId) +end + +function XUiMoeWarPrepare:RefreshOccupy() + local teamData = XDataCenter.MoeWarManager.GetPrepareTeamData(self.StageId) + local charId = XRobotManager.GetCharacterId(teamData[1]) + local isHaveHelper = charId > 0 and true or false + self.BtnOccupyMember.gameObject:SetActiveEx(not isHaveHelper) + self.BtnOccupy.gameObject:SetActiveEx(isHaveHelper) + + if isHaveHelper then + local icon = XDataCenter.CharacterManager.GetCharHalfBodyBigImage(charId) + self.RImgRole:SetRawImage(icon) + end +end + +function XUiMoeWarPrepare:CheckClearPrepareTeamData() + if not IsNumberValid(self.HelperId) then + return + end + + local expirationTime = XDataCenter.MoeWarManager.GetRecruitHelperExpirationTime(self.HelperId) + local nowServerTime = XTime.GetServerNowTimestamp() + if IsNumberValid(expirationTime) and nowServerTime >= expirationTime then + XDataCenter.MoeWarManager.ClearPrepareTeamData() + end +end + +function XUiMoeWarPrepare:CheckLastTimer() + self:StopLastTimer() + + local expirationTime = XDataCenter.MoeWarManager.GetRecruitHelperExpirationTime(self.HelperId) + local nowServerTime = XTime.GetServerNowTimestamp() + if not self.HelperId or self.HelperId == 0 or nowServerTime >= expirationTime then + self.TextLastTime.text = "" + self:SetImgLastTimeIsActive(false) + return + end + + self:SetImgLastTimeIsActive(true) + + local timeLimit = expirationTime - nowServerTime + local timeLimitStr = XUiHelper.GetTime(timeLimit, XUiHelper.TimeFormatType.CHATEMOJITIMER) + self.TextLastTime.text = CSXTextManagerGetText("MoeWarHelperTimeLimit", timeLimitStr) + self.LastTimer = XScheduleManager.ScheduleForever(function() + nowServerTime = XTime.GetServerNowTimestamp() + timeLimit = expirationTime - nowServerTime + if timeLimit <= 0 then + self:StopLastTimer() + self:Refresh() + return + end + + timeLimitStr = XUiHelper.GetTime(timeLimit, XUiHelper.TimeFormatType.CHATEMOJITIMER) + self.TextLastTime.text = CSXTextManagerGetText("MoeWarHelperTimeLimit", timeLimitStr) + end, XScheduleManager.SECOND) +end + +function XUiMoeWarPrepare:SetImgLastTimeIsActive(isActive) + if self.ImgLastTime then + self.ImgLastTime.gameObject:SetActiveEx(isActive) + end +end + +function XUiMoeWarPrepare:StopLastTimer() + if self.LastTimer then + XScheduleManager.UnSchedule(self.LastTimer) + self.LastTimer = nil + end +end + +function XUiMoeWarPrepare:RefreshExtraReward() + local rewardIds = XMoeWarConfig.GetPreparationStageShowExtraRewardIds(self.StageId) + local rewardDic = {} + local rewards + for index, rewardId in ipairs(rewardIds) do + rewards = XRewardManager.GetRewardList(rewardId) + if not rewardDic[rewardId] then + rewardDic[rewardId] = XTool.Clone(rewards[1]) + rewardDic[rewardId].Count = 0 + end + if self.FillConditionIndexDic[index] then + rewardDic[rewardId].Count = rewardDic[rewardId].Count + rewards[1].Count + end + end + local extraRewardGridCount = 1 + for _, reward in pairs(rewardDic) do + local grid = self.ExtraRewardGrids[extraRewardGridCount] + if not grid then + grid = XUiGridCommon.New(self, self.ExtraRewardGrid) + grid.Transform:SetParent(self.PaneExtralReward, false) + self.ExtraRewardGrids[extraRewardGridCount] = grid + end + grid:Refresh(reward) + grid.GameObject:SetActiveEx(true) + end + + if not self.HelperId or self.HelperId == 0 then + self.TxtBonus.gameObject:SetActiveEx(true) + self.TxtExtraBonus.gameObject:SetActiveEx(false) + return + end + self.TxtBonus.gameObject:SetActiveEx(false) + self.TxtExtraBonus.gameObject:SetActiveEx(true) + + self.TxtEvaluation.text = XMoeWarConfig.GetPreparationStageEvaluationEvaluatioLabel(self.FillConditionCount) +end + +function XUiMoeWarPrepare:RefreshReward() + local rewardId = XMoeWarConfig.GetPreparationStageShowBaseRewardId(self.StageId) + local rewards = XTool.IsNumberValid(rewardId) and XRewardManager.GetRewardList(rewardId) or {} + local itemId = XDataCenter.ItemManager.ItemId.MoeWarCommunicateItemId + local communicateItemCount = 0 + for i, v in ipairs(rewards) do + local grid = self.RewardGrids[i] + if not grid then + local obj = i == 1 and self.RewardGrid or CSUnityEngineObjectInstantiate(self.RewardGrid, self.PanelReward) + grid = XUiGridCommon.New(self, obj) + grid.Transform:SetParent(self.PanelReward, false) + self.RewardGrids[i] = grid + end + grid:Refresh(v) + grid.GameObject:SetActiveEx(true) + + if v.TemplateId == itemId then + communicateItemCount = v.Count + end + end + + for i = #rewards + 1, #self.RewardGrids do + self.RewardGrids[i].GameObject:SetActiveEx(false) + end + + local showSpecialRewardId = XMoeWarConfig.GetPreparationStageShowSpecialRewardId(self.StageId) + local showSpecialRewardIds = showSpecialRewardId > 0 and XRewardManager.GetRewardList(showSpecialRewardId) or {} + local showSpecialItemId = showSpecialRewardIds[1] and showSpecialRewardIds[1].TemplateId + local showSpecialItemCount = showSpecialRewardIds[1] and showSpecialRewardIds[1].Count or 0 + if self.TxtRewardName then + local itemName = showSpecialItemId and XDataCenter.ItemManager.GetItemName(showSpecialItemId) + self.TxtRewardName.text = itemName and itemName .. ":" or "" + end + + local goodsShowParams = showSpecialItemId and XGoodsCommonManager.GetGoodsShowParamsByTemplateId(showSpecialItemId) + if XTool.IsTableEmpty(goodsShowParams) then + self.RewardIcon.gameObject:SetActiveEx(false) + self.TxtRewardNumber.text = "" + else + self.RewardIcon:SetRawImage(goodsShowParams.Icon) + self.RewardIcon.gameObject:SetActiveEx(true) + self.TxtRewardNumber.text = "+" .. showSpecialItemCount + end +end + +function XUiMoeWarPrepare:RefreshHelperCondition() + local labelIds = XMoeWarConfig.GetPreparationStageLabelIds(self.StageId) + self.FillConditionCount = 0 + self.FillConditionIndexDic = {} + for i, stageLabelId in ipairs(labelIds) do + local grid = self.GridConditions[i] + if not grid then + local gridCondition = 1 == i and self.GridCondition or CSUnityEngineObjectInstantiate(self.GridCondition, self.PanelConditions) + grid = XUiMoeWarPrepareConditionGrid.New(gridCondition, i) + self.GridConditions[i] = grid + end + grid:Refresh(self.StageId, stageLabelId, self.HelperId) + grid:SetActive(true) + if XMoeWarConfig.IsFillPreparationStageLabel(stageLabelId, self.HelperId) then + self.FillConditionCount = self.FillConditionCount + 1 + self.FillConditionIndexDic[i] = true + end + end + self:RefreshExtraReward() + + for i = #labelIds + 1, GRID_CONDITION_MAX_COUNT do + if self.GridConditions[i] then + self.GridConditions[i]:SetActive(false) + end + end +end + +function XUiMoeWarPrepare:CheckHelperOverExpiredHint() + local teamData = XDataCenter.MoeWarManager.GetPrepareTeamData(self.StageId) + local charId = teamData[1] + local helperId = XDataCenter.MoeWarManager.GetPrepareOwnHelperId(charId) + if XDataCenter.MoeWarManager.IsHelperExpired(helperId) then + XUiManager.TipText("MoeWarHelperOverExpired") + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMoeWar/Prepare/XUiMoeWarPrepareConditionGrid.lua b/Resources/Scripts/XUi/XUiMoeWar/Prepare/XUiMoeWarPrepareConditionGrid.lua new file mode 100644 index 00000000..f4bc257c --- /dev/null +++ b/Resources/Scripts/XUi/XUiMoeWar/Prepare/XUiMoeWarPrepareConditionGrid.lua @@ -0,0 +1,51 @@ +local CSXTextManagerGetText = CS.XTextManager.GetText + +local XUiMoeWarPrepareConditionGrid = XClass(nil, "XUiMoeWarPrepareConditionGrid") + +function XUiMoeWarPrepareConditionGrid:Ctor(ui, index) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + self.Index = index +end + +function XUiMoeWarPrepareConditionGrid:Refresh(stageId, stageLabelId, helperId) + local tagLabel = XMoeWarConfig.GetPreparationStageTagLabelById(stageLabelId) + self.TxtSelectConditions.text = CSXTextManagerGetText("MoeWarConditionDesc", self.Index, tagLabel) + self.TxtNormalConditions.text = CSXTextManagerGetText("MoeWarConditionDesc", self.Index, tagLabel) + + local rewardName = XMoeWarConfig.GetPreparationStageShowExtraRewardName(stageId, self.Index) + self.TxtNormalPrepare.text = rewardName + self.TxtSelectPrepare.text = rewardName + + local num = XMoeWarConfig.GetPreparationStageExtraRewardCount(stageId, self.Index) + self.TxtSelectNumber.text = "+" .. num + self.TxtNormalNumber.text = "+" .. num + + local rewardId = XMoeWarConfig.GetPreparationStageShowExtraRewardId(stageId, self.Index) + local rewardList = XTool.IsNumberValid(rewardId) and XRewardManager.GetRewardList(rewardId) or {} + local itemId = rewardList[1] and rewardList[1].TemplateId + local goodsShowParams = itemId and XGoodsCommonManager.GetGoodsShowParamsByTemplateId(itemId) + local icon = goodsShowParams and goodsShowParams.Icon + if self.NormalIcon and icon then + self.NormalIcon:SetRawImage(icon) + end + if self.SelectIcon and icon then + self.SelectIcon:SetRawImage(icon) + end + + if XMoeWarConfig.IsFillPreparationStageLabel(stageLabelId, helperId) then + self.Normal.gameObject:SetActiveEx(false) + self.Select.gameObject:SetActiveEx(true) + return + end + self.Normal.gameObject:SetActiveEx(true) + self.Select.gameObject:SetActiveEx(false) +end + +function XUiMoeWarPrepareConditionGrid:SetActive(isActive) + self.GameObject:SetActiveEx(isActive) +end + +return XUiMoeWarPrepareConditionGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMoeWar/Recruit/XUiMoeWarChatPools.lua b/Resources/Scripts/XUi/XUiMoeWar/Recruit/XUiMoeWarChatPools.lua new file mode 100644 index 00000000..22800c1b --- /dev/null +++ b/Resources/Scripts/XUi/XUiMoeWar/Recruit/XUiMoeWarChatPools.lua @@ -0,0 +1,18 @@ +local XUiMoeWarChatPools = XClass(nil, "XUiMoeWarChatPools") + +function XUiMoeWarChatPools:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiMoeWarChatPools:InitData(dynamicList) + self.GameObject:SetActiveEx(false) + dynamicList:AddObjectPools("myMsg", self.PanelSocialMyMsgItem.gameObject) + dynamicList:AddObjectPools("otherMsg", self.PanelSocialOhterMsgItem.gameObject) + dynamicList:AddObjectPools("myNo", self.PanelSocialMyNo.gameObject) + dynamicList:AddObjectPools("myYes", self.PanelSocialMyYes.gameObject) + dynamicList:AddObjectPools("line", self.PanelLine.gameObject) +end + +return XUiMoeWarChatPools \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMoeWar/Recruit/XUiMoeWarRecruit.lua b/Resources/Scripts/XUi/XUiMoeWar/Recruit/XUiMoeWarRecruit.lua new file mode 100644 index 00000000..5ff7aa2f --- /dev/null +++ b/Resources/Scripts/XUi/XUiMoeWar/Recruit/XUiMoeWarRecruit.lua @@ -0,0 +1,266 @@ +local CSXTextManagerGetText = CS.XTextManager.GetText + +local XUiMoeWarRecruitGrid = require("XUi/XUiMoeWar/Recruit/XUiMoeWarRecruitGrid") +local XUiMoeWarRecruitMsgPanel = require("XUi/XUiMoeWar/Recruit/XUiMoeWarRecruitMsgPanel") + +--招募通讯和答题 +local XUiMoeWarRecruit = XLuaUiManager.Register(XLuaUi, "UiMoeWarRecruit") + +function XUiMoeWarRecruit:OnAwake() + self:AutoAddListener() + + self:InitAssetPanel() + self.ContactButtons = {} + self.ContactButtonObjList = {} +end + +function XUiMoeWarRecruit:OnStart() + self:SetCurrOpenMatch() + + self:InitMsgListPanel() + self:RefreshAssetPanel() +end + +function XUiMoeWarRecruit:OnEnable() + self:Refresh() + self:StartTimer() + XDataCenter.MoeWarManager.JudgeGotoMainWhenFightOver() +end + +function XUiMoeWarRecruit:OnDisable() + self:StopTimer() + self.MsgListPanel:OnDisable() + for _, contactButtonObj in ipairs(self.ContactButtonObjList) do + contactButtonObj:OnDisable() + end +end + +function XUiMoeWarRecruit:InitMsgListPanel() + local refreshContactButtonCb = handler(self, self.RefreshCurrSelectContactButton) + local playAnimation = handler(self, self.PlayAnimation) + local contactButtonClickCallBack = handler(self, self.ContactButtonClickCallBack) + local resetCurrSelectContactBtnIndexCb = handler(self, self.ResetCurrSelectContactBtnIndex) + self.MsgListPanel = XUiMoeWarRecruitMsgPanel.New(self.MsgList, refreshContactButtonCb, playAnimation, contactButtonClickCallBack, resetCurrSelectContactBtnIndexCb) +end + +function XUiMoeWarRecruit:AutoAddListener() + self:RegisterClickEvent(self.BtnBack, self.Close) + self:RegisterClickEvent(self.BtnMainUi, function() XLuaUiManager.RunMain() end) + self:RegisterClickEvent(self.BtnCommunicateIcon, handler(self, self.OnBtnCommunicateIconClick)) +end + +function XUiMoeWarRecruit:SetCurrOpenMatch() + self.CurrOpenMatchId = XMoeWarConfig.GetPreparationCurrOpenMatchId() + if not self.CurrOpenMatchId then + self:Close() + return + end + local timeId = XMoeWarConfig.GetPreparationMatchTimeId(self.CurrOpenMatchId) + self.CurrOpenMatchEndTime = XFunctionManager.GetEndTimeByTimeId(timeId) +end + +function XUiMoeWarRecruit:RefreshCurrOpenMatch() + self:SetCurrOpenMatch() + self:Refresh() +end + +function XUiMoeWarRecruit:OnGetEvents() + return { + XEventId.EVENT_MOE_WAR_PREPARATION_UPDATE, + } +end + +function XUiMoeWarRecruit:OnNotify(event, ...) + if event == XEventId.EVENT_MOE_WAR_PREPARATION_UPDATE then + self:RefreshCurrOpenMatch() + end +end + +function XUiMoeWarRecruit:InitAssetPanel() + if not self.PanelSpecialTool then + return + end + local actInfo = XDataCenter.MoeWarManager.GetActivityInfo() + local currencyIdList = actInfo and actInfo.CurrencyId or {} + self.AssetActivityPanel = XUiPanelActivityAsset.New(self.PanelSpecialTool) + + XDataCenter.ItemManager.AddCountUpdateListener(currencyIdList, function() + self.AssetActivityPanel:Refresh(currencyIdList) + end, self.AssetActivityPanel) +end + +function XUiMoeWarRecruit:OnBtnCommunicateIconClick() + local itemId = XDataCenter.ItemManager.ItemId.MoeWarCommunicateItemId + XLuaUiManager.Open("UiTip", itemId) +end + +function XUiMoeWarRecruit:RefreshAssetPanel() + if not self.AssetActivityPanel then + return + end + local actInfo = XDataCenter.MoeWarManager.GetActivityInfo() + local currencyIdList = actInfo and actInfo.CurrencyId or {} + self.AssetActivityPanel:Refresh(currencyIdList) +end + +function XUiMoeWarRecruit:Refresh() + self:RefreshAndCheckActivityTime() + self:RefreshRecruitCount() + self:RefreshContactButtonGroup() + self:RefreshMsgList() +end + +function XUiMoeWarRecruit:RefreshMsgList(isNotRefreshMsgPanel) + if not self.MsgListPanel then + return + end + if isNotRefreshMsgPanel then + self.MsgListPanel:RefreshAnswerRecord() + else + self.MsgListPanel:Refresh() + end +end + +function XUiMoeWarRecruit:RefreshContactButtonGroup() + if not self.CurrOpenMatchId then return end + + self.CurrSelectContactBtnIndex = nil + self.HelperIds = XMoeWarConfig.GetPreparationMatchHelperIds(self.CurrOpenMatchId) + for i, helperId in ipairs(self.HelperIds) do + local gridObj = self.ContactButtonObjList[i] + if not gridObj then + local obj = i == 1 and self.GridPanel or CS.UnityEngine.Object.Instantiate(self.GridPanel, self.Contact) + gridObj = XUiMoeWarRecruitGrid.New(obj, i) + self.ContactButtonObjList[i] = gridObj + self.ContactButtons[i] = XUiHelper.TryGetComponent(obj.transform, "BtnBackground", "XUiButton") + end + gridObj:SetHelperId(helperId) + gridObj:Refresh() + gridObj:SetActive(true) + end + + local contactCount = #self.ContactButtonObjList + for i = #self.HelperIds + 1, contactCount do + self.ContactButtonObjList:SetActive(false) + end + self.ContactButtonGroup:Init(self.ContactButtons, function(index) self:OnSelectContactButton(index) end) +end + +function XUiMoeWarRecruit:RefreshCurrSelectContactButton() + local currSelectContactButtonIndex = self.CurrSelectContactBtnIndex + local obj = currSelectContactButtonIndex and self.ContactButtonObjList[currSelectContactButtonIndex] + if not obj then + return + end + obj:Refresh() +end + +function XUiMoeWarRecruit:OnSelectContactButton(index) + local obj = self.ContactButtonObjList[index] + local helperId = obj and obj:GetHelperId() + if self.CurrSelectContactBtnIndex == index then + if not helperId then + return + end + + local helperStatus = XDataCenter.MoeWarManager.GetRecruitHelperStatus(helperId) + if helperStatus == XMoeWarConfig.PreparationHelperStatus.Communicating or helperStatus == XMoeWarConfig.PreparationHelperStatus.RecruitFinish then + return + end + end + + if helperId then + self:ContactButtonClickCallBack(helperId, index) + end +end + +function XUiMoeWarRecruit:ContactButtonClickCallBack(helperId, currSelectContactBtnIndex) + currSelectContactBtnIndex = currSelectContactBtnIndex or self.CurrSelectContactBtnIndex + + local status = XDataCenter.MoeWarManager.GetRecruitHelperStatus(helperId) + if status == XMoeWarConfig.PreparationHelperStatus.Communicating then + self:RequestMoeWarPreparationHelperCommunicate(helperId, currSelectContactBtnIndex) + elseif status == XMoeWarConfig.PreparationHelperStatus.CommunicationEnd or status ~= XMoeWarConfig.PreparationHelperStatus.RecruitFinish then + local count = XMoeWarConfig.GetMoeWarPreparationCommunicateConsumeCount(helperId) + local roleName = XMoeWarConfig.GetCharacterFullNameByHelperId(helperId) + local desc = CSXTextManagerGetText("MoeWarRecruitTipsDesc", count, roleName) + local okFunc = function() + self:RequestMoeWarPreparationHelperCommunicate(helperId, currSelectContactBtnIndex) + end + XUiManager.DialogTip(CSXTextManagerGetText("TipTitle"), desc, XUiManager.DialogType.Normal, handler(self, self.CancelSelect), okFunc) + end +end + +function XUiMoeWarRecruit:CancelSelect() + self.ContactButtonGroup:CancelSelect() + if self.CurrSelectContactBtnIndex then + self.ContactButtonGroup:SelectIndex(self.CurrSelectContactBtnIndex, false) + end +end + +function XUiMoeWarRecruit:ResetCurrSelectContactBtnIndex() + self.CurrSelectContactBtnIndex = nil +end + +function XUiMoeWarRecruit:RequestMoeWarPreparationHelperCommunicate(helperId, currSelectContactBtnIndex) + local setMsgListPanelHelperIdCb = function(helperId) + self.MsgListPanel:SetHelperId(helperId) + end + + local receiveChatHandlerCb = function(chatData) + self.MsgListPanel:ReceiveChatHandler(chatData) + end + + local refreshCb = function(helperId, currSelectContactBtnIndex, isNotRefreshMsgPanel) + self:PlayAnimation("QieHuan") + local obj = self.ContactButtonObjList[currSelectContactBtnIndex] + if obj then + obj:Refresh() + end + self:RefreshMsgList(isNotRefreshMsgPanel) + self:RefreshRecruitCount() + self.CurrSelectContactBtnIndex = currSelectContactBtnIndex + end + + local requestFailCb = handler(self, self.CancelSelect) + + XDataCenter.MoeWarManager.RequestMoeWarPreparationHelperCommunicate(helperId, refreshCb, receiveChatHandlerCb, currSelectContactBtnIndex, setMsgListPanelHelperIdCb, requestFailCb) +end + +function XUiMoeWarRecruit:StartTimer() + self:StopTimer() + self.Timer = XScheduleManager.ScheduleForever(function() + self:RefreshAndCheckActivityTime() + end, XScheduleManager.SECOND) +end + +function XUiMoeWarRecruit:StopTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end + +function XUiMoeWarRecruit:RefreshAndCheckActivityTime() + local nowServerTime = XTime.GetServerNowTimestamp() + local lastTime = self.CurrOpenMatchEndTime and self.CurrOpenMatchEndTime - nowServerTime or 0 + if lastTime <= 0 then + self:StopTimer() + self:Close() + return + end +end + +function XUiMoeWarRecruit:RefreshRecruitCount() + local itemId = XDataCenter.ItemManager.ItemId.MoeWarCommunicateItemId + local icon = XDataCenter.ItemManager.GetItemIcon(itemId) + self.CommunicateIcon:SetRawImage(icon) + + local itemCount = XDataCenter.ItemManager.GetCount(itemId) + local itemMaxCount = XDataCenter.ItemManager.GetMaxCount(itemId) + self.NumTxt.text = CSXTextManagerGetText("MoeWarLastRecruitCount", itemCount, itemMaxCount) + + local itemName = XItemConfigs.GetItemNameById(itemId) + local residueDesc = CSXTextManagerGetText("Residue") + self.InfoText.text = residueDesc .. itemName +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMoeWar/Recruit/XUiMoeWarRecruitGrid.lua b/Resources/Scripts/XUi/XUiMoeWar/Recruit/XUiMoeWarRecruitGrid.lua new file mode 100644 index 00000000..60a0c3ae --- /dev/null +++ b/Resources/Scripts/XUi/XUiMoeWar/Recruit/XUiMoeWarRecruitGrid.lua @@ -0,0 +1,156 @@ +local TEXT_GROUP = { + ["Name"] = 0, + ["Time"] = 1, + ["Tag1"] = 2, + ["Tag2"] = 3, + ["Tag3"] = 4, +} +local TAG_MAX_COUNT = 3 +local CSXTextManagerGetText = CS.XTextManager.GetText +local Normal = CS.UiButtonState.Normal +local Select = CS.UiButtonState.Select +local Disable = CS.UiButtonState.Disable + +local XUiMoeWarRecruitGrid = XClass(nil, "XUiMoeWarRecruitGrid") + +function XUiMoeWarRecruitGrid:Ctor(ui, index) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + self.Index = index + self.BtnBackground:SetButtonState(Normal) +end + +function XUiMoeWarRecruitGrid:OnDisable() + self:StopTimer() +end + +function XUiMoeWarRecruitGrid:SetHelperId(helperId) + self.HelperId = helperId +end + +function XUiMoeWarRecruitGrid:Refresh() + local helperId = self.HelperId + if not helperId then + return + end + + XDataCenter.MoeWarManager.CheckIsResetHelperStatus(helperId) + + self:RefreshRoleInfo(helperId) + self:RefreshTag(helperId) + self:RefreshStatus(helperId) + self:RefreshRedPoint(helperId) + self:CheckBtnDisableAndTagIcon(helperId) +end + +function XUiMoeWarRecruitGrid:RefreshRedPoint(helperId) + local isShowRedPoint = XDataCenter.MoeWarManager.CheckHelperRedPoint(helperId) + self.BtnBackground:ShowReddot(isShowRedPoint) +end + +function XUiMoeWarRecruitGrid:RefreshStatus(helperId) + local helperStatus = XDataCenter.MoeWarManager.GetRecruitHelperStatus(helperId) + local isRecruitFinish = helperStatus == XMoeWarConfig.PreparationHelperStatus.RecruitFinish + self.TagZhaomu.gameObject:SetActiveEx(isRecruitFinish) + self.TagJindu.gameObject:SetActiveEx(not isRecruitFinish) + + self:CheckStartTimer(isRecruitFinish, helperId) + self:RefreshPercent(isRecruitFinish, helperId) +end + +function XUiMoeWarRecruitGrid:RefreshPercent(isRecruitFinish, helperId) + if isRecruitFinish then + return + end + local currRightCount = XDataCenter.MoeWarManager.GetFinishQuestionCount(helperId) + local totalCount = XMoeWarConfig.GetMoeWarPreparationHelperTotalQuestionCount(helperId) + self.TxtNum.text = currRightCount .. "/" .. totalCount + self.ImgJindu.fillAmount = totalCount > 0 and currRightCount / totalCount or 0 +end + +function XUiMoeWarRecruitGrid:CheckStartTimer(isRecruitFinish, helperId) + self:StopTimer() + if not isRecruitFinish then + self.BtnBackground:SetNameByGroup(TEXT_GROUP["Time"], "") + return + end + + local nowServerTime = XTime.GetServerNowTimestamp() + local expirationTime = XDataCenter.MoeWarManager.GetRecruitHelperExpirationTime(helperId) + if nowServerTime >= expirationTime then + self.BtnBackground:SetNameByGroup(TEXT_GROUP["Time"], "") + return + end + + local timeLimit = expirationTime - nowServerTime + local timeLimitStr = XUiHelper.GetTime(timeLimit, XUiHelper.TimeFormatType.CHATEMOJITIMER) + self.BtnBackground:SetNameByGroup(TEXT_GROUP["Time"], CSXTextManagerGetText("MoeWarHelperTimeLimit", timeLimitStr)) + self.Timer = XScheduleManager.ScheduleForever(function() + nowServerTime = XTime.GetServerNowTimestamp() + timeLimit = expirationTime - nowServerTime + if timeLimit <= 0 then + self:StopTimer() + self:Refresh() + return + end + + if not XTool.UObjIsNil(self.BtnBackground) then + timeLimitStr = XUiHelper.GetTime(timeLimit, XUiHelper.TimeFormatType.CHATEMOJITIMER) + self.BtnBackground:SetNameByGroup(TEXT_GROUP["Time"], CSXTextManagerGetText("MoeWarHelperTimeLimit", timeLimitStr)) + end + end, XScheduleManager.SECOND) +end + +function XUiMoeWarRecruitGrid:StopTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end + +function XUiMoeWarRecruitGrid:RefreshTag(helperId) + local lableIds = XMoeWarConfig.GetMoeWarPreparationHelperLabelIds(helperId) + for i, lableId in ipairs(lableIds) do + if not TEXT_GROUP["Tag" .. i] then + break + end + local label = XMoeWarConfig.GetPreparationStageTagLabelById(lableId) + self.BtnBackground:SetNameByGroup(TEXT_GROUP["Tag" .. i], label) + end +end + +function XUiMoeWarRecruitGrid:RefreshRoleInfo(helperId) + local robotId = XMoeWarConfig.GetMoeWarPreparationHelperRobotId(helperId) + local characterId = XRobotManager.GetCharacterId(robotId) + local roleName = XCharacterConfigs.GetCharacterFullNameStr(characterId) + self.BtnBackground:SetNameByGroup(TEXT_GROUP["Name"], roleName) + + local headIcon = XMoeWarConfig.GetMoeWarPreparationHelperCirleIcon(helperId) + self.StandIcon:SetRawImage(headIcon) +end + +function XUiMoeWarRecruitGrid:CheckBtnDisableAndTagIcon(helperId) + local helperStatus = XDataCenter.MoeWarManager.GetRecruitHelperStatus(helperId) + local isRecruitFinish = helperStatus == XMoeWarConfig.PreparationHelperStatus.RecruitFinish + if isRecruitFinish and self.BtnBackground.ButtonState ~= Disable then + self.BtnBackground:SetDisable(true, false) + elseif self.BtnBackground.ButtonState == Disable then + self.BtnBackground:SetDisable(false) + end + + if self.TagLock then + self.TagLock.gameObject:SetActiveEx(not isRecruitFinish) + end +end + +function XUiMoeWarRecruitGrid:SetActive(isShow) + self.GameObject:SetActiveEx(isShow) +end + +function XUiMoeWarRecruitGrid:GetHelperId() + return self.HelperId +end + +return XUiMoeWarRecruitGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMoeWar/Recruit/XUiMoeWarRecruitMsgPanel.lua b/Resources/Scripts/XUi/XUiMoeWar/Recruit/XUiMoeWarRecruitMsgPanel.lua new file mode 100644 index 00000000..6c9cba7a --- /dev/null +++ b/Resources/Scripts/XUi/XUiMoeWar/Recruit/XUiMoeWarRecruitMsgPanel.lua @@ -0,0 +1,391 @@ +local BtnAnswerMaxCount = 3 +local tableInsert = table.insert +local tableRemove = table.remove +local CSXTextManagerGetText = CS.XTextManager.GetText +local Vector2 = CS.UnityEngine.Vector2 +local ButtonStateDisable = CS.UiButtonState.Disable +local IsNumberValid = XTool.IsNumberValid + +local XUiMoeWarChatPools = require("XUi/XUiMoeWar/Recruit/XUiMoeWarChatPools") +local XUiPanelMsgItem = require("XUi/XUiMoeWar/Recruit/XUiPanelMsgItem") +local XUiPanelLineItem = require("XUi/XUiMoeWar/Recruit/XUiPanelLineItem") + +local XUiMoeWarRecruitMsgPanel = XClass(nil, "XUiMoeWarRecruitMsgPanel") + +function XUiMoeWarRecruitMsgPanel:Ctor(ui, refreshContactButtonCb, playAnimation, contactButtonClickCallBack, resetCurrSelectContactBtnIndexCb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + self.RefreshContactButtonCb = refreshContactButtonCb + self.PlayAnimation = playAnimation + self.ContactButtonClickCallBack = contactButtonClickCallBack + self.ResetCurrSelectContactBtnIndexCb = resetCurrSelectContactBtnIndexCb + + self.PanelTip.gameObject:SetActiveEx(false) + self:AutoAddListener() + + self.DynamicListManager = XDynamicList.New(self.PanelChatView.transform, self) + self.DynamicListManager:SetReverse(true) + + self.PanelChatPools = XUiMoeWarChatPools.New(self.PanelSocialPools) + self.PanelChatPools:InitData(self.DynamicListManager) + + self.InsertDynamicData = {} + self.PanelChatViewDefaultHeight = self.PanelChatView.rect.height + + self.TempExcludeAnima = {} --缓存当前问题已播放动画的错误答案 +end + +function XUiMoeWarRecruitMsgPanel:OnDisable() + self:StopInsertDynamicTimer() + self:StopTimer() + self:CancelPauseInsertDynamicTimer() +end + +function XUiMoeWarRecruitMsgPanel:AutoAddListener() + self.BtnHelp.CallBack = function() self:OnBtnHelpClick() end + + for i = 1, BtnAnswerMaxCount do + self["BtnRecord" .. i].CallBack = function() self:OnBtnClickRequestHelperAnswer(i) end + end +end + +function XUiMoeWarRecruitMsgPanel:SetHelperId(helperId) + self.HelperId = helperId + self.BtnHuifu.CallBack = function() self:OnBtnHuifuClick() end + self.BtnHuifu:SetName(CSXTextManagerGetText("MoeWarRecruitSelectReply")) +end + +function XUiMoeWarRecruitMsgPanel:Refresh() + if not self.HelperId then + self:SetMsgListPanelIsNone(true) + return + end + + self.InsertDynamicData = {} + self.PanelTip.gameObject:SetActiveEx(false) + self:ChangePanelChatViewHeight(false) + self:StopInsertDynamicTimer() + self:CancelPauseInsertDynamicTimer() + self:SetMsgListPanelIsNone(false) + + self:RefreshAnswerRecord() + self:RefreshPanelChat() +end + +function XUiMoeWarRecruitMsgPanel:RefreshAnswerRecord() + if not self.HelperId then + return + end + self.AnswerRecordsTemplate = XDataCenter.MoeWarManager.GetAnswerRecordsTemplate(self.HelperId) + + local totalCount = XMoeWarConfig.GetMoeWarPreparationHelperTotalQuestionCount(self.HelperId) + local currCount = XDataCenter.MoeWarManager.GetCurrQuestionCount(self.HelperId) + local rightCount = XDataCenter.MoeWarManager.GetFinishQuestionCount(self.HelperId) + self.TextAnswerRecordPerctnt.text = CSXTextManagerGetText("MoeWarAnswerRecordPerctnt", currCount, totalCount) + self.TextAnswerRecordRightCount.text = CSXTextManagerGetText("MoeWarAnswerRecordRightCount", rightCount) +end + +function XUiMoeWarRecruitMsgPanel:RefreshPanelChat() + local allQuestionTemplate = XDataCenter.MoeWarManager.GetAllQuestionTemplateByHelperId(self.HelperId) + self:InitWorldChatDynamicList(allQuestionTemplate) + self:SetBtnHuifuDisable(false) +end + +--每间隔一段时间插入一条对话 +function XUiMoeWarRecruitMsgPanel:ReceiveChatHandler(chatData) + if XTool.UObjIsNil(self.GameObject) then + return + end + + for _, v in ipairs(chatData) do + tableInsert(self.InsertDynamicData, v) + end + + self:SetBtnHuifuDisable(true) + self.PanelTip.gameObject:SetActiveEx(false) + self:ChangePanelChatViewHeight(false) + self:SetMsgListPanelIsNone(false) + self:RefreshAnswerRecord() + + self:StartInsertDynamicTimer() +end + +function XUiMoeWarRecruitMsgPanel:CheckInsertDynamicDataIsEmptyAndRefresh() + if XTool.IsTableEmpty(self.InsertDynamicData) then + self:CheckBtnHuifuIsClick() + self:StopInsertDynamicTimer() + return true + end + return false +end + +function XUiMoeWarRecruitMsgPanel:StartInsertDynamicTimer() + self:StopInsertDynamicTimer() + if self.IsPauseInsertDynamicTimer then + return + end + if self:CheckInsertDynamicDataIsEmptyAndRefresh() then + return + end + self.InsertDynamicTimer = XScheduleManager.ScheduleForever(function() + if not XTool.IsTableEmpty(self.InsertDynamicData) then + local newChatData = tableRemove(self.InsertDynamicData, 1) + self.DynamicListManager:InsertData({ newChatData }, DLInsertDataDir.Head, true) + return + end + self:CheckInsertDynamicDataIsEmptyAndRefresh() + end, 500) +end + +function XUiMoeWarRecruitMsgPanel:StopInsertDynamicTimer() + if self.InsertDynamicTimer then + XScheduleManager.UnSchedule(self.InsertDynamicTimer) + self.InsertDynamicTimer = nil + end +end + +function XUiMoeWarRecruitMsgPanel:PauseInsertDynamicTimer() + self.IsPauseInsertDynamicTimer = true + self:StopInsertDynamicTimer() +end + +function XUiMoeWarRecruitMsgPanel:CancelPauseInsertDynamicTimer(isStartInsertDynamicTimer) + self.IsPauseInsertDynamicTimer = false + if isStartInsertDynamicTimer then + self:StartInsertDynamicTimer() + end +end + +function XUiMoeWarRecruitMsgPanel:InitWorldChatDynamicList(msgData) + --初始化动态列表数据 + msgData = msgData or {} + self.DynamicListManager:SetData(msgData, function(data, cb) + local poolName = nil + local ctor = nil + local recruitMsgType = data.RecruitMsgType + if recruitMsgType == XMoeWarConfig.RecruitMsgType.MyMsg then + poolName = "myMsg" + ctor = XUiPanelMsgItem.New + elseif recruitMsgType == XMoeWarConfig.RecruitMsgType.OtherMsg then + poolName = "otherMsg" + ctor = XUiPanelMsgItem.New + elseif recruitMsgType == XMoeWarConfig.RecruitMsgType.MyNo then + poolName = "myNo" + ctor = XUiPanelMsgItem.New + elseif recruitMsgType == XMoeWarConfig.RecruitMsgType.MyYes then + poolName = "myYes" + ctor = XUiPanelMsgItem.New + elseif recruitMsgType == XMoeWarConfig.RecruitMsgType.Line then + poolName = "line" + ctor = XUiPanelLineItem.New + end + if cb and poolName and ctor then + local item = cb(poolName, ctor) + item.RootUi = self + item.PauseInsertDynamicTimer = handler(self, self.PauseInsertDynamicTimer) + item.CancelPauseInsertDynamicTimer = handler(self, self.CancelPauseInsertDynamicTimer) + item:Refresh(data, self.HelperId) + else + XLog.Error("------Init MoeWarRecruitMsg item is error!------") + end + end) +end + +function XUiMoeWarRecruitMsgPanel:SetMsgListPanelIsNone(isNone) + self.PanelJindu.gameObject:SetActiveEx(not isNone) + self.Content.gameObject:SetActiveEx(not isNone) + self.PanelNone.gameObject:SetActiveEx(isNone) + if isNone then + self.PanelTip.gameObject:SetActiveEx(false) + self:SetBtnHuifuDisable(true) + end +end + +function XUiMoeWarRecruitMsgPanel:OnBtnHuifuClick() + local activeSelf = self.PanelTip.gameObject.activeSelf + self:RefreshHuifuPanel(not activeSelf) + self:ChangePanelChatViewHeight(not activeSelf) + self.PanelTip.gameObject:SetActiveEx(not activeSelf) + if self.PanelTipCanvasGroup and not activeSelf then + self.PanelTipCanvasGroup.alpha = 0 + end + if self.PlayAnimation and not activeSelf then + self.PlayAnimation("PanelTipEnable") + end +end + +function XUiMoeWarRecruitMsgPanel:OnBtnHuifuClickContinueContact() + if self.ContactButtonClickCallBack then + self.ContactButtonClickCallBack(self.HelperId) + end +end + +function XUiMoeWarRecruitMsgPanel:OnBtnHuifuClickClose() + self.BtnHuifu.CallBack = function() self:OnBtnHuifuClick() end + self:SetMsgListPanelIsNone(true) + self.HelperId = nil + self:CheckBtnHuifuIsClick() + if self.ResetCurrSelectContactBtnIndexCb then + self.ResetCurrSelectContactBtnIndexCb() + end +end + +function XUiMoeWarRecruitMsgPanel:ChangePanelChatViewHeight(activeSelf) + local defaultWidth = self.PanelChatView.rect.width + local height = activeSelf and self.PanelChatViewDefaultHeight * 0.6 or self.PanelChatViewDefaultHeight + self.PanelChatView:SetInsetAndSizeFromParentEdge(CS.UnityEngine.RectTransform.Edge.Top, 0, height) + self.DynamicListManager:SetViewSize(Vector2(defaultWidth, height), true) +end + +--刷新回答问题 +function XUiMoeWarRecruitMsgPanel:RefreshHuifuPanel(activeSelf) + if not activeSelf or not self.AnswerRecordsTemplate then + return + end + + local questionId + local questionType + for _, template in ipairs(self.AnswerRecordsTemplate) do + local tempQuestionId = template:GetQuestionId() + questionType = XMoeWarConfig.GetPreparationQuestionType(tempQuestionId) + if questionType == XMoeWarConfig.QuestionType.RandomQuestion and template:GetAnswerId() == 0 then + questionId = tempQuestionId + break + end + end + if not questionId then return end + + if not self.TempExcludeAnima[questionId] then + self.TempExcludeAnima = {} + self.TempExcludeAnima[questionId] = {} + end + + local answers = XMoeWarConfig.GetPreparationQuestionAnswers(questionId) + local isExcludeWrongAnswer + for i = 1, BtnAnswerMaxCount do + if answers[i] then + local btnRecord = self["BtnRecord" .. i] + btnRecord:SetNameByGroup(0, answers[i]) + isExcludeWrongAnswer = XDataCenter.MoeWarManager.IsExcludeWrongAnswer(i) + btnRecord:SetDisable(isExcludeWrongAnswer, not isExcludeWrongAnswer) + btnRecord.gameObject:SetActiveEx(true) + if not self.TempExcludeAnima[questionId][i] and isExcludeWrongAnswer and self.PlayAnimation then + self.TempExcludeAnima[questionId][i] = true + end + else + self["BtnRecord" .. i].gameObject:SetActiveEx(false) + end + end + + local assistanceCount = XDataCenter.MoeWarManager.GetAssistanceCount() + local assistanceMaxCount = XMoeWarConfig.GetPreparationAssistanceSupportMaxCount() + self.BtnHelp:SetNameByGroup(1, assistanceCount .. "/" .. assistanceMaxCount) + self.BtnHelp:SetDisable(assistanceCount == 0) + + local recoveryTime = XDataCenter.MoeWarManager.GetAssistanceRecoveryTime() + if recoveryTime > 0 then + self:RefreshRecoveryTime(recoveryTime) + self:StartTimer(recoveryTime) + else + self:StopTimer() + self.TextTime.text = "" + end +end + +function XUiMoeWarRecruitMsgPanel:RefreshRecoveryTime(recoveryTime) + local nowServerTime = XTime.GetServerNowTimestamp() + local lastTime = recoveryTime - nowServerTime + if lastTime <= 0 then + self.TextTime.text = "" + self:StopTimer() + self:RefreshHuifuPanel(true) + return + end + + local timeStr = XUiHelper.GetTime(lastTime, XUiHelper.TimeFormatType.DEFAULT) + self.TextTime.text = CSXTextManagerGetText("MoeWarAssistanceRecoveryTime", timeStr) +end + +function XUiMoeWarRecruitMsgPanel:StartTimer(recoveryTime) + self:StopTimer() + local recoveryTime = recoveryTime + self.Timer = XScheduleManager.ScheduleForever(function() + self:RefreshRecoveryTime(recoveryTime) + end, XScheduleManager.SECOND) +end + +function XUiMoeWarRecruitMsgPanel:StopTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end + +function XUiMoeWarRecruitMsgPanel:OnBtnHelpClick() + XDataCenter.MoeWarManager.RequestMoeWarPreparationAssistance(self.HelperId, function() + self:RefreshHuifuPanel(true) + end) +end + +function XUiMoeWarRecruitMsgPanel:OnBtnClickRequestHelperAnswer(answerIndex) + self:OnBtnHuifuClick() + local refreshCb = function() + if self.RefreshContactButtonCb then + self.RefreshContactButtonCb() + end + end + + local receiveChatHandlerCb = function(chatData) + self:ReceiveChatHandler(chatData) + end + + XDataCenter.MoeWarManager.RequestMoeWarPreparationHelperAnswer(self.HelperId, answerIndex, refreshCb, receiveChatHandlerCb) +end + +function XUiMoeWarRecruitMsgPanel:CheckBtnHuifuIsClick() + if not IsNumberValid(self.HelperId) then + self.PanelTip.gameObject:SetActiveEx(false) + self.BtnHuifu:SetName(CSXTextManagerGetText("MoeWarRecruitSelectReply")) + self:SetBtnHuifuDisable(true) + return + end + + local status = XDataCenter.MoeWarManager.GetRecruitHelperStatus(self.HelperId) + --招募失败,设置按钮为继续联络 + if status == XMoeWarConfig.PreparationHelperStatus.CommunicationEnd then + self.BtnHuifu:SetName(CSXTextManagerGetText("MoeWarRecruitContinueContact")) + self.BtnHuifu.CallBack = function() self:OnBtnHuifuClickContinueContact() end + self:SetBtnHuifuDisable(false) + return + end + + --招募成功,设置按钮为关闭 + if status == XMoeWarConfig.PreparationHelperStatus.RecruitFinish then + self.BtnHuifu:SetName(CSXTextManagerGetText("Close")) + self.BtnHuifu.CallBack = function() self:OnBtnHuifuClickClose() end + self:SetBtnHuifuDisable(false) + return + end + + if status ~= XMoeWarConfig.PreparationHelperStatus.Communicating then + self.PanelTip.gameObject:SetActiveEx(false) + self:SetBtnHuifuDisable(true) + else + self:SetBtnHuifuDisable(false) + end +end + +function XUiMoeWarRecruitMsgPanel:SetBtnHuifuDisable(isDisable) + self.BtnHuifu:SetDisable(isDisable, not isDisable) +end + +function XUiMoeWarRecruitMsgPanel:NotifyRefreshHuifuPanel() + local activeSelf = self.PanelTip.gameObject.activeSelf + if activeSelf then + self:RefreshHuifuPanel(true) + end +end + +return XUiMoeWarRecruitMsgPanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMoeWar/Recruit/XUiPanelLineItem.lua b/Resources/Scripts/XUi/XUiMoeWar/Recruit/XUiPanelLineItem.lua new file mode 100644 index 00000000..6c92d9b4 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMoeWar/Recruit/XUiPanelLineItem.lua @@ -0,0 +1,12 @@ +local XUiPanelLineItem = XClass(nil, "XUiPanelLineItem") + +function XUiPanelLineItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiPanelLineItem:Refresh() +end + +return XUiPanelLineItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMoeWar/Recruit/XUiPanelMsgItem.lua b/Resources/Scripts/XUi/XUiMoeWar/Recruit/XUiPanelMsgItem.lua new file mode 100644 index 00000000..65571f03 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMoeWar/Recruit/XUiPanelMsgItem.lua @@ -0,0 +1,86 @@ +local MoeWarRecruitAnimaContentShowTime = CS.XGame.ClientConfig:GetInt("MoeWarRecruitAnimaContentShowTime") +local UObjIsNil = XTool.UObjIsNil +local IsNumberValid = XTool.IsNumberValid + +local XUiPanelMsgItem = XClass(nil, "XUiPanelMsgItem") + +function XUiPanelMsgItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiPanelMsgItem:Refresh(data, helperId) + local questionId = data.QuestionId + local desc = data.Desc + local recruitMsgType = data.RecruitMsgType + local IsPlayMsgAnima = data.IsPlayMsgAnima + local IsOverPlayMsgAnima = data.IsOverPlayMsgAnima + + self:StopTimer() + + if self.TxtWord then + self.TxtWord.text = desc + end + + local name + if recruitMsgType == XMoeWarConfig.RecruitMsgType.OtherMsg then + local questionType = XMoeWarConfig.GetPreparationQuestionType(questionId) + local questionIsRight = XDataCenter.MoeWarManager.GetRecruitQuestionIsRight(helperId, questionId) + local answerId = XDataCenter.MoeWarManager.GetRecruitAnswerId(helperId, questionId) + local headIcon = XMoeWarConfig.GetPreparationQuestionHelperIcon(questionId) + local headRawImage = XUiHelper.TryGetComponent(self.Head.transform, "StandIcon", "RawImage") + + --回答错误或招募失败,播放完动画才显示内容 + local isCheckAnima = false + if not IsOverPlayMsgAnima and IsPlayMsgAnima then + isCheckAnima = true + end + + headRawImage:SetRawImage(headIcon) + name = XMoeWarConfig.GetPreparationQuestionHelperName(questionId) + self:CheckSwitchAnimaContent(isCheckAnima) + else + name = XPlayer.Name + XUiPLayerHead.InitPortrait(XPlayer.CurrHeadPortraitId, XPlayer.CurrHeadFrameId, self.Head) + self:CheckSwitchAnimaContent(false) + end + if self.TxtName then + self.TxtName.text = name + end + + data.IsOverPlayMsgAnima = true +end + +function XUiPanelMsgItem:CheckSwitchAnimaContent(isCheck) + self:SwitchAnimaContentIsShow(isCheck) + if isCheck then + if self.PauseInsertDynamicTimer then + self.PauseInsertDynamicTimer() + end + self.Timer = XScheduleManager.ScheduleOnce(function() + self:SwitchAnimaContentIsShow(false) + if self.CancelPauseInsertDynamicTimer then + self.CancelPauseInsertDynamicTimer(true) + end + end, MoeWarRecruitAnimaContentShowTime) + end +end + +function XUiPanelMsgItem:SwitchAnimaContentIsShow(isShow) + if not UObjIsNil(self.AnimaContent) then + self.AnimaContent.gameObject:SetActiveEx(isShow) + end + if not UObjIsNil(self.Content) then + self.Content.alpha = isShow and 0 or 1 + end +end + +function XUiPanelMsgItem:StopTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end + +return XUiPanelMsgItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMoeWar/SceneAnimation/UiMoeWarAnimationTips.lua b/Resources/Scripts/XUi/XUiMoeWar/SceneAnimation/UiMoeWarAnimationTips.lua new file mode 100644 index 00000000..b033969e --- /dev/null +++ b/Resources/Scripts/XUi/XUiMoeWar/SceneAnimation/UiMoeWarAnimationTips.lua @@ -0,0 +1,7 @@ +local XUiMoeWarAnimationTips = XLuaUiManager.Register(XLuaUi, "UiMoeWarAnimationTips") + +function XUiMoeWarAnimationTips:OnStart() + self:PlayAnimationWithMask("AnimStart",function () + self:Close() + end) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMoeWar/SceneAnimation/XMoeWarAnimationRole.lua b/Resources/Scripts/XUi/XUiMoeWar/SceneAnimation/XMoeWarAnimationRole.lua new file mode 100644 index 00000000..46d7015c --- /dev/null +++ b/Resources/Scripts/XUi/XUiMoeWar/SceneAnimation/XMoeWarAnimationRole.lua @@ -0,0 +1,262 @@ +local XMoeWarAnimationRole = XClass(nil, "XMoeWarAnimationRole") + +local Vector3 = CS.UnityEngine.Vector3 +local VForward = Vector3.forward + +local PLAY_END_ANIM_DISTANCE = CS.XGame.ClientConfig:GetFloat("MoeWarSceneAnimationPlayEndAnimDistance")--当镜头跟随者到达此位置后播放结束镜头动画和慢镜头动作 +local PLAY_GOAL_ANIM_DISTANCE = CS.XGame.ClientConfig:GetFloat("MoeWarSceneAnimationGoalDistance")--当镜头跟随者到达此位置后播放冲线特效 +local PLAY_RESTORE_ANIM_DISTANCE = CS.XGame.ClientConfig:GetFloat("MoeWarSceneAnimationRestoreDistance")--当镜头跟随者到达此位置后恢复慢镜头动作 +local SLOW_DOWN_PERCENT = 0.01 * CS.XGame.ClientConfig:GetInt("MoeWarSceneAnimationSlowdownPercent")--慢动作速度百分比 +local END_ANIM_TOTAL_TIME = CS.XGame.ClientConfig:GetInt("MoeWarSceneAnimationTotalTime")--整个终场动画持续时间/s + +local SynPlaySlowDownAnim = nil--同步播放慢动作 +local SynPlayRestoreAnim = nil--同步恢复原始速度 + +function XMoeWarAnimationRole:Ctor(index, groupId, parent, uiName, scene, switchCameraCb, endAnimCb, goalAnimCb) + self.Index = index--赛道Index + self.GroupId = groupId--动画组Id + self.ModelParent = parent--角色模型父节点 + self.UiName = uiName + self.Scene = scene + self.SwitchCameraCb = switchCameraCb--切换相机回调 + self.EndAnimCb = endAnimCb--终场场景动画回调 + self.GoalAnimCb = goalAnimCb--冲线场景动画回调 + + self:Init() +end + +function XMoeWarAnimationRole:Dispose() + self:DestroyTimer() + + for _, effectRoot in pairs(self.SceneEffectRoots) do + effectRoot.gameObject:SetActiveEx(false) + end + self.SceneEffectRoots = {} +end + +function XMoeWarAnimationRole:Init() + self.AnimationIds = XMoeWarConfig.GetAnimationIds(self.GroupId)--动画节点组 + self.CurrentAnimationIndex = 0--当前播放动画Index + self.CurrentModelName = nil--当前加载角色模型名称 + self.Model = nil--当前加载角色模型 + self.Animator = nil--动画控制器 + self.FollowCameras = {}--跟随相机 + self.SceneEffectRoots = {}--已加载场景特效根节点 + self._IsEnd = nil--全部动画节点是否播放完毕 + self._IsFocus = nil--是否是相机跟随者 + self.PlaySlowDownAnim = nil--播放慢动作 + self.PlayRestoreAnim = nil--恢复原始速度 + + SynPlaySlowDownAnim = nil + SynPlayRestoreAnim = nil + + local modelName = XMoeWarConfig.GetAnimationGroupInitModelName(self.GroupId) + self:ChangeModel(modelName) +end + +--替换模型 +function XMoeWarAnimationRole:ChangeModel(modelName) + if not modelName or modelName == self.CurrentModelName then return end + + --记录旧模型位置 + local oldPos = self.Model and self.Model.transform.localPosition + + --加载新模型 + local prefabPath = XModelManager.GetModelPath(modelName) + local model = self.ModelParent:LoadPrefab(prefabPath, false) + self.Model = model + + if oldPos then + self.Model.transform.localPosition = oldPos + end + + --加载controller + local controllerPath = XModelManager.GetUiControllerPath(modelName) + local runtimeController = CS.LoadHelper.LoadUiController(controllerPath, self.UiName) + self.Animator = model.transform:GetComponent("Animator") + self.Animator.runtimeAnimatorController = runtimeController + + --播放初始动画 + local initAnim = XMoeWarConfig.GetAnimationGroupInitAnim(self.GroupId) + if not string.IsNilOrEmpty(initAnim) then + self.Animator:Play(initAnim) + end + + --切换模型时换一个相机跟随保证平滑,否则会延迟回拉 + if self.CurrentModelName and modelName ~= self.CurrentModelName then + self.SwitchCameraCb(self.Index) + end + + self.CurrentModelName = modelName +end + +--设置跟随虚拟相机 +function XMoeWarAnimationRole:SetFollowCamera(virtualCamera) + if self.FollowCameras[virtualCamera] then return end + self._IsFocus = true + self.FollowCameras = {} + self.FollowCameras[virtualCamera] = virtualCamera + self:UpdateFollowCameras() +end + +function XMoeWarAnimationRole:UpdateFollowCameras() + for virtualCamera in pairs(self.FollowCameras) do + virtualCamera.Follow = self.Model.transform + end +end + +--执行动画节点 +function XMoeWarAnimationRole:Run() + local animationIndex = self.CurrentAnimationIndex + 1 + local animationId = self.AnimationIds[animationIndex] + + if not XTool.IsNumberValid(animationId) then + self:OnExit() + return + end + + self.CurrentAnimationIndex = animationIndex + self._IsEnd = false + + --替换动画模型 + local modelName = XMoeWarConfig.GetAnimationModelName(animationId) + self:ChangeModel(modelName) + + --角色动作 + local animName = XMoeWarConfig.GetAnimationAnimName(animationId) + self.Animator:Play(animName) + + --角色特效 + local roleEffect, roleEffectRoot = XMoeWarConfig.GetAnimationRoleEffect(animationId) + if not string.IsNilOrEmpty(roleEffect) + and not string.IsNilOrEmpty(roleEffectRoot) + then + local effectRoot = self.Model.transform:FindTransform(roleEffectRoot) + if XTool.UObjIsNil(effectRoot) then + XLog.Error("XMoeWarAnimationRole:Run error: 角色特效父节点找不到, roleEffectRoot: " .. roleEffectRoot) + else + effectRoot:LoadPrefab(roleEffect, false) + effectRoot.gameObject:SetActiveEx(false) + effectRoot.gameObject:SetActiveEx(true) + end + end + + --场景特效 + local sceneEffect, sceneEffectRoot = XMoeWarConfig.GetAnimationSceneEffect(animationId) + if not string.IsNilOrEmpty(sceneEffect) + and not string.IsNilOrEmpty(sceneEffectRoot) + then + local effectRoot = self.SceneEffectRoots[sceneEffectRoot] + if not effectRoot then + effectRoot = self.Scene:FindTransform(sceneEffectRoot) + self.SceneEffectRoots[sceneEffectRoot] = effectRoot + end + + if XTool.UObjIsNil(effectRoot) then + XLog.Error("XMoeWarAnimationRole:Run error: 场景特效父节点找不到, sceneEffectRoot: " .. sceneEffectRoot) + else + effectRoot.gameObject:SetLayerRecursively(CS.UnityEngine.LayerMask.NameToLayer("UiNear")) + effectRoot:LoadPrefab(sceneEffect, false) + effectRoot.gameObject:SetActiveEx(false) + effectRoot.gameObject:SetActiveEx(true) + end + end + + --速度 + local speed = XMoeWarConfig.GetAnimationSpeed(animationId) + + --目标点 + local distance = XMoeWarConfig.GetAnimationDistance(animationId) + local transform = self.Model.transform + local start = transform.localPosition.z + local target = start + distance + + --触发动画 + local playEndAnim = nil + local playGoalAnim = nil + + --角色移动 + local position = nil + self:DestroyTimer() + self.Timer = XScheduleManager.ScheduleForever(function() + if XTool.UObjIsNil(transform) then + self:DestroyTimer() + return + end + + position = transform.localPosition.z + + --到达目标位置后执行下一动画节点 + if position >= target then + self:DestroyTimer() + self:Run() + return + end + + --终场镜头动画 + if self._IsFocus and position >= PLAY_END_ANIM_DISTANCE then + if not playEndAnim then + playEndAnim = true + + --播放场景动画 + self.EndAnimCb(END_ANIM_TOTAL_TIME) + end + + if not SynPlaySlowDownAnim then + SynPlaySlowDownAnim = true + end + end + + --慢动作 + if SynPlaySlowDownAnim and not self.PlaySlowDownAnim then + self.PlaySlowDownAnim = true + + speed = speed * SLOW_DOWN_PERCENT + self.Animator.speed = self.Animator.speed * SLOW_DOWN_PERCENT + end + + --冲线动画 + if not playGoalAnim and self._IsFocus and position >= PLAY_GOAL_ANIM_DISTANCE then + playGoalAnim = true + + --播放冲线特效 + self.GoalAnimCb() + end + + --恢复原始速度 + if self._IsFocus and not SynPlayRestoreAnim and position >= PLAY_RESTORE_ANIM_DISTANCE then + SynPlayRestoreAnim = true + end + + if SynPlayRestoreAnim and not self.PlayRestoreAnim then + self.PlayRestoreAnim = true + + speed = speed / SLOW_DOWN_PERCENT + self.Animator.speed = self.Animator.speed / SLOW_DOWN_PERCENT + end + + --角色移动 + transform:Translate(speed * VForward * CS.UnityEngine.Time.deltaTime) + end, 0, 0) + +end + +--动画全部执行完毕 +function XMoeWarAnimationRole:OnExit() + self._IsEnd = true + + self:DestroyTimer() +end + +function XMoeWarAnimationRole:DestroyTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end + +function XMoeWarAnimationRole:IsEnd() + return self._IsEnd or false +end + +return XMoeWarAnimationRole \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMoeWar/SceneAnimation/XUiMoeWarAnimation.lua b/Resources/Scripts/XUi/XUiMoeWar/SceneAnimation/XUiMoeWarAnimation.lua new file mode 100644 index 00000000..b7bdb7cb --- /dev/null +++ b/Resources/Scripts/XUi/XUiMoeWar/SceneAnimation/XUiMoeWarAnimation.lua @@ -0,0 +1,294 @@ +local XMoeWarAnimationRole = require("XUi/XUiMoeWar/SceneAnimation/XMoeWarAnimationRole") + +local Lerp = CS.UnityEngine.Mathf.Lerp +local mathFloor = math.floor + +local END_CAMERA_INDEX = 3--终场相机Index +local FOLLOW_ROLE_CAMERA_INDEXS = { 2, 4 }--跟随胜利角色的相机Index +local MowWarSceneAnimationFxGoalEffectPath = CS.XGame.ClientConfig:GetString("MowWarSceneAnimationFxGoalEffectPath")--终点特效路径 +local MowWarSceneAnimationFxVictoryEffectPath = CS.XGame.ClientConfig:GetString("MowWarSceneAnimationFxVictoryEffectPath")--终点特效路径(胜利) + +local XUiMoeWarAnimation = XLuaUiManager.Register(XLuaUi, "UiMoeWarAnimation") + +function XUiMoeWarAnimation:OnAwake() + self:RegisterButtonEvent() + self.PanelStart.gameObject:SetActiveEx(false) +end + +---@param closeCallback function 设置关闭回调时接管原有的关闭逻辑 +function XUiMoeWarAnimation:OnStart(animGroupIds, winnerIndex ,closeCallback) + self.GroupIds = animGroupIds + self.WinnerIndex = winnerIndex + self.CloseCallback = closeCallback + self:InitScene() + self:InitRoles() + self:PlayStartAnimation() +end + +function XUiMoeWarAnimation:OnDisable() + self:DestroyTimer() +end + +function XUiMoeWarAnimation:OnDestroy() + for _, role in pairs(self.Roles) do + role:Dispose() + end +end + +function XUiMoeWarAnimation:OnGetEvents() + return { + XEventId.EVENT_MOE_WAR_ACTIVITY_END, + XEventId.EVENT_MOE_WAR_UPDATE, + } +end + +function XUiMoeWarAnimation:OnNotify(event, ...) + local args = { ... } + if event == XEventId.EVENT_MOE_WAR_ACTIVITY_END then + self.CloseCallback = function() + XUiManager.TipText("MoeWarActivityOver") + XLuaUiManager.RunMain() + end + elseif event == XEventId.EVENT_MOE_WAR_UPDATE then + self.CloseCallback = function() + XLuaUiManager.RunMain() + XLuaUiManager.Open("UiMoeWarMain") + XUiManager.TipText("MoeWarMatchEnd") + end + end +end + +function XUiMoeWarAnimation:OnClose() + if self.CloseCallback then + self.CloseCallback() + return + end + self:Close() +end + +function XUiMoeWarAnimation:InitScene() + local scene = self.UiSceneInfo.Transform + local root = self.UiModelGo.transform + local roleNum = #self.GroupIds + + --选手模型父节点 + local roleRoot + local roleRoot2 = root:FindTransformWithSplit("Panel01")--两人 + local roleRoot3 = root:FindTransformWithSplit("Panel02")--三人 + if roleNum == 3 then + roleRoot = roleRoot3 + roleRoot2.gameObject:SetActiveEx(false) + roleRoot3.gameObject:SetActiveEx(true) + else + roleRoot = roleRoot2 + roleRoot2.gameObject:SetActiveEx(true) + roleRoot3.gameObject:SetActiveEx(false) + end + self.RoleParents = { + roleRoot:FindTransform("PanelModelCase1"), + roleRoot:FindTransform("PanelModelCase2"), + roleRoot:FindTransform("PanelModelCase3"), + } + + --跑道 + local paodao2 = scene:FindTransformWithSplit("SceneRunway_01")--两人 + local paodao3 = scene:FindTransformWithSplit("SceneRunway_01b")--三人 + paodao2.gameObject:SetActiveEx(roleNum == 2) + paodao3.gameObject:SetActiveEx(roleNum == 3) + + --终点线特效 + self.GoalEffectRoot = scene:FindTransform("PanelEffectGoal") + self.GoalEffectRoot.gameObject:SetLayerRecursively(CS.UnityEngine.LayerMask.NameToLayer("UiNear")) + self.GoalEffectRoot:LoadPrefab(MowWarSceneAnimationFxGoalEffectPath, false) + + --角色相机 + self.CurRoleCamera = nil + self.CameraRoles = { + root:FindTransform("CameraRole1"):GetComponent("CinemachineVirtualCamera"), + root:FindTransform("CameraRole2"):GetComponent("CinemachineVirtualCamera"), + root:FindTransform("CameraRole3"):GetComponent("CinemachineVirtualCamera"), + root:FindTransform("CameraRole4"):GetComponent("CinemachineVirtualCamera"), + } + + --远景相机 + self.CurFarCamera = nil + self.FarCameras = { + root:FindTransform("CameraFar1"):GetComponent("CinemachineVirtualCamera"), + root:FindTransform("CameraFar2"):GetComponent("CinemachineVirtualCamera"), + root:FindTransform("CameraFar3"):GetComponent("CinemachineVirtualCamera"), + root:FindTransform("CameraFar4"):GetComponent("CinemachineVirtualCamera"), + } + + --当前跟随角色的虚拟相机Index + self.FollowRoleCameraIndex = FOLLOW_ROLE_CAMERA_INDEXS[1] +end + +function XUiMoeWarAnimation:InitRoles() + self.Roles = {} + + for index, groupId in pairs(self.GroupIds) do + local parent = self.RoleParents[index] + if not parent then + XLog.Error("XUiMoeWarAnimation:InitRoles error: 找不到角色对应赛道, index: " .. index) + break + end + + local switchCameraCb = function(index) + if index ~= self.WinnerIndex then return end + self:SwitchFollowRoleCamera() + end + + local endAnimCb = handler(self, self.PlayEndAnimation) + local goalAnimCb = handler(self, self.PlayGoalAnimation) + local role = XMoeWarAnimationRole.New(index, groupId, parent, self.Name, self.UiSceneInfo.Transform, switchCameraCb, endAnimCb, goalAnimCb) + self.Roles[index] = role + end +end + +function XUiMoeWarAnimation:SwitchFollowRoleCamera() + local cameraIndex + + for _, index in pairs(FOLLOW_ROLE_CAMERA_INDEXS) do + if index ~= self.FollowRoleCameraIndex then + cameraIndex = index + break + end + end + + local role = self.Roles[self.WinnerIndex] + role:SetFollowCamera(self.CameraRoles[cameraIndex]) + role:SetFollowCamera(self.FarCameras[cameraIndex]) + + for index, camera in pairs(self.CameraRoles) do + camera.gameObject:SetActiveEx(index == cameraIndex) + end + for index, camera in pairs(self.FarCameras) do + camera.gameObject:SetActiveEx(index == cameraIndex) + end + + self.FollowRoleCameraIndex = index +end + +function XUiMoeWarAnimation:PlayCameraAnimationStart() + if XTool.UObjIsNil(self.GameObject) then return end + + local cameraIndex = self.FollowRoleCameraIndex + + for index, camera in pairs(self.CameraRoles) do + if index == cameraIndex then + self.CurRoleCamera = camera + camera.gameObject:SetActiveEx(true) + else + camera.gameObject:SetActiveEx(false) + end + end + + for index, camera in pairs(self.FarCameras) do + if index == cameraIndex then + self.CurFarCamera = camera + camera.gameObject:SetActiveEx(true) + else + camera.gameObject:SetActiveEx(false) + end + end +end + +function XUiMoeWarAnimation:PlayCameraAnimationEnd() + local cameraIndex = END_CAMERA_INDEX + + for index, camera in pairs(self.CameraRoles) do + camera.gameObject:SetActiveEx(index == cameraIndex) + end + + for index, camera in pairs(self.FarCameras) do + camera.gameObject:SetActiveEx(index == cameraIndex) + end +end + +function XUiMoeWarAnimation:RegisterButtonEvent() + self.BtnMainUi.CallBack = function() XLuaUiManager.RunMain() end + self.BtnBack.CallBack = handler(self, self.OnClickBtnClose) + self.BtnSkip.CallBack = handler(self, self.OnClickBtnClose) +end + +function XUiMoeWarAnimation:OnClickBtnClose() + self:OnClose() +end + +function XUiMoeWarAnimation:DestroyTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end + +--播放开场动画 +function XUiMoeWarAnimation:PlayStartAnimation() + local asynPlayAnim = asynTask(self.PlayAnimationWithMask, self) + + RunAsyn(function() + --等待角色准备动作播放完毕 + asynWaitSecond(2) + + --播放镜头动画 + self:PlayCameraAnimationStart() + + --等待镜头动画播放完毕 + asynWaitSecond(1) + + --播放UI动画 + if XTool.UObjIsNil(self.PanelStart) then return end + self.PanelStart.gameObject:SetActiveEx(true) + asynPlayAnim("PanelStartEnable") + if XTool.UObjIsNil(self.PanelStart) then return end + self.PanelStart.gameObject:SetActiveEx(false) + + --UI动画播放完毕之后播放赛跑动画 + self:PlayRaceAnimation() + end) +end + +--播放所有赛道动画 +function XUiMoeWarAnimation:PlayRaceAnimation() + for index, role in pairs(self.Roles) do + --相机跟随胜利者 + if index == self.WinnerIndex then + role:SetFollowCamera(self.CurRoleCamera) + role:SetFollowCamera(self.CurFarCamera) + end + + role:Run() + end +end + +--播放终场动画 +function XUiMoeWarAnimation:PlayEndAnimation(totalTime) + + RunAsyn(function() + --播放相机转场动画 + self:PlayCameraAnimationEnd() + + --等待相机转场动画播放完毕 + asynWaitSecond(totalTime) + + --打开结束动画UI + if XTool.UObjIsNil(self.GameObject) then return end + XLuaUiManager.Open("UiMoeWarAnimationTips") + + --等待ui结束动画播到一半刚好遮挡住全屏时 + asynWaitSecond(0.6) + + --关闭本UI + if XTool.UObjIsNil(self.GameObject) then return end + self:OnClose() + end) + +end + +--播放冲线特效 +function XUiMoeWarAnimation:PlayGoalAnimation() + if XTool.UObjIsNil(self.GoalEffectRoot) then return end + self.GoalEffectRoot:LoadPrefab(MowWarSceneAnimationFxVictoryEffectPath, false) + self.GoalEffectRoot.gameObject:SetActiveEx(false) + self.GoalEffectRoot.gameObject:SetActiveEx(true) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMoeWar/SubPage/XUiPanelMatchFinal.lua b/Resources/Scripts/XUi/XUiMoeWar/SubPage/XUiPanelMatchFinal.lua new file mode 100644 index 00000000..3fc88b67 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMoeWar/SubPage/XUiPanelMatchFinal.lua @@ -0,0 +1,136 @@ +local XUiPanelMatchFinal = XClass(nil, "XUiPanelMatchFinal") + +local XUiScheduleGridPlayer = require("XUi/XUiMoeWar/ChildItem/XUiScheduleGridPlayer") +local ipairs = ipairs + +local MAX_PLAYER_COUNT = 3 + +function XUiPanelMatchFinal:Ctor(uiRoot, ui, sessionId, modelUpdater) + self.UiRoot = uiRoot + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.ModelUpdater = modelUpdater + + self.ObjGroup = {} + self.PairList = {} + self.Rank = {} + self.SessionId = sessionId + XTool.InitUiObject(self) + self:AutoRegister() + self:InitGroup() + + --XTool.InitUiObject(self) + self.BtnPlayBack.CallBack = function() self:OnBtnPlayBack() end + + self.Player1 = XUiScheduleGridPlayer.New(self.Player1Go) + self.Player2 = XUiScheduleGridPlayer.New(self.Player2Go) + self.Player3 = XUiScheduleGridPlayer.New(self.Player3Go) + self.PlayerWin = XUiScheduleGridPlayer.New(self.PlayerWinGo) +end + +function XUiPanelMatchFinal:AutoRegister() + self.Player1Normal = self.Transform:Find("PanelTeam1/Line1/PanelNone") + self.Player1Win = self.Transform:Find("PanelTeam1/Line1/PanelWin") + self.Player2Normal = self.Transform:Find("PanelTeam1/Line2/PanelNone") + self.Player2Win = self.Transform:Find("PanelTeam1/Line2/PanelWin") + self.Player3Normal = self.Transform:Find("PanelTeam1/Line3/PanelNone") + self.Player3Win = self.Transform:Find("PanelTeam1/Line3/PanelWin") + self.PlayerWinNormal = self.Transform:Find("PanelTeam1/LineWin/PanelNone") + self.PlayerWinWin = self.Transform:Find("PanelTeam1/LineWin/PanelWin") + self.BtnPlayBack = self.Transform:Find("PanelTeam1/BtnPlayBack"):GetComponent("XUiButton") + self.Player1Go = self.Transform:Find("PanelTeam1/PanelRole1") + self.Player2Go = self.Transform:Find("PanelTeam1/PanelRole2") + self.Player3Go = self.Transform:Find("PanelTeam1/PanelRole3") + self.PlayerWinGo = self.Transform:Find("PanelTeam1/PanelRole4") + self.PanelNone = self.Transform:Find("PanelTeam1/PanelWenhao") + self.PanelWin = self.Transform:Find("PanelTeam1/PanelWin") +end + +function XUiPanelMatchFinal:InitGroup() + for i in ipairs(XMoeWarConfig.GetGroups()) do + local grpName = XDataCenter.MoeWarManager.GetActivityInfo().GroupName[i] + local txtName = self["Player"..i.."Go"]:Find("TextTeam"):GetComponent("Text") + txtName.text = grpName + end +end + +function XUiPanelMatchFinal:InitPairGroup() + -- 整理数据 分组 + self.PairGroup = {} + local match = XDataCenter.MoeWarManager.GetMatch(self.SessionId) + self.PairInfo = match.PairList[1] + for i, playerId in ipairs(self.PairInfo.Players) do + self.PairGroup[i] = XDataCenter.MoeWarManager.GetPlayer(playerId) + end + + table.sort(self.PairGroup, function(playerA, playerB) + return playerA.Id < playerB.Id + end) +end + +function XUiPanelMatchFinal:Refresh(isForce) + if isForce or not self.PairGroup then + self:InitPairGroup() + end + local pair = self.PairGroup + local match = XDataCenter.MoeWarManager.GetMatch(self.SessionId) + local winner = 0 + self.Player1Entity = pair[1] + self.Player2Entity = pair[2] + self.Player3Entity = pair[3] + self.Player1:Refresh(pair[1], match) + self.Player2:Refresh(pair[2], match) + self.Player3:Refresh(pair[3], match) + if match:GetResultOut() then + for i = 1, MAX_PLAYER_COUNT do + local matchInfo = self["Player"..i.."Entity"].MatchInfoDic[match.Id] + if matchInfo.IsWin then + self.Rank[i] = 1 + winner = i + elseif matchInfo.IsSecond then + self.Rank[i] = 2 + else + self.Rank[i] = 3 + end + self["Player"..i.."Win"].gameObject:SetActiveEx(matchInfo.IsWin) + self["Player"..i.."Normal"].gameObject:SetActiveEx(not matchInfo.IsWin) + end + + self.PlayerWinNormal.gameObject:SetActiveEx(false) + self.PlayerWinWin.gameObject:SetActiveEx(true) + self.PlayerWin:Refresh(pair[winner], match) + self.BtnPlayBack.gameObject:SetActiveEx(true) + + self.ModelUpdater(self.TeamNo, pair[winner]) + self.PanelNone.gameObject:SetActiveEx(false) + self.PanelWin.gameObject:SetActiveEx(true) + else + for i in pairs(self.PairGroup) do + self["Player"..i.."Win"].gameObject:SetActiveEx(false) + self["Player"..i.."Normal"].gameObject:SetActiveEx(true) + end + self.PlayerWinNormal.gameObject:SetActiveEx(true) + self.PlayerWinWin.gameObject:SetActiveEx(false) + self.BtnPlayBack.gameObject:SetActiveEx(false) + self.PlayerWin:Refresh() + + self.ModelUpdater(nil, nil) + self.PanelNone.gameObject:SetActiveEx(true) + self.PanelWin.gameObject:SetActiveEx(false) + end + + self.TxtRefreshTip.text = match:GetRefreshVoteText() + self:SetRankIcon() +end + +function XUiPanelMatchFinal:SetRankIcon() + for index in pairs(self.PairGroup) do + self["Player"..index]:SetFinalRank(self.Rank[index] or 0) + end +end + +function XUiPanelMatchFinal:OnBtnPlayBack() + XDataCenter.MoeWarManager.EnterAnimation(self.PairInfo, self.Match) +end + +return XUiPanelMatchFinal \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMoeWar/SubPage/XUiPanelMatchLarge.lua b/Resources/Scripts/XUi/XUiMoeWar/SubPage/XUiPanelMatchLarge.lua new file mode 100644 index 00000000..4cb7eaab --- /dev/null +++ b/Resources/Scripts/XUi/XUiMoeWar/SubPage/XUiPanelMatchLarge.lua @@ -0,0 +1,115 @@ +local XUiPanelMatchLarge = XClass(nil, "XUiPanelMatchLarge") + +local XUiScheduleGridPair = require("XUi/XUiMoeWar/ChildItem/XUiScheduleGridPair") +local tableInsert = table.insert +local ipairs = ipairs + +local MAX_TAB_INDEX = 3 +local MAX_PAIRS_IN_ONE_TAB = 4 + +function XUiPanelMatchLarge:Ctor(uiRoot, ui, sessionId) + self.UiRoot = uiRoot + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.TabList = {} + self.PairList = {} + self.SessionId = sessionId + XTool.InitUiObject(self) + --self.GridMonster.gameObject:SetActiveEx(false) + self:InitTabList() + self:InitDefaultGroupIndex() +end + +function XUiPanelMatchLarge:InitTabList() + local actInfo = XDataCenter.MoeWarManager.GetActivityInfo() + if not actInfo then + XLog.Error("未获取到活动信息") + end + for i in ipairs(XMoeWarConfig.GetGroups()) do + local grpName = actInfo.GroupName[i] + local btn = self["Btn"..i] + btn:SetNameByGroup(0, grpName) + tableInsert(self.TabList, btn) + end + + for i = #self.TabList + 1, MAX_TAB_INDEX do + self["Btn"..i].gameObject:SetActiveEx(false) + end + + self.BtnGrpGroup:Init(self.TabList ,function(index) self:SwitchTab(index) end) +end + +function XUiPanelMatchLarge:InitPairGroup() + -- 整理数据 分组 + self.PairGroup = {} + local match = XDataCenter.MoeWarManager.GetMatch(self.SessionId) + for _, v in ipairs(match.PairList) do + local group = XMoeWarConfig.GetPlayerGroup(v.Players[1]) + if not self.PairGroup[group] then + self.PairGroup[group] = {} + end + tableInsert(self.PairGroup[group], v) + end + + for _, pairList in ipairs(self.PairGroup) do + table.sort(pairList, function(pairA, pairB) + return pairA.Players[1] < pairB.Players[1] + end) + end +end + +function XUiPanelMatchLarge:InitDefaultGroupIndex() + local userSupportPlayer = XDataCenter.MoeWarManager.GetUserSupportPlayer(self.SessionId) + if userSupportPlayer ~= 0 then + self.CurrentGroup = XMoeWarConfig.GetPlayerGroup(userSupportPlayer) + else + -- 无投票的情况下 选择假匹配的组 或者 1、2、3顺序循环 + self.CurrentGroup = XDataCenter.MoeWarManager.GetDefaultSelectGroup() or XDataCenter.MoeWarManager.GetNextTabIndex(self.SessionId) + end +end + +-- 默认选中的页签序号 defaultGroup +function XUiPanelMatchLarge:Refresh(isForce, selectIndex) + if isForce or not self.PairGroup then + self:InitPairGroup() + end + if selectIndex then + self.CurrentGroup = selectIndex + end + self.BtnGrpGroup:SelectIndex(self.CurrentGroup, false) + local match = XDataCenter.MoeWarManager.GetMatch(self.SessionId) + if not self.PairGroup[self.CurrentGroup] then + XLog.Error("defaultGroup is invalid", self.CurrentGroup, self.SessionId, self.PairGroup) + return + end + for teamNo, pair in ipairs(self.PairGroup[self.CurrentGroup]) do + if teamNo > MAX_PAIRS_IN_ONE_TAB then break end + self["PanelTeam"..teamNo].gameObject:SetActiveEx(true) + if not self.PairList[teamNo] then + self.PairList[teamNo] = XUiScheduleGridPair.New(self["PanelTeam"..teamNo]) + end + self.PairList[teamNo]:Refresh(pair, match) + end + + for i = #self.PairList + 1, MAX_PAIRS_IN_ONE_TAB do + if self["PanelTeam"..i] then + self["PanelTeam"..i].gameObject:SetActiveEx(false) + end + end + + self.TxtRefreshTip.text = match:GetRefreshVoteText() +end + +function XUiPanelMatchLarge:SwitchTab(index, isFromOtherUi) + if self.CurrentGroup == index then + return + else + self.CurrentGroup = index + self:Refresh() + if not isFromOtherUi then + self.UiRoot:PlayAnimation("QieHuan2") + end + end +end + +return XUiPanelMatchLarge \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMoeWar/SubPage/XUiPanelMatchSmall.lua b/Resources/Scripts/XUi/XUiMoeWar/SubPage/XUiPanelMatchSmall.lua new file mode 100644 index 00000000..b08c7d42 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMoeWar/SubPage/XUiPanelMatchSmall.lua @@ -0,0 +1,59 @@ +local XUiPanelMatchSmall = XClass(nil, "XUiPanelMatchSmall") + +local XUiScheduleGridPair = require("XUi/XUiMoeWar/ChildItem/XUiScheduleGridPair") +local tableInsert = table.insert +local ipairs = ipairs + +local MAX_PAIRS = 3 + +function XUiPanelMatchSmall:Ctor(uiRoot, ui, sessionId, modelUpdater) + self.UiRoot = uiRoot + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.ModelUpdater = modelUpdater + + self.ObjGroup = {} + self.PairList = {} + self.SessionId = sessionId + XTool.InitUiObject(self) + self:InitGroup() +end + +function XUiPanelMatchSmall:InitGroup() + for i in ipairs(XMoeWarConfig.GetGroups()) do + local grpName = XDataCenter.MoeWarManager.GetActivityInfo().GroupName[i] + local txtName = self["PanelTeam"..i]:Find("TextTeam"):GetComponent("Text") + txtName.text = grpName + end +end + +function XUiPanelMatchSmall:InitPairGroup() + -- 整理数据 分组 + self.PairGroup = {} + local match = XDataCenter.MoeWarManager.GetMatch(self.SessionId) + for _, v in ipairs(match.PairList) do + tableInsert(self.PairGroup, v) + end + + table.sort(self.PairGroup, function(pairA, pairB) + return pairA.Players[1] < pairB.Players[1] + end) +end + +function XUiPanelMatchSmall:Refresh(isForce) + if isForce or not self.PairGroup then + self:InitPairGroup() + end + local match = XDataCenter.MoeWarManager.GetMatch(self.SessionId) + for teamNo, pair in ipairs(self.PairGroup) do + if teamNo > MAX_PAIRS then break end + if not self.PairList[teamNo] then + self.PairList[teamNo] = XUiScheduleGridPair.New(self["PanelTeam"..teamNo], teamNo, self.ModelUpdater) + end + self.PairList[teamNo]:Refresh(pair, match) + end + self.TxtRefreshTip.text = match:GetRefreshVoteText() +end + + +return XUiPanelMatchSmall \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMoeWar/SubPage/XUiPanelMyRank.lua b/Resources/Scripts/XUi/XUiMoeWar/SubPage/XUiPanelMyRank.lua new file mode 100644 index 00000000..3ac0855f --- /dev/null +++ b/Resources/Scripts/XUi/XUiMoeWar/SubPage/XUiPanelMyRank.lua @@ -0,0 +1,75 @@ +local XUiPanelMyRank = XClass(nil, "XUiPanelMyRank") + +local CSXTextManagerGetText = CS.XTextManager.GetText +local MAX_SPECIAL_NUM = 3 +local MAX_RANK_COUNT = 99 + +function XUiPanelMyRank:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) +end + +function XUiPanelMyRank:Refresh(rankMyData, rankType) + if rankMyData then + self.RankMyData = rankMyData + else + return + end + + if rankMyData.Rank <= MAX_RANK_COUNT and rankMyData.Rank > 0 then + self.TxtRankPercent.gameObject:SetActive(false) + self.TxtRankNormal.gameObject:SetActive(math.floor(rankMyData.Rank) > MAX_SPECIAL_NUM) + self.ImgRankSpecial.gameObject:SetActive(rankMyData.Rank <= MAX_SPECIAL_NUM) + + if rankMyData.Rank <= MAX_SPECIAL_NUM then + local icon = XMoeWarConfig.RankIcon[rankMyData.Rank] + self.RootUi:SetUiSprite(self.ImgRankSpecial, icon) + else + self.TxtRankNormal.text = math.floor(rankMyData.Rank) + end + else + self.TxtRankPercent.gameObject:SetActive(true) + self.TxtRankNormal.gameObject:SetActive(false) + self.ImgRankSpecial.gameObject:SetActive(false) + local text + if rankMyData.Rank > 0 then + if not rankMyData.MemberCount or rankMyData.MemberCount == 0 then + text = CS.XTextManager.GetText("None") + else + local num = math.floor(rankMyData.Rank / (rankMyData.MemberCount + 1) * 100) + if num < 1 then + num = 1 + end + + text = CS.XTextManager.GetText("BossSinglePrecentDesc", num) + end + else + text = CS.XTextManager.GetText("None") + end + self.TxtRankPercent.text = text + end + + local textPrefix = "" + if rankType == XMoeWarConfig.RankType.Player then + textPrefix = CSXTextManagerGetText("MoeWarRankPlayer") + elseif rankType == XMoeWarConfig.RankType.Daily then + textPrefix = CSXTextManagerGetText("MoeWarRankDaily") + end + self.TxtRankScore.text = CSXTextManagerGetText("MoeWarMyRankScore", textPrefix, rankMyData.Score) + local name = XPlayer.Name + self.TxtPlayerName.text = name + + XUiPLayerHead.InitPortrait(XPlayer.CurrHeadPortraitId, XPlayer.CurrHeadFrameId, self.Head) +end + +function XUiPanelMyRank:HidePanel() + self.GameObject:SetActive(false) +end + +function XUiPanelMyRank:ShowPanel() + self.GameObject:SetActive(true) +end + +return XUiPanelMyRank \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMoeWar/SubPage/XUiPanelPlayerVote.lua b/Resources/Scripts/XUi/XUiMoeWar/SubPage/XUiPanelPlayerVote.lua new file mode 100644 index 00000000..808796ca --- /dev/null +++ b/Resources/Scripts/XUi/XUiMoeWar/SubPage/XUiPanelPlayerVote.lua @@ -0,0 +1,148 @@ +local XUiPanelPlayerVote = XClass(nil, "XUiPanelPlayerVote") +local MAX_ANIMATION_NUMBER = 3 +local ANIMATION_DELAY = 500 +function XUiPanelPlayerVote:Ctor(ui) + ---@type UnityEngine.GameObject + self.GameObject = ui + ---@type UnityEngine.Transform + self.Transform = self.GameObject.transform + self:AutoInitUiObject() + self.BtnPoll.CallBack = function() + self:OnClickBtnPoll() + end + self.ColdDown = CS.XGame.ClientConfig:GetInt("MoeWarPlayerScreenRecordAnimationCD") + self.CurrCD = 0 + self.AnimationGridList = {} + self.AnimationIndex = 1 + self.Timer = CS.XScheduleManager.ScheduleForever(function() + self:PlayAnimation() + self.CurrCD = self.CurrCD - 1 + end,1000,0) + self.BtnPoll:SetName(CS.XTextManager.GetText("MoeWarVote")) + self.TxtMyTitle.text = CS.XTextManager.GetText("MoeWarMyVote") +end + +function XUiPanelPlayerVote:AutoInitUiObject() + self.TxtName = self.Transform:Find("TxtName"):GetComponent("Text") + self.TxtAllNumber = self.Transform:Find("PanelRolePoll/TxtNumber"):GetComponent("Text") + self.TxtDis = self.Transform:Find("PanelRolePoll/TxtDis"):GetComponent("Text") + self.TxtDis2 = self.Transform:Find("PanelRolePoll/TxtDis2"):GetComponent("Text") + self.TxtMyNumber = self.Transform:Find("PanelPoll/GridPollMy/TxtNumber"):GetComponent("Text") + self.TxtMyTitle = self.Transform:Find("PanelPoll/GridPollMy/TxtTitle"):GetComponent("Text") + self.MyPollPanel = self.Transform:Find("PanelPoll/GridPollMy") + self.PanelOther = self.Transform:Find("PanelPoll/PanelPollOther") + self.PlayableDirector = self.Transform:Find("PanelPoll/PanelPollOther/GridPollOther"):GetComponent("PlayableDirector") + self.TxtOtherName = self.Transform:Find("PanelPoll/PanelPollOther/GridPollOther/TxtName"):GetComponent("Text") + self.ImgOtherIcon = self.Transform:Find("PanelPoll/PanelPollOther/GridPollOther/TxtNumber/RImgIcon"):GetComponent("RawImage") + self.TxtOtherNumber = self.Transform:Find("PanelPoll/PanelPollOther/GridPollOther/TxtNumber"):GetComponent("Text") + self.BtnPoll = self.Transform:Find("BtnPoll"):GetComponent("XUiButton") + self.ImgAllIcon = self.Transform:Find("PanelRolePoll/RImgIcon"):GetComponent("RawImage") + self.ImgMyIcon = self.Transform:Find("PanelPoll/GridPollMy/RawImage"):GetComponent("RawImage") + self.GridPollOther = self.Transform:Find("PanelPoll/PanelPollOther/GridPollOther") + self.MyVoteChangeEffect = self.Transform:Find("PanelPoll/GridPollMy/TxtNumber/Effect") +end + +function XUiPanelPlayerVote:OnClickBtnPoll() + XLuaUiManager.Open("UiMoeWarPollTips",self.PlayerId) +end + +function XUiPanelPlayerVote:Refresh(playerId) + self.PlayerId = playerId + local playerEntity = XDataCenter.MoeWarManager.GetPlayer(self.PlayerId) + local match = XDataCenter.MoeWarManager.GetCurMatch() + local allCount = playerEntity:GetSupportCount(XDataCenter.MoeWarManager.GetCurMatchId()) + if XDataCenter.MoeWarManager.IsInStatistics() then + self.TxtDis.gameObject:SetActiveEx(false) + self.TxtDis2.gameObject:SetActiveEx(true) + self.TxtAllNumber.gameObject:SetActiveEx(false) + else + self.TxtDis2.gameObject:SetActiveEx(false) + if allCount == 0 and XDataCenter.MoeWarManager.GetCurMatch():GetType() == XMoeWarConfig.MatchType.Voting then + self.TxtAllNumber.text = CS.XTextManager.GetText("MoeWarMatchVoteNotRefresh") + if self.TxtDis then + self.TxtAllNumber.gameObject:SetActiveEx(false) + self.TxtDis.gameObject:SetActiveEx(true) + end + else + if self.TxtDis then + self.TxtAllNumber.gameObject:SetActiveEx(true) + self.TxtDis.gameObject:SetActiveEx(false) + end + self.TxtAllNumber.text = playerEntity:GetSupportCount(XDataCenter.MoeWarManager.GetCurMatchId()) + end + end + local myCount = playerEntity:GetMySupportCount(match:GetSessionId()) + self.TxtMyNumber.text = myCount + self.MyPollPanel.gameObject:SetActiveEx(myCount ~= 0) + self.TxtName.text = playerEntity:GetName() + self.ImgAllIcon:SetRawImage(CS.XGame.ClientConfig:GetString("MoeWarScheduleSupportIcon")) + self.ImgMyIcon:SetRawImage(CS.XGame.ClientConfig:GetString("MoeWarScheduleSupportIcon")) + self.ImgOtherIcon:SetRawImage(CS.XGame.ClientConfig:GetString("MoeWarScheduleSupportIcon")) + local matchType = match:GetType() + if XDataCenter.MoeWarManager.IsInStatistics() then + self.BtnPoll.gameObject:SetActiveEx(false) + else + self.BtnPoll.gameObject:SetActiveEx(matchType ~= XMoeWarConfig.MatchType.Publicity) + end +end + +function XUiPanelPlayerVote:SetVisible(isVisible) + self.GameObject:SetActiveEx(isVisible) +end + +function XUiPanelPlayerVote:SetBtnVoteVisible(isVisible) + self.BtnPoll.gameObject:SetActiveEx(isVisible) +end + +function XUiPanelPlayerVote:PlayAnimation() + local isSkip = XSaveTool.GetData(string.format("%s_%s",XMoeWarConfig.SKIP_KEY_PREFIX,XPlayer.Id)) or false + if isSkip then return end + if XTool.UObjIsNil(self.TxtAllNumber) then + if self.Timer then + CS.XScheduleManager.UnSchedule(self.Timer) + end + return + end + local data = XDataCenter.MoeWarManager.GetScreenRecordByPlayerId(self.PlayerId) + if not data then return end + local grid = self.AnimationGridList[self.AnimationIndex % MAX_ANIMATION_NUMBER] + if not grid then + local obj = CS.UnityEngine.GameObject.Instantiate(self.GridPollOther,self.PanelOther) + grid = {} + grid.Transform = obj + grid.GameObject = obj.gameObject + grid.TxtName = obj.transform:Find("TxtName"):GetComponent("Text") + grid.TxtNumber = obj.transform:Find("TxtNumber"):GetComponent("Text") + grid.PlayableDirector = obj:GetComponent("PlayableDirector") + self.AnimationGridList[self.AnimationIndex % MAX_ANIMATION_NUMBER] = grid + end + self.AnimationIndex = self.AnimationIndex % MAX_ANIMATION_NUMBER + grid.Transform:SetAsLastSibling() + grid.GameObject:SetActiveEx(false) + grid.GameObject:SetActiveEx(true) + grid.TxtName.text = data.PlayerName + grid.TxtNumber.text = data.Vote + grid.PlayableDirector:Play() + if self.CurrCD <= 0 then + self.CurrCD = self.ColdDown + XEventManager.DispatchEvent(XEventId.EVENT_MOE_WAR_PLAY_SCREEN_RECORD_ANIMATION,self.PlayerId) + end +end + +function XUiPanelPlayerVote:PlayVoteChangeEffect() + self.MyVoteChangeEffect.gameObject:SetActiveEx(false) + self.MyVoteChangeEffect.gameObject:SetActiveEx(true) +end + +function XUiPanelPlayerVote:ResetEffect() + self.MyVoteChangeEffect.gameObject:SetActiveEx(false) +end + +function XUiPanelPlayerVote:ClearBulletCache() + for i = 1,#self.AnimationGridList do + CS.UnityEngine.GameObject.Destroy(self.AnimationGridList[i].GameObject) + end + self.AnimationGridList = {} +end + +return XUiPanelPlayerVote \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMoeWar/Support/XUiMoeWarSupport.lua b/Resources/Scripts/XUi/XUiMoeWar/Support/XUiMoeWarSupport.lua new file mode 100644 index 00000000..44ac3fc6 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMoeWar/Support/XUiMoeWarSupport.lua @@ -0,0 +1,49 @@ +local XUiMoeWarSupportGrid = require("XUi/XUiMoeWar/Support/XUiMoeWarSupportGrid") + +--场外应援 +local XUiMoeWarSupport = XLuaUiManager.Register(XLuaUi, "UiMoeWarSupport") + +function XUiMoeWarSupport:OnAwake() + self:AutoAddListener() + self:InitAssetPanel() + self:InitDynamicTable() + self.TxtName.text = CS.XTextManager.GetText("MoeWarSupportViewTitle") + self.GridReward.gameObject:SetActiveEx(false) +end + +function XUiMoeWarSupport:OnEnable() + self:Refresh() + XDataCenter.MoeWarManager.JudgeGotoMainWhenFightOver() +end + +function XUiMoeWarSupport:AutoAddListener() + self:RegisterClickEvent(self.BtnBack, self.Close) + self:RegisterClickEvent(self.BtnMainUi, function() XLuaUiManager.RunMain() end) + self:BindHelpBtn(self.BtnHelpCourse, "MoeWar") +end + +function XUiMoeWarSupport:InitAssetPanel() + self.AssetActivityPanel = XUiPanelActivityAsset.New(self.PanelSpecialTool, true) +end + +function XUiMoeWarSupport:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.SViewRewardList) + self.DynamicTable:SetDelegate(self) + self.DynamicTable:SetProxy(XUiMoeWarSupportGrid) + + self.EffectIdList = XMoeWarConfig.GetPreparationAssistanceEffectIdList(true) + self.DynamicTable:SetDataSource(self.EffectIdList) +end + +function XUiMoeWarSupport:Refresh() + self.DynamicTable:ReloadDataSync() + local allDifferVoteItemId = XMoeWarConfig.GetPreparationAssistanceAllDifferVoteItemId() + self.AssetActivityPanel:Refresh(allDifferVoteItemId) +end + +function XUiMoeWarSupport:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local effectId = self.EffectIdList[index] + grid:Refresh(effectId) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMoeWar/Support/XUiMoeWarSupportGrid.lua b/Resources/Scripts/XUi/XUiMoeWar/Support/XUiMoeWarSupportGrid.lua new file mode 100644 index 00000000..62d0f53b --- /dev/null +++ b/Resources/Scripts/XUi/XUiMoeWar/Support/XUiMoeWarSupportGrid.lua @@ -0,0 +1,31 @@ +local XUiMoeWarSupportGrid = XClass(nil, "XUiMoeWarSupportGrid") + +function XUiMoeWarSupportGrid:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiMoeWarSupportGrid:Refresh(effectId) + self.TextName.text = XMoeWarConfig.GetPreparationAssistanceTitle(effectId) + self.TextInfo.text = XMoeWarConfig.GetPreparationAssistanceDesc(effectId) + + local itemId = XMoeWarConfig.GetPreparationAssistanceVoteItemId(effectId) + local voteItemCount = XMoeWarConfig.GetPreparationAssistanceVoteItemCount(effectId) + local ownVoteItemCount = XDataCenter.MoeWarManager.GetSupportVoteItemCount(itemId) + local isFill = ownVoteItemCount >= voteItemCount + self.TxtCondition01.gameObject:SetActiveEx(not isFill) + self.TxtCondition02.gameObject:SetActiveEx(isFill) + if not isFill then + local itemName = XDataCenter.ItemManager.GetItemName(itemId) + local desc = CS.XTextManager.GetText("MoeWarSupportVoteItemCount", itemName, ownVoteItemCount, voteItemCount) + desc = string.gsub(desc, "\\n", "\n") + self.TxtCondition01.text = desc + end + + if self.ImageDark then + self.ImageDark.gameObject:SetActiveEx(not isFill) + end +end + +return XUiMoeWarSupportGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMoeWar/XUiMoeWarCharacter.lua b/Resources/Scripts/XUi/XUiMoeWar/XUiMoeWarCharacter.lua new file mode 100644 index 00000000..96a33678 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMoeWar/XUiMoeWarCharacter.lua @@ -0,0 +1,780 @@ +local CSXTextManagerGetText = CS.XTextManager.GetText + +local TabBtnIndex = { + Normal = 1, + Isomer = 2, +} + +local CharDataType = { + Normal = 1, --普通角色 + Try = 2, --试玩角色(robot) +} + +local CharacterTypeConvert = { + [TabBtnIndex.Normal] = XCharacterConfigs.CharacterType.Normal, + [TabBtnIndex.Isomer] = XCharacterConfigs.CharacterType.Isomer, +} +local TabBtnIndexConvert = { + [XCharacterConfigs.CharacterType.Normal] = TabBtnIndex.Normal, + [XCharacterConfigs.CharacterType.Isomer] = TabBtnIndex.Isomer, +} + +local stagePass = false +local LABEL_TEXT_MAX_COUNT = 3 + +local XUiMoeWarCharacter = XLuaUiManager.Register(XLuaUi, "UiMoeWarCharacter") + +function XUiMoeWarCharacter:OnAwake() + self:InitAutoScript() + self:InitDynamicTable() + + local root = self.UiModelGo + self.PanelRoleModel = root:FindTransform("PanelRoleModel") + self.ImgEffectHuanren = root:FindTransform("ImgEffectHuanren") + self.ImgEffectHuanren1 = root:FindTransform("ImgEffectHuanren1") + + self.TagCacheDic = {} + self.SortFunction = {} + self.SortFunction[XRoomCharFilterTipsConfigs.EnumSortTag.Default] = function(a, b, params) + local isIgnoreQuality = params and params.IsIgnoreQuality + local isIgnoreLevel = params and params.IsIgnoreLevel + local isIgnoreAbility = params and params.IsIgnoreAbility + + local AIsInTeam = self:IsInTeam(a) + local BIsInTeam = self:IsInTeam(b) + + if AIsInTeam ~= BIsInTeam then + return AIsInTeam + end + + local AHelperId = XDataCenter.MoeWarManager.GetPrepareOwnHelperId(a) + local BHelperId = XDataCenter.MoeWarManager.GetPrepareOwnHelperId(b) + local AfillConditionCount = XMoeWarConfig.GetPreparationFillConditionCount(self.StageId, AHelperId) + local BfillConditionCount = XMoeWarConfig.GetPreparationFillConditionCount(self.StageId, BHelperId) + if AfillConditionCount ~= BfillConditionCount then + return AfillConditionCount > BfillConditionCount + end + + if not isIgnoreAbility then + local AAbility = self:GetAbility(a) + local BAbility = self:GetAbility(b) + if AAbility ~= BAbility then + return AAbility > BAbility + end + end + + if not isIgnoreLevel then + local ALevel = self:GetLevel(a) + local BLevel = self:GetLevel(b) + if ALevel ~= BLevel then + return ALevel > BLevel + end + end + + if not isIgnoreQuality then + local AQuality = self:GetQuality(a) + local BQuality = self:GetQuality(b) + if AQuality ~= BQuality then + return AQuality > BQuality + end + end + + local ACharId = self:GetCharacterId(a) + local BCharID = self:GetCharacterId(b) + local priorityA = XCharacterConfigs.GetCharacterPriority(ACharId) + local priorityB = XCharacterConfigs.GetCharacterPriority(BCharID) + if priorityA ~= priorityB then + return priorityA < priorityB + end + + return ACharId > BCharID + end + self.SortFunction[XRoomCharFilterTipsConfigs.EnumSortTag.Quality] = function(a, b) + local AQuality = self:GetQuality(a) + local BQuality = self:GetQuality(b) + if AQuality ~= BQuality then + return AQuality > BQuality + end + return self.SortFunction[XRoomCharFilterTipsConfigs.EnumSortTag.Default](a, b, { IsIgnoreQuality = true }) + end + self.SortFunction[XRoomCharFilterTipsConfigs.EnumSortTag.Level] = function(a, b) + local ALevel = self:GetLevel(a) + local BLevel = self:GetLevel(b) + if ALevel ~= BLevel then + return ALevel > BLevel + end + return self.SortFunction[XRoomCharFilterTipsConfigs.EnumSortTag.Default](a, b, { IsIgnoreLevel = true }) + end + self.SortFunction[XRoomCharFilterTipsConfigs.EnumSortTag.Ability] = function(a, b) + local AAbility = self:GetAbility(a) + local BAbility = self:GetAbility(b) + if AAbility ~= BAbility then + return AAbility > BAbility + end + return self.SortFunction[XRoomCharFilterTipsConfigs.EnumSortTag.Default](a, b, { IsIgnoreAbility = true }) + end + + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self.GridCharacter.gameObject:SetActiveEx(false) +end + +function XUiMoeWarCharacter:OnStart(teamCharIdMap, teamSelectPos, cb, stageType, isHideQuitButton, characterLimitType, limitBuffId, teamBuffId, robotIdList, challengeId, stageId) + self.CharacterLimitType = characterLimitType or XFubenConfigs.CharacterLimitType.All + self.LimitBuffId = limitBuffId + self.RoleModelPanel = XUiPanelRoleModel.New(self.PanelRoleModel, self.Name, nil, true) + self.CharacterGrids = {} + self.StageType = stageType or 0 + self.IsHideQuitButton = isHideQuitButton + self.TeamCharIdMap = teamCharIdMap + self.TeamSelectPos = teamSelectPos + self.TeamResultCb = cb + self.TeamBuffId = teamBuffId + self.RobotIdList = robotIdList + self.ChallengeId = challengeId + self.StageId = stageId + + self:InitRequireCharacterInfo() + self:InitCharacterTypeBtns() + self:HideJump() + self:InitEffectPositionInfo() +end + +function XUiMoeWarCharacter:OnEnable() + self:UpdateInfo() + + self.DynamicTable:ReloadDataASync() + CS.XGraphicManager.UseUiLightDir = true + XDataCenter.MoeWarManager.JudgeGotoMainWhenFightOver() +end + +function XUiMoeWarCharacter:OnDisable() + CS.XGraphicManager.UseUiLightDir = false +end + +function XUiMoeWarCharacter:HideJump() + if self.StageType ~= XDataCenter.FubenManager.StageType.ArenaOnline then + return + end + + if self.AssetPanel.BtnBuyJump1 then + self.AssetPanel.BtnBuyJump1.gameObject:SetActiveEx(false) + end + + if self.AssetPanel.BtnBuyJump2 then + self.AssetPanel.BtnBuyJump2.gameObject:SetActiveEx(false) + end + + if self.AssetPanel.BtnBuyJump3 then + self.AssetPanel.BtnBuyJump3.gameObject:SetActiveEx(false) + end +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiMoeWarCharacter:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiMoeWarCharacter:AutoInitUi() + self.BtnBack = XUiHelper.TryGetComponent(self.Transform, "SafeAreaContentPane/Top/BtnBack", "Button") + self.BtnJoinTeam = XUiHelper.TryGetComponent(self.Transform, "SafeAreaContentPane/CharList/TeamBtn/BtnJoinTeam", "Button") + self.BtnConsciousness = XUiHelper.TryGetComponent(self.Transform, "SafeAreaContentPane/CharList/TeamBtn/BtnConsciousness", "Button") + self.BtnQuitTeam = XUiHelper.TryGetComponent(self.Transform, "SafeAreaContentPane/CharList/TeamBtn/BtnQuitTeam", "Button") + self.SViewCharacterList = XUiHelper.TryGetComponent(self.Transform, "SafeAreaContentPane/CharList/CharInfo/Left/SViewCharacterList", "ScrollRect") + self.PanelRoleContent = XUiHelper.TryGetComponent(self.Transform, "SafeAreaContentPane/CharList/CharInfo/Left/SViewCharacterList/Viewport/PanelRoleContent") + self.GridCharacter = XUiHelper.TryGetComponent(self.Transform, "SafeAreaContentPane/CharList/CharInfo/Left/SViewCharacterList/Viewport/PanelRoleContent/GridCharacter") + self.BtnFashion = XUiHelper.TryGetComponent(self.Transform, "SafeAreaContentPane/CharList/TeamBtn/BtnFashion", "Button") + self.PanelRoleModel = XUiHelper.TryGetComponent(self.Transform, "SafeAreaContentPane/ModelRoot/NearRoot/PanelRoleModel") + self.PanelDrag = XUiHelper.TryGetComponent(self.Transform, "SafeAreaContentPane/CharList/CharInfo/PanelDrag", "XDrag") + self.BtnWeapon = XUiHelper.TryGetComponent(self.Transform, "SafeAreaContentPane/CharList/TeamBtn/BtnWeapon", "Button") + self.TxtRequireAbility = XUiHelper.TryGetComponent(self.Transform, "SafeAreaContentPane/CharList/TeamBtn/PanelTxt/TxtRequireAbility", "Text") + self.PanelAsset = XUiHelper.TryGetComponent(self.Transform, "SafeAreaContentPane/PanelAsset") + self.BtnMainUi = XUiHelper.TryGetComponent(self.Transform, "SafeAreaContentPane/Top/BtnMainUi", "Button") + self.PanelRequireCharacter = XUiHelper.TryGetComponent(self.Transform, "SafeAreaContentPane/CharList/TeamBtn/PanelTxt/PanelRequireCharacter") + self.ImgRequireCharacter = XUiHelper.TryGetComponent(self.Transform, "SafeAreaContentPane/CharList/TeamBtn/PanelTxt/PanelRequireCharacter/Image/ImgRequireCharacter", "Image") + self.TxtRequireCharacter = XUiHelper.TryGetComponent(self.Transform, "SafeAreaContentPane/CharList/TeamBtn/PanelTxt/PanelRequireCharacter/TxtRequireCharacter", "Text") + + for i = 1, LABEL_TEXT_MAX_COUNT do + self["TagLabel" .. i] = XUiHelper.TryGetComponent(self.Transform, "SafeAreaContentPane/CharList/PanelLabel/Label0" .. i) + self["TextTagLabel" .. i] = XUiHelper.TryGetComponent(self["TagLabel" .. i].transform, "Text", "Text") + end +end + +function XUiMoeWarCharacter:AutoAddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnJoinTeam, self.OnBtnJoinTeamClick) + self:RegisterClickEvent(self.BtnConsciousness, self.OnBtnConsciousnessClick) + self:RegisterClickEvent(self.BtnQuitTeam, self.OnBtnQuitTeamClick) + self:RegisterClickEvent(self.BtnFashion, self.OnBtnFashionClick) + self:RegisterClickEvent(self.BtnWeapon, self.OnBtnWeaponClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:RegisterClickEvent(self.BtnPartner, self.OnCarryPartnerClick) + + self.BtnFilter.CallBack = function() self:OnBtnFilterClick() end +end +-- auto +function XUiMoeWarCharacter:OnBtnWeaponClick() + XLuaUiManager.Open("UiEquipReplaceNew", self.CurCharacter.Id, nil, true) +end + +function XUiMoeWarCharacter:OnBtnConsciousnessClick() + XLuaUiManager.Open("UiEquipAwarenessReplace", self.CurCharacter.Id, nil, true) +end + +function XUiMoeWarCharacter:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiMoeWarCharacter:OnCarryPartnerClick() + XDataCenter.PartnerManager.GoPartnerCarry(self.CurCharacter.Id, false) +end + +function XUiMoeWarCharacter:OnBtnFilterClick() + local characterType = CharacterTypeConvert[self.SelectTabBtnIndex] + XLuaUiManager.Open("UiRoomCharacterFilterTips", + self, + XRoomCharFilterTipsConfigs.EnumFilterType.Common, + XRoomCharFilterTipsConfigs.EnumSortType.Common, + characterType) +end + +--初始化音效 +function XUiMoeWarCharacter:InitBtnSound() + self.SpecialSoundMap[self:GetAutoKey(self.BtnBack, "onClick")] = XSoundManager.UiBasicsMusic.Return + self.SpecialSoundMap[self:GetAutoKey(self.BtnEquip, "onClick")] = XSoundManager.UiBasicsMusic.Fuben_UiMainLineRoomCharacter_Equip + self.SpecialSoundMap[self:GetAutoKey(self.BtnFashion, "onClick")] = XSoundManager.UiBasicsMusic.Fuben_UiMainLineRoomCharacter_Fashion + self.SpecialSoundMap[self:GetAutoKey(self.BtnJoinTeam, "onClick")] = XSoundManager.UiBasicsMusic.Fuben_UiMainLineRoomCharacter_JoinTeam + self.SpecialSoundMap[self:GetAutoKey(self.BtnQuitTeam, "onClick")] = XSoundManager.UiBasicsMusic.Fuben_UiMainLineRoomCharacter_QuitTeam +end + +function XUiMoeWarCharacter:InitRequireCharacterInfo() + local characterLimitType = self.CharacterLimitType + + if not XFubenConfigs.IsStageCharacterLimitConfigExist(characterLimitType) then + self.PanelRequireCharacter.gameObject:SetActiveEx(false) + return + else + self.PanelRequireCharacter.gameObject:SetActiveEx(true) + end + + local icon = XFubenConfigs.GetStageCharacterLimitImageTeamEdit(characterLimitType) + self.ImgRequireCharacter:SetSprite(icon) +end + +function XUiMoeWarCharacter:InitEffectPositionInfo() + if self.StageType ~= XDataCenter.FubenManager.StageType.InfestorExplore then + self.PanelEffectPosition.gameObject:SetActiveEx(false) + return + end + self.TxtEffectPosition.text = XDataCenter.FubenInfestorExploreManager.GetBuffDes() + self.PanelEffectPosition.gameObject:SetActiveEx(true) +end + +function XUiMoeWarCharacter:RefreshCharacterTypeTips() + local limitBuffId = self.LimitBuffId + local characterType = CharacterTypeConvert[self.SelectTabBtnIndex] + local characterLimitType = self.CharacterLimitType + local text = XFubenConfigs.GetStageCharacterLimitTextSelectCharacter(characterLimitType, characterType, limitBuffId) + self.TxtRequireCharacter.text = text +end + +function XUiMoeWarCharacter:ResetTeamData() + self.TeamCharIdMap = { 0, 0, 0 } +end + +function XUiMoeWarCharacter:InitCharacterTypeBtns() + self.BtnTabShougezhe.gameObject:SetActiveEx(not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.Isomer)) + + local tabBtns = { self.BtnTabGouzaoti, self.BtnTabShougezhe } + self.PanelCharacterTypeBtns:Init(tabBtns, function(index) self:TrySelectCharacterType(index) end) + + local characterLimitType = self.CharacterLimitType + local lockGouzaoti = characterLimitType == XFubenConfigs.CharacterLimitType.Isomer + local lockShougezhe = not XFunctionManager.JudgeOpen(XFunctionManager.FunctionName.Isomer) or characterLimitType == XFubenConfigs.CharacterLimitType.Normal + self.BtnTabGouzaoti:SetDisable(lockGouzaoti) + self.BtnTabShougezhe:SetDisable(lockShougezhe) + + --检查选择角色类型是否和副本限制类型冲突 + local characterType = XDataCenter.FubenManager.GetDefaultCharacterTypeByCharacterLimitType(self.CharacterLimitType) + local tempCharacterType = self:GetTeamCharacterType() + if tempCharacterType and not (tempCharacterType == XCharacterConfigs.CharacterType.Normal and lockGouzaoti + or tempCharacterType == XCharacterConfigs.CharacterType.Isomer and lockShougezhe) then + characterType = tempCharacterType + end + + self:InitBtnTabIsClick() + self.PanelCharacterTypeBtns:SelectIndex(TabBtnIndexConvert[characterType]) +end + +function XUiMoeWarCharacter:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.SViewCharacterList) + self.DynamicTable:SetProxy(XUiGridCharacter, self) + self.DynamicTable:SetDelegate(self) +end + +function XUiMoeWarCharacter:TrySelectCharacterType(index) + local characterType = CharacterTypeConvert[index] + + if not self:IsCanClickBtnTab(characterType) then + return + end + + local characterLimitType = self.CharacterLimitType + if characterLimitType == XFubenConfigs.CharacterLimitType.Normal then + if characterType == XCharacterConfigs.CharacterType.Isomer then + XUiManager.TipText("TeamSelectCharacterTypeLimitTipNormal") + return + end + elseif characterLimitType == XFubenConfigs.CharacterLimitType.Isomer then + if characterType == XCharacterConfigs.CharacterType.Normal then + XUiManager.TipText("TeamSelectCharacterTypeLimitTipIsomer") + return + end + end + + self:OnSelectCharacterType(index) +end + +function XUiMoeWarCharacter:OnSelectCharacterType(index) + if self.SelectTabBtnIndex == index then + local btn = self.PanelCharacterTypeBtns:GetButtonByIndex(index) + btn:SetButtonState(CS.UiButtonState.Normal) + return + end + self.SelectTabBtnIndex = index + local characterType = CharacterTypeConvert[index] + self.CharIdlist = {} + self.AllCharIdList = {} + XDataCenter.RoomCharFilterTipsManager.Reset() + + self.CharIdlist = XDataCenter.CharacterManager.GetRobotAndCorrespondCharacterIdList(self.RobotIdList, characterType) + + table.sort(self.CharIdlist, self.SortFunction[XRoomCharFilterTipsConfigs.EnumSortTag.Default]) + self.AllCharIdList = self.CharIdlist + + self:RefreshCharacterTypeTips() + self:UpdateCharacterList(index) +end + +function XUiMoeWarCharacter:InitBtnTabIsClick() + local isClickNormal, isClickOmer = false, false + local characterType + for _, charId in ipairs(self.RobotIdList) do + if charId > 0 then + characterType = XCharacterConfigs.GetCharacterType(charId) + if characterType == XCharacterConfigs.CharacterType.Normal and not isClickNormal then + isClickNormal = true + elseif characterType == XCharacterConfigs.CharacterType.Isomer and not isClickOmer then + isClickOmer = true + end + end + end + self.IsClickNormal = isClickNormal + self.IsClickOmer = isClickOmer + self.BtnTabGouzaoti:SetDisable(not isClickNormal) + self.BtnTabShougezhe:SetDisable(not isClickOmer) +end + +function XUiMoeWarCharacter:IsCanClickBtnTab(characterType) + if not self.CharIdlist then + return true + end + + if characterType == XCharacterConfigs.CharacterType.Normal and self.IsClickNormal then + return true + end + if characterType == XCharacterConfigs.CharacterType.Isomer and self.IsClickOmer then + return true + end + return false +end + +function XUiMoeWarCharacter:SetPanelEmptyList(isEmpty) + local curCharIsRobot = self.CurCharacter and XRobotManager.CheckIsRobotId(self.CurCharacter.Id) or false + + self.BtnQuitTeam.gameObject:SetActiveEx(false) + self.BtnJoinTeam.gameObject:SetActiveEx(false) + + self.BtnConsciousness.gameObject:SetActiveEx(not isEmpty and not curCharIsRobot) + self.BtnFashion.gameObject:SetActiveEx(not isEmpty and not curCharIsRobot) + self.BtnWeapon.gameObject:SetActiveEx(not isEmpty and not curCharIsRobot) + self.BtnPartner.gameObject:SetActiveEx(not isEmpty and not curCharIsRobot) + + self.PanelRoleModel.gameObject:SetActiveEx(not isEmpty) + self.PanelRoleContent.gameObject:SetActiveEx(not isEmpty) + self.PanelEmptyList.gameObject:SetActiveEx(isEmpty) +end + +function XUiMoeWarCharacter:UpdataPanelEmptyList() + local curCharIsRobot = self.CurCharacter and XRobotManager.CheckIsRobotId(self.CurCharacter.Id) or false + + self.BtnConsciousness.gameObject:SetActiveEx(not curCharIsRobot) + self.BtnFashion.gameObject:SetActiveEx(not curCharIsRobot) + self.BtnWeapon.gameObject:SetActiveEx(not curCharIsRobot) + self.BtnPartner.gameObject:SetActiveEx(not curCharIsRobot) + + self.BtnJoinTeam.gameObject:SetActiveEx(self.NeedShowBtnJoinTeam) +end + +function XUiMoeWarCharacter:UpdateCharacterList(index) + stagePass = XDataCenter.RoomManager.CheckPlayerStagePass() or XDataCenter.ArenaOnlineManager.CheckStagePass(self.ChallengeId) + local characterType = CharacterTypeConvert[index] + local teamCharIdMap = self.TeamCharIdMap + local selectId = teamCharIdMap[self.TeamSelectPos] + + if not next(self.CharIdlist) then + self:SetPanelEmptyList(true) + return + end + self:SetPanelEmptyList(false) + + self.CurIndex = nil + self.CharacterIdToIndex = {} + local useDefaultIndex = true + if selectId and selectId ~= 0 and characterType == XCharacterConfigs.GetCharacterType(selectId) then + useDefaultIndex = false + end + for index, id in ipairs(self.CharIdlist) do + self.CharacterIdToIndex[id] = index + if self.CurIndex == nil and id == selectId and not useDefaultIndex then + self.CurIndex = index + end + end + self.CurIndex = self.CurIndex or 1 + + local charInfo = self:GetCharInfo(self.CurIndex) + self:UpdateInfo(charInfo) + + self.DynamicTable:SetDataSource(self.CharIdlist) + self.DynamicTable:ReloadDataASync() +end + +function XUiMoeWarCharacter:OnDynamicTableEvent(event, index, grid) + local characterId = self.CharIdlist[index] + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + if index < 0 or index > #self.CharIdlist then return end + local char = self:GetCharInfo(index) + grid:UpdateGrid(char, self.StageType) + + local showTeamBuff = XFubenConfigs.IsCharacterFitTeamBuff(self.TeamBuffId, characterId) + grid:SetTeamBuff(showTeamBuff) + grid:SetSelect(self.CurIndex == index) + grid:SetInTeam(false) + for pos, id in pairs(self.TeamCharIdMap) do + if id > 0 and self.CharacterIdToIndex[id] == index then + grid:SetInTeam(true, CSXTextManagerGetText("CommonInTheTeam"), pos) + break + end + end + + grid.Transform:SetAsLastSibling() + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + self.CurIndex = index + self:UpdateInfo(grid.Character) + self.DynamicTable:ReloadDataSync() + end +end + +function XUiMoeWarCharacter:GetCharInfo(index) + local characterId = self.CharIdlist[index] + local char = {} + if XRobotManager.CheckIsRobotId(characterId) then + char.Id = characterId + char.IsRobot = true + else + char = XDataCenter.CharacterManager.GetCharacter(characterId) + end + return char +end + +function XUiMoeWarCharacter:UpdateInfo(character) + if character then + self.CurCharacter = character + end + if not self.CurCharacter then return end + + self:UpdateTeamBtn() + self:UpdateRoleModel() + self:UpdateTagLabel() +end + +function XUiMoeWarCharacter:UpdateTagLabel() + local helperId = XDataCenter.MoeWarManager.GetPrepareOwnHelperId(self.CurCharacter.Id) + local helperLabelIds = helperId > 0 and XMoeWarConfig.GetMoeWarPreparationHelperLabelIds(helperId) or {} + for i = 1, LABEL_TEXT_MAX_COUNT do + if not helperLabelIds[i] then + self["TagLabel" .. i].gameObject:SetActiveEx(false) + else + self["TextTagLabel" .. i].text = XMoeWarConfig.GetPreparationStageTagLabelById(helperLabelIds[i]) + self["TagLabel" .. i].gameObject:SetActiveEx(true) + end + end +end + +function XUiMoeWarCharacter:UpdateTeamBtn() + if not (self.TeamCharIdMap and next(self.TeamCharIdMap)) then + return + end + + --在当前操作的队伍中 + local isInTeam = self:IsInTeam(self.CurCharacter.Id) + + local needShowBtnQuitTeam = isInTeam + self.NeedShowBtnJoinTeam = not isInTeam + + self.BtnQuitTeam.gameObject:SetActiveEx(needShowBtnQuitTeam and not self.IsHideQuitButton) + self.BtnJoinTeam.gameObject:SetActiveEx(false) +end + +function XUiMoeWarCharacter:IsInTeam(id) + if not (self.TeamCharIdMap and next(self.TeamCharIdMap)) then + return false + end + for _, v in pairs(self.TeamCharIdMap) do + if id == v then + return true + end + end + return false +end + +function XUiMoeWarCharacter:UpdateRoleModel() + local characterId = self.CurCharacter and self.CurCharacter.Id + if not characterId then return end + local targetPanelRole = self.PanelRoleModel + local targetUiName = self.Name + local func = function() + self:UpdataPanelEmptyList() + end + local charaterFunc = function(model) + if not model then + return + end + self.PanelDrag.Target = model.transform + if self.SelectTabBtnIndex == TabBtnIndex.Normal then + self.ImgEffectHuanren.gameObject:SetActiveEx(true) + elseif self.SelectTabBtnIndex == TabBtnIndex.Isomer then + self.ImgEffectHuanren1.gameObject:SetActiveEx(true) + end + end + + self.ImgEffectHuanren.gameObject:SetActiveEx(false) + self.ImgEffectHuanren1.gameObject:SetActiveEx(false) + + if XRobotManager.CheckIsRobotId(self.CurCharacter.Id) then + local robotCfg = XRobotManager.GetRobotTemplate(self.CurCharacter.Id) + self.RoleModelPanel:UpdateRobotModel(self.CurCharacter.Id, self.CurCharacter.Id, nil, robotCfg.FashionId, robotCfg.WeaponId, func) + else + self.RoleModelPanel:UpdateCharacterModel(self.CurCharacter.Id, targetPanelRole, targetUiName, charaterFunc, func) + end +end + +function XUiMoeWarCharacter:OnBtnBackClick() + if self.TeamResultCb then + self.TeamResultCb(self.TeamCharIdMap) + end + self:Close() +end + +function XUiMoeWarCharacter:OnBtnJoinTeamClick() + local id = self.CurCharacter.Id + local joinFunc = function(isReset) + if isReset then + self:ResetTeamData() + else + for k, v in pairs(self.TeamCharIdMap) do + if XRobotManager.CheckIsRobotId(v) and not XRobotManager.CheckIsRobotId(id) then + local robotTemplate = XRobotManager.GetRobotTemplate(v) + local charId = robotTemplate and robotTemplate.CharacterId or 0 + if charId == id then + self.TeamCharIdMap[k] = 0 + break + end + elseif not XRobotManager.CheckIsRobotId(v) and XRobotManager.CheckIsRobotId(id) then + local robotTemplate = XRobotManager.GetRobotTemplate(id) + local charId = robotTemplate and robotTemplate.CharacterId or 0 + if v == charId then + self.TeamCharIdMap[k] = 0 + break + end + else + if v == id then + self.TeamCharIdMap[k] = 0 + break + end + end + end + end + + self.TeamCharIdMap[self.TeamSelectPos] = id + + if self.TeamResultCb then + self.TeamResultCb(self.TeamCharIdMap) + end + + self:Close() + end + + -- 角色类型不一致拦截 + local inTeamCharacterType = self:GetTeamCharacterType() + if inTeamCharacterType then + local characterType = id and id ~= 0 and XCharacterConfigs.GetCharacterType(id) + if characterType and characterType ~= inTeamCharacterType then + local content = CSXTextManagerGetText("TeamCharacterTypeNotSame") + local sureCallBack = function() + local isReset = true + joinFunc(isReset) + end + XUiManager.DialogTip(nil, content, XUiManager.DialogType.Normal, nil, sureCallBack) + return + end + end + + joinFunc() +end + +function XUiMoeWarCharacter:OnBtnQuitTeamClick() + local count = 0 + for _, v in pairs(self.TeamCharIdMap) do + if v > 0 then + count = count + 1 + end + end + + local id = self.CurCharacter.Id + for k, v in pairs(self.TeamCharIdMap) do + if v == id then + self.TeamCharIdMap[k] = 0 + break + end + end + + if self.TeamResultCb then + self.TeamResultCb(self.TeamCharIdMap) + end + self:Close() +end + +function XUiMoeWarCharacter:OnBtnFashionClick() + XLuaUiManager.Open("UiFashion", self.CurCharacter.Id) +end + +function XUiMoeWarCharacter:GetTeamCharacterType() + for k, v in pairs(self.TeamCharIdMap) do + if v ~= 0 then + return XCharacterConfigs.GetCharacterType(v) + end + end +end + +function XUiMoeWarCharacter:CheckIsRobotId(id) + return id < 1000000 +end + +function XUiMoeWarCharacter:GetCharacterId(id) + if XRobotManager.CheckIsRobotId(id) then + return XRobotManager.GetRobotTemplate(id).CharacterId + else + return id + end +end + +function XUiMoeWarCharacter:GetAbility(id) + if XRobotManager.CheckIsRobotId(id) then + return XRobotManager.GetRobotTemplate(id).ShowAbility + else + return XDataCenter.CharacterManager.GetCharacter(id).Ability + end +end + +function XUiMoeWarCharacter:GetLevel(id) + if XRobotManager.CheckIsRobotId(id) then + return XRobotManager.GetRobotTemplate(id).CharacterLevel + else + return XDataCenter.CharacterManager.GetCharacter(id).Level + end +end + +function XUiMoeWarCharacter:GetQuality(id) + if XRobotManager.CheckIsRobotId(id) then + return XRobotManager.GetRobotTemplate(id).CharacterQuality + else + return XDataCenter.CharacterManager.GetCharacter(id).Quality + end +end + +function XUiMoeWarCharacter:Filter(selectTagGroupDic, sortTagId, isThereFilterDataCb) + local judgeCb = function(groupId, tagValue, characterId) + local char = {} + if XRobotManager.CheckIsRobotId(characterId) then + char.Id = characterId + char.IsRobot = true + else + char = XDataCenter.CharacterManager.GetCharacter(characterId) + end + + local compareValue + local detailConfig + if char.IsRobot then + local robotTemplate = XRobotManager.GetRobotTemplate(char.Id) + detailConfig = XCharacterConfigs.GetCharDetailTemplate(robotTemplate.CharacterId) + else + detailConfig = XCharacterConfigs.GetCharDetailTemplate(char.Id) + end + + if groupId == XRoomCharFilterTipsConfigs.EnumFilterTagGroup.Career then + compareValue = detailConfig.Career + if compareValue == tagValue then + -- 当前角色满足该标签 + return true + end + elseif groupId == XRoomCharFilterTipsConfigs.EnumFilterTagGroup.Element then + compareValue = detailConfig.ObtainElementList + for _, element in pairs(compareValue) do + if element == tagValue then + -- 当前角色满足该标签 + return true + end + end + else + XLog.Error(string.format("XUiMoeWarCharacter:Filter函数错误,没有处理排序组:%s的逻辑", groupId)) + return false + end + end + + XDataCenter.RoomCharFilterTipsManager.Filter(self.TagCacheDic, selectTagGroupDic, self.AllCharIdList, judgeCb, + function(filteredData) + self:FilterRefresh(filteredData, sortTagId) + end, + isThereFilterDataCb) +end + +function XUiMoeWarCharacter:FilterRefresh(filteredData, sortTagId) + self.CharIdlist = filteredData + + if not next(filteredData) then + self:SetPanelEmptyList(true) + return + end + self:SetPanelEmptyList(false) + + if self.SortFunction[sortTagId] then + table.sort(filteredData, self.SortFunction[sortTagId]) + else + XLog.Error(string.format("XUiMoeWarCharacter:FilterRefresh函数错误,没有定义标签:%s的排序函数", sortTagId)) + return + end + + self.CharacterIdToIndex = {} + for index, id in ipairs(filteredData) do + self.CharacterIdToIndex[id] = index + end + self.CurIndex = 1 + + local charInfo = self:GetCharInfo(self.CurIndex) + self:UpdateInfo(charInfo) + + self.DynamicTable:SetDataSource(filteredData) + self.DynamicTable:ReloadDataASync() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMoeWar/XUiMoeWarGroupList.lua b/Resources/Scripts/XUi/XUiMoeWar/XUiMoeWarGroupList.lua new file mode 100644 index 00000000..6330fab1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMoeWar/XUiMoeWarGroupList.lua @@ -0,0 +1,72 @@ +local XUiMoeWarGroupList = XLuaUiManager.Register(XLuaUi, "UiMoeWarGroupList") +local XUiGridGroupList = require("XUi/XUiMoeWar/ChildItem/XUiGridGroupList") +local tableInsert = table.insert +local GROUP_COUNT = 3 +function XUiMoeWarGroupList:OnStart() + self:InitUi() +end + +function XUiMoeWarGroupList:OnEnable() +end + +function XUiMoeWarGroupList:OnDisable() + +end + +function XUiMoeWarGroupList:OnGetEvents() + return { + XEventId.EVENT_MOE_WAR_UPDATE, + XEventId.EVENT_MOE_WAR_ACTIVITY_END, + } +end + +function XUiMoeWarGroupList:OnNotify(event, ...) + if event == XEventId.EVENT_MOE_WAR_UPDATE then + local match = XDataCenter.MoeWarManager.GetCurMatch() + if match:GetSessionId() ~= XMoeWarConfig.SessionType.Game24In12 then + self:Close() + end + elseif event == XEventId.EVENT_MOE_WAR_ACTIVITY_END then + XUiManager.TipText("MoeWarActivityOver") + XLuaUiManager.RunMain() + end +end + +function XUiMoeWarGroupList:PlayGroupAnimation() + +end + +function XUiMoeWarGroupList:RegisterButtonEvent() + self.BtnMainUi.CallBack = function() XLuaUiManager.RunMain() end + self.BtnBack.CallBack = function() XLuaUiManager.Close("UiMoeWarGroupList") end +end + +function XUiMoeWarGroupList:InitGroups() + self.GridGroupList = {} + for i = 1, GROUP_COUNT do + local obj = CS.UnityEngine.GameObject.Instantiate(self.GridGroup, self.PanelGroup) + local grid = XUiGridGroupList.New(obj, i) + tableInsert(self.GridGroupList, grid) + end + self.GridGroup.gameObject:SetActiveEx(false) +end + +function XUiMoeWarGroupList:InitUi() + if self.PanelSpecialTool then + self.ActInfo = XDataCenter.MoeWarManager.GetActivityInfo() + self.AssetActivityPanel = XUiPanelActivityAsset.New(self.PanelSpecialTool) + self.AssetActivityPanel:Refresh(self.ActInfo.CurrencyId) + for i = 1,#self.ActInfo.CurrencyId do + XDataCenter.ItemManager.AddCountUpdateListener(self.ActInfo.CurrencyId[i], function() + self.AssetActivityPanel:Refresh(self.ActInfo.CurrencyId) + end, self.AssetActivityPanel) + end + end + --self.TxtTip.text = CS.XTextManager.GetText("MoeWarGroupListTip") + self:RegisterButtonEvent() + self:InitGroups() +end + + + +return XUiMoeWarGroupList \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMoeWar/XUiMoeWarMain.lua b/Resources/Scripts/XUi/XUiMoeWar/XUiMoeWarMain.lua new file mode 100644 index 00000000..4a1013ed --- /dev/null +++ b/Resources/Scripts/XUi/XUiMoeWar/XUiMoeWarMain.lua @@ -0,0 +1,348 @@ + +local ButtonStateNormal = CS.UiButtonState.Normal +local ButtonStateSelect = CS.UiButtonState.Select +local ButtonStateDisable = CS.UiButtonState.Disable +local CSXTextManagerGetText = CS.XTextManager.GetText +local MaxMatchCount = 4 + +local XUiMoeWarMain = XLuaUiManager.Register(XLuaUi, "UiMoeWarMain") + +function XUiMoeWarMain:OnStart() + self:RegisterButtonEvent() + self:InitRedPoint() + self:InitUi() +end + +function XUiMoeWarMain:OnEnable() + self.AssetActivityPanel:Refresh(self.ActInfo.CurrencyId) + self:StartTimer() + self:RefreshPreparation() + self:RefreshVotePanel() + self:CheckRedPoint() +end + +function XUiMoeWarMain:OnDisable() + self:StopTimer() +end + +function XUiMoeWarMain:OnGetEvents() + return { + XEventId.EVENT_MOE_WAR_PREPARATION_UPDATE, + XEventId.EVENT_MOE_WAR_UPDATE, + } +end + +function XUiMoeWarMain:OnNotify(event, ...) + local args = { ... } + if event == XEventId.EVENT_MOE_WAR_PREPARATION_UPDATE then + self:RefreshPreparation() + elseif event == XEventId.EVENT_MOE_WAR_UPDATE then + self:RefreshVotePanel() + end +end + +function XUiMoeWarMain:InitRedPoint() + self.BtnPrepareRedPointEventId = XRedPointManager.AddRedPointEvent(self.BtnPrepare, self.OnPrepareRedPointEvent, self, { XRedPointConditions.Types.CONDITION_MOEWAR_PREPARATION }) + XRedPointManager.AddRedPointEvent(self.BtnTask,self.OnTaskRedPointEvent,self,{XRedPointConditions.Types.CONDITION_MOEWAR_TASK}) + XRedPointManager.AddRedPointEvent(self.BtnReward,self.OnGachaRedPointEvent,self,{XRedPointConditions.Types.CONDITION_MOEWAR_DRAW}) +end + +function XUiMoeWarMain:InitUi() + self.TxtName.text = XMoeWarConfig.GetActivityName() + self.ActInfo = XDataCenter.MoeWarManager.GetActivityInfo() + self.AssetActivityPanel = XUiPanelActivityAsset.New(self.PanelSpecialTool) + for i = 1,#self.ActInfo.CurrencyId do + XDataCenter.ItemManager.AddCountUpdateListener(self.ActInfo.CurrencyId[i], function() + self.AssetActivityPanel:Refresh(self.ActInfo.CurrencyId) + end, self.AssetActivityPanel) + end + + self.ItemGridList = {} + local showItems = XMoeWarConfig.GetShowItems() + for i = 1,#showItems do + if self.ItemGrid then + local obj = CS.UnityEngine.GameObject.Instantiate(self.ItemGrid,self.ItemContent) + local grid = XUiGridCommon.New(self,obj) + local itemTemplate = XDataCenter.ItemManager.GetItemTemplate(showItems[i]) + table.insert(self.ItemGridList,grid) + grid:Refresh(itemTemplate) + end + end + if self.ItemGrid then + self.ItemGrid.gameObject:SetActiveEx(false) + end + self.BtnVote:SetName(CS.XTextManager.GetText("MoeWarGoVote")) + self.BtnRank:SetName(CS.XTextManager.GetText("MoeWarRankName")) + self.BtnRole:SetName(CS.XTextManager.GetText("MoeWarIntroduceName")) + self.BtnSchedule:SetName(CS.XTextManager.GetText("MoeWarGameName")) + self.BtnActivity:SetNameByGroup(0,CS.XTextManager.GetText("MoeWarWebName")) + self.BtnActivity:SetNameByGroup(1,CS.XTextManager.GetText("MoeWarWebNameEng")) + self.BtnReward:SetNameByGroup(0,CS.XTextManager.GetText("MoeWarRewardName")) + self.BtnReward:SetNameByGroup(1,CS.XTextManager.GetText("MoeWarRewardNameEng")) + self.BtnShop:SetNameByGroup(0,CS.XTextManager.GetText("MoeWarGachaName")) + self.BtnShop:SetNameByGroup(1,CS.XTextManager.GetText("MoeWarGachaNameEng")) + self.BtnTask:SetNameByGroup(0,CS.XTextManager.GetText("MoeWarTaskName")) + self.BtnTask:SetNameByGroup(1,CS.XTextManager.GetText("MoeWarTaskNameEng")) + self.TxtRewardMain = self.Transform:Find("SafeAreaContentPane/PanelAll/PanelReward/Text"):GetComponent("Text") + if self.TxtRewardMain then + local text = CS.XTextManager.GetText("MoeWarMainText") + self.TxtRewardMain.text = string.gsub(text, "\\n", "\n") + end + self:InitBtnPrepare() + self:RefreshActivityTime() + self:RefreshVoteTime() +end + +function XUiMoeWarMain:InitBtnPrepare() + local preparationActivityId = XMoeWarConfig.GetPreparationActivityIdInTime() + if not preparationActivityId then + return + end + + local activityName = XMoeWarConfig.GetPreparationActivityName(preparationActivityId) + local smallTitle = CSXTextManagerGetText("MoeWarBtnPrepareSmallTitle") + self.BtnPrepare:SetNameByGroup(0, activityName) + self.BtnPrepare:SetNameByGroup(1, smallTitle) +end + +function XUiMoeWarMain:RegisterButtonEvent() + self.BtnMainUi.CallBack = function() + XLuaUiManager.RunMain() + end + + self.BtnBack.CallBack = function() + self:Close() + end + + self.BtnShop.CallBack = function() + local gachaSkipId = XMoeWarConfig.GetGachaSkipId() + if gachaSkipId then + XFunctionManager.SkipInterface(gachaSkipId) + end + end + + self.BtnActivity.CallBack = function() + local webUrl = XMoeWarConfig.GetWebUrl() + if webUrl then + if string.find(webUrl, "eden") ~= nil then -- 伊甸文化跳转 + local uid = XUserManager.UserId + local serverId = CS.XHeroBdcAgent.ServerId + if uid and uid ~= "" then + if serverId and serverId ~= "" then + CS.UnityEngine.Application.OpenURL(webUrl.."?uid="..uid.."&serverId="..serverId) + else + CS.UnityEngine.Application.OpenURL(webUrl.."?uid="..uid) + end + else + CS.UnityEngine.Application.OpenURL(webUrl) + end + else + CS.UnityEngine.Application.OpenURL(webUrl) + end + end + end + + self.BtnReward.CallBack = function() + local rewardSkipId = XMoeWarConfig.GetRewardSkipId() + if rewardSkipId then + XFunctionManager.SkipInterface(rewardSkipId) + end + end + + self.BtnTask.CallBack = function() + XLuaUiManager.Open("UiMoeWarTask") + end + + self.BtnRank.CallBack = function() + XLuaUiManager.Open("UiMoeWarRankingList") + end + + self.BtnRole.CallBack = function() + XLuaUiManager.Open("UiMoeWarMessage") + end + + self.BtnSchedule.CallBack = function() + XLuaUiManager.Open("UiMoeWarSchedule") + end + + self.BtnPrepare.CallBack = function() + XLuaUiManager.Open("UiMoeWarPreparation") + end + + self.BtnVote.CallBack = function() + self:OnClickBtnVote() + end + + if self.BtnHelp then + local mainHelpId = XMoeWarConfig.GetMainHelpId() + self.BtnHelp.CallBack = function () + if mainHelpId > 0 then + local template = XHelpCourseConfig.GetHelpCourseTemplateById(mainHelpId) + XUiManager.ShowHelpTip(template.Function) + end + end + self.BtnHelp.gameObject:SetActiveEx(mainHelpId > 0) + end +end + +function XUiMoeWarMain:OnClickBtnVote() + local match = XDataCenter.MoeWarManager.GetCurMatch() + if match:GetType() == XMoeWarConfig.MatchType.Publicity then + local index = XDataCenter.MoeWarManager.GetDefaultSelect() + local saveKey = string.format("%s_%s_%d_%d",XMoeWarConfig.MOE_WAR_VOTE_ANIMATION_RECORD,tostring(XPlayer.Id),match:GetSessionId(),index) + local data = XSaveTool.GetData(saveKey) + local isSkip = XSaveTool.GetData(string.format("%s_%s",XMoeWarConfig.SKIP_KEY_PREFIX,XPlayer.Id)) or false + if not data and not isSkip then + XDataCenter.MoeWarManager.EnterAnimation(match:GetPairList()[index],match,function() + XDataCenter.MoeWarManager.OpenVotePanel(index) + XLuaUiManager.Remove("UiMoeWarAnimation") + end) + XSaveTool.SaveData(saveKey,1) + else + XDataCenter.MoeWarManager.OpenVotePanel(index) + end + else + XDataCenter.MoeWarManager.OpenVotePanel() + end +end + +function XUiMoeWarMain:StartTimer() + if self.Timer then + self:StopTimer() + end + + self.Timer = XScheduleManager.ScheduleForever(function() + if XTool.UObjIsNil(self.TxtTime) then + self:StopTimer() + return + end + self:RefreshVoteTime() + self:RefreshActivityTime() + end, XScheduleManager.SECOND, 0) +end + +function XUiMoeWarMain:StopTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end + +function XUiMoeWarMain:RefreshVotePanel() + local match = XDataCenter.MoeWarManager.GetCurMatch() + if not match then return end + local desc = match:GetDesc() + local matchType = match:GetType() + local session = match:GetSessionId() + self.TxtVoteTitle.text = match:GetName() + if matchType == XMoeWarConfig.MatchType.Publicity and session == XMoeWarConfig.SessionType.Game3In1 then + self.Group01.gameObject:SetActiveEx(false) + self.Group02.gameObject:SetActiveEx(true) + local playerEntity = XDataCenter.MoeWarManager.GetPlayer(match:GetPairList()[1].WinnerId) + self.ImgVictoryHead:SetRawImage(playerEntity:GetCircleHead()) + self.TxtVictoryName.text = playerEntity:GetName() + else + self.Group01.gameObject:SetActiveEx(true) + self.Group02.gameObject:SetActiveEx(false) + self.TxtMatchState.text = desc[1] + self.TxtMatchDesc.text = desc[2] + self.ImgCover:SetRawImage(match:GetCoverImg()) + end +end + +function XUiMoeWarMain:RefreshVoteTime() + local match = XDataCenter.MoeWarManager.GetCurMatch() + if not match then return end + local endTime = match:GetEndTime() + local now = XTime.GetServerNowTimestamp() + local offset = endTime - now + if match:GetVoteEnd() and (not match:GetResultOut()) and match:GetType() == XMoeWarConfig.MatchType.Voting then + self.TxtVoteTime.text = CS.XTextManager.GetText("MoeWarMatchVoteNoResult") + else + self.TxtVoteTime.text = XUiHelper.GetTime(offset,XUiHelper.TimeFormatType.CHALLENGE) + end +end + +function XUiMoeWarMain:RefreshActivityTime() + local endTime = XDataCenter.MoeWarManager.GetActivityEndTime() + local now = XTime.GetServerNowTimestamp() + local offset = endTime - now + if offset <= 0 then + XLuaUiManager.RunMain() + XUiManager.TipText("MoeWarActivityOver") + self:StopTimer() + return + end + self.TxtTime.text = XUiHelper.GetTime(offset,XUiHelper.TimeFormatType.ACTIVITY) +end + +function XUiMoeWarMain:RefreshPreparation() + local preparationActivityId = XMoeWarConfig.GetPreparationActivityIdInTime() + local defaultPreparationActivityId = XMoeWarConfig.GetPreparationActivityIdInTime(true) + + --活动结束时,使用最后一个结束的活动id显示 + local matchIds = defaultPreparationActivityId and XMoeWarConfig.GetPreparationActivityMatchIds(defaultPreparationActivityId) or {} + for i = 1, MaxMatchCount do + if matchIds[i] then + local matchId = matchIds[i] + local numText = XMoeWarConfig.GetPreparationMatchNumText(matchId) + local matchState = XDataCenter.MoeWarManager.GetPreparationMatchOpenState(matchId) + local btnState + local lineState = ButtonStateNormal + if matchState == XMoeWarConfig.MatchState.Open then + btnState = ButtonStateSelect + elseif matchState == XMoeWarConfig.MatchState.Over then + btnState = ButtonStateDisable + lineState = ButtonStateDisable + else + btnState = ButtonStateNormal + end + self["GridProgress" .. i]:SetNameByGroup(0, numText) + self["GridProgress" .. i]:SetButtonState(btnState) + self["GridProgress" .. i].gameObject:SetActiveEx(true) + if self["Line" .. i] then + self["Line" .. i]:SetButtonState(lineState) + self["Line" .. i].gameObject:SetActiveEx(true) + end + else + self["GridProgress" .. i].gameObject:SetActiveEx(false) + if self["Line" .. i] then + self["Line" .. i].gameObject:SetActiveEx(false) + end + end + end + + if not preparationActivityId then + self.BtnPrepare:SetDisable(true, false) + self.PanelOver.gameObject:SetActiveEx(true) + self.PanelJd.gameObject:SetActiveEx(false) + return + end + + if self.BtnPrepare.ButtonState == ButtonStateDisable then + self.BtnPrepare:SetDisable(false) + end + + local maxStageCount = XMoeWarConfig.GetPreparationActivityMaxStageCount(preparationActivityId) + local currOpenStageCount = XDataCenter.MoeWarManager.GetPreparationAllOpenStageCount() + self.PrepareJdTxtNumber.text = currOpenStageCount .. "/" .. maxStageCount + self.PrepareJd.fillAmount = maxStageCount > 0 and currOpenStageCount / maxStageCount or 0 + self.PanelOver.gameObject:SetActiveEx(false) + self.PanelJd.gameObject:SetActiveEx(true) +end + +function XUiMoeWarMain:OnPrepareRedPointEvent(count) + self.BtnPrepare:ShowReddot(count >= 0) +end + +function XUiMoeWarMain:OnTaskRedPointEvent(count) + self.BtnTask:ShowReddot(count >= 0) +end + +function XUiMoeWarMain:OnGachaRedPointEvent(count) + self.BtnShop:ShowReddot(count >= 0) +end + +function XUiMoeWarMain:CheckRedPoint() + XRedPointManager.Check(self.BtnPrepareRedPointEventId) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMoeWar/XUiMoeWarMessage.lua b/Resources/Scripts/XUi/XUiMoeWar/XUiMoeWarMessage.lua new file mode 100644 index 00000000..4fc1d613 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMoeWar/XUiMoeWarMessage.lua @@ -0,0 +1,252 @@ +local ipairs = ipairs +local XUiMessageGridPlayer = require("XUi/XUiMoeWar/ChildItem/XUiMessageGridPlayer") +local XUiMessageGridAction = require("XUi/XUiMoeWar/ChildItem/XUiMessageGridAction") + +local XUiMoeWarMessage = XLuaUiManager.Register(XLuaUi, "UiMoeWarMessage") + +local CurrentActionSchedule +local CurrentCvInstance + +function XUiMoeWarMessage:OnAwake() + self:AutoAddListener() + self:InitDynamicTable() + + self.PlayerIds = {} + for _, v in ipairs(XMoeWarConfig.GetPlayers()) do + self.PlayerIds[#self.PlayerIds + 1] = v.Id + end + + self.ActionList = {} + self.ActionList[XMoeWarConfig.ActionType.Intro] = XUiMessageGridAction.New(self, self.GridActionIntro) + self.ActionList[XMoeWarConfig.ActionType.Thank] = XUiMessageGridAction.New(self, self.GridActionThank) + + self.ActInfo = XDataCenter.MoeWarManager.GetActivityInfo() + self.AssetActivityPanel = XUiPanelActivityAsset.New(self.PanelSpecialTool) + XDataCenter.ItemManager.AddCountUpdateListener(self.ActInfo.CurrencyId[1], function() + self.AssetActivityPanel:Refresh(self.ActInfo.CurrencyId) + end, self.AssetActivityPanel) + self.GridPlayer.gameObject:SetActiveEx(false) +end + +function XUiMoeWarMessage:OnStart() + self:InitSceneRoot() + self.AssetActivityPanel:Refresh(self.ActInfo.CurrencyId) + self.SelectPlayerId = 1 + self.SelectPlayer = XDataCenter.MoeWarManager.GetPlayer(self.SelectPlayerId) + self:UpdateCurrentPlayer() + self:UpdateActionGrid() + + self.DynamicTable:SetDataSource(self.PlayerIds) + self.DynamicTable:ReloadDataASync() + + self.LastMatchType = XDataCenter.MoeWarManager.GetCurMatch():GetType() +end + +function XUiMoeWarMessage:OnEnable() + self:CheckIsNeedPop() +end + +function XUiMoeWarMessage:OnDisable() + self:StopAction() +end + +function XUiMoeWarMessage:OnGetEvents() + return { XEventId.EVENT_MOE_WAR_UPDATE, + XEventId.EVENT_MOE_WAR_ACTIVITY_END} +end + +function XUiMoeWarMessage:OnNotify(evt, ...) + if evt == XEventId.EVENT_MOE_WAR_UPDATE then + self:CheckIsNeedPop() + elseif evt == XEventId.EVENT_MOE_WAR_ACTIVITY_END then + XDataCenter.MoeWarManager.OnActivityEnd() + end +end + +function XUiMoeWarMessage:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PlayerList) + self.DynamicTable:SetProxy(XUiMessageGridPlayer) + self.DynamicTable:SetDelegate(self) +end + +function XUiMoeWarMessage:InitSceneRoot() + local root = self.UiModelGo.transform + self.PanelRoleModel = root:FindTransform("PanelRoleModel") + self.ImgEffectHuanren = root:FindTransform("ImgEffectHuanren") + self.RoleModelPanel = XUiPanelRoleModel.New(self.PanelRoleModel, self.Name, nil, true, nil, true) +end + +function XUiMoeWarMessage:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:UpdateData(self.PlayerIds[index]) + + if self.SelectPlayerId == grid.Id then + grid:SetSelect(true) + self.LastSelectPlayerGrid = grid + else + grid:SetSelect(false) + end + + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + if self.SelectPlayerId == grid.Id then + return + end + + if self.LastSelectPlayerGrid then + self.LastSelectPlayerGrid:SetSelect(false) + end + + self:ResetAction(false) + self.LastSelectPlayerGrid = grid + grid:SetSelect(true) + + self.SelectPlayerId = grid.Id + self.SelectPlayer = XDataCenter.MoeWarManager.GetPlayer(self.SelectPlayerId) + self:UpdateCurrentPlayer() + self:UpdateActionGrid() + self:PlayAnimation("QieHuan") + end +end + +function XUiMoeWarMessage:UpdateCurrentPlayer() + self.TxtName.text = self.SelectPlayer:GetName() + self.TxtJob.text = self.SelectPlayer:GetJob() + self.RImgCareer:SetRawImage(self.SelectPlayer:GetCareerIcon()) + self.TxtCamp.text = self.SelectPlayer:GetCamp() + self.TxtDescription.text = self.SelectPlayer:GetDesc() + + self:UpdateCurrentPlayerModel(true) +end + +function XUiMoeWarMessage:UpdateActionGrid() + for i, v in pairs(self.ActionList) do + local actionData = { + HeadIcon = self.SelectPlayer:GetActionBg(), + ActionType = i + } + v:Refresh(actionData) + end +end + +function XUiMoeWarMessage:UpdateCurrentPlayerModel(isChangeChar) + self.ImgEffectHuanren.gameObject:SetActiveEx(false) + self.RoleModelPanel:UpdateRoleModel(self.SelectPlayer:GetModel(), self.PanelRoleModel, XModelManager.MODEL_UINAME.XUiMoeWarMessage, function(model) + self.ImgEffectHuanren.gameObject:SetActiveEx(isChangeChar) + self.PanelDrag.Target = model.transform + end, nil, true, true) +end + +function XUiMoeWarMessage:AutoAddListener() + self.BtnBack.CallBack = function() self:OnClickBtnBack() end + self.BtnMainUi.CallBack = function() self:OnClickBtnMainUi() end + self.BtnPanelDrag.CallBack = function() self:OnClickPlayer() end +end + +function XUiMoeWarMessage:OnClickBtnBack() + self:Close() +end + +function XUiMoeWarMessage:OnClickBtnMainUi() + XLuaUiManager.RunMain() +end + +function XUiMoeWarMessage:OnClickPlayer() + if self.CurrentPlayAction then + return + end + self:OnActionClick(self.ActionList[1].ActionData, self.ActionList[1]) +end + +function XUiMoeWarMessage:GetSelectPlayerId() + return self.PlayerIds[self.SelectPlayerId] +end + +-- 被XUiMessageGridAction调用 +function XUiMoeWarMessage:OnActionClick(actionData, grid) + if self.CurrentPlayAction then + local action = self.CurrentPlayAction + self:ResetAction(true) + if action.ActionType == actionData.ActionType then + return + end + end + --XDataCenter.FavorabilityManager.SetDontStopCvContent(true) + --停止正在播放的动作,准备播放新动作 + self.RoleModelPanel:PlayAnima(self.SelectPlayer:GetAnim(actionData.ActionType), true) + --CurrentCvInstance = XSoundManager.PlaySoundByType(self.SelectPlayer:GetCv(actionData.ActionType) ,XSoundManager.SoundType.CV) + --海外萌战由于语音不全所以屏蔽语音 + self.CurrentPlayAction = actionData + self.CurrentPlayAction.IsPlay = true + grid:UpdatePlayStatus(true) + local isFinish = false + local progress = 0 + local updateCount = 0 + local startTime = CS.UnityEngine.Time.realtimeSinceStartup + local duration = self.SelectPlayer:GetLength(actionData.ActionType) + + CurrentActionSchedule = XScheduleManager.ScheduleForever(function() + if self.CurrentPlayAction then + local time = CS.UnityEngine.Time.realtimeSinceStartup + progress = (time - startTime) / duration + if progress >= 1 then + progress = 1 + isFinish = true + end + --判断当前grid存放的数据是不是正在播放的数据 + if grid:GetActionType() == actionData.ActionType then + grid:UpdateProgress(progress) + grid:UpdateActionAlpha(updateCount) + end + updateCount = updateCount + 1 + end + if not self.CurrentPlayAction or isFinish then + actionData.IsPlay = false + if grid:GetActionType() == actionData.ActionType then + grid:UpdatePlayStatus(false) + grid:UpdateProgress(0) + end + --自然结束动作,不播放打断特效 + self:ResetAction(false) + end + end, 20) +end + +function XUiMoeWarMessage:ResetAction(isForce) + self.CurrentPlayAction = nil + self:StopAction(isForce) + + for _, v in pairs(self.ActionList) do + v:Refresh() + end + + --self:UpdateActionGrid() +end + +function XUiMoeWarMessage:StopAction(isForce) + if isForce then + self.RoleModelPanel:HideRoleModel() + self.RoleModelPanel:ShowRoleModel() + end + + if CurrentActionSchedule then + XScheduleManager.UnSchedule(CurrentActionSchedule) + end + + --[[if CurrentCvInstance then + CurrentCvInstance:Stop() + end--]] +end + +function XUiMoeWarMessage:CheckIsNeedPop() + local match = XDataCenter.MoeWarManager.GetCurMatch() + if match:GetType() == XMoeWarConfig.MatchType.Voting and self.LastMatchType == XMoeWarConfig.MatchType.Publicity then + XUiManager.TipText("MoeWarMatchEnd") + XLuaUiManager.Remove("XUiMoeWarVote") + self:Close() + return true + else + self.LastMatchType = match:GetType() + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMoeWar/XUiMoeWarPhotograph.lua b/Resources/Scripts/XUi/XUiMoeWar/XUiMoeWarPhotograph.lua new file mode 100644 index 00000000..845ef607 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMoeWar/XUiMoeWarPhotograph.lua @@ -0,0 +1,46 @@ +local XUiMoeWarPhotograph = XLuaUiManager.Register(XLuaUi,"UiMoeWarPhotograph") +local XUiPhotographSDKPanel = require("XUi/XUiPhotograph/XUiPhotographSDKPanel") + +function XUiMoeWarPhotograph:OnStart(playerId) + self.PlayerId = playerId + self.SDKPanel = XUiPhotographSDKPanel.New(self, self.PanelSDK) + local playerEntity = XDataCenter.MoeWarManager.GetPlayer(self.PlayerId) + self.RImgRoleIcon:SetRawImage(playerEntity:GetShareImage()) + self.TxtUserName.text = XPlayer.Name + self:Photograph() + self:RegisterButtonEvent() +end + +function XUiMoeWarPhotograph:OnDestroy() + XDataCenter.PhotographManager.ClearTextureCache() + CS.UnityEngine.Object.Destroy(self.ShareTexture) +end + +function XUiMoeWarPhotograph:RegisterButtonEvent() + self.BtnClose.CallBack = function() self:Close() end +end + +function XUiMoeWarPhotograph:ChangeState(state) + if state == XPhotographConfigs.PhotographViewState.Normal then + self.SDKPanel:Hide() + elseif state == XPhotographConfigs.PhotographViewState.Capture then + self.SDKPanel:Hide() + elseif state == XPhotographConfigs.PhotographViewState.SDK then + self.SDKPanel:Show() + end +end + +function XUiMoeWarPhotograph:Photograph() + self:PlayAnimation("Photo") + XCameraHelper.ScreenShotNew(self.ImagePhoto, self.CameraCupture, function(screenShot) + -- 把合成后的图片渲染到游戏UI中的照片展示(最终要分享的图片) + CsXUiManager.Instance:ChangeCanvasTypeCamera(CsXUiType.Normal, CS.XUiManager.Instance.UiCamera) + self.ShareTexture = screenShot + self.PhotoName = "[" .. tostring(XPlayer.Id) .. "]" .. XTime.GetServerNowTimestamp() + end, function() + CsXUiManager.Instance:ChangeCanvasTypeCamera(CsXUiType.Normal, self.CameraCupture) + end) + XDataCenter.MoeWarManager.RequestShare(self.PlayerId) +end + +return XUiMoeWarPhotograph \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMoeWar/XUiMoeWarPollTips.lua b/Resources/Scripts/XUi/XUiMoeWar/XUiMoeWarPollTips.lua new file mode 100644 index 00000000..0e6a9b3a --- /dev/null +++ b/Resources/Scripts/XUi/XUiMoeWar/XUiMoeWarPollTips.lua @@ -0,0 +1,49 @@ +local XUiMoeWarPollTips = XLuaUiManager.Register(XLuaUi,"UiMoeWarPollTips") +local XUiGridVoteItem = require("XUi/XUiMoeWar/ChildItem/XUiGridVoteItem") + +function XUiMoeWarPollTips:OnStart(playerId) + self.PlayerId = playerId + self:InitVoteItemList() + self:RegisterButtonEvent() + if self.TxtName then + self.TxtName.text = CS.XTextManager.GetText("MoeWarSupportTitle",XDataCenter.MoeWarManager.GetPlayer(self.PlayerId):GetName()) + end + if self.TxtNumber then + local match = XDataCenter.MoeWarManager.GetCurMatch() + local dailyLimitCount = match:GetDailyLimitCount() + local currCount = XDataCenter.MoeWarManager.GetDailyVoteCount() + self.TxtNumber.text = string.format("%s/%s",currCount,dailyLimitCount) + end +end + +function XUiMoeWarPollTips:RegisterButtonEvent() + self.BtnClose.CallBack = function() XLuaUiManager.Close("UiMoeWarPollTips") end + self.BtnTanchuangClose.CallBack = function() XLuaUiManager.Close("UiMoeWarPollTips") end +end + +function XUiMoeWarPollTips:InitVoteItemList() + self.VoteItemDic = {} + local voteItems = XMoeWarConfig.GetVoteItems() + for i = 1, #voteItems do + local obj = CS.UnityEngine.GameObject.Instantiate(self.GridCore,self.PanelContent) + local grid = XUiGridVoteItem.New(obj,self.PlayerId,i,function(voteId) self:OnGridValueChanged(voteId) end,function(voteNumber) self:OnVoteSuccess(voteNumber,self.PlayerId) end,self) + self.VoteItemDic[i] = grid + end + self.GridCore.gameObject:SetActiveEx(false) +end + +function XUiMoeWarPollTips:OnVoteSuccess(voteNumber,playerId) + XLuaUiManager.Close("UiMoeWarPollTips") + XLuaUiManager.Open("UiMoeWarSupportTips",voteNumber,playerId) + CS.XGameEventManager.Instance:Notify(XEventId.EVENT_MOE_WAR_VOTE_PANEL_UPDATE) +end + +function XUiMoeWarPollTips:OnGridValueChanged(voteId) + for id,grid in pairs(self.VoteItemDic) do + if id ~= voteId then + grid:SetVoteNumber(0) + end + end +end + +return XUiMoeWarPollTips \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMoeWar/XUiMoeWarRankingList.lua b/Resources/Scripts/XUi/XUiMoeWar/XUiMoeWarRankingList.lua new file mode 100644 index 00000000..47b5b469 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMoeWar/XUiMoeWarRankingList.lua @@ -0,0 +1,226 @@ +local XUiMoeWarRankingList = XLuaUiManager.Register(XLuaUi, "UiMoeWarRankingList") + +local XUiGridRank = require("XUi/XUiMoeWar/ChildItem/XUiGridRank") +local XUiPanelMyRank = require("XUi/XUiMoeWar/SubPage/XUiPanelMyRank") +local DEFAULT_TOG_INDEX = 1 +local MAX_RANK_COUNT = 99 + +function XUiMoeWarRankingList:OnAwake() + self:AddListener() + self.ActInfo = XDataCenter.MoeWarManager.GetActivityInfo() + + self.AssetActivityPanel = XUiPanelActivityAsset.New(self.PanelSpecialTool) + XDataCenter.ItemManager.AddCountUpdateListener(self.ActInfo.CurrencyId[1], function() + self.AssetActivityPanel:Refresh(self.ActInfo.CurrencyId) + end, self.AssetActivityPanel) + + XDataCenter.MoeWarManager.ClearCache() + self.GridRank.gameObject:SetActiveEx(false) +end + +function XUiMoeWarRankingList:OnStart() + self.BtnGoList = {} + self.RankingListTables = {} + self.tagCount = 1 + self.TabGroup = {} + + self.BtnFirst.gameObject:SetActiveEx(false) + self.BtnSecond.gameObject:SetActiveEx(false) + + self.DynamicTable = XDynamicTableNormal.New(self.PanelRankingList) + self.DynamicTable:SetProxy(XUiGridRank) + self.DynamicTable:SetDelegate(self) + + self.MyRank = XUiPanelMyRank.New(self, self.PanelMyRank) + + self:UpdateTog() + self.AssetActivityPanel:Refresh(self.ActInfo.CurrencyId) + + self.LastMatchType = XDataCenter.MoeWarManager.GetCurMatch():GetType() +end + +function XUiMoeWarRankingList:OnEnable() + self:CheckIsNeedPop() +end + +function XUiMoeWarRankingList:AddListener() + self.BtnBack.CallBack = function() + self:OnBtnBackClick() + end + self.BtnMainUi.CallBack = function() + self:OnBtnMainUiClick() + end +end + +function XUiMoeWarRankingList:OnGetEvents() + return { XEventId.EVENT_MOE_WAR_UPDATE, + XEventId.EVENT_MOE_WAR_ACTIVITY_END} +end + +function XUiMoeWarRankingList:OnNotify(evt, ...) + if evt == XEventId.EVENT_MOE_WAR_UPDATE then + self:CheckIsNeedPop() + elseif evt == XEventId.EVENT_MOE_WAR_ACTIVITY_END then + XDataCenter.MoeWarManager.OnActivityEnd() + end +end + +function XUiMoeWarRankingList:OnBtnBackClick() + self:Close() +end + +function XUiMoeWarRankingList:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiMoeWarRankingList:OnDestroy() + +end + +function XUiMoeWarRankingList:UpdateTog() + local infoList = XDataCenter.MoeWarManager.GetRankTabList() + local selectIndex = DEFAULT_TOG_INDEX + local SubGroupIndexMemo = 0 + + for i = 1, #self.BtnGoList do + self.BtnGoList[i].gameObject:SetActiveEx(false) + end + + for index, info in pairs(infoList) do + local btn = self.BtnGoList[self.tagCount] + if self.TabGroup[info.RankType] then + if self.TabGroup[info.RankType][index] then + btn = self.BtnGoList[self.TabGroup[info.RankType] [index]] + end + end + + if not btn then + local name + local SubGroupIndex + + if info.IsSub then + if info.SecondTagType == XMoeWarConfig.SubTagType.Top then + btn = CS.UnityEngine.Object.Instantiate(self.BtnSecondTop) + elseif info.SecondTagType == XMoeWarConfig.SubTagType.Mid then + btn = CS.UnityEngine.Object.Instantiate(self.BtnSecond) + elseif info.SecondTagType == XMoeWarConfig.SubTagType.Btm then + btn = CS.UnityEngine.Object.Instantiate(self.BtnSecondBottom) + else + btn = CS.UnityEngine.Object.Instantiate(self.BtnSecondAll) + end + + SubGroupIndex = SubGroupIndexMemo + else + if info.HasSub then + btn = CS.UnityEngine.Object.Instantiate(self.BtnFirstHasSnd) + else + btn = CS.UnityEngine.Object.Instantiate(self.BtnFirst) + end + SubGroupIndexMemo = self.tagCount + SubGroupIndex = 0 + end + + name = info.TagName + + if btn then + if not self.TabGroup[info.RankType] then + self.TabGroup[info.RankType] = {} + end + table.insert(self.TabGroup[info.RankType], self.tagCount) + self.tagCount = self.tagCount + 1 + + table.insert(self.RankingListTables, info) + + btn.transform:SetParent(self.TabBtnContent, false) + local uiButton = btn:GetComponent("XUiButton") + uiButton.SubGroupIndex = SubGroupIndex + uiButton:SetName(name) + table.insert(self.BtnGoList, uiButton) + btn.gameObject.name = info.Id + end + end + + btn.gameObject:SetActiveEx(true) + --selectIndex = self.TabGroup[info.RankType][index] + end + + if #infoList <= 0 then + return + end + + self.TabBtnGroup:Init(self.BtnGoList, function(index) self:SwitchTab(index) end) + self.TabBtnGroup:SelectIndex(selectIndex, false) + self:SwitchTab(selectIndex, true) +end + +function XUiMoeWarRankingList:SetTitleName(rankType, playerId) + local cfg = XMoeWarConfig.GetRankGroupByType(rankType) + local player = XDataCenter.MoeWarManager.GetPlayer(playerId) + self.TxtTitle.text = string.format(cfg.Title, player and player:GetName() or nil) + self.TxtResetTip.text = cfg.ResetTip +end + +function XUiMoeWarRankingList:ShowRank(isFromOtherUi) + XDataCenter.MoeWarManager.RequestRank(self.CurTabInfo.RankType, self.CurTabInfo.PlayerId or 0, function(rankData) + self.RankData = rankData + self:UpdateRankList(isFromOtherUi) + end) +end + +--显示排行详情 +function XUiMoeWarRankingList:SwitchTab(index, isFromOtherUi) + if self.CurSelectIndex ~= index then + self.CurTabInfo = self.RankingListTables[index] + self:ShowRank(isFromOtherUi) + self.CurSelectIndex = index + end +end + +function XUiMoeWarRankingList:HidePanel() + if not XTool.UObjIsNil(self.GameObject) then + self.GameObject:SetActiveEx(false) + end +end + +--动态列表事件 +function XUiMoeWarRankingList:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.RankData.RankingList[index] + grid:Refresh(data, self.CurTabInfo.RankType) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_RECYCLE then + --grid:OnRecycle() + end +end + +function XUiMoeWarRankingList:UpdateRankList(isFromOtherUi) + if not isFromOtherUi then + self:PlayAnimation("QieHuan") + end + --XLog.Warning(self.RankData) + local count = self.RankData.RankingList and #self.RankData.RankingList or 0 + self.DynamicTable:SetDataSource(self.RankData.RankingList) + self.DynamicTable:ReloadDataASync() + + self.PanelRankingList.gameObject:SetActiveEx(count > 0) + self.PanelMyRank.gameObject:SetActiveEx(count > 0) + if count > 0 then + self.MyRank:Refresh(self.RankData.UserRank, self.CurTabInfo.RankType) + end + self.PanelNoRank.gameObject:SetActiveEx(count <= 0) + self:SetTitleName(self.CurTabInfo.RankType, self.CurTabInfo.PlayerId) +end + + +function XUiMoeWarRankingList:CheckIsNeedPop() + local match = XDataCenter.MoeWarManager.GetCurMatch() + if match:GetType() == XMoeWarConfig.MatchType.Voting and self.LastMatchType == XMoeWarConfig.MatchType.Publicity then + XUiManager.TipText("MoeWarMatchEnd") + XLuaUiManager.Remove("XUiMoeWarVote") + self:Close() + return true + else + self.LastMatchType = match:GetType() + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMoeWar/XUiMoeWarSchedule.lua b/Resources/Scripts/XUi/XUiMoeWar/XUiMoeWarSchedule.lua new file mode 100644 index 00000000..2d9ebe87 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMoeWar/XUiMoeWarSchedule.lua @@ -0,0 +1,259 @@ +local XUiMoeWarSchedule = XLuaUiManager.Register(XLuaUi, "UiMoeWarSchedule") + +local XUiPanelMatchLarge = require("XUi/XUiMoeWar/SubPage/XUiPanelMatchLarge") +local XUiPanelMatchSmall = require("XUi/XUiMoeWar/SubPage/XUiPanelMatchSmall") +local XUiPanelMatchFinal = require("XUi/XUiMoeWar/SubPage/XUiPanelMatchFinal") + +local CSXTextManagerGetText = CS.XTextManager.GetText + +local MAX_MODEL_COUNT = 3 + +function XUiMoeWarSchedule:OnAwake() + self.BtnList = {self.BtnGame24In12, self.BtnGame12In6, self.BtnGame6In3, self.BtnGame3In1} + self.PanelList = {self.PanelGame24In12, self.PanelGame12In6, self.PanelGame6In3, self.PanelGame3In1} + self.ObjList = {} + self.SessionList = XDataCenter.MoeWarManager.GetSessionList() + self.ActInfo = XDataCenter.MoeWarManager.GetActivityInfo() + self.IsPlayAnim = false + + self:InitUiView() + self:InitSceneRoot() + + for i, match in ipairs(self.SessionList) do + if not match:GetNotOpen() then + self.CurrentView = i + end + end + self.CurrentView = self.CurrentView or 1 + self.BtnGrpMatch:Init(self.BtnList ,function(index) self:SwitchTab(index) end) + self:UpdateBtnGrpMatch() + self.BtnGrpMatch:SelectIndex(self.CurrentView, false) +end + +function XUiMoeWarSchedule:OnEnable() + if not self:CheckIsNeedPop() then + self:AddTimer() + self:Refresh() + end +end + +function XUiMoeWarSchedule:OnStart(selectGroup) + self.LastMatchType = XDataCenter.MoeWarManager.GetCurMatch():GetType() + self.AssetActivityPanel:Refresh(self.ActInfo.CurrencyId) + self:Refresh(true, selectGroup) +end + +function XUiMoeWarSchedule:OnGetEvents() + return { XEventId.EVENT_MOE_WAR_UPDATE, + XEventId.EVENT_MOE_WAR_ACTIVITY_END} +end + +function XUiMoeWarSchedule:OnNotify(evt, ...) + if evt == XEventId.EVENT_MOE_WAR_UPDATE then + if not self:CheckIsNeedPop() then + self:Refresh(true) + end + elseif evt == XEventId.EVENT_MOE_WAR_ACTIVITY_END then + XDataCenter.MoeWarManager.OnActivityEnd() + end +end + +function XUiMoeWarSchedule:OnDisable() + self:RemoveTimer() +end + +function XUiMoeWarSchedule:InitUiView() + self.AssetActivityPanel = XUiPanelActivityAsset.New(self.PanelSpecialTool) + + XDataCenter.ItemManager.AddCountUpdateListener(self.ActInfo.CurrencyId[1], function() + self.AssetActivityPanel:Refresh(self.ActInfo.CurrencyId) + end, self.AssetActivityPanel) + + self.TxtBtnGrpMatchLock = {} + self.TxtBtnGrpMatchNow = {} + self.TxtBtnGrpMatchEnd = {} + + for i, v in ipairs(self.BtnList) do + local match = XDataCenter.MoeWarManager.GetMatch(i) + v:SetNameByGroup(0, match:GetName()) + v:SetNameByGroup(1, match:GetSubName()) + self.TxtBtnGrpMatchLock[i] = v.transform:Find("TagLock/Text"):GetComponent("Text") + self.TxtBtnGrpMatchNow[i] = v.transform:Find("TagNow/Text"):GetComponent("Text") + self.TxtBtnGrpMatchEnd[i] = v.transform:Find("TagEnd/Text"):GetComponent("Text") + end + + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + self:BindHelpBtn(self.BtnHelp, "MoeWar") +end + +function XUiMoeWarSchedule:InitSceneRoot() + local root = self.UiModelGo.transform + self.SmallMatchPanelModel = {} + self.SmallMatchImgEffect = {} + self.SmallMatchPanelModel[1] = root:FindTransform("PanelModelCase1") + --self.SmallMatchImgEffect[1] = root:FindTransform("ImgEffectHuanren1") + self.SmallMatchPanelModel[2] = root:FindTransform("PanelModelCase2") + --self.SmallMatchImgEffect[2] = root:FindTransform("ImgEffectHuanren2") + self.SmallMatchPanelModel[3] = root:FindTransform("PanelModelCase3") + --self.SmallMatchImgEffect[3] = root:FindTransform("ImgEffectHuanren3") + self.FinalMatchPanelModel = root:FindTransform("PanelModelCase4") + --self.FinalMatchImgEffect = root:FindTransform("ImgEffectHuanren4") +end + +function XUiMoeWarSchedule:SwitchTab(index, isFromOtherUi) + if self.CurrentView == index then + return + elseif XDataCenter.MoeWarManager.GetMatch(index):GetNotOpen() then + local startTime = XDataCenter.MoeWarManager.GetVoteMatch(index):GetStartTime() + XUiManager.TipMsg(XUiHelper.GetInTimeDesc(startTime)) + return + else + if not isFromOtherUi then + self:PlayAnimation("QieHuan1") + end + self.CurrentView = index + self:Refresh() + end +end + +function XUiMoeWarSchedule:Refresh(isForce, selectGroup) + -- 刷新右侧内容 + if not self.ObjList[self.CurrentView] then + local curPanel = self.PanelList[self.CurrentView] + if self.CurrentView == XMoeWarConfig.SessionType.Game24In12 + or self.CurrentView == XMoeWarConfig.SessionType.Game12In6 then + self.ObjList[self.CurrentView] = XUiPanelMatchLarge.New(self, curPanel, self.CurrentView) + elseif self.CurrentView == XMoeWarConfig.SessionType.Game6In3 then + self.SmallMatchRolePanel = {} + for i = 1, MAX_MODEL_COUNT do + self.SmallMatchRolePanel[i] = XUiPanelRoleModel.New(self.SmallMatchPanelModel[i], self.Name, nil, true, nil, true) + end + self.ObjList[self.CurrentView] = XUiPanelMatchSmall.New(self, curPanel, self.CurrentView, function(pos, player) + self:UpdateModel(pos, player) + end) + elseif self.CurrentView == XMoeWarConfig.SessionType.Game3In1 then + self.FinalMatchRolePanel = XUiPanelRoleModel.New(self.FinalMatchPanelModel, self.Name, nil, true, nil, true) + self.ObjList[self.CurrentView] = XUiPanelMatchFinal.New(self, curPanel, self.CurrentView, function(pos, player) + self:UpdateModel(pos, player) + end) + end + end + + for i, panel in ipairs(self.PanelList) do + panel.gameObject:SetActiveEx(i == self.CurrentView) + end + + if self.CurrentView == XMoeWarConfig.SessionType.Game6In3 then + for i = 1, MAX_MODEL_COUNT do + self.SmallMatchRolePanel[i]:ShowRoleModel() + end + CS.XShadowHelper.SetGlobalShadowMeshHeight(0.52) + elseif self.ObjList[XMoeWarConfig.SessionType.Game6In3] then + for i = 1, MAX_MODEL_COUNT do + self.SmallMatchRolePanel[i]:HideRoleModel() + end + end + + if self.ObjList[XMoeWarConfig.SessionType.Game3In1] then + if self.CurrentView == XMoeWarConfig.SessionType.Game3In1 then + self.FinalMatchRolePanel:ShowRoleModel() + CS.XShadowHelper.SetGlobalShadowMeshHeight(0.63) + else + self.FinalMatchRolePanel:HideRoleModel() + end + end + + self.ObjList[self.CurrentView]:Refresh(isForce, selectGroup) +end + +function XUiMoeWarSchedule:AddTimer() + self.Timer = XScheduleManager.ScheduleForever(function() self:UpdateBtnGrpMatch() end, XScheduleManager.SECOND) +end + +function XUiMoeWarSchedule:RemoveTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end + +-- 刷新左侧时间 +function XUiMoeWarSchedule:UpdateBtnGrpMatch() + for i, v in ipairs(self.BtnList) do + local txtLock = self.TxtBtnGrpMatchLock[i] + local txtNow = self.TxtBtnGrpMatchNow[i] + local txtEnd = self.TxtBtnGrpMatchEnd[i] + local match = XDataCenter.MoeWarManager.GetVoteMatch(i) + local now = XTime.GetServerNowTimestamp() + local curBtnState = v.ButtonState:GetHashCode() ~= XUiButtonState.Disable + local nextBtnState = curBtnState + if match:GetNotOpen() then + nextBtnState = false + local openTimeStr = XUiHelper.GetTime(match:GetStartTime() - now, XUiHelper.TimeFormatType.MOE_WAR) + txtLock.text = CSXTextManagerGetText("MoeWarScheOpenCountdown", openTimeStr) + elseif match:GetInTime() then + nextBtnState = true + local remainTimeStr = XUiHelper.GetTime(match:GetEndTime() - now, XUiHelper.TimeFormatType.MOE_WAR) + txtNow.text = CSXTextManagerGetText("MoeWarScheCloseCountdown", remainTimeStr) + else + nextBtnState = true + txtEnd.text = CSXTextManagerGetText("MoeWarScheIsEnd") + end + if curBtnState ~= nextBtnState then + v:SetButtonState(nextBtnState and XUiButtonState.Normal or XUiButtonState.Disable) + end + v:ShowTag(match:GetInTime()) + txtLock.gameObject:SetActiveEx(match:GetNotOpen()) + txtEnd.transform.parent.gameObject:SetActiveEx(match:GetIsEnd()) + end + +end + + +function XUiMoeWarSchedule:UpdateModel(pos, player) + local modelPanel--, effect + if pos then + --effect =self.SmallMatchPanelModel[pos] + modelPanel = self.SmallMatchRolePanel[pos] + else + --effect = self.FinalMatchImgEffect + modelPanel = self.FinalMatchRolePanel + end + + --effect.gameObject:SetActiveEx(false) + if not player then + return + end + + modelPanel:UpdateRoleModel(player:GetModel(), nil, XModelManager.MODEL_UINAME.XUiMoeWarSchedule, function(model) + --effect.gameObject:SetActiveEx(true) + end, nil, true, true) + + if not self.IsPlayAnim then + XScheduleManager.ScheduleOnce(function() + modelPanel:PlayAnima(player:GetAnim(XMoeWarConfig.ActionType.Thank), true) + self.IsPlayAnim = true + end, 500) + end +end + +function XUiMoeWarSchedule:OnBtnBackClick() + self:Close() +end + +function XUiMoeWarSchedule:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiMoeWarSchedule:CheckIsNeedPop() + local match = XDataCenter.MoeWarManager.GetCurMatch() + if match:GetType() == XMoeWarConfig.MatchType.Voting and self.LastMatchType == XMoeWarConfig.MatchType.Publicity then + XUiManager.TipText("MoeWarMatchEnd") + XLuaUiManager.Remove("XUiMoeWarVote") + self:Close() + return true + else + self.LastMatchType = match:GetType() + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMoeWar/XUiMoeWarShop.lua b/Resources/Scripts/XUi/XUiMoeWar/XUiMoeWarShop.lua new file mode 100644 index 00000000..d9443b4c --- /dev/null +++ b/Resources/Scripts/XUi/XUiMoeWar/XUiMoeWarShop.lua @@ -0,0 +1,255 @@ +local CSXTextManagerGetText = CS.XTextManager.GetText +local ShopHintText = CS.XTextManager.GetText("ActivityNierShopLock") +local XUiMoeWarShop = XLuaUiManager.Register(XLuaUi, "UiMoeWarShop") +local Dropdown = CS.UnityEngine.UI.Dropdown + + +function XUiMoeWarShop:OnAwake() + self.GridShop.gameObject:SetActiveEx(false) + self.TxtTime.gameObject:SetActiveEx(false) + self.HintTxt.gameObject:SetActiveEx(false) + self.AssetActivityPanel = XUiPanelActivityAsset.New(self.PanelActivityAsset, true) + self:InitDynamicTable() + self:InitPanels() +end + +function XUiMoeWarShop:OnStart() + + self.IsCanCheckLock = false + self.ShopIdList = XDataCenter.MoeWarManager.GetActivityShopIds() + self.ShopItemTextColor = {} + self.ShopItemTextColor.CanBuyColor = CS.XGame.ClientConfig:GetString("NierShopItemTextCanBuyColor") + self.ShopItemTextColor.CanNotBuyColor = CS.XGame.ClientConfig:GetString("NierShopItemTextCanNotBuyColor") + + --self.TextName.text = CS.XTextManager.GetText("NieRShopNameStr") + XShopManager.GetShopInfoList(self.ShopIdList, function() + self.IsCanCheckLock = true + self:CheckShopLock() + self:InitShopButton() + self:SetButtonLock() + end, XShopManager.ActivityShopType.MoeWarShop) +end + +function XUiMoeWarShop:OnEnable() + + if self.IsCanCheckLock then + self:CheckShopLock() + self:SetButtonLock() + self:RefreshBuy() + end + self.FromEnable = true + self.EffectRefresh.gameObject:SetActiveEx(false) +end + +function XUiMoeWarShop:InitShopButton() + local shopBtns = { + self.BtnTong1, + self.BtnTong2, + self.BtnTong3, + self.BtnTong4, + } + self.CurIndex = 1 + self.ShopBtn = shopBtns + + local btnNum = #self.ShopIdList + for index, shopBtn in pairs(shopBtns) do + if index <= btnNum then + shopBtn.gameObject:SetActiveEx(true) + shopBtn:SetButtonState(CS.UiButtonState.Normal) + --shopBtn:SetNameByGroup(0, XDataCenter.NieRManager.GetActivityShopBtnNameById(self.ShopIdList[index])) + else + shopBtn.gameObject:SetActiveEx(false) + end + + end + + self.FromInit = true + self.BtnTab:Init(shopBtns, function(index) + if not self.FromEnable then + self.EffectRefresh.gameObject:SetActiveEx(false) + else + self.FromEnable = nil + end + + if not self.FromInit and not self.FromEnable then + self.EffectRefresh.gameObject:SetActiveEx(true) + else + self.FromInit = nil + end + if index > btnNum then + return + end + self:SelectShop(index) + end) + self.BtnTab:SelectIndex(self.CurIndex) +end + +function XUiMoeWarShop:CheckShopLock() + self.IsShopLock = {} + self.ShopLockDecs = {} + for k, v in pairs(self.ShopIdList) do + local conditions = XShopManager.GetShopConditionIdList(v) + self.IsShopLock[k] = false + self.ShopLockDecs[k] = "" + for _, condition in pairs(conditions or {}) do + if condition ~= 0 then + self.IsShopLock[k], self.ShopLockDecs[k] = XConditionManager.CheckCondition(condition) + self.IsShopLock[k] = not self.IsShopLock[k] + if self.IsShopLock[k] then + break + end + end + end + end +end + +function XUiMoeWarShop:SetButtonLock() + for k, v in pairs(self.ShopBtn or {}) do + v:ShowTag(self.IsShopLock[k]) + end +end + +function XUiMoeWarShop:InitPanels() + self.ImgEmpty.gameObject:SetActiveEx(true) + self.AssetActivityPanel.GameObject:SetActiveEx(false) + self.BtnBack.CallBack = function() + self:Close() + end + + self.BtnScreenWords.onValueChanged:AddListener(function() + -- self.SelectBtnScreenWordsCaptionText = + self:UpdateDynamicTable() + end) +end + +function XUiMoeWarShop:UpdatePanels() + local shopId = self.ShopIdList[self.CurIndex] + local shopGoods = XShopManager.GetShopGoodsList(shopId) + local isEmpty = not next(shopGoods or {}) + self.ImgEmpty.gameObject:SetActiveEx(isEmpty) + self.AssetActivityPanel.GameObject:SetActiveEx(not isEmpty) + + + local shopTimeInfo = XShopManager.GetShopTimeInfo(shopId) + local leftTime = shopTimeInfo.ClosedLeftTime + if leftTime and leftTime > 0 then + local timeStr = XUiHelper.GetTime(leftTime, XUiHelper.TimeFormatType.ACTIVITY) + self.TxtTime.text = CSXTextManagerGetText("ActivityNierShopLeftTime", timeStr) + self.TxtTime.gameObject:SetActiveEx(true) + else + self.TxtTime.gameObject:SetActiveEx(false) + end +end + +function XUiMoeWarShop:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelItemList) + self.DynamicTable:SetProxy(XUiGridShop) + self.DynamicTable:SetDelegate(self) +end + +function XUiMoeWarShop:UpdateDynamicTable() + local shopId = self.ShopIdList[self.CurIndex] + local shopGoods + if self:IsShowDropdown() then + shopGoods = XShopManager.GetScreenGoodsListByTag(self:GetCurShopId(), self.ScreenGroupIDList[1], self.BtnScreenWords.captionText.text) + else + shopGoods = XShopManager.GetShopGoodsList(shopId) + end + + self.ShopGoods = shopGoods + self.DynamicTable:SetDataSource(shopGoods) + self.DynamicTable:ReloadDataASync() +end + +function XUiMoeWarShop:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.ShopGoods[index] + self:SetShopItemLock(grid) + --self:SetShopItemBg(grid) + grid:UpdateData(data, self.ShopItemTextColor) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_RECYCLE then + grid:OnRecycle() + end +end + +function XUiMoeWarShop:InitDropdown() + local shopId = self:GetCurShopId() + self.ScreenGroupIDList = XShopManager.GetShopScreenGroupIDList(shopId) + + if self:IsShowDropdown() then + self.BtnScreenWords.gameObject:SetActiveEx(true) + + local screenTagList = XShopManager.GetScreenTagListById(shopId, self.ScreenGroupIDList[1]) + self.BtnScreenWords:ClearOptions() + self.BtnScreenWords.captionText.text = CSXTextManagerGetText("ScreenAll") + for _, v in pairs(screenTagList or {}) do + local op = Dropdown.OptionData() + op.text = v.Text + self.BtnScreenWords.options:Add(op) + end + self.BtnScreenWords.value = 0 + else + self.BtnScreenWords.gameObject:SetActiveEx(false) + end +end + +function XUiMoeWarShop:IsShowDropdown() + if self.ScreenGroupIDList and next(self.ScreenGroupIDList) then + return true + else + return false + end +end + +function XUiMoeWarShop:UpdateBuy(data, cb) + XLuaUiManager.Open("UiShopItem", self, data, cb) + self:PlayAnimation("ShopItemEnable") +end + +function XUiMoeWarShop:GetCurShopId() + return self.ShopIdList[self.CurIndex] +end + +function XUiMoeWarShop:RefreshBuy() + local shopId = self:GetCurShopId() + self.AssetActivityPanel:Refresh(XShopManager.GetShopShowIdList(shopId)) + self:UpdateDynamicTable() +end + +function XUiMoeWarShop:SetShopItemBg(grid) + local shopId = self:GetCurShopId() + local bg = XDataCenter.NieRManager.GetActivityShopItemBgById(shopId) + if grid.ItemBg and bg then + grid.ItemBg:SetRawImage(bg) + end +end + +function XUiMoeWarShop:SetShopItemLock(grid) + grid.IsShopLock = self.IsShopLock[self.CurIndex] + grid.ShopLockDecs = ShopHintText + if grid.ImgLock then + grid.ImgLock.gameObject:SetActiveEx(self.IsShopLock[self.CurIndex]) + end +end + +function XUiMoeWarShop:SelectShop(index) + self.CurIndex = index + local shopId = self:GetCurShopId() + self:PlayAnimation("AnimQieHuan") + self.HintTxt.gameObject:SetActiveEx(self.IsShopLock[self.CurIndex]) + self.HintTxt.text = self.ShopLockDecs[self.CurIndex] + + --local bg = XDataCenter.NieRManager.GetActivityShopBgById(shopId) + --self.RImgBg:SetRawImage(bg) + -- + --local icon = XDataCenter.NieRManager.GetActivityShopIconById(shopId) + --self.RImgShopIcon:SetRawImage(icon) + + XShopManager.GetShopInfoList(self.ShopIdList, function() + self:UpdatePanels() + self:RefreshBuy() + self:InitDropdown() + end, XShopManager.ActivityShopType.MoeWarShop) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMoeWar/XUiMoeWarSupportTips.lua b/Resources/Scripts/XUi/XUiMoeWar/XUiMoeWarSupportTips.lua new file mode 100644 index 00000000..bfc9577a --- /dev/null +++ b/Resources/Scripts/XUi/XUiMoeWar/XUiMoeWarSupportTips.lua @@ -0,0 +1,38 @@ +local XUiMoeWarSupportTips = XLuaUiManager.Register(XLuaUi,"UiMoeWarSupportTips") + +function XUiMoeWarSupportTips:OnStart(voteCount,playerId) + self.PlayerId = playerId + self.VoteCount = voteCount + self:InitUiView() + self:RegisterButtonEvent() +end + +function XUiMoeWarSupportTips:InitUiView() + local playerEntity = XDataCenter.MoeWarManager.GetPlayer(self.PlayerId) + self.TxtAllNumber.text = playerEntity:GetMySupportCount(XDataCenter.MoeWarManager.GetCurMatch():GetSessionId()) + self.TxtOnceNumber.text = self.VoteCount + self.TxtTalk.text = CS.XTextManager.GetText("MoeWarSupportSuccess",playerEntity:GetName()) + self.RImgRoleIcon:SetRawImage(playerEntity:GetBigCharacterImage()) + if self.ImgAllIcon then + self.ImgAllIcon:SetRawImage(CS.XGame.ClientConfig:GetString("MoeWarScheduleSupportIcon")) + self.ImgOnceIcon:SetRawImage(CS.XGame.ClientConfig:GetString("MoeWarScheduleSupportIcon")) + end +end + +function XUiMoeWarSupportTips:OnClickBtnShare() + XDataCenter.MoeWarManager.RequestShare(self.PlayerId,function() + XLuaUiManager.Open("UiMoeWarPhotograph", self.PlayerId) + end) +end + +function XUiMoeWarSupportTips:OnClickBtnSure() + CS.XGameEventManager.Instance:Notify(XEventId.EVENT_MOE_WAR_PLAY_THANK_ANIMATION,self.PlayerId) + XLuaUiManager.Close("UiMoeWarSupportTips") +end + +function XUiMoeWarSupportTips:RegisterButtonEvent() + self.BtnConfirm.CallBack = function() self:OnClickBtnSure() end + self.BtnShare.CallBack = function() self:OnClickBtnShare() end +end + +return XUiMoeWarSupportTips \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMoeWar/XUiMoeWarTask.lua b/Resources/Scripts/XUi/XUiMoeWar/XUiMoeWarTask.lua new file mode 100644 index 00000000..e69edb82 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMoeWar/XUiMoeWarTask.lua @@ -0,0 +1,124 @@ +local XUiMoeWarTask = XLuaUiManager.Register(XLuaUi,"UiMoeWarTask") + +function XUiMoeWarTask:OnStart(defaultIndex) + self.SelectIndex = defaultIndex or 1 + self:InitUi() +end + +function XUiMoeWarTask:OnEnable() + +end + +function XUiMoeWarTask:OnGetEvents() + return { + XEventId.EVENT_FINISH_TASK, + XEventId.EVENT_TASK_SYNC, + XEventId.EVENT_MOE_WAR_ACTIVITY_END, + } +end + +function XUiMoeWarTask:OnNotify(event,...) + if event == XEventId.EVENT_FINISH_TASK + or event == XEventId.EVENT_TASK_SYNC then + self:RefreshTaskPanel() + elseif event == XEventId.EVENT_MOE_WAR_ACTIVITY_END then + XUiManager.TipText("MoeWarActivityOver") + XLuaUiManager.RunMain() + end +end + +function XUiMoeWarTask:RefreshTaskPanel() + for i = 1,#self.TaskDic do + self.TaskDic[i] = XDataCenter.MoeWarManager.GetTaskListByType(i, XMoeWarConfig.GetTaskGroupId(i)) + end + self:SetupDynamicTable() +end + +function XUiMoeWarTask:InitUi() + self.ActInfo = XDataCenter.MoeWarManager.GetActivityInfo() + self.AssetActivityPanel = XUiPanelActivityAsset.New(self.PanelSpecialTool) + self.AssetActivityPanel:Refresh(self.ActInfo.CurrencyId) + for i = 1,#self.ActInfo.CurrencyId do + XDataCenter.ItemManager.AddCountUpdateListener(self.ActInfo.CurrencyId[i], function() + self.AssetActivityPanel:Refresh(self.ActInfo.CurrencyId) + end, self.AssetActivityPanel) + end + self:RegisterButtonEvent() + self:InitDynamicTable() + self:InitButtonGroup() +end + +function XUiMoeWarTask:InitButtonGroup() + self.TabButtons = {} + self.TaskDic = {} + local count = XMoeWarConfig.GetTaskGroupCount() + for i = 1, count do + local obj = CS.UnityEngine.Object.Instantiate(self.GridBtn, self.Content) + local button = obj:GetComponent("XUiButton") + button:SetName(XMoeWarConfig.GetTaskName(i)) + obj.gameObject:SetActiveEx(true) + self.TabButtons[i] = button + self.TaskDic[i] = XDataCenter.MoeWarManager.GetTaskListByType(i,XMoeWarConfig.GetTaskGroupId(i)) + XRedPointManager.AddRedPointEvent(self.TabButtons[i],self.CheckButtonRedPoint,self,{XRedPointConditions.Types.CONDITION_MOEWAR_TASK_TAB},i) + end + self.Content.gameObject:SetActiveEx(true) + self.GridBtn.gameObject:SetActiveEx(false) + self.ButtonGroup:Init(self.TabButtons,function(index) self:OnSelectToggle(index) end) + self.ButtonGroup:SelectIndex(self.SelectIndex) +end + +function XUiMoeWarTask:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelTaskStoryList) + self.DynamicTable:SetProxy(XDynamicGridTask,self,handler(self,self.BeforeFinishCheck)) + self.DynamicTable:SetDelegate(self) +end + +function XUiMoeWarTask:SetupDynamicTable() + local list = self.TaskDic[self.SelectIndex] + if not list then + XLog.Error("XUiMoeWarTask:SetupDynamicTable 选中的任务列表不存在,index:",self.SelectIndex) + return + end + self.PanelNoneStoryTask.gameObject:SetActiveEx(#list == 0) + self.DynamicTable:SetTotalCount(#list) + self.DynamicTable:ReloadDataASync() +end + +function XUiMoeWarTask:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:ResetData(self.TaskDic[self.SelectIndex][index]) + end +end + +function XUiMoeWarTask:RegisterButtonEvent() + self.BtnBack.CallBack = function() + XLuaUiManager.Close("UiMoeWarTask") + end + self.BtnMainUi.CallBack = function() XLuaUiManager.RunMain() end +end + +function XUiMoeWarTask:OnSelectToggle(index) + self.SelectIndex = index + self:PlayAnimation("TaskStoryQieHuan") + self:SetupDynamicTable() +end + +function XUiMoeWarTask:CheckButtonRedPoint(count,index) + self.TabButtons[index]:ShowReddot(count >= 0) +end + +function XUiMoeWarTask:BeforeFinishCheck(taskData) + local rewards = XRewardManager.GetRewardList(taskData.RewardId) + if not rewards then return false end + local needCheck = false + for i = 1,#rewards do + if rewards[i].TemplateId == XDataCenter.ItemManager.ItemId.MoeWarRespondItemId then + needCheck = true + break + end + end + if not needCheck then return true end + return not XDataCenter.MoeWarManager.CheckRespondItemIsMax(false) +end + +return XUiMoeWarTask \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMoeWar/XUiMoeWarVote.lua b/Resources/Scripts/XUi/XUiMoeWar/XUiMoeWarVote.lua new file mode 100644 index 00000000..d3ffdd26 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMoeWar/XUiMoeWarVote.lua @@ -0,0 +1,756 @@ +local XUiMoeWarVote = XLuaUiManager.Register(XLuaUi, "UiMoeWarVote") +local XUiPanelPlayerVote = require("XUi/XUiMoeWar/SubPage/XUiPanelPlayerVote") +local tableInsert = table.insert +local Vector2 = CS.UnityEngine.Vector2 +local TipTextContentPos = {[1] = Vector2(0,231),[2] = Vector2(-260,231),[3] = Vector2(460,231)} +local TipTextContentPosL = {[1] = Vector2(0,231),[2] = Vector2(-600,231),[3] = Vector2(0,231),[4] = Vector2(600,231)} + +function XUiMoeWarVote:OnStart(defaultSelectIndex) + if defaultSelectIndex then + self.SelectIndex = self:ConvertIndexToSelectIndex(defaultSelectIndex) + else + self.SelectIndex = self:ConvertIndexToSelectIndex(XDataCenter.MoeWarManager.GetDefaultSelect()) + end + self.IsPlayAnimation = false + if self:IsFinalSession() and XDataCenter.MoeWarManager.GetCurMatch():GetType() == XMoeWarConfig.MatchType.Publicity then + self.IsSkip = false + else + self.IsSkip = XDataCenter.MoeWarManager.IsSelectSkip() + end + if self.IsSkip then self.BtnShield:SetButtonState(CS.UiButtonState.Select) end + self.BtnTabGoList = {} + self.BtnObjDic = {} + self:RegisterButtonEvent() + self:InitSceneRoot() + self:InitVotePanel() + self.LastMatchType = XDataCenter.MoeWarManager.GetCurMatch():GetSessionId() + self.PairList = XDataCenter.MoeWarManager.GetCurMatch():GetPairList() + self:InitButtonGroup() + self:UpdateMatchName() + self:UpdatePanelState() + self:UpdateMatchTime() + if self.PanelSpecialTool then + self.ActInfo = XDataCenter.MoeWarManager.GetActivityInfo() + self.AssetActivityPanel = XUiPanelActivityAsset.New(self.PanelSpecialTool) + self.AssetActivityPanel:Refresh(self.ActInfo.CurrencyId) + for i = 1,#self.ActInfo.CurrencyId do + XDataCenter.ItemManager.AddCountUpdateListener(self.ActInfo.CurrencyId[i], function() + self.AssetActivityPanel:Refresh(self.ActInfo.CurrencyId) + end, self.AssetActivityPanel) + end + end + self.BtnRank:SetName(CS.XTextManager.GetText("MoeWarRankName")) + self.BtnRole:SetName(CS.XTextManager.GetText("MoeWarIntroduceName")) + self.BtnSchedule:SetName(CS.XTextManager.GetText("MoeWarGameName")) + XEventManager.AddEventListener(XEventId.EVENT_MOE_WAR_PLAY_SCREEN_RECORD_ANIMATION,self.PlayScreenRecordAnimation,self) + self.AfterHandler = function(evt,ui) self:AfterUiOpen(ui) end +end + +function XUiMoeWarVote:OnEnable() + CS.XGameEventManager.Instance:RegisterEvent(CS.XEventId.EVENT_UI_ALLOWOPERATE,self.AfterHandler) + XLuaUiManager.Remove("UiMoeWarGroupList") + self.PairList = XDataCenter.MoeWarManager.GetCurMatch():GetPairList() + self:PlaySwitchAnimation() + self:UpdateAllPanel() + self:StartTimer() +end + +function XUiMoeWarVote:OnDisable() + if self.PlayingCv then + self.PlayingCv:Stop() + end + if self.AnimationTimer then + self.IsPlayAnimation = false + CS.XScheduleManager.UnSchedule(self.AnimationTimer) + end + self:StopTimer() + self:ClearPanelBulletCache() + CS.XGameEventManager.Instance:RemoveEvent(CS.XEventId.EVENT_UI_ALLOWOPERATE,self.AfterHandler) +end + +function XUiMoeWarVote:OnDestroy() + XEventManager.RemoveEventListener(XEventId.EVENT_MOE_WAR_PLAY_SCREEN_RECORD_ANIMATION,self.PlayScreenRecordAnimation,self) +end + +function XUiMoeWarVote:OnGetEvents() + return { + XEventId.EVENT_MOE_WAR_UPDATE, + XEventId.EVENT_MOE_WAR_PLAY_THANK_ANIMATION, + XEventId.EVENT_MOE_WAR_VOTE_PANEL_UPDATE, + XEventId.EVENT_MOE_WAR_ACTIVITY_END, + } +end + +function XUiMoeWarVote:OnNotify(event, ...) + local args = { ... } + if event == XEventId.EVENT_MOE_WAR_UPDATE then + local match = XDataCenter.MoeWarManager.GetCurMatch() + self.PairList = match:GetPairList() + if self:CheckIsNeedPop() then return end + self:UpdateAllPanel() + if match:GetType() == XMoeWarConfig.MatchType.Publicity then + XLuaUiManager.Close("UiMoeWarPollTips") + local saveKey + if match:GetSessionId() == XMoeWarConfig.SessionType.Game3In1 then + saveKey = string.format("%s_%s_%d_%d","MOE_WAR_VOTE_ANIMATION_RECORD",tostring(XPlayer.Id),match:GetSessionId(),1) + else + saveKey = string.format("%s_%s_%d_%d","MOE_WAR_VOTE_ANIMATION_RECORD",tostring(XPlayer.Id),match:GetSessionId(),self:ConvertSelectIndexToIndex(self.SelectIndex)) + end + if saveKey then XSaveTool.SaveData(saveKey,1) end + self:PlayRunAnimation(self.IsSkip) + end + elseif event == XEventId.EVENT_MOE_WAR_PLAY_THANK_ANIMATION then + self:PlayThankAnimation(args[1]) + elseif event == XEventId.EVENT_MOE_WAR_VOTE_PANEL_UPDATE then + self:UpdateAllPanel() + elseif event == XEventId.EVENT_MOE_WAR_ACTIVITY_END then + XUiManager.TipText("MoeWarActivityOver") + XLuaUiManager.RunMain() + end +end + +function XUiMoeWarVote:AfterUiOpen(ui) + if ui then + if ui[0].UiData.UiName ~= self.Name then + return + end + end + local match = XDataCenter.MoeWarManager.GetCurMatch() + if match:GetType() == XMoeWarConfig.MatchType.Publicity and match:GetSessionId() == XMoeWarConfig.SessionType.Game3In1 then + local saveKey = string.format("%s_%s_%d_%d", XMoeWarConfig.MOE_WAR_VOTE_ANIMATION_RECORD, tostring(XPlayer.Id), match:GetSessionId(), 1) + local isShow = XSaveTool.GetData(saveKey) + if not isShow then + self:PlayRunAnimation(self.IsSkip) + XSaveTool.SaveData(saveKey, 1) + else + self:PlayWinnerAnimation() + end + elseif match:GetType() == XMoeWarConfig.MatchType.Publicity then + local saveKey = string.format("%s_%s_%d_%d", XMoeWarConfig.MOE_WAR_VOTE_ANIMATION_RECORD, tostring(XPlayer.Id), match:GetSessionId(), self:ConvertSelectIndexToIndex(self.SelectIndex)) + local isShow = XSaveTool.GetData(saveKey) + if not isShow then + self:PlayRunAnimation(self.IsSkip) + XSaveTool.SaveData(saveKey, 1) + else + self:PlayWinnerAnimation() + end + end + self:CheckIsNeedPop() +end + +function XUiMoeWarVote:PlayModelAnimation(playerEntity,playerModel,type) + self.IsPlayAnimation = true + playerModel:PlayAnima(playerEntity:GetAnim(type)) + --self.PlayingCv = XSoundManager.PlaySoundByType(playerEntity:GetCv(type),XSoundManager.SoundType.CV) + --海外萌战由于语音不全所以屏蔽语音加入显示弹幕 + self.content = XFavorabilityConfigs.GetCvContent(playerEntity:GetCv(type)) + self.TxtContent.text = self.content + self.PanelLayout.gameObject:SetActiveEx(true) + self:SetTextContentPosWithId(playerEntity.Id) + if self.AnimationTimer then + CS.XScheduleManager.UnSchedule(self.AnimationTimer) + end + self.AnimationTimer = CS.XScheduleManager.ScheduleOnce(function() + self.IsPlayAnimation = false + self.PanelLayout.gameObject:SetActiveEx(false) + end,math.floor(playerEntity:GetLength(type) * 1000)) +end + +function XUiMoeWarVote:PlayThankAnimation(playerId) + local playerModel = self:GetPlayAnimationPlayer(playerId) + local playerEntity = XDataCenter.MoeWarManager.GetPlayer(playerId) + local panelList = self:IsFinalSession() and self.ThreeVotePanel or self.TwoVotePanel + for i = 1, #panelList do + panelList[i]:PlayVoteChangeEffect() + end + self:PlayModelAnimation(playerEntity, playerModel, XMoeWarConfig.ActionType.Thank) +end + +function XUiMoeWarVote:PlayRunAnimation(isSkip) + if isSkip then return end + if self:IsFinalSession() then + if self.PairList[1] then + XDataCenter.MoeWarManager.EnterAnimation(self.PairList[1]) + end + else + local realIndex = self:ConvertSelectIndexToIndex(self.SelectIndex) + if self.PairList[realIndex] then + XDataCenter.MoeWarManager.EnterAnimation(self.PairList[realIndex]) + end + end +end + +function XUiMoeWarVote:PlayScreenRecordAnimation(playerId) + if self.IsPlayAnimation then return end + local playerModel = self:GetPlayAnimationPlayer(playerId) + local playerEntity = XDataCenter.MoeWarManager.GetPlayer(playerId) + playerModel:PlayAnima(playerEntity:GetAnim(XMoeWarConfig.ActionType.Thank)) +end + +function XUiMoeWarVote:PlayWinnerAnimation() + local playerModel,playerEntity,pairConfig + if not self:IsFinalSession() then + pairConfig = self.PairList[self:ConvertSelectIndexToIndex(self.SelectIndex)] + else + pairConfig = self.PairList[1] + end + if not pairConfig then return end + if self.EffectVictory then + self.EffectVictory.gameObject:SetActiveEx(false) + self.EffectVictory.gameObject:SetActiveEx(true) + end + playerEntity = XDataCenter.MoeWarManager.GetPlayer(pairConfig.WinnerId) + for i = 1, #pairConfig.Players do + if pairConfig.Players[i] == pairConfig.WinnerId then + if self:IsFinalSession() then + playerModel = self.ThreeCharacterModel[i] + else + playerModel = self.TwoCharacterModel[i] + end + end + end + + if not playerModel then return end + self:PlayModelAnimation(playerEntity,playerModel,XMoeWarConfig.ActionType.Thank) +end + +function XUiMoeWarVote:OnClickBtnShield() + self.IsSkip = self.BtnShield:GetToggleState() + XDataCenter.MoeWarManager.SetIsSelectSkip(self.IsSkip) + XDataCenter.MoeWarManager.ClearAllScreenRecord() +end + +function XUiMoeWarVote:OnClickPlayRecord() + self:PlayRunAnimation(false) +end + +function XUiMoeWarVote:OnClickRankList() + XLuaUiManager.Open("UiMoeWarRankingList") +end + +function XUiMoeWarVote:OnClickBtnRole() + XLuaUiManager.Open("UiMoeWarMessage") +end + +function XUiMoeWarVote:OnClickBtnSchedule() + XLuaUiManager.Open("UiMoeWarSchedule",self:GetCurrSelectGroup(self.SelectIndex)) +end + +function XUiMoeWarVote:OnClickModel(eventData,index) + if self.IsPlayAnimation then return end + local match = XDataCenter.MoeWarManager.GetCurMatch() + local playerEntity,playerModel + if match:GetSessionId() == XMoeWarConfig.SessionType.Game3In1 then + local playerId = match:GetPairList()[1].Players[index] + playerEntity = XDataCenter.MoeWarManager.GetPlayer(playerId) + playerModel = self.ThreeCharacterModel[index] + else + local realIndex = self:ConvertSelectIndexToIndex(self.SelectIndex) + local playerId = self.PairList[realIndex].Players[index] + playerEntity = XDataCenter.MoeWarManager.GetPlayer(playerId) + playerModel = self.TwoCharacterModel[index] + end + if playerEntity and playerModel then + self:PlayModelAnimation(playerEntity,playerModel,XMoeWarConfig.ActionType.Intro) + end +end + +function XUiMoeWarVote:SetTextContentPosWithId(curPlayerId) + local match = XDataCenter.MoeWarManager.GetCurMatch() + local index = 0 + local pos = nil + if match:GetSessionId() == XMoeWarConfig.SessionType.Game3In1 then + pos = TipTextContentPosL + for i = 1, 3 do + local playerId = match:GetPairList()[1].Players[i] + if playerId == curPlayerId then + index = i + break + end + end + else + pos = TipTextContentPos + local realIndex = self:ConvertSelectIndexToIndex(self.SelectIndex) + for i = 1, 2 do + local playerId = self.PairList[realIndex].Players[i] + if playerId == curPlayerId then + index = i + break + end + end + end + index = index + 1 + if pos then + if pos[index] then + self.PanelChat.anchoredPosition = pos[index] + else + self.PanelChat.anchoredPosition = pos[1] + end + else + self.PanelChat.anchoredPosition = TipTextContentPos[1] + end +end + +function XUiMoeWarVote:RegisterButtonEvent() + self.BtnBack.CallBack = function() + XLuaUiManager.Close("UiMoeWarVote") + end + self.BtnMainUi.CallBack = function() + XLuaUiManager.RunMain() + end + self.BtnRank.CallBack = function() + self:OnClickRankList() + end + self.BtnRole.CallBack = function() + self:OnClickBtnRole() + end + self.BtnSchedule.CallBack = function() + self:OnClickBtnSchedule() + end + self.BtnVideo.CallBack = function() + self:OnClickPlayRecord() + end + self.BtnShield.CallBack = function() + self:OnClickBtnShield() + end + if self.BtnHelp then + local voteHelpId = XMoeWarConfig.GetVoteHelpId() + self.BtnHelp.CallBack = function () + if voteHelpId > 0 then + local template = XHelpCourseConfig.GetHelpCourseTemplateById(voteHelpId) + XUiManager.ShowHelpTip(template.Function) + end + end + self.BtnHelp.gameObject:SetActiveEx(voteHelpId > 0) + end +end + +function XUiMoeWarVote:InitVotePanel() + self.TwoVotePanel = {} + self.TwoVoteResultImgList = {} + for i = 1, 2 do + local panel = XUiPanelPlayerVote.New(self.Panel01:FindTransform("PanelVote" .. i).gameObject) + tableInsert(self.TwoVotePanel, panel) + local img = self.Panel01:FindTransform("ImgIconResult"..i):GetComponent("Image") + tableInsert(self.TwoVoteResultImgList,img) + end + self.ThreeVotePanel = {} + self.ThreeVoteResultImgList = {} + for i = 1, 3 do + local panel = XUiPanelPlayerVote.New(self.Panel02:FindTransform("PanelVote" .. i).gameObject) + tableInsert(self.ThreeVotePanel, panel) + local img = self.Panel02:FindTransform("ImgIconResult"..i):GetComponent("Image") + tableInsert(self.ThreeVoteResultImgList,img) + end +end + +function XUiMoeWarVote:InitButtonGroup() + local match = XDataCenter.MoeWarManager.GetCurMatch() + if not match or match:GetSessionId() == XMoeWarConfig.SessionType.Game3In1 then + return + end + self.PairList = match:GetPairList() + local groups = XDataCenter.MoeWarManager.GetActivityInfo() + local currParentIndex = 0 + for i = 1, #(groups.GroupName) do + local children = match:GetPairListByGroupId(i) + local obj = CS.UnityEngine.GameObject.Instantiate(self.BtnFirst, self.PanelTitleBtnContent) + ---@type XUiComponent.XUiButton + local btnComponent = obj:GetComponent("XUiButton") + btnComponent:SetNameByGroup(1, groups.GroupName[i]) + btnComponent:SetNameByGroup(2, groups.GroupSecondName[i]) + currParentIndex = #self.BtnTabGoList + 1 + tableInsert(self.BtnTabGoList, btnComponent) + for j = 1, #children do + local currIndex = (i - 1)*#children + j + local childObj = nil + if self.BtnObjDic[currIndex] then + childObj = self.BtnObjDic[currIndex] + else + childObj = CS.UnityEngine.GameObject.Instantiate(self.BtnChild, self.PanelTitleBtnContent) + self.BtnObjDic[currIndex] = childObj + end + ---@type XUiComponent.XUiButton + local childBtnComponent = childObj:GetComponent("XUiButton") + childBtnComponent.SubGroupIndex = currParentIndex + + tableInsert(self.BtnTabGoList, childBtnComponent) + local playerA = XDataCenter.MoeWarManager.GetPlayer(children[j].Players[1]) + local playerB = XDataCenter.MoeWarManager.GetPlayer(children[j].Players[2]) + local imgLeftHead = childObj.transform:Find("Head1/StandIcon"):GetComponent("RawImage") + local imgRightHead = childObj.transform:Find("Head2/StandIcon"):GetComponent("RawImage") + imgLeftHead:SetRawImage(playerA:GetCircleHead()) + imgRightHead:SetRawImage(playerB:GetCircleHead()) + if match:GetType() == XMoeWarConfig.MatchType.Publicity then + local imgLeftLose = childObj.transform:Find("Head1/ImgLose") + local imgRightLose = childObj.transform:Find("Head2/ImgLose") + imgLeftLose.gameObject:SetActiveEx(children[j].WinnerId ~= children[j].Players[1]) + imgRightLose.gameObject:SetActiveEx(children[j].WinnerId ~= children[j].Players[2]) + end + end + end + + for i = 1, #(groups.GroupName) do + local children = match:GetPairListByGroupId(i) + for j = #children + 1, (#self.BtnTabGoList / 3) - 1 do + local currIndex = (i - 1) * #children + j + i + if self.BtnObjDic[currIndex] then + self.BtnObjDic[currIndex].gameObject:SetActiveEx(false) + end + end + end + self.BtnFirst.gameObject:SetActiveEx(false) + self.BtnChild.gameObject:SetActiveEx(false) + self.PanelTitleBtnGroup:Init(self.BtnTabGoList, function(index) + self:OnSelectToggle(index) + end) + self.PanelTitleBtnGroup:SelectIndex(self.SelectIndex) +end + +function XUiMoeWarVote:OnSelectToggle(index) + self.SelectIndex = index + local realIndex = self:ConvertSelectIndexToIndex(index) + self:UpdateCurrModel(realIndex) + self:UpdateVotePanel(realIndex) + self.PanelLayout.gameObject:SetActiveEx(false) + local match = XDataCenter.MoeWarManager.GetCurMatch() + self:PlaySwitchAnimation() + if match:GetType() == XMoeWarConfig.MatchType.Publicity then + local saveKey = string.format("%s_%s_%d_%d","MOE_WAR_VOTE_ANIMATION_RECORD",tostring(XPlayer.Id),match:GetSessionId(),realIndex) + local data = XSaveTool.GetData(saveKey) + if not data then + if not self.IsSkip then + XDataCenter.MoeWarManager.EnterAnimation(self.PairList[realIndex]) + else + self:PlayWinnerAnimation() + end + XSaveTool.SaveData(saveKey, 1) + else + self:PlayWinnerAnimation() + end + self:UpdateResultIcon() + end +end + +function XUiMoeWarVote:InitSceneRoot() + local root = self.UiModelGo.transform + self.TwoCharacterPanel = root:FindTransform("Panel01") + self.ThreeCharacterPanel = root:FindTransform("Panel02") + self.TwoCharacterTransform = {} + self.TwoCharacterModel = {} + self.TwoCharacterEffect = {} + self.TwoCharacterTransform[1] = self.TwoCharacterPanel:FindTransform("PanelModelCase1") + self.TwoCharacterTransform[2] = self.TwoCharacterPanel:FindTransform("PanelModelCase2") + for i = 1, #self.TwoCharacterTransform do + self.TwoCharacterEffect[i] = self.TwoCharacterPanel:Find("PanelModelCase"..i.."/ImgEffectHuanren1").gameObject + self.TwoCharacterModel[i] = XUiPanelRoleModel.New(self.TwoCharacterTransform[i], self.Name, nil, true, nil, true) + local inputHandler = self.TwoCharacterTransform[i]:GetComponent(typeof(CS.XGoInputHandler)) + if not inputHandler then + inputHandler = self.TwoCharacterTransform[i].gameObject:AddComponent(typeof(CS.XGoInputHandler)) + end + local index = i + inputHandler:AddPointerClickListener(function(eventData) + self:OnClickModel(eventData,index) + end) + end + self.ThreeCharacterTransform = {} + self.ThreeCharacterModel = {} + self.ThreeCharacterEffect = {} + self.ThreeCharacterTransform[1] = self.ThreeCharacterPanel:FindTransform("PanelModelCase1") + self.ThreeCharacterTransform[2] = self.ThreeCharacterPanel:FindTransform("PanelModelCase2") + self.ThreeCharacterTransform[3] = self.ThreeCharacterPanel:FindTransform("PanelModelCase3") + for i = 1, #self.ThreeCharacterTransform do + self.ThreeCharacterEffect[i] = self.ThreeCharacterPanel:Find("PanelModelCase"..i.."/ImgEffectHuanren1").gameObject + self.ThreeCharacterModel[i] = XUiPanelRoleModel.New(self.ThreeCharacterTransform[i], self.Name, nil, true, nil, true) + local inputHandler = self.ThreeCharacterTransform[i]:GetComponent(typeof(CS.XGoInputHandler)) + if not inputHandler then + inputHandler = self.ThreeCharacterTransform[i].gameObject:AddComponent(typeof(CS.XGoInputHandler)) + end + local index = i + inputHandler:AddPointerClickListener(function(eventData) + self:OnClickModel(eventData,index) + end) + end +end + +function XUiMoeWarVote:UpdateAllPanel() + self:UpdateTabGroup() + self:UpdateVotePanel(self:ConvertSelectIndexToIndex(self.SelectIndex)) + self:UpdateMatchName() + self:UpdatePanelState() + self:UpdateMatchTime() + self:UpdateResultIcon() + self:UpdateCurrModel(self:ConvertSelectIndexToIndex(self.SelectIndex)) +end + +function XUiMoeWarVote:UpdateTabGroup() + local match = XDataCenter.MoeWarManager.GetCurMatch() + if not match or match:GetSessionId() == XMoeWarConfig.SessionType.Game3In1 then + return + end + self.PairList = match:GetPairList() + local groups = XDataCenter.MoeWarManager.GetActivityInfo() + local currParentIndex = 0 + for i = 1, #(groups.GroupName) do + local children = match:GetPairListByGroupId(i) + ---@type XUiComponent.XUiButton + currParentIndex = #self.BtnTabGoList + 1 + for j = 1, #children do + local currIndex = (i - 1)*#children + j + local childObj = nil + if self.BtnObjDic[currIndex] then + childObj = self.BtnObjDic[currIndex] + else + childObj = CS.UnityEngine.GameObject.Instantiate(self.BtnChild, self.PanelTitleBtnContent) + self.BtnObjDic[currIndex] = childObj + end + self:UpdatePairGroup(children[j],childObj) + end + end +end + +function XUiMoeWarVote:UpdatePairGroup(pairConfig,obj) + local match = XDataCenter.MoeWarManager.GetCurMatch() + local playerA = XDataCenter.MoeWarManager.GetPlayer(pairConfig.Players[1]) + local playerB = XDataCenter.MoeWarManager.GetPlayer(pairConfig.Players[2]) + local imgLeftHead = obj.transform:Find("Head1/StandIcon"):GetComponent("RawImage") + local imgRightHead = obj.transform:Find("Head2/StandIcon"):GetComponent("RawImage") + imgLeftHead:SetRawImage(playerA:GetCircleHead()) + imgRightHead:SetRawImage(playerB:GetCircleHead()) + if match:GetType() == XMoeWarConfig.MatchType.Publicity then + local imgLeftLose = obj.transform:Find("Head1/ImgLose") + local imgRightLose = obj.transform:Find("Head2/ImgLose") + imgLeftLose.gameObject:SetActiveEx(pairConfig.WinnerId ~= pairConfig.Players[1]) + imgRightLose.gameObject:SetActiveEx(pairConfig.WinnerId ~= pairConfig.Players[2]) + end +end + +function XUiMoeWarVote:UpdateCurrModel(index) + if self:IsFinalSession() then + for _, pairInfo in pairs(self.PairList) do + for i = 1, #(pairInfo.Players) do + local playerEntity = XDataCenter.MoeWarManager.GetPlayer(pairInfo.Players[i]) + self.ThreeCharacterModel[i]:UpdateRoleModel(playerEntity:GetModel(), self.ThreeCharacterTransform[i], XModelManager.MODEL_UINAME.XUiMoeWarVote, function(model) + model.gameObject:SetActiveEx(true) + local animator = model:GetComponent("Animator") + animator.applyRootMotion = false + end,nil, true, true) + end + end + else + local pairConfig = self.PairList[index] + local leftPlayer = XDataCenter.MoeWarManager.GetPlayer(pairConfig.Players[1]) + local rightPlayer = XDataCenter.MoeWarManager.GetPlayer(pairConfig.Players[2]) + self.TwoCharacterModel[1]:UpdateRoleModel(leftPlayer:GetModel(), self.TwoCharacterTransform[1], XModelManager.MODEL_UINAME.XUiMoeWarVote,function(model) + model.gameObject:SetActiveEx(true) + local animator = model:GetComponent("Animator") + animator.applyRootMotion = false + end, nil, true, true) + self.TwoCharacterModel[2]:UpdateRoleModel(rightPlayer:GetModel(), self.TwoCharacterTransform[2], XModelManager.MODEL_UINAME.XUiMoeWarVote,function(model) + model.gameObject:SetActiveEx(true) + local animator = model:GetComponent("Animator") + animator.applyRootMotion = false + end, nil, true, true) + end +end + +function XUiMoeWarVote:UpdateVotePanel(index) + if self:IsFinalSession() then + for i = 1, #self.PairList do + for j = 1, #(self.PairList[i].Players) do + self.ThreeVotePanel[j]:Refresh(self.PairList[i].Players[j]) + end + end + else + local pairConfig = self.PairList[index] + for i = 1, #(pairConfig.Players) do + self.TwoVotePanel[i]:Refresh(pairConfig.Players[i]) + end + end +end + +function XUiMoeWarVote:UpdateResultIcon() + local match = XDataCenter.MoeWarManager.GetCurMatch() + if match:GetType() ~= XMoeWarConfig.MatchType.Publicity then + return + end + local iconList = XMoeWarConfig.GetIconList(match:GetSessionId()) + if self:IsFinalSession() then + local pairList = match:GetPairList() + for i = 1,#pairList do + for j = 1,#(pairList[i].Players) do + if pairList[i].Players[j] == pairList[i].WinnerId then + self:SetUiSprite(self.ThreeVoteResultImgList[j],iconList[1]) + elseif pairList[i].Players[j] == pairList[i].SecondId then + self:SetUiSprite(self.ThreeVoteResultImgList[j],iconList[2]) + else + self:SetUiSprite(self.ThreeVoteResultImgList[j],iconList[3]) + end + end + end + else + local index = self:ConvertSelectIndexToIndex(self.SelectIndex) + local pair = self.PairList[index] + for i = 1, #(pair.Players) do + if pair.Players[i] == pair.WinnerId then + self:SetUiSprite(self.TwoVoteResultImgList[i],iconList[1]) + self.TwoVoteResultImgList[i].gameObject:SetActiveEx(true) + else + self.TwoVoteResultImgList[i].gameObject:SetActiveEx(false) + end + end + end +end + +function XUiMoeWarVote:UpdatePanelState() + self.Panel01.gameObject:SetActiveEx(not self:IsFinalSession()) + self.Panel02.gameObject:SetActiveEx(self:IsFinalSession()) + self.TwoCharacterPanel.gameObject:SetActiveEx(not self:IsFinalSession()) + self.ThreeCharacterPanel.gameObject:SetActiveEx(self:IsFinalSession()) + local match = XDataCenter.MoeWarManager.GetCurMatch() + local type = match:GetType() + self.BtnShield.gameObject:SetActiveEx(not (self:IsFinalSession() and type == XMoeWarConfig.MatchType.Publicity)) + self.BtnShield:SetName(type == XMoeWarConfig.MatchType.Publicity and CS.XTextManager.GetText("MoeWarSkipAnimation") or CS.XTextManager.GetText("MoeWarSkipGift")) + self.BtnVideo.gameObject:SetActiveEx(type == XMoeWarConfig.MatchType.Publicity) + for i = 1, #self.TwoVoteResultImgList do + self.TwoVoteResultImgList[i].gameObject:SetActiveEx(type == XMoeWarConfig.MatchType.Publicity) + end + for i = 1, #self.ThreeVoteResultImgList do + self.ThreeVoteResultImgList[i].gameObject:SetActiveEx(type == XMoeWarConfig.MatchType.Publicity) + end +end + +function XUiMoeWarVote:UpdateMatchName() + local match = XDataCenter.MoeWarManager.GetCurMatch() + if match then + self.TxtTitle.text = match:GetName() + end + if self.RImgIcon then + local desc = match:GetDesc() + self.RImgIcon:SetRawImage(match:GetCoverImg()) + if match:GetType() == XMoeWarConfig.MatchType.Publicity and match:GetSessionId() == XMoeWarConfig.SessionType.Game3In1 then + self.TxtRefresh.text = match:GetDesc()[3] + self.TxtTimeTitle.gameObject:SetActiveEx(false) + self.TxtTime.gameObject:SetActiveEx(false) + self.RImgIcon:SetRawImage(match:GetFinalImg()) + else + self.TxtRefresh.text = match:GetRefreshVoteText() + self.TxtTimeTitle.gameObject:SetActiveEx(true) + end + self.TxtTimeTitle.text = desc[2] + end +end + +function XUiMoeWarVote:UpdateMatchTime() + local match = XDataCenter.MoeWarManager.GetCurMatch() + if not match then + return + end + local endTime = match:GetEndTime() + local now = XTime.GetServerNowTimestamp() + local offset = endTime - now + if XDataCenter.MoeWarManager.IsInStatistics() then + self.TxtRefresh.text = CS.XTextManager.GetText("MoeWarMatchVoteNoResult") + self.TxtTimeTitle.gameObject:SetActiveEx(false) + else self.TxtTime.text = XUiHelper.GetTime(offset, XUiHelper.TimeFormatType.CHALLENGE) + end +end + +function XUiMoeWarVote:StartTimer() + if self.Timer then + self:StopTimer() + end + + self.Timer = CS.XScheduleManager.ScheduleForever(function() + if XTool.UObjIsNil(self.TxtTime) then + self:StopTimer() + return + end + self:UpdateVotePanel(self:ConvertSelectIndexToIndex(self.SelectIndex)) + self:UpdateMatchTime() + end, CS.XScheduleManager.SECOND, 0) +end + +function XUiMoeWarVote:StopTimer() + if self.Timer then + CS.XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end + +function XUiMoeWarVote:ConvertIndexToSelectIndex(index) + return math.ceil(index / XDataCenter.MoeWarManager.GetMatchPerGroupCount()) + index +end + +function XUiMoeWarVote:ConvertSelectIndexToIndex(index) + return index - math.ceil(index / (XDataCenter.MoeWarManager.GetMatchPerGroupCount() + 1)) +end + +function XUiMoeWarVote:GetCurrSelectGroup(selectIndex) + local realIndex = self:ConvertSelectIndexToIndex(selectIndex) + return math.ceil(realIndex / XDataCenter.MoeWarManager.GetMatchPerGroupCount()) +end + +function XUiMoeWarVote:IsFinalSession() + local match = XDataCenter.MoeWarManager.GetCurMatch() + if not match then + return false + end + return match:GetSessionId() == XMoeWarConfig.SessionType.Game3In1 +end + +function XUiMoeWarVote:GetPlayAnimationPlayer(playerId) + if self:IsFinalSession() then + for i = 1, #self.PairList do + for j = 1, #(self.PairList[i].Players) do + if self.PairList[i].Players[j] == playerId then + return self.ThreeCharacterModel[j] + end + end + end + else + local pairConfig = self.PairList[self:ConvertSelectIndexToIndex(self.SelectIndex)] + for i = 1, #(pairConfig.Players) do + if pairConfig.Players[i] == playerId then + return self.TwoCharacterModel[i] + end + end + end +end + +function XUiMoeWarVote:PlaySwitchAnimation() + local match = XDataCenter.MoeWarManager.GetCurMatch() + local sessionId = match:GetSessionId() + local animName = sessionId == XMoeWarConfig.SessionType.Game3In1 and "Panel02QieHuan" or "Panel01QieHuan" + local effects = sessionId == XMoeWarConfig.SessionType.Game3In1 and self.ThreeCharacterEffect or self.TwoCharacterEffect + for i = 1, #effects do + effects[i]:SetActiveEx(false) + effects[i]:SetActiveEx(true) + end + self:PlayAnimation(animName) +end + +function XUiMoeWarVote:CheckIsNeedPop() + local match = XDataCenter.MoeWarManager.GetCurMatch() + if match:GetSessionId() ~= self.LastMatchType then + XUiManager.TipText("MoeWarMatchEnd") + XLuaUiManager.Close("UiMoeWarVote") + XLuaUiManager.Close("UiMoeWarPollTips") + return true + else + self.LastMatchType = match:GetSessionId() + return false + end +end + +function XUiMoeWarVote:ClearPanelBulletCache() + for i = 1,#self.TwoVotePanel do + self.TwoVotePanel[i]:ClearBulletCache() + end + + for i = 1,#self.ThreeVotePanel do + self.ThreeVotePanel[i]:ClearBulletCache() + end +end + +return XUiMoeWarVote \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMoneyReward/XUiMoneyReward.lua b/Resources/Scripts/XUi/XUiMoneyReward/XUiMoneyReward.lua new file mode 100644 index 00000000..de71720f --- /dev/null +++ b/Resources/Scripts/XUi/XUiMoneyReward/XUiMoneyReward.lua @@ -0,0 +1,338 @@ +local XUiMoneyReward = XLuaUiManager.Register(XLuaUi, "UiMoneyReward") + +function XUiMoneyReward:OnAwake() + self:AutoAddListener() +end + +function XUiMoneyReward:OnStart() + self:Init() +end + +function XUiMoneyReward:OnEnable() + self:CheckMoneyRewardOver(function () + self:SetupContent() + local selectIndex = XDataCenter.BountyTaskManager.GetSelectIndex() + + if selectIndex > 0 then + + self.PanelTask[selectIndex].GameObject:SetActive(true) + XLuaUiManager.SetMask(true) + self:PlayAnimation("MoneyRewardPanelTask" .. selectIndex, function() + XLuaUiManager.SetMask(false) + end) + + XDataCenter.BountyTaskManager.SetSelectIndex(-1) + else + XLuaUiManager.SetMask(true) + + self:PlayAnimation("MoneyRewardBegin", function() + XLuaUiManager.SetMask(false) + end) + end + XEventManager.AddEventListener(XEventId.EVENT_BOUNTYTASK_ACCEPT_TASK, self.SetupBountyTask, self) + XEventManager.AddEventListener(XEventId.EVENT_BOUNTYTASK_ACCEPT_TASK_REWARD, self.OnRankLevelChange, self) + XEventManager.AddEventListener(XEventId.EVENT_BOUNTYTASK_TASK_COMPLETE_NOTIFY, self.SetupContent, self) + XEventManager.AddEventListener(XEventId.EVENT_BOUNTYTASK_INFO_CHANGE_NOTIFY, self.SetupContent, self) + XEventManager.AddEventListener(XEventId.EVENT_MAINTAINERACTION_WEEK_UPDATA, self.CheckMoneyRewardOver, self) + end) +end + +function XUiMoneyReward:OnDisable() + self:RemoveTimer() + XEventManager.RemoveEventListener(XEventId.EVENT_BOUNTYTASK_ACCEPT_TASK_REWARD, self.OnRankLevelChange, self) + XEventManager.RemoveEventListener(XEventId.EVENT_BOUNTYTASK_TASK_COMPLETE_NOTIFY, self.SetupContent, self) + XEventManager.RemoveEventListener(XEventId.EVENT_BOUNTYTASK_INFO_CHANGE_NOTIFY, self.SetupContent, self) + XEventManager.RemoveEventListener(XEventId.EVENT_BOUNTYTASK_ACCEPT_TASK, self.SetupBountyTask, self) + XEventManager.RemoveEventListener(XEventId.EVENT_MAINTAINERACTION_WEEK_UPDATA, self.CheckMoneyRewardOver, self) +end + +--初始化 +function XUiMoneyReward:Init() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self.CurExp = -1 + self.TargetExp = 0; + self.CurRankLevel = -1 + self.TargetRankLevel = -1 + self.Timer = nil + self.BountyInfo = nil + self.PanelTask = {} + self.PanelTask[1] = XUiPanelTask.New(self.PanelTask1, self, 1) + self.PanelTask[2] = XUiPanelTask.New(self.PanelTask2, self, 2) + self.PanelTask[3] = XUiPanelTask.New(self.PanelTask3, self, 3) +end + +--关闭 +function XUiMoneyReward:OnDestroy() + self:RemoveTimer() +end + +--设置面板内容 +function XUiMoneyReward:SetupContent() + self.BountyInfo = XDataCenter.BountyTaskManager.GetBountyTaskInfo() + self:SetupBountyTask() + self:SetLeftTime() +end + +--设置领取任务信息 +function XUiMoneyReward:SetupBountyTask() + if not self.BountyInfo then + return + end + + local completeCount = XDataCenter.BountyTaskManager.GetBountyTaskCompletedCount() + + self.TxtTaskSum.text = string.format("%s/%s", completeCount, XDataCenter.BountyTaskManager.MAX_BOUNTY_TASK_COUNT) + + local fakeOrder = XDataCenter.BountyTaskManager.GetFakeTaskOrder() + + local occupyIndexs = {} + for k, v in pairs(fakeOrder) do + occupyIndexs[v] = k + end + + local selectIndex = XDataCenter.BountyTaskManager.GetSelectIndex() + if selectIndex > 0 then + self.PanelTask[selectIndex].GameObject:SetActive(false) + end + + for index = 1, XDataCenter.BountyTaskManager.MAX_BOUNTY_TASK_COUNT do + self:SetTaskByIndex(index, occupyIndexs, fakeOrder) + end +end + +function XUiMoneyReward:SetTaskByIndex(index, occupyIndexs, fakeOrder) + local task = self.BountyInfo.TaskCards[index] + if task and fakeOrder[task.Id] then + self.PanelTask[fakeOrder[task.Id]]:SetupContent(task) + if fakeOrder[task.Id] ~= index and not occupyIndexs[index] then + self.PanelTask[index]:SetupContent(nil) + end + elseif not occupyIndexs[index] then + self.PanelTask[index]:SetupContent(task) + end +end + + +--设置排名信息 +function XUiMoneyReward:SetupRankLevel(isAnimate) + if not self.BountyInfo then + return + end + + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end + + local rankLevel = self.BountyInfo.RankLevel + local rankConfig = XDataCenter.BountyTaskManager.GetBountyTaskRankConfig(rankLevel) + local nextNeed = rankConfig.LevelUpExp + + local itemId = XDataCenter.ItemManager.ItemId.BountyTaskExp + local count = XDataCenter.ItemManager.GetCount(itemId) + count = count > nextNeed and nextNeed or count + + self.PanelEffect.gameObject:SetActive(false) + if ((self.CurExp ~= -1 and count > self.CurExp) or (self.CurRankLevel ~= -1 and self.CurRankLevel ~= rankLevel)) and isAnimate then + self.TargetExp = count + self.TargetRankLevel = rankLevel + else + self.CurExp = count + self.CurRankLevel = self.BountyInfo.RankLevel + self:StopExpAnimation() + end +end + +function XUiMoneyReward:OnRankLevelChange() + self.BountyInfo = XDataCenter.BountyTaskManager.GetBountyTaskInfo() + self:SetupBountyTask() +end + +local NextExp = 0 +local TargetExp = 0 + +function XUiMoneyReward:StartExpAnimation() + if self.PanelEffect:Exist() then + self.PanelEffect.gameObject:SetActive(true) + end + + if self.TargetRankLevel > self.CurRankLevel then + local rankConfig = XDataCenter.BountyTaskManager.GetBountyTaskRankConfig(self.CurRankLevel) + + TargetExp = rankConfig.LevelUpExp + NextExp = rankConfig.LevelUpExp + self.TxtNeed.text = tostring(NextExp) + + if not self.Timer then + self.Timer = XScheduleManager.ScheduleForever(function() + self:Update() + end, 0) + end + elseif self.TargetRankLevel == self.CurRankLevel and self.TargetExp == self.CurExp then + self:StopExpAnimation() + else + local rankConfig = XDataCenter.BountyTaskManager.GetBountyTaskRankConfig(self.CurRankLevel) + NextExp = rankConfig.LevelUpExp + TargetExp = self.TargetExp + self.TxtNeed.text = tostring(NextExp) + + if not self.Timer then + self.Timer = XScheduleManager.ScheduleForever(function() + self:Update() + end, 0) + end + end +end + +function XUiMoneyReward:StopExpAnimation() + self.PanelEffect.gameObject:SetActive(false) + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end + + local rankConfig = XDataCenter.BountyTaskManager.GetBountyTaskRankConfig(self.BountyInfo.RankLevel) + local nextNeed = rankConfig.LevelUpExp + + local rankLevel = self.BountyInfo.RankLevel + local itemId = XDataCenter.ItemManager.ItemId.BountyTaskExp + local count = XDataCenter.ItemManager.GetCount(itemId) + + self.TxtCurValue.text = tostring(count) + self.TxtNeed.text = tostring(nextNeed) + self.SliderExp.value = count / nextNeed + + local MaxLevel = XDataCenter.BountyTaskManager.GetMaxBountyTaskInfoRankLevel() + if MaxLevel == rankLevel then + self.TxtCurValue.gameObject:SetActive(false) + self.TxtMax.gameObject:SetActive(true) + self.SliderExp.value = 0 + self.TxtNeed.text = "0" + else + self.TxtMax.gameObject:SetActive(false) + self.TxtCurValue.gameObject:SetActive(true) + end + + self.RImgLevelNew.gameObject:SetActive(true) + self.RImgLevelNew:SetRawImage(rankConfig.RankIcon) +end + +function XUiMoneyReward:Update() + + if not self.TxtCurValue:Exist() or not self.SliderExp:Exist() or not self.TxtNeed:Exist() or not self.RImgLevelNew:Exist() then + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end + return + end + + if self.CurExp < TargetExp then + self.CurExp = self.CurExp + NextExp / 30 / 3 + self.TxtCurValue.text = tostring(math.floor(self.CurExp)) + self.SliderExp.value = self.CurExp / NextExp; + else + self.CurExp = TargetExp + if self.TargetRankLevel > self.CurRankLevel then + self.CurRankLevel = self.CurRankLevel + 1 + self.CurExp = 0 + + local targetRankConfig = XDataCenter.BountyTaskManager.GetBountyTaskRankConfig(self.TargetRankLevel) + self.RImgLevelNew:SetRawImage(targetRankConfig.RankIcon) + + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end + + self:PlayAnimation("MoneyRewardRankUp", function() + self:StartExpAnimation() + end) + end + + end +end + +function XUiMoneyReward:AutoAddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:RegisterClickEvent(self.BtnHelper, self.OnBtnHelperClick) +end + +function XUiMoneyReward:OnBtnHelperClick() + XUiManager.UiFubenDialogTip(CS.XTextManager.GetText("BountyTaskTipTitle"), CS.XTextManager.GetText("BountyTaskTipContent")); +end + +function XUiMoneyReward:OnBtnBackClick() + + self:PlayAnimation("MoneyRewardEnd", function() + self:Close() + end) +end + +function XUiMoneyReward:OnBtnMainUiClick() + self:PlayAnimation("MoneyRewardEnd", function() + XLuaUiManager.RunMain() + end) +end + +--设置剩余时间 +function XUiMoneyReward:SetLeftTime() + if self.Timer then + self:RemoveTimer() + end + + local refreshTime = XDataCenter.BountyTaskManager.GetRefreshTime() + refreshTime = refreshTime or 0 + local leftTime = refreshTime - XTime.GetServerNowTimestamp() + + if leftTime <= 0 then + local dataTime = XUiHelper.GetTime(0) + self.TxtCurTime.text = dataTime + self:RemoveTimer() + XLuaUiManager.RunMain() -- 修复赏金任务到时间后会由于循环调用导致卡死问题(海外) + --self:Refresh() + else + local dataTime = XUiHelper.GetTime(leftTime) + self.TxtCurTime.text = dataTime + end + + + self.Timer = XScheduleManager.ScheduleForever(function() + if XTool.UObjIsNil(self.GameObject) then + return + end + + leftTime = refreshTime - XTime.GetServerNowTimestamp() + + if leftTime <= 0 then + local dataTime = XUiHelper.GetTime(0) + self.TxtCurTime.text = dataTime + self:RemoveTimer() + XLuaUiManager.RunMain() -- 到时间踢回主界面(海外) + else + local dataTime = XUiHelper.GetTime(leftTime) + self.TxtCurTime.text = dataTime + end + end, 1000) +end + +function XUiMoneyReward:Refresh() + self.BountyInfo = XDataCenter.BountyTaskManager.GetBountyTaskInfo() + self:SetupBountyTask() +end + + +function XUiMoneyReward:RemoveTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end + +function XUiMoneyReward:CheckMoneyRewardOver(cb) + XUiManager.TipText("MaintainerActionEventOver") + XScheduleManager.ScheduleOnce(function() + XLuaUiManager.RunMain() + end, 100) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMoneyReward/XUiMoneyRewardFightTipFind.lua b/Resources/Scripts/XUi/XUiMoneyReward/XUiMoneyRewardFightTipFind.lua new file mode 100644 index 00000000..8506e369 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMoneyReward/XUiMoneyRewardFightTipFind.lua @@ -0,0 +1,74 @@ +local XUiMoneyRewardFightTipFind = XLuaUiManager.Register(XLuaUi, "UiMoneyRewardFightTipFind") + +function XUiMoneyRewardFightTipFind:OnAwake() + self:InitAutoScript() +end + +function XUiMoneyRewardFightTipFind:OnStart() + self:PlayAnimation("FindBegan", function() + self:TryExitFight() + end) +end + +function XUiMoneyRewardFightTipFind:TryExitFight() + self.Timer = XScheduleManager.ScheduleForever(function() + self:ExitFight() + end, XScheduleManager.SECOND, 0) +end + +function XUiMoneyRewardFightTipFind:ExitFight() + XDataCenter.FubenManager.ExitFight() +end + +function XUiMoneyRewardFightTipFind:OnDestroy() + XScheduleManager.UnSchedule(self.Timer) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiMoneyRewardFightTipFind:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiMoneyRewardFightTipFind:AutoInitUi() + self.PanelFind = self.Transform:Find("FullScreenBackground/PanelFind") +end + +function XUiMoneyRewardFightTipFind:GetAutoKey(uiNode, eventName) + if not uiNode then + return + end + return eventName .. uiNode:GetHashCode() +end + +function XUiMoneyRewardFightTipFind:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then + return + end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiMoneyRewardFightTipFind:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiMoneyRewardFightTipFind:AutoAddListener() + self.AutoCreateListeners = {} +end +-- auto diff --git a/Resources/Scripts/XUi/XUiMoneyReward/XUiMoneyRewardFightTips.lua b/Resources/Scripts/XUi/XUiMoneyReward/XUiMoneyRewardFightTips.lua new file mode 100644 index 00000000..97ff4209 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMoneyReward/XUiMoneyRewardFightTips.lua @@ -0,0 +1,79 @@ +local XUiMoneyRewardFightTips = XLuaUiManager.Register(XLuaUi, "UiMoneyRewardFightTips") + +function XUiMoneyRewardFightTips:OnAwake() + self:InitAutoScript() +end + +function XUiMoneyRewardFightTips:OnStart(stageId) + + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + local bountyInfo = XDataCenter.BountyTaskManager.GetBountyTaskConfig(stageInfo.BountyId) + + local rand = math.random(1, #bountyInfo.EnterAnimation) + local animationName = "" + if bountyInfo.EnterAnimation and bountyInfo.EnterAnimation ~= "" then + animationName = bountyInfo.EnterAnimation[rand] + end + + XUiHelper.PlayAnimation(self, animationName, nil, function() + XDataCenter.FubenManager.ReadyToFight() + end) + +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiMoneyRewardFightTips:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiMoneyRewardFightTips:AutoInitUi() + self.BtnBg = self.Transform:Find("FullScreenBackground/BtnBg"):GetComponent("Button") +end + +function XUiMoneyRewardFightTips:GetAutoKey(uiNode, eventName) + if not uiNode then + return + end + return eventName .. uiNode:GetHashCode() +end + +function XUiMoneyRewardFightTips:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then + return + end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiMoneyRewardFightTips:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiMoneyRewardFightTips:AutoAddListener() + self.AutoCreateListeners = {} + self:RegisterClickEvent(self.BtnBg, self.OnBtnBgClick) +end +-- auto +function XUiMoneyRewardFightTips:OnBtnBgClick() + -- if self.AnimationEnd == false then + -- return + -- end + -- CS.XUiManager.ViewManager:Pop() + -- XDataCenter.BountyTaskManager.EnterFight(self.FightResult) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMoneyReward/XUiMoneyRewardLevelUpTips.lua b/Resources/Scripts/XUi/XUiMoneyReward/XUiMoneyRewardLevelUpTips.lua new file mode 100644 index 00000000..453d6bfd --- /dev/null +++ b/Resources/Scripts/XUi/XUiMoneyReward/XUiMoneyRewardLevelUpTips.lua @@ -0,0 +1,89 @@ +local XUiMoneyRewardLevelUpTips = XLuaUiManager.Register(XLuaUi, "UiMoneyRewardLevelUpTips") + +function XUiMoneyRewardLevelUpTips:OnAwake() + self:InitAutoScript() +end + +function XUiMoneyRewardLevelUpTips:OnStart(oldLevel, newLevel) + self.OldLevel = oldLevel + self.NewLevel = newLevel + self:SetupTips() + + self.PlayingAnimaiton = true + self:PlayAnimation("MoneyRewardLevelUpTipBegin", function() + self.PlayingAnimaiton = false + end) + +end + +--设置Tips内容 +function XUiMoneyRewardLevelUpTips:SetupTips() + local configPre = XDataCenter.BountyTaskManager.GetBountyTaskRankConfig(self.OldLevel) + local configCur = XDataCenter.BountyTaskManager.GetBountyTaskRankConfig(self.NewLevel) + + self.TxtPre.text = configPre.RankName + self.TxtNext.text = configCur.RankName +end + +function XUiMoneyRewardLevelUpTips:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiMoneyRewardLevelUpTips:AutoInitUi() + self.TxtNext = self.Transform:Find("FullScreenBackground/TxtNext"):GetComponent("Text") + self.TxtPre = self.Transform:Find("FullScreenBackground/TxtPre"):GetComponent("Text") + self.BtnBg = self.Transform:Find("FullScreenBackground/BtnBg"):GetComponent("Button") +end + +function XUiMoneyRewardLevelUpTips:GetAutoKey(uiNode, eventName) + if not uiNode then + return + end + return eventName .. uiNode:GetHashCode() +end + +function XUiMoneyRewardLevelUpTips:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then + return + end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiMoneyRewardLevelUpTips:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiMoneyRewardLevelUpTips:AutoAddListener() + self.AutoCreateListeners = {} + self:RegisterClickEvent(self.BtnBg, self.OnBtnBgClick) +end + +function XUiMoneyRewardLevelUpTips:OnBtnBgClick() + + if self.PlayingAnimaiton then + return + end + + self.PlayingAnimaiton = true + + self:PlayAnimation("MoneyRewardLevelUpTipEnd",function() + self:Close() + XEventManager.DispatchEvent(XEventId.EVENT_BOUNTYTASK_ACCEPT_TASK_REWARD) + end) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMoneyReward/XUiMoneyRewardRank.lua b/Resources/Scripts/XUi/XUiMoneyReward/XUiMoneyRewardRank.lua new file mode 100644 index 00000000..80f097f8 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMoneyReward/XUiMoneyRewardRank.lua @@ -0,0 +1,49 @@ +local XUiMoneyRewardRank = XLuaUiManager.Register(XLuaUi, "UiMoneyRewardRank") + +function XUiMoneyRewardRank:OnAwake() + self:AutoAddListener() +end + +function XUiMoneyRewardRank:OnStart() + self:Init() + self:SetupRewardInfo() + self:PlayAnimation("MoneyRewardRank") +end + +function XUiMoneyRewardRank:Init() + self.DynamicTable = XDynamicTableNormal.New(self.PanelScroll) + self.DynamicTable:SetProxy(XUiPanelRewardGird) + self.DynamicTable:SetDelegate(self) +end + +--设置内容 +function XUiMoneyRewardRank:SetupRewardInfo() + local config = XDataCenter.BountyTaskManager.GetBountyTaskRankTable() + if not config then + return + end + + local curLevel = XDataCenter.BountyTaskManager.GetBountyTaskInfoRankLevel() + + self.TxtDesc.text = CS.XTextManager.GetText("BountyRankDescContent") + self.BountyTaskRankConfig = config + self.DynamicTable:SetDataSource(config) + self.DynamicTable:ReloadDataSync(#config - curLevel) +end + +--动态列表事件 +function XUiMoneyRewardRank:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.BountyTaskRankConfig[index] + grid.Parent = self + grid:SetupContent(data) + end +end + +function XUiMoneyRewardRank:AutoAddListener() + self:RegisterClickEvent(self.BtnBg, self.OnBtnBgClick) +end + +function XUiMoneyRewardRank:OnBtnBgClick() + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMoneyReward/XUiMoneyRewardTask.lua b/Resources/Scripts/XUi/XUiMoneyReward/XUiMoneyRewardTask.lua new file mode 100644 index 00000000..8ff16ca5 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMoneyReward/XUiMoneyRewardTask.lua @@ -0,0 +1,103 @@ +local XUiMoneyRewardTask = XLuaUiManager.Register(XLuaUi, "UiMoneyRewardTask") + +function XUiMoneyRewardTask:OnAwake() + self:AutoAddListener() +end + +function XUiMoneyRewardTask:OnStart() + + self:Init() + self:SetupContent() + + self:PlayAnimation("MoneyRewardTaskBegin") +end + +function XUiMoneyRewardTask:OnDestroy() + XEventManager.RemoveEventListener(XEventId.EVENT_BOUNTYTASK_ACCEPT_TASK, self.OnAsseptTask, self) + XEventManager.RemoveEventListener(XEventId.EVENT_BOUNTYTASK_TASK_REFRESH, self.SetupContent, self) +end + +function XUiMoneyRewardTask:OnAsseptTask() + self:PlayAnimation("MoneyRewardTaskEnd",function() + self:Close() + end) +end + +--设置任务卡 +function XUiMoneyRewardTask:Init() + self.TaskGrid = {} + self.TaskGrid[1] = XUiPanelTaskCard.New(self.PanelTaskCard, self) + for i = 2, XDataCenter.BountyTaskManager.MAX_BOUNTY_TASK_COUNT do + local ui = CS.UnityEngine.Object.Instantiate(self.PanelTaskCard) + self.TaskGrid[i] = XUiPanelTaskCard.New(ui, self) + self.TaskGrid[i].Transform:SetParent(self.PanelTask, false) + end + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + + XEventManager.AddEventListener(XEventId.EVENT_BOUNTYTASK_TASK_REFRESH, self.SetupContent, self) + XEventManager.AddEventListener(XEventId.EVENT_BOUNTYTASK_ACCEPT_TASK, self.OnAsseptTask, self) +end + +--设置内容 +function XUiMoneyRewardTask:SetupContent() + self.BountyInfo = XDataCenter.BountyTaskManager.GetBountyTaskInfo() + if not self.BountyInfo then + return + end + + --设置刷新次数 + local taskPoolRefreshCount = self.BountyInfo.TaskPoolRefreshCount + local leaveRefreshCount = XDataCenter.BountyTaskManager.MAX_BOUNTY_TASK_REFRESH_COUNT - taskPoolRefreshCount + leaveRefreshCount = leaveRefreshCount >= 0 and leaveRefreshCount or 0 + self.TxtTimes.text = tostring(leaveRefreshCount) + + self:SetupTaskCard() +end + +--设置任务卡 +function XUiMoneyRewardTask:SetupTaskCard() + local taskCards = self.BountyInfo.TaskPool + for i = 1, XDataCenter.BountyTaskManager.MAX_BOUNTY_TASK_COUNT do + if taskCards[i] then + self.TaskGrid[i]:SetupTaskCard(taskCards[i]) + else + self.TaskGrid[i]:SetActive(false) + end + end +end + +function XUiMoneyRewardTask:AutoAddListener() + self:RegisterClickEvent(self.BtnRefresh, self.OnBtnRefreshClick) + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) +end + +function XUiMoneyRewardTask:OnBtnRefreshClick() + if not self.BountyInfo then + return + end + + local taskPoolRefreshCount = self.BountyInfo.TaskPoolRefreshCount + local leaveRefreshCount = XDataCenter.BountyTaskManager.MAX_BOUNTY_TASK_REFRESH_COUNT - taskPoolRefreshCount + if leaveRefreshCount <= 0 then + XUiManager.TipMsg(CS.XTextManager.GetText("BountyTaskRefreshCountNotEnough")) + return + end + + XDataCenter.BountyTaskManager.RefreshBountyTaskPool(function() + self:PlayAnimation("MoneyRewardTaskBeginRefresh") + end) +end + +function XUiMoneyRewardTask:OnBtnBackClick() + self:PlayAnimation("MoneyRewardTaskEnd", function() + XDataCenter.BountyTaskManager.SetSelectIndex(-1) + self:Close() + end) + +end + +function XUiMoneyRewardTask:OnBtnMainUiClick() + XDataCenter.BountyTaskManager.SetSelectIndex(-1) + XLuaUiManager.RunMain() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMoneyReward/XUiMoneyRewardTaskCardTip.lua b/Resources/Scripts/XUi/XUiMoneyReward/XUiMoneyRewardTaskCardTip.lua new file mode 100644 index 00000000..655e7761 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMoneyReward/XUiMoneyRewardTaskCardTip.lua @@ -0,0 +1,82 @@ +local XUiMoneyRewardTaskCardTip = XLuaUiManager.Register(XLuaUi, "UiMoneyRewardTaskCardTip") + +function XUiMoneyRewardTaskCardTip:OnAwake() + self:AutoAddListener() +end + +function XUiMoneyRewardTaskCardTip:OnStart(taskCard) + self.GridList = {} + self.BountyTask = taskCard + self:SetupTaskCard() + + self:PlayAnimation("MoneyRewardTaskCardTipBegin") +end + +--设置任务卡内容 +function XUiMoneyRewardTaskCardTip:SetupTaskCard() + if not self.BountyTask then + return + end + + local taskConfig = XDataCenter.BountyTaskManager.GetBountyTaskConfig(self.BountyTask.Id) + if not taskConfig then + local path = XBountyTaskConfigs.GetBountyTaskPath() + XLog.ErrorTableDataNotFound("XUiPanelTaskCard:SetupTaskCard", "taskConfig", path, "Id", tostring(self.BountyTask.Id)) + return + end + + self.TxtTitle.text = taskConfig.Name + self.TxtDesc.text = taskConfig.Desc + + self.RImgRoleIcon:SetRawImage(taskConfig.RoleIcon) + self:SetUiSprite(self.ImgQuality,taskConfig.DifficultLevelIconX, function() + self.ImgQuality:SetNativeSize() + end) + + local randomEventCfg = XDataCenter.BountyTaskManager.GetBountyTaskRandomEventConfig(self.BountyTask.EventId) + self.TxtBuff.text = randomEventCfg.EventName + + local difficultStageCfg = XDataCenter.BountyTaskManager.GetBountyTaskDifficultStageConfig(self.BountyTask.DifficultStageId) + self.TxtLevel.text = string.format(taskConfig.TextColor, difficultStageCfg.Name) + + self:SetupReward(self.BountyTask.RewardId) +end + +--设置奖励 +function XUiMoneyRewardTaskCardTip:SetupReward(rewardId) + local rewards = XRewardManager.GetRewardList(rewardId) + if not rewards then + return + end + + --显示的奖励 + local start = 0 + if rewards then + for i, item in ipairs(rewards) do + start = i + local grid + if self.GridList[i] then + grid = self.GridList[i] + else + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommon) + grid = XUiGridCommon.New(self, ui) + grid.Transform:SetParent(self.PanelReward, false) + self.GridList[i] = grid + end + grid:Refresh(item) + grid.GameObject:SetActive(true) + end + end + + for j = start + 1, #self.GridList do + self.GridList[j].GameObject:SetActive(false) + end +end + +function XUiMoneyRewardTaskCardTip:AutoAddListener() + self:RegisterClickEvent(self.BtnBg, self.OnBtnBgClick) +end + +function XUiMoneyRewardTaskCardTip:OnBtnBgClick() + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMoneyReward/XUiPanelRewardGird.lua b/Resources/Scripts/XUi/XUiMoneyReward/XUiPanelRewardGird.lua new file mode 100644 index 00000000..9be40675 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMoneyReward/XUiPanelRewardGird.lua @@ -0,0 +1,95 @@ +XUiPanelRewardGird = XClass(nil, "XUiPanelRewardGird") + +function XUiPanelRewardGird:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.GridList = {} + XTool.InitUiObject(self) + self:InitAutoScript() + self.GridCommon.gameObject:SetActive(false) +end + +--设置内容 +function XUiPanelRewardGird:SetupContent(config) + local curLevel = XDataCenter.BountyTaskManager.GetBountyTaskInfoRankLevel() + self.TxtValue.text = config.RankName + self.ImgCur.gameObject:SetActive(curLevel == config.RankLevel) + self:SetupReward(config.RewardId) + self.RImgIcon:SetRawImage(config.RankIcon) + --MoneyTaskIcon3 +end + +--设置奖励 +function XUiPanelRewardGird:SetupReward(rewardId) + + local rewards = XRewardManager.GetRewardList(rewardId) + + if not rewards then + return + end + + --显示的奖励 + local start = 0 + if rewards then + for i, item in ipairs(rewards) do + start = i + local grid + if self.GridList[i] then + grid = self.GridList[i] + else + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommon) + grid = XUiGridCommon.New(self.Parent, ui) + grid.Transform:SetParent(self.PanelRewards, false) + self.GridList[i] = grid + end + grid:Refresh(item) + grid.GameObject:SetActive(true) + end + end + + for j = start + 1, #self.GridList do + self.GridList[j].GameObject:SetActive(false) + end +end + + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelRewardGird:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiPanelRewardGird:AutoInitUi() + -- self.TxtValue = self.Transform:Find("TxtValue"):GetComponent("Text") + -- self.TxtName = self.Transform:Find("TxtName"):GetComponent("Text") + -- self.PanelRewards = self.Transform:Find("PanelRewards") + -- self.GridCommon = self.Transform:Find("PanelRewards/GridCommon") + -- self.PanelSite = self.Transform:Find("PanelRewards/GridCommon/PanelSite") + -- self.TxtSite = self.Transform:Find("PanelRewards/GridCommon/PanelSite/TxtSite"):GetComponent("Text") + -- self.ImgCur = self.Transform:Find("ImgCur"):GetComponent("Image") + -- self.ImgQuality = self.Transform:Find("ImgQuality"):GetComponent("Image") + -- self.RImgIcon = self.Transform:Find("RImgIcon"):GetComponent("RawImage") +end + +function XUiPanelRewardGird:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelRewardGird:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelRewardGird:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelRewardGird:AutoAddListener() +end +-- auto +return XUiPanelRewardGird \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMoneyReward/XUiPanelTask.lua b/Resources/Scripts/XUi/XUiMoneyReward/XUiPanelTask.lua new file mode 100644 index 00000000..f794f841 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMoneyReward/XUiPanelTask.lua @@ -0,0 +1,179 @@ +XUiPanelTask = XClass(nil, "XUiPanelTask") + +function XUiPanelTask:Ctor(ui, parent, index) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Parent = parent + self.Index = index + self.GridList = {} + XTool.InitUiObject(self) + self:InitAutoScript() + self.GridCommon.gameObject:SetActive(false) +end + +function XUiPanelTask:SetupContent(taskData) + self.PanelNone.gameObject:SetActive(false) + self.PanelDone.gameObject:SetActive(false) + self.PanelTask.gameObject:SetActive(false) + + self.BountyTask = taskData + + if self.BountyTask ~= nil then + self:SetupTask() + else + self.PanelNone.gameObject:SetActive(true) + end +end + +--设置任务数据 +function XUiPanelTask:SetupTask() + if not self.BountyTask then + return + end + + self.BtnGet.gameObject:SetActive(false) + self.BtnGo.gameObject:SetActive(false) + self.PanelTask.gameObject:SetActive(true) + + --根据状态显示按钮状态 + if self.BountyTask.Status == XDataCenter.BountyTaskManager.BountyTaskStatus.AcceptReward then + self.PanelDone.gameObject:SetActive(true) + elseif self.BountyTask.Status == XDataCenter.BountyTaskManager.BountyTaskStatus.Complete then + self.BtnGet.gameObject:SetActive(true) + else + self.BtnGo.gameObject:SetActive(true) + end + + local taskConfig = XDataCenter.BountyTaskManager.GetBountyTaskConfig(self.BountyTask.Id) + if not taskConfig then + local path = XBountyTaskConfigs.GetBountyTaskPath() + XLog.ErrorTableDataNotFound("XUiPanelTaskCard:SetupTaskCard", "taskConfig", path, "Id", tostring(self.BountyTask.Id)) + return + end + + self.DifficultStageCfg = XDataCenter.BountyTaskManager.GetBountyTaskDifficultStageConfig(self.BountyTask.DifficultStageId) + + self.TxtLevel.text = self.DifficultStageCfg.Name + --self.Parent:SetUiSprite(self.ImgPic, taskConfig.RoleIcon) + self.RImgPic:SetRawImage(taskConfig.RoleIcon) + self.Parent:SetUiSprite(self.ImgQuality, taskConfig.DifficultLevelIcon, function() + self.ImgQuality:SetNativeSize() + end) + + self:SetupReward(self.BountyTask.RewardId) +end + +--设置奖励 +function XUiPanelTask:SetupReward(rewardId) + + local rewards = XRewardManager.GetRewardList(rewardId) + + if not rewards then + return + end + + --显示的奖励 + local start = 0 + if rewards then + for i, item in ipairs(rewards) do + start = i + local grid + if self.GridList[i] then + grid = self.GridList[i] + else + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommon) + grid = XUiGridCommon.New(self.Parent, ui) + grid.Transform:SetParent(self.PanelReward, false) + self.GridList[i] = grid + end + grid:Refresh(item) + grid.GameObject:SetActive(true) + end + end + + for j = start + 1, #self.GridList do + self.GridList[j].GameObject:SetActive(false) + end +end + + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelTask:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiPanelTask:AutoInitUi() + -- self.PanelDone = self.Transform:Find("PanelDone") + -- self.ImgDone = self.Transform:Find("PanelDone/ImgDone"):GetComponent("Image") + -- self.PanelTask = self.Transform:Find("PanelTask") + -- self.PanelHead = self.Transform:Find("PanelTask/PanelHead") + -- self.RImgPic = self.Transform:Find("PanelTask/PanelHead/RImgPic"):GetComponent("RawImage") + -- self.ImgQuality = self.Transform:Find("PanelTask/PanelHead/ImgQuality"):GetComponent("Image") + -- self.BtnClick = self.Transform:Find("PanelTask/PanelHead/BtnClick"):GetComponent("Button") + -- self.PanelReward = self.Transform:Find("PanelTask/PanelReward") + -- self.GridCommon = self.Transform:Find("PanelTask/PanelReward/GridCommon") + -- self.BtnGo = self.Transform:Find("PanelTask/BtnGo"):GetComponent("Button") + -- self.BtnGet = self.Transform:Find("PanelTask/BtnGet"):GetComponent("Button") + -- self.TxtLevel = self.Transform:Find("PanelTask/TxtLevel"):GetComponent("Text") + -- self.PanelNone = self.Transform:Find("PanelNone") + -- self.BtnSelectedTask = self.Transform:Find("PanelNone/BtnSelectedTask"):GetComponent("Button") +end + +function XUiPanelTask:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelTask:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelTask:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelTask:AutoAddListener() + self:RegisterClickEvent(self.BtnClick, self.OnBtnClickClick) + self:RegisterClickEvent(self.BtnGo, self.OnBtnGoClick) + self:RegisterClickEvent(self.BtnGet, self.OnBtnGetClick) + self:RegisterClickEvent(self.BtnSelectedTask, self.OnBtnSelectedTaskClick) +end +-- auto + +function XUiPanelTask:OnBtnClickAClick() + +end +function XUiPanelTask:OnBtnSelectedTaskClick() + XDataCenter.BountyTaskManager.SetSelectIndex(self.Index) + XLuaUiManager.Open("UiMoneyRewardTask") +end + +function XUiPanelTask:OnBtnClickClick() + XLuaUiManager.Open("UiMoneyRewardTaskCardTip", self.BountyTask, self.Parent) +end + +--跳转 +function XUiPanelTask:OnBtnGoClick() + if not self.DifficultStageCfg then + return + end + + local skipId = self.DifficultStageCfg.SkipId + XFunctionManager.SkipInterface(skipId) +end + +function XUiPanelTask:OnBtnGetClick() + if not self.BountyTask or self.BountyTask.Status ~= XDataCenter.BountyTaskManager.BountyTaskStatus.Complete then + return + end + + XDataCenter.BountyTaskManager.AcceptBountyTaskReward(self.BountyTask.Id) +end + +return XUiPanelTask \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMoneyReward/XUiPanelTaskCard.lua b/Resources/Scripts/XUi/XUiMoneyReward/XUiPanelTaskCard.lua new file mode 100644 index 00000000..2337dee6 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMoneyReward/XUiPanelTaskCard.lua @@ -0,0 +1,143 @@ +XUiPanelTaskCard = XClass(nil, "XUiPanelTaskCard") + +function XUiPanelTaskCard:Ctor(ui, parent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.GridList = {} + self.Parent = parent + XTool.InitUiObject(self) + self:InitAutoScript() + self.GridCommon.gameObject:SetActive(false) +end + +--激活 +function XUiPanelTaskCard:SetActive(active) + self.GameObject:SetActive(active) +end + +--设置任务卡内容 +function XUiPanelTaskCard:SetupTaskCard(taskCard) + if not taskCard then + return + end + + self.BountyTask = taskCard + + local taskConfig = XDataCenter.BountyTaskManager.GetBountyTaskConfig(self.BountyTask.Id) + if not taskConfig then + local path = XBountyTaskConfigs.GetBountyTaskPath() + XLog.ErrorTableDataNotFound("XUiPanelTaskCard:SetupTaskCard", "taskConfig", path, "Id", tostring(self.BountyTask.Id)) + return + end + + self.TxtTitle.text = taskConfig.Name + self.TxtDesc.text = taskConfig.Desc + + --self.Parent:SetUiSprite(self.ImgRoleIcon, taskConfig.RoleIcon) + self.RImgRoleIcon:SetRawImage(taskConfig.RoleIcon) + + self.Parent:SetUiSprite(self.ImgIconQuality, taskConfig.DifficultLevelIconX, function() + self.ImgIconQuality:SetNativeSize() + end) + + local randomEventCfg = XDataCenter.BountyTaskManager.GetBountyTaskRandomEventConfig(self.BountyTask.EventId) + self.TxtBuff.text = randomEventCfg.EventName + + local difficultStageCfg = XDataCenter.BountyTaskManager.GetBountyTaskDifficultStageConfig(self.BountyTask.DifficultStageId) + self.TxtLevel.text = string.format(taskConfig.TextColor, difficultStageCfg.Name) + + self:SetupReward(self.BountyTask.RewardId) +end + + + +--设置奖励 +function XUiPanelTaskCard:SetupReward(rewardId) + local rewards = XRewardManager.GetRewardList(rewardId) + if not rewards then + return + end + + --显示的奖励 + local start = 0 + if rewards then + for i, item in ipairs(rewards) do + start = i + local grid + if self.GridList[i] then + grid = self.GridList[i] + else + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommon) + grid = XUiGridCommon.New(self.Parent, ui) + grid.Transform:SetParent(self.PanelReward, false) + self.GridList[i] = grid + end + grid:Refresh(item) + grid.GameObject:SetActive(true) + end + end + + for j = start + 1, #self.GridList do + self.GridList[j].GameObject:SetActive(false) + end +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelTaskCard:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiPanelTaskCard:AutoInitUi() + -- self.ImgLevel = self.Transform:Find("ImgLevel"):GetComponent("Image") + -- self.ImgBG = self.Transform:Find("ImgLevel/ImgBG"):GetComponent("Image") + -- self.TxtLevel = self.Transform:Find("ImgLevel/ImgBG/TxtLevel"):GetComponent("Text") + -- self.RImgRoleIcon = self.Transform:Find("ImgLevel/RImgRoleIcon"):GetComponent("RawImage") + -- self.ImgIconQuality = self.Transform:Find("ImgLevel/ImgIconQuality"):GetComponent("Image") + -- self.TxtTitle = self.Transform:Find("TxtTitle"):GetComponent("Text") + -- self.TxtDesc = self.Transform:Find("TxtDesc"):GetComponent("Text") + -- self.TxtBuff = self.Transform:Find("Image/TxtBuff"):GetComponent("Text") + -- self.PanelReward = self.Transform:Find("PanelReward") + -- self.GridCommon = self.Transform:Find("PanelReward/GridCommon") + -- self.RImgIcon = self.Transform:Find("PanelReward/GridCommon/RImgIcon"):GetComponent("RawImage") + -- self.PanelSite = self.Transform:Find("PanelReward/GridCommon/PanelSite") + -- self.TxtSite = self.Transform:Find("PanelReward/GridCommon/PanelSite/TxtSite"):GetComponent("Text") + -- self.BtnAccept = self.Transform:Find("BtnAccept"):GetComponent("Button") +end + +function XUiPanelTaskCard:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelTaskCard:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelTaskCard:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelTaskCard:AutoAddListener() + self:RegisterClickEvent(self.BtnAccept, self.OnBtnAcceptClick) +end +-- auto +function XUiPanelTaskCard:OnBtnClickClick() + +end + +--接受任务 +function XUiPanelTaskCard:OnBtnAcceptClick() + if not self.BountyTask then + return + end + + XDataCenter.BountyTaskManager.AcceptBountyTask(self.BountyTask.Id) +end + +return XUiPanelTaskCard \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMovie/XUIGridStaff.lua b/Resources/Scripts/XUi/XUiMovie/XUIGridStaff.lua new file mode 100644 index 00000000..f337b84a --- /dev/null +++ b/Resources/Scripts/XUi/XUiMovie/XUIGridStaff.lua @@ -0,0 +1,17 @@ +local stringUtf8Len = string.Utf8Len +local DefaultColor = CS.UnityEngine.Color.white + +local XUIGridStaff = XClass(nil, "XUIGridStaff") + +function XUIGridStaff:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUIGridStaff:Refresh(staffPath, staffId) + local name = XMovieConfigs.GetStaffName(staffPath, staffId) + self.Text.text = name +end + +return XUIGridStaff \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMovie/XUiGridMovieActor.lua b/Resources/Scripts/XUi/XUiMovie/XUiGridMovieActor.lua new file mode 100644 index 00000000..22d7cddc --- /dev/null +++ b/Resources/Scripts/XUi/XUiMovie/XUiGridMovieActor.lua @@ -0,0 +1,366 @@ +local DefaultScale = CS.UnityEngine.Vector3(1, 1, 1) +local DefaultColor = CS.UnityEngine.Color.white +local FrontScale = CS.UnityEngine.Vector3(1.02, 1.02, 1) +local BackColor = CS.UnityEngine.Color(0.39, 0.39, 0.39, 1) +local AnimNames = { + Enable = { + "PanelActor1Enable", + "PanelActor2Enable", + "PanelActor3Enable", + }, + Disable = { + "PanelActor1Disable", + "PanelActor2Disable", + "PanelActor3Disable", + }, + NormalToFront = { + "PanelActor1BlowUpNor", + "PanelActor2BlowUpNor", + "PanelActor3BlowUpNor", + }, + NormalToBack = { + "PanelActor1DarkNor", + "PanelActor2DarkNor", + "PanelActor3DarkNor", + }, + BackToFront = { + "PanelActor1BlowUp", + "PanelActor2BlowUp", + "PanelActor3BlowUp", + }, + FrontToBack = { + "PanelActor1Dark", + "PanelActor2Dark", + "PanelActor3Dark", + }, +} + +local ShowStatus = { + Normal = 0, + Back = 1, + Front = 2, + Hide = 3, +} + +local XUiGridMovieActor = XClass(nil, "XUiGridMovieActor") + +function XUiGridMovieActor:Ctor(uiRoot, actorIndex) + self.UiRoot = uiRoot + self.ActorIndex = actorIndex + self.PlayingAnimDic = {} + + local panelActor = {} + local go = self.UiRoot["PanelActor" .. actorIndex] + panelActor.Transform = go.transform + panelActor.gameObject = go.gameObject + XTool.InitUiObject(panelActor) + + self.PanelActor = panelActor + self.RImgActor = panelActor.RImgActor + self.RImgFace = panelActor.RImgFace + self.EffctActor = panelActor.EffctActor + self.MetearialActor = panelActor.MetearialActor + self.MeterialFace = panelActor.MeterialFace + self.CanvasGroup = panelActor.Transform:GetComponent("CanvasGroup") + self.Status = ShowStatus.Hide + panelActor.gameObject:SetActiveEx(false) + self.RImgFace.gameObject:SetActiveEx(false) + XEventManager.AddEventListener(XEventId.EVENT_MOVIE_UI_DESTROY, self.Destroy, self) +end + +function XUiGridMovieActor:Destroy() + self.UiRoot = nil + self.RImgActor = nil + self.PanelActor = nil + self.EffctActor = nil + self.RImgFace = nil + self.MetearialActor = nil + self.MeterialFace = nil + self.CanvasGroup = nil +end + +function XUiGridMovieActor:UpdateActor(actorId) + if self.ActorId == actorId then return end + self.ActorId = actorId + + self:SetImage() + self.PanelActor.gameObject:SetActiveEx(true) +end + +function XUiGridMovieActor:SetImage() + local rImgActor = self.RImgActor + if not rImgActor then return end + + local actorId = self.ActorId + local path = XMovieConfigs.GetActorImgPath(actorId) + rImgActor:SetRawImage(path, function() + rImgActor:SetNativeSize() + end) +end + +function XUiGridMovieActor:SetImagePos(pos) + if self.Pos == pos then return end + local rImgActor = self.RImgActor + if XTool.UObjIsNil(rImgActor) then return end + + self.Pos = pos + rImgActor.rectTransform.anchoredPosition3D = pos +end + +function XUiGridMovieActor:GetImagePos() + return self.Pos +end + +function XUiGridMovieActor:GetEffectGo() + return self.EffctActor +end + +function XUiGridMovieActor:GetEffectParentGo() + return self.RImgActor.transform +end + +function XUiGridMovieActor:GetActorId() + return self.ActorId or 0 +end + +function XUiGridMovieActor:GetFaceId() + return self.FaceId or 0 +end + +function XUiGridMovieActor:IsHide() + return self.Status == ShowStatus.Hide +end + +function XUiGridMovieActor:IsBack() + return self.Status == ShowStatus.Back +end + +function XUiGridMovieActor:IsFront() + return self.Status == ShowStatus.Front +end + +function XUiGridMovieActor:SetFace(faceId) + local rImgFace = self.RImgFace + + local actorId = self.ActorId + if faceId ~= 0 then + self.FaceId = faceId + local path = XMovieConfigs.GetActorFaceImgPath(actorId, faceId) + rImgFace:SetRawImage(path, function() + rImgFace:SetNativeSize() + end) + rImgFace.rectTransform.anchoredPosition = XMovieConfigs.GetActorFacePosVector2(actorId) + rImgFace.gameObject:SetActiveEx(true) + else + rImgFace.gameObject:SetActiveEx(false) + end +end + +function XUiGridMovieActor:SetGrayScale(value) + if self.GrayValue == value then return end + self.GrayValue = value + self.MetearialActor:SetGrayScale(value) + self.MeterialFace:SetGrayScale(value) +end + +function XUiGridMovieActor:RevertActorPanel() + local rImgActor = self.RImgActor + local rImgFace = self.RImgFace + if XTool.UObjIsNil(rImgActor) then return end + + local alpha = 1 + local color = DefaultColor + local scale = DefaultScale + local status = self.Status + if status == ShowStatus.Back then + color = BackColor + elseif status == ShowStatus.Front then + self.PanelActor.Transform:SetAsLastSibling() + scale = FrontScale + elseif status == ShowStatus.Hide then + alpha = 0 + end + + self.CanvasGroup.alpha = alpha + rImgActor.color = color + rImgFace.color = color + rImgActor.rectTransform.localScale = scale +end + +function XUiGridMovieActor:PlayAnimEnable(skipAnim) + if self.IsUsing then return end + self.IsUsing = true + + if self.Status == ShowStatus.Normal then return end + self.Status = ShowStatus.Normal + + if skipAnim then + self:RevertActorPanel() + return + end + + local actorIndex = self.ActorIndex + local animName = AnimNames.Enable[actorIndex] + if not animName then return end + + local sameAnimPlaying = self.PlayingAnimDic[animName] + if sameAnimPlaying then + XLog.Error("XUiGridMovieActor:PlayAnimEnable Error:配置错误,不允许连续配置相同index的角色出现") + return + end + self.PlayingAnimDic[animName] = true + + self.IsPlayingEnable = true + local anim = self.UiRoot[animName] + anim.gameObject:SetActiveEx(true) + + anim:PlayTimelineAnimation(function() + XLuaUiManager.SetMask(false) + self.IsPlayingEnable = nil + self.PlayingAnimDic[animName] = nil + anim.gameObject:SetActiveEx(false) + + local tmpAnimName = self.DelayAnimName + if tmpAnimName then + local tmpAnim = self.UiRoot[tmpAnimName] + tmpAnim.gameObject:SetActiveEx(true) + tmpAnim:PlayTimelineAnimation(function() + XLuaUiManager.SetMask(false) + tmpAnim.gameObject:SetActiveEx(false) + self:RevertActorPanel() + end, function() + XLuaUiManager.SetMask(true) + end) + self.DelayAnimName = nil + else + self:RevertActorPanel() + end + end, function() + XLuaUiManager.SetMask(true) + end) +end + +function XUiGridMovieActor:PlayAnimDisable(skipAnim, cb) + if not self.IsUsing then return end + self.IsUsing = nil + + if self.Status == ShowStatus.Hide then return end + self.Status = ShowStatus.Hide + + if skipAnim then + self:RevertActorPanel() + return + end + + local actorIndex = self.ActorIndex + local animName = AnimNames.Disable[actorIndex] + if not animName then return end + + local sameAnimPlaying = self.PlayingAnimDic[animName] + if sameAnimPlaying then + XLog.Error("XUiGridMovieActor:PlayAnimEnable Error:配置错误,不允许连续配置相同index的角色消失") + return + end + self.PlayingAnimDic[animName] = true + + local anim = self.UiRoot[animName] + anim.gameObject:SetActiveEx(true) + anim:PlayTimelineAnimation(function() + XLuaUiManager.SetMask(false) + anim.gameObject:SetActiveEx(false) + self.PlayingAnimDic[animName] = nil + if cb then + cb() + end + end, function() + XLuaUiManager.SetMask(true) + end) +end + +function XUiGridMovieActor:PlayAnimBack(skipAnim) + if not self.IsUsing then return end + + if self.Status == ShowStatus.Back then return end + + local animName = self:GetStatusAnimName(ShowStatus.Back) + if not animName then return end + + self.Status = ShowStatus.Back + + if skipAnim then + self:RevertActorPanel() + return + end + + if self.IsPlayingEnable then + self.DelayAnimName = animName + return + end + + local anim = self.UiRoot[animName] + anim.gameObject:SetActiveEx(true) + anim:PlayTimelineAnimation(function() + XLuaUiManager.SetMask(false) + anim.gameObject:SetActiveEx(false) + self:RevertActorPanel() + end, function() + XLuaUiManager.SetMask(true) + end) +end + +function XUiGridMovieActor:PlayAnimFront(skipAnim) + if not self.IsUsing then return end + + if self.Status == ShowStatus.Front then return end + + local animName = self:GetStatusAnimName(ShowStatus.Front) + if not animName then return end + + self.Status = ShowStatus.Front + + if skipAnim then + self:RevertActorPanel() + return + end + + if self.IsPlayingEnable then + self.DelayAnimName = animName + return + end + + local anim = self.UiRoot[animName] + anim.gameObject:SetActiveEx(true) + anim:PlayTimelineAnimation(function() + XLuaUiManager.SetMask(false) + anim.gameObject:SetActiveEx(false) + self:RevertActorPanel() + end, function() + XLuaUiManager.SetMask(true) + end) +end + +function XUiGridMovieActor:GetStatusAnimName(toStatus) + local animName + + local actorIndex = self.ActorIndex + if not actorIndex then return end + + local status = self.Status + if toStatus == ShowStatus.Back then + if status == ShowStatus.Normal then + animName = AnimNames.NormalToBack[actorIndex] + elseif status == ShowStatus.Front then + animName = AnimNames.FrontToBack[actorIndex] + end + elseif toStatus == ShowStatus.Front then + if status == ShowStatus.Normal then + animName = AnimNames.NormalToFront[actorIndex] + elseif status == ShowStatus.Back then + animName = AnimNames.BackToFront[actorIndex] + end + end + + return animName +end + +return XUiGridMovieActor \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMovie/XUiGridReviewItem.lua b/Resources/Scripts/XUi/XUiMovie/XUiGridReviewItem.lua new file mode 100644 index 00000000..44be2ffc --- /dev/null +++ b/Resources/Scripts/XUi/XUiMovie/XUiGridReviewItem.lua @@ -0,0 +1,24 @@ +local XUiGridReviewItem = XClass(nil, "XUiGridReviewItem") + +function XUiGridReviewItem:Ctor(ui, data) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:Refresh(data) +end + +function XUiGridReviewItem:Refresh(data) + self.TxtName.text = data.RoleName + self.TxtWords.text = data.Content +end + +function XUiGridReviewItem:SetTextColor(color) + self.TxtWords.color = color + self.TxtName.color = color +end + +function XUiGridReviewItem:GetTextColor() + return self.TxtWords.color +end + +return XUiGridReviewItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMovie/XUiGridSingleDialog.lua b/Resources/Scripts/XUi/XUiMovie/XUiGridSingleDialog.lua new file mode 100644 index 00000000..95f5cfee --- /dev/null +++ b/Resources/Scripts/XUi/XUiMovie/XUiGridSingleDialog.lua @@ -0,0 +1,47 @@ +local stringUtf8Len = string.Utf8Len +local DefaultColor = CS.UnityEngine.Color.white + +local XUiGridSingleDialog = XClass(nil, "XUiGridSingleDialog") + +function XUiGridSingleDialog:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiGridSingleDialog:Refresh(dialogContent, color, duration, typeWriterCb) + local txtWords = self.TxtWords + local typeWriter = self.TypeWriter + txtWords.text = dialogContent + + self.DialogContent = dialogContent + + if color then + txtWords.color = XUiHelper.Hexcolor2Color(color) + end + + if duration then + typeWriter.Duration = duration ~= 0 and duration or stringUtf8Len(dialogContent) * XMovieConfigs.TYPE_WRITER_SPEED + typeWriter:Play() + end + + if typeWriterCb then + typeWriter.CompletedHandle = typeWriterCb + end +end + +function XUiGridSingleDialog:Reset() + local txtWords = self.TxtWords + txtWords.text = "" + txtWords.color = DefaultColor + + local typeWriter = self.TypeWriter + typeWriter:Stop() + typeWriter.CompletedHandle = nil +end + +function XUiGridSingleDialog:StopTypeWriter() + self.TypeWriter:Stop() +end + +return XUiGridSingleDialog \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMovie/XUiMovie.lua b/Resources/Scripts/XUi/XUiMovie/XUiMovie.lua new file mode 100644 index 00000000..1adc5184 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMovie/XUiMovie.lua @@ -0,0 +1,144 @@ +local tableInsert = table.insert +local CSXTextManagerGetText = CS.XTextManager.GetText +local TipSkipTitle = CSXTextManagerGetText("MovieSkipTipTitle") +local TipSkipContent = CSXTextManagerGetText("MovieSkipTipContent") +local XUiGridMovieActor = require("XUi/XUiMovie/XUiGridMovieActor") + +local XUiMovie = XLuaUiManager.Register(XLuaUi, "UiMovie") + +function XUiMovie:OnAwake() + self:AddListener() +end + +function XUiMovie:OnStart(hideSkipBtn) + self:InitView() + + self.BtnSkip.gameObject:SetActiveEx(not hideSkipBtn) + XEventManager.DispatchEvent(XEventId.EVENT_MOVIE_UI_OPEN, self) +end + +function XUiMovie:OnEnable() + XEventManager.DispatchEvent(XEventId.EVENT_MOVIE_BREAK_BLOCK) +end + +function XUiMovie:OnDestroy() + XEventManager.DispatchEvent(XEventId.EVENT_MOVIE_UI_DESTROY) +end + +function XUiMovie:InitView() + self.FullScreenDialogUsingIndex = 1 + self.FullScreenDialogGrids = {} + self.AnimPrefabDic = {} + self.EffectGoDic = {} + self.PanelEffects = { + self.EffectBg, + self.EffectCha, + self.EffectFull, + } + self.Actors = {} + for actorIndex = 1, XMovieConfigs.MAX_ACTOR_NUM do + tableInsert(self.Actors, XUiGridMovieActor.New(self, actorIndex)) + end + + self.PanelElement.gameObject:SetActiveEx(true) + self.PanelDialog.gameObject:SetActiveEx(false) + self.PanelFullScreenDialog.gameObject:SetActiveEx(false) + self.PanelSelectableDialog.gameObject:SetActiveEx(false) + self.PanelTheme.gameObject:SetActiveEx(false) + self.PanelSummer.gameObject:SetActiveEx(false) + self.PanelSelectableDialog.gameObject:SetActiveEx(false) + self.PanelMask.gameObject:SetActiveEx(false) + self.PanelStaff.gameObject:SetActiveEx(false) +end + +function XUiMovie:AddListener() + self.BtnSkip.CallBack = function() self:OnClickBtnSkip() end + self.BtnReview.CallBack = function() self:OnClickBtnReview() end + self.BtnAuto.CallBack = function() self:OnClickBtnAuto() end + self.BtnTurn.CallBack = function() self:OnClickBtnTurn() end + self.BtnHide.CallBack = function() self:OnClickBtnHide() end + self.PanelMaskInputHandler:AddPointerClickListener(handler(self, self.OnClickBtnPause)) + self.PanelHideMaskInputHandler:AddPointerClickListener(handler(self,self.OnClickHideMask)) +end + +function XUiMovie:OnClickBtnSkip() + local description = XDataCenter.MovieManager.GetMovieDescription() + local closeCb = function() + XDataCenter.MovieManager.StopMovie() + end + if description and description ~= "" then + XLuaUiManager.Open("UiStorySkipDialog", description, closeCb) + else + XUiManager.SystemDialogTip(TipSkipTitle, TipSkipContent, XUiManager.DialogType.Normal, nil, closeCb) + end +end + +function XUiMovie:OnClickBtnReview() + self:OpenChildUi("UiMovieReview") + self:ResetAutoPlay() +end + +function XUiMovie:OnClickHideMask() + self.PanelHideMask.gameObject:SetActiveEx(false) + self.PanelDialogCanvasGroup.alpha = 1 + self.TopBtnCanvasGroup.alpha = 1 +end + +function XUiMovie:OnClickBtnHide() + self.PanelHideMask.gameObject:SetActiveEx(true) + self.PanelDialogCanvasGroup.alpha = 0 + self.TopBtnCanvasGroup.alpha = 0 + self:ResetAutoPlay() +end + +function XUiMovie:OnClickBtnPause() + if not XDataCenter.MovieManager.IsAutoPlay() then + return + end + XDataCenter.MovieManager.SwitchMovieState() + local isMoviePause = XDataCenter.MovieManager.IsMoviePause() + if isMoviePause then + self:PlayAnimation("ImgPauseIconEnable") + else + self:PlayAnimation("ImgPauseIconDisable") + end + self.ImgPauseIcon.gameObject:SetActiveEx(isMoviePause) +end +function XUiMovie:OnClickBtnAuto() + XDataCenter.MovieManager.SwitchAutoPlay() + + if XDataCenter.MovieManager.IsMoviePause() then + XDataCenter.MovieManager.SetMoviePause(false) + end + local isAutoPlay = XDataCenter.MovieManager.IsAutoPlay() + self.BtnTurn:SetDisable(isAutoPlay, not isAutoPlay) + self.PanelMask.gameObject:SetActiveEx(isAutoPlay) + self.ImgPauseIcon.gameObject:SetActiveEx(false) +end + +function XUiMovie:OnClickBtnTurn() + XDataCenter.MovieManager.BackToLastAction() +end + +function XUiMovie:ResetAutoPlay() + if XDataCenter.MovieManager.IsAutoPlay() then + self.BtnAuto:SetButtonState(XUiButtonState.Normal) + self:OnClickBtnAuto() + end +end + +function XUiMovie:GetActor(actorIndex) + local actor = self.Actors[actorIndex] + if not actor then + XLog.Error("XUiMovie:GetActor error:ActorIndex is not match, actorIndex is " .. actorIndex) + end + return actor +end + +function XUiMovie:Hide() + self.GameObject:SetActiveEx(false) +end + +function XUiMovie:Show() + self.GameObject:SetActiveEx(true) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMovie/XUiMovieReview.lua b/Resources/Scripts/XUi/XUiMovie/XUiMovieReview.lua new file mode 100644 index 00000000..a7ff29a6 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMovie/XUiMovieReview.lua @@ -0,0 +1,53 @@ +local next = next +local XUiGridReviewItem = require("XUi/XUiMovie/XUiGridReviewItem") + +local XUiMovieReview = XLuaUiManager.Register(XLuaUi, "UiMovieReview") + +function XUiMovieReview:OnAwake() + self.GridReviewItem.gameObject:SetActiveEx(false) + self.HighlightColor = XUiHelper.Hexcolor2Color(CS.XGame.ClientConfig:GetString("MovieReviewHighlightColor")) + self:AddListener() +end + +function XUiMovieReview:OnEnable() + self:RefreshView() +end + +function XUiMovieReview:RefreshView() + local reviewDialogList = XDataCenter.MovieManager.GetReviewDialogList() + --if not next(reviewDialogList) then return end + + self.GridList = self.GridList or {} + self.LastColor = self.LastColor or {} + for i, data in pairs(reviewDialogList) do + local grid = self.GridList[i] + if not grid then + local obj = CS.UnityEngine.Object.Instantiate(self.GridReviewItem) + grid = XUiGridReviewItem.New(obj, data) + grid.Transform:SetParent(self.PanelReviewContent, false) + self.GridList[i] = grid + self.LastColor[i] = grid:GetTextColor() + end + grid.GameObject:SetActiveEx(true) + grid:Refresh(data) + grid:SetTextColor(i == #reviewDialogList and self.HighlightColor or self.LastColor[i]) + end + + local dataNum = #reviewDialogList + local gridNum = #self.GridList + for i = dataNum + 1, gridNum do + self.GridList[i].GameObject:SetActiveEx(false) + end + if self.SViewReview then + self.SViewReview.verticalNormalizedPosition = 0 + end + CS.UnityEngine.UI.LayoutRebuilder.ForceRebuildLayoutImmediate(self.PanelReviewContent) +end + +function XUiMovieReview:AddListener() + self.BtnClose.CallBack = function() self:OnClickBtnClose() end +end + +function XUiMovieReview:OnClickBtnClose() + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMovie/XUiStorySkipDialog.lua b/Resources/Scripts/XUi/XUiMovie/XUiStorySkipDialog.lua new file mode 100644 index 00000000..9596e7f5 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMovie/XUiStorySkipDialog.lua @@ -0,0 +1,33 @@ +local XUiStorySkipDialog = XLuaUiManager.Register(XLuaUi, "UiStorySkipDialog") + +function XUiStorySkipDialog:OnAwake() + self:AddListener() +end + +function XUiStorySkipDialog:OnStart(descpription, okCallBack, cancelCallBack) + self.OkCallBack = okCallBack + self.CancelCallBack = cancelCallBack + self.TxtInfo.text = descpription or "" +end + +function XUiStorySkipDialog:AddListener() + self:RegisterClickEvent(self.BtnTanchuangClose, self.OnBtnCloseClick) + self:RegisterClickEvent(self.BtnClose, self.OnBtnCloseClick) + self:RegisterClickEvent(self.BtnConfirm, self.OnBtnConfirmClick) +end + +function XUiStorySkipDialog:OnBtnConfirmClick() + self:Close() + if self.OkCallBack then + self.OkCallBack() + end +end + +function XUiStorySkipDialog:OnBtnCloseClick() + self:Close() + if self.CancelCallBack then + self.CancelCallBack() + end +end + +return XUiStorySkipDialog \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMovieAssemble/XUiMovieAssemble.lua b/Resources/Scripts/XUi/XUiMovieAssemble/XUiMovieAssemble.lua new file mode 100644 index 00000000..50c7b357 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMovieAssemble/XUiMovieAssemble.lua @@ -0,0 +1,66 @@ +local CSXTextManagerGetText = CS.XTextManager.GetText + +local XUiMovieAssemble = XLuaUiManager.Register(XLuaUi, "UiMovieAssemble") +local XUiMovieAssembleStage = require("XUi/XUiMovieAssemble/XUiMovieAssembleStage") + + +function XUiMovieAssemble:OnStart(assembleId) + self.StagePool = {} + self.AssembleId = assembleId + self:Refresh() +end + +function XUiMovieAssemble:Refresh() + local bgImgUrl = XMovieAssembleConfig.GetBgImgUrlById(self.AssembleId) + if bgImgUrl and bgImgUrl ~= "" then + self.RImgBg:SetRawImage(bgImgUrl) + end + + local uiPrefabUrl = XMovieAssembleConfig.GetUiPrefabById(self.AssembleId) + if uiPrefabUrl and uiPrefabUrl ~= "" then + local uiPrefab = self.UiPrefabRoot:LoadPrefab(uiPrefabUrl) + if uiPrefab then + self:InitUiPrefab(uiPrefab, function () + if self.BtnBack then + self.BtnBack.CallBack = function () self:Close() end + end + if self.BtnMainUi then + self.BtnMainUi.CallBack = function () XLuaUiManager.RunMain() end + end + + self:RefreshContent() + end) + end + end +end + +function XUiMovieAssemble:InitUiPrefab(uiPrefab, cb) -- 把Ui预制体的引用添加到父UI上 + local obj = uiPrefab.transform:GetComponent("UiObject") + if obj ~= nil then + for i = 0, obj.NameList.Count - 1 do + self[obj.NameList[i]] = obj.ObjList[i] + end + + if cb then cb() end + end +end + +function XUiMovieAssemble:RefreshContent() + if self.PanelStageContent then + local stagePrefabUrl = XMovieAssembleConfig.GetMovieTmpPrefabById(self.AssembleId) + self.StageTmpObj = CS.XResourceManager.Load(stagePrefabUrl).Asset + local movieIds = XMovieAssembleConfig.GetMovieTmpIdsById(self.AssembleId) + local onCreat = function (item, movieId) + item:OnCreat(movieId) + end + + XUiHelper.CreateTemplates(self, self.StagePool, movieIds, XUiMovieAssembleStage.New, self.StageTmpObj, self.PanelStageContent, onCreat) + end +end + +function XUiMovieAssemble:PlayMovie(movieId) + local storyId = XMovieAssembleConfig.GetMovieIdById(movieId) + XDataCenter.MovieManager.PlayMovie(storyId) + XSaveTool.SaveData(string.format("%s%s%s", XMovieAssembleConfig.MovieAssembleWatchedKey, XPlayer.Id, movieId), XMovieAssembleConfig.MovieWatchedState.Watched) + XEventManager.DispatchEvent(XEventId.EVENT_MOVIE_ASSEMBLE_WATCH_MOVIE) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMovieAssemble/XUiMovieAssembleStage.lua b/Resources/Scripts/XUi/XUiMovieAssemble/XUiMovieAssembleStage.lua new file mode 100644 index 00000000..3abd35b0 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMovieAssemble/XUiMovieAssembleStage.lua @@ -0,0 +1,83 @@ +local tableInsert = table.insert +local CsXTextManagerGetText = CS.XTextManager.GetText +local XUiMovieAssembleStage = XClass(nil, "XUiMovieAssembleStage") + +function XUiMovieAssembleStage:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + + self:Init() +end + +function XUiMovieAssembleStage:Init() + self.GameObject:SetActiveEx(true) + self:AutoRegisterListener() +end + +function XUiMovieAssembleStage:OnCreat(movieId) + self.MovieId = movieId + if self.RImgStageNorBg then + local unlockImgUrl = XMovieAssembleConfig.GetMovieUnlockBgUrlById(self.MovieId) + if unlockImgUrl and unlockImgUrl ~= "" then + self.RImgStageNorBg:SetRawImage(unlockImgUrl) + end + end + + if self.RImgStageLockBg then + local lockImgUrl = XMovieAssembleConfig.GetMovieLockedBgUrlById(self.MovieId) + if lockImgUrl and lockImgUrl ~= "" then + self.RImgStageLockBg:SetRawImage(lockImgUrl) + end + end + + local isUnlock = false + local conditionId = XMovieAssembleConfig.GetMovieConditionIdById(self.MovieId) + if conditionId and conditionId ~= 0 then + isUnlock = XConditionManager.CheckCondition(conditionId) + else + isUnlock = true + end + self:SetUnLock(isUnlock) + self:InitRedPoint() +end + +function XUiMovieAssembleStage:SetUnLock(bool) + if self.StageMaskUnlocking then self.StageMaskUnlocking.gameObject:SetActiveEx(bool) end + if self.StageMaskLocking then self.StageMaskLocking.gameObject:SetActiveEx(not bool) end +end + +function XUiMovieAssembleStage:AutoRegisterListener() + if self.BtnPressArea then + self.BtnPressArea.CallBack = function () + self:OnClick() + end + end +end + +function XUiMovieAssembleStage:OnClick() + if self.MovieId then + local conditionId = XMovieAssembleConfig.GetMovieConditionIdById(self.MovieId) + if conditionId and conditionId ~= 0 then + local isUnlock, desc = XConditionManager.CheckCondition(conditionId) + if isUnlock then + self.RootUi:PlayMovie(self.MovieId) + else + XUiManager.TipMsg(CsXTextManagerGetText("MovieAssembleConditionDesc", desc)) + end + else + self.RootUi:PlayMovie(self.MovieId) + end + end +end + +function XUiMovieAssembleStage:InitRedPoint() + if self.RedId then + XRedPointManager.RemoveRedPointEvent(self.RedId) + self.RedId = nil + end + self.RedId = XRedPointManager.AddRedPointEvent(self.BtnPressArea.ReddotObj, nil, nil, {XRedPointConditions.Types.CONDITION_MOVIE_ASSEMBLE_MOVIE_RED}, self.MovieId, true) +end + +return XUiMovieAssembleStage \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMultiplayerFightGrade/XUiGridFightDataItem.lua b/Resources/Scripts/XUi/XUiMultiplayerFightGrade/XUiGridFightDataItem.lua new file mode 100644 index 00000000..98034d76 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMultiplayerFightGrade/XUiGridFightDataItem.lua @@ -0,0 +1,15 @@ +local XUiGridFightDataItem = XClass(nil, "XUiGridFightDataItem") + +function XUiGridFightDataItem:Ctor(ui, name) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.TxtTitle.text = name +end + +function XUiGridFightDataItem:Refresh(mvp, value) + self.ImgMvp.gameObject:SetActive(mvp and true or false) + self.TxtValue.text = value +end + +return XUiGridFightDataItem diff --git a/Resources/Scripts/XUi/XUiMultiplayerFightGrade/XUiGridFightGradeItem.lua b/Resources/Scripts/XUi/XUiMultiplayerFightGrade/XUiGridFightGradeItem.lua new file mode 100644 index 00000000..1646096c --- /dev/null +++ b/Resources/Scripts/XUi/XUiMultiplayerFightGrade/XUiGridFightGradeItem.lua @@ -0,0 +1,102 @@ +local XUiGridFightGradeItem = XClass(nil, "XUiGridFightGradeItem") +local XUiGridFightDataItem = require("XUi/XUiMultiplayerFightGrade/XUiGridFightDataItem") + +function XUiGridFightGradeItem:Ctor(ui, parent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Parent = parent + XTool.InitUiObject(self) + XUiHelper.RegisterClickEvent(self, self.BtnReport, self.OnBtnReportClick) + XUiHelper.RegisterClickEvent(self, self.BtnLike, self.OnBtnLikeClick) + XUiHelper.RegisterClickEvent(self, self.BtnAddFriend, self.OnBtnAddFriendClick) +end + +function XUiGridFightGradeItem:OnBtnReportClick() + if self.IsAlreadyReport then + return + end + XUiManager.TipText("ReportFinish") + self.BtnReport.ButtonState = CS.UiButtonState.Disable + self.IsAlreadyReport = true +end + +function XUiGridFightGradeItem:OnBtnLikeClick() + self.Parent:OnAddLike(self.PlayerData.Id) +end + +function XUiGridFightGradeItem:OnBtnAddFriendClick() + self.Parent:OnApplyFriend(self.PlayerData.Id) +end + +function XUiGridFightGradeItem:Init(playerData, playerCount) + local medalConfig = XMedalConfigs.GetMeadalConfigById(playerData.MedalId) + local medalIcon = nil + if medalConfig then + medalIcon = medalConfig.MedalIcon + end + if medalIcon ~= nil then + self.ImgMedalIcon:SetRawImage(medalIcon) + self.ImgMedalIcon.gameObject:SetActiveEx(true) + else + self.ImgMedalIcon.gameObject:SetActiveEx(false) + end + + self.PlayerData = playerData + local headIcon = XDataCenter.CharacterManager.GetCharSmallHeadIconByCharacter(playerData.Character) + self.RImgIcon:SetRawImage(headIcon) + self.TxtName.text = XDataCenter.SocialManager.GetPlayerRemark(playerData.Id, playerData.Name) + local isArenaOnline = playerData.StageType and playerData.StageType == XDataCenter.FubenManager.StageType.ArenaOnline + local isPass = playerData.HaveFirstPass and playerCount > 1 + self.PanelArenaOnline.gameObject:SetActiveEx(isArenaOnline and isPass) + + local item1 = CS.UnityEngine.GameObject.Instantiate(self.GridFightDataItem, self.PanelFightDataContainer) + local item2 = CS.UnityEngine.GameObject.Instantiate(self.GridFightDataItem, self.PanelFightDataContainer) + --TODO 配置名字 + self.GridFightDataList = { + XUiGridFightDataItem.New(self.GridFightDataItem, CS.XTextManager.GetText("FightGradeOutput")), + XUiGridFightDataItem.New(item1, CS.XTextManager.GetText("FightGradeCure")), + XUiGridFightDataItem.New(item2, CS.XTextManager.GetText("FightGradeBreak")), + } +end + +function XUiGridFightGradeItem:Refresh(dpsData) + if dpsData then + self.GridFightDataList[1]:Refresh(dpsData.IsDamageTotalMvp, dpsData.DamageTotal) + self.GridFightDataList[2]:Refresh(dpsData.IsCureMvp, dpsData.Cure) + self.GridFightDataList[3]:Refresh(dpsData.IsBreakEndureMvp, dpsData.BreakEndure) + else + self.GridFightDataList[1]:Refresh(false, 0) + self.GridFightDataList[2]:Refresh(false, 0) + self.GridFightDataList[3]:Refresh(false, 0) + end +end + +function XUiGridFightGradeItem:SwitchNormal() + self.PanelOperation.gameObject:SetActiveEx(true) + self.TxtMyself.gameObject:SetActiveEx(false) + self.BtnLike.gameObject:SetActiveEx(true) + self.ImgLikeDisabled.gameObject:SetActiveEx(false) + self.ImgLikeAlready.gameObject:SetActiveEx(false) +end + +function XUiGridFightGradeItem:SwitchMyself() + self.PanelOperation.gameObject:SetActiveEx(false) + self.TxtMyself.gameObject:SetActiveEx(true) + self.BtnLike.gameObject:SetActiveEx(false) + self.ImgLikeDisabled.gameObject:SetActiveEx(false) + self.ImgLikeAlready.gameObject:SetActiveEx(false) +end + +function XUiGridFightGradeItem:SwitchDisabledLike() + self.ImgLikeDisabled.gameObject:SetActiveEx(true) + self.ImgLikeAlready.gameObject:SetActiveEx(false) + self.BtnLike.gameObject:SetActiveEx(false) +end + +function XUiGridFightGradeItem:SwitchAlreadyLike() + self.ImgLikeDisabled.gameObject:SetActiveEx(false) + self.ImgLikeAlready.gameObject:SetActiveEx(true) + self.BtnLike.gameObject:SetActiveEx(false) +end + +return XUiGridFightGradeItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMultiplayerFightGrade/XUiMultiplayerFightGrade.lua b/Resources/Scripts/XUi/XUiMultiplayerFightGrade/XUiMultiplayerFightGrade.lua new file mode 100644 index 00000000..411608c0 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMultiplayerFightGrade/XUiMultiplayerFightGrade.lua @@ -0,0 +1,108 @@ +local XUiMultiplayerFightGrade = XLuaUiManager.Register(XLuaUi, "UiMultiplayerFightGrade") +local XUiGridFightGradeItem = require("XUi/XUiMultiplayerFightGrade/XUiGridFightGradeItem") + +local countDownTime = CS.XGame.Config:GetInt("OnlinePraiseCountDown") + +function XUiMultiplayerFightGrade:OnAwake() + self:RegisterClickEvent(self.BtnContinue, self.OnBtnContinueClick) +end + +function XUiMultiplayerFightGrade:OnStart(cb) + self:Init() + self.Cb = cb + XEventManager.AddEventListener(XEventId.EVENT_ROOM_KICKOUT, self.OnKickOut, self) +end + +function XUiMultiplayerFightGrade:OnDestroy() + XEventManager.RemoveEventListener(XEventId.EVENT_ROOM_KICKOUT, self.OnKickOut, self) +end + +function XUiMultiplayerFightGrade:OnKickOut() + XLuaUiManager.Remove("UiMultiplayerRoom") +end + +function XUiMultiplayerFightGrade:OnBtnContinueClick() + if not self.IsCountDownFinish then + return + end + + if self.Cb then + self.Cb() + else + self:Close() + end +end + +function XUiMultiplayerFightGrade:Init() + local beginData = XDataCenter.FubenManager.GetFightBeginData() + local PlayerList = beginData.PlayerList + local dpsTable = XDataCenter.FubenManager.LastDpsTable + + local index = 0 + self.GridList = {} + for _, v in pairs(PlayerList) do + local ui + if index == 0 then + ui = self.GridFightGradeItem + else + ui = CS.UnityEngine.GameObject.Instantiate(self.GridFightGradeItem, self.PanelFightGradeContainer) + end + self.GridList[v.Id] = XUiGridFightGradeItem.New(ui, self) + index = index + 1 + end + + for _, v in pairs(PlayerList) do + local dps = dpsTable[v.Id] + local grid = self.GridList[v.Id] + grid:Init(v, index) + grid:Refresh(dps) + if v.Id == XPlayer.Id then + grid:SwitchMyself() + else + grid:SwitchNormal() + end + end + + self:StartCountDown() +end + +function XUiMultiplayerFightGrade:StartCountDown() + self.IsCountDownFinish = false + self.TxtContinue.gameObject:SetActive(false) + self.PanelCountDown.gameObject:SetActive(true) + local startTicks = CS.XTimerManager.Ticks + local refresh = function(timer) + if not self.GameObject or not self.GameObject:Exist() then + self.IsCountDownFinish = true + XScheduleManager.UnSchedule(timer) + return + end + local t = countDownTime - (CS.XTimerManager.Ticks - startTicks) / CS.System.TimeSpan.TicksPerSecond + self.ImgCountDownBarRight.fillAmount = t / countDownTime + self.ImgCountDownBarLeft.fillAmount = t / countDownTime + if t <= 0 then + self.IsCountDownFinish = true + XScheduleManager.UnSchedule(timer) + self.TxtContinue.gameObject:SetActive(true) + self.PanelCountDown.gameObject:SetActive(false) + end + end + XScheduleManager.ScheduleForever(refresh, 0) +end + +function XUiMultiplayerFightGrade:OnAddLike(playerId) + XDataCenter.RoomManager.AddLike(playerId) + for k, v in pairs(self.GridList) do + if k ~= XPlayer.Id then + if k == playerId then + v:SwitchAlreadyLike() + else + v:SwitchDisabledLike() + end + end + end +end + +function XUiMultiplayerFightGrade:OnApplyFriend(playerId) + XDataCenter.SocialManager.ApplyFriend(playerId) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMultiplayerInviteFriend/XUiGridInviteFriendItem.lua b/Resources/Scripts/XUi/XUiMultiplayerInviteFriend/XUiGridInviteFriendItem.lua new file mode 100644 index 00000000..8a65e5fb --- /dev/null +++ b/Resources/Scripts/XUi/XUiMultiplayerInviteFriend/XUiGridInviteFriendItem.lua @@ -0,0 +1,67 @@ +local XUiGridInviteFriendItem = XClass(nil, "XUiGridInviteFriendItem") + +function XUiGridInviteFriendItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.BtnInvite.CallBack = handler(self, self.OnBtnInviteClick) +end + +function XUiGridInviteFriendItem:SetRootUi(parent) + self.Parent = parent +end + +function XUiGridInviteFriendItem:OnBtnInviteClick() + if not self.Data.IsOnline then + return + end + self.Parent:OnClickInvite(self.Data) + self.Invited.gameObject:SetActive(true) + self.BtnInvite.gameObject:SetActive(false) +end + +function XUiGridInviteFriendItem:Refresh(data, invited) + invited = invited or false + self.Data = data + self.TxtName.text = XDataCenter.SocialManager.GetPlayerRemark(data.FriendId, data.NickName) + + XUiPlayerLevel.UpdateLevel(data.Level, self.TxtLevel) + + if data.Sign == nil or (string.len(data.Sign) == 0) then + local text = CS.XTextManager.GetText('CharacterSignTip') + self.TxtSign.text = text + else + self.TxtSign.text = data.Sign + end + + XDataCenter.PlayerInfoManager.RequestPlayerInfoData(data.FriendId, function (tmpData) + self.TxtPraiseLevel.text = tmpData.Likes + if tmpData.FriendInfo then + self.TxtFetterLevel.text = tmpData.FriendInfo.FetterExp + else + self.TxtFetterLevel.text = 1 + end + end) + + self.Invited.gameObject:SetActive(invited) + self.BtnInvite.gameObject:SetActive(not invited) + if data.IsOnline then + self.TxtOnline.gameObject:SetActive(true) + self.TxtTime.gameObject:SetActive(false) + self.HeadOnLine.gameObject:SetActive(true) + self.HeadOffLine.gameObject:SetActive(false) + XUiPLayerHead.InitPortrait(data.Icon, data.HeadFrameId, self.HeadOnLine) + self.BtnInvite.ButtonState = CS.UiButtonState.Normal + else + self.TxtOnline.gameObject:SetActive(false) + local loginText = CS.XTextManager.GetText("FriendLatelyLogin") + self.TxtTime.text = loginText .. XUiHelper.CalcLatelyLoginTime(data.LastLoginTime) + self.TxtTime.gameObject:SetActive(true) + self.HeadOnLine.gameObject:SetActive(false) + self.HeadOffLine.gameObject:SetActive(true) + XUiPLayerHead.InitPortrait(data.Icon, data.HeadFrameId, self.HeadOffLine) + self.BtnInvite.ButtonState = CS.UiButtonState.Disable + end +end + +return XUiGridInviteFriendItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMultiplayerInviteFriend/XUiMultiplayerInviteFriend.lua b/Resources/Scripts/XUi/XUiMultiplayerInviteFriend/XUiMultiplayerInviteFriend.lua new file mode 100644 index 00000000..c594df58 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMultiplayerInviteFriend/XUiMultiplayerInviteFriend.lua @@ -0,0 +1,83 @@ +local XUiMultiplayerInviteFriend = XLuaUiManager.Register(XLuaUi, "UiMultiplayerInviteFriend") +local XUiGridInviteFriendItem = require("XUi/XUiMultiplayerInviteFriend/XUiGridInviteFriendItem") + +function XUiMultiplayerInviteFriend:OnAwake() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self.GridInviteFriendItem.gameObject:SetActive(false) +end + +function XUiMultiplayerInviteFriend:OnStart(...) + local args = {...} + self.Invited = {} + self.ItemsPool = {} + self.MultipleRoomType = args[1] or MultipleRoomType.Normal + self.DynamicListManager = XDynamicTableNormal.New(self.PanelContactView) + self.DynamicListManager:SetProxy(XUiGridInviteFriendItem) + self.DynamicListManager:SetDelegate(self) + XDataCenter.SocialManager.GetFriendsInfo(handler(self, self.Refresh)) +end + +function XUiMultiplayerInviteFriend:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:SetRootUi(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.FriendList[index] + grid:Refresh(data, self.Invited[data.FriendId]) + end +end + +function XUiMultiplayerInviteFriend:Refresh() + self.FriendList = XDataCenter.SocialManager.GetFriendList() + self.PanelTips.gameObject:SetActive(#self.FriendList == 0) + self.DynamicListManager:SetDataSource(self.FriendList) + self.DynamicListManager:ReloadDataASync() +end + +function XUiMultiplayerInviteFriend:OnClickInvite(data) + local content + if self.MultipleRoomType == MultipleRoomType.UnionKill then + local unionRoomData = XDataCenter.FubenUnionKillRoomManager.GetUnionRoomData() + if not unionRoomData then return end + content = XChatData.EncodeRoomMsg( + RoomMsgContentId.FrinedInvite, + XPlayer.Id, + 0, + unionRoomData.Id, + self.MultipleRoomType) + else + local roomId = XDataCenter.RoomManager.RoomData.Id + local stageId = XDataCenter.RoomManager.RoomData.StageId + local stateLevel = XDataCenter.RoomManager.RoomData.StageLevel + if self.MultipleRoomType == MultipleRoomType.ArenaOnline then + roomId = XDataCenter.RoomManager.RoomData.RoomId + stageId = XDataCenter.RoomManager.RoomData.ChallengeId + stateLevel = XDataCenter.RoomManager.RoomData.ChallengeLevel + end + content = XChatData.EncodeRoomMsg( + RoomMsgContentId.FrinedInvite, + XPlayer.Id, + stageId, + roomId, + self.MultipleRoomType, + stateLevel) + end + + local sendChat = {} + sendChat.ChannelType = ChatChannelType.Private + sendChat.MsgType = ChatMsgType.RoomMsg + sendChat.Content = content + sendChat.TargetIds = { data.FriendId } + self.Invited[data.FriendId] = true + XDataCenter.ChatManager.SendChat(sendChat, function() + XUiManager.TipText("OnlineSendWorldSuccess") + end, true) +end + +function XUiMultiplayerInviteFriend:OnBtnBackClick() + self:Close() +end + +function XUiMultiplayerInviteFriend:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMultiplayerRoom/XUiGridMulitiplayerRoomChar.lua b/Resources/Scripts/XUi/XUiMultiplayerRoom/XUiGridMulitiplayerRoomChar.lua new file mode 100644 index 00000000..be0816f5 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMultiplayerRoom/XUiGridMulitiplayerRoomChar.lua @@ -0,0 +1,367 @@ +local XUiGridMulitiplayerRoomChar = XClass(nil, "XUiGridMulitiplayerRoomChar") + +function XUiGridMulitiplayerRoomChar:Ctor(ui, parent, index, rolePanel, effectObj) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Parent = parent + self.Index = index + self.RolePanel = rolePanel + self.EffectObj = effectObj + XTool.InitUiObject(self) + + XUiHelper.RegisterClickEvent(self, self.BtnDetailInfo, self.OnBtnDetailInfoClick) + XUiHelper.RegisterClickEvent(self, self.BtnAddFriend, self.OnBtnAddFriendClick) + XUiHelper.RegisterClickEvent(self, self.BtnChangeLeader, self.OnBtnChangeLeaderClick) + XUiHelper.RegisterClickEvent(self, self.BtnKick, self.OnBtnKickClick) + XUiHelper.RegisterClickEvent(self, self.BtnItem, self.OnBtnItemClick) + XUiHelper.RegisterClickEvent(self, self.BtnFriend, self.OnBtnFriendClick) + XUiHelper.RegisterClickEvent(self, self.BtnWorld, self.OnBtnWorldClick) + XUiHelper.RegisterClickEvent(self, self.BtnTeam, self.OnBtnTeamClick) + + self.CharacterPets:GetObject("BtnClick").CallBack = function() + self:OnBtnItemClick() + end + + self.PanelCountDown.gameObject:SetActiveEx(false) +end + +function XUiGridMulitiplayerRoomChar:InitCharData(playerData) + self.PanelInfo.gameObject:SetActiveEx(true) + self.PanelHaveCharacter.gameObject:SetActiveEx(true) + self.PanelNoCharacter.gameObject:SetActiveEx(false) + self.PanelOperation.gameObject:SetActiveEx(false) + self:StopTimer() + self.PanelChat.gameObject:SetActiveEx(false) + self:RefreshPlayer(playerData) +end + +function XUiGridMulitiplayerRoomChar:InitEmpty() + self.PlayerData = nil + self.PanelInfo.gameObject:SetActiveEx(false) + self.PanelHaveCharacter.gameObject:SetActiveEx(false) + self.PanelNoCharacter.gameObject:SetActiveEx(true) + self.PanelInvite.gameObject:SetActiveEx(false) + self.PanelChat.gameObject:SetActiveEx(false) + self.PanelAssist.gameObject:SetActiveEx(false) + self.PanelStaminaBar.gameObject:SetActiveEx(false) + self:StopTimer() + self.RolePanel:HideRoleModel() + self:CloseEffctObje() +end + +function XUiGridMulitiplayerRoomChar:CheckOpenEffctObje() + if not self.EffectObj then + return + end + if not self.PlayerData then + self.EffectObj.gameObject:SetActiveEx(false) + return + end + + if self.Parent:CheckActiveOn(self.PlayerData.Id) then + self.EffectObj.gameObject:SetActiveEx(false) + self.EffectObj.gameObject:SetActiveEx(true) + else + self.EffectObj.gameObject:SetActiveEx(false) + end +end + +function XUiGridMulitiplayerRoomChar:CloseEffctObje() + if not self.EffectObj then return end + self.EffectObj.gameObject:SetActiveEx(false) +end + +function XUiGridMulitiplayerRoomChar:RefreshPlayer(playerData) + local medalConfig = XMedalConfigs.GetMeadalConfigById(playerData.MedalId) + local medalIcon = nil + if medalConfig then + medalIcon = medalConfig.MedalIcon + end + if medalIcon ~= nil then + self.ImgMedalIcon:SetRawImage(medalIcon) + self.ImgMedalIcon.gameObject:SetActiveEx(true) + else + self.ImgMedalIcon.gameObject:SetActiveEx(false) + end + self.PlayerData = playerData + self.TxtName.text = XDataCenter.SocialManager.GetPlayerRemark(playerData.Id, playerData.Name) + + XUiPlayerLevel.UpdateLevel(playerData.Level, self.TxtLevel) + + self.ImgLeader.gameObject:SetActiveEx(playerData.Leader) + + -- 准备状态 + if playerData.State == XDataCenter.RoomManager.PlayerState.Select then + self.ImgReady.gameObject:SetActiveEx(false) + self.ImgModifying.gameObject:SetActiveEx(true) + elseif playerData.State == XDataCenter.RoomManager.PlayerState.Ready or playerData.Leader then + self.ImgReady.gameObject:SetActiveEx(true) + self.ImgModifying.gameObject:SetActiveEx(false) + else + self.ImgReady.gameObject:SetActiveEx(false) + self.ImgModifying.gameObject:SetActiveEx(false) + end + + -- 战斗类型 + local charId = playerData.FightNpcData.Character.Id + local quality = playerData.FightNpcData.Character.Quality + local npcId = XCharacterConfigs.GetCharNpcId(charId, quality) + local npcTemplate = XCharacterConfigs.GetNpcTemplate(npcId) + self.RImgArms:SetRawImage(XCharacterConfigs.GetNpcTypeIcon(npcTemplate.Type)) + + -- 战斗力 + self.TxtAbility.text = playerData.FightNpcData.Character.Ability + + local partner = XDataCenter.PartnerManager.CreatePartnerEntityByPartnerData(playerData.FightNpcData.Partner) + local IsHasPartner = partner and next(partner) + if IsHasPartner then + self.CharacterPets:GetObject("RImgType"):SetRawImage(partner:GetIcon()) + end + self.CharacterPets:GetObject("RImgType").gameObject:SetActiveEx(IsHasPartner) + self.CharacterPets.gameObject:SetActiveEx(IsHasPartner or playerData.Id == XPlayer.Id) + + -- 操作按钮状态 + local curRole = self.Parent:GetCurRole() + if curRole and curRole.Leader then + self.BtnChangeLeader.ButtonState = CS.UiButtonState.Normal + self.BtnKick.ButtonState = CS.UiButtonState.Normal + else + self.BtnChangeLeader.ButtonState = CS.UiButtonState.Disable + self.BtnKick.ButtonState = CS.UiButtonState.Disable + end + + -- 助战次数 + local stageInfo = XDataCenter.FubenManager.GetStageInfo(XDataCenter.RoomManager.RoomData.StageId) + if stageInfo.Type == XDataCenter.FubenManager.StageType.ArenaOnline then + self.PanelAssist.gameObject:SetActiveEx(playerData.HaveFirstPass) + self.TxtAssisitCount.text = playerData.AssistCount + else + self.PanelAssist.gameObject:SetActiveEx(false) + end + + -- 耐力条 + if stageInfo.Type == XDataCenter.FubenManager.StageType.ArenaOnline then + local active = not playerData.HaveFirstPass and playerData.Id == XPlayer.Id + self.PanelStaminaBar.gameObject:SetActiveEx(active) + if active then + local maxStamina = XArenaOnlineConfigs.MAX_NAILI + local curStamina = maxStamina - XDataCenter.ArenaOnlineManager.GetCharEndurance(charId) + local text = CS.XTextManager.GetText("RoomStamina", curStamina, maxStamina) + self.TxtMyStamina.text = text + self.ImgStaminaExpFill.fillAmount = curStamina / maxStamina + end + else + self.PanelStaminaBar.gameObject:SetActiveEx(false) + end + + -- 模型 + self.RolePanel:UpdateCharacterModelByFightNpcData(playerData.FightNpcData) + self.RolePanel:ShowRoleModel() + self:CheckOpenEffctObje() +end + +function XUiGridMulitiplayerRoomChar:ShowOperationPanel() + self.IsShowOperationPanel = not self.IsShowOperationPanel + if self.IsShowOperationPanel then + -- 操作按钮状态 + local curRole = self.Parent:GetCurRole() + if curRole and curRole.Leader then + self.BtnChangeLeader.ButtonState = CS.UiButtonState.Normal + self.BtnKick.ButtonState = CS.UiButtonState.Normal + else + self.BtnChangeLeader.ButtonState = CS.UiButtonState.Disable + self.BtnKick.ButtonState = CS.UiButtonState.Disable + end + end + self.PanelOperation.gameObject:SetActiveEx(self.IsShowOperationPanel) +end + +function XUiGridMulitiplayerRoomChar:ShowInvitePanel() + self.IsShowInvitePanel = not self.IsShowInvitePanel + self.PanelInvite.gameObject:SetActiveEx(self.IsShowInvitePanel) +end + +function XUiGridMulitiplayerRoomChar:ShowSameCharTips(enable) + self.PanelSameCharTips.gameObject:SetActive(enable) +end + +function XUiGridMulitiplayerRoomChar:CloseAllOperationPanel() + self.Parent:CloseAllOperationPanel() +end + +function XUiGridMulitiplayerRoomChar:CloseOperationPanelAndInvitePanel() + if self.PlayerData then + self.PanelOperation.gameObject:SetActiveEx(false) + self.IsShowOperationPanel = false + else + self.PanelInvite.gameObject:SetActiveEx(false) + self.IsShowInvitePanel = false + end +end + +function XUiGridMulitiplayerRoomChar:OpenSelectCharView() + local playerData = self.PlayerData + if not playerData or playerData.State == XDataCenter.RoomManager.PlayerState.Ready then + XUiManager.TipText("OnlineCancelReadyBeforeSelectCharacter") + return + end + + XDataCenter.RoomManager.BeginSelectRequest() + local stageId = XDataCenter.RoomManager.RoomData.StageId + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + local characterLimitType = XFubenConfigs.GetStageCharacterLimitType(stageId) + local limitBuffId = XFubenConfigs.GetStageCharacterLimitBuffId(stageId) + XLuaUiManager.Open("UiRoomCharacter", { [1] = playerData.FightNpcData.Character.Id }, 1, handler(self, self.OnSelectCharacter), stageInfo.Type, characterLimitType, { IsHideQuitButton = true, LimitBuffId = limitBuffId, StageId = stageId }) +end + +function XUiGridMulitiplayerRoomChar:OnSelectCharacter(charIdMap) + if not XDataCenter.RoomManager.RoomData then + -- 被踢出房间不回调 + return + end + + XDataCenter.RoomManager.EndSelectRequest() + + local charId = charIdMap[1] + XDataCenter.RoomManager.Select(charId, function(code) + if code ~= XCode.Success then + XUiManager.TipCode(code) + return + end + if XDataCenter.RoomManager.StageInfo.Type == XDataCenter.FubenManager.StageType.ArenaOnline then + if self.PlayerData.FightNpcData.Character.Id ~= charId then + self.Parent:InsertFightSuccessTips() + end + else + XUiManager.TipText("OnlineFightSuccess", XUiManager.UiTipType.Success) + end + end) +end + +function XUiGridMulitiplayerRoomChar:ShowCountDownPanel(enable) + self.PanelCountDown.gameObject:SetActiveEx(enable) +end + +function XUiGridMulitiplayerRoomChar:SetCountDownTime(second) + self.TxtCountDown.text = second +end + +-- 聊天相关 +function XUiGridMulitiplayerRoomChar:StopTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end + +function XUiGridMulitiplayerRoomChar:RefreshChat(chatDataLua) + local isEmoji = chatDataLua.MsgType == ChatMsgType.Emoji + local maxWorld = XFubenConfigs.ROOM_MAX_WORLD + self.LeftTime = XFubenConfigs.ROOM_WORLD_TIME + self:StopTimer() + if isEmoji then + local icon = XDataCenter.ChatManager.GetEmojiIcon(chatDataLua.Content) + self.RImgEmoji:SetRawImage(icon) + else + local str = string.InsertStr(chatDataLua.Content, maxWorld, "\n") + self.TxtDesc.text = str + end + + self.Timer = XScheduleManager.ScheduleForever(function() + self.LeftTime = self.LeftTime - 1 + if self.LeftTime <= 0 then + self:StopTimer() + self.PanelChat.gameObject:SetActiveEx(false) + return + end + end, XScheduleManager.SECOND, 0) + + self.PanelChat.gameObject:SetActiveEx(true) + self.PanelDailog.gameObject:SetActive(not isEmoji) + self.PanelEmoji.gameObject:SetActive(isEmoji) + self.PanelChatEnable:PlayTimelineAnimation() +end + +----------------------- 按钮回调 ----------------------- +function XUiGridMulitiplayerRoomChar:OnBtnDetailInfoClick() + -- 查看信息 + XDataCenter.PersonalInfoManager.ReqShowInfoPanel(self.PlayerData.Id, handler(self, self.CloseAllOperationPanel)) +end + +function XUiGridMulitiplayerRoomChar:OnBtnAddFriendClick() + -- 加好友 + XDataCenter.SocialManager.ApplyFriend(self.PlayerData.Id, handler(self, self.CloseAllOperationPanel)) +end + +function XUiGridMulitiplayerRoomChar:OnBtnChangeLeaderClick() + local curRole = self.Parent:GetCurRole() + if not curRole or not curRole.Leader then + return + end + + --转移队长 + XDataCenter.RoomManager.ChangeLeader(self.PlayerData.Id, handler(self, self.CloseAllOperationPanel)) +end + +function XUiGridMulitiplayerRoomChar:OnBtnKickClick() + local curRole = self.Parent:GetCurRole() + if not curRole or not curRole.Leader then + return + end + + --移出队伍 + XDataCenter.RoomManager.KickOut(self.PlayerData.Id, handler(self, self.CloseAllOperationPanel)) +end + +function XUiGridMulitiplayerRoomChar:OnBtnItemClick() + self.Parent:CloseAllOperationPanel(self.Index) + if self.PlayerData then + if self.PlayerData.Id == XPlayer.Id then + self:OpenSelectCharView() + else + self:ShowOperationPanel() + end + else + self:ShowInvitePanel() + end +end + +function XUiGridMulitiplayerRoomChar:OnBtnFriendClick() + self.Parent:CloseAllOperationPanel() + local roomData = XDataCenter.RoomManager.RoomData + if not roomData or not roomData.StageId then + return + end + + local roomType = MultipleRoomType.Normal + local stageInfo = XDataCenter.FubenManager.GetStageInfo(roomData.StageId) + if stageInfo.Type == XDataCenter.FubenManager.StageType.ArenaOnline then + roomType = MultipleRoomType.ArenaOnline + end + + XLuaUiManager.Open("UiMultiplayerInviteFriend", roomType) +end + +function XUiGridMulitiplayerRoomChar:OnBtnWorldClick() + self.Parent:CloseAllOperationPanel() + --邀请世界 + local cfgData = XDataCenter.FubenManager.GetStageCfg(XDataCenter.RoomManager.RoomData.StageId) + local content = CS.XTextManager.GetText("OnlineInviteFriend", XPlayer.Name, cfgData.Name) + local customContent = CS.XTextManager.GetText("OnlineInviteLink", XDataCenter.RoomManager.RoomData.Id .. "|" .. XDataCenter.RoomManager.RoomData.StageId) + local sendChat = {} + sendChat.ChannelType = ChatChannelType.World + sendChat.Content = content + sendChat.CustomContent = XMessagePack.Encode(customContent) + sendChat.MsgType = ChatMsgType.Normal + sendChat.TargetIds = { XPlayer.Id } + local callBack = function() + XUiManager.TipText("OnlineSendWorldSuccess") + end + XDataCenter.ChatManager.SendChat(sendChat, callBack, true) +end + +function XUiGridMulitiplayerRoomChar:OnBtnTeamClick() + self.Parent:CloseAllOperationPanel(self.Index) +end + +return XUiGridMulitiplayerRoomChar \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMultiplayerRoom/XUiGridMultiplayerDifficultyItem.lua b/Resources/Scripts/XUi/XUiMultiplayerRoom/XUiGridMultiplayerDifficultyItem.lua new file mode 100644 index 00000000..c0db3885 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMultiplayerRoom/XUiGridMultiplayerDifficultyItem.lua @@ -0,0 +1,27 @@ +local XUiGridMultiplayerDifficultyItem = XClass(nil, "XUiGridMultiplayerDifficultyItem") + +function XUiGridMultiplayerDifficultyItem:Ctor(ui, difficulty, cb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Difficulty = difficulty + self.Cb = cb + XTool.InitUiObject(self) + self.BtnSelect.CallBack = handler(self, self.OnBtnSelectClick) +end + +function XUiGridMultiplayerDifficultyItem:Refresh(levelControl) + self.TxtRecommend.text = CS.XTextManager.GetText("MultiplayerRoomRecommendAbility", levelControl.RecommendAbility) +end + +function XUiGridMultiplayerDifficultyItem:SetSelected(enable) + self.BtnSelect.ButtonState = enable and CS.UiButtonState.Disable or CS.UiButtonState.Normal + self.ImgSelected.gameObject:SetActive(enable) +end + +function XUiGridMultiplayerDifficultyItem:OnBtnSelectClick() + if self.Cb then + self.Cb(self.Difficulty) + end +end + +return XUiGridMultiplayerDifficultyItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMultiplayerRoom/XUiMultiplayerRoom.lua b/Resources/Scripts/XUi/XUiMultiplayerRoom/XUiMultiplayerRoom.lua new file mode 100644 index 00000000..c9e11ff1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMultiplayerRoom/XUiMultiplayerRoom.lua @@ -0,0 +1,1132 @@ +local XUiMultiplayerRoom = XLuaUiManager.Register(XLuaUi, "UiMultiplayerRoom") +local XUiGridMulitiplayerRoomChar = require("XUi/XUiMultiplayerRoom/XUiGridMulitiplayerRoomChar") +local XUiGridMultiplayerDifficultyItem = require("XUi/XUiMultiplayerRoom/XUiGridMultiplayerDifficultyItem") +local XUiPanelChangeStage = require("XUi/XUiMultiplayerRoom/XUiPanelChangeStage") +local XUiPanelActiveBuffMian = require("XUi/XUiMultiplayerRoom/XUiPanelActiveBuffMian") +local XUiPanelActiveBuff = require("XUi/XUiMultiplayerRoom/XUiPanelActiveBuff") +local CSXTextManagerGetText = CS.XTextManager.GetText +local MAX_CHAT_WIDTH = 450 +local CHAT_SUB_LENGTH = 18 +local IsFirstFriendEffect = "LocalValue_IsFirstFriendEffect"--是否是第一次在联机页面开启队友特效 +------------------------------ tips类 --------------------------- +local XUiTips = XClass(nil, "XUiTips") +function XUiTips:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiTips:SetText(desc) + self.TxtTips.text = desc +end + +function XUiTips:SetActiveEx(enable) + self.GameObject:SetActiveEx(enable) +end +--------------------------------------------------------- +local MAX_PLAYER_COUNT = 3 + +local ButtonState = { + ["Waiting"] = 1, + ["Fight"] = 2, + ["Ready"] = 3, + ["CancelReady"] = 4, +} + +local DifficultyType = { + ["Normal"] = 1, + ["Hart"] = 2, + ["Nightmare"] = 3, +} + +local TipsType = { + ["LevelTips"] = 1, --关卡提示 + ["ChuzhanTips"] = 2, --出战提示 + ["TongTiaoTips"] = 3, --同调提示 +} +function XUiMultiplayerRoom:OnAwake() + self.RoomKickCountDownTime = CS.XGame.Config:GetInt("RoomKickCountDownTime") + self.RoomKickCountDownShowTime = CS.XGame.Config:GetInt("RoomKickCountDownShowTime") + + local root = self.UiModelGo.transform + self.RoleModelList = {} + for i = 1, MAX_PLAYER_COUNT do + self.RoleModelList[i] = {} + local case = root:FindTransform("PanelModelCase" .. i) + local effectObj = root:FindTransform("ImgEffectTongDiao" .. i) + local roleModel = XUiPanelRoleModel.New(case, self.Name, nil, true) + self.RoleModelList[i].RoleModel = roleModel + self.RoleModelList[i].EffectObj = effectObj + end + + self.InFSetAbilityLimit = self.InFSetAbilityLimit:GetComponent("InputField") + + self:RegisterClickEvent(self.ToggleQuickMatch, self.OnToggleQuickMatchClick) + self:RegisterClickEvent(self.BtnFight, self.OnBtnFightClick) + self:RegisterClickEvent(self.BtnCancelReady, self.OnBtnCancelReadyClick) + self:RegisterClickEvent(self.BtnReady, self.OnBtnReadyClick) + self:RegisterClickEvent(self.BtnChat, self.OnBtnChatClick) + self:RegisterClickEvent(self.BtnChangeDifficulty, self.OnBtnChangeDifficultyClick) + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:RegisterClickEvent(self.BtnDifficultySelect, self.OnBtnDifficultySelectClick) + self:RegisterClickEvent(self.BtnCloseDifficulty, self.OnBtnCloseDifficultyClick) + self:RegisterClickEvent(self.BtnMapSelect, self.OnBtnMapsSelectClick) + self.BtnSetAbilityLimit.CallBack = handler(self, self.OnBtnSetAbilityLimitClick) + self.BtnCloseAbilityLimit.CallBack = handler(self, self.OnBtnCloseAbilityLimitClick) + self.BtnCancel.CallBack = handler(self, self.OnBtnCloseAbilityLimitClick) + self.BtnConfirmSetAbilityLimit.CallBack = handler(self, self.OnBtnConfirmSetAbilityLimitClick) + self.BtnAutoMatch.CallBack = handler(self, self.OnBtnAutoMatchClick) + self.BtnSpecialEffects.CallBack = handler(self, self.OnBtnSpecialEffectsClick) + self.BtnChangeStage.CallBack = handler(self, self.OnBtnChangeStageClick) + local actionIcon = XDataCenter.ItemManager.GetItemIcon(XDataCenter.ItemManager.ItemId.ActionPoint) + self.RImgActionIcon:SetRawImage(actionIcon) + self.BtnGroup = { + [ButtonState.Waiting] = self.BtnWaiting.gameObject, + [ButtonState.Fight] = self.BtnFight.gameObject, + [ButtonState.Ready] = self.BtnReady.gameObject, + [ButtonState.CancelReady] = self.BtnCancelReady.gameObject, + } + + self:InitCharItems() + + self:InitDifficultyButtons() + + self:InitSpecialEffectsButton() + + self:InitSummerEpisodeMapSelectBtn() + + self.TipsList = { + XUiTips.New(self.PanelTips) + } + + self.PanelDifficulty.gameObject:SetActiveEx(false) + self.PanelChangeDifficulty.gameObject:SetActiveEx(false) + self.PanelAbilityLimit.gameObject:SetActiveEx(false) + + self.ChangeStagePanel = XUiPanelChangeStage.New(self.PanelChangeStage) + self.ActiveBuffMainPanel = XUiPanelActiveBuffMian.New(self.PanelActiveBuffMain, self) + self.ActiveBuffPanel = XUiPanelActiveBuff.New(self.PanelActiveBuff) + + + + self:InitFun() +end + +function XUiMultiplayerRoom:OnStart() + self.GridMap = {} + self.TipsFuns = {} + XEventManager.AddEventListener(XEventId.EVENT_ROOM_REFRESH, self.OnRoomRefresh, self) + XEventManager.AddEventListener(XEventId.EVENT_ROOM_KICKOUT, self.OnKickOut, self) + XEventManager.AddEventListener(XEventId.EVENT_ITEM_COUNT_UPDATE_PREFIX .. XDataCenter.ItemManager.ItemId.ActionPoint, self.OnActionPointUpdate, self) + XEventManager.AddEventListener(XEventId.EVENT_ROOM_PLAYER_ENTER, self.OnPlayerEnter, self) + XEventManager.AddEventListener(XEventId.EVENT_ROOM_PLAYER_LEAVE, self.OnPlayerLevel, self) + XEventManager.AddEventListener(XEventId.EVENT_ROOM_PLAYER_STAGE_REFRESH, self.OnPlayerStageRefresh, self) + XEventManager.AddEventListener(XEventId.EVENT_ROOM_PLAYER_NPC_REFRESH, self.OnPlayerNpcRefresh, self) + XEventManager.AddEventListener(XEventId.EVENT_ROOM_AUTO_MATCH_CHANGE, self.OnRoomAutoMatchChange, self) + XEventManager.AddEventListener(XEventId.EVENT_ROOM_STAGE_LEVEL_CHANGE, self.OnRoomStageLevelChange, self) + XEventManager.AddEventListener(XEventId.EVENT_ROOM_STAGE_CHANGE, self.OnRoomStageChange, self) + XEventManager.AddEventListener(XEventId.EVENT_ROOM_STAGE_ABILITY_LIMIT_CHANGE, self.OnRoomAbilityLimitChange, self) + XEventManager.AddEventListener(XEventId.EVENT_CHAT_RECEIVE_ROOM_MSG, self.RefreshChatMsg, self) + XEventManager.AddEventListener(XEventId.EVENT_ROOM_CHANGE_STAGE, self.OnStageChange, self) + XEventManager.AddEventListener(XEventId.EVENT_ARENAONLINE_WEEK_REFRESH, self.OnArenaOnlineWeekRefrsh, self) + XEventManager.AddEventListener(XEventId.EVENT_ROOM_CHANGE_STAGE_SUMMER_EPISODE, self.OnStageChangeSummerEpisode, self) +end + +function XUiMultiplayerRoom:OnEnable() + self:Refresh() +end + +function XUiMultiplayerRoom:OnDestroy() + self:StopTimer() + self:StopCharTimer() + self:CloseAllOperationPanel() + self.IsAlreadyTip = nil + + XEventManager.RemoveEventListener(XEventId.EVENT_ROOM_REFRESH, self.OnRoomRefresh, self) + XEventManager.RemoveEventListener(XEventId.EVENT_ROOM_KICKOUT, self.OnKickOut, self) + XEventManager.RemoveEventListener(XEventId.EVENT_ITEM_COUNT_UPDATE_PREFIX .. XDataCenter.ItemManager.ItemId.ActionPoint, self.OnActionPointUpdate, self) + XEventManager.RemoveEventListener(XEventId.EVENT_ROOM_PLAYER_ENTER, self.OnPlayerEnter, self) + XEventManager.RemoveEventListener(XEventId.EVENT_ROOM_PLAYER_LEAVE, self.OnPlayerLevel, self) + XEventManager.RemoveEventListener(XEventId.EVENT_ROOM_PLAYER_STAGE_REFRESH, self.OnPlayerStageRefresh, self) + XEventManager.RemoveEventListener(XEventId.EVENT_ROOM_PLAYER_NPC_REFRESH, self.OnPlayerNpcRefresh, self) + XEventManager.RemoveEventListener(XEventId.EVENT_ROOM_AUTO_MATCH_CHANGE, self.OnRoomAutoMatchChange, self) + XEventManager.RemoveEventListener(XEventId.EVENT_ROOM_STAGE_LEVEL_CHANGE, self.OnRoomStageLevelChange, self) + XEventManager.RemoveEventListener(XEventId.EVENT_ROOM_STAGE_CHANGE, self.OnRoomStageChange, self) + XEventManager.RemoveEventListener(XEventId.EVENT_ROOM_STAGE_ABILITY_LIMIT_CHANGE, self.OnRoomAbilityLimitChange, self) + XEventManager.RemoveEventListener(XEventId.EVENT_CHAT_RECEIVE_ROOM_MSG, self.RefreshChatMsg, self) + XEventManager.RemoveEventListener(XEventId.EVENT_ROOM_CHANGE_STAGE, self.OnStageChange, self) + XEventManager.RemoveEventListener(XEventId.EVENT_ARENAONLINE_WEEK_REFRESH, self.OnArenaOnlineWeekRefrsh, self) + XEventManager.RemoveEventListener(XEventId.EVENT_ROOM_CHANGE_STAGE_SUMMER_EPISODE, self.OnStageChangeSummerEpisode, self) +end + +function XUiMultiplayerRoom:InitFun() + self.RoomInfoActiveTipFun = function(arg) self:RoomInfoActiveTip(arg) end + self.RoomInfoContenttextTipFun = function(arg) self:RoomInfoContenttextTip(arg) end + self.RoomInfoFightSuccesstextTipFun = function(arg) self:RoomInfoFightSuccesstextTip(arg) end + self.ShowRoomTipsFun = function() self:ShowRoomTips() end +end + +function XUiMultiplayerRoom:OnRoomRefresh() +end + +function XUiMultiplayerRoom:OnKickOut() + XLuaUiManager.Remove("UiDialog") + XLuaUiManager.Remove("UiReport") + XLuaUiManager.Remove("UiRoomCharacter") + XLuaUiManager.Remove("UiPlayerInfo") + XLuaUiManager.Remove("UiChatServeMain") + + if XUiManager.CheckTopUi(CsXUiType.Normal, "UiMultiplayerRoom") then + self:Close() + else + self:Remove() + end +end + +function XUiMultiplayerRoom:OnActionPointUpdate() + self.TxtActionPoint.text = XDataCenter.ItemManager.GetItem(XDataCenter.ItemManager.ItemId.ActionPoint).Count +end + +-- 有玩家进入房间 +function XUiMultiplayerRoom:OnPlayerEnter(playerData) + local grid = self:GetGrid(playerData.Id) + self.ActiveBuffMainPanel:Refresh() + grid:InitCharData(playerData) + self:RefreshButtonStatus() + self:CheckLeaderCountDown() + self:RefreshTips() + self:RefreshSameCharTips() + self:RefreshCharActiveEffct() +end + +-- 有玩家离开房间 +function XUiMultiplayerRoom:OnPlayerLevel(playerId) + local grid = self:GetGrid(playerId) + self.ActiveBuffMainPanel:Refresh() + grid:InitEmpty() + self:RefreshButtonStatus() + self.GridMap[playerId] = nil + self:CheckLeaderCountDown() + self:RefreshTips() + self:RefreshSameCharTips() + self:RefreshCharActiveEffct() +end + +-- 玩家状态刷新 +function XUiMultiplayerRoom:OnPlayerStageRefresh(playerData) + local grid = self:GetGrid(playerData.Id) + grid:RefreshPlayer(playerData) + self:RefreshButtonStatus() + self:CheckLeaderCountDown() +end + +-- 玩家Npc信息刷新 +function XUiMultiplayerRoom:OnPlayerNpcRefresh(playerData) + local grid = self:GetGrid(playerData.Id) + self.ActiveBuffMainPanel:Refresh() + grid:InitCharData(playerData) + self:RefreshButtonStatus() + self:CheckLeaderCountDown() + self:RefreshTips() + self:RefreshSameCharTips() + self:RefreshCharActiveEffct() + self:RefreshChangeStageBtn() +end + +-- 刷新玩家同调特效 +function XUiMultiplayerRoom:RefreshCharActiveEffct() + local roomData = XDataCenter.RoomManager.RoomData + if not roomData or not roomData.StageId then + return + end + + local stageInfo = XDataCenter.FubenManager.GetStageInfo(roomData.StageId) + if stageInfo.Type ~= XDataCenter.FubenManager.StageType.ArenaOnline then + return + end + + for _, grid in pairs(self.GridMap) do + grid:CheckOpenEffctObje() + end +end + +-- 房间自动修改 +function XUiMultiplayerRoom:OnRoomAutoMatchChange() + self:RefreshButtonStatus() + self:RefreshDifficultyPanel() + self:CheckLeaderCountDown() +end + +-- 房间难度等级修改 +function XUiMultiplayerRoom:OnRoomStageLevelChange(lastLevel, curLevel) + self:RefreshButtonStatus() + self:RefreshDifficultyPanel() + self:PlayStageLevelChange(lastLevel, curLevel) + self.PanelDifficulty.gameObject:SetActiveEx(false) + self:CheckLeaderCountDown() +end + +-- 房间状态修改 +function XUiMultiplayerRoom:OnRoomStageChange() + self:CheckLeaderCountDown() +end + +-- 房间战力限制修改 +function XUiMultiplayerRoom:OnRoomAbilityLimitChange() + self:RefreshAbilityLimit() +end + +-- 夏活关卡改变 +function XUiMultiplayerRoom:OnStageChangeSummerEpisode() + local roomData = XDataCenter.RoomManager.RoomData + self.TxtMap.text = XDataCenter.FubenManager.GetStageName(roomData.StageId) + self.TxtTitle.text = XDataCenter.FubenManager.GetStageName(roomData.StageId) + --todo aafasou 待接入地图更改后的动画 +end + +function XUiMultiplayerRoom:PlayStageLevelChange(lastLevel, curLevel) + local roomData = XDataCenter.RoomManager.RoomData + local levelControl = XDataCenter.FubenManager.GetStageMultiplayerLevelControl(roomData.StageId, curLevel) + self.TxtChangeAdditionDest.text = levelControl.AdditionDest + + local level + local stageInfo = XDataCenter.FubenManager.GetStageInfo(roomData.StageId) + if stageInfo.Type == XDataCenter.FubenManager.StageType.ArenaOnline then + level = roomData.ChallengeLevel + else + level = roomData.StageLevel + end + + --设置显隐 + for k, v in pairs(self.DifficultyIconGroup) do + if k == lastLevel then + v.gameObject:SetActiveEx(true) + elseif k == level then + v.gameObject:SetActiveEx(true) + else + v.gameObject:SetActiveEx(false) + end + end + + --设置位置 + self.DifficultyIconGroup[lastLevel].localPosition = self.ChangeDifficultyCase1.localPosition + self.DifficultyIconGroup[level].localPosition = self.ChangeDifficultyCase2.localPosition + + if XLuaUiManager.IsUiShow("UiMultiplayerRoom") then + local begin = function() + XLuaUiManager.SetMask(true) + end + + local finished = function() + XLuaUiManager.SetMask(false) + self.PanelChangeDifficulty.gameObject:SetActiveEx(false) + end + + self:PlayAnimation("AnimChangeDifficulty", finished, begin) + end +end + +----------------------- 界面方法 ----------------------- +function XUiMultiplayerRoom:SwitchButtonState(state) + for k, v in pairs(self.BtnGroup) do + v:SetActiveEx(k == state) + end +end + +function XUiMultiplayerRoom:SwitchDifficultyState(diff) + local showBtn = false + for k, v in pairs(self.DifficultyImageGroup) do + v.gameObject:SetActiveEx(k == diff) + if k == diff then + showBtn = true + end + end + + self.BtnDifficultySelect.gameObject:SetActiveEx(showBtn) +end + +function XUiMultiplayerRoom:GetCurRole() + local roomData = XDataCenter.RoomManager.RoomData + + if not roomData then + return nil + end + + for _, v in pairs(roomData.PlayerDataList) do + if v.Id == XPlayer.Id then + return v + end + end +end + +function XUiMultiplayerRoom:CheckPeopleEnough() + local roomData = XDataCenter.RoomManager.RoomData + + if not roomData then + return 0 + end + + local count = 0 + for _, v in pairs(roomData.PlayerDataList) do + count = count + 1 + end + + local stageId = roomData.StageId + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + local leastPlayer = stageCfg.OnlinePlayerLeast <= 0 and 1 or stageCfg.OnlinePlayerLeast + + if count < leastPlayer then + XUiManager.TipMsg(string.format(CS.XTextManager.GetText("OnlineRoomLeastPlayer"), leastPlayer)) + return false + end + + return true +end + +function XUiMultiplayerRoom:GetLeaderRole() + local roomData = XDataCenter.RoomManager.RoomData + for _, v in pairs(roomData.PlayerDataList) do + if v.Leader then + return v + end + end +end + +function XUiMultiplayerRoom:CheckAllReady() + local roomData = XDataCenter.RoomManager.RoomData + for _, v in pairs(roomData.PlayerDataList) do + if not v.Leader and v.State ~= XDataCenter.RoomManager.PlayerState.Ready then + return false + end + end + return true +end + +function XUiMultiplayerRoom:CheckListFullAndAllReady() + local roomData = XDataCenter.RoomManager.RoomData + return roomData.State == 0 and #roomData.PlayerDataList == MAX_PLAYER_COUNT and self:CheckAllReady() +end + +-- 界面刷新 +function XUiMultiplayerRoom:Refresh() + local roomData = XDataCenter.RoomManager.RoomData + local stageId = roomData.StageId + local challengeId = roomData.ChallengeId + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + + self.TxtTitle.text = stageCfg.Name + + --体力&门票 + if XDataCenter.FubenManager.CheckCanFlop(stageId) and stageInfo.Type == XDataCenter.FubenManager.StageType.BossOnline then + self.TxtActionConsume.text = XDataCenter.FubenManager.GetStageActionPointConsume(stageId) + local itemId = XDataCenter.FubenManager.GetFlopConsumeItemId(stageId) + local item = XDataCenter.ItemManager.GetItem(itemId) + local count = item and item:GetCount() or 0 + self.TxtTicket.text = count + local flopIcon = XDataCenter.ItemManager.GetItemIcon(itemId) + self.RImgFlopIcon:SetRawImage(flopIcon) + self.PanelFlopItem.gameObject:SetActiveEx(true) + self.PanelStaminaCost.gameObject:SetActiveEx(false) + self.PanelArenaOnlineTip.gameObject:SetActiveEx(false) + self.TxtLv.gameObject:SetActiveEx(false) + self.PanelConsume.gameObject:SetActiveEx(true) + elseif stageInfo.Type == XDataCenter.FubenManager.StageType.ArenaOnline then + self.PanelFlopItem.gameObject:SetActiveEx(false) + self.PanelStaminaCost.gameObject:SetActiveEx(true) + self.PanelArenaOnlineTip.gameObject:SetActiveEx(stageInfo.Passed) + self.PanelConsume.gameObject:SetActiveEx(false) + local arenaStageCfg = XDataCenter.ArenaOnlineManager.GetArenaOnlineStageCfgStageId(challengeId) + local arenaChapterCfg = XDataCenter.ArenaOnlineManager.GetCurChapterCfg() + local cost = stageInfo.Passed and 0 or arenaStageCfg.EnduranceCost + self.TxtStamina.text = cost + self.TxtLv.text = CS.XTextManager.GetText("ArenaOnlineChapterLevel", arenaChapterCfg.MinLevel, arenaChapterCfg.MaxLevel) + self.ActiveBuffMainPanel:Show(stageId) + else + local stage = XDataCenter.FubenManager.GetStageCfg(stageId) + self.TxtActionConsume.text = stage.RequireActionPoint + self.PanelFlopItem.gameObject:SetActiveEx(false) + self.PanelStaminaCost.gameObject:SetActiveEx(false) + self.PanelArenaOnlineTip.gameObject:SetActiveEx(false) + self.TxtLv.gameObject:SetActiveEx(false) + self.PanelConsume.gameObject:SetActiveEx(true) + end + self.TxtActionPoint.text = XDataCenter.ItemManager.GetItem(XDataCenter.ItemManager.ItemId.ActionPoint).Count + + --按钮状态 + self:RefreshButtonStatus() + + self:RefreshChangeStageBtn() + + self:RefreshChars() + + self:RefreshTips() + + self:RefreshSameCharTips() + + self:RefreshDifficultyPanel() + + self:RefreshAbilityLimit() + + self:InitSpecialEffectsButton() + + self:RoomInfoTip() +end + +function XUiMultiplayerRoom:CloseAllOperationPanel(exceptIndex) + for k, v in pairs(self.GridList) do + if not exceptIndex or k ~= exceptIndex then + v:CloseOperationPanelAndInvitePanel() + end + end +end + +-- 角色面板初始化 +function XUiMultiplayerRoom:InitCharItems() + local caseList = { + self.RoomCharCase1, + self.RoomCharCase2, + self.RoomCharCase3, + } + + self.GridList = {} + for i = 1, MAX_PLAYER_COUNT do + local ui + if i == 1 then + ui = self.GridMulitiplayerRoomChar + else + ui = CS.UnityEngine.GameObject.Instantiate(self.GridMulitiplayerRoomChar) + end + ui.transform:SetParent(caseList[i], false) + ui.transform:Reset() + local grid = XUiGridMulitiplayerRoomChar.New(ui, self, i, self.RoleModelList[i].RoleModel, self.RoleModelList[i].EffectObj) + self.GridList[i] = grid + end +end + +function XUiMultiplayerRoom:InitSpecialEffectsButton() + + local val = XSaveTool.GetData(XSetConfigs.FriendEffect) or XSetConfigs.FriendEffectEnum.Open + + if val == XSetConfigs.FriendEffectEnum.Open then + self.BtnSpecialEffects:SetButtonState(XUiButtonState.Select) + + if not CS.UnityEngine.PlayerPrefs.HasKey(IsFirstFriendEffect) then + CS.UnityEngine.PlayerPrefs.SetString(IsFirstFriendEffect, "false") + XSaveTool.SaveData(XSetConfigs.IsFirstFriendEffect, nil) + local title = CS.XTextManager.GetText("TipTitle") + local friendEffectMsg = CS.XTextManager.GetText("OnlineFriendEffectMsg") + XUiManager.DialogTip(title, friendEffectMsg, XUiManager.DialogType.Normal, nil, + function() + XDataCenter.SetManager.SaveFriendEffect(XSetConfigs.FriendEffectEnum.Close) + XDataCenter.SetManager.SetAllyEffect(false) + self.BtnSpecialEffects:SetButtonState(XUiButtonState.Normal) + end) + end + else + self.BtnSpecialEffects:SetButtonState(XUiButtonState.Normal) + end +end + +function XUiMultiplayerRoom:InitDifficultyButtons() + self.DifficultyImageGroup = { + [DifficultyType.Normal] = self.ImgDifficultyNormal, + [DifficultyType.Hart] = self.ImgDifficultyHart, + [DifficultyType.Nightmare] = self.ImgDifficultyNightmare, + } + self.DifficultyButtonGroup = { + [DifficultyType.Normal] = XUiGridMultiplayerDifficultyItem.New(self.GridDifficultyNormal, DifficultyType.Normal, handler(self, self.SelectDifficulty)), + [DifficultyType.Hart] = XUiGridMultiplayerDifficultyItem.New(self.GridDifficultyHart, DifficultyType.Hart, handler(self, self.SelectDifficulty)), + [DifficultyType.Nightmare] = XUiGridMultiplayerDifficultyItem.New(self.GridDifficultyNightmare, DifficultyType.Nightmare, handler(self, self.SelectDifficulty)), + } + + self.DifficultyIconGroup = { self.IconNormal, self.IconHart, self.IconNightmare } +end + +function XUiMultiplayerRoom:InitSummerEpisodeMapSelectBtn() + local roomData = XDataCenter.RoomManager.RoomData + if not roomData then + return + end + self.TxtMap.text = XDataCenter.FubenManager.GetStageName(roomData.StageId) +end + +function XUiMultiplayerRoom:GetGrid(playerId) + local grid = self.GridMap[playerId] + if not grid then + if playerId == XPlayer.Id then + grid = self.GridList[1] + self.GridMap[playerId] = grid + else + for i = 2, MAX_PLAYER_COUNT do + if not self.GridList[i].PlayerData then + grid = self.GridList[i] + self.GridMap[playerId] = grid + break + end + end + end + end + if not grid then + XLog.Error("XUiMultiplayerRoom:GetGrid error, there is no empty grid") + end + return grid +end + +function XUiMultiplayerRoom:RefreshButtonStatus() + local roomData = XDataCenter.RoomManager.RoomData + local role = self:GetCurRole() + if role and role.Leader then + if self:CheckAllReady() then + self:SwitchButtonState(ButtonState.Fight) + else + self:SwitchButtonState(ButtonState.Waiting) + end + else + if role.State == XDataCenter.RoomManager.PlayerState.Ready then + self:SwitchButtonState(ButtonState.CancelReady) + else + self:SwitchButtonState(ButtonState.Ready) + end + end + + if XDataCenter.FubenManager.CheckMultiplayerLevelControl(roomData.StageId) then + self:SwitchDifficultyState(roomData.StageLevel) + else + self:SwitchDifficultyState(0) + end + self.BtnMapSelect.gameObject:SetActiveEx(XDataCenter.FubenSpecialTrainManager.IsPhotoStage(roomData.StageId)) + self.PanelLimit.gameObject:SetActiveEx(not XDataCenter.FubenSpecialTrainManager.IsPhotoStage(roomData.StageId)) + self.BtnAutoMatch.ButtonState = roomData.AutoMatch and CS.UiButtonState.Select or CS.UiButtonState.Normal +end + +function XUiMultiplayerRoom:RefreshChars() + local roomData = XDataCenter.RoomManager.RoomData + for _, v in pairs(roomData.PlayerDataList) do + local grid = self:GetGrid(v.Id) + grid:InitCharData(v) + end + + for _, v in pairs(self.GridList) do + if not v.PlayerData then + v:InitEmpty() + end + end +end + +function XUiMultiplayerRoom:RefreshChangeStageBtn() + local roomData = XDataCenter.RoomManager.RoomData + local stageId = roomData.StageId + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + + if stageInfo.Type ~= XDataCenter.FubenManager.StageType.ArenaOnline then + self.BtnChangeStage.gameObject:SetActiveEx(false) + return + end + + local leader = self:GetLeaderRole() + if not leader then + self.BtnChangeStage.gameObject:SetActiveEx(false) + return + end + + self.BtnChangeStage.gameObject:SetActiveEx(leader.Id == XPlayer.Id) +end + +function XUiMultiplayerRoom:RefreshDifficultyPanel() + local roomData = XDataCenter.RoomManager.RoomData + if XDataCenter.FubenManager.CheckMultiplayerLevelControl(roomData.StageId) then + local stageInfo = XDataCenter.FubenManager.GetStageInfo(roomData.StageId) + if stageInfo.Type == XDataCenter.FubenManager.StageType.ArenaOnline then + local cfg = XArenaOnlineConfigs.GetStageById(roomData.ChallengeId) + if cfg and cfg.Difficulty then + local difficultyIds = cfg.Difficulty + for k, id in pairs(difficultyIds) do + local levelControl = XFubenConfigs.GetStageMultiplayerLevelControlCfgById(id) + if levelControl then + local item = self.DifficultyButtonGroup[k] + if item then + item:Refresh(levelControl) + item:SetSelected(roomData.ChallengeLevel == k) + end + end + end + end + else + for k, v in pairs(self.DifficultyButtonGroup) do + local levelControl = XDataCenter.FubenManager.GetStageMultiplayerLevelControl(roomData.StageId, k) + v:Refresh(levelControl) + v:SetSelected(roomData.StageLevel == k) + end + end + local levelControl = XDataCenter.FubenManager.GetStageMultiplayerLevelControl(roomData.StageId, roomData.StageLevel) + self.TxtAdditionDest.text = levelControl.AdditionDest + self.TxtRecommend.text = CS.XTextManager.GetText("MultiplayerRoomRecommendAbility", levelControl.RecommendAbility) + else + self.TxtAdditionDest.gameObject:SetActiveEx(false) + self.TxtRecommend.gameObject:SetActiveEx(false) + end +end + +function XUiMultiplayerRoom:RefreshAbilityLimit() + local roomData = XDataCenter.RoomManager.RoomData + self.TxtAbilityLimit.text = roomData.AbilityLimit + self.TxtCurAbilityLimit.text = roomData.AbilityLimit +end + +function XUiMultiplayerRoom:RefreshAbilityLimitPanel() + local roomData = XDataCenter.RoomManager.RoomData + local levelControl = XDataCenter.FubenManager.GetStageMultiplayerLevelControl(roomData.StageId, roomData.StageLevel) + local defaultAbilityLimit = roomData.AbilityLimit > 0 and roomData.AbilityLimit or levelControl and levelControl.RecommendAbility or 0 + self.InFSetAbilityLimit.text = defaultAbilityLimit + self.TxtCurAbilityLimit.text = roomData.AbilityLimit +end + +function XUiMultiplayerRoom:CheckSameCharacterByMyself() + local roomData = XDataCenter.RoomManager.RoomData + local curRole = self:GetCurRole() + if not curRole then + return false + end + + for _, v in pairs(roomData.PlayerDataList) do + if v.Id ~= curRole.Id + and (v.Leader or v.State == XDataCenter.RoomManager.PlayerState.Ready) + and v.FightNpcData.Character.Id == curRole.FightNpcData.Character.Id then + return true + end + end +end + +function XUiMultiplayerRoom:RefreshChatMsg(chatDataLua) + local senderName = XDataCenter.SocialManager.GetPlayerRemark(chatDataLua.SenderId, chatDataLua.NickName) + if chatDataLua.MsgType == ChatMsgType.Emoji then + self.TxtMessageContent.text = string.format("%s:%s", senderName, CSXTextManagerGetText("EmojiText")) + else + self.TxtMessageContent.text = string.format("%s:%s", senderName, chatDataLua.Content) + end + + if not string.IsNilOrEmpty(chatDataLua.CustomContent) then + self.TxtMessageContent.supportRichText = true + else + self.TxtMessageContent.supportRichText = false + end + + if XUiHelper.CalcTextWidth(self.TxtMessageContent) > MAX_CHAT_WIDTH then + self.TxtMessageContent.text = string.Utf8Sub(self.TxtMessageContent.text, 1, CHAT_SUB_LENGTH) .. [[......]] + end + + local grid = self:GetGrid(chatDataLua.SenderId) + grid:RefreshChat(chatDataLua) +end + +----------------------- 职业提示 ----------------------- +function XUiMultiplayerRoom:RefreshTips() + for _, v in pairs(self.TipsList) do + v:SetActiveEx(false) + end + + local roomData = XDataCenter.RoomManager.RoomData + local stageTemplate = XDataCenter.FubenManager.GetStageCfg(roomData.StageId) + + if stageTemplate.NeedJobType then + local needJobCount = {} + for _, v in pairs(stageTemplate.NeedJobType) do + if not needJobCount[v] then + needJobCount[v] = 0 + end + needJobCount[v] = needJobCount[v] + 1 + end + + local index = 0 + for k, v in pairs(needJobCount) do + local jobCount = self:GetJopCount(k) + if jobCount < v then + index = index + 1 + local tips = self.TipsList[index] + if not tips then + local ui = CS.UnityEngine.GameObject.Instantiate(self.PanelTips, self.PanelTipsContainer) + tips = XUiTips.New(ui) + self.TipsList[index] = tips + end + tips:SetActiveEx(true) + tips:SetText(self:GetJobTips(k, v - jobCount)) + end + end + end +end + +function XUiMultiplayerRoom:RefreshSameCharTips() + local roomData = XDataCenter.RoomManager.RoomData + for _, v in pairs(roomData.PlayerDataList) do + local grid = self:GetGrid(v.Id) + grid:ShowSameCharTips(false) + for _, v2 in pairs(roomData.PlayerDataList) do + if v.Id ~= v2.Id and v.FightNpcData.Character.Id == v2.FightNpcData.Character.Id then + grid:ShowSameCharTips(true) + break + end + end + end +end + +function XUiMultiplayerRoom:StopCharTimer() + for _, grid in pairs(self.GridMap) do + grid:StopTimer() + end +end + +function XUiMultiplayerRoom:GetJopCount(type) + local count = 0 + local roomData = XDataCenter.RoomManager.RoomData + for _, v in pairs(roomData.PlayerDataList) do + local charId = v.FightNpcData.Character.Id + local quality = v.FightNpcData.Character.Quality + local npcId = XCharacterConfigs.GetCharNpcId(charId, quality) + local npcTemplate = XCharacterConfigs.GetNpcTemplate(npcId) + if type == npcTemplate.Type then + count = count + 1 + end + end + return count +end + +function XUiMultiplayerRoom:GetJobTips(type, count) + if type == 1 then + return CS.XTextManager.GetText("CharacterLackDps", count) + elseif type == 2 then + return CS.XTextManager.GetText("CharacterLackTank", count) + elseif type == 3 then + return CS.XTextManager.GetText("CharacterLackCure", count) + end +end + +function XUiMultiplayerRoom:SelectDifficulty(diff) + XDataCenter.RoomManager.SetStageLevel(diff) +end + +----------------------- 倒计时 ----------------------- +function XUiMultiplayerRoom:CheckLeaderCountDown() + if self.Timer then + if not self:CheckListFullAndAllReady() then + self:StopTimer() + end + else + if self:CheckListFullAndAllReady() then + self:StartTimer() + end + end +end + +function XUiMultiplayerRoom:StartTimer() + self.StartTime = XTime.GetServerNowTimestamp() + self.Timer = XScheduleManager.ScheduleForever(handler(self, self.UpdateTimer), XScheduleManager.SECOND) + local role = self:GetLeaderRole() + self.CurCountDownGrid = self:GetGrid(role.Id) + self:UpdateTimer() +end + +function XUiMultiplayerRoom:StopTimer() + if self.CurCountDownGrid then + self.CurCountDownGrid:ShowCountDownPanel(false) + self.CurCountDownGrid = nil + end + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end + +function XUiMultiplayerRoom:UpdateTimer() + local elapseTime = XTime.GetServerNowTimestamp() - self.StartTime + if elapseTime > self.RoomKickCountDownShowTime then + self.CurCountDownGrid:ShowCountDownPanel(true) + local leftTime = self.RoomKickCountDownTime - elapseTime + self.CurCountDownGrid:SetCountDownTime(leftTime) + end +end + +----------------------- 按钮回调 ----------------------- +function XUiMultiplayerRoom:OnToggleQuickMatchClick() + XDataCenter.RoomManager.Ready() +end + +function XUiMultiplayerRoom:OnBtnFightClick() + local role = self:GetCurRole() + if not role or not role.Leader then + return + end + + if not self:CheckPeopleEnough() then + return + end + + if self:CheckSameCharacterByMyself() then + local msg = CS.XTextManager.GetText("MultiplayerRoomTeamHasSameCharacter") + XUiManager.TipMsg(msg) + return + end + + XDataCenter.RoomManager.Enter(function(response) + if response.Code ~= XCode.Success then + XUiManager.TipCode(response.Code) + return + end + end) +end + +function XUiMultiplayerRoom:OnBtnCancelReadyClick() + XDataCenter.RoomManager.CancelReady(function(code) + XUiManager.TipCode(code) + if code ~= XCode.Success then + return + end + self.BtnReady.gameObject:SetActiveEx(true) + self.BtnCancelReady.gameObject:SetActiveEx(false) + end) +end + +function XUiMultiplayerRoom:OnBtnReadyClick() + if self:CheckSameCharacterByMyself() then + local msg = CS.XTextManager.GetText("MultiplayerRoomTeamHasSameCharacter") + XUiManager.TipMsg(msg) + return + end + XDataCenter.RoomManager.Ready() +end + +function XUiMultiplayerRoom:OnBtnChatClick() + XLuaUiManager.Open("UiChatServeMain", false, ChatChannelType.Room, ChatChannelType.World) +end + +function XUiMultiplayerRoom:OnBtnChangeDifficultyClick() + +end + +function XUiMultiplayerRoom:OnBtnBackClick() + if not XDataCenter.RoomManager.RoomData then + self:Close() + return + end + + self:CloseAllOperationPanel() + local title = CS.XTextManager.GetText("TipTitle") + local cancelMatchMsg + + local stageId = XDataCenter.RoomManager.RoomData.StageId + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + if stageInfo.Type == XDataCenter.FubenManager.StageType.ArenaOnline then + cancelMatchMsg = CS.XTextManager.GetText("ArenaOnlineInstanceQuitRoom") + else + cancelMatchMsg = CS.XTextManager.GetText("OnlineInstanceQuitRoom") + end + + XUiManager.DialogTip(title, cancelMatchMsg, XUiManager.DialogType.Normal, nil, function() + XDataCenter.RoomManager.Quit(function() + XLuaUiManager.Close("UiMultiplayerRoom") + end) + end) +end + +function XUiMultiplayerRoom:OnBtnMainUiClick() + self:CloseAllOperationPanel() + XLuaUiManager.RunMain() +end + +function XUiMultiplayerRoom:OnBtnMapsSelectClick() + local leader = self:GetLeaderRole() + if leader.Id ~= XPlayer.Id then return end + XLuaUiManager.Open("UiSummerEpisodeMap",XDataCenter.RoomManager.RoomData.StageId,function() + self:PlayAnimation("BtnMapSelectEnable") + end) +end + +function XUiMultiplayerRoom:OnBtnDifficultySelectClick() + self:CloseAllOperationPanel() + local curRole = self:GetCurRole() + if not curRole or not curRole.Leader then + local msg = CS.XTextManager.GetText("MultiplayerRoomCanNotSelectDifficulty") + XUiManager.TipMsg(msg) + return + end + self.PanelDifficulty.gameObject:SetActiveEx(true) + self:PlayAnimation("DifficultyEnable") + self:RefreshDifficultyPanel() +end + +function XUiMultiplayerRoom:OnBtnCloseDifficultyClick() + self.PanelDifficulty.gameObject:SetActiveEx(false) +end + +function XUiMultiplayerRoom:OnBtnSetAbilityLimitClick() + self:CloseAllOperationPanel() + local curRole = self:GetCurRole() + if not curRole or not curRole.Leader then + local msg = CS.XTextManager.GetText("MultiplayerRoomCanNotSetAbilityLimit") + XUiManager.TipMsg(msg) + return + end + self.PanelAbilityLimit.gameObject:SetActiveEx(true) + self:PlayAnimation("AbilityLimitEnable") + self:RefreshAbilityLimitPanel() +end + +function XUiMultiplayerRoom:OnBtnCloseAbilityLimitClick() + self.PanelAbilityLimit.gameObject:SetActiveEx(false) +end + +--队友特效开关 +function XUiMultiplayerRoom:OnBtnSpecialEffectsClick(val) + if val > 0 then + XDataCenter.SetManager.SaveFriendEffect(XSetConfigs.FriendEffectEnum.Open) + XDataCenter.SetManager.SetAllyEffect(true) + else + XDataCenter.SetManager.SaveFriendEffect(XSetConfigs.FriendEffectEnum.Close) + XDataCenter.SetManager.SetAllyEffect(false) + end +end + +function XUiMultiplayerRoom:OnBtnAutoMatchClick() + self:CloseAllOperationPanel() + local curRole = self:GetCurRole() + if not curRole or not curRole.Leader then + local msg = CS.XTextManager.GetText("MultiplayerRoomCanNotChangeAutoMatch") + XUiManager.TipMsg(msg) + -- 重置按钮状态 + local roomData = XDataCenter.RoomManager.RoomData + self.BtnAutoMatch.ButtonState = roomData.AutoMatch and CS.UiButtonState.Select or CS.UiButtonState.Normal + return + end + local roomData = XDataCenter.RoomManager.RoomData + XDataCenter.RoomManager.SetAutoMatch(not roomData.AutoMatch) +end + +function XUiMultiplayerRoom:OnBtnConfirmSetAbilityLimitClick() + local abilityLimit = tonumber(self.InFSetAbilityLimit.text) + if not abilityLimit or abilityLimit < 0 then + local msg = CS.XTextManager.GetText("MultiplayerRoomAbilityNotLegal") + XUiManager.TipMsg(msg) + return + end + abilityLimit = math.floor(abilityLimit) + XDataCenter.RoomManager.SetAbilityLimit(abilityLimit, function() + self.PanelAbilityLimit.gameObject:SetActiveEx(false) + end) +end + +-- 改变关卡 +function XUiMultiplayerRoom:OnBtnChangeStageClick() + local roomData = XDataCenter.RoomManager.RoomData + local stageId = roomData.StageId + + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + if stageInfo.Type == XDataCenter.FubenManager.StageType.ArenaOnline then + stageId = roomData.ChallengeId + end + + self.ChangeStagePanel:Show(stageId) + self:PlayAnimation("ChangeStageEnable") +end + +-- 打开同调详情 +function XUiMultiplayerRoom:PanelActiveBuffShow(activeBuffCfg) + self.ActiveBuffPanel:Show(activeBuffCfg) + self:PlayAnimation("ActiveBuffEnable") +end + +-- 检查同调开启 +function XUiMultiplayerRoom:CheckActiveOn(playerId) + return self.ActiveBuffMainPanel:CheckActiveOn(playerId) +end + +-- 房间信息提示 +function XUiMultiplayerRoom:RoomInfoTip() + if self.IsAlreadyTip then + return + end + + self.IsAlreadyTip = true + local roomData = XDataCenter.RoomManager.RoomData + local stageCfg = XDataCenter.FubenManager.GetStageCfg(roomData.StageId) + if XDataCenter.FubenManager.CheckMultiplayerLevelControl(roomData.StageId) then + local levelControl = XDataCenter.FubenManager.GetStageMultiplayerLevelControl(roomData.StageId, roomData.StageLevel) + self.Contenttext = CS.XTextManager.GetText("ArenaOnlineStageInfoTip", stageCfg.Name, levelControl.DifficultyDesc) + self:InsertTips(TipsType.LevelTips, self.RoomInfoContenttextTipFun) + end +end + +function XUiMultiplayerRoom:InsertTips(tipstype, cb) + table.insert(self.TipsFuns, {["TipsType"] = tipstype, ["TipsFun"] = cb }) + table.sort(self.TipsFuns, function(a, b) + return a.TipsType > b.TipsType + end) + + if self.TipsDelayTimerId then + XScheduleManager.UnSchedule(self.TipsDelayTimerId) + end + self.TipsDelayTimerId = XScheduleManager.ScheduleOnce(function() + self:ShowRoomTips() + self.TipsDelayTimerId = nil + end, 500) +end + +function XUiMultiplayerRoom:InsertFightSuccessTips() + self:InsertTips(TipsType.ChuzhanTips, self.RoomInfoFightSuccesstextTipFun) +end + +function XUiMultiplayerRoom:InsertActiveTips(tip) + self.ActiveTip = tip + self:InsertTips(TipsType.TongTiaoTips, self.RoomInfoActiveTipFun) +end + +function XUiMultiplayerRoom:RoomInfoActiveTip(cb) + XUiManager.TipMsg(self.ActiveTip, nil, cb) +end + +function XUiMultiplayerRoom:RoomInfoContenttextTip(cb) + XUiManager.TipMsg(self.Contenttext, nil, cb) +end + +function XUiMultiplayerRoom:RoomInfoFightSuccesstextTip(cb) + local text = CS.XTextManager.GetText("OnlineFightSuccess") + XUiManager.TipMsg(text, nil, cb) +end + +function XUiMultiplayerRoom:ShowRoomTips() + local curtips = table.remove(self.TipsFuns) + if not curtips or not curtips.TipsFun then + return + end + + local fun = curtips.TipsFun + fun(self.ShowRoomTipsFun) +end + +-- 关卡改变 +function XUiMultiplayerRoom:OnStageChange() + self:Refresh() + local leader = self:GetLeaderRole() + if leader.Id == XPlayer.Id then + -- return + end + + local roomData = XDataCenter.RoomManager.RoomData + + + local stageCfg = XDataCenter.FubenManager.GetStageCfg(roomData.StageId) + if not CS.XFight.IsRunning and not XLuaUiManager.IsUiLoad("UiLoading") then + local contenttext = CS.XTextManager.GetText("ArenaOnlineStageChangeInfo", stageCfg.Name) + XUiManager.TipMsg(contenttext) + end +end + +-- 区域联机周刷新 +function XUiMultiplayerRoom:OnArenaOnlineWeekRefrsh() + local roomData = XDataCenter.RoomManager.RoomData + local stageInfo = XDataCenter.FubenManager.GetStageInfo(roomData.StageId) + + if stageInfo.Type == XDataCenter.FubenManager.StageType.ArenaOnline then + XDataCenter.ArenaOnlineManager.RunMain() + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMultiplayerRoom/XUiPanelActiveBuff.lua b/Resources/Scripts/XUi/XUiMultiplayerRoom/XUiPanelActiveBuff.lua new file mode 100644 index 00000000..001dfff7 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMultiplayerRoom/XUiPanelActiveBuff.lua @@ -0,0 +1,38 @@ +local XUiPanelActiveBuff = XClass(nil, "XUiPanelActiveBuff") + +function XUiPanelActiveBuff:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:AutoAddListener() +end + +function XUiPanelActiveBuff:AutoAddListener() + self.BtnClose.CallBack = function() self:Hide() end + self.BtnTanchuangClose.CallBack = function() self:Hide() end +end + +function XUiPanelActiveBuff:Show(activeBuffCfg) + if self.CfgId == activeBuffCfg.Id then + self.GameObject:SetActiveEx(true) + return + end + + self.CfgId = activeBuffCfg.Id + self:Refresh(activeBuffCfg) + self.GameObject:SetActiveEx(true) +end + +function XUiPanelActiveBuff:Hide() + self.GameObject:SetActiveEx(false) +end + +function XUiPanelActiveBuff:Refresh(activeBuffCfg) + self.RImgOnIcon:SetRawImage(activeBuffCfg.OnIcon) + self.RImgOffIcon:SetRawImage(activeBuffCfg.OffIcon) + self.TxtTile.text = activeBuffCfg.Title + local description = string.gsub(activeBuffCfg.Desc, "\\n", "\n") + self.TxtDesc.text = description +end + +return XUiPanelActiveBuff \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMultiplayerRoom/XUiPanelActiveBuffMian.lua b/Resources/Scripts/XUi/XUiMultiplayerRoom/XUiPanelActiveBuffMian.lua new file mode 100644 index 00000000..68f0a66f --- /dev/null +++ b/Resources/Scripts/XUi/XUiMultiplayerRoom/XUiPanelActiveBuffMian.lua @@ -0,0 +1,83 @@ +local XUiPanelActiveBuffMian = XClass(nil, "XUiPanelActiveBuffMian") + +function XUiPanelActiveBuffMian:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + self.PlayerActiveBuffOnList = {} + XTool.InitUiObject(self) + self:AutoAddListener() + self:Hide() +end + +function XUiPanelActiveBuffMian:AutoAddListener() + self.BtnDesc.CallBack = function() self:OnBenDescClick() end +end + +function XUiPanelActiveBuffMian:Show() + self:Refresh() + self.GameObject:SetActiveEx(true) +end + +function XUiPanelActiveBuffMian:Hide() + self.GameObject:SetActiveEx(false) +end + +function XUiPanelActiveBuffMian:Refresh() + local roomData = XDataCenter.RoomManager.RoomData + if not roomData or not roomData.StageId then + return + end + + local stageInfo = XDataCenter.FubenManager.GetStageInfo(roomData.StageId) + if stageInfo.Type ~= XDataCenter.FubenManager.StageType.ArenaOnline then + return + end + + self.PlayerActiveBuffOnList = {} + self.BuffCfg = XDataCenter.ArenaOnlineManager.GetActiveBuffCfgByStageId(roomData.ChallengeId) + local enoughCount = 0 + for _, player in pairs(roomData.PlayerDataList) do + local initQualty = player.FightNpcData.Character.InitQuality + if initQualty <= self.BuffCfg.Quality then + enoughCount = enoughCount + 1 + end + end + + if enoughCount >= self.BuffCfg.QualityCount then + self.PanalOn.gameObject:SetActiveEx(true) + self.PanelOFF.gameObject:SetActiveEx(false) + self.UiRoot:PlayAnimation("PanalOnQiHuan") + + for _, player in pairs(roomData.PlayerDataList) do + local initQualty = player.FightNpcData.Character.InitQuality + if initQualty <= self.BuffCfg.AffectQuality then + self.PlayerActiveBuffOnList[player.Id] = true + end + end + + if not self.ActiveOn then + -- XUiManager.TipMsg(self.BuffCfg.ActiveTip) + self.UiRoot:InsertActiveTips(self.BuffCfg.ActiveTip) + end + self.ActiveOn = true + else + self.ActiveOn = false + self.PanalOn.gameObject:SetActiveEx(false) + self.PanelOFF.gameObject:SetActiveEx(true) + self.UiRoot:PlayAnimation("PanelOFFQiHuan") + end + self.TxtDesc.text = CS.XTextManager.GetText("ArenaOnlineActiveBuffDesc", enoughCount, self.BuffCfg.QualityCount) + self.RawOnIcon:SetRawImage(self.BuffCfg.OnIcon) + self.RawOffIcon:SetRawImage(self.BuffCfg.OffIcon) +end + +function XUiPanelActiveBuffMian:CheckActiveOn(playerId) + return self.PlayerActiveBuffOnList and self.PlayerActiveBuffOnList[playerId] +end + +function XUiPanelActiveBuffMian:OnBenDescClick() + self.UiRoot:PanelActiveBuffShow(self.BuffCfg) +end + +return XUiPanelActiveBuffMian \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMultiplayerRoom/XUiPanelChangeStage.lua b/Resources/Scripts/XUi/XUiMultiplayerRoom/XUiPanelChangeStage.lua new file mode 100644 index 00000000..086ba737 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMultiplayerRoom/XUiPanelChangeStage.lua @@ -0,0 +1,80 @@ +local XUiPanelChangeStage = XClass(nil, "XUiPanelChangeStage") + +function XUiPanelChangeStage:Ctor(ui, offlineFlag) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.GridStageList = {} + XTool.InitUiObject(self) + self:AutoAddListener() + self.GridStage.gameObject:SetActiveEx(false) + self.OfflineFlag = offlineFlag +end + +function XUiPanelChangeStage:AutoAddListener() + self.BtnClose.CallBack = function() self:Hide() end +end + +function XUiPanelChangeStage:Show(challengeId, callBack) + self:Refresh(challengeId, callBack) + self.GameObject:SetActiveEx(true) +end + +function XUiPanelChangeStage:Hide() + self.GameObject:SetActiveEx(false) +end + +function XUiPanelChangeStage:Refresh(challengeId) + local t = XDataCenter.ArenaOnlineManager.GetCurSectionData() + local stageIds = t.Stages + for _, v in ipairs(self.GridStageList) do + v.gameObject:SetActive(false) + end + + if not stageIds or #stageIds <= 0 then + return + end + + for index, stageId in ipairs(stageIds) do + local grid = self.GridStageList[index] + if not grid then + local go = CS.UnityEngine.GameObject.Instantiate(self.GridStage.gameObject) + grid = go.transform + grid:SetParent(self.PanelContent, false) + table.insert(self.GridStageList, grid) + end + grid.gameObject:SetActive(true) + + local btn = XUiHelper.TryGetComponent(grid.transform, "BtnChange", "Button") + local name = XUiHelper.TryGetComponent(grid.transform, "TxtStage", "Text") + local cur = XUiHelper.TryGetComponent(grid.transform, "PanelCurStgae") + + local cfg = XArenaOnlineConfigs.GetStageById(stageId) + name.text = cfg.Name + local isCur = cfg.Id == challengeId + cur.gameObject:SetActiveEx(isCur) + btn.gameObject:SetActiveEx(not isCur) + btn.CallBack = function() + if self.OfflineFlag and not cfg.SingleSwitch then + XUiManager.TipText("ArenaOnlineCanNotSwitchToUnopenedSingleStage") + return + end + local titletext = CS.XTextManager.GetText("TipTitle") + local contenttext = CS.XTextManager.GetText("ArenaOnlineStageChangeTip", cfg.Name) + XUiManager.DialogTip(titletext, contenttext, XUiManager.DialogType.Normal, nil, function() + if self.OfflineFlag then + local data = {ChallengeId = stageId} + local cfg = XDataCenter.ArenaOnlineManager.GetArenaOnlineStageCfgStageId(stageId) + local levelControl = XFubenConfigs.GetStageMultiplayerLevelControlCfgById(cfg.SingleDiff[1]) + XEventManager.DispatchEvent(XEventId.EVENT_ROOM_CHANGE_STAGE, levelControl.StageId, data) + self:Hide() + else + XDataCenter.RoomManager.ArenaOnlineSetStageId(stageId ,function() + self:Hide() + end) + end + end) + end + end +end + +return XUiPanelChangeStage \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMusicPlayer/XUiGridMusicPlayer.lua b/Resources/Scripts/XUi/XUiMusicPlayer/XUiGridMusicPlayer.lua new file mode 100644 index 00000000..d452a664 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMusicPlayer/XUiGridMusicPlayer.lua @@ -0,0 +1,27 @@ +-- +-- Author: wujie +-- Note: 播放器专辑格子相关 + +local UiGridMusicPlayer = XClass(nil, "UiGridMusicPlayer") + +function UiGridMusicPlayer:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) +end + +function UiGridMusicPlayer:Refresh(id) + self.Id = id + local template = XMusicPlayerConfigs.GetAlbumTemplateById(id) + local coverPath = template.Cover + self.RImgCoverSelect:SetRawImage(coverPath) + self.RImgCoverNotSelect:SetRawImage(coverPath) +end + +function UiGridMusicPlayer:UpdateSelect(isSelect) + self.PanelSelect.gameObject:SetActiveEx(isSelect) + self.PanelNotSelect.gameObject:SetActiveEx(not isSelect) +end + +return UiGridMusicPlayer \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMusicPlayer/XUiMusicPlayer.lua b/Resources/Scripts/XUi/XUiMusicPlayer/XUiMusicPlayer.lua new file mode 100644 index 00000000..59c0f293 --- /dev/null +++ b/Resources/Scripts/XUi/XUiMusicPlayer/XUiMusicPlayer.lua @@ -0,0 +1,207 @@ +-- +-- Author: wujie +-- Note: 播放器的专辑界面 +local XUiMusicPlayer = XLuaUiManager.Register(XLuaUi, "UiMusicPlayer") + +local XUiGridMusicPlayer = require("XUi/XUiMusicPlayer/XUiGridMusicPlayer") +local XUiPanelMusicSpectrum = require("XUi/XUiMusicPlayer/XUiPanelMusicSpectrum") + +local ScheduleIntervalTime = CS.XGame.ClientConfig:GetInt("MusicPlayerSpectrumIntervalTime") +local CSXAudioManager = CS.XAudioManager + +function XUiMusicPlayer:OnAwake() + self.PanelSpectrumList = { + XUiPanelMusicSpectrum.New(self.PanelLeftBar), + XUiPanelMusicSpectrum.New(self.PanelRightBar), + } + + self:InitDynamicTable() + self:AutoAddListener() +end + +function XUiMusicPlayer:OnStart(closeCallback) + self.CloseCallback = closeCallback + self.IsFirstHandleSelect = true + + CSXAudioManager.StopAll() + + self.CurMusicVolume = CSXAudioManager.GetMusicVolume() + self.DynamicTableDataList = XMusicPlayerConfigs.GetAlbumIdList() + + local uiMainNeedPlayedAlbumId = XDataCenter.MusicPlayerManager.GetUiMainNeedPlayedAlbumId() + for index, id in ipairs(self.DynamicTableDataList) do + if id == uiMainNeedPlayedAlbumId then + self.SelectedIndex = index + break + end + end + if not self.SelectedIndex then + self.SelectedIndex = 1 + end +end + +function XUiMusicPlayer:OnEnable() + self:UpdateDynamicTable() + self:UpdateSelect(self.SelectedIndex) + self.PlayableDirectorFrontEffectEnable.transform:PlayTimelineAnimation(function(isFinish) self:OnPlayFrontEffectEnableFinish(isFinish) end) + self.PanelFrontEffect.gameObject:SetActiveEx(true) +end + +function XUiMusicPlayer:OnDisable() + if self.ScheduleId then + XScheduleManager.UnSchedule(self.ScheduleId) + self.ScheduleId = nil + end + CSXAudioManager.StopMusicWithAnalyzer() + CSXAudioManager.PlayMusic(CSXAudioManager.UiMainNeedPlayedBgmCueId) +end + +function XUiMusicPlayer:AutoAddListener() + self.BtnBack.CallBack = function() self:OnClose() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + self.BtnChange.CallBack = function() self:OnBtnChangeClick() end +end + +function XUiMusicPlayer:InitDynamicTable() + self.DynamicTable = XDynamicTableCurve.New(self.PanelDynamicTable) + self.DynamicTable:SetProxy(XUiGridMusicPlayer) + self.DynamicTable:SetDelegate(self) +end + +function XUiMusicPlayer:UpdateDynamicTable() + self.DynamicTableDataList = self.DynamicTableDataList or {} + self.DynamicTable:SetDataSource(self.DynamicTableDataList) + self.DynamicTable:ReloadData(#self.DynamicTableDataList > 0 and (self.SelectedIndex - 1) or -1) +end + +function XUiMusicPlayer:UpdateAlbumContent(id) + local template = XMusicPlayerConfigs.GetAlbumTemplateById(id) + if self.IsFirstHandleSelect then + self.RImgBg:SetRawImage(template.Bg) + self.IsFirstHandleSelect = nil + else + self.PlayableDirectorBgImgDisable.gameObject:SetActiveEx(false) + self.PlayableDirectorBgImgEnable.gameObject:SetActiveEx(false) + + self.PlayableDirectorBgImgDisable.gameObject:SetActiveEx(true) + self.PlayableDirectorBgImgDisable.transform:PlayTimelineAnimation(function(isFinish) self:OnPlayBgImgDisableFinish(isFinish, template.Bg) end) + end + + self.TxtMusicName.text = template.Name + self.TxtComposer.text = template.Composer + if XDataCenter.MusicPlayerManager.GetUiMainNeedPlayedAlbumId() == id then + self.BtnChange.gameObject:SetActiveEx(false) + self.ImgChangeDisable.gameObject:SetActiveEx(true) + else + self.BtnChange.gameObject:SetActiveEx(true) + self.ImgChangeDisable.gameObject:SetActiveEx(false) + end +end + +function XUiMusicPlayer:UpdateSpectrum(id) + local template = XMusicPlayerConfigs.GetAlbumTemplateById(id) + CSXAudioManager.PlayMusicWithAnalyzer(template.CueId) + if self.ScheduleId then + XScheduleManager.UnSchedule(self.ScheduleId) + self.ScheduleId = nil + end + self.ScheduleId = XScheduleManager.ScheduleForever(function() + local spectrumData = CSXAudioManager.GetSpectrumLvData() + for _, panel in ipairs(self.PanelSpectrumList) do + panel:UpdateSpectrum(spectrumData) + end + end, ScheduleIntervalTime, 0) +end + +function XUiMusicPlayer:UpdateSelect(index) + local id = self.DynamicTableDataList[index] + self:UpdateAlbumContent(id) + if self.CurMusicVolume ~= 0 then + self:UpdateSpectrum(id) + end + local startIndex = self.DynamicTable.Imp.StartIndex + for idx, grid in pairs(self.DynamicTable:GetGrids()) do + grid:UpdateSelect(idx == startIndex) + end + + self.PlayableDirectorBgEffectEnable.gameObject:SetActiveEx(false) + self.PlayableDirectorBgEffectLoop:Stop() + + self.PlayableDirectorBgEffectEnable.gameObject:SetActiveEx(true) + self.PlayableDirectorBgEffectEnable.transform:PlayTimelineAnimation(function(isFinish) self:OnPlayBgEffectEnableFinish(isFinish) end) +end + +--事件相关------------------------------------>>> +function XUiMusicPlayer:OnClose() + if self.CloseCallback then + self.CloseCallback() + self.CloseCallback = nil + end + self:Close() +end + +function XUiMusicPlayer:OnBtnMainUiClick() + if self.CloseCallback then + self.CloseCallback() + self.CloseCallback = nil + end + XLuaUiManager.RunMain() +end + +function XUiMusicPlayer:OnBtnChangeClick() + local selelctedId = self.DynamicTableDataList[self.SelectedIndex] + if selelctedId == XDataCenter.MusicPlayerManager.GetUiMainNeedPlayedAlbumId() then return end + XDataCenter.MusicPlayerManager.ChangeUiMainAlbumId(selelctedId) + self.BtnChange.gameObject:SetActiveEx(false) + self.ImgChangeDisable.gameObject:SetActiveEx(true) + XUiManager.TipError(CS.XTextManager.GetText("MusicPlayerAlbumSetSuccess")) +end + +function XUiMusicPlayer:OnPlayFrontEffectEnableFinish(isFinish) + if not isFinish then return end + self.PlayableDirectorFrontEffectLoop:Evaluate() + self.PlayableDirectorFrontEffectLoop:Play() +end + +function XUiMusicPlayer:OnPlayBgEffectEnableFinish(isFinish) + if not isFinish then return end + self.PlayableDirectorBgEffectLoop:Evaluate() + self.PlayableDirectorBgEffectLoop:Play() +end + +function XUiMusicPlayer:OnPlayBgImgDisableFinish(isFinish, bgPath) + if not isFinish then return end + self.RImgBg:SetRawImage(bgPath) + self.PlayableDirectorBgImgEnable.gameObject:SetActiveEx(true) + self.PlayableDirectorBgImgEnable.transform:PlayTimelineAnimation() +end + +function XUiMusicPlayer:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + index = index % self.DynamicTable.Imp.TotalCount + 1 + local id = self.DynamicTableDataList[index] + grid:Refresh(id) + grid:UpdateSelect(false) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_TWEEN_OVER then + local startIndex = self.DynamicTable.Imp.StartIndex + local selectIndex = startIndex % self.DynamicTable.Imp.TotalCount + 1 + if self.SelectedIndex ~= selectIndex then + self.SelectedIndex = selectIndex + self:UpdateSelect(selectIndex) + end + + self.PlayableDirectorFrontEffectEnable.gameObject:SetActiveEx(false) + self.PlayableDirectorFrontEffectLoop:Stop() + + self.PanelFrontEffect.gameObject:SetActiveEx(true) + self.PlayableDirectorFrontEffectEnable.gameObject:SetActiveEx(true) + self.PlayableDirectorFrontEffectEnable.transform:PlayTimelineAnimation(function(isFinish) self:OnPlayFrontEffectEnableFinish(isFinish) end) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + self.DynamicTable.Imp:TweenToIndex(index) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_BEGIN_DRAG then + self.PlayableDirectorFrontEffectEnable.gameObject:SetActiveEx(false) + self.PlayableDirectorFrontEffectLoop:Stop() + self.PanelFrontEffect.gameObject:SetActiveEx(false) + end +end +--事件相关------------------------------------<<< \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiMusicPlayer/XUiPanelMusicSpectrum.lua b/Resources/Scripts/XUi/XUiMusicPlayer/XUiPanelMusicSpectrum.lua new file mode 100644 index 00000000..123e81da --- /dev/null +++ b/Resources/Scripts/XUi/XUiMusicPlayer/XUiPanelMusicSpectrum.lua @@ -0,0 +1,49 @@ +-- +-- Author: wujie +-- Note: 频谱ui + +local XUiPanelMusicSpectrum = XClass(nil, "XUiPanelMusicSpectrum") + +local XMathClamp = XMath.Clamp +local SpectrumMinHeight = CS.XGame.ClientConfig:GetFloat("MusicPlayerSpectrumMinHeight") +local SpectrumBaseHeight = CS.XGame.ClientConfig:GetFloat("MusicPlayerSpectrumBaseHeight") +local SpectrumMaxHeight = CS.XGame.ClientConfig:GetFloat("MusicPlayerSpectrumMaxHeight") +local SpectrumIgnoreFrequencyCount = CS.XGame.ClientConfig:GetInt("MusicPlayerSpectrumIgnoreFrequencyCount") + +function XUiPanelMusicSpectrum:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + self.ImgBarRectTransformList = { + self.ImgBarRectTransform1, self.ImgBarRectTransform2, self.ImgBarRectTransform3, self.ImgBarRectTransform4, self.ImgBarRectTransform5, + self.ImgBarRectTransform6, self.ImgBarRectTransform7, self.ImgBarRectTransform8, self.ImgBarRectTransform9, self.ImgBarRectTransform10, + self.ImgBarRectTransform11, self.ImgBarRectTransform12, self.ImgBarRectTransform13, self.ImgBarRectTransform14, self.ImgBarRectTransform15, + self.ImgBarRectTransform16, self.ImgBarRectTransform17, self.ImgBarRectTransform18, self.ImgBarRectTransform19, self.ImgBarRectTransform20, + self.ImgBarRectTransform21, self.ImgBarRectTransform22, self.ImgBarRectTransform23, self.ImgBarRectTransform24, self.ImgBarRectTransform25, + self.ImgBarRectTransform26, self.ImgBarRectTransform27, self.ImgBarRectTransform28, self.ImgBarRectTransform29, self.ImgBarRectTransform30, + self.ImgBarRectTransform31, self.ImgBarRectTransform32, self.ImgBarRectTransform33, self.ImgBarRectTransform34, self.ImgBarRectTransform35, + self.ImgBarRectTransform36, self.ImgBarRectTransform37, self.ImgBarRectTransform38, self.ImgBarRectTransform39, self.ImgBarRectTransform40, + self.ImgBarRectTransform41, self.ImgBarRectTransform42, self.ImgBarRectTransform43, self.ImgBarRectTransform44, self.ImgBarRectTransform45, + self.ImgBarRectTransform46, self.ImgBarRectTransform47, self.ImgBarRectTransform48, self.ImgBarRectTransform49, self.ImgBarRectTransform50, + self.ImgBarRectTransform51, self.ImgBarRectTransform52, self.ImgBarRectTransform53, self.ImgBarRectTransform54, self.ImgBarRectTransform55, + self.ImgBarRectTransform56, self.ImgBarRectTransform57, self.ImgBarRectTransform58, self.ImgBarRectTransform59, self.ImgBarRectTransform60, + } +end + +function XUiPanelMusicSpectrum:UpdateSpectrum(spectrumData) + local spectrumDataLength = spectrumData.Length + local height + for i, rectTransform in ipairs(self.ImgBarRectTransformList) do + if i <= spectrumDataLength then + rectTransform.gameObject:SetActiveEx(true) + local spectrumValue = spectrumData[i+SpectrumIgnoreFrequencyCount-1] or 0 + height = XMathClamp(spectrumValue * SpectrumBaseHeight, SpectrumMinHeight, SpectrumMaxHeight) + rectTransform:SetSizeDeltaY(height) + else + rectTransform.gameObject:SetActiveEx(false) + end + end +end + +return XUiPanelMusicSpectrum \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNameplate/XUiGridNameplate.lua b/Resources/Scripts/XUi/XUiNameplate/XUiGridNameplate.lua new file mode 100644 index 00000000..a81fe509 --- /dev/null +++ b/Resources/Scripts/XUi/XUiNameplate/XUiGridNameplate.lua @@ -0,0 +1,167 @@ +local XUiGridNameplate = XClass(nil, "XUiGridNameplate") +local XUiPanelNameplate = require("XUi/XUiNameplate/XUiPanelNameplate") + + +function XUiGridNameplate:Ctor(ui, rootUi) + self.RootUi = rootUi + self.Transform = ui.transform + self.GameObject = ui.gameObject + XTool.InitUiObject(self) + + self.UiPanelNameplate = XUiPanelNameplate.New(self.PanelNameplate, rootUi) + + self.BtnSelect.CallBack = function() + self:OnBtnSelect() + end +end + +function XUiGridNameplate:UpdateDataByGet(data, needSelClick, isHave) + self.IsOnlyShow = true + if data:IsNamepalteExpire() then + self.TxtMedalName.text = CS.XTextManager.GetText("GetNamepalteIsExpire", data:GetNameplateName()) + else + if isHave then + self.TxtMedalName.text = CS.XTextManager.GetText("NameplateIsHave", data:GetNameplateName()) + else + self.TxtMedalName.text = data:GetNameplateName() + end + end + + self.Data = data + self.NeedSelClick = needSelClick + self.UiPanelNameplate:UpdateDataById(data:GetNameplateId()) + + self.PanelTime.gameObject:SetActiveEx(false) + if not data:IsNamepalteExpire() then + if not data:IsNamepalteForever() then + self.PanelTime.gameObject:SetActiveEx(true) + self:SetTimePanel(data:GetNamepalteLeftTime()) + end + end +end + +function XUiGridNameplate:UpdateData(data, needSelClick, isInList) + self.PanelNew.gameObject:SetActiveEx(false) + self.PanelTime.gameObject:SetActiveEx(false) + self.LabelPress.gameObject:SetActiveEx(false) + self.LabelLock.gameObject:SetActiveEx(false) + self.Red.gameObject:SetActiveEx(false) + self.TxtMedalName.text = data:GetNameplateName() + self.Data = data + self.NeedSelClick = needSelClick + self.IsInList = isInList + self.UiPanelNameplate:UpdateDataById(data:GetNameplateId()) + if data:IsNameplateNew() then + self.PanelNew.gameObject:SetActiveEx(true) + if data:IsNameplateDress() then + self.LabelPress.gameObject:SetActiveEx(true) + end + else + if not data:IsNamepalteExpire() then + if not data:IsNamepalteForever() then + self.PanelTime.gameObject:SetActiveEx(true) + self:SetTimePanel(data:GetNamepalteLeftTime()) + end + + if data:IsNameplateDress() then + self.LabelPress.gameObject:SetActiveEx(true) + end + if self.PanelStale then + self.PanelStale.gameObject:SetActiveEx(false) + end + else + if self.PanelStale then + self.PanelStale.gameObject:SetActiveEx(true) + end + end + end +end + +function XUiGridNameplate:UpdateDataById(nameplateId, needSelClick, isInList, isInReward) + self.PanelNew.gameObject:SetActiveEx(false) + self.PanelTime.gameObject:SetActiveEx(false) + self.LabelPress.gameObject:SetActiveEx(false) + self.LabelLock.gameObject:SetActiveEx(false) + + self.Red.gameObject:SetActiveEx(false) + self.TxtMedalName.text = XMedalConfigs.GetNameplateName(nameplateId) + + local data = XDataCenter.MedalManager.CheckNameplateGroupUnluck(XMedalConfigs.GetNameplateGroup(nameplateId)) + if data and data:GetNameplateId() == nameplateId then + self.Data = data + end + + self.NeedSelClick = needSelClick + self.IsInList = isInList + self.UiPanelNameplate:UpdateDataById(nameplateId) + if self.PanelStale then + self.PanelStale.gameObject:SetActiveEx(false) + end + if not data or isInReward then + return + end + if data:IsNameplateNew() then + self.PanelNew.gameObject:SetActiveEx(true) + if data:IsNameplateDress() then + self.LabelPress.gameObject:SetActiveEx(true) + end + else + if not data:IsNamepalteExpire() then + if not data:IsNamepalteForever() then + self.PanelTime.gameObject:SetActiveEx(true) + self:SetTimePanel(data:GetNamepalteLeftTime()) + end + + if data:IsNameplateDress() then + self.LabelPress.gameObject:SetActiveEx(true) + end + if self.PanelStale then + self.PanelStale.gameObject:SetActiveEx(false) + end + else + if self.PanelStale then + self.PanelStale.gameObject:SetActiveEx(true) + end + end + end +end + +function XUiGridNameplate:HideNewLabel() + self.PanelNew.gameObject:SetActiveEx(false) +end + +function XUiGridNameplate:HidePressLabel() + self.LabelPress.gameObject:SetActiveEx(false) +end + +function XUiGridNameplate:SetTimePanel(leftTime) + if self.ImageTime then + local sprite = nil + local text = "" + -- if XDataCenter.ItemManager.IsCanConvert(self.TemplateId) then + -- sprite = XUiHelper.TagBgPath.Blue + -- text = CS.XTextManager.GetText("ItemCanConvert") + -- else + if leftTime then + text, sprite = XUiHelper.GetBagTimeLimitTimeStrAndBg(leftTime) + end + if sprite then + self.ImageTime:SetSprite(sprite) + self.ImageTime.gameObject:SetActive(true) + self.TextTime.text = text or "" + else + self.ImageTime.gameObject:SetActive(false) + end + end +end + +function XUiGridNameplate:OnBtnSelect() + if self.NeedSelClick then + XLuaUiManager.Open("UiNameplateTip", self.Data:GetNameplateId(), self.IsOnlyShow) + if self.IsInList then + XDataCenter.MedalManager.SetNameplateRedPointDic(self.Data:GetNameplateId()) + end + end +end + +return XUiGridNameplate \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNameplate/XUiNameplateTip.lua b/Resources/Scripts/XUi/XUiNameplate/XUiNameplateTip.lua new file mode 100644 index 00000000..9df4f7e7 --- /dev/null +++ b/Resources/Scripts/XUi/XUiNameplate/XUiNameplateTip.lua @@ -0,0 +1,134 @@ +local XUiNameplateTip = XLuaUiManager.Register(XLuaUi, "UiNameplateTip") +local XUiGridNameplate = require("XUi/XUiNameplate/XUiGridNameplate") + + +function XUiNameplateTip:OnAwake() + + self.BtnClose.CallBack = function() + self:Close() + end + + self.BtnDress.CallBack = function() + self:OnBtnDressClick() + end + self.BtnUnDress.CallBack = function() + self:OnBtnDressClick(true) + end + + self.NameplateGrid = XUiGridNameplate.New(self.GridNameplate, self) + self.TxtHintList = {} + + for index = 1, 4 do + self.TxtHintList[index] = self["TxtHint"..index] + end + + +end + +function XUiNameplateTip:OnStart(Id, isOnlyShow, isInReward) + self.NameplateId = Id + local data = XDataCenter.MedalManager.CheckNameplateGroupUnluck(XMedalConfigs.GetNameplateGroup(Id)) + if data and data:GetNameplateId() == Id then + self.Data = data + end + self.IsOnlyShow = isOnlyShow + self.IsInReward = isInReward + self:UpdateAllInfo(self.NameplateId, self.Data) +end + +function XUiNameplateTip:OnEnable() + +end + +function XUiNameplateTip:UpdateAllInfo(nameplateId, nameplateData) + self:UpdateRightPanel(nameplateId, nameplateData) + self:UpdateNameplatePanel(nameplateId, nameplateData) +end + +function XUiNameplateTip:UpdateRightPanel(nameplateId, nameplateData) + self.TxtTitleName.text = XMedalConfigs.GetNameplateName(nameplateId) + self.TxtInfo.text = XMedalConfigs.GetNameplateDescription(nameplateId) + local HintList = XMedalConfigs.GetNameplateHint(nameplateId) + for index, text in pairs(self.TxtHintList) do + if HintList[index] then + text.text = HintList[index] + text.gameObject:SetActiveEx(true) + else + text.gameObject:SetActiveEx(false) + end + end + + if self.IsOnlyShow or not nameplateData then + self.BtnDress.gameObject:SetActiveEx(false) + self.BtnUnDress.gameObject:SetActiveEx(false) + else + if not nameplateData:IsNamepalteExpire() then + if nameplateData:IsNameplateDress() then + self.BtnDress.gameObject:SetActiveEx(false) + self.BtnUnDress.gameObject:SetActiveEx(true) + else + self.BtnDress.gameObject:SetActiveEx(true) + self.BtnUnDress.gameObject:SetActiveEx(false) + self.BtnDress:SetDisable(false) + end + else + self.BtnDress.gameObject:SetActiveEx(true) + self.BtnUnDress.gameObject:SetActiveEx(false) + self.BtnDress:SetDisable(true, false) + end + end + + self.PanelNameplateCondition.gameObject:SetActiveEx(true) + self.TxtCondition.text = XMedalConfigs.GetNameplateGetWay(nameplateId) + if nameplateData and XDataCenter.MedalManager.CheckNameplateGroupUnluck(nameplateData:GetNameplateGroup()) then + self.ImgConditionUnlock.gameObject:SetActiveEx(true) + else + self.ImgConditionUnlock.gameObject:SetActiveEx(false) + end + + if nameplateData and nameplateData:GetNamepalteGetTime() then + self.TxtTime.text = CS.XTextManager.GetText("NameplateGetTime", nameplateData:GetNamepalteGetTimeToString()) + else + self.TxtTime.text = "" + end +end + +function XUiNameplateTip:UpdateNameplatePanel(nameplateId, nameplateData) + self.NameplateGrid:UpdateDataById(nameplateId, false, false, self.IsInReward) + self.NameplateGrid:HideNewLabel() + if self.IsOnlyShow then + self.NameplateGrid:HidePressLabel() + end + if not XMedalConfigs.GetNameplateQualityIcon(nameplateId) then + self.IconLevel.gameObject:SetActiveEx(false) + else + self.IconLevel.gameObject:SetActiveEx(true) + self.IconLevel:SetSprite(XMedalConfigs.GetNameplateQualityIcon(nameplateId)) + end + + if XMedalConfigs.GetNameplateUpgradeType(nameplateId) ~= XMedalConfigs.NameplateGetType.TypeThree or not nameplateData then + self.PanelLevel.gameObject:SetActiveEx(false) + else + self.PanelLevel.gameObject:SetActiveEx(true) + self.TextLevel.text = CS.XTextManager.GetText("NameplateLv", XMedalConfigs.GetNameplateQuality(nameplateId)) + self.TextNum.text = CS.XTextManager.GetText("NameplateExp", nameplateData:GetNamepalteExp(), nameplateData:GetNameplateUpgradeExp()) + self.ImageExp.fillAmount = nameplateData:GetNamepalteExp() / nameplateData:GetNameplateUpgradeExp() + end + +end + +function XUiNameplateTip:ShowLock(IsLock) + self.ImgConditionUnlock.gameObject:SetActiveEx(not IsLock) +end + +function XUiNameplateTip:OnBtnDressClick(isUnDress) + if not self.Data:IsNamepalteExpire() then + local nameplateId = isUnDress and 0 or self.Data:GetNameplateId() + XDataCenter.MedalManager.WearNameplate(nameplateId, function() + self:UpdateAllInfo(self.NameplateId, self.Data) + end) + else + self:UpdateAllInfo(self.NameplateId, self.Data) + XUiManager.TipText("NameplateOutTime") + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNameplate/XUiObtainNameplate.lua b/Resources/Scripts/XUi/XUiNameplate/XUiObtainNameplate.lua new file mode 100644 index 00000000..9e41b6cc --- /dev/null +++ b/Resources/Scripts/XUi/XUiNameplate/XUiObtainNameplate.lua @@ -0,0 +1,54 @@ +local XUiObtainNameplate = XLuaUiManager.Register(XLuaUi, "UiObtainNameplate") +local XUiGridNameplate = require("XUi/XUiNameplate/XUiGridNameplate") +function XUiObtainNameplate:OnAwake() + self.BtnClose.CallBack = function() + self:Close() + end + self.GridPanelOne = XUiGridNameplate.New(self.PanelOneGrid, self) + self.GridPanelTwo = XUiGridNameplate.New(self.PanelTwoGrid, self) + self.GridPanelTwo2 = XUiGridNameplate.New(self.PanelTwoGridTwo, self) + self.GridPanelOneThree = XUiGridNameplate.New(self.PanelOneThreeGrid, self) + self.GridPanelFour = XUiGridNameplate.New(self.PanelFourGrid, self) + self.GridPanelFour2 = XUiGridCommon.New(self, self.PanelFourGridProperty) +end + +function XUiObtainNameplate:OnStart(data, lastData, itemId, itemCount) + self.PanelOne.gameObject:SetActiveEx(false) + self.PanelTwo.gameObject:SetActiveEx(false) + self.PanelOneThree.gameObject:SetActiveEx(false) + self.PanelFour.gameObject:SetActiveEx(false) + if not lastData then + if data:GetNameplateUpgradeType() == XMedalConfigs.NameplateGetType.TypeFour and itemId then + self.PanelFour.gameObject:SetActiveEx(true) + self:PlayAnimation("AnimEnable4") + self.GridPanelFour:UpdateDataByGet(data) + local itemData = { TemplateId = itemId, Count = itemCount } + self.GridPanelFour2:Refresh(itemData) + + self.PanelFourTxtTips.text = CS.XTextManager.GetText("NameplateToItemStr", XItemConfigs.GetItemNameById(itemId)) + else + self.PanelOne.gameObject:SetActiveEx(true) + self:PlayAnimation("AnimEnable1") + self.GridPanelOne:UpdateDataByGet(data, true, false) + end + else + if data:GetNameplateId() ~= lastData:GetNameplateId() then + self.PanelTwo.gameObject:SetActiveEx(true) + self:PlayAnimation("AnimEnable2") + self.GridPanelTwo:UpdateDataByGet(lastData) + self.GridPanelTwo2:UpdateDataByGet(data) + else + self.PanelOneThree.gameObject:SetActiveEx(true) + self:PlayAnimation("AnimEnable3") + self.GridPanelOneThree:UpdateDataByGet(data, true, true) + end + end +end + +function XUiObtainNameplate:OnEnable() + +end + +function XUiObtainNameplate:OnDestroy() + XDataCenter.MedalManager.OpenNextUiObtainNameplate() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNameplate/XUiPanelNameplate.lua b/Resources/Scripts/XUi/XUiNameplate/XUiPanelNameplate.lua new file mode 100644 index 00000000..78c92a25 --- /dev/null +++ b/Resources/Scripts/XUi/XUiNameplate/XUiPanelNameplate.lua @@ -0,0 +1,46 @@ +local XUiPanelNameplate = XClass(nil, "XUiPanelNameplate") + +function XUiPanelNameplate:Ctor(ui, rootUi) + self.RootUi = rootUi + self.Transform = ui.transform + self.GameObject = ui.gameObject + XTool.InitUiObject(self) +end + +function XUiPanelNameplate:UpdateDataById(id) + self.PanelGold.gameObject:SetActiveEx(true) + self.PanelSilver.gameObject:SetActiveEx(false) + self.PanelCopper.gameObject:SetActiveEx(false) + if XMedalConfigs.GetNameplateIconType(id) == XMedalConfigs.NameplateShow.ShowIcon then + self.ImgGold:SetSprite(XMedalConfigs.GetNameplateIcon(id)) + self.TxtGold.gameObject:SetActiveEx(false) + else + local icon, title = XMedalConfigs.GetNameplateIcon(id) + self.ImgGold:SetSprite(icon) + self.TxtGold.gameObject:SetActiveEx(true) + self.TxtGold.text = title + self.TxtGoldOutLine.effectColor = XUiHelper.Hexcolor2Color(XMedalConfigs.GetNameplateOutLineColor(id)) + end + + -- if Quality == XMedalConfigs.NameplateQuality.Copper then + -- self.PanelGold.gameObject:SetActiveEx(false) + -- self.PanelSilver.gameObject:SetActiveEx(false) + -- self.PanelCopper.gameObject:SetActiveEx(true) + -- --self.ImgCopper:SetSprite("") + -- self.TxtCopper.text = Title + -- elseif Quality == XMedalConfigs.NameplateQuality.Silver then + -- self.PanelGold.gameObject:SetActiveEx(false) + -- self.PanelSilver.gameObject:SetActiveEx(true) + -- self.PanelCopper.gameObject:SetActiveEx(false) + -- --self.ImgSilver:SetSprite("") + -- self.TxtSilver.text = Title + -- elseif Quality == XMedalConfigs.NameplateQuality.Gold then + -- self.PanelGold.gameObject:SetActiveEx(true) + -- self.PanelSilver.gameObject:SetActiveEx(false) + -- self.PanelCopper.gameObject:SetActiveEx(false) + -- --self.ImgGold:SetSprite("") + -- self.TxtGold.text = Title + -- end +end + +return XUiPanelNameplate \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNewAutoFight/XUiGridAutoFightRewardLine.lua b/Resources/Scripts/XUi/XUiNewAutoFight/XUiGridAutoFightRewardLine.lua new file mode 100644 index 00000000..06f24d64 --- /dev/null +++ b/Resources/Scripts/XUi/XUiNewAutoFight/XUiGridAutoFightRewardLine.lua @@ -0,0 +1,43 @@ +local XUiGridAutoFightRewardLine = XClass(nil, "XUiGridAutoFightRewardLine") + +function XUiGridAutoFightRewardLine:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.GridReward.gameObject:SetActiveEx(false) + self.RewardGrids = {} +end + +function XUiGridAutoFightRewardLine:InitRootUi(rootUi) + self.RootUi = rootUi +end + +function XUiGridAutoFightRewardLine:Refresh(sweepRewards, index, isShow) + self.TxtOrder.text = index < 10 and "0" .. index or index + local rewardGoodsList = sweepRewards.RewardGoods or {} + local rewards = XRewardManager.MergeAndSortRewardGoodsList(rewardGoodsList) + for idx, item in ipairs(rewards) do + local grid = self.RewardGrids[idx] + if not grid then + local ui = CS.UnityEngine.Object.Instantiate(self.GridReward) + grid = XUiGridCommon.New(self.RootUi, ui) + grid.Transform:SetParent(self.PanelRewardContent, false) + grid.GameObject:SetActiveEx(true) + self.RewardGrids[idx] = grid + end + grid:Refresh(item, nil, nil, true) + end + + for i = #rewards + 1, #self.RewardGrids do + self.RewardGrids[i].GameObject:SetActiveEx(false) + end + if isShow then + self:Show() + end +end + +function XUiGridAutoFightRewardLine:Show() + self.Root.gameObject:SetActiveEx(true) +end + +return XUiGridAutoFightRewardLine \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNewAutoFight/XUiNewAutoFightDialog.lua b/Resources/Scripts/XUi/XUiNewAutoFight/XUiNewAutoFightDialog.lua new file mode 100644 index 00000000..f71edb88 --- /dev/null +++ b/Resources/Scripts/XUi/XUiNewAutoFight/XUiNewAutoFightDialog.lua @@ -0,0 +1,201 @@ +local XUiNewAutoFightDialog = XLuaUiManager.Register(XLuaUi, "UiAutoFightEnter") + +local tableinsert = table.insert + +local CsTextManagerGetText = CS.XTextManager.GetText + +function XUiNewAutoFightDialog:OnAwake() + self:InitComponent() +end + +function XUiNewAutoFightDialog:OnStart(stageId, stage) + self:InitUI(stageId, stage) +end + +function XUiNewAutoFightDialog:InitComponent() + self.BtnSub.CallBack = function() self:OnBtnSubClick() end + self.BtnAdd.CallBack = function() self:OnBtnAddClick() end + self.BtnMax.CallBack = function() self:OnBtnMaxClick() end + self.BtnEnter.CallBack = function() self:OnBtnEnterClick() end + self.BtnClose.CallBack = function() self:OnBtnCloseClick() end +end + +function XUiNewAutoFightDialog:InitUI(stageId, stage) + self.StageId = stageId + self.Stage = stage + self.StageData = XDataCenter.FubenManager.GetStageData(stageId) + self.GridList = {} + + self.TxtTitle.text = CsTextManagerGetText("AutoFightDialogTitle") + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + local autoFightCfg = XAutoFightConfig.GetCfg(stageCfg.AutoFightId) + + local maxChallengeNum = XDataCenter.FubenManager.GetStageMaxChallengeNums(stageId) + if maxChallengeNum > 0 then + local chanllengedNum = 0 + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + if stageInfo.Type == XDataCenter.FubenManager.StageType.Prequel then + local info = XDataCenter.PrequelManager.GetUnlockChallengeStagesByStageId(stageId) + if info then + chanllengedNum = info.Count + end + else + chanllengedNum = self.StageData and self.StageData.PassTimesToday or 0 + end + maxChallengeNum = maxChallengeNum - chanllengedNum + + if autoFightCfg.Limit > 0 then + maxChallengeNum = math.min(maxChallengeNum, autoFightCfg.Limit) + end + else + maxChallengeNum = autoFightCfg.Limit + end + + self.RequireAP = stageCfg.RequireActionPoint + self.LeftTimes = maxChallengeNum + self.RecordTime = self.StageData.LastRecordTime + + self.Head.gameObject:SetActiveEx(false) + self.GridCommon.gameObject:SetActiveEx(false) + self.PanelCostEx.gameObject:SetActiveEx(false) + + local cardIds = self.StageData.LastCardIds + if stageCfg.RobotId and #stageCfg.RobotId > 0 then + cardIds = {} + for _, v in pairs(stageCfg.RobotId) do + local charId = XRobotManager.GetCharacterId(v) + tableinsert(cardIds, charId) + end + end + + self:InitCharacters(cardIds) + self:InitRewards() + + self:SetFightTimes(1) +end + +function XUiNewAutoFightDialog:InitCharacters(characterIds) + local index = 0 + for _, id in pairs(characterIds) do + if id > 0 then + index = index + 1 + local transform + if index == 1 then + transform = self.Head + else + transform = CS.UnityEngine.Object.Instantiate(self.Head, self.CharacterContent) + end + + local img = transform:Find("ImgIcon"):GetComponent("RawImage") + local icon = XDataCenter.CharacterManager.GetCharRoundnessHeadIcon(id) + img:SetRawImage(icon) + transform.gameObject:SetActiveEx(true) + end + end +end + +function XUiNewAutoFightDialog:InitRewards() + local stageId = self.StageId + local cfg = XDataCenter.FubenManager.GetStageLevelControl(stageId) + + local rewardId = (cfg and cfg.FinishRewardShow) or (self.Stage and self.Stage.FinishRewardShow) + if not rewardId or rewardId == 0 then + self.PanelRewards.gameObject:SetActiveEx(false) + return + else + self.PanelRewards.gameObject:SetActiveEx(true) + end + + local rewards = XRewardManager.GetRewardListNotCount(rewardId) + if rewards then + for i, item in ipairs(rewards) do + local grid + if self.GridList[i] then + grid = self.GridList[i] + else + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommon) + grid = XUiGridCommon.New(self, ui) + grid.Transform:SetParent(self.PanelRewards, false) + self.GridList[i] = grid + end + grid:Refresh(item) + grid.GameObject:SetActive(true) + end + end + + local rewardsCount = 0 + if rewards then + rewardsCount = #rewards + end + + for j = 1, #self.GridList do + if j > rewardsCount then + self.GridList[j].GameObject:SetActive(false) + end + end +end + +function XUiNewAutoFightDialog:SetFightTimes(value) + self.FightTimes = value + self.TxtATNums.text = value * self.RequireAP + self.TxtChallengeNum.text = value + self.TxtRewardNum.text = "X" .. value + + local canSub = value > 1 + self.BtnSub.gameObject:SetActiveEx(canSub) + self.ImgCantSub.gameObject:SetActiveEx(not canSub) + + local canAdd = value < self.LeftTimes + self.BtnAdd.gameObject:SetActiveEx(canAdd) + self.ImgCantAdd.gameObject:SetActiveEx(not canAdd) +end + +function XUiNewAutoFightDialog:OnBtnSubClick() + local tempTimes = self.FightTimes - 1 + if tempTimes < 1 then + return + end + + self:SetFightTimes(tempTimes) +end + +function XUiNewAutoFightDialog:OnBtnAddClick() + local tempTimes = self.FightTimes + 1 + if tempTimes > self.LeftTimes then + return + end + + self:SetFightTimes(tempTimes) +end + +function XUiNewAutoFightDialog:OnBtnMaxClick() + local ownActionPoint = XDataCenter.ItemManager.GetCount(XDataCenter.ItemManager.ItemId.ActionPoint) + local times1 = self.RequireAP ~= 0 and math.floor(ownActionPoint / self.RequireAP) or self.LeftTimes + local maxTimes = math.min(times1, self.LeftTimes) + maxTimes = maxTimes > 0 and maxTimes or 1 + self:SetFightTimes(maxTimes) +end + +function XUiNewAutoFightDialog:OnBtnEnterClick() + if self.FightTimes == 0 then + return + end + + local stageCfg = XDataCenter.FubenManager.GetStageCfg(self.StageId) + if not XDataCenter.FubenManager.CheckPreFight(stageCfg, self.FightTimes, true) then + return + end + + XDataCenter.AutoFightManager.RecordFightBeginData(self.StageId, self.FightTimes, self.StageData.LastCardIds) + + XDataCenter.AutoFightManager.StartNewAutoFight(self.StageId, self.FightTimes, function(res) + if res.Code == XCode.Success then + self:Close() + XLuaUiManager.Open("UiNewAutoFightSettleWin", XDataCenter.AutoFightManager.GetAutoFightBeginData(), res) + end + end) +end + +function XUiNewAutoFightDialog:OnBtnCloseClick() + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNewAutoFight/XUiNewAutoFightSettleWin.lua b/Resources/Scripts/XUi/XUiNewAutoFight/XUiNewAutoFightSettleWin.lua new file mode 100644 index 00000000..c041ab02 --- /dev/null +++ b/Resources/Scripts/XUi/XUiNewAutoFight/XUiNewAutoFightSettleWin.lua @@ -0,0 +1,148 @@ +local XUiPanelExpBar = require("XUi/XUiSettleWinMainLine/XUiPanelExpBar") +local XUiGridAutoFightRewardLine = require("XUi/XUiNewAutoFight/XUiGridAutoFightRewardLine") + +local XUiNewAutoFightSettleWin = XLuaUiManager.Register(XLuaUi, "UiNewAutoFightSettleWin") + +function XUiNewAutoFightSettleWin:OnAwake() + self:InitComponent() + self:InitDynamicTable() +end + +function XUiNewAutoFightSettleWin:OnStart(beginData, winData) + if beginData == nil or winData == nil then + self:OnAnimationDone() + return + end + + self.StageCfg = XDataCenter.FubenManager.GetStageCfg(beginData.StageId) + self.Count = beginData.Times + self.BeginData = beginData + self.WinData = winData + + self:InitInfo() +end + +function XUiNewAutoFightSettleWin:InitComponent() + self.BtnConfirm.gameObject:SetActiveEx(false) + self.BtnConfirm.CallBack = function() self:OnBtnConfirmClick() end +end + +function XUiNewAutoFightSettleWin:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelRewards) + self.DynamicTable:SetDelegate(self) + self.DynamicTable:SetProxy(XUiGridAutoFightRewardLine) + self.GridRewardLine.gameObject:SetActiveEx(false) +end + +function XUiNewAutoFightSettleWin:UpdateDynamicTable(rewardLineList) + self.RewardLineList = rewardLineList + self.IsListCompleted = false + self.GridCount = #self.RewardLineList + self.DynamicTable:SetDataSource(self.RewardLineList) + self.DynamicTable:ReloadDataSync() +end + +function XUiNewAutoFightSettleWin:InitInfo() + self.TxtStageName.text = XDataCenter.FubenManager.GetStageName(self.BeginData.StageId) + + self:InitRewardCharacterList(self.BeginData.CharExp) + self:UpdatePlayerInfo(self.BeginData) + + local sweepRewards = self.WinData.SweepRewards + if not sweepRewards or next(sweepRewards) == nil then + self:OnAnimationDone() + else + self:UpdateDynamicTable(sweepRewards) + end +end + +-- 角色奖励列表 +function XUiNewAutoFightSettleWin:InitRewardCharacterList(charExps) + self.GridWinRole.gameObject:SetActive(false) + if self.StageCfg.RobotId and #self.StageCfg.RobotId > 0 then + for i = 1, #self.StageCfg.RobotId do + if self.StageCfg.RobotId[i] > 0 then + local ui = CS.UnityEngine.Object.Instantiate(self.GridWinRole) + local grid = XUiGridWinRole.New(self, ui) + grid.Transform:SetParent(self.PanelRoleContent, false) + grid:UpdateRobotInfo(self.StageCfg.RobotId[i]) + grid.GameObject:SetActive(true) + end + end + else + local count = #charExps + if count <= 0 then + return + end + + for _, exp in pairs(charExps) do + local ui = CS.UnityEngine.Object.Instantiate(self.GridWinRole) + local grid = XUiGridWinRole.New(self, ui) + grid.Transform:SetParent(self.PanelRoleContent, false) + grid:UpdateRoleInfo(exp, self.StageCfg.CardExp * self.Count) + grid.GameObject:SetActive(true) + end + end +end + +-- 玩家经验 +function XUiNewAutoFightSettleWin:UpdatePlayerInfo(data) + if not data or not next(data) then return end + + local lastLevel = data.RoleLevel + local lastExp = data.RoleExp + local lastMaxExp = XPlayerManager.GetMaxExp(lastLevel, XPlayer.IsHonorLevelOpen()) + local curLevel = XPlayer.GetLevelOrHonorLevel() + local curExp = XPlayer.Exp + local curMaxExp = XPlayerManager.GetMaxExp(curLevel, XPlayer.IsHonorLevelOpen()) + local txtLevelName = XPlayer.IsHonorLevelOpen() and CS.XTextManager.GetText("HonorLevel") or nil + + local addExp = self.StageCfg.TeamExp * self.Count + self.PlayerExpBar = self.PlayerExpBar or XUiPanelExpBar.New(self.PanelPlayerExpBar) + self.PlayerExpBar:LetsRoll(lastLevel, lastExp, lastMaxExp, curLevel, curExp, curMaxExp, addExp, txtLevelName) +end + +function XUiNewAutoFightSettleWin:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:InitRootUi(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local rewardGoodsList = self.RewardLineList[index] + grid:Refresh(rewardGoodsList, index, self.IsListCompleted) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_RELOAD_COMPLETED then + self.IsListCompleted = true + + local grids = self.DynamicTable:GetGrids() + self.GridIndex = 1 + self.CurAnimationTimer = XScheduleManager.Schedule(function() + local item = grids[self.GridIndex] + if item then + item:Show() + end + self.GridIndex = self.GridIndex + 1 + if self.GridIndex > self.GridCount then + self:OnAnimationDone() + self:StopSchedule() + end + end, 0, self.GridCount, 0) + end +end + +function XUiNewAutoFightSettleWin:OnAnimationDone() + self.BtnConfirm.gameObject:SetActiveEx(true) + XDataCenter.FunctionEventManager.UnLockFunctionEvent() +end + +function XUiNewAutoFightSettleWin:OnBtnConfirmClick() + self:Close() +end + +function XUiNewAutoFightSettleWin:StopSchedule() + if self.CurAnimationTimer then + XScheduleManager.UnSchedule(self.CurAnimationTimer) + self.CurAnimationTimer = nil + end +end + +function XUiNewAutoFightSettleWin:OnDisable() + self:StopSchedule() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNewChar/WeiLa/XUiFubenWeiLaStageItem.lua b/Resources/Scripts/XUi/XUiNewChar/WeiLa/XUiFubenWeiLaStageItem.lua new file mode 100644 index 00000000..02160561 --- /dev/null +++ b/Resources/Scripts/XUi/XUiNewChar/WeiLa/XUiFubenWeiLaStageItem.lua @@ -0,0 +1,87 @@ +local XUiFubenWeiLaStageItem = XClass(nil, "XUiFubenWeiLaStageItem") +local XUiPanelStars = require("XUi/XUiFubenMainLineChapter/XUiPanelStars") + +function XUiFubenWeiLaStageItem:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) +end + +function XUiFubenWeiLaStageItem:UpdateNode(id, stageId, stageIndex, panelType) + self.Id = id + self.StageId = stageId + self.StageIndex = stageIndex + self.Template = XFubenNewCharConfig.GetDataById(self.Id, self.StageIndex) + + if panelType == XFubenNewCharConfig.KoroPanelType.Teaching then + self.StagePrefabName = self.Template.GridFubenPrefab + end + if panelType == XFubenNewCharConfig.KoroPanelType.Challenge then + self.StagePrefabName = self.Template.GridFubenChallengePrefab + end + + self.IsOpen, self.Des = true, CS.XTextManager.GetText("FubenPreStageNotPass") + local gridGo = self.Transform:LoadPrefab(self.StagePrefabName) + local uiObject = gridGo.transform:GetComponent("UiObject") + for i = 0, uiObject.NameList.Count - 1 do + self[uiObject.NameList[i]] = uiObject.ObjList[i] + end + self.BtnStage.CallBack = function() + self:OnBtnStageClick() + end + + self.IsLock = not self.IsOpen + self.StagePrefix = XDataCenter.FubenManager.GetStageName(self.StageId) + self.StageName = XDataCenter.FubenManager.GetStageDes(self.StageId) + self:SetNormalStage() + if not self.PanelStagePass then + self.PanelStagePass = gridGo.transform:Find("ChristmasStageParent/PanelStagePass") + end + + if self.PanelStagePass then + self.PanelStagePass.gameObject:SetActiveEx(XDataCenter.FubenNewCharActivityManager.CheckStagePass(stageId)) + end + + if panelType == XFubenNewCharConfig.KoroPanelType.Challenge then + self.PanelStars = XUiPanelStars.New(self.PanelStar) + local starsMap = XDataCenter.FubenNewCharActivityManager.GetStarMap(self.StageId) + self.PanelStars:OnEnable(starsMap) + end +end + +function XUiFubenWeiLaStageItem:SetNormalStage() + self.PanelStageNormal.gameObject:SetActiveEx(self.IsOpen) + if self.IsOpen then + self.StageCfg = XDataCenter.FubenManager.GetStageCfg(self.StageId) + self.RImgFightActiveNor:SetRawImage(self.StageCfg.Icon) + end + + --self.TxtStageTitle.text = self.StageName + --self.ImgStageOrder.gameObject:SetActiveEx(true) + --self.TxtStagePrefix.text = self.StagePrefix + if self.PanelStageLock then + self.PanelStageLock.gameObject:SetActiveEx(self.IsLock) + end +end + +function XUiFubenWeiLaStageItem:OnBtnStageClick() + if self.StageId and self.Id then + if self.IsOpen then + self.RootUi:UpdateNodesSelect(self.StageId) + self.RootUi:OpenStageDetails(self.StageId, self.Id) + self.RootUi:PlayScrollViewMove(self.Transform) + else + XUiManager.TipMsg(self.Description) + end + end +end + +--显示选中框 +function XUiFubenWeiLaStageItem:SetNodeSelect(isSelect) + if self.IsOpen then + self.ImageSelected.gameObject:SetActiveEx(isSelect) + end +end + +return XUiFubenWeiLaStageItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNewChar/WeiLa/XUiFubenWeiLaTutorial.lua b/Resources/Scripts/XUi/XUiNewChar/WeiLa/XUiFubenWeiLaTutorial.lua new file mode 100644 index 00000000..9ef8c341 --- /dev/null +++ b/Resources/Scripts/XUi/XUiNewChar/WeiLa/XUiFubenWeiLaTutorial.lua @@ -0,0 +1,186 @@ +local XUiFunbenWeiLaTutorial = XLuaUiManager.Register(XLuaUi, "UiFunbenWeiLaTutorial") +local XUiPanelFubenWeiLaStage = require("XUi/XUiNewChar/WeiLa/XUiPanelFubenWeiLaStage") + +function XUiFunbenWeiLaTutorial:OnAwake() + self:InitAutoScript() + self.RedPointBtnChallengeId = XRedPointManager.AddRedPointEvent(self.BtnChallenge, self.RefreshBtnChallengeRedDot, self, { + XRedPointConditions.Types.CONDITION_KOROMCHARACTIVITYCHALLENGERED, + }) + self.RedPointBtnTeachingId = XRedPointManager.AddRedPointEvent(self.BtnTeaching, self.RefreshBtnTeachingRedDot, self, { + XRedPointConditions.Types.CONDITION_KOROMCHARACTIVITYTEACHINGRED, + }) + --self.PanelRoot = self.PanelStageRoot.parent:Find("PanelRoot") +end + +function XUiFunbenWeiLaTutorial:OnStart(actId) + --XLuaUiManager.SetMask(true) + --self:PlayAnimation("AnimSwitch", function() + -- XLuaUiManager.SetMask(false) + --end) + + self.Id = actId + self.CurPanelStage = XDataCenter.FubenNewCharActivityManager.GetKoroLastOpenPanel() or XFubenNewCharConfig.KoroPanelType.Normal + self.ActivityCfg = XFubenNewCharConfig.GetDataById(self.Id) + self.ActivityEndTime = XFunctionManager.GetEndTimeByTimeId(self.ActivityCfg.TimeId) + self:InitPanel() + local isPlayVideo = self.ActivityCfg.MovieId and self.ActivityCfg.MovieId ~= 0 + self.VideoPlayer.gameObject:SetActiveEx(isPlayVideo) + if isPlayVideo then + local config = XVideoConfig.GetMovieById(self.ActivityCfg.MovieId) + self.VideoPlayer:SetVideoFromRelateUrl(config.VideoUrl) + self.VideoPlayer:Play() + end +end + +function XUiFunbenWeiLaTutorial:OnEnable() + self:CheckRedPoint() + self:SwitchPanelStage(self.CurPanelStage) + self:StartActivityTimer() +end + +function XUiFunbenWeiLaTutorial:OnDisable() + self:CloseActivityTimer() +end + +function XUiFunbenWeiLaTutorial:InitPanel() + --self.TxtActivityName.text = self.ActivityCfg.Name + self.FubenGo = self.PanelStageRoot:LoadPrefab(self.ActivityCfg.FubenPrefab) + self.FubenGo.gameObject:SetActiveEx(false) + self.PanelStageKoro = XUiPanelFubenWeiLaStage.New(self, self.FubenGo, self.ActivityCfg, XFubenNewCharConfig.KoroPanelType.Teaching) + self.FubenChallengeGo = self.PanelChallengeStageRoot:LoadPrefab(self.ActivityCfg.FubenChallengePrefab) + self.FubenChallengeGo.gameObject:SetActiveEx(false) + self.PanelStageKoroChallenge = XUiPanelFubenWeiLaStage.New(self, self.FubenChallengeGo, self.ActivityCfg, XFubenNewCharConfig.KoroPanelType.Challenge) +end + +--按钮红点 +function XUiFunbenWeiLaTutorial:CheckRedPoint() + XRedPointManager.Check(self.RedPointBtnChallengeId) + XRedPointManager.Check(self.RedPointBtnTeachingId) + self.BtnChapter:ShowReddot(false) +end + +--活动时间的定时器开启与关闭 +function XUiFunbenWeiLaTutorial:StartActivityTimer() + local now = XTime.GetServerNowTimestamp() + self.TxtDay.text = XUiHelper.GetTime(self.ActivityEndTime - now, XUiHelper.TimeFormatType.ACTIVITY) + self:CloseActivityTimer() + + self.TimerId = XScheduleManager.ScheduleForever(function() + self:RefreshActivityTime() + end, XScheduleManager.SECOND, 0) +end + +function XUiFunbenWeiLaTutorial:RefreshActivityTime() + local now = XTime.GetServerNowTimestamp() + if now > self.ActivityEndTime then + XUiManager.TipText("KoroCharacterActivityEnd") + self:CloseActivityTimer() + XLuaUiManager.RunMain() + return + end + self.TxtDay.text = XUiHelper.GetTime(self.ActivityEndTime - now, XUiHelper.TimeFormatType.ACTIVITY) +end + +function XUiFunbenWeiLaTutorial:CloseActivityTimer() + if self.TimerId then + XScheduleManager.UnSchedule(self.TimerId) + self.TimerId = nil + end +end + +--切换到挑战界面或者教学关界面 +function XUiFunbenWeiLaTutorial:SwitchPanelStage(panelStage) + XDataCenter.FubenNewCharActivityManager.SetKoroLastOpenPanel(panelStage) + if panelStage ~= XFubenNewCharConfig.KoroPanelType.Normal then + self.PanelMain.gameObject:SetActiveEx(false) + self.PanelSpine.gameObject:SetActiveEx(false) + self.VideoPlayer.gameObject:SetActiveEx(false) + --self.PanelRoot.gameObject:SetActiveEx(false) + self.PanelEffect.gameObject:SetActiveEx(false) + if panelStage == XFubenNewCharConfig.KoroPanelType.Teaching then + self.PanelStageKoro:OnShow(panelStage) + elseif panelStage == XFubenNewCharConfig.KoroPanelType.Challenge then + self.PanelStageKoroChallenge:OnShow(panelStage) + end + self.CurPanelStage = panelStage + else + if self.PanelStageKoro:CheckCanClose() and self.PanelStageKoroChallenge:CheckCanClose() then + self.PanelMain.gameObject:SetActiveEx(true) + self.PanelSpine.gameObject:SetActiveEx(true) + self.VideoPlayer.gameObject:SetActiveEx(true) + --self.PanelRoot.gameObject:SetActiveEx(true) + self.PanelEffect.gameObject:SetActiveEx(true) + self.PanelStageKoro:OnHide() + self.PanelStageKoroChallenge:OnHide() + self.CurPanelStage = panelStage + self:CheckRedPoint() + --XLuaUiManager.SetMask(true) + --self:PlayAnimation("AnimSwitch", function() + -- XLuaUiManager.SetMask(false) + --end) + end + end +end + +--按钮绑定事件 +function XUiFunbenWeiLaTutorial:InitAutoScript() + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + self.BtnChapter.CallBack = function() self:OnBtnChapterClick() end + self.BtnTeaching.CallBack = function() self:OnBtnTeachingClick() end + self.BtnChallenge.CallBack = function() self:OnBtnChallengeClick() end + self.BtnDetails.CallBack = function() self:OnBtnDetailsClick() end + self.BtnCultivate.CallBack = function() self:OnBtnCultivateClick() end + self.BtnObtain.CallBack = function() self:OnBtnObtainClick() end + self.BtnSkin.CallBack = function() self:OnBtnSkinClick() end +end + +function XUiFunbenWeiLaTutorial:OnBtnBackClick() + if self.CurPanelStage == XFubenNewCharConfig.KoroPanelType.Normal then + XDataCenter.FubenNewCharActivityManager.SetKoroLastOpenPanel(self.CurPanelStage) + self:Close() + return + end + self:SwitchPanelStage(XFubenNewCharConfig.KoroPanelType.Normal) +end + +function XUiFunbenWeiLaTutorial:OnBtnMainUiClick() + XDataCenter.FubenNewCharActivityManager.SetKoroLastOpenPanel(XFubenNewCharConfig.KoroPanelType.Normal) + XLuaUiManager.RunMain() +end + +function XUiFunbenWeiLaTutorial:OnBtnChapterClick() + XFunctionManager.SkipInterface(self.ActivityCfg.SkipIdJZ) +end + +function XUiFunbenWeiLaTutorial:OnBtnTeachingClick() + self:SwitchPanelStage(XFubenNewCharConfig.KoroPanelType.Teaching) +end + +function XUiFunbenWeiLaTutorial:OnBtnChallengeClick() + self:SwitchPanelStage(XFubenNewCharConfig.KoroPanelType.Challenge) +end + +function XUiFunbenWeiLaTutorial:OnBtnDetailsClick() + XLuaUiManager.Open("UiCharacterDetail", self.ActivityCfg.CharacterId) +end + +function XUiFunbenWeiLaTutorial:OnBtnCultivateClick() + XFunctionManager.SkipInterface(self.ActivityCfg.SkipIdChar) +end + +function XUiFunbenWeiLaTutorial:OnBtnObtainClick() + XFunctionManager.SkipInterface(self.ActivityCfg.SkipIdDraw) +end + +function XUiFunbenWeiLaTutorial:OnBtnSkinClick() + XFunctionManager.SkipInterface(self.ActivityCfg.SkipIdSkin) +end + +function XUiFunbenWeiLaTutorial:RefreshBtnChallengeRedDot(count) + self.BtnChallenge:ShowReddot(count >= 0) +end + +function XUiFunbenWeiLaTutorial:RefreshBtnTeachingRedDot(count) + self.BtnTeaching:ShowReddot(count >= 0) +end diff --git a/Resources/Scripts/XUi/XUiNewChar/WeiLa/XUiPanelFubenWeiLaStage.lua b/Resources/Scripts/XUi/XUiNewChar/WeiLa/XUiPanelFubenWeiLaStage.lua new file mode 100644 index 00000000..4a8d94ee --- /dev/null +++ b/Resources/Scripts/XUi/XUiNewChar/WeiLa/XUiPanelFubenWeiLaStage.lua @@ -0,0 +1,252 @@ +local XUiPanelFubenWeiLaStage = XClass(nil, "XUiPanelFubenWeiLaStage") +local XUiFubenWeiLaStageItem = require("XUi/XUiNewChar/WeiLa/XUiFubenWeiLaStageItem") +local UIFUBENKOROTUTORIA_TEACHING_DETAIL = "UiFunbenKoroTutoriaTeachingDetail" +local UIFUBENKOROTUTORIA_CHALLENGE_DETAIL = "UiFunbenKoroTutoriaChallengeDetail" +local XUguiDragProxy = CS.XUguiDragProxy + +function XUiPanelFubenWeiLaStage:Ctor(uiRoot, ui, cfg, panelType) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.UiRoot = uiRoot + self.Cfg = cfg + self:InitPanel(panelType) + self.GridTreasureList = {} +end + +function XUiPanelFubenWeiLaStage:InitPanel(panelType) + if panelType == XFubenNewCharConfig.KoroPanelType.Teaching then + self.StageIds = self.Cfg.StageId + end + if panelType == XFubenNewCharConfig.KoroPanelType.Challenge then + self.StageIds = self.Cfg.ChallengeStage + end + + self.DragProxy = self.PaneStageList:GetComponent(typeof(XUguiDragProxy)) + if not self.DragProxy then + self.DragProxy = self.PaneStageList.gameObject:AddComponent(typeof(XUguiDragProxy)) + end + self.DragProxy:RegisterHandler(handler(self, self.OnDragProxy)) + + self.Stages = {} + self.StageGroup = {} + for i = 1, #self.StageIds do + local itemStage = self.PanelStageContent:Find(string.format("Stage%d", i)) + if not itemStage then + XLog.Error("XUiPanelFubenKoroStage:HandleStages() 函数错误: 游戏物体PanelStageContent下找不到名字为:" .. string.format("Stage%d", i) .. "的游戏物体") + return + end + self.StageGroup[i] = itemStage + self.Stages[i] = XUiFubenWeiLaStageItem.New(self, itemStage) + itemStage.gameObject:SetActiveEx(true) + end + + self.Lines = {} + for i = 1, #self.StageIds - 1 do + local itemLine = self.PanelStageContent:Find(string.format("Line%d", i)) + self.Lines[i] = itemLine + end + self.LineIcon = self.PanelStageContent:Find("IconEnd") + self.BtnCloseDetail.CallBack = function() self:OnBtnCloseDetailClick() end +end + +--初始化挑战目标 +function XUiPanelFubenWeiLaStage:InitTreasureGrade() + local baseItem = self.GridTreasureGrade + self.GridTreasureGrade.gameObject:SetActiveEx(false) + + for j = 1, #self.GridTreasureList do + self.GridTreasureList[j].GameObject:SetActiveEx(false) + end + + local targetList = self.Cfg.TreasureId + if not targetList then + return + end + + local gridCount = #targetList + for i = 1, gridCount do + local grid = self.GridTreasureList[i] + + if not grid then + local item = CS.UnityEngine.Object.Instantiate(baseItem) -- 复制一个item + grid = XUiGridTreasureGrade.New(self.UiRoot, item, XDataCenter.FubenManager.StageType.NewCharAct) + grid.Transform:SetParent(self.PanelGradeContent, false) + self.GridTreasureList[i] = grid + end + + local treasureCfg = XFubenNewCharConfig.GetTreasureCfg(targetList[i]) + local curStars = XDataCenter.FubenNewCharActivityManager.GetKoroStarProgressById(self.Cfg.Id) + grid:UpdateGradeGrid(curStars, treasureCfg, self.Cfg.Id) + + grid:InitTreasureList() + grid.GameObject:SetActiveEx(true) + end +end + +--初始化收集进度 +function XUiPanelFubenWeiLaStage:InitStarts() + local curStars + local totalStars + curStars, totalStars = XDataCenter.FubenNewCharActivityManager.GetKoroStarProgressById(self.Cfg.Id) + + self.ImgJindu.fillAmount = totalStars > 0 and curStars / totalStars or 0 + self.ImgJindu.gameObject:SetActiveEx(true) + self.TxtStarNum.text = CS.XTextManager.GetText("Fract", curStars, totalStars) + + local received = true + for _, v in pairs(self.Cfg.TreasureId) do + if not XDataCenter.FubenNewCharActivityManager.IsTreasureGet(v) then + received = false + break + end + end + self.ImgLingqu.gameObject:SetActiveEx(received) + + local isShowRed = XDataCenter.FubenNewCharActivityManager.CheckTreasureReward(self.Cfg.Id) + self.ImgRedProgress.gameObject:SetActiveEx(isShowRed) +end + +function XUiPanelFubenWeiLaStage:OnShow(type) + self.PanelType = type + self.GameObject:SetActiveEx(true) + for i = 1, #self.StageIds do + self.Stages[i]:UpdateNode(self.Cfg.Id, self.StageIds[i], i, self.PanelType) + end + if self.PanelType == XFubenNewCharConfig.KoroPanelType.Challenge then + self.BtnTreasure.CallBack = function() + self:OnBtnTreasureClick() + end + self.BtnTreasureBg.CallBack = function() + self:OnBtnTreasureBgClick() + end + self:InitStarts() + end + for i = 1, #self.StageIds - 1 do + self.Lines[i].gameObject:SetActiveEx(XDataCenter.FubenNewCharActivityManager.CheckStagePass(self.StageIds[i])) + end + + for i = 2, #self.StageIds do + self.StageGroup[i].gameObject:SetActiveEx(XDataCenter.FubenNewCharActivityManager.CheckStagePass(self.StageIds[i - 1])) + end + self.LineIcon.gameObject:SetActiveEx(XDataCenter.FubenNewCharActivityManager.CheckStagePass(self.StageIds[#self.StageIds - 1])) + self.LineEnable:PlayTimelineAnimation() +end + +function XUiPanelFubenWeiLaStage:OnHide() + self.GameObject:SetActiveEx(false) +end + +--选中关卡 +function XUiPanelFubenWeiLaStage:UpdateNodesSelect(stageId) + local stageIds = self.StageIds + for i = 1, #stageIds do + if self.Stages[i] then + self.Stages[i]:SetNodeSelect(stageIds[i] == stageId) + end + end +end + +--取消选中关卡 +function XUiPanelFubenWeiLaStage:ClearNodesSelect() + local stageIds = self.StageIds + for i = 1, #stageIds do + if self.Stages[i] then + self.Stages[i]:SetNodeSelect(false) + end + end + self.IsOpenDetails = false +end + +function XUiPanelFubenWeiLaStage:OpenStageDetails(stageId, id) + self.IsOpenDetails = true + self.BtnCloseDetail.gameObject:SetActiveEx(true) + + if self.PanelType == XFubenNewCharConfig.KoroPanelType.Teaching then + self.UiRoot:OpenOneChildUi(UIFUBENKOROTUTORIA_TEACHING_DETAIL, self) + self.UiRoot:FindChildUiObj(UIFUBENKOROTUTORIA_TEACHING_DETAIL):SetStageDetail(stageId, id) + if XLuaUiManager.IsUiShow(UIFUBENKOROTUTORIA_CHALLENGE_DETAIL) then + self.UiRoot:FindChildUiObj(UIFUBENKOROTUTORIA_CHALLENGE_DETAIL):Close() + end + end + + if self.PanelType == XFubenNewCharConfig.KoroPanelType.Challenge then + self.UiRoot:OpenOneChildUi(UIFUBENKOROTUTORIA_CHALLENGE_DETAIL, self) + self.UiRoot:FindChildUiObj(UIFUBENKOROTUTORIA_CHALLENGE_DETAIL):SetStageDetail(stageId, id) + if XLuaUiManager.IsUiShow(UIFUBENKOROTUTORIA_TEACHING_DETAIL) then + self.UiRoot:FindChildUiObj(UIFUBENKOROTUTORIA_TEACHING_DETAIL):Close() + end + end + if self.AssetPanel then + self.AssetPanel.GameObject:SetActiveEx(false) + end + self.PanelStageContentRaycast.raycastTarget = false +end + +--关闭战斗详情 +function XUiPanelFubenWeiLaStage:CloseStageDetails() + self.IsOpenDetails = false + self.BtnCloseDetail.gameObject:SetActiveEx(false) + + if XLuaUiManager.IsUiShow(UIFUBENKOROTUTORIA_TEACHING_DETAIL) then + self.UiRoot:FindChildUiObj(UIFUBENKOROTUTORIA_TEACHING_DETAIL):CloseDetailWithAnimation() + end + + + if XLuaUiManager.IsUiShow(UIFUBENKOROTUTORIA_CHALLENGE_DETAIL) then + self.UiRoot:FindChildUiObj(UIFUBENKOROTUTORIA_CHALLENGE_DETAIL):CloseDetailWithAnimation() + end + self.PanelStageContentRaycast.raycastTarget = true + self:ClearNodesSelect() + self.PaneStageList.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Elastic +end + +function XUiPanelFubenWeiLaStage:PlayScrollViewMove(gridTransform) + self.PaneStageList.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Unrestricted + local gridRect = gridTransform:GetComponent("RectTransform") + local diffX = gridRect.localPosition.x + self.PanelStageContent.localPosition.x + if diffX < XDataCenter.FubenMainLineManager.UiGridChapterMoveMinX or diffX > XDataCenter.FubenMainLineManager.UiGridChapterMoveMaxX then + local tarPosX = XDataCenter.FubenMainLineManager.UiGridChapterMoveTargetX - gridRect.localPosition.x + local tarPos = self.PanelStageContent.localPosition + tarPos.x = tarPosX + XLuaUiManager.SetMask(true) + XUiHelper.DoMove(self.PanelStageContent, tarPos, XDataCenter.FubenMainLineManager.UiGridChapterMoveDuration, XUiHelper.EaseType.Sin, function() + XLuaUiManager.SetMask(false) + end) + end +end + +--点击关闭详情按钮 +function XUiPanelFubenWeiLaStage:OnBtnCloseDetailClick() + self:CloseStageDetails() +end + +function XUiPanelFubenWeiLaStage:CheckCanClose() + if self.IsOpenDetails then + self:CloseStageDetails() + return false + end + return true +end + +function XUiPanelFubenWeiLaStage:OnBtnTreasureBgClick() + self.TreasureDisable:PlayTimelineAnimation(function() + self.PanelTreasure.gameObject:SetActiveEx(false) + self:InitStarts() + end) +end + +function XUiPanelFubenWeiLaStage:OnBtnTreasureClick() + self:InitTreasureGrade() + self.PanelTreasure.gameObject:SetActiveEx(true) + self.TreasureEnable:PlayTimelineAnimation() +end + +--拖拽事件处理 +function XUiPanelFubenWeiLaStage:OnDragProxy(dragType) + if self.IsOpenDetails and dragType == 0 then + self:CloseStageDetails() + end +end + +return XUiPanelFubenWeiLaStage \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNewChar/XUiFubenKoroStageItem.lua b/Resources/Scripts/XUi/XUiNewChar/XUiFubenKoroStageItem.lua new file mode 100644 index 00000000..49dc8b1a --- /dev/null +++ b/Resources/Scripts/XUi/XUiNewChar/XUiFubenKoroStageItem.lua @@ -0,0 +1,87 @@ +local XUiFubenKoroStageItem = XClass(nil, "XUiFestivalStageItem") +local XUiPanelStars = require("XUi/XUiFubenMainLineChapter/XUiPanelStars") + +function XUiFubenKoroStageItem:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) +end + +function XUiFubenKoroStageItem:UpdateNode(id, stageId, stageIndex, panelType) + self.Id = id + self.StageId = stageId + self.StageIndex = stageIndex + self.Template = XFubenNewCharConfig.GetDataById(self.Id, self.StageIndex) + + if panelType == XFubenNewCharConfig.KoroPanelType.Teaching then + self.StagePrefabName = self.Template.GridFubenPrefab + end + if panelType == XFubenNewCharConfig.KoroPanelType.Challenge then + self.StagePrefabName = self.Template.GridFubenChallengePrefab + end + + self.IsOpen, self.Des = true, CS.XTextManager.GetText("FubenPreStageNotPass") + local gridGo = self.Transform:LoadPrefab(self.StagePrefabName) + local uiObject = gridGo.transform:GetComponent("UiObject") + for i = 0, uiObject.NameList.Count - 1 do + self[uiObject.NameList[i]] = uiObject.ObjList[i] + end + self.BtnStage.CallBack = function() + self:OnBtnStageClick() + end + + self.IsLock = not self.IsOpen + self.StagePrefix = XDataCenter.FubenManager.GetStageName(self.StageId) + self.StageName = XDataCenter.FubenManager.GetStageDes(self.StageId) + self:SetNormalStage() + if not self.PanelStagePass then + self.PanelStagePass = gridGo.transform:Find("ChristmasStageParent/PanelStagePass") + end + + if self.PanelStagePass then + self.PanelStagePass.gameObject:SetActiveEx(XDataCenter.FubenNewCharActivityManager.CheckStagePass(stageId)) + end + + if panelType == XFubenNewCharConfig.KoroPanelType.Challenge then + self.PanelStars = XUiPanelStars.New(self.PanelStar) + local starsMap = XDataCenter.FubenNewCharActivityManager.GetStarMap(self.StageId) + self.PanelStars:OnEnable(starsMap) + end +end + +function XUiFubenKoroStageItem:SetNormalStage() + self.PanelStageNormal.gameObject:SetActiveEx(self.IsOpen) + if self.IsOpen then + self.StageCfg = XDataCenter.FubenManager.GetStageCfg(self.StageId) + self.RImgFightActiveNor:SetRawImage(self.StageCfg.Icon) + end + + self.TxtStageTitle.text = self.StageName + self.ImgStageOrder.gameObject:SetActiveEx(true) + self.TxtStagePrefix.text = self.StagePrefix + if self.PanelStageLock then + self.PanelStageLock.gameObject:SetActiveEx(self.IsLock) + end +end + +function XUiFubenKoroStageItem:OnBtnStageClick() + if self.StageId and self.Id then + if self.IsOpen then + self.RootUi:UpdateNodesSelect(self.StageId) + self.RootUi:OpenStageDetails(self.StageId, self.Id) + self.RootUi:PlayScrollViewMove(self.Transform) + else + XUiManager.TipMsg(self.Description) + end + end +end + +--显示选中框 +function XUiFubenKoroStageItem:SetNodeSelect(isSelect) + if self.IsOpen then + self.ImageSelected.gameObject:SetActiveEx(isSelect) + end +end + +return XUiFubenKoroStageItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNewChar/XUiFunbenKoroTutoriaChallengeDetail.lua b/Resources/Scripts/XUi/XUiNewChar/XUiFunbenKoroTutoriaChallengeDetail.lua new file mode 100644 index 00000000..7cd359d6 --- /dev/null +++ b/Resources/Scripts/XUi/XUiNewChar/XUiFunbenKoroTutoriaChallengeDetail.lua @@ -0,0 +1,113 @@ +local XUiFunbenKoroTutoriaChallengeDetail = XLuaUiManager.Register(XLuaUi, "UiFunbenKoroTutoriaChallengeDetail") +local XUiGridStageBuffIcon = require("XUi/XUiFubenSimulatedCombat/ChildItem/XUiGridStageBuffIcon") +local DescCount = 3 + + +function XUiFunbenKoroTutoriaChallengeDetail:OnAwake() + self.BtnEnter.CallBack = function() + self:OnBtnEnterClick() + end + self:InitStarPanels() +end + +function XUiFunbenKoroTutoriaChallengeDetail:OnStart(rootUi) + self.RootUi = rootUi +end + +function XUiFunbenKoroTutoriaChallengeDetail:InitStarPanels() + self.StarGridList = {} + for i = 1, DescCount do + self.StarGridList[i] = XUiGridStageStar.New(self[string.format("GridStageStar%d", i)]) + end +end + +function XUiFunbenKoroTutoriaChallengeDetail:SetStageDetail(stageId, id) + self.Id = id + self.StageId = stageId + self.StageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + self.TxtTitle.text = self.StageCfg.Name + self.TxtDescDetail.text = XFubenNewCharConfig.GetNewCharDescDetail(self.StageId) + local starsMap = XDataCenter.FubenNewCharActivityManager.GetStarMap(self.StageId) + for i = 1, DescCount do + self.StarGridList[i]:Refresh(self.StageCfg.StarDesc[i], starsMap[i]) + end + self:SetBuffList() + + local data = XFubenConfigs.GetStageFightControl(self.StageId) + if data then + self.TxtATNums.text = data.ShowFight + end + self:PlayAnimation("AnimBegin") +end + +--设置词缀 +function XUiFunbenKoroTutoriaChallengeDetail:SetBuffList() + if not self.BuffList then self.BuffList = {} end + local buffList = XFubenNewCharConfig.GetNewCharShowFightEventIds(self.StageId) + if buffList == nil or #buffList == 0 then + self.PanelBuffNone.gameObject:SetActiveEx(true) + self.BtnBuffTip.gameObject:SetActiveEx(false) + self.PanelBuffContent.gameObject:SetActiveEx(false) + return + end + self.PanelBuffNone.gameObject:SetActiveEx(false) + self.BtnBuffTip.gameObject:SetActiveEx(true) + self.PanelBuffContent.gameObject:SetActiveEx(true) + self.GridBuff.gameObject:SetActiveEx(false) + self.StageBuffCfgList = {} + for i = 1, #buffList do + if not self.BuffList[i] then + local prefab = CS.UnityEngine.GameObject.Instantiate(self.GridBuff.gameObject) + self.BuffList[i] = XUiGridStageBuffIcon.New(prefab, self.RootUi) + end + end + for i = 1, #self.BuffList do + self.BuffList[i].Transform:SetParent(self.PanelBuffContent, false) + if buffList[i] then + self.BuffList[i]:RefreshData(buffList[i]) + self.BuffList[i]:Show() + table.insert(self.StageBuffCfgList, buffList[i]) + else + self.BuffList[i]:Hide() + end + end + + self.BtnBuffTip.CallBack = function() + self:OnBtnBuffTip() + end + self.PanelBuffNone.gameObject:SetActiveEx(#buffList == 0) +end + +function XUiFunbenKoroTutoriaChallengeDetail:OnBtnBuffTip() + local buffList = XFubenNewCharConfig.GetNewCharShowFightEventIds(self.StageId) + if buffList and next(buffList) then + XLuaUiManager.Open("UiSimulatedCombatBossBuffTips", buffList) + end +end + +function XUiFunbenKoroTutoriaChallengeDetail:OnBtnEnterClick() + --判断是否结束 + local activityCfg = XFubenNewCharConfig.GetDataById(self.Id) + local endTime = XFunctionManager.GetEndTimeByTimeId(activityCfg.TimeId) + local nowTime = XTime.GetServerNowTimestamp() + if nowTime > endTime then + XUiManager.TipText("KoroCharacterActivityEnd") + XLuaUiManager.RunMain() + return + end + + if XDataCenter.FubenManager.CheckPreFight(self.StageCfg) then + if self.RootUi then + self.RootUi:ClearNodesSelect() + end + self.RootUi:CloseStageDetails() + --self:Close() + XLuaUiManager.Open("UiNewRoomSingle", self.StageCfg.StageId) + end +end + +function XUiFunbenKoroTutoriaChallengeDetail:CloseDetailWithAnimation() + self:PlayAnimation("AnimEnd", function() + self:Close() + end) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNewChar/XUiFunbenKoroTutoriaTeachingDetail.lua b/Resources/Scripts/XUi/XUiNewChar/XUiFunbenKoroTutoriaTeachingDetail.lua new file mode 100644 index 00000000..5aeb752a --- /dev/null +++ b/Resources/Scripts/XUi/XUiNewChar/XUiFunbenKoroTutoriaTeachingDetail.lua @@ -0,0 +1,94 @@ +local XUiFunbenKoroTutoriaTeachingDetail = XLuaUiManager.Register(XLuaUi, "UiFunbenKoroTutoriaTeachingDetail") +local DescCount = 3 + +function XUiFunbenKoroTutoriaTeachingDetail:OnAwake() + self.StarGridList = {} + self:InitStarPanels() + self.GridList = {} + self.BtnEnter.CallBack = function() self:OnBtnEnterClick() end + self.GridCommon.gameObject:SetActiveEx(false) + self.TextAT.gameObject:SetActiveEx(false) + self.TxtATNums.gameObject:SetActiveEx(false) +end + +function XUiFunbenKoroTutoriaTeachingDetail:OnStart(rootUi) + self.RootUi = rootUi +end + +function XUiFunbenKoroTutoriaTeachingDetail:InitStarPanels() + for i = 1, DescCount do + self.StarGridList[i] = XUiGridStageStar.New(self[string.format("GridStageStar%d", i)]) + end +end + +function XUiFunbenKoroTutoriaTeachingDetail:SetStageDetail(stageId, id) + self.Id = id + self.StageId = stageId + self.StageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + self.TxtTitle.text = self.StageCfg.Name + for i = 1, DescCount do + self.StarGridList[i]:Refresh(self.StageCfg.StarDesc[i], true) + end + self:UpdateRewards() + XLuaUiManager.SetMask(true) + self:PlayAnimation("AnimBegin", function() + XLuaUiManager.SetMask(false) + end) +end + +function XUiFunbenKoroTutoriaTeachingDetail:UpdateRewards() + local rewardId = self.StageCfg.FirstRewardShow + if rewardId == 0 then + for i = 1, #self.GridList do + self.GridList[i].GameObject:SetActiveEx(false) + end + return + end + + local rewards = XRewardManager.GetRewardList(rewardId) + if rewards then + for i, item in ipairs(rewards) do + local grid + if self.GridList[i] then + grid = self.GridList[i] + else + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommon) + grid = XUiGridCommon.New(self, ui) + grid.Transform:SetParent(self.PanelDropContent, false) + self.GridList[i] = grid + end + grid:Refresh(item) + grid:SetReceived(XDataCenter.FubenNewCharActivityManager.CheckStagePass(self.StageId)) + grid.GameObject:SetActiveEx(true) + end + end +end + +function XUiFunbenKoroTutoriaTeachingDetail:OnBtnEnterClick() + --判断是否结束 + local activityCfg = XFubenNewCharConfig.GetDataById(self.Id) + local endTime = XFunctionManager.GetEndTimeByTimeId(activityCfg.TimeId) + local nowTime = XTime.GetServerNowTimestamp() + if nowTime > endTime then + XUiManager.TipText("KoroCharacterActivityEnd") + XLuaUiManager.RunMain() + return + end + + if XDataCenter.FubenManager.CheckPreFight(self.StageCfg) then + if self.RootUi then + self.RootUi:ClearNodesSelect() + end + self.RootUi:CloseStageDetails() + --self:Close() + XLuaUiManager.Open("UiNewRoomSingle", self.StageCfg.StageId) + end +end + +function XUiFunbenKoroTutoriaTeachingDetail:CloseDetailWithAnimation() + XLuaUiManager.SetMask(true) + self:PlayAnimation("AnimEnd", function() + XLuaUiManager.SetMask(false) + self:Close() + end) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNewChar/XUiFunbenKoroTutorial.lua b/Resources/Scripts/XUi/XUiNewChar/XUiFunbenKoroTutorial.lua new file mode 100644 index 00000000..d178dd67 --- /dev/null +++ b/Resources/Scripts/XUi/XUiNewChar/XUiFunbenKoroTutorial.lua @@ -0,0 +1,172 @@ +local XUiFunbenKoroTutorial = XLuaUiManager.Register(XLuaUi, "UiFunbenKoroTutorial") +local XUiPanelFubenKoroStage = require("XUi/XUiNewChar/XUiPanelFubenKoroStage") + +function XUiFunbenKoroTutorial:OnAwake() + self:InitAutoScript() + self.RedPointBtnChallengeId = XRedPointManager.AddRedPointEvent(self.BtnChallenge, self.RefreshBtnChallengeRedDot, self, { + XRedPointConditions.Types.CONDITION_KOROMCHARACTIVITYCHALLENGERED, + }) + self.RedPointBtnTeachingId = XRedPointManager.AddRedPointEvent(self.BtnTeaching, self.RefreshBtnTeachingRedDot, self, { + XRedPointConditions.Types.CONDITION_KOROMCHARACTIVITYTEACHINGRED, + }) + self.PanelRoot = self.PanelStageRoot.parent:Find("PanelRoot") +end + +function XUiFunbenKoroTutorial:OnStart(actId) + XLuaUiManager.SetMask(true) + self:PlayAnimation("AnimSwitch", function() + XLuaUiManager.SetMask(false) + end) + + self.Id = actId + self.CurPanelStage = XDataCenter.FubenNewCharActivityManager.GetKoroLastOpenPanel() or XFubenNewCharConfig.KoroPanelType.Normal + self.ActivityCfg = XFubenNewCharConfig.GetDataById(self.Id) + self.ActivityEndTime = XFunctionManager.GetEndTimeByTimeId(self.ActivityCfg.TimeId) + self:InitPanel() +end + +function XUiFunbenKoroTutorial:OnEnable() + self:CheckRedPoint() + self:SwitchPanelStage(self.CurPanelStage) + self:StartActivityTimer() +end + +function XUiFunbenKoroTutorial:OnDisable() + self:CloseActivityTimer() +end + +function XUiFunbenKoroTutorial:InitPanel() + --self.TxtActivityName.text = self.ActivityCfg.Name + self.FubenGo = self.PanelStageRoot:LoadPrefab(self.ActivityCfg.FubenPrefab) + self.FubenGo.gameObject:SetActiveEx(false) + self.PanelStageKoro = XUiPanelFubenKoroStage.New(self, self.FubenGo, self.ActivityCfg, XFubenNewCharConfig.KoroPanelType.Teaching) + self.FubenChallengeGo = self.PanelChallengeStageRoot:LoadPrefab(self.ActivityCfg.FubenChallengePrefab) + self.FubenChallengeGo.gameObject:SetActiveEx(false) + self.PanelStageKoroChallenge = XUiPanelFubenKoroStage.New(self, self.FubenChallengeGo, self.ActivityCfg, XFubenNewCharConfig.KoroPanelType.Challenge) +end + +--按钮红点 +function XUiFunbenKoroTutorial:CheckRedPoint() + XRedPointManager.Check(self.RedPointBtnChallengeId) + XRedPointManager.Check(self.RedPointBtnTeachingId) + self.BtnChapter:ShowReddot(false) +end + +--活动时间的定时器开启与关闭 +function XUiFunbenKoroTutorial:StartActivityTimer() + local now = XTime.GetServerNowTimestamp() + self.TxtDay.text = XUiHelper.GetTime(self.ActivityEndTime - now, XUiHelper.TimeFormatType.ACTIVITY) + self:CloseActivityTimer() + + self.TimerId = XScheduleManager.ScheduleForever(function() + self:RefreshActivityTime() + end, XScheduleManager.SECOND, 0) +end + +function XUiFunbenKoroTutorial:RefreshActivityTime() + local now = XTime.GetServerNowTimestamp() + if now > self.ActivityEndTime then + XUiManager.TipText("KoroCharacterActivityEnd") + self:CloseActivityTimer() + XLuaUiManager.RunMain() + return + end + self.TxtDay.text = XUiHelper.GetTime(self.ActivityEndTime - now, XUiHelper.TimeFormatType.ACTIVITY) +end + +function XUiFunbenKoroTutorial:CloseActivityTimer() + if self.TimerId then + XScheduleManager.UnSchedule(self.TimerId) + self.TimerId = nil + end +end + +--切换到挑战界面或者教学关界面 +function XUiFunbenKoroTutorial:SwitchPanelStage(panelStage) + XDataCenter.FubenNewCharActivityManager.SetKoroLastOpenPanel(panelStage) + if panelStage ~= XFubenNewCharConfig.KoroPanelType.Normal then + self.PanelMain.gameObject:SetActiveEx(false) + self.PanelSpine.gameObject:SetActiveEx(false) + self.PanelRoot.gameObject:SetActiveEx(false) + self.PanelEffect.gameObject:SetActiveEx(false) + if panelStage == XFubenNewCharConfig.KoroPanelType.Teaching then + self.PanelStageKoro:OnShow(panelStage) + elseif panelStage == XFubenNewCharConfig.KoroPanelType.Challenge then + self.PanelStageKoroChallenge:OnShow(panelStage) + end + self.CurPanelStage = panelStage + else + if self.PanelStageKoro:CheckCanClose() and self.PanelStageKoroChallenge:CheckCanClose() then + self.PanelMain.gameObject:SetActiveEx(true) + self.PanelSpine.gameObject:SetActiveEx(true) + self.PanelRoot.gameObject:SetActiveEx(true) + self.PanelEffect.gameObject:SetActiveEx(true) + self.PanelStageKoro:OnHide() + self.PanelStageKoroChallenge:OnHide() + self.CurPanelStage = panelStage + self:CheckRedPoint() + XLuaUiManager.SetMask(true) + self:PlayAnimation("AnimSwitch", function() + XLuaUiManager.SetMask(false) + end) + end + end +end + +--按钮绑定事件 +function XUiFunbenKoroTutorial:InitAutoScript() + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + self.BtnChapter.CallBack = function() self:OnBtnChapterClick() end + self.BtnTeaching.CallBack = function() self:OnBtnTeachingClick() end + self.BtnChallenge.CallBack = function() self:OnBtnChallengeClick() end + self.BtnDetails.CallBack = function() self:OnBtnDetailsClick() end + self.BtnCultivate.CallBack = function() self:OnBtnCultivateClick() end + self.BtnObtain.CallBack = function() self:OnBtnObtainClick() end +end + +function XUiFunbenKoroTutorial:OnBtnBackClick() + if self.CurPanelStage == XFubenNewCharConfig.KoroPanelType.Normal then + XDataCenter.FubenNewCharActivityManager.SetKoroLastOpenPanel(self.CurPanelStage) + self:Close() + return + end + self:SwitchPanelStage(XFubenNewCharConfig.KoroPanelType.Normal) +end + +function XUiFunbenKoroTutorial:OnBtnMainUiClick() + XDataCenter.FubenNewCharActivityManager.SetKoroLastOpenPanel(XFubenNewCharConfig.KoroPanelType.Normal) + XLuaUiManager.RunMain() +end + +function XUiFunbenKoroTutorial:OnBtnChapterClick() + XFunctionManager.SkipInterface(self.ActivityCfg.SkipIdJZ) +end + +function XUiFunbenKoroTutorial:OnBtnTeachingClick() + self:SwitchPanelStage(XFubenNewCharConfig.KoroPanelType.Teaching) +end + +function XUiFunbenKoroTutorial:OnBtnChallengeClick() + self:SwitchPanelStage(XFubenNewCharConfig.KoroPanelType.Challenge) +end + +function XUiFunbenKoroTutorial:OnBtnDetailsClick() + XLuaUiManager.Open("UiCharacterDetail", self.ActivityCfg.CharacterId) +end + +function XUiFunbenKoroTutorial:OnBtnCultivateClick() + XFunctionManager.SkipInterface(self.ActivityCfg.SkipIdChar) +end + +function XUiFunbenKoroTutorial:OnBtnObtainClick() + XFunctionManager.SkipInterface(self.ActivityCfg.SkipIdDraw) +end + +function XUiFunbenKoroTutorial:RefreshBtnChallengeRedDot(count) + self.BtnChallenge:ShowReddot(count >= 0) +end + +function XUiFunbenKoroTutorial:RefreshBtnTeachingRedDot(count) + self.BtnTeaching:ShowReddot(count >= 0) +end diff --git a/Resources/Scripts/XUi/XUiNewChar/XUiNewCharActivity.lua b/Resources/Scripts/XUi/XUiNewChar/XUiNewCharActivity.lua new file mode 100644 index 00000000..74621e5d --- /dev/null +++ b/Resources/Scripts/XUi/XUiNewChar/XUiNewCharActivity.lua @@ -0,0 +1,295 @@ +local XUiPanelLineChapter = require("XUi/XUiNewChar/XUiPanelLineChapter") +local XUiNewCharActivity = XLuaUiManager.Register(XLuaUi, "UiNewCharActivity") + +local PageIndex = { + Main = 1, + Teaching = 2, + Profile = 3, +} + +local Delay = { + [PageIndex.Teaching] = 500, + [PageIndex.Profile] = 350, +} + +function XUiNewCharActivity:OnAwake() + if XLuaUiManager.IsUiLoad("UiNewCharActivity") then + XLuaUiManager.Remove("UiNewCharActivity") + end + self:InitUiView() + self:InitSceneRoot() + self.CurrentView = PageIndex.Main + self.StageGroup = {} + self.TabBtns = {} + self.SwitchEffect = {} + -- self.InitEffect = {} + -- self.MsgBtnAnimEnable = true + --XEventManager.AddEventListener(XEventId.EVENT_ON_FESTIVAL_CHANGED, self.RefreshFestivalNodes, self) + self:UpdateCamera(PageIndex.Main) +end + +function XUiNewCharActivity:OnStart(actId) + -- 进入活动时刷新 + local actTemplate = XFubenNewCharConfig.GetDataById(actId) + self.ActTemplate = actTemplate + self.ActId = actId + -- 初始化prefab组件 + local chapterGo = self.PanelTeaching:LoadPrefab(actTemplate.FubenPrefab) + self.PanelLineChapter = XUiPanelLineChapter.New(self, chapterGo, actTemplate) + + local now = XTime.GetServerNowTimestamp() + local _, endTimeSecond = XFunctionManager.GetTimeByTimeId(actTemplate.TimeId) + if endTimeSecond then + self.TxtDay.text = XUiHelper.GetTime(endTimeSecond - now, XUiHelper.TimeFormatType.ACTIVITY) + self:CreateActivityTimer(now, endTimeSecond) + end + --self.TxtChapterName.text = actTemplate.Name + --self.TxtChapter.text = (self.ChapterId >= 10) and self.ChapterId or string.format("0%d", self.ChapterId) + local itemId = XDataCenter.ItemManager.ItemId + if self.PanelAsset then + if not self.AssetPanel then + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, itemId.FreeGem, itemId.ActionPoint, itemId.Coin) + end + end +end + +function XUiNewCharActivity:OnEnable() + self:PlayAnimation("PanelMainEnable") + + if self.RedPointId then + XRedPointManager.Check(self.RedPointId) + end + + if self.CurrentView == PageIndex.Teaching then + self.PanelLineChapter:OnShow(0) + end +end + +function XUiNewCharActivity:OnDestroy() + self.IsOpenDetails = nil + self:StopActivityTimer() + --XEventManager.RemoveEventListener(XEventId.EVENT_ON_FESTIVAL_CHANGED, self.RefreshFestivalNodes, self) +end + +function XUiNewCharActivity:InitUiView() + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + self.BtnProfile.CallBack = function() self:OnBtnProfileClick() end + self.BtnReward.CallBack = function() self:OnBtnRewardClick() end + self.BtnObtain.CallBack = function() self:OnBtnObtainClick() end + self.BtnCharDetail.CallBack = function() self:OnBtnCharDetailClick() end + self.BtnTeaching.CallBack = function() self:OnBtnTeachingClick() end +end + +function XUiNewCharActivity:InitSceneRoot() + local root = self.UiModelGo.transform + self.CameraFar = { + root:FindTransform("FarCamera1"), + root:FindTransform("FarCamera2"), + root:FindTransform("FarCamera3"), + } + self.CameraNear = { + root:FindTransform("NearCamera1"), + root:FindTransform("NearCamera2"), + root:FindTransform("NearCamera3"), + } +end + +function XUiNewCharActivity:UpdateCamera(camera) + for _, cameraIndex in pairs(PageIndex) do + self.CameraNear[cameraIndex].gameObject:SetActive(cameraIndex == camera) + self.CameraFar[cameraIndex].gameObject:SetActive(cameraIndex == camera) + end +end + +function XUiNewCharActivity:OnBtnBackClick() + if self.CurrentView ~= PageIndex.Main then + self:SwitchPanelProfile(false) + self:UpdateCamera(PageIndex.Main) + if self.CurrentView == PageIndex.Teaching then + self.PanelLineChapter:OnHide() + end + + self.AnimTimer = XScheduleManager.ScheduleOnce(function() + self.PanelTeaching.gameObject:SetActiveEx(false) + self:OnSwitchView() + end, Delay[self.CurrentView]) + + self.CurrentView = PageIndex.Main + else + self:Close() + end +end + +function XUiNewCharActivity:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiNewCharActivity:OnBtnTeachingClick() + self.CurrentView = PageIndex.Teaching + self:OnSwitchView() + self.PanelTeaching.gameObject:SetActiveEx(true) + self.PanelLineChapter:OnShow() + self:UpdateCamera(PageIndex.Teaching) +end + +function XUiNewCharActivity:OnBtnProfileClick() + self.CurrentView = PageIndex.Profile + self.CurrentMsgIndex = 0 + self:OnSwitchView() + self:SwitchPanelProfile(true) + self:UpdateCamera(PageIndex.Profile) + self:PlayAnimation("MsgEnable") + self:RefreshProfile() +end + +function XUiNewCharActivity:OnBtnRewardClick() + if XLuaUiManager.IsUiLoad("UiActivityBase") then + XLuaUiManager.Remove("UiActivityBase") + end + -- 活动奖励,点击跳转活动任务界面 + XFunctionManager.SkipInterface(self.ActTemplate.SkipIdAct) +end + +function XUiNewCharActivity:OnBtnCharDetailClick() + -- 打开通用角色信息面板 + XLuaUiManager.Open("UiCharacterDetail", self.ActTemplate.CharacterId) +end + +function XUiNewCharActivity:OnBtnObtainClick() + -- 前往获取,点击跳转主题抽卡界面 + XFunctionManager.SkipInterface(self.ActTemplate.SkipIdDraw) +end + +function XUiNewCharActivity:RefreshProfile() + self.MsgList = XFubenNewCharConfig.GetMsgGroupById(self.ActId) + for index, v in ipairs(self.MsgList) do + if not self.TabBtns[index] then + self.TabBtns[index] = self["BtnMsg"..index] + -- self.InitEffect[index] = XUiHelper.TryGetComponent(self.TabBtns[index].transform, "Press/Effect", "RectTransform") + self.SwitchEffect[index] = XUiHelper.TryGetComponent(self.TabBtns[index].transform, "Normal/Effect", "RectTransform") + self.TabBtns[index]:SetNameByGroup(0, v.Title) + --解锁条件 + local desc = XConditionManager.GetConditionDescById(v.ConditionId) + self.TabBtns[index]:SetNameByGroup(1, desc) + self.TabBtns[index]:SetRawImage(v.BtnBg) + end + + if v.IsLock then + local result = XConditionManager.CheckCondition(v.ConditionId) + -- XUiButtonState.Press 是第二种Normal状态(只在还未选择任何线索时显示) + self.TabBtns[index]:SetButtonState(result and XUiButtonState.Press or XUiButtonState.Disable) + end + end + self.BtnGrp:Init(self.TabBtns, function(index) self:OnBtnMsg(index) end, 0) + self.MsgContent.gameObject:SetActiveEx(false) + self.MsgContentBg.gameObject:SetActiveEx(false) +end + +function XUiNewCharActivity:OnBtnMsg(index) + local btn = self.TabBtns[index] + if btn.ButtonState == CS.UiButtonState.Disable then + local desc = XConditionManager.GetConditionDescById(self.MsgList[index].ConditionId) + XUiManager.TipMsg(desc) + return + end + + for i, v in ipairs(self.TabBtns) do + if v.ButtonState ~= CS.UiButtonState.Disable then + -- 点击线索后,其他线索变为第一种Normal状态(置为灰色) + v:SetButtonState(self.CurrentMsgIndex == i and XUiButtonState.Select or XUiButtonState.Normal) + end + -- 特效只在切换时显示 + self.SwitchEffect[i].gameObject:SetActive(self.CurrentMsgIndex == i) + -- self.InitEffect[i].gameObject:SetActive(MsgBtnAnimEnable) + end + + --if self.MsgBtnAnimEnable then + -- self.MsgBtnAnimEnable = false + --end + if self.CurrentMsgIndex == index then + -- 点击已选中线索则为取消选中 + self:RefreshProfile() + self.CurrentMsgIndex = 0 + return + end + + self.MsgContent.gameObject:SetActiveEx(true) + self.MsgContentBg.gameObject:SetActiveEx(true) + -- 将选中的线索层级置为内容区之上,其他层级置为内容区之下 + self.MsgContent:SetSiblingIndex(self.MsgContent.parent.childCount - 1) + btn.transform:SetSiblingIndex(btn.transform.parent.childCount - 1) + self.TxtSerial.text = string.format("NO.%d", index) + self.TxtMsg.text = string.gsub(self.MsgList[index].Content, "\\n", "\n") + -- 每次查看线索时,文本都从最开头进行显示 + self.MsgScrollRect.verticalNormalizedPosition = 1 + self.CurrentMsgIndex = index + -- 用于将Press状态的按钮强制转换为Select状态,且需确保其位于判等返回函数之后 + self.BtnGrp:SelectIndex(index, false) + self:PlayAnimation("MsgContentEnable") +end + +function XUiNewCharActivity:OnSwitchView(nextView) + if self.CurrentView == PageIndex.Main then + self.PanelMain.gameObject:SetActiveEx(true) + self:PlayAnimation("PanelMainEnable", function () + end) + else + self:PlayAnimation("PanelMainDisable", function () + self.PanelMain.gameObject:SetActiveEx(false) + end) + -- self.MsgBtnAnimEnable = true + end +end + +function XUiNewCharActivity:SwitchPanelProfile(state) + self.PanelProfile.gameObject:SetActiveEx(state) + self.PanelProfileBg.gameObject:SetActiveEx(state) + self.MsgContentBg.gameObject:SetActiveEx(false) +end + +function XUiNewCharActivity:ReopenAssetPanel() + if self.IsOpenDetails then + return + end + if self.AssetPanel then + self.AssetPanel.GameObject:SetActiveEx(true) + end +end + +-- 背景 +function XUiNewCharActivity:SwitchBg(actTemplate) + if not actTemplate or not actTemplate.MainBackgound then return end + self.RImgFestivalBg:SetRawImage(actTemplate.MainBackgound) +end + +-- 计时器 +function XUiNewCharActivity:CreateActivityTimer(startTime, endTime) + local time = XTime.GetServerNowTimestamp() + self:StopActivityTimer() + self.ActivityTimer = XScheduleManager.ScheduleForever(function() + time = XTime.GetServerNowTimestamp() + if time > endTime then + self:Close() + XUiManager.TipError(CS.XTextManager.GetText("ActivityMainLineEnd")) + self:StopActivityTimer() + return + end + self.TxtDay.text = XUiHelper.GetTime(endTime - time, XUiHelper.TimeFormatType.ACTIVITY) + end, XScheduleManager.SECOND, 0) +end + +function XUiNewCharActivity:StopActivityTimer() + if self.ActivityTimer then + XScheduleManager.UnSchedule(self.ActivityTimer) + self.ActivityTimer = nil + end + if self.AnimTimer then + XScheduleManager.UnSchedule(self.AnimTimer) + self.AnimTimer = nil + end +end + +function XUiNewCharActivity:OnCheckBtnGameRedPoint(count) + self.BtnSkip:ShowReddot(count>=0) +end diff --git a/Resources/Scripts/XUi/XUiNewChar/XUiNewCharNewRoomSingle.lua b/Resources/Scripts/XUi/XUiNewChar/XUiNewCharNewRoomSingle.lua new file mode 100644 index 00000000..e672dc39 --- /dev/null +++ b/Resources/Scripts/XUi/XUiNewChar/XUiNewCharNewRoomSingle.lua @@ -0,0 +1,38 @@ +-- 教学关出战界面代理 +local XUiNewCharNewRoomSingle = {} +local CSXTextManagerGetText = CS.XTextManager.GetText + +function XUiNewCharNewRoomSingle.InitEditBattleUi(newRoomSingle) + newRoomSingle.BtnTeamPrefab.gameObject:SetActiveEx(false) +end + +function XUiNewCharNewRoomSingle.GetBattleTeamData(newRoomSingle) + local curTeam = XDataCenter.TeamManager.LoadTeamLocal(newRoomSingle.CurrentStageId) + XDataCenter.TeamManager.SaveTeamLocal(curTeam, newRoomSingle.CurrentStageId) + XDataCenter.TeamManager.SetPlayerTeam(curTeam, false) + return XTool.Clone(curTeam) +end + +function XUiNewCharNewRoomSingle.HandleCharClick(newRoomSingle, charPos) + local teamData = XTool.Clone(newRoomSingle.CurTeam.TeamData) + local robotIdList = XDataCenter.FubenNewCharActivityManager.GetCharacterList(newRoomSingle.CurrentStageId) + XLuaUiManager.Open("UiRoomCharacter", teamData, charPos, function(resTeam) + newRoomSingle:UpdateTeam(resTeam) + end, XDataCenter.FubenManager.StageType.NewCharAct, nil, {RobotIdList = robotIdList, RobotAndCharacter = true}) +end + +function XUiNewCharNewRoomSingle.UpdateTeam(newRoomSingle) + XDataCenter.TeamManager.SaveTeamLocal(newRoomSingle.CurTeam, newRoomSingle.CurrentStageId) + XDataCenter.TeamManager.SetPlayerTeam(newRoomSingle.CurTeam, false) +end + +function XUiNewCharNewRoomSingle.OnResetEvent(newRoomSingle) + XLuaUiManager.RunMain() + XUiManager.TipMsg(CSXTextManagerGetText("ActivityMainLineEnd")) +end + +function XUiNewCharNewRoomSingle.UpdateFightControl(newRoomSingle, curTeam) + return XUiFightControlState.Normal +end + +return XUiNewCharNewRoomSingle \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNewChar/XUiNewCharStageItem.lua b/Resources/Scripts/XUi/XUiNewChar/XUiNewCharStageItem.lua new file mode 100644 index 00000000..b2bda0b0 --- /dev/null +++ b/Resources/Scripts/XUi/XUiNewChar/XUiNewCharStageItem.lua @@ -0,0 +1,81 @@ +XUiNewCharStageItem = XClass(nil, "XUiNewCharStageItem") + +local XUiPanelStars = require("XUi/XUiFubenMainLineChapter/XUiPanelStars") + +function XUiNewCharStageItem:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) +end + +function XUiNewCharStageItem:SetNormalStage(stageId, stagePrefix, stageName) + self.PanelStageNormal.gameObject:SetActiveEx(not self.IsLock) + if not self.IsLock then + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + self.RImgFightActiveNor:SetRawImage(stageCfg.Icon) + end + + self.TxtStageTitle.text = stageName + self.TxtStagePrefix.text = stagePrefix + -- SetLockStage + self.PanelStageLock.gameObject:SetActiveEx(self.IsLock) +end + +function XUiNewCharStageItem:UpdateNode(actId, stageId, stageIndex) + local chapterTemplate = XFubenNewCharConfig.GetDataById(actId, stageIndex) + self.ActId = actId + self.StageId = stageId + self.StageIndex = stageIndex + local stageInfo = XDataCenter.FubenManager.GetStageInfo(self.StageId) + local stagePrefabName = chapterTemplate.GridFubenPrefab + + local isOpen, description = XDataCenter.FubenNewCharActivityManager.CheckStageOpen(stageId), CS.XTextManager.GetText("FubenPreStageNotPass") + -- self.GameObject:SetActiveEx(isOpen) + local gridGo = self.Transform:LoadPrefab(stagePrefabName) + local uiObj = gridGo.transform:GetComponent("UiObject") + for i = 0, uiObj.NameList.Count - 1 do + self[uiObj.NameList[i]] = uiObj.ObjList[i] + end + self.BtnStage.CallBack = function() self:OnBtnStageClick() end + + self.IsLock = not isOpen + self.Description = description + local stagePrefix = XDataCenter.FubenManager.GetStageName(chapterTemplate.StageId[self.StageIndex]) + local stageName = XDataCenter.FubenManager.GetStageDes(chapterTemplate.StageId[self.StageIndex]) + self:SetNormalStage(self.StageId, stagePrefix, stageName) + self.PanelStagePass.gameObject:SetActiveEx(XDataCenter.FubenNewCharActivityManager.CheckStagePass(stageId)) + + self.PanelStars = XUiPanelStars.New(self.PanelStar) + local starsMap = XDataCenter.FubenNewCharActivityManager.GetStarMap(self.StageId) + self.PanelStars:OnEnable(starsMap) +end + +function XUiNewCharStageItem:OnBtnStageClick() + if self.StageId and self.ActId then + if not self.IsLock then + self.RootUi:UpdateNodesSelect(self.StageId) + -- 打开详细界面 + self.RootUi:OpenStageDetails(self.StageId, self.ActId) + self.RootUi:PlayScrollViewMove(self.Transform) + else + XUiManager.TipMsg(self.Description) + end + + end +end + +function XUiNewCharStageItem:SetNodeSelect(isSelect) + if not self.IsLock then + self.ImageSelected.gameObject:SetActiveEx(isSelect) + end +end + +function XUiNewCharStageItem:ResetItemPosition(pos) + if self.ImgHideLine then + local rect = self.ImgHideLine:GetComponent("RectTransform").rect + self.Transform.localPosition = CS.UnityEngine.Vector3(pos.x, pos.y - rect.height, pos.z) + end +end + +return XUiNewCharStageItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNewChar/XUiPanelFubenKoroStage.lua b/Resources/Scripts/XUi/XUiNewChar/XUiPanelFubenKoroStage.lua new file mode 100644 index 00000000..f81f1d56 --- /dev/null +++ b/Resources/Scripts/XUi/XUiNewChar/XUiPanelFubenKoroStage.lua @@ -0,0 +1,252 @@ +local XUiPanelFubenKoroStage = XClass(nil, "XUiPanelFubenKoroStage") +local XUiFubenKoroStageItem = require("XUi/XUiNewChar/XUiFubenKoroStageItem") +local UIFUBENKOROTUTORIA_TEACHING_DETAIL = "UiFunbenKoroTutoriaTeachingDetail" +local UIFUBENKOROTUTORIA_CHALLENGE_DETAIL = "UiFunbenKoroTutoriaChallengeDetail" +local XUguiDragProxy = CS.XUguiDragProxy + +function XUiPanelFubenKoroStage:Ctor(uiRoot, ui, cfg, panelType) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.UiRoot = uiRoot + self.Cfg = cfg + self:InitPanel(panelType) + self.GridTreasureList = {} +end + +function XUiPanelFubenKoroStage:InitPanel(panelType) + if panelType == XFubenNewCharConfig.KoroPanelType.Teaching then + self.StageIds = self.Cfg.StageId + end + if panelType == XFubenNewCharConfig.KoroPanelType.Challenge then + self.StageIds = self.Cfg.ChallengeStage + end + + self.DragProxy = self.PaneStageList:GetComponent(typeof(XUguiDragProxy)) + if not self.DragProxy then + self.DragProxy = self.PaneStageList.gameObject:AddComponent(typeof(XUguiDragProxy)) + end + self.DragProxy:RegisterHandler(handler(self, self.OnDragProxy)) + + self.Stages = {} + self.StageGroup = {} + for i = 1, #self.StageIds do + local itemStage = self.PanelStageContent:Find(string.format("Stage%d", i)) + if not itemStage then + XLog.Error("XUiPanelFubenKoroStage:HandleStages() 函数错误: 游戏物体PanelStageContent下找不到名字为:" .. string.format("Stage%d", i) .. "的游戏物体") + return + end + self.StageGroup[i] = itemStage + self.Stages[i] = XUiFubenKoroStageItem.New(self, itemStage) + itemStage.gameObject:SetActiveEx(true) + end + + self.Lines = {} + for i = 1, #self.StageIds - 1 do + local itemLine = self.PanelStageContent:Find(string.format("Line%d", i)) + self.Lines[i] = itemLine + end + self.LineIcon = self.PanelStageContent:Find("IconEnd") + self.BtnCloseDetail.CallBack = function() self:OnBtnCloseDetailClick() end +end + +--初始化挑战目标 +function XUiPanelFubenKoroStage:InitTreasureGrade() + local baseItem = self.GridTreasureGrade + self.GridTreasureGrade.gameObject:SetActiveEx(false) + + for j = 1, #self.GridTreasureList do + self.GridTreasureList[j].GameObject:SetActiveEx(false) + end + + local targetList = self.Cfg.TreasureId + if not targetList then + return + end + + local gridCount = #targetList + for i = 1, gridCount do + local grid = self.GridTreasureList[i] + + if not grid then + local item = CS.UnityEngine.Object.Instantiate(baseItem) -- 复制一个item + grid = XUiGridTreasureGrade.New(self.UiRoot, item, XDataCenter.FubenManager.StageType.NewCharAct) + grid.Transform:SetParent(self.PanelGradeContent, false) + self.GridTreasureList[i] = grid + end + + local treasureCfg = XFubenNewCharConfig.GetTreasureCfg(targetList[i]) + local curStars = XDataCenter.FubenNewCharActivityManager.GetKoroStarProgressById(self.Cfg.Id) + grid:UpdateGradeGrid(curStars, treasureCfg, self.Cfg.Id) + + grid:InitTreasureList() + grid.GameObject:SetActiveEx(true) + end +end + +--初始化收集进度 +function XUiPanelFubenKoroStage:InitStarts() + local curStars + local totalStars + curStars, totalStars = XDataCenter.FubenNewCharActivityManager.GetKoroStarProgressById(self.Cfg.Id) + + self.ImgJindu.fillAmount = totalStars > 0 and curStars / totalStars or 0 + self.ImgJindu.gameObject:SetActiveEx(true) + self.TxtStarNum.text = CS.XTextManager.GetText("Fract", curStars, totalStars) + + local received = true + for _, v in pairs(self.Cfg.TreasureId) do + if not XDataCenter.FubenNewCharActivityManager.IsTreasureGet(v) then + received = false + break + end + end + self.ImgLingqu.gameObject:SetActiveEx(received) + + local isShowRed = XDataCenter.FubenNewCharActivityManager.CheckTreasureReward(self.Cfg.Id) + self.ImgRedProgress.gameObject:SetActiveEx(isShowRed) +end + +function XUiPanelFubenKoroStage:OnShow(type) + self.PanelType = type + self.GameObject:SetActiveEx(true) + for i = 1, #self.StageIds do + self.Stages[i]:UpdateNode(self.Cfg.Id, self.StageIds[i], i, self.PanelType) + end + if self.PanelType == XFubenNewCharConfig.KoroPanelType.Challenge then + self.BtnTreasure.CallBack = function() + self:OnBtnTreasureClick() + end + self.BtnTreasureBg.CallBack = function() + self:OnBtnTreasureBgClick() + end + self:InitStarts() + end + for i = 1, #self.StageIds - 1 do + self.Lines[i].gameObject:SetActiveEx(XDataCenter.FubenNewCharActivityManager.CheckStagePass(self.StageIds[i])) + end + + for i = 2, #self.StageIds do + self.StageGroup[i].gameObject:SetActiveEx(XDataCenter.FubenNewCharActivityManager.CheckStagePass(self.StageIds[i - 1])) + end + self.LineIcon.gameObject:SetActiveEx(XDataCenter.FubenNewCharActivityManager.CheckStagePass(self.StageIds[#self.StageIds - 1])) + self.LineEnable:PlayTimelineAnimation() +end + +function XUiPanelFubenKoroStage:OnHide() + self.GameObject:SetActiveEx(false) +end + +--选中关卡 +function XUiPanelFubenKoroStage:UpdateNodesSelect(stageId) + local stageIds = self.StageIds + for i = 1, #stageIds do + if self.Stages[i] then + self.Stages[i]:SetNodeSelect(stageIds[i] == stageId) + end + end +end + +--取消选中关卡 +function XUiPanelFubenKoroStage:ClearNodesSelect() + local stageIds = self.StageIds + for i = 1, #stageIds do + if self.Stages[i] then + self.Stages[i]:SetNodeSelect(false) + end + end + self.IsOpenDetails = false +end + +function XUiPanelFubenKoroStage:OpenStageDetails(stageId, id) + self.IsOpenDetails = true + self.BtnCloseDetail.gameObject:SetActiveEx(true) + + if self.PanelType == XFubenNewCharConfig.KoroPanelType.Teaching then + self.UiRoot:OpenOneChildUi(UIFUBENKOROTUTORIA_TEACHING_DETAIL, self) + self.UiRoot:FindChildUiObj(UIFUBENKOROTUTORIA_TEACHING_DETAIL):SetStageDetail(stageId, id) + if XLuaUiManager.IsUiShow(UIFUBENKOROTUTORIA_CHALLENGE_DETAIL) then + self.UiRoot:FindChildUiObj(UIFUBENKOROTUTORIA_CHALLENGE_DETAIL):Close() + end + end + + if self.PanelType == XFubenNewCharConfig.KoroPanelType.Challenge then + self.UiRoot:OpenOneChildUi(UIFUBENKOROTUTORIA_CHALLENGE_DETAIL, self) + self.UiRoot:FindChildUiObj(UIFUBENKOROTUTORIA_CHALLENGE_DETAIL):SetStageDetail(stageId, id) + if XLuaUiManager.IsUiShow(UIFUBENKOROTUTORIA_TEACHING_DETAIL) then + self.UiRoot:FindChildUiObj(UIFUBENKOROTUTORIA_TEACHING_DETAIL):Close() + end + end + if self.AssetPanel then + self.AssetPanel.GameObject:SetActiveEx(false) + end + self.PanelStageContentRaycast.raycastTarget = false +end + +--关闭战斗详情 +function XUiPanelFubenKoroStage:CloseStageDetails() + self.IsOpenDetails = false + self.BtnCloseDetail.gameObject:SetActiveEx(false) + + if XLuaUiManager.IsUiShow(UIFUBENKOROTUTORIA_TEACHING_DETAIL) then + self.UiRoot:FindChildUiObj(UIFUBENKOROTUTORIA_TEACHING_DETAIL):CloseDetailWithAnimation() + end + + + if XLuaUiManager.IsUiShow(UIFUBENKOROTUTORIA_CHALLENGE_DETAIL) then + self.UiRoot:FindChildUiObj(UIFUBENKOROTUTORIA_CHALLENGE_DETAIL):CloseDetailWithAnimation() + end + self.PanelStageContentRaycast.raycastTarget = true + self:ClearNodesSelect() + self.PaneStageList.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Elastic +end + +function XUiPanelFubenKoroStage:PlayScrollViewMove(gridTransform) + self.PaneStageList.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Unrestricted + local gridRect = gridTransform:GetComponent("RectTransform") + local diffX = gridRect.localPosition.x + self.PanelStageContent.localPosition.x + if diffX < XDataCenter.FubenMainLineManager.UiGridChapterMoveMinX or diffX > XDataCenter.FubenMainLineManager.UiGridChapterMoveMaxX then + local tarPosX = XDataCenter.FubenMainLineManager.UiGridChapterMoveTargetX - gridRect.localPosition.x + local tarPos = self.PanelStageContent.localPosition + tarPos.x = tarPosX + XLuaUiManager.SetMask(true) + XUiHelper.DoMove(self.PanelStageContent, tarPos, XDataCenter.FubenMainLineManager.UiGridChapterMoveDuration, XUiHelper.EaseType.Sin, function() + XLuaUiManager.SetMask(false) + end) + end +end + +--点击关闭详情按钮 +function XUiPanelFubenKoroStage:OnBtnCloseDetailClick() + self:CloseStageDetails() +end + +function XUiPanelFubenKoroStage:CheckCanClose() + if self.IsOpenDetails then + self:CloseStageDetails() + return false + end + return true +end + +function XUiPanelFubenKoroStage:OnBtnTreasureBgClick() + self.TreasureDisable:PlayTimelineAnimation(function() + self.PanelTreasure.gameObject:SetActiveEx(false) + self:InitStarts() + end) +end + +function XUiPanelFubenKoroStage:OnBtnTreasureClick() + self:InitTreasureGrade() + self.PanelTreasure.gameObject:SetActiveEx(true) + self.TreasureEnable:PlayTimelineAnimation() +end + +--拖拽事件处理 +function XUiPanelFubenKoroStage:OnDragProxy(dragType) + if self.IsOpenDetails and dragType == 0 then + self:CloseStageDetails() + end +end + +return XUiPanelFubenKoroStage \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNewChar/XUiPanelLineChapter.lua b/Resources/Scripts/XUi/XUiNewChar/XUiPanelLineChapter.lua new file mode 100644 index 00000000..39399699 --- /dev/null +++ b/Resources/Scripts/XUi/XUiNewChar/XUiPanelLineChapter.lua @@ -0,0 +1,323 @@ +local XUiPanelLineChapter = XClass(nil, "XUiPanelLineChapter") +local XUguiDragProxy = CS.XUguiDragProxy + +function XUiPanelLineChapter:Ctor(uiRoot, ui, chapterTemplate) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + self.ChapterTemplate = chapterTemplate + self.StageGroup = {} + self.GridTreasureList = {} + + XTool.InitUiObject(self) + + XUiHelper.RegisterClickEvent(self, self.BtnTreasureBg, self.OnBtnTreasureBgClick) + XUiHelper.RegisterClickEvent(self, self.BtnTreasure, self.OnBtnTreasureClick) + + self.RedPointId = XRedPointManager.AddRedPointEvent(self.ImgRedProgress, self.OnCheckRewards, self, { XRedPointConditions.Types.CONDITION_NEWCHARACT_TREASURE }, chapterTemplate.Id, false) + -- 初始化prefab组件 +end + +function XUiPanelLineChapter:OnShow(delay) + self.GameObject:SetActiveEx(false) + self:Refresh() + self.AnimTimer = XScheduleManager.ScheduleOnce(function() + self.GameObject:SetActiveEx(true) + --self.AnimEnable:PlayTimelineAnimation() + self.LineEnable:PlayTimelineAnimation() + for _, v in ipairs(self.ActStages) do + v.IconEnable:PlayTimelineAnimation() + end + end, delay or 1000) + self:UpdateChapterStars() + if self.PaneStageList and self.NeedReset then + self.PaneStageList.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Elastic + else + self.NeedReset = true + end + -- self.PanelTreasure.gameObject:SetActiveEx(false) +end + +function XUiPanelLineChapter:OnHide() + self.GameObject:SetActiveEx(true) + self.LineDisable:PlayTimelineAnimation() + for _, v in ipairs(self.ActStages) do + v.IconDisable:PlayTimelineAnimation() + end + if self.AnimTimer then + XScheduleManager.UnSchedule(self.AnimTimer) + self.AnimTimer = nil + end +end + +-- 更新刷新 +function XUiPanelLineChapter:Refresh() + local dragProxy = self.PaneStageList:GetComponent(typeof(XUguiDragProxy)) + if not dragProxy then + dragProxy = self.PaneStageList.gameObject:AddComponent(typeof(XUguiDragProxy)) + end + dragProxy:RegisterHandler(handler(self, self.OnDragProxy)) + + self.ActStageIds = self.ChapterTemplate.StageId + --XDataCenter.FubenNewCharActivityManager.GetAvailableStageIds(self.ChapterTemplate.Id) + -- 线条处理 + self:HandleStageLines() + -- 关卡处理 + self:HandleStages() + -- 界面信息 + -- self:SwitchFestivalBg(chapterTemplate) +end + +function XUiPanelLineChapter:HandleStages() + self.ActStages = {} + for i = 1, #self.ActStageIds do + local itemStage = self.PanelStageContent:Find(string.format("Stage%d", i)) + if not itemStage then + XLog.Error("XUiPanelLineChapter:HandleStages() 函数错误: 游戏物体PanelStageContent下找不到名字为:" .. string.format("Stage%d", i) .. "的游戏物体") + return + end + -- 组件初始化 + -- XLog.Warning(self.ActStageIds[i], isOpen, itemStage) + self.StageGroup[i] = itemStage + self.ActStages[i] = XUiNewCharStageItem.New(self, itemStage) + itemStage.gameObject:SetActiveEx(true) + self.ActStages[i]:UpdateNode(self.ChapterTemplate.Id, self.ActStageIds[i], i) + end + self:UpdateNodeLines() +end + +function XUiPanelLineChapter:HandleStageLines() + self.ActStageLine = {} + for i = 2, #self.ActStageIds do + local itemLine = self.PanelStageContent:Find(string.format("Line%d", i-1)) + if not itemLine then + XLog.Error("XUiPanelLineChapter:SetUiData() error: prefab not found a child name:" .. string.format("Line%d", i)) + return + end + itemLine.gameObject:SetActiveEx(false) + self.ActStageLine[i] = itemLine + end +end + +-- 更新节点线条 +function XUiPanelLineChapter:UpdateNodeLines() + if not self.ChapterTemplate or not self.ActStageIds then return end + local stageLength = #self.ActStageIds + for i = 2, stageLength do + --local isOpen = XDataCenter.FubenNewCharActivityManager.CheckStageOpen(self.ActStageIds[i]) + self:SetStageLineActive(i, true) + --if isOpen then + -- self.LastOpenStage = i + --end + end + self:SetStageLineActive(1, true) +end + +function XUiPanelLineChapter:SetStageLineActive(index, isActive) + if self.ActStageLine[index] then + self.ActStageLine[index].gameObject:SetActiveEx(isActive) + end +end + +-- 选中关卡 +function XUiPanelLineChapter:UpdateNodesSelect(stageId) + local stageIds = self.ActStageIds + for i = 1, #stageIds do + if self.ActStages[i] then + self.ActStages[i]:SetNodeSelect(stageIds[i] == stageId) + end + end +end + +-- 取消选中 +function XUiPanelLineChapter:ClearNodesSelect() + for i = 1, #self.ActStageIds do + if self.ActStages[i] then + self.ActStages[i]:SetNodeSelect(false) + end + end + self.IsOpenDetails = false +end + +function XUiPanelLineChapter:GetStages() + local stageIds = {} + for i = 1, #self.ChapterTemplate.StageId do + stageIds[i] = self.ChapterTemplate.StageId[i] + end + return stageIds +end + +-- 打开剧情,战斗详情 +function XUiPanelLineChapter:OpenStageDetails(stageId, festivalId) + local fStage = XDataCenter.FubenFestivalActivityManager.GetFestivalStageByFestivalIdAndStageId(festivalId, stageId) + local detailType = XDataCenter.FubenFestivalActivityManager.StageFuben + if not fStage then + self.IsOpenDetails = true + self.StageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + local stageType = self.StageCfg.StageType + if stageType == XFubenConfigs.STAGETYPE_FIGHT or stageType == XFubenConfigs.STAGETYPE_FIGHTEGG then + detailType = XDataCenter.FubenFestivalActivityManager.StageFuben + elseif stageType == XFubenConfigs.STAGETYPE_STORY or stageType == XFubenConfigs.STAGETYPE_STORYEGG then + detailType = XDataCenter.FubenFestivalActivityManager.StageStory + end + else + self.FStage = fStage + self.IsOpenDetails = true + detailType = self.FStage:GetStageShowType() + end + + if detailType == XDataCenter.FubenFestivalActivityManager.StageFuben then + XLuaUiManager.Open("UiFubenExploreDetail", self, self.FStage and self.FStage:GetStageCfg() or self.StageCfg, function() + if self.CurChapterGrid then + self.CurChapterGrid:ScaleBack() + end + self:CloseStageDetails() + end, XDataCenter.FubenManager.StageType.ActivtityBranch) + end + if self.AssetPanel then + self.AssetPanel.GameObject:SetActiveEx(false) + end + self.PanelStageContentRaycast.raycastTarget = false +end + +-- 关闭剧情,战斗详情 +function XUiPanelLineChapter:CloseStageDetails() + self.IsOpenDetails = false + self.PanelStageContentRaycast.raycastTarget = true + self:ClearNodesSelect() + --self:ReopenAssetPanel() + self.PaneStageList.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Elastic +end + +function XUiPanelLineChapter:OnBntCloseDetailClick() + self:CloseStageDetails() +end + +function XUiPanelLineChapter:OnDragProxy(dragType) + if self.IsOpenDetails and dragType == 0 then + self:CloseStageDetails() + end +end + +function XUiPanelLineChapter:PlayScrollViewMove(gridTransform) + self.PaneStageList.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Unrestricted + local gridRect = gridTransform:GetComponent("RectTransform") + local diffX = gridRect.localPosition.x + self.PanelStageContent.localPosition.x + if diffX < XDataCenter.FubenMainLineManager.UiGridChapterMoveMinX or diffX > XDataCenter.FubenMainLineManager.UiGridChapterMoveMaxX then + local tarPosX = XDataCenter.FubenMainLineManager.UiGridChapterMoveTargetX - gridRect.localPosition.x + local tarPos = self.PanelStageContent.localPosition + tarPos.x = tarPosX + XLuaUiManager.SetMask(true) + XUiHelper.DoMove(self.PanelStageContent, tarPos, XDataCenter.FubenMainLineManager.UiGridChapterMoveDuration, XUiHelper.EaseType.Sin, function() + XLuaUiManager.SetMask(false) + end) + end +end + +function XUiPanelLineChapter:MoveIntoStage(stageIndex) + local gridRect = self.StageGroup[stageIndex] + local diffX = gridRect.localPosition.x + self.PanelStageContent.localPosition.x + if diffX > CS.XResolutionManager.OriginWidth / 2 then + local tarPosX = (CS.XResolutionManager.OriginWidth / 4) - gridRect.localPosition.x + local tarPos = self.PanelStageContent.localPosition + tarPos.x = tarPosX + XLuaUiManager.SetMask(true) + self.PaneStageList.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Unrestricted + XUiHelper.DoMove(self.PanelStageContent, tarPos, XDataCenter.FubenMainLineManager.UiGridChapterMoveDuration, XUiHelper.EaseType.Sin, function() + XLuaUiManager.SetMask(false) + self.PaneStageList.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Elastic + end) + end +end + +function XUiPanelLineChapter:EndScrollViewMove() + self.PaneStageList.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Elastic + self:ReopenAssetPanel() +end + +-- 背景 +function XUiPanelLineChapter:SwitchFestivalBg(festivalTemplate) + if not festivalTemplate or not festivalTemplate.MainBackgound then return end + self.RImgFestivalBg:SetRawImage(festivalTemplate.MainBackgound) +end + +-- 是否显示红点 +function XUiPanelLineChapter:OnCheckRewards(count) + self.ImgRedProgress.gameObject:SetActiveEx(count >= 0) +end + +function XUiPanelLineChapter:UpdateChapterStars() + local curStars + local totalStars + curStars, totalStars = XDataCenter.FubenNewCharActivityManager.GetStarProgressById(self.ChapterTemplate.Id) + + self.ImgJindu.fillAmount = totalStars > 0 and curStars / totalStars or 0 + self.ImgJindu.gameObject:SetActiveEx(true) + self.TxtStarNum.text = CS.XTextManager.GetText("Fract", curStars, totalStars) + + local received = true + for _, v in pairs(self.ChapterTemplate.TreasureId) do + if not XDataCenter.FubenNewCharActivityManager.IsTreasureGet(v) then + received = false + break + end + end + self.ImgLingqu.gameObject:SetActiveEx(received) + + self.PanelBfrtTask.gameObject:SetActiveEx(false) + self.PanelDesc.gameObject:SetActiveEx(true) + XRedPointManager.Check(self.RedPointId, self.ChapterTemplate.Id) +end + +function XUiPanelLineChapter:OnBtnTreasureBgClick() + self.UiRoot.TopControl.gameObject:SetActiveEx(true) + self.TreasureDisable:PlayTimelineAnimation(function() + self.PanelTreasure.gameObject:SetActiveEx(false) + end) +end + +function XUiPanelLineChapter:OnBtnTreasureClick() + self.UiRoot.TopControl.gameObject:SetActiveEx(false) + self:InitTreasureGrade() + self.PanelTreasure.gameObject:SetActiveEx(true) + self.TreasureEnable:PlayTimelineAnimation() +end + +-- 初始化 treasure grade grid panel,填充数据 +function XUiPanelLineChapter:InitTreasureGrade() + local baseItem = self.GridTreasureGrade + self.GridTreasureGrade.gameObject:SetActiveEx(false) + + -- 先把所有的格子隐藏 + for j = 1, #self.GridTreasureList do + self.GridTreasureList[j].GameObject:SetActiveEx(false) + end + + local targetList = self.ChapterTemplate.TreasureId + if not targetList then + return + end + -- XLog.Warning(targetList) + + local gridCount = #targetList + + for i = 1, gridCount do + local grid = self.GridTreasureList[i] + + if not grid then + local item = CS.UnityEngine.Object.Instantiate(baseItem) -- 复制一个item + grid = XUiGridTreasureGrade.New(self.UiRoot, item, XDataCenter.FubenManager.StageType.NewCharAct) + grid.Transform:SetParent(self.PanelGradeContent, false) + self.GridTreasureList[i] = grid + end + + local treasureCfg = XFubenNewCharConfig.GetTreasureCfg(targetList[i]) + local curStars = XDataCenter.FubenNewCharActivityManager.GetStarProgressById(self.ChapterTemplate.Id) + grid:UpdateGradeGrid(curStars, treasureCfg, self.ChapterTemplate.Id) + + grid:InitTreasureList() + grid.GameObject:SetActiveEx(true) + end +end + +return XUiPanelLineChapter \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNewPlayerTask/XUiBtnNewbieTaskTab.lua b/Resources/Scripts/XUi/XUiNewPlayerTask/XUiBtnNewbieTaskTab.lua new file mode 100644 index 00000000..b36f7232 --- /dev/null +++ b/Resources/Scripts/XUi/XUiNewPlayerTask/XUiBtnNewbieTaskTab.lua @@ -0,0 +1,76 @@ +XUiBtnNewbieTaskTab = XClass(nil, "XUiBtnNewbieTaskTab") + +function XUiBtnNewbieTaskTab:Ctor(ui, rootUi, tabInfos) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self.TabInfos = tabInfos + self:InitAutoScript() + self:OnRefreshView() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiBtnNewbieTaskTab:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiBtnNewbieTaskTab:AutoInitUi() + self.BtnNewbieTaskTab = self.Transform:GetComponent("Button") + self.ImgDefault = self.Transform:Find("ImgDefault"):GetComponent("Image") + self.TxtDayDefault = self.Transform:Find("TxtDayDefault"):GetComponent("Text") + self.ImgSelected = self.Transform:Find("ImgSelected"):GetComponent("Image") + self.TxtDaySelected = self.Transform:Find("ImgSelected/TxtDaySelected"):GetComponent("Text") + self.ImgReddot = self.Transform:Find("ImgReddot"):GetComponent("Image") + self.ImgLock = self.Transform:Find("ImgLock"):GetComponent("Image") +end + +function XUiBtnNewbieTaskTab:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiBtnNewbieTaskTab:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiBtnNewbieTaskTab:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiBtnNewbieTaskTab:AutoAddListener() + self:RegisterClickEvent(self.BtnNewbieTaskTab, self.OnBtnNewbieTaskTabClick) +end +-- auto + +function XUiBtnNewbieTaskTab:OnBtnNewbieTaskTabClick() + +end + +function XUiBtnNewbieTaskTab:OnSelectDayTab(isSelect) + self.ImgSelected.gameObject:SetActive(isSelect) +end + +function XUiBtnNewbieTaskTab:OnRefreshView() + self.TxtDayDefault.text = CS.XTextManager.GetText("NewbieDayTab1", self.TabInfos.OpenDay) + self.TxtDaySelected.text = CS.XTextManager.GetText("NewbieDayTab1", self.TabInfos.OpenDay) + local isCurrentLock = self:IsCurrentLock() + self.ImgLock.gameObject:SetActive(isCurrentLock) + if isCurrentLock then + self.ImgReddot.gameObject:SetActive(false) + else + self.ImgReddot.gameObject:SetActive(XDataCenter.TaskManager.GetNewbiePlayTaskReddotByOpenDay(self.TabInfos.OpenDay)) + end +end + +function XUiBtnNewbieTaskTab:IsCurrentLock() + if XPlayer.NewPlayerTaskActiveDay == nil then return true end + return self.TabInfos.OpenDay > XPlayer.NewPlayerTaskActiveDay +end + +return XUiBtnNewbieTaskTab \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNewPlayerTask/XUiGridNewbieTaskItem.lua b/Resources/Scripts/XUi/XUiNewPlayerTask/XUiGridNewbieTaskItem.lua new file mode 100644 index 00000000..de78ad2a --- /dev/null +++ b/Resources/Scripts/XUi/XUiNewPlayerTask/XUiGridNewbieTaskItem.lua @@ -0,0 +1,118 @@ +XUiGridNewbieTaskItem = XClass(nil, "XUiGridNewbieTaskItem") + +function XUiGridNewbieTaskItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + self.BtnCollect.CallBack = function() self:OnBtnCollectClick() end + self.BtnSkip.CallBack = function() self:OnBtnSkipClick() end + + self.RewardPanelList = {} +end + +function XUiGridNewbieTaskItem:Init(rootUi) + self.RootUi = rootUi +end + +function XUiGridNewbieTaskItem:OnBtnCollectClick() + if not self.NewbieTaskInfo then return end + -- local templateTask = XDataCenter.TaskManager.GetTaskTemplate(self.NewbieTaskInfo) + local stateTask = XDataCenter.TaskManager.GetTaskDataById(self.NewbieTaskInfo) + + if stateTask.State ~= XDataCenter.TaskManager.TaskState.Achieved then + return + end + + local weaponCount = 0 + local chipCount = 0 + for i=1, #self.RewardPanelList do + local rewardsId = self.RewardPanelList[i].TemplateId + if XDataCenter.EquipManager.IsClassifyEqualByTemplateId(rewardsId, XEquipConfig.Classify.Weapon) then + weaponCount = weaponCount + 1 + elseif XDataCenter.EquipManager.IsClassifyEqualByTemplateId(rewardsId, XEquipConfig.Classify.Awareness) then + chipCount = chipCount + 1 + end + + end + + if weaponCount > 0 and XDataCenter.EquipManager.CheckBagCount(weaponCount, XEquipConfig.Classify.Weapon) == false or + chipCount > 0 and XDataCenter.EquipManager.CheckBagCount(chipCount, XEquipConfig.Classify.Awareness) == false then + return + end + + XDataCenter.TaskManager.FinishTask(stateTask.Id, function(rewards) + XUiManager.OpenUiObtain(rewards, nil, function() + self.RootUi:OnTaskChangeSync() + end, nil) + end) +end + +function XUiGridNewbieTaskItem:OnBtnSkipClick() + + local templateTaskData = XDataCenter.TaskManager.GetTaskTemplate(self.NewbieTaskInfo) + local stateTaskData = XDataCenter.TaskManager.GetTaskDataById(self.NewbieTaskInfo) + if not templateTaskData then return end + + if stateTaskData.State ~= XDataCenter.TaskManager.TaskState.Achieved then + XFunctionManager.SkipInterface(templateTaskData.SkipId) + end +end + +function XUiGridNewbieTaskItem:OnRefreshDatas(newbieTaskInfo) + self.NewbieTaskInfo = newbieTaskInfo + local templateTaskData = XDataCenter.TaskManager.GetTaskTemplate(newbieTaskInfo) + local stateTaskData = XDataCenter.TaskManager.GetTaskDataById(newbieTaskInfo) + + self.TxtTitle.text = templateTaskData.Desc + local result = templateTaskData.Result > 0 and templateTaskData.Result or 1 + XTool.LoopMap(stateTaskData.Schedule, function(_, pair) + pair.Value = pair.Value > result and result or pair.Value + self.TxtProgress.text = string.format("%d/%d", pair.Value, result) + end) + + self:UpdateBtns() + self:UpdateRewards() +end + +function XUiGridNewbieTaskItem:UpdateBtns() + if self.NewbieTaskInfo == nil then return end + local stateTaskData = XDataCenter.TaskManager.GetTaskDataById(self.NewbieTaskInfo) + self.BtnCollect.gameObject:SetActive(false) + self.BtnSkip.gameObject:SetActive(false) + if stateTaskData.State == XDataCenter.TaskManager.TaskState.Achieved then--可领取 + self.BtnCollect.gameObject:SetActive(true) + elseif stateTaskData.State ~= XDataCenter.TaskManager.TaskState.Finish and stateTaskData.State ~= XDataCenter.TaskManager.TaskState.Invalid then--跳转 + self.BtnSkip.gameObject:SetActive(true) + end +end + +function XUiGridNewbieTaskItem:UpdateRewards() + if self.NewbieTaskInfo == nil then return end + local templateTaskData = XDataCenter.TaskManager.GetTaskTemplate(self.NewbieTaskInfo) + -- local stateTaskData = XDataCenter.TaskManager.GetTaskDataById(self.NewbieTaskInfo) + local rewards = XRewardManager.GetRewardList(templateTaskData.RewardId) + if not rewards then return end + local rewardCount = #rewards + + for i=1, rewardCount do + local panel = self.RewardPanelList[i] + if not panel then + local ui = CS.UnityEngine.Object.Instantiate(self.PanelReward) + ui.transform:SetParent(self.UiContent, false) + ui.gameObject:SetActive(true) + ui.gameObject.name = string.format("PanelReward%d", i) + panel = XUiGridCommon.New(self.RootUi, ui) + table.insert(self.RewardPanelList, i, panel) + end + + end + for i=1, #self.RewardPanelList do + self.RewardPanelList[i].GameObject:SetActive(i <= rewardCount) + if i <= rewardCount then + self.RewardPanelList[i]:Refresh(rewards[i]) + end + end +end + +return XUiGridNewbieTaskItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNewPlayerTask/XUiNewPlayerTask.lua b/Resources/Scripts/XUi/XUiNewPlayerTask/XUiNewPlayerTask.lua new file mode 100644 index 00000000..d919913b --- /dev/null +++ b/Resources/Scripts/XUi/XUiNewPlayerTask/XUiNewPlayerTask.lua @@ -0,0 +1,293 @@ +local XUiNewPlayerTask = XLuaUiManager.Register(XLuaUi, "UiNewPlayerTask") + +local ITEM_TASK_PROGRESS_ID = CS.XGame.ClientConfig:GetInt("NewPlayerTaskExpId") +local FULL_PROGRESS = 0.9 + +function XUiNewPlayerTask:OnAwake() + self:InitBottomView() + self:InitDayTabView() + self:InitNewbieTaskView() + + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self.BtnBack.CallBack = function() self:Close() end + self.BtnMainUi.CallBack = function() XLuaUiManager.RunMain() end + self.BtnSkipChat.CallBack = function() self:OnEndTalkClick() end + + XDataCenter.ItemManager.AddCountUpdateListener(ITEM_TASK_PROGRESS_ID, function() + self:RefreshBottomView() + end, self.TxtCurProgress) + self.OnStartState = false + -- local hintFirstOpenTab = string.format("%s%d", XDataCenter.TaskManager.NewPLayerTaskFirstTalk, 2) + -- XDataCenter.TaskManager.SaveNewPlayerHint(hintFirstOpenTab, 0) +end + +function XUiNewPlayerTask:InitNewbieTaskView() + if not self.DynamicTableNewbieTask then + self.DynamicTableNewbieTask = XDynamicTableNormal.New(self.SViewTask.gameObject) + self.DynamicTableNewbieTask:SetProxy(XUiGridNewbieTaskItem) + self.DynamicTableNewbieTask:SetDelegate(self) + end +end + +function XUiNewPlayerTask:InitDayTabView() + + local tabName = "BtnNewbie" + self.BtnsTabInfos = XTaskConfig.GetNewPlayerTaskGroupTemplate() + self.BtnsDayTab = {} + self.BtnsDayTab[1] = self.BtnNewbieTaskTab + self.BtnsDayTab[1].gameObject.name = string.format( "%s%d", tabName, 1 ) + self:UpdateTaskListTag(self.BtnsDayTab[1], self.BtnsTabInfos[1].OpenDay) + + for i=2, #self.BtnsTabInfos do + local btnTab = self.BtnsDayTab[i] + if not btnTab then + local tabUi = CS.UnityEngine.Object.Instantiate(self.BtnNewbieTaskTab.gameObject) + tabUi.name = string.format( "%s%d", tabName, i ) + tabUi.transform:SetParent(self.UiContent, false) + btnTab = tabUi.transform:GetComponent("XUiButton") + btnTab:SetName(CS.XTextManager.GetText("NewbieDayTab1", self.BtnsTabInfos[i].OpenDay)) + tabUi:SetActive(true) + table.insert(self.BtnsDayTab, i, btnTab) + end + self:UpdateTaskListTag(btnTab, self.BtnsTabInfos[i].OpenDay) + end + + self.TabBtnGroup:Init(self.BtnsDayTab, function(index) self:OnBtnDaySelected(index) end) +end + +function XUiNewPlayerTask:UpdateTaskListTag(tab, openDay) + local curNewbieTask = XDataCenter.TaskManager.GetNewPlayerTaskListByGroup(openDay) + if curNewbieTask == nil then + tab:ShowTag(true) + return + end + for _, v in pairs(curNewbieTask) do + local stateTask = XDataCenter.TaskManager.GetTaskDataById(v) + if stateTask.State ~= XDataCenter.TaskManager.TaskState.Finish and stateTask.State ~= XDataCenter.TaskManager.TaskState.Invalid then + tab:ShowTag(false) + return + end + end + tab:ShowTag(true) +end + +function XUiNewPlayerTask:InitBottomView() + local newbieActiveness = XTaskConfig.GetTaskNewbieActivenessTemplate() + self.TotalProgress = {} + self.TotalCount = #newbieActiveness.Activeness + self.MaxProgress = newbieActiveness.Activeness[self.TotalCount] + self.ProgressStage = {} + for i=1, self.TotalCount do + self.ProgressStage[i] = newbieActiveness.Activeness[i] + end + + self.ImgProgressRect = self.ImgProgress:GetComponent("RectTransform") + self.TemplatePositon = self.PanelNewbieActive.transform.localPosition + self.TemplateRect = self.PanelNewbieActive:GetComponent("RectTransform") + + self.TotalProgress[1] = XUiPanelNewbieActive.New(self.PanelNewbieActive.gameObject, self, 1, self.ProgressStage[1]) + for i=2, #self.ProgressStage do + local progress = self.TotalProgress[i] + if not progress then + local ui = CS.UnityEngine.Object.Instantiate(self.PanelNewbieActive) + ui.transform:SetParent(self.ImgProgress.transform, false) + progress = XUiPanelNewbieActive.New(ui, self, i, self.ProgressStage[i]) + table.insert(self.TotalProgress, i, progress) + end + end + +end + +function XUiNewPlayerTask:UpdateNewbieActivePositions() + -- 更新位置 + local totalWdith = self.ImgProgressRect.rect.size.x + local activeWidthOffset = self.TemplateRect.rect.size.x / 2 + for i=1, #self.ProgressStage do + local currProgress = self.ProgressStage[i] * 1.0 / self.MaxProgress * FULL_PROGRESS + local progress = self.TotalProgress[i] + if progress then + progress.Transform:GetComponent("RectTransform").anchoredPosition3D = CS.UnityEngine.Vector3(currProgress * totalWdith - activeWidthOffset, self.TemplatePositon.y, self.TemplatePositon.z) + end + end +end + + +function XUiNewPlayerTask:OnStart(selectIdx) + self.OnStartState = true + self.DefaultIdx = selectIdx + XEventManager.AddEventListener(XEventId.EVENT_TASK_SYNC, self.OnTaskChangeSync, self) + XEventManager.AddEventListener(XEventId.EVENT_NEWBIETASK_DAYCHANGED, self.OnTaskChangeSync, self) +end + + +function XUiNewPlayerTask:OnEnable() + local hintTab = XDataCenter.TaskManager.GetNewPlayerHint(XDataCenter.TaskManager.NewPlayerLastSelectTab, self.BtnsTabInfos[1].OpenDay) + hintTab = self.DefaultIdx or self.CurSelectDay or hintTab + self.DefaultIdx = nil + + local hintFirstOpenTab = string.format("%s%d", XDataCenter.TaskManager.NewPLayerTaskFirstTalk, hintTab) + local hintTabFirstOpen = XDataCenter.TaskManager.GetNewPlayerHint(hintFirstOpenTab, 0) + + self:UpdateTabGroupStatus() + self.TabBtnGroup:SelectIndex(hintTab) + + -- 不是第一次播放了,可以直接播入場動畫 + if self.OnStartState and hintTabFirstOpen == 1 then + self:PlayAnimation("AnimEnableOpen", function() + self.AnimEnableOpenDirector:Stop() + XLuaUiManager.SetMask(false) + end, + function() + XLuaUiManager.SetMask(true) + end) + end + self.OnStartState = false +end + + +function XUiNewPlayerTask:OnDestroy() + XEventManager.RemoveEventListener(XEventId.EVENT_TASK_SYNC, self.OnTaskChangeSync, self) + XEventManager.RemoveEventListener(XEventId.EVENT_NEWBIETASK_DAYCHANGED, self.OnTaskChangeSync, self) +end + + +function XUiNewPlayerTask:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.CurrentNewbieTasks[index] + if data ~= nil then + grid:OnRefreshDatas(data) + end + -- elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + end +end + +-- [更新底部] +function XUiNewPlayerTask:RefreshBottomView() + local newbieActiveness = XTaskConfig.GetTaskNewbieActivenessTemplate() + local count = #newbieActiveness.Activeness + local maxProgress = newbieActiveness.Activeness[count] + local taskProgressCount = XDataCenter.ItemManager.GetCount(ITEM_TASK_PROGRESS_ID) or 0 + self.TxtCurProgress.text = taskProgressCount + self.TxtTotalProgress.text = string.format("/%d", maxProgress) + local currentProgress = taskProgressCount * 1.0 / maxProgress * FULL_PROGRESS + self.ImgProgress.fillAmount = (currentProgress > FULL_PROGRESS) and 1 or currentProgress + + for i=1, #self.TotalProgress do + self.TotalProgress[i]:UpdateNewbieActiveView(taskProgressCount, maxProgress) + end + -- 更新 + self:UpdateNewbieActivePositions() +end + +-- [更新左边立绘信息] +function XUiNewPlayerTask:RefreshLeftView(day) + local talkConfig = XDataCenter.TaskManager.GetNewPlayerTaskTalkConfig(day) + if not talkConfig then return end + + self.RImgTabBoard:SetRawImage(talkConfig.RoleHalfIcon) + self.TxtBoardName.text = XCharacterConfigs.GetCharacterName(talkConfig.ShowCharId) + self.TxtBoardPinyin.text = talkConfig.SpellName +end + + +-- [刷新第几天的任务列表] +function XUiNewPlayerTask:RefreshNewbieTaskView(group) + local curNewbieTask = XDataCenter.TaskManager.GetNewPlayerTaskListByGroup(group) + if curNewbieTask == nil then return end + self.CurrentNewbieTasks = {} + for _, v in pairs(curNewbieTask) do + local stateTask = XDataCenter.TaskManager.GetTaskDataById(v) + if stateTask.State ~= XDataCenter.TaskManager.TaskState.Finish and stateTask.State ~= XDataCenter.TaskManager.TaskState.Invalid then + table.insert(self.CurrentNewbieTasks, v) + end + end + + self.PanelNoneTask.gameObject:SetActive(#self.CurrentNewbieTasks <= 0) + self.BtnsDayTab[group]:ShowTag(#self.CurrentNewbieTasks <= 0) + + if self.DynamicTableNewbieTask then + self.DynamicTableNewbieTask:SetDataSource(self.CurrentNewbieTasks) + self.DynamicTableNewbieTask:ReloadDataSync() + end +end + +function XUiNewPlayerTask:IsCurrentLock(day) + if XPlayer.NewPlayerTaskActiveDay == nil then return true end + + return day > XPlayer.NewPlayerTaskActiveDay +end + +function XUiNewPlayerTask:UpdateTabGroupStatus() + for i=1, #self.BtnsDayTab do + if self:IsCurrentLock(self.BtnsTabInfos[i].OpenDay) then + self.BtnsDayTab[i]:SetButtonState(CS.UiButtonState.Disable) + self.BtnsDayTab[i]:ShowReddot(false) + else + self.BtnsDayTab[i]:ShowReddot(XDataCenter.TaskManager.GetNewbiePlayTaskReddotByOpenDay(self.BtnsTabInfos[i].OpenDay)) + end + end +end + +function XUiNewPlayerTask:OnTaskChangeSync() + if self.CurSelectDay then + self:UpdateTabGroupStatus() + self:RefreshLeftView(self.CurSelectDay) + self:RefreshBottomView() + self:RefreshNewbieTaskView(self.CurSelectDay) + end +end + +function XUiNewPlayerTask:OnBtnDaySelected(day) + + if self:IsCurrentLock(self.BtnsTabInfos[day].OpenDay) then + XUiManager.TipMsg(CS.XTextManager.GetText("NewbieDayUnlock")) + return + end + + self:RefreshBottomView() + if self.CurSelectDay ~= nil and self.CurSelectDay == day then + self:RefreshLeftView(day) + self:RefreshNewbieTaskView(day) + else + self:RefreshLeftView(day) + self:RefreshNewbieTaskView(day) + + local hintFirstOpenTab = string.format("%s%d", XDataCenter.TaskManager.NewPLayerTaskFirstTalk, day) + local isFirstOpen = XDataCenter.TaskManager.GetNewPlayerHint(hintFirstOpenTab, 0) + + if isFirstOpen == 1 then + self.AnimQieHuan:PlayTimelineAnimation(function() + self:UpdateNewbieActivePositions() + end) + else + -- 第一次打開,設置已經標記 + XDataCenter.TaskManager.SaveNewPlayerHint(hintFirstOpenTab, 1) + + self.PanelRightCanvas.alpha = 0 + self.PanelContent.gameObject:SetActive(false) + self.ImgMask.gameObject:SetActiveEx(true) + self.ChatContent.text = self.BtnsTabInfos[day].FirstTalk + self.BeginTalkEnable:PlayTimelineAnimation(function() + self.BtnSkipChat.gameObject:SetActive(true) + self.MaskClickCount = 0 + end) + end + + end + self.CurSelectDay = day + XDataCenter.TaskManager.SaveNewPlayerHint(XDataCenter.TaskManager.NewPlayerLastSelectTab, day) +end + +function XUiNewPlayerTask:OnEndTalkClick() + if self.MaskClickCount and self.MaskClickCount >= 1 then return end + self.PanelRightCanvas.alpha = 1 + self.PanelContent.gameObject:SetActive(true) + self.EndTalkEnable:PlayTimelineAnimation(function() + self.BtnSkipChat.gameObject:SetActive(false) + self.ImgMask.gameObject:SetActiveEx(false) + end) + self:UpdateNewbieActivePositions() + self.MaskClickCount = self.MaskClickCount + 1 +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNewPlayerTask/XUiPanelNewbieActive.lua b/Resources/Scripts/XUi/XUiNewPlayerTask/XUiPanelNewbieActive.lua new file mode 100644 index 00000000..a7bc561e --- /dev/null +++ b/Resources/Scripts/XUi/XUiNewPlayerTask/XUiPanelNewbieActive.lua @@ -0,0 +1,134 @@ +XUiPanelNewbieActive = XClass(nil, "XUiPanelNewbieActive") + +local normalSize = CS.XGame.ClientConfig:GetInt("NewPlayerTaskSmallSize") +local specialSize = CS.XGame.ClientConfig:GetInt("NewPlayerTaskBigSize") + +function XUiPanelNewbieActive:Ctor(ui, rootUi, index, stageInfo) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self:InitAutoScript() + self.RootUi = rootUi + self.Index = index + self.TxtValue.text = stageInfo + self.ImgActiveRect = self.GridCommon:GetComponent("RectTransform") +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelNewbieActive:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiPanelNewbieActive:AutoInitUi() + self.BtnActive = self.Transform:Find("BtnActive"):GetComponent("Button") + self.TxtValue = self.Transform:Find("TxtValue"):GetComponent("Text") + self.PanelEffect = self.Transform:Find("PanelEffect") + self.ImgRe = self.Transform:Find("ImgRe"):GetComponent("Image") + self.GridCommon = self.Transform:Find("Grid128") +end + +function XUiPanelNewbieActive:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelNewbieActive:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelNewbieActive:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelNewbieActive:AutoAddListener() + self:RegisterClickEvent(self.BtnActive, self.OnBtnActiveClick) +end +-- auto + +function XUiPanelNewbieActive:UpdateNewbieActiveView(currentActiveness, maxActiveness) + self.CurrentActiveness = currentActiveness + self.MaxActiveness = maxActiveness + local newbieActiveness = XTaskConfig.GetTaskNewbieActivenessTemplate() + local rewardId = newbieActiveness.RewardId[self.Index or 1] + local count = #newbieActiveness.RewardId + local data = XRewardManager.GetRewardList(rewardId) + + if #data >= 1 then + if not self.GridComp then + self.GridComp = XUiGridCommon.New(self.RootUi, self.GridCommon) + end + self.GridComp:Refresh(data[1]) + self.GridComp:ShowCount(false) + end + local adjustSizeX = (self.Index == count) and specialSize or normalSize + self.ImgActiveRect.sizeDelta = CS.UnityEngine.Vector2(adjustSizeX, adjustSizeX) + + local tmpNewbieActiveness = XTaskConfig.GetTaskNewbieActivenessTemplate() + local activeness = tmpNewbieActiveness.Activeness[self.Index or 1] + + if XDataCenter.TaskManager.CheckNewbieActivenessRecord(activeness) then + self:ChangeActiveState(true, false) + else + if currentActiveness >= activeness then + self:ChangeActiveState(false, true) + else + self:ChangeActiveState(false, false) + end + end +end + +function XUiPanelNewbieActive:ChangeActiveState(imgRe, effect) + self.ImgRe.gameObject:SetActive(imgRe) + self.PanelEffect.gameObject:SetActive(effect) +end + +function XUiPanelNewbieActive:OnBtnActiveClick() + if self.CurrentActiveness and self.MaxActiveness then + local newbieActiveness = XTaskConfig.GetTaskNewbieActivenessTemplate() + local activeness = newbieActiveness.Activeness[self.Index or 1] + local templateId = newbieActiveness.RewardId[self.Index or 1] + local rewardList = XRewardManager.GetRewardList(templateId) + + if XDataCenter.TaskManager.CheckNewbieActivenessRecord(activeness) then--已经领取 + self:ShowTipsByType(rewardList) + else + if self.CurrentActiveness >= activeness then--可领取 + XDataCenter.TaskManager.GetNewPlayerRewardReq(activeness, rewardList, function() + self.RootUi:RefreshBottomView() + end) + else--还不能领取 + self:ShowTipsByType(rewardList) + end + end + end + +end + +function XUiPanelNewbieActive:ShowTipsByType(rewardList) + for _, v in pairs(rewardList or {}) do + local templateId = v.TemplateId + local goodsShowParams = XGoodsCommonManager.GetGoodsShowParamsByTemplateId(templateId) + if goodsShowParams.RewardType == XRewardManager.XRewardType.Character then + if self.RootUi.Ui.UiData.UiType == CsXUiType.Tips then + self.RootUi:Close() + end + XLuaUiManager.Open("UiCharacterDetail", templateId) + elseif goodsShowParams.RewardType == XRewardManager.XRewardType.Equip then + if self.RootUi.Ui.UiData.UiType == CsXUiType.Tips then + self.RootUi:Close() + end + XLuaUiManager.Open("UiEquipDetail", templateId, true) + else + XLuaUiManager.Open("UiTip", templateId) + end + break + end + +end + +return XUiPanelNewbieActive \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNewPlayerTask/XUiPanelTaskItem.lua b/Resources/Scripts/XUi/XUiNewPlayerTask/XUiPanelTaskItem.lua new file mode 100644 index 00000000..f3accf59 --- /dev/null +++ b/Resources/Scripts/XUi/XUiNewPlayerTask/XUiPanelTaskItem.lua @@ -0,0 +1,104 @@ +XUiPanelTaskItem = XClass(nil, "XUiPanelTaskItem") + +function XUiPanelTaskItem:Ctor(ui, index, funcCallback) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self:InitAutoScript() + self.TaskId = 0 + self.Index = index + self.Selected = false + self.FunctionCallBack = funcCallback +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelTaskItem:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiPanelTaskItem:AutoInitUi() + self.BtnClick = self.Transform:Find("BtnClick"):GetComponent("Button") + self.ImgNormal = self.Transform:Find("ImgNormal").gameObject + self.ImgCompleted = self.Transform:Find("ImgCompleted").gameObject + self.ImgSelected = self.Transform:Find("ImgSelected").gameObject + self.TxtTitle = self.Transform:Find("TxtTitle"):GetComponent("Text") + self.ImgRedPoint = self.Transform:Find("ImgRedPoint").gameObject +end + +function XUiPanelTaskItem:GetAutoKey(uiNode, eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiPanelTaskItem:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiPanelTaskItem:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiPanelTaskItem:AutoAddListener() + self.AutoCreateListeners = {} + XUiHelper.RegisterClickEvent(self, self.BtnClick, self.OnBtnClickClick) +end +-- auto +function XUiPanelTaskItem:OnBtnClickClick() + self.FunctionCallBack(self.Index) +end + +function XUiPanelTaskItem:SetSelect(bValue) + self.Selected = bValue + self:UpdateTitle() + self:UpdateView() +end + +function XUiPanelTaskItem:UpdateTaskState() + self.State = XDataCenter.TaskManager.GetTaskDataById(self.TaskId).State +end + +function XUiPanelTaskItem:SetData(taskId) + self.TaskId = taskId + self.GameObject.name = "XUiPanelTaskItem" .. taskId + + self:UpdateTitle() + self:UpdateTaskState() + self:UpdateView() +end + +function XUiPanelTaskItem:UpdateTitle() + local title = XDataCenter.TaskManager.GetTaskTemplate(self.TaskId).Title + if self.Selected then + self.TxtTitle.text = "" .. title .. "" + else + self.TxtTitle.text = "" .. title .. "" + end +end + +function XUiPanelTaskItem:UpdateView() + self.ImgSelected:SetActive(self.Selected) + self.ImgNormal:SetActive(not self.Selected and self.State < XDataCenter.TaskManager.TaskState.Finish) + self.ImgCompleted:SetActive(not self.Selected and self.State == XDataCenter.TaskManager.TaskState.Finish) + self.ImgRedPoint:SetActive(self.State == XDataCenter.TaskManager.TaskState.Achieved) +end + +function XUiPanelTaskItem:SetActive(bValue) + self.GameObject:SetActive(bValue) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNewRoleShow/XUiNewRoleShow.lua b/Resources/Scripts/XUi/XUiNewRoleShow/XUiNewRoleShow.lua new file mode 100644 index 00000000..a11588ae --- /dev/null +++ b/Resources/Scripts/XUi/XUiNewRoleShow/XUiNewRoleShow.lua @@ -0,0 +1,235 @@ +local XUiNewRoleShow = XLuaUiManager.Register(XLuaUi, "UiNewRoleShow") + +function XUiNewRoleShow:OnAwake() + self:InitAutoScript() +end + +function XUiNewRoleShow:OnStart(RoleId, closecallback, openCallback) + self.RoleConfig = nil + self.CanClick = false + self.CloseCallback = nil + + self.CanClick = false + self.CloseCallback = closecallback + self.RoleConfig = XNewRoleShowManager.GetNewRoleShowTemplate(RoleId) + if openCallback then + openCallback() + end + self:PlayAnimations() +end + +function XUiNewRoleShow:OnDestroy() + XUiHelper.StopAnimation() + self.RoleConfig = nil + if self.CloseCallback then + self.CloseCallback() + end + self.CloseCallback = nil +end + +function XUiNewRoleShow:PlayAnimations() + self.PanelLoading.gameObject:SetActive(true) + self.PanelRoleDetail.gameObject:SetActive(false) + self.PanelEffect.gameObject:SetActive(false) + self.PanelCenter.gameObject:SetActive(false) + self.PanelLU.gameObject:SetActive(false) + self.PanelRU.gameObject:SetActive(false) + self.PanelLD.gameObject:SetActive(false) + self.PanelRD.gameObject:SetActive(false) + self:PlayBegan() + self:PlayName() + self:PlayDetail() + self:PlayLu() + self:PlayRd() + self:PlayLd() + self:PlayRu() +end + +function XUiNewRoleShow:PlayBegan() + -- local onStart = function() + -- self.PanelLoading.gameObject:SetActive(false) + -- self.PanelRoleDetail.gameObject:SetActive(true) + -- end + -- local onFinish = function() + -- self.PanelEffect.gameObject:SetActive(true) + -- end + --XUiHelper.PlayAnimation(self, "Began", onStart, onFinish) +end + +function XUiNewRoleShow:PlayDetail() + -- local onStart = function() + -- self.PanelLoading.gameObject:SetActive(false) + -- self.PanelRoleDetail.gameObject:SetActive(true) + -- end + -- local onFinish = function() + -- self.PanelEffect.gameObject:SetActive(true) + -- end + --XUiHelper.PlayAnimation(self, "Detail", onStart, onFinish) +end + +function XUiNewRoleShow:PlayName() + -- local onStart = function() + -- self.PanelCenter.gameObject:SetActive(true) + -- self.TxtRace.text = "" + -- end + -- local onFinish = function() + -- XUiHelper.ShowCharByTypeAnimation(self.TxtRace, self.RoleConfig.Name, 100) + -- end + --XUiHelper.PlayAnimation(self, "Name", onStart, onFinish) +end + +function XUiNewRoleShow:PlayLu() + -- local onStart = function() + -- self.PanelLU.gameObject:SetActive(true) + -- self.TxtHeight.text = "0cm" + -- self.TxtWeight.text = "0kg" + -- end + -- local onFinish = function() + -- XUiHelper.Tween(0.5, function(f) + -- if XTool.UObjIsNil(self.TxtHeight) then + -- return + -- end + + -- if self.TxtHeight and self.RoleConfig then + -- self.TxtHeight.text = math.floor(f * self.RoleConfig.Height) .. "cm" + -- self.TxtWeight.text = math.floor(f * self.RoleConfig.Weight) .. "kg" + -- else + -- return true + -- end + -- end) + -- --XUiHelper.ShowCharByTypeAnimation(self.TxtBWH,self.RoleConfig.BWH,100) + -- end + --XUiHelper.PlayAnimation(self, "Lu", onStart, onFinish) +end + +function XUiNewRoleShow:PlayRu() + -- local onStart = function() + -- self.PanelRU.gameObject:SetActive(true) + -- self.ImgIQ.fillAmount = 0 + -- self.ImgEQ.fillAmount = 0 + -- self.ImgPhysical.fillAmount = 0 + -- self.ImgTactics.fillAmount = 0 + -- self.ImgLeaderShip.fillAmount = 0 + -- end + -- local onFinish = function() + -- XUiHelper.Tween( + -- 0.5, + -- function(f) + -- if self.RoleConfig then + -- local mul = f * 0.01 + -- self.ImgIQ.fillAmount = self.RoleConfig.IQ * mul + -- self.ImgEQ.fillAmount = self.RoleConfig.EQ * mul + -- self.ImgPhysical.fillAmount = self.RoleConfig.Physical * mul + -- self.ImgTactics.fillAmount = self.RoleConfig.Tactics * mul + -- self.ImgLeaderShip.fillAmount = self.RoleConfig.LeaderShip * mul + -- else + -- return true + -- end + -- end + -- ) + -- end + --XUiHelper.PlayAnimation(self, "Ru", onStart, onFinish) +end + +function XUiNewRoleShow:PlayLd() + -- local onStart = function() + -- self.PanelLD.gameObject:SetActive(true) + -- self.TxtAwareness.text = "" + -- self.TxtActionStandard.text = "" + -- end + -- local onFinish = function() + -- XUiHelper.ShowCharByTypeAnimation(self.TxtAwareness, self.RoleConfig.Awareness, 100) + -- XUiHelper.ShowCharByTypeAnimation(self.TxtActionStandard, self.RoleConfig.ActionStandard, 100) + -- end + --XUiHelper.PlayAnimation(self, "Ld", onStart, onFinish) +end + +function XUiNewRoleShow:PlayRd() + -- local onStart = function() + -- self.PanelRD.gameObject:SetActive(true) + -- self.TxtCarryDevice.text = "" + -- end + -- local onFinish = function() + -- XUiHelper.ShowCharByTypeAnimation(self.TxtCarryDevice, self.RoleConfig.CarrayDevice, 100, nil, function() + -- self.CanClick = true + -- end) + -- end + --XUiHelper.PlayAnimation(self, "Rd", onStart, onFinish) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiNewRoleShow:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiNewRoleShow:AutoInitUi() + self.PanelRoleDetail = self.Transform:Find("SafeAreaContentPane/PanelRoleDetail") + self.ImgRole = self.Transform:Find("SafeAreaContentPane/PanelRoleDetail/ImgRole"):GetComponent("Image") + self.PanelEffect = self.Transform:Find("SafeAreaContentPane/PanelRoleDetail/PanelEffect") + self.PanelLU = self.Transform:Find("SafeAreaContentPane/PanelRoleDetail/PanelLU") + self.TxtHeight = self.Transform:Find("SafeAreaContentPane/PanelRoleDetail/PanelLU/TxtHeight"):GetComponent("Text") + self.TxtWeight = self.Transform:Find("SafeAreaContentPane/PanelRoleDetail/PanelLU/TxtWeight"):GetComponent("Text") + self.TxtBWH = self.Transform:Find("SafeAreaContentPane/PanelRoleDetail/PanelLU/TxtBWH"):GetComponent("Text") + self.PanelLD = self.Transform:Find("SafeAreaContentPane/PanelRoleDetail/PanelLD") + self.TxtAwareness = self.Transform:Find("SafeAreaContentPane/PanelRoleDetail/PanelLD/TxtAwareness"):GetComponent("Text") + self.TxtActionStandard = self.Transform:Find("SafeAreaContentPane/PanelRoleDetail/PanelLD/TxtActionStandard"):GetComponent("Text") + self.PanelRU = self.Transform:Find("SafeAreaContentPane/PanelRoleDetail/PanelRU") + self.ImgIQ = self.Transform:Find("SafeAreaContentPane/PanelRoleDetail/PanelRU/ImgIQ"):GetComponent("Image") + self.ImgEQ = self.Transform:Find("SafeAreaContentPane/PanelRoleDetail/PanelRU/ImgEQ"):GetComponent("Image") + self.ImgPhysical = self.Transform:Find("SafeAreaContentPane/PanelRoleDetail/PanelRU/ImgPhysical"):GetComponent("Image") + self.ImgTactics = self.Transform:Find("SafeAreaContentPane/PanelRoleDetail/PanelRU/ImgTactics"):GetComponent("Image") + self.ImgLeaderShip = self.Transform:Find("SafeAreaContentPane/PanelRoleDetail/PanelRU/ImgLeaderShip"):GetComponent("Image") + self.PanelRD = self.Transform:Find("SafeAreaContentPane/PanelRoleDetail/PanelRD") + self.TxtCarryDevice = self.Transform:Find("SafeAreaContentPane/PanelRoleDetail/PanelRD/TxtCarryDevice"):GetComponent("Text") + self.PanelCenter = self.Transform:Find("SafeAreaContentPane/PanelRoleDetail/PanelCenter") + self.TxtRace = self.Transform:Find("SafeAreaContentPane/PanelRoleDetail/PanelCenter/TxtRace"):GetComponent("Text") + self.BtnClick = self.Transform:Find("SafeAreaContentPane/PanelRoleDetail/BtnClick"):GetComponent("Button") + self.PanelLoading = self.Transform:Find("SafeAreaContentPane/PanelLoading") +end + +function XUiNewRoleShow:GetAutoKey(uiNode, eventName) + if not uiNode then + return + end + return eventName .. uiNode:GetHashCode() +end + +function XUiNewRoleShow:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then + return + end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiNewRoleShow:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiNewRoleShow:AutoAddListener() + self.AutoCreateListeners = {} + self:RegisterClickEvent(self.BtnClick, self.OnBtnClickClick) +end +-- auto + +function XUiNewRoleShow:OnBtnClickClick() + if self.CanClick then + self:Close() + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNewRoomSingle/XUiBattleRoleRoom.lua b/Resources/Scripts/XUi/XUiNewRoomSingle/XUiBattleRoleRoom.lua new file mode 100644 index 00000000..78a2f5c5 --- /dev/null +++ b/Resources/Scripts/XUi/XUiNewRoomSingle/XUiBattleRoleRoom.lua @@ -0,0 +1,425 @@ +local CsXTextManager = CS.XTextManager +local XUiBattleRoleRoomDefaultProxy = require("XUi/XUiNewRoomSingle/XUiBattleRoleRoomDefaultProxy") +local XUiBattleRoleRoom = XLuaUiManager.Register(XLuaUi, "UiBattleRoleRoom") +local MAX_ROLE_COUNT = 3 +local LONG_TIMER = 1 + +function XUiBattleRoleRoom:OnAwake() + -- 重定义 begin + self.FirstEnterBtnGroup = self.PanelTabCaptain + self.PanelFirstEnterTag1 = self.PanelFirstRole1 + self.PanelFirstEnterTag2 = self.PanelFirstRole2 + self.PanelFirstEnterTag3 = self.PanelFirstRole3 + self.UiObjPartner1 = self.CharacterPets1 + self.UiObjPartner2 = self.CharacterPets2 + self.UiObjPartner3 = self.CharacterPets3 + self.UiPointerCharacter1 = self.BtnChar1:GetComponent("XUiPointer") + self.UiPointerCharacter2 = self.BtnChar2:GetComponent("XUiPointer") + self.UiPointerCharacter3 = self.BtnChar3:GetComponent("XUiPointer") + -- 重定义 end + -- XTeam + self.Team = nil + self.StageId = nil + self.Proxy = nil + self.UiPanelRoleModels = nil + self.LongClickTime = 0 + self.Camera = nil + self.ChildPanelData = nil + self:InitUiPanelRoleModels() + self:RegisterUiEvents() +end + +-- team : XTeam +function XUiBattleRoleRoom:OnStart(team, stageId, proxy) + self.Camera = self.Transform:GetComponent("Canvas").worldCamera + if proxy == nil then proxy = XUiBattleRoleRoomDefaultProxy end + self.Team = team + self.StageId = stageId + self.Proxy = proxy.New() + local isStop = self.Proxy:AOPOnStartBefore(self) + if isStop then return end + -- 关卡名字刷新 + self:RefreshStageName() + self.BtnShowInfoToggle:SetButtonState(self.Team:GetIsShowRoleDetailInfo() + and XUiButtonState.Select or XUiButtonState.Normal) + -- 注册自动关闭 + local openAutoClose, autoCloseEndTime, callback = self.Proxy:GetAutoCloseInfo() + if openAutoClose then + self:SetAutoCloseInfo(autoCloseEndTime, callback) + end + self.Proxy:AOPOnStartAfter(self) +end + +function XUiBattleRoleRoom:OnEnable() + XUiBattleRoleRoom.Super.OnEnable(self) + -- 刷新角色模型 + self:RefreshRoleModels() + -- 刷新角色特效 + self:RefreshRoleEffects() + -- 刷新伙伴 + self:RefreshPartners() + -- 刷新队长信息 + self:RefreshCaptainPosInfo() + -- 设置首出信息 + self.FirstEnterBtnGroup:SelectIndex(self.Team:GetFirstFightPos()) + -- 刷新角色详细信息 + self:RefreshRoleDetalInfo() + -- 角色限制提示 + self:RefreshRoleLimitTip() + -- 设置子面板配置 + self.ChildPanelData = self.Proxy:GetChildPanelData() + self:LoadChildPanelInfo() + self:RegisterListeners() +end + +function XUiBattleRoleRoom:OnDisable() + XUiBattleRoleRoom.Super.OnDisable(self) +end + +function XUiBattleRoleRoom:OnDestory() + self:UnRegisterListeners() +end + +--######################## 私有方法 ######################## + +function XUiBattleRoleRoom:RegisterUiEvents() + self.BtnBack.CallBack = function() self:Close() end + self.BtnMainUi.CallBack = function() XLuaUiManager.RunMain() end + self.BtnEnterFight.CallBack = function() self:OnBtnEnterFightClicked() end + self.BtnShowInfoToggle.CallBack = function(val) self:OnBtnShowInfoToggleClicked(val) end + self.BtnLeader.CallBack = function() self:OnBtnLeaderClicked() end + -- 首出按钮组 + local firstTabGroup = { self.BtnRed, self.BtnBlue, self.BtnYellow } + self.FirstEnterBtnGroup:Init(firstTabGroup, function(tabIndex) self:OnEnterSortBtnGroupClicked(tabIndex) end) + -- 角色拖动相关 + XUiButtonLongClick.New(self.UiPointerCharacter1, 10, self, nil, self.OnBtnCharacter1LongClicked, self.OnBtnCharacter1LongClickUp, false) + XUiButtonLongClick.New(self.UiPointerCharacter2, 10, self, nil, self.OnBtnCharacter2LongClicked, self.OnBtnCharacter2LongClickUp, false) + XUiButtonLongClick.New(self.UiPointerCharacter3, 10, self, nil, self.OnBtnCharacter3LongClicked, self.OnBtnCharacter3LongClickUp, false) + -- 角色点击 + self:RegisterClickEvent(self.BtnChar1, self.OnBtnChar1Clicked) + self:RegisterClickEvent(self.BtnChar2, self.OnBtnChar2Clicked) + self:RegisterClickEvent(self.BtnChar3, self.OnBtnChar3Clicked) + self.BtnTeamPrefab.CallBack = function() self:OnBtnTeamPrefabClicked() end + -- 宠物加号点击 + local uiObjPartner + for pos = 1, MAX_ROLE_COUNT do + uiObjPartner = self["UiObjPartner" .. pos] + uiObjPartner:GetObject("BtnClick").CallBack = function() + self[string.format("OnBtnChar%sClicked", pos)](self) + end + end +end + +function XUiBattleRoleRoom:RegisterListeners() + XEventManager.AddEventListener(XEventId.EVENT_FIGHT_BEGIN_PLAYMOVIE, self.OnBeginBattleAutoRemove, self) + XEventManager.AddEventListener(XEventId.EVENT_FIGHT_LOADINGFINISHED, self.OnBeginBattleAutoRemove, self) + XEventManager.AddEventListener(XEventId.EVENT_TEAM_PREFAB_SELECT, self.OnTeamPrefabSelect, self) +end + +function XUiBattleRoleRoom:UnRegisterListeners() + XEventManager.RemoveEventListener(XEventId.EVENT_FIGHT_BEGIN_PLAYMOVIE, self.OnBeginBattleAutoRemove, self) + XEventManager.RemoveEventListener(XEventId.EVENT_FIGHT_LOADINGFINISHED, self.OnBeginBattleAutoRemove, self) + -- XEventManager.RemoveEventListener(XEventId.EVENT_TEAM_PREFAB_SELECT, self.OnTeamPrefabSelect, self) +end + +function XUiBattleRoleRoom:OnBtnTeamPrefabClicked() + XLuaUiManager.Open("UiRoomTeamPrefab", self.Team:GetCaptainPos() + , self.Team:GetFirstFightPos() + , self.Team:GetCharacterLimitType()) +end + +function XUiBattleRoleRoom:OnTeamPrefabSelect(teamData) + self.Team:UpdateFromTeamData(teamData) +end + +function XUiBattleRoleRoom:OnBeginBattleAutoRemove() + self:Remove() +end + +function XUiBattleRoleRoom:OnBtnLeaderClicked() + local characterViewModelDic = {} + local viewModel = nil + for pos, entityId in ipairs(self.Team:GetEntityIds()) do + characterViewModelDic[pos] = self.Proxy:GetCharacterViewModelByEntityId(entityId) + end + XLuaUiManager.Open("UiBattleRoleRoomCaptain", characterViewModelDic, self.Team:GetCaptainPos(), function(newCaptainPos) + self.Team:UpdateCaptianPos(newCaptainPos) + self:RefreshCaptainPosInfo() + end) +end + +-- val : 1 or 0 , 1是开启,0是关闭 +function XUiBattleRoleRoom:OnBtnShowInfoToggleClicked(val) + self.Team:SaveIsShowRoleDetailInfo(val) + self:RefreshRoleDetalInfo(val == 1) +end + +function XUiBattleRoleRoom:OnBtnChar1Clicked() + self:OnBtnCharacterClicked(1) +end + +function XUiBattleRoleRoom:OnBtnChar2Clicked() + self:OnBtnCharacterClicked(2) +end + +function XUiBattleRoleRoom:OnBtnChar3Clicked() + self:OnBtnCharacterClicked(3) +end + +function XUiBattleRoleRoom:OnBtnCharacter1LongClicked(time) + self:OnBtnCharacterLongClick(1, time) +end + +function XUiBattleRoleRoom:OnBtnCharacter2LongClicked(time) + self:OnBtnCharacterLongClick(2, time) +end + +function XUiBattleRoleRoom:OnBtnCharacter3LongClicked(time) + self:OnBtnCharacterLongClick(3, time) +end + +function XUiBattleRoleRoom:OnBtnCharacter1LongClickUp() + self:OnBtnCharacterLongClickUp(1) +end + +function XUiBattleRoleRoom:OnBtnCharacter2LongClickUp() + self:OnBtnCharacterLongClickUp(2) +end + +function XUiBattleRoleRoom:OnBtnCharacter3LongClickUp() + self:OnBtnCharacterLongClickUp(3) +end + +function XUiBattleRoleRoom:OnBtnCharacterLongClick(index, time) + -- 无实体直接不处理 + if self.Team:GetEntityIdByTeamPos(index) == 0 then return end + self.LongClickTime = self.LongClickTime + time / 1000 + if self.LongClickTime > LONG_TIMER then + self.ImgRoleRepace.gameObject:SetActiveEx(true) + self.ImgRoleRepace.transform.localPosition = self:GetClickPosition() + end +end + +function XUiBattleRoleRoom:OnBtnCharacterLongClickUp(index) + -- 未激活不处理 + if not self.ImgRoleRepace.gameObject.activeSelf then return end + self.LongClickTime = 0 + self.ImgRoleRepace.gameObject:SetActiveEx(false) + local transformWidth = self.Transform.rect.width + local targetX = math.floor(self:GetClickPosition().x + transformWidth / 2) + local targetIndex + if targetX <= transformWidth / 3 then + targetIndex = 2 + elseif targetX > transformWidth / 3 and targetX <= transformWidth / 3 * 2 then + targetIndex = 1 + else + targetIndex = 3 + end + -- 相同直接不处理 + if index == targetIndex then return end + self.Team:SwitchEntityPos(index, targetIndex) + -- 刷新角色信息 + self:RefreshRoleInfos() + self:LoadChildPanelInfo() + self:RefreshPartners() + self:RefreshRoleDetalInfo() +end + +function XUiBattleRoleRoom:OnBtnCharacterClicked(index) + XLuaUiManager.Open("UiBattleRoomRoleDetail" + , self.StageId + , self.Team + , index + , self.Proxy:GetRoleDetailProxy(), self.StageId) +end + +function XUiBattleRoleRoom:OnBtnEnterFightClicked() + local canEnterFight, errorTip = self.Proxy:GetIsCanEnterFight(self.Team) + if not canEnterFight then + XUiManager.TipError(errorTip) + return + end + self.Proxy:EnterFight(self.Team, self.StageId) +end + +function XUiBattleRoleRoom:OnEnterSortBtnGroupClicked(index) + self.Team:UpdateFirstFightPos(index) + self:RefreshFirstFightInfo() +end + +function XUiBattleRoleRoom:InitUiPanelRoleModels() + local uiModelRoot = self.UiModelGo.transform + self.UiPanelRoleModels = {} + for i = 1, MAX_ROLE_COUNT do + self.UiPanelRoleModels[i] = XUiPanelRoleModel.New(uiModelRoot:FindTransform("PanelRoleModel" .. i) + , self.Name, nil, true, nil, true, true) + end +end + +function XUiBattleRoleRoom:RefreshRoleModels() + local characterViewModel + local entityId + local sourceEntityId + local uiPanelRoleModel + -- local finishedCallback = function() + + -- end + for pos = 1, MAX_ROLE_COUNT do + uiPanelRoleModel = self.UiPanelRoleModels[pos] + entityId = self.Team:GetEntityIdByTeamPos(pos) + characterViewModel = self.Proxy:GetCharacterViewModelByEntityId(entityId) + self["ImgAdd" .. pos].gameObject:SetActiveEx(characterViewModel == nil) + if characterViewModel then + sourceEntityId = characterViewModel:GetSourceEntityId() + if XRobotManager.CheckIsRobotId(sourceEntityId) then + local robotConfig = XRobotManager.GetRobotTemplate(sourceEntityId) + uiPanelRoleModel:UpdateRobotModel(sourceEntityId, robotConfig.CharacterId + , nil, robotConfig.FashionId, robotConfig.WeaponId) + else + uiPanelRoleModel:UpdateCharacterModel(sourceEntityId, nil, nil, nil, nil, characterViewModel:GetFashionId()) + end + uiPanelRoleModel:ShowRoleModel() + else + uiPanelRoleModel:HideRoleModel() + end + end +end + +function XUiBattleRoleRoom:RefreshPartners() + local entityId = 0 + local partner = nil + local characterViewModel = nil + local uiObjPartner + local rImgParnetIcon = nil + for pos = 1, MAX_ROLE_COUNT do + entityId = self.Team:GetEntityIdByTeamPos(pos) + partner = self.Proxy:GetPartnerByEntityId(entityId) + characterViewModel = self.Proxy:GetCharacterViewModelByEntityId(entityId) + uiObjPartner = self["UiObjPartner" .. pos] + uiObjPartner.gameObject:SetActiveEx(characterViewModel ~= nil) + rImgParnetIcon = uiObjPartner:GetObject("RImgType") + rImgParnetIcon.gameObject:SetActiveEx(partner ~= nil) + if partner then + rImgParnetIcon:SetRawImage(partner:GetIcon()) + end + end +end + +function XUiBattleRoleRoom:RefreshRoleEffects() + local uiModelRoot = self.UiModelGo.transform + local panelRoleBGEffectGo + local teamConfig + local isLoadRoleBGEffect = self.Proxy:GetIsShowRoleBGEffect() + for i = 1, MAX_ROLE_COUNT do + -- 加载背景特效 + if isLoadRoleBGEffect then + teamConfig = XTeamConfig.GetTeamCfgById(i) + panelRoleBGEffectGo = uiModelRoot:FindTransform("PanelRoleEffect" .. i).gameObject + panelRoleBGEffectGo:LoadPrefab(teamConfig.EffectPath, false) + end + end +end + +function XUiBattleRoleRoom:RefreshFirstFightInfo() + for i = 1, MAX_ROLE_COUNT do + self["PanelFirstEnterTag" .. i].gameObject:SetActiveEx(self.Team:GetFirstFightPos() == i) + end +end + +function XUiBattleRoleRoom:RefreshCaptainPosInfo() + local captainPos = self.Team:GetCaptainPos() + local entityId = self.Team:GetEntityIdByTeamPos(captainPos) + local characterViewModel = self.Proxy:GetCharacterViewModelByEntityId(entityId) + self.RImgCapIcon.gameObject:SetActiveEx(characterViewModel ~= nil) + self.TxtSkillDesc.gameObject:SetActiveEx(characterViewModel ~= nil) + if characterViewModel then + local captainSkillInfo = characterViewModel:GetCaptainSkillInfo() + self.RImgCapIcon:SetRawImage(characterViewModel:GetSmallHeadIcon()) + self.TxtSkillName.text = captainSkillInfo.Name + self.TxtSkillDesc.text = captainSkillInfo.Level > 0 and + captainSkillInfo.Intro or CsXTextManager.GetText("CaptainSkillLock") + else + self.TxtSkillName.text = CsXTextManager.GetText("TeamDoNotChooseCaptain") + end +end + +function XUiBattleRoleRoom:RefreshRoleInfos() + -- 刷新角色模型 + self:RefreshRoleModels() + -- 刷新角色特效 + self:RefreshRoleEffects() + -- 刷新伙伴 + self:RefreshPartners() + -- 刷新队长信息 + self:RefreshCaptainPosInfo() +end + +function XUiBattleRoleRoom:LoadChildPanelInfo() + if not self.ChildPanelData then return end + local childPanelData = self.ChildPanelData + -- 加载panel asset + local instanceGo = childPanelData.instanceGo + if XTool.UObjIsNil(instanceGo) then + instanceGo = self.PanelExtraUiInfo:LoadPrefab(childPanelData.assetPath) + childPanelData.instanceGo = instanceGo + -- 加载panel proxy + childPanelData.instanceProxy = childPanelData.proxy.New(instanceGo) + end + -- 加载proxy参数 + local proxyArgs = {} + if childPanelData.proxyArgs then + for _, argName in ipairs(childPanelData.proxyArgs) do + if type(argName) == "string" then + proxyArgs[#proxyArgs + 1] = self[argName] + else + proxyArgs[#proxyArgs + 1] = argName + end + end + end + childPanelData.instanceProxy:SetData(table.unpack(proxyArgs)) +end + +function XUiBattleRoleRoom:RefreshRoleLimitTip() + -- XFubenConfigs.CharacterLimitType + local limitType = XFubenConfigs.GetStageCharacterLimitType(self.StageId) + local isShow = XFubenConfigs.IsStageCharacterLimitConfigExist(limitType) + self.PanelCharacterLimit.gameObject:SetActiveEx(isShow) + if not isShow then return end + -- 图标 + self.ImgCharacterLimit:SetSprite(XFubenConfigs.GetStageCharacterLimitImageTeamEdit(limitType)) + -- 文案 + local limitBuffId = XFubenConfigs.GetStageCharacterLimitBuffId(self.StageId) + self.TxtCharacterLimit.text = XFubenConfigs.GetStageCharacterLimitTextTeamEdit(limitType + , self.Team:GetCharacterType(), limitBuffId) +end + +function XUiBattleRoleRoom:RefreshStageName() + local chapterName, stageName = XDataCenter.FubenManager.GetFubenNames(self.StageId) + self.TxtChapterName.text = chapterName + self.TxtStageName.text = stageName +end + +function XUiBattleRoleRoom:RefreshRoleDetalInfo(isShow) + if isShow == nil then isShow = self.Team:GetIsShowRoleDetailInfo() end + local entityId + local characterViewModel + for pos = 1, 3 do + self["CharacterInfo" .. pos].gameObject:SetActiveEx(isShow) + if isShow then + entityId = self.Team:GetEntityIdByTeamPos(pos) + characterViewModel = self.Proxy:GetCharacterViewModelByEntityId(entityId) + if characterViewModel then + self["TxtFight" .. pos].text = self.Proxy:GetRoleAbility(entityId) + self["RImgType" .. pos]:SetRawImage(characterViewModel:GetProfessionIcon()) + else + self["CharacterInfo" .. pos].gameObject:SetActiveEx(false) + end + end + end +end + +function XUiBattleRoleRoom:GetClickPosition() + return XUiHelper.GetScreenClickPosition(self.Transform, self.Camera) +end + +return XUiBattleRoleRoom \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNewRoomSingle/XUiBattleRoleRoomCaptain.lua b/Resources/Scripts/XUi/XUiNewRoomSingle/XUiBattleRoleRoomCaptain.lua new file mode 100644 index 00000000..ed9d5535 --- /dev/null +++ b/Resources/Scripts/XUi/XUiNewRoomSingle/XUiBattleRoleRoomCaptain.lua @@ -0,0 +1,94 @@ +local XUiBattleRoleRoomCaptain = XLuaUiManager.Register(XLuaUi, "UiBattleRoleRoomCaptain") + +function XUiBattleRoleRoomCaptain:OnAwake() + -- 重定义 begin + self.RImgIcon1 = self.RawImage01 + self.RImgIcon2 = self.RawImage02 + self.RImgIcon3 = self.RawImage03 + self.TxtName1 = self.TextName01 + self.TxtName2 = self.TextName02 + self.TxtName3 = self.TextName03 + self.TxtSkillName1 = self.TextJinengName01 + self.TxtSkillName2 = self.TextJinengName02 + self.TxtSkillName3 = self.TextJinengName03 + self.TxtSkillDesc1 = self.TextJinengInfo01 + self.TxtSkillDesc2 = self.TextJinengInfo02 + self.TxtSkillDesc3 = self.TextJinengInfo03 + self.CaptainBtnGroup = self.PanelBtnSel + self.BtnSelect1 = self.BtnSel01 + self.BtnSelect2 = self.BtnSel02 + self.BtnSelect3 = self.BtnSel03 + self.PanelEnable1 = self.Ena01 + self.PanelEnable2 = self.Ena02 + self.PanelEnable3 = self.Ena03 + self.PanelDisable1 = self.Dis01 + self.PanelDisable2 = self.Dis02 + self.PanelDisable3 = self.Dis03 + -- 重定义 end + self.CharacterViewModelDic = nil + self.Callback = nil + -- 当前队长位置 + self.CurrentCaptainPos = nil + self:RegisterUiEvents() +end + +-- team : XTeam +function XUiBattleRoleRoomCaptain:OnStart(characterViewModelDic, currentCaptainPos, callback) + self.CharacterViewModelDic = characterViewModelDic + self.CurrentCaptainPos = currentCaptainPos + self.Callback = callback + -- 刷新数据 + self:RefreshRoleList() + self.CaptainBtnGroup:SelectIndex(currentCaptainPos) +end + +--######################## 私有方法 ######################## + +function XUiBattleRoleRoomCaptain:RegisterUiEvents() + self.BtnTanchuangCloseBig.CallBack = function() self:OnCloseClicked() end + self.CaptainBtnGroup:Init({ + self.BtnSelect1, + self.BtnSelect2, + self.BtnSelect3, + }, function(tabIndex) + self:OnCaptainBtnGroupClicked(tabIndex) + end) +end + +function XUiBattleRoleRoomCaptain:OnCaptainBtnGroupClicked(index) + -- 禁用中,不处理 + if self["BtnSelect" .. index].ButtonState == CS.UiButtonState.Disable then + return + end + self.CurrentCaptainPos = index +end + +function XUiBattleRoleRoomCaptain:OnCloseClicked() + if self.Callback then self.Callback(self.CurrentCaptainPos) end + self:Close() +end + +function XUiBattleRoleRoomCaptain:RefreshRoleList() + local viewModel = nil + local captainSkillInfo = nil + for pos = 1, 3 do + viewModel = self.CharacterViewModelDic[pos] + if viewModel then + captainSkillInfo = viewModel:GetCaptainSkillInfo() + self["RImgIcon" .. pos]:SetRawImage(viewModel:GetSmallHeadIcon()) + self["TxtName" .. pos].text = viewModel:GetLogName() + self["TxtSkillName" .. pos].text = captainSkillInfo.Name + self["TxtSkillDesc" .. pos].text = captainSkillInfo.Level > 0 and + captainSkillInfo.Intro or CS.XTextManager.GetText("CaptainSkillLock") + self["PanelEnable" .. pos].gameObject:SetActiveEx(true) + self["PanelDisable" .. pos].gameObject:SetActiveEx(false) + self["BtnSelect" .. pos]:SetButtonState(CS.UiButtonState.Normal) + else + self["PanelEnable" .. pos].gameObject:SetActiveEx(false) + self["PanelDisable" .. pos].gameObject:SetActiveEx(true) + self["BtnSelect" .. pos]:SetButtonState(CS.UiButtonState.Disable) + end + end +end + +return XUiBattleRoleRoomCaptain \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNewRoomSingle/XUiBattleRoleRoomDefaultProxy.lua b/Resources/Scripts/XUi/XUiNewRoomSingle/XUiBattleRoleRoomDefaultProxy.lua new file mode 100644 index 00000000..b2ec265e --- /dev/null +++ b/Resources/Scripts/XUi/XUiNewRoomSingle/XUiBattleRoleRoomDefaultProxy.lua @@ -0,0 +1,68 @@ +local XUiBattleRoleRoomDefaultProxy = XClass(nil, "XUiBattleRoleRoomDefaultProxy") + +function XUiBattleRoleRoomDefaultProxy:GetCharacterViewModelByEntityId(id) + return nil +end + +function XUiBattleRoleRoomDefaultProxy:GetRoleAbility(entityId) + local viewModel = self:GetCharacterViewModelByEntityId(entityId) + if viewModel then + return viewModel:GetAbility() + end + return 0 +end + +function XUiBattleRoleRoomDefaultProxy:GetPartnerByEntityId(id) + return nil +end + +function XUiBattleRoleRoomDefaultProxy:GetIsShowRoleBGEffect() + return true +end + +function XUiBattleRoleRoomDefaultProxy:GetChildPanelData() + return nil +end + +function XUiBattleRoleRoomDefaultProxy:GetRoleDetailProxy() + return nil +end + +-- team : XTeam +function XUiBattleRoleRoomDefaultProxy:GetIsCanEnterFight(team) + -- 检查队长是否为空 + if team:GetCaptainPosEntityId() == 0 then + return false, CS.XTextManager.GetText("TeamManagerCheckCaptainNil") + end + -- 检查首发位置是否为空 + if team:GetFirstFightPosEntityId() == 0 then + return false, CS.XTextManager.GetText("TeamManagerCheckFirstFightNil") + end + return true +end + +-- team : XTeam +-- stageId : number +function XUiBattleRoleRoomDefaultProxy:EnterFight(team, stageId) + local stageConfig = XDataCenter.FubenManager.GetStageCfg(stageId) + local teamId = team:GetId() + local isAssist = false + local challengeCount = 1 + XDataCenter.FubenManager.EnterFight(stageConfig, teamId, isAssist, challengeCount) +end + +function XUiBattleRoleRoomDefaultProxy:GetAutoCloseInfo() + return false +end + +--######################## AOP ######################## + +function XUiBattleRoleRoomDefaultProxy:AOPOnStartBefore(rootUi) + +end + +function XUiBattleRoleRoomDefaultProxy:AOPOnStartAfter(rootUi) + +end + +return XUiBattleRoleRoomDefaultProxy \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNewRoomSingle/XUiBattleRoomRoleDetail.lua b/Resources/Scripts/XUi/XUiNewRoomSingle/XUiBattleRoomRoleDetail.lua new file mode 100644 index 00000000..dd99a8d0 --- /dev/null +++ b/Resources/Scripts/XUi/XUiNewRoomSingle/XUiBattleRoomRoleDetail.lua @@ -0,0 +1,306 @@ +local CsXTextManager = CS.XTextManager +local Vector2 = CS.UnityEngine.Vector2 +local XUiBattleRoomRoleGrid = require("XUi/XUiNewRoomSingle/XUiBattleRoomRoleGrid") +local XUiBattleRoomRoleDetailDefaultProxy = require("XUi/XUiNewRoomSingle/XUiBattleRoomRoleDetailDefaultProxy") +local XUiBattleRoomRoleDetail = XLuaUiManager.Register(XLuaUi, "UiBattleRoomRoleDetail") + +function XUiBattleRoomRoleDetail:OnAwake() + -- XTeam + self.Team = nil + self.StageId = nil + self.Pos = nil + self.CurrentEntityId = nil + self.CurrentCharacterType = XCharacterConfigs.CharacterType.Normal + self.ChildPanelData = nil + self.RoleDynamicGrid = self.GridCharacter + self.CurrentSelectTagGroup = { + [XCharacterConfigs.CharacterType.Normal] = {}, + [XCharacterConfigs.CharacterType.Isomer] = {}, + } + -- 角色列表 + self.DynamicTable = XDynamicTableNormal.New(self.SViewCharacterList) + self.DynamicTable:SetProxy(XUiBattleRoomRoleGrid) + self.DynamicTable:SetDelegate(self) + self:RegisterUiEvents() + self.BtnTabShougezhe:SetDisable(not XFunctionManager.JudgeOpen(XFunctionManager.FunctionName.Isomer)) + -- 模型初始化 + local panelRoleModel = self.UiModelGo.transform:FindTransform("PanelRoleModel") + self.ImgEffectHuanren = self.UiModelGo.transform:FindTransform("ImgEffectHuanren") + self.ImgEffectHuanren1 = self.UiModelGo.transform:FindTransform("ImgEffectHuanren1") + self.ImgEffectHuanren1.gameObject:SetActiveEx(false) + self.UiPanelRoleModel = XUiPanelRoleModel.New(panelRoleModel, self.Name, nil, true) + XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem + , XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) +end + +-- team : XTeam +function XUiBattleRoomRoleDetail:OnStart(stageId, team, pos, proxy) + if proxy == nil then proxy = XUiBattleRoomRoleDetailDefaultProxy end + self.StageId = stageId + self.Team = team + self.Pos = pos + self.Proxy = proxy.New() + local isStop = self.Proxy:AOPOnStartBefore(self) + if isStop then return end + self.CurrentEntityId = self.Team:GetEntityIdByTeamPos(self.Pos) + local gridProxy = self.Proxy:GetGridProxy() or XUiBattleRoomRoleGrid + self.RoleDynamicGrid = self.Proxy:GetRoleDynamicGrid(self) or self.GridCharacter + self.DynamicTable:SetProxy(gridProxy) + self.DynamicTable:SetGrid(self.RoleDynamicGrid) + self.DynamicTable:SetGridSize(Vector2(self.RoleDynamicGrid.transform.rect.width, self.RoleDynamicGrid.transform.rect.height)) + self.CurrentCharacterType = self.Team:GetCharacterType() + -- 注册自动关闭 + local openAutoClose, autoCloseEndTime, callback = self.Proxy:GetAutoCloseInfo() + if openAutoClose then + self:SetAutoCloseInfo(autoCloseEndTime, callback) + end + self.Proxy:AOPOnStartAfter(self) +end + +function XUiBattleRoomRoleDetail:OnEnable() + XUiBattleRoomRoleDetail.Super.OnEnable(self) + -- 设置子面板配置 + self.ChildPanelData = self.Proxy:GetChildPanelData() + self:LoadChildPanelInfo() + self.BtnGroupCharacterType:SelectIndex(self.CurrentCharacterType) +end + +function XUiBattleRoomRoleDetail:OnDisable() + XUiBattleRoomRoleDetail.Super.OnDisable(self) +end + +function XUiBattleRoomRoleDetail:Filter(selectTagGroupDic, sortTagId, isThereFilterDataCb) + if self.TagCacheDic == nil then self.TagCacheDic = {} end + XDataCenter.RoomCharFilterTipsManager.Filter(self.TagCacheDic, selectTagGroupDic + , self.Proxy:GetEntities(self.CurrentCharacterType) + , self.Proxy:GetFilterJudge() + , function(filteredData) + self.CurrentSelectTagGroup[self.CurrentCharacterType].TagGroupDic = selectTagGroupDic + self.CurrentSelectTagGroup[self.CurrentCharacterType].SortType = sortTagId + self:FilterRefresh(filteredData, sortTagId) + end + , isThereFilterDataCb) +end + +function XUiBattleRoomRoleDetail:FilterRefresh(filteredData, sortTagType) + filteredData = self.Proxy:SortEntitiesWithTeam(self.Team, filteredData, sortTagType) + -- self.CurrentEntityId = nil + self:RefreshRoleList(filteredData) +end + +--######################## 私有方法 ######################## + +function XUiBattleRoomRoleDetail:RegisterUiEvents() + self.BtnBack.CallBack = function() self:Close() end + self.BtnMainUi.CallBack = function() XLuaUiManager.RunMain() end + -- 角色类型按钮组 + self.BtnGroupCharacterType:Init({ + [XCharacterConfigs.CharacterType.Normal] = self.BtnTabGouzaoti, + [XCharacterConfigs.CharacterType.Isomer] = self.BtnTabShougezhe + }, function(tabIndex) self:OnBtnGroupCharacterTypeClicked(tabIndex) end) + self.BtnJoinTeam.CallBack = function() self:OnBtnJoinTeamClicked() end + self.BtnQuitTeam.CallBack = function() self:OnBtnQuitTeamClicked() end + self.BtnPartner.CallBack = function() self:OnBtnPartnerClicked() end + self.BtnFashion.CallBack = function() self:OnBtnFashionClicked() end + self.BtnConsciousness.CallBack = function() self:OnBtnConsciousnessClicked() end + self.BtnWeapon.CallBack = function() self:OnBtnWeaponClicked() end + self.BtnFilter.CallBack = function() self:OnBtnFilterClicked() end +end + +function XUiBattleRoomRoleDetail:OnBtnFilterClicked() + XLuaUiManager.Open("UiRoomCharacterFilterTips", self, + XRoomCharFilterTipsConfigs.EnumFilterType.SuperTower, + XRoomCharFilterTipsConfigs.EnumSortType.SuperTower, + self.CurrentCharacterType, nil, nil, + self.Proxy:GetHideSortTagDic()) +end + +function XUiBattleRoomRoleDetail:OnBtnJoinTeamClicked() + local isStop = self.Proxy:AOPOnBtnJoinTeamClickedBefore(self) + if isStop then return end + local finishedCallback = function() + self.Team:UpdateEntityTeamPos(self.CurrentEntityId, self.Pos, true) + self.Proxy:AOPOnBtnJoinTeamClickedAfter(self) + self:Close() + end + if not self:CheckCanJoin(self.CurrentEntityId, finishedCallback) then + return + end + finishedCallback() +end + +function XUiBattleRoomRoleDetail:CheckCanJoin(entityId, finishedCallback) + -- 检查队伍里是否拥有同样的角色(同时兼容机器人) + if self.Proxy:CheckTeamHasSameCharacterId(self.Team, entityId) then + XUiManager.TipError(XUiHelper.GetText("SameCharacterInTeamTip")) + return false + end + -- 检查是否为角色类型不一致,不一致清空 + local currentCharacterType = self.Proxy:GetCharacterType(entityId) + local teamCharacterType = self.Team:GetCharacterType() + if currentCharacterType ~= teamCharacterType and not self.Team:GetIsEmpty() then + XUiManager.DialogTip(nil + , CsXTextManager.GetText("TeamCharacterTypeNotSame") + , XUiManager.DialogType.Normal, nil, function() + -- 清空 + self.Team:ClearEntityIds() + if finishedCallback then + finishedCallback() + end + end) + return false + end + return true +end + +function XUiBattleRoomRoleDetail:OnBtnQuitTeamClicked() + self.Team:UpdateEntityTeamPos(self.CurrentEntityId, self.Pos, false) + self:Close() +end + +function XUiBattleRoomRoleDetail:OnBtnPartnerClicked() + XDataCenter.PartnerManager.GoPartnerCarry(self.CurrentEntityId, false) +end + +function XUiBattleRoomRoleDetail:OnBtnFashionClicked() + XLuaUiManager.Open("UiFashion", self.CurrentEntityId) +end + +function XUiBattleRoomRoleDetail:OnBtnConsciousnessClicked() + XLuaUiManager.Open("UiEquipAwarenessReplace", self.CurrentEntityId, nil, true) +end + +function XUiBattleRoomRoleDetail:OnBtnWeaponClicked() + XLuaUiManager.Open("UiEquipReplaceNew", self.CurrentEntityId, nil, true) +end + +-- characterType : XCharacterConfigs.CharacterType +function XUiBattleRoomRoleDetail:OnBtnGroupCharacterTypeClicked(characterType) + if characterType == XCharacterConfigs.CharacterType.Isomer + and not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.Isomer) then + return + end + self.CurrentCharacterType = characterType + local selectTagGroupDic = self.CurrentSelectTagGroup[characterType].TagGroupDic or {} + local sortTagId = self.CurrentSelectTagGroup[characterType].SortType or XRoomCharFilterTipsConfigs.EnumSortTag.Default + local roles = self.Proxy:GetEntities(self.CurrentCharacterType) + if #roles <= 0 then + XUiManager.TipError(XUiHelper.GetText("IsomerLimitTip")) + self.BtnGroupCharacterType:SelectIndex(XCharacterConfigs.CharacterType.Normal) + return + end + self:Filter(selectTagGroupDic, sortTagId, function(roles) + if #roles <= 0 then + XUiManager.TipError(XUiHelper.GetText("IsomerLimitTip")) + self.BtnGroupCharacterType:SelectIndex(XCharacterConfigs.CharacterType.Normal) + return false + end + return true + end) +end + +-- characterType : XCharacterConfigs.CharacterType +function XUiBattleRoomRoleDetail:RefreshRoleList(roleEntities) + local searchEntityId = self.CurrentEntityId + local index = 1 + if searchEntityId ~= nil or searchEntityId ~= 0 then + for i, v in ipairs(roleEntities) do + if v:GetId() == searchEntityId then + index = i + break + end + end + end + self.CurrentEntityId = roleEntities[index]:GetId() + self:SetJoinBtnIsActive(not self.Team:GetEntityIdIsInTeam(self.CurrentEntityId)) + self.DynamicTable:SetDataSource(roleEntities) + self.DynamicTable:ReloadDataSync(index) + self:RefreshModel() + self:RefreshOperationBtns() +end + +function XUiBattleRoomRoleDetail:OnDynamicTableEvent(event, index, grid) + if index <= 0 or index > #self.DynamicTable.DataSource then return end + local entity = self.DynamicTable.DataSource[index] + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:SetData(entity, self.Team, self.StageId) + grid:SetSelectStatus(self.CurrentEntityId == entity:GetId()) + grid:SetInTeamStatus(self.Team:GetEntityIdIsInTeam(entity:GetId())) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + self.CurrentEntityId = entity:GetId() + for _, tmpGrid in pairs(self.DynamicTable:GetGrids()) do + tmpGrid:SetSelectStatus(false) + end + grid:SetSelectStatus(true) + self:SetJoinBtnIsActive(not self.Team:GetEntityIdIsInTeam(self.CurrentEntityId)) + self:RefreshModel() + self:RefreshOperationBtns() + self:RefreshChildPanel() + end +end + +function XUiBattleRoomRoleDetail:SetJoinBtnIsActive(value) + self.BtnJoinTeam.gameObject:SetActiveEx(value) + self.BtnQuitTeam.gameObject:SetActiveEx(not value) +end + +function XUiBattleRoomRoleDetail:RefreshModel(entityId) + if entityId == nil then entityId = self.CurrentEntityId end + self.ImgEffectHuanren.gameObject:SetActiveEx(false) + self.ImgEffectHuanren1.gameObject:SetActiveEx(false) + local finishedCallback = function(model) + self.PanelDrag.Target = model.transform + self.ImgEffectHuanren.gameObject:SetActiveEx(self.CurrentCharacterType == XCharacterConfigs.CharacterType.Normal) + self.ImgEffectHuanren1.gameObject:SetActiveEx(self.CurrentCharacterType == XCharacterConfigs.CharacterType.Isomer) + end + local characterViewModel = self.Proxy:GetCharacterViewModelByEntityId(entityId) + if XRobotManager.CheckIsRobotId(entityId) then + local robotConfig = XRobotManager.GetRobotTemplate(entityId) + self.UiPanelRoleModel:UpdateRobotModel(entityId, robotConfig.CharacterId + , nil, robotConfig.FashionId, robotConfig.WeaponId, finishedCallback) + else + self.UiPanelRoleModel:UpdateCharacterModel(entityId, nil, nil, finishedCallback, nil, characterViewModel:GetFashionId()) + end +end + +function XUiBattleRoomRoleDetail:RefreshOperationBtns() + local isRobot = XRobotManager.CheckIsRobotId(self.CurrentEntityId) + self.BtnPartner.gameObject:SetActiveEx(not isRobot) + self.BtnFashion.gameObject:SetActiveEx(not isRobot) + self.BtnConsciousness.gameObject:SetActiveEx(not isRobot) + self.BtnWeapon.gameObject:SetActiveEx(not isRobot) +end + +function XUiBattleRoomRoleDetail:LoadChildPanelInfo() + if not self.ChildPanelData then return end + local childPanelData = self.ChildPanelData + -- 加载panel asset + local instanceGo = childPanelData.instanceGo + if XTool.UObjIsNil(instanceGo) then + instanceGo = self.PanelChildContainer:LoadPrefab(childPanelData.assetPath) + childPanelData.instanceGo = instanceGo + -- 加载panel proxy + childPanelData.instanceProxy = childPanelData.proxy.New(instanceGo) + end + -- 加载proxy参数 + local proxyArgs = {} + if childPanelData.proxyArgs then + for _, argName in ipairs(childPanelData.proxyArgs) do + if type(argName) == "string" then + proxyArgs[#proxyArgs + 1] = self[argName] + else + proxyArgs[#proxyArgs + 1] = argName + end + end + end + childPanelData.instanceProxy:SetData(table.unpack(proxyArgs)) +end + +function XUiBattleRoomRoleDetail:RefreshChildPanel() + if not self.ChildPanelData then return end + if not self.ChildPanelData.instanceProxy then return end + if not self.ChildPanelData.instanceProxy.Refresh then return end + self.ChildPanelData.instanceProxy:Refresh(self.CurrentEntityId) +end + +return XUiBattleRoomRoleDetail \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNewRoomSingle/XUiBattleRoomRoleDetailDefaultProxy.lua b/Resources/Scripts/XUi/XUiNewRoomSingle/XUiBattleRoomRoleDetailDefaultProxy.lua new file mode 100644 index 00000000..f0ac00ec --- /dev/null +++ b/Resources/Scripts/XUi/XUiNewRoomSingle/XUiBattleRoomRoleDetailDefaultProxy.lua @@ -0,0 +1,98 @@ +local XUiBattleRoomRoleDetailDefaultProxy = XClass(nil, "XUiBattleRoomRoleDetailDefaultProxy") + +-- characterType : XCharacterConfigs.CharacterType +function XUiBattleRoomRoleDetailDefaultProxy:GetEntities(characterType) + return {} +end + +function XUiBattleRoomRoleDetailDefaultProxy:GetFilterJudge() + return function() + return false + end +end + +function XUiBattleRoomRoleDetailDefaultProxy:GetEntityIndexById(entityId) + if entityId == nil or entityId == 0 then return 1 end + for i, v in ipairs(self:GetEntities()) do + if v:GetId() == entityId then + return i + end + end + return 1 +end + +function XUiBattleRoomRoleDetailDefaultProxy:GetGridProxy() + return nil +end + +function XUiBattleRoomRoleDetailDefaultProxy:GetChildPanelData() + return nil +end + +function XUiBattleRoomRoleDetailDefaultProxy:GetCharacterViewModelByEntityId(entityId) + return nil +end + +function XUiBattleRoomRoleDetailDefaultProxy:GetCharacterType(entityId) + return XCharacterConfigs.GetCharacterType(XEntityHelper.GetCharacterIdByEntityId(entityId)) +end + +function XUiBattleRoomRoleDetailDefaultProxy:CheckTeamHasSameCharacterId(team, checkEntityId) + local checkCharacterId = XEntityHelper.GetCharacterIdByEntityId(checkEntityId) + for _, entityId in pairs(team:GetEntityIds()) do + if XEntityHelper.GetCharacterIdByEntityId(entityId) == checkCharacterId then + return true + end + end + return false +end + +-- team : XTeam +-- sortTagType : XRoomCharFilterTipsConfigs.EnumSortTag +function XUiBattleRoomRoleDetailDefaultProxy:SortEntitiesWithTeam(team, entities, sortTagType) + table.sort(entities, function(entityA, entityB) + local _, posA = team:GetEntityIdIsInTeam(entityA:GetId()) + local _, posB = team:GetEntityIdIsInTeam(entityB:GetId()) + local teamWeightA = posA ~= -1 and (10 - posA) * 1000 or 0 + local teamWeightB = posB ~= -1 and (10 - posB) * 1000 or 0 + if teamWeightA == teamWeightB then + return entityA:GetId() > entityB:GetId() + else + return teamWeightA > teamWeightB + end + end) + return entities +end + +function XUiBattleRoomRoleDetailDefaultProxy:GetAutoCloseInfo() + return false +end + +function XUiBattleRoomRoleDetailDefaultProxy:GetRoleDynamicGrid() + +end + +-- return { [XRoomCharFilterTipsConfigs.EnumSortTag.xxx] = true } 即为隐藏 +function XUiBattleRoomRoleDetailDefaultProxy:GetHideSortTagDic() + return nil +end + +--######################## AOP ######################## + +function XUiBattleRoomRoleDetailDefaultProxy:AOPOnStartBefore(rootUi) + +end + +function XUiBattleRoomRoleDetailDefaultProxy:AOPOnStartAfter(rootUi) + +end + +function XUiBattleRoomRoleDetailDefaultProxy:AOPOnBtnJoinTeamClickedBefore(rootUi) + +end + +function XUiBattleRoomRoleDetailDefaultProxy:AOPOnBtnJoinTeamClickedAfter(rootUi) + +end + +return XUiBattleRoomRoleDetailDefaultProxy \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNewRoomSingle/XUiBattleRoomRoleGrid.lua b/Resources/Scripts/XUi/XUiNewRoomSingle/XUiBattleRoomRoleGrid.lua new file mode 100644 index 00000000..017a3162 --- /dev/null +++ b/Resources/Scripts/XUi/XUiNewRoomSingle/XUiBattleRoomRoleGrid.lua @@ -0,0 +1,35 @@ +local XUiBattleRoomRoleGrid = XClass(nil, "XUiBattleRoomRoleGrid") + +function XUiBattleRoomRoleGrid:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiBattleRoomRoleGrid:SetData(entity) + local characterViewModel = entity:GetCharacterViewModel() + self.RImgHeadIcon:SetRawImage(characterViewModel:GetSmallHeadIcon()) + self.TxtPower.text = characterViewModel:GetAbility() + self.TxtLevel.text = characterViewModel:GetLevel() + self.RImgQuality:SetRawImage(characterViewModel:GetQualityIcon()) + -- 元素图标 + local obtainElementIcons = characterViewModel:GetObtainElementIcons() + local elementIcon + for i = 1, 3 do + elementIcon = obtainElementIcons[i] + self["RImgElement" .. i].gameObject:SetActiveEx(elementIcon ~= nil) + if elementIcon then + self["RImgElement" .. i]:SetRawImage(elementIcon) + end + end +end + +function XUiBattleRoomRoleGrid:SetSelectStatus(value) + self.PanelSelected.gameObject:SetActiveEx(value) +end + +function XUiBattleRoomRoleGrid:SetInTeamStatus(value) + self.ImgInTeam.gameObject:SetActiveEx(value) +end + +return XUiBattleRoomRoleGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNewRoomSingle/XUiNewRoomSingle.lua b/Resources/Scripts/XUi/XUiNewRoomSingle/XUiNewRoomSingle.lua new file mode 100644 index 00000000..83cce383 --- /dev/null +++ b/Resources/Scripts/XUi/XUiNewRoomSingle/XUiNewRoomSingle.lua @@ -0,0 +1,2367 @@ +local XUiPanelBabelTower = require("XUi/XUiNewRoomSingle/XUiPanelBabelTower") + +local CSXTextManagerGetText = CS.XTextManager.GetText + +local XUiNewRoomSingle = XLuaUiManager.Register(XLuaUi, "UiNewRoomSingle") + +local CHAR_POS1 = 1 +local CHAR_POS2 = 2 +local CHAR_POS3 = 3 +local MAX_CHAR_COUNT = 3 +local LONG_CLICK_TIME = 0 +local TIMER = 1 +local LOAD_TIME = 10 + +function XUiNewRoomSingle:OnAwake() + self:AutoAddListener() + self.PanelTip.gameObject:SetActiveEx(false) + self.ImgRoleRepace.gameObject:SetActiveEx(false) +end +--== data 可能包含的变量 ---- +-- ChallengeCount +-- ForceConditionIds +-- NodeId +-- TeamBuffId +-- WorldBossTeamDatas +-- BabelTowerData +-- ChallengeId +-- ChessPursuitData +--== end ---- +function XUiNewRoomSingle:OnStart(stageId, data, ...) + self.Args = { ... } + self.ChangeCharIndex = 0 + local uiModelRoot = self.UiModelGo.transform + self.PanelCharacterInfo = { + [1] = { + PanelRoleEffect = uiModelRoot:FindTransform("PanelRoleEffect1"), + TongdiaoEffect = uiModelRoot:FindTransform("ImgEffectTongDiao1"), + RoleModelPanel = XUiPanelRoleModel.New(uiModelRoot:FindTransform("PanelRoleModel1"), self.Name, nil, true, nil, true, true), + }, + [2] = { + PanelRoleEffect = uiModelRoot:FindTransform("PanelRoleEffect2"), + TongdiaoEffect = uiModelRoot:FindTransform("ImgEffectTongDiao2"), + RoleModelPanel = XUiPanelRoleModel.New(uiModelRoot:FindTransform("PanelRoleModel2"), self.Name, nil, true, nil, true, true), + }, + [3] = { + PanelRoleEffect = uiModelRoot:FindTransform("PanelRoleEffect3"), + TongdiaoEffect = uiModelRoot:FindTransform("ImgEffectTongDiao3"), + RoleModelPanel = XUiPanelRoleModel.New(uiModelRoot:FindTransform("PanelRoleModel3"), self.Name, nil, true, nil, true, true), + }, + } + + self.Camera = self.Transform:GetComponent("Canvas").worldCamera + self.RectTransform = self.Transform:GetComponent("RectTransform") + self:InitInfo(stageId, data) + self.Proxy = XUiNewRoomSingleProxy.ProxyDic[self.StageInfos.Type] or + XUiNewRoomSingleProxy.ProxyDic[self.StageCfg.StageType] + self.BtnShowInfoToggle.CallBack = function(val) + self:OnBtnShowInfoToggleByProxy(val) + end + -- 默认助战为关闭状态 + if XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.OtherHelp) then + self.BtnSupportToggle:SetButtonState(XUiButtonState.Normal) + end + + self:InitEffectPositionInfo() + self:InitTeamData() + self:InitPanelTeam() + self:SetWeakness() + self:InitCharacterLimit() + self:InitBtnLongClicks() + self:SetCondition() + self:SetStageInfo() + self:InitEndurance() + --更新战力限制提示 + self:InitFightControl() + --更新战斗信息 + self:InitCharacterInfo() + self:InitFirstFightTabBtns() + + if self.StageInfos.HaveAssist == 1 then + self:ShowAssistToggle(true) + -- 保存玩家选择助战状态 + local assistSwitch = CS.UnityEngine.PlayerPrefs.GetInt(XPrefs.AssistSwitch .. XPlayer.Id) + if assistSwitch == nil or assistSwitch == 0 then + self:SetAssistStatus(false) + else + self:SetAssistStatus(true) + end + else + self:ShowAssistToggle(false) + self:SetAssistStatus(false) + end + -- 更新爬塔活动切换助战按钮状态 + self:SetSwitchRole() + self:InitProxyPanel() + self:InitWorldBoss() + self:InitPanelBabelTower() + self:InitPanelNieR() + self:InitChessPursuit() + + XEventManager.AddEventListener(XEventId.EVENT_TEAM_PREFAB_SELECT, self.UpdateTeamPrefab, self) + XEventManager.AddEventListener(XEventId.EVENT_FIGHT_BEGIN_PLAYMOVIE, self.OnOpenLoadingOrBeginPlayMovie, self) + XEventManager.AddEventListener(XEventId.EVENT_FIGHT_LOADINGFINISHED, self.OnOpenLoadingOrBeginPlayMovie, self) + -- 自动关闭 + local openAutoClose, autoCloseEndTime, callback = self:GetAutoCloseInfo() + if openAutoClose then + self:SetAutoCloseInfo(autoCloseEndTime, callback) + end +end + +function XUiNewRoomSingle:OnDestroy() + self:DestroyNewRoomSingle() + XUiHelper.StopAnimation() + self:RemoveTimer() + XEventManager.RemoveEventListener(XEventId.EVENT_TEAM_PREFAB_SELECT, self.UpdateTeamPrefab, self) + XEventManager.RemoveEventListener(XEventId.EVENT_FIGHT_BEGIN_PLAYMOVIE, self.OnOpenLoadingOrBeginPlayMovie, self) + XEventManager.RemoveEventListener(XEventId.EVENT_FIGHT_LOADINGFINISHED, self.OnOpenLoadingOrBeginPlayMovie, self) +end + +function XUiNewRoomSingle:OnEnable() + XUiNewRoomSingle.Super.OnEnable(self) + self:InitFightControl() + self:InitCharacterInfo() + XEventManager.AddEventListener(XEventId.EVENT_ROOM_CHANGE_STAGE, self.OnSetStageId, self) +end + +function XUiNewRoomSingle:OnDisable() + XUiNewRoomSingle.Super.OnDisable(self) + XDataCenter.FavorabilityManager.StopCv() + XEventManager.RemoveEventListener(XEventId.EVENT_ROOM_CHANGE_STAGE, self.OnSetStageId, self) +end + +function XUiNewRoomSingle:OnSetStageId(stageId, data) + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + if not CS.XFight.IsRunning and not XLuaUiManager.IsUiLoad("UiLoading") then + local contenttext = CS.XTextManager.GetText("StageChangeInfo", stageCfg.Name) + XUiManager.TipMsg(contenttext) + end + self:InitInfo(stageId, data) + self:RefreshCharacterTypeTips() +end + +function XUiNewRoomSingle:InitInfo(stageId, data) + self.CurrentStageId = stageId + if data then + self.ChallengeCount = data.ChallengeCount + self.SuggestedConditionIds = data.SuggestedConditionIds -- 暂未使用 + self.ForceConditionIds = data.ForceConditionIds + self.EventIds = data.EventIds -- 暂未使用 + self.NodeId = data.NodeId + self.TeamBuffId = data.TeamBuffId + self.WorldBossTeamDatas = data.WorldBossTeamDatas + self.ChessPursuitData = data.ChessPursuitData + self.BabelTowerData = data.BabelTowerData + self.ChallengeId = data.ChallengeId + end + -- 需要默认值的变量 + self.SuggestedConditionIds = self.SuggestedConditionIds or {} + self.ForceConditionIds = self.ForceConditionIds or {} + + self.TypeIdMainLine = CS.XGame.Config:GetInt("TypeIdMainLine") + self.TypeIdBossSingle = CS.XGame.Config:GetInt("TypeIdBossSingle") + self.TypeIdExplore = CS.XGame.Config:GetInt("TypeIdExplore") + self.TypeIdRpgTower = CS.XGame.Config:GetInt("TypeIdRpgTower") + self.StageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + self.StageInfos = XDataCenter.FubenManager.GetStageInfo(stageId) +end + +function XUiNewRoomSingle:InitEffectPositionInfo() + if self.StageInfos.Type ~= XDataCenter.FubenManager.StageType.InfestorExplore then + self.PanelEffectPosition.gameObject:SetActiveEx(false) + return + end + self.TxtEffectPosition.text = XDataCenter.FubenInfestorExploreManager.GetBuffDes() + self.PanelEffectPosition.gameObject:SetActiveEx(true) +end + +function XUiNewRoomSingle:InitCharacterLimit() + local characterLimitType = self:GetCharacterLimitType() + + if not XFubenConfigs.IsStageCharacterLimitConfigExist(characterLimitType) then + self.PanelCharacterLimit.gameObject:SetActiveEx(false) + return + else + self.PanelCharacterLimit.gameObject:SetActiveEx(true) + end + + local icon = XFubenConfigs.GetStageCharacterLimitImageTeamEdit(characterLimitType) + self.ImgCharacterLimit:SetSprite(icon) +end + +function XUiNewRoomSingle:GetCurTeamCharacterType() + for _, characterId in pairs(self.CurTeam.TeamData) do + if characterId > 0 then + return XCharacterConfigs.GetCharacterType(characterId) + end + end +end + +function XUiNewRoomSingle:RefreshCharacterTypeTips() + local stageId = self.CurrentStageId + local limitBuffId = XFubenConfigs.GetStageCharacterLimitBuffId(stageId) + local characterType = self:GetCurTeamCharacterType() + local characterLimitType = self:GetCharacterLimitType() + local text = XFubenConfigs.GetStageCharacterLimitTextTeamEdit(characterLimitType, characterType, limitBuffId) + self.TxtCharacterLimit.text = text +end + +-- 首次出场按钮组 +function XUiNewRoomSingle:InitFirstFightTabBtns() + if self:GetIsHideSwitchFirstFightPosBtnsWithProxy() then + -- 出场按钮组与队长技能选择的显隐 + self.PanelTeamLeader.gameObject:SetActiveEx(false) + self.PanelBtnLeader.gameObject:SetActiveEx(false) + return + end + + local tabGroup = { + self.BtnRed, + self.BtnBlue, + self.BtnYellow, + } + self.PanelTabCaptain:Init(tabGroup, function(tabIndex) self:OnFirstFightTabClick(tabIndex) end) + + -- 首发位为nil或0,使其与队长位一致(因为服务器在之前只有队长位,后面区分了队长位与首发位,存在有队长位,没有首发位的情况) + if self.CurTeam.FirstFightPos == nil or self.CurTeam.FirstFightPos == 0 then + self.CurTeam.FirstFightPos = self.CurTeam.CaptainPos + end + + -- 首发位依然为nil或0则报错,默认第一位为首发位 + if self.CurTeam.FirstFightPos == nil then + XLog.Error("XUiNewRoomSingle:InitFirstFightTabBtns函数错误, self.CurTeam.FirstFightPos为nil") + self.CurTeam.FirstFightPos = CHAR_POS1 + elseif self.CurTeam.FirstFightPos == 0 then + XLog.Error("XUiNewRoomSingle:InitFirstFightTabBtns函数错误, self.CurTeam.FirstFightPos为0") + self.CurTeam.FirstFightPos = CHAR_POS1 + end + + self.PanelTabCaptain:SelectIndex(self.CurTeam.FirstFightPos) +end + +-- 设置首次出场 +function XUiNewRoomSingle:OnFirstFightTabClick(tabIndex) + local firstFightPos = self.CurTeam.FirstFightPos + if firstFightPos == tabIndex then + return + end + + self.CurTeam.FirstFightPos = tabIndex + self:SetFirstFightPosWithProxy(tabIndex) + self:SetTeamByProxy() + if self:IsBabelTower() then + local cb = self.BabelTowerData.Cb + if cb then + cb(self.CurTeam.TeamData, self.CurTeam.CaptainPos, self.CurTeam.FirstFightPos) + end + end + self:InitPanelTeam() +end + +-- 设置队长技能 +function XUiNewRoomSingle:OnClickTabCallBack(tabIndex) + local captainPos = self.CurTeam.CaptainPos + if captainPos == tabIndex then + return + end + self.CurTeam.CaptainPos = tabIndex + self:SetCaptainPosWithProxy(tabIndex) + self:SetTeamByProxy() + local isUnionKillType = self:IsUnionKillType() + if isUnionKillType then + self:UpdateTeamCaptionPos() + end + + if self:IsBabelTower() then + local cb = self.BabelTowerData.Cb + if cb then + cb(self.CurTeam.TeamData, self.CurTeam.CaptainPos, self.CurTeam.FirstFightPos) + end + end + self:InitPanelTeam() +end + +function XUiNewRoomSingle:OnOpenLoadingOrBeginPlayMovie() + self:Remove() +end + +function XUiNewRoomSingle:AutoAddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:RegisterClickEvent(self.BtnTeamPrefab, self.OnBtnTeamPrefabClick) + self:RegisterClickEvent(self.BtnChar1, self.OnBtnChar1Click) + self:RegisterClickEvent(self.BtnChar2, self.OnBtnChar2Click) + self:RegisterClickEvent(self.BtnChar3, self.OnBtnChar3Click) + + self.CharacterPets1:GetObject("BtnClick").CallBack = function() self:OnBtnChar1Click() end + self.CharacterPets2:GetObject("BtnClick").CallBack = function() self:OnBtnChar2Click() end + self.CharacterPets3:GetObject("BtnClick").CallBack = function() self:OnBtnChar3Click() end + + self.BtnEnterFight.CallBack = function() self:OnBtnEnterFightClick() end + self.BtnSupportToggle.CallBack = function(state) self:OnBtnAssistToggleClick(state) end + self.BtnSwitchRole01.CallBack = function() self:OnBtnSwitchRoleClick() end + self.BtnSwitchRole02.CallBack = function() self:OnBtnSwitchRoleClick() end + self.BtnTeamBuff.CallBack = function() self:OnClickBtnTeamBuff() end + self.BtnGo.CallBack = function() self:OnPanelBtnLeaderClick() end + if not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.OtherHelp) then + self.BtnSupportToggle:SetDisable(true) + end +end + +function XUiNewRoomSingle:OnPanelBtnLeaderClick() + -- 获取机器人为RobotId,玩家角色为CharacterId的队伍数据 + -- 如果代理没有实现该接口,且队伍拥有没有使用RobotId的机器人,则无法获取机器人配置的时装与解放等级数据,队长头像会使用初始头像 + local realCharData = self:GetRealCharDataByProxy() + local teamData = realCharData or self.CurTeam.TeamData + + XLuaUiManager.Open("UiNewRoomSingleTip", self, teamData, self.CurTeam.CaptainPos, function(index) + self:OnClickTabCallBack(index) + end) +end + +function XUiNewRoomSingle:OnBtnTeamPrefabClick() + if self:IsWorldBossType() then + return + end + if self:IsRogueLikeType() then + return + end + if self:CheckHasRobot() then + return + end + + local stageId = self.CurrentStageId + local limitBuffId = XFubenConfigs.GetStageCharacterLimitBuffId(stageId) + local characterLimitType = self:GetCharacterLimitType() + local teamGridId = self:GetTeamGridId() + XLuaUiManager.Open("UiRoomTeamPrefab", self.CurTeam.CaptainPos, self.CurTeam.FirstFightPos, characterLimitType, limitBuffId, self.StageCfg.StageType, teamGridId) +end + +function XUiNewRoomSingle:GetTeamGridId() + local teamGridId + if self:IsChessPursuit() then + teamGridId = self.ChessPursuitData.TeamGridIndex + end + return teamGridId +end + +function XUiNewRoomSingle:OnBtnShowInfoToggle(val) + if val then + local key = "NewRoomShowInfoToggle" .. tostring(XPlayer.Id) + CS.UnityEngine.PlayerPrefs.SetInt(key, val) + end + self:InitCharacterInfo() +end + +function XUiNewRoomSingle:OnBtnAssistToggleClick(state) + if self:IsRogueLikeType() or self:IsUnionKillType() then + return + end + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.OtherHelp) then + return + end + + self:SetAssistStatus(XUiHelper.GetToggleVal(state)) + local assistSwitch = self:GetAssistStatus() and 1 or 0 + CS.UnityEngine.PlayerPrefs.SetInt(XPrefs.AssistSwitch .. XPlayer.Id, assistSwitch) + if self:GetAssistStatus() then + self:PlayTips("FightAssistOpen", true) + else + self:PlayTips("FightAssistClose", false) + end +end + +function XUiNewRoomSingle:SetBossSingleInfo() + self:ShowAssistToggle(false) +end + +-- 初始化长按事件 +function XUiNewRoomSingle:InitBtnLongClicks() + local btnLongClick1 = self.BtnChar1:GetComponent("XUiPointer") + local btnLongClick2 = self.BtnChar2:GetComponent("XUiPointer") + local btnLongClick3 = self.BtnChar3:GetComponent("XUiPointer") + XUiButtonLongClick.New(btnLongClick1, 10, self, nil, self.OnBtnUnLockLongClick1, self.OnBtnUnLockLongUp, false) + XUiButtonLongClick.New(btnLongClick2, 10, self, nil, self.OnBtnUnLockLongClick2, self.OnBtnUnLockLongUp, false) + XUiButtonLongClick.New(btnLongClick3, 10, self, nil, self.OnBtnUnLockLongClick3, self.OnBtnUnLockLongUp, false) +end + +function XUiNewRoomSingle:OnBtnUnLockLongUp() + self.ImgRoleRepace.gameObject:SetActiveEx(false) + self.IsUp = not self.IsUp + LONG_CLICK_TIME = 0 + + if not self:CheckCharCanClickByProxy() then + return + end + + if self.ChangeCharIndex > 0 then + local targetX = math.floor(self:GetPisont().x + self.RectTransform.rect.width / 2) + local targetIndex + if targetX <= self.RectTransform.rect.width / 3 then + targetIndex = CHAR_POS2 + elseif targetX > self.RectTransform.rect.width / 3 and targetX <= self.RectTransform.rect.width / 3 * 2 then + targetIndex = CHAR_POS1 --UI的位置1号位是在中间的 + else + targetIndex = CHAR_POS3 + end + + local changeIndex = self.ChangeCharIndex + if targetIndex > 0 and targetIndex ~= changeIndex then + local teamData = XTool.Clone(self.CurTeam.TeamData) + local targetId = teamData[targetIndex] + teamData[targetIndex] = teamData[changeIndex] + teamData[changeIndex] = targetId + + self:HandleSwitchTeamPosWithProxy(changeIndex, targetIndex) + self:UpdateTeam(teamData) + + if self:IsUnionKillType() then + self:SwitchCacheTeam(changeIndex, targetIndex) + end + + if self:IsRogueLikeType() and self.RogueLikeIsRobot then + local teamCache = self.ChooseRobots + local temp = teamCache[changeIndex] + teamCache[changeIndex] = teamCache[targetIndex] + teamCache[targetIndex] = temp + end + end + self.ChangeCharIndex = 0 + end +end + +function XUiNewRoomSingle:SeBtnUnLockLongClickt(index, time) + if self.CurTeam.TeamData[index] <= 0 then + self.IsUp = true + return + end + + LONG_CLICK_TIME = LONG_CLICK_TIME + time / 1000 + if self.IsUp then + self.IsUp = false + return + end + if LONG_CLICK_TIME > TIMER and not self.IsUp then + self.IsUp = false + if not self.ImgRoleRepace.gameObject.activeSelf then + self.ImgRoleRepace.gameObject:SetActiveEx(true) + end + self.ImgRoleRepace.gameObject.transform.localPosition = self:GetPisont() + end + if self.ChangeCharIndex <= 0 then + self.ChangeCharIndex = index + end +end + +function XUiNewRoomSingle:GetPisont() + local screenPoint + if CS.UnityEngine.Application.platform == CS.UnityEngine.RuntimePlatform.WindowsEditor or CS.UnityEngine.Application.platform == CS.UnityEngine.RuntimePlatform.WindowsPlayer then + screenPoint = CS.UnityEngine.Vector2(CS.UnityEngine.Input.mousePosition.x, CS.UnityEngine.Input.mousePosition.y) + else + screenPoint = CS.UnityEngine.Input.GetTouch(0).position + end + + -- 设置拖拽 + local hasValue, v2 = CS.UnityEngine.RectTransformUtility.ScreenPointToLocalPointInRectangle(self.RectTransform, screenPoint, self.Camera) + if hasValue then + return CS.UnityEngine.Vector3(v2.x, v2.y, 0) + else + return CS.UnityEngine.Vector3.zero + end +end + +function XUiNewRoomSingle:OnBtnUnLockLongClick1(time) + self:SeBtnUnLockLongClickt(CHAR_POS1, time) +end + +function XUiNewRoomSingle:OnBtnUnLockLongClick2(time) + self:SeBtnUnLockLongClickt(CHAR_POS2, time) +end + +function XUiNewRoomSingle:OnBtnUnLockLongClick3(time) + self:SeBtnUnLockLongClickt(CHAR_POS3, time) +end + +-- 初始化 team 数据 +function XUiNewRoomSingle:InitTeamData() + local curTeam + curTeam = self:GetTeamByProxy() + if not curTeam then + if self.StageInfos.Type == XDataCenter.FubenManager.StageType.BossSingle then + curTeam = XDataCenter.TeamManager.GetPlayerTeam(self.TypeIdBossSingle) + elseif self.StageInfos.Type == XDataCenter.FubenManager.StageType.Explore then + curTeam = XDataCenter.TeamManager.GetPlayerTeam(self.TypeIdExplore) + --每次进入清空上次的选则 + for i = 1, #curTeam.TeamData do + curTeam.TeamData[i] = 0 + end + elseif self:IsWorldBossType() then + local characterDatas = self.WorldBossTeamDatas + local tmpData = {} + for index, data in pairs(characterDatas) do + tmpData.TeamData = tmpData.TeamData or {} + if data.IsCaptain then + tmpData.CaptainPos = index + end + + if data.IsFirstFight then + tmpData.FirstFightPos = index + end + + if data.RobotId > 0 then + table.insert(tmpData.TeamData, data.RobotId) + elseif data.Id > 0 then + table.insert(tmpData.TeamData, data.Id) + else + table.insert(tmpData.TeamData, 0) + end + end + curTeam = next(tmpData) and tmpData + curTeam = curTeam or XWorldBossConfigs.DefaultTeam + elseif self:IsChessPursuit() then + -- 默认清空 + curTeam = self.ChessPursuitData.CurTeam + elseif self:IsBabelTower() then + curTeam = self.BabelTowerData.TeamList + elseif self:IsNieRType() then + curTeam = XDataCenter.NieRManager.GetPlayerTeamData(self.CurrentStageId) + else + curTeam = XDataCenter.TeamManager.GetPlayerTeam(self.TypeIdMainLine) + end + end + if curTeam == nil then + return + end + + self:LimitCharacterByProxy(curTeam) + + -- 初始化爬塔阵容 + if self:IsRogueLikeType() then + curTeam = self:RogueLikeInitTeam(curTeam) + end + -- 初始化狙击战阵容 + if self:IsUnionKillType() then + curTeam = self:UnionKillInitTeam(curTeam) + end + self.CurTeam = curTeam + local stageCfg = XDataCenter.FubenManager.GetStageCfg(self.CurrentStageId) + local RobotIds = self:GetRobotIdsByProxy(self.CurrentStageId) + self.HasRobot = RobotIds and #RobotIds > 0 or (self:IsNieRType() and self.Args[3]) + if RobotIds and #RobotIds > 0 then + self.CurTeam.TeamData = {} + for i = 1, MAX_CHAR_COUNT do + if i > #RobotIds then + table.insert(self.CurTeam.TeamData, 0) + else + local charId = XRobotManager.GetCharacterId(RobotIds[i]) + table.insert(self.CurTeam.TeamData, charId) + end + end + + -- 有机器人出战位和首发位设为1 + self.CurTeam.CaptainPos = self:GetCaptainPos() + self.CurTeam.FirstFightPos = self:GetFirstFightPos() + end + + for i = 1, MAX_CHAR_COUNT do + local teamCfg = XTeamConfig.GetTeamCfgById(i) + if teamCfg then + self.PanelCharacterInfo[i].PanelRoleEffect:LoadPrefab(teamCfg.EffectPath, false) + end + end +end + +-- team Ui 初始化 +function XUiNewRoomSingle:InitPanelTeam() + self.BtnEnterFight:SetDisable(true, false) + + if not self.CurTeam then + return + end + local firstFightPos = self.CurTeam.FirstFightPos + -- 记录是否全部加载完成 + self.LoadModelCount = 0 + for i = 1, MAX_CHAR_COUNT do + local posData = self.CurTeam.TeamData[i] + if posData and posData > 0 then + self.LoadModelCount = self.LoadModelCount + 1 + end + + -- 设置首发标签,隐藏所有队长标签 + self["PanelLeader" .. i].gameObject:SetActiveEx(false) + self["PanelFirstRole" .. i].gameObject:SetActiveEx(not self:GetIsHideSwitchFirstFightPosBtnsWithProxy() + and i == firstFightPos) + + end + + for i = 1, MAX_CHAR_COUNT do + self["Timer" .. i] = XScheduleManager.ScheduleOnce(function() + if XTool.UObjIsNil(self.Transform) or not self.GameObject.activeSelf then + return + end + local posData = self.CurTeam.TeamData[i] + if posData and posData > 0 then + self:UpdateRoleModelByProxy(posData, self.PanelCharacterInfo[i].RoleModelPanel, i) + self["ImgAdd" .. i].gameObject:SetActiveEx(false) + self:UpdateRoleStanmina(posData, i) + else + self["PanelStaminaBar" .. i].gameObject:SetActiveEx(false) + self["ImgAdd" .. i].gameObject:SetActiveEx(true) + end + end, i * LOAD_TIME) + end + + self:RefreshCaptainSkill() +end + +function XUiNewRoomSingle:UpdateFightControl() + local teamAbility = {} + + for _, v in ipairs(self.CurTeam.TeamData) do + if self.Proxy and self.Proxy.GetCharAbility then + table.insert(teamAbility, self.Proxy.GetCharAbility(v)) + end + local isRobot = XRobotManager.CheckIsRobotId(v) + local char = XDataCenter.CharacterManager.GetCharacter(v) + + if isRobot then + table.insert(teamAbility, XRobotManager.GetRobotAbility(v)) + elseif char == nil then + table.insert(teamAbility, 0) + else + table.insert(teamAbility, char.Ability) + end + end + local conditionResult = true + for _, id in pairs(self.ForceConditionIds) do + local ret = XConditionManager.CheckCondition(id, self.CurTeam.TeamData) + if not ret then + conditionResult = false + end + end + self.FightControlResult = self.FightControl:UpdateInfo(self.StageCfg.FightControlId, teamAbility, conditionResult, self.CurrentStageId, self.CurTeam.TeamData) +end + +function XUiNewRoomSingle:RemoveTimer() + for i = 1, MAX_CHAR_COUNT do + if self["Timer" .. i] then + XScheduleManager.UnSchedule(self["Timer" .. i]) + self["Timer" .. i] = nil + end + end +end + +--更新模型 +function XUiNewRoomSingle:UpdateRoleModel(charId, roleModelPanel, pos) + roleModelPanel:ShowRoleModel() -- 先Active 再加载模型以及播放动画 + local callback = function() + self.LoadModelCount = self.LoadModelCount - 1 + if self.LoadModelCount <= 0 then + self.BtnEnterFight:SetDisable(false) + end + end + -- 根据机器人id来更新模型 + if self.HasRobot then + local RobotIds = self:GetRobotIdsByProxy(self.CurrentStageId) + local robotId = RobotIds[pos] + local robotCfg = XRobotManager.GetRobotTemplate(robotId) + roleModelPanel:UpdateRobotModel(robotId, charId, callback, robotCfg.FashionId, robotCfg.WeaponId) + else + if self:IsRogueLikeType() and self.RogueLikeIsRobot then + roleModelPanel:UpdateCharacterModel(charId, nil, nil, nil, callback, self:GetRogueLikeFactionByCid(charId)) + elseif self:IsUnionKillType() then + self:UpdateUnionKillMode(roleModelPanel, pos, callback, charId) + else + if XRobotManager.CheckIsRobotId(charId) then + local robotId = charId + local robotCfg = XRobotManager.GetRobotTemplate(robotId) + roleModelPanel:UpdateRobotModel(robotId, robotCfg.CharacterId, callback, robotCfg.FashionId, robotCfg.WeaponId) + else + roleModelPanel:UpdateCharacterModel(charId, nil, nil, nil, callback) + end + end + end +end + +--更新耐力值 +function XUiNewRoomSingle:UpdateRoleStanmina(charId, index) + local maxStamina = 9 + local curStamina = 0 + if self.StageInfos.Type == XDataCenter.FubenManager.StageType.BossSingle then + maxStamina = XDataCenter.FubenBossSingleManager.GetMaxStamina() + curStamina = maxStamina - XDataCenter.FubenBossSingleManager.GetCharacterChallengeCount(charId) + elseif self.StageInfos.Type == XDataCenter.FubenManager.StageType.Explore then + maxStamina = XDataCenter.FubenExploreManager.GetMaxEndurance(XDataCenter.FubenExploreManager.GetCurChapterId()) + curStamina = maxStamina - XDataCenter.FubenExploreManager.GetEndurance(XDataCenter.FubenExploreManager.GetCurChapterId(), charId) + else + self["PanelStaminaBar" .. index].gameObject:SetActiveEx(false) + return + end + + local text = CSXTextManagerGetText("RoomStamina", curStamina, maxStamina) + self["TxtMyStamina" .. index].text = text + self["ImgStaminaExpFill" .. index].fillAmount = curStamina / maxStamina + self["PanelStaminaBar" .. index].gameObject:SetActiveEx(true) +end + +function XUiNewRoomSingle:SetAssistStatus(active) + if XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.OtherHelp) then + if active then + self.BtnSupportToggle:SetButtonState(XUiButtonState.Select) + else + self.BtnSupportToggle:SetButtonState(XUiButtonState.Normal) + end + end +end + +function XUiNewRoomSingle:ShowAssistToggle(show) + if show then + self.BtnSupportToggle.gameObject:SetActiveEx(true) + else + self.BtnSupportToggle.gameObject:SetActiveEx(false) + end +end + +function XUiNewRoomSingle:GetAssistStatus() + return self.BtnSupportToggle:GetToggleState() +end + +function XUiNewRoomSingle:SetWeakness() + self.PanelWeakness.gameObject:SetActiveEx(true) + + local eventDesc + if self.EventIds and #self.EventIds > 0 and self.EventIds[1] > 0 then + eventDesc = XRoomSingleManager.GetEvenDesc(self.EventIds[1]) + self.TxtWeaknessDesc.text = eventDesc + return + end + + eventDesc = XRoomSingleManager.GetEventDescByMapId(self.CurrentStageId) + if eventDesc then + self.TxtWeaknessDesc.text = eventDesc + else + self.PanelWeakness.gameObject:SetActiveEx(false) + end +end + +function XUiNewRoomSingle:SetCondition() + self.GridCondition.gameObject:SetActiveEx(false) + + local stageSuggestedConditionIds, stageForceConditionIds = XDataCenter.FubenManager.GetConditonByMapId(self.CurrentStageId) + for _, value in pairs(stageSuggestedConditionIds) do + table.insert(self.SuggestedConditionIds, value) + end + + for _, value in pairs(stageForceConditionIds) do + table.insert(self.ForceConditionIds, value) + end + + for _, id in pairs(self.SuggestedConditionIds) do + self:SetConditionGrid(id) + end + + for _, id in pairs(self.ForceConditionIds) do + self:SetConditionGrid(id) + end +end + +function XUiNewRoomSingle:SetConditionGrid(id) + local item = CS.UnityEngine.Object.Instantiate(self.GridCondition) + item.gameObject.transform:SetParent(self.PanelConditionContent, false) + local textDesc = item.gameObject.transform:Find("TxtDesc"):GetComponent("Text") + local _, desc = XConditionManager.CheckCondition(id, self.CurTeam.TeamData) + textDesc.text = desc + item.gameObject:SetActiveEx(true) +end + +function XUiNewRoomSingle:RefreshCaptainSkill() + -- 开启技能面板、队长头像、技能描述 + self.PanelSkill.gameObject:SetActiveEx(true) + self.PanelRole.gameObject:SetActiveEx(true) + self.TxtSkillDesc.gameObject:SetActiveEx(true) + + local teamMemberNum = self:GetCurTeamMemberNum() + local captainId = self:GetCaptainIdByProxy() + + -- 获取机器人为RobotId,玩家角色为CharacterId的队伍数据 + -- 如果代理没有实现该接口,且队伍拥有没有使用RobotId的机器人,则无法获取机器人配置的时装与解放等级数据,队长头像会使用初始头像 + local realCharData = self:GetRealCharDataByProxy() + if realCharData then + captainId = realCharData[self.CurTeam.CaptainPos] + end + + if captainId == nil or captainId <= 0 then + -- 当前队长位没有角色 + if teamMemberNum <= 0 then + -- 队伍内没有角色,隐藏技能面板 + self.PanelSkill.gameObject:SetActiveEx(false) + else + -- 队伍内还有其他角色,隐藏队长头像与技能描述 + self.PanelRole.gameObject:SetActiveEx(false) + self.TxtSkillDesc.gameObject:SetActiveEx(false) + + -- 队长技能名称更改为未选择队长 + self.TxtSkillName.text = CS.XTextManager.GetText("TeamDoNotChooseCaptain") + end + return + end + + -- 获取队长技能信息 + local captianSkillInfo + if not XRobotManager.CheckIsRobotId(captainId) then + captianSkillInfo = XDataCenter.CharacterManager.GetCaptainSkillInfo(captainId) + else + captianSkillInfo = XRobotManager.GetRobotCaptainSkillInfo(captainId) + end + + if captianSkillInfo == nil then + return + end + + -- 设置队长技能图标与名称 + self:SetUiSprite(self.ImgSkillIcon, captianSkillInfo.Icon) + self.TxtSkillName.text = captianSkillInfo.Name + + -- 设置队长头像与队长技能描述 + local head + local skillDesc + if not XRobotManager.CheckIsRobotId(captainId) then + if self.HasRobot or self.RogueLikeIsRobot then + -- 使用了CharacterId的机器人 + skillDesc = captianSkillInfo.Intro + -- 机器人使用了CharacterId,无法得知机器人的RobotId(获取终解等级与时装配置数据),使用初始头像代替 + head = XDataCenter.CharacterManager.GetDefaultCharSmallHeadIcon(captainId) + else + -- 玩家角色 + skillDesc = captianSkillInfo.Level > 0 and captianSkillInfo.Intro or CS.XTextManager.GetText("CaptainSkillLock") + head = XDataCenter.CharacterManager.GetCharSmallHeadIcon(captainId) + end + else + -- 使用了RobotId的机器人 + head = XRobotManager.GetRobotSmallHeadIcon(captainId) + skillDesc = captianSkillInfo.Intro + end + if head then + self.RImgCapIcon:SetRawImage(head) + end + if skillDesc then + self.TxtSkillDesc.text = skillDesc + end + +end + +function XUiNewRoomSingle:SetStageInfo() + local chapterName, stageName = XDataCenter.FubenManager.GetFubenNames(self.CurrentStageId) + self.TxtChapterName.text = chapterName + self.TxtStageName.text = stageName +end + +function XUiNewRoomSingle:InitEndurance() + if self.StageInfos.Type == XDataCenter.FubenManager.StageType.Explore then + if XDataCenter.FubenExploreManager.IsNodeFinish(XDataCenter.FubenExploreManager.GetCurChapterId(), XDataCenter.FubenExploreManager.GetCurNodeId()) then + self.PanelEndurance.gameObject:SetActiveEx(false) + else + self.PanelEndurance.gameObject:SetActiveEx(true) + self.TxtEnduranceNum.text = XDataCenter.FubenExploreManager.GetCurNodeEndurance() + end + else + self.PanelEndurance.gameObject:SetActiveEx(false) + end +end + +--更新战斗信息 +function XUiNewRoomSingle:InitCharacterInfo() + self:UpdateTeamBuff() + self:UpdatePartnerInfo() + self:UpdateFeatureInfo() + --机器人关卡不显示战斗信息 + if self.HasRobot or self:IsRogueLikeType() or self:IsUnionKillType() or self:IsNieRType() then + self.BtnShowInfoToggle.gameObject:SetActiveEx(false) + for i = 1, MAX_CHAR_COUNT do + self["CharacterInfo" .. i].gameObject:SetActiveEx(false) + end + self:InitCharacterInfoByProxy() + return + end + self.BtnShowInfoToggle.gameObject:SetActiveEx(true) + self.IsShowCharacterInfo = 0 + local key = "NewRoomShowInfoToggle" .. tostring(XPlayer.Id) + if CS.UnityEngine.PlayerPrefs.HasKey(key) then + self.IsShowCharacterInfo = CS.UnityEngine.PlayerPrefs.GetInt(key) + else + CS.UnityEngine.PlayerPrefs.SetInt(key, 0) + end + self:InitCharacterInfoByProxy() + self.PanelCombatPower = {} + self.TxtCombatPower = {} + self.ImgCombatPower = {} + for i = 1, MAX_CHAR_COUNT do + -- 位于角色右上方的战斗参数 + self.PanelCombatPower[i] = self["CharacterInfo" .. i] + self.TxtCombatPower[i] = self["TxtFight" .. i] + self.ImgCombatPower[i] = self["RImgType" .. i] + end + + + if self.IsShowCharacterInfo > 0 then + + self.BtnShowInfoToggle:SetButtonState(XUiButtonState.Select) + for i = 1, #self.CurTeam.TeamData do + if not XRobotManager.CheckIsRobotId(self.CurTeam.TeamData[i]) then + local character = XDataCenter.CharacterManager.GetCharacter(self.CurTeam.TeamData[i]) + if character == nil then + self.PanelCombatPower[i].gameObject:SetActiveEx(false) + else + self.PanelCombatPower[i].gameObject:SetActiveEx(true) + self.TxtCombatPower[i].text = math.floor(character.Ability) + self.ImgCombatPower[i]:SetRawImage(XCharacterConfigs.GetNpcTypeIcon(character.Type)) + end + elseif self.CurTeam.TeamData[i] > 0 then + local robotId = self.CurTeam.TeamData[i] + local robotData = XRobotManager.GetRobotTemplate(robotId) + local detailConfig = XCharacterConfigs.GetCharDetailTemplate(robotData.CharacterId) + local careerConfig = XCharacterConfigs.GetNpcTypeTemplate(detailConfig.Career) + if robotData == nil then + self.PanelCombatPower[i].gameObject:SetActiveEx(false) + else + self.PanelCombatPower[i].gameObject:SetActiveEx(true) + if self.Proxy and self.Proxy.GetCharAbility then + self.TxtCombatPower[i].text = self.Proxy.GetCharAbility(robotId) + else + self.TxtCombatPower[i].text = XRobotManager.GetRobotAbility(robotId) + end + self.ImgCombatPower[i]:SetRawImage(careerConfig.Icon) + end + else + self.PanelCombatPower[i].gameObject:SetActiveEx(false) + end + end + else + self.BtnShowInfoToggle:SetButtonState(XUiButtonState.Normal) + for i = 1, MAX_CHAR_COUNT do + self.PanelCombatPower[i].gameObject:SetActiveEx(false) + end + end +end + +function XUiNewRoomSingle:DefaultUpdatePartnerInfo() + if self.HasRobot or self:IsRogueLikeType() or self:IsUnionKillType() or self:IsNieRType() then + for i = 1, MAX_CHAR_COUNT do + local stageCfg = XDataCenter.FubenManager.GetStageCfg(self.CurrentStageId) + local robotId = stageCfg.RobotId[i] + if robotId then + local robotPartner = XRobotManager.GetRobotPartner(robotId) + self:ShowPartner(self["CharacterPets" .. i], robotPartner, true) + else + self["CharacterPets" .. i].gameObject:SetActiveEx(false) + end + end + return + end + + self.PanelPartner = {} + for i = 1, MAX_CHAR_COUNT do + self.PanelPartner[i] = self["CharacterPets" .. i] + end + + for i = 1, #self.CurTeam.TeamData do + if not XRobotManager.CheckIsRobotId(self.CurTeam.TeamData[i]) then + local character = XDataCenter.CharacterManager.GetCharacter(self.CurTeam.TeamData[i]) + if character == nil then + self.PanelPartner[i].gameObject:SetActiveEx(false) + else + self.PanelPartner[i].gameObject:SetActiveEx(true) + local partner = XDataCenter.PartnerManager.GetCarryPartnerEntityByCarrierId(character.Id) + self:ShowPartner(self.PanelPartner[i], partner, false) + end + elseif self.CurTeam.TeamData[i] > 0 then + local robotId = self.CurTeam.TeamData[i] + local robotData = XRobotManager.GetRobotTemplate(robotId) + local robotPartner = XRobotManager.GetRobotPartner(robotId) + + if robotData == nil then + self.PanelPartner[i].gameObject:SetActiveEx(false) + else + self.PanelPartner[i].gameObject:SetActiveEx(true) + self:ShowPartner(self.PanelPartner[i], robotPartner, true) + end + else + self.PanelPartner[i].gameObject:SetActiveEx(false) + end + end +end + +function XUiNewRoomSingle:DefaultUpdateFeatureInfo() + for i = 1, MAX_CHAR_COUNT do + self["CharacterFeature" .. i].gameObject:SetActiveEx(false) + end + + self.PanelStageFeature.gameObject:SetActiveEx(false) +end + +function XUiNewRoomSingle:ShowPartner(panel, partner, IsRobot) + if partner and next(partner) then + panel:GetObject("RImgType"):SetRawImage(partner:GetIcon()) + end + local IsHasPartner = partner and next(partner) + panel:GetObject("RImgType").gameObject:SetActiveEx(IsHasPartner) + panel.gameObject:SetActiveEx(IsHasPartner or (not IsRobot)) +end + +function XUiNewRoomSingle:OnBtnBackClick() + self:Close() +end + +function XUiNewRoomSingle:OnBtnMainUiClick() + if self.Proxy and self.Proxy.HandleBtnMainUiClick then + self.Proxy.HandleBtnMainUiClick() + return + else + XLuaUiManager.RunMain() + end +end + +function XUiNewRoomSingle:HandleCharClick(charPos) + if self:IsRogueLikeType() and self.RogueLikeIsRobot then + self:OnRogueLikeChangeRole(charPos) + return + end + if self:IsUnionKillType() then + self:OnUnionKillChangeRole(charPos) + return + end + -- 默认交给代理检查,否则目前单一检查是否为机器人 + if not self:CheckCharCanClickByProxy() then + return + end + + local teamData = XTool.Clone(self.CurTeam.TeamData) + local stageId = self.CurrentStageId + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + + if self:IsChessPursuit() then + XLuaUiManager.Open("UiRoomCharacter", teamData, charPos, function(resTeam) + self:UpdateTeam(resTeam) + end, stageInfo.Type, nil, { + IsHideQuitButton = self.ChessPursuitData.SceneUiType == XChessPursuitCtrl.SCENE_UI_TYPE.BOSS_ROUND, + RobotIdList = self.ChessPursuitData.RobotList, + MapId = self.ChessPursuitData.MapId, + TeamGridIndex = self.ChessPursuitData.TeamGridIndex, + SceneUiType = self.ChessPursuitData.SceneUiType, + }) + elseif self:IsBabelTower() then + self:OpenBabelRoomCharacter(teamData, charPos) + elseif self:IsWorldBossType() then + local worldBossActivity = XDataCenter.WorldBossManager.GetCurWorldBossActivity() + if worldBossActivity then + local robotBuffIdList = worldBossActivity:GetGetedRobotIdList() + local robotIdList = {} + for _, buffId in pairs(robotBuffIdList) do + local buffData = XDataCenter.WorldBossManager.GetWorldBossBuffById(buffId) + table.insert(robotIdList, buffData:GetCustomizeId()) + end + + XLuaUiManager.Open("UiRoomCharacter", teamData, charPos, function(resTeam) + self:UpdateTeam(resTeam) + end, stageInfo.Type, nil, { RobotIdList = robotIdList }) + end + elseif self:IsNieRType() then + local robotList = XDataCenter.NieRManager.GetChapterCharacterList(self.Args[1], self.Args[2]) + XLuaUiManager.Open("UiSelectCharacterWin", function(resTeam) + self:UpdateTeam(resTeam) + end, UiSelectCharacterType.NieROnlyRobot, teamData, charPos, robotList) + else + self:HandleCharClickByProxy(charPos) + end +end + +function XUiNewRoomSingle:OnBtnChar1Click() + self:HandleCharClick(CHAR_POS1) +end + +function XUiNewRoomSingle:OnBtnChar2Click() + self:HandleCharClick(CHAR_POS2) +end + +function XUiNewRoomSingle:OnBtnChar3Click() + self:HandleCharClick(CHAR_POS3) +end + +function XUiNewRoomSingle:GetTeamData() + return self.CurTeam +end + +-- 更新队伍 +function XUiNewRoomSingle:UpdateTeam(teamData, isUsePrefab) + for posId, val in pairs(teamData) do + local oldCharId = self.CurTeam.TeamData[posId] + if oldCharId and oldCharId > 0 and oldCharId ~= val then + -- 检查被替换的位置是否有角色,并且不相同 + self.PanelCharacterInfo[posId].RoleModelPanel:HideRoleModel() + end + end + + self.CurTeam.TeamData = XTool.Clone(teamData) + + self:UpdateTeamByProxy() + self:InitPanelTeam() -- 更新当前队伍显示状态 + + if self:IsBabelTower() then + local cb = self.BabelTowerData.Cb + if cb then + cb(teamData, self.CurTeam.CaptainPos, self.CurTeam.FirstFightPos) + end + elseif self:IsNieRType() then + XDataCenter.NieRManager.SetPlayerTeamData(self.CurTeam, self.CurrentStageId) + elseif self:IsChessPursuit() then + XDataCenter.ChessPursuitManager.SetPlayerTeamData(self.CurTeam, self.ChessPursuitData.MapId, self.ChessPursuitData.TeamGridIndex, isUsePrefab) + elseif self:GetIsSaveTeamData() then + XDataCenter.TeamManager.SetPlayerTeam(self.CurTeam, false) -- 保存数据 + end + --更新角色信息面板 + self:InitCharacterInfo() +end + +function XUiNewRoomSingle:UpdateTeamBuff() + local teamBuffId = self.TeamBuffId + + if not teamBuffId or teamBuffId <= 0 then + self.PanelTeamBuff.gameObject:SetActiveEx(false) + return + end + + local maxCount = XFubenConfigs.GetTeamBuffMaxBuffCount(teamBuffId) + if maxCount <= 0 then + self.PanelTeamBuff.gameObject:SetActiveEx(false) + return + end + + self.PanelTeamBuff.gameObject:SetActiveEx(true) + + local fitCount = XFubenConfigs.GetTeamBuffFitCharacterCount(teamBuffId, self.CurTeam.TeamData) + local isBuffOn = fitCount > 0 + self.PanelTeamBuffOn.gameObject:SetActiveEx(isBuffOn) + self.PanelTeamBuffOff.gameObject:SetActiveEx(not isBuffOn) + self.TxtTeamBuff.text = CSXTextManagerGetText("NewRoomSingleTeamBuffDes", fitCount, maxCount) +end + +function XUiNewRoomSingle:UpdateTeamPrefab(team) + self:OnClickTabCallBack(team.CaptainPos) + self.PanelTabCaptain:SelectIndex(team.FirstFightPos) + + if self:IsUnionKillType() then + self:UpdateUnionKillTeamCache(team.TeamData) + end + self:UpdateTeam(team.TeamData, true) +end + +function XUiNewRoomSingle:PlayTips(key, isOn) + local msg = CSXTextManagerGetText(key) + self.TxtTips1.text = isOn and msg or "" + self.TxtTips2.text = isOn and "" or msg + self.PanelTip.gameObject:SetActiveEx(true) + + self:PlayAnimation("PanelTipEnable", handler(self, function() + self.PanelTip.gameObject:SetActiveEx(false) + end)) +end + +function XUiNewRoomSingle:CheckHasRobot() + if self.HasRobot then + local text = CSXTextManagerGetText("NewRoomSingleCannotSetRobot") + XUiManager.TipError(text) + end + return self.HasRobot +end + +function XUiNewRoomSingle:OnBtnEnterFightClick() + -- 进战前检查 + if not self:CheckEnterFightByProxy() then + return + end + + -- 巴别塔进入战斗 + if self:IsBabelTower() then + self:HandleEnterBabelTower() + return + end + + if self:GetIsCheckCaptainIdAndFirstFightId() then + local captainId = self:GetTeamCaptainId() + local firstFightId = self:GetTeamFirstFightId() + -- 检查队长位与首发位是否为空 + if captainId == nil or captainId <= 0 then + XUiManager.TipText("TeamManagerCheckCaptainNil") + return + end + if firstFightId == nil or firstFightId <= 0 then + XUiManager.TipText("TeamManagerCheckFirstFightNil") + return + end + end + + if not XDataCenter.FubenManager.CheckFightConditionByTeamData(self.ForceConditionIds, self.CurTeam.TeamData) then + return + end + + if not self:CheckRoleStanmina() then + return + end + + local stage = XDataCenter.FubenManager.GetStageCfg(self.CurrentStageId) + local isAssist = self:GetAssistStatus() + + if self.StageInfos.Type == XDataCenter.FubenManager.StageType.Explore then + XDataCenter.FubenExploreManager.SetCurTeam(self.CurTeam) + end + + if self.StageInfos.Type == XDataCenter.FubenManager.StageType.Daily then + XDataCenter.FubenDailyManager.SetFubenDailyRecord(self.CurrentStageId) + end + + -- 狙击战进入战斗相关 + if self:IsUnionKillType() then + self:HandleEnterUnionKill(stage) + return + end + + -- 爬塔玩法出站人数必须为3人 + if self:IsRogueLikeType() then + self:HandleEnterRogueLike(stage) + return + end + + --追击玩法 + if self:IsChessPursuit() then + self:HandleSaveChessPursuit(stage) + return + end + + -- 世界boss进入战斗 + if self:IsWorldBossType() then + self:HandleEnterWorldBoss(stage) + return + end + + -- 尼尔玩法进入战斗 + if self:IsNieRType() then + self:HandleEnterNieR(stage) + return + end + + --跑团BOSS进入战斗 + if XTRPGConfigs.IsBossStage(self.CurrentStageId) then + self:HandleEnterTRPGWorldBoss(stage) + return + end + + --杀戮无双进入战斗 + if self:IsKillZone() then + self:HandleEnterKillZone(stage) + return + end + + --特训关检查是否超时 + if self:IsSpecialTrain() then + if XDataCenter.FubenSpecialTrainManager.CheckActivityTimeout(XDataCenter.FubenSpecialTrainManager.CurActiveId, true) then + return + end + end + + --战力警告 + if self.FightControlResult == XUiFightControlState.Ex then + local data = XFubenConfigs.GetStageFightControl(self.StageCfg.FightControlId) + local contenttext + --计算战力 + local teamAbility = {} + for i = 1, #self.CurTeam.TeamData do + local character = XDataCenter.CharacterManager.GetCharacter(self.CurTeam.TeamData[i]) + if character == nil then + table.insert(teamAbility, 0) + else + table.insert(teamAbility, character.Ability) + end + end + + if data.MaxRecommendFight > 0 then + contenttext = CSXTextManagerGetText("Insufficient", data.MaxShowFight) + elseif data.AvgRecommendFight > 0 then + local count = 0 + for _, v in pairs(teamAbility) do + if v > 0 then + if v < data.AvgShowFight then + count = count + 1 + end + end + end + contenttext = CSXTextManagerGetText("AvgInsufficient", count, data.AvgShowFight) + else + contenttext = CSXTextManagerGetText("Insufficient", data.ShowFight) + end + + local titletext = CSXTextManagerGetText("AbilityInsufficient") + XUiManager.DialogTip(titletext, contenttext, XUiManager.DialogType.Normal, nil, function() + XDataCenter.FubenManager.EnterFight(stage, self.CurTeam.TeamId, isAssist, self.ChallengeCount) + end) + else + XDataCenter.FubenManager.EnterFight(stage, self.CurTeam.TeamId, isAssist, self.ChallengeCount, self.ChallengeId) + end +end + +function XUiNewRoomSingle:CheckRoleStanmina() + if self.StageInfos.Type == XDataCenter.FubenManager.StageType.BossSingle then + for i = 1, MAX_CHAR_COUNT do + local posData = self.CurTeam.TeamData[i] + if posData and posData > 0 then + local curStamina = XDataCenter.FubenBossSingleManager.GetMaxStamina() - XDataCenter.FubenBossSingleManager.GetCharacterChallengeCount(posData) + if curStamina <= 0 then + local charName = XCharacterConfigs.GetCharacterName(posData) + local text = CSXTextManagerGetText("BossSingleNoStamina", charName) + XUiManager.TipError(text) + return false + end + end + end + end + + return true +end + +-- 获取当前队伍的角色数 +function XUiNewRoomSingle:GetCurTeamMemberNum() + local count = 0 + for _, id in pairs(self.CurTeam.TeamData) do + if id > 0 then + count = count + 1 + end + end + return count +end + +--------------------------------------------------------------------------------------------------------------------------狙击战相关 +function XUiNewRoomSingle:IsUnionKillType() + return self.StageInfos.Type == XDataCenter.FubenManager.StageType.UnionKill +end + +function XUiNewRoomSingle:UpdateTeamCaptionPos() + local teamCache = XDataCenter.FubenUnionKillManager.GetCacheTeam() + local captainPos = self.CurTeam.CaptainPos + for i = 1, MAX_CHAR_COUNT do + local memberInfo = teamCache[i] + if memberInfo then + memberInfo.IsTeamLeader = captainPos == i + end + end +end + +-- 初始化阵容 +function XUiNewRoomSingle:UnionKillInitTeam(curTeam) + -- UiUnionKillTipCardShare + -- + -- 显示共享角色 + -- + local fightData = XDataCenter.FubenUnionKillManager.GetCurRoomData() + if fightData and fightData.UnionKillPlayerInfos and not fightData.IsShowShareCharacter then + local shareInfos = {} + for _, v in pairs(fightData.UnionKillPlayerInfos) do + if v.Id ~= XPlayer.Id then + table.insert(shareInfos, v.ShareNpcData) + end + end + if #shareInfos > 0 then + XLuaUiManager.Open("UiUnionKillTipCardShare", shareInfos) + end + fightData.IsShowShareCharacter = true + end + + local isTrialBoss = XDataCenter.FubenUnionKillManager.IsTrialStage(self.CurrentStageId) and XDataCenter.FubenUnionKillManager.CurIsTrialBoss() + local isUseShare = XDataCenter.FubenUnionKillManager.GetTrialUseShare() + -- 是试炼关清掉共享角色 + if isTrialBoss and not isUseShare then + local adjustCache = {} + local shareTeamCache = XDataCenter.FubenUnionKillManager.GetCacheTeam() + for i = 1, MAX_CHAR_COUNT do + local characterInfo = shareTeamCache[i] + if characterInfo and not characterInfo.IsShare then + adjustCache[i] = {} + adjustCache[i].CharacterId = characterInfo.CharacterId + adjustCache[i].IsShare = false + adjustCache[i].PlayerId = characterInfo.PlayerId + adjustCache[i].IsTeamLeader = characterInfo.IsTeamLeader + end + end + XDataCenter.FubenUnionKillManager.UpdateCacheTeam(adjustCache) + end + + local unionTeam = XTool.Clone(curTeam) + local teamCache = XDataCenter.FubenUnionKillManager.GetCacheTeam() + unionTeam.CaptainPos = 1 + for i = 1, MAX_CHAR_COUNT do + unionTeam.TeamData[i] = 0 + local characterInfo = teamCache[i] + if characterInfo then + unionTeam.TeamData[i] = characterInfo.CharacterId + if characterInfo.IsTeamLeader then + unionTeam.CaptainPos = i + end + end + end + + curTeam = unionTeam + return curTeam +end + +-- 缓存阵容切换 +function XUiNewRoomSingle:SwitchCacheTeam(changeIndex, targetIndex) + local teamCache = XDataCenter.FubenUnionKillManager.GetCacheTeam() + local temp = teamCache[changeIndex] + teamCache[changeIndex] = teamCache[targetIndex] + teamCache[targetIndex] = temp + for i = 1, MAX_CHAR_COUNT do + local characterInfo = teamCache[i] + if characterInfo then + characterInfo.IsTeamLeader = i == self.CurTeam.CaptainPos + end + end +end + +-- 狙击战换人 +function XUiNewRoomSingle:OnUnionKillChangeRole(index) + + local args = {} + args.StageId = self.CurrentStageId + args.DefaultSelectId = self.CurTeam.TeamData[index] + args.Index = index + args.CallBack = function(selectItem, isJoin) + self:OnUnionKillSelectRole(index, selectItem, isJoin) + end + + args.InTeamList = {} + args.CharacterInTeamList = {} + local teamCache = XDataCenter.FubenUnionKillManager.GetCacheTeam() + for i = 1, MAX_CHAR_COUNT do + if teamCache[i] then + local characterId = teamCache[i].CharacterId + local playerId = teamCache[i].PlayerId + local key = string.format("%s_%s", tostring(playerId), tostring(characterId)) + args.InTeamList[key] = true + args.CharacterInTeamList[tostring(characterId)] = true + end + end + if teamCache[index] then + args.DefaultSelectOwner = teamCache[index].PlayerId + else + args.DefaultSelectOwner = XPlayer.Id + end + + -- 我的角色 + args.CharacterList = {} + local ownCharacters = XDataCenter.CharacterManager.GetOwnCharacterList() + for _, v in pairs(ownCharacters or {}) do + table.insert(args.CharacterList, { + Id = v.Id, + OwnerId = XPlayer.Id, + Flag = XFubenUnionKillConfigs.UnionKillCharType.Own, + Ability = math.floor(v.Ability) + }) + end + + -- 共享角色 + local unionFightRoomData = XDataCenter.FubenUnionKillManager.GetCurRoomData() + local isTrialBoss = XDataCenter.FubenUnionKillManager.IsTrialStage(self.CurrentStageId) and XDataCenter.FubenUnionKillManager.CurIsTrialBoss() + local isUseShare = XDataCenter.FubenUnionKillManager.GetTrialUseShare() + local dontShare = isTrialBoss and not isUseShare + if unionFightRoomData and not dontShare then + for id, playerInfo in pairs(unionFightRoomData.UnionKillPlayerInfos or {}) do + if id ~= XPlayer.Id then + local character = playerInfo.ShareNpcData.Character + table.insert(args.CharacterList, { + Id = character.Id, + OwnerId = id, + Flag = XFubenUnionKillConfigs.UnionKillCharType.Share, + OwnerInfo = playerInfo, + Ability = math.floor(character.Ability) + }) + end + end + end + + XLuaUiManager.Open("UiUnionKillXuanRen", args) +end + +function XUiNewRoomSingle:UpdateUnionKillTeamCache(teamData) + local teamCache = XDataCenter.FubenUnionKillManager.GetCacheTeam() + for i = 1, MAX_CHAR_COUNT do + if teamData[i] and teamData[i] > 0 then + teamCache[i] = {} + teamCache[i].CharacterId = teamData[i] + teamCache[i].IsShare = false + teamCache[i].PlayerId = XPlayer.Id + teamCache[i].IsTeamLeader = self.CurTeam.CaptainPos == i + else + teamCache[i] = nil + end + end +end + +-- 选中角色 +function XUiNewRoomSingle:OnUnionKillSelectRole(index, selectItem, isJoin) + local teamCache = XDataCenter.FubenUnionKillManager.GetCacheTeam() + if selectItem then + if isJoin then + local oldIndex + local oldItem + for i = 1, MAX_CHAR_COUNT do + local cacheItem = teamCache[i] + if cacheItem then + if selectItem.OwnerId == cacheItem.PlayerId and selectItem.Id == cacheItem.CharacterId and i ~= index then + oldIndex = i + oldItem = cacheItem + break + end + end + end + if oldIndex and oldItem then + teamCache[oldIndex] = teamCache[index] + end + teamCache[index] = {} + teamCache[index].CharacterId = selectItem.Id + teamCache[index].IsShare = selectItem.Flag == XFubenUnionKillConfigs.UnionKillCharType.Share + teamCache[index].PlayerId = selectItem.OwnerId + teamCache[index].IsTeamLeader = self.CurTeam.CaptainPos == index + if selectItem.Flag == XFubenUnionKillConfigs.UnionKillCharType.Share then + local unionFightRoomData = XDataCenter.FubenUnionKillManager.GetCurRoomData() + if unionFightRoomData and unionFightRoomData.UnionKillPlayerInfos then + local playerInfo = unionFightRoomData.UnionKillPlayerInfos[selectItem.OwnerId] + if playerInfo then + teamCache[index].Character = playerInfo.ShareNpcData.Character + end + end + else + teamCache[index].Character = nil + end + else + teamCache[index] = nil + end + end + + -- 更新 + local teamData = {} + for i = 1, MAX_CHAR_COUNT do + if teamCache[i] then + teamData[i] = teamCache[i].CharacterId + else + teamData[i] = 0 + end + end + self:UpdateTeam(teamData) +end + +-- 更新狙击战模型 +function XUiNewRoomSingle:UpdateUnionKillMode(roleModelPanel, pos, callback, defaultCharId) + local teamCache = XDataCenter.FubenUnionKillManager.GetCacheTeam() + local teamItem = teamCache[pos] + if teamItem and teamItem.IsShare then + local playerId = teamItem.PlayerId + local fashionId + local shareNpcData + local unionFightRoomData = XDataCenter.FubenUnionKillManager.GetCurRoomData() + if unionFightRoomData and unionFightRoomData.UnionKillPlayerInfos then + local playerInfo = unionFightRoomData.UnionKillPlayerInfos[playerId] + if playerInfo then + fashionId = playerInfo.ShareNpcData.Character.FashionId + shareNpcData = playerInfo.ShareNpcData + end + end + + local roleModelLoadedCb = function(model) + if shareNpcData then + roleModelPanel:UpdateEquipsModelsByFightNpcData(model, shareNpcData) + end + end + + roleModelPanel:UpdateCharacterModel(defaultCharId, nil, nil, roleModelLoadedCb, callback, fashionId) + else + local characterInfo = XDataCenter.CharacterManager.GetCharacter(teamItem.CharacterId) + roleModelPanel:UpdateCharacterModel(defaultCharId, nil, nil, nil, callback, characterInfo.FashionId) + end +end + +-- 狙击战进入战斗 +function XUiNewRoomSingle:HandleEnterUnionKill(stage) + local teamCache = XDataCenter.FubenUnionKillManager.GetCacheTeam() + XDataCenter.FubenManager.EnterUnionKillFight(stage, self.CurTeam, teamCache, function() + -- 进入战斗请求后续处理 + end) +end + +--------------------------------------------------------------------------------------------------------------------------爬塔活动相关 +-- 初始化阵容 +function XUiNewRoomSingle:RogueLikeInitTeam(curTeam) + local rogueLikeTeam = XTool.Clone(curTeam) + local characterInfos = XDataCenter.FubenRogueLikeManager.GetCharacterInfos() + for i = 1, MAX_CHAR_COUNT do + local characterInfo = characterInfos[i] + if characterInfo then + rogueLikeTeam.TeamData[characterInfo.TeamPos] = characterInfo.Id + if characterInfo.Captain == 1 then + rogueLikeTeam.CaptainPos = characterInfo.TeamPos + end + if characterInfo.FirstFight == 1 then + rogueLikeTeam.FirstFightPos = characterInfo.TeamPos + end + else + rogueLikeTeam.TeamData[i] = 0 + end + end + curTeam = rogueLikeTeam + return curTeam +end + + +-- 爬塔活动玩法 +function XUiNewRoomSingle:IsRogueLikeType() + return self.StageInfos.Type == XDataCenter.FubenManager.StageType.RogueLike +end + +function XUiNewRoomSingle:IsRogueLikeIsTiral() + return XDataCenter.FubenRogueLikeManager.IsSectionPurgatory() +end + +-- 特训关活动玩法 +function XUiNewRoomSingle:IsSpecialTrain() + return self.StageInfos.Type == XDataCenter.FubenManager.StageType.SpecialTrain +end + +--追击玩法 +function XUiNewRoomSingle:IsChessPursuit() + return self.StageCfg.StageType == XDataCenter.FubenManager.StageType.ChessPursuit +end + +--世界boss玩法 +function XUiNewRoomSingle:IsWorldBossType() + return self.StageInfos.Type == XDataCenter.FubenManager.StageType.WorldBoss +end + +--尼尔玩法 +function XUiNewRoomSingle:IsNieRType() + return self.StageInfos.Type == XDataCenter.FubenManager.StageType.NieR +end + +--杀戮无双 +function XUiNewRoomSingle:IsKillZone() + return self.StageInfos.Type == XDataCenter.FubenManager.StageType.KillZone +end + +-- 更换爬塔助战角色 +function XUiNewRoomSingle:OnRogueLikeChangeRole(index) + local currentActivityId = XDataCenter.FubenRogueLikeManager.GetRogueLikeActivityId() + local activityTemplate = XFubenRogueLikeConfig.GetRougueLikeTemplateById(currentActivityId) + local args = {} + args.TeamSelectPos = index + args.TeamCharIdMap = self.ChooseRobots + args.Type = XFubenRogueLikeConfig.SelectCharacterType.Robot + args.CharacterLimitType = activityTemplate.CharacterLimitType + args.LimitBuffId = XFubenConfigs.GetLimitShowBuffId(activityTemplate.LimitBuffId) + args.CallBack = function(selectId, isJoin, isReset) + self:HandleSelectRobot(index, selectId, isJoin, isReset) + end + XLuaUiManager.Open("UiRogueLikeRoomCharacter", args) +end + +-- 选完机器人回来 +function XUiNewRoomSingle:HandleSelectRobot(index, selectRobot, isJoin, isReset) + if isReset then + self.ChooseRobots = {} + end + + if isJoin then + local oldIndex + local oldRobot + for k, v in pairs(self.ChooseRobots) do + if k ~= index and v == selectRobot then + oldIndex = k + oldRobot = v + break + end + end + if oldIndex and oldRobot then + self.ChooseRobots[oldIndex] = self.ChooseRobots[index] + self.ChooseRobots[index] = selectRobot + else + self.ChooseRobots[index] = selectRobot + end + + else + self.ChooseRobots[index] = nil + end + -- 更新 + local teamData = {} + for i = 1, MAX_CHAR_COUNT do + local robotId = self.ChooseRobots[i] + if robotId then + local characterId = XRobotManager.GetCharacterId(robotId) + teamData[i] = characterId + else + teamData[i] = 0 + end + end + self:UpdateTeam(teamData) +end + +function XUiNewRoomSingle:GetRogueLikeFactionByCid(cid) + local factionId + for i = 1, MAX_CHAR_COUNT do + local robotId = self.ChooseRobots[i] + if robotId then + local robotTemplate = XRobotManager.GetRobotTemplate(robotId) + if robotTemplate and cid == robotTemplate.CharacterId then + factionId = robotTemplate.FashionId + break + end + + end + end + return factionId +end + +-- 爬塔活动切换助战角色 +function XUiNewRoomSingle:OnBtnSwitchRoleClick() + if not self:CanRogueLikeSwitchAssist() and not self.RogueLikeIsRobot then + XUiManager.TipMsg(CSXTextManagerGetText("RogueLikeNeed3SupportChars")) + return + end + self.RogueLikeIsRobot = not self.RogueLikeIsRobot + if self.CurTeam then + local teamData = {} + self.PanelTeamLeader.gameObject:SetActiveEx(not self.RogueLikeIsRobot) + self.PanelBtnLeader.gameObject:SetActiveEx(not self.RogueLikeIsRobot) + if self.RogueLikeIsRobot then + for i = 1, MAX_CHAR_COUNT do + local robotId = self.ChooseRobots[i] + if robotId then + local characterId = XRobotManager.GetCharacterId(robotId) + teamData[i] = characterId + else + teamData[i] = 0 + end + end + + -- 设置队长位与首发位为1 + self.CurTeam.CaptainPos = 1 + self.CurTeam.FirstFightPos = 1 + + self:InitPanelTeam() + self:SetRogueLikeRobotTips() + else + -- 获取NotifyRogueLikeData下发的参战列表,并检查是不是首发或者队长 + -- 切换队长与首发时,爬塔活动不保存阵容,只在开始战斗时保存阵容 + local characterInfos = XDataCenter.FubenRogueLikeManager.GetCharacterInfos() + for i = 1, MAX_CHAR_COUNT do + local characterInfo = characterInfos[i] + if characterInfo then + teamData[characterInfo.TeamPos] = characterInfo.Id + if characterInfo.Captain == 1 then + self.CurTeam.CaptainPos = characterInfo.TeamPos + self:InitPanelTeam() + end + + if characterInfo.FirstFight == 1 then + self.CurTeam.FirstFightPos = characterInfo.TeamPos + self:InitPanelTeam() + end + else + teamData[i] = 0 + end + end + self:SetRogueLikeCharacterTips() + end + self:UpdateTeam(teamData) + self:PlayAnimation("AnimEnable") + self.BtnSwitchRole01.gameObject:SetActiveEx(not self.RogueLikeIsRobot) + self.BtnSwitchRole02.gameObject:SetActiveEx(self.RogueLikeIsRobot) + end +end + +function XUiNewRoomSingle:SetSwitchRole() + self.RogueLikeIsRobot = false + self.BtnSwitchRole01.gameObject:SetActiveEx(not self.RogueLikeIsRobot and self:IsRogueLikeType() and not self:IsRogueLikeIsTiral()) + self.BtnSwitchRole02.gameObject:SetActiveEx(self.RogueLikeIsRobot and self:IsRogueLikeType() and not self:IsRogueLikeIsTiral()) + self.BtnSwitchRole01:SetDisable(not self:CanRogueLikeSwitchAssist()) + self.ChooseRobots = {} + if #self.ChooseRobots < MAX_CHAR_COUNT then + local robots = XDataCenter.FubenRogueLikeManager.GetAssistRobots() + for i = 1, MAX_CHAR_COUNT do + self.ChooseRobots[i] = robots[i] and robots[i].Id or nil + end + end + + local teamPrefabState = (self:IsRogueLikeType() or self:IsWorldBossType()) and XUiButtonState.Disable or XUiButtonState.Normal + self.BtnTeamPrefab:SetButtonState(teamPrefabState) + + if self.PanelRogueLike then + self.PanelRogueLike.gameObject:SetActiveEx(self:IsRogueLikeType()) + if self.RogueLikeIsRobot then + self:SetRogueLikeRobotTips() + else + self:SetRogueLikeCharacterTips() + end + end +end + +function XUiNewRoomSingle:SetRogueLikeCharacterTips() + local activityId = XDataCenter.FubenRogueLikeManager.GetRogueLikeActivityId() + if not activityId then return end + local activityTemplate = XFubenRogueLikeConfig.GetRougueLikeTemplateById(activityId) + if not activityTemplate then return end + self.PanelEnduranceRogueLike.gameObject:SetActiveEx(not self:IsRogueLikeIsTiral()) + self.TxtActionPointNum.text = CSXTextManagerGetText("RogueLikeCostAction", activityTemplate.FightNeedPoint) + self.TxtTeamMemberCount.text = CSXTextManagerGetText("RogueLikeTeamNeedCount", XDataCenter.FubenRogueLikeManager:GetTeamMemberCount()) +end + +function XUiNewRoomSingle:SetRogueLikeRobotTips() + --self.PanelEnduranceRogueLike.gameObject:SetActiveEx(false) + local activityId = XDataCenter.FubenRogueLikeManager.GetRogueLikeActivityId() + if not activityId then return end + local activityTemplate = XFubenRogueLikeConfig.GetRougueLikeTemplateById(activityId) + if not activityTemplate then return end + self.TxtActionPointNum.text = CSXTextManagerGetText("RogueLikeCostAction", activityTemplate.FightNeedPoint) --CSXTextManagerGetText("RogueLikeNotCostAction") + self.TxtTeamMemberCount.text = CSXTextManagerGetText("RogueLikeDefaultSupportChar") +end + +-- 是否为爬塔并且不可以切换上阵角色 +function XUiNewRoomSingle:IsRogueLikeLockCharacter() + return self:IsRogueLikeType() and XDataCenter.FubenRogueLikeManager.IsRogueLikeCharacterLock() +end + +-- 是否为爬塔并且可以切换为助战角色 +function XUiNewRoomSingle:CanRogueLikeSwitchAssist() + return self:IsRogueLikeType() and XDataCenter.FubenRogueLikeManager.CanSwitch2Assist() +end + +-- 爬塔进入战斗并保存阵容 +function XUiNewRoomSingle:HandleEnterRogueLike(stage) + local curTeamMemberCount = 0 + local isAssist = self.RogueLikeIsRobot and 1 or 0 + for i = 1, #self.CurTeam.TeamData do + if self.CurTeam.TeamData[i] > 0 then + curTeamMemberCount = curTeamMemberCount + 1 + end + end + if XDataCenter.FubenRogueLikeManager.GetTeamMemberCount() > curTeamMemberCount then + XUiManager.TipMsg(CSXTextManagerGetText("RogueLikeTeamMaxMember")) + return + end + + XDataCenter.FubenRogueLikeManager.UpdateRogueLikeStageRobots(self.CurrentStageId, isAssist, self.ChooseRobots) + + -- function参数是PreFightRequest协议返回之后的回调函数 + XDataCenter.FubenManager.EnterRogueLikeFight(stage, self.CurTeam, isAssist, self.NodeId, function() + for _, robotId in pairs(self.ChooseRobots or {}) do + XDataCenter.FubenRogueLikeManager.UpdateNewRobots(robotId) + end + -- 非机器人 + -- 更新位置、队长位置、首发位置 + if not self.RogueLikeIsRobot then + local id2Index = {} + local characterInfos = XDataCenter.FubenRogueLikeManager.GetCharacterInfos() + for i = 1, #self.CurTeam.TeamData do + id2Index[self.CurTeam.TeamData[i]] = i + end + for i = 1, #characterInfos do + local characterInfo = characterInfos[i] + local characterId = characterInfo.Id + characterInfo.TeamPos = id2Index[characterId] + characterInfo.Captain = (self.CurTeam.CaptainPos == id2Index[characterId]) and 1 or 0 + characterInfo.FirstFight = (self.CurTeam.FirstFightPos == id2Index[characterId]) and 1 or 0 + end + end + end) +end + +function XUiNewRoomSingle:HandleSaveChessPursuit(stage) + if self.CurTeam.TeamData[self.CurTeam.CaptainPos] == nil or self.CurTeam.TeamData[self.CurTeam.CaptainPos] <= 0 then + XUiManager.TipText("TeamManagerCheckCaptainNil") + return + end + if self.CurTeam.TeamData[self.CurTeam.FirstFightPos] == nil or self.CurTeam.TeamData[self.CurTeam.FirstFightPos] <= 0 then + XUiManager.TipText("TeamManagerCheckFirstFightNil") + return + end + + if self.ChessPursuitData.SceneUiType == XChessPursuitCtrl.SCENE_UI_TYPE.BOSS_ROUND then + XDataCenter.ChessPursuitManager.RequestChessPursuitChangeTeam(self.ChessPursuitData.TeamGridIndex) + else + XDataCenter.ChessPursuitManager.SaveTempTeamData(self.ChessPursuitData.MapId) + end + + self:Close() +end + +-- 世界boss进入战斗,检查队长位与首发位是否为空 +function XUiNewRoomSingle:HandleEnterWorldBoss(stage) + if self.CurTeam.TeamData[self.CurTeam.CaptainPos] == nil or self.CurTeam.TeamData[self.CurTeam.CaptainPos] <= 0 then + XUiManager.TipText("TeamManagerCheckCaptainNil") + return + end + if self.CurTeam.TeamData[self.CurTeam.FirstFightPos] == nil or self.CurTeam.TeamData[self.CurTeam.FirstFightPos] <= 0 then + XUiManager.TipText("TeamManagerCheckFirstFightNil") + return + end + local stageLevel = XDataCenter.WorldBossManager.GetBossStageLevel() + XDataCenter.FubenManager.EnterWorldBossFight(stage, self.CurTeam, stageLevel) +end + +-- 尼尔玩法进入战斗,检查队长位与首发位是否为空 +function XUiNewRoomSingle:HandleEnterNieR(stage) + if self.CurTeam.TeamData[self.CurTeam.CaptainPos] == nil or self.CurTeam.TeamData[self.CurTeam.CaptainPos] <= 0 then + XUiManager.TipText("TeamManagerCheckCaptainNil") + return + end + if self.CurTeam.TeamData[self.CurTeam.FirstFightPos] == nil or self.CurTeam.TeamData[self.CurTeam.FirstFightPos] <= 0 then + XUiManager.TipText("TeamManagerCheckFirstFightNil") + return + end + XDataCenter.FubenManager.EnterNieRFight(stage, self.CurTeam) +end + +-- 跑团世界boss进入战斗,检查队长位与首发位是否为空 +function XUiNewRoomSingle:HandleEnterTRPGWorldBoss(stage) + if self.CurTeam.TeamData[self.CurTeam.CaptainPos] == nil or self.CurTeam.TeamData[self.CurTeam.CaptainPos] <= 0 then + XUiManager.TipText("TeamManagerCheckCaptainNil") + return + end + if self.CurTeam.TeamData[self.CurTeam.FirstFightPos] == nil or self.CurTeam.TeamData[self.CurTeam.FirstFightPos] <= 0 then + XUiManager.TipText("TeamManagerCheckFirstFightNil") + return + end + XDataCenter.FubenManager.EnterTRPGWorldBossFight(stage, self.CurTeam) +end + +function XUiNewRoomSingle:HandleEnterKillZone(stage) + if self.CurTeam.TeamData[self.CurTeam.CaptainPos] == nil or self.CurTeam.TeamData[self.CurTeam.CaptainPos] <= 0 then + XUiManager.TipText("TeamManagerCheckCaptainNil") + return + end + if self.CurTeam.TeamData[self.CurTeam.FirstFightPos] == nil or self.CurTeam.TeamData[self.CurTeam.FirstFightPos] <= 0 then + XUiManager.TipText("TeamManagerCheckFirstFightNil") + return + end + XDataCenter.FubenManager.EnterKillZoneFight(stage, self.CurTeam) +end + +function XUiNewRoomSingle:GetCharacterLimitType() + if self:IsRogueLikeType() then + local currentActivityId = XDataCenter.FubenRogueLikeManager.GetRogueLikeActivityId() + local activityTemplate = XFubenRogueLikeConfig.GetRougueLikeTemplateById(currentActivityId) + return activityTemplate.CharacterLimitType + end + + local stageId = self.CurrentStageId + return stageId and XFubenConfigs.GetStageCharacterLimitType(stageId) +end + +function XUiNewRoomSingle:OnClickBtnTeamBuff() + XLuaUiManager.Open("UiRoomTeamBuff", self.TeamBuffId) +end + +function XUiNewRoomSingle:InitWorldBoss() + if not self:IsWorldBossType() then return end + self.BtnTeamPrefab.gameObject:SetActiveEx(false) +end + +function XUiNewRoomSingle:OnGetEvents() + return { XEventId.EVENT_ACTIVITY_ON_RESET } +end + +function XUiNewRoomSingle:OnNotify(evt, ...) + local args = { ... } + if evt == XEventId.EVENT_ACTIVITY_ON_RESET then + self:OnResetEvent(args[1]) + end +end + +function XUiNewRoomSingle:IsBabelTower() + return self.StageInfos.Type == XDataCenter.FubenManager.StageType.BabelTower +end + +function XUiNewRoomSingle:InitPanelBabelTower() + if not self:IsBabelTower() then + self.PanelBabel.gameObject:SetActiveEx(false) + return + end + self.PanelBabel.gameObject:SetActiveEx(true) + self.BtnTeamPrefab.gameObject:SetActiveEx(false) + + self.BabelTowerPanel = XUiPanelBabelTower.New(self.PanelBabel, self.CurrentStageId, self.CurTeam.TeamData) + self.BtnEnterFight:SetNameByGroup(0, CSXTextManagerGetText("BabelTowerNewRoomBtnName")) +end + +function XUiNewRoomSingle:InitChessPursuit() + if not self:IsChessPursuit() then + return + end + + self.BtnTeamPrefab.gameObject:SetActiveEx(self.ChessPursuitData.SceneUiType == XChessPursuitCtrl.SCENE_UI_TYPE.BUZHEN) + self.BtnEnterFight:SetNameByGroup(0, CSXTextManagerGetText("ChessPursuitBuZhenEnter")) +end + +function XUiNewRoomSingle:OpenBabelRoomCharacter(teamData, charPos) + local args = {} + args.StageId = self.CurrentStageId + args.TeamId = self.BabelTowerData.TeamId + args.Index = charPos + args.CurTeamList = teamData + args.CharacterLimitType = XFubenConfigs.GetStageCharacterLimitType(self.CurrentStageId) + args.LimitBuffId = XFubenConfigs.GetStageCharacterLimitBuffId(self.CurrentStageId) + XLuaUiManager.Open("UiBabelTowerRoomCharacter", args, function(resTeam) + self:UpdateTeam(resTeam) + self.BabelTowerPanel:Refresh(resTeam) + end) +end + +-- 巴别塔进入战斗,检查队长位与首发位是否为空 +function XUiNewRoomSingle:HandleEnterBabelTower() + local captainPos = self.CurTeam.CaptainPos + local firstFightPos = self.CurTeam.FirstFightPos + local team = self.CurTeam.TeamData + + local captainId = team[captainPos] + if captainId == nil or captainId <= 0 then + XUiManager.TipText("TeamManagerCheckCaptainNil") + return + end + + local firFightId = team[firstFightPos] + if firFightId == nil or firFightId <= 0 then + XUiManager.TipMsg(CS.XTextManager.GetText("TeamManagerCheckFirstFightNil")) + return + end + + local closeCb = self.BabelTowerData.CloseCb + if closeCb then + XLuaUiManager.Remove("UiNewRoomSingle") + closeCb(team, captainPos, firstFightPos) + else + self:Close() + end +end + +function XUiNewRoomSingle:InitPanelNieR() + if not self:IsNieRType() then + return + end + self.BtnTeamPrefab.gameObject:SetActiveEx(false) + self.PanelCharacterLimit.gameObject:SetActiveEx(false) + self:ShowAssistToggle(false) +end + +--============================================================ +-- 页面代理方法 +-- 详情参考XUiNewRoomSingleProxy,注册页面代理 +--============================================================ +--================ +--初始化界面 +--================ +function XUiNewRoomSingle:InitProxyPanel() + if not self.Proxy then return end + if self.Proxy.InitEditBattleUi then self.Proxy.InitEditBattleUi(self) end +end + +--================ +--显示资料处理 +--================ +function XUiNewRoomSingle:OnBtnShowInfoToggleByProxy(val) + if (not self.Proxy) or (not self.Proxy.OnBtnShowInfoToggle) then + self:OnBtnShowInfoToggle(val) + else + self.Proxy.OnBtnShowInfoToggle(self, val) + end +end +--================ +--刷新成员信息处理 +--================ +function XUiNewRoomSingle:InitCharacterInfoByProxy() + if (not self.Proxy) or (not self.Proxy.InitEditBattleUiCharacterInfo) then + self:RefreshCharacterTypeTips() + return + end + self.Proxy.InitEditBattleUiCharacterInfo(self) +end +--================ +--保存玩法出战队伍操作,更改队长位和首发位时触发 +--================ +function XUiNewRoomSingle:SetTeamByProxy() + if not self.Proxy then + -- 不保存阵容 + if not self:IsRogueLikeType() + and not self:IsUnionKillType() + and not self:IsBabelTower() + and not self:IsWorldBossType() + and not self:IsChessPursuit() + and not self:IsNieRType() then + XDataCenter.TeamManager.SetPlayerTeam(self.CurTeam, false) + end + return + end + + if self.Proxy.SetEditBattleUiTeam then + self.Proxy.SetEditBattleUiTeam(self) + elseif self.Proxy.UpdateTeam then + self.Proxy.UpdateTeam(self) + end +end + +--================ +--获取队长ID +--================ +function XUiNewRoomSingle:GetCaptainIdByProxy() + if (not self.Proxy) or (not self.Proxy.GetEditBattleUiCaptainId) then + return self.CurTeam.TeamData[self.CurTeam.CaptainPos] + end + return self.Proxy.GetEditBattleUiCaptainId(self) +end + +--================ +--获取队伍数据 +--================ +function XUiNewRoomSingle:GetTeamByProxy() + if not self.Proxy then return nil end + if self.Proxy.GetBattleTeamData then + return self.Proxy.GetBattleTeamData(self) + end + return nil +end + +--========================================= +--获取队伍的角色Id +--与CurTeam不同,它主要用于区分机器人与玩家角色 +--在CurTeam中,有些机器人用了CharacterId而不是RobotId,无法获得得到机器人配置数据 +-- +--所以如果玩法中有机器人,并且CurTeam使用了CharacterId,则代理需要实现接口返回机器人的robotId,玩家角色则不变 +--不然机器人会使用玩家数据或者默认数据 +-- +--返回的数据结构与TeamData一致,索引1为中间,2为左边,3为右边 +--机器人是robotId,玩家角色是characterId +--========================================= +function XUiNewRoomSingle:GetRealCharDataByProxy() + if not self.Proxy then + return nil + end + if self.Proxy.GetRealCharData then + return self.Proxy.GetRealCharData(self, self.CurrentStageId) + end + return nil +end + +--================ +--当点击角色模型时 +--================ +function XUiNewRoomSingle:HandleCharClickByProxy(charPos) + if (not self.Proxy) or (not self.Proxy.HandleCharClick) then + local teamData = XTool.Clone(self.CurTeam.TeamData) + local stageId = self.CurrentStageId + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + local characterLimitType = self:GetCharacterLimitType() + XLuaUiManager.Open("UiRoomCharacter", teamData, charPos, + function(resTeam) + self:UpdateTeam(resTeam) + end, + stageInfo.Type, + characterLimitType, + { + LimitBuffId = XFubenConfigs.GetStageCharacterLimitBuffId(stageId), + ChallengeId = self.ChallengeId, + TeamBuffId = self.TeamBuffId, + }) + return + end + self.Proxy.HandleCharClick(self, charPos, self.CurrentStageId) +end + +--================ +--刷新警告面板 +--================ +function XUiNewRoomSingle:InitFightControl() + if not self.FightControl then + self.FightControl = XUiNewRoomFightControl.New(self.PanelNewRoomFightControl) + end + if (not self.Proxy) or (not self.Proxy.UpdateFightControl) then + self:UpdateFightControl() + else + self.FightControlResult = self.Proxy.UpdateFightControl(self, self.CurTeam) + end +end + +--================ +--刷新队伍,编队角色或编队顺序发生变化时触发 +--================ +function XUiNewRoomSingle:UpdateTeamByProxy() + if (not self.Proxy) or (not self.Proxy.UpdateTeam) then + return + end + self.Proxy.UpdateTeam(self) +end + +--================ +--刷新模型 +--================ +function XUiNewRoomSingle:UpdateRoleModelByProxy(charId, roleModelPanel, pos) + if (not self.Proxy) or (not self.Proxy.UpdateRoleModel) then + self:UpdateRoleModel(charId, roleModelPanel, pos) + return + end + self.Proxy.UpdateRoleModel(self, charId, roleModelPanel, pos) +end + +--================ +--接受到活动重置或结束消息时 +--================ +function XUiNewRoomSingle:OnResetEvent(stageType) + if self.StageInfos.Type ~= stageType then return end + if self.Proxy.OnResetEvent then self.Proxy.OnResetEvent(self) end +end + +--================ +--筛选角色 +--================ +function XUiNewRoomSingle:LimitCharacterByProxy(curTeam) + if (not self.Proxy) or (not self.Proxy.LimitCharacter) then + return + end + self.Proxy.LimitCharacter(self, curTeam) +end + +function XUiNewRoomSingle:GetRobotIdsByProxy(stageId) + if self.Proxy and self.Proxy.GetRobotIds then + return self.Proxy.GetRobotIds(stageId) + end + return XDataCenter.FubenManager.GetStageCfg(stageId).RobotId +end + +function XUiNewRoomSingle:CheckCharCanClickByProxy() + if self.Proxy and self.Proxy.CheckCanCharClick then + return self.Proxy.CheckCanCharClick() + end + return not self:CheckHasRobot() +end + +-- 获取是否隐藏切换第一次战斗位置按钮信息(红色,蓝色,黄色) +function XUiNewRoomSingle:GetIsHideSwitchFirstFightPosBtnsWithProxy() + if self.Proxy and self.Proxy.GetIsHideSwitchFirstFightPosBtns then + return self.Proxy.GetIsHideSwitchFirstFightPosBtns() + end + return self.HasRobot +end +--================ +--销毁窗口时 +--================ +function XUiNewRoomSingle:DestroyNewRoomSingle() + if (not self.Proxy) or (not self.Proxy.DestroyNewRoomSingle) then + return + end + self.Proxy.DestroyNewRoomSingle(self) +end +--================ +--更新伙伴信息 +--================ +function XUiNewRoomSingle:UpdatePartnerInfo() + if (not self.Proxy) or (not self.Proxy.UpdatePartnerInfo) then + self:DefaultUpdatePartnerInfo() + return + end + self.Proxy.UpdatePartnerInfo(self, MAX_CHAR_COUNT) +end + +--================ +--更新人物特性信息 +--================ +function XUiNewRoomSingle:UpdateFeatureInfo() + if (not self.Proxy) or (not self.Proxy.UpdateFeatureInfo) then + self:DefaultUpdateFeatureInfo() + return + end + self.Proxy.UpdateFeatureInfo(self, MAX_CHAR_COUNT) +end + +--================ +--进战前检查 +--================ +function XUiNewRoomSingle:CheckEnterFightByProxy() + if (not self.Proxy) or (not self.Proxy.CheckEnterFight) then + return true + end + return self.Proxy.CheckEnterFight(self, self.CurTeam) +end + +function XUiNewRoomSingle:GetIsSaveTeamData() + if self.Proxy and self.Proxy.GetIsSaveTeamData then + return self.Proxy.GetIsSaveTeamData() + end + return not self:IsRogueLikeType() and not self:IsUnionKillType() and not self:IsWorldBossType() +end + +function XUiNewRoomSingle:HandleSwitchTeamPosWithProxy(fromPos, toPos) + if self.Proxy and self.Proxy.SwitchTeamPos then + self.Proxy.SwitchTeamPos(self.CurrentStageId, fromPos, toPos) + end +end + +function XUiNewRoomSingle:SetFirstFightPosWithProxy(index) + if self.Proxy and self.Proxy.SetFirstFightPos then + self.Proxy.SetFirstFightPos(self.CurrentStageId, index) + end +end + +function XUiNewRoomSingle:SetCaptainPosWithProxy(index) + if self.Proxy and self.Proxy.SetCaptainPos then + self.Proxy.SetCaptainPos(self.CurrentStageId, index) + end +end + +function XUiNewRoomSingle:GetFirstFightPos() + if self.Proxy and self.Proxy.GetFirstFightPos then + return self.Proxy.GetFirstFightPos(self.CurrentStageId) + end + return CHAR_POS1 +end + +function XUiNewRoomSingle:GetCaptainPos() + if self.Proxy and self.Proxy.GetCaptainPos then + return self.Proxy.GetCaptainPos(self.CurrentStageId) + end + return CHAR_POS1 +end + +function XUiNewRoomSingle:GetTeamCaptainId() + if self.Proxy and self.Proxy.GetTeamCaptainId then + return self.Proxy.GetTeamCaptainId(self.CurrentStageId) + end + return XDataCenter.TeamManager.GetTeamCaptainId(self.CurTeam.TeamId) +end + +function XUiNewRoomSingle:GetTeamFirstFightId() + if self.Proxy and self.Proxy.GetTeamFirstFightId then + return self.Proxy.GetTeamFirstFightId(self.CurrentStageId) + end + return XDataCenter.TeamManager.GetTeamFirstFightId(self.CurTeam.TeamId) +end + +function XUiNewRoomSingle:GetIsCheckCaptainIdAndFirstFightId() + if self.Proxy and self.Proxy.GetIsCheckCaptainIdAndFirstFightId then + return self.Proxy.GetIsCheckCaptainIdAndFirstFightId(self.CurrentStageId) + end + return not self:IsWorldBossType() + and not self.HasRobot + and (not self:IsRogueLikeType()) + and (not self:IsUnionKillType()) + and (not self:IsChessPursuit()) + and (not self:IsNieRType()) +end + +function XUiNewRoomSingle:GetAutoCloseInfo() + if self.Proxy and self.Proxy.GetAutoCloseInfo then + return self.Proxy.GetAutoCloseInfo(self.StageCfg) + end + return false +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNewRoomSingle/XUiNewRoomSingleProxy.lua b/Resources/Scripts/XUi/XUiNewRoomSingle/XUiNewRoomSingleProxy.lua new file mode 100644 index 00000000..b8cf42b1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiNewRoomSingle/XUiNewRoomSingleProxy.lua @@ -0,0 +1,147 @@ +-- 通用出战界面代理管理 +XUiNewRoomSingleProxy = XUiNewRoomSingleProxy or {} + +XUiNewRoomSingleProxy.ProxyDic = {} +--================= +-- 注册出战界面代理 +--@param stageType:FubenManager中关卡的分类StageType +--@param proxy:代理 +--================= +function XUiNewRoomSingleProxy.RegisterProxy(stageType, proxy) + if XUiNewRoomSingleProxy.ProxyDic[stageType] then return end + XUiNewRoomSingleProxy.ProxyDic[stageType] = proxy +end + +--[[ +--============================================================ +-- 页面代理方法 +--============================================================ +所有方法都可选择性使用,不写该方法会调用NewRoomSingle本身的默认方法 +代理需使用上面的注册方法才能使用(一个FubenManager的StageType分类代理只有一个) +如有需要追加的方法请在下方补充 + +--================ +--初始化界面 在出战界面OnStart初始化界面所有元素后调用 +--================ +function ProxyName:InitEditBattleUi(newRoomSingleUi) + +--================ +--点击出战界面资料时的显示处理 +--@param val 显示资料状态,参照XUiNewRoomSingle.OnBtnShowInfoToggle方法 +--================ +function ProxyName:OnBtnShowInfoToggle(newRoomSingleUi, val) + +--================ +--刷新成员信息处理 +--================ +function ProxyName:InitEditBattleUiCharacterInfo(newRoomSingleUi) + +--================ +--保存玩法出战队伍操作,更改队长位和首发位时触发 +--================ +function ProxyName:SetEditBattleUiTeam(newRoomSingleUi) + +--================ +--刷新警告面板 +--================ +function ProxyName:UpdateFightControl(newRoomSingleUi. curTeam) + +--================ +--获取队长ID +--@return captainId:队长的ID +--================ +function ProxyName:GetEditBattleUiCaptainId(newRoomSingleUi) + +--================ +--获取队伍数据 +--@return teamData:队伍数据 +--================ +function ProxyName:GetBattleTeamData(newRoomSingleUi) + +--================ +--当点击角色模型时 +--@param charPos:点击的角色的队伍位置 +--================ +function ProxyName:HandleCharClick(newRoomSingleUi, charPos) + +--================ +--当点击主界面按钮时 +--================ +function ProxyName:HandleBtnMainUiClick() + + +--================ +--刷新队伍,编队角色或编队顺序发生变化时触发 +--================ +function ProxyName:UpdateTeam(newRoomSingleUi) + +--================ +--刷新模型 +--@param charId:角色Id +--@param roleModelPanel:3D UI角色 +--@param pos:角色位置 +--================ +function ProxyName:UpdateRoleModel(newRoomSingleUi, charId, roleModelPanel, pos) + +--================ +--返回正确的队员ID(基础角色使用CharacterId,机器人使用RobotId) +--@param teamIds:队员Id +--用于显示队员资料(如队长技能) +--================ +function ProxyName:GetRealCharData(newRoomSingleUi) + +--================ +--接受到活动重置或结束消息时 +--================ +function ProxyName:OnResetEvent(newRoomSingleUi) + +--================ +--筛选角色 +--================ +function ProxyName:LimitCharacter(newRoomSingleUi, curTeam) + +--================ +--页面获取机器人Id数组 +--================ +function ProxyName:GetRobotIds(stageId) + +--================ +--页面检查角色是否能点击 +--================ +function ProxyName:CheckCanCharClick() + +--================ +--页面检查是否隐藏切换第一次战斗位置按钮信息 +--================ +function ProxyName:GetIsHideSwitchFirstFightPosBtns() + +--================ +--关闭界面销毁时 +--================ +function ProxyName:DestroyNewRoomSingle() + +--================ +--更新伙伴信息 +--@param newRoomSingleUi:页面对象 +--@param maxCharaCount:编队角色最大值 +--================ +function ProxyName:UpdatePartnerInfo(newRoomSingleUi, maxCharaCount) +--================ +--更新人物特性信息 +--================ +function ProxyName:UpdateFeatureInfo(newRoomSingleUi, maxCharaCount) +--================ +--进战前检查 +--================ +function ProxyName:CheckEnterFight(newRoomSingleUi, CurTeam) +--================ +--更新队伍后是否保存队伍数据 +--================ +function ProxyName:GetIsSaveTeamData(newRoomSingleUi, maxCharaCount) + +--================ +--处理切换队伍位置 +--================ +function ProxyName:SwitchTeamPos(stageId, fromPos, toPos) + +]] \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNewRoomSingle/XUiNewRoomSingleTip.lua b/Resources/Scripts/XUi/XUiNewRoomSingle/XUiNewRoomSingleTip.lua new file mode 100644 index 00000000..70de1db8 --- /dev/null +++ b/Resources/Scripts/XUi/XUiNewRoomSingle/XUiNewRoomSingleTip.lua @@ -0,0 +1,186 @@ +local XUiNewRoomSingleTip = XLuaUiManager.Register(XLuaUi, "UiNewRoomSingleTip") + +local MAX_CHAR_COUNT = 3 + +function XUiNewRoomSingleTip:OnAwake() + self:AddListener() + self:InitSelectTabGroup() + + for i = 1, MAX_CHAR_COUNT do + local panelEnable = string.format("%s%s", "Ena0", i) + local panelDisable = string.format("%s%s", "Dis0", i) + local btnSelect = string.format("%s%s", "BtnSel0", i) + + if self[panelEnable] then + self[panelEnable].gameObject:SetActiveEx(false) + end + if self[panelDisable] then + self[panelDisable].gameObject:SetActiveEx(true) + end + if self[btnSelect] then + self[btnSelect]:SetButtonState(CS.UiButtonState.Disable) + end + end + +end + +function XUiNewRoomSingleTip:AddListener() + self.BtnTanchuangCloseBig.CallBack = function() self:OnCloseClick() end +end + +function XUiNewRoomSingleTip:InitSelectTabGroup() + self.tabGroup = { + self.BtnSel01, + self.BtnSel02, + self.BtnSel03, + } + self.PanelBtnSel:Init(self.tabGroup, function(tabIndex) + self:OnClickTabCallBack(tabIndex) + end) +end + +function XUiNewRoomSingleTip:OnClickTabCallBack(index) + if self.CurCaptainPos == index or self.tabGroup[index].ButtonState == CS.UiButtonState.Disable then + return + else + self.CurCaptainPos = index + end +end + +---================================= +--- 'teamData'是当前队伍角色 +--- 索引:1中间,2左边,3右边 +--- 值:角色的CharacterId或RobotId +--- +--- 'curCaptainPos'是当前队长技能位置 +--- 当关闭当前界面时,会调用'cb'函数更新相应界面 +--- +---'characterIdToIsIsAssitantDic'是角色是否为援助角色(即该角色是否不属于自己的) +---索引:角色的CharacterId或RobotId +---值:是否为援助角色 +---@param rootUi table +---@param teamData table +---@param curCaptainPos number +---@param cb function +---================================= +function XUiNewRoomSingleTip:OnStart(rootUi, teamData, curCaptainPos, cb, characterIdToIsIsAssitantDic) + self.RootUi = rootUi + self.TeamData = teamData + self.CurCaptainPos = curCaptainPos + self.Cb = cb + self.CharacterIdToIsIsAssitantDic = characterIdToIsIsAssitantDic + self:Refresh() +end + +function XUiNewRoomSingleTip:Refresh() + if not self.TeamData then + XLog.Error("XUiNewRoomSingleTip:Refresh函数错误:self.TeamData为nil") + return + end + + -- 设置三个角色栏的技能信息 + for i, char in pairs(self.TeamData) do + local charId = 0 + + if self.RootUi.IsExpedition and self.RootUi:IsExpedition() then + local eCharCfg = XDataCenter.ExpeditionManager.GetMemberECfgByBaseId(char) + charId = eCharCfg and eCharCfg.RobotId or 0 + else + charId = char + end + + if charId > 0 then + local captianSkillInfo + local head + local skillDesc + local isAssitant + local charConfig = XCharacterConfigs.GetCharacterTemplate(charId) + if charConfig == nil then + return + end + + if not XRobotManager.CheckIsRobotId(charId) then + -- 玩家角色 + captianSkillInfo = XDataCenter.CharacterManager.GetCaptainSkillInfo(charId) + if captianSkillInfo == nil then + return + end + + -- 如果机器人使用了CharacterId,会误判断成玩家角色,并使用玩家角色的数据 + head = XDataCenter.CharacterManager.GetCharSmallHeadIcon(charId) + isAssitant = self.CharacterIdToIsIsAssitantDic and self.CharacterIdToIsIsAssitantDic[charId] or false + skillDesc = (captianSkillInfo.Level > 0 or isAssitant) and captianSkillInfo.Intro + or string.format("%s%s", captianSkillInfo.Intro, CS.XTextManager.GetText("CaptainSkillLock")) + else + -- 使用了RobotId的机器人 + head = XRobotManager.GetRobotSmallHeadIcon(charId) + captianSkillInfo = XRobotManager.GetRobotCaptainSkillInfo(charId) + if captianSkillInfo == nil then + return + end + skillDesc = captianSkillInfo.Intro + end + + local name = string.format("%s%s", "TextName0", i) + local skillName = string.format("%s%s", "TextJinengName0", i) + local ImgHead = string.format("%s%s", "RawImage0", i) + local skillInfo = string.format("%s%s", "TextJinengInfo0", i) + + local panelEnable = string.format("%s%s", "Ena0", i) + local panelDisable = string.format("%s%s", "Dis0", i) + local btnSelect = string.format("%s%s", "BtnSel0", i) + + if self[name] then + self[name].text = string.format("%s-%s", charConfig.Name, charConfig.TradeName) + end + if self[skillName] then + self[skillName].text = captianSkillInfo.Name + end + if head and self[ImgHead] then + self[ImgHead]:SetRawImage(head) + end + if skillDesc and self[skillInfo] then + self[skillInfo].text = skillDesc + end + + if self[panelEnable] then + self[panelEnable].gameObject:SetActiveEx(true) + end + if self[panelDisable] then + self[panelDisable].gameObject:SetActiveEx(false) + end + if self[btnSelect] then + self[btnSelect]:SetButtonState(CS.UiButtonState.Normal) + end + else + local panelEnable = string.format("%s%s", "Ena0", i) + local panelDisable = string.format("%s%s", "Dis0", i) + local btnSelect = string.format("%s%s", "BtnSel0", i) + + -- 当前位置未上阵角色 + if self[panelEnable] then + self[panelEnable].gameObject:SetActiveEx(false) + end + if self[panelDisable] then + self[panelDisable].gameObject:SetActiveEx(true) + end + if self[btnSelect] then + self[btnSelect]:SetButtonState(CS.UiButtonState.Disable) + end + end + end + + if not self.CurCaptainPos or self.CurCaptainPos <= 0 or self.CurCaptainPos > 3 then + XLog.Error("XUiNewRoomSingleTip:Refresh函数错误:self.CurCaptainPos超出队伍索引范围") + return + end + + self.PanelBtnSel:SelectIndex(self.CurCaptainPos) +end + +function XUiNewRoomSingleTip:OnCloseClick() + if self.Cb then + self.Cb(self.CurCaptainPos) + end + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNewRoomSingle/XUiPanelActiveBuff.lua b/Resources/Scripts/XUi/XUiNewRoomSingle/XUiPanelActiveBuff.lua new file mode 100644 index 00000000..a35b545b --- /dev/null +++ b/Resources/Scripts/XUi/XUiNewRoomSingle/XUiPanelActiveBuff.lua @@ -0,0 +1,94 @@ +local XUiPanelActiveBuff = XClass(nil, "XUiPanelActiveBuff") + +function XUiPanelActiveBuff:Ctor(ui, uiRoot,stageId, challengeId) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + self.PlayerActiveBuffOnList = {} + XTool.InitUiObject(self) + self:AutoAddListener() + self:Hide() + self.StageId = stageId + self.ChallengeId = challengeId +end + +function XUiPanelActiveBuff:AutoAddListener() + self.BtnDesc.CallBack = function() self:OnBenDescClick() end +end + +function XUiPanelActiveBuff:Show() + self:Refresh() + self.GameObject:SetActiveEx(true) +end + +function XUiPanelActiveBuff:Hide() + self.GameObject:SetActiveEx(false) +end + +function XUiPanelActiveBuff:Refresh() + local stageInfo = XDataCenter.FubenManager.GetStageInfo(self.StageId) + if stageInfo.Type ~= XDataCenter.FubenManager.StageType.ArenaOnline then + return + end + self.PlayerActiveBuffOnList = {} + local PlayerDataList = {} + self.BuffCfg = XDataCenter.ArenaOnlineManager.GetActiveBuffCfgByStageId(self.ChallengeId) + local enoughCount = 0 + + self.teamData = self.UiRoot:GetTeamData() + + for _, player in pairs(self.teamData.TeamData) do + local info = XDataCenter.CharacterManager.GetCharacter(player) + table.insert(PlayerDataList, info) + end + if not next(PlayerDataList) then return end + for _, player in pairs(PlayerDataList) do + local initQualty = player.InitQuality + if initQualty <= self.BuffCfg.Quality then + enoughCount = enoughCount + 1 + end + end + + if enoughCount >= self.BuffCfg.QualityCount then + self.PanalOn.gameObject:SetActiveEx(true) + self.PanelOFF.gameObject:SetActiveEx(false) + self.UiRoot:PlayAnimation("PanalOnQiHuan") + + for _, player in pairs(PlayerDataList) do + local initQualty = player.InitQuality + if initQualty <= self.BuffCfg.AffectQuality then + self.PlayerActiveBuffOnList[player.Id] = true + end + end + + if not self.ActiveOn then + XUiManager.TipMsgEnqueue(self.BuffCfg.ActiveTip) + -- self.UiRoot:InsertActiveTips(self.BuffCfg.ActiveTip) + end + self.ActiveOn = true + else + self.ActiveOn = false + self.PanalOn.gameObject:SetActiveEx(false) + self.PanelOFF.gameObject:SetActiveEx(true) + self.UiRoot:PlayAnimation("PanelOFFQiHuan") + end + self.TxtDesc.text = CS.XTextManager.GetText("ArenaOnlineActiveBuffDesc", enoughCount, self.BuffCfg.QualityCount) + self.RawOnIcon:SetRawImage(self.BuffCfg.OnIcon) + self.RawOffIcon:SetRawImage(self.BuffCfg.OffIcon) +end + +function XUiPanelActiveBuff:CheckActiveOn(playerId) + return self.PlayerActiveBuffOnList and self.PlayerActiveBuffOnList[playerId] +end + +function XUiPanelActiveBuff:OnBenDescClick() + self.ActiveBuffPanelTip:Show(self.BuffCfg) + self.UiRoot:PlayAnimation("ActiveBuffEnable") +end + +function XUiPanelActiveBuff:RegisterPanel(panel) + self.ActiveBuffPanelTip = panel +end + + +return XUiPanelActiveBuff \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNewRoomSingle/XUiPanelActiveBuffTip.lua b/Resources/Scripts/XUi/XUiNewRoomSingle/XUiPanelActiveBuffTip.lua new file mode 100644 index 00000000..3b5a62ad --- /dev/null +++ b/Resources/Scripts/XUi/XUiNewRoomSingle/XUiPanelActiveBuffTip.lua @@ -0,0 +1,38 @@ +local XUiPanelActiveBuffTip = XClass(nil, "XUiPanelActiveBuffTip") + +function XUiPanelActiveBuffTip:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:AutoAddListener() +end + +function XUiPanelActiveBuffTip:AutoAddListener() + self.BtnClose.CallBack = function() self:Hide() end + self.BtnTanchuangClose.CallBack = function() self:Hide() end +end + +function XUiPanelActiveBuffTip:Show(activeBuffCfg) + if self.CfgId == activeBuffCfg.Id then + self.GameObject:SetActiveEx(true) + return + end + + self.CfgId = activeBuffCfg.Id + self:Refresh(activeBuffCfg) + self.GameObject:SetActiveEx(true) +end + +function XUiPanelActiveBuffTip:Hide() + self.GameObject:SetActiveEx(false) +end + +function XUiPanelActiveBuffTip:Refresh(activeBuffCfg) + self.RImgOnIcon:SetRawImage(activeBuffCfg.OnIcon) + self.RImgOffIcon:SetRawImage(activeBuffCfg.OffIcon) + self.TxtTile.text = activeBuffCfg.Title + local description = string.gsub(activeBuffCfg.Desc, "\\n", "\n") + self.TxtDesc.text = description +end + +return XUiPanelActiveBuffTip \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNewRoomSingle/XUiPanelArenaOnline.lua b/Resources/Scripts/XUi/XUiNewRoomSingle/XUiPanelArenaOnline.lua new file mode 100644 index 00000000..9f13123e --- /dev/null +++ b/Resources/Scripts/XUi/XUiNewRoomSingle/XUiPanelArenaOnline.lua @@ -0,0 +1,67 @@ +local XUiPanelActiveBuff = require("XUi/XUiNewRoomSingle/XUiPanelActiveBuff") +local XUiPanelActiveBuffTip = require("XUi/XUiNewRoomSingle/XUiPanelActiveBuffTip") +local XUiPanelChangeStage = require("XUi/XUiMultiplayerRoom/XUiPanelChangeStage") + +local XUiPanelArenaOnline = XClass(nil, "XUiPanelArenaOnline") + +function XUiPanelArenaOnline:Ctor(ui, rootUi, stageId, challengeId) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + + XTool.InitUiObject(self) + self.ChangeStagePanel = XUiPanelChangeStage.New(self.PanelChangeStage, true) + -- 开启同调 + self.ActiveBuffObj = XUiPanelActiveBuff.New(self.PanelTeamBuff, self.RootUi, stageId, challengeId) + self.ActiveBuffObj:Refresh() + self.ActiveBuffObj:Show() + self.ActiveBuffPanelTip = XUiPanelActiveBuffTip.New(self.PanelActiveBuffTip) + self.ActiveBuffObj:RegisterPanel(self.ActiveBuffPanelTip) + self:Refresh(stageId, challengeId) + self.BtnDifficultySelect.CallBack = function() self:OnBtnDifficultySelectClick() end + self.BtnChangeStage.CallBack = function() self:OnBtnChangeStageClick() end +end + +function XUiPanelArenaOnline:Refresh(stageId, challengeId) + self.StageId = stageId + self.ChallengeId = challengeId + local isPassed = XDataCenter.ArenaOnlineManager.CheckStagePass(challengeId) + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + local arenaStageCfg = XDataCenter.ArenaOnlineManager.GetArenaOnlineStageCfgStageId(challengeId) + local arenaChapterCfg = XDataCenter.ArenaOnlineManager.GetCurChapterCfg() + self.PanelArenaOnlineTip.gameObject:SetActiveEx(isPassed) + -- self.PanelConsume.gameObject:SetActiveEx(false) + local cost = isPassed and 0 or arenaStageCfg.EnduranceCost + self.TxtStamina.text = cost + self.TxtLv.text = CS.XTextManager.GetText("ArenaOnlineChapterLevel", arenaChapterCfg.MinLevel, arenaChapterCfg.MaxLevel) + self.ActiveBuffObj:Show(stageId) + + local difficult = XDataCenter.ArenaOnlineManager.GetSingleModeDifficulty(challengeId) + local levelControl = XDataCenter.FubenManager.GetStageMultiplayerLevelControl(stageId, difficult) + self.TxtAdditionDest.text = levelControl.AdditionDest + self.TxtRecommend.text = CS.XTextManager.GetText("MultiplayerRoomRecommendAbility", levelControl.RecommendAbility) + self.TxtTitle.text = stageCfg.Name + + self.ActiveBuffObj:Refresh() +end + +function XUiPanelArenaOnline:OnBtnDifficultySelectClick() + local msg = CS.XTextManager.GetText("SingleModeCanNotSelectDifficulty") + XUiManager.TipMsg(msg) + return +end + +-- 改变关卡 +function XUiPanelArenaOnline:OnBtnChangeStageClick() + self.ChangeStagePanel:Show(self.ChallengeId) + self.RootUi:PlayAnimation("ChangeStageEnable") +end + +function XUiPanelArenaOnline:CheckTongdiaoState(playerId) + return self.ActiveBuffObj:CheckActiveOn(playerId) +end + +return XUiPanelArenaOnline + + +-- XDataCenter.ArenaOnlineManager.CheckStagePass(self.ChallengeId) \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNewRoomSingle/XUiPanelBabelTower.lua b/Resources/Scripts/XUi/XUiNewRoomSingle/XUiPanelBabelTower.lua new file mode 100644 index 00000000..468be14d --- /dev/null +++ b/Resources/Scripts/XUi/XUiNewRoomSingle/XUiPanelBabelTower.lua @@ -0,0 +1,102 @@ +local XUiGridInfoSupportCondition = require("XUi/XUiFubenBabelTower/XUiGridInfoSupportCondition") + +local XUiPanelBabelTower = XClass(nil, "XUiPanelBabelTower") + +function XUiPanelBabelTower:Ctor(ui, stageId, characterIds) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.GridCondition.gameObject:SetActiveEx(false) + self.StageTemplate = XFubenBabelTowerConfigs.GetBabelTowerStageTemplate(stageId) + self.DynamicTableSupportConditon = XDynamicTableNormal.New(self.PanelCondition.gameObject) + self.DynamicTableSupportConditon:SetProxy(XUiGridInfoSupportCondition) + self.DynamicTableSupportConditon:SetDelegate(self) + + self:Refresh(characterIds) +end + +function XUiPanelBabelTower:Refresh(characterIds) + self.CharacterIds = characterIds + + self.TxtTotalPoint.text = self:GetTotalSupportPoint() + + self.SupportConditionList = self:GetStageSupportConditionListSort() + self.DynamicTableSupportConditon:SetDataSource(self.SupportConditionList) + self.DynamicTableSupportConditon:ReloadDataASync() +end + +function XUiPanelBabelTower:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + if self.SupportConditionList[index] then + grid:SetItemInfo(self.SupportConditionList[index]) + end + end +end + +function XUiPanelBabelTower:GetStageSupportConditionListSort() + if not self.StageTemplate then return {} end + local conditionList = {} + for i = 1, #self.StageTemplate.SupportConditionId do + local conditionId = self.StageTemplate.SupportConditionId[i] + local conditionTemplate = XFubenBabelTowerConfigs.GetBabelTowerSupportConditonTemplate(conditionId) + local isSupport = self:CheckBabelTeamCondition(conditionTemplate.Condition) + table.insert(conditionList, { + SupportConditionId = conditionId, + IsSupport = isSupport + }) + end + table.sort(conditionList, function(elementA, elemenbB) + local priorityA = elementA.IsSupport and 1 or 0 + local priorityB = elemenbB.IsSupport and 1 or 0 + if priorityA == priorityB then + return elementA.SupportConditionId < elemenbB.SupportConditionId + end + return priorityA > priorityB + end) + return conditionList +end + +function XUiPanelBabelTower:CheckBabelTeamCondition(conditionId) + if conditionId == nil or conditionId == 0 then return true end + local characterIds = {} + for i = 1, XFubenBabelTowerConfigs.MAX_TEAM_MEMBER do + local characterId = self.CharacterIds[i] + if characterId ~= nil and characterId ~= 0 then + table.insert(characterIds, characterId) + end + end + local isConditionAvailable = XConditionManager.CheckCondition(conditionId, characterIds) + return isConditionAvailable +end + +function XUiPanelBabelTower:GetTotalSupportPoint() + local totalSupportPoint = self.StageTemplate.BaseSupportPoint or 0 + + local characterIds = {} + for i = 1, XFubenBabelTowerConfigs.MAX_TEAM_MEMBER do + local characterId = self.CharacterIds[i] + if characterId ~= nil and characterId ~= 0 then + table.insert(characterIds, characterId) + end + end + + for i = 1, #self.StageTemplate.SupportConditionId do + local supportConditionId = self.StageTemplate.SupportConditionId[i] + local supportConditionTemplate = XFubenBabelTowerConfigs.GetBabelTowerSupportConditonTemplate(supportConditionId) + if supportConditionTemplate.Condition == nil or supportConditionTemplate.Condition == 0 then + totalSupportPoint = totalSupportPoint + supportConditionTemplate.PointAdd + else + local isConditionAvailable = XConditionManager.CheckCondition(supportConditionTemplate.Condition, characterIds) + if isConditionAvailable then + totalSupportPoint = totalSupportPoint + supportConditionTemplate.PointAdd + end + end + + end + + return totalSupportPoint +end + +return XUiPanelBabelTower \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNewYearDrawActivity/XUiDrawActivityControl.lua b/Resources/Scripts/XUi/XUiNewYearDrawActivity/XUiDrawActivityControl.lua new file mode 100644 index 00000000..1131d340 --- /dev/null +++ b/Resources/Scripts/XUi/XUiNewYearDrawActivity/XUiDrawActivityControl.lua @@ -0,0 +1,97 @@ +local XUiDrawActivityControl = XClass(nil, "XUiDrawActivityControl") +local characterRecord = require("XUi/XUiDraw/XUiDrawTools/XUiDrawCharacterRecord") + +local MAX_GACHA_BTN_COUNT = 2 + +function XUiDrawActivityControl:Ctor(rootUi, gachaCfg, gachaCb, uiDraw) + self.RootUi = rootUi + self.GachaCfg = gachaCfg + self.GachaCb = gachaCb + self.UiDraw = uiDraw + self.IsCanGacha = true + self:InitRes() + self:InitButtons() + return self +end + +function XUiDrawActivityControl:InitRes() + self.UseItemIcon = XDataCenter.ItemManager.GetItemBigIcon(self.GachaCfg.ConsumeId) +end + +function XUiDrawActivityControl:InitButtons() + for i = 1, MAX_GACHA_BTN_COUNT do + local btnName = "BtnDraw" .. i + local btn = XUiHelper.TryGetComponent(self.RootUi.PanelDrawButtons, btnName) + if btn then + self:InitButton(btn, i) + end + end +end + +function XUiDrawActivityControl:InitButton(btn, index) + --@DATA + local gachaCount = self.GachaCfg.BtnGachaCount[index] + btn.transform:Find("TxtDrawDesc"):GetComponent("Text").text = CS.XTextManager.GetText("DrawCount", gachaCount) + local itemIcon = btn.transform:Find("ImgUseItemIcon"):GetComponent("RawImage") + itemIcon:SetRawImage(self.UseItemIcon) + btn.transform:Find("TxtUseItemCount"):GetComponent("Text").text = gachaCount * self.GachaCfg.ConsumeCount + + self.RootUi:RegisterClickEvent(btn:GetComponent("Button"), function() + self.UiDraw:UpdateItemCount() + self:OnDraw(gachaCount) + end) +end + +function XUiDrawActivityControl:ShowGacha() + + XDataCenter.AntiAddictionManager.BeginDrawCardAction() + self.UiDraw.OpenSound = CS.XAudioManager.PlaySound(XSoundManager.UiBasicsMusic.UiDrawCard_GachaOpen) + + if self.GachaCb then + self.GachaCb() + end + + if self.RewardList and #self.RewardList > 0 then + self.IsCanGacha = true + self.UiDraw:PushShow(self.RewardList) + else + self.UiDraw:PushShow(self.RewardList) + end + + self.UiDraw:UpDataPreviewData() + self.UiDraw.IsReadyForGacha = false +end + + +function XUiDrawActivityControl:OnDraw(gachaCount) + + local ownItemCount = XDataCenter.ItemManager.GetItem(self.GachaCfg.ConsumeId).Count + local lackItemCount = self.GachaCfg.ConsumeCount * gachaCount - ownItemCount + if lackItemCount > 0 then + XUiManager.TipError(CS.XTextManager.GetText("DrawNotEnoughError")) + return + end + local dtCount = XDataCenter.GachaManager.GetMaxCountOfAll() - XDataCenter.GachaManager.GetCurCountOfAll() + if dtCount < gachaCount then + XUiManager.TipMsg(CS.XTextManager.GetText("GachaIsNotEnough")) + return + end + if not XDataCenter.GachaManager.CheckGachaIsOpenById(self.GachaCfg.Id,true) then + return + end + if self.IsCanGacha then + self.IsCanGacha = false + + characterRecord.Record() + self.UiDraw.ImgMask.gameObject:SetActiveEx(true) + + XDataCenter.GachaManager.DoGacha(self.GachaCfg.Id, gachaCount, function(rewardList) + self.UiDraw:PlayAnimation("DrawRetract",function() + self.UiDraw.IsReadyForGacha = true + end) + self.RewardList = rewardList + end) + end +end + +return XUiDrawActivityControl \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNewYearDrawActivity/XUiDrawBuyAssert.lua b/Resources/Scripts/XUi/XUiNewYearDrawActivity/XUiDrawBuyAssert.lua new file mode 100644 index 00000000..d780111c --- /dev/null +++ b/Resources/Scripts/XUi/XUiNewYearDrawActivity/XUiDrawBuyAssert.lua @@ -0,0 +1,87 @@ +local XUiDrawBuyAssert = XClass(nil, "XUiDrawBuyAssert") + +local UiType = 15 + +local Application = CS.UnityEngine.Application +local Platform = Application.platform +local RuntimePlatform = CS.UnityEngine.RuntimePlatform + +function XUiDrawBuyAssert:Ctor(rootUi, ui) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:InitAutoScript() +end + +function XUiDrawBuyAssert:InitAutoScript() + self.BtnConfirm.CallBack = function() + self:OnBtnConfirmClick() + end + self.BtnTanchuangClose.CallBack = function() + self:OnBtnCloseClick() + end + self.BtnCancel.CallBack = function() + self:OnBtnCloseClick() + end +end + +function XUiDrawBuyAssert:Show() + local data = XDataCenter.PurchaseManager.GetDatasByUiType(UiType)[1] + self.CurData = data + if not data then + return + end + + self.GameObject:SetActiveEx(true) + --先显示目标物品 + local targetItemId + local targeTotalCount = 0 + if data.RewardGoodsList and #data.RewardGoodsList > 0 then + for _, v in pairs(data.RewardGoodsList) do + targetItemId = v.TemplateId + targeTotalCount = targeTotalCount + v.Count + end + end + self.TxtTargetName.text = XDataCenter.ItemManager.GetItemName(targetItemId) + self.ImgTarget:SetRawImage(XDataCenter.ItemManager.GetItemIcon(targetItemId)) + self.TxtTargetCount.text = targeTotalCount + + local consumeCount = 0 + --再显示兑换源 + if data.PayKeySuffix then + local key + if Platform == RuntimePlatform.Android then + key = string.format("%s%s", XPayConfigs.GetPlatformConfig(1), data.PayKeySuffix) + else + key = string.format("%s%s", XPayConfigs.GetPlatformConfig(2), data.PayKeySuffix) + end + + local payConfig = XPayConfigs.GetPayTemplate(key) + consumeCount = payConfig.Amount + end + + local path = CS.XGame.ClientConfig:GetString("PurchaseBuyRiYuanIconPath") + self.ImgConsume:SetRawImage(path) + self.TxtConsumeName.text = "" + self.TxtConsumeCount.text = consumeCount +end + +function XUiDrawBuyAssert:OnBtnConfirmClick() + if self.CurData.PayKeySuffix then + local key + if Platform == RuntimePlatform.Android then + key = string.format("%s%s", XPayConfigs.GetPlatformConfig(1), self.CurData.PayKeySuffix) + else + key = string.format("%s%s", XPayConfigs.GetPlatformConfig(2), self.CurData.PayKeySuffix) + end + self.GameObject:SetActiveEx(false) + XDataCenter.PayManager.Pay(key, 1, { self.CurData.Id }) + end +end + +function XUiDrawBuyAssert:OnBtnCloseClick() + self.GameObject:SetActiveEx(false) +end + +return XUiDrawBuyAssert \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNewYearDrawActivity/XUiDrawNewYear.lua b/Resources/Scripts/XUi/XUiNewYearDrawActivity/XUiDrawNewYear.lua new file mode 100644 index 00000000..9c4ccfa3 --- /dev/null +++ b/Resources/Scripts/XUi/XUiNewYearDrawActivity/XUiDrawNewYear.lua @@ -0,0 +1,449 @@ +local XUiDrawNewYear = XLuaUiManager.Register(XLuaUi, "UiDrawNewYear") +local characterRecord = require("XUi/XUiDraw/XUiDrawTools/XUiDrawCharacterRecord") +local TextManager = CS.XTextManager + +local type = {IN = 1, OUT = 2} +local UiType = 15 +local startPlaySoundTime = CS.XGame.ClientConfig:GetFloat("DrawNewYearPlaySoundTime") + +local MAX_GACHA_BTN_COUNT = 2 + +local ShowDrawTipTime = CS.XGame.ClientConfig:GetFloat("NewYearShowDrawTipsTime") +local RotateSpeed = CS.XGame.ClientConfig:GetFloat("LuckDrawCoinsRotateSpeed") +local NewYearCoinsPerDragAddSpeed = CS.XGame.ClientConfig:GetFloat("NewYearCoinsPerDragAddSpeed") +local NewYearCoinsMaxAddSpeed = CS.XGame.ClientConfig:GetFloat("NewYearCoinsMaxAddSpeed") +local NewYearCoinsDampAddSpeed = CS.XGame.ClientConfig:GetFloat("NewYearCoinsDampAddSpeed") +local NewYearCoinsMaxSpeed = CS.XGame.ClientConfig:GetFloat("NewYearCoinsMaxSpeed") +local NewYearCoinsDampSpeed = CS.XGame.ClientConfig:GetFloat("NewYearCoinsDampSpeed") + +local Application = CS.UnityEngine.Application +local Platform = Application.platform +local RuntimePlatform = CS.UnityEngine.RuntimePlatform + +function XUiDrawNewYear:OnStart(id, signId) + self.GachaId = id + self.IsCanGacha = true + self.SignId = signId + self.IsFirst = true + self.LastId = 1 + self.Coins = {} + + self.GachaCfg = XGachaConfigs.GetGachaCfgById(id) + self.PreviewList = {} + self.PreviewList[type.IN] = {} + self.PreviewList[type.OUT] = {} + + local tempTab = {} + table.insert(tempTab, UiType) + XDataCenter.PurchaseManager.GetPurchaseListRequest(tempTab, function() + self.PurchaseDatas = XDataCenter.PurchaseManager.GetDatasByUiType(UiType) + end) + self.GachaTemplate = XGachaConfigs.GetGachaCfgById(self.GachaId) + + self:InitAutoScript() + self:InitUiScene() + self:InitPanelPreview() + self:InitDrawButtons() + --初始化硬币常规速度以及加速度数据 + self.DragActivity:SetNormalRotateSpeed(RotateSpeed, NewYearCoinsPerDragAddSpeed, + NewYearCoinsMaxAddSpeed, NewYearCoinsDampAddSpeed, NewYearCoinsMaxSpeed, NewYearCoinsDampSpeed) + self.DragActivity.gameObject:SetActiveEx(false) + --self.BuyAssert = XUiDrawBuyAssert.New(self, self.PanelBuyAsset) + self.ImgMask.gameObject:SetActiveEx(false) + + self.CStartPos.gameObject:SetActiveEx(true) + self.CCanDrawPos.gameObject:SetActiveEx(false) + self.HeiPingPingMuGo.gameObject:SetActiveEx(false) +end + +function XUiDrawNewYear:OnEnable() + --XEventManager.AddEventListener(XEventId.EVENT_PURCAHSE_BUYUSERIYUAN, self.UpdateInfo, self) + self:UpdateInfo() + self.IsReadyForGacha = false + XUiHelper.SetDelayPopupFirstGet(true) + self.ImgMask.gameObject:SetActiveEx(true) + self:PlayAnimation("DrawBegan", function() self.ImgMask.gameObject:SetActiveEx(false) end) + self:PlayLoopAnime() + + self.DragActivity.gameObject:SetActiveEx(false) + self.CStartPos.gameObject:SetActiveEx(true) + self.CCanDrawPos.gameObject:SetActiveEx(false) + self.BtnToStart.gameObject:SetActiveEx(false) + self.PurpleEffectGo.gameObject:SetActiveEx(false) + self.OrangeEffectGo.gameObject:SetActiveEx(false) + for i = 1, MAX_GACHA_BTN_COUNT do + self.Coins[i].gameObject:SetActiveEx(false) + end + + self.RefreshId = CS.XScheduleManager.ScheduleForever(function() + self:UpdateInfo() + end, 1000, 0) +end + +function XUiDrawNewYear:OnDisable() + for i = 1, 6 do + self.BackGround.transform:Find("TimeLine/Level" .. i).gameObject:SetActiveEx(false) + end + + self.PurpleEffectGo.gameObject:SetActiveEx(false) + self.OrangeEffectGo.gameObject:SetActiveEx(false) + self:ClearTimer() + if self.RefreshId then + CS.XScheduleManager.UnSchedule(self.RefreshId) + self.RefreshId = nil + end + + if self.SoundTimeId then + CS.XScheduleManager.UnSchedule(self.SoundTimeId) + self.SoundTimeId = nil + end +end + +function XUiDrawNewYear:OnDestroy() + if self.CloseCb then + self.CloseCb() + end +end + +function XUiDrawNewYear:PlayLoopAnime() + local behaviour = self.GameObject:AddComponent(typeof(CS.XLuaBehaviour)) + if self.Update then + behaviour.LuaUpdate = function() self:Update() end + end +end + +function XUiDrawNewYear:Update() + if self.IsReadyForGacha then + self:ShowGacha() + end +end + +--按钮绑定 +function XUiDrawNewYear:InitAutoScript() + self.BtnBack.CallBack = function() + self:OnBtnBackClick() + end + self.BtnMainUi.CallBack = function() + self:OnBtnMainUiClick() + end + self.BtnMore.CallBack = function() + self:OnBtnMore() + end + self.BtnUseItem.CallBack = function() + self:OnBtnUseItemClick() + end + self.BtnToStart.CallBack = function() + self:OnBtnToStartClick() + end + self.BtnHelp.CallBack = function() + self:OnBtnHelpClick() + end +end + +--获取场景中的内容 +function XUiDrawNewYear:InitUiScene() + local root = self.UiModelGo.transform + self.BackGround = root.parent.parent:FindTransform("GroupBase") + self.CStartPos = self.BackGround:FindTransform("CStartPos") + self.CCanDrawPos = self.BackGround:FindTransform("CCanDrawPos") + self.CoinsParentPoint = self.BackGround:FindTransform("CoinsParentPoint") + for i = 0, self.CoinsParentPoint.childCount - 1 do + self.CoinsParentPoint:GetChild(i).gameObject:SetActiveEx(false) + end + self.Coins[1] = self.BackGround:FindTransform("UiLuckdraw03Yingbi01") + self.Coins[2] = self.BackGround:FindTransform("UiLuckdraw03Yingbi") + self.DrawShowTipGo = self.BackGround:FindTransform("FxUiJPDrawYuandanTishi") + self.OrangeEffectGo = self.BackGround:FindTransform("FxUiJPDrawYuandanLingdangOrange") + self.PurpleEffectGo = self.BackGround:FindTransform("FxUiJPDrawYuandanLingdangPurple") + self.HeiPingPingMuGo = self.BackGround:FindTransform("FxHeipingpingmuYuanDan") + self.DrawShowTipGo.gameObject:SetActiveEx(false) + + for i = 1, MAX_GACHA_BTN_COUNT do + self.Coins[i].gameObject:SetActiveEx(false) + end +end + +--初始化两个抽奖按钮 +function XUiDrawNewYear:InitDrawButtons() + self.UseItemIcon = XDataCenter.ItemManager.GetItemBigIcon(self.GachaCfg.ConsumeId) + for i = 1, MAX_GACHA_BTN_COUNT do + local btnName = "BtnDraw" .. i + local btn = XUiHelper.TryGetComponent(self.PanelDrawButtons, btnName) + if btn then + self:InitButton(btn, i) + end + end +end + +--初始化每个按钮信息 +function XUiDrawNewYear:InitButton(btn, index) + local gachaCount = self.GachaCfg.BtnGachaCount[index] + btn.transform:Find("TxtDrawDesc"):GetComponent("Text").text = CS.XTextManager.GetText("NewYearGachaCount", gachaCount) + local itemIcon = btn.transform:Find("ImgUseItemIcon"):GetComponent("RawImage") + itemIcon:SetRawImage(self.UseItemIcon) + btn.transform:Find("TxtUseItemCount"):GetComponent("Text").text = gachaCount * self.GachaCfg.ConsumeCount + + self:RegisterClickEvent(btn:GetComponent("Button"), function() + self:OnBtnDrawClick(btn, gachaCount, index) + end) +end + +--初始化面板信息,奖励,展示 +function XUiDrawNewYear:InitPanelPreview() + local gachaInfo = {} + gachaInfo = XDataCenter.GachaManager.GetGachaRewardInfoById(self.GachaId) + + self.AllPreviewPanel = {} + self.AllPreviewPanel.Transform = self.PanelPreview.transform + XTool.InitUiObject(self.AllPreviewPanel) + --奖励预览关闭按钮 + self.AllPreviewPanel.BtnPreviewConfirm.CallBack = function() + self.PanelPreview.gameObject:SetActiveEx(false) + end + self.AllPreviewPanel.BtnPreviewClose.CallBack = function() + self.PanelPreview.gameObject:SetActiveEx(false) + end + self:SetPreviewData(gachaInfo, self.AllPreviewPanel.GridDrawActivity, self.AllPreviewPanel.PanelDrawItemSP, self.AllPreviewPanel.PanelDrawItemNA, self.PreviewList[type.IN], type.IN) + self:SetPreviewData(gachaInfo, self.GridDrawActivity, nil, nil, self.PreviewList[type.OUT], type.OUT) + + --奖励预览界面的已获得描述 + self.AllPreviewPanel.TxetFuwenben.text = string.format("%d%s%d", XDataCenter.GachaManager.GetCurCountOfAll(), '/', XDataCenter.GachaManager.GetMaxCountOfAll())--CS.XTextManager.GetText("AlreadyobtainedCount", XDataCenter.GachaManager.GetCurCountOfAll(), XDataCenter.GachaManager.GetMaxCountOfAll()) + --主界面的已获得 + self.TxtNumber.text = string.format("%d%s%d", XDataCenter.GachaManager.GetCurCountOfAll(), '/', XDataCenter.GachaManager.GetMaxCountOfAll()) + --活动名字 + self.TxtActivityTime.text = CS.XTextManager.GetText("NewYearChouJiang") +end + +--设置奖励展示 +function XUiDrawNewYear:SetPreviewData(gachaInfo, obj, parentSP, parentNA, previewList, previewType) + local count = 1 + + for i = 1, 6 do + self["GridDrawActivity" .. i].gameObject:SetActiveEx(false) + end + + for k,v in pairs(gachaInfo) do + local go = nil + if previewType == type.IN then + if v.Rare and parentSP then + go = CS.UnityEngine.Object.Instantiate(obj, parentSP) + elseif (not v.Rare) and parentNA then + go = CS.UnityEngine.Object.Instantiate(obj, parentNA) + end + else + if v.Rare then + go = self["GridDrawActivity" .. count] + count = count + 1 + end + end + + if go then + local item = XUiGridCommon.New(self, go) + local tmpData = {} + previewList[k] = item + tmpData.TemplateId = v.TemplateId + tmpData.Count = v.Count + go.gameObject:SetActiveEx(true) + item:Refresh(tmpData, nil, nil, nil, v.CurCount) + end + end +end + +--更新金币信息 +function XUiDrawNewYear:UpdateInfo() + local icon = XDataCenter.ItemManager.GetItemBigIcon(self.GachaCfg.ConsumeId) + self.ImgUseItemIcon:SetRawImage(icon) + self:UpdateItemCount() +end + +--更新持有的抽奖金币数量 +function XUiDrawNewYear:UpdateItemCount() + self.TxtUseItemCount.text = XDataCenter.ItemManager.GetItem(self.GachaCfg.ConsumeId).Count +end + +--显示获取的奖励信息 +function XUiDrawNewYear:ShowGacha() + self.BtnToStart.gameObject:SetActiveEx(false) + XDataCenter.AntiAddictionManager.BeginDrawCardAction() + self.SoundTimeId = nil + self.SoundTimeId = CS.XScheduleManager.ScheduleOnce(function() + self.OpenSound = CS.XAudioManager.PlaySound(XSoundManager.UiBasicsMusic.UiLuckDraw_DragCoin) + end, startPlaySoundTime) + + self:UpdateItemCount() + self.IsCanGacha = self.RewardList and #self.RewardList > 0 + self.IsReadyForGacha = false + self:PushShow(self.RewardList) + + self:UpDataPreviewData() +end + +function XUiDrawNewYear:UpDataPreviewData() + local gachaInfo = XDataCenter.GachaManager.GetGachaRewardInfoById(self.GachaId) + for i = 1, 2 do + for k,v in pairs(self.PreviewList[i] or {}) do + local tmpData = {} + tmpData.TemplateId = gachaInfo[k].TemplateId + tmpData.Count = gachaInfo[k].Count + v:Refresh(tmpData, nil, nil, nil, gachaInfo[k].CurCount) + end + end + self.AllPreviewPanel.TxetFuwenben.text = CS.XTextManager.GetText("AlreadyobtainedCount", XDataCenter.GachaManager.GetCurCountOfAll(), XDataCenter.GachaManager.GetMaxCountOfAll()) + self.TxtNumber.text = XDataCenter.GachaManager.GetCurCountOfAll() .. "/" .. XDataCenter.GachaManager.GetMaxCountOfAll() +end + +--显示抽奖完成展示界面 +function XUiDrawNewYear:PushShow(rewardList) + self:OpenChildUi("UiDrawNewYearActivityShow") + self:FindChildUiObj("UiDrawNewYearActivityShow"):SetData(rewardList, function() + if self.OpenSound then + self.OpenSound:Stop() + end + self:PushResult(rewardList) + self:UpdateInfo() + end, self.BackGround) +end + +function XUiDrawNewYear:PushResult(rewardList) + XLuaUiManager.Open("UiDrawResult", nil, rewardList, function() end) +end + +function XUiDrawNewYear:OnBtnBackClick() + self:Close() +end + +function XUiDrawNewYear:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiDrawNewYear:OnBtnMore() + self.PanelPreview.gameObject:SetActiveEx(true) + self:PlayAnimation("PanelPreviewEnable") +end + +function XUiDrawNewYear:OnBtnUseItemClick() + local data = XDataCenter.ItemManager.GetItem(self.GachaCfg.ConsumeId) + XLuaUiManager.Open("UiTip", data) +end + +function XUiDrawNewYear:OnBtnToStartClick() + self:PlayAnimation("DrawBegan") + self:ClearTimer() + self.BtnToStart.gameObject:SetActiveEx(false) + self.CStartPos.gameObject:SetActiveEx(true) + self.CCanDrawPos.gameObject:SetActiveEx(false) + for i = 1, MAX_GACHA_BTN_COUNT do + self.Coins[i].gameObject:SetActiveEx(false) + end + + self.DragActivity.gameObject:SetActiveEx(false) +end + +function XUiDrawNewYear:OnBtnHelpClick() + XLuaUiManager.Open("UiNewYearDrawLog", self.SignId) +end + +--抽奖 +function XUiDrawNewYear:OnBtnDrawClick(btn, gachaCount, index) + local ownItemCount = XDataCenter.ItemManager.GetItem(self.GachaCfg.ConsumeId).Count + local lackItemCount = self.GachaCfg.ConsumeCount * gachaCount - ownItemCount + if lackItemCount > 0 then + local leftTimes = XDataCenter.GachaManager.GetMaxCountOfAll() - XDataCenter.GachaManager.GetCurCountOfAll() + if gachaCount > leftTimes then + XUiManager.TipText("DrawNewYearLeftTimes") + return + end + + local titleText = TextManager.GetText("DrawNewYearBuyCosumeItemTitle") + local contentText = TextManager.GetText("DrawNewYearBuyCosumeItemContent") + XUiManager.DialogTip(titleText, contentText, XUiManager.DialogType.Normal, nil, function() + XLuaUiManager.Open("UiPurchase", XPurchaseConfigs.TabsConfig.LB, nil, 3) + end) + --local purchaseCfg + --for _, v in pairs(self.PurchaseDatas) do + --if v.Id == self.GachaTemplate.BtnGachaPurchaseID[index] then + --purchaseCfg = v + --end + --end + + --if not XDataCenter.PayManager.CheckCanBuy(purchaseCfg.Id) then + --return + --end + + --if purchaseCfg.PayKeySuffix then + --local key + --if Platform == RuntimePlatform.Android then + --key = string.format("%s%s", XPayConfigs.GetPlatformConfig(1), purchaseCfg.PayKeySuffix) + --else + --key = string.format("%s%s", XPayConfigs.GetPlatformConfig(2), purchaseCfg.PayKeySuffix) + --end + --XDataCenter.PayManager.Pay(key, 1, { purchaseCfg.Id }, purchaseCfg.Id) + --end + return + end + + self:PlayAnimation("DrawRetract", function() + if not self.CCanDrawPos.gameObject.activeSelf then + self.CStartPos.gameObject:SetActiveEx(false) + self.CCanDrawPos.gameObject:SetActiveEx(true) + end + self.DragActivity.gameObject:SetActiveEx(true) + for i = 1, MAX_GACHA_BTN_COUNT do + self.Coins[i].gameObject:SetActiveEx(false) + end + + if self.Coins[index] then + self.Coins[index].gameObject:SetActiveEx(true) + end + self.DragActivity:SetOperatorGo(self.Coins[index].gameObject, function() + self:OnStartDraw(gachaCount) + end) + + self.IsFirst = false + self.LastId = index + end) + + self.DrawTipTimeId = CS.XScheduleManager.ScheduleOnce(function () + self.DrawShowTipGo.gameObject:SetActiveEx(true) + end, ShowDrawTipTime * 1000) + self.BtnToStart.gameObject:SetActiveEx(true) +end + +--硬币滑动结束后开始抽奖 +function XUiDrawNewYear:OnStartDraw(gachaCount) + local dtCount = XDataCenter.GachaManager.GetMaxCountOfAll() - XDataCenter.GachaManager.GetCurCountOfAll() + if dtCount < gachaCount then + XUiManager.TipMsg(CS.XTextManager.GetText("GachaIsNotEnough")) + return + end + + --if not XDataCenter.GachaManager.CheckGachaIsOpenById(self.GachaCfg.Id, true) then + --self:PlayAnimation("DrawBegan") + --return + --end + if self.IsCanGacha then + self.IsCanGacha = false + + characterRecord.Record() + self.ImgMask.gameObject:SetActiveEx(true) + + XDataCenter.GachaManager.DoGacha(self.GachaCfg.Id, gachaCount, function(rewardList) + self.IsReadyForGacha = true + self.RewardList = rewardList + end, function() + self:OnBtnToStartClick() + self.ImgMask.gameObject:SetActiveEx(false) + self.IsCanGacha = true + end) + end + + self:ClearTimer() +end + +function XUiDrawNewYear:ClearTimer() + self.DrawShowTipGo.gameObject:SetActiveEx(false) + if self.DrawTipTimeId then + CS.XScheduleManager.UnSchedule(self.DrawTipTimeId) + self.DrawTipTimeId = nil + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNewYearDrawActivity/XUiDrawNewYearActivityShow.lua b/Resources/Scripts/XUi/XUiNewYearDrawActivity/XUiDrawNewYearActivityShow.lua new file mode 100644 index 00000000..c90ebdf6 --- /dev/null +++ b/Resources/Scripts/XUi/XUiNewYearDrawActivity/XUiDrawNewYearActivityShow.lua @@ -0,0 +1,562 @@ +local XUiDrawNewYearActivityShow = XLuaUiManager.Register(XLuaUi, "UiDrawNewYearActivityShow") +local drawShowWeapon = require("XUi/XUiDraw/XUiDrawTools/XUiDrawWeapon") +local drawShowEffect = require("XUi/XUiDraw/XUiDrawTools/XUiDrawShowEffect") +local drawScene = require("XUi/XUiDraw/XUiDrawTools/XUiDrawScene") + +function XUiDrawNewYearActivityShow:OnAwake() + self:InitAutoScript() +end + +function XUiDrawNewYearActivityShow:OnStart() + self.Animation = self.Transform:GetComponent("Animation") + self:InitImgRewards() + self.RareCount = XGachaConfigs.GetAllRareGacha() +end + +function XUiDrawNewYearActivityShow:SetData(rewardList, resultCb, backGround) + self.BackGround = backGround + self.RewardList = rewardList + self.ResultCb = resultCb + + self:ResetState() + self:InitTools() + self.ShowIndex = 1 + self.IsOpening = false + self.CurLight = {} + self.PlayBoxAnim = false + self.BtnClick.gameObject:SetActiveEx(false) + self:InitDrawBackGround() + XUiHelper.SetDelayPopupFirstGet(true) +end + +function XUiDrawNewYearActivityShow:OnDisable() + self:HideAllEffect() + XUiHelper.SetDelayPopupFirstGet() +end + +function XUiDrawNewYearActivityShow:Update() + if self.PlayBoxAnim then + if self.PlayableDirector.time >= self.PlayableDirector.duration - 0.1 then + self.BackGround:FindTransform("UiLuckdraw03Yingbi01").gameObject:SetActiveEx(false) + self.BackGround:FindTransform("UiLuckdraw03Yingbi").gameObject:SetActiveEx(false) + self:BoxAnimEnd() + end + end +end + +function XUiDrawNewYearActivityShow:InitImgRewards() + self.ImgRewards = {} + self.ImgRewards[XArrangeConfigs.Types.Character] = self.ImgCharacter + self.ImgRewards[XArrangeConfigs.Types.Fashion] = self.ImgItem + self.ImgRewards[XArrangeConfigs.Types.Item] = self.ImgItem + self.ImgRewards[XArrangeConfigs.Types.Wafer] = self.ImgWafer + self.ImgRewards[XArrangeConfigs.Types.Weapon] = self.ImgEquip + self.ImgRewards[XArrangeConfigs.Types.Furniture] = self.ImgItem + self.ImgRewards[XArrangeConfigs.Types.HeadPortrait] = self.ImgItem +end + +function XUiDrawNewYearActivityShow:ResetState() + self.ImgCharacter.gameObject:SetActiveEx(false) + self.ImgItem.gameObject:SetActiveEx(false) + self.ImgWafer.gameObject:SetActiveEx(false) + self.ImgEquip.gameObject:SetActiveEx(false) + self.ImageItemPack.gameObject:SetActiveEx(false) + self.ImageWeaponPack.gameObject:SetActiveEx(false) + self.ImageCharacterPack.gameObject:SetActiveEx(false) + self.ImageWaferPack.gameObject:SetActiveEx(false) +end + +function XUiDrawNewYearActivityShow:InitTools() + --drawScene.AddObject(self.PanelWeapon, drawScene.Types.WEAPON) + --drawShowWeapon.SetNode(self.PanelAnim, self.PanelWeapon) + drawScene.SetActive(drawScene.Types.BOX, false) + drawScene.SetActive(drawScene.Types.BG, false) + XRTextureManager.SetTextureCache(self.RImgDrawCardShow) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiDrawNewYearActivityShow:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiDrawNewYearActivityShow:AutoInitUi() + -- self.PanelDrawBackGround = self.Transform:Find("FullScreenBackground/PanelDrawBackGround") + -- self.PanelResult = self.Transform:Find("SafeAreaContentPane/PanelResult") + -- self.ImgItem = self.Transform:Find("SafeAreaContentPane/PanelResult/ImgItem"):GetComponent("RawImage") + -- self.ImgCharacter = self.Transform:Find("SafeAreaContentPane/PanelResult/ImgCharacter"):GetComponent("RawImage") + -- self.ImgWafer = self.Transform:Find("SafeAreaContentPane/PanelResult/ImgWafer"):GetComponent("RawImage") + -- self.RImgDrawCardShow = self.Transform:Find("SafeAreaContentPane/RImgDrawCardShow"):GetComponent("RawImage") + -- self.PanelEffect = self.Transform:Find("SafeAreaContentPane/PanelEffect") + -- self.BtnClick = self.Transform:Find("SafeAreaContentPane/BtnClick"):GetComponent("Button") + -- self.PanelAnim = self.Transform:Find("SafeAreaContentPane/ModelRoot/NearRoot/PanelAnim") + -- self.PanelInfo = self.Transform:Find("SafeAreaContentPane/PanelInfo") + -- self.TxtType = self.Transform:Find("SafeAreaContentPane/PanelInfo/TxtType"):GetComponent("Text") + -- self.TxtName = self.Transform:Find("SafeAreaContentPane/PanelInfo/TxtName"):GetComponent("Text") + -- self.TxtQuality = self.Transform:Find("SafeAreaContentPane/PanelInfo/TxtQuality"):GetComponent("Text") + -- self.ImgEquip = self.Transform:Find("SafeAreaContentPane/PanelResult/ImgEquip"):GetComponent("RawImage") + -- self.BtnSkip = self.Transform:Find("SafeAreaContentPane/BtnSkip"):GetComponent("Button") +end + +function XUiDrawNewYearActivityShow:AutoAddListener() + self:RegisterClickEvent(self.BtnClick, self.OnBtnClickClick) + self:RegisterClickEvent(self.BtnSkip, self.OnBtnSkipClick) +end +-- auto +function XUiDrawNewYearActivityShow:OnBtnClickClick() + if self.IsOpening then + self:ShowResult() + else + self:HideAllEffect() + self:NextPack() + end +end + +function XUiDrawNewYearActivityShow:OnBtnSkipClick() + self:ClearLastModel() + self:PlayEnd() +end + +function XUiDrawNewYearActivityShow:ShowWeapon() + drawScene.SetActive(drawScene.Types.WEAPON, true) +end + +function XUiDrawNewYearActivityShow:ShowResult() + XUiHelper.StopAnimation(false) + + local reward = self.RewardList[self.ShowIndex] + local id = reward.Id and reward.Id > 0 and reward.Id or reward.TemplateId + if reward.ConvertFrom > 0 then + id = reward.ConvertFrom + end + local Type = XTypeManager.GetTypeById(id) + local quality + local templateIdData = XGoodsCommonManager.GetGoodsShowParamsByTemplateId(id) + if Type == XArrangeConfigs.Types.Wafer then + quality = templateIdData.Star + elseif Type == XArrangeConfigs.Types.Weapon then + quality = templateIdData.Star + elseif Type == XArrangeConfigs.Types.Character then + quality = XCharacterConfigs.GetCharMinQuality(id) + else + quality = XTypeManager.GetQualityById(id) + end + local showTable = XDataCenter.DrawManager.GetDrawNewYearShow(Type) + local skipEffect = string.gsub(showTable.PanelGachaOpenUp[quality], ".prefab", "Skip.prefab") + self.CurPanelOpenUpEffect = self.PanelOpenUp:LoadPrefab(skipEffect) + self.CurPanelOpenUpEffect.gameObject.name = skipEffect + self.CurPanelOpenUpEffect.gameObject:SetActiveEx(true) + + local reward = self.RewardList[self.ShowIndex] + local id = reward.Id and reward.Id > 0 and reward.Id or reward.TemplateId + if reward.ConvertFrom > 0 then + id = reward.ConvertFrom + end + + local Type = XTypeManager.GetTypeById(id) + local showTable = XDataCenter.DrawManager.GetDrawNewYearShow(Type) + self.IsOpening = false + self.Animation:Play(showTable.UiResultAnim) + -- if Type == XArrangeConfigs.Types.Weapon then + -- drawShowWeapon.PlayResultAnim() + -- end + + self.ShowIndex = self.ShowIndex + 1 +end + +function XUiDrawNewYearActivityShow:ClearLastModel() + if self.LastCharacterModel then + self.LastCharacterModel.gameObject:SetActiveEx(false) + self.LastCharacterModel = nil + end + + if self.LastWeaponModel then + self.LastWeaponModel.gameObject:SetActiveEx(false) + self.LastWeaponModel = nil + end +end + +function XUiDrawNewYearActivityShow:NextPack() + self.BtnClick.gameObject:SetActiveEx(false) + self:ClearLastModel() + if self.ShowIndex > #self.RewardList then + self:PlayEnd() + return + end + + if self.CvInfo then + self.CvInfo:Stop() + self.CvInfo = nil + end + + local reward = self.RewardList[self.ShowIndex] + local id = reward.Id and reward.Id > 0 and reward.Id or reward.TemplateId + if reward.ConvertFrom > 0 then + id = reward.ConvertFrom + end + + local Type = XTypeManager.GetTypeById(id) + local quality + local templateIdData = XGoodsCommonManager.GetGoodsShowParamsByTemplateId(id) + if Type == XArrangeConfigs.Types.Wafer then + quality = templateIdData.Star + elseif Type == XArrangeConfigs.Types.Weapon then + quality = templateIdData.Star + elseif Type == XArrangeConfigs.Types.Character then + quality = XCharacterConfigs.GetCharMinQuality(id) + else + quality = XTypeManager.GetQualityById(id) + end + + + local soundType = XSoundManager.UiBasicsMusic.UiDrawCard_Type.Normal + + local needCharacterNameSound = false + if quality then + if quality == 5 then + soundType = XSoundManager.UiBasicsMusic.UiDrawCard_Type.FiveStar + elseif quality == 6 then + soundType = XSoundManager.UiBasicsMusic.UiDrawCard_Type.SixStar + end + end + + local icon + if Type == XArrangeConfigs.Types.Weapon or Type == XArrangeConfigs.Types.Furniture or Type == XArrangeConfigs.Types.HeadPortrait then + local goodsShowParams = XGoodsCommonManager.GetGoodsShowParamsByTemplateId(id) + icon = goodsShowParams.BigIcon + + --if Type ~= XArrangeConfigs.Types.Weapon then + self.ImgRewards[Type]:SetRawImage(icon) + self.BtnClick.gameObject:SetActiveEx(true) + self.ImgRewards[Type].gameObject:SetActiveEx(true) + --end + else + if Type == XArrangeConfigs.Types.Character then + icon = XDataCenter.CharacterManager.GetCharHalfBodyImage(id) + if quality < 3 then + soundType = XSoundManager.UiBasicsMusic.UiDrawCard_Type.FiveStar + elseif quality > 2 then + soundType = XSoundManager.UiBasicsMusic.UiDrawCard_Type.SixStar + end + needCharacterNameSound = true + elseif Type == XArrangeConfigs.Types.Wafer then + local star = self.RewardList[self.ShowIndex].Star + icon = XDataCenter.EquipManager.GetEquipLiHuiPath(id) + elseif Type == XArrangeConfigs.Types.Item then + icon = XDataCenter.ItemManager.GetItemBigIcon(id) + elseif Type == XArrangeConfigs.Types.Fashion then + icon = XDataCenter.FashionManager.GetFashionIcon(id) + end + + if Type ~= XArrangeConfigs.Types.Character then + self.ImgRewards[Type]:SetRawImage(icon) + self.BtnClick.gameObject:SetActiveEx(true) + end + end + local curShowNum = self.ShowIndex + local showTable = XDataCenter.DrawManager.GetDrawNewYearShow(Type) + self.IsOpening = true + XUiHelper.StopAnimation(false) + XUiHelper.PlayAnimation(self, showTable.UiAnim, nil, function() + self.PanelCardShowOff.gameObject:SetActiveEx(true) + if self.GameObject.activeInHierarchy then + if curShowNum == self.ShowIndex then + self.CurPanelOpenUpEffect = self.PanelOpenUp.transform:Find(showTable.PanelGachaOpenUp[quality]) + if self.CurPanelOpenUpEffect then + self.CurPanelOpenUpEffect.gameObject:SetActiveEx(true) + else + self.CurPanelOpenUpEffect = self.PanelOpenUp:LoadPrefab(showTable.PanelGachaOpenUp[quality]) + self.CurPanelOpenUpEffect.gameObject.name = showTable.PanelGachaOpenUp[quality] + self.CurPanelOpenUpEffect.gameObject:SetActiveEx(true) + end + end + if Type == XArrangeConfigs.Types.Character then + self:ShowCharacterModel(id) + -- elseif Type == XArrangeConfigs.Types.Weapon then + -- self:ShowWeaponModel(id) + end + if Type ~= XArrangeConfigs.Types.Character then + self.ImgRewards[Type].gameObject:SetActiveEx(true) + end + XUiHelper.PlayAnimation(self, showTable.UiAnim .. "Item", nil, function() + if curShowNum == self.ShowIndex then + self.IsOpening = false + self.ShowIndex = self.ShowIndex + 1 + end + if Type ~= XArrangeConfigs.Types.Character then + self.ImgRewards[Type].gameObject:SetActiveEx(true) + end + end) + end + + CS.XAudioManager.PlaySound(soundType.Show) + end) + + CS.XAudioManager.PlaySound(soundType.Start) + + local templeid = id + if XArrangeConfigs.Types.Furniture == reward.RewardType then + local cfg = XFurnitureConfigs.GetFurnitureReward(id) + if cfg and cfg.FurnitureId then + templeid = cfg.FurnitureId + end + end + self.TxtName.text = XTypeManager.GetNameById(templeid) + self.TxtType.text = showTable.TypeText + self.TxtQuality.text = showTable.QualityText[quality] + + --effect + self.PanelOpenUp.gameObject:SetActiveEx(true) + self.PanelOpenDown.gameObject:SetActiveEx(true) + -- self.PanelCardShowOff.gameObject:SetActiveEx(true) + self.CurPanelOpenDownEffect = self.PanelOpenDown.transform:Find(showTable.PanelGachaOpenDown[quality]) + -- self.CurPanelCardShowOffEffect = self.PanelCardShowOff.transform:Find(showTable.PanelCardShowOff[quality]) + if self.CurPanelOpenDownEffect then + self.CurPanelOpenDownEffect.gameObject:SetActiveEx(true) + else + self.CurPanelOpenDownEffect = self.PanelOpenDown:LoadPrefab(showTable.PanelGachaOpenDown[quality]) + self.CurPanelOpenDownEffect.gameObject.name = showTable.PanelGachaOpenDown[quality] + self.CurPanelOpenDownEffect.gameObject:SetActiveEx(true) + end + -- if self.CurPanelCardShowOffEffect then + -- self.CurPanelCardShowOffEffect.gameObject:SetActiveEx(true) + -- else + -- self.CurPanelCardShowOffEffect = self.PanelCardShowOff:LoadPrefab(showTable.PanelCardShowOff[quality]) + -- self.CurPanelCardShowOffEffect.gameObject.name = showTable.PanelCardShowOff[quality] + -- self.CurPanelCardShowOffEffect.gameObject:SetActiveEx(true) + -- end +end + +function XUiDrawNewYearActivityShow:ShowWeaponModel(templateId) + local modelConfig = XDataCenter.EquipManager.GetWeaponModelCfg(templateId, self.Name, 0) + if modelConfig then + XModelManager.LoadWeaponModel(modelConfig.ModelId, self.WeaponRoot, modelConfig.TransfromConfig, function(model) + local rotate = self.WeaponRoot:GetComponent("XAutoRotation") + if rotate then + rotate.RotateSelf = false + rotate.Inited = false + rotate.Target = model.transform + end + + model.gameObject:SetActiveEx(true) + self.LastWeaponModel = model + self.BtnClick.gameObject:SetActiveEx(true) + end) + end +end + +function XUiDrawNewYearActivityShow:ShowCharacterModel(templateId) + if not self.InitRoleMode then + self.InitRoleMode = true + self.RoleModelPanel = XUiPanelRoleModel.New(self.CharacterRoot, self.Name, true, false, false) + end + + local fashtionId = XCharacterConfigs.GetCharacterTemplate(templateId).DefaultNpcFashtionId + XDataCenter.DisplayManager.UpdateRoleModel(self.RoleModelPanel, templateId, nil, fashtionId) + + self.RoleModelPanel:UpdateCharacterModel(templateId, self.CharacterRoot, XModelManager.MODEL_UINAME.XUiDrawShow, function(model) + CS.XAudioManager.PlaySound(XSoundManager.UiBasicsMusic.UiDrawCard_Chouka_Name) + model.gameObject:SetActiveEx(true) + + local animeID = XDataCenter.DrawManager.GetDrawShowCharacter(templateId).AnimeID + local voiceId = XDataCenter.DrawManager.GetDrawShowCharacter(templateId).VoiceId + + if animeID then + self.RoleModelPanel:PlayAnima(animeID) + end + + if voiceId then + self.CvInfo = CS.XAudioManager.PlayCv(voiceId) + end + + self.LastCharacterModel = model + self.BtnClick.gameObject:SetActiveEx(true) + end, nil, fashtionId) +end + +function XUiDrawNewYearActivityShow:HideAllEffect() + if not XTool.UObjIsNil(self.PanelOpenUp) then + self.PanelOpenUp.gameObject:SetActiveEx(false) + end + if not XTool.UObjIsNil(self.PanelOpenDown) then + self.PanelOpenDown.gameObject:SetActiveEx(false) + end + if not XTool.UObjIsNil(self.PanelCardShowOff) then + self.PanelCardShowOff.gameObject:SetActiveEx(false) + end + if not XTool.UObjIsNil(self.CurPanelOpenUpEffect) then + self.CurPanelOpenUpEffect.gameObject:SetActiveEx(false) + end + if not XTool.UObjIsNil(self.CurPanelOpenDownEffect) then + self.CurPanelOpenDownEffect.gameObject:SetActiveEx(false) + end + if not XTool.UObjIsNil(self.CurPanelCardShowOffEffect) then + self.CurPanelCardShowOffEffect.gameObject:SetActiveEx(false) + end +end + +function XUiDrawNewYearActivityShow:PlayEnd() + XUiHelper.StopAnimation() + + self.BtnClick.gameObject:SetActiveEx(true) + drawScene.SetActive(drawScene.Types.BOX, true) + if self.CurStape_1 and not XTool.UObjIsNil(self.CurStape_1.gameObject) then + self.CurStape_1.gameObject:SetActiveEx(false) + end + if self.CurStape_2 and not XTool.UObjIsNil(self.CurStape_2.gameObject) then + self.CurStape_2.gameObject:SetActiveEx(false) + end + if self.CvInfo then + self.CvInfo:Stop() + self.CvInfo = nil + end + self:Close() + self.ResultCb() +end + +function XUiDrawNewYearActivityShow:OnDestroy() + drawScene.DestroyObject(drawScene.Types.EFFECT) + drawScene.DestroyObject(drawScene.Types.WEAPON) + drawScene.DestroyObject(drawScene.Types.SHOWBG) + drawShowEffect.Dispose() +end + +--wind +function XUiDrawNewYearActivityShow:InitDrawBackGround(backgroundName) + self.TxtType.text = "" + self.TxtName.text = "" + self.TxtQuality.text = "" + self.PanelInfo.gameObject:GetComponent("CanvasGroup").alpha = 0 + + self:PlayBoxAnimStart() +end + +function XUiDrawNewYearActivityShow:PlayBoxAnimStart() + self.PanelOpenUp = self.BackGround.transform:Find("ModelRoot/UiNearRoot/EffectRoot/PanelOpenUp") + self.PanelOpenDown = self.BackGround.transform:Find("ModelRoot/UiNearRoot/EffectRoot/PanelOpenDown") + self.PanelCardShowOff = self.BackGround.transform:Find("ModelRoot/UiNearRoot/EffectRoot/PanelCardShowOff") + self.WeaponRoot = self.BackGround.transform:Find("ModelRoot/UiNearRoot/WeaponRoot") + self.CharacterRoot = self.BackGround.transform:Find("ModelRoot/UiNearRoot/CharacterRoot") + + local behaviour = self.GameObject:AddComponent(typeof(CS.XLuaBehaviour)) + if self.Update then + behaviour.LuaUpdate = function() self:Update() end + end + + + self.GachaShowStape_1 = self.BackGround.transform:Find("BoxEffect/Stape1") + self.GachaShowStape_2 = self.BackGround.transform:Find("BoxEffect/Stape2") + + local effectsName = "" + local effectsLevel = 1 + + effectsName,effectsLevel = self:GetMaxQualityEffectName() + + + local useTimeLineId = 2 + for i = 1, #self.RewardList do + if self.RareCount[self.RewardList[i].TemplateId] then + useTimeLineId = 1 + end + end + if self.GachaShowStape_1 then + self.CurStape_1 = self.GachaShowStape_1:LoadPrefab(XUiConfigs.GetComponentUrl("UiGachaNewYearSteap1")) + self.CurStape_1.gameObject:SetActiveEx(true) + end + if self.GachaShowStape_2 then + self.CurStape_2 = self.GachaShowStape_2:LoadPrefab(effectsName) + self.CurStape_2.gameObject:SetActiveEx(true) + end + + self.PlayableDirector = XUiHelper.TryGetComponent(self.BackGround.transform, "TimeLine/Level"..useTimeLineId, "PlayableDirector") + if self.PlayableDirector then + self.BtnSkip.gameObject:SetActiveEx(false) + self.PlayableDirector.gameObject:SetActiveEx(true) + self.PlayableDirector:Play() + self.PlayBoxAnim = true + end +end + +function XUiDrawNewYearActivityShow:BoxAnimEnd() + self.PlayBoxAnim = false + self.BtnSkip.gameObject:SetActiveEx(true) + self:NextPack() +end + +function XUiDrawNewYearActivityShow:GetQuality(showIndex) + local reward = self.RewardList[showIndex] + local id = reward.Id and reward.Id > 0 and reward.Id or reward.TemplateId + if reward.ConvertFrom > 0 then + id = reward.ConvertFrom + end + local quality + local templateIdData = XGoodsCommonManager.GetGoodsShowParamsByTemplateId(id) + local Type = XTypeManager.GetTypeById(id) + if Type == XArrangeConfigs.Types.Wafer then + quality = templateIdData.Star + elseif Type == XArrangeConfigs.Types.Weapon then + quality = templateIdData.Star + elseif Type == XArrangeConfigs.Types.Character then + quality = XCharacterConfigs.GetCharMinQuality(id) + else + quality = XTypeManager.GetQualityById(id) + end + return quality +end + +function XUiDrawNewYearActivityShow:GetRewardType(showIndex) + local reward = self.RewardList[showIndex] + local id = reward.Id and reward.Id > 0 and reward.Id or reward.TemplateId + if reward.ConvertFrom > 0 then + id = reward.ConvertFrom + end + local type = XTypeManager.GetTypeById(id) + return type +end + +--获取最高品级效果,按类型取每一类最大值,最后比较大小得出最大的类型和值 +function XUiDrawNewYearActivityShow:GetMaxQualityEffectName() + local maxByType = {} + + for k, v in pairs(XArrangeConfigs.Types) do + local maxQuality = 0 + for i = 1, #self.RewardList do + if self:GetRewardType(i) == v then + local tempQuality = self:GetQuality(i) + if tempQuality > maxQuality then + maxQuality = tempQuality + end + end + end + maxByType[k] = maxQuality + end + local maxEffectLevel = 1 + local maxEffectPath + for k, v in pairs(XArrangeConfigs.Types) do + if maxByType[k] > 0 then + local showTable = XDataCenter.DrawManager.GetDrawNewYearShow(v) + if tonumber(string.sub(showTable.EffectOpenGacha[maxByType[k]], -8, -8)) > maxEffectLevel then + maxEffectLevel = tonumber(string.sub(showTable.EffectOpenGacha[maxByType[k]], -8, -8)) + maxEffectPath = showTable.EffectOpenGacha[maxByType[k]] + end + end + end + return maxEffectPath, maxEffectLevel +end + +function XUiDrawNewYearActivityShow:SetWeaponPos(target, config) + if not target or not config then + return + end + target.transform.localPosition = CS.UnityEngine.Vector3(config.PositionX, config.PositionY, config.PositionZ) + --检查数据 模型旋转 + target.transform.localEulerAngles = CS.UnityEngine.Vector3(config.RotationX, config.RotationY, config.RotationZ) + --检查数据 模型大小 + target.transform.localScale = CS.UnityEngine.Vector3( + config.ScaleX == 0 and 1 or config.ScaleX, + config.ScaleY == 0 and 1 or config.ScaleY, + config.ScaleZ == 0 and 1 or config.ScaleZ + ) +end +--windEnd \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNewYearDrawActivity/XUiNewYearDrawLog.lua b/Resources/Scripts/XUi/XUiNewYearDrawActivity/XUiNewYearDrawLog.lua new file mode 100644 index 00000000..9386f792 --- /dev/null +++ b/Resources/Scripts/XUi/XUiNewYearDrawActivity/XUiNewYearDrawLog.lua @@ -0,0 +1,56 @@ +local XUiNewYearDrawLog = XLuaUiManager.Register(XLuaUi, "UiNewYearDrawLog") + +function XUiNewYearDrawLog:OnStart(id) + self.Id = id + self.BtnTanchuangClose.CallBack = function() + self:OnBtnTanchuangClose() + end + self.BtnClose.CallBack = function() + self:OnBtnTanchuangClose() + end + self:InitBaseRulePanel() +end + +function XUiNewYearDrawLog:InitBaseRulePanel() + local cfg = XSignInConfigs.GetSignDrawNewYearConfig(self.Id) + local baseRules = cfg.RuleTitle + local baseRuleTitles = cfg.RuleContent + self:SetRuleData(baseRules, baseRuleTitles, self.Panel1) +end + +function XUiNewYearDrawLog:SetRuleData(rules, ruleTitles, panel) + local PanelObj = {} + PanelObj.Transform = panel.transform + XTool.InitUiObject(PanelObj) + PanelObj.PanelTxt.gameObject:SetActiveEx(false) + for k,v in pairs(rules) do + local go = CS.UnityEngine.Object.Instantiate(PanelObj.PanelTxt, PanelObj.PanelContent) + local tmpObj = {} + tmpObj.Transform = go.transform + tmpObj.GameObject = go.gameObject + local description = + XTool.InitUiObject(tmpObj) + tmpObj.TxtRule.HrefListener = function(link, content) + self:ClickLink(link) + end + local str = rules[k] + if string.find(str, "%s/%s", podExp, podMaxExp) + else + self.TxtExpNum.text = string.format("MAX") + end + + self.ImgExpSlider.fillAmount = podExp / podMaxExp +end + +function XUiFuBenNierWork:UpDateNierSkill() + local nierPODSkills = self.NierPOD:GetNieRPODSkillList() + self.NieRPODSkills = nierPODSkills + for index, skillCfg in ipairs(nierPODSkills) do + local grid + if not self.GirdSkillList[index] then + local ui + local parent = self.PanelDropContent + + if index == 1 then + ui = self.GridSubSkill + ui.gameObject:SetActiveEx(true) + ui.transform:SetParent(parent, false) + grid = XUiGridNierPODSkill.New(ui, self) + else + ui = CS.UnityEngine.Object.Instantiate(self.GridSubSkill) + ui.gameObject:SetActiveEx(true) + ui.transform:SetParent(parent, false) + grid = XUiGridNierPODSkill.New(ui, self) + end + self.GirdSkillList[index] = grid + grid:SetSelectStatue(false) + else + grid = self.GirdSkillList[index] + end + grid:RefreShData(skillCfg, index) + + end + if not self.CurSelectSkillIndex then + for index, skillCfg in ipairs(nierPODSkills) do + if self.NierPOD:CheckNieRPODSkillActive(skillCfg.SkillId) then + self:OnSkillClick(index) + break + end + end + end +end + +function XUiFuBenNierWork:UpdateSkillInfo() + if not self.CurSelectSkillIndex then return end + local index = self.CurSelectSkillIndex + local skillId = self.NieRPODSkills[index].SkillId + local skillLv = self.NierPOD:GetNieRPODSkillLevelById(skillId) + local maxSkillLv = XNieRConfigs.GetNieRSupportMaxSkillLevelById(skillId) + local skillName = self.NierPOD:GetNieRPODSkillName(skillId) + local skillDesc = self.NierPOD:GetNieRPODSkillDesc(skillId) + local skillStr = string.format("%s\n%s",skillName, skillDesc) + self.TxtContentNoticeNow.text = skillStr + + + if skillLv >= maxSkillLv then + self.PanelBtn.gameObject:SetActiveEx(false) + self.ImgJiantou.gameObject:SetActiveEx(false) + self.PanelShowNext.gameObject:SetActiveEx(false) + self.ImgMax.gameObject:SetActiveEx(true) + else + self.ImgJiantou.gameObject:SetActiveEx(true) + self.PanelShowNext.gameObject:SetActiveEx(true) + self.PanelBtn.gameObject:SetActiveEx(true) + self.ImgMax.gameObject:SetActiveEx(false) + local canUpLv, desc = self.NierPOD:CheckNieRPODSkillUpLevel(skillId) + if canUpLv then + self.TxtTipsCondit.text = "" + else + self.TxtTipsCondit.text = desc + end + local nextSkillInfo = XNieRConfigs.GetNieRSupportSkillClientConfig(skillId, skillLv + 1) + local nextSkillStr = string.format("%s\n%s",nextSkillInfo.Name, nextSkillInfo.Desc) + self.TxtContentNoticeNext.text = nextSkillStr + local upLvItemId, upLvItemCounts = self.NierPOD:GetNieRPODSkillUpLevelItem(skillId) + + self.TextAT.text = CS.XTextManager.GetText("NieRPODSkillUpLevelNeed", "")--XDataCenter.ItemManager.GetItemName(upLvItemId) + self.ImgATIcon:SetRawImage(XDataCenter.ItemManager.GetItemIcon(upLvItemId)) + self.TxtATNums.text = upLvItemCounts + + end +end + +function XUiFuBenNierWork:OnSkillClick(index) + if self.CurSelectSkillIndex == index then return end + local skillId = self.NieRPODSkills[index].SkillId + local active, desc = self.NierPOD:CheckNieRPODSkillActive(skillId) + if not active then + XUiManager.TipMsg(desc) + else + local grid + if self.CurSelectSkillIndex then + grid = self.GirdSkillList[self.CurSelectSkillIndex] + grid:SetSelectStatue(false) + end + self.CurSelectSkillIndex = index + grid = self.GirdSkillList[self.CurSelectSkillIndex] + grid:SetSelectStatue(true) + self:UpdateSkillInfo() + end +end + +function XUiFuBenNierWork:OnBtnBackClick() + self:Close() +end + +function XUiFuBenNierWork:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiFuBenNierWork:OnBtnSkillUpLevelClick() + if not self.CurSelectSkillIndex then return end + local skillId = self.NieRPODSkills[self.CurSelectSkillIndex].SkillId + XDataCenter.NieRManager.NieRUpgradeSupportSkill(skillId, function() + self:UpDateNierSkill() + self:UpdateSkillInfo() + XUiManager.TipMsg(CS.XTextManager.GetText("NieRPODSkillUpLevelSuccess")) + end) +end + +function XUiFuBenNierWork:OnTickJumpClick() + local item = XDataCenter.ItemManager.GetItem(self.NierPOD:GetUpSkillLevelItem()) + local data = { + Id = item.Id, + Count = item ~= nil and tostring(item.Count) or "0" + } + XLuaUiManager.Open("UiTip", data) +end + +function XUiFuBenNierWork:InitSceneRoot() + local root = self.UiModelGo.transform + -- if self.PanelRoleModel then + -- self.PanelRoleModel:DestroyChildren() + -- end + self.PanelRoleModel = root:FindTransform("PanelModelCase1") + -- self.ImgEffectHuanren = root:FindTransform("ImgEffectHuanren") + self.ImgEffectHuanren1 = root:FindTransform("ImgEffectHuanren1") + -- self.ImgEffectLogoGouzao = root:FindTransform("ImgEffectLogoGouzao") + -- self.ImgEffectLogoGanran = root:FindTransform("ImgEffectLogoGanran") + -- self.CameraFar = { + -- root:FindTransform("UiCamFarLv"), + -- root:FindTransform("UiCamFarGrade"), + -- root:FindTransform("UiCamFarQuality"), + -- root:FindTransform("UiCamFarSkill"), + -- root:FindTransform("UiCamFarrExchange"), + -- } + -- self.CameraNear = { + -- root:FindTransform("UiCamNearLv"), + -- root:FindTransform("UiCamNearGrade"), + -- root:FindTransform("UiCamNearQuality"), + -- root:FindTransform("UiCamNearSkill"), + -- root:FindTransform("UiCamNearrExchange"), + -- } + self.RoleModelPanel = XUiPanelRoleModel.New(self.PanelRoleModel, self.Name, nil, true, nil, true) +end + +--更新模型 +function XUiFuBenNierWork:UpdateRoleModel() + + self.RoleModelPanel:UpdateBossModel(self.NierPOD:GetNieRPODModel(), self.PanelRoleModel, XModelManager.MODEL_UINAME.XUiNieRPOD, function(model) + -- self.PanelDrag.Target = model.transform + end) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNieR/XUiCharacter/XUiFubenNierShengji.lua b/Resources/Scripts/XUi/XUiNieR/XUiCharacter/XUiFubenNierShengji.lua new file mode 100644 index 00000000..56fbd047 --- /dev/null +++ b/Resources/Scripts/XUi/XUiNieR/XUiCharacter/XUiFubenNierShengji.lua @@ -0,0 +1,56 @@ +local XUiFubenNierShengji = XLuaUiManager.Register(XLuaUi, "UiFubenNierShengji") +local XGridNieRUpLvDetail = require("XUi/XUiNieR/XUiCharacter/XGridNieRUpLvDetail") +local XGridNieRPODUpLvDetail = require("XUi/XUiNieR/XUiCharacter/XGridNieRPODUpLvDetail") + +function XUiFubenNierShengji:OnAwake() + self.BtnClose.CallBack = function() self:OnBtnCloseClick() end + + self.PanelShengjiDetail.gameObject:SetActiveEx(false) + self.PanelPodShengjiDetail.gameObject:SetActiveEx(false) +end + +function XUiFubenNierShengji:OnStart(dataList, podInfo, closeCb) + self.CloseCb = closeCb + self.DataList = dataList + self.PodInfo = podInfo +end + +function XUiFubenNierShengji:OnEnable() + self:UpdateGrid(self.DataList, self.PodInfo) +end + +function XUiFubenNierShengji:OnDisable() + +end + +function XUiFubenNierShengji:OnDestroy() + +end + +function XUiFubenNierShengji:UpdateGrid(dataList, podInfo) + local upCharacterNum = #dataList + local maxCharNum = podInfo and 2 or 3 + upCharacterNum = upCharacterNum > maxCharNum and maxCharNum or upCharacterNum + for i = 1, upCharacterNum do + local ui = CS.UnityEngine.Object.Instantiate(self.PanelShengjiDetail) + local grid = XGridNieRUpLvDetail.New(self, ui) + grid.Transform:SetParent(self.PanelShengjiList, false) + grid.GameObject:SetActiveEx(true) + grid:UpdateInfo(dataList[i]) + end + + if podInfo then + local ui = CS.UnityEngine.Object.Instantiate(self.PanelPodShengjiDetail) + local grid = XGridNieRPODUpLvDetail.New(self, ui) + grid.Transform:SetParent(self.PanelShengjiList, false) + grid.GameObject:SetActiveEx(true) + grid:UpdateInfo(podInfo) + end +end + +function XUiFubenNierShengji:OnBtnCloseClick() + if self.CloseCb then + self.CloseCb() + end + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNieR/XUiCharacter/XUiGridNierPODSkill.lua b/Resources/Scripts/XUi/XUiNieR/XUiCharacter/XUiGridNierPODSkill.lua new file mode 100644 index 00000000..b5186374 --- /dev/null +++ b/Resources/Scripts/XUi/XUiNieR/XUiCharacter/XUiGridNierPODSkill.lua @@ -0,0 +1,65 @@ +local XUiGridNierPODSkill = XClass(nil, "XUiGridNierPODSkill") + +function XUiGridNierPODSkill:Ctor(ui, rootUi) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + + self.BtnSkill.CallBack = function() self:OnBtnSkillClick() end + self:SetSelectStatue(false) +end + +function XUiGridNierPODSkill:RefreShData(skillInfo, index) + self.NierPOD = XDataCenter.NieRManager.GetNieRPODData() + self.Index = index + local skillId = skillInfo.SkillId + local skillName = self.NierPOD:GetNieRPODSkillName(skillId) + local skillIcon = self.NierPOD:GetNieRPODSkillIcon(skillId) + local condit, desc = self.NierPOD:CheckNieRPODSkillActive(skillId) + local levelStr = CS.XTextManager.GetText("NieRPODSkillLevel", self.NierPOD:GetNieRPODSkillLevelById(skillId)) + + self.TxtNameNor.text = skillName + self.TxtNameSel.text = skillName + self.TxtLevelNor.text = levelStr + self.TxtLevelSel.text = levelStr + if not condit then + self.PanelIconTip.gameObject:SetActiveEx(true) + else + self.PanelIconTip.gameObject:SetActiveEx(false) + end + self.RImgSubSkillIconNormal:SetRawImage(skillIcon) + self.ImgSubSkillIconSelected:SetRawImage(skillIcon) + + local isRed = false + if condit and self.NierPOD:CheckNieRPODSkillUpLevel(skillId) then + local cousumId, consumCount = self.NierPOD:GetNieRPODSkillUpLevelItem(skillId) + if cousumId ~= 0 then + local haveCount = XDataCenter.ItemManager.GetCount(cousumId) + if haveCount >= consumCount then + isRed = true + end + end + + end + if self.ImgBeidong then + if not self.NierPOD:CheckNieRPODSkillActiveSkill(skillId) then + self.ImgBeidong.gameObject:SetActiveEx(true) + else + self.ImgBeidong.gameObject:SetActiveEx(false) + end + end + self.Red.gameObject:SetActiveEx(isRed) +end + +function XUiGridNierPODSkill:SetSelectStatue(isSel) + self.ImgBgSelected.gameObject:SetActiveEx(isSel) + self.NomalLevel.gameObject:SetActiveEx(not isSel) + self.SlectlLevel.gameObject:SetActiveEx(isSel) +end + +function XUiGridNierPODSkill:OnBtnSkillClick() + self.RootUi:OnSkillClick(self.Index) +end +return XUiGridNierPODSkill \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNieR/XUiCharacter/XUiGrideNieRCharacterFoster.lua b/Resources/Scripts/XUi/XUiNieR/XUiCharacter/XUiGrideNieRCharacterFoster.lua new file mode 100644 index 00000000..83de1273 --- /dev/null +++ b/Resources/Scripts/XUi/XUiNieR/XUiCharacter/XUiGrideNieRCharacterFoster.lua @@ -0,0 +1,168 @@ +local XUiGrideNieRCharacterFoster = XClass(nil, "XUiGrideNieRCharacterFoster") + +function XUiGrideNieRCharacterFoster:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + self.BtnCondition.CallBack = function() self:OnBtnConditionClick() end +end + +function XUiGrideNieRCharacterFoster:Init(rootUi) + self.RootUi = rootUi +end + +function XUiGrideNieRCharacterFoster:ResetData(data, index) + self.Index = index + local characterData = self.RootUi.CharacterData + local config = XNieRConfigs.GetAbilityGroupConfigById(data.ConfigId) + + local isActive = XConditionManager.CheckCondition(config.Condition) + self.TxtName.text = config.TitleStr + self.TxtNameAc.text = config.TitleStr + if data.Type == XNieRConfigs.AbilityType.Skill then + local skillId = config.SkillId + local skillLevel = config.SkillLevel + self:CreateSkill(skillId, skillLevel, isActive) + elseif data.Type == XNieRConfigs.AbilityType.Fashion then + local fashionId = config.FashionId + self:CreateFashion(fashionId, isActive) + elseif data.Type == XNieRConfigs.AbilityType.Weapon then + local equipId = config.WeaponId + local equipBreakthrough = characterData:GetNieRWeaponBreakThrough() + local equipLevel = characterData:GetNieRWeaponLevel() + self:CreateEquip(equipId, equipLevel, equipBreakthrough, isActive) + elseif data.Type == XNieRConfigs.AbilityType.FourWafer then + local equipId = config.WaferId[1] + local equipBreakthrough = characterData:GetNieRWaferBreakThroughById(equipId) + local equipLevel = characterData:GetNieRWaferLevel(equipId) + self:CreateEquip(equipId, equipLevel, equipBreakthrough, isActive) + elseif data.Type == XNieRConfigs.AbilityType.TwoWafer then + local equipId = config.WaferId[1] + local equipBreakthrough = characterData:GetNieRWaferBreakThroughById(equipId) + local equipLevel = characterData:GetNieRWaferLevel(equipId) + self:CreateEquip(equipId, equipLevel, equipBreakthrough, isActive) + end +end + +function XUiGrideNieRCharacterFoster:CreateSkill(skillId, skillLevel, isActive) + if not isActive then + self.GridCommon.gameObject:SetActiveEx(true) + self.GridCommonAc.gameObject:SetActiveEx(false) + self.LevelTitle.gameObject:SetActiveEx(true) + self.RImgIcon.gameObject:SetActiveEx(true) + self.ImgQuality.gameObject:SetActiveEx(false) + self.PanelSite.gameObject:SetActiveEx(false) + -- self.ItemBg.gameObject:SetActiveEx(false) + local skillInfo = XCharacterConfigs.GetSkillGradeDesConfig(skillId, skillLevel) + self.RImgIcon:SetRawImage(skillInfo.Icon) + + self.LevelLable.text = skillLevel + else + self.GridCommon.gameObject:SetActiveEx(false) + self.GridCommonAc.gameObject:SetActiveEx(true) + self.LevelTitleAc.gameObject:SetActiveEx(true) + self.RImgIconAc.gameObject:SetActiveEx(true) + self.ImgQualityAc.gameObject:SetActiveEx(false) + self.PanelSiteAc.gameObject:SetActiveEx(false) + -- self.ItemBg.gameObject:SetActiveEx(false) + local skillInfo = XCharacterConfigs.GetSkillGradeDesConfig(skillId, skillLevel) + self.RImgIconAc:SetRawImage(skillInfo.Icon) + + self.LevelLableAc.text = skillLevel + end + +end + + +function XUiGrideNieRCharacterFoster:CreateFashion(fashionId, isActive) + if not isActive then + self.GridCommon.gameObject:SetActiveEx(true) + self.GridCommonAc.gameObject:SetActiveEx(false) + self.LevelTitle.gameObject:SetActiveEx(false) + self.RImgIcon.gameObject:SetActiveEx(true) + self.ImgQuality.gameObject:SetActiveEx(false) + self.PanelSite.gameObject:SetActiveEx(false) + -- self.ItemBg.gameObject:SetActiveEx(false) + -- 图标 + local template = XDataCenter.FashionManager.GetFashionTemplate(fashionId) + self.RImgIcon:SetRawImage(template.Icon) + else + self.GridCommon.gameObject:SetActiveEx(false) + self.GridCommonAc.gameObject:SetActiveEx(true) + self.LevelTitleAc.gameObject:SetActiveEx(false) + self.RImgIconAc.gameObject:SetActiveEx(true) + self.ImgQualityAc.gameObject:SetActiveEx(false) + self.PanelSiteAc.gameObject:SetActiveEx(false) + -- self.ItemBg.gameObject:SetActiveEx(false) + -- 图标 + local template = XDataCenter.FashionManager.GetFashionTemplate(fashionId) + self.RImgIconAc:SetRawImage(template.Icon) + end +end + +function XUiGrideNieRCharacterFoster:CreateEquip(euipId, level, breakthrough, isActive) + if not isActive then + self.GridCommon.gameObject:SetActiveEx(true) + self.GridCommonAc.gameObject:SetActiveEx(false) + self.GoodsShowParams = XGoodsCommonManager.GetGoodsShowParamsByTemplateId(euipId) + self.LevelTitle.gameObject:SetActiveEx(true) + self.RImgIcon.gameObject:SetActiveEx(true) + self.ImgQuality.gameObject:SetActiveEx(true) + self.ItemBg.gameObject:SetActiveEx(true) + + -- 图标 + local icon = self.GoodsShowParams.Icon + if icon and #icon > 0 then + self.RImgIcon:SetRawImage(icon) + end + + -- 品质底图 + local qualityIcon = self.GoodsShowParams.QualityIcon + if qualityIcon then + self.ImgQuality:SetSprite(qualityIcon) + else + local spriteName = XArrangeConfigs.GeQualityPath(self.GoodsShowParams.Quality) + self.ImgQuality:SetSprite(spriteName) + end + + local showSite = self.GoodsShowParams.Site ~= XEquipConfig.EquipSite.Weapon + self.PanelSite.gameObject:SetActiveEx(showSite) + self.TxtSite.text = "0" .. self.GoodsShowParams.Site + self.LevelLable.text = level + else + self.GridCommon.gameObject:SetActiveEx(false) + self.GridCommonAc.gameObject:SetActiveEx(true) + self.GoodsShowParams = XGoodsCommonManager.GetGoodsShowParamsByTemplateId(euipId) + self.LevelTitleAc.gameObject:SetActiveEx(true) + self.RImgIconAc.gameObject:SetActiveEx(true) + self.ImgQualityAc.gameObject:SetActiveEx(true) + self.ItemBgAc.gameObject:SetActiveEx(true) + + -- 图标 + local icon = self.GoodsShowParams.Icon + if icon and #icon > 0 then + self.RImgIconAc:SetRawImage(icon) + end + + -- 品质底图 + local qualityIcon = self.GoodsShowParams.QualityIcon + if qualityIcon then + self.ImgQualityAc:SetSprite(qualityIcon) + else + local spriteName = XArrangeConfigs.GeQualityPath(self.GoodsShowParams.Quality) + self.ImgQualityAc:SetSprite(spriteName) + end + + local showSite = self.GoodsShowParams.Site ~= XEquipConfig.EquipSite.Weapon + self.PanelSiteAc.gameObject:SetActiveEx(showSite) + self.TxtSiteAc.text = "0" .. self.GoodsShowParams.Site + self.LevelLableAc.text = level + end +end + +function XUiGrideNieRCharacterFoster:OnBtnConditionClick() + self.RootUi:OnDynamicGridClick(self.Index) +end + +return XUiGrideNieRCharacterFoster \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNieR/XUiCharacter/XUiGrideNieRCharacterStory.lua b/Resources/Scripts/XUi/XUiNieR/XUiCharacter/XUiGrideNieRCharacterStory.lua new file mode 100644 index 00000000..9abfa7a4 --- /dev/null +++ b/Resources/Scripts/XUi/XUiNieR/XUiCharacter/XUiGrideNieRCharacterStory.lua @@ -0,0 +1,46 @@ +local XUiGrideNieRCharacterStory = XClass(nil, "XUiGrideNieRCharacterStory") + +function XUiGrideNieRCharacterStory:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + self.BtnUnLock.CallBack = function() self:OnBtnUnLockClick() end +end + +function XUiGrideNieRCharacterStory:Init(parent) + self.Parent = parent +end + +function XUiGrideNieRCharacterStory:ResetData(data) + self.Data = data + if data.IsUnLock == XNieRConfigs.NieRChInforStatue.UnLock then + self.PanelAnimationGroup.gameObject:SetActiveEx(true) + self.PanelAnimationlock.gameObject:SetActiveEx(false) + self.RedCanUnLock.gameObject:SetActiveEx(false) + self.TextTitle.text = data.Config.Title + self.ContentLable.text = string.gsub(data.Config.Content, "\\n", "\n") + self.TxtDescEx.text = data.Config.DescEx + elseif data.IsUnLock == XNieRConfigs.NieRChInforStatue.CanUnLock then + self.PanelAnimationGroup.gameObject:SetActiveEx(false) + self.PanelAnimationlock.gameObject:SetActiveEx(true) + self.TextTitleLock.text = data.Config.Title + self.ConditionLable.text = string.gsub(data.Desc, "\\n", "\n") + self.RedCanUnLock.gameObject:SetActiveEx(true) + else + self.PanelAnimationGroup.gameObject:SetActiveEx(false) + self.PanelAnimationlock.gameObject:SetActiveEx(true) + self.RedCanUnLock.gameObject:SetActiveEx(false) + self.TextTitleLock.text = data.Config.Title + self.ConditionLable.text = string.gsub(data.Desc, "\\n", "\n") + end +end + +function XUiGrideNieRCharacterStory:OnBtnUnLockClick() + if self.Data.IsUnLock == XNieRConfigs.NieRChInforStatue.CanUnLock then + XDataCenter.NieRManager.CheckCharacterInformationUnlock(self.Data.Config.Id, true) + self.Parent:UpdateAllInfo() + end +end + +return XUiGrideNieRCharacterStory \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNieR/XUiCharacter/XUiNierCharacter.lua b/Resources/Scripts/XUi/XUiNieR/XUiCharacter/XUiNierCharacter.lua new file mode 100644 index 00000000..aece7c7f --- /dev/null +++ b/Resources/Scripts/XUi/XUiNieR/XUiCharacter/XUiNierCharacter.lua @@ -0,0 +1,125 @@ +local XUiNierCharacter = XLuaUiManager.Register(XLuaUi, "UiNierCharacter") +local UiPanelFoster = require("XUi/XUiNieR/XUiCharacter/XUiPanelNierCharacterFoster") +local UiPanelStory = require("XUi/XUiNieR/XUiCharacter/XUiPanelNierCharacterStory") +local UiPanelTeaching = require("XUi/XUiNieR/XUiCharacter/XUiPanelNierCharacterTeaching") + +local PANEL_INDEX = { + Foster = 1, + Story = 2, + Teaching = 3, +} +function XUiNierCharacter:OnAwake() + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + self:BindHelpBtn(self.BtnHelp, "NierCharacterHelp") + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + + self.TabList = { + self.BtnTabPeiyang, + self.BtnTabDangan, + self.BtnTabJiaoxue + } + self.PanelCharacterTypeBtns:Init(self.TabList, function(index) self:OnBtnTabPanelSelect(index) end) + + self.UiPanelFoster = UiPanelFoster.New(self.PanelFoster , self) + self.UiPanelStory = UiPanelStory.New(self.PanelStory , self) + self.UiPanelTeaching = UiPanelTeaching.New(self.PanelMainlineTeaching , self) +end + +function XUiNierCharacter:OnStart() + self.CurToggleType = PANEL_INDEX.Foster + self.Character = XDataCenter.NieRManager.GetSelNieRCharacter() + self.NieRCharacterId = self.Character:GetNieRCharacterId() + self.RoleName.text = self.Character:GetNieRCharName() + + self.ImgRole:SetRawImage(self.Character:GetNieRCharacterIcon()) + + self:AddRedPointEvent() +end + +function XUiNierCharacter:OnEnable() + + + if XDataCenter.NieRManager.GetIsActivityEnd() then + XScheduleManager.ScheduleOnce(function() + XDataCenter.NieRManager.OnActivityEnd() + end, 1) + else + self.PanelCharacterTypeBtns:SelectIndex(self.CurToggleType) + end +end + +function XUiNierCharacter:OnDisable() +end + +function XUiNierCharacter:OnDestroy() +end + +--添加点事件 +function XUiNierCharacter:AddRedPointEvent() + XRedPointManager.AddRedPointEvent(self.BtnTabDangan, self.RefreshDanganRedDot, self,{ XRedPointConditions.Types.CONDITION_NIER_CHARACTER_RED }, {CharacterId = self.NieRCharacterId, IsInfor = true, IsTeach = false} ) + XRedPointManager.AddRedPointEvent(self.RedJiaoxue, self.RefreshTeachRedDot, self,{ XRedPointConditions.Types.CONDITION_NIER_CHARACTER_RED }, {CharacterId = self.NieRCharacterId, IsInfor = false, IsTeach = true} ) + self.RedPeiyang.gameObject:SetActive(false) + --self.RedJiaoxue.gameObject:SetActive(false) +end + +--任务按钮红点 +function XUiNierCharacter:RefreshDanganRedDot(count) + self.RedDangan.gameObject:SetActive(count >= 0) +end + +--任务按钮红点 +function XUiNierCharacter:RefreshTeachRedDot(count) + self.RedJiaoxue.gameObject:SetActive(count >= 0) +end + +function XUiNierCharacter:OnBtnBackClick() + self:Close() +end + +function XUiNierCharacter:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiNierCharacter:OnGetEvents() + return { XEventId.EVENT_FUBEN_ENTERFIGHT } +end + +--事件监听 +function XUiNierCharacter:OnNotify(evt, ...) + local args = { ... } + if evt == XEventId.EVENT_FUBEN_ENTERFIGHT then + self:EnterFight(args[1]) + end +end + +function XUiNierCharacter:EnterFight(stage) + if XDataCenter.FubenManager.OpenRoomSingle(stage) then + XLuaUiManager.Remove("UiFubenStageDetail") + end +end + +function XUiNierCharacter:OnBtnTabPanelSelect(index) + if index == PANEL_INDEX.Foster then + self.UiPanelStory:HidePanel() + self.UiPanelTeaching:HidePanel() + self.UiPanelFoster:ShowPanel() + + self.UiPanelFoster:InitAllData() + self.CurToggleType = PANEL_INDEX.Foster + elseif index == PANEL_INDEX.Story then + self.UiPanelFoster:HidePanel() + self.UiPanelTeaching:HidePanel() + self.UiPanelStory:ShowPanel() + + self.UiPanelStory:InitAllInfo() + self.CurToggleType = PANEL_INDEX.Story + elseif index == PANEL_INDEX.Teaching then + self.UiPanelFoster:HidePanel() + self.UiPanelStory:HidePanel() + self.UiPanelTeaching:ShowPanel() + + self.UiPanelTeaching:InitAllInfo() + self.CurToggleType = PANEL_INDEX.Teaching + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNieR/XUiCharacter/XUiNierCharacterSel.lua b/Resources/Scripts/XUi/XUiNieR/XUiCharacter/XUiNierCharacterSel.lua new file mode 100644 index 00000000..86863dd1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiNieR/XUiCharacter/XUiNierCharacterSel.lua @@ -0,0 +1,134 @@ +local XUiNierCharacterSel = XLuaUiManager.Register(XLuaUi, "UiNierCharacterSel") + +local MAX_CHAR_COUNT = 3 +function XUiNierCharacterSel:OnAwake() + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + self.BtnHelp.gameObject:SetActiveEx(false) + self.BtnCharList = {} + for index = 1, MAX_CHAR_COUNT do + local btn = self["Btn"..index] + if btn then + self.BtnCharList[index] = btn + btn.CallBack = function() self:OnRealBtnCharClick(index) end + end + end +end + +function XUiNierCharacterSel:OnStart() + local uiModelRoot = self.UiModelGo.transform + self.NierCharacters = XDataCenter.NieRManager.GetCurDevelopCharacterIds() + self.CharacterList = {} + for _, characterId in ipairs(self.NierCharacters) do + local nieRCharacter = XDataCenter.NieRManager.GetNieRCharacterByCharacterId(characterId) + if nieRCharacter then + self.CharacterList[nieRCharacter:GetNieRClientPos()] = nieRCharacter + end + end + self:AddRedPointEvent() +end + +function XUiNierCharacterSel:OnEnable() + self:InitPanelNierCharacter() +end + +function XUiNierCharacterSel:OnDisable() + +end + +function XUiNierCharacterSel:OnDestroy() + +end + + +function XUiNierCharacterSel:InitPanelNierCharacter() + local sortList = {} + for key, nieRCharacter in pairs(self.CharacterList) do + local characterBtn = self.BtnCharList[key] + local charName = nieRCharacter:GetNieRCharName() + characterBtn:SetNameByGroup(0, charName) + characterBtn:SetRawImage(nieRCharacter:GetNieRCharacterIcon()) + local condit, desc = nieRCharacter:CheckNieRCharacterCondition() + if condit then + local charLevel = "Lv." .. nieRCharacter:GetNieRCharacterLevel() + characterBtn:SetNameByGroup(1, charLevel) + characterBtn:SetDisable(false, true) + if nieRCharacter:CheckNieRCharacterMaxLevel() then + self["BtnMAX"..key].gameObject:SetActiveEx(true) + else + self["BtnMAX"..key].gameObject:SetActiveEx(false) + end + else + characterBtn:SetNameByGroup(2, desc) + characterBtn:SetDisable(true, true) + end + local tmp = {} + tmp.key = key + tmp.condit = condit + table.insert(sortList, tmp) + end + local sortRule = { + [2] = 1, + [1] = 2, + [3] = 3 + } + table.sort(sortList, function(a, b) + return sortRule[a.key] < sortRule[b.key] + end) + for __, info in ipairs(sortList) do + local characterBtn = self.BtnCharList[info.key] + if info.condit then + characterBtn.transform:SetAsLastSibling() + end + end +end +--添加点事件 +function XUiNierCharacterSel:AddRedPointEvent() + if self.CharacterList[1] then + XRedPointManager.AddRedPointEvent(self.BtnCharList[1], self.RefreshCharRed1, self,{ XRedPointConditions.Types.CONDITION_NIER_CHARACTER_RED }, {CharacterId = self.CharacterList[1]:GetNieRCharacterId(), IsInfor = true, IsTeach = true}) + end + if self.CharacterList[2] then + XRedPointManager.AddRedPointEvent(self.BtnCharList[2], self.RefreshCharRed2, self,{ XRedPointConditions.Types.CONDITION_NIER_CHARACTER_RED }, {CharacterId = self.CharacterList[2]:GetNieRCharacterId(), IsInfor = true, IsTeach = true}) + end + if self.CharacterList[3] then + XRedPointManager.AddRedPointEvent(self.BtnCharList[3], self.RefreshCharRed3, self,{ XRedPointConditions.Types.CONDITION_NIER_CHARACTER_RED }, {CharacterId = self.CharacterList[3]:GetNieRCharacterId(), IsInfor = true, IsTeach = true}) + end + +end + +--按钮红点 +function XUiNierCharacterSel:RefreshCharRed1(count) + self.BtnRed1.gameObject:SetActiveEx(count >= 0) +end + +--按钮红点 +function XUiNierCharacterSel:RefreshCharRed2(count) + self.BtnRed2.gameObject:SetActiveEx(count >= 0) +end + +--按钮红点 +function XUiNierCharacterSel:RefreshCharRed3(count) + self.BtnRed3.gameObject:SetActiveEx(count >= 0) +end + +function XUiNierCharacterSel:OnBtnBackClick() + self:Close() +end + +function XUiNierCharacterSel:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiNierCharacterSel:OnRealBtnCharClick(index) + if not self.CharacterList[index] then + return + end + local nieRCharacter = self.CharacterList[index] + local condit, desc = nieRCharacter:CheckNieRCharacterCondition() + if condit then + XDataCenter.NieRManager.SetSelCharacterId(nieRCharacter:GetNieRCharacterId()) + XLuaUiManager.Open("UiNierCharacter") + else + XUiManager.TipMsg(desc) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNieR/XUiCharacter/XUiNierRoomSingle.lua b/Resources/Scripts/XUi/XUiNieR/XUiCharacter/XUiNierRoomSingle.lua new file mode 100644 index 00000000..b1c4a9fe --- /dev/null +++ b/Resources/Scripts/XUi/XUiNieR/XUiCharacter/XUiNierRoomSingle.lua @@ -0,0 +1,125 @@ +local XUiNierRoomSingle = XLuaUiManager.Register(XLuaUi, "UiNierRoomSingle") + +local MAX_CHAR_COUNT = 3 +function XUiNierRoomSingle:OnAwake() + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + + self:AutoAddListener() +end + +function XUiNierRoomSingle:OnStart() + local uiModelRoot = self.UiModelGo.transform + self.PanelCharacterInfo = { + [1] = { + PanelRoleEffect = uiModelRoot:FindTransform("PanelRoleEffect1"), + TongdiaoEffect = uiModelRoot:FindTransform("ImgEffectTongDiao1"), + RoleModelPanel = XUiPanelRoleModel.New(uiModelRoot:FindTransform("PanelRoleModel1"), self.Name, nil, true, nil, true, true), + }, + [2] = { + PanelRoleEffect = uiModelRoot:FindTransform("PanelRoleEffect2"), + TongdiaoEffect = uiModelRoot:FindTransform("ImgEffectTongDiao2"), + RoleModelPanel = XUiPanelRoleModel.New(uiModelRoot:FindTransform("PanelRoleModel2"), self.Name, nil, true, nil, true, true), + }, + [3] = { + PanelRoleEffect = uiModelRoot:FindTransform("PanelRoleEffect3"), + TongdiaoEffect = uiModelRoot:FindTransform("ImgEffectTongDiao3"), + RoleModelPanel = XUiPanelRoleModel.New(uiModelRoot:FindTransform("PanelRoleModel3"), self.Name, nil, true, nil, true, true), + }, + } + self.NierCharacters = XDataCenter.NieRManager.GetCurDevelopCharacterIds() + + +end + +function XUiNierRoomSingle:OnEnable() + self:InitPanelNierCharacter() +end + +function XUiNierRoomSingle:OnDisable() + +end + +function XUiNierRoomSingle:OnDestroy() + +end + +function XUiNierRoomSingle:AutoAddListener() + self:RegisterClickEvent(self.BtnChar1, self.OnBtnChar1Click) + self:RegisterClickEvent(self.BtnChar2, self.OnBtnChar2Click) + self:RegisterClickEvent(self.BtnChar3, self.OnBtnChar3Click) +end + +function XUiNierRoomSingle:InitPanelNierCharacter() + for index = 1, MAX_CHAR_COUNT do + local characterId = self.NierCharacters[index] + if not characterId then + self["BtnChar" .. index].gameObject:SetActiveEx(false) + else + self["BtnChar" .. index].gameObject:SetActiveEx(true) + local nieRCharacter = XDataCenter.NieRManager.GetNieRCharacterByCharacterId(characterId) + local condit, desc = nieRCharacter:CheckNieRCharacterCondition() + if condit then + self["PanelAbility" .. index].gameObject:SetActiveEx(true) + self["PanelFirstRole" .. index].gameObject:SetActiveEx(false) + self["TxtAbility" .. index].text = "LV" .. nieRCharacter:GetNieRCharacterLevel() + local careerIcon = XCharacterConfigs.GetNpcTypeIcon(nieRCharacter:GetRobotCharacterCareerType()) + local rImgArms = self["RImgArms" .. index] + if careerIcon then + rImgArms:SetRawImage(careerIcon) + rImgArms.gameObject:SetActiveEx(true) + else + rImgArms.gameObject:SetActiveEx(false) + end + + else + self["PanelAbility" .. index].gameObject:SetActiveEx(false) + self["PanelFirstRole" .. index].gameObject:SetActiveEx(true) + self["PanelFirstRole" .. index].gameObject:SetActiveEx(true) + + local text = XUiHelper.TryGetComponent(self["PanelFirstRole" .. index].transform, "Text3", "Text") + text.text = desc + end + self:UpdateRoleModel(nieRCharacter:GetNieRCharacterRobotId(), nieRCharacter:GetNieRFashionId(), nieRCharacter:GetNieRWeaponId(), self.PanelCharacterInfo[index].RoleModelPanel) + end + + end +end + +function XUiNierRoomSingle:OnBtnBackClick() + self:Close() +end + +function XUiNierRoomSingle:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiNierRoomSingle:OnBtnChar1Click() + self:OnRealBtnCharClick(1) +end + +function XUiNierRoomSingle:OnBtnChar2Click() + self:OnRealBtnCharClick(2) +end + +function XUiNierRoomSingle:OnBtnChar3Click() + self:OnRealBtnCharClick(3) +end + +function XUiNierRoomSingle:OnRealBtnCharClick(index) + if not self.NierCharacters[index] then + return + end + XDataCenter.NieRManager.SetSelCharacterId(self.NierCharacters[index]) + XLuaUiManager.Open("UiNierCharacter") +end + +--更新模型 +function XUiNierRoomSingle:UpdateRoleModel(robotId, fashionId, weaponId, roleModelPanel) + roleModelPanel:ShowRoleModel() -- 先Active 再加载模型以及播放动画 + local callback = function() + + end + local characterId = XRobotManager.GetCharacterId(robotId) + roleModelPanel:UpdateRobotModel(robotId, characterId, callback, fashionId, weaponId) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNieR/XUiCharacter/XUiPanelNierCharacterFoster.lua b/Resources/Scripts/XUi/XUiNieR/XUiCharacter/XUiPanelNierCharacterFoster.lua new file mode 100644 index 00000000..165e3ce1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiNieR/XUiCharacter/XUiPanelNierCharacterFoster.lua @@ -0,0 +1,126 @@ +local XUiPanelNierCharacterFoster = XClass(nil, "XUiPanelNierCharacterFoster") +local XUiGrideNieRCharacterFoster = require("XUi/XUiNieR/XUiCharacter/XUiGrideNieRCharacterFoster") + +function XUiPanelNierCharacterFoster:Ctor(ui, parent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = parent + + XTool.InitUiObject(self) + self.BtnTcanchaungBlue.CallBack = function() self:OnBtnGoToUpAbilityClick() end + self.BtnBuyJump1.CallBack = function() self:OnBtnUpLevelMatClick() end + self.DynamicTable = XDynamicTableNormal.New(self.PanelItemList) + self.DynamicTable:SetProxy(XUiGrideNieRCharacterFoster) + self.DynamicTable:SetDelegate(self) +end + +function XUiPanelNierCharacterFoster:InitAllData() + local characterData = XDataCenter.NieRManager.GetSelNieRCharacter() + self.CharacterData = characterData + self:UpdateLevelPanel(characterData) + + self.AbilityList = characterData:GetAbilityList() + self.DynamicTable:SetDataSource(self.AbilityList) + self.DynamicTable:ReloadDataASync() +end + +function XUiPanelNierCharacterFoster:UpdateLevelPanel(characterData) + self.LevelLable.text = characterData:GetNieRCharacterLevel() + local exp = characterData:GetNieRCharacterExp() + local maxExp = characterData:GetNieRCharacterMaxExp() + if characterData:CheckNieRCharacterMaxLevel() then + self.LevelMAX.gameObject:SetActiveEx(true) + else + self.LevelMAX.gameObject:SetActiveEx(false) + end + self.TxtExpNum.text = string.format( "%s/%s", exp , maxExp) + self.ImgProgress.fillAmount = exp / maxExp + + local attribs = characterData:GetAttribs() + + self.DamageNumLable.text = FixToInt(attribs[XNpcAttribType.AttackNormal]) + self.HealthNumLable.text = FixToInt(attribs[XNpcAttribType.Life]) + self.DefenseNumLable.text = FixToInt(attribs[XNpcAttribType.DefenseNormal]) + self.CritNumLable.text = FixToInt(attribs[XNpcAttribType.Crit]) + + local abilityNum = characterData:GetAbilityNum() + self.FightNum.text = abilityNum + + self.UpLevelItemId = characterData:GetNieRCharacterUpLevelItemId() + self.ImgNormal:SetSprite(XDataCenter.ItemManager.GetItemIcon(self.UpLevelItemId)) + self.ImgPress:SetSprite(XDataCenter.ItemManager.GetItemIcon(self.UpLevelItemId)) + + local detailConfig = XCharacterConfigs.GetCharDetailTemplate(characterData:GetRobotCharacterId()) + local elementList = detailConfig.ObtainElementList + for i = 1, 2 do + local rImg = self["ProfessionIcon" .. i] + if elementList[i] then + rImg.gameObject:SetActiveEx(true) + local elementConfig = XCharacterConfigs.GetCharElement(elementList[i]) + rImg:SetRawImage(elementConfig.Icon2) + else + rImg.gameObject:SetActiveEx(false) + end + end + +end + +function XUiPanelNierCharacterFoster:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:ResetData(self.AbilityList[index], index) + end +end + +function XUiPanelNierCharacterFoster:OnDynamicGridClick(index) + local data = self.AbilityList[index] + local config = XNieRConfigs.GetAbilityGroupConfigById(data.ConfigId) + local condit, desc = XConditionManager.CheckCondition(config.Condition) + if XConditionManager.CheckCondition(config.Condition) then + if data.Type == XNieRConfigs.AbilityType.Skill then + local skillId = config.SkillId + local skillLevel = config.SkillLevel + local skillInfo = XCharacterConfigs.GetSkillGradeDesConfig(skillId, skillLevel) + XUiManager.DialogDragTip(skillInfo.Name, skillInfo.Intro, XUiManager.DialogType.NoBtn, nil, nil) + elseif data.Type == XNieRConfigs.AbilityType.Fashion then + XLuaUiManager.Open("UiFashion", self.CharacterData:GetRobotCharacterId(), true, true, XUiConfigs.OpenUiType.NieRCharacterUI) + elseif data.Type == XNieRConfigs.AbilityType.Weapon then + local equipId = config.WeaponId + XLuaUiManager.Open("UiEquipDetail", equipId, true, nil, nil, nil, XUiConfigs.OpenUiType.NieRCharacterUI) + elseif data.Type == XNieRConfigs.AbilityType.FourWafer then + local equipId = config.WaferId[1] + XLuaUiManager.Open("UiEquipDetail", equipId, true, nil, nil, nil, XUiConfigs.OpenUiType.NieRCharacterUI) + elseif data.Type == XNieRConfigs.AbilityType.TwoWafer then + local equipId = config.WaferId[1] + XLuaUiManager.Open("UiEquipDetail", equipId, true, nil, nil, nil, XUiConfigs.OpenUiType.NieRCharacterUI) + end + else + XUiManager.TipMsg(desc) + end +end + +function XUiPanelNierCharacterFoster:ShowPanel(isPlayAnimation) + self.IsPlayAnimation = isPlayAnimation + self.GameObject:SetActiveEx(true) +end + +function XUiPanelNierCharacterFoster:HidePanel() + self.IsPlayAnimation = false + self.GameObject:SetActiveEx(false) +end + +function XUiPanelNierCharacterFoster:OnBtnGoToUpAbilityClick() + XFunctionManager.SkipInterface(self.CharacterData:GetNieRClientSkipId()) +end + +function XUiPanelNierCharacterFoster:OnBtnUpLevelMatClick() + local item = XDataCenter.ItemManager.GetItem(self.UpLevelItemId) + local data = { + Id = item.Id, + Count = item ~= nil and tostring(item.Count) or "0" + } + XLuaUiManager.Open("UiTip", data) +end + +return XUiPanelNierCharacterFoster \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNieR/XUiCharacter/XUiPanelNierCharacterStory.lua b/Resources/Scripts/XUi/XUiNieR/XUiCharacter/XUiPanelNierCharacterStory.lua new file mode 100644 index 00000000..d48b6723 --- /dev/null +++ b/Resources/Scripts/XUi/XUiNieR/XUiCharacter/XUiPanelNierCharacterStory.lua @@ -0,0 +1,80 @@ +local XUiPanelNierCharacterStory = XClass(nil, "XUiPanelNierCharacterStory") +local XUiGrideNieRCharacterStory = require("XUi/XUiNieR/XUiCharacter/XUiGrideNieRCharacterStory") + +function XUiPanelNierCharacterStory:Ctor(ui, parent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = parent + + XTool.InitUiObject(self) + + self.DynamicTable = XDynamicTableNormal.New(self.PanelTaskStoryList) + self.DynamicTable:SetProxy(XUiGrideNieRCharacterStory) + self.DynamicTable:SetDelegate(self) + +end + +function XUiPanelNierCharacterStory:ShowPanel(isPlayAnimation) + self.IsPlayAnimation = isPlayAnimation + self.GameObject:SetActive(true) +end + +function XUiPanelNierCharacterStory:HidePanel() + self.IsPlayAnimation = false + self.GameObject:SetActive(false) +end + +function XUiPanelNierCharacterStory:InitAllInfo() + self:UpdateAllInfo() +end + +function XUiPanelNierCharacterStory:UpdateAllInfo() + local characterData = XDataCenter.NieRManager.GetSelNieRCharacter() + local characterId = characterData:GetNieRCharacterId() + local inforList = XNieRConfigs.GetNieRCharacterInforListById(characterId) + self.DataList = {} + for _, config in ipairs(inforList) do + local condit, desc + if config.UnlockCondition ~= 0 then + condit, desc = XConditionManager.CheckCondition(config.UnlockCondition) + else + condit, desc = true, "" + end + local tmpInfor = {} + tmpInfor.Config = config + tmpInfor.Desc = desc + + if condit then + if not XDataCenter.NieRManager.CheckCharacterInformationUnlock(config.Id, false) then + tmpInfor.IsUnLock = XNieRConfigs.NieRChInforStatue.CanUnLock + else + tmpInfor.IsUnLock = XNieRConfigs.NieRChInforStatue.UnLock + end + else + tmpInfor.IsUnLock = XNieRConfigs.NieRChInforStatue.Lock + end + table.insert(self.DataList, tmpInfor) + end + + -- table.sort(self.DataList, function(a, b) + -- if a.IsUnLock > b.IsUnLock then + -- return true + -- elseif a.IsUnLock == b.IsUnLock then + -- return a.Config.Priority < b.Config.Priority + -- end + -- return false + -- end) + + self.DynamicTable:SetDataSource(self.DataList) + self.DynamicTable:ReloadDataASync() +end + +function XUiPanelNierCharacterStory:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:ResetData(self.DataList[index]) + end +end + +return XUiPanelNierCharacterStory \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNieR/XUiCharacter/XUiPanelNierCharacterTeaching.lua b/Resources/Scripts/XUi/XUiNieR/XUiCharacter/XUiPanelNierCharacterTeaching.lua new file mode 100644 index 00000000..ce5fdd32 --- /dev/null +++ b/Resources/Scripts/XUi/XUiNieR/XUiCharacter/XUiPanelNierCharacterTeaching.lua @@ -0,0 +1,120 @@ +local XUiPanelNierCharacterTeaching = XClass(nil, "XUiPanelNierCharacterTeaching") +local XUiGridNierStage = require("XUi/XUiNieR/XUiGridNierStage") + +function XUiPanelNierCharacterTeaching:Ctor(ui, parent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = parent + + XTool.InitUiObject(self) + + self.StageLine = {} + self.StageNode = {} + for index = 1, 4 do + if index <= 3 then + self.StageLine[index] = self["Line"..index] + self.StageLine[index].gameObject:SetActiveEx(false) + end + self.StageNode[index] = self["Stage"..index] + end + self.GridList = {} + self.JumpToIndex = true +end + +function XUiPanelNierCharacterTeaching:ShowPanel() + self.GameObject:SetActiveEx(true) +end + +function XUiPanelNierCharacterTeaching:HidePanel() + self.GameObject:SetActiveEx(false) +end + +function XUiPanelNierCharacterTeaching:InitAllInfo() + local characterData = XDataCenter.NieRManager.GetSelNieRCharacter() + local stageIds = characterData:GetTeachingStageIds() + local stageNum = #stageIds + stageNum = stageNum > 4 and 4 or stageNum + + local defIndex + for index = 1, 4 do + local prefab = self.GridAssignNierStage + local stageType = XNieRConfigs.NieRStageType.Teaching + + if stageIds[index] and XDataCenter.FubenManager.GetStageInfo(stageIds[index]).Unlock then + self:CreatStageNode(index, prefab) + self.GridList[index]:UpdateNieRStageGrid(stageIds[index], stageType, index) + self.StageNode[index].gameObject:SetActiveEx(true) + if index > 1 then + self.StageLine[index-1].gameObject:SetActiveEx(true) + end + if not defIndex or defIndex < index then + defIndex = index + end + else + self.StageNode[index].gameObject:SetActiveEx(false) + if index > 1 then + self.StageLine[index-1].gameObject:SetActiveEx(false) + end + end + end + if self.JumpToIndex then + + if not defIndex then + defIndex = 1 + end + self:MoveIntoStage(defIndex) + end +end + +function XUiPanelNierCharacterTeaching:CreatStageNode(index, prefab) + local grid + if self.GridList[index] then + grid = self.GridList[index] + else + local ui = CS.UnityEngine.Object.Instantiate(prefab) + grid = XUiGridNierStage.New(ui, self.RootUi) + grid.Transform:SetParent(self.StageNode[index], false) + grid.Transform:GetComponent("RectTransform").anchoredPosition = CS.UnityEngine.Vector2(0, 0) + self.GridList[index] = grid + end +end + +function XUiPanelNierCharacterTeaching:MoveIntoStage(stageIndex) + local gridRect = self.StageNode[stageIndex].transform:GetComponent("RectTransform") + local diffX = gridRect.localPosition.x + self.PanelStageContent.localPosition.x + local viewRect = self.ViewPort.transform:GetComponent("RectTransform") + if diffX > viewRect.rect.width / 2 then + local tarPosX = (viewRect.rect.width / 4) - gridRect.localPosition.x + local tarPos = self.PanelStageContent.localPosition + tarPos.x = tarPosX + -- XLuaUiManager.SetMask(true) + -- self:SetPanelStageListMovementType(CS.UnityEngine.UI.ScrollRect.MovementType.Unrestricted) + -- XUiHelper.DoMove(self.PanelStageContent, tarPos, XDataCenter.FubenMainLineManager.UiGridChapterMoveDuration, XUiHelper.EaseType.Sin, function() + -- XLuaUiManager.SetMask(false) + -- self:SetPanelStageListMovementType(CS.UnityEngine.UI.ScrollRect.MovementType.Elastic) + -- end) + self.PanelStageContent.localPosition = tarPos + end +end + +-- function XUiPanelNierCharacterTeaching:PlayScrollViewMove(gridTransform) +-- self:SetPanelStageListMovementType(CS.UnityEngine.UI.ScrollRect.MovementType.Unrestricted) +-- local gridRect = gridTransform:GetComponent("RectTransform") +-- local diffX = gridRect.localPosition.x + self.PanelStageContent.localPosition.x +-- if diffX < XDataCenter.FubenMainLineManager.UiGridChapterMoveMinX or diffX > XDataCenter.FubenMainLineManager.UiGridChapterMoveMaxX then +-- local tarPosX = XDataCenter.FubenMainLineManager.UiGridChapterMoveTargetX - gridRect.localPosition.x +-- local tarPos = self.PanelStageContent.localPosition +-- tarPos.x = tarPosX +-- XLuaUiManager.SetMask(true) +-- XUiHelper.DoMove(self.PanelStageContent, tarPos, XDataCenter.FubenMainLineManager.UiGridChapterMoveDuration, XUiHelper.EaseType.Sin, function() +-- XLuaUiManager.SetMask(false) +-- end) +-- end +-- end + +function XUiPanelNierCharacterTeaching:SetPanelStageListMovementType(moveMentType) + if not self.PanelStageList then return end + self.PanelStageList.movementType = moveMentType +end + +return XUiPanelNierCharacterTeaching \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNieR/XUiFubenNierEnter.lua b/Resources/Scripts/XUi/XUiNieR/XUiFubenNierEnter.lua new file mode 100644 index 00000000..9fbff828 --- /dev/null +++ b/Resources/Scripts/XUi/XUiNieR/XUiFubenNierEnter.lua @@ -0,0 +1,158 @@ +local XUiFubenNierEnter = XLuaUiManager.Register(XLuaUi, "UiFubenNierEnter") +local XUiNierMainLineBanner = require("XUi/XUiNieR/XUiNierMainLineBanner") + +function XUiFubenNierEnter:OnAwake() + + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + self:RegisterClickEvent(self.BtnTrial, self.OnBtnTrialClick) + self.BtnTongBlue.CallBack = function() self:OnBtnTongBlueClick() end + self.BtnTeam.CallBack = function() self:OnBtnTeamClick() end + self.BtnPOD.CallBack = function() self:OnBtnPODClick() end + self.BtnRenWu.CallBack = function() self:OnBtnRenWuClick() end + self.BtnShop.CallBack = function() self:OnBtnShopClick() end + self:BindHelpBtn(self.BtnHelp, "NierEnterHelp") + self.TiaoxingmaFinsh.gameObject:SetActiveEx(false) + self.EasterEggBg.gameObject:SetActiveEx(false) + self.UiNierMainLineBanner = XUiNierMainLineBanner.New(self.UiFubenMainLineBanner, self) +end + +function XUiFubenNierEnter:OnStart() + self:AddRedPointEvent() + XEventManager.AddEventListener(XEventId.EVENT_NIER_ACTIVITY_END, self.OnActivityEnd, self) + XEventManager.AddEventListener(CS.XEventId.EVENT_UI_ALLOWOPERATE, self.OnActivityEnd, self) +end + +function XUiFubenNierEnter:OnEnable() + if XDataCenter.NieRManager.GetIsActivityEnd() then + XScheduleManager.ScheduleOnce(function() + if not self.GameObject:Exist() then return end + XDataCenter.NieRManager.OnActivityEnd() + end, 1) + end + local unlockCount,count = XDataCenter.NieRManager.GetCharacterCount() + local nierPOD = XDataCenter.NieRManager.GetNieRPODData() + self.BtnTeam:SetNameByGroup(0, CS.XTextManager.GetText("NieRBtnTeamNameStr")) + self.BtnPOD:SetNameByGroup(0, CS.XTextManager.GetText("NieRBtnPODNameStr")) + self.BtnRenWu:SetNameByGroup(0, CS.XTextManager.GetText("NieRBtnRenWuNameStr")) + self.BtnShop:SetNameByGroup(0, CS.XTextManager.GetText("NieRBtnShopNameStr")) + + if self.TextBtnTrial then + self.TextBtnTrial.text = CS.XTextManager.GetText("NieRBtnRepeatNameStr") + end + + self.BtnTeam:SetNameByGroup(1, string.format("%s/%s",unlockCount, count)) + self.BtnPOD:SetNameByGroup(1, string.format("Lv.%s",nierPOD:GetNieRPODLevel())) + + local easterEggPassed = XDataCenter.NieRManager.CheckNieREasterEggStagePassed() + local needShowDelData = false + if easterEggPassed then + self.TiaoxingmaFinsh.gameObject:SetActiveEx(true) + self.BtnTongBlue.gameObject:SetActiveEx(false) + self.BtnTeam.gameObject:SetActiveEx(true) + self.BtnPOD.gameObject:SetActiveEx(true) + self.BtnRenWu.gameObject:SetActiveEx(true) + self.BtnShop.gameObject:SetActiveEx(true) + self.BtnTrial.gameObject:SetActiveEx(true) + self.EasterEggBg.gameObject:SetActiveEx(false) + else + self.TiaoxingmaFinsh.gameObject:SetActiveEx(false) + needShowDelData = XDataCenter.NieRManager.GetNieREasterEggStageShow() + if needShowDelData then + self.BtnTeam.gameObject:SetActiveEx(false) + self.BtnPOD.gameObject:SetActiveEx(false) + self.BtnRenWu.gameObject:SetActiveEx(false) + self.BtnShop.gameObject:SetActiveEx(false) + self.BtnTrial.gameObject:SetActiveEx(false) + self.BtnTongBlue.gameObject:SetActiveEx(true) + self.EasterEggBg.gameObject:SetActiveEx(true) + else + self.BtnTongBlue.gameObject:SetActiveEx(false) + self.BtnTeam.gameObject:SetActiveEx(true) + self.BtnPOD.gameObject:SetActiveEx(true) + self.BtnRenWu.gameObject:SetActiveEx(true) + self.BtnShop.gameObject:SetActiveEx(true) + self.BtnTrial.gameObject:SetActiveEx(true) + self.EasterEggBg.gameObject:SetActiveEx(false) + end + end + self.UiNierMainLineBanner:UpdateData(easterEggPassed, needShowDelData) +end + +function XUiFubenNierEnter:OnDisable() +end + +function XUiFubenNierEnter:OnDestroy() + self.UiNierMainLineBanner:StopTimer() + XEventManager.RemoveEventListener(XEventId.EVENT_NIER_ACTIVITY_END, self.OnActivityEnd, self) + XEventManager.RemoveEventListener(CS.XEventId.EVENT_UI_ALLOWOPERATE, self.OnActivityEnd, self) +end + +--添加点事件 +function XUiFubenNierEnter:AddRedPointEvent() + XRedPointManager.AddRedPointEvent(self.BtnRenWu, self.RefreshTaskRedDot, self,{ XRedPointConditions.Types.CONDITION_NIER_TASK_RED }, -1) + XRedPointManager.AddRedPointEvent(self.BtnTeam, self.RefreshTeamRedDot, self,{ XRedPointConditions.Types.CONDITION_NIER_CHARACTER_RED }, {CharacterId = -1, IsInfor = true, IsTeach = true}) + XRedPointManager.AddRedPointEvent(self.BtnTrial, self.RefreshRepeatRedDot, self,{ XRedPointConditions.Types.CONDITION_NIER_REPEAT_RED }) + XRedPointManager.AddRedPointEvent(self.BtnPOD, self.RefreshPODRedDot, self,{ XRedPointConditions.Types.CONDITION_NIER_POD_RED }) + +end + +function XUiFubenNierEnter:OnActivityEnd() + if not XDataCenter.NieRManager.GetIsActivityEnd() then return end + XDataCenter.NieRManager.OnActivityEnd() +end + +--任务按钮红点 +function XUiFubenNierEnter:RefreshTaskRedDot(count) + self.BtnRenWuRed.gameObject:SetActiveEx(count >= 0) +end + +--尼尔角色按钮红点 +function XUiFubenNierEnter:RefreshTeamRedDot(count) + self.BtnTeamRed.gameObject:SetActiveEx(count >= 0) +end + +--复刷关按钮红点 +function XUiFubenNierEnter:RefreshRepeatRedDot(count) + self.BtnTrialRed.gameObject:SetActiveEx(count >= 0) +end + +--辅助机按钮红点 +function XUiFubenNierEnter:RefreshPODRedDot(count) + self.BtnPODRed.gameObject:SetActiveEx(count >= 0) +end + +function XUiFubenNierEnter:OnBtnBackClick() + self:Close() +end + +function XUiFubenNierEnter:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiFubenNierEnter:OnBtnTrialClick() + XLuaUiManager.Open("UiFubenNierRepeat") +end + +function XUiFubenNierEnter:OnBtnTongBlueClick() + XDataCenter.NieRManager.OpenNieREasterEggCom() +end + +function XUiFubenNierEnter:OnBtnTeamClick() + XLuaUiManager.Open("UiNierCharacterSel") +end + +function XUiFubenNierEnter:OnBtnPODClick() + XLuaUiManager.Open("UiFuBenNierWork") +end + +function XUiFubenNierEnter:OnBtnRenWuClick() + XLuaUiManager.Open("UiNierTask") +end + +function XUiFubenNierEnter:OnBtnShopClick() + if XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.ShopCommon) + or XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.ShopActive) then + XLuaUiManager.Open("UiNierShop") + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNieR/XUiFubenNierGuanqiaNormal.lua b/Resources/Scripts/XUi/XUiNieR/XUiFubenNierGuanqiaNormal.lua new file mode 100644 index 00000000..67e303d1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiNieR/XUiFubenNierGuanqiaNormal.lua @@ -0,0 +1,340 @@ +local XUiFubenNierGuanqiaNormal = XLuaUiManager.Register(XLuaUi, "UiFubenNierGuanqiaNormal") +local XUiGridFubenNierPODSkill = require("XUi/XUiNieR/XUiGridFubenNierPODSkill") +function XUiFubenNierGuanqiaNormal:OnAwake() + --self.BtnClose.CallBack = function () self:Close() end + self.BtnTanchuangClose.CallBack = function () self:Close() end + + self.BtnEnter.CallBack = function () self:OnBtnEnterClick() end + if self.PanelAsset then + self.PanelAsset.gameObject:SetActiveEx(false) + end + + self:InitTextTipsPanels() +end + +function XUiFubenNierGuanqiaNormal:OnStart(stageId, nieRStageType, repeatStageId, chapterId) + self.GridList = {} + self.RepeatStageId = repeatStageId + self.ChapterId = chapterId + self.StageId = stageId + self.Stage = XDataCenter.FubenManager.GetStageCfg(stageId) + self.NieRStageType = nieRStageType + self.GirdSkillList = {} +end + +function XUiFubenNierGuanqiaNormal:OnEnable() + self:Refresh(self.Stage) +end + +function XUiFubenNierGuanqiaNormal:OnDisable() + +end + +function XUiFubenNierGuanqiaNormal:InitAssetPanel() + if not self.PanelAsset then return end + self.PanelAsset.gameObject:SetActiveEx(true) + local PanelTool1 = XUiHelper.TryGetComponent(self.PanelAsset.transform, "PanelTool1", nil) + local RImgTool1 = XUiHelper.TryGetComponent(self.PanelAsset.transform, "PanelTool1/RImgTool1", "RawImage") + self.TxtTool1 = XUiHelper.TryGetComponent(self.PanelAsset.transform, "PanelTool1/TxtTool1", "Text") + self.BtnBuyJump1 = XUiHelper.TryGetComponent(self.PanelAsset.transform, "PanelTool1/BtnBuyJump1", "Button") + if self.BtnBuyJump1 then + XUiHelper.RegisterClickEvent(self, self.BtnBuyJump1, self.OnTickJumpClick) + end + + local itemId = XDataCenter.NieRManager.GetRepeatStageConsumeId() + local item = XDataCenter.ItemManager.GetItem(itemId) + + if RImgTool1 ~= nil and RImgTool1:Exist() then + RImgTool1:SetRawImage(item.Template.Icon, nil, false) + end + + local func = function(textTool, id) + local itemCount = XDataCenter.ItemManager.GetCount(id) + textTool.text = itemCount .. "/" .. XDataCenter.NieRManager.GetNieRRepeatConsumeMaxCount() + end + local f = function() + func(self.TxtTool1, itemId) + end + XDataCenter.ItemManager.AddCountUpdateListener(itemId, f, self.TxtTool1) + func(self.TxtTool1, itemId) +end + +function XUiFubenNierGuanqiaNormal:OnTickJumpClick() + local item = XDataCenter.ItemManager.GetItem(XDataCenter.NieRManager.GetRepeatStageConsumeId()) + local data = { + Id = item.Id, + Count = item ~= nil and tostring(item.Count) or "0" + } + XLuaUiManager.Open("UiTip", data) +end + +function XUiFubenNierGuanqiaNormal:InitTextTipsPanels() + self.GridStarList = {} + for i = 1, 3 do + local tmpNode = {} + tmpNode.node = self["TextTips"..i] + tmpNode.text = self["TextTipsLabel"..i] + self.GridStarList[i] = tmpNode + end + +end + +function XUiFubenNierGuanqiaNormal:Refresh(stage) + self.Stage = stage or self.Stage + self:UpdateCommon() + self.PanelRewards.gameObject:SetActiveEx(false) + self.ShowRImg:SetRawImage(self.Stage.StoryIcon) + if self.NieRStageType == XNieRConfigs.NieRStageType.BossStage then + self.PanelJinduDetail.gameObject:SetActiveEx(true) + self.PanelDropList.gameObject:SetActiveEx(false) + self:UpdateBossInfo() + else + self.PanelDropList.gameObject:SetActiveEx(true) + self.PanelJinduDetail.gameObject:SetActiveEx(false) + self:UpdateRewards() + end + self:UpdatePODAndSkill() +end + +function XUiFubenNierGuanqiaNormal:UpdateBossInfo() + local nieRBoss = XDataCenter.NieRManager.GetNieRBossDataById(self.StageId) + local leftHp = nieRBoss:GetLeftHp() + local maxHp = nieRBoss:GetMaxHp() + local score = nieRBoss:GetScore() + local percent = (maxHp - leftHp) / maxHp + self.PanelExpBar.fillAmount = percent + + local percentStr + if (percent * 100) > 1 then + percentStr = string.format("%d%%",math.floor( percent * 100), "%") + else + percentStr = string.format("%.2f%%", percent * 100, "%") + end + self.TextContsJindu.text = percentStr + self.TextJinduNow.text = (maxHp - leftHp) + self.TextJinduAll.text = string.format("/%s", maxHp) + self.TextJifen.text = score + if score > 0 then + self.TextShowTips.gameObject:SetActiveEx(true) + else + self.TextShowTips.gameObject:SetActiveEx(false) + end +end + +function XUiFubenNierGuanqiaNormal:UpdateCommon() + + self.TxtTitle.text = self.Stage.Name + for i = 1, 3 do + if self.Stage.StarDesc[i] then + self.GridStarList[i].node.gameObject:SetActiveEx(true) + self.GridStarList[i].text.text = self.Stage.StarDesc[i] + else + self.GridStarList[i].node.gameObject:SetActiveEx(false) + end + end + if self.NieRStageType == XNieRConfigs.NieRStageType.RepeatStage then + local nieRRepeat = XDataCenter.NieRManager.GetRepeatDataById(self.RepeatStageId) + local consumeId, counsumCount + if self.RepeatStageId == self.StageId then + consumeId, counsumCount = XDataCenter.NieRManager.GetRepeatStageConsumeId(), nieRRepeat:GetNierRepeatStageConsumeCount() + else + consumeId, counsumCount = nieRRepeat:GetExConsumIdAndCount(self.StageId) + end + if counsumCount == 0 then + self.UsePowerItemGrid1.gameObject:SetActiveEx(false) + else + self.UsePowerItemGrid1.gameObject:SetActiveEx(true) + self.UsePowerIcon1:SetRawImage(XDataCenter.ItemManager.GetItemIcon(consumeId)) + self.UsePowerNum1.text = counsumCount + end + if self.Stage.RequireActionPoint == 0 then + self.UsePowerItemGrid2.gameObject:SetActiveEx(false) + else + self.UsePowerItemGrid2.gameObject:SetActiveEx(true) + self.UsePowerNum2.text = self.Stage.RequireActionPoint + end + self:InitAssetPanel() + XDataCenter.NieRManager.SaveNieRRepeatRedCheckCount() + XEventManager.DispatchEvent(XEventId.EVENT_NIER_REPEAT_CLICK) + else + self.UsePowerItemGrid1.gameObject:SetActiveEx(false) + if self.Stage.RequireActionPoint == 0 then + self.UsePowerItemGrid2.gameObject:SetActiveEx(false) + else + self.UsePowerItemGrid2.gameObject:SetActiveEx(true) + self.UsePowerNum2.text = self.Stage.RequireActionPoint + end + + end + +end + +function XUiFubenNierGuanqiaNormal:UpdateRewards() + local stage = self.Stage + + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stage.StageId) + -- 获取显示奖励Id + local rewardId = 0 + local IsFirst = false + local rewards + self.TxtDrop.text = CS.XTextManager.GetText("DropRewardTitle") + if self.NieRStageType == XNieRConfigs.NieRStageType.RepeatStage and XDataCenter.NieRManager.CheckNieRRepeatMainStage(stage.StageId) then + local nierRepeat = XDataCenter.NieRManager.GetRepeatDataById(stage.StageId) + local starNum = nierRepeat:GetNieRRepeatStar() + + if starNum > 0 then + self.PanelRewards.gameObject:SetActiveEx(true) + self.TextContRewards.text = "X" .. starNum + rewardId = nierRepeat:GetNieRExStarReward(starNum) + else + self.PanelRewards.gameObject:SetActiveEx(true) + self.TextContRewards.text = "X" .. starNum + rewardId = nierRepeat:GetNieRNorStarReward() + end + if rewardId == 0 then + for j = 1, #self.GridList do + self.GridList[j].GameObject:SetActiveEx(false) + end + return + end + rewards = starNum >= 0 and XRewardManager.GetRewardList(rewardId) or XRewardManager.GetRewardListNotCount(rewardId) + else + local cfg = XDataCenter.FubenManager.GetStageLevelControl(stage.StageId) + if not stageInfo.Passed then + rewardId = cfg and cfg.FirstRewardShow or stage.FirstRewardShow + if cfg and cfg.FirstRewardShow > 0 or stage.FirstRewardShow > 0 then + IsFirst = true + end + end + if rewardId == 0 then + rewardId = cfg and cfg.FinishRewardShow or stage.FinishRewardShow + end + if rewardId == 0 then + rewardId = cfg and cfg.FirstRewardShow or stage.FirstRewardShow + if cfg and cfg.FirstRewardShow > 0 or stage.FirstRewardShow > 0 then + IsFirst = true + end + end + if rewardId == 0 then + for j = 1, #self.GridList do + self.GridList[j].GameObject:SetActiveEx(false) + end + return + end + if IsFirst then + self.TxtDrop.text = CS.XTextManager.GetText("FirstRewardTitle") + else + self.TxtDrop.text = CS.XTextManager.GetText("DropRewardTitle") + end + rewards = IsFirst and XRewardManager.GetRewardList(rewardId) or XRewardManager.GetRewardListNotCount(rewardId) + end + + -- if IsFirst then + -- self.TxtDrop.text = CS.XTextManager.GetText("FirstRewardTitle") + -- else + -- self.TxtDrop.text = CS.XTextManager.GetText("DropRewardTitle") + -- end + -- rewards = IsFirst and XRewardManager.GetRewardList(rewardId) or XRewardManager.GetRewardListNotCount(rewardId) + if rewards then + for i, item in ipairs(rewards) do + local grid + if self.GridList[i] then + grid = self.GridList[i] + else + local ui = CS.UnityEngine.Object.Instantiate(self.RewardGridCommon) + grid = XUiGridCommon.New(self, ui) + grid.Transform:SetParent(self.RewardDropContent, false) + self.GridList[i] = grid + end + grid:Refresh(item) + grid.GameObject:SetActiveEx(true) + local obj = grid.Transform:Find("GetTips") + if IsFirst and stageInfo.Passed then + if obj then + obj.gameObject:SetActiveEx(true) + end + else + if obj then + obj.gameObject:SetActiveEx(false) + end + end + end + end + + local rewardsCount = 0 + if rewards then + rewardsCount = #rewards + end + + for j = 1, #self.GridList do + if j > rewardsCount then + self.GridList[j].GameObject:SetActiveEx(false) + end + end +end + +function XUiFubenNierGuanqiaNormal:UpdatePODAndSkill() + local nieRPOD = XDataCenter.NieRManager.GetNieRPODData() + local skillList = nieRPOD:GetFightSkillList() + self.PODHeadImg:SetSprite(nieRPOD:GetNieRPODHeadIcon()) + self.SkillList = skillList + local defIndex = 1 + local defSelSkillId = nieRPOD:GetNieRPODSelectSkillId() + for index, skillInfo in ipairs(skillList) do + local grid + if not self.GirdSkillList[index] then + local ui + local parent = self.PODPanelSkillContent + + if index == 1 then + ui = self.PODGridSkillNormal + ui.gameObject:SetActiveEx(true) + ui.transform:SetParent(parent, false) + grid = XUiGridFubenNierPODSkill.New(ui, self) + else + ui = CS.UnityEngine.Object.Instantiate(self.PODGridSkillNormal) + ui.gameObject:SetActiveEx(true) + ui.transform:SetParent(parent, false) + grid = XUiGridFubenNierPODSkill.New(ui, self) + end + self.GirdSkillList[index] = grid + else + grid = self.GirdSkillList[index] + end + if defSelSkillId == skillInfo.SkillId and nieRPOD:CheckNieRPODSkillActive(defSelSkillId) then + defIndex = index + end + grid:SetSelectStatue(false) + grid:RefreshData(skillInfo, index) + end + self:OnBtnSkillClick(defIndex) +end + +function XUiFubenNierGuanqiaNormal:OnBtnSkillClick(index) + local info = self.SkillList[index] + if not info then + return + end + if not info.IsActive then + XUiManager.TipMsg(info.Desc) + return + end + local grid + if self.SelectNieRPODIndex then + grid = self.GirdSkillList[self.SelectNieRPODIndex] + grid:SetSelectStatue(false) + end + self.SelectNieRPODIndex = index + self.SelectNieRPODSkillId = info and info.SkillId + grid = self.GirdSkillList[self.SelectNieRPODIndex] + grid:SetSelectStatue(true) +end + +function XUiFubenNierGuanqiaNormal:OnBtnEnterClick() + if XDataCenter.FubenManager.CheckPreFight(self.Stage) then + if self.SelectNieRPODSkillId ~= XDataCenter.NieRManager.GetNieRPODData():GetNieRPODSelectSkillId() then + XDataCenter.NieRManager.NieRSelectSupportSkill(self.SelectNieRPODSkillId) + end + XLuaUiManager.PopThenOpen("UiNewRoomSingle", self.Stage.StageId, nil, self.RepeatStageId, self.ChapterId) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNieR/XUiGridFubenNierPODSkill.lua b/Resources/Scripts/XUi/XUiNieR/XUiGridFubenNierPODSkill.lua new file mode 100644 index 00000000..825e7736 --- /dev/null +++ b/Resources/Scripts/XUi/XUiNieR/XUiGridFubenNierPODSkill.lua @@ -0,0 +1,43 @@ +local XUiGridFubenNierPODSkill = XClass(nil, "XUiGridFubenNierPODSkill") + +function XUiGridFubenNierPODSkill:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + + self.PanelSkillNormal.CallBack = function() self:OnBtnSkillClick() end +end + +function XUiGridFubenNierPODSkill:RefreshData(info, index) + self.NierPOD = XDataCenter.NieRManager.GetNieRPODData() + local skillId = info.SkillId + local isActive = info.IsActive + self.Index = index + local skillName = self.NierPOD:GetNieRPODSkillName(skillId) + local skillIcon = self.NierPOD:GetNieRPODSkillIcon(skillId) + local skillLvStr = CS.XTextManager.GetText("NieRPODSkillLevel", self.NierPOD:GetNieRPODSkillLevelById(skillId)) + self.PanelSkillNormal:SetRawImage(skillIcon) + self.PanelSkillNormal:SetNameByGroup(1, skillLvStr) + self.PanelSkillNormal:SetNameByGroup(0, skillName) + + if self.PanelIconTip then + if isActive then + self.PanelIconTip.gameObject:SetActiveEx(false) + else + self.PanelIconTip.gameObject:SetActiveEx(true) + end + end + +end + +function XUiGridFubenNierPODSkill:SetSelectStatue(isSel) + self.Normal.gameObject:SetActiveEx(not isSel) + self.Select.gameObject:SetActiveEx(isSel) +end + +function XUiGridFubenNierPODSkill:OnBtnSkillClick() + self.RootUi:OnBtnSkillClick(self.Index) +end + +return XUiGridFubenNierPODSkill \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNieR/XUiGridNieRTaskBtn.lua b/Resources/Scripts/XUi/XUiNieR/XUiGridNieRTaskBtn.lua new file mode 100644 index 00000000..d5250847 --- /dev/null +++ b/Resources/Scripts/XUi/XUiNieR/XUiGridNieRTaskBtn.lua @@ -0,0 +1,25 @@ +local XUiGridNieRTaskBtn = XClass(nil, "XUiGridNieRTaskBtn") +function XUiGridNieRTaskBtn:Ctor(ui, rootUi) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + +end + +function XUiGridNieRTaskBtn:Refresh(data) + local groupId = data.TaskGroupId + local titleStr = data.TitleStr + self.NormalTxt.text = titleStr + self.PressTxt.text = titleStr + self.SelectTxt.text = titleStr + local red = XDataCenter.NieRManager.CheckNieRTaskRed(groupId) + self.Red.gameObject:SetActiveEx(red) +end + +function XUiGridNieRTaskBtn:IsSelect(isSel) + self.Normal.gameObject:SetActiveEx(not isSel) + self.Select.gameObject:SetActiveEx(isSel) +end + +return XUiGridNieRTaskBtn \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNieR/XUiGridNierChapter.lua b/Resources/Scripts/XUi/XUiNieR/XUiGridNierChapter.lua new file mode 100644 index 00000000..f57635c6 --- /dev/null +++ b/Resources/Scripts/XUi/XUiNieR/XUiGridNierChapter.lua @@ -0,0 +1,92 @@ +local XUiGridNierChapter = XClass(nil, "XUiGridNierChapter") + +function XUiGridNierChapter:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Transform3d = ui.transform + XTool.InitUiObject(self) +end + +function XUiGridNierChapter:UpdateChapterGrid(chapterData, needShowDelData) + if not needShowDelData then + self.PanelNormal.gameObject:SetActiveEx(true) + self.PanelEffect.gameObject:SetActiveEx(false) + local isUnLock = chapterData:CheckNieRChapterUnLock() + if not isUnLock then + self.PanelChapter.gameObject:SetActiveEx(false) + self.ImgRedDot.gameObject:SetActiveEx(false) + self.ImgFinish.gameObject:SetActiveEx(false) + self.PanelChapterLock.gameObject:SetActiveEx(true) + self:UpdateLockedPanel(chapterData) + else + self.PanelChapter.gameObject:SetActiveEx(true) + self.ImgRedDot.gameObject:SetActiveEx(false) + self.ImgFinish.gameObject:SetActiveEx(false) + self.PanelChapterLock.gameObject:SetActiveEx(false) + self:UpdateUnLockPanel(chapterData) + end + else + self.PanelNormal.gameObject:SetActiveEx(false) + self.PanelEffect.gameObject:SetActiveEx(true) + end +end + +function XUiGridNierChapter:UpdateUnLockPanel(chapterData) + self.TextPart.text = chapterData:GetNieRChapterName() + self.ImgPercentNormal.fillAmount = 0 + self.TxtPercentNormal.text = CS.XTextManager.GetText("NieRChapterPercentStr", chapterData:GetIndex()) + self.RImgChapter:SetRawImage(chapterData:GetNieRChapterIcon()) + + if XDataCenter.FubenManager.GetStageInfo(chapterData:GetNieRBossStageId()).Unlock then + self.ImgPercentNormal.gameObject:SetActiveEx(true) + self.TxtPercentNormalBg.gameObject:SetActiveEx(true) + local nieRBoss = XDataCenter.NieRManager.GetNieRBossDataById(chapterData:GetNieRBossStageId()) + local leftHp = nieRBoss:GetLeftHp() + local maxHp = nieRBoss:GetMaxHp() + self.ImgPercentNormal.fillAmount = (maxHp - leftHp) / maxHp + self.TxtPercentNormal.text = string.format("%d%%",math.floor( (maxHp - leftHp) / maxHp * 100)) + self.TxtPercentNormalBg.text = string.format("%d%%",math.floor( (maxHp - leftHp) / maxHp * 100)) + self.ImgFinish.gameObject:SetActiveEx(leftHp <= 0) + + -- local needShowDelData = XDataCenter.NieRManager.GetNieREasterEggStageShow() + -- if not needShowDelData then + + -- else + -- self.TxtTitlePart.text = CS.XTextManager.GetText("NieRChapterPhaseStr", 3) + -- self.TextTitleDesc.text = CS.XTextManager.GetText("NieRChapterBossRate") + -- end + + self.TxtTitlePart.text = CS.XTextManager.GetText("NieRChapterPhaseStr", 2) + self.TextTitleDesc.text = CS.XTextManager.GetText("NieRChapterBossRate") + else + local stageIds = chapterData:GetNierChapterStageIds() + local stageNum = #stageIds + local passNum = 0 + for index, stageId in ipairs(stageIds) do + if index ~= chapterData:GetNieRRepeatPoStagePos() and XDataCenter.FubenManager.CheckStageIsPass(stageId) then + passNum = passNum + 1 + end + end + self.ImgPercentNormal.fillAmount = passNum / (stageNum - 1) + self.TxtPercentNormal.text = string.format("%d/%d", passNum, (stageNum - 1)) + self.TxtPercentNormalBg.text = string.format("%d%%", math.floor( passNum / (stageNum - 1))* 100) + self.TxtTitlePart.text = CS.XTextManager.GetText("NieRChapterPhaseStr", 1) + self.TextTitleDesc.text = CS.XTextManager.GetText("NieRChapterOtherRate") + end + +end + +function XUiGridNierChapter:UpdateLockedPanel(chapterData) + local startTime = chapterData:GetNierChapterStartTime() + local nowTime = XTime.GetServerNowTimestamp() + if nowTime < startTime then + self.LockTxtDate.text = os.date("%Y/%m/%d", startTime) + else + self.LockTxtDate.text = "" + end + + self.LockTextPart.text = chapterData:GetNieRChapterName() + self.LockRImgChapter:SetRawImage(chapterData:GetNieRChapterIcon()) +end + +return XUiGridNierChapter \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNieR/XUiGridNierStage.lua b/Resources/Scripts/XUi/XUiNieR/XUiGridNierStage.lua new file mode 100644 index 00000000..77a57a2c --- /dev/null +++ b/Resources/Scripts/XUi/XUiNieR/XUiGridNierStage.lua @@ -0,0 +1,71 @@ +local XUiGridNierStage = XClass(nil, "XUiGridNierStage") + +function XUiGridNierStage:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Transform3d = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + + self.GameObject:SetActiveEx(true) + self.GridAssignStage.CallBack = function() self:OnBtnStageClick() end + +end + +function XUiGridNierStage:UpdateNieRStageGrid(stageId, nierStageType, index, labelStr) + self.StageId = stageId + self.StageConfig = XDataCenter.FubenManager.GetStageCfg(stageId) + self.StageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + + self.NierStageType = nierStageType + self.TextNameNormal.text = self.StageConfig.Name + local stageIsPassed = XDataCenter.FubenManager.CheckStageIsPass(stageId) + if self.NierStageType == XNieRConfigs.NieRStageType.BossStage then + local nieRBoss = XDataCenter.NieRManager.GetNieRBossDataById(stageId) + local leftHp = nieRBoss:GetLeftHp() + local maxHp = nieRBoss:GetMaxHp() + self.ImgFubenEnd.gameObject:SetActiveEx(leftHp == 0) + + if not XDataCenter.FubenManager.CheckStageIsUnlock(stageId) then + self.GridAssignStage:SetDisable(true, true) + self.TextNameDisable.text = self.StageConfig.Name + self.RImgStageDisable:SetRawImage(self.StageConfig.Icon) + else + self.GridAssignStage:SetDisable(false, true) + self.ImgJinduNormal.fillAmount = (maxHp - leftHp) / maxHp + self.TextJinduNormal.text = string.format("%d%s",math.floor( (maxHp - leftHp) / maxHp * 100), "%") + end + elseif self.NierStageType == XNieRConfigs.NieRStageType.RepeatPoStage then + self.TextLabelNormal.text = labelStr or "" + --self.TextLabelDisable.text = labelStr + self.ImgFubenEnd.gameObject:SetActiveEx(stageIsPassed) + elseif self.NierStageType == XNieRConfigs.NieRStageType.Teaching then + self.Red.gameObject:SetActiveEx(not stageIsPassed) + self.ImgFubenEnd.gameObject:SetActiveEx(stageIsPassed) + else + self.ImgFubenEnd.gameObject:SetActiveEx(stageIsPassed) + end + self.RImgStageNormal:SetRawImage(self.StageConfig.Icon) +end + +function XUiGridNierStage:OnBtnStageClick() + local condit, desc + local stageInfo = XDataCenter.FubenManager.GetStageInfo(self.StageId) + if not stageInfo.Unlock then + condit, desc = false, XDataCenter.FubenManager.GetFubenOpenTips(self.StageId) + else + condit = true + end + if condit then + if self.NierStageType == XNieRConfigs.NieRStageType.Teaching then + XLuaUiManager.Open("UiFubenStageDetail", self.StageConfig, nil, true) + else + XLuaUiManager.Open("UiFubenNierGuanqiaNormal", self.StageId, self.NierStageType, nil, self.RootUi.CurChapterId) + end + else + XUiManager.TipMsg(desc) + end + +end + +return XUiGridNierStage \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNieR/XUiMainLine/XUiFubenNierLineChapter.lua b/Resources/Scripts/XUi/XUiNieR/XUiMainLine/XUiFubenNierLineChapter.lua new file mode 100644 index 00000000..3100adcf --- /dev/null +++ b/Resources/Scripts/XUi/XUiNieR/XUiMainLine/XUiFubenNierLineChapter.lua @@ -0,0 +1,131 @@ + +local XUiFubenNierLineChapter = XLuaUiManager.Register(XLuaUi, "UiFubenNierLineChapter") +local PanelMainlineChapter = require("XUi/XUiNieR/XUiMainLine/XUiPanelMainlineChapter") + +function XUiFubenNierLineChapter:OnAwake() + + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + + self.BtnTongBlue.CallBack = function() self:OnBtnTongBlueClick() end + self.BtnTeam.CallBack = function() self:OnBtnTeamClick() end + self.BtnPOD.CallBack = function() self:OnBtnPODClick() end + self.BtnRenWu.CallBack = function() self:OnBtnRenWuClick() end + self.BtnShop.CallBack = function() self:OnBtnShopClick() end + self.BtnTongBlue.gameObject:SetActiveEx(false) + self:BindHelpBtn(self.BtnHelp, "NierLineChapterHelp") + + self.XUiNieRLineBanner = PanelMainlineChapter.New(self.PanelMainlineChapter, self) + -- self.UiNierMainLineBanner:UpdateData() + +end + +function XUiFubenNierLineChapter:OnStart(curChapterId) + self.CurChapterId = curChapterId + self:AddRedPointEvent() +end + +function XUiFubenNierLineChapter:OnEnable() + + if XDataCenter.NieRManager.GetIsActivityEnd() then + XScheduleManager.ScheduleOnce(function() + if not self.GameObject or not self.GameObject:Exist() then return end + XDataCenter.NieRManager.OnActivityEnd() + end, 1) + else + + if XDataCenter.NieRManager.CheckFirstNieREasterEggStageShow() then + XScheduleManager.ScheduleOnce(function() + if not self.GameObject or not self.GameObject:Exist() then return end + self:Close() + end, 1) + else + self.CurChapterData = XDataCenter.NieRManager.GetChapterDataById(self.CurChapterId) + local unlockCount, count = XDataCenter.NieRManager.GetCharacterCount() + local nierPOD = XDataCenter.NieRManager.GetNieRPODData() + + self.BtnTeam:SetNameByGroup(0, CS.XTextManager.GetText("NieRBtnTeamNameStr")) + self.BtnPOD:SetNameByGroup(0, CS.XTextManager.GetText("NieRBtnPODNameStr")) + self.BtnRenWu:SetNameByGroup(0, CS.XTextManager.GetText("NieRBtnRenWuNameStr")) + self.BtnShop:SetNameByGroup(0, CS.XTextManager.GetText("NieRBtnShopNameStr")) + + + self.BtnTeam:SetNameByGroup(1, string.format("%s/%s", unlockCount, count)) + self.BtnPOD:SetNameByGroup(1, string.format("Lv.%s", nierPOD:GetNieRPODLevel())) + self.XUiNieRLineBanner:UpdateAllInfo() + + XDataCenter.NieRManager.CheckNieRMainLineUITips() + end + end +end + +function XUiFubenNierLineChapter:OnDisable() + +end + + +function XUiFubenNierLineChapter:OnDestroy() + --self.XUiNieRLineBanner:StopTween() +end + +--添加点事件 +function XUiFubenNierLineChapter:AddRedPointEvent() + XRedPointManager.AddRedPointEvent(self.BtnRenWu, self.RefreshTaskRedDot, self,{ XRedPointConditions.Types.CONDITION_NIER_TASK_RED }, -1) + XRedPointManager.AddRedPointEvent(self.BtnTeam, self.RefreshTeamRedDot, self,{ XRedPointConditions.Types.CONDITION_NIER_CHARACTER_RED }, {CharacterId = -1, IsInfor = true, IsTeach = true}) + XRedPointManager.AddRedPointEvent(self.BtnPOD, self.RefreshPODRedDot, self,{ XRedPointConditions.Types.CONDITION_NIER_POD_RED }) +end + +--任务按钮红点 +function XUiFubenNierLineChapter:RefreshTaskRedDot(count) + self.BtnRenWuRed.gameObject:SetActiveEx(count >= 0) +end + +--尼尔角色按钮红点 +function XUiFubenNierLineChapter:RefreshTeamRedDot(count) + self.BtnTeamRed.gameObject:SetActiveEx(count >= 0) +end + +--辅助机按钮红点 +function XUiFubenNierLineChapter:RefreshPODRedDot(count) + self.BtnPODRed.gameObject:SetActiveEx(count >= 0) +end + +function XUiFubenNierLineChapter:OnBtnBackClick() + self:Close() +end + +function XUiFubenNierLineChapter:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiFubenNierLineChapter:OnBtnTongBlueClick() + XLog.Debug("OnBtnTongBlueClick") +end + +function XUiFubenNierLineChapter:OnBtnTeamClick() + XLuaUiManager.Open("UiNierCharacterSel") +end + +function XUiFubenNierLineChapter:OnBtnPODClick() + XLuaUiManager.Open("UiFuBenNierWork") +end + +function XUiFubenNierLineChapter:OnBtnRenWuClick() + local skipId = self.CurChapterData:GetNieRChapterTaskSkipId() + if skipId and skipId ~= 0 then + XFunctionManager.SkipInterface(skipId) + else + XLuaUiManager.Open("UiNierTask") + end +end + +function XUiFubenNierLineChapter:OnBtnShopClick() + if XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.ShopCommon) + or XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.ShopActive) then + XLuaUiManager.Open("UiNierShop") + end +end + +function XUiFubenNierLineChapter:GetNieRLineBanner() + return self.XUiNieRLineBanner +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNieR/XUiMainLine/XUiPanelChapterStage.lua b/Resources/Scripts/XUi/XUiNieR/XUiMainLine/XUiPanelChapterStage.lua new file mode 100644 index 00000000..712eb377 --- /dev/null +++ b/Resources/Scripts/XUi/XUiNieR/XUiMainLine/XUiPanelChapterStage.lua @@ -0,0 +1,121 @@ +local XUiPanelChapterStage = XClass(nil, "XUiPanelChapterStage") +local XUiGridNierStage = require("XUi/XUiNieR/XUiGridNierStage") + +local ALL_STAGE_NUM = 5 +local TIME_TWEEN = 0.75 +function XUiPanelChapterStage:Ctor(ui, rootUi) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + local parent = self.RootUi:GetNieRLineBanner() + self.GridAssignNierStage = parent.GridAssignNierStage + self.GridRepeatNierStage = parent.GridRepeatNierStage + self.GridBossNierStage = parent.GridBossNierStage + + self.StageLine = {} + self.StageNode = {} + for index = 1, ALL_STAGE_NUM do + self.StageLine[index] = self["Line"..index] + self.StageNode[index] = self["Stage"..index] + end + + self.GridList = {} +end + +function XUiPanelChapterStage:UpdateAllInfo(chapterData) + + + + local stageIds = chapterData:GetNierChapterStageIds() + local bossStageId = chapterData:GetNieRBossStageId() + + local nieRBoss = XDataCenter.NieRManager.GetNieRBossDataById(bossStageId) + local leftHp = nieRBoss:GetLeftHp() + local maxHp = nieRBoss:GetMaxHp() + + local stageNum = #stageIds + stageNum = stageNum > 4 and 4 or stageNum + + local needShowBossStage = false + + for index = 1, stageNum do + local prefab = self.GridAssignNierStage + local stageType = XNieRConfigs.NieRStageType.AssignStage + local labelStr + if XDataCenter.FubenManager.CheckStageIsUnlock(stageIds[index]) then + if index == chapterData:GetNieRRepeatPoStagePos() then + prefab = self.GridRepeatNierStage + stageType = XNieRConfigs.NieRStageType.RepeatPoStage + needShowBossStage = true + labelStr = chapterData:GetNieRRepeatPoStageLabel() + end + self:CreatStageNode(index, prefab) + self.GridList[index]:UpdateNieRStageGrid(stageIds[index], stageType, index, labelStr) + if self.StageNode[index] then + self.StageNode[index].gameObject:SetActiveEx(true) + end + if index > 1 and self.StageLine[index-1] then + self.StageLine[index-1].gameObject:SetActiveEx(true) + end + else + self.StageNode[index].gameObject:SetActiveEx(false) + if index > 1 and self.StageLine[index-1] then + self.StageLine[index-1].gameObject:SetActiveEx(false) + end + end + end + + if needShowBossStage then + local prefab = self.GridBossNierStage + local stageType = XNieRConfigs.NieRStageType.BossStage + local index = stageNum + 1 + self:CreatStageNode(index, prefab) + self.GridList[index]:UpdateNieRStageGrid(bossStageId, stageType, index) + if self.StageNode[index] then + self.StageNode[index].gameObject:SetActiveEx(true) + end + if not XDataCenter.FubenManager.CheckStageIsUnlock(bossStageId) then + if self.StageLine[index-1] then + self.StageLine[index - 1].gameObject:SetActiveEx(true) + end + if self.StageLine[index] then + self.StageLine[index].gameObject:SetActiveEx(false) + end + else + self.StageLine[index - 1].gameObject:SetActiveEx(false) + self.StageLine[index].gameObject:SetActiveEx(true) + end + else + local index = stageNum + 1 + if self.StageNode[index] then + self.StageNode[index].gameObject:SetActiveEx(false) + end + + if self.StageLine[index-1] then + self.StageLine[index-1].gameObject:SetActiveEx(false) + end + if self.StageLine[index] then + self.StageLine[index].gameObject:SetActiveEx(false) + end + end + +end + +function XUiPanelChapterStage:CreatStageNode(index, prefab) + local grid + if self.GridList[index] then + grid = self.GridList[index] + else + if not self.StageNode[index] then return end + local ui = CS.UnityEngine.Object.Instantiate(prefab) + grid = XUiGridNierStage.New(ui, self.RootUi) + grid.Transform:SetParent(self.StageNode[index], false) + grid.Transform:GetComponent("RectTransform").anchoredPosition = CS.UnityEngine.Vector2(0, 0) + self.GridList[index] = grid + end +end + + +return XUiPanelChapterStage diff --git a/Resources/Scripts/XUi/XUiNieR/XUiMainLine/XUiPanelMainlineChapter.lua b/Resources/Scripts/XUi/XUiNieR/XUiMainLine/XUiPanelMainlineChapter.lua new file mode 100644 index 00000000..d57ca4a6 --- /dev/null +++ b/Resources/Scripts/XUi/XUiNieR/XUiMainLine/XUiPanelMainlineChapter.lua @@ -0,0 +1,85 @@ +local XUiPanelMainlineChapter = XClass(nil, "XUiPanelMainlineChapter") +local XUiPanelChapterStage = require("XUi/XUiNieR/XUiMainLine/XUiPanelChapterStage") + +local XUiGridNierStage = require("XUi/XUiNieR/XUiGridNierStage") +local TIME_TWEEN = 0.75 +function XUiPanelMainlineChapter:Ctor(ui, rootUi) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + + self.ChapeterList = {} + for index = 1, 4 do + self.ChapeterList[index] = self["PanelStage"..index] + end + +end + + +function XUiPanelMainlineChapter:UpdateAllInfo() + local chapterData = self.RootUi.CurChapterData + + local chapterIndex = chapterData:GetIndex() + local PanelStage + if not self.PanelChpterSatge then + + for index = 1, 4 do + if chapterIndex == index then + self.ChapeterList[index].gameObject:SetActiveEx(true) + PanelStage = self.ChapeterList[index] + else + self.ChapeterList[index].gameObject:SetActiveEx(false) + end + end + + self.PanelChpterSatge = XUiPanelChapterStage.New(PanelStage, self.RootUi) + end + + self.TxtChapter.text = chapterData:GetNieRChapterName() + self.TxtNum.text= chapterData:GetNieRChapterPhaseStr() + + self.PanelChpterSatge:UpdateAllInfo(chapterData) + +end + +--废弃代码 +-- function XUiPanelMainlineChapter:UpdateBossPercent(leftHp, maxHp) +-- if not self.LastLeftHp or self.LastLeftHp == 0 then +-- self.LastLeftHp = leftHp +-- self.ImgJindu.fillAmount = (maxHp - leftHp) / maxHp +-- self.JinduLable.text = string.format("%d%s",math.floor( (maxHp - leftHp) / maxHp * 100), "%") +-- else +-- local changeHp = self.LastLeftHp - leftHp +-- if self.Tween then +-- XScheduleManager.UnSchedule(self.Tween) +-- end +-- self.Tween = XUiHelper.Tween(TIME_TWEEN, function(f) +-- if XTool.UObjIsNil(self.Transform) then +-- return +-- end +-- local tmpChangeHp = math.floor(f * changeHp) +-- local tmpPercent = ( maxHp - self.LastLeftHp + tmpChangeHp ) / maxHp + +-- self.ImgJindu.fillAmount = tmpPercent +-- self.JinduLable.text = string.format("%d%s",math.floor( tmpPercent * 100), "%") + +-- end,function () +-- if XTool.UObjIsNil(self.Transform) then +-- return +-- end +-- self.LastLeftHp = leftHp +-- self.ImgJindu.fillAmount = (maxHp - leftHp) / maxHp +-- self.JinduLable.text = string.format("%d%s",math.floor( (maxHp - leftHp) / maxHp * 100), "%") +-- end) +-- end +-- end + +-- function XUiPanelMainlineChapter:StopTween() +-- if self.Tween then +-- XScheduleManager.UnSchedule(self.Tween) +-- end +-- end + +return XUiPanelMainlineChapter \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNieR/XUiNieRBossFightResult.lua b/Resources/Scripts/XUi/XUiNieR/XUiNieRBossFightResult.lua new file mode 100644 index 00000000..5f5bdc99 --- /dev/null +++ b/Resources/Scripts/XUi/XUiNieR/XUiNieRBossFightResult.lua @@ -0,0 +1,119 @@ +local XUiNieRBossFightResult = XLuaUiManager.Register(XLuaUi, "UiNieRBossFightResult") + +function XUiNieRBossFightResult:OnAwake() + self:AutoAddListener() +end + +function XUiNieRBossFightResult:OnStart(winData) + self.WinData = winData +end + +function XUiNieRBossFightResult:OnEnable() + self:Refresh() + XDataCenter.FunctionEventManager.UnLockFunctionEvent() +end + +function XUiNieRBossFightResult:AutoAddListener() + self:RegisterClickEvent(self.BtnSaveInfo, self.OnBtnSaveInfoClick) + self:RegisterClickEvent(self.BtnExitFight, self.OnBtnExitFightClick) +end + + +function XUiNieRBossFightResult:OnBtnSaveInfoClick() + XDataCenter.NieRManager.NieRUpdateBossScore(function() + self:StopAudio() + self:Close() + end) +end + +function XUiNieRBossFightResult:OnBtnExitFightClick() + self:StopAudio() + self:Close() +end + +function XUiNieRBossFightResult:StopAudio() + if self.AudioInfo then + self.AudioInfo:Stop() + end +end + + +function XUiNieRBossFightResult:Refresh() + if not self.WinData or not self.WinData.SettleData or + not self.WinData.SettleData.NieRBossFightResult then + return + end + local stageId = self.WinData.StageId + local time = CS.XGame.ClientConfig:GetFloat("BossSingleAnimaTime") + local data = self.WinData.SettleData.NieRBossFightResult + local info = XDataCenter.FubenManager.GetStageInfo(stageId) + + self.TxtTile.text = XDataCenter.FubenManager.GetStageName(stageId) + self.PanelNewRecord.gameObject:SetActiveEx(data.TotalScore > data.TotalHighScore) + + self.PanelBossLoseHp.gameObject:SetActiveEx(true) + self.PanelSurplusHp.gameObject:SetActiveEx(true) + self.PanelLeftTime.gameObject:SetActiveEx(false) + self.PanelGroupCount.gameObject:SetActiveEx(true) + + local SetMaxTextDesc = function(text, ponit) + text.text = "" + -- if ponit > 0 then + -- text.text = CS.XTextManager.GetText("NieRMaxSingleScore", ponit) + -- else + -- text.text = CS.XTextManager.GetText("NieRMaxSingleNoScore") + -- end + end + + SetMaxTextDesc(self.TxtHitSocreMax, 0) + SetMaxTextDesc(self.TxtRemainHpScoreMax, 0) + SetMaxTextDesc(self.TxtGroupCountScoreMax, data.HpMaxScore or 0) + + -- 播放音效 + self.AudioInfo = CS.XAudioManager.PlaySound(XSoundManager.UiBasicsMusic.UiSettle_Win_Number) + + XUiHelper.Tween(time, function(f) + if XTool.UObjIsNil(self.Transform) then + return + end + + -- 参与分 + + local hitCombo = math.floor(f * data.BaseScore) + local hitScore = '+' .. math.floor(f * data.BaseScore) + self.TxtHitCombo.text = hitCombo + self.TxtHitScore.text = hitScore + + + -- 伤害量 + + local remainHp = math.floor(f * data.Damage) + local remainHpScore = '+' .. math.floor(f * data.DamageScore) + self.TxtRemainHp.text = remainHp + self.TxtRemainHpScore.text = remainHpScore + + + -- 我方血量 + local groupCount = math.floor(f * data.HpLeftPer) .. "%" + local groupCountSacore = '+' .. math.floor(f * data.HpScore) + self.TxtGroupCount.text = groupCount + self.TxtGroupCountScore.text = groupCountSacore + + + -- 通关时间 + local costTime = XUiHelper.GetTime(math.floor(f * data.UseTime), XUiHelper.TimeFormatType.SHOP) + self.TxtCostTime.text = costTime + + -- 当前总分 + local point = math.floor(f * data.TotalScore) + + self.TxtPoint.text = point + + -- 历史最高分 + local highScore = math.floor(f * data.TotalHighScore) + self.TxtHighScore.text = highScore + + end, function() + self:StopAudio() + end) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNieR/XUiNieREasterEgg/XGridNieREasterEggChatList.lua b/Resources/Scripts/XUi/XUiNieR/XUiNieREasterEgg/XGridNieREasterEggChatList.lua new file mode 100644 index 00000000..3291c4af --- /dev/null +++ b/Resources/Scripts/XUi/XUiNieR/XUiNieREasterEgg/XGridNieREasterEggChatList.lua @@ -0,0 +1,23 @@ +local XGridNieREasterEggChatList = XClass(nil, "XGridNieREasterEggChatList") + +function XGridNieREasterEggChatList:Ctor(ui, rootUi) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XGridNieREasterEggChatList:Refesh(data) + self.TagBtn:SetNameByGroup(0, data.Message) +end + +function XGridNieREasterEggChatList:IsSelect(isSel) + if not isSel then + self.TagBtn:SetButtonState(CS.UiButtonState.Normal) + else + self.TagBtn:SetButtonState(CS.UiButtonState.Select) + end + +end + +return XGridNieREasterEggChatList \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNieR/XUiNieREasterEgg/XPanelNieREasterEggAge.lua b/Resources/Scripts/XUi/XUiNieR/XUiNieREasterEgg/XPanelNieREasterEggAge.lua new file mode 100644 index 00000000..a7337c0b --- /dev/null +++ b/Resources/Scripts/XUi/XUiNieR/XUiNieREasterEgg/XPanelNieREasterEggAge.lua @@ -0,0 +1,39 @@ +local XPanelNieREasterEggAge = XClass(nil, "XPanelNieREasterEggAge") + +local InitAge = 19 +function XPanelNieREasterEggAge:Ctor(ui, rootUi) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + self.Btn.CallBack = function() self:OnBtn1Click() end + self.Btn2.CallBack = function() self:OnBtn2Click() end +end + +function XPanelNieREasterEggAge:Init() + self.MinAge, self.MaxAge = XDataCenter.NieRManager.GetCurNieREasterEggAgeInfo() + self:UpdateCurAge(InitAge) +end + +function XPanelNieREasterEggAge:OnBtn1Click() + if self.CurAge == self.MinAge then + return + end + self:UpdateCurAge(self.CurAge - 1) +end + +function XPanelNieREasterEggAge:OnBtn2Click() + if self.CurAge == self.MaxAge then + return + end + self:UpdateCurAge(self.CurAge + 1) +end + +function XPanelNieREasterEggAge:UpdateCurAge(age) + self.CurAge = age + self.Text.text = age + self.RootUi:SetNieREasterEggAge(age) +end + +return XPanelNieREasterEggAge \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNieR/XUiNieREasterEgg/XPanelNieREasterEggChat.lua b/Resources/Scripts/XUi/XUiNieR/XUiNieREasterEgg/XPanelNieREasterEggChat.lua new file mode 100644 index 00000000..46a536e7 --- /dev/null +++ b/Resources/Scripts/XUi/XUiNieR/XUiNieREasterEgg/XPanelNieREasterEggChat.lua @@ -0,0 +1,194 @@ +local XPanelNieREasterEggChat = XClass(nil, "XPanelNieREasterEggChat") + +local NieREasterEggBulletChatDelayTime = CS.XGame.ClientConfig:GetFloat("NieREasterEggBulletChatDelayTime") +local NieREasterEggBulletChatShowTime = CS.XGame.ClientConfig:GetFloat("NieREasterEggBulletChatShowTime") + +function XPanelNieREasterEggChat:Ctor(ui, rootUi) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + local width = CS.XUiManager.RealScreenWidth + local height = CS.XUiManager.RealScreenHeight + self.LengthMin = math.ceil(math.sqrt(width ^ 2 + height ^ 2) / 2) + self.TextObj2List = {} + + self.TextTypeWriter = self.Text.gameObject:GetComponent("TextTypewriter") + + self.TextObjList = {} + self.UseTextDic = {} + for i = 1, 6 do + local tmpI = {} + tmpI.Text = self["Text"..i] + tmpI.CanvasGroup = self["Text"..i].gameObject:GetComponent("CanvasGroup") + tmpI.CanvasGroup.alpha = 0 + tmpI.Name = self["Name"..i] + self.TextObjList[i] = tmpI + end +end + +function XPanelNieREasterEggChat:ResetAll() + self:StopBulletTimer() + for i = 1, 6 do + self.TextObjList[i].CanvasGroup.alpha = 0 + end + +end + +function XPanelNieREasterEggChat:PlayEndStory() + self.RootUi:HideBtn() +end + +function XPanelNieREasterEggChat:PlayStoryInfo(storyConfig) + self.RootUi:HideBtn() + self.TextTypeWriter.CompletedHandle = function() + self.RootUi:ShowStoryBtn() + end + self.Text.text = storyConfig.Desc + self.TextTypeWriter:Play() + self.Text.gameObject:SetActiveEx(true) +end + +function XPanelNieREasterEggChat:PlayBulletChat() + local index = 1 + local count = 1 + local bulletList = XDataCenter.NieRManager.GetNieREasterEggData() + local ageStr = CS.XTextManager.GetText("NieREasterEggAgeStr") + local maxMessgaeCount = XDataCenter.NieRManager.GetCurMaxEasterEggMessageCount() + local delayTime = NieREasterEggBulletChatDelayTime * 1000 + local timeTween = NieREasterEggBulletChatShowTime + local timeTween1 = timeTween / 2 + + local PlayBulletFunc = function() + if self.UseTextDic[index] then + return + end + if count > maxMessgaeCount then + self:StopBulletTimer() + return + end + local tmpObj = self.TextObjList[index] + self.UseTextDic[index] = true + + local bullet = bulletList[count] + if not bullet then return end + local playerName = bullet.PlayerName + local message = XNieRConfigs.GetNieREasterEggMessageConfigById(bullet.MessageId).Message + local label = XNieRConfigs.GetNieREasterEggLabelConfigById(bullet.LabelId).Label + local age = bullet.Age + tmpObj.Text.text = string.format("\"%s\"", message) + tmpObj.Name.text = CS.XTextManager.GetText("NieREasterEggLabelStr", playerName, age, ageStr, label) + XUiHelper.DoAlpha(tmpObj.CanvasGroup, 0, 1, timeTween, XUiHelper.EaseType.Linear,function() + self.UseTextDic[index] = false + end) + if index > 1 then + local lastIndex = index - 1 + local lastTmpObj = self.TextObjList[lastIndex] + XUiHelper.DoAlpha(lastTmpObj.CanvasGroup, 1, 0.5, timeTween1, XUiHelper.EaseType.Linear,function() + self.UseTextDic[index] = false + end) + end + index = index + 1 + count = count + 1 + index = index > 6 and 1 or index + + local nextObj = self.TextObjList[index] + if nextObj.CanvasGroup.alpha == 0.5 and count < maxMessgaeCount then + XUiHelper.DoAlpha(nextObj.CanvasGroup, 0.5, 0, timeTween1, XUiHelper.EaseType.Linear,function() + self.UseTextDic[index] = false + end) + end + end + + PlayBulletFunc() + self.Timer = XScheduleManager.ScheduleForever(function() + PlayBulletFunc() + end, delayTime) +end + +function XPanelNieREasterEggChat:StopBulletTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end +-- function XPanelNieREasterEggChat:UpdateRealShowInfoSingle(isFirstDied, isWin) +-- local strShow = "153456465465465465465" +-- local txtShow +-- if self.TextPer then +-- txtShow = self.TextPer +-- else +-- local txtObj = CS.UnityEngine.Object.Instantiate(self.Text1) +-- txtObj.transform:SetParent(self.CenterPoint, false) +-- txtShow = txtObj.transform:GetComponent("Text") +-- self.TextPer = txtShow +-- end +-- txtShow.text = strShow +-- txtShow.gameObject:SetActiveEx(true) +-- end + +-- function XPanelNieREasterEggChat:UpdateRealShowInfos() +-- local strShow = "153456465465465465465" +-- local txtShow +-- if self.TextPer then +-- txtShow = self.TextPer +-- else +-- local txtObj = CS.UnityEngine.Object.Instantiate(self.Text1) +-- txtObj.transform:SetParent(self.CenterPoint, false) +-- txtShow = txtObj.transform:GetComponent("Text") +-- self.TextPer = txtShow +-- end +-- txtShow.text = strShow +-- txtShow.gameObject:SetActiveEx(true) + +-- local scin = 0 +-- local timeTween = 10 +-- local startScale = CS.UnityEngine.Vector3(2,2,2) +-- local endScale = CS.UnityEngine.Vector3(0.5, 0.5, 0.5) +-- local endPos = CS.UnityEngine.Vector3(0, 0, 0) +-- BULLET_CHAT_TIME = 150 +-- self.Timer = XScheduleManager.Schedule(function() +-- local length = math.random(self.LengthMin, self.LengthMin + 500) +-- local argue = math.random(scin * 90, (scin + 1) * 90) +-- timeTween = math.random(10, 15) +-- scin = scin < 3 and scin + 1 or 0 +-- local x = math.sin(math.rad(argue)) * length +-- local y = math.cos(math.rad(argue)) * length + +-- local txtShow +-- local txtRect +-- local txtCanvasGroup +-- local tmpObj +-- if next(self.TextObj2List) ~= nil then +-- tmpObj = table.remove(self.TextObj2List) +-- txtShow = tmpObj.txtShow +-- txtRect = tmpObj.txtRect +-- txtCanvasGroup = tmpObj.txtCanvasGroup +-- else +-- local txtObj = CS.UnityEngine.Object.Instantiate(self.Text2) +-- txtObj.transform:SetParent(self.CenterPoint, false) +-- txtShow = txtObj.transform:GetComponent("Text") +-- txtRect = txtObj.transform:GetComponent("RectTransform") +-- txtCanvasGroup = txtObj.transform:GetComponent("CanvasGroup") +-- txtObj.gameObject:SetActiveEx(true) +-- tmpObj = {} +-- tmpObj.txtShow = txtShow +-- tmpObj.txtRect = txtRect +-- tmpObj.txtCanvasGroup = txtCanvasGroup +-- end + +-- txtRect.anchoredPosition = CS.UnityEngine.Vector2(x, y) +-- txtRect.localScale = startScale +-- txtCanvasGroup.alpha = 1 +-- XUiHelper.DoMove(txtRect, endPos, timeTween, XUiHelper.EaseType.Sin, function() +-- table.insert(self.TextObj2List, tmpObj) +-- end) +-- XUiHelper.DoAlpha(txtCanvasGroup, 1, 0, timeTween, XUiHelper.EaseType.Sin,nil) +-- XUiHelper.DoScale(txtRect, startScale, endScale, timeTween, XUiHelper.EaseType.Sin,nil) +-- end, BULLET_CHAT_TIME, BULLET_CHAT_NUM, 0) +-- end + + + +return XPanelNieREasterEggChat \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNieR/XUiNieREasterEgg/XPanelNieREasterEggChatList.lua b/Resources/Scripts/XUi/XUiNieR/XUiNieREasterEgg/XPanelNieREasterEggChatList.lua new file mode 100644 index 00000000..3d974d50 --- /dev/null +++ b/Resources/Scripts/XUi/XUiNieR/XUiNieREasterEgg/XPanelNieREasterEggChatList.lua @@ -0,0 +1,49 @@ +local XPanelNieREasterEggChatList = XClass(nil, "XPanelNieREasterEggChatList") +local XGridNieREasterEggChatList = require("XUi/XUiNieR/XUiNieREasterEgg/XGridNieREasterEggChatList") + +function XPanelNieREasterEggChatList:Ctor(ui, rootUi) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + self.DynamicTable = XDynamicTableNormal.New(self.PanelTaskActivityList) + self.DynamicTable:SetProxy(XGridNieREasterEggChatList) + self.DynamicTable:SetDelegate(self) +end + +function XPanelNieREasterEggChatList:Init() + self.TagList = XNieRConfigs.GetNieREasterEggMessageConfigs() + self:SelNieREasterEggMessage(1) + self.DynamicTable:SetDataSource(self.TagList) + self.DynamicTable:ReloadDataASync() + + +end + +--动态列表事件 +function XPanelNieREasterEggChatList:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:Refesh(self.TagList[index]) + if index == self.CurSelIndex then + grid:IsSelect(true) + else + grid:IsSelect(false) + end + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + if self.CurSelIndex == index then return end + local lastGrid = self.DynamicTable:GetGridByIndex(self.CurSelIndex) + if lastGrid then + lastGrid:IsSelect(false) + end + + grid:IsSelect(true) + self:SelNieREasterEggMessage(index) + end +end + +function XPanelNieREasterEggChatList:SelNieREasterEggMessage(index) + self.CurSelIndex = index + self.RootUi:SetNieREasterEggMessageId(self.TagList[index].Id) +end +return XPanelNieREasterEggChatList \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNieR/XUiNieREasterEgg/XPanelNieREasterEggTag.lua b/Resources/Scripts/XUi/XUiNieR/XUiNieREasterEgg/XPanelNieREasterEggTag.lua new file mode 100644 index 00000000..9b03feab --- /dev/null +++ b/Resources/Scripts/XUi/XUiNieR/XUiNieREasterEgg/XPanelNieREasterEggTag.lua @@ -0,0 +1,38 @@ +local XPanelNieREasterEggTag = XClass(nil, "XPanelNieREasterEggTag") +local MAX_BUTTON_NUM = 9 +function XPanelNieREasterEggTag:Ctor(ui, rootUi) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + self.TagBtnList = {} + for i = 1, MAX_BUTTON_NUM do + self.TagBtnList[i] = self["TagBtn"..i] + end + + self.TagBtnGroup:Init(self.TagBtnList, function(index) self:SelectTagType(index) end) + +end + +function XPanelNieREasterEggTag:Init() + self.TagList = XNieRConfigs.GetNieREasterEggLabelConfigs() + local num = #self.TagList + for index = 1, num do + local config = self.TagList[index] + self.TagBtnList[index]:SetNameByGroup(0, config.Label) + end + if num < MAX_BUTTON_NUM then + for i = num + 1, MAX_BUTTON_NUM do + self.TagBtnList[i].gameObject:SetActiveEx(false) + end + end + self.TagBtnGroup:SelectIndex(1, true) +end + +function XPanelNieREasterEggTag:SelectTagType(index) + self.CurTag = self.TagList[index] + self.RootUi:SetNieREasterEggTagId(self.CurTag.Id) +end + +return XPanelNieREasterEggTag \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNieR/XUiNieREasterEgg/XUiFightNieRTips.lua b/Resources/Scripts/XUi/XUiNieR/XUiNieREasterEgg/XUiFightNieRTips.lua new file mode 100644 index 00000000..82def485 --- /dev/null +++ b/Resources/Scripts/XUi/XUiNieR/XUiNieREasterEgg/XUiFightNieRTips.lua @@ -0,0 +1,80 @@ +local XUiFightNieRTips = XLuaUiManager.Register(XLuaUi, "UiFightNieRTips") + +local ANI_TIME = 3000 +function XUiFightNieRTips:OnAwake() + self.PanelCondition.gameObject:SetActiveEx(true) + self.PanelCondition2.gameObject:SetActiveEx(true) + self.PanelConditionCa.alpha = 0 + self.PanelCondition2Ca.alpha = 0 +end + + +function XUiFightNieRTips:OnStart(lastPlayer, nowPlayer) + + self:PlayAnimation(lastPlayer, nowPlayer) +end + +function XUiFightNieRTips:OnDestroy() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end + if self.Timer1 then + XScheduleManager.UnSchedule(self.Timer1) + self.Timer1 = nil + end +end + +function XUiFightNieRTips:PlayAnimation(lastPlayer, nowPlayer) + self.TitleCondition.text = CS.XTextManager.GetText("NieREasterEggReviveStr", lastPlayer or "") + self.TitleCondition2.text = CS.XTextManager.GetText("NieREasterEggReviveStr", nowPlayer or "") + local timeTween = 0.1 + local Vector1 = CS.UnityEngine.Vector3(0, 189, 0) + local Vector2 = CS.UnityEngine.Vector3(0, 125, 0) + local Vector3 = CS.UnityEngine.Vector3(0, 253 + 15, 0) + if not lastPlayer then + self.PanelCondition2Ca.alpha = 1 + self.PanelConditionRe.anchoredPosition3D = Vector2 + XUiHelper.DoUiMove(self.PanelCondition2Re, Vector1, timeTween, XUiHelper.EaseType.Linear,function() + + end) + self.Timer = XScheduleManager.ScheduleOnce(function() + if not self.GameObject or not self.GameObject:Exist() then return end + self.Timer = nil + self:Close() + end, ANI_TIME) + else + self.PanelConditionRe.anchoredPosition3D = Vector2 + self.PanelCondition2Re.anchoredPosition3D = Vector2 + self.PanelConditionCa.alpha = 1 + XUiHelper.DoUiMove(self.PanelConditionRe, Vector1, timeTween, XUiHelper.EaseType.Linear,function() + + -- XUiHelper.DoUiMove(self.PanelCondition2Re, Vector1, timeTween, XUiHelper.EaseType.Linear,function() + + -- end) + end) + self.Timer = XScheduleManager.ScheduleOnce(function() + if not self.GameObject or not self.GameObject:Exist() then return end + XUiHelper.DoUiMove(self.PanelCondition2Re, Vector1, timeTween, XUiHelper.EaseType.Linear,function() + + -- XUiHelper.DoUiMove(self.PanelCondition2Re, Vector1, timeTween, XUiHelper.EaseType.Linear,function() + + -- end) + end) + self.Timer = nil + self.PanelConditionRe.anchoredPosition3D = Vector3 + self.PanelCondition2Ca.alpha = 1 + self.Timer1 = XScheduleManager.ScheduleOnce(function() + if not self.GameObject or not self.GameObject:Exist() then return end + self.Timer1 = nil + self:Close() + -- self.Timer2 = XScheduleManager.ScheduleOnce(function() + -- self:Close() + -- end, ANI_TIME) + end, ANI_TIME) + + + end, ANI_TIME) + + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNieR/XUiNieREasterEgg/XUiNieREasterEgg.lua b/Resources/Scripts/XUi/XUiNieR/XUiNieREasterEgg/XUiNieREasterEgg.lua new file mode 100644 index 00000000..452624f5 --- /dev/null +++ b/Resources/Scripts/XUi/XUiNieR/XUiNieREasterEgg/XUiNieREasterEgg.lua @@ -0,0 +1,257 @@ +local XUiNieREasterEgg = XLuaUiManager.Register(XLuaUi, "UiNieREasterEgg") +local XPanelNieREasterEggChat = require("XUi/XUiNieR/XUiNieREasterEgg/XPanelNieREasterEggChat") + +local XPanelNieREasterEggChatList = require("XUi/XUiNieR/XUiNieREasterEgg/XPanelNieREasterEggChatList") +local XPanelNieREasterEggAge = require("XUi/XUiNieR/XUiNieREasterEgg/XPanelNieREasterEggAge") +local XPanelNieREasterEggTag = require("XUi/XUiNieR/XUiNieREasterEgg/XPanelNieREasterEggTag") + +local WinTagType = { + Age = 1, + Tag = 2, + ChatList = 3, + Reward = 4 +} + +function XUiNieREasterEgg:OnAwake() + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + self.BtnLeft.CallBack = function() self:OnBtnLeftClick() end + self.BtnRight.CallBack = function() self:OnBtnRightClick() end + self.BtnClick.CallBack = function() self:OnBtnClickClick() end + + self.PanelChat = XPanelNieREasterEggChat.New(self.Chat, self) + self.PanelChatList = XPanelNieREasterEggChatList.New(self.ChatList, self) + self.PanelAge = XPanelNieREasterEggAge.New(self.Age, self) + self.PanelTag = XPanelNieREasterEggTag.New(self.Tag, self) + + self.BtnBack.gameObject:SetActiveEx(false) + self.Age.gameObject:SetActiveEx(false) + self.Tag.gameObject:SetActiveEx(false) + self.ChatList.gameObject:SetActiveEx(false) + self.Chat.gameObject:SetActiveEx(false) + + self.WinTagOpen = {} +end + +function XUiNieREasterEgg:OnStart(isWin, isFirstDied) + + self.Age.gameObject:SetActiveEx(false) + self.Tag.gameObject:SetActiveEx(false) + self.ChatList.gameObject:SetActiveEx(false) + self.Chat.gameObject:SetActiveEx(true) + self.IsWin = isWin + local storyConfig + if not isWin then + if isFirstDied then + storyConfig = XNieRConfigs.GetNieREasterEggClientConfigByGroupId(1) + else + storyConfig = XNieRConfigs.GetNieREasterEggClientConfigByGroupId(2) + end + self.CurStoryConfig = storyConfig + self.PanelChat:PlayStoryInfo(storyConfig) + else + storyConfig = XNieRConfigs.GetNieREasterEggClientConfigByGroupId(3) + self.PanelChat:ResetAll() + self.CurStoryConfig = storyConfig + self.PanelChat:PlayStoryInfo(storyConfig) + end + +end + +function XUiNieREasterEgg:OnDestroy() + self.PanelChat:StopBulletTimer() +end + +function XUiNieREasterEgg:OpenNierEasterEggChatList() + self.Age.gameObject:SetActiveEx(false) + self.Tag.gameObject:SetActiveEx(false) + self.Chat.gameObject:SetActiveEx(false) + self.ChatList.gameObject:SetActiveEx(true) + if not self.WinTagOpen[WinTagType.ChatList] then + self.PanelChatList:Init() + end + self.CurWinTagType = WinTagType.ChatList + self.WinTagOpen[WinTagType.ChatList] = true + self.BtnLeft.gameObject:SetActiveEx(false) + --self.BtnLeft:SetNameByGroup(0, CS.XTextManager.GetText("NieREasterEggLeftBtnStr")) + self.BtnRight.gameObject:SetActiveEx(true) + self.BtnRight:SetNameByGroup(0, CS.XTextManager.GetText("NieREasterEggRightBtnStr", 1, 3)) +end + +function XUiNieREasterEgg:SetNieREasterEggMessageId(id) + self.NieREasteEggMessageId = id +end + +function XUiNieREasterEgg:OpenNierEasterEggAge() + self.ChatList.gameObject:SetActiveEx(false) + self.Chat.gameObject:SetActiveEx(false) + self.Tag.gameObject:SetActiveEx(false) + self.Age.gameObject:SetActiveEx(true) + if not self.WinTagOpen[WinTagType.Age] then + self.PanelAge:Init() + end + self.CurWinTagType = WinTagType.Age + self.WinTagOpen[WinTagType.Age] = true + self.BtnLeft.gameObject:SetActiveEx(true) + self.BtnLeft:SetNameByGroup(0, CS.XTextManager.GetText("NieREasterEggLeftBtnStr")) + self.BtnRight.gameObject:SetActiveEx(true) + self.BtnRight:SetNameByGroup(0, CS.XTextManager.GetText("NieREasterEggRightBtnStr", 2, 3)) +end + +function XUiNieREasterEgg:SetNieREasterEggAge(age) + self.NieREasteEggAge = age +end + +function XUiNieREasterEgg:OpenNierEasterEggTag() + self.Age.gameObject:SetActiveEx(false) + self.ChatList.gameObject:SetActiveEx(false) + self.Chat.gameObject:SetActiveEx(false) + self.Tag.gameObject:SetActiveEx(true) + + if not self.WinTagOpen[WinTagType.Tag] then + self.PanelTag:Init() + end + self.CurWinTagType = WinTagType.Tag + self.WinTagOpen[WinTagType.Tag] = true + + self.BtnLeft.gameObject:SetActiveEx(true) + self.BtnLeft:SetNameByGroup(0, CS.XTextManager.GetText("NieREasterEggLeftBtnStr")) + self.BtnRight.gameObject:SetActiveEx(true) + self.BtnRight:SetNameByGroup(0, CS.XTextManager.GetText("NieREasterEggOkBtnStr")) +end + +function XUiNieREasterEgg:SetNieREasterEggTagId(id) + self.NieREasteEggTagId = id +end + +function XUiNieREasterEgg:OnBtnBackClick() + self:Close() +end + +function XUiNieREasterEgg:HideBtn() + self.BtnLeft.gameObject:SetActiveEx(false) + self.BtnRight.gameObject:SetActiveEx(false) + self.BtnClick.gameObject:SetActiveEx(false) +end + +function XUiNieREasterEgg:ShowStoryBtn() + local storyConfig = self.CurStoryConfig + local btnNum = #storyConfig.BtnStr + self.ShowBtnNum = btnNum + if btnNum > 0 then + for index, btnName in ipairs(storyConfig.BtnStr) do + if index == 1 then + self.BtnLeft.gameObject:SetActiveEx(true) + self.BtnLeft:SetNameByGroup(0, btnName) + else + self.BtnRight.gameObject:SetActiveEx(true) + self.BtnRight:SetNameByGroup(0, btnName) + end + end + else + local btnStr = storyConfig.BtnExStr or "" + self.BtnClick.gameObject:SetActiveEx(true) + self.BtnClick:SetNameByGroup(0, btnStr) + end +end + +function XUiNieREasterEgg:OnBtnMainUiClick() + +end + +function XUiNieREasterEgg:OnBtnLeftClick() + if not self.PlayerInput then + if self.ShowBtnNum > 0 then + local nextStoryId = self.CurStoryConfig.BtnTag[1] + self:RealNieREasterEggStoryClick(nextStoryId) + end + else + if self.CurWinTagType == WinTagType.ChatList then + elseif self.CurWinTagType == WinTagType.Age then + self:OpenNierEasterEggChatList() + elseif self.CurWinTagType == WinTagType.Tag then + self:OpenNierEasterEggAge() + end + end +end + +function XUiNieREasterEgg:OnBtnRightClick() + if not self.PlayerInput then + if self.ShowBtnNum > 1 then + local nextStoryId = self.CurStoryConfig.BtnTag[2] + self:RealNieREasterEggStoryClick(nextStoryId) + end + else + if self.CurWinTagType == WinTagType.ChatList then + self:OpenNierEasterEggAge() + elseif self.CurWinTagType == WinTagType.Age then + self:OpenNierEasterEggTag() + elseif self.CurWinTagType == WinTagType.Tag then + XUiManager.DialogTip("", CS.XTextManager.GetText("NieREasterEggSaveToServer"), XUiManager.DialogType.NormalAndNoBtnTanchuangClose,function() + --XLuaUiManager.PopThenOpen("UiNieRSaveData") + end ,function () + XDataCenter.NieRManager.NieREasterEggLeaveMessage(self.NieREasteEggMessageId, self.NieREasteEggAge, self.NieREasteEggTagId, function(rewardgodList) + XDataCenter.NieRManager.NieREasterEggDataRealPass() + self.RealEasterEggWin = true + self.PlayerInput = nil + self.Tag.gameObject:SetActiveEx(false) + self.Chat.gameObject:SetActiveEx(true) + self.PanelChat:ResetAll() + local storyConfig = XNieRConfigs.GetNieREasterEggClientConfigByGroupId(4) + self.CurStoryConfig = storyConfig + self.PanelChat:PlayStoryInfo(storyConfig) + self.RewardGodList = rewardgodList + end) + end) + + end + end +end + +function XUiNieREasterEgg:OnBtnClickClick() + if not self.PlayerInput then + if self.ShowBtnNum == 0 then + local nextStoryId = self.CurStoryConfig.BtnTag[1] + self:RealNieREasterEggStoryClick(nextStoryId) + end + else + self:Close() + end +end + +function XUiNieREasterEgg:RealNieREasterEggStoryClick(nextStoryId) + local storyConfig = XNieRConfigs.GetNieREasterEggClientConfigById(nextStoryId) + if storyConfig.Type == XNieRConfigs.EasterEggStoryType.NoThing then + self.CurStoryConfig = storyConfig + self.PanelChat:PlayStoryInfo(storyConfig) + if storyConfig.ShowBullet == 1 then + self.PanelChat:PlayBulletChat() + end + elseif storyConfig.Type == XNieRConfigs.EasterEggStoryType.Leave then + if self.IsWin then + else + if CS.XFight.Instance ~= nil then + CS.XFight.Instance.InputControl:OnOperationClick(CS.XNpcOperationClickKey.NieREasterLeave, CS.XNpcOperationClickType.KeyDown) + CS.XFight.Instance.InputControl:OnOperationClick(CS.XNpcOperationClickKey.NieREasterLeave, CS.XNpcOperationClickType.KeyUp) + end + end + self:Close() + elseif storyConfig.Type == XNieRConfigs.EasterEggStoryType.Revive then + if self.RealEasterEggWin then + if self.RewardGodList then + XUiManager.OpenUiObtain(self.RewardGodList) + end + self:Close() + elseif self.IsWin then + self.BtnClick.gameObject:SetActiveEx(false) + self:OpenNierEasterEggChatList() + self.PlayerInput = true + else + if CS.XFight.Instance ~= nil then + CS.XFight.Instance.InputControl:OnOperationClick(CS.XNpcOperationClickKey.NieREasterRevive, CS.XNpcOperationClickType.KeyDown) + CS.XFight.Instance.InputControl:OnOperationClick(CS.XNpcOperationClickKey.NieREasterRevive, CS.XNpcOperationClickType.KeyUp) + end + self:Close() + end + end +end diff --git a/Resources/Scripts/XUi/XUiNieR/XUiNieREasterEgg/XUiNieRSaveData.lua b/Resources/Scripts/XUi/XUiNieR/XUiNieREasterEgg/XUiNieRSaveData.lua new file mode 100644 index 00000000..94524417 --- /dev/null +++ b/Resources/Scripts/XUi/XUiNieR/XUiNieREasterEgg/XUiNieRSaveData.lua @@ -0,0 +1,39 @@ + +local XUiNieRSaveData = XLuaUiManager.Register(XLuaUi, "UiNieRSaveData") + + +function XUiNieRSaveData:OnAwake() + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + self.BtnCancel.CallBack = function() self:OnBtnCancelClick() end + self.BtnOk.CallBack = function() self:OnBtnOkClick() end + + +end + +function XUiNieRSaveData:OnStart(isWin, isFirstDied) + if XLuaUiManager.IsUiLoad("UiFubenNierLineChapter") then + XLuaUiManager.Remove("UiFubenNierLineChapter") + end +end + +function XUiNieRSaveData:OnDestroy() + +end + +function XUiNieRSaveData:OnBtnBackClick() + self:Close() +end + +function XUiNieRSaveData:OnBtnMainUiClick() + +end + +function XUiNieRSaveData:OnBtnCancelClick() + self:Close() +end + +function XUiNieRSaveData:OnBtnOkClick() + local stageId = XDataCenter.NieRManager.GetCurNieREasterEggStageId() + XLuaUiManager.PopThenOpen("UiNewRoomSingle", stageId, nil, nil, nil, true) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNieR/XUiNieRNewRoomSingle.lua b/Resources/Scripts/XUi/XUiNieR/XUiNieRNewRoomSingle.lua new file mode 100644 index 00000000..0c2aaaaa --- /dev/null +++ b/Resources/Scripts/XUi/XUiNieR/XUiNieRNewRoomSingle.lua @@ -0,0 +1,36 @@ +-- 尼尔玩法出战界面代理 +local XUiNieRNewRoomSingle = {} + + +function XUiNieRNewRoomSingle.UpdateRoleModel(newRoomSingle, charId, roleModelPanel, pos) + roleModelPanel:ShowRoleModel() + local callback = function() + newRoomSingle.LoadModelCount = newRoomSingle.LoadModelCount - 1 + if newRoomSingle.LoadModelCount <= 0 then + newRoomSingle.BtnEnterFight:SetDisable(false) + end + end + local robotCfg = XRobotManager.GetRobotTemplate(charId) + if not robotCfg then + newRoomSingle:UpdateRoleModel(charId, roleModelPanel, pos) + else + local robotId = charId + local characterId = XRobotManager.GetCharacterId(robotId) + local fashionId = robotCfg.FashionId + local weaponId = robotCfg.WeaponId + local nierChId = XDataCenter.NieRManager.GetCharacterIdByNieRRobotId(charId) + if nierChId ~= 0 then + local nierCharacter = XDataCenter.NieRManager.GetNieRCharacterByCharacterId(nierChId) + weaponId = nierCharacter:GetNieRWeaponId() + fashionId = nierCharacter:GetNieRFashionId() + end + + roleModelPanel:UpdateRobotModel(robotId, characterId, callback, fashionId, weaponId) + end +end + +function XUiNieRNewRoomSingle.SetEditBattleUiTeam(newRoomSingle) + XDataCenter.NieRManager.SetPlayerTeamData(newRoomSingle.CurTeam, newRoomSingle.CurrentStageId) +end + +return XUiNieRNewRoomSingle \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNieR/XUiNieRTask.lua b/Resources/Scripts/XUi/XUiNieR/XUiNieRTask.lua new file mode 100644 index 00000000..df75fae5 --- /dev/null +++ b/Resources/Scripts/XUi/XUiNieR/XUiNieRTask.lua @@ -0,0 +1,102 @@ +local XUiNieRTask = XLuaUiManager.Register(XLuaUi, "UiNierTask") +local XUiPanelNieRTask = require("XUi/XUiNieR/XUiPanelNieRTask") +local XUiGridNieRTaskBtn = require("XUi/XUiNieR/XUiGridNieRTaskBtn") +local PANEL_INDEX = { + Chapter1 = 1, + Chapter2 = 2, + Chapter3 = 3, + Chapter4 = 4, + RepeatChapter = 4, +} +function XUiNieRTask:OnAwake() + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + + self.XUiPanelNieRTask = XUiPanelNieRTask.New(self.PanelTaskStory, self) + + self.DynamicTable = XDynamicTableNormal.New(self.PanelBtnDynamic) + self.DynamicTable:SetProxy(XUiGridNieRTaskBtn) + self.DynamicTable:SetDelegate(self) +end + +function XUiNieRTask:OnStart(jumpId) + self.DefJumpId = jumpId + XEventManager.AddEventListener(XEventId.EVENT_TASK_SYNC, self.ResetNierTaskNode, self) +end + +function XUiNieRTask:OnEnable() + self.LastSelGridIndex = 1 + self:ResetNierTaskNode() +end + +function XUiNieRTask:ResetNierTaskNode() + self.TaskList = XDataCenter.NieRManager.GetActivityNierTaskGroupList() + self.DynamicTable:SetDataSource(self.TaskList) + self.DynamicTable:ReloadDataASync() + + if next(self.TaskList) ~= nil and not self.DefJumpId then + self:OnTaskBtnSelect(self.LastSelGridIndex) + else + local jumpIndex = self.LastSelGridIndex + for index, info in ipairs(self.TaskList) do + if info.TaskGroupId == self.DefJumpId then + jumpIndex = index + end + end + self.LastSelGridIndex = jumpIndex + self:OnTaskBtnSelect(jumpIndex) + self.DefJumpId = nil + end +end + +function XUiNieRTask:OnDisable() + +end + +function XUiNieRTask:OnDestroy() + XEventManager.RemoveEventListener(XEventId.EVENT_TASK_SYNC, self.ResetNierTaskNode, self) +end + +--动态列表事件 +function XUiNieRTask:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.TaskList[index] + grid:Refresh(data) + if self.LastSelGridIndex == index then + grid:IsSelect(true) + else + grid:IsSelect(false) + end + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + if self.LastSelGridIndex == index then return end + local gridLast = self.DynamicTable:GetGridByIndex(self.LastSelGridIndex) + if gridLast then + gridLast:IsSelect(false) + end + grid:IsSelect(true) + self.LastSelGridIndex = index + self:OnTaskBtnSelect(index) + end +end + +function XUiNieRTask:OnTaskBtnSelect(index) + local data = self.TaskList[index] + local taskList = XDataCenter.NieRManager.GetActivityNierTaskByChapterId(data.TaskGroupId) + if self.IsFirstAnimation == nil then + self.IsFirstAnimation = true + else + self.IsFirstAnimation = false + end + XLog.Debug("OnTaskBtnSelect", self.IsFirstAnimation) + self.XUiPanelNieRTask:UpdateTaskList(taskList, self.IsFirstAnimation) + self:PlayAnimation("TaskStoryQieHuan") +end + +function XUiNieRTask:OnBtnBackClick() + self:Close() +end + +function XUiNieRTask:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end diff --git a/Resources/Scripts/XUi/XUiNieR/XUiNierMainLineBanner.lua b/Resources/Scripts/XUi/XUiNieR/XUiNierMainLineBanner.lua new file mode 100644 index 00000000..1efe0c00 --- /dev/null +++ b/Resources/Scripts/XUi/XUiNieR/XUiNierMainLineBanner.lua @@ -0,0 +1,99 @@ +local XUiNierMainLineBanner = XClass(nil, "UiNierMainLineBanner") +local XUiGridNierChapter = require("XUi/XUiNieR/XUiGridNierChapter") +function XUiNierMainLineBanner:Ctor(ui, rootUi) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.StageList = {} + self.GridStageList = {} + self.LineList = {} + + XTool.InitUiObject(self) + + self.DynamicTable = XDynamicTableNormal.New(self.PanelChapterEX) + self.DynamicTable:SetProxy(XUiGridNierChapter) + self.DynamicTable:SetDelegate(self) +end + +function XUiNierMainLineBanner:UpdateData(hideChapter, needShowDelData) + self:SetTimer() + self.TextName.text = XDataCenter.NieRManager.GetActivityName() + self.PanelChapterEX.gameObject:SetActiveEx(not hideChapter) + self.NeedShowDelData = needShowDelData + if needShowDelData then + self.FubenTitleName.gameObject:SetActiveEx(false) + else + self.FubenTitleName.gameObject:SetActiveEx(true) + end + if not hideChapter then + self:SetupDynamicTable() + end +end + +--设置动态列表 +function XUiNierMainLineBanner:SetupDynamicTable() + self.PageDatas = XDataCenter.NieRManager.GetChapterDataList() + self.DynamicTable:SetDataSource(self.PageDatas) + self.DynamicTable:ReloadDataSync() +end + +--动态列表事件 +function XUiNierMainLineBanner:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:UpdateChapterGrid(self.PageDatas[index], self.NeedShowDelData) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + if not self.NeedShowDelData then + self:ClickChapterGrid(self.PageDatas[index]) + end + end +end + +function XUiNierMainLineBanner:ClickChapterGrid(chapterData) + local isUnLock, desc = chapterData:CheckNieRChapterUnLock() + if isUnLock then + XLuaUiManager.Open("UiFubenNierLineChapter", chapterData:GetChapterId()) + else + XUiManager.TipMsg(desc) + end + +end + +--设置活动结束倒计时 +function XUiNierMainLineBanner:SetTimer() + local endTimeSecond = XDataCenter.NieRManager.GetEndTime() + local now = XTime.GetServerNowTimestamp() + if now <= endTimeSecond then + local activeOverStr = CS.XTextManager.GetText("NieREnd") + self:StopTimer() + if now <= endTimeSecond then + self.TextTitle.text = CS.XTextManager.GetText("NieRActivityLeftTime", XUiHelper.GetTime(endTimeSecond - now, XUiHelper.TimeFormatType.CHATEMOJITIMER)) + self.TxtDayNum.text = XUiHelper.GetTime(endTimeSecond - now, XUiHelper.TimeFormatType.NieRShow) + else + self.TxtDayNum.text = activeOverStr + end + + self.Timer = XScheduleManager.ScheduleForever(function() + now = XTime.GetServerNowTimestamp() + if now <= endTimeSecond then + self.TextTitle.text = CS.XTextManager.GetText("NieRActivityLeftTime", XUiHelper.GetTime(endTimeSecond - now, XUiHelper.TimeFormatType.CHATEMOJITIMER)) + self.TxtDayNum.text = XUiHelper.GetTime(endTimeSecond - now, XUiHelper.TimeFormatType.NieRShow) + else + self.TextTitle.text = activeOverStr + self.TxtDayNum.text = activeOverStr + end + if now > endTimeSecond then + self:StopTimer() + return + end + end, XScheduleManager.SECOND, 0) + end +end + +function XUiNierMainLineBanner:StopTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end + +return XUiNierMainLineBanner \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNieR/XUiNierShop.lua b/Resources/Scripts/XUi/XUiNieR/XUiNierShop.lua new file mode 100644 index 00000000..79e3a921 --- /dev/null +++ b/Resources/Scripts/XUi/XUiNieR/XUiNierShop.lua @@ -0,0 +1,254 @@ +local CSXTextManagerGetText = CS.XTextManager.GetText +local ShopHintText = CS.XTextManager.GetText("ActivityNierShopLock") +local XUiNierShop = XLuaUiManager.Register(XLuaUi, "UiNierShop") +local Dropdown = CS.UnityEngine.UI.Dropdown + +function XUiNierShop:OnAwake() + self.GridShop.gameObject:SetActiveEx(false) + self.TxtTime.gameObject:SetActiveEx(false) + self.HintTxt.gameObject:SetActiveEx(false) + self.AssetActivityPanel = XUiPanelActivityAsset.New(self.PanelActivityAsset, true) + self:InitDynamicTable() + self:InitPanels() +end + +function XUiNierShop:OnStart() + + self.IsCanCheckLock = false + self.ShopIdList = XDataCenter.NieRManager.GetActivityShopIds() + self.ShopItemTextColor = {} + self.ShopItemTextColor.CanBuyColor = CS.XGame.ClientConfig:GetString("NierShopItemTextCanBuyColor") + self.ShopItemTextColor.CanNotBuyColor = CS.XGame.ClientConfig:GetString("NierShopItemTextCanNotBuyColor") + + self.TextName.text = CS.XTextManager.GetText("NieRShopNameStr") + XShopManager.GetShopInfoList(self.ShopIdList, function() + self.IsCanCheckLock = true + self:CheckShopLock() + self:InitShopButton() + self:SetButtonLock() + end, XShopManager.ActivityShopType.NieRShop) +end + +function XUiNierShop:OnEnable() + + if self.IsCanCheckLock then + self:CheckShopLock() + self:SetButtonLock() + self:RefreshBuy() + end + self.FromEnable = true + self.EffectRefresh.gameObject:SetActiveEx(false) +end + +function XUiNierShop:InitShopButton() + local shopBtns = { + self.BtnTong1, + self.BtnTong2, + self.BtnTong3, + self.BtnTong4, + } + self.CurIndex = 1 + self.ShopBtn = shopBtns + + local btnNum = #self.ShopIdList + for index, shopBtn in pairs(shopBtns) do + if index <= btnNum then + shopBtn.gameObject:SetActiveEx(true) + shopBtn:SetButtonState(CS.UiButtonState.Normal) + shopBtn:SetNameByGroup(0, XDataCenter.NieRManager.GetActivityShopBtnNameById(self.ShopIdList[index])) + else + shopBtn.gameObject:SetActiveEx(false) + end + + end + + self.FromInit = true + self.BtnTab:Init(shopBtns, function(index) + if not self.FromEnable then + self.EffectRefresh.gameObject:SetActiveEx(false) + else + self.FromEnable = nil + end + + if not self.FromInit and not self.FromEnable then + self.EffectRefresh.gameObject:SetActiveEx(true) + else + self.FromInit = nil + end + if index > btnNum then + return + end + self:SelectShop(index) + end) + self.BtnTab:SelectIndex(self.CurIndex) +end + +function XUiNierShop:CheckShopLock() + self.IsShopLock = {} + self.ShopLockDecs = {} + for k, v in pairs(self.ShopIdList) do + local conditions = XDataCenter.NieRManager.GetActivityShopConditionByShopId(v) + self.IsShopLock[k] = false + self.ShopLockDecs[k] = "" + for _, condition in pairs(conditions or {}) do + if condition ~= 0 then + self.IsShopLock[k], self.ShopLockDecs[k] = XConditionManager.CheckCondition(condition) + self.IsShopLock[k] = not self.IsShopLock[k] + if self.IsShopLock[k] then + break + end + end + end + end +end + +function XUiNierShop:SetButtonLock() + for k, v in pairs(self.ShopBtn or {}) do + v:ShowTag(self.IsShopLock[k]) + end +end + +function XUiNierShop:InitPanels() + self.ImgEmpty.gameObject:SetActiveEx(true) + self.AssetActivityPanel.GameObject:SetActiveEx(false) + self.BtnBack.CallBack = function() + self:Close() + end + + self.BtnScreenWords.onValueChanged:AddListener(function() + -- self.SelectBtnScreenWordsCaptionText = + self:UpdateDynamicTable() + end) +end + +function XUiNierShop:UpdatePanels() + local shopId = self.ShopIdList[self.CurIndex] + local shopGoods = XDataCenter.NieRManager.GetActivityShopGoodsByShopId(shopId) + local isEmpty = not next(shopGoods or {}) + self.ImgEmpty.gameObject:SetActiveEx(isEmpty) + self.AssetActivityPanel.GameObject:SetActiveEx(not isEmpty) + + + local shopTimeInfo = XShopManager.GetShopTimeInfo(shopId) + local leftTime = shopTimeInfo.ClosedLeftTime + if leftTime and leftTime > 0 then + local timeStr = XUiHelper.GetTime(leftTime, XUiHelper.TimeFormatType.ACTIVITY) + self.TxtTime.text = CSXTextManagerGetText("ActivityNierShopLeftTime", timeStr) + self.TxtTime.gameObject:SetActiveEx(true) + else + self.TxtTime.gameObject:SetActiveEx(false) + end +end + +function XUiNierShop:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelItemList) + self.DynamicTable:SetProxy(XUiGridShop) + self.DynamicTable:SetDelegate(self) +end + +function XUiNierShop:UpdateDynamicTable() + local shopId = self.ShopIdList[self.CurIndex] + local shopGoods + if self:IsShowDropdown() then + shopGoods = XShopManager.GetScreenGoodsListByTag(self:GetCurShopId(), self.ScreenGroupIDList[1], self.BtnScreenWords.captionText.text) + else + shopGoods = XDataCenter.NieRManager.GetActivityShopGoodsByShopId(shopId) + end + + self.ShopGoods = shopGoods + self.DynamicTable:SetDataSource(shopGoods) + self.DynamicTable:ReloadDataASync() +end + +function XUiNierShop:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.ShopGoods[index] + self:SetShopItemLock(grid) + self:SetShopItemBg(grid) + grid:UpdateData(data, self.ShopItemTextColor) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_RECYCLE then + grid:OnRecycle() + end +end + +function XUiNierShop:InitDropdown() + local shopId = self:GetCurShopId() + self.ScreenGroupIDList = XShopManager.GetShopScreenGroupIDList(shopId) + + if self:IsShowDropdown() then + self.BtnScreenWords.gameObject:SetActiveEx(true) + + local screenTagList = XShopManager.GetScreenTagListById(shopId, self.ScreenGroupIDList[1]) + self.BtnScreenWords:ClearOptions() + self.BtnScreenWords.captionText.text = CSXTextManagerGetText("ScreenAll") + for _, v in pairs(screenTagList or {}) do + local op = Dropdown.OptionData() + op.text = v.Text + self.BtnScreenWords.options:Add(op) + end + self.BtnScreenWords.value = 0 + else + self.BtnScreenWords.gameObject:SetActiveEx(false) + end +end + +function XUiNierShop:IsShowDropdown() + if self.ScreenGroupIDList and next(self.ScreenGroupIDList) then + return true + else + return false + end +end + +function XUiNierShop:UpdateBuy(data, cb) + XLuaUiManager.Open("UiShopItem", self, data, cb) + self:PlayAnimation("ShopItemEnable") +end + +function XUiNierShop:GetCurShopId() + return self.ShopIdList[self.CurIndex] +end + +function XUiNierShop:RefreshBuy() + local shopId = self:GetCurShopId() + self.AssetActivityPanel:Refresh(XShopManager.GetShopShowIdList(shopId)) + self:UpdateDynamicTable() +end + +function XUiNierShop:SetShopItemBg(grid) + local shopId = self:GetCurShopId() + local bg = XDataCenter.NieRManager.GetActivityShopItemBgById(shopId) + if grid.ItemBg and bg then + grid.ItemBg:SetRawImage(bg) + end +end + +function XUiNierShop:SetShopItemLock(grid) + grid.IsShopLock = self.IsShopLock[self.CurIndex] + grid.ShopLockDecs = ShopHintText + if grid.ImgLock then + grid.ImgLock.gameObject:SetActiveEx(self.IsShopLock[self.CurIndex]) + end +end + +function XUiNierShop:SelectShop(index) + self.CurIndex = index + local shopId = self:GetCurShopId() + self:PlayAnimation("AnimQieHuan") + self.HintTxt.gameObject:SetActiveEx(self.IsShopLock[self.CurIndex]) + self.HintTxt.text = self.ShopLockDecs[self.CurIndex] + + local bg = XDataCenter.NieRManager.GetActivityShopBgById(shopId) + self.RImgBg:SetRawImage(bg) + + local icon = XDataCenter.NieRManager.GetActivityShopIconById(shopId) + self.RImgShopIcon:SetRawImage(icon) + + XShopManager.GetShopInfoList(self.ShopIdList, function() + self:UpdatePanels() + self:RefreshBuy() + self:InitDropdown() + end, XShopManager.ActivityShopType.NieRShop) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNieR/XUiPanelNieRTask.lua b/Resources/Scripts/XUi/XUiNieR/XUiPanelNieRTask.lua new file mode 100644 index 00000000..681d5ce1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiNieR/XUiPanelNieRTask.lua @@ -0,0 +1,58 @@ +local XUiPanelNieRTask = XClass(nil, "XUiPanelNieRTask") +local GridTimeAnimation = 50 +function XUiPanelNieRTask:Ctor(ui, rootUi) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + self.DynamicTable = XDynamicTableNormal.New(self.PanelTaskStoryList) + self.DynamicTable:SetProxy(XDynamicGridTask) + self.DynamicTable:SetDelegate(self) +end + +function XUiPanelNieRTask:UpdateTaskList(taskList, playAnimation) + self.TaskList = taskList + self.GridCount = 0 + if self.CurAnimationTimerId then + XScheduleManager.UnSchedule(self.CurAnimationTimerId) + self.CurAnimationTimerId = nil + end + self.PlayAnimation = playAnimation + if next(taskList) == nil then + self.PanelTaskStoryList.gameObject:SetActiveEx(false) + self.PanelNoneStoryTask.gameObject:SetActiveEx(true) + else + self.PanelTaskStoryList.gameObject:SetActiveEx(true) + self.PanelNoneStoryTask.gameObject:SetActiveEx(false) + self.DynamicTable:SetDataSource(self.TaskList) + self.DynamicTable:ReloadDataASync() + end + +end + +--动态列表事件 +function XUiPanelNieRTask:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.TaskList[index] + grid.RootUi = self.RootUi + grid:ResetData(data) + self.GridCount = self.GridCount + 1 + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_RELOAD_COMPLETED then + if not self.PlayAnimation then + return + end + local grids = self.DynamicTable:GetGrids() + self.GridIndex = 1 + self.CurAnimationTimerId = XScheduleManager.Schedule(function() + local item = grids[self.GridIndex] + if item then + item.GameObject:SetActive(true) + item:PlayAnimation() + end + self.GridIndex = self.GridIndex + 1 + end, GridTimeAnimation, self.GridCount, 0) + end +end + +return XUiPanelNieRTask \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNieR/XUiRepeat/XUiFubenNierRepeat.lua b/Resources/Scripts/XUi/XUiNieR/XUiRepeat/XUiFubenNierRepeat.lua new file mode 100644 index 00000000..d5ac2c60 --- /dev/null +++ b/Resources/Scripts/XUi/XUiNieR/XUiRepeat/XUiFubenNierRepeat.lua @@ -0,0 +1,155 @@ +local XUiFubenNierRepeat = XLuaUiManager.Register(XLuaUi, "UiFubenNierRepeat") +local XUiNieRLineBanner = require("XUi/XUiNieR/XUiRepeat/XUiNierRepeatLineBanner") + +function XUiFubenNierRepeat:OnAwake() + + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + + self.BtnTeam.CallBack = function() self:OnBtnTeamClick() end + self.BtnPOD.CallBack = function() self:OnBtnPODClick() end + self.BtnRenWu.CallBack = function() self:OnBtnRenWuClick() end + self.BtnShop.CallBack = function() self:OnBtnShopClick() end + self:BindHelpBtn(self.BtnHelp, "NierRepeatHelp") + self.BtnTeam.gameObject:SetActiveEx(false) + self.BtnPOD.gameObject:SetActiveEx(false) + self.BtnRenWu.gameObject:SetActiveEx(false) + self.BtnShop.gameObject:SetActiveEx(false) + + -- self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.NieRManager.GetRepeatStageConsumeId()) + -- self.AssetPanel:RegisterJumpCallList({[1] = function() + -- self:OnTickJumpClick() + -- end }) + self:InitAssetPanel() + self.XUiNieRLineBanner = XUiNieRLineBanner.New(self.UiFubenMainLineBanner, self) + -- self.UiNierMainLineBanner:UpdateData() + +end + +function XUiFubenNierRepeat:OnStart(paramId) + self.NeedJumpId = paramId + self:AddRedPointEvent() +end + +function XUiFubenNierRepeat:OnEnable() + if XDataCenter.NieRManager.GetIsActivityEnd() then + XScheduleManager.ScheduleOnce(function() + if not self.GameObject or not self.GameObject:Exist() then return end + XDataCenter.NieRManager.OnActivityEnd() + end, 1) + else + local unlockCount,count = XDataCenter.NieRManager.GetCharacterCount() + local nierPOD = XDataCenter.NieRManager.GetNieRPODData() + -- self.BtnTeam:SetNameByGroup(0, CS.XTextManager.GetText("NieRBtnTeamNameStr")) + -- self.BtnPOD:SetNameByGroup(0, CS.XTextManager.GetText("NieRBtnPODNameStr")) + -- self.BtnRenWu:SetNameByGroup(0, CS.XTextManager.GetText("NieRBtnRenWuNameStr")) + -- self.BtnShop:SetNameByGroup(0, CS.XTextManager.GetText("NieRBtnShopNameStr")) + + -- self.BtnTeam:SetNameByGroup(1, string.format("%s/%s",unlockCount, count)) + -- self.BtnPOD:SetNameByGroup(1, string.format("Lv.%s",nierPOD:GetNieRPODLevel())) + self.XUiNieRLineBanner:UpdateData(self.NeedJumpId) + self.NeedJumpId = nil + XDataCenter.NieRManager.CheckNieRCharacterAbilityOpen() + end +end + +function XUiFubenNierRepeat:OnDisable() +end + +function XUiFubenNierRepeat:OnDestroy() +end + +function XUiFubenNierRepeat:InitAssetPanel() + local PanelTool1 = XUiHelper.TryGetComponent(self.PanelAsset.transform, "PanelTool1", nil) + local RImgTool1 = XUiHelper.TryGetComponent(self.PanelAsset.transform, "PanelTool1/RImgTool1", "RawImage") + self.TxtTool1 = XUiHelper.TryGetComponent(self.PanelAsset.transform, "PanelTool1/TxtTool1", "Text") + self.BtnBuyJump1 = XUiHelper.TryGetComponent(self.PanelAsset.transform, "PanelTool1/BtnBuyJump1", "Button") + if self.BtnBuyJump1 then + XUiHelper.RegisterClickEvent(self, self.BtnBuyJump1, self.OnTickJumpClick) + end + + local itemId = XDataCenter.NieRManager.GetRepeatStageConsumeId() + local item = XDataCenter.ItemManager.GetItem(itemId) + + if RImgTool1 ~= nil and RImgTool1:Exist() then + RImgTool1:SetRawImage(item.Template.Icon, nil, false) + end + + local func = function(textTool, id) + local itemCount = XDataCenter.ItemManager.GetCount(id) + textTool.text = itemCount .. "/" .. XDataCenter.NieRManager.GetNieRRepeatConsumeMaxCount() + end + local f = function() + func(self.TxtTool1, itemId) + end + XDataCenter.ItemManager.AddCountUpdateListener(itemId, f, self.TxtTool1) + func(self.TxtTool1, itemId) +end + +function XUiFubenNierRepeat:OnTickJumpClick() + local item = XDataCenter.ItemManager.GetItem(XDataCenter.NieRManager.GetRepeatStageConsumeId()) + local data = { + Id = item.Id, + Count = item ~= nil and tostring(item.Count) or "0" + } + XLuaUiManager.Open("UiTip", data) +end + +--添加点事件 +function XUiFubenNierRepeat:AddRedPointEvent() + -- XRedPointManager.AddRedPointEvent(self.BtnRenWu, self.RefreshTaskRedDot, self,{ XRedPointConditions.Types.CONDITION_NIER_TASK_RED }, -1) + -- XRedPointManager.AddRedPointEvent(self.BtnTeam, self.RefreshTeamRedDot, self,{ XRedPointConditions.Types.CONDITION_NIER_CHARACTER_RED }, {CharacterId = -1, IsInfor = true, IsTeach = true}) + -- XRedPointManager.AddRedPointEvent(self.BtnPOD, self.RefreshPODRedDot, self,{ XRedPointConditions.Types.CONDITION_NIER_POD_RED }) +end + +--任务按钮红点 +function XUiFubenNierRepeat:RefreshTaskRedDot(count) + self.BtnRenWuRed.gameObject:SetActiveEx(count >= 0) +end + +--尼尔角色按钮红点 +function XUiFubenNierRepeat:RefreshTeamRedDot(count) + self.BtnTeamRed.gameObject:SetActiveEx(count >= 0) +end + +--辅助机按钮红点 +function XUiFubenNierRepeat:RefreshPODRedDot(count) + self.BtnPODRed.gameObject:SetActiveEx(count >= 0) +end + +function XUiFubenNierRepeat:OnBtnBackClick() + self:Close() +end + +function XUiFubenNierRepeat:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiFubenNierRepeat:OnBtnTeamClick() + XLuaUiManager.Open("UiNierCharacterSel") +end + +function XUiFubenNierRepeat:OnBtnPODClick() + XLuaUiManager.Open("UiFuBenNierWork") +end + +function XUiFubenNierRepeat:OnBtnRenWuClick() + local skipId = self.XUiNieRLineBanner:GetNieRRepeatTaskSkipId() + if skipId and skipId ~= 0 then + XFunctionManager.SkipInterface(skipId) + else + XLuaUiManager.Open("UiNierTask") + end +end + +function XUiFubenNierRepeat:OnBtnShopClick() + if XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.ShopCommon) + or XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.ShopActive) then + XLuaUiManager.Open("UiNierShop") + end +end + +function XUiFubenNierRepeat:OnBtnChapterClick(stageId, nierRepeatStageId) + XLuaUiManager.Open("UiFubenNierGuanqiaNormal", stageId, XNieRConfigs.NieRStageType.RepeatStage, nierRepeatStageId) + XDataCenter.NieRManager.SaveSelRepeatStageId(nierRepeatStageId) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNieR/XUiRepeat/XUiGridNierRepeatMainStage.lua b/Resources/Scripts/XUi/XUiNieR/XUiRepeat/XUiGridNierRepeatMainStage.lua new file mode 100644 index 00000000..451fa649 --- /dev/null +++ b/Resources/Scripts/XUi/XUiNieR/XUiRepeat/XUiGridNierRepeatMainStage.lua @@ -0,0 +1,148 @@ +local XUiGridNierRepeatMainStage = XClass(nil, "XUiGridNierRepeatMainStage") +local MAX_GIRD_COUNT = 3 +function XUiGridNierRepeatMainStage:Ctor(ui, rootUi) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + self.RootUi:RegisterClickEvent(self.BtnChapter, function() + self:OnBtnChapterClick() + end) + self.GridList = {} +end + +function XUiGridNierRepeatMainStage:UpdateInfo(data) + self.NierRepeatStageId = data:GetNieRRepeatStageId() + self.StageId = data:GetNieRRepeatStageId() + self.Stage = XDataCenter.FubenManager.GetStageCfg(self.StageId) + self.TitleName.text = self.Stage.Name + self.RepeatData = data + + local Icon = self.Stage.Icon + + if data:CheckNieRRepeatMainStageUnlock() then + self.PanelNewEffect.gameObject:SetActiveEx(false) + local starNum = data:GetNieRRepeatStar() + starNum = starNum > 4 and 4 or starNum + for index = 1, 4 do + if index <= starNum then + self["DarkStar"..index].gameObject:SetActiveEx(false) + else + self["DarkStar"..index].gameObject:SetActiveEx(true) + end + end + self.ImgFinish.gameObject:SetActiveEx(starNum > 4) + self:UpdateRewardShow(data, starNum) + + local consumeId, consumCount = XDataCenter.NieRManager.GetRepeatStageConsumeId(), data:GetNierRepeatStageConsumeCount() + local haveCount = XDataCenter.ItemManager.GetCount(consumeId) + local needActionPoint = self.Stage.RequireActionPoint + local haveActionPoint = XDataCenter.ItemManager.GetCount(XDataCenter.ItemManager.ItemId.ActionPoint) + local redByShowTime = XDataCenter.NieRManager.CheckNieRRepeatRedTime() + local isRed = false + if redByShowTime and haveCount >= consumCount and haveActionPoint >= needActionPoint then + isRed = true + end + self.ImgRedDot.gameObject:SetActiveEx(isRed) + if not Icon or Icon == "" then + self.PanelNormal.gameObject:SetActiveEx(false) + self.PanelSpecial.gameObject:SetActiveEx(true) + self.SpecoalBgLock.gameObject:SetActiveEx(false) + self.SpecoalBg.gameObject:SetActiveEx(true) + else + self.PanelNormal.gameObject:SetActiveEx(true) + self.PanelSpecial.gameObject:SetActiveEx(false) + self.BgLock.gameObject:SetActiveEx(false) + self.RawBgBg:SetRawImage(Icon) + self.RawBg:SetRawImage(Icon) + self.RawBg.gameObject:SetActiveEx(true) + end + else + for index = 1, 4 do + self["DarkStar"..index].gameObject:SetActiveEx(true) + end + self.ImgRedDot.gameObject:SetActiveEx(false) + self.ImgFinish.gameObject:SetActiveEx(false) + self.PanelNewEffect.gameObject:SetActiveEx(false) + if not Icon or Icon == "" then + self.PanelNormal.gameObject:SetActiveEx(false) + self.PanelSpecial.gameObject:SetActiveEx(true) + self.SpecoalBgLock.gameObject:SetActiveEx(true) + self.SpecoalBg.gameObject:SetActiveEx(false) + else + self.PanelNormal.gameObject:SetActiveEx(true) + self.PanelSpecial.gameObject:SetActiveEx(false) + self.BgLock.gameObject:SetActiveEx(true) + self.RawBgBg:SetRawImage(Icon) + self.RawBg:SetRawImage(Icon) + self.RawBgLock:SetRawImage(Icon) + self.RawBg.gameObject:SetActiveEx(false) + end + self:UpdateRewardShow(data, 0) + end +end + +function XUiGridNierRepeatMainStage:UpdateRewardShow(data, starNum) + local rewardId = 0 + local stage = XDataCenter.FubenManager.GetStageCfg(self.StageId) + local rewards + local IsFirst = false + if starNum > 0 then + rewardId = data:GetNieRExStarReward(starNum) + else + rewardId = data:GetNieRNormalReward() + end + if rewardId == 0 then + for j = 1, MAX_GIRD_COUNT do + if self.GridList[j] then + self.GridList[j].GameObject:SetActiveEx(false) + elseif self["Grid"..j] then + self["Grid"..j].gameObject:SetActiveEx(false) + end + end + return + end + + rewards = IsFirst and XRewardManager.GetRewardList(rewardId) or XRewardManager.GetRewardListNotCount(rewardId) + + local rewardsCount = 0 + if rewards then + rewardsCount = #rewards + rewardsCount = rewardsCount > 3 and 3 or rewardsCount + for i = 1, rewardsCount, 1 do + local grid + local item = rewards[i] + if self.GridList[i] then + grid = self.GridList[i] + else + local ui = self["Grid"..i] + grid = XUiGridCommon.New(self.RootUi, ui) + self.GridList[i] = grid + end + grid:Refresh(item) + grid.GameObject:SetActiveEx(true) + end + end + + for j = 1, MAX_GIRD_COUNT do + if j > rewardsCount then + if self.GridList[j] then + self.GridList[j].GameObject:SetActiveEx(false) + elseif self["Grid"..j] then + self["Grid"..j].gameObject:SetActiveEx(false) + end + end + end +end + +function XUiGridNierRepeatMainStage:OnBtnChapterClick() + local condit, desc = self.RepeatData:CheckNieRRepeatMainStageUnlock() + if condit then + self.RootUi:OnBtnChapterClick(self.StageId, self.NierRepeatStageId) + else + XUiManager.TipMsg(desc) + end +end + +return XUiGridNierRepeatMainStage \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNieR/XUiRepeat/XUiGridNierRepeatStage.lua b/Resources/Scripts/XUi/XUiNieR/XUiRepeat/XUiGridNierRepeatStage.lua new file mode 100644 index 00000000..6499ce05 --- /dev/null +++ b/Resources/Scripts/XUi/XUiNieR/XUiRepeat/XUiGridNierRepeatStage.lua @@ -0,0 +1,78 @@ +local XUiGridNierRepeatStage = XClass(nil, "XUiGridNierRepeatStage") + +function XUiGridNierRepeatStage:Ctor(ui, rootUi) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + self.RootUi:RegisterClickEvent(self.BtnChapter, function() + self:OnBtnChapterClick() + end) + + self.GridList = {} + self.LockGridList = {} +end + +function XUiGridNierRepeatStage:UpdateInfo(data, index) + self.RepeatData = data + self.NierRepeatStageId = data:GetNieRRepeatStageId() + local stageId = data:GetNieRExStageIds()[index] + local nierRepeatCondit = data:GetNieRExStageConditions()[index] + self.StageId = stageId + self.Stage = XDataCenter.FubenManager.GetStageCfg(stageId) + self.TextTitle.text = self.Stage.Name + self.TextTitleLock.text = self.Stage.Name + local stageIsPassed = XDataCenter.FubenManager.CheckStageIsPass(stageId) + + self.ImgFinish.gameObject:SetActiveEx(stageIsPassed) + self.GetTips.gameObject:SetActiveEx(stageIsPassed) + if data:CheckNieRRepeatStageUnlock(stageId) then + self.PanelChapter.gameObject:SetActiveEx(true) + self.PanelNewEffect.gameObject:SetActiveEx(false) + self.ImgRedDot.gameObject:SetActiveEx(false) + self.PanelChapterLock.gameObject:SetActiveEx(false) + if data:CheckNieRRepeatStagePass(stageId) then + self.ImgFinish.gameObject:SetActiveEx(true) + else + self.ImgFinish.gameObject:SetActiveEx(false) + end + self.RImgChapter:SetRawImage(self.Stage.Icon) + + else + self.PanelChapter.gameObject:SetActiveEx(false) + self.PanelNewEffect.gameObject:SetActiveEx(false) + self.ImgRedDot.gameObject:SetActiveEx(false) + self.ImgFinish.gameObject:SetActiveEx(false) + self.PanelChapterLock.gameObject:SetActiveEx(true) + self.RImgChapterLock:SetRawImage(self.Stage.Icon) + end + + self:UpdateRewardShow(data) +end + +function XUiGridNierRepeatStage:UpdateRewardShow(data) + local cfg = XNieRConfigs.GetNieRRepeatableStageClient(self.StageId) + -- + self.RImgIcon:SetRawImage(cfg.RewardIcon) + self.RImgIconL:SetRawImage(cfg.RewardIcon) + if cfg.RewardQuality ~= 0 then + XUiHelper.SetQualityIcon(self.RootUi, self.ImgQuality, cfg.RewardQuality) + XUiHelper.SetQualityIcon(self.RootUi, self.ImgQualityL, cfg.RewardQuality) + end + self.TxtName.text = cfg.RewardTitle + self.TxtNameL.text = cfg.RewardTitle + + +end + +function XUiGridNierRepeatStage:OnBtnChapterClick() + local condit, desc = self.RepeatData:CheckNieRRepeatStageUnlock(self.StageId) + if condit then + self.RootUi:OnBtnChapterClick(self.StageId, self.NierRepeatStageId) + else + XUiManager.TipMsg(desc) + end +end + +return XUiGridNierRepeatStage \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNieR/XUiRepeat/XUiNieRRepeatTag.lua b/Resources/Scripts/XUi/XUiNieR/XUiRepeat/XUiNieRRepeatTag.lua new file mode 100644 index 00000000..d7cada87 --- /dev/null +++ b/Resources/Scripts/XUi/XUiNieR/XUiRepeat/XUiNieRRepeatTag.lua @@ -0,0 +1,66 @@ +local XUiNieRRepeatTag = XClass(nil, "XUiNieRRepeatTag") +local XUiPanelNieRRepeatBanner = require("XUi/XUiNieR/XUiRepeat/XUiPanelNieRRepeatBanner") +function XUiNieRRepeatTag:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + self.StageNor.gameObject:SetActiveEx(false) + self.StageNorSel.gameObject:SetActiveEx(false) + self.StageNor.gameObject:SetActiveEx(false) + self.StageNorSel.gameObject:SetActiveEx(false) +end + +function XUiNieRRepeatTag:Init(data, isSel) + self.IsActive = data:CheckNieRRepeatMainStageUnlock() + self.StageId = data:GetNieRRepeatStageId() + self.Stage = XDataCenter.FubenManager.GetStageCfg(self.StageId) + self.IsSelect = isSel + if self.IsActive then + self.TextNor.text = self.Stage.Name + self.TextNorSel.text = self.Stage.Name + if not isSel then + self.StageNor.gameObject:SetActiveEx(true) + self.StageNorSel.gameObject:SetActiveEx(false) + else + self.StageNor.gameObject:SetActiveEx(false) + self.StageNorSel.gameObject:SetActiveEx(true) + end + else + self.TextDis.text = self.Stage.Name + self.TextDisSel.text = self.Stage.Name + if not isSel then + self.StageDis.gameObject:SetActiveEx(true) + self.StageDisSel.gameObject:SetActiveEx(false) + else + self.StageDis.gameObject:SetActiveEx(false) + self.StageDisSel.gameObject:SetActiveEx(true) + end + end +end + +function XUiNieRRepeatTag:ChangeSelState(isSel) + if self.IsSelect == isSel then + return + end + self.IsSelect = isSel + if self.IsActive then + if not isSel then + self.StageNor.gameObject:SetActiveEx(true) + self.StageNorSel.gameObject:SetActiveEx(false) + else + self.StageNor.gameObject:SetActiveEx(false) + self.StageNorSel.gameObject:SetActiveEx(true) + end + else + if not isSel then + self.StageDis.gameObject:SetActiveEx(true) + self.StageDisSel.gameObject:SetActiveEx(false) + else + self.StageDis.gameObject:SetActiveEx(false) + self.StageDisSel.gameObject:SetActiveEx(true) + end + end +end + +return XUiNieRRepeatTag \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNieR/XUiRepeat/XUiNierRepeatLineBanner.lua b/Resources/Scripts/XUi/XUiNieR/XUiRepeat/XUiNierRepeatLineBanner.lua new file mode 100644 index 00000000..0a0d10e1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiNieR/XUiRepeat/XUiNierRepeatLineBanner.lua @@ -0,0 +1,149 @@ +local XUiNierRepeatLineBanner = XClass(nil, "XUiNierRepeatLineBanner") +local XUiPanelNieRRepeatBanner = require("XUi/XUiNieR/XUiRepeat/XUiPanelNieRRepeatBanner") +local XUiNieRRepeatTag = require("XUi/XUiNieR/XUiRepeat/XUiNieRRepeatTag") +function XUiNierRepeatLineBanner:Ctor(ui, rootUi) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + + self.ArrowR.CallBack = function() self:OnBtnArrowRClick() end + self.ArrowL.CallBack = function() self:OnBtnArrowLClick() end + + self.DynamicTable = XDynamicTableCurve.New(self.ScrollChapterCurve) + self.DynamicTable:SetProxy(XUiPanelNieRRepeatBanner) + self.DynamicTable:SetDelegate(self) + + self.NieRRepeatTags = {} + self.SelectedIndex = 0 + self.IsShowTag = true + +end + +function XUiNierRepeatLineBanner:UpdateData(jumpId) + self.AnimEnable.gameObject:PlayTimelineAnimation(function() + + end) + self.RepeatList = XDataCenter.NieRManager.GetRepeatDataList() + + + self.RepeatCount = #self.RepeatList + self.DynamicTable:SetDataSource(self.RepeatList) + self.DynamicTable:ReloadData(self.RepeatCount > 0 and self.SelectedIndex or -1) + + self:UpdateArrowByIndex(self.SelectedIndex) + self.TxtTitleBg.text = string.format("/%02d", self.RepeatCount) + for index = 1, 4 do + local grid + if not self.NieRRepeatTags[index] then + grid = XUiNieRRepeatTag.New(self["Stage"..index]) + self.NieRRepeatTags[index] = grid + else + grid = self.NieRRepeatTags[index] + end + grid:Init(self.RepeatList[index], (self.SelectedIndex + 1 == index)) + end + self.LastTagIndex = self.SelectedIndex + + if jumpId then + local jumpIndex = 0 + for index, data in ipairs(self.RepeatList) do + if data:GetNieRRepeatStageId() == jumpId then + jumpIndex = index - 1 + break + end + end + self.DynamicTable:TweenToIndex(jumpIndex) + else + local stageId = XDataCenter.NieRManager.GetSelRepeatStageId() + if stageId == 0 then + return + end + local jumpIndex = 0 + for index, data in ipairs(self.RepeatList) do + if data:GetNieRRepeatStageId() == stageId then + jumpIndex = index - 1 + break + end + end + self.DynamicTable:TweenToIndex(jumpIndex) + end +end + +function XUiNierRepeatLineBanner:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self.RootUi) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:Refresh(self.RepeatList[index + 1]) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_TWEEN_OVER then + local startIndex = self.DynamicTable.Imp.StartIndex + local selectIndex = startIndex % self.DynamicTable.Imp.TotalCount + if self.SelectedIndex ~= selectIndex then + self.SelectedIndex = selectIndex + grid = self.DynamicTable:GetGridByIndex(selectIndex) + if grid then + grid:PlayLoopAnim() + end + end + self.Retrieval.gameObject:SetActiveEx(true) + self.IsShowTag = true + self:UpdateArrowByIndex(self.SelectedIndex) + self:UpdateTagByIndex(self.SelectedIndex) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_BEGIN_DRAG then + if self.IsShowTag then + self.Retrieval.gameObject:SetActiveEx(false) + self.IsShowTag = false + end + end +end + + +function XUiNierRepeatLineBanner:UpdateArrowByIndex(index) + if index == self.LastTagIndex then + return + end + if index == 0 then + self.ArrowL.gameObject:SetActiveEx(false) + else + self.ArrowL.gameObject:SetActiveEx(true) + end + + if index == self.RepeatCount - 1 then + self.ArrowR.gameObject:SetActiveEx(false) + else + self.ArrowR.gameObject:SetActiveEx(true) + end +end + +function XUiNierRepeatLineBanner:UpdateTagByIndex(index) + if index == self.LastTagIndex then + return + end + self.TxtTitle.text = string.format("%02d", index + 1) + self.NieRRepeatTags[index + 1]:ChangeSelState(true) + if self.LastTagIndex then + self.NieRRepeatTags[self.LastTagIndex + 1]:ChangeSelState(false) + end + self.LastTagIndex = index +end + +function XUiNierRepeatLineBanner:OnBtnArrowRClick() + self.DynamicTable:TweenToIndex(self.SelectedIndex + 1) +end + +function XUiNierRepeatLineBanner:OnBtnArrowLClick() + self.DynamicTable:TweenToIndex(self.SelectedIndex - 1) +end + +function XUiNierRepeatLineBanner:GetNieRRepeatTaskSkipId() + local nieRRepeat = self.RepeatList[self.SelectedIndex + 1] + if nieRRepeat then + return nieRRepeat:GetNieRRepeatTaskSkipId() + end + return nil +end + +return XUiNierRepeatLineBanner \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNieR/XUiRepeat/XUiPanelNieRRepeatBanner.lua b/Resources/Scripts/XUi/XUiNieR/XUiRepeat/XUiPanelNieRRepeatBanner.lua new file mode 100644 index 00000000..ad76a298 --- /dev/null +++ b/Resources/Scripts/XUi/XUiNieR/XUiRepeat/XUiPanelNieRRepeatBanner.lua @@ -0,0 +1,52 @@ +local XUiPanelNieRRepeatBanner = XClass(nil, "XUiPanelNieRRepeatBanner") +local XUiGridNierRepeatMainStage = require("XUi/XUiNieR/XUiRepeat/XUiGridNierRepeatMainStage") +local XUiGridNierRepeatStage = require("XUi/XUiNieR/XUiRepeat/XUiGridNierRepeatStage") +function XUiPanelNieRRepeatBanner:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + + self.StageList = {} + for index = 1, 4 do + self.StageList[index] = self["GridMainLineBanner"..index] + end + self.RepeatStageEx = {} +end + +function XUiPanelNieRRepeatBanner:Init(rootUi) + self.RootUi = rootUi +end + +function XUiPanelNieRRepeatBanner:Refresh(repeatMainStage) + local chapterProxy + if not self.RepeatChapter then + chapterProxy = XUiGridNierRepeatMainStage.New(self.GridMainLineBannerRepeat1, self.RootUi) + self.RepeatChapter = chapterProxy + else + chapterProxy = self.RepeatChapter + end + chapterProxy:UpdateInfo(repeatMainStage) + + local stageProxy + for index = 1, 4 do + if not self.RepeatStageEx[index] then + stageProxy = XUiGridNierRepeatStage.New(self.StageList[index], self.RootUi) + self.RepeatStageEx[index] = stageProxy + else + stageProxy = self.RepeatStageEx[index] + end + + stageProxy:UpdateInfo(repeatMainStage, index) + end +end + +function XUiPanelNieRRepeatBanner:PlayLoopAnim() + self.AnimEnable.gameObject:SetActiveEx(false) + self.AnimEnable.gameObject:SetActiveEx(true) + self.IconLoop.gameObject:PlayTimelineAnimation(function() + + end) +end + +return XUiPanelNieRRepeatBanner \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiNoticeTips/XUiNoticeTips.lua b/Resources/Scripts/XUi/XUiNoticeTips/XUiNoticeTips.lua new file mode 100644 index 00000000..e8d4464c --- /dev/null +++ b/Resources/Scripts/XUi/XUiNoticeTips/XUiNoticeTips.lua @@ -0,0 +1,177 @@ +local XUiNoticeTips = XLuaUiManager.Register(XLuaUi, "UiNoticeTips") + +local MoveSpeed = 100 +local TextReservedWidth = 60 +local HideIntervalTime = 3 +local WaitTime = 3 + +function XUiNoticeTips:OnAwake() + self:InitAutoScript() + + if not self.behaviour then + self.behaviour = self.Transform.gameObject:AddComponent(typeof(CS.XLuaBehaviour)) + self.behaviour.LuaUpdate = function() + if self.Update then + self:Update() + end + end + end +end + +function XUiNoticeTips:OnStart() + self:RefreshNoticeContent() + + self.TxtNoticeWidth = XUiHelper.CalcTextWidth(self.TxtNotice) + self.PanelNoticeRect = self.PanelNotice.gameObject:GetComponent("RectTransform") + self.PauseTime = 0 +end + +function XUiNoticeTips:RefreshNoticeContent() + local noticeContent = XDataCenter.NoticeManager.GetTextNoticeContent() + if not noticeContent then + return + end + self.TxtNotice.text = noticeContent +end + +function XUiNoticeTips:OnNotify(evt) + if evt == XEventId.EVENT_USER_LOGOUT then + self:Close() + elseif evt == XEventId.EVENT_NOTICE_CLOSE_TEXT_NOTICE then + self:Close() + end +end + +function XUiNoticeTips:OnGetEvents() + return {XEventId.EVENT_NOTICE_CLOSE_TEXT_NOTICE, XEventId.EVENT_USER_LOGOUT} +end + +function XUiNoticeTips:GetEndPos() + if self.EndPos then + return self.EndPos + end + + self.EndPos = CS.UnityEngine.Vector3((-self.PanelNoticeRect.sizeDelta.x / 2 - self.TxtNoticeWidth / 2), 0, 0) + + return self.EndPos +end + +function XUiNoticeTips:GetBeginPos() + local BeginPos + if self.TxtNoticeWidth > self.PanelNoticeRect.sizeDelta.x then + BeginPos = CS.UnityEngine.Vector3((self.TxtNoticeWidth - self.PanelNoticeRect.sizeDelta.x) / 2 + TextReservedWidth, 0, 0) + else + BeginPos = CS.UnityEngine.Vector3(0, 0, 0) + end + return BeginPos +end + +function XUiNoticeTips:ResetTxtNoticePos() + if not self.NeedReset then + return false + end + + XDataCenter.NoticeManager.AddTextNoticeCount() + + if not XDataCenter.NoticeManager.CheckTextNoticeValid() then + return true + end + + self:SetBgActive(true) + + self.TxtNotice.transform.localPosition = self:GetBeginPos() + self.WaitTime = 0 + self.NeedReset = false + + self:RefreshNoticeContent() + + return false +end + +function XUiNoticeTips:OnEnable() + self.NeedReset = true + self.IsInit = true + + if self:ResetTxtNoticePos() then + self:Close() + end +end + +function XUiNoticeTips:Update() + if not self.IsInit then + return + end + + if self:ResetTxtNoticePos() then + self:Close() + return + end + + if XTool.UObjIsNil(self.TxtNotice) then + self:Close() + return + end + + local timeInterval = CS.UnityEngine.Time.deltaTime + if self.TxtNotice.transform.localPosition.x <= self:GetEndPos().x then + if HideIntervalTime <= XDataCenter.NoticeManager.GetTextNoticeScrollInterval() then + self:SetBgActive(false) + end + if self.PauseTime < XDataCenter.NoticeManager.GetTextNoticeScrollInterval() then + self.PauseTime = self.PauseTime + timeInterval + return + end + + self.NeedReset = true + self.PauseTime = 0 + end + + -- 公告刚出来静止一定时间再开始滚动 + if self.WaitTime < WaitTime then + self.WaitTime = self.WaitTime + timeInterval + return + end + + self.TxtNotice.transform.localPosition = self.TxtNotice.transform.localPosition - CS.UnityEngine.Vector3(timeInterval * MoveSpeed, 0, 0) +end + +function XUiNoticeTips:SetBgActive(flag) + self.ImgBg.gameObject:SetActive(flag) + self.BtnClose.gameObject:SetActive(flag) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiNoticeTips:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiNoticeTips:AutoInitUi() + self.PanelNotice = self.Transform:Find("SafeAreaContentPane/PanelNotice") + self.TxtNotice = self.Transform:Find("SafeAreaContentPane/PanelNotice/TxtNotice"):GetComponent("Text") + self.ImgBg = self.Transform:Find("SafeAreaContentPane/ImgBg"):GetComponent("Image") + self.BtnClose = self.Transform:Find("SafeAreaContentPane/BtnClose"):GetComponent("XUiButton") +end + +function XUiNoticeTips:AutoAddListener() + self.BtnClose.CallBack = function() self:OnBtnCloseClick() end +end +-- auto + +function XUiNoticeTips:OnBtnCloseClick() + XDataCenter.NoticeManager.ChangeTextNoticeHideCache() + if XDataCenter.NoticeManager.CheckTextNoticeHideCache() then + return + end + + self:Close() +end + +function XUiNoticeTips:OnDestroy() + if not XTool.UObjIsNil(self.behaviour) then + CS.UnityEngine.GameObject.Destroy(self.behaviour) + end + + self.behaviour = nil +end diff --git a/Resources/Scripts/XUi/XUiObtain/XUiGridCommon.lua b/Resources/Scripts/XUi/XUiObtain/XUiGridCommon.lua new file mode 100644 index 00000000..18c5af31 --- /dev/null +++ b/Resources/Scripts/XUi/XUiObtain/XUiGridCommon.lua @@ -0,0 +1,436 @@ +local type = type + +local CONDITION_COLOR = { + [true] = CS.UnityEngine.Color.black, + [false] = CS.UnityEngine.Color.red, +} + +XUiGridCommon = XClass(nil, "XUiGridCommon") +local XUiPanelNameplate = require("XUi/XUiNameplate/XUiPanelNameplate") +function XUiGridCommon:Ctor(rootUi, ui) + if not ui then + ui = rootUi + else + self.RootUi = rootUi + end + + self.GameObject = ui.gameObject + self.Transform = ui.transform + self:InitAutoScript() + self.TextCount = XUiHelper.TryGetComponent(self.Transform, "TextCount", nil) +end + +function XUiGridCommon:Init(rootUi) + self.RootUi = rootUi +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiGridCommon:InitAutoScript() + self:AutoInitUi() + XTool.InitUiObject(self) + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiGridCommon:AutoInitUi() + self.TxtCount = XUiHelper.TryGetComponent(self.Transform, "TxtCount", "Text") + if not self.TxtCount then self.TxtCount = XUiHelper.TryGetComponent(self.Transform, "PanelTxt/TxtCount", "Text") end -- 兼容不同grid结构 + self.TxtName = XUiHelper.TryGetComponent(self.Transform, "TxtName", "Text") + self.TxtHave = XUiHelper.TryGetComponent(self.Transform, "TxtHave", "Text") + if not self.TxtHave then self.TxtHave = XUiHelper.TryGetComponent(self.Transform, "PanelTxt/TxtHave", "Text") end -- 兼容不同grid结构 + self.ImgNew = XUiHelper.TryGetComponent(self.Transform, "ImgNew", "Image") + self.RImgIcon = XUiHelper.TryGetComponent(self.Transform, "RImgIcon", "RawImage") + self.HeadIconEffect = XUiHelper.TryGetComponent(self.Transform, "RImgIcon/Effect", "XUiEffectLayer") + self.ImgQuality = XUiHelper.TryGetComponent(self.Transform, "ImgQuality", "Image") + self.PanelSite = XUiHelper.TryGetComponent(self.Transform, "PanelSite", nil) + self.TxtSite = XUiHelper.TryGetComponent(self.Transform, "PanelSite/TxtSite", "Text") + self.BtnClick = XUiHelper.TryGetComponent(self.Transform, "BtnClick", "Button") + self.ImgUp = XUiHelper.TryGetComponent(self.Transform, "ImgUp", "Image") + self.ImgRail = XUiHelper.TryGetComponent(self.Transform, "ImgRail", "Image") + self.ImgReceived = XUiHelper.TryGetComponent(self.Transform, "ImgReceived", "Image") + self.ImgQualityTag = XUiHelper.TryGetComponent(self.Transform, "ImgQualityTag", "Image") + self.TxtStock = XUiHelper.TryGetComponent(self.Transform, "TxtStock", "Text") + self.ImgNone = XUiHelper.TryGetComponent(self.Transform, "ImgNone", nil) +end + +function XUiGridCommon:AutoAddListener() + XUiHelper.RegisterClickEvent(self, self.BtnClick, self.OnBtnClickClick) +end + +function XUiGridCommon:SetBtnNotClick(statue) + self.BtnNotClick = statue +end + +-- auto +function XUiGridCommon:OnBtnClickClick() + if self.Disable or self.BtnNotClick then + return + end + -- 匹配中 + if XDataCenter.FubenUnionKillRoomManager.IsMatching() then + return + end + + if self.GoodsShowParams.RewardType == XRewardManager.XRewardType.Character then + --从Tips的ui跳转需要关闭Tips的UI + if self.RootUi.Ui.UiData.UiType == CsXUiType.Tips then + self.RootUi:Close() + end + + -- 暂停自动弹窗 + XDataCenter.AutoWindowManager.StopAutoWindow() + XLuaUiManager.Open("UiCharacterDetail", self.TemplateId) + elseif self.GoodsShowParams.RewardType == XRewardManager.XRewardType.Equip then + XLuaUiManager.Open("UiEquipDetail", self.TemplateId, true) + --从Tips的ui跳转需要关闭Tips的UI + if self.RootUi.Ui.UiData.UiType == CsXUiType.Tips then + self.RootUi:Close() + end + + -- 暂停自动弹窗 + XDataCenter.AutoWindowManager.StopAutoWindow() + elseif self.GoodsShowParams.RewardType == XRewardManager.XRewardType.Furniture then + local cfg = XFurnitureConfigs.GetFurnitureReward(self.TemplateId) + local furnitureRewardId = self.TemplateId + local configId = cfg.FurnitureId + XLuaUiManager.Open("UiFurnitureDetail", self.Data.InstanceId, configId, furnitureRewardId, nil, true) + elseif self.GoodsShowParams.RewardType == XRewardManager.XRewardType.Fashion then + local buyData + if self.Data and self.Data.ItemCount and self.Data.ItemIcon and self.Data.BuyCallBack then + buyData = {} + local isHave, isLimitTime = XRewardManager.CheckRewardOwn(self.GoodsShowParams.RewardType, self.GoodsShowParams.TemplateId) + buyData.IsHave = isHave and not isLimitTime + buyData.ItemIcon = self.Data.ItemIcon + buyData.ItemCount = self.Data.ItemCount + buyData.BuyCallBack = self.Data.BuyCallBack + end + XLuaUiManager.Open("UiFashionDetail", self.TemplateId, false, buyData) + elseif self.GoodsShowParams.RewardType == XRewardManager.XRewardType.Partner then + --从Tips的ui跳转需要关闭Tips的UI + if self.RootUi.Ui.UiData.UiType == CsXUiType.Tips then + self.RootUi:Close() + end + -- 暂停自动弹窗 + XDataCenter.AutoWindowManager.StopAutoWindow() + + local partnerData = {Id = 0,TemplateId = self.TemplateId} + local partner = XDataCenter.PartnerManager.CreatePartnerEntityByPartnerData(partnerData, true) + XLuaUiManager.Open("UiPartnerPreview", partner) + + elseif XDataCenter.ItemManager.IsWeaponFashion(self.TemplateId) then + local weaponFashionId = XDataCenter.ItemManager.GetWeaponFashionId(self.TemplateId) + XLuaUiManager.Open("UiFashionDetail", weaponFashionId, true) + elseif self.GoodsShowParams.RewardType == XRewardManager.XRewardType.Nameplate then + XLuaUiManager.Open("UiNameplateTip", self.TemplateId, true, true) + else + XLuaUiManager.Open("UiTip", self.Data and self.Data or self.TemplateId, self.HideSkipBtn, self.RootUi.Name) + end +end + +function XUiGridCommon:SetUiActive(ui, active) + if not ui or not ui.gameObject then + return + end + + if ui.gameObject.activeSelf == active then + return + end + + ui.gameObject:SetActiveEx(active) +end + +function XUiGridCommon:ResetUi() + self:SetUiActive(self.TxtCount, false) + self:SetUiActive(self.TxtName, false) + self:SetUiActive(self.ImgNew, false) + self:SetUiActive(self.RImgIcon, false) + self:SetUiActive(self.ImgQuality, false) + self:SetUiActive(self.PanelSite, false) + self:SetUiActive(self.ImgUp, false) + self:SetUiActive(self.ImgRail, false) + self:SetUiActive(self.ImgReceived, false) + self:SetUiActive(self.ImgQualityTag, false) + self:SetUiActive(self.IconLevel, false) + self:SetUiActive(self.TxtHave, false) + self:SetUiActive(self.TxtStock, false) + self:SetUiActive(self.ImgNone, false) +end + +-- data支持数据结构: XEquipData XItemData XCharacterData +-- tags可包含: { ShowUp, ShowNew } +function XUiGridCommon:Refresh(data, params, isBigIcon, hideSkipBtn, curCount) + if XTool.UObjIsNil(self.GameObject) then + return + end + self.GameObject:SetActiveEx(data) + if not data then + return + end + + self:ResetUi() + + self.HideSkipBtn = hideSkipBtn + + local count, costCount + + if type(data) == "number" then + self.TemplateId = data + else + self.Data = data + self.TemplateId = (data.TemplateId and data.TemplateId > 0) and data.TemplateId or data.Id + count = data.Count + costCount = data.CostCount + end + + self.GoodsShowParams = XGoodsCommonManager.GetGoodsShowParamsByTemplateId(self.TemplateId) + + params = params or {} + + -- 名字 + if self.TxtName and self.GoodsShowParams.Name then + if self.GoodsShowParams.RewardType == XArrangeConfigs.Types.Character then + self.TxtName.text = self.GoodsShowParams.TradeName + else + self.TxtName.text = self.GoodsShowParams.Name + end + + self:SetUiActive(self.TxtName, true) + end + + -- 数量 + if self.TxtCount and count then + self.TxtCount.text = CS.XTextManager.GetText("ShopGridCommonCount", count) + self:SetUiActive(self.TxtCount, true) + end + + -- 可消耗数量 + if self.TxtHaveCount and count and self.TxtNeedCount and costCount then + self.TxtHaveCount.text = count + self.TxtNeedCount.text = "/" .. costCount + self.TxtHaveCount.color = CONDITION_COLOR[count >= costCount] + self:SetUiActive(self.TxtHaveCount, true) + self:SetUiActive(self.TxtNeedCount, true) + end + + -- 图标 + if self.RImgIcon then + local icon = self.GoodsShowParams.Icon + if isBigIcon and self.GoodsShowParams.BigIcon then + icon = self.GoodsShowParams.BigIcon + end + + if icon and #icon > 0 then + --self.RootUi:SetUiSprite(self.RImgIcon, icon) + self.RImgIcon:SetRawImage(icon) + self:SetUiActive(self.RImgIcon, true) + end + end + + -- 特效 + if self.HeadIconEffect then + local effect = self.GoodsShowParams.Effect + if effect then + self.HeadIconEffect.gameObject:LoadPrefab(effect) + self.HeadIconEffect.gameObject:SetActiveEx(true) + else + self.HeadIconEffect.gameObject:SetActiveEx(false) + end + end + + -- 品质底图 + if self.ImgQuality and self.GoodsShowParams.Quality then + local qualityIcon = self.GoodsShowParams.QualityIcon + + if qualityIcon then + self.RootUi:SetUiSprite(self.ImgQuality, qualityIcon) + else + XUiHelper.SetQualityIcon(self.RootUi, self.ImgQuality, self.SyncQuality or self.GoodsShowParams.Quality) + end + + self:SetUiActive(self.ImgQuality, true) + end + + -- 品质底图(大) + if self.ImgIconQuality and self.GoodsShowParams.Quality then + XUiHelper.SetQualityIcon(self.RootUi, self.ImgIconQuality, self.SyncQuality or self.GoodsShowParams.Quality) + self:SetUiActive(self.ImgQuality, true) + end + + -- 创世纪标签 + if self.ImgQualityTag and self.GoodsShowParams.QualityTag then + self:SetUiActive(self.ImgQualityTag, true) + end + + if self.GoodsShowParams.RewardType == XRewardManager.XRewardType.Equip then + -- 星数 + if self.PanelStars then + self:ShowStar(self.GoodsShowParams.Star, self.GoodsShowParams.Star) + end + -- + if self.PanelSite then + self:SetUiActive(self.PanelSite, self.GoodsShowParams.Site ~= XEquipConfig.EquipSite.Weapon) + self.TxtSite.text = "0" .. self.GoodsShowParams.Site + end + end + --铭牌 + if self.GoodsShowParams.RewardType == XRewardManager.XRewardType.Nameplate then + self:SetUiActive(self.ImgQuality, false) + self:SetUiActive(self.RImgIcon, false) + local BtnSiblingIndex = 0 + if self.BtnClick then + BtnSiblingIndex = self.BtnClick.transform:GetSiblingIndex() + end + + if not self.PanelNamePlate then + local prefab = self.GameObject:LoadPrefab(XMedalConfigs.XNameplatePanelPath) + prefab.transform:SetSiblingIndex(BtnSiblingIndex) + local rectTransform = prefab.transform:GetComponent("RectTransform") + if rectTransform then + rectTransform.anchorMax = CS.UnityEngine.Vector2(0.5, 0.5) + rectTransform.anchorMin = CS.UnityEngine.Vector2(0.5, 0.5) + rectTransform.anchoredPosition = CS.UnityEngine.Vector2(0, 15) + rectTransform.localScale = CS.UnityEngine.Vector3(0.8, 0.8, 0.8) + end + self.PanelNamePlate = XUiPanelNameplate.New(prefab, self.RootUi) + end + self.PanelNamePlate.GameObject:SetActiveEx(true) + self.PanelNamePlate:UpdateDataById(self.TemplateId) + else + if self.PanelNamePlate then + self.PanelNamePlate.GameObject:SetActiveEx(false) + else + local prefab = self.GameObject:LoadPrefab(XMedalConfigs.XNameplatePanelPath) + prefab.gameObject:SetActiveEx(false) + end + end + -- 特殊 : Params + -- Params.ShowUp + if self.ImgUp then + self:SetUiActive(self.ImgUp, params.ShowUp) + end + + -- Params.ShowNew + if self.ImgNew then + self:SetUiActive(self.ImgNew, params.ShowNew) + end + + -- Params.ShowReceived 已领取 + if self.ImgReceived then + self:SetUiActive(self.ImgReceived, params.ShowReceived) + end + + -- Params.Disable 不可点击 + self.Disable = params.Disable + + --特殊抽奖中奖品的剩余数 + if self.TxtStock then + if curCount then + self.TxtStock.text = CS.XTextManager.GetText("ResidueStockText", curCount) + self:SetUiActive(self.TxtStock, true) + end + self:SetUiActive(self.TxtName, false) + end + + --特殊抽奖中是否有库存的提示 + if self.ImgNone then + self:SetUiActive(self.ImgNone, curCount and curCount <= 0) + end + + --收藏品等级 + if self.IconLevel and self.GoodsShowParams.LevelIcon then + local levelIcon = self.SyncLevelIcon or self.GoodsShowParams.LevelIcon + if levelIcon then + self.RootUi:SetUiSprite(self.IconLevel, levelIcon) + self:SetUiActive(self.IconLevel, true) + end + end + + --是否已拥有 + if self.TxtHave then + local isHave, isLimitTime = XRewardManager.CheckRewardOwn(self.GoodsShowParams.RewardType, self.GoodsShowParams.TemplateId) + local isShowTextHave = isHave and not isLimitTime + self:SetUiActive(self.TxtHave, isShowTextHave) + self:SetUiActive(self.TxtCount, not isShowTextHave) + end + + --清除临时的同步数据 + self:ClearSynData() +end + +function XUiGridCommon:ShowCount(show) + if (self.TxtCount) then + self.TxtCount.gameObject:SetActiveEx(show) + end + if self.TextCount then + self.TextCount.gameObject:SetActiveEx(show) + end +end + +function XUiGridCommon:ShowStar(count, max) + local showStar = max > 0 + self.PanelStars.gameObject:SetActiveEx(showStar) + + if not showStar then + return + end + + for i = 1, 6 do + local starPanel = self["PanelStar" .. i] + if starPanel then + starPanel.gameObject:SetActiveEx(i <= max) + end + + local imgStar = self["ImgStar" .. i] + if imgStar then + imgStar.gameObject:SetActiveEx(i <= count) + end + end +end + +function XUiGridCommon:SetReceived(isReceive) + if self.ImgReceived then + self:SetUiActive(self.ImgReceived, isReceive) + end +end + +function XUiGridCommon:SetShowUp(isShow) + if self.ImgUp then + self:SetUiActive(self.ImgUp, isShow) + end +end + +function XUiGridCommon:SetUpText(text) + if self.UpText then + self.UpText.text = text + end +end + +function XUiGridCommon:SetUpImg(img) + if self.ImgUp then + self.ImgUp:SetRawImage(img) + end +end + +function XUiGridCommon:SetClickCallback(callback) + XUiHelper.RegisterClickEvent(self, self.BtnClick, callback, true) +end + +function XUiGridCommon:SetSyncQuality(quality) + self.SyncQuality = quality +end + +function XUiGridCommon:SetSyncLevelIcon(levelIcon) + self.SyncLevelIcon = levelIcon +end + +function XUiGridCommon:ClearSynData() + self.SyncQuality = nil + self.SyncLevelIcon = nil +end + +function XUiGridCommon:GetQuality() + return self.GoodsShowParams.Quality +end + +return XUiGridCommon \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiObtain/XUiObtain.lua b/Resources/Scripts/XUi/XUiObtain/XUiObtain.lua new file mode 100644 index 00000000..991ef38a --- /dev/null +++ b/Resources/Scripts/XUi/XUiObtain/XUiObtain.lua @@ -0,0 +1,140 @@ +local XUiObtain = XLuaUiManager.Register(XLuaUi, "UiObtain") + +-- auto +-- Automatic generation of code, forbid to edit +function XUiObtain:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiObtain:AutoInitUi() + self.ScrView = self.Transform:Find("SafeAreaContentPane/ScrView"):GetComponent("Scrollbar") + self.PanelContent = self.Transform:Find("SafeAreaContentPane/ScrView/Viewport/PanelContent") + self.GridCommon = self.Transform:Find("SafeAreaContentPane/ScrView/Viewport/PanelContent/GridCommon") + self.BtnBack = self.Transform:Find("SafeAreaContentPane/BtnBack"):GetComponent("Button") + self.TxtTitle = self.Transform:Find("SafeAreaContentPane/GameObject/TxtTitle1"):GetComponent("Text") + self.BtnCancel = self.Transform:Find("SafeAreaContentPane/BtnCancel"):GetComponent("Button") + self.BtnSure = self.Transform:Find("SafeAreaContentPane/BtnSure"):GetComponent("Button") +end + +function XUiObtain:GetAutoKey(uiNode, eventName) + if not uiNode then + return + end + return eventName .. uiNode:GetHashCode() +end + +function XUiObtain:AutoAddListener() + self.AutoCreateListeners = {} + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnCancel, self.OnBtnCancelClick) + self:RegisterClickEvent(self.BtnSure, self.OnBtnSureClick) +end +-- auto +--初始化音效 +function XUiObtain:InitBtnSound() + self.SpecialSoundMap[self:GetAutoKey(self.BtnBack, "onClick")] = XSoundManager.UiBasicsMusic.Return + self.SpecialSoundMap[self:GetAutoKey(self.BtnCancel, "onClick")] = XSoundManager.UiBasicsMusic.Return + self.SpecialSoundMap[self:GetAutoKey(self.BtnSure, "onClick")] = XSoundManager.UiBasicsMusic.Confirm +end + +function XUiObtain:OnBtnCancelClick() + self:Close() + if self.CancelCallback then + self.CancelCallback() + end + self:CheckItemOverLimit() +end + +function XUiObtain:OnBtnSureClick() + self:Close() + if self.OkCallback then + self.OkCallback() + end + self:CheckItemOverLimit() +end + +function XUiObtain:OnBtnBackClick() + self:Close() + if self.CancelCallback then + self.CancelCallback() + end + self:CheckItemOverLimit() +end + +function XUiObtain:CheckItemOverLimit() + --XUiManager.TipMsg(CS.XTextManager.GetText("ItemOverLimit")) +end + +function XUiObtain:OnAwake() + self:InitAutoScript() + self:InitBtnSound() +end + +function XUiObtain:OnStart(rewardGoodsList, title, closeCb, sureCb) + self.Items = {} + self.GridCommon.gameObject:SetActive(false) + self.CancelBtnPosX = self.BtnCancel.transform.localPosition.x + self.SureBtnPosX = self.BtnSure.transform.localPosition.x + if title then + self.TxtTitle.text = title + end + self.OkCallback = sureCb + self.CancelCallback = closeCb + self:Refresh(rewardGoodsList) + self:Layout() + + self:CheckIsTimelimitGood(rewardGoodsList) + self:PlayAnimation("AniObtain") +end + +function XUiObtain:OnEnable() + CS.XAudioManager.PlaySound(XSoundManager.UiBasicsMusic.Common_UiObtain) +end + +function XUiObtain:Layout() + self.BtnSure.gameObject:SetActive(false) + self.BtnCancel.gameObject:SetActive(false) + local CancelBtnPosY = self.BtnCancel.transform.localPosition.y + local SureBtnPosY = self.BtnSure.transform.localPosition.y + + if self.OkCallback and self.CancelCallback then + self.BtnSure.gameObject:SetActive(true) + self.BtnCancel.gameObject:SetActive(true) + self.BtnCancel.transform.localPosition = CS.UnityEngine.Vector3(self.CancelBtnPosX, CancelBtnPosY, 0) + self.BtnSure.transform.localPosition = CS.UnityEngine.Vector3(self.SureBtnPosX, SureBtnPosY, 0) + elseif self.OkCallback then + self.BtnSure.gameObject:SetActive(true) + self.BtnSure.transform.localPosition = CS.UnityEngine.Vector3(0, SureBtnPosY, 0) + elseif self.CancelCallback then + self.BtnCancel.gameObject:SetActive(true) + self.BtnCancel.transform.localPosition = CS.UnityEngine.Vector3(0, CancelBtnPosY, 0) + end +end + +function XUiObtain:Refresh(rewardGoodsList) + rewardGoodsList = XRewardManager.MergeAndSortRewardGoodsList(rewardGoodsList) + XUiHelper.CreateTemplates(self, self.Items, rewardGoodsList, XUiGridCommon.New, self.GridCommon, self.PanelContent, function(grid, data) + grid:Refresh(data, nil, nil, false) + if data.RewardType == XRewardManager.XRewardType.Nameplate then + if grid.PanelNamePlate then -- 特殊处理尺寸 + grid.PanelNamePlate.Transform.localScale = CS.UnityEngine.Vector3(1.6, 1.6, 1.6); + end + end + end) +end + +function XUiObtain:CheckIsTimelimitGood(rewardGoodsList) + for _, good in pairs(rewardGoodsList) do + if XArrangeConfigs.GetType(good.TemplateId) == XArrangeConfigs.Types.Item then -- 是道具 + local itemData = XDataCenter.ItemManager.GetItemTemplate(good.TemplateId) + if itemData.SubTypeParams[1] and XArrangeConfigs.GetType(itemData.SubTypeParams[1]) == XArrangeConfigs.Types.WeaponFashion then -- 对应武器涂装 + if itemData.SubTypeParams[2] and itemData.SubTypeParams[2] > 0 then + XUiManager.TipMsg(CS.XTextManager.GetText("WeaponFashionLimitGetInBag", itemData.Name,XUiHelper.GetTime(itemData.SubTypeParams[2], XUiHelper.TimeFormatType.ACTIVITY))) + break + end + end + end + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiOnLineTranscript/XUiOnLineMatching.lua b/Resources/Scripts/XUi/XUiOnLineTranscript/XUiOnLineMatching.lua new file mode 100644 index 00000000..f467c885 --- /dev/null +++ b/Resources/Scripts/XUi/XUiOnLineTranscript/XUiOnLineMatching.lua @@ -0,0 +1,148 @@ +local XUiOnLineMatching = XLuaUiManager.Register(XLuaUi, "UiOnLineMatching") + +function XUiOnLineMatching:OnAwake() + +end + +function XUiOnLineMatching:OnStart(cfgData) + self:InitAutoScript() + self.CsUiList = {} + self.CfgData = cfgData + self.timerId = -1 + self:StartMatching() + XEventManager.AddEventListener(XEventId.EVENT_ROOM_ENTER_ROOM, self.OnBack, self) + XEventManager.AddEventListener(XEventId.EVENT_ROOM_CANCEL_MATCH, self.OnCancelMatch, self) +end + +function XUiOnLineMatching:OnDestroy() + self:RemoveTimer()--移除计时器 + XEventManager.RemoveEventListener(XEventId.EVENT_ROOM_ENTER_ROOM, self.OnBack, self) + XEventManager.RemoveEventListener(XEventId.EVENT_ROOM_CANCEL_MATCH, self.OnCancelMatch, self) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiOnLineMatching:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiOnLineMatching:AutoInitUi() + self.PanelMatchingNormal = self.Transform:Find("SafeAreaContentPane/PanelMatchingNormal") + self.BtnBack = self.Transform:Find("SafeAreaContentPane/PanelMatchingNormal/BtnBack"):GetComponent("Button") + self.TxtTime = self.Transform:Find("SafeAreaContentPane/PanelMatchingNormal/TxtTime"):GetComponent("Text") + self.PanelMatchingSimplified = self.Transform:Find("SafeAreaContentPane/PanelMatchingSimplified") +end + +function XUiOnLineMatching:GetAutoKey(uiNode, eventName) + if not uiNode then + return + end + return eventName .. uiNode:GetHashCode() +end + +function XUiOnLineMatching:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then + return + end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiOnLineMatching:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiOnLineMatching:AutoAddListener() + self.AutoCreateListeners = {} + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnReturn, self.OnBtnReturnClick) +end +-- auto +function XUiOnLineMatching:OnBtnBackClick() + --取消匹配 + XDataCenter.RoomManager.CancelMatch() +end + +function XUiOnLineMatching:OnCancelMatch() + -- self:SetIsShow(false) + self:Close() +end + +function XUiOnLineMatching:OnBtnReturnClick() + if self.characterUi ~= nil then + self.characterUi:OnBtnBackClick() + self.characterUi.GameObject:SetActive(false) + end + if self.bagUi ~= nil then + self.bagUi:OnBtnBackClick() + self.bagUi.GameObject:SetActive(false) + end + self:SetSimplifiedPanelView(false) +end + +function XUiOnLineMatching:OnBack() + self:Close() +end + +function XUiOnLineMatching:SetIsShow(code) + if self.GameObject ~= nil then + self.GameObject.gameObject:SetActive(code) + end + self:SetSimplifiedPanelView(false) +end + +function XUiOnLineMatching:SetSimplifiedPanelView(code) + if self.PanelMatchingNormal == nil or self.PanelMatchingSimplified == nil then + return + end + self.PanelMatchingSimplified.gameObject:SetActive(code) + self.PanelMatchingNormal.gameObject:SetActive(not code) +end + +function XUiOnLineMatching:RemoveTimer() + if self.timerId ~= -1 then + XScheduleManager.UnSchedule(self.timerId) + self.timerId = -1 + end +end + +function XUiOnLineMatching:StartCountDown() + --倒计时开始 + self.TxtTime.text = "00:00" + local startTicks = CS.XTimerManager.Ticks + local refresh = function() + if not XDataCenter.RoomManager.Matching then + self:OnBack() + return + end + local t = math.floor((CS.XTimerManager.Ticks - startTicks) / CS.System.TimeSpan.TicksPerSecond) + local m = math.floor(t / 60) + local s = math.floor(t - m * 60) + local formatTime = string.format("%02d:%02d", m, s) + self.TxtTime.text = formatTime + -- self.TxtTimeSimplified.text = formatTime + end + self.timerId = XScheduleManager.ScheduleForever(refresh, 0) +end + +function XUiOnLineMatching:StartMatching() + self:StartCountDown() + self:SetIsShow(true) +end + +return XUiOnLineMatching \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiOnLineTranscript/XUiOnLineTranscript.lua b/Resources/Scripts/XUi/XUiOnLineTranscript/XUiOnLineTranscript.lua new file mode 100644 index 00000000..5a6f96f7 --- /dev/null +++ b/Resources/Scripts/XUi/XUiOnLineTranscript/XUiOnLineTranscript.lua @@ -0,0 +1,242 @@ +-- local XUiOnLineTranscript = XUiManager.Register("UiOnLineTranscript") +local XUiOnLineTranscript = XLuaUiManager.Register(XLuaUi, "UiOnLineTranscript") + +function XUiOnLineTranscript:OnAwake() + self:InitAutoScript() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) +end + +function XUiOnLineTranscript:OnStart(stage) + self.CreateObjectList = {} + self.GridList = {} + self:Refresh(stage) + XEventManager.AddEventListener(XEventId.EVENT_ROOM_ENTER_ROOM, self.CloseSelf, self) + XEventManager.AddEventListener(XEventId.EVENT_ROOM_CANCEL_MATCH, self.OnCancelMatch, self) +end + +function XUiOnLineTranscript:OnDestroy() + XEventManager.RemoveEventListener(XEventId.EVENT_ROOM_ENTER_ROOM, self.CloseSelf, self) + XEventManager.RemoveEventListener(XEventId.EVENT_ROOM_CANCEL_MATCH, self.OnCancelMatch, self) +end + +function XUiOnLineTranscript:OnCancelMatch() + self:SetIsMatchingStatus(false) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiOnLineTranscript:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiOnLineTranscript:AutoInitUi() + self.BtnClose = self.Transform:Find("SafeAreaContentPane/BtnClose"):GetComponent("Button") + self.PanelAsset = self.Transform:Find("SafeAreaContentPane/PanelAsset") + self.PanelDesc = self.Transform:Find("SafeAreaContentPane/PanelDesc") + self.TxtTitle = self.Transform:Find("SafeAreaContentPane/PanelDesc/TxtTitle"):GetComponent("Text") + self.TxtChallengesTimes = self.Transform:Find("SafeAreaContentPane/PanelDesc/PanelChallengeTimes/TxtChallengeTimes"):GetComponent("Text") + self.TxtMaxChallengesTimes = self.Transform:Find("SafeAreaContentPane/PanelDesc/PanelChallengeTimes/TxtMaxChallengeTimes"):GetComponent("Text") + self.BtnBuyChallengeTimes = self.Transform:Find("SafeAreaContentPane/PanelDesc/PanelChallengeTimes/BtnBuyChallengeTimes"):GetComponent("Button") + self.PanelChallengeTimes = self.Transform:Find("SafeAreaContentPane/PanelDesc/PanelChallengeTimes") + self.TxtLevelVal = self.Transform:Find("SafeAreaContentPane/PanelDesc/TxtLevelVal"):GetComponent("Text") + self.TxtPeople = self.Transform:Find("SafeAreaContentPane/PanelBottom/TxtPeople"):GetComponent("Text") + self.ImgNandu = self.Transform:Find("SafeAreaContentPane/PanelDesc/ImgNandu"):GetComponent("Image") + self.TxtDesc = self.Transform:Find("SafeAreaContentPane/PanelDesc/TxtDesc"):GetComponent("Text") + self.PanelLineupTips = self.Transform:Find("SafeAreaContentPane/PanelLineupTips") + self.PanelDesItem = self.Transform:Find("SafeAreaContentPane/PanelLineupTips/PanelDesItem") + self.TxtDes = self.Transform:Find("SafeAreaContentPane/PanelLineupTips/PanelDesItem/TxtDes"):GetComponent("Text") + self.PanelDropList = self.Transform:Find("SafeAreaContentPane/PanelDropList") + self.PanelDrop = self.Transform:Find("SafeAreaContentPane/PanelDropList/PanelDrop") + self.TxtDrop = self.Transform:Find("SafeAreaContentPane/PanelDropList/PanelDrop/TxtDrop"):GetComponent("Text") + self.TxtDropEn = self.Transform:Find("SafeAreaContentPane/PanelDropList/PanelDrop/TxtDropEn"):GetComponent("Text") + self.TxtFirstDrop = self.Transform:Find("SafeAreaContentPane/PanelDropList/PanelDrop/TxtFirstDrop"):GetComponent("Text") + self.PanelDropContent = self.Transform:Find("SafeAreaContentPane/PanelDropList/DropList/Viewport/PanelDropContent") + self.GridCommon = self.Transform:Find("SafeAreaContentPane/PanelDropList/DropList/Viewport/PanelDropContent/GridCommon") + + self.PanelBottom = self.Transform:Find("SafeAreaContentPane/PanelBottom") + self.TxtATNums = self.Transform:Find("SafeAreaContentPane/PanelBottom/TxtATNums"):GetComponent("Text") + self.BtnMatch = self.Transform:Find("SafeAreaContentPane/PanelBottom/BtnMatch"):GetComponent("Button") + self.BtnMatching = self.Transform:Find("SafeAreaContentPane/PanelBottom/BtnMatching"):GetComponent("Button") + self.BtnCreateRoom = self.Transform:Find("SafeAreaContentPane/PanelBottom/BtnCreateRoom"):GetComponent("Button") + self.BtnNotCreateRoom = self.Transform:Find("SafeAreaContentPane/PanelBottom/BtnNotCreateRoom"):GetComponent("Button") +end + +function XUiOnLineTranscript:GetAutoKey(uiNode, eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiOnLineTranscript:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiOnLineTranscript:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiOnLineTranscript:AutoAddListener() + self.AutoCreateListeners = {} + self:RegisterClickEvent(self.BtnClose, self.OnBtnCloseClick) + self:RegisterClickEvent(self.BtnMatch, self.OnBtnMatchClick) + self:RegisterClickEvent(self.BtnCreateRoom, self.OnBtnCreateRoomClick) + self:RegisterClickEvent(self.BtnBuyChallengeTimes, self.OnBtnBuyChallengeTimesClick) +end +-- auto +function XUiOnLineTranscript:OnBtnCloseClick() + if XDataCenter.RoomManager.Matching then + local title = CS.XTextManager.GetText("TipTitle") + local cancelMatchMsg = CS.XTextManager.GetText("OnlineInstanceQuitRoom") + XUiManager.DialogTip(title, cancelMatchMsg, XUiManager.DialogType.Normal, nil, function() + XDataCenter.RoomManager.CancelMatch(function() + self.CloseSelf() + end) + end) + else + self:CloseSelf() + end +end + +function XUiOnLineTranscript:CloseSelf() + self:Close() + CsXGameEventManager.Instance:Notify(XEventId.EVENT_FUBEN_CLOSE_FUBENSTAGEDETAIL) +end + +function XUiOnLineTranscript:OnBtnMatchClick() + if XDataCenter.RoomManager.Matching then + return + end + XDataCenter.FubenManager.RequestMatchRoom(self.Stage, function() + --匹配房间 + if XDataCenter.RoomManager.Matching then + XLuaUiManager.Open("UiOnLineMatching", self.Stage) + end + end) +end + +function XUiOnLineTranscript:OnBtnCreateRoomClick() + if XDataCenter.RoomManager.Matching then + return + end + self:CloseSelf() + XDataCenter.FubenManager.RequestCreateRoom(self.Stage) +end + +function XUiOnLineTranscript:OnBtnBuyChallengeTimesClick() + --@TODO buy challenge times + --XUiManager.OpenBuyAssetPanel(XDataCenter.ItemManager.ItemId.DailyActiveness, function() self:Refresh() end) +end + +function XUiOnLineTranscript:ResetOriStatus()--重置原始状态 + self:SetIsMatchingStatus(false) + self.GridCommon.gameObject:SetActive(false) +end + +function XUiOnLineTranscript:SetIsMatchingStatus(actived) + self.BtnMatching.gameObject:SetActive(actived) + self.BtnNotCreateRoom.gameObject:SetActive(actived) + self.BtnMatch.gameObject:SetActive(not actived) + self.BtnCreateRoom.gameObject:SetActive(not actived) +end + +function XUiOnLineTranscript:Refresh(stage) + self:ResetOriStatus() + self.Stage = stage + self.TxtTitle.text = stage.Name + self.TxtDesc.text = stage.Description + self.TxtLevelVal.text = stage.RequireLevel + self.TxtATNums.text = stage.RequireActionPoint + local leastPlayer = stage.OnlinePlayerLeast <= 0 and 1 or stage.OnlinePlayerLeast + self.TxtPeople.text = leastPlayer + + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stage.StageId) + local sectionCfg = XDataCenter.FubenDailyManager.GetDailySection(stageInfo.DailySectionId) + local sectionData = XDataCenter.FubenDailyManager.GetDailySectionData(stageInfo.DailySectionId) + if sectionCfg then + local fightNum = sectionData and sectionData.PassTimesToday or 0 + local rewardNeedFinishCount = sectionCfg.RewardNeedFinishCount or 0 + if fightNum > rewardNeedFinishCount then + fightNum = rewardNeedFinishCount + end + self.TxtChallengesTimes.text = rewardNeedFinishCount - fightNum + self.TxtMaxChallengesTimes.text = '/' .. rewardNeedFinishCount + self.BtnBuyChallengeTimes.gameObject:SetActive(false) + else + self.PanelChallengeTimes.gameObject:SetActive(false) + end + + self:UpdateRewards() +end + +function XUiOnLineTranscript:UpdateRewards() + local stage = self.Stage + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stage.StageId) + + -- 是否首通奖励显示 + local firstDrop = false + if not stageInfo.Passed then + local cfg = XDataCenter.FubenManager.GetStageLevelControl(self.Stage.StageId) + if cfg and cfg.FirstRewardShow > 0 or self.Stage.FirstRewardShow > 0 then + firstDrop = true + end + end + self.TxtFirstDrop.gameObject:SetActive(firstDrop) + self.TxtDrop.gameObject:SetActive(not firstDrop) + + -- 获取显示奖励Id + local rewardId = 0 + local IsFirst = false + local cfg = XDataCenter.FubenManager.GetStageLevelControl(stage.StageId) + if not stageInfo.Passed then + rewardId = cfg and cfg.FirstRewardShow or stage.FirstRewardShow + if cfg and cfg.FirstRewardShow > 0 or stage.FirstRewardShow > 0 then + IsFirst = true + end + end + if rewardId == 0 then + rewardId = cfg and cfg.FinishRewardShow or stage.FinishRewardShow + end + if rewardId == 0 then + for j = 1, #self.GridList do + self.GridList[j].GameObject:SetActive(false) + end + return + end + + local rewards = IsFirst and XRewardManager.GetRewardList(rewardId) or XRewardManager.GetRewardListNotCount(rewardId) + for i, item in ipairs(rewards) do + local grid + if self.GridList[i] then + grid = self.GridList[i] + else + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommon) + grid = XUiGridCommon.New(self, ui) + grid.Transform:SetParent(self.PanelDropContent, false) + self.GridList[i] = grid + end + grid:Refresh(item) + grid.GameObject:SetActive(true) + end + + for j = 1, #self.GridList do + if j > #rewards then + self.GridList[j].GameObject:SetActive(false) + end + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiOnlineBoss/UiOnlineBossActivity.lua b/Resources/Scripts/XUi/XUiOnlineBoss/UiOnlineBossActivity.lua new file mode 100644 index 00000000..6666eaab --- /dev/null +++ b/Resources/Scripts/XUi/XUiOnlineBoss/UiOnlineBossActivity.lua @@ -0,0 +1,2 @@ +local XUiOnlineBoss = require("XUi/XUiOnlineBoss/XUiOnlineBoss") +local XUiOnlineBossActivity = XLuaUiManager.Register(XUiOnlineBoss, "UiOnlineBossActivity") \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiOnlineBoss/XUiGridOnlineBossTask.lua b/Resources/Scripts/XUi/XUiOnlineBoss/XUiGridOnlineBossTask.lua new file mode 100644 index 00000000..3f2e1c44 --- /dev/null +++ b/Resources/Scripts/XUi/XUiOnlineBoss/XUiGridOnlineBossTask.lua @@ -0,0 +1,55 @@ +local XUiGridOnlineBossTask = XClass(nil, "XUiGridOnlineBossTask") + +function XUiGridOnlineBossTask:Ctor(ui, rootUi) + self.GameObject = ui.GameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + self.BtnFinish.CallBack = function() + self:OnBtnFinishClick() + end +end + +function XUiGridOnlineBossTask:Refresh(taskData, preTaskData) + self.TaskData = taskData or self.TaskData + self.PreTaskData = preTaskData or self.PreTaskData + + local lastTaskTargetCount + if self.PreTaskData == nil then + lastTaskTargetCount = 0 + else + local preTaskCfg = XTaskConfig.GetTaskConfigById(self.PreTaskData.Id) + lastTaskTargetCount = preTaskCfg.Result + end + + local taskCfg = XTaskConfig.GetTaskConfigById(self.TaskData.Id) + + for _, scheduleCfg in pairs(self.TaskData.Schedule) do + if scheduleCfg.Value > lastTaskTargetCount then + self.Scrollbar.size = (scheduleCfg.Value - lastTaskTargetCount) / (taskCfg.Result - lastTaskTargetCount) + end + end + + local isAchieved = XDataCenter.TaskManager.CheckTaskAchieved(self.TaskData.Id) + local isFinished = XDataCenter.TaskManager.CheckTaskFinished(self.TaskData.Id) + + self.PanelEffect.gameObject:SetActiveEx(isAchieved) + self.BtnFinish.gameObject:SetActiveEx(isAchieved) + self.PanelFinish.gameObject:SetActiveEx(isFinished) + + self.TxtNum.text = taskCfg.Result + + local rewards = XRewardManager.GetRewardList(taskCfg.RewardId) + self.ItemCommon = XUiGridCommon.New(self.RootUi, self.GiftItem) + self.ItemCommon:Refresh(rewards[1]) +end + +function XUiGridOnlineBossTask:OnBtnFinishClick() + XDataCenter.TaskManager.FinishTask(self.TaskData.Id, function(rewards) + XUiManager.OpenUiObtain(rewards, nil, function(...) + self:Refresh() + end, nil) + end) +end + +return XUiGridOnlineBossTask \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiOnlineBoss/XUiOnlineBoss.lua b/Resources/Scripts/XUi/XUiOnlineBoss/XUiOnlineBoss.lua new file mode 100644 index 00000000..1f227c36 --- /dev/null +++ b/Resources/Scripts/XUi/XUiOnlineBoss/XUiOnlineBoss.lua @@ -0,0 +1,500 @@ +local XUiGridOnlineBossTask = require("XUi/XUiOnlineBoss/XUiGridOnlineBossTask") +local XUiOnlineBoss = XLuaUiManager.Register(XLuaUi, "UiOnlineBoss") + +local UiState = { + Enter = 1, + Match = 2, + Info = 3, + NewBoss = 4, +} + +local TaskCount = 3 + +function XUiOnlineBoss:OnAwake() + local root = self.UiModelGo.transform + self.SceneCase = root:FindTransform("SceneCase") + self.PanelModel = root:FindTransform("PanelModel") + self.UiCamFarMain = root:FindTransform("UiCamFarMain") or root:FindTransform("UiCamFarMainActivity") + self.UiCamFarPanelMatch = root:FindTransform("UiCamFarPanelMatch") or root:FindTransform("UiCamFarPanelMatchActivity") + self.UiCamFarBossInfo = root:FindTransform("UiCamFarBossInfo") or root:FindTransform("UiCamFarBossInfoActivity") + self.UiCamNearMain = root:FindTransform("UiCamNearMain") or root:FindTransform("UiCamNearMainActivity") + self.UiCamNearPanelMatch = root:FindTransform("UiCamNearPanelMatch") or root:FindTransform("UiCamNearPanelMatchActivity") + self.UiCamNearBossInfo = root:FindTransform("UiCamNearBossInfo") or root:FindTransform("UiCamNearBossInfoActivity") + self.UiCamNearFirst = root:FindTransform("UiCamNearFirstActivity") + self.ImgEffectHuanren = root:FindTransform("ImgEffectHuanren") + -- self.TextTypewriter = self.TxtAutoInvade:GetComponent("TextTypewriter") + self.TaskList = {} +end + +function XUiOnlineBoss:OnStart(selectIdx, isFirst) + self.ScenePool = {} + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self.MatchPanel = XUiPanelMatch.New(self.PanelMatch, self) + self.BossInfoPanel = XUiPanelBossInfo.New(self.PanelBossInfo) + + self.UiState = isFirst and UiState.NewBoss or UiState.Enter + self.GameObjectGroup = { + [UiState.Enter] = { + self.PanelEnter.gameObject, + self.UiCamFarMain.gameObject, + self.UiCamNearMain.gameObject, + }, + [UiState.Match] = { + self.PanelMatch.gameObject, + self.UiCamFarPanelMatch.gameObject, + self.UiCamNearPanelMatch.gameObject, + }, + [UiState.Info] = { + self.PanelBossInfo.gameObject, + self.UiCamFarBossInfo.gameObject, + self.UiCamNearBossInfo.gameObject, + }, + } + if self.Name == "UiOnlineBossActivity" then + self.GameObjectGroup[UiState.NewBoss] = { + self.PanelEnter.gameObject, + self.UiCamFarMain.gameObject, + self.UiCamNearFirst.gameObject, + } + end + + self.TabList = { + self.BtnTog0, + self.BtnTog1, + self.BtnTog2, + self.BtnTog3, + self.BtnTog4, + } + + self.DifficultMap = { + XDataCenter.FubenBossOnlineManager.OnlineBossDifficultLevel.SIMPLE, + XDataCenter.FubenBossOnlineManager.OnlineBossDifficultLevel.NORMAL, + XDataCenter.FubenBossOnlineManager.OnlineBossDifficultLevel.HARD, + XDataCenter.FubenBossOnlineManager.OnlineBossDifficultLevel.HELL, + XDataCenter.FubenBossOnlineManager.OnlineBossDifficultLevel.NightMare, + } + + self:SetDifficult(self.DifficultMap[1]) + + self.TabPanel:Init(self.TabList, handler(self, self.OnSelectTab), 1) + if XDataCenter.FubenBossOnlineManager.CheckOnlineBossUnlock(self.DifficultMap[1]) then + self.TabPanel:SelectIndex(selectIdx or 1) + end + self.DefaultIndex = selectIdx + self.IsOnStart = true + self.CurAnimator = nil + self:InitModel() + self:InitPanelInvade() + self:SwitchState(self.UiState) + self:StartTimer() + + self:RegisterClickEvent(self.BtnStart, self.OnBtnStartClick) + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:RegisterClickEvent(self.BtnInvade, self.OnBtnInvadeClick) + + XEventManager.AddEventListener(XEventId.EVENT_ROOM_CANCEL_MATCH, self.OnCancelMatch, self) + XEventManager.AddEventListener(XEventId.EVENT_ROOM_ENTER_ROOM, self.EnterRoom, self) + XEventManager.AddEventListener(XEventId.EVENT_ONLINEBOSS_UPDATE, self.OnBossUpdate, self) + XEventManager.AddEventListener(XEventId.EVENT_ONLINEBOSS_REFRESH, self.OnBossRefresh, self) +end + +function XUiOnlineBoss:OnEnable() + XDataCenter.FubenBossOnlineManager.RefreshBossData() + self:RefreshBtnList() + if self.CurAnimator and self.SectionTemplate then + self.CurAnimator:Play(self.SectionTemplate.Animation) + end + + self:RefreshPassNumInfo() + + if self.UiState == UiState.Match then + self.MatchPanel:Refresh() + self.PanelMatchEnable:PlayTimelineAnimation() + elseif self.UiState == UiState.NewBoss then + self.PanelTip.gameObject:SetActive(true) + CS.XAudioManager.PlaySound(1105) + self.TipEnable:PlayTimelineAnimation(function () + if not self.GameObject or not self.GameObject:Exist() then + return + end + CS.XAudioManager.PlaySound(1106) + self:SwitchState(UiState.Enter) + self.EnterFirst:PlayTimelineAnimation() + self.PanelTip.gameObject:SetActive(true) + XScheduleManager.ScheduleOnce(function() + if not self.GameObject or not self.GameObject:Exist() then + return + end + CS.XAudioManager.PlaySound(1107) + end, 1500) + end) + elseif self.UiState == UiState.Enter then + if self.Name == "UiOnlineBossActivity" then + -- CS.XAudioManager.PlaySound(1107) + self.EnterEnable:PlayTimelineAnimation() + end + end +end + +function XUiOnlineBoss:OnDestroy() + self:StopTimer() + XEventManager.RemoveEventListener(XEventId.EVENT_ROOM_CANCEL_MATCH, self.OnCancelMatch, self) + XEventManager.RemoveEventListener(XEventId.EVENT_ROOM_ENTER_ROOM, self.EnterRoom, self) + XEventManager.RemoveEventListener(XEventId.EVENT_ONLINEBOSS_UPDATE, self.OnBossUpdate, self) + XEventManager.RemoveEventListener(XEventId.EVENT_ONLINEBOSS_REFRESH, self.OnBossRefresh, self) +end + +function XUiOnlineBoss:OnNotify(evt, ...) + if evt == CS.XEventId.EVENT_UI_ALLOWOPERATE then + if self.NeedClose then + self:Close() + end + end +end + +function XUiOnlineBoss:OnGetEvents() + return { CS.XEventId.EVENT_UI_ALLOWOPERATE } +end + +function XUiOnlineBoss:UseLastTemplate() + return XDataCenter.FubenBossOnlineManager.GetIsActivity() and not XDataCenter.FubenBossOnlineManager.CheckIsInvade() +end + +function XUiOnlineBoss:InitPanelInvade() + if self:UseLastTemplate() then + self.PanelInvade.gameObject:SetActive(true) + else + self.PanelInvade.gameObject:SetActive(false) + end +end + +function XUiOnlineBoss:OnSelectTab(index) + local diff = self.DifficultMap[index] + if XDataCenter.FubenBossOnlineManager.CheckOnlineBossUnlock(diff, true) and self.CurDifficult ~= diff then + self:SetDifficult(diff) + self:RefreshModel() + self:RefreshName() + self:RefreshRisk() + self:PlayAnimation("QieHuan") + end +end + +--刷新通关次数以及进度 +function XUiOnlineBoss:RefreshPassNumInfo() + --获取所有任务数据 + local allOnlineTask = XDataCenter.TaskManager.GetBossOnlineTaskListData() + for i = 1, #allOnlineTask do + local currentProxy = self.TaskList[i] + if not currentProxy then + currentProxy = XUiGridOnlineBossTask.New(self["PanelScrollBar" .. i], self) + self.TaskList[i] = currentProxy + end + + currentProxy:Refresh(allOnlineTask[i], allOnlineTask[i - 1]) + end +end + +function XUiOnlineBoss:RefreshName() + local stageCfg = XDataCenter.FubenManager.GetStageCfg(self.StageId) + self.TxtName.text = stageCfg.Name +end + +function XUiOnlineBoss:OnUpdateRefreshTime() + local curTime = XTime.GetServerNowTimestamp() + local nextTime = XDataCenter.FubenBossOnlineManager.GetOnlineBossUpdateTime() + + if not self.GameObject or not self.GameObject:Exist() then + self:StopTimer() + return + end + + local remainTime = nextTime - curTime + if remainTime > 0 then + self.TxtTime.text = XUiHelper.GetTime(remainTime, XUiHelper.TimeFormatType.ONLINE_BOSS) + else + self.TxtTime.text = "00:00" + self:StopTimer() + self:OnTimeOut() + end +end + + +function XUiOnlineBoss:StartTimer() + if self.Timers then + self:StopTimer() + end + self:OnUpdateRefreshTime() + self.Timers = XScheduleManager.ScheduleForever(function() self:OnUpdateRefreshTime() end, XScheduleManager.SECOND) +end + +function XUiOnlineBoss:StopTimer() + if self.Timers then + XScheduleManager.UnSchedule(self.Timers) + self.Timers = nil + end + if self.ShowCharAnimation then + CS.XScheduleManager.UnSchedule(self.ShowCharAnimation) + self.ShowCharAnimation = nil + end +end + +function XUiOnlineBoss:RefreshRisk() + if self.Name == "UiOnlineBossActivity" then + local bossData = XDataCenter.FubenBossOnlineManager.GetActOnlineBossSectionForDiff(self.CurDifficult) + local riskTemplate = XFubenBossOnlineConfig.GetRiskTemplate(bossData.KillCount) + self.TxtRisk.text = riskTemplate.Name + self.TxtKill.text = CS.XTextManager.GetText("BossOnlineKillCount", bossData.KillCount) + local color = XUiHelper.Hexcolor2Color(riskTemplate.Color) + self.TxtRisk.color = color + self.TxtKill.color = color + self.PanelRisk.gameObject:SetActive(true) + else + self.PanelRisk.gameObject:SetActive(false) + end +end + +function XUiOnlineBoss:OnBtnStartClick() + if not XDataCenter.FubenBossOnlineManager.CheckOnlineBossUnlock(self.CurDifficult, true) then + return + end + local bossData = XDataCenter.FubenBossOnlineManager.GetActOnlineBossSectionForDiff(self.CurDifficult) + self:OnEnterMatch(bossData.BossId) +end + +function XUiOnlineBoss:OnBtnBackClick() + if self.UiState == UiState.Enter then + self:Close() + elseif self.UiState == UiState.Match then + if XDataCenter.RoomManager.Matching then + local title = CS.XTextManager.GetText("TipTitle") + local cancelMatchMsg = CS.XTextManager.GetText("OnlineInstanceCancelMatch") + XUiManager.DialogTip(title, cancelMatchMsg, XUiManager.DialogType.Normal, nil, function() + XDataCenter.RoomManager.CancelMatch(function() + self:SwitchState(UiState.Enter) + end) + end) + else + self:SwitchState(UiState.Enter) + end + elseif self.UiState == UiState.Info then + self:SwitchState(UiState.Match) + self.PanelMatchEnable:PlayTimelineAnimation() + end +end + +function XUiOnlineBoss:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiOnlineBoss:OnBtnInvadeClick() + if not self:UseLastTemplate() or self.IsPlayInvade then + return + end + CS.XAudioManager.PlaySound(1104) + XDataCenter.FubenBossOnlineManager.RecordInvade() + + self.InvadeEffect.gameObject:SetActive(true) + local effectUrl = CS.XGame.ClientConfig:GetString("BossOnlineInvadeEffectUrl") + local effect = self.InvadeEffect.gameObject:LoadUiEffect(effectUrl) + local obj = {Transform = effect.transform} + XTool.InitUiObject(obj) + self.InvadeBeginEffect = obj.BeginEffect + self.InvadeEndEffect = obj.EndEffect + self.InvadeBeginEffect:PlayTimelineAnimation() + + XScheduleManager.ScheduleOnce(function() + if not self.GameObject or not self.GameObject:Exist() then + return + end + self:PlayTxtAutoInvade() + end, CS.XGame.ClientConfig:GetInt("BossOnlineInvadeDelay")) + + self.IsPlayInvade = true +end + +function XUiOnlineBoss:OnBossUpdate() + self:RefreshModel() + self:RefreshName() + self:RefreshRisk() + self:StartTimer() + self:RefreshBtnList() +end + +function XUiOnlineBoss:OnBossRefresh() + self:OnTimeOut() +end + +function XUiOnlineBoss:OnTimeOut() + if XDataCenter.RoomManager.Matching then + XDataCenter.RoomManager.CancelMatch() + XLuaUiManager.Remove("UiOnLineMatching") + end + + if XLuaUiManager.IsUiShow("UiDialog") then + XLuaUiManager.Close("UiDialog") + end + + if XDataCenter.FubenBossOnlineManager.TryPopOverTips() then + self:Close() + else + self:Close() + self.NeedClose = true + end +end + +function XUiOnlineBoss:SwitchState(state) + XLog.Debug("XUiOnlineBoss:SwitchState " .. state) + self.UiState = state + for _, v in pairs(self.GameObjectGroup) do + for _, go in pairs(v) do + go:SetActive(false) + end + end + + for _, go in pairs(self.GameObjectGroup[state]) do + go:SetActive(true) + end + +end + +function XUiOnlineBoss:OnShowBossInfo(section) + self:SwitchState(UiState.Info) + self.BossInfoPanel:SetData(section) + self.PanelBossInfoEnable:PlayTimelineAnimation() +end + +function XUiOnlineBoss:OnEnterMatch(sectionId) + self:SwitchState(UiState.Match) + local sectionCfg = XDataCenter.FubenBossOnlineManager.GetActOnlineBossSectionById(sectionId) + if sectionCfg then + self.MatchPanel:Refresh(sectionCfg) + self.PanelMatchEnable:PlayTimelineAnimation() + end +end + +function XUiOnlineBoss:OnCancelMatch() + self.MatchPanel:OnCancelMatch() +end + +function XUiOnlineBoss:EnterRoom() + self.MatchPanel:ResetState() +end + +--初始化模型 +function XUiOnlineBoss:InitModel() + self.RoleModelPanel = XUiPanelRoleModel.New(self.PanelModel, self.Name, nil, true) + self:RefreshModel() +end + +--怪物模型&场景 +function XUiOnlineBoss:RefreshModel() + local bossData = XDataCenter.FubenBossOnlineManager.GetActOnlineBossSectionForDiff(self.CurDifficult) + if bossData then + local sectionTemplate = XDataCenter.FubenBossOnlineManager.GetActOnlineBossSectionById(bossData.BossId, self:UseLastTemplate()) + if sectionTemplate then + self.SectionTemplate = sectionTemplate + if self.Name == "UiOnlineBossActivity" then + self:LoadScene(self.SectionTemplate.Scene) + end + self:LoadModel(self.SectionTemplate.ModelId) + end + end +end + +function XUiOnlineBoss:RefreshBtnList() + for k, v in pairs(self.TabList) do + local diff = self.DifficultMap[k] + if XDataCenter.FubenBossOnlineManager.CheckOnlineBossUnlock(diff) then + if v.ButtonState == CS.UiButtonState.Disable then + v.ButtonState = CS.UiButtonState.Normal + end + else + v.ButtonState = CS.UiButtonState.Disable + end + end +end + +function XUiOnlineBoss:PlayTxtAutoInvade() + local count = CS.XGame.ClientConfig:GetInt("BossOnlineInvadeDescCount") + local desc = {} + for i = 1, count do + desc[i] = CS.XTextManager.GetText("BossOnlineInvade" .. i) + end + + local delay = 0 + local interval = CS.XGame.ClientConfig:GetInt("BossOnlineInvadeInterval") + local wait = CS.XGame.ClientConfig:GetInt("BossOnlineInvadeWait") + for _, v in ipairs(desc) do + local str = v + local chartab = string.CharsConvertToCharTab(str) + local length = #chartab + XScheduleManager.ScheduleOnce(function() + if not self.GameObject or not self.GameObject:Exist() then + return + end + self.ShowCharAnimation = XUiHelper.ShowCharByTypeAnimation(_self.TxtAutoInvade, str, interval) + end, delay) + delay = delay + length * interval + wait + end + + XScheduleManager.ScheduleOnce(function() + if not self.GameObject or not self.GameObject:Exist() then + return + end + local defaultIdx = self.DefaultIndex or 1 + self.TxtAutoInvade.gameObject:SetActive(false) + self.InvadeEndEffect:PlayTimelineAnimation(function() + XLuaUiManager.PopThenOpen("UiOnlineBossActivity", defaultIdx, true) + end) + self.DefaultIndex = nil + end, delay) +end + +function XUiOnlineBoss:SetDifficult(difficult) + self.CurDifficult = difficult + local bossData = XDataCenter.FubenBossOnlineManager.GetActOnlineBossSectionForDiff(self.CurDifficult) + local sectionCfg = XDataCenter.FubenBossOnlineManager.GetActOnlineBossSectionById(bossData.BossId, self:UseLastTemplate()) + self.StageId = sectionCfg.StageId +end + +--加载模型 +function XUiOnlineBoss:LoadModel(modelId) + if not self.RoleModelPanel then + return + end + + self.ImgEffectHuanren.gameObject:SetActive(false) + self.ImgEffectHuanren.gameObject:SetActive(true) + self.RoleModelPanel:SetDefaultAnimation(self.SectionTemplate.Animation) + self.RoleModelPanel:UpdateBossModel(modelId, XModelManager.MODEL_UINAME.XUiOnlineBoss, nil, function(model) + local animator = model:GetComponent("Animator") + if animator then + self.CurAnimator = animator + end + end) + self.PanelModel.gameObject:SetActive(false) + self.PanelModel.gameObject:SetActive(true) +end + +--加载场景 +function XUiOnlineBoss:LoadScene(sceneUrl) + local scene = self.ScenePool[sceneUrl] + if not scene then + scene = XModelManager.LoadSceneModel(sceneUrl, self.SceneCase, self.Name) + self.ScenePool[sceneUrl] = scene + end + + if self.CurScene then + self.CurScene.gameObject:SetActive(false) + end + + scene.gameObject:SetActive(true) + self.CurScene = scene +end + +--加载特效 +function XUiOnlineBoss:LoadEffect() +end + +return XUiOnlineBoss \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiOnlineBoss/XUiPanelBossInfo.lua b/Resources/Scripts/XUi/XUiOnlineBoss/XUiPanelBossInfo.lua new file mode 100644 index 00000000..f812062f --- /dev/null +++ b/Resources/Scripts/XUi/XUiOnlineBoss/XUiPanelBossInfo.lua @@ -0,0 +1,60 @@ +XUiPanelBossInfo = XClass(nil, "XUiPanelBossInfo") +local PrePageSkillCount = 5 + +function XUiPanelBossInfo:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + self.SkillPanels = { + self.PanelSkillBox1, + self.PanelSkillBox2, + self.PanelSkillBox3, + self.PanelSkillBox4, + self.PanelSkillBox5, + } + self.CurPage = 1 + self:InitGrids() + + XUiHelper.RegisterClickEvent(self, self.BtnNext, self.OnBtnNextClick) +end + +function XUiPanelBossInfo:InitGrids() + self.SkillPanelGrids = {} + for i = 1, PrePageSkillCount, 1 do + local ui = self.SkillPanels[i] + local grid = XUiPanelSkillBox.New(ui, self, i) + self.SkillPanelGrids[i] = grid + end +end + +function XUiPanelBossInfo:OnBtnNextClick() + self.CurPage = self.CurPage + 1 + self.CurPage = self.CurPage > self.MaxPage and 1 or self.CurPage + self:Refresh() +end + +function XUiPanelBossInfo:SetData(section) + self.Section = section + self.CurPage = 1 + self.MaxPage = math.ceil(#self.Section.SkillName / PrePageSkillCount) + self.BtnNext.gameObject:SetActive(self.MaxPage > 1) + self:Refresh() +end + +function XUiPanelBossInfo:Refresh() + local offset = PrePageSkillCount * (self.CurPage - 1) + for i = 1, PrePageSkillCount, 1 do + local skillName = self.Section.SkillName[i + offset] + local desc = self.Section.SkillDes[i + offset] + local grid = self.SkillPanelGrids[i] + if skillName and desc then + grid:Refresh(skillName, desc) + grid:SetActive(true) + else + grid:SetActive(false) + end + end +end + +return XUiPanelBossInfo \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiOnlineBoss/XUiPanelMatch.lua b/Resources/Scripts/XUi/XUiOnlineBoss/XUiPanelMatch.lua new file mode 100644 index 00000000..1d191dad --- /dev/null +++ b/Resources/Scripts/XUi/XUiOnlineBoss/XUiPanelMatch.lua @@ -0,0 +1,273 @@ +local CSXTextManagerGetText = CS.XTextManager.GetText + +XUiPanelMatch = XClass(nil, "XUiPanelMatch") + +function XUiPanelMatch:Ctor(ui, parent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + XUiHelper.RegisterClickEvent(self, self.BtnInfo, self.OnBtnInfoClick) + XUiHelper.RegisterClickEvent(self, self.BtnCreateRoom, self.OnBtnCreateRoomClick) + XUiHelper.RegisterClickEvent(self, self.BtnMatch, self.OnBtnMatchClick) + XUiHelper.RegisterClickEvent(self, self.BtnMatching, self.OnBtnMatchingClick) + XUiHelper.RegisterClickEvent(self, self.BtnBossInfo, self.OnBtnBossInfoClick) + + self.ArmsTips = { + self.RImgArms1, + self.RImgArms2, + self.RImgArms3, + } + self.Parent = parent + self.GridList = {} + self.GridCommon.gameObject:SetActive(false) + self.BtnMatching.interactable = false + self.StageDescs = {} + self.TxtDes.text = "" +end + +function XUiPanelMatch:OnBtnInfoClick() + local itemId = XDataCenter.FubenManager.GetFlopConsumeItemId(self.SectionCfg.StageId) + local item = XDataCenter.ItemManager.GetItem(itemId) + XLuaUiManager.Open("UiTip", item) +end + +function XUiPanelMatch:Refresh(sectionCfg) + self:ResetState() + sectionCfg = sectionCfg or self.SectionCfg + local stageCfg = XDataCenter.FubenManager.GetStageCfg(sectionCfg.StageId) + self.SectionCfg = sectionCfg + self.CurStageCfg = stageCfg + self.TxtBossName.text = stageCfg.Name + self.TxtDesc.text = stageCfg.Description + local itemId = XDataCenter.FubenManager.GetFlopConsumeItemId(sectionCfg.StageId) + local item = XDataCenter.ItemManager.GetItem(itemId) + local count = 0 + if item ~= nil and item:GetCount() >= 0 then + count = item:GetCount() + end + if itemId > 0 then + self.PanelScavenger.gameObject:SetActive(true) + local icon = XDataCenter.ItemManager.GetItemIcon(itemId) + self.RImgIcon:SetRawImage(icon) + self.TxtCount.text = count + self.TxtATNums.text = XDataCenter.FubenManager.GetStageActionPointConsume(sectionCfg.StageId) + else + self.PanelScavenger.gameObject:SetActive(false) + end + + local leastPlayer = stageCfg.OnlinePlayerLeast <= 0 and 1 or stageCfg.OnlinePlayerLeast + self.TxtPeople.text = leastPlayer + + for i, _ in ipairs(self.StageDescs) do + if self.StageDescs[i] then + self.StageDescs[i].gameObject:SetActive(false) + end + end + + for i, v in ipairs(sectionCfg.Description) do + local textTemp + + if self.StageDescs[i] then + textTemp = self.StageDescs[i] + + else + local obj = CS.UnityEngine.Object.Instantiate(self.TxtDes.gameObject) + obj.transform:SetParent(self.PanelLineupTips, false) + textTemp = obj:GetComponent("Text") + self.StageDescs[i] = textTemp + end + textTemp.text = v + textTemp.gameObject:SetActive(true) + end + + self:UpdateArmsTips() + self:UpdateRewards() +end + +function XUiPanelMatch:UpdateArmsTips() + local stage = self.CurStageCfg + + for index = 1, 3 do + local arms = stage.NeedJobType[index] + if arms then + self.ArmsTips[index].gameObject:SetActive(true) + self.ArmsTips[index]:SetRawImage(XCharacterConfigs.GetNpcTypeIconTranspose(arms)) + else + self.ArmsTips[index].gameObject:SetActive(false) + end + end +end + +function XUiPanelMatch:UpdateRewards() + local stage = self.CurStageCfg + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stage.StageId) + + -- 是否首通奖励显示 + local firstDrop = false + if not stageInfo.Passed then + local cfg = XDataCenter.FubenManager.GetStageLevelControl(stage.StageId) + if cfg and cfg.FirstRewardShow > 0 or stage.FirstRewardShow > 0 then + firstDrop = true + end + end + self.TxtFirstDrop.gameObject:SetActive(firstDrop) + self.TxtDrop.gameObject:SetActive(not firstDrop) + + -- 获取显示奖励Id + local rewardId = 0 + local cfg = XDataCenter.FubenManager.GetStageLevelControl(stage.StageId) + if not stageInfo.Passed then + rewardId = cfg and cfg.FirstRewardShow or stage.FirstRewardShow + end + if rewardId == 0 then + rewardId = cfg and cfg.FinishRewardShow or stage.FinishRewardShow + end + if rewardId == 0 then + for j = 1, #self.GridList do + self.GridList[j].GameObject:SetActive(false) + end + end + + local rewards = {} + if rewardId > 0 then + rewards = XRewardManager.GetRewardList(rewardId) + end + + --显示的奖励 + if XDataCenter.FubenManager.CheckCanFlop(stage.StageId) then + local showRewards = XRewardManager.GetRewardList(XDataCenter.FubenManager.GetFlopShowId(stage.StageId)) + rewards = XTool.MergeArray(showRewards, rewards) + end + + --关卡掉落 + for i, item in ipairs(rewards) do + local grid + if self.GridList[i] then + grid = self.GridList[i] + else + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommon) + grid = XUiGridCommon.New(self.Parent, ui) + grid.Transform:SetParent(self.PanelDropContent, false) + self.GridList[i] = grid + end + grid:Refresh(item) + grid.GameObject:SetActive(true) + end + + for j = 1, #self.GridList do + if j > #rewards then + self.GridList[j].GameObject:SetActive(false) + end + end +end + +function XUiPanelMatch:OnBtnBossInfoClick() + self.Parent:OnShowBossInfo(self.SectionCfg) + self:Refresh(self.SectionCfg) +end + + +function XUiPanelMatch:OnBtnMatchingClick() + +end + +function XUiPanelMatch:OnBtnCreateRoomClick() + if XDataCenter.FubenBossOnlineManager.CheckOnlineBossTimeOut() then + XUiManager.TipMsg(CS.XTextManager.GetText("OnlineBossTimeOut")) + return + end + + local enterFunc = function() + if XDataCenter.FubenManager.CheckCanFlop(self.CurStageCfg.StageId) then + XDataCenter.FubenManager.RequestCreateRoom(self.CurStageCfg) + else + XUiManager.DialogTip(CS.XTextManager.GetText("TipTitle"), CS.XTextManager.GetText("BossOnlineConsumeTips"), XUiManager.DialogType.Normal, nil, function() + XDataCenter.FubenManager.RequestCreateRoom(self.CurStageCfg) + end) + end + end + + local pass, requireAbility = self:CheckLevelControl() + if not pass then + local title = CSXTextManagerGetText("OnlineBossEnterConfirmTitle") + local content = CSXTextManagerGetText("OnlineBossEnterConfirmContent", requireAbility) + XUiManager.DialogTip(title, content, XUiManager.DialogType.Normal, nil, enterFunc) + else + enterFunc() + end +end + +function XUiPanelMatch:OnBtnMatchClick() + if XDataCenter.FubenBossOnlineManager.CheckOnlineBossTimeOut() then + XUiManager.TipMsg(CS.XTextManager.GetText("OnlineBossTimeOut")) + return + end + + if XDataCenter.RoomManager.Matching then + return + end + + local enterFunc = function() + if XDataCenter.FubenManager.CheckCanFlop(self.CurStageCfg.StageId) then + self:Match() + else + XUiManager.DialogTip(CS.XTextManager.GetText("TipTitle"), CS.XTextManager.GetText("BossOnlineConsumeTips"), XUiManager.DialogType.Normal, nil, handler(self, self.Match)) + end + end + + local pass, requireAbility = self:CheckLevelControl() + if not pass then + local title = CSXTextManagerGetText("OnlineBossEnterConfirmTitle") + local content = CSXTextManagerGetText("OnlineBossEnterConfirmContent", requireAbility) + XUiManager.DialogTip(title, content, XUiManager.DialogType.Normal, nil, enterFunc) + else + enterFunc() + end +end + +function XUiPanelMatch:Match() + XDataCenter.FubenManager.RequestMatchRoom(self.CurStageCfg, function()--匹配房间 + self:RefreshMatching() + self.BtnCreateRoom.interactable = false + self.BtnMatch.gameObject:SetActive(false) + self.BtnMatching.gameObject:SetActive(true) + end) +end + +-- 检测超频-普通难度战力限制 +function XUiPanelMatch:CheckLevelControl() + if self.Parent.CurDifficult ~= XDataCenter.FubenBossOnlineManager.OnlineBossDifficultLevel.NightMare then + return true + end + + local levelControl = XDataCenter.FubenManager.GetStageMultiplayerLevelControl(self.CurStageCfg.StageId, 1) + local requireAbility = levelControl and levelControl.RecommendAbility + if not requireAbility then + return true + end + + local maxAbility = XDataCenter.CharacterManager.GetMaxOwnCharacterAbility() + return maxAbility >= requireAbility, requireAbility +end + +function XUiPanelMatch:RefreshMatching() + if XDataCenter.RoomManager.Matching then + XLuaUiManager.Open("UiOnLineMatching", self.CurStageCfg) + end +end + +function XUiPanelMatch:OnCancelMatch() + self.BtnCreateRoom.interactable = true + self.BtnMatch.gameObject:SetActive(true) + self.BtnMatching.gameObject:SetActive(false) +end + + +function XUiPanelMatch:ResetState() + self.BtnMatch.gameObject:SetActive(true) + self.BtnMatching.gameObject:SetActive(false) + self.BtnCreateRoom.interactable = true +end + +return XUiPanelMatch \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiOnlineBoss/XUiPanelSkillBox.lua b/Resources/Scripts/XUi/XUiOnlineBoss/XUiPanelSkillBox.lua new file mode 100644 index 00000000..177cd6bc --- /dev/null +++ b/Resources/Scripts/XUi/XUiOnlineBoss/XUiPanelSkillBox.lua @@ -0,0 +1,18 @@ +XUiPanelSkillBox = XClass(nil, "XUiPanelSkillBox") + +function XUiPanelSkillBox:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiPanelSkillBox:Refresh(skillName, skillDesc) + self.TxtSkillName.text = skillName + self.TxtDesc.text = skillDesc +end + +function XUiPanelSkillBox:SetActive(enabled) + self.GameObject:SetActive(enabled) +end + +return XUiPanelSkillBox \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiOnlineLoading/XUiOnLineLoading.lua b/Resources/Scripts/XUi/XUiOnlineLoading/XUiOnLineLoading.lua new file mode 100644 index 00000000..52b1b1ce --- /dev/null +++ b/Resources/Scripts/XUi/XUiOnlineLoading/XUiOnLineLoading.lua @@ -0,0 +1,76 @@ +local XUiOnLineLoading = XLuaUiManager.Register(XLuaUi, "UiOnLineLoading") + +function XUiOnLineLoading:OnAwake() + self:InitAutoScript() + self.XUiPanelOnLineLoadingDetail = XUiPanelOnLineLoadingDetail.New(self.PanelOnLineLoadingDetail, self) +end + +function XUiOnLineLoading:OnStart() + XEventManager.AddEventListener(XEventId.EVENT_FIGHT_PROGRESS, self.RefreshLoadProcess, self) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiOnLineLoading:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiOnLineLoading:AutoInitUi() + self.PanelOnLineLoadingDetail = self.Transform:Find("SafeAreaContentPane/PanelOnLineLoadingDetail") + self.TxtTips = self.Transform:Find("SafeAreaContentPane/TxtTips"):GetComponent("Text") +end + +function XUiOnLineLoading:GetAutoKey(uiNode, eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiOnLineLoading:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiOnLineLoading:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiOnLineLoading:AutoAddListener() + self.AutoCreateListeners = {} +end +-- auto +function XUiOnLineLoading:SetActive(actived) + if self.GameObject then + self.GameObject.gameObject:SetActive(actived) + end +end + +function XUiOnLineLoading:Refresh() + self.XUiPanelOnLineLoadingDetail:Refresh() + self:SetActive(true) +end + +function XUiOnLineLoading:RefreshLoadProcess(playerId, progress)--更新玩家进度 + self.XUiPanelOnLineLoadingDetail:RefreshLoadProcess(playerId, progress) +end + +function XUiOnLineLoading:OnDestroy() + XEventManager.RemoveEventListener(XEventId.EVENT_FIGHT_PROGRESS, self.RefreshLoadProcess, self) +end + +return XUiOnLineLoading \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiOnlineLoading/XUiPanelOnLineLoadingDetail.lua b/Resources/Scripts/XUi/XUiOnlineLoading/XUiPanelOnLineLoadingDetail.lua new file mode 100644 index 00000000..4969384d --- /dev/null +++ b/Resources/Scripts/XUi/XUiOnlineLoading/XUiPanelOnLineLoadingDetail.lua @@ -0,0 +1,128 @@ +XUiPanelOnLineLoadingDetail = XClass(nil, "XUiPanelOnLineLoadingDetail") + +function XUiPanelOnLineLoadingDetail:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self:InitAutoScript() + self.ItemsPool = {} + self.LeftItem = nil + self.CenterItem = nil + self.RightItem = nil + self:Init() +end + +function XUiPanelOnLineLoadingDetail:Init() + self:InitializationView() + self:InitData() + self:SetActive(true) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelOnLineLoadingDetail:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiPanelOnLineLoadingDetail:AutoInitUi() + self.PanelOnLineLoadingDetailItem = self.Transform:Find("PanelOnLineLoadingDetailItem") +end + +function XUiPanelOnLineLoadingDetail:GetAutoKey(uiNode, eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiPanelOnLineLoadingDetail:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiPanelOnLineLoadingDetail:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiPanelOnLineLoadingDetail:AutoAddListener() + self.AutoCreateListeners = {} +end +-- auto +function XUiPanelOnLineLoadingDetail:InitializationView()--初始化界面 + for i = 1, XDataCenter.RoomManager.IndexType.Max do + local item + if i <= #self.ItemsPool then + item = self.ItemsPool[i] + else + local go = i == 1 + and self.PanelOnLineLoadingDetailItem.gameObject + or CS.UnityEngine.GameObject.Instantiate(self.PanelOnLineLoadingDetailItem.gameObject) + + if go then + go.transform:SetParent(self.PanelOnLineLoadingDetailItem.transform.parent, false) + end + item = XUiPanelOnLineLoadingDetailItem.New(go, self.RootUi, self) + table.insert(self.ItemsPool, item) + end + if i == 1 then + self.LeftItem = item + elseif i == 2 then + self.CenterItem = item + elseif i == 3 then + self.RightItem = item + end + item:Refresh(nil) + end +end + +function XUiPanelOnLineLoadingDetail:InitData() + if XDataCenter.RoomManager.RoomData == nil then + return + end + local left = false + XTool.LoopCollection(XDataCenter.RoomManager.RoomData.PlayerDataList, function(data) + if data.Id == XPlayer.Id then--自己 + self.CenterItem:Refresh(data) + elseif not left then + self.LeftItem:Refresh(data) + left = true + else + self.RightItem:Refresh(data) + end + end) + +end + +function XUiPanelOnLineLoadingDetail:SetActive(actived) + if self.GameObject then + self.GameObject.gameObject:SetActive(actived) + end +end + +function XUiPanelOnLineLoadingDetail:RefreshLoadProcess(playerId, progress)--更新玩家进度 + for _, v in pairs(self.ItemsPool) do + if v.Data ~= nil and v.Data.Id == playerId then + v:UpdateProgress(progress) + end + end +end + +function XUiPanelOnLineLoadingDetail:OnClose() + -- body +end + +return XUiPanelOnLineLoadingDetail \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiOnlineLoading/XUiPanelOnLineLoadingDetailItem.lua b/Resources/Scripts/XUi/XUiOnlineLoading/XUiPanelOnLineLoadingDetailItem.lua new file mode 100644 index 00000000..d54a12fd --- /dev/null +++ b/Resources/Scripts/XUi/XUiOnlineLoading/XUiPanelOnLineLoadingDetailItem.lua @@ -0,0 +1,104 @@ +XUiPanelOnLineLoadingDetailItem = XClass(nil, "XUiPanelOnLineLoadingDetailItem") + +function XUiPanelOnLineLoadingDetailItem:Ctor(ui, rootUi, parent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self.Parent = parent + XTool.InitUiObject(self) + self:InitAutoScript() + self.ImgCompleted.gameObject:SetActiveEx(false) + self:UpdateProgress(0) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelOnLineLoadingDetailItem:InitAutoScript() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiPanelOnLineLoadingDetailItem:GetAutoKey(uiNode, eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiPanelOnLineLoadingDetailItem:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiPanelOnLineLoadingDetailItem:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiPanelOnLineLoadingDetailItem:AutoAddListener() + self.AutoCreateListeners = {} +end +-- auto +function XUiPanelOnLineLoadingDetailItem:SetIsShow(active) + if self.GameObject then + self.GameObject.gameObject:SetActiveEx(active) + end +end + +function XUiPanelOnLineLoadingDetailItem:Refresh(data) + if not data then + self:SetIsShow(false) + return + end + + local medalConfig = XMedalConfigs.GetMeadalConfigById(data.MedalId) + local medalIcon = nil + if medalConfig then + medalIcon = medalConfig.MedalIcon + end + if medalIcon ~= nil then + self.ImgMedalIcon:SetRawImage(medalIcon) + self.ImgMedalIcon.gameObject:SetActiveEx(true) + else + self.ImgMedalIcon.gameObject:SetActiveEx(false) + end + + self.Data = data + self.TxtName.text = XDataCenter.SocialManager.GetPlayerRemark(data.Id, data.Name) + self.TxtPercent.text = "0%" + local character = data.FightNpcData.Character + local icon = XDataCenter.CharacterManager.GetCharHalfBodyImage(character.Id) + if icon then + self.RootUi:SetUiSprite(self.ImgIcon, icon) + end + local npcId = XCharacterConfigs.GetCharNpcId(character.Id, character.Quality) + local npcTemplate = CS.XNpcManager.GetNpcTemplate(npcId) + local logo = XCharacterConfigs.GetNpcTypeIcon(npcTemplate.Type) + if logo then + self.RootUi:SetUiSprite(self.ImgLogo, logo) + end + self:SetIsShow(true) +end + +function XUiPanelOnLineLoadingDetailItem:UpdateProgress(progress) + if progress >= 100 then + self.ImgCompleted.gameObject:SetActiveEx(true) + self.TxtPercent.text = "100%" + else + self.ImgCompleted.gameObject:SetActiveEx(false) + self.TxtPercent.text = progress .. "%" + end +end + +return XUiPanelOnLineLoadingDetailItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPartner/PartnerCarry/XUiGridPartnerCarry.lua b/Resources/Scripts/XUi/XUiPartner/PartnerCarry/XUiGridPartnerCarry.lua new file mode 100644 index 00000000..6d2fac4a --- /dev/null +++ b/Resources/Scripts/XUi/XUiPartner/PartnerCarry/XUiGridPartnerCarry.lua @@ -0,0 +1,63 @@ +local XUiGridPartnerCarry = XClass(nil, "XUiGridPartnerCarry") + +function XUiGridPartnerCarry:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + self:SetButtonCallBack() +end + +function XUiGridPartnerCarry:SetButtonCallBack() + self.BtnClick.CallBack = function() + self:OnBtnSelectClick() + end +end + +function XUiGridPartnerCarry:OnBtnSelectClick() + self.Base:SelectPartner(self.Data) + + local grids = self.Base.DynamicTable:GetGrids() + for _,grid in pairs(grids) do + grid:ShowSelect(false) + end + + self:ShowSelect(true) +end + +function XUiGridPartnerCarry:UpdateGrid(data, base) + self.Data = data + self.Base = base + + if data then + local selectPartnerId = self.Base.CurPartner:GetId() + local IsSelect = self.Data:GetId() == selectPartnerId + if IsSelect then + self:OnBtnSelectClick() + else + self:ShowSelect(IsSelect) + end + self:ShowInfo() + end + +end + +function XUiGridPartnerCarry:ShowSelect(IsShow) + self.PanelSelected.gameObject:SetActiveEx(IsShow) +end + +function XUiGridPartnerCarry:OnCheckRedPoint(count) + self.BtnCharacter:ShowReddot(count >= 0) +end + +function XUiGridPartnerCarry:ShowInfo() + self.RImgHeadIcon:SetRawImage(self.Data:GetIcon()) + self.PanelLv:GetObject("TxtLevel").text = self.Data:GetLevel() + self.RImgQuality:SetRawImage(XCharacterConfigs.GetCharacterQualityIcon(self.Data:GetQuality())) + self.ImgLock.gameObject:SetActiveEx(self.Data:GetIsLock()) + self.ImgIsCarry.gameObject:SetActiveEx(self.Data:GetIsCarry()) + local btImg = self.Data:GetBreakthroughIcon() + self.ImgBreak:SetSprite(btImg) +end + +return XUiGridPartnerCarry \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPartner/PartnerCarry/XUiPartnerCarry.lua b/Resources/Scripts/XUi/XUiPartner/PartnerCarry/XUiPartnerCarry.lua new file mode 100644 index 00000000..8606b116 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPartner/PartnerCarry/XUiPartnerCarry.lua @@ -0,0 +1,271 @@ +local XUiPartnerCarry = XLuaUiManager.Register(XLuaUi, "UiPartnerCarry") +local XUiGridSkill = require("XUi/XUiPartner/PartnerCommon/XUiGridSkill") +local XUiGridPartnerCarry = require("XUi/XUiPartner/PartnerCarry/XUiGridPartnerCarry") +local CSTextManagerGetText = CS.XTextManager.GetText +local DefaultIndex = 1 +local Select = CS.UiButtonState.Select +local Normal = CS.UiButtonState.Normal + +local ATTR_COLOR = { + BELOW = XUiHelper.Hexcolor2Color("d11e38ff"), + EQUAL = XUiHelper.Hexcolor2Color("000000ff"), + OVER = XUiHelper.Hexcolor2Color("188649ff"), +} + +local TakeState = { + On = 1, + Off = 2, + Change = 3, +} + +function XUiPartnerCarry:OnStart(characterId,IsCanSkipProperty) + self.CurCarrierId = characterId + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self:SetButtonCallBack() + self:InitDynamicTable() + self.GridSkill.gameObject:SetActiveEx(false) + self.MainSkillGrid = {} + self.PassiveSkillGrid = {} + self.IsCanSkipProperty = IsCanSkipProperty +end + +function XUiPartnerCarry:OnDestroy() + +end + +function XUiPartnerCarry:OnEnable() + self:UpdatePanel() + XEventManager.AddEventListener(XEventId.EVENT_PARTNER_CARRY, self.ShowHint, self) + XEventManager.AddEventListener(XEventId.EVENT_PARTNER_SKILLCHANGE, self.UpdatePanel, self) +end + +function XUiPartnerCarry:OnDisable() + XEventManager.RemoveEventListener(XEventId.EVENT_PARTNER_CARRY, self.ShowHint, self) + XEventManager.RemoveEventListener(XEventId.EVENT_PARTNER_SKILLCHANGE, self.UpdatePanel, self) +end + +function XUiPartnerCarry:SetButtonCallBack() + self.BtnBack.CallBack = function() + self:OnBtnBackClick() + end + self.BtnMainUi.CallBack = function() + self:OnBtnMainUiClick() + end + self.BtnPartnerLock.CallBack = function() + self:OnBtnPartnerLockClick() + end + self.BtnStrengthen.CallBack = function() + self:OnBtnStrengthenClick() + end + self.BtnTakeOn.CallBack = function() + self.TakeState = TakeState.On + self:OnBtnTakeOnClick() + end + self.BtnTakeOff.CallBack = function() + self.TakeState = TakeState.Off + self:OnBtnTakeOffClick() + end + self.BtnTakeChange.CallBack = function() + self.TakeState = TakeState.Change + self:OnBtnTakeOnClick() + end +end + +function XUiPartnerCarry:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelPartnerScroll) + self.DynamicTable:SetProxy(XUiGridPartnerCarry) + self.DynamicTable:SetDelegate(self) + self.GridPartner.gameObject:SetActiveEx(false) +end + +function XUiPartnerCarry:SetupDynamicTable() + local curPartnerType = XCharacterConfigs.GetCharacterType(self.CurCarrierId) + + self.PageDatas = XDataCenter.PartnerManager.GetPartnerOverviewDataList(nil, curPartnerType, false) + XPartnerSort.CarrySortFunction(self.PageDatas, self.CurCarrierId) + + self.CurPartner = self.CurPartner or self.PageDatas[DefaultIndex] + self.DynamicTable:SetDataSource(self.PageDatas) + self.DynamicTable:ReloadDataASync(1) +end + +function XUiPartnerCarry:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:UpdateGrid(self.PageDatas[index], self) + end +end + +function XUiPartnerCarry:UpdatePanel() + self:SetupDynamicTable() + self:PlayAnimation("LeftQieHuan") + + local charName = XCharacterConfigs.GetCharacterLogName(self.CurCarrierId) + local charElement = XCharacterConfigs.GetCharacterElement(self.CurCarrierId) + local elementConfig = XCharacterConfigs.GetCharElement(charElement) + + self.CountText.text = #self.PageDatas + self.TxtCarrierName.text = charName +end + +function XUiPartnerCarry:SelectPartner(partner) + self.CurPartner = partner + self:UpdatePanelPartnerCarryInfo(partner) + self:PlayAnimation("RightQieHuan") +end + +function XUiPartnerCarry:UpdatePanelPartnerCarryInfo(data) + self.Data = data + if data then + + local carryPartnerId = XDataCenter.PartnerManager.GetCarryPartnerIdByCarrierId(self.CurCarrierId) + local carryPartner = carryPartnerId and XDataCenter.PartnerManager.GetPartnerEntityById(carryPartnerId) + carryPartnerId = carryPartner and carryPartnerId or nil + + self.TxtPartnerName.text = data:GetName() + self.TxtPartnerLevel.text = data:GetLevel() + + local IsShowSelect = true + if not carryPartnerId or carryPartnerId == data:GetId() then + self.TxtCurAbil.text = data:GetAbility() + IsShowSelect = false + else + self.TxtSelectAbil.text = data:GetAbility() + self.TxtCurAbil.text = carryPartner:GetAbility() + + if carryPartner:GetAbility() == data:GetAbility() then + self.TxtSelectAbil.color = ATTR_COLOR.EQUAL + elseif carryPartner:GetAbility() < data:GetAbility() then + self.TxtSelectAbil.color = ATTR_COLOR.OVER + elseif carryPartner:GetAbility() > data:GetAbility() then + self.TxtSelectAbil.color = ATTR_COLOR.BELOW + end + + IsShowSelect = true + end + + self.ImgCompare.gameObject:SetActiveEx(IsShowSelect) + self.TxtSelectAbil.gameObject:SetActiveEx(IsShowSelect) + + local IsTakeOn = not carryPartnerId or carryPartnerId ~= data:GetId() + self.BtnTakeOn.gameObject:SetActiveEx(IsTakeOn and not carryPartnerId) + self.BtnTakeOff.gameObject:SetActiveEx(not IsTakeOn) + self.BtnTakeChange.gameObject:SetActiveEx(IsTakeOn and carryPartnerId) + self.BtnStrengthen.gameObject:SetActiveEx(self.IsCanSkipProperty) + + local qualityIcon = XCharacterConfigs.GetCharacterQualityIcon(data:GetQuality()) + self.RImgPartnerIcon:SetRawImage(data:GetIcon()) + self.RawImageQuality:SetRawImage(qualityIcon) + + self:ShowLock() + self:ShowPanelSkill() + end +end + +function XUiPartnerCarry:ShowPanelSkill() + local mainSkillList = self.Data:GetCarryMainSkillGroupList() + local passiveSkillList = self.Data:GetCarryPassiveSkillGroupList() + local skillCount = self.Data:GetQualitySkillColumnCount() + local initQuality = self.Data:GetInitQuality() + + for index = 1, XPartnerConfigs.MainSkillCount do + local grid = self.MainSkillGrid[index] + if not grid then + local obj = CS.UnityEngine.Object.Instantiate(self.GridSkill,self.PanelSkills) + obj.gameObject:SetActiveEx(true) + grid = XUiGridSkill.New(obj) + grid.GameObject.name = string.format("MainSkill%d", index) + self.MainSkillGrid[index] = grid + end + grid:UpdateGrid(mainSkillList[index], self.Data, false, XPartnerConfigs.SkillType.MainSkill, index + 1) + end + + for index = 1, XPartnerConfigs.PassiveSkillCount do + local grid = self.PassiveSkillGrid[index] + if not grid then + local obj = CS.UnityEngine.Object.Instantiate(self.GridSkill,self.PanelSkills) + obj.gameObject:SetActiveEx(true) + grid = XUiGridSkill.New(obj) + grid.GameObject.name = string.format("PassiveSkill%d", index) + self.PassiveSkillGrid[index] = grid + end + grid:UpdateGrid(passiveSkillList[index], self.Data, skillCount < index, XPartnerConfigs.SkillType.PassiveSkill, index + 1) + end +end + +function XUiPartnerCarry:ShowLock() + self.BtnPartnerLock:SetButtonState(self.Data:GetIsLock() and Select or Normal) + self.BtnPartnerLock.TempState = self.Data:GetIsLock() and Select or Normal +end + +function XUiPartnerCarry:OnBtnPartnerLockClick() + XDataCenter.PartnerManager.PartnerUpdateLockRequest(self.Data:GetId(), not self.Data:GetIsLock(), function () + self:UpdatePanel() + end) +end + +function XUiPartnerCarry:OnBtnBackClick() + self:Close() +end + +function XUiPartnerCarry:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiPartnerCarry:OnBtnStrengthenClick() + XLuaUiManager.Open("UiPartnerMain", XPartnerConfigs.MainUiState.Property, self.CurPartner, true, true) +end + +function XUiPartnerCarry:OnBtnTakeOnClick() + local IsCarring = self.Data:GetIsCarry() and self.Data:GetCharacterId() ~= self.CurCarrierId + if IsCarring then + local CarrierName = XCharacterConfigs.GetCharacterLogName(self.Data:GetCharacterId()) + XDataCenter.PartnerManager.TipDialog(nil,function () + self:DoTakeOn() + end, "PartnerIsCarringHint", CarrierName) + else + self:DoTakeOn() + end +end + +function XUiPartnerCarry:DoTakeOn() + self:OpenMask() + XDataCenter.PartnerManager.PartnerCarryRequest(self.CurCarrierId, self.CurPartner:GetId(), function () + self:CloseMask() + end) +end + +function XUiPartnerCarry:OnBtnTakeOffClick() + self:OpenMask() + XDataCenter.PartnerManager.PartnerBreakAwayRequest(self.CurPartner:GetId(), function () + self:CloseMask() + end) +end + +function XUiPartnerCarry:OpenMask() + if not self.IsSendMeg then + XLuaUiManager.SetMask(true) + self.IsSendMeg = true + end +end + +function XUiPartnerCarry:CloseMask() + if self.IsSendMeg then + XLuaUiManager.SetMask(false) + self.IsSendMeg = false + end +end + +function XUiPartnerCarry:ShowHint() + local hintText = "" + if self.TakeState == TakeState.On then + hintText = CSTextManagerGetText("PartnerCarrySuccess") + elseif self.TakeState == TakeState.Off then + hintText = CSTextManagerGetText("PartnerPutdownSuccess") + elseif self.TakeState == TakeState.Change then + hintText = CSTextManagerGetText("PartnerChangeSuccess") + end + + XLuaUiManager.Open("UiPartnerPopupTip", hintText) + self:UpdatePanel() + self:CloseMask() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPartner/PartnerCommon/XPartnerSort.lua b/Resources/Scripts/XUi/XUiPartner/PartnerCommon/XPartnerSort.lua new file mode 100644 index 00000000..d7e8f5bf --- /dev/null +++ b/Resources/Scripts/XUi/XUiPartner/PartnerCommon/XPartnerSort.lua @@ -0,0 +1,285 @@ +XPartnerSort = XPartnerSort or {} +local sortDic = {} + +sortDic[XPartnerConfigs.SortType.Ability] = function(a, b, IsDescend) + if a:GetAbility() ~= b:GetAbility() then + if IsDescend then + return a:GetAbility() > b:GetAbility() + else + return a:GetAbility() < b:GetAbility() + end + end + return nil +end + +sortDic[XPartnerConfigs.SortType.Quality] = function(a, b, IsDescend) + if a:GetQuality() ~= b:GetQuality() then + if IsDescend then + return a:GetQuality() > b:GetQuality() + else + return a:GetQuality() < b:GetQuality() + end + end + return nil +end + +sortDic[XPartnerConfigs.SortType.Breakthrough] = function(a, b, IsDescend) + if a:GetBreakthrough() ~= b:GetBreakthrough() then + if IsDescend then + return a:GetBreakthrough() > b:GetBreakthrough() + else + return a:GetBreakthrough() < b:GetBreakthrough() + end + end + return nil +end + +sortDic[XPartnerConfigs.SortType.Level] = function(a, b, IsDescend) + if a:GetLevel() ~= b:GetLevel() then + if IsDescend then + return a:GetLevel() > b:GetLevel() + else + return a:GetLevel() < b:GetLevel() + end + end + return nil +end + +sortDic[XPartnerConfigs.SortType.SkillLevel] = function(a, b, IsDescend) + if a:GetTotalSkillLevel() ~= b:GetTotalSkillLevel() then + if IsDescend then + return a:GetTotalSkillLevel() > b:GetTotalSkillLevel() + else + return a:GetTotalSkillLevel() < b:GetTotalSkillLevel() + end + end + return nil +end + +sortDic[XPartnerConfigs.SortType.Lock] = function(a, b, IsDescend) + if a:GetIsLock() ~= b:GetIsLock() then + if IsDescend then + return a:GetIsLock() + else + return b:GetIsLock() + end + end + return nil +end + +sortDic[XPartnerConfigs.SortType.Priority] = function(a, b, IsDescend) + if a:GetPriority() ~= b:GetPriority() then + if IsDescend then + return a:GetPriority() > b:GetPriority() + else + return a:GetPriority() < b:GetPriority() + end + end + return nil +end + +sortDic[XPartnerConfigs.SortType.Stack] = function(a, b, IsDescend) + if a:GetIsByOneself() ~= b:GetIsByOneself() then + if IsDescend then + return a:GetIsByOneself() + else + return b:GetIsByOneself() + end + end + return nil +end + +sortDic[XPartnerConfigs.SortType.CanCompose] = function(a, b, IsDescend) + if a:GetIsCanCompose() ~= b:GetIsCanCompose() then + if IsDescend then + return a:GetIsCanCompose() + else + return b:GetIsCanCompose() + end + end + return nil +end + +sortDic[XPartnerConfigs.SortType.Carry] = function(a, b, IsDescend) + if a:GetIsCarry() ~= b:GetIsCarry() then + if IsDescend then + return a:GetIsCarry() + else + return b:GetIsCarry() + end + end + return nil +end + +local CarrySortTypeList = { + {Type = XPartnerConfigs.SortType.Carry, IsDescend = false}, + {Type = XPartnerConfigs.SortType.Ability, IsDescend = true}, + {Type = XPartnerConfigs.SortType.Quality, IsDescend = true}, + {Type = XPartnerConfigs.SortType.Breakthrough, IsDescend = true}, + {Type = XPartnerConfigs.SortType.Level, IsDescend = true}, + {Type = XPartnerConfigs.SortType.SkillLevel, IsDescend = true}, + {Type = XPartnerConfigs.SortType.Priority, IsDescend = true}, +} + +local OverviewSortTypeList = { + {Type = XPartnerConfigs.SortType.Ability, IsDescend = true}, + {Type = XPartnerConfigs.SortType.Quality, IsDescend = true}, + {Type = XPartnerConfigs.SortType.Breakthrough, IsDescend = true}, + {Type = XPartnerConfigs.SortType.Level, IsDescend = true}, + {Type = XPartnerConfigs.SortType.SkillLevel, IsDescend = true}, + {Type = XPartnerConfigs.SortType.Lock, IsDescend = true}, + {Type = XPartnerConfigs.SortType.Priority, IsDescend = true}, + {Type = XPartnerConfigs.SortType.Stack, IsDescend = false}, +} + +local EatSortTypeList = { + {Type = XPartnerConfigs.SortType.Quality, IsDescend = false}, + {Type = XPartnerConfigs.SortType.Breakthrough, IsDescend = false}, + {Type = XPartnerConfigs.SortType.Level, IsDescend = false}, + {Type = XPartnerConfigs.SortType.Priority, IsDescend = false}, +} + +local ComposeSortTypeList = { + {Type = XPartnerConfigs.SortType.CanCompose, IsDescend = true}, + {Type = XPartnerConfigs.SortType.Quality, IsDescend = true}, + {Type = XPartnerConfigs.SortType.Priority, IsDescend = true}, +} + +local BagShowSortTypeList = { + {Type = XPartnerConfigs.SortType.Carry, IsDescend = false}, + {Type = XPartnerConfigs.SortType.Quality, IsDescend = true}, + {Type = XPartnerConfigs.SortType.Breakthrough, IsDescend = true}, + {Type = XPartnerConfigs.SortType.Level, IsDescend = true}, + {Type = XPartnerConfigs.SortType.Priority, IsDescend = true}, +} + +function XPartnerSort.OverviewSortFunction(partnerList) + local tmpSortList = {} + local orderList = {} + for _,data in pairs(OverviewSortTypeList) do + table.insert(tmpSortList, sortDic[data.Type]) + table.insert(orderList, data.IsDescend) + end + + table.sort(partnerList, function(a, b) + + for index,sort in pairs(tmpSortList) do + if sort(a, b, orderList[index]) ~= nil then + return sort(a, b, orderList[index]) + end + end + + return a:GetId() > b:GetId() + end) +end + +function XPartnerSort.BagShowSortFunction(partnerList, firstType, IsDescend) + local tmpSortList = {} + local orderList = {} + for _,data in pairs(BagShowSortTypeList) do + if data.Type == firstType then + table.insert(tmpSortList, 2, sortDic[data.Type]) + else + table.insert(tmpSortList, sortDic[data.Type]) + end + + local oder + if IsDescend then + oder = data.IsDescend + else + oder = not data.IsDescend + end + table.insert(orderList, oder) + end + + table.sort(partnerList, function(a, b) + for index,sort in pairs(tmpSortList) do + if sort(a, b, orderList[index]) ~= nil then + return sort(a, b, orderList[index]) + end + end + return a:GetId() > b:GetId() + end) +end + +function XPartnerSort.ComposeSortFunction(partnerList) + local tmpSortList = {} + local orderList = {} + for _,data in pairs(ComposeSortTypeList) do + table.insert(tmpSortList, sortDic[data.Type]) + table.insert(orderList, data.IsDescend) + end + + table.sort(partnerList, function(a, b) + + for index,sort in pairs(tmpSortList) do + if sort(a, b, orderList[index]) ~= nil then + return sort(a, b, orderList[index]) + end + end + + return a:GetId() > b:GetId() + end) +end + +function XPartnerSort.EatSortFunction(partnerList) + local tmpSortList = {} + local orderList = {} + for _,data in pairs(EatSortTypeList) do + table.insert(tmpSortList, sortDic[data.Type]) + table.insert(orderList, data.IsDescend) + end + + table.sort(partnerList, function(a, b) + + for index,sort in pairs(tmpSortList) do + if sort(a, b, orderList[index]) ~= nil then + return sort(a, b, orderList[index]) + end + end + + return a:GetId() > b:GetId() + end) +end + +function XPartnerSort.CarrySortFunction(partnerList, carrierId) + local tmpSortList = {} + local orderList = {} + for _,data in pairs(CarrySortTypeList) do + table.insert(tmpSortList, sortDic[data.Type]) + table.insert(orderList, data.IsDescend) + end + + table.sort(partnerList, function(a, b) + if a:GetCharacterId() == carrierId or b:GetCharacterId() == carrierId then + return a:GetCharacterId() == carrierId + else + for index,sort in pairs(tmpSortList) do + if sort(a, b, orderList[index]) ~= nil then + return sort(a, b, orderList[index]) + end + end + end + + return a:GetId() > b:GetId() + end) +end + +function XPartnerSort.SkillSort(skillList) + table.sort(skillList, function (a, b) + return a:GetId() < b:GetId() + end) +end + +function XPartnerSort.CanComposeIdSort(partnerIdList) + table.sort(partnerIdList, function (a, b) + local cfg_A = XPartnerConfigs.GetPartnerTemplateById(a) + local cfg_B = XPartnerConfigs.GetPartnerTemplateById(b) + if cfg_A.InitQuality ~= cfg_B.InitQuality then + return cfg_A.InitQuality > cfg_B.InitQuality + else + return cfg_A.Priority > cfg_B.Priority + end + + end) +end diff --git a/Resources/Scripts/XUi/XUiPartner/PartnerCommon/XUiGridBagPartner.lua b/Resources/Scripts/XUi/XUiPartner/PartnerCommon/XUiGridBagPartner.lua new file mode 100644 index 00000000..26370547 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPartner/PartnerCommon/XUiGridBagPartner.lua @@ -0,0 +1,43 @@ +local XUiGridBagPartner = XClass(nil, "XUiGridBagPartner") + +function XUiGridBagPartner:Ctor(ui, clickCb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.IsSelect = false + self.ClickCb = clickCb + XTool.InitUiObject(self) + self:SetButtonCallBack() + self:SetSelected(false) +end + +function XUiGridBagPartner:SetButtonCallBack() + self.BtnClick.CallBack = function() + self:OnBtnClickClick() + end +end + +function XUiGridBagPartner:OnBtnClickClick() + if self.ClickCb then + self.ClickCb(self.Data, self) + end +end + +function XUiGridBagPartner:UpdateGrid(data) + self.Data = data + if data then + self.RImgIcon:SetRawImage(data:GetIcon()) + self.RImgQuality:SetRawImage(XCharacterConfigs.GetCharacterQualityIcon(data:GetQuality())) + self.ImgBreak:SetSprite(data:GetBreakthroughIcon()) + self.TxtLevel.text = data:GetLevel() + self.TxtName.text = data:GetName() + self.ImageQuality:SetSprite(XPartnerConfigs.GeQualityBgPath(data:GetInitQuality())) + self.ImgLock.gameObject:SetActiveEx(data:GetIsLock()) + self.PanelUsing.gameObject:SetActiveEx(data:GetIsCarry()) + end +end + +function XUiGridBagPartner:SetSelected(status) + self.ImgSelect.gameObject:SetActiveEx(status) +end + +return XUiGridBagPartner \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPartner/PartnerCommon/XUiGridPartnerAttrib.lua b/Resources/Scripts/XUi/XUiPartner/PartnerCommon/XUiGridPartnerAttrib.lua new file mode 100644 index 00000000..dff91175 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPartner/PartnerCommon/XUiGridPartnerAttrib.lua @@ -0,0 +1,51 @@ +local ATTR_COLOR = { + BELOW = XUiHelper.Hexcolor2Color("d11e38ff"), + EQUAL = XUiHelper.Hexcolor2Color("000000ff"), + OVER = XUiHelper.Hexcolor2Color("188649ff"), +} + +local XUiGridPartnerAttrib = XClass(nil, "XUiGridPartnerAttrib") + +function XUiGridPartnerAttrib:Ctor(ui, name, doNotChangeColor) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + self.TxtName.text = name + self.DoNotChangeColor = doNotChangeColor +end + +function XUiGridPartnerAttrib:UpdateData(curAttrValue, newattrvalue) + if self.TxtCurAttr then + if curAttrValue then + self.TxtCurAttr.text = curAttrValue + else + self.TxtCurAttr.gameObject:SetActive(false) + end + end + + if self.TxtSelectAttr then + if not newattrvalue or (newattrvalue == curAttrValue) then + self.TxtSelectAttr.gameObject:SetActive(false) + else + self.TxtSelectAttr.text = newattrvalue + self.TxtSelectAttr.gameObject:SetActive(true) + + if not self.DoNotChangeColor then + if curAttrValue == newattrvalue then + self.TxtSelectAttr.color = ATTR_COLOR.EQUAL + elseif curAttrValue < newattrvalue then + self.TxtSelectAttr.color = ATTR_COLOR.OVER + elseif curAttrValue > newattrvalue then + self.TxtSelectAttr.color = ATTR_COLOR.BELOW + end + end + end + end + + if self.TxtCurLevel then + self.TxtCurLevel.text = curAttrValue + end +end + +return XUiGridPartnerAttrib \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPartner/PartnerCommon/XUiGridSkill.lua b/Resources/Scripts/XUi/XUiPartner/PartnerCommon/XUiGridSkill.lua new file mode 100644 index 00000000..6bfa62f6 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPartner/PartnerCommon/XUiGridSkill.lua @@ -0,0 +1,99 @@ +local XUiGridSkill = XClass(nil, "XUiGridSkill") +local CSTextManagerGetText = CS.XTextManager.GetText +function XUiGridSkill:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.IsLock = false + XTool.InitUiObject(self) + self:SetButtonCallBack() +end + +function XUiGridSkill:SetButtonCallBack() + self.BtnSkill.CallBack = function() + self:OnBtnSkillClick() + end +end + +function XUiGridSkill:OnBtnSkillClick() + if self.IsNone then + return + end + + if self.IsLock then + XUiManager.TipMsg(CSTextManagerGetText("PartnerSkillFieldIsLock", XPartnerConfigs.QualityString[self.UnLockQuality])) + return + end + + if self:IsMainSkill() then + XLuaUiManager.Open("UiPartnerActivateMainSkill", self.Partner) + + elseif self:IsPassiveSkill() then + XLuaUiManager.Open("UiPartnerActivatePassiveSkill", self.Partner) + end + +end + +function XUiGridSkill:UpdateGrid(data, partner, IsLock, type, unLockQuality, IsNone) + self.Data = data + self.Partner = partner + self.Type = type + self.IsLock = IsLock + self.UnLockQuality = unLockQuality + self.IsNone = IsNone + + if data and not IsNone then + local level = data:GetLevelStr() + if self:IsMainSkill() then + self.PanelMainSkill:GetObject("TxtLevel").text = level + self.PanelMainSkill:GetObject("IconSkill"):SetRawImage(data:GetSkillIcon()) + if self.Tag then + if self.Partner:GetIsCarry() then + local charId = self.Partner:GetCharacterId() + local charElement = XCharacterConfigs.GetCharacterElement(charId) + local elementConfig = XCharacterConfigs.GetCharElement(charElement) + self.Tag:GetObject("RawElement"):SetRawImage(elementConfig.Icon2) + self.Tag:GetObject("RawElement").gameObject:SetActiveEx(true) + else + self.Tag:GetObject("RawElement").gameObject:SetActiveEx(false) + end + end + elseif self:IsPassiveSkill() then + self.PanelPassiveSkill:GetObject("TxtLevel").text = level + self.PanelPassiveSkill:GetObject("IconSkill"):SetRawImage(data:GetSkillIcon()) + + end + + self.PanelNoSkill.gameObject:SetActiveEx(false) + self.PanelMainSkill.gameObject:SetActiveEx(self:IsMainSkill()) + self.PanelPassiveSkill.gameObject:SetActiveEx(self:IsPassiveSkill()) + self.PanelLock.gameObject:SetActiveEx(false) + + if self.Tag then + self.Tag.gameObject:SetActiveEx(self:IsMainSkill()) + end + else + self.PanelNoSkill.gameObject:SetActiveEx(not IsLock and not IsNone) + self.PanelMainSkill.gameObject:SetActiveEx(false) + self.PanelPassiveSkill.gameObject:SetActiveEx(false) + self.PanelLock.gameObject:SetActiveEx(IsLock and not IsNone) + + if self.Tag then + self.Tag.gameObject:SetActiveEx(false) + end + end + + if self.PanelNone then + self.PanelNone.gameObject:SetActiveEx(IsNone) + end + +end + +function XUiGridSkill:IsMainSkill() + return self.Type == XPartnerConfigs.SkillType.MainSkill +end + +function XUiGridSkill:IsPassiveSkill() + return self.Type == XPartnerConfigs.SkillType.PassiveSkill +end + +return XUiGridSkill \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPartner/PartnerCommon/XUiPanelMainSkill.lua b/Resources/Scripts/XUi/XUiPartner/PartnerCommon/XUiPanelMainSkill.lua new file mode 100644 index 00000000..8c5cebf5 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPartner/PartnerCommon/XUiPanelMainSkill.lua @@ -0,0 +1,39 @@ +local XUiPanelMainSkill = XClass(nil, "XUiPanelMainSkill") +local CSTextManagerGetText = CS.XTextManager.GetText +function XUiPanelMainSkill:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.IsLock = false + XTool.InitUiObject(self) + self:SetButtonCallBack() +end + +function XUiPanelMainSkill:SetButtonCallBack() + self.BtnSkill.CallBack = function() + self:OnBtnSkillClick() + end +end + +function XUiPanelMainSkill:OnBtnSkillClick() + XLuaUiManager.Open("UiPartnerActivateMainSkill", self.Partner) +end + +function XUiPanelMainSkill:UpdatePanel(data, partner) + self.Data = data + self.Partner = partner + + if data then + local level = data:GetLevelStr() + self.TxtLevel.text = level + self.SkillName.text = data:GetSkillName() + self.IconSkill:SetRawImage(data:GetSkillIcon()) + local IsShowRed = XDataCenter.PartnerManager.CheckNewSkillRedByPartnerId(self.Partner:GetId()) + self:ShowRed(IsShowRed) + end +end + +function XUiPanelMainSkill:ShowRed(IsShowRed) + self.BtnSkill:ShowReddot(IsShowRed) +end + +return XUiPanelMainSkill \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPartner/PartnerCommon/XUiPartnerPopupTip.lua b/Resources/Scripts/XUi/XUiPartner/PartnerCommon/XUiPartnerPopupTip.lua new file mode 100644 index 00000000..e77cb55e --- /dev/null +++ b/Resources/Scripts/XUi/XUiPartner/PartnerCommon/XUiPartnerPopupTip.lua @@ -0,0 +1,21 @@ +local XUiPartnerPopupTip = XLuaUiManager.Register(XLuaUi, "UiPartnerPopupTip") + +function XUiPartnerPopupTip:OnStart(title, closeCb) + self.Title = title + self.CloseCb = closeCb + self:InitView() +end + +function XUiPartnerPopupTip:OnEnable() + self:PlayAnimation("AniUnlockTip", function() + self:Close() + end) +end + +function XUiPartnerPopupTip:OnDestroy() + if self.CloseCb then self.CloseCb() end +end + +function XUiPartnerPopupTip:InitView() + self.TxtTitle.text = self.Title +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPartner/PartnerCompose/XUiPartnerCompose.lua b/Resources/Scripts/XUi/XUiPartner/PartnerCompose/XUiPartnerCompose.lua new file mode 100644 index 00000000..9ff1e4ea --- /dev/null +++ b/Resources/Scripts/XUi/XUiPartner/PartnerCompose/XUiPartnerCompose.lua @@ -0,0 +1,67 @@ +local XUiPartnerCompose = XLuaUiManager.Register(XLuaUi, "UiPartnerCompose") + +local CSTextManagerGetText = CS.XTextManager.GetText +local DOFillTime = 0.5 +local DefaultIndex = 1 + +function XUiPartnerCompose:OnStart(base) + self.Base = base + self:SetButtonCallBack() +end + +function XUiPartnerCompose:OnDestroy() + +end + +function XUiPartnerCompose:OnEnable() + XEventManager.AddEventListener(XEventId.EVENT_PARTNER_OBTAIN, self.GoPartnerMain, self) +end + +function XUiPartnerCompose:OnDisable() + XEventManager.RemoveEventListener(XEventId.EVENT_PARTNER_OBTAIN, self.GoPartnerMain, self) +end + +function XUiPartnerCompose:SetButtonCallBack() + self.BtnCompose.CallBack = function() + self:OnBtnComposeClick() + end + self.BtnGet.CallBack = function() + self:OnBtnGetClick() + end +end + +function XUiPartnerCompose:OnBtnComposeClick() + if not self.Data:GetIsCanCompose() then + XUiManager.TipText("PartnerComposeClipEmpty") + return + end + XDataCenter.PartnerManager.PartnerComposeRequest({self.Data:GetTemplateId()}, false) +end + +function XUiPartnerCompose:OnBtnGetClick() + local unionFightData = XDataCenter.FubenUnionKillRoomManager.GetUnionRoomData() + if unionFightData and unionFightData.Id then + return + end + + local useItemId = self.Data:GetChipItemId() + XLuaUiManager.Open("UiTip", XDataCenter.ItemManager.GetItem(useItemId)) +end + +function XUiPartnerCompose:UpdatePanel(data) + self.Data = data + if data then + local IsShowRed = XDataCenter.PartnerManager.CheckComposeRedByTemplateId(self.Data:GetTemplateId()) + self.BtnCompose:ShowReddot(IsShowRed) + end +end + +function XUiPartnerCompose:GoPartnerMain(partnerList) + local selectPartner = partnerList and partnerList[DefaultIndex] or nil + for _,partner in pairs(partnerList or {}) do + if partner:GetPriority() > selectPartner:GetPriority() then + selectPartner = partner + end + end + XLuaUiManager.PopThenOpen("UiPartnerMain", nil, selectPartner) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPartner/PartnerInfo/XUiPartnerOwnedInfo.lua b/Resources/Scripts/XUi/XUiPartner/PartnerInfo/XUiPartnerOwnedInfo.lua new file mode 100644 index 00000000..7af276a5 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPartner/PartnerInfo/XUiPartnerOwnedInfo.lua @@ -0,0 +1,103 @@ +local XUiPartnerOwnedInfo = XLuaUiManager.Register(XLuaUi, "UiPartnerOwnedInfo") +local XUiGridSkill = require("XUi/XUiPartner/PartnerCommon/XUiGridSkill") +local XUiPanelMainSkill = require("XUi/XUiPartner/PartnerCommon/XUiPanelMainSkill") +local CSTextManagerGetText = CS.XTextManager.GetText +local Select = CS.UiButtonState.Select +local Normal = CS.UiButtonState.Normal +local DefaultIndex = 1 +local SkillGridMaxCount = 6 +function XUiPartnerOwnedInfo:OnStart(base) + self.Base = base + self.PassiveSkillGrid = {} + self:SetButtonCallBack() + self.GridSkill.gameObject:SetActiveEx(false) + +end + +function XUiPartnerOwnedInfo:OnDestroy() + +end + +function XUiPartnerOwnedInfo:OnEnable() + XEventManager.AddEventListener(XEventId.EVENT_PARTNER_SKILLUNLOCK_CLOSERED, self.ShowPanelSkill, self) +end + +function XUiPartnerOwnedInfo:OnDisable() + XEventManager.RemoveEventListener(XEventId.EVENT_PARTNER_SKILLUNLOCK_CLOSERED, self.ShowPanelSkill, self) +end + +function XUiPartnerOwnedInfo:SetButtonCallBack() + self.BtnRename.CallBack = function() + self:OnBtnRenameClick() + end + self.BtnLevelUp.CallBack = function() + self:OnBtnLevelUpClick() + end + self.BtnPartnerLock.CallBack = function() + self:OnBtnPartnerLockClick() + end +end + +function XUiPartnerOwnedInfo:OnBtnRenameClick() + XLuaUiManager.Open("UiPartnerRename", self.Base, self.Data:GetId()) +end + +function XUiPartnerOwnedInfo:OnBtnLevelUpClick() + self.Base:ChangeUiState(XPartnerConfigs.MainUiState.Property) +end + +function XUiPartnerOwnedInfo:OnBtnPartnerLockClick() + XDataCenter.PartnerManager.PartnerUpdateLockRequest(self.Data:GetId(), not self.Data:GetIsLock(), function () + self.Base:ShowPanel() + end) +end + +function XUiPartnerOwnedInfo:UpdatePanel(data) + self.Data = data + if data then + self.TxtName.text = data:GetName() + self.TxtAbility.text = data:GetAbility() + self.TxtType.text = data:GetDesc() + + local btImg = data:GetBreakthroughIcon() + self.ImgBreakthrough:SetSprite(btImg) + + self:ShowLock() + self:ShowPanelSkill() + self:PlayAnimation("QieHuan") + end +end + +function XUiPartnerOwnedInfo:ShowPanelSkill() + local mainSkillList = self.Data:GetCarryMainSkillGroupList() + local passiveSkillList = self.Data:GetCarryPassiveSkillGroupList() + local skillCount = self.Data:GetQualitySkillColumnCount() + local initQuality = self.Data:GetInitQuality() + + local panel = self.MainSkillPanel + if not panel then + panel = XUiPanelMainSkill.New(self.PanelMainSkill) + self.MainSkillPanel = panel + end + panel:UpdatePanel(mainSkillList[DefaultIndex], self.Data) + + for index = 1, SkillGridMaxCount do + local grid = self.PassiveSkillGrid[index] + if not grid then + local obj = CS.UnityEngine.Object.Instantiate(self.GridSkill,self.PanelSkillContent) + obj.gameObject:SetActiveEx(true) + grid = XUiGridSkill.New(obj) + self.PassiveSkillGrid[index] = grid + end + local IsNone = false + if index > XPartnerConfigs.PassiveSkillCount then + IsNone = true + end + grid:UpdateGrid(passiveSkillList[index], self.Data, skillCount < index, XPartnerConfigs.SkillType.PassiveSkill, index + 1, IsNone) + end +end + +function XUiPartnerOwnedInfo:ShowLock() + self.BtnPartnerLock:SetButtonState(self.Data:GetIsLock() and Select or Normal) + self.BtnPartnerLock.TempState = self.Data:GetIsLock() and Select or Normal +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPartner/PartnerInfo/XUiPartnerRename.lua b/Resources/Scripts/XUi/XUiPartner/PartnerInfo/XUiPartnerRename.lua new file mode 100644 index 00000000..02188e16 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPartner/PartnerInfo/XUiPartnerRename.lua @@ -0,0 +1,45 @@ +local XUiPartnerRename = XLuaUiManager.Register(XLuaUi, "UiPartnerRename") + +local CSXTextManagerGetText = CS.XTextManager.GetText +local MaxNameLength = CS.XGame.Config:GetInt("PartnerNameMaxLength") + +function XUiPartnerRename:OnStart(base, partnerId) + self.Base = base + self.PartnerId = partnerId + self:SetButtonCallBack() +end + +function XUiPartnerRename:SetButtonCallBack() + self.BtnClose.CallBack = function() + self:Close() + end + self.BtnTanchuangClose.CallBack = function() + self:Close() + end + self.BtnNameCancel.CallBack = function() + self:Close() + end + self.BtnNameSure.CallBack = function() + self:OnBtnNameSure() + end +end + +function XUiPartnerRename:OnBtnNameSure() + local editName = string.gsub(self.InFSigm.text, "^%s*(.-)%s*$", "%1") + + if string.len(editName) > 0 then + local utf8Count = self.InFSigm.textComponent.cachedTextGenerator.characterCount - 1 + if utf8Count > MaxNameLength then + XUiManager.TipError(CSXTextManagerGetText("MaxNameLengthTips", MaxNameLength)) + return + end + + XDataCenter.PartnerManager.PartnerChangeNameRequest(self.PartnerId, editName, function () + XUiManager.TipText("PartnerRenameSuc") + self.Base:ShowPanel() + self:Close() + end) + else + XUiManager.TipError(CSXTextManagerGetText("PartnerNameIsEmpty")) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPartner/PartnerMain/XUiGridPartner.lua b/Resources/Scripts/XUi/XUiPartner/PartnerMain/XUiGridPartner.lua new file mode 100644 index 00000000..89022cb0 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPartner/PartnerMain/XUiGridPartner.lua @@ -0,0 +1,110 @@ +local XUiGridPartner = XClass(nil, "XUiGridPartner") + +function XUiGridPartner:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + self:SetButtonCallBack() +end + +function XUiGridPartner:SetButtonCallBack() + self.BtnCharacter.CallBack = function() + self:OnBtnSelectClick() + end +end + +function XUiGridPartner:OnBtnSelectClick() + self.Base:SelectPartner(self.Data) + + local grids = self.Base.CurDynamicTable:GetGrids() + for _,grid in pairs(grids) do + grid:ShowSelect(false) + end + + self:ShowSelect(true) +end + +function XUiGridPartner:UpdateGrid(data, uiType, base) + self.Data = data + self.UiType = uiType + self.Base = base + + if data then + local lastPartner = self.Base:GetLastPartner(uiType) + local selectPartnerId = lastPartner and lastPartner:GetId() or self.Base.DefaultSelectPartnerId + local IsSelect = self.Data:GetId() == selectPartnerId + if IsSelect then + self:OnBtnSelectClick() + else + self:ShowSelect(IsSelect) + end + self:ShowInfo(uiType) + end + +end + +function XUiGridPartner:ShowSelect(IsShow) + self.PanelSelected.gameObject:SetActiveEx(IsShow) +end + +function XUiGridPartner:OnCheckRedPoint(count) + self.BtnCharacter:ShowReddot(count >= 0) +end + +function XUiGridPartner:ShowInfo(uiType) + self.ImgCanCompose.gameObject:SetActiveEx(false) + self.ImgIsCarry.gameObject:SetActiveEx(false) + self.ImgLock.gameObject:SetActiveEx(false) + + if uiType == XPartnerConfigs.MainUiState.Overview then + self:ShowOverviewInfo() + elseif uiType == XPartnerConfigs.MainUiState.Compose then + self:ShowComposeInfo() + end + + self.PanelLevel.gameObject:SetActiveEx(uiType == XPartnerConfigs.MainUiState.Overview) + self.TxtCount.gameObject:SetActiveEx(uiType == XPartnerConfigs.MainUiState.Overview and self.Data:GetStackCount() > 1) + self.PanelFragment.gameObject:SetActiveEx(uiType == XPartnerConfigs.MainUiState.Compose) + self.ImgBreakthrough.gameObject:SetActiveEx(uiType == XPartnerConfigs.MainUiState.Overview) +end + +function XUiGridPartner:ShowRed(IsShow) + self.BtnCharacter:ShowReddot(IsShow) +end + +--------------------------------总览界面用------------------------------------------- + +function XUiGridPartner:ShowOverviewInfo() + self.RImgHeadIcon:SetRawImage(self.Data:GetIcon()) + self.PanelLevel:GetObject("TxtLevel").text = self.Data:GetLevel() + self.RImgQuality:SetRawImage(XCharacterConfigs.GetCharacterQualityIcon(self.Data:GetQuality())) + self.ImgLock.gameObject:SetActiveEx(self.Data:GetIsLock()) + self.ImgIsCarry.gameObject:SetActiveEx(self.Data:GetIsCarry()) + + self.TxtCount:GetObject("Text").text = string.format("X%d",self.Data:GetStackCount()) + + local btImg = self.Data:GetBreakthroughIcon() + self.ImgBreakthrough:SetSprite(btImg) + + local IsShowRed = XDataCenter.PartnerManager.CheckNewSkillRedByPartnerId(self.Data:GetId()) + self:ShowRed(IsShowRed) +end + +--------------------------------合成界面用------------------------------------------- + +function XUiGridPartner:ShowComposeInfo() + self.RImgHeadIcon:SetRawImage(self.Data:GetIcon()) + self.RImgQuality:SetRawImage(XCharacterConfigs.GetCharacterQualityIcon(self.Data:GetInitQuality())) + self.PanelFragment:GetObject("TxtCurCount").text = self.Data:GetChipCurCount() + self.PanelFragment:GetObject("TxtNeedCount").text = self.Data:GetChipNeedCount() + + local IsCanCompose = self.Data:GetChipCurCount() >= self.Data:GetChipNeedCount() + self.ImgCanCompose.gameObject:SetActiveEx(IsCanCompose) + self.ImgLock.gameObject:SetActiveEx(not IsCanCompose) + + local IsShowRed = XDataCenter.PartnerManager.CheckComposeRedByTemplateId(self.Data:GetTemplateId()) + self:ShowRed(IsShowRed) +end + +return XUiGridPartner \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPartner/PartnerMain/XUiPartnerMain.lua b/Resources/Scripts/XUi/XUiPartner/PartnerMain/XUiPartnerMain.lua new file mode 100644 index 00000000..fffbcdbb --- /dev/null +++ b/Resources/Scripts/XUi/XUiPartner/PartnerMain/XUiPartnerMain.lua @@ -0,0 +1,446 @@ +local XUiPartnerMain = XLuaUiManager.Register(XLuaUi, "UiPartnerMain") +local XUiGridPartner = require("XUi/XUiPartner/PartnerMain/XUiGridPartner") +local CSTextManagerGetText = CS.XTextManager.GetText +local CSUnityEngineGameObject = CS.UnityEngine.GameObject +local DefaultIndex = 1 + +function XUiPartnerMain:OnStart(state,partner,IsNotBackChange,IsNotSelectPartner) + self.LastPartner = {} + self.ModelEffect = {} + self.IsChangeUiState = true + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self.CurUiState = self.FightBackUiState or (state or XPartnerConfigs.MainUiState.Overview) + + self:SetLastPartner(self.CurUiState,self.FightBackPartner or partner) + + self.CurPartnerState = XPartnerConfigs.PartnerState.Combat + self.IsNotBackChange = self.FightBackIsNotBackChange or IsNotBackChange + self.IsNotSelectPartner = self.FightBackIsNotSelectPartner or IsNotSelectPartner + + self:SetButtonCallBack() + self:InitSceneRoot() + self:InitDynamicTable() + + XRedPointManager.AddRedPointEvent(self.BtnCompose, self.OnCheckComposeNews, self, { XRedPointConditions.Types.CONDITION_PARTNER_COMPOSE_RED }) +end + +function XUiPartnerMain:OnDestroy() + +end + +function XUiPartnerMain:OnEnable() + self:ChangeUiState(self.CurUiState) + XEventManager.AddEventListener(XEventId.EVENT_PARTNER_DATAUPDATE, self.ShowPanel, self) + XEventManager.AddEventListener(XEventId.EVENT_PARTNER_SKILLUNLOCK_CLOSERED, self.ShowPanel, self) +end + +function XUiPartnerMain:OnDisable() + XEventManager.RemoveEventListener(XEventId.EVENT_PARTNER_DATAUPDATE, self.ShowPanel, self) + XEventManager.RemoveEventListener(XEventId.EVENT_PARTNER_SKILLUNLOCK_CLOSERED, self.ShowPanel, self) + self.RoleModelPanel:HideAllEffects() +end + +function XUiPartnerMain:IsUiOverview() + return self.CurUiState == XPartnerConfigs.MainUiState.Overview +end + +function XUiPartnerMain:IsUiCompose() + return self.CurUiState == XPartnerConfigs.MainUiState.Compose +end + +function XUiPartnerMain:IsUiProperty() + return self.CurUiState == XPartnerConfigs.MainUiState.Property +end + +function XUiPartnerMain:IsPartnerStandby() + return self.CurPartnerState == XPartnerConfigs.PartnerState.Standby +end + +function XUiPartnerMain:IsPartnerCombat() + return self.CurPartnerState == XPartnerConfigs.PartnerState.Combat +end + +function XUiPartnerMain:GetLastPartner(state) + if state == XPartnerConfigs.MainUiState.Property then + return self.LastPartner[XPartnerConfigs.MainUiState.Overview] + else + return self.LastPartner[state] + end +end + +function XUiPartnerMain:SetLastPartner(state, partner) + if state == XPartnerConfigs.MainUiState.Property then + self.LastPartner[XPartnerConfigs.MainUiState.Overview] = partner + else + self.LastPartner[state] = partner + end +end + +function XUiPartnerMain:SetButtonCallBack() + self.BtnCompose.CallBack = function() + self:ChangeUiState(XPartnerConfigs.MainUiState.Compose) + end + self.BtnChange.CallBack = function() + self:ChangePartnerState() + end + self.BtnTrial.CallBack = function() + self:OnBtnTrialClick() + end + self.BtnBack.CallBack = function() + self:OnBtnBackClick() + end + self.BtnMainUi.CallBack = function() + self:OnBtnMainUiClick() + end + + self.PaneComposeView:GetObject("BtnComposeAll").CallBack = function() + self:OnBtnComposeAllClick() + end + + self:BindHelpBtn(self.BtnHelp, "PartnerHelp") +end + +function XUiPartnerMain:InitSceneRoot() + local root = self.UiModelGo.transform + + self.PanelRoleModel = root:FindTransform("PanelRoleModel") + self.ImgEffectHuanren = root:FindTransform("ImgEffectHuanren") + + self.CameraFar = { + [XPartnerConfigs.CameraType.Standby] = root:FindTransform("UiCamFarStandby"), + [XPartnerConfigs.CameraType.Combat] = root:FindTransform("UiCamFarCombat"), + [XPartnerConfigs.CameraType.Compose] = root:FindTransform("UiCamFarCompose"), + [XPartnerConfigs.CameraType.Level] = root:FindTransform("UiCamFarLv"), + [XPartnerConfigs.CameraType.Quality] = root:FindTransform("UiCamFarQuality"), + [XPartnerConfigs.CameraType.Skill] = root:FindTransform("UiCamFarSkill"), + [XPartnerConfigs.CameraType.Story] = root:FindTransform("UiCamFarrStory"), + [XPartnerConfigs.CameraType.StandbyNoSelect] = root:FindTransform("UiCamFarStandbyNoSelect"), + [XPartnerConfigs.CameraType.CombatNoSelect] = root:FindTransform("UiCamFarCombatNoSelect"), + } + self.CameraNear = { + [XPartnerConfigs.CameraType.Standby] = root:FindTransform("UiCamNearStandby"), + [XPartnerConfigs.CameraType.Combat] = root:FindTransform("UiCamNearCombat"), + [XPartnerConfigs.CameraType.Compose] = root:FindTransform("UiCamNearCompose"), + [XPartnerConfigs.CameraType.Level] = root:FindTransform("UiCamNearLv"), + [XPartnerConfigs.CameraType.Quality] = root:FindTransform("UiCamNearQuality"), + [XPartnerConfigs.CameraType.Skill] = root:FindTransform("UiCamNearSkill"), + [XPartnerConfigs.CameraType.Story] = root:FindTransform("UiCamNearrStory"), + [XPartnerConfigs.CameraType.StandbyNoSelect] = root:FindTransform("UiCamNearStandbyNoSelect"), + [XPartnerConfigs.CameraType.CombatNoSelect] = root:FindTransform("UiCamNearCombatNoSelect"), + } + + self.RoleModelPanel = XUiPanelRoleModel.New(self.PanelRoleModel, self.Name, nil, true, nil, true) +end + +function XUiPartnerMain:InitDynamicTable() + self.PaneMainView:GetObject("GridCharacterNew").gameObject:SetActiveEx(false) + self.PaneComposeView:GetObject("GridCharacterNew").gameObject:SetActiveEx(false) + + self.MainDynamicTable = XDynamicTableNormal.New(self.PaneMainView:GetObject("SViewCharacterList")) + self.MainDynamicTable:SetProxy(XUiGridPartner) + self.MainDynamicTable:SetDelegate(self) + + self.ComposeDynamicTable = XDynamicTableNormal.New(self.PaneComposeView:GetObject("SViewCharacterList")) + self.ComposeDynamicTable:SetProxy(XUiGridPartner) + self.ComposeDynamicTable:SetDelegate(self) + +end + +function XUiPartnerMain:SetupDynamicTable() + local selectIndex = 1 + self.DefaultSelectPartnerId = self.PageDatas[DefaultIndex] and self.PageDatas[DefaultIndex]:GetId() + + local lastPartner = self:GetLastPartner(self.CurUiState) + if lastPartner then + for index,data in pairs(self.PageDatas) do + if data:GetId() == lastPartner:GetId() then + selectIndex = index + self.DefaultSelectPartnerId = lastPartner:GetId() + break + end + end + end + + if self:IsUiCompose() then + self.CurDynamicTable = self.ComposeDynamicTable + else + self.CurDynamicTable = self.MainDynamicTable + end + + self.CurDynamicTable:SetDataSource(self.PageDatas) + self.CurDynamicTable:ReloadDataSync(selectIndex) + +end + +function XUiPartnerMain:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:UpdateGrid(self.PageDatas[index], self.CurUiState, self) + end +end + +function XUiPartnerMain:SelectPartner(partner) + local lastPartner = self:GetLastPartner(self.CurUiState) + local lastPartnerId = lastPartner and lastPartner:GetId() + if lastPartnerId ~= partner:GetId() or self.IsChangeUiState then + self.CurPartnerState = XPartnerConfigs.PartnerState.Combat + self.IsChangeUiState = false + self:UpdateRoleModel(partner:GetCombatModel(), partner, true) + self:UpdateCamera() + end + self:UpdatePanel(partner) + self:SetLastPartner(self.CurUiState, partner) + self.BtnTrial.gameObject:SetActiveEx(self:IsUiOverview() and partner and partner:GetStageSkipId() > 0) +end + +function XUiPartnerMain:UpdatePanel(Data) + if self:IsUiOverview() then + self:UpdateChildUi("UiPartnerOwnedInfo", Data) + elseif self:IsUiCompose() then + self:UpdateChildUi("UiPartnerCompose", Data) + end +end + +function XUiPartnerMain:UpdateChildUi(uiName, Data) + local childUi = self:FindChildUiObj(uiName) + childUi:UpdatePanel(Data) +end + +function XUiPartnerMain:ChangePartnerState() + if self:IsPartnerStandby() then + self:DoPartnerStateChange(XPartnerConfigs.PartnerState.Combat) + elseif self:IsPartnerCombat() then + self:DoPartnerStateChange(XPartnerConfigs.PartnerState.Standby) + end +end + +function XUiPartnerMain:DoPartnerStateChange(state) + if state == self.CurPartnerState then + return + end + + local partner = self:GetLastPartner(self.CurUiState) + if not partner then + return + end + + XLuaUiManager.SetMask(true) + local closeMask = function() + XLuaUiManager.SetMask(false) + end + + if self:IsPartnerStandby() then + + local voiceId = partner:GetSToCVoice() + if voiceId and voiceId > 0 then + XSoundManager.PlaySoundByType(voiceId, XSoundManager.SoundType.Sound) + end + + self.CurPartnerState = state + self:UpdateCamera() + self.RoleModelPanel:LoadEffect(partner:GetSToCEffect(), "ModelOffEffect", true, true) + self:PlayPartnerAnima(partner:GetSToCAnime(), true, function () + self:UpdateRoleModel(partner:GetCombatModel(), partner, false) + self.RoleModelPanel:LoadEffect(partner:GetCombatBornEffect(), "ModelOnEffect", true, true) + self:PlayPartnerAnima(partner:GetCombatBornAnime(), true, closeMask) + end) + + elseif self:IsPartnerCombat() then + + local voiceId = partner:GetCToSVoice() + if voiceId and voiceId > 0 then + XSoundManager.PlaySoundByType(voiceId, XSoundManager.SoundType.Sound) + end + self.RoleModelPanel:LoadEffect(partner:GetCToSEffect(), "ModelOnEffect", true, true) + self:PlayPartnerAnima(partner:GetCToSAnime(), true, function () + self.CurPartnerState = state + self:UpdateCamera() + self:UpdateRoleModel(partner:GetStandbyModel(), partner, false) + self.RoleModelPanel:LoadEffect(partner:GetStandbyBornEffect(), "ModelOffEffect", true, true) + self:PlayPartnerAnima(partner:GetStandbyBornAnime(), true, closeMask) + end) + else + closeMask() + end +end + +function XUiPartnerMain:PlayPartnerAnima(animaName, fromBegin, callBack) + local IsCanPlay = self.RoleModelPanel:PlayAnima(animaName, fromBegin, callBack) + if not IsCanPlay then + if callBack then callBack() end + end +end + +--更新模型 +function XUiPartnerMain:UpdateRoleModel(modelId, partner, IsShowEffect) + self.RoleModelPanel:UpdatePartnerModel(modelId, XModelManager.MODEL_UINAME.XUiPartnerMain, nil, function(model) + self.PanelDrag.Target = model.transform + if IsShowEffect then + self.ImgEffectHuanren.gameObject:SetActiveEx(false) + self.ImgEffectHuanren.gameObject:SetActiveEx(true) + end + end, false, true, true) + +end + +function XUiPartnerMain:ChangeUiState(state) + if self.CurUiState ~= XPartnerConfigs.MainUiState.Property and + state ~= XPartnerConfigs.MainUiState.Property then + self:PlayAnimation("DarkEnable") + self.IsChangeUiState = true + end + + self.CurUiState = state + self:ShowPanel() +end + +function XUiPartnerMain:ShowPanel() + self.PageDatas = {} + local IsPartnerListEmpty = XDataCenter.PartnerManager.IsPartnerListEmpty() + + if self:IsUiOverview() then + if IsPartnerListEmpty then + self.CurUiState = XPartnerConfigs.MainUiState.Compose + end + end + + self.RoleModelPanel:ShowRoleModel() + + local lastPartner = self:GetLastPartner(self.CurUiState) + if self:IsUiOverview() then + local lastPartnerId = lastPartner and lastPartner:GetId() + + self.PageDatas = XDataCenter.PartnerManager.GetPartnerOverviewDataList(lastPartnerId, nil, true) + XPartnerSort.OverviewSortFunction(self.PageDatas) + + self:OpenChildUi("UiPartnerOwnedInfo", self) + self:PlayAnimation("ListEnable") + + elseif self:IsUiCompose() then + self.PageDatas, self.CanComposeIdList, self.CanComposeCount = XDataCenter.PartnerManager.GetPartnerComposeDataList() + self.PaneComposeView:GetObject("BtnComposeAll").gameObject:SetActiveEx(self.CanComposeCount > 1) + + XPartnerSort.ComposeSortFunction(self.PageDatas) + + self:OpenChildUi("UiPartnerCompose", self) + self:PlayAnimation("ListEnable") + + elseif self:IsUiProperty() then + self:DoPartnerStateChange(XPartnerConfigs.PartnerState.Combat) + self:OpenChildUi("UiPartnerProperty", self) + self:UpdateChildUi("UiPartnerProperty", lastPartner) + end + + self:UpdateCamera() + + self.BtnCompose.gameObject:SetActiveEx(self:IsUiOverview() and not self.IsNotSelectPartner) + self.BtnChange.gameObject:SetActiveEx(self:IsUiOverview()) + + self.BtnTrial.gameObject:SetActiveEx(self:IsUiOverview()) + + self.PaneMainView.gameObject:SetActiveEx(self:IsUiOverview() and not self.IsNotSelectPartner) + self.PaneComposeView.gameObject:SetActiveEx(self:IsUiCompose()) + + if self.IsNotSelectPartner or (self.IsFightBack and self:IsUiProperty()) then + local partner = self:GetLastPartner(self.CurUiState) + if partner then + self:SelectPartner(partner) + end + else + self:SetupDynamicTable() + end + + self.IsFightBack = false +end + +function XUiPartnerMain:OpenChildUi(uiName, ...) + if not XLuaUiManager.IsUiShow(uiName) then + self:OpenOneChildUi(uiName, ...) + end +end + +function XUiPartnerMain:SetCameraType(type) + for k, _ in pairs(self.CameraFar) do + self.CameraFar[k].gameObject:SetActiveEx(k == type) + end + + for k, _ in pairs(self.CameraNear) do + self.CameraNear[k].gameObject:SetActiveEx(k == type) + end +end + +function XUiPartnerMain:UpdateCamera() + if self:IsPartnerStandby() then + local cameraType = self.IsNotSelectPartner and XPartnerConfigs.CameraType.StandbyNoSelect or XPartnerConfigs.CameraType.Standby + self:SetCameraType(cameraType) + elseif self:IsPartnerCombat() then + if self:IsUiOverview() then + local cameraType = self.IsNotSelectPartner and XPartnerConfigs.CameraType.CombatNoSelect or XPartnerConfigs.CameraType.Combat + self:SetCameraType(cameraType) + elseif self:IsUiCompose() then + self:SetCameraType(XPartnerConfigs.CameraType.Compose) + elseif self:IsUiProperty() then + self:SetCameraType(XPartnerConfigs.CameraType.Combat) + end + end +end + +function XUiPartnerMain:OnBtnBackClick() + if not self:IsUiOverview() then + if XDataCenter.PartnerManager.IsPartnerListEmpty() or self.IsNotBackChange then + self:Close() + else + self:ChangeUiState(XPartnerConfigs.MainUiState.Overview) + end + else + self:Close() + end +end + +function XUiPartnerMain:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiPartnerMain:OnBtnTrialClick() + local partner = self:GetLastPartner(self.CurUiState) + local skipId = partner:GetStageSkipId() + if skipId > 0 then + XFunctionManager.SkipInterface(skipId) + end +end + +function XUiPartnerMain:ShowRoleModel() + self.RoleModelPanel:ShowRoleModel() +end + +function XUiPartnerMain:HideRoleModel() + self.RoleModelPanel:HideRoleModel() + self.RoleModelPanel:HideAllEffects() +end + +function XUiPartnerMain:OnCheckComposeNews(count) + self.BtnCompose:ShowReddot(count >= 0) +end + +function XUiPartnerMain:OnReleaseInst() + return { + UiState = self.CurUiState, + Partner = self:GetLastPartner(self.CurUiState), + IsNotBackChange = self.IsNotBackChange, + IsNotSelectPartner = self.IsNotSelectPartner, + } +end + +function XUiPartnerMain:OnResume(data) + self.IsFightBack = true + self.FightBackUiState = data.UiState + self.FightBackPartner = data.Partner + self.FightBackIsNotBackChange = data.IsNotBackChange + self.FightBackIsNotSelectPartner = data.IsNotSelectPartner +end + +function XUiPartnerMain:OnBtnComposeAllClick() + XDataCenter.PartnerManager.TipDialog(nil,function () + XPartnerSort.CanComposeIdSort(self.CanComposeIdList) + XDataCenter.PartnerManager.PartnerComposeRequest(self.CanComposeIdList, true) + end,"PartnerAllComposeHint") +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPartner/PartnerPreview/XUiPartnerPreview.lua b/Resources/Scripts/XUi/XUiPartner/PartnerPreview/XUiPartnerPreview.lua new file mode 100644 index 00000000..b07de757 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPartner/PartnerPreview/XUiPartnerPreview.lua @@ -0,0 +1,191 @@ +local XUiPartnerPreview = XLuaUiManager.Register(XLuaUi, "UiPartnerPreview") +local CSUnityEngineGameObject = CS.UnityEngine.GameObject +function XUiPartnerPreview:OnEnable() + +end + +function XUiPartnerPreview:OnDisable() + self.RoleModelPanel:HideAllEffects() +end + +function XUiPartnerPreview:OnStart(data) + self.Data = data + if not self.Data then + return + end + + self.ModelEffect = {} + self.CurPartnerState = XPartnerConfigs.PartnerState.Combat + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self:Init() + +end + +function XUiPartnerPreview:Init() + self.MosterEffects = {} + self:InitScene3DRoot() + self:SetButtonCallBack() + self:UpdateRoleModel(self.Data:GetCombatModel(), self.Data, true) + self:UpdateCamera() + self:UpdatePartnerInfo() +end + +function XUiPartnerPreview:InitScene3DRoot() + local root = self.UiModelGo.transform + + self.PanelRoleModel = root:FindTransform("PanelRoleModel") + self.ImgEffectHuanren = root:FindTransform("ImgEffectHuanren") + + self.CameraFar = { + [XPartnerConfigs.CameraType.Standby] = root:FindTransform("UiCamFarStandby"), + [XPartnerConfigs.CameraType.Combat] = root:FindTransform("UiCamFarCombat"), + } + self.CameraNear = { + [XPartnerConfigs.CameraType.Standby] = root:FindTransform("UiCamNearStandby"), + [XPartnerConfigs.CameraType.Combat] = root:FindTransform("UiCamNearCombat"), + } + + self.RoleModelPanel = XUiPanelRoleModel.New(self.PanelRoleModel, self.Name, nil, true, nil, true) +end + +function XUiPartnerPreview:SetButtonCallBack() + self.BtnBack.CallBack = function() + self:OnBtnBackClick() + end + self.BtnMainUi.CallBack = function() + self:OnBtnMainUiClick() + end + self.BtnChange.CallBack = function() + self:ChangePartnerState() + end +end + +function XUiPartnerPreview:DoPartnerStateChange(state) + if state == self.CurPartnerState then + return + end + + local partner = self.Data + + XLuaUiManager.SetMask(true) + local closeMask = function() + XLuaUiManager.SetMask(false) + end + + if self:IsPartnerStandby() then + + local voiceId = partner:GetSToCVoice() + if voiceId and voiceId > 0 then + XSoundManager.PlaySoundByType(voiceId, XSoundManager.SoundType.Sound) + end + + self.CurPartnerState = state + self:UpdateCamera() + self.RoleModelPanel:LoadEffect(partner:GetSToCEffect(), "ModelOffEffect", true, true) + self:PlayPartnerAnima(partner:GetSToCAnime(), true, function () + self:UpdateRoleModel(partner:GetCombatModel(), partner, false) + self.RoleModelPanel:LoadEffect(partner:GetCombatBornEffect(), "ModelOnEffect", true, true) + self:PlayPartnerAnima(partner:GetCombatBornAnime(), true, closeMask) + end) + + elseif self:IsPartnerCombat() then + + local voiceId = partner:GetCToSVoice() + if voiceId and voiceId > 0 then + XSoundManager.PlaySoundByType(voiceId, XSoundManager.SoundType.Sound) + end + self.RoleModelPanel:LoadEffect(partner:GetCToSEffect(), "ModelOnEffect", true, true) + + self:PlayPartnerAnima(partner:GetCToSAnime(), true, function () + self.CurPartnerState = state + self:UpdateCamera() + self:UpdateRoleModel(partner:GetStandbyModel(), partner, false) + self.RoleModelPanel:LoadEffect(partner:GetStandbyBornEffect(), "ModelOffEffect", true, true) + self:PlayPartnerAnima(partner:GetStandbyBornAnime(), true, closeMask) + end) + + else + closeMask() + end +end + +function XUiPartnerPreview:PlayPartnerAnima(animaName, fromBegin, callBack) + local IsCanPlay = self.RoleModelPanel:PlayAnima(animaName, fromBegin, callBack) + if not IsCanPlay then + if callBack then callBack() end + end +end + +--更新模型 +function XUiPartnerPreview:UpdateRoleModel(modelId, partner, IsShowEffect) + self.RoleModelPanel:UpdatePartnerModel(modelId, XModelManager.MODEL_UINAME.XUiPartnerMain, nil, function(model) + self.PanelDrag.Target = model.transform + if IsShowEffect then + self.ImgEffectHuanren.gameObject:SetActiveEx(false) + self.ImgEffectHuanren.gameObject:SetActiveEx(true) + end + end, false, true) + +end + +function XUiPartnerPreview:SetCameraType(type) + for k, _ in pairs(self.CameraFar) do + self.CameraFar[k].gameObject:SetActiveEx(k == type) + end + + for k, _ in pairs(self.CameraNear) do + self.CameraNear[k].gameObject:SetActiveEx(k == type) + end +end + +function XUiPartnerPreview:UpdateCamera() + if self:IsPartnerCombat() then + self:SetCameraType(XPartnerConfigs.CameraType.Combat) + elseif self:IsPartnerStandby() then + self:SetCameraType(XPartnerConfigs.CameraType.Standby) + end +end + +function XUiPartnerPreview:UpdatePartnerInfo() + local qualityIcon = XCharacterConfigs.GetCharacterQualityIcon(self.Data:GetInitQuality()) + + self.TxtPartnerMainName.text = self.Data:GetOriginalName() + self.RawQuality:SetRawImage(qualityIcon) + self.TxtAbility.text = self.Data:GetAbility() + self.TxtDesc.text = self.Data:GetDesc() + + local strElement = "" + for index,element in pairs(self.Data:GetRecommendElement() or {}) do + if element > 0 then + local elementConfig = XCharacterConfigs.GetCharElement(element) + local strFormat = index > 1 and "%s, %s" or "%s%s" + strElement = string.format(strFormat,strElement,elementConfig.ElementName) + end + end + self.TxtElement.text = strElement + self.TxtElement.gameObject:SetActiveEx(not string.IsNilOrEmpty(strElement)) +end + +function XUiPartnerPreview:IsPartnerStandby() + return self.CurPartnerState == XPartnerConfigs.PartnerState.Standby +end + +function XUiPartnerPreview:IsPartnerCombat() + return self.CurPartnerState == XPartnerConfigs.PartnerState.Combat +end + +function XUiPartnerPreview:OnBtnBackClick() + self:Close() +end + +function XUiPartnerPreview:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiPartnerPreview:ChangePartnerState() + if self:IsPartnerStandby() then + self:DoPartnerStateChange(XPartnerConfigs.PartnerState.Combat) + elseif self:IsPartnerCombat() then + self:DoPartnerStateChange(XPartnerConfigs.PartnerState.Standby) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerLevel/XUiPanelLevelBreak.lua b/Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerLevel/XUiPanelLevelBreak.lua new file mode 100644 index 00000000..d9346e2e --- /dev/null +++ b/Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerLevel/XUiPanelLevelBreak.lua @@ -0,0 +1,107 @@ +local XUiPanelLevelBreak = XClass(nil, "XUiPanelLevelBreak") +local XUiGridCostItem = require("XUi/XUiEquipBreakThrough/XUiGridCostItem") +local XUiGridPartnerAttrib = require("XUi/XUiPartner/PartnerCommon/XUiGridPartnerAttrib") +local moneyIndex = 1 +local CONDITION_COLOR = { + [true] = CS.UnityEngine.Color.black, + [false] = CS.UnityEngine.Color.gray, +} +function XUiPanelLevelBreak:Ctor(ui, base, root) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Base = base + self.Root = root + self.AttrGridList = {} + XTool.InitUiObject(self) + + self.GridLevelChange.gameObject:SetActiveEx(false) + self.GridCostItem.gameObject:SetActiveEx(false) + + self:SetButtonCallBack() +end + +function XUiPanelLevelBreak:UpdatePanel(data)---刷新掉这个 + self.Data = data + self:UpdatePartnerPreView() + self:UpdateBreakthroughConsume() + self.GameObject:SetActiveEx(true) +end + +function XUiPanelLevelBreak:HidePanel() + self.GameObject:SetActiveEx(false) +end + +function XUiPanelLevelBreak:UpdatePartnerPreView() + local nextBreakthrough = self.Data:GetBreakthrough() + 1 + self.TxtCurLevel.text = self.Data:GetBreakthroughLevelLimit() + self.TxtNextLevel.text = self.Data:GetBreakthroughLevelLimit(nextBreakthrough) + + local preAttrMap = self.Data:GetBreakthroughPromotedAttrMap(nextBreakthrough) + local curAttrMap = self.Data:GetBreakthroughPromotedAttrMap() + for attrIndex, attrInfo in pairs(curAttrMap) do + local preAttrInfo = preAttrMap[attrIndex] + + local grid = self.AttrGridList[attrIndex] + if not grid then + local ui = CS.UnityEngine.Object.Instantiate(self.GridLevelChange) + grid = XUiGridPartnerAttrib.New(ui, CS.XTextManager.GetText("EquipBreakThroughPopUpAttrPrefix", attrInfo.Name), false) + grid.Transform:SetParent(self.PanelAttrParent, false) + self.AttrGridList[attrIndex] = grid + end + grid.GameObject:SetActiveEx(true) + grid:UpdateData(attrInfo.Value, preAttrInfo.Value, true) + end + + for i = #curAttrMap + 1, #self.AttrGridList do + self.AttrGridList[i].GameObject:SetActiveEx(false) + end +end + +function XUiPanelLevelBreak:UpdateBreakthroughConsume() + local costMoney = self.Data:GetBreakthroughMoney().Count + self.TxtCost.text = costMoney + self.TxtCost.color = CONDITION_COLOR[XDataCenter.ItemManager.GetCoinsNum() >= costMoney] + + self.GridCostItems = self.GridCostItems or {} + local consumeItems = self.Data:GetBreakthroughItem() + + for index, item in ipairs(consumeItems) do + local grid = self.GridCostItems[index] + if not grid then + local ui = CS.UnityEngine.Object.Instantiate(self.GridCostItem) + grid = XUiGridCostItem.New(self.Root, ui) + grid.Transform:SetParent(self.PanelCostItem, false) + self.GridCostItems[index] = grid + end + grid.GameObject:SetActiveEx(true) + grid:Refresh(item.Id, item.Count) + end + + for i = #consumeItems + 1, #self.GridCostItems do + self.GridCostItems[i].GameObject:SetActiveEx(false) + end +end + +function XUiPanelLevelBreak:SetButtonCallBack() + self.BtnBreak.CallBack = function() + self:OnBtnBreakClick() + end +end + +function XUiPanelLevelBreak:OnBtnBreakClick() + local nextBreakthrough = self.Data:GetBreakthrough() + 1 + local nextLevelLimit = self.Data:GetBreakthroughLevelLimit(nextBreakthrough) + local preAttrMap = self.Data:GetBreakthroughPromotedAttrMap(nextBreakthrough) + local curAttrMap = self.Data:GetBreakthroughPromotedAttrMap() + XDataCenter.PartnerManager.PartnerBreakThroughRequest(self.Data:GetId(), function () + local exBreakthrough = self.Data:GetBreakthrough() - 1 + local viewCurLevelLimit = self.Data:GetBreakthroughLevelLimit() + local viewCurAttrMap = self.Data:GetBreakthroughPromotedAttrMap() + local viewExAttrMap = self.Data:GetBreakthroughPromotedAttrMap(exBreakthrough) + XLuaUiManager.Open("UiEquipBreakThroughPopUp", viewCurLevelLimit, viewExAttrMap, viewCurAttrMap, function() + self.Base:UpdatePanel(self.Data) + end) + end) +end + +return XUiPanelLevelBreak \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerLevel/XUiPanelLevelMax.lua b/Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerLevel/XUiPanelLevelMax.lua new file mode 100644 index 00000000..d2d5e511 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerLevel/XUiPanelLevelMax.lua @@ -0,0 +1,51 @@ +local XUiPanelLevelMax = XClass(nil, "XUiPanelLevelMax") +local XUiGridPartnerAttrib = require("XUi/XUiPartner/PartnerCommon/XUiGridPartnerAttrib") + +function XUiPanelLevelMax:Ctor(ui, base, root) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Base = base + self.Root = root + self.AttrGridList = {} + XTool.InitUiObject(self) + self.GridLevelChange.gameObject:SetActiveEx(false) +end + +function XUiPanelLevelMax:UpdatePanel(data)---刷新掉这个 + self.Data = data + self:UpdatePartnerInfo() + self.GameObject:SetActiveEx(true) +end + +function XUiPanelLevelMax:HidePanel() + self.GameObject:SetActiveEx(false) +end + +function XUiPanelLevelMax:UpdatePartnerInfo() + local btImg = self.Data:GetBreakthroughIcon() + + self.Txtname.text = self.Data:GetName() + self.TxtLevel.text = self.Data:GetLevel() + self.TxtLevelMax.text = string.format("/%d MAX",self.Data:GetBreakthroughLevelLimit()) + self.ImgBreak:SetSprite(btImg) + + local curAttrMap = self.Data:GetPartnerAttrMap() + for attrIndex, attrInfo in pairs(curAttrMap) do + local grid = self.AttrGridList[attrIndex] + if not grid then + local ui = CS.UnityEngine.Object.Instantiate(self.GridLevelChange) + grid = XUiGridPartnerAttrib.New(ui, attrInfo.Name, true) + grid.Transform:SetParent(self.PanelAttrParent, false) + + self.AttrGridList[attrIndex] = grid + end + grid.GameObject:SetActiveEx(true) + grid:UpdateData(attrInfo.Value) + end + + for i = #curAttrMap + 1, #self.AttrGridList do + self.AttrGridList[i].GameObject:SetActiveEx(false) + end +end + +return XUiPanelLevelMax \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerLevel/XUiPanelLevelUp.lua b/Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerLevel/XUiPanelLevelUp.lua new file mode 100644 index 00000000..f9ad6af9 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerLevel/XUiPanelLevelUp.lua @@ -0,0 +1,310 @@ +local XUiPanelLevelUp = XClass(nil, "XUiPanelLevelUp") +local XUiPanelExpBar = require("XUi/XUiSettleWinMainLine/XUiPanelExpBar") +local XUiGridPartnerAttrib = require("XUi/XUiPartner/PartnerCommon/XUiGridPartnerAttrib") +local XUiGridEquipExpItem = require("XUi/XUiEquipStrengthen/XUiGridEquipExpItem") +local CONDITION_COLOR = { + [true] = XUiHelper.Hexcolor2Color("0E70BDFF"), + [false] = CS.UnityEngine.Color.gray, +} +local CSXTextManagerGetText = CS.XTextManager.GetText +local mathMax = math.max +local mathFloor = math.floor + +function XUiPanelLevelUp:Ctor(ui, base, root) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Base = base + self.Root = root + XTool.InitUiObject(self) + + self.PreExp = 0 + self.PreLevel = 0 + self.GridAttrInfoList = {} + self.AttrGridList = {} + self.GridPartnerReplaceAttr.gameObject:SetActiveEx(false) + self.GridExpItem.gameObject:SetActiveEx(false) + self.PartnerExpBar = XUiPanelExpBar.New(self.PanelExpBar) + + self:InitDynamicTable() + self:SetButtonCallBack() +end + +function XUiPanelLevelUp:UpdatePanel(data)---刷新掉这个 + self.Data = data + self:ResetSelectedData() + self:SetupDynamicTable() + self:UpdatePartnerInfo() + self:UpdatePartnerPreView() + self.GameObject:SetActiveEx(true) +end + +function XUiPanelLevelUp:HidePanel() + self.GameObject:SetActiveEx(false) +end + +function XUiPanelLevelUp:SetButtonCallBack() + self.BtnStrengthen.CallBack = function() + self:OnBtnStrengthenClick() + end + self.BtnSource.CallBack = function() + self:OnBtnSourceClick() + end + self.BtnAllSelect.CallBack = function() + self:OnBtnAllSelectClick() + end +end + +function XUiPanelLevelUp:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelItemScroll) + self.DynamicTable:SetDelegate(self) + self.DynamicTable:SetProxy(XUiGridEquipExpItem) +end + +function XUiPanelLevelUp:SetupDynamicTable() + self.ItemIdList = XDataCenter.PartnerManager.GetCanEatItemIds() + self.DynamicTable:SetDataSource(self.ItemIdList) + self.DynamicTable:ReloadDataSync() +end + +function XUiPanelLevelUp:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + local addCountCb = function(itemId, addCount) + self:OnSelectItem(itemId, addCount) + end + + local addCountCheckCb = function(doNotTip) + return self:CheckCanSelect(doNotTip) + end + + grid:Init(self.Root, addCountCb, addCountCheckCb) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local itemId = self.ItemIdList[index] + local selectCount = self.SelectItemDic[itemId] or 0 + grid:Refresh(itemId, selectCount) + end +end + +function XUiPanelLevelUp:UpdatePartnerInfo() + local curLv = self.Data:GetLevel() + local maxLv = self.Data:GetBreakthroughLevelLimit() + local curExp = mathFloor(self.Data:GetExp()) + local maxExp = self.Data:GetLevelUpInfoExp() + + self.TxtCurLv.text = CSXTextManagerGetText("EquipStrengthenCurLevel", curLv, maxLv) + self.PartnerExpBar:PreviewExpBar(curExp, maxExp, self.PreExp) + self.TxtExp.text = string.format("%d/%d", curExp, maxExp) + self.TxtPreExp.gameObject:SetActiveEx(false) + self.PanelNone.gameObject:SetActiveEx(#self.ItemIdList <= 0) + + local curAttrMap = self.Data:GetPartnerAttrMap() + for attrIndex, attrInfo in pairs(curAttrMap) do + local attrGrid = self.AttrGridList[attrIndex] + if not attrGrid then + local ui = CS.UnityEngine.Object.Instantiate(self.GridPartnerReplaceAttr) + attrGrid = XUiGridPartnerAttrib.New(ui, attrInfo.Name, true) + attrGrid.Transform:SetParent(self.PanelAttrParent, false) + self.AttrGridList[attrIndex] = attrGrid + end + attrGrid.GameObject:SetActive(true) + attrGrid:UpdateData(attrInfo.Value) + end + + for i = #curAttrMap + 1, #self.AttrGridList do + self.AttrGridList[i].GameObject:SetActive(false) + end +end + +function XUiPanelLevelUp:UpdatePartnerPreView() + local curLv = self.Data:GetLevel() + local maxLv = self.Data:GetBreakthroughLevelLimit() + local curExp = mathFloor(self.Data:GetExp()) + + local preLevel = self.PreLevel + local preExp = mathFloor(self.PreExp) + local maxExp = self.Data:GetLevelUpInfoExp(nil, preLevel) + + local totalAddExp = self.TotalAddExp + + self.TxtCurLv.text = CSXTextManagerGetText("EquipStrengthenCurLevel", preLevel, maxLv) + self.TxtExp.text = string.format("%d/%d", preExp, maxExp) + + if preExp == 0 then + self.PartnerExpBar:PreviewExpBar(0, maxExp, preExp) + else + if curLv ~= preLevel then + self.PartnerExpBar:PreviewExpBar(0, maxExp, preExp) + else + self.PartnerExpBar:PreviewExpBar(curExp, maxExp, preExp) + end + end + + local addExp = mathFloor(totalAddExp) + if addExp > 0 then + self.TxtPreExp.text = string.format("+%d", addExp) + self.TxtPreExp.gameObject:SetActiveEx(true) + else + self.TxtPreExp.gameObject:SetActiveEx(false) + end + + local preAttrMap = self.Data:GetPartnerAttrMap(preLevel) + local curAttrMap = self.Data:GetPartnerAttrMap() + for attrIndex, attrInfo in pairs(curAttrMap) do + local preAttrInfo = preAttrMap[attrIndex] + local attrGrid = self.AttrGridList[attrIndex] + if not attrGrid then + local ui = CS.UnityEngine.Object.Instantiate(self.GridPartnerReplaceAttr) + attrGrid = XUiGridPartnerAttrib.New(ui, attrInfo.Name, true) + attrGrid.Transform:SetParent(self.PanelAttrParent, false) + self.AttrGridList[attrIndex] = attrGrid + end + attrGrid.GameObject:SetActive(true) + attrGrid:UpdateData(attrInfo.Value, preAttrInfo.Value, true) + end + + for i = #curAttrMap + 1, #self.AttrGridList do + self.AttrGridList[i].GameObject:SetActive(false) + end + + local costMoney = XDataCenter.PartnerManager.GetEatItemsCostMoney(self.SelectItemDic) + self.TxtCost.text = costMoney + self.TxtCost.color = CONDITION_COLOR[XDataCenter.ItemManager.GetCoinsNum() >= costMoney] + + local canStrengthen = next(self.SelectItemDic) + self.BtnStrengthen:SetDisable(not canStrengthen) +end + +function XUiPanelLevelUp:CheckCanSelect(doNotTip) + local preLevel = self.PreLevel + local limitLevel = self.Data:GetBreakthroughLevelLimit() + if preLevel >= limitLevel then + if not doNotTip then + XUiManager.TipMsg(CSXTextManagerGetText("EquipStrengthenMaxLevel")) + end + return false + else + return true + end +end + +function XUiPanelLevelUp:OnSelectItem(itemId, addCount) + local selectItemDic = self.SelectItemDic + local oldCount = selectItemDic[itemId] or 0 + local newCount = mathMax(0, oldCount + addCount) + selectItemDic[itemId] = newCount > 0 and newCount or nil + + local addExp = XDataCenter.ItemManager.GetItemsAddEquipExp(itemId, addCount) + self.PreLevel, self.TotalAddExp, self.PreExp = self:GetStrengthenPreData(addExp) + self:UpdatePartnerPreView() +end + +function XUiPanelLevelUp:OnBtnStrengthenClick() + XDataCenter.PartnerManager.PartnerLevelUpRequest(self.Data:GetId(), self.SelectItemDic, function() + if not self.Data:GetIsMaxBreakthrough() and self.Data:GetIsLevelMax() then + self:ShowHint(CSXTextManagerGetText("PartnerCanBreakthroughHint")) + else + self:ShowHint(CSXTextManagerGetText("PartnerUpLevelHint")) + end + end) +end + +function XUiPanelLevelUp:ShowHint(hintText) + XLuaUiManager.SetMask(true) + XLuaUiManager.Open("UiPartnerPopupTip", hintText, function () + XLuaUiManager.SetMask(false) + self.Base:UpdatePanel(self.Data) + end) +end + +function XUiPanelLevelUp:OnBtnSourceClick() + local skipIds = self.Data:GetLevelUpSkipIdList() + XLuaUiManager.Open("UiPartnerStrengthenSkip", skipIds) +end + +function XUiPanelLevelUp:OnBtnAllSelectClick() + self:AutoSelectItems() +end + +function XUiPanelLevelUp:ResetSelectedData() + self.PreLevel = self.Data:GetLevel() + self.TotalAddExp = 0 + self.PreExp = mathFloor(self.Data:GetExp()) + self.SelectItemDic = {} +end + +function XUiPanelLevelUp:GetStrengthenPreData(addExp) + local totalAddExp = self.TotalAddExp + addExp + local preExp = totalAddExp + self.Data:GetExp() + local preLevel = self.Data:GetLevel() + + local limitLevel = self.Data:GetBreakthroughLevelLimit() + while true do + local nextExp = self.Data:GetLevelUpInfoExp(nil ,preLevel) + if preExp < nextExp then + break + end + + preExp = preExp - nextExp + preLevel = preLevel + 1 + + --超出需要吃的装备个数范围检测 + if preLevel >= limitLevel then + preLevel = limitLevel + preExp = 0 + return preLevel, totalAddExp, preExp + end + end + + return preLevel, totalAddExp, preExp +end + +function XUiPanelLevelUp:AutoSelectItems() + local recommendEatItemIds = self.ItemIdList + if not next(recommendEatItemIds) then + XUiManager.TipText("PartnerStrengthenAutoSelectEmpty") + return + end + + self:ResetSelectedData() + + local costItemCount + local preLevel, totalAddExp, preExp, addExp + local doNotTip = true + for _, costItemId in ipairs(recommendEatItemIds) do + costItemCount = XDataCenter.ItemManager.GetCount(costItemId) + for costCount = 1, costItemCount do + addExp = XDataCenter.ItemManager.GetItemsAddEquipExp(costItemId, 1) + preLevel, totalAddExp, preExp = self:GetStrengthenPreData(addExp) + if not self:CheckCanSelect(doNotTip) then + break + end + + self.PreLevel, self.TotalAddExp, self.PreExp = preLevel, totalAddExp, preExp + self.SelectItemDic[costItemId] = costCount > 0 and costCount or nil + end + end + + local limitLevel = self.Data:GetBreakthroughLevelLimit() + local totalNeedExp = self.Data:GetPartnerLevelTotalNeedExp(limitLevel) + local selectCount + totalAddExp = self.TotalAddExp + for _, costItemId in ipairs(recommendEatItemIds) do + costItemCount = XDataCenter.ItemManager.GetCount(costItemId) + for _ = 1, costItemCount do + addExp = XDataCenter.ItemManager.GetItemsAddEquipExp(costItemId, -1) + if totalAddExp + addExp < totalNeedExp then + break + end + preLevel, totalAddExp, preExp = self:GetStrengthenPreData(addExp) + + self.PreLevel, self.TotalAddExp, self.PreExp = preLevel, totalAddExp, preExp + selectCount = self.SelectItemDic[costItemId] or 0 + selectCount = selectCount - 1 + self.SelectItemDic[costItemId] = selectCount > 0 and selectCount or nil + end + end + + self:UpdatePartnerPreView() + self:SetupDynamicTable() +end + +return XUiPanelLevelUp \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerLevel/XUiPanelPartnerLevel.lua b/Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerLevel/XUiPanelPartnerLevel.lua new file mode 100644 index 00000000..071401ac --- /dev/null +++ b/Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerLevel/XUiPanelPartnerLevel.lua @@ -0,0 +1,66 @@ +local XUiPanelPartnerLevel = XClass(nil, "XUiPanelPartnerLevel") +local XUiPanelLevelUp = require("XUi/XUiPartner/PartnerProperty/PanelPartnerLevel/XUiPanelLevelUp") +local XUiPanelLevelBreak = require("XUi/XUiPartner/PartnerProperty/PanelPartnerLevel/XUiPanelLevelBreak") +local XUiPanelLevelMax = require("XUi/XUiPartner/PartnerProperty/PanelPartnerLevel/XUiPanelLevelMax") + +local panelState = { + LevelUp = 1, + LevelBreak = 2, + LevelMax = 3, + } + +function XUiPanelPartnerLevel:Ctor(ui, base) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Base = base + XTool.InitUiObject(self) + self.LevelUpPanel = XUiPanelLevelUp.New(self.PanelLevelUp, self, self.Base) + self.LevelBreakPanel = XUiPanelLevelBreak.New(self.PanelLevelBreak, self, self.Base) + self.LevelMaxPanel = XUiPanelLevelMax.New(self.PanelLevelMax, self, self.Base) +end + +function XUiPanelPartnerLevel:UpdatePanel(data) + self.Data = data + self:CheckPanelState() + self:ShowPanel(data) + self.GameObject:SetActiveEx(true) + self.Base.BtnTabLevel:ShowTag(self.Data:GetIsMaxBreakthrough() and self.Data:GetIsLevelMax()) +end + +function XUiPanelPartnerLevel:HidePanel() + self.GameObject:SetActiveEx(false) +end + +function XUiPanelPartnerLevel:CheckPanelState() + if not self.Data:GetIsLevelMax() then + self.PanelState = panelState.LevelUp + else + if self.Data:GetIsMaxBreakthrough() then + self.PanelState = panelState.LevelMax + else + self.PanelState = panelState.LevelBreak + end + end +end + +function XUiPanelPartnerLevel:ShowPanel(data) + self.LevelUpPanel:HidePanel() + self.LevelBreakPanel:HidePanel() + self.LevelMaxPanel:HidePanel() + if self.PanelState == panelState.LevelUp then + self.LevelUpPanel:UpdatePanel(data) + elseif self.PanelState == panelState.LevelBreak then + self.LevelBreakPanel:UpdatePanel(data) + elseif self.PanelState == panelState.LevelMax then + self.LevelMaxPanel:UpdatePanel(data) + end + self:PlayEnableAnime() +end + +function XUiPanelPartnerLevel:PlayEnableAnime() + XScheduleManager.ScheduleOnce(function() + self.Animation:GetObject("AnimEnable"):PlayTimelineAnimation() + end, 1) +end + +return XUiPanelPartnerLevel diff --git a/Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerQuality/XUiGridCanEatPartner.lua b/Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerQuality/XUiGridCanEatPartner.lua new file mode 100644 index 00000000..b5841935 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerQuality/XUiGridCanEatPartner.lua @@ -0,0 +1,42 @@ +local XUiGridCanEatPartner = XClass(nil, "XUiGridCanEatPartner") + +function XUiGridCanEatPartner:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.IsSelect = false + XTool.InitUiObject(self) + self:SetButtonCallBack() +end + +function XUiGridCanEatPartner:SetButtonCallBack() + self.BtnAddSelect.CallBack = function() + self:OnBtnAddSelectClick() + end +end + +function XUiGridCanEatPartner:OnBtnAddSelectClick() + self.Base:SetSelectFood(self.Data, not self.IsSelect) + self:ShowSelect() +end + +function XUiGridCanEatPartner:UpdateGrid(data, base) + self.Data = data + self.Base = base + + if data then + self.RImgHeadIcon:SetRawImage(data:GetIcon()) + self.RImgQuality:SetRawImage(XCharacterConfigs.GetCharacterQualityIcon(data:GetQuality())) + self.ImgBreak:SetSprite(data:GetBreakthroughIcon()) + self.TxtLevel.text = data:GetLevel() + self.Txtname.text = data:GetName() + self:ShowSelect() + end + +end + +function XUiGridCanEatPartner:ShowSelect() + self.IsSelect = self.Base:CheckIsSelectFood(self.Data:GetId()) + self.ImgSelect.gameObject:SetActiveEx(self.IsSelect) +end + +return XUiGridCanEatPartner \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerQuality/XUiPanelPartnerQuality.lua b/Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerQuality/XUiPanelPartnerQuality.lua new file mode 100644 index 00000000..11109b37 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerQuality/XUiPanelPartnerQuality.lua @@ -0,0 +1,110 @@ +local XUiPanelPartnerQuality = XClass(nil, "XUiPanelPartnerQuality") +local XUiPanelQualityUp = require("XUi/XUiPartner/PartnerProperty/PanelPartnerQuality/XUiPanelQualityUp") +local XUiPanelQualityStar = require("XUi/XUiPartner/PartnerProperty/PanelPartnerQuality/XUiPanelQualityStar") +local XUiPanelQualityMax = require("XUi/XUiPartner/PartnerProperty/PanelPartnerQuality/XUiPanelQualityMax") +local XUiPanelQualityUpConfirm = require("XUi/XUiPartner/PartnerProperty/PanelPartnerQuality/XUiPanelQualityUpConfirm") + +local panelState = { + QualityStar = 1, + QualityUp = 2, + QualityMax = 3, + QualityUpConfirm = 4, +} + +function XUiPanelPartnerQuality:Ctor(ui, base) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Base = base + self.IsQualityUpFinish = false + XTool.InitUiObject(self) + self.QualityUpPanel = XUiPanelQualityUp.New(self.PanelQualityUp, self, self.Base) + self.QualityStarPanel = XUiPanelQualityStar.New(self.PanelQualityStar, self, self.Base) + self.QualityMaxPanel = XUiPanelQualityMax.New(self.PanelQualityMax, self, self.Base) + self.QualityUpConfirmPanel = XUiPanelQualityUpConfirm.New(self.PanelQualityUpConfirm, self, self.Base) +end + +function XUiPanelPartnerQuality:UpdatePanel(data) + self.Data = data + self:CheckPanelState() + self:ShowPanel(data) + self.GameObject:SetActiveEx(true) + self.Base.BtnTabQuality:ShowTag(self.Data:GetIsMaxQuality()) +end + +function XUiPanelPartnerQuality:HidePanel() + self.GameObject:SetActiveEx(false) +end + +function XUiPanelPartnerQuality:CheckPanelState() + if self.IsQualityUpFinish then + self.PanelState = panelState.QualityUpConfirm + else + if self.Data:GetIsMaxQuality() then + self.PanelState = panelState.QualityMax + else + if not self.Data:GetCanUpQuality() then + self.PanelState = panelState.QualityStar + else + self.PanelState = panelState.QualityUp + end + end + end +end + +function XUiPanelPartnerQuality:ShowPanel(data) + self.QualityUpPanel:HidePanel() + self.QualityStarPanel:HidePanel() + self.QualityMaxPanel:HidePanel() + self.QualityUpConfirmPanel:HidePanel() + + if self.PanelState == panelState.QualityStar then + self.QualityStarPanel:UpdatePanel(data) + elseif self.PanelState == panelState.QualityUp then + self.QualityUpPanel:UpdatePanel(data) + elseif self.PanelState == panelState.QualityMax then + self.QualityMaxPanel:UpdatePanel(data) + elseif self.PanelState == panelState.QualityUpConfirm then + self.QualityUpConfirmPanel:UpdatePanel(data) + end + + if self.PanelState == panelState.QualityStar then + self:HideRoleModel() + else + self:ShowRoleModel() + end + + self:PlayEnableAnime() +end + +function XUiPanelPartnerQuality:SetQualityUpFinish(IsFinish) + self.IsQualityUpFinish = IsFinish +end + +function XUiPanelPartnerQuality:ShowRoleModel() + self.Base:ShowRoleModel() +end + +function XUiPanelPartnerQuality:HideRoleModel() + self.Base:HideRoleModel() +end + +function XUiPanelPartnerQuality:PlayEnableAnime() + XScheduleManager.ScheduleOnce(function() + if self.PanelState == panelState.QualityStar then + self.Animation:GetObject("PanelQualityStarEnable"):PlayTimelineAnimation() + self.Animation:GetObject("PanelQualityStarLoop").gameObject:SetActiveEx(false) + self.Animation:GetObject("PanelQualityStarLoop").gameObject:SetActiveEx(true) + elseif self.PanelState == panelState.QualityUp then + self.Animation:GetObject("PanelQualityUpEnable"):PlayTimelineAnimation() + elseif self.PanelState == panelState.QualityMax then + self.Animation:GetObject("PanelQualityMaxEnable"):PlayTimelineAnimation() + elseif self.PanelState == panelState.QualityUpConfirm then + XLuaUiManager.SetMask(true) + self.Animation:GetObject("PanelQualityUpConfirmEnable"):PlayTimelineAnimation(function () + XLuaUiManager.SetMask(false) + end) + end + end, 1) +end + +return XUiPanelPartnerQuality diff --git a/Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerQuality/XUiPanelQualityMax.lua b/Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerQuality/XUiPanelQualityMax.lua new file mode 100644 index 00000000..4de894b5 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerQuality/XUiPanelQualityMax.lua @@ -0,0 +1,27 @@ +local XUiPanelQualityMax = XClass(nil, "XUiPanelQualityMax") + +function XUiPanelQualityMax:Ctor(ui, base, root) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Base = base + self.Root = root + XTool.InitUiObject(self) +end + +function XUiPanelQualityMax:UpdatePanel(data)---刷新掉这个 + self.Data = data + self:UpdatePartnerInfo() + self.GameObject:SetActiveEx(true) +end + +function XUiPanelQualityMax:HidePanel() + self.GameObject:SetActiveEx(false) +end + +function XUiPanelQualityMax:UpdatePartnerInfo() + local icon = XCharacterConfigs.GetCharacterQualityIcon(self.Data:GetQuality()) + self.TxtCount.text = self.Data:GetQualitySkillColumnCount() + self.RawImageQuality:SetRawImage(icon) +end + +return XUiPanelQualityMax \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerQuality/XUiPanelQualityStar.lua b/Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerQuality/XUiPanelQualityStar.lua new file mode 100644 index 00000000..50b5c585 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerQuality/XUiPanelQualityStar.lua @@ -0,0 +1,205 @@ +local XUiPanelQualityStar = XClass(nil, "XUiPanelQualityStar") +local XUiGridCanEatPartner = require("XUi/XUiPartner/PartnerProperty/PanelPartnerQuality/XUiGridCanEatPartner") +local DOFillTime = 0.5 +local STAR_COLOR = { + [true] = XUiHelper.Hexcolor2Color("0F70BCFF"), + [false] = XUiHelper.Hexcolor2Color("6A6A6AFF"), +} + +function XUiPanelQualityStar:Ctor(ui, base, root) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Base = base + self.Root = root + self.SelectFoodDic = {} + + XTool.InitUiObject(self) + self:InitPanelStarPoint() + self:InitDynamicTable() + self:InitPanelItems() +end + +function XUiPanelQualityStar:InitPanelStarPoint() + self.StarList = { + self.PanelStarPoint:GetObject("Point1"), + self.PanelStarPoint:GetObject("Point2"), + self.PanelStarPoint:GetObject("Point3"), + self.PanelStarPoint:GetObject("Point4"), + self.PanelStarPoint:GetObject("Point5"), + } + + self.PanelStarPoint:GetObject("ProgressCircle").fillAmount = 0 + self.PanelStarPoint:GetObject("ProgressCirclePreview").fillAmount = 0 +end + +function XUiPanelQualityStar:InitPanelItems() + self.PanelItems:GetObject("BtnUpgrade").CallBack = function() + self:OnBtnUpgradeClick() + end + + self.PanelItems:GetObject("BtnSource").CallBack = function() + self:OnBtnSourceClick() + end +end + +function XUiPanelQualityStar:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelItems:GetObject("SffViewItem")) + self.DynamicTable:SetProxy(XUiGridCanEatPartner) + self.DynamicTable:SetDelegate(self) + self.PanelItems:GetObject("GridEatItem").gameObject:SetActiveEx(false) +end + +function XUiPanelQualityStar:OnBtnUpgradeClick() + local list = {} + local IsNotTraining = true + for _,entity in pairs(self.SelectFoodDic)do + table.insert(list, entity:GetId()) + if not entity:GetIsNotTraining() then + IsNotTraining = false + end + end + + if not IsNotTraining then + XDataCenter.PartnerManager.TipDialog(nil,function () + self:DoStarActivate(list) + end,"PartnerIsTrainingHint") + else + self:DoStarActivate(list) + end +end + +function XUiPanelQualityStar:DoStarActivate(list) + XDataCenter.PartnerManager.PartnerStarActivateRequest(self.Data:GetId(), list, function () + self.Base:UpdatePanel(self.Data) + end) +end + +function XUiPanelQualityStar:UpdatePanel(data)---刷新掉这个 + self.Data = data + self.SelectFoodDic = {} + self:UpdatePanelGrowUp() + self:UpdatePanelStarPoint(false) + self:SetupDynamicTable() + self.GameObject:SetActiveEx(true) +end + +function XUiPanelQualityStar:HidePanel() + self.GameObject:SetActiveEx(false) +end + +function XUiPanelQualityStar:UpdatePanelGrowUp() + local nextQuality = self.Data:GetQuality() + 1 + local icon = XCharacterConfigs.GetCharacterQualityIcon(nextQuality) + self.PanelGrowUp:GetObject("TxtSkill").text = self.Data:GetQualitySkillColumnCount() + self.PanelGrowUp:GetObject("TxtSkillNext").text = self.Data:GetQualitySkillColumnCount(nextQuality) + self.PanelGrowUp:GetObject("RawImageQuality"):SetRawImage(icon) +end + +function XUiPanelQualityStar:UpdatePanelStarPoint(IsAnime) + + local addClipCount = 0 + for _,food in pairs(self.SelectFoodDic) do + addClipCount = addClipCount + food:GetChipCurCount() + end + local exQuality = self.Data:GetQuality() - 1 + exQuality = exQuality >= self.Data:GetInitQuality() and exQuality or 0 + local exMaxClipCount = exQuality > 0 and self.Data:GetClipMaxCount(exQuality) or 0 + + local curClipCount = self.Data:GetStarSchedule() + local nextClipCount = self.Data:GetStarSchedule() + addClipCount + local maxClipCount = self.Data:GetClipMaxCount() + + local curStar = self.Data:GetCanActivateStarCount(nil, curClipCount) + local nextStar = self.Data:GetCanActivateStarCount(nil, nextClipCount) + local maxStarCount = self.Data:GetMaxStarCount() + local attribList = self.Data:GetQualityStarAttribs() + local qualityIcon = XCharacterConfigs.GetCharQualityIcon(self.Data:GetQuality()) + + self.IsSelectClipFull = nextClipCount >= maxClipCount + + local curP = (curClipCount - exMaxClipCount) / (maxClipCount - exMaxClipCount) + local needP = (nextClipCount - exMaxClipCount) / (maxClipCount - exMaxClipCount) + if IsAnime then + self.PanelStarPoint:GetObject("ProgressCircle"):DOFillAmount(curP, DOFillTime) + self.PanelStarPoint:GetObject("ProgressCirclePreview"):DOFillAmount(needP, DOFillTime) + else + self.PanelStarPoint:GetObject("ProgressCircle").fillAmount = curP + self.PanelStarPoint:GetObject("ProgressCirclePreview").fillAmount = needP + end + + self.PanelStarPoint:GetObject("BigRImgQuality"):SetRawImage(qualityIcon) + + for index = 1, maxStarCount do + local star = self.StarList[index] + if star then + local IsActivate = index <= curStar + local IsPreview = not IsActivate and (index <= nextStar) + local IsLock = not IsActivate and not IsPreview + local attrib = attribList[index] + + local attribInfoList = XDataCenter.PartnerManager.ConstructPartnerAttrMap(attrib, false, true) + for _,info in pairs(attribInfoList) do + star:GetObject("TextName").text = info.Name + star:GetObject("TextValue").text = info.Value + break + end + + star:GetObject("TextName").color = STAR_COLOR[IsActivate] + star:GetObject("TextValue").color = STAR_COLOR[IsActivate] + star:GetObject("TextPlus").color = STAR_COLOR[IsActivate] + + star:GetObject("PointLock").gameObject:SetActiveEx(IsLock) + star:GetObject("PointPreview").gameObject:SetActiveEx(IsPreview) + star:GetObject("PointActivate").gameObject:SetActiveEx(IsActivate) + end + end + + self.PanelEvolution:GetObject("TxtEvolution").text = string.format("%d/%d", nextClipCount - exMaxClipCount, maxClipCount - exMaxClipCount) +end + +function XUiPanelQualityStar:SetupDynamicTable() + self.PageDatas = XDataCenter.PartnerManager.GetPartnerQualityUpDataList(self.Data:GetId()) + XPartnerSort.EatSortFunction(self.PageDatas) + + self.PanelItems:GetObject("PanelNone").gameObject:SetActiveEx(#self.PageDatas <= 0) + self.PanelItems:GetObject("BtnSource").gameObject:SetActiveEx(#self.PageDatas <= 0) + self.PanelItems:GetObject("BtnUpgrade").gameObject:SetActiveEx(#self.PageDatas > 0) + + self.DynamicTable:SetDataSource(self.PageDatas) + self.DynamicTable:ReloadDataSync(1) +end + +function XUiPanelQualityStar:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:UpdateGrid(self.PageDatas[index], self) + end +end + +function XUiPanelQualityStar:SetSelectFood(entity, IsAdd) + if IsAdd then + if self.IsSelectClipFull then + XUiManager.TipText("PartnerAllStarCanActivate") + return + end + + if not self.SelectFoodDic[entity:GetId()] then + self.SelectFoodDic[entity:GetId()] = entity + end + else + if self.SelectFoodDic[entity:GetId()] then + self.SelectFoodDic[entity:GetId()] = nil + end + end + self:UpdatePanelStarPoint(true) +end + +function XUiPanelQualityStar:CheckIsSelectFood(id) + return self.SelectFoodDic[id] and true or false +end + +function XUiPanelQualityStar:OnBtnSourceClick() + local skipIds = self.Data:GetClipSkipIdList() + XLuaUiManager.Open("UiPartnerStrengthenSkip", skipIds) +end + +return XUiPanelQualityStar \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerQuality/XUiPanelQualityUp.lua b/Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerQuality/XUiPanelQualityUp.lua new file mode 100644 index 00000000..d307345f --- /dev/null +++ b/Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerQuality/XUiPanelQualityUp.lua @@ -0,0 +1,51 @@ +local XUiPanelQualityUp = XClass(nil, "XUiPanelQualityUp") + +local CONDITION_COLOR = { + [true] = XUiHelper.Hexcolor2Color("0E70BDFF"), + [false] = CS.UnityEngine.Color.gray, +} + +function XUiPanelQualityUp:Ctor(ui, base, root) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Base = base + self.Root = root + XTool.InitUiObject(self) + self:SetButtonCallBack() +end + +function XUiPanelQualityUp:UpdatePanel(data)---刷新掉这个 + self.Data = data + self:UpdatePartnerInfo() + self.GameObject:SetActiveEx(true) +end + +function XUiPanelQualityUp:HidePanel() + self.GameObject:SetActiveEx(false) +end + +function XUiPanelQualityUp:UpdatePartnerInfo() + local nextQuality = self.Data:GetQuality() + 1 + local icon = XCharacterConfigs.GetCharacterQualityIcon(nextQuality) + self.TxtCurCount.text = self.Data:GetQualitySkillColumnCount() + self.TxtNextCount.text = self.Data:GetQualitySkillColumnCount(nextQuality) + self.RawImageQuality:SetRawImage(icon) + local costMoney = self.Data:GetQualityEvolutionMoney().Count + self.TxtCost.text = costMoney + self.TxtCost.color = CONDITION_COLOR[XDataCenter.ItemManager.GetCoinsNum() >= costMoney] +end + +function XUiPanelQualityUp:SetButtonCallBack() + self.BtnUpgrade.CallBack = function() + self:OnBtnUpgradeClick() + end +end + +function XUiPanelQualityUp:OnBtnUpgradeClick() + XDataCenter.PartnerManager.PartnerEvolutionRequest(self.Data:GetId(), function () + self.Base:SetQualityUpFinish(true) + self.Base:UpdatePanel(self.Data) + end) +end + +return XUiPanelQualityUp \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerQuality/XUiPanelQualityUpConfirm.lua b/Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerQuality/XUiPanelQualityUpConfirm.lua new file mode 100644 index 00000000..2591d46e --- /dev/null +++ b/Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerQuality/XUiPanelQualityUpConfirm.lua @@ -0,0 +1,38 @@ +local XUiPanelQualityUpConfirm = XClass(nil, "XUiPanelQualityUpConfirm") + +function XUiPanelQualityUpConfirm:Ctor(ui, base, root) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Base = base + self.Root = root + XTool.InitUiObject(self) + self:SetButtonCallBack() +end + +function XUiPanelQualityUpConfirm:SetButtonCallBack() + self.BtnClose.CallBack = function() + self:OnBtnCloseClick() + end +end + +function XUiPanelQualityUpConfirm:UpdatePanel(data)---刷新掉这个 + self.Data = data + self:UpdatePartnerInfo(data) + self.GameObject:SetActiveEx(true) +end + +function XUiPanelQualityUpConfirm:HidePanel() + self.GameObject:SetActiveEx(false) +end + +function XUiPanelQualityUpConfirm:UpdatePartnerInfo(data) + self.IconQuality:SetRawImage(XCharacterConfigs.GetCharacterQualityIcon(data:GetQuality())) +end + +function XUiPanelQualityUpConfirm:OnBtnCloseClick(data) + self.Base:SetQualityUpFinish(false) + self.Base:UpdatePanel(self.Data) +end + + +return XUiPanelQualityUpConfirm \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerSkill/UiPartnerSkillLevelUpAll.lua b/Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerSkill/UiPartnerSkillLevelUpAll.lua new file mode 100644 index 00000000..16bc8664 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerSkill/UiPartnerSkillLevelUpAll.lua @@ -0,0 +1,195 @@ +local XUiPartnerSkillLevelUpAll = XLuaUiManager.Register(XLuaUi, "UiPartnerSkillLevelUpAll") +local CSTextManagerGetText = CS.XTextManager.GetText +local XUiGridCostItem = require("XUi/XUiEquipBreakThrough/XUiGridCostItem") +local DefaultIndex = 1 +local MAX_COUNT = 999 +local CONDITION_COLOR = { + [true] = XUiHelper.Hexcolor2Color("0E70BDFF"), + [false] = CS.UnityEngine.Color.red, +} +function XUiPartnerSkillLevelUpAll:OnStart(partner, base, root) + self.Partner = partner + self.Base = base + self.Root = root + self.SkillUpCount = 1 + self.MinCount = 1 + self.TxtSelect.text = 1 + self:SetButtonCallBack() + self:InitPanel() +end + +function XUiPartnerSkillLevelUpAll:OnDestroy() + +end + +function XUiPartnerSkillLevelUpAll:OnEnable() + +end + +function XUiPartnerSkillLevelUpAll:OnDisable() + +end + +function XUiPartnerSkillLevelUpAll:SetButtonCallBack() + self.BtnClose.CallBack = function() + self:OnBtnCloseClick() + end + self.BtnTanchuangClose.CallBack = function() + self:OnBtnCloseClick() + end + self.BtnAdd.CallBack = function() + self:OnBtnAddSelectClick() + end + self.BtnMinus.CallBack = function() + self:OnBtnMinusSelectClick() + end + self.BtnMax.CallBack = function() + self:OnBtnMaxClick() + end + self.BtnSkillUp.CallBack = function() + self:OnBtnSkillUpClick() + end + + self.TxtSelect.onValueChanged:AddListener(function() + self:OnSelectTextChange() + end) + + self.TxtSelect.onEndEdit:AddListener(function() + self:OnSelectTextInputEnd() + end) + +end + +function XUiPartnerSkillLevelUpAll:InitPanel() + self.GridCostItems = {} + self.ItemCost:GetObject("GridCostItem").gameObject:SetActiveEx(false) + self:SetSelectTextData() + self:SetCanBuyCount() + self:CheckSkillCanUp() + self:SetCanAddOrMinusBtn() +end + +function XUiPartnerSkillLevelUpAll:SetSelectTextData() + self.TxtSelect.characterLimit = 4 + self.TxtSelect.contentType = CS.UnityEngine.UI.InputField.ContentType.IntegerNumber +end + +function XUiPartnerSkillLevelUpAll:SetCanBuyCount() + self.MaxCount = self.Partner:GetSkillLevelGap() + local canBuyCount = self.MaxCount + for _, costItem in pairs(self.Partner:GetSkillUpgradeCostItem()) do + local itemCount = XDataCenter.ItemManager.GetCount(costItem.Id) + local buyCount = math.floor(itemCount / costItem.Count) + canBuyCount = math.min(buyCount, canBuyCount) + end + canBuyCount = math.max(self.MinCount, canBuyCount) + self.CanBuyCount = canBuyCount +end + +function XUiPartnerSkillLevelUpAll:OnBtnAddSelectClick() + if self.SkillUpCount + 1 > self.MaxCount then + XUiManager.TipText("PartnerSkillLevelOverFlow") + return + end + self.SkillUpCount = self.SkillUpCount + 1 + self:CheckSkillCanUp() + self.TxtSelect.text = self.SkillUpCount + self:SetCanAddOrMinusBtn() +end + +function XUiPartnerSkillLevelUpAll:OnBtnMinusSelectClick() + if self.SkillUpCount - 1 < self.MinCount then + return + end + self.SkillUpCount = self.SkillUpCount - 1 + self:CheckSkillCanUp() + self.TxtSelect.text = self.SkillUpCount + self:SetCanAddOrMinusBtn() +end + +function XUiPartnerSkillLevelUpAll:OnBtnMaxClick() + self.SkillUpCount = math.min(self.MaxCount, self.CanBuyCount) + self:CheckSkillCanUp() + self.TxtSelect.text = self.SkillUpCount + self:SetCanAddOrMinusBtn() +end + +function XUiPartnerSkillLevelUpAll:OnSelectTextChange() + if self.TxtSelect.text == nil or self.TxtSelect.text == "" then + return + end + if self.TxtSelect.text == "0" then + self.TxtSelect.text = 1 + end + local tmp = tonumber(self.TxtSelect.text) + local tmpMax = math.max(math.min(MAX_COUNT, self.MaxCount), 1) + if tmp > tmpMax then + tmp = tmpMax + self.TxtSelect.text = tmp + end + self.SkillUpCount = tmp + self:CheckSkillCanUp() +end + +function XUiPartnerSkillLevelUpAll:OnSelectTextInputEnd() + if self.TxtSelect.text == nil or self.TxtSelect.text == "" then + self.TxtSelect.text = 1 + local tmp = tonumber(self.TxtSelect.text) + self.SkillUpCount = tmp + self:CheckSkillCanUp() + end +end + +function XUiPartnerSkillLevelUpAll:OnBtnSkillUpClick() + if self.Base.IsPlayingAnim then + return + end + self.Base.IsPlayingAnim = true + XDataCenter.PartnerManager.PartnerSkillUpRequest(self.Partner:GetId(), self.SkillUpCount, function (skillUpInfo) + self:OnBtnCloseClick() + self.Base.IsPlayingAnim = false + self.Root:SetSkillUpFinish(true) + self.Root:SetSkillUpInfo(skillUpInfo) + self.Root:UpdatePanel(self.Partner) + end,function () + self.Base.IsPlayingAnim = false + end) +end + +function XUiPartnerSkillLevelUpAll:OnBtnCloseClick() + self:Close() +end + +function XUiPartnerSkillLevelUpAll:SetCanAddOrMinusBtn() + self.BtnMinus:SetDisable(self.SkillUpCount <= self.MinCount) + + self.BtnAdd:SetDisable(self.SkillUpCount >= self.MaxCount) + + self.BtnMax:SetDisable(self.MaxCount <= 1) + self.BtnMax.interactable = self.MaxCount > 1 +end + + +function XUiPartnerSkillLevelUpAll:CheckSkillCanUp() + local costMoney = self.Partner:GetSkillUpgradeMoney().Count * self.SkillUpCount + self.MoneyCost:GetObject("TxtCost").text = costMoney + self.MoneyCost:GetObject("TxtCost").color = CONDITION_COLOR[XDataCenter.ItemManager.GetCoinsNum() >= costMoney] + self.MoneyCost.gameObject:SetActiveEx(costMoney > 0) + + local consumeItems = self.Partner:GetSkillUpgradeItem() + for index,item in pairs(consumeItems)do + local grid = self.GridCostItems[index] + if not grid then + local tmpObj = self.ItemCost:GetObject("GridCostItem") + local obj = CS.UnityEngine.Object.Instantiate(tmpObj, self.ItemCost.transform) + grid = XUiGridCostItem.New(self, obj) + self.GridCostItems[index] = grid + end + grid.GameObject:SetActiveEx(true) + grid:Refresh(item.Id, item.Count * self.SkillUpCount) + end + + for i = #consumeItems + 1, #self.GridCostItems do + self.GridCostItems[i].GameObject:SetActiveEx(false) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerSkill/XUiGridSkillUp.lua b/Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerSkill/XUiGridSkillUp.lua new file mode 100644 index 00000000..ca155f16 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerSkill/XUiGridSkillUp.lua @@ -0,0 +1,47 @@ +local XUiGridSkillUp = XClass(nil, "XUiGridSkillUp") +local CSTextManagerGetText = CS.XTextManager.GetText +function XUiGridSkillUp:Ctor(ui, base) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Base = base + self.IsLock = false + XTool.InitUiObject(self) + self:SetButtonCallBack() +end + +function XUiGridSkillUp:SetButtonCallBack() + self.BtnSkill.CallBack = function() + self:OnBtnSkillClick() + end +end + +function XUiGridSkillUp:OnBtnSkillClick() + self.Base:PlaySelectAnime(self.Data:GetActiveSkillId(), function () + if self:IsMainSkill() then + XLuaUiManager.Open("UiPartnerSkillPreview", self.DataList, XPartnerConfigs.SkillType.MainSkill) + elseif self:IsPassiveSkill() then + XLuaUiManager.Open("UiPartnerSkillPreview", {self.Data}, XPartnerConfigs.SkillType.PassiveSkill) + end + end) +end + +function XUiGridSkillUp:UpdateGrid(data, dataList, type) + self.Data = data + self.DataList = dataList + self.Type = type + if data then + local level = data:GetLevelStr() + self.TxtLv.text = CSTextManagerGetText("PartnerSkillLevelEN",level) + self.SkillIcon:SetRawImage(data:GetSkillIcon()) + end +end + +function XUiGridSkillUp:IsMainSkill() + return self.Type == XPartnerConfigs.SkillType.MainSkill +end + +function XUiGridSkillUp:IsPassiveSkill() + return self.Type == XPartnerConfigs.SkillType.PassiveSkill +end + +return XUiGridSkillUp \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerSkill/XUiPanelAnimationControl.lua b/Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerSkill/XUiPanelAnimationControl.lua new file mode 100644 index 00000000..a8ed31c3 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerSkill/XUiPanelAnimationControl.lua @@ -0,0 +1,114 @@ +local XUiPanelAnimationControl = XClass(nil, "XUiPanelAnimationControl") +local FirstIndex = 1 +local LastIndex = 6 +function XUiPanelAnimationControl:Ctor(ui, base, root) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Base = base + self.Root = root + XTool.InitUiObject(self) + self:InitPanel() +end + +function XUiPanelAnimationControl:InitPanel() + self.RandomEnableAnimeList = { + self.MainSkillAnime:GetObject("MainSkillPosEnable"), + self.PassiveSkillAnime1:GetObject("PassiveSkillPosEnable"), + self.PassiveSkillAnime2:GetObject("PassiveSkillPosEnable"), + self.PassiveSkillAnime3:GetObject("PassiveSkillPosEnable"), + self.PassiveSkillAnime4:GetObject("PassiveSkillPosEnable"), + self.PassiveSkillAnime5:GetObject("PassiveSkillPosEnable")} + + self.RandomSelectedAnimeList = { + self.MainSkillAnime:GetObject("ImgColor"), + self.PassiveSkillAnime1:GetObject("ImgColor"), + self.PassiveSkillAnime2:GetObject("ImgColor"), + self.PassiveSkillAnime3:GetObject("ImgColor"), + self.PassiveSkillAnime4:GetObject("ImgColor"), + self.PassiveSkillAnime5:GetObject("ImgColor")} +end + +function XUiPanelAnimationControl:UpdatePanel() + self.RandomShowSkillAnimeList = { + self.Base.SkillUpPanel.MainSkill.GridMainSkillEnable, + self.Base.SkillUpPanel.PassiveSkillList[1].GridPassiveSkillEnable, + self.Base.SkillUpPanel.PassiveSkillList[2].GridPassiveSkillEnable, + self.Base.SkillUpPanel.PassiveSkillList[3].GridPassiveSkillEnable, + self.Base.SkillUpPanel.PassiveSkillList[4].GridPassiveSkillEnable, + self.Base.SkillUpPanel.PassiveSkillList[5].GridPassiveSkillEnable} +end + +function XUiPanelAnimationControl:GetRandomNumList(firstIndex, lastIndex) + local temp = {} + local list = {} + for i = 1, lastIndex - firstIndex + 1 do + table.insert(list, firstIndex + i - 1) + end + for i = 1, lastIndex - firstIndex + 1 do + local r = math.random(1, #list) + temp[i] = list[r] + table.remove(list, r) + end + return temp +end + +function XUiPanelAnimationControl:SetEndNum(list, endNum) + if not list then return end + + for index,num in pairs(list) do + if num == endNum then + table.remove(list, index) + break + end + end + + table.insert(list,endNum) +end + +function XUiPanelAnimationControl:PlaySkillUpAnime(endIndex, cb) + math.randomseed(os.time()) + local randomIndexList = self:GetRandomNumList(FirstIndex, LastIndex) + self:SetEndNum(randomIndexList, endIndex) + + coroutine.wrap(function() + local co = coroutine.running() + local callBack = function() coroutine.resume(co) end + + local count = 1 + local count_2_CallBack = function() + if count >= 2 then + coroutine.resume(co) + count = 1 + return + end + count = count + 1 + end + XLuaUiManager.SetMask(true) + self.ReadySkillUpRotate:PlayTimelineAnimation() + + for count,index in pairs(randomIndexList) do + if count < #randomIndexList then + self.RandomEnableAnimeList[index]:PlayTimelineAnimation(callBack) + coroutine.yield() + end + end + + self.RandomSelectedAnimeList[endIndex]:PlayTimelineAnimation(count_2_CallBack) + self.RandomShowSkillAnimeList[endIndex]:PlayTimelineAnimation(count_2_CallBack) + coroutine.yield() + + XLuaUiManager.SetMask(false) + if cb then cb() end + + end)() +end + +function XUiPanelAnimationControl:PlaySelectAnime(index, cb) + XLuaUiManager.SetMask(true) + self.RandomEnableAnimeList[index]:PlayTimelineAnimation(function () + XLuaUiManager.SetMask(false) + if cb then cb() end + end) +end + +return XUiPanelAnimationControl \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerSkill/XUiPanelPartnerSkill.lua b/Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerSkill/XUiPanelPartnerSkill.lua new file mode 100644 index 00000000..94984894 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerSkill/XUiPanelPartnerSkill.lua @@ -0,0 +1,64 @@ +local XUiPanelPartnerSkill = XClass(nil, "XUiPanelPartnerSkill") +local XUiPanelSkillUp = require("XUi/XUiPartner/PartnerProperty/PanelPartnerSkill/XUiPanelSkillUp") +local XUiPanelSkillUpConfirm = require("XUi/XUiPartner/PartnerProperty/PanelPartnerSkill/XUiPanelSkillUpConfirm") +local XUiPanelAnimationControl = require("XUi/XUiPartner/PartnerProperty/PanelPartnerSkill/XUiPanelAnimationControl") +local panelState = { + SkillUp = 1, + SkillUpConfirm = 2, +} + +function XUiPanelPartnerSkill:Ctor(ui, base) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Base = base + self.IsSkillUpFinish = false + XTool.InitUiObject(self) + self.SkillUpPanel = XUiPanelSkillUp.New(self.PanelSkillUp, self, self.Base) + self.SkillUpConfirmPanel = XUiPanelSkillUpConfirm.New(self.PanelSkillUpConfirm, self, self.Base) + self.AnimationControlPanel = XUiPanelAnimationControl.New(self.PanelAnimationControl, self, self.Base) +end + +function XUiPanelPartnerSkill:UpdatePanel(data) + self.Data = data + self:CheckPanelState() + self:ShowPanel(data) + self.GameObject:SetActiveEx(true) + self.Base.BtnTabSkill:ShowTag(self.Data:GetIsTotalSkillLevelMax()) +end + +function XUiPanelPartnerSkill:HidePanel() + self.GameObject:SetActiveEx(false) +end + +function XUiPanelPartnerSkill:CheckPanelState() + if self.IsSkillUpFinish then + self.PanelState = panelState.SkillUpConfirm + else + self.PanelState = panelState.SkillUp + end +end + +function XUiPanelPartnerSkill:ShowPanel(data) + self.SkillUpPanel:HidePanel() + self.SkillUpConfirmPanel:HidePanel() + + if self.PanelState == panelState.SkillUp then + self.SkillUpPanel:UpdatePanel(data) + self.SkillUpPanel:PlayEnableAnime() + elseif self.PanelState == panelState.SkillUpConfirm then + self.SkillUpConfirmPanel:UpdatePanel(data, self.SkillUpInfo) + self.SkillUpConfirmPanel:PlayEnableAnime() + end + + self.AnimationControlPanel:UpdatePanel() +end + +function XUiPanelPartnerSkill:SetSkillUpFinish(IsFinish) + self.IsSkillUpFinish = IsFinish +end + +function XUiPanelPartnerSkill:SetSkillUpInfo(info) + self.SkillUpInfo = info +end + +return XUiPanelPartnerSkill \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerSkill/XUiPanelSkillUp.lua b/Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerSkill/XUiPanelSkillUp.lua new file mode 100644 index 00000000..efcdb7b3 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerSkill/XUiPanelSkillUp.lua @@ -0,0 +1,191 @@ +local XUiPanelSkillUp = XClass(nil, "XUiPanelSkillUp") +local XUiGridSkillUp = require("XUi/XUiPartner/PartnerProperty/PanelPartnerSkill/XUiGridSkillUp") +local XUiGridCostItem = require("XUi/XUiEquipBreakThrough/XUiGridCostItem") +local Vector3 = CS.UnityEngine.Vector3 +local DefaultIndex = 1 +local DefaultCount = 1 +local CONDITION_COLOR = { + [true] = XUiHelper.Hexcolor2Color("0E70BDFF"), + [false] = CS.UnityEngine.Color.gray, +} + +function XUiPanelSkillUp:Ctor(ui, base, root) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Base = base + self.Root = root + XTool.InitUiObject(self) + self:SetButtonCallBack() + self.IsPlayingAnim = false + self.SkillIdToIndexDic = {} + self:InitPanelSkill() + self:InitPanelCost() +end + +function XUiPanelSkillUp:InitPanelSkill() + self.PassiveSkillPos = { + self.PassiveSkillPos1, + self.PassiveSkillPos2, + self.PassiveSkillPos3, + self.PassiveSkillPos4, + self.PassiveSkillPos5, + } + self.GridMainSkill.gameObject:SetActiveEx(false) + self.GridPassiveSkill.gameObject:SetActiveEx(false) + self.MainSkill = nil + self.PassiveSkillList = {} +end + +function XUiPanelSkillUp:InitPanelCost() + self.GridCostItems = {} + self.GridCostItem.gameObject:SetActiveEx(false) +end + +function XUiPanelSkillUp:SetButtonCallBack() + self.BtnSkillUp.CallBack = function() + self:OnBtnSkillUpClick() + end + + self.BtnSkillUpAll.CallBack = function() + self:OnBtnSkillUpAllClick() + end +end + +function XUiPanelSkillUp:UpdatePanel(data) + self.Data = data + self.GameObject:SetActiveEx(true) + + if not self.IsPlayingAnim then + self:UpdatePanelSkill(data) + self:UpdatePanelCost(data) + end +end + +function XUiPanelSkillUp:UpdatePanelSkill(data) + local mainSkillGroupList = data:GetMainSkillGroupList() + local passiveSkillEntityDic = data:GetPassiveSkillGroupEntityDic() + + for _,entity in pairs(mainSkillGroupList or {}) do--主技能共享技能等级,此处只显示装备中的主技能 + if entity:GetIsCarry() then + if not self.MainSkill then + local obj = CS.UnityEngine.Object.Instantiate(self.GridMainSkill, self.MainSkillPos) + obj.gameObject:SetActiveEx(true) + obj.transform.localPosition = Vector3.zero + self.MainSkill = XUiGridSkillUp.New(obj, self) + end + self.MainSkill:UpdateGrid(entity, mainSkillGroupList, XPartnerConfigs.SkillType.MainSkill) + self.SkillIdToIndexDic[entity:GetActiveSkillId()] = DefaultIndex + break + end + end + + local posindex = 1 + local skillIndex = 1 + for _,entity in pairs(passiveSkillEntityDic or {}) do + local skillPos = self.PassiveSkillPos[posindex] + if skillPos then + local skill = self.PassiveSkillList[skillIndex] + if not skill then + local obj = CS.UnityEngine.Object.Instantiate(self.GridPassiveSkill, skillPos) + obj.gameObject:SetActiveEx(true) + obj.transform.localPosition = Vector3.zero + skill = XUiGridSkillUp.New(obj, self) + self.PassiveSkillList[skillIndex] = skill + end + skill:UpdateGrid(entity, nil, XPartnerConfigs.SkillType.PassiveSkill) + skillIndex = skillIndex + 1 + self.SkillIdToIndexDic[entity:GetActiveSkillId()] = posindex + 1 + end + posindex = posindex + 1 + end + + for index = skillIndex, #self.PassiveSkillPos do + self.PassiveSkillPos[index].gameObject:SetActiveEx(false) + end +end + +function XUiPanelSkillUp:UpdatePanelCost(data) + local costMoney = data:GetSkillUpgradeMoney().Count + self.PanelCost:GetObject("CostCount").text = costMoney + self.PanelCost:GetObject("CostCount").color = CONDITION_COLOR[XDataCenter.ItemManager.GetCoinsNum() >= costMoney] + self.PanelCost.gameObject:SetActiveEx(costMoney > 0) + + local consumeItems = data:GetSkillUpgradeItem() + for index,item in pairs(consumeItems)do + local grid = self.GridCostItems[index] + if not grid then + local obj = CS.UnityEngine.Object.Instantiate(self.GridCostItem, self.PanelCostItem) + grid = XUiGridCostItem.New(self.Root, obj) + self.GridCostItems[index] = grid + end + grid.GameObject:SetActiveEx(true) + grid:Refresh(item.Id, item.Count) + end + + for i = #consumeItems + 1, #self.GridCostItems do + self.GridCostItems[i].GameObject:SetActiveEx(false) + end +end + +function XUiPanelSkillUp:HidePanel() + self.GameObject:SetActiveEx(false) +end + +function XUiPanelSkillUp:PlayEnableAnime() + if not self.IsPlayingAnim then + XScheduleManager.ScheduleOnce(function() + XLuaUiManager.SetMask(true) + self.SkillUpEnable.gameObject:PlayTimelineAnimation(function () + XLuaUiManager.SetMask(false) + end) + self.PassiveSkillPosLoop.gameObject:SetActiveEx(false) + self.PassiveSkillPosLoop.gameObject:SetActiveEx(true) + end, 1) + end +end + +function XUiPanelSkillUp:OnBtnSkillUpClick() + if self.IsPlayingAnim then + return + end + self.IsPlayingAnim = true + local animeCb = function(skillUpInfo) + self.IsPlayingAnim = false + self.Base:SetSkillUpFinish(true) + self.Base:SetSkillUpInfo(skillUpInfo) + self.Base:UpdatePanel(self.Data) + end + + XDataCenter.PartnerManager.PartnerSkillUpRequest(self.Data:GetId(), DefaultCount, function (skillUpInfo) + local skillId = skillUpInfo[DefaultIndex].SkillId + self:PlayAnime(skillId, function () + animeCb(skillUpInfo) + end) + end, function () + self.IsPlayingAnim = false + end) +end + +function XUiPanelSkillUp:OnBtnSkillUpAllClick() + XLuaUiManager.Open("UiPartnerSkillLevelUpAll", self.Data, self, self.Base) +end + +function XUiPanelSkillUp:PlayAnime(skillId, cb) + local index = self.SkillIdToIndexDic[skillId] + if index then + self.Base.AnimationControlPanel:PlaySkillUpAnime(index ,cb) + else + if cb then cb() end + end +end + +function XUiPanelSkillUp:PlaySelectAnime(skillId, cb) + local index = self.SkillIdToIndexDic[skillId] + if index then + self.Base.AnimationControlPanel:PlaySelectAnime(index ,cb) + else + if cb then cb() end + end +end + +return XUiPanelSkillUp \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerSkill/XUiPanelSkillUpConfirm.lua b/Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerSkill/XUiPanelSkillUpConfirm.lua new file mode 100644 index 00000000..8eafc595 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerSkill/XUiPanelSkillUpConfirm.lua @@ -0,0 +1,69 @@ +local XUiPanelSkillUpConfirm = XClass(nil, "XUiPanelSkillUpConfirm") +local CSTextManagerGetText = CS.XTextManager.GetText +function XUiPanelSkillUpConfirm:Ctor(ui, base, root) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Base = base + self.Root = root + XTool.InitUiObject(self) + self.GirdSkill.gameObject:SetActiveEx(false) + self.GirdSkillList = {} + self:SetButtonCallBack() +end + +function XUiPanelSkillUpConfirm:UpdatePanel(data, skillUpInfo) + self.Data = data + self.GameObject:SetActiveEx(true) + self:UpdatePartnerInfo(data, skillUpInfo) +end + +function XUiPanelSkillUpConfirm:HidePanel() + self.GameObject:SetActiveEx(false) +end + +function XUiPanelSkillUpConfirm:PlayEnableAnime() + XScheduleManager.ScheduleOnce(function() + XLuaUiManager.SetMask(true) + self.PanelSkillUpConfirmEnable.gameObject:PlayTimelineAnimation(function () + XLuaUiManager.SetMask(false) + end) + end, 1) +end + +function XUiPanelSkillUpConfirm:UpdatePartnerInfo(data, skillUpInfo) + for index,info in pairs(skillUpInfo or {}) do + local grid = self.GirdSkillList[index] + if not grid then + grid = CS.UnityEngine.Object.Instantiate(self.GirdSkill, self.PanelSkill) + self.GirdSkillList[index] = grid + end + grid.gameObject:SetActiveEx(true) + self:UpdataGridSkill(grid, data, info) + end + + for i = #skillUpInfo + 1, #self.GirdSkillList do + self.GirdSkillList[i].gameObject:SetActiveEx(false) + end +end + +function XUiPanelSkillUpConfirm:UpdataGridSkill(grid, data, info) + local uiObj = grid.transform:GetComponent("UiObject") + local skillEntity = data:GetSkillById(info.SkillId) + uiObj:GetObject("SkillIcon"):SetRawImage(skillEntity:GetSkillIcon(nil, info.CurrentLevel)) + uiObj:GetObject("NameText").text = skillEntity:GetSkillName(nil, info.CurrentLevel) + uiObj:GetObject("TxtLevel").text = CSTextManagerGetText("PartnerSkillLevelEN",info.CurrentLevel) + uiObj:GetObject("TxtMax").gameObject:SetActiveEx(false) +end + +function XUiPanelSkillUpConfirm:SetButtonCallBack() + self.BtnClose.CallBack = function() + self:OnBtnCloseClick() + end +end + +function XUiPanelSkillUpConfirm:OnBtnCloseClick() + self.Base:SetSkillUpFinish(false) + self.Base:UpdatePanel(self.Data) +end + +return XUiPanelSkillUpConfirm \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerStory/XUiGridStoryInfo.lua b/Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerStory/XUiGridStoryInfo.lua new file mode 100644 index 00000000..401c5343 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerStory/XUiGridStoryInfo.lua @@ -0,0 +1,38 @@ +local XUiGridStoryInfo = XClass(nil, "XUiGridStoryInfo") +local ArrowDown = CS.UnityEngine.Vector3.one +local ArrowUp = CS.UnityEngine.Vector3(1, -1, 1) +local GridState = {Close = false ,Open = true} + +function XUiGridStoryInfo:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) +end + +function XUiGridStoryInfo:UpdateGrid(data, storyGridState) + self.Data = data + + local IsLock = data:GetIsLock() + self.InfoLock.gameObject:SetActiveEx(IsLock) + self.InfoNor.gameObject:SetActiveEx(not IsLock) + + self.TxtLock.text = data:GetConditionDesc() + self.TxtTitle.text = data:GetTitle() + self.TxtLockTitle.text = data:GetTitle() + self.TxtInfo.text = string.gsub(data:GetText(), "\\n", "\n") + + local tmpGridState = storyGridState[data:GetId()] + self.ImgContent.gameObject:SetActiveEx(tmpGridState == GridState.Open and not IsLock) + + if tmpGridState == GridState.Open then + self.ImgArrow.transform.localScale = ArrowUp + else + self.ImgArrow.transform.localScale = ArrowDown + end + + self.ImgContentLayoutNode:SetDirty() + self.GridLayoutNode:SetDirty() +end + +return XUiGridStoryInfo \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerStory/XUiPanelPartnerStory.lua b/Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerStory/XUiPanelPartnerStory.lua new file mode 100644 index 00000000..208ec0d8 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPartner/PartnerProperty/PanelPartnerStory/XUiPanelPartnerStory.lua @@ -0,0 +1,78 @@ +local XUiPanelPartnerStory = XClass(nil, "XUiPanelPartnerStory") +local XUiGridStoryInfo = require("XUi/XUiPartner/PartnerProperty/PanelPartnerStory/XUiGridStoryInfo") + +function XUiPanelPartnerStory:Ctor(ui, base) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Base = base + XTool.InitUiObject(self) + self:InitDynamicTable() +end + +function XUiPanelPartnerStory:UpdatePanel(data) + self.Data = data + self.StoryGridState = {} + self:SetupDynamicTable(data) + self.GameObject:SetActiveEx(true) + self:PlayEnableAnime() +end + +function XUiPanelPartnerStory:HidePanel() + self.GameObject:SetActiveEx(false) +end + +function XUiPanelPartnerStory:InitDynamicTable() + self.DynamicTable = XDynamicTableIrregular.New(self.PanelDataList) + self.DynamicTable:SetDynamicEventDelegate(function(event, index, grid) + self:OnDynamicTableEvent(event, index, grid) + end) + self.DynamicTable:SetProxy("XUiGridStoryInfo", XUiGridStoryInfo, self.GridStoryInfo.gameObject) + self.DynamicTable:SetDelegate(self) + self.GridStoryInfo.gameObject:SetActiveEx(false) +end + +function XUiPanelPartnerStory:GetProxyType() + return "XUiGridStoryInfo" +end + +function XUiPanelPartnerStory:SetupDynamicTable(data) + XScheduleManager.ScheduleOnce(function()--异形屏适配需要 + self.PageDatas = data:GetStoryEntityList() + self.DynamicTable:SetDataSource(self.PageDatas) + self.DynamicTable:ReloadDataSync(1) + end, 1) + +end + +function XUiPanelPartnerStory:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:UpdateGrid(self.PageDatas[index],self.StoryGridState) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + self:OnGridClick(self.PageDatas[index]) + end +end + +function XUiPanelPartnerStory:OnGridClick(storyData) + if storyData:GetIsLock() then + XUiManager.TipMsg(storyData:GetConditionDesc()) + return + end + if storyData then + if self.OldId and self.OldId ~= storyData:GetId() then + self.StoryGridState[self.OldId] = false + end + self.StoryGridState[storyData:GetId()] = self.StoryGridState[storyData:GetId()] or false + self.StoryGridState[storyData:GetId()] = not self.StoryGridState[storyData:GetId()] + self.DynamicTable:ReloadDataSync() + self.OldId = storyData:GetId() + end + +end + +function XUiPanelPartnerStory:PlayEnableAnime() + XScheduleManager.ScheduleOnce(function() + self.Animation:GetObject("AnimEnable"):PlayTimelineAnimation() + end, 1) +end + +return XUiPanelPartnerStory diff --git a/Resources/Scripts/XUi/XUiPartner/PartnerProperty/XUiPartnerProperty.lua b/Resources/Scripts/XUi/XUiPartner/PartnerProperty/XUiPartnerProperty.lua new file mode 100644 index 00000000..c3a7f83b --- /dev/null +++ b/Resources/Scripts/XUi/XUiPartner/PartnerProperty/XUiPartnerProperty.lua @@ -0,0 +1,129 @@ +local XUiPanelPartnerLevel = require("XUi/XUiPartner/PartnerProperty/PanelPartnerLevel/XUiPanelPartnerLevel") +local XUiPanelPartnerQuality = require("XUi/XUiPartner/PartnerProperty/PanelPartnerQuality/XUiPanelPartnerQuality") +local XUiPanelPartnerSkill = require("XUi/XUiPartner/PartnerProperty/PanelPartnerSkill/XUiPanelPartnerSkill") +local XUiPanelPartnerStory = require("XUi/XUiPartner/PartnerProperty/PanelPartnerStory/XUiPanelPartnerStory") +local XUiPartnerProperty = XLuaUiManager.Register(XLuaUi, "UiPartnerProperty") +local CSTextManagerGetText = CS.XTextManager.GetText +local DefaultIndex = 1 + +local PANEL_INDEX = { + Level = 1, + Quality = 2, + Skill = 3, + Story = 4, +} + +function XUiPartnerProperty:OnStart(base, data, index) + self.Base = base + self.Data = data + self.SelectedIndex = index or DefaultIndex + self.PanelsMap = {} + self:InitChildUiInfos() + self:InitBtnTabGroup() +end + +function XUiPartnerProperty:OnDestroy() + +end + +function XUiPartnerProperty:OnEnable() + +end + +function XUiPartnerProperty:OnDisable() + self.SelectedIndex = DefaultIndex +end + +function XUiPartnerProperty:InitChildUiInfos() + self.ChildUiInitInfos = { + [PANEL_INDEX.Level] = { + ChildClass = XUiPanelPartnerLevel, + UiParent = self.PanelPartnerLevel, + AssetPath = XUiConfigs.GetComponentUrl("UiPanelPartnerLevel"), + }, + [PANEL_INDEX.Quality] = { + ChildClass = XUiPanelPartnerQuality, + UiParent = self.PanelPartnerQuality, + AssetPath = XUiConfigs.GetComponentUrl("UiPanelPartnerQuality"), + }, + [PANEL_INDEX.Skill] = { + ChildClass = XUiPanelPartnerSkill, + UiParent = self.PanelPartneSkill, + AssetPath = XUiConfigs.GetComponentUrl("UiPanelPartnerSkill"), + }, + [PANEL_INDEX.Story] = { + ChildClass = XUiPanelPartnerStory, + UiParent = self.PanelPartnerStory, + AssetPath = XUiConfigs.GetComponentUrl("UiPanelPartnerStory"), + }, + } +end + +function XUiPartnerProperty:InitBtnTabGroup() + local tabGroup = { + [PANEL_INDEX.Level] = self.BtnTabLevel, + [PANEL_INDEX.Quality] = self.BtnTabQuality, + [PANEL_INDEX.Skill] = self.BtnTabSkill, + [PANEL_INDEX.Story] = self.BtnTabStory, + } + self.PanelPropertyButtons:Init(tabGroup, function(tabIndex) self:OnClickTabCallBack(tabIndex) end) +end + +function XUiPartnerProperty:UpdatePanel(data) + self.Data = data + self.BtnTabLevel:ShowTag(self.Data:GetIsMaxBreakthrough()) + self.BtnTabQuality:ShowTag(self.Data:GetIsMaxQuality()) + self.BtnTabSkill:ShowTag(self.Data:GetIsTotalSkillLevelMax()) + self.BtnTabStory:ShowTag(false) + self.PanelPropertyButtons:SelectIndex(self.SelectedIndex) +end + +function XUiPartnerProperty:OnClickTabCallBack(tabIndex) + if tabIndex == PANEL_INDEX.Level then + --self.PlayAnimation("LevelBegan") + self.Base:SetCameraType(XPartnerConfigs.CameraType.Level) + elseif tabIndex == PANEL_INDEX.Quality then + --self.PlayAnimation("AniPanelGradesBegin") + self.Base:SetCameraType(XPartnerConfigs.CameraType.Quality) + elseif tabIndex == PANEL_INDEX.Skill then + --self.PlayAnimation("AniPanelQualityBegin") + self.Base:SetCameraType(XPartnerConfigs.CameraType.Skill) + elseif tabIndex == PANEL_INDEX.Story then + --self.PlayAnimation("SkillBegan") + self.Base:SetCameraType(XPartnerConfigs.CameraType.Story) + end + + if tabIndex == PANEL_INDEX.Skill then + self:HideRoleModel() + else + self:ShowRoleModel() + end + + self.SelectedIndex = tabIndex + self:UpdateShowPanel(tabIndex) +end + +function XUiPartnerProperty:UpdateShowPanel(tabIndex) + for k, panel in pairs(self.PanelsMap) do + if k ~= tabIndex then + panel:HidePanel() + end + end + + local panel = self.PanelsMap[tabIndex] + if not panel then + local childUiInfo = self.ChildUiInitInfos[tabIndex] + local ui = childUiInfo.UiParent:LoadPrefab(childUiInfo.AssetPath) + panel = childUiInfo.ChildClass.New(ui, self) + self.PanelsMap[tabIndex] = panel + end + panel:UpdatePanel(self.Data) +end + +function XUiPartnerProperty:ShowRoleModel() + self.Base:ShowRoleModel() +end + +function XUiPartnerProperty:HideRoleModel() + self.Base:HideRoleModel() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPartner/PartnerShow/XUiPanelPartnerOverview.lua b/Resources/Scripts/XUi/XUiPartner/PartnerShow/XUiPanelPartnerOverview.lua new file mode 100644 index 00000000..378a71aa --- /dev/null +++ b/Resources/Scripts/XUi/XUiPartner/PartnerShow/XUiPanelPartnerOverview.lua @@ -0,0 +1,73 @@ +local XUiPartnerShowSkillGrid = require("XUi/XUiPartner/PartnerShow/XUiPartnerShowSkillGrid") +local XUiPanelPartnerOverview = XClass(nil, "XUiPanelPartnerOverview") + +function XUiPanelPartnerOverview:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + -- XPartner + self.Partner = nil + -- XUiPartnerShowSkillGrid list + self.PassiveSkillGrids = {} + -- XPartnerMainSkillGroup + self.MainSkill = nil + self.OpenPassiveSkillDetailUiFunc = nil + XTool.InitUiObject(self) + self:RegisterUiEvents() +end + +-- partner : XPartner +function XUiPanelPartnerOverview:SetData(partner, openPassiveSkillDetailUiFunc) + self.Partner = partner + self.OpenPassiveSkillDetailUiFunc = openPassiveSkillDetailUiFunc + -- 伙伴名字 + self.TxtName.text = partner:GetName() + -- 伙伴战力参数 + self.TxtAbility.text = partner:GetAbility() + -- 伙伴类型 + self.TxtType.text = partner:GetDesc() + -- 伙伴阶级 + self.ImgBreakthrough:SetSprite(partner:GetBreakthroughIcon()) + -- 主动技能 + self:RefreshMainSkill() + -- 被动技能 + self:RefreshPassiveSkills() +end + +--########################## 私有方法 ############################## + +function XUiPanelPartnerOverview:RegisterUiEvents() + self.BtnMainSkill.CallBack = function() self:OnMainSkillClicked() end +end + +function XUiPanelPartnerOverview:OnMainSkillClicked() + XLuaUiManager.Open("UiPanelPartnerShowMainSkill", self.MainSkill, self.Partner) +end + +-- 刷新伙伴主技能 +function XUiPanelPartnerOverview:RefreshMainSkill() + local mainSkillList = self.Partner:GetCarryMainSkillGroupList() + self.MainSkill = mainSkillList[1] + if not self.MainSkill then return end + self.TxtMainSkillName.text = self.MainSkill:GetSkillName() + self.TxtMainSkillLevel.text = self.MainSkill:GetLevelStr() + self.RImgMainSkillIcon:SetRawImage(self.MainSkill:GetSkillIcon()) +end + +-- 刷新伙伴被动技能 +function XUiPanelPartnerOverview:RefreshPassiveSkills() + local passiveSkillList = self.Partner:GetCarryPassiveSkillGroupList() + local skillSlotCount = self.Partner:GetQualitySkillColumnCount() + local uiShowMaxSkillCount = 6 + for index = 1, uiShowMaxSkillCount do + local grid = self.PassiveSkillGrids[index] + if grid == nil then + local go = CS.UnityEngine.Object.Instantiate(self.GridPassiveSkill, self.PanelPassiveSkillContent) + grid = XUiPartnerShowSkillGrid.New(go) + self.PassiveSkillGrids[index] = grid + end + grid:SetData(passiveSkillList[index], index > skillSlotCount, index > XPartnerConfigs.PassiveSkillCount, self.OpenPassiveSkillDetailUiFunc) + end + self.GridPassiveSkill.gameObject:SetActiveEx(false) +end + +return XUiPanelPartnerOverview \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPartner/PartnerShow/XUiPanelPartnerPassiveSkill.lua b/Resources/Scripts/XUi/XUiPartner/PartnerShow/XUiPanelPartnerPassiveSkill.lua new file mode 100644 index 00000000..a0c27477 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPartner/PartnerShow/XUiPanelPartnerPassiveSkill.lua @@ -0,0 +1,21 @@ +local XUiPanelPartnerPassiveSkill = XClass(nil, "XUiPanelPartnerPassiveSkill") + +function XUiPanelPartnerPassiveSkill:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +-- skill : XPartnerPassiveSkillGroup +function XUiPanelPartnerPassiveSkill:SetData(skill) + self.GameObject:SetActiveEx(true) + self.RImgSkillIcon:SetRawImage(skill:GetSkillIcon()) + self.TxtName.text = skill:GetSkillName() + self.TxtDesc.text = skill:GetSkillDesc() +end + +function XUiPanelPartnerPassiveSkill:Close() + self.GameObject:SetActiveEx(false) +end + +return XUiPanelPartnerPassiveSkill \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPartner/PartnerShow/XUiPanelPartnerShowMainSkill.lua b/Resources/Scripts/XUi/XUiPartner/PartnerShow/XUiPanelPartnerShowMainSkill.lua new file mode 100644 index 00000000..f8841636 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPartner/PartnerShow/XUiPanelPartnerShowMainSkill.lua @@ -0,0 +1,105 @@ + +local XUiPanelPartnerShowMainSkillOption = require("XUi/XUiPartner/PartnerShow/XUiPanelPartnerShowMainSkillOption") +local XUiPanelPartnerShowMainSkillElement = require("XUi/XUiPartner/PartnerShow/XUiPanelPartnerShowMainSkillElement") +local XUiPanelPartnerShowMainSkill = XLuaUiManager.Register(XLuaUi, "UiPanelPartnerShowMainSkill") + +local ChildPanelType = { + SkillOption = 1, + SkillElement = 2, +} + +function XUiPanelPartnerShowMainSkill:OnAwake() + -- XPartnerMainSkillGroup + self.Skill = nil + -- XPartner + self.Partner = nil + -- XUiPanelPartnerShowMainSkillOption + self.UiPanelPartnerShowMainSkillOption = nil -- XUiPanelPartnerShowMainSkillOption.New(self.PanelMainSkillOption) + -- XUiPanelPartnerShowMainSkillElement + self.XUiPanelPartnerShowMainSkillElement = nil + -- ChildPanelType + self.CurrentChildPanelType = nil + -- 子面板信息配置 + self.ChillPanelInfoDic = { + [ChildPanelType.SkillOption] = { + instanceGo = self.PanelMainSkillOption, + proxy = XUiPanelPartnerShowMainSkillOption, + -- 代理参数 + proxyArgs = { + "Skill", + "Partner", + function(skill) + self:ChangeChildPanelStatus(ChildPanelType.SkillElement, skill) + end + }, + animName = "QieHuan2", + }, + [ChildPanelType.SkillElement] = { + instanceGo = self.PanelElement, + proxy = XUiPanelPartnerShowMainSkillElement, + proxyArgs = { + "Partner" + }, + animName = "QieHuan1", + }, + } + self:RegisterUiEvents() +end + +-- skill : XPartnerMainSkillGroup +-- partner : XPartner +function XUiPanelPartnerShowMainSkill:OnStart(skill, partner) + self.Skill = skill + self.Partner = partner + -- 设置默认打开的子panel + self:ChangeChildPanelStatus(ChildPanelType.SkillOption) + -- 设置面板隐藏状态 + self.PanelMainSkillOption.gameObject:SetActiveEx(true) + self.PanelElement.gameObject:SetActiveEx(false) +end + +--########################## 私有方法 ############################## + +function XUiPanelPartnerShowMainSkill:RegisterUiEvents() + self.BtnTanchuangClose.CallBack = function() + if self.CurrentChildPanelType == ChildPanelType.SkillOption then + self:Close() + else + self:ChangeChildPanelStatus(ChildPanelType.SkillOption) + end + end +end + +function XUiPanelPartnerShowMainSkill:ChangeChildPanelStatus(panelType, ...) + self.CurrentChildPanelType = panelType + -- 显示/隐藏关联子面板 + for key, data in pairs(self.ChillPanelInfoDic) do + data.instanceGo.gameObject:SetActiveEx(key == panelType) + end + local childPanelData = self.ChillPanelInfoDic[panelType] + -- 加载panel proxy + local instanceProxy = childPanelData.instanceProxy + if instanceProxy == nil then + instanceProxy = childPanelData.proxy.New(childPanelData.instanceGo) + childPanelData.instanceProxy = instanceProxy + end + -- 加载proxy参数 + local proxyArgs = {} + if childPanelData.proxyArgs then + for _, argName in ipairs(childPanelData.proxyArgs) do + if type(argName) == "string" then + proxyArgs[#proxyArgs + 1] = self[argName] + else + proxyArgs[#proxyArgs + 1] = argName + end + end + end + proxyArgs = XTool.MergeArray(proxyArgs, {...}) + instanceProxy:SetData(table.unpack(proxyArgs)) + -- 播放ui进场动画 + if childPanelData.animName then + XScheduleManager.ScheduleOnce(function() + self:PlayAnimation(childPanelData.animName) + end, 1) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPartner/PartnerShow/XUiPanelPartnerShowMainSkillElement.lua b/Resources/Scripts/XUi/XUiPartner/PartnerShow/XUiPanelPartnerShowMainSkillElement.lua new file mode 100644 index 00000000..65d7e852 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPartner/PartnerShow/XUiPanelPartnerShowMainSkillElement.lua @@ -0,0 +1,72 @@ +--########################## XUiGridPartnerShowMainSkillElement ############################## +local XUiGridPartnerShowMainSkillElement = XClass(nil, "XUiGridPartnerShowMainSkillElement") + +function XUiGridPartnerShowMainSkillElement:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +-- skill : XPartnerMainSkillGroup +function XUiGridPartnerShowMainSkillElement:DynamicSetData(skill, isSelected) + local elementConfig = XCharacterConfigs.GetCharElement(skill:GetActiveElement()) + self.Activate.gameObject:SetActiveEx(isSelected) + self.Normal.gameObject:SetActiveEx(not isSelected) + local rootPanel = isSelected and self.Activate or self.Normal + rootPanel:GetObject("TxtContent").text = skill:GetSkillDesc() + rootPanel:GetObject("RImgIcon"):SetRawImage(elementConfig.Icon2) + rootPanel:GetObject("TxtName").text = elementConfig.ElementName +end + +--########################## XUiPanelPartnerShowMainSkillElement ############################## +local XUiPanelPartnerShowMainSkillElement = XClass(nil, "XUiPanelPartnerShowMainSkillElement") + +function XUiPanelPartnerShowMainSkillElement:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + -- XPartnerMainSkillGroup + self.Skill = nil + self.CharacterElement = nil + -- XPartnerMainSkillGroup list + self.ElementSkills = nil + XTool.InitUiObject(self) + -- 初始化动态列表 + self.DynamicTable = XDynamicTableNormal.New(self.PanelElementGroup) + self.DynamicTable:SetProxy(XUiGridPartnerShowMainSkillElement) + self.DynamicTable:SetDelegate(self) + self.GridElement.gameObject:SetActiveEx(false) +end + +-- skill : XPartnerMainSkillGroup +-- partner : XPartner +function XUiPanelPartnerShowMainSkillElement:SetData(partner, skill) + self.Skill = skill + if partner:GetIsCarry() then + self.CharacterElement = XCharacterConfigs.GetCharacterElement(partner:GetCharacterId()) + end + -- 刷新列表 + self:RefreshDynamicTable() +end + +--########################## 私有方法 ############################## + +function XUiPanelPartnerShowMainSkillElement:RefreshDynamicTable() + self.ElementSkills = self.Skill:GetSelfElementSkillS() + local selectIndex = 1 + for index, skill in ipairs(self.ElementSkills) do + if skill:GetActiveElement() == self.CharacterElement then + selectIndex = index + break + end + end + self.DynamicTable:SetDataSource(self.ElementSkills) + self.DynamicTable:ReloadDataSync(selectIndex) +end + +function XUiPanelPartnerShowMainSkillElement:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:DynamicSetData(self.ElementSkills[index], self.ElementSkills[index]:GetActiveElement() == self.CharacterElement) + end +end + +return XUiPanelPartnerShowMainSkillElement \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPartner/PartnerShow/XUiPanelPartnerShowMainSkillOption.lua b/Resources/Scripts/XUi/XUiPartner/PartnerShow/XUiPanelPartnerShowMainSkillOption.lua new file mode 100644 index 00000000..deeeb263 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPartner/PartnerShow/XUiPanelPartnerShowMainSkillOption.lua @@ -0,0 +1,128 @@ +--########################## XUiGridPartnerShowMainSkillOption ############################## +local XUiGridPartnerShowMainSkillOption = XClass(nil, "XUiGridPartnerShowMainSkillOption") + +function XUiGridPartnerShowMainSkillOption:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.DetailClickFunc = nil + -- XPartnerMainSkillGroup + self.Skill = nil + XTool.InitUiObject(self) + self:RegisterUiEvents() + -- 默认隐藏选择按钮 + local showBtnSelect = self.Normal.gameObject:FindGameObject("BtnSelect") + if showBtnSelect then + showBtnSelect:SetActiveEx(false) + end +end + +-- skill : XPartnerMainSkillGroup +function XUiGridPartnerShowMainSkillOption:DynamicSetData(skill, isSelected, detailClickFunc) + self.Skill = skill + self.DetailClickFunc = detailClickFunc + self.Normal.gameObject:SetActiveEx(not isSelected) + self.Select.gameObject:SetActiveEx(isSelected) + local rootPanel = isSelected and self.Select or self.Normal + rootPanel:GetObject("TxtContent").text = skill:GetSkillDesc() + rootPanel:GetObject("RImgIcon"):SetRawImage(skill:GetSkillIcon()) + rootPanel:GetObject("TxtName").text = skill:GetSkillName() + rootPanel:GetObject("TxtLevel").text = CS.XTextManager.GetText("PartnerSkillLevelEN", skill:GetLevelStr()) +end + +--########################## 私有方法 ############################## + +function XUiGridPartnerShowMainSkillOption:RegisterUiEvents() + self.BtnDetail.CallBack = function() self:OnBtnDetailClicked() end +end + +function XUiGridPartnerShowMainSkillOption:OnBtnDetailClicked() + if self.DetailClickFunc then + self.DetailClickFunc(self.Skill) + end +end + +--########################## XUiPanelPartnerShowMainSkillOption ############################## +local XUiPanelPartnerShowMainSkillOption = XClass(nil, "XUiPanelPartnerShowMainSkillOption") + +function XUiPanelPartnerShowMainSkillOption:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + -- 重定义名称 + self.RImgElementIcon = self.ElementIcon + -- XPartnerMainSkillGroup + self.Skill = nil + -- XPartner + self.Partner = nil + self.DetailClickFunc = nil + -- XPartnerMainSkillGroup list + self.MainSkillGroups = nil + self.SelectedSkillIndex = nil + -- 初始化动态列表 + self.DynamicTable = XDynamicTableNormal.New(self.PanelSkillOptionGroup) + self.DynamicTable:SetProxy(XUiGridPartnerShowMainSkillOption) + self.DynamicTable:SetDelegate(self) + self.GridSkillOption.gameObject:SetActiveEx(false) +end + +-- skill : XPartnerMainSkillGroup +-- partner : XPartner +function XUiPanelPartnerShowMainSkillOption:SetData(skill, partner, detailClickFunc) + self.Skill = skill + self.Partner = partner + self.DetailClickFunc = detailClickFunc + self.TxtTitle.text = CS.XTextManager.GetText("PartnerMainSkill") + -- 携带角色名称 + self.TxtName.text = self:GetCharacterName() + -- 属性图标 + local elementResult = self:GetCharacterElementIcon() + if elementResult then + self.RImgElementIcon:SetRawImage(elementResult) + else + self.RImgElementIcon.gameObject:SetActiveEx(false) + end + -- 动态列表 + self:RefreshDynamicTable() +end + +--########################## 私有方法 ############################## + +function XUiPanelPartnerShowMainSkillOption:RefreshDynamicTable() + -- XPartnerMainSkillGroup list + self.MainSkillGroups = self.Partner:GetMainSkillGroupList() + -- 获取被选中的技能 + self.SelectedSkillIndex = 1 + for index, data in ipairs(self.MainSkillGroups) do + if data:GetId() == self.Skill:GetId() then + self.SelectedSkillIndex = index + break + end + end + self.DynamicTable:SetDataSource(self.MainSkillGroups) + self.DynamicTable:ReloadDataSync(self.SelectedSkillIndex) +end + +function XUiPanelPartnerShowMainSkillOption:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:DynamicSetData(self.MainSkillGroups[index], index == self.SelectedSkillIndex, self.DetailClickFunc) + end +end + +function XUiPanelPartnerShowMainSkillOption:GetCharacterName() + local result = CS.XTextManager.GetText("PartnerNoBadyCarry") + if self.Partner:GetIsCarry() then + result = XCharacterConfigs.GetCharacterLogName(self.Partner:GetCharacterId()) + end + return result +end + +function XUiPanelPartnerShowMainSkillOption:GetCharacterElementIcon() + local result + if self.Partner:GetIsCarry() then + local element = XCharacterConfigs.GetCharacterElement(self.Partner:GetCharacterId()) + result = XCharacterConfigs.GetCharElement(element).Icon2 + end + return result +end + +return XUiPanelPartnerShowMainSkillOption \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPartner/PartnerShow/XUiPartnerPropertyOther.lua b/Resources/Scripts/XUi/XUiPartner/PartnerShow/XUiPartnerPropertyOther.lua new file mode 100644 index 00000000..0988f830 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPartner/PartnerShow/XUiPartnerPropertyOther.lua @@ -0,0 +1,273 @@ +local XUiPanelPartnerOverview = require("XUi/XUiPartner/PartnerShow/XUiPanelPartnerOverview") +local XUiPanelPartnerPassiveSkill = require("XUi/XUiPartner/PartnerShow/XUiPanelPartnerPassiveSkill") +local XUiPartnerPropertyOther = XLuaUiManager.Register(XLuaUi, "UiPartnerPropertyOther") + +local LeftButtonType = { + Overview = 1, -- 总览 + -- Quality = 2, -- 品质 +} + +function XUiPartnerPropertyOther:OnAwake() + -- XPartner + self.Partner = nil + -- XUiPanelRoleModel + self.UiPanelRoleModel = nil + -- 设置被动技能提示面板 + self.UiPanelPartnerPassiveSkill = XUiPanelPartnerPassiveSkill.New(self.PanelTips) + -- 子面板信息配置 + self.ChillPanelInfoDic = { + [LeftButtonType.Overview] = { + uiParent = self.PanelPartnerOverview, + -- 默认存在于界面中 + instanceGo = self.PanelPartnerOverview, + proxy = XUiPanelPartnerOverview, + -- 代理设置参数 + proxyArgs = { + "Partner" + , function(skill) + self.BtnHidePassiveSkill.gameObject:SetActiveEx(true) + self.UiPanelPartnerPassiveSkill:SetData(skill) + end + } + }, + } + self.CameraFarDic = nil + self.CameraNearDic = nil + -- XPartnerConfigs.CameraType + self.PartnerStatus = nil + self:RegisterUiEvents() +end + +-- partner : XPartner +function XUiPartnerPropertyOther:OnStart(partner) + self.Partner = partner + self.PartnerStatus = XPartnerConfigs.CameraType.Standby + -- 显示伙伴品质 + self.RImgQuality:SetRawImage(partner:GetCharacterQualityIcon()) + -- 伙伴等级 + self.TxtLevel.text = partner:GetLevel() + -- 加载伙伴模型 + self:InitUiPanelRoleModel() + self.BtnChangeRaycast.raycastTarget = false + self.PanelDragRaycast.raycastTarget = false + self:RefreshModel(self.PartnerStatus, function() + self:PlayEnterAnim() + end) + -- -- 设置默认选中的左边按钮 + -- self.PanelLeftButtonGroup:SelectIndex(1) + self:OnLeftButtonClicked(1) +end + +function XUiPartnerPropertyOther:OnDisable() + self.UiPanelRoleModel:HideAllEffects() +end + +--########################## 私有方法 ############################## + +function XUiPartnerPropertyOther:RegisterUiEvents() + self.BtnBack.CallBack = function() self:Close() end + self.BtnMainUi.CallBack = function() XLuaUiManager.RunMain() end + self.BtnChange.CallBack = function() self:OnChangePartnerStatus() end + self.BtnHidePassiveSkill.CallBack = function() self:OnBtnHidePassiveSkillClicked() end + -- 注册按钮组 + -- self.PanelLeftButtonGroup:Init({ + -- [LeftButtonType.Overview] = self.BtnTabAll, + -- [LeftButtonType.Quality] = self.BtnTabQuality, + -- }, function(tabIndex) self:OnLeftButtonClicked(tabIndex) end, 1000) +end + +function XUiPartnerPropertyOther:OnBtnHidePassiveSkillClicked() + self.BtnHidePassiveSkill.gameObject:SetActiveEx(false) + self.UiPanelPartnerPassiveSkill:Close() +end + +function XUiPartnerPropertyOther:OnLeftButtonClicked(tabIndex) + -- 显示/隐藏关联子面板 + for key, data in pairs(self.ChillPanelInfoDic) do + data.uiParent.gameObject:SetActiveEx(key == tabIndex) + end + local childPanelData = self.ChillPanelInfoDic[tabIndex] + -- 加载panel asset + local instanceGo = childPanelData.instanceGo + if instanceGo == nil then + instanceGo = childPanelData.uiParent:LoadPrefab(childPanelData.assetPath) + childPanelData.instanceGo = instanceGo + end + -- 加载panel proxy + local instanceProxy = childPanelData.instanceProxy + if instanceProxy == nil then + instanceProxy = childPanelData.proxy.New(instanceGo) + childPanelData.instanceProxy = instanceProxy + end + -- 加载proxy参数 + local proxyArgs = {} + if childPanelData.proxyArgs then + for _, argName in ipairs(childPanelData.proxyArgs) do + if type(argName) == "string" then + proxyArgs[#proxyArgs + 1] = self[argName] + else + proxyArgs[#proxyArgs + 1] = argName + end + end + end + instanceProxy:SetData(table.unpack(proxyArgs)) +end + +function XUiPartnerPropertyOther:OnChangePartnerStatus(finishCallback, isAutoCloseMask, isCheckAnimExist) + if isCheckAnimExist == nil then isCheckAnimExist = false end + -- 检查动画切换动画是否存在,不存在直接不处理 + if isCheckAnimExist then + local readyPlayAnim = nil + if self.PartnerStatus == XPartnerConfigs.CameraType.Standby then + readyPlayAnim = self:GetChangeAnim(XPartnerConfigs.CameraType.Combat) + elseif self.PartnerStatus == XPartnerConfigs.CameraType.Combat then + readyPlayAnim = self:GetChangeAnim(XPartnerConfigs.CameraType.Standby) + end + if not self.UiPanelRoleModel:CheckAnimaCanPlay(readyPlayAnim) then + self:RecoverRaycastTargets() + return + end + end + if isAutoCloseMask == nil then isAutoCloseMask = true end + if isAutoCloseMask then XLuaUiManager.SetMask(true) end + -- 播放变身音效 + local voiceId = self:GetChangeVoice() + if voiceId and voiceId > 0 then + XSoundManager.PlaySoundByType(voiceId, XSoundManager.SoundType.Sound) + end + -- 更改状态 + if self.PartnerStatus == XPartnerConfigs.CameraType.Standby then + self.PartnerStatus = XPartnerConfigs.CameraType.Combat + self:SetCameraType(self.PartnerStatus) + self.UiPanelRoleModel:LoopLoadEffect(self.Partner:GetSToCEffect(), true) + elseif self.PartnerStatus == XPartnerConfigs.CameraType.Combat then + self.PartnerStatus = XPartnerConfigs.CameraType.Standby + self.UiPanelRoleModel:LoopLoadEffect(self:GetBornEffectPath(), true) + end + -- 动画无论成功还是失败的回调 + local callback = function() + -- 变身状态特殊处理 + if self.PartnerStatus == XPartnerConfigs.CameraType.Combat then + self:SetCameraType(self.PartnerStatus) + self.UiPanelRoleModel:LoopLoadEffect(self:GetBornEffectPath(), true) + else + self.UiPanelRoleModel:LoopLoadEffect(self.Partner:GetStandbyBornEffect(), true) + end + -- 刷新模型 + self:RefreshModel(self.PartnerStatus, finishCallback) + if isAutoCloseMask then + XLuaUiManager.SetMask(false) + end + end + -- 播放变身动画 + self.UiPanelRoleModel:PlayAnima(self:GetChangeAnim(), true, callback, callback) +end + +-- 播放伙伴入场动画(盒子-牛-盒子) +function XUiPartnerPropertyOther:PlayEnterAnim() + self:OnChangePartnerStatus(function() + self:OnChangePartnerStatus(nil, nil, true) + self:RecoverRaycastTargets() + end, false, true) +end + +function XUiPartnerPropertyOther:RecoverRaycastTargets() + self.BtnChangeRaycast.raycastTarget = true + self.PanelDragRaycast.raycastTarget = true +end + +function XUiPartnerPropertyOther:GetChangeVoice(partnerStatus) + partnerStatus = partnerStatus or self.PartnerStatus + local voiceId = 0 + if partnerStatus == XPartnerConfigs.CameraType.Standby then + voiceId = self.Partner:GetSToCVoice() + elseif partnerStatus == XPartnerConfigs.CameraType.Combat then + voiceId = self.Partner:GetCToSVoice() + end + return voiceId +end + +function XUiPartnerPropertyOther:GetChangeAnim(partnerStatus) + partnerStatus = partnerStatus or self.PartnerStatus + local animName + if partnerStatus == XPartnerConfigs.CameraType.Standby then + animName = self.Partner:GetCToSAnime() + elseif partnerStatus == XPartnerConfigs.CameraType.Combat then + animName = self.Partner:GetSToCAnime() + end + return animName +end + +function XUiPartnerPropertyOther:GetBornEffectPath(partnerStatus) + partnerStatus = partnerStatus or self.PartnerStatus + local effectPath + if partnerStatus == XPartnerConfigs.CameraType.Standby then + effectPath = self.Partner:GetCToSEffect() + elseif partnerStatus == XPartnerConfigs.CameraType.Combat then + effectPath = self.Partner:GetCombatBornEffect() + end + return effectPath +end + +function XUiPartnerPropertyOther:GetBornAnim(partnerStatus) + partnerStatus = partnerStatus or self.PartnerStatus + local animName + if partnerStatus == XPartnerConfigs.CameraType.Standby then + animName = self.Partner:GetStandbyBornAnime() + elseif partnerStatus == XPartnerConfigs.CameraType.Combat then + animName = self.Partner:GetCombatBornAnime() + end + return animName +end + +function XUiPartnerPropertyOther:GetModelId(partnerStatus) + partnerStatus = partnerStatus or self.PartnerStatus + local modelId + if partnerStatus == XPartnerConfigs.CameraType.Standby then + modelId = self.Partner:GetStandbyModel() + elseif partnerStatus == XPartnerConfigs.CameraType.Combat then + modelId = self.Partner:GetCombatModel() + end + return modelId +end + +function XUiPartnerPropertyOther:InitUiPanelRoleModel() + local root = self.UiModelGo.transform + local panelRoleModel = root:FindTransform("PanelRoleModel") + self.ImgEffectHuanren = root:FindTransform("ImgEffectHuanren") + -- 初始化镜头信息 + self.CameraFarDic = { + [XPartnerConfigs.CameraType.Standby] = root:FindTransform("UiCamFarStandby"), + [XPartnerConfigs.CameraType.Combat] = root:FindTransform("UiCamFarCombat"), + } + self.CameraNearDic = { + [XPartnerConfigs.CameraType.Standby] = root:FindTransform("UiCamNearStandby"), + [XPartnerConfigs.CameraType.Combat] = root:FindTransform("UiCamNearCombat"), + } + -- self.Name 参数看起来只是在武器那边做了一个键标记 + self.UiPanelRoleModel = XUiPanelRoleModel.New(panelRoleModel, self.Name, nil, true, nil, true) + self.UiPanelRoleModel:SetEffectMaxCount(2) +end + +function XUiPartnerPropertyOther:RefreshModel(partnerStatus, bornAnimCallback) + partnerStatus = partnerStatus or self.PartnerStatus + local modelId = self:GetModelId(partnerStatus) + self.ImgEffectHuanren.gameObject:SetActiveEx(false) + -- 参数2是UiModelTansform的配置表的键,用来设置模型的一些旋转,大小之类的,这里用回UiPartnerMain默认的 + self.UiPanelRoleModel:UpdatePartnerModel(modelId, XModelManager.MODEL_UINAME.XUiPartnerMain, nil, function(model) + self.ImgEffectHuanren.gameObject:SetActiveEx(true) + self.PanelDrag.Target = model.transform + self.UiPanelRoleModel:PlayAnima(self:GetBornAnim(), true, bornAnimCallback, bornAnimCallback) + end, false, true) + self:SetCameraType(partnerStatus) +end + +function XUiPartnerPropertyOther:SetCameraType(partnerStatus) + for k, _ in pairs(self.CameraFarDic) do + self.CameraFarDic[k].gameObject:SetActiveEx(k == partnerStatus) + end + for k, _ in pairs(self.CameraNearDic) do + self.CameraNearDic[k].gameObject:SetActiveEx(k == partnerStatus) + end +end + diff --git a/Resources/Scripts/XUi/XUiPartner/PartnerShow/XUiPartnerShowSkillGrid.lua b/Resources/Scripts/XUi/XUiPartner/PartnerShow/XUiPartnerShowSkillGrid.lua new file mode 100644 index 00000000..c49e4d90 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPartner/PartnerShow/XUiPartnerShowSkillGrid.lua @@ -0,0 +1,55 @@ +local XUiPartnerShowSkillGrid = XClass(nil, "XUiPartnerShowSkillGrid") + +function XUiPartnerShowSkillGrid:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + -- XPartnerPassiveGroupSkill + self.Skill = nil + self.IsLock = nil + self.OpenSkillFunc = nil + XTool.InitUiObject(self) + self:RegisterUiEvents() +end + +-- skill : XPartnerPassiveGroupSkill +-- isLock : 技能槽是否被锁住 +function XUiPartnerShowSkillGrid:SetData(skill, isLock, isNone, openSkillFunc) + self.GameObject:SetActiveEx(true) + self.Skill = skill + self.IsLock = isLock + self.OpenSkillFunc = openSkillFunc + local isNullSkill = skill == nil + -- 如果没有锁住并存在技能直接初始化技能相关信息 + if not isLock and not isNullSkill and not isNone then + self.RImgSkillIcon:SetRawImage(skill:GetSkillIcon()) + self.TxtLevel.text = skill:GetLevelStr() + end + self.PanelLock.gameObject:SetActiveEx(isLock and not isNone) + self.PanelSkill.gameObject:SetActiveEx(not isLock and not isNullSkill and not isNone) + self.PanelNoSkill.gameObject:SetActiveEx(not isLock and isNullSkill and not isNone) + self.PanelNone.gameObject:SetActiveEx(isNone) +end + +--########################## 私有方法 ############################## + +function XUiPartnerShowSkillGrid:RegisterUiEvents() + self.BtnSelf.CallBack = function() self:OnBtnSelfClicked() end +end + +function XUiPartnerShowSkillGrid:OnBtnSelfClicked() + -- 未解锁 + if self.IsLock then + XUiManager.TipError(CS.XTextManager.GetText("PartnerSeatNotLock")) + return + end + -- 已解锁,未装备 + if self.Skill == nil then + XUiManager.TipError(CS.XTextManager.GetText("PartnerSkillUnequipped")) + return + end + if self.OpenSkillFunc then + self.OpenSkillFunc(self.Skill) + end +end + +return XUiPartnerShowSkillGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPartner/PartnerSkillInstall/MainSkill/XUiGridMainSkill.lua b/Resources/Scripts/XUi/XUiPartner/PartnerSkillInstall/MainSkill/XUiGridMainSkill.lua new file mode 100644 index 00000000..2591d254 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPartner/PartnerSkillInstall/MainSkill/XUiGridMainSkill.lua @@ -0,0 +1,146 @@ +local XUiGridMainSkill = XClass(nil, "XUiGridMainSkill") +local CSTextManagerGetText = CS.XTextManager.GetText +local State = {Normal = 1, Select = 2, Lock = 3} + +function XUiGridMainSkill:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.GridState = State.Normal + XTool.InitUiObject(self) + self:AutoInitUi() --海外修改,辅助机描述文字过长改为滑动显示 + self:SetButtonCallBack() +end + +function XUiGridMainSkill:SetButtonCallBack() + self.BtnSelect.CallBack = function() + self:OnBtnSelectClick() + end + + self.BtnDetail.CallBack = function() + self:OnBtnDetailClick() + end +end + +function XUiGridMainSkill:OnBtnSelectClick() + if self.SkillGroup:GetIsLock() then + XUiManager.TipMsg(self.SkillGroup:GetConditionDesc()) + return + end + + self.Base:SelectSkill(self.SkillGroup) + + local grids = self.Base.DynamicTable:GetGrids() + for _,grid in pairs(grids) do + grid:ShowGrid() + end + + --self:ChangeState(State.Select) +end + +function XUiGridMainSkill:OnBtnDetailClick() + self.Base:SelectPreviewSkill(self.SkillGroup) + self.Root:GoElementView() +end + +function XUiGridMainSkill:UpdateGrid(skillGroup, base, root) + self.SkillGroup = skillGroup + self.Base = base + self.Root = root + self:ShowGrid() +end + +function XUiGridMainSkill:ShowGrid() + if self.SkillGroup then + local selectSkillId = self.Root.CurSkillGroup:GetId() + local IsSelect = self.SkillGroup:GetId() == selectSkillId + if IsSelect then + self:ChangeState(State.Select) + else + if self.SkillGroup:GetIsLock() then + self:ChangeState(State.Lock) + else + self:ChangeState(State.Normal) + end + end + end +end + +function XUiGridMainSkill:ChangeState(state) + self.GridState = state + self:ShowNormal(self.GridState == State.Normal) + self:ShowSelect(self.GridState == State.Select) + self:ShowLock(self.GridState == State.Lock) + self:UpdateSkillInfo() +end + +function XUiGridMainSkill:UpdateSkillInfo() + local panel = {} + if self.GridState == State.Normal then + panel = self.Normal + panel:GetObject("TxtContent").text = self.SkillGroup:GetSkillDesc() + elseif self.GridState == State.Select then + panel = self.Select + panel:GetObject("TxtContent").text = self.SkillGroup:GetSkillDesc() + elseif self.GridState == State.Lock then + panel = self.Lock + panel:GetObject("TxtUnlock").text = self.SkillGroup:GetConditionDesc() + end + + panel:GetObject("RImgIcon"):SetRawImage(self.SkillGroup:GetSkillIcon()) + panel:GetObject("TxtName").text = self.SkillGroup:GetSkillName() + panel:GetObject("TxtLevel").text = CSTextManagerGetText("PartnerSkillLevelEN",self.SkillGroup:GetLevelStr()) +end + +function XUiGridMainSkill:ShowSelect(IsShow) + self.Select.gameObject:SetActiveEx(IsShow) +end + +function XUiGridMainSkill:ShowLock(IsLock) + self.Lock.gameObject:SetActiveEx(IsLock) +end + +function XUiGridMainSkill:ShowNormal(IsNormal) + self.Normal.gameObject:SetActiveEx(IsNormal) +end + +function XUiGridMainSkill:AutoInitUi() + local normalSelect = self.Transform:Find("Normal/BtnSelect") + if (normalSelect) then + self.normalSelectBtn = normalSelect:GetComponent("XUiButton") + self.normalSelectBtn.CallBack = function() + self:OnBtnSelectClick() + end + end + + local temp = self.Transform:Find("Normal/BgKuang") + if (temp) then + temp:GetComponent("Image").raycastTarget = false + end + + temp = self.Transform:Find("Normal/BgKuang2") + if (temp) then + temp:GetComponent("Image").raycastTarget = false + end + + temp = self.Transform:Find("Select/BgKuang") + if (temp) then + temp:GetComponent("Image").raycastTarget = false + end + + temp = self.Transform:Find("Select/BgKuang2") + if (temp) then + temp:GetComponent("Image").raycastTarget = false + end + + temp = self.Transform:Find("Lock/BgKuang") + if (temp) then + temp:GetComponent("Image").raycastTarget = false + end + + temp = self.Transform:Find("BtnSelect") + if (temp) then + temp.gameObject:SetActiveEx(false) + end +end + +return XUiGridMainSkill \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPartner/PartnerSkillInstall/MainSkill/XUiGridSkillElement.lua b/Resources/Scripts/XUi/XUiPartner/PartnerSkillInstall/MainSkill/XUiGridSkillElement.lua new file mode 100644 index 00000000..eb4f755f --- /dev/null +++ b/Resources/Scripts/XUi/XUiPartner/PartnerSkillInstall/MainSkill/XUiGridSkillElement.lua @@ -0,0 +1,53 @@ +local XUiGridSkillElement = XClass(nil, "XUiGridSkillElement") +local CSTextManagerGetText = CS.XTextManager.GetText +local State = {Normal = 1, Activate = 2} + +function XUiGridSkillElement:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.GridState = State.Normal + XTool.InitUiObject(self) +end + +function XUiGridSkillElement:UpdateGrid(skillGroup, carrierElement) + self.SkillGroup = skillGroup + self.CarrierElement = carrierElement + local IsSameElement = carrierElement and skillGroup:GetActiveElement() == carrierElement + if IsSameElement then + self:ChangeState(State.Activate) + else + self:ChangeState(State.Normal) + end +end + +function XUiGridSkillElement:ChangeState(state) + self.GridState = state + self:ShowNormal(self.GridState == State.Normal) + self:ShowActivate(self.GridState == State.Activate) + self:UpdateSkillInfo() +end + +function XUiGridSkillElement:UpdateSkillInfo() + local panel = {} + if self.GridState == State.Normal then + panel = self.Normal + elseif self.GridState == State.Activate then + panel = self.Activate + end + + local elementConfig = XCharacterConfigs.GetCharElement(self.SkillGroup:GetActiveElement()) + + panel:GetObject("RImgIcon"):SetRawImage(elementConfig.Icon2) + panel:GetObject("TxtName").text = elementConfig.ElementName + panel:GetObject("TxtContent").text = self.SkillGroup:GetSkillDesc() +end + +function XUiGridSkillElement:ShowActivate(IsActivate) + self.Activate.gameObject:SetActiveEx(IsActivate) +end + +function XUiGridSkillElement:ShowNormal(IsNormal) + self.Normal.gameObject:SetActiveEx(IsNormal) +end + +return XUiGridSkillElement \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPartner/PartnerSkillInstall/MainSkill/XUiPanelElement.lua b/Resources/Scripts/XUi/XUiPartner/PartnerSkillInstall/MainSkill/XUiPanelElement.lua new file mode 100644 index 00000000..6d252559 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPartner/PartnerSkillInstall/MainSkill/XUiPanelElement.lua @@ -0,0 +1,55 @@ +local XUiPanelElement = XClass(nil, "XUiPanelElement") +local XUiGridSkillElement = require("XUi/XUiPartner/PartnerSkillInstall/MainSkill/XUiGridSkillElement") +local XPartnerMainSkillGroup = require("XEntity/XPartner/XPartnerMainSkillGroup") + +function XUiPanelElement:Ctor(ui, base) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Base = base + XTool.InitUiObject(self) + self:InitDynamicTable() +end + +function XUiPanelElement:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelElementGroup) + self.DynamicTable:SetProxy(XUiGridSkillElement) + self.DynamicTable:SetDelegate(self) + self.GridElement.gameObject:SetActiveEx(false) +end + +function XUiPanelElement:UpdatePanel() + self:SetupDynamicTable() + self.GameObject:SetActiveEx(true) +end + +function XUiPanelElement:HidePanel() + self.GameObject:SetActiveEx(false) +end + +function XUiPanelElement:SetupDynamicTable() + local selectIndex = 1 + local skillGroup = self.Base.PreviewSkillGroup + local elementList = skillGroup:GetElementList() + + self.PageDatas = {} + for _,element in pairs(elementList or {}) do + local entity = XPartnerMainSkillGroup.New(skillGroup:GetId()) + local tmpData = {} + tmpData.Level = skillGroup:GetLevel() + tmpData.IsLock = skillGroup:GetIsLock() + tmpData.ActiveSkillId = skillGroup:GetSkillIdByElement(element) + tmpData.Type = XPartnerConfigs.SkillType.MainSkill + entity:UpdateData(tmpData) + table.insert(self.PageDatas,entity) + end + self.DynamicTable:SetDataSource(self.PageDatas) + self.DynamicTable:ReloadDataSync(selectIndex) +end + +function XUiPanelElement:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:UpdateGrid(self.PageDatas[index], self.Base.CharElement) + end +end + +return XUiPanelElement \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPartner/PartnerSkillInstall/MainSkill/XUiPanelMainSkillOption.lua b/Resources/Scripts/XUi/XUiPartner/PartnerSkillInstall/MainSkill/XUiPanelMainSkillOption.lua new file mode 100644 index 00000000..e54453dc --- /dev/null +++ b/Resources/Scripts/XUi/XUiPartner/PartnerSkillInstall/MainSkill/XUiPanelMainSkillOption.lua @@ -0,0 +1,74 @@ +local XUiPanelMainSkillOption = XClass(nil, "XUiPanelMainSkillOption") +local XUiGridMainSkill = require("XUi/XUiPartner/PartnerSkillInstall/MainSkill/XUiGridMainSkill") +local CSTextManagerGetText = CS.XTextManager.GetText + +function XUiPanelMainSkillOption:Ctor(ui, base, partner) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Base = base + self.Partner = partner + XTool.InitUiObject(self) + self:InitPanel() + self:InitDynamicTable() +end + +function XUiPanelMainSkillOption:InitPanel() + local charName = CSTextManagerGetText("PartnerNoBadyCarry") + if self.Partner:GetIsCarry() then + local charId = self.Partner:GetCharacterId() + charName = XCharacterConfigs.GetCharacterLogName(charId) + local elementConfig = XCharacterConfigs.GetCharElement(self.Base.CharElement) + self.ElementIcon:SetRawImage(elementConfig.Icon2) + self.ElementIcon.gameObject:SetActiveEx(true) + else + self.ElementIcon.gameObject:SetActiveEx(false) + end + self.TxtName.text = charName +end + +function XUiPanelMainSkillOption:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelSkillOptionGroup) + self.DynamicTable:SetProxy(XUiGridMainSkill) + self.DynamicTable:SetDelegate(self) + self.GridSkillOption.gameObject:SetActiveEx(false) +end + +function XUiPanelMainSkillOption:UpdatePanel() + self:SetupDynamicTable() + self.GameObject:SetActiveEx(true) +end + +function XUiPanelMainSkillOption:HidePanel() + self.GameObject:SetActiveEx(false) +end + +function XUiPanelMainSkillOption:SetupDynamicTable() + local selectIndex = 1 + self.PageDatas = self.Partner:GetMainSkillGroupList() + + for index,data in pairs(self.PageDatas) do + if data:GetId() == self.Base.CurSkillGroup:GetId() then + selectIndex = index + break + end + end + + self.DynamicTable:SetDataSource(self.PageDatas) + self.DynamicTable:ReloadDataSync(selectIndex) +end + +function XUiPanelMainSkillOption:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:UpdateGrid(self.PageDatas[index], self, self.Base) + end +end + +function XUiPanelMainSkillOption:SelectSkill(skillGroup) + self.Base:SetCurSkillGroup(skillGroup) +end + +function XUiPanelMainSkillOption:SelectPreviewSkill(skillGroup) + self.Base:SetPreviewSkillGroup(skillGroup) +end + +return XUiPanelMainSkillOption \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPartner/PartnerSkillInstall/MainSkill/XUiPartnerActivateMainSkill.lua b/Resources/Scripts/XUi/XUiPartner/PartnerSkillInstall/MainSkill/XUiPartnerActivateMainSkill.lua new file mode 100644 index 00000000..a3b45b7e --- /dev/null +++ b/Resources/Scripts/XUi/XUiPartner/PartnerSkillInstall/MainSkill/XUiPartnerActivateMainSkill.lua @@ -0,0 +1,162 @@ +local XUiPartnerActivateMainSkill = XLuaUiManager.Register(XLuaUi, "UiPartnerActivateMainSkill") + +local XUiPanelMainSkillOption = require("XUi/XUiPartner/PartnerSkillInstall/MainSkill/XUiPanelMainSkillOption") +local XUiPanelElement = require("XUi/XUiPartner/PartnerSkillInstall/MainSkill/XUiPanelElement") + +local PanelState = { + SkillOption = 1, + Element = 2, +} + +local CSTextManagerGetText = CS.XTextManager.GetText +local DefaultIndex = 1 + +function XUiPartnerActivateMainSkill:OnStart(partner) + self.Partner = partner + self:SetButtonCallBack() + self:Init() + self:GoSkillOptionView() + XDataCenter.PartnerManager.MarkedNewSkillRed(self.Partner:GetId()) + XEventManager.DispatchEvent(XEventId.EVENT_PARTNER_SKILLUNLOCK_CLOSERED) +end + +function XUiPartnerActivateMainSkill:OnEnable() + XEventManager.AddEventListener(XEventId.EVENT_PARTNER_SKILLCHANGE, self.CloseMask, self) +end + +function XUiPartnerActivateMainSkill:OnDisable() + XEventManager.RemoveEventListener(XEventId.EVENT_PARTNER_SKILLCHANGE, self.CloseMask, self) +end + +function XUiPartnerActivateMainSkill:SetButtonCallBack() + self.BtnTanchuangClose.CallBack = function() + self:OnBtnCloseClick() + end +end + +function XUiPartnerActivateMainSkill:Init() + self.SkillGroupList = self.Partner:GetMainSkillGroupList() + + for index,skillgroup in pairs(self.SkillGroupList) do + if skillgroup:GetIsCarry() then + self.CurSkillGroup = skillgroup + self.PreviewSkillGroup = skillgroup + break + end + end + + if self.Partner:GetIsCarry() then + local charId = self.Partner:GetCharacterId() + self.CharElement = XCharacterConfigs.GetCharacterElement(charId) + end + + self.SkillOptionPanel = XUiPanelMainSkillOption.New(self.PanelMainSkillOption, self, self.Partner) + self.ElementPanel = XUiPanelElement.New(self.PanelElement, self) +end + + +function XUiPartnerActivateMainSkill:SetPanelState(state) + self.PanelState = state +end + + +function XUiPartnerActivateMainSkill:ShowPanel() + --self.SkillOptionPanel:HidePanel() + --self.ElementPanel:HidePanel() + + if self.PanelState == PanelState.SkillOption then + self.SkillOptionPanel:UpdatePanel() + elseif self.PanelState == PanelState.Element then + self.ElementPanel:UpdatePanel() + end + self:PlayEnableAnime() +end + +function XUiPartnerActivateMainSkill:SetCurSkillGroup(skillGroup) + self.CurSkillGroup = skillGroup +end + +function XUiPartnerActivateMainSkill:SetPreviewSkillGroup(skillGroup) + self.PreviewSkillGroup = skillGroup +end + +function XUiPartnerActivateMainSkill:OnBtnCloseClick() + if self.PanelState == PanelState.SkillOption then + self:DoSkillSelect() + elseif self.PanelState == PanelState.Element then + self:GoSkillOptionView() + end +end + +function XUiPartnerActivateMainSkill:DoSkillSelect() + local IsChange = false + local oldCarrySkillGroup = {} + IsChange, oldCarrySkillGroup = self:CheckIsSkillChange() + + if IsChange then + self:OpenMask() + oldCarrySkillGroup:UpdateData({IsCarry = not oldCarrySkillGroup:GetIsCarry()}) + XDataCenter.PartnerManager.PartnerSkillWearRequest(self.Partner:GetId(), + {[self.CurSkillGroup:GetActiveSkillId()] = true}, + XPartnerConfigs.SkillType.MainSkill, + function () + oldCarrySkillGroup:UpdateData({IsCarry = not oldCarrySkillGroup:GetIsCarry()}) + self:CloseMask() + end) + else + self:Close() + end +end + +function XUiPartnerActivateMainSkill:CheckIsSkillChange() + local mainSkillGrouplist = self.SkillGroupList + local changeSkillDic = {} + local IsChange = false + local oldCarrySkillGroup = {} + for _,skillGroup in pairs(mainSkillGrouplist) do + if not skillGroup:GetIsCarry() then + if self.CurSkillGroup:GetId() == skillGroup:GetId() then + IsChange = true + end + else + oldCarrySkillGroup = skillGroup + end + end + + return IsChange, oldCarrySkillGroup +end + +function XUiPartnerActivateMainSkill:OpenMask() + if not self.IsSendMeg then + XLuaUiManager.SetMask(true) + self.IsSendMeg = true + end +end + +function XUiPartnerActivateMainSkill:CloseMask() + if self.IsSendMeg then + XLuaUiManager.SetMask(false) + self.IsSendMeg = false + self:Close() + end +end + +function XUiPartnerActivateMainSkill:GoElementView() + self:SetPanelState(PanelState.Element) + self:ShowPanel() +end + +function XUiPartnerActivateMainSkill:GoSkillOptionView() + self:SetPanelState(PanelState.SkillOption) + self:ShowPanel() +end + +function XUiPartnerActivateMainSkill:PlayEnableAnime() + XScheduleManager.ScheduleOnce(function() + if self.PanelState == PanelState.SkillOption then + self:PlayAnimation("QieHuan2") + elseif self.PanelState == PanelState.Element then + self:PlayAnimation("QieHuan1") + end + end, 1) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPartner/PartnerSkillInstall/PassiveSkill/XUiGridPassiveSkill.lua b/Resources/Scripts/XUi/XUiPartner/PartnerSkillInstall/PassiveSkill/XUiGridPassiveSkill.lua new file mode 100644 index 00000000..346f4f31 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPartner/PartnerSkillInstall/PassiveSkill/XUiGridPassiveSkill.lua @@ -0,0 +1,43 @@ +local XUiGridSkillDesc = XClass(nil, "XUiGridSkillDesc") +local CSTextManagerGetText = CS.XTextManager.GetText + +function XUiGridSkillDesc:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.IsSelect = false + XTool.InitUiObject(self) + self:SetButtonCallBack() +end + +function XUiGridSkillDesc:SetButtonCallBack() + self.BtnAddSelect.CallBack = function() + self:OnBtnAddSelectClick() + end +end + +function XUiGridSkillDesc:OnBtnAddSelectClick() + self.Base:SetSelectSkill(self.Data, not self.IsSelect) + self:ShowSelect() +end + +function XUiGridSkillDesc:UpdateGrid(data, base) + self.Data = data + self.Base = base + + if data then + local level = data:GetLevelStr() + self.TxtLevel.text = CSTextManagerGetText("PartnerSkillLevelCN",level) + self.TxtName.text = data:GetSkillName() + self.TxtContent.text = data:GetSkillDesc() + self.RImgIcon:SetRawImage(data:GetSkillIcon()) + self:ShowSelect() + end + +end + +function XUiGridSkillDesc:ShowSelect() + self.IsSelect = self.Base:CheckIsSelectSkill(self.Data:GetId()) + self.PanelSelect.gameObject:SetActiveEx(self.IsSelect) +end + +return XUiGridSkillDesc \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPartner/PartnerSkillInstall/PassiveSkill/XUiPartnerActivatePassiveSkill.lua b/Resources/Scripts/XUi/XUiPartner/PartnerSkillInstall/PassiveSkill/XUiPartnerActivatePassiveSkill.lua new file mode 100644 index 00000000..715f5a1b --- /dev/null +++ b/Resources/Scripts/XUi/XUiPartner/PartnerSkillInstall/PassiveSkill/XUiPartnerActivatePassiveSkill.lua @@ -0,0 +1,144 @@ +local XUiPartnerActivatePassiveSkill = XLuaUiManager.Register(XLuaUi, "UiPartnerActivatePassiveSkill") +local XUiGridPassiveSkill = require("XUi/XUiPartner/PartnerSkillInstall/PassiveSkill/XUiGridPassiveSkill") +local CSTextManagerGetText = CS.XTextManager.GetText + +function XUiPartnerActivatePassiveSkill:OnStart(partner) + self.Partner = partner + self:SetButtonCallBack() + self:InitDynamicTable() + self:InitPanel() + self.IsSendMeg = false +end + +function XUiPartnerActivatePassiveSkill:OnEnable() + self:SetupDynamicTable() + self:UpdatePanel() + XEventManager.AddEventListener(XEventId.EVENT_PARTNER_SKILLCHANGE, self.CloseMask, self) +end + +function XUiPartnerActivatePassiveSkill:OnDisable() + XEventManager.RemoveEventListener(XEventId.EVENT_PARTNER_SKILLCHANGE, self.CloseMask, self) +end + +function XUiPartnerActivatePassiveSkill:SetButtonCallBack() + self.BtnTanchuangClose.CallBack = function() + self:OnBtnCloseClick() + end +end + +function XUiPartnerActivatePassiveSkill:InitPanel() + self.SelectSkillDic = {} + local carryPassiveSkillGroupList = self.Partner:GetCarryPassiveSkillGroupList() + for _,skillGroup in pairs(carryPassiveSkillGroupList) do + self.SelectSkillDic[skillGroup:GetId()] = skillGroup + end +end + +function XUiPartnerActivatePassiveSkill:UpdatePanel() + local count = 0 + for _,_ in pairs(self.SelectSkillDic or {}) do + count = count + 1 + end + + self.TxtCurSkillCount.text = count + self.TxtMaxSkillCount.text = string.format(" / %d",self.Partner:GetQualitySkillColumnCount()) + + self.IsSelectCountFull = self.Partner:GetQualitySkillColumnCount() <= count +end + +function XUiPartnerActivatePassiveSkill:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelSkillDetails) + self.DynamicTable:SetProxy(XUiGridPassiveSkill) + self.DynamicTable:SetDelegate(self) + self.GridSkillDetail.gameObject:SetActiveEx(false) +end + +function XUiPartnerActivatePassiveSkill:SetupDynamicTable() + self.PageDatas = self.Partner:GetPassiveSkillGroupList() + self.DynamicTable:SetDataSource(self.PageDatas) + self.DynamicTable:ReloadDataSync() +end + +function XUiPartnerActivatePassiveSkill:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:UpdateGrid(self.PageDatas[index], self) + end +end + +function XUiPartnerActivatePassiveSkill:SetSelectSkill(entity, IsAdd) + if IsAdd then + if self.IsSelectCountFull then + XUiManager.TipText("PartnerSelectSkillFull") + return + end + + if not self.SelectSkillDic[entity:GetId()] then + self.SelectSkillDic[entity:GetId()] = entity + end + else + if self.SelectSkillDic[entity:GetId()] then + self.SelectSkillDic[entity:GetId()] = nil + end + end + + self:UpdatePanel() +end + +function XUiPartnerActivatePassiveSkill:CheckIsSelectSkill(id) + return self.SelectSkillDic[id] and true or false +end + +function XUiPartnerActivatePassiveSkill:CheckIsSkillChange() + local passiveSkillGrouplist = self.Partner:GetPassiveSkillGroupList() + local changeSkillDic = {} + local IsChange = false + for _,skillGroup in pairs(passiveSkillGrouplist) do + if not skillGroup:GetIsCarry() then + if self.SelectSkillDic[skillGroup:GetId()] then + changeSkillDic[skillGroup:GetActiveSkillId()] = true + IsChange = true + end + else + if not self.SelectSkillDic[skillGroup:GetId()] then + changeSkillDic[skillGroup:GetActiveSkillId()] = false + IsChange = true + end + end + end + + return IsChange, changeSkillDic +end + +function XUiPartnerActivatePassiveSkill:OnBtnCloseClick() + local IsChange = false + local changeSkillDic = {} + + IsChange, changeSkillDic = self:CheckIsSkillChange() + + if IsChange then + self:OpenMask() + XDataCenter.PartnerManager.PartnerSkillWearRequest(self.Partner:GetId(), + changeSkillDic, + XPartnerConfigs.SkillType.PassiveSkill, + function () + self:CloseMask() + end) + else + self:Close() + end +end + +function XUiPartnerActivatePassiveSkill:OpenMask() + if not self.IsSendMeg then + XLuaUiManager.SetMask(true) + self.IsSendMeg = true + end +end + +function XUiPartnerActivatePassiveSkill:CloseMask() + if self.IsSendMeg then + XLuaUiManager.SetMask(false) + self.IsSendMeg = false + self:Close() + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPartner/PartnerSkillPreview/XUiGridSkillDesc.lua b/Resources/Scripts/XUi/XUiPartner/PartnerSkillPreview/XUiGridSkillDesc.lua new file mode 100644 index 00000000..cc306c57 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPartner/PartnerSkillPreview/XUiGridSkillDesc.lua @@ -0,0 +1,36 @@ +local XUiGridSkillDesc = XClass(nil, "XUiGridSkillDesc") +local CSTextManagerGetText = CS.XTextManager.GetText +function XUiGridSkillDesc:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.IsLock = false + XTool.InitUiObject(self) +end + +function XUiGridSkillDesc:UpdateGrid(data,curLevel) + self.Data = data + if data then + local panel + local level = data:GetLevelStr() + local sameLevel = curLevel == data:GetLevel() + local IsShowUnLock = not data:GetIsLock() and sameLevel + local IsLevelMax = data:GetLevel() >= data:GetLevelLimit() + + if IsShowUnLock then + panel = self.PanelNormal + else + panel = self.PanelLock + end + + panel:GetObject("TxtLevel").text = level + panel:GetObject("TxtContent").text = data:GetSkillDesc() + panel:GetObject("CurText").gameObject:SetActiveEx(sameLevel) + panel:GetObject("PanelLevelMax").gameObject:SetActiveEx(IsLevelMax) + panel:GetObject("PanelLevel").gameObject:SetActiveEx(not IsLevelMax) + + self.PanelNormal.gameObject:SetActiveEx(IsShowUnLock) + self.PanelLock.gameObject:SetActiveEx(not IsShowUnLock) + end +end + +return XUiGridSkillDesc \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPartner/PartnerSkillPreview/XUiPartnerSkillPreview.lua b/Resources/Scripts/XUi/XUiPartner/PartnerSkillPreview/XUiPartnerSkillPreview.lua new file mode 100644 index 00000000..842f263e --- /dev/null +++ b/Resources/Scripts/XUi/XUiPartner/PartnerSkillPreview/XUiPartnerSkillPreview.lua @@ -0,0 +1,167 @@ +local XUiPartnerSkillPreview = XLuaUiManager.Register(XLuaUi, "UiPartnerSkillPreview") +local XUiGridSkillDesc = require("XUi/XUiPartner/PartnerSkillPreview/XUiGridSkillDesc") +local XPartnerMainSkillGroup = require("XEntity/XPartner/XPartnerMainSkillGroup") +local XPartnerPassiveSkillGroup = require("XEntity/XPartner/XPartnerPassiveSkillGroup") + +local CSTextManagerGetText = CS.XTextManager.GetText +local DefaultIndex = 1 + +function XUiPartnerSkillPreview:OnStart(skillGroupList, skillType) + self.SkillGroupList = skillGroupList + self.SkillType = skillType + self:SetButtonCallBack() + self:InitBtnGroup() + self:InitDynamicTable() + +end + +function XUiPartnerSkillPreview:OnEnable() + self:UpdateSkillOptionBtnGroup() +end + +function XUiPartnerSkillPreview:OnDisable() + +end + +function XUiPartnerSkillPreview:InitBtnGroup() + self.BtnSkillOptionList = {} + self.BtnElementList = {} + self.BtnSkillOption.gameObject:SetActiveEx(false) + self.BtnElement.gameObject:SetActiveEx(false) + self.CurSkillIndex = DefaultIndex + self.CurElementIndex = DefaultIndex + + for index,skillgroup in pairs(self.SkillGroupList) do + if skillgroup:GetIsCarry() then + self.CurSkillIndex = index + if self.SkillType == XPartnerConfigs.SkillType.MainSkill then + local skillId = skillgroup:GetActiveSkillId() + self.CurElementIndex = skillgroup:GetElementIndexBySkillId(skillId) + end + break + end + end +end + +function XUiPartnerSkillPreview:SetButtonCallBack() + self.BtnClose.CallBack = function() + self:OnBtnCloseClick() + end + self.BtnTanchuangClose.CallBack = function() + self:OnBtnCloseClick() + end +end + +function XUiPartnerSkillPreview:UpdateSkillOptionBtnGroup() + for index,skillgroup in pairs(self.SkillGroupList) do + local btn = self.BtnSkillOptionList[index] + if not btn then + local obj = CS.UnityEngine.Object.Instantiate(self.BtnSkillOption, self.PanelBtnSkillOptionGroup.transform) + obj.gameObject:SetActiveEx(true) + btn = obj:GetComponent("XUiButton") + self.BtnSkillOptionList[index] = btn + end + + btn:SetName(skillgroup:GetSkillName()) + btn:SetRawImage(skillgroup:GetSkillIcon()) + btn:ShowTag(skillgroup:GetIsLock()) + end + self.PanelBtnSkillOptionGroup:Init(self.BtnSkillOptionList, function(index) self:SelectSkill(index) end) + self.PanelBtnSkillOptionGroup:SelectIndex(self.CurSkillIndex) +end + +function XUiPartnerSkillPreview:SelectSkill(index) + self.CurSkillIndex = index + self:UpdateElementBtnGroup() +end + +function XUiPartnerSkillPreview:UpdateElementBtnGroup() + if self.SkillType == XPartnerConfigs.SkillType.MainSkill then + local skillgroup = self.SkillGroupList[self.CurSkillIndex] + local elementList = skillgroup:GetElementList() + self.CurElementIndex = self.CurElementIndex <= #elementList and self.CurElementIndex or DefaultIndex + + for index,element in pairs(elementList) do + local btn = self.BtnElementList[index] + if not btn then + local obj = CS.UnityEngine.Object.Instantiate(self.BtnElement, self.PanelBtnElementGroup.transform) + obj.gameObject:SetActiveEx(true) + btn = obj:GetComponent("XUiButton") + self.BtnElementList[index] = btn + end + local elementConfig = XCharacterConfigs.GetCharElement(element) + btn:SetName(elementConfig.ElementName) + btn:SetRawImage(elementConfig.Icon2) + end + + self.PanelBtnElementGroup:Init(self.BtnElementList, function(index) self:SelectElement(index) end) + self.PanelBtnElementGroup:SelectIndex(self.CurElementIndex) + self.PanelBtnElementGroup.gameObject:SetActiveEx(true) + else + self.PanelBtnElementGroup.gameObject:SetActiveEx(false) + self:SetupDynamicTable() + end +end + +function XUiPartnerSkillPreview:SelectElement(index) + self.CurElementIndex = index + self:SetupDynamicTable() + self:PlayAnimation("QieHuan") +end + +function XUiPartnerSkillPreview:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelSkillDescList) + self.DynamicTable:SetProxy(XUiGridSkillDesc) + self.DynamicTable:SetDelegate(self) + self.GridSkillDesc.gameObject:SetActiveEx(false) +end + +function XUiPartnerSkillPreview:SetupDynamicTable() + self.PageDatas = {} + local skillGroup = self.SkillGroupList[self.CurSkillIndex] + if self.SkillType == XPartnerConfigs.SkillType.MainSkill then + for level = 1,skillGroup:GetLevelLimit() do + local entity = XPartnerMainSkillGroup.New(skillGroup:GetId()) + local tmpData = {} + tmpData.Level = level + tmpData.IsLock = skillGroup:GetIsLock() + tmpData.ActiveSkillId = skillGroup:GetSkillIdByElementIndex(self.CurElementIndex) + tmpData.Type = self.SkillType + entity:UpdateData(tmpData) + table.insert(self.PageDatas,entity) + end + elseif self.SkillType == XPartnerConfigs.SkillType.PassiveSkill then + for level = 1,skillGroup:GetLevelLimit() do + local entity = XPartnerPassiveSkillGroup.New(skillGroup:GetId()) + local tmpData = {} + tmpData.Level = level + tmpData.IsLock = skillGroup:GetIsLock() + tmpData.ActiveSkillId = skillGroup:GetActiveSkillId() + tmpData.Type = self.SkillType + entity:UpdateData(tmpData) + table.insert(self.PageDatas,entity) + end + end + + local selectIndex = 1 + for index,data in pairs(self.PageDatas) do + if skillGroup:GetLevel() == data:GetLevel() then + selectIndex = index + break + end + end + + self.DynamicTable:SetDataSource(self.PageDatas) + self.DynamicTable:ReloadDataSync(selectIndex) +end + +function XUiPartnerSkillPreview:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local curLevel = self.SkillGroupList[self.CurSkillIndex]:GetLevel() + grid:UpdateGrid(self.PageDatas[index], curLevel) + end +end + +function XUiPartnerSkillPreview:OnBtnCloseClick() + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPartner/PartnerStrengthenSkip/XUiPartnerStrengthenSkip.lua b/Resources/Scripts/XUi/XUiPartner/PartnerStrengthenSkip/XUiPartnerStrengthenSkip.lua new file mode 100644 index 00000000..4726e83d --- /dev/null +++ b/Resources/Scripts/XUi/XUiPartner/PartnerStrengthenSkip/XUiPartnerStrengthenSkip.lua @@ -0,0 +1,33 @@ +local XUiPartnerStrengthenSkip = XLuaUiManager.Register(XLuaUi, "UiPartnerStrengthenSkip") + +function XUiPartnerStrengthenSkip:OnAwake() + self:InitAutoScript() + self.PanelGridSkip.gameObject:SetActive(false) +end + +function XUiPartnerStrengthenSkip:OnStart(skipIds) + self.GridPool = {} + self:Refresh(skipIds) +end + +function XUiPartnerStrengthenSkip:Refresh(skipIds) + + XUiHelper.CreateTemplates(self, self.GridPool, skipIds, XUiGridSkip.New, self.PanelGridSkip, self.PanelContent, function(grid, data) + grid:Refresh(data) + end) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPartnerStrengthenSkip:InitAutoScript() + self:AutoAddListener() +end + +function XUiPartnerStrengthenSkip:AutoAddListener() + self:RegisterClickEvent(self.BtnClose, self.OnBtnCloseClick) + self:RegisterClickEvent(self.BtnTanchuangClose, self.OnBtnCloseClick) +end +-- auto +function XUiPartnerStrengthenSkip:OnBtnCloseClick() + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPassport/Card/XUiPassportCard.lua b/Resources/Scripts/XUi/XUiPassport/Card/XUiPassportCard.lua new file mode 100644 index 00000000..6b0a10ad --- /dev/null +++ b/Resources/Scripts/XUi/XUiPassport/Card/XUiPassportCard.lua @@ -0,0 +1,132 @@ +local XUiPassportCardGrid = require("XUi/XUiPassport/Card/XUiPassportCardGrid") + +local XUiPassportCard = XLuaUiManager.Register(XLuaUi, "UiPassportCard") + +local CSXTextManagerGetText = CS.XTextManager.GetText +local tableInsert = table.insert + +--购买通行证 +function XUiPassportCard:OnAwake() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.HongKa) + self:RegisterButtonEvent() +end + +function XUiPassportCard:OnStart(passportId, closeCb) + self.PassportId = passportId + self.CloseCb = closeCb + + self.DynamicTable = XDynamicTableNormal.New(self.PanelIconList.transform) + self.DynamicTable:SetProxy(XUiPassportCardGrid) + self.DynamicTable:SetDelegate(self) + self.PanelBagItem.gameObject:SetActive(false) + self:UpdateDynamicTable(passportId) + + self:UpdateDesc(passportId) + self:UpdateFashionShow(passportId) + self:InitBtnXqActive(passportId) +end + +function XUiPassportCard:OnEnable() + self:Refresh() +end + +function XUiPassportCard:OnDestroy() + if self.CloseCb then + self.CloseCb() + end +end + +function XUiPassportCard:InitBtnXqActive(passportId) + local fashionId = XPassportConfigs.GetPassportBuyFashionShowFashionId(passportId) + self.BtnXq.gameObject:SetActiveEx(XTool.IsNumberValid(fashionId)) +end + +function XUiPassportCard:Refresh() + local passportId = self:GetPassportId() + local isUnLock = XDataCenter.PassportManager.GetPassportInfos(passportId) and true or false + self.BtnBuy:SetDisable(isUnLock, not isUnLock) + + local costItemId = XPassportConfigs.GetPassportTypeInfoCostItemId(passportId) + local costItemCount = XPassportConfigs.GetPassportTypeInfoCostItemCount(passportId) + local costItemName = "" --策划需求,不显示道具名字 + local btnName = isUnLock and CSXTextManagerGetText("AlreadyBuy") or CSXTextManagerGetText("PassportBtnBuyPassportDesc", costItemCount, costItemName) + self.BtnBuy:SetName(btnName) + + if self.IconBtnBuy then + local costItemIcon = XItemConfigs.GetItemIconById(costItemId) + self.IconBtnBuy:SetRawImage(costItemIcon) + end +end + +function XUiPassportCard:UpdateFashionShow(passportId) + local isHavePassportId = XTool.IsNumberValid(passportId) + if isHavePassportId then + local icon = XPassportConfigs.GetPassportBuyFashionShowIcon(passportId) + self.RImgShow:SetRawImage(icon) + end + + self.RImgShow.gameObject:SetActiveEx(isHavePassportId) +end + +function XUiPassportCard:UpdateDesc(passportId) + self.TxtName.text = XPassportConfigs.GetPassportTypeInfoName(passportId) + + local icon = XPassportConfigs.GetPassportTypeInfoIcon(passportId) + self.RImgIcon:SetRawImage(icon) + + local buyDesc = XPassportConfigs.GetPassportTypeInfoBuyDesc(passportId) + self.TxtMessage.text = string.gsub(buyDesc, "\\n", "\n") +end + +function XUiPassportCard:UpdateDynamicTable(passportId) + self.BuyRewardShowIdList = XPassportConfigs.GetBuyRewardShowIdList(passportId) + self.DynamicTable:SetDataSource(self.BuyRewardShowIdList) + self.DynamicTable:ReloadDataSync() +end + +function XUiPassportCard:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local passportRewardId = self.BuyRewardShowIdList[index] + grid:Refresh(passportRewardId) + end +end + +function XUiPassportCard:RegisterButtonEvent() + self:RegisterClickEvent(self.BtnClose, self.Close) + self:RegisterClickEvent(self.BtnXq, self.OnBtnXqClick) + self.BtnBuy.CallBack = handler(self, self.OnBtnBuyClick) +end + +function XUiPassportCard:OnBtnXqClick() + local passportId = self:GetPassportId() + local fashionId = XPassportConfigs.GetPassportBuyFashionShowFashionId(passportId) + local isWeaponFahion = XPassportConfigs.IsPassportBuyFashionShowIsWeaponFahion(passportId) + XLuaUiManager.Open("UiFashionDetail", fashionId, isWeaponFahion) +end + +function XUiPassportCard:OnBtnBuyClick() + local passportId = self:GetPassportId() + local costItemId = XPassportConfigs.GetPassportTypeInfoCostItemId(passportId) + local haveCostItemCount = XDataCenter.ItemManager.GetCount(costItemId) + local costItemCount = XPassportConfigs.GetPassportTypeInfoCostItemCount(passportId) + local passportName = XPassportConfigs.GetPassportTypeInfoName(passportId) + local costItemName = XItemConfigs.GetItemNameById(costItemId) + local title = CSXTextManagerGetText("BuyConfirmTipsTitle") + local desc = CSXTextManagerGetText("PassportBuyPassportTipsDesc", costItemCount, costItemName, passportName) + local sureCallback = function() + if haveCostItemCount < costItemCount then + XUiManager.TipText("ShopItemHongKaNotEnough") + XLuaUiManager.Open("UiPurchase", XPurchaseConfigs.TabsConfig.Pay) + return + end + XDataCenter.PassportManager.RequestPassportBuyPassport(passportId, handler(self, self.Refresh)) + end + + XUiManager.DialogTip(title, desc, nil, nil, sureCallback) +end + +function XUiPassportCard:GetPassportId() + return self.PassportId +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPassport/Card/XUiPassportCardGrid.lua b/Resources/Scripts/XUi/XUiPassport/Card/XUiPassportCardGrid.lua new file mode 100644 index 00000000..6d48dd4e --- /dev/null +++ b/Resources/Scripts/XUi/XUiPassport/Card/XUiPassportCardGrid.lua @@ -0,0 +1,34 @@ +local XUiPassportCardGrid = XClass(nil, "XUiPassportCardGrid") + +local CSXTextManagerGetText = CS.XTextManager.GetText + +function XUiPassportCardGrid:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + self.RewardPanelList = {} +end + +function XUiPassportCardGrid:Init(rootUi) + self.RootUi = rootUi +end + +function XUiPassportCardGrid:Refresh(passportBuyRewardShowId) + local level = XPassportConfigs.GetPassportBuyRewardShowLevel(passportBuyRewardShowId) + if XTool.IsNumberValid(level) then + self.TextUnLock.text = CSXTextManagerGetText("PassportLevelUnLockDesc", level) + self.RImgUnLock.gameObject:SetActiveEx(true) + else + self.RImgUnLock.gameObject:SetActiveEx(false) + end + + if not self.GridCommon then + self.GridCommon = XUiGridCommon.New(self.RootUi, self.Gridicon) + end + + local rewardData = XPassportConfigs.GetPassportBuyRewardShowRewardData(passportBuyRewardShowId, true) + self.GridCommon:Refresh(rewardData) +end + +return XUiPassportCardGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPassport/UpLevel/XUiPassportUpLevel.lua b/Resources/Scripts/XUi/XUiPassport/UpLevel/XUiPassportUpLevel.lua new file mode 100644 index 00000000..7d2531b5 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPassport/UpLevel/XUiPassportUpLevel.lua @@ -0,0 +1,250 @@ +local XUiPassportUpLevelGrid = require("XUi/XUiPassport/UpLevel/XUiPassportUpLevelGrid") + +local XUiPassportUpLevel = XLuaUiManager.Register(XLuaUi, "UiPassportUpLevel") + +local MinSelectCount = 1 +local CSXTextManagerGetText = CS.XTextManager.GetText +local tableInsert = table.insert +local mathMax = math.max +local mathFloor = math.floor + +--购买等级 +function XUiPassportUpLevel:OnAwake() + self.SpendBuyCount = 0 --花费多少 + self.SpendBuyExp = 0 --购买多少经验 + self.LevelAfter = 0 --购买后提升至多少级 + self.CurLevelIdListCount = 0 --当前滑动列表显示的数量 + self.IsShowGridEffect = false --滑动列表中新出现的格子显示特效 +end + +function XUiPassportUpLevel:OnStart() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem) + self:RegisterButtonEvent() + self:SetSelectCount(1) + self.PassportBaseInfo = XDataCenter.PassportManager.GetPassportBaseInfo() + + self.MaxLevel = XPassportConfigs.GetPassportMaxLevel() + self.MaxSelectCount = self.MaxLevel - self.PassportBaseInfo:GetLevel() + + local expItemIcon = XItemConfigs.GetItemIconById(XDataCenter.ItemManager.ItemId.PassportExp) + self.RImgIconBuy:SetRawImage(expItemIcon) + + self.DynamicTable = XDynamicTableNormal.New(self.PanelRewardList.transform) + self.DynamicTable:SetProxy(XUiPassportUpLevelGrid) + self.DynamicTable:SetDelegate(self) + self.GridStage.gameObject:SetActive(false) +end + +function XUiPassportUpLevel:OnEnable() + XEventManager.AddEventListener(XEventId.EVENT_NOTIFY_PASSPORT_BASE_INFO, self.Refresh, self) + self.TxtLevelNow.text = self.PassportBaseInfo:GetLevel() + self:Refresh() +end + +function XUiPassportUpLevel:OnDisable() + XEventManager.RemoveEventListener(XEventId.EVENT_NOTIFY_PASSPORT_BASE_INFO, self.Refresh, self) +end + +function XUiPassportUpLevel:RegisterButtonEvent() + self:RegisterClickEvent(self.BtnCancel, self.Close) + self:RegisterClickEvent(self.BtnTanchuangClose, self.Close) + self:RegisterClickEvent(self.BtnConfirm, self.OnBtnConfirmClick) + self.BtnAddSelect.CallBack = handler(self, self.OnBtnAddClick) + self.BtnMinusSelect.CallBack = handler(self, self.OnBtnReduceClick) + self.WidgetBtnMinusLongClick = XUiButtonLongClick.New(self.WidgetBtnMinusSelect, 100, self, nil, self.BtnMinusSelectLongClickCallback, nil, true) + self.WidgetBtnAddMinusLongClick = XUiButtonLongClick.New(self.WidgetBtnAddSelect, 100, self, nil, self.BtnAddSelectLongClickCallback, nil, true) + self.TxtSelect.onValueChanged:AddListener(function() self:OnInputFieldTextChanged() end) +end + +function XUiPassportUpLevel:Refresh() + self:UpdateTextSelectCount() + self:UpdateBtnSelectState() +end + +function XUiPassportUpLevel:UpdateBtnSelectState() + local isDisable = self.SelectCount <= MinSelectCount + self.BtnMinusSelect:SetDisable(isDisable, not isDisable) + + local maxSelectCount = self:GetMaxSelectCount() + isDisable = self.SelectCount >= maxSelectCount + self.BtnAddSelect:SetDisable(isDisable, not isDisable) +end + +function XUiPassportUpLevel:UpdateTextSelectCount() + local selectCount = self:GetSelectCount() + local currLevel = self.PassportBaseInfo:GetLevel() + local maxSelectCount = self:GetMaxSelectCount() + local levelAfter = math.min(self.MaxLevel, currLevel + selectCount) + self.TxtLevelAfter.text = levelAfter + self.TxtSelect.text = selectCount + + local spendBuyCount = 0 --花费多少 + local levelId + local costItemId = XPassportConfigs.GetBuyLevelCostItemId() + local costItemIcon = XItemConfigs.GetItemIconById(costItemId) + local costItemCount + local spendBuyExp = 0 --购买多少经验 + local expCfg + local levelIdList = {} --要购买的等级Id列表 + for i = currLevel + 1, levelAfter do + levelId = XPassportConfigs.GetPassportLevelId(i) + costItemCount = levelId and XPassportConfigs.GetPassportLevelCostItemCount(levelId) or 0 + spendBuyCount = spendBuyCount + costItemCount + + expCfg = levelId and XPassportConfigs.GetPassportLevelTotalExp(levelId) or 0 + spendBuyExp = spendBuyExp + expCfg + + if levelId then + tableInsert(levelIdList, levelId) + end + end + self.RImgIconSpend:SetRawImage(costItemIcon) + self.TxtTips.text = CSXTextManagerGetText("PassportSpendBuyDesc", spendBuyCount) + self.TxtBuy.text = spendBuyExp + self.TxtLevel.text = CSXTextManagerGetText("PassportBuyLevelUpDesc", levelAfter) + + self:SetSpendBuyExp(spendBuyExp) + self:SetSpendBuyCount(spendBuyCount) + self:SetLevelAfter(levelAfter) + + self:UpdateDynamicTable(levelIdList) +end + +function XUiPassportUpLevel:UpdateDynamicTable(levelIdList) + self.IsShowGridEffect = #levelIdList > self.CurLevelIdListCount + self.CurLevelIdListCount = #levelIdList + self.LevelIdList = XTool.ReverseList(levelIdList) + self.DynamicTable:SetDataSource(levelIdList) + self.DynamicTable:ReloadDataSync(1) +end + +function XUiPassportUpLevel:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local levelId = self.LevelIdList[index] + grid:Refresh(levelId) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_RELOAD_COMPLETED then + if not self.IsShowGridEffect then + return + end + + local grid = self.DynamicTable:GetGridByIndex(1) + if grid then + grid:ShowEffect() + end + end +end + +function XUiPassportUpLevel:OnBtnReduceClick() + self:SetSelectCount(self.SelectCount - 1) + self:Refresh() +end + +function XUiPassportUpLevel:OnBtnAddClick() + self:SetSelectCount(self.SelectCount + 1) + self:Refresh() +end + +function XUiPassportUpLevel:BtnMinusSelectLongClickCallback(time) + if self.SelectCount == MinSelectCount then + return + end + + local delta = mathMax(0, mathFloor(time / 150)) + local count = self.SelectCount - delta + if count <= MinSelectCount then + count = MinSelectCount + end + self:SetSelectCount(count) + self:Refresh() +end + +function XUiPassportUpLevel:BtnAddSelectLongClickCallback(time) + local maxCount = self:GetMaxSelectCount() + if maxCount and self.SelectCount >= maxCount then + return + end + local delta = mathMax(0, mathFloor(time / 150)) + local count = self.SelectCount + delta + if maxCount and count >= maxCount then + count = maxCount + end + + self:SetSelectCount(count) + self:Refresh() +end + +function XUiPassportUpLevel:OnBtnConfirmClick() + local costItemId = XPassportConfigs.GetBuyLevelCostItemId() + local haveItemCount = XDataCenter.ItemManager.GetCount(costItemId) + local spendBuyCount = self:GetSpendBuyCount() + + local costItemName = XItemConfigs.GetItemNameById(costItemId) + local spendBuyExp = self:GetSpendBuyExp() + local spendBuyExpName = XItemConfigs.GetItemNameById(XDataCenter.ItemManager.ItemId.PassportExp) + local levelAfter = self:GetLevelAfter() + local title = CSXTextManagerGetText("BuyConfirmTipsTitle") + local desc = CSXTextManagerGetText("PassportBuyLevelTipsDesc", spendBuyCount, costItemName, spendBuyExp, spendBuyExpName, levelAfter) + + local sureCallback = function() + if haveItemCount < spendBuyCount then + XUiManager.TipText("ShopItemPaidGemNotEnough") + XLuaUiManager.Open("UiPurchase", XPurchaseConfigs.TabsConfig.HK) + return + end + XDataCenter.PassportManager.RequestPassportBuyExp(levelAfter, function() self:Close() end) + end + + XUiManager.DialogTip(title, desc, nil, nil, sureCallback) +end + +function XUiPassportUpLevel:OnInputFieldTextChanged() + local selectCount = tonumber(self.TxtSelect.text) or 0 + if selectCount == self.SelectCount then + return + end + + local maxCount = self:GetMaxSelectCount() + selectCount = math.max(MinSelectCount, selectCount) + selectCount = math.min(maxCount, selectCount) + + self:SetSelectCount(selectCount) + self:Refresh() +end + +function XUiPassportUpLevel:SetLevelAfter(levelAfter) + self.LevelAfter = levelAfter +end + +function XUiPassportUpLevel:GetLevelAfter() + return self.LevelAfter +end + +function XUiPassportUpLevel:SetSpendBuyExp(spendBuyExp) + self.SpendBuyExp = spendBuyExp +end + +function XUiPassportUpLevel:GetSpendBuyExp() + return self.SpendBuyExp +end + +function XUiPassportUpLevel:SetSpendBuyCount(spendBuyCount) + self.SpendBuyCount = spendBuyCount +end + +function XUiPassportUpLevel:GetSpendBuyCount() + return self.SpendBuyCount +end + +function XUiPassportUpLevel:SetSelectCount(selectCount) + self.SelectCount = selectCount +end + +function XUiPassportUpLevel:GetSelectCount() + return self.SelectCount +end + +function XUiPassportUpLevel:GetMaxSelectCount() + return self.MaxSelectCount +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPassport/UpLevel/XUiPassportUpLevelGrid.lua b/Resources/Scripts/XUi/XUiPassport/UpLevel/XUiPassportUpLevelGrid.lua new file mode 100644 index 00000000..b14c4dfd --- /dev/null +++ b/Resources/Scripts/XUi/XUiPassport/UpLevel/XUiPassportUpLevelGrid.lua @@ -0,0 +1,68 @@ +local XUiPassportUpLevelGrid = XClass(nil, "XUiPassportUpLevelGrid") + +local CSXTextManagerGetText = CS.XTextManager.GetText +local MaxGridCount = 3 + +function XUiPassportUpLevelGrid:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + self.RewardPanelList = {} + self:SetImgEffectActive(false) +end + +function XUiPassportUpLevelGrid:Init(rootUi) + self.RootUi = rootUi +end + +function XUiPassportUpLevelGrid:Refresh(levelId) + self:SetImgEffectActive(false) + + local level = XPassportConfigs.GetPassportLevel(levelId) + self.Text.text = CSXTextManagerGetText("PassportLevelUnLockSupplyDesc", level) + + local unLockPassportRewardIdList = XPassportConfigs.GetUnLockPassportRewardIdListByLevel(level) + local gridCostItem + local panel + local rewardData + for i, passportRewardId in ipairs(unLockPassportRewardIdList) do + rewardData = XPassportConfigs.GetPassportRewardData(passportRewardId, true) + gridCostItem = self["GridCostItem" .. i] + panel = self.RewardPanelList[i] + if gridCostItem and not panel then + panel = XUiGridCommon.New(self.RootUi, gridCostItem) + table.insert(self.RewardPanelList, panel) + end + + if gridCostItem and panel and rewardData then + panel:Refresh(rewardData) + gridCostItem.gameObject:SetActiveEx(true) + else + gridCostItem.gameObject:SetActiveEx(false) + end + end + + for i = #unLockPassportRewardIdList + 1, MaxGridCount do + gridCostItem = self["GridCostItem" .. i] + if gridCostItem then + gridCostItem.gameObject:SetActiveEx(false) + end + end +end + +function XUiPassportUpLevelGrid:ShowEffect() + self:SetImgEffectActive(true) + XScheduleManager.ScheduleOnce(function() + self:SetImgEffectActive(false) + end, XScheduleManager.SECOND) +end + +function XUiPassportUpLevelGrid:SetImgEffectActive(isActive) + if XTool.UObjIsNil(self.ImgEffect) then + return + end + self.ImgEffect.gameObject:SetActiveEx(isActive) +end + +return XUiPassportUpLevelGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPassport/XUiPassport.lua b/Resources/Scripts/XUi/XUiPassport/XUiPassport.lua new file mode 100644 index 00000000..a12ce13b --- /dev/null +++ b/Resources/Scripts/XUi/XUiPassport/XUiPassport.lua @@ -0,0 +1,290 @@ +local XUiPassportPanel = require("XUi/XUiPassport/XUiPassportPanel") +local XUiPassportPanelTaskActivity = require("XUi/XUiPassport/XUiPassportPanelTaskActivity") +local XUiPassportPanelTaskDaily = require("XUi/XUiPassport/XUiPassportPanelTaskDaily") +local XUiPassportPanelTaskWeekly = require("XUi/XUiPassport/XUiPassportPanelTaskWeekly") + +local XUiPassport = XLuaUiManager.Register(XLuaUi, "UiPassport") + +local tableInsert = table.insert +local BtnTaskChildMaxCount = 3 --任务页签的子页签最大数量 +local BtnGetClickDefaultIndex = 3 --点击跳转至挑战任务页签的下标 + +--战斗通行证主界面 +function XUiPassport:OnAwake() + self.CurWeeklyGroupId = XPassportConfigs.GetPassportTaskGroupIdByType(XPassportConfigs.TaskType.Weekly) --记录当前第几周 +end + +function XUiPassport:OnStart() + self:InitPanel() + self:RegisterButtonEvent() + self:InitUi() + self:InitTab() + self:InitRedPoint() +end + +function XUiPassport:OnEnable() + self:CheckOpenAutoGetTaskRewardListView() + + if not XDataCenter.PassportManager.CheckActivityIsOpen() then + return + end + + XEventManager.AddEventListener(XEventId.EVENT_BUY_EXP_COMPLEATE, self.UpdatePanel, self) + XEventManager.AddEventListener(XEventId.EVENT_NOTIFY_PASSPORT_BASE_INFO, self.UpdateLevel, self) + XEventManager.AddEventListener(XEventId.EVENT_AUTO_GET_TASK_REWARD_LIST, self.CheckOpenAutoGetTaskRewardListView, self) + self:Refresh() + + self:StartTimer() +end + +function XUiPassport:OnDisable() + self:StopTimer() + for _, panel in ipairs(self.PanelViews) do + if not XTool.IsTableEmpty(panel) then + panel:Hide() + end + end + XEventManager.RemoveEventListener(XEventId.EVENT_BUY_EXP_COMPLEATE, self.UpdatePanel, self) + XEventManager.RemoveEventListener(XEventId.EVENT_NOTIFY_PASSPORT_BASE_INFO, self.UpdateLevel, self) + XEventManager.RemoveEventListener(XEventId.EVENT_AUTO_GET_TASK_REWARD_LIST, self.CheckOpenAutoGetTaskRewardListView, self) +end + +--未按时领取的任务奖励,等打开该界面再弹出提示 +function XUiPassport:CheckOpenAutoGetTaskRewardListView() + local rewardList = XDataCenter.PassportManager.GetCookieAutoGetTaskRewardList() + if not XTool.IsTableEmpty(rewardList) then + local title = CS.XTextManager.GetText("PassportAutoGetTipsTitle") + local desc = CS.XTextManager.GetText("PassportAutoGetTipsDesc") + XLuaUiManager.Open("UiPassportTips", rewardList, title, desc) + + XDataCenter.PassportManager.ClearCookieAutoGetTaskRewardList() + end +end + +function XUiPassport:InitRedPoint() + XRedPointManager.AddRedPointEvent(self.Btn01, self.OnCheckRewardRedPoint, self, { XRedPointConditions.Types.CONDITION_PASSPORT_PANEL_REWARD_RED }) + XRedPointManager.AddRedPointEvent(self.Btn02, self.OnCheckTaskRedPoint, self, + { XRedPointConditions.Types.CONDITION_PASSPORT_TASK_DAILY_RED, + XRedPointConditions.Types.CONDITION_PASSPORT_TASK_WEEKLY_RED, + XRedPointConditions.Types.CONDITION_PASSPORT_TASK_ACTIVITY_RED }) + XRedPointManager.AddRedPointEvent(self.BtnChild01, self.OnCheckTaskDailyRedPoint, self, { XRedPointConditions.Types.CONDITION_PASSPORT_TASK_DAILY_RED }) + XRedPointManager.AddRedPointEvent(self.BtnChild02, self.OnCheckTaskWeeklyRedPoint, self, { XRedPointConditions.Types.CONDITION_PASSPORT_TASK_WEEKLY_RED }) + XRedPointManager.AddRedPointEvent(self.BtnChild03, self.OnCheckTaskActivityRedPoint, self, { XRedPointConditions.Types.CONDITION_PASSPORT_TASK_ACTIVITY_RED }) +end + +function XUiPassport:InitPanel() + self.PassportPanel = XUiPassportPanel.New(self.PanelPassport, self) + self.PassportPanelTaskActivity = XUiPassportPanelTaskActivity.New(self.PanelTaskActivity, self) + self.PassportPanelTaskDaily = XUiPassportPanelTaskDaily.New(self.PanelTaskDaily, self) + self.PassportPanelTaskWeekly = XUiPassportPanelTaskWeekly.New(self.PanelTaskWeekly, self) + self:InitSubPanel() +end + +function XUiPassport:InitSubPanel() + self.PanelViews = {} + tableInsert(self.PanelViews, self.PassportPanel) + tableInsert(self.PanelViews, {}) --为了和页签数量相同占位用 + tableInsert(self.PanelViews, self.PassportPanelTaskDaily) + tableInsert(self.PanelViews, self.PassportPanelTaskWeekly) + tableInsert(self.PanelViews, self.PassportPanelTaskActivity) +end + +function XUiPassport:InitTab() + self.BtnGroupList = {} + + tableInsert(self.BtnGroupList, self.Btn01) --战略补给 + tableInsert(self.BtnGroupList, self.Btn02) --任务 + + --任务下的子页签 + local tagCount = #self.BtnGroupList + local btn + for i = 1, BtnTaskChildMaxCount do + btn = self["BtnChild0" .. i] + if btn then + self["BtnChild0" .. i].SubGroupIndex = tagCount + tableInsert(self.BtnGroupList, btn) + end + end + + local defaultTagIndex = XDataCenter.PassportManager.GetCurrMainViewSelectTagIndex() + self.PanelNoticeTitleBtnGroup:Init(self.BtnGroupList, function(index) self:OnSelectedTag(index) end) + self.PanelNoticeTitleBtnGroup:SelectIndex(defaultTagIndex) +end + +function XUiPassport:OnSelectedTag(index) + if self.CurrSelectTagIndex == index then + return + end + + self.CurrSelectTagIndex = index + XDataCenter.PassportManager.CatchCurrMainViewSelectTagIndex(index) + self:UpdatePanel() +end + +function XUiPassport:InitUi() + self.AssetActivityPanel = XUiPanelActivityAsset.New(self.PanelSpecialTool) + self.ItemIdList = {XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin} + for _, itemId in ipairs(self.ItemIdList) do + XDataCenter.ItemManager.AddCountUpdateListener(itemId, function() + self.AssetActivityPanel:Refresh(self.ItemIdList) + end, self.AssetActivityPanel) + end + self.AssetActivityPanel:Refresh(self.ItemIdList) + + XDataCenter.ItemManager.AddCountUpdateListener(XDataCenter.ItemManager.ItemId.PassportExp, function() + self:UpdateExp() + end, self) +end + +function XUiPassport:Refresh() + self:UpdateActivityTime() + self:UpdateLevel() + self:UpdateExp() + self:UpdatePanel() +end + +function XUiPassport:UpdatePanel() + local currSelectTagIndex = self:GetCurrSelectTagIndex() + for i, panel in ipairs(self.PanelViews) do + if i == currSelectTagIndex then + panel:Show() + elseif not XTool.IsTableEmpty(panel) then + panel:Hide() + end + end +end + +function XUiPassport:UpdateTaskPanel() + self.PassportPanelTaskDaily:Refresh() + self.PassportPanelTaskActivity:Refresh() + self.PassportPanelTaskWeekly:Refresh() +end + +function XUiPassport:UpdateLevel() + local passportBaseInfo = XDataCenter.PassportManager.GetPassportBaseInfo() + local level = passportBaseInfo:GetLevel() + self.TxtLevel.text = level +end + +function XUiPassport:UpdateExp() + local passportBaseInfo = XDataCenter.PassportManager.GetPassportBaseInfo() + local itemId = XDataCenter.ItemManager.ItemId.PassportExp + local curExp = XDataCenter.ItemManager.GetCount(itemId) + local level = passportBaseInfo:GetLevel() + local maxLevel = XPassportConfigs.GetPassportMaxLevel() + + local curLevelId = XTool.IsNumberValid(level) and XPassportConfigs.GetPassportLevelId(level) + local curLevelExp = curLevelId and XPassportConfigs.GetPassportLevelTotalExp(curLevelId) or 0 + + local upperLevel = level - 1 + + local nextLevel = math.min(maxLevel, level + 1) + local nextLevelId = XPassportConfigs.GetPassportLevelId(nextLevel) + local nextLevelTotalExp = nextLevelId and XPassportConfigs.GetPassportLevelTotalExp(nextLevelId) + + curExp = upperLevel > 0 and curExp - curLevelExp or curExp + nextLevelTotalExp = (upperLevel > 0 and XTool.IsNumberValid(nextLevelTotalExp)) and nextLevelTotalExp - curLevelExp or nextLevelTotalExp --初始等级1服务端下发的经验是0 + local progress = XTool.IsNumberValid(nextLevelTotalExp) and curExp / nextLevelTotalExp or 0 + + self.TxtPointNum.text = string.format("%s/%s", curExp, nextLevelTotalExp) --(玩家总经验-之前等级升级需要经验之和)/ 升至下一等级需要的经验 + self.ImgProgress.fillAmount = math.min(1, progress) +end + +function XUiPassport:UpdateActivityTime() + local timeId = XPassportConfigs.GetPassportActivityTimeId() + local startTime, endTime = XFunctionManager.GetTimeByTimeId(timeId) + local startTimeStr = os.date("%m/%d",startTime) + local endTimeStr = os.date("%m/%d",endTime) + local totleWeekly, currWeekly = XPassportConfigs.GetPassportWeeklyTaskGroupCountAndCurrWeekly() + self.TxtTime01.text = CS.XTextManager.GetText("PassportActivityTime", startTimeStr, endTimeStr, totleWeekly) + self.TxtTime02.text = CS.XTextManager.GetText("PassportActivityCurrWeekly", currWeekly) +end + +function XUiPassport:RegisterButtonEvent() + self:RegisterClickEvent(self.BtnBack, self.Close) + self:RegisterClickEvent(self.BtnMainUi, function() XLuaUiManager.RunMain() end) + self:RegisterClickEvent(self.BtnGet, self.OnBtnGetClick) + self:RegisterClickEvent(self.BtnBuy, self.OnBtnBuyClick) + self:BindHelpBtn(self.BtnHelp, "Passport") +end + +--跳转至挑战任务页签 +function XUiPassport:OnBtnGetClick() + self.PanelNoticeTitleBtnGroup:SelectIndex(BtnGetClickDefaultIndex) +end + +--购买等级 +function XUiPassport:OnBtnBuyClick() + local passportBaseInfo = XDataCenter.PassportManager.GetPassportBaseInfo() + local level = passportBaseInfo:GetLevel() + local maxLevel = XPassportConfigs.GetPassportMaxLevel() + if level >= maxLevel then + XUiManager.TipText("PassportBuyLevelMaxDesc") + return + end + XLuaUiManager.Open("UiPassportUpLevel", handler(self, self.Refresh)) +end + +function XUiPassport:OnGetEvents() + return { + XEventId.EVENT_FINISH_TASK, + XEventId.EVENT_TASK_SYNC, + } +end + +function XUiPassport:OnNotify(event) + if event == XEventId.EVENT_FINISH_TASK + or event == XEventId.EVENT_TASK_SYNC then + self:UpdateTaskPanel() + end +end + +function XUiPassport:GetCurrSelectTagIndex() + return self.CurrSelectTagIndex +end + +function XUiPassport:OnCheckRewardRedPoint(count) + self.Btn01:ShowReddot(count >= 0) +end + +function XUiPassport:OnCheckTaskRedPoint(count) + self.Btn02:ShowReddot(count >= 0) +end + +function XUiPassport:OnCheckTaskDailyRedPoint(count) + self.BtnChild01:ShowReddot(count >= 0) +end + +function XUiPassport:OnCheckTaskWeeklyRedPoint(count) + self.BtnChild02:ShowReddot(count >= 0) +end + +function XUiPassport:OnCheckTaskActivityRedPoint(count) + self.BtnChild03:ShowReddot(count >= 0) +end + +function XUiPassport:StartTimer() + self:StopTimer() + local curWeeklyGroupId + self.Timer = XScheduleManager.ScheduleForever(function() + if not XDataCenter.PassportManager.CheckActivityIsOpen() then + return + end + + curWeeklyGroupId = XPassportConfigs.GetPassportTaskGroupIdByType(XPassportConfigs.TaskType.Weekly) + if curWeeklyGroupId ~= self.CurWeeklyGroupId then + self.CurWeeklyGroupId = curWeeklyGroupId + self:Refresh() + return + end + + self.PassportPanelTaskWeekly:UpdateTime() + end, XScheduleManager.SECOND) +end + +function XUiPassport:StopTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPassport/XUiPassportPanel.lua b/Resources/Scripts/XUi/XUiPassport/XUiPassportPanel.lua new file mode 100644 index 00000000..23610df4 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPassport/XUiPassportPanel.lua @@ -0,0 +1,204 @@ +local XUiPassportPanelGrid = require("XUi/XUiPassport/XUiPassportPanelGrid") + +local XUiPassportPanel = XClass(nil, "XUiPassportPanel") + +--通行证面板 +function XUiPassportPanel:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + + self:InitDynamicList() + self:AutoAddListener() + self:InitData() + + XRedPointManager.AddRedPointEvent(self.BtnTongBlack, self.OnCheckRewardRedPoint, self, { XRedPointConditions.Types.CONDITION_PASSPORT_PANEL_REWARD_RED }) +end + +function XUiPassportPanel:InitData() + local activityId = XPassportConfigs.GetDefaultActivityId() + self.LevelIdList = XPassportConfigs.GetPassportLevelIdList(activityId) +end + +function XUiPassportPanel:InitDynamicList() + self.DynamicTable = XDynamicTableNormal.New(self.PanelItemList) + self.DynamicTable:SetProxy(XUiPassportPanelGrid) + self.DynamicTable:SetDelegate(self) + self.Grid01.gameObject:SetActiveEx(false) + + local gridWidth = self.Grid01:GetComponent("RectTransform").rect.size.x + local panelWidth = self.PanelItemList:GetComponent("RectTransform").rect.size.x + self.DynamicTableOffsetIndex = math.floor(panelWidth / gridWidth / 2) +end + +function XUiPassportPanel:AutoAddListener() + local typeInfoIdList = XPassportConfigs.GetPassportActivityIdToTypeInfoIdList() + for i, typeInfoId in ipairs(typeInfoIdList) do + if self["BtnUnlockLeftGrid" .. i] then + XUiHelper.RegisterClickEvent(self, self["BtnUnlockLeftGrid" .. i], function() self:OnBtnUnlockLeftGridClick(typeInfoId) end) + end + end + + XUiHelper.RegisterClickEvent(self, self.BtnTongBlack, self.OnBtnTongBlackClick) +end + +function XUiPassportPanel:Refresh() + self:UpdateDynamicTable() + self:UpdateLeftGrid() +end + +--遍历DynamicTable的Grid,根据最大等级的LevelId刷新 +function XUiPassportPanel:UpdateRightGrid() + local currMaxLevel = 0 + for _, v in pairs(self.DynamicTable:GetGrids()) do + local levelIdCfg = v:GetLevelId() + local levelCfg = XPassportConfigs.GetPassportLevel(levelIdCfg) + if currMaxLevel < levelCfg then + currMaxLevel = levelCfg + end + end + + local targetLevel = XPassportConfigs.GetPassportTargetLevel(currMaxLevel) + if not targetLevel then + self.PanelRewardRight.gameObject:SetActiveEx(false) + return + else + self.PanelRewardRight.gameObject:SetActiveEx(true) + end + + self.TxtLevelRight.text = targetLevel and CS.XTextManager.GetText("PassportLevelDesc", targetLevel) or "" + + local grid + local rewardData + local typeInfoIdList = XPassportConfigs.GetPassportActivityIdToTypeInfoIdList() + local isReceiveReward --是否已领取奖励 + local isCanReceiveReward --是否可领取奖励 + local isUnLock --是否已解锁当前通行证奖励 + + for i, typeInfoId in ipairs(typeInfoIdList) do + if self["GridCommonRight" .. i] then + grid = XUiGridCommon.New(self.RootUi, self["GridCommonRight" .. i]) + local passportRewardId = XPassportConfigs.GetRewardIdByPassportIdAndLevel(typeInfoId, targetLevel) + rewardData = passportRewardId and XPassportConfigs.GetPassportRewardData(passportRewardId) + if XTool.IsNumberValid(rewardData) then + grid:Refresh(rewardData) + grid.GameObject:SetActive(true) + + isReceiveReward = XDataCenter.PassportManager.IsReceiveReward(typeInfoId, passportRewardId) + isCanReceiveReward = XDataCenter.PassportManager.IsCanReceiveReward(typeInfoId, passportRewardId) + if not isReceiveReward and isCanReceiveReward then + grid:SetClickCallback(function() self:GridOnClick(passportRewardId) end) + else + grid:AutoAddListener() + end + else + isCanReceiveReward = nil + isReceiveReward = nil + grid.GameObject:SetActive(false) + end + end + + --已领取标志 + if self["ImgGetOutRight" .. i] then + self["ImgGetOutRight" .. i].gameObject:SetActiveEx(isReceiveReward) + end + + --未解锁标志 + if self["ImgLockingRight" .. i] then + local passportInfo = XDataCenter.PassportManager.GetPassportInfos(typeInfoId) + local isUnLock = passportInfo and true or false + self["ImgLockingRight" .. i].gameObject:SetActiveEx(not isUnLock) + end + + --可领取特效 + local isShowEffect = not isReceiveReward and isCanReceiveReward and XTool.IsNumberValid(rewardData) + if self["PanelPermitEffect" .. i] then + self["PanelPermitEffect" .. i].gameObject:SetActiveEx(isShowEffect) + end + end +end + +function XUiPassportPanel:UpdateLeftGrid() + local typeInfoIdList = XPassportConfigs.GetPassportActivityIdToTypeInfoIdList() + local passportInfo + local isUnLock + for i, typeInfoId in ipairs(typeInfoIdList) do + passportInfo = XDataCenter.PassportManager.GetPassportInfos(typeInfoId) + isUnLock = passportInfo and true or false + if self["TxtNameLeftGrid" .. i] then + self["TxtNameLeftGrid" .. i].text = XPassportConfigs.GetPassportTypeInfoName(typeInfoId) + end + if self["ImgLockLeftGrid" .. i] then + self["ImgLockLeftGrid" .. i].gameObject:SetActiveEx(not isUnLock) + end + if self["BtnUnlockLeftGrid" .. i] then + self["BtnUnlockLeftGrid" .. i].gameObject:SetActiveEx(not isUnLock) + end + end +end + +function XUiPassportPanel:UpdateDynamicTable() + self.DynamicTable:SetDataSource(self.LevelIdList) + + local index = self:GetDynamicIndex() + self.DynamicTable:ReloadDataSync(index) +end + +function XUiPassportPanel:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self.RootUi) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local levelId = self.LevelIdList[index] + grid:Refresh(levelId) + self:UpdateRightGrid() + end +end + +function XUiPassportPanel:GetDynamicIndex() + local baseInfo = XDataCenter.PassportManager.GetPassportBaseInfo() + local currLevel = baseInfo:GetLevel() + local level + local index = 0 + for i, levelId in ipairs(self.LevelIdList) do + level = XPassportConfigs.GetPassportLevel(levelId) + if level >= currLevel then + index = i + break + end + end + + index = math.max(-1, index - self.DynamicTableOffsetIndex) --居中显示 + return index +end + +function XUiPassportPanel:OnBtnUnlockLeftGridClick(typeInfoId) + XLuaUiManager.Open("UiPassportCard", typeInfoId, handler(self, self.Refresh)) +end + +--一键领取 +function XUiPassportPanel:OnBtnTongBlackClick() + XDataCenter.PassportManager.RequestPassportRecvAllReward(handler(self, self.Refresh)) +end + +function XUiPassportPanel:OnCheckRewardRedPoint(count) + self.BtnTongBlack:ShowReddot(count >= 0) +end + +function XUiPassportPanel:Show() + self.GameObject:SetActiveEx(true) + self:Refresh() +end + +function XUiPassportPanel:Hide() + self.GameObject:SetActiveEx(false) +end + +function XUiPassportPanel:GridOnClick(passportRewardId) + local cb = function() + self.DynamicTable:ReloadDataASync() + end + XDataCenter.PassportManager.RequestPassportRecvReward(passportRewardId, cb) +end + +return XUiPassportPanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPassport/XUiPassportPanelGrid.lua b/Resources/Scripts/XUi/XUiPassport/XUiPassportPanelGrid.lua new file mode 100644 index 00000000..ce2a8db3 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPassport/XUiPassportPanelGrid.lua @@ -0,0 +1,132 @@ +local XUiPassportPanelGrid = XClass(nil, "XUiPassportPanelGrid") + +--通行证面板中间一列的格子 +function XUiPassportPanelGrid:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + self.GridObjs = {} + self:AutoAddListener() +end + +function XUiPassportPanelGrid:Init(rootUi) + self.RootUi = rootUi +end + +function XUiPassportPanelGrid:AutoAddListener() + if self.Btn then + XUiHelper.RegisterClickEvent(self, self.Btn, self.OnBtnClick) + end +end + +function XUiPassportPanelGrid:Refresh(levelId) + self.LevelId = levelId + self:UpdateLevelPanel() + self:UpdatePermitPanel() + self:UpdateRImgLock() +end + +--当前等级没到显示黑色遮罩 +function XUiPassportPanelGrid:UpdateRImgLock() + local levelId = self:GetLevelId() + local level = XPassportConfigs.GetPassportLevel(levelId) + local baseInfo = XDataCenter.PassportManager.GetPassportBaseInfo() + local currLevel = baseInfo:GetLevel() + self.RImgLock.gameObject:SetActiveEx(currLevel < level) +end + +--刷新物品格子 +function XUiPassportPanelGrid:UpdatePermitPanel() + local levelId = self:GetLevelId() + local typeInfoIdList = XPassportConfigs.GetPassportActivityIdToTypeInfoIdList() + local rewardData + local grid + local level = XPassportConfigs.GetPassportLevel(levelId) + local isReceiveReward --是否已领取奖励 + local isCanReceiveReward --是否可领取奖励 + local passportInfo + local isUnLock --是否已解锁当前通行证奖励 + + for i, typeInfoId in ipairs(typeInfoIdList) do + grid = self.GridObjs[i] + if self["GridCommonPermit" .. i] and not grid then + grid = XUiGridCommon.New(self.RootUi, self["GridCommonPermit" .. i]) + self.GridObjs[i] = grid + end + + local passportRewardId = XPassportConfigs.GetRewardIdByPassportIdAndLevel(typeInfoId, level) + rewardData = passportRewardId and XPassportConfigs.GetPassportRewardData(passportRewardId) + if XTool.IsNumberValid(rewardData) then + isReceiveReward = XDataCenter.PassportManager.IsReceiveReward(typeInfoId, passportRewardId) + isCanReceiveReward = XDataCenter.PassportManager.IsCanReceiveReward(typeInfoId, passportRewardId) + if not isReceiveReward and isCanReceiveReward then + grid:SetClickCallback(function() self:GridOnClick(passportRewardId) end) + self:SetGridCommonPermitEffectActive(i, true) + else + grid:AutoAddListener() + self:SetGridCommonPermitEffectActive(i, false) + end + + grid:Refresh(rewardData) + grid.GameObject:SetActive(true) + else + isReceiveReward = nil + grid.GameObject:SetActive(false) + self:SetGridCommonPermitEffectActive(i, false) + end + + --已领取标志 + if self["ImgGetOutPermit" .. i] then + self["ImgGetOutPermit" .. i].gameObject:SetActiveEx(isReceiveReward or false) + end + + --未解锁标志 + if self["ImgLockingPermit" .. i] then + passportInfo = XDataCenter.PassportManager.GetPassportInfos(typeInfoId) + isUnLock = passportInfo and true or false + self["ImgLockingPermit" .. i].gameObject:SetActiveEx(not isUnLock) + + if self["GridCommonPermitCanvasGroup" .. i] then + self["GridCommonPermitCanvasGroup" .. i].alpha = isUnLock and 1 or 0.5 --未解锁时半透明 + end + end + end +end + +function XUiPassportPanelGrid:SetGridCommonPermitEffectActive(index, isActive) + local effectObj = self["GridCommonPermitEffect" .. index] + if effectObj then + effectObj.gameObject:SetActiveEx(isActive) + end +end + +function XUiPassportPanelGrid:GridOnClick(passportRewardId) + XDataCenter.PassportManager.RequestPassportRecvReward(passportRewardId, handler(self, self.UpdatePermitPanel)) +end + +function XUiPassportPanelGrid:UpdateLevelPanel() + local levelId = self:GetLevelId() + local level = XPassportConfigs.GetPassportLevel(levelId) + local baseInfo = XDataCenter.PassportManager.GetPassportBaseInfo() + local currLevel = baseInfo:GetLevel() + local levelDesc = CS.XTextManager.GetText("PassportLevelDesc", level) + + --当前等级 + self.NowLevel.gameObject:SetActiveEx(currLevel == level) + self.TxtNowLevel.text = levelDesc + + --超过当前等级 + self.ReachLevel.gameObject:SetActiveEx(currLevel > level) + self.TxtReachLevel.text = levelDesc + + --当前等级未到达 + self.NotreachedLevel.gameObject:SetActiveEx(currLevel < level) + self.TxtNotReachedLevel.text = levelDesc +end + +function XUiPassportPanelGrid:GetLevelId() + return self.LevelId +end + +return XUiPassportPanelGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPassport/XUiPassportPanelTaskActivity.lua b/Resources/Scripts/XUi/XUiPassport/XUiPassportPanelTaskActivity.lua new file mode 100644 index 00000000..fb285a01 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPassport/XUiPassportPanelTaskActivity.lua @@ -0,0 +1,68 @@ +local XUiPassportPanelTaskActivity = XClass(nil, "XUiPassportPanelTaskActivity") + +--活动任务 +function XUiPassportPanelTaskActivity:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + + XUiHelper.RegisterClickEvent(self, self.BtnTongBlack, self.OnBtnTongBlackClick) + + self.DynamicTable = XDynamicTableNormal.New(self.SViewTask.transform) + self.DynamicTable:SetProxy(XDynamicGridTask) + self.DynamicTable:SetDelegate(self) + + self.GridTask.gameObject:SetActive(false) + + XRedPointManager.AddRedPointEvent(self.BtnTongBlack, self.OnCheckTaskRedPoint, self, { XRedPointConditions.Types.CONDITION_PASSPORT_TASK_ACTIVITY_RED }) +end + +function XUiPassportPanelTaskActivity:Refresh() + if not self:IsShow() then + return + end + + self.Tasks = XDataCenter.PassportManager.GetPassportTask(XPassportConfigs.TaskType.Activity) + self.DynamicTable:SetDataSource(self.Tasks) + self.DynamicTable:ReloadDataSync() + + local clearTaskCount = XDataCenter.PassportManager.GetClearTaskCount(XPassportConfigs.TaskType.Activity) + local taskTotalCount = XPassportConfigs.GetPassportBPTaskTotalCount() + self.TxtDailyNumber.text = string.format("%s/%s", clearTaskCount, taskTotalCount) +end + +function XUiPassportPanelTaskActivity:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.Tasks[index] + grid.RootUi = self.RootUi + grid:ResetData(data) + end +end + +--一键领取 +function XUiPassportPanelTaskActivity:OnBtnTongBlackClick() + XDataCenter.PassportManager.FinishMultiTaskRequest(XPassportConfigs.TaskType.Activity) +end + +function XUiPassportPanelTaskActivity:OnCheckTaskRedPoint(count) + self.BtnTongBlack:ShowReddot(count >= 0) +end + +function XUiPassportPanelTaskActivity:Show() + self.GameObject:SetActiveEx(true) + self:Refresh() +end + +function XUiPassportPanelTaskActivity:Hide() + self.GameObject:SetActiveEx(false) +end + +function XUiPassportPanelTaskActivity:IsShow() + if XTool.UObjIsNil(self.GameObject) then + return false + end + return self.GameObject.activeSelf +end + +return XUiPassportPanelTaskActivity \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPassport/XUiPassportPanelTaskDaily.lua b/Resources/Scripts/XUi/XUiPassport/XUiPassportPanelTaskDaily.lua new file mode 100644 index 00000000..2aa18bbf --- /dev/null +++ b/Resources/Scripts/XUi/XUiPassport/XUiPassportPanelTaskDaily.lua @@ -0,0 +1,64 @@ +local XUiPassportPanelTaskDaily = XClass(nil, "XUiPassportPanelTaskDaily") + +--每日任务 +function XUiPassportPanelTaskDaily:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + + XUiHelper.RegisterClickEvent(self, self.BtnTongBlack, self.OnBtnTongBlackClick) + + self.DynamicTable = XDynamicTableNormal.New(self.SViewTask.transform) + self.DynamicTable:SetProxy(XDynamicGridTask) + self.DynamicTable:SetDelegate(self) + + self.GridTask.gameObject:SetActive(false) + + XRedPointManager.AddRedPointEvent(self.BtnTongBlack, self.OnCheckTaskRedPoint, self, { XRedPointConditions.Types.CONDITION_PASSPORT_TASK_DAILY_RED }) +end + +function XUiPassportPanelTaskDaily:Refresh() + if not self:IsShow() then + return + end + + self.Tasks = XDataCenter.PassportManager.GetPassportTask(XPassportConfigs.TaskType.Daily) + self.DynamicTable:SetDataSource(self.Tasks) + self.DynamicTable:ReloadDataASync() +end + +function XUiPassportPanelTaskDaily:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.Tasks[index] + grid.RootUi = self.RootUi + grid:ResetData(data) + end +end + +--一键领取 +function XUiPassportPanelTaskDaily:OnBtnTongBlackClick() + XDataCenter.PassportManager.FinishMultiTaskRequest(XPassportConfigs.TaskType.Daily) +end + +function XUiPassportPanelTaskDaily:OnCheckTaskRedPoint(count) + self.BtnTongBlack:ShowReddot(count >= 0) +end + +function XUiPassportPanelTaskDaily:Show() + self.GameObject:SetActiveEx(true) + self:Refresh() +end + +function XUiPassportPanelTaskDaily:Hide() + self.GameObject:SetActiveEx(false) +end + +function XUiPassportPanelTaskDaily:IsShow() + if XTool.UObjIsNil(self.GameObject) then + return false + end + return self.GameObject.activeSelf +end + +return XUiPassportPanelTaskDaily \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPassport/XUiPassportPanelTaskWeekly.lua b/Resources/Scripts/XUi/XUiPassport/XUiPassportPanelTaskWeekly.lua new file mode 100644 index 00000000..7eb1dad4 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPassport/XUiPassportPanelTaskWeekly.lua @@ -0,0 +1,83 @@ +local XUiPassportPanelTaskWeekly = XClass(nil, "XUiPassportPanelTaskWeekly") + +--周任务 +function XUiPassportPanelTaskWeekly:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + + XUiHelper.RegisterClickEvent(self, self.BtnTongBlack, self.OnBtnTongBlackClick) + + self.DynamicTable = XDynamicTableNormal.New(self.SViewTask.transform) + self.DynamicTable:SetProxy(XDynamicGridTask) + self.DynamicTable:SetDelegate(self) + + self.GridTask.gameObject:SetActive(false) + + XRedPointManager.AddRedPointEvent(self.BtnTongBlack, self.OnCheckTaskRedPoint, self, { XRedPointConditions.Types.CONDITION_PASSPORT_TASK_WEEKLY_RED }) +end + +function XUiPassportPanelTaskWeekly:Refresh() + if not self:IsShow() then + return + end + + local taskType = XPassportConfigs.TaskType.Weekly + + self.Tasks = XDataCenter.PassportManager.GetPassportTask(taskType) + self.DynamicTable:SetDataSource(self.Tasks) + self.DynamicTable:ReloadDataASync() + + local passportTaskGroupId = XPassportConfigs.GetPassportTaskGroupIdByType(taskType) + local currExp, totalExp = XDataCenter.PassportManager.GetPassportTaskExp(passportTaskGroupId) + self.TxtDailyNumber.text = string.format("%s/%s", currExp, totalExp) + + self:UpdateTime() +end + +function XUiPassportPanelTaskWeekly:UpdateTime() + if not self:IsShow() then + return + end + local passportTaskGroupId = XPassportConfigs.GetPassportTaskGroupIdByType(XPassportConfigs.TaskType.Weekly) + local timeId = XPassportConfigs.GetPassportTaskGroupTimeId(passportTaskGroupId) + local endTime = XFunctionManager.GetEndTimeByTimeId(timeId) + local nowServerTime = XTime.GetServerNowTimestamp() + self.TxtDailyTime.text = XUiHelper.GetTime(endTime - nowServerTime, XUiHelper.TimeFormatType.PASSPORT) +end + +function XUiPassportPanelTaskWeekly:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.Tasks[index] + grid.RootUi = self.RootUi + grid:ResetData(data) + end +end + +--一键领取 +function XUiPassportPanelTaskWeekly:OnBtnTongBlackClick() + XDataCenter.PassportManager.FinishMultiTaskRequest(XPassportConfigs.TaskType.Weekly) +end + +function XUiPassportPanelTaskWeekly:OnCheckTaskRedPoint(count) + self.BtnTongBlack:ShowReddot(count >= 0) +end + +function XUiPassportPanelTaskWeekly:Show() + self.GameObject:SetActiveEx(true) + self:Refresh() +end + +function XUiPassportPanelTaskWeekly:Hide() + self.GameObject:SetActiveEx(false) +end + +function XUiPassportPanelTaskWeekly:IsShow() + if XTool.UObjIsNil(self.GameObject) then + return false + end + return self.GameObject.activeSelf +end + +return XUiPassportPanelTaskWeekly \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPassport/XUiPassportTips.lua b/Resources/Scripts/XUi/XUiPassport/XUiPassportTips.lua new file mode 100644 index 00000000..fbca73dc --- /dev/null +++ b/Resources/Scripts/XUi/XUiPassport/XUiPassportTips.lua @@ -0,0 +1,51 @@ +local XUiPassportTips = XLuaUiManager.Register(XLuaUi, "UiPassportTips") + +function XUiPassportTips:OnAwake() + self:AutoAddListener() +end + +function XUiPassportTips:OnStart(rewardGoodsList, title, desc, closeCb, sureCb) + self.Items = {} + self.GridCommon.gameObject:SetActive(false) + if title then + self.TxtTitle.text = title + end + if desc then + self.TxtDesc.text = desc + end + self.OkCallback = sureCb + self.CancelCallback = closeCb + self:Refresh(rewardGoodsList) +end + +function XUiPassportTips:OnEnable() + CS.XAudioManager.PlaySound(XSoundManager.UiBasicsMusic.Common_UiObtain) +end + +-- function XUiPassportTips:AutoInitUi() +-- self.ScrView = self.Transform:Find("SafeAreaContentPane/ScrView"):GetComponent("Scrollbar") +-- self.PanelContent = self.Transform:Find("SafeAreaContentPane/ScrView/Viewport/PanelContent") +-- self.GridCommon = self.Transform:Find("SafeAreaContentPane/ScrView/Viewport/PanelContent/GridCommon") +-- self.BtnBack = self.Transform:Find("SafeAreaContentPane/BtnBack"):GetComponent("Button") +-- self.TxtTitle = self.Transform:Find("SafeAreaContentPane/GameObject/TxtTitle1"):GetComponent("Text") +-- self.BtnCancel = self.Transform:Find("SafeAreaContentPane/BtnCancel"):GetComponent("Button") +-- self.BtnSure = self.Transform:Find("SafeAreaContentPane/BtnSure"):GetComponent("Button") +-- end + +function XUiPassportTips:AutoAddListener() + self:RegisterClickEvent(self.BtnTongBlack, self.OnBtnSureClick) +end + +function XUiPassportTips:OnBtnSureClick() + self:Close() + if self.OkCallback then + self.OkCallback() + end +end + +function XUiPassportTips:Refresh(rewardGoodsList) + rewardGoodsList = XRewardManager.MergeAndSortRewardGoodsList(rewardGoodsList) + XUiHelper.CreateTemplates(self, self.Items, rewardGoodsList, XUiGridCommon.New, self.GridCommon, self.PanelContent, function(grid, data) + grid:Refresh(data, nil, nil, false) + end) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPersonalInfo/PanelBoard/LeaveMsg/XUiPanelLeaveMsg.lua b/Resources/Scripts/XUi/XUiPersonalInfo/PanelBoard/LeaveMsg/XUiPanelLeaveMsg.lua new file mode 100644 index 00000000..d20fd7a0 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPersonalInfo/PanelBoard/LeaveMsg/XUiPanelLeaveMsg.lua @@ -0,0 +1,66 @@ +XUiPanelLeaveMsg = XClass(nil, "XUiPanelLeaveMsg") + +function XUiPanelLeaveMsg:Ctor(ui,rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self:InitAutoScript() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelLeaveMsg:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiPanelLeaveMsg:AutoInitUi() + self.PanelLeaveMsgItem = self.Transform:Find("PanelLeaveMsgItem") +end + +function XUiPanelLeaveMsg:GetAutoKey(uiNode,eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiPanelLeaveMsg:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiPanelLeaveMsg:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key],eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiPanelLeaveMsg:AutoAddListener() + self.AutoCreateListeners = {} +end +-- auto + +function XUiPanelLeaveMsg:SetIsShow( code ) + if self.GameObject ~= nil then + self.GameObject.gameObject:SetActive(code) + end +end +function XUiPanelLeaveMsg:Refresh( parent ) + XDataCenter.PersonalInfoManager.CreateItems(self.RootUi, self.PanelLeaveMsgItem, self.PanelLeaveMsgItem.gameObject.transform.parent,parent.pageNum,parent.data.Id,XDataCenter.PersonalInfoManager.ItemPanelType.DailyleaveMsg,function() + self:SetIsShow(true) + end) +end + +return XUiPanelLeaveMsg \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPersonalInfo/PanelBoard/LeaveMsg/XUiPanelLeaveMsgItem.lua b/Resources/Scripts/XUi/XUiPersonalInfo/PanelBoard/LeaveMsg/XUiPanelLeaveMsgItem.lua new file mode 100644 index 00000000..eeb519a0 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPersonalInfo/PanelBoard/LeaveMsg/XUiPanelLeaveMsgItem.lua @@ -0,0 +1,90 @@ +XUiPanelLeaveMsgItem = XClass(nil, "XUiPanelLeaveMsgItem") + +function XUiPanelLeaveMsgItem:Ctor(rootUi,ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self:InitAutoScript() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelLeaveMsgItem:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiPanelLeaveMsgItem:AutoInitUi() + self.ImgIcon = self.Transform:Find("ImgIcon"):GetComponent("Image") + self.PanelTop = self.Transform:Find("PanelTop") + self.TxtName = self.Transform:Find("PanelTop/TxtName"):GetComponent("Text") + self.TxtTime = self.Transform:Find("PanelTop/TxtTime"):GetComponent("Text") + self.PanelTxtContent = self.Transform:Find("PanelTxtContent") + self.TxtContent = self.Transform:Find("PanelTxtContent/TxtContent"):GetComponent("Text") + if not XTool.UObjIsNil(self.Transform:Find("BtnDelete")) then + self.BtnDelete = self.Transform:Find("BtnDelete"):GetComponent("Button") + end +end + +function XUiPanelLeaveMsgItem:GetAutoKey(uiNode,eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiPanelLeaveMsgItem:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiPanelLeaveMsgItem:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key],eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end +function XUiPanelLeaveMsgItem:AutoAddListener() + self.AutoCreateListeners = {} + if not XTool.UObjIsNil(self.BtnDelete) then + XUiHelper.RegisterClickEvent(self, self.BtnDelete, self.OnBtnBtnDeleteClick) + end +end +-- auto + +function XUiPanelLeaveMsgItem:OnBtnBtnDeleteClick() + XDataCenter.PersonalInfoManager.DeleteLeaveMsg(self.ParentId,self.data.Id,function() + XDataCenter.PersonalInfoManager.RefreshLeaveMsgData(self.data.DailyId,self.pageNum, + function() + XDataCenter.PersonalInfoManager.PanelMsgBoard:Refresh() + end) + end) +end + +function XUiPanelLeaveMsgItem:SetProperty( data,index,pageNum,parentId) + self.data = data + self.index = index + self.pageNum = pageNum + self.ParentId = parentId + self:RefreshPanel() +end + +function XUiPanelLeaveMsgItem:RefreshPanel() + self.TxtContent.text = self.data.Content + self.TxtName.text = self.data.Name + self.RootUi:SetUiSprite(self.ImgIcon, XPlayerManager.GetHeadPortraitInfoById(self.data.CurrHeadPortraitId).ImgSrc) + self.TxtTime.text = XUiHelper.CalcLatelyLoginTime(self.data.LeaveMsgTime) + self.GameObject.gameObject:SetActive(true) +end + +return XUiPanelLeaveMsgItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPersonalInfo/PanelBoard/MsgBoard/XUiPanelMsgBoard.lua b/Resources/Scripts/XUi/XUiPersonalInfo/PanelBoard/MsgBoard/XUiPanelMsgBoard.lua new file mode 100644 index 00000000..bb5b5e15 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPersonalInfo/PanelBoard/MsgBoard/XUiPanelMsgBoard.lua @@ -0,0 +1,87 @@ +XUiPanelMsgBoard = XClass(nil, "XUiPanelMsgBoard") + +function XUiPanelMsgBoard:Ctor(ui,rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self:InitAutoScript() + self.XUiPanelWriteDiary = XUiPanelWriteDiary.New(self.PanelWriteDiary,self.RootUi) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelMsgBoard:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiPanelMsgBoard:AutoInitUi() + self.PanelScrollView = self.Transform:Find("PanelScrollView"):GetComponent("ScrollRect") + self.PanelMsgBoardItem = self.Transform:Find("PanelScrollView/Viewport/Content/PanelMsgBoardItem") + self.PanelBtnBrief = self.Transform:Find("PanelScrollView/Viewport/Content/PanelInfoMsgItem/PanelTxt/PanelBtnBrief") + self.PanelWriteDiary = self.Transform:Find("PanelWriteDiary") +end + +function XUiPanelMsgBoard:GetAutoKey(uiNode,eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiPanelMsgBoard:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiPanelMsgBoard:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key],eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiPanelMsgBoard:AutoAddListener() + self.AutoCreateListeners = {} +end +-- auto + +function XUiPanelMsgBoard:SetIsShow( code ) + if self.GameObject ~= nil then + self.GameObject.gameObject:SetActive(code) + end +end + +function XUiPanelMsgBoard:ResetPanel() + self.PanelMsgBoardItem.gameObject:SetActive(false) + self.PanelWriteDiary.gameObject:SetActive(false) +end + +function XUiPanelMsgBoard:Refresh() + XDataCenter.PersonalInfoManager.PanelMsgBoard = self + self:ResetPanel() + XDataCenter.PersonalInfoManager.CreateItems(self.RootUi, self.PanelMsgBoardItem, self.PanelMsgBoardItem.gameObject.transform.parent, 1,nil ,XDataCenter.PersonalInfoManager.ItemPanelType.NorDaily,function() + self:SetIsShow(true) + self:MoveToBottom() + end) +end + +function XUiPanelMsgBoard:MoveToBottom() + if self.PanelScrollView ~= nil then + CS.UnityEngine.Canvas.ForceUpdateCanvases(); + self.PanelScrollView.verticalNormalizedPosition = 0 + CS.UnityEngine.Canvas.ForceUpdateCanvases() + end +end + +return XUiPanelMsgBoard \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPersonalInfo/PanelBoard/MsgBoard/XUiPanelMsgBoardItem.lua b/Resources/Scripts/XUi/XUiPersonalInfo/PanelBoard/MsgBoard/XUiPanelMsgBoardItem.lua new file mode 100644 index 00000000..4922b799 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPersonalInfo/PanelBoard/MsgBoard/XUiPanelMsgBoardItem.lua @@ -0,0 +1,186 @@ +XUiPanelMsgBoardItem = XClass(nil, "XUiPanelMsgBoardItem") + +-- local BriefStatus = { +-- Open = 1, +-- Close = 2, +-- } +function XUiPanelMsgBoardItem:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self:InitAutoScript() + self.XUiPanelLeaveMsgDetail = XUiPanelLeaveMsg.New(self.PanelLeaveMsg, self.RootUi) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelMsgBoardItem:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiPanelMsgBoardItem:AutoInitUi() + self.PanelTxt = self.Transform:Find("PanelTxt") + self.TxtContent = self.Transform:Find("PanelTxt/TxtContent"):GetComponent("Text") + self.BtnContent = self.Transform:Find("PanelTxt/BtnContent"):GetComponent("Button") + self.TxtLeaveMsg = self.Transform:Find("PanelTxt/BtnContent/BtnLeaveMsg/TxtLeaveMsg"):GetComponent("Text") + if not XTool.UObjIsNil(self.Transform:Find("PanelTxt/BtnContent/BtnLeaveMsg")) then + self.BtnLeaveMsg = self.Transform:Find("PanelTxt/BtnContent/BtnLeaveMsg"):GetComponent("Button") + end + if not XTool.UObjIsNil(self.Transform:Find("PanelTxt/BtnContent/BtnComment")) then + self.BtnComment = self.Transform:Find("PanelTxt/BtnContent/BtnComment"):GetComponent("Button") + end + if not XTool.UObjIsNil(self.Transform:Find("PanelTop/BtnEditor")) then + self.BtnBan = self.Transform:Find("PanelTop/BtnEditor"):GetComponent("Toggle") + self.BtnBan.isOn = false + end + if not XTool.UObjIsNil(self.Transform:Find("PanelTxt/BtnContent/BtnDelete")) then + self.BtnDelete = self.Transform:Find("PanelTxt/BtnContent/BtnDelete"):GetComponent("Button") + end + self.BtnPraise = self.Transform:Find("PanelTxt/BtnContent/BtnPraise"):GetComponent("Button") + self.TxtLeaveMsgA = self.Transform:Find("PanelTxt/BtnContent/BtnPraise/TxtLeaveMsg"):GetComponent("Text") + self.PanelLeaveMsg = self.Transform:Find("PanelTxt/PanelLeaveMsg") + self.BtnBackBrief = self.Transform:Find("PanelTxt/PanelBtnBrief/BtnBackBrief"):GetComponent("Button") + self.PanelTop = self.Transform:Find("PanelTop") + self.ImgIcon = self.Transform:Find("PanelTop/ImgIcon"):GetComponent("Image") + self.TxtName = self.Transform:Find("PanelTop/TxtName"):GetComponent("Text") + if not XTool.UObjIsNil(self.Transform:Find("PanelTxt/BtnContent/Image/TxtTime")) then + self.TxtTime = self.Transform:Find("PanelTxt/BtnContent/Image/TxtTime"):GetComponent("Text") + else + self.TxtTime = self.Transform:Find("PanelTop/TxtTime"):GetComponent("Text") + end +end + +function XUiPanelMsgBoardItem:GetAutoKey(uiNode, eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiPanelMsgBoardItem:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiPanelMsgBoardItem:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiPanelMsgBoardItem:AutoAddListener() + self.AutoCreateListeners = {} + XUiHelper.RegisterClickEvent(self, self.BtnContent, self.OnBtnContentClick) + if not XTool.UObjIsNil(self.BtnLeaveMsg) then + XUiHelper.RegisterClickEvent(self, self.BtnLeaveMsg, self.OnBtnLeaveMsgClick) + end + if not XTool.UObjIsNil(self.BtnComment) then + XUiHelper.RegisterClickEvent(self, self.BtnComment, self.OnBtnCommentClick) + end + if not XTool.UObjIsNil(self.BtnBan) then + self:RegisterListener(self.BtnBan, "onValueChanged", self.OnBtnBanClick) + end + if not XTool.UObjIsNil(self.BtnDelete) then + XUiHelper.RegisterClickEvent(self, self.BtnDelete, self.OnBtnDeleteClick) + end + XUiHelper.RegisterClickEvent(self, self.BtnPraise, self.OnBtnPraiseClick) + XUiHelper.RegisterClickEvent(self, self.BtnBackBrief, self.OnBtnBackBriefClick) +end +-- auto +function XUiPanelMsgBoardItem:OnBtnContentClick() + +end + +function XUiPanelMsgBoardItem:OnBtnLeaveMsgClick()--打开留言 + XDataCenter.PersonalInfoManager.RefreshLeaveMsgData(self.data.Id,self.pageNum, function() + self.XUiPanelLeaveMsgDetail:Refresh(self) + self.BtnBackBrief.gameObject.transform.parent.gameObject:SetActive(true) + end) +end + +function XUiPanelMsgBoardItem:OnBtnCommentClick() + XDataCenter.PersonalInfoManager.OpenInputView(function(content) + XDataCenter.PersonalInfoManager.AddLeaveMsg(self.data.PlayerId, self.data.Id, content, function() + self.data.LeaveMsgCount = self.data.LeaveMsgCount + 1 + self.TxtLeaveMsg.text = "(" .. self.data.LeaveMsgCount .. ")" + self:OnBtnLeaveMsgClick() + end) + end) +end + +function XUiPanelMsgBoardItem:OnBtnBanClick(isOn) + if isOn then + XDataCenter.PersonalInfoManager.BanWriteMsg(self.data.Id, function() + end)--禁止留言 + end +end + +function XUiPanelMsgBoardItem:OnBtnDeleteClick() + local removeTip = CS.XTextManager.GetText("IsSureDelete") + XUiManager.DialogTip("", removeTip, XUiManager.DialogType.Normal, nil, function() + XDataCenter.PersonalInfoManager.DeleteDaily(self.data.Id, function() + XDataCenter.PersonalInfoManager.RefreshDailyData(self.pageNum, + function() + XDataCenter.PersonalInfoManager.PanelMsgBoard:Refresh() + end) + end)--删除日记 + end) +end + +function XUiPanelMsgBoardItem:OnBtnPraiseClick() + if self.data ~= nil then + XDataCenter.PersonalInfoManager.GiveALike(self.data.PlayerId, self.data.Id, function(code) + local text = code and tonumber(self.data.UpCount) + 1 or tonumber(self.data.UpCount) - 1 + self.data.UpCount = text + self.TxtLeaveMsgA.text = "(" .. tostring(text) .. ")" + end) + end +end + +function XUiPanelMsgBoardItem:OnBtnBackBriefClick()--合起 + self.PanelLeaveMsg.gameObject:SetActive(false) + self.BtnBackBrief.gameObject.transform.parent.gameObject:SetActive(false) +end + +function XUiPanelMsgBoardItem:SetIsShow(code) + if self.GameObject then + self.GameObject.gameObject:SetActive(code) + end +end + +function XUiPanelMsgBoardItem:SetProperty(data, index, pageNum) + self.data = data + if(self.data.CurrHeadPortraitId==0) then self.data.CurrHeadPortraitId=1001 end + self.index = index + self.pageNum = pageNum + self:RefreshPanel() +end + +function XUiPanelMsgBoardItem:RefreshPanel() + if not self.data then + return + end + self.PanelLeaveMsg.gameObject:SetActive(false) + self.BtnBackBrief.gameObject.transform.parent.gameObject:SetActive(false) + self.TxtName.text = self.data.Name + self.TxtContent.text = self.data.Content + self.TxtLeaveMsg.text = "(" .. self.data.LeaveMsgCount .. ")" + self.TxtLeaveMsgA.text = "(" .. self.data.UpCount .. ")" + self.TxtTime.text = XUiHelper.CalcLatelyLoginTime(self.data.CreateTime) + self.RootUi:SetUiSprite(self.ImgIcon, XPlayerManager.GetHeadPortraitInfoById(self.data.CurrHeadPortraitId).ImgSrc) + self:SetIsShow(true) +end + +return XUiPanelMsgBoardItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPersonalInfo/PanelBoard/MsgBoard/XUiPanelWriteDiary.lua b/Resources/Scripts/XUi/XUiPersonalInfo/PanelBoard/MsgBoard/XUiPanelWriteDiary.lua new file mode 100644 index 00000000..8e7dd904 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPersonalInfo/PanelBoard/MsgBoard/XUiPanelWriteDiary.lua @@ -0,0 +1,105 @@ +XUiPanelWriteDiary = XClass(nil, "XUiPanelWriteDiary") + +function XUiPanelWriteDiary:Ctor(ui,rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self:InitAutoScript() + local behaviour = self.GameObject:AddComponent(typeof(CS.XLuaBehaviour)) + if self.Update then + behaviour.LuaUpdate = function() + self:Update() + end + end + self.inputText = self.Transform:Find("PanelInput/BtnInputField/Text"):GetComponent("Text") +end + +function XUiPanelWriteDiary:Update() + self.TxtNum.text = (self.inputText.cachedTextGenerator.characterCount - 1).."/".."100" +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelWriteDiary:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiPanelWriteDiary:AutoInitUi() + self.BtnBack = self.Transform:Find("BtnBack"):GetComponent("Button") + self.TxtName = self.Transform:Find("TxtName"):GetComponent("Text") + self.PanelInput = self.Transform:Find("PanelInput") + self.TxtNum = self.Transform:Find("PanelInput/TxtNum"):GetComponent("Text") + self.BtnInputField = self.Transform:Find("PanelInput/BtnInputField"):GetComponent("InputField") + self.BtnConfirm = self.Transform:Find("BtnConfirm"):GetComponent("Button") +end + +function XUiPanelWriteDiary:GetAutoKey(uiNode,eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiPanelWriteDiary:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiPanelWriteDiary:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key],eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiPanelWriteDiary:AutoAddListener() + self.AutoCreateListeners = {} + XUiHelper.RegisterClickEvent(self, self.BtnBack, self.OnBtnBackClick) + XUiHelper.RegisterClickEvent(self, self.BtnConfirm, self.OnBtnConfirmClick) +end +-- auto + +function XUiPanelWriteDiary:OnBtnBackClick() + self.GameObject.gameObject:SetActive(false) +end + +function XUiPanelWriteDiary:OnBtnInputFieldClick() + +end + +function XUiPanelWriteDiary:OnBtnConfirmClick() + local content = self.BtnInputField.text + if string.IsNilOrEmpty(content) then + self.BtnInputField.text = '' + return + end + self.BtnInputField.text = '' + if self.Callback then + self.Callback(content) + end + self.GameObject.gameObject:SetActive(false) +end + +function XUiPanelWriteDiary:InitializationView() + self.BtnInputField.characterLimit = 100; + self.BtnInputField.lineType = 1 + self.BtnInputField.text = '' +end + +function XUiPanelWriteDiary:OpenView(cb) + self:InitializationView() + self.Callback = cb + self.GameObject.gameObject:SetActive(true) +end +return XUiPanelWriteDiary \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPersonalInfo/PanelPersonalDetails/XUiPanelJubao.lua b/Resources/Scripts/XUi/XUiPersonalInfo/PanelPersonalDetails/XUiPanelJubao.lua new file mode 100644 index 00000000..e197bff8 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPersonalInfo/PanelPersonalDetails/XUiPanelJubao.lua @@ -0,0 +1,136 @@ +XUiPanelJubao = XClass(nil, "XUiPanelJubao") + +function XUiPanelJubao:Ctor(ui, parent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Parent = parent + self:InitAutoScript() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelJubao:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiPanelJubao:AutoInitUi() + self.BtnBack = self.Transform:Find("BtnBack"):GetComponent("Button") + self.BtnConfirm = self.Transform:Find("BtnConfirm"):GetComponent("Button") + self.PanelRole = self.Transform:Find("PanelRole") + self.RImgRole = self.Transform:Find("PanelRole/RImgRole"):GetComponent("RawImage") + self.PanelTGroup = self.Transform:Find("PanelTGroup") + self.TogQt = self.Transform:Find("PanelTGroup/TogQt"):GetComponent("Toggle") + self.TogDs = self.Transform:Find("PanelTGroup/TogDs"):GetComponent("Toggle") + self.TogZp = self.Transform:Find("PanelTGroup/TogZp"):GetComponent("Toggle") + self.TogGg = self.Transform:Find("PanelTGroup/TogGg"):GetComponent("Toggle") + self.PanelInput = self.Transform:Find("PanelInput") + self.TxtNum = self.Transform:Find("PanelInput/TxtNum"):GetComponent("Text") + self.InFReason = self.Transform:Find("PanelInput/InFReason"):GetComponent("InputField") + self.TxtName = self.Transform:Find("TxtName"):GetComponent("Text") +end + +function XUiPanelJubao:GetAutoKey(uiNode, eventName) + if not uiNode then + return + end + return eventName .. uiNode:GetHashCode() +end + +function XUiPanelJubao:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then + return + end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiPanelJubao:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiPanelJubao:AutoAddListener() + self.AutoCreateListeners = {} + XUiHelper.RegisterClickEvent(self, self.BtnBack, self.OnBtnBackClick) + XUiHelper.RegisterClickEvent(self, self.BtnConfirm, self.OnBtnConfirmClick) + self:RegisterListener(self.TogQt, "onValueChanged", self.OnTogQtValueChanged) + self:RegisterListener(self.TogDs, "onValueChanged", self.OnTogDsValueChanged) + self:RegisterListener(self.TogZp, "onValueChanged", self.OnTogZpValueChanged) + self:RegisterListener(self.TogGg, "onValueChanged", self.OnTogGgValueChanged) + self:RegisterListener(self.InFReason, "onValueChanged", self.OnInFReasonValueChanged) + self:RegisterListener(self.InFReason, "onEndEdit", self.OnInFReasonEndEdit) +end +-- auto +function XUiPanelJubao:OnTogQtValueChanged() + +end + +function XUiPanelJubao:OnTogDsValueChanged() + +end + +function XUiPanelJubao:OnTogZpValueChanged() + +end + +function XUiPanelJubao:OnTogGgValueChanged() + +end + +function XUiPanelJubao:OnInFReasonValueChanged() + local length = string.Utf8Len(self.InFReason.text) + self.TxtNum.text = length .. "/" .. "100" +end + +function XUiPanelJubao:OnInFReasonEndEdit() + +end + +function XUiPanelJubao:OnBtnBackClick() + self:SetIsShow(false) +end + +function XUiPanelJubao:OnBtnConfirmClick() + XUiManager.TipCode(XCode.Success) + self:SetIsShow(false) +end + +function XUiPanelJubao:OnBtnInputFieldClick() + +end + +function XUiPanelJubao:SetIsShow(code) + self.GameObject.gameObject:SetActive(code) +end + +function XUiPanelJubao:Refresh(playerData) + self.playerData = playerData + self.TogGg.isOn = false + self.TogZp.isOn = false + self.TogDs.isOn = false + self.TogQt.isOn = false + + self.TxtName.text = playerData.Name + local info = XPlayerManager.GetHeadPortraitInfoById(playerData.CurrHeadPortraitId) + if (info ~= nil) then + self.RImgRole:SetRawImage(info.ImgSrc) + end + self:SetIsShow(true) + +end + +return XUiPanelJubao \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPersonalInfo/PanelPersonalDetails/XUiPanelPersonalDetails.lua b/Resources/Scripts/XUi/XUiPersonalInfo/PanelPersonalDetails/XUiPanelPersonalDetails.lua new file mode 100644 index 00000000..149d7b36 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPersonalInfo/PanelPersonalDetails/XUiPanelPersonalDetails.lua @@ -0,0 +1,276 @@ +XUiPanelPersonalDetails = XClass(nil, "XUiPanelPersonalDetails") + +function XUiPanelPersonalDetails:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self:InitAutoScript() + self:InitData() +end +function XUiPanelPersonalDetails:InitData() + self.BtnSlider = self.Transform:Find("ImgJBLevelBg/Slider"):GetComponent("Slider") + self.BtnSlider.interactable = false + self.BtnDormitory.gameObject:SetActive(false) + self.BtnDormitoryDis.gameObject:SetActive(true) + self.BtnAssistance.gameObject:SetActive(false) + self.BtnAssistanceDis.gameObject:SetActive(true) + self.BtnPraise.interactable = false + self.XUiPanelCombat = XUiPanelPersonalDetailsCombat.New(self.PanelPersonalDetailsCombat, self.RootUi) + self.XUiPanelSupport = XUiPanelSupport.New(self.PanelSupport, self.RootUi) + self.BtnViewJb.gameObject:SetActive(false) +end +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelPersonalDetails:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiPanelPersonalDetails:AutoInitUi() + self.TxtIdcode = self.Transform:Find("TxtIdcode"):GetComponent("Text") + self.BtnCopy = self.Transform:Find("TxtIdcode/BtnCopy"):GetComponent("Button") + self.TxtLevel = self.Transform:Find("TxtLevel"):GetComponent("Text") + self.TxtName = self.Transform:Find("TxtName"):GetComponent("Text") + self.ImgIcon = self.Transform:Find("ImgIcon"):GetComponent("Image") + self.TxtBirthday = self.Transform:Find("TxtBirthday"):GetComponent("Text") + self.ImgJBLevelBg = self.Transform:Find("ImgJBLevelBg"):GetComponent("Image") + self.TxtJBLevel = self.Transform:Find("ImgJBLevelBg/TxtJBLevel"):GetComponent("Text") + self.TxtJBPercent = self.Transform:Find("ImgJBLevelBg/TxtJBPercent"):GetComponent("Text") + self.Slider = self.Transform:Find("ImgJBLevelBg/Slider"):GetComponent("Slider") + self.BtnViewJb = self.Transform:Find("ImgJBLevelBg/BtnView"):GetComponent("Button") + self.ImgTeamBg = self.Transform:Find("ImgTeamBg"):GetComponent("Image") + self.TxtTeamName = self.Transform:Find("ImgTeamBg/TxtTeamName"):GetComponent("Text") + self.BtnViewTeam = self.Transform:Find("ImgTeamBg/BtnView"):GetComponent("Button") + self.BtnContent = self.Transform:Find("BtnContent"):GetComponent("Button") + self.BtnDormitory = self.Transform:Find("BtnContent/BtnDormitory"):GetComponent("Button") + self.BtnDormitoryDis = self.Transform:Find("BtnContent/BtnDormitoryDis") + self.BtnPrivateChat = self.Transform:Find("BtnContent/BtnPrivateChat"):GetComponent("Button") + self.BtnAssistance = self.Transform:Find("BtnContent/BtnAssistance"):GetComponent("Button") + self.BtnAssistanceDis = self.Transform:Find("BtnContent/BtnAssistanceDis") + self.BtnDelete = self.Transform:Find("BtnContent/BtnDelete"):GetComponent("Button") + self.BtnAdd = self.Transform:Find("BtnContent/BtnAdd"):GetComponent("Button") + self.BtnReport = self.Transform:Find("BtnContent/BtnReport"):GetComponent("Button") + self.BtnPraise = self.Transform:Find("BtnContent/BtnPraise"):GetComponent("Button") + self.TxtCount = self.Transform:Find("BtnContent/BtnPraise/TxtCount"):GetComponent("Text") + self.PanelSupport = self.Transform:Find("PanelSupport") + self.PanelPersonalDetailsCombat = self.Transform:Find("PanelPersonalDetailsCombat") +end + +function XUiPanelPersonalDetails:GetAutoKey(uiNode, eventName) + if not uiNode then + return + end + return eventName .. uiNode:GetHashCode() +end + +function XUiPanelPersonalDetails:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then + return + end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiPanelPersonalDetails:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiPanelPersonalDetails:AutoAddListener() + self.AutoCreateListeners = {} + XUiHelper.RegisterClickEvent(self, self.BtnCopy, self.OnBtnCopyClick) + self:RegisterListener(self.Slider, "onValueChanged", self.OnSliderValueChanged) + XUiHelper.RegisterClickEvent(self, self.BtnViewTeam, self.OnBtnViewClick) + XUiHelper.RegisterClickEvent(self, self.BtnContent, self.OnBtnContentClick) + XUiHelper.RegisterClickEvent(self, self.BtnDormitory, self.OnBtnDormitoryClick) + XUiHelper.RegisterClickEvent(self, self.BtnPrivateChat, self.OnBtnPrivateChatClick) + XUiHelper.RegisterClickEvent(self, self.BtnAssistance, self.OnBtnAssistanceClick) + XUiHelper.RegisterClickEvent(self, self.BtnDelete, self.OnBtnDeleteClick) + XUiHelper.RegisterClickEvent(self, self.BtnAdd, self.OnBtnAddClick) + XUiHelper.RegisterClickEvent(self, self.BtnReport, self.OnBtnReportClick) + XUiHelper.RegisterClickEvent(self, self.BtnPraise, self.OnBtnPraiseClick) + XUiHelper.RegisterClickEvent(self, self.BtnViewJb, self.OnBtnViewJbClick) +end +-- auto + +-- function XUiPanelPersonalDetails:OnBtnCopyClick(...) +-- local id = self.Id +-- if id ~= nil then +-- CS.XAppPlatBridge.CopyStringToClipboard(tostring(id)) +-- end +-- XUiManager.TipCode(XCode.Success) +-- end + +function XUiPanelPersonalDetails:OnSliderValueChanged() + +end + +function XUiPanelPersonalDetails:OnBtnViewClick() + +end + +function XUiPanelPersonalDetails:OnBtnContentClick() + +end + +function XUiPanelPersonalDetails:OnBtnDormitoryClick() + +end + +function XUiPanelPersonalDetails:OnBtnPrivateChatClick() + self.RootUi:OnBtnBackClick() + + XLuaUiManager.Close("UiChatServeMain") + + if XLuaUiManager.IsUiShow("UiSocial") then + XLuaUiManager.PopThenOpen("UiSocial", function() + XEventManager.DispatchEvent(XEventId.EVENT_FRIEND_OPEN_PRIVATE_VIEW, self.Id) + end) + else + XLuaUiManager.Open("UiSocial", function() + XEventManager.DispatchEvent(XEventId.EVENT_FRIEND_OPEN_PRIVATE_VIEW, self.Id) + end) + end +end + +function XUiPanelPersonalDetails:OnBtnAssistanceClick() + +end + +function XUiPanelPersonalDetails:OnBtnDeleteClick() + --确认删除好友的回调 + local sureCallBack = function() + local callBack = function() + local uisocial = XUiManager.FindClassType("UiSocial") + if uisocial ~= nil then + uisocial:OnBtnBackClick() + end + end + local removeIds = {} + table.insert(removeIds, self.Id) + XDataCenter.SocialManager.DeleteFriends(removeIds, callBack) + end + local removeTip = CS.XTextManager.GetText("FriendRemoveTip") + XUiManager.DialogTip("", removeTip, XUiManager.DialogType.Normal, nil, sureCallBack) +end + +function XUiPanelPersonalDetails:OnBtnAddClick() + XDataCenter.SocialManager.ApplyFriend(self.Id) +end + +function XUiPanelPersonalDetails:OnBtnReportClick() + --举报 + self.RootUi.XUiPanelJubao:Refresh(self.Info) +end + +function XUiPanelPersonalDetails:OnBtnViewJbClick() + local sureCallBack = function() + + end + local data = XDataCenter.SocialManager.GetFetterTableDataByLevel(tonumber(self.Add)) + if data then + local removeTip = "与这位好友组队参战时,最大生命提升" .. data.Add .. "%"--CS.XTextManager.GetText("FriendRemoveTip") + XUiManager.DialogTip("", removeTip, XUiManager.DialogType.Normal, nil, sureCallBack) + end +end + +function XUiPanelPersonalDetails:SetIsShow(code) + self.GameObject.gameObject:SetActive(code) +end + +function XUiPanelPersonalDetails:Refresh(personalInfo) + self.XUiPanelCombat:Refresh(personalInfo.TeamData, self.RootUi)--小队 + self.XUiPanelSupport:Refresh(personalInfo.AssistData, self.RootUi)--助战 + + local playerData = personalInfo.PlayerData + self.Info = playerData + self.Id = playerData.Id + self.TxtName.text = playerData.Name + self.TxtLevel.text = playerData.Level + self.TxtIdcode.text = playerData.Id + self.TxtCount.text = playerData.Likes + if playerData.Birthday == nil then + self.TxtBirthday.text = "未登记" + else + self.TxtBirthday.text = CS.XTextManager.GetText("Birthday", playerData.Birthday.Mon, playerData.Birthday.Day) + end + local info = XPlayerManager.GetHeadPortraitInfoById(playerData.CurrHeadPortraitId) + if (info ~= nil) then + self.RootUi:SetUiSprite(self.ImgIcon, info.ImgSrc) + end + self.TxtTeamName.text = "暂无军团" + self.BtnViewTeam.gameObject:SetActive(false) + + --羁绊 + local Level = XDataCenter.SocialManager.GetFriendExpLevel(self.Id) + if personalInfo.FetterExp ~= nil then + if Level == 1 then + local template = XDataCenter.SocialManager.GetFetterTableDataByLevel(Level) + self.TxtJBPercent.text = personalInfo.FetterExp .. "/" .. template.Exp + self.Slider.value = personalInfo.FetterExp / template.Exp + else + local template = XDataCenter.SocialManager.GetFetterTableDataByLevel(Level) + local lastTemplate = XDataCenter.SocialManager.GetFetterTableDataByLevel(Level - 1) + self.TxtJBPercent.text = (personalInfo.FetterExp - lastTemplate.Exp) .. "/" .. (template.Exp - lastTemplate.Exp) + self.Slider.value = (personalInfo.FetterExp - lastTemplate.Exp) / (template.Exp - lastTemplate.Exp) + end + self.TxtJBLevel.text = Level + self.Add = Level + elseif XDataCenter.SocialManager.CheckIsFriend(self.Id) then + self.TxtJBLevel.text = 1 + self.TxtJBPercent.text = "0" .. "/" .. XDataCenter.SocialManager.GetFetterTableDataByLevel(2).Exp + self.Slider.value = 0 + self.Add = 1 + else + self.BtnViewJb.transform.parent.gameObject:SetActive(false) + end + + self:SetBtnStatus(personalInfo.IsFriend) + + self:SetIsShow(true) +end + +function XUiPanelPersonalDetails:SetBtnStatus(isFriend) + if self.Id == XPlayer.Id then + self.BtnAdd.gameObject:SetActive(false) + self.BtnDelete.gameObject:SetActive(false) + self.BtnReport.gameObject:SetActive(false) + self.BtnDormitory.gameObject:SetActive(false) + self.BtnPrivateChat.gameObject:SetActive(false) + self.BtnAssistance.gameObject:SetActive(false) + self.BtnDormitoryDis.gameObject:SetActive(false) + self.BtnAssistanceDis.gameObject:SetActive(false) + elseif isFriend then + self.BtnAdd.gameObject:SetActive(false) + self.BtnDelete.gameObject:SetActive(true) + self.BtnReport.gameObject:SetActive(true) + self.BtnDormitory.gameObject:SetActive(false) + self.BtnPrivateChat.gameObject:SetActive(true) + self.BtnAssistance.gameObject:SetActive(false) + self.BtnDormitoryDis.gameObject:SetActive(true) + self.BtnAssistanceDis.gameObject:SetActive(true) + else + self.BtnAdd.gameObject:SetActive(true) + self.BtnDelete.gameObject:SetActive(false) + self.BtnReport.gameObject:SetActive(true) + self.BtnDormitory.gameObject:SetActive(false) + self.BtnPrivateChat.gameObject:SetActive(false) + self.BtnAssistance.gameObject:SetActive(false) + self.BtnDormitoryDis.gameObject:SetActive(false) + self.BtnAssistanceDis.gameObject:SetActive(false) + end +end +return XUiPanelPersonalDetails \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPersonalInfo/PanelPersonalDetails/XUiPanelPersonalDetailsCombat.lua b/Resources/Scripts/XUi/XUiPersonalInfo/PanelPersonalDetails/XUiPanelPersonalDetailsCombat.lua new file mode 100644 index 00000000..f8027fc1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPersonalInfo/PanelPersonalDetails/XUiPanelPersonalDetailsCombat.lua @@ -0,0 +1,85 @@ +XUiPanelPersonalDetailsCombat = XClass(nil, "XUiPanelPersonalDetailsCombat") + +function XUiPanelPersonalDetailsCombat:Ctor(ui,parent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Parent = parent + self:InitAutoScript() + self.ItemsList = {} +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelPersonalDetailsCombat:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiPanelPersonalDetailsCombat:AutoInitUi() + self.PanelGird = self.Transform:Find("PanelGird") + self.PanelPersonalDetailsCombatItem = self.Transform:Find("PanelGird/PanelPersonalDetailsCombatItem") +end + +function XUiPanelPersonalDetailsCombat:GetAutoKey(uiNode,eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiPanelPersonalDetailsCombat:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiPanelPersonalDetailsCombat:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key],eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiPanelPersonalDetailsCombat:AutoAddListener() + self.AutoCreateListeners = {} +end +-- auto +function XUiPanelPersonalDetailsCombat:Refresh(combatData) + self.PanelPersonalDetailsCombatItem.gameObject:SetActive(false) + if combatData ~= nil then + local i = 1 + XTool.LoopCollection(combatData,function (data) + if data then + local go + if i <= #self.ItemsList then + go = self.ItemsList[i] + else + go = self:InsObj() + table.insert(self.ItemsList,go) + end + local item = XUiPanelPersonalDetailsCombatItem.New(go,self.Parent) + item:Refresh(data) + i = i + 1 + end + end) + end +end + +function XUiPanelPersonalDetailsCombat:InsObj() + local go = CS.UnityEngine.GameObject.Instantiate(self.PanelPersonalDetailsCombatItem.gameObject) + if go ~= nil then + go.transform:SetParent(self.PanelGird, false) + end + return go +end + +return XUiPanelPersonalDetailsCombat \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPersonalInfo/PanelPersonalDetails/XUiPanelPersonalDetailsCombatItem.lua b/Resources/Scripts/XUi/XUiPersonalInfo/PanelPersonalDetails/XUiPanelPersonalDetailsCombatItem.lua new file mode 100644 index 00000000..a012bf87 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPersonalInfo/PanelPersonalDetails/XUiPanelPersonalDetailsCombatItem.lua @@ -0,0 +1,74 @@ +XUiPanelPersonalDetailsCombatItem = XClass(nil, "XUiPanelPersonalDetailsCombatItem") + +function XUiPanelPersonalDetailsCombatItem:Ctor(ui,parent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Parent = parent + self:InitAutoScript() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelPersonalDetailsCombatItem:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiPanelPersonalDetailsCombatItem:AutoInitUi() + self.PanelHaveData = self.Transform:Find("PanelHaveData") + self.ImgIcon = self.Transform:Find("PanelHaveData/ImgIcon"):GetComponent("Image") + self.ImgRoleQulity = self.Transform:Find("PanelHaveData/ImgRoleQulity"):GetComponent("Image") + self.TxtLevel = self.Transform:Find("PanelHaveData/TxtLevel"):GetComponent("Text") + self.PanelNoData = self.Transform:Find("PanelNoData") +end + +function XUiPanelPersonalDetailsCombatItem:GetAutoKey(uiNode,eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiPanelPersonalDetailsCombatItem:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiPanelPersonalDetailsCombatItem:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key],eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiPanelPersonalDetailsCombatItem:AutoAddListener() + self.AutoCreateListeners = {} +end +-- auto + +function XUiPanelPersonalDetailsCombatItem:Refresh(data) + if data then + self.TxtLevel.text = data.Level + self.Parent:SetUiSprite(self.ImgIcon, XDataCenter.CharacterManager.GetCharSmallHeadIcon(data.CharacterId)) + self.Parent:SetUiSprite(self.ImgRoleQulity, XCharacterConfigs.GetCharacterQualityIcon(data.Quality)) + + self.PanelHaveData.gameObject:SetActive(true) + self.PanelNoData.gameObject:SetActive(false) + else + self.PanelHaveData.gameObject:SetActive(false) + self.PanelNoData.gameObject:SetActive(true) + end + self.GameObject.gameObject:SetActive(true) +end + +return XUiPanelPersonalDetailsCombatItem diff --git a/Resources/Scripts/XUi/XUiPersonalInfo/PanelPersonalDetails/XUiPanelSupport.lua b/Resources/Scripts/XUi/XUiPersonalInfo/PanelPersonalDetails/XUiPanelSupport.lua new file mode 100644 index 00000000..cc665944 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPersonalInfo/PanelPersonalDetails/XUiPanelSupport.lua @@ -0,0 +1,77 @@ +XUiPanelSupport = XClass(nil, "XUiPanelSupport") + +function XUiPanelSupport:Ctor(ui,parent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Parent = parent + self:InitAutoScript() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelSupport:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiPanelSupport:AutoInitUi() + self.PanelInfo = self.Transform:Find("PanelInfo") + self.PanelHaveData = self.Transform:Find("PanelInfo/PanelHaveData") + self.TxtName = self.Transform:Find("PanelInfo/PanelHaveData/TxtName"):GetComponent("Text") + self.ImgRoleQulity = self.Transform:Find("PanelInfo/PanelHaveData/ImgRoleQulity"):GetComponent("Image") + self.ImgIcon = self.Transform:Find("PanelInfo/PanelHaveData/ImgIcon"):GetComponent("Image") + self.TxtLevel = self.Transform:Find("PanelInfo/PanelHaveData/TxtLevel"):GetComponent("Text") + self.PanelNoData = self.Transform:Find("PanelInfo/PanelNoData") + self.ImgMedalNone = self.Transform:Find("PanelInfo/PanelNoData/ImgMedalNone"):GetComponent("Image") + self.PanelMedal = self.Transform:Find("PanelMedal") + self.ImgMedal = self.Transform:Find("PanelMedal/ImgMedal"):GetComponent("Image") + self.ImgMedalNoneA = self.Transform:Find("PanelMedal/ImgMedalNone"):GetComponent("Image") +end + +function XUiPanelSupport:GetAutoKey(uiNode,eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiPanelSupport:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiPanelSupport:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key],eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiPanelSupport:AutoAddListener() + self.AutoCreateListeners = {} +end +-- auto + +function XUiPanelSupport:Refresh(AssistData) + if AssistData then + self.TxtLevel.text = AssistData.Level + self.Parent:SetUiSprite(self.ImgIcon, XDataCenter.CharacterManager.GetCharSmallHeadIcon(AssistData.CharacterId)) + self.Parent:SetUiSprite(self.ImgRoleQulity, XCharacterConfigs.GetCharacterQualityIcon(AssistData.Quality)) + self.TxtName.text = XCharacterConfigs.GetCharacterName(AssistData.CharacterId) + self.PanelHaveData.gameObject:SetActive(true) + self.PanelNoData.gameObject:SetActive(false) + else + self.PanelHaveData.gameObject:SetActive(false) + self.PanelNoData.gameObject:SetActive(true) + end +end diff --git a/Resources/Scripts/XUi/XUiPersonalInfo/XUiPersonalInfo.lua b/Resources/Scripts/XUi/XUiPersonalInfo/XUiPersonalInfo.lua new file mode 100644 index 00000000..b21bc080 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPersonalInfo/XUiPersonalInfo.lua @@ -0,0 +1,134 @@ +local XUiPersonalInfo = XLuaUiManager.Register(XLuaUi, "UiPersonalInfo") + +-- PersonalToggleType = { +-- Info = 1, +-- MsgBoard = 2, +-- } + +function XUiPersonalInfo:OnAwake() + self:InitAutoScript() +end + +function XUiPersonalInfo:OnStart(personalInfo, closeCB) + XDataCenter.PersonalInfoManager.AddPanelPersonalInfo(self) + self.PersonalInfo = personalInfo + self.CloseCB = closeCB + self:InitView() +end + +function XUiPersonalInfo:GetPanelMsgboard() + if self.XUiPanelMsgBoard then + return self.XUiPanelMsgBoard + else + XLog.Error("XUiPersonalInfo.XUiPanelMsgBoard错误, XUiPanelMsgBoard这个子窗口初始化失败") + end +end + +function XUiPersonalInfo:InitView() + self.PanelPersonalDetails.gameObject:SetActive(false) + self.PanelMsgBoard.gameObject:SetActive(false) + self.PanelJubao.gameObject:SetActive(false) + self.XUiPanelPersonalDetails = XUiPanelPersonalDetails.New(self.PanelPersonalDetails, self) + self.XUiPanelJubao = XUiPanelJubao.New(self.PanelJubao, self) + self.XUiPanelMsgBoard = XUiPanelMsgBoard.New(self.PanelMsgBoard, self) + self.TogMsgBoard.gameObject:SetActive(false) + + self.TogInfo.isOn = true + self.TogMsgBoard.isOn = false + self:OnTogInfoValueChanged(true) +end +-- auto +-- Automatic generation of code, forbid to edit +function XUiPersonalInfo:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiPersonalInfo:AutoInitUi() + self.PanelTopBtn = self.Transform:Find("SafeAreaContentPane/PanelTopBtn") + self.BtnBack = self.Transform:Find("SafeAreaContentPane/PanelTopBtn/BtnBack"):GetComponent("Button") + self.BtnLeftToggle = self.Transform:Find("SafeAreaContentPane/BtnLeftToggle"):GetComponent("Button") + self.TogMsgBoard = self.Transform:Find("SafeAreaContentPane/BtnLeftToggle/TogMsgBoard"):GetComponent("Toggle") + self.TxtMsgBoard = self.Transform:Find("SafeAreaContentPane/BtnLeftToggle/TogMsgBoard/Background/TxtMsgBoard"):GetComponent("Text") + self.TogInfo = self.Transform:Find("SafeAreaContentPane/BtnLeftToggle/TogInfo"):GetComponent("Toggle") + self.TxtInfo = self.Transform:Find("SafeAreaContentPane/BtnLeftToggle/TogInfo/Background/TxtInfo"):GetComponent("Text") + self.PanelPersonalDetails = self.Transform:Find("SafeAreaContentPane/PanelPersonalDetails") + self.PanelMsgBoard = self.Transform:Find("SafeAreaContentPane/PanelMsgBoard") + self.PanelJubao = self.Transform:Find("SafeAreaContentPane/PanelJubao") +end + +function XUiPersonalInfo:GetAutoKey(uiNode, eventName) + if not uiNode then + return + end + return eventName .. uiNode:GetHashCode() +end + +function XUiPersonalInfo:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then + return + end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiPersonalInfo:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiPersonalInfo:AutoAddListener() + self.AutoCreateListeners = {} + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterListener(self.TogMsgBoard, "onValueChanged", self.OnTogMsgBoardValueChanged) + self:RegisterListener(self.TogInfo, "onValueChanged", self.OnTogInfoValueChanged) +end +-- auto + +function XUiPersonalInfo:OnTogInfoValueChanged(code) + --点击个人信息面板 + if not code then + return + end + self.TxtInfo.gameObject:SetActive(false) + self.TxtMsgBoard.gameObject:SetActive(true) + self.XUiPanelMsgBoard:SetIsShow(false) + self.XUiPanelPersonalDetails:Refresh(self.PersonalInfo) +end + +function XUiPersonalInfo:OnTogMsgBoardValueChanged(code) + --点击日记面板 + if not code then + return + end + self.TxtInfo.gameObject:SetActive(true) + self.TxtMsgBoard.gameObject:SetActive(false) + self.XUiPanelPersonalDetails:SetIsShow(false) + XDataCenter.PersonalInfoManager.GetDailys(self.PersonalInfo.PlayerData.Id, 1, function() + self.XUiPanelMsgBoard:Refresh() + end) +end + +function XUiPersonalInfo:OnBtnBackClick() + if self.CloseCB then + self.CloseCB() + end + self:Close() +end + +function XUiPersonalInfo:OnDestroy() + XDataCenter.PersonalInfoManager.OnDispose() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPhotograph/XUiGridPhotographCharacterBtn.lua b/Resources/Scripts/XUi/XUiPhotograph/XUiGridPhotographCharacterBtn.lua new file mode 100644 index 00000000..ecc0c0a6 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPhotograph/XUiGridPhotographCharacterBtn.lua @@ -0,0 +1,37 @@ +local CSXTextManagerGetText = CS.XTextManager.GetText + +local XUiGridPhotographCharacterBtn = XClass(nil, "XUiGridPhotographCharacterBtn") + +function XUiGridPhotographCharacterBtn:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RectTransform = ui:GetComponent("RectTransform") + XTool.InitUiObject(self) +end + +function XUiGridPhotographCharacterBtn:Init(rootUi) + self.rootUi = rootUi +end + +function XUiGridPhotographCharacterBtn:Refrash(data) + self.ImgHead:SetRawImage(XDataCenter.CharacterManager.GetCharSmallHeadIcon(data.Id)) + self.TxtName.text = data.LogName + self.TxtNameEn.text = data.EnName + self.TxtAIXin.text = data.TrustLv +end + +function XUiGridPhotographCharacterBtn:OnTouched(charId) + self:SetSelect(true) + local fashionId = XDataCenter.FashionManager.GetFashionIdByCharId(charId) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_PHOTO_CHANGE_MODEL, charId, fashionId) +end + +function XUiGridPhotographCharacterBtn:SetSelect(bool) + self.Sel.gameObject:SetActiveEx(bool) +end + +function XUiGridPhotographCharacterBtn:Reset() + self:SetSelect(false) +end + +return XUiGridPhotographCharacterBtn \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPhotograph/XUiGridPhotographOtherBtn.lua b/Resources/Scripts/XUi/XUiPhotograph/XUiGridPhotographOtherBtn.lua new file mode 100644 index 00000000..c098689a --- /dev/null +++ b/Resources/Scripts/XUi/XUiPhotograph/XUiGridPhotographOtherBtn.lua @@ -0,0 +1,64 @@ +local XUiGridPhotographOtherBtn = XClass(nil, "XUiGridPhotographOtherBtn") + +function XUiGridPhotographOtherBtn:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RectTransform = ui:GetComponent("RectTransform") + XTool.InitUiObject(self) +end + +function XUiGridPhotographOtherBtn:Init(rootUi) + self.rootUi = rootUi +end + +function XUiGridPhotographOtherBtn:RefrashFashion(data) + local fashionName = XDataCenter.FashionManager.GetFashionName(data) + self.TxtNor.text = fashionName + self.TxtSel.text = fashionName + self.TxtLock.text = fashionName + if not XDataCenter.FashionManager.CheckHasFashion(data) then + self:SetLock() + end +end + +function XUiGridPhotographOtherBtn:RefrashAction(data, charData) + self.TxtNor.text = data.Name + self.TxtSel.text = data.Name + self.TxtLock.text = data.Name + self.Txtcondition.text = data.ConditionDescript + if charData.TrustLv < data.UnlockLv then + self:SetLock() + end +end + +function XUiGridPhotographOtherBtn:OnFashionTouched(charId, fashionId) + self:SetSelect(true) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_PHOTO_CHANGE_MODEL, charId, fashionId) +end + +function XUiGridPhotographOtherBtn:OnActionTouched(data) + self:SetSelect(true) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_PHOTO_PLAY_ACTION, data.SignBoardActionId) +end + +function XUiGridPhotographOtherBtn:SetSelect(bool) + self.Sel.gameObject:SetActiveEx(bool) + self.ImageCheck.gameObject:SetActiveEx(bool) + self.Nor.gameObject:SetActiveEx(not bool) +end + +function XUiGridPhotographOtherBtn:SetLock() + self.Nor.gameObject:SetActiveEx(false) + self.Sel.gameObject:SetActiveEx(false) + self.Lock.gameObject:SetActiveEx(true) +end + +function XUiGridPhotographOtherBtn:Reset() + self.Nor.gameObject:SetActiveEx(true) + self.Sel.gameObject:SetActiveEx(false) + self.Lock.gameObject:SetActiveEx(false) + self.ImageCheck.gameObject:SetActiveEx(false) + self.Txtcondition.text = "" +end + +return XUiGridPhotographOtherBtn \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPhotograph/XUiGridPhotographSceneBtn.lua b/Resources/Scripts/XUi/XUiPhotograph/XUiGridPhotographSceneBtn.lua new file mode 100644 index 00000000..82adec04 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPhotograph/XUiGridPhotographSceneBtn.lua @@ -0,0 +1,43 @@ +local XUiGridPhotographSceneBtn = XClass(nil, "XUiGridPhotographSceneBtn") + +function XUiGridPhotographSceneBtn:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RectTransform = ui:GetComponent("RectTransform") + XTool.InitUiObject(self) +end + +function XUiGridPhotographSceneBtn:Init(rootUi) + self.rootUi = rootUi +end + +function XUiGridPhotographSceneBtn:Refrash(data) + self.ImgScene:SetSprite(data.IconPath) + self.TxSceneName.text = data.Name + self.TxtLock.text = data.LockDec + self:SetLock(not XDataCenter.PhotographManager.CheckSceneIsHaveById(data.Id)) +end + +function XUiGridPhotographSceneBtn:OnTouched(data) + self:SetSelect(true) + if self.rootUi then + self.rootUi:PlayAnimation("Loading", function() + CsXGameEventManager.Instance:Notify(XEventId.EVENT_PHOTO_CHANGE_SCENE, data.Id) + end) + end +end + +function XUiGridPhotographSceneBtn:SetSelect(bool) + self.Sel.gameObject:SetActiveEx(bool) +end + +function XUiGridPhotographSceneBtn:SetLock(bool) + self.Lock.gameObject:SetActiveEx(bool) +end + +function XUiGridPhotographSceneBtn:Reset() + self:SetSelect(false) + self:SetLock(false) +end + +return XUiGridPhotographSceneBtn \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPhotograph/XUiPhotograph.lua b/Resources/Scripts/XUi/XUiPhotograph/XUiPhotograph.lua new file mode 100644 index 00000000..40d815bc --- /dev/null +++ b/Resources/Scripts/XUi/XUiPhotograph/XUiPhotograph.lua @@ -0,0 +1,331 @@ +local CSXTextManagerGetText = CS.XTextManager.GetText + +local XUiPhotograph = XLuaUiManager.Register(XLuaUi, "UiPhotograph") +local XUiPhotographPanel = require("XUi/XUiPhotograph/XUiPhotographPanel") +local XUiPhotographCapturePanel = require("XUi/XUiPhotograph/XUiPhotographCapturePanel") +local XUiPhotographSDKPanel = require("XUi/XUiPhotograph/XUiPhotographSDKPanel") + +local SCREEN_WIDTH = CS.UnityEngine.Screen.width +local SCREEN_HEIGHT = CS.UnityEngine.Screen.height +local Vector2 = CS.UnityEngine.Vector2 + +local XQualityManager = CS.XQualityManager.Instance +local LowPowerValue = CS.XGame.ClientConfig:GetFloat("UiMainLowPowerValue") +local BatteryComponent = CS.XUiBattery + +function XUiPhotograph:OnAwake() + self.PhotographPanel = XUiPhotographPanel.New(self, self.PanelPhotograph) + self.CapturePanel = XUiPhotographCapturePanel.New(self, self.PanelCapture) + self.SDKPanel = XUiPhotographSDKPanel.New(self, self.PanelSDK) + + local signBoardPlayer = require("XCommon/XSignBoardPlayer").New(self, CS.XGame.ClientConfig:GetInt("SignBoardPlayInterval"), CS.XGame.ClientConfig:GetFloat("SignBoardDelayInterval")) + local playerData = XDataCenter.SignBoardManager.GetSignBoardPlayerData() + signBoardPlayer:SetPlayerData(playerData) + self.SignBoardPlayer = signBoardPlayer +end + +function XUiPhotograph:OnStart() + self:SetProportionImage() + self.Parent = self + self:AutoRegisterBtnListener() + local displayChar = XDataCenter.DisplayManager.GetDisplayChar() + self.CurCharacterId = displayChar.Id + self.CurFashionId = displayChar.FashionId + self.SelectCharacterId = self.CurCharacterId + self.SelectFashionId = self.CurFashionId + self.TxtUserName.text = XPlayer.Name + XDataCenter.PhotographManager.SetCurSelectSceneId() +end + +function XUiPhotograph:OnEnable() + -- 重启计时器 + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end + + self.Timer = XScheduleManager.ScheduleForever(function() + self:Update() + end, 0) + + if self.SignBoardPlayer then + self.SignBoardPlayer:OnEnable() + end + + self.PhotographPanel:DefaultClick() + local sceneId = XDataCenter.PhotographManager.GetCurSceneId() + local sceneTemplate = XDataCenter.PhotographManager.GetSceneTemplateById(sceneId) + local scenePath, modelPath = XSceneModelConfigs.GetSceneAndModelPathById(sceneTemplate.SceneModelId) + self:LoadUiScene(scenePath, modelPath, self.OnUiSceneLoadedCB, false) + self.Enable = true + self:PlayAnimation("PanelSceneListEnable") + XEventManager.DispatchEvent(XEventId.EVENT_PHOTO_ENTER) +end + +function XUiPhotograph:Update() + if not self.Enable then + return + end + + local dt = CS.UnityEngine.Time.deltaTime + if self.SignBoardPlayer then + self.SignBoardPlayer:Update(dt) + end +end + +function XUiPhotograph:OnDisable() + if self.Timer ~= nil then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end + + if self.SignBoardPlayer then + self.SignBoardPlayer:OnDisable() + end + + self.Enable = false + XEventManager.DispatchEvent(XEventId.EVENT_PHOTO_LEAVE) +end + +function XUiPhotograph:OnDestroy() + if self.Timer ~= nil then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end + + if self.SignBoardPlayer then + self.SignBoardPlayer:OnDestroy() + end + + XDataCenter.PhotographManager.ClearTextureCache() +end + +function XUiPhotograph:OnGetEvents() + return { + XEventId.EVENT_PHOTO_CHANGE_SCENE, + XEventId.EVENT_PHOTO_CHANGE_MODEL, + XEventId.EVENT_PHOTO_PLAY_ACTION, + XEventId.EVENT_PHOTO_PHOTOGRAPH, + } +end + +function XUiPhotograph:OnNotify(evt, ...) + if evt == XEventId.EVENT_PHOTO_CHANGE_SCENE then + self.SignBoardPlayer:Stop() + self:ChangeScene(...) + self.PhotographPanel:SetBtnSynchronousActiveEx(self:CheckHasChanged()) + elseif evt == XEventId.EVENT_PHOTO_CHANGE_MODEL then + self.SignBoardPlayer:Stop() + self:UpdateRoleModel(...) + self:PlayChangeActionEffect() + self.PhotographPanel:SetBtnSynchronousActiveEx(self:CheckHasChanged()) + elseif evt == XEventId.EVENT_PHOTO_PLAY_ACTION then + self:ForcePlay(...) + elseif evt == XEventId.EVENT_PHOTO_PHOTOGRAPH then + self:Photograph() + end +end + +function XUiPhotograph:OnBtnBackClick() + self:Close() +end + +function XUiPhotograph:ChangeScene(sceneId) + XDataCenter.PhotographManager.SetCurSelectSceneId(sceneId) + local sceneTemplate = XDataCenter.PhotographManager.GetSceneTemplateById(sceneId) + local scenePath, modelPath = XSceneModelConfigs.GetSceneAndModelPathById(sceneTemplate.SceneModelId) + self:LoadUiScene(scenePath, modelPath, self.OnUiSceneLoadedCB, false) +end + +function XUiPhotograph:AutoRegisterBtnListener() + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.OnUiSceneLoadedCB = function() self:OnUiSceneLoaded() end +end + +function XUiPhotograph:ChangeState(state) + if state == XPhotographConfigs.PhotographViewState.Normal then + self.PhotographPanel:Show() + self.CapturePanel:Hide() + self.SDKPanel:Hide() + self.PanelMenu.gameObject:SetActiveEx(true) + self.ImgLine.gameObject:SetActiveEx(true) + elseif state == XPhotographConfigs.PhotographViewState.Capture then + self.PhotographPanel:Hide() + self.CapturePanel:Show() + self.SDKPanel:Hide() + self.PanelMenu.gameObject:SetActiveEx(false) + self.ImgLine.gameObject:SetActiveEx(false) + elseif state == XPhotographConfigs.PhotographViewState.SDK then + self.PhotographPanel:Hide() + self.CapturePanel:Show() + self.SDKPanel:Show() + self.PanelMenu.gameObject:SetActiveEx(false) + self.ImgLine.gameObject:SetActiveEx(false) + end +end + +function XUiPhotograph:OnUiSceneLoaded() + self:PlayAnimation("Loading2") + self:SetGameObject() + self:InitSceneRoot() + self:UpdateRoleModel(self.SelectCharacterId, self.SelectFashionId) + self:UpdateCamera() + self:UpdateBatteryMode() +end + +function XUiPhotograph:InitSceneRoot() + local root = self.UiModelGo.transform + self.CameraFar = self:FindVirtualCamera("CamFarMain") + self.CameraNear = self:FindVirtualCamera("CamNearMain") + self.CameraComponentFar = root:FindTransform("UiFarCamera"):GetComponent("Camera") + self.CameraComponentNear = root:FindTransform("UiNearCamera"):GetComponent("Camera") + self.UiModelParent = root:FindTransform("UiModelParent") + self.ChangeActionEffect = root:FindTransform("ChangeActionEffect") + self.RoleModel = XUiPanelRoleModel.New(self.UiModelParent, self.Name, true, true, false, true, nil, nil, true) +end + +function XUiPhotograph:UpdateRoleModel(charId, fashionId) + self.SelectCharacterId = charId + self.SelectFashionId = fashionId + XDataCenter.DisplayManager.UpdateRoleModel(self.RoleModel, charId, nil, fashionId) +end + +function XUiPhotograph:UpdateCamera() + self.CameraFar.gameObject:SetActiveEx(true) + self.CameraNear.gameObject:SetActiveEx(true) +end + +function XUiPhotograph:ForcePlay(signBoardActionId) + local config = XSignBoardConfigs.GetSignBoardConfigById(signBoardActionId) + if self.SignBoardPlayer:GetInterruptDetection() and self.SignBoardPlayer.PlayerData.PlayingElement.Id ~= config.Id then + self:PlayChangeActionEffect() + end + self.SignBoardPlayer:ForcePlay(config) + self.SignBoardPlayer:SetInterruptDetection(true) +end + +function XUiPhotograph:Play(element) + if not element then + return + end + + if element.SignBoardConfig.CvId and element.SignBoardConfig.CvId > 0 then + if element.CvType then + self.PlayingCv = CS.XAudioManager.PlayCvWithCvType(element.SignBoardConfig.CvId, element.CvType) + else + self.PlayingCv = CS.XAudioManager.PlayCv(element.SignBoardConfig.CvId) + end + end + + local actionId = element.SignBoardConfig.ActionId + if actionId then + self.RoleModel:PlayAnima(actionId, true) + self.RoleModel:LoadCharacterUiEffect(tonumber(element.SignBoardConfig.RoleId), actionId) + end +end + +--停止 +function XUiPhotograph:OnStop(playingElement) + if self.PlayingCv then + self.PlayingCv:Stop() + self.PlayingCv = nil + end + + if playingElement then + self.RoleModel:StopAnima(playingElement.SignBoardConfig.ActionId) + self.RoleModel:LoadCurrentCharacterDefaultUiEffect() + end + + self.SignBoardPlayer:SetInterruptDetection(false) +end + +function XUiPhotograph:Photograph() + XCameraHelper.ScreenShotNew(self.ImgPicture, self.CameraComponentNear, function (screenShot) + -- 截图后操作 + XCameraHelper.ScreenShotNew(self.CapturePanel.ImagePhoto, self.CameraCupture, function (screenShot) -- 把合成后的图片渲染到游戏UI中的照片展示(最终要分享的图片) + CsXUiManager.Instance:ChangeCanvasTypeCamera(CsXUiType.Normal, CS.XUiManager.Instance.UiCamera) + self.ShareTexture = screenShot + self.PhotoName = "[" .. tostring(XPlayer.Id) .. "]" .. XTime.GetServerNowTimestamp() + self:PlayAnimation("Shanguang", function () + if not XTool.UObjIsNil(self.ImgPicture.mainTexture) and self.ImgPicture.mainTexture.name ~= "UnityWhite" then -- 销毁texture2d (UnityWhite为默认的texture2d) + CS.UnityEngine.Object.Destroy(self.ImgPicture.mainTexture) + end + end) + self:PlayAnimation("Photo", function () + self.CapturePanel.BtnClose.gameObject:SetActiveEx(true) + end, function () + self:ChangeState(XPhotographConfigs.PhotographViewState.SDK) + self.CapturePanel.BtnClose.gameObject:SetActiveEx(false) + end) + end, function () CsXUiManager.Instance:ChangeCanvasTypeCamera(CsXUiType.Normal, self.CameraCupture) end) + end) + XDataCenter.PhotographManager.SendPhotoGraphRequest() +end + +function XUiPhotograph:SetProportionImage() + local defaultHeight = self.ImageContainer.rect.height + local ProportionValue = SCREEN_WIDTH / SCREEN_HEIGHT + local screenWidth = math.floor(ProportionValue * defaultHeight) + self.ImageContainer.sizeDelta = Vector2(screenWidth, defaultHeight) + + self.ImgPicture.rectTransform.sizeDelta = Vector2(CsXUiManager.RealScreenWidth, CsXUiManager.RealScreenHeight) +end + +function XUiPhotograph:CheckHasChanged() + local curSceneId = XDataCenter.PhotographManager.GetCurSceneId() + local curSelectSceneId = XDataCenter.PhotographManager.GetCurSelectSceneId() + if curSceneId == curSelectSceneId and self.CurCharacterId == self.SelectCharacterId and self.CurFashionId == self.SelectFashionId then + return false + end + + return true +end + +function XUiPhotograph:PlayChangeActionEffect() + if self.ChangeActionEffect then + self.ChangeActionEffect.gameObject:SetActive(false) + self.ChangeActionEffect.gameObject:SetActive(true) + end +end + +function XUiPhotograph:UpdateBatteryMode() -- editor模式下 BatteryComponent.BatteryLevel 默认值为-1 + if XQualityManager.IsSimulator and not BatteryComponent.DebugMode then + return + end + + local animationRoot = self.UiSceneInfo.Transform:Find("Animations") + local toChargeTimeLine = animationRoot:Find("ToChargeTimeLine") + local toFullTimeLine = animationRoot:Find("ToFullTimeLine") + local fullTimeLine = animationRoot:Find("FullTimeLine") + local chargeTimeLine = animationRoot:Find("ChargeTimeLine") + + toChargeTimeLine.gameObject:SetActiveEx(false) + toFullTimeLine.gameObject:SetActiveEx(false) + fullTimeLine.gameObject:SetActiveEx(false) + chargeTimeLine.gameObject:SetActiveEx(false) + + local curSelectSceneId = XDataCenter.PhotographManager.GetCurSelectSceneId() + local particleGroupName = XDataCenter.PhotographManager.GetSceneTemplateById(curSelectSceneId).ParticleGroupName + local chargeAnimator = nil + if particleGroupName and particleGroupName ~= "" then + local chargeAnimatorTrans = self.UiSceneInfo.Transform:FindTransform(particleGroupName) + if chargeAnimatorTrans then + chargeAnimator = chargeAnimatorTrans:GetComponent("Animator") + else + XLog.Error("Can't Find \""..particleGroupName.."\", Plase Check \"ParticleGroupName\" In Share/PhotoMode/Background.tab") + end + end + + if BatteryComponent.IsCharging then --充电状态 + if chargeAnimator then chargeAnimator:Play("Full") end + fullTimeLine.gameObject:SetActiveEx(true) + else + if BatteryComponent.BatteryLevel > LowPowerValue then -- 比较电量 + if chargeAnimator then chargeAnimator:Play("Full") end + fullTimeLine.gameObject:SetActiveEx(true) + else + if chargeAnimator then chargeAnimator:Play("Low") end + chargeTimeLine.gameObject:SetActiveEx(true) + end + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPhotograph/XUiPhotographCapturePanel.lua b/Resources/Scripts/XUi/XUiPhotograph/XUiPhotographCapturePanel.lua new file mode 100644 index 00000000..59a7df28 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPhotograph/XUiPhotographCapturePanel.lua @@ -0,0 +1,35 @@ +local XUiPhotographCapturePanel = XClass(nil, "XUiPhotographCapturePanel") + +function XUiPhotographCapturePanel:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + + self:Init() +end + +function XUiPhotographCapturePanel:Init() + self:AutoRegisterBtn() +end + +function XUiPhotographCapturePanel:AutoRegisterBtn() + self.BtnClose.CallBack = function () self:OnBtnCloseClick() end +end + +function XUiPhotographCapturePanel:OnBtnCloseClick() + self.RootUi:ChangeState(XPhotographConfigs.PhotographViewState.Normal) + if not XTool.UObjIsNil(self.ImagePhoto.mainTexture) and self.ImagePhoto.mainTexture.name ~= "UnityWhite" then -- 销毁texture2d (UnityWhite为默认的texture2d) + CS.UnityEngine.Object.Destroy(self.ImagePhoto.mainTexture) + end +end + +function XUiPhotographCapturePanel:Show() + self.GameObject:SetActiveEx(true) +end + +function XUiPhotographCapturePanel:Hide() + self.GameObject:SetActiveEx(false) +end + +return XUiPhotographCapturePanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPhotograph/XUiPhotographPanel.lua b/Resources/Scripts/XUi/XUiPhotograph/XUiPhotographPanel.lua new file mode 100644 index 00000000..be19a1a9 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPhotograph/XUiPhotographPanel.lua @@ -0,0 +1,296 @@ +local CSXTextManagerGetText = CS.XTextManager.GetText + +local XUiPhotographPanel = XClass(nil, "XUiPhotographPanel") +local XUiGridPhotographSceneBtn = require("XUi/XUiPhotograph/XUiGridPhotographSceneBtn") +local XUiGridPhotographCharacterBtn = require("XUi/XUiPhotograph/XUiGridPhotographCharacterBtn") +local XUiGridPhotographOtherBtn = require("XUi/XUiPhotograph/XUiGridPhotographOtherBtn") + +local MenuBtnType = { + Scene = 1, + Character = 2, + Fashion = 3, + Action = 4, +} + +function XUiPhotographPanel:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + + self:Init() +end + +function XUiPhotographPanel:Init() + self:InitMenuBtnGroup() + self:InitDynamicTable() + self.BtnPhotograph.CallBack = function () self:OnBtnPhotographClick() end + self.BtnSynchronous.CallBack = function () self:OnBtnSynchronousClick() end + self.CurCharId = self.CurCharId and self.CurCharId or XPlayer.DisplayCharId + self:SetBtnSynchronousActiveEx(false) +end + +function XUiPhotographPanel:DefaultClick() + self:OnSelectMenuBtn(MenuBtnType.Scene, true) + self.MenuBtns[MenuBtnType.Scene].ButtonState = CS.UiButtonState.Select + local data = XDataCenter.PhotographManager.GetSceneTemplateById(XDataCenter.PhotographManager.GetCurSceneId()) + self:SetInfoTextName(data.Name) +end + +function XUiPhotographPanel:Show() + self.GameObject:SetActiveEx(true) +end + +function XUiPhotographPanel:Hide() + self.GameObject:SetActiveEx(false) +end + +function XUiPhotographPanel:InitMenuBtnGroup() + self.MenuBtns = { + self.BtnScene, + self.BtnCharacter, + self.BtnFashion, + self.BtnAction, + } + self.PanelMenu:Init(self.MenuBtns, function(index) self:OnSelectMenuBtn(index) end) +end + +function XUiPhotographPanel:OnSelectMenuBtn(index, isDefault) + if self.CurMenuType and self.CurMenuType == index then + return + end + self.CurMenuType = index + + self.PanelSceneList.gameObject:SetActiveEx(false) + self.PanelCharacterList.gameObject:SetActiveEx(false) + self.PanelOtherList.gameObject:SetActiveEx(false) + + if index == MenuBtnType.Scene then + self.PanelSceneList.gameObject:SetActiveEx(true) + self.CurSceneIndex = XDataCenter.PhotographManager.GetSceneIndexById(XDataCenter.PhotographManager.GetCurSceneId()) + self.CurSceneIndex = 1 + self.DynamicTableScene:SetDataSource(XDataCenter.PhotographManager.GetSceneIdList()) + self.DynamicTableScene:ReloadDataASync(self.CurSceneIndex) + elseif index == MenuBtnType.Character then + self.PanelCharacterList.gameObject:SetActiveEx(true) + self.DynamicTableCharacter:SetDataSource(XDataCenter.PhotographManager.GetCharacterList()) + self.CurCharId = self.CurCharId and self.CurCharId or XPlayer.DisplayCharId + self.CurCharIndex = XDataCenter.PhotographManager.GetCharIndexById(self.CurCharId) + self.DynamicTableCharacter:ReloadDataASync(self.CurCharIndex) + elseif index == MenuBtnType.Fashion then + self.PanelOtherList.gameObject:SetActiveEx(true) + self.FashionList = XDataCenter.FashionManager.GetCurrentTimeFashionByCharId(self.CurCharId) + self.CurFashionIndex = self.CurFashionIndex and self.CurFashionIndex or XDataCenter.PhotographManager.GetFashionIndexByFashionList(self.CurCharId, self.FashionList) + self.DynamicTableOther:SetDataSource(self.FashionList) + self.DynamicTableOther:ReloadDataASync() + elseif index == MenuBtnType.Action then + self.PanelOtherList.gameObject:SetActiveEx(true) + self.ActionList = XFavorabilityConfigs.GetCharacterActionById(self.CurCharId) or {} + self.DynamicTableOther:SetDataSource(self.ActionList) + self.DynamicTableOther:ReloadDataASync() + end + + self:UpdateInfoType(index) + + self:PlayPanelListAnim(index) +end + +function XUiPhotographPanel:InitDynamicTable() + self.DynamicTableScene = XDynamicTableNormal.New(self.PanelSceneList) + self.DynamicTableScene:SetProxy(XUiGridPhotographSceneBtn) + self.DynamicTableScene:SetDelegate(self) + + self.DynamicTableCharacter = XDynamicTableNormal.New(self.PanelCharacterList) + self.DynamicTableCharacter:SetProxy(XUiGridPhotographCharacterBtn) + self.DynamicTableCharacter:SetDelegate(self) + + self.DynamicTableOther = XDynamicTableNormal.New(self.PanelOtherList) + self.DynamicTableOther:SetProxy(XUiGridPhotographOtherBtn) + self.DynamicTableOther:SetDelegate(self) +end + +function XUiPhotographPanel:OnDynamicTableEvent(event, index, grid) + if self.CurMenuType == MenuBtnType.Scene then -- 场景按钮格子事件处理回调 + self:OnDynamicTableSceneEvent(event, index, grid) + elseif self.CurMenuType == MenuBtnType.Character then -- 角色按钮格子事件处理回调 + self:OnDynamicTableCharacterEvent(event, index, grid) + elseif self.CurMenuType == MenuBtnType.Fashion then -- 涂装按钮格子事件处理回调 + self:OnDynamicTableFashionEvent(event, index, grid) + elseif self.CurMenuType == MenuBtnType.Action then -- 动作按钮格子事件处理回调 + self:OnDynamicTableActionEvent(event, index, grid) + end +end + +function XUiPhotographPanel:OnDynamicTableSceneEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self.RootUi) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local sceneId = XDataCenter.PhotographManager.GetSceneIdByIndex(index) + local data = XDataCenter.PhotographManager.GetSceneTemplateById(sceneId) + grid:Reset() + grid:Refrash(data) + if self.CurSceneIndex and self.CurSceneIndex == index then + self.CurSceneGrid = grid + grid:SetSelect(true) + self:SetInfoTextName(data.Name) + end + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + local sceneId = XDataCenter.PhotographManager.GetSceneIdByIndex(index) + local sceneTemplate = XDataCenter.PhotographManager.GetSceneTemplateById(sceneId) + local isHas = XDataCenter.PhotographManager.CheckSceneIsHaveById(sceneId) + if not isHas then + XUiManager.TipError(sceneTemplate.LockDec) + return + end + if self.CurSceneIndex and self.CurSceneIndex == index then + return + end + if self.CurSceneGrid ~= nil then + self.CurSceneGrid:SetSelect(false) + end + self.CurSceneGrid = grid + self.CurSceneIndex = index + local sceneId = XDataCenter.PhotographManager.GetSceneIdByIndex(index) + local data = XDataCenter.PhotographManager.GetSceneTemplateById(sceneId) + self:SetInfoTextName(data.Name) + grid:OnTouched(data) + end +end + +function XUiPhotographPanel:OnDynamicTableCharacterEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = XDataCenter.PhotographManager.GetCharacterDataByIndex(index) + grid:Reset() + grid:Refrash(data) + if self.CurCharIndex and self.CurCharIndex == index then + self.CurCharGrid = grid + grid:SetSelect(true) + self:SetInfoTextName(data.LogName) + end + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + if self.CurCharIndex and self.CurCharIndex == index then + return + end + if self.CurCharGrid ~= nil then + self.CurCharGrid:SetSelect(false) + end + self.CurCharGrid = grid + local data = XDataCenter.PhotographManager.GetCharacterDataByIndex(index) + self.CurCharId = data.Id + self.CurCharIndex = index + self.CurFashionIndex = nil -- 切换角色清空涂装index 再次点击涂装会重新获取index + self:SetInfoTextName(data.LogName) + grid:OnTouched(self.CurCharId) + end +end + +function XUiPhotographPanel:OnDynamicTableFashionEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.FashionList[index] + grid:Reset() + grid:RefrashFashion(data) + if self.CurFashionIndex and self.CurFashionIndex == index then + self.CurFashionGrid = grid + grid:SetSelect(true) + self:SetInfoTextName(XDataCenter.FashionManager.GetFashionName(data)) + end + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + local isHas = XDataCenter.FashionManager.CheckHasFashion(self.FashionList[index]) + if not isHas then + XUiManager.TipError(CS.XTextManager.GetText("PhotoModeNoFashion")) + return + end + if self.CurFashionIndex and self.CurFashionIndex == index then + return + end + if self.CurFashionGrid ~= nil then + self.CurFashionGrid:SetSelect(false) + end + self.CurFashionGrid = grid + self.CurFashionIndex = index + self:SetInfoTextName(XDataCenter.FashionManager.GetFashionName(self.FashionList[index])) + grid:OnFashionTouched(self.CurCharId, self.FashionList[index]) + end +end + +function XUiPhotographPanel:OnDynamicTableActionEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.ActionList[index] + local charData = XDataCenter.PhotographManager.GetCharacterDataById(self.CurCharId) + grid:Reset() + grid:RefrashAction(data, charData) + self:SetInfoTextName() + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + local isHas = XDataCenter.PhotographManager.GetCharacterDataById(self.CurCharId).TrustLv >= self.ActionList[index].UnlockLv + if not isHas then + XUiManager.TipError(self.ActionList[index].ConditionDescript) + return + end + if self.CurActionGrid ~= nil then + self.CurActionGrid:SetSelect(false) + end + self.CurActionGrid = grid + self:SetInfoTextName(self.ActionList[index].Name) + grid:OnActionTouched(self.ActionList[index]) + end +end + +function XUiPhotographPanel:OnBtnPhotographClick() + CsXGameEventManager.Instance:Notify(XEventId.EVENT_PHOTO_PHOTOGRAPH) +end + +function XUiPhotographPanel:OnBtnSynchronousClick() + XDataCenter.PhotographManager.ChangeDisplay(XDataCenter.PhotographManager.GetCurSelectSceneId(), self.RootUi.SelectCharacterId, self.RootUi.SelectFashionId, function () + self.RootUi.CurCharacterId = self.RootUi.SelectCharacterId + self.RootUi.CurFashionId = self.RootUi.SelectFashionId + self:SetBtnSynchronousActiveEx(self.RootUi:CheckHasChanged()) + end) +end + +function XUiPhotographPanel:SetBtnSynchronousActiveEx(bool) + self.BtnSynchronous.gameObject:SetActiveEx(bool) +end + +function XUiPhotographPanel:UpdateInfoType(btnType) + self.TxtAction.gameObject:SetActiveEx(false) + self.TxtScene.gameObject:SetActiveEx(false) + self.TxTFashion.gameObject:SetActiveEx(false) + self.TxTCharacter.gameObject:SetActiveEx(false) + if btnType == MenuBtnType.Scene then + self.TxtScene.gameObject:SetActiveEx(true) + elseif btnType == MenuBtnType.Character then + self.TxTCharacter.gameObject:SetActiveEx(true) + elseif btnType == MenuBtnType.Fashion then + self.TxTFashion.gameObject:SetActiveEx(true) + elseif btnType == MenuBtnType.Action then + self.TxtAction.gameObject:SetActiveEx(true) + end +end + +function XUiPhotographPanel:SetInfoTextName(textName) + if not textName or textName == "" then + self.TxtName.text = CSXTextManagerGetText("PhotoModeNotChooseText") + return + end + + self.TxtName.text = textName +end + +function XUiPhotographPanel:PlayPanelListAnim(menuBtnType) + self.RootUi:PlayAnimation("Qiehuan") + if menuBtnType == MenuBtnType.Scene then + self.RootUi:PlayAnimation("PanelSceneListEnable") + elseif menuBtnType == MenuBtnType.Character then + self.RootUi:PlayAnimation("PanelCharacterListEnable") + elseif menuBtnType == MenuBtnType.Fashion or menuBtnType == MenuBtnType.Action then + self.RootUi:PlayAnimation("PanelOtherListEnable") + end +end + +return XUiPhotographPanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPhotograph/XUiPhotographSDKPanel.lua b/Resources/Scripts/XUi/XUiPhotograph/XUiPhotographSDKPanel.lua new file mode 100644 index 00000000..7b407099 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPhotograph/XUiPhotographSDKPanel.lua @@ -0,0 +1,58 @@ +local XUiPhotographSDKPanel = XClass(nil, "XUiPhotographSDKPanel") + +function XUiPhotographSDKPanel:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + + self:Init() +end + +function XUiPhotographSDKPanel:Init() + self.ShareBtnList = { + self.BtnShare1, + self.BtnShare2, + self.BtnShare3, + self.BtnShare4, + self.BtnShare5, + } + self:AutoRegisterBtn() +end + +function XUiPhotographSDKPanel:AutoRegisterBtn() + local shareSDKIds = XDataCenter.PhotographManager.GetShareSDKIds() + local shareBtnCount = #shareSDKIds + for i=1, #self.ShareBtnList, 1 do + if i <= shareBtnCount then + local shareInfo = XPhotographConfigs.GetShareInfoByType(shareSDKIds[i]) + if shareInfo then + self.ShareBtnList[i].gameObject:SetActiveEx(true) + self.ShareBtnList[i].CallBack = function () self:OnClickShareBtn(i) end + self.ShareBtnList[i]:SetSprite(shareInfo.IconPath) + self.ShareBtnList[i]:SetName(shareInfo.Name) + end + else + self.ShareBtnList[i].gameObject:SetActiveEx(false) + end + end + self.BtnSave.CallBack = function () + XDataCenter.PhotographManager.SharePhoto(self.RootUi.PhotoName, self.RootUi.ShareTexture, XPlatformShareConfigs.PlatformType.Local) + end + self.BtnSave.gameObject:SetActiveEx(false) -- 日服屏蔽保存功能 +end + +function XUiPhotographSDKPanel:Show() + self.GameObject:SetActiveEx(true) +end + +function XUiPhotographSDKPanel:Hide() + self.GameObject:SetActiveEx(false) +end + +function XUiPhotographSDKPanel:OnClickShareBtn(index) + local platformType = XDataCenter.PhotographManager.GetShareTypeByIndex(index) + XDataCenter.PhotographManager.SharePhoto(self.RootUi.PhotoName, self.RootUi.ShareTexture, platformType) +end + +return XUiPhotographSDKPanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPicComposition/XUiGridEditDialogue.lua b/Resources/Scripts/XUi/XUiPicComposition/XUiGridEditDialogue.lua new file mode 100644 index 00000000..d2220226 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPicComposition/XUiGridEditDialogue.lua @@ -0,0 +1,146 @@ +XUiGridEditDialogue = XClass(nil, "XUiGridEditDialogue") +local EditIcon = CS.XGame.ClientConfig:GetString("PicCompositionEditIcon") +local CSTextManagerGetText = CS.XTextManager.GetText +function XUiGridEditDialogue:Ctor(ui,base) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Base = base + + XTool.InitUiObject(self) + self:Init() + self:SetButtonCallBack() + +end + +function XUiGridEditDialogue:Init() + local picCompositionCfg = XMarketingActivityConfigs.GetPicCompositionActivityInfoConfigs() + local activityId = XDataCenter.MarketingActivityManager.GetNowActivityId() + self.TxtEdit.characterLimit = picCompositionCfg[activityId] and picCompositionCfg[activityId].ContentMaxLength or 0 +end + +function XUiGridEditDialogue:AddListener() + XEventManager.AddEventListener(XEventId.EVENT_PICCOMPOSITION_GET_WORD,self.SetTrueWord,self) +end + +function XUiGridEditDialogue:RemoveListener() + XEventManager.RemoveEventListener(XEventId.EVENT_PICCOMPOSITION_GET_WORD,self.SetTrueWord,self) +end + +function XUiGridEditDialogue:SetButtonCallBack() + self.BtnEdit.CallBack = function() + self:OnBtnEditClick() + end + + self.BtnView.CallBack = function() + self:OnBtnViewClick() + end + + self.BtnClear.CallBack = function() + self:OnBtnClearClick() + end + + self.TxtEdit.onValueChanged:AddListener(function() + self:OnTextChange() + end) + + self.TxtEdit.onEndEdit:AddListener(function() + self:OnTextInputEnd() + end) +end + +function XUiGridEditDialogue:Update(index,IsCanEdit) + self.DialogueIndex = index + self.TxtEdit.text = "" + self.TxtWord.text = "" + self.ImgHead:SetRawImage(EditIcon) + self.PanelMsg.gameObject:SetActiveEx(false) + self.BtnClear.gameObject:SetActiveEx(false) + + self:ShowEditText(true) + if self.Base.EditDialogueDataList.Dialogue[index] then + if self.Base.EditDialogueDataList.Dialogue[index].CharacterId then + local info = XMarketingActivityConfigs.GetCompositionCharacterConfigById(self.Base.EditDialogueDataList.Dialogue[index].CharacterId) + if info then + self.PanelMsg.gameObject:SetActiveEx(true) + self.BtnClear.gameObject:SetActiveEx(true) + self.ImgHead:SetRawImage(info.Icon) + self.TxtName.text = info.Name + end + end + local content = self.Base.EditDialogueDataList.Dialogue[index].Content + if content and #content > 0 then + self:ShowEditText(false) + self.TxtWord.text = content + end + self.GameObject:SetActiveEx(true) + self:AddListener() + else + self.GameObject:SetActiveEx(IsCanEdit) + self:RemoveListener() + end +end + +function XUiGridEditDialogue:OnBtnEditClick() + self:ShowEditText(true) + self.TxtEdit.text = self.TxtWord.text + self.TxtEdit:ActivateInputField() +end + +function XUiGridEditDialogue:OnBtnViewClick() + if not self.Base.EditDialogueDataList.Dialogue[self.DialogueIndex] then + self.Base.EditDialogueDataList.Dialogue[self.DialogueIndex] = {} + end + self.Base.HeadPortraitSelect:PreviewHeadPortrait(self.Base.EditDialogueDataList.Dialogue[self.DialogueIndex],function () + self.Base:UpdateEditDialogueList() + end,function () + local content = self.Base.EditDialogueDataList.Dialogue[self.DialogueIndex].Content + if not content or #content == 0 then + self:OnBtnClearClick() + end + end) +end + +function XUiGridEditDialogue:OnBtnClearClick() + self.Base.EditDialogueDataList.Dialogue[self.DialogueIndex].IsClear = true + self.Base:CheckEditDialogueClear() +end + +function XUiGridEditDialogue:OnTextChange() + +end + +function XUiGridEditDialogue:OnTextInputEnd() + if #self.TxtEdit.text > 0 then + self:ShowEditText(false) + end + --self.TxtWord.text = self.TxtEdit.text + self.TxtWord.text = CSTextManagerGetText("PicCompositionWaitWord") + self.Base.EditDialogueDataList.Dialogue[self.DialogueIndex].Content = self.TxtWord.text + self.Base.EditDialogueDataList.Dialogue[self.DialogueIndex].StartIndex = self.DialogueIndex + XDataCenter.MarketingActivityManager.GetTrueWord(self.TxtEdit.text,nil,nil,self.DialogueIndex) + --self.Base.EditDialogueDataList.Dialogue[self.DialogueIndex].Content = self.TxtWord.text +end + +function XUiGridEditDialogue:SetTrueWord(IsGet,trueWord,index) + local dialogue = self.Base.EditDialogueDataList.Dialogue[self.DialogueIndex] + if dialogue and index == dialogue.StartIndex then + if IsGet then + self.TxtWord.text = trueWord + dialogue.Content = self.TxtWord.text + else + self:ErrorExit() + end + dialogue.StartIndex = self.DialogueIndex + end +end + +function XUiGridEditDialogue:ShowEditText(IsShowEdit) + self.TxtEdit.gameObject:SetActiveEx(IsShowEdit) + self.TxtWord.gameObject:SetActiveEx(not IsShowEdit) +end + +function XUiGridEditDialogue:ErrorExit() + XUiManager.TipText("PicCompositionNetError") + XLuaUiManager.RunMain() +end + diff --git a/Resources/Scripts/XUi/XUiPicComposition/XUiGridHeadPortrait.lua b/Resources/Scripts/XUi/XUiPicComposition/XUiGridHeadPortrait.lua new file mode 100644 index 00000000..fc659a6d --- /dev/null +++ b/Resources/Scripts/XUi/XUiPicComposition/XUiGridHeadPortrait.lua @@ -0,0 +1,46 @@ +XUiGridHeadPortrait = XClass(nil, "XUiGridHeadPortrait") + +function XUiGridHeadPortrait:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:AutoAddListener() +end + +function XUiGridHeadPortrait:AutoAddListener() + self.BtnRole.CallBack = function() + self:OnBtnRoleClick() + end +end + +function XUiGridHeadPortrait:OnBtnRoleClick() + self.Base:SetData(self.CharacterId) + self:SetSelectShow(self.Base) + self.Base.OldSelectGrig:SetSelectShow(self.Base) + self.Base.OldSelectGrig = self +end + +function XUiGridHeadPortrait:UpdateGrid(chapter, parent) + self.Base = parent + self.CharacterId = chapter.Id + if chapter.Icon ~= nil then + self.UnLockImgHeadImg:SetRawImage(chapter.Icon) + end + + self:SetSelectShow(parent) +end + +function XUiGridHeadPortrait:SetSelectShow(parent) + if parent.SelectCharacterId == self.CharacterId then + self:ShowSelect(true) + else + self:ShowSelect(false) + end + if not self.Base.OldSelectGrig then + self.Base.OldSelectGrig = self + end +end + +function XUiGridHeadPortrait:ShowSelect(bShow) + self.ImgRoleSelect.gameObject:SetActiveEx(bShow) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPicComposition/XUiGridNormalDialogue.lua b/Resources/Scripts/XUi/XUiPicComposition/XUiGridNormalDialogue.lua new file mode 100644 index 00000000..2e9d3d13 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPicComposition/XUiGridNormalDialogue.lua @@ -0,0 +1,33 @@ +XUiGridNormalDialogue = XClass(nil, "XUiGridNormalDialogue") +local EditIcon = CS.XGame.ClientConfig:GetString("PicCompositionEditIcon") + +function XUiGridNormalDialogue:Ctor(ui,base) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Base = base + + XTool.InitUiObject(self) +end + + +function XUiGridNormalDialogue:Update(dialogueData) + self.TxtWord.text = "" + self.ImgHead:SetRawImage(EditIcon) + + if dialogueData then + if dialogueData.CharacterId then + local info = XMarketingActivityConfigs.GetCompositionCharacterConfigById(dialogueData.CharacterId) + if info then + self.ImgHead:SetRawImage(info.Icon) + self.TxtName.text = info.Name + end + end + if dialogueData.Content then + self.TxtWord.text = dialogueData.Content + end + self.GameObject:SetActiveEx(true) + else + self.GameObject:SetActiveEx(false) + end +end + diff --git a/Resources/Scripts/XUi/XUiPicComposition/XUiGridRank.lua b/Resources/Scripts/XUi/XUiPicComposition/XUiGridRank.lua new file mode 100644 index 00000000..e97775ea --- /dev/null +++ b/Resources/Scripts/XUi/XUiPicComposition/XUiGridRank.lua @@ -0,0 +1,60 @@ +XUiGridRank = XClass(nil, "XUiGridRank") + +local MAX_SPECIAL_NUM = 3 +local FirstIndex = 1 +function XUiGridRank:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:SetButtonCallBack() +end + +function XUiGridRank:SetButtonCallBack() + self.BtnGo.CallBack = function() + self:OnBtnGoClick() + end +end + +function XUiGridRank:UpdateGrid(data,index,base,IsInit) + self.Data = data + self.Base = base + self.TxtPlayerName.text = data.UserName + self.TxtRankScore.text = math.floor(data.Hot) + self.Index = index + + local btnStatus = self.Base.SelectDataIndex == index and + CS.UiButtonState.Select or CS.UiButtonState.Normal + self.BtnGo:SetButtonState(btnStatus) + + self.TxtRankNormal.gameObject:SetActiveEx(index > MAX_SPECIAL_NUM) + self.ImgRankSpecial.gameObject:SetActiveEx(index <= MAX_SPECIAL_NUM) + if index <= MAX_SPECIAL_NUM then + local icon = XDataCenter.FubenBossSingleManager.GetRankSpecialIcon(index) + self.Base:SetUiSprite(self.ImgRankSpecial, icon) + else + self.TxtRankNormal.text = index + end + + XUiPLayerHead.InitPortrait(data.HeadPortraitId, data.HeadFrameId, self.Head) + + if not self.Base.IsHaveReward and IsInit then + if index == FirstIndex then + self:OnBtnGoClick() + end + end +end + +function XUiGridRank:OnBtnGoClick() + self.Base.PanelRankReward.gameObject:SetActiveEx(false) + self.Base.Phone.gameObject:SetActiveEx(true) + self.Base.PlayerRankData = self.Data + self.Base:UpdatePhone() + self.Base:PlayAnimation("PhoneQieHuan") + + if self.Base.OldButton then + self.Base.OldButton:SetButtonState(CS.UiButtonState.Normal) + end + self.BtnGo:SetButtonState(CS.UiButtonState.Select) + self.Base.OldButton = self.BtnGo + self.Base.SelectDataIndex = self.Index +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPicComposition/XUiHeadPortraitSelect.lua b/Resources/Scripts/XUi/XUiPicComposition/XUiHeadPortraitSelect.lua new file mode 100644 index 00000000..c141900e --- /dev/null +++ b/Resources/Scripts/XUi/XUiPicComposition/XUiHeadPortraitSelect.lua @@ -0,0 +1,73 @@ +XUiHeadPortraitSelect = XClass(nil, "XUiHeadPortraitSelect") +local DefaultIndex = 1 +function XUiHeadPortraitSelect:Ctor(base,ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Base = base + XTool.InitUiObject(self) + self:AutoAddListener() + self:InitDynamicTable() + self.GameObject:SetActiveEx(false) +end + +function XUiHeadPortraitSelect:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.ScrollView) + self.DynamicTable:SetProxy(XUiGridHeadPortrait) + self.DynamicTable:SetDelegate(self) + self.HeadPortrait.gameObject:SetActiveEx(false) +end + +function XUiHeadPortraitSelect:SetupDynamicTable() + self.PageDatas = XDataCenter.MarketingActivityManager.GetCharacterList() + self.DynamicTable:SetDataSource(self.PageDatas) + self.DynamicTable:ReloadDataSync(1) +end + +function XUiHeadPortraitSelect:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:UpdateGrid(self.PageDatas[index],self) + end +end + +function XUiHeadPortraitSelect:AutoAddListener() + self.BtnHeadSure.CallBack = function() + self:OnBtnHeadSureClick() + end + self.BtnHeadCancel.CallBack = function() + if self.ClearCb then self.ClearCb() end + self.Base:HideHeadPortraitSelect() + end + self.BtnClose.CallBack = function() + if self.ClearCb then self.ClearCb() end + self.Base:HideHeadPortraitSelect() + end +end + +function XUiHeadPortraitSelect:OnBtnHeadSureClick() + self.DialogueData.CharacterId = self.SelectCharacterId + self.Base:HideHeadPortraitSelect() + if self.CallBack then + self.CallBack() + end +end + +function XUiHeadPortraitSelect:SetData(characterId) + local info = XMarketingActivityConfigs.GetCompositionCharacterConfigById(characterId) + if (info ~= nil) then + self.RImgPlayerIcon:SetRawImage(info.Icon) + self.SelectCharacterId = characterId + self.TxtHeadName.text = info.Name + self.TxtDesc.text = info.Desc + end +end + +function XUiHeadPortraitSelect:PreviewHeadPortrait(dialogueData,cb,clearCb) + self.OldSelectGrig = nil + self:SetupDynamicTable() + local id = dialogueData.CharacterId or self.PageDatas[DefaultIndex].Id + self.DialogueData = dialogueData + self.CallBack = cb + self.ClearCb = clearCb + self:SetData(id) + self.GameObject:SetActiveEx(true) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPicComposition/XUiPicChatRank.lua b/Resources/Scripts/XUi/XUiPicComposition/XUiPicChatRank.lua new file mode 100644 index 00000000..7b5a7c69 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPicComposition/XUiPicChatRank.lua @@ -0,0 +1,254 @@ +local XUiPicChatRank = XLuaUiManager.Register(XLuaUi, "UiPicChatRank") +local RankRewardMax = 3 +local DialogueMax = 4 +local CSTextManagerGetText = CS.XTextManager.GetText +local CSXGameConfig = CS.XGame.Config +function XUiPicChatRank:OnDestroy() + +end + +function XUiPicChatRank:OnStart() + self:InitData() +end + +function XUiPicChatRank:OnEnable() + +end + + + +function XUiPicChatRank:InitData() + local picCompositionCfg = XMarketingActivityConfigs.GetPicCompositionActivityInfoConfigs() + + self.CurActivityId = XDataCenter.MarketingActivityManager.GetNowActivityId() + local picComposition = picCompositionCfg[self.CurActivityId] + + self.LikeItem = self.CurActivityId and picComposition and + picComposition.PraiseItemId or nil + + self.RankNum = self.CurActivityId and picComposition and + picComposition.RankNum or nil + + self.RankDataAllList = {} + self.AssetActivityPanel = XUiPanelActivityAsset.New(self.PanelSpecialTool, true) + + self.RankDataAllList = XDataCenter.MarketingActivityManager.GetRankCompositionDataList() + self.PanelNoRank.gameObject:SetActiveEx(#self.RankDataAllList == 0) + + self.TopTxet.text = CSTextManagerGetText("PicCompositionRankTop",self.RankNum) + + self:InitRankReward() + self:InitPhone() + self:UpdatePhone() + self:SetButtonCallBack() + self:InitDynamicTable() + self:SetupDynamicTable() + +end + +function XUiPicChatRank:InitRankReward() + local RankRewardInfos = XDataCenter.MarketingActivityManager.GetPicCompositionRankRewardInfoList() + self.RankObj = { + self.Rank1, + self.Rank2, + self.Rank3 + } + + self.IsHaveReward = #RankRewardInfos > 0 + self.PanelRankReward.gameObject:SetActiveEx(self.IsHaveReward) + self.Phone.gameObject:SetActiveEx(not self.IsHaveReward) + + if self.IsHaveReward then + self:PlayAnimation("AnimEnable1") + else + self:PlayAnimation("AnimEnable2") + end + + self.RankReward ={} + for i = 1, RankRewardMax do + if not RankRewardInfos[i] then + self.RankObj[i].gameObject:SetActiveEx(false) + break + end + + self.RankReward[i] = {} + self.RankReward[i].RewardPanelList = {} + self.RankReward[i].Transform = self.RankObj[i].transform + self.RankReward[i].GameObject = self.RankObj[i].gameObject + XTool.InitUiObject(self.RankReward[i]) + + local minRank = RankRewardInfos[i].MinRank or 0 + local maxRank = RankRewardInfos[i].MaxRank or 0 + self.RankReward[i].Text.text = CSTextManagerGetText("PicCompositionRankReward",minRank,maxRank) + + local rewards = XRewardManager.GetRewardList(RankRewardInfos[i].RewardId) + for _,reward in pairs(rewards or {}) do + local panel + if #self.RankReward[i].RewardPanelList == 0 then + panel = XUiGridCommon.New(self, self.RankReward[i].GridDrawActivity) + else + local ui = CS.UnityEngine.Object.Instantiate(self.RankReward[i].GridDrawActivity) + ui.transform:SetParent(self.RankReward[i].Reward, false) + panel = XUiGridCommon.New(self, ui) + end + table.insert(self.RankReward[i].RewardPanelList, panel) + panel:Refresh(reward) + end + end + + local serverId = CS.XHeroBdcAgent.ServerId + if serverId == XMarketingActivityConfigs.SeverId.SparkServer then + self.TxtIos.text = CSTextManagerGetText("PicCompositionServerRankName",CSXGameConfig:GetString("SparkServer")) + elseif serverId == XMarketingActivityConfigs.SeverId.BeaconServer then + self.TxtIos.text = CSTextManagerGetText("PicCompositionServerRankName",CSXGameConfig:GetString("BeaconServer")) + else + self.TxtIos.text = CSTextManagerGetText("PicCompositionServerRankName",CSXGameConfig:GetString("TestServer")) + end +end + +function XUiPicChatRank:InitPhone() + self.NormalPhone = {} + self.NormalDialogueList = {} + self.NormalPhone.Transform = self.PanelNormalPhone.transform + self.NormalPhone.GameObject = self.PanelNormalPhone.gameObject + XTool.InitUiObject(self.NormalPhone) + self.NormalPhone.BtnPhoneClose.CallBack = function() + self:OnBtnPhoneCloseClick() + end + self.NormalPhone.BtnPhoneClose.gameObject:SetActiveEx(self.IsHaveReward) + self.NormalPhone.GameObject:SetActiveEx(true) + self.NormalPhone.DialogueObj = { + self.NormalPhone.Dialogue1, + self.NormalPhone.Dialogue2, + self.NormalPhone.Dialogue3, + self.NormalPhone.Dialogue4 + } + + for index = 1,DialogueMax do + self.NormalDialogueList[index] = XUiGridNormalDialogue.New(self.NormalPhone.DialogueObj[index],self) + end + +end + +function XUiPicChatRank:UpdatePhone() + if not self.PlayerRankData then + local UpLoadTimeType = XDataCenter.MarketingActivityManager.CheckIsCanUpLoad() + self:SetOtherDialogueStateShow(false) + if UpLoadTimeType == XMarketingActivityConfigs.TimeType.Before then + local bTime,eTime = XDataCenter.MarketingActivityManager.GetUpLoadTime(false) + self.NormalPhone.TipsText.text = CSTextManagerGetText("PicCompositionUpLoadTimeText") + self.NormalPhone.TimeText.text = string.format("%s--%s",bTime,eTime) + self.NormalPhone.TimeText.gameObject:SetActiveEx(true) + else + self.NormalPhone.TipsText.text = CSTextManagerGetText("NotHaveOtherComposition") + self.NormalPhone.TimeText.gameObject:SetActiveEx(false) + end + else + local hot = self.PlayerRankData.Hot or 0 + local name = self.PlayerRankData.UserName + local id = self.PlayerRankData.Id + local IsLike = XDataCenter.MarketingActivityManager.IsDoPicCompositionLike(id) + local dialogueDataList = self.PlayerRankData.Dialogue + local btnStatus = IsLike and CS.UiButtonState.Select or CS.UiButtonState.Normal + self.NormalPhone.OtherHotNum.text = XMarketingActivityConfigs.GetCountUnitChange(hot) + self.NormalPhone.PlayerName.text = CSTextManagerGetText("PicCompositionPlayerName",name) + self.NormalPhone.Tips.gameObject:SetActiveEx(false) + for index = 1,DialogueMax do + self.NormalDialogueList[index]:Update(dialogueDataList[index]) + end + + self:SetOtherDialogueStateShow(true) + self.NormalPhone.BtnLike:SetButtonState(btnStatus) + end + + local item = XDataCenter.ItemManager.GetItem(self.LikeItem) + if item then + self.AssetActivityPanel:Refresh({self.LikeItem}) + else + self.AssetActivityPanel:Refresh(nil) + end +end + +function XUiPicChatRank:SetOtherDialogueStateShow(IsShow) + self.NormalPhone.Tips.gameObject:SetActiveEx(not IsShow) + self.NormalPhone.PanelChatView.gameObject:SetActiveEx(IsShow) + self.NormalPhone.PanelOther.gameObject:SetActiveEx(IsShow) +end + +function XUiPicChatRank:SetButtonCallBack() + self.BtnBack.CallBack = function() + self:OnBtnBackClick() + end + self.BtnMainUi.CallBack = function() + self:OnBtnMainUiClick() + end + + self.NormalPhone.BtnLike.CallBack = function() + self:OnBtnLikeClick() + end +end + +function XUiPicChatRank:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.ChatRankList) + self.DynamicTable:SetProxy(XUiGridRank) + self.DynamicTable:SetDelegate(self) +end + +function XUiPicChatRank:SetupDynamicTable() + self.PageDatas = self.RankDataAllList + self.DynamicTable:SetDataSource(self.PageDatas) + self.DynamicTable:ReloadDataSync(1) +end + +function XUiPicChatRank:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:UpdateGrid(self.PageDatas[index],index,self,true) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:UpdateGrid(self.PageDatas[index],index,self,false) + -- elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + end +end + +function XUiPicChatRank:OnBtnBackClick() + self:Close() +end + +function XUiPicChatRank:OnBtnPhoneCloseClick() + self.PanelRankReward.gameObject:SetActiveEx(true) + self.Phone.gameObject:SetActiveEx(false) + self:PlayAnimation("RankRewardQieHuan") +end + +function XUiPicChatRank:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiPicChatRank:OnBtnLikeClick() + local id = self.PlayerRankData.Id + if XDataCenter.MarketingActivityManager.IsDoPicCompositionLike(id) then + XUiManager.TipText("PicCompositionLikeHint") + return + end + + if self.PlayerRankData.UserId == XPlayer.Id then + XUiManager.TipText("PicCompositionLikeSelf") + return + end + + local itemCount = XDataCenter.ItemManager.GetCount(self.LikeItem) + if not XDataCenter.MarketingActivityManager.CheckItemEnough(itemCount) then + XUiManager.TipText("PicCompositionNotEnough") + return + end + + XDataCenter.MarketingActivityManager.GivePraise(id, function () + self.PlayerRankData.Hot = + self.PlayerRankData.Hot + 1 + self:UpdatePhone() + end) +end + +function XUiPicChatRank:ErrorExit() + XUiManager.TipText("PicCompositionNetError") + XLuaUiManager.RunMain() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPicComposition/XUiPicComposition.lua b/Resources/Scripts/XUi/XUiPicComposition/XUiPicComposition.lua new file mode 100644 index 00000000..81f3c2b8 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPicComposition/XUiPicComposition.lua @@ -0,0 +1,823 @@ +local XUiPicComposition = XLuaUiManager.Register(XLuaUi, "UiPicComposition") +local DialogueMax = 4 +local FirstIndex = 1 +local TimeFormat = "MM/dd" +local tableInsert = table.insert +local stringGsub = string.gsub +local CSTextManagerGetText = CS.XTextManager.GetText +local PhoneState = { + Other = 1, + My = 2, + Edit = 3 + } + +------------草稿到期后需要删除-------------- +function XUiPicComposition:OnStart() + self:AddListener() + self:InitData() + self:InitPhonePanel() + self:InitPicComposition() + self:SetButtonCallBack() + self:ChangePhoneState() + self:InitNormalPhone() + self:InitEditPhone() + self:AddRedPointEvent() + self:UpdateActivityState() + self.InTimeSchedule = XScheduleManager.ScheduleForever(function() + if not XDataCenter.MarketingActivityManager.CheckIsIntime() then + XUiManager.TipText("PicCompositionTimeQver") + XLuaUiManager.RunMain() + return + end + self:UpdateActivityState() + end, 1000) +end + +function XUiPicComposition:OnEnable() + +end + +function XUiPicComposition:OnDestroy() + if self.InTimeSchedule then + XScheduleManager.UnSchedule(self.InTimeSchedule) + self.InTimeSchedule = nil + end + XEventManager.RemoveEventListener(XEventId.EVENT_FINISH_TASK, self.OnTaskChangeSync, self) + XEventManager.RemoveEventListener(XEventId.EVENT_TASK_FINISH_FAIL, self.OnTaskChangeSync, self) + XEventManager.RemoveEventListener(XEventId.EVENT_PICCOMPOSITION_GET_RANKDATA, self.OpenChatRank, self) + XEventManager.RemoveEventListener(XEventId.EVENT_PICCOMPOSITION_GET_OTHERDATA, self.SetOtherComposition, self) +end + +function XUiPicComposition:InitData() + self.OtherDialogueDataAllList = {}--储存其他玩家的过审作文 + self.MyDialogueDataAllList = {}--储存自己的所有 + + self.EditDialogueDataList = {}--储存编辑中的一篇作文 + self.EditOldDialogueDataList = {} + + self.NormalDialogueList = {} + self.EditDialogueList = {} + + self.Normal = {} + self.Edit = {} + + self.MyDialogueDataAllList = XDataCenter.MarketingActivityManager.GetMyCompositionDataList() + local picCompositionCfg = XMarketingActivityConfigs.GetPicCompositionActivityInfoConfigs() + + self.CurActivityId = XDataCenter.MarketingActivityManager.GetNowActivityId() + + self.LikeItem = self.CurActivityId and picCompositionCfg[self.CurActivityId] and + picCompositionCfg[self.CurActivityId].PraiseItemId or nil + + self.TaskItem = self.CurActivityId and picCompositionCfg[self.CurActivityId] and + picCompositionCfg[self.CurActivityId].ScheduleItemId or nil + + + self.CurPhoneState = PhoneState.Other + + self.HeadPortraitSelect = XUiHeadPortraitSelect.New(self,self.HeadPotrait) + self.PicCompositionTask = XUiPicCompositionTask.New(self,self.PanelTask) + + self.AssetActivityPanel = XUiPanelActivityAsset.New(self.PanelSpecialTool, true) + +end + +function XUiPicComposition:AddRedPointEvent() + XRedPointManager.AddRedPointEvent(self.IconTaskBtn, self.CheckTaskRedDot, self, + { XRedPointConditions.Types.CONDITION_PIC_COMPOSITION_TASK_FINISHED }) +end + +function XUiPicComposition:AddListener() + XEventManager.AddEventListener(XEventId.EVENT_FINISH_TASK, self.OnTaskChangeSync, self) + XEventManager.AddEventListener(XEventId.EVENT_TASK_FINISH_FAIL, self.OnTaskChangeSync, self) + XEventManager.AddEventListener(XEventId.EVENT_PICCOMPOSITION_GET_RANKDATA, self.OpenChatRank, self) + XEventManager.AddEventListener(XEventId.EVENT_PICCOMPOSITION_GET_OTHERDATA, self.SetOtherComposition, self) +end + +function XUiPicComposition:OnTaskChangeSync() + self.PicCompositionTask:Refresh() +end + + +function XUiPicComposition:InitPicComposition() + local PicCompositionInfo = XDataCenter.MarketingActivityManager.GetPicCompositionInfo() + local beginTime = XDataCenter.MarketingActivityManager.GetPicCompositionTime(XMarketingActivityConfigs.TimeDataType.BeginTime) + local endTime = XDataCenter.MarketingActivityManager.GetPicCompositionTime(XMarketingActivityConfigs.TimeDataType.EndTime) + + if PicCompositionInfo then + if PicCompositionInfo.Img then + self.PicRawImage:SetRawImage(PicCompositionInfo.Img) + self.PicRawImageSmall:SetRawImage(PicCompositionInfo.Img) + end + self.TitleText.text = PicCompositionInfo.Name + end + + local beginTimeStr = XTime.TimestampToGameDateTimeString(beginTime, TimeFormat) + local endTimeStr = XTime.TimestampToGameDateTimeString(endTime, TimeFormat) + self.ActTime.text = CSTextManagerGetText("PicCompositionTotalTime", beginTimeStr, endTimeStr) + + if XDataCenter.MarketingActivityManager.IsCanAutoOpenGuide() then + self:OnBtnHelpClick() + end +end + +function XUiPicComposition:InitPhonePanel() + self:InitPhoneObj(self.Normal,self.NormalPhone) + self:InitPhoneObj(self.Edit,self.EditPhone) +end + +function XUiPicComposition:InitPhoneObj(tmp,obj) + tmp.Transform = obj.transform + tmp.GameObject = obj.gameObject + XTool.InitUiObject(tmp) +end + +function XUiPicComposition:ChangePhoneState() + self.Normal.GameObject:SetActiveEx( + self.CurPhoneState == PhoneState.Other or + self.CurPhoneState == PhoneState.My) + + self.OtherBtnGroup.gameObject:SetActiveEx(self.CurPhoneState == PhoneState.Other) + self.Normal.PanelOther.gameObject:SetActiveEx(self.CurPhoneState == PhoneState.Other) + + self.MyBtnGroup.gameObject:SetActiveEx(self.CurPhoneState == PhoneState.My) + self.Normal.PanelMy.gameObject:SetActiveEx(self.CurPhoneState == PhoneState.My) + + self.Edit.GameObject:SetActiveEx(self.CurPhoneState == PhoneState.Edit) + + if self.CurPhoneState == PhoneState.Edit then + self:PlayAnimation("EditPhoneEnable") + else + self:PlayAnimation("NormalPhoneEnable") + end +end + +function XUiPicComposition:SetButtonCallBack() + self.BtnBack.CallBack = function() + self:OnBtnBackRead() + end + self.BtnMainUi.CallBack = function() + self:OnBtnMainUiClick() + end + self.BtnNew.CallBack = function() + self:OnBtnNewClick() + end + self.BtnHotRank.CallBack = function() + self:OnBtnHotRankClick() + end + self.BtnMyUpLoad.CallBack = function() + self:OnBtnMyUpLoadClick() + end + self.IconTaskBtn.CallBack = function() + self:OnIconTaskBtnClick() + end + self.IconMagnifierBtn.CallBack = function() + self:OnIconMagnifierBtnClick() + end + self.BtnImageClose.CallBack = function() + self:OnBtnImageCloseClick() + end + self.BtnHelp.CallBack = function() + self:OnBtnHelpClick() + end + self:BindHelpBtnOnly(self.BtnHelp) +end + + +function XUiPicComposition:OnBtnBackClick() + if self.CurPhoneState == PhoneState.Other then + self:Close() + return + elseif self.CurPhoneState == PhoneState.My then + self.CurPhoneState = PhoneState.Other + self:UpdateOtherDialogueList() + elseif self.CurPhoneState == PhoneState.Edit then + self.CurPhoneState = PhoneState.My + end + self:ChangePhoneState() +end + +function XUiPicComposition:OnBtnBackRead() + if self.CurPhoneState == PhoneState.Edit then + self:CheckSave(function () + self:OnBtnBackClick() + end) + else + self:OnBtnBackClick() + end +end + +function XUiPicComposition:OnBtnMainUiClick() + if self.CurPhoneState == PhoneState.Edit then + self:CheckSave(function () + XLuaUiManager.RunMain() + end) + else + XLuaUiManager.RunMain() + end +end + +function XUiPicComposition:CheckSave(cb) + local IsTextChange = false + local IsHeadChange = false + local IsChange = true + + for index,data in pairs(self.EditOldDialogueDataList.Dialogue or {}) do + if #self.EditOldDialogueDataList.Dialogue == #self.EditDialogueDataList.Dialogue then + IsHeadChange = IsHeadChange or + self.EditDialogueDataList.Dialogue[index].CharacterId ~= data.CharacterId + + IsTextChange = IsTextChange or + self.EditDialogueDataList.Dialogue[index].Content ~= data.Content + + IsChange = IsHeadChange or IsTextChange + end + if IsChange then + break + end + end + + if #self.EditDialogueDataList.Dialogue > 0 and IsChange then + local cancelCb = function () + if cb then cb() end + end + local confirmCb = function () + self:OnBtnSaveClick( + function () + if cb then cb() end + end) + end + self:TipDialog(cancelCb,confirmCb,"PicCompositionNotSave") + else + if cb then cb() end + end +end + +function XUiPicComposition:OnBtnNewClick() + + local upLoadTimeType = XDataCenter.MarketingActivityManager.CheckIsCanUpLoad() + if upLoadTimeType == XMarketingActivityConfigs.TimeType.After then + XUiManager.TipText("PicCompositionUpLoadTimeAfter") + return + end + + local upLoadMaxCount = XDataCenter.MarketingActivityManager.GetUpLoadMaxCount() + if upLoadMaxCount == 0 then + XUiManager.TipText("PicCompositionMaxUpLoad") + return + end + + + self.CurPhoneState = PhoneState.Edit + self.EditDialogueDataList = {} + self.EditOldDialogueDataList = {} + self.EditDialogueDataList.Dialogue = {} + self.CurMemoIndex = nil + self:UpdateEditDialogueList() + self:ChangePhoneState() + self:OpenRuleDialog() +end + +function XUiPicComposition:OpenRuleDialog() + local ruleText = stringGsub(CSTextManagerGetText("PicCompositionRuleText"), "\\n", "\n") + local ruleTitle = CSTextManagerGetText("PicCompositionRuleTitle") + XUiManager.UiFubenDialogTip(ruleTitle, ruleText) +end + +function XUiPicComposition:OnBtnHotRankClick() + XDataCenter.MarketingActivityManager.InitRankCompositionDataList() +end + +function XUiPicComposition:OpenChatRank(IsOpen) + if IsOpen then + XLuaUiManager.Open("UiPicChatRank") + else + self:ErrorExit() + end +end + +function XUiPicComposition:OnBtnMyUpLoadClick() + self.CurPhoneState = PhoneState.My + self:UpdateMyDialogueList() + self:ChangePhoneState() +end + +function XUiPicComposition:OnIconTaskBtnClick() + self.PicCompositionTask:ShowPanel() + self.PicCompositionTask:UpdateActiveness() + self:PlayAnimation("TaskEnable") +end + +function XUiPicComposition:OnIconMagnifierBtnClick() + self.PicPlus.gameObject:SetActiveEx(true) + self:PlayAnimation("PicPlusEnable") +end + +function XUiPicComposition:OnBtnImageCloseClick() + self.PicPlus.gameObject:SetActiveEx(false) +end + +function XUiPicComposition:OnBtnHelpClick() + local PicCompositionInfo = XDataCenter.MarketingActivityManager.GetPicCompositionInfo() + local helpId = PicCompositionInfo.HelpId + local helpCourseTemplate = XHelpCourseConfig.GetHelpCourseTemplateById(helpId) + XUiManager.ShowHelpTip(helpCourseTemplate.Function) +end + + +function XUiPicComposition:OnBtnEditClick() + local upLoadTimeType = XDataCenter.MarketingActivityManager.CheckIsCanUpLoad() + if upLoadTimeType == XMarketingActivityConfigs.TimeType.After then + XUiManager.TipText("PicCompositionUpLoadTimeAfter") + return + end + + local upLoadMaxCount = XDataCenter.MarketingActivityManager.GetUpLoadMaxCount() + if upLoadMaxCount == 0 then + XUiManager.TipText("PicCompositionMaxUpLoad") + return + end + + self.CurPhoneState = PhoneState.Edit + self.EditDialogueDataList = XTool.Clone(self.MyDialogueDataAllList[self.CurMyDialogueIndex]) + self.EditOldDialogueDataList = XTool.Clone(self.MyDialogueDataAllList[self.CurMyDialogueIndex]) + self.CurMemoIndex = nil + self:UpdateEditDialogueList() + self:ChangePhoneState() +end + +function XUiPicComposition:OnBtnLikeClick() + local id = self.OtherDialogueDataAllList[self.CurOtherDialogueIndex].Id + if XDataCenter.MarketingActivityManager.IsDoPicCompositionLike(id) then + XUiManager.TipText("PicCompositionLikeHint") + return + end + if self.OtherDialogueDataAllList[self.CurOtherDialogueIndex].UserId == XPlayer.Id then + XUiManager.TipText("PicCompositionLikeSelf") + return + end + + local itemCount = XDataCenter.ItemManager.GetCount(self.LikeItem) + if not XDataCenter.MarketingActivityManager.CheckItemEnough(itemCount) then + XUiManager.TipText("PicCompositionNotEnough") + return + end + + XDataCenter.MarketingActivityManager.GivePraise(id, function () + self.OtherDialogueDataAllList[self.CurOtherDialogueIndex].Hot = + self.OtherDialogueDataAllList[self.CurOtherDialogueIndex].Hot + 1 + self:UpdateOtherDialogueList() + end) +end + +function XUiPicComposition:OnBtnLeftClick() + if self.CurPhoneState == PhoneState.Other then + self.CurOtherDialogueIndex = self.CurOtherDialogueIndex - 1 + if self.CurOtherDialogueIndex < 1 then + self:GetOtherComposition(XMarketingActivityConfigs.GetType.Before) + else + self:UpdateOtherDialogueList() + end + elseif self.CurPhoneState == PhoneState.My then + self.CurMyDialogueIndex = self.CurMyDialogueIndex > 1 and + (self.CurMyDialogueIndex - 1) or (self.CurMyDialogueIndex) + self:UpdateMyDialogueList() + end + self:PlayAnimation("NormalPhoneEnable") +end + +function XUiPicComposition:OnBtnRightClick() + if self.CurPhoneState == PhoneState.Other then + self.CurOtherDialogueIndex = self.CurOtherDialogueIndex + 1 + if self.CurOtherDialogueIndex > #self.OtherDialogueDataAllList then + self:GetOtherComposition(XMarketingActivityConfigs.GetType.After) + else + self:UpdateOtherDialogueList() + end + elseif self.CurPhoneState == PhoneState.My then + self.CurMyDialogueIndex = self.CurMyDialogueIndex < #self.MyDialogueDataAllList and + (self.CurMyDialogueIndex + 1) or self.CurMyDialogueIndex + self:UpdateMyDialogueList() + end + self:PlayAnimation("NormalPhoneEnable") +end + +function XUiPicComposition:HideHeadPortraitSelect() + self.HeadPotraitSelect.GameObject:SetActiveEx(false) +end + +function XUiPicComposition:UpdateActivityState() + local upLoadTimeType = XDataCenter.MarketingActivityManager.CheckIsCanUpLoad() + local upLoadMaxCount = XDataCenter.MarketingActivityManager.GetUpLoadMaxCount() + local upLoadDayCount = XDataCenter.MarketingActivityManager.GetUpLoadDayCount() + local upLoadBeginTime = XDataCenter.MarketingActivityManager.GetPicCompositionTime(XMarketingActivityConfigs.TimeDataType.UploadBeginTime) + local upLoadEndTime = XDataCenter.MarketingActivityManager.GetPicCompositionTime(XMarketingActivityConfigs.TimeDataType.UploadEndTime) + local endTime = XDataCenter.MarketingActivityManager.GetPicCompositionTime(XMarketingActivityConfigs.TimeDataType.EndTime) + local nowTime = XTime.GetServerNowTimestamp() + + local btnNewStatus = (upLoadTimeType == XMarketingActivityConfigs.TimeType.After or upLoadMaxCount == 0) and + CS.UiButtonState.Disable or CS.UiButtonState.Normal + + local btnUpLoadStatus = (upLoadTimeType ~= XMarketingActivityConfigs.TimeType.In or upLoadDayCount == 0 or upLoadMaxCount == 0) and + CS.UiButtonState.Disable or CS.UiButtonState.Normal + + + self.Edit.UploadNum.gameObject:SetActiveEx(upLoadTimeType == XMarketingActivityConfigs.TimeType.In) + + self.IconTaskBtn.gameObject:SetActiveEx(upLoadTimeType ~= XMarketingActivityConfigs.TimeType.Before) + + + self.BtnNew:SetButtonState(btnNewStatus) + self.Edit.BtnUpLoad:SetButtonState(btnUpLoadStatus) + + if upLoadTimeType == XMarketingActivityConfigs.TimeType.Before then + local timeStr = upLoadBeginTime - nowTime + timeStr = timeStr > 0 and timeStr or 0 + self.TimeCount.text = CSTextManagerGetText("PicCompositionUpLoadOpenTimeCount", + XUiHelper.GetTime(timeStr, XUiHelper.TimeFormatType.ACTIVITY)) + elseif upLoadTimeType == XMarketingActivityConfigs.TimeType.In then + local timeStr = upLoadEndTime - nowTime + timeStr = timeStr > 0 and timeStr or 0 + self.TimeCount.text = CSTextManagerGetText("PicCompositionUpLoadOverTimeCount", + XUiHelper.GetTime(timeStr, XUiHelper.TimeFormatType.ACTIVITY)) + elseif upLoadTimeType == XMarketingActivityConfigs.TimeType.After then + local timeStr = endTime - nowTime + timeStr = timeStr > 0 and timeStr or 0 + self.TimeCount.text = CSTextManagerGetText("PicCompositionOverTimeCount", + XUiHelper.GetTime(timeStr, XUiHelper.TimeFormatType.ACTIVITY)) + end + +end + +function XUiPicComposition:CheckTaskRedDot(count) + self.IconTaskBtn:ShowReddot(count >= 0) +end + +function XUiPicComposition:ErrorExit() + XUiManager.TipText("PicCompositionNetError") + XLuaUiManager.RunMain() +end +-----------------------------NormalPhone------------------------------- +function XUiPicComposition:InitNormalPhone() + + self:InitBtnGroup() + self:SetNormalPhoneButtonCallBack() + self.CurMyDialogueIndex = 1 + self.CurOtherDialogueIndex = 1 + self.Normal.DialogueObj = { + self.Normal.Dialogue1, + self.Normal.Dialogue2, + self.Normal.Dialogue3, + self.Normal.Dialogue4 + } + + for index = 1,DialogueMax do + self.NormalDialogueList[index] = XUiGridNormalDialogue.New(self.Normal.DialogueObj[index],self) + end + self.Normal.BtnGroup:SelectIndex(self.Normal.CurSortType) +end + +function XUiPicComposition:InitBtnGroup() + self.Normal.CurSortType = XMarketingActivityConfigs.SortType.Hot + self.Normal.BtnList = { + [1] = self.Normal.BtnHot, + [2] = self.Normal.BtnTime} + + self.Normal.BtnGroup:Init(self.Normal.BtnList, function(index) self:SelectSortType(index) end) + +end + +function XUiPicComposition:UpdateOtherDialogueList() + if #self.OtherDialogueDataAllList == 0 then + local upLoadTimeType = XDataCenter.MarketingActivityManager.CheckIsCanUpLoad() + self:SetOtherDialogueStateShow(false) + if upLoadTimeType == XMarketingActivityConfigs.TimeType.Before then + local bTime,eTime = XDataCenter.MarketingActivityManager.GetUpLoadTime(false) + self.Normal.TipsText.text = CSTextManagerGetText("PicCompositionUpLoadTimeText") + self.Normal.TimeText.text = string.format("%s--%s",bTime,eTime) + self.Normal.TimeText.gameObject:SetActiveEx(true) + else + self.Normal.TipsText.text = CSTextManagerGetText("NotHaveOtherComposition") + self.Normal.TimeText.gameObject:SetActiveEx(false) + end + else + if self.OtherDialogueDataAllList[self.CurOtherDialogueIndex] then + local hot = self.OtherDialogueDataAllList[self.CurOtherDialogueIndex].Hot or 0 + local name = self.OtherDialogueDataAllList[self.CurOtherDialogueIndex].UserName + local id = self.OtherDialogueDataAllList[self.CurOtherDialogueIndex].Id + local IsLike = XDataCenter.MarketingActivityManager.IsDoPicCompositionLike(id) + local dialogueDataList = self.OtherDialogueDataAllList[self.CurOtherDialogueIndex].Dialogue + local btnStatus = IsLike and CS.UiButtonState.Select or CS.UiButtonState.Normal + + self.Normal.OtherHotNum.text = XMarketingActivityConfigs.GetCountUnitChange(hot) + self.Normal.PlayerName.text = CSTextManagerGetText("PicCompositionPlayerName",name) + + self:SetOtherDialogueStateShow(true) + self.Normal.BtnLike:SetButtonState(btnStatus) + + for index = 1,DialogueMax do + self.NormalDialogueList[index]:Update(dialogueDataList[index]) + end + end + end + + local item = XDataCenter.ItemManager.GetItem(self.LikeItem) + if item then + self.AssetActivityPanel:Refresh({self.LikeItem}) + else + self.AssetActivityPanel:Refresh(nil) + end + +end + +function XUiPicComposition:SetOtherDialogueStateShow(IsShow) + self.Normal.Tips.gameObject:SetActiveEx(not IsShow) + + self.Normal.PanelChatView.gameObject:SetActiveEx(IsShow) + + self.Normal.OtherLike.gameObject:SetActiveEx(IsShow) + + self.Normal.PlayerName.gameObject:SetActiveEx(IsShow) + + local curAfterCount = XDataCenter.MarketingActivityManager.GetPicCompositionAfterStartIndex() + local allCount = XDataCenter.MarketingActivityManager.GetPicCompositionAllCount() + local maxCount = XDataCenter.MarketingActivityManager.GetPicCompositionGetMaxCount() + local IsRightBtnNotShow + if maxCount == #self.OtherDialogueDataAllList then + IsRightBtnNotShow = curAfterCount == allCount and self.CurOtherDialogueIndex == #self.OtherDialogueDataAllList + else + IsRightBtnNotShow = curAfterCount > allCount and self.CurOtherDialogueIndex == #self.OtherDialogueDataAllList + end + IsRightBtnNotShow = IsRightBtnNotShow or #self.OtherDialogueDataAllList == 0 + self.Normal.BtnRight.gameObject:SetActiveEx(not IsRightBtnNotShow) + + local curBeforCount = XDataCenter.MarketingActivityManager.GetPicCompositionBeforStartIndex() + local IsLeftBtnNotShow = #self.OtherDialogueDataAllList == 0 or curBeforCount == 0 and self.CurOtherDialogueIndex == 1 + self.Normal.BtnLeft.gameObject:SetActiveEx(not IsLeftBtnNotShow) +end + +function XUiPicComposition:UpdateMyDialogueList() + if #self.MyDialogueDataAllList == 0 then + self:SetMyDialogueStateShow(false) + self.Normal.TimeText.gameObject:SetActiveEx(false) + self.Normal.TipsText.text = CSTextManagerGetText("NotHaveMyComposition") + else + if self.MyDialogueDataAllList[self.CurMyDialogueIndex] then + local hot = self.MyDialogueDataAllList[self.CurMyDialogueIndex].Hot or 0 + self.Normal.MyHotNum.text = XMarketingActivityConfigs.GetCountUnitChange(hot) + local dialogueDataList = self.MyDialogueDataAllList[self.CurMyDialogueIndex].Dialogue + self:SetMyDialogueStateShow(true) + for index = 1,DialogueMax do + self.NormalDialogueList[index]:Update(dialogueDataList[index]) + end + end + end +end + +function XUiPicComposition:SetMyDialogueStateShow(IsShow) + self.Normal.FailedPass.gameObject:SetActiveEx(IsShow and + self.MyDialogueDataAllList[self.CurMyDialogueIndex].Type == + XMarketingActivityConfigs.CompositionType.UnExamine) + + self.Normal.Examine.gameObject:SetActiveEx(IsShow and + self.MyDialogueDataAllList[self.CurMyDialogueIndex].Type == + XMarketingActivityConfigs.CompositionType.Examining) + + self.Normal.UpLoad.gameObject:SetActiveEx(IsShow and + self.MyDialogueDataAllList[self.CurMyDialogueIndex].Type == + XMarketingActivityConfigs.CompositionType.Memo) + + self.Normal.Pass.gameObject:SetActiveEx(IsShow and + self.MyDialogueDataAllList[self.CurMyDialogueIndex].Type == + XMarketingActivityConfigs.CompositionType.Examined) + + self.Normal.MyLike.gameObject:SetActiveEx(IsShow and + self.MyDialogueDataAllList[self.CurMyDialogueIndex].Type == + XMarketingActivityConfigs.CompositionType.Examined) + + self.Normal.BtnEdit.gameObject:SetActiveEx(IsShow and + self.MyDialogueDataAllList[self.CurMyDialogueIndex].Type == + XMarketingActivityConfigs.CompositionType.Memo) + + self.Normal.PanelChatView.gameObject:SetActiveEx(IsShow) + + self.Normal.Tips.gameObject:SetActiveEx(not IsShow) + + local IsLeftBtnNotShow = #self.MyDialogueDataAllList == 0 or self.CurMyDialogueIndex == 1 + self.Normal.BtnLeft.gameObject:SetActiveEx(not IsLeftBtnNotShow) + + local IsRightBtnNotShow = #self.MyDialogueDataAllList == 0 or self.CurMyDialogueIndex == #self.MyDialogueDataAllList + self.Normal.BtnRight.gameObject:SetActiveEx(not IsRightBtnNotShow) + + self.Normal.FailedPassText.text = CSTextManagerGetText("PicCompositionFailedPass") + self.Normal.ExamineText.text = CSTextManagerGetText("PicCompositionExamine") + self.Normal.UpLoadText.text = CSTextManagerGetText("PicCompositionNotUpLoad") + self.Normal.PassText.text = CSTextManagerGetText("PicCompositionPass") +end + +function XUiPicComposition:SelectSortType(index) + self.CurSortType = index + XDataCenter.MarketingActivityManager.ResetPicCompositionStartIndex() + self:GetOtherComposition(XMarketingActivityConfigs.GetType.After) + self:PlayAnimation("NormalPhoneEnable") +end + +function XUiPicComposition:GetOtherComposition(type) + self.Normal.GameObject:SetActiveEx(false) + XDataCenter.MarketingActivityManager.InitOtherCompositionDataList(self.CurSortType,type) +end + +function XUiPicComposition:SetOtherComposition(IsGet,type) + if IsGet then + self.OtherDialogueDataAllList = XDataCenter.MarketingActivityManager.GetOtherCompositionDataList(self.CurSortType) + self.CurOtherDialogueIndex = type == XMarketingActivityConfigs.GetType.After and + 1 or #self.OtherDialogueDataAllList + self:UpdateOtherDialogueList() + else + self:ErrorExit() + end + self.Normal.GameObject:SetActiveEx(true) +end + +function XUiPicComposition:SetNormalPhoneButtonCallBack() + self.Normal.BtnLeft.CallBack = function() + self:OnBtnLeftClick() + end + self.Normal.BtnRight.CallBack = function() + self:OnBtnRightClick() + end + self.Normal.BtnEdit.CallBack = function() + self:OnBtnEditClick() + end + self.Normal.BtnLike.CallBack = function() + self:OnBtnLikeClick() + end + --Zhang +end +-----------------------------NormalPhone------------------------------- +------------------------------EditPhone-------------------------------- +function XUiPicComposition:InitEditPhone() + self:SetEditPhoneButtonCallBack() + self.Edit.DialogueObj = { + self.Edit.Dialogue1, + self.Edit.Dialogue2, + self.Edit.Dialogue3, + self.Edit.Dialogue4 + } + + for index = 1,DialogueMax do + self.EditDialogueList[index] = XUiGridEditDialogue.New(self.Edit.DialogueObj[index],self) + end +end + +function XUiPicComposition:SetEditPhoneButtonCallBack() + self.Edit.BtnSave.CallBack = function() + self:OnBtnSaveClick() + end + + self.Edit.BtnUpLoad.CallBack = function() + self:OnBtnUpLoadClick() + end +end + +function XUiPicComposition:UpdateEditDialogueList() + for index = 1,DialogueMax do + local IsCanEdit = false + if index == FirstIndex then + IsCanEdit = true + else + if self.EditDialogueDataList.Dialogue[index - 1] then + IsCanEdit = true + end + end + self.EditDialogueList[index]:Update(index,IsCanEdit) + end + + local upLoadMaxCount = XDataCenter.MarketingActivityManager.GetUpLoadMaxCount() + self.Edit.UploadNum.text = CSTextManagerGetText("PicCompositionUpLoadCount",upLoadMaxCount) +end + +function XUiPicComposition:CheckEditDialogueClear() + for i = #self.EditDialogueDataList.Dialogue, 1, -1 do + if self.EditDialogueDataList.Dialogue[i].IsClear then + table.remove(self.EditDialogueDataList.Dialogue, i) + end + end + self:UpdateEditDialogueList() +end + +function XUiPicComposition:OnBtnSaveClick(cb) + local dialogueList = {} + local IsCanSave = true + local IsNotEmpty = false + for _,dialogueData in pairs(self.EditDialogueDataList.Dialogue or {}) do + local tmpData = {} + if dialogueData.CharacterId then + tmpData.CharacterId = dialogueData.CharacterId + end + if dialogueData.Content and #dialogueData.Content > 0 and (not string.match(dialogueData.Content, "^[%s]+$"))then + tmpData.Content = dialogueData.Content + IsCanSave = IsCanSave and true + else + IsCanSave = IsCanSave and false + end + IsNotEmpty = true + tableInsert(dialogueList,tmpData) + end + + if IsCanSave and IsNotEmpty then + XDataCenter.MarketingActivityManager.SaveMemoDialogue(self.EditDialogueDataList.Dialogue,self.EditDialogueDataList.MemoId,function () + self.MyDialogueDataAllList = XDataCenter.MarketingActivityManager.GetMyCompositionDataList() + self:UpdateMyDialogueList() + self:OnBtnBackClick() + if cb then cb() end + end) + else + if not IsNotEmpty then + XUiManager.TipText("PicCompositionAllEmpty") + else + XUiManager.TipText("PicCompositionHaveEmpty") + end + end + +end + +function XUiPicComposition:OnBtnUpLoadClick() + local dialogueList = {} + + local IsCanUpLoad = true + local IsNotEmpty = false + + local upLoadTimeType = XDataCenter.MarketingActivityManager.CheckIsCanUpLoad() + + if upLoadTimeType == XMarketingActivityConfigs.TimeType.Out then + XUiManager.TipText("PicCompositionTimeOut") + return + end + + if upLoadTimeType == XMarketingActivityConfigs.TimeType.Before then + XUiManager.TipText("PicCompositionUpLoadTimeBefor") + return + end + + if upLoadTimeType == XMarketingActivityConfigs.TimeType.After then + XUiManager.TipText("PicCompositionUpLoadTimeAfter") + return + end + + local upLoadMaxCount = XDataCenter.MarketingActivityManager.GetUpLoadMaxCount() + if upLoadMaxCount == 0 then + XUiManager.TipText("PicCompositionMaxUpLoad") + return + end + + local upLoadDayCount = XDataCenter.MarketingActivityManager.GetUpLoadDayCount() + if upLoadDayCount == 0 then + XUiManager.TipText("PicCompositionDayUpLoad") + return + end + + for _,dialogueData in pairs(self.EditDialogueDataList.Dialogue or {}) do + local tmpData = {} + if dialogueData.CharacterId then + tmpData.CharacterId = dialogueData.CharacterId + end + if dialogueData.Content and #dialogueData.Content > 0 and (not string.match(dialogueData.Content, "^[%s]+$"))then + tmpData.Content = dialogueData.Content + IsCanUpLoad = IsCanUpLoad and true + else + IsCanUpLoad = IsCanUpLoad and false + end + IsNotEmpty = true + tableInsert(dialogueList,tmpData) + end + + if IsCanUpLoad and IsNotEmpty then + self:TipDialog(nil,function () + XDataCenter.MarketingActivityManager.GiveUploadComment(dialogueList, function () + XDataCenter.MarketingActivityManager.DelectMemoDialogue(self.EditDialogueDataList.MemoId) + self.MyDialogueDataAllList = XDataCenter.MarketingActivityManager.GetMyCompositionDataList() + self:UpdateMyDialogueList() + self:OnBtnBackClick() + end) + end,"PicCompositionUpLoadRead") + else + if not IsNotEmpty then + XUiManager.TipText("PicCompositionAllEmpty") + else + XUiManager.TipText("PicCompositionHaveEmpty") + end + end +end + +function XUiPicComposition:TipDialog(cancelCb, confirmCb,TextKey) + CsXUiManager.Instance:Open("UiDialog", CSTextManagerGetText("TipTitle"), CSTextManagerGetText(TextKey), + XUiManager.DialogType.Normal, cancelCb, confirmCb) +end +------------------------------EditPhone-------------------------------- + + + + + + diff --git a/Resources/Scripts/XUi/XUiPicComposition/XUiPicCompositionPanelActive.lua b/Resources/Scripts/XUi/XUiPicComposition/XUiPicCompositionPanelActive.lua new file mode 100644 index 00000000..f921e181 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPicComposition/XUiPicCompositionPanelActive.lua @@ -0,0 +1,54 @@ +XUiPicCompositionPanelActive = XClass(nil, "XUiPicCompositionPanelActive") +local CSTextManagerGetText = CS.XTextManager.GetText +function XUiPicCompositionPanelActive:Ctor(ui,rootUi,index,parent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.rootUi = rootUi + self.Parent = parent + self.index = index + XTool.InitUiObject(self) + self.BtnActive.CallBack = function() self:OnBtnActiveClick() end +end + +function XUiPicCompositionPanelActive:Refresh() + +end + +function XUiPicCompositionPanelActive:UpdateActiveness(dailyActiveness,dActiveness) + if dailyActiveness <= dActiveness then + self.rootUi:SetUiSprite(self.BtnActive.image, CS.XGame.ClientConfig:GetString("TaskDailyActiveReach"..self.index)) + self.PanelEffect.gameObject:SetActiveEx(not XDataCenter.MarketingActivityManager.IsGetedScheduleReward(self.index)) + self.ImgRe.gameObject:SetActiveEx(XDataCenter.MarketingActivityManager.IsGetedScheduleReward(self.index)) + else + self.rootUi:SetUiSprite(self.BtnActive.image, CS.XGame.ClientConfig:GetString("TaskDailyActiveNotReach"..self.index)) + self.PanelEffect.gameObject:SetActiveEx(false) + self.ImgRe.gameObject:SetActiveEx(false) + end + + self.TxtValue.text = dailyActiveness +end + +function XUiPicCompositionPanelActive:OnBtnActiveClick() + self:TouchDailyRewardBtn(self.index) +end + +function XUiPicCompositionPanelActive:TouchDailyRewardBtn(index) + local curActiveness = XDataCenter.ItemManager.GetCount(self.Parent.Parent.TaskItem) + local ActivenesDatas = XMarketingActivityConfigs.GetPicCompositionScheduleRewardInfoConfigs() + -- local ActivenesTotal = XMarketingActivityConfigs.GetPicCompositionScheduleRewardTotal() + local data = XRewardManager.GetRewardList(ActivenesDatas[index].RewardId) + + if curActiveness >= ActivenesDatas[index].Schedule then + if XDataCenter.MarketingActivityManager.IsGetedScheduleReward(ActivenesDatas[index].Id) then + return + end + XDataCenter.MarketingActivityManager.GetCommentScheduleReward(ActivenesDatas[index].Id,function () + self.Parent:UpdateActiveness() + end) + else + XUiManager.OpenUiTipReward(data, CSTextManagerGetText("DailyActiveRewardTitle")) + end + +end + +return XUiPicCompositionPanelActive \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPicComposition/XUiPicCompositionTask.lua b/Resources/Scripts/XUi/XUiPicComposition/XUiPicCompositionTask.lua new file mode 100644 index 00000000..67fcc884 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPicComposition/XUiPicCompositionTask.lua @@ -0,0 +1,120 @@ +XUiPicCompositionTask = XClass(nil, "XUiPicCompositionTask") + +local ProTime = 2 + +function XUiPicCompositionTask:Ctor(parent,ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Parent = parent + + XTool.InitUiObject(self) + + self:InitPanelActiveGrid() + self.ItemObjList = {} + self.GameObject:SetActiveEx(false) + -- 自适应调整 + self.OriginPosition = self.PanelActiveGrids[1].Transform.localPosition + self.ActiveProgressRect = self.ImgDaylyActiveProgressTransform + + self:SetButtonCallBack() + self:InitDynamicTable() + + XDataCenter.ItemManager.AddCountUpdateListener(self.Parent.TaskItem, function() + self:UpdateActiveness() + end, self.TxtDailyActive) +end + +function XUiPicCompositionTask:SetButtonCallBack() + self.BtnClose.CallBack = function() + self:HidePanel() + self.Parent.AssetActivityPanel:Refresh({self.Parent.LikeItem}) + end +end + +function XUiPicCompositionTask:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelTaskDailyList.gameObject) + self.DynamicTable:SetProxy(XDynamicGridTask) + self.DynamicTable:SetDelegate(self) +end + +function XUiPicCompositionTask:SetupDynamicTable() + self.DailyTasks = XDataCenter.MarketingActivityManager.GetPicCompositionTaskDatas() + self.PanelNoneDailyTask.gameObject:SetActiveEx(self.DailyTasks and #self.DailyTasks<=0) + self.DynamicTable:SetDataSource(self.DailyTasks) + self.DynamicTable:ReloadDataASync(1) +end + +function XUiPicCompositionTask:Refresh() + self:SetupDynamicTable() + self:UpdateActiveness() +end + +--动态列表事件 +function XUiPicCompositionTask:OnDynamicTableEvent(event,index,grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.DailyTasks[index] + if data == nil then return end + grid.RootUi = self.Parent + grid:ResetData(data) + self.GridCount = self.GridCount + 1 + -- elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_RELOAD_COMPLETED then + end +end + +function XUiPicCompositionTask:InitPanelActiveGrid() + self.PanelActiveGrids = {} + self.PanelActiveGridRects = {} + local ActivenesTotal = XMarketingActivityConfigs.GetPicCompositionScheduleRewardTotal() + for i = 1,ActivenesTotal do + local grid = self.PanelActiveGrids[i] + if not grid then + if i == 1 then + grid = XUiPicCompositionPanelActive.New(self.PanelActive, self.Parent, i, self) + else + local activeGO = CS.UnityEngine.Object.Instantiate(self.PanelActive) + activeGO.transform:SetParent(self.PanelContent, false) + grid = XUiPicCompositionPanelActive.New(activeGO, self.Parent, i, self) + end + self.PanelActiveGrids[i] = grid + self.PanelActiveGridRects[i] = grid.Transform:GetComponent("RectTransform") + end + end +end + +function XUiPicCompositionTask:UpdateActiveness() + local curActiveness = XDataCenter.ItemManager.GetCount(self.Parent.TaskItem) + local ActivenesDatas = XMarketingActivityConfigs.GetPicCompositionScheduleRewardInfoConfigs() + local ActivenesTotal = XMarketingActivityConfigs.GetPicCompositionScheduleRewardTotal() + + if ActivenesTotal > 0 then + local fillAmount = curActiveness / ActivenesDatas[ActivenesTotal].Schedule + if self.Curfillamount ~= fillAmount then + self.ImgDaylyActiveProgress:DOFillAmount(fillAmount,ProTime) + self.Curfillamount = fillAmount + end + end + + self.TxtDailyActive.text = curActiveness < ActivenesDatas[ActivenesTotal].Schedule and curActiveness or ActivenesDatas[ActivenesTotal].Schedule + self.TextMax.text = string.format("/%d",ActivenesDatas[ActivenesTotal].Schedule) + for i = 1, ActivenesTotal do + self.PanelActiveGrids[i]:UpdateActiveness(ActivenesDatas[i].Schedule,curActiveness) + end + + -- 自适应 + local activeProgressRectSize = self.ActiveProgressRect.rect.size + for i = 1, #self.PanelActiveGrids do + local valOffset = ActivenesDatas[i].Schedule / ActivenesDatas[ActivenesTotal].Schedule + local adjustPosition = CS.UnityEngine.Vector3(activeProgressRectSize.x * valOffset, self.OriginPosition.y, self.OriginPosition.z) + self.PanelActiveGridRects[i].anchoredPosition3D = adjustPosition + end +end + +function XUiPicCompositionTask:ShowPanel() + self.GridCount = 0 + self.GameObject:SetActiveEx(true) + self:SetupDynamicTable() +end + +function XUiPicCompositionTask:HidePanel() + self.GameObject:SetActiveEx(false) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPlayer/XUiGridHeadFrame.lua b/Resources/Scripts/XUi/XUiPlayer/XUiGridHeadFrame.lua new file mode 100644 index 00000000..596ee0ef --- /dev/null +++ b/Resources/Scripts/XUi/XUiPlayer/XUiGridHeadFrame.lua @@ -0,0 +1,96 @@ +local XUiGridHeadFrame = XClass(nil, "XUiGridHeadFrame") + +function XUiGridHeadFrame:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:AutoAddListener() +end + +function XUiGridHeadFrame:AutoAddListener() + self.BtnRole.CallBack = function() + self:OnBtnRoleClick() + end +end + +function XUiGridHeadFrame:OnBtnRoleClick() + local IsTrueHeadFrame = self.Base:SetHeadFrameImgRole(self.HeadFrameId) + self:SetSelectShow(self.Base) + if self.Base.OldFrameSelectGrig then + self.Base.OldFrameSelectGrig:SetSelectShow(self.Base) + end + self.Base.OldFrameSelectGrig = self + self:ShowRedPoint(false, true) + + self.Base:ShowHeadFramePanel(IsTrueHeadFrame) + self.Base:RefreshHeadFrameDynamicTable() +end + +function XUiGridHeadFrame:UpdateGrid(chapter, parent) + self.Base = parent + self.HeadFrameId = chapter.Id + if chapter.ImgSrc ~= nil then + self.UnLockImgHeadImg:SetRawImage(chapter.ImgSrc) + self.LockImgHeadImg:SetRawImage(chapter.ImgSrc) + self.HeadIcon = chapter.ImgSrc + end + + if chapter.Effect then + self.HeadIconEffect.gameObject:LoadPrefab(chapter.Effect) + self.HeadIconEffect.gameObject:SetActiveEx(true) + else + self.HeadIconEffect.gameObject:SetActiveEx(false) + end + + local isTimeLimit = chapter.LimitType ~= XHeadPortraitConfigs.HeadTimeLimitType.Forever + self.LockIconTime.gameObject:SetActiveEx(isTimeLimit) + self.SelIconTime.gameObject:SetActiveEx(isTimeLimit) + + self:SetSelectShow(parent) + self:ShowLock(XDataCenter.HeadPortraitManager.IsHeadPortraitValid(self.HeadFrameId)) +end + +function XUiGridHeadFrame:SetSelectShow(parent) + if parent.TempHeadFrameId == self.HeadFrameId then + self:ShowSelect(true) + else + self:ShowSelect(false) + end + if parent.CurrHeadFrameId == self.HeadFrameId then + self:ShowTxt(true) + if not self.Base.OldFrameSelectGrig then + self.Base.OldFrameSelectGrig = self + self:ShowRedPoint(false,true) + end + else + self:ShowTxt(false) + end +end + +function XUiGridHeadFrame:ShowSelect(bShow) + self.ImgRoleSelect.gameObject:SetActive(bShow) +end + +function XUiGridHeadFrame:ShowTxt(bShow) + self.TxtDangqian.gameObject:SetActive(bShow) +end + +function XUiGridHeadFrame:ShowLock(unLock) + self.SelRoleHead.gameObject:SetActive(unLock) + self.LockRoleHead.gameObject:SetActive(not unLock) +end + +function XUiGridHeadFrame:ShowRedPoint(bShow,IsClick) + if not XDataCenter.HeadPortraitManager.IsHeadPortraitValid(self.HeadFrameId) then + self.Red.gameObject:SetActive(false) + else + self.Red.gameObject:SetActive(bShow) + end + + if not bShow and IsClick then + XDataCenter.HeadPortraitManager.SetHeadPortraitForOld(self.HeadFrameId) + self.Base:ShowHeadFrameRedPoint() + end +end + +return XUiGridHeadFrame \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPlayer/XUiGridHeadPortrait.lua b/Resources/Scripts/XUi/XUiPlayer/XUiGridHeadPortrait.lua new file mode 100644 index 00000000..0bf823d4 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPlayer/XUiGridHeadPortrait.lua @@ -0,0 +1,96 @@ +local XUiGridHeadPortrait = XClass(nil, "XUiGridHeadPortrait") + +function XUiGridHeadPortrait:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:AutoAddListener() +end + +function XUiGridHeadPortrait:AutoAddListener() + self.BtnRole.CallBack = function() + self:OnBtnRoleClick() + end +end + +function XUiGridHeadPortrait:OnBtnRoleClick() + local IsTrueHeadPortrait = self.Base:SetHeadPortraitImgRole(self.HeadPortraitId) + self:SetSelectShow(self.Base) + if self.Base.OldPortraitSelectGrig then + self.Base.OldPortraitSelectGrig:SetSelectShow(self.Base) + end + self.Base.OldPortraitSelectGrig = self + self:ShowRedPoint(false, true) + + self.Base:ShowHeadPortraitPanel(IsTrueHeadPortrait) + self.Base:RefreshHeadPortraitDynamicTable() +end + +function XUiGridHeadPortrait:UpdateGrid(chapter, parent) + self.Base = parent + self.HeadPortraitId = chapter.Id + if chapter.ImgSrc ~= nil then + self.UnLockImgHeadImg:SetRawImage(chapter.ImgSrc) + self.LockImgHeadImg:SetRawImage(chapter.ImgSrc) + self.HeadIcon = chapter.ImgSrc + end + + if chapter.Effect then + self.HeadIconEffect.gameObject:LoadPrefab(chapter.Effect) + self.HeadIconEffect.gameObject:SetActiveEx(true) + else + self.HeadIconEffect.gameObject:SetActiveEx(false) + end + + local isTimeLimit = chapter.LimitType ~= XHeadPortraitConfigs.HeadTimeLimitType.Forever + self.LockIconTime.gameObject:SetActiveEx(isTimeLimit) + self.SelIconTime.gameObject:SetActiveEx(isTimeLimit) + + self:SetSelectShow(parent) + self:ShowLock(XDataCenter.HeadPortraitManager.IsHeadPortraitValid(self.HeadPortraitId)) +end + +function XUiGridHeadPortrait:SetSelectShow(parent) + if parent.TempHeadPortraitId == self.HeadPortraitId then + self:ShowSelect(true) + else + self:ShowSelect(false) + end + if parent.CurrHeadPortraitId == self.HeadPortraitId then + self:ShowTxt(true) + if not self.Base.OldPortraitSelectGrig then + self.Base.OldPortraitSelectGrig = self + self:ShowRedPoint(false,true) + end + else + self:ShowTxt(false) + end +end + +function XUiGridHeadPortrait:ShowSelect(bShow) + self.ImgRoleSelect.gameObject:SetActive(bShow) +end + +function XUiGridHeadPortrait:ShowTxt(bShow) + self.TxtDangqian.gameObject:SetActive(bShow) +end + +function XUiGridHeadPortrait:ShowLock(unLock) + self.SelRoleHead.gameObject:SetActive(unLock) + self.LockRoleHead.gameObject:SetActive(not unLock) +end + +function XUiGridHeadPortrait:ShowRedPoint(bShow,IsClick) + if not XDataCenter.HeadPortraitManager.IsHeadPortraitValid(self.HeadPortraitId) then + self.Red.gameObject:SetActive(false) + else + self.Red.gameObject:SetActive(bShow) + end + + if not bShow and IsClick then + XDataCenter.HeadPortraitManager.SetHeadPortraitForOld(self.HeadPortraitId) + self.Base:ShowHeadPortraitRedPoint() + end +end + +return XUiGridHeadPortrait \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPlayer/XUiPanelAchieve.lua b/Resources/Scripts/XUi/XUiPlayer/XUiPanelAchieve.lua new file mode 100644 index 00000000..b1a69ba5 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPlayer/XUiPanelAchieve.lua @@ -0,0 +1,198 @@ +local XUiPanelAchieve = XLuaUiManager.Register(XLuaUi, "UiPanelAchieve") + +function XUiPanelAchieve:OnAwake() + self:InitAutoScript() +end + +function XUiPanelAchieve:OnStart(parent, selectIdx) + self.Base = parent + self.AchieveType = selectIdx or XDataCenter.TaskManager.AchvType.Fight + self:SetTogFightActive(self.AchieveType == XDataCenter.TaskManager.AchvType.Fight) + self:SetTogCollectActive(self.AchieveType == XDataCenter.TaskManager.AchvType.Collect) + self:SetTogSocialActive(self.AchieveType == XDataCenter.TaskManager.AchvType.Social) + self:SetTogOtherActive(self.AchieveType == XDataCenter.TaskManager.AchvType.Other) + + self.AchieveTasks = {} + self.DynamicTable = XDynamicTableNormal.New(self.PanelAchvList) + self.DynamicTable:SetProxy(XDynamicGridTask) + self.DynamicTable:SetDelegate(self) + self:AddRedPointEvent() + self:InitAchvPanel() + XEventManager.AddEventListener(XEventId.EVENT_TASK_SYNC, self.OnTaskChangeSync, self) +end + +function XUiPanelAchieve:AddRedPointEvent() + XRedPointManager.AddRedPointEvent(self.ImgRedFight,self.OnCheckTabRedPoint,self,{XRedPointConditions.Types.CONDITION_PLAYER_ACHIEVE_TYPE},XDataCenter.TaskManager.AchvType.Fight) + XRedPointManager.AddRedPointEvent(self.ImgRedCollect,self.OnCheckTabRedPoint,self,{XRedPointConditions.Types.CONDITION_PLAYER_ACHIEVE_TYPE},XDataCenter.TaskManager.AchvType.Collect) + XRedPointManager.AddRedPointEvent(self.ImgRedSocial,self.OnCheckTabRedPoint,self,{XRedPointConditions.Types.CONDITION_PLAYER_ACHIEVE_TYPE},XDataCenter.TaskManager.AchvType.Social) + XRedPointManager.AddRedPointEvent(self.ImgRedOther,self.OnCheckTabRedPoint,self,{XRedPointConditions.Types.CONDITION_PLAYER_ACHIEVE_TYPE},XDataCenter.TaskManager.AchvType.Other) +end + +function XUiPanelAchieve:OnCheckTabRedPoint(show,achievetype) + if XDataCenter.TaskManager.AchvType.Fight == achievetype then + self.ImgRedFight.gameObject:SetActive(show >= 0) + elseif XDataCenter.TaskManager.AchvType.Collect == achievetype then + self.ImgRedCollect.gameObject:SetActive(show >= 0) + elseif XDataCenter.TaskManager.AchvType.Social == achievetype then + self.ImgRedSocial.gameObject:SetActive(show >= 0) + elseif XDataCenter.TaskManager.AchvType.Other == achievetype then + self.ImgRedOther.gameObject:SetActive(show >= 0) + end +end + +function XUiPanelAchieve:OnShow() + self:SetupTaskList(false) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelAchieve:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiPanelAchieve:AutoInitUi() + self.TogFight = self.Transform:Find("GroupTop/TogFight"):GetComponent("Toggle") + self.ImgAchvUnactive = self.Transform:Find("GroupTop/TogFight/ImgAchvUnactive"):GetComponent("Image") + self.ImgAchvActive = self.Transform:Find("GroupTop/TogFight/ImgAchvActive"):GetComponent("Image") + self.ImgRedFight = self.Transform:Find("GroupTop/TogFight/ImgRedFight"):GetComponent("Image") + self.TogCollect = self.Transform:Find("GroupTop/TogCollect"):GetComponent("Toggle") + self.ImgCollvUnActive = self.Transform:Find("GroupTop/TogCollect/ImgCollvUnActive"):GetComponent("Image") + self.ImgCollvActive = self.Transform:Find("GroupTop/TogCollect/ImgCollvActive"):GetComponent("Image") + self.ImgRedCollect = self.Transform:Find("GroupTop/TogCollect/ImgRedCollect"):GetComponent("Image") + self.TogSocial = self.Transform:Find("GroupTop/TogSocial"):GetComponent("Toggle") + self.ImgSocUnactive = self.Transform:Find("GroupTop/TogSocial/ImgSocUnactive"):GetComponent("Image") + self.ImgSocActive = self.Transform:Find("GroupTop/TogSocial/ImgSocActive"):GetComponent("Image") + self.ImgRedSocial = self.Transform:Find("GroupTop/TogSocial/ImgRedSocial"):GetComponent("Image") + self.TogOther = self.Transform:Find("GroupTop/TogOther"):GetComponent("Toggle") + self.ImgOthUnactive = self.Transform:Find("GroupTop/TogOther/ImgOthUnactive"):GetComponent("Image") + self.ImgOthActive = self.Transform:Find("GroupTop/TogOther/ImgOthActive"):GetComponent("Image") + self.ImgRedOther = self.Transform:Find("GroupTop/TogOther/ImgRedOther"):GetComponent("Image") + self.PanelAchvList = self.Transform:Find("PanelAchvList") + self.PanelAchvContainer = self.Transform:Find("PanelAchvList/Viewport/PanelAchvContainer") + self.PanelAchvReach = self.Transform:Find("PanelAchvReach") + self.TxtAchvGetCount = self.Transform:Find("PanelAchvReach/TxtAchvGetCount"):GetComponent("Text") +end + +function XUiPanelAchieve:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelAchieve:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelAchieve:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelAchieve:AutoAddListener() + self:RegisterClickEvent(self.TogFight, self.OnTogFightClick) + self:RegisterClickEvent(self.TogCollect, self.OnTogCollectClick) + self:RegisterClickEvent(self.TogSocial, self.OnTogSocialClick) + self:RegisterClickEvent(self.TogOther, self.OnTogOtherClick) +end +-- auto + +function XUiPanelAchieve:OnTogFightClick() + self:SetTogOtherActive(false) + self:SetTogCollectActive(false) + self:SetTogSocialActive(false) + self:SetTogFightActive(true) + + self.AchieveType = XDataCenter.TaskManager.AchvType.Fight + self:SetupTaskList(true) +end + +function XUiPanelAchieve:OnTogCollectClick() + self:SetTogOtherActive(false) + self:SetTogCollectActive(true) + self:SetTogSocialActive(false) + self:SetTogFightActive(false) + + self.AchieveType = XDataCenter.TaskManager.AchvType.Collect + self:SetupTaskList(true) +end + +function XUiPanelAchieve:OnTogSocialClick() + self:SetTogOtherActive(false) + self:SetTogCollectActive(false) + self:SetTogSocialActive(true) + self:SetTogFightActive(false) + self.AchieveType = XDataCenter.TaskManager.AchvType.Social + self:SetupTaskList(true) +end + +function XUiPanelAchieve:OnTogOtherClick() + self:SetTogOtherActive(true) + self:SetTogCollectActive(false) + self:SetTogSocialActive(false) + self:SetTogFightActive(false) + + self.AchieveType = XDataCenter.TaskManager.AchvType.Other + self:SetupTaskList(true) +end + +--动态列表事件 +function XUiPanelAchieve:OnDynamicTableEvent(event,index,grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.AchieveTasks[index] + grid.RootUi = self.Base + grid:ResetData(data) + end +end + +function XUiPanelAchieve:SetTogFightActive(flag) + self.ImgAchvActive.gameObject:SetActive(flag) + self.ImgAchvUnactive.gameObject:SetActive(not flag) +end + +function XUiPanelAchieve:SetupTaskList() + local achieveTask,achieveCount, total = XDataCenter.TaskManager.GetAchievedTasksByType(self.AchieveType) + self.TxtAchvGetCount.text = tostring(achieveCount) .. "/" .. tostring(total) + self.AchieveTasks = achieveTask + + self.DynamicTable:SetDataSource(self.AchieveTasks) + self.DynamicTable:ReloadDataSync(1) +end + +function XUiPanelAchieve:SetTogCollectActive(flag) + self.ImgCollvActive.gameObject:SetActive(flag) + self.ImgCollvUnActive.gameObject:SetActive(not flag) +end + +function XUiPanelAchieve:SetTogSocialActive(flag) + self.ImgSocActive.gameObject:SetActive(flag) + self.ImgSocUnactive.gameObject:SetActive(not flag) +end + +function XUiPanelAchieve:SetTogOtherActive(flag) + self.ImgOthActive.gameObject:SetActive(flag) + self.ImgOthUnactive.gameObject:SetActive(not flag) +end + +function XUiPanelAchieve:InitAchvPanel() + self.PanelAchvContainer.gameObject:SetActive(true) + self:SetupTaskList(true) +end + +function XUiPanelAchieve:ShowPanelPlayer() + self.PanelPlayerObj:SetActive(true) + self.PanelPlayerInst:UpdatePlayerInfo() + self.PanelPlayerExpInst:UpdatePlayerLevelInfo() +end + +function XUiPanelAchieve:OnTaskChangeSync() + self:SetupTaskList(false) +end + +function XUiPanelAchieve:OnDestroy() + XEventManager.RemoveEventListener(XEventId.EVENT_TASK_SYNC, self.OnTaskChangeSync, self) +end + +return XUiPanelAchieve \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPlayer/XUiPanelHeadPortrait.lua b/Resources/Scripts/XUi/XUiPlayer/XUiPanelHeadPortrait.lua new file mode 100644 index 00000000..1a0949a6 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPlayer/XUiPanelHeadPortrait.lua @@ -0,0 +1,90 @@ +XUiPanelHeadPortrait = XClass(nil, "XUiPanelHeadPortrait") + +function XUiPanelHeadPortrait:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:AutoAddListener() +end + +function XUiPanelHeadPortrait:AutoAddListener() + self.BtnRole.CallBack = function() + self:OnBtnRoleClick() + end +end + +function XUiPanelHeadPortrait:OnBtnRoleClick() + self.Base:SetImgRole(self.HeadPortraitId) + self:SetSelectShow(self.Base) + self.Base.OldSelectGrig:SetSelectShow(self.Base) + self.Base.OldSelectGrig = self + self:ShowRedPoint(false, true) + + self.Base:RefreshDynamicTable() +end + +function XUiPanelHeadPortrait:UpdateGrid(chapter, parent) + self.Base = parent + self.HeadPortraitId = chapter.Id + if chapter.ImgSrc ~= nil then + self.UnLockImgHeadImg:SetRawImage(chapter.ImgSrc) + self.LockImgHeadImg:SetRawImage(chapter.ImgSrc) + self.HeadIcon = chapter.ImgSrc + end + + if chapter.Effect then + self.HeadIconEffect.gameObject:LoadPrefab(chapter.Effect) + self.HeadIconEffect.gameObject:SetActiveEx(true) + else + self.HeadIconEffect.gameObject:SetActiveEx(false) + end + + local isTimeLimit = chapter.LimitType ~= XDataCenter.HeadPortraitManager.HeadTimeLimitType.Forever + self.LockIconTime.gameObject:SetActiveEx(isTimeLimit) + self.SelIconTime.gameObject:SetActiveEx(isTimeLimit) + + self:SetSelectShow(parent) + self:ShowLock(XDataCenter.HeadPortraitManager.IsHeadPortraitValid(self.HeadPortraitId)) +end + +function XUiPanelHeadPortrait:SetSelectShow(parent) + if parent.TempHeadPortraitId == self.HeadPortraitId then + self:ShowSelect(true) + else + self:ShowSelect(false) + end + if parent.CurrHeadPortraitId == self.HeadPortraitId then + self:ShowTxt(true) + if not self.Base.OldSelectGrig then + self.Base.OldSelectGrig = self + self:ShowRedPoint(false,true) + end + else + self:ShowTxt(false) + end +end + +function XUiPanelHeadPortrait:ShowSelect(bShow) + self.ImgRoleSelect.gameObject:SetActive(bShow) +end + +function XUiPanelHeadPortrait:ShowTxt(bShow) + self.TxtDangqian.gameObject:SetActive(bShow) +end + +function XUiPanelHeadPortrait:ShowLock(unLock) + self.SelRoleHead.gameObject:SetActive(unLock) + self.LockRoleHead.gameObject:SetActive(not unLock) +end + +function XUiPanelHeadPortrait:ShowRedPoint(bShow,IsClick) + if not XDataCenter.HeadPortraitManager.IsHeadPortraitValid(self.HeadPortraitId) then + self.Red.gameObject:SetActive(false) + else + self.Red.gameObject:SetActive(bShow) + end + + if not bShow and IsClick then + XDataCenter.HeadPortraitManager.SetHeadPortraitForOld(self.HeadPortraitId) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPlayer/XUiPanelPlayerExp.lua b/Resources/Scripts/XUi/XUiPlayer/XUiPanelPlayerExp.lua new file mode 100644 index 00000000..3894e2e9 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPlayer/XUiPanelPlayerExp.lua @@ -0,0 +1,65 @@ +XUiPanelPlayerExp = XClass(nil, "XUiPanelPlayerExp") + +function XUiPanelPlayerExp:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self:InitAutoScript() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelPlayerExp:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiPanelPlayerExp:AutoInitUi() + self.ImgExpCircle = self.Transform:Find("ImgExpCircle"):GetComponent("Image") + self.ImgExpCircleFill1 = self.Transform:Find("ImgExpCircle/ImgExpCircleFill1"):GetComponent("Image") + self.ImgExpCircleFill2 = self.Transform:Find("ImgExpCircle/ImgExpCircleFill2"):GetComponent("Image") + self.ImgCircle1 = self.Transform:Find("ImgCircle1"):GetComponent("Image") + self.TxtLevelNum = self.Transform:Find("TxtLevelNum"):GetComponent("Text") + self.PanelExp = self.Transform:Find("PanelExp") + self.TxtExpNum = self.Transform:Find("PanelExp/TxtExpNum"):GetComponent("Text") +end + +function XUiPanelPlayerExp:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelPlayerExp:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelPlayerExp:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelPlayerExp:AutoAddListener() +end +-- auto + +function XUiPanelPlayerExp:UpdatePlayerLevelInfo() + local curExp = XPlayer.Exp + local maxExp= XPlayerManager.GetMaxExp(XPlayer.Level) + local fillAmount = curExp / maxExp + XUiHelper.Tween(1, function(f) + if XTool.UObjIsNil(self.Transform) then + return + end + + local fill = math.floor(f * curExp) + + self.ImgExpCircleFill1.fillAmount=fill / maxExp + self.ImgExpCircleFill2.fillAmount=fill / maxExp + end) + + self.ImgExpCircle.fillAmount=1.0-fillAmount + self.TxtLevelNum.text=XPlayer.Level + self.TxtExpNum.text="" .. curExp .. "" .. "/" ..maxExp +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPlayer/XUiPanelPlayerGloryExp.lua b/Resources/Scripts/XUi/XUiPlayer/XUiPanelPlayerGloryExp.lua new file mode 100644 index 00000000..2b035540 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPlayer/XUiPanelPlayerGloryExp.lua @@ -0,0 +1,65 @@ +XUiPanelPlayerGloryExp = XClass(nil, "XUiPanelPlayerGloryExp") + +function XUiPanelPlayerGloryExp:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self:InitAutoScript() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelPlayerGloryExp:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiPanelPlayerGloryExp:AutoInitUi() + self.ImgExpCircle = self.Transform:Find("ImgExpCircle"):GetComponent("Image") + self.ImgExpCircleFill1 = self.Transform:Find("ImgExpCircle/ImgExpCircleFill1"):GetComponent("Image") + self.ImgExpCircleFill2 = self.Transform:Find("ImgExpCircle/ImgExpCircleFill2"):GetComponent("Image") + self.ImgExpCircleFill3 = self.Transform:Find("ImgExpCircle/ImgExpCircleFill3"):GetComponent("Image") + self.TxtLevelNum = self.Transform:Find("TxtLevelNum"):GetComponent("Text") + self.TxtExpNum = self.Transform:Find("PanelExp/TxtExpNum"):GetComponent("Text") +end + +function XUiPanelPlayerGloryExp:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelPlayerGloryExp:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelPlayerGloryExp:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelPlayerGloryExp:AutoAddListener() +end +-- auto + +function XUiPanelPlayerGloryExp:UpdatePlayerLevelInfo() + local curExp = XPlayer.Exp + local maxExp= XPlayer.GetMaxExp() + local fillAmount = curExp / maxExp + XUiHelper.Tween(1, function(f) + if XTool.UObjIsNil(self.Transform) then + return + end + + local fill = math.floor(f * curExp) + + self.ImgExpCircleFill1.fillAmount = fill / maxExp + self.ImgExpCircleFill2.fillAmount = fill / maxExp + self.ImgExpCircleFill3.fillAmount = fill / maxExp + end) + + self.ImgExpCircle.fillAmount = 1.0-fillAmount + self.TxtLevelNum.text = XPlayer.GetHonorLevel() + self.TxtExpNum.text = "" .. curExp .. "" .. "/" ..maxExp +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPlayer/XUiPanelPlayerInfo.lua b/Resources/Scripts/XUi/XUiPlayer/XUiPanelPlayerInfo.lua new file mode 100644 index 00000000..7549ece6 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPlayer/XUiPanelPlayerInfo.lua @@ -0,0 +1,471 @@ +local CustomerServiceUrl = CS.XGame.ClientConfig:GetString("CustomerServiceUrl") or "" +local FeedBackUrl = CS.XGame.ClientConfig:GetString("FeedBackUrl") or "" + +local CSNetWebRequest = CS.UnityEngine.Networking.UnityWebRequest + +local XUiPanelPlayerInfo = XLuaUiManager.Register(XLuaUi, "UiPanelPlayerInfo") +local MaxSignLength = CS.XGame.ClientConfig:GetInt("MaxSignLength") +local XUiPanelSetHeadPortrait = require("XUi/XUiPlayer/XUiPanelSetHeadPortrait") +local MODE_LOOP = 1 + +function XUiPanelPlayerInfo:OnAwake() + self:InitAutoScript() +end + +function XUiPanelPlayerInfo:OnEnable() + self:ResumeAnimation() + self:UpdatePlayerInfo() +end + +function XUiPanelPlayerInfo:OnStart() + self.PanelSetNameInst = XUiPanelSetName.New(self.PanelSetName, self) + self.PanelSetBirthdayInst = XUiPanelSetBirthday.New(self.PanelSetBirthday, self) + self.PanelSetHeadPortraitInst = XUiPanelSetHeadPortrait.New(self.PanelSetHeadPortrait, self) + + self.DefaultText = CS.XTextManager.GetText("CharacterSignTip") + + self.TxtVersion.text = CS.XRemoteConfig.DocumentVersion + self.TxtServerName.text = XServerManager.GetCurServerName() + self.PanelServerInfo.gameObject:SetActiveEx(false) + + self.BtnFeedback.gameObject:SetActiveEx(not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.Feedback)) + self.PanelDuihuan.gameObject:SetActiveEx(not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.ExchangeCode)) + + XRedPointManager.AddRedPointEvent(self.ImgSetNameTag, self.OnCheckSetName, self, { XRedPointConditions.Types.CONDITION_PLAYER_SETNAME }) + XRedPointManager.AddRedPointEvent(self.ImgExhibitionNew, self.OnCheckExhibition, self, { XRedPointConditions.Types.CONDITION_EXHIBITION_NEW }) + XRedPointManager.AddRedPointEvent(self.NewHead, self.OnCheckHeadPortrait, self, { XRedPointConditions.Types.CONDITION_HEADPORTRAIT_RED }) + XRedPointManager.AddRedPointEvent(self.BtnArchive, self.OnCheckArchive, self, { XRedPointConditions.Types.CONDITION_ARCHIVE_MONSTER_ALL, XRedPointConditions.Types.CONDITION_ARCHIVE_WEAPON, XRedPointConditions.Types.CONDITION_ARCHIVE_AWARENESS, XRedPointConditions.Types.CONDITION_ARCHIVE_CG_ALL }) + + self:UpdatePlayerLevelInfo() +end + +--- +--- 记录动画的播放进度与状态,避免切换到新界面再切回来时动画中断 +function XUiPanelPlayerInfo:RecordAnimation() + -- 荣耀勋阶循环 + if self.PanelPlayerGloryExpLoop.state == CS.UnityEngine.Playables.PlayState.Playing then + self.PanelPlayerGloryExpLoopTime = self.PanelPlayerGloryExpLoop.time + end + -- 普通经验循环 + if self.PanelPlayerExpLoop.state == CS.UnityEngine.Playables.PlayState.Playing then + self.PanelPlayerExpLoopTime = self.PanelPlayerExpLoop.time + end + + -- 解锁荣耀勋阶 + if self.PanelPlayerGloryExpEnable.state == CS.UnityEngine.Playables.PlayState.Playing then + self.PanelPlayerGloryExpEnablePlaying = true + end +end + +--- +--- 恢复动画播放 +function XUiPanelPlayerInfo:ResumeAnimation() + -- 荣耀勋阶循环 + if self.PanelPlayerGloryExpLoopTime then + self.PanelPlayerGloryExpLoop.initialTime = self.PanelPlayerGloryExpLoopTime + self.PanelPlayerGloryExpLoop:Play() + self.PanelPlayerGloryExpLoopTime = nil + end + -- 普通经验循环 + if self.PanelPlayerExpLoopTime then + self.PanelPlayerExpLoop.initialTime = self.PanelPlayerExpLoopTime + self.PanelPlayerExpLoop:Play() + self.PanelPlayerExpLoopTime = nil + end + + -- 解锁荣耀勋阶中断后直接播放循环动画,需要把解锁动画的时间调成最后,不然界面会卡在动画中断处 + if self.PanelPlayerGloryExpEnablePlaying and not self.FinishedPanelPlayerGloryExpEnable then + -- 解锁动画播放到最后 + self.PanelPlayerGloryExpEnable.initialTime = self.PanelPlayerGloryExpEnable.duration + self.PanelPlayerGloryExpEnable:Play() + self.FinishedPanelPlayerGloryExpEnable = true + + self:PlayAnimation("PanelPlayerGloryExpLoop") + self.PanelPlayerGloryExpLoop.extrapolationMode = MODE_LOOP + end +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelPlayerInfo:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiPanelPlayerInfo:AutoInitUi() + self.PanelRight = self.Transform:Find("PanelRight") + self.PanelCorps = self.Transform:Find("PanelRight/PanelCorps") + self.TxtCorps = self.Transform:Find("PanelRight/PanelCorps/TxtCorps"):GetComponent("Text") + self.PanelInfo = self.Transform:Find("PanelRight/PanelInfo") + self.PanelRole = self.Transform:Find("PanelRight/PanelInfo/PanelRole") + self.BtnRoleHeadImg = self.Transform:Find("PanelRight/PanelInfo/PanelRole/BtnRoleHeadImg"):GetComponent("Button") + self.TxtPlayerName = self.Transform:Find("PanelRight/PanelInfo/TxtPlayerName"):GetComponent("Text") + self.BtnName = self.Transform:Find("PanelRight/PanelInfo/BtnName"):GetComponent("Button") + self.BtnCopy = self.Transform:Find("PanelRight/PanelInfo/BtnCopy"):GetComponent("Button") + self.TxtPlayerIdNum = self.Transform:Find("PanelRight/PanelInfo/TxtPlayerIdNum"):GetComponent("Text") + self.PanelBirthday = self.Transform:Find("PanelRight/PanelInfo/PanelBirthday") + self.BtnBirModify = self.Transform:Find("PanelRight/PanelInfo/PanelBirthday/BtnGenghuan"):GetComponent("Button") + self.TxtDate = self.Transform:Find("PanelRight/PanelInfo/PanelBirthday/TxtDate"):GetComponent("Text") + self.PanelSign = self.Transform:Find("PanelRight/PanelInfo/PanelSign") + self.BtnSign = self.Transform:Find("PanelRight/PanelInfo/PanelSign/BtnSign"):GetComponent("Button") + self.TxtSign = self.Transform:Find("PanelRight/PanelInfo/PanelSign/BtnSign/TxtSign"):GetComponent("Text") + self.TxtSignSet = self.Transform:Find("PanelRight/PanelInfo/PanelSign/BtnSign/TxtSignSet"):GetComponent("Text") + self.ImgSetNameTag = self.Transform:Find("PanelRight/PanelInfo/ImgSetNameTag"):GetComponent("Image") + self.BtnLogout = self.Transform:Find("PanelRight/BtnLogout"):GetComponent("Button") + self.PanelZhiyuan = self.Transform:Find("PanelRight/PanelZhiyuan") + self.PanelZhiyuanA = self.Transform:Find("PanelRight/PanelZhiyuan/PanelZhiyuan") + self.BtnRole = self.Transform:Find("PanelRight/PanelZhiyuan/PanelZhiyuan/BtnRole"):GetComponent("Button") + self.RImgAssist = self.Transform:Find("PanelRight/PanelZhiyuan/PanelZhiyuan/BtnRole/RImgAssist"):GetComponent("RawImage") + self.RImgCharacterRank = self.Transform:Find("PanelRight/PanelZhiyuan/PanelZhiyuan/RImgCharacterRank"):GetComponent("RawImage") + self.TxtRoleName = self.Transform:Find("PanelRight/PanelZhiyuan/PanelZhiyuan/TxtRoleName"):GetComponent("Text") + self.TxtRoleRank = self.Transform:Find("PanelRight/PanelZhiyuan/PanelZhiyuan/TxtRoleRank"):GetComponent("Text") + self.BtnAssistModify = self.Transform:Find("PanelRight/PanelZhiyuan/PanelZhiyuan/BtnGenghuan"):GetComponent("Button") + self.PanelPlayerExp = self.Transform:Find("PanelPlayerExp") + self.PanelPlayerGloryExp = self.Transform:Find("PanelPlayerGloryExp") + self.PanelSetSign = self.Transform:Find("PanelSetSign") + self.BtnSignSure = self.Transform:Find("PanelSetSign/BtnSignSure"):GetComponent("Button") + self.BtnSignCancel = self.Transform:Find("PanelSetSign/BtnSignCancel"):GetComponent("Button") + self.Txt = self.Transform:Find("PanelSetSign/Txt"):GetComponent("Text") + self.InFSigm = self.Transform:Find("PanelSetSign/InFSigm"):GetComponent("InputField") + self.PanelSetName = self.Transform:Find("PanelSetName") + self.PanelSetBirthday = self.Transform:Find("PanelSetBirthday") + self.PanelSetHeadPortrait = self.Transform:Find("PanelSetHeadPotrait") + self.BtnExhibition = self.Transform:Find("BtnExhibition"):GetComponent("Button") + self.ImgExhibitionNew = self.Transform:Find("BtnExhibition/ImgExhibitionNew"):GetComponent("Image") + self.DuihuanInput = self.Transform:Find("PanelRight/PanelDuihuan/PanelSign/DuihuanInput"):GetComponent("InputField") + self.BtnGenghuan = self.Transform:Find("PanelRight/PanelDuihuan/PanelSign/BtnGenghuan"):GetComponent("XUiButton") +end + +function XUiPanelPlayerInfo:AutoAddListener() + self:RegisterClickEvent(self.BtnRoleHeadImg, self.OnBtnRoleHeadImgClick) + self:RegisterClickEvent(self.BtnName, self.OnBtnNameClick) + self:RegisterClickEvent(self.BtnCopy, self.OnBtnCopyClick) + self:RegisterClickEvent(self.BtnBirModify, self.OnBtnBirModifyClick) + self:RegisterClickEvent(self.BtnSign, self.OnBtnSignClick) + self:RegisterClickEvent(self.BtnLogout, self.OnBtnLogoutClick) + self:RegisterClickEvent(self.BtnAssistModify, self.OnBtnAssistModifyClick) + self:RegisterClickEvent(self.BtnSignSure, self.OnBtnSignSureClick) + self:RegisterClickEvent(self.BtnSignCancel, self.OnBtnSignCancelClick) + self:RegisterClickEvent(self.BtnExhibition, self.OnBtnExhibitionClick) + self.BtnClose.CallBack = function() + self:OnBtnSignCancelClick() + end + self.BtnArchive.CallBack = function() self:OnBtnArchiveClick() end + self.BtnGenghuan.CallBack = function() self:OnBtnGenghuanClick() end + self.BtnFeedback.CallBack = function() self:OnBtnFeedbackClick() end + self.BtnServerInfo.CallBack = function() self:SetPanelServerInfoShow(true) end + self.BtnCloseServerInfo.CallBack = function() self:SetPanelServerInfoShow(false) end + + self.BtnExhibition.gameObject:SetActiveEx(not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.CharacterExhibition)) + self.BtnArchive.gameObject:SetActiveEx(not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.Archive)) +end +-- auto + +function XUiPanelPlayerInfo:OnBtnExhibitionClick() + if XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.CharacterExhibition) then + self:RecordAnimation() + XLuaUiManager.Open("UiExhibition", true) + end +end + +function XUiPanelPlayerInfo:SetPanelServerInfoShow(isShow) + self.PanelServerInfo.gameObject:SetActiveEx(isShow) +end + +function XUiPanelPlayerInfo:OnCheckSetName(count) + self.ImgSetNameTag.gameObject:SetActiveEx(count >= 0) +end + +function XUiPanelPlayerInfo:OnCheckExhibition(count) + self.ImgExhibitionNew.gameObject:SetActiveEx(count >= 0) +end + +function XUiPanelPlayerInfo:OnCheckHeadPortrait(count) + self.NewHead.gameObject:SetActiveEx(count >= 0) +end + +function XUiPanelPlayerInfo:OnCheckArchive(count) + self.BtnArchive:ShowReddot(count >= 0) +end + +function XUiPanelPlayerInfo:OnBtnSignCancelClick() + if self.PanelSetSign ~= nil then + self.PanelSetSign.gameObject:SetActiveEx(false) + end +end + +function XUiPanelPlayerInfo:OnBtnLogoutClick() + XUserManager.ShowLogout() +end + +function XUiPanelPlayerInfo:OnBtnRoleHeadImgClick() + self.PanelSetHeadPortrait.gameObject:SetActiveEx(true) + self.PanelSetHeadPortraitInst:Reset() + self:PlayAnimation("SetHeadPotraitEnable") +end + +function XUiPanelPlayerInfo:OnBtnBirModifyClick() + self.PanelSetBirthday.gameObject:SetActiveEx(true) + self:PlayAnimation("SetBirthdayEnable") +end + +function XUiPanelPlayerInfo:OnBtnAssistModifyClick() + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.Character) then + return + end + self:RecordAnimation() + XLuaUiManager.Open("UiCharacter", nil, nil, nil, true) +end + +function XUiPanelPlayerInfo:OnBtnCopyClick() + XTool.CopyToClipboard(self.TxtPlayerIdNum.text) +end + +function XUiPanelPlayerInfo:OnBtnNameClick() + self.PanelSetNameInst.GameObject:SetActiveEx(true) + self:PlayAnimation("SetNameEnable") +end + +function XUiPanelPlayerInfo:OnBtnSignClick() + self.PanelSetSign.gameObject:SetActiveEx(true) + self.InFSigm.text = "" + self:PlayAnimation("SetSignEnable") +end + +function XUiPanelPlayerInfo:UpdatePlayerInfo() + self.TxtPlayerIdNum.text = XPlayer.Id + self.TxtPlayerName.text = XPlayer.Name + self:SetBirthday(XPlayer.Birthday) + XUiPLayerHead.InitPortrait(XPlayer.CurrHeadPortraitId, XPlayer.CurrHeadFrameId, self.Head) + self:UpdateAssistInfo() + local sign = XPlayer.Sign + if sign == nil or string.len(sign) == 0 then + local text = CS.XTextManager.GetText('CharacterSignTip') + self:SetSign(text) + else + self:SetSign(sign) + end + + if self.TxtLikeCount then + if XPlayer.Likes > 9999 then + self.TxtLikeCount.text = "9999+" + else + self.TxtLikeCount.text = XPlayer.Likes + end + end + --self.TxtCorpsName.text = "" -- 需要军团 +end + +function XUiPanelPlayerInfo:UpdateAssistInfo() + local id = XDataCenter.AssistManager.GetAssistCharacterId() + local character = XDataCenter.CharacterManager.GetCharacter(id) + self.RImgCharacterRank:SetRawImage(XCharacterConfigs.GetCharacterQualityIcon(character.Quality)) + self.RImgAssist:SetRawImage(XDataCenter.CharacterManager.GetCharSmallHeadIcon(id)) + self.TxtRoleRank.text = character.Level + self.TxtRoleName.text = XCharacterConfigs.GetCharacterName(id) +end + +function XUiPanelPlayerInfo:SetName(name) + self.TxtPlayerName.text = name +end + +function XUiPanelPlayerInfo:SetSign(sign) + self.TxtSignSet.text = sign + self.TxtSign.gameObject:SetActiveEx(false) + self.TxtSignSet.gameObject:SetActiveEx(true) +end + +function XUiPanelPlayerInfo:SetBirthday(birthday) + if (birthday == nil) then + self.TxtDate.text = CS.XTextManager.GetText("Birthday", "--", "--") + else + self.TxtDate.text = CS.XTextManager.GetText("Birthday", birthday.Mon, birthday.Day) + self.BtnBirModify.gameObject:SetActiveEx(false) + end +end + +function XUiPanelPlayerInfo:OnBtnSignSureClick() + if string.len(self:trim(self.InFSigm.text)) > 0 then + if self.InFSigm.text ~= nil then + local signText = self.InFSigm.text + local utf8Count = self.InFSigm.textComponent.cachedTextGenerator.characterCount - 1 + if utf8Count > MaxSignLength then + XUiManager.TipError(CS.XTextManager.GetText("MaxSignLengthTips", MaxSignLength)) + return + end + XPlayer.ChangeSign(signText, + function() + self:ChangeSignCallback() + end) + end + else + XUiManager.TipError(CS.XTextManager.GetText("SignLengthError")) + end +end + +function XUiPanelPlayerInfo:OnBtnGenghuanClick() + local cdKey = self.DuihuanInput.text + if not cdKey then + return + end + + XDataCenter.CdKeyManager.UseCdKeyRequest(cdKey) +end + +function XUiPanelPlayerInfo:OnBtnFeedbackClick() + if FeedBackUrl and FeedBackUrl ~= "" then + --local playerName = CSNetWebRequest.EscapeURL(XPlayer.Name) + --local playerId = CSNetWebRequest.EscapeURL(tostring(XPlayer.Id)) + --local documentVersion = CSNetWebRequest.EscapeURL(tostring(CS.XRemoteConfig.DocumentVersion)) + --local os = CSNetWebRequest.EscapeURL(tostring(CS.UnityEngine.SystemInfo.operatingSystem)) + --local device = CSNetWebRequest.EscapeURL(tostring(CS.UnityEngine.SystemInfo.deviceModel)) + --local resStr = "%s?playerName=%s&playerId=%s&type=%s&os=%s&documentVersion=%s" + --local targetUrl = string.format(resStr, FeedBackUrl, playerName, playerId, device, os, documentVersion) + --targetUrl = string.gsub(targetUrl, "+", ".") + --XLog.Debug(targetUrl) + local targetUrl = FeedBackUrl + CS.UnityEngine.Application.OpenURL(targetUrl) + end +end + +function XUiPanelPlayerInfo:OnBtnArchiveClick() + if XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.Archive) then + self:RecordAnimation() + XLuaUiManager.Open("UiArchiveMain") + end +end + +function XUiPanelPlayerInfo:ChangeSignCallback() + if not XPlayer.Sign or string.len(XPlayer.Sign) == 0 then + self:SetSign(self.DefaultText) + else + self:SetSign(XPlayer.Sign) + end + if self.PanelSetSign.gameObject ~= nil then + self.PanelSetSign.gameObject:SetActiveEx(false) + end +end + +function XUiPanelPlayerInfo:ChangeNameCallback() + self:HidePanelSetName() + self:SetName(XPlayer.Name) + XEventManager.DispatchEvent(XEventId.EVENT_PLAYER_SET_NAME) +end + +function XUiPanelPlayerInfo:HidePanelSetName() + self.PanelSetNameInst.GameObject:SetActiveEx(false) +end + +function XUiPanelPlayerInfo:HidePanelSetHeadPortrait() + self.PanelSetHeadPortrait.gameObject:SetActiveEx(false) + XUiPLayerHead.InitPortrait(XPlayer.CurrHeadPortraitId, XPlayer.CurrHeadFrameId, self.Head) +end + +function XUiPanelPlayerInfo:ChangeBirthdayCallback() + self:HidePanelSetBirthday() + self:SetBirthday(XPlayer.Birthday) +end + +function XUiPanelPlayerInfo:HidePanelSetBirthday() + self.PanelSetBirthday.gameObject:SetActiveEx(false) +end + +function XUiPanelPlayerInfo:OnDestroy() + self.PanelSetHeadPortraitInst:Release() +end + +function XUiPanelPlayerInfo:trim(s) + return (string.gsub(s, "^%s*(.-)%s*$", "%1")) +end + +function XUiPanelPlayerInfo:UpdatePlayerLevelInfo() + if XPlayer.IsHonorLevelOpen() then + self:ShowGloryExp() + else + self:ShowDefaultExp() + end +end + +function XUiPanelPlayerInfo:ShowGloryExp() + if not self.PanelPlayerGloryExpInst then + self.PanelPlayerGloryExpInst = XUiPanelPlayerGloryExp.New(self.PanelPlayerGloryExp, self) + end + self.PanelPlayerGloryExpInst:UpdatePlayerLevelInfo() + + if XPlayer.CheckIsFirstOpenHonor() then + self.PanelPlayerExp.gameObject:SetActiveEx(true) + self.PanelPlayerGloryExp.gameObject:SetActiveEx(false) + self:PlayAnimation("AnimEnablePanelPlayerExp", function() + self.PanelPlayerGloryExp.gameObject:SetActiveEx(true) + self:PlayAnimation("PanelPlayerGloryExpEnable", function() + self:PlayAnimation("PanelPlayerGloryExpLoop") + self.PanelPlayerGloryExpLoop.extrapolationMode = MODE_LOOP + end) + end) + else + self.PanelPlayerExp.gameObject:SetActiveEx(false) + self.PanelPlayerGloryExp.gameObject:SetActiveEx(true) + self:PlayAnimation("AnimEnablePanelPlayerGloryExp", function() + self:PlayAnimation("PanelPlayerGloryExpLoop") + self.PanelPlayerGloryExpLoop.extrapolationMode = MODE_LOOP + end) + end +end + +function XUiPanelPlayerInfo:ShowDefaultExp() + if not self.PanelPlayerExpInst then + self.PanelPlayerExpInst = XUiPanelPlayerExp.New(self.PanelPlayerExp, self) + end + self.PanelPlayerExpInst:UpdatePlayerLevelInfo() + self.PanelPlayerExp.gameObject:SetActiveEx(true) + self.PanelPlayerGloryExp.gameObject:SetActiveEx(false) + self:PlayAnimation("AnimEnablePanelPlayerExp", function() + self:PlayAnimation("PanelPlayerExpLoop") + self.PanelPlayerExpLoop.extrapolationMode = MODE_LOOP + end) +end + +--- 记录动画的播放进度与状态,避免切换到新界面再切回来时动画中断 +function XUiPanelPlayerInfo:RecordAnimation() + -- 荣耀勋阶循环 + if self.PanelPlayerGloryExpLoop.state == CS.UnityEngine.Playables.PlayState.Playing then + self.PanelPlayerGloryExpLoopTime = self.PanelPlayerGloryExpLoop.time + end + -- 普通经验循环 + if self.PanelPlayerExpLoop.state == CS.UnityEngine.Playables.PlayState.Playing then + self.PanelPlayerExpLoopTime = self.PanelPlayerExpLoop.time + end + + -- 解锁荣耀勋阶 + if self.PanelPlayerGloryExpEnable.state == CS.UnityEngine.Playables.PlayState.Playing then + self.PanelPlayerGloryExpEnablePlaying = true + end +end + +--- +--- 恢复动画播放 +function XUiPanelPlayerInfo:ResumeAnimation() + -- 荣耀勋阶循环 + if self.PanelPlayerGloryExpLoopTime then + self.PanelPlayerGloryExpLoop.initialTime = self.PanelPlayerGloryExpLoopTime + self.PanelPlayerGloryExpLoop:Play() + self.PanelPlayerGloryExpLoopTime = nil + end + -- 普通经验循环 + if self.PanelPlayerExpLoopTime then + self.PanelPlayerExpLoop.initialTime = self.PanelPlayerExpLoopTime + self.PanelPlayerExpLoop:Play() + self.PanelPlayerExpLoopTime = nil + end + + -- 解锁荣耀勋阶中断后直接播放循环动画,需要把解锁动画的时间调成最后,不然界面会卡在动画中断处 + if self.PanelPlayerGloryExpEnablePlaying and not self.FinishedPanelPlayerGloryExpEnable then + -- 解锁动画播放到最后 + self.PanelPlayerGloryExpEnable.initialTime = self.PanelPlayerGloryExpEnable.duration + self.PanelPlayerGloryExpEnable:Play() + self.FinishedPanelPlayerGloryExpEnable = true + + self:PlayAnimation("PanelPlayerGloryExpLoop") + self.PanelPlayerGloryExpLoop.extrapolationMode = MODE_LOOP + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPlayer/XUiPanelSetBirthday.lua b/Resources/Scripts/XUi/XUiPlayer/XUiPanelSetBirthday.lua new file mode 100644 index 00000000..621e9e16 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPlayer/XUiPanelSetBirthday.lua @@ -0,0 +1,94 @@ +XUiPanelSetBirthday = XClass(nil, "XUiPanelSetBirthday") + +function XUiPanelSetBirthday:Ctor(ui,base) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Base = base + XTool.InitUiObject(self) + self:InitAutoScript() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelSetBirthday:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiPanelSetBirthday:AutoInitUi() + self.BtnBirSure = self.Transform:Find("BtnBirSure"):GetComponent("Button") + self.BtnBirCancel = self.Transform:Find("BtnBirCancel"):GetComponent("Button") + self.TxtB = self.Transform:Find("Txt"):GetComponent("Text") + self.TxtMon = self.Transform:Find("InMon/TxtMon"):GetComponent("Text") + self.TxtDay = self.Transform:Find("InDay/TxtDay"):GetComponent("Text") +end + +function XUiPanelSetBirthday:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelSetBirthday:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelSetBirthday:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelSetBirthday:AutoAddListener() + self:RegisterClickEvent(self.BtnBirSure, self.OnBtnBirSureClick) + self:RegisterClickEvent(self.BtnBirCancel, self.OnBtnBirCancelClick) + self.BtnClose.CallBack = function() + self:OnBtnBirCancelClick() + end +end +-- auto + +function XUiPanelSetBirthday:OnBtnBirSureClick() + local dayNum = 31 + local mon = tonumber(self.TxtMon.text) + local day = tonumber(self.TxtDay.text) + if not mon or not day then + XUiManager.TipText("WrongDate",XUiManager.UiTipType.Wrong) + return + end + + if mon < 1 or mon > 12 then + XUiManager.TipText("WrongDate",XUiManager.UiTipType.Wrong) + return + end + + if mon == 2 then + dayNum = 29 + elseif mon == 4 or mon == 6 or mon == 9 or mon == 11 then + dayNum = 30 + end + + if day < 1 or day > dayNum then + XUiManager.TipText("WrongDate",XUiManager.UiTipType.Wrong) + return + end + + local currBir = XPlayer.Birthday + if currBir then + if (currBir.Mon and mon == currBir.Mon) and (currBir.Day and day == currBir.Day) then + self.Base:HidePanelSetBirthday() + return + end + end + + XPlayer.ChangeBirthday(mon, day, function() + self.Base:ChangeBirthdayCallback() + end) +end + +function XUiPanelSetBirthday:OnBtnBirCancelClick() + self.Base:HidePanelSetBirthday() +end + +return XUiPanelSetBirthday \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPlayer/XUiPanelSetHeadPortrait.lua b/Resources/Scripts/XUi/XUiPlayer/XUiPanelSetHeadPortrait.lua new file mode 100644 index 00000000..a9965b47 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPlayer/XUiPanelSetHeadPortrait.lua @@ -0,0 +1,354 @@ +local XUiPanelSetHeadPortrait = XClass(nil, "XUiPanelSetHeadPortrait") +local XUiGridHeadPortrait = require("XUi/XUiPlayer/XUiGridHeadPortrait") +local XUiGridHeadFrame = require("XUi/XUiPlayer/XUiGridHeadFrame") +function XUiPanelSetHeadPortrait:Ctor(ui, base) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Base = base + XTool.InitUiObject(self) + + self.TempHeadPortraitId = 0 + self.TempHeadFrameId = 0 + self.CurrHeadPortraitId = 0 + self.CurrHeadFrameId = 0 + self.OldPortraitSelectGrig = {} + self.OldFrameSelectGrig = {} + self.PanelHeadPortraitInfo = {} + self.PanelHeadFrameInfo = {} + self.PanelNoSelectInfo = {} + self:InitHeadInfoObj(self.PanelHeadPortraitInfo, self.PanelHeadPortraitInfoObj) + self:InitHeadInfoObj(self.PanelHeadFrameInfo, self.PanelHeadFrameInfoObj) + self:InitHeadInfoObj(self.PanelNoSelectInfo, self.PanelNoSelectInfoObj) + self:AutoAddListener() + self:InitHeadPortraitDynamicTable() + self:InitHeadFrameDynamicTable() + self:BtnGroupInit() + + +end + +function XUiPanelSetHeadPortrait:InitHeadInfoObj(info, obj) + info.GameObject = obj.gameObject + info.Transform = obj.transform + XTool.InitUiObject(info) +end + +function XUiPanelSetHeadPortrait:Reset() + self.CurType = XHeadPortraitConfigs.HeadType.HeadPortrait + self.TempHeadFrameId = 0 + self.PanelTouxiangGroup:SelectIndex(self.CurType) + self:ShowHeadPortraitRedPoint() + self:ShowHeadFrameRedPoint() + XEventManager.AddEventListener(XEventId.EVENT_HEAD_PORTRAIT_TIMEOUT, self.TimeOutRefresh, self) +end + +function XUiPanelSetHeadPortrait:TimeOutRefresh() + self.TempHeadFrameId = 0 + self.PanelTouxiangGroup:SelectIndex(self.CurType) + self:ShowHeadPortraitRedPoint() + self:ShowHeadFrameRedPoint() +end + +function XUiPanelSetHeadPortrait:BtnGroupInit() + self.CurType = XHeadPortraitConfigs.HeadType.HeadPortrait + self.BtnList = {self.BtnTouxiang, self.BtnTouxiangKuang} + self.PanelTouxiangGroup:Init(self.BtnList, function(index) self:SelectType(index) end) +end + +function XUiPanelSetHeadPortrait:SelectType(index) + self.CurType = index + local IsTrueHeadPortrait = self:ShowPreviewHeadPortrait() + local IsTrueHeadFrame = self:ShowPreviewHeadFrame() + + if self.CurType == XHeadPortraitConfigs.HeadType.HeadPortrait then + self:ShowHeadPortraitPanel(IsTrueHeadPortrait) + self:SetupHeadPortraitDynamicTable(XDataCenter.HeadPortraitManager.GetHeadPortraitNumById(self.CurrHeadPortraitId, self.CurType)) + self.Base:PlayAnimation("PortraitInfoEnable") + elseif self.CurType == XHeadPortraitConfigs.HeadType.HeadFrame then + self:ShowHeadFramePanel(IsTrueHeadFrame) + self:SetupHeadFrameDynamicTable(XDataCenter.HeadPortraitManager.GetHeadPortraitNumById(self.CurrHeadFrameId, self.CurType)) + self.Base:PlayAnimation("FrameInfoEnable") + end +end + +function XUiPanelSetHeadPortrait:AutoAddListener() + self.PanelHeadPortraitInfo.BtnHeadSure.CallBack = function() + self:OnBtnHeadPortraitSureClick() + end + self.PanelHeadPortraitInfo.BtnHeadCancel.CallBack = function() + self:OnBtnCancelClick() + end + self.PanelHeadFrameInfo.BtnHeadSure.CallBack = function() + self:OnBtnHeadFrameSureClick() + end + self.PanelHeadFrameInfo.BtnHeadCancel.CallBack = function() + self:OnBtnCancelClick() + end + self.BtnClose.CallBack = function() + self:OnBtnCancelClick() + end +end + +function XUiPanelSetHeadPortrait:OnBtnCancelClick() + self.TempHeadFrameId = XPlayer.CurrHeadFrameId or 0 + self.TempHeadPortraitId = XPlayer.CurrHeadPortraitId or 0 + self.Base:HidePanelSetHeadPortrait() + XEventManager.DispatchEvent(XEventId.EVENT_HEAD_PORTRAIT_RESETINFO) + XEventManager.RemoveEventListener(XEventId.EVENT_HEAD_PORTRAIT_TIMEOUT, self.TimeOutRefresh, self) +end + +------------------------------------HeadPortrait----------------------------------------------- +function XUiPanelSetHeadPortrait:InitHeadPortraitDynamicTable() + self.HeadPortraitDynamicTable = XDynamicTableNormal.New(self.HeadPortraitScrollView) + self.HeadPortraitDynamicTable:SetProxy(XUiGridHeadPortrait) + self.HeadPortraitDynamicTable:SetDelegate(self) + self.HeadPortraitDynamicTable:SetDynamicEventDelegate(function(event, index, grid) + self:OnHeadPortraitDynamicTableEvent(event, index, grid) + end) + self.GridHeadPortrait.gameObject:SetActiveEx(false) +end + +function XUiPanelSetHeadPortrait:SetupHeadPortraitDynamicTable(index) + self.PageDatas = XDataCenter.HeadPortraitManager.GetUnlockedHeadPortraitIds(XHeadPortraitConfigs.HeadType.HeadPortrait) + self.HeadPortraitDynamicTable:SetDataSource(self.PageDatas) + self.HeadPortraitDynamicTable:ReloadDataSync(index and index or 1) +end + +function XUiPanelSetHeadPortrait:RefreshHeadPortraitDynamicTable() + self.CurrHeadPortraitId = XPlayer.CurrHeadPortraitId or 0 + self.HeadPortraitDynamicTable:ReloadDataSync() +end + +function XUiPanelSetHeadPortrait:OnHeadPortraitDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:UpdateGrid(self.PageDatas[index], self) + self:SetHeadPortraitRedPoint(grid) + end +end + +function XUiPanelSetHeadPortrait:SetHeadPortraitRedPoint(grid) + grid:ShowRedPoint(XDataCenter.HeadPortraitManager.CheckIsNewHeadPortraitById(grid.HeadPortraitId), false) +end + +function XUiPanelSetHeadPortrait:OnBtnHeadPortraitSureClick() + if self.PanelHeadPortraitInfo.BtnHeadSure.ButtonState == CS.UiButtonState.Disable then + return + end + if self.TempHeadPortraitId ~= nil then + if self.TempHeadPortraitId == XPlayer.CurrHeadPortraitId then + return + end + + XDataCenter.HeadPortraitManager.ChangeHeadPortrait(self.TempHeadPortraitId, function() + self:RefreshHeadPortraitDynamicTable() + self:SetHeadPortraitImgRole(self.TempHeadPortraitId) + XUiManager.TipText("HeadPortraitUsecomplete") + end) + end + XEventManager.DispatchEvent(XEventId.EVENT_HEAD_PORTRAIT_RESETINFO) +end + +function XUiPanelSetHeadPortrait:ShowPreviewHeadPortrait() + self.CurrHeadPortraitId = XPlayer.CurrHeadPortraitId or 0 + self.OldPortraitSelectGrig = nil + local IsTrueHeadPortrait = self:SetHeadPortraitImgRole(self.TempHeadPortraitId ~= 0 and self.TempHeadPortraitId or self.CurrHeadPortraitId) + return IsTrueHeadPortrait +end +function XUiPanelSetHeadPortrait:ShowHeadPortraitPanel(IsTrueHeadPortrait) + self.HeadFrameScrollView.gameObject:SetActiveEx(false) + self.PanelHeadFrameInfo.GameObject:SetActiveEx(false) + + self.HeadPortraitScrollView.gameObject:SetActiveEx(true) + self.PanelHeadPortraitInfo.GameObject:SetActiveEx(IsTrueHeadPortrait) + self.PanelNoSelectInfo.GameObject:SetActiveEx(not IsTrueHeadPortrait) + self.PanelNoSelectInfo.TxtHeadName.text = CS.XTextManager.GetText("HeadFrameNoSelectTitle") + self.PanelNoSelectInfo.TxtDecs.text = CS.XTextManager.GetText("HeadPortraitNoSelectHint") +end + +function XUiPanelSetHeadPortrait:SetHeadPortraitImgRole(headId) + local info = XPlayerManager.GetHeadPortraitInfoById(headId) + XUiPLayerHead.InitPortrait(headId, nil, self.Head) + if (info ~= nil) then + self.TempHeadPortraitId = headId + if self.CurType == XHeadPortraitConfigs.HeadType.HeadPortrait then + self:SetHeadTime(info, self.PanelHeadPortraitInfo, headId) + self:SetHeadPortraitDesc(info, self.PanelHeadPortraitInfo, headId, self.CurrHeadPortraitId) + end + return true + else + return false + end +end + +function XUiPanelSetHeadPortrait:SetHeadPortraitDesc(info, panel, Id ,curId) + local isValid = XDataCenter.HeadPortraitManager.IsHeadPortraitValid(Id) + + panel.TxtHeadName.text = info.Name + panel.TxtDecs.text = info.WorldDesc + panel.TxtCondition.text = info.LockDesc + self.TxetTitle.text = CS.XTextManager.GetText("HeadPortraitSelect") + + if Id == curId then + panel.TxtCondition.gameObject:SetActiveEx(false) + panel.BtnHeadSure:SetButtonState(CS.UiButtonState.Disable) + panel.BtnIsUsing.gameObject:SetActiveEx(true) + panel.BtnIsNotHave.gameObject:SetActiveEx(false) + elseif not isValid then + panel.BtnHeadSure:SetButtonState(CS.UiButtonState.Disable) + panel.BtnIsUsing.gameObject:SetActiveEx(false) + panel.BtnIsNotHave.gameObject:SetActiveEx(true) + panel.TxtCondition.gameObject:SetActiveEx(true) + else + panel.BtnHeadSure:SetButtonState(CS.UiButtonState.Normal) + panel.TxtCondition.gameObject:SetActiveEx(false) + end +end +------------------------------------HeadPortrait----------------------------------------------- +------------------------------------HeadFrame----------------------------------------------- +function XUiPanelSetHeadPortrait:InitHeadFrameDynamicTable() + self.HeadFrameDynamicTable = XDynamicTableNormal.New(self.HeadFrameScrollView) + self.HeadFrameDynamicTable:SetProxy(XUiGridHeadFrame) + self.HeadFrameDynamicTable:SetDelegate(self) + self.HeadFrameDynamicTable:SetDynamicEventDelegate(function(event, index, grid) + self:OnHeadFrameDynamicTableEvent(event, index, grid) + end) + self.GridHeadFrame.gameObject:SetActiveEx(false) +end + +function XUiPanelSetHeadPortrait:SetupHeadFrameDynamicTable(index) + self.PageDatas = XDataCenter.HeadPortraitManager.GetUnlockedHeadPortraitIds(XHeadPortraitConfigs.HeadType.HeadFrame) + self.HeadFrameDynamicTable:SetDataSource(self.PageDatas) + self.HeadFrameDynamicTable:ReloadDataSync(index and index or 1) +end + +function XUiPanelSetHeadPortrait:RefreshHeadFrameDynamicTable() + self.CurrHeadFrameId = XPlayer.CurrHeadFrameId or 0 + self.HeadFrameDynamicTable:ReloadDataSync() +end + +function XUiPanelSetHeadPortrait:OnHeadFrameDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:UpdateGrid(self.PageDatas[index], self) + self:SetHeadFrameRedPoint(grid) + end +end + +function XUiPanelSetHeadPortrait:SetHeadFrameRedPoint(grid) + grid:ShowRedPoint(XDataCenter.HeadPortraitManager.CheckIsNewHeadPortraitById(grid.HeadFrameId), false) +end + +function XUiPanelSetHeadPortrait:OnBtnHeadFrameSureClick() + if self.PanelHeadFrameInfo.BtnHeadSure.ButtonState == CS.UiButtonState.Disable then + return + end + if self.TempHeadFrameId ~= nil then + local id = 0 + if self.PanelHeadFrameInfo.BtnType == XHeadPortraitConfigs.BtnState.Use then + id = self.TempHeadFrameId + end + XDataCenter.HeadPortraitManager.ChangeHeadFrame(id, function() + if id == 0 then + XUiManager.TipText("HeadFrameNonUsecomplete") + else + XUiManager.TipText("HeadFrameUsecomplete") + end + self:RefreshHeadFrameDynamicTable() + self:SetHeadFrameImgRole(self.TempHeadFrameId) + end) + end + XEventManager.DispatchEvent(XEventId.EVENT_HEAD_PORTRAIT_RESETINFO) +end + +function XUiPanelSetHeadPortrait:ShowPreviewHeadFrame() + self.CurrHeadFrameId = XPlayer.CurrHeadFrameId or 0 + self.OldFrameSelectGrig = nil + local IsTrueHeadFrame =self:SetHeadFrameImgRole(self.TempHeadFrameId ~= 0 and self.TempHeadFrameId or self.CurrHeadFrameId) + return IsTrueHeadFrame +end + +function XUiPanelSetHeadPortrait:ShowHeadFramePanel(IsTrueHeadFrame) + self.HeadPortraitScrollView.gameObject:SetActiveEx(false) + self.PanelHeadPortraitInfo.GameObject:SetActiveEx(false) + + self.HeadFrameScrollView.gameObject:SetActiveEx(true) + self.PanelHeadFrameInfo.GameObject:SetActiveEx(IsTrueHeadFrame) + self.PanelNoSelectInfo.GameObject:SetActiveEx(not IsTrueHeadFrame) + self.PanelNoSelectInfo.TxtHeadName.text = CS.XTextManager.GetText("HeadFrameNoSelectTitle") + self.PanelNoSelectInfo.TxtDecs.text = CS.XTextManager.GetText("HeadFrameNoSelectHint") +end + +function XUiPanelSetHeadPortrait:SetHeadFrameImgRole(headId) + local info = XPlayerManager.GetHeadPortraitInfoById(headId) + XUiPLayerHead.InitPortrait(nil, headId, self.Head) + if (info ~= nil) then + self.TempHeadFrameId = headId + if self.CurType == XHeadPortraitConfigs.HeadType.HeadFrame then + self:SetHeadTime(info,self.PanelHeadFrameInfo, headId) + self:SetHeadFrameDesc(info, self.PanelHeadFrameInfo, headId, self.CurrHeadFrameId) + end + return true + else + return false + end +end + +function XUiPanelSetHeadPortrait:SetHeadFrameDesc(info, panel, Id ,curId) + local isValid = XDataCenter.HeadPortraitManager.IsHeadPortraitValid(Id) + + panel.TxtHeadName.text = info.Name + panel.TxtDecs.text = info.WorldDesc + panel.TxtCondition.text = info.LockDesc + self.TxetTitle.text = CS.XTextManager.GetText("HeadFrameSelect") + + if Id == curId then + panel.TxtCondition.gameObject:SetActiveEx(false) + panel.BtnHeadSure:SetButtonState(CS.UiButtonState.Normal) + panel.BtnHeadSure:SetName(CS.XTextManager.GetText("HeadFrameNonUse")) + panel.BtnType = XHeadPortraitConfigs.BtnState.NonUse + elseif not isValid then + panel.BtnHeadSure:SetButtonState(CS.UiButtonState.Disable) + panel.BtnIsUsing.gameObject:SetActiveEx(false) + panel.BtnIsNotHave.gameObject:SetActiveEx(true) + panel.TxtCondition.gameObject:SetActiveEx(true) + else + panel.BtnHeadSure:SetButtonState(CS.UiButtonState.Normal) + panel.TxtCondition.gameObject:SetActiveEx(false) + panel.BtnHeadSure:SetName(CS.XTextManager.GetText("HeadFrameUse")) + panel.BtnType = XHeadPortraitConfigs.BtnState.Use + end +end +------------------------------------HeadFrame----------------------------------------------- + +function XUiPanelSetHeadPortrait:SetHeadTime(info, panel, headId) + if info.LimitType == XHeadPortraitConfigs.HeadTimeLimitType.FixedTime then + local beginTime = XDataCenter.HeadPortraitManager.GetBeginTimestamp(headId) + local endTime = XDataCenter.HeadPortraitManager.GetEndTimestamp(headId) + + panel.PanelTime.gameObject:SetActiveEx(true) + panel.TxtTime.text = XTime.TimestampToGameDateTimeString(beginTime, "yyyy/MM/dd") .. "-" .. XTime.TimestampToGameDateTimeString(endTime, "yyyy/MM/dd") + elseif info.LimitType == XHeadPortraitConfigs.HeadTimeLimitType.Duration then + panel.PanelTime.gameObject:SetActiveEx(true) + if XDataCenter.HeadPortraitManager.IsHeadPortraitValid(headId) then + panel.TxtTime.text = XDataCenter.HeadPortraitManager.GetHeadLeftTime(headId) + else + panel.TxtTime.text = XDataCenter.HeadPortraitManager.GetHeadValidDuration(headId) + end + else + panel.PanelTime.gameObject:SetActiveEx(false) + end +end + +function XUiPanelSetHeadPortrait:ShowHeadPortraitRedPoint() + local IsShowRed = XDataCenter.HeadPortraitManager.CheckIsNewHeadPortrait(XHeadPortraitConfigs.HeadType.HeadPortrait) + self.BtnTouxiang:ShowReddot(IsShowRed) +end + +function XUiPanelSetHeadPortrait:ShowHeadFrameRedPoint() + local IsShowRed = XDataCenter.HeadPortraitManager.CheckIsNewHeadPortrait(XHeadPortraitConfigs.HeadType.HeadFrame) + self.BtnTouxiangKuang:ShowReddot(IsShowRed) +end + +function XUiPanelSetHeadPortrait:Release() +end + +return XUiPanelSetHeadPortrait \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPlayer/XUiPanelSetName.lua b/Resources/Scripts/XUi/XUiPlayer/XUiPanelSetName.lua new file mode 100644 index 00000000..36096f49 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPlayer/XUiPanelSetName.lua @@ -0,0 +1,93 @@ +XUiPanelSetName = XClass(nil, "XUiPanelSetName") +local MaxNameLength = CS.XGame.ClientConfig:GetInt("MaxNameLength") + +function XUiPanelSetName:Ctor(ui, base) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Base = base + XTool.InitUiObject(self) + self:InitAutoScript() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelSetName:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiPanelSetName:AutoInitUi() + self.TxtA = self.Transform:Find("Txt"):GetComponent("Text") + self.BtnNameSure = self.Transform:Find("BtnNameSure"):GetComponent("Button") + self.BtnNameCancel = self.Transform:Find("BtnNameCancel"):GetComponent("Button") + self.InFSigmA = self.Transform:Find("InFSigm"):GetComponent("InputField") + self.TxtName = self.Transform:Find("InFSigm/Text"):GetComponent("Text") +end + +function XUiPanelSetName:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelSetName:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelSetName:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelSetName:AutoAddListener() + self:RegisterClickEvent(self.BtnNameSure, self.OnBtnNameSureClick) + self:RegisterClickEvent(self.BtnNameCancel, self.OnBtnNameCancelClick) + self.BtnClose.CallBack = function() + self:OnBtnNameCancelClick() + end +end +-- auto + +function XUiPanelSetName:OnBtnNameCancelClick() + self.Base:HidePanelSetName() +end + +function XUiPanelSetName:OnBtnNameSureClick() + local editName = self:trim(self.InFSigmA.text) + if string.len(editName) > 0 then + local utf8Count = self.InFSigmA.textComponent.cachedTextGenerator.characterCount - 1 + if utf8Count > MaxNameLength then + XUiManager.TipError(CS.XTextManager.GetText("MaxNameLengthTips", MaxNameLength)) + return + end + XPlayer.ChangeName(editName, function() + self.Base:ChangeNameCallback() + end) + else + XUiManager.TipError(CS.XTextManager.GetText("RenameLengthError")) + end +end + +function XUiPanelSetName:RefreshLimit() + self.InFSigmA.text = XPlayer.Name + if not XPlayer.ChangeNameTime then return end + local nextCanChangeTime = XPlayer.ChangeNameTime + XPlayerManager.PlayerChangeNameInterval + local timeLimit = nextCanChangeTime - XTime.GetServerNowTimestamp() + local hour = math.floor(timeLimit / 3600) + local minute = math.ceil(timeLimit % 3600 / 60) + if timeLimit > 0 then + if minute > 0 then + self.TxtCoolTip.text = CS.XTextManager.GetText("ChangeNameLimitHourMin", hour, minute) + else + self.TxtCoolTip.text = CS.XTextManager.GetText("ChangeNameLimitHour", hour) + end + else + self.TxtCoolTip.text = "" + end +end + +function XUiPanelSetName:trim(s) + return (string.gsub(s, "^%s*(.-)%s*$", "%1")) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPlayer/XUiPanelSetting.lua b/Resources/Scripts/XUi/XUiPlayer/XUiPanelSetting.lua new file mode 100644 index 00000000..a6b92531 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPlayer/XUiPanelSetting.lua @@ -0,0 +1,701 @@ +local XUiPanelSetting = XLuaUiManager.Register(XLuaUi, "UiPanelSetting") + +local XUiGridCollectionWall = require("XUi/XUiCollectionWall/XUiCollectionWallGrid/XUiGridCollectionWall") +local UiButtonState = CS.UiButtonState +local tableInsert = table.insert +local MAX_CHARACTER = 5 +local ScoreTitleType = { + Babel = 2 +} +local ShowTypeIndex = { + All = 1, + Friend = 2, + Self = 3 +} + +function XUiPanelSetting:OnStart(root) + self.UiRoot = root + self.UiRoot.UiPanelSetting = self + + self.SortedDormitoryList = {} -- 拥有的宿舍数组,值为{ DormitoryId, DormitoryName },索引从1开始,对应的下拉列表值为索引减1,按照宿舍号进行排序 + self.DormIdToDropValue = {} -- 宿舍Id对应的下拉列表值,从0开始 + + self.OldWallShowSetting = {} -- 旧收藏品墙展示设置 + self.CurWallShowSetting = {} -- 当前收藏品墙展示设置 + self.WallPool = {} -- XUiGridCollectionWall池子 + + self.CharacterList = XPlayer.ShowCharacters + self.RImgCharacter = { + self.RImgCharacter1, + self.RImgCharacter2, + self.RImgCharacter3, + self.RImgCharacter4, + self.RImgCharacter5 + } + self:AddListener() + + self:InitCollectionShowBtnGroup() + self:InitMemberShowBtnGroup() + self:InitFashionShowBtnGroup() + self:InitWeaponShowBtnGroup() + self:InitDormitoryShowBtnGroup() + + self:InitAppearanceSetting() + self:UpdateCharacterHead() + + self:InitUnfold() +end + +--- +--- 更新展示角色 +function XUiPanelSetting:UpdateCharacterHead() + for i = 1, #self.RImgCharacter do + if self.CharacterList[i] then + self.RImgCharacter[i].gameObject:SetActive(true) + local charIcon = XDataCenter.CharacterManager.GetCharSmallHeadIcon(self.CharacterList[i]) + self.RImgCharacter[i]:SetRawImage(charIcon) + else + self.RImgCharacter[i].gameObject:SetActive(false) + end + end +end + +--- +--- 初始化展示设置 +function XUiPanelSetting:InitAppearanceSetting() + self.CurScoreTitleShowState = XDataCenter.MedalManager.GetScoreTitleShowState() + self.OldScoreTitleShowState = XDataCenter.MedalManager.GetScoreTitleShowState() + + -- 是否全角色展示,0全部显示,1自己选择显示 + self.OldCharactersAppearanceType = XPlayer.GetAppearanceShowType() + self.CurCharactersAppearanceType = XPlayer.GetAppearanceShowType() + local isShowAllCharacter = self.CurCharactersAppearanceType and self.CurCharactersAppearanceType == XPlayerInfoConfigs.CharactersAppearanceType.All or false + self.BtnAllCharacterShow:SetButtonState(isShowAllCharacter and UiButtonState.Select or UiButtonState.Normal) + self.MemberContent.gameObject:SetActiveEx(not isShowAllCharacter) + self.HadAllChar.gameObject:SetActiveEx(isShowAllCharacter) + + -- 展示设置,1全部可见,2朋友可见,3自己可见 + self.OldAppearanceSetting = XPlayer.GetAppearanceSettingInfo() + self.CurAppearanceSetting = XPlayer.GetAppearanceSettingInfo() + self.CollectionShowBtnGroup:SelectIndex(self.CurAppearanceSetting and self.CurAppearanceSetting.TitleType or ShowTypeIndex.All) + self.MemberShowBtnGroup:SelectIndex(self.CurAppearanceSetting and self.CurAppearanceSetting.CharacterType or ShowTypeIndex.All) + self.FashionShowBtnGroup:SelectIndex(self.CurAppearanceSetting and self.CurAppearanceSetting.FashionType or ShowTypeIndex.All) + self.WeaponShowBtnGroup:SelectIndex(self.CurAppearanceSetting and self.CurAppearanceSetting.WeaponFashionType or ShowTypeIndex.All) + self.DormitoryShowBtnGroup:SelectIndex(self.CurAppearanceSetting and self.CurAppearanceSetting.DormitoryType or ShowTypeIndex.All) + + -- 判断宿舍系统是否开开启 + local isDormOpen = XFunctionManager.JudgeCanOpen( XFunctionManager.FunctionName.Dorm) + self.TxtDromNotOpen.gameObject:SetActiveEx(not isDormOpen) + self.DormitoryShowBtnGroup.gameObject:SetActiveEx(isDormOpen) + if isDormOpen then + -- 设置宿舍下拉列表 + XPlayer.GetDormitoryList(function(dormitoryList) + self:InitDormitoryDrop(dormitoryList) + end) + end + + -- 在聊天与个人信息展示本期巴别塔等级设置 + local IsBabelScoreTitleShow = XDataCenter.MedalManager.CheckScoreTitleIsShow(ScoreTitleType.Babel) + self.BtnBabelScoreTitleShow:SetButtonState(IsBabelScoreTitleShow and UiButtonState.Select or UiButtonState.Normal) + local IsHaveType = XDataCenter.MedalManager.CheckHaveScoreTitleType(ScoreTitleType.Babel) + local IsInTime = XDataCenter.MedalManager.CheckScoreTitleInTimeByType(ScoreTitleType.Babel) + self.BtnBabelScoreTitleShow.gameObject:SetActiveEx(IsHaveType and IsInTime) +end + +--- +--- 初始化折叠信息 +function XUiPanelSetting:InitUnfold() + local charUnfold = XSaveTool.GetData(string.format("%d%s", XPlayer.Id, "CharUnfold")) + local displayUnfold = XSaveTool.GetData(string.format("%d%s", XPlayer.Id, "DisplayUnfold")) + local collectionUnfold = XSaveTool.GetData(string.format("%d%s", XPlayer.Id, "CollectionUnfold")) + + if charUnfold == nil or charUnfold == false then + self.BtnCharUnfold:SetButtonState(UiButtonState.Normal) + else + self.BtnCharUnfold:SetButtonState(UiButtonState.Select) + end + + if displayUnfold == nil or displayUnfold == false then + self.BtnDisplayUnfold:SetButtonState(UiButtonState.Normal) + else + self.BtnDisplayUnfold:SetButtonState(UiButtonState.Select) + end + + if collectionUnfold == nil or collectionUnfold == 1 then + self.BtnCollectionUnfold:SetButtonState(UiButtonState.Select) + else + self.BtnCollectionUnfold:SetButtonState(UiButtonState.Normal) + end + + self:OnBtnCharUnfold() + self:OnBtnDisplayUnfold() + self:OnBtnCollectionUnfold() +end + +--- +--- 根据已解锁宿舍,初始化宿舍下拉列表 +--- @param dormitoryList table 已解锁的宿舍数组,结构为{ DormitoryId, DormitoryName } +function XUiPanelSetting:InitDormitoryDrop(dormitoryList) + if not dormitoryList or not next(dormitoryList) then + XLog.Error("XUiPanelSetting:InitDormitoryDrop函数错误,dormitoryList为空") + return + end + self.SortedDormitoryList = dormitoryList or {} + + -- 排序下拉列表的宿舍 + table.sort(self.SortedDormitoryList, function(a, b) + local cfg1 = XDormConfig.GetDormitoryCfgById(a.DormitoryId) + local cfg2 = XDormConfig.GetDormitoryCfgById(b.DormitoryId) + return cfg1.InitNumber < cfg2.InitNumber + end) + + -- 创建下拉列表选项 + local optionsDataList = CS.UnityEngine.UI.Dropdown.OptionDataList() + for index, dorm in ipairs(self.SortedDormitoryList) do + local optionContribute = CS.UnityEngine.UI.Dropdown.OptionData() + optionContribute.text = dorm.DormitoryName + optionsDataList.options:Add(optionContribute) + self.DormIdToDropValue[dorm.DormitoryId] = index - 1 + end + self.DormitoryDrop:ClearOptions() + self.DormitoryDrop:AddOptions(optionsDataList.options) + + -- 未解锁宿舍系统时,登录推送的宿舍Id为0,解锁宿舍系统后需要初始化为默认的宿舍Id + if self.CurAppearanceSetting.DormitoryId == 0 or self.OldAppearanceSetting.DormitoryId == 0 then + if self.CurAppearanceSetting.DormitoryId ~= self.OldAppearanceSetting.DormitoryId then + XLog.Error("XUiPanelSetting:InitDormitoryDrop函数错误,当前设置宿舍ID 与 旧设置宿舍ID 一个为0,另一个不为0") + end + + if (self.SortedDormitoryList[1] or {}).DormitoryId then + self.CurAppearanceSetting.DormitoryId = self.SortedDormitoryList[1].DormitoryId + self.OldAppearanceSetting.DormitoryId = self.SortedDormitoryList[1].DormitoryId + else + XLog.Error("XUiPanelSetting:InitDormitoryDrop函数错误,展示设置宿舍Id为0,且SortedDormitoryList中没有宿舍数据") + end + end + + -- 选择对应的宿舍 + local dropValue = self.DormIdToDropValue[self.CurAppearanceSetting.DormitoryId] + if dropValue then + self.DormitoryDrop.value = dropValue + else + XLog.Error(string.format("XUiPanelSetting:CreateOptionsDataList函数错误,宿舍%s不在的解锁的宿舍数据中", tostring(self.CurAppearanceSetting.DormitoryId))) + self.DormitoryDrop.value = 0 + end +end + +--- +--- 更改设置之后,检查与原来设置是否相同 +--- 不相同则在退出时提示是否需要保存 +function XUiPanelSetting:CheckSave() + local needSave = false + + -- 选择展示的成员 + for i = 1, MAX_CHARACTER do + if self.CharacterList[i] ~= XPlayer.ShowCharacters[i] then + needSave = true + break + end + end + + -- 在聊天与个人信息展示本期巴别塔等级设置 + for index, showState in pairs(self.OldScoreTitleShowState) do + if self.CurScoreTitleShowState[index].Hide ~= showState.Hide then + needSave = true + break + end + end + + -- 展示设置 + for index, showState in pairs(self.OldAppearanceSetting) do + if self.CurAppearanceSetting[index] ~= showState then + needSave = true + break + end + end + + -- 全角色展示 + if self.CurCharactersAppearanceType ~= self.OldCharactersAppearanceType then + needSave = true + end + + -- 收藏品墙展示 + for wallDataId, isShow in pairs(self.OldWallShowSetting) do + if self.CurWallShowSetting[wallDataId] ~= isShow then + needSave = true + break + end + end + + self.UiRoot.NeedSave = needSave +end + +function XUiPanelSetting:SaveScoreTitleShowData() + local list = {} + + for index, showState in pairs(self.OldScoreTitleShowState) do + if self.CurScoreTitleShowState[index].Hide ~= showState.Hide then + tableInsert(list, self.CurScoreTitleShowState[index]) + end + end + if #list > 0 then + XDataCenter.MedalManager.SetScoreTitleShow(list, function() + self.CurScoreTitleShowState = XDataCenter.MedalManager.GetScoreTitleShowState() + self.OldScoreTitleShowState = XDataCenter.MedalManager.GetScoreTitleShowState() + end) + end +end + +--- +--- 初始化收藏品墙展示设置 +function XUiPanelSetting:InitCollectionWallShow() + self.UseWallDic = {} -- WallPool池子中正在使用的格子 { key:Id, value:XUiGridCollectionWall } + self.OldWallShowSetting = {} + self.CurWallShowSetting = {} + self.GridCollectionWall.gameObject:SetActiveEx(false) + + for _, wall in pairs(self.WallPool) do + wall.GameObject:SetActiveEx(false) + end + + self.NormalCollectionWall = XDataCenter.CollectionWallManager.GetNormalWallEntityList() + if #self.NormalCollectionWall <= 0 then + self.CollectionWallNone.gameObject:SetActiveEx(true) + self.BtnAllCollectionShow.gameObject:SetActiveEx(false) + return + end + + self.CollectionWallNone.gameObject:SetActiveEx(false) + self.BtnAllCollectionShow.gameObject:SetActiveEx(true) + + local isShowAll = true + for i, wallData in ipairs(self.NormalCollectionWall) do + local isShow = wallData:GetIsShow() + self.OldWallShowSetting[wallData:GetId()] = isShow + self.CurWallShowSetting[wallData:GetId()] = isShow + + if isShow == false then + -- 有一个收藏品墙不展示,所以不是全部展示 + isShowAll = false + end + + if not self.WallPool[i] then + local ui = CS.UnityEngine.Object.Instantiate(self.GridCollectionWall) + ui.transform:SetParent(self.CollectionWallContent, false) + ui.gameObject:SetActive(true) + + local collectionWall = XUiGridCollectionWall.New(ui, self, XCollectionWallConfigs.EnumWallGridOpenType.Setting) + self.WallPool[i] = collectionWall + end + self.WallPool[i]:UpdateGrid(wallData) + self.WallPool[i].GameObject:SetActiveEx(true) + + self.UseWallDic[wallData:GetId()] = self.WallPool[i] + end + + -- 设置全部展示的状态 + if isShowAll then + self.BtnAllCollectionShow:SetButtonState(CS.UiButtonState.Select) + else + self.BtnAllCollectionShow:SetButtonState(CS.UiButtonState.Normal) + end +end + +--- +--- 保存收藏品墙展示设置 +--- 在发送协议后更新收藏品墙数据实体(XCollectionWall)IsShow属性 +--- 然后在回调中更新设置缓存 +function XUiPanelSetting:SaveCollectionWallShow() + if #self.NormalCollectionWall <= 0 then + -- 没有对外展示的墙 + return + end + + -- 构造发送请求需要的数据 + local showInfoList = {} + for id, isShow in pairs(self.CurWallShowSetting) do + local showInfo = {} + showInfo.Id = id + showInfo.IsShow = isShow + table.insert(showInfoList, showInfo) + end + + XDataCenter.CollectionWallManager.RequestEditCollectionWallIsShow(showInfoList, function() + -- 保存后更新新旧设置缓存 + for _, wallData in ipairs(self.NormalCollectionWall) do + self.OldWallShowSetting[wallData:GetId()] = wallData:GetIsShow() + self.CurWallShowSetting[wallData:GetId()] = wallData:GetIsShow() + end + end) +end + + +---------------------------------------------------添加按钮响应函数--------------------------------------------------------- + +function XUiPanelSetting:AddListener() + self.BtnAllCharacterShow.CallBack = function() + self:OnBtnAllCharacterShow() + end + self.BtnCharacter1.CallBack = function() + self:OnBtnCharacter(1) + end + self.BtnCharacter2.CallBack = function() + self:OnBtnCharacter(2) + end + self.BtnCharacter3.CallBack = function() + self:OnBtnCharacter(3) + end + self.BtnCharacter4.CallBack = function() + self:OnBtnCharacter(4) + end + self.BtnCharacter5.CallBack = function() + self:OnBtnCharacter(5) + end + + self.BtnBabelScoreTitleShow.CallBack = function() + self:OnBtnBabelScoreTitleShow() + end + self.BtnSave.CallBack = function() + self:OnBtnSave() + end + self.BtnView.CallBack = function() + self:OnBtnView() + end + + self.DormitoryDrop.onValueChanged:AddListener(function() + self:OnDormitoryDropClick() + end) + + self.BtnAllCollectionShow.CallBack = function() + self:OnBtnAllCollectionShow() + end + + self.BtnCharUnfold.CallBack = function() + self:OnBtnCharUnfold() + end + self.BtnDisplayUnfold.CallBack = function() + self:OnBtnDisplayUnfold() + end + self.BtnCollectionUnfold.CallBack = function() + self:OnBtnCollectionUnfold() + end +end + +function XUiPanelSetting:OnBtnCollectionUnfold() + local isUnfold + if self.BtnCollectionUnfold.ButtonState == CS.UiButtonState.Select then + isUnfold = 1 + self.PanelCollectionWall.gameObject:SetActiveEx(true) + else + isUnfold = 2 + self.PanelCollectionWall.gameObject:SetActiveEx(false) + end + + XSaveTool.SaveData(string.format("%d%s", XPlayer.Id, "CollectionUnfold"), isUnfold) +end + +function XUiPanelSetting:OnBtnDisplayUnfold() + local isUnfold = self.BtnDisplayUnfold.ButtonState == CS.UiButtonState.Select + + self.PanelDisplaySetting.gameObject:SetActiveEx(isUnfold) + XSaveTool.SaveData(string.format("%d%s", XPlayer.Id, "DisplayUnfold"), isUnfold) +end + +function XUiPanelSetting:OnBtnCharUnfold() + local isUnfold = self.BtnCharUnfold.ButtonState == CS.UiButtonState.Select + local isShowAllCharacter = self.CurCharactersAppearanceType and self.CurCharactersAppearanceType == XPlayerInfoConfigs.CharactersAppearanceType.All or false + + self.PanelMember.gameObject:SetActiveEx(isUnfold) + + -- 展示全角色不显示头像 + self.MemberContent.gameObject:SetActiveEx(not isShowAllCharacter) + self.HadAllChar.gameObject:SetActiveEx(isShowAllCharacter) + XSaveTool.SaveData(string.format("%d%s", XPlayer.Id, "CharUnfold"), isUnfold) +end + +function XUiPanelSetting:OnBtnAllCollectionShow() + local isShowAll = self.BtnAllCollectionShow.ButtonState == UiButtonState.Select + for _, wall in pairs(self.UseWallDic) do + wall:SetIsSelect(isShowAll) + end +end + +function XUiPanelSetting:OnBtnAllCharacterShow() + local isShowAll = self.BtnAllCharacterShow.ButtonState == UiButtonState.Select + + if isShowAll then + self.CurCharactersAppearanceType = XPlayerInfoConfigs.CharactersAppearanceType.All + else + self.CurCharactersAppearanceType = XPlayerInfoConfigs.CharactersAppearanceType.Select + end + self.MemberContent.gameObject:SetActiveEx(not isShowAll) + self.HadAllChar.gameObject:SetActiveEx(isShowAll) + + self:CheckSave() +end + +function XUiPanelSetting:OnBtnCharacter(index) + local curTeam = {} + for i = 1, MAX_CHARACTER do + curTeam[i] = self.CharacterList[i] or 0 + end + + local cb = function(resTeam) + self.CharacterList = {} + for i = 1, #resTeam do + if resTeam[i] ~= 0 then + table.insert(self.CharacterList, resTeam[i]) + end + end + self.UiRoot.CharacterList = self.CharacterList + self:CheckSave() + self:UpdateCharacterHead() + end + + -- 根据选中的角色类型打开对应的页签 + local characterType + if curTeam[index] and curTeam[index] ~= 0 then + characterType = XCharacterConfigs.GetCharacterType(curTeam[index]) + else + -- 添加新角色时,默认打开构造体页签 + characterType = XCharacterConfigs.CharacterType.Normal + end + + -- 角色展示不拦截角色类型,构造体与授格者可以同时展示 + XLuaUiManager.Open("UiRoomCharacter", curTeam, index, cb, nil, nil, { NotReset = true, SelectCharacterType = characterType }) +end + +function XUiPanelSetting:OnBtnBabelScoreTitleShow() + local state = self.CurScoreTitleShowState[ScoreTitleType.Babel] + if state then + state.Hide = (self.BtnBabelScoreTitleShow.ButtonState == UiButtonState.Select) and + XMedalConfigs.Hide.OFF or + XMedalConfigs.Hide.ON + else + self.BtnBabelScoreTitleShow:SetButtonState(UiButtonState.Normal) + end + self:CheckSave() +end + +function XUiPanelSetting:OnBtnSave() + self.UiRoot.NeedSave = false + self:SaveScoreTitleShowData() + self:SaveCollectionWallShow() + XDataCenter.PlayerInfoManager.SaveData(self.CurCharactersAppearanceType, self.CharacterList, self.CurAppearanceSetting, function() + self.CurCharactersAppearanceType = XPlayer.GetAppearanceShowType() + self.OldCharactersAppearanceType = XPlayer.GetAppearanceShowType() + self.OldAppearanceSetting = XPlayer.GetAppearanceSettingInfo() + self.CurAppearanceSetting = XPlayer.GetAppearanceSettingInfo() + end) +end + +--- +--- 展示预览 +function XUiPanelSetting:OnBtnView() + XDataCenter.PlayerInfoManager.RequestPlayerInfoData(XPlayer.Id, function(data) + XPlayer.SetPlayerLikes(data.Likes) + local tmpData = {} + for k, v in pairs(data) do + tmpData[k] = v + end + + tmpData.AppearanceSettingInfo = self.CurAppearanceSetting + + if XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.Dorm) then + local dormDetail = {} + dormDetail.DormitoryId = self.CurAppearanceSetting.DormitoryId + for _, dorm in pairs(self.SortedDormitoryList) do + if dorm.DormitoryId == dormDetail.DormitoryId then + dormDetail.DormitoryName = dorm.DormitoryName + end + end + if not dormDetail.DormitoryName then + XLog.Error(string.format("XUiPanelSetting:OnBtnView函数错误,在self.SortedDormitoryList中没有宿舍%s的数据", dormDetail.DormitoryId)) + dormDetail = nil + end + tmpData.DormDetail = dormDetail + end + + --展示角色列表 + tmpData.CharacterShow = {} + if self.CurCharactersAppearanceType == XPlayerInfoConfigs.CharactersAppearanceType.Select then + for i = 1, MAX_CHARACTER do + if self.CharacterList[i] then + local char = XDataCenter.CharacterManager.GetCharacter(self.CharacterList[i]) + tmpData.CharacterShow[i] = char + else + tmpData.CharacterShow[i] = nil + end + end + else + --展示全角色 + tmpData.CharacterShow = XDataCenter.CharacterManager.GetOwnCharacterList() + end + + --请求的数据有缓冲,使用XPlayer的数据可以实时看到预览的改变 + tmpData.Sign = XPlayer.Sign + tmpData.Level = XPlayer.Level + tmpData.Likes = XPlayer.Likes + tmpData.Birthday = XPlayer.Birthday + tmpData.CurrHeadFrameId = XPlayer.CurrHeadFrameId + tmpData.CurrHeadPortraitId = XPlayer.CurrHeadPortraitId + tmpData.AppearanceShowType = self.CurCharactersAppearanceType --角色展示类型 + + --收藏品信息 + tmpData.CollectionShow = {} + for _, v in pairs(XDataCenter.MedalManager.GetScoreTitleUnLockList()) do + table.insert(tmpData.CollectionShow, v) + end + + tmpData.CollectionWall = {} + for wallId, isShow in pairs(self.CurWallShowSetting) do + if isShow then + local wallData = XDataCenter.CollectionWallManager.GetWallEntityData(wallId) + tableInsert(tmpData.CollectionWall, wallData) + end + end + + --成员涂装 + tmpData.FashionShow = {} + for k, _ in pairs(XDataCenter.FashionManager.GetOwnFashionStatus()) do + table.insert(tmpData.FashionShow, k) + end + + --武器涂装 + tmpData.WeaponFashionShow = {} + for _, v in pairs(XDataCenter.WeaponFashionManager.GetOwnWeaponFashion()) do + table.insert(tmpData.WeaponFashionShow, v.Id) + end + tmpData.CurrentWearNameplate = data.CurrentWearNameplate + + XLuaUiManager.Open("UiPlayerInfo", tmpData, nil, true) + end) +end + +function XUiPanelSetting:OnDormitoryDropClick() + -- 选择的宿舍Id与当前设置的Id是否相同 + local selectDormId = self.SortedDormitoryList[self.DormitoryDrop.value + 1].DormitoryId + + if selectDormId == self.CurAppearanceSetting.DormitoryId then + return + end + self.CurAppearanceSetting.DormitoryId = selectDormId + self:CheckSave() +end + +--- +--- 'wallDataId'墙的展示设置缓存更改为'isShow' +--- 由XUiGridCollectionWall脚本的点击函数回调 +---@param wallDataId number +---@param isShow boolean +function XUiPanelSetting:ChangeCurShowSetting(wallDataId, isShow) + local isShowAll = true + + if self.CurWallShowSetting[wallDataId] ~= nil then + self.CurWallShowSetting[wallDataId] = isShow + self:CheckSave() + else + XLog.Error(string.format("XUiPanelSetting:ChangeCurShowSetting函数错误,没有Id:%s 收藏品墙数据", tostring(wallDataId))) + end + + for _, showSetting in pairs(self.CurWallShowSetting) do + if showSetting == false then + isShowAll = false + break; + end + end + + if isShowAll then + self.BtnAllCollectionShow:SetButtonState(CS.UiButtonState.Select) + else + self.BtnAllCollectionShow:SetButtonState(CS.UiButtonState.Normal) + end +end + + +--------------------------------------------------初始化展示设置的按钮组---------------------------------------------------------- + +--- +--- 宿舍展示 +function XUiPanelSetting:InitDormitoryShowBtnGroup() + self.DormitoryShowBtns = { self.BtnDormitoryShowAll, self.BtnDormitoryShowFriend, self.BtnDormitoryShowSelf } + self.DormitoryShowBtnGroup:Init(self.DormitoryShowBtns, function(tabIndex) + self:OnDormitoryShowBtnGroup(tabIndex) + end) +end +function XUiPanelSetting:OnDormitoryShowBtnGroup(tabIndex) + if self.DormitoryShowIndex and self.DormitoryShowIndex == tabIndex then + return + end + self.CurAppearanceSetting.DormitoryType = tabIndex + self.DormitoryShowIndex = tabIndex + self:CheckSave() +end + +--- +--- 成员展示 +function XUiPanelSetting:InitMemberShowBtnGroup() + self.MemberShowBtns = { self.BtnMemberShowAll, self.BtnMemberShowFriend, self.BtnMemberShowSelf } + self.MemberShowBtnGroup:Init(self.MemberShowBtns, function(tabIndex) + self:OnMemberShowBtnGroup(tabIndex) + end) +end +function XUiPanelSetting:OnMemberShowBtnGroup(tabIndex) + if self.MemberShowIndex and self.MemberShowIndex == tabIndex then + return + end + self.CurAppearanceSetting.CharacterType = tabIndex + self.MemberShowIndex = tabIndex + self:CheckSave() +end + +--- +--- 收藏品展示 +function XUiPanelSetting:InitCollectionShowBtnGroup() + self.CollectionShowBtns = { self.BtnCollectionShowAll, self.BtnCollectionShowFriend, self.BtnCollectionShowSelf } + self.CollectionShowBtnGroup:Init(self.CollectionShowBtns, function(tabIndex) + self:OnCollectionShowBtnGroup(tabIndex) + end) +end +function XUiPanelSetting:OnCollectionShowBtnGroup(tabIndex) + if self.CollectionShowIndex and self.CollectionShowIndex == tabIndex then + return + end + self.CurAppearanceSetting.TitleType = tabIndex + self.CollectionShowIndex = tabIndex + self:CheckSave() +end + +--- +--- 成员涂装展示 +function XUiPanelSetting:InitFashionShowBtnGroup() + self.FashionShowBtns = { self.BtnFashionShowAll, self.BtnFashionShowFriend, self.BtnFashionShowSelf } + self.FashionShowBtnGroup:Init(self.FashionShowBtns, function(tabIndex) + self:OnFashionShowBtnGroup(tabIndex) + end) +end +function XUiPanelSetting:OnFashionShowBtnGroup(tabIndex) + if self.FashionShowIndex and self.FashionShowIndex == tabIndex then + return + end + self.CurAppearanceSetting.FashionType = tabIndex + self.FashionShowIndex = tabIndex + self:CheckSave() +end + +--- +--- 武器涂装展示 +function XUiPanelSetting:InitWeaponShowBtnGroup() + self.WeaponShowBtns = { self.BtnWeaponShowAll, self.BtnWeaponShowFriend, self.BtnWeaponShowSelf } + self.WeaponShowBtnGroup:Init(self.WeaponShowBtns, function(tabIndex) + self:OnWeaponShowBtnGroup(tabIndex) + end) +end +function XUiPanelSetting:OnWeaponShowBtnGroup(tabIndex) + if self.WeaponShowIndex and self.WeaponShowIndex == tabIndex then + return + end + self.CurAppearanceSetting.WeaponFashionType = tabIndex + self.WeaponShowIndex = tabIndex + self:CheckSave() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPlayer/XUiPlayer.lua b/Resources/Scripts/XUi/XUiPlayer/XUiPlayer.lua new file mode 100644 index 00000000..3ea8d9f3 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPlayer/XUiPlayer.lua @@ -0,0 +1,144 @@ +local XUiPlayer = XLuaUiManager.Register(XLuaUi, "UiPlayer") +local None = -1 +function XUiPlayer:OnStart(closeCb, selectIdx, achiveIdx,medalViewType) + self.TagPage = { + PlayerInfo = 1, + Achievement = 2, + Setting = 3, + Collect = 4, + } + self.SelectIdx = selectIdx + self.MedalViewType = medalViewType + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + self.BtnAchievement:SetDisable(not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.PlayerAchievement)) + self.TagBtns = { self.BtnPlayerInfo, self.BtnAchievement, self.BtnSetting, self.BtnCollect } + self.TabBtnGroup:Init(self.TagBtns, function(index) self:OnTabBtnGroup(index) end) + self.closeCb = closeCb + self.AchiveIdx = achiveIdx + + self.TabBtnGroup:SelectIndex(self.SelectIdx or self.TagPage.PlayerInfo) + XRedPointManager.AddRedPointEvent(self.ImgSetNameTag, self.OnCheckSetName, self, { XRedPointConditions.Types.CONDITION_PLAYER_SETNAME, XRedPointConditions.Types.CONDITION_HEADPORTRAIT_RED }) + XRedPointManager.AddRedPointEvent(self.BtnAchievement, self.OnCheckAcchiveRedPoint, self, { XRedPointConditions.Types.CONDITION_PLAYER_ACHIEVE }) + XRedPointManager.AddRedPointEvent(self.BtnCollect, self.OnCheckMedalRedPoint, self, { XRedPointConditions.Types.CONDITION_MEDAL_RED }) + -- 功能屏蔽 + self.BtnAchievement.gameObject:SetActiveEx(not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.PlayerAchievement)) +end + +function XUiPlayer:OnEnable() + -- 跳转到设置界面 + XEventManager.AddEventListener(XEventId.EVENT_PLAYER_SETTING, self.SelectSetting, self) +end + +function XUiPlayer:OnCheckSetName(count) + self.ImgSetNameTag.gameObject:SetActive(count >= 0) +end + +function XUiPlayer:OnCheckAcchiveRedPoint(count) + self.BtnAchievement:ShowReddot(count >= 0) +end + +function XUiPlayer:OnCheckMedalRedPoint(count) + self.BtnCollect:ShowReddot(count >= 0) +end + +function XUiPlayer:OnTabBtnGroup(index) + if self.NeedSave then + self:CheckSave(function() self:OnTabBtnGroup(index) end) + return + end + + -- 记录玩家信息界面的动画状态,避免切换界面后卡在动画中间 + if XLuaUiManager.IsUiShow("UiPanelPlayerInfo") then + self:FindChildUiObj("UiPanelPlayerInfo"):RecordAnimation() + end + + if index == self.TagPage.PlayerInfo then + self:ShowPanelPlayer() + elseif index == self.TagPage.Achievement then + if XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.PlayerAchievement) then + self:ShowPanelAchv() + end + elseif index == self.TagPage.Setting then + self:ShowSetting() + elseif index == self.TagPage.Collect then + self:ShowCollect() + end + self:PlayAnimation("QieHuan") +end + +function XUiPlayer:OnBtnMainUiClick() + if self.NeedSave then + self:CheckSave(function() self:OnBtnMainUiClick() end) + return + end + XLuaUiManager.RunMain() +end + +function XUiPlayer:OnBtnBackClick() + if self.NeedSave then + self:CheckSave(function() self:OnBtnBackClick() end) + return + end + + self:Close() + + if self.closeCb then + self.closeCb() + end +end + +function XUiPlayer:ShowPanelPlayer() + self:OpenOneChildUi("UiPanelPlayerInfo") +end + +function XUiPlayer:ShowPanelAchv() + self:OpenOneChildUi("UiPanelAchieve", self, self.AchiveIdx) + self.AchiveIdx = nil +end + +function XUiPlayer:ShowSetting() + self:OpenOneChildUi("UiPanelSetting", self) + self.UiPanelSetting:InitCollectionWallShow() + self.UiPanelSetting:UpdateCharacterHead() +end + +function XUiPlayer:ShowCollect() + local viewType = None + if XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.Collection) then + viewType = XMedalConfigs.ViewType.Collection + end + if XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.Medal) then + viewType = XMedalConfigs.ViewType.Medal + end + self:OpenOneChildUi("UiPanelMedal",self.MedalViewType or viewType) +end + +function XUiPlayer:CheckSave(cb) + self.NeedSave = false + XUiManager.DialogTip( + CS.XTextManager.GetText("TipTitle"), + CS.XTextManager.GetText("SaveShowSetting"), + XUiManager.DialogType.Normal, + function() + self.UiPanelSetting.CharacterList = XPlayer.ShowCharacters + self.UiPanelSetting:InitAppearanceSetting() + if cb then + cb() + end + end, + function() + self.UiPanelSetting:OnBtnSave() + if cb then + cb() + end + end) +end + +function XUiPlayer:SelectSetting() + self.TabBtnGroup:SelectIndex(self.TagPage.Setting) +end + +function XUiPlayer:OnDisable() + XEventManager.RemoveEventListener(XEventId.EVENT_PLAYER_SETTING, self.SelectSetting, self) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPlayerInfo/XUiEquipDetailChildOther.lua b/Resources/Scripts/XUi/XUiPlayerInfo/XUiEquipDetailChildOther.lua new file mode 100644 index 00000000..0656c2af --- /dev/null +++ b/Resources/Scripts/XUi/XUiPlayerInfo/XUiEquipDetailChildOther.lua @@ -0,0 +1,225 @@ +local CsXTextManager = CS.XTextManager + +local MAX_AWARENESS_ATTR_COUNT = 2 --不包括共鸣属性,最大有2条 +local XUiGridResonanceSkillOther = require("XUi/XUiPlayerInfo/XUiGridResonanceSkillOther") + +local XUiEquipDetailChildOther = XLuaUiManager.Register(XLuaUi, "UiEquipDetailChildOther") + +XUiEquipDetailChildOther.BtnTabIndex = { + SuitSkill = 1, + ResonanceSkill = 2, +} + +function XUiEquipDetailChildOther:OnAwake() + local tabGroupList = { + self.BtnSuitSkill, + self.BtnResonanceSkill, + } + self.TabGroupRight:Init(tabGroupList, function(tabIndex) self:OnClickTabCallBack(tabIndex) end) +end + +function XUiEquipDetailChildOther:OnStart(equip, character) + self.Equip = equip + self.EquipId = equip.Id + self.Character = character + self.TemplateId = equip.TemplateId + self.GridResonanceSkills = {} + + self:InitTabBtns() + self:InitClassifyPanel() + self:InitEquipInfo() +end + +function XUiEquipDetailChildOther:OnEnable() + self:UpdateEquipAttr() + self:UpdateEquipLevel() + self:UpdateEquipBreakThrough() + self:UpdateEquipSkillDes() + self:UpdateResonanceSkills() + + self.BtnLock.gameObject:SetActiveEx(false) + self.BtnUnlock.gameObject:SetActiveEx(false) + self.BtnLaJi.gameObject:SetActiveEx(false) + self.BtnUnLaJi.gameObject:SetActiveEx(false) +end + +function XUiEquipDetailChildOther:OnClickTabCallBack(tabIndex) + if tabIndex == XUiEquipDetailChildOther.BtnTabIndex.SuitSkill then + self.PanelSuitSkill.gameObject:SetActive(true) + self.PanelResonanceSkill.gameObject:SetActive(false) + self:UpdateEquipSkillDes() + self:PlayAnimation("SuitSkill") + elseif tabIndex == XUiEquipDetailChildOther.BtnTabIndex.ResonanceSkill then + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.EquipResonance) then + return + end + self.PanelSuitSkill.gameObject:SetActive(false) + self.PanelResonanceSkill.gameObject:SetActive(true) + self:UpdateResonanceSkills() + self:PlayAnimation("ResonanceSkill") + end +end + +function XUiEquipDetailChildOther:InitTabBtns() + if not XDataCenter.EquipManager.CanResonanceByTemplateId(self.TemplateId) then + self.BtnResonanceSkill.gameObject:SetActive(false) + self.BtnSuitSkill.gameObject:SetActive(false) + return + end + + self.TabGroupRight:SelectIndex(XUiEquipDetailChildOther.BtnTabIndex.SuitSkill) +end + +function XUiEquipDetailChildOther:InitClassifyPanel() + if XDataCenter.EquipManager.IsClassifyEqualByTemplateId(self.TemplateId, XEquipConfig.Classify.Weapon) then + self.TxtTitle.text = CsXTextManager.GetText("WeaponDetailTitle") + self.PanelPainter.gameObject:SetActive(false) + else + local breakthroughTimes = not self.IsPreview and XDataCenter.EquipManager.GetBreakthroughTimes(self.EquipId) or 0 + self.TxtPainter.text = XDataCenter.EquipManager.GetEquipPainterName(self.TemplateId, breakthroughTimes) + self.PanelPainter.gameObject:SetActive(true) + self.TxtTitle.text = CsXTextManager.GetText("AwarenessDetailTitle") + end +end + +function XUiEquipDetailChildOther:UpdateEquipSkillDes() + if XDataCenter.EquipManager.IsClassifyEqualByTemplateId(self.TemplateId, XEquipConfig.Classify.Weapon) then + local weaponSkillInfo = XDataCenter.EquipManager.GetOriginWeaponSkillInfo(self.TemplateId) + local noWeaponSkill = not weaponSkillInfo.Name and not weaponSkillInfo.Description + + self.TxtSkillName.text = weaponSkillInfo.Name + self.TxtSkillDes.text = weaponSkillInfo.Description + + self.PanelAwarenessSkillDes.gameObject:SetActive(false) + self.PanelNoAwarenessSkill.gameObject:SetActive(false) + self.PanelWeaponSkillDes.gameObject:SetActive(not noWeaponSkill) + self.PanelNoWeaponSkill.gameObject:SetActive(noWeaponSkill) + elseif XDataCenter.EquipManager.IsClassifyEqualByTemplateId(self.TemplateId, XEquipConfig.Classify.Awareness) then + local suitId = XDataCenter.EquipManager.GetSuitIdByTemplateId(self.TemplateId) + local skillDesList = XDataCenter.EquipManager.GetSuitSkillDesList(suitId) + + local noSuitSkill = true + for i = 1, XEquipConfig.MAX_SUIT_SKILL_COUNT do + if skillDesList[i * 2] then + self["TxtSkillDes" .. i].text = skillDesList[i * 2] + self["TxtSkillDes" .. i].gameObject:SetActive(true) + noSuitSkill = false + else + self["TxtSkillDes" .. i].gameObject:SetActive(false) + end + end + + self.PanelNoAwarenessSkill.gameObject:SetActive(noSuitSkill) + self.PanelAwarenessSkillDes.gameObject:SetActive(not noSuitSkill) + self.PanelWeaponSkillDes.gameObject:SetActive(false) + self.PanelNoWeaponSkill.gameObject:SetActive(false) + end +end + +function XUiEquipDetailChildOther:UpdateEquipLevel() + local level, levelLimit + + level = self.Equip.Level + levelLimit = XDataCenter.EquipManager.GetBreakthroughLevelLimitByEquipData(self.Equip) + + self.PanelMaxLevel.gameObject:SetActive((level >= levelLimit) and not XDataCenter.EquipManager.CanBreakThroughByEquipData(self.Equip)) + + if level and levelLimit then + self.TxtLevel.text = CsXTextManager.GetText("EquipLevelText", level, levelLimit) + end +end + +function XUiEquipDetailChildOther:UpdateEquipBreakThrough() + self:SetUiSprite(self.ImgBreakThrough, XEquipConfig.GetEquipBreakThroughIcon(self.Equip.Breakthrough)) +end + +function XUiEquipDetailChildOther:InitEquipInfo() + local star = XDataCenter.EquipManager.GetEquipStar(self.TemplateId) + for i = 1, XEquipConfig.MAX_STAR_COUNT do + if i <= star then + self["ImgStar" .. i].gameObject:SetActive(true) + else + self["ImgStar" .. i].gameObject:SetActive(false) + end + end + + self.TxtEquipName.text = XDataCenter.EquipManager.GetEquipName(self.TemplateId) + + local equipSite = XDataCenter.EquipManager.GetEquipSiteByTemplateId(self.TemplateId) + if equipSite ~= XEquipConfig.EquipSite.Weapon then + local breakthrough = 0 + + breakthrough = self.Equip.Breakthrough + self.RImgIcon:SetRawImage(XDataCenter.EquipManager.GetEquipIconBagPath(self.TemplateId, breakthrough)) + self.TxtPos.text = "0" .. equipSite + self.PanelPos.gameObject:SetActive(true) + self.RImgType.gameObject:SetActive(false) + else + self.RImgType:SetRawImage(XEquipConfig.GetWeaponTypeIconPath(self.TemplateId)) + self.RImgType.gameObject:SetActive(true) + self.PanelPos.gameObject:SetActive(false) + end + + local equipSpecialCharacterId = XDataCenter.EquipManager.GetEquipSpecialCharacterIdByTemplateId(self.TemplateId) + if equipSpecialCharacterId then + self.RImgHead:SetRawImage(XDataCenter.CharacterManager.GetCharSmallHeadIcon(equipSpecialCharacterId)) + self.PanelSpecialCharacter.gameObject:SetActive(true) + else + self.PanelSpecialCharacter.gameObject:SetActive(false) + end +end + +function XUiEquipDetailChildOther:UpdateEquipAttr() + local attrMap + + attrMap = XDataCenter.EquipManager.GetEquipAttrMapByEquipData(self.Equip) + + local attrCount = 1 + for _, attrInfo in pairs(attrMap) do + if attrCount > MAX_AWARENESS_ATTR_COUNT then break end + self["TxtName" .. attrCount].text = attrInfo.Name + self["TxtAttr" .. attrCount].text = attrInfo.Value + self["PanelAttr" .. attrCount].gameObject:SetActive(true) + attrCount = attrCount + 1 + end + for i = attrCount, MAX_AWARENESS_ATTR_COUNT do + self["PanelAttr" .. i].gameObject:SetActive(false) + end +end + +function XUiEquipDetailChildOther:UpdateResonanceSkills() + local count = 1 + local resonanceSkillNum = XDataCenter.EquipManager.GetResonanceSkillNumByTemplateId(self.TemplateId) + for pos = 1, resonanceSkillNum do + self["PanelSkill" .. pos].gameObject:SetActive(true) + self["PanelEmptySkill" .. pos].gameObject:SetActive(true) + count = count + 1 + self:UpdateResonanceSkill(pos) + end + for pos = count, XEquipConfig.MAX_RESONANCE_SKILL_COUNT do + self["PanelSkill" .. pos].gameObject:SetActive(false) + end +end + +function XUiEquipDetailChildOther:UpdateResonanceSkill(pos) + local grid = self.GridResonanceSkills[pos] + + if self.Equip.ResonanceInfo and self.Equip.ResonanceInfo[pos] then + if not grid then + local item = CS.UnityEngine.Object.Instantiate(self.GridResonanceSkill) + grid = XUiGridResonanceSkillOther.New(item, self.Equip, pos, false, self.Character, function() + XLuaUiManager.Open("UiEquipResonanceSkillDetailInfo", nil, pos, nil, nil, nil, true, true, self.Character, self.Equip) + end) + grid.Transform:SetParent(self["PanelSkill" .. pos], false) + self.GridResonanceSkills[pos] = grid + end + + grid:Refresh() + grid.GameObject:SetActive(true) + self["PanelEmptySkill" .. pos].gameObject:SetActive(false) + else + if grid then + grid.GameObject:SetActive(false) + end + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPlayerInfo/XUiEquipDetailOther.lua b/Resources/Scripts/XUi/XUiPlayerInfo/XUiEquipDetailOther.lua new file mode 100644 index 00000000..4e909712 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPlayerInfo/XUiEquipDetailOther.lua @@ -0,0 +1,88 @@ +local XUiEquipDetailOther = XLuaUiManager.Register(XLuaUi, "UiEquipDetailOther") + +function XUiEquipDetailOther:OnAwake() + self:InitAutoScript() +end + +-- equip : XEquip | XEquipViewModel +-- character : XCharacter | XCharacterViewModel +function XUiEquipDetailOther:OnStart(equip, character) + self.Equip = equip + self.Character = character + self.EquipId = equip.Id + self.CharacterId = character.Id + self.TemplateId = equip.TemplateId + + local sceneRoot = self.UiSceneInfo.Transform + local root = self.UiModelGo.transform + self.PanelWeapon = root:FindTransform("PanelWeapon") + self.PanelWeaponPlane = sceneRoot:FindTransform("Plane") + self.PanelWeaponPlane.gameObject:SetActiveEx(false) +end + +function XUiEquipDetailOther:OnEnable() + self:InitClassifyPanel() + + self:OpenOneChildUi("UiEquipDetailChildOther", self.Equip, self.Character) + self.ImgLihuiMask.gameObject:SetActiveEx(false) + self.BtnHelp.gameObject:SetActiveEx(false) + self.PanelTabGroup.gameObject:SetActiveEx(false) + self.PanelRole.gameObject:SetActiveEx(false) + self.PanelAsset.gameObject:SetActiveEx(false) +end + +function XUiEquipDetailOther:OnDestroy() + self.PanelWeaponPlane.gameObject:SetActiveEx(true) + if self.Resource then + CS.XResourceManager.Unload(self.Resource) + self.Resource = nil + end +end + +function XUiEquipDetailOther:InitClassifyPanel() + self.FxUiLihuiChuxian01.gameObject:SetActiveEx(false) + if XDataCenter.EquipManager.IsClassifyEqualByTemplateId(self.TemplateId, XEquipConfig.Classify.Weapon) then + local breakthroughTimes = self.Equip.Breakthrough + local resonanceCount = self.Equip.ResonanceInfo and (self.Equip.ResonanceInfo.Count or XTool.GetTableCount(self.Equip.ResonanceInfo)) or 0 + local modelConfig = XDataCenter.EquipManager.GetWeaponModelCfg(self.TemplateId, "UiEquipDetail", breakthroughTimes, resonanceCount) + + if modelConfig then + XModelManager.LoadWeaponModel(modelConfig.ModelId, self.PanelWeapon, modelConfig.TransformConfig, "UiEquipDetail", nil, { gameObject = self.GameObject }) + end + + self.PanelWeapon.gameObject:SetActiveEx(true) + self.ImgLihuiMask.gameObject:SetActiveEx(false) + elseif XDataCenter.EquipManager.IsClassifyEqualByTemplateId(self.TemplateId, XEquipConfig.Classify.Awareness) then + local breakthroughTimes = XDataCenter.EquipManager.GetBreakthroughTimes(self.EquipId) + + local resource = CS.XResourceManager.Load(XDataCenter.EquipManager.GetEquipLiHuiPath(self.TemplateId, breakthroughTimes)) + local texture = resource.Asset + self.MeshLihui.sharedMaterial:SetTexture("_MainTex", texture) + if self.Resource then + CS.XResourceManager.Unload(self.Resource) + end + self.Resource = resource + XScheduleManager.ScheduleOnce(function() + self.FxUiLihuiChuxian01.gameObject:SetActiveEx(true) + end, 500) + + self.PanelWeapon.gameObject:SetActiveEx(false) + end +end + +function XUiEquipDetailOther:InitAutoScript() + self:AutoAddListener() +end + +function XUiEquipDetailOther:AutoAddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainClick) +end + +function XUiEquipDetailOther:OnBtnBackClick() + self:Close() +end + +function XUiEquipDetailOther:OnBtnMainClick() + XLuaUiManager.RunMain() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPlayerInfo/XUiGridEquipOther.lua b/Resources/Scripts/XUi/XUiPlayerInfo/XUiGridEquipOther.lua new file mode 100644 index 00000000..9b173dd2 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPlayerInfo/XUiGridEquipOther.lua @@ -0,0 +1,102 @@ +local XUiGridEquipOther = XClass(nil, "XUiGridEquipOther") + +function XUiGridEquipOther:Ctor(ui, rootUi, clickCb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self.ClickCb = clickCb + self:InitAutoScript() +end + +function XUiGridEquipOther:Refresh(equip) + local templateId = equip.TemplateId + + if self.RImgIcon and self.RImgIcon:Exist() then + self.RImgIcon:SetRawImage(XDataCenter.EquipManager.GetEquipIconBagPath(templateId, equip.Breakthrough), nil, true) + end + + --通用的横条品质色 + if self.ImgQuality then + self.RootUi.Parent:SetUiSprite(self.ImgQuality, XDataCenter.EquipManager.GetEquipQualityPath(templateId)) + end + + --装备专用的竖条品质色 + if self.ImgEquipQuality then + self.RootUi.Parent:SetUiSprite(self.ImgEquipQuality, XDataCenter.EquipManager.GetEquipBgPath(templateId)) + end + + if self.TxtName then + self.TxtName.text = XDataCenter.EquipManager.GetEquipName(templateId) + end + + if self.TxtLevel then + self.TxtLevel.text = equip.Level + end + + if self.PanelSite and self.TxtSite then + local equipSite = XDataCenter.EquipManager.GetEquipSiteByEquipData(equip) + if equipSite and equipSite ~= XEquipConfig.EquipSite.Weapon then + self.TxtSite.text = "0" .. equipSite + self.PanelSite.gameObject:SetActiveEx(true) + else + self.PanelSite.gameObject:SetActiveEx(false) + end + end + + for i = 1, XEquipConfig.MAX_STAR_COUNT do + if self["ImgGirdStar" .. i] then + if i <= XDataCenter.EquipManager.GetEquipStar(templateId) then + self["ImgGirdStar" .. i].transform.parent.gameObject:SetActiveEx(true) + else + self["ImgGirdStar" .. i].transform.parent.gameObject:SetActiveEx(false) + end + end + end + + for i = 1, XEquipConfig.MAX_RESONANCE_SKILL_COUNT do + local obj = self["ImgResonance" .. i] + if obj then + if equip.ResonanceInfo and equip.ResonanceInfo[i] then + local icon = XEquipConfig.GetEquipResoanceIconPath(equip:IsEquipPosAwaken(i)) + self.RootUi.Parent:SetUiSprite(obj, icon) + obj.gameObject:SetActiveEx(true) + else + obj.gameObject:SetActiveEx(false) + end + end + end + + self:UpdateBreakthrough(equip) + +end + +function XUiGridEquipOther:UpdateBreakthrough(equip) + if XTool.UObjIsNil(self.ImgBreakthrough) then + return + end + + local icon + if equip.Breakthrough ~= 0 then + icon = XEquipConfig.GetEquipBreakThroughSmallIcon(equip.Breakthrough) + end + + if icon then + self.RootUi.Parent:SetUiSprite(self.ImgBreakthrough, icon) + self.ImgBreakthrough.gameObject:SetActiveEx(true) + else + self.ImgBreakthrough.gameObject:SetActiveEx(false) + end +end + +function XUiGridEquipOther:InitAutoScript() + XTool.InitUiObject(self) + CsXUiHelper.RegisterClickEvent(self.BtnClick,function() self:OnBtnClickClick() end) +end + +function XUiGridEquipOther:OnBtnClickClick() + if self.ClickCb then + self.ClickCb() + end +end + +return XUiGridEquipOther \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPlayerInfo/XUiGridResonanceSkillOther.lua b/Resources/Scripts/XUi/XUiPlayerInfo/XUiGridResonanceSkillOther.lua new file mode 100644 index 00000000..e0f07bb4 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPlayerInfo/XUiGridResonanceSkillOther.lua @@ -0,0 +1,130 @@ +local CsXTextManagerGetText = CS.XTextManager.GetText + +local XUiGridResonanceSkillOther = XClass(nil, "XUiGridResonanceSkillOther") + +local CONDITION_COLOR = { + [true] = XUiHelper.Hexcolor2Color("188649FF"), + [false] = XUiHelper.Hexcolor2Color("FF4E4EFF"), +} + +function XUiGridResonanceSkillOther:Ctor(ui, equip, pos, fromTip, character, clickCb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Equip = equip + self.EquipId = equip.Id + self.Pos = pos + self.FromTip = fromTip + self.Character = character + self.ClickCb = clickCb + self:InitAutoScript() +end + +function XUiGridResonanceSkillOther:InitAutoScript() + self:AutoInitUi() + XTool.InitUiObject(self) + self:AutoAddListener() +end + +function XUiGridResonanceSkillOther:AutoInitUi() + self.TxtSkillDes = XUiHelper.TryGetComponent(self.Transform, "TxtSkillDes", "Text") + self.TxtSkillName = XUiHelper.TryGetComponent(self.Transform, "TxtSkillName", "Text") + self.PanelBindCharacter = XUiHelper.TryGetComponent(self.Transform, "PanelBindCharacter", nil) + self.RImgHead = XUiHelper.TryGetComponent(self.Transform, "PanelBindCharacter/RImgHead", "RawImage") + self.RImgResonanceSkill = XUiHelper.TryGetComponent(self.Transform, "RImgResonanceSkill", "RawImage") + + self.BtnClick = XUiHelper.TryGetComponent(self.Transform, "BtnClick", "Button") +end + +function XUiGridResonanceSkillOther:Refresh() + local pos = self.Pos + local isAwakeDes = self.FromTip + + local skillInfo = XDataCenter.EquipManager.GetResonanceSkillInfoByEquipData(self.Equip, pos) + local bindCharacterId = XDataCenter.EquipManager.GetResonanceBindCharacterIdByEquipData(self.Equip, pos) + + if self.PanelBindCharacter and self.RImgHead then + if not isAwakeDes then + if bindCharacterId > 0 then + self.RImgHead:SetRawImage(XDataCenter.CharacterManager.GetCharBigRoundnessNotItemHeadIcon(bindCharacterId)) + self.PanelBindCharacter.gameObject:SetActiveEx(true) + else + self.PanelBindCharacter.gameObject:SetActiveEx(false) + end + else + self.PanelBindCharacter.gameObject:SetActiveEx(false) + end + end + + if self.TxtPos then + self.TxtPos.gameObject:SetActiveEx(false) + end + + if self.RImgResonanceSkill and skillInfo.Icon then + self.RImgResonanceSkill:SetRawImage(skillInfo.Icon) + end + + if self.TxtSkillName then + self.TxtSkillName.text = skillInfo.Name + end + + if self.TxtSkillDes then + self.TxtSkillDes.text = skillInfo.Description + self.TxtSkillDes.gameObject:SetActiveEx(not isAwakeDes) + end + + local isAwaken = self.Equip:IsEquipPosAwaken(pos) + if self.PanelAwaken then + self.PanelAwaken.gameObject:SetActiveEx(isAwaken) + end + + local notBindResonance = bindCharacterId ~= 0 and self.Character.Id ~= bindCharacterId + + if self.PanelAwakeSkills then + local awakeSkillDes = XDataCenter.EquipManager.GetAwakeSkillDesListByEquipData(self.Equip, pos) + for i = 1, XEquipConfig.AWAKE_SKILL_COUNT do + self["TxtAwakeSkill" .. i].text = awakeSkillDes[i] + end + self.PanelAwakeSkills.gameObject:SetActiveEx(true) + end + + if self.ImgNotResonance then + self.ImgNotResonance.gameObject:SetActiveEx(notBindResonance) + if self.PanelAwaken then + self.PanelAwaken.gameObject:SetActiveEx(not notBindResonance and isAwaken) + end + end + + if self.TxtAwake then + if isAwakeDes then + if bindCharacterId ~= 0 then + local characterName = XCharacterConfigs.GetCharacterTradeName(bindCharacterId) + self.TxtAwake.text = CsXTextManagerGetText("AwakeCharacterName", characterName) + self.TxtAwake.color = CONDITION_COLOR[not notBindResonance] + self.TxtAwake.gameObject:SetActiveEx(true) + else + self.TxtAwake.gameObject:SetActiveEx(false) + end + else + self.TxtAwake.gameObject:SetActiveEx(false) + end + end + +end + +function XUiGridResonanceSkillOther:AutoAddListener() + if self.BtnClick then + CsXUiHelper.RegisterClickEvent(self.BtnClick, function() + self:OnBtnClickClick() + end) + end +end + +function XUiGridResonanceSkillOther:OnBtnClickClick() + if self.Equip:IsEquipPosAwaken(self.Pos) then + if self.ClickCb then + self.ClickCb() + end + end +end + +return XUiGridResonanceSkillOther \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPlayerInfo/XUiGridSkillItemOther.lua b/Resources/Scripts/XUi/XUiPlayerInfo/XUiGridSkillItemOther.lua new file mode 100644 index 00000000..9ca9caab --- /dev/null +++ b/Resources/Scripts/XUi/XUiPlayerInfo/XUiGridSkillItemOther.lua @@ -0,0 +1,67 @@ +XUiGridSkillItemOther = XClass(nil, "XUiGridSkillItemOther") + +function XUiGridSkillItemOther:Ctor(rootUi, ui, skill, character, equipList, assignChapterRecords, cb) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.SkillInfo = skill + self.EquipList = equipList + self.Character = character + self.AssignChapterRecords = assignChapterRecords + self.ClickCallback = cb + self:InitAutoScript() + + self:UpdateInfo(self.SkillInfo) +end + +function XUiGridSkillItemOther:InitAutoScript() + self.SpecialSoundMap = {} + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiGridSkillItemOther:AutoInitUi() + self.TxtTotalPoint = XUiHelper.TryGetComponent(self.Transform, "TxtTotalPoint", "Text") + self.RImgSkillIcon = XUiHelper.TryGetComponent(self.Transform, "RImgSkillIcon", "RawImage") + self.BtnIconBg = XUiHelper.TryGetComponent(self.Transform, "BtnIconBg", "Button") + + self.PanelIconTip = XUiHelper.TryGetComponent(self.Transform, "PanelIconTip", nil) + self.PanelLock = XUiHelper.TryGetComponent(self.Transform, "PanelIconTip/PanelLock", nil) + self.ImgUpgradeTip = XUiHelper.TryGetComponent(self.Transform, "PanelIconTip/ImgUpgradeTip", "Image") +end + +function XUiGridSkillItemOther:AutoAddListener() + XUiHelper.RegisterClickEvent(self, self.BtnIconBg, self.OnBtnIconBgClick) +end + +function XUiGridSkillItemOther:OnBtnIconBgClick() + if self.ClickCallback then + self.ClickCallback() + end +end + +function XUiGridSkillItemOther:UpdateInfo(skill) + self.RImgSkillIcon:SetRawImage(skill.Icon) + + self.PanelLock.gameObject:SetActive(false) + self.ImgUpgradeTip.gameObject:SetActive(false) + if (skill.TotalLevel <= 0) then + self.PanelLock.gameObject:SetActive(true) + end + + local addLevel = 0 + local npcData = {Character = self.Character,Equips = self.EquipList} + + for _, skillId in pairs(skill.SkillIdList) do + local resonanceSkillLevelMap = XMagicSkillManager.GetResonanceSkillLevelMap(npcData) + local resonanceSkillLevel = resonanceSkillLevelMap[skillId] or 0 + + addLevel = addLevel + resonanceSkillLevel + XDataCenter.FubenAssignManager.GetSkillLevelByCharacterData(self.Character, skillId, self.AssignChapterRecords) + end + + if addLevel > 0 then + self.TxtTotalPoint.text = CS.XTextManager.GetText("CharacterResonanceSkillDes", skill.TotalLevel, addLevel) + else + self.TxtTotalPoint.text = CS.XTextManager.GetText("HostelDeviceLevel") .. ':' .. skill.TotalLevel + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPlayerInfo/XUiGridSubSkillOther.lua b/Resources/Scripts/XUi/XUiPlayerInfo/XUiGridSubSkillOther.lua new file mode 100644 index 00000000..cf8d5533 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPlayerInfo/XUiGridSubSkillOther.lua @@ -0,0 +1,91 @@ +local RESONANCED_GRID_TEXT_COLOR = { + [true] = XUiHelper.Hexcolor2Color("fee82aff"), + [false] = XUiHelper.Hexcolor2Color("ffffffff"), +} + +XUiGridSubSkillOther = XClass(nil, "XUiGridSubSkillOther") + +function XUiGridSubSkillOther:Ctor(ui, index, npcData,assignChapterRecords, callback) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Index = index + self.NpcaData = npcData + self.AssignChapterRecords = assignChapterRecords + self.ClickCallback = callback + self:InitAutoScript() + self:SetSelect(false) + self.PanelIconTip.gameObject:SetActive(true) + self.ImgUpgrade.gameObject:SetActiveEx(false) +end + +function XUiGridSubSkillOther:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiGridSubSkillOther:AutoInitUi() + self.TxtSubSkillLevel = XUiHelper.TryGetComponent(self.Transform, "ImgLevelBg/TxtSubSkillLevel", "Text") + self.PanelIconTip = XUiHelper.TryGetComponent(self.Transform, "PanelIconTip", nil) + self.ImgUpgrade = XUiHelper.TryGetComponent(self.Transform, "PanelIconTip/ImgUpgrade", "Image") + self.ImgLock = XUiHelper.TryGetComponent(self.Transform, "PanelIconTip/ImgLock") + self.ImgBgSelected = XUiHelper.TryGetComponent(self.Transform, "ImgBgSelected", "Image") + self.RImgSubSkillIconSelected = XUiHelper.TryGetComponent(self.Transform, "ImgBgSelected/RImgSubSkillIconSelected", "RawImage") + self.RImgSubSkillIconNormal = XUiHelper.TryGetComponent(self.Transform, "RImgSubSkillIconNormal", "RawImage") + self.BtnSubSkillIconBg = XUiHelper.TryGetComponent(self.Transform, "BtnSubSkillIconBg", "Button") +end + +function XUiGridSubSkillOther:AutoAddListener() + XUiHelper.RegisterClickEvent(self, self.BtnSubSkillIconBg, self.OnBtnSubSkillIconBgClick) +end + +function XUiGridSubSkillOther:OnBtnSubSkillIconBgClick() + if (self.ClickCallback) then + self.ClickCallback(self.SubSkillInfo, self.Index) + end +end + +function XUiGridSubSkillOther:UpdateGrid(subSkillInfo) + self.SubSkillInfo = subSkillInfo + + if (subSkillInfo.configDes.Icon and subSkillInfo.configDes.Icon ~= "") then + self.RImgSubSkillIconNormal:SetRawImage(subSkillInfo.configDes.Icon) + self.RImgSubSkillIconSelected:SetRawImage(subSkillInfo.configDes.Icon) + else + XLog.Warning("sub skill config icon is null. id = " .. subSkillInfo.SubSkillId) + end + + local addLevel = 0 + local resonanceSkillLevelMap = XMagicSkillManager.GetResonanceSkillLevelMap(self.NpcaData) + local resonanceSkillLevel = resonanceSkillLevelMap[subSkillInfo.SubSkillId] or 0 + addLevel = addLevel + resonanceSkillLevel + XDataCenter.FubenAssignManager.GetSkillLevelByCharacterData(self.NpcaData.Character, subSkillInfo.SubSkillId, self.AssignChapterRecords) + + local totalLevel = subSkillInfo.Level + addLevel + local curLevel = totalLevel == 0 and '' or CS.XTextManager.GetText("HostelDeviceLevel") .. ':' .. totalLevel + self.TxtSubSkillLevel.color = RESONANCED_GRID_TEXT_COLOR[addLevel > 0] + self.TxtSubSkillLevel.text = curLevel + + local min_max = XCharacterConfigs.GetSubSkillMinMaxLevel(subSkillInfo.SubSkillId) + if (subSkillInfo.Level >= min_max.Max) then + self.ImgLock.gameObject:SetActive(false) + else + self.ImgLock.gameObject:SetActive(subSkillInfo.Level <= 0) + end + self.GameObject:SetActive(true) +end + +function XUiGridSubSkillOther:SetSelect(isSelect) + if (self.ImgBgSelected) then + self.ImgBgSelected.gameObject:SetActive(isSelect) + end +end + +function XUiGridSubSkillOther:Reset() + self.SubSkillInfo = nil + self.GameObject:SetActive(false) + self:SetSelect(false) +end + +function XUiGridSubSkillOther:ResetSelect(subSkillId) + self:SetSelect(self.SubSkillInfo and self.SubSkillInfo.SubSkillId == subSkillId) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPlayerInfo/XUiPanelCharAllOther.lua b/Resources/Scripts/XUi/XUiPlayerInfo/XUiPanelCharAllOther.lua new file mode 100644 index 00000000..59c6ee7a --- /dev/null +++ b/Resources/Scripts/XUi/XUiPlayerInfo/XUiPanelCharAllOther.lua @@ -0,0 +1,114 @@ +XUiPanelCharAllOther = XClass(nil, "XUiPanelCharAllOther") + +local XUiGridEquipOther = require("XUi/XUiPlayerInfo/XUiGridEquipOther") + +-- partner : XPartner +function XUiPanelCharAllOther:Ctor(ui,parent,character,equipList,assignChapterRecords, partner) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Parent = parent + self.Character = character + self.EquipList = equipList + self.AssignChapterRecords = assignChapterRecords + -- XPartner + self.Partner = partner + + XTool.InitUiObject(self) + self:AddListener() +end + +function XUiPanelCharAllOther:AddListener() + CsXUiHelper.RegisterClickEvent(self.BtnWeaponReplace, function() self:OnBtnWeaponReplaceClick() end) + CsXUiHelper.RegisterClickEvent(self.BtnCarryPartner, function() self:OnBtnCarryPartnerClicked() end) +end + +-- partner : XPartner +function XUiPanelCharAllOther:ShowPanel(character, weapon, awareness, partner) + self.Character = character + self.CharacterId = character.Id + self.Weapon = weapon + self.Awareness = awareness + self.Partner = partner + + self.GameObject:SetActive(true) + self:UpdatePanel(character, weapon, awareness, partner) + self.RImgPartnerIcon.gameObject:SetActiveEx(partner ~= nil) + if partner then + self.RImgPartnerIcon:SetRawImage(partner:GetIcon()) + end +end + +function XUiPanelCharAllOther:HidePanel() + self.GameObject:SetActive(false) +end + +-- partner : XPartner +function XUiPanelCharAllOther:UpdatePanel(character, weapon, awareness, partner) + local charConfig = XCharacterConfigs.GetCharacterTemplate(self.CharacterId) + local detailConfig = XCharacterConfigs.GetCharDetailTemplate(self.CharacterId) + + self.TxtName.text = charConfig.Name + self.TxtNameOther.text = charConfig.TradeName + self.RImgTypeIcon:SetRawImage(XCharacterConfigs.GetNpcTypeIcon(character.Type)) + + local ability = XDataCenter.CharacterManager.GetCharacterAbilityOther(character, self.EquipList, self.AssignChapterRecords, partner) + self.TxtLv.text = math.floor(ability) + + local elementList = detailConfig.ObtainElementList + for i = 1, 3 do + local rImg = self["RImgCharElement" .. i] + if elementList[i] then + rImg.gameObject:SetActive(true) + local elementConfig = XCharacterConfigs.GetCharElement(elementList[i]) + rImg:SetRawImage(elementConfig.Icon) + else + rImg.gameObject:SetActive(false) + end + end + + self.WeaponGrid = self.WeaponGrid or XUiGridEquipOther.New(self.GridWeapon, self) + self.WeaponGrid:Refresh(weapon) + + self.WearingAwarenessGrids = self.WearingAwarenessGrids or {} + for _, equipSite in pairs(XEquipConfig.EquipSite.Awareness) do + + local equip + for _, v in pairs(awareness) do + if XDataCenter.EquipManager.GetEquipSiteByEquipData(v) == equipSite then + equip = v + end + end + + self.WearingAwarenessGrids[equipSite] = self.WearingAwarenessGrids[equipSite] + or XUiGridEquipOther.New(CS.UnityEngine.Object.Instantiate(self.GridAwareness), self, function() + XLuaUiManager.Open("UiEquipDetailOther", equip, self.Character) + end) + + self.WearingAwarenessGrids[equipSite].Transform:SetParent(self["PanelAwareness" .. equipSite], false) + + if not equip then + self.WearingAwarenessGrids[equipSite].GameObject:SetActive(false) + self["PanelNoAwareness" .. equipSite].gameObject:SetActive(true) + else + self.WearingAwarenessGrids[equipSite].GameObject:SetActive(true) + self["PanelNoAwareness" .. equipSite].gameObject:SetActive(false) + self.WearingAwarenessGrids[equipSite]:Refresh(equip) + end + end +end + +function XUiPanelCharAllOther:OnBtnWeaponReplaceClick() + XLuaUiManager.Open("UiEquipDetailOther", self.Weapon, self.Character) +end + +function XUiPanelCharAllOther:OnBtnCarryPartnerClicked() + if self.Partner == nil then + XUiManager.TipError(CS.XTextManager.GetText("PartnerUnequipped")) + return + end + -- -- 检查该玩家是否满足开启伙伴系统的等级功能 + -- if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.Partner) then + -- return + -- end + XLuaUiManager.Open("UiPartnerPropertyOther", self.Partner) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPlayerInfo/XUiPanelCharGradeOther.lua b/Resources/Scripts/XUi/XUiPlayerInfo/XUiPanelCharGradeOther.lua new file mode 100644 index 00000000..5e232964 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPlayerInfo/XUiPanelCharGradeOther.lua @@ -0,0 +1,190 @@ +XUiPanelCharGradeOther = XClass(nil, "XUiPanelCharGradeOther") + +local Show_Part = { + [1] = XNpcAttribType.Life, + [2] = XNpcAttribType.AttackNormal, + [3] = XNpcAttribType.DefenseNormal, + [4] = XNpcAttribType.Crit, +} + +function XUiPanelCharGradeOther:Ctor(ui, parent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Parent = parent + self:InitAutoScript() + + self.Star = { self.ImgStar1, self.ImgStar2, self.ImgStar3, self.ImgStar4 } + self.OnStar = { self.ImgOnStar1, self.ImgOnStar2, self.ImgOnStar3, self.ImgOnStar4 } + + self.Grading = { + Recruit = 1, --新兵 + RecruitStar = 1, --新兵最大等级 + Picked = 2, --精锐 + PickedStar = 3, --精锐最大等级 + MainForce = 3, --主力 + MainForceStar = 6, --主力最大等级 + Ace = 3, --王牌 + AceStar = 9, --王牌最大等级 + TheChosen = 4, --天选 + TheChosenStar = 13, --天选最大等级 + } + + self.TxtAttrib = { + [1] = self.TxtAttrib1, + [2] = self.TxtAttrib2, + [3] = self.TxtAttrib3, + [4] = self.TxtAttrib4 + } + + self.TxtNormal = { + [1] = self.TxtNormal1A, + [2] = self.TxtNormal2A, + [3] = self.TxtNormal3A, + [4] = self.TxtNormal4A + } +end + +function XUiPanelCharGradeOther:InitAutoScript() + self:AutoInitUi() + XTool.InitUiObject(self) +end + +function XUiPanelCharGradeOther:AutoInitUi() + self.PanelParts = self.Transform:Find("PanelGrades/PanelParts") + self.DetailPanel = self.Transform:Find("PanelGrades/DetailPanel") + self.ImgMax1 = self.Transform:Find("PanelGrades/ImgMax1"):GetComponent("Image") + self.PanelStarGoup = self.Transform:Find("PanelGrades/PanelGrade/PanelStarGoup") + self.PanelPartsItems = self.Transform:Find("PanelGrades/PanelParts/PanelPartsItems") + self.RImgIconTitle = self.Transform:Find("PanelGrades/PanelGrade/RImgIconTitle"):GetComponent("RawImage") + self.TxtCurPorperty = self.Transform:Find("PanelGrades/PanelParts/TxtCurPorperty") + self.TxtPropertyPreview = self.Transform:Find("PanelGrades/PanelParts/TxtPropertyPreview") + + self.GridPart1 = self.Transform:Find("PanelGrades/PanelParts/PanelPartsItems/GridPart1") + self.TxtAttrib1 = self.Transform:Find("PanelGrades/PanelParts/PanelPartsItems/GridPart1/Image/TxtAttrib1"):GetComponent("Text") + self.TxtNormal1A = self.Transform:Find("PanelGrades/PanelParts/PanelPartsItems/GridPart1/Image/TxtNormal1"):GetComponent("Text") + self.TxtLevel1A = self.Transform:Find("PanelGrades/PanelParts/PanelPartsItems/GridPart1/Image/TxtLevel1"):GetComponent("Text") + + self.GridPart2 = self.Transform:Find("PanelGrades/PanelParts/PanelPartsItems/GridPart2") + self.TxtAttrib2 = self.Transform:Find("PanelGrades/PanelParts/PanelPartsItems/GridPart2/Image/TxtAttrib2"):GetComponent("Text") + self.TxtNormal2A = self.Transform:Find("PanelGrades/PanelParts/PanelPartsItems/GridPart2/Image/TxtNormal2"):GetComponent("Text") + self.TxtLevel2A = self.Transform:Find("PanelGrades/PanelParts/PanelPartsItems/GridPart2/Image/TxtLevel2"):GetComponent("Text") + + self.GridPart3 = self.Transform:Find("PanelGrades/PanelParts/PanelPartsItems/GridPart3") + self.TxtAttrib3 = self.Transform:Find("PanelGrades/PanelParts/PanelPartsItems/GridPart3/Image/TxtAttrib3"):GetComponent("Text") + self.TxtNormal3A = self.Transform:Find("PanelGrades/PanelParts/PanelPartsItems/GridPart3/Image/TxtNormal3"):GetComponent("Text") + self.TxtLevel3A = self.Transform:Find("PanelGrades/PanelParts/PanelPartsItems/GridPart3/Image/TxtLevel3"):GetComponent("Text") + + self.GridPart4 = self.Transform:Find("PanelGrades/PanelParts/PanelPartsItems/GridPart4") + self.TxtAttrib4 = self.Transform:Find("PanelGrades/PanelParts/PanelPartsItems/GridPart4/Image/TxtAttrib4"):GetComponent("Text") + self.TxtNormal4A = self.Transform:Find("PanelGrades/PanelParts/PanelPartsItems/GridPart4/Image/TxtNormal4"):GetComponent("Text") + self.TxtLevel4A = self.Transform:Find("PanelGrades/PanelParts/PanelPartsItems/GridPart4/Image/TxtLevel4"):GetComponent("Text") + + self.ImgStar1 = self.Transform:Find("PanelGrades/PanelGrade/PanelStarGoup/Star1/ImgStar1"):GetComponent("Image") + self.ImgOnStar1 = self.Transform:Find("PanelGrades/PanelGrade/PanelStarGoup/Star1/ImgOnStar1"):GetComponent("Image") + + self.ImgStar2 = self.Transform:Find("PanelGrades/PanelGrade/PanelStarGoup/Star2/ImgStar2"):GetComponent("Image") + self.ImgOnStar2 = self.Transform:Find("PanelGrades/PanelGrade/PanelStarGoup/Star2/ImgOnStar2"):GetComponent("Image") + + self.ImgStar3 = self.Transform:Find("PanelGrades/PanelGrade/PanelStarGoup/Star3/ImgStar3"):GetComponent("Image") + self.ImgOnStar3 = self.Transform:Find("PanelGrades/PanelGrade/PanelStarGoup/Star3/ImgOnStar3"):GetComponent("Image") + + self.ImgStar4 = self.Transform:Find("PanelGrades/PanelGrade/PanelStarGoup/Star4/ImgStar4"):GetComponent("Image") + self.ImgOnStar4 = self.Transform:Find("PanelGrades/PanelGrade/PanelStarGoup/Star4/ImgOnStar4"):GetComponent("Image") + + self.PanelGradeUpgrade = self.Transform:Find("PanelGradeUpgrade") +end + +function XUiPanelCharGradeOther:ShowPanel(character) + self.GameObject:SetActiveEx(true) + self.PanelPartsItems.gameObject:SetActiveEx(true) + self.TxtCurPorperty.gameObject:SetActiveEx(true) + + self.DetailPanel.gameObject:SetActiveEx(false) + self.TxtLevel1A.gameObject:SetActiveEx(false) + self.TxtLevel2A.gameObject:SetActiveEx(false) + self.TxtLevel3A.gameObject:SetActiveEx(false) + self.TxtLevel4A.gameObject:SetActiveEx(false) + self.TxtPropertyPreview.gameObject:SetActiveEx(false) + self.PanelGradeUpgrade.gameObject:SetActiveEx(false) + self.GradeQiehuan:PlayTimelineAnimation() + + self:UpdateGradeData(character) +end + +function XUiPanelCharGradeOther:HidePanel() + self.GameObject:SetActiveEx(false) +end + +function XUiPanelCharGradeOther:UpdateGradeData(character) + local curGradeConfig = XCharacterConfigs.GetGradeTemplates(character.Id, character.Grade) + local curAttrib = XAttribManager.GetBaseAttribs(curGradeConfig.AttrId) + self.RImgIconTitle:SetRawImage(curGradeConfig.GradeBigIcon) + self:UpdateStarSprite(curGradeConfig.NoStar, curGradeConfig.Star) + + for i = 1, 4 do + local name = XAttribManager.GetAttribNameByIndex(Show_Part[i]) + local attribType = Show_Part[i] + self.TxtAttrib[i].text = name + self.TxtNormal[i].text = XMath.ToMinInt(FixToDouble(curAttrib[attribType])) + end + + if character.Grade > self.Grading.TheChosenStar then + self:UpdateStarInfo(self.Grading.TheChosen, character.Grade - self.Grading.AceStar) + return + end + + if character.Grade > self.Grading.AceStar then + self:UpdateStarInfo(self.Grading.TheChosen, character.Grade - self.Grading.AceStar) + return + end + + if character.Grade > self.Grading.MainForceStar then + self:UpdateStarInfo(self.Grading.Ace, character.Grade - self.Grading.MainForceStar) + return + end + + if character.Grade > self.Grading.PickedStar then + self:UpdateStarInfo(self.Grading.MainForce, character.Grade - self.Grading.PickedStar) + return + end + + if character.Grade > self.Grading.RecruitStar then + self:UpdateStarInfo(self.Grading.Picked, character.Grade - self.Grading.RecruitStar) + return + end + + if character.Grade <= self.Grading.RecruitStar then + self:UpdateStarInfo(self.Grading.Recruit, character.Grade) + return + end +end + +function XUiPanelCharGradeOther:UpdateStarSprite(starSprite, onStarSprite) + for i = 1, #self.Star do + self.Parent:SetUiSprite(self.Star[i], starSprite) + self.Parent:SetUiSprite(self.OnStar[i], onStarSprite) + end +end + +function XUiPanelCharGradeOther:UpdateStarInfo(index, onIndex) + for i = 1, #self.Star do + self.Star[i].gameObject:SetActiveEx(false) + self.OnStar[i].gameObject:SetActiveEx(false) + end + + if onIndex > #self.Star then + for i = 1, #self.Star do + self.Star[i].gameObject:SetActiveEx(false) + self.OnStar[i].gameObject:SetActiveEx(true) + end + return + end + + for i = 1, index do + self.Star[i].gameObject:SetActiveEx(true) + end + + for i = 1, onIndex do + self.OnStar[i].gameObject:SetActiveEx(true) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPlayerInfo/XUiPanelCharLevelOther.lua b/Resources/Scripts/XUi/XUiPlayerInfo/XUiPanelCharLevelOther.lua new file mode 100644 index 00000000..ee1a81ea --- /dev/null +++ b/Resources/Scripts/XUi/XUiPlayerInfo/XUiPanelCharLevelOther.lua @@ -0,0 +1,46 @@ +XUiPanelCharLevelOther = XClass(nil, "XUiPanelCharLevelOther") + +function XUiPanelCharLevelOther:Ctor(ui, parent, character, equipList,assignChapterRecords) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Parent = parent + self.Character = character + self.EquipList = equipList + self.AssignChapterRecords = assignChapterRecords + + XTool.InitUiObject(self) +end + +function XUiPanelCharLevelOther:ShowPanel(character) + self.GameObject:SetActive(true) + self.PanelLeveInfo.gameObject:SetActive(true) + + self.PanelSelectLevelItems.gameObject:SetActiveEx(false) + self.BtnLiberation.gameObject:SetActiveEx(false) + self.ImgMaxLevel.gameObject:SetActiveEx(false) + self.BtnLevelUpButton.gameObject:SetActiveEx(false) + + self.LeveInfoQiehuan:PlayTimelineAnimation() + self:UpdatePanel(character) +end + +function XUiPanelCharLevelOther:HidePanel() + self.GameObject:SetActive(false) +end + +function XUiPanelCharLevelOther:UpdatePanel(character) + local characterId = character.Id + local nextLeveExp = XCharacterConfigs.GetNextLevelExp(characterId, character.Level) + + self.TxtCurLevel.text = character.Level + self.TxtMaxLevel.text = "/" .. XCharacterConfigs.GetCharMaxLevel(characterId) + self.TxtExp.text = character.Exp .. "/" .. nextLeveExp + self.ImgFill.fillAmount = character.Exp / nextLeveExp + + character.Attribs = XDataCenter.CharacterManager.GetCharacterAttribsOther(character, self.EquipList, self.AssignChapterRecords) + + self.TxtAttack.text = FixToInt(character.Attribs[XNpcAttribType.AttackNormal]) + self.TxtLife.text = FixToInt(character.Attribs[XNpcAttribType.Life]) + self.TxtDefense.text = FixToInt(character.Attribs[XNpcAttribType.DefenseNormal]) + self.TxtCrit.text = FixToInt(character.Attribs[XNpcAttribType.Crit]) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPlayerInfo/XUiPanelCharPropertyOther.lua b/Resources/Scripts/XUi/XUiPlayerInfo/XUiPanelCharPropertyOther.lua new file mode 100644 index 00000000..49d61b72 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPlayerInfo/XUiPanelCharPropertyOther.lua @@ -0,0 +1,181 @@ +local XUiPanelCharPropertyOther = XLuaUiManager.Register(XLuaUi, "UiPanelCharPropertyOther") + +local PANEL_INDEX = { + All = 1, + Level = 2, + Grade = 3, + Quality = 4, + Skill = 5, +} +local DEFAULT_INDEX = 1 + +function XUiPanelCharPropertyOther:OnAwake() + self:AddListener() + -- XPartner + self.Partner = nil +end + +-- partner : XPartner +function XUiPanelCharPropertyOther:OnStart(character, equipList, weaponFashionId, assignChapterRecords, partner) + self.Character = character + self.EquipList = equipList + self.WeaponFashionId = weaponFashionId + self.AssignChapterRecords = assignChapterRecords + self.Partner = partner + + --把服务器发来的装备数据分成武器与意识 + self.Awareness = {} + for _, v in pairs(equipList) do + if XDataCenter.EquipManager.IsClassifyEqualByTemplateId(v.TemplateId, XEquipConfig.Classify.Weapon) then + self.Weapon = v + else + table.insert(self.Awareness, v) + end + end + + self:InitSceneRoot() + self:InitChildUiInfos() + self:InitBtnTabGroup() +end + +function XUiPanelCharPropertyOther:OnEnable() + self.PanelPropertyButtons:SelectIndex(DEFAULT_INDEX) + self:UpdateSceneAndModel() +end + +function XUiPanelCharPropertyOther:AddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) +end + +function XUiPanelCharPropertyOther:InitSceneRoot() + local root = self.UiModelGo.transform + + self.PanelRoleModel = root:FindTransform("PanelRoleModel") + self.RoleModelPanel = XUiPanelRoleModel.New(self.PanelRoleModel, self.Name, nil, true, nil, true) +end + +function XUiPanelCharPropertyOther:OnBtnBackClick() + if self:RecoveryPanel() then + return + end + self:Close() +end + +function XUiPanelCharPropertyOther:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiPanelCharPropertyOther:InitChildUiInfos() + --总览面板不是不是预制体 + local panelAll = XUiPanelCharAllOther.New(self.PanelOwnedInfoOther, self, self.Character, self.EquipList, self.AssignChapterRecords, self.Partner) + self.PanelsMap = { + [PANEL_INDEX.All] = panelAll + } + -- AsstPath在配表中的配置没有总览面板,所以获取其他面板路径要索引减1 + self.ChildUiInitInfos = { + [PANEL_INDEX.All] = { + ChildClass = XUiPanelCharAllOther, + UiParent = self.PanelOwnedInfoOther, + }, + [PANEL_INDEX.Level] = { + ChildClass = XUiPanelCharLevelOther, + UiParent = self.PanelCharLevelOther, + AssetPath = XUiConfigs.GetComponentUrl("UiPanelCharProperty".. PANEL_INDEX.Level-1), + }, + [PANEL_INDEX.Grade] = { + ChildClass = XUiPanelCharGradeOther, + UiParent = self.PanelCharGradeOther, + AssetPath = XUiConfigs.GetComponentUrl("UiPanelCharProperty" .. PANEL_INDEX.Grade-1), + }, + [PANEL_INDEX.Quality] = { + ChildClass = XUiPanelCharQualityOther, + UiParent = self.PanelCharQualityOther, + AssetPath = XUiConfigs.GetComponentUrl("UiPanelCharProperty" .. PANEL_INDEX.Quality-1), + }, + [PANEL_INDEX.Skill] = { + ChildClass = XUiPanelCharSkillOther, + UiParent = self.PanelCharSkillOther, + AssetPath = XUiConfigs.GetComponentUrl("UiPanelCharProperty" .. PANEL_INDEX.Skill-1), + }, + } +end + +function XUiPanelCharPropertyOther:InitBtnTabGroup() + self.BtnTabGrade.gameObject:SetActiveEx(not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.CharacterGrade)) + self.BtnTabQuality.gameObject:SetActiveEx(not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.CharacterQuality)) + self.BtnTabSkill.gameObject:SetActiveEx(not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.CharacterSkill)) + self.BtnTabLevel.gameObject:SetActiveEx(not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.CharacterLevelUp)) + + local tabGroup = { + [PANEL_INDEX.All] = self.BtnTabAll, + [PANEL_INDEX.Level] = self.BtnTabLevel, + [PANEL_INDEX.Grade] = self.BtnTabGrade, + [PANEL_INDEX.Quality] = self.BtnTabQuality, + [PANEL_INDEX.Skill] = self.BtnTabSkill, + } + self.PanelPropertyButtons:Init(tabGroup, function(tabIndex) self:OnClickTabCallBack(tabIndex) end) +end + +function XUiPanelCharPropertyOther:OnClickTabCallBack(tabIndex) + self.SelectedIndex = tabIndex + self:UpdateShowPanel() +end + +function XUiPanelCharPropertyOther:UpdateShowPanel() + local index = self.SelectedIndex + + for k, panel in pairs(self.PanelsMap) do + if k ~= index then + panel:HidePanel() + end + end + + local panel = self.PanelsMap[index] + if not panel then + local childUiInfo = self.ChildUiInitInfos[index] + local ui = childUiInfo.UiParent:LoadPrefab(childUiInfo.AssetPath) + if self.SelectedIndex == PANEL_INDEX.Skill or self.SelectedIndex == PANEL_INDEX.Level then + panel = childUiInfo.ChildClass.New(ui, self, self.Character, self.EquipList, self.AssignChapterRecords) + else + panel = childUiInfo.ChildClass.New(ui, self) + end + self.PanelsMap[index] = panel + end + if self.SelectedIndex == PANEL_INDEX.All then + panel:ShowPanel(self.Character, self.Weapon, self.Awareness, self.Partner) + elseif self.SelectedIndex == PANEL_INDEX.Skill then + panel:ShowPanel(self.Character, self.EquipList) + else + panel:ShowPanel(self.Character) + end + +end + +function XUiPanelCharPropertyOther:UpdateSceneAndModel() + local sceneUrl = self:GetSceneUrl() + local modelUrl = self:GetDefaultUiModelUrl() + self:LoadUiScene(sceneUrl, modelUrl, nil, false) + + self.RoleModelPanel:UpdateCharacterModelOther(self.Character, self.Weapon, self.WeaponFashionId, self.PanelRoleModel, XModelManager.MODEL_UINAME.XUiCharacter, function(model) + self.PanelDrag.Target = model.transform + end) +end + +function XUiPanelCharPropertyOther:GetSceneUrl() + local fashionId = self.Character.FashionId or + XCharacterConfigs.GetCharacterTemplate(self.Character.Id).DefaultNpcFashtionId + local sceneUrl = XDataCenter.FashionManager.GetFashionSceneUrl(fashionId) + return sceneUrl or self:GetDefaultSceneUrl() +end + +function XUiPanelCharPropertyOther:RecoveryPanel() + local skillPanel = self.PanelsMap[PANEL_INDEX.Skill] + + if skillPanel and skillPanel.SkillInfoPanel.IsShow then + skillPanel.SkillInfoPanel:HidePanel() + skillPanel:ShowPanel(self.Character, self.EquipList) + return true + end + return false +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPlayerInfo/XUiPanelCharQualityOther.lua b/Resources/Scripts/XUi/XUiPlayerInfo/XUiPanelCharQualityOther.lua new file mode 100644 index 00000000..1aeca5ef --- /dev/null +++ b/Resources/Scripts/XUi/XUiPlayerInfo/XUiPanelCharQualityOther.lua @@ -0,0 +1,165 @@ +XUiPanelCharQualityOther = XClass(nil, "XUiPanelCharQualityOther") + +function XUiPanelCharQualityOther:Ctor(ui, parent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Parent = parent + self:InitAutoScript() + self:InitIcon() +end + +function XUiPanelCharQualityOther:InitAutoScript() + self:AutoInitUi() + XTool.InitUiObject(self) +end + +function XUiPanelCharQualityOther:AutoInitUi() + self.PanelQualityUpgrade = self.Transform:Find("PanelQualityUpgrade") + self.PanelWaferIcon = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon") + + self.ImgLine1 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/Bg/ImgLine1"):GetComponent("Image") + self.ImgLine2 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/Bg/ImgLine2"):GetComponent("Image") + self.ImgLine3 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/Bg/ImgLine3"):GetComponent("Image") + self.ImgLine4 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/Bg/ImgLine4"):GetComponent("Image") + self.ImgLine5 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/Bg/ImgLine5"):GetComponent("Image") + self.ImgLine6 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/Bg/ImgLine6"):GetComponent("Image") + self.ImgLine7 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/Bg/ImgLine7"):GetComponent("Image") + self.ImgLine8 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/Bg/ImgLine8"):GetComponent("Image") + self.ImgLine9 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/Bg/ImgLine9"):GetComponent("Image") + self.ImgLine10 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/Bg/ImgLine10"):GetComponent("Image") + + self.ImgWaferColour1 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon1/ImgWaferColour1"):GetComponent("Image") + self.ImgSelect1 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon1/ImgSelect1"):GetComponent("Image") + self.ImgWaferon1 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon1/ImgWaferon1"):GetComponent("Image") + self.TxtWaferName1 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon1/TxtWaferName1"):GetComponent("Text") + self.PanelHint1 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon1/PanelHint1") + + self.ImgWaferColour2 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon2/ImgWaferColour2"):GetComponent("Image") + self.ImgSelect2 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon2/ImgSelect2"):GetComponent("Image") + self.ImgWaferon2 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon2/ImgWaferon2"):GetComponent("Image") + self.TxtWaferName2 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon2/TxtWaferName2"):GetComponent("Text") + self.PanelHint2 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon2/PanelHint2") + + self.ImgWaferColour3 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon3/ImgWaferColour3"):GetComponent("Image") + self.ImgSelect3 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon3/ImgSelect3"):GetComponent("Image") + self.ImgWaferon3 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon3/ImgWaferon3"):GetComponent("Image") + self.TxtWaferName3 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon3/TxtWaferName3"):GetComponent("Text") + self.PanelHint3 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon3/PanelHint3") + + self.ImgWaferColour4 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon4/ImgWaferColour4"):GetComponent("Image") + self.ImgSelect4 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon4/ImgSelect4"):GetComponent("Image") + self.ImgWaferon4 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon4/ImgWaferon4"):GetComponent("Image") + self.TxtWaferName4 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon4/TxtWaferName4"):GetComponent("Text") + self.PanelHint4 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon4/PanelHint4") + + self.ImgWaferColour5 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon5/ImgWaferColour5"):GetComponent("Image") + self.ImgSelect5 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon5/ImgSelect5"):GetComponent("Image") + self.ImgWaferon5 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon5/ImgWaferon5"):GetComponent("Image") + self.TxtWaferName5 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon5/TxtWaferName5"):GetComponent("Text") + self.PanelHint5 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon5/PanelHint5") + + self.ImgWaferColour6 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon6/ImgWaferColour6"):GetComponent("Image") + self.ImgSelect6 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon6/ImgSelect6"):GetComponent("Image") + self.ImgWaferon6 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon6/ImgWaferon6"):GetComponent("Image") + self.TxtWaferName6 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon6/TxtWaferName6"):GetComponent("Text") + self.PanelHint6 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon6/PanelHint6") + + self.ImgWaferColour7 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon7/ImgWaferColour7"):GetComponent("Image") + self.ImgSelect7 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon7/ImgSelect7"):GetComponent("Image") + self.ImgWaferon7 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon7/ImgWaferon7"):GetComponent("Image") + self.TxtWaferName7 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon7/TxtWaferName7"):GetComponent("Text") + self.PanelHint7 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon7/PanelHint7") + + self.ImgWaferColour8 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon8/ImgWaferColour8"):GetComponent("Image") + self.ImgSelect8 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon8/ImgSelect8"):GetComponent("Image") + self.ImgWaferon8 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon8/ImgWaferon8"):GetComponent("Image") + self.TxtWaferName8 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon8/TxtWaferName8"):GetComponent("Text") + self.PanelHint8 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon8/PanelHint8") + + self.ImgWaferColour9 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon9/ImgWaferColour9"):GetComponent("Image") + self.ImgSelect9 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon9/ImgSelect9"):GetComponent("Image") + self.ImgWaferon9 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon9/ImgWaferon9"):GetComponent("Image") + self.TxtWaferName9 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon9/TxtWaferName9"):GetComponent("Text") + self.PanelHint9 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon9/PanelHint9") + + self.ImgWaferColour10 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon10/ImgWaferColour10"):GetComponent("Image") + self.ImgSelect10 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon10/ImgSelect10"):GetComponent("Image") + self.ImgWaferon10 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon10/ImgWaferon10"):GetComponent("Image") + self.TxtWaferName10 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon10/TxtWaferName10"):GetComponent("Text") + self.PanelHint10 = self.Transform:Find("PanelQuality/PanelInfo/PanelItems/PanelWaferIcon/WaferIcon10/PanelHint10") + + self.RImgQuality = self.Transform:Find("PanelQuality/PanelInfo/WaferCircuit/RImgQuality"):GetComponent("RawImage") + self.RImgQualityMax = self.Transform:Find("PanelQuality/PanelInfo/WaferCircuit/RImgQualityMax"):GetComponent("RawImage") + self.BtnAdvanced = self.Transform:Find("PanelQuality/PanelInfo/BtnAdvanced"):GetComponent("Button") + self.PanelCondition = self.Transform:Find("PanelQuality/PanelCondition") +end + +function XUiPanelCharQualityOther:InitIcon() + self.StarIcon = {} + self.StarAttr = {} + self.SelectIcon = {} + self.Line = {} + self.StarColour = {} + self.PanelHint = {} + for i = 1, XCharacterConfigs.MAX_QUALITY_STAR do + self.StarIcon[i] = self["ImgWaferon" .. i] + self.StarAttr[i] = self["TxtWaferName" .. i] + self.SelectIcon[i] = self["ImgSelect" .. i] + self.Line[i] = self["ImgLine" .. i] + self.StarColour[i] = self["ImgWaferColour" .. i] + self.PanelHint[i] = self["PanelHint"..i] + end +end + +function XUiPanelCharQualityOther:ShowPanel(character) + self.GameObject:SetActive(true) + self.CharacterId = character.Id + self.QualityQiehuan:PlayTimelineAnimation() + + for _, hint in pairs(self.PanelHint) do + hint.gameObject:SetActiveEx(false) + end + + for i = 1, #self.StarAttr do + self.StarAttr[i].gameObject:SetActive(false) + self.SelectIcon[i].gameObject:SetActive(false) + end + + self:UpdatePanel(character) +end + +function XUiPanelCharQualityOther:HidePanel() + self.GameObject:SetActive(false) +end + +function XUiPanelCharQualityOther:UpdatePanel(character) + local maxStar = XCharacterConfigs.MAX_QUALITY_STAR + local isMaxQuality = XDataCenter.CharacterManager.IsMaxQuality(character) + local qualityIcon = XCharacterConfigs.GetCharQualityIcon(character.Quality) + + self.RImgQuality.gameObject:SetActive(not isMaxQuality) + self.RImgQualityMax.gameObject:SetActive(isMaxQuality) + + for i = 1, XCharacterConfigs.MAX_QUALITY_STAR do + self.StarAttr[i].gameObject:SetActive(false) + self.SelectIcon[i].gameObject:SetActive(false) + end + + self.BtnAdvanced.gameObject:SetActive(false) + self.PanelCondition.gameObject:SetActive(false) + self.PanelWaferIcon.gameObject:SetActive(not isMaxQuality) + self.RImgQuality:SetRawImage(qualityIcon) + self.RImgQualityMax:SetRawImage(qualityIcon) + + for i = 1, character.Star do + self.StarIcon[i].gameObject:SetActive(true) + self.Line[i].gameObject:SetActive(true) + self.StarColour[i].gameObject:SetActive(false) + end + + for i = maxStar, character.Star + 1, -1 do + self.StarIcon[i].gameObject:SetActive(false) + self.Line[i].gameObject:SetActive(false) + self.StarColour[i].gameObject:SetActive(true) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPlayerInfo/XUiPanelCharSkillOther.lua b/Resources/Scripts/XUi/XUiPlayerInfo/XUiPanelCharSkillOther.lua new file mode 100644 index 00000000..90e787c0 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPlayerInfo/XUiPanelCharSkillOther.lua @@ -0,0 +1,88 @@ +XUiPanelCharSkillOther = XClass(nil, "XUiPanelCharSkillOther") + +local XUiPanelSkillLevelDetail = require("XUi/XUiCharacter/XUiPanelSkillLevelDetail") + +local MAX_SKILL_COUNT = 5 +function XUiPanelCharSkillOther:Ctor(ui, parent, character, equipList, assignChapterRecords) + self.Parent = parent + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.AssignChapterRecords = assignChapterRecords + self:InitAutoScript() + + self.NpcData = {Character = character,Equips = equipList} + + self.SkillInfoPanel = XUiPanelSkillInfoOther.New(self.PanelSkillInfo, self, self.Parent, self.NpcData, self.AssignChapterRecords) + self.LevelDetailPanel = XUiPanelSkillLevelDetail.New(self.PanelSkillDetails) + + self.SkillTeach.gameObject:SetActiveEx(false) + self.PanelSkillInfo.gameObject:SetActive(false) + self.PanelSkillDetails.gameObject:SetActive(false) +end + +function XUiPanelCharSkillOther:InitAutoScript() + self:AutoInitUi() + XTool.InitUiObject(self) +end + +function XUiPanelCharSkillOther:AutoInitUi() + self.PanelSkillItems = self.Transform:Find("PanelSkillItems") + + self.GridSkillItem5 = self.Transform:Find("PanelSkillItems/GridSkillItem5") + self.GridSkillItem4 = self.Transform:Find("PanelSkillItems/GridSkillItem4") + self.GridSkillItem3 = self.Transform:Find("PanelSkillItems/GridSkillItem3") + self.GridSkillItem2 = self.Transform:Find("PanelSkillItems/GridSkillItem2") + self.GridSkillItem1 = self.Transform:Find("PanelSkillItems/GridSkillItem1") + + self.SkillTeach = self.Transform:Find("PanelSkillItems/SkillTeach") + self.PanelSkillInfo = self.Transform:Find("PanelSkillInfo") +end + +function XUiPanelCharSkillOther:ShowPanel(character,equipList) + self.CharacterId = character.Id + self.EquipList = equipList + self.GameObject:SetActiveEx(true) + self:ShowSkillItemPanel() + self:UpdatePanel(character) +end + +function XUiPanelCharSkillOther:ShowSkillItemPanel() + self.PanelSkillItems.gameObject:SetActive(true) + self.SkillInfoPanel:HidePanel() + self.SkillItemsQiehuan:PlayTimelineAnimation() +end + +function XUiPanelCharSkillOther:HidePanel() + self:HideSkillItemPanel() + self.SkillInfoPanel:HidePanel() + self.GameObject:SetActive(false) +end + +function XUiPanelCharSkillOther:HideSkillItemPanel() + self.PanelSkillItems.gameObject:SetActive(false) +end + +--技能信息格子点击后弹出等级详情 +function XUiPanelCharSkillOther:ShowLevelDetail(skillId) + self.PanelSkillDetails.gameObject:SetActive(true) + self.LevelDetailPanel:RefreshByNpcData(self.NpcData, skillId, self.AssignChapterRecords) +end + +function XUiPanelCharSkillOther:UpdatePanel(character) + local skills = XCharacterConfigs.GetCharacterSkillsByCharacter(character) + + if (self.SkillGrids and #self.SkillGrids > 0) then + for i = 1, MAX_SKILL_COUNT do + self.SkillGrids[i]:UpdateInfo( skills[i]) + end + else + self.SkillGrids = {} + for i = 1, MAX_SKILL_COUNT do + self.SkillGrids[i] = XUiGridSkillItemOther.New(self.Parent, self["GridSkillItem" .. i], skills[i], character, self.EquipList, self.AssignChapterRecords, + function() + self:HideSkillItemPanel() + self.SkillInfoPanel:ShowPanel(self.CharacterId, skills, i) + end) + end + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPlayerInfo/XUiPanelCharacterList.lua b/Resources/Scripts/XUi/XUiPlayerInfo/XUiPanelCharacterList.lua new file mode 100644 index 00000000..b2df12bb --- /dev/null +++ b/Resources/Scripts/XUi/XUiPlayerInfo/XUiPanelCharacterList.lua @@ -0,0 +1,172 @@ +XUiPanelCharacterList = XClass(nil, "XUiPanelCharacterList") + +local TextManager = CS.XTextManager +local tableInsert = table.insert +local tableSort = table.sort + +local Sort = function(a, b) + if a.IsLocked ~= b.IsLocked then + return not a.IsLocked + end + if a.Data.Quality ~= b.Data.Quality then + return a.Data.Quality > b.Data.Quality + end + if a.Data.Level ~= b.Data.Level then + return a.Data.Level > b.Data.Level + end + return a.Data.Id > b.Data.Id +end + +function XUiPanelCharacterList:Ctor(ui, rootUi) + self.RootUi = rootUi + self.Transform = ui.transform + self.GameObject = ui.gameObject + XTool.InitUiObject(self) + + self.AllCharList = {} --全部成员 + self.CharacterList = {} --展示的成员 + self:InitDynamicTable() +end + +function XUiPanelCharacterList:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelCharacterList) + self.DynamicTable:SetProxy(XUiPlayerInfoCharacterGrid) + self.DynamicTable:SetDelegate(self) + self.PlayerInfoCharacterGrid.gameObject:SetActiveEx(false) +end + +function XUiPanelCharacterList:Show() + self.GameObject:SetActiveEx(true) + self.PanelScore.gameObject:SetActiveEx(true) + self.AppearanceShowType = self.RootUi.Data.AppearanceShowType or XPlayerInfoConfigs.CharactersAppearanceType.All + + if self.RootUi.IsOpenFromSetting then + --从设置面板进入,使用预览数据 + for _,v in pairs(self.RootUi.Data.CharacterShow) do + local temData = { Data = v, IsLocked = false } + tableInsert(self.CharacterList, temData) + end + self:Refresh(true) + else + self:Refresh() + if self:HasPermission() then + XDataCenter.PlayerInfoManager.RequestPlayerCharacterListData(self.RootUi.Data.Id, function(data) + for _,v in pairs(data) do + local temData = { Data = v, IsLocked = false } + tableInsert(self.CharacterList, temData) + end + self:Refresh(true) + end) + end + end +end + +function XUiPanelCharacterList:Refresh(hasPermission) + local hasCharacterDisplay = self:HasCharacterDisplay() + self:SetupDynamicTable(hasPermission,hasCharacterDisplay) +end + +function XUiPanelCharacterList:SetupDynamicTable(hasPermission, hasCharacterDisplay, index) + self.DynamicTable:SetDataSource(self:HandleData(hasPermission,hasCharacterDisplay)) + self.DynamicTable:ReloadDataSync(index and index or 1) +end + +--==============================-- +--desc: 是否拥有权限查看信息 +--@return: 有true,无false +--==============================-- +function XUiPanelCharacterList:HasPermission() + self.AppearanceSettingInfo = self.RootUi.Data.AppearanceSettingInfo and + self.RootUi.Data.AppearanceSettingInfo.CharacterType or XUiAppearanceShowType.ToSelf + + local isFriend = XDataCenter.SocialManager.CheckIsFriend(self.RootUi.Data.Id) + local hasPermission = (self.AppearanceSettingInfo == XUiAppearanceShowType.ToAll) + or (self.AppearanceSettingInfo == XUiAppearanceShowType.ToFriend and isFriend) + return hasPermission +end + +--==============================-- +--desc: 自选成员展示时是否有设置成员 +--==============================-- +function XUiPanelCharacterList:HasCharacterDisplay() + --展示类型为自选成员,没有设置成员时返回false + local hasCharacterDisplay = not (self.AppearanceShowType == XPlayerInfoConfigs.CharactersAppearanceType.Select and #self.CharacterList < 1) + return hasCharacterDisplay +end + +--==============================-- +--desc: 处理动态列表的数据源 +--@return: 有序的成员表,全部展示包括未拥有成员 +--==============================-- +function XUiPanelCharacterList:HandleData(hasPermission, hasCharacterDisplay) + local isLoadData = hasPermission and hasCharacterDisplay + + if not isLoadData then + self.PanelScore.gameObject:SetActiveEx(false) + self.PanelCharacterNone.gameObject:SetActiveEx(true) + if not hasPermission then + self.EmptyText.text = TextManager.GetText("PlayerInfoWithoutPermission") + else + self.EmptyText.text = TextManager.GetText("PlayerInfoCharacterEmpty") + end + return {} + end + + self.PanelCharacterNone.gameObject:SetActiveEx(false) + + if self.AppearanceShowType == XPlayerInfoConfigs.CharactersAppearanceType.All then + -- 全成员展示,数据源包括未解锁成员 + local score = 0 + local allCharList = {} --最终数据,拥有成员排在前面 + local characterListById = {} --拥有成员字典,Id做索引,用来查询未解锁成员 + + for _, v in ipairs(self.CharacterList) do + characterListById[v.Data.Id] = v + local characterShowScoreList = XPlayerInfoConfigs.GetCharacterShowScore(v.Data.Id) + local addScore = characterShowScoreList[v.Data.Quality] and characterShowScoreList[v.Data.Quality] or 0 + score = score + addScore + end + self.PanelScore.gameObject:SetActiveEx(true) + self.TxtScore.text = score + + for k, v in pairs(XCharacterConfigs.GetCharacterTemplates()) do + local temData = { IsLocked = true } + if characterListById[k] then + tableInsert(allCharList, characterListById[k]) + else + temData.Data = v + tableInsert(allCharList, temData) + end + end + + tableSort(allCharList, function(item1, item2) return Sort(item1, item2) end) + + self.AllCharList = allCharList + + return allCharList + else + -- 自选成员展示,数据源不包括未解锁成员 + self.PanelScore.gameObject:SetActiveEx(false) + + return self.CharacterList + end +end + +function XUiPanelCharacterList:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self.RootUi.Data.Id) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + if self.AppearanceShowType == XPlayerInfoConfigs.CharactersAppearanceType.All then + grid:UpdateGrid(self.AllCharList[index], self.AppearanceShowType, self.RootUi.Data.AssistCharacterDetail) + else + grid:UpdateGrid(self.CharacterList[index], self.AppearanceShowType, self.RootUi.Data.AssistCharacterDetail) + end + end +end + +function XUiPanelCharacterList:Close() + self.AllCharList = {} + self.CharacterList = {} + self.AppearanceShowType = nil + self.GameObject:SetActiveEx(false) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPlayerInfo/XUiPanelCollectionScrollPlayerInfo.lua b/Resources/Scripts/XUi/XUiPlayerInfo/XUiPanelCollectionScrollPlayerInfo.lua new file mode 100644 index 00000000..af47902f --- /dev/null +++ b/Resources/Scripts/XUi/XUiPlayerInfo/XUiPanelCollectionScrollPlayerInfo.lua @@ -0,0 +1,118 @@ +XUiPanelCollectionScrollPlayerInfo = XClass(nil, "XUiPanelCollectionScrollPlayerInfo") + +local XUiCollectionWallOther = require("XUi/XUiCollectionWall/XUiCollectionWallOther") +local XCollectionWall = require("XEntity/XCollectionWall/XCollectionWall") + +local TextManager = CS.XTextManager + +function XUiPanelCollectionScrollPlayerInfo:Ctor(ui, rootUi) + self.RootUi = rootUi + self.Transform = ui.transform + self.GameObject = ui.gameObject + XTool.InitUiObject(self) + + self.CollectionList = {} --拥有的收藏品 + self.CollectionWall = {} + self.GridCollection.gameObject:SetActiveEx(false) + + self.BtnCollectionWall.CallBack = function() + self:OnBtnCollectionWallClick() + end +end + +function XUiPanelCollectionScrollPlayerInfo:Show() + self.GameObject:SetActiveEx(true) + + if self.RootUi.IsOpenFromSetting then + --从设置面板进入,使用预览数据 + self.CollectionList = self.RootUi.Data.CollectionShow + self.CollectionWall = self.RootUi.Data.CollectionWall + self:Refresh(true) + else + self:Refresh() + if self:HasPermission() then + XDataCenter.PlayerInfoManager.RequestPlayerTitleData(self.RootUi.Data.Id, function(data) + XDataCenter.MedalManager.SetSpecificMaxScore(data.Titles) + self.CollectionList = data.Titles + self.CollectionWall = {} + for _, wall in pairs(data.Walls) do + local collectionWall = XCollectionWall.New(wall.Id) + collectionWall:UpdateDate( + { Id = wall.Id, + PedestalId = wall.PedestalId, + BackgroundId = wall.BackgroundId, + CollectionSetInfos = wall.CollectionSetInfos + }) + table.insert(self.CollectionWall, collectionWall) + end + self:Refresh(true) + end) + end + end +end + +function XUiPanelCollectionScrollPlayerInfo:Refresh(hasPermission) + local hasCollection = self:HasCollection() + self:SetContent(hasPermission, hasCollection) +end + +function XUiPanelCollectionScrollPlayerInfo:SetContent(hasPermission, hasCollection) + local isLoadData = hasPermission and hasCollection + + if not isLoadData then + self.PanelCollectionNone.gameObject:SetActiveEx(true) + self.BtnCollectionWall.gameObject:SetActiveEx(false) + if not hasPermission then + self.EmptyText.text = TextManager.GetText("PlayerInfoWithoutPermission") + else + self.EmptyText.text = TextManager.GetText("CollectionWallEmpty") + end + else + self.BtnCollectionWall.gameObject:SetActiveEx(true) + self.PanelCollectionNone.gameObject:SetActiveEx(false) + + self.OtherPlayerScoreTitleList = XDataCenter.MedalManager.CreateOtherPlayerScoreTitleList(self.CollectionList) + + local pedestalId = self.CollectionWall[1]:GetPedestalId() + local backgroundId = self.CollectionWall[1]:GetBackgroundId() + local collectionInfo = self.CollectionWall[1]:GetCollectionSetInfos() + local scoreTitleDic = {} + for _, data in pairs(self.OtherPlayerScoreTitleList) do + scoreTitleDic[data.Id] = data + end + self.WallPanel = XUiCollectionWallOther.New(self.PanelWall, pedestalId, backgroundId, collectionInfo, scoreTitleDic) + end +end + +--==============================-- +--desc: 是否拥有权限查看信息 +--@return: 有true,无false +--==============================-- +function XUiPanelCollectionScrollPlayerInfo:HasPermission() + self.AppearanceSettingInfo = self.RootUi.Data.AppearanceSettingInfo and + self.RootUi.Data.AppearanceSettingInfo.TitleType or XUiAppearanceShowType.ToSelf + + local isFriend = XDataCenter.SocialManager.CheckIsFriend(self.RootUi.Data.Id) + local hasPermission = (self.AppearanceSettingInfo == XUiAppearanceShowType.ToAll) + or (self.AppearanceSettingInfo == XUiAppearanceShowType.ToFriend and isFriend) + return hasPermission +end + +--==============================-- +--desc: 是否拥有收藏品 +--@return: 有true,无false +--==============================-- +function XUiPanelCollectionScrollPlayerInfo:HasCollection() + local length = #self.CollectionWall + return length >= 1 +end + +function XUiPanelCollectionScrollPlayerInfo:OnBtnCollectionWallClick() + XLuaUiManager.Open("UiCollectionWallView", self.CollectionWall, XDataCenter.MedalManager.InType.OtherPlayer, self.OtherPlayerScoreTitleList) +end + +function XUiPanelCollectionScrollPlayerInfo:Close() + self.CollectionList = {} + self.AppearanceSettingInfo = nil + self.GameObject:SetActiveEx(false) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPlayerInfo/XUiPanelFashionPlayerInfo.lua b/Resources/Scripts/XUi/XUiPlayerInfo/XUiPanelFashionPlayerInfo.lua new file mode 100644 index 00000000..ead665e7 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPlayerInfo/XUiPanelFashionPlayerInfo.lua @@ -0,0 +1,205 @@ +XUiPanelFashionPlayerInfo = XClass(nil, "XUiPanelFashionPlayerInfo") + +local FASHION_QUALITY_LIMIT = 2 + +local TextManager = CS.XTextManager +local tableInsert = table.insert +local tableSort = table.sort + +local Sort = function(a, b, fashionType) + if a.IsLocked ~= b.IsLocked then + return not a.IsLocked + end + if a.Data.Quality ~= b.Data.Quality then + return a.Data.Quality > b.Data.Quality + end + if fashionType == XPlayerInfoConfigs.FashionType.Character then + return a.Data.CharacterId > b.Data.CharacterId + else + return a.Data.Id > b.Data.Id + end +end + +function XUiPanelFashionPlayerInfo:Ctor(ui, rootUi) + self.RootUi = rootUi + self.Transform = ui.transform + self.GameObject = ui.gameObject + self.FashionType = XPlayerInfoConfigs.FashionType.Character + XTool.InitUiObject(self) + + self.FashionList = {} --拥有的成员涂装 + self.WeaponFashionList = {} --拥有的武器涂装 + self.AllFashionList = {} --全部成员涂装信息 + self.AllWeaponFashionList = {} --全部武器涂装信息 + + self:AutoAddListener() + self:InitDynamicTable() +end + +function XUiPanelFashionPlayerInfo:AutoAddListener() + self.BtnDropDown.onValueChanged:AddListener(function() + self.FashionList = {} + self.WeaponFashionList = {} + self.AllFashionList = {} + self.AllWeaponFashionList = {} + self.AppearanceSettingInfo = nil + self.FashionType = self.BtnDropDown.value + + if self.RootUi.IsOpenFromSetting then + --从设置面板进入,使用预览数据 + self.FashionList = self.RootUi.Data.FashionShow + self.WeaponFashionList = self.RootUi.Data.WeaponFashionShow + self:Refresh(true) + else + self:Refresh() + if self:HasPermission() then + self:RequestData() + end + end + end) +end + +function XUiPanelFashionPlayerInfo:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.FashionDynamicTable) + self.DynamicTable:SetProxy(XUiPlayerInfoClothGrid) + self.DynamicTable:SetDelegate(self) + self.ClothGrid.gameObject:SetActiveEx(false) +end + +function XUiPanelFashionPlayerInfo:Show() + self.GameObject:SetActiveEx(true) + + if self.RootUi.IsOpenFromSetting then + --从设置面板进入,使用预览数据 + self.FashionList = self.RootUi.Data.FashionShow + self.WeaponFashionList = self.RootUi.Data.WeaponFashionShow + self:Refresh(true) + else + self:Refresh() + if self:HasPermission() then + self:RequestData() + end + end +end + +function XUiPanelFashionPlayerInfo:RequestData() + if self.FashionType == XPlayerInfoConfigs.FashionType.Character then + --请求成员涂装数据 + XDataCenter.PlayerInfoManager.RequestPlayerFashionData(self.RootUi.Data.Id, function(data) + self.FashionList = data + self:Refresh(true) + end) + else + --请求武器涂装数据 + XDataCenter.PlayerInfoManager.RequestPlayerWeaponFashionData(self.RootUi.Data.Id, function(data) + self.WeaponFashionList = data + self:Refresh(true) + end) + end +end + +function XUiPanelFashionPlayerInfo:Refresh(hasPermission) + self:SetupDynamicTable(hasPermission) +end + +function XUiPanelFashionPlayerInfo:SetupDynamicTable(hasPermission,index) + if self.FashionType == XPlayerInfoConfigs.FashionType.Character then + self.AllFashionList = self:HandleData(XDataCenter.FashionManager.GetAllFashionTemplateInTime(), self.FashionList, XPlayerInfoConfigs.FashionType.Character, hasPermission) + self.DynamicTable:SetDataSource(self.AllFashionList) + else + self.AllWeaponFashionList = self:HandleData(XWeaponFashionConfigs.GetWeaponFashionResTemplatesInTime(), self.WeaponFashionList, XPlayerInfoConfigs.FashionType.Weapon, hasPermission) + self.DynamicTable:SetDataSource(self.AllWeaponFashionList) + end + self.DynamicTable:ReloadDataSync(index and index or 1) +end + +--==============================-- +--desc: 是否拥有权限查看信息 +--@return: 有true,无false +--==============================-- +function XUiPanelFashionPlayerInfo:HasPermission() + local isFriend = XDataCenter.SocialManager.CheckIsFriend(self.RootUi.Data.Id) + + if self.FashionType == XPlayerInfoConfigs.FashionType.Character then + self.AppearanceSettingInfo = self.RootUi.Data.AppearanceSettingInfo + and self.RootUi.Data.AppearanceSettingInfo.FashionType or XUiAppearanceShowType.ToSelf + else + self.AppearanceSettingInfo = self.RootUi.Data.AppearanceSettingInfo + and self.RootUi.Data.AppearanceSettingInfo.WeaponFashionType or XUiAppearanceShowType.ToSelf + end + + local hasPermission = (self.AppearanceSettingInfo == XUiAppearanceShowType.ToAll) + or (self.AppearanceSettingInfo == XUiAppearanceShowType.ToFriend and isFriend) + + return hasPermission +end + +--==============================-- +--desc: 获得涂装数据 +--@allFashion: 配置表得到的全部涂装数据 +--@ownFashion: 服务器返回的已拥有涂装 +--@fashionType: 涂装类型,成员涂装需要过滤泛用式涂装 +--@return: 有序的涂装数据 +--==============================-- +function XUiPanelFashionPlayerInfo:HandleData(allFashion, ownFashion, fashionType, hasPermission) + if not hasPermission then + self.PanelScore.gameObject:SetActiveEx(false) + self.PanelFashionNone.gameObject:SetActiveEx(true) + self.EmptyText.text = TextManager.GetText("PlayerInfoWithoutPermission") + + return {} + end + + self.PanelScore.gameObject:SetActiveEx(true) + self.PanelFashionNone.gameObject:SetActiveEx(false) + + local ownCount = 0 + local allFashionList = {} --最终数据,拥有涂装排在前面 + local fashionListById = {} --拥有涂装字典,Id做索引,用来查询未解锁成员 + + for _, v in ipairs(ownFashion) do + fashionListById[v] = v + end + + for k, v in pairs(allFashion) do + -- 成员涂装需要去除泛用式涂装 + local isWeaponFashion = fashionType ~= XPlayerInfoConfigs.FashionType.Character + if isWeaponFashion or v.Quality > FASHION_QUALITY_LIMIT then + local temData = { Data = v, IsLocked = true } + if fashionListById[k] then + temData.IsLocked = false + ownCount = ownCount + 1 + end + tableInsert(allFashionList, temData) + end + end + tableSort(allFashionList, function(item1, item2) + return Sort(item1, item2, self.FashionType) + end) + + -- 计算收集率 + local score = string.format("%.1f", (ownCount / #allFashionList) * 100) + self.TxtShouJiLv.text = score .. "%" + + return allFashionList +end + +function XUiPanelFashionPlayerInfo:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + if self.FashionType == XPlayerInfoConfigs.FashionType.Character then + grid:UpdateGrid(self.AllFashionList[index], self.FashionType) + else + grid:UpdateGrid(self.AllWeaponFashionList[index], self.FashionType) + end + end +end + +function XUiPanelFashionPlayerInfo:Close() + self.FashionList = {} + self.WeaponFashionList = {} + self.AllFashionList = {} + self.AllWeaponFashionList = {} + self.AppearanceSettingInfo = nil + self.GameObject:SetActiveEx(false) +end + diff --git a/Resources/Scripts/XUi/XUiPlayerInfo/XUiPanelInfo.lua b/Resources/Scripts/XUi/XUiPlayerInfo/XUiPanelInfo.lua new file mode 100644 index 00000000..857a9d9f --- /dev/null +++ b/Resources/Scripts/XUi/XUiPlayerInfo/XUiPanelInfo.lua @@ -0,0 +1,164 @@ +XUiPanelInfo = XClass(nil, "XUiPanelInfo") +local TextManager = CS.XTextManager + +function XUiPanelInfo:Ctor(ui, rootUi) + self.RootUi = rootUi + self.Transform = ui.transform + self.GameObject = ui.gameObject + XTool.InitUiObject(self) + + self.BtnDorm.CallBack = function() self:OnBtnDorm() end + self.BtnExhibition.CallBack = function() self:OnBtnExhibition() end + self.BtnFriendLevel.CallBack = function() self:OnBtnFriendLevel() end + self.BtnGuild.CallBack = function() self:OnBtnGuild() end + + self.BtnFriendLevel.gameObject:SetActiveEx(not (self.RootUi.Data.Id == XPlayer.Id)) + self.BtnExhibition.gameObject:SetActiveEx(not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.CharacterExhibition)) + + self:InitDynamicTable() +end + +function XUiPanelInfo:Show() + self.GameObject:SetActiveEx(true) + self:SetupDynamicTable() + self:UpdateInfo() +end + +function XUiPanelInfo:UpdateInfo() + local data = self.RootUi.Data + self.MedalInfos = data.MedalInfos + + -- 成就 + self.TxtAchievement.text = data.AchievementDetail.Achievement .. "/" .. data.AchievementDetail.TotalAchievement + if (data.Birthday == nil) then + self.TxtBirthday.text = TextManager.GetText("Birthday", "--", "--") + else + self.TxtBirthday.text = TextManager.GetText("Birthday", data.Birthday.Mon, data.Birthday.Day) + end + + -- 羁绊 + if data.Id == XPlayer.Id then + self.TxtFriendLevel.text = "-" + elseif XDataCenter.SocialManager.CheckIsFriend(data.Id) then + self.TxtFriendLevel.text = XDataCenter.SocialManager.GetFriendExpLevel(data.Id) + else + self.TxtFriendLevel.text = TextManager.GetText("IsNotFriend") + end + + -- 宿舍 + local playerId = self.RootUi.Data.Id + local appearanceShowType = (self.RootUi.Data.AppearanceSettingInfo or {}) .DormitoryType + local hasPermission = XDataCenter.DormManager.HasDormPermission(playerId, appearanceShowType) + + if hasPermission then + if data.DormDetail then + self.BtnDorm.gameObject:SetActiveEx(true) + self.TxtDormName.text = data.DormDetail.DormitoryName + else + -- 宿舍系统未开启 + self.BtnDorm.gameObject:SetActiveEx(false) + self.TxtDormName.text = TextManager.GetText("DormDisable") + end + else + self.BtnDorm.gameObject:SetActiveEx(false) + self.TxtDormName.text = TextManager.GetText("PlayerInfoWithoutPermission") + end + + --收集 + local collectionRate = XDataCenter.ExhibitionManager.GetCollectionRate(true) + self.TxtExhibition.text = math.floor(collectionRate * 100) .. "%" + + -- 指挥局 + local guildDetail = data.GuildDetail + local guildName = guildDetail and guildDetail.GuildName + if guildDetail == nil or not guildName or string.len(guildName) == 0 then + self.TxtGuildName.text = TextManager.GetText("GuildNoneJoinGuild") + self.BtnGuild.gameObject:SetActiveEx(false) + else + self.TxtGuildName.text = guildDetail.GuildName + end +end + +function XUiPanelInfo:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelMedalList) + self.DynamicTable:SetProxy(XUiOtherPlayerGridMedal) + self.GridMedal.gameObject:SetActiveEx(false) + self.DynamicTable:SetDelegate(self) +end + +function XUiPanelInfo:SetupDynamicTable(index) + self.MedalData = XMedalConfigs.GetMeadalConfigs() + self.DynamicTable:SetDataSource(self.MedalData) + self.DynamicTable:ReloadDataSync(index and index or 1) +end + +function XUiPanelInfo:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:UpdateGrid(self.MedalData[index], self.MedalInfos) + end +end + +function XUiPanelInfo:OnBtnFriendLevel() + local data = self.RootUi.Data + if not self.PanelPlayerInfoFetters then + local obj = CS.UnityEngine.Object.Instantiate(self.PlayerInfoFetters) + obj.transform:SetParent(self.PlayerInfoBase, false) + self.PanelPlayerInfoFetters = XUiPlayerInfoFetters.New(obj, XDataCenter.SocialManager.CheckIsFriend(data.Id), XDataCenter.SocialManager.GetFriendExp(data.Id)) + else + self.PanelPlayerInfoFetters:UpdateInfo(XDataCenter.SocialManager.CheckIsFriend(data.Id), XDataCenter.SocialManager.GetFriendExp(data.Id)) + self.PanelPlayerInfoFetters.GameObject:SetActiveEx(true) + end +end + +function XUiPanelInfo:OnBtnDorm() + if XDataCenter.RoomManager.RoomData then + XUiManager.TipError(TextManager.GetText("InTeamCantLookDorm")) + return + end + + local unionFightData = XDataCenter.FubenUnionKillRoomManager.GetUnionRoomData() + if unionFightData and unionFightData.Id then + XUiManager.TipError(TextManager.GetText("InTeamCantLookDorm")) + return + end + + local data = self.RootUi.Data + if data and data.Id and data.DormDetail and data.DormDetail.DormitoryId then + if XLuaUiManager.IsUiLoad("UiDormSecond") then + XLuaUiManager.CloseWithCallback("UiPlayerInfo", function() + XEventManager.DispatchEvent(XEventId.EVENT_DORM_VISTOR_SKIP, data.Id, data.DormDetail.DormitoryId) + end) + return + end + XHomeDormManager.EnterDorm(data.Id, data.DormDetail.DormitoryId, true) + end +end + +function XUiPanelInfo:OnBtnExhibition() + if XDataCenter.RoomManager.RoomData then + XUiManager.TipError(TextManager.GetText("InTeamCantLookExhibition")) + return + end + local unionFightData = XDataCenter.FubenUnionKillRoomManager.GetUnionRoomData() + if unionFightData and unionFightData.Id then + XUiManager.TipError(TextManager.GetText("InTeamCantLookExhibition")) + return + end + + if XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.CharacterExhibition) then + XLuaUiManager.Open("UiExhibition", false) + end +end + +function XUiPanelInfo:OnBtnGuild() + local data = self.RootUi.Data + local guildId = data.GuildDetail.GuildId + if guildId == 0 then return end + XDataCenter.GuildManager.GetVistorGuildDetailsReq(guildId, function() + XLuaUiManager.Open("UiGuildRankingList", guildId) + end) +end + +function XUiPanelInfo:Close() + self.GameObject:SetActiveEx(false) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPlayerInfo/XUiPanelSkillInfoOther.lua b/Resources/Scripts/XUi/XUiPlayerInfo/XUiPanelSkillInfoOther.lua new file mode 100644 index 00000000..bd767442 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPlayerInfo/XUiPanelSkillInfoOther.lua @@ -0,0 +1,248 @@ +XUiPanelSkillInfoOther = XClass(nil, "XUiPanelSkillInfoOther") + +local MAX_SUB_SKILL_GRID_COUNT = 6 +local MAX_MAIN_SKILL_GRID_COUNT = 5 + +function XUiPanelSkillInfoOther:Ctor(ui, parent, rootUi, npcData,assignChapterRecords) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Parent = parent + self.RootUi = rootUi + self.NpcData = npcData + self.AssignChapterRecords = assignChapterRecords + self:InitAutoScript() + + self.SkillPoint.gameObject:SetActive(false) + self.SubSkillInfo.gameObject:SetActive(false) + self.GridSkillInfo.gameObject:SetActive(false) + self.GridSubSkill.gameObject:SetActive(false) + + self.SkillInfoGo = {} + self.SkillInfoGrids = {} + table.insert(self.SkillInfoGo, self.GridSkillInfo) + + self:InitSubSkillGrids() +end + +function XUiPanelSkillInfoOther:InitAutoScript() + self:AutoInitUi() + XTool.InitUiObject(self) + self:AutoAddListener() +end + +function XUiPanelSkillInfoOther:AutoInitUi() + self.SkillPoint = self.Transform:Find("SkillPoint") + self.SubSkillInfo = self.Transform:Find("PaneSkillInfo/SubSkillInfo") + self.GridSubSkill = self.Transform:Find("PaneSkillInfo/PanelSubSkillList/GridSubSkill") + self.GridSkillInfo = self.Transform:Find("PaneSkillInfo/PanelScroll/GridSkillInfo") + + self.PanelSkillBig = self.Transform:Find("PaneSkillInfo/PanelSkillBig") + self.PanelSubSkillList = self.Transform:Find("PaneSkillInfo/PanelSubSkillList") + self.PanelScroll = self.Transform:Find("PaneSkillInfo/PanelScroll") + self.BtnHuadong = self.Transform:Find("PaneSkillInfo/BtnHuadong"):GetComponent("Button") + self.BtnHuadong1 = self.Transform:Find("PaneSkillInfo/BtnHuadong1"):GetComponent("Button") + + self.ImgSkillPointIcon = self.Transform:Find("PaneSkillInfo/PanelSkillBig/ImgSkillPointIcon"):GetComponent("Image") + self.TxtSkillType = self.Transform:Find("PaneSkillInfo/PanelSkillBig/TxtSkillType"):GetComponent("Text") + self.TxtSkillName = self.Transform:Find("PaneSkillInfo/PanelSkillBig/TxtSkillName"):GetComponent("Text") + self.TxtSkillLevel = self.Transform:Find("PaneSkillInfo/PanelSkillBig/TxtSkillLevel"):GetComponent("Text") + +end + +function XUiPanelSkillInfoOther:InitSubSkillGrids() + self.SubSkillGrids = {} + for i = 1, MAX_SUB_SKILL_GRID_COUNT do + local item = CS.UnityEngine.Object.Instantiate(self.GridSubSkill) -- 复制一个item + local grid = XUiGridSubSkillOther.New(item, i, self.NpcData, self.AssignChapterRecords, function(subSkill, index) + self:UpdateSubSkillInfoPanel(subSkill, index) + end) + grid.GameObject:SetActive(false) + grid.Transform:SetParent(self.PanelSubSkillList, false) + table.insert(self.SubSkillGrids, grid) + end +end + +function XUiPanelSkillInfoOther:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelSkillInfo:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelSkillInfo:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelSkillInfoOther:AutoAddListener() + self:RegisterClickEvent(self.BtnHuadong, self.OnBtnHuadongClick) + self:RegisterClickEvent(self.BtnHuadong1, self.OnBtnHuadong1Click) +end + +function XUiPanelSkillInfoOther:OnBtnHuadongClick() + if self.Pos then + self:GotoSkill(self.Pos + 1) + end +end + +function XUiPanelSkillInfoOther:OnBtnHuadong1Click() + if self.Pos then + self:GotoSkill(self.Pos - 1) + end +end + +function XUiPanelSkillInfoOther:GotoSkill(index) + if self.Parent.SkillGrids[index] then + self.Parent.SkillGrids[index]:OnBtnIconBgClick() + end + self:UpdateArrowView() +end + +function XUiPanelSkillInfoOther:UpdateArrowView() + self.BtnHuadong.gameObject:SetActive(not (self.Pos == MAX_MAIN_SKILL_GRID_COUNT)) + self.BtnHuadong1.gameObject:SetActive(not (self.Pos == 1)) +end + +function XUiPanelSkillInfoOther:ShowPanel(characterId, skills, pos) + self.CharacterId = characterId or self.CharacterId + self.Skills = skills + self.Pos = pos + self.Skill = skills[pos] + self.IsShow = true + self.GameObject:SetActive(true) + + for i, skill in pairs(skills) do + local grid = self.SkillInfoGrids[i] + if (grid == nil) then + local ui_item = self.SkillInfoGo[i] + if (ui_item == nil) then + ui_item = CS.UnityEngine.Object.Instantiate(self.GridSkillInfo, self.PanelScroll) + ui_item.transform:SetAsFirstSibling() + table.insert(self.SkillInfoGo, ui_item) + end + grid = XUiGridSkillInfo.New(ui_item, skill, function(skillId) + self.Parent:ShowLevelDetail(skillId) + end) + table.insert(self.SkillInfoGrids, grid) + else + grid:UpdateData(skill) + end + + grid.GameObject:SetActive(true) + end + + self:RefreshPanel( self.Skill) + self:RefreshData() + -- 默认点击 + if self.SubSkillGrids[1] then + self.SubSkillGrids[1]:OnBtnSubSkillIconBgClick() + end + + self:UpdateArrowView() + self.Parent.SkillInfoQiehuan:PlayTimelineAnimation() +end + +function XUiPanelSkillInfoOther:RefreshData() + local characterId = self.CharacterId + if not characterId then return end + + self.Skills = XCharacterConfigs.GetCharacterSkillsByCharacter(self.NpcData.Character) + local skill = self.Skills[self.Skill.config.Pos] + local grid = self.SkillInfoGrids[self.Pos] + for i = 1, #self.SkillInfoGrids do + self.SkillInfoGrids[i].GameObject:SetActive(self.Pos == i) + end + if (grid) then + grid:UpdateData(skill) + end + self.Parent:UpdatePanel(self.NpcData.Character) + self:RefreshPanel(skill) + self:RefreshBigSkill(skill) +end + +function XUiPanelSkillInfoOther:RefreshBigSkill(skill) + self.RootUi:SetUiSprite(self.ImgSkillPointIcon, skill.Icon) + self.TxtSkillType.text = skill.TypeDes + self.TxtSkillName.text = skill.Name + + local addLevel = 0 + + for _, skillId in pairs(skill.SkillIdList) do + local resonanceSkillLevelMap = XMagicSkillManager.GetResonanceSkillLevelMap(self.NpcData) + local resonanceSkillLevel = resonanceSkillLevelMap[skillId] or 0 + addLevel = addLevel + resonanceSkillLevel + XDataCenter.FubenAssignManager.GetSkillLevelByCharacterData(self.NpcData.Character, skillId, self.AssignChapterRecords) + end + + + local totalLevel = skill.TotalLevel + addLevel + self.TxtSkillLevel.text = totalLevel +end + +function XUiPanelSkillInfoOther:RefreshPanel( skill) + self:UpdateSubSkillList(skill.subSkills) + + for i, sub_skill in ipairs(skill.subSkills) do + if (i == self.CurSubSkillIndex) then + self:UpdateSubSkillInfoPanel(sub_skill, self.CurSubSkillIndex) + break + end + end +end + +function XUiPanelSkillInfoOther:UpdateSubSkillList(subSkillList) + for _, grid in pairs(self.SubSkillGrids) do + grid:Reset() + end + + local count = #subSkillList + + if count > MAX_SUB_SKILL_GRID_COUNT then + XLog.Warning("max subskill grid count is " .. MAX_SUB_SKILL_GRID_COUNT) + count = MAX_SUB_SKILL_GRID_COUNT + end + + for i = 1, count do + local sub_skill = subSkillList[i] + local grid = self.SubSkillGrids[i] + grid:UpdateGrid(sub_skill) + grid.GameObject.name = sub_skill.SubSkillId + + if i == 1 then + grid:SetSelect(true) + end + end +end + +--技能格子点击 +function XUiPanelSkillInfoOther:UpdateSubSkillInfoPanel(subSkill, index) + if not subSkill then return end + + if self.CurSubSkillIndex then + self.SubSkillGrids[self.CurSubSkillIndex]:SetSelect(false) + end + + local grid = self.SkillInfoGrids[self.Pos] + if grid then + grid:SetSubInfoByCharacterData(self.NpcData, index, subSkill.Level, subSkill.SubSkillId, self.AssignChapterRecords) + end + + self.CurSubSkillIndex = index + self.SubSkillGrids[self.CurSubSkillIndex]:SetSelect(true) + self.CurSubSkill = subSkill + + for _, tmpGrid in pairs(self.SubSkillGrids) do + tmpGrid:ResetSelect(subSkill.SubSkillId) + end +end + +function XUiPanelSkillInfoOther:HidePanel() + self.IsShow = false + self.GameObject:SetActive(false) + self.CurSubSkillIndex = nil + self.CurSubSkill = nil +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPlayerInfo/XUiPanelSkillLevelDetailOther.lua b/Resources/Scripts/XUi/XUiPlayerInfo/XUiPanelSkillLevelDetailOther.lua new file mode 100644 index 00000000..31666fd1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPlayerInfo/XUiPanelSkillLevelDetailOther.lua @@ -0,0 +1,61 @@ +local LEVEL_PREFIX_FORMAT = "+%s" +local stringFormat = string.format +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate +local CSXTextManagerGetText = CS.XTextManager.GetText + +local XUiPanelSkillLevelDetailOther = XClass(nil, "XUiPanelSkillLevelDetailOther") + +function XUiPanelSkillLevelDetailOther:Ctor(ui) + self.DetailGrids = {} + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.GridDetails.gameObject:SetActiveEx(false) + self.BtnClose.CallBack = function() self.GameObject:SetActiveEx(false) end +end + +function XUiPanelSkillLevelDetailOther:Refresh(characterId, skillId) + local detailGrids = self.DetailGrids + + local grid = detailGrids.ResonanceLevel + local resonanceLevel = XDataCenter.CharacterManager.GetResonanceSkillLevel(characterId, skillId) + if resonanceLevel and resonanceLevel > 0 then + if not grid then + grid = self:NewGrid() + detailGrids.ResonanceLevel = grid + end + + grid.TxtName.text = CSXTextManagerGetText("CharacterSkillLevelDetailResonanace") + grid.TxtLv.text = stringFormat(LEVEL_PREFIX_FORMAT, resonanceLevel) + grid.GameObject:SetActiveEx(true) + elseif grid then + grid.GameObject:SetActiveEx(false) + end + + local grid2 = detailGrids.AssignLevel + local assignLevel = XDataCenter.FubenAssignManager.GetSkillLevel(characterId, skillId) + if resonanceLevel and assignLevel > 0 then + if not grid2 then + grid2 = self:NewGrid() + detailGrids.AssignLevel = grid2 + end + + grid2.TxtName.text = CSXTextManagerGetText("CharacterSkillLevelDetailAssign") + grid2.TxtLv.text = stringFormat(LEVEL_PREFIX_FORMAT, assignLevel) + grid2.GameObject:SetActiveEx(true) + elseif grid2 then + grid2.GameObject:SetActiveEx(false) + end +end + +function XUiPanelSkillLevelDetailOther:NewGrid() + local grid = {} + local go = CSUnityEngineObjectInstantiate(self.GridDetails, self.PanelDetails) + grid.GameObject = go.gameObject + grid.Transform = go.transform + XTool.InitUiObject(grid) + grid.GameObject:SetActiveEx(true) + return grid +end + +return XUiPanelSkillLevelDetailOther \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPlayerInfo/XUiPlayerInfo.lua b/Resources/Scripts/XUi/XUiPlayerInfo/XUiPlayerInfo.lua new file mode 100644 index 00000000..dd58159f --- /dev/null +++ b/Resources/Scripts/XUi/XUiPlayerInfo/XUiPlayerInfo.lua @@ -0,0 +1,380 @@ +local XUiPlayerInfo = XLuaUiManager.Register(XLuaUi, "UiPlayerInfo") + +function XUiPlayerInfo:OnStart(data, chatContent, isOpenFromSetting) + self.Data = data + self.ChatContent = chatContent + self.IsOpenFromSetting = isOpenFromSetting --是否从设置预览进入 + self.Tab = { + BaseInfo = 1, + FightInfo = 2, + AppearanceInfo = 3, + } + --ButtonCallBack + self.BtnChat.CallBack = function() self:OnBtnChat() end + self.BtnAddFriend.CallBack = function() self:OnBtnAddFriend() end + self.BtnReport.CallBack = function() self:OnBtnReport() end + self.BtnClose.CallBack = function() self:OnBtnClose() end + self.BtnReplace.CallBack = function() self:OnBtnReplaceClick() end + self.BtnOut.CallBack = function() self:OnBtnOutClick() end + self.BtnRequestGuild.CallBack = function() self:OnBtnRequestGuildClick() end + self.BtnInviteGuild.CallBack = function() self:OnBtnInviteGuildClick() end + self.BtnBuildMentorships.CallBack = function() self:OnBtnBuildMentorshipsClick() end + self.BtnDisconnect.CallBack = function() self:OnBtnDisconnectClick() end + self.BtnGraduation.CallBack = function() self:OnBtnDisconnectClick() end + self.BtnBlock.CallBack = function() self:OnBtnBlockClick() end + + self.PanelBaseInfo = nil + self.PanelFightInfo = nil + self.PanelAppearanceInfo = nil + self.TabPanels = {} + --self.TabGroup:Init({ self.BtnBaseInfo, self.BtnFightInfo, self.BtnAppearance }, function(index) self:OnTabGroupClick(index) end) + --self.TabGroup:SelectIndex(self.Tab.BaseInfo) + self.BtnBaseInfo:SetDisable(true) + self.BtnFightInfo:SetDisable(true) + self.BtnAppearance:SetDisable(true) + self:UpdateInfo(self.Tab.BaseInfo) +end + +function XUiPlayerInfo:OnDestroy() + if self.PanelBaseInfo then + self.PanelBaseInfo:Destroy() + end +end + +function XUiPlayerInfo:OnTabGroupClick(index) + --功能未完成,暂时屏蔽 + if index == self.Tab.FightInfo or index == self.Tab.AppearanceInfo then + XUiManager.TipText("CommonNotOpen") + return + end + self:UpdateInfo(index) +end + +function XUiPlayerInfo:OnBtnChat() + -- 联机中不给跳转,防止跳出联机房间 + local unionFightData = XDataCenter.FubenUnionKillRoomManager.GetUnionRoomData() + if unionFightData and unionFightData.Id then + XUiManager.TipMsg(CS.XTextManager.GetText("UnionCantLeaveRoom")) + return + end + + XLuaUiManager.Close("UiChatServeMain") + + if XLuaUiManager.IsUiShow("UiSocial") then + XLuaUiManager.CloseWithCallback("UiPlayerInfo", function() + XEventManager.DispatchEvent(XEventId.EVENT_FRIEND_OPEN_PRIVATE_VIEW, self.Data.Id) + end) + else + XLuaUiManager.Open("UiSocial", function() + XEventManager.DispatchEvent(XEventId.EVENT_FRIEND_OPEN_PRIVATE_VIEW, self.Data.Id) + end) + end +end + +function XUiPlayerInfo:OnBtnAddFriend() + XDataCenter.SocialManager.ApplyFriend(self.Data.Id) +end + +function XUiPlayerInfo:OnBtnReport() + XLuaUiManager.Open("UiReport", self.Data.Id, self.Data.Name, self.Data.Level, self.ChatContent) +end + +function XUiPlayerInfo:OnBtnClose() + self:Close() +end + +function XUiPlayerInfo:UpdateInfo(index) + if self.Data.Id == XPlayer.Id then + self.BtnAddFriend.gameObject:SetActiveEx(false) + self.BtnChat.gameObject:SetActiveEx(false) + self.BtnReport.gameObject:SetActiveEx(false) + self.Mask.gameObject:SetActiveEx(false) + self.BtnBlock.gameObject:SetActiveEx(false) + elseif XDataCenter.SocialManager.CheckIsFriend(self.Data.Id) then + self.BtnAddFriend.gameObject:SetActiveEx(false) + self.BtnChat.gameObject:SetActiveEx(true) + self.BtnReport.gameObject:SetActiveEx(true) + self.Mask.gameObject:SetActiveEx(true) + self.BtnBlock.gameObject:SetActiveEx(true) + else + self.BtnAddFriend.gameObject:SetActiveEx(true) + self.BtnChat.gameObject:SetActiveEx(false) + self.BtnReport.gameObject:SetActiveEx(true) + self.Mask.gameObject:SetActiveEx(true) + self.BtnBlock.gameObject:SetActiveEx(true) + end + + if index == self.Tab.BaseInfo then + if not self.PanelBaseInfo then + local obj = CS.UnityEngine.Object.Instantiate(self.Obj:GetPrefab("PlayerInfoBase")) + obj.transform:SetParent(self.PanelContent, false) + self.PanelBaseInfo = XUiPlayerInfoBase.New(obj, self) + self.TabPanels[index] = self.PanelBaseInfo + self.TabPanels[index].Type = self.Tab.BaseInfo + else + self.PanelBaseInfo:UpdateInfo() + end + self:UpdateGuildInfo() + elseif index == self.Tab.FightInfo then + if not self.PanelFightInfo then + local obj = CS.UnityEngine.Object.Instantiate(self.Obj:GetPrefab("PlayerInfoFight")) + obj.transform:SetParent(self.PanelContent, false) + self.PanelFightInfo = XUiPlayerInfoFight.New(obj, self) + self.TabPanels[index] = self.PanelFightInfo + self.TabPanels[index].Type = self.Tab.FightInfo + else + self.PanelFightInfo:UpdateInfo() + end + elseif index == self.Tab.AppearanceInfo then + if not self.PanelAppearanceInfo then + local obj = CS.UnityEngine.Object.Instantiate(self.Obj:GetPrefab("PlayerInfoAppearance")) + obj.transform:SetParent(self.PanelContent, false) + self.PanelAppearanceInfo = XUiPlayerInfoAppearance.New(obj, self) + self.TabPanels[index] = self.PanelAppearanceInfo + self.TabPanels[index].Type = self.Tab.AppearanceInfo + else + self.PanelAppearanceInfo:UpdateInfo() + end + end + self:UpdateMentorInfo() + self:ActivePanel(index) +end + +function XUiPlayerInfo:UpdateGuildInfo() + -- 如果自己有公会 + --查看一个有公会的玩家 + -- 同一个公会 :管理级别以上:更换职位、踢出公会 + -- 不同公会 :都不显示 + --查看一个没有公会的玩家 :管理级别以上:邀请入会 + -- 如果自己没有公会 + --查看一个有公会的玩家 :申请入会 + --查看一个没有公会的玩家 :都不显示 + self:ResetGuildBtns() + if not self.Data then return end + local targetGuildId = self.Data.GuildDetail and self.Data.GuildDetail.GuildId + local targetRankLevel = self.Data.GuildDetail and self.Data.GuildDetail.GuildRankLevel + + if self.Data.Id == XPlayer.Id then return end + + if XDataCenter.GuildManager.IsJoinGuild() then + local isAdministor = XDataCenter.GuildManager.IsGuildAdminister() + local myRankLevel = XDataCenter.GuildManager.GetCurRankLevel() + if XDataCenter.GuildManager.CheckMemberOperatePermission(self.Data.Id) then + self.BtnOut.gameObject:SetActiveEx(true) + self.BtnReplace.gameObject:SetActiveEx(true) + else + if isAdministor then + self.BtnInviteGuild.gameObject:SetActiveEx(true) + end + end + else + if targetGuildId ~= nil and targetGuildId > 0 then + self.BtnRequestGuild.gameObject:SetActiveEx(true) + end + end +end + +function XUiPlayerInfo:UpdateMentorInfo() + local mentorData = XDataCenter.MentorSystemManager.GetMentorData() + local IsSelf = self.Data.Id == XPlayer.Id + local IsMyMentorShip = mentorData:IsMyMentorShip(self.Data.Id) + local IdentityType = self.Data.MentorDetail and self.Data.MentorDetail.MentorType or XMentorSystemConfigs.IdentityType.None + local IsSameIdentity = IdentityType == mentorData:GetIdentity() + local IsCanShow = not IsSelf and not IsSameIdentity and IdentityType ~= XMentorSystemConfigs.IdentityType.None + local IsCanGraduatLevel = self:CheckIsCanGraduatLevel(mentorData) + self.BtnBuildMentorships.gameObject:SetActiveEx(IsCanShow and not IsMyMentorShip) + self.BtnDisconnect.gameObject:SetActiveEx((not IsCanGraduatLevel) and IsCanShow and IsMyMentorShip) + self.BtnGraduation.gameObject:SetActiveEx(IsCanGraduatLevel and IsCanShow and IsMyMentorShip) +end + +function XUiPlayerInfo:ResetGuildBtns() + self.BtnRequestGuild.gameObject:SetActiveEx(false) + self.BtnInviteGuild.gameObject:SetActiveEx(false) + self.BtnOut.gameObject:SetActiveEx(false) + self.BtnReplace.gameObject:SetActiveEx(false) +end + +function XUiPlayerInfo:HasModifyGuildAccess() + if not XDataCenter.GuildManager.IsGuildAdminister() then + XUiManager.TipMsg(CS.XTextManager.GetText("GuildNotAdministor")) + return true + end + return false +end + +function XUiPlayerInfo:ChecGuildKickOut() + if not XDataCenter.GuildManager.IsJoinGuild() then + XUiManager.TipMsg(CS.XTextManager.GetText("GuildKickOutByAdministor")) + return true + end + return false +end + +function XUiPlayerInfo:OnBtnReplaceClick() + -- 中途被踢出公会 + if self:ChecGuildKickOut() then return end + -- 职位变更 + if self:HasModifyGuildAccess() then return end + -- 是否有更换职位的权利 + local memberList = XDataCenter.GuildManager.GetMemberList() + local memberInfo = memberList[self.Data.Id] + if memberInfo then + XLuaUiManager.Open("UiGuildChangePosition", XGuildConfig.TipsType.ChangePosition, memberInfo) + end +end + +function XUiPlayerInfo:OnBtnOutClick() + -- 中途被踢出公会 + if self:ChecGuildKickOut() then return end + -- 职位变更 + if self:HasModifyGuildAccess() then return end + + local title = CS.XTextManager.GetText("GuildDialogTitle") + local content = CS.XTextManager.GetText("GuildIsKickMember") + + XUiManager.DialogTip(title, content, XUiManager.DialogType.Normal, function() + end, function() + XDataCenter.GuildManager.GuildKickMember(self.Data.Id, function() + XUiManager.TipMsg(CS.XTextManager.GetText("GuildKickMemberSuccess")) + self:Close() + end) + end) +end + +-- 申请入会 +function XUiPlayerInfo:OnBtnRequestGuildClick() + if not self.Data then return end + if self.Data.GuildDetail and self.Data.GuildDetail.GuildId and self.Data.GuildDetail.GuildId > 0 then + XDataCenter.GuildManager.ApplyToJoinGuildRequest(self.Data.GuildDetail.GuildId, function() + XUiManager.TipMsg(CS.XTextManager.GetText("GuildApplyRequestSuccess")) + self:Close() + end) + end +end + +-- 邀请入会 +function XUiPlayerInfo:OnBtnInviteGuildClick() + if not self.Data then return end + -- 中途被踢出公会 + if self:ChecGuildKickOut() then return end + -- 职位变更 + if self:HasModifyGuildAccess() then return end + + XDataCenter.GuildManager.GuildRecruit(self.Data.Id, function() + XUiManager.TipMsg(CS.XTextManager.GetText("GuildSendRequestSuccess")) + self:Close() + end, true) +end + +-- 缔结师徒关系 +function XUiPlayerInfo:OnBtnBuildMentorshipsClick() + if not self.Data then return end + + local mentorData = XDataCenter.MentorSystemManager.GetMentorData() + local IsCanGraduatLevel = self:CheckIsCanGraduatLevel(mentorData) + local hintStr = "" + + if not mentorData:IsCanDoApply(true) then + return + else + if mentorData:IsTeacher()then + local IsHasTeacher = self.Data.MentorDetail.MentorId and self.Data.MentorDetail.MentorId > 0 + if IsHasTeacher then + XUiManager.TipMsg(CS.XTextManager.GetText("MentorDoApplyTeachaeMaxHint")) + return + end + if IsCanGraduatLevel then + XUiManager.TipMsg(CS.XTextManager.GetText("MentorDoApplyLevelOverHint")) + return + end + end + end + + XDataCenter.MentorSystemManager.ApplyMentorRequest({self.Data.Id}, function() + XUiManager.TipText("MentorShipBuildSendHint") + self:Close() + end) +end + +-- 解除师徒关系 +function XUiPlayerInfo:OnBtnDisconnectClick() + if not self.Data then return end + local hintStr = "" + local mentorData = XDataCenter.MentorSystemManager.GetMentorData() + local lastLoginTime = mentorData:GetMenberLastLoginTimeById(self.Data.Id) + local IsOverTime = XDataCenter.MentorSystemManager.JudgeFailPassTime(lastLoginTime) + + local IsCanGraduatLevel = self:CheckIsCanGraduatLevel(mentorData) + if IsCanGraduatLevel then + if IsOverTime then + hintStr = "MentorDoGraduateFailPassHint" + else + hintStr = "MentorDoGraduateHint" + end + else + if IsOverTime then + hintStr = "MentorDoMentorShipDisconnectFailPassHint" + else + hintStr = "MentorDoMentorShipDisconnectHint" + end + end + self:TipDialog(nil,function () + XDataCenter.MentorSystemManager.TickMentorRequest(self.Data.Id, function() + XUiManager.TipText("MentorShipDisconnectHint") + self:Close() + end) + end,hintStr) +end + +--拉黑 +function XUiPlayerInfo:OnBtnBlockClick() + if not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.SocialFriend) then + XUiManager.TipText("FunctionNotOpen") + return + end + + if XDataCenter.SocialManager.GetBlackData(self.Data.Id) then + XUiManager.TipText("SocialBlackEnterOver") + return + end + + local content = CS.XTextManager.GetText("SocialBlackTipsDesc") + local sureCallback = function() + local cb = function() + self:UpdateInfo(self.Tab.BaseInfo) + end + XDataCenter.SocialManager.RequestBlackPlayer(self.Data.Id, cb) + end + XUiManager.DialogTip(nil, content, XUiManager.DialogType.Normal, nil, sureCallback) +end + +function XUiPlayerInfo:CheckIsCanGraduatLevel(mentorData) + local IsCanGraduatLevel = false + if mentorData:IsTeacher() then + IsCanGraduatLevel = self.Data.Level >= XMentorSystemConfigs.GetMentorSystemData("GraduateLv") + elseif mentorData:IsStudent() then + IsCanGraduatLevel = XPlayer.Level >= XMentorSystemConfigs.GetMentorSystemData("GraduateLv") + end + return IsCanGraduatLevel +end + +function XUiPlayerInfo:SetGameObjActive(obj, active) + if obj then + obj.GameObject:SetActiveEx(active) + end +end + +function XUiPlayerInfo:ActivePanel(index) + for _, v in pairs(self.TabPanels) do + if v.Type == index then + v.GameObject:SetActiveEx(true) + else + v.GameObject:SetActiveEx(false) + end + end +end + +function XUiPlayerInfo:TipDialog(cancelCb, confirmCb,TextKey) + CsXUiManager.Instance:Open("UiDialog", CS.XTextManager.GetText("TipTitle"), CS.XTextManager.GetText(TextKey), + XUiManager.DialogType.Normal, cancelCb, confirmCb) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPlayerInfo/XUiPlayerInfoAppearance.lua b/Resources/Scripts/XUi/XUiPlayerInfo/XUiPlayerInfoAppearance.lua new file mode 100644 index 00000000..ca0b77ce --- /dev/null +++ b/Resources/Scripts/XUi/XUiPlayerInfo/XUiPlayerInfoAppearance.lua @@ -0,0 +1,11 @@ +XUiPlayerInfoAppearance = XClass(nil, "XUiPlayerInfoAppearance") +function XUiPlayerInfoAppearance:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiPlayerInfoAppearance:UpdateInfo() +end + +return XUiPlayerInfoAppearance \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPlayerInfo/XUiPlayerInfoBase.lua b/Resources/Scripts/XUi/XUiPlayerInfo/XUiPlayerInfoBase.lua new file mode 100644 index 00000000..c8a3c391 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPlayerInfo/XUiPlayerInfoBase.lua @@ -0,0 +1,110 @@ +XUiPlayerInfoBase = XClass(nil, "XUiPlayerInfoBase") +local XUiPanelNameplate = require("XUi/XUiNameplate/XUiPanelNameplate") +local TextManager = CS.XTextManager +local BtnGroupIndex = { + PlayerInfo = 1, + Collection = 2, + CharacterList = 3, + FashionList = 4 +} + +function XUiPlayerInfoBase:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + + self.BtnCopy.CallBack = function() self:OnBtnCopy() end + self.Panels = {} + self.Panels[BtnGroupIndex.PlayerInfo] = XUiPanelInfo.New(self.PanelInfo, self.RootUi) + self.Panels[BtnGroupIndex.Collection] = XUiPanelCollectionScrollPlayerInfo.New(self.PanelCollectionScroll, self.RootUi) + self.Panels[BtnGroupIndex.CharacterList] = XUiPanelCharacterList.New(self.PanelCharacterList, self.RootUi) + self.Panels[BtnGroupIndex.FashionList] = XUiPanelFashionPlayerInfo.New(self.PanelFashionList, self.RootUi) + + self.InfoPanel = self.Panels[BtnGroupIndex.PlayerInfo] + self.FashionListPanel = self.Panels[BtnGroupIndex.PlayerInfo] + + self.UiPanelNameplate = XUiPanelNameplate.New(self.PanelNameplate, self) + self:UpdateInfo() + self:InitBtnGroup() +end + +function XUiPlayerInfoBase:Destroy() + XDataCenter.ExhibitionManager.ClearCharacterInfo() +end + +function XUiPlayerInfoBase:InitBtnGroup() + self.CurType = BtnGroupIndex.PlayerInfo + self.BtnList = { + [1] = self.BtnPlayerInfo, + [2] = self.BtnCollection, + [3] = self.BtnCharacter, + [4] = self.BtnFashion + } + self.BtnGroup:Init(self.BtnList, function(index) self:SelectType(index) end) + self.BtnGroup:SelectIndex(self.CurType) +end + +function XUiPlayerInfoBase:SelectType(index) + if self.SelectedIndex and self.SelectedIndex == index then + return + end + + self.Panels[index]:Show() + if self.SelectedIndex then + self.Panels[self.SelectedIndex]:Close() + end + + self.SelectedIndex = index +end + +function XUiPlayerInfoBase:UpdateInfo() + --更新展示厅的临时数据 + XDataCenter.ExhibitionManager.SetCharacterInfo(self.RootUi.Data.GatherIds) + local data = self.RootUi.Data + XUiPLayerHead.InitPortrait(data.CurrHeadPortraitId, data.CurrHeadFrameId, self.Head) + --------------------------巴别塔徽章显示------------->>> + local babelTowerIcon = XDataCenter.MedalManager.GetScoreTitleIconById(data.BabelTowerTitleInfo and data.BabelTowerTitleInfo.Id) + local babelTowerLevel = data.BabelTowerTitleInfo and data.BabelTowerTitleInfo.Score or 0 + + if babelTowerIcon then + self.BabelMedalImage:SetRawImage(babelTowerIcon) + self.TxtBabelLevel.text = babelTowerLevel + self.BabelMedalImage.gameObject:SetActiveEx(true) + else + self.BabelMedalImage.gameObject:SetActiveEx(false) + end + --------------------------巴别塔徽章显示-------------<<< + self.TxtName.text = XDataCenter.SocialManager.GetPlayerRemark(data.Id, data.Name) + + XUiPlayerLevel.UpdateLevel(data.Level, self.level) + + self.TxtId.text = data.Id + if data.Likes > 9999 then + self.TxtLikeNum.text = "9999+" + else + self.TxtLikeNum.text = data.Likes + end + + local sign = data.Sign + if sign == nil or string.len(sign) == 0 then + local text = TextManager.GetText('CharacterSignTip') + self.TxtSign.text = text + else + self.TxtSign.text = sign + end + + if data.CurrentWearNameplate ~= 0 then + self.UiPanelNameplate:UpdateDataById(data.CurrentWearNameplate) + self.UiPanelNameplate.GameObject:SetActiveEx(true) + else + self.UiPanelNameplate.GameObject:SetActiveEx(false) + end +end + +function XUiPlayerInfoBase:OnBtnCopy() + CS.XAppPlatBridge.CopyStringToClipboard(tostring(self.TxtId.text)) + XUiManager.TipText("Clipboard", XUiManager.UiTipType.Tip) +end + +return XUiPlayerInfoBase \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPlayerInfo/XUiPlayerInfoCharacterGrid.lua b/Resources/Scripts/XUi/XUiPlayerInfo/XUiPlayerInfoCharacterGrid.lua new file mode 100644 index 00000000..9dff61fe --- /dev/null +++ b/Resources/Scripts/XUi/XUiPlayerInfo/XUiPlayerInfoCharacterGrid.lua @@ -0,0 +1,93 @@ +XUiPlayerInfoCharacterGrid = XClass(nil, "XUiPlayerInfoCharacterGrid") +local XEquip = require("XEntity/XEquip/XEquip") +local XPartner = require("XEntity/XPartner/XPartner") + +function XUiPlayerInfoCharacterGrid:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.PanelGrade.gameObject:SetActiveEx(false) + self.ImgInSupport.gameObject:SetActiveEx(false) + self:AutoAddListener() +end + +function XUiPlayerInfoCharacterGrid:Init(playerId) + self.PlayerId = playerId +end + +function XUiPlayerInfoCharacterGrid:AutoAddListener() + self.BtnCharacter.CallBack = function() + self:OnBtnCharacter() + end +end + +function XUiPlayerInfoCharacterGrid:OnBtnCharacter() + XDataCenter.PlayerInfoManager.RequestCharacterInfoData(self.PlayerId, self.Character.Id, function(characterInfo) + local character = XCharacter.New(characterInfo.CharacterData) + local equipList = {} + local assignChapterRecords = characterInfo.AssignChapterRecords + for _, v in pairs(characterInfo.EquipData) do + local equip = XEquip.New(v) + table.insert(equipList, equip) + end + -- XPartner + local partner = nil + if characterInfo.PartnerData then + partner = XPartner.New(characterInfo.PartnerData.Id, characterInfo.PartnerData.TemplateId, true) + partner:UpdateData(characterInfo.PartnerData) + partner:SetIsBelongSelf(characterInfo.IsSelfData) + end + XLuaUiManager.Open("UiPanelCharPropertyOther", character, equipList, characterInfo.WeaponFashionId, assignChapterRecords, partner) + end) +end + +function XUiPlayerInfoCharacterGrid:UpdateGrid(character, appearanceShowType, assistCharacterDetail) + if not character then + XLog.Error("XUiPlayerInfoCharacterGrid:UpdateGrid函数参数错误:参数character不能为空") + return + end + self.Character = character.Data + + if (appearanceShowType == XPlayerInfoConfigs.CharactersAppearanceType.All) then + -- 展示选项为全部,判断是否拥有该成员 + local isLocked = character.IsLocked + + self.ImgInSupport.gameObject:SetActiveEx(false) + self.PanelLock.gameObject:SetActiveEx(isLocked) + self.PanelLevel.gameObject:SetActiveEx(not isLocked) + self.RImgQuality.gameObject:SetActiveEx(not isLocked) + self.BtnCharacter.gameObject:SetActiveEx(not isLocked) + + -- 内部使用了characterId来获取自己的角色时装id,如果对应不同时装有不同的终解头像,这里需要更改 + self.RImgHeadIcon:SetRawImage(XDataCenter.CharacterManager.GetCharSmallHeadIcon(self.Character.Id,nil,true)) + + if not isLocked then + self.TxtLevel.text = self.Character.Level + self.RImgQuality:SetRawImage(XCharacterConfigs.GetCharacterQualityIcon(self.Character.Quality)) + -- 是否为支援角色 + if assistCharacterDetail and self.Character.Id == assistCharacterDetail.Id then + self.ImgInSupport.gameObject:SetActiveEx(true) + end + end + else + -- 展示选项为自选,拥有该成员,更新信息 + self.PanelLock.gameObject:SetActiveEx(false) + self.PanelLevel.gameObject:SetActiveEx(true) + self.RImgQuality.gameObject:SetActiveEx(true) + self.BtnCharacter.gameObject:SetActiveEx(true) + self.ImgInSupport.gameObject:SetActiveEx(false) + + self.TxtLevel.text = self.Character.Level + self.RImgQuality:SetRawImage(XCharacterConfigs.GetCharacterQualityIcon(self.Character.Quality)) + + -- 内部使用了characterId来获取自己的角色时装id,如果对应不同时装有不同的终解头像,这里需要更改 + self.RImgHeadIcon:SetRawImage(XDataCenter.CharacterManager.GetCharSmallHeadIcon(self.Character.Id,nil,true)) + + -- 是否为支援角色 + if assistCharacterDetail and self.Character.Id == assistCharacterDetail.Id then + self.ImgInSupport.gameObject:SetActiveEx(true) + end + end +end + + diff --git a/Resources/Scripts/XUi/XUiPlayerInfo/XUiPlayerInfoClothGrid.lua b/Resources/Scripts/XUi/XUiPlayerInfo/XUiPlayerInfoClothGrid.lua new file mode 100644 index 00000000..b1b54fa3 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPlayerInfo/XUiPlayerInfoClothGrid.lua @@ -0,0 +1,33 @@ +XUiPlayerInfoClothGrid = XClass(nil, "XUiPlayerInfoClothGrid") + +function XUiPlayerInfoClothGrid:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:AutoAddListener() +end + +function XUiPlayerInfoClothGrid:AutoAddListener() + self.BtnFashion.CallBack = function() self:OnBtnFashion() end +end + +function XUiPlayerInfoClothGrid:OnBtnFashion() + local IsWeaponFashion = self.FashionType == XPlayerInfoConfigs.FashionType.Weapon + XLuaUiManager.Open("UiFashionDetail", self.Fashion.Id, IsWeaponFashion) +end + +function XUiPlayerInfoClothGrid:UpdateGrid(fashion, fashionType) + if not fashion then + XLog.Error("XUiPlayerInfoClothGrid:UpdateGrid函数参数错误:参数fashion不能为空") + return + end + local isLocked = fashion.IsLocked + + self.Fashion = fashion.Data + self.FashionType = fashionType + self.TxtFashionName.text = fashion.Data.Name + + self.ImgFashion:SetRawImage(fashion.Data.BigIcon) + self.PanelLock.gameObject:SetActiveEx(isLocked) + self.BtnFashion.gameObject:SetActiveEx(not isLocked) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPlayerInfo/XUiPlayerInfoFetters.lua b/Resources/Scripts/XUi/XUiPlayerInfo/XUiPlayerInfoFetters.lua new file mode 100644 index 00000000..96b08c51 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPlayerInfo/XUiPlayerInfoFetters.lua @@ -0,0 +1,33 @@ +XUiPlayerInfoFetters = XClass(nil, "XUiPlayerInfoFetters") +function XUiPlayerInfoFetters:Ctor(ui, isFriend, exp) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.BtnClose.CallBack = function() self.GameObject:SetActive(false) end + self:UpdateInfo(isFriend, exp) +end + +function XUiPlayerInfoFetters:UpdateInfo(isFriend, exp) + if isFriend then + self.PanelNormal.gameObject:SetActive(true) + self.PanelNone.gameObject:SetActive(false) + local fettersData = XPlayerInfoConfigs.GetLevelDataByExp(exp) + self.TxtLevel.text = fettersData.Level + self.TxtAdd.text = fettersData.Add .. "%" + local max = XPlayerInfoConfigs.GetCurLevelExp(fettersData.Level) - XPlayerInfoConfigs.GetCurLevelExp(fettersData.Level - 1) + local cur = exp - XPlayerInfoConfigs.GetCurLevelExp(fettersData.Level - 1) + self.TxtMax.text = "/" .. max + self.TxtCur.text = cur + local progress = 0 + if max ~= 0 then + progress = cur / max + end + self.ImgProgress.fillAmount = 0 + self.ImgProgress:DOFillAmount(progress, 0.3) + else + self.PanelNormal.gameObject:SetActive(false) + self.PanelNone.gameObject:SetActive(true) + end +end + +return XUiPlayerInfoFetters \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPlayerInfo/XUiPlayerInfoFight.lua b/Resources/Scripts/XUi/XUiPlayerInfo/XUiPlayerInfoFight.lua new file mode 100644 index 00000000..00634ef9 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPlayerInfo/XUiPlayerInfoFight.lua @@ -0,0 +1,11 @@ +XUiPlayerInfoFight = XClass(nil, "XUiPlayerInfoFight") +function XUiPlayerInfoFight:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiPlayerInfoFight:UpdateInfo() +end + +return XUiPlayerInfoFight \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPlayerUp/XUiPlayerUp.lua b/Resources/Scripts/XUi/XUiPlayerUp/XUiPlayerUp.lua new file mode 100644 index 00000000..f7867bc5 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPlayerUp/XUiPlayerUp.lua @@ -0,0 +1,275 @@ +local XUiPlayerUp = XLuaUiManager.Register(XLuaUi, "UiPlayerUp") +local WAIT_CLOSE_TIME = 2 +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate + +function XUiPlayerUp:OnAwake() + self:InitAutoScript() +end + +function XUiPlayerUp:OnStart(oldLevel, newLevel) + self.OldLevel = oldLevel + self.NewLevel = newLevel + + self.BtnCloseTs.gameObject:SetActive(true) + self.IsAnimating = true + self.Timer = nil + + self:Update() +end + +function XUiPlayerUp:OnEnable() + CS.XAudioManager.PlaySound(XSoundManager.UiBasicsMusic.Common_UiPlayerUp) +end + +function XUiPlayerUp:InitAutoScript() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiPlayerUp:GetAutoKey(uiNode, eventName) + if not uiNode then + return + end + return eventName .. uiNode:GetHashCode() +end + +function XUiPlayerUp:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then + return + end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiPlayerUp:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiPlayerUp:AutoAddListener() + self.AutoCreateListeners = {} + self:RegisterClickEvent(self.BtnClose, self.OnBtnCloseClick) +end + +--@region 界面信息 +function XUiPlayerUp:Update() + self:SetInitUi() + self:UpdateInitText() + self:PlayAniPlayerUpBegin() + self:SetReward() +end + +function XUiPlayerUp:SetInitUi() + self:SetText() + self.HonorLevelUp.gameObject:SetActiveEx(self:IsHonorLevelOpen()) + self.PlayerUp.gameObject:SetActiveEx(not self:IsHonorLevelOpen()) +end + +function XUiPlayerUp:SetText() + if self:IsHonorLevelOpen() then + self.TxtLv1 = self.TxtLv1_HonorLevelUp + self.TxtLv2 = self.TxtLv2_HonorLevelUp + self.TxtLevelName = self.TxtLevelName_HonorLevelUp + self.TxtMaxFriendCount = self.TxtMaxFriendCount_HonorLevelUp + else + self.TxtLv1 = self.TxtLv1_PlayerUp + self.TxtLv2 = self.TxtLv2_PlayerUp + self.TxtLevelName = self.TxtLevelName_PlayerUp + self.TxtMaxFriendCount = self.TxtMaxFriendCount_PlayerUp + self.TxtFreeActionPoint = self.TxtFreeActionPoint_PlayerUp + end +end + +function XUiPlayerUp:UpdateInitText() + local addActionPoint = self:GetMaxActionPoint(self.NewLevel) - self:GetMaxActionPoint(self.OldLevel) + local differenceGrade = self.NewLevel - self.OldLevel + local num = 0 + for i = 1, differenceGrade do + num = num + self:GetFreeActionPoint(self.OldLevel + i - 1) + end + + if not self:IsHonorLevelOpen() then + self.TxtFreeActionPoint.text = num + end + + self.TxtMaxFriendCount.text = CS.XTextManager.GetText("LevelActionPoint", self:GetMaxActionPoint(self.OldLevel), addActionPoint) + self.TxtLv1.text = self.OldLevel + self.TxtLv2.text = self.NewLevel + self.TxtLevelName.text = self:GetTxtLevelName() + self.TxtLevelNameFirst.text = self:GetTxtLevelName() -- 国际服升级字母不插入空格 +end + +function XUiPlayerUp:SetReward() + if not self:IsHonorLevelOpen() then + return + end + + local rewards = self:GetRewards() + local rewardCount = #rewards + + for i = 1, rewardCount do + local ui = CSUnityEngineObjectInstantiate(self.PanelReward,self.UiContent) + ui.gameObject:SetActiveEx(true) + ui.gameObject.name = string.format("PanelReward%d", i) + local panel = XUiGridCommon.New(self, ui) + panel.GameObject:SetActiveEx(true) + local reward = rewards[i] + panel:Refresh(reward) + end +end + +--合并奖励,处理等级连升的情况 +function XUiPlayerUp:GetRewards() + local newRewards = {} + for i=self.OldLevel,self.NewLevel-1 do + local rewards = XRewardManager.GetRewardList(XPlayerManager.GetRewardId(i)) + for i,reward in ipairs(rewards) do + local isInside = false + for i,newReward in ipairs(newRewards) do + if newReward.TemplateId == reward.TemplateId and newReward.RewardType == reward.RewardType then + newReward.Count = newReward.Count + reward.Count + isInside = true + break + end + end + + if not isInside then + local xReward = {} + for k,v in pairs(reward) do + xReward[k] = v + end + table.insert(newRewards, xReward) + end + end + end + + return newRewards +end +--@endregion + +--@region 120级依然显示小队等级的,不显示荣耀勋阶,这里特殊处理 +function XUiPlayerUp:IsHonorLevelOpen() + if XPlayer.GetMaxLevel() == self.NewLevel then + return false + else + return XPlayer.IsHonorLevelOpen() + end +end + +function XUiPlayerUp:GetMaxActionPoint(level) + return XPlayerManager.GetMaxActionPoint(level, self:IsHonorLevelOpen()) +end + +function XUiPlayerUp:GetFreeActionPoint(level) + if not self:IsHonorLevelOpen() then + return XPlayerManager.GetFreeActionPoint(level, self:IsHonorLevelOpen()) + else + return 0 + end +end + +function XUiPlayerUp:GetTxtLevelName() -- 国际服升级单子中间加空格 + if self:IsHonorLevelOpen() then + return CS.XTextManager.GetText("HonorLevel") .." ".. CS.XTextManager.GetText("Promote") + else + return CS.XTextManager.GetText("PlayerLevel") .." ".. CS.XTextManager.GetText("Promote") + end +end +--@endregion + +--字符之间插入空格 +function XUiPlayerUp:StringInsertBlank(s) + local tb = {} + local newS = "" + local index = 1 + for utfChar in string.gmatch(s, "[%z\1-\127\194-\244][\128-\191]*") do + if index == 1 then + newS = newS .. utfChar + else + newS = newS .. " " .. utfChar + end + index = index + 1 + end + + return newS +end + +function XUiPlayerUp:PlayAniPlayerUpBegin() + local aniName = self:GetAnimationName(true) + self:PlayAnimation(aniName, function() + self.IsAnimating = false + + local time = 0 + self.Timer = XScheduleManager.Schedule(function() + time = time + 1 + if time >= WAIT_CLOSE_TIME and self.BtnCloseTs.gameObject.activeInHierarchy then + self:OnBtnCloseClick() + end + end, 1000, WAIT_CLOSE_TIME) + end) +end + +function XUiPlayerUp:PlayAniPlayerUpEnd() + local aniName = self:GetAnimationName(false) + self:PlayAnimation(aniName, function() + if XTool.UObjIsNil(self.BtnClose) then + return + end + self.IsAnimating = false + + if self.Timer ~= nil then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end + self:Close() + XEventManager.DispatchEvent(XEventId.EVENT_PLAYER_LEVEL_UP_ANIMATION_END) + end) +end + +function XUiPlayerUp:GetAnimationName(isBegin) + local aniName + if self:IsHonorLevelOpen() then + if isBegin then + aniName = "HonorLevelUpEnable" + else + aniName = "HonorLevelUpEnd" + end + else + if isBegin then + aniName = "AniPlayerUpBegin" + else + aniName = "AniPlayerUpEnd" + end + end + return aniName +end + +function XUiPlayerUp:OnBtnCloseClick() + if self.IsAnimating then + return + end + + self.IsAnimating = true + self:PlayAniPlayerUpEnd() +end + +function XUiPlayerUp:OnDestroy() + if self.Timer ~= nil then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end + + XTipManager.Execute() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPokemon/XUiGridPokemonChapter.lua b/Resources/Scripts/XUi/XUiPokemon/XUiGridPokemonChapter.lua new file mode 100644 index 00000000..ccb1f7b3 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPokemon/XUiGridPokemonChapter.lua @@ -0,0 +1,43 @@ +local XUiGridPokemonChapter = XClass(nil,"XUiGridPokemonChapter") +function XUiGridPokemonChapter:Ctor(ui) + ---@type UnityEngine.GameObject + self.GameObject = ui + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiGridPokemonChapter:Refresh(index) + local chapters = XDataCenter.PokemonManager.GetChapters() + self.ChapterCfg = chapters[index] + self.TxtName.text = XPokemonConfigs.GetChapterName(self.ChapterCfg.Id) + self.RImgDz:SetRawImage(XPokemonConfigs.GetChapterBackground(self.ChapterCfg.Id)) + local isOpen,desc = self:CheckIsOpen() + self.Imglock.gameObject:SetActiveEx(not isOpen) + self.TxtUnlockCondition.text = desc + local passCount = XDataCenter.PokemonManager.GetPassedCountByChapterId(self.ChapterCfg.Id) + local totalCount = XPokemonConfigs.GetStageCountByChapter(XDataCenter.PokemonManager.GetCurrActivityId(),self.ChapterCfg.Id) + self.TxtProgress.text = CS.XTextManager.GetText("PokemonChapterProgress",passCount,totalCount) +end + +function XUiGridPokemonChapter:CheckIsOpen() + local isInTime = XFunctionManager.CheckInTimeByTimeId(self.ChapterCfg.TimeId) + local isOpen = true + local desc = "" + local condition = self.ChapterCfg.OpenCondition + if condition and condition ~= 0 then + isOpen,desc = XConditionManager.CheckCondition(self.ChapterCfg.OpenCondition) + end + return isInTime and isOpen, isInTime and desc or XUiHelper.GetInTimeDesc(XFunctionManager.GetStartTimeByTimeId(self.ChapterCfg.TimeId), XFunctionManager.GetEndTimeByTimeId(self.ChapterCfg.TimeId)) +end + +function XUiGridPokemonChapter:OnClickGrid(index) + local isOpen,desc = self:CheckIsOpen() + if not isOpen then + XUiManager.TipMsg(desc) + return + end + XDataCenter.PokemonManager.SetSelectChapter(index) + XLuaUiManager.Open("UiPokemonMain") +end + +return XUiGridPokemonChapter \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPokemon/XUiGridPokemonPortrait.lua b/Resources/Scripts/XUi/XUiPokemon/XUiGridPokemonPortrait.lua new file mode 100644 index 00000000..5767aa42 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPokemon/XUiGridPokemonPortrait.lua @@ -0,0 +1,27 @@ +local XUiGridPokemonPortrait = XClass(nil, "XUiGridPokemonPortrait") + +function XUiGridPokemonPortrait:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.MonsterId = 0 + XTool.InitUiObject(self) +end + + +function XUiGridPokemonPortrait:Refresh(monsterId, isInfinityStage) + self.GameObject:SetActiveEx(monsterId) + if not monsterId then + return + end + self.MonsterId = monsterId + if isInfinityStage then + self.ImgBossIcon:SetRawImage(XPokemonConfigs.GetMonsterHeadIcon(monsterId)) + self.ImgTheAttack:SetSprite(XPokemonConfigs.GetMonsterCareerIcon(monsterId)) + else + self.ImgBossIcon:SetRawImage(XPokemonConfigs.GetStageMonsterHeadIcon(monsterId)) + self.ImgTheAttack:SetSprite(XPokemonConfigs.GetStageMonsterCareerIcon(monsterId)) + end + +end + +return XUiGridPokemonPortrait \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPokemon/XUiGridPokemonStage.lua b/Resources/Scripts/XUi/XUiPokemon/XUiGridPokemonStage.lua new file mode 100644 index 00000000..4e8c9cb3 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPokemon/XUiGridPokemonStage.lua @@ -0,0 +1,42 @@ +local XUiGridPokemonStage = XClass(nil, "XUiGridPokemonStage") + +function XUiGridPokemonStage:Ctor(ui, stageId, callback) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.StageId = stageId + self.Callback = callback + XTool.InitUiObject(self) + self.Btn.CallBack = function() + self.Callback(self.StageId) + end +end + + + +function XUiGridPokemonStage:Refresh(stageId) + self.StageId = stageId + self.TxtName.text = XDataCenter.PokemonManager.GetStageName(stageId) + self.ImgStage:SetRawImage(XDataCenter.PokemonManager.GetStageIcon(stageId)) + if self.ImgBoss then + if XDataCenter.PokemonManager.IsBossStage(stageId) then + self.ImgBoss.gameObject:SetActiveEx(true) + self.ImgBoss:SetRawImage(XDataCenter.PokemonManager.GetStageBossHeadIcon(stageId)) + else + self.ImgBoss.gameObject:SetActiveEx(false) + end + end + if self.CommonFuBenClear then + if XDataCenter.PokemonManager.CheckStageIsPassed(XDataCenter.PokemonManager.GetStageFightStageId(stageId)) and self.CommonFuBenClear then + self.CommonFuBenClear.gameObject:SetActiveEx(true) + else + self.CommonFuBenClear.gameObject:SetActiveEx(false) + end + end + + if self.PokemonPass then + local isSkip = XDataCenter.PokemonManager.CheckIsSkip(XDataCenter.PokemonManager.GetStageFightStageId(self.StageId)) + self.PokemonPass.gameObject:SetActiveEx(isSkip) + end +end + +return XUiGridPokemonStage \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPokemon/XUiGridPokemonStagePage.lua b/Resources/Scripts/XUi/XUiPokemon/XUiGridPokemonStagePage.lua new file mode 100644 index 00000000..d7a321f4 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPokemon/XUiGridPokemonStagePage.lua @@ -0,0 +1,132 @@ +local XUiGridPokemonStagePage = XClass(nil, "XUiGridPokemonStagePage") +local XUiGridPokemonStage = require("XUi/XUiPokemon/XUiGridPokemonStage") +local CSVector2 = CS.UnityEngine.Vector2 +local CSVector3 = CS.UnityEngine.Vector3 +local CSQuaternion = CS.UnityEngine.Quaternion + + +function XUiGridPokemonStagePage:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.CurrIndex = 1 + self.PageStageCount = XDataCenter.PokemonManager.GetChapterPerPageStageCount() + self.Stages = {} + self.ConnectTransformDic = {} + XTool.InitUiObject(self) +end + +function XUiGridPokemonStagePage:InitStage(callback) + for i = 1, XPokemonConfigs.PerPageCount do + self.Stages[i] = XUiGridPokemonStage.New(self["Stage" .. i], self:CalculateStageIndex(i), callback) + end +end + +function XUiGridPokemonStagePage:Refresh(index) + self.CurrIndex = index + self:RefreshBg() + self:RefreshStage() + self:RefreshEffect() +end + +function XUiGridPokemonStagePage:RefreshStage() + for _, transform in pairs(self.ConnectTransformDic) do + transform.gameObject:SetActiveEx(false) + end + for i = 1,self.PageStageCount do + self["Stage" .. i].gameObject:SetActiveEx(false) + self["Line" .. i].gameObject:SetActiveEx(false) + end + for i = 1, self.PageStageCount do + local stageTemplate = self:GetUiTemplate(i, XPokemonConfigs.ObjType.Stage, self.CurrIndex + 1) + local lineTemplate = self:GetUiTemplate(i, XPokemonConfigs.ObjType.Line, self.CurrIndex + 1) + local stageIndex = self:CalculateStageIndex(i) + local totalCount = XDataCenter.PokemonManager.GetStageCountByChapter() + local passCount = XDataCenter.PokemonManager.GetPassedCountByChapterId(XDataCenter.PokemonManager.GetSelectChapter()) + local isShow = (stageIndex - passCount) <= 1 + if stageIndex > totalCount then break end + self["Stage" .. i].gameObject:SetActiveEx(isShow) + self["Line" .. i].gameObject:SetActiveEx(isShow) + self.Stages[i]:Refresh(stageIndex) + self:SetObjByTemplate(self["Stage" .. i], stageTemplate) + self:SetObjByTemplate(self["Line" .. i].transform, lineTemplate) + if (XDataCenter.PokemonManager.CheckStageIsPassed(XDataCenter.PokemonManager.GetStageFightStageId(stageIndex)) + or XDataCenter.PokemonManager.CheckIsSkip(XDataCenter.PokemonManager.GetStageFightStageId(stageIndex))) + and stageIndex ~= totalCount then + local startPos = CSVector2(lineTemplate.PosX, lineTemplate.PosY) + local endPos, nextLineTemplate + if i == self.PageStageCount then + nextLineTemplate = self:GetUiTemplate(1, XPokemonConfigs.ObjType.Line, self.CurrIndex + 2) + else + nextLineTemplate = self:GetUiTemplate(i + 1, XPokemonConfigs.ObjType.Line, self.CurrIndex + 1) + end + endPos = CSVector2(nextLineTemplate.PosX, nextLineTemplate.PosY) + self:CalculateConnectLine(startPos, endPos, i) + end + end +end + +function XUiGridPokemonStagePage:GetUiTemplate(index,type,pages) + local pageCount = XDataCenter.PokemonManager.GetStageCountByChapter() / self.PageStageCount + if pages == 1 then + return XDataCenter.PokemonManager.GetUiTemplate(index, type) + elseif pages== pageCount then + return XDataCenter.PokemonManager.GetUiTemplate((pageCount - 1) * self.PageStageCount + index, type) + else + local i = ((pages % 2) + 1) * self.PageStageCount + index + return XDataCenter.PokemonManager.GetUiTemplate(i, type) + end +end + +function XUiGridPokemonStagePage:CalculateConnectLine(startPosition,endPosition,index) + local transform = self.ConnectTransformDic[index] + if not transform then + transform = CS.UnityEngine.GameObject.Instantiate(self.Connect, self.PanelConnect) + self.ConnectTransformDic[index] = transform + end + + if index == self.PageStageCount then + endPosition.y = endPosition.y + self.Transform.parent.rect.height + end + local vecOffset = endPosition - startPosition + local width = vecOffset.magnitude + local position = (startPosition + endPosition) / 2 + local sizeDelta = transform.sizeDelta + transform.sizeDelta = CSVector2(width, sizeDelta.y) + transform.anchoredPosition = CSVector2(position.x, position.y) + transform.localRotation = CSQuaternion.Euler(CSVector2.Angle(CSVector2(1, 0), vecOffset) * CSVector3(0, 0, 1)) + transform.gameObject:SetActiveEx(true) +end + +function XUiGridPokemonStagePage:SetObjByTemplate(transform,config) + local position = CSVector2(config.PosX, config.PosY) + local scale = CSVector3(config.ScaleX, config.ScaleY, config.ScaleZ) + transform.anchoredPosition = position + transform.localScale = scale +end + +function XUiGridPokemonStagePage:RefreshEffect() + for i = 1, 4 do + self["Effect" .. i].gameObject:SetActiveEx(false) + end + if self.CurrIndex % 2 == 0 then + self.Effect1.gameObject:SetActiveEx(true) + elseif self.CurrIndex % 2 == 1 then + self.Effect2.gameObject:SetActiveEx(true) + end +end + +function XUiGridPokemonStagePage:RefreshBg() + local index = self.CurrIndex * self.PageStageCount + 1 + local totalCount = XDataCenter.PokemonManager.GetStageCountByChapter() + index = XMath.Clamp(index, 1, totalCount) + + local bgPath = XDataCenter.PokemonManager.GetStageBg(index) + self.BgCommonBai:SetRawImage(bgPath) +end + + +function XUiGridPokemonStagePage:CalculateStageIndex(index) + return self.CurrIndex * self.PageStageCount + index or 0 +end + +return XUiGridPokemonStagePage \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPokemon/XUiMonster/XUiGridPokemonMonster.lua b/Resources/Scripts/XUi/XUiPokemon/XUiMonster/XUiGridPokemonMonster.lua new file mode 100644 index 00000000..24cee626 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPokemon/XUiMonster/XUiGridPokemonMonster.lua @@ -0,0 +1,133 @@ +local XUiPanelStars = require("XUi/XUiPokemon/XUiMonster/XUiPanelStars") + +local handler = handler +local CSXTextManagerGetText = CS.XTextManager.GetText + +local XUiGridPokemonMonster = XClass(nil, "XUiGridPokemonMonster") + +function XUiGridPokemonMonster:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + + self:SetSelect(false) + self:SetDisable(false) + + if self.BtnClick then + self.BtnClick.CallBack = handler(self, self.OnClickBtnClick) + end + + XEventManager.AddEventListener(XEventId.EVENT_POKEMON_MONSTERS_LEVEL_UP, self.UpdateData, self) + XEventManager.AddEventListener(XEventId.EVENT_POKEMON_MONSTERS_STAR_UP, self.UpdateData, self) +end + +function XUiGridPokemonMonster:UpdateData(monsterId) + if not monsterId or monsterId ~= self.MonsterId then return end + if XTool.UObjIsNil(self.GameObject) then return end + self:Refresh(monsterId) +end + +function XUiGridPokemonMonster:Refresh(monsterId, star, clickCb) + self.MonsterId = monsterId + self.ClickCb = clickCb + + if self.TxtCareer then + local name = XPokemonConfigs.GetMonsterCareerName(monsterId) + self.TxtCareer.text = name + end + + if self.TxtCostEnergy then + local costEnergy = XPokemonConfigs.GetMonsterEnergyCost(monsterId) + self.TxtCostEnergy.text = CSXTextManagerGetText("PokemonMonsterEnergyCost", costEnergy) + end + + if self.TxtLevel then + local level = XDataCenter.PokemonManager.GetMonsterLevel(monsterId) + self.TxtLevel.text = level + end + + if self.RImgHeadIcon then + local headIcon = XPokemonConfigs.GetMonsterHeadIcon(monsterId) + self.RImgHeadIcon:SetRawImage(headIcon) + end + + if self.ImgIconCareer then + local careerIcon = XPokemonConfigs.GetMonsterCareerIcon(monsterId) + self.ImgIconCareer:SetSprite(careerIcon) + end + + if self.PanelBoss then + local isBoss = XPokemonConfigs.CheckMonsterType(monsterId, XPokemonConfigs.MonsterType.Boss) + self.PanelBoss.gameObject:SetActiveEx(isBoss) + end + + if self.TxtAbility then + local ability = XDataCenter.PokemonManager.GetMonsterAbility(monsterId) + self.TxtAbility.text = ability + end + + if self.ImgClass then + local ratingIcon = XPokemonConfigs.GetMonsterRatingIcon(monsterId) + local isEmpty = ratingIcon == "" + self.ImgClass.gameObject:SetActiveEx(not isEmpty) + if not isEmpty then + self.ImgClass:SetSprite(ratingIcon) + end + end + + if self.ImgConsume then + local rateIcon = XPokemonConfigs.GetMonsterRatingIcon(monsterId) + local isEmpty = string.IsNilOrEmpty(rateIcon) + self.ImgConsume.gameObject:SetActiveEx(not isEmpty) + if not isEmpty then + self.ImgConsume:SetSprite(rateIcon) + end + end + + if self.TxtConsume then + self.TxtConsume.text = CS.XTextManager.GetText("PokemonMonsterEnergyCost",XPokemonConfigs.GetMonsterEnergyCost(monsterId)) + end + + if self.PanelCamp then + self.PanelCamp.gameObject:SetActiveEx(XDataCenter.PokemonManager.CheckMonsterIsInTeam(monsterId)) + end + + if self.PanelStars then + self.StarPanel = self.StarPanel or XUiPanelStars.New(self.PanelStars) + star = star or XDataCenter.PokemonManager.GetMonsterStar(monsterId) + local maxStar = XPokemonConfigs.GetMonsterStarMaxStar(monsterId) + self.StarPanel:Refresh(star, maxStar) + end +end + +function XUiGridPokemonMonster:SetSelect(value) + if self.PanelSelected then + self.PanelSelected.gameObject:SetActiveEx(value) + end + if value == true then + self:ShowRedDot(0) + local key = string.format("%s_%s_%s", XPokemonConfigs.PokemonNewRoleClickedPrefix, tostring(XPlayer.Id), tostring(self.MonsterId)) + XSaveTool.SaveData(key, true) + end +end + +function XUiGridPokemonMonster:SetDisable(value) + if self.PanelDisable then + self.PanelDisable.gameObject:SetActiveEx(value) + end +end + +function XUiGridPokemonMonster:OnClickBtnClick() + if self.ClickCb then + self.ClickCb(self.MonsterId) + end +end + +function XUiGridPokemonMonster:ShowRedDot(count) + if self.Red then + self.Red.gameObject:SetActiveEx(count < 0) + end +end + +return XUiGridPokemonMonster \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPokemon/XUiMonster/XUiGridPokemonMonsterSelectSkill.lua b/Resources/Scripts/XUi/XUiPokemon/XUiMonster/XUiGridPokemonMonsterSelectSkill.lua new file mode 100644 index 00000000..7fad2c3f --- /dev/null +++ b/Resources/Scripts/XUi/XUiPokemon/XUiMonster/XUiGridPokemonMonsterSelectSkill.lua @@ -0,0 +1,50 @@ +local XUiGridPokemonMonsterSelectSkill = XClass(nil, "XUiGridPokemonMonsterSelectSkill") + +function XUiGridPokemonMonsterSelectSkill:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + self.UiButton.CallBack = function() self:OnClickBtn() end +end + +function XUiGridPokemonMonsterSelectSkill:Refresh(monsterId, skillId, clickCb) + self.ClickCb = clickCb + + local uiButton = self.UiButton + + local icon = XPokemonConfigs.GetMonsterSkillIcon(skillId) + uiButton:SetRawImage(icon) + + local name = XPokemonConfigs.GetMonsterSkillName(skillId) + uiButton:SetNameByGroup(0, name) + + local desc = XPokemonConfigs.GetMonsterSkillDescription(skillId) + uiButton:SetNameByGroup(1, desc) + + local isDisable = not XDataCenter.PokemonManager.IsMonsterSkillUnlock(monsterId, skillId) + uiButton:SetDisable(isDisable) + self._IsDisable = isDisable + + local isSelect = XDataCenter.PokemonManager.IsMonsterSkillUsing(monsterId, skillId) + self:SetSelect(isSelect) +end + +function XUiGridPokemonMonsterSelectSkill:OnClickBtn() + if self._IsSelect then return end + if self._IsDisable then + XUiManager.TipText("PokemonMonsterSwitchSkillUnlock") + return + end + + self.ClickCb() +end + +function XUiGridPokemonMonsterSelectSkill:SetSelect(value) + if self._IsDisable then return end + self._IsSelect = value + self.UiButton.enabled = not value + self.UiButton:SetButtonState(value and CS.UiButtonState.Select or CS.UiButtonState.Normal) +end + +return XUiGridPokemonMonsterSelectSkill \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPokemon/XUiMonster/XUiPanelStars.lua b/Resources/Scripts/XUi/XUiPokemon/XUiMonster/XUiPanelStars.lua new file mode 100644 index 00000000..ca52edb9 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPokemon/XUiMonster/XUiPanelStars.lua @@ -0,0 +1,34 @@ +local pairs = pairs +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate + +local XUiPanelStars = XClass(nil, "XUiPanelStars") + +function XUiPanelStars:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.StarGrids = {} + + XTool.InitUiObject(self) +end + +function XUiPanelStars:Refresh(star, maxStar) + for index = 1, maxStar do + local grid = self.StarGrids[index] + if not grid then + local go = index == 1 and self.GridStar or CSUnityEngineObjectInstantiate(self.GridStar, self.Transform) + grid = XTool.InitUiObjectByUi({}, go) + self.StarGrids[index] = grid + end + + grid.GameObject:SetActiveEx(true) + grid.ImgStar.gameObject:SetActiveEx(index <= star) + end + for index = maxStar + 1, #self.StarGrids do + local grid = self.StarGrids[index] + if grid then + grid.GameObject:SetActiveEx(false) + end + end +end + +return XUiPanelStars \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPokemon/XUiMonster/XUiPokemonMonster.lua b/Resources/Scripts/XUi/XUiPokemon/XUiMonster/XUiPokemonMonster.lua new file mode 100644 index 00000000..c713b7ec --- /dev/null +++ b/Resources/Scripts/XUi/XUiPokemon/XUiMonster/XUiPokemonMonster.lua @@ -0,0 +1,565 @@ +local XUiGridPokemonMonster = require("XUi/XUiPokemon/XUiMonster/XUiGridPokemonMonster") +local XRedPointConditionPokemonNewRole = require("XRedPoint/XRedPointConditions/XRedPointConditionPokemonNewRole") +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate +local pairs = pairs +local tableInsert = table.insert +local tonumber = tonumber +local mathFloor = math.floor +local Lerp = CS.UnityEngine.Mathf.Lerp +local CSXScheduleManagerUnSchedule = XScheduleManager.UnSchedule +local CsXTextManagerGetText = CsXTextManagerGetText +local NewSkillSaveKey = "PokemonNewSkillSaveKey_%s_%d_%d" +local TabBtnIndex = { + Shooter = 1, --射手 + Shield = 2, --盾卫 + Knight = 3, --骑士 + Assassin = 4, --刺客 +} +local SCORE_ANIM_DURATION = 1 + +local XUiPokemonMonster = XLuaUiManager.Register(XLuaUi, "UiPokemonMonster") + +function XUiPokemonMonster:OnAwake() + self:AutoAddListener() + self:InitDynamicTable() + self:InitTabBtns() + + self.GridStar.gameObject:SetActiveEx(false) + self.BtnSkill.gameObject:SetActiveEx(false) + self.GridMonster.gameObject:SetActiveEx(false) + + self.AssetActivityPanel = XUiPanelActivityAsset.New(self.PanelSpecialTool) + XDataCenter.ItemManager.AddCountUpdateListener(XDataCenter.ItemManager.ItemId.PokemonLevelUpItem, function() + self.AssetActivityPanel:Refresh({ XDataCenter.ItemManager.ItemId.PokemonLevelUpItem, XDataCenter.ItemManager.ItemId.PokemonStarUpItem,XDataCenter.ItemManager.ItemId.PokemonLowStarUpItem }) + end, self.AssetActivityPanel) + XDataCenter.ItemManager.AddCountUpdateListener(XDataCenter.ItemManager.ItemId.PokemonStarUpItem, function() + self.AssetActivityPanel:Refresh({ XDataCenter.ItemManager.ItemId.PokemonLevelUpItem, XDataCenter.ItemManager.ItemId.PokemonStarUpItem,XDataCenter.ItemManager.ItemId.PokemonLowStarUpItem }) + end, self.AssetActivityPanel) + XDataCenter.ItemManager.AddCountUpdateListener(XDataCenter.ItemManager.ItemId.PokemonLowStarUpItem, function() + self.AssetActivityPanel:Refresh({ XDataCenter.ItemManager.ItemId.PokemonLevelUpItem, XDataCenter.ItemManager.ItemId.PokemonStarUpItem,XDataCenter.ItemManager.ItemId.PokemonLowStarUpItem }) + end, self.AssetActivityPanel) +end + +function XUiPokemonMonster:OnStart() + self.StarGrids = {} + self.SkillGrids = {} + + self:InitDefaultSelect() + self:InitSceneRoot() + self.AssetActivityPanel:Refresh({ XDataCenter.ItemManager.ItemId.PokemonLevelUpItem, XDataCenter.ItemManager.ItemId.PokemonStarUpItem,XDataCenter.ItemManager.ItemId.PokemonLowStarUpItem }) +end + +function XUiPokemonMonster:OnEnable() + --local isBossEmpty = XDataCenter.PokemonManager.CheckOwnMonsterEmpty(XPokemonConfigs.MonsterType.Boss) + --self.BtnTabBoss:SetDisable(isBossEmpty) + -- + --local isMemberEmpty = XDataCenter.PokemonManager.CheckOwnMonsterEmpty(XPokemonConfigs.MonsterType.Member) + --self.BtnTabMember:SetDisable(isMemberEmpty) + local isShooterEmpty = XDataCenter.PokemonManager.CheckOwnMonsterEmptyByCareer(XPokemonConfigs.MonsterCareer.Shooter) + local isShieldEmpty = XDataCenter.PokemonManager.CheckOwnMonsterEmptyByCareer(XPokemonConfigs.MonsterCareer.Shield) + local isKnightEmpty = XDataCenter.PokemonManager.CheckOwnMonsterEmptyByCareer(XPokemonConfigs.MonsterCareer.Knight) + local isAssassinEmpty = XDataCenter.PokemonManager.CheckOwnMonsterEmptyByCareer(XPokemonConfigs.MonsterCareer.Assassin) + self.BtnTabShooter:SetDisable(isShooterEmpty) + self.BtnTabShield:SetDisable(isShieldEmpty) + self.BtnTabKnight:SetDisable(isKnightEmpty) + self.BtnTabAssassin:SetDisable(isAssassinEmpty) + self.PanelCharacterTypeBtns:SelectIndex(self.SelectTabBtnIndex) + self:CheckTabRedDot() +end + +function XUiPokemonMonster:OnDisable() + self:DestroyTimer() +end + +function XUiPokemonMonster:OnGetEvents() + local eventIds = XPokemonConfigs.GetToCheckItemIdEventIds() + tableInsert(eventIds, XEventId.EVENT_POKEMON_MONSTERS_SKILL_SWITCH) + tableInsert(eventIds, XEventId.EVENT_POKEMON_MONSTERS_LEVEL_UP) + tableInsert(eventIds, XEventId.EVENT_POKEMON_MONSTERS_DATA_CHANGE) + tableInsert(eventIds, XEventId.EVENT_POKEMON_MONSTERS_STAR_UP) + return eventIds +end + +function XUiPokemonMonster:OnNotify(evt, ...) + local eventIds = XPokemonConfigs.GetToCheckItemIdEventIds() + for _, eventId in pairs(eventIds) do + if evt == eventId then + self:UpdateCostItem() + return + end + end + + if evt == XEventId.EVENT_POKEMON_MONSTERS_SKILL_SWITCH then + self:UpdateSkills() + elseif evt == XEventId.EVENT_POKEMON_MONSTERS_DATA_CHANGE then + self:UpdateMonsters() + elseif evt == XEventId.EVENT_POKEMON_MONSTERS_LEVEL_UP or + evt == XEventId.EVENT_POKEMON_MONSTERS_STAR_UP then + self:UpdateCostItem() + end +end + +function XUiPokemonMonster:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.SViewCharacterList) + self.DynamicTable:SetProxy(XUiGridPokemonMonster) + self.DynamicTable:SetDelegate(self) +end + +function XUiPokemonMonster:InitTabBtns() + self.TabBtns = { self.BtnTabShooter, self.BtnTabShield, self.BtnTabKnight, self.BtnTabAssassin } + self.PanelCharacterTypeBtns:Init(self.TabBtns, function(index) self:OnSelectMonsterType(index) end) +end + +function XUiPokemonMonster:InitDefaultSelect() + --if not XDataCenter.PokemonManager.CheckOwnMonsterEmpty(XPokemonConfigs.MonsterType.Boss) then + -- self.SelectTabBtnIndex = TabBtnIndex.Shooter + --else + -- self.SelectTabBtnIndex = TabBtnIndex.Shield + --end + local isShooterEmpty = XDataCenter.PokemonManager.CheckOwnMonsterEmptyByCareer(XPokemonConfigs.MonsterCareer.Shooter) + local isShieldEmpty = XDataCenter.PokemonManager.CheckOwnMonsterEmptyByCareer(XPokemonConfigs.MonsterCareer.Shield) + local isKnightEmpty = XDataCenter.PokemonManager.CheckOwnMonsterEmptyByCareer(XPokemonConfigs.MonsterCareer.Knight) + local isAssassinEmpty = XDataCenter.PokemonManager.CheckOwnMonsterEmptyByCareer(XPokemonConfigs.MonsterCareer.Assassin) + + if not isShooterEmpty then + self.SelectTabBtnIndex = TabBtnIndex.Shooter + elseif not isShieldEmpty then + self.SelectTabBtnIndex = TabBtnIndex.Shield + elseif not isKnightEmpty then + self.SelectTabBtnIndex = TabBtnIndex.Knight + elseif not isAssassinEmpty then + self.SelectTabBtnIndex = TabBtnIndex.Assassin + end + + self.SelectMonsterIndex = 1 +end + +function XUiPokemonMonster:InitSceneRoot() + local root = self.UiModelGo.transform + self.PanelRoleModel = root:FindTransform("PanelRoleModel") + self.ImgEffectHuanren = root:FindTransform("ImgEffectHuanren") + self.RoleModelPanel = XUiPanelRoleModel.New(self.PanelRoleModel, self.Name, nil, true, nil, true) +end + +function XUiPokemonMonster:OnSelectMonsterType(index) + self.SelectTabBtnIndex = index + self.SelectMonsterIndex = 1 + + self:UpdateMonsters() +end + +function XUiPokemonMonster:UpdateMonsters() + local careerType = self:GetSelectMonsterType() + local monsterIds = XDataCenter.PokemonManager.GetOwnMonsterIdsByCareer(careerType) + if XTool.IsTableEmpty(monsterIds) then + XUiManager.TipText("PokemonMonsterListEmpty") + return + end + + self:PlayAnimation("QieHuan") + + self.MonsterIds = monsterIds + table.sort(self.MonsterIds,function(a, b) + local costA = XPokemonConfigs.GetMonsterEnergyCost(a) + local costB = XPokemonConfigs.GetMonsterEnergyCost(b) + costA = costA == 0 and math.huge or costA + costB = costB == 0 and math.huge or costB + return costA > costB + end) + self.DynamicTable:SetDataSource(monsterIds) + self.DynamicTable:ReloadDataASync() + + self:UpdateCurrentMonster() + self:UpdateCurrentMonsterModel() +end + +function XUiPokemonMonster:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + + local monsterId = self.MonsterIds[index] + + grid:Refresh(monsterId) + + if self.SelectMonsterIndex == index then + grid:SetSelect(true) + self.LastSelectMonsterGrid = grid + self:CheckTabRedDot() + else + grid:SetSelect(false) + end + XRedPointManager.CheckOnce(grid.ShowRedDot, grid, { XRedPointConditions.Types.CONDITION_POKEMON_NEW_ROLE }, monsterId) + + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + + if self.LastSelectMonsterGrid then + self.LastSelectMonsterGrid:SetSelect(false) + end + self.LastSelectMonsterGrid = grid + grid:SetSelect(true) + self:CheckTabRedDot() + self.SelectMonsterIndex = index + self:UpdateCurrentMonster() + self:UpdateCurrentMonsterModel() + + self:PlayAnimation("QieHuan") + + end +end + +function XUiPokemonMonster:UpdateCurrentMonster() + local monsterId = self.MonsterIds[self.SelectMonsterIndex] + + local name = XPokemonConfigs.GetMonsterName(monsterId) + self.TxtName.text = name + + local level = XDataCenter.PokemonManager.GetMonsterLevel(monsterId) + local maxLevel = XDataCenter.PokemonManager.GetMonsterMaxLevel(monsterId) + self.TxtLevel.text = level .. "/" .. maxLevel + self.BtnReset.gameObject:SetActiveEx(level ~= 1) + local ability = XDataCenter.PokemonManager.GetMonsterAbility(monsterId) + self.TxtAbility.text = ability + + local hp = XDataCenter.PokemonManager.GetMonsterHp(monsterId) + self.TxtHp.text = hp + + local attack = XDataCenter.PokemonManager.GetMonsterAttack(monsterId) + self.TxtAttack.text = attack + + local star = XDataCenter.PokemonManager.GetMonsterStar(monsterId) + local maxStar = XPokemonConfigs.GetMonsterStarMaxStar(monsterId) + for index = 1, maxStar do + local grid = self.StarGrids[index] + if not grid then + local go = index == 1 and self.GridStar or CSUnityEngineObjectInstantiate(self.GridStar, self.PanelStar) + grid = XTool.InitUiObjectByUi({}, go) + self.StarGrids[index] = grid + end + + grid.GameObject:SetActiveEx(true) + grid.ImgStar.gameObject:SetActiveEx(index <= star) + end + for index = maxStar + 1, #self.StarGrids do + local grid = self.StarGrids[index] + if grid then + grid.GameObject:SetActiveEx(false) + end + end + + self:UpdateCostItem() + self:UpdateSkills() + +end + +function XUiPokemonMonster:UpdateCurrentMonsterModel() + local monsterId = self.MonsterIds[self.SelectMonsterIndex] + local modelId = XPokemonConfigs.GetMonsterModelId(monsterId) + self.ImgEffectHuanren.gameObject:SetActiveEx(false) + self.RoleModelPanel:UpdateRoleModel(modelId, self.PanelRoleModel, XModelManager.MODEL_UINAME.XUiPokemonMonster, function(model) + self.ImgEffectHuanren.gameObject:SetActiveEx(true) + self.PanelDrag.Target = model.transform + end, nil) +end + +function XUiPokemonMonster:UpdateCostItem() + local monsterId = self.MonsterIds[self.SelectMonsterIndex] + + if not XDataCenter.PokemonManager.IsMonsterMaxLevel(monsterId) then + + local itemId, itemCount = XDataCenter.PokemonManager.GetMonsterLevelUpCostItemInfo(monsterId) + + local icon = XItemConfigs.GetItemIconById(itemId) + self.RImgIconCost:SetRawImage(icon) + + self.TxtCostNum.text = itemCount + self.PanelCost.gameObject:SetActiveEx(true) + + self.BtnUpgrade:SetDisable(false) + self.BtnUpgrade.gameObject:SetActiveEx(true) + + self.BtnUpgradeStars.gameObject:SetActiveEx(false) + + self.BtnAutoUpgrade.gameObject:SetActiveEx(true) + self.BtnAutoUpgrade:SetDisable(false) + + elseif not XDataCenter.PokemonManager.IsMonsterMaxStar(monsterId) then + + local itemId, itemCount = XDataCenter.PokemonManager.GetMonsterStarUpCostItemInfo(monsterId) + + local icon = XItemConfigs.GetItemIconById(itemId) + self.RImgIconCost:SetRawImage(icon) + self.TxtCostNum.text = itemCount + + self.PanelCost.gameObject:SetActiveEx(true) + + self.BtnUpgrade.gameObject:SetActiveEx(false) + + self.BtnUpgradeStars.gameObject:SetActiveEx(true) + + self.BtnAutoUpgrade:SetDisable(true) + self.BtnAutoUpgrade.gameObject:SetActiveEx(true) + + else + + self.PanelCost.gameObject:SetActiveEx(false) + + self.BtnUpgrade:SetDisable(true) + self.BtnUpgrade.gameObject:SetActiveEx(true) + + self.BtnUpgradeStars.gameObject:SetActiveEx(false) + + self.BtnAutoUpgrade.gameObject:SetActiveEx(false) + + end +end + +function XUiPokemonMonster:UpdateSkills() + local monsterId = self.MonsterIds[self.SelectMonsterIndex] + + local isBoss = XPokemonConfigs.CheckMonsterType(monsterId, XPokemonConfigs.MonsterType.Boss) + self.TxtSkillDescBoss.gameObject:SetActiveEx(isBoss) + self.TxtSkillDescMember.gameObject:SetActiveEx(not isBoss) + + local skillIds = XDataCenter.PokemonManager.GetMonsterUsingSkillIdList(monsterId) + for index, skillId in pairs(skillIds) do + local grid = self.SkillGrids[index] + if not grid then + local go = index == 1 and self.BtnSkill or CSUnityEngineObjectInstantiate(self.BtnSkill, self.PanelSkillLayout) + grid = XTool.InitUiObjectByUi({}, go) + self.SkillGrids[index] = grid + end + + local uiButton = grid.UiButton + + local icon = XPokemonConfigs.GetMonsterSkillIcon(skillId) + uiButton:SetRawImage(icon) + + local name = XPokemonConfigs.GetMonsterSkillName(skillId) + uiButton:SetNameByGroup(0, name) + + local canSwith = XDataCenter.PokemonManager.IsMonsterSkillCanSwitch(monsterId, skillId) + uiButton:ShowTag(canSwith) + + local paramSkillId = skillId + grid.UiButton.CallBack = function() + XSaveTool.SaveData(string.format(NewSkillSaveKey, XPlayer.Id, monsterId, index), 0) + grid.NewPanel.gameObject:SetActiveEx(false) + self:OnClickBtnSkill(paramSkillId) + end + local isNewSkill = XSaveTool.GetData(string.format(NewSkillSaveKey, XPlayer.Id, monsterId, index)) + grid.NewPanel.gameObject:SetActiveEx(isNewSkill == 1) + grid.GameObject:SetActiveEx(true) + end + for index = #skillIds + 1, #self.SkillGrids do + local grid = self.SkillGrids[index] + if grid then + grid.GameObject:SetActiveEx(false) + end + end + +end + +function XUiPokemonMonster:OnClickBtnSkill(skillId) + local monsterId = self.MonsterIds[self.SelectMonsterIndex] + if XDataCenter.PokemonManager.IsMonsterSkillCanSwitch(monsterId, skillId) then + local skillIds = XDataCenter.PokemonManager.GetMonsterCanSwitchSkillIdList(monsterId, skillId) + XLuaUiManager.Open("UiPokemonSkillSelect", monsterId, skillIds) + else + XLuaUiManager.Open("UiPokemonSkillDetails", skillId) + end +end + +function XUiPokemonMonster:AutoAddListener() + self.BtnBack.CallBack = function() self:OnClickBtnBack() end + self.BtnMainUi.CallBack = function() self:OnClickBtnMainUi() end + self:BindHelpBtn(self.BtnHelp, "PokemonMonster") + self.BtnUpgrade.CallBack = function() self:OnClickBtnUpgrade() end + self.BtnUpgradeStars.CallBack = function() self:OnClickBtnUpgradeStars() end + self.BtnAutoUpgrade.CallBack = function() self:OnClickBtnAutoUpgrade() end + self.BtnReset.CallBack = function() self:OnClickBtnReset() end +end + +function XUiPokemonMonster:OnClickBtnBack() + self:Close() +end + +function XUiPokemonMonster:OnClickBtnMainUi() + XLuaUiManager.RunMain() +end + +function XUiPokemonMonster:OnClickBtnReset() + local monsterId = self.MonsterIds[self.SelectMonsterIndex] + XUiManager.DialogTip(CS.XTextManager.GetText("PokemonResetTipsTitle"), CS.XTextManager.GetText("PokemonResetTipsContent"), XUiManager.DialogType.Normal, nil, function() + XDataCenter.PokemonManager.PokemonResetUpgradeRequest(monsterId,function(rewards) + for index,grid in pairs(self.SkillGrids) do + XSaveTool.SaveData(string.format(NewSkillSaveKey, XPlayer.Id, monsterId, index), 0) + grid.NewPanel.gameObject:SetActiveEx(false) + end + if rewards and #rewards > 0 then + XUiManager.OpenUiObtain(rewards) + end + end) + end) +end + +function XUiPokemonMonster:OnClickBtnUpgrade() + local monsterId = self.MonsterIds[self.SelectMonsterIndex] + if XDataCenter.PokemonManager.IsMonsterMaxLevel(monsterId) then + XUiManager.TipText("PokemonMonsterMaxLevel") + return + end + + local costItemId,costItemCount = XPokemonConfigs.GetMonsterLevelCostItemInfo(monsterId,XDataCenter.PokemonManager.GetMonsterLevel(monsterId)) + if costItemId and costItemCount and XDataCenter.ItemManager.GetCount(costItemId) < costItemCount then + XUiManager.TipText("PokemonUpgradeItemNotEnough") + return + end + + local times = 1 + local cb = function() self:PlayLevelUpAnim(monsterId) end + XDataCenter.PokemonManager.PokemonLevelUpRequest(monsterId, times, cb) +end + +function XUiPokemonMonster:OnClickBtnUpgradeStars() + local monsterId = self.MonsterIds[self.SelectMonsterIndex] + + if XDataCenter.PokemonManager.IsMonsterMaxStar(monsterId) then + return + end + local costItemId, costItemCount = XPokemonConfigs.GetMonsterStarCostItemInfo(monsterId, XDataCenter.PokemonManager.GetMonsterStar(monsterId)) + if costItemId and costItemCount and XDataCenter.ItemManager.GetCount(costItemId) < costItemCount then + XUiManager.TipText("PokemonUpgradeItemNotEnough") + return + end + + local oldStar = XDataCenter.PokemonManager.GetMonsterStar(monsterId) + local cb = function() + self:UpdateCurrentMonster() + self:UpdateCurrentMonsterModel() + local star = XDataCenter.PokemonManager.GetMonsterStar(monsterId) + local unlockSkillIds = XDataCenter.PokemonManager.GetMonsterStarUnlockSkillIds(monsterId, star) + local skillId = unlockSkillIds[1] + if skillId then + local pos = XPokemonConfigs.GetMonsterSkillGroupId(skillId) + 1 + local grid = self.SkillGrids[pos] + if grid then + XSaveTool.SaveData(string.format(NewSkillSaveKey, XPlayer.Id, monsterId, pos), 1) + grid.NewPanel.gameObject:SetActiveEx(true) + end + end + XLuaUiManager.Open("UiPokemonStarSuccess", monsterId, oldStar) + end + XDataCenter.PokemonManager.PokemonStarUpRequest(monsterId, cb) +end + +function XUiPokemonMonster:OnClickBtnAutoUpgrade() + local monsterId = self.MonsterIds[self.SelectMonsterIndex] + + if XDataCenter.PokemonManager.IsMonsterMaxLevel(monsterId) then + XUiManager.TipText("PokemonMonsterMaxLevel") + return + end + + local times = XDataCenter.PokemonManager.GetMonsterCanLevelUpTimes(monsterId) + if times < 1 then + XUiManager.TipText("PokemonMonsterAutoLevelUpLackItem") + return + end + + local curLevel = XDataCenter.PokemonManager.GetMonsterLevel(monsterId) + local cb = function() + local toLevel = times + curLevel + local msg = CsXTextManagerGetText("PokemonMonsterLevelUpTo", toLevel) + XUiManager.TipMsg(msg) + self:PlayLevelUpAnim(monsterId) + end + XLuaUiManager.Open("UiPokemonUpgradePreview", monsterId, cb) +end + +local TabBtnIndexToMonsterType = { + [TabBtnIndex.Shooter] = XPokemonConfigs.MonsterCareer.Shooter, + [TabBtnIndex.Shield] = XPokemonConfigs.MonsterCareer.Shield, + [TabBtnIndex.Knight] = XPokemonConfigs.MonsterCareer.Knight, + [TabBtnIndex.Assassin] = XPokemonConfigs.MonsterCareer.Assassin, +} +function XUiPokemonMonster:GetSelectMonsterType() + return TabBtnIndexToMonsterType[self.SelectTabBtnIndex] +end + +function XUiPokemonMonster:GetSelectMonsterId() + return self.MonsterIds[self.SelectMonsterIndex] +end + +function XUiPokemonMonster:PlayLevelUpAnim(monsterId) + local asynPlayAnim = asynTask(self.PlayAnimation, self) + local asynLetAttrsRoll = asynTask(self.LetAttrsRoll, self) + + RunAsyn(function() + local targetHp = XDataCenter.PokemonManager.GetMonsterHp(monsterId) + local targetAttack = XDataCenter.PokemonManager.GetMonsterAttack(monsterId) + local startHp = tonumber(self.TxtHp.text) or 0 + local startAttack = tonumber(self.TxtAttack.text) or 0 + + --addAttr refresh + local deltaHp = targetHp - startHp + self.TxtAddHealth.text = "+" .. deltaHp + local deltaAttack = targetAttack - startAttack + self.TxtAddAttack.text = "+" .. deltaAttack + --ui refresh + self:UpdateCurrentMonster() + self:UpdateCurrentMonsterModel() + --addAttr anim appear + asynPlayAnim("NumberEnable") + + --attr anim + asynLetAttrsRoll(startHp, targetHp, startAttack, targetAttack) + + --addAttr anim disappear + asynPlayAnim("NumberDisable") + + self:UpdateCurrentMonster() + end) +end + +function XUiPokemonMonster:LetAttrsRoll(startHp, targetHp, startAttack, targetAttack, finishCb) + if not targetHp then return end + if not targetAttack then return end + + local onRefreshFunc = function(time) + if XTool.UObjIsNil(self.TxtHp) + or XTool.UObjIsNil(self.TxtAttack) + then + self:DestroyTimer() + return true + end + + if startHp == targetHp + and startAttack == targetAttack + then + return true + end + + self.TxtHp.text = mathFloor(Lerp(startHp, targetHp, time)) + self.TxtAttack.text = mathFloor(Lerp(startAttack, targetAttack, time)) + end + + self:DestroyTimer() + self.Timer = XUiHelper.Tween(SCORE_ANIM_DURATION, onRefreshFunc, finishCb) +end + +function XUiPokemonMonster:DestroyTimer() + if self.Timer then + CSXScheduleManagerUnSchedule(self.Timer) + self.Timer = nil + end +end + +function XUiPokemonMonster:CheckTabRedDot() + for index,career in pairs(TabBtnIndexToMonsterType) do + local monsters = XDataCenter.PokemonManager.GetOwnMonsterIdsByCareer(career) + local isShowRed = true + for _,id in pairs(monsters) do + isShowRed = isShowRed and XRedPointConditionPokemonNewRole.Check(id) + end + self.TabBtns[index]:ShowReddot(not isShowRed) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPokemon/XUiMonster/XUiPokemonMonsterObtain.lua b/Resources/Scripts/XUi/XUiPokemon/XUiMonster/XUiPokemonMonsterObtain.lua new file mode 100644 index 00000000..7faa3b90 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPokemon/XUiMonster/XUiPokemonMonsterObtain.lua @@ -0,0 +1,44 @@ +local XUiGridPokemonMonster = require("XUi/XUiPokemon/XUiMonster/XUiGridPokemonMonster") + +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate + +local XUiPokemonMonsterObtain = XLuaUiManager.Register(XLuaUi, "UiPokemonMonsterObtain") + +function XUiPokemonMonsterObtain:OnAwake() + self:AutoAddListener() + + self.GridMonster.gameObject:SetActiveEx(false) +end + +function XUiPokemonMonsterObtain:OnStart(monsterIds) + self.MonsterIds = monsterIds + self.MonsterGrids = {} +end + +function XUiPokemonMonsterObtain:OnEnable() + self:UpdateMonsters() +end + +function XUiPokemonMonsterObtain:UpdateMonsters() + local monsterIds = self.MonsterIds + + for index = 1, #monsterIds do + local grid = self.MonsterGrids[index] + if not grid then + local go = index == 1 and self.GridMonster or CSUnityEngineObjectInstantiate(self.GridMonster, self.PanelContent) + grid = XUiGridPokemonMonster.New(go) + end + + local monsterId = monsterIds[index] + grid:Refresh(monsterId) + grid.GameObject:SetActiveEx(true) + end +end + +function XUiPokemonMonsterObtain:AutoAddListener() + self.BtnBack.CallBack = function() self:OnClickBtnBack() end +end + +function XUiPokemonMonsterObtain:OnClickBtnBack() + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPokemon/XUiMonster/XUiPokemonSkillDetails.lua b/Resources/Scripts/XUi/XUiPokemon/XUiMonster/XUiPokemonSkillDetails.lua new file mode 100644 index 00000000..64d8c5eb --- /dev/null +++ b/Resources/Scripts/XUi/XUiPokemon/XUiMonster/XUiPokemonSkillDetails.lua @@ -0,0 +1,34 @@ +local XUiPokemonSkillDetails = XLuaUiManager.Register(XLuaUi, "UiPokemonSkillDetails") + +function XUiPokemonSkillDetails:OnAwake() + self:AutoAddListener() +end + +function XUiPokemonSkillDetails:OnStart(skillId) + self.SkillId = skillId +end + +function XUiPokemonSkillDetails:OnEnable() + self:UpdateSkill() +end + +function XUiPokemonSkillDetails:UpdateSkill() + local skillId = self.SkillId + + local name = XPokemonConfigs.GetMonsterSkillName(skillId) + self.TxtName.text = name + + local desc = XPokemonConfigs.GetMonsterSkillDescription(skillId) + self.TxtWorldDesc.text = desc + + local icon = XPokemonConfigs.GetMonsterSkillIcon(skillId) + self.RImgSkill:SetRawImage(icon) +end + +function XUiPokemonSkillDetails:AutoAddListener() + self.BtnTanchuangClose.CallBack = function() self:OnClickBtnBack() end +end + +function XUiPokemonSkillDetails:OnClickBtnBack() + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPokemon/XUiMonster/XUiPokemonSkillSelect.lua b/Resources/Scripts/XUi/XUiPokemon/XUiMonster/XUiPokemonSkillSelect.lua new file mode 100644 index 00000000..f6d9d4fb --- /dev/null +++ b/Resources/Scripts/XUi/XUiPokemon/XUiMonster/XUiPokemonSkillSelect.lua @@ -0,0 +1,62 @@ +local XUiGridPokemonMonsterSelectSkill = require("XUi/XUiPokemon/XUiMonster/XUiGridPokemonMonsterSelectSkill") + +local XUiPokemonSkillSelect = XLuaUiManager.Register(XLuaUi, "UiPokemonSkillSelect") + +function XUiPokemonSkillSelect:OnAwake() + self:InitDynamicTable() + self:AutoAddListener() + self.GridMonsterSkill.gameObject:SetActiveEx(false) +end + +function XUiPokemonSkillSelect:OnStart(monsterId, skillIds) + self.MonsterId = monsterId + self.SkillIds = skillIds +end + +function XUiPokemonSkillSelect:OnEnable() + self:UpdateSkills() +end + +function XUiPokemonSkillSelect:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelScroll) + self.DynamicTable:SetProxy(XUiGridPokemonMonsterSelectSkill) + self.DynamicTable:SetDelegate(self) +end + +function XUiPokemonSkillSelect:UpdateSkills() + self.DynamicTable:SetDataSource(self.SkillIds) + self.DynamicTable:ReloadDataASync() +end + +function XUiPokemonSkillSelect:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + + local monsterId = self.MonsterId + local skillId = self.SkillIds[index] + local clickCb = function() self:OnSelectSkill(index) end + grid:Refresh(monsterId, skillId, clickCb) + + end +end + +function XUiPokemonSkillSelect:OnSelectSkill(index) + local monsterId = self.MonsterId + local skillId = self.SkillIds[index] + + if not XDataCenter.PokemonManager.IsMonsterSkillUnlock(monsterId, skillId) then + return + end + + local cb = function() + self:UpdateSkills() + end + XDataCenter.PokemonManager.PokemonSetSkillRequest(monsterId, skillId, cb) +end + +function XUiPokemonSkillSelect:AutoAddListener() + self.BtnTanchuangClose.CallBack = function() self:OnClickBtnBack() end +end + +function XUiPokemonSkillSelect:OnClickBtnBack() + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPokemon/XUiMonster/XUiPokemonStarSuccess.lua b/Resources/Scripts/XUi/XUiPokemon/XUiMonster/XUiPokemonStarSuccess.lua new file mode 100644 index 00000000..cf4abfe4 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPokemon/XUiMonster/XUiPokemonStarSuccess.lua @@ -0,0 +1,53 @@ +local XUiGridPokemonMonster = require("XUi/XUiPokemon/XUiMonster/XUiGridPokemonMonster") + +local XUiPokemonStarSuccess = XLuaUiManager.Register(XLuaUi, "UiPokemonStarSuccess") + +function XUiPokemonStarSuccess:OnAwake() + self:AutoAddListener() +end + +function XUiPokemonStarSuccess:OnStart(monsterId, oldStar) + self.MonsterId = monsterId + self.OldStar = oldStar +end + +function XUiPokemonStarSuccess:OnEnable() + self:UpdatePreview() +end + +function XUiPokemonStarSuccess:UpdatePreview() + local monsterId = self.MonsterId + local oldStar = self.OldStar + local star = XDataCenter.PokemonManager.GetMonsterStar(monsterId) + + self.LeftGrid = self.LeftGrid or XUiGridPokemonMonster.New(self.GridMonsterLeft) + self.LeftGrid:Refresh(monsterId, oldStar) + + self.RightGrid = self.RightGrid or XUiGridPokemonMonster.New(self.GridMonsterRight) + self.RightGrid:Refresh(monsterId, star) + + local maxLevel = XDataCenter.PokemonManager.GetMonsterMaxLevel(monsterId) + self.TxtLevelLimit.text = maxLevel + + local unlockSkillIds = XDataCenter.PokemonManager.GetMonsterStarUnlockSkillIds(monsterId, star) + local showSkillId = unlockSkillIds[1] + if showSkillId then + local skillName = XPokemonConfigs.GetMonsterSkillName(showSkillId) + self.TxtSkillName.text = skillName + + local skillIcon = XPokemonConfigs.GetMonsterSkillIcon(showSkillId) + self.RImgSkillIcon:SetRawImage(skillIcon) + + self.PanelNewSkill.gameObject:SetActiveEx(true) + else + self.PanelNewSkill.gameObject:SetActiveEx(false) + end +end + +function XUiPokemonStarSuccess:AutoAddListener() + self.BtnDarkBg.CallBack = function() self:OnClickBtnBack() end +end + +function XUiPokemonStarSuccess:OnClickBtnBack() + self:Close() +end diff --git a/Resources/Scripts/XUi/XUiPokemon/XUiMonster/XUiPokemonUpgradePreview.lua b/Resources/Scripts/XUi/XUiPokemon/XUiMonster/XUiPokemonUpgradePreview.lua new file mode 100644 index 00000000..430ff085 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPokemon/XUiMonster/XUiPokemonUpgradePreview.lua @@ -0,0 +1,77 @@ +local CSXTextManagerGetText = CS.XTextManager.GetText + +local XUiPokemonUpgradePreview = XLuaUiManager.Register(XLuaUi, "UiPokemonUpgradePreview") + +function XUiPokemonUpgradePreview:OnAwake() + self:AutoAddListener() +end + +function XUiPokemonUpgradePreview:OnStart(monsterId, calllBack) + self.MonsterId = monsterId + self.CallBack = calllBack +end + +function XUiPokemonUpgradePreview:OnEnable() + self:UpdatePreview() +end + +function XUiPokemonUpgradePreview:UpdatePreview() + local monsterId = self.MonsterId + local addLevel, costItemDic = XDataCenter.PokemonManager.GetMonsterCanLevelUpTimes(monsterId) + + local level = XDataCenter.PokemonManager.GetMonsterLevel(monsterId) + self.TxtLvBefore.text = "Lv." .. level + + local newLevel = level + addLevel + self.TxtLvNow.text = "Lv." .. newLevel + + local hp = XDataCenter.PokemonManager.GetMonsterHp(monsterId) + self.TxtBeforeHp.text = hp + + local attack = XDataCenter.PokemonManager.GetMonsterAttack(monsterId) + self.TxtBeforeAttack.text = attack + + local preHp, preAttack = XDataCenter.PokemonManager.GetMonsterPreHpAndPreAttack(monsterId, newLevel) + self.TxtNowHp.text = preHp + self.TxtNowAttack.text = preAttack + + local costItemName, costItemCount = "", "" + for itemId, itemCount in pairs(costItemDic) do + costItemName = XItemConfigs.GetItemNameById(itemId) + costItemCount = itemCount + break + end + local tips = CsXTextManagerGetText("PokemonMonsterAutoLevelUpTips", costItemName, costItemCount) + self.TxtTip.text = tips +end + +function XUiPokemonUpgradePreview:AutoAddListener() + self.BtnTanchuangClose.CallBack = function() self:OnClickBtnBack() end + self.BtnConfirm.CallBack = function() self:OnClickBtnConfirm() end + self.BtnCancel.CallBack = function() self:OnClickBtnBack() end +end + +function XUiPokemonUpgradePreview:OnClickBtnBack() + self:Close() +end + +function XUiPokemonUpgradePreview:OnClickBtnConfirm() + local monsterId = self.MonsterId + + if XDataCenter.PokemonManager.IsMonsterMaxLevel(monsterId) then + XUiManager.TipText("PokemonMonsterMaxLevel") + return + end + + local times = XDataCenter.PokemonManager.GetMonsterCanLevelUpTimes(monsterId) + if times < 1 then + XUiManager.TipText("PokemonMonsterAutoLevelUpLackItem") + return + end + + local cb = function() + self:Close() + self.CallBack() + end + XDataCenter.PokemonManager.PokemonLevelUpRequest(monsterId, times, cb) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPokemon/XUiPanelPokemonStageDetail.lua b/Resources/Scripts/XUi/XUiPokemon/XUiPanelPokemonStageDetail.lua new file mode 100644 index 00000000..f98e0c29 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPokemon/XUiPanelPokemonStageDetail.lua @@ -0,0 +1,144 @@ +local XUiPanelPokemonStageDetail = XLuaUiManager.Register(XLuaUi, "UiPokemonStageDetail") +local XUiGridPokemonPortrait = require("XUi/XUiPokemon/XUiGridPokemonPortrait") + +function XUiPanelPokemonStageDetail:OnStart(stageId) + self.RewardPanelList = {} + self.MonsterHeadIcons = {} + self.BtnEnter.CallBack = function() + self:OnClickEnterBtn() + end + + if self.BtnMask then + self.BtnMask.CallBack = function() + self:Close() + end + self.BtnSkip.CallBack = function() + self:OnClickSkipBtn() + end + end + self.PanelAsset = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self:Refresh(stageId) +end + +function XUiPanelPokemonStageDetail:Refresh(stageId) + self.StageId = stageId + self:RefreshMonsters() + self:RefreshReward() + self:RefreshTitle() + self:RefreshSkipPanel() +end + +function XUiPanelPokemonStageDetail:RefreshSkipPanel() + local isCanSkip = XDataCenter.PokemonManager.IsCanSkipStage(self.StageId) + local isSkip = XDataCenter.PokemonManager.CheckIsSkip(XDataCenter.PokemonManager.GetStageFightStageId(self.StageId)) + local isPassed = XDataCenter.PokemonManager.CheckStageIsPassed(XDataCenter.PokemonManager.GetStageFightStageId(self.StageId)) + if self.PanelSkip then + self.PanelSkip.gameObject:SetActiveEx(isCanSkip and (not isSkip) and (not isPassed)) + end + if self.TxtAT then + self.TxtAT.text = CS.XTextManager.GetText("PokemonMonsterEnergyCost", XDataCenter.ItemManager.GetItemName(XPokemonConfigs.GetSkipItemId())) + self.RImgSkipIcon:SetRawImage(XDataCenter.ItemManager.GetItemIcon(XPokemonConfigs.GetSkipItemId())) + end +end + +function XUiPanelPokemonStageDetail:RefreshMonsters() + local monsters + if XDataCenter.PokemonManager.IsInfinityStage(self.StageId) then + monsters = XDataCenter.PokemonManager.GetRandomMonsters() + else + monsters = XDataCenter.PokemonManager.GetStageMonsterIds(self.StageId) + end + + for i = 1, XPokemonConfigs.TeamNum do + local panel = self.MonsterHeadIcons[i] + if not panel then + local ui = CS.UnityEngine.Object.Instantiate(self.GridPortrait) + ui.transform:SetParent(self.GridPortrait.parent, false) + panel = XUiGridPokemonPortrait.New(ui) + table.insert(self.MonsterHeadIcons, panel) + end + panel:Refresh(monsters[i], XDataCenter.PokemonManager.IsInfinityStage(self.StageId)) + end +end + +function XUiPanelPokemonStageDetail:RefreshReward() + + if XDataCenter.PokemonManager.CheckStageIsPassed(XDataCenter.PokemonManager.GetStageFightStageId(self.StageId)) then + self.TxtSpecialReward.gameObject:SetActiveEx(false) + self.PanelDropList.gameObject:SetActiveEx(false) + return + end + + self.TxtSpecialReward.gameObject:SetActiveEx(true) + self.PanelDropList.gameObject:SetActiveEx(true) + self.TxtSpecialReward.text = XDataCenter.PokemonManager.GetStageUnlockDesc(self.StageId) + + local fightStageId = XDataCenter.PokemonManager.GetStageFightStageId(self.StageId) + local stage = XDataCenter.FubenManager.GetStageCfg(fightStageId) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(fightStageId) + local rewardId = 0 + local IsFirst = false + for i = 1, #self.RewardPanelList do + self.RewardPanelList[i]:Refresh() + end + + local cfg = XDataCenter.FubenManager.GetStageLevelControl(fightStageId) + if not stageInfo.Passed then + rewardId = cfg and cfg.FirstRewardShow or stage.FirstRewardShow + if cfg and cfg.FirstRewardShow > 0 or stage.FirstRewardShow > 0 then + IsFirst = true + end + end + if rewardId == 0 then + rewardId = cfg and cfg.FinishRewardShow or stage.FinishRewardShow + end + + if rewardId == 0 then + return + end + + local rewardsList = IsFirst and XRewardManager.GetRewardList(rewardId) or XRewardManager.GetRewardListNotCount(rewardId) + + if not rewardsList then + return + end + + for i = 1, #rewardsList do + local panel = self.RewardPanelList[i] + if not panel then + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommon) + ui.transform:SetParent(self.GridCommon.parent, false) + panel = XUiGridCommon.New(self, ui) + end + panel:Refresh(rewardsList[i]) + end +end + +function XUiPanelPokemonStageDetail:RefreshTitle() + self.TxtTitle.text = XDataCenter.PokemonManager.GetStageName(self.StageId) +end + +function XUiPanelPokemonStageDetail:OnClickEnterBtn() + if XDataCenter.PokemonManager.CheckRemainingTimes() or XDataCenter.PokemonManager.IsInfinityStage(self.StageId) then + self:Close() + XLuaUiManager.Open("UiPokemonFormation", self.StageId) + else + XUiManager.TipText("PokemonRemainingTimeLimit") + end + +end + +function XUiPanelPokemonStageDetail:OnClickSkipBtn() + if not XDataCenter.PokemonManager.CheckCanSkip() then + XUiManager.TipText("PokemonSkipTimesNotEnough") + end + XDataCenter.PokemonManager.PokemonSkipStageRequest(XDataCenter.PokemonManager.GetPokemonStageId(self.StageId),function(rewardsList) + XUiManager.TipText("PokemonSkipSuccessTips") + self:Close() + if rewardsList and #rewardsList > 0 then + XUiManager.OpenUiTipReward(rewardsList) + end + end) +end + +return XUiPanelPokemonStageDetail \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPokemon/XUiPokemonActiveTask.lua b/Resources/Scripts/XUi/XUiPokemon/XUiPokemonActiveTask.lua new file mode 100644 index 00000000..8500e9cf --- /dev/null +++ b/Resources/Scripts/XUi/XUiPokemon/XUiPokemonActiveTask.lua @@ -0,0 +1,66 @@ +local XUiPokemonActiveTask = XLuaUiManager.Register(XLuaUi, "UiPokemonActiveTask") + +function XUiPokemonActiveTask:OnStart() + + + self.PanelAsset = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + + self:InitDynamicTable() + self:RegisterButtonClick() + self:Refresh() +end + +function XUiPokemonActiveTask:OnEnable() + self:Refresh() +end + +function XUiPokemonActiveTask:OnGetEvents() + return { + XEventId.EVENT_FINISH_TASK, + } +end + +function XUiPokemonActiveTask:OnNotify(event, ...) + if event == XEventId.EVENT_FINISH_TASK then + self:Refresh() + end +end + +function XUiPokemonActiveTask:RegisterButtonClick() + self.BtnBack.CallBack = function() + self:OnClickBackBtn() + end + + self.BtnMainUi.CallBack = function() + self:OnClickMainBtn() + end +end + +function XUiPokemonActiveTask:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.SViewTask.gameObject) + self.DynamicTable:SetProxy(XDynamicGridTask, self) + self.DynamicTable:SetDelegate(self) +end + +function XUiPokemonActiveTask:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:ResetData(self.TaskList[index]) + end +end + +function XUiPokemonActiveTask:Refresh() + self.TaskList = XDataCenter.PokemonManager.GetPokemonTimeLimitTask() + self.DynamicTable:SetDataSource(self.TaskList) + self.DynamicTable:ReloadDataSync() +end + +function XUiPokemonActiveTask:OnClickBackBtn() + XLuaUiManager.Close("UiPokemonActiveTask") +end + +function XUiPokemonActiveTask:OnClickMainBtn() + XLuaUiManager.RunMain() +end + + +return XUiPokemonActiveTask \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPokemon/XUiPokemonFight.lua b/Resources/Scripts/XUi/XUiPokemon/XUiPokemonFight.lua new file mode 100644 index 00000000..e3883523 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPokemon/XUiPokemonFight.lua @@ -0,0 +1,34 @@ +local XUiPokemonFight = XLuaUiManager.Register(XLuaUi,"UiPokemonFight") + +function XUiPokemonFight:OnStart() + self.Btns = {} + self:RegisterClickEvent(self.BtnMaskB,function() + self:Close() + end) + self:InitButton() +end + +function XUiPokemonFight:OnEnable() + +end + +function XUiPokemonFight:InitButton() + local skipList = XDataCenter.PokemonManager.GetSkipStageInfo() + for i = 1,#skipList do + local id = skipList[i] + local index = XPokemonConfigs.GetStageIdByFightStageId(XDataCenter.PokemonManager.GetCurrActivityId(),id) + ---@type UnityEngine.GameObject + local obj = CS.UnityEngine.GameObject.Instantiate(self.BtnEnterArena,self.PanelButton) + obj.gameObject:SetActiveEx(true) + ---@type XUiComponent.XUiButton + local btn = obj:GetComponent("XUiButton") + btn:SetName(XDataCenter.PokemonManager.GetStageName(index)) + btn.CallBack = function() + self:Close() + XLuaUiManager.Open("UiPokemonStageDetail",index) + end + table.insert(self.Btns,btn) + end +end + +return XUiPokemonFight \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPokemon/XUiPokemonFormation/XUiGridPokemonInfinityStageMonster.lua b/Resources/Scripts/XUi/XUiPokemon/XUiPokemonFormation/XUiGridPokemonInfinityStageMonster.lua new file mode 100644 index 00000000..c7565263 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPokemon/XUiPokemonFormation/XUiGridPokemonInfinityStageMonster.lua @@ -0,0 +1,34 @@ +local XUiGridPokemonInfinityStageMonster = XClass(nil, "XUiGridPokemonInfinityStageMonster") + +function XUiGridPokemonInfinityStageMonster:Ctor(ui, pos) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Pos = pos + XTool.InitUiObject(self) +end + +function XUiGridPokemonInfinityStageMonster:Refresh(monsterId) + + if self.TxtCareer then + local careerName = XPokemonConfigs.GetMonsterCareerName(monsterId) + self.TxtCareer.text = careerName + end + if self.TxtAbility then + local fightStageId = XDataCenter.PokemonManager.GetRandomStageId() + local stageId = XPokemonConfigs.GetStageIdByFightStageId(XDataCenter.PokemonManager.GetCurrActivityId(),fightStageId) + local ability = XDataCenter.PokemonManager.GetShowAbility(stageId, self.Pos) + self.TxtAbility.text = ability == 0 and "" or ability + end + + if self.RImgHeadIcon then + local icon = XPokemonConfigs.GetMonsterHeadIcon(monsterId) + self.RImgHeadIcon:SetRawImage(icon) + end + + if self.ImgIconCareer then + local icon = XPokemonConfigs.GetMonsterCareerIcon(monsterId) + self.ImgIconCareer:SetSprite(icon) + end +end + +return XUiGridPokemonInfinityStageMonster \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPokemon/XUiPokemonFormation/XUiGridPokemonMemberMonster.lua b/Resources/Scripts/XUi/XUiPokemon/XUiPokemonFormation/XUiGridPokemonMemberMonster.lua new file mode 100644 index 00000000..1ed04f9b --- /dev/null +++ b/Resources/Scripts/XUi/XUiPokemon/XUiPokemonFormation/XUiGridPokemonMemberMonster.lua @@ -0,0 +1,137 @@ +local CSXTextManagerGetText = CS.XTextManager.GetText + +local XUiGridPokemonMemberMonster = XClass(nil, "XUiGridPokemonMemberMonster") + +function XUiGridPokemonMemberMonster:Ctor(ui, clickCb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.ClickCb = clickCb + + XTool.InitUiObject(self) + + self.BtnKickout.CallBack = function() self:OnClickBtnKickout() end + self.BtnSwitch.CallBack = function() self:OnClickBtnSwitch() end + self.BtnSelect.CallBack = function() self:OnClickBtnSelect() end +end + +function XUiGridPokemonMemberMonster:Refresh(pos, recommendCareer, monsterId, selectPos, stageMonsterCareer) + self.Pos = pos + self.SelectPos = selectPos + local isEmpty = not monsterId or monsterId == 0 + + --位置未解锁 + local isLock = XDataCenter.PokemonManager.IsTeamPosLock(pos) + if isLock then + + self.PanelLock.gameObject:SetActiveEx(true) + self.PanelInformation.gameObject:SetActiveEx(false) + self.PanelRecommend.gameObject:SetActiveEx(false) + self.PanelSwitch.gameObject:SetActiveEx(false) + self.PanelKickout.gameObject:SetActiveEx(false) + + return + end + + --位置处于选中状态 + if selectPos then + + if pos == selectPos and not isEmpty then + + --设置为可下阵状态 + self.PanelLock.gameObject:SetActiveEx(false) + self.PanelInformation.gameObject:SetActiveEx(true) + self.PanelRecommend.gameObject:SetActiveEx(false) + self.PanelSwitch.gameObject:SetActiveEx(false) + self.PanelKickout.gameObject:SetActiveEx(true) + + else + + --设置为可交换位置状态 + self.PanelLock.gameObject:SetActiveEx(false) + self.PanelInformation.gameObject:SetActiveEx(false) + self.PanelRecommend.gameObject:SetActiveEx(false) + self.PanelSwitch.gameObject:SetActiveEx(true) + self.PanelKickout.gameObject:SetActiveEx(false) + + end + + return + end + + --位置未上阵怪物 + if isEmpty then + + if recommendCareer then + + local icon = XPokemonConfigs.GetCareerIcon(recommendCareer) + self.ImgIconCareerRecommend:SetSprite(icon) + self.ImgIconCareerRecommend.gameObject:SetActiveEx(false) + + local careerName = XPokemonConfigs.GetCareerName(recommendCareer) + self.TxtRecommendCareer.text = CSXTextManagerGetText("PokemonMonsterRecommendCareer", careerName) + self.TxtRecommendCareer.gameObject:SetActiveEx(false) + + else + + self.ImgIconCareerRecommend.gameObject:SetActiveEx(false) + self.TxtRecommendCareer.gameObject:SetActiveEx(false) + + end + + self.PanelRecommend.gameObject:SetActiveEx(true) + self.PanelInformation.gameObject:SetActiveEx(false) + self.PanelLock.gameObject:SetActiveEx(false) + self.PanelKickout.gameObject:SetActiveEx(false) + self.PanelSwitch.gameObject:SetActiveEx(false) + + return + end + + local headIcon = XPokemonConfigs.GetMonsterHeadIcon(monsterId) + self.RImgHeadIcon:SetRawImage(headIcon) + + local careerIcon = XPokemonConfigs.GetMonsterCareerIcon(monsterId) + self.ImgIconCareer:SetSprite(careerIcon) + + if self.TxtCareer then + local careerName = XPokemonConfigs.GetMonsterCareerName(monsterId) + self.TxtCareer.text = careerName + end + + local costEnergy = XPokemonConfigs.GetMonsterEnergyCost(monsterId) + self.TxtCostEnergy.text = CSXTextManagerGetText("PokemonMonsterEnergyCost", costEnergy) + + local ability = XDataCenter.PokemonManager.GetMonsterAbility(monsterId) + self.TxtAbility.text = ability + + local isCareerUp = XPokemonConfigs.IsMonsterCareerUp(monsterId, stageMonsterCareer) + self.IconUp.gameObject:SetActiveEx(isCareerUp) + + local isCareerDown = XPokemonConfigs.IsMonsterCareerDown(monsterId, stageMonsterCareer) + self.IconDown.gameObject:SetActiveEx(isCareerDown) + + if self.PanelBoss then + local isBoss = XPokemonConfigs.CheckMonsterType(monsterId, XPokemonConfigs.MonsterType.Boss) + self.PanelBoss.gameObject:SetActiveEx(isBoss) + end + + self.PanelInformation.gameObject:SetActiveEx(true) + self.PanelRecommend.gameObject:SetActiveEx(false) + self.PanelLock.gameObject:SetActiveEx(false) + self.PanelKickout.gameObject:SetActiveEx(false) + self.PanelSwitch.gameObject:SetActiveEx(false) +end + +function XUiGridPokemonMemberMonster:OnClickBtnKickout() + self.ClickCb(self.Pos) +end + +function XUiGridPokemonMemberMonster:OnClickBtnSwitch() + self.ClickCb(self.Pos) +end + +function XUiGridPokemonMemberMonster:OnClickBtnSelect() + self.ClickCb(self.Pos) +end + +return XUiGridPokemonMemberMonster \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPokemon/XUiPokemonFormation/XUiGridPokemonStageMonster.lua b/Resources/Scripts/XUi/XUiPokemon/XUiPokemonFormation/XUiGridPokemonStageMonster.lua new file mode 100644 index 00000000..d89ef11a --- /dev/null +++ b/Resources/Scripts/XUi/XUiPokemon/XUiPokemonFormation/XUiGridPokemonStageMonster.lua @@ -0,0 +1,32 @@ +local XUiGridPokemonStageMonster = XClass(nil, "XUiGridPokemonStageMonster") + +function XUiGridPokemonStageMonster:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) +end + +function XUiGridPokemonStageMonster:Refresh(stageMonsterId) + if self.TxtCareer then + local careerName = XPokemonConfigs.GetStageMonsterCareerName(stageMonsterId) + self.TxtCareer.text = careerName + end + + if self.TxtAbility then + local ability = XPokemonConfigs.GetStageMonsterAbility(stageMonsterId) + self.TxtAbility.text = ability + end + + if self.RImgHeadIcon then + local icon = XPokemonConfigs.GetStageMonsterHeadIcon(stageMonsterId) + self.RImgHeadIcon:SetRawImage(icon) + end + + if self.ImgIconCareer then + local icon = XPokemonConfigs.GetStageMonsterCareerIcon(stageMonsterId) + self.ImgIconCareer:SetSprite(icon) + end +end + +return XUiGridPokemonStageMonster \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPokemon/XUiPokemonFormation/XUiPokemonFormation.lua b/Resources/Scripts/XUi/XUiPokemon/XUiPokemonFormation/XUiPokemonFormation.lua new file mode 100644 index 00000000..15675b2d --- /dev/null +++ b/Resources/Scripts/XUi/XUiPokemon/XUiPokemonFormation/XUiPokemonFormation.lua @@ -0,0 +1,561 @@ +local XUiGridPokemonMonster = require("XUi/XUiPokemon/XUiMonster/XUiGridPokemonMonster") +local XUiGridPokemonStageMonster = require("XUi/XUiPokemon/XUiPokemonFormation/XUiGridPokemonStageMonster") +local XUiGridPokemonMemberMonster = require("XUi/XUiPokemon/XUiPokemonFormation/XUiGridPokemonMemberMonster") +local XUiGridPokemonInfinityStageMonster = require("XUi/XUiPokemon/XUiPokemonFormation/XUiGridPokemonInfinityStageMonster") + +local CSXTextManagerGetText = CS.XTextManager.GetText +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate +local ipairs = ipairs +local pairs = pairs +local tableInsert = table.insert +local tableSort = table.sort + +local TabBtnIndex = { + Shooter = 1, --射手 + Shield = 2, --盾卫 + Knight = 3, --骑士 + Assassin = 4,--刺客 +} + +local XUiPokemonFormation = XLuaUiManager.Register(XLuaUi, "UiPokemonFormation") + +function XUiPokemonFormation:OnAwake() + self:AutoAddListener() + self:InitTabBtns() + self:InitDynamicTable() + self:InitToggleState() + + self.GridEnemy.gameObject:SetActiveEx(false) + self.GridTeamMonster.gameObject:SetActiveEx(false) + self.GridMonster.gameObject:SetActiveEx(false) +end + +function XUiPokemonFormation:OnStart(stageId) + self.StageId = stageId + self.EnemyGrids = {} + self.TeamMemberGrids = {} + self.TempSpriteList = {} + self.TeamMonsterIds = XDataCenter.PokemonManager.GetTeamMonsterIds() + + self:InitPanelEnemy() + self:InitSuitDrdOptionList() + self:InitDefaultSelect() +end + +function XUiPokemonFormation:OnEnable() + --local isBossEmpty = XDataCenter.PokemonManager.CheckOwnMonsterEmpty(XPokemonConfigs.MonsterType.Boss) + --self.BtnTabBoss:SetDisable(isBossEmpty) + -- + --local isMemberEmpty = XDataCenter.PokemonManager.CheckOwnMonsterEmpty(XPokemonConfigs.MonsterType.Member) + --self.BtnTabMember:SetDisable(isMemberEmpty) + + self.PanelTypeGroup:SelectIndex(self.SelectTabBtnIndex) + + self:UpdatePanelTeamMembers() +end + +function XUiPokemonFormation:OnDestroy() + for _, info in pairs(self.TempSpriteList) do + CS.UnityEngine.Object.Destroy(info.Sprite) + CS.XResourceManager.Unload(info.Resource) + end +end + +function XUiPokemonFormation:InitToggleState() + local isSpeedUp = XDataCenter.PokemonManager.IsSpeedUp() + self.BtnToggle:SetButtonState(isSpeedUp and XUiButtonState.Select or XUiButtonState.Normal) +end + +function XUiPokemonFormation:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelDynamicTableMonster) + self.DynamicTable:SetProxy(XUiGridPokemonMonster) + self.DynamicTable:SetDelegate(self) +end + +function XUiPokemonFormation:InitTabBtns() + local tabBtns = { self.BtnTabBoss, self.BtnTabMember, self.BtnTabKnight, self.BtnTabAssassin } + for _,button in pairs(tabBtns) do + button:SetButtonState(CS.UiButtonState.Normal) + end + self.PanelTypeGroup:Init(tabBtns, function(index) self:OnSelectMonsterType(index) end, -1) +end + +function XUiPokemonFormation:InitDefaultSelect() + local isShooterEmpty = XDataCenter.PokemonManager.CheckBagMonsterEmptyByCareer(XPokemonConfigs.MonsterCareer.Shooter) + local isShieldEmpty = XDataCenter.PokemonManager.CheckBagMonsterEmptyByCareer(XPokemonConfigs.MonsterCareer.Shield) + local isKnightEmpty = XDataCenter.PokemonManager.CheckBagMonsterEmptyByCareer(XPokemonConfigs.MonsterCareer.Knight) + local isAssassinEmpty = XDataCenter.PokemonManager.CheckBagMonsterEmptyByCareer(XPokemonConfigs.MonsterCareer.Assassin) + + if not isShooterEmpty then + self.SelectTabBtnIndex = TabBtnIndex.Shooter + elseif not isShieldEmpty then + self.SelectTabBtnIndex = TabBtnIndex.Shield + elseif not isKnightEmpty then + self.SelectTabBtnIndex = TabBtnIndex.Knight + elseif not isAssassinEmpty then + self.SelectTabBtnIndex = TabBtnIndex.Assassin + else + self.SelectTabBtnIndex = TabBtnIndex.Shooter + end + + self.SelectMonsterIndex = 1 +end + +function XUiPokemonFormation:InitSuitDrdOptionList() + self.DrdCareer:ClearOptions() + + local allCareers = XPokemonConfigs.GetAllCareers() + self.AllCareers = allCareers + + local optionDataList = CS.UnityEngine.UI.Dropdown.OptionDataList() + for _, career in ipairs(allCareers) do + + local optionData = CS.UnityEngine.UI.Dropdown.OptionData() + + local careerName = XPokemonConfigs.GetCareerName(career) + optionData.text = careerName + + local careerIcon = XPokemonConfigs.GetCareerIcon(career) + if careerIcon then + local resource = CS.XResourceManager.Load(careerIcon) + local asset = resource.Asset + + local sprite + if asset and asset.width and asset.height then + --texture + sprite = CS.UnityEngine.Sprite.Create(asset, + CS.UnityEngine.Rect(0, 0, asset.width, asset.height), + CS.UnityEngine.Vector2.zero) + + local info = { + Sprite = sprite, + Resource = resource, + } + tableInsert(self.TempSpriteList, info) + else + --sprite + sprite = asset + end + optionData.image = sprite + + end + + optionDataList.options:Add(optionData) + + end + + self.DrdCareer:AddOptions(optionDataList.options) + + local defaultValue = #allCareers + self.DrdCareer.value = defaultValue - 1 + self.SortCareer = self.AllCareers[defaultValue] +end + +function XUiPokemonFormation:InitPanelEnemy() + local stageId = self.StageId + local stageMonsterIds + if XDataCenter.PokemonManager.IsInfinityStage(stageId) then + stageMonsterIds = XDataCenter.PokemonManager.GetRandomMonsters() + else + stageMonsterIds = XDataCenter.PokemonManager.GetStageMonsterIds(stageId) + end + self.StageMonsterIds = stageMonsterIds + + for pos = 1, XPokemonConfigs.TeamNum do + + local grid = self.EnemyGrids[pos] + if not grid then + local parent = self["PanelEnemy" .. pos] + local go = pos == 1 and self.GridEnemy or CSUnityEngineObjectInstantiate(self.GridEnemy, parent) + if XDataCenter.PokemonManager.IsInfinityStage(stageId) then + grid = XUiGridPokemonInfinityStageMonster.New(go, pos) + else + grid = XUiGridPokemonStageMonster.New(go) + end + grid.Transform:SetParent(parent) + grid.Transform:Reset() + self.EnemyGrids[pos] = grid + end + + local stageMonsterId = stageMonsterIds[pos] + if stageMonsterId and stageMonsterId > 0 then + grid:Refresh(stageMonsterId) + + grid.GameObject:SetActiveEx(true) + else + grid.GameObject:SetActiveEx(false) + end + + end + +end + +function XUiPokemonFormation:UpdatePanelTeamMembers() + + local selectPos = self.SelectMemberPos + local monsterIds = self.TeamMonsterIds + for pos = 1, XPokemonConfigs.TeamNum do + + local grid = self.TeamMemberGrids[pos] + if not grid then + local parent = self["PanelMonster" .. pos] + local go = pos == 1 and self.GridTeamMonster or CSUnityEngineObjectInstantiate(self.GridTeamMonster, parent) + local clickCb = function(selectPos) + self:OnSelectTeamMemberPos(selectPos) + end + grid = XUiGridPokemonMemberMonster.New(go, clickCb) + grid.Transform:SetParent(parent) + grid.Transform:Reset() + self.TeamMemberGrids[pos] = grid + end + + local monsterId = monsterIds[pos] + local stageMonsterId = self.StageMonsterIds[pos] + if XDataCenter.PokemonManager.IsInfinityStage(self.StageId) then + local stageMonsterCareer = stageMonsterId and XPokemonConfigs.GetMonsterCareer(stageMonsterId) + local recommendCareer = XPokemonConfigs.GetMonsterCareerRecommendCareer(stageMonsterCareer) + grid:Refresh(pos, recommendCareer, monsterId, selectPos, stageMonsterCareer) + grid.GameObject:SetActiveEx(true) + else + local stageMonsterCareer = stageMonsterId and XPokemonConfigs.GetStageMonsterCareer(stageMonsterId) + local recommendCareer = XPokemonConfigs.GetMonsterCareerRecommendCareer(stageMonsterCareer) + grid:Refresh(pos, recommendCareer, monsterId, selectPos, stageMonsterCareer) + grid.GameObject:SetActiveEx(true) + end + end + + local currentCostEnergy = self:GetCurrentCostEnergy() + local maxCostEnergy = XDataCenter.PokemonManager.GetMaxEnergy() + local canCostEnrgy = maxCostEnergy - currentCostEnergy + self.TxtEnergy.text = CSXTextManagerGetText("PokemonMonsterEnergyCostProgress", canCostEnrgy, maxCostEnergy) + +end + +function XUiPokemonFormation:OnSelectTeamMemberPos(selectPos) + + local oldSelectPos = self.SelectMemberPos + if oldSelectPos then + + --已经处于选中状态 + if selectPos == oldSelectPos then + + --再次选中相同位置下阵 + self.TeamMonsterIds[selectPos] = 0 + + elseif selectPos then + + --选中不同位置, 互相交换 + local monsterIds = self.TeamMonsterIds + monsterIds[oldSelectPos], monsterIds[selectPos] = monsterIds[selectPos], monsterIds[oldSelectPos] + + end + + --取消选中状态,隐藏遮罩 + self.BtnFullMask.gameObject:SetActiveEx(false) + + self.SelectMemberPos = nil + self:UpdatePanelTeamMembers() + self:UpdateMonsters() + + else + + --置为选中状态,增加遮罩 + if selectPos then + self.BtnFullMask.gameObject:SetActiveEx(true) + end + + self.SelectMemberPos = selectPos + self:UpdatePanelTeamMembers() + self:UpdateMonsters() + + end + +end + +function XUiPokemonFormation:OnSelectMonsterType(index) + self.SelectTabBtnIndex = index + + if index == TabBtnIndex.Boss then + + self.TxtBossDisableTip.gameObject:SetActiveEx(true) + self.TxtEnergy.gameObject:SetActiveEx(false) + + else + + self.TxtBossDisableTip.gameObject:SetActiveEx(false) + self.TxtEnergy.gameObject:SetActiveEx(true) + + end + + self:UpdateMonsters() + + self:PlayAnimationWithMask("QieHuan") +end + +function XUiPokemonFormation:UpdateMonsters() + local monsterIds = self:GetCanSelectMonsterIdList() + + local isEmpty = XTool.IsTableEmpty(monsterIds) + self.ImgEmpty.gameObject:SetActiveEx(isEmpty) + + self.MonsterIds = monsterIds + self.DynamicTable:SetDataSource(monsterIds) + self.DynamicTable:ReloadDataASync() +end + +function XUiPokemonFormation:UpdateSelectIndex() + --if self.SelectTabBtnIndex == TabBtnIndex.Member then + -- return + --end + -- + --if XDataCenter.PokemonManager.CheckBagMonsterEmpty(XPokemonConfigs.MonsterType.Boss) and not XDataCenter.PokemonManager.CheckOwnMonsterEmpty(XPokemonConfigs.MonsterType.Member) then + -- self.SelectTabBtnIndex = TabBtnIndex.Member + --else + -- self.SelectTabBtnIndex = TabBtnIndex.Boss + --end + self.PanelTypeGroup:SelectIndex(self.SelectTabBtnIndex) +end + +function XUiPokemonFormation:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + + local monsterId = self.MonsterIds[index] + grid:Refresh(monsterId) + + local isDisable = XPokemonConfigs.CheckMonsterType(monsterId,XPokemonConfigs.MonsterType.Boss) and self:CheckBossInTeam() + grid:SetDisable(isDisable) + + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + + local monsterId = self.MonsterIds[index] + + --能量超出可分配上限 + if self:CheckMonsterCostEnergyOverMax(monsterId) then + XUiManager.TipText("PokemonMonsterFormationMaxEnergyCost") + return + end + + --队伍已满 + if self:CheckTeamFull() then + XUiManager.TipText("PokemonMonsterFormationTeamFull") + return + end + + --已上阵BOSS + if self:CheckBossInTeam() and XPokemonConfigs.CheckMonsterType(monsterId,XPokemonConfigs.MonsterType.Boss) then + return + end + + local firstEmptyPos = self:GetFirstEmptyTeamMemberPos() + self.TeamMonsterIds[firstEmptyPos] = monsterId + + self:UpdatePanelTeamMembers() + self:UpdateMonsters() + self:UpdateSelectIndex() + end +end + +function XUiPokemonFormation:AutoAddListener() + self.BtnBack.CallBack = function() self:OnClickBtnBack() end + self.BtnMainUi.CallBack = function() self:OnClickBtnMainUi() end + self.BtnClear.CallBack = function() self:OnClickBtnClear() end + self.BtnStart.CallBack = function() self:OnClickBtnStart() end + self.BtnFullMask.CallBack = function() self:OnClickBtnFullMask() end + self.BtnToggle.CallBack = function() self:OnClickSpeedUpToggle() end + self.DrdCareer.onValueChanged:AddListener(function() self:OnDrdSuitValueChanged() end) +end + +function XUiPokemonFormation:OnDrdSuitValueChanged() + self.SortCareer = self.AllCareers[self.DrdCareer.value + 1] + self:UpdateMonsters() + + self:PlayAnimationWithMask("QieHuan") +end + +function XUiPokemonFormation:OnClickSpeedUpToggle() + local isSelect = self.BtnToggle:GetToggleState() + self.BtnToggle:SetButtonState(not isSelect and XUiButtonState.Select or XUiButtonState.Normal) + if isSelect then + local content = string.gsub(CSXTextManagerGetText("PokemonSpeedUpTipContent"), "\\n", "\n") + XUiManager.DialogTip(CSXTextManagerGetText("PokemonSpeedUpTipTitle"), content, XUiManager.DialogType.Normal, function() + self.BtnToggle:SetButtonState(XUiButtonState.Normal) + XDataCenter.PokemonManager.SetSpeedUp(false) + end, function() + self.BtnToggle:SetButtonState(XUiButtonState.Select) + XDataCenter.PokemonManager.SetSpeedUp(true) + end) + else + self.BtnToggle:SetButtonState(XUiButtonState.Normal) + XDataCenter.PokemonManager.SetSpeedUp(false) + end +end + +function XUiPokemonFormation:OnClickBtnBack() + self:Close() +end + +function XUiPokemonFormation:OnClickBtnMainUi() + XLuaUiManager.RunMain() +end + +function XUiPokemonFormation:OnClickBtnClear() + if self:CheckTeamEmpty() then + XUiManager.TipText("PokemonMonsterFormationTeamEmpty") + return + end + + self:ResetTeam() + self:OnSelectTeamMemberPos(nil) +end + +function XUiPokemonFormation:OnClickBtnStart() + --未上阵BOSS + if not self:CheckBossInTeam() then + XUiManager.TipText("PokemonMonsterFormationTeamWithoutBoss") + return + end + + local monsterIdList = self.TeamMonsterIds + local cb = function() + local stageId = self.StageId + local fightStageId = XDataCenter.PokemonManager.GetStageFightStageId(stageId) + + self:Close() + XDataCenter.FubenManager.EnterPokemonFight(fightStageId) + end + XDataCenter.PokemonManager.PokemonSetFormationRequest(monsterIdList, cb) +end + +function XUiPokemonFormation:OnClickBtnFullMask() + self:OnSelectTeamMemberPos(nil) +end +------------UI DATA BEGIN--------------- +local TabBtnIndexToMonsterType = { + [TabBtnIndex.Shooter] = XPokemonConfigs.MonsterCareer.Shooter, + [TabBtnIndex.Shield] = XPokemonConfigs.MonsterCareer.Shield, + [TabBtnIndex.Knight] = XPokemonConfigs.MonsterCareer.Knight, + [TabBtnIndex.Assassin] = XPokemonConfigs.MonsterCareer.Assassin, +} +function XUiPokemonFormation:GetSelectMonsterType() + return TabBtnIndexToMonsterType[self.SelectTabBtnIndex] +end + +function XUiPokemonFormation:ResetTeam() + for pos = 1, XPokemonConfigs.TeamNum do + self.TeamMonsterIds[pos] = 0 + end +end + +function XUiPokemonFormation:GetFirstEmptyTeamMemberPos() + local pos = 0 + + for teamPos = 1, XPokemonConfigs.TeamNum do + if not XDataCenter.PokemonManager.IsTeamPosLock(teamPos) then + + local teamMonsterId = self.TeamMonsterIds[teamPos] + if not teamMonsterId or teamMonsterId == 0 then + pos = teamPos + break + end + + end + end + + return pos +end + +function XUiPokemonFormation:CheckTeamFull() + return self:GetFirstEmptyTeamMemberPos() == 0 +end + +function XUiPokemonFormation:CheckTeamEmpty() + for _, teamMonsterId in pairs(self.TeamMonsterIds) do + if teamMonsterId ~= 0 then + return false + end + end + return true +end + +function XUiPokemonFormation:CheckBossInTeam() + for _, teamMonsterId in pairs(self.TeamMonsterIds) do + if XPokemonConfigs.CheckMonsterType(teamMonsterId, XPokemonConfigs.MonsterType.Boss) then + return true + end + end + + return false +end + +function XUiPokemonFormation:CheckMonsterInTeam(monsterId) + if not monsterId or monsterId == 0 then return false end + + for _, teamMonsterId in pairs(self.TeamMonsterIds) do + if teamMonsterId == monsterId then + return true + end + end + + return false +end + +function XUiPokemonFormation:GetCanSelectMonsterIdList() + local monsterIds = {} + + local careerType = self:GetSelectMonsterType() + local ownMonsterIds = XDataCenter.PokemonManager.GetOwnMonsterIdsByCareer(careerType) + local teamMonsterIds = self.TeamMonsterIds + + --剔除已在队伍中的成员 + for _, monsterId in pairs(ownMonsterIds) do + if monsterId > 0 and not self:CheckMonsterInTeam(monsterId) then + tableInsert(monsterIds, monsterId) + end + end + + local sortCareer = self.SortCareer + tableSort(monsterIds, function(aMonsterId, bMonsterId) + --if sortCareer ~= XPokemonConfigs.DefaultAllCareer then + -- local aCareer = XPokemonConfigs.GetMonsterCareer(aMonsterId) + -- local bCareer = XPokemonConfigs.GetMonsterCareer(bMonsterId) + -- if aCareer ~= bCareer then + -- return aCareer == sortCareer + -- end + --end + -- + --local aAbility = XDataCenter.PokemonManager.GetMonsterAbility(aMonsterId) + --local bAbility = XDataCenter.PokemonManager.GetMonsterAbility(bMonsterId) + --return aAbility > bAbility + local costA = XPokemonConfigs.GetMonsterEnergyCost(aMonsterId) + local costB = XPokemonConfigs.GetMonsterEnergyCost(bMonsterId) + costA = costA == 0 and math.huge or costA + costB = costB == 0 and math.huge or costB + return costA > costB + end) + + return monsterIds +end + +function XUiPokemonFormation:GetCurrentCostEnergy() + local energy = 0 + + for _, teamMonsterId in pairs(self.TeamMonsterIds) do + if teamMonsterId and teamMonsterId ~= 0 then + local costEnergy = XPokemonConfigs.GetMonsterEnergyCost(teamMonsterId) + energy = energy + costEnergy + end + end + + return energy +end + +function XUiPokemonFormation:CheckMonsterCostEnergyOverMax(monsterId) + if not monsterId or monsterId == 0 then return false end + + local maxCostEnergy = XDataCenter.PokemonManager.GetMaxEnergy() + local currentCostEnergy = self:GetCurrentCostEnergy() + local costEnergy = XPokemonConfigs.GetMonsterEnergyCost(monsterId) + + return currentCostEnergy + costEnergy > maxCostEnergy +end +------------UI DATA END--------------- \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPokemon/XUiPokemonMain.lua b/Resources/Scripts/XUi/XUiPokemon/XUiPokemonMain.lua new file mode 100644 index 00000000..3834817f --- /dev/null +++ b/Resources/Scripts/XUi/XUiPokemon/XUiPokemonMain.lua @@ -0,0 +1,342 @@ +local XUiPokemonMain = XLuaUiManager.Register(XLuaUi, "UiPokemonMain") +local XUiGridPokemonStagePage = require("XUi/XUiPokemon/XUiGridPokemonStagePage") +local XUiGridPokemonStage = require("XUi/XUiPokemon/XUiGridPokemonStage") + +local SWITCH_EFFECT_TIME = 2 * XScheduleManager.SECOND + +function XUiPokemonMain:OnStart() + local helpId = XPokemonConfigs.GetHelpId() + self.BtnHelp.gameObject:SetActiveEx(helpId > 0) + self:RegisterButtonEvent() + self.ImpDynamicTable.GridSize = CS.UnityEngine.Vector2(self.ViewPort.rect.width, self.ViewPort.rect.height) + self:InitDynamicTable() + self.InfinityStage = XUiGridPokemonStage.New(self.BtnInfinity, 0, function(stageId) + self:OnOpenStageDetail(stageId) + end) + self.IsInfinity = false + local stages = XDataCenter.PokemonManager.GetPassedCount() + 1 + local pages = math.ceil(stages / XPokemonConfigs.PerPageCount) + self.LastIndex = pages - 1 + self.StartTime, self.EndTime = XDataCenter.PokemonManager.GetCurrActivityTime() + self.TimeHandler = XScheduleManager.ScheduleForever(function() + if XTool.UObjIsNil(self.TxtProgress) then + self:StopTimer() + return + end + local currentTime = XTime.GetServerNowTimestamp() + if currentTime > self.EndTime then + XDataCenter.PokemonManager.OnActivityEnd() + return + end + self:RefreshTimeSupplyText() + self:RefreshTimeSupplyProgress() + --self:RefreshNextRecoverTime() + end, 1000, 0) + self:RefreshTimeSupplyText() + self:RefreshTimeSupplyProgress() + self:RefreshChapterStageBuff() + self:RefreshSkipPanel() + if self.Background then + self.Background:SetRawImage(XDataCenter.PokemonManager.GetChapterScrollBg()) + end + --self:RefreshNextRecoverTime() + XRedPointManager.AddRedPointEvent(self.ImgRedPoint, self.CheckTimeSupplyRedPoint, self, { XRedPointConditions.Types.CONDITION_POKEMON_TIME_SUPPLY_RED }) +end + +function XUiPokemonMain:OnEnable() + XRedPointManager.CheckOnce(self.CheckTaskRedPoint, self, { XRedPointConditions.Types.CONDITION_POKEMON_TASK_RED }) + self:RefreshSkipStageTimes() + self:SetupDynamicTable() + --self:SwitchToInfinity() + --self.InfinityStage:Refresh(XDataCenter.PokemonManager.GetNextStage()) + --self:RefreshRemainingTimes() + --新怪物弹窗 + XDataCenter.PokemonManager.CheckNewMonsterIds() +end + +function XUiPokemonMain:OnDisable() + self.LastIndex = self.ImpDynamicTable.StartIndex +end + +function XUiPokemonMain:OnDestroy() + self:StopTimer() +end + +function XUiPokemonMain:OnGetEvents() + return { + XEventId.EVENT_POKEMON_REMAINING_TIMES_CHANGE, + XEventId.EVENT_POKEMON_PASSED_STAGE_CHANGE, + } +end + +function XUiPokemonMain:OnNotify(event, ...) + if event == XEventId.EVENT_POKEMON_REMAINING_TIMES_CHANGE then + --self:RefreshRemainingTimes() + elseif event == XEventId.EVENT_POKEMON_PASSED_STAGE_CHANGE then + self:SetupDynamicTable() + self:RefreshSkipPanel() + self:RefreshSkipStageTimes() + end +end + +function XUiPokemonMain:InitDynamicTable() + self.DynamicTable = XDynamicTableCurve.New(self.PaneStageList) + self.DynamicTable:SetProxy(XUiGridPokemonStagePage) + self.DynamicTable:SetDelegate(self) +end + +function XUiPokemonMain:SetupDynamicTable() + local stages = XDataCenter.PokemonManager.GetPassedCountByChapterId(XDataCenter.PokemonManager.GetSelectChapter()) + 1 + stages = XMath.Clamp(stages,1,XPokemonConfigs.GetStageCountByChapter(XDataCenter.PokemonManager.GetCurrActivityId(),XDataCenter.PokemonManager.GetSelectChapter())) + local pages = math.ceil(stages / XPokemonConfigs.GetChapterPerPageStageCount(XDataCenter.PokemonManager.GetSelectChapter())) + self.DynamicTable:SetTotalCount(pages) + self.DynamicTable:ReloadData(self.LastIndex) + self.DynamicTable:TweenToIndex(pages - 1) +end + +function XUiPokemonMain:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:Refresh(index) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + --self:CloseDetailUi() + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:InitStage(function(stageId) + self:OnOpenStageDetail(stageId) + end) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_TWEEN_OVER then + --if self.ImpDynamicTable.StartIndex * XPokemonConfigs.PerPageCount >= XDataCenter.PokemonManager.GetStageCountByType(XPokemonConfigs.StageType.Normal) then + -- self.ImpDynamicTable.enabled = false + -- self.IsInfinity = true + --end + end +end + +--function XUiPokemonMain:CloseDetailUi() +-- if XLuaUiManager.IsUiShow("UiPokemonStageDetail") then +-- local childUi = self:FindChildUiObj("UiPokemonStageDetail") +-- self:CloseChildUi("UiPokemonStageDetail") +-- end +--end + +function XUiPokemonMain:RegisterButtonEvent() + self.BtnBack.CallBack = function() + self:OnClickBackBtn() + end + self.BtnMainUi.CallBack = function() + self:OnClickMainBtn() + end + self.BtnTask.CallBack = function() + self:OnClickTaskBtn() + end + self.BtnCulture.CallBack = function() + self:OnClickTeamTraining() + end + + self.BtnHelp.CallBack = function() + self:OnClickHelpBtn() + end + + self.BtnJumpOff.CallBack = function() + self:OnClickBtnJump() + end + + self.InfinityUiWidget:AddPointerClickListener(function(eventData) + self:CloseDetailUi() + end) + + CsXUiHelper.RegisterClickEvent(self.BtnTreasure, function() + self:OnClickTimeSupplyBtn() + end) + CsXUiHelper.RegisterClickEvent(self.BtnSkipIconClick, function() + local itemId = XPokemonConfigs.GetSkipItemId() + local data = { + IsTempItemData = true, + Name = XDataCenter.ItemManager.GetItemName(itemId), + Count = XDataCenter.PokemonManager.GetStageSkipTimes(), + Icon = XDataCenter.ItemManager.GetItemIcon(itemId), + Quality = XDataCenter.ItemManager.GetItemQuality(itemId), + WorldDesc = XDataCenter.ItemManager.GetItemWorldDesc(itemId), + Description = XDataCenter.ItemManager.GetItemDescription(itemId) + } + XLuaUiManager.Open("UiTip",data,false,self.Name) + end) +end + +function XUiPokemonMain:OnOpenStageDetail(stageId) + XLuaUiManager.Open("UiPokemonStageDetail",stageId) +end + +function XUiPokemonMain:OnClickHelpBtn() + local helpId = XPokemonConfigs.GetHelpId() + if helpId > 0 then + local template = XHelpCourseConfig.GetHelpCourseTemplateById(helpId) + XUiManager.ShowHelpTip(template.Function) + end +end + +function XUiPokemonMain:OnClickTaskBtn() + XLuaUiManager.Open("UiPokemonActiveTask") +end + +function XUiPokemonMain:OnClickBackBtn() + XLuaUiManager.Close("UiPokemonMain") +end + +function XUiPokemonMain:OnClickMainBtn() + XLuaUiManager.RunMain() +end + +function XUiPokemonMain:OnClickTeamTraining() + XDataCenter.PokemonManager.OpenMonsterUi() +end + +function XUiPokemonMain:OnClickTimeSupplyBtn() + if XDataCenter.PokemonManager.CheckCanGetTimeSupply() then + XDataCenter.PokemonManager.PokemonGetTimeSupplyRewardRequest(function(rewardsList) + self:ShowBoxRewards(rewardsList) + end) + else + XUiManager.TipText("PokemonCannotGetTimeSupply") + end +end + +function XUiPokemonMain:OnClickBtnJump() + XLuaUiManager.Open("UiPokemonFight") +end + +function XUiPokemonMain:RefreshSkipPanel() + local chapter = XDataCenter.PokemonManager.GetSelectChapterType() + local skipInfo = XDataCenter.PokemonManager.GetSkipStageInfo() + if self.PanelIcon and self.BtnJumpOff then + self.BtnJumpOff.gameObject:SetActiveEx(chapter == XPokemonConfigs.ChapterType.Skip and (#skipInfo ~= 0)) + self.PanelIcon.gameObject:SetActiveEx(chapter == XPokemonConfigs.ChapterType.Skip) + end +end + +function XUiPokemonMain:RefreshStagePanel() + --屏蔽原有无尽关逻辑 + if false then --XDataCenter.PokemonManager.IsInfinity() then + self.PanelNightmareStageList.gameObject:SetActiveEx(true) + self.PanelNormalStageList.gameObject:SetActiveEx(false) + self.InfinityStage:Refresh(XDataCenter.PokemonManager.GetNextStage()) + self.PanelChallenge.gameObject:SetActiveEx(false) + else + self.PanelNightmareStageList.gameObject:SetActiveEx(false) + self.PanelNormalStageList.gameObject:SetActiveEx(true) + self.PanelChallenge.gameObject:SetActiveEx(true) + self:SetupDynamicTable() + end +end + +function XUiPokemonMain:RefreshNextRecoverTime() + if not self.TxtNextRecoverTime then return end + local nextRecoverTime = XDataCenter.PokemonManager.GetNextRecoverTime() + if nextRecoverTime == 0 then + local timeStr = XUiHelper.GetTime(XPokemonConfigs.GetDefaultStageTimesRecoverInterval(), XUiHelper.TimeFormatType.DEFAULT) + self.TxtNextRecoverTime.text = timeStr + return + end + + local now = XTime.GetServerNowTimestamp() + local offset = nextRecoverTime - now + offset = XMath.Clamp(offset, 0, nextRecoverTime) + local timeStr = XUiHelper.GetTime(offset, XUiHelper.TimeFormatType.DEFAULT) + self.TxtNextRecoverTime.text = timeStr +end + +function XUiPokemonMain:RefreshChapterStageBuff() + local path = XDataCenter.PokemonManager.GetSelectChapterTitleImage() + if not string.IsNilOrEmpty(path) then + self:SetUiSprite(self.ImgChapterTitle,path) + end + self.TxtBuffTitle.text = XDataCenter.PokemonManager.GetSelectChapterName() + self.TxtBuff.text = string.gsub(XDataCenter.PokemonManager.GetSelectChapterDesc(), "\\n", "\n") +end + +function XUiPokemonMain:RefreshRemainingTimes() + local times = XDataCenter.PokemonManager.GetRemainingTimes() + self.TxtNumber.text = times +end + +function XUiPokemonMain:RefreshTimeSupplyText() + local offsetTime = XDataCenter.PokemonManager.GetTimeSupplyOffsetTime() + self.TxtProgress.text = self:ParseTime(offsetTime) + XEventManager.DispatchEvent(XEventId.EVENT_POKEMON_RED_POINT_TIME_SUPPLY) +end + +function XUiPokemonMain:RefreshTimeSupplyProgress() + local offsetTime = XDataCenter.PokemonManager.GetTimeSupplyOffsetTime() + self.ImgProgress.fillAmount = offsetTime / (XPokemonConfigs.GetTimeSupplyMaxCount() * XPokemonConfigs.GetTimeSupplyInterval()) +end + +function XUiPokemonMain:RefreshActivityTime() + local _, endTime = XDataCenter.PokemonManager.GetCurrActivityTime() + local now = XTime.GetServerNowTimestamp() + local offset = endTime - now + if offset < 0 then + offset = 0 + end + local timeStr = XUiHelper.GetTime(offset, XUiHelper.TimeFormatType.ACTIVITY) + self.TxtTime.text = timeStr +end +--原有的时间显示修改为跳关券数量展示 +function XUiPokemonMain:RefreshSkipStageTimes() + self.TxtSkipNum.text = XDataCenter.PokemonManager.GetStageSkipTimes() + self.TxtSkipMaxNum.text = string.format("/%s",tostring(XPokemonConfigs.GetSkipMaxTime())) + self.RImgSkipIcon:SetRawImage(XDataCenter.ItemManager.GetItemIcon(XPokemonConfigs.GetSkipItemId())) +end + +function XUiPokemonMain:ShowBoxRewards(rewardsList) + XUiManager.OpenUiTipReward(rewardsList) +end + +function XUiPokemonMain:CheckTimeSupplyRedPoint(isShow) + self.ImgRedPoint.gameObject:SetActiveEx(isShow >= 0) + + if self.TxtReward then + self.TxtReward.gameObject:SetActiveEx(isShow >= 0) + end + + if self.RImgBgIcon then + self.RImgBgIcon.gameObject:SetActiveEx(isShow < 0) + end + + if self.RImgBgIcon2 then + self.RImgBgIcon2.gameObject:SetActiveEx(isShow >= 0) + end +end + +function XUiPokemonMain:CheckTaskRedPoint(isShow) + self.BtnTask:ShowReddot(isShow >= 0) +end + +function XUiPokemonMain:StopTimer() + if self.TimeHandler then + XScheduleManager.UnSchedule(self.TimeHandler) + self.TimeHandler = nil + end +end +--原有无尽关逻辑修改屏蔽 +--function XUiPokemonMain:SwitchToInfinity() +-- if XDataCenter.PokemonManager.GetIsSwitchToInfinity() then +-- if self.SwitchEffect then +-- self.SwitchEffect.gameObject:SetActiveEx(true) +-- XScheduleManager.ScheduleOnce(function() +-- self:RefreshStagePanel() +-- end, SWITCH_EFFECT_TIME) +-- end +-- XDataCenter.PokemonManager.SetIsSwitchToInfinity(false) +-- else +-- self:RefreshStagePanel() +-- self.SwitchEffect.gameObject:SetActiveEx(false) +-- end +--end + +function XUiPokemonMain:ParseTime(time) + local seconds = math.floor(time % 60) + local mins = math.floor((time / 60) % 60) + local hours = math.floor(time / 3600) + return string.format("%02d:%02d:%02d", hours, mins, seconds) +end + +return XUiPokemonMain \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPokemon/XUiPokemonMainLineBanner.lua b/Resources/Scripts/XUi/XUiPokemon/XUiPokemonMainLineBanner.lua new file mode 100644 index 00000000..a91e903c --- /dev/null +++ b/Resources/Scripts/XUi/XUiPokemon/XUiPokemonMainLineBanner.lua @@ -0,0 +1,160 @@ +local XUiPokemonMainLineBanner = XLuaUiManager.Register(XLuaUi, "UiPokemonMainLineBanner") +local XUiGridPokemonChapter = require("XUi/XUiPokemon/XUiGridPokemonChapter") + +function XUiPokemonMainLineBanner:OnStart() + self:RegisterButtonEvent() + self:InitDynamicTable() + self:SetupDynamicTable() + local helpId = XPokemonConfigs.GetHelpId() + self.BtnHelp.gameObject:SetActiveEx(helpId > 0) + XRedPointManager.AddRedPointEvent(self.ImgRedPoint, self.CheckTimeSupplyRedPoint, self, { XRedPointConditions.Types.CONDITION_POKEMON_TIME_SUPPLY_RED }) +end + +function XUiPokemonMainLineBanner:OnEnable() + self:RefreshTimeSupplyText() + self:RefreshTimeSupplyProgress() + self:RefreshActivityTime() + self:StartTimer() + XRedPointManager.CheckOnce(self.CheckTaskRedPoint, self, { XRedPointConditions.Types.CONDITION_POKEMON_TASK_RED }) +end + +function XUiPokemonMainLineBanner:OnDisable() + self:StopTimer() +end + +function XUiPokemonMainLineBanner:InitDynamicTable() + ---@type XDynamicTableNormal + self.DynamicTable = XDynamicTableNormal.New(self.SViewChapterDz) + self.DynamicTable:SetDelegate(self) + self.DynamicTable:SetProxy(XUiGridPokemonChapter,self) +end + +function XUiPokemonMainLineBanner:SetupDynamicTable() + local chapters = XDataCenter.PokemonManager.GetChapters() + self.DynamicTable:SetTotalCount(#chapters) + self.DynamicTable:ReloadDataASync() +end + +function XUiPokemonMainLineBanner:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:Refresh(index) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + grid:OnClickGrid(index) + end +end + +function XUiPokemonMainLineBanner:StartTimer() + if self.TimeHandler then self:StopTimer() end + self.StartTime, self.EndTime = XDataCenter.PokemonManager.GetCurrActivityTime() + self.TimeHandler = XScheduleManager.ScheduleForever(function() + if XTool.UObjIsNil(self.TxtProgress) then + self:StopTimer() + return + end + local currentTime = XTime.GetServerNowTimestamp() + if currentTime > self.EndTime then + XDataCenter.PokemonManager.OnActivityEnd() + return + end + self:RefreshTimeSupplyText() + self:RefreshTimeSupplyProgress() + self:RefreshActivityTime() + end, 1000, 0) +end + +function XUiPokemonMainLineBanner:StopTimer() + if self.TimeHandler then + XScheduleManager.UnSchedule(self.TimeHandler) + self.TimeHandler = nil + end +end + +function XUiPokemonMainLineBanner:RegisterButtonEvent() + self.BtnBack.CallBack = function() + self:Close() + end + self.BtnMainUi.CallBack = function() + XLuaUiManager.RunMain() + end + self.BtnTask.CallBack = function() + XLuaUiManager.Open("UiPokemonActiveTask") + end + self.BtnCulture.CallBack = function() + XDataCenter.PokemonManager.OpenMonsterUi() + end + + self.BtnHelp.CallBack = function() + self:OnClickHelpBtn() + end + + self:RegisterClickEvent(self.BtnTreasure,function() self:OnClickTimeSupplyBtn() end) +end + +function XUiPokemonMainLineBanner:OnClickHelpBtn() + local helpId = XPokemonConfigs.GetHelpId() + if helpId > 0 then + local template = XHelpCourseConfig.GetHelpCourseTemplateById(helpId) + XUiManager.ShowHelpTip(template.Function) + end +end + +function XUiPokemonMainLineBanner:OnClickTimeSupplyBtn() + if XDataCenter.PokemonManager.CheckCanGetTimeSupply() then + XDataCenter.PokemonManager.PokemonGetTimeSupplyRewardRequest(function(rewardsList) + XUiManager.OpenUiTipReward(rewardsList) + end) + else + XUiManager.TipText("PokemonCannotGetTimeSupply") + end +end + +function XUiPokemonMainLineBanner:RefreshTimeSupplyText() + local offsetTime = XDataCenter.PokemonManager.GetTimeSupplyOffsetTime() + self.TxtProgress.text = self:ParseTime(offsetTime) + XEventManager.DispatchEvent(XEventId.EVENT_POKEMON_RED_POINT_TIME_SUPPLY) +end + +function XUiPokemonMainLineBanner:RefreshActivityTime() + local _, endTime = XDataCenter.PokemonManager.GetCurrActivityTime() + local now = XTime.GetServerNowTimestamp() + local offset = endTime - now + if offset < 0 then + offset = 0 + end + local timeStr = XUiHelper.GetTime(offset, XUiHelper.TimeFormatType.ACTIVITY) + self.TxtEndurance.text = timeStr +end + +function XUiPokemonMainLineBanner:CheckTimeSupplyRedPoint(isShow) + self.ImgRedPoint.gameObject:SetActiveEx(isShow >= 0) + + if self.TxtReward then + self.TxtReward.gameObject:SetActiveEx(isShow >= 0) + end + + if self.RImgBgIcon then + self.RImgBgIcon.gameObject:SetActiveEx(isShow < 0) + end + + if self.RImgBgIcon2 then + self.RImgBgIcon2.gameObject:SetActiveEx(isShow >= 0) + end +end + +function XUiPokemonMainLineBanner:CheckTaskRedPoint(isShow) + self.BtnTask:ShowReddot(isShow >= 0) +end + +function XUiPokemonMainLineBanner:RefreshTimeSupplyProgress() + local offsetTime = XDataCenter.PokemonManager.GetTimeSupplyOffsetTime() + self.ImgProgress.fillAmount = offsetTime / (XPokemonConfigs.GetTimeSupplyMaxCount() * XPokemonConfigs.GetTimeSupplyInterval()) +end + +function XUiPokemonMainLineBanner:ParseTime(time) + local seconds = math.floor(time % 60) + local mins = math.floor((time / 60) % 60) + local hours = math.floor(time / 3600) + return string.format("%02d:%02d:%02d", hours, mins, seconds) +end + +return XUiPokemonMainLineBanner \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPokerGuessing/XUiFubenPokerGuessing.lua b/Resources/Scripts/XUi/XUiPokerGuessing/XUiFubenPokerGuessing.lua new file mode 100644 index 00000000..1d433e38 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPokerGuessing/XUiFubenPokerGuessing.lua @@ -0,0 +1,270 @@ +local XUiFubenPokerGuessing = XLuaUiManager.Register(XLuaUi,"UiFubenPokerGuessing") + +function XUiFubenPokerGuessing:OnStart() + self.IsFirstEnter = true + self:RegisterButtonEvent() + self:InitUiView() + self:UpdateGameState() + self.BtnBig.ButtonType = CS.UiButtonType.Toggle + self.BtnSmall.ButtonType = CS.UiButtonType.Toggle + self.ItemIds = {XDataCenter.ItemManager.ItemId.PokerGuessingItemId,XDataCenter.ItemManager.ItemId.Coin} +end + +function XUiFubenPokerGuessing:OnEnable() + self:UpdateScore() + self.AssetActivityPanel:Refresh(self.ItemIds) + XRedPointManager.CheckOnce(self.OnCheckRedPoint,self,{XRedPointConditions.Types.CONDITION_POKER_GUESSING_RED}) +end + +function XUiFubenPokerGuessing:OnDisable() + +end + +function XUiFubenPokerGuessing:OnGetEvents() + return { + XEventId.EVENT_POKER_GUESSING_UPDATE_SCORE, + XEventId.EVENT_POKER_GUESSING_UPDATE_RESULT, + XEventId.EVENT_POKER_GUESSING_UPDATE_STATE, + XEventId.EVENT_POKER_GUESSING_ACTIVITY_END, + XEventId.EVENT_FINISH_TASK, + XEventId.EVENT_TASK_SYNC, + } +end + +function XUiFubenPokerGuessing:OnNotify(event, ... ) + if event == XEventId.EVENT_POKER_GUESSING_UPDATE_STATE then + self:UpdateGameState() + self:UpdateScore() + elseif event == XEventId.EVENT_POKER_GUESSING_UPDATE_RESULT then + elseif event == XEventId.EVENT_POKER_GUESSING_UPDATE_SCORE then + elseif event == XEventId.EVENT_POKER_GUESSING_ACTIVITY_END then + XUiManager.TipText("PokerGuessingActivityEnd") + XLuaUiManager.RunMain() + elseif event == XEventId.EVENT_FINISH_TASK or + event == XEventId.EVENT_TASK_SYNC then + XRedPointManager.CheckOnce(self.OnCheckRedPoint,self,{XRedPointConditions.Types.CONDITION_POKER_GUESSING_RED}) + end +end + +function XUiFubenPokerGuessing:InitUiView() + self.AssetActivityPanel = XUiPanelActivityAsset.New(self.PanelSpecialTool) + XDataCenter.ItemManager.AddCountUpdateListener(XDataCenter.ItemManager.ItemId.PokerGuessingItemId, function() + self.AssetActivityPanel:Refresh(self.ItemIds) + end, self.AssetActivityPanel) + XDataCenter.ItemManager.AddCountUpdateListener(XDataCenter.ItemManager.ItemId.Coin, function() + self.AssetActivityPanel:Refresh(self.ItemIds) + end, self.AssetActivityPanel) + --self.TxtCostItem.text = CS.XTextManager.GetText("PokerGuessingCostItemText",XDataCenter.PokerGuessingManager.GetCostItemName()) + self.TxtTitle.text = CS.XTextManager.GetText("PokerGuessingStraightWins") + self.TxtCostNum.text = XDataCenter.PokerGuessingManager.GetCostItemCount() + self.RImgCostIcon:SetRawImage(XDataCenter.PokerGuessingManager.GetCostItemIcon()) + self.BtnRecord:SetName(CS.XTextManager.GetText("PokerGuessingRecordTitle")) + self.BtnNewGame:SetName(CS.XTextManager.GetText("PokerGuessingNewGame")) + self.BtnTask:SetName(CS.XTextManager.GetText("PokerGuessingTask")) + self.BtnShop:SetName(CS.XTextManager.GetText("PokerGuessingShop")) + self:UpdateScore() +end + +function XUiFubenPokerGuessing:RegisterButtonEvent() + self.BtnMainUi.CallBack = function () XLuaUiManager.RunMain() end + self.BtnBack.CallBack = function () self:Close() end + self.BtnHelp.CallBack = function () + local content = CS.XTextManager.GetText("PokerGuessingRuleText") + XUiManager.UiFubenDialogTip(CS.XTextManager.GetText("PokerGuessingRuleTextTitle"),string.gsub(content, "\\n", "\n")) + end + self.BtnRecord.CallBack = function () + XLuaUiManager.Open("UiFubenPokerGuessingCardRecorder") + end + self.BtnBig.CallBack = function() + XDataCenter.PokerGuessingManager.GuessCompareRequest(XPokerGuessingConfig.GuessType.Greater) + self.BtnSmall:SetButtonState(CS.UiButtonState.Normal) + end + self.BtnSmall.CallBack = function() + XDataCenter.PokerGuessingManager.GuessCompareRequest(XPokerGuessingConfig.GuessType.Less) + self.BtnBig:SetButtonState(CS.UiButtonState.Normal) + end + self.BtnNewGame.CallBack = function() + XDataCenter.PokerGuessingManager.StartNewPokerGuessingRequest(function() + self:PlayNewGameAnimation() + end) + end + self.BtnShop.CallBack = function() + local skipId = XDataCenter.PokerGuessingManager.GetShopSkipId() + if skipId and skipId ~= 0 then + XFunctionManager.SkipInterface(skipId) + end + end + self.BtnTask.CallBack = function() + XLuaUiManager.Open("UiFubenPokerGuessingTask") + end +end + + +function XUiFubenPokerGuessing:UpdateGameState() + local currGameStatus = XDataCenter.PokerGuessingManager.GetCurrGameStatus() + self.RImgRightCard.gameObject:SetActiveEx(true) + if currGameStatus == XPokerGuessingConfig.GameStatus.Initialize then + self.PanelNewGame.gameObject:SetActiveEx(true) + self.PanelPlay.gameObject:SetActiveEx(false) + self.RImgLeftCard:SetRawImage(XDataCenter.PokerGuessingManager.GetBackAssetPath()) + self.RImgRightCard:SetRawImage(XDataCenter.PokerGuessingManager.GetBackAssetPath()) + self.RImgRightCard.gameObject:SetActiveEx(false) + -- if self.IsFirstEnter then self:PlayAnimationWithMask("RImgRightCard2Flip2") end + elseif currGameStatus == XPokerGuessingConfig.GameStatus.Process then + self.PanelNewGame.gameObject:SetActiveEx(false) + self.PanelPlay.gameObject:SetActiveEx(true) + self:PlayAnimation("RImgLeftCardRotate",function() XLuaUiManager.SetMask(false) end,function() XLuaUiManager.SetMask(true) end) + self.RImgLeftCard:SetRawImage(XPokerGuessingConfig.GetCardFrontAssetPath(XDataCenter.PokerGuessingManager.GetDisplayCardId())) + self.RImgRightCard:SetRawImage(XDataCenter.PokerGuessingManager.GetBackAssetPath()) + elseif currGameStatus == XPokerGuessingConfig.GameStatus.Victory + or currGameStatus == XPokerGuessingConfig.GameStatus.Failed + or currGameStatus == XPokerGuessingConfig.GameStatus.Drawn then + self.PanelNewGame.gameObject:SetActiveEx(false) + self.PanelPlay.gameObject:SetActiveEx(true) + self.RImgRightCard:SetRawImage(XPokerGuessingConfig.GetCardFrontAssetPath(XDataCenter.PokerGuessingManager.GetDisplayCardId())) + if self.IsFirstEnter then + if currGameStatus == XPokerGuessingConfig.GameStatus.Victory or currGameStatus == XPokerGuessingConfig.GameStatus.Drawn then + self:PlayAnimation("RImgLeftCardRotate",function() XLuaUiManager.SetMask(false) end,function() XLuaUiManager.SetMask(true) end) + self.RImgLeftCard:SetRawImage(XPokerGuessingConfig.GetCardFrontAssetPath(XDataCenter.PokerGuessingManager.GetDisplayCardId())) + self.RImgRightCard:SetRawImage(XDataCenter.PokerGuessingManager.GetBackAssetPath()) + self.BtnSmall:SetButtonState(CS.UiButtonState.Normal) + self.BtnBig:SetButtonState(CS.UiButtonState.Normal) + elseif currGameStatus == XPokerGuessingConfig.GameStatus.Failed then + self.PanelNewGame.gameObject:SetActiveEx(true) + self.PanelPlay.gameObject:SetActiveEx(false) + self.RImgRightCard:SetRawImage(XDataCenter.PokerGuessingManager.GetBackAssetPath()) + self.RImgLeftCard:SetRawImage(XDataCenter.PokerGuessingManager.GetBackAssetPath()) + self.RImgRightCard.gameObject:SetActiveEx(false) + --self:PlayAnimationWithMask("RImgRightCard2Flip2") + end + else + self:ShowResultPanel(currGameStatus) + self:PlayShowResultAnimation(currGameStatus == XPokerGuessingConfig.GameStatus.Victory) + self:PlayAnimation("RImgRightCardRotate",function() + XLuaUiManager.SetMask(false) + if currGameStatus == XPokerGuessingConfig.GameStatus.Victory or currGameStatus == XPokerGuessingConfig.GameStatus.Drawn then + self:PlaySuccessAnimation() + else + self:PlayFailedAnimation() + end + end,function() XLuaUiManager.SetMask(true) end) + end + elseif currGameStatus == XPokerGuessingConfig.GameStatus.ScoreOutRange then + XUiManager.TipText("PokerGuessingScoreOutRange") + XDataCenter.PokerGuessingManager.IsContinueGuessRequest(false) + elseif currGameStatus == XPokerGuessingConfig.GameStatus.LibraryEmpty then + self.RImgRightCard:SetRawImage(XPokerGuessingConfig.GetCardFrontAssetPath(XDataCenter.PokerGuessingManager.GetDisplayCardId())) + local result = XDataCenter.PokerGuessingManager.GetResult() + self:ShowResultPanel(result) + self:PlayShowResultAnimation(currGameStatus == XPokerGuessingConfig.GameStatus.Victory) + self:PlayAnimationWithMask("RImgRightCardRotate",function() + XUiManager.TipText("PokerGuessingEmptyLibrayText") + self:PlaySuccessAnimation() + XDataCenter.PokerGuessingManager.IsContinueGuessRequest(false) + --self:PlayLibraryEmptyAnimation() + end) + end + self.IsFirstEnter = false + self.RImgCostIcon.gameObject:SetActiveEx(not XDataCenter.PokerGuessingManager.GetIsEnterCost()) + self.TxtCostNum.gameObject:SetActiveEx(not XDataCenter.PokerGuessingManager.GetIsEnterCost()) +end + +function XUiFubenPokerGuessing:UpdateScore() + self.TxtScore.text = XDataCenter.PokerGuessingManager.GetCurrentScore() +end + +function XUiFubenPokerGuessing:ShowResultPanel(gameStatus) + if gameStatus == XPokerGuessingConfig.GameStatus.Victory then + self.TxtResult1.text = CS.XTextManager.GetText("PokerGuessingVictory") + self.TxtResult2.text = CS.XTextManager.GetText("PokerGuessingVictoryEng") + elseif gameStatus == XPokerGuessingConfig.GameStatus.Failed then + self.TxtResult1.text = CS.XTextManager.GetText("PokerGuessingFailed") + self.TxtResult2.text = CS.XTextManager.GetText("PokerGuessingFailedEng") + elseif gameStatus == XPokerGuessingConfig.GameStatus.Drawn then + self.TxtResult1.text = CS.XTextManager.GetText("PokerGuessingDraw") + self.TxtResult2.text = CS.XTextManager.GetText("PokerGuessingDrawEng") + end +end + +function XUiFubenPokerGuessing:PlayNewGameAnimation() + XLuaUiManager.SetMask(true) + self:PlayAnimation("PanelPlayEnable") + self:PlayAnimation("PanelNewGameDisable") + self:PlayAnimation("RImgLeftCardRotate") + self:PlayAnimation("RImgRightCard2Flip",function() + XLuaUiManager.SetMask(false) + end) +end + +function XUiFubenPokerGuessing:PlayShowResultAnimation(isWin) + local aniName = isWin and "PanelTipsVictoryEnable" or "PanelTipsLoseEnable" + self.Victory.gameObject:SetActiveEx(isWin) + self.Lose.gameObject:SetActiveEx(not isWin) + self.PanelTips.gameObject:SetActiveEx(true) + self:PlayAnimation(aniName,function() + self:PlayAnimation("PanelTipsDisable",function() + self.PanelTips.gameObject:SetActiveEx(false) + end) + end) +end + +function XUiFubenPokerGuessing:PlaySuccessAnimation() + XLuaUiManager.SetMask(true) + local originPosition = self.RImgRightCard.transform.position + XUiHelper.DoWorldMove(self.RImgRightCard.transform,self.RImgLeftCard.transform.position,0.5,XUiHelper.EaseType.Linear,function() + if XTool.UObjIsNil(self.RImgRightCard) then + XLuaUiManager.SetMask(false) + return + end + self.RImgLeftCard:SetRawImage(XPokerGuessingConfig.GetCardFrontAssetPath(XDataCenter.PokerGuessingManager.GetDisplayCardId())) + self.RImgRightCard.transform:GetComponent("CanvasGroup").alpha = 0 + self.RImgRightCard.transform.position = originPosition + self:PlayAnimation("RImgRightCard2Flip",function() + XLuaUiManager.SetMask(false) + self.BtnSmall:SetButtonState(CS.UiButtonState.Normal) + self.BtnBig:SetButtonState(CS.UiButtonState.Normal) + end) + end) +end + +function XUiFubenPokerGuessing:PlayFailedAnimation() + self.PanelNewGame.gameObject:SetActiveEx(true) + self.PanelPlay.gameObject:SetActiveEx(false) + self:PlayAnimation("PanelNewGameEnable") + self:PlayAnimation("PanelPlayDisable") + self:PlayAnimation("RImgLeftCardRotate2") + self:PlayAnimation("RImgRightCardRotate2",function() + self:PlayAnimation("RImgRightCard2Flip2",function() + XLuaUiManager.SetMask(false) + if XTool.UObjIsNil(self.RImgRightCard) then + return + end + self.BtnSmall:SetButtonState(CS.UiButtonState.Normal) + self.BtnBig:SetButtonState(CS.UiButtonState.Normal) + end) + end,function() XLuaUiManager.SetMask(true) end) +end + +function XUiFubenPokerGuessing:PlayLibraryEmptyAnimation() + self.PanelNewGame.gameObject:SetActiveEx(true) + self.PanelPlay.gameObject:SetActiveEx(false) + self:PlayAnimation("PanelNewGameEnable") + self:PlayAnimation("PanelPlayDisable") + self:PlayAnimation("RImgLeftCardRotate2") + self:PlayAnimation("RImgRightCardRotate2",function() + self:PlayAnimation("RImgRightCard2Flip2",function() + XLuaUiManager.SetMask(false) + if XTool.UObjIsNil(self.RImgRightCard) then + return + end + self.BtnSmall:SetButtonState(CS.UiButtonState.Normal) + self.BtnBig:SetButtonState(CS.UiButtonState.Normal) + end) + end,function() XLuaUiManager.SetMask(true) end) +end + +function XUiFubenPokerGuessing:OnCheckRedPoint(count) + self.BtnTask:ShowReddot(count >= 0) +end + +return XUiFubenPokerGuessing \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPokerGuessing/XUiFubenPokerGuessingCardRecorder.lua b/Resources/Scripts/XUi/XUiPokerGuessing/XUiFubenPokerGuessingCardRecorder.lua new file mode 100644 index 00000000..be047f0d --- /dev/null +++ b/Resources/Scripts/XUi/XUiPokerGuessing/XUiFubenPokerGuessingCardRecorder.lua @@ -0,0 +1,56 @@ +local XUiFubenPokerGuessingCardRecorder = XLuaUiManager.Register(XLuaUi,"UiFubenPokerGuessingCardRecorder") + +function XUiFubenPokerGuessingCardRecorder:OnStart() + self.GridList = {} + self.PanelName.text = CS.XTextManager.GetText("PokerGuessingRecordTitle") + self.PanelTitle.text = CS.XTextManager.GetText("PokerGuessingRecordTitle2") + self.BtnTanchuangClose.CallBack = function() self:Close() end + self.BtnClose.CallBack = function() self:Close() end + self:InitButtonGroup() +end + +function XUiFubenPokerGuessingCardRecorder:InitButtonGroup() + self.TabBtnGroup = {} + local template = XPokerGuessingConfig.GetButtonGroupConfig() + for id, config in pairs(template) do + ---@type UnityEngine.GameObject + local obj = CS.UnityEngine.GameObject.Instantiate(self.BtnTab, self.PanelTabTc) + obj.gameObject:SetActiveEx(true) + local btn = obj.gameObject:GetComponent("XUiButton") + btn:SetName(config.Name) + btn.CallBack = function() + self:RefreshPanelGrid(id) + end + table.insert(self.TabBtnGroup,btn) + end + self.ButtonGroup:Init(self.TabBtnGroup,function(index) + self:PlayAnimation("QieHuan") + self:RefreshPanelGrid(index) + end) + self.ButtonGroup:SelectIndex(1) +end + +function XUiFubenPokerGuessingCardRecorder:RefreshPanelGrid(type) + local cardList = XPokerGuessingConfig.GetCardListByType(type, XDataCenter.PokerGuessingManager.GetPokerGroup()) + for i = 1, #cardList do + local grid = self.GridList[i] + if not grid then + ---@type UnityEngine.GameObject + local obj = CS.UnityEngine.GameObject.Instantiate(self.GridCard,self.PanelCardParent) + obj.gameObject:SetActiveEx(true) + grid = obj.gameObject:GetComponent("RawImage") + table.insert(self.GridList, grid) + end + grid.gameObject:SetActiveEx(true) + if XDataCenter.PokerGuessingManager.IsInRecordCardDic(cardList[i].Id) then + grid:SetRawImage(cardList[i].FrontImg) + else + grid:SetRawImage(XDataCenter.PokerGuessingManager.GetBackAssetPath()) + end + end + for i = #cardList + 1, #self.GridList do + self.GridList[i].gameObject:SetActiveEx(false) + end +end + +return XUiFubenPokerGuessingCardRecorder \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPokerGuessing/XUiFubenPokerGuessingTask.lua b/Resources/Scripts/XUi/XUiPokerGuessing/XUiFubenPokerGuessingTask.lua new file mode 100644 index 00000000..f786ed35 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPokerGuessing/XUiFubenPokerGuessingTask.lua @@ -0,0 +1,67 @@ +local XUiFubenPokerGuessingTask = XLuaUiManager.Register(XLuaUi, "UiFubenPokerGuessingTask") + +function XUiFubenPokerGuessingTask:OnStart() + + + self.PanelAsset = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self.TxtTime.text = "" + self:InitDynamicTable() + self:RegisterButtonClick() + self:Refresh() +end + +function XUiFubenPokerGuessingTask:OnEnable() + self:Refresh() +end + +function XUiFubenPokerGuessingTask:OnGetEvents() + return { + XEventId.EVENT_FINISH_TASK, + XEventId.EVENT_TASK_SYNC + } +end + +function XUiFubenPokerGuessingTask:OnNotify(event, ...) + if event == XEventId.EVENT_FINISH_TASK or event == XEventId.EVENT_TASK_SYNC then + self:Refresh() + end +end + +function XUiFubenPokerGuessingTask:RegisterButtonClick() + self.BtnBack.CallBack = function() + self:OnClickBackBtn() + end + + self.BtnMainUi.CallBack = function() + self:OnClickMainBtn() + end +end + +function XUiFubenPokerGuessingTask:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.SViewTask.gameObject) + self.DynamicTable:SetProxy(XDynamicGridTask, self) + self.DynamicTable:SetDelegate(self) +end + +function XUiFubenPokerGuessingTask:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:ResetData(self.TaskList[index]) + end +end + +function XUiFubenPokerGuessingTask:Refresh() + self.TaskList = XDataCenter.TaskManager.GetPokerGuessingTaskList() + self.DynamicTable:SetDataSource(self.TaskList) + self.DynamicTable:ReloadDataSync() +end + +function XUiFubenPokerGuessingTask:OnClickBackBtn() + self:Close() +end + +function XUiFubenPokerGuessingTask:OnClickMainBtn() + XLuaUiManager.RunMain() +end + + +return XUiFubenPokerGuessingTask \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPokerGuessing/XUiFubenPokerGuessingTips.lua b/Resources/Scripts/XUi/XUiPokerGuessing/XUiFubenPokerGuessingTips.lua new file mode 100644 index 00000000..54600fd6 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPokerGuessing/XUiFubenPokerGuessingTips.lua @@ -0,0 +1,65 @@ +local XUiFubenPokerGuessingTips = XLuaUiManager.Register(XLuaUi,"UiFubenPokerGuessingTips") + +function XUiFubenPokerGuessingTips:OnStart() + self:RegisterButtonEvent() + self:Refresh() +end + +function XUiFubenPokerGuessingTips:RegisterButtonEvent() + self.BtnEnd.CallBack = function() self:OnClickBtnEnd() end + self.BtnContinue.CallBack = function() self:OnClickBtnContinue() end + self.BtnNo.CallBack = function() self:OnClickBtnNo() end + self.BtnYes.CallBack = function() self:OnClickBtnYes() end +end + +function XUiFubenPokerGuessingTips:Refresh() + local currStatus = XDataCenter.PokerGuessingManager.GetCurrGameStatus() + if currStatus == XPokerGuessingConfig.GameStatus.Victory then + self.PanelNormal.gameObject:SetActiveEx(true) + self.PanelEnd.gameObject:SetActiveEx(false) + self.TxtTitle1.text = CS.XTextManager.GetText("PokerGuessingVictory") + self.TxtTitle2.text = CS.XTextManager.GetText("PokerGuessingVictoryEng") + elseif currStatus == XPokerGuessingConfig.GameStatus.Failed then + self.PanelNormal.gameObject:SetActiveEx(true) + self.PanelEnd.gameObject:SetActiveEx(false) + self.TxtTitle1.text = CS.XTextManager.GetText("PokerGuessingFailed") + self.TxtTitle2.text = CS.XTextManager.GetText("PokerGuessingFailedEng") + elseif currStatus == XPokerGuessingConfig.GameStatus.VictoryAndLibraryEmpty then + self.PanelNormal.gameObject:SetActiveEx(false) + self.PanelEnd.gameObject:SetActiveEx(true) + self.TxtTitle1.text = CS.XTextManager.GetText("PokerGuessingVictory") + self.TxtTitle2.text = CS.XTextManager.GetText("PokerGuessingVictoryEng") + end + self:RefreshPanel() +end + +function XUiFubenPokerGuessingTips:RefreshPanel() + self.TxtLeftScore.text = XDataCenter.PokerGuessingManager.GetOldScore() + self.TxtRightScore.text = XDataCenter.PokerGuessingManager.GetCurrentScore() + self.TxtEndLeftScore.text = XDataCenter.PokerGuessingManager.GetOldScore() + self.TxtEndRightScore.text = XDataCenter.PokerGuessingManager.GetCurrentScore() + self.Prompt.text = CS.XTextManager.GetText("PokerGuessingEmptyLibrayText") +end + +function XUiFubenPokerGuessingTips:OnClickBtnEnd() + XDataCenter.PokerGuessingManager.IsContinueGuessRequest(false) + self:Close() +end + +function XUiFubenPokerGuessingTips:OnClickBtnContinue() + XDataCenter.PokerGuessingManager.IsContinueGuessRequest(true) + self:Close() +end + +function XUiFubenPokerGuessingTips:OnClickBtnNo() + XDataCenter.PokerGuessingManager.IsContinueGuessRequest(false) + self:Close() +end + +function XUiFubenPokerGuessingTips:OnClickBtnYes() + XDataCenter.PokerGuessingManager.IsContinueGuessRequest(true) + self:Close() +end + + +return XUiFubenPokerGuessingTips diff --git a/Resources/Scripts/XUi/XUiPrequel/XUiGridChallengeItem.lua b/Resources/Scripts/XUi/XUiPrequel/XUiGridChallengeItem.lua new file mode 100644 index 00000000..d5562217 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPrequel/XUiGridChallengeItem.lua @@ -0,0 +1,137 @@ +XUiGridChallengeItem = XClass(nil, "XUiGridChallengeItem") + +function XUiGridChallengeItem:Ctor(ui, rootUi, index, clickCb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self.Index = index + self.ClickCb = clickCb + self:InitAutoScript() + self.PanelAutoFight.gameObject:SetActive(true) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiGridChallengeItem:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiGridChallengeItem:AutoInitUi() + self.PanelActive = XUiHelper.TryGetComponent(self.Transform, "PanelActive", nil) + self.RImgChallengeIcon = XUiHelper.TryGetComponent(self.Transform, "PanelActive/RImgChallengeIcon", "RawImage") + self.TxtTitle = XUiHelper.TryGetComponent(self.Transform, "PanelActive/TxtTitle", "Text") + self.PanelLock = XUiHelper.TryGetComponent(self.Transform, "PanelLock", nil) + self.TxtLockDesc = XUiHelper.TryGetComponent(self.Transform, "PanelLock/TxtLockDesc", "Text") + self.BtnClickMask = XUiHelper.TryGetComponent(self.Transform, "BtnClickMask", "Button") + self.TxtLeftTimes = XUiHelper.TryGetComponent(self.Transform, "TxtLeftTimes", "Text") + self.PanelAutoFight = XUiHelper.TryGetComponent(self.Transform, "PanelAutoFight", nil) + self.TxtCountdown = XUiHelper.TryGetComponent(self.Transform, "PanelAutoFight/TxtCountdown", "Text") +end + +function XUiGridChallengeItem:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiGridChallengeItem:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiGridChallengeItem:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiGridChallengeItem:AutoAddListener() + self:RegisterClickEvent(self.BtnClickMask, self.OnBtnClickMaskClick) +end +-- auto + +function XUiGridChallengeItem:OnBtnClickMaskClick() + if self.ChallengeStage then + local stageId = self.ChallengeStage.ChallengeStage + -- local isLock = self:IsChallengeStageLock(stageId) + -- if isLock then + -- self.RootUi:Switch2UnlockChallengeStage(self.ChallengeStage) + -- else + -- end + --isLock=false + self.RootUi:OpenOneChildUi("UiPrequelLineDetail") + self.RootUi:FindChildUiObj("UiPrequelLineDetail"):Refresh(stageId) + self.RootUi:SetPanelAssetActive(false) + + if self.ClickCb then + self.ClickCb(self.Index) + end + end +end + +function XUiGridChallengeItem:UpdateChallengeGridInfo(challengeStage) + self.ChallengeStage = challengeStage + local stageId = challengeStage.ChallengeStage + -- local isLock = self:IsChallengeStageLock(stageId) + self.PanelLock.gameObject:SetActive(false) + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + self.TxtTitle.text = stageCfg.Name + self.RImgChallengeIcon:SetRawImage(stageCfg.Icon) + + self:UpdateChallengeTimes(stageId) + + self:UpdateAutoFightStatus() +end + +function XUiGridChallengeItem:UpdateChallengeTimes(stageId) + -- local isLock = self:IsChallengeStageLock(stageId) + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + local maxChallengeNums = stageCfg.MaxChallengeNums or 0 + + -- if isLock then + -- self.TxtLeftTimes.text = "" + -- else + -- end + --isLock == false + local csInfo = XDataCenter.PrequelManager.GetUnlockChallengeStagesByStageId(stageId) + if csInfo then + local leftTimes = maxChallengeNums - csInfo.Count + self.TxtLeftTimes.text = CS.XTextManager.GetText("PrequelChapterTimes", leftTimes) + else + self.TxtLeftTimes.text = CS.XTextManager.GetText("PrequelChapterTimes", maxChallengeNums) + end +end + +function XUiGridChallengeItem:UpdateAutoFightStatus() + if not self.ChallengeStage then return end + local stageId = self.ChallengeStage.ChallengeStage + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + + if self.PanelAutoFight then + self.PanelAutoFight.localScale = CS.UnityEngine.Vector3.zero + end + + if stageCfg.AutoFightId > 0 then + self.AutoFightRecord = XDataCenter.AutoFightManager.GetRecordByStageId(stageId) + if self.AutoFightRecord and self.PanelAutoFight then + local now = XTime.GetServerNowTimestamp() + local showTimes = self.AutoFightRecord.CompleteTime - now + self.PanelAutoFight.localScale = CS.UnityEngine.Vector3.one + if showTimes == 0 then + XEventManager.DispatchEvent(XEventId.EVENT_AUTO_FIGHT_COMPLETE, stageId) + end + if showTimes < 0 then + showTimes = 0 + end + self.TxtCountdown.text = XUiHelper.GetTime(showTimes) + self:UpdateChallengeTimes(stageId) + end + end +end + +function XUiGridChallengeItem:IsChallengeStageLock(stageId) + return XDataCenter.PrequelManager.GetUnlockChallengeStagesByStageId(stageId) == nil +end + +return XUiGridChallengeItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPrequel/XUiGridChallengeTab.lua b/Resources/Scripts/XUi/XUiPrequel/XUiGridChallengeTab.lua new file mode 100644 index 00000000..b53bb8b8 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPrequel/XUiGridChallengeTab.lua @@ -0,0 +1,59 @@ +XUiGridChallengeTab = XClass(nil, "XUiGridChallengeTab") + +function XUiGridChallengeTab:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self:InitAutoScript() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiGridChallengeTab:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiGridChallengeTab:AutoInitUi() + self.PanelTabUnSelect = self.Transform:Find("PanelTabUnSelect") + self.ImgUnSelect = self.Transform:Find("PanelTabUnSelect/ImgUnSelect"):GetComponent("Image") + self.TxtUnSelectTitle = self.Transform:Find("PanelTabUnSelect/TxtUnSelectTitle"):GetComponent("Text") + self.PanelTabSelect = self.Transform:Find("PanelTabSelect") + self.ImgSelect = self.Transform:Find("PanelTabSelect/ImgSelect"):GetComponent("Image") + self.TxtSelectTitle = self.Transform:Find("PanelTabSelect/TxtSelectTitle"):GetComponent("Text") + self.PanelTabLock = self.Transform:Find("PanelTabLock") + self.ImgUnSelect = self.Transform:Find("PanelTabLock/ImgUnSelect"):GetComponent("Image") + self.ImgLock = self.Transform:Find("PanelTabLock/ImgLock"):GetComponent("Image") + self.TxtLockTitleA = self.Transform:Find("PanelTabLock/TxtLockTitle"):GetComponent("Text") + self.ImgNewCheckPoint = self.Transform:Find("ImgNewCheckPoint"):GetComponent("Image") +end + +function XUiGridChallengeTab:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiGridChallengeTab:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiGridChallengeTab:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiGridChallengeTab:AutoAddListener() +end +-- auto + +function XUiGridChallengeTab:UpdateDefaultViews() + self.PanelTabUnSelect.gameObject:SetActive(false) + self.PanelTabSelect.gameObject:SetActive(true) + self.PanelTabLock.gameObject:SetActive(false) + self.ImgNewCheckPoint.gameObject:SetActive(false) + self.TxtSelectTitle.text = CS.XTextManager.GetText("PrequelChallangeTab") +end + +return XUiGridChallengeTab diff --git a/Resources/Scripts/XUi/XUiPrequel/XUiGridPrequelCheckPointReward.lua b/Resources/Scripts/XUi/XUiPrequel/XUiGridPrequelCheckPointReward.lua new file mode 100644 index 00000000..4a408ec1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPrequel/XUiGridPrequelCheckPointReward.lua @@ -0,0 +1,126 @@ +XUiGridPrequelCheckPointReward = XClass(nil, "XUiGridPrequelCheckPointReward") + +function XUiGridPrequelCheckPointReward:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self:InitAutoScript() + self.RewardList = {} + self.GridCommon.gameObject:SetActive(false) +end + +function XUiGridPrequelCheckPointReward:Init(rootUi, parent) + self.RootUi = rootUi + self.Parent = parent +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiGridPrequelCheckPointReward:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiGridPrequelCheckPointReward:AutoInitUi() + self.TxtOrder = self.Transform:Find("TxtOrder"):GetComponent("Text") + self.TxtTaskName = self.Transform:Find("TxtTaskName"):GetComponent("Text") + self.PanelRewardContent = self.Transform:Find("PanelRewardContent") + self.GridCommon = self.Transform:Find("PanelRewardContent/GridCommon") + self.RImgIcon = self.Transform:Find("PanelRewardContent/GridCommon/RImgIcon"):GetComponent("RawImage") + self.ImgQuality = self.Transform:Find("PanelRewardContent/GridCommon/ImgQuality"):GetComponent("Image") + self.BtnClick = self.Transform:Find("PanelRewardContent/GridCommon/BtnClick"):GetComponent("Button") + self.TxtCount = self.Transform:Find("PanelRewardContent/GridCommon/TxtCount"):GetComponent("Text") + self.BtnFinish = self.Transform:Find("BtnFinish"):GetComponent("Button") + self.ImgAlreadyFinish = self.Transform:Find("ImgAlreadyFinish"):GetComponent("Image") + self.ImgUnFinish = self.Transform:Find("ImgUnFinish"):GetComponent("Image") +end + +function XUiGridPrequelCheckPointReward:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiGridPrequelCheckPointReward:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiGridPrequelCheckPointReward:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiGridPrequelCheckPointReward:AutoAddListener() + self:RegisterClickEvent(self.BtnClick, self.OnBtnClickClick) + self:RegisterClickEvent(self.BtnFinish, self.OnBtnFinishClick) +end +-- auto + +function XUiGridPrequelCheckPointReward:OnBtnClickClick() + +end + +function XUiGridPrequelCheckPointReward:OnBtnFinishClick() + if self.StageId then + local stageInfo = XDataCenter.FubenManager.GetStageInfo(self.StageId) + local rewardedStages = XDataCenter.PrequelManager.GetRewardedStages() + if stageInfo.Passed and rewardedStages and (not rewardedStages[self.StageId]) then + XDataCenter.PrequelManager.ReceivePrequelRewardRequest(self.StageId, function() + self.Parent:RefreshReward() + self.RootUi:RefreshRegionalReward() + end) + end + end +end + +function XUiGridPrequelCheckPointReward:OnRefreshDatas(data, chapterId) + self.StageId = data + self.ChapterId = chapterId + local stageCfg = XDataCenter.FubenManager.GetStageCfg(self.StageId) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(self.StageId) + local chapterInfo = XPrequelConfigs.GetPrequelChapterById(chapterId) + self.TxtOrder.text = chapterInfo.ChapterName + self.TxtTaskName.text = stageCfg.Name + + local rewardId = stageCfg.FirstRewardShow + local rewards = XRewardManager.GetRewardList(rewardId) + + if not rewards then return end + local rewardCount = #rewards + for i=1, rewardCount do + local xcommon = self.RewardList[i] + if not xcommon then + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommon.gameObject) + ui.transform:SetParent(self.PanelRewardContent, false) + ui.gameObject:SetActive(true) + xcommon = XUiGridCommon.New(self.RootUi, ui) + table.insert(self.RewardList, i, xcommon ) + end + end + for i=1, #self.RewardList do + self.RewardList[i].GameObject:SetActive(i <= rewardCount) + if i <= rewardCount then + self.RewardList[i]:Refresh(rewards[i]) + end + end + + local rewardedStages = XDataCenter.PrequelManager.GetRewardedStages() + if stageInfo.Passed then + if rewardedStages and rewardedStages[self.StageId] then--领过了 + self:ChangeCollectStatus(false, true, false) + else--没有领取 + self:ChangeCollectStatus(true, false, false) + end + else + self:ChangeCollectStatus(false, false, true) + end +end + +function XUiGridPrequelCheckPointReward:ChangeCollectStatus(finish, alreadyFinish, unfinish) + self.BtnFinish.gameObject:SetActive(finish) + self.ImgAlreadyFinish.gameObject:SetActive(alreadyFinish) + self.ImgUnFinish.gameObject:SetActive(unfinish) +end + +return XUiGridPrequelCheckPointReward \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPrequel/XUiGridPrequelPlotTab.lua b/Resources/Scripts/XUi/XUiPrequel/XUiGridPrequelPlotTab.lua new file mode 100644 index 00000000..ce1c13d4 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPrequel/XUiGridPrequelPlotTab.lua @@ -0,0 +1,91 @@ +XUiGridPrequelPlotTab = XClass(nil, "XUiGridPrequelPlotTab") + +function XUiGridPrequelPlotTab:Ctor(ui, rootUi, index) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self.Index = index + self:InitAutoScript() + self.TogClick = self.Transform:GetComponent("Toggle") +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiGridPrequelPlotTab:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiGridPrequelPlotTab:AutoInitUi() + self.PanelTabUnSelect = self.Transform:Find("PanelTabUnSelect") + self.ImgUnSelect = self.Transform:Find("PanelTabUnSelect/ImgUnSelect"):GetComponent("Image") + self.TxtUnSelectTitle = self.Transform:Find("PanelTabUnSelect/TxtUnSelectTitle"):GetComponent("Text") + self.PanelTabSelect = self.Transform:Find("PanelTabSelect") + self.ImgSelect = self.Transform:Find("PanelTabSelect/ImgSelect"):GetComponent("Image") + self.TxtSelectTitle = self.Transform:Find("PanelTabSelect/TxtSelectTitle"):GetComponent("Text") + self.PanelTabLock = self.Transform:Find("PanelTabLock") + self.ImgUnSelectA = self.Transform:Find("PanelTabLock/ImgUnSelect"):GetComponent("Image") + self.ImgLock = self.Transform:Find("PanelTabLock/ImgLock"):GetComponent("Image") + self.TxtLockTitle = self.Transform:Find("PanelTabLock/TxtLockTitle"):GetComponent("Text") + self.ImgNewCheckPoint = self.Transform:Find("ImgNewCheckPoint"):GetComponent("Image") +end + +function XUiGridPrequelPlotTab:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiGridPrequelPlotTab:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiGridPrequelPlotTab:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiGridPrequelPlotTab:AutoAddListener() +end +-- auto + +function XUiGridPrequelPlotTab:RegisterClick(clickEvent, clear) + self:RegisterClickEvent(self.TogClick, function() clickEvent(self.Index) end, clear) +end + +function XUiGridPrequelPlotTab:UpdateStates(chapterId) + self.ChapterId = chapterId + local chapterData = XPrequelConfigs.GetPrequelChapterById(chapterId) + self.TxtUnSelectTitle.text = chapterData.ChapterName + self.TxtSelectTitle.text = chapterData.ChapterName + self.TxtLockTitle.text = chapterData.ChapterName + + -- 处理锁住+活动的情况 + self.PanelTabLock.gameObject:SetActive(false) + self.ImgNewCheckPoint.gameObject:SetActive(false) + + -- 锁住,优先级较低 + if XDataCenter.PrequelManager.GetChapterLockStatus(chapterId) then + self.PanelTabLock.gameObject:SetActive(true) + self.ImgNewCheckPoint.gameObject:SetActive(false) + end + + -- 活动 + if XDataCenter.PrequelManager.IsChapterInActivity(chapterId) then + self.PanelTabLock.gameObject:SetActive(false) + self.ImgNewCheckPoint.gameObject:SetActive(true) + end +end + +function XUiGridPrequelPlotTab:OnSelected(isSelect) + self.PanelTabUnSelect.gameObject:SetActive(not isSelect) + self.PanelTabSelect.gameObject:SetActive(isSelect) +end + +function XUiGridPrequelPlotTab:OnLock() + +end + +return XUiGridPrequelPlotTab diff --git a/Resources/Scripts/XUi/XUiPrequel/XUiPanelChallengeChapter.lua b/Resources/Scripts/XUi/XUiPrequel/XUiPanelChallengeChapter.lua new file mode 100644 index 00000000..ad3315a7 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPrequel/XUiPanelChallengeChapter.lua @@ -0,0 +1,138 @@ +XUiPanelChallengeChapter = XClass(nil, "XUiPanelChallengeChapter") + +local XUguiDragProxy = CS.XUguiDragProxy + +function XUiPanelChallengeChapter:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self:InitAutoScript() + self.BoundSizeFitter = self.UiContent:GetComponent("XBoundSizeFitter") + self.GridChallengeList = {} +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelChallengeChapter:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiPanelChallengeChapter:AutoInitUi() + self.GridChallengeItem = self.Transform:Find("GridChallengeItem") + self.SViewChallenge = self.Transform:Find("SViewChallange"):GetComponent("ScrollRect") + self.UiContent = self.Transform:Find("SViewChallange/Viewport/UiContent") + local dragProxy = self.SViewChallenge:GetComponent(typeof(XUguiDragProxy)) + if not dragProxy then + dragProxy = self.SViewChallenge.gameObject:AddComponent(typeof(XUguiDragProxy)) + end + dragProxy:RegisterHandler(handler(self, self.OnDragProxy)) +end + +function XUiPanelChallengeChapter:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelChallengeChapter:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelChallengeChapter:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelChallengeChapter:AutoAddListener() +end +-- auto + + +function XUiPanelChallengeChapter:UpdateChallengeGrid(data) + self.ChallengeStageDataList = data + local index = 0 + for i=1, #self.ChallengeStageDataList do + local grid = self.GridChallengeList[i] + if not grid then + local cell = self.UiContent.transform:Find(string.format("GridChallengeItem%d", i)) + if not cell then + XLog.Error("XUiPanelChallengeChapter:UpdateChallengeGrid error: prefab not found a child name : " .. string.format("GridChallengeItem%d", i)) + end + grid = XUiGridChallengeItem.New(cell, self.RootUi, i, function(idx) self:OnChallengeItemClick(idx) end) + self.GridChallengeList[i] = grid + end + + grid:UpdateChallengeGridInfo(self.ChallengeStageDataList[i]) + grid.GameObject:SetActive(true) + index = i + end + + index = index + 1 + local hideGrid = self.UiContent.transform:Find(string.format("GridChallengeItem%d", index)) + while hideGrid do + hideGrid.gameObject:SetActive(false) + index = index + 1 + hideGrid = self.UiContent.transform:Find(string.format("GridChallengeItem%d", index)) + end + + -- [跳到最后开放的位置] + if self.SViewChallenge then + self.SViewChallenge.horizontalNormalizedPosition = 1 + end +end + +function XUiPanelChallengeChapter:OnChallengeItemClick(i) + local grid = self.GridChallengeList[i] + if not grid then return end + self:PlayScrollViewMove(grid) +end + +function XUiPanelChallengeChapter:OnPrequelDetailClosed() + self.SViewChallenge.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Elastic +end + +function XUiPanelChallengeChapter:PlayScrollViewMove(grid) + -- 跟主线一样的动画 + self.SViewChallenge.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Unrestricted + local gridRect = grid.GameObject:GetComponent("RectTransform") + local diffX = gridRect.localPosition.x + self.UiContent.localPosition.x + if diffX < XDataCenter.FubenMainLineManager.UiGridChapterMoveMinX or diffX > XDataCenter.FubenMainLineManager.UiGridChapterMoveMaxX then + local tarPosX = XDataCenter.FubenMainLineManager.UiGridChapterMoveTargetX - gridRect.localPosition.x + local tarPos = self.UiContent.localPosition + tarPos.x = tarPosX + XLuaUiManager.SetMask(true) + XUiHelper.DoMove(self.UiContent, tarPos, XDataCenter.FubenMainLineManager.UiGridChapterMoveDuration, XUiHelper.EaseType.Sin, function() + XLuaUiManager.SetMask(false) + end) + end +end + +function XUiPanelChallengeChapter:UpdateItems() + for i=1, #self.ChallengeStageDataList do + if self.GridChallengeList[i] then + self.GridChallengeList[i]:UpdateAutoFightStatus() + end + end +end + + +function XUiPanelChallengeChapter:Show() + if self.GameObject.activeSelf == true then return end + self.GameObject:SetActiveEx(true) +end + +function XUiPanelChallengeChapter:Hide() + if self.GameObject.activeSelf == false then return end + self.GameObject:SetActiveEx(false) +end + +function XUiPanelChallengeChapter:OnDragProxy(dragType) + if dragType == 0 then + self.RootUi:OnClosePrequelDetail() + end +end + +return XUiPanelChallengeChapter diff --git a/Resources/Scripts/XUi/XUiPrequel/XUiPanelChallengeMode.lua b/Resources/Scripts/XUi/XUiPrequel/XUiPanelChallengeMode.lua new file mode 100644 index 00000000..5096f1df --- /dev/null +++ b/Resources/Scripts/XUi/XUiPrequel/XUiPanelChallengeMode.lua @@ -0,0 +1,214 @@ +XUiPanelChallengeMode = XClass(nil, "XUiPanelChallengeMode") +local ANICHALLENGEMODEBEGIN = "AniChallengeModeBegin" + +local ChallengeChapterTimer = nil +local ChallengeChapterInterval = 1000 + +function XUiPanelChallengeMode:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self:InitAutoScript() + self.ChallengeTab = XUiPanelChallengeTab.New(self.PanelChallengeTab, self.RootUi) + self.ChallengeList = {} +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelChallengeMode:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiPanelChallengeMode:AutoInitUi() + self.PanelMode = self.Transform:Find("PanelMode") + self.BtnDetailMask = self.Transform:Find("PanelMode/BtnDetailMask"):GetComponent("Button") + self.PanelPrequelStages = self.Transform:Find("PanelMode/PanelPrequelStages") + self.TxtMode = self.Transform:Find("PanelMode/PanelBt/TxtMode"):GetComponent("Text") + self.PanelLeft = self.Transform:Find("PanelMode/PanelLeft") + self.PanelChallengeTab = self.Transform:Find("PanelMode/PanelLeft/PanelChallengeTab") + self.BtnSwitch2Regional = self.Transform:Find("PanelMode/PanelBt/BtnSwitch2Regional"):GetComponent("Button") + self.PanelShop = self.Transform:Find("PanelMode/PanelShop") + self.BtnShop = self.Transform:Find("PanelMode/PanelShop/BtnShop"):GetComponent("Button") + self.PanelReset = self.Transform:Find("PanelMode/PanelReset") + self.PanelCenter = self.Transform:Find("PanelMode/PanelReset/PanelCenter") + self.TxtResetTime = self.Transform:Find("PanelMode/PanelReset/PanelCenter/TxtResetTime"):GetComponent("Text") + self.PanelOpenItem = self.Transform:Find("PanelMode/PanelOpenItem") + self.TxtTotalNum = self.Transform:Find("PanelMode/PanelOpenItem/TxtTotalNum"):GetComponent("Text") + self.RImgCostIcon = self.Transform:Find("PanelMode/PanelOpenItem/RImgCostIcon"):GetComponent("RawImage") + self.BtnActDesc = self.Transform:Find("PanelMode/BtnActDesc"):GetComponent("Button") +end + +function XUiPanelChallengeMode:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelChallengeMode:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelChallengeMode:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelChallengeMode:AutoAddListener() + self:RegisterClickEvent(self.BtnDetailMask, self.OnBtnDetailMaskClick) + self:RegisterClickEvent(self.BtnSwitch2Regional, self.OnBtnSwitch2RegionalClick) + self:RegisterClickEvent(self.BtnShop, self.OnBtnShopClick) + self:RegisterClickEvent(self.BtnActDesc, self.OnBtnActDescClick) +end +-- auto + +function XUiPanelChallengeMode:OnBtnDetailMaskClick() + self:OnClosePrequelDetail() +end + +function XUiPanelChallengeMode:OnClosePrequelDetail() + self.RootUi:OnClosePrequelDetail() +end + +function XUiPanelChallengeMode:OnBtnSwitch2RegionalClick() + self:OnClosePrequelDetail() + + local keyX = string.format("%s%d%d", "PrequelLastSwitchPanelType", XPlayer.Id, self.CurrentCover.CoverId) + local panelType = 1 + CS.UnityEngine.PlayerPrefs.SetInt(keyX, panelType) + self.RootUi:Switch2Regional(self.CurrentCover) + self:RemoveTimer() + self:RemoveChallengeTimer() +end + +function XUiPanelChallengeMode:OnBtnShopClick() + if self.CurrentCover then + if XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.ShopCommon) then + XLuaUiManager.Open("UiShop", XShopManager.ShopType.Activity) + end + end +end + +function XUiPanelChallengeMode:OnBtnActDescClick() + if self.CurrentCover then + self:OnClosePrequelDetail() + local coverInfo = XPrequelConfigs.GetPrequelCoverInfoById(self.CurrentCover.CoverId) + local description = string.gsub(coverInfo.CoverDescription, "\\n", "\n") + XUiManager.UiFubenDialogTip("", description) + end +end + +function XUiPanelChallengeMode:InitChallengeTab() + self.ChallengeTab:UpdateTabs(self.CurrentCover) +end + +function XUiPanelChallengeMode:UpdateChallengeStages() + if not self.CurrentCover then return end + for _, v in pairs(self.ChallengeList) do + v:Hide() + end + + local prefabName = self.CurrentCover.CoverVal.ChallengePrefabName + if not prefabName or prefabName == "" then + XLog.Error("XUiPanelChallengeMode:UpdateChallengeStages error : prefabName not found " .. tostring(prefabName)) + return + end + + self.ChallengeStageDatas = {} + for i=1, #self.CurrentCover.CoverVal.ChallengeStage do + table.insert(self.ChallengeStageDatas, { + CoverId = self.CurrentCover.CoverId, + ChallengeStage = self.CurrentCover.CoverVal.ChallengeStage[i], + ChallengeConsumeItem = self.CurrentCover.CoverVal.ChallengeConsumeItem[i], + ChallengeConsumeCount = self.CurrentCover.CoverVal.ChallengeConsumeCount[i], + ChallengeIndex = i, + }) + end + + local asset = self.PanelPrequelStages:LoadPrefab(prefabName) + if asset == nil or (not asset:Exist()) then + XLog.Error("当前prefab不存在:" .. tostring(prefabName)) + return + end + local grid = XUiPanelChallengeChapter.New(asset, self.RootUi) + grid.Transform:SetParent(self.PanelPrequelStages, false) + grid:UpdateChallengeGrid(self.ChallengeStageDatas) + grid:Show() + self.CurrentChallengeGrid = grid +end + +function XUiPanelChallengeMode:OnDetailClosed() + if self.CurrentChallengeGrid then + self.CurrentChallengeGrid:OnPrequelDetailClosed() + end +end + +-- [刷新挑战消耗] +function XUiPanelChallengeMode:UpdateCostItem() + local itemId = self.CurrentCover.CoverVal.ChallengeConsumeItem[1] + local itemNum = XDataCenter.ItemManager.GetCount(itemId) + self.TxtTotalNum.text = itemNum + self.RImgCostIcon:SetRawImage(XDataCenter.ItemManager.GetItemIcon(itemId)) +end + +function XUiPanelChallengeMode:OnRefresh(coverData) + self.CurrentCover = coverData + + self.RootUi:PlayAnimation(ANICHALLENGEMODEBEGIN, function() + self.RootUi:SetChallengeAnimBegin(false) + end, + function() + self.RootUi:SetChallengeAnimBegin(true) + self:InitChallengeTab() + self:UpdateChallengeStages() + self:UpdateCostItem() + self:AddTimer() + self:AddChallengeTimer() + end) + +end + +function XUiPanelChallengeMode:UpdateTimer() + self:AddTimer() +end + +function XUiPanelChallengeMode:AddTimer() + local checkpointTime = XDataCenter.PrequelManager.GetNextCheckPointTime() + local remainTime = checkpointTime - XTime.GetServerNowTimestamp() + if remainTime > 0 then + + XCountDown.CreateTimer(self.GameObject.name, remainTime) + XCountDown.BindTimer(self.GameObject, self.GameObject.name, function(v) + self.TxtResetTime.text = XUiHelper.GetTime(v, XUiHelper.TimeFormatType.SHOP) + if v == 0 then self:RemoveTimer() end + end) + end +end + +function XUiPanelChallengeMode:RemoveTimer() + XCountDown.RemoveTimer(self.GameObject.name) +end + +function XUiPanelChallengeMode:AddChallengeTimer() + self:RemoveChallengeTimer() + ChallengeChapterTimer = XScheduleManager.ScheduleForever(function() + self:UpdateChapterItems() + end, ChallengeChapterInterval) +end + +function XUiPanelChallengeMode:RemoveChallengeTimer() + if ChallengeChapterTimer then + XScheduleManager.UnSchedule(ChallengeChapterTimer) + ChallengeChapterTimer = nil + end +end + +function XUiPanelChallengeMode:UpdateChapterItems() + if self.CurrentChallengeGrid then + self.CurrentChallengeGrid:UpdateItems() + end +end + +return XUiPanelChallengeMode \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPrequel/XUiPanelChallengeTab.lua b/Resources/Scripts/XUi/XUiPrequel/XUiPanelChallengeTab.lua new file mode 100644 index 00000000..1c68d728 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPrequel/XUiPanelChallengeTab.lua @@ -0,0 +1,64 @@ +XUiPanelChallengeTab = XClass(nil, "XUiPanelChallengeTab") + +function XUiPanelChallengeTab:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self:InitAutoScript() + + self.BtnGroupList = {} + table.insert(self.BtnGroupList, self.BtnChallengeTab) + self.BtnGroup:Init(self.BtnGroupList, function() self:OnTabsClick() end) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelChallengeTab:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiPanelChallengeTab:AutoInitUi() + self.ScrollView = self.Transform:Find("ScrollView"):GetComponent("Scrollbar") + self.BtnGroup = self.Transform:Find("ScrollView/Viewport/Content"):GetComponent("XUiButtonGroup") + self.BtnChallengeTab = self.Transform:Find("ScrollView/Viewport/Content/BtnChallengeTab"):GetComponent("XUiButton") +end + +function XUiPanelChallengeTab:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelChallengeTab:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelChallengeTab:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelChallengeTab:AutoAddListener() +end +-- auto + +-- [策划需求只有一个tab] +function XUiPanelChallengeTab:UpdateTabs(coverDatas) + self.Cover = coverDatas + self.BtnChallengeTab:SetName(CS.XTextManager.GetText("PrequelChallangeTab")) + self.BtnGroup:SelectIndex(1) + if #self.BtnGroupList == 1 then + self.GameObject:SetActiveEx(false) + end +end + +function XUiPanelChallengeTab:OnTabsClick() + if not self.RootUi:IsChallengeAnimPlaying() then + self.RootUi:PlayAnimation("AniChallengeModeSwitch") + end +end + +return XUiPanelChallengeTab diff --git a/Resources/Scripts/XUi/XUiPrequel/XUiPanelCheckReward.lua b/Resources/Scripts/XUi/XUiPrequel/XUiPanelCheckReward.lua new file mode 100644 index 00000000..f4ab3e7e --- /dev/null +++ b/Resources/Scripts/XUi/XUiPrequel/XUiPanelCheckReward.lua @@ -0,0 +1,115 @@ +XUiPanelCheckReward = XClass(nil, "XUiPanelCheckReward") + +function XUiPanelCheckReward:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self:InitAutoScript() + if not self.DynamicRewardList then + self.DynamicRewardList = XDynamicTableNormal.New(self.SViewRewardList.gameObject) + self.DynamicRewardList:SetProxy(XUiGridPrequelCheckPointReward) + self.DynamicRewardList:SetDelegate(self) + end +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelCheckReward:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiPanelCheckReward:AutoInitUi() + self.BtnMask = self.Transform:Find("BtnMask"):GetComponent("Button") + self.PanelReward = self.Transform:Find("PanelReward") + self.SViewRewardList = self.Transform:Find("PanelReward/SViewRewardList"):GetComponent("ScrollRect") + self.GridPrequelCheckPointReward = self.Transform:Find("PanelReward/SViewRewardList/Viewport/GridPrequelCheckPointReward") + self.Scrollbar = self.Transform:Find("PanelReward/SViewRewardList/Scrollbar"):GetComponent("Scrollbar") + self.PanelBg = self.Transform:Find("PanelReward/PanelBg") +end + +function XUiPanelCheckReward:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelCheckReward:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelCheckReward:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelCheckReward:AutoAddListener() + self:RegisterClickEvent(self.BtnMask, self.OnBtnMaskClick) + self:RegisterClickEvent(self.SViewRewardList, self.OnSViewRewardListClick) + self:RegisterClickEvent(self.Scrollbar, self.OnScrollbarClick) +end +-- auto + +function XUiPanelCheckReward:OnSViewRewardListClick() + +end + +function XUiPanelCheckReward:OnScrollbarClick() + +end + +function XUiPanelCheckReward:OnBtnMaskClick() + self.GameObject:SetActive(false) +end + +-- [刷新奖励界面] +function XUiPanelCheckReward:UpdateRewardList(chapterId) + self.ChapterId = chapterId + self.RegionalDatas = XPrequelConfigs.GetPrequelChapterById(chapterId) + self.RewardStages = self:FilterNotRewardStage(self.RegionalDatas.StageId) + if self.DynamicRewardList then + self.DynamicRewardList:SetDataSource(self.RewardStages) + self.DynamicRewardList:ReloadDataASync() + end +end + +function XUiPanelCheckReward:RefreshReward() + if self.ChapterId then + self.RegionalDatas = XPrequelConfigs.GetPrequelChapterById(self.ChapterId) + self.RewardStages = self:FilterNotRewardStage(self.RegionalDatas.StageId) + if self.DynamicRewardList then + self.DynamicRewardList:SetDataSource(self.RewardStages) + self.DynamicRewardList:ReloadDataASync() + end + end +end + +function XUiPanelCheckReward:FilterNotRewardStage(stages) + local rewardStages = {} + local index = 1 + for _, stageId in pairs(stages or {}) do + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + if stageCfg.FirstRewardShow > 0 then + table.insert(rewardStages, index, stageId) + index = index + 1 + end + end + return rewardStages +end + +function XUiPanelCheckReward:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self.RootUi, self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.RewardStages[index] + if data ~= nil then + grid:OnRefreshDatas(data, self.ChapterId) + end + -- elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + -- 点击事件交由按钮处理 + end +end + +return XUiPanelCheckReward \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPrequel/XUiPanelEnterFightDialog.lua b/Resources/Scripts/XUi/XUiPrequel/XUiPanelEnterFightDialog.lua new file mode 100644 index 00000000..26a53f32 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPrequel/XUiPanelEnterFightDialog.lua @@ -0,0 +1,122 @@ +XUiPanelEnterFightDialog = XClass(nil, "XUiPanelEnterFightDialog") + +function XUiPanelEnterFightDialog:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self:InitAutoScript() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelEnterFightDialog:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiPanelEnterFightDialog:AutoInitUi() + self.BtnMaskB = self.Transform:Find("BtnMask"):GetComponent("Button") + self.PanelStory = self.Transform:Find("PanelStory") + self.TxtStoryName = self.Transform:Find("PanelStory/TxtStoryName"):GetComponent("Text") + self.TxtStoryDec = self.Transform:Find("PanelStory/TxtStoryDec"):GetComponent("Text") + self.RImgStory = self.Transform:Find("PanelStory/RImgStory"):GetComponent("RawImage") + self.BtnEnterStory = self.Transform:Find("PanelStory/BtnEnterStory"):GetComponent("Button") + self.PanelFight = self.Transform:Find("PanelFight") + self.TxtFightName = self.Transform:Find("PanelFight/TxtFightName"):GetComponent("Text") + self.TxtFightDec = self.Transform:Find("PanelFight/TxtFightDec"):GetComponent("Text") + self.RImgFight = self.Transform:Find("PanelFight/RImgFight"):GetComponent("RawImage") + self.BtnEnterFight = self.Transform:Find("PanelFight/BtnEnterFight"):GetComponent("Button") +end + +function XUiPanelEnterFightDialog:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelEnterFightDialog:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelEnterFightDialog:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelEnterFightDialog:AutoAddListener() + self:RegisterClickEvent(self.BtnMaskB, self.OnBtnMaskBClick) + self:RegisterClickEvent(self.BtnEnterStory, self.OnBtnEnterStoryClick) + self:RegisterClickEvent(self.BtnEnterFight, self.OnBtnEnterFightClick) +end +-- auto + +function XUiPanelEnterFightDialog:OnBtnMaskBClick() + self:OnCloseDialog() +end + +function XUiPanelEnterFightDialog:OnBtnEnterStoryClick() + if self:PreCheckChapterCondition() then return end + + self:OnCallback() +end + +function XUiPanelEnterFightDialog:OnBtnEnterFightClick() + if self:PreCheckChapterCondition() then return end + + self:OnCallback() +end + +function XUiPanelEnterFightDialog:PreCheckChapterCondition() + if self.StageId then + local chapterId = XDataCenter.PrequelManager.GetChapterIdByStageId(self.StageId) + if chapterId then + local unlockDescription = XDataCenter.PrequelManager.GetChapterUnlockDescription(chapterId) + if unlockDescription then + XUiManager.TipMsg(unlockDescription) + self:OnCloseDialog() + return true + end + end + end + return false +end + +function XUiPanelEnterFightDialog:OnShowStoryDialog(stageId, callback) + self.StageId = stageId + self.Callback = callback + self.PanelStory.gameObject:SetActive(true) + self.PanelFight.gameObject:SetActive(false) + + local stageCfg = XDataCenter.FubenManager.GetStageCfg(self.StageId) + self.TxtStoryName.text = stageCfg.Name + self.TxtStoryDec.text = stageCfg.Description + self.RImgStory:SetRawImage(stageCfg.Icon) +end + +function XUiPanelEnterFightDialog:OnShowFightDialog(stageId, callback) + self.StageId = stageId + self.Callback = callback + self.PanelFight.gameObject:SetActive(true) + self.PanelStory.gameObject:SetActive(false) + + local stageCfg = XDataCenter.FubenManager.GetStageCfg(self.StageId) + self.TxtFightName.text = stageCfg.Name + self.TxtFightDec.text = stageCfg.Description + self.RImgFight:SetRawImage(stageCfg.Icon) +end + +function XUiPanelEnterFightDialog:OnCallback() + if self.Callback then + self.Callback() + end + self:OnCloseDialog() +end + +function XUiPanelEnterFightDialog:OnCloseDialog() + self.GameObject:SetActive(false) +end + + +return XUiPanelEnterFightDialog \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPrequel/XUiPanelPlotTab.lua b/Resources/Scripts/XUi/XUiPrequel/XUiPanelPlotTab.lua new file mode 100644 index 00000000..b9414633 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPrequel/XUiPanelPlotTab.lua @@ -0,0 +1,150 @@ +XUiPanelPlotTab = XClass(nil, "XUiPanelPlotTab") + +local ANIPREQUELREGIONALSWITCH = "AniPrequelRegionalSwitch" + +function XUiPanelPlotTab:Ctor(ui, rootUi, parent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self.ParentUi = parent + self:InitAutoScript() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelPlotTab:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiPanelPlotTab:AutoInitUi() + self.ScrollView = self.Transform:Find("ScrollView"):GetComponent("Scrollbar") + self.UiContent = self.Transform:Find("ScrollView/Viewport/UiContent") + self.BtnPrequelPlotTab = self.Transform:Find("ScrollView/Viewport/UiContent/BtnPrequelPlotTab") + self.BtnPrequelGroup = self.UiContent:GetComponent("XUiButtonGroup") +end + +function XUiPanelPlotTab:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelPlotTab:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelPlotTab:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelPlotTab:AutoAddListener() +end +-- auto + +function XUiPanelPlotTab:UpdateTabs(coverDatas) + self.Cover = coverDatas + self.PrequelPlotTabs = self.PrequelPlotTabs or {} + self.CoverValues = {} + local chapterIds = self.Cover.CoverActiveChapterIds + local chapterNum = #chapterIds + --逆序排序 + local orderIndex = chapterNum + for i = 1, chapterNum do + self.CoverValues[i] = chapterIds[orderIndex] + orderIndex = orderIndex - 1 + end + for i=1, chapterNum do + local plotTab = self.PrequelPlotTabs[i] + if not plotTab then + if i == 1 then + self.PrequelPlotTabs[i] = self.BtnPrequelPlotTab:GetComponent("XUiButton") + else + local tabUi = CS.UnityEngine.Object.Instantiate(self.BtnPrequelPlotTab.gameObject) + tabUi.transform:SetParent(self.UiContent, false) + plotTab = tabUi.transform:GetComponent("XUiButton") + tabUi:SetActive(true) + table.insert(self.PrequelPlotTabs, i, plotTab) + end + end + end + for i in pairs(self.PrequelPlotTabs) do + self:UpdatePlotTabStatus(self.PrequelPlotTabs[i], self.CoverValues[i]) + end + if chapterNum == 1 then + for i in pairs(self.PrequelPlotTabs) do + self.PrequelPlotTabs[i].gameObject:SetActiveEx(false) + end + else + for i=chapterNum + 1, #self.PrequelPlotTabs do + self.PrequelPlotTabs[i].gameObject:SetActiveEx(false) + end + end + self.BtnPrequelGroup:Init(self.PrequelPlotTabs, function(index) self:OnTabsClick(index) end) +end + +function XUiPanelPlotTab:UpdatePlotTabStatus(tab, chapterId) + local chapterData = XPrequelConfigs.GetPrequelChapterById(chapterId) + tab:SetName(chapterData.ChapterName) + if not string.IsNilOrEmpty(chapterData.TabRawImagePath) then + tab:SetRawImage(chapterData.TabRawImagePath) + end + -- 处理锁住+活动的情况 + tab:SetDisable(false, true) + tab:ShowTag(false) + + -- 锁住,优先级较低 + if XDataCenter.PrequelManager.GetChapterLockStatus(chapterId) then + tab:SetDisable(true, true) + tab:ShowTag(false) + end + + -- 活动 + if XDataCenter.PrequelManager.IsChapterInActivity(chapterId) then + tab:SetDisable(false, true) + tab:ShowTag(true) + end +end + +function XUiPanelPlotTab:SelectIndex(index, doNotAnim) + if self.BtnPrequelGroup then + self.BtnPrequelGroup:SelectIndex(index, false) + self:OnTabsClick(index, doNotAnim) + end +end + +function XUiPanelPlotTab:OnTabsClick(index, doNotAnim) + if not self.CoverValues then return end + local currentChapterId = self.CoverValues[index] + local isLock = XDataCenter.PrequelManager.GetChapterLockStatus(currentChapterId) + local inActivity = XDataCenter.PrequelManager.IsChapterInActivity(currentChapterId) + local fx = XPrequelConfigs.GetPrequelChapterById(currentChapterId).UiFxPath + if isLock and (not inActivity) then + local msg = XDataCenter.PrequelManager.GetChapterUnlockDescription(currentChapterId) + if msg then + XUiManager.TipMsg(msg) + end + return + end + + if doNotAnim then + self:OnTabSelected(index) + return + end + self:OnTabSelected(index) + + if not self.RootUi:IsRegionalAnimPlaying() then + self.RootUi:PlayAnimation(ANIPREQUELREGIONALSWITCH) + end + self.RootUi:ResetBgFx(fx) +end + +-- [选中一个章节] +function XUiPanelPlotTab:OnTabSelected(index) + self.ParentUi:OnChapterSelected(index, self.CoverValues[index]) +end + +return XUiPanelPlotTab \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPrequel/XUiPanelPrequelChapter.lua b/Resources/Scripts/XUi/XUiPrequel/XUiPanelPrequelChapter.lua new file mode 100644 index 00000000..6b3c26cb --- /dev/null +++ b/Resources/Scripts/XUi/XUiPrequel/XUiPanelPrequelChapter.lua @@ -0,0 +1,183 @@ +local XUiGridStage = require("XUi/XUiFubenMainLineChapter/XUiGridStage") + +XUiPanelPrequelChapter = XClass(nil, "XUiPanelPrequelChapter") + +function XUiPanelPrequelChapter:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self:InitAutoScript() + self.GridChapterStageList = {} + self.GridLineList = {} + self.BoundSizeFitter = self.PanelStageContent:GetComponent("XBoundSizeFitter") +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelPrequelChapter:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiPanelPrequelChapter:AutoInitUi() + self.GridPrequelStage = self.Transform:Find("GridPrequelStage") + self.SViewlStageList = self.Transform:Find("SViewlStageList"):GetComponent("ScrollRect") + self.PanelStageContent = self.Transform:Find("SViewlStageList/ViewPort/PanelStageContent") +end + +function XUiPanelPrequelChapter:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelPrequelChapter:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelPrequelChapter:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelPrequelChapter:AutoAddListener() +end +-- auto + +function XUiPanelPrequelChapter:Show() + if self.GameObject.activeSelf == true then return end + self.GameObject:SetActive(true) +end + +function XUiPanelPrequelChapter:Hide() + if self.GameObject.activeSelf == false then return end + self.GameObject:SetActive(false) +end + +-- 如果没有彩蛋,生成假彩蛋 +function XUiPanelPrequelChapter:GenerateEggDatas(datas) + local eggDatas = {} + if not datas then return eggDatas end + for k, v in pairs(datas) do + eggDatas[k] = v + end + local stageCfg = XDataCenter.FubenManager.GetStageCfg(eggDatas[1]) + if not self:IsHideStage(stageCfg) then + table.insert(eggDatas, 1, eggDatas[1]) + end + return eggDatas +end + +function XUiPanelPrequelChapter:UpdatePrequelGrid(data) + if not data then return end + self.PrequelChapterStageList = self:GenerateEggDatas(data) + + -- 设置剧情数据 + for i=1, #self.PrequelChapterStageList do + local grid = self.GridChapterStageList[i] + if not grid then + local parent = self.PanelStageContent.transform:Find(string.format("GridPrequelStage%d", i)) + if not parent then + XLog.Error("XUiPanelPrequelChapter:UpdatePrequelGrid error: prefab not found a child name " .. string.format("GridPrequelStage%d", i)) + return + end + local prefab = parent:LoadPrefab(CS.XGame.ClientConfig:GetString("GridPrequelStage")) + grid = XUiGridStage.New(self.RootUi, prefab , nil, XFubenConfigs.FUBENTYPE_PREQUEL) + self.GridChapterStageList[i] = grid + end + + local stageCfg = XDataCenter.FubenManager.GetStageCfg(self.PrequelChapterStageList[i]) + grid:UpdateStageMapGrid(stageCfg) + end + + -- 隐藏多余的剧情 + local index = #self.PrequelChapterStageList + 1 + local extraStage = self.PanelStageContent.transform:Find(string.format("GridPrequelStage%d", index)) + while extraStage do + extraStage.gameObject:SetActive(false) + index = index + 1 + extraStage = self.PanelStageContent.transform:Find(string.format("GridPrequelStage%d", index)) + end + + -- 获得所有黑色线条 + for i = 1, #self.PrequelChapterStageList - 1 do + if not self.GridLineList[i] then + local line = self.PanelStageContent.transform:Find(string.format("Line%d", i)) + if not XTool.UObjIsNil(line) then + line.gameObject:SetActive(false) + self.GridLineList[i] = line + end + end + end + + -- 隐藏多余的黑色线条,如果有 + local idx = #self.PrequelChapterStageList - 1 + local hideGrid = self.PanelStageContent.transform:Find(string.format("Line%d", idx)) + while hideGrid do + hideGrid.gameObject:SetActive(false) + idx = idx + 1 + hideGrid = self.PanelStageContent.transform:Find(string.format("Line%d", idx)) + end + + -- 第一个是彩蛋 + -- 设置剧情显隐,从2开始第一个默认开启 + for i=3, #self.PrequelChapterStageList do + local currentStageId = self.PrequelChapterStageList[i] + -- local stageCfg = XDataCenter.FubenManager.GetStageCfg(currentStageId) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(currentStageId) + -- local isHideStage = self:IsHideStage(stageCfg) + self.GridChapterStageList[i].GameObject:SetActive(stageInfo.Unlock) + self.GridChapterStageList[i].Transform.parent.gameObject:SetActive(stageInfo.Unlock) + if self.GridLineList[i-2] then + self.GridLineList[i-2].gameObject:SetActive(stageInfo.Unlock) + end + end + + -- 挂彩蛋 + local hideStageGridIndex = 1 + local hideStageGrid = self.GridChapterStageList[hideStageGridIndex] + local hideStageId = self.PrequelChapterStageList[hideStageGridIndex] + self:HangUpHideStage(hideStageGridIndex, hideStageGrid, hideStageId) + + + -- 移动至ListView正确的位置 + if self.BoundSizeFitter then + self.BoundSizeFitter:SetLayoutHorizontal() + end + + if self.SViewlStageList then + self.SViewlStageList.horizontalNormalizedPosition = 1 + end + +end + +function XUiPanelPrequelChapter:HangUpHideStage(hideStageGridIndex, hideStageGrid, hideStageId) + local stageCfg = XDataCenter.FubenManager.GetStageCfg(hideStageId) + -- local stageInfo = XDataCenter.FubenManager.GetStageInfo(hideStageId) + local isHideStage = self:IsHideStage(stageCfg) + local isHideStageOpen = XDataCenter.PrequelManager.CheckPrequelStageOpen(hideStageId) + + local isShowHideStage = isHideStage and isHideStageOpen + hideStageGrid.GameObject:SetActive(isShowHideStage) + hideStageGrid.Transform.parent.gameObject:SetActive(isShowHideStage) + + if isShowHideStage then + if stageCfg.PreStageId and stageCfg.PreStageId[1] then + for i=1, #self.PrequelChapterStageList do + local hangUpPointStage = self.PrequelChapterStageList[i] + if hangUpPointStage == stageCfg.PreStageId[1] then + hideStageGrid.Transform.parent.transform.localPosition = self.GridChapterStageList[i].Transform.parent.transform.localPosition + break + end + end + end + end +end + +function XUiPanelPrequelChapter:IsHideStage(stageCfg) + return stageCfg.StageType == XFubenConfigs.STAGETYPE_STORYEGG or stageCfg.StageType == XFubenConfigs.STAGETYPE_FIGHTEGG +end + +return XUiPanelPrequelChapter \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPrequel/XUiPanelRegional.lua b/Resources/Scripts/XUi/XUiPrequel/XUiPanelRegional.lua new file mode 100644 index 00000000..757bd81c --- /dev/null +++ b/Resources/Scripts/XUi/XUiPrequel/XUiPanelRegional.lua @@ -0,0 +1,235 @@ +XUiPanelRegional = XClass(nil, "XUiPanelRegional") + +function XUiPanelRegional:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self:InitAutoScript() + self.CurrentPrequelGrid = nil + self.LastPrequelPrefabName = "" + self.PrequelGridList = {} + self.PrequelGridAsset = {} + self.PlotTab = XUiPanelPlotTab.New(self.PanelPlotTab, self.RootUi, self) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelRegional:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiPanelRegional:AutoInitUi() + self.PanelRegional = self.Transform:Find("PanelRegional") + self.PanelPrequelStages = self.Transform:Find("PanelRegional/PanelPrequelStages") + self.TxtMode = self.Transform:Find("PanelRegional/PanelBt/TxtMode"):GetComponent("Text") + self.TxtProgress = self.Transform:Find("PanelRegional/PanelBt/TxtProgress"):GetComponent("Text") + self.PanelLeft = self.Transform:Find("PanelRegional/PanelLeft") + self.PanelPlotTab = self.Transform:Find("PanelRegional/PanelLeft/PanelPlotTab") + self.BtnSwitch2Fight = self.Transform:Find("PanelRegional/PanelBt/BtnSwitch2Fight"):GetComponent("Button") + self.ImgLock = self.Transform:Find("PanelRegional/PanelBt/BtnSwitch2Fight/ImgLock/Image"):GetComponent("Image") + self.PanelBottom = self.Transform:Find("PanelRegional/PanelBottom") + self.PanelJundu = self.Transform:Find("PanelRegional/PanelBottom/PanelJundu") + self.ImgJindu = self.Transform:Find("PanelRegional/PanelBottom/PanelJundu/ImgJindu"):GetComponent("Image") + self.ImgLingqu = self.Transform:Find("PanelRegional/PanelBottom/PanelJundu/ImgLingqu"):GetComponent("Image") + self.BtnTreasure = self.Transform:Find("PanelRegional/PanelBottom/PanelJundu/BtnTreasure"):GetComponent("Button") + self.PanelNum = self.Transform:Find("PanelRegional/PanelBottom/PanelNum") + self.TxtBfrtTaskTotalNum = self.Transform:Find("PanelRegional/PanelBottom/PanelNum/TxtBfrtTaskTotalNum"):GetComponent("Text") + self.TxtBfrtTaskFinishNum = self.Transform:Find("PanelRegional/PanelBottom/PanelNum/TxtBfrtTaskFinishNum"):GetComponent("Text") + self.ImgRedProgress = self.Transform:Find("PanelRegional/PanelBottom/PanelNum/ImgRedProgress") + self.BtnActDesc = self.Transform:Find("PanelRegional/BtnActDesc"):GetComponent("Button") + self.RImgChapterName = self.Transform:Find("PanelRegional/PanelBt/RImgChapterName"):GetComponent("RawImage") +end + +function XUiPanelRegional:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelRegional:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelRegional:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelRegional:AutoAddListener() + self:RegisterClickEvent(self.BtnSwitch2Fight, self.OnBtnSwitch2FightClick) + self:RegisterClickEvent(self.BtnTreasure, self.OnBtnTreasureClick) + self:RegisterClickEvent(self.BtnActDesc, self.OnBtnActDescClick) +end + +function XUiPanelRegional:CheckHaveChallengeMode() + local cStage = self.CurrentCover.CoverVal.ChallengeStage + self.BtnSwitch2Fight.gameObject:SetActiveEx(cStage ~= nil and #cStage > 0) +end +-- auto + +function XUiPanelRegional:OnBtnSwitch2FightClick() + if not self.CurrentCover then + return + end + local coverVal = self.CurrentCover.CoverVal + if not coverVal.ChallengeStage or #coverVal.ChallengeStage == 0 then return end + -- 检查条件 + if coverVal.ChallengeCondition > 0 then + local rect, desc = XConditionManager.CheckCondition(coverVal.ChallengeCondition) + if not rect then + XUiManager.TipMsg(desc) + return + end + end + local keyX = string.format("%s%d%d", "PrequelLastSwitchPanelType", XPlayer.Id, self.CurrentCover.CoverId) + local panelType = 2 + CS.UnityEngine.PlayerPrefs.SetInt(keyX, panelType) + self.RootUi:Switch2Challenge(self.CurrentCover) +end + +function XUiPanelRegional:OnBtnTreasureClick() + if not self.CurrentSelectedChapterId then + return + end + self.RootUi:Switch2RewardList(self.CurrentSelectedChapterId) +end + +function XUiPanelRegional:OnBtnActDescClick() + if self.CurrentCover and self.CurrentSelectIdx then + local reverseIndex = #self.CurrentCover.CoverVal.ChapterId - self.CurrentSelectIdx + 1 + local chapterId = self.CurrentCover.CoverVal.ChapterId[reverseIndex] + local chapterInfo = XPrequelConfigs.GetPrequelChapterInfoById(chapterId) + local description = string.gsub(chapterInfo.ChapterDescription, "\\n", "\n") + XUiManager.UiFubenDialogTip("", description) + end +end + +function XUiPanelRegional:InitPlotTab() + self.PlotTab:UpdateTabs(self.CurrentCover) + local defaultIndex = XDataCenter.PrequelManager.GetSelectableChaperIndex(self.CurrentCover) or 1 + local skipChapter = self.RootUi:GetDefaultChapter() + local isSkipChapterInActivity = (skipChapter ~= nil) and XDataCenter.PrequelManager.IsChapterInActivity(skipChapter) or false + + local skipIndex = XDataCenter.PrequelManager.GetIndexByChapterId(self.CurrentCover, skipChapter) + self.CurrentSelectIdx = self.CurrentSelectIdx or defaultIndex + if isSkipChapterInActivity then + local skipDescription = XDataCenter.PrequelManager.GetChapterUnlockDescription(skipChapter) + -- 活动内、已解锁 + if skipDescription == nil then + self.CurrentSelectIdx = skipIndex or self.CurrentSelectIdx + end + end + local index = self.RootUi:GetResumeTabIndex() + if index then self.CurrentSelectIdx = index end + self.PlotTab:SelectIndex(self.CurrentSelectIdx, false) +end + +function XUiPanelRegional:OnRefresh(coverData) + self.CurrentCover = coverData + self:CheckHaveChallengeMode() + self:InitPlotTab() +end + +function XUiPanelRegional:UpdateCurrentTab() + if self.CurrentSelectIdx then + self:OnChapterSelected(self.CurrentSelectIdx) + end +end + +function XUiPanelRegional:UpdateRewardView() + if self.CurrentCover and self.CurrentSelectIdx then + local reverseIndex = #self.CurrentCover.CoverVal.ChapterId - self.CurrentSelectIdx + 1 + local chapterId = self.CurrentCover.CoverVal.ChapterId[reverseIndex] + self.ImgRedProgress.gameObject:SetActive(XDataCenter.PrequelManager.CheckRewardAvailable(chapterId)) + local totalNum, finishedNum = self:GetRewardTotalNumAndFinishNum(chapterId) + self.TxtBfrtTaskTotalNum.text = totalNum + self.TxtBfrtTaskFinishNum.text = finishedNum + self.ImgJindu.fillAmount = finishedNum / totalNum * 1.0 + end +end + +function XUiPanelRegional:UpdateCover() + XEventManager.DispatchEvent(XEventId.EVENT_NOTICE_SELECTCOVER_CHANGE, {Cover = self.CurrentCover, Index = self.CurrentSelectIdx}) +end + +function XUiPanelRegional:OnChapterSelected(index, chapterId) + self.CurrentSelectIdx = index + local reverseIndex = #self.CurrentCover.CoverVal.ChapterId - index + 1 + local id = self.RootUi:GetResumeChapterId() --页面恢复时读取缓存的ID项 + if id then chapterId = id end + if chapterId == nil then chapterId = self.CurrentCover.CoverVal.ChapterId[reverseIndex] end + self.ChapterDatas = XPrequelConfigs.GetPrequelChapterById(chapterId) + self.CurrentSelectedChapterId = chapterId + local prefabName = self.ChapterDatas.PrefabName + if not prefabName or prefabName == "" then + XLog.Error("XUiPanelRegional:OnChapterSelected错误 : 没找到预制体 prefabName = " .. tostring(prefabName)) + return + end + --local asset = self.PanelRegional:LoadPrefab(prefabName) + local asset = self.RootUi.PanelFullScreen:LoadPrefab(prefabName) + if asset == nil or (not asset:Exist()) then + XLog.Error("当前prefab不存在:" .. tostring(prefabName)) + return + end + if self.LastPrequelPrefabName ~= prefabName then + local grid = XUiPanelPrequelChapter.New(asset, self.RootUi) + --grid.Transform:SetParent(self.PanelRegional, false) + self.CurrentPrequelGrid = grid + self.LastPrequelPrefabName = prefabName + if not string.IsNilOrEmpty(self.ChapterDatas.UiBgPath) then + local bg = asset.transform:Find("RImgChapterBg") + if bg then + bg:GetComponent("RawImage"):SetRawImage(self.ChapterDatas.UiBgPath) + end + end + end + self.CurrentPrequelGrid:UpdatePrequelGrid(self.ChapterDatas.StageId) + self.CurrentPrequelGrid:Show() + + local progressFinishedNum, progressTotalNum = XDataCenter.PrequelManager.GetChapterProgress(chapterId) + self.TxtProgress.text = CS.XTextManager.GetText("UiPrequelTitleProgressStrFormat", progressFinishedNum, progressTotalNum) + local totalNum, finishedNum = self:GetRewardTotalNumAndFinishNum(chapterId) + self.TxtBfrtTaskTotalNum.text = totalNum + self.TxtBfrtTaskFinishNum.text = finishedNum + self.ImgRedProgress.gameObject:SetActive(XDataCenter.PrequelManager.CheckRewardAvailable(chapterId)) + self.ImgJindu.fillAmount = finishedNum / totalNum * 1.0 + if self.CurrentCover.CoverVal.ChallengeCondition > 0 then + local rect = XConditionManager.CheckCondition(self.CurrentCover.CoverVal.ChallengeCondition) + self.ImgLock.gameObject:SetActive(not rect) + else + self.ImgLock.gameObject:SetActive(false) + end + if string.IsNilOrEmpty(self.ChapterDatas.RImgChapterNamePath) then + XLog.Warning("间章标题图片路径为空值!设置失败!chapterId = " .. chapterId .. " 请检查Chapter.tab表") + self.RImgChapterName.gameObject:SetActiveEx(false) + else + self.RImgChapterName:SetRawImage(self.ChapterDatas.RImgChapterNamePath) + self.RImgChapterName.gameObject:SetActiveEx(true) + end +end + +function XUiPanelRegional:GetRewardTotalNumAndFinishNum(chapterId) + local totalNum = 0 + local finishNum = 0 + local chapterCfg = XPrequelConfigs.GetPrequelChapterById(chapterId) + for _, stageId in pairs(chapterCfg and chapterCfg.StageId or {}) do + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + if stageCfg.FirstRewardShow > 0 then + totalNum = totalNum + 1 + if XDataCenter.PrequelManager.IsRewardStageCollected(stageId) then + finishNum = finishNum + 1 + end + end + end + return totalNum, finishNum +end + +function XUiPanelRegional:SetPanelActive(isActive) + if self.CurrentPrequelGrid then self.CurrentPrequelGrid.GameObject:SetActiveEx(isActive) end + self.GameObject:SetActiveEx(isActive) +end + +return XUiPanelRegional \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPrequel/XUiPanelUnlockChallenge.lua b/Resources/Scripts/XUi/XUiPrequel/XUiPanelUnlockChallenge.lua new file mode 100644 index 00000000..b394a8fd --- /dev/null +++ b/Resources/Scripts/XUi/XUiPrequel/XUiPanelUnlockChallenge.lua @@ -0,0 +1,126 @@ +XUiPanelUnlockChallenge = XClass(nil, "XUiPanelUnlockChallenge") + +function XUiPanelUnlockChallenge:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self:InitAutoScript() + self.RewardList = {} + self.GridCommon.gameObject:SetActive(false) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelUnlockChallenge:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiPanelUnlockChallenge:AutoInitUi() + self.ImgMask = self.Transform:Find("ImgMask"):GetComponent("Image") + self.PanelMain = self.Transform:Find("PanelMain") + self.TxtUnlockTitle = self.Transform:Find("PanelMain/TxtUnlockTitle"):GetComponent("Text") + self.PanelInfo = self.Transform:Find("PanelMain/PanelInfo") + self.TxtTitle = self.Transform:Find("PanelMain/PanelInfo/TxtTitle"):GetComponent("Text") + self.TxtCheckPoint = self.Transform:Find("PanelMain/PanelInfo/TxtCheckPoint"):GetComponent("Text") + self.RImgCheckPoint = self.Transform:Find("PanelMain/PanelInfo/RImgCheckPoint"):GetComponent("RawImage") + self.GridCommon = self.Transform:Find("PanelMain/RewardListList/Viewport/Content/GridCommon") + self.RImgIcon = self.Transform:Find("PanelMain/RewardListList/Viewport/Content/GridCommon/RImgIcon"):GetComponent("RawImage") + self.PanelChallengeTimes = self.Transform:Find("PanelMain/PanelChallengeTimes") + self.TxtChallengeTimes = self.Transform:Find("PanelMain/PanelChallengeTimes/TxtChallengeTimes"):GetComponent("Text") + self.PanelCost = self.Transform:Find("PanelMain/PanelCost") + self.PanelMoney = self.Transform:Find("PanelMain/PanelCost/PanelMoney") + self.RImgCost = self.Transform:Find("PanelMain/PanelCost/PanelMoney/RImgCost"):GetComponent("RawImage") + self.TxtCostNum = self.Transform:Find("PanelMain/PanelCost/PanelMoney/TxtCostNum"):GetComponent("Text") + self.BtnUnlock = self.Transform:Find("PanelMain/PanelCost/BtnUnlock"):GetComponent("Button") + self.BtnMask = self.Transform:Find("BtnMask"):GetComponent("Button") + self.PanelBgA = self.Transform:Find("PanelBg") +end + +function XUiPanelUnlockChallenge:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelUnlockChallenge:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelUnlockChallenge:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelUnlockChallenge:AutoAddListener() + self:RegisterClickEvent(self.BtnUnlock, self.OnBtnUnlockClick) + self:RegisterClickEvent(self.BtnMask, self.OnBtnMaskClick) +end +-- auto + +function XUiPanelUnlockChallenge:OnBtnMaskClick() + self.RootUi:PlayAnimation("AniUnlockChallengeEnd", function() + self.GameObject:SetActive(false) + end) +end + +function XUiPanelUnlockChallenge:OnBtnUnlockClick() + if not self.CurrentChallengeStage then return end + + XDataCenter.PrequelManager.UnlockPrequelChallengeRequest(self.CurrentChallengeStage.CoverId, self.CurrentChallengeStage.ChallengeIndex, self.CurrentChallengeStage.ChallengeStage, function() + self.GameObject:SetActive(false) + self.RootUi:RefreshChallenge() + end) +end + +function XUiPanelUnlockChallenge:RefreshWithAnim(challengeStage) + self.RootUi:PlayAnimation("AniUnlockChallengeBegin") + self:RefreshDatas(challengeStage) +end + +function XUiPanelUnlockChallenge:RefreshDatas(challengeStage) + self.CurrentChallengeStage = challengeStage + local stageId = challengeStage.ChallengeStage + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + self.TxtCheckPoint.text = stageCfg.Name + self.RImgCheckPoint:SetRawImage(stageCfg.Icon) + self.TxtChallengeTimes.text = stageCfg.MaxChallengeNums or 0 + + self.RImgCost:SetRawImage(XDataCenter.ItemManager.GetItemIcon(self.CurrentChallengeStage.ChallengeConsumeItem)) + local ownNum = XDataCenter.ItemManager.GetCount(self.CurrentChallengeStage.ChallengeConsumeItem) + local needNum = self.CurrentChallengeStage.ChallengeConsumeCount + local currentNum = (ownNum >= needNum) and needNum or XPrequelConfigs.GetNotEnoughCost(needNum) + self.TxtCostNum.text = currentNum + self:UpdateRewards() +end + +function XUiPanelUnlockChallenge:UpdateRewards() + local stageId = self.CurrentChallengeStage.ChallengeStage + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + local rewardId = stageCfg.FirstRewardShow + local rewards = XRewardManager.GetRewardList(rewardId) + + if not rewards then return end + local rewardCount = #rewards + for i=1, rewardCount do + local xcommon = self.RewardList[i] + if not xcommon then + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommon.gameObject) + ui.transform:SetParent(self.GridCommon.parent, false) + ui.gameObject:SetActive(true) + xcommon = XUiGridCommon.New(self.RootUi, ui) + table.insert(self.RewardList, i, xcommon) + end + end + + for i=1, #self.RewardList do + self.RewardList[i].GameObject:SetActive(i <= rewardCount) + if i <= rewardCount then + self.RewardList[i]:Refresh(rewards[i]) + end + end +end + +return XUiPanelUnlockChallenge \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPrequel/XUiPrequel.lua b/Resources/Scripts/XUi/XUiPrequel/XUiPrequel.lua new file mode 100644 index 00000000..91ce77d5 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPrequel/XUiPrequel.lua @@ -0,0 +1,281 @@ +local XUiPrequel = XLuaUiManager.Register(XLuaUi, "UiPrequel") + +local MODE_REGIONAL = 1 +local MODE_CHALLANGE = 2 + +function XUiPrequel:OnAwake() + self:InitAutoScript() + self.Regional = XUiPanelRegional.New(self.PanelRegional, self) + self.ChallengeMode = XUiPanelChallengeMode.New(self.PanelChallengeMode, self) + self.CheckReward = XUiPanelCheckReward.New(self.PanelCheckReward, self) + self.UnlockChallenge = XUiPanelUnlockChallenge.New(self.PanelUnlockChallenge, self) + self.FightDailog = XUiPanelEnterFightDialog.New(self.PanelEnterFightDialog, self) + + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self.OnRefreshTimeChanged = function() self:UpdateRefreshTime() end + self.OnUnlockChallengeStageChanged = function() self:UpdateChallengeStage() end + self.OnPrequelDetailClosed = function() self:OnDetailClosed() end + + XEventManager.AddEventListener(XEventId.EVENT_NOTICE_CHALLENGESTAGES_CHANGE, self.OnRefreshTimeChanged) + XEventManager.AddEventListener(XEventId.EVENT_NOTICE_REFRESHTIME_CHANGE, self.OnUnlockChallengeStageChanged) + XEventManager.AddEventListener(XEventId.EVENT_NOTICE_PREQUELDETAIL_CLOSE, self.OnPrequelDetailClosed) + + + self.IsRegionalAnimBegin = false + self.IsChallengeAnimBegin = false +end + +function XUiPrequel:IsRegionalAnimPlaying() + return self.IsRegionalAnimBegin or false +end + +function XUiPrequel:IsChallengeAnimPlaying() + return self.IsChallengeAnimBegin or false +end + +function XUiPrequel:SetChallengeAnimBegin(isBegin) + self.IsChallengeAnimBegin = isBegin +end + +function XUiPrequel:OnStart(coverData, currentMode, defaultChapter) + self.CurrentCover = coverData + self.DefaultChapter = defaultChapter + self:SetPanelAssetActive(true) + if currentMode and currentMode ~= 0 then + self.CurrentMode = currentMode + end +end + +function XUiPrequel:GetDefaultChapter() + local chapter = self.DefaultChapter + self.DefaultChapter = nil + return chapter +end + +function XUiPrequel:OnEnable() + self:OnRefresh() +end + + +function XUiPrequel:OnDisable() + -- 关闭界面也检查计时器是否还没清除 + self.ChallengeMode:RemoveChallengeTimer() +end + + +function XUiPrequel:OnDestroy() + XEventManager.RemoveEventListener(XEventId.EVENT_NOTICE_CHALLENGESTAGES_CHANGE, self.OnRefreshTimeChanged) + XEventManager.RemoveEventListener(XEventId.EVENT_NOTICE_REFRESHTIME_CHANGE, self.OnUnlockChallengeStageChanged) + XEventManager.RemoveEventListener(XEventId.EVENT_NOTICE_PREQUELDETAIL_CLOSE, self.OnPrequelDetailClosed) +end + + +function XUiPrequel:OnGetEvents() + return nil +end + + +function XUiPrequel:OnNotify() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPrequel:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiPrequel:AutoInitUi() + self.RImgBg = self.Transform:Find("FullScreenBackground/RImgBg"):GetComponent("RawImage") + self.PanelRegional = self.Transform:Find("SafeAreaContentPane/PanelRegional") + self.PanelChallengeMode = self.Transform:Find("SafeAreaContentPane/PanelChallengeMode") + self.BtnBack = self.Transform:Find("SafeAreaContentPane/Top/BtnBack"):GetComponent("Button") + self.BtnMainUi = self.Transform:Find("SafeAreaContentPane/Top/BtnMainUi"):GetComponent("Button") + self.PanelAsset = self.Transform:Find("SafeAreaContentPane/PanelAsset") + self.PanelCheckReward = self.Transform:Find("SafeAreaContentPane/PanelCheckReward") + self.PanelUnlockChallenge = self.Transform:Find("SafeAreaContentPane/PanelUnlockChallenge") + self.PanelEnterFightDialog = self.Transform:Find("SafeAreaContentPane/PanelEnterFightDialog") + self.PanelEffect = self.Transform:Find("FullScreenBackground/PanelEffect") + self.PanelFullScreen = self.Transform:Find("FullScreenBackground/PanelStage/PanelRegional/PanelRegional/PanelPrequelStages") +end + +function XUiPrequel:AutoAddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) +end +-- auto +function XUiPrequel:OnBtnBackClick() + self.Regional:UpdateCover() + self:Close() +end + +function XUiPrequel:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiPrequel:OnRefresh() + --获取上次保存的数据 + local lastSelectPanelType = 1 + local keyX = string.format("%s%d%d", "PrequelLastSwitchPanelType", XPlayer.Id, self.CurrentCover.CoverId) + if CS.UnityEngine.PlayerPrefs.HasKey(keyX) then + lastSelectPanelType = CS.UnityEngine.PlayerPrefs.GetInt(keyX) + end + + self.CurrentMode = self.CurrentMode or lastSelectPanelType + if self.CurrentMode == MODE_REGIONAL then + self:Switch2Regional(self.CurrentCover) + elseif self.CurrentMode == MODE_CHALLANGE then + self:Switch2Challenge(self.CurrentCover) + end +end + +function XUiPrequel:OnClosePrequelDetail() + self:FindChildUiObj("UiPrequelLineDetail"):OnPrequelDetailClose() + self:SetPanelAssetActive(true) +end + +function XUiPrequel:SetPanelAssetActive(isActive) + self.AssetPanel.GameObject:SetActiveEx(isActive) +end + +-- [支线剧情] +function XUiPrequel:Switch2Regional(coverData) + + self:PlayAnimation("AniPrequelRegionalBegin", function() + self.IsRegionalAnimBegin = false + end, function() + self.IsRegionalAnimBegin = true + self.Regional:SetPanelActive(true) + self.PanelChallengeMode.gameObject:SetActive(false) + self.Regional:OnRefresh(coverData) + self.CurrentMode = MODE_REGIONAL + local coverDatas = XPrequelConfigs.GetPrequelCoverInfoById(coverData.CoverId) + self:ResetBackground(coverDatas.CoverBg) + end) +end + +function XUiPrequel:RefreshRegional() + if self.CurrentMode and self.CurrentMode == MODE_REGIONAL then + self.Regional:UpdateCurrentTab() + end +end + +function XUiPrequel:RefreshRegionalReward() + self.Regional:UpdateRewardView() +end + +-- [挑战] +function XUiPrequel:Switch2Challenge(coverData) + if not coverData.CoverVal.ChallengeStage or #coverData.CoverVal.ChallengeStage == 0 then return end + self.Regional:SetPanelActive(false) + self.PanelChallengeMode.gameObject:SetActive(true) + self.ChallengeMode:OnRefresh(coverData) + self.CurrentMode = MODE_CHALLANGE + local coverDatas = XPrequelConfigs.GetPrequelCoverInfoById(coverData.CoverId) + self:ResetBgFx(coverData.CoverVal.ChallengeFx) + self:ResetBackground(coverDatas.ChallengeBg) +end + +-- [刷新挑战界面] +function XUiPrequel:RefreshChallenge() + if self.CurrentCover then + self.ChallengeMode:OnRefresh(self.CurrentCover) + end +end + +-- [解锁挑战关卡] +function XUiPrequel:Switch2UnlockChallengeStage(challengeStage) + self.UnlockChallenge.GameObject:SetActive(true) + self.UnlockChallenge:RefreshWithAnim(challengeStage) +end + +-- [奖励列表:查看某个支线的奖励] +function XUiPrequel:Switch2RewardList(chapterId) + self.CheckReward.GameObject:SetActive(true) + self.CheckReward:UpdateRewardList(chapterId) + self:PlayAnimation("AniPrequelCheckRewardBegin") +end + +-- [刷新倒计时] +function XUiPrequel:UpdateRefreshTime() + if self.CurrentMode and self.CurrentMode == MODE_CHALLANGE then + self.ChallengeMode:UpdateTimer() + end +end + +-- [详情界面关闭,后续处理] +function XUiPrequel:OnDetailClosed() + self.ChallengeMode:OnDetailClosed() +end + +-- [刷新挑战关卡] +function XUiPrequel:UpdateChallengeStage() + if self.CurrentMode and self.CurrentMode == MODE_CHALLANGE then + self.ChallengeMode:UpdateChallengeStages() + end +end + +-- [进入剧情确认框] +function XUiPrequel:OnEnterStory(stageId, callback) + self.FightDailog.GameObject:SetActive(true) + self:PlayAnimation("AniBeginPanelEnterFightDialog", nil, function() + self.FightDailog:OnShowStoryDialog(stageId, callback) + end) +end + +-- [进入战斗确认框] +function XUiPrequel:OnEnterFight(stageId, callback) + self.FightDailog.GameObject:SetActive(true) + self:PlayAnimation("AniBeginPanelEnterFightDialog", nil, function() + self.FightDailog:OnShowFightDialog(stageId, callback) + end) +end + +-- [切换背景] +function XUiPrequel:ResetBackground(rawBg) + local bgNil = string.IsNilOrEmpty(rawBg) + if bgNil then + self.RImgBg:SetRawImage("Assets/Product/Texture/Image/UiFubenMainMapTab/ChapterBg01B.png") + return + end + if self.bgName and self.bgName == rawBg then return end + self.bgName = rawBg + self.RImgBg:SetRawImage(rawBg) +end + +-- [切换背景特效] +function XUiPrequel:ResetBgFx(fxPath) + local disable = string.IsNilOrEmpty(fxPath) + self.PanelEffect.gameObject:SetActiveEx(not disable) + if disable then return end + if self.fxName and self.fxName == fxPath then return end + self.fxName = fxPath + self.PanelEffect.gameObject:LoadUiEffect(fxPath) +end + +function XUiPrequel:OnReleaseInst() + local data = { + CurrentMode = self.CurrentMode, + CurIndex = self.Regional.CurrentSelectIdx, + CurChapterId = self.Regional.CurrentSelectedChapterId + } + return data +end + +function XUiPrequel:OnResume(data) + self.CurrentMode = data.CurrentMode + self.ResumeChapterId = data.CurChapterId + self.ResumeTabIndex = data.CurIndex +end + +function XUiPrequel:GetResumeChapterId() + local id = self.ResumeChapterId + self.ResumeChapterId = nil + return id +end + +function XUiPrequel:GetResumeTabIndex() + local index = self.ResumeTabIndex + self.ResumeTabIndex = nil + return index +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPrequelLineDetail/XUiPrequelLineDetail.lua b/Resources/Scripts/XUi/XUiPrequelLineDetail/XUiPrequelLineDetail.lua new file mode 100644 index 00000000..4e30ee84 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPrequelLineDetail/XUiPrequelLineDetail.lua @@ -0,0 +1,320 @@ +local XUiPrequelLineDetail = XLuaUiManager.Register(XLuaUi, "UiPrequelLineDetail") + +local PANELPREQUELDETAILEND = "PanelPrequelDetailEnd" +local PANELPREQUELDETAILBEGIN = "PanelPrequelDetailBegin" + +function XUiPrequelLineDetail:OnAwake() + self:InitAutoScript() + self.StartGridList = {} + self.GridList = {} + self.GridCommon.gameObject:SetActive(false) + self:InitStarPanels() + + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self.BtnMask.gameObject:SetActive(false) +end + +function XUiPrequelLineDetail:InitStarPanels() + self.GridStarList = {} + for i = 1, 3 do + local ui = self.Transform:Find(string.format("SafeAreaContentPane/PanelPrequelDetail/PanelTargetList/GridStageStar%d", i)) + ui.gameObject:SetActive(true) + local grid = XUiGridStageStar.New(ui) + self.GridStarList[i] = grid + end +end + + +function XUiPrequelLineDetail:OnStart() + +end + +function XUiPrequelLineDetail:Refresh(stage) + self.PrequelStage = stage + self:PlayAnimation(PANELPREQUELDETAILBEGIN) + self:RefreshDetail(self.PrequelStage) +end + + +function XUiPrequelLineDetail:OnEnable() + self:AddListeners() +end + + +function XUiPrequelLineDetail:OnDisable() + self:RemoveListeners() +end + + +function XUiPrequelLineDetail:OnDestroy() +end + + +function XUiPrequelLineDetail:OnGetEvents() + return nil +end + + +function XUiPrequelLineDetail:OnNotify() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPrequelLineDetail:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiPrequelLineDetail:AutoInitUi() + self.PanelPrequelDetail = self.Transform:Find("SafeAreaContentPane/PanelPrequelDetail") + self.PanelAsset = self.Transform:Find("SafeAreaContentPane/PanelPrequelDetail/PanelAsset") + self.PanelNums = self.Transform:Find("SafeAreaContentPane/PanelPrequelDetail/PanelNums") + self.TxtAllNums = self.Transform:Find("SafeAreaContentPane/PanelPrequelDetail/PanelNums/TxtAllNums"):GetComponent("Text") + self.TxtLeftNums = self.Transform:Find("SafeAreaContentPane/PanelPrequelDetail/PanelNums/TxtLeftNums"):GetComponent("Text") + self.BtnAddNum = self.Transform:Find("SafeAreaContentPane/PanelPrequelDetail/PanelNums/BtnAddNum"):GetComponent("Button") + self.PanelDesc = self.Transform:Find("SafeAreaContentPane/PanelPrequelDetail/PanelDesc") + self.TxtTitle = self.Transform:Find("SafeAreaContentPane/PanelPrequelDetail/PanelDesc/TxtTitle"):GetComponent("Text") + self.TxtLevelVal = self.Transform:Find("SafeAreaContentPane/PanelPrequelDetail/PanelDesc/TxtLevelVal"):GetComponent("Text") + self.RImgNandu = self.Transform:Find("SafeAreaContentPane/PanelPrequelDetail/PanelDesc/RImgNandu"):GetComponent("RawImage") + self.TxtDesc = self.Transform:Find("SafeAreaContentPane/PanelPrequelDetail/PanelDesc/TxtDesc"):GetComponent("Text") + self.PanelNoLimitCount = self.Transform:Find("SafeAreaContentPane/PanelPrequelDetail/PanelNoLimitCount") + self.PanelTargetList = self.Transform:Find("SafeAreaContentPane/PanelPrequelDetail/PanelTargetList") + self.GridStageStar = self.Transform:Find("SafeAreaContentPane/PanelPrequelDetail/PanelTargetList/GridStageStar") + self.PanelDropList = self.Transform:Find("SafeAreaContentPane/PanelPrequelDetail/PanelDropList") + self.PanelDrop = self.Transform:Find("SafeAreaContentPane/PanelPrequelDetail/PanelDropList/PanelDrop") + self.TxtDrop = self.Transform:Find("SafeAreaContentPane/PanelPrequelDetail/PanelDropList/PanelDrop/TxtDrop"):GetComponent("Text") + self.TxtDropEn = self.Transform:Find("SafeAreaContentPane/PanelPrequelDetail/PanelDropList/PanelDrop/TxtDropEn"):GetComponent("Text") + self.TxtFirstDrop = self.Transform:Find("SafeAreaContentPane/PanelPrequelDetail/PanelDropList/PanelDrop/TxtFirstDrop"):GetComponent("Text") + self.PanelDropContent = self.Transform:Find("SafeAreaContentPane/PanelPrequelDetail/PanelDropList/DropList/Viewport/PanelDropContent") + self.GridCommon = self.Transform:Find("SafeAreaContentPane/PanelPrequelDetail/PanelDropList/DropList/Viewport/PanelDropContent/GridCommon") + self.PanelBottom = self.Transform:Find("SafeAreaContentPane/PanelPrequelDetail/PanelBottom") + self.TxtATNums = self.Transform:Find("SafeAreaContentPane/PanelPrequelDetail/PanelBottom/TxtATNums"):GetComponent("Text") + self.BtnEnter = self.Transform:Find("SafeAreaContentPane/PanelPrequelDetail/PanelBottom/BtnEnter"):GetComponent("Button") + self.PanelAutoFightButton = self.Transform:Find("SafeAreaContentPane/PanelPrequelDetail/PanelBottom/PanelAutoFightButton") + self.BtnEnterB = self.Transform:Find("SafeAreaContentPane/PanelPrequelDetail/PanelBottom/PanelAutoFightButton/BtnEnterB"):GetComponent("Button") + self.BtnAutoFight = self.Transform:Find("SafeAreaContentPane/PanelPrequelDetail/PanelBottom/PanelAutoFightButton/BtnAutoFight"):GetComponent("Button") + self.ImgAutoFighting = self.Transform:Find("SafeAreaContentPane/PanelPrequelDetail/PanelBottom/PanelAutoFightButton/ImgAutoFighting"):GetComponent("Image") + self.BtnAutoFightComplete = self.Transform:Find("SafeAreaContentPane/PanelPrequelDetail/PanelBottom/PanelAutoFightButton/BtnAutoFightComplete"):GetComponent("Button") + self.BtnMask = self.Transform:Find("SafeAreaContentPane/BtnMask"):GetComponent("Button") +end + +function XUiPrequelLineDetail:AutoAddListener() + self:RegisterClickEvent(self.BtnAddNum, self.OnBtnAddNumClick) + self:RegisterClickEvent(self.BtnEnter, self.OnBtnEnterClick) + self:RegisterClickEvent(self.BtnEnterB, self.OnBtnEnterBClick) + self:RegisterClickEvent(self.BtnAutoFight, self.OnBtnAutoFightClick) + self:RegisterClickEvent(self.BtnAutoFightComplete, self.OnBtnAutoFightCompleteClick) + self:RegisterClickEvent(self.BtnMask, self.OnBtnMaskClick) +end +-- auto +function XUiPrequelLineDetail:OnBtnMaskClick() + self:PlayAnimation(PANELPREQUELDETAILEND, function() + self:OnPrequelDetailClose() + end) +end + +function XUiPrequelLineDetail:OnPrequelDetailClose() + XEventManager.DispatchEvent(XEventId.EVENT_NOTICE_PREQUELDETAIL_CLOSE) + self:Close() +end + +function XUiPrequelLineDetail:OnBtnAddNumClick() + +end + +function XUiPrequelLineDetail:OnBtnEnterClick() + if not self.PrequelStage then + XLog.Error("XUiPrequelLineDetail:OnBtnEnterClick error: stageId error " .. tostring(self.PrequelStage)) + return + end + local stageId = self.PrequelStage + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + if not stageCfg then + XLog.Error("XUiPrequelLineDetail:OnBtnEnterClick error: stageId error " .. tostring(stageId)) + return + end + + local csInfo = XDataCenter.PrequelManager.GetUnlockChallengeStagesByStageId(stageId) + local maxChallengeNum = XDataCenter.FubenManager.GetStageMaxChallengeNums(stageId) + if csInfo and maxChallengeNum == csInfo.Count then + XUiManager.TipMsg(CS.XTextManager.GetText("FubenChallengeCountNotEnough")) + return + end + + if XDataCenter.FubenManager.OpenRoomSingle(stageCfg) then + self:OnPrequelDetailClose() + end +end + +function XUiPrequelLineDetail:OnBtnEnterBClick(eventData) + self:OnBtnEnterClick(eventData) +end + +function XUiPrequelLineDetail:OnBtnAutoFightClick() + if self.PrequelStage then + XDataCenter.AutoFightManager.CheckOpenDialog(self.PrequelStage) + end +end + +function XUiPrequelLineDetail:OnBtnAutoFightCompleteClick() + if self.PrequelStage then + local index = XDataCenter.AutoFightManager.GetIndexByStageId(self.PrequelStage) + XDataCenter.AutoFightManager.ObtainRewards(index) + end +end + +function XUiPrequelLineDetail:RefreshDetail(stage) + local stageId = stage + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + self.TxtTitle.text = stageCfg.Name + self.TxtLevelVal.text = stageCfg.RecomandLevel or 1 + self.TxtDesc.text = stageCfg.Description + self.TxtATNums.text = stageCfg.RequireActionPoint + + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + + -- local challengeNum = stageData and stageData.PassTimesToday or 0 + + local csInfo = XDataCenter.PrequelManager.GetUnlockChallengeStagesByStageId(stageId) + local maxChallengeNum = XDataCenter.FubenManager.GetStageMaxChallengeNums(stage) + + if csInfo == nil then--剧情支线 + self.PanelNoLimitCount.gameObject:SetActive(maxChallengeNum <= 0) + self.PanelNums.gameObject:SetActive(maxChallengeNum > 0) + self.TxtAllNums.text = string.format("/%d", maxChallengeNum) + self.TxtLeftNums.text = maxChallengeNum + else--挑战 + self.PanelNoLimitCount.gameObject:SetActive(false) + self.PanelNums.gameObject:SetActive(true) + self.TxtAllNums.text = string.format("/%d", maxChallengeNum) + self.TxtLeftNums.text = maxChallengeNum - csInfo.Count + end + self.BtnAddNum.gameObject:SetActive(false) + + for i = 1, 3 do + self.GridStarList[i]:Refresh(stageCfg.StarDesc[i], stageInfo.StarsMap[i]) + end + + local nanDuIcon = XDataCenter.FubenManager.GetDifficultIcon(stageId) + self.RImgNandu:SetRawImage(nanDuIcon) + + self:UpdateRewards() +end + +function XUiPrequelLineDetail:UpdateRewards() + if not self.PrequelStage then return end + local stageId = self.PrequelStage + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + + local rewardId = stageCfg.FinishRewardShow + local IsFirst = false + -- 首通有没有填 + local controlCfg = XDataCenter.FubenManager.GetStageLevelControl(stageId) + -- 有首通 + if not stageInfo.Passed then + if controlCfg and controlCfg.FirstRewardShow > 0 then + rewardId = controlCfg.FirstRewardShow + IsFirst = true + elseif stageCfg.FirstRewardShow > 0 then + rewardId = stageCfg.FirstRewardShow + IsFirst = true + end + end + -- 没首通 + if not IsFirst then + if controlCfg and controlCfg.FinishRewardShow > 0 then + rewardId = controlCfg.FinishRewardShow + else + rewardId = stageCfg.FinishRewardShow + end + end + + self:UpdateRewardTitle(IsFirst) + + local rewards = {} + if rewardId > 0 then + rewards = IsFirst and XRewardManager.GetRewardList(rewardId) or XRewardManager.GetRewardListNotCount(rewardId) + end + if rewards then + for i, item in ipairs(rewards) do + local grid + if self.GridList[i] then + grid = self.GridList[i] + else + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommon) + grid = XUiGridCommon.New(self, ui) + grid.Transform:SetParent(self.PanelDropContent, false) + self.GridList[i] = grid + end + grid:Refresh(item) + grid.GameObject:SetActive(true) + end + end + + local rewardsCount = 0 + if rewards then + rewardsCount = #rewards + end + + for j = 1, #self.GridList do + if j > rewardsCount then + self.GridList[j].GameObject:SetActive(false) + end + end + + local showAutoFightBtn = XDataCenter.AutoFightManager.CheckAutoFightAvailable(stageId) == XCode.Success + if showAutoFightBtn then + self:SetAutoFightStatus(XDataCenter.AutoFightManager.State.None) + end + + self:SetAutoFightActive(showAutoFightBtn) +end + +function XUiPrequelLineDetail:SetAutoFightActive(value) + self.PanelAutoFightButton.gameObject:SetActive(value) + self.BtnEnter.gameObject:SetActive(not value) +end + +function XUiPrequelLineDetail:SetAutoFightStatus(value) + local state = XDataCenter.AutoFightManager.State + self.BtnAutoFight.gameObject:SetActive(value == state.None) + self.ImgAutoFighting.gameObject:SetActive(value == state.Fighting) + self.BtnAutoFightComplete.gameObject:SetActive(value == state.Complete) +end + +function XUiPrequelLineDetail:UpdateRewardTitle(isFirstDrop) + self.TxtDrop.gameObject:SetActive(not isFirstDrop) + self.TxtDropEn.gameObject:SetActive(not isFirstDrop) + self.TxtFirstDrop.gameObject:SetActive(isFirstDrop) +end + +function XUiPrequelLineDetail:OnAutoFightStart(stageId) + if self.PrequelStage and self.PrequelStage == stageId then + self:OnBtnMaskClick() + end +end + +function XUiPrequelLineDetail:OnAutoFightRemove(stageId) + if self.PrequelStage and self.PrequelStage == stageId then + self:SetAutoFightStatus(XDataCenter.AutoFightManager.State.None) + end +end + +function XUiPrequelLineDetail:OnAutoFightComplete(stageId) + if self.PrequelStage and self.PrequelStage == stageId then + self:SetAutoFightStatus(XDataCenter.AutoFightManager.State.Complete) + end +end + +function XUiPrequelLineDetail:AddListeners() + XEventManager.AddEventListener(XEventId.EVENT_AUTO_FIGHT_START, self.OnAutoFightStart, self) + XEventManager.AddEventListener(XEventId.EVENT_AUTO_FIGHT_REMOVE, self.OnAutoFightRemove, self) + XEventManager.AddEventListener(XEventId.EVENT_AUTO_FIGHT_COMPLETE, self.OnAutoFightComplete, self) +end + +function XUiPrequelLineDetail:RemoveListeners() + XEventManager.RemoveEventListener(XEventId.EVENT_AUTO_FIGHT_START, self.OnAutoFightStart, self) + XEventManager.RemoveEventListener(XEventId.EVENT_AUTO_FIGHT_REMOVE, self.OnAutoFightRemove, self) + XEventManager.RemoveEventListener(XEventId.EVENT_AUTO_FIGHT_COMPLETE, self.OnAutoFightComplete, self) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPromotionWay/XUiPromotionWay.lua b/Resources/Scripts/XUi/XUiPromotionWay/XUiPromotionWay.lua new file mode 100644 index 00000000..9ecd8ed8 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPromotionWay/XUiPromotionWay.lua @@ -0,0 +1,74 @@ +local XUiPromotionWay = XLuaUiManager.Register(XLuaUi, "UiPromotionWay") + +function XUiPromotionWay:OnStart(showAbility, teamData, stageFightControlId, stageId) + self.StageFightControlId = stageFightControlId + self.TeamData = teamData + self.ShowAbility = showAbility + self.StageId = stageId + self.BtnClose.CallBack = function() self:OnBtnClose() end + self.BtnCharacterJump.CallBack = function() self:OnBtnCharacterJump() end + self.BtnEquipJump.CallBack = function() self:OnBtnEquipJump() end + + local _, stageName = XDataCenter.FubenManager.GetFubenNames(self.StageId) + self.TxtTitle.text = stageName +end + +function XUiPromotionWay:OnEnable() + self:UpdateData() +end + +function XUiPromotionWay:OnBtnClose() + self:Close() +end + +function XUiPromotionWay:OnBtnCharacterJump() + XLuaUiManager.Open("UiCharacter", self.TeamData[self.TargetCharacter], nil, nil, nil, true) +end + +function XUiPromotionWay:OnBtnEquipJump() + XLuaUiManager.Open("UiCharacter", self.TeamData[self.TargetCharacter]) +end + +function XUiPromotionWay:UpdateData() + local data = XFubenConfigs.GetStageFightControl(self.StageFightControlId) + local targetAbility + if data.MaxShowFight > 0 then + targetAbility = data.MaxShowFight + elseif data.AvgShowFight > 0 then + targetAbility = data.AvgShowFight + else + targetAbility = data.ShowFight + end + --找出最接近战力限制的为显示目标 + local teamAbility = {} + for i = 1, #self.TeamData do + local character = XDataCenter.CharacterManager.GetCharacter(self.TeamData[i]) + if character == nil then + table.insert(teamAbility, 0) + else + table.insert(teamAbility, character.Ability) + end + end + + local targetCharacter = 1 + for i = 2, #self.TeamData do + if targetAbility - teamAbility[i] > 0 and targetAbility - teamAbility[i] < math.abs(targetAbility - teamAbility[targetCharacter]) then + targetCharacter = i + end + end + + targetCharacter = self.TeamData[targetCharacter] ~= 0 and targetCharacter or self.TargetCharacter + + self.TargetCharacter = targetCharacter + local targetCharacterAbility = data.CharacterFight + local targetEquipAbility = data.EquipFight + local equipAbility = XDataCenter.EquipManager.GetEquipAbility(self.TeamData[targetCharacter]) + local characterAbility = teamAbility[targetCharacter] - equipAbility + + self.TxtCharacter.text = math.floor(characterAbility / targetCharacterAbility * 100) .. "%" + self.ImgCharacterProgress.fillAmount = 0 + self.ImgCharacterProgress:DOFillAmount(characterAbility / targetCharacterAbility, 0.5) + self.TxtEquip.text = math.floor(equipAbility / targetEquipAbility * 100) .. "%" + self.ImgEquipProgress.fillAmount = 0 + self.ImgEquipProgress:DOFillAmount(equipAbility / targetEquipAbility, 0.5) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPurchase/XUiBatchPanel.lua b/Resources/Scripts/XUi/XUiPurchase/XUiBatchPanel.lua new file mode 100644 index 00000000..01f4f968 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPurchase/XUiBatchPanel.lua @@ -0,0 +1,180 @@ +local XUiBatchPanel = XClass(nil, "XUiBatchPanel") +local Interval = 100 +local MinCount = 1 +local MaxCount = 99 +-- panelParam格式 +-- panelParam = { +-- MaxCount, +-- MinCount, +-- BtnAddCallBack, +-- BtnReduceCallBack, +-- BtnAddLongCallBack, +-- BtnReduceLongCallBack, +-- BtnMaxCallBack, +-- SelectTextChangeCallBack, +-- SelectTextInputEndCallBack, +-- } +function XUiBatchPanel:Ctor(rootUi, ui, panelParam) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RectTransform = ui + self.RootUi = rootUi + XTool.InitUiObject(self) + self:Init(panelParam) +end + +function XUiBatchPanel:Init(panelParam) + if not panelParam then + XLog.Error("PanelParam Cant Be nil") + return + end + self.MaxCount = panelParam.MaxCount or MaxCount + self.MinCount = panelParam.MinCount or MinCount + self.Interval = panelParam.Interval or Interval + self.BtnAddCallBack = panelParam.BtnAddCallBack + self.BtnReduceCallBack = panelParam.BtnReduceCallBack + self.BtnAddLongCallBack = panelParam.BtnAddLongCallBack + self.BtnReduceLongCallBack = panelParam.BtnReduceLongCallBack + self.BtnMaxCallBack = panelParam.BtnMaxCallBack + self.SelectTextChangeCallBack = panelParam.SelectTextChangeCallBack + self.SelectTextInputEndCallBack = panelParam.SelectTextInputEndCallBack + + self:AutoRegisterListener() + self:SetSelectTextData() + self.IsInLongClick = false + + if self.MaxCount <= 1 then + self.BtnMax:SetDisable(true, false) + else + self.BtnMax:SetDisable(false, true) + end + + self.TxtSelect.text = tostring(self.MinCount) +end + +function XUiBatchPanel:OnBtnAddClick() + if self.IsInLongClick then + self.IsInLongClick = false + return + end + + if self.RootUi.CurrentBuyCount >= self.MaxCount then + return + end + + if self.BtnAddCallBack then + self.BtnAddCallBack() + self.BtnClicked = true + self.TxtSelect.text = tostring(self.RootUi.CurrentBuyCount) + end +end + +function XUiBatchPanel:OnBtnReduceClick() + if self.IsInLongClick then + self.IsInLongClick = false + return + end + + if self.RootUi.CurrentBuyCount <= self.MinCount then + return + end + + if self.BtnReduceCallBack then + self.BtnReduceCallBack() + self.BtnClicked = true + self.TxtSelect.text = tostring(self.RootUi.CurrentBuyCount) + end +end + +function XUiBatchPanel:OnBtnAddLongClick() + if self.RootUi.CurrentBuyCount >= self.MaxCount then + return + end + + if not self.IsInLongClick then self.IsInLongClick = true end + if self.BtnAddLongCallBack then + self.BtnAddLongCallBack() + self.BtnClicked = true + self.TxtSelect.text = tostring(self.RootUi.CurrentBuyCount) + end +end + +function XUiBatchPanel:OnBtnReduceLongClick() + if self.RootUi.CurrentBuyCount <= self.MinCount then + return + end + + if not self.IsInLongClick then self.IsInLongClick = true end + if self.BtnReduceLongCallBack then + self.BtnReduceLongCallBack() + self.BtnClicked = true + self.TxtSelect.text = tostring(self.RootUi.CurrentBuyCount) + end +end + +function XUiBatchPanel:OnBtnMaxClick() + if self.BtnMaxCallBack then + self.BtnMaxCallBack() + self.BtnClicked = true + self.TxtSelect.text = tostring(self.RootUi.CurrentBuyCount) + end +end + +function XUiBatchPanel:OnSelectTextValueChange() + if self.BtnClicked then + self.BtnClicked = false + return + end + if self.SelectTextChangeCallBack then + local num = tonumber(self.TxtSelect.text) + if not num then + num = self.MinCount + end + if num < self.MinCount then + num = self.MinCount + elseif num > self.MaxCount then + num = self.MaxCount + end + self.SelectTextChangeCallBack(num) + if self.TxtSelect.text ~= tostring(self.RootUi.CurrentBuyCount) then + self.TxtSelect.text = tostring(self.RootUi.CurrentBuyCount) + end + end +end + +function XUiBatchPanel:OnSelectTextInputEnd() + if self.SelectTextInputEndCallBack then + local num = tonumber(self.TxtSelect.text) + if not num then + num = self.MinCount + end + if num < self.MinCount then + num = self.MinCount + elseif num > self.MaxCount then + num = self.MaxCount + end + self.SelectTextInputEndCallBack(num) + self.TxtSelect.text = tostring(self.RootUi.CurrentBuyCount) + end +end + +function XUiBatchPanel:AutoRegisterListener() + self.BtnAddSelect.CallBack = function () self:OnBtnAddClick() end + self.BtnMinSelect.CallBack = function () self:OnBtnReduceClick() end + self.BtnMax.CallBack = function () self:OnBtnMaxClick() end + self.BtnAddSelectPointer:RemoveAllListeners() + XUiButtonLongClick.New(self.BtnAddSelectPointer, self.Interval, self, nil, self.OnBtnAddLongClick, nil, true) + self.BtnMinusSelectPointer:RemoveAllListeners() + XUiButtonLongClick.New(self.BtnMinusSelectPointer, self.Interval, self, nil, self.OnBtnReduceLongClick, nil, true) + self.TxtSelect.onValueChanged:RemoveAllListeners() + self.TxtSelect.onValueChanged:AddListener(function() self:OnSelectTextValueChange() end) + self.TxtSelect.onEndEdit:RemoveAllListeners() + self.TxtSelect.onEndEdit:AddListener(function() self:OnSelectTextInputEnd() end) +end + +function XUiBatchPanel:SetSelectTextData() + self.TxtSelect.characterLimit = 4 + self.TxtSelect.contentType = CS.UnityEngine.UI.InputField.ContentType.IntegerNumber +end + +return XUiBatchPanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPurchase/XUiGridPurchaseYK.lua b/Resources/Scripts/XUi/XUiPurchase/XUiGridPurchaseYK.lua new file mode 100644 index 00000000..3b1a8826 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPurchase/XUiGridPurchaseYK.lua @@ -0,0 +1,247 @@ +local XUiGridPurchaseYK = XClass(nil, "XUiGridPurchaseYK") + +local TextManager = CS.XTextManager +local Next = _G.next + +local UiType = +{ + BgMonth = 2, + BgWeek = 13, + BgDay = 14, +} + +local BuyState = { + CanBuy = 1, + NotCanBuy = 2 +} + +local TotalCountLimit +local CountLimit +local TotalCountLimitWeek +local TotalCountLimitDay +local CountLimitWeek + +local Application = CS.UnityEngine.Application +local Platform = Application.platform +local RuntimePlatform = CS.UnityEngine.RuntimePlatform + +function XUiGridPurchaseYK:Ctor(ui, uiroot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiroot + + TotalCountLimit = CS.XGame.ClientConfig:GetInt("PurchaseYKTotalCount") or 1 + CountLimit = CS.XGame.ClientConfig:GetInt("PurchaseYKLimtCount") or 30 + TotalCountLimitWeek = CS.XGame.ClientConfig:GetInt("PurchaseYKTotalCountWeek") or 1 + TotalCountLimitDay = CS.XGame.ClientConfig:GetInt("PurchaseYKTotalCountDay") or 1 + CountLimitWeek = CS.XGame.ClientConfig:GetInt("PurchaseYKLimtCountWeek") or 7 + + XTool.InitUiObject(self) + self:InitUi() + self.RewardItems = {} + self.DailyRewardItems = {} +end + +function XUiGridPurchaseYK:SetBuyClickCallBack(uiroot, callback) + self.UiRoot = uiroot + self.CallBack = callback +end + +function XUiGridPurchaseYK:InitUi() + self.BtnYkBuy.CallBack = function() + self:OnBtnYKBuyClick() + end +end + +function XUiGridPurchaseYK:Refresh(data, needUpdateId) + if data == nil then + return + end + + self.Data = data + + --根据类型判断显示的内容 + self.TextPromptlyGet.gameObject:SetActiveEx(self.Data.UiType == UiType.BgMonth) + self.TextDayGet.gameObject:SetActiveEx(self.Data.UiType == UiType.BgMonth) + self.TextDayGetNotMonth.gameObject:SetActiveEx(self.Data.UiType ~= UiType.BgMonth) + self.PanelNowGet.gameObject:SetActiveEx(self.Data.UiType == UiType.BgMonth) + self.PanelDayGet.gameObject:SetActiveEx(self.Data.UiType == UiType.BgMonth) + self.PanelDayGetNotMonth.gameObject:SetActiveEx(self.Data.UiType ~= UiType.BgMonth) + --self.GetNotMonthPanel.gameObject:SetActiveEx(self.Data.UiType ~= UiType.BgMonth) + + --根据类型显示对应的背景图 + local icon = XPurchaseConfigs.GetPurchaseYKIconById(self.Data.Id) + local bgPathConfig = XPurchaseConfigs.GetIconPathByIconName(icon.Path) + self.ImgMonth:SetRawImage(bgPathConfig.AssetPath) + + if self.Data.UiType == UiType.BgDay then + self.TxtDay.gameObject:SetActiveEx(false) + --self.TxtDay.text = self.Data.MailCount and self.Data.MailCount or 0 + else + self.TxtDay.gameObject:SetActiveEx(false) + end + + local totalCount + local countLimit + if self.Data.UiType == UiType.BgDay then + totalCount = TotalCountLimitDay + countLimit = self.Data.MailCount and self.Data.MailCount or 1 + elseif self.Data.UiType == UiType.BgWeek then + totalCount = TotalCountLimitWeek + countLimit = CountLimitWeek + elseif self.Data.UiType == UiType.BgMonth then + totalCount = self.Data.MailCount > 0 and 1 or TotalCountLimit + countLimit = CountLimit + end + local isMutexPur = XDataCenter.PurchaseManager.CheckMutexPurchaseYKBuy(self.Data.UiType, self.Data.Id) + self.IsMutexPur = isMutexPur + if self.Data.BuyTimes > 0 or isMutexPur then + local curlimitcount = math.ceil(self.Data.DailyRewardRemainDay / countLimit) + self.Txtlimit.text = TextManager.GetText("PurchaseYKBuyLimt", curlimitcount, totalCount) + local clientResetInfo = self.Data.ClientResetInfo + if not isMutexPur and clientResetInfo and clientResetInfo.DayCount >= self.Data.DailyRewardRemainDay and curlimitcount < totalCount then + if self.Data.DailyRewardRemainDay > 0 then + self.BtnYkBuy:SetName(TextManager.GetText("PurchaseYKBuyText2")) + else + local name + local count + if self.Data.PayKeySuffix then + name = TextManager.GetText("PurchaseRiYuanName") + local key + if Platform == RuntimePlatform.Android then + key = string.format("%s%s", XPayConfigs.GetPlatformConfig(1), self.Data.PayKeySuffix) + else + key = string.format("%s%s", XPayConfigs.GetPlatformConfig(2), self.Data.PayKeySuffix) + end + local payConfig = XPayConfigs.GetPayTemplate(key) + count = payConfig.Amount + else + name = XDataCenter.ItemManager.GetItemName(self.Data.ConsumeId) + count = self.Data.ConsumeCount + end + self.BtnYkBuy:SetName(TextManager.GetText("PurchaseYKBuyText1", count, name)) + end + self.CurBuyState = BuyState.CanBuy + else + self.CurBuyState = BuyState.NotCanBuy + self.BtnYkBuy:SetName(TextManager.GetText("PurchaseYKBuyText3")) + end + + if self.Data.UiType == UiType.BgMonth then + self.TxtSurplus.text = TextManager.GetText("PurchaseYKSurplusDay", self.Data.DailyRewardRemainDay > 0 and self.Data.DailyRewardRemainDay - 1 or 0) + else + self.TxtSurplus.text = TextManager.GetText("PurchaseYKSurplusMail", self.Data.DailyRewardRemainDay > 0 and self.Data.DailyRewardRemainDay - 1 or 0) + end + else + self.Txtlimit.text = TextManager.GetText("PurchaseYKBuyLimt", 0, totalCount) + self.CurBuyState = BuyState.CanBuy + + local name + local count + if self.Data.PayKeySuffix then + name = TextManager.GetText("PurchaseRiYuanName") + local key + if Platform == RuntimePlatform.Android then + key = string.format("%s%s", XPayConfigs.GetPlatformConfig(1), self.Data.PayKeySuffix) + else + key = string.format("%s%s", XPayConfigs.GetPlatformConfig(2), self.Data.PayKeySuffix) + end + local payConfig = XPayConfigs.GetPayTemplate(key) + count = payConfig.Amount + else + name = XDataCenter.ItemManager.GetItemName(self.Data.ConsumeId) + count = self.Data.ConsumeCount + end + self.BtnYkBuy:SetName(TextManager.GetText("PurchaseYKBuyText1", count, name)) + + if self.Data.UiType == UiType.BgMonth then + self.TxtSurplus.text = TextManager.GetText("PurchaseYKSurplusDay", 0) + else + self.TxtSurplus.text = TextManager.GetText("PurchaseYKSurplusMail", 0) + end + end + + if needUpdateId and needUpdateId == self.Data.Id then + self.BtnYkBuy:SetName(TextManager.GetText("BuyLimitYKButtonTips")) + end + + self.Txtlimit.gameObject:SetActiveEx(true) + self.TxtSurplus.gameObject:SetActiveEx(true) + self.TxtTotalLimit.gameObject:SetActiveEx(false) + --多日卡并且限购次数为1 + if self.Data.UiType == XPurchaseConfigs.YKType.Day and self.Data.BuyLimitTimes == 1 then + self.TxtSurplus.gameObject:SetActiveEx(false) + self.Txtlimit.gameObject:SetActiveEx(false) + self.TxtTotalLimit.gameObject:SetActiveEx(true) + self.TxtTotalLimit.text = TextManager.GetText("PurchaseYKBuyLimitDayCardTips", self.Data.BuyLimitTimes) + end + + self.TxtYuan.text = self.Data.ConsumeCount + + for i = 1, #self.RewardItems do + self.RewardItems[i].GameObject:SetActiveEx(false) + end + + for i = 1, #self.DailyRewardItems do + self.DailyRewardItems[i].GameObject:SetActiveEx(false) + end + + --显示奖励物品 + if self.Data.RewardGoodsList and next(self.Data.RewardGoodsList) then + local parent = self.Data.UiType == UiType.BgMonth and self.PanelNowGet or self.PanelNowGetNotMonth + for i = 1, #self.Data.RewardGoodsList do + local grid + if not self.RewardItems[i] then + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommon) + grid = XUiGridCommon.New(self.UiRoot, ui) + grid.Transform:SetParent(parent, false) + self.RewardItems[i] = grid + else + grid = self.RewardItems[i] + grid.Transform:SetParent(parent, false) + end + grid:Refresh(self.Data.RewardGoodsList[i]) + grid.GameObject:SetActiveEx(true) + end + if self.Data.UiType ~= UiType.BgMonth then + self.NowGetNotMonthRoot.gameObject:SetActiveEx(true) + end + else + if self.Data.UiType ~= UiType.BgMonth then + self.NowGetNotMonthRoot.gameObject:SetActiveEx(false) + end + end + + if self.Data.DailyRewardGoodsList and next(self.Data.DailyRewardGoodsList) then + local parent = self.Data.UiType == UiType.BgMonth and self.PanelDayGet or self.PanelDayGetNotMonth + for i = 1, #self.Data.DailyRewardGoodsList do + local grid + if not self.DailyRewardItems[i] then + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommon) + grid = XUiGridCommon.New(self.UiRoot, ui) + grid.Transform:SetParent(parent, false) + self.DailyRewardItems[i] = grid + else + grid = self.DailyRewardItems[i] + grid.Transform:SetParent(parent, false) + end + grid:Refresh(self.Data.DailyRewardGoodsList[i]) + grid.GameObject:SetActiveEx(true) + end + if self.Data.UiType ~= UiType.BgMonth then + self.DayGetNotMonthRoot.gameObject:SetActiveEx(true) + end + else + if self.Data.UiType ~= UiType.BgMonth then + self.DayGetNotMonthRoot.gameObject:SetActiveEx(false) + end + end +end + +function XUiGridPurchaseYK:OnBtnYKBuyClick() + if self.CallBack then + self.CallBack(self.Data) + end +end + +return XUiGridPurchaseYK \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPurchase/XUiPurchase.lua b/Resources/Scripts/XUi/XUiPurchase/XUiPurchase.lua new file mode 100644 index 00000000..239cdebf --- /dev/null +++ b/Resources/Scripts/XUi/XUiPurchase/XUiPurchase.lua @@ -0,0 +1,547 @@ +local Object = CS.UnityEngine.Object +local Next = _G.next +local XUiPurchase = XLuaUiManager.Register(XLuaUi, "UiPurchase") +-- local TabsConfig +local PanelNameConfig +local PanelExNameConfig +local LBUiTypes +local YKUiTypes + +local TabExConfig +local UITypeCfg = {} +local XUiPurchasePay = require("XUi/XUiPurchase/XUiPurchasePay") +local XUiPurchasePayAdd = require("XUi/XUiPurchase/XUiPurchasePayAdd") +local XUiPurchaseLB = require("XUi/XUiPurchase/XUiPurchaseLB") +local XUiPurchaseYK = require("XUi/XUiPurchase/XUiPurchaseYK") +-- local XUiPurchaseHK = require("XUi/XUiPurchase/XUiPurchaseHK") +local XUiPurchaseHKShop = require("XUi/XUiPurchase/XUiPurchaseHKShop") +local XUiPurchaseHKExchange = require("XUi/XUiPurchase/XUiPurchaseHKExchange") +local XUiPurchaseCoatingLB = require("XUi/XUiPurchase/XUiPurchaseCoatingLB") +local XUiPurchaseDetail = require("XUi/XUiPurchase/XUiPurchaseDetail") + +local lastTab = nil; + +-- BtnLzcj = 累计充值、LB = 礼包、YK = 月卡、HK = 虹卡 + +local YKUiType = 3 + +function XUiPurchase:OnAwake() + -- TabsConfig = XPurchaseConfigs.TabsConfig + PanelNameConfig = XPurchaseConfigs.PanelNameConfig + PanelExNameConfig = XPurchaseConfigs.PanelExNameConfig + -- TabExConfig = XPurchaseConfigs.TabExConfig + self:GetLBUiTypesList() + self:GetYKUiTypesList() + UITypeCfg = XPurchaseConfigs.GetTabControlUiTypeConfig() + self:InitUi() + XRedPointManager.AddRedPointEvent(self.GameObject, self.LBRedPoint, self, {XRedPointConditions.Types.CONDITION_PURCHASE_LB_RED}) + XRedPointManager.AddRedPointEvent(self.GameObject, self.AccumulateRedPoint, self, {XRedPointConditions.Types.CONDITION_ACCUMULATE_PAY_RED}) +end + +function XUiPurchase:OnEnable() + if self.CurUiView then + self.CurUiView:ShowPanel() + end + XEventManager.AddEventListener(XEventId.EVENT_ACCUMULATED_UPDATE,self.OnAccumulatedUpdate,self) + XEventManager.AddEventListener(XEventId.EVENT_ACCUMULATED_REWARD,self.OnAccumulatedGeted,self) +end + +function XUiPurchase:GetYKUiTypesList() + local t = XPurchaseConfigs.GetYKUiTypes() + YKUiTypes = {} + for _,v in pairs(t)do + YKUiTypes[v] = v + end +end + +function XUiPurchase:OnStart(tab, isClearData, childTabIndex) + self.IsClearData = isClearData + if isClearData == nil then + self.IsClearData = true + end + + self.ChildTabIndex = childTabIndex or 1 + + XDataCenter.PurchaseManager.GetPurchaseListRequest(XPurchaseConfigs.GetLBUiTypesList()) + local t = tab or 1 + self:OnStartSelTab(t) + + local flag = XDataCenter.PurchaseManager.IsAccumulateEnterOpen() + self.BtnLjcz.gameObject:SetActive(flag) + if flag then + local f = XDataCenter.PurchaseManager.AccumulatePayRedPoint() + self.BtnLjcz:ShowReddot(f) + end +end + +function XUiPurchase:AddListener() + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:RegisterClickEvent(self.BtnBack, self.OnBtnReturnClick) + self:RegisterClickEvent(self.BtnLjcz, self.OnBtnPayAddClick) + self.BtnDetail.CallBack = function() + self:OnBtnDetailClick() + end + self:RegisterClickEvent(self.BtnLaw1, self.OnBtnLaw1) + self:RegisterClickEvent(self.BtnLaw2, self.OnBtnLaw2) +end + +function XUiPurchase:OnBtnLaw1() + local lawTxt = CS.XTextManager.GetText("Capitaldecisionmethod") + local lawTitle = CS.XTextManager.GetText("CapitaldecisionmethodTitle") + XLuaUiManager.Open("UiFubenDialog", lawTitle, lawTxt) +end + +function XUiPurchase:OnEnable() + if self.CurUiView then + self.CurUiView:ShowPanel() + end + XEventManager.AddEventListener(XEventId.EVENT_ACCUMULATED_UPDATE,self.OnAccumulatedUpdate,self) + XEventManager.AddEventListener(XEventId.EVENT_ACCUMULATED_REWARD,self.OnAccumulatedGeted,self) +end + +function XUiPurchase:OnGetEvents() +end + +function XUiPurchase:OnNotify() +end + +function XUiPurchase:OnBtnReturnClick() + self:Close() +end + +function XUiPurchase:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiPurchase:OnBtnPayAddClick() + self.PanelLjcz.gameObject:SetActive(true) + self:PlayAnimation("PanelLjczEnable") + self.UiPurchasePayAdd:OnRefresh() +end + +function XUiPurchase:GetLBUiTypesList() + local t = XPurchaseConfigs.GetLBUiTypesList() + LBUiTypes = {} + for _,v in pairs(t)do + LBUiTypes[v] = v + end +end + +function XUiPurchase:IsYKUiType(cfg) + if Next(cfg) then + for _, v in pairs(cfg)do + if YKUiTypes[v.UiType] then + return true + end + end + end +end + +function XUiPurchase:InitUi() + self.TabBtns = {} + self.LBtnIndex = {} + + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAssetPay, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.HongKa) + + local groupTabBtns = {} + self.TabsCfg = XPurchaseConfigs.GetGroupConfigType() + self.TabGroup = self.PanelTopTabGroup:GetComponent("XUiButtonGroup") + for _, v in ipairs(self.TabsCfg) do + local btn = Object.Instantiate(self.BtnPayTab) + btn.gameObject:SetActive(true) + -- btn.gameObject:SetActive(v.GroupId ~= 1) + btn.transform:SetParent(self.PanelTopTabGroup.transform, false) + local btncs = btn:GetComponent("XUiButton") + btncs:SetName(v.GroupName) + local iconPath = XPurchaseConfigs.GetIconPathByIconName(v.GroupIcon) + if iconPath and iconPath.AssetPath then + btn:SetRawImage(iconPath.AssetPath) + end + if self:IsLBUiType(v.Childs) then + btn:ShowReddot(XDataCenter.PurchaseManager.LBRedPoint()) + self.LBBtn = btn + elseif self:IsYKUiType(v.Childs) then + btn:ShowReddot(XDataCenter.PurchaseManager.CheckYKContinueBuy()) + else + btn:ShowReddot(false) + end + table.insert(groupTabBtns, btncs) + end + + self.TabGroup:Init(groupTabBtns, function(tab) self:TabSkip(tab) end) + + local purchaseLBCb = function(skipIndex) + self:OnStartSelTab(skipIndex) + end + + self.LuaUIs = {} + self.LuaUIs[PanelNameConfig.PanelRecharge] = XUiPurchasePay.New(self.PanelRecharge,self,XPurchaseConfigs.TabExConfig.Sample) + self.LuaUIs[PanelNameConfig.PanelLb] = XUiPurchaseLB.New(self.PanelLb,self, purchaseLBCb) + --self.UiPanel[PanelNameConfig.PanelYk] = XUiPurchaseYK.New(self.PanelYk,self) + self.LuaUIs[PanelNameConfig.PanelDh] = XUiPurchaseHKExchange.New(self.PanelDh,self) + self.LuaUIs[PanelNameConfig.PanelHksd] = XUiPurchaseHKShop.New(self.PanelHksd,self) + self.LuaUIs[PanelNameConfig.PanelDh] = XUiPurchaseHKExchange.New(self.PanelDh,self) + + self.LuaUIs[PanelExNameConfig.PanelRecharge] = XUiPurchasePay.New(self.PanelRechargeEx,self,XPurchaseConfigs.TabExConfig.EXTable) + self.LuaUIs[PanelExNameConfig.PanelLb] = XUiPurchaseLB.New(self.PanelLbEx,self, purchaseLBCb) + self.LuaUIs[PanelExNameConfig.PanelYk] = XUiPurchaseYK.New(self.PanelYkEx,self) + + self.LuaUIs[PanelExNameConfig.PanelHksd] = XUiPurchaseHKShop.New(self.PanelHksdEx,self) + self.LuaUIs[PanelExNameConfig.PanelCoatingLb] = XUiPurchaseCoatingLB.New(self.PanelCoatingLbEx, self, purchaseLBCb) + + self.LuaUIs[PanelExNameConfig.PanelHksd] = XUiPurchaseHKShop.New(self.PanelHksdEx,self) + self.LuaUIs[PanelExNameConfig.PanelCoatingLb] = XUiPurchaseCoatingLB.New(self.PanelCoatingLbEx, self, purchaseLBCb) + + self.UiPurchasePayAdd = XUiPurchasePayAdd.New(self.PanelLjcz,self) + self.UiPanelDetail = XUiPurchaseDetail.New(self.PanelDetail, self, function() + self:ClosePanelDetail() + end) + self:AddListener() +end + +function XUiPurchase:SetData() + local cfg = self.TabsCfg[self.CurGroupTab] + if not cfg then + return + end + + local names = XPurchaseConfigs.PanelNameConfig + local childs = cfg.Childs or {} + if #childs > 1 then + -- names = XPurchaseConfigs.PanelExNameConfig + self.Panels.gameObject:SetActive(false) + self.PanelsEx.gameObject:SetActive(true) + self.ImgBgEx.gameObject:SetActive(true) + self.PanelTabGroup.gameObject:SetActive(true) + self:InitGroupTab(self.CurUiTypes) + if self.IsStartAnimation then + self.IsStartAnimation = false + self:PlayAnimation("AnimEnableSmall") + else + self:PlayAnimation("QieHuanSmall") + end + else + self.PanelTabGroup.gameObject:SetActive(false) + self.ImgBgEx.gameObject:SetActive(false) + self.Panels.gameObject:SetActive(true) + self.PanelsEx.gameObject:SetActive(false) + for k,v in pairs(names)do + if k ~= self.CurUiNames[k] then + if self.LuaUIs[k] then + self.LuaUIs[k]:HidePanel() + end + else + self.CurUiView = self.LuaUIs[v] + self.CurUiView:ShowPanel() + self.CurUiView:OnRefresh(self.CurUiTypes[1]) + end + end + if self.IsStartAnimation then + self.IsStartAnimation = false + self:PlayAnimation("AnimEnableBig") + else + self:PlayAnimation("QieHuanBig") + end + end +end + +function XUiPurchase:TabSkip(tab) + if self.CurGroupTab == tab then + return + end + + if tab == 4 then + if self.CurGroupTab then + self.TabGroup:SelectIndex(self.CurGroupTab); + end + XUiManager.TipText("EnPcRechargeCloseTip") + XLog.Debug("暂时屏蔽充值入口"); + return; + end + + local cfg = self.TabsCfg[tab] + if not cfg then + return + end + local childs = cfg.Childs or {} + if Next(childs) == nil then + return + end + + self.CurGroupTab = tab + self.SingleTab = nil + + local names = XPurchaseConfigs.PanelNameConfig + local sendUiTypes = {} + self.CurUiTypes = {} + self.CurUiNames = {} + + -- 充值的读表不需后端数据 + local payUiTypes = XPurchaseConfigs.GetPayUiTypes() + for _, v in pairs(childs) do + if not payUiTypes[v.UiType] then + table.insert(sendUiTypes, v.UiType) + end + + table.insert(self.CurUiTypes, v.UiType) + local cfg = XPurchaseConfigs.GetUiTypeConfigByType(v.UiType) + + if cfg and cfg.UiPrefabStyle then + self.CurUiNames[cfg.UiPrefabStyle] = cfg.UiPrefabStyle + end + end + if self.CurUiView then + self.CurUiView:HidePanel() + end + + if Next(sendUiTypes) ~= nil then + if XDataCenter.PurchaseManager.IsHaveDataByUiTypes(sendUiTypes) then + self:SetData() + else + XDataCenter.PurchaseManager.GetPurchaseListRequest(sendUiTypes,function() + self:SetData() + end) + end + else + if #childs > 1 then + -- names = XPurchaseConfigs.PanelExNameConfig + self.Panels.gameObject:SetActive(false) + self.PanelsEx.gameObject:SetActive(true) + self.ImgBgEx.gameObject:SetActive(true) + self.PanelTabGroup.gameObject:SetActive(true) + self:InitGroupTab(self.CurUiTypes) + if self.IsStartAnimation then + self.IsStartAnimation = false + self:PlayAnimation("AnimEnableSmall") + else + self:PlayAnimation("QieHuanSmall") + end + else + self.PanelTabGroup.gameObject:SetActive(false) + self.ImgBgEx.gameObject:SetActive(false) + self.Panels.gameObject:SetActive(true) + self.PanelsEx.gameObject:SetActive(false) + for k,v in pairs(names)do + if k ~= self.CurUiNames[k] then + self.LuaUIs[k]:HidePanel() + else + self.CurUiView = self.LuaUIs[v] + self.CurUiView:ShowPanel() + self.CurUiView:OnRefresh(self.CurUiTypes[1]) + end + end + if self.IsStartAnimation then + self.IsStartAnimation = false + self:PlayAnimation("AnimEnableBig") + else + self:PlayAnimation("QieHuanBig") + end + end + end +end + +function XUiPurchase:AccumulateRedPoint(result) + if self.BtnLjcz then + self.BtnLjcz:ShowReddot(result >= 0) + end +end + +function XUiPurchase:LBRedPoint(result) + if self.LBBtn then + self.LBBtn:ShowReddot(result >= 0) + end + + local LbRedUiTypes = XDataCenter.PurchaseManager.LBRedPointUiTypes() + if self.Btns and Next(self.LBtnIndex) and Next(LbRedUiTypes) then + for index,uiType in pairs(self.LBtnIndex)do + if uiType and self.Btns[index] then + self.Btns[index]:ShowReddot(LbRedUiTypes[uiType] ~= nil) + end + end + else + if self.Btns and Next(self.Btns) then + for _,btn in pairs(self.Btns)do + if btn then + btn:ShowReddot(false) + end + end + end + end +end + +-- [监听动态列表事件] +function XUiPurchase:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.ListData[index] + grid:OnRefresh(data) + -- elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + end +end + + +function XUiPurchase:OnStartSelTab(t) + local uiTypes = XPurchaseConfigs.GetUiTypesByTab(t) + local cfg = self.TabsCfg + local index = 1 + for k, v in pairs(cfg)do + local childs = v.Childs + for _,c in pairs(childs)do + for _,a in pairs(uiTypes)do + if a.UiType == c.UiType then + index = k + break + end + end + end + end + + self.IsStartAnimation = true + self:TabSkip(index) + self.TabGroup:SelectIndex(index) +end + +function XUiPurchase.UiTypeTabSort(a,b) + if UITypeCfg[a] and UITypeCfg[b] then + return UITypeCfg[a].GroupOrder < UITypeCfg[b].GroupOrder + end + return false +end + +function XUiPurchase:InitGroupTab(uiTypes) + if not self.Btns then + self.Btns = {} + end + + self.LBtnIndex = {} + local LbRedUiTypes = XDataCenter.PurchaseManager.LBRedPointUiTypes() + local i = 0 + for k, v in pairs(uiTypes) do + local purchaseUiTypeConfig = XPurchaseConfigs.GetUiTypeConfigByType(v) + local data = XDataCenter.PurchaseManager.GetDatasByUiType(v) + local isYKType = purchaseUiTypeConfig and purchaseUiTypeConfig.GroupType == YKUiType + if isYKType and (data == nil or #data == 0) then + goto continue + end + + if not self.TabBtns[k] then + local btn = Object.Instantiate(self.BtnTab) + btn.transform:SetParent(self.PanelTabGroup.transform, false) + self.Btns[k] = btn + local btncs = btn:GetComponent("XUiButton") + self.TabBtns[k] = btncs + end + if LbRedUiTypes and LbRedUiTypes[v] then + self.Btns[k]:ShowReddot(true) + self.LBtnIndex[k] = v + else + self.Btns[k]:ShowReddot(false) + end + self.Btns[k].gameObject:SetActive(true) + self.TabBtns[k]:SetName(UITypeCfg[v].Name) + i = i + 1 + + :: continue :: + end + + local len = #self.Btns + if i < len then + for index = i+1, len do + self.Btns[index].gameObject:SetActive(false) + end + end + + self.GroupTabgroup:Init(self.TabBtns, function(tab) self:GroupTabSkip(tab) end) + if next(self.TabBtns) ~= nil then + self.GroupTabgroup:SelectIndex(self.ChildTabIndex) + end +end + +function XUiPurchase:GroupTabSkip(tab) + if self.SingleTab == tab then + return + end + if self.CurGroupTab == 2 then + local tempTab = {} + table.insert(tempTab, XPurchaseConfigs.YKType.Day) + XDataCenter.PurchaseManager.GetPurchaseListRequest(tempTab, function() + self.ChildTabIndex = tab + self:InitGroupTab({XPurchaseConfigs.YKType.Month, XPurchaseConfigs.YKType.Week, XPurchaseConfigs.YKType.Day}) + end) + end + + local cfgs = self.TabsCfg[self.CurGroupTab] + if not cfgs or not cfgs.Childs[tab] then + return + end + + local cfg = XPurchaseConfigs.GetUiTypeConfigByType(cfgs.Childs[tab].UiType) + if not cfg or not cfg.UiPrefabStyle then + return + end + + self.SingleTab = tab + + if self.CurUiView then + self.CurUiView:HidePanel() + end + + local n = PanelExNameConfig[cfg.UiPrefabStyle] + self.CurUiView = self.LuaUIs[n] + self.CurUiView:ShowPanel() + self.CurUiView:OnRefresh(cfg.UiType) + self:PlayAnimation("QieHuanSmall") +end + + +function XUiPurchase:OnAccumulatedUpdate() +end + +function XUiPurchase:OnAccumulatedGeted() + self.UiPurchasePayAdd:SetListData() +end + +function XUiPurchase:OnDisable() + if self.CurUiView then + self.CurUiView:HidePanel() + end + XEventManager.RemoveEventListener(XEventId.EVENT_ACCUMULATED_UPDATE,self.OnAccumulatedUpdate,self) + XEventManager.RemoveEventListener(XEventId.EVENT_ACCUMULATED_REWARD, self.OnAccumulatedGeted,self) +end + +function XUiPurchase:OnDestroy() + self.Btns = nil + if self.IsClearData then + XDataCenter.PurchaseManager.ClearData() + end + + for _,panel in pairs(self.LuaUIs) do + if panel.BuyUiTips then + panel.BuyUiTips:OnDestroy() + end + end +end + +function XUiPurchase:IsLBUiType(cfg) + if Next(cfg) then + for _, v in pairs(cfg)do + if LBUiTypes[v.UiType] then + return true + end + end + end + return false +end + +function XUiPurchase:IsYKUiType(cfg) + if Next(cfg) then + for _, v in pairs(cfg)do + if YKUiTypes[v.UiType] then + return true + end + end + end + return false +end + diff --git a/Resources/Scripts/XUi/XUiPurchase/XUiPurchaseBuyTips.lua b/Resources/Scripts/XUi/XUiPurchase/XUiPurchaseBuyTips.lua new file mode 100644 index 00000000..7f4cd712 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPurchase/XUiPurchaseBuyTips.lua @@ -0,0 +1,769 @@ +local TextManager = CS.XTextManager +local DropdownOptionData = CS.UnityEngine.UI.Dropdown.OptionData +local XUiPurchaseLBTipsListItem = require("XUi/XUiPurchase/XUiPurchaseLBTipsListItem") +local XUiPurchaseSignTip = require("XUi/XUiPurchase/XUiPurchaseSignTip/XUiPurchaseSignTip") +local XUiBatchPanel = require("XUi/XUiPurchase/XUiBatchPanel") +local RestTypeConfig +local LBGetTypeConfig +local Next = _G.next +local UpdateTimerTypeEnum = { + SettOff = 1, + SettOn = 2 +} +local Application = CS.UnityEngine.Application +local Platform = Application.platform +local RuntimePlatform = CS.UnityEngine.RuntimePlatform +local CurrentSchedule = nil + +local XUiPurchaseBuyTips = XLuaUiManager.Register(XLuaUi, "UiPurchaseBuyTips") + +function XUiPurchaseBuyTips:OnAwake() + self:Init() +end + +-- 更新数据 +function XUiPurchaseBuyTips:OnStart(data, checkBuyFun, updateCb, beforeBuyReqFun, uiTypeList,curType) + if not data then + return + end + + self.Data = data + self.CheckBuyFun = checkBuyFun + self.UpdateCb = updateCb + self.BeforeBuyReqFun = beforeBuyReqFun + self.UiTypeList = uiTypeList + self.CurUiType = curType + CS.XAudioManager.PlaySound(1100) + + RestTypeConfig = XPurchaseConfigs.RestTypeConfig + LBGetTypeConfig = XPurchaseConfigs.LBGetTypeConfig + self.CurState = false + self.TimerFun = {} -- 计时器方法表 + self.TitleGoPool = {} + self.ItemPool = {} + self.PurchaseSignTipDic = {} -- 签到礼包的奖励预览脚本实例,key:PrefabPath,value:{ PurchaseSignTip, Resource } + self.OpenBuyTipsList = {} + + -- 检查是否是签到礼包 + if self:CheckSignLBAndOpen() then + return + else + self.PanelSignGiftPack.gameObject:SetActiveEx(false) + end + + self.PanelCommon.gameObject:SetActiveEx(true) + self:AutoRegisterListener() + + self.TxtName.text = data.Name + local path = XPurchaseConfigs.GetIconPathByIconName(data.Icon) + if path and path.AssetPath then + self.RawImageIcon:SetRawImage(path.AssetPath) + end + + -- 下列方法存在公用变量,注意调用顺序 + self:CheckLBIsUseMail() + -- self:SetList() + self:InitAndRegisterTimer() + self:InitAndCheckNormalDiscount() + self:CheckLBRewardIsHave() + self:CheckLBCouponDiscount() + self:InitAndCheckMultiply() + self:SetBuyDes() + + self:StartTimer() +end + +function XUiPurchaseBuyTips:OnEnable() + -- SetList 放在Enable中跳出充值界面返回显示的时候重新刷新奖励列表 + self:SetList() +end + +function XUiPurchaseBuyTips:Init() + self.AssetPanel = XUiPanelAsset.New(self,self.PanelAssetPay,XDataCenter.ItemManager.ItemId.FreeGem,XDataCenter.ItemManager.ItemId.HongKa) +end + +function XUiPurchaseBuyTips:InitBatchPanel() + local batchPanelParam = { + MaxCount = self.MaxBuyCount, + MinCount = 1, + BtnAddCallBack = function() self:OnBtnAddClick() end, + BtnReduceCallBack = function() self:OnBtnReduceClick() end, + BtnAddLongCallBack = function() self:BtnAddLongClick() end, + BtnReduceLongCallBack = function() self:BtnReduceLongClick() end, + BtnMaxCallBack = function() self:OnBtnMaxClick() end, + SelectTextChangeCallBack = function(count) self:OnSelectTextChange(count) end, + SelectTextInputEndCallBack = function(count) self:OnSelectTextInputEnd(count) end, + } + self.BatchPanel = XUiBatchPanel.New(self, self.PanelBatch, batchPanelParam) +end + +function XUiPurchaseBuyTips:OnCouponDropDownValueChanged(index) + if index == 0 then + self.CurDiscountCouponIndex = index + self:RefreshDiscount(index) + else + local discountInfo = self.CurData.DiscountCouponInfos[index] + local couponItemId = discountInfo.ItemId + local couponName = XDataCenter.ItemManager.GetItemName(couponItemId) + if XPurchaseConfigs.GetTagType(self.CurData.Tag) == XPurchaseConfigs.PurchaseTagType.Discount then -- 配置了打折需要进行比较 + local normalDisCountValue = XDataCenter.PurchaseManager.GetLBDiscountValue(self.CurData) + local normalDiscountConsume = math.floor(normalDisCountValue * self.CurData.ConsumeCount) + local couponDisCountValue = XDataCenter.PurchaseManager.GetLBCouponDiscountValue(self.CurData, index) + local couponDisCountConsume = math.floor(couponDisCountValue * self.CurData.ConsumeCount) + if couponDisCountConsume >= normalDiscountConsume then -- 普通打折比选择的打折券便宜 + self.BuyUiTips.DrdSort.value = self.CurDiscountCouponIndex and self.CurDiscountCouponIndex or 0 + XUiManager.TipMsg(TextManager.GetText("NormalDiscountIsBetter")..couponName) + return + end + end + local needCount = discountInfo.ItemCount + local count = XDataCenter.ItemManager.GetCount(couponItemId) + if count < needCount then + self.BuyUiTips.DrdSort.value = self.CurDiscountCouponIndex and self.CurDiscountCouponIndex or 0 + XUiManager.TipMsg(TextManager.GetText("CouponCountInsufficient", needCount)) + return + end + self.CurDiscountCouponIndex = index + self:RefreshDiscount(index) + end +end + +function XUiPurchaseBuyTips:RefreshDiscount(discountItemIndex) -- 打折券刷新显示 + if self.Data.PayKeySuffix then + local key + if Platform == RuntimePlatform.Android then + key = string.format("%s%s", XPayConfigs.GetPlatformConfig(1), self.Data.PayKeySuffix) + else + key = string.format("%s%s", XPayConfigs.GetPlatformConfig(2), self.Data.PayKeySuffix) + end + self.TxtPrice.gameObject:SetActiveEx(false) + local payConfig = XPayConfigs.GetPayTemplate(key) + self.RawImageConsume.gameObject:SetActiveEx(true) + local path = CS.XGame.ClientConfig:GetString("PurchaseBuyRiYuanIconPath") + self.RawImageConsume:SetRawImage(path) + self.BtnBuy:SetName(payConfig.Amount) + else + if discountItemIndex == 0 then + if XPurchaseConfigs.GetTagType(self.Data.Tag) == XPurchaseConfigs.PurchaseTagType.Discount and self.NormalDisCountValue < 1 then -- 打折的 + self.RawImageConsume.gameObject:SetActiveEx(true) + self.BtnBuy:SetName(math.modf(self.Data.ConsumeCount * self.NormalDisCountValue)) + local icon = XDataCenter.ItemManager.GetItemIcon(self.Data.ConsumeId) + if icon then + self.RawImageConsume:SetRawImage(icon) + end + self.TxtPrice.gameObject:SetActiveEx(true) + self.TxtPrice.text = self.Data.ConsumeCount + else + self.BtnBuy:SetName(self.Data.ConsumeCount) + self.TxtPrice.gameObject:SetActiveEx(false) + end + else + local couponDisCountValue = XDataCenter.PurchaseManager.GetLBCouponDiscountValue(self.Data, discountItemIndex) + self.RawImageConsume.gameObject:SetActiveEx(true) + self.BtnBuy:SetName(math.modf(self.Data.ConsumeCount * couponDisCountValue)) + self.TxtPrice.gameObject:SetActiveEx(true) + self.TxtPrice.text = self.Data.ConsumeCount + end + end +end + +-- 更新倒计时 +function XUiPurchaseBuyTips:UpdateTimerFun() + self:UpdateCouponRemainTime() + + self.RemainTime = self.RemainTime - 1 + + if self.RemainTime <= 0 then + self:RemoveTimerFun(self.Data.Id) + if self.UpdateTimerType == UpdateTimerTypeEnum.SettOff then + self.TXtTime.text = TextManager.GetText("PurchaseLBSettOff") + return + end + + self.TXtTime.text = "" + return + end + + if self.UpdateTimerType == UpdateTimerTypeEnum.SettOff then + self.TXtTime.text = TextManager.GetText("PurchaseSetOffTime",XUiHelper.GetTime(self.RemainTime, XUiHelper.TimeFormatType.PURCHASELB)) + return + end + + self.TXtTime.text = TextManager.GetText("PurchaseSetOnTime",XUiHelper.GetTime(self.RemainTime)) +end + +function XUiPurchaseBuyTips:UpdateCouponRemainTime() -- 打折券倒计时更新 + if not self.IsHasCoupon then + return + end + + local nowTime = XTime.GetServerNowTimestamp() + local remainTime = self.AllCouponMaxEndTime - nowTime + if remainTime > 0 then + self.TxtTimeCoupon.text = TextManager.GetText("CouponEndTime", XUiHelper.GetTime(remainTime, XUiHelper.TimeFormatType.SHOP)) + else + self.DrdSort.value = 0 + self.TxtTimeCoupon.text = "" + self.DrdSort.gameObject:SetActiveEx(false) + self.IsHasCoupon = false + end +end + +function XUiPurchaseBuyTips:OnBtnAddClick() + self.CurrentBuyCount = self.CurrentBuyCount + 1 + if self.MaxBuyCount and self.CurrentBuyCount > self.MaxBuyCount then + self.CurrentBuyCount = self.MaxBuyCount + end + self:RefreshBtnBuyPrice() +end + +function XUiPurchaseBuyTips:OnBtnReduceClick() + self.CurrentBuyCount = self.CurrentBuyCount - 1 + if self.CurrentBuyCount < 1 then self.CurrentBuyCount = 1 end + self:RefreshBtnBuyPrice() +end + +function XUiPurchaseBuyTips:BtnAddLongClick() + self:OnBtnAddClick() +end + +function XUiPurchaseBuyTips:BtnReduceLongClick() + self:OnBtnReduceClick() +end + +function XUiPurchaseBuyTips:OnBtnMaxClick() + local consumeCount = self.Data.ConsumeCount + consumeCount = math.floor(self.NormalDisCountValue * consumeCount) + local canBuyCount = math.floor(XDataCenter.ItemManager.GetCount(self.Data.ConsumeId) / consumeCount) + if canBuyCount <= 0 then canBuyCount = 1 end -- 最小可购买数量为1 + + if not self.MaxBuyCount then + if canBuyCount < self.BatchPanel.MaxCount then + self.CurrentBuyCount = canBuyCount + else + self.CurrentBuyCount = self.BatchPanel.MaxCount + end + else + if canBuyCount < self.MaxBuyCount then + self.CurrentBuyCount = canBuyCount + else + self.CurrentBuyCount = self.MaxBuyCount + end + end + self:RefreshBtnBuyPrice() +end + +function XUiPurchaseBuyTips:OnSelectTextChange(count) + self.CurrentBuyCount = count + self:RefreshBtnBuyPrice() +end + +function XUiPurchaseBuyTips:OnSelectTextInputEnd(count) + self.CurrentBuyCount = count + self:RefreshBtnBuyPrice() +end + +function XUiPurchaseBuyTips:CloseTips() + if (self.Data or {}).SignInId and self.Data.SignInId ~= 0 then + -- 签到礼包展示预览关闭 + if (self.PurchaseSignTipDic[self.CurPrefabPath] or {}).PurchaseSignTip then + self.PurchaseSignTipDic[self.CurPrefabPath].PurchaseSignTip:OnClose() + self.CurPrefabPath = nil + end + else + for _,v in pairs(self.ItemPool) do + v.Transform:SetParent(self.PoolGo) + v.GameObject:SetActiveEx(false) + end + + for _,v in pairs(self.TitleGoPool) do + v:SetParent(self.PoolGo) + v.gameObject:SetActiveEx(false) + end + + if self.UpdateTimerType then + self:RemoveTimerFun(self.Data.Id) + end + end + + self:Close() +end + +function XUiPurchaseBuyTips:SetList() + -- 直接获得的道具 + self.ListDirData = {} + self.ListDayData = {} + local rewards0 = self.Data.RewardGoodsList or {} + for _,v in pairs(rewards0) do + v.LBGetType = LBGetTypeConfig.Direct + table.insert(self.ListDirData,v) + end + -- 每日获得的道具 + local rewards1 = self.Data.DailyRewardGoodsList or {} + for _,v in pairs(rewards1) do + v.LBGetType = LBGetTypeConfig.Day + table.insert(self.ListDayData,v) + end + + local index1 = 1 + local index2 = 1 + + if Next(self.ListDirData) ~= nil then + local obj = self:GetTitleGo(index1) + index1 = index1 + 1 + obj.transform:Find("TxtTitle"):GetComponent("Text").text = TextManager.GetText("PurchaseDirGet") + for _,v in pairs(self.ListDirData)do + local item = self:GetItemObj(index2) + item:OnRefresh(v) + index2 = index2 + 1 + end + end + + if Next(self.ListDayData) ~= nil then + local obj = self:GetTitleGo(index1) + obj.transform:Find("TxtTitle"):GetComponent("Text").text = self.Data.Desc or "" + for _,v in pairs(self.ListDayData)do + local item = self:GetItemObj(index2) + item:OnRefresh(v) + index2 = index2 + 1 + end + end +end + +function XUiPurchaseBuyTips:GetTitleGo(index) + if self.TitleGoPool[index] then + self.TitleGoPool[index].gameObject:SetActiveEx(true) + self.TitleGoPool[index]:SetParent(self.PanelReward) + return self.TitleGoPool[index] + end + + local obj = CS.UnityEngine.Object.Instantiate(self.ImgTitle,self.PanelReward) + obj.gameObject:SetActiveEx(true) + obj:SetParent(self.PanelReward) + table.insert(self.TitleGoPool, obj) + return obj +end + +function XUiPurchaseBuyTips:GetItemObj(index) + if self.ItemPool[index] then + self.ItemPool[index].GameObject:SetActiveEx(true) + self.ItemPool[index].Transform:SetParent(self.PanelReward) + return self.ItemPool[index] + end + + local itemObj = CS.UnityEngine.Object.Instantiate(self.PanelPropItem,self.PanelReward) + itemObj.gameObject:SetActiveEx(true) + itemObj:SetParent(self.PanelReward) + local item = XUiPurchaseLBTipsListItem.New(itemObj) + item:Init(self) + table.insert(self.ItemPool, item) + return item +end + +function XUiPurchaseBuyTips:SetBuyDes() + if self.Data.BuyLimitTimes and self.Data.BuyLimitTimes ~= 0 then + local clientResetInfo = self.Data.ClientResetInfo or {} + if Next(clientResetInfo) == nil then --不限时 + -- if self.Data.CanMultiply and self.MaxBuyCount and self.MaxBuyCount > 0 then + if true and self.MaxBuyCount and self.MaxBuyCount > 0 then + self.TxtLimitBuy.gameObject:SetActiveEx(true) + self.TxtLimitBuy.text = TextManager.GetText("PurchaseCanBuyText", self.MaxBuyCount) + else + self.TxtLimitBuy.gameObject:SetActiveEx(false) + end + else -- 限时刷新 + local textKey = nil + if clientResetInfo.ResetType == RestTypeConfig.Interval then + self.TxtLimitBuy.gameObject:SetActiveEx(true) + self.TxtLimitBuy.text = TextManager.GetText("PurchaseRestTypeInterval",clientResetInfo.DayCount,self.Data.BuyTimes,self.Data.BuyLimitTimes) + return + elseif clientResetInfo.ResetType == RestTypeConfig.Day then + textKey = "PurchaseRestTypeDay" + elseif clientResetInfo.ResetType == RestTypeConfig.Week then + textKey = "PurchaseRestTypeWeek" + elseif clientResetInfo.ResetType == RestTypeConfig.Month then + textKey = "PurchaseRestTypeMonth" + end + + if not textKey then + self.TxtLimitBuy.text = "" + self.TxtLimitBuy.gameObject:SetActiveEx(false) + return + end + self.TxtLimitBuy.gameObject:SetActiveEx(true) + self.TxtLimitBuy.text = TextManager.GetText(textKey,self.Data.BuyTimes,self.Data.BuyLimitTimes) + end + else + self.TxtLimitBuy.gameObject:SetActiveEx(false) + end +end + +function XUiPurchaseBuyTips:RefreshBtnBuyPrice() + if self.Data.PayKeySuffix then + local key + if Platform == RuntimePlatform.Android then + key = string.format("%s%s", XPayConfigs.GetPlatformConfig(1), self.Data.PayKeySuffix) + else + key = string.format("%s%s", XPayConfigs.GetPlatformConfig(2), self.Data.PayKeySuffix) + end + self.TxtPrice.gameObject:SetActiveEx(false) + local payConfig = XPayConfigs.GetPayTemplate(key) + self.BtnBuy:SetName(payConfig.Amount) + else + local consumeCount = self.Data.ConsumeCount + if self.Data.ConvertSwitch and self.Data.ConvertSwitch < consumeCount and self.Data.ConvertSwitch > 0 then + consumeCount = self.Data.ConvertSwitch + end + local disCountConsume = math.floor(self.NormalDisCountValue * consumeCount) + self.TxtPrice.text = consumeCount * self.CurrentBuyCount + self.BtnBuy:SetName(disCountConsume * self.CurrentBuyCount) + end +end + +function XUiPurchaseBuyTips:OnDestroy() + self:DestroyTimer() + + if not self.PurchaseSignTipDic or not next(self.PurchaseSignTipDic) then + return + end + + for _, v in pairs(self.PurchaseSignTipDic) do + if v.Resource then + v.Resource:Release() + end + + if v.PurchaseSignTip then + v.PurchaseSignTip:OnClose() + CS.UnityEngine.Object.Destroy(v.PurchaseSignTip.GameObject) + end + end +end + +function XUiPurchaseBuyTips:RegisterTimerFun(id, fun) + if id and fun then + self.TimerFun[id] = fun + end +end + +function XUiPurchaseBuyTips:RemoveTimerFun(id) + if self.TimerFun[id] then + self.TimerFun[id] = nil + end +end + +function XUiPurchaseBuyTips:AutoRegisterListener() + self.BtnBuy.CallBack = function() self:OnBtnBuyClick() end + self.BtnBgClick.CallBack = function() self:CloseTips() end + self.BtnCloseBg.CallBack = function() self:CloseTips() end + + self.DrdSort.onValueChanged:RemoveAllListeners() + self.DrdSort.onValueChanged:AddListener(function(index) self:OnCouponDropDownValueChanged(index) end) +end + +function XUiPurchaseBuyTips:CheckSignLBAndOpen() + if self.Data.SignInId and self.Data.SignInId ~= 0 then + -- 签到礼包展示预览 + self.PanelCommon.gameObject:SetActiveEx(false) + self.PanelSignGiftPack.gameObject:SetActiveEx(true) + + self.BtnSignGiftPackBgClose.CallBack = function() self:CloseTips() end + self.BtnSignGiftPackClose.CallBack = function() self:CloseTips() end + for _, v in pairs(self.PurchaseSignTipDic) do + v.PurchaseSignTip.GameObject:SetActiveEx(false) + end + + self.CurPrefabPath = XSignInConfigs.GetSignPrefabPath(self.Data.SignInId) + local purchaseSignTip = (self.PurchaseSignTipDic[self.CurPrefabPath] or {}).PurchaseSignTip + if not purchaseSignTip then + -- 生成对应prefab的实例 + local resource = CS.XResourceManager.Load(self.CurPrefabPath) + local go = CS.UnityEngine.Object.Instantiate(resource.Asset) + go.transform:SetParent(self.SignGiftPackNode, false) + go.gameObject:SetLayerRecursively(self.SignGiftPackNode.gameObject.layer) + purchaseSignTip = XUiPurchaseSignTip.New(go, self) + + local info = {} + info.PurchaseSignTip = purchaseSignTip + info.Resource = resource + self.PurchaseSignTipDic[self.CurPrefabPath] = info + end + + purchaseSignTip:Refresh(self.Data, function() self:OnBtnBuyClick() end) + purchaseSignTip.GameObject:SetActiveEx(true) + return true + else + return false + end +end + +function XUiPurchaseBuyTips:CheckLBIsUseMail() + local isUseMail = self.Data.IsUseMail or false + self.TxtContinue.gameObject:SetActiveEx(isUseMail) +end + +function XUiPurchaseBuyTips:InitAndRegisterTimer() + self.RemainTime = 0 + self.UpdateTimerType = nil + self.NowTime = XTime.GetServerNowTimestamp() + if self.Data.TimeToInvalid and self.Data.TimeToInvalid > 0 then + self.RemainTime = self.Data.TimeToInvalid - self.NowTime + self.UpdateTimerType = UpdateTimerTypeEnum.SettOff + if self.RemainTime > 0 then--大于0,注册。 + self.TXtTime.gameObject:SetActiveEx(true) + self:RegisterTimerFun(self.Data.Id, function() self:UpdateTimerFun() end) + self.TXtTime.text = TextManager.GetText("PurchaseSetOffTime",XUiHelper.GetTime(self.RemainTime, XUiHelper.TimeFormatType.PURCHASELB)) + else + self.TXtTime.gameObject:SetActiveEx(false) + self:RemoveTimerFun(self.Data.Id) + end + else + if (self.Data.TimeToShelve == nil or self.Data.TimeToShelve == 0) and (self.Data.TimeToUnShelve == nil or self.Data.TimeToUnShelve == 0) then + self.TXtTime.gameObject:SetActiveEx(false) + else + self.TXtTime.gameObject:SetActiveEx(true) + if self.Data.TimeToUnShelve > 0 then + self.RemainTime = self.Data.TimeToUnShelve - self.NowTime + self.UpdateTimerType = UpdateTimerTypeEnum.SettOff + self.TXtTime.text = TextManager.GetText("PurchaseSetOffTime",XUiHelper.GetTime(self.RemainTime, XUiHelper.TimeFormatType.PURCHASELB)) + else + self.RemainTime = self.Data.TimeToShelve-self.NowTime + self.UpdateTimerType = UpdateTimerTypeEnum.SettOn + self.TXtTime.text = TextManager.GetText("PurchaseSetOnTime",XUiHelper.GetTime(self.RemainTime)) + end + if self.RemainTime > 0 then--大于0,注册。 + self:RegisterTimerFun(self.Data.Id, function() self:UpdateTimerFun() end) + else + self:RemoveTimerFun(self.Data.Id) + end + end + end +end + +function XUiPurchaseBuyTips:InitAndCheckNormalDiscount() + if self.Data.PayKeySuffix then + local key + if Platform == RuntimePlatform.Android then + key = string.format("%s%s", XPayConfigs.GetPlatformConfig(1), self.Data.PayKeySuffix) + else + key = string.format("%s%s", XPayConfigs.GetPlatformConfig(2), self.Data.PayKeySuffix) + end + self.TxtPrice.gameObject:SetActiveEx(false) + local payConfig = XPayConfigs.GetPayTemplate(key) + self.RawImageConsume.gameObject:SetActiveEx(true) + local path = CS.XGame.ClientConfig:GetString("PurchaseBuyRiYuanIconPath") + self.RawImageConsume:SetRawImage(path) + self.BtnBuy:SetName(payConfig.Amount) + else + self.NormalDisCountValue = XDataCenter.PurchaseManager.GetLBDiscountValue(self.Data) + self.IsDisCount = XPurchaseConfigs.GetTagType(self.Data.Tag) == XPurchaseConfigs.PurchaseTagType.Discount and self.NormalDisCountValue < 1 + if self.Data.ConsumeCount == 0 then + self.TxtPrice.gameObject:SetActiveEx(false) + self.RawImageConsume.gameObject:SetActiveEx(false) + self.BtnBuy:SetName(TextManager.GetText("PurchaseFreeText")) + else + self.RawImageConsume.gameObject:SetActiveEx(true) + if self.IsDisCount then -- 打折的 + self.BtnBuy:SetName(math.modf(self.Data.ConsumeCount * self.NormalDisCountValue)) + self.TxtPrice.gameObject:SetActiveEx(true) + self.TxtPrice.text = self.Data.ConsumeCount + else + self.TxtPrice.gameObject:SetActiveEx(false) + self.BtnBuy:SetName(self.Data.ConsumeCount) + end + + local icon = XDataCenter.ItemManager.GetItemIcon(self.Data.ConsumeId) + if icon then + self.RawImageConsume:SetRawImage(icon) + end + end + end +end + +function XUiPurchaseBuyTips:CheckLBRewardIsHave() + if self.Data.ConvertSwitch and self.Data.ConvertSwitch < self.Data.ConsumeCount and not self.Data.PayKeySuffix then -- 礼包存在已拥有物品折扣 --日服不判断礼包存在已拥有物品折扣 + local remainPrice = self.Data.ConvertSwitch + if remainPrice < 0 then remainPrice = 0 end + if remainPrice == 0 then -- 全部都拥有 + self.TxtHave.gameObject:SetActiveEx(true) + self.TxtHave.text = TextManager.GetText("PurchaseLBHaveFashion") + self.BtnBuy:SetName(TextManager.GetText("PurchaseLBDontNeed")) + self.BtnBuy:SetDisable(true, true) + local path = CS.XGame.ClientConfig:GetString("PurchaseBuyRiYuanIconPath1") + self.RawImageConsume:SetRawImage(path) + else -- 未拥有和拥有同时存在 + self.TxtHave.gameObject:SetActiveEx(true) + self.TxtHave.text = TextManager.GetText("PurchaseLBHaveFashion") + self.BtnBuy:SetDisable(false) + if self.IsDisCount then + remainPrice = math.modf(remainPrice * self.NormalDisCountValue) + end + self.BtnBuy:SetName(remainPrice) + self.TxtPrice.gameObject:SetActiveEx(true) + self.TxtPrice.text = self.Data.ConsumeCount + local path = CS.XGame.ClientConfig:GetString("PurchaseBuyRiYuanIconPath") + self.RawImageConsume:SetRawImage(path) + end + else + -- 默认检测是否已拥有逻辑 + local isHave, isLimitTime = XRewardManager.CheckRewardGoodsListIsOwn(self.Data.RewardGoodsList) + local isShowHave = isHave and not isLimitTime + self.TxtHave.gameObject:SetActiveEx(isShowHave) + self.TxtPrice.gameObject:SetActiveEx(false) + if isShowHave then + if #self.Data.RewardGoodsList > 1 then + self.TxtHave.text = TextManager.GetText("PurchaseLBHaveFashion") + self.BtnBuy:SetDisable(not isShowHave) + local icon = XDataCenter.ItemManager.GetItemIcon(self.Data.ConsumeId) + if icon then + self.RawImageConsume:SetRawImage(icon) + end + else + self.TxtHave.text = TextManager.GetText("PurchaseLBHaveFashionCantBuy") + self.BtnBuy:SetDisable(isShowHave, not isShowHave) + local path = CS.XGame.ClientConfig:GetString("PurchaseBuyRiYuanIconPath1") + self.RawImageConsume:SetRawImage(path) + end + else + self.BtnBuy:SetDisable(false) + if (self.Data.BuyLimitTimes > 0 and self.Data.BuyTimes == self.Data.BuyLimitTimes) or (self.Data.TimeToShelve > 0 and self.Data.TimeToShelve <= self.NowTime) or (self.Data.TimeToUnShelve > 0 and self.Data.TimeToUnShelve <= self.NowTime) then --卖完了,不管。 + self.TXtTime.text = "" + if self.UpdateTimerType then + self:RemoveTimerFun(self.Data.Id) + end + self.TxtPrice.gameObject:SetActiveEx(false) + self.BtnBuy:SetButtonState(XUiButtonState.Disable) + if self.Data.ConsumeId ~= 0 then + local icon = XDataCenter.ItemManager.GetItemIcon(self.Data.ConsumeId) + if icon then + self.RawImageConsume:SetRawImage(icon) + end + end + else + self.BtnBuy:SetButtonState(XUiButtonState.Normal) + if self.Data.ConsumeId ~= 0 then + local icon = XDataCenter.ItemManager.GetItemIcon(self.Data.ConsumeId) + if icon then + self.RawImageConsume:SetRawImage(icon) + end + end + end + end + end +end + +function XUiPurchaseBuyTips:CheckLBCouponDiscount() + if self.Data.DiscountCouponInfos and #self.Data.DiscountCouponInfos > 0 then + self.CurDiscountCouponIndex = 0 + self.DrdSort.gameObject:SetActiveEx(true) + self.DrdSort:ClearOptions() + local od = DropdownOptionData(TextManager.GetText("UnUsedCouponDiscount")) + self.DrdSort.options:Add(od) + self.DrdSort.captionText.text = TextManager.GetText("UnUsedCouponDiscount") + self.AllCouponMaxEndTime = 0 + for _, optionData in ipairs(self.Data.DiscountCouponInfos) do + local itemId = optionData.ItemId + local itemName = XDataCenter.ItemManager.GetItemName(itemId) + local count = XDataCenter.ItemManager.GetCount(itemId) + local od = DropdownOptionData(itemName..TextManager.GetText("DiscountCouponRemain", count)) + self.DrdSort.options:Add(od) + if optionData.EndTime > self.AllCouponMaxEndTime then + self.AllCouponMaxEndTime = optionData.EndTime + end + end + self.DrdSort.value = 0 + self.TxtTimeCoupon.text = TextManager.GetText("CouponEndTime", XUiHelper.GetTime(self.AllCouponMaxEndTime - self.NowTime, XUiHelper.TimeFormatType.SHOP)) + self.IsHasCoupon = true + else + self.DrdSort.gameObject:SetActiveEx(false) + self.IsHasCoupon = false + end +end + +function XUiPurchaseBuyTips:InitAndCheckMultiply() + self.CurrentBuyCount = 1 -- 每次打开把购买数量重置为1 + local isSellOut = self.Data.BuyLimitTimes and self.Data.BuyLimitTimes > 0 and self.Data.BuyTimes == self.Data.BuyLimitTimes + if not isSellOut and self.Data.CanMultiply then -- 批量购买开关 + self.MaxBuyCount = XDataCenter.PurchaseManager.GetPurchaseMaxBuyCount(self.Data) + self:InitBatchPanel() + self.PanelBatch.gameObject:SetActiveEx(true) + self:RefreshBtnBuyPrice() + else + self.MaxBuyCount = nil + self.PanelBatch.gameObject:SetActiveEx(false) + end +end + +function XUiPurchaseBuyTips:OnBtnBuyClick() + if self.CheckBuyFun then -- 存在检测函数 + if self.CheckBuyFun(self.CurrentBuyCount, self.CurDiscountCouponIndex) then + if self.BeforeBuyReqFun then -- 购买前执行函数 + self.BeforeBuyReqFun(function() self:BuyPurchaseRequest() end) + return + end + self:BuyPurchaseRequest() + else + self:CloseTips() + end + else + self:BuyPurchaseRequest() + end +end + +function XUiPurchaseBuyTips:BuyPurchaseRequest() + if self.Data.PayKeySuffix then + local key + if Platform == RuntimePlatform.Android then + key = string.format("%s%s", XPayConfigs.GetPlatformConfig(1), self.Data.PayKeySuffix) + else + key = string.format("%s%s", XPayConfigs.GetPlatformConfig(2), self.Data.PayKeySuffix) + end + if self.CurUiType ~= nil then + XDataCenter.PayManager.Pay(key, 1, { self.Data.Id,self.CurUiType}, self.Data.Id) + else + XDataCenter.PayManager.Pay(key, 1, { self.Data.Id}, self.Data.Id) + end + self:CloseTips() + else + if self.Data and self.Data.Id then + if not self.CurrentBuyCount or self.CurrentBuyCount == 0 then + self.CurrentBuyCount = 1 + end + local discountCouponId = nil + if self.CurDiscountCouponIndex and self.CurDiscountCouponIndex ~= 0 then + discountCouponId = self.CurData.DiscountCouponInfos[self.CurDiscountCouponIndex].Id + end + XDataCenter.PurchaseManager.PurchaseRequest(self.Data.Id, self.UpdateCb, self.CurrentBuyCount, discountCouponId, self.UiTypeList) + self:CloseTips() + end + end +end + +function XUiPurchaseBuyTips:StartTimer() + if self.IsTimerStart then + return + end + + if CurrentSchedule then + XScheduleManager.UnSchedule(CurrentSchedule) + CurrentSchedule = nil + end + + CurrentSchedule = XScheduleManager.ScheduleForever(function() self:UpdateTimer() end, 1000) + self.IsTimerStart = true +end + +function XUiPurchaseBuyTips:DestroyTimer() + if CurrentSchedule then + XScheduleManager.UnSchedule(CurrentSchedule) + CurrentSchedule = nil + self.IsTimerStart = false + end +end + +function XUiPurchaseBuyTips:UpdateTimer() + if self.TimerFun and next(self.TimerFun) then + for _, fun in pairs(self.TimerFun) do + fun() + end + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPurchase/XUiPurchaseCoatingLB.lua b/Resources/Scripts/XUi/XUiPurchase/XUiPurchaseCoatingLB.lua new file mode 100644 index 00000000..18fcae85 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPurchase/XUiPurchaseCoatingLB.lua @@ -0,0 +1,430 @@ +local XUiPurchaseCoatingLB = XClass(nil, "XUiPurchaseCoatingLB") +local Next = _G.next +local CSXTextManagerGetText = CS.XTextManager.GetText +local XUiPurchaseCoatingLBListItem = require("XUi/XUiPurchase/XUiPurchaseCoatingLBListItem") +local CurrentSchedule = nil +local Application = CS.UnityEngine.Application +local Platform = Application.platform +local RuntimePlatform = CS.UnityEngine.RuntimePlatform + +function XUiPurchaseCoatingLB:Ctor(ui,uiRoot, callBack) + self.CurState = false + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.CallBack = callBack + self.UiRoot = uiRoot + self.TimeFuns = {} + self.TimeSaveFuns = {} + XTool.InitUiObject(self) + self.ListData = {} + self.IsCheckOpenAddTimeTips = false + self.TipsTemplateContentList = {} + self.OpenBuyTipsList = {} + self:Init() +end + +-- 先分类后排序 +function XUiPurchaseCoatingLB:OnSortFun(data) + self.SellOutList = {}--买完了 + self.SellingList = {}--在上架中 + self.SellOffList = {}--下架了 + self.SellWaitList = {}--待上架中 + self.ListData = {} + + local nowTime = XTime.GetServerNowTimestamp() + for _,v in pairs(data)do + if v and not v.IsSelloutHide then + if v.TimeToUnShelve > 0 and v.TimeToUnShelve <= nowTime then--下架了 + table.insert(self.SellOffList,v) + elseif v.TimeToShelve > 0 and v.TimeToShelve > nowTime then--待上架中 + table.insert(self.SellWaitList,v) + elseif v.BuyTimes > 0 and v.BuyLimitTimes > 0 and v.BuyTimes >= v.BuyLimitTimes then--买完了 + table.insert(self.SellOutList,v) + else --在上架中,还能买。 + table.insert(self.SellingList,v) + end + end + end + + --在上架中,还能买。 + if Next(self.SellingList) then + table.sort(self.SellingList, XUiPurchaseCoatingLB.SortByPriority) + for _,v in pairs(self.SellingList) do + table.insert(self.ListData, v) + end + end + + --待上架中 + if Next(self.SellWaitList) then + table.sort(self.SellWaitList, XUiPurchaseCoatingLB.SortByPriority) + for _,v in pairs(self.SellWaitList) do + table.insert(self.ListData, v) + end + end + + --买完了 + if Next(self.SellOutList) then + table.sort(self.SellOutList, XUiPurchaseCoatingLB.SortByPriority) + for _,v in pairs(self.SellOutList) do + table.insert(self.ListData, v) + end + end + + --下架了 + if Next(self.SellOffList) then + table.sort(self.SellOffList, XUiPurchaseCoatingLB.SortByPriority) + for _,v in pairs(self.SellOffList) do + table.insert(self.ListData, v) + end + end + +end + +function XUiPurchaseCoatingLB.SortByPriority(a,b) + return a.Priority < b.Priority +end + +function XUiPurchaseCoatingLB:StartLBTimer() + if self.IsStart then + return + end + + self.IsStart = true + CurrentSchedule = XScheduleManager.ScheduleForever(function() self:UpdateLBTimer()end, 1000) +end + +function XUiPurchaseCoatingLB:UpdateLBTimer() + if Next(self.TimeFuns) then + for _,timerFun in pairs(self.TimeFuns)do + if timerFun then + timerFun() + end + end + return + end + self:DestroyTimer() +end + +function XUiPurchaseCoatingLB:RemoveTimerFun(id) + self.TimeFuns[id] = nil +end + +function XUiPurchaseCoatingLB:RecoverTimerFun(id) + self.TimeFuns[id] = self.TimeSaveFuns[id] + if self.TimeFuns[id] then + self.TimeFuns[id](true) + end + self.TimeSaveFuns[id] = nil +end + +function XUiPurchaseCoatingLB:RegisterTimerFun(id,fun,isSave) + if not isSave then + self.TimeFuns[id] = fun + return + end + + self.TimeSaveFuns[id] = self.TimeFuns[id] + self.TimeFuns[id] = fun + +end + +-- 更新数据 +function XUiPurchaseCoatingLB:OnRefresh(uiType) + local data = XDataCenter.PurchaseManager.GetDatasByUiType(uiType) + if not data then + return + end + + self.CurUiType = uiType + self.GameObject:SetActive(true) + if Next(data) ~= nil then + self:OnSortFun(data) + end + self.TimeFuns = {} + self.TimeSaveFuns = {} + self.DynamicTable:SetDataSource(self.ListData) + self.DynamicTable:ReloadDataASync(1) + self:StartLBTimer() +end + +function XUiPurchaseCoatingLB:OnUpdate(rewardList) + if self.IsCheckOpenAddTimeTips then + self:CheckAddTimeTips(rewardList) + self.IsCheckOpenAddTimeTips = false + end + if self.CurUiType then + self:OnRefresh(self.CurUiType) + end +end + +function XUiPurchaseCoatingLB:HidePanel() + self:DestroyTimer() + XEventManager.RemoveEventListener(XEventId.EVENT_PURCAHSE_BUYUSERIYUAN, self.OnUpdate, self) + self.GameObject:SetActive(false) +end + +function XUiPurchaseCoatingLB:ShowPanel() + XEventManager.AddEventListener(XEventId.EVENT_PURCAHSE_BUYUSERIYUAN, self.OnUpdate, self) + self.GameObject:SetActive(true) +end + +function XUiPurchaseCoatingLB:DestroyTimer() + if CurrentSchedule then + self.IsStart = false + XScheduleManager.UnSchedule(CurrentSchedule) + CurrentSchedule = nil + end +end + +function XUiPurchaseCoatingLB:Init() + self:InitList() + self.CheckBuyFun = function(count, disCountCouponIndex) return self:CheckBuy(count, disCountCouponIndex) end + self.BeforeBuyReqFun = function(successCb) self:CheckIsOpenBuyTips(successCb) end + self.UpdateCb = function(rewardList) self:OnUpdate(rewardList) end +end + +function XUiPurchaseCoatingLB:InitList() + self.DynamicTable = XDynamicTableNormal.New(self.Transform) + self.DynamicTable:SetProxy(XUiPurchaseCoatingLBListItem) + self.DynamicTable:SetDelegate(self) +end + +-- [监听动态列表事件] +function XUiPurchaseCoatingLB:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self.UiRoot,self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.ListData[index] + grid:OnRefresh(data) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + local data = self.ListData[index] + if not data then + return + end + + XDataCenter.PurchaseManager.RemoveNotInTimeDiscountCoupon(data) -- 移除未到时间的打折券 + self.CurData = data + self:OpenUiView(data) + CS.XAudioManager.PlaySound(1011) + end +end + +function XUiPurchaseCoatingLB:OpenUiView(data) + local templateId, isWeaponFashion = self:CheckSingleFashion(data) + if templateId then + local isHave, isLimitTime = XRewardManager.CheckRewardGoodsListIsOwn(data.RewardGoodsList) + local disCountValue = XDataCenter.PurchaseManager.GetLBDiscountValue(data) + + local buyData = {} + if data.PayKeySuffix then + buyData.ItemIcon = CS.XGame.ClientConfig:GetString("PurchaseBuyRiYuanIconPath") + else + buyData.ItemIcon = XDataCenter.ItemManager.GetItemIcon(data.ConsumeId) + end + buyData.PayKeySuffix = data.PayKeySuffix + buyData.IsHave = isHave and not isLimitTime + buyData.ItemCount = math.modf(data.ConsumeCount * disCountValue) + buyData.BuyCallBack = function() self:FashionDetailBuyCB() end + XLuaUiManager.Open("UiFashionDetail", templateId, isWeaponFashion, buyData) + else + XLuaUiManager.Open("UiPurchaseBuyTips", data, self.CheckBuyFun, self.UpdateCb, self.BeforeBuyReqFun, XPurchaseConfigs.GetLBUiTypesList()) + end +end + +-- 检测是否礼包内是否只有一件物品且为时装 +function XUiPurchaseCoatingLB:CheckSingleFashion(data) + if #(data.RewardGoodsList) == 1 then + local good = data.RewardGoodsList[1] + if good.RewardType == XRewardManager.XRewardType.Fashion then + return good.TemplateId, false + elseif good.RewardType == XRewardManager.XRewardType.WeaponFashion then + return good.TemplateId, true + elseif XDataCenter.ItemManager.IsWeaponFashion(good.TemplateId) then + local templateId = XDataCenter.ItemManager.GetWeaponFashionId(good.TemplateId) + return templateId, true + end + end + return false +end + +function XUiPurchaseCoatingLB:FashionDetailBuyCB() + if self:CheckBuy() then + if self.CurData.PayKeySuffix then --判断是不是直购礼包 + local key + if Platform == RuntimePlatform.Android then + key = string.format("%s%s", XPayConfigs.GetPlatformConfig(1), self.CurData.PayKeySuffix) + else + key = string.format("%s%s", XPayConfigs.GetPlatformConfig(2), self.CurData.PayKeySuffix) + end + XDataCenter.PayManager.Pay(key, 1, { self.CurData.Id }, self.CurData.Id) + else + if self.CurData and self.CurData.Id then + XDataCenter.PurchaseManager.PurchaseRequest(self.CurData.Id, self.UpdateCb, 1, nil, XPurchaseConfigs.GetLBUiTypesList()) + end + end + end +end + +function XUiPurchaseCoatingLB:CheckBuy(count, disCountCouponIndex) + count = count or 1 + disCountCouponIndex = disCountCouponIndex or 0 + + if not XDataCenter.PayManager.CheckCanBuy(self.CurData.Id) then + return false + end + + if self.CurData.BuyLimitTimes > 0 and self.CurData.BuyTimes == self.CurData.BuyLimitTimes then --卖完了,不管。 + XUiManager.TipText("PurchaseLiSellOut") + return false + end + + if self.CurData.TimeToShelve > 0 and self.CurData.TimeToShelve > XTime.GetServerNowTimestamp() then --没有上架 + XUiManager.TipText("PurchaseBuyNotSet") + return false + end + + if self.CurData.TimeToUnShelve > 0 and self.CurData.TimeToUnShelve < XTime.GetServerNowTimestamp() then --下架了 + XUiManager.TipText("PurchaseSettOff") + return false + end + + if self.CurData.TimeToInvalid > 0 and self.CurData.TimeToInvalid < XTime.GetServerNowTimestamp() then --失效了 + XUiManager.TipText("PurchaseSettOff") + return false + end + + if self.CurData.ConsumeCount > 0 and self.CurData.ConvertSwitch <= 0 then -- 礼包内容全部拥有 + XUiManager.TipText("PurchaseRewardAllHaveErrorTips") + return false + end + + local consumeCount = self.CurData.ConsumeCount + if disCountCouponIndex and disCountCouponIndex ~= 0 then + local disCountValue = XDataCenter.PurchaseManager.GetLBCouponDiscountValue(self.CurData, disCountCouponIndex) + consumeCount = math.floor(disCountValue * consumeCount) + else + if self.CurData.ConvertSwitch and consumeCount > self.CurData.ConvertSwitch then -- 已经被服务器计算了抵扣和折扣后的钱 + consumeCount = self.CurData.ConvertSwitch + end + + if XPurchaseConfigs.GetTagType(self.CurData.Tag) == XPurchaseConfigs.PurchaseTagType.Discount then -- 计算打折后的钱(普通打折或者选择了打折券) + local disCountValue = XDataCenter.PurchaseManager.GetLBDiscountValue(self.CurData) + consumeCount = math.floor(disCountValue * consumeCount) + end + end + + if consumeCount > 0 and consumeCount > XDataCenter.ItemManager.GetCount(self.CurData.ConsumeId) then --钱不够 + local name = XDataCenter.ItemManager.GetItemName(self.CurData.ConsumeId) or "" + local tips = CSXTextManagerGetText("PurchaseBuyKaCountTips", name) + XUiManager.TipMsg(tips,XUiManager.UiTipType.Wrong) + if self.CurData.ConsumeId == XDataCenter.ItemManager.ItemId.PaidGem then + self.CallBack(XPurchaseConfigs.TabsConfig.HK) + elseif self.CurData.ConsumeId == XDataCenter.ItemManager.ItemId.HongKa then + self.CallBack(XPurchaseConfigs.TabsConfig.Pay) + end + return false + end + + return true +end + +function XUiPurchaseCoatingLB:CheckIsOpenBuyTips(successCb) + if self.CurData.ConvertSwitch and self.CurData.ConsumeCount > self.CurData.ConvertSwitch then -- 礼包被计算拥有物品折扣价后,拥有物品不会下发,所以无需二次提示转化碎片 + if successCb then successCb() end + return + end + + local rewardGoodsList = self.CurData.RewardGoodsList + if not rewardGoodsList then + if successCb then successCb() end + return + end + + for _, v in pairs(rewardGoodsList) do + if XRewardManager.IsRewardWeaponFashion(v.RewardType, v.TemplateId) then + local isHave, ownRewardIsLimitTime, rewardIsLimitTime, leftTime = XRewardManager.CheckRewardOwn(v.RewardType, v.TemplateId) + if isHave then + if not ownRewardIsLimitTime or not rewardIsLimitTime then + local tipContent = {} + tipContent["title"] = CSXTextManagerGetText("WeaponFashionConverseTitle") + if ownRewardIsLimitTime and not rewardIsLimitTime then --自己拥有的武器涂装是限时的去买永久的 + local timeText = XUiHelper.GetTime(leftTime, XUiHelper.TimeFormatType.ACTIVITY) + tipContent["content"] = #rewardGoodsList > 1 and CSXTextManagerGetText("OwnLimitBuyForeverWeaponFashionGiftConverseText", timeText) or CSXTextManagerGetText("OwnLimitBuyForeverWeaponFashionConverseText", timeText) + elseif not ownRewardIsLimitTime and rewardIsLimitTime then --自己拥有的武器涂装是永久的去买限时的 + tipContent["content"] = CSXTextManagerGetText("OwnForeverBuyLimitWeaponFashionConverseText") + elseif not ownRewardIsLimitTime and not rewardIsLimitTime then --自己拥有的武器涂装是永久的去买永久的 + tipContent["content"] = CSXTextManagerGetText("OwnForeverBuyForeverWeaponFashionConverseText") + end + table.insert(self.OpenBuyTipsList, tipContent) + else + --自己拥有的武器涂装是限时的去买限时的 + self.IsCheckOpenAddTimeTips = true + end + end + elseif XRewardManager.IsRewardFashion(v.RewardType, v.TemplateId) and XRewardManager.CheckRewardOwn(v.RewardType, v.TemplateId) then + local tipContent = {} + tipContent["title"] = CSXTextManagerGetText("PurchaseFashionRepeatTipsTitle") + tipContent["content"] = CSXTextManagerGetText("PurchaseFashionRepeatTipsContent") + table.insert(self.OpenBuyTipsList, tipContent) + end + end + + if #self.OpenBuyTipsList > 0 then + self:OpenBuyTips(successCb) + return + end + + if successCb then successCb() end +end + +function XUiPurchaseCoatingLB:OpenBuyTips(successCb) + if #self.OpenBuyTipsList > 0 then + local tipContent = table.remove(self.OpenBuyTipsList, 1) + local sureCallback = function () + if #self.OpenBuyTipsList > 0 then + self:OpenBuyTips() + else + if successCb then successCb() end + end + end + local closeCallback = function() + self.OpenBuyTipsList = {} + end + XUiManager.DialogTip(tipContent["title"], tipContent["content"], XUiManager.DialogType.Normal, closeCallback, sureCallback) + end +end + +function XUiPurchaseCoatingLB:CheckAddTimeTips(rewardList) + if not rewardList then return end + local descStr + for _, v in pairs(rewardList) do + if XRewardManager.IsRewardWeaponFashion(v.RewardType, v.TemplateId)then + descStr = self:GetRewardWeaponFashionDescStr(v.TemplateId) + if descStr then + table.insert(self.TipsTemplateContentList, descStr) + end + end + end + self:OpenAddTimeTips() +end + +function XUiPurchaseCoatingLB:GetRewardWeaponFashionDescStr(templateId) + local weaponFashionId = XDataCenter.ItemManager.GetWeaponFashionId(templateId) + local weaponFashion = XDataCenter.WeaponFashionManager.GetWeaponFashion(weaponFashionId) + local time = XDataCenter.ItemManager.GetWeaponFashionAddTime(templateId) + if weaponFashion and weaponFashion:IsTimeLimit() and time then + --此时提示叠加时长信息 + local addTime = XUiHelper.GetTime(time, XUiHelper.TimeFormatType.DEFAULT) + local weaponFashionName = XDataCenter.WeaponFashionManager.GetWeaponFashionName(weaponFashionId) + return CSXTextManagerGetText("WeaponFashionLimitGetAlreadyHaveLimit", weaponFashionName, addTime) + end +end + +function XUiPurchaseCoatingLB:OpenAddTimeTips() + if #self.TipsTemplateContentList > 0 then + local content = table.remove(self.TipsTemplateContentList) + XUiManager.TipMsg(content, nil, function() self:OpenAddTimeTips() end) + end +end + +return XUiPurchaseCoatingLB \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPurchase/XUiPurchaseCoatingLBListItem.lua b/Resources/Scripts/XUi/XUiPurchase/XUiPurchaseCoatingLBListItem.lua new file mode 100644 index 00000000..ec438067 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPurchase/XUiPurchaseCoatingLBListItem.lua @@ -0,0 +1,305 @@ +local XUiPurchaseCoatingLBListItem = XClass(nil, "XUiPurchaseCoatingLBListItem") +local TextManager = CS.XTextManager +local RestTypeConfig +local Next = _G.next +local Application = CS.UnityEngine.Application +local Platform = Application.platform +local RuntimePlatform = CS.UnityEngine.RuntimePlatform +local UpdateTimerTypeEnum = { + SettOff = 1, + SettOn = 2 +} +function XUiPurchaseCoatingLBListItem:Ctor(ui, uiRoot) + RestTypeConfig = XPurchaseConfigs.RestTypeConfig + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + XTool.InitUiObject(self) + self.OriginSize = self.ImgIconLb.rectTransform.sizeDelta + self.originUnShelveColor = self.TxtUnShelveTime2.color; + self.TimerUpdateCb = function(isRecover) self:UpdateTimer(isRecover) end +end + +-- 更新数据 +function XUiPurchaseCoatingLBListItem:OnRefresh(itemData) + if not itemData then + return + end + + self.ItemData = itemData + self:SetData() +end + +function XUiPurchaseCoatingLBListItem:Init(uiRoot, parent) + self.UiRoot = uiRoot + self.Parent = parent +end + +function XUiPurchaseCoatingLBListItem:SetData() + if self.ItemData.Icon then + local iconPath = XPurchaseConfigs.GetIconPathByIconName(self.ItemData.Icon) + if iconPath then + if iconPath.CoverImgPath then + self.ImgIconLb:SetRawImage(iconPath.CoverImgPath, function() self.ImgIconLb.rectTransform.sizeDelta = self.OriginSize end) + elseif iconPath.AssetPath then + self.ImgIconLb:SetRawImage(iconPath.AssetPath, function() self.ImgIconLb:SetNativeSize() end) + end + end + end + self.TxtName.text = self.ItemData.Name + self.ImgSellout.gameObject:SetActive(false) + self.TxtUnShelveTime.gameObject:SetActive(false) + self.Parent:RemoveTimerFun(self.ItemData.Id) + self.RemainTime = 0 + local nowTime = XTime.GetServerNowTimestamp() + + self.IsDisCount = false + local tag = self.ItemData.Tag + local isShowTag = false + if tag > 0 then + isShowTag = true + local path = XPurchaseConfigs.GetTagBgPath(tag) + if path then + self.UiRoot:SetUiSprite(self.ImgTagBg, path) + end + local tagText = XPurchaseConfigs.GetTagDes(tag) + + if XPurchaseConfigs.GetTagType(tag) == XPurchaseConfigs.PurchaseTagType.Discount then + local disCountValue = XDataCenter.PurchaseManager.GetLBDiscountValue(self.ItemData) + if disCountValue < 1 then + local disCountStr = string.format("%.1f", disCountValue * 10) + if self.ItemData.DiscountShowStr and self.ItemData.DiscountShowStr ~= "" then + disCountStr = self.ItemData.DiscountShowStr + end + tagText = disCountStr..tagText + self.IsDisCount = true + else + isShowTag = false + end + end + self.TxtTagDes.text = tagText + else + isShowTag = false + end + self.PanelLabel.gameObject:SetActive(isShowTag) + + local consumeCount = self.ItemData.ConsumeCount or 0 + self.TxtUnShelveTime.color = self.originUnShelveColor; + self.RedPoint.gameObject:SetActive(false) + if self.ItemData.PayKeySuffix then --判断是不是直购礼包 + self.TxtHk2.gameObject:SetActiveEx(false) + self.TxtFree.gameObject:SetActiveEx(false) + self.TxtHk.gameObject:SetActiveEx(false) + -- self.TxtYuan.gameObject:SetActiveEx(true) + self.RedPoint.gameObject:SetActive(false) + local key + if Platform == RuntimePlatform.Android then + key = string.format("%s%s", XPayConfigs.GetPlatformConfig(1), self.ItemData.PayKeySuffix) + else + key = string.format("%s%s", XPayConfigs.GetPlatformConfig(2), self.ItemData.PayKeySuffix) + end + local payConfig = XPayConfigs.GetPayTemplate(key) + -- self.TxtYuan.text = payConfig.Amount + else + -- self.TxtYuan.gameObject:SetActiveEx(false) + if consumeCount == 0 then -- 免费的 + self.TxtHk.gameObject:SetActive(false) + self.TxtHk2.gameObject:SetActiveEx(false) + self.TxtFree.gameObject:SetActive(true) + local isShowRedPoint = (self.ItemData.BuyTimes == 0 or self.ItemData.BuyTimes < self.ItemData.BuyLimitTimes) + and (self.ItemData.TimeToShelve == 0 or self.ItemData.TimeToShelve < nowTime) + and (self.ItemData.TimeToUnShelve == 0 or self.ItemData.TimeToUnShelve > nowTime) + self.RedPoint.gameObject:SetActive(isShowRedPoint) + elseif self.IsDisCount or self.ItemData.ConvertSwitch < consumeCount then -- 打折或者存在拥有物品折扣的 + self.TxtFree.gameObject:SetActive(false) + self.TxtHk.gameObject:SetActive(false) + local path = XDataCenter.ItemManager.GetItemIcon(self.ItemData.ConsumeId) + if path then + self.RawConsumeImage2:SetRawImage(path) + end + if self.ItemData.ConvertSwitch <= 0 then + self.TxtHk2.gameObject:SetActiveEx(false) + else + self.TxtHk2.gameObject:SetActiveEx(true) + local consumeNum = consumeCount + if self.ItemData.ConvertSwitch > 0 and self.ItemData.ConvertSwitch < consumeCount then + consumeNum = self.ItemData.ConvertSwitch + end + if self.IsDisCount then + local disCountValue = XDataCenter.PurchaseManager.GetLBDiscountValue(self.ItemData) + consumeNum = math.modf(disCountValue * consumeNum) or "" + end + self.TxtHk2.text = consumeNum + self.TxtUnShelveTime.color = CS.UnityEngine.Color.red; + self.TxtUnShelveTime2.gameObject:SetActiveEx(false); + end + self.TxtPrice.text = self.ItemData.ConsumeCount or "" + else + self.TxtFree.gameObject:SetActive(false) + self.TxtHk2.gameObject:SetActiveEx(false) + self.TxtHk.gameObject:SetActive(true) + local path = XDataCenter.ItemManager.GetItemIcon(self.ItemData.ConsumeId) + if path then + self.RawConsumeImage:SetRawImage(path) + end + self.TxtHk.text = self.ItemData.ConsumeCount or "" + end + end + + --是否已拥有 + if self.ImgHave then + local isShowHave + if self.ItemData.RewardGoodsList and #self.ItemData.RewardGoodsList == 1 then + local isHave, isLimitTime = XRewardManager.CheckRewardGoodsListIsOwn(self.ItemData.RewardGoodsList) + isShowHave = isHave and not isLimitTime + else + isShowHave = false + end + self.ImgHave.gameObject:SetActive(isShowHave) + end + + -- 上架时间 + if self.ItemData.TimeToShelve > 0 and nowTime < self.ItemData.TimeToShelve then + self.RemainTime = self.ItemData.TimeToShelve - XTime.GetServerNowTimestamp() + if self.RemainTime > 0 then--大于0,注册。 + self.UpdateTimerType = UpdateTimerTypeEnum.SettOn + self.Parent:RegisterTimerFun(self.ItemData.Id, function() self:UpdateTimer() end) + else + self.Parent:RemoveTimerFun(self.ItemData.Id) + end + self.TxtPutawayTime.gameObject:SetActive(true) + self.TxtHk.gameObject:SetActive(false) + self.TxtFree.gameObject:SetActive(false) + self.TxtPutawayTime.text = TextManager.GetText("PurchaseSetOnTime", XUiHelper.GetTime(self.RemainTime, XUiHelper.TimeFormatType.PURCHASELB)) + self:SetBuyDes() + return + end + + -- 达到限购次数 + if self.ItemData.BuyLimitTimes and self.ItemData.BuyLimitTimes > 0 and self.ItemData.BuyTimes == self.ItemData.BuyLimitTimes then + self.ImgSellout.gameObject:SetActive(true) + self.TxtSetOut.text = TextManager.GetText("PurchaseSettOut") + self.TxtFree.gameObject:SetActive(false) + self.TxtHk.gameObject:SetActive(false) + return + end + + + self.ImgQuota.gameObject:SetActive(true) + self:SetBuyDes() + + --有失效时间只显示失效时间。 + -- 失效时间 + if self.ItemData.TimeToInvalid and self.ItemData.TimeToInvalid > 0 then + self.RemainTime = self.ItemData.TimeToInvalid - XTime.GetServerNowTimestamp() + if self.RemainTime > 0 then--大于0,注册。 + self.UpdateTimerType = UpdateTimerTypeEnum.SettOff + self.Parent:RegisterTimerFun(self.ItemData.Id, self.TimerUpdateCb) + self.TxtUnShelveTime.gameObject:SetActive(true) + if self.IsDisCount then + self.TxtUnShelveTime.text = TextManager.GetText("PurchaseSetOffTime", XUiHelper.GetTime(self.RemainTime, XUiHelper.TimeFormatType.PURCHASELB)) + else + self.TxtUnShelveTime.text = TextManager.GetText("PurchaseSetOffTime", XUiHelper.GetTime(self.RemainTime, XUiHelper.TimeFormatType.PURCHASELB)) + end + else + self.Parent:RemoveTimerFun(self.ItemData.Id) + self.TxtUnShelveTime.gameObject:SetActive(false) + self.ImgSellout.gameObject:SetActive(true) + self.TxtSetOut.text = TextManager.GetText("PurchaseLBSettOff") + end + return + end + + -- 下架时间 + if self.ItemData.TimeToUnShelve > 0 then + if nowTime < self.ItemData.TimeToUnShelve then + self.RemainTime = self.ItemData.TimeToUnShelve - XTime.GetServerNowTimestamp() + if self.RemainTime > 0 then--大于0,注册。 + self.UpdateTimerType = UpdateTimerTypeEnum.SettOff + self.Parent:RegisterTimerFun(self.ItemData.Id, self.TimerUpdateCb) + self.TxtUnShelveTime.gameObject:SetActive(true) + if self.IsDisCount then + self.TxtUnShelveTime.text = TextManager.GetText("PurchaseSetOffTime", XUiHelper.GetTime(self.RemainTime, XUiHelper.TimeFormatType.PURCHASELB)) + else + self.TxtUnShelveTime.text = TextManager.GetText("PurchaseSetOffTime", XUiHelper.GetTime(self.RemainTime, XUiHelper.TimeFormatType.PURCHASELB)) + end + else + self.Parent:RemoveTimerFun(self.ItemData.Id) + self.TxtUnShelveTime.gameObject:SetActive(false) + end + else + self.ImgSellout.gameObject:SetActive(true) + self.TxtUnShelveTime.text = "" + self.TxtSetOut.text = TextManager.GetText("PurchaseLBSettOff") + end + else + self.TxtUnShelveTime.gameObject:SetActive(false) + end +end + +function XUiPurchaseCoatingLBListItem:SetBuyDes() + local clientResetInfo = self.ItemData.ClientResetInfo or {} + if Next(clientResetInfo) == nil then + if self.ItemData.BuyLimitTimes > 0 then + self.TxtQuota.text = TextManager.GetText("PurchaseLimitBuy", self.ItemData.BuyTimes, self.ItemData.BuyLimitTimes) + else + self.ImgQuota.gameObject:SetActive(false) + end + return + end + + local textKey = "" + if clientResetInfo.ResetType == RestTypeConfig.Interval then + self.TxtQuota.text = TextManager.GetText("PurchaseRestTypeInterval", clientResetInfo.DayCount, self.ItemData.BuyTimes, self.ItemData.BuyLimitTimes) + return + elseif clientResetInfo.ResetType == RestTypeConfig.Day then + textKey = "PurchaseRestTypeDay" + elseif clientResetInfo.ResetType == RestTypeConfig.Week then + textKey = "PurchaseRestTypeWeek" + elseif clientResetInfo.ResetType == RestTypeConfig.Month then + textKey = "PurchaseRestTypeMonth" + end + self.TxtQuota.text = TextManager.GetText(textKey, self.ItemData.BuyTimes, self.ItemData.BuyLimitTimes) +end + +-- 更新倒计时 +function XUiPurchaseCoatingLBListItem:UpdateTimer(isRecover) + if self.ItemData.TimeToInvalid == 0 and self.ItemData.TimeToUnShelve == 0 and self.ItemData.TimeToShelve == 0 then + return + end + + if isRecover then + if self.UpdateTimerType == UpdateTimerTypeEnum.SettOff then + if self.ItemData.TimeToInvalid > 0 then + self.RemainTime = self.ItemData.TimeToInvalid - XTime.GetServerNowTimestamp() + else + self.RemainTime = self.ItemData.TimeToUnShelve - XTime.GetServerNowTimestamp() + end + else + self.RemainTime = self.ItemData.TimeToShelve - XTime.GetServerNowTimestamp() + end + else + self.RemainTime = self.RemainTime - 1 + end + + if self.RemainTime <= 0 then + self.Parent:RemoveTimerFun(self.ItemData.Id) + if self.UpdateTimerType == UpdateTimerTypeEnum.SettOff then + self.ImgSellout.gameObject:SetActive(true) + self.TxtUnShelveTime.text = "" + self.TxtSetOut.text = TextManager.GetText("PurchaseLBSettOff") + return + end + + self.TxtPutawayTime.text = "" + return + end + + if self.UpdateTimerType == UpdateTimerTypeEnum.SettOff then + self.TxtUnShelveTime.text = TextManager.GetText("PurchaseSetOffTime", XUiHelper.GetTime(self.RemainTime, XUiHelper.TimeFormatType.PURCHASELB)) + return + end + self.TxtPutawayTime.text = TextManager.GetText("PurchaseSetOnTime", XUiHelper.GetTime(self.RemainTime, XUiHelper.TimeFormatType.PURCHASELB)) +end + +return XUiPurchaseCoatingLBListItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPurchase/XUiPurchaseDetail.lua b/Resources/Scripts/XUi/XUiPurchase/XUiPurchaseDetail.lua new file mode 100644 index 00000000..5830a426 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPurchase/XUiPurchaseDetail.lua @@ -0,0 +1,42 @@ +local XUiPurchaseDetail = XClass(nil, "XUiPurchaseDetail") + +function XUiPurchaseDetail:Ctor(ui, uiroot, callback) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Uiroot = uiroot + self.CallBack = callback + XTool.InitUiObject(self) + self:Init() +end + +function XUiPurchaseDetail:Init() + self.BtnBgClick.CallBack = function() + self:OnBtnBgClick() + end + self.BtnCloseBg.CallBack = function() + self:OnBtnCloseBgClick() + end +end + +function XUiPurchaseDetail:OnBtnBgClick() + if self.CallBack then + self.CallBack() + end +end + +function XUiPurchaseDetail:OnBtnCloseBgClick() + if self.CallBack then + self.CallBack() + end +end + +function XUiPurchaseDetail:Show() + --显示有偿黑卡的数量 + local TxtYouChangcount = XDataCenter.ItemManager.GetPaidGemCount() + self.TxtYouChangNum.text = TxtYouChangcount + --显示无偿黑卡的数量 + local TxtWuChangCount = XDataCenter.ItemManager.GetFreeGemCount() + self.TxtWuChangNum.text = TxtWuChangCount +end + +return XUiPurchaseDetail \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPurchase/XUiPurchaseHK.lua b/Resources/Scripts/XUi/XUiPurchase/XUiPurchaseHK.lua new file mode 100644 index 00000000..69ab25e9 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPurchase/XUiPurchaseHK.lua @@ -0,0 +1,91 @@ +local Object = CS.UnityEngine.Object +local XUiPurchaseHK = XClass(nil, "XUiPurchaseHK") +local TextManager = CS.XTextManager +local TabConfig = { + Exchange = 1, + Shop = 2 +} +local XUiPurchaseHKShop = require("XUi/XUiPurchase/XUiPurchaseHKShop") +local XUiPurchaseHKExchange = require("XUi/XUiPurchase/XUiPurchaseHKExchange") + +function XUiPurchaseHK:Ctor(ui) + self.CurState = false + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:Init() +end + +-- 更新数据 +function XUiPurchaseHK:OnRefresh() + --测试 + local data = {} + if not data then + return + end + + self.Data = data + self:TabSkip(TabConfig.Exchange) + self.TabGroup:SelectIndex(TabConfig.Exchange) +end + +function XUiPurchaseHK:Init() + local tabBtns = {} + local tabText = { TextManager.GetText("PurchaseYKExChangeTab"), TextManager.GetText("PurchaseYKShopTab") } + self.TabGroup = self.PanelHkdhTabGroup:GetComponent("XUiButtonGroup") + for k, v in pairs(tabText) do + local btn = Object.Instantiate(self.BtnHkTab) + btn.gameObject:SetActive(true) + btn.transform:SetParent(self.PanelHkdhTabGroup.transform, false) + local btncs = btn:GetComponent("XUiButton") + btncs:SetName(v) + tabBtns[k] = btncs + end + self.TabGroup:Init(tabBtns, function(tab) self:TabSkip(tab) end) + + self.TabEnterSkip = {} + self.TabEnterSkip[TabConfig.Exchange] = function() self:OpenExchange() end + self.TabEnterSkip[TabConfig.Shop] = function() self:OpenHKShop() end + + self.UiTabs = {} + self.UiTabs[TabConfig.Exchange] = XUiPurchaseHKExchange.New(self.PanelDh) + self.UiTabs[TabConfig.Shop] = XUiPurchaseHKShop.New(self.PanelHksd) +end + +function XUiPurchaseHK:TabSkip(tab) + if tab == self.CurTab then + return + end + + self.CurTab = tab + + if self.TabEnterSkip[tab] then + self.TabEnterSkip[tab]() + end +end + +-- 黑卡商店 +function XUiPurchaseHK:OpenHKShop() + local data = XDataCenter.PurchaseManager.GetHKShopData() + -- if data then + -- return + -- end + + self.PanelDh.gameObject:SetActive(false) + self.PanelHksd.gameObject:SetActive(true) + self.UiTabs[TabConfig.Shop]:OnRefresh(data) +end + +-- 兑换 +function XUiPurchaseHK:OpenExchange() + local data = XDataCenter.PurchaseManager.GetHKDHData() + -- if not data then + -- return + -- end + + self.PanelDh.gameObject:SetActive(true) + self.PanelHksd.gameObject:SetActive(false) + self.UiTabs[TabConfig.Exchange]:OnRefresh(data) +end + +return XUiPurchaseHK \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPurchase/XUiPurchaseHKExchange.lua b/Resources/Scripts/XUi/XUiPurchase/XUiPurchaseHKExchange.lua new file mode 100644 index 00000000..5d3bf407 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPurchase/XUiPurchaseHKExchange.lua @@ -0,0 +1,80 @@ +local XUiPurchaseHKExchange = XClass(nil, "XUiPurchaseHKExchange") +local Next = _G.next +local XUiPurchaseHKExchangeListItem = require("XUi/XUiPurchase/XUiPurchaseHKExchangeListItem") +local XUiPurchaseHKExchangeTips = require("XUi/XUiPurchase/XUiPurchaseHKExchangeTips") + +function XUiPurchaseHKExchange:Ctor(ui, uiRoot, notEnoughCb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + self.NotEnoughCb = notEnoughCb + XTool.InitUiObject(self) + self:Init() +end + +-- 更新数据 +function XUiPurchaseHKExchange:OnRefresh(uiType) + local data = XDataCenter.PurchaseManager.GetDatasByUiType(uiType) + if not data then + return + end + + self.CurUiType = uiType + self.GameObject:SetActive(true) + if Next(data) ~= nil then + table.sort(data, XUiPurchaseHKExchange.SortFun) + end + self.ListData = data + self.DynamicTable:SetDataSource(data) + self.DynamicTable:ReloadDataASync(1) +end + +function XUiPurchaseHKExchange.SortFun(a, b) + return a.Priority < b.Priority +end + +function XUiPurchaseHKExchange:OnUpdate() + if self.CurUiType then + self:OnRefresh(self.CurUiType) + end +end + +function XUiPurchaseHKExchange:HidePanel() + self.GameObject:SetActive(false) +end + +function XUiPurchaseHKExchange:ShowPanel() + self.GameObject:SetActive(true) +end + +function XUiPurchaseHKExchange:Init() + self:InitExchangeList() + self.HKExchangeUi = XUiPurchaseHKExchangeTips.New(self.PaneHkExChangeTips, self) + self.UpdateCb = function() self:OnUpdate() end +end + +function XUiPurchaseHKExchange:InitExchangeList() + self.DynamicTable = XDynamicTableNormal.New(self.Transform, self) + self.DynamicTable:SetProxy(XUiPurchaseHKExchangeListItem) + self.DynamicTable:SetDelegate(self) +end + +function XUiPurchaseHKExchange:ReqBuy(id) + XDataCenter.PurchaseManager.PurchaseRequest(id, self.UpdateCb) +end + +-- [监听动态列表事件] +function XUiPurchaseHKExchange:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self.UiRoot, self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.ListData[index] + grid:OnRefresh(data) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + local data = self.ListData[index] + self.HKExchangeUi:OnRefresh(data) + CS.XAudioManager.PlaySound(1011) + end +end + +return XUiPurchaseHKExchange \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPurchase/XUiPurchaseHKExchangeListItem.lua b/Resources/Scripts/XUi/XUiPurchase/XUiPurchaseHKExchangeListItem.lua new file mode 100644 index 00000000..8dee2ede --- /dev/null +++ b/Resources/Scripts/XUi/XUiPurchase/XUiPurchaseHKExchangeListItem.lua @@ -0,0 +1,80 @@ +local XUiPurchaseHKExchangeListItem = XClass(nil, "XUiPurchaseHKExchangeListItem") +local TextManager = CS.XTextManager + +function XUiPurchaseHKExchangeListItem:Ctor(ui,uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + XTool.InitUiObject(self) +end + +-- 更新数据 +function XUiPurchaseHKExchangeListItem:OnRefresh(itemData) + if not itemData then + return + end + + self.ItemData = itemData + + -- 直接获得的道具 + local rewardGoods = self.ItemData.RewardGoodsList or {} + + -- 额外获得 + local extraRewardGood = self.ItemData.ExtraRewardGoods or {} + local extraCount = extraRewardGood.Count or 0 + + -- 首充获得物品 + local firstRewardGoods = self.ItemData.FirstRewardGoods or {} + local firstCount = firstRewardGoods.Count or 0 + + self.TxtName.text = self.ItemData.Desc + self.RawImageConsu:SetRawImage(XDataCenter.ItemManager.GetItemIcon(itemData.ConsumeId)) + if itemData.Icon then + local path = XPurchaseConfigs.GetIconPathByIconName(itemData.Icon) + if path and path.AssetPath then + self.ImgIconDh:SetRawImage(path.AssetPath) + end + end + + self.TxtHk.text = itemData.ConsumeCount + + if extraCount == 0 and firstCount == 0 then + self.PanelFirstLabel.gameObject:SetActive(false) + self.PanelNormalLabel.gameObject:SetActive(false) + else + local dirCount = 0 + if rewardGoods[1] then + dirCount = rewardGoods[1].Count or 0 + end + + if self.ItemData.BuyTimes == 0 or firstCount > 0 then + if firstCount == dirCount then -- 首次购买而且双倍 + self.PanelFirstLabel.gameObject:SetActive(true) + self.PanelNormalLabel.gameObject:SetActive(true) + self.TxtFirst.text = TextManager.GetText("PurchasePayFirstGetText") + if firstRewardGoods.TemplateId then + self.TxtNormal.text = TextManager.GetText("PurchaseFirstPayTips",firstCount,XDataCenter.ItemManager.GetItemName(firstRewardGoods.TemplateId)) + end + else + self.PanelFirstLabel.gameObject:SetActive(false) + self.PanelNormalLabel.gameObject:SetActive(true) + if firstRewardGoods.TemplateId then + self.TxtNormal.text = TextManager.GetText("PurchaseFirstPayTips",firstCount,XDataCenter.ItemManager.GetItemName(firstRewardGoods.TemplateId)) + end + end + else + self.PanelNormalLabel.gameObject:SetActive(false) + self.PanelFirstLabel.gameObject:SetActive(false) + if extraCount > 0 and extraRewardGood.TemplateId then + self.PanelNormalLabel.gameObject:SetActive(true) + self.TxtNormal.text = TextManager.GetText("PurchasePayGetText",extraCount,XDataCenter.ItemManager.GetItemName(extraRewardGood.TemplateId)) + end + end + end +end + +function XUiPurchaseHKExchangeListItem:Init(uiRoot) + self.UiRoot = uiRoot +end + +return XUiPurchaseHKExchangeListItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPurchase/XUiPurchaseHKExchangeTips.lua b/Resources/Scripts/XUi/XUiPurchase/XUiPurchaseHKExchangeTips.lua new file mode 100644 index 00000000..733fa51b --- /dev/null +++ b/Resources/Scripts/XUi/XUiPurchase/XUiPurchaseHKExchangeTips.lua @@ -0,0 +1,75 @@ +local XUiPurchaseHKExchangeTips = XClass(nil, "XUiPurchaseHKExchangeTips") +local Next = _G.next + +function XUiPurchaseHKExchangeTips:Ctor(ui,parent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Parent = parent + XTool.InitUiObject(self) +end + +-- 更新数据 +function XUiPurchaseHKExchangeTips:OnRefresh(data) + self:InitAdd() + self.GameObject:SetActive(true) + self.Parent.UiRoot:PlayAnimation("HkExChangeTipsEnable") + self.ItemData = data + self.TxtConsumeName.text = XDataCenter.ItemManager.GetItemName(data.ConsumeId) + self.TxtConsumeCount.text = data.ConsumeCount + self.TxtTargetName.text = data.Name + -- 直接获得的道具 + local rewardGoods = data.RewardGoodsList or {} + -- 首充获得物品 + local firstRewardGoods = data.FirstRewardGoods or {} + -- 额外获得 + local extraRewardGoods = data.ExtraRewardGoods or {} + + local count = 0 + if rewardGoods[1] then + count = rewardGoods[1].Count + self.TxtTargetName.text = XDataCenter.ItemManager.GetItemName(rewardGoods[1].TemplateId) + end + + if Next(extraRewardGoods) ~= nil then + count = count + extraRewardGoods.Count + end + + if Next(firstRewardGoods) ~= nil then + count = count + firstRewardGoods.Count + end + + self.TxtTargetCount.text = count +end + +function XUiPurchaseHKExchangeTips:ReqBuy() + if self.ItemData.ConsumeCount > XDataCenter.ItemManager.GetCount(XDataCenter.ItemManager.ItemId.HongKa) then + XUiManager.TipText("PurchaseBuyHongKaCountTips") + if self.Parent and self.Parent.NotEnoughCb then + self.Parent.NotEnoughCb(XPurchaseConfigs.TabsConfig.Pay) + self:PlayAnimation() + end + return + end + self:PlayAnimation() + -- self:Hide() + if self.ItemData and self.ItemData.Id then + self.Parent:ReqBuy(self.ItemData.Id) + end +end + +function XUiPurchaseHKExchangeTips:PlayAnimation() + self.Parent.UiRoot:PlayAnimation("HkExChangeTipsDisable",function()self:Hide()end) +end + +function XUiPurchaseHKExchangeTips:Hide() + self.GameObject:SetActive(false) +end + +function XUiPurchaseHKExchangeTips:InitAdd() + local closeFun = function()self:PlayAnimation()end + self.BtnCancel.CallBack = closeFun + self.BtnCloseBg.CallBack = closeFun + self.BtnConfirm.CallBack = function()self:ReqBuy()end +end + +return XUiPurchaseHKExchangeTips \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPurchase/XUiPurchaseHKListItem.lua b/Resources/Scripts/XUi/XUiPurchase/XUiPurchaseHKListItem.lua new file mode 100644 index 00000000..c806475b --- /dev/null +++ b/Resources/Scripts/XUi/XUiPurchase/XUiPurchaseHKListItem.lua @@ -0,0 +1,23 @@ +local XUiPurchaseHKListItem = XClass(nil, "XUiPurchaseHKListItem") + +function XUiPurchaseHKListItem:Ctor(ui,uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + XTool.InitUiObject(self) +end + +-- 更新数据 +function XUiPurchaseHKListItem:OnRefresh(itemData) + if not itemData then + return + end + self.ItemData = itemData +end + +function XUiPurchaseHKListItem:Init(uiRoot,parent) + self.UiRoot = uiRoot + self.Parent = parent +end + +return XUiPurchaseHKListItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPurchase/XUiPurchaseHKShop.lua b/Resources/Scripts/XUi/XUiPurchase/XUiPurchaseHKShop.lua new file mode 100644 index 00000000..1c4d0104 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPurchase/XUiPurchaseHKShop.lua @@ -0,0 +1,91 @@ +local XUiPurchaseHKShop = XClass(nil, "XUiPurchaseHKShop") +local XUiPurchaseHKShopListItem = require("XUi/XUiPurchase/XUiPurchaseHKShopListItem") + +function XUiPurchaseHKShop:Ctor(ui,uiRoot) + self.CurState = false + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + XTool.InitUiObject(self) + self:Init() +end + +-- 更新数据 +function XUiPurchaseHKShop:OnRefresh(uiType) + local data = XDataCenter.PurchaseManager.GetDatasByUiType(uiType) + if not data then + return + end + + self.CurUiType = uiType + self.GameObject:SetActive(true) + self.ListData = data + self.DynamicTable:SetDataSource(data) + self.DynamicTable:ReloadDataASync(1) +end + +function XUiPurchaseHKShop:OnUpdate() + if self.CurUiType then + self:OnRefresh(self.CurUiType) + end +end + +function XUiPurchaseHKShop:HidePanel() + self.GameObject:SetActive(false) +end + +function XUiPurchaseHKShop:ShowPanel() + self.GameObject:SetActive(true) +end + +function XUiPurchaseHKShop:Init() + self:InitShopList() + self.CheckBuyFun = function() return self:CheckBuy() end + self.UpdateCb = function() self:OnUpdate() end +end + +function XUiPurchaseHKShop:InitShopList() + self.DynamicTable = XDynamicTableNormal.New(self.Transform) + self.DynamicTable:SetProxy(XUiPurchaseHKShopListItem) + self.DynamicTable:SetDelegate(self) +end + +-- [监听动态列表事件] +function XUiPurchaseHKShop:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self.UiRoot,self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.ListData[index] + grid:OnRefresh(data) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + self.CurData = self.ListData[index] + XLuaUiManager.Open("UiPurchaseBuyTips", self.CurData, self.CheckBuyFun, self.UpdateCb) + CS.XAudioManager.PlaySound(1011) + end +end + +function XUiPurchaseHKShop:CheckBuy() + if self.CurData.BuyLimitTimes > 0 and self.CurData.BuyTimes == self.CurData.BuyLimitTimes then --卖完了,不管。 + XUiManager.TipText("PurchaseLiSellOut") + return false + end + + if self.CurData.TimeToShelve > 0 and self.CurData.TimeToShelve > XTime.GetServerNowTimestamp() then --没有上架 + XUiManager.TipText("PurchaseBuyNotSet") + return false + end + + if self.CurData.TimeToUnShelve > 0 and self.CurData.TimeToUnShelve < XTime.GetServerNowTimestamp() then --下架了 + XUiManager.TipText("PurchaseSettOff") + return false + end + + if self.CurData.ConsumeCount > 0 and self.CurData.ConsumeCount > XDataCenter.ItemManager.GetCount(XDataCenter.ItemManager.ItemId.HongKa) then --钱不够 + XUiManager.TipText("PurchaseBuyHongKaCountTips") + return false + end + + return true +end + +return XUiPurchaseHKShop \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPurchase/XUiPurchaseHKShopListItem.lua b/Resources/Scripts/XUi/XUiPurchase/XUiPurchaseHKShopListItem.lua new file mode 100644 index 00000000..f7701d31 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPurchase/XUiPurchaseHKShopListItem.lua @@ -0,0 +1,100 @@ +local XUiPurchaseHKShopListItem = XClass(nil, "XUiPurchaseHKShopListItem") +local TextManager = CS.XTextManager +local RestTypeConfig +local Next = _G.next + +function XUiPurchaseHKShopListItem:Ctor(ui,uiRoot) + RestTypeConfig = XPurchaseConfigs.RestTypeConfig + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + XTool.InitUiObject(self) +end + +-- 更新数据 +function XUiPurchaseHKShopListItem:OnRefresh(itemData) + if not itemData then + return + end + self.ItemData = itemData + self:SetData() +end + +function XUiPurchaseHKShopListItem:Init(uiRoot,parent) + self.UiRoot = uiRoot + self.Parent = parent +end + +function XUiPurchaseHKShopListItem:SetData() + if self.ItemData.Icon then + local path = XPurchaseConfigs.GetIconPathByIconName(self.ItemData.Icon) + if path and path.AssetPath then + self.ImgIconLb:SetRawImage(path.AssetPath) + end + end + self.TxtName.text = self.ItemData.Name + + -- 上架时间 + if self.ItemData.TimeToShelve > 0 then + self.TxtPutawayTime.gameObject:SetActive(true) + self.TxtHk.gameObject:SetActive(false) + self.TxtFree.gameObject:SetActive(false) + self.TxtQuota.gameObject:SetActive(true) + self:SetBuyDes() + return + end + + -- 达到限购次数 + if self.ItemData.BuyTimes == self.ItemData.BuyLimitTimes then + self.ImgSellout.gameObject:SetActive(true) + self.PanelLabel.gameObject:SetActive(false) + self.TxtFree.gameObject:SetActive(false) + self.TxtQuota.gameObject:SetActive(false) + return + end + + -- 下架时间 + self.TxtPutawayTime.gameObject:SetActive(false) + if self.ItemData.TimeToUnShelve > 0 then + self.TxtUnShelveTime.gameObject:SetActive(true) + self.TxtUnShelveTime.text = TextManager.GetText("PurchaseSetOffTime",XUiHelper.GetTime(self.ItemData.TimeToUnShelve - XTime.GetServerNowTimestamp())) + else + self.TxtUnShelveTime.gameObject:SetActive(false) + end + + self.TxtQuota.gameObject:SetActive(true) + self:SetBuyDes() + + local consumeCount = self.ItemData.ConsumeCount or 0 + if consumeCount == 0 then -- 免费的 + self.TxtHk.gameObject:SetActive(false) + self.TxtFree.gameObject:SetActive(true) + return + end + + self.TxtFree.gameObject:SetActive(false) + self.TxtHk.gameObject:SetActive(true) + + self.RawConsumeImage:SetRawImage(XDataCenter.ItemManager.GetItemIcon(self.ItemData.ConsumeId)) + self.TxtHk.text = self.ItemData.ConsumeCount or "" +end + +function XUiPurchaseHKShopListItem:SetBuyDes() + local clientResetInfo = self.ItemData.ClientResetInfo or {} + if Next(clientResetInfo) == nil then + self.TxtQuota.text = "" + end + local textKey = "" + if clientResetInfo.ResetType == RestTypeConfig.Interval then + self.TxtQuota.text = TextManager.GetText("PurchaseRestTypeInterval",clientResetInfo.DayCount, self.ItemData.BuyTimes,self.ItemData.BuyLimitTimes) + return + elseif clientResetInfo.ResetType == RestTypeConfig.Day then + textKey = "PurchaseRestTypeDay" + elseif clientResetInfo.ResetType == RestTypeConfig.Week then + textKey = "PurchaseRestTypeWeek" + elseif clientResetInfo.ResetType == RestTypeConfig.Month then + textKey = "PurchaseRestTypeMonth" + end + self.TxtQuota.text = TextManager.GetText(textKey,self.ItemData.BuyTimes,self.ItemData.BuyLimitTimes) +end +return XUiPurchaseHKShopListItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPurchase/XUiPurchaseLB.lua b/Resources/Scripts/XUi/XUiPurchase/XUiPurchaseLB.lua new file mode 100644 index 00000000..e75d5516 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPurchase/XUiPurchaseLB.lua @@ -0,0 +1,376 @@ +local XUiPurchaseLB = XClass(nil, "XUiPurchaseLB") +local Next = _G.next +local CSXTextManagerGetText = CS.XTextManager.GetText +local XUiPurchaseLBListItem = require("XUi/XUiPurchase/XUiPurchaseLBListItem") +local CurrentSchedule = nil + +function XUiPurchaseLB:Ctor(ui,uiRoot, callBack) + self.CurState = false + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.CallBack = callBack + self.UiRoot = uiRoot + self.TimeFuns = {} + self.TimeSaveFuns = {} + XTool.InitUiObject(self) + self.ListData = {} + self.IsCheckOpenAddTimeTips = false + self.TipsTemplateContentList = {} + self.OpenBuyTipsList = {} + self:Init() +end + +-- 先分类后排序 +function XUiPurchaseLB:OnSortFun(data) + print("XUiPurchaseLB:OnSortFun"); + self.SellOutList = {}--买完了 + self.SellingList = {}--在上架中 + self.SellOffList = {}--下架了 + self.SellWaitList = {}--待上架中 + self.ListData = {} + + local nowTime = XTime.GetServerNowTimestamp() + for _,v in pairs(data)do + if v and not v.IsSelloutHide then + if v.TimeToUnShelve > 0 and v.TimeToUnShelve <= nowTime then--下架了 + table.insert(self.SellOffList,v) + elseif v.TimeToShelve > 0 and v.TimeToShelve > nowTime then--待上架中 + table.insert(self.SellWaitList,v) + elseif v.BuyTimes > 0 and v.BuyLimitTimes > 0 and v.BuyTimes >= v.BuyLimitTimes then--买完了 + table.insert(self.SellOutList,v) + else --在上架中,还能买。 + table.insert(self.SellingList,v) + end + end + end + + --在上架中,还能买。 + if Next(self.SellingList) then + table.sort(self.SellingList, XUiPurchaseLB.SortByPriority) + for _,v in pairs(self.SellingList) do + table.insert(self.ListData, v) + end + end + + --待上架中 + if Next(self.SellWaitList) then + table.sort(self.SellWaitList, XUiPurchaseLB.SortByPriority) + for _,v in pairs(self.SellWaitList) do + table.insert(self.ListData, v) + end + end + + --买完了 + if Next(self.SellOutList) then + table.sort(self.SellOutList, XUiPurchaseLB.SortByPriority) + for _,v in pairs(self.SellOutList) do + table.insert(self.ListData, v) + end + end + + --下架了 + if Next(self.SellOffList) then + table.sort(self.SellOffList, XUiPurchaseLB.SortByPriority) + for _,v in pairs(self.SellOffList) do + table.insert(self.ListData, v) + end + end + +end + +function XUiPurchaseLB.SortByPriority(a,b) + return a.Priority < b.Priority +end + +function XUiPurchaseLB:StartLBTimer() + if self.IsStart then + return + end + + self.IsStart = true + CurrentSchedule = XScheduleManager.ScheduleForever(function() self:UpdateLBTimer()end, 1000) +end + +function XUiPurchaseLB:UpdateLBTimer() + if Next(self.TimeFuns) then + for _,timerFun in pairs(self.TimeFuns)do + if timerFun then + timerFun() + end + end + return + end + self:DestroyTimer() +end + +function XUiPurchaseLB:RemoveTimerFun(id) + self.TimeFuns[id] = nil +end + +function XUiPurchaseLB:RecoverTimerFun(id) + self.TimeFuns[id] = self.TimeSaveFuns[id] + if self.TimeFuns[id] then + self.TimeFuns[id](true) + end + self.TimeSaveFuns[id] = nil +end + +function XUiPurchaseLB:RegisterTimerFun(id,fun,isSave) + if not isSave then + self.TimeFuns[id] = fun + return + end + + self.TimeSaveFuns[id] = self.TimeFuns[id] + self.TimeFuns[id] = fun + +end + +-- 更新数据 +function XUiPurchaseLB:OnRefresh(uiType) + local data = XDataCenter.PurchaseManager.GetDatasByUiType(uiType) + XLog.Debug(data); + if not data then + return + end + + self.CurUiType = uiType + self.GameObject:SetActive(true) + if Next(data) ~= nil then + self:OnSortFun(data) + end + self.TimeFuns = {} + self.TimeSaveFuns = {} + self.DynamicTable:SetDataSource(self.ListData) + self.DynamicTable:ReloadDataASync(1) + self:StartLBTimer() +end + +function XUiPurchaseLB:OnUpdate(rewardList) + if self.IsCheckOpenAddTimeTips then + self:CheckAddTimeTips(rewardList) + self.IsCheckOpenAddTimeTips = false + end + if self.CurUiType then + self:OnRefresh(self.CurUiType) + end +end + +function XUiPurchaseLB:HidePanel() + self:DestroyTimer() + XEventManager.RemoveEventListener(XEventId.EVENT_PURCAHSE_BUYUSERIYUAN, self.OnUpdate, self) + self.GameObject:SetActive(false) +end + +function XUiPurchaseLB:ShowPanel() + self.GameObject:SetActive(true) + XEventManager.AddEventListener(XEventId.EVENT_PURCAHSE_BUYUSERIYUAN, self.OnUpdate, self) +end + +function XUiPurchaseLB:DestroyTimer() + if CurrentSchedule then + self.IsStart = false + XScheduleManager.UnSchedule(CurrentSchedule) + CurrentSchedule = nil + end +end + +function XUiPurchaseLB:Init() + self:InitList() + self.CheckBuyFun = function(count, disCountCouponIndex) return self:CheckBuy(count, disCountCouponIndex) end + self.BeforeBuyReqFun = function(successCb) self:CheckIsOpenBuyTips(successCb) end + self.UpdateCb = function(rewardList) self:OnUpdate(rewardList) end +end + +function XUiPurchaseLB:InitList() + self.DynamicTable = XDynamicTableNormal.New(self.Transform) + self.DynamicTable:SetProxy(XUiPurchaseLBListItem) + self.DynamicTable:SetDelegate(self) +end + +-- [监听动态列表事件] +function XUiPurchaseLB:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self.UiRoot,self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.ListData[index] + grid:OnRefresh(data) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + local data = self.ListData[index] + if not data then + return + end + + XDataCenter.PurchaseManager.RemoveNotInTimeDiscountCoupon(data) -- 移除未到时间的打折券 + self.CurData = data + XLuaUiManager.Open("UiPurchaseBuyTips", data, self.CheckBuyFun, self.UpdateCb, self.BeforeBuyReqFun, XPurchaseConfigs.GetLBUiTypesList(),self.CurUiType) + CS.XAudioManager.PlaySound(1011) + end +end + + + +function XUiPurchaseLB:CheckBuy(count, disCountCouponIndex) + count = count or 1 + disCountCouponIndex = disCountCouponIndex or 0 + + if not XDataCenter.PayManager.CheckCanBuy(self.CurData.Id) then + return false + end + + if self.CurData.BuyLimitTimes > 0 and self.CurData.BuyTimes == self.CurData.BuyLimitTimes then --卖完了,不管。 + XUiManager.TipText("PurchaseLiSellOut") + return false + end + + if self.CurData.TimeToShelve > 0 and self.CurData.TimeToShelve > XTime.GetServerNowTimestamp() then --没有上架 + XUiManager.TipText("PurchaseBuyNotSet") + return false + end + + if self.CurData.TimeToUnShelve > 0 and self.CurData.TimeToUnShelve < XTime.GetServerNowTimestamp() then --下架了 + XUiManager.TipText("PurchaseSettOff") + return false + end + + if self.CurData.TimeToInvalid > 0 and self.CurData.TimeToInvalid < XTime.GetServerNowTimestamp() then --失效了 + XUiManager.TipText("PurchaseSettOff") + return false + end + + if self.CurData.ConsumeCount > 0 and self.CurData.ConvertSwitch <= 0 then -- 礼包内容全部拥有 + XUiManager.TipText("PurchaseRewardAllHaveErrorTips") + return false + end + + local consumeCount = self.CurData.ConsumeCount + if disCountCouponIndex and disCountCouponIndex ~= 0 then + local disCountValue = XDataCenter.PurchaseManager.GetLBCouponDiscountValue(self.CurData, disCountCouponIndex) + consumeCount = math.floor(disCountValue * consumeCount) + else + if self.CurData.ConvertSwitch and consumeCount > self.CurData.ConvertSwitch then -- 已经被服务器计算了抵扣和折扣后的钱 + consumeCount = self.CurData.ConvertSwitch + end + + if XPurchaseConfigs.GetTagType(self.CurData.Tag) == XPurchaseConfigs.PurchaseTagType.Discount then -- 计算打折后的钱(普通打折或者选择了打折券) + local disCountValue = XDataCenter.PurchaseManager.GetLBDiscountValue(self.CurData) + consumeCount = math.floor(disCountValue * consumeCount) + end + end + + consumeCount = count * consumeCount -- 全部数量的总价 + if consumeCount > 0 and consumeCount > XDataCenter.ItemManager.GetCount(self.CurData.ConsumeId) then --钱不够 + local name = XDataCenter.ItemManager.GetItemName(self.CurData.ConsumeId) or "" + local tips = CSXTextManagerGetText("PurchaseBuyKaCountTips", name) + XUiManager.TipMsg(tips,XUiManager.UiTipType.Wrong) + if self.CurData.ConsumeId == XDataCenter.ItemManager.ItemId.PaidGem then + self.CallBack(XPurchaseConfigs.TabsConfig.HK) + elseif self.CurData.ConsumeId == XDataCenter.ItemManager.ItemId.HongKa then + self.CallBack(XPurchaseConfigs.TabsConfig.Pay) + end + return false + end + + return true +end + +function XUiPurchaseLB:CheckIsOpenBuyTips(successCb) + if self.CurData.ConvertSwitch and self.CurData.ConsumeCount > self.CurData.ConvertSwitch then -- 礼包被计算拥有物品折扣价后,拥有物品不会下发,所以无需二次提示转化碎片 + if successCb then successCb() end + return + end + + local rewardGoodsList = self.CurData.RewardGoodsList + if not rewardGoodsList then + if successCb then successCb() end + return + end + + for _, v in pairs(rewardGoodsList) do + if XRewardManager.IsRewardWeaponFashion(v.RewardType, v.TemplateId) then + local isHave, ownRewardIsLimitTime, rewardIsLimitTime, leftTime = XRewardManager.CheckRewardOwn(v.RewardType, v.TemplateId) + if isHave then + if not ownRewardIsLimitTime or not rewardIsLimitTime then + local tipContent = {} + tipContent["title"] = CSXTextManagerGetText("WeaponFashionConverseTitle") + if ownRewardIsLimitTime and not rewardIsLimitTime then --自己拥有的武器涂装是限时的去买永久的 + local timeText = XUiHelper.GetTime(leftTime, XUiHelper.TimeFormatType.ACTIVITY) + tipContent["content"] = #rewardGoodsList > 1 and CSXTextManagerGetText("OwnLimitBuyForeverWeaponFashionGiftConverseText", timeText) or CSXTextManagerGetText("OwnLimitBuyForeverWeaponFashionConverseText", timeText) + elseif not ownRewardIsLimitTime and rewardIsLimitTime then --自己拥有的武器涂装是永久的去买限时的 + tipContent["content"] = CSXTextManagerGetText("OwnForeverBuyLimitWeaponFashionConverseText") + elseif not ownRewardIsLimitTime and not rewardIsLimitTime then --自己拥有的武器涂装是永久的去买永久的 + tipContent["content"] = CSXTextManagerGetText("OwnForeverBuyForeverWeaponFashionConverseText") + end + table.insert(self.OpenBuyTipsList, tipContent) + else + --自己拥有的武器涂装是限时的去买限时的 + self.IsCheckOpenAddTimeTips = true + end + end + elseif XRewardManager.IsRewardFashion(v.RewardType, v.TemplateId) and XRewardManager.CheckRewardOwn(v.RewardType, v.TemplateId) then + local tipContent = {} + tipContent["title"] = CSXTextManagerGetText("PurchaseFashionRepeatTipsTitle") + tipContent["content"] = CSXTextManagerGetText("PurchaseFashionRepeatTipsContent") + table.insert(self.OpenBuyTipsList, tipContent) + end + end + + if #self.OpenBuyTipsList > 0 then + self:OpenBuyTips(successCb) + return + end + + if successCb then successCb() end +end + +function XUiPurchaseLB:OpenBuyTips(successCb) + if #self.OpenBuyTipsList > 0 then + local tipContent = table.remove(self.OpenBuyTipsList, 1) + local sureCallback = function () + if #self.OpenBuyTipsList > 0 then + self:OpenBuyTips() + else + if successCb then successCb() end + end + end + local closeCallback = function() + self.OpenBuyTipsList = {} + end + XUiManager.DialogTip(tipContent["title"], tipContent["content"], XUiManager.DialogType.Normal, closeCallback, sureCallback) + end +end + +function XUiPurchaseLB:CheckAddTimeTips(rewardList) + if not rewardList then return end + local descStr + for _, v in pairs(rewardList) do + if XRewardManager.IsRewardWeaponFashion(v.RewardType, v.TemplateId)then + descStr = self:GetRewardWeaponFashionDescStr(v.TemplateId) + if descStr then + table.insert(self.TipsTemplateContentList, descStr) + end + end + end + self:OpenAddTimeTips() +end + +function XUiPurchaseLB:GetRewardWeaponFashionDescStr(templateId) + local weaponFashionId = XDataCenter.ItemManager.GetWeaponFashionId(templateId) + local weaponFashion = XDataCenter.WeaponFashionManager.GetWeaponFashion(weaponFashionId) + local time = XDataCenter.ItemManager.GetWeaponFashionAddTime(templateId) + if weaponFashion and weaponFashion:IsTimeLimit() and time then + --此时提示叠加时长信息 + local addTime = XUiHelper.GetTime(time, XUiHelper.TimeFormatType.DEFAULT) + local weaponFashionName = XDataCenter.WeaponFashionManager.GetWeaponFashionName(weaponFashionId) + return CSXTextManagerGetText("WeaponFashionLimitGetAlreadyHaveLimit", weaponFashionName, addTime) + end +end + +function XUiPurchaseLB:OpenAddTimeTips() + if #self.TipsTemplateContentList > 0 then + local content = table.remove(self.TipsTemplateContentList) + XUiManager.TipMsg(content, nil, function() self:OpenAddTimeTips() end) + end +end + +return XUiPurchaseLB \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPurchase/XUiPurchaseLBListItem.lua b/Resources/Scripts/XUi/XUiPurchase/XUiPurchaseLBListItem.lua new file mode 100644 index 00000000..3093d1d9 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPurchase/XUiPurchaseLBListItem.lua @@ -0,0 +1,320 @@ +local XUiPurchaseLBListItem = XClass(nil, "XUiPurchaseLBListItem") +local TextManager = CS.XTextManager +local Next = _G.next +local UpdateTimerTypeEnum = { + SettOff = 1, + SettOn = 2 +} + +local Application = CS.UnityEngine.Application +local Platform = Application.platform +local RuntimePlatform = CS.UnityEngine.RuntimePlatform + +function XUiPurchaseLBListItem:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + XTool.InitUiObject(self) + self.TimerUpdateCb = function(isRecover) self:UpdateTimer(isRecover) end + self:SetHaveDataState(true) +end + +-- 更新数据 +function XUiPurchaseLBListItem:OnRefresh(itemData) + if not itemData or not next(itemData) then + self:SetHaveDataState(false) + return + else + self:SetHaveDataState(true); + end + if self.ItemData and self.ItemData.Id ~= 0 then + self.Parent:RemoveTimerFun(self.ItemData.Id) + end + self.ItemData = itemData + self:SetData() +end + +function XUiPurchaseLBListItem:SetHaveDataState(bool) + if self.PanelHave then self.PanelHave.gameObject:SetActiveEx(bool) end + if self.PanelNone then self.PanelNone.gameObject:SetActiveEx(not bool) end +end + +function XUiPurchaseLBListItem:Init(uiRoot, parent) + self.UiRoot = uiRoot + self.Parent = parent +end + +function XUiPurchaseLBListItem:SetData() + if self.ItemData.Icon then + local iconPath = XPurchaseConfigs.GetIconPathByIconName(self.ItemData.Icon) + if iconPath and iconPath.AssetPath then + self.ImgIconLb:SetRawImage(iconPath.AssetPath, function() self.ImgIconLb:SetNativeSize() end) + end + end + self.TxtName.text = self.ItemData.Name + self.ImgSellout.gameObject:SetActive(false) + self.TxtUnShelveTime.gameObject:SetActive(false) + self.Parent:RemoveTimerFun(self.ItemData.Id) + self.RemainTime = 0 + local nowTime = XTime.GetServerNowTimestamp() + + self.IsDisCount = false + local tag = self.ItemData.Tag + local isShowTag = false + if tag > 0 then + isShowTag = true + local path = XPurchaseConfigs.GetTagBgPath(tag) + if path then + self.UiRoot:SetUiSprite(self.ImgTagBg, path) + end + local tagText = XPurchaseConfigs.GetTagDes(tag) + + if XPurchaseConfigs.GetTagType(tag) == XPurchaseConfigs.PurchaseTagType.Discount then + local disCountValue = XDataCenter.PurchaseManager.GetLBDiscountValue(self.ItemData) + if disCountValue < 1 then + local disCountStr = string.format("%.1f", disCountValue * 10) + if self.ItemData.DiscountShowStr and self.ItemData.DiscountShowStr ~= "" then + disCountStr = self.ItemData.DiscountShowStr + end + tagText = disCountStr..tagText + self.IsDisCount = true + else + isShowTag = false + end + end + self.TxtTagDes.text = tagText + + -- path = XPurchaseConfigs.GetTagEffectPath(tag) + -- if path then + -- self.FxGo.AssetName = path + -- self.FxGo.Prefab = self.FxGo.gameObject:LoadPrefab(path) + -- self.FxGo.gameObject:SetActive(true) + --end + else + isShowTag = false + end + self.PanelLabel.gameObject:SetActive(isShowTag) + + local consumeCount = self.ItemData.ConsumeCount or 0 + self.RedPoint.gameObject:SetActive(false) + if self.ItemData.PayKeySuffix then + self.TxtFree.gameObject:SetActiveEx(false) + self.TxtHk.gameObject:SetActiveEx(false) + self.TxtYuan.gameObject:SetActiveEx(true) + local key + if Platform == RuntimePlatform.Android then + key = string.format("%s%s", XPayConfigs.GetPlatformConfig(1), self.ItemData.PayKeySuffix) + else + key = string.format("%s%s", XPayConfigs.GetPlatformConfig(2), self.ItemData.PayKeySuffix) + end + + local payConfig = XPayConfigs.GetPayTemplate(key) + self.TxtYuan.text = payConfig.Amount + else + self.TxtYuan.gameObject:SetActiveEx(false) + if consumeCount == 0 then -- 免费的 + self.TxtHk.gameObject:SetActive(false) + -- self.TxtHk2.gameObject:SetActiveEx(false) + self.TxtFree.gameObject:SetActive(true) + local isShowRedPoint = (self.ItemData.BuyTimes == 0 or self.ItemData.BuyTimes < self.ItemData.BuyLimitTimes) + and (self.ItemData.TimeToShelve == 0 or self.ItemData.TimeToShelve < nowTime) + and (self.ItemData.TimeToUnShelve == 0 or self.ItemData.TimeToUnShelve > nowTime) + -- self.RedPoint.gameObject:SetActive(XDataCenter.PurchaseManager.LBRedPoint()) + self.RedPoint.gameObject:SetActive(isShowRedPoint) + elseif self.IsDisCount or self.ItemData.ConvertSwitch < consumeCount then -- 打折或者存在拥有物品折扣的 + self.TxtFree.gameObject:SetActive(false) + self.TxtHk.gameObject:SetActive(false) + local path = XDataCenter.ItemManager.GetItemIcon(self.ItemData.ConsumeId) + if path then + self.RawConsumeImage2:SetRawImage(path) + end + if self.ItemData.ConvertSwitch <= 0 then + -- self.TxtHk2.gameObject:SetActiveEx(false) + self.TextNotNeed.gameObject:SetActiveEx(true) + else + -- self.TxtHk2.gameObject:SetActiveEx(true) + self.TextNotNeed.gameObject:SetActiveEx(false) + local consumeNum = consumeCount + if self.ItemData.ConvertSwitch > 0 and self.ItemData.ConvertSwitch < consumeCount then + consumeNum = self.ItemData.ConvertSwitch + end + if self.IsDisCount then + local disCountValue = XDataCenter.PurchaseManager.GetLBDiscountValue(self.ItemData) + consumeNum = math.modf(disCountValue * consumeNum) or "" + end + -- self.TxtHk2.text = consumeNum + end + self.TxtPrice.text = self.ItemData.ConsumeCount or "" + else + self.TxtFree.gameObject:SetActive(false) + -- self.TxtHk2.gameObject:SetActiveEx(false) + self.TxtHk.gameObject:SetActive(true) + local path = XDataCenter.ItemManager.GetItemIcon(self.ItemData.ConsumeId) + if path then + self.RawConsumeImage:SetRawImage(path) + end + self.TxtHk.text = self.ItemData.ConsumeCount or "" + end + end + + --是否已拥有 + if self.ImgHave then + local isShowHave + if self.ItemData.RewardGoodsList and #self.ItemData.RewardGoodsList == 1 then + local isHave, isLimitTime = XRewardManager.CheckRewardGoodsListIsOwn(self.ItemData.RewardGoodsList) + isShowHave = isHave and not isLimitTime + else + isShowHave = false + end + self.ImgHave.gameObject:SetActive(isShowHave) + end + + -- 上架时间 + if self.ItemData.TimeToShelve > 0 and nowTime < self.ItemData.TimeToShelve then + self.RemainTime = self.ItemData.TimeToShelve - XTime.GetServerNowTimestamp() + if self.RemainTime > 0 then--大于0,注册。 + self.UpdateTimerType = UpdateTimerTypeEnum.SettOn + self.Parent:RegisterTimerFun(self.ItemData.Id, function() self:UpdateTimer() end) + else + self.Parent:RemoveTimerFun(self.ItemData.Id) + end + self.TxtPutawayTime.gameObject:SetActive(true) + self.TxtHk.gameObject:SetActive(false) + self.TxtFree.gameObject:SetActive(false) + self.TxtYuan.gameObject:SetActive(false) + self.TxtPutawayTime.text = TextManager.GetText("PurchaseSetOnTime", XUiHelper.GetTime(self.RemainTime)) + self:SetBuyDes() + return + end + + -- 达到限购次数 + if self.ItemData.BuyLimitTimes and self.ItemData.BuyLimitTimes > 0 and self.ItemData.BuyTimes == self.ItemData.BuyLimitTimes then + self.TxtPutawayTime.gameObject:SetActive(false) + self.ImgSellout.gameObject:SetActive(true) + self.TxtSetOut.text = TextManager.GetText("PurchaseSettOut") + self.TxtFree.gameObject:SetActive(false) + self.TxtHk.gameObject:SetActive(false) + self.TxtYuan.gameObject:SetActive(false) + self:SetBuyDes() + return + end + + self.TxtQuota.gameObject:SetActive(true) + self:SetBuyDes() + + --有失效时间只显示失效时间。 + -- 失效时间 + self.TxtPutawayTime.gameObject:SetActive(false) + if self.ItemData.TimeToInvalid and self.ItemData.TimeToInvalid > 0 then + self.RemainTime = self.ItemData.TimeToInvalid - XTime.GetServerNowTimestamp() + if self.RemainTime > 0 then--大于0,注册。 + self.UpdateTimerType = UpdateTimerTypeEnum.SettOff + self.Parent:RegisterTimerFun(self.ItemData.Id, self.TimerUpdateCb) + self.TxtUnShelveTime.gameObject:SetActive(true) + if self.IsDisCount then + self.TxtUnShelveTime.text = TextManager.GetText("PurchaseSetOffTime", XUiHelper.GetTime(self.RemainTime, XUiHelper.TimeFormatType.PURCHASELB)) + else + self.TxtUnShelveTime.text = TextManager.GetText("PurchaseSetOffTime", XUiHelper.GetTime(self.RemainTime, XUiHelper.TimeFormatType.PURCHASELB)) + end + else + self.Parent:RemoveTimerFun(self.ItemData.Id) + self.TxtUnShelveTime.gameObject:SetActive(false) + self.ImgSellout.gameObject:SetActive(true) + self.TxtSetOut.text = TextManager.GetText("PurchaseLBSettOff") + end + return + end + + -- 下架时间 + if self.ItemData.TimeToUnShelve > 0 then + if nowTime < self.ItemData.TimeToUnShelve then + self.RemainTime = self.ItemData.TimeToUnShelve - XTime.GetServerNowTimestamp() + if self.RemainTime > 0 then--大于0,注册。 + self.UpdateTimerType = UpdateTimerTypeEnum.SettOff + self.Parent:RegisterTimerFun(self.ItemData.Id, self.TimerUpdateCb) + self.TxtUnShelveTime.gameObject:SetActive(true) + if self.IsDisCount then + self.TxtUnShelveTime.text = TextManager.GetText("PurchaseSetOffTime", XUiHelper.GetTime(self.RemainTime, XUiHelper.TimeFormatType.PURCHASELB)) + else + self.TxtUnShelveTime.text = TextManager.GetText("PurchaseSetOffTime", XUiHelper.GetTime(self.RemainTime, XUiHelper.TimeFormatType.PURCHASELB)) + end + else + self.Parent:RemoveTimerFun(self.ItemData.Id) + self.TxtUnShelveTime.gameObject:SetActive(false) + end + else + self.ImgSellout.gameObject:SetActive(true) + self.TxtUnShelveTime.text = "" + self.TxtSetOut.text = TextManager.GetText("PurchaseLBSettOff") + end + else + self.TxtUnShelveTime.gameObject:SetActive(false) + end +end + +function XUiPurchaseLBListItem:SetBuyDes() + local clientResetInfo = self.ItemData.ClientResetInfo or {} + if Next(clientResetInfo) == nil then + if self.ItemData.BuyLimitTimes > 0 then + self.TxtQuota.text = TextManager.GetText("PurchaseLimitBuy", self.ItemData.BuyTimes, self.ItemData.BuyLimitTimes) + else + self.TxtQuota.text = "" + end + return + end + + local textKey = "" + if clientResetInfo.ResetType == XPurchaseConfigs.RestTypeConfig.Interval then + self.TxtQuota.text = TextManager.GetText("PurchaseRestTypeInterval", clientResetInfo.DayCount, self.ItemData.BuyTimes, self.ItemData.BuyLimitTimes) + return + elseif clientResetInfo.ResetType == XPurchaseConfigs.RestTypeConfig.Day then + textKey = "PurchaseRestTypeDay" + elseif clientResetInfo.ResetType == XPurchaseConfigs.RestTypeConfig.Week then + textKey = "PurchaseRestTypeWeek" + elseif clientResetInfo.ResetType == XPurchaseConfigs.RestTypeConfig.Month then + textKey = "PurchaseRestTypeMonth" + end + self.TxtQuota.text = TextManager.GetText(textKey, self.ItemData.BuyTimes, self.ItemData.BuyLimitTimes) +end + +-- 更新倒计时 +function XUiPurchaseLBListItem:UpdateTimer(isRecover) + if self.ItemData.TimeToInvalid == 0 and self.ItemData.TimeToUnShelve == 0 and self.ItemData.TimeToShelve == 0 then + return + end + + if isRecover then + if self.UpdateTimerType == UpdateTimerTypeEnum.SettOff then + if self.ItemData.TimeToInvalid > 0 then + self.RemainTime = self.ItemData.TimeToInvalid - XTime.GetServerNowTimestamp() + else + self.RemainTime = self.ItemData.TimeToUnShelve - XTime.GetServerNowTimestamp() + end + else + self.RemainTime = self.ItemData.TimeToShelve - XTime.GetServerNowTimestamp() + end + else + self.RemainTime = self.RemainTime - 1 + end + + if self.RemainTime <= 0 then + self.Parent:RemoveTimerFun(self.ItemData.Id) + if self.UpdateTimerType == UpdateTimerTypeEnum.SettOff then + self.ImgSellout.gameObject:SetActive(true) + self.TxtUnShelveTime.text = "" + self.TxtSetOut.text = TextManager.GetText("PurchaseLBSettOff") + return + end + + self.TxtPutawayTime.text = "" + return + end + + if self.UpdateTimerType == UpdateTimerTypeEnum.SettOff then + self.TxtUnShelveTime.text = TextManager.GetText("PurchaseSetOffTime", XUiHelper.GetTime(self.RemainTime, XUiHelper.TimeFormatType.PURCHASELB)) + return + end + + self.TxtPutawayTime.text = TextManager.GetText("PurchaseSetOnTime", XUiHelper.GetTime(self.RemainTime)) +end +return XUiPurchaseLBListItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPurchase/XUiPurchaseLBTips.lua b/Resources/Scripts/XUi/XUiPurchase/XUiPurchaseLBTips.lua new file mode 100644 index 00000000..c4024b15 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPurchase/XUiPurchaseLBTips.lua @@ -0,0 +1,330 @@ +local XUiPurchaseLBTips = XClass(nil ,"XUiPurchaseLBTips") +local TextManager = CS.XTextManager +local PurchaseManager +local XUiPurchaseLBTipsListItem = require("XUi/XUiPurchase/XUiPurchaseLBTipsListItem") +local XUiPurchaseSignTip = require("XUi/XUiPurchase/XUiPurchaseSignTip/XUiPurchaseSignTip") +local RestTypeConfig +local LBGetTypeConfig +local Next = _G.next +local UpdateTimerTypeEnum = { + SettOff = 1, + SettOn = 2 +} + +local Application = CS.UnityEngine.Application +local Platform = Application.platform +local RuntimePlatform = CS.UnityEngine.RuntimePlatform + +function XUiPurchaseLBTips:Ctor(ui,uiroot,parent) + PurchaseManager = XDataCenter.PurchaseManager + RestTypeConfig = XPurchaseConfigs.RestTypeConfig + LBGetTypeConfig = XPurchaseConfigs.LBGetTypeConfig + self.CurState = false + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiroot + self.TitleGoPool = {} + self.ItemPool = {} + self.PurchaseSignTipDic = {} -- 签到礼包的奖励预览脚本实例,key:PrefabPath,value:{ PurchaseSignTip, Resource } + self.Parent = parent + XTool.InitUiObject(self) + self:Init() +end + +-- 更新数据 +function XUiPurchaseLBTips:OnRefresh(data,cb) + if not data then + return + end + CS.XAudioManager.PlaySound(1100) + local closeFun = function() self:CloseTips() end + if data.SignInId and data.SignInId ~= 0 then + -- 签到礼包展示预览 + self.PanelCommon.gameObject:SetActiveEx(false) + self.PanelSignGiftPack.gameObject:SetActiveEx(true) + + self.BtnSignGiftPackBgClose.CallBack = closeFun + self.BtnSignGiftPackClose.CallBack = closeFun + for _, v in pairs(self.PurchaseSignTipDic) do + v.PurchaseSignTip.GameObject:SetActiveEx(false) + end + + self.CurPrefabPath = XSignInConfigs.GetSignPrefabPath(data.SignInId) + local purchaseSignTip = (self.PurchaseSignTipDic[self.CurPrefabPath] or {}).PurchaseSignTip + if not purchaseSignTip then + -- 生成对应prefab的实例 + local resource = CS.XResourceManager.Load(self.CurPrefabPath) + local go = CS.UnityEngine.Object.Instantiate(resource.Asset) + go.transform:SetParent(self.SignGiftPackNode, false) + go.gameObject:SetLayerRecursively(self.SignGiftPackNode.gameObject.layer) + purchaseSignTip = XUiPurchaseSignTip.New(go, self, self.UiRoot) + + local info = {} + info.PurchaseSignTip = purchaseSignTip + info.Resource = resource + self.PurchaseSignTipDic[self.CurPrefabPath] = info + end + + purchaseSignTip:Refresh(data, cb) + purchaseSignTip.GameObject:SetActiveEx(true) + else + -- 通用展示预览 + self.PanelCommon.gameObject:SetActiveEx(true) + self.PanelSignGiftPack.gameObject:SetActiveEx(false) + self.RetimeSec = 0 + self.UpdateTimerType = nil + local curtime = XTime.GetServerNowTimestamp() + self.BtnBuy.CallBack = cb + self.BtnBgClick.CallBack = closeFun + self.BtnCloseBg.CallBack = closeFun + self.Data = data + + -- 直接获得的道具 + self.ListDirData = {} + self.ListDayData = {} + local rewards0 = data.RewardGoodsList or {} + for _,v in pairs(rewards0) do + v.LBGetType = LBGetTypeConfig.Direct + table.insert(self.ListDirData,v) + end + -- 每日获得的道具 + local rewards1 = data.DailyRewardGoodsList or {} + for _,v in pairs(rewards1) do + v.LBGetType = LBGetTypeConfig.Day + table.insert(self.ListDayData,v) + end + local isUseMail = self.Data.IsUseMail or false + self.TxtContinue.gameObject:SetActive(isUseMail) + self:SetList() + + if data.TimeToInvalid and data.TimeToInvalid > 0 then + self.RetimeSec = data.TimeToInvalid - curtime + self.UpdateTimerType = UpdateTimerTypeEnum.SettOff + if self.RetimeSec > 0 then--大于0,注册。 + self.TXtTime.gameObject:SetActive(true) + self.Parent:RegisterTimerFun(data.Id,function()self:UpdataTimer()end,true) + self.TXtTime.text = TextManager.GetText("PurchaseSetOffTime",XUiHelper.GetTime(self.RetimeSec)) + else + self.TXtTime.gameObject:SetActive(false) + self.Parent:RemoveTimerFun(data.Id) + end + else + if (data.TimeToShelve == nil or data.TimeToShelve == 0) and (data.TimeToUnShelve == nil or data.TimeToUnShelve == 0) then + self.TXtTime.gameObject:SetActive(false) + else + self.TXtTime.gameObject:SetActive(true) + if data.TimeToUnShelve > 0 then + self.RetimeSec = data.TimeToUnShelve - curtime + self.UpdateTimerType = UpdateTimerTypeEnum.SettOff + self.TXtTime.text = TextManager.GetText("PurchaseSetOffTime",XUiHelper.GetTime(self.RetimeSec)) + else + self.RetimeSec = data.TimeToShelve-curtime + self.UpdateTimerType = UpdateTimerTypeEnum.SettOn + self.TXtTime.text = TextManager.GetText("PurchaseSetOnTime",XUiHelper.GetTime(self.RetimeSec)) + end + if self.RetimeSec > 0 then--大于0,注册。 + self.Parent:RegisterTimerFun(data.Id,function()self:UpdataTimer()end,true) + else + self.Parent:RemoveTimerFun(data.Id) + end + end + end + + self.TxtName.text = data.Name + local assetpath = XPurchaseConfigs.GetIconPathByIconName(data.Icon) + if assetpath and assetpath.AssetPath then + self.RawImageIcon:SetRawImage(assetpath.AssetPath) + end + self:SetBuyDes() + + if self.Data.UiType == XPurchaseConfigs.YKType.Month or self.Data.UiType == XPurchaseConfigs.YKType.Week or self.Data.UiType == XPurchaseConfigs.YKType.Day then + self.TxtLimitBuy.gameObject:SetActiveEx(false) + end + + if data.PayKeySuffix then + local key + if Platform == RuntimePlatform.Android then + key = string.format("%s%s", XPayConfigs.GetPlatformConfig(1), data.PayKeySuffix) + else + key = string.format("%s%s", XPayConfigs.GetPlatformConfig(2), data.PayKeySuffix) + end + + local payConfig = XPayConfigs.GetPayTemplate(key) + self.RawImageConsume.gameObject:SetActive(true) + local path = CS.XGame.ClientConfig:GetString("PurchaseBuyRiYuanIconPath") + self.RawImageConsume:SetRawImage(path) + self.BtnBuy:SetName(payConfig.Amount) + else + if data.ConsumeCount == 0 then + self.RawImageConsume.gameObject:SetActive(false) + self.BtnBuy:SetName(TextManager.GetText("PurchaseFreeText")) + else + self.RawImageConsume.gameObject:SetActive(true) + self.BtnBuy:SetName(data.ConsumeCount) + local icon = XDataCenter.ItemManager.GetItemIcon(data.ConsumeId) + if icon then + self.RawImageConsume:SetRawImage(icon) + end + end + end + + if (data.BuyLimitTimes > 0 and data.BuyTimes == data.BuyLimitTimes) or (data.TimeToShelve > 0 and data.TimeToShelve <= curtime) or (data.TimeToUnShelve > 0 and data.TimeToUnShelve <= curtime) then --卖完了,不管。 + self.TXtTime.text = "" + if self.UpdateTimerType then + self.Parent:RemoveTimerFun(self.Data.Id) + end + self.BtnBuy:SetButtonState(XUiButtonState.Disable) + else + self.BtnBuy:SetButtonState(XUiButtonState.Normal) + end + end + self.GameObject:SetActive(true) + self.UiRoot:PlayAnimation("BuyTipsEnable") +end + +-- 更新倒计时 +function XUiPurchaseLBTips:UpdataTimer() + self.RetimeSec = self.RetimeSec - 1 + + if self.RetimeSec <= 0 then + self.Parent:RemoveTimerFun(self.Data.Id) + if self.UpdateTimerType == UpdateTimerTypeEnum.SettOff then + self.TXtTime.text = TextManager.GetText("PurchaseLBSettOff") + return + end + + self.TXtTime.text = "" + return + end + + if self.UpdateTimerType == UpdateTimerTypeEnum.SettOff then + self.TXtTime.text = TextManager.GetText("PurchaseSetOffTime",XUiHelper.GetTime(self.RetimeSec)) + return + end + + self.TXtTime.text = TextManager.GetText("PurchaseSetOnTime",XUiHelper.GetTime(self.RetimeSec)) +end + +function XUiPurchaseLBTips:Init() + self.AssetPanel = XUiPanelAsset.New(self,self.PanelAssetPay,XDataCenter.ItemManager.ItemId.FreeGem,XDataCenter.ItemManager.ItemId.HongKa) +end + +function XUiPurchaseLBTips:CloseTips() + for _,v in pairs(self.ItemPool) do + v.Transform:SetParent(self.PoolGo) + v.GameObject:SetActive(false) + end + + for _,v in pairs(self.TitleGoPool) do + v:SetParent(self.PoolGo) + v.gameObject:SetActive(false) + end + + if self.UpdateTimerType then + self.Parent:RemoveTimerFun(self.Data.Id) + self.Parent:RecoverTimerFun(self.Data.Id) + end + self.GameObject:SetActive(false) +end + +function XUiPurchaseLBTips:SetList() + local index1 = 1 + local index2 = 1 + + if Next(self.ListDirData) ~= nil then + local obj = self:GetTitlGo(index1) + index1 = index1 + 1 + obj.transform:Find("TxtTitle"):GetComponent("Text").text = TextManager.GetText("PurchaseDirGet") + for _,v in pairs(self.ListDirData)do + local item = self:GetItemObj(index2) + item:OnRefresh(v) + index2 = index2 + 1 + end + end + + if Next(self.ListDayData) ~= nil then + local obj = self:GetTitlGo(index1) + obj.transform:Find("TxtTitle"):GetComponent("Text").text = self.Data.Desc or "" + for _,v in pairs(self.ListDayData)do + local item = self:GetItemObj(index2) + item:OnRefresh(v) + index2 = index2 + 1 + end + end +end + +function XUiPurchaseLBTips:GetTitlGo(index) + if self.TitleGoPool[index] then + self.TitleGoPool[index].gameObject:SetActive(true) + self.TitleGoPool[index]:SetParent(self.PanelReward) + return self.TitleGoPool[index] + end + + local obj = CS.UnityEngine.Object.Instantiate(self.ImgTitle,self.PanelReward) + obj.gameObject:SetActive(true) + obj:SetParent(self.PanelReward) + table.insert(self.TitleGoPool, obj) + return obj +end + +function XUiPurchaseLBTips:GetItemObj(index) + if self.ItemPool[index] then + self.ItemPool[index].GameObject:SetActive(true) + self.ItemPool[index].Transform:SetParent(self.PanelReward) + return self.ItemPool[index] + end + + local itemobj = CS.UnityEngine.Object.Instantiate(self.PanelPropItem,self.PanelReward) + itemobj.gameObject:SetActive(true) + itemobj:SetParent(self.PanelReward) + local item = XUiPurchaseLBTipsListItem.New(itemobj) + item:Init(self.UiRoot) + table.insert(self.ItemPool, item) + return item +end + +-- [监听动态列表事件] +function XUiPurchaseLBTips:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self,self.UiRoot) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.ListData[index] + grid:OnRefresh(data) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + end +end + +function XUiPurchaseLBTips:SetBuyDes() + if self.Data.UiType == XPurchaseConfigs.YKType.Month or self.Data.UiType == XPurchaseConfigs.YKType.Week or self.Data.UiType == XPurchaseConfigs.YKType.Day then + self.TxtLimitBuy.gameObject:SetActiveEx(false) + end + local clientResetInfo = self.Data.ClientResetInfo or {} + if Next(clientResetInfo) == nil then + self.TxtLimitBuy.text = "" + return + end + + local textKey = nil + if clientResetInfo.ResetType == RestTypeConfig.Interval then + self.TxtLimitBuy.text = TextManager.GetText("PurchaseRestTypeInterval",clientResetInfo.DayCount,self.Data.BuyTimes,self.Data.BuyLimitTimes) + return + elseif clientResetInfo.ResetType == RestTypeConfig.Day then + textKey = "PurchaseRestTypeDay" + elseif clientResetInfo.ResetType == RestTypeConfig.Week then + textKey = "PurchaseRestTypeWeek" + elseif clientResetInfo.ResetType == RestTypeConfig.Month then + textKey = "PurchaseRestTypeMonth" + end + + if not textKey then + self.TxtLimitBuy.text = "" + return + end + self.TxtLimitBuy.text = TextManager.GetText(textKey,self.Data.BuyTimes,self.Data.BuyLimitTimes) + + if self.Data.UiType == XPurchaseConfigs.YKType.Month or self.Data.UiType == XPurchaseConfigs.YKType.Week or self.Data.UiType == XPurchaseConfigs.YKType.Day then + self.TxtLimitBuy.gameObject:SetActiveEx(false) + end +end + +return XUiPurchaseLBTips \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPurchase/XUiPurchaseLBTipsListItem.lua b/Resources/Scripts/XUi/XUiPurchase/XUiPurchaseLBTipsListItem.lua new file mode 100644 index 00000000..2beca50f --- /dev/null +++ b/Resources/Scripts/XUi/XUiPurchase/XUiPurchaseLBTipsListItem.lua @@ -0,0 +1,23 @@ +local XUiPurchaseLBTipsListItem = XClass(nil, "XUiPurchaseLBTipsListItem") + +function XUiPurchaseLBTipsListItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +-- 更新数据 +function XUiPurchaseLBTipsListItem:OnRefresh(itemData) + if not itemData then + return + end + + self.ItemData = itemData + self.GridItemUi:Refresh(itemData) +end + +function XUiPurchaseLBTipsListItem:Init(root) + self.GridItemUi = XUiGridCommon.New(root,self.GridItem) +end + +return XUiPurchaseLBTipsListItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPurchase/XUiPurchasePay.lua b/Resources/Scripts/XUi/XUiPurchase/XUiPurchasePay.lua new file mode 100644 index 00000000..a1d48553 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPurchase/XUiPurchasePay.lua @@ -0,0 +1,174 @@ +local XUiPurchasePay = XClass(nil, "XUiPurchasePay") +local TextManager = CS.XTextManager +local Next = _G.next +local XUiPurchasePayListItem = require("XUi/XUiPurchase/XUiPurchasePayListItem") +local TabExConfig + +local Application = CS.UnityEngine.Application +local Platform = Application.platform +local RuntimePlatform = CS.UnityEngine.RuntimePlatform + +function XUiPurchasePay:Ctor(ui, uiRoot, tab) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + self.Tab = tab + TabExConfig = XPurchaseConfigs.TabExConfig + XTool.InitUiObject(self) + self:Init() +end + +function XUiPurchasePay:OnUpdate() + if self.CurUitype then + self:OnRefresh(self.CurUitype) + end +end + +-- 更新数据 +function XUiPurchasePay:OnRefresh(uiType) + self.CurUitype = uiType + self.CurState = false + self.PanelPurchase.gameObject:SetActive(false) + local data = XDataCenter.PurchaseManager.GetDatasByUiType(uiType) or {} + self.GameObject:SetActive(true) + self.Len = #data or 0 + if Next(data) then + table.sort(data, XUiPurchasePay.SortFun) + end + self.ListData = data + --XLog.Warning("XUiPurchasePay:OnRefresh",data) + self.DynamicTable:SetDataSource(data) + self.DynamicTable:ReloadDataASync(1) + if self.Tab == TabExConfig.Sample then + self.UiRoot:PlayAnimation("PanelPurchaseBig") + else + self.UiRoot:PlayAnimation("PanelPurchaseSmall") + end +end + +function XUiPurchasePay.SortFun(a,b) + return a.Amount < b.Amount +end + +function XUiPurchasePay:OnUpdate() + if self.CurUitype then + self:OnRefresh(self.CurUitype) + end +end + +function XUiPurchasePay:HidePanel() + self.GameObject:SetActive(false) + self.CurState = false + XEventManager.RemoveEventListener(XEventId.EVENT_PURCAHSE_BUYUSERIYUAN, self.OnUpdate, self) + self.PanelPurchase.gameObject:SetActive(false) +end + +function XUiPurchasePay:ShowPanel() + XEventManager.AddEventListener(XEventId.EVENT_PURCAHSE_BUYUSERIYUAN, self.OnUpdate, self) + self.GameObject:SetActive(true) +end + +function XUiPurchasePay:InitList() + self.DynamicTable = XDynamicTableNormal.New(self.SviewRecharge) + self.DynamicTable:SetProxy(XUiPurchasePayListItem) + self.DynamicTable:SetDelegate(self) +end + +function XUiPurchasePay:Init() + self:InitList() + self.BtnBuy.CallBack = function() self:OnBtnBuyClick() end +end + +function XUiPurchasePay:OnBtnBuyClick() + if not XDataCenter.PayManager.CheckCanBuy(self.SelectId) then + return + end + + local key + if self.PayKeySuffix == nil then + if self.BuyKey then + XDataCenter.PayManager.Pay(self.BuyKey) + return + end + XLog.Error("配置出错,检查PurcahseItem表中PayKeySuffix,或者是否是购买虹卡") + return + end + + if Platform == RuntimePlatform.Android then + key = string.format("%s%s", XPayConfigs.GetPlatformConfig(1), self.PayKeySuffix) + else + key = string.format("%s%s", XPayConfigs.GetPlatformConfig(2), self.PayKeySuffix) + end + XDataCenter.PayManager.Pay(key, 1, { self.SelectId }, self.SelectId) +end + +function XUiPurchasePay:OnBuySuccessCB() + self.BuyKey = nil + XUiManager.TipText("PurchaseBuySuccessTips", XUiManager.UiTipType.Success) +end +-- [监听动态列表事件] +function XUiPurchasePay:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.ListData[index] + grid:OnRefresh(data) + if self.CurItemIndex == index then + grid:OnSelectState(self.CurState) + end + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + grid:OnClick() + self:SetListItemState(index) + if self.CurItemIndex ~= index or self.CurState == false then + self.CurItemIndex = index + self.CurState = true + self.PanelPurchase.gameObject:SetActive(true) + else + self.CurState = false + self.PanelPurchase.gameObject:SetActive(false) + end + + local data = self.ListData[index] or {} + local price = data.Amount or "" + local name = data.Name or "" + if data.PayKeySuffix then + price = self:GetPayAmount(data) + name = TextManager.GetText("PurchaseBuyHeiKaName") + self.BuyKey = data.Key + self.PayKeySuffix = data.PayKeySuffix + self.SelectId = data.Id + self.TxtTips.text = TextManager.GetText("PusrchaseBuyTips", price, name) + else + self.BuyKey = data.Key + self.TxtTips.text = TextManager.GetText("PusrchaseBuyTips",price,name) + end + + + + + CS.XAudioManager.PlaySound(1011) + end +end + +function XUiPurchasePay:GetPayAmount(data) + local key + if Platform == RuntimePlatform.Android then + key = string.format("%s%d", XPayConfigs.GetPlatformConfig(1), data.PayKeySuffix) + else + key = string.format("%s%d", XPayConfigs.GetPlatformConfig(2), data.PayKeySuffix) + end + + local payConfig = XPayConfigs.GetPayTemplate(key) + return payConfig and payConfig.Amount or 0 +end + +function XUiPurchasePay:SetListItemState(index) + for i = 1,self.Len do + local item = self.DynamicTable:GetGridByIndex(i) + if item and i ~= index then + item:OnSelectState(false) + end + end +end + +return XUiPurchasePay \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPurchase/XUiPurchasePayAdd.lua b/Resources/Scripts/XUi/XUiPurchase/XUiPurchasePayAdd.lua new file mode 100644 index 00000000..6017f64d --- /dev/null +++ b/Resources/Scripts/XUi/XUiPurchase/XUiPurchasePayAdd.lua @@ -0,0 +1,129 @@ +local XUiPurchasePayAdd = XClass(nil, "XUiPurchasePayAdd") +local TextManager = CS.XTextManager +local XUiPurchasePayAddListItem = require("XUi/XUiPurchase/XUiPurchasePayAddListItem") + +function XUiPurchasePayAdd:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + self.PurchaseCanGet = {} + self.PurchaseGeted = {} + self.PurchaseCanotGet = {} + self.ListData = {} + self.CurLookState = XSaveTool.GetData(XPurchaseConfigs.LjczLookStateKey) or CS.XGame.ClientConfig:GetInt(XPurchaseConfigs.PurchaseLJCZDefaultLookStateKey) + XTool.InitUiObject(self) + self:Init() +end + +-- 更新数据 +function XUiPurchasePayAdd:OnRefresh() + local data = XDataCenter.PurchaseManager.GetAccumulatePayConfig() + if not data then + return + end + + local beginTimeStr, endTimeStr = XDataCenter.PurchaseManager.GetAccumulatePayTimeStr() + if beginTimeStr and endTimeStr then + self.TxtLjczTime.text = beginTimeStr .. "--" .. endTimeStr + else + self.TxtLjczTime.text = "" + end + + self.TxtPaynumber.text = XDataCenter.PurchaseManager.GetAccumulatedPayCount() + + self.CurPayIds = data.PayRewardId or {} + self:SetListData() + self:SetLookState(self.CurLookState) + + -- if XDataCenter.SetManager.RechargeType == XSetConfigs.RechargeEnum.Close then + -- self.PanelLjcjValue.gameObject:SetActiveEx(false) + -- else + -- self.PanelLjcjValue.gameObject:SetActiveEx(true) + -- end +end + +function XUiPurchasePayAdd:SetListData() + self.ListData = {} + self.PurchaseCanGet = {} + self.PurchaseGeted = {} + self.PurchaseCanotGet = {} + for _, id in pairs(self.CurPayIds) do + local state = XDataCenter.PurchaseManager.PurchaseAddRewardState(id) + if state == XPurchaseConfigs.PurchaseRewardAddState.CanGet then + table.insert(self.PurchaseCanGet, id) + elseif state == XPurchaseConfigs.PurchaseRewardAddState.Geted then + table.insert(self.PurchaseGeted, id) + elseif state == XPurchaseConfigs.PurchaseRewardAddState.CanotGet then + table.insert(self.PurchaseCanotGet, id) + end + end + + for _, id in pairs(self.PurchaseCanGet) do + table.insert(self.ListData, id) + end + + for _, id in pairs(self.PurchaseCanotGet) do + table.insert(self.ListData, id) + end + + for _, id in pairs(self.PurchaseGeted) do + table.insert(self.ListData, id) + end + self.DynamicTable:SetDataSource(self.ListData) + self.DynamicTable:ReloadDataASync(1) +end + +function XUiPurchasePayAdd:Init() + self:InitList() + local closeFun = function() self.GameObject:SetActive(false) end + self.BtnClose.CallBack = closeFun + self.BtnLjczHelp.CallBack = function() self:OnBtnHelp() end + self.BtnLjczLook.CallBack = function() self:OnBtnLook() end + self.BtnCloseBg.CallBack = closeFun +end + +function XUiPurchasePayAdd:OnBtnLook() + if self.CurLookState == XPurchaseConfigs.LjczLookState.Show then + self.CurLookState = XPurchaseConfigs.LjczLookState.Hide + else + self.CurLookState = XPurchaseConfigs.LjczLookState.Show + end + self:SetLookState(self.CurLookState) +end + +function XUiPurchasePayAdd:SetLookState(state) + local isShow = (state == XPurchaseConfigs.LjczLookState.Show) + self.ImgLook.gameObject:SetActive(isShow) + self.ImgUnlook.gameObject:SetActive(not isShow) + local num = XDataCenter.PurchaseManager.GetAccumulatedPayCount() + if isShow then + self.TxtPaynumber.text = num + else + self.TxtPaynumber.text = TextManager.GetText("PurchaseAddHide") + end + + XSaveTool.SaveData(XPurchaseConfigs.LjczLookStateKey, state) +end + + +function XUiPurchasePayAdd:OnBtnHelp() + XUiManager.UiFubenDialogTip("", TextManager.GetText("PurchaseAddPayDes") or "") +end + +function XUiPurchasePayAdd:InitList() + self.DynamicTable = XDynamicTableNormal.New(self.PanelRewardGroup) + self.DynamicTable:SetProxy(XUiPurchasePayAddListItem) + self.DynamicTable:SetDelegate(self) +end + +-- [监听动态列表事件] +function XUiPurchasePayAdd:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self.UiRoot, self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.ListData[index] + grid:OnRefresh(data) + -- elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + end +end +return XUiPurchasePayAdd \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPurchase/XUiPurchasePayAddListItem.lua b/Resources/Scripts/XUi/XUiPurchase/XUiPurchasePayAddListItem.lua new file mode 100644 index 00000000..bda365c5 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPurchase/XUiPurchasePayAddListItem.lua @@ -0,0 +1,119 @@ +local XUiPurchasePayAddListItem = XClass(nil, "XUiPurchasePayAddListItem") +local TextManager = CS.XTextManager +local Object = CS.UnityEngine.Object + +function XUiPurchasePayAddListItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RewardItemList = {} + self.RewardGetedCb = function() self:RewardGetedUpdate() end + XTool.InitUiObject(self) + self.BtnTcanchaungBlueCb = function()self:BtnGetClick() end +end + +-- 更新数据 +function XUiPurchasePayAddListItem:OnRefresh(id) + if not id then + return + end + + self.Id = id + self.ItemData = XPurchaseConfigs.GetAccumulateRewardConfigById(id) + if not self.ItemData then + return + end + + local money = self.ItemData.Money + local count = XDataCenter.PurchaseManager.GetAccumulatedPayCount() + if count >= money then + if not XDataCenter.PurchaseManager.AccumulateRewardGeted(id) then + self.BtnTcanchaungBlue.gameObject:SetActiveEx(true) + self.BtnReceiveHave.gameObject:SetActiveEx(false) + self.BtnTcanchaungBlue:SetButtonState(XUiButtonState.Normal) + self.BtnTcanchaungBlue.CallBack = self.BtnTcanchaungBlueCb + else + self.BtnTcanchaungBlue.gameObject:SetActiveEx(false) + self.BtnReceiveHave.gameObject:SetActiveEx(true) + self.BtnTcanchaungBlue.CallBack = nil + end + else + if XDataCenter.PurchaseManager.AccumulateRewardGeted(id) then + self.BtnTcanchaungBlue.gameObject:SetActiveEx(false) + self.BtnReceiveHave.gameObject:SetActiveEx(true) + self.BtnTcanchaungBlue.CallBack = nil + else + self.BtnTcanchaungBlue.gameObject:SetActiveEx(true) + self.BtnReceiveHave.gameObject:SetActiveEx(false) + self.BtnTcanchaungBlue:SetButtonState(XUiButtonState.Disable) + end + end + + local bigRewardId = self.ItemData.BigRewardId + local smallRewardId = self.ItemData.SmallRewardId + if self.SmallRewardId ~= smallRewardId then + self.SmallRewardId = smallRewardId + self:SetReward(smallRewardId) + end + if self.BigRewardId ~= bigRewardId then + self.BigRewardId = bigRewardId + if not self.BigItem then + self.BigItem = XUiGridCommon.New(self.UiRoot, self.BigRewardGrid) + XTool.InitUiObject(self.BigItem) + self.BigItem.ButtonClick.CallBack = function() self.BigItem:OnBtnClickClick() end + end + local rewards = XRewardManager.GetRewardList(bigRewardId) + if rewards and rewards[1] then + self.BigItem:Refresh(rewards[1]) + end + end + + self.TxtRewareTitle.text = TextManager.GetText("AccumulateMonyDes",money) +end + +function XUiPurchasePayAddListItem:SetReward(rewardId) + local rewards = XRewardManager.GetRewardList(rewardId) + if not rewards then + return + end + + local rewardCount = #rewards + for i = 1, rewardCount do + local item = self.RewardItemList[i] + if not item then + local ui = Object.Instantiate(self.SmallRewardGrid) + ui.transform:SetParent(self.RewardContent, false) + ui.gameObject:SetActive(true) + item = XUiGridCommon.New(self.UiRoot, ui) + XTool.InitUiObject(item) + item.ButtonClick.CallBack = function() item:OnBtnClickClick() end + table.insert(self.RewardItemList,item) + end + end + + for i = 1, #self.RewardItemList do + self.RewardItemList[i].GameObject:SetActive(i <= rewardCount) + if i <= rewardCount then + self.RewardItemList[i]:Refresh(rewards[i]) + end + end +end + +function XUiPurchasePayAddListItem:Init(uiRoot, parent) + self.UiRoot = uiRoot + self.Parent = parent +end + +function XUiPurchasePayAddListItem:BtnGetClick() + local payId = XDataCenter.PurchaseManager.GetAccumulatePayId() + XDataCenter.PurchaseManager.GetAccumulatePayReq(payId, self.Id, self.RewardGetedCb) +end + +function XUiPurchasePayAddListItem:RewardGetedUpdate() + if not self.Id then + return + end + + self:OnRefresh(self.Id) +end + +return XUiPurchasePayAddListItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPurchase/XUiPurchasePayListItem.lua b/Resources/Scripts/XUi/XUiPurchase/XUiPurchasePayListItem.lua new file mode 100644 index 00000000..f3cb5e87 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPurchase/XUiPurchasePayListItem.lua @@ -0,0 +1,64 @@ +local XUiPurchasePayListItem = XClass(nil, "XUiPurchasePayListItem") +local TextManager = CS.XTextManager +local Application = CS.UnityEngine.Application +local Platform = Application.platform +local RuntimePlatform = CS.UnityEngine.RuntimePlatform + +function XUiPurchasePayListItem:Ctor(ui,uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + XTool.InitUiObject(self) + self.PanelLabel.gameObject:SetActive(false) +end + +function XUiPurchasePayListItem:Init(uiRoot,parent) + self.UiRoot = uiRoot + self.Parent = parent +end + +-- 更新数据 +function XUiPurchasePayListItem:OnRefresh(itemData) + if not itemData then + return + end + + self.ItemData = itemData + self.CurState = false + self:SetSelectState(false) + self:SetData() +end + +function XUiPurchasePayListItem:SetData() + self.TxtCzsl.text = self.ItemData.Name + self.TxtContent.text = self.ItemData.Desc + if self.ItemData.Icon then + local assetpath = XPurchaseConfigs.GetIconPathByIconName(self.ItemData.Icon) + if assetpath and assetpath.AssetPath then + self.ImgCz:SetRawImage(assetpath.AssetPath,function()self.ImgCz:SetNativeSize()end) + end + end + + self.TxtYuan.text = self.ItemData.Amount + +end + +function XUiPurchasePayListItem:OnSelectState(state) + if self.CurState == state then + return + end + + self.CurState = state + self:SetSelectState(state) +end + +function XUiPurchasePayListItem:SetSelectState(state) + self.ImgSelectCz.gameObject:SetActive(state) +end + +function XUiPurchasePayListItem:OnClick() + self.CurState = not self.CurState + self:SetSelectState(self.CurState) +end + +return XUiPurchasePayListItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPurchase/XUiPurchaseSignTip/XUiPurchaseSignTip.lua b/Resources/Scripts/XUi/XUiPurchase/XUiPurchaseSignTip/XUiPurchaseSignTip.lua new file mode 100644 index 00000000..dd618336 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPurchase/XUiPurchaseSignTip/XUiPurchaseSignTip.lua @@ -0,0 +1,81 @@ +-- 签到礼包奖励预览脚本,使用签到UI界面,一个脚本对应一个签到prefab +-- 每个签到轮次有一个XUiPurchaseSignTipRound脚本实例 + +local XUiPurchaseSignTip = XClass(nil, "XUiPurchaseSignTip") + +local XUiPurchaseSignTipRound = require("XUi/XUiPurchase/XUiPurchaseSignTip/XUiPurchaseSignTipRound") +local MAX_COUNT = 10 + +function XUiPurchaseSignTip:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + + self.PanelRounds = {} + self.PanelSignPrefabs = {} + + XTool.InitUiObject(self) + self:InitComponent() +end + +function XUiPurchaseSignTip:InitComponent() + -- 获取并隐藏各个轮次界面 + for i = 1, MAX_COUNT do + local panelRound = XUiHelper.TryGetComponent(self.Transform, "PanelRound" .. i, nil) + if not panelRound then + break + end + panelRound.gameObject:SetActiveEx(false) + table.insert(self.PanelRounds, panelRound) + end +end + +function XUiPurchaseSignTip:Refresh(purchaseData, buyCb) + self.PurchaseData = purchaseData + self.BuyCb = buyCb + local signInInfos = XSignInConfigs.GetSignInInfos(purchaseData.SignInId) + + -- 根据配置信息实例对应的轮次脚本 + for i = 1, #signInInfos do + local panelRound = self.PanelRounds[i] + if not panelRound then + XLog.Error(string.format("XUiPurchaseSignTip:Refresh函数错误,SignInId:%s 的UI界面PanelRound不足,轮次为:%s ", tostring(purchaseData.SignInId), tostring(i))) + break + end + local signPrefab = self.PanelSignPrefabs[i] + if not signPrefab then + signPrefab = XUiPurchaseSignTipRound.New(panelRound, self, self.RootUi) + end + self.PanelSignPrefabs[i] = signPrefab + signPrefab:Refresh(purchaseData, i, self.BuyCb) + end + + -- 默认显示第一个轮次 + self:RefreshPanel(1) +end + +function XUiPurchaseSignTip:RegisterTimerFun(id, fun) + self.RootUi.Parent:RegisterTimerFun(id, fun) +end + +function XUiPurchaseSignTip:RemoveTimerFun(id) + self.RootUi.Parent:RemoveTimerFun(id) +end + +--- +--- 显示并刷新第'round'轮次的界面 +function XUiPurchaseSignTip:RefreshPanel(round) + for k,v in pairs(self.PanelSignPrefabs) do + v:SetSignActive(k == round, round) + end +end + +function XUiPurchaseSignTip:OnClose() + for _, round in pairs(self.PanelSignPrefabs) do + round:OnClose() + end + + self.GameObject:SetActiveEx(false) +end + +return XUiPurchaseSignTip \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPurchase/XUiPurchaseSignTip/XUiPurchaseSignTipGridDay.lua b/Resources/Scripts/XUi/XUiPurchase/XUiPurchaseSignTip/XUiPurchaseSignTipGridDay.lua new file mode 100644 index 00000000..6fa1d16d --- /dev/null +++ b/Resources/Scripts/XUi/XUiPurchase/XUiPurchaseSignTip/XUiPurchaseSignTipGridDay.lua @@ -0,0 +1,37 @@ +local XUiPurchaseSignTipGridDay = XClass(nil, "XUiPurchaseSignTipGridDay") + +function XUiPurchaseSignTipGridDay:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self.Grid = nil + + XTool.InitUiObject(self) + self:InitComponent() +end + +function XUiPurchaseSignTipGridDay:InitComponent() + self.PanelNext.gameObject:SetActiveEx(false) + self.PanelNow.gameObject:SetActiveEx(false) + self.PanelHaveReceive.gameObject:SetActiveEx(false) + self.PanelEffect.gameObject:SetActiveEx(false) +end + +function XUiPurchaseSignTipGridDay:Refresh(config) + self.Config = config + self.TxtDay.text = string.format("%02d", config.Pre) + + local rewardList = XRewardManager.GetRewardList(config.ShowRewardId) + if not rewardList or #rewardList <= 0 then + return + end + + if not self.Grid then + self.Grid = XUiGridCommon.New(self.RootUi, self.GridCommon) + end + + self.Grid:Refresh(rewardList[1]) + self.GameObject:SetActiveEx(true) +end + +return XUiPurchaseSignTipGridDay \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPurchase/XUiPurchaseSignTip/XUiPurchaseSignTipRound.lua b/Resources/Scripts/XUi/XUiPurchase/XUiPurchaseSignTip/XUiPurchaseSignTipRound.lua new file mode 100644 index 00000000..5264d0cd --- /dev/null +++ b/Resources/Scripts/XUi/XUiPurchase/XUiPurchaseSignTip/XUiPurchaseSignTipRound.lua @@ -0,0 +1,326 @@ +-- 签到礼包奖励预览,签到轮次脚本,每个签到轮次都有一个面板,面板上的背景、按钮等元素不共享,重复存在各个签到轮次界面上 + +local XUiPurchaseSignTipRound = XClass(nil, "XUiPurchaseSignTipRound") + +local XUiPurchaseSignTipGridDay = require("XUi/XUiPurchase/XUiPurchaseSignTip/XUiPurchaseSignTipGridDay") +local RuntimePlatform = CS.UnityEngine.RuntimePlatform +local UpdateTimerTypeEnum = { + SettOff = 1, + SettOn = 2 +} + +function XUiPurchaseSignTipRound:Ctor(ui, parent, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Parent = parent + self.RootUi = rootUi + + XTool.InitUiObject(self) + self:InitComponent() + self:AddListener() +end + +function XUiPurchaseSignTipRound:InitComponent() + self.DaySmallGrids = {} + table.insert(self.DaySmallGrids, XUiPurchaseSignTipGridDay.New(self.GridDaySmall, self.RootUi)) + self.DayBigGrids = {} + table.insert(self.DayBigGrids, XUiPurchaseSignTipGridDay.New(self.GridDayBig, self.RootUi)) + self.BtnList = {} + table.insert(self.BtnList, self.BtnTab) + + self.PanelPrice.gameObject:SetActiveEx(true) + self.BtnPurchase.gameObject:SetActiveEx(true) + + self.BtnReceive.gameObject:SetActiveEx(false) + self.PanelPurchaseRemain.gameObject:SetActiveEx(false) +end + +function XUiPurchaseSignTipRound:AddListener() + self.BtnHelp.CallBack = function() + self:OnBtnHelpClick() + end +end + +function XUiPurchaseSignTipRound:Refresh(purchaseData, round, buyCb) + self.Round = round + self.PurchaseData = purchaseData + self.BtnPurchase.CallBack = function() buyCb() end + self.UpdateTimerType = nil + + self.SignInInfos = XSignInConfigs.GetSignInInfos(purchaseData.SignInId) + + local nowTime = XTime.GetServerNowTimestamp() + + self:SetBuyDes() + if purchaseData.PayKeySuffix then + local key + local Platform = Application.platform + if Platform == RuntimePlatform.Android then + key = string.format("%s%s", XPayConfigs.GetPlatformConfig(1), purchaseData.PayKeySuffix) + else + key = string.format("%s%s", XPayConfigs.GetPlatformConfig(2), purchaseData.PayKeySuffix) + end + + local payConfig = XPayConfigs.GetPayTemplate(key) + self.RImPrice.gameObject:SetActiveEx(true) + local path = CS.XGame.ClientConfig:GetString("PurchaseBuyRiYuanIconPath") + self.RImPrice:SetRawImage(path) + self.PanelSale.gameObject:SetActiveEx(false) + self.TxtPrice.text = payConfig.Amount + else + -- 货币图标与价格刷新 + local disCountValue = XDataCenter.PurchaseManager.GetLBDiscountValue(purchaseData) + if purchaseData.ConsumeCount == 0 then + -- 免费购买 + self.RImPrice.gameObject:SetActiveEx(false) + self.TxtPrice.text = CS.XTextManager.GetText("SignGiftPackFree") + self.PanelSale.gameObject:SetActiveEx(false) + elseif + XPurchaseConfigs.GetTagType(purchaseData.Tag) == XPurchaseConfigs.PurchaseTagType.Discount and disCountValue < 1 then + -- 打折 + self.RImPrice.gameObject:SetActiveEx(true) + local icon = XDataCenter.ItemManager.GetItemIcon(purchaseData.ConsumeId) + if icon then + self.RImPrice:SetRawImage(icon) + end + + self.PanelSale.gameObject:SetActiveEx(true) + self.TxtSale.text = purchaseData.ConsumeCount + self.TxtPrice.text = math.modf(purchaseData.ConsumeCount * disCountValue) + else + -- 正常显示价格 + self.RImPrice.gameObject:SetActiveEx(true) + local path = XDataCenter.ItemManager.GetItemIcon(purchaseData.ConsumeId) + if path then + self.RImPrice:SetRawImage(path) + end + self.TxtPrice.text = purchaseData.ConsumeCount or "" + self.PanelSale.gameObject:SetActiveEx(false) + end + end + + -- 根据购买限制次数设置购买按钮的状态 + if (purchaseData.BuyLimitTimes > 0 and purchaseData.BuyTimes == purchaseData.BuyLimitTimes) + or (purchaseData.TimeToShelve > 0 and purchaseData.TimeToShelve <= nowTime) + or (purchaseData.TimeToUnShelve > 0 and purchaseData.TimeToUnShelve <= nowTime) then + self.BtnPurchase:SetButtonState(XUiButtonState.Disable) + else + self.BtnPurchase:SetButtonState(XUiButtonState.Normal) + end + + -- 刷新倒计时 + self.TimerId = purchaseData.Id + round + if purchaseData.TimeToInvalid and purchaseData.TimeToInvalid > 0 then + -- 失效时间 + self.RemainTime = purchaseData.TimeToInvalid - nowTime + self.UpdateTimerType = UpdateTimerTypeEnum.SettOff + + if self.RemainTime > 0 then + self.TxShelf.gameObject:SetActiveEx(true) + + self.Parent:RegisterTimerFun(self.TimerId, function() + self:UpdateTimer() + end) + self.TxShelf.text = CS.XTextManager.GetText("PurchaseSetOffTime",XUiHelper.GetTime(self.RemainTime)) + else + self.TxShelf.gameObject:SetActiveEx(false) + self.Parent:RemoveTimerFun(self.TimerId) + end + else + if (purchaseData.TimeToShelve == nil or purchaseData.TimeToShelve == 0) and (purchaseData.TimeToUnShelve == nil or purchaseData.TimeToUnShelve == 0) then + self.TxShelf.gameObject:SetActiveEx(false) + else + self.TxShelf.gameObject:SetActiveEx(true) + if purchaseData.TimeToUnShelve > 0 then + -- 下架时间 + self.RemainTime = purchaseData.TimeToUnShelve - nowTime + self.UpdateTimerType = UpdateTimerTypeEnum.SettOff + self.TxShelf.text = CS.XTextManager.GetText("PurchaseSetOffTime",XUiHelper.GetTime(self.RemainTime)) + else + -- 上架时间 + self.RemainTime = purchaseData.TimeToShelve-nowTime + self.UpdateTimerType = UpdateTimerTypeEnum.SettOn + self.TxShelf.text = CS.XTextManager.GetText("PurchaseSetOnTime",XUiHelper.GetTime(self.RemainTime)) + end + + if self.RemainTime > 0 then + self.Parent:RegisterTimerFun(self.TimerId, function() + self:UpdateTimer() + end) + else + self.Parent:RemoveTimerFun(self.TimerId) + end + end + end + + self:InitTabGroup() + self:SetRewardInfos(self.Round) +end + +function XUiPurchaseSignTipRound:SetBuyDes() + local clientResetInfo = self.PurchaseData.ClientResetInfo or {} + if next(clientResetInfo) == nil then + self.PanelPurchaseLimit.gameObject:SetActiveEx(false) + self.TxtPurchaseLimit.text = "" + return + end + + local textKey = nil + if clientResetInfo.ResetType == XPurchaseConfigs.RestTypeConfig.Interval then + self.PanelPurchaseLimit.gameObject:SetActiveEx(true) + self.TxtPurchaseLimit.text = CS.XTextManager.GetText("PurchaseRestTypeInterval", clientResetInfo.DayCount, self.PurchaseData.BuyTimes, self.PurchaseData.BuyLimitTimes) + return + elseif clientResetInfo.ResetType == XPurchaseConfigs.RestTypeConfig.Day then + textKey = "PurchaseRestTypeDay" + elseif clientResetInfo.ResetType == XPurchaseConfigs.RestTypeConfig.Week then + textKey = "PurchaseRestTypeWeek" + elseif clientResetInfo.ResetType == XPurchaseConfigs.RestTypeConfig.Month then + textKey = "PurchaseRestTypeMonth" + end + + if not textKey then + self.TxtLimitBuy.text = "" + self.PanelPurchaseLimit.gameObject:SetActiveEx(false) + return + end + self.PanelPurchaseLimit.gameObject:SetActiveEx(true) + self.TxtPurchaseLimit.text = CS.XTextManager.GetText(textKey, self.PurchaseData.BuyTimes, self.PurchaseData.BuyLimitTimes) +end + +--- +--- 更新倒计时 +function XUiPurchaseSignTipRound:UpdateTimer() + self.RemainTime = self.RemainTime - 1 + + if self.RemainTime <= 0 then + self.Parent:RemoveTimerFun(self.TimerId) + if self.UpdateTimerType == UpdateTimerTypeEnum.SettOff then + self.TxShelf.text = CS.XTextManager.GetText("PurchaseLBSettOff") + return + end + self.TxShelf.text = "" + return + end + + if self.UpdateTimerType == UpdateTimerTypeEnum.SettOff then + self.TxShelf.text = CS.XTextManager.GetText("PurchaseSetOffTime",XUiHelper.GetTime(self.RemainTime)) + return + end + self.TxShelf.text = CS.XTextManager.GetText("PurchaseSetOnTime",XUiHelper.GetTime(self.RemainTime)) +end + +--- +--- 初始化轮次标签按钮组 +function XUiPurchaseSignTipRound:InitTabGroup() + for _, v in ipairs(self.BtnList) do + v.gameObject:SetActiveEx(false) + end + if #self.SignInInfos <= 1 then + return + end + + local btnGroupList = {} + for i = 1, #self.SignInInfos do + local grid = self.BtnList[i] + if not grid then + grid = CS.UnityEngine.Object.Instantiate(self.BtnTab.gameObject) + grid.transform:SetParent(self.PanelTabContent.gameObject.transform, false) + table.insert(self.BtnList, grid) + end + local xBtn = grid.transform:GetComponent("XUiButton") + local rowImg = XUiHelper.TryGetComponent(grid.transform, "RImgIcon", "RawImage") + + table.insert(btnGroupList, xBtn) + xBtn:SetName(self.SignInInfos[i].RoundName) + rowImg:SetRawImage(self.SignInInfos[i].Icon) + xBtn.gameObject:SetActiveEx(true) + end + + self.PanelTabContent:Init(btnGroupList, function(index) + self:SelectPanelRound(index) + end) + self.PanelTabContent:SelectIndex(self.Round, false) +end + +--- +--- 轮次标签按钮组响应函数 +function XUiPurchaseSignTipRound:SelectPanelRound(index) + self.Parent:RefreshPanel(index) +end + +--- +--- 设置奖励信息 +function XUiPurchaseSignTipRound:SetRewardInfos(index) + local signInInfo = self.SignInInfos[index] + local rewardConfigs = XSignInConfigs.GetSignInRewardConfigs(self.PurchaseData.SignInId, signInInfo.Round, false) + + for _, v in ipairs(self.DaySmallGrids) do + v.GameObject:SetActiveEx(false) + end + + for _, v in ipairs(self.DayBigGrids) do + v.GameObject:SetActiveEx(false) + end + + local smallIndex = 1 + local bigIndex = 1 + + for _, config in ipairs(rewardConfigs) do + if config.IsGrandPrix then -- 设置大奖励 + local dayGrid = self.DayBigGrids[bigIndex] + if not dayGrid then + local grid = CS.UnityEngine.GameObject.Instantiate(self.GridDayBig) + grid.transform:SetParent(self.PanelDayContent, false) + dayGrid = XUiPurchaseSignTipGridDay.New(grid, self.RootUi) + table.insert(self.DayBigGrids, dayGrid) + end + + dayGrid:Refresh(config) + dayGrid.Transform:SetAsLastSibling() + bigIndex = bigIndex + 1 + else -- 设置小奖励 + local dayGrid = self.DaySmallGrids[smallIndex] + if not dayGrid then + local grid = CS.UnityEngine.GameObject.Instantiate(self.GridDaySmall) + grid.transform:SetParent(self.PanelDayContent, false) + dayGrid = XUiPurchaseSignTipGridDay.New(grid, self.RootUi) + table.insert(self.DaySmallGrids, dayGrid) + end + + dayGrid:Refresh(config) + dayGrid.Transform:SetAsLastSibling() + smallIndex = smallIndex + 1 + end + end +end + +--- +--- 控制当前轮次面板的显示与隐藏 +--- 父UI调用,其他同级的轮次脚本切换轮次时,就调用此函数显示对应轮次的面板 +function XUiPurchaseSignTipRound:SetSignActive(active, round) + if active and self.GameObject.activeSelf then + return + end + + if not active and not self.GameObject.activeSelf then + return + end + + if #self.SignInInfos > 1 then + self.PanelTabContent:SelectIndex(round, false) + end + + self.GameObject:SetActiveEx(active) +end + +function XUiPurchaseSignTipRound:OnBtnHelpClick() + XUiManager.UiFubenDialogTip("Event Info", self.SignInInfos[1].Description or "") +end + +function XUiPurchaseSignTipRound:OnClose() + if self.UpdateTimerType then + self.Parent:RemoveTimerFun(self.TimerId) + end +end + +return XUiPurchaseSignTipRound \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPurchase/XUiPurchaseYK.lua b/Resources/Scripts/XUi/XUiPurchase/XUiPurchaseYK.lua new file mode 100644 index 00000000..26b21b92 --- /dev/null +++ b/Resources/Scripts/XUi/XUiPurchase/XUiPurchaseYK.lua @@ -0,0 +1,218 @@ +local XUiPurchaseYK = XClass(nil, "XUiPurchaseYK") +local TextManager = CS.XTextManager +local PurchaseManager +local Next = _G.next +local XUiPurchaseYKListItem = require("XUi/XUiPurchase/XUiPurchaseYKListItem") +local XUiPurchaseLBTips = require("XUi/XUiPurchase/XUiPurchaseLBTips") +local XUiGridPurchaseYK = require("XUi/XUiPurchase/XUiGridPurchaseYK") +local BuyState = { + CanBuy = 1, + NotCanBuy = 2 +} + +local UiType = +{ + BgMonth = 2, + BgWeek = 13, + BgDay = 14, +} + +local Application = CS.UnityEngine.Application +local Platform = Application.platform +local RuntimePlatform = CS.UnityEngine.RuntimePlatform + +local TotalCountLimit +local CountLimit + +local CurrentSchedule = nil + +function XUiPurchaseYK:Ctor(ui, uiroot) + PurchaseManager = XDataCenter.PurchaseManager + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiroot + self.TimeFuns = {} + self.TimeSaveFuns = {} + XTool.InitUiObject(self) + self:Init() + self:InitDynamic() + --self.NeedUpdateId = {} -- 海外修改(表改为字段) +end + +function XUiPurchaseYK:Init() + self.BtnHelp.CallBack = function() self:OnBtnHelp() end + self.BuyUITips = XUiPurchaseLBTips.New(self.PanelBuyTips,self.UiRoot, self) + self.BuyCb = function() return self:BuyReq() end + self.UpdateCb = function() self:OnUpdate() end +end + +function XUiPurchaseYK:InitDynamic() + self.DynamicTable = XDynamicTableNormal.New(self.PanelYkExInfo) + self.DynamicTable:SetProxy(XUiGridPurchaseYK) + self.DynamicTable:SetDelegate(self) +end + +--显示面板 +function XUiPurchaseYK:ShowPanel() + XEventManager.AddEventListener(XEventId.EVENT_PURCAHSE_BUYUSERIYUAN, self.OnUpdate, self) + self.GameObject:SetActive(true) +end + +--隐藏面板 +function XUiPurchaseYK:HidePanel() + self.CurState = false + XEventManager.RemoveEventListener(XEventId.EVENT_PURCAHSE_BUYUSERIYUAN, self.OnUpdate, self) + self.GameObject:SetActive(false) +end + +--购买完成回调 +function XUiPurchaseYK:OnUpdate() + if self.CurUitype then + self:OnRefresh(self.CurUitype) + end +end + +-- 更新数据 +function XUiPurchaseYK:OnRefresh(uiType) + local data = PurchaseManager.GetDatasByUiType(uiType) + if not data or not data[1] then + return + end + if uiType == XPurchaseConfigs.PurChaseCardUiType then + XDataCenter.PurchaseManager.SetYKContinueBuy() + end + self.CurUitype = uiType + self.Datas = data + + self.TxtBtnInfo.text = XPurchaseConfigs.GetPurchaseNameByUiType(self.CurUitype) + + self.DynamicTable:SetDataSource(self.Datas) + self.DynamicTable:ReloadDataASync(1) + self:StartLBTimer() +end + +--动态列表事件 +function XUiPurchaseYK:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:SetBuyClickCallBack(self.UiRoot, function(data) + self:OnYKBuyClick(data) + end) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.Datas[index] + grid:Refresh(data, self.NeedUpdateId) + self.NeedUpdateId = nil + end +end + +--帮助按钮点击 +function XUiPurchaseYK:OnBtnHelp() + if self.CurUitype == UiType.BgMonth then + XUiManager.UiFubenDialogTip("", TextManager.GetText("PurchaseYKDes") or "") + elseif self.CurUitype == UiType.BgWeek then + XUiManager.UiFubenDialogTip("", TextManager.GetText("PurchaseYKDes13") or "") + elseif self.CurUitype == UiType.BgDay then + XUiManager.UiFubenDialogTip("", TextManager.GetText("PurchaseYKDes14") or "") + end +end + +--月卡子项点击购买回调 +function XUiPurchaseYK:OnYKBuyClick(data) + self.CurData = data + self.BuyUITips:OnRefresh(data, self.BuyCb) +end + +--确认购买按钮回调 +function XUiPurchaseYK:BuyReq() + if not XDataCenter.PayManager.CheckCanBuy(self.CurData.Id) then + return false + end + if self.CurData.BuyLimitTimes > 0 and self.CurData.BuyTimes == self.CurData.BuyLimitTimes then --卖完了,不管。 + XUiManager.TipText("PurchaseLiSellOut") + return false + end + + if self.CurData.TimeToShelve > 0 and self.CurData.TimeToShelve > XTime.GetServerNowTimestamp() then --没有上架 + XUiManager.TipText("PurchaseBuyNotSet") + return false + end + + if self.CurData.TimeToUnShelve > 0 and self.CurData.TimeToUnShelve < XTime.GetServerNowTimestamp() then --下架了 + XUiManager.TipText("PurchaseSettOff") + return false + end + self.NeedUpdateId = nil + if self.CurData.PayKeySuffix then + local key + if Platform == RuntimePlatform.Android then + key = string.format("%s%s", XPayConfigs.GetPlatformConfig(1), self.CurData.PayKeySuffix) + else + key = string.format("%s%s", XPayConfigs.GetPlatformConfig(2), self.CurData.PayKeySuffix) + end + self.BuyUITips:CloseTips() + if self.CurData.BuyLimitTimes == 1 and self.CurData.UiType == UiType.BgDay then + self.NeedUpdateId = self.CurData.Id + end + XDataCenter.PayManager.Pay(key, 1, { self.CurData.Id }, self.CurData.Id) + else + if self.CurData and self.CurData.Id then + self.BuyUITips:CloseTips() + XAppEventManager.HKPurchasePayAppLogEvent(self.CurData.Id) -- 月卡购买埋点 + PurchaseManager.PurchaseRequest(self.CurData.Id,self.UpdateCb) + end + end + return true +end + +function XUiPurchaseYK:StartLBTimer() + if self.IsStart then + return + end + + self.IsStart = true + CurrentSchedule = CS.XScheduleManager.Schedule(function() self:UpdateLBTimer() end, 1000, 0) +end + +function XUiPurchaseYK:UpdateLBTimer() + if Next(self.TimeFuns) then + for _, timerfun in pairs(self.TimeFuns) do + if timerfun then + timerfun() + end + end + return + end + self:DestoryTimer() +end + +function XUiPurchaseYK:DestoryTimer() + if CurrentSchedule then + self.IsStart = false + CS.XScheduleManager.UnSchedule(CurrentSchedule) + CurrentSchedule = nil + end +end + +function XUiPurchaseYK:RemoveTimerFun(id) + self.TimeFuns[id] = nil +end + +function XUiPurchaseYK:RecoverTimerFun(id) + self.TimeFuns[id] = self.TimeSaveFuns[id] + if self.TimeFuns[id] then + self.TimeFuns[id](true) + end + self.TimeSaveFuns[id] = nil +end + +function XUiPurchaseYK:RegisterTimerFun(id, fun, isSave) + if not isSave then + self.TimeFuns[id] = fun + return + end + + self.TimeSaveFuns[id] = self.TimeFuns[id] + self.TimeFuns[id] = fun + +end + +return XUiPurchaseYK \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiPurchase/XUiPurchaseYKListItem.lua b/Resources/Scripts/XUi/XUiPurchase/XUiPurchaseYKListItem.lua new file mode 100644 index 00000000..fbd3eedb --- /dev/null +++ b/Resources/Scripts/XUi/XUiPurchase/XUiPurchaseYKListItem.lua @@ -0,0 +1,23 @@ +local XUiPurchaseYKListItem = XClass(nil, "XUiPurchaseYKListItem") + +function XUiPurchaseYKListItem:Ctor(ui,uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + XTool.InitUiObject(self) +end + +-- 更新数据 +function XUiPurchaseYKListItem:OnRefresh(itemData) + if not itemData then + return + end + self.ItemData = itemData +end + +function XUiPurchaseYKListItem:Init(uiRoot,parent) + self.UiRoot = uiRoot + self.Parent = parent +end + +return XUiPurchaseYKListItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRedEnvelope/XUiGridRedEnvelopeInfo.lua b/Resources/Scripts/XUi/XUiRedEnvelope/XUiGridRedEnvelopeInfo.lua new file mode 100644 index 00000000..f6d9b1ed --- /dev/null +++ b/Resources/Scripts/XUi/XUiRedEnvelope/XUiGridRedEnvelopeInfo.lua @@ -0,0 +1,40 @@ +local XUiGridRedEnvelopeInfo = XClass(nil, "XUiGridRedEnvelopeInfo") + +function XUiGridRedEnvelopeInfo:Ctor(ui, parent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:InitParent(parent) +end + +function XUiGridRedEnvelopeInfo:InitParent(parent) + self.Parent = parent +end + +function XUiGridRedEnvelopeInfo:Refresh(info) + local id = info.Id + local count = info.ItemCount + local itemId = info.ItemId + local isLuckyBoy = info.IsLuckyBoy + + local headIcon, headEffect, name = "", "" + if id == self.Parent.LeaderTemplateId then + name = XPlayer.Name + if self.Head then + XUiPLayerHead.InitPortrait(XPlayer.CurrHeadPortraitId, XPlayer.CurrHeadFrameId, self.Head) + end + else + local config = XRedEnvelopeConfigs.GetNpcConfig(id) + name = config.NpcName + if self.RImgHead then + self.RImgHead:SetRawImage(config.NpcHead) + end + end + + self.TxtName.text = name + self.TxtNum.text = count + self.PanelLucky.gameObject:SetActiveEx(isLuckyBoy) + self.RImgIcon:SetRawImage(XDataCenter.ItemManager.GetItemIcon(itemId)) +end + +return XUiGridRedEnvelopeInfo \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRedEnvelope/XUiRedEnvelope.lua b/Resources/Scripts/XUi/XUiRedEnvelope/XUiRedEnvelope.lua new file mode 100644 index 00000000..541fd79f --- /dev/null +++ b/Resources/Scripts/XUi/XUiRedEnvelope/XUiRedEnvelope.lua @@ -0,0 +1,79 @@ +local tableInsert = table.insert + +local XUiGridRedEnvelopeInfo = require("XUi/XUiRedEnvelope/XUiGridRedEnvelopeInfo") + +local XUiRedEnvelope = XLuaUiManager.Register(XLuaUi, "UiRedEnvelope") + +XUiRedEnvelope.LeaderTemplateId = 0 --指挥官templateId + +function XUiRedEnvelope:OnStart(itemId, rewardGoodsList) + self.ItemId = itemId + self.RewardGoodsList = rewardGoodsList + + self:InitView() + self:UpdateView() +end + +function XUiRedEnvelope:InitView() + self.BtnTanchuangClose.CallBack = function() self:Close() end + + local itemId = self.ItemId + self.TxtTitle.text = XDataCenter.ItemManager.GetItemName(itemId) + + self.DynamicTable = XDynamicTableNormal.New(self.PanelDynamicList) + self.DynamicTable:SetProxy(XUiGridRedEnvelopeInfo) + self.DynamicTable:SetDelegate(self) +end + +function XUiRedEnvelope:UpdateView() + self.MemberInfos = {} + local leaderInfo = { + Id = self.LeaderTemplateId, + ItemCount = 0, + IsLuckyBoy = false, + } + + local maxCount = 0 + for _, v in pairs(self.RewardGoodsList) do + if v.ItemCount > maxCount then + maxCount = v.ItemCount + end + end + + for _, v in pairs(self.RewardGoodsList) do + local count = v.ItemCount + if v.NpcId == leaderInfo.Id then + leaderInfo.ItemCount = v.ItemCount + leaderInfo.ItemId = v.ItemId + if maxCount and count == maxCount then + leaderInfo.IsLuckyBoy = true + maxCount = nil + end + else + local memberInfo = {} + memberInfo.Id = v.NpcId + memberInfo.ItemCount = v.ItemCount + memberInfo.ItemId = v.ItemId + if maxCount and count == maxCount then + memberInfo.IsLuckyBoy = true + maxCount = nil + end + tableInsert(self.MemberInfos, memberInfo) + end + end + + self.LeaderGrid = self.LeaderGrid or XUiGridRedEnvelopeInfo.New(self.GridLeader, self) + self.LeaderGrid:Refresh(leaderInfo) + + self.DynamicTable:SetDataSource(self.MemberInfos) + self.DynamicTable:ReloadDataASync() +end + +function XUiRedEnvelope:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:InitParent(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local memberInfo = self.MemberInfos[index] + grid:Refresh(memberInfo) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiReform/XUiReform.lua b/Resources/Scripts/XUi/XUiReform/XUiReform.lua new file mode 100644 index 00000000..c6189c7c --- /dev/null +++ b/Resources/Scripts/XUi/XUiReform/XUiReform.lua @@ -0,0 +1,502 @@ +local CsXTextManager = CS.XTextManager + +--######################## XUiReformTaskGrid ######################## +local XUiReformTaskGrid = XClass(nil, "XUiReformTaskGrid") + +function XUiReformTaskGrid:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.Data = nil + self.UiGridCommon = XUiGridCommon.New(rootUi, self.GridCommon) + self.BtnClick.CallBack = function() self:OnBtnClicked() end +end + +-- data : TaskData +function XUiReformTaskGrid:SetData(data, nextData, maxScore) + self.Data = data + -- 分数 + local score = XDataCenter.ReformActivityManager.GetTaskFinishScore(data.Id) + self.TxtScore.text = score + -- 完成状态 + self.PanelFinish.gameObject:SetActiveEx(data.State == XDataCenter.TaskManager.TaskState.Finish) + -- 物品信息 + local rewardId = XTaskConfig.GetTaskRewardId(data.Id) + local rewardList = XRewardManager.GetRewardList(rewardId) + self.UiGridCommon:Refresh(rewardList[1]) + -- 红点 + self.Red.gameObject:SetActiveEx(data.State == XDataCenter.TaskManager.TaskState.Achieved) + -- self.ImgEffect.gameObject:SetActiveEx(data.State == XDataCenter.TaskManager.TaskState.Achieved) + -- 任务进度 + local nextScore = XDataCenter.ReformActivityManager.GetTaskFinishScore(nextData.Id) + local progress = (maxScore - score) / (nextScore - score) + self.PanelPassedLine.fillAmount = progress +end + +function XUiReformTaskGrid:OnBtnClicked() + if not XDataCenter.ReformActivityManager.GetIsOpen() then + XLuaUiManager.RunMain() + XUiManager.TipError(CsXTextManager.GetText("ReformAtivityTimeEnd")) + return + end + if self.Data.State == XDataCenter.TaskManager.TaskState.Achieved then + XDataCenter.TaskManager.FinishTask(self.Data.Id, function(rewardGoodsList) + XUiManager.OpenUiObtain(rewardGoodsList) + end) + return + end + XUiManager.OpenUiTipRewardByRewardId(XTaskConfig.GetTaskRewardId(self.Data.Id)) +end + +--######################## XUiReformStageGrid ######################## +local XUiReformStageGrid = XClass(nil, "XUiReformStageGrid") + +function XUiReformStageGrid:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.BaseStage = nil + self.ClickProxy = nil + self.ClickCallback = nil + self.Index = nil + self.Score = nil + self.BtnSelf.CallBack = function() self:OnBtnSelfClicked() end +end + +function XUiReformStageGrid:SetData(baseStage, index) + self.BaseStage = baseStage + self.Index = index + -- 名字 + self.BtnSelf:SetNameByGroup(0, baseStage:GetName()) + self:RefreshStatus() + -- 是否选中 + local isSelected = baseStage:GetId() == XDataCenter.ReformActivityManager.GetCurrentBaseStageId() + self:SetSelectStatus(isSelected) + self.Red.gameObject:SetActiveEx(XDataCenter.ReformActivityManager.CheckBaseStageIsShowRedDot(baseStage:GetId())) +end + +function XUiReformStageGrid:RefreshStatus() + local isUnlock = self.BaseStage:GetIsUnlock() + local score = self.BaseStage:GetAccumulativeScore() + local isSelected = self.BaseStage:GetId() == XDataCenter.ReformActivityManager.GetCurrentBaseStageId() + self.Score = score + self.Currency.gameObject:SetActiveEx(isUnlock and score > 0 and not isSelected) + self.Currency2.gameObject:SetActiveEx(isUnlock and score > 0 and isSelected) + self.Lock.gameObject:SetActiveEx(not isUnlock) + if isUnlock then + -- 分数 + self.TxtScore.text = score + self.TxtScore2.text = score + else + -- 解锁时间 + self.TxtUnlockTime.text = CsXTextManager.GetText("ReformBaseStageUnlockText", self.BaseStage:GetUnlockTimeStr()) + end +end + +function XUiReformStageGrid:SetClickCallBack(clickProxy, clickCallback) + self.ClickProxy = clickProxy + self.ClickCallback = clickCallback +end + +function XUiReformStageGrid:SetSelectStatus(value) + self.Select.gameObject:SetActiveEx(value) + local isUnlock = self.BaseStage:GetIsUnlock() + if isUnlock and self.Score > 0 then + self.Currency.gameObject:SetActiveEx(not value) + self.Currency2.gameObject:SetActiveEx(value) + end +end + +function XUiReformStageGrid:OnBtnSelfClicked() + if self.ClickCallback then + self.ClickCallback(self.ClickProxy, self.Index) + end + if self.BaseStage:GetIsUnlock() then + XDataCenter.ReformActivityManager.SetBaseStageRedDotHistory(self.BaseStage:GetId()) + self.Red.gameObject:SetActiveEx(XDataCenter.ReformActivityManager.CheckBaseStageIsShowRedDot(self.BaseStage:GetId())) + end +end + +--######################## XUiReformReadyPanel ######################## +local XUiReformReadyPanel = XClass(nil, "XUiReformReadyPanel") + +function XUiReformReadyPanel:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + self.BaseStage = nil + self.GridBuff.gameObject:SetActiveEx(false) + self.GridCommon.gameObject:SetActiveEx(false) + self:RegisterUiEvents() + -- 资源 + XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem + , XDataCenter.ItemManager.ItemId.ActionPoint) +end + +function XUiReformReadyPanel:SetData(baseStage) + self.BaseStage = baseStage + -- 关卡名称 + self.TxtTitle.text = CsXTextManager.GetText("ReformReadyTitleText", baseStage:GetName() + , baseStage:GetCurrentEvolvableStage():GetName()) + -- 词缀 + local fightEvents = baseStage:GetShowFightEvents() + self.PanelBuffContent.gameObject:SetActiveEx(#fightEvents > 0) + self.PanelBuffNone.gameObject:SetActiveEx(#fightEvents <= 0) + if #fightEvents > 0 then + for i = 2, self.PanelBuffContent.childCount do + CS.UnityEngine.Object.Destroy(self.PanelBuffContent:GetChild(i - 1).gameObject) + end + local go + for i, v in ipairs(fightEvents) do + go = CS.UnityEngine.Object.Instantiate(self.GridBuff, self.PanelBuffContent) + go.gameObject:SetActiveEx(true) + go.transform:Find("Buff"):GetComponent("RawImage"):SetRawImage(v.Icon) + end + end + -- 提示 + local tips = baseStage:GetShowTips() + for i = 1, self.PanelTips.childCount do + if tips[i] then + self["TxtTip" .. i].gameObject:SetActiveEx(true) + self["TxtTip" .. i].text = tips[i] + else + self["TxtTip" .. i].gameObject:SetActiveEx(false) + end + end + -- 首通奖励 PanelDropContent + local isPassed = baseStage:GetIsPassed() + self.PanelIntegral.gameObject:SetActiveEx(isPassed) + self.UireformIcon.gameObject:SetActiveEx(isPassed) + self.PanelAwardList.gameObject:SetActiveEx(not isPassed) + if isPassed then + self.TxtScore.text = baseStage:GetCurrentEvolvableStage():GetChallengeScore() + self.TxtFirstDrop.text = CsXTextManager.GetText("ReformReadyScoreDropText") + else + self.TxtFirstDrop.text = CsXTextManager.GetText("ReformReadyFirstDropText") + for i = 2, self.PanelDropContent.childCount do + CS.UnityEngine.Object.Destroy(self.PanelDropContent:GetChild(i - 1).gameObject) + end + local rewardList = baseStage:GetFirstRewards() + local gridCommont = nil + local go = nil + for _, reward in ipairs(rewardList) do + go = CS.UnityEngine.Object.Instantiate(self.GridCommon, self.PanelDropContent) + go.gameObject:SetActiveEx(false) + gridCommont = XUiGridCommon.New(self.RootUi, go) + gridCommont:Refresh(reward) + end + end +end + +function XUiReformReadyPanel:Open(baseStage) + local showTip, evolvableStage = baseStage:GetIsShowEvolvableDiffTip() + if showTip then + XUiManager.TipError(CsXTextManager.GetText("ReformEvolvableDiffOpenTip", baseStage:GetName() + , evolvableStage:GetName())) + end + self.EnterAnim:Play() + self.GameObject:SetActiveEx(true) +end + +function XUiReformReadyPanel:Close() + self.EnterAnim:Stop() + self.GameObject:SetActiveEx(false) + -- self.RootUi.UiPanelAsset.GameObject:SetActiveEx(true) +end + +--######################## 私有方法 ######################## + +function XUiReformReadyPanel:RegisterUiEvents() + self.BtnClose.CallBack = function() self:Close() end + self.BtnEnter.CallBack = function() self:OnBtnEnterClicked() end + self.BtnBuffTip.CallBack = function() self:OnBtnBuffTipClicked() end +end + +function XUiReformReadyPanel:OnBtnEnterClicked() + self:Close() + XLuaUiManager.Open("UiNewRoomSingle", self.BaseStage:GetId()) +end + +function XUiReformReadyPanel:OnBtnBuffTipClicked() + local showFightEvents = self.BaseStage:GetShowFightEvents() + if #showFightEvents > 0 then + XLuaUiManager.Open("UiReformBuffTips", showFightEvents, CsXTextManager.GetText("ReformMainBuffTipsTitle")) + end +end + +--######################## XUiReform ######################## +local XUiReform = XLuaUiManager.Register(XLuaUi, "UiReform") + +function XUiReform:OnAwake() + self.CurrentBaseStage = nil + self.CurrentEvolvableBaseStage = nil + self.ActivityTimer = nil + self:RegisterUiEvents() + self.UiReformReadyPanel = XUiReformReadyPanel.New(self.PanelStageDetail, self) + self.MosterHideParts = {} + self.MosterEffects = {} + XUiNewRoomSingleProxy.RegisterProxy(XDataCenter.FubenManager.StageType.Reform, + require("XUi/XUiReform/XUiReformNewRoomSingle")) + -- 关卡列表 + self.UiReformStageGridDic = {} + self.GridStage.gameObject:SetActiveEx(false) + self.DynamicTable = XDynamicTableNormal.New(self.PanelStageList) + self.DynamicTable:SetProxy(XUiReformStageGrid) + self.DynamicTable:SetDelegate(self) + -- 初始化任务 + self.UiReformTaskGrids = {} + self:InitTaskDataGrid() + -- 模型初始化 + local panelRoleModel = self.UiModelGo.transform:FindTransform("PanelRoleModel") + self.UiPanelRoleModel = XUiPanelRoleModel.New(panelRoleModel, self.Name, nil, true) + -- 资源 + self.UiPanelAsset = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem + , XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self.EffectReformUnlock.gameObject:SetActiveEx(false) + self.ImgEffectHuanren = self.UiModelGo.transform:FindTransform("ImgEffectHuanren") + -- 自动关闭 + local endTime = XDataCenter.ReformActivityManager.GetActivityEndTime() + self:SetAutoCloseInfo(endTime, function(isClose) + if isClose then + XDataCenter.ReformActivityManager.HandleActivityEndTime() + else + self.TxtRemainTime.text = XDataCenter.ReformActivityManager.GetLeaveTimeStr() + for _, grid in pairs(self.UiReformStageGridDic) do + grid:RefreshStatus() + end + end + end) +end + +function XUiReform:OnStart() + local reformActivityManager = XDataCenter.ReformActivityManager + self.CurrentBaseStage = reformActivityManager.GetCurrentBaseStage() + self.CurrentEvolvableBaseStage = self.CurrentBaseStage:GetCurrentEvolvableStage() + -- 名字 + self.TxtTitle.text = reformActivityManager.GetActivityName() + self.TxtMaxScoreTitle.text = CsXTextManager.GetText("ReformMaxScoreTitle") +end + +function XUiReform:OnEnable() + XUiReform.Super.OnEnable(self) + self.TxtRemainTime.text = XDataCenter.ReformActivityManager.GetLeaveTimeStr() + -- 基础关卡列表 + self:RefreshDynamicTable() + self:RefreshBaseStageInfo(self.CurrentBaseStage) + self:RefreshTaskDataGrid() + XEventManager.AddEventListener(XEventId.EVENT_FINISH_TASK, self.RefreshTaskDataGrid, self) +end + +function XUiReform:OnDisable() + XUiReform.Super.OnDisable(self) + XEventManager.RemoveEventListener(XEventId.EVENT_FINISH_TASK, self.RefreshTaskDataGrid, self) +end + +--######################## 私有方法 ######################## + +function XUiReform:OnCheckBtnReformRedPoint(count) + self.BtnReform:ShowReddot(count >= 0) +end + +function XUiReform:InitTaskDataGrid() + self.GridCourse.gameObject:SetActiveEx(false) + local taskDatas = XDataCenter.ReformActivityManager.GetTaskDatas() + local go = nil + local grid = nil + for index, taskData in ipairs(taskDatas) do + go = CS.UnityEngine.Object.Instantiate(self.GridCourse, self.PanelCourseContainer) + go.gameObject:SetActiveEx(true) + grid = XUiReformTaskGrid.New(go, self) + self.UiReformTaskGrids[index] = grid + end +end + +function XUiReform:RefreshTaskDataGrid() + local taskDatas = XDataCenter.ReformActivityManager.GetTaskDatas() + local maxScore = XDataCenter.ReformActivityManager.GetTaskMaxScore() + local scrollIndex = nil + local tmpTaskData = nil + local lastFinishIndex = 0 + for index, grid in ipairs(self.UiReformTaskGrids) do + tmpTaskData = taskDatas[index] + -- 一进来去到开始能完成的任务 + if tmpTaskData.State == XDataCenter.TaskManager.TaskState.Achieved and scrollIndex == nil then + scrollIndex = index + elseif tmpTaskData.State == XDataCenter.TaskManager.TaskState.Finish then + lastFinishIndex = index + end + grid:SetData(tmpTaskData, taskDatas[math.min(index + 1, #taskDatas)], maxScore) + end + if scrollIndex == nil then + scrollIndex = math.min(lastFinishIndex + 1, #taskDatas) + end + local firstTaskData = taskDatas[1] + self.TxtTaskScore.text = maxScore + local nextScore = XDataCenter.ReformActivityManager.GetTaskFinishScore(firstTaskData.Id) + local progress = maxScore / nextScore + self.ImgFirstPassedLine.fillAmount = progress + XScheduleManager.ScheduleOnce(function() + self:ScrollTaskGrid(scrollIndex) + end, 0.01) +end + +function XUiReform:RegisterUiEvents() + self.BtnBack.CallBack = function() self:Close() end + self.BtnMainUi.CallBack = function() XLuaUiManager.RunMain() end + self.BtnReform.CallBack = function() self:OnBtnReformClicked() end + self.BtnEnterStage.CallBack = function() self:OnBtnEnterStageClicked() end + self.BtnPreview.CallBack = function() self:OnBtnPreviewClicked() end + self:BindHelpBtn(self.BtnHelp, XDataCenter.ReformActivityManager.GetHelpName()) + self:BindHelpBtn(self.BtnScoreHelp, XDataCenter.ReformActivityManager.GetScoreHelpName()) +end + +function XUiReform:RefreshBaseStageInfo(baseStage) + self.CurrentBaseStage = baseStage + self.CurrentEvolvableBaseStage = self.CurrentBaseStage:GetCurrentEvolvableStage() + -- 累计积分 + self.TxtAccumulativeScore.text = self.CurrentBaseStage:GetAccumulativeScore() + -- 本次挑战积分 + self.TxtChallengeScore.text = self.CurrentEvolvableBaseStage:GetChallengeScore() + -- 当前改造等级名称 + self.TxtGrade.text = self.CurrentEvolvableBaseStage:GetName() + -- 刷新模型 + self:RefreshModel(baseStage:GetShowNpcId()) + self.BtnReform:SetDisable(not baseStage:GetIsPassed()) + -- 播放开锁特效 + if baseStage:GetIsPlayReformUnlockEffect() then + XScheduleManager.ScheduleOnce(function() + if self == nil then return end + if XTool.UObjIsNil(self.EffectReformUnlock) then + return + end + self.EffectReformUnlock.gameObject:SetActiveEx(false) + self.EffectReformUnlock.gameObject:SetActiveEx(true) + end, 1000) + end + -- 检查改造关卡小红点 + XRedPointManager.CheckOnce(self.OnCheckBtnReformRedPoint, self, { XRedPointConditions.Types.CONDITION_REFORM_EVOLVABLE_STAGE_UNLOCK }, { + BaseStageId = self.CurrentBaseStage:GetId(), + EvolvableDiffIndex = nil + }) +end + +function XUiReform:RefreshModel(npcId) + self.ImgEffectHuanren.gameObject:SetActiveEx(false) + self.ImgEffectHuanren.gameObject:SetActiveEx(true) + for _, prats in pairs(self.MosterHideParts) do + if not XTool.UObjIsNil(prats) then + prats.gameObject:SetActiveEx(true) + end + end + for _, effect in pairs(self.MosterEffects) do + if not XTool.UObjIsNil(effect) then + effect.gameObject:SetActiveEx(false) + end + end + self.MosterHideParts = {} + self.MosterEffects = {} + local transDatas = XArchiveConfigs.GetMonsterTransDatas(npcId, 1) + local effectDatas = XArchiveConfigs.GetMonsterEffectDatas(npcId, 1) + local modelId = XArchiveConfigs.GetMonsterModel(npcId) + self.UiPanelRoleModel:SetDefaultAnimation(transDatas and transDatas.StandAnime) + self.UiPanelRoleModel:UpdateArchiveMonsterModel(modelId, XModelManager.MODEL_UINAME.UiReform) + self.UiPanelRoleModel:ShowRoleModel() + local modelInfo = self.UiPanelRoleModel:GetModelInfoByName(modelId) + local modelGo = modelInfo.Model + if transDatas then + for _, node in pairs(transDatas.HideNodeName or {}) do + local parts = modelGo.gameObject:FindTransform(node) + if not XTool.UObjIsNil(parts) then + parts.gameObject:SetActiveEx(false) + table.insert(self.MosterHideParts, parts) + else + XLog.Error("HideNodeName Is Wrong :" .. node) + end + end + end + if effectDatas then + for node, effectPath in pairs(effectDatas) do + local parts = modelGo.gameObject:FindTransform(node) + if not XTool.UObjIsNil(parts) then + local effect = parts.gameObject:LoadPrefab(effectPath, false) + if effect then + effect.gameObject:SetActiveEx(true) + table.insert(self.MosterEffects, effect) + end + else + XLog.Error("EffectNodeName Is Wrong :"..node) + end + end + end +end + +function XUiReform:RefreshDynamicTable() + local index = 1 + local baseStages = XDataCenter.ReformActivityManager.GetBaseStages() + for i, baseStage in ipairs(baseStages) do + if baseStage:GetId() == XDataCenter.ReformActivityManager.GetCurrentBaseStageId() then + index = i + break + end + end + self.DynamicTable:SetDataSource(XDataCenter.ReformActivityManager.GetBaseStages()) + self.DynamicTable:ReloadDataSync(index) + XDataCenter.ReformActivityManager.SetBaseStageRedDotHistory(baseStages[index]:GetId()) +end + +function XUiReform:OnDynamicTableEvent(event, index, grid) + self.UiReformStageGridDic[index] = grid + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:SetData(self.DynamicTable.DataSource[index], index) + grid:SetClickCallBack(self, self.OnStageGridClicked) + end +end + +function XUiReform:OnStageGridClicked(selectedIndex) + local baseStage = self.DynamicTable.DataSource[selectedIndex] + if not baseStage:GetIsUnlock() then + XUiManager.TipError(CsXTextManager.GetText("ReformStageTimeLockTip")) + return + end + XDataCenter.ReformActivityManager.SetCurrentBaseStageId(baseStage:GetId()) + self:RefreshBaseStageInfo(self.DynamicTable.DataSource[selectedIndex]) + for i, stageGrid in pairs(self.UiReformStageGridDic) do + stageGrid:SetSelectStatus(selectedIndex == i) + end + self.UiReformStageGridDic[selectedIndex]:SetSelectStatus(true) +end + +function XUiReform:OnBtnReformClicked() + if not self.CurrentBaseStage:GetIsPassed() then + XUiManager.TipError(CsXTextManager.GetText("ReformStagePassLockTip")) + return + end + XLuaUiManager.Open("UiReformList", self.CurrentBaseStage) +end + +function XUiReform:OnBtnEnterStageClicked() + self.UiReformReadyPanel:Open(self.CurrentBaseStage) + self.UiReformReadyPanel:SetData(self.CurrentBaseStage) + -- self.UiPanelAsset.GameObject:SetActiveEx(false) +end + +function XUiReform:OnBtnPreviewClicked() + if not self.CurrentBaseStage:GetIsPassed() then + XUiManager.TipError(CsXTextManager.GetText("ReformPreviewLimitTip")) + return + end + XLuaUiManager.Open("UiReformPreview", self.CurrentEvolvableBaseStage) +end + +function XUiReform:ScrollTaskGrid(index) + local grid = self.UiReformTaskGrids[index] + if grid == nil then return end + local targetPos = self.PanelCourseContainer.localPosition + local viewPortWidthHalf = self.PanelCourseContainer.parent.rect.width / 2 + local maxValue = (self.PanelCourseContainer.rect.width - viewPortWidthHalf) * -1 + targetPos.x = math.max(maxValue, -grid.Transform.localPosition.x + grid.Transform.rect.width / 2 - viewPortWidthHalf + 50) + XUiHelper.DoMove(self.PanelCourseContainer, targetPos, 0.3, XUiHelper.EaseType.Sin) +end + +return XUiReform \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiReform/XUiReformBuffDetail.lua b/Resources/Scripts/XUi/XUiReform/XUiReformBuffDetail.lua new file mode 100644 index 00000000..7c49699f --- /dev/null +++ b/Resources/Scripts/XUi/XUiReform/XUiReformBuffDetail.lua @@ -0,0 +1,20 @@ +local XUiReformBuffDetail = XLuaUiManager.Register(XLuaUi, "UiReformBuffDetail") + +function XUiReformBuffDetail:OnAwake() + self:RegisterUiEvents() +end + +function XUiReformBuffDetail:OnStart(data) + self.TxtName.text = data.Name + self.RImgIcon:SetRawImage(data.Icon) + self.TxtStarCount.text = data.StarCount + self.TxtDescription.text = data.Description +end + +--######################## 私有方法 ######################## + +function XUiReformBuffDetail:RegisterUiEvents() + self.BtnClose.CallBack = function() self:Close() end +end + +return XUiReformBuffDetail \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiReform/XUiReformBuffPanel.lua b/Resources/Scripts/XUi/XUiReform/XUiReformBuffPanel.lua new file mode 100644 index 00000000..20a44318 --- /dev/null +++ b/Resources/Scripts/XUi/XUiReform/XUiReformBuffPanel.lua @@ -0,0 +1,125 @@ +local CsXTextManager = CS.XTextManager + +--######################## XUiReformBuffGrid ######################## +local XUiReformBuffGrid = XClass(nil, "XUiReformBuffGrid") + +function XUiReformBuffGrid:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:RegisterUiEvents() + -- XReformEvolvableStage + self.EvolvableStage = nil + self.BaseStageId = nil + -- XReformBuff + self.Data = nil +end + +function XUiReformBuffGrid:SetData(baseStageId, evolvableStage, data) + self.BaseStageId = baseStageId + self.EvolvableStage = evolvableStage + self.Data = data + self.RImgIcon:SetRawImage(data:GetIcon()) + self.TxtName.text = data:GetName() + self.TxtLevel.text = data:GetStarLevel() + self.TxtScore.text = data:GetScore() + local isActive = data:GetIsActive() + self.PanelSelect.gameObject:SetActiveEx(isActive) + self.Tab1.gameObject:SetActiveEx(false) + -- self.Tab2.gameObject:SetActiveEx(isActive) + self.Tab2.gameObject:SetActiveEx(false) +end + +-- evolvableStage : XReformEvolvableStage +function XUiReformBuffGrid:DynamicTouched() + XLuaUiManager.Open("UiReformBuffDetail", { + Name = self.Data:GetName(), + Icon = self.Data:GetIcon(), + StarCount = self.Data:GetStarLevel(), + Description = self.Data:GetDes() + }) +end + +--######################## 私有方法 ######################## + +function XUiReformBuffGrid:RegisterUiEvents() + self.BtnReform.CallBack = function() self:OnBtnReformClicked() end +end + +function XUiReformBuffGrid:OnBtnReformClicked() + -- 检查是否满足扣减分数 + if not self.Data:GetIsActive() then + if not self.EvolvableStage:CheckBuffMaxCount() then + XUiManager.TipError(CsXTextManager.GetText("ReformMaxBuffCountTip")) + return + end + if self.Data:GetScore() > self.EvolvableStage:GetChallengeScore() then + XUiManager.TipError(CsXTextManager.GetText("ReformScoreLimitTip")) + return + end + end + local buffIds = XTool.Clone(self.EvolvableStage:GetBuffIds()) + local selfBuffId = self.Data:GetId() + if self.Data:GetIsActive() then -- 取消激活 + XTool.TableRemove(buffIds, selfBuffId) + else -- 激活 + table.insert(buffIds, selfBuffId) + end + XDataCenter.ReformActivityManager.BuffUpdateRequest(self.BaseStageId, self.EvolvableStage:GetDifficulty(), buffIds, self.Data:GetId()) +end + +--######################## XUiReformBuffPanel ######################## +local XUiReformBuffPanel = XClass(nil, "XUiReformBuffPanel") + +function XUiReformBuffPanel:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + -- XReformEvolvableStage + self.EvolvableStage = nil + -- XReformBaseStage + self.BaseStage = nil + -- 初始化动态列表 + self.GirdBuff.gameObject:SetActiveEx(false) + self.DynamicTable = XDynamicTableNormal.New(self.PanelBuffList) + self.DynamicTable:SetProxy(XUiReformBuffGrid) + self.DynamicTable:SetDelegate(self) + self.GridDic = nil +end + +-- baseStage : XReformBaseStage +-- evolableStage : XReformEvolvableStage +function XUiReformBuffPanel:SetData(baseStage, evolableStage) + self.GridDic = {} + self.BaseStage = baseStage + self.EvolvableStage = evolableStage + -- 刷新动态列表 + self:RefreshDynamicTable() + self.TxtTip.text = CsXTextManager.GetText("ReformBuffPanelTopTip", evolableStage:GetMaxBuffCount()) +end + +function XUiReformBuffPanel:RefreshEvolvableData(buffId) + local buffGroup = self.EvolvableStage:GetEvolvableGroupByType(XReformConfigs.EvolvableGroupType.Buff) + self.GridDic[buffId]:SetData(self.BaseStage:GetId(), self.EvolvableStage, buffGroup:GetBuffById(buffId)) +end + +--######################## 私有方法 ######################## + +function XUiReformBuffPanel:RefreshDynamicTable() + local buffGroup = self.EvolvableStage:GetEvolvableGroupByType(XReformConfigs.EvolvableGroupType.Buff) + self.DynamicTable:SetDataSource(buffGroup:GetBuffs()) + self.DynamicTable:ReloadDataSync(1) +end + +function XUiReformBuffPanel:OnDynamicTableEvent(event, index, grid) + if index <= 0 or index > #self.DynamicTable.DataSource then return end + local buff = self.DynamicTable.DataSource[index] + self.GridDic[buff:GetId()] = grid + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:SetData(self.BaseStage:GetId(), self.EvolvableStage, buff) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + grid:DynamicTouched() + end +end + +return XUiReformBuffPanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiReform/XUiReformBuffTips.lua b/Resources/Scripts/XUi/XUiReform/XUiReformBuffTips.lua new file mode 100644 index 00000000..004e137c --- /dev/null +++ b/Resources/Scripts/XUi/XUiReform/XUiReformBuffTips.lua @@ -0,0 +1,49 @@ +--######################## XUiReformBuffGrid ######################## +local XUiReformBuffGrid = XClass(nil, "XUiReformBuffGrid") + +function XUiReformBuffGrid:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiReformBuffGrid:SetData(data) + self.RImgIcon:SetRawImage(data.Icon) + self.TxtName.text = data.Name + self.TxtDesc.text = data.Description + self.GameObject:SetActiveEx(true) +end + +--######################## XUiReformBuffTips ######################## +local XUiReformBuffTips = XLuaUiManager.Register(XLuaUi, "UiReformBuffTips") + +function XUiReformBuffTips:OnAwake() + self.GridBuff.gameObject:SetActiveEx(false) + self:RegisterUiEvents() + self.Datas = nil +end + +function XUiReformBuffTips:OnStart(datas, title) + self.Datas = datas + self.TxtTitle.text = title + self:RefreshDataList() +end + +--######################## 私有方法 ######################## + +function XUiReformBuffTips:RegisterUiEvents() + self.BtnClose.CallBack = function() self:Close() end +end + +function XUiReformBuffTips:RefreshDataList() + local go + local grid + for _, data in ipairs(self.Datas) do + go = CS.UnityEngine.Object.Instantiate(self.GridBuff.gameObject) + go.transform:SetParent(self.PanelContent.transform, false) + grid = XUiReformBuffGrid.New(go) + grid:SetData(data) + end +end + +return XUiReformBuffTips \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiReform/XUiReformCharacterDetailInfo.lua b/Resources/Scripts/XUi/XUiReform/XUiReformCharacterDetailInfo.lua new file mode 100644 index 00000000..861e1a42 --- /dev/null +++ b/Resources/Scripts/XUi/XUiReform/XUiReformCharacterDetailInfo.lua @@ -0,0 +1,107 @@ +local CsXTextManager = CS.XTextManager + +--######################## XUiReformCharacterLevelPanel ######################## +local XUiReformCharacterLevelPanel = XClass(nil, "XUiReformCharacterLevelPanel") + +function XUiReformCharacterLevelPanel:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + -- 特殊处理 + self.ExpBar.gameObject:SetActiveEx(false) + self.BtnLevelUpButton.gameObject:SetActiveEx(false) + self.ImgMaxLevel.gameObject:SetActiveEx(false) + self.BtnLiberation.gameObject:SetActiveEx(false) +end + +function XUiReformCharacterLevelPanel:SetData(source) + local robot = source:GetRobot() + local characterViewModel = robot:GetCharacterViewModel() + local attributeDic = characterViewModel:GetAttributes(robot:GetEquipViewModels()) + self.TxtAttack.text = FixToInt(attributeDic[XNpcAttribType.AttackNormal]) + self.TxtLife.text = FixToInt(attributeDic[XNpcAttribType.Life]) + self.TxtDefense.text = FixToInt(attributeDic[XNpcAttribType.DefenseNormal]) + self.TxtCrit.text = FixToInt(attributeDic[XNpcAttribType.Crit]) +end + +--######################## XUiReformCharacterDetailInfo ######################## +local XUiReformCharacterDetailInfo = XLuaUiManager.Register(XLuaUi, "UiReformCharacterDetailInfo") + +local PANEL_INDEX = { + Level = 1, +} + +function XUiReformCharacterDetailInfo:OnAwake() + self:RegisterUiEvents() + self.Source = nil + self.UiReformRoleList = nil + -- 子面板信息配置 + self.ChillPanelInfoDic = { + [PANEL_INDEX.Level] = { + uiParent = self.PanelCharLevel, + assetPath = XUiConfigs.GetComponentUrl("UiPanelCharProperty1"), + proxy = XUiReformCharacterLevelPanel, + -- 代理设置参数 + proxyArgs = { "Source" } + }, + } + -- 按钮组 + self.PanelPropertyButtons:Init({ + [PANEL_INDEX.Level] = self.BtnTabLevel + }, function(tabIndex) self:OnBtnGroupClicked(tabIndex) end) + -- 特殊处理 + self.BtnTabGrade.gameObject:SetActiveEx(false) + self.BtnTabQuality.gameObject:SetActiveEx(false) + self.BtnTabSkill.gameObject:SetActiveEx(false) + self.BtnExchange.gameObject:SetActiveEx(false) + self.BtnTabLevel:SetNameByGroup(0, CsXTextManager.GetText("ReformCharDetailText")) +end + +function XUiReformCharacterDetailInfo:OnStart(uiReformRoleList) + self.UiReformRoleList = uiReformRoleList +end + +function XUiReformCharacterDetailInfo:SetData(source) + self.Source = source + self.PanelPropertyButtons:SelectIndex(PANEL_INDEX.Level) +end + +--######################## 私有方法 ######################## + +function XUiReformCharacterDetailInfo:RegisterUiEvents() +end + +function XUiReformCharacterDetailInfo:OnBtnGroupClicked(index) + local childPanelData = self.ChillPanelInfoDic[index] + if childPanelData == nil then return end + -- 隐藏其他的子面板 + for key, data in pairs(self.ChillPanelInfoDic) do + data.uiParent.gameObject:SetActiveEx(key == index) + end + -- 加载子面板实体 + local instanceGo = childPanelData.instanceGo + if instanceGo == nil then + instanceGo = childPanelData.uiParent:LoadPrefab(childPanelData.assetPath) + childPanelData.instanceGo = instanceGo + end + -- 加载子面板代理 + local instanceProxy = childPanelData.instanceProxy + if instanceProxy == nil then + instanceProxy = childPanelData.proxy.New(instanceGo) + childPanelData.instanceProxy = instanceProxy + end + -- 设置子面板代理参数 + local proxyArgs = {} + if childPanelData.proxyArgs then + for _, argName in ipairs(childPanelData.proxyArgs) do + if type(argName) == "string" then + proxyArgs[#proxyArgs + 1] = self[argName] + else + proxyArgs[#proxyArgs + 1] = argName + end + end + end + instanceProxy:SetData(table.unpack(proxyArgs)) +end + +return XUiReformCharacterDetailInfo \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiReform/XUiReformCharacterInfo.lua b/Resources/Scripts/XUi/XUiReform/XUiReformCharacterInfo.lua new file mode 100644 index 00000000..1c98e396 --- /dev/null +++ b/Resources/Scripts/XUi/XUiReform/XUiReformCharacterInfo.lua @@ -0,0 +1,238 @@ +local CsXTextManager = CS.XTextManager + +local XUiReformAwarenessGrid = XClass(nil, "XUiReformAwarenessGrid") + +function XUiReformAwarenessGrid:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiReformAwarenessGrid:SetData(data) + -- 品质 + self.ImgQuality:SetSprite(data:GetQualityIcon()) + -- 图标 + self.RImgIcon:SetRawImage(data:GetIcon()) + -- 等级 + self.TxtLevel.text = data:GetLevel() + -- 位置 + self.TxtSite.text = "0" .. data:GetSite() + -- 共鸣 + local ResonanceInfos = data:GetResonanceInfos() + local obj = nil + for i = 1, XEquipConfig.MAX_RESONANCE_SKILL_COUNT do + obj = self["ImgResonance" .. i] + if obj then + if ResonanceInfos and ResonanceInfos[i] then + obj.gameObject:SetActiveEx(data:CheckPosIsAwaken(i)) + else + obj.gameObject:SetActiveEx(false) + end + end + end + -- 突破 + local breakthrough = data:GetBreakthrough() + if breakthrough ~= 0 then + self.ImgBreakthrough.gameObject:SetActiveEx(true) + local breakthroughIcon = XEquipConfig.GetEquipBreakThroughSmallIcon(breakthrough) + self.ImgBreakthrough:SetSprite(breakthroughIcon) + else + self.ImgBreakthrough.gameObject:SetActiveEx(false) + end +end + +--######################## XUiReformWeaponGrid ######################## +local XUiReformWeaponGrid = XClass(nil, "XUiReformWeaponGrid") + +function XUiReformWeaponGrid:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiReformWeaponGrid:SetData(data) + -- 头像 + self.RImgIcon:SetRawImage(data:GetIcon()) + -- 品质 + self.ImgQuality:SetSprite(data:GetQualityIcon()) + -- 等级 + self.TxtLevel.text = data:GetLevel() + -- 名字 + self.TxtName.text = data:GetName() + -- 共鸣 + local ResonanceInfos = data:GetResonanceInfos() + local obj = nil + for i = 1, XEquipConfig.MAX_RESONANCE_SKILL_COUNT do + obj = self["ImgResonance" .. i] + if obj then + if ResonanceInfos and ResonanceInfos[i] then + obj:SetSprite(XEquipConfig.GetEquipResoanceIconPath(false)) + obj.gameObject:SetActiveEx(true) + else + obj.gameObject:SetActiveEx(false) + end + end + end + -- 突破 + local breakthrough = data:GetBreakthrough() + if breakthrough ~= 0 then + self.ImgBreakthrough.gameObject:SetActiveEx(true) + local breakthroughIcon = XEquipConfig.GetEquipBreakThroughSmallIcon(breakthrough) + self.ImgBreakthrough:SetSprite(breakthroughIcon) + else + self.ImgBreakthrough.gameObject:SetActiveEx(false) + end +end + +--######################## XUiReformCharacterInfo ######################## +local XUiReformCharacterInfo = XLuaUiManager.Register(XLuaUi, "UiReformCharacterInfo") + +function XUiReformCharacterInfo:OnAwake() + self.Source = nil + self.UiReformWeaponGrid = XUiReformWeaponGrid.New(self.GridWeapon) + self.UiAwarenessGridDic = {} + self.UiReformRoleList = nil + self:RegisterUiEvents() + -- 特殊处理 + self.BtnLevelUpText.text = CsXTextManager.GetText("ReformCharDetailText") + self.ImgRedPoint.gameObject:SetActiveEx(false) +end + +function XUiReformCharacterInfo:OnStart(uiReformRoleList) + self.UiReformRoleList = uiReformRoleList +end + +function XUiReformCharacterInfo:Open() + self.GameObject:SetActiveEx(true) +end + +function XUiReformCharacterInfo:SetData(source) + self.Source = source + local robot = source:GetRobot() + local characterViewModel = robot:GetCharacterViewModel() + -- 头像 + self.RImgTypeIcon:SetRawImage(characterViewModel:GetProfessionIcon()) + -- 名字 + self.TxtName.text = characterViewModel:GetName() + -- 战力参数 + self.TxtLv.text = math.floor(characterViewModel:GetAbility()) + -- 型号 + self.TxtNameOther.text = characterViewModel:GetTradeName() + -- 元素列表 + local elementList = characterViewModel:GetObtainElements() + local rImg = nil + for i = 1, 3 do + rImg = self["RImgCharElement" .. i] + if elementList[i] then + rImg.gameObject:SetActiveEx(true) + rImg:SetRawImage(XCharacterConfigs.GetCharElement(elementList[i]).Icon) + else + rImg.gameObject:SetActiveEx(false) + end + end + -- 装备 + self.UiReformWeaponGrid:SetData(robot:GetWeaponViewModel()) + -- 伙伴 + local partner = robot:GetPartner() + if partner and next(partner) ~= nil then + self.PartnerIcon:SetRawImage(partner:GetIcon()) + end + -- 意识 + local awarenessViewModelDic = robot:GetAwarenessViewModelDic() + local awarenessViewModel = nil + for _, equipSite in pairs(XEquipConfig.EquipSite.Awareness) do + self.UiAwarenessGridDic[equipSite] = self.UiAwarenessGridDic[equipSite] + or XUiReformAwarenessGrid.New(CS.UnityEngine.Object.Instantiate(self.GridAwareness)) + self.UiAwarenessGridDic[equipSite].Transform:SetParent(self["PanelAwareness" .. equipSite], false) + awarenessViewModel = awarenessViewModelDic[equipSite] + if not awarenessViewModel then + self.UiAwarenessGridDic[equipSite].GameObject:SetActiveEx(false) + self["PanelNoAwareness" .. equipSite].gameObject:SetActiveEx(true) + else + self.UiAwarenessGridDic[equipSite].GameObject:SetActiveEx(true) + self["BtnAwarenessReplace" .. equipSite].transform:SetAsLastSibling() + self["PanelNoAwareness" .. equipSite].gameObject:SetActiveEx(false) + self.UiAwarenessGridDic[equipSite]:SetData(awarenessViewModel) + end + end +end + +function XUiReformCharacterInfo:Close() + self.GameObject:SetActiveEx(false) +end + +--######################## 私有方法 ######################## + +function XUiReformCharacterInfo:RegisterUiEvents() + self:RegisterClickEvent(self.BtnCareerTips, self.OnBtnCareerTipsClicked) + self:RegisterClickEvent(self.BtnWeaponReplace, self.OnBtnWeaponReplaceClicked) + self:RegisterClickEvent(self.BtnAwarenessReplace6, self.OnBtnAwarenessReplace6Click) + self:RegisterClickEvent(self.BtnAwarenessReplace5, self.OnBtnAwarenessReplace5Click) + self:RegisterClickEvent(self.BtnAwarenessReplace4, self.OnBtnAwarenessReplace4Click) + self:RegisterClickEvent(self.BtnAwarenessReplace3, self.OnBtnAwarenessReplace3Click) + self:RegisterClickEvent(self.BtnAwarenessReplace2, self.OnBtnAwarenessReplace2Click) + self:RegisterClickEvent(self.BtnAwarenessReplace1, self.OnBtnAwarenessReplace1Click) + self:RegisterClickEvent(self.BtnLevelUp, self.OnBtnLevelUpClicked) + self.BtnElementDetail.CallBack = function() self:OnBtnElementDetailClicked() end + self.BtnCarryPartner.CallBack = function() self:OnCarryPartnerClicked() end +end + +function XUiReformCharacterInfo:OnBtnLevelUpClicked() + self.UiReformRoleList:OpenUiReformCharacterDetailInfo() +end + +function XUiReformCharacterInfo:OnBtnCareerTipsClicked() + XLuaUiManager.Open("UiCharacterCarerrTips") +end + +function XUiReformCharacterInfo:OnBtnElementDetailClicked() + XLuaUiManager.Open("UiCharacterElementDetail", XRobotManager.GetCharacterId(self.Source:GetRobotId())) +end + +function XUiReformCharacterInfo:OnBtnWeaponReplaceClicked() + local robot = self.Source:GetRobot() + XLuaUiManager.Open("UiEquipDetailOther", robot:GetWeaponViewModel():GetEquip(), robot:GetCharacterViewModel():GetCharacter()) +end + +function XUiReformCharacterInfo:OnCarryPartnerClicked() + local robot = self.Source:GetRobot() + local partner = robot:GetPartner() + if partner and next(partner) ~= nil then + XLuaUiManager.Open("UiPartnerPropertyOther", partner) + end +end + +function XUiReformCharacterInfo:OnAwarenessClick(index) + local robot = self.Source:GetRobot() + local awarenessViewModelDic = robot:GetAwarenessViewModelDic() + if awarenessViewModelDic[index] == nil then + return + end + XLuaUiManager.Open("UiEquipDetailOther", awarenessViewModelDic[index]:GetEquip(), robot:GetCharacterViewModel():GetCharacter()) +end + +function XUiReformCharacterInfo:OnBtnAwarenessReplace6Click() + self:OnAwarenessClick(6) +end + +function XUiReformCharacterInfo:OnBtnAwarenessReplace5Click() + self:OnAwarenessClick(5) +end + +function XUiReformCharacterInfo:OnBtnAwarenessReplace4Click() + self:OnAwarenessClick(4) +end + +function XUiReformCharacterInfo:OnBtnAwarenessReplace3Click() + self:OnAwarenessClick(3) +end + +function XUiReformCharacterInfo:OnBtnAwarenessReplace2Click() + self:OnAwarenessClick(2) +end + +function XUiReformCharacterInfo:OnBtnAwarenessReplace1Click() + self:OnAwarenessClick(1) +end + +return XUiReformCharacterInfo \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiReform/XUiReformCombatSettleWin.lua b/Resources/Scripts/XUi/XUiReform/XUiReformCombatSettleWin.lua new file mode 100644 index 00000000..3fcffd74 --- /dev/null +++ b/Resources/Scripts/XUi/XUiReform/XUiReformCombatSettleWin.lua @@ -0,0 +1,138 @@ +local CsXTextManager = CS.XTextManager + +--######################## XUiWinRoleGrid ######################## +local XUiWinRoleGrid = XClass(nil, "XUiWinRoleGrid") + +function XUiWinRoleGrid:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +-- data : XReformMemberSource +function XUiWinRoleGrid:SetData(data) + self.RImgIcon:SetRawImage(data:GetBigHeadIcon()) + self.TxtStar.text = data:GetStarLevel() +end + +--######################## XUiReformCombatSettleWin ######################## + +local XUiReformCombatSettleWin = XLuaUiManager.Register(XLuaUi, "UiReformCombatSettleWin") + +function XUiReformCombatSettleWin:OnAwake() + self.GridWinRole.gameObject:SetActiveEx(false) + self.GridReward.gameObject:SetActiveEx(false) + self.GridRewardList = {} + self.RewardAnimationIndex = 1 + self:RegisterUiEvents() +end + +function XUiReformCombatSettleWin:OnStart(winData) + local currDiff = winData.SettleData.ReformFightResult.CurrDiff + local baseStage = XDataCenter.ReformActivityManager.GetBaseStage(winData.StageId) + local evolvableStage = baseStage:GetEvolvableStageByDiffIndex(currDiff + 1) + -- 名称 + self.TxtTitle.text = baseStage:GetName() + -- 难度等级 + self.TxtDiffTitle.text = evolvableStage:GetName() + -- 角色 + local teamData = evolvableStage:GetTeamData() + local memberSource = nil + local memberGroup = evolvableStage:GetEvolvableGroupByType(XReformConfigs.EvolvableGroupType.Member) + local winRoleGo = nil + local winRoleGrid = nil + for _, sourceId in ipairs(teamData.SourceIdsInTeam) do + memberSource = memberGroup:GetSourceById(sourceId) + if memberSource then + winRoleGo = CS.UnityEngine.Object.Instantiate(self.GridWinRole, self.PanelRoleContent) + winRoleGo.gameObject:SetActiveEx(true) + winRoleGrid = XUiWinRoleGrid.New(winRoleGo) + winRoleGrid:SetData(memberSource) + end + end + self.RewardList.gameObject:SetActiveEx(winData.RewardGoodsList ~= nil and #winData.RewardGoodsList > 0) + self.PanelAssist.gameObject:SetActiveEx(winData.RewardGoodsList == nil or #winData.RewardGoodsList <= 0) + -- 奖励 + if winData.RewardGoodsList ~= nil and #winData.RewardGoodsList > 0 then + self.RewardList.gameObject:SetActiveEx(true) + local rewards = XRewardManager.FilterRewardGoodsList(winData.RewardGoodsList) + rewards = XRewardManager.MergeAndSortRewardGoodsList(rewards) + local rewardGo = nil + local rewardGrid = nil + for _, item in ipairs(rewards) do + rewardGo = CS.UnityEngine.Object.Instantiate(self.GridReward) + rewardGrid = XUiGridCommon.New(self, rewardGo) + rewardGrid.Transform:SetParent(self.PanelRewardContent, false) + rewardGrid:Refresh(item, nil, nil, true) + rewardGo.gameObject:SetActiveEx(false) + table.insert(self.GridRewardList, rewardGrid) + end + else + self.RewardList.gameObject:SetActiveEx(false) + end + -- 积分 + if winData.RewardGoodsList == nil or #winData.RewardGoodsList <= 0 then + self.PanelAssist.gameObject:SetActiveEx(true) + self.TxtAssist.text = CsXTextManager.GetText("ReformSettleScoreText", winData.SettleData.ReformFightResult.Score) + local maxScore = evolvableStage:GetMaxScore() + self.TxtAssistMax.gameObject:SetActiveEx(winData.SettleData.ReformFightResult.Score < maxScore) + self.TxtAssistMax.text = CsXTextManager.GetText("ReformSettleMaxScoreTip", maxScore) + else + self.PanelAssist.gameObject:SetActiveEx(false) + end + local txtLevelName = XPlayer.IsHonorLevelOpen() and CS.XTextManager.GetText("HonorLevel") or nil + if self.TxtLevelTitle and txtLevelName then + self.TxtLevelTitle.text = txtLevelName + end + self.TxtPlayerLevel.text = XPlayer.GetLevelOrHonorLevel() + self:PlayRewardAnimation() +end + +--######################## 私有方法 ######################## + +function XUiReformCombatSettleWin:RegisterUiEvents() + self.BtnBlock.CallBack = function() self:Close() end +end + +-- 奖励动画 +function XUiReformCombatSettleWin:PlayRewardAnimation() + XLuaUiManager.SetMask(true) + local delay = XDataCenter.FubenManager.SettleRewardAnimationDelay + local interval = XDataCenter.FubenManager.SettleRewardAnimationInterval + -- 没有奖励则直接播放第二个动画 + if #self.GridRewardList == 0 then + XScheduleManager.ScheduleOnce(function() + self:PlaySecondAnimation() + end, delay) + return + end + self.RewardAnimationIndex = 1 + XScheduleManager.Schedule(function() + if XTool.UObjIsNil(self.GridRewardList[self.RewardAnimationIndex].GameObject) then + return + end + if self.RewardAnimationIndex == #self.GridRewardList then + self:PlayReward(self.RewardAnimationIndex, function() + self:PlaySecondAnimation() + end) + else + self:PlayReward(self.RewardAnimationIndex) + end + self.RewardAnimationIndex = self.RewardAnimationIndex + 1 + end, interval, #self.GridRewardList, delay) +end + +function XUiReformCombatSettleWin:PlaySecondAnimation() + self:PlayAnimation("AnimEnable2", function() + XLuaUiManager.SetMask(false) + XDataCenter.FunctionEventManager.UnLockFunctionEvent() + self.IsFirst = false; + end) +end + +function XUiReformCombatSettleWin:PlayReward(index, cb) + self.GridRewardList[index].GameObject:SetActiveEx(true) + self:PlayAnimation("GridReward", cb) +end + +return XUiReformCombatSettleWin \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiReform/XUiReformEnemyPanel.lua b/Resources/Scripts/XUi/XUiReform/XUiReformEnemyPanel.lua new file mode 100644 index 00000000..d87a5a39 --- /dev/null +++ b/Resources/Scripts/XUi/XUiReform/XUiReformEnemyPanel.lua @@ -0,0 +1,489 @@ +local CsXTextManager = CS.XTextManager + +--######################## XUiReformTargetGrid ######################## +local XUiReformTargetGrid = XClass(nil, "XUiReformTargetGrid") + +function XUiReformTargetGrid:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.Target = nil + self.BaseStage = nil + self.EvolvableStage = nil + self.TargetPanel = nil + self.BtnBuff1.CallBack = function() self:OnBtnBuffClicked() end + self.BtnBuff2.CallBack = function() self:OnBtnBuffClicked() end + self.BtnClick.CallBack = function() self:OnClicked() end +end + +-- target : XReformEnemyTarget +function XUiReformTargetGrid:SetData(target, baseStage, evolvableStage, targetPanel) + self.Target = target + self.BaseStage = baseStage + self.EvolvableStage = evolvableStage + self.TargetPanel = targetPanel + self.TxtName.text = target:GetName() + self.RImgIcon:SetRawImage(target:GetIcon()) + self.TxtLevel.text = target:GetShowLevel() + self.TxtScore.text = target:GetScore() + self.PanelSelect.gameObject:SetActiveEx(target:GetIsActive()) + local buffViewModels = target:GetBuffDetailViewModels() + for i = 1, 2 do + if buffViewModels[i] then + self["RImgBuff" .. i].gameObject:SetActiveEx(true) + self["RImgBuff" .. i]:SetRawImage(buffViewModels[i].Icon) + if self["TextNone" .. i] then + self["TextNone" .. i].gameObject:SetActiveEx(false) + end + else + self["RImgBuff" .. i].gameObject:SetActiveEx(false) + if self["TextNone" .. i] then + self["TextNone" .. i].gameObject:SetActiveEx(true) + end + end + end +end + +function XUiReformTargetGrid:OnBtnBuffClicked() + local buffDatas = self.Target:GetBuffDetailViewModels() + if #buffDatas > 0 then + XLuaUiManager.Open("UiReformBuffTips", buffDatas, CsXTextManager.GetText("ReformEnemyBuffTipsTitle")) + end +end + +function XUiReformTargetGrid:DynamicTouched(source) + local isActive = self.Target:GetIsActive() + if isActive then + -- 取消激活,检查取消后是否能够继续满足分数 + local subScore = self.Target:GetScore() + if source:GetEntityType() == XReformConfigs.EntityType.Add then + subScore = subScore + source:GetScore() + end + if subScore > self.EvolvableStage:GetChallengeScore() then + XUiManager.TipError(CsXTextManager.GetText("ReformScoreCancelLimitTip")) + return + end + end + local replaceIdDic = XTool.Clone(self.EvolvableStage:GetEnemyReplaceIdDic()) + if isActive then + replaceIdDic[self.Target:GetSourceId()] = 0 + else + replaceIdDic[source:GetId()] = self.Target:GetId() + end + local replaceIdData = {} + for sourceId, targetId in pairs(replaceIdDic) do + table.insert(replaceIdData, { + SourceId = sourceId, + TargetId = targetId, + }) + end + XDataCenter.ReformActivityManager.EnemyReplaceRequest(self.BaseStage:GetId(), self.EvolvableStage:GetDifficulty() + , replaceIdData, function() + local selectedIndex = self.TargetPanel.RootPanel:GetSourceIndex(source) + if source:GetEntityType() == XReformConfigs.EntityType.Add then + self.TargetPanel.RootPanel:OnSourceGridClicked(selectedIndex) + end + self.TargetPanel:Close() + self.TargetPanel.RootPanel:SetBtnCloseReformActive(false) + -- 激活,播放选中的格子动画 + if not isActive then + self.TargetPanel.RootPanel:PlaySourceGridRefreshAnim(selectedIndex) + end + end) +end + +function XUiReformTargetGrid:OnClicked() + -- 检查图鉴是否已经开放 + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.Archive, false, true) then + XUiManager.TipError(CsXTextManager.GetText("ReformMonsterOpenTip")) + return + end + local monsterEntity = self.Target:GetMonsterEntity() + if monsterEntity == nil then return end + if monsterEntity:GetIsLockMain() then + XUiManager.TipText("ArchiveMonsterLock") + return + end + XDataCenter.ArchiveManager.GetMonsterEvaluateFromSever(monsterEntity:GetNpcId(), function() + XLuaUiManager.Open("UiArchiveMonsterDetail", { monsterEntity }, 1, XArchiveConfigs.MonsterDetailUiType.Show) + end) +end + +--######################## XUiReformTargetPanel ######################## +local XUiReformTargetPanel = XClass(nil, "XUiReformTargetPanel") + +function XUiReformTargetPanel:Ctor(ui, rootPanel) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.Source = nil + self.BaseStage = nil + self.EvolvableStage = nil + self.RootPanel = rootPanel + self:RegisterUiEvents() + -- 动态列表 + self.GridEnemy.gameObject:SetActiveEx(false) + self.DynamicTable = XDynamicTableNormal.New(self.PanelReformList) + self.DynamicTable:SetProxy(XUiReformTargetGrid) + self.DynamicTable:SetDelegate(self) +end + +function XUiReformTargetPanel:SetData(source, baseStage, evolvableStage) + self.Source = source + self.BaseStage = baseStage + self.EvolvableStage = evolvableStage + self:RefreshDynamicTable() +end + +function XUiReformTargetPanel:Refresh() + self:RefreshDynamicTable() +end + +function XUiReformTargetPanel:Open() + self.RootPanel.PanelReformEnable:Play() + self.GameObject:SetActiveEx(true) +end + +function XUiReformTargetPanel:Close() + self.RootPanel.PanelReformEnable:Stop() + self.GameObject:SetActiveEx(false) + self.RootPanel:SetScrollListControl(true) + self.RootPanel:SetSelectedGrid(nil) +end + +--######################## 私有方法 ######################## + +function XUiReformTargetPanel:RegisterUiEvents() + self.BtnClose.CallBack = function() self:Close() end +end + +function XUiReformTargetPanel:RefreshDynamicTable() + self.DynamicTable:SetDataSource(self.Source:GetTargets()) + self.DynamicTable:ReloadDataSync(1) +end + +function XUiReformTargetPanel:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:SetData(self.DynamicTable.DataSource[index] + , self.BaseStage, self.EvolvableStage, self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + grid:DynamicTouched(self.Source) + end +end + +--######################## XUiReformAddGrid ######################## +local XUiReformAddGrid = XClass(nil, "XUiReformAddGrid") + +function XUiReformAddGrid:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.Source = nil + self.EmptyPosCount = nil + self.SourcePanel = nil + self.Index = nil + self:RegisterUiEvents() +end + +function XUiReformAddGrid:SetData(data, index, sourcePanel) + self.Source = data.source + self.EmptyPosCount = data.emptyPosCount + self.SourcePanel = sourcePanel + self.Index = index + self.TxtCount.text = CsXTextManager.GetText("ReformEnemyAddCountText", data.emptyPosCount) + self.TxtScore.text = data.source:GetScore() +end + +--######################## 私有方法 ######################## + +function XUiReformAddGrid:RegisterUiEvents() + self.BtnAdd.CallBack = function() self:OnBtnAddClicked() end +end + +function XUiReformAddGrid:OnBtnAddClicked() + self.SourcePanel:OpenTargetReformPanel(self.Source) + self.SourcePanel:OnSourceGridClicked(self.Index) +end + +--######################## XUiReformSourceGrid ######################## +local XUiReformSourceGrid = XClass(nil, "XUiReformSourceGrid") + +function XUiReformSourceGrid:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.Data = nil + self.SourcePanel = nil + self.Index = nil + self.UiGridAdd = XUiReformAddGrid.New(self.GridAdd) + self:RegisterUiEvents() +end + +function XUiReformSourceGrid:SetData(data, index, sourcePanel) + self.Data = data + self.Index = index + self.SourcePanel = sourcePanel + local isAdd = data.isAddEntity == true and true or false + self.GridAdd.gameObject:SetActiveEx(isAdd) + self.GridEntity.gameObject:SetActiveEx(not isAdd) + if isAdd then + self:SetAddData(data) + else + self:SetEntityData(data) + end +end + +function XUiReformSourceGrid:SetEntityData(source) + local score = 0 + if source:GetEntityType() == XReformConfigs.EntityType.Add then + self.Tab1.gameObject:SetActiveEx(source:GetIsActive()) + self.Tab2.gameObject:SetActiveEx(false) + score = score + source:GetScore() + else + self.Tab1.gameObject:SetActiveEx(false) + -- self.Tab2.gameObject:SetActiveEx(source:GetIsActive()) + self.Tab2.gameObject:SetActiveEx(false) + end + score = score + source:GetTargetScore() + self.TxtName.text = source:GetName() + self.RImgIcon:SetRawImage(source:GetIcon()) + self.TxtLevel.text = CsXTextManager.GetText("ReformEnemyLevelText", source:GetShowLevel()) + self.TxtCost.text = score + local buffViewModels = self.Data:GetBuffDetailViewModels() + for i = 1, 2 do + if buffViewModels[i] then + self["BtnBuff" .. i].gameObject:SetActiveEx(true) + self["RImgBuff" .. i]:SetRawImage(buffViewModels[i].Icon) + else + self["BtnBuff" .. i].gameObject:SetActiveEx(false) + end + end +end + +function XUiReformSourceGrid:SetAddData(data) + self.UiGridAdd:SetData(data, self.Index, self.SourcePanel) +end + +function XUiReformSourceGrid:SetSelectStatus(value) + self.PanelSelect.gameObject:SetActiveEx(value) +end + +function XUiReformSourceGrid:PlayRefreshAnim() + self.PlayableDirector:Play() +end + +--######################## 私有方法 ######################## + +function XUiReformSourceGrid:RegisterUiEvents() + self.BtnReform.CallBack = function() self:OnBtnReformClicked() end + self.BtnClick.CallBack = function() self:OnBtnClickClicked() end + self.BtnBuff1.CallBack = function() self:OnBtnBuffClicked() end + self.BtnBuff2.CallBack = function() self:OnBtnBuffClicked() end +end + +function XUiReformSourceGrid:OnBtnBuffClicked() + local buffDatas = self.Data:GetBuffDetailViewModels() + if #buffDatas > 0 then + XLuaUiManager.Open("UiReformBuffTips", buffDatas, CsXTextManager.GetText("ReformEnemyBuffTipsTitle")) + end +end + +function XUiReformSourceGrid:OnBtnReformClicked() + self.SourcePanel:OpenTargetReformPanel(self.Data) + self.SourcePanel:OnSourceGridClicked(self.Index) +end + +function XUiReformSourceGrid:OnBtnClickClicked() + -- 检查图鉴是否已经开放 + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.Archive, false, true) then + XUiManager.TipError(CsXTextManager.GetText("ReformMonsterOpenTip")) + return + end + local monsterEntity = self.Data:GetMonsterEntity() + if monsterEntity == nil then return end + if monsterEntity:GetIsLockMain() then + XUiManager.TipText("ArchiveMonsterLock") + return + end + -- local sourcesWithEntity = self.SourcePanel:GetSources() + -- local monsterEntities = {} + -- local tempMonsterEntity = nil + -- local selfIndex = 1 + -- for i, source in ipairs(sourcesWithEntity) do + -- tempMonsterEntity = source:GetMonsterEntity() + -- if tempMonsterEntity and not tempMonsterEntity:GetIsLockMain() then + -- table.insert(monsterEntities, tempMonsterEntity) + -- end + -- if source:GetId() == self.Data:GetId() then + -- selfIndex = i + -- end + -- end + -- XDataCenter.ArchiveManager.GetMonsterEvaluateFromSever(monsterEntity:GetNpcId(), function() + -- XLuaUiManager.Open("UiArchiveMonsterDetail", monsterEntities, selfIndex, XArchiveConfigs.MonsterDetailUiType.Show) + -- end) + XDataCenter.ArchiveManager.GetMonsterEvaluateFromSever(monsterEntity:GetNpcId(), function() + XLuaUiManager.Open("UiArchiveMonsterDetail", { monsterEntity }, 1, XArchiveConfigs.MonsterDetailUiType.Show) + end) +end + +--######################## XUiReformEnemyPanel ######################## +local XUiReformEnemyPanel = XClass(nil, "XUiReformEnemyPanel") + +function XUiReformEnemyPanel:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.BaseStage = nil + self.EvolvableStage = nil + self.EvolvableGroup = nil + -- 动态列表 + self.GridEnemy.gameObject:SetActiveEx(false) + self.DynamicTable = XDynamicTableNormal.New(self.PanelEnemyList) + self.DynamicTable:SetProxy(XUiReformSourceGrid) + self.DynamicTable:SetDelegate(self) + -- 改造面板 + self.UiReformTargetPanel = XUiReformTargetPanel.New(self.PanelReform, self) + self.TxtTip.text = CsXTextManager.GetText("ReformEnemyPanelTopTip") + self.BtnCloseReform.gameObject:SetActiveEx(false) + self.TxtTip2.text = CsXTextManager.GetText("ReformMemberPanelTopEvolableTip") + self:RegisterUiEvents() +end + +function XUiReformEnemyPanel:SetData(baseStage, evolvableStage) + self.BaseStage = baseStage + self.EvolvableStage = evolvableStage + self.EvolvableGroup = evolvableStage:GetEvolvableGroupByType(XReformConfigs.EvolvableGroupType.Enemy) + -- 刷新源列表 + self:RefreshDynamicTable() + self:CloseTargetReformPanel() +end + +function XUiReformEnemyPanel:RefreshEvolvableData() + local sources = self:GetSourcesWithEntity() + local grids = self.DynamicTable:GetGrids() + if #self.DynamicTable.DataSource == #sources then + for i, v in ipairs(sources) do + if grids[i] then + grids[i]:SetData(sources[i], i, self) + end + end + self.DynamicTable:SetDataSource(sources) + else + self:RefreshDynamicTable(sources) + end + self.UiReformTargetPanel:Refresh() +end + +function XUiReformEnemyPanel:OpenTargetReformPanel(source) + self.UiReformTargetPanel:Open() + self.UiReformTargetPanel:SetData(source, self.BaseStage, self.EvolvableStage) + self.BtnCloseReform.gameObject:SetActiveEx(true) +end + +function XUiReformEnemyPanel:CloseTargetReformPanel() + self.UiReformTargetPanel:Close() + self.BtnCloseReform.gameObject:SetActiveEx(false) +end + +function XUiReformEnemyPanel:SetBtnCloseReformActive(value) + self.BtnCloseReform.gameObject:SetActiveEx(value) +end + +function XUiReformEnemyPanel:SetScrollListControl(value) + if value then + self.PanelEnemyList.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Elastic + self.PanelEnemyList.horizontal = true + else + self.PanelEnemyList.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Unrestricted + self.PanelEnemyList.horizontal = false + end +end + +--######################## 私有方法 ######################## + +function XUiReformEnemyPanel:RegisterUiEvents() + self.BtnCloseReform.CallBack = function() self:OnBtnCloseReformClicked() end +end + +function XUiReformEnemyPanel:OnBtnCloseReformClicked() + self:CloseTargetReformPanel() +end + +function XUiReformEnemyPanel:RefreshDynamicTable(sources) + sources = sources or self:GetSourcesWithEntity() + self.DynamicTable:SetDataSource(sources) + self.DynamicTable:ReloadDataSync(1) +end + +function XUiReformEnemyPanel:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:SetData(self.DynamicTable.DataSource[index], index, self) + end +end + +function XUiReformEnemyPanel:GetSourcesWithEntity() + local entities, nextAddSource, emptyPosCount = self.EvolvableGroup:GetSourcesWithEntity() + if nextAddSource then + table.insert(entities, { + source = nextAddSource, + emptyPosCount = emptyPosCount, + isAddEntity = true, + Id = nextAddSource:GetId() + }) + end + return entities +end + +function XUiReformEnemyPanel:GetSources() + return self.EvolvableGroup:GetSourcesWithEntity() +end + +function XUiReformEnemyPanel:GetSourceIndex(source) + local sources = self:GetSources() + for i, v in ipairs(sources) do + if v == source then + return i + end + end + return #self.DynamicTable.DataSource - 1 +end + +function XUiReformEnemyPanel:OnSourceGridClicked(index) + self:SetSelectedGrid(index) + self:ScrollGrid(index) +end + +function XUiReformEnemyPanel:SetSelectedGrid(index) + for i, grid in pairs(self.DynamicTable:GetGrids()) do + grid:SetSelectStatus(i == index) + end +end + +function XUiReformEnemyPanel:ScrollGrid(index) + local grids = self.DynamicTable:GetGrids() + local grid = grids[index] + if not grid then + self.DynamicTable:ReloadDataSync(index) + return + end + self:SetScrollListControl(false) + local distance = (grid.Transform.localPosition + self.PanelEnemyListContent.localPosition).x * -1 + if distance >= XReformConfigs.MinDistance and distance <= XReformConfigs.MaxDistance then return end + local targetPos = self.PanelEnemyListContent.localPosition + if index == 1 then + targetPos.x = math.min(self.PanelEnemyListContent.rect.width / 2 - self.PanelEnemyListContent.parent.rect.width / 2) + - self.PanelEnemyListContent.rect.width / 2 + else + targetPos.x = targetPos.x + distance - grid.Transform.rect.width / 2 - XReformConfigs.ScrollOffset + end + XUiHelper.DoMove(self.PanelEnemyListContent, targetPos, 0.3, XUiHelper.EaseType.Sin) +end + +function XUiReformEnemyPanel:PlaySourceGridRefreshAnim(index) + local grid = self.DynamicTable:GetGrids()[index] + if not grid then return end + grid:PlayRefreshAnim() +end + + +return XUiReformEnemyPanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiReform/XUiReformEnvironmentPanel.lua b/Resources/Scripts/XUi/XUiReform/XUiReformEnvironmentPanel.lua new file mode 100644 index 00000000..b808d79d --- /dev/null +++ b/Resources/Scripts/XUi/XUiReform/XUiReformEnvironmentPanel.lua @@ -0,0 +1,108 @@ +local CsXTextManager = CS.XTextManager + +--######################## XUiReformEnvironmentGrid ######################## +local XUiReformEnvironmentGrid = XClass(nil, "XUiReformEnvironmentGrid") + +function XUiReformEnvironmentGrid:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:RegisterUiEvents() + -- XReformEvolvableStage + self.EvolvableStage = nil + self.BaseStageId = nil + -- XReformEnvrionment + self.Data = nil +end + +function XUiReformEnvironmentGrid:SetData(baseStageId, evolvableStage, data) + self.BaseStageId = baseStageId + self.EvolvableStage = evolvableStage + self.Data = data + self.RImgIcon:SetRawImage(data:GetIcon()) + self.RImgText:SetRawImage(data:GetTextIcon()) + self.TxtDes.text = data:GetDes() + self.TxtScore.text = data:GetScore() + self.PanelSelect.gameObject:SetActiveEx(data:GetIsActive()) +end + +--######################## 私有方法 ######################## + +function XUiReformEnvironmentGrid:RegisterUiEvents() + self.BtnReform.CallBack = function() self:OnBtnReformClicked() end +end + +function XUiReformEnvironmentGrid:OnBtnReformClicked() + -- 检查取消激活后分数是否大于0 + if self.Data:GetIsActive() and self.EvolvableStage:GetChallengeScore() < self.Data:GetScore() then + XUiManager.TipError(CsXTextManager.GetText("ReformScoreLimitTip")) + return + end + if not self.Data:GetIsActive() and not self.EvolvableStage:CheckEnvironmentMaxCount() then + XUiManager.TipError(CsXTextManager.GetText("ReformMaxEnvCountTip")) + return + end + local envIds = XTool.Clone(self.EvolvableStage:GetEnvIds()) + local selfId = self.Data:GetId() + if self.Data:GetIsActive() then -- 取消激活 + XTool.TableRemove(envIds, selfId) + else -- 激活 + table.insert(envIds, selfId) + end + XDataCenter.ReformActivityManager.EnvironmentUpdateRequest(self.BaseStageId, self.EvolvableStage:GetDifficulty(), envIds, self.Data:GetId()) +end + +--######################## XUiReformEnvironmentPanel ######################## +local XUiReformEnvironmentPanel = XClass(nil, "XUiReformEnvironmentPanel") + +function XUiReformEnvironmentPanel:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + -- XReformEvolvableStage + self.EvolvableStage = nil + -- XReformBaseStage + self.BaseStage = nil + -- 初始化动态列表 + self.GirdScene.gameObject:SetActiveEx(false) + self.DynamicTable = XDynamicTableNormal.New(self.PanelSceneList) + self.DynamicTable:SetProxy(XUiReformEnvironmentGrid) + self.DynamicTable:SetDelegate(self) + self.GridDic = nil +end + +-- baseStage : XReformBaseStage +-- evolableStage : XReformEvolvableStage +function XUiReformEnvironmentPanel:SetData(baseStage, evolableStage) + self.GridDic = {} + self.BaseStage = baseStage + self.EvolvableStage = evolableStage + -- 刷新动态列表 + self:RefreshDynamicTable() + self.TxtTip.text = CsXTextManager.GetText("ReformEnvPanelTopTip", evolableStage:GetMaxEnvrionmentCount()) +end + +function XUiReformEnvironmentPanel:RefreshEvolvableData(envId) + local environmentGroup = self.EvolvableStage:GetEvolvableGroupByType(XReformConfigs.EvolvableGroupType.Environment) + self.GridDic[envId]:SetData(self.BaseStage:GetId(), self.EvolvableStage, environmentGroup:GetEnvironmentById(envId)) +end + +--######################## 私有方法 ######################## + +function XUiReformEnvironmentPanel:RefreshDynamicTable(envId) + local environmentGroup = self.EvolvableStage:GetEvolvableGroupByType(XReformConfigs.EvolvableGroupType.Environment) + self.DynamicTable:SetDataSource(environmentGroup:GetEnvironments()) + self.DynamicTable:ReloadDataSync(1) +end + +function XUiReformEnvironmentPanel:OnDynamicTableEvent(event, index, grid) + if index <= 0 or index > #self.DynamicTable.DataSource then return end + local environmentGroup = self.EvolvableStage:GetEvolvableGroupByType(XReformConfigs.EvolvableGroupType.Environment) + local environment = self.DynamicTable.DataSource[index] + self.GridDic[environment:GetId()] = grid + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:SetData(self.BaseStage:GetId(), self.EvolvableStage, environment) + end +end + +return XUiReformEnvironmentPanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiReform/XUiReformList.lua b/Resources/Scripts/XUi/XUiReform/XUiReformList.lua new file mode 100644 index 00000000..6b3fbd97 --- /dev/null +++ b/Resources/Scripts/XUi/XUiReform/XUiReformList.lua @@ -0,0 +1,251 @@ +local CsXTextManager = CS.XTextManager + +--######################## XUiReformList ######################## +local XUiReformList = XLuaUiManager.Register(XLuaUi, "UiReformList") + +function XUiReformList:OnAwake() + -- XReformBaseStage + self.BaseStage = nil + -- XReformEvolvableStage + self.CurrentEvolvableStage = nil + self.CurrentElementBtnIndex = nil + -- 当前改造等级选中的index + self.CurEvolvableLevelBtnGroupIndex = nil + self.ElementBtnGroupDic = { + [XReformConfigs.EvolvableGroupType.Enemy] = self.BtnEnemy, + [XReformConfigs.EvolvableGroupType.Member] = self.BtnChar, + [XReformConfigs.EvolvableGroupType.Environment] = self.BtnScene, + [XReformConfigs.EvolvableGroupType.Buff] = self.BtnBuff, + } + self:RegisterUiEvents() + -- 子面板信息配置 + self.ChildPanelInfoDic = { + [XReformConfigs.EvolvableGroupType.Enemy] = { + uiParent = self.PanelReformEnemy, + assetPath = XUiConfigs.GetComponentUrl("UiReformEnemyPanel"), + proxy = require("XUi/XUiReform/XUiReformEnemyPanel"), + proxyArgs = { "BaseStage", "CurrentEvolvableStage"}, + }, + [XReformConfigs.EvolvableGroupType.Member] = { + uiParent = self.PanelReformChar, + assetPath = XUiConfigs.GetComponentUrl("UiReformMemberPanel"), + proxy = require("XUi/XUiReform/XUiReformMemberPanel"), + proxyArgs = { "BaseStage", "CurrentEvolvableStage" }, + }, + [XReformConfigs.EvolvableGroupType.Buff] = { + uiParent = self.PanelReformBuff, + assetPath = XUiConfigs.GetComponentUrl("UiReformBuffPanel"), + proxy = require("XUi/XUiReform/XUiReformBuffPanel"), + proxyArgs = { "BaseStage", "CurrentEvolvableStage" }, + }, + [XReformConfigs.EvolvableGroupType.Environment] = { + uiParent = self.PanelReformScene, + assetPath = XUiConfigs.GetComponentUrl("UiReformEnvironmentPanel"), + proxy = require("XUi/XUiReform/XUiReformEnvironmentPanel"), + proxyArgs = { "BaseStage", "CurrentEvolvableStage" }, + }, + } + XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem + , XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + -- 自动关闭 + local endTime = XDataCenter.ReformActivityManager.GetActivityEndTime() + self:SetAutoCloseInfo(endTime, function(isClose) + if isClose then + XDataCenter.ReformActivityManager.HandleActivityEndTime() + end + end) +end + +-- baseStage : XReformBaseStage +function XUiReformList:OnStart(baseStage) + self.BaseStage = baseStage + if baseStage:GetCurrentDifficulty() == 1 then + baseStage:SetCurrentDiffIndex(2) + XDataCenter.ReformActivityManager.ChageStageDiffRequest(baseStage:GetId(), 2) + end + -- 处理顶部细节 + local tabBtn = nil + local isOpen = nil + for i = 1, 3 do + isOpen = self.BaseStage:GetDifficultyIsOpen(i + 1) + tabBtn = self["Tab" .. i] + self["Tab" .. i .. "RedPoint"].gameObject:SetActiveEx(XDataCenter.ReformActivityManager.CheckEvolvableDiffIsShowRedDot(self.BaseStage:GetId(), i + 1)) + tabBtn:SetNameByGroup(0, CsXTextManager.GetText("ReformEvolvableStageName" .. i)) + tabBtn:SetNameByGroup(2, "0" .. i) + tabBtn:SetButtonState(isOpen and CS.UiButtonState.Normal or CS.UiButtonState.Disable) + if not isOpen then + tabBtn.transform:Find("Disable/TextCost"):GetComponent("Text").text = baseStage:GetEvolvableStageByDiffIndex(i):GetName() + tabBtn.transform:Find("Disable/TextCost/TxtCost"):GetComponent("Text").text = baseStage:GetEvolvableStageByDiffIndex(i + 1):GetUnlockScore() + end + end + -- 默认打开最后通关的难度 + local currentEvolvableLevelIndex = math.max(baseStage:GetCurrentDifficulty() - 1, 1) + self.EvolvableLevelBtnGroup:SelectIndex(currentEvolvableLevelIndex) + self.CurEvolvableLevelBtnGroupIndex = currentEvolvableLevelIndex + -- 初始化改造相关按钮 + local btnResult = {} + for groupType, btn in pairs(self.ElementBtnGroupDic) do + table.insert(btnResult, { + groupType = groupType, + btn = btn, + }) + end + table.sort(btnResult, function(dataA, dataB) + return XReformConfigs.GetGroupTypeSortWeight(dataA.groupType) < XReformConfigs.GetGroupTypeSortWeight(dataB.groupType) + end) + for index, data in pairs(btnResult) do + data.btn.gameObject:SetActiveEx(self.CurrentEvolvableStage:GetEvolvableGroupByType(data.groupType) ~= nil) + data.btn.transform:SetSiblingIndex(index) + end + -- 更新改造等级下的积分 + self:RefreshEvolvableLevelScores() + -- 更新挑战积分 + self:RefreshChallengeScore(false) + self.BtnSaveReform:SetNameByGroup(0, CsXTextManager.GetText("ReformListSaveBtnName")) +end + +function XUiReformList:OnEnable() + XUiReformList.Super.OnEnable(self) + self:RegisterEventListeners() +end + +function XUiReformList:OnDisable() + XUiReformList.Super.OnDisable(self) + self:ClearEventListeners() +end + +--######################## 私有方法 ######################## + +function XUiReformList:RefreshEvolvableLevelScores() + local evolvableStages = self.BaseStage:GetEvolvableStages() + local tabBtn = nil + for index, evolvableStage in ipairs(evolvableStages) do + tabBtn = self["Tab" .. index] + tabBtn.transform:Find("Normal/TextCost/TxtCost"):GetComponent("Text").text = evolvableStage:GetMaxScore() + tabBtn.transform:Find("Press/TextCost/TxtCost"):GetComponent("Text").text = evolvableStage:GetMaxScore() + tabBtn.transform:Find("Select/TextCost/TxtCost"):GetComponent("Text").text = evolvableStage:GetMaxScore() + -- tabBtn.transform:Find("Disable/TextCost/TxtCost"):GetComponent("Text").text = evolvableStage:GetMaxScore() + end +end + +function XUiReformList:RefreshChallengeScore(showEffect) + if showEffect == nil then showEffect = true end + self.TxtScore.text = self.CurrentEvolvableStage:GetChallengeScore() + self.EffectScore.gameObject:SetActiveEx(false) + if showEffect then + self.EffectScore.gameObject:SetActiveEx(true) + end +end + + +function XUiReformList:RegisterEventListeners() + XEventManager.AddEventListener(XEventId.EVENT_REFORM_EVOLVABLE_GROUP_UPDATE, self.OnReformEvolvableGroupUpdate, self) +end + +function XUiReformList:ClearEventListeners() + XEventManager.RemoveEventListener(XEventId.EVENT_REFORM_EVOLVABLE_GROUP_UPDATE, self.OnReformEvolvableGroupUpdate, self) +end + +function XUiReformList:RegisterUiEvents() + self.BtnBack.CallBack = function() self:Close() end + self.BtnMainUi.CallBack = function() XLuaUiManager.RunMain() end + self.BtnSaveReform.CallBack = function() self:OnBtnSaveReformClicked() end + self.BtnScoreIcon.CallBack = function() self:OnBtnScoreIconClicked() end + -- 初始化改造等级按钮组 + self.EvolvableLevelBtnGroup:Init({ + [1] = self.Tab1, + [2] = self.Tab2, + [3] = self.Tab3, + }, function(tabIndex) self:OnEvolvableLevelBtnGroupClicked(tabIndex) end) + -- 初始化改造元素按钮组 + self.EvolvableElementBtnGroup:Init(self.ElementBtnGroupDic, function(tabIndex) self:OnEvolvableElementBtnGroupClicked(tabIndex) end) + self.BtnPreview.CallBack = function() self:OnBtnPreviewClicked() end + self:BindHelpBtn(self.BtnHelp, XDataCenter.ReformActivityManager.GetHelpName()) +end + +function XUiReformList:OnBtnPreviewClicked() + XLuaUiManager.Open("UiReformPreview", self.CurrentEvolvableStage) +end + +function XUiReformList:OnBtnScoreIconClicked() + XLuaUiManager.Open("UiTip", XDataCenter.ReformActivityManager.GetScoreItemId()) +end + +-- 改造等级难度点击 +function XUiReformList:OnEvolvableLevelBtnGroupClicked(index) + local selectDiffIndex = index + 1 + if not self.BaseStage:GetDifficultyIsOpen(selectDiffIndex) then + local evolvableStage = self.BaseStage:GetEvolvableStageByDiffIndex(selectDiffIndex) + XUiManager.TipError(CsXTextManager.GetText("ReformEvolvableStageUnlockTip", evolvableStage:GetUnlockScore())) + self.EvolvableLevelBtnGroup:SelectIndex(self.CurEvolvableLevelBtnGroupIndex) + return + end + XDataCenter.ReformActivityManager.SetEvolableStageRedDotHistory(self.BaseStage:GetId(), selectDiffIndex) + self["Tab" .. index .. "RedPoint"].gameObject:SetActiveEx(false) + if self.CurEvolvableLevelBtnGroupIndex == index then + return + end + self.CurEvolvableLevelBtnGroupIndex = index + self.CurrentEvolvableStage = self.BaseStage:GetEvolvableStageByDiffIndex(selectDiffIndex) + -- 隐藏当前改造关卡没有的改造元素页签按钮 + local isExist = false + for groupType, btnGo in pairs(self.ElementBtnGroupDic) do + isExist = self.CurrentEvolvableStage:GetEvolvableGroupByType(groupType) ~= nil + btnGo.gameObject:SetActiveEx(isExist) + end + self.EvolvableElementBtnGroup:SelectIndex(self.CurrentEvolvableStage:GetDefaultFirstGroupType()) + self:RefreshChallengeScore() +end + +function XUiReformList:OnEvolvableElementBtnGroupClicked(index) + self:PlayAnimation("QieHuan") + self.CurrentElementBtnIndex = index + local childPanelData = self.ChildPanelInfoDic[index] + if childPanelData == nil then return end + -- 隐藏其他的子面板 + for key, data in pairs(self.ChildPanelInfoDic) do + data.uiParent.gameObject:SetActiveEx(key == index) + end + -- 加载子面板实体 + local instanceGo = childPanelData.instanceGo + if instanceGo == nil then + instanceGo = childPanelData.uiParent:LoadPrefab(childPanelData.assetPath) + childPanelData.instanceGo = instanceGo + end + -- 加载子面板代理 + local instanceProxy = childPanelData.instanceProxy + if instanceProxy == nil then + instanceProxy = childPanelData.proxy.New(instanceGo) + childPanelData.instanceProxy = instanceProxy + end + -- 设置子面板代理参数 + local proxyArgs = {} + if childPanelData.proxyArgs then + for _, argName in ipairs(childPanelData.proxyArgs) do + if type(argName) == "string" then + proxyArgs[#proxyArgs + 1] = self[argName] + else + proxyArgs[#proxyArgs + 1] = argName + end + end + end + instanceProxy:SetData(table.unpack(proxyArgs)) +end + +function XUiReformList:OnBtnSaveReformClicked() + XDataCenter.ReformActivityManager.ChageStageDiffRequest(self.BaseStage:GetId(), self.CurEvolvableLevelBtnGroupIndex + 1, function() + self.BaseStage:SetCurrentDiffIndex(self.CurEvolvableLevelBtnGroupIndex + 1) + self:Close() + XUiManager.TipMsg(CsXTextManager.GetText("ReformSaveEvolableStageTip", self.BaseStage:GetName(), self.CurrentEvolvableStage:GetName())) + end) +end + +-- evolvableGroupType : XReformConfigs.EvolvableGroupType +function XUiReformList:OnReformEvolvableGroupUpdate(evolvableGroupType, data) + if self.ChildPanelInfoDic[evolvableGroupType].instanceProxy then + self.ChildPanelInfoDic[evolvableGroupType].instanceProxy:RefreshEvolvableData(data) + end + self:RefreshChallengeScore() +end + +return XUiReformList diff --git a/Resources/Scripts/XUi/XUiReform/XUiReformMemberPanel.lua b/Resources/Scripts/XUi/XUiReform/XUiReformMemberPanel.lua new file mode 100644 index 00000000..a8bf0088 --- /dev/null +++ b/Resources/Scripts/XUi/XUiReform/XUiReformMemberPanel.lua @@ -0,0 +1,434 @@ +local CsXTextManager = CS.XTextManager + +--######################## XUiReformTargetGrid ######################## +local XUiReformTargetGrid = XClass(nil, "XUiReformTargetGrid") + +function XUiReformTargetGrid:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.Target = nil + self.Source = nil + self.BaseStage = nil + self.EvolvableStage = nil + self.TargetPanel = nil + self.BtnClick.CallBack = function() self:OnClicked() end +end + +-- target : XReformMemberTarget +function XUiReformTargetGrid:SetData(target, baseStage, evolvableStage, targetPanel, source) + self.Target = target + self.Source = source + self.BaseStage = baseStage + self.EvolvableStage = evolvableStage + self.TargetPanel = targetPanel + self.TxtName.text = target:GetLogName() + self.RImgIcon:SetRawImage(target:GetSmallHeadIcon()) + self.TxtStar.text = target:GetStarLevel() + self.TxtScore.text = target:GetScore() + self.PanelSelect.gameObject:SetActiveEx(target:GetIsActive()) +end + +function XUiReformTargetGrid:DynamicTouched(source) + local isActive = self.Target:GetIsActive() + if not isActive then + -- 准备激活,检查分数够不够扣 + local subScore = self.Target:GetScore() + if source:GetCurrentTarget() == nil and source:GetEntityType() == XReformConfigs.EntityType.Add then + subScore = subScore + source:GetScore() + end + -- 已经有目标了,把目标的分数减去 + subScore = subScore - source:GetTargetScore() + if subScore > self.EvolvableStage:GetChallengeScore() then + XUiManager.TipError(CsXTextManager.GetText("ReformScoreLimitTip")) + return + end + end + local replaceIdDic = XTool.Clone(self.EvolvableStage:GetMemberReplaceIdDic()) + if isActive then + replaceIdDic[self.Target:GetSourceId()] = 0 + else + replaceIdDic[source:GetId()] = self.Target:GetId() + end + local replaceIdData = {} + for sourceId, targetId in pairs(replaceIdDic) do + table.insert(replaceIdData, { + SourceId = sourceId, + TargetId = targetId, + }) + end + XDataCenter.ReformActivityManager.MemberReplaceRequest(self.BaseStage:GetId(), self.EvolvableStage:GetDifficulty() + , replaceIdData, function() + -- 取消激活并且是加号来源,直接关闭改造界面 + -- if isActive and source:GetEntityType() == XReformConfigs.EntityType.Add then + -- self.TargetPanel:Close() + -- end + local selectedIndex = self.TargetPanel.RootPanel:GetSourceIndex(source) + if source:GetEntityType() == XReformConfigs.EntityType.Add then + self.TargetPanel.RootPanel:OnSourceGridClicked(selectedIndex) + end + self.TargetPanel:Close() + self.TargetPanel.RootPanel:SetBtnCloseReformActive(false) + -- 激活,播放选中的格子动画 + if not isActive then + self.TargetPanel.RootPanel:PlaySourceGridRefreshAnim(selectedIndex) + end + end) +end + +function XUiReformTargetGrid:OnClicked() + local targets = self.Source:GetTargets() + local index = 1 + for i, v in ipairs(targets) do + if v == self.Target then + index = i + break + end + end + XLuaUiManager.Open("UiReformRoleList", targets, index) +end + +--######################## XUiReformTargetPanel ######################## +local XUiReformTargetPanel = XClass(nil, "XUiReformTargetPanel") + +function XUiReformTargetPanel:Ctor(ui, rootPanel) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.Source = nil + self.BaseStage = nil + self.EvolvableStage = nil + self.RootPanel = rootPanel + self:RegisterUiEvents() + -- 动态列表 + self.GridMember.gameObject:SetActiveEx(false) + self.DynamicTable = XDynamicTableNormal.New(self.PanelReformList) + self.DynamicTable:SetProxy(XUiReformTargetGrid) + self.DynamicTable:SetDelegate(self) +end + +function XUiReformTargetPanel:SetData(source, baseStage, evolvableStage) + self.Source = source + self.BaseStage = baseStage + self.EvolvableStage = evolvableStage + self:RefreshDynamicTable() +end + +function XUiReformTargetPanel:Refresh() + self:RefreshDynamicTable() +end + +function XUiReformTargetPanel:Open() + self.RootPanel.PanelReformEnable:Play() + self.GameObject:SetActiveEx(true) +end + +function XUiReformTargetPanel:Close() + self.RootPanel.PanelReformEnable:Stop() + self.GameObject:SetActiveEx(false) + self.RootPanel:SetScrollListControl(true) + self.RootPanel:SetSelectedGrid(nil) +end + +--######################## 私有方法 ######################## + +function XUiReformTargetPanel:RegisterUiEvents() + self.BtnClose.CallBack = function() self:Close() end +end + +function XUiReformTargetPanel:RefreshDynamicTable() + self.DynamicTable:SetDataSource(self.Source:GetTargets()) + self.DynamicTable:ReloadDataSync(1) +end + +function XUiReformTargetPanel:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:SetData(self.DynamicTable.DataSource[index] + , self.BaseStage, self.EvolvableStage, self, self.Source) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + grid:DynamicTouched(self.Source) + end +end + +--######################## XUiReformAddGrid ######################## +local XUiReformAddGrid = XClass(nil, "XUiReformAddGrid") + +function XUiReformAddGrid:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.Source = nil + self.EmptyPosCount = nil + self.SourcePanel = nil + self.Index = nil + self:RegisterUiEvents() +end + +function XUiReformAddGrid:SetData(data, index, sourcePanel) + self.Source = data.source + self.EmptyPosCount = data.emptyPosCount + self.SourcePanel = sourcePanel + self.Index = index + self.TxtCount.text = CsXTextManager.GetText("ReformMemberAddCountText", data.emptyPosCount) + self.TxtScore.text = data.source:GetScore() +end + +--######################## 私有方法 ######################## + +function XUiReformAddGrid:RegisterUiEvents() + self.BtnAdd.CallBack = function() self:OnBtnAddClicked() end +end + +function XUiReformAddGrid:OnBtnAddClicked() + self.SourcePanel:OpenTargetReformPanel(self.Source) + self.SourcePanel:OnSourceGridClicked(self.Index) +end + +--######################## XUiReformSourceGrid ######################## +local XUiReformSourceGrid = XClass(nil, "XUiReformSourceGrid") + +function XUiReformSourceGrid:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.Data = nil + self.SourcePanel = nil + self.Index = nil + self.UiGridAdd = XUiReformAddGrid.New(self.GridAdd) + self:RegisterUiEvents() +end + +function XUiReformSourceGrid:SetData(data, index, sourcePanel) + self.Data = data + self.Index = index + self.SourcePanel = sourcePanel + local isAdd = data.isAddEntity == true and true or false + self.GridAdd.gameObject:SetActiveEx(isAdd) + self.GridEntity.gameObject:SetActiveEx(not isAdd) + if isAdd then + self:SetAddData(data) + else + self:SetEntityData(data) + end +end + +function XUiReformSourceGrid:SetEntityData(source) + local score = 0 + if source:GetEntityType() == XReformConfigs.EntityType.Add then + self.Tab1.gameObject:SetActiveEx(source:GetIsActive()) + self.Tab2.gameObject:SetActiveEx(false) + score = score + source:GetScore() + else + self.Tab1.gameObject:SetActiveEx(false) + -- self.Tab2.gameObject:SetActiveEx(source:GetIsActive()) + self.Tab2.gameObject:SetActiveEx(false) + end + score = score + source:GetTargetScore() + self.TxtName.text = source:GetLogName() + self.RImgIcon:SetRawImage(source:GetBigHeadIcon()) + self.TxtStar.text = source:GetStarLevel() + self.TxtCost.text = score +end + +function XUiReformSourceGrid:SetAddData(data) + self.UiGridAdd:SetData(data, self.Index, self.SourcePanel) +end + +function XUiReformSourceGrid:SetSelectStatus(value) + self.PanelSelect.gameObject:SetActiveEx(value) +end + +function XUiReformSourceGrid:PlayRefreshAnim() + self.PlayableDirector:Play() +end + +--######################## 私有方法 ######################## + +function XUiReformSourceGrid:RegisterUiEvents() + self.BtnReform.CallBack = function() self:OnBtnReformClicked() end + self.BtnClick.CallBack = function() self:OnBtnClickClicked() end +end + +function XUiReformSourceGrid:OnBtnReformClicked() + -- 如果没有改造目标,不处理 + if #self.Data:GetTargets() <= 0 then + return + end + self.SourcePanel:OpenTargetReformPanel(self.Data) + self.SourcePanel:OnSourceGridClicked(self.Index) +end + +function XUiReformSourceGrid:OnBtnClickClicked() + local sources = self.SourcePanel:GetSources() + local index = 1 + for i, v in ipairs(sources) do + if v == self.Data then + index = i + break + end + end + -- 显示角色详情 + XLuaUiManager.Open("UiReformRoleList", sources, index) +end + +--######################## XUiReformMemberPanel ######################## +local XUiReformMemberPanel = XClass(nil, "XUiReformMemberPanel") + +function XUiReformMemberPanel:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.BaseStage = nil + self.EvolvableStage = nil + self.EvolvableGroup = nil + -- 动态列表 + self.GridMember.gameObject:SetActiveEx(false) + self.DynamicTable = XDynamicTableNormal.New(self.PanelMemberList) + self.DynamicTable:SetProxy(XUiReformSourceGrid) + self.DynamicTable:SetDelegate(self) + -- 改造面板 + self.UiReformTargetPanel = XUiReformTargetPanel.New(self.PanelReform, self) + self.TxtTip.text = CsXTextManager.GetText("ReformMemberPanelTopTip") + self.BtnCloseReform.gameObject:SetActiveEx(false) + self.TxtTip2.text = CsXTextManager.GetText("ReformMemberPanelTopEvolableTip") + self:RegisterUiEvents() +end + +function XUiReformMemberPanel:SetData(baseStage, evolvableStage) + self.BaseStage = baseStage + self.EvolvableStage = evolvableStage + self.EvolvableGroup = evolvableStage:GetEvolvableGroupByType(XReformConfigs.EvolvableGroupType.Member) + -- 刷新源列表 + self:RefreshDynamicTable() + self:CloseTargetReformPanel() +end + +function XUiReformMemberPanel:RefreshEvolvableData() + local sources = self:GetSourcesWithEntity() + local grids = self.DynamicTable:GetGrids() + if #self.DynamicTable.DataSource == #sources then + for i, v in ipairs(sources) do + if grids[i] then + grids[i]:SetData(sources[i], i, self) + end + end + self.DynamicTable:SetDataSource(sources) + else + self:RefreshDynamicTable(sources) + end + self.UiReformTargetPanel:Refresh() +end + +function XUiReformMemberPanel:OpenTargetReformPanel(source) + self.UiReformTargetPanel:Open() + self.UiReformTargetPanel:SetData(source, self.BaseStage, self.EvolvableStage) + self.BtnCloseReform.gameObject:SetActiveEx(true) +end + +function XUiReformMemberPanel:CloseTargetReformPanel() + self.UiReformTargetPanel:Close() + self.BtnCloseReform.gameObject:SetActiveEx(false) +end + +function XUiReformMemberPanel:SetBtnCloseReformActive(value) + self.BtnCloseReform.gameObject:SetActiveEx(value) +end + +function XUiReformMemberPanel:SetScrollListControl(value) + if value then + self.PanelMemberList.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Elastic + self.PanelMemberList.horizontal = true + else + self.PanelMemberList.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Unrestricted + self.PanelMemberList.horizontal = false + end +end + +--######################## 私有方法 ######################## + +function XUiReformMemberPanel:RegisterUiEvents() + self.BtnCloseReform.CallBack = function() self:OnBtnCloseReformClicked() end +end + +function XUiReformMemberPanel:OnBtnCloseReformClicked() + self:CloseTargetReformPanel() +end + +function XUiReformMemberPanel:RefreshDynamicTable(sources) + sources = sources or self:GetSourcesWithEntity() + self.DynamicTable:SetDataSource(sources) + self.DynamicTable:ReloadDataSync(1) +end + +function XUiReformMemberPanel:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:SetData(self.DynamicTable.DataSource[index], index, self) + end +end + +function XUiReformMemberPanel:GetSourcesWithEntity() + local entities, nextAddSource, emptyPosCount = self.EvolvableGroup:GetSourcesWithEntity() + if nextAddSource then + table.insert(entities, { + source = nextAddSource, + emptyPosCount = emptyPosCount, + isAddEntity = true, + -- 引导Id + Id = nextAddSource:GetId() + }) + end + return entities +end + +function XUiReformMemberPanel:GetSources() + return self.EvolvableGroup:GetSourcesWithEntity() +end + +function XUiReformMemberPanel:GetSourceIndex(source) + local sources = self:GetSources() + for i, v in ipairs(sources) do + if v == source then + return i + end + end + return #self.DynamicTable.DataSource - 1 +end + +function XUiReformMemberPanel:OnSourceGridClicked(index) + self:SetSelectedGrid(index) + self:ScrollGrid(index) +end + +function XUiReformMemberPanel:PlaySourceGridRefreshAnim(index) + local grid = self.DynamicTable:GetGrids()[index] + if not grid then return end + grid:PlayRefreshAnim() +end + +function XUiReformMemberPanel:SetSelectedGrid(index) + for i, grid in pairs(self.DynamicTable:GetGrids()) do + grid:SetSelectStatus(i == index) + end +end + +function XUiReformMemberPanel:ScrollGrid(index) + local grids = self.DynamicTable:GetGrids() + local grid = grids[index] + if not grid then + self.DynamicTable:ReloadDataSync(index) + return + end + self:SetScrollListControl(false) + local distance = (grid.Transform.localPosition + self.PanelMemberListContent.localPosition).x * -1 + if distance >= XReformConfigs.MinDistance and distance <= XReformConfigs.MaxDistance then return end + local targetPos = self.PanelMemberListContent.localPosition + if index == 1 then + targetPos.x = math.min(self.PanelMemberListContent.rect.width / 2 - self.PanelMemberListContent.parent.rect.width / 2) + - self.PanelMemberListContent.rect.width / 2 + else + targetPos.x = targetPos.x + distance - grid.Transform.rect.width / 2 - XReformConfigs.ScrollOffset + end + XUiHelper.DoMove(self.PanelMemberListContent, targetPos, XReformConfigs.ScrollTime, XUiHelper.EaseType.Sin) +end + +return XUiReformMemberPanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiReform/XUiReformNewRoomSingle.lua b/Resources/Scripts/XUi/XUiReform/XUiReformNewRoomSingle.lua new file mode 100644 index 00000000..7f281e11 --- /dev/null +++ b/Resources/Scripts/XUi/XUiReform/XUiReformNewRoomSingle.lua @@ -0,0 +1,157 @@ +local XUiReformNewRoomSingle = {} + +function XUiReformNewRoomSingle.InitEditBattleUi(uiNewRoomSingle) + uiNewRoomSingle.BtnTeamPrefab.gameObject:SetActiveEx(false) + uiNewRoomSingle.PanelCharacterLimit.gameObject:SetActiveEx(false) +end + +function XUiReformNewRoomSingle.GetBattleTeamData() + return XDataCenter.ReformActivityManager.GetFightTeam() +end + +-- 当点击角色模型时 +function XUiReformNewRoomSingle.HandleCharClick(uiNewRoomSingle, pos, stageId) + local baseStage = XDataCenter.ReformActivityManager.GetBaseStage(stageId) + local memberGroup = baseStage:GetCurrentEvolvableStageGroup(XReformConfigs.EvolvableGroupType.Member) + local teamData = baseStage:GetCurrentEvolvableStageTeamData() + local sources = memberGroup:GetAllCanJoinTeamSources() + local sourceInTeamDic = {} + local sourceInTeam = nil + local sourceIdWeightDic = {} + for index, sourceId in ipairs(teamData.SourceIdsInTeam) do + sourceInTeam = memberGroup:GetSourceById(sourceId) + if sourceInTeam then + sourceIdWeightDic[sourceId] = 100 + sourceInTeamDic[index] = sourceInTeam + end + end + -- 在队伍里的默认在前排 + table.sort(sources, function(sourceA, sourceB) + local aWeight = sourceIdWeightDic[sourceA:GetId()] or 1 + local bWeight = sourceIdWeightDic[sourceB:GetId()] or 1 + local aStarLevel = sourceA:GetStarLevel() + local bStarLevel = sourceB:GetStarLevel() + -- 不相等,说明在一个在队伍,一个在非队伍,队伍更大 + if aWeight ~= bWeight then + return aWeight > bWeight + else + if aStarLevel == bStarLevel then + return sourceA:GetId() < sourceB:GetId() + else + return aStarLevel > bStarLevel + end + end + end) + local characterTeamData = XTool.Clone(uiNewRoomSingle.CurTeam.TeamData) + XLuaUiManager.Open("UiReformTeamUp", sources, sourceInTeamDic, pos, function(source, isJoin) + if isJoin then + teamData.SourceIdsInTeam[pos] = source:GetId() + characterTeamData[pos] = XRobotManager.GetCharacterId(source:GetRobotId()) + else + for i, value in ipairs(teamData.SourceIdsInTeam) do + if value == source:GetId() then + teamData.SourceIdsInTeam[i] = 0 + characterTeamData[i] = 0 + break + end + end + end + baseStage:SaveCurrentEvolvableTeamData(teamData) + uiNewRoomSingle:UpdateTeam(characterTeamData) + end, function() + uiNewRoomSingle:UpdateTeam(characterTeamData) + end) +end + +function XUiReformNewRoomSingle.GetRealCharData(uiNewRoomSingle, stageId) + return XUiReformNewRoomSingle.GetRobotIds(stageId) +end + +function XUiReformNewRoomSingle.GetRobotIds(stageId) + local baseStage = XDataCenter.ReformActivityManager.GetBaseStage(stageId) + local memberGroup = baseStage:GetCurrentEvolvableStageGroup(XReformConfigs.EvolvableGroupType.Member) + local teamData = baseStage:GetCurrentEvolvableStageTeamData() + local result = {} + local source = nil + for _, sourceId in ipairs(teamData.SourceIdsInTeam) do + source = memberGroup:GetSourceById(sourceId) + if source then + table.insert(result, source:GetRobotId()) + else + table.insert(result, 0) + end + end + return result +end + +function XUiReformNewRoomSingle.CheckCanCharClick() + return true +end + +function XUiReformNewRoomSingle.GetIsHideSwitchFirstFightPosBtns() + return false +end + +function XUiReformNewRoomSingle.GetIsSaveTeamData() + return false +end + +function XUiReformNewRoomSingle.SwitchTeamPos(stageId, fromPos, toPos) + local baseStage = XDataCenter.ReformActivityManager.GetBaseStage(stageId) + local teamData = baseStage:GetCurrentEvolvableStageTeamData() + local fromId = teamData.SourceIdsInTeam[fromPos] + teamData.SourceIdsInTeam[fromPos] = teamData.SourceIdsInTeam[toPos] + teamData.SourceIdsInTeam[toPos] = fromId + baseStage:SaveCurrentEvolvableTeamData(teamData) +end + +function XUiReformNewRoomSingle.SetFirstFightPos(stageId, index) + local baseStage = XDataCenter.ReformActivityManager.GetBaseStage(stageId) + local teamData = baseStage:GetCurrentEvolvableStageTeamData() + teamData.FirstFightPos = index + baseStage:SaveCurrentEvolvableTeamData(teamData) +end + +function XUiReformNewRoomSingle.SetCaptainPos(stageId, index) + local baseStage = XDataCenter.ReformActivityManager.GetBaseStage(stageId) + local teamData = baseStage:GetCurrentEvolvableStageTeamData() + teamData.CaptainPos = index + baseStage:SaveCurrentEvolvableTeamData(teamData) +end + +function XUiReformNewRoomSingle.GetFirstFightPos(stageId) + local baseStage = XDataCenter.ReformActivityManager.GetBaseStage(stageId) + return baseStage:GetCurrentEvolvableStageTeamData().FirstFightPos +end + +function XUiReformNewRoomSingle.GetCaptainPos(stageId) + local baseStage = XDataCenter.ReformActivityManager.GetBaseStage(stageId) + return baseStage:GetCurrentEvolvableStageTeamData().CaptainPos +end + +function XUiReformNewRoomSingle.GetTeamCaptainId(stageId) + local baseStage = XDataCenter.ReformActivityManager.GetBaseStage(stageId) + local teamData = baseStage:GetCurrentEvolvableStageTeamData() + return teamData.SourceIdsInTeam[teamData.CaptainPos] +end + +function XUiReformNewRoomSingle.GetTeamFirstFightId(stageId) + local baseStage = XDataCenter.ReformActivityManager.GetBaseStage(stageId) + local teamData = baseStage:GetCurrentEvolvableStageTeamData() + return teamData.SourceIdsInTeam[teamData.FirstFightPos] +end + +function XUiReformNewRoomSingle.GetIsCheckCaptainIdAndFirstFightId(stageId) + return true +end + +function XUiReformNewRoomSingle.GetAutoCloseInfo() + local endTime = XDataCenter.ReformActivityManager.GetActivityEndTime() + return true, endTime, function(isClose) + if isClose then + XDataCenter.ReformActivityManager.HandleActivityEndTime() + end + end +end + +return XUiReformNewRoomSingle \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiReform/XUiReformPreview.lua b/Resources/Scripts/XUi/XUiReform/XUiReformPreview.lua new file mode 100644 index 00000000..826c8eef --- /dev/null +++ b/Resources/Scripts/XUi/XUiReform/XUiReformPreview.lua @@ -0,0 +1,140 @@ +local CsXTextManager = CS.XTextManager + +--######################## XUiReformPreviewGrid ######################## +local XUiReformPreviewGrid = XClass(nil, "XUiReformPreviewGrid") + +function XUiReformPreviewGrid:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + -- XReformEnemySource | XReformMemberSource + -- | XReformEnvironment | XReformBuff + self.Source = nil +end + +-- source : XReformEnemySource | XReformMemberSource +-- | XReformEnvironment | XReformBuff +function XUiReformPreviewGrid:SetData(source) + self.Source = source + local reformType = source:GetReformType() + if reformType == XReformConfigs.EvolvableGroupType.Buff then + self.TxtBuffLevel.text = source:GetStarLevel() + self.RImgBuffIcon:SetRawImage(source:GetIcon()) + -- self.BuffTag.gameObject:SetActiveEx(source:GetIsActive()) + self.BuffTag.gameObject:SetActiveEx(false) + elseif reformType == XReformConfigs.EvolvableGroupType.Environment then + self.ImgEnvIcon:SetSprite(source:GetPreviewIcon()) + -- self.EnvTag.gameObject:SetActiveEx(source:GetIsActive()) + self.EnvTag.gameObject:SetActiveEx(false) + self.TxtScene.text = source:GetPreviewText() + elseif reformType == XReformConfigs.EvolvableGroupType.Member then + self.TxtLevel.text = source:GetStarLevel() + self.RImgIcon:SetRawImage(source:GetIcon()) + self.Tag.gameObject:SetActiveEx(source:GetIsActive() and source:GetEntityType() == XReformConfigs.EntityType.Entity) + self.TagNew.gameObject:SetActiveEx(source:GetIsActive() and source:GetEntityType() == XReformConfigs.EntityType.Add) + elseif reformType == XReformConfigs.EvolvableGroupType.Enemy then + self.TxtLevel.text = source:GetShowLevel() + self.RImgIcon:SetRawImage(source:GetIcon()) + self.Tag.gameObject:SetActiveEx(source:GetIsActive() and source:GetEntityType() == XReformConfigs.EntityType.Entity) + self.TagNew.gameObject:SetActiveEx(source:GetIsActive() and source:GetEntityType() == XReformConfigs.EntityType.Add) + end + if self.GridBuff then + self.GridBuff.gameObject:SetActiveEx(reformType == XReformConfigs.EvolvableGroupType.Buff) + end + if self.GridScene then + self.GridScene.gameObject:SetActiveEx(reformType == XReformConfigs.EvolvableGroupType.Environment) + end +end + +--######################## XUiReformPreviewPanel ######################## +local XUiReformPreviewPanel = XClass(nil, "XUiReformPreviewPanel") + +function XUiReformPreviewPanel:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + -- XReformEnemySource | XReformMemberSource + -- | XReformEnvironment | XReformBuff + self.Sources = nil + XTool.InitUiObject(self) + self.DynamicTable = XDynamicTableNormal.New(self.DataList) + self.DynamicTable:SetProxy(XUiReformPreviewGrid) + self.DynamicTable:SetDelegate(self) +end + +-- sources : XReformEnemySource | XReformMemberSource +-- | XReformEnvironment | XReformBuff +function XUiReformPreviewPanel:SetData(sources, title) + self.TxtTitle.text = title + self.Sources = sources + self:RefreshDynamicTable() +end + +function XUiReformPreviewPanel:SetNoneTextActive(value) + if self.TxtNone then + self.TxtNone.gameObject:SetActiveEx(value) + end +end + +function XUiReformPreviewPanel:RefreshDynamicTable() + self.DynamicTable:SetDataSource(self.Sources) + self.DynamicTable:ReloadDataSync(1) +end + +function XUiReformPreviewPanel:OnDynamicTableEvent(event, index, grid) + local source = self.Sources[index] + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:SetData(source) + end +end + +--######################## XUiReformPreview ######################## +local XUiReformPreview = XLuaUiManager.Register(XLuaUi, "UiReformPreview") + +function XUiReformPreview:OnAwake() + -- XReformEvolvableStage + self.EvolvableStage = nil + self:RegisterUiEvents() + self.UiReformPreviewEnemyPanel = XUiReformPreviewPanel.New(self.PanelEnemy) + self.UiReformPreviewMemberPanel = XUiReformPreviewPanel.New(self.PanelChar) + self.UiReformPreviewEffectPanel = XUiReformPreviewPanel.New(self.PanelBuff) + XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem + , XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + -- 自动关闭 + local endTime = XDataCenter.ReformActivityManager.GetActivityEndTime() + self:SetAutoCloseInfo(endTime, function(isClose) + if isClose then + XDataCenter.ReformActivityManager.HandleActivityEndTime() + end + end) +end + +-- evolvableStage : XReformEvolvableStage +function XUiReformPreview:OnStart(evolvableStage) + self.EvolvableStage = evolvableStage + local enemyGroup = evolvableStage:GetEvolvableGroupByType(XReformConfigs.EvolvableGroupType.Enemy) + self.UiReformPreviewEnemyPanel:SetData(enemyGroup:GetSourcesWithEntity(false), CsXTextManager.GetText("ReformEvolvableEnemyNameText")) + local memberGroup = evolvableStage:GetEvolvableGroupByType(XReformConfigs.EvolvableGroupType.Member) + self.UiReformPreviewMemberPanel:SetData(memberGroup:GetSourcesWithEntity(false), CsXTextManager.GetText("ReformEvolvableMemberNameText")) + local envIds = evolvableStage:GetEnvIds() + local buffIds = evolvableStage:GetBuffIds() + local environmentGroup = evolvableStage:GetEvolvableGroupByType(XReformConfigs.EvolvableGroupType.Environment) + local buffGroup = evolvableStage:GetEvolvableGroupByType(XReformConfigs.EvolvableGroupType.Buff) + local effects = {} + for _, envId in ipairs(envIds) do + table.insert(effects, environmentGroup:GetEnvironmentById(envId)) + end + for _, buffId in ipairs(buffIds) do + table.insert(effects, buffGroup:GetBuffById(buffId)) + end + self.UiReformPreviewEffectPanel:SetData(effects, string.format("%s/%s", CsXTextManager.GetText("ReformEvolvableEnvNameText"), CsXTextManager.GetText("ReformEvolvableBuffNameText"))) + self.UiReformPreviewEffectPanel:SetNoneTextActive(#effects <= 0) +end + +--######################## 私有方法 ######################## + +function XUiReformPreview:RegisterUiEvents() + self.BtnBack.CallBack = function() self:Close() end + self.BtnMainUi.CallBack = function() XLuaUiManager.RunMain() end +end + +return XUiReformPreview \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiReform/XUiReformRoleList.lua b/Resources/Scripts/XUi/XUiReform/XUiReformRoleList.lua new file mode 100644 index 00000000..5bd351a2 --- /dev/null +++ b/Resources/Scripts/XUi/XUiReform/XUiReformRoleList.lua @@ -0,0 +1,198 @@ +--######################## XUiReformRoleGrid ######################## +local XUiReformRoleGrid = XClass(nil, "XUiReformRoleGrid") + +function XUiReformRoleGrid:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.Source = nil + self.ClickProxy = nil + self.ClickCallBack = nil + self.BtnClick.CallBack = function() self:OnBtnClicked() end +end + +-- source : MemberSource | MemberTarget +function XUiReformRoleGrid:SetData(source, isSelect) + self.Source = source + local characterViewModel = source:GetRobot():GetCharacterViewModel() + -- 头像 + self.RImgHeadIcon:SetRawImage(source:GetSmallHeadIcon()) + -- 战力 + self.TxtFight.text = characterViewModel:GetAbility() + -- 星级 + self.TxtLevel.text = source:GetStarLevel() + -- 元素列表 + local elementList = characterViewModel:GetObtainElements() + local rImg = nil + for i = 1, 3 do + rImg = self["RImgCharElement" .. i] + if elementList[i] then + rImg.gameObject:SetActiveEx(true) + rImg:SetRawImage(XCharacterConfigs.GetCharElement(elementList[i]).Icon) + else + rImg.gameObject:SetActiveEx(false) + end + end + self:SetSelectStatus(isSelect) +end + +function XUiReformRoleGrid:SetSelectStatus(value) + self.PanelSelected.gameObject:SetActiveEx(value) +end + +function XUiReformRoleGrid:SetSelectStatusBySource(source) + self.PanelSelected.gameObject:SetActiveEx(self.Source == source) +end + +function XUiReformRoleGrid:SetClickCallback(clickProxy, callback) + self.ClickProxy = clickProxy + self.ClickCallBack = callback +end + +function XUiReformRoleGrid:OnBtnClicked() + if self.ClickCallBack then + self.ClickCallBack(self.ClickProxy, self.Source) + end +end + +--######################## XUiReformRoleList ######################## +local XUiReformCharacterInfo = require("XUi/XUiReform/XUiReformCharacterInfo") +local XUiReformRoleList = XLuaUiManager.Register(XLuaUi, "UiReformRoleList") + +function XUiReformRoleList:OnAwake() + self.Sources = nil + self.CurrentSource = nil + self:RegisterUiEvents() + self.UiRoleGrids = {} + self.GridCharacter.gameObject:SetActiveEx(false) + -- 模型相关 + local root = self.UiModelGo.transform + local panelRoleModel = root:FindTransform("PanelRoleModel") + -- XCharacterConfigs.XUiCharacter_Camera.MAIN + self.CameraFar = { + root:FindTransform("UiCamFarLv"), + root:FindTransform("UiCamFarGrade"), + root:FindTransform("UiCamFarQuality"), + root:FindTransform("UiCamFarSkill"), + root:FindTransform("UiCamFarrExchange"), + } + self.CameraNear = { + root:FindTransform("UiCamNearLv"), + root:FindTransform("UiCamNearGrade"), + root:FindTransform("UiCamNearQuality"), + root:FindTransform("UiCamNearSkill"), + root:FindTransform("UiCamNearrExchange"), + } + self.ImgEffectHuanren = root:FindTransform("ImgEffectHuanren") + self.UiPanelRoleModel = XUiPanelRoleModel.New(panelRoleModel, self.Name, nil, true, nil, true) + -- 资源 + XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem + , XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + -- 基础信息面板 + self.UiReformCharacterInfo = self:FindChildUiObj("UiReformCharacterInfo") + self.UiReformCharacterDetailInfo = self:FindChildUiObj("UiReformCharacterDetailInfo") + -- 自动关闭 + local endTime = XDataCenter.ReformActivityManager.GetActivityEndTime() + self:SetAutoCloseInfo(endTime, function(isClose) + if isClose then + XDataCenter.ReformActivityManager.HandleActivityEndTime() + end + end) +end + +function XUiReformRoleList:OnStart(sources, index) + self.Sources = sources + self.CurrentSource = sources[index] + -- 刷新模型 + self:RefreshModel() + -- 刷新列表 + self:RefreshRoleList() + self:OpenUiReformCharacterInfo() +end + +--######################## 私有方法 ######################## + +function XUiReformRoleList:RegisterUiEvents() + self.BtnBack.CallBack = function() self:OnBtnBackClicked() end + self.BtnMainUi.CallBack = function() XLuaUiManager.RunMain() end + self:BindHelpBtn(self.BtnHelp, XDataCenter.ReformActivityManager.GetHelpName()) +end + +function XUiReformRoleList:OnBtnBackClicked() + if XLuaUiManager.IsUiShow("UiReformCharacterDetailInfo") then + self:CloseChildUi("UiReformCharacterDetailInfo") + self:OpenUiReformCharacterInfo() + return + end + self:Close() +end + +function XUiReformRoleList:RefreshRoleList() + local go = nil + local grid = nil + for index, source in ipairs(self.Sources) do + go = CS.UnityEngine.Object.Instantiate(self.GridCharacter, self.PanelRoleContent) + go.gameObject:SetActiveEx(true) + grid = XUiReformRoleGrid.New(go) + grid:SetData(source, source == self.CurrentSource) + grid:SetClickCallback(self, self.OnRoleGridClicked) + self.UiRoleGrids[index] = grid + end +end + +function XUiReformRoleList:OnRoleGridClicked(source) + self.CurrentSource = source + self:RefreshModel() + self:OpenUiReformCharacterInfo() + -- 刷新选中状态 + for _, grid in ipairs(self.UiRoleGrids) do + grid:SetSelectStatusBySource(source) + end +end + +function XUiReformRoleList:RefreshModel() + local robotId = self.CurrentSource:GetRobotId() + local robotCfg = XRobotManager.GetRobotTemplate(robotId) + local characterId = XRobotManager.GetCharacterId(robotId) + self.ImgEffectHuanren.gameObject:SetActiveEx(false) + self.UiPanelRoleModel:UpdateRobotModel(robotId, characterId, nil + , robotCfg.FashionId, robotCfg.WeaponId, function(model) + self.PanelDrag.Target = model.transform + self.ImgEffectHuanren.gameObject:SetActiveEx(true) + end) +end + +function XUiReformRoleList:RefreshBaseInfo() + self.UiReformCharacterInfo:Open() + self.UiReformCharacterInfo:SetData(self.CurrentSource) +end + +function XUiReformRoleList:OpenUiReformCharacterInfo() + self:OpenOneChildUi("UiReformCharacterInfo", self) + self.SViewCharacterList.gameObject:SetActiveEx(true) + self.UiReformCharacterInfo:Open() + self.UiReformCharacterInfo:SetData(self.CurrentSource) + self:SetCameraType(0) +end + +function XUiReformRoleList:OpenUiReformCharacterDetailInfo() + -- 隐藏左边的列表 + self.SViewCharacterList.gameObject:SetActiveEx(false) + -- 隐藏基本信息面板 + self.UiReformCharacterInfo:Close() + -- 打开属性信息面板 + self:OpenOneChildUi("UiReformCharacterDetailInfo", self) + self.UiReformCharacterDetailInfo:SetData(self.CurrentSource) + self:SetCameraType(1) +end + +function XUiReformRoleList:SetCameraType(index) + for k, _ in pairs(self.CameraFar) do + self.CameraFar[k].gameObject:SetActiveEx(k == index) + end + for k, _ in pairs(self.CameraNear) do + self.CameraNear[k].gameObject:SetActiveEx(k == index) + end +end + +return XUiReformRoleList \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiReform/XUiReformTeamUp.lua b/Resources/Scripts/XUi/XUiReform/XUiReformTeamUp.lua new file mode 100644 index 00000000..8568177b --- /dev/null +++ b/Resources/Scripts/XUi/XUiReform/XUiReformTeamUp.lua @@ -0,0 +1,172 @@ +--######################## XUiReformTeamUp ######################## +local UiReformTeamMemberGrid = XClass(nil, "UiReformTeamMemberGrid") + +function UiReformTeamMemberGrid:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.Source = nil +end + +function UiReformTeamMemberGrid:SetData(source, inTeam, isSelected) + self.Source = source + self.ImgInTeam.gameObject:SetActiveEx(inTeam) + local characterViewModel = source:GetRobot():GetCharacterViewModel() + -- 头像 + self.RImgHeadIcon:SetRawImage(source:GetSmallHeadIcon()) + -- 战力 + self.TxtFight.text = characterViewModel:GetAbility() + -- 星级 + self.TxtLevel.text = source:GetStarLevel() + -- 元素列表 + local elementList = characterViewModel:GetObtainElements() + local rImg = nil + for i = 1, 3 do + rImg = self["RImgCharElement" .. i] + if elementList[i] then + rImg.gameObject:SetActiveEx(true) + rImg:SetRawImage(XCharacterConfigs.GetCharElement(elementList[i]).Icon) + else + rImg.gameObject:SetActiveEx(false) + end + end + -- 设置选中 + self:SetSelectStatus(isSelected) +end + +function UiReformTeamMemberGrid:SetSelectStatus(value) + self.PanelSelected.gameObject:SetActiveEx(value) +end + +--######################## XUiReformTeamUp ######################## +local XUiReformTeamUp = XLuaUiManager.Register(XLuaUi, "UiReformTeamUp") + +function XUiReformTeamUp:OnAwake() + self:RegisterUiEvents() + self.Sources = nil + self.SourceInTeamDic = nil + self.CurrentTeamPos = nil + self.CurrentSelectedSource = nil + self.JoinCallback = nil + self.CloseCallback = nil + -- 成员列表 + self.GridCharacter.gameObject:SetActiveEx(false) + self.DynamicTable = XDynamicTableNormal.New(self.SViewCharacterList) + self.DynamicTable:SetProxy(UiReformTeamMemberGrid) + self.DynamicTable:SetDelegate(self) + -- 模型初始化 + local panelRoleModel = self.UiModelGo.transform:FindTransform("PanelRoleModel") + self.ImgEffectHuanren = self.UiModelGo.transform:FindTransform("ImgEffectHuanren") + self.ImgEffectHuanren1 = self.UiModelGo.transform:FindTransform("ImgEffectHuanren1") + self.ImgEffectHuanren1.gameObject:SetActiveEx(false) + self.UiPanelRoleModel = XUiPanelRoleModel.New(panelRoleModel, self.Name, nil, true) + -- 资源 + XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem + , XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + -- 自动关闭 + local endTime = XDataCenter.ReformActivityManager.GetActivityEndTime() + self:SetAutoCloseInfo(endTime, function(isClose) + if isClose then + XDataCenter.ReformActivityManager.HandleActivityEndTime() + end + end) +end + +function XUiReformTeamUp:OnStart(sources, sourceInTeamDic, pos, joinCallback, closeCallback) + self.Sources = sources + self.SourceInTeamDic = sourceInTeamDic + self.CurrentTeamPos = pos + self.CurrentSelectedSource = sourceInTeamDic[pos] + self.JoinCallback = joinCallback + self.CloseCallback = closeCallback + local isInTeam = true + if self.CurrentSelectedSource == nil then + for _, source in pairs(sourceInTeamDic) do + if source then + self.CurrentSelectedSource = source + break + end + end + end + if self.CurrentSelectedSource == nil then + self.CurrentSelectedSource = sources[1] + isInTeam = false + end + self.BtnJoinTeam.gameObject:SetActiveEx(not isInTeam) + self.BtnQuitTeam.gameObject:SetActiveEx(isInTeam) + -- 刷新可选择列表 + self:RefreshDynamicTable() + self:RefreshModel() +end + +--######################## 私有方法 ######################## + +function XUiReformTeamUp:RegisterUiEvents() + self.BtnBack.CallBack = function() self:OnBtnBackClicked() end + self.BtnMainUi.CallBack = function() XLuaUiManager.RunMain() end + self.BtnJoinTeam.CallBack = function() self:OnBtnJoinTeamClicked() end + self.BtnQuitTeam.CallBack = function() self:OnBtnQuitTeamClicked() end +end + +function XUiReformTeamUp:OnBtnBackClicked() + if self.CloseCallback then + self.CloseCallback() + end + self:Close() +end + +function XUiReformTeamUp:OnBtnJoinTeamClicked() + if self.JoinCallback then + self.JoinCallback(self.CurrentSelectedSource, true) + end + self:Close() +end + +function XUiReformTeamUp:OnBtnQuitTeamClicked() + if self.JoinCallback then + self.JoinCallback(self.CurrentSelectedSource, false) + end + self:Close() +end + +function XUiReformTeamUp:RefreshDynamicTable() + self.DynamicTable:SetDataSource(self.Sources) + self.DynamicTable:ReloadDataSync(1) +end + +function XUiReformTeamUp:OnDynamicTableEvent(event, index, grid) + local source = self.Sources[index] + local isInTeam = self:GetSourceIsInTeam(source) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:SetData(source, isInTeam, source == self.CurrentSelectedSource) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + self.CurrentSelectedSource = source + self:RefreshDynamicTable() + self.BtnJoinTeam.gameObject:SetActiveEx(not isInTeam) + self.BtnQuitTeam.gameObject:SetActiveEx(isInTeam) + self:RefreshModel() + end +end + +function XUiReformTeamUp:GetSourceIsInTeam(source) + for _, data in pairs(self.SourceInTeamDic) do + if data == source then + return true + end + end + return false +end + +function XUiReformTeamUp:RefreshModel() + local robotId = self.CurrentSelectedSource:GetRobotId() + local robotCfg = XRobotManager.GetRobotTemplate(robotId) + local characterId = XRobotManager.GetCharacterId(robotId) + self.ImgEffectHuanren.gameObject:SetActiveEx(false) + self.UiPanelRoleModel:UpdateRobotModel(robotId, characterId, nil + , robotCfg.FashionId, robotCfg.WeaponId, function(model) + self.PanelDrag.Target = model.transform + self.ImgEffectHuanren.gameObject:SetActiveEx(true) + end) +end + +return XUiReformTeamUp \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRegister/XUiGridAccount.lua b/Resources/Scripts/XUi/XUiRegister/XUiGridAccount.lua new file mode 100644 index 00000000..30f7d4a8 --- /dev/null +++ b/Resources/Scripts/XUi/XUiRegister/XUiGridAccount.lua @@ -0,0 +1,22 @@ +local XUiGridAccount = XClass(nil, "XUiGridAccount") + +function XUiGridAccount:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiGridAccount:Init(uiRoot) + self.UiRoot = uiRoot +end + +function XUiGridAccount:Refresh(data) + if not data then return end + self.Data = data + self.BtnAccount:SetNameByGroup(0, data.Name) + --local timeStr = XTime.TimestampToLocalDateTimeString(data.Time, "yyyy/MM/dd HH:mm") + local timeStr = XUiHelper.CalcLatelyLoginTime(data.Time, os.time()) + self.BtnAccount:SetNameByGroup(1, timeStr) +end + +return XUiGridAccount \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRegister/XUiRegister.lua b/Resources/Scripts/XUi/XUiRegister/XUiRegister.lua new file mode 100644 index 00000000..6e129f8d --- /dev/null +++ b/Resources/Scripts/XUi/XUiRegister/XUiRegister.lua @@ -0,0 +1,74 @@ +local XUiRegister = XLuaUiManager.Register(XLuaUi, "UiRegister") +local XUiGridAccount = require("XUi/XUiRegister/XUiGridAccount") + +function XUiRegister:OnAwake() + self:InitAutoScript() +end + +function XUiRegister:OnStart(loginCb) + self.LoginCb = loginCb + self.InFUserId.text = XUserManager.UserId or "" + self.PanelRegister.gameObject:SetActive(true) + + self.DynamicTable = XDynamicTableNormal.New(self.PanelAccountHistory) + self.DynamicTable:SetProxy(XUiGridAccount) + self.DynamicTable:SetDelegate(self) + + self.AccountList = XHaruUserManager.GetAccountList() + self.DynamicTable:SetDataSource(self.AccountList) + self.DynamicTable:ReloadDataSync() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiRegister:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiRegister:AutoInitUi() + self.PanelRegister = self.Transform:Find("SafeAreaContentPane/PanelRegister") + self.InFUserId.contentType = CS.UnityEngine.UI.InputField.ContentType.Standard +end + +function XUiRegister:AutoAddListener() + self:RegisterClickEvent(self.BtnSignIn, self.OnBtnSignInClick) + self:RegisterClickEvent(self.BtnCancel, self.OnBtnCancelClick) +end +-- auto + +function XUiRegister:OnBtnSignInClick() + local userIdText = self.InFUserId.text + + if not userIdText or #self.InFUserId.text == 0 then + XUiManager.TipText("LoginPhoneEmpty") + return + end + + self:OnSignIn(userIdText) +end + +function XUiRegister:OnBtnCancelClick() + self:Close() +end + +function XUiRegister:OnSignIn(userId) + XHaruUserManager.SignIn(userId, function() + if self.LoginCb then + self.LoginCb() + end + + self:Close() + end) +end + +--动态列表事件 +function XUiRegister:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:Refresh(self.AccountList[index]) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + self:OnSignIn(self.AccountList[index].Name) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRegression/XUiGridRegressionTaskSchedule.lua b/Resources/Scripts/XUi/XUiRegression/XUiGridRegressionTaskSchedule.lua new file mode 100644 index 00000000..5197b906 --- /dev/null +++ b/Resources/Scripts/XUi/XUiRegression/XUiGridRegressionTaskSchedule.lua @@ -0,0 +1,56 @@ +-- +-- Author: wujie +-- Note: 回归任务活跃奖励格子相关 + +local XUiGridRegressionTaskSchedule = XClass(nil, "XUiGridRegressionTaskSchedule") + +function XUiGridRegressionTaskSchedule:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + self.GridCommon = XUiGridCommon.New(self.PanelGridCommon) + self.BtnReward.CallBack = function() self:OnBtnRewardClick() end +end + +function XUiGridRegressionTaskSchedule:InitRootUi(rootUi) + self.GridCommon:Init(rootUi) +end + +function XUiGridRegressionTaskSchedule:Refresh(rewardData) + self.Data = rewardData + self.TxtValue.text = rewardData.Schedule + local rewardList = XRewardManager.GetRewardList(rewardData.RewardId) + local firstRewardIndex = 1 + local reward = rewardList[firstRewardIndex] + if not reward then + XLog.ErrorTableDataNotFound("XUiGridRegressionTaskSchedule:Refresh", + "reward", "Share/Reward/Reward.tab", "rewardData.Id", tostring(rewardData.Id)) + return + end + self.GridCommon:Refresh(reward) + self:UpdateGetStatus() +end + +function XUiGridRegressionTaskSchedule:UpdateGetStatus() + if not self.Data then return end + local isHaveGet = XDataCenter.RegressionManager.IsTaskScheduleRewardHaveGet(self.Data.Id) + local isCanGet = XDataCenter.RegressionManager.IsTaskScheduleRewardCanGet(self.Data.Id) + self.BtnReward.gameObject:SetActiveEx(isHaveGet or isCanGet) + self.ImgGet.gameObject:SetActiveEx(isHaveGet) + self.PanelEffect.gameObject:SetActiveEx(isCanGet) +end + +function XUiGridRegressionTaskSchedule:OnBtnRewardClick() + if not self.Data then return end + local scheduleRewardId = self.Data.Id + if XDataCenter.RegressionManager.IsTaskScheduleRewardHaveGet(scheduleRewardId) then + XUiManager.TipError(CS.XTextManager.GetText("RegressionTaskScheduleRewardHaveGet")) + elseif XDataCenter.RegressionManager.IsTaskScheduleRewardCanGet(scheduleRewardId) then + XDataCenter.RegressionManager.RequestGetRegressionScheduleReward(scheduleRewardId, function () + self:UpdateGetStatus() + end) + end +end + +return XUiGridRegressionTaskSchedule \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRegression/XUiPanelRegressionTaskCourse.lua b/Resources/Scripts/XUi/XUiRegression/XUiPanelRegressionTaskCourse.lua new file mode 100644 index 00000000..55d58f59 --- /dev/null +++ b/Resources/Scripts/XUi/XUiRegression/XUiPanelRegressionTaskCourse.lua @@ -0,0 +1,42 @@ +-- +--Author: wujie +--Note: 回归活动历程任务动态表 + +local XUiPanelRegressionTaskCourse = XClass(nil, "XUiPanelRegressionTaskCourse") + +function XUiPanelRegressionTaskCourse:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self:InitDynamicTable() +end + +function XUiPanelRegressionTaskCourse:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.GameObject) + self.DynamicTable:SetProxy(XDynamicDailyTask) + self.DynamicTable:SetDelegate(self) +end + +function XUiPanelRegressionTaskCourse:InitRootUi(rootUi) + self.RootUi = rootUi +end + +function XUiPanelRegressionTaskCourse:UpdateDynamicTable(taskList) + self.DynamicTableDataList = taskList + self.DynamicTable:SetDataSource(self.DynamicTableDataList) + self.DynamicTable:ReloadDataASync(#self.DynamicTableDataList > 0 and 1 or -1) +end + + +--事件相关------------------------------------>>> +function XUiPanelRegressionTaskCourse:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid.RootUi = self.RootUi + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.DynamicTableDataList[index] + grid:ResetData(data) + end +end + +--事件相关------------------------------------<<< + +return XUiPanelRegressionTaskCourse \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRegression/XUiPanelRegressionTaskDay.lua b/Resources/Scripts/XUi/XUiRegression/XUiPanelRegressionTaskDay.lua new file mode 100644 index 00000000..799e7006 --- /dev/null +++ b/Resources/Scripts/XUi/XUiRegression/XUiPanelRegressionTaskDay.lua @@ -0,0 +1,42 @@ +-- +--Author: wujie +--Note: 回归活动每日任务动态表 + +local XUiPanelRegressionTaskDay = XClass(nil, "XUiPanelRegressionTaskDay") + +function XUiPanelRegressionTaskDay:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self:InitDynamicTable() +end + +function XUiPanelRegressionTaskDay:InitRootUi(rootUi) + self.RootUi = rootUi +end + +function XUiPanelRegressionTaskDay:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.GameObject) + self.DynamicTable:SetProxy(XDynamicDailyTask) + self.DynamicTable:SetDelegate(self) +end + +function XUiPanelRegressionTaskDay:UpdateDynamicTable(taskList) + self.DynamicTableDataList = taskList + self.DynamicTable:SetDataSource(self.DynamicTableDataList) + self.DynamicTable:ReloadDataASync(#self.DynamicTableDataList > 0 and 1 or -1) +end + + +--事件相关------------------------------------>>> +function XUiPanelRegressionTaskDay:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid.RootUi = self.RootUi + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.DynamicTableDataList[index] + grid:ResetData(data) + end +end + +--事件相关------------------------------------<<< + +return XUiPanelRegressionTaskDay \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRegression/XUiPanelRegressionTaskWeek.lua b/Resources/Scripts/XUi/XUiRegression/XUiPanelRegressionTaskWeek.lua new file mode 100644 index 00000000..34db8594 --- /dev/null +++ b/Resources/Scripts/XUi/XUiRegression/XUiPanelRegressionTaskWeek.lua @@ -0,0 +1,41 @@ +-- +--Author: wujie +--Note:回归活动每周任务动态表 + +local XUiPanelRegressionTaskWeek = XClass(nil, "XUiPanelRegressionTaskWeek") + +function XUiPanelRegressionTaskWeek:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self:InitDynamicTable() +end + +function XUiPanelRegressionTaskWeek:InitRootUi(rootUi) + self.RootUi = rootUi +end + +function XUiPanelRegressionTaskWeek:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.GameObject) + self.DynamicTable:SetProxy(XDynamicDailyTask) + self.DynamicTable:SetDelegate(self) +end + +function XUiPanelRegressionTaskWeek:UpdateDynamicTable(taskList) + self.DynamicTableDataList = taskList + self.DynamicTable:SetDataSource(self.DynamicTableDataList) + self.DynamicTable:ReloadDataASync(#self.DynamicTableDataList > 0 and 1 or -1) +end + +--事件相关------------------------------------>>> +function XUiPanelRegressionTaskWeek:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid.RootUi = self.RootUi + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.DynamicTableDataList[index] + grid:ResetData(data) + end +end + +--事件相关------------------------------------<<< + +return XUiPanelRegressionTaskWeek \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRegression/XUiRegression.lua b/Resources/Scripts/XUi/XUiRegression/XUiRegression.lua new file mode 100644 index 00000000..6ebb564c --- /dev/null +++ b/Resources/Scripts/XUi/XUiRegression/XUiRegression.lua @@ -0,0 +1,108 @@ +-- +--Author: wujie +--Note: 回归活动主界面 + +local UiRegression = XLuaUiManager.Register(XLuaUi, "UiRegression") + +function UiRegression:OnAwake() + XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + + self.BtnIndexToTypeDic = {} + + self:InitTabBtnGroup() + self:AutoAddListener() + XEventManager.AddEventListener(XEventId.EVENT_REGRESSION_OPEN_STATUS_UPDATE,self.OnOpenStatusUpdate, self) +end + +function UiRegression:OnStart() + if not XDataCenter.RegressionManager.IsHaveOneRegressionActivityOpen() then + self:Close() + return + end + + XDataCenter.RegressionManager.HandlePlayStory(true) + self.BtnReview.gameObject:SetActiveEx(XDataCenter.RegressionManager.IsShowActivityViewStoryBtn()) + + for _, type in pairs(XRegressionConfigs.MainViewShowedTypeList) do + if XDataCenter.RegressionManager.IsRegressionActivityOpen(type) then + table.insert(self.BtnIndexToTypeDic, type) + end + end + local showedTabBtnCount = #self.BtnIndexToTypeDic + + local activityType + for i, btn in ipairs(self.BtnTabList) do + if i > showedTabBtnCount then + btn.gameObject:SetActiveEx(false) + else + btn.gameObject:SetActiveEx(true) + activityType = self.BtnIndexToTypeDic[i] + btn:SetName(XRegressionConfigs.ActivityTypeToTabText[activityType]) + XRedPointManager.AddRedPointEvent( + btn.ReddotObj, + nil, + self, + {XRegressionConfigs.ActivityTypeToRedPointCondition[activityType]} + ) + end + end + + if showedTabBtnCount > 0 then + local firstBtnIndex = 1 + self.TabBtnGroup:SelectIndex(firstBtnIndex) + end +end + +function UiRegression:InitTabBtnGroup() + self.BtnTabList = { + self.BtnTab1, + self.BtnTab2 + } + self.TabBtnGroup:Init(self.BtnTabList, function(index) self:OnTabBtnGroupClick(index) end) +end + +function UiRegression:AutoAddListener() + self.BtnBack.CallBack = function() self:Close() end + self.BtnMainUi.CallBack = function() XLuaUiManager.RunMain() end + self.BtnReview.CallBack = function() self:OnBtnReviewClick() end + self.BtnHelp.CallBack = function() self:OnBtnHelpClick() end + self:BindHelpBtnOnly(self.BtnHelp) +end + +--事件相关------------------------------------>>> +function UiRegression:OnTabBtnGroupClick(index) + if self.SelectTabBtnIndex == index then return end + self.SelectTabBtnIndex = index + if index == XRegressionConfigs.ActivitySubType.Task then + self:OpenOneChildUi("UiRegressionTask", self) + local activityId = XDataCenter.RegressionManager.GetTaskActivityId() + local activityTemplate = XRegressionConfigs.GetActivityTemplateByActivityId(activityId) + local helpId = activityTemplate.HelpId + self.BtnHelp.gameObject:SetActiveEx(helpId ~= nil) + end +end + +function UiRegression:OnBtnReviewClick() + XDataCenter.RegressionManager.HandlePlayStory() +end + +function UiRegression:OnBtnHelpClick() + if self.SelectTabBtnIndex == XRegressionConfigs.ActivitySubType.Task then + local activityId = XDataCenter.RegressionManager.GetTaskActivityId() + local activityTemplate = XRegressionConfigs.GetActivityTemplateByActivityId(activityId) + local helpId = activityTemplate.HelpId + local helpCourseTemplate = XHelpCourseConfig.GetHelpCourseTemplateById(helpId) + XUiManager.ShowHelpTip(helpCourseTemplate.Function) + end +end + +function UiRegression:OnOpenStatusUpdate() + if not XDataCenter.RegressionManager.IsHaveOneRegressionActivityOpen() then + if CS.XFight.IsRunning or XLuaUiManager.IsUiLoad("UiLoading") then + return + end + XUiManager.TipText("RegressionActivityOver") + XLuaUiManager.RunMain() + end +end +--事件相关------------------------------------<<< \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRegression/XUiRegressionTask.lua b/Resources/Scripts/XUi/XUiRegression/XUiRegressionTask.lua new file mode 100644 index 00000000..b4d9b8e1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiRegression/XUiRegressionTask.lua @@ -0,0 +1,181 @@ +-- +--Author: wujie +--Note: 回归活动子界面-任务界面 + +local XUiRegressionTask = XLuaUiManager.Register(XLuaUi, "UiRegressionTask") + +local XUiGridRegressionTaskSchedule = require("XUi/XUiRegression/XUiGridRegressionTaskSchedule") + +local XUiPanelRegressionTaskCourse = require("XUi/XUiRegression/XUiPanelRegressionTaskCourse") +local XUiPanelRegressionTaskDay = require("XUi/XUiRegression/XUiPanelRegressionTaskDay") +local XUiPanelRegressionTaskWeek = require("XUi/XUiRegression/XUiPanelRegressionTaskWeek") + +local AnimTime = CS.XGame.ClientConfig:GetInt("RegressionTaskScheduleProgressAnimTime") + +function XUiRegressionTask:OnAwake() + self:InitTabBtnGroup() + self.PanelList = { + XUiPanelRegressionTaskCourse.New(self.PanelDynamicTableCourse), + XUiPanelRegressionTaskDay.New(self.PanelDynamicTableDay), + XUiPanelRegressionTaskWeek.New(self.PanelDynamicTableWeek), + } + + self.GridScheduleList = { + XUiGridRegressionTaskSchedule.New(self.GridSchedule1), + XUiGridRegressionTaskSchedule.New(self.GridSchedule2), + XUiGridRegressionTaskSchedule.New(self.GridSchedule3), + XUiGridRegressionTaskSchedule.New(self.GridSchedule4), + XUiGridRegressionTaskSchedule.New(self.GridSchedule5), + } + + XEventManager.AddEventListener(XEventId.EVENT_TASK_SYNC, self.OnEventTaskSync, self) + XEventManager.AddEventListener(XEventId.EVENT_REGRESSION_TASK_SCHEDULE_UPDATE, self.OnEventScheduleUpdate, self) + + XRedPointManager.AddRedPointEvent( + self.BtnTabCourse.ReddotObj, + nil, + self, + {XRedPointConditions.Types.CONDITION_REGRESSION_TASK_TYPE}, + XRegressionConfigs.TaskType.Course + ) + XRedPointManager.AddRedPointEvent( + self.BtnTabDay.ReddotObj, + nil, + self, + {XRedPointConditions.Types.CONDITION_REGRESSION_TASK_TYPE}, + XRegressionConfigs.TaskType.Day + ) + XRedPointManager.AddRedPointEvent( + self.BtnTabWeek.ReddotObj, + nil, + self, + {XRedPointConditions.Types.CONDITION_REGRESSION_TASK_TYPE}, + XRegressionConfigs.TaskType.Week + ) +end + +function XUiRegressionTask:OnStart(parent) + self:UpdateHeadContent() + + for _, grid in ipairs(self.GridScheduleList) do + grid:InitRootUi(parent) + end + + for _, panel in ipairs(self.PanelList) do + panel:InitRootUi(parent) + end + + local firstBtnIndex = 1 + self.TabBtnGroup:SelectIndex(firstBtnIndex) +end + +function XUiRegressionTask:OnEnable() + self:UpdateScheduleRewardList() + self:UpdateProgress() + if self.IsNeedRefreshDynamicTable then + if self.SelectTabBtnIndex then + self:UpdateDynamicTableByIndex(self.SelectTabBtnIndex) + end + self.IsNeedRefreshDynamicTable = false + end +end + +function XUiRegressionTask:OnDestroy() + XEventManager.RemoveEventListener(XEventId.EVENT_TASK_SYNC, self.OnEventTaskSync, self) + XEventManager.RemoveEventListener(XEventId.EVENT_REGRESSION_TASK_SCHEDULE_UPDATE, self.OnEventScheduleUpdate, self) +end + +function XUiRegressionTask:InitTabBtnGroup() + self.BtnTabList = { + self.BtnTabCourse, + self.BtnTabDay, + self.BtnTabWeek, + } + self.TabBtnGroup:Init(self.BtnTabList, function(index) self:OnTabBtnGroupClick(index) end) +end + +function XUiRegressionTask:UpdateHeadContent() + local startTimeStamp = XDataCenter.RegressionManager.GetTaskStartTime() + local endTimeStamp = XDataCenter.RegressionManager.GetTaskEndTime() + if startTimeStamp and endTimeStamp then + local format = "yyyy-MM-dd HH:mm" + self.TxtTimeStart.text = XTime.TimestampToGameDateTimeString(startTimeStamp, format) + self.TxtTimeEnd.text = XTime.TimestampToGameDateTimeString(endTimeStamp, format) + end +end + +function XUiRegressionTask:UpdateScheduleRewardList() + local activityId = XDataCenter.RegressionManager.GetTaskActivityId() + local groupId = XRegressionConfigs.GetTaskScheduleGroupId(activityId) + if not groupId then return end + local scheduleRewardList = XRegressionConfigs.GetTaskScheduleRewardList(groupId) + if not scheduleRewardList then return end + local rewardCount = #scheduleRewardList + local rewardData + for i, grid in ipairs(self.GridScheduleList) do + if i > rewardCount then + grid.GameObject:SetActiveEx(false) + else + rewardData = scheduleRewardList[i] + grid.GameObject:SetActiveEx(true) + grid:Refresh(rewardData) + end + end +end + +function XUiRegressionTask:UpdateProgress() + local activityId = XDataCenter.RegressionManager.GetTaskActivityId() + if not activityId then return end + local groupId = XRegressionConfigs.GetTaskScheduleGroupId(activityId) + local maxSchedule = XRegressionConfigs.GetTaskMaxTargetSchedule(groupId) + if maxSchedule == 0 then + self.ImgProgress:DOFillAmount(0, AnimTime) + self.TxtCurProgress.text = 0 + self.TxtSumProgress.text = 0 + return + end + local itemId = XDataCenter.RegressionManager.GetTaskScheduleItemId() + local curSchedule = XDataCenter.ItemManager.GetCount(itemId) + + self.ImgProgress:DOFillAmount(curSchedule/maxSchedule, AnimTime) + self.TxtCurProgress.text = curSchedule + self.TxtSumProgress.text = maxSchedule +end + +function XUiRegressionTask:UpdateDynamicTableByIndex(index) + local taskType = XRegressionConfigs.IndexToTaskType[index] + local taskIdList = XDataCenter.TaskManager.GetRegressionTaskByType(taskType) + if taskIdList then + local panel = self.PanelList[index] + panel.GameObject:SetActiveEx(true) + panel:UpdateDynamicTable(taskIdList) + end +end + +--事件相关------------------------------------>>> +function XUiRegressionTask:OnTabBtnGroupClick(index) + if self.SelectTabBtnIndex == index then return end + if self.SelectTabBtnIndex then + self.PanelList[self.SelectTabBtnIndex].GameObject:SetActiveEx(false) + end + + self:PlayAnimation("QieHuan") + self:UpdateDynamicTableByIndex(index) + self.SelectTabBtnIndex = index +end + +function XUiRegressionTask:OnEventTaskSync() + if self.GameObject.activeInHierarchy then + if self.SelectTabBtnIndex then + self:UpdateDynamicTableByIndex(self.SelectTabBtnIndex) + end + else + self.IsNeedRefreshDynamicTable = true + end +end + +function XUiRegressionTask:OnEventScheduleUpdate() + self:UpdateProgress() + self:UpdateScheduleRewardList() +end +--事件相关------------------------------------<<< \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiReport/XUiReport.lua b/Resources/Scripts/XUi/XUiReport/XUiReport.lua new file mode 100644 index 00000000..55bbd516 --- /dev/null +++ b/Resources/Scripts/XUi/XUiReport/XUiReport.lua @@ -0,0 +1,105 @@ +local XUiReport = XLuaUiManager.Register(XLuaUi, "UiReport") + +function XUiReport:OnStart(playerId, playerName, playerLevel, chatContent, callback) + self.PlayerId = playerId + self.PlayerName = playerName + self.TxtReportName.text = playerName + self.PlayerLevel = playerLevel + self.ChatContent = chatContent + self.CallBack = callback + + self.BtnClose.CallBack = function() self:OnBtnClose() end + self.BtnConfirm.CallBack = function() self:OnBtnConfirm() end + + self.TimerId = XScheduleManager.ScheduleForever(function() + self.TxtCount.text = (self.InputField.textComponent.cachedTextGenerator.characterCount - 1) .. "/100" + end, 300) + + self.MainTabs = {} + self.CurSelectMainIndex = 0 + self.SubTabs = {} + self.CurSelectSubIndex = 0 + self:UpdateTabs() +end + +function XUiReport:OnDestroy() + self:RemoveTimer() +end + +function XUiReport:RemoveTimer() + if self.TimerId then + XScheduleManager.UnSchedule(self.TimerId) + self.TimerId = nil + end +end + +function XUiReport:UpdateTabs() + local data = XReportConfigs.GetReportCfg() + for k, v in pairs(data) do + if v.ParentId == 0 then + if not self.MainTabs[k] then + local tabObj = CS.UnityEngine.Object.Instantiate(self.UiObj:GetPrefab("BtnReportType")) + tabObj.transform:SetParent(self.PanelSelectGroup.transform, false) + local xUiButton = tabObj:GetComponent("XUiButton") + xUiButton:SetName(v.Name) + table.insert(self.MainTabs, k, xUiButton) + end + end + end + self.PanelSelectGroup:Init(self.MainTabs, function(index) self:OnMainTab(index) end) +end + +function XUiReport:OnMainTab(index) + self.InputField.text = "" + self.CurSelectMainIndex = index + self:UpdateSubTabs(index) +end + +function XUiReport:UpdateSubTabs(index) + --clean + for _, v in pairs(self.SubTabs) do + CS.UnityEngine.GameObject.Destroy(v.gameObject) + end + self.SubTabs = {} + local data = XReportConfigs.GetReportCfg() + local count = 1 + for k, v in pairs(data) do + if v.ParentId == index then + local tabObj = CS.UnityEngine.Object.Instantiate(self.UiObj:GetPrefab("BtnReportSubType")) + tabObj.transform:SetParent(self.PanelSelectSubGroup.transform, false) + local xUiButton = tabObj:GetComponent("XUiButton") + xUiButton:SetName(v.Name) + self.SubTabs[k] = xUiButton + count = count + 1 + end + end + self.PanelSelectSubGroup:Init(self.SubTabs, function(idx) self:OnSubTab(idx) end) +end + +function XUiReport:OnBtnClose() + self:Close() +end + +--玩法选择 +function XUiReport:OnSubTab(index) + local data = XReportConfigs.GetReportCfg() + for _, v in pairs(data) do + if v.Id == index then + self.InputField.text = CS.XTextManager.GetText("ReportTemplate", tostring(v.Name)) + end + end + self.CurSelectSubIndex = index +end + +function XUiReport:OnBtnConfirm() + if self.CurSelectMainIndex == 0 then + XUiManager.TipText("ReportSelectTypeError") + return + end + XDataCenter.ReportManager.Report(self.PlayerId, self.PlayerName, self.CurSelectMainIndex, self.CurSelectSubIndex, self.InputField.text, self.PlayerLevel, self.ChatContent) + if self.CallBack then + self.CallBack() + end + + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRoomCharacter/XUiGridFilterTagGroup.lua b/Resources/Scripts/XUi/XUiRoomCharacter/XUiGridFilterTagGroup.lua new file mode 100644 index 00000000..dac772b8 --- /dev/null +++ b/Resources/Scripts/XUi/XUiRoomCharacter/XUiGridFilterTagGroup.lua @@ -0,0 +1,61 @@ +-- 角色筛选界面的的标签组 +local XUiGridFilterTagGroup = XClass(nil, "XUiGridFilterTagGroup") + +function XUiGridFilterTagGroup:Ctor(ui, rootUi, groupId) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self.CharacterType = rootUi.CharacterType + self.GroupId = groupId + + self.TagItem = {} + + XTool.InitUiObject(self) + self:InitComponent() +end + +function XUiGridFilterTagGroup:InitComponent() + self.BtnFilterTagGrid.gameObject:SetActiveEx(false) +end + +function XUiGridFilterTagGroup:Refresh() + self.TxtGroupName.text = XRoomCharFilterTipsConfigs.GetFilterTagGroupName(self.GroupId) + local tags = XRoomCharFilterTipsConfigs.GetFilterTagGroupTags(self.GroupId) + for _, tagId in pairs(tags) do + local tabCharType = XRoomCharFilterTipsConfigs.GetFilterTagCharType(tagId) + if tabCharType == self.CharacterType or tabCharType == 0 then + -- 筛选标签的角色类型为当前的角色类型或通用,则生成 + local btnTag = CS.UnityEngine.Object.Instantiate(self.BtnFilterTagGrid) + btnTag.transform:SetParent(self.PanelTags, false) + btnTag.gameObject:SetActiveEx(true) + btnTag:SetName(XRoomCharFilterTipsConfigs.GetFilterTagName(tagId)) + btnTag.CallBack = function() + self:OnTagClick(tagId) + end + + if XDataCenter.RoomCharFilterTipsManager.CheckFilterTagIsSelect(self.GroupId, tagId, self.CharacterType) then + btnTag:SetButtonState(XUiButtonState.Select) + end + + self.TagItem[tagId] = btnTag + end + end +end + +--- +--- 清除所有选择的标签 +function XUiGridFilterTagGroup:ClearAllSelectTag() + for tagId, tag in pairs(self.TagItem) do + if tag.ButtonState == CS.UiButtonState.Select then + tag:SetButtonState(XUiButtonState.Normal) + self:OnTagClick(tagId) + end + end +end + +function XUiGridFilterTagGroup:OnTagClick(tagId) + XDataCenter.RoomCharFilterTipsManager.SetSelectFilterTag(self.GroupId, tagId, + self.TagItem[tagId].ButtonState == CS.UiButtonState.Select) +end + +return XUiGridFilterTagGroup \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRoomCharacter/XUiRoomCharacter.lua b/Resources/Scripts/XUi/XUiRoomCharacter/XUiRoomCharacter.lua new file mode 100644 index 00000000..06616d1c --- /dev/null +++ b/Resources/Scripts/XUi/XUiRoomCharacter/XUiRoomCharacter.lua @@ -0,0 +1,1041 @@ +local CSXTextManagerGetText = CS.XTextManager.GetText + +local TabBtnIndex = { + Normal = 1, + Isomer = 2, +} + +local CharacterTypeConvert = { + [TabBtnIndex.Normal] = XCharacterConfigs.CharacterType.Normal, + [TabBtnIndex.Isomer] = XCharacterConfigs.CharacterType.Isomer, +} +local TabBtnIndexConvert = { + [XCharacterConfigs.CharacterType.Normal] = TabBtnIndex.Normal, + [XCharacterConfigs.CharacterType.Isomer] = TabBtnIndex.Isomer, +} + +local stagePass = false + +local XUiRoomCharacter = XLuaUiManager.Register(XLuaUi, "UiRoomCharacter") + +function XUiRoomCharacter:OnAwake() + self:InitAutoScript() + self:InitDynamicTable() + + local root = self.UiModelGo + self.PanelRoleModel = root:FindTransform("PanelRoleModel") + self.ImgEffectHuanren = root:FindTransform("ImgEffectHuanren") + self.ImgEffectHuanren1 = root:FindTransform("ImgEffectHuanren1") + + self.TagCacheDic = {} + self.SortFunction = {} + self.SortFunction[XRoomCharFilterTipsConfigs.EnumSortTag.Default] = function(a, b) + local AIsInTeam = self:IsInTeam(a) + local BIsInTeam = self:IsInTeam(b) + + if AIsInTeam ~= BIsInTeam then + return AIsInTeam + end + + if self:IsWorldBossType() or self:IsNewCharType() then + local AAbility = self:GetAbility(a) + local BAbility = self:GetAbility(b) + local AIsRobot = XRobotManager.CheckIsRobotId(a) + local BIsRobot = XRobotManager.CheckIsRobotId(b) + + if AIsRobot ~= BIsRobot then + return AIsRobot + else + return AAbility > BAbility + end + elseif self:IsChessPursuitType() then + local AAbility = self:GetAbility(a) + local BAbility = self:GetAbility(b) + if AAbility ~= BAbility then + return AAbility > BAbility + end + + local ACharId = self:GetCharacterId(a) + local BCharId = self:GetCharacterId(b) + if ACharId ~= BCharId then + return ACharId > BCharId + end + + local AIsRobot = XRobotManager.CheckIsRobotId(a) + local BIsRobot = XRobotManager.CheckIsRobotId(b) + if AIsRobot ~= BIsRobot then + return BIsRobot + end + return false + else + local ACharId = self:GetCharacterId(a) + local BCharID = self:GetCharacterId(b) + local ALevel = self:GetLevel(a) + local BLevel = self:GetLevel(b) + local AQuality = self:GetQuality(a) + local BQuality = self:GetQuality(b) + + if ALevel ~= BLevel then + return ALevel > BLevel + end + if AQuality ~= BQuality then + return AQuality > BQuality + end + + local priorityA = XCharacterConfigs.GetCharacterPriority(ACharId) + local priorityB = XCharacterConfigs.GetCharacterPriority(BCharID) + if priorityA ~= priorityB then + return priorityA < priorityB + end + + return ACharId > BCharID + end + end + self.SortFunction[XRoomCharFilterTipsConfigs.EnumSortTag.Quality] = function(a, b) + local AQuality = self:GetQuality(a) + local BQuality = self:GetQuality(b) + if AQuality ~= BQuality then + return AQuality > BQuality + end + return self.SortFunction[XRoomCharFilterTipsConfigs.EnumSortTag.Default](a, b) + end + self.SortFunction[XRoomCharFilterTipsConfigs.EnumSortTag.Level] = function(a, b) + local ALevel = self:GetLevel(a) + local BLevel = self:GetLevel(b) + if ALevel ~= BLevel then + return ALevel > BLevel + end + return self.SortFunction[XRoomCharFilterTipsConfigs.EnumSortTag.Default](a, b) + end + self.SortFunction[XRoomCharFilterTipsConfigs.EnumSortTag.Ability] = function(a, b) + local AAbility = self:GetAbility(a) + local BAbility = self:GetAbility(b) + if AAbility ~= BAbility then + return AAbility > BAbility + end + return self.SortFunction[XRoomCharFilterTipsConfigs.EnumSortTag.Default](a, b) + end + + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self.GridCharacter.gameObject:SetActiveEx(false) +end + +function XUiRoomCharacter:OnStart(teamCharIdMap, teamSelectPos, cb, stageType, characterLimitType, data) + self.TeamCharIdMap = teamCharIdMap + self.TeamSelectPos = teamSelectPos + self.TeamResultCb = cb + self.StageType = stageType or 0 + self.CharacterLimitType = characterLimitType or XFubenConfigs.CharacterLimitType.All + + -- data可能包含的参数: + if data then + self.LimitBuffId = data.LimitBuffId + self.TeamBuffId = data.TeamBuffId + self.RobotIdList = data.RobotIdList + self.ChallengeId = data.ChallengeId + self.SelectCharacterType = data.SelectCharacterType + self.IsHideQuitButton = data.IsHideQuitButton + self.NotReset = data.NotReset + self.SelectCharacterType = data.SelectCharacterType + self.MapId = data.MapId + self.TeamGridIndex = data.TeamGridIndex + self.SceneUiType = data.SceneUiType + self.IsRobotOnly = data.IsRobotOnly + self.RobotAndCharacter = data.RobotAndCharacter + self.StageId = data.StageId + end + self.Proxy = XUiRoomCharacterProxy.ProxyDic[self.StageType] + + self.RoleModelPanel = XUiPanelRoleModel.New(self.PanelRoleModel, self.Name, nil, true) + self.CharacterGrids = {} + + self:InitRequireCharacterInfo() + self:InitCharacterTypeBtns() + self:HideJump() + self:InitEffectPositionInfo() +end + +function XUiRoomCharacter:OnEnable() + self:UpdateInfo() + + self.DynamicTable:ReloadDataASync() + CS.XGraphicManager.UseUiLightDir = true + XEventManager.AddEventListener(XEventId.EVENT_ARENAONLINE_WEEK_REFRESH, self.OnArenaOnlineWeekRefrsh, self) +end + +function XUiRoomCharacter:OnGetEvents() + return { XEventId.EVENT_ACTIVITY_ON_RESET } +end + +function XUiRoomCharacter:OnNotify(evt, ...) + local args = { ... } + if evt == XEventId.EVENT_ACTIVITY_ON_RESET then + self:OnResetEvent(args[1]) + end +end + +function XUiRoomCharacter:OnDisable() + CS.XGraphicManager.UseUiLightDir = false + XEventManager.RemoveEventListener(XEventId.EVENT_ARENAONLINE_WEEK_REFRESH, self.OnArenaOnlineWeekRefrsh, self) +end + +function XUiRoomCharacter:HideJump() + if self.StageType ~= XDataCenter.FubenManager.StageType.ArenaOnline then + return + end + + if self.AssetPanel.BtnBuyJump1 then + self.AssetPanel.BtnBuyJump1.gameObject:SetActiveEx(false) + end + + if self.AssetPanel.BtnBuyJump2 then + self.AssetPanel.BtnBuyJump2.gameObject:SetActiveEx(false) + end + + if self.AssetPanel.BtnBuyJump3 then + self.AssetPanel.BtnBuyJump3.gameObject:SetActiveEx(false) + end +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiRoomCharacter:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiRoomCharacter:AutoInitUi() + self.BtnBack = self.Transform:Find("SafeAreaContentPane/Top/BtnBack"):GetComponent("Button") + self.BtnJoinTeam = self.Transform:Find("SafeAreaContentPane/CharList/TeamBtn/BtnJoinTeam"):GetComponent("Button") + self.BtnConsciousness = self.Transform:Find("SafeAreaContentPane/CharList/TeamBtn/BtnConsciousness"):GetComponent("Button") + self.BtnQuitTeam = self.Transform:Find("SafeAreaContentPane/CharList/TeamBtn/BtnQuitTeam"):GetComponent("Button") + self.SViewCharacterList = self.Transform:Find("SafeAreaContentPane/CharList/CharInfo/Left/SViewCharacterList"):GetComponent("ScrollRect") + self.PanelRoleContent = self.Transform:Find("SafeAreaContentPane/CharList/CharInfo/Left/SViewCharacterList/Viewport/PanelRoleContent") + self.GridCharacter = self.Transform:Find("SafeAreaContentPane/CharList/CharInfo/Left/SViewCharacterList/Viewport/PanelRoleContent/GridCharacter") + self.BtnFashion = self.Transform:Find("SafeAreaContentPane/CharList/TeamBtn/BtnFashion"):GetComponent("Button") + self.PanelRoleModel = self.Transform:Find("SafeAreaContentPane/ModelRoot/NearRoot/PanelRoleModel") + self.PanelDrag = self.Transform:Find("SafeAreaContentPane/CharList/CharInfo/PanelDrag"):GetComponent("XDrag") + self.BtnWeapon = self.Transform:Find("SafeAreaContentPane/CharList/TeamBtn/BtnWeapon"):GetComponent("Button") + self.TxtRequireAbility = self.Transform:Find("SafeAreaContentPane/CharList/TeamBtn/PanelTxt/TxtRequireAbility"):GetComponent("Text") + self.PanelAsset = self.Transform:Find("SafeAreaContentPane/PanelAsset") + self.BtnMainUi = self.Transform:Find("SafeAreaContentPane/Top/BtnMainUi"):GetComponent("Button") + self.PanelRequireCharacter = self.Transform:Find("SafeAreaContentPane/CharList/TeamBtn/PanelTxt/PanelRequireCharacter") + self.ImgRequireCharacter = self.Transform:Find("SafeAreaContentPane/CharList/TeamBtn/PanelTxt/PanelRequireCharacter/Image/ImgRequireCharacter"):GetComponent("Image") + self.TxtRequireCharacter = self.Transform:Find("SafeAreaContentPane/CharList/TeamBtn/PanelTxt/PanelRequireCharacter/TxtRequireCharacter"):GetComponent("Text") +end + +function XUiRoomCharacter:AutoAddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnJoinTeam, self.OnBtnJoinTeamClick) + self:RegisterClickEvent(self.BtnConsciousness, self.OnBtnConsciousnessClick) + self:RegisterClickEvent(self.BtnQuitTeam, self.OnBtnQuitTeamClick) + self:RegisterClickEvent(self.BtnFashion, self.OnBtnFashionClick) + self:RegisterClickEvent(self.BtnWeapon, self.OnBtnWeaponClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:RegisterClickEvent(self.BtnPartner, self.OnCarryPartnerClick) + + self.BtnFilter.CallBack = function() self:OnBtnFilterClick() end +end +-- auto +function XUiRoomCharacter:OnBtnWeaponClick() + XLuaUiManager.Open("UiEquipReplaceNew", self.CurCharacter.Id, nil, true) +end + +function XUiRoomCharacter:OnBtnConsciousnessClick() + XLuaUiManager.Open("UiEquipAwarenessReplace", self.CurCharacter.Id, nil, true) +end + +function XUiRoomCharacter:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiRoomCharacter:OnCarryPartnerClick() + XDataCenter.PartnerManager.GoPartnerCarry(self.CurCharacter.Id, false) +end + +function XUiRoomCharacter:OnBtnFilterClick() + local characterType = CharacterTypeConvert[self.SelectTabBtnIndex] + XLuaUiManager.Open("UiRoomCharacterFilterTips", + self, + XRoomCharFilterTipsConfigs.EnumFilterType.Common, + XRoomCharFilterTipsConfigs.EnumSortType.Common, + characterType) +end + +--初始化音效 +function XUiRoomCharacter:InitBtnSound() + self.SpecialSoundMap[self:GetAutoKey(self.BtnBack, "onClick")] = XSoundManager.UiBasicsMusic.Return + self.SpecialSoundMap[self:GetAutoKey(self.BtnEquip, "onClick")] = XSoundManager.UiBasicsMusic.Fuben_UiMainLineRoomCharacter_Equip + self.SpecialSoundMap[self:GetAutoKey(self.BtnFashion, "onClick")] = XSoundManager.UiBasicsMusic.Fuben_UiMainLineRoomCharacter_Fashion + self.SpecialSoundMap[self:GetAutoKey(self.BtnJoinTeam, "onClick")] = XSoundManager.UiBasicsMusic.Fuben_UiMainLineRoomCharacter_JoinTeam + self.SpecialSoundMap[self:GetAutoKey(self.BtnQuitTeam, "onClick")] = XSoundManager.UiBasicsMusic.Fuben_UiMainLineRoomCharacter_QuitTeam +end + +function XUiRoomCharacter:InitRequireCharacterInfo() + local characterLimitType = self.CharacterLimitType + + if not XFubenConfigs.IsStageCharacterLimitConfigExist(characterLimitType) then + self.PanelRequireCharacter.gameObject:SetActiveEx(false) + return + else + self.PanelRequireCharacter.gameObject:SetActiveEx(true) + end + + local icon = XFubenConfigs.GetStageCharacterLimitImageTeamEdit(characterLimitType) + self.ImgRequireCharacter:SetSprite(icon) +end + +function XUiRoomCharacter:InitEffectPositionInfo() + if self.StageType ~= XDataCenter.FubenManager.StageType.InfestorExplore then + self.PanelEffectPosition.gameObject:SetActiveEx(false) + return + end + self.TxtEffectPosition.text = XDataCenter.FubenInfestorExploreManager.GetBuffDes() + self.PanelEffectPosition.gameObject:SetActiveEx(true) +end + +function XUiRoomCharacter:RefreshCharacterTypeTips() + local limitBuffId = self.LimitBuffId + local characterType = CharacterTypeConvert[self.SelectTabBtnIndex] + local characterLimitType = self.CharacterLimitType + local text = XFubenConfigs.GetStageCharacterLimitTextSelectCharacter(characterLimitType, characterType, limitBuffId) + self.TxtRequireCharacter.text = text +end + +function XUiRoomCharacter:ResetTeamData() + self.TeamCharIdMap = { 0, 0, 0 } +end + +function XUiRoomCharacter:InitCharacterTypeBtns() + local tabBtns = { self.BtnTabGouzaoti, self.BtnTabShougezhe } + self.PanelCharacterTypeBtns:Init(tabBtns, function(index) self:TrySelectCharacterType(index) end) + + if self.Proxy and self.Proxy.InitCharacterTypeBtns then + self.Proxy.InitCharacterTypeBtns(self, self.TeamCharIdMap, TabBtnIndex) + else + self.BtnTabShougezhe.gameObject:SetActiveEx(not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.Isomer)) + + local characterLimitType = self.CharacterLimitType + local lockGouzaoti = characterLimitType == XFubenConfigs.CharacterLimitType.Isomer + local lockShougezhe = not XFunctionManager.JudgeOpen(XFunctionManager.FunctionName.Isomer) or characterLimitType == XFubenConfigs.CharacterLimitType.Normal + self.BtnTabGouzaoti:SetDisable(lockGouzaoti) + self.BtnTabShougezhe:SetDisable(lockShougezhe) + + --检查选择角色类型是否和副本限制类型冲突 + local characterType = XDataCenter.FubenManager.GetDefaultCharacterTypeByCharacterLimitType(self.CharacterLimitType) + + -- 优先使用SelectCharacterType自定义要选择的角色类型,否则根据队伍的角色类型来判断选择的角色类型 + local tempCharacterType + if self.SelectCharacterType then + tempCharacterType = self.SelectCharacterType + else + tempCharacterType = self:GetTeamCharacterType() + end + + -- tempCharacterType为上锁的角色类型时,不更新characterType,使用默认的角色类型 + if tempCharacterType and not (tempCharacterType == XCharacterConfigs.CharacterType.Normal and lockGouzaoti + or tempCharacterType == XCharacterConfigs.CharacterType.Isomer and lockShougezhe) then + characterType = tempCharacterType + end + + self:InitBtnTabIsClick() + self.PanelCharacterTypeBtns:SelectIndex(TabBtnIndexConvert[characterType]) + end +end + +function XUiRoomCharacter:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.SViewCharacterList) + self.DynamicTable:SetProxy(XUiGridCharacter, self) + self.DynamicTable:SetDelegate(self) +end + +function XUiRoomCharacter:TrySelectCharacterType(index) + local characterType = CharacterTypeConvert[index] + if characterType == XCharacterConfigs.CharacterType.Isomer and not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.Isomer) then return end + + if not self:IsCanClickBtnTab(characterType) then + return + end + + local characterLimitType = self.CharacterLimitType + if characterLimitType == XFubenConfigs.CharacterLimitType.Normal then + if characterType == XCharacterConfigs.CharacterType.Isomer then + XUiManager.TipText("TeamSelectCharacterTypeLimitTipNormal") + return + end + elseif characterLimitType == XFubenConfigs.CharacterLimitType.Isomer then + if characterType == XCharacterConfigs.CharacterType.Normal then + XUiManager.TipText("TeamSelectCharacterTypeLimitTipIsomer") + return + end + -- elseif characterLimitType == XFubenConfigs.CharacterLimitType.IsomerDebuff then + -- if characterType == XCharacterConfigs.CharacterType.Isomer then + -- local buffDes = XFubenConfigs.GetBuffDes(self.LimitBuffId) + -- local content = CSXTextManagerGetText("TeamSelectCharacterTypeLimitTipIsomerDebuff", buffDes) + -- local sureCallBack = function() + -- self:OnSelectCharacterType(index) + -- end + -- local closeCallback = function() + -- self.PanelCharacterTypeBtns:SelectIndex(TabBtnIndexConvert[XCharacterConfigs.CharacterType.Normal]) + -- end + -- XUiManager.DialogTip(nil, content, XUiManager.DialogType.Normal, closeCallback, sureCallBack) + -- return + -- end + -- elseif characterLimitType == XFubenConfigs.CharacterLimitType.NormalDebuff then + -- if characterType == XCharacterConfigs.CharacterType.Normal then + -- local buffDes = XFubenConfigs.GetBuffDes(self.LimitBuffId) + -- local content = CSXTextManagerGetText("TeamSelectCharacterTypeLimitTipNormalDebuff", buffDes) + -- local sureCallBack = function() + -- self:OnSelectCharacterType(index) + -- end + -- local closeCallback = function() + -- self.PanelCharacterTypeBtns:SelectIndex(TabBtnIndexConvert[XCharacterConfigs.CharacterType.Isomer]) + -- end + -- XUiManager.DialogTip(nil, content, XUiManager.DialogType.Normal, closeCallback, sureCallBack) + -- return + -- end + end + + self:OnSelectCharacterType(index) +end + +function XUiRoomCharacter:OnSelectCharacterType(index) + if self.SelectTabBtnIndex == index then return end + self.SelectTabBtnIndex = index + local characterType = CharacterTypeConvert[index] + self.CharIdList = {} + self.AllCharIdList = {} + XDataCenter.RoomCharFilterTipsManager.Reset() + + if self:IsWorldBossType() then + self.CharIdList = XDataCenter.CharacterManager.GetRobotAndCharacterIdList(self.RobotIdList, characterType) + elseif self:IsChessPursuitType() then + if self.SceneUiType == XChessPursuitCtrl.SCENE_UI_TYPE.BOSS_ROUND then + for _, charId in pairs(self.TeamCharIdMap) do + if charId > 0 then + table.insert(self.CharIdList, charId) + end + end + else + self.CharIdList = XDataCenter.CharacterManager.GetRobotAndCharacterIdList(self.RobotIdList, characterType) + end + elseif self.IsRobotOnly then + self.CharIdList = XRobotManager.GetRobotIdFilterListByCharacterType(self.RobotIdList, characterType) + elseif self.RobotAndCharacter then + self.CharIdList = XDataCenter.CharacterManager.GetRobotAndCharacterIdList(self.RobotIdList, characterType) + else + self.CharIdList = XDataCenter.CharacterManager.GetCharacterIdListInTeam(characterType) + end + + if self.Proxy and self.Proxy.SortList then + self.AllCharIdList = self.Proxy.SortList(self, self.CharIdList) + else + table.sort(self.CharIdList, self.SortFunction[XRoomCharFilterTipsConfigs.EnumSortTag.Default]) + self.AllCharIdList = self.CharIdList + end + + self:RefreshCharacterTypeTips() + self:UpdateCharacterList(index) +end + +--初始化部分功能,当前队伍中无某个类型,则不可点击标签按钮切换 +function XUiRoomCharacter:InitBtnTabIsClick() + if not self:CheckBtnTabIsClick() then + return + end + + local isClickNormal, isClickOmer = false, false + local characterType + for _, charId in ipairs(self.TeamCharIdMap) do + if charId > 0 then + characterType = XCharacterConfigs.GetCharacterType(charId) + if characterType == XCharacterConfigs.CharacterType.Normal and not isClickNormal then + isClickNormal = true + elseif characterType == XCharacterConfigs.CharacterType.Isomer and not isClickOmer then + isClickOmer = true + end + end + end + self.IsClickNormal = isClickNormal + self.IsClickOmer = isClickOmer + self.BtnTabGouzaoti:SetDisable(not isClickNormal) + self.BtnTabShougezhe:SetDisable(not isClickOmer) +end + +function XUiRoomCharacter:CheckBtnTabIsClick() + if self:IsChessPursuitType() and self.SceneUiType == XChessPursuitCtrl.SCENE_UI_TYPE.BOSS_ROUND then + return true + end + return false +end + +function XUiRoomCharacter:IsCanClickBtnTab(characterType) + if not self.CharIdList then + return true + end + + if not self:CheckBtnTabIsClick() then + return true + end + + if characterType == XCharacterConfigs.CharacterType.Normal and self.IsClickNormal then + return true + end + if characterType == XCharacterConfigs.CharacterType.Isomer and self.IsClickOmer then + return true + end + return false +end + +function XUiRoomCharacter:SetPanelEmptyList(isEmpty) + if self.Proxy and self.Proxy.SetPanelEmptyList then + self.Proxy.SetPanelEmptyList(self, isEmpty) + else + local curCharIsRobot = self.CurCharacter and XRobotManager.CheckIsRobotId(self.CurCharacter.Id) or false + + self.BtnQuitTeam.gameObject:SetActiveEx(false) + self.BtnJoinTeam.gameObject:SetActiveEx(false) + + self.BtnConsciousness.gameObject:SetActiveEx(not isEmpty and not curCharIsRobot) + self.BtnFashion.gameObject:SetActiveEx(not isEmpty and not curCharIsRobot) + self.BtnWeapon.gameObject:SetActiveEx(not isEmpty and not curCharIsRobot) + self.BtnPartner.gameObject:SetActiveEx(not isEmpty and not curCharIsRobot) + + self.PanelRoleModel.gameObject:SetActiveEx(not isEmpty) + self.PanelRoleContent.gameObject:SetActiveEx(not isEmpty) + self.PanelEmptyList.gameObject:SetActiveEx(isEmpty) + end +end + +function XUiRoomCharacter:UpdatePanelEmptyList() + if self.Proxy and self.Proxy.UpdatePanelEmptyList then + self.Proxy.UpdatePanelEmptyList(self, self.CurCharacter.Id) + else + local curCharIsRobot = self.CurCharacter and XRobotManager.CheckIsRobotId(self.CurCharacter.Id) or false + + self.BtnConsciousness.gameObject:SetActiveEx(not curCharIsRobot) + self.BtnFashion.gameObject:SetActiveEx(not curCharIsRobot) + self.BtnWeapon.gameObject:SetActiveEx(not curCharIsRobot) + self.BtnPartner.gameObject:SetActiveEx(not curCharIsRobot) + + self.BtnJoinTeam.gameObject:SetActiveEx(self.NeedShowBtnJoinTeam and not self:IsRogueLikeAndLock()) + end +end + +function XUiRoomCharacter:CenterToGrid(grid) + -- local normalizedPosition + -- local count = self.SViewCharacterList.content.transform.childCount + -- local index = grid.Transform:GetSiblingIndex() + -- if index > count / 2 then + -- normalizedPosition = (index + 1) / count + -- else + -- normalizedPosition = (index - 1) / count + -- end + -- self.SViewCharacterList.verticalNormalizedPosition = math.max(0, math.min(1, (1 - normalizedPosition))) +end + +function XUiRoomCharacter:UpdateCharacterList(index) + stagePass = XDataCenter.RoomManager.CheckPlayerStagePass() or XDataCenter.ArenaOnlineManager.CheckStagePass(self.ChallengeId) + local characterType = CharacterTypeConvert[index] + local teamCharIdMap = self.TeamCharIdMap + local selectId = teamCharIdMap[self.TeamSelectPos] + + if not next(self.CharIdList) then + self:SetPanelEmptyList(true) + return + end + self:SetPanelEmptyList(false) + + self.CurIndex = nil + self.CharacterIdToIndex = {} + local useDefaultIndex = true + if selectId and selectId ~= 0 and characterType == XCharacterConfigs.GetCharacterType(selectId) then + useDefaultIndex = false + end + for i, id in ipairs(self.CharIdList) do + self.CharacterIdToIndex[id] = i + if self.CurIndex == nil and id == selectId and not useDefaultIndex then + self.CurIndex = i + end + end + self.CurIndex = self.CurIndex or 1 + + local charInfo = self:GetCharInfo(self.CurIndex) + self:UpdateInfo(charInfo) + + self.DynamicTable:SetDataSource(self.CharIdList) + self.DynamicTable:ReloadDataASync() +end + +function XUiRoomCharacter:OnDynamicTableEvent(event, index, grid) + local characterId = self.CharIdList[index] + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + if index < 0 or index > #self.CharIdList then return end + local char = self:GetCharInfo(index) + grid:UpdateGrid(char, self.StageType) + + local showTeamBuff = XFubenConfigs.IsCharacterFitTeamBuff(self.TeamBuffId, characterId) + grid:SetTeamBuff(showTeamBuff) + + if self.StageType == XDataCenter.FubenManager.StageType.BossSingle then + local maxStamina = XDataCenter.FubenBossSingleManager.GetMaxStamina() + local curStamina = maxStamina - XDataCenter.FubenBossSingleManager.GetCharacterChallengeCount(characterId) + grid:UpdateStamina(curStamina, maxStamina) + elseif self.StageType == XDataCenter.FubenManager.StageType.Explore then + local maxStamina = XDataCenter.FubenExploreManager.GetMaxEndurance(XDataCenter.FubenExploreManager.GetCurChapterId()) + local curStamina = maxStamina - XDataCenter.FubenExploreManager.GetEndurance(XDataCenter.FubenExploreManager.GetCurChapterId(), characterId) + grid:UpdateStamina(curStamina, maxStamina) + elseif self.StageType == XDataCenter.FubenManager.StageType.ArenaOnline then + if not stagePass then + local maxStamina = XArenaOnlineConfigs.MAX_NAILI + local curStamina = maxStamina - XDataCenter.ArenaOnlineManager.GetCharEndurance(characterId) + grid:UpdateStamina(curStamina, maxStamina) + end + local isShow = XDataCenter.ArenaOnlineManager.CheckActiveBuffOnByCharId(characterId) + grid:SetTeamBuff(isShow) + elseif self.StageType == XDataCenter.FubenManager.StageType.InfestorExplore and XDataCenter.FubenInfestorExploreManager.IsInSectionOne() then + local hpPercent = XDataCenter.FubenInfestorExploreManager.GetCharacterHpPrecent(char.Id) + grid:UpdateStaminaByPercent(hpPercent) + elseif self:IsRogueLikeType() then + grid:SetArrowUp(XDataCenter.FubenRogueLikeManager.IsTeamEffectCharacter(characterId)) + end + + grid:SetSelect(self.CurIndex == index) + grid:SetInTeam(false) + for pos, id in pairs(self.TeamCharIdMap) do + if id > 0 and self.CharacterIdToIndex[id] == index then + grid:SetInTeam(true, CSXTextManagerGetText("CommonInTheTeam"), pos) + break + end + end + + --追击玩法 + if self:IsChessPursuitType() then + local inTeam, gridId = self:CheckIsInChessPursuit(characterId) + if inTeam then + grid:SetInTeam(inTeam, CSXTextManagerGetText("BfrtFightEchelonTitleSimple", gridId)) + end + if self:IsSameCharIdInTeam(characterId) then + grid:SetSameRoleTag(true) + end + end + + grid.Transform:SetAsLastSibling() + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + self.CurIndex = index + self:UpdateInfo(grid.Character) + self.DynamicTable:ReloadDataSync() + end +end + +function XUiRoomCharacter:GetCharInfo(index) + local charId = self.CharIdList[index] + if self.Proxy and self.Proxy.GetCharInfo then + return self.Proxy.GetCharInfo(self, charId) + else + local charInfo = {} + if XRobotManager.CheckIsRobotId(charId) then + charInfo.Id = charId + charInfo.IsRobot = true + else + charInfo = XDataCenter.CharacterManager.GetCharacter(charId) + end + return charInfo + end +end + +function XUiRoomCharacter:UpdateInfo(character) + if character then + self.CurCharacter = character + end + if not self.CurCharacter then return end + + self:UpdateTeamBtn() + self:UpdateRoleModel() +end + +function XUiRoomCharacter:UpdateTeamBtn() + if self.Proxy and self.Proxy.UpdateTeamBtn then + self.Proxy.UpdateTeamBtn(self, self.CurCharacter.Id) + else + if not (self.TeamCharIdMap and next(self.TeamCharIdMap)) then + return + end + + --在当前操作的队伍中 + local isInTeam = self:IsInTeam(self.CurCharacter.Id) + + self.NeedShowBtnJoinTeam = not isInTeam + + self.BtnQuitTeam.gameObject:SetActiveEx(isInTeam and not self.IsHideQuitButton) + self.BtnJoinTeam.gameObject:SetActiveEx(false) + + -- 爬塔玩法、并且角色被锁定、不能编入、卸下队伍 + if self:IsRogueLikeAndLock() then + self.BtnQuitTeam.gameObject:SetActiveEx(false) + self.BtnJoinTeam.gameObject:SetActiveEx(false) + end + end +end + +function XUiRoomCharacter:IsInTeam(id) + if not (self.TeamCharIdMap and next(self.TeamCharIdMap)) then + return false + end + for _, v in pairs(self.TeamCharIdMap) do + if id == v then + return true + end + end + return false +end + +-- 区域联机周刷新 +function XUiRoomCharacter:OnArenaOnlineWeekRefrsh() + if self.StageType == XDataCenter.FubenManager.StageType.ArenaOnline then + XDataCenter.ArenaOnlineManager.RunMain() + end +end + +function XUiRoomCharacter:IsRogueLikeType() + return self.StageType == XDataCenter.FubenManager.StageType.RogueLike +end + +function XUiRoomCharacter:IsRogueLikeAndLock() + return self:IsRogueLikeType() and XDataCenter.FubenRogueLikeManager.IsRogueLikeCharacterLock() +end + +function XUiRoomCharacter:IsWorldBossType() + return self.StageType == XDataCenter.FubenManager.StageType.WorldBoss +end + +function XUiRoomCharacter:IsChessPursuitType() + return self.StageType == XDataCenter.FubenManager.StageType.ChessPursuit +end + +function XUiRoomCharacter:IsNewCharType() + return self.StageType == XDataCenter.FubenManager.StageType.NewCharAct +end + +function XUiRoomCharacter:IsHackType() + return self.StageType == XDataCenter.FubenManager.StageType.Hack +end + +function XUiRoomCharacter:IsSummerEpisodePhotoType() + return XDataCenter.FubenSpecialTrainManager.IsPhotoStage(self.StageId) +end + +function XUiRoomCharacter:UpdateRoleModel() + local characterId = self.CurCharacter and self.CurCharacter.Id + if not characterId then return end + local targetPanelRole = self.PanelRoleModel + local targetUiName = self.Name + local func = function() + self:UpdatePanelEmptyList() + end + local characterFunc = function(model) + if not model then + return + end + self.PanelDrag.Target = model.transform + if self.SelectTabBtnIndex == TabBtnIndex.Normal then + self.ImgEffectHuanren.gameObject:SetActiveEx(true) + elseif self.SelectTabBtnIndex == TabBtnIndex.Isomer then + self.ImgEffectHuanren1.gameObject:SetActiveEx(true) + end + end + + self.ImgEffectHuanren.gameObject:SetActiveEx(false) + self.ImgEffectHuanren1.gameObject:SetActiveEx(false) + + if XRobotManager.CheckIsRobotId(self.CurCharacter.Id) then + local robotId = self.CurCharacter.Id + local robotCfg = XRobotManager.GetRobotTemplate(robotId) + characterId = XRobotManager.GetCharacterId(robotId) + self.RoleModelPanel:UpdateRobotModel(robotId, characterId, func, robotCfg.FashionId, robotCfg.WeaponId, characterFunc) + else + self.RoleModelPanel:UpdateCharacterModel(self.CurCharacter.Id, targetPanelRole, targetUiName, characterFunc, func) + end +end + +function XUiRoomCharacter:OnBtnBackClick() + if self.TeamResultCb then + self.TeamResultCb(self.TeamCharIdMap) + end + self:Close() +end + +function XUiRoomCharacter:OnBtnJoinTeamClick() + local id = self.CurCharacter.Id + if self.StageType == XDataCenter.FubenManager.StageType.BossSingle then + local challengeCount = XDataCenter.FubenBossSingleManager.GetCharacterChallengeCount(id) + if challengeCount >= XDataCenter.FubenBossSingleManager.GetMaxStamina() then + XUiManager.TipCode(XCode.FubenBossSingleCharacterPointsNotEnough) + return + end + elseif self.StageType == XDataCenter.FubenManager.StageType.ArenaOnline then + local stagePass = XDataCenter.RoomManager.CheckPlayerStagePass() or XDataCenter.ArenaOnlineManager.CheckStagePass(self.ChallengeId) + if not stagePass then + local cost = XDataCenter.ArenaOnlineManager.GetStageEndurance(self.ChallengeId) + local cur = XArenaOnlineConfigs.MAX_NAILI - XDataCenter.ArenaOnlineManager.GetCharEndurance(id) + if cost > cur then + XUiManager.TipText("ArenaOnlineCharEnduranceTip", XUiManager.UiTipType.Tip) + return + end + end + end + + local joinFunc = function(isReset) + if isReset then + self:ResetTeamData() + else + for k, v in pairs(self.TeamCharIdMap) do + if XRobotManager.CheckIsRobotId(v) and not XRobotManager.CheckIsRobotId(id) then + local robotTemplate = XRobotManager.GetRobotTemplate(v) + local charId = robotTemplate and robotTemplate.CharacterId or 0 + if charId == id then + self.TeamCharIdMap[k] = 0 + break + end + elseif not XRobotManager.CheckIsRobotId(v) and XRobotManager.CheckIsRobotId(id) then + local robotTemplate = XRobotManager.GetRobotTemplate(id) + local charId = robotTemplate and robotTemplate.CharacterId or 0 + if v == charId then + self.TeamCharIdMap[k] = 0 + break + end + else + if v == id then + self.TeamCharIdMap[k] = 0 + break + end + end + end + end + + self.TeamCharIdMap[self.TeamSelectPos] = id + + if self.TeamResultCb then + self.TeamResultCb(self.TeamCharIdMap) + end + + self:Close() + end + + if not self.NotReset and (not self:IsSummerEpisodePhotoType()) then + -- 角色类型不一致拦截 + local inTeamCharacterType = self:GetTeamCharacterType() + if inTeamCharacterType then + local characterType = id and id ~= 0 and XCharacterConfigs.GetCharacterType(id) + if characterType and characterType ~= inTeamCharacterType then + local content = CSXTextManagerGetText("TeamCharacterTypeNotSame") + local sureCallBack = function() + local isReset = true + joinFunc(isReset) + end + XUiManager.DialogTip(nil, content, XUiManager.DialogType.Normal, nil, sureCallBack) + return + end + end + end + + if self:IsChessPursuitType() then + local isIn, gridId, teamDataIndex = self:CheckIsInChessPursuit(id) + if isIn then + local content = CSXTextManagerGetText("ChessPursuitDeploySwitchTipsContent", gridId) + local sureCallBack = function() + if not XDataCenter.ChessPursuitManager.CheckIsSwapTeamPos(gridId, teamDataIndex, self.TeamGridIndex, self.TeamSelectPos) then + XUiManager.TipText("ChessPursuitNotSwitchCharacter") + return + end + joinFunc() + end + XUiManager.DialogTip(nil, content, XUiManager.DialogType.Normal, nil, sureCallBack) + return + end + end + + joinFunc() +end + +function XUiRoomCharacter:OnBtnQuitTeamClick() + local count = 0 + for _, v in pairs(self.TeamCharIdMap) do + if v > 0 then + count = count + 1 + end + end + + local id = self.CurCharacter.Id + for k, v in pairs(self.TeamCharIdMap) do + if v == id then + self.TeamCharIdMap[k] = 0 + break + end + end + + if self.TeamResultCb then + self.TeamResultCb(self.TeamCharIdMap) + end + self:Close() +end + +function XUiRoomCharacter:OnBtnFashionClick() + XLuaUiManager.Open("UiFashion", self.CurCharacter.Id) +end + +function XUiRoomCharacter:GetTeamCharacterType() + for k, v in pairs(self.TeamCharIdMap) do + if v ~= 0 then + return XCharacterConfigs.GetCharacterType(v) + end + end +end + +function XUiRoomCharacter:GetCharacterId(id) + if XRobotManager.CheckIsRobotId(id) then + return XRobotManager.GetRobotTemplate(id).CharacterId + else + return id + end +end + +function XUiRoomCharacter:GetAbility(id) + if XRobotManager.CheckIsRobotId(id) then + return XRobotManager.GetRobotAbility(id) + else + return XDataCenter.CharacterManager.GetCharacter(id).Ability + end +end + +function XUiRoomCharacter:GetLevel(id) + if XRobotManager.CheckIsRobotId(id) then + return XRobotManager.GetRobotTemplate(id).CharacterLevel + else + return XDataCenter.CharacterManager.GetCharacter(id).Level + end +end + +function XUiRoomCharacter:GetQuality(id) + if XRobotManager.CheckIsRobotId(id) then + return XRobotManager.GetRobotTemplate(id).CharacterQuality + else + return XDataCenter.CharacterManager.GetCharacter(id).Quality + end +end + +function XUiRoomCharacter:Filter(selectTagGroupDic, sortTagId, isThereFilterDataCb) + + local judgeCb = function(groupId, tagValue, characterId) + local char = {} + if XRobotManager.CheckIsRobotId(characterId) then + char.Id = characterId + char.IsRobot = true + else + char = XDataCenter.CharacterManager.GetCharacter(characterId) + end + + local compareValue + local detailConfig + if char.IsRobot then + local robotTemplate = XRobotManager.GetRobotTemplate(char.Id) + detailConfig = XCharacterConfigs.GetCharDetailTemplate(robotTemplate.CharacterId) + else + detailConfig = XCharacterConfigs.GetCharDetailTemplate(char.Id) + end + + if groupId == XRoomCharFilterTipsConfigs.EnumFilterTagGroup.Career then + compareValue = detailConfig.Career + if compareValue == tagValue then + -- 当前角色满足该标签 + return true + end + elseif groupId == XRoomCharFilterTipsConfigs.EnumFilterTagGroup.Element then + compareValue = detailConfig.ObtainElementList + for _, element in pairs(compareValue) do + if element == tagValue then + -- 当前角色满足该标签 + return true + end + end + else + XLog.Error(string.format("XUiRoomCharacter:Filter函数错误,没有处理排序组:%s的逻辑", groupId)) + return false + end + end + + XDataCenter.RoomCharFilterTipsManager.Filter(self.TagCacheDic, selectTagGroupDic, self.AllCharIdList, judgeCb, + function(filteredData) + self:FilterRefresh(filteredData, sortTagId) + end, + isThereFilterDataCb) +end + +function XUiRoomCharacter:FilterRefresh(filteredData, sortTagId) + self.CharIdList = filteredData + + if not next(filteredData) then + self:SetPanelEmptyList(true) + return + end + self:SetPanelEmptyList(false) + + if self.SortFunction[sortTagId] then + table.sort(filteredData, self.SortFunction[sortTagId]) + else + XLog.Error(string.format("XUiRoomCharacter:FilterRefresh函数错误,没有定义标签:%s的排序函数", sortTagId)) + return + end + + self.CharacterIdToIndex = {} + for index, id in ipairs(filteredData) do + self.CharacterIdToIndex[id] = index + end + self.CurIndex = 1 + + local charInfo = self:GetCharInfo(self.CurIndex) + self:UpdateInfo(charInfo) + + self.DynamicTable:SetDataSource(filteredData) + self.DynamicTable:ReloadDataASync() +end + +function XUiRoomCharacter:CheckIsInChessPursuit(characterId) + if not self:IsChessPursuitType() then + return false + end + + local isIn, gridId, teamDataIndex = XDataCenter.ChessPursuitManager.CheckIsInChessPursuit(self.MapId, characterId, self.TeamGridIndex) + return isIn, gridId, teamDataIndex +end + +function XUiRoomCharacter:ShowChessPursuitDialogTip(characterId, sureCallBack) + local name = XCharacterConfigs.GetCharacterName(characterId) + local title = CSXTextManagerGetText("BfrtDeployTipTitle") + local content = CSXTextManagerGetText("ChessPursuitReplaceCharacterTip", name) + XUiManager.DialogTip(title, content, XUiManager.DialogType.Normal, nil, sureCallBack) +end + +function XUiRoomCharacter:IsSameCharIdInTeam(characterId) + if self:IsInTeam(characterId) then + return false + end + + characterId = XRobotManager.CheckIdToCharacterId(characterId) + local inTeamCharId + for _, charId in pairs(self.TeamCharIdMap) do + inTeamCharId = XRobotManager.CheckIdToCharacterId(charId) + if characterId == inTeamCharId then + return true + end + end + return false +end + +--================ +--接受到活动重置或结束消息时 +--================ +function XUiRoomCharacter:OnResetEvent(stageType) + if self.StageType ~= stageType then return end + if self.Proxy.OnResetEvent then self.Proxy.OnResetEvent(self) end +end diff --git a/Resources/Scripts/XUi/XUiRoomCharacter/XUiRoomCharacterFilterTips.lua b/Resources/Scripts/XUi/XUiRoomCharacter/XUiRoomCharacterFilterTips.lua new file mode 100644 index 00000000..31b5785b --- /dev/null +++ b/Resources/Scripts/XUi/XUiRoomCharacter/XUiRoomCharacterFilterTips.lua @@ -0,0 +1,141 @@ +local XUiRoomCharacterFilterTips = XLuaUiManager.Register(XLuaUi, "UiRoomCharacterFilterTips") + +local XUiGridFilterTagGroup = require("XUi/XUiRoomCharacter/XUiGridFilterTagGroup") + +function XUiRoomCharacterFilterTips:OnAwake() + self.FilterTagGroupList = {} + self.SortTagBtnList = {} + self.SortTagIdList = {} + self.HideSortTagDic = nil + self:InitComponent() + self:AddListener() +end + +-- hideSortTagDic : { [XRoomCharFilterTipsConfigs.EnumSortTag.xxx] = true } 即为隐藏 +function XUiRoomCharacterFilterTips:OnStart(rootUi, filterType, sortType, characterType, hideFilter, hideSort, hideSortTagDic) + hideSortTagDic = hideSortTagDic or {} + self.RootUi = rootUi + self.FilterType = filterType + self.SortType = sortType + self.CharacterType = characterType + self.HideFilter = hideFilter + self.HideSort = hideSort + self.HideSortTagDic = hideSortTagDic + + XDataCenter.RoomCharFilterTipsManager.InitTemp(characterType) + self:Refresh() +end + +function XUiRoomCharacterFilterTips:Refresh() + if not self.HideFilter then + -- 筛选标签组 + self.PanelFilter.gameObject:SetActiveEx(true) + local filterTagGroups = XRoomCharFilterTipsConfigs.GetFilterTagGroups(self.FilterType) + for _, groupId in ipairs(filterTagGroups) do + local obj = CS.UnityEngine.Object.Instantiate(self.GridFilterTagGroup) + obj.transform:SetParent(self.FilterContent, false) + obj.gameObject:SetActiveEx(true) + + local gridGroup = XUiGridFilterTagGroup.New(obj, self, groupId) + gridGroup:Refresh() + + table.insert(self.FilterTagGroupList, gridGroup) + end + else + self.PanelFilter.gameObject:SetActiveEx(false) + end + + if not self.HideSort then + -- 排序标签 + self.PanelSort.gameObject:SetActiveEx(true) + local selectSortTagIndex + local sortTags = XRoomCharFilterTipsConfigs.GetCharacterSortTags(self.SortType) + for index, sortTabId in ipairs(sortTags) do + local tabCharType = XRoomCharFilterTipsConfigs.GetCharacterSortTagCharType(sortTabId) + if tabCharType == self.CharacterType or tabCharType == 0 then + -- 排序标签的角色类型为当前的角色类型或通用,则生成 + local btnSortTag = CS.UnityEngine.Object.Instantiate(self.BtnSortTagGrid) + btnSortTag.transform:SetParent(self.SortContent, false) + btnSortTag.gameObject:SetActiveEx(true) + btnSortTag:SetName(XRoomCharFilterTipsConfigs.GetCharacterSortTagName(sortTabId)) + + + self.SortTagBtnList[index] = btnSortTag + self.SortTagIdList[index] = sortTabId + if XDataCenter.RoomCharFilterTipsManager.CheckSortTagIsSelect(sortTabId, self.CharacterType) then + selectSortTagIndex = index + end + -- 隐藏指定的排序类型 + if self.HideSortTagDic[sortTabId] then + btnSortTag.gameObject:SetActiveEx(false) + end + end + end + + self.SortGroup:Init(self.SortTagBtnList, function(index) self:OnSortGroupClick(index) end) + self.SortGroup:SelectIndex(selectSortTagIndex or 1) + else + self.PanelSort.gameObject:SetActiveEx(false) + end +end + +function XUiRoomCharacterFilterTips:OnDestroy() + XDataCenter.RoomCharFilterTipsManager.ClearTemp() +end + +function XUiRoomCharacterFilterTips:InitComponent() + self.GridFilterTagGroup.gameObject:SetActiveEx(false) + self.BtnSortTagGrid.gameObject:SetActiveEx(false) +end + +function XUiRoomCharacterFilterTips:AddListener() + self.BtnSelect.CallBack = function() self:OnBtnSelectClick() end + self.BtnCancel.CallBack = function() self:OnCancelClick() end + self.BtnTanchuangCloseBig.CallBack = function() self:OnCancelClick() end + self.BtnAllCategory.CallBack = function() self:OnBtnAllCategoryClick() end +end + +function XUiRoomCharacterFilterTips:OnBtnAllCategoryClick() + for _,group in ipairs(self.FilterTagGroupList) do + group:ClearAllSelectTag() + end +end + +--- +--- selectTagGroupDic是一个二维字典 +--- Key:筛选组Id +--- Value:标签字典 +--- +--- 标签字典(组所勾选的标签) +--- Key:标签Id +--- Value:标签Id +function XUiRoomCharacterFilterTips:OnBtnSelectClick() + if self.RootUi.Filter then + local sortTagId = XDataCenter.RoomCharFilterTipsManager.GetSelectSortTag() + local selectTagGroupDic = XDataCenter.RoomCharFilterTipsManager.GetSelectFilterTag() + self.RootUi:Filter(selectTagGroupDic, sortTagId, function(filteredData) + return self:IsThereFilterData(filteredData) + end) + else + XLog.Error("XUiRoomCharacterFilterTips:OnBtnSelectClick函数错误,父UI未实现函数Filter") + end +end + +function XUiRoomCharacterFilterTips:IsThereFilterData(filteredData) + if next(filteredData) == nil then + XUiManager.TipText("CharacterFilterEmpty") + return false + else + XDataCenter.RoomCharFilterTipsManager.UseTemp(self.CharacterType) + self:Close() + return true + end +end + +function XUiRoomCharacterFilterTips:OnSortGroupClick(index) + XDataCenter.RoomCharFilterTipsManager.SetSelectSortTag(self.SortTagIdList[index]) +end + +function XUiRoomCharacterFilterTips:OnCancelClick() + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRoomCharacter/XUiRoomCharacterProxy.lua b/Resources/Scripts/XUi/XUiRoomCharacter/XUiRoomCharacterProxy.lua new file mode 100644 index 00000000..48133770 --- /dev/null +++ b/Resources/Scripts/XUi/XUiRoomCharacter/XUiRoomCharacterProxy.lua @@ -0,0 +1,58 @@ +-- 通用出战界面代理管理 +XUiRoomCharacterProxy = XUiRoomCharacterProxy or {} + +XUiRoomCharacterProxy.ProxyDic = {} +--================= +-- 注册出战界面代理 +--@param stageType:FubenManager中关卡的分类StageType +--@param proxy:代理 +--================= +function XUiRoomCharacterProxy.RegisterProxy(stageType, proxy) + if XUiRoomCharacterProxy.ProxyDic[stageType] then return end + XUiRoomCharacterProxy.ProxyDic[stageType] = proxy +end + +--[[ +--============================================================ +-- 页面代理方法 +--============================================================ +所有方法都可选择性使用,不写该方法会调用UiRoomCharacter本身的默认方法 +代理需使用上面的注册方法才能使用(一个FubenManager的StageType分类代理只有一个) +如有需要追加的方法请在下方补充 + +--================ +--初始化左侧界面 +--================ +function ProxyName:InitCharacterTypeBtns(roomCharacterUi, teamCharIdMap, TabBtnIndex) + +--================ +--成员排序函数 +--================ +function ProxyName:SortList(roomCharacterUi, charIdList) + +--================ +--设置右侧界面显示 +--================ +function ProxyName:SetPanelEmptyList(roomCharacterUi, isEmpty) + +--================ +--刷新右侧界面 +--================ +function ProxyName:UpdatePanelEmptyList(roomCharacterUi) + +--================ +--刷新进战按钮 +--================ +function ProxyName:UpdateTeamBtn(roomCharacterUi, charId) + +--================ +--接受到活动重置或结束消息时 +--================ +function ProxyName:OnResetEvent(roomCharacterUi) + +--================ +--获取角色信息 +--================ +function ProxyName:GetCharInfo(roomCharacterUi, charId) + +--]] \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRoomTeamBuff/XUiRoomTeamBuff.lua b/Resources/Scripts/XUi/XUiRoomTeamBuff/XUiRoomTeamBuff.lua new file mode 100644 index 00000000..810d9575 --- /dev/null +++ b/Resources/Scripts/XUi/XUiRoomTeamBuff/XUiRoomTeamBuff.lua @@ -0,0 +1,19 @@ +local CSXTextManagerGetText = CS.XTextManager.GetText + +local XUiRoomTeamBuff = XLuaUiManager.Register(XLuaUi, "UiRoomTeamBuff") + +function XUiRoomTeamBuff:OnAwake() + self:AutoAddListener() +end + +function XUiRoomTeamBuff:OnStart(teamBuffId) + self.RImgOnIcon:SetRawImage(XFubenConfigs.GetTeamBuffOnIcon(teamBuffId)) + self.RImgOffIcon:SetRawImage(XFubenConfigs.GetTeamBuffOffIcon(teamBuffId)) + self.TxtTile.text = XFubenConfigs.GetTeamBuffTitle(teamBuffId) + self.TxtDesc.text = XFubenConfigs.GetTeamBuffDesc(teamBuffId) +end + +function XUiRoomTeamBuff:AutoAddListener() + self.BtnTanchuangClose.CallBack = function() self:Close() end + self.BtnClose.CallBack = function() self:Close() end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRoomTeamPrefab/XUiGridTeam.lua b/Resources/Scripts/XUi/XUiRoomTeamPrefab/XUiGridTeam.lua new file mode 100644 index 00000000..b7975843 --- /dev/null +++ b/Resources/Scripts/XUi/XUiRoomTeamPrefab/XUiGridTeam.lua @@ -0,0 +1,237 @@ +local CSXTextManagerGetText = CS.XTextManager.GetText + +local XUiGridTeam = XClass(nil, "XUiGridTeam") + +function XUiGridTeam:Ctor(rootUi, ui, characterLimitType, limitBuffId, stageType, teamGridId) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.StageType = stageType + self:AddListener() + self:InitFirstFightTabBtnGroup() + self.GridTeamRole.gameObject:SetActive(false) + self.TeamRoles = {} + self.CharacterLimitType = characterLimitType + self.LimitBuffId = limitBuffId + self.TeamGridId = teamGridId +end + +function XUiGridTeam:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiGridTeam:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiGridTeam:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiGridTeam:AddListener() + if self:IsChessPursuit() then + self:RegisterClickEvent(self.BtnChoices, self.OnChessPursuitBtnChoicesClick) + else + self:RegisterClickEvent(self.BtnChoices, self.OnBtnChoicesClick) + end + + self.BtnCaptain.CallBack = function() + self:OnBtnCaptainClick() + end + self.BtnReName.CallBack = function() + self:OnBtnReNameClick() + end +end + +function XUiGridTeam:InitFirstFightTabBtnGroup() + local tabGroup = { + self.BtnRed, + self.BtnBlue, + self.BtnYellow, + } + self.PanelTabFirstFight:Init(tabGroup, function(tabIndex) self:OnFirstFightTabClick(tabIndex) end) +end + +--- +--- 设置首发位 +function XUiGridTeam:OnFirstFightTabClick(tabIndex) + if self.TeamData.FirstFightPos == tabIndex then + return + end + + self.TeamData.FirstFightPos = tabIndex + XDataCenter.TeamManager.SetPlayerTeam(self.TeamData, true) + self:RefreshTeamRoles() +end + +--- +--- 设置队长 +function XUiGridTeam:SelectCaptain(index) + if self.TeamData.CaptainPos == index then + return + end + + self.TeamData.CaptainPos = index + XDataCenter.TeamManager.SetPlayerTeam(self.TeamData, true) + self:RefreshTeamRoles() +end + +function XUiGridTeam:Refresh(teamData, index) + self:HandleCharacterType(teamData) + self.TeamData = teamData + self:SetName(teamData.TeamName or CS.XTextManager.GetText("TeamPrefabDefaultName", index)) + self.PanelTabFirstFight:SelectIndex(teamData.FirstFightPos) + self:RefreshTeamRoles() +end + +function XUiGridTeam:SetName(name) + self.TextName.text = name +end + +function XUiGridTeam:ChangeName(confirmName, closeCb) + local teamData = {} + teamData.TeamId = self.TeamData.TeamId + teamData.CaptainPos = self.TeamData.CaptainPos + teamData.FirstFightPos = self.TeamData.FirstFightPos + teamData.TeamData = self.TeamData.TeamData + teamData.TeamName = confirmName + + XDataCenter.TeamManager.SetPlayerTeam(teamData, true, function() + self.TeamData.TeamName = confirmName + self:SetName(confirmName) + if closeCb then + closeCb() + end + end) +end + +function XUiGridTeam:HandleCharacterType(teamData) + local characterType = 0 + for _, charId in ipairs(teamData.TeamData) do + if charId > 0 then + local charTemplate = XCharacterConfigs.GetCharacterTemplate(charId) + if charTemplate then + characterType = charTemplate.Type + break + end + end + end + self.CharacterType = characterType +end + +function XUiGridTeam:RefreshTeamRoles() + self:RefreshRoleGrid(2) + self:RefreshRoleGrid(1) + self:RefreshRoleGrid(3) +end + +function XUiGridTeam:RefreshRoleGrid(pos) + local grid = self.TeamRoles[pos] + if not grid then + local item = CS.UnityEngine.Object.Instantiate(self.GridTeamRole) + grid = XUiGridTeamRole.New(self.RootUi, item) + grid.Transform:SetParent(self.PanelCharContent, false) + grid.GameObject:SetActive(true) + self.TeamRoles[pos] = grid + end + + local characterLimitType = self.CharacterLimitType + local limitBuffId = self.LimitBuffId + grid:Refresh(pos, self.TeamData, characterLimitType, limitBuffId) +end + +function XUiGridTeam:SetSelectFasle(pos) + self.TeamRoles[pos]:SetSelect(false) + self.TeamRoles[pos].IsClick = false +end + +function XUiGridTeam:OnChessPursuitBtnChoicesClick() + local isInOtherTeam = false + local isInOtherTeamTemp, teamGridIndex, teamIndex, inOtherTeamCharId + local teamData = XTool.Clone(self.TeamData.TeamData) + table.sort(teamData, function(charIdA, charIdB) + return charIdA < charIdB + end) + for _, charId in ipairs(teamData) do + isInOtherTeamTemp, teamGridIndex = XDataCenter.ChessPursuitManager.CheckIsInChessPursuit(nil, charId, self.TeamGridId) + if isInOtherTeamTemp then + inOtherTeamCharId = charId + isInOtherTeam = true + break + end + end + if isInOtherTeam then + local name = XCharacterConfigs.GetCharacterFullNameStr(inOtherTeamCharId) + local content = CSXTextManagerGetText("ChessPursuitUsePrefabTipsContent", name, teamGridIndex) + content = string.gsub(content, " ", "\u{00A0}") --不换行空格 + XUiManager.DialogTip(nil, content, XUiManager.DialogType.Normal, nil, function() self:OnBtnChoicesClick() end) + return + end + + self:OnBtnChoicesClick() +end + +function XUiGridTeam:OnBtnChoicesClick() + local characterLimitType = self.CharacterLimitType + local limitBuffId = self.LimitBuffId + local characterType = self.CharacterType + + local selectFunc = function() + XEventManager.DispatchEvent(XEventId.EVENT_TEAM_PREFAB_SELECT, self.TeamData) + self.RootUi:Close() + end + + if characterLimitType == XFubenConfigs.CharacterLimitType.Normal then + if characterType == XCharacterConfigs.CharacterType.Isomer then + XUiManager.TipText("TeamCharacterTypeNormalLimitText") + return + end + elseif characterLimitType == XFubenConfigs.CharacterLimitType.Isomer then + if characterType == XCharacterConfigs.CharacterType.Normal then + XUiManager.TipText("TeamCharacterTypeIsomerLimitText") + return + end + elseif characterLimitType == XFubenConfigs.CharacterLimitType.IsomerDebuff then + if characterType == XCharacterConfigs.CharacterType.Isomer then + local buffDes = XFubenConfigs.GetBuffDes(limitBuffId) + local content = CSXTextManagerGetText("TeamPrefabCharacterTypeLimitTipIsomerDebuff", buffDes) + local sureCallBack = selectFunc + XUiManager.DialogTip(nil, content, XUiManager.DialogType.Normal, nil, sureCallBack) + return + end + elseif characterLimitType == XFubenConfigs.CharacterLimitType.NormalDebuff then + if characterType == XCharacterConfigs.CharacterType.Normal then + local buffDes = XFubenConfigs.GetBuffDes(limitBuffId) + local content = CSXTextManagerGetText("TeamPrefabCharacterTypeLimitTipNormalDebuff", buffDes) + local sureCallBack = selectFunc + XUiManager.DialogTip(nil, content, XUiManager.DialogType.Normal, nil, sureCallBack) + return + end + end + + selectFunc() +end + +function XUiGridTeam:OnBtnCaptainClick() + XLuaUiManager.Open("UiNewRoomSingleTip", self, self.TeamData.TeamData, self.TeamData.CaptainPos, function(index) + self:SelectCaptain(index) + end) +end + +function XUiGridTeam:OnBtnReNameClick() + XLuaUiManager.Open("UiTeamPrefabReName", function(newName, closeCb) + self:ChangeName(newName, closeCb) + end) +end + +function XUiGridTeam:IsChessPursuit() + return self.StageType == XDataCenter.FubenManager.StageType.ChessPursuit +end + +return XUiGridTeam \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRoomTeamPrefab/XUiGridTeamCharacter.lua b/Resources/Scripts/XUi/XUiRoomTeamPrefab/XUiGridTeamCharacter.lua new file mode 100644 index 00000000..e26b911b --- /dev/null +++ b/Resources/Scripts/XUi/XUiRoomTeamPrefab/XUiGridTeamCharacter.lua @@ -0,0 +1,55 @@ +local XUiGridTeamCharacter = XClass(nil, "XUiGridTeamCharacter") + +function XUiGridTeamCharacter:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self:InitAutoScript() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiGridTeamCharacter:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiGridTeamCharacter:AutoInitUi() + self.PanelSelected = self.Transform:Find("PanelSelected") + self.ImgSelected = self.Transform:Find("PanelSelected/ImgSelected"):GetComponent("Image") + self.PanelHead = self.Transform:Find("PanelHead") + self.ImgeHeadIconBg = self.Transform:Find("PanelHead/ImgeHeadIconBg"):GetComponent("Image") + self.ImgHeadIcon = self.Transform:Find("PanelHead/ImgHeadIcon"):GetComponent("Image") + self.PanelLevel = self.Transform:Find("PanelLevel") + self.TxtLevelA = self.Transform:Find("PanelLevel/TxtLevel"):GetComponent("Text") + self.ImgInTeam = self.Transform:Find("ImgInTeam"):GetComponent("Image") + self.ImgQualityA = self.Transform:Find("ImgQuality"):GetComponent("Image") + self.BtnCharacter = self.Transform:Find("BtnCharacter"):GetComponent("Button") +end + +function XUiGridTeamCharacter:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiGridTeamCharacter:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiGridTeamCharacter:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiGridTeamCharacter:AutoAddListener() + self:RegisterClickEvent(self.BtnCharacter, self.OnBtnCharacterClick) +end +-- auto + +function XUiGridTeamCharacter:OnBtnCharacterClick() + +end + +return XUiGridTeamCharacter \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRoomTeamPrefab/XUiGridTeamRole.lua b/Resources/Scripts/XUi/XUiRoomTeamPrefab/XUiGridTeamRole.lua new file mode 100644 index 00000000..b907bbfb --- /dev/null +++ b/Resources/Scripts/XUi/XUiRoomTeamPrefab/XUiGridTeamRole.lua @@ -0,0 +1,92 @@ +XUiGridTeamRole = XClass(nil, "XUiGridTeamRole") + +function XUiGridTeamRole:Ctor(rootUi, ui) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:AddListener() +end + +function XUiGridTeamRole:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiGridTeamRole:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiGridTeamRole:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiGridTeamRole:AddListener() + self:RegisterClickEvent(self.BtnPlus, self.OnBtnClickClick) + self:RegisterClickEvent(self.BtnClick, self.OnBtnClickClick) +end +-- auto +function XUiGridTeamRole:SetNull() + self.ImgLeftnull.color = XDataCenter.TeamManager.GetTeamMemberColor(self.CurPos) + self.ImgRightnull.color = XDataCenter.TeamManager.GetTeamMemberColor(self.CurPos) + + self.PanelHave.gameObject:SetActive(false) + self.PanelNull.gameObject:SetActive(true) +end + +function XUiGridTeamRole:SetHave(chrId) + self.PanelHave.gameObject:SetActive(true) + self.PanelNull.gameObject:SetActive(false) + local character = XDataCenter.CharacterManager.GetCharacter(chrId) + if not character then return end + + self.ImgLeftSkill.color = XDataCenter.TeamManager.GetTeamMemberColor(self.CurPos) + self.ImgRightSkill.color = XDataCenter.TeamManager.GetTeamMemberColor(self.CurPos) + self.RootUi:SetUiSprite(self.ImgIcon, XDataCenter.CharacterManager.GetCharBigHeadIcon(character.Id)) + self.RootUi:SetUiSprite(self.ImgQuality, XCharacterConfigs.GetCharacterQualityIcon(character.Quality)) +end + +function XUiGridTeamRole:Refresh(curPos, teamData, characterLimitType, limitBuffId) + self.CharacterLimitType = characterLimitType + self.LimitBuffId = limitBuffId + self.CurPos = curPos + self.TeamData = teamData + local chrId = teamData.TeamData[curPos] + + self.IconLeader.gameObject:SetActiveEx(teamData.CaptainPos == self.CurPos) + self.IconFirstFight.gameObject:SetActiveEx(teamData.FirstFightPos == self.CurPos) + + if chrId > 0 then + self:SetHave(chrId) + else + self:SetNull() + end +end + +function XUiGridTeamRole:OnSelect(teamData) + local firstCharPos + local charCount = 0 + + self.TeamData.TeamData = teamData + for pos, charId in ipairs(self.TeamData.TeamData) do + if charId > 0 then + firstCharPos = pos + charCount = charCount + 1 + end + end + + if charCount == 1 then + self.TeamData.CaptainPos = firstCharPos + self.TeamData.FirstFightPos = firstCharPos + end + + XDataCenter.TeamManager.SetPlayerTeam(self.TeamData, true) +end + +function XUiGridTeamRole:OnBtnClickClick() + XLuaUiManager.Open("UiRoomCharacter", self.TeamData.TeamData, self.CurPos, handler(self, self.OnSelect), nil, self.CharacterLimitType, {LimitBuffId = self.LimitBuffId}) +end diff --git a/Resources/Scripts/XUi/XUiRoomTeamPrefab/XUiPanelTeamSelect.lua b/Resources/Scripts/XUi/XUiRoomTeamPrefab/XUiPanelTeamSelect.lua new file mode 100644 index 00000000..6d6e27a6 --- /dev/null +++ b/Resources/Scripts/XUi/XUiRoomTeamPrefab/XUiPanelTeamSelect.lua @@ -0,0 +1,180 @@ +XUiPanelTeamSelect = XClass(nil, "XUiPanelTeamSelect") + +function XUiPanelTeamSelect:Ctor(rootUi, ui) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + self:InitAutoScript() + self.CharacterGrids = {} + self:SetCharacterList() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelTeamSelect:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiPanelTeamSelect:AutoInitUi() + self.GridTeamCharacter = self.Transform:Find("CharacterList/Viewport/GridTeamCharacter") + self.PanelCharacterContent = self.Transform:Find("CharacterList/Viewport/PanelCharacterContent") + self.BtnCharDelete = self.Transform:Find("BtnCharDelete"):GetComponent("Button") + self.BtnCharSelect = self.Transform:Find("BtnCharSelect"):GetComponent("Button") +end + +function XUiPanelTeamSelect:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelTeamSelect:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelTeamSelect:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelTeamSelect:AutoAddListener() + self:RegisterClickEvent(self.BtnCharDelete, self.OnBtnCharDeleteClick) + self:RegisterClickEvent(self.BtnCharSelect, self.OnBtnCharSelectClick) +end +-- auto +function XUiPanelTeamSelect:ShowPanel(curPos, teamData, index, cb) + self.TeamSelectPos = curPos + self.TeamData = teamData + self.IndexTeamPrefab = index + self.Callback = cb + self.CurChangeId = self.TeamData.TeamData[self.TeamSelectPos] + self:UpdateCharaterInTeam() + self:UpdateTeamBtn() + self.GameObject:SetActive(true) + + -- 播放界面动画 + -- XUiHelper.PlayAnimation(parntUi, "RoomTeamPreTeamSelectIn", nil, nil) +end + + + +function XUiPanelTeamSelect:SetCharacterList() + local baseItem = self.GridTeamCharacter + baseItem.gameObject:SetActive(false) + local charList = XDataCenter.CharacterManager.GetSpecilOwnCharacterList() + + local count = #charList + + for i = 1, count do + local char = charList[i] + local grid = self.CharacterGrids[char.Id] + if not grid then + local item = CS.UnityEngine.Object.Instantiate(baseItem) + grid = XUiGridCharacter.New(item, self.RootUi, char, function(character) + self:UpdateInfo(character) + end) + grid.GameObject.name = char.Id + grid.Transform:SetParent(self.PanelCharacterContent, false) + self.CharacterGrids[char.Id] = grid + else + grid:UpdateGrid(char) + grid.GameObject.name = char.Id + end + grid:SetSelect(false) + grid.GameObject:SetActive(true) + grid.Transform:SetAsLastSibling() + end +end + +function XUiPanelTeamSelect:UpdateInfo(character) + if character then + self.CurCharacter = character + end + + if self.CurCharacterGrid then + self.CurCharacterGrid:SetSelect(false) + end + + self.CurCharacterGrid = self.CharacterGrids[self.CurCharacter.Id] + self.CurCharacterGrid:UpdateGrid() + self.CurCharacterGrid:SetSelect(true) + + self:UpdateTeamBtn() +end + +function XUiPanelTeamSelect:UpdateTeamBtn() + if not self.CurCharacter then + self.BtnCharDelete.gameObject:SetActive(false) + self.BtnCharSelect.gameObject:SetActive(false) + return + end + + local isInTeam = self.CurChangeId == self.CurCharacter.Id + + self.BtnCharDelete.gameObject:SetActive(isInTeam) + self.BtnCharSelect.gameObject:SetActive(not isInTeam) +end + +function XUiPanelTeamSelect:UpdateCharaterInTeam() + for _, item in pairs(self.CharacterGrids) do + local isInTeam = false + for _, v in pairs(self.TeamData.TeamData) do + if item.Character.Id == v then + isInTeam = true + break + end + end + item:SetInTeam(isInTeam) + end +end + +function XUiPanelTeamSelect:HidePanel(cb) + -- 播放界面动画 + -- local onFinish = function() + -- self.GameObject:SetActive(false) + -- if cb then cb() end + -- end + -- XUiHelper.PlayAnimation(parntUi, "RoomTeamPreTeamSelectOut", nil, onFinish) + self.GameObject:SetActive(false) + if cb then cb() end +end + +function XUiPanelTeamSelect:OnBtnCharSelectClick() + -- 判断编队中是否有此角色 + local teamMap = self.TeamData.TeamData + local isHave = false + local exchagePos = 0 + for k, v in pairs(teamMap) do + if self.CurCharacter.Id == v then + isHave = true + exchagePos = k + break + end + end + + -- 设置角色对换 + if isHave then + self.TeamData.TeamData[exchagePos] = self.TeamData.TeamData[self.TeamSelectPos] + end + + self:OnService(false, exchagePos) +end + +function XUiPanelTeamSelect:OnBtnCharDeleteClick() + self:OnService(true, 0) +end + +function XUiPanelTeamSelect:OnService(isDelete, exchagePos) + self.TeamData.TeamData[self.TeamSelectPos] = isDelete and 0 or self.CurCharacter.Id + self.CurChangeId = self.TeamData.TeamData[self.TeamSelectPos] + XDataCenter.TeamManager.SetPlayerTeam(self.TeamData, true, function() + self:UpdateCharaterInTeam() + self:UpdateTeamBtn() + if self.Callback then + self.Callback(self.TeamSelectPos, self.TeamData, isDelete, self.IndexTeamPrefab, exchagePos) + end + end) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRoomTeamPrefab/XUiRoomTeamPrefab.lua b/Resources/Scripts/XUi/XUiRoomTeamPrefab/XUiRoomTeamPrefab.lua new file mode 100644 index 00000000..944ef392 --- /dev/null +++ b/Resources/Scripts/XUi/XUiRoomTeamPrefab/XUiRoomTeamPrefab.lua @@ -0,0 +1,97 @@ +local XUiGridTeam = require("XUi/XUiRoomTeamPrefab/XUiGridTeam") +local MAX_PREFAB_NUM = CS.XGame.Config:GetInt("MaxTeamPrefab") + +local XUiRoomTeamPrefab = XLuaUiManager.Register(XLuaUi, "UiRoomTeamPrefab") + +function XUiRoomTeamPrefab:OnAwake() + self:AddListener() +end + +function XUiRoomTeamPrefab:OnStart(captainPos, firstFightPos, characterLimitType, limitBuffId, stageType, teamGridId, closeCb) + self.CaptainPos = captainPos + self.FirstFightPos = firstFightPos + self.CharacterLimitType = characterLimitType + self.LimitBuffId = limitBuffId + self.StageType = stageType + self.TeamGridId = teamGridId + self.CloseCb = closeCb + self.TeamPrefabs = {} + self:RefreshTeamList() + XEventManager.AddEventListener(XEventId.EVENT_TEAM_PREFAB_CHANGE, self.OnTeamPrefabChange, self) +end + +function XUiRoomTeamPrefab:OnDestroy() + XEventManager.RemoveEventListener(XEventId.EVENT_TEAM_PREFAB_CHANGE, self.OnTeamPrefabChange, self) + if self.CloseCb then + self.CloseCb() + end +end + +function XUiRoomTeamPrefab:OnTeamPrefabChange(index, teamData) + if self.TeamPrefabs[index] then + self.TeamPrefabs[index]:Refresh(teamData, index) + end +end + +function XUiRoomTeamPrefab:AddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) +end + +function XUiRoomTeamPrefab:NewTeamGrid() + local item = CS.UnityEngine.Object.Instantiate(self.GridTeam) + local characterLimitType = self.CharacterLimitType + local limitBuffId = self.LimitBuffId + local stageType = self.StageType + local teamGridId = self.TeamGridId + local grid = XUiGridTeam.New(self, item, characterLimitType, limitBuffId, stageType, teamGridId) + grid.Transform:SetParent(self.PanelTeamContent, false) + grid.GameObject:SetActive(true) + return grid +end + +function XUiRoomTeamPrefab:GetSimpleTeamData(index) + local maxPos = XDataCenter.TeamManager.GetMaxPos() + local teamData = {} + teamData.TeamId = index + teamData.CaptainPos = XDataCenter.TeamManager.GetCaptainPos() + teamData.FirstFightPos = XDataCenter.TeamManager.GetFirstFightPos() + teamData.TeamName = CS.XTextManager.GetText("TeamPrefabDefaultName", index) + teamData.TeamData = {} + for idx = 1, maxPos do + teamData.TeamData[idx] = 0 + end + return teamData +end + +function XUiRoomTeamPrefab:RefreshTeamList() + self.GridTeam.gameObject:SetActive(false) + local teamDataList = XDataCenter.TeamManager.GetTeamPrefabData() + + for i = 1, MAX_PREFAB_NUM do + local grid = self.TeamPrefabs[i] + if not grid then + grid = self:NewTeamGrid(i) + self.TeamPrefabs[i] = grid + end + local teamData = teamDataList[i] or self:GetSimpleTeamData(i) + + if not teamData.CaptainPos + or teamData.CaptainPos < 1 + or teamData.CaptainPos > 3 then + XLog.Error("XUiRoomTeamPrefab:RefreshTeamList函数错误,teamData的CaptainPos数据不正确") + teamData.CaptainPos = 1 + end + if not teamData.FirstFightPos + or teamData.FirstFightPos < 1 + or teamData.FirstFightPos > 3 then + XLog.Error("XUiRoomTeamPrefab:RefreshTeamList函数错误,teamData的FirstFightPos数据不正确") + teamData.FirstFightPos = 1 + end + + grid:Refresh(teamData, i) + end +end + +function XUiRoomTeamPrefab:OnBtnBackClick() + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRoomTeamPrefab/XUiTeamPrefabReName.lua b/Resources/Scripts/XUi/XUiRoomTeamPrefab/XUiTeamPrefabReName.lua new file mode 100644 index 00000000..89fa9022 --- /dev/null +++ b/Resources/Scripts/XUi/XUiRoomTeamPrefab/XUiTeamPrefabReName.lua @@ -0,0 +1,45 @@ +local XUiTeamPrefabReName = XLuaUiManager.Register(XLuaUi, "UiTeamPrefabReName") + +local CSXTextManagerGetText = CS.XTextManager.GetText +local MaxNameLength = CS.XGame.Config:GetInt("TeamPrefabNameLength") + +function XUiTeamPrefabReName:OnAwake() + self:AddListener() +end + +function XUiTeamPrefabReName:OnStart(confirmCb) + self.ConfirmCb = confirmCb +end + +function XUiTeamPrefabReName:AddListener() + self.BtnClose.CallBack = function() + self:Close() + end + self.BtnTanchuangClose.CallBack = function() + self:Close() + end + self.BtnNameCancel.CallBack = function() + self:Close() + end + self.BtnNameSure.CallBack = function() + self:OnBtnNameSure() + end +end + +function XUiTeamPrefabReName:OnBtnNameSure() + local editName = string.gsub(self.InFSigm.text, "^%s*(.-)%s*$", "%1") + + if string.len(editName) > 0 then + local utf8Count = self.InFSigm.textComponent.cachedTextGenerator.characterCount - 1 + if utf8Count > MaxNameLength then + XUiManager.TipError(CSXTextManagerGetText("MaxNameLengthTips", MaxNameLength)) + return + end + self.ConfirmCb(editName, function() + XUiManager.TipText("TeamPrefabRenameSuc") + self:Close() + end) + else + XUiManager.TipError(CSXTextManagerGetText("TeamPrefabWithoutName")) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgMakerGame/Character/XUiRpgMakerGameCharacter.lua b/Resources/Scripts/XUi/XUiRpgMakerGame/Character/XUiRpgMakerGameCharacter.lua new file mode 100644 index 00000000..2e1cbdaa --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgMakerGame/Character/XUiRpgMakerGameCharacter.lua @@ -0,0 +1,172 @@ +local XUiRpgMakerGameCharacterGrid = require("XUi/XUiRpgMakerGame/Character/XUiRpgMakerGameCharacterGrid") + +local CSXTextManagerGetText = CS.XTextManager.GetText + +local XUiRpgMakerGameCharacter = XLuaUiManager.Register(XLuaUi, "UiRpgMakerGameCharacter") + +function XUiRpgMakerGameCharacter:OnAwake() + self:AutoAddListener() + self:InitDynamicTable() + self:InitSceneRoot() + + self.GridCharacterNew.gameObject:SetActiveEx(false) +end + +function XUiRpgMakerGameCharacter:OnStart(stageId) + self.StageId = stageId +end + +function XUiRpgMakerGameCharacter:OnEnable() + local characterId = self:GetCharacterId() + self:UpdateCurCharacterInfo(characterId) + self.DynamicTable:ReloadDataSync() +end + +function XUiRpgMakerGameCharacter:AutoAddListener() + self:RegisterClickEvent(self.BtnBack, self.Close) + self:RegisterClickEvent(self.BtnMainUi, function() XLuaUiManager.RunMain() end) + self:BindHelpBtn(self.BtnHelp, "RpgMakerGame") + self.BtnEnterFight.CallBack = handler(self, self.OnBtnEnterFightClick) +end + +function XUiRpgMakerGameCharacter:InitSceneRoot() + local root = self.UiModelGo.transform + + self.PanelRoleModel = root:FindTransform("PanelRoleModel") + self.ImgEffectHuanren = root:FindTransform("ImgEffectHuanren") + self.ImgEffectHuanren1 = root:FindTransform("ImgEffectHuanren1") + self.ImgEffectLogoGouzao = root:FindTransform("ImgEffectLogoGouzao") + self.ImgEffectLogoGanran = root:FindTransform("ImgEffectLogoGanran") + self.CameraFar = { + root:FindTransform("UiCamFarLv"), + root:FindTransform("UiCamFarGrade"), + root:FindTransform("UiCamFarQuality"), + root:FindTransform("UiCamFarSkill"), + root:FindTransform("UiCamFarrExchange"), + } + self.CameraNear = { + root:FindTransform("UiCamNearLv"), + root:FindTransform("UiCamNearGrade"), + root:FindTransform("UiCamNearQuality"), + root:FindTransform("UiCamNearSkill"), + root:FindTransform("UiCamNearrExchange"), + } + self.RoleModelPanel = XUiPanelRoleModel.New(self.PanelRoleModel, self.Name, nil, true, nil, true) + self.RoleModelPanel:SetDefaultAnimation("Stand1") +end + +function XUiRpgMakerGameCharacter:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.SViewCharacterList) + self.DynamicTable:SetDelegate(self) + self.DynamicTable:SetProxy(XUiRpgMakerGameCharacterGrid) + + self.CharacterList = XRpgMakerGameConfigs.GetRpgMakerGameRoleIdList() + self.CharacterId = XDataCenter.RpgMakerGameManager.GetOnceUnLockRoleId() + self.DynamicTable:SetDataSource(self.CharacterList) +end + +function XUiRpgMakerGameCharacter:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local characterId = self.CharacterList[index] + local currSelectCharId = self:GetCharacterId() + if currSelectCharId == characterId then + self.CurSelectGrid = grid + end + grid:Refresh(characterId) + grid:SetSelect(currSelectCharId == characterId) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + local characterId = self.CharacterList[index] + local currSelectCharId = self:GetCharacterId() + if currSelectCharId ~= characterId then + if self.CurSelectGrid then + self.CurSelectGrid:SetSelect(false) + end + grid:SetSelect(true) + self.CurSelectGrid = grid + self:UpdateCurCharacterInfo(characterId) + self:UpdateBtnEnterFightState(characterId) + self:PlaySwitchAnima(currSelectCharId, characterId) + self:CheckOpenTips(characterId) + end + end +end + +function XUiRpgMakerGameCharacter:CheckOpenTips(characterId) + local isUnlock, desc = XDataCenter.RpgMakerGameManager.IsUnlockRole(characterId) + if not isUnlock then + XUiManager.TipMsg(desc) + end +end + +function XUiRpgMakerGameCharacter:PlaySwitchAnima(oldCharacterId, newCharacterId) + self:PlayAnimation("QieHuan1") + + local isUnlockRoleOld = XDataCenter.RpgMakerGameManager.IsUnlockRole(oldCharacterId) + local isUnlockRoleNew = XDataCenter.RpgMakerGameManager.IsUnlockRole(newCharacterId) + + if isUnlockRoleNew then + self.ImgEffectHuanren.gameObject:SetActiveEx(false) + self.ImgEffectHuanren.gameObject:SetActiveEx(true) + end + + --从3d角色(已解锁)切换到2d立绘(未解锁)播放的动画 + if not isUnlockRoleNew and isUnlockRoleOld ~= isUnlockRoleNew then + self:PlayAnimation("QieHuan2") + end +end + +function XUiRpgMakerGameCharacter:UpdateBtnEnterFightState(characterId) + local isUnlockRole, desc = XDataCenter.RpgMakerGameManager.IsUnlockRole(characterId) + self.BtnEnterFight:SetDisable(not isUnlockRole, isUnlockRole) + self.TextStyleTitle.gameObject:SetActiveEx(isUnlockRole) + if not isUnlockRole then + self.BtnEnterFight:SetNameByGroup(1, desc) + end +end + +function XUiRpgMakerGameCharacter:UpdateCurCharacterInfo(characterId) + local isUnlockRole = XDataCenter.RpgMakerGameManager.IsUnlockRole(characterId) + self.CharacterId = characterId + self.TextName.text = isUnlockRole and XRpgMakerGameConfigs.GetRpgMakerGameRoleName(characterId) or CSXTextManagerGetText("RpgMakerGameCharacterLockName") + self.TextStyle.text = isUnlockRole and XRpgMakerGameConfigs.GetRpgMakerGameRoleStyle(characterId) or "" + self.TextInfoName.text = isUnlockRole and XRpgMakerGameConfigs.GetRpgMakerGameRoleInfoName(characterId) or CSXTextManagerGetText("RpgMakerGameCharacterLockInfoTitle") + self.TextInfo.text = isUnlockRole and XRpgMakerGameConfigs.GetRpgMakerGameRoleInfo(characterId) or CSXTextManagerGetText("RpgMakerGameCharacterLockInfoDesc") + self:UpdateModel(characterId) +end + +function XUiRpgMakerGameCharacter:UpdateModel(characterId) + local isUnlockRole = XDataCenter.RpgMakerGameManager.IsUnlockRole(characterId) + self.PanelDrag.gameObject:SetActiveEx(isUnlockRole) + if self.PanelDragLock then + self.PanelDragLock.gameObject:SetActiveEx(not isUnlockRole) + end + + if not isUnlockRole then + self.RoleModelPanel:HideRoleModel() + return + end + + local modelName = XRpgMakerGameConfigs.GetRpgMakerGameRoleModelAssetPath(characterId) + self.RoleModelPanel:UpdateRoleModel(modelName, self.PanelRoleModel, XModelManager.MODEL_UINAME.XUiCharacter, function(model) + self.PanelDrag.Target = model.transform + end, nil, true, true) + self.RoleModelPanel:ShowRoleModel() +end + +function XUiRpgMakerGameCharacter:OnBtnEnterFightClick() + local stageId = self:GetStageId() + local characterId = self:GetCharacterId() + local cb = function() + XLuaUiManager.Remove("UiRpgMakerGameDetail") + XLuaUiManager.PopThenOpen("UiRpgMakerGamePlayMain") + end + XDataCenter.RpgMakerGameManager.RequestRpgMakerGameEnterStage(stageId, characterId, cb) +end + +function XUiRpgMakerGameCharacter:GetCharacterId() + return self.CharacterId +end + +function XUiRpgMakerGameCharacter:GetStageId() + return self.StageId +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgMakerGame/Character/XUiRpgMakerGameCharacterGrid.lua b/Resources/Scripts/XUi/XUiRpgMakerGame/Character/XUiRpgMakerGameCharacterGrid.lua new file mode 100644 index 00000000..56630958 --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgMakerGame/Character/XUiRpgMakerGameCharacterGrid.lua @@ -0,0 +1,31 @@ +local XUiRpgMakerGameCharacterGrid = XClass(nil, "XUiRpgMakerGameCharacterGrid") + +function XUiRpgMakerGameCharacterGrid:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiRpgMakerGameCharacterGrid:Refresh(characterId) + local isUnlock = XDataCenter.RpgMakerGameManager.IsUnlockRole(characterId) + self.ImgLock.gameObject:SetActiveEx(not isUnlock) + + local headPath = isUnlock and XRpgMakerGameConfigs.GetRpgMakerGameRoleHeadPath(characterId) or CS.XGame.ClientConfig:GetString("RpgMakerGameRoleUnLockHeadPath") + self.RImgHeadIcon:SetRawImage(headPath) + + local name = XRpgMakerGameConfigs.GetRpgMakerGameRoleName(characterId) + self.TextName1.text = isUnlock and name or "" + + local style = XRpgMakerGameConfigs.GetRpgMakerGameRoleStyle(characterId) + self.TextName2.text = isUnlock and style or "" + + self.ImgRedPoint.gameObject:SetActiveEx(false) +end + +function XUiRpgMakerGameCharacterGrid:SetSelect(isSelect) + if self.PanelSelected then + self.PanelSelected.gameObject:SetActiveEx(isSelect) + end +end + +return XUiRpgMakerGameCharacterGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgMakerGame/Hint/XUiGridRpgMakerGameCardMini.lua b/Resources/Scripts/XUi/XUiRpgMakerGame/Hint/XUiGridRpgMakerGameCardMini.lua new file mode 100644 index 00000000..9bf09fd3 --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgMakerGame/Hint/XUiGridRpgMakerGameCardMini.lua @@ -0,0 +1,94 @@ +local XUiGridRpgMakerGameCardMini = XClass(nil, "XUiGridRpgMakerGameCardMini") + +local Vector3 = CS.UnityEngine.Vector3 +local LookRotation = CS.UnityEngine.Quaternion.LookRotation + +--提示说明地图上节点的小图标 +function XUiGridRpgMakerGameCardMini:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + + XTool.InitUiObject(self) +end + +function XUiGridRpgMakerGameCardMini:Refresh(blockId, colIndex, blockStatus, mapId) + local isBlock = blockStatus == XRpgMakerGameConfigs.XRpgMakerGameBlockStatus.Block + local row = XRpgMakerGameConfigs.GetRpgMakerGameBlockRow(blockId) + local monsterId = XRpgMakerGameConfigs.GetRpgMakerGameMonsterId(mapId, colIndex, row) + local isStartPoint = XRpgMakerGameConfigs.IsRpgMakerGameStartPoint(mapId, colIndex, row) + local isEndPoint = XRpgMakerGameConfigs.IsRpgMakerGameEndPoint(mapId, colIndex, row) + local triggerId = XRpgMakerGameConfigs.GetRpgMakerGameTriggerId(mapId, colIndex, row) + local sameXYGapIdList = XRpgMakerGameConfigs.GetRpgMakerGameSameXYGapIdIdList(mapId, colIndex, row) + + --设置移动路线图标 + local isShowMoveLine = XRpgMakerGameConfigs.IsRpgMakerGameHintShowMoveLine(mapId, row, colIndex) + if isShowMoveLine then + local moveLineIcon = XRpgMakerGameConfigs.GetRpgMakerGameHintIcon("MoveLineIcon") + self.ImageLine:SetRawImage(moveLineIcon) + self.ImageLine.gameObject:SetActiveEx(true) + else + self.ImageLine.gameObject:SetActiveEx(false) + end + + local icon + if isBlock then + icon = XRpgMakerGameConfigs.GetRpgMakerGameHintIcon("BlockIcon") + elseif monsterId then + local monsterType = XRpgMakerGameConfigs.GetRpgMakerGameMonsterType(monsterId) + icon = XRpgMakerGameConfigs.GetNormalMonsterIcon(monsterType) + elseif isStartPoint then + icon = XRpgMakerGameConfigs.GetRpgMakerGameHintIcon("StartPointIcon") + elseif isEndPoint then + icon = XRpgMakerGameConfigs.GetRpgMakerGameHintIcon("EndPointIcon") + elseif triggerId then + local triggerType = XRpgMakerGameConfigs.GetRpgMakerGameTriggerType(triggerId) + icon = XRpgMakerGameConfigs.GetTriggerIcon(triggerType) + end + + --设置缝隙图标列表 + if not XTool.IsTableEmpty(sameXYGapIdList) then + self:SetGapIcon(sameXYGapIdList) + end + + if icon then + self.ImgIcon:SetRawImage(icon) + self.ImgIcon.gameObject:SetActiveEx(true) + else + self.ImgIcon.gameObject:SetActiveEx(false) + end +end + +function XUiGridRpgMakerGameCardMini:SetGapIcon(sameXYGapIdList) + local icon = XRpgMakerGameConfigs.GetRpgMakerGameHintIcon("GapIcon") + local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate + local imgIcon + local direction + local gapSize = self.ImgIcon.transform.sizeDelta + local originPos = self.ImgIcon.transform.localPosition + local directionPos + local lookRotation + + for i, gapId in ipairs(sameXYGapIdList) do + direction = XRpgMakerGameConfigs.GetRpgMakerGameGapDirection(gapId) + imgIcon = CSUnityEngineObjectInstantiate(self.ImgIcon, self.Transform) + if direction == XRpgMakerGameConfigs.RpgMakerGapDirection.GridLeft then + directionPos = originPos - Vector3(gapSize.x / 2, 0, 0) + elseif direction == XRpgMakerGameConfigs.RpgMakerGapDirection.GridRight then + directionPos = originPos + Vector3(gapSize.x / 2, 0, 0) + elseif direction == XRpgMakerGameConfigs.RpgMakerGapDirection.GridTop then + directionPos = originPos + Vector3(0, gapSize.y / 2, 0) + elseif direction == XRpgMakerGameConfigs.RpgMakerGapDirection.GridBottom then + directionPos = originPos - Vector3(0, gapSize.y / 2, 0) + end + + if directionPos then + imgIcon.transform.localPosition = directionPos + imgIcon.transform.up = originPos - directionPos + end + imgIcon:SetRawImage(icon) + imgIcon.gameObject:SetActiveEx(true) + end +end + +return XUiGridRpgMakerGameCardMini \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgMakerGame/Hint/XUiGridRpgMakerGameMapNode.lua b/Resources/Scripts/XUi/XUiRpgMakerGame/Hint/XUiGridRpgMakerGameMapNode.lua new file mode 100644 index 00000000..794e46c9 --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgMakerGame/Hint/XUiGridRpgMakerGameMapNode.lua @@ -0,0 +1,34 @@ +local XUiGridRpgMakerGameCardMini = require("XUi/XUiRpgMakerGame/Hint/XUiGridRpgMakerGameCardMini") + +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate + +--提示说明地图上的节点 +local XUiGridRpgMakerGameMapNode = XClass(nil, "XUiGridRpgMakerGameMapNode") + +function XUiGridRpgMakerGameMapNode:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.CardGrids = {} + + XTool.InitUiObject(self) +end + +function XUiGridRpgMakerGameMapNode:Init(uiRoot) + self.UiRoot = uiRoot +end + +function XUiGridRpgMakerGameMapNode:Refresh(blockId, mapId) + local cardGrids = self.CardGrids + local blockColList = XRpgMakerGameConfigs.GetRpgMakerGameBlockColList(blockId) + for colIndex, col in ipairs(blockColList) do + local grid = cardGrids[colIndex] + if not grid then + local ui = colIndex == 1 and self.GridCardMini or CSUnityEngineObjectInstantiate(self.GridCardMini, self.Transform) + grid = XUiGridRpgMakerGameCardMini.New(ui, self.UiRoot) + cardGrids[colIndex] = grid + end + grid:Refresh(blockId, colIndex, col, mapId) + end +end + +return XUiGridRpgMakerGameMapNode \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgMakerGame/Hint/XUiGridRpgMakerGameRecord.lua b/Resources/Scripts/XUi/XUiRpgMakerGame/Hint/XUiGridRpgMakerGameRecord.lua new file mode 100644 index 00000000..da698184 --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgMakerGame/Hint/XUiGridRpgMakerGameRecord.lua @@ -0,0 +1,22 @@ +local CSXTextManagerGetText = CS.XTextManager.GetText + +--图标的说明 +local XUiGridRpgMakerGameRecord = XClass(nil, "XUiGridRpgMakerGameRecord") + +function XUiGridRpgMakerGameRecord:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + + XTool.InitUiObject(self) +end + +function XUiGridRpgMakerGameRecord:Refresh(hintIconKey) + local icon = XRpgMakerGameConfigs.GetRpgMakerGameHintIcon(hintIconKey) + self.ImgIconContent:SetRawImage(icon) + + local iconName = XRpgMakerGameConfigs.GetRpgMakerGameHintIconName(hintIconKey) + self.TxtContent.text = iconName +end + +return XUiGridRpgMakerGameRecord \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgMakerGame/Hint/XUiRpgMakerGameMapTip.lua b/Resources/Scripts/XUi/XUiRpgMakerGame/Hint/XUiRpgMakerGameMapTip.lua new file mode 100644 index 00000000..26fcd924 --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgMakerGame/Hint/XUiRpgMakerGameMapTip.lua @@ -0,0 +1,72 @@ +local XUiGridRpgMakerGameMapNode = require("XUi/XUiRpgMakerGame/Hint/XUiGridRpgMakerGameMapNode") +local XUiGridRpgMakerGameRecord = require("XUi/XUiRpgMakerGame/Hint/XUiGridRpgMakerGameRecord") + +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate + +--关卡谜底界面 +local XUiRpgMakerGameMapTip = XLuaUiManager.Register(XLuaUi, "UiRpgMakerGameMapTip") + +function XUiRpgMakerGameMapTip:OnAwake() + self:InitMap() + self:AutoAddListener() + self.GridNode.gameObject:SetActiveEx(false) +end + +function XUiRpgMakerGameMapTip:OnStart(mapId) + self.MapId = mapId + self.RecordGrids = {} +end + +function XUiRpgMakerGameMapTip:OnEnable() + self:UpdateMap() + self:UpdateRecords() +end + +function XUiRpgMakerGameMapTip:InitMap() + self.DynamicTable = XDynamicTableNormal.New(self.SViewStage) + self.DynamicTable:SetDelegate(self) + self.DynamicTable:SetProxy(XUiGridRpgMakerGameMapNode) +end + +function XUiRpgMakerGameMapTip:UpdateMap() + local mapId = self:GetMapId() + local blockIdListTemp = XRpgMakerGameConfigs.GetRpgMakerGameMapIdToBlockIdList(mapId) + blockIdListTemp = XTool.Clone(blockIdListTemp) + self.BlockIdList = XTool.ReverseList(blockIdListTemp) + self.DynamicTable:SetDataSource(self.BlockIdList) + self.DynamicTable:ReloadDataSync() +end + +function XUiRpgMakerGameMapTip:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local blockId = self.BlockIdList[index] + grid:Refresh(blockId, self.MapId) + end +end + +function XUiRpgMakerGameMapTip:UpdateRecords() + local mapId = self:GetMapId() + local hintIconKeyList = XRpgMakerGameConfigs.GetRpgMakerGameHintIconKeyListByMapId(mapId) + local grids = self.RecordGrids + + for i, hintIconKey in ipairs(hintIconKeyList) do + local grid = grids[i] + if not grid then + local ui = i == 1 and self.GridReward or CSUnityEngineObjectInstantiate(self.GridReward, self.PanelContent) + grid = XUiGridRpgMakerGameRecord.New(ui, self) + grids[i] = grid + end + grid:Refresh(hintIconKey) + grid.GameObject:SetActiveEx(true) + end +end + +function XUiRpgMakerGameMapTip:AutoAddListener() + self.BtnTanchuangCloseBig.CallBack = handler(self, self.Close) +end + +function XUiRpgMakerGameMapTip:GetMapId() + return self.MapId +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgMakerGame/Main/XUiRpgMakerGameDetail.lua b/Resources/Scripts/XUi/XUiRpgMakerGame/Main/XUiRpgMakerGameDetail.lua new file mode 100644 index 00000000..5c366d24 --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgMakerGame/Main/XUiRpgMakerGameDetail.lua @@ -0,0 +1,86 @@ +--副本详情 +local XUiRpgMakerGameDetail = XLuaUiManager.Register(XLuaUi, "UiRpgMakerGameDetail") + +local MaxStarCount = XRpgMakerGameConfigs.MaxStarCount + +function XUiRpgMakerGameDetail:OnAwake() + self:InitUi() + self:AutoAddListener() +end + +function XUiRpgMakerGameDetail:OnStart(stageId, closeCb, tabGroupIndex) + self.StageId = stageId + self.CloseCb = closeCb + self.TabGroupIndex = tabGroupIndex + + local numberName = XRpgMakerGameConfigs.GetRpgMakerGameNumberName(stageId) + local name = XRpgMakerGameConfigs.GetRpgMakerGameStageName(stageId) + self.TxtFightName.text = string.format("%s %s", numberName, name) + self.TxtInfo.text = XRpgMakerGameConfigs.GetRpgMakerGameStageHint(stageId) + + local starConditionIdList = XRpgMakerGameConfigs.GetRpgMakerGameStarConditionIdList(stageId) + local starConditionDesc + for i, starConditionId in ipairs(starConditionIdList) do + starConditionDesc = XRpgMakerGameConfigs.GetRpgMakerGameStarConditionDesc(starConditionId) + if self["TxtUnActive" .. i] then + self["TxtUnActive" .. i].text = starConditionDesc + end + if self["TxtActive" .. i] then + self["TxtActive" .. i].text = starConditionDesc + end + self["GridStageStar" .. i].gameObject:SetActiveEx(true) + end + + for i = #starConditionIdList + 1, MaxStarCount do + self["GridStageStar" .. i].gameObject:SetActiveEx(false) + end +end + +function XUiRpgMakerGameDetail:OnEnable() + self:Refresh() +end + +function XUiRpgMakerGameDetail:OnDestroy() + if self.CloseCb then + self.CloseCb() + end +end + +function XUiRpgMakerGameDetail:InitUi() + local gridStageStar + for i = 1, MaxStarCount do + gridStageStar = self["GridStageStar" .. i] + if gridStageStar then + self["PanelUnActive" .. i] = XUiHelper.TryGetComponent(gridStageStar.transform, "PanelUnActive") + self["TxtUnActive" .. i] = XUiHelper.TryGetComponent(gridStageStar.transform, "PanelUnActive/TxtUnActive", "Text") + self["PanelActive" .. i] = XUiHelper.TryGetComponent(gridStageStar.transform, "PanelActive") + self["TxtActive" .. i] = XUiHelper.TryGetComponent(gridStageStar.transform, "PanelActive/TxtActive", "Text") + end + end +end + +function XUiRpgMakerGameDetail:AutoAddListener() + self:RegisterClickEvent(self.BtnMask, self.Close) + self:RegisterClickEvent(self.BtnEnterFight, self.OnBtnEnterFightClick) +end + +function XUiRpgMakerGameDetail:Refresh() + local stageId = self:GetStageId() + local starConditionIdList = XRpgMakerGameConfigs.GetRpgMakerGameStarConditionIdList(stageId) + local stageDb = XDataCenter.RpgMakerGameManager.GetRpgMakerActivityStageDb(stageId) + local isClear + for i, starConditionId in ipairs(starConditionIdList) do + isClear = stageDb and stageDb:IsStarConditionClear(starConditionId) or false + self["PanelActive" .. i].gameObject:SetActiveEx(isClear) + self["PanelUnActive" .. i].gameObject:SetActiveEx(not isClear) + end +end + +function XUiRpgMakerGameDetail:OnBtnEnterFightClick() + local stageId = self:GetStageId() + XLuaUiManager.Open("UiRpgMakerGameCharacter", stageId) +end + +function XUiRpgMakerGameDetail:GetStageId() + return self.StageId +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgMakerGame/Main/XUiRpgMakerGameMain.lua b/Resources/Scripts/XUi/XUiRpgMakerGame/Main/XUiRpgMakerGameMain.lua new file mode 100644 index 00000000..3f6ed648 --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgMakerGame/Main/XUiRpgMakerGameMain.lua @@ -0,0 +1,205 @@ +local XUiRpgMakerGameStages = require("XUi/XUiRpgMakerGame/Main/XUiRpgMakerGameStages") +local XUiRpgMakerGameTabBtn = require("XUi/XUiRpgMakerGame/Main/XUiRpgMakerGameTabBtn") + +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate + +--功能主界面 +local XUiRpgMakerGameMain = XLuaUiManager.Register(XLuaUi, "UiRpgMakerGameMain") + +function XUiRpgMakerGameMain:OnAwake() + self.NewStageId = 0 --最近解锁的关卡 + self:AutoAddListener() + self:InitTabGroup() +end + +function XUiRpgMakerGameMain:OnStart() + local defaultButtonGroupIndex = self:GetDefaultButtonGroupIndex() + self.UiContentButtonGroup:SelectIndex(defaultButtonGroupIndex) +end + +function XUiRpgMakerGameMain:OnEnable() + self:UpdateNewStageId() + self:Refresh() + self:StartActivityTimer() +end + +function XUiRpgMakerGameMain:OnDisable() + self:StopActivityTimer() +end + +function XUiRpgMakerGameMain:UpdateNewStageId() + local allStageIdList = XRpgMakerGameConfigs.GetRpgMakerGameAllStageIdList() + local stageIdTemp + for _, stageId in ipairs(allStageIdList) do + if not XDataCenter.RpgMakerGameManager.IsStageClear(stageId) then + self.NewStageId = stageId + return + end + end + self.NewStageId = 0 +end + +function XUiRpgMakerGameMain:StartActivityTimer() + self:StopActivityTimer() + if not XDataCenter.RpgMakerGameManager.CheckActivityIsOpen() then + return + end + + self:RefreshActivityTime() + self.ActivityTimer = XScheduleManager.ScheduleForever(function() + if not XDataCenter.RpgMakerGameManager.CheckActivityIsOpen() then + return + end + self:RefreshActivityTime() + end, XScheduleManager.SECOND) +end + +function XUiRpgMakerGameMain:StopActivityTimer() + if self.ActivityTimer then + XScheduleManager.UnSchedule(self.ActivityTimer) + self.ActivityTimer = nil + end +end + +function XUiRpgMakerGameMain:RefreshActivityTime() + local id = XRpgMakerGameConfigs.GetDefaultActivityId() + local timeId = XRpgMakerGameConfigs.GetRpgMakerGameActivityTimeId(id) + local endTime = XFunctionManager.GetEndTimeByTimeId(timeId) + local now = XTime.GetServerNowTimestamp() + local offset = endTime - now + if self.TxtDay then + self.TxtDay.text = XUiHelper.GetTime(offset, XUiHelper.TimeFormatType.ACTIVITY) + end + + for _, tabBtn in ipairs(self.TabBtnTemplates) do + tabBtn:RefreshTimer() + end +end + +function XUiRpgMakerGameMain:InitTabGroup() + self.TabBtns = {} + self.TabBtnTemplates = {} + local chapterIdList = XRpgMakerGameConfigs.GetRpgMakerGameChapterIdList() + for i, chapterId in ipairs(chapterIdList) do + self.TabBtns[i] = i == 1 and self.BtnPlotTab or CSUnityEngineObjectInstantiate(self.BtnPlotTab, self.UiContent) + self.TabBtnTemplates[i] = XUiRpgMakerGameTabBtn.New(self.TabBtns[i], chapterId, i) + end + + self.UiContentButtonGroup = self.UiContent:GetComponent("XUiButtonGroup") + self.UiContentButtonGroup:Init(self.TabBtns, function(groupIndex) self:TabGroupSkip(groupIndex) end) +end + +function XUiRpgMakerGameMain:GetDefaultButtonGroupIndex() + local groupIndex = XDataCenter.RpgMakerGameManager.GetCurrClearButtonGroupIndex() + if groupIndex then + return groupIndex + end + + local allStageIdList = XRpgMakerGameConfigs.GetRpgMakerGameAllStageIdList() + local chapterId + local defaultGroupIndex = 1 + for _, stageId in ipairs(allStageIdList) do + if not XDataCenter.RpgMakerGameManager.IsStageUnLock(stageId) then + chapterId = XRpgMakerGameConfigs.GetRpgMakerGameStageChapterId(stageId) + groupIndex = self:GetTabBtnIndex(chapterId) or defaultGroupIndex + return groupIndex + end + end + + return defaultGroupIndex +end + +function XUiRpgMakerGameMain:GetTabBtnIndex(chapterId) + local tabBtnTemplates = self:GetTabBtnTemplates() + for _, v in ipairs(tabBtnTemplates) do + if v:GetChapterId() == chapterId then + return v:GetTabBtnIndex() + end + end +end + +function XUiRpgMakerGameMain:TabGroupSkip(groupIndex) + if self.TabGroupIndex == groupIndex then + return + end + + local chapterId = XRpgMakerGameConfigs.GetRpgMakerGameChapterId(groupIndex) + local isUnLock = XDataCenter.RpgMakerGameManager.IsChapterUnLock(chapterId) + if not isUnLock then + local timeId = XRpgMakerGameConfigs.GetRpgMakerGameChapterOpenTimeId(chapterId) + local time = XFunctionManager.GetStartTimeByTimeId(timeId) + local serverTimestamp = XTime.GetServerNowTimestamp() + local str = CS.XTextManager.GetText("ScheOpenCountdown", XUiHelper.GetTime(time - serverTimestamp, XUiHelper.TimeFormatType.RPG_MAKER_GAME)) + XUiManager.TipMsg(str) + + if self.TabGroupIndex then + self.UiContentButtonGroup:SelectIndex(self.TabGroupIndex) + end + return + end + + self:PlayAnimation("QieHuan") + self.TabGroupIndex = groupIndex + XDataCenter.RpgMakerGameManager.SetCurrTabGroupIndexByUiMainTemp(groupIndex) + self:Refresh() +end + +function XUiRpgMakerGameMain:AutoAddListener() + self:RegisterClickEvent(self.SceneBtnBack, self.Close) + self:RegisterClickEvent(self.SceneBtnMainUi, self.OnBtnMainUiClick) + self:BindHelpBtn(self.BtnActDesc, "RpgMakerGame") + self:RegisterClickEvent(self.BtnTask, self.OnBtnTaskClick) +end + +function XUiRpgMakerGameMain:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiRpgMakerGameMain:OnBtnTaskClick() + XLuaUiManager.Open("UiRpgMakerGamePlayTask") +end + +function XUiRpgMakerGameMain:Refresh() + self:UpdateStagesMap() + self:UpdateTabBtnTemplates() + self:UpdateTaskRedPoint() +end + +function XUiRpgMakerGameMain:UpdateTaskRedPoint() + local isShowRedPoint = XDataCenter.RpgMakerGameManager.CheckRedPoint() + self.BtnTask:ShowReddot(isShowRedPoint) +end + +function XUiRpgMakerGameMain:UpdateStagesMap() + if not self.TabGroupIndex then + return + end + + local chapterId = XRpgMakerGameConfigs.GetRpgMakerGameChapterId(self.TabGroupIndex) + if chapterId ~= self.ChapterId then + local prefabName = XRpgMakerGameConfigs.GetRpgMakerGameChapterPrefab(chapterId) + local prefab = self.PanelChapter:LoadPrefab(prefabName) + if prefab == nil or not prefab:Exist() then + return + end + self.ChapterId = chapterId + self.CurStages = XUiRpgMakerGameStages.New(prefab, chapterId, function(stageId) self:OpenEnterDialog(stageId) end) + end + + local newStageId = self:GetNewStageId() + self.CurStages:Refresh(newStageId) +end + +function XUiRpgMakerGameMain:UpdateTabBtnTemplates() + for _, tabBtn in ipairs(self.TabBtnTemplates) do + tabBtn:Refresh() + end +end + +function XUiRpgMakerGameMain:GetTabBtnTemplates() + return self.TabBtnTemplates +end + +function XUiRpgMakerGameMain:GetNewStageId() + return self.NewStageId +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgMakerGame/Main/XUiRpgMakerGameStage.lua b/Resources/Scripts/XUi/XUiRpgMakerGame/Main/XUiRpgMakerGameStage.lua new file mode 100644 index 00000000..38413055 --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgMakerGame/Main/XUiRpgMakerGameStage.lua @@ -0,0 +1,84 @@ +local XUiRpgMakerGameStage = XClass(nil, "XUiRpgMakerGameStage") + +function XUiRpgMakerGameStage:Ctor(ui, rpgMakerGameStageId, tabGroupIndex) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + self.RpgMakerGameStageId = rpgMakerGameStageId + self.TabGroupIndex = tabGroupIndex + + XUiHelper.RegisterClickEvent(self, self.BtnStage, self.OnBtnClick) +end + +function XUiRpgMakerGameStage:Refresh(newStageId) + local rpgMakerGameStageId = self:GetRpgMakerGameStageId() + local stageStatus = XDataCenter.RpgMakerGameManager.GetRpgMakerGameStageStatus(rpgMakerGameStageId) + + self:UpdatePanelStageStatus(stageStatus) + self:UpdateStar(rpgMakerGameStageId) + + --背景图 + if self.RImgFightActiveNor then + local bg = XRpgMakerGameConfigs.GetRpgMakerGameStageBG(rpgMakerGameStageId) + self.RImgFightActiveNor:SetRawImage(bg) + end + + --关卡名 + if self.TxtStageOrder then + self.TxtStageOrder.text = stageStatus ~= XRpgMakerGameConfigs.RpgMakerGameStageStatus.Lock and XRpgMakerGameConfigs.GetRpgMakerGameNumberName(rpgMakerGameStageId) or "" + end + + self.PanelEffect.gameObject:SetActiveEx(newStageId == rpgMakerGameStageId) +end + +function XUiRpgMakerGameStage:UpdateStar(rpgMakerGameStageId) + local starConditionIdList = XRpgMakerGameConfigs.GetRpgMakerGameStarConditionIdList(rpgMakerGameStageId) + local totalStar = XRpgMakerGameConfigs.GetRpgMakerGameStageTotalStar(rpgMakerGameStageId) + local clearStarCount = 0 + local starCfg + local maxStarCount = XRpgMakerGameConfigs.MaxStarCount + local stageDb = XDataCenter.RpgMakerGameManager.GetRpgMakerActivityStageDb(rpgMakerGameStageId) + local stageClearStarCount = stageDb and stageDb:GetStarCount() or 0 --通关获得的星星数 + + for i = 1, totalStar do + if self["Img" .. i] then + self["Img" .. i].gameObject:SetActiveEx(stageClearStarCount >= i) + end + if self["Star" .. i] then + self["Star" .. i].gameObject:SetActiveEx(true) + end + end + for i = totalStar + 1, maxStarCount do + self["Star" .. i].gameObject:SetActiveEx(false) + end +end + +function XUiRpgMakerGameStage:UpdatePanelStageStatus(stageStatus) + if self.PanelStageNormal then + self.PanelStageNormal.gameObject:SetActiveEx(stageStatus ~= XRpgMakerGameConfigs.RpgMakerGameStageStatus.Lock) + end + if self.PanelStageLock then + self.PanelStageLock.gameObject:SetActiveEx(stageStatus == XRpgMakerGameConfigs.RpgMakerGameStageStatus.Lock) + end + if self.PanelStagePass then + self.PanelStagePass.gameObject:SetActiveEx(stageStatus == XRpgMakerGameConfigs.RpgMakerGameStageStatus.Clear) + end +end + +function XUiRpgMakerGameStage:OnBtnClick() + local rpgMakerGameStageId = self:GetRpgMakerGameStageId() + local ret, desc = XDataCenter.RpgMakerGameManager.IsStageUnLock(rpgMakerGameStageId) + if not ret then + XUiManager.TipMsg(desc) + return + end + + XLuaUiManager.Open("UiRpgMakerGameDetail", rpgMakerGameStageId) +end + +function XUiRpgMakerGameStage:GetRpgMakerGameStageId() + return self.RpgMakerGameStageId +end + +return XUiRpgMakerGameStage \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgMakerGame/Main/XUiRpgMakerGameStages.lua b/Resources/Scripts/XUi/XUiRpgMakerGame/Main/XUiRpgMakerGameStages.lua new file mode 100644 index 00000000..aca416dd --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgMakerGame/Main/XUiRpgMakerGameStages.lua @@ -0,0 +1,59 @@ +local XUiRpgMakerGameStage = require("XUi/XUiRpgMakerGame/Main/XUiRpgMakerGameStage") + +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate + +--路线 +local XUiRpgMakerGameStages = XClass(nil, "XUiRpgMakerGameStages") + +function XUiRpgMakerGameStages:Ctor(ui, chapterId, cb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + self.CallBack = cb + self.ChapterId = chapterId + + self.StageTemplateDic = {} + self:InitStage() +end + +function XUiRpgMakerGameStages:InitStage() + local chapterId = self:GetChapterId() + local stageIdList = XRpgMakerGameConfigs.GetRpgMakerGameStageIdList(chapterId) + local stageGrid + local prefabName + local prefab + + for i, stageId in ipairs(stageIdList) do + stageGrid = XUiHelper.TryGetComponent(self.PanelStageContent.transform, "Stage" .. i) + stageGrid = stageGrid and XUiHelper.TryGetComponent(stageGrid.transform, "PanelGrid") or stageGrid + if not stageGrid then + XLog.Error(string.format("PanelStageContent下不存在%s,检查UI:%s和配置:%s,chapterId %s对应的stageId数量", + "Stage" .. i, self.GameObject.name, "RpgMakerGameStage", chapterId)) + goto continue + end + + stageGrid.gameObject:SetActiveEx(true) + prefabName = XRpgMakerGameConfigs.GetRpgMakerGameStagePrefab(stageId) + prefab = stageGrid:LoadPrefab(prefabName) + if prefab == nil or not prefab:Exist() then + goto continue + end + + self.StageTemplateDic[stageId] = XUiRpgMakerGameStage.New(prefab, stageId) + + :: continue :: + end +end + +function XUiRpgMakerGameStages:Refresh(newStageId) + for _, stageTempalte in pairs(self.StageTemplateDic) do + stageTempalte:Refresh(newStageId) + end +end + +function XUiRpgMakerGameStages:GetChapterId() + return self.ChapterId +end + +return XUiRpgMakerGameStages \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgMakerGame/Main/XUiRpgMakerGameTabBtn.lua b/Resources/Scripts/XUi/XUiRpgMakerGame/Main/XUiRpgMakerGameTabBtn.lua new file mode 100644 index 00000000..b9ebe423 --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgMakerGame/Main/XUiRpgMakerGameTabBtn.lua @@ -0,0 +1,63 @@ +local XUiRpgMakerGameTabBtn = XClass(nil, "XUiRpgMakerGameTabBtn") + +local ButtonStateDisable = CS.UiButtonState.Disable + +function XUiRpgMakerGameTabBtn:Ctor(ui, chapterId, tabBtnIndex) + self.BtnPlotTab = ui + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + self.ChapterId = chapterId + self.TabBtnIndex = tabBtnIndex + + local bg = XRpgMakerGameConfigs.GetRpgMakerGameChapterTagBtnBG(chapterId) + local name = XRpgMakerGameConfigs.GetRpgMakerGameChapterName(chapterId) + self.BtnPlotTab:SetRawImage(bg) + self.BtnPlotTab:SetNameByGroup(0, name) +end + +function XUiRpgMakerGameTabBtn:Refresh() + local chapterId = self:GetChapterId() + local totalStarCount = XRpgMakerGameConfigs.GetRpgMakerGameTotalStar(chapterId) + local currStarCount = XDataCenter.RpgMakerGameManager.GetRpgMakerChapterClearStarCount(chapterId) + local isClear = currStarCount >= totalStarCount + + self.BtnPlotTab:SetNameByGroup(1, currStarCount) + self.BtnPlotTab:SetNameByGroup(2, "/" .. totalStarCount) + self.TagStar.gameObject:SetActiveEx(not isClear) + self.TagClear.gameObject:SetActiveEx(isClear) +end + +function XUiRpgMakerGameTabBtn:RefreshTimer() + local chapterId = self:GetChapterId() + local isUnLock = XDataCenter.RpgMakerGameManager.IsChapterUnLock(chapterId) + if not isUnLock and self.BtnPlotTab.ButtonState ~= ButtonStateDisable then + self.BtnPlotTab:SetDisable(true) + elseif isUnLock and self.BtnPlotTab.ButtonState == ButtonStateDisable then + self.BtnPlotTab:SetDisable(false) + end + + if not isUnLock then + local timeId = XRpgMakerGameConfigs.GetRpgMakerGameChapterOpenTimeId(chapterId) + local time = XFunctionManager.GetStartTimeByTimeId(timeId) + local serverTimestamp = XTime.GetServerNowTimestamp() + if self.TextTagTime then + self.TextTagTime.text = CS.XTextManager.GetText("ScheOpenCountdown", XUiHelper.GetTime(time - serverTimestamp, XUiHelper.TimeFormatType.RPG_MAKER_GAME)) + end + end + + if self.TagTime then + self.TagTime.gameObject:SetActiveEx(not isUnLock) + end +end + +function XUiRpgMakerGameTabBtn:GetChapterId() + return self.ChapterId +end + +function XUiRpgMakerGameTabBtn:GetTabBtnIndex() + return self.TabBtnIndex +end + +return XUiRpgMakerGameTabBtn \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgMakerGame/PlayMain/XUiRpgMakerGamePanelLoseTip.lua b/Resources/Scripts/XUi/XUiRpgMakerGame/PlayMain/XUiRpgMakerGamePanelLoseTip.lua new file mode 100644 index 00000000..b76e9a78 --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgMakerGame/PlayMain/XUiRpgMakerGamePanelLoseTip.lua @@ -0,0 +1,56 @@ +local MaxHintCount = 3 + +local XUiRpgMakerGamePanelLoseTip = XClass(nil, "XUiRpgMakerGamePanelLoseTip") + +function XUiRpgMakerGamePanelLoseTip:Ctor(ui, tipOutCb, tipResetCb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + self.TipOutCb = tipOutCb + self.TipResetCb = tipResetCb + + XUiHelper.RegisterClickEvent(self, self.BtnTipOut, self.OnBtnTipOutClick) + XUiHelper.RegisterClickEvent(self, self.BtnTipReset, self.OnBtnTipResetClick) +end + +function XUiRpgMakerGamePanelLoseTip:Show(stageId) + self:RefreshTxt(stageId) + self.GameObject:SetActiveEx(true) +end + +function XUiRpgMakerGamePanelLoseTip:RefreshTxt(stageId) + local loseHintList = XRpgMakerGameConfigs.GetRpgMakerGameStageLoseHintList(stageId) + for i, desc in ipairs(loseHintList or {}) do + if self["TextHint" .. i] then + self["TextHint" .. i].text = desc + end + end + + for i = #loseHintList + 1, MaxHintCount do + if self["TextHint" .. i] then + self["TextHint" .. i].text = "" + end + end +end + +function XUiRpgMakerGamePanelLoseTip:Hide() + self.GameObject:SetActiveEx(false) +end + +--回到活动主界面 +function XUiRpgMakerGamePanelLoseTip:OnBtnTipOutClick() + if self.TipOutCb then + self:Hide() + self.TipOutCb() + end +end + +--重置当前关卡 +function XUiRpgMakerGamePanelLoseTip:OnBtnTipResetClick() + if self.TipResetCb and self.TipResetCb() then + self:Hide() + end +end + +return XUiRpgMakerGamePanelLoseTip \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgMakerGame/PlayMain/XUiRpgMakerGamePanelWinTip.lua b/Resources/Scripts/XUi/XUiRpgMakerGame/PlayMain/XUiRpgMakerGamePanelWinTip.lua new file mode 100644 index 00000000..ffcf3017 --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgMakerGame/PlayMain/XUiRpgMakerGamePanelWinTip.lua @@ -0,0 +1,105 @@ +local XUiRpgMakerGamePanelWinTip = XClass(nil, "XUiRpgMakerGamePanelWinTip") + +function XUiRpgMakerGamePanelWinTip:Ctor(ui, tipOutCb, tipNextCb, tipResetCb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + self.TipOutCb = tipOutCb + self.TipNextCb = tipNextCb + self.TipResetCb = tipResetCb + + XUiHelper.RegisterClickEvent(self, self.BtnTipOut, self.OnBtnTipOutClick) + XUiHelper.RegisterClickEvent(self, self.BtnTipNext, self.OnBtnTipNextClick) + XUiHelper.RegisterClickEvent(self, self.BtnTipReset, self.OnBtnTipResetClick) + + self:InitUi() +end + +function XUiRpgMakerGamePanelWinTip:InitUi() + local panelText + for i = 1, XRpgMakerGameConfigs.MaxStarCount do + panelText = self["PanelText" .. i] + if panelText then + self["PanelLose" .. i] = XUiHelper.TryGetComponent(panelText.transform, "PanelLose") + self["TxtUnActive" .. i] = XUiHelper.TryGetComponent(panelText.transform, "PanelLose/TextInfo1", "Text") + self["PanelClear" .. i] = XUiHelper.TryGetComponent(panelText.transform, "PanelClear") + self["TxtActive" .. i] = XUiHelper.TryGetComponent(panelText.transform, "PanelClear/TextInfo1", "Text") + end + end + + self.BtnTipReset.gameObject:SetActiveEx(true) +end + +function XUiRpgMakerGamePanelWinTip:Show(stageId) + self.StageId = stageId + + local nextStageId = XRpgMakerGameConfigs.GetRpgMakerGameNextStageId(stageId) + local isHaveNextStage = XTool.IsNumberValid(nextStageId) + self.BtnTipNext.gameObject:SetActiveEx(isHaveNextStage) + + self:RefreshTxt(stageId) + self:RefreshStar(stageId) + + self.GameObject:SetActiveEx(true) +end + +function XUiRpgMakerGamePanelWinTip:RefreshStar(stageId) + local stageDb = XDataCenter.RpgMakerGameManager.GetRpgMakerActivityStageDb(stageId) + local starConditionIdList = XRpgMakerGameConfigs.GetRpgMakerGameStarConditionIdList(stageId) + local stageDb = XDataCenter.RpgMakerGameManager.GetRpgMakerActivityStageDb(stageId) + local isClear + for i, starConditionId in ipairs(starConditionIdList) do + isClear = stageDb and stageDb:IsStarConditionClear(starConditionId) or false + self["PanelClear" .. i].gameObject:SetActiveEx(isClear) + self["PanelLose" .. i].gameObject:SetActiveEx(not isClear) + end +end + +function XUiRpgMakerGamePanelWinTip:RefreshTxt(stageId) + local starConditionIdList = XRpgMakerGameConfigs.GetRpgMakerGameStarConditionIdList(stageId) + local starConditionDesc + for i, starConditionId in ipairs(starConditionIdList or {}) do + starConditionDesc = XRpgMakerGameConfigs.GetRpgMakerGameStarConditionDesc(starConditionId) + if self["TxtUnActive" .. i] then + self["TxtUnActive" .. i].text = starConditionDesc + end + if self["TxtActive" .. i] then + self["TxtActive" .. i].text = starConditionDesc + end + self["PanelText" .. i].gameObject:SetActiveEx(true) + end + + for i = #starConditionIdList + 1, XRpgMakerGameConfigs.MaxStarCount do + self["PanelText" .. i].gameObject:SetActiveEx(false) + end +end + +function XUiRpgMakerGamePanelWinTip:Hide() + self.GameObject:SetActiveEx(false) +end + +--回到活动主界面 +function XUiRpgMakerGamePanelWinTip:OnBtnTipOutClick() + if self.TipOutCb then + self:Hide() + self.TipOutCb() + end +end + +--进入下一关 +function XUiRpgMakerGamePanelWinTip:OnBtnTipNextClick() + if self.TipNextCb then + self:Hide() + self.TipNextCb() + end +end + +--重置当前关卡 +function XUiRpgMakerGamePanelWinTip:OnBtnTipResetClick() + if self.TipResetCb and self.TipResetCb() then + self:Hide() + end +end + +return XUiRpgMakerGamePanelWinTip \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgMakerGame/PlayMain/XUiRpgMakerGamePlayMain.lua b/Resources/Scripts/XUi/XUiRpgMakerGame/PlayMain/XUiRpgMakerGamePlayMain.lua new file mode 100644 index 00000000..23a4b45e --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgMakerGame/PlayMain/XUiRpgMakerGamePlayMain.lua @@ -0,0 +1,675 @@ +local XUiRpgMakerGamePanelWinTip = require("XUi/XUiRpgMakerGame/PlayMain/XUiRpgMakerGamePanelWinTip") +local XUiRpgMakerGamePanelLoseTip = require("XUi/XUiRpgMakerGame/PlayMain/XUiRpgMakerGamePanelLoseTip") +local XUiRpgMakerGameUnlockTip = require("XUi/XUiRpgMakerGame/PlayMain/XUiRpgMakerGameUnlockTip") + +local MaxStarCount = XRpgMakerGameConfigs.MaxStarCount +local IsNumberValid = XTool.IsNumberValid +local Vector2 = CS.UnityEngine.Vector2 +local Vector2Right = Vector2.right +local mathAbs = math.abs +local CSXTextManagerGetText = CS.XTextManager.GetText +local CSUiButtonStateSelect = CS.UiButtonState.Select +local CSUiButtonStateNormal = CS.UiButtonState.Normal + +local RandomDialogBoxIntervalSecond = CS.XGame.ClientConfig:GetFloat("RpgMakerGameRandomDialogBoxIntervalSecond") + +--关卡玩法主界面 +local XUiRpgMakerGamePlayMain = XLuaUiManager.Register(XLuaUi, "UiRpgMakerGamePlayMain") + +function XUiRpgMakerGamePlayMain:OnAwake() + self.RpgMakerGamePlayScene = XDataCenter.RpgMakerGameManager.GetCurrentScene() + + self:InitGuide() + self:InitUiCameraEffect() + self:AutoAddListener() + self:InitTip() + + self.IsGuideing = false --是否正在功能引导中 + self.IsPlayingBackoffEffect = false --是否播放后退特效中 + self.IsTriggerDrag = false --是否触发拖拽 + self.IsWin = false --是否胜利 + self:SetCurrUseBackCount(0) --当前使用后退的次数,重置关卡后,计数重置 + self.TxtWord.text = CSXTextManagerGetText("RpgMakerGamePlayMainIsUseHintDesc") + self:SetContentAddBtn(false) + self:SetIconChatActive(false) + self:SetContentActive(false) +end + +function XUiRpgMakerGamePlayMain:OnStart() + self:InitStarCondition() + self:InitMaxChallengeCountDesc() + + self.RpgMakerGamePlayScene:PlayAnimation() +end + +function XUiRpgMakerGamePlayMain:OnEnable() + if self.RpgMakerGamePlayScene:IsSceneNil() then + return + end + self:Refresh() +end + +function XUiRpgMakerGamePlayMain:OnDisable() + self.IsPlayingAction = false + self:StopCheckShowHintTimer() + self:StopRandomDialogBoxDurationTimer() +end + +function XUiRpgMakerGamePlayMain:OnDestroy() + if self.UiCameraEffect and self.UiCameraEffect:Exist() then + CS.UnityEngine.GameObject.Destroy(self.UiCameraEffect) + self.UiCameraEffect = nil + end + self.RpgMakerGamePlayScene:RemoveScene() + XDataCenter.RpgMakerGameManager.ClearStageMap() +end + +function XUiRpgMakerGamePlayMain:InitUiCameraEffect() + local camera = CS.XUiManager.Instance.UiCamera + local cameraEffectPath = CS.XGame.ClientConfig:GetString("RpgMakerPlayScreenUiCameraEffect") + local resource = CS.XResourceManager.Load(cameraEffectPath) + if resource == nil or not resource.Asset then + XLog.Error(string.format("XUiRpgMakerGamePlayMain:InitUiCameraEffect() 加载:%s失败", cameraEffectPath)) + return + end + + self.UiCameraEffect = CS.UnityEngine.Object.Instantiate(resource.Asset, camera.transform) + self.UiCameraEffectStart = XUiHelper.TryGetComponent(self.UiCameraEffect.transform, "Start") + self.UiCameraEffectStart.gameObject:SetActiveEx(false) +end + +function XUiRpgMakerGamePlayMain:InitTip() + local tipOutCb = handler(self, self.Close) + local tipNextCb = function() + local stageId = self:GetStageId() + local nextStageId = XRpgMakerGameConfigs.GetRpgMakerGameNextStageId(stageId) + local selectRoleId = self:GetSelectRoleId() + local cb = function() + self:SetIsWin(false) + self:SetCurrUseBackCount(0) + self:OnStart() + self:Refresh() + end + XDataCenter.RpgMakerGameManager.RequestRpgMakerGameEnterStage(nextStageId, selectRoleId, cb) + end + local tipResetCb = handler(self, self.OnBtnResetClick) + + self.WinTip = XUiRpgMakerGamePanelWinTip.New(self.PanelWinTip, tipOutCb, tipNextCb, tipResetCb) + self.LoseTip = XUiRpgMakerGamePanelLoseTip.New(self.PanelLoseTip, tipOutCb, tipResetCb) + self.UnlockTip = XUiRpgMakerGameUnlockTip.New(self.PanelUnlockTip) + self.WinTip:Hide() + self.LoseTip:Hide() + self.UnlockTip:Hide() +end + +function XUiRpgMakerGamePlayMain:InitMaxChallengeCountDesc() + local mapId = self:GetMapId() + if not IsNumberValid(mapId) then + return + end + local desc = XRpgMakerGameConfigs.GetRpgMakerGameMaxRound(mapId) + self.TextMaxChallenge.text = "/" .. desc +end + +function XUiRpgMakerGamePlayMain:InitStarCondition() + local stageId = self:GetStageId() + if not IsNumberValid(stageId) then + return + end + + local starConditionIdList = XRpgMakerGameConfigs.GetRpgMakerGameStarConditionIdList(stageId) + local starConditionDesc + for i, starConditionId in ipairs(starConditionIdList or {}) do + starConditionDesc = XRpgMakerGameConfigs.GetRpgMakerGameStarConditionDesc(starConditionId) + self["Task" .. i]:SetName(starConditionDesc) + self["Task" .. i].gameObject:SetActiveEx(true) + self["Task" .. i]:SetButtonState(CSUiButtonStateNormal) + end + + for i = #starConditionIdList + 1, MaxStarCount do + self["Task" .. i].gameObject:SetActiveEx(false) + end +end + +function XUiRpgMakerGamePlayMain:AutoAddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnCloseClick) + self:BindHelpBtn(self.BtnHelp, "RpgMakerGame") + self:RegisterClickEvent(self.BtnReset, handler(self, self.OnBtnResetClick)) + self:RegisterClickEvent(self.BtnBackoff, handler(self, self.OnBtnBackoffClick)) + self:RegisterClickEvent(self.BtnNo, handler(self, self.OnBtnNoClick)) + self:RegisterClickEvent(self.BtnYes, handler(self, self.OnBtnYesClick)) + self:RegisterClickEvent(self.BtnHead, handler(self, self.OnBtnHeadClick)) + if self.BtnGuideRoleClick then + self:RegisterClickEvent(self.BtnGuideRoleClick, handler(self, self.OnBtnGuideRoleClick)) + end + if self.BtnGuideRoadClick then + self:RegisterClickEvent(self.BtnGuideRoadClick, handler(self, self.OnBtnGuideRoadClick)) + end + + self.GoInputHandler:AddPointerDownListener(function(eventData) self:OnPointerDown(eventData) end) + self.GoInputHandler:AddDragListener(function(eventData) self:OnDrag(eventData) end) + self.GoInputHandler:AddPointerUpListener(function(eventData) self:OnPointerUp(eventData) end) +end + +function XUiRpgMakerGamePlayMain:Refresh() + self.TextChallenge.text = XDataCenter.RpgMakerGameManager.GetCurrentCount() + self:RefreshHint() + self:RefreshStarCondition() + self:CheckActions() +end + +function XUiRpgMakerGamePlayMain:RefreshStarCondition() + local stageId = self:GetStageId() + if not IsNumberValid(stageId) then + return + end + + local currentCount = XDataCenter.RpgMakerGameManager.GetCurrentCount() + local totalDeathCount, normalMonsterDeathCount, bossDeathCount = XDataCenter.RpgMakerGameManager.GetMonsterDeathCount() + local starConditionIdList = XRpgMakerGameConfigs.GetRpgMakerGameStarConditionIdList(stageId) + local stepCount + local monsterCount + local monsterBossCount + local monsterTotalCount + local btnState + local playableDirector + local isWin = self:GetIsWin() + + for i, starConditionId in ipairs(starConditionIdList or {}) do + stepCount = XRpgMakerGameConfigs.GetRpgMakerGameStarConditionStepCount(starConditionId) + monsterCount = XRpgMakerGameConfigs.GetRpgMakerGameStarConditionMonsterCount(starConditionId) + monsterBossCount = XRpgMakerGameConfigs.GetRpgMakerGameStarConditionMonsterBossCount(starConditionId) + monsterTotalCount = monsterCount + monsterBossCount + + if isWin and currentCount <= stepCount then + btnState = CSUiButtonStateSelect + elseif XTool.IsNumberValid(monsterCount) and XTool.IsNumberValid(monsterBossCount) then + btnState = monsterTotalCount <= totalDeathCount and CSUiButtonStateSelect or CSUiButtonStateNormal + elseif XTool.IsNumberValid(monsterCount) then + btnState = monsterCount <= normalMonsterDeathCount and CSUiButtonStateSelect or CSUiButtonStateNormal + elseif XTool.IsNumberValid(monsterBossCount) then + btnState = monsterBossCount <= bossDeathCount and CSUiButtonStateSelect or CSUiButtonStateNormal + else + btnState = CSUiButtonStateNormal + end + + --播放动画 + if self["Task" .. i].ButtonState ~= btnState then + self["Task" .. i]:SetButtonState(btnState) + if btnState == CS.UiButtonState.Select then + playableDirector = XUiHelper.TryGetComponent(self["Task" .. i].gameObject.transform, "Animation/SleEnable", "PlayableDirector") + if playableDirector then + playableDirector.gameObject:SetActiveEx(false) + playableDirector.gameObject:SetActiveEx(true) + playableDirector:Play() + end + end + end + end +end + +function XUiRpgMakerGamePlayMain:RefreshHint() + local isShowHintDialog = self:IsShowHintDialog() + self:SetContentAddBtn(false) + self:SetIconChatActive(isShowHintDialog) + self:SetContentActive(false) + self:StartCheckShowHintTimer() +end + +--检查播放行动动画 +function XUiRpgMakerGamePlayMain:CheckActions() + if self.IsPlayingAction then + return + end + + if XDataCenter.RpgMakerGameManager.IsActionsEmpty() then + return + end + + self.IsPlayingAction = true + + local action = XDataCenter.RpgMakerGameManager.GetNextAction() + local actionType = action.ActionType + local cb = handler(self, self.PlayActionEndCallback) + local playerObj = XDataCenter.RpgMakerGameManager.GetPlayerObj() + local endPointObj = XDataCenter.RpgMakerGameManager.GetEndPointObj() + local monsterObj = XDataCenter.RpgMakerGameManager.GetMonsterObj(action.MonsterId) + local triggerObj = XDataCenter.RpgMakerGameManager.GetTriggerObj(action.TriggerId) + + if actionType == XRpgMakerGameConfigs.RpgMakerGameActionType.ActionPlayerMove then + if playerObj then + playerObj:PlayMoveAction(action, cb) + end + return + end + + if actionType == XRpgMakerGameConfigs.RpgMakerGameActionType.ActionKillMonster then + if playerObj then + playerObj:PlayKillMonsterAction(action, cb) + end + return + end + + if actionType == XRpgMakerGameConfigs.RpgMakerGameActionType.ActionStageWin then + local stageId = self:GetStageId() + self.WinTip:Show(stageId) + self:PlayAnimation("PanelWinTipEnable") + self:SetIsWin(true) + XDataCenter.RpgMakerGameManager.SetCurrClearButtonGroupIndex() + cb() + return + end + + if actionType == XRpgMakerGameConfigs.RpgMakerGameActionType.ActionEndPointOpen then + if endPointObj then + endPointObj:PlayEndPointStatusChangeAction(action, cb) + end + return + end + + if actionType == XRpgMakerGameConfigs.RpgMakerGameActionType.ActionMonsterRunAway or actionType == XRpgMakerGameConfigs.RpgMakerGameActionType.ActionMonsterPatrol then + if monsterObj then + monsterObj:RemovePatrolLineObjs() + monsterObj:RemoveViewAreaModels() + local moveEndCb = function() + monsterObj:SetGameObjectViewArea() + cb() + end + monsterObj:PlayMoveAction(action, moveEndCb) + end + return + end + + if actionType == XRpgMakerGameConfigs.RpgMakerGameActionType.ActionMonsterChangeDirection then + if monsterObj then + monsterObj:ChangeDirectionAction(action, cb) + end + return + end + + if actionType == XRpgMakerGameConfigs.RpgMakerGameActionType.ActionMonsterKillPlayer then + if monsterObj then + local killPlayerCb = function() + local stageId = self:GetStageId() + self.LoseTip:Show(stageId) + self:PlayAnimation("PanelLoseTipEnable") + cb() + end + monsterObj:PlayKillPlayerAction(action, killPlayerCb) + end + return + end + + if actionType == XRpgMakerGameConfigs.RpgMakerGameActionType.ActionTriggerStatusChange then + if triggerObj then + triggerObj:PlayTriggerStatusChangeAction(action, cb) + end + return + end + + if actionType == XRpgMakerGameConfigs.RpgMakerGameActionType.ActionUnlockRole then + local roleId = action.RoleId + if IsNumberValid(roleId) then + self.UnlockTip:Show(roleId) + self:PlayAnimation("PanelUnlockTipEnable") + end + cb() + return + end + + if actionType == XRpgMakerGameConfigs.RpgMakerGameActionType.ActionMonsterPatrolLine then + if monsterObj then + monsterObj:SetMoveLine(action) + end + cb() + return + end + + cb() +end + +function XUiRpgMakerGamePlayMain:PlayActionEndCallback() + self.IsPlayingAction = false + self:Refresh() +end + +--手指按下 +function XUiRpgMakerGamePlayMain:OnPointerDown(eventData) + self.StartDir = eventData.position +end + +--拖拽 +function XUiRpgMakerGamePlayMain:OnDrag(eventData) + if not self:IsCanRequest() then + return + end + + local playerObj = XDataCenter.RpgMakerGameManager.GetPlayerObj() + if not playerObj then + return + end + + self.IsTriggerDrag = true + + local endDir = eventData.position - self.StartDir + local angle = Vector2.SignedAngle(Vector2Right, endDir) --向量转角度,范围:-180度 ~ 180度 + local direction = self:GetDirectionByAngle(angle) + playerObj:ChangeDirectionAction({Direction = direction}) + playerObj:SetMoveDirectionEffectActive(true) +end + +--手指松开 +function XUiRpgMakerGamePlayMain:OnPointerUp(eventData) + local playerObj = XDataCenter.RpgMakerGameManager.GetPlayerObj() + if playerObj then + playerObj:SetMoveDirectionEffectActive(false) + end + + if not self:IsCanRequest() or not self.IsTriggerDrag then + return + end + + self.IsTriggerDrag = false + + local endDir = eventData.position - self.StartDir + local angle = Vector2.SignedAngle(Vector2Right, endDir) --向量转角度,范围:-180度 ~ 180度 + local mapId = self:GetMapId() + local direction = self:GetDirectionByAngle(angle) + XDataCenter.RpgMakerGameManager.RequestRpgMakerGameMapMove(mapId, direction, handler(self, self.Refresh)) +end + +--根据角度返回对应的方向 +function XUiRpgMakerGamePlayMain:GetDirectionByAngle(angle) + local direction + if angle >= -45 and angle < 45 then + direction = XRpgMakerGameConfigs.RpgMakerGameMoveDirection.MoveRight + elseif angle >= 45 and angle < 135 then + direction = XRpgMakerGameConfigs.RpgMakerGameMoveDirection.MoveUp + elseif angle >= 135 or angle < -135 then + direction = XRpgMakerGameConfigs.RpgMakerGameMoveDirection.MoveLeft + elseif angle >= -135 and angle < -45 then + direction = XRpgMakerGameConfigs.RpgMakerGameMoveDirection.MoveDown + end + return direction +end + +function XUiRpgMakerGamePlayMain:OnBtnResetClick() + if not self:IsCanRequest() then + return false + end + + local mapId = self:GetMapId() + local cb = function() + self.IsPlayingAction = false + self.RpgMakerGamePlayScene:Reset() + self:SetIsWin(false) + self:SetCurrUseBackCount(0) + self:Refresh() + end + XDataCenter.RpgMakerGameManager.RequestRpgMakerGameMapResetGame(mapId, cb) + return true +end + +function XUiRpgMakerGamePlayMain:OnBtnBackoffClick() + if not self:IsCanRequest() then + return + end + + self:PlayBackoffEffect() + + local mapId = self:GetMapId() + local cb = function(currentRound) + self:SetCurrUseBackCount(self.CurrUseBackCount + 1) + self.RpgMakerGamePlayScene:BackUp(currentRound) + self:Refresh() + end + XDataCenter.RpgMakerGameManager.RequestRpgMakerGameMapBackUp(mapId, cb) +end + +function XUiRpgMakerGamePlayMain:OnBtnCloseClick() + local sureCallback = function() + self:Close() + end + XUiManager.DialogTip(CSXTextManagerGetText("TipTitle"), CSXTextManagerGetText("RpgMakerGamePlayMainQuickTipsDesc"), nil, nil, sureCallback) +end + +--所有动作播完才能发协议 +function XUiRpgMakerGamePlayMain:IsCanRequest() + if not XDataCenter.RpgMakerGameManager.IsActionsEmpty() or self.IsPlayingAction or self.IsPlayingBackoffEffect or self.IsGuideing then + return false + end + return true +end + +--------------------------提示相关 begin--------------------------- +--确定使用提示 +function XUiRpgMakerGamePlayMain:OnBtnYesClick() + self:OnBtnNoClick() + local mapId = self:GetMapId() + XLuaUiManager.Open("UiRpgMakerGameMapTip", mapId) +end + +--取消使用提示 +function XUiRpgMakerGamePlayMain:OnBtnNoClick() + self:SetContentAddBtn(false) + self:SetIconChatActive(true) +end + +function XUiRpgMakerGamePlayMain:OnBtnHeadClick() + if self:IsShowHintDialog() then + self:SetContentAddBtn(true) + self:SetIconChatActive(false) + else + local stageId = self:GetStageId() + self.TextHint.text = XRpgMakerGameConfigs.GetRpgMakerGameHintDialogBoxText(stageId) + self:SetContentActive(true) + end + + self:StartCheckShowHintTimer() +end + +--延迟一段时间显示随机提示语 +function XUiRpgMakerGamePlayMain:StartCheckShowHintTimer() + self:StopCheckShowHintTimer() + self:StopRandomDialogBoxDurationTimer() + if self:IsShowHintDialog() then + return + end + + local duration = RandomDialogBoxIntervalSecond + self.CheckShowHintTimer = XScheduleManager.ScheduleForever(function() + duration = duration - 1 + if duration <= 0 then + self:StopCheckShowHintTimer() + self:ShowRandomHintDialog() + end + end, XScheduleManager.SECOND) +end + +function XUiRpgMakerGamePlayMain:StopCheckShowHintTimer() + if self.CheckShowHintTimer then + XScheduleManager.UnSchedule(self.CheckShowHintTimer) + self.CheckShowHintTimer = nil + end +end + +function XUiRpgMakerGamePlayMain:ShowRandomHintDialog() + local id = XDataCenter.RpgMakerGameManager.GetRandomDialogBoxId() + local text = XRpgMakerGameConfigs.GetRpgMakerGameRandomDialogBoxText(id) + self.TextHint.text = text + self:SetContentActive(true) + self:StartRandomDialogBoxDurationTimer(id) +end + +function XUiRpgMakerGamePlayMain:SetContentAddBtn(isActive) + self.ContentAddBtn.gameObject:SetActiveEx(isActive) +end + +function XUiRpgMakerGamePlayMain:SetContentActive(isActive) + self.Content.gameObject:SetActiveEx(isActive) + if isActive then + self.ContentDynamicGrid:SetAllLayoutDirty() + end +end + +function XUiRpgMakerGamePlayMain:SetIconChatActive(isActive) + self.IconChat.gameObject:SetActiveEx(isActive) +end + +--显示一段时间的随机提示语 +function XUiRpgMakerGamePlayMain:StartRandomDialogBoxDurationTimer(randomdialogBoxId) + self:StopRandomDialogBoxDurationTimer() + + local duration = XRpgMakerGameConfigs.GetRpgMakerGameRandomDialogBoxDuration(randomdialogBoxId) + self.RandomDialogBoxDurationTimer = XScheduleManager.ScheduleForever(function() + duration = duration - 1 + if duration <= 0 then + self:SetContentActive(false) + self:StartCheckShowHintTimer() + end + end, XScheduleManager.SECOND) +end + +function XUiRpgMakerGamePlayMain:StopRandomDialogBoxDurationTimer() + if self.RandomDialogBoxDurationTimer then + XScheduleManager.UnSchedule(self.RandomDialogBoxDurationTimer) + self.RandomDialogBoxDurationTimer = nil + end +end + +--是否停止随机对话,显示通关路线对话 +function XUiRpgMakerGamePlayMain:IsShowHintDialog() + local currUseBackCount = self:GetCurrUseBackCount() + local stageId = self:GetStageId() + local backCount = XRpgMakerGameConfigs.GetRpgMakerGameHintDialogBoxBackCount(stageId) + return currUseBackCount >= backCount +end + +function XUiRpgMakerGamePlayMain:SetCurrUseBackCount(currUseBackCount) + self.CurrUseBackCount = currUseBackCount +end +--------------------------提示相关 end--------------------------- + +function XUiRpgMakerGamePlayMain:GetStageId() + local enterStageDb = XDataCenter.RpgMakerGameManager:GetRpgMakerGameEnterStageDb() + return enterStageDb:GetStageId() +end + +function XUiRpgMakerGamePlayMain:GetSelectRoleId() + local enterStageDb = XDataCenter.RpgMakerGameManager:GetRpgMakerGameEnterStageDb() + return enterStageDb:GetSelectRoleId() +end + +function XUiRpgMakerGamePlayMain:GetMapId() + local enterStageDb = XDataCenter.RpgMakerGameManager:GetRpgMakerGameEnterStageDb() + return enterStageDb:GetMapId() +end + +function XUiRpgMakerGamePlayMain:GetCurrUseBackCount() + return self.CurrUseBackCount +end + +function XUiRpgMakerGamePlayMain:SetIsWin(isWin) + self.IsWin = isWin +end + +function XUiRpgMakerGamePlayMain:GetIsWin() + return self.IsWin +end + +function XUiRpgMakerGamePlayMain:PlayBackoffEffect() + if XTool.UObjIsNil(self.UiCameraEffectStart) then + return + end + + self.IsPlayingBackoffEffect = true + self.UiCameraEffectStart.gameObject:SetActiveEx(false) + self.UiCameraEffectStart.gameObject:SetActiveEx(true) + + local time = CS.XGame.ClientConfig:GetInt("RpgMakerPlayScreenPlayUiCameraEffectTime") + XScheduleManager.ScheduleOnce(function() + if XTool.UObjIsNil(self.UiCameraEffectStart) then + self.UiCameraEffectStart.gameObject:SetActiveEx(false) + return + end + self.IsPlayingBackoffEffect = false + end, time) +end + +----------------------引导相关 begin----------------------- +function XUiRpgMakerGamePlayMain:InitGuide() + local offsetY = 50 + + local playerObj = XDataCenter.RpgMakerGameManager.GetPlayerObj() + local modelPosotion = playerObj and playerObj:GetGameObjPosition() + local localPosition = modelPosotion and self:WorldToUILocaPosition(modelPosotion) + if localPosition then + localPosition.y = localPosition.y + offsetY + end + + --设置按钮到角色模型所在的位置 + if self.BtnGuideRoleClick and localPosition then + self.BtnGuideRoleClick.transform.localPosition = localPosition + end + if self.BtnGuideRoadClick and localPosition then + local height = self.BtnGuideRoadClick.transform.rect.height + localPosition. y = height / 2 + self.BtnGuideRoadClick.transform.localPosition = localPosition + end + + --设置按钮到终点所在的位置 + local endPointObj = XDataCenter.RpgMakerGameManager.GetEndPointObj() + modelPosotion = endPointObj and endPointObj:GetGameObjPosition() + localPosition = modelPosotion and self:WorldToUILocaPosition(modelPosotion) + if self.BtnGuideEndPointClick and localPosition then + self.BtnGuideEndPointClick.transform.localPosition = localPosition + end + + --设置按钮到怪物所在的位置 + local mapId = self:GetMapId() + local monsterIdList = XRpgMakerGameConfigs.GetRpgMakerGameMapIdToMonsterIdList(mapId) + local monsterId = monsterIdList[1] + local monsterObj = XDataCenter.RpgMakerGameManager.GetMonsterObj(monsterId) + modelPosotion = monsterObj and monsterObj:GetGameObjPosition() + localPosition = modelPosotion and self:WorldToUILocaPosition(modelPosotion) + if localPosition then + localPosition.y = localPosition.y + offsetY + end + if self.BtnGuideMonsterClick and localPosition then + self.BtnGuideMonsterClick.transform.localPosition = localPosition + end +end + +function XUiRpgMakerGamePlayMain:OnBtnGuideRoleClick() + self.IsGuideing = true + local playerObj = XDataCenter.RpgMakerGameManager.GetPlayerObj() + if not playerObj then + return + end + + playerObj:ChangeDirectionAction({Direction = XRpgMakerGameConfigs.RpgMakerGameMoveDirection.MoveDown}) + playerObj:SetMoveDirectionEffectActive(true) +end + +function XUiRpgMakerGamePlayMain:OnBtnGuideRoadClick() + self.IsGuideing = false + local playerObj = XDataCenter.RpgMakerGameManager.GetPlayerObj() + if playerObj then + playerObj:SetMoveDirectionEffectActive(false) + end + + local mapId = self:GetMapId() + local direction = XRpgMakerGameConfigs.RpgMakerGameMoveDirection.MoveDown + XDataCenter.RpgMakerGameManager.RequestRpgMakerGameMapMove(mapId, direction, handler(self, self.Refresh)) +end + +--世界坐标-> UGUI坐标 +function XUiRpgMakerGamePlayMain:WorldToUILocaPosition(modelPosotion) + local sceneCamera = self.RpgMakerGamePlayScene:GetSceneCamera() + local viewportPos = sceneCamera:WorldToViewportPoint(modelPosotion) + local realScreenWidth = CsXUiManager.RealScreenWidth + local realScreenHeight = CsXUiManager.RealScreenHeight + + return CS.UnityEngine.Vector3((viewportPos.x - 0.5) * realScreenWidth, (viewportPos.y - 0.5) * realScreenHeight, 0) +end +----------------------引导相关 end----------------------- \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgMakerGame/PlayMain/XUiRpgMakerGamePlayScene.lua b/Resources/Scripts/XUi/XUiRpgMakerGame/PlayMain/XUiRpgMakerGamePlayScene.lua new file mode 100644 index 00000000..8a989904 --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgMakerGame/PlayMain/XUiRpgMakerGamePlayScene.lua @@ -0,0 +1,415 @@ +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate +local Vector3 = CS.UnityEngine.Vector3 +local CSXResourceManagerLoad = CS.XResourceManager.Load +local CSXResourceManagerLoadAsync = CS.XResourceManager.LoadAsync + +local XRpgMakerGameBlock = require("XEntity/XRpgMakerGame/Object/XRpgMakerGameBlock") +local XRpgMakerGameGap = require("XEntity/XRpgMakerGame/Object/XRpgMakerGameGap") +local XRpgMakerGameCube = require("XEntity/XRpgMakerGame/Object/XRpgMakerGameCube") + +local XUiRpgMakerGamePlayScene = XClass(nil, "XUiRpgMakerGamePlayScene") + +function XUiRpgMakerGamePlayScene:LoadScene(mapId, sceneLoadCompleteCb, uiName) + self.MapId = mapId + self.UiName = uiName + + local sceneAssetUrl = XRpgMakerGameConfigs.GetRpgMakerGamePrefab(mapId) + self.Resource = CSXResourceManagerLoadAsync(sceneAssetUrl) + CS.XTool.WaitCoroutine(self.Resource, function() + if not self.Resource or not self.Resource.Asset then + XLog.Error("XUiRpgMakerGamePlayScene LoadScene error, instantiate error, name: " .. sceneAssetUrl) + return + end + + self.GameObject = CSUnityEngineObjectInstantiate(self.Resource.Asset) + self.SceneObjRoot = XUiHelper.TryGetComponent(self.GameObject.transform, "GroupBase") + self.BlockObjs = {} + self.GapObjs = {} + self.CubeObjs = {} + self:Init() + if sceneLoadCompleteCb then + sceneLoadCompleteCb() + end + end) +end + +function XUiRpgMakerGamePlayScene:RemoveScene() + if self.GameObject then + CS.UnityEngine.GameObject.Destroy(self.GameObject) + self.GameObject = nil + end + + if self.Resource then + self.Resource:Release() + self.Resource = nil + end +end + +function XUiRpgMakerGamePlayScene:DisposeMonsterPatrolLineObjs() + for _, obj in pairs(self.MonsterPatrolLineObjs) do + obj:Dispose() + end + self.MonsterPatrolLineObjs = {} +end + +function XUiRpgMakerGamePlayScene:Init() + if XTool.UObjIsNil(self.GameObject) then + return + end + + self:InitCamera() + + local mapId = self:GetMapId() + self:InitCube(mapId) + self:InitBlock(mapId) + self:InitPlayer(mapId) + self:InitMonster(mapId) + self:InitGap(mapId) + self:InitEndPoint(mapId) + self:InitTriggerPoint(mapId) +end + +function XUiRpgMakerGamePlayScene:InitCamera() + self.Camera = self.GameObject.transform:Find("Camera"):GetComponent("Camera") +end + +function XUiRpgMakerGamePlayScene:InitTriggerPoint(mapId) + local triggerIdList = XRpgMakerGameConfigs.GetRpgMakerGameMapIdToTriggerIdList(mapId) + local sceneObjRoot = self:GetSceneObjRoot() + local triggerObj + local modelPath + local triggerType + + for _, triggerId in ipairs(triggerIdList) do + triggerObj = XDataCenter.RpgMakerGameManager.GetTriggerObj(triggerId) + triggerType = XRpgMakerGameConfigs.GetRpgMakerGameTriggerType(triggerId) + modelPath = XRpgMakerGameConfigs.GetRpgMakerGameTriggerPath(triggerType) + triggerObj:LoadModel(modelPath, sceneObjRoot) + end + + self:InitTriggerPointPosition(mapId) +end + +function XUiRpgMakerGamePlayScene:InitTriggerPointPosition(mapId) + local triggerIdList = XRpgMakerGameConfigs.GetRpgMakerGameMapIdToTriggerIdList(mapId) + local triggerObj + local x, y + local cube + local cubePosition + for _, triggerId in ipairs(triggerIdList) do + triggerObj = XDataCenter.RpgMakerGameManager.GetTriggerObj(triggerId) + x = XRpgMakerGameConfigs.GetRpgMakerGameTriggerX(triggerId) + y = XRpgMakerGameConfigs.GetRpgMakerGameTriggerY(triggerId) + cube = self:GetCubeObj(y, x) + cubePosition = cube:GetGameObjUpCenterPosition() + triggerObj:UpdatePosition({PositionX = x, PositionY = y}) + triggerObj:SetGameObjectPosition(cubePosition) + triggerObj:UpdateObjTriggerStatus(true) + end +end + +--初始化缝隙 +function XUiRpgMakerGamePlayScene:InitGap(mapId) + local sceneGameRoot = self:GetSceneObjRoot() + local gapIdList = XRpgMakerGameConfigs.GetRpgMakerGameMapIdToGapIdList(mapId) + local x, y + local direction + local gameObj + local cube + local cubePosition + local modelPath = XRpgMakerGameConfigs.GetRpgMakerGameModelPath("Gap") + + for _, gapId in ipairs(gapIdList) do + gameObj = XRpgMakerGameGap.New(gapId) + gameObj:LoadModel(modelPath, sceneGameRoot) + + x = XRpgMakerGameConfigs.GetRpgMakerGameGapX(gapId) + y = XRpgMakerGameConfigs.GetRpgMakerGameGapY(gapId) + direction = XRpgMakerGameConfigs.GetRpgMakerGameGapDirection(gapId) + cube = self:GetCubeObj(y, x) + cubePosition = cube:GetGameObjUpCenterPosition() + gameObj:UpdatePosition({PositionX = x, PositionY = y}) + gameObj:SetGameObjectPosition(cubePosition) + gameObj:ChangeDirectionAction({Direction = direction}) + + self.GapObjs[gapId] = gameObj + end +end + +--初始化终点 +function XUiRpgMakerGamePlayScene:InitEndPoint(mapId) + local endPointObj = XDataCenter.RpgMakerGameManager.GetEndPointObj() + local sceneObjRoot = self:GetSceneObjRoot() + local modelPath = endPointObj:IsOpen() and XRpgMakerGameConfigs.GetRpgMakerGameModelPath("GoldOpen") or XRpgMakerGameConfigs.GetRpgMakerGameModelPath("GoldClose") + endPointObj:LoadModel(modelPath, sceneObjRoot) + + self:InitEndPointPosition(mapId) +end + +function XUiRpgMakerGamePlayScene:InitEndPointPosition(mapId) + local endPointObj = XDataCenter.RpgMakerGameManager.GetEndPointObj() + local endPointId = endPointObj:GetId() + local x = XRpgMakerGameConfigs.GetRpgMakerGameEndPointX(endPointId) + local y = XRpgMakerGameConfigs.GetRpgMakerGameEndPointY(endPointId) + local cube = self:GetCubeObj(y, x) + local cubePosition = cube:GetGameObjUpCenterPosition() + endPointObj:UpdatePosition({PositionX = x, PositionY = y}) + endPointObj:SetGameObjectPosition(cubePosition) +end + +function XUiRpgMakerGamePlayScene:InitMonster(mapId) + local monsterIdList = XRpgMakerGameConfigs.GetRpgMakerGameMapIdToMonsterIdList(mapId) + local sceneObjRoot = self:GetSceneObjRoot() + local monsterObj + local modelPath + local modelName + local uiName = self:GetUiName() + + for _, monsterId in ipairs(monsterIdList) do + monsterObj = XDataCenter.RpgMakerGameManager.GetMonsterObj(monsterId) + modelName = XRpgMakerGameConfigs.GetRpgMakerGameMonsterPrefab(monsterId) + modelPath = XModelManager.GetModelPath(modelName) + monsterObj:LoadModel(modelPath, sceneObjRoot, modelName) + monsterObj:SetAnimator(modelName, uiName) + monsterObj:CheckLoadTriggerEndEffect() + end + + self:InitMonsterPosition(mapId) + self:InitMonsterViewArea(mapId) +end + +--设置怪物模型初始视野范围 +function XUiRpgMakerGamePlayScene:InitMonsterViewArea(mapId) + local monsterIdList = XRpgMakerGameConfigs.GetRpgMakerGameMapIdToMonsterIdList(mapId) + local monsterObj + for _, monsterId in ipairs(monsterIdList) do + monsterObj = XDataCenter.RpgMakerGameManager.GetMonsterObj(monsterId) + monsterObj:SetGameObjectViewArea() + end +end + +--设置怪物模型初始位置 +function XUiRpgMakerGamePlayScene:InitMonsterPosition(mapId, isUseSelfObjPosY) + local monsterIdList = XRpgMakerGameConfigs.GetRpgMakerGameMapIdToMonsterIdList(mapId) + local monsterObj + local x, y + local direction + local cube + local cubePosition + local position + local transform + local modelName + + for _, monsterId in ipairs(monsterIdList) do + monsterObj = XDataCenter.RpgMakerGameManager.GetMonsterObj(monsterId) + x = XRpgMakerGameConfigs.GetRpgMakerGameMonsterX(monsterId) + y = XRpgMakerGameConfigs.GetRpgMakerGameMonsterY(monsterId) + direction = XRpgMakerGameConfigs.GetRpgMakerGameMonsterDirection(monsterId) + cube = self:GetCubeObj(y, x) + cubePosition = cube:GetGameObjUpCenterPosition() + transform = monsterObj:GetTransform() + modelName = XRpgMakerGameConfigs.GetRpgMakerGameMonsterPrefab(monsterId) + monsterObj:SetGameObjectPosition(cubePosition) + monsterObj:ChangeDirectionAction({Direction = direction}) + end +end + +function XUiRpgMakerGamePlayScene:InitPlayer(mapId) + local playerObj = XDataCenter.RpgMakerGameManager.GetPlayerObj() + + --加载玩家角色模型 + local roleId = playerObj:GetId() + local uiName = self:GetUiName() + local modelName = XRpgMakerGameConfigs.GetRpgMakerGameRoleModelAssetPath(roleId) + local modelPath = XModelManager.GetModelPath(modelName) + local sceneObjRoot = self:GetSceneObjRoot() + playerObj:LoadModel(modelPath, sceneObjRoot, modelName) + playerObj:SetAnimator(modelName, uiName) + + self:InitPlayerPosition(mapId) + playerObj:LoadMoveDirectionEffect() + playerObj:SetMoveDirectionEffectActive(false) +end + +--设置玩家角色模型初始位置 +function XUiRpgMakerGamePlayScene:InitPlayerPosition(mapId, isUseSelfObjPosY) + local playerObj = XDataCenter.RpgMakerGameManager.GetPlayerObj() + local roleId = playerObj:GetId() + local startPointId = XRpgMakerGameConfigs.GetRpgMakerGameStartPointId(mapId) + local x = XRpgMakerGameConfigs.GetRpgMakerGameStartPointX(startPointId) + local y = XRpgMakerGameConfigs.GetRpgMakerGameStartPointY(startPointId) + local direction = XRpgMakerGameConfigs.GetRpgMakerGameStartPointDirection(startPointId) + local cube = self:GetCubeObj(y, x) + local objSize = cube:GetGameObjSize() + local cubePosition = cube:GetGameObjUpCenterPosition() + + playerObj:SetGameObjectPosition(cubePosition) + playerObj:ChangeDirectionAction({Direction = direction}) +end + +--初始化地面 +function XUiRpgMakerGamePlayScene:InitCube(mapId) + local transform = self.GameObject.transform + local sceneObjRoot = self:GetSceneObjRoot() + local cube = XUiHelper.TryGetComponent(sceneObjRoot.transform, "ScenePuzzle01_03Hezi01") + if not cube then + XLog.Error(string.format("XUiRpgMakerGamePlayScene:InitCube没找到ScenePuzzle01_03Hezi01对象 mapId:%s,sceneObjRoot:%s", mapId, sceneObjRoot)) + return + end + + local cubeMeshFilter = cube:GetComponent("MeshFilter") + local cubeSize = cubeMeshFilter.mesh.bounds.size + + local row = XRpgMakerGameConfigs.GetRpgMakerGameRow(mapId) + local col = XRpgMakerGameConfigs.GetRpgMakerGameCol(mapId) + local modelPath + local gameObjPositionX + local gameObjPositionY + local gameObj + local firstModelPath + local secondModelPath + local cubeModelPath1 = XRpgMakerGameConfigs.GetRpgMakerGameModelPath("Cube1") + local cubeModelPath2 = XRpgMakerGameConfigs.GetRpgMakerGameModelPath("Cube2") + + for i = 1, row do + self.CubeObjs[i] = {} + firstModelPath = i % 2 ~= 0 and cubeModelPath1 or cubeModelPath2 + secondModelPath = i % 2 == 0 and cubeModelPath1 or cubeModelPath2 + for j = 1, col do + modelPath = j % 2 ~= 0 and firstModelPath or secondModelPath + gameObjPositionX = cube.position.x + cubeSize.x * (j - 1) + gameObjPositionY = cube.position.z + cubeSize.z * (i - 1) + gameObj = XRpgMakerGameCube.New() + gameObj:LoadModel(modelPath, sceneObjRoot) + gameObj:SetGameObjectPosition(Vector3(gameObjPositionX, cube.position.y, gameObjPositionY)) + self.CubeObjs[i][j] = gameObj + end + end +end + +--初始化阻挡物 +function XUiRpgMakerGamePlayScene:InitBlock(mapId) + local blockIdList = XRpgMakerGameConfigs.GetRpgMakerGameMapIdToBlockIdList(mapId) + local blockRow + local colList + local blockObjTemp + local sceneObjRoot = self:GetSceneObjRoot() + local cube + local cubePosition + local modelPath = XRpgMakerGameConfigs.GetRpgMakerGameModelPath("Block") + + for _, blockId in ipairs(blockIdList) do + blockRow = XRpgMakerGameConfigs.GetRpgMakerGameBlockRow(blockId) + colList = XRpgMakerGameConfigs.GetRpgMakerGameBlockColList(blockId) + + for colNum, blockStatus in ipairs(colList) do + if blockStatus == XRpgMakerGameConfigs.XRpgMakerGameBlockStatus.Block then + cube = self:GetCubeObj(blockRow, colNum) + cubePosition = cube:GetGameObjUpCenterPosition() + blockObjTemp = XRpgMakerGameBlock.New() + blockObjTemp:LoadModel(modelPath, sceneObjRoot) + blockObjTemp:UpdatePosition({PositionX = blockRow, PositionY = colNum}) + blockObjTemp:SetGameObjectPosition(cubePosition) + + if not self.BlockObjs[blockRow] then + self.BlockObjs[blockRow] = {} + end + self.BlockObjs[blockRow][colNum] = blockObjTemp + end + end + end +end + +function XUiRpgMakerGamePlayScene:GetMapId() + return self.MapId +end + +function XUiRpgMakerGamePlayScene:GetCubeObj(row, col) + return self.CubeObjs[row] and self.CubeObjs[row][col] +end + +function XUiRpgMakerGamePlayScene:GetCubeObjs() + return self.CubeObjs +end + +function XUiRpgMakerGamePlayScene:GetSceneObjRoot() + return self.SceneObjRoot +end + +function XUiRpgMakerGamePlayScene:IsSceneNil() + return XTool.UObjIsNil(self.GameObject) +end + +function XUiRpgMakerGamePlayScene:SetSceneActive(isActive) + if not self:IsSceneNil() then + self.GameObject.gameObject:SetActiveEx(isActive) + end +end + +--重置 +function XUiRpgMakerGamePlayScene:Reset() + self:BackUp() +end + +--后退 +function XUiRpgMakerGamePlayScene:BackUp() + local mapId = self:GetMapId() + local playerObj = XDataCenter.RpgMakerGameManager.GetPlayerObj() + playerObj:UpdateObjPosAndDirection() + playerObj:CheckIsDeath() + + local monsterIdList = XRpgMakerGameConfigs.GetRpgMakerGameMapIdToMonsterIdList(mapId) + local monsterObj + for _, monsterId in ipairs(monsterIdList) do + monsterObj = XDataCenter.RpgMakerGameManager.GetMonsterObj(monsterId) + if monsterObj then + monsterObj:UpdateObjPosAndDirection() + monsterObj:CheckIsDeath() + monsterObj:RemovePatrolLineObjs() + monsterObj:SetGameObjectViewArea() + end + end + + self:UpdateEndPointObjStatus() + self:UpdateTriggeObjStatus(mapId) +end + +function XUiRpgMakerGamePlayScene:UpdateEndPointObjStatus() + local endPointObj = XDataCenter.RpgMakerGameManager.GetEndPointObj() + endPointObj:UpdateObjStatus() +end + +function XUiRpgMakerGamePlayScene:UpdateTriggeObjStatus(mapId) + local triggerIdList = XRpgMakerGameConfigs.GetRpgMakerGameMapIdToTriggerIdList(mapId) + local triggerObj + for _, triggerId in ipairs(triggerIdList) do + triggerObj = XDataCenter.RpgMakerGameManager.GetTriggerObj(triggerId) + triggerObj:UpdateObjTriggerStatus() + end +end + +function XUiRpgMakerGamePlayScene:PlayAnimation() + self.PlayableDirector = XUiHelper.TryGetComponent(self.GameObject.transform, "Animation/AnimEnable", "PlayableDirector") + if self.PlayableDirector then + self.PlayableDirector.gameObject:SetActiveEx(true) + self.PlayableDirector:Play() + end +end + +function XUiRpgMakerGamePlayScene:GetUiName() + return self.UiName +end + +function XUiRpgMakerGamePlayScene:GetBlockObj(pointY, pointX) + return self.BlockObjs and self.BlockObjs[pointY] and self.BlockObjs[pointY][pointX] +end + +function XUiRpgMakerGamePlayScene:GetGapObj(gapId) + return self.GapObjs and self.GapObjs[gapId] +end + +function XUiRpgMakerGamePlayScene:GetSceneCamera() + return self.Camera +end + +return XUiRpgMakerGamePlayScene \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgMakerGame/PlayMain/XUiRpgMakerGameUnlockTip.lua b/Resources/Scripts/XUi/XUiRpgMakerGame/PlayMain/XUiRpgMakerGameUnlockTip.lua new file mode 100644 index 00000000..df32c8d5 --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgMakerGame/PlayMain/XUiRpgMakerGameUnlockTip.lua @@ -0,0 +1,29 @@ +local XUiRpgMakerGameUnlockTip = XClass(nil, "XUiRpgMakerGameUnlockTip") + +function XUiRpgMakerGameUnlockTip:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + XUiHelper.RegisterClickEvent(self, self.BgDark, self.Hide) +end + +function XUiRpgMakerGameUnlockTip:Show(unlockRoleId) + self:Refresh(unlockRoleId) + self.GameObject:SetActiveEx(true) +end + +function XUiRpgMakerGameUnlockTip:Hide() + self.GameObject:SetActiveEx(false) +end + +function XUiRpgMakerGameUnlockTip:Refresh(unlockRoleId) + local name = XRpgMakerGameConfigs.GetRpgMakerGameRoleName(unlockRoleId) + local style = XRpgMakerGameConfigs.GetRpgMakerGameRoleStyle(unlockRoleId) + self.TextName.text = name .. "·" .. style + + local headPath = XRpgMakerGameConfigs.GetRpgMakerGameRoleHeadPath(unlockRoleId) + self.StandIcon:SetRawImage(headPath) +end + +return XUiRpgMakerGameUnlockTip \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgMakerGame/Task/XUiRpgMakerGamePlayTask.lua b/Resources/Scripts/XUi/XUiRpgMakerGame/Task/XUiRpgMakerGamePlayTask.lua new file mode 100644 index 00000000..c67e5afc --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgMakerGame/Task/XUiRpgMakerGamePlayTask.lua @@ -0,0 +1,69 @@ +local XUiRpgMakerGamePlayTask = XLuaUiManager.Register(XLuaUi, "UiRpgMakerGamePlayTask") + +function XUiRpgMakerGamePlayTask:OnAwake() + self:AutoAddListener() +end + +function XUiRpgMakerGamePlayTask:OnStart() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + + self.GridTask.gameObject:SetActive(false) + + self.DynamicTable = XDynamicTableNormal.New(self.SViewTask.transform) + self.DynamicTable:SetProxy(XDynamicGridTask) + self.DynamicTable:SetDelegate(self) +end + +function XUiRpgMakerGamePlayTask:OnEnable() + self:Refresh() +end + +function XUiRpgMakerGamePlayTask:OnGetEvents() + return { + XEventId.EVENT_FINISH_TASK, + XEventId.EVENT_TASK_SYNC, + XEventId.EVENT_RPG_MAKER_GAME_ACTIVITY_END, + } +end + +function XUiRpgMakerGamePlayTask:OnNotify(event) + if event == XEventId.EVENT_FINISH_TASK + or event == XEventId.EVENT_TASK_SYNC then + self:Refresh() + elseif event == XEventId.EVENT_RPG_MAKER_GAME_ACTIVITY_END then + XUiManager.TipText("ActivityAlreadyOver") + XLuaUiManager.RunMain() + end +end + +function XUiRpgMakerGamePlayTask:AutoAddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) +end + +function XUiRpgMakerGamePlayTask:OnBtnBackClick() + self:Close() +end + +function XUiRpgMakerGamePlayTask:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +--动态列表事件 +function XUiRpgMakerGamePlayTask:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.Tasks[index] + grid.RootUi = self + grid:ResetData(data) + end +end + +function XUiRpgMakerGamePlayTask:Refresh() + if not self.GameObject:Exist() then + return + end + + self.Tasks = XDataCenter.RpgMakerGameManager.GetTimeLimitTask() + self.DynamicTable:SetDataSource(self.Tasks) + self.DynamicTable:ReloadDataASync() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgMakerGame/XUiFubenRpgMakerGameMovie.lua b/Resources/Scripts/XUi/XUiRpgMakerGame/XUiFubenRpgMakerGameMovie.lua new file mode 100644 index 00000000..0fdefad1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgMakerGame/XUiFubenRpgMakerGameMovie.lua @@ -0,0 +1,17 @@ +--Loading界面 +local XUiFubenRpgMakerGameMovie = XLuaUiManager.Register(XLuaUi, "UiFubenRpgMakerGameMovie") + +function XUiFubenRpgMakerGameMovie:OnStart(stageId) + if not XTool.IsNumberValid(stageId) then + return + end + + self.TxtTitle.text = XRpgMakerGameConfigs.GetRpgMakerGameStageName(stageId) + + local desc = XRpgMakerGameConfigs.GetRpgMakerGameStageHint(stageId) + self.TxtContent.text = string.gsub(desc, "\\n", "\n") +end + +function XUiFubenRpgMakerGameMovie:OnEnable() + self:PlayAnimation("ThemeEnable") +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgTower/Battle/BattleResult/XUiRpgTowerSettleWin.lua b/Resources/Scripts/XUi/XUiRpgTower/Battle/BattleResult/XUiRpgTowerSettleWin.lua new file mode 100644 index 00000000..f284f35a --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgTower/Battle/BattleResult/XUiRpgTowerSettleWin.lua @@ -0,0 +1,188 @@ +-- 兵法蓝图战斗胜利结算Ui +local XUiRpgTowerSettleWin = XLuaUiManager.Register(XLuaUi, "UiRpgTowerSettleWin") +local CharaItem = require("XUi/XUiRpgTower/Common/XUiRpgTowerCharaItem") +function XUiRpgTowerSettleWin:OnAwake() + XTool.InitUiObject(self) + self:InitAutoScript() + self.GridReward.gameObject:SetActive(false) +end + +function XUiRpgTowerSettleWin:OnStart(data, cb) + self.WinData = data + self.StageInfos = XDataCenter.FubenManager.GetStageInfo(data.StageId) + self.StageCfg = XDataCenter.FubenManager.GetStageCfg(data.StageId) + self.CurrentStageId = data.StageId + self.CurrAssistInfo = data.ClientAssistInfo + self.Cb = cb + self.IsFirst = true; + self:InitInfo(data) + XLuaUiManager.SetMask(true) + self:PlayRewardAnimation() +end + +function XUiRpgTowerSettleWin:OnEnable() + if not self.IsFirst then + XLuaUiManager.SetMask(true) + self.Timer = XScheduleManager.ScheduleOnce(function() + self:PlaySecondAnimation() + end) + end +end + +function XUiRpgTowerSettleWin:OnDestroy() + self.TeamBar:StopTimer() + XDataCenter.AntiAddictionManager.EndFightAction() +end + +-- 奖励动画 +function XUiRpgTowerSettleWin:PlayRewardAnimation() + local delay = XDataCenter.FubenManager.SettleRewardAnimationDelay + local interval = XDataCenter.FubenManager.SettleRewardAnimationInterval + local this = self + + -- 没有奖励则直接播放第二个动画 + if not self.GridRewardList or #self.GridRewardList == 0 then + self.Timer = XScheduleManager.ScheduleOnce(function() + this:PlaySecondAnimation() + end, delay) + return + end + + self.RewardAnimationIndex = 1 + self.Timer = XScheduleManager.Schedule(function() + if this.RewardAnimationIndex == #self.GridRewardList then + this:PlayReward(this.RewardAnimationIndex, function() + this:PlaySecondAnimation() + end) + else + this:PlayReward(this.RewardAnimationIndex) + end + this.RewardAnimationIndex = this.RewardAnimationIndex + 1 + end, interval, #self.GridRewardList, delay) +end + + +function XUiRpgTowerSettleWin:PlaySecondAnimation() + local this = self + self:PlayAnimation("AnimEnable2", function() + XLuaUiManager.SetMask(false) + XDataCenter.FunctionEventManager.UnLockFunctionEvent() + self.IsFirst = false; + end) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiRpgTowerSettleWin:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiRpgTowerSettleWin:AutoInitUi() + self.PanelNorWinInfo = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo") + self.PanelNor = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor") + self.PanelBtn = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelBtn") + self.PanelBtns = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelBtn/PanelBtns") + self.BtnLeft = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelBtn/PanelBtns/BtnLeft"):GetComponent("Button") + self.TxtLeft = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelBtn/PanelBtns/BtnLeft/TxtLeft"):GetComponent("Text") + self.BtnRight = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelBtn/PanelBtns/BtnRight"):GetComponent("Button") + self.TxtRight = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelBtn/PanelBtns/BtnRight/TxtRight"):GetComponent("Text") + self.PanelTouch = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelBtn/PanelTouch") + self.BtnBlock = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelBtn/PanelTouch/BtnBlock"):GetComponent("Button") + self.TxtLeftA = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelBtn/PanelTouch/BtnBlock/TxtLeft"):GetComponent("Text") + self.PanelLeft = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelLeft") + self.PanelRoleContent = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelLeft/Team/PanelRoleContent") + self.GridWinRole = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelLeft/Team/PanelRoleContent/GridWinRole") + self.PanelRight = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelRight") + self.TxtChapterName = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelRight/StageInfo/TxtChapterName"):GetComponent("Text") + self.TxtStageName = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelRight/StageInfo/TxtStageName"):GetComponent("Text") + self.PanelRewardContent = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelRight/RewardList/Viewport/PanelRewardContent") + self.GridReward = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelRight/RewardList/Viewport/PanelRewardContent/GridReward") + self.PanelFriend = self.Transform:Find("SafeAreaContentPane/PanelFriend") + self.PanelInf = self.Transform:Find("SafeAreaContentPane/PanelFriend/PanelInf") + self.TxtName = self.Transform:Find("SafeAreaContentPane/PanelFriend/PanelInf/TxtName"):GetComponent("Text") + self.TxtLv = self.Transform:Find("SafeAreaContentPane/PanelFriend/PanelInf/TxtLv"):GetComponent("Text") + self.PanelPlayerExpBar = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelLeft/PlayerExp/PanelPlayerExpBar") +end + +function XUiRpgTowerSettleWin:AutoAddListener() + self:RegisterClickEvent(self.BtnBlock, self.OnBtnExitClick) +end + +function XUiRpgTowerSettleWin:InitInfo(data) + self.PanelFriend.gameObject:SetActive(false) + self:SetBtnsInfo() + self:SetStageInfo(data) + self:UpdatePlayerInfo(data) + self:InitRewardCharacterList(data) + self:InitRewardList(data.RewardGoodsList) +end + +function XUiRpgTowerSettleWin:SetBtnsInfo() + self.PanelTouch.gameObject:SetActive(true) + self.PanelBtns.gameObject:SetActive(false) +end + +function XUiRpgTowerSettleWin:SetStageInfo(data) + local chapterName, stageName = XDataCenter.FubenManager.GetFubenNames(data.StageId) + self.TxtChapterName.text = chapterName + self.TxtStageName.text = stageName +end + +-- 角色奖励列表 +function XUiRpgTowerSettleWin:InitRewardCharacterList(data) + self.GridWinRole.gameObject:SetActive(false) + local teamData = XDataCenter.TeamManager.GetPlayerTeam(CS.XGame.Config:GetInt("TypeIdRpgTower")) + for i = 1, #teamData.TeamData do + if teamData.TeamData[i] ~= 0 then + local ui = CS.UnityEngine.Object.Instantiate(self.GridWinRole) + local grid = CharaItem.New(ui, XDataCenter.RpgTowerManager.CharaItemShowType.OnlyIconAndStar, nil, true) + grid.Transform:SetParent(self.PanelRoleContent, false) + grid:RefreshData(XDataCenter.RpgTowerManager.GetTeamMemberByCharacterId(teamData.TeamData[i])) + grid.GameObject:SetActive(true) + end + end +end + +-- 玩家经验 +function XUiRpgTowerSettleWin:UpdatePlayerInfo(data) + if not data or not next(data) then return end + local TeamBar = require("XUi/XUiRpgTower/Common/XUiRpgTowerSettleWinExpBar") + self.TeamBar = self.TeamBar or TeamBar.New(self.PanelPlayerExpBar) + local expChanges = XDataCenter.RpgTowerManager.GetExpChanges() + self.TeamBar:StartRun(expChanges) +end + +-- 物品奖励列表 +function XUiRpgTowerSettleWin:InitRewardList(rewardGoodsList) + rewardGoodsList = rewardGoodsList or {} + self.GridRewardList = {} + local rewards = XRewardManager.MergeAndSortRewardGoodsList(rewardGoodsList) + for _, item in ipairs(rewards) do + local ui = CS.UnityEngine.Object.Instantiate(self.GridReward) + local grid = XUiGridCommon.New(self, ui) + grid.Transform:SetParent(self.PanelRewardContent, false) + grid:Refresh(item, nil, nil, true) + grid.GameObject:SetActive(false) + table.insert(self.GridRewardList, grid) + end +end + +function XUiRpgTowerSettleWin:OnBtnExitClick() + if XDataCenter.RpgTowerManager.GetIsReset() then + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end + self.TeamBar:StopTimer() + XLuaUiManager.RunMain() + XUiManager.TipMsg(CS.XTextManager.GetText("RpgTowerFinished")) + else + self:Close() + end +end + +function XUiRpgTowerSettleWin:PlayReward(index, cb) + self.GridRewardList[index].GameObject:SetActive(true) + self:PlayAnimation("GridReward", cb) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgTower/Battle/ChangeMember/XUiRpgTowerRoomCharaListItem.lua b/Resources/Scripts/XUi/XUiRpgTower/Battle/ChangeMember/XUiRpgTowerRoomCharaListItem.lua new file mode 100644 index 00000000..a2b07469 --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgTower/Battle/ChangeMember/XUiRpgTowerRoomCharaListItem.lua @@ -0,0 +1,56 @@ +-- 兵法蓝图出战换人界面角色列表项控件 +local XUiRpgTowerRoomCharaListItem = XClass(nil, "XUiRpgTowerRoomCharaListItem") +local XUiRpgTowerCharaItem = require("XUi/XUiRpgTower/Common/XUiRpgTowerCharaItem") +function XUiRpgTowerRoomCharaListItem:Ctor() + +end + +function XUiRpgTowerRoomCharaListItem:Init(ui, list) + XTool.InitUiObjectByUi(self, ui) + self.List = list + self.PanelSelected.gameObject:SetActiveEx(false) + self.CharacterItem = XUiRpgTowerCharaItem.New(ui, + XDataCenter.RpgTowerManager.CharaItemShowType.OnlyIconAndStar) +end +--================ +--刷新数据 +--================ +function XUiRpgTowerRoomCharaListItem:RefreshData(rCharacter, gridIndex) + self.CharacterItem:RefreshData(rCharacter) + self.RChara = rCharacter + self.GridIndex = gridIndex + self.TxtFight.text = self.RChara:GetAbility() + self.ImgInTeam.gameObject:SetActiveEx(self.RChara:GetIsInTeam()) + self:RefreshElements() +end +--================ +--刷新元素图标 +--================ +function XUiRpgTowerRoomCharaListItem:RefreshElements() + local elementList = self.RChara:GetElements() + for i = 1, 3 do + local rImg = self["RImgCharElement" .. i] + if rImg and elementList[i] then + rImg.transform.gameObject:SetActive(true) + rImg:SetRawImage(elementList[i].Icon) + elseif rImg then + rImg.transform.gameObject:SetActive(false) + end + end +end +--================ +--点击事件 +--================ +function XUiRpgTowerRoomCharaListItem:OnClick() + if self.IsSelect then return end + self:SetSelect(true) +end +--================ +--选中事件 +--================ +function XUiRpgTowerRoomCharaListItem:SetSelect(isSelect) + self.IsSelect = isSelect + self.PanelSelected.gameObject:SetActiveEx(isSelect) + if isSelect then self.List:SetSelect(self) end +end +return XUiRpgTowerRoomCharaListItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgTower/Battle/ChangeMember/XUiRpgTowerRoomCharaListPanel.lua b/Resources/Scripts/XUi/XUiRpgTower/Battle/ChangeMember/XUiRpgTowerRoomCharaListPanel.lua new file mode 100644 index 00000000..86f35895 --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgTower/Battle/ChangeMember/XUiRpgTowerRoomCharaListPanel.lua @@ -0,0 +1,58 @@ +-- 兵法蓝图出战换人界面角色列表面板 +local XUiRpgTowerRoomCharaListPanel = XClass(nil, "XUiRpgTowerRoomCharaListPanel") +local CharaItem = require("XUi/XUiRpgTower/Battle/ChangeMember/XUiRpgTowerRoomCharaListItem") +function XUiRpgTowerRoomCharaListPanel:Ctor(ui, rootUi) + XTool.InitUiObjectByUi(self, ui) + self.RootUi = rootUi + self.DynamicTable = XDynamicTableNormal.New(self.GameObject) + self.DynamicTable:SetProxy(CharaItem) + self.DynamicTable:SetDelegate(self) +end +--动态列表事件 +function XUiRpgTowerRoomCharaListPanel:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(grid.DynamicGrid.gameObject, self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + if self.TeamList and self.TeamList[index] then + grid:RefreshData(self.TeamList[index], index) + if self.CurrentIndex == index then + grid:SetSelect(true) + else + grid:SetSelect(false) + end + end + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + grid:OnClick() + end +end +--================ +--刷新列表 +--================ +function XUiRpgTowerRoomCharaListPanel:UpdateData() + self.TeamList = XDataCenter.RpgTowerManager.GetTeam() + -- 获取当前选中角色在列表中的序号,若没有选中角色则默认列表第一个角色 + local rChara = self.RootUi.RCharacter + if rChara then + for index, member in pairs(self.TeamList) do + if member == rChara then + self.CurrentIndex = index + break + end + end + end + self.CurrentIndex = self.CurrentIndex or 1 + self.DynamicTable:SetDataSource(self.TeamList) + self.DynamicTable:ReloadDataASync(self.CurrentIndex) +end +--================ +--列表项选中事件 +--================ +function XUiRpgTowerRoomCharaListPanel:SetSelect(grid) + if self.CurGrid and self.CurGrid ~= grid then + self.CurGrid:SetSelect(false) + end + self.CurGrid = grid + self.CurrentIndex = grid.GridIndex + self.RootUi:OnCharaSelect(grid.RChara) +end +return XUiRpgTowerRoomCharaListPanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgTower/Battle/ChangeMember/XUiRpgTowerRoomCharacter.lua b/Resources/Scripts/XUi/XUiRpgTower/Battle/ChangeMember/XUiRpgTowerRoomCharacter.lua new file mode 100644 index 00000000..b8fef63a --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgTower/Battle/ChangeMember/XUiRpgTowerRoomCharacter.lua @@ -0,0 +1,137 @@ +-- 兵法蓝图出战换人界面 +local XUiRpgTowerRoomCharacter = XLuaUiManager.Register(XLuaUi, "UiRpgTowerRoomCharacter") +local CharaListPanel = require("XUi/XUiRpgTower/Battle/ChangeMember/XUiRpgTowerRoomCharaListPanel") +function XUiRpgTowerRoomCharacter:OnAwake() + XTool.InitUiObject(self) + self:InitPanels() + self:InitButtons() +end + +function XUiRpgTowerRoomCharacter:OnStart(teamData, changePos, cb) + self.TeamData = teamData + self.ChangePos = changePos + local characterId = teamData[changePos] + if characterId and characterId > 0 then + self.RCharacter = XDataCenter.RpgTowerManager.GetTeamMemberByCharacterId(characterId) + end + self.CallBack = cb + self:Refresh() +end + +function XUiRpgTowerRoomCharacter:OnEnable() + CS.XGraphicManager.UseUiLightDir = true + self.CharacterList:UpdateData(self.CurrentSelect or 1) +end + +function XUiRpgTowerRoomCharacter:OnDisable() + CS.XGraphicManager.UseUiLightDir = false +end + +function XUiRpgTowerRoomCharacter:OnDestroy() + if self.CallBack then + self.CallBack(self.TeamData) + self.CallBack = nil + end +end +function XUiRpgTowerRoomCharacter:InitPanels() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + local root = self.UiModelGo.transform + self.PanelRoleModel = root:FindTransform("PanelRoleModel") + self.ImgEffectHuanren = root:FindTransform("ImgEffectHuanren") + self.GridCharacter.gameObject:SetActiveEx(false) + self.CharacterList = CharaListPanel.New(self.SViewCharacterList, self) + self.RoleModelPanel = XUiPanelRoleModel.New(self.PanelRoleModel, self.Name, nil, true, nil, true) +end + +function XUiRpgTowerRoomCharacter:InitButtons() + self.BtnBack.CallBack = function() self:OnClickBack() end + self.BtnMainUi.CallBack = function() self:OnClickMainUi() end + self:RegisterClickEvent(self.BtnJoinTeam, self.OnBtnJoinClick, self) + self:RegisterClickEvent(self.BtnQuitTeam, self.OnBtnQuitClick, self) +end + +function XUiRpgTowerRoomCharacter:OnClickBack() + self:Close() +end + +function XUiRpgTowerRoomCharacter:OnClickMainUi() + XLuaUiManager.RunMain() +end + +function XUiRpgTowerRoomCharacter:OnBtnJoinClick() + local id = self.RCharacter:GetCharacterId() + for k, v in pairs(self.TeamData) do + if v == id then + self.TeamData[k] = 0 + break + end + end + + self.TeamData[self.ChangePos] = id + if self.CallBack then + self.CallBack(self.TeamData) + self.CallBack = nil + end + self:Close() +end + +function XUiRpgTowerRoomCharacter:OnBtnQuitClick() + local id = self.RCharacter:GetCharacterId() + for k, v in pairs(self.TeamData) do + if v == id then + self.TeamData[k] = 0 + break + end + end + + if self.CallBack then + self.CallBack(self.TeamData) + self.CallBack = nil + end + self:Close() +end + +function XUiRpgTowerRoomCharacter:Refresh() + self.CharacterList:UpdateData() +end + +function XUiRpgTowerRoomCharacter:OnCharaSelect(rChara) + self.RCharacter = rChara + self:UpdateModel() + self:SetTeamBtns() +end + +function XUiRpgTowerRoomCharacter:UpdateModel() + local characterId = self.RCharacter:GetCharacterId() + local robotId = self.RCharacter:GetRobotId() + if not characterId then return end + self.ImgEffectHuanren.gameObject:SetActiveEx(false) + self.ImgEffectHuanren.gameObject:SetActiveEx(true) + local robotCfg = XRobotManager.GetRobotTemplate(robotId) + if not robotCfg then return end + self.RoleModelPanel:UpdateRobotModel(robotId, characterId, nil, robotCfg and robotCfg.FashionId, robotCfg and robotCfg.WeaponId) +end + +function XUiRpgTowerRoomCharacter:SetTeamBtns() + local isInTeam = self.RCharacter:GetIsInTeam() + self.BtnJoinTeam.gameObject:SetActiveEx(not isInTeam) + self.BtnQuitTeam.gameObject:SetActiveEx(isInTeam) +end + +function XUiRpgTowerRoomCharacter:OnGetEvents() + return { XEventId.EVENT_RPGTOWER_RESET } +end + +function XUiRpgTowerRoomCharacter:OnNotify(evt, ...) + local args = { ... } + if evt == XEventId.EVENT_RPGTOWER_RESET then + self:OnActivityReset() + end +end + +function XUiRpgTowerRoomCharacter:OnActivityReset() + if self.IsReseting then return end + self.IsReseting = true + XLuaUiManager.RunMain() + XUiManager.TipMsg(CS.XTextManager.GetText("RpgTowerFinished")) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgTower/Battle/EditBattleUi/XUiRpgTowerNewRoomSingle.lua b/Resources/Scripts/XUi/XUiRpgTower/Battle/EditBattleUi/XUiRpgTowerNewRoomSingle.lua new file mode 100644 index 00000000..ee6df258 --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgTower/Battle/EditBattleUi/XUiRpgTowerNewRoomSingle.lua @@ -0,0 +1,87 @@ +-- 兵法蓝图出战界面代理 +local XUiRpgTowerNewRoomSingle = {} + +function XUiRpgTowerNewRoomSingle.InitEditBattleUi(newRoomSingle) + newRoomSingle.BtnTeamPrefab.gameObject:SetActiveEx(false) + newRoomSingle.PanelCharacterLimit.gameObject:SetActiveEx(false) +end + +function XUiRpgTowerNewRoomSingle.InitEditBattleUiCharacterInfo(newRoomSingle) + newRoomSingle.BtnShowInfoToggle.gameObject:SetActiveEx(false) + newRoomSingle.IsShowCharacterInfo = 0 +end + +function XUiRpgTowerNewRoomSingle.GetBattleTeamData(newRoomSingle) + local team = XDataCenter.TeamManager.GetPlayerTeam(newRoomSingle.TypeIdRpgTower) + for i in pairs(team.TeamData) do + if team.TeamData[i] > 0 and not XDataCenter.RpgTowerManager.GetTeamMemberExist(team.TeamData[i]) then + team.TeamData[i] = 0 + end + end + return team +end + +function XUiRpgTowerNewRoomSingle.HandleCharClick(newRoomSingle, charPos) + XLuaUiManager.Open("UiRpgTowerRoomCharacter", XTool.Clone(newRoomSingle.CurTeam.TeamData), charPos, function(resTeam) + newRoomSingle:UpdateTeam(resTeam) + end) +end + +function XUiRpgTowerNewRoomSingle.UpdateTeam(newRoomSingle) + XDataCenter.TeamManager.SetPlayerTeam(newRoomSingle.CurTeam, false) +end + +function XUiRpgTowerNewRoomSingle.UpdateRoleModel(newRoomSingle, charId, roleModelPanel, pos) + roleModelPanel:ShowRoleModel() + local callback = function() + newRoomSingle.LoadModelCount = newRoomSingle.LoadModelCount - 1 + if newRoomSingle.LoadModelCount <= 0 then + newRoomSingle.BtnEnterFight:SetDisable(false) + end + end + local rChara = XDataCenter.RpgTowerManager.GetTeamMemberByCharacterId(charId) + local robotId = rChara:GetRobotId() + local robotCfg = XRobotManager.GetRobotTemplate(robotId) + roleModelPanel:UpdateRobotModel(robotId, charId, callback, robotCfg.FashionId, robotCfg.WeaponId) +end + +function XUiRpgTowerNewRoomSingle.OnResetEvent(newRoomSingle) + XLuaUiManager.RunMain() + XUiManager.TipMsg(CS.XTextManager.GetText("RpgTowerFinished")) +end + +function XUiRpgTowerNewRoomSingle.SetEditBattleUiTeam(newRoomSingle) + XDataCenter.TeamManager.SetPlayerTeam(newRoomSingle.CurTeam, false) +end + +function XUiRpgTowerNewRoomSingle.GetRealCharData(newRoomSingle) + local teamData = newRoomSingle.CurTeam.TeamData + local teamIdData = {} + for pos, charaId in pairs(teamData) do + if charaId and charaId > 0 then + teamIdData[pos] = XDataCenter.RpgTowerManager.GetTeamMemberByCharacterId(charaId):GetRobotId() + else + teamIdData[pos] = 0 + end + end + return teamIdData +end + +function XUiRpgTowerNewRoomSingle.UpdateFightControl(newRoomSingle, curTeam) + local rStage = XDataCenter.RpgTowerManager.GetRStageByStageId(newRoomSingle.CurrentStageId) + newRoomSingle.FightControlResult = newRoomSingle.FightControl:UpdateByTextAndWarningLevel( + rStage:GetStageWarningType(), + CS.XTextManager.GetText("RpgTowerWarningControlName"), + rStage:GetRecommendLevel(), + CS.XTextManager.GetText("RpgTowerCurNumText", XDataCenter.RpgTowerManager.GetCurrentLevel()) + ) +end + +function XUiRpgTowerNewRoomSingle.UpdatePartnerInfo(newRoomSingleUi, maxCharaCount) + for i = 1, maxCharaCount do + local panel = newRoomSingleUi["CharacterPets" .. i] + if panel then panel.gameObject:SetActiveEx(false) end + end +end + +return XUiRpgTowerNewRoomSingle \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/AdaptPage/XUiRpgTowerRoleListAdaptPage.lua b/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/AdaptPage/XUiRpgTowerRoleListAdaptPage.lua new file mode 100644 index 00000000..33b7e52e --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/AdaptPage/XUiRpgTowerRoleListAdaptPage.lua @@ -0,0 +1,41 @@ +-- 兵法蓝图成员列表改造页面 +local XUiRpgTowerRoleListAdaptPage = XClass(nil, "XUiRpgTowerRoleListAdaptPage") +function XUiRpgTowerRoleListAdaptPage:Ctor(rootUi) + self.RootUi = rootUi + self:CreatePage() +end +--================ +--创建子面板控件(默认显示控件) +--================ +function XUiRpgTowerRoleListAdaptPage:CreatePage() + local ui = self.RootUi:LoadChildPrefab("Adapt", XUiConfigs.GetComponentUrl("RpgTowerRoleListChildWindowAdapt")) + local panelScript = require("XUi/XUiRpgTower/CharacterPage/AdaptPage/XUiRpgTowerRoleListAdaptPanel") + self.AdaptPanel = panelScript.New(ui, self, self.RootUi) +end +--================ +--打开页面 +--================ +function XUiRpgTowerRoleListAdaptPage:ShowPage() + self.RootUi:UpdateCamera(XDataCenter.RpgTowerManager.UiCharacter_Camera.ADAPT) + self.AdaptPanel:ShowPanel() + self.RootUi:SetModelDragFieldActive(true) +end +--================ +--刷新页面 +--================ +function XUiRpgTowerRoleListAdaptPage:RefreshPage(rChara) + self.AdaptPanel:RefreshData(rChara) +end +--================ +--隐藏页面 +--================ +function XUiRpgTowerRoleListAdaptPage:HidePage() + self.AdaptPanel:HidePanel() +end +--================ +--在面板被销毁时 +--================ +function XUiRpgTowerRoleListAdaptPage:OnCollect() + if self.AdaptPanel.OnCollet then self.AdaptPanel:OnCollect() end +end +return XUiRpgTowerRoleListAdaptPage \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/AdaptPage/XUiRpgTowerRoleListAdaptPanel.lua b/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/AdaptPage/XUiRpgTowerRoleListAdaptPanel.lua new file mode 100644 index 00000000..795bc74e --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/AdaptPage/XUiRpgTowerRoleListAdaptPanel.lua @@ -0,0 +1,71 @@ +-- +local XUiRpgTowerRoleListAdaptPanel = XClass(nil, "XUiRpgTowerRoleListAdaptPanel") + +function XUiRpgTowerRoleListAdaptPanel:Ctor(uiGameObject, page, rootUi) + XTool.InitUiObjectByUi(self, uiGameObject) + self.Page = page + self.RootUi = rootUi + self.BtnExchange.CallBack = function() self:OnClickChangeMember() end + self.GridSingular.gameObject:SetActiveEx(false) + self.GridDual.gameObject:SetActiveEx(false) + local iconScript = require("XUi/XUiRpgTower/Common/XUiRpgTowerItemIcon") + self.TalentItemIcon = iconScript.New(self.RImgTalentPointsIcon) + self.BtnTalentTotal.CallBack = function() self:OnClickTalentTotal() end + self.BtnReset.CallBack = function() self:OnClickReset() end + self:CreateLayers() +end + +function XUiRpgTowerRoleListAdaptPanel:CreateLayers() + self.Layers = {} + local LayerScript = require("XUi/XUiRpgTower/CharacterPage/AdaptPage/XUiRpgTowerRoleListTalentLevel") + local cfgs = XRpgTowerConfig.GetAllTalentLayerCfgs() + local isOdd = true + for layerId, cfg in pairs(cfgs) do + local grid = isOdd and self.GridSingular or self.GridDual + local layerObj = CS.UnityEngine.GameObject.Instantiate(grid) + layerObj.transform:SetParent(self.PanelCirculation.transform, false) + table.insert(self.Layers, LayerScript.New(layerObj, self.RootUi, cfg)) + layerObj.gameObject:SetActiveEx(true) + layerObj.gameObject.name = "Setting" .. layerId + isOdd = not isOdd + end +end +--================ +--刷新数据 +--================ +function XUiRpgTowerRoleListAdaptPanel:RefreshData(rChara) + self.RCharacter = rChara + self.TxtTalentPieces.text = rChara:GetTalentPoints() + self.TalentItemIcon:InitIcon(rChara:GetTalentItem()) + for _, layer in pairs(self.Layers) do + layer:RefreshData(rChara) + end +end +--================ +--点击更换队员按钮 +--================ +function XUiRpgTowerRoleListAdaptPanel:OnClickChangeMember() + self.RootUi:OpenChildPage(XDataCenter.RpgTowerManager.PARENT_PAGE.CHANGEMEMBER) +end + +function XUiRpgTowerRoleListAdaptPanel:ShowPanel() + self.GameObject:SetActiveEx(true) +end + +function XUiRpgTowerRoleListAdaptPanel:HidePanel() + self.GameObject:SetActiveEx(false) +end +--================ +--点击天赋汇总 +--================ +function XUiRpgTowerRoleListAdaptPanel:OnClickTalentTotal() + if not self.RCharacter then return end + XLuaUiManager.Open("UiRpgTowerCollect", self.RCharacter) +end +--================ +--点击天赋重置 +--================ +function XUiRpgTowerRoleListAdaptPanel:OnClickReset() + XDataCenter.RpgTowerManager.CharacterReset(self.RCharacter:GetCharacterId()) +end +return XUiRpgTowerRoleListAdaptPanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/AdaptPage/XUiRpgTowerRoleListTalentLevel.lua b/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/AdaptPage/XUiRpgTowerRoleListTalentLevel.lua new file mode 100644 index 00000000..92021eb8 --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/AdaptPage/XUiRpgTowerRoleListTalentLevel.lua @@ -0,0 +1,47 @@ +-- 兵法蓝图角色队伍等级天赋面板控件 +local XUiRpgTowerRoleListTalentLevel = XClass(nil, "XUiRpgTowerRoleListTalentLevel") +local TalentScript = require("XUi/XUiRpgTower/CharacterPage/GrowPage/XUiRpgTowerGrowPageNatureItem") +function XUiRpgTowerRoleListTalentLevel:Ctor(uiGameObject, rootUi, cfg) + XTool.InitUiObjectByUi(self, uiGameObject) + self.RootUi = rootUi + self.LayerCfg = cfg + self:InitPanel() +end + +function XUiRpgTowerRoleListTalentLevel:InitPanel() + self.PanelLock.gameObject:SetActiveEx(false) + self.Talents = {} + local talentPrefabPath = XUiConfigs.GetComponentUrl("RpgTowerTalentComponent") + local i = 1 + while(self["PanelSkill" .. i] ~= nil) do + local uiGameObject = self["PanelSkill" .. i].transform:LoadPrefab(talentPrefabPath) + table.insert(self.Talents, TalentScript.New(uiGameObject)) + self.Talents[i]:Hide() + i = i + 1 + end +end + +function XUiRpgTowerRoleListTalentLevel:RefreshData(rChara) + self.TxtLevel.text = self.LayerCfg.NeedTeamLevel + local currentLevel = XDataCenter.RpgTowerManager.GetCurrentLevel() + local needLevel = self.LayerCfg and self.LayerCfg.NeedTeamLevel or 1 + if self.LayerCfg and currentLevel >= needLevel then + self.PanelLock.gameObject:SetActiveEx(false) + else + self.PanelLock.gameObject:SetActiveEx(true) + self.TxtLock.text = CS.XTextManager.GetText("RpgTowerNeedTeamLevel", needLevel) + end + local talents = rChara:GetTalentsByLayer(self.LayerCfg.LayerId) + for index, talent in pairs(self.Talents) do + if talents[index] then + self["PanelSkill" .. index].gameObject:SetActiveEx(true) + talent:Show() + talent:RefreshData(talents[index]) + else + self["PanelSkill" .. index].gameObject:SetActiveEx(false) + talent:Hide() + end + end +end + +return XUiRpgTowerRoleListTalentLevel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/ChangeMemberPage/XUiRpgTowerChangeMemberItem.lua b/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/ChangeMemberPage/XUiRpgTowerChangeMemberItem.lua new file mode 100644 index 00000000..44f48623 --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/ChangeMemberPage/XUiRpgTowerChangeMemberItem.lua @@ -0,0 +1,50 @@ +-- 兵法蓝图养成界面更换成员列表项控件 +local XUiRpgTowerChangeMemberItem = XClass(nil, "XUiRpgTowerChangeMemberItem") +local XUiRpgTowerCharaItem = require("XUi/XUiRpgTower/Common/XUiRpgTowerCharaItem") +function XUiRpgTowerChangeMemberItem:Ctor() + +end + +function XUiRpgTowerChangeMemberItem:Init(ui, list) + XTool.InitUiObjectByUi(self, ui) + self.List = list + self:SetPanelSelect(false) + self.CharacterItem = XUiRpgTowerCharaItem.New(ui, + XDataCenter.RpgTowerManager.CharaItemShowType.Normal) +end +--================ +--刷新角色数据 +--================ +function XUiRpgTowerChangeMemberItem:RefreshData(rCharacter, gridIndex) + self.CharacterItem:RefreshData(rCharacter) + self.RChara = rCharacter + self.GridIndex = gridIndex +end +--================ +--点击事件 +--================ +function XUiRpgTowerChangeMemberItem:OnClick() + if self.IsSelect then return end + self:SetSelect(true) + local updateModelCb = function(model) + self.List.RootUi:OpenChildPage(XDataCenter.RpgTowerManager.PARENT_PAGE.ADAPT) + end + self.List.RootUi:OnCharaSelect(self.RChara, updateModelCb) +end +--================ +--选中 +--================ +function XUiRpgTowerChangeMemberItem:SetSelect(isSelect) + self.IsSelect = isSelect + self:SetPanelSelect(isSelect) + self.List:SetSelect(self) +end +--================ +--设置UI选中状态 +--================ +function XUiRpgTowerChangeMemberItem:SetPanelSelect(isSelect) + self.PanelSelected.gameObject:SetActiveEx(isSelect) + self.ImgInTeam.gameObject:SetActiveEx(isSelect) +end + +return XUiRpgTowerChangeMemberItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/ChangeMemberPage/XUiRpgTowerChangeMemberList.lua b/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/ChangeMemberPage/XUiRpgTowerChangeMemberList.lua new file mode 100644 index 00000000..c3e848a4 --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/ChangeMemberPage/XUiRpgTowerChangeMemberList.lua @@ -0,0 +1,71 @@ +--兵法蓝图养成界面更换成员页面成员动态列表控件 +local XUiRpgTowerChangeMemberList = XClass(nil, "XUiRpgTowerChangeMemberList") +local XUiRpgTowerChangeMemberItem = require("XUi/XUiRpgTower/CharacterPage/ChangeMemberPage/XUiRpgTowerChangeMemberItem") + +function XUiRpgTowerChangeMemberList:Ctor(ui, page, rootUi) + XTool.InitUiObjectByUi(self, ui) + self.Page = page + self.RootUi = rootUi + self.Page.GridCharacterNew.gameObject:SetActiveEx(false) + self.DynamicTable = XDynamicTableNormal.New(self.GameObject) + self.DynamicTable:SetProxy(XUiRpgTowerChangeMemberItem) + self.DynamicTable:SetDelegate(self) +end +--动态列表事件 +function XUiRpgTowerChangeMemberList:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(grid.DynamicGrid.gameObject, self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + if self.TeamList and self.TeamList[index] then + grid:RefreshData(self.TeamList[index], index) + if self.CurrentIndex == index then + grid:SetSelect(true) + end + end + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + grid:OnClick() + end +end +--================ +--刷新列表数据 +--================ +function XUiRpgTowerChangeMemberList:UpdateData() + self.TeamList = XDataCenter.RpgTowerManager.GetTeam() + local rChara = self.RootUi.RCharacter + if rChara then + for index, member in pairs(self.TeamList) do + if member == rChara then + self.CurrentIndex = index + break + end + end + end + self.CurrentIndex = self.CurrentIndex or 1 + self.DynamicTable:SetDataSource(self.TeamList) + self.DynamicTable:ReloadDataASync(1) +end +--================ +--列表项选中事件 +--================ +function XUiRpgTowerChangeMemberList:SetSelect(grid) + if self.CurGrid == grid then return end + if self.CurGrid then + self.CurGrid:SetSelect(false) + end + self.CurGrid = grid + self.CurrentIndex = grid.GridIndex +end +--================ +--显示面板 +--================ +function XUiRpgTowerChangeMemberList:ShowPanel() + self.GameObject:SetActiveEx(true) +end +--================ +--隐藏面板 +--================ +function XUiRpgTowerChangeMemberList:HidePanel() + self.GameObject:SetActiveEx(false) +end + +return XUiRpgTowerChangeMemberList \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/ChangeMemberPage/XUiRpgTowerRoleListChangeMember.lua b/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/ChangeMemberPage/XUiRpgTowerRoleListChangeMember.lua new file mode 100644 index 00000000..5a206f3a --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/ChangeMemberPage/XUiRpgTowerRoleListChangeMember.lua @@ -0,0 +1,44 @@ +-- 兵法蓝图养成界面更换成员窗口控件 +local XUiRpgTowerRoleListChangeMember = XClass(nil, "XUiRpgTowerRoleListChangeMember") +local XUiRpgTowerChangeMemberList = require("XUi/XUiRpgTower/CharacterPage/ChangeMemberPage/XUiRpgTowerChangeMemberList") +function XUiRpgTowerRoleListChangeMember:Ctor(ui, page) + XTool.InitUiObjectByUi(self, ui) + self.Page = page + XUiHelper.RegisterClickEvent(self, self.BtnCancel, function() self:OnClickCancel() end) + self.ChangeMemberList = XUiRpgTowerChangeMemberList.New(self.PanelScrollView, self, self.Page.RootUi) + self.AnimDisable:stopped('+', function(director) self:HidePanelCallBack() end) +end +--================ +--显示面板 +--================ +function XUiRpgTowerRoleListChangeMember:ShowPanel() + self.AnimDisable.gameObject:SetActiveEx(false) + self.GameObject:SetActiveEx(true) + self.ChangeMemberList:UpdateData() +end +--================ +--刷新面板 +--================ +function XUiRpgTowerRoleListChangeMember:UpdateData() + +end +--================ +--隐藏面板 +--================ +function XUiRpgTowerRoleListChangeMember:HidePanel() + self.AnimDisable.gameObject:SetActiveEx(true) +end +--================ +--隐藏面板动画结束回调 +--================ +function XUiRpgTowerRoleListChangeMember:HidePanelCallBack(director) + self.GameObject:SetActiveEx(false) +end +--================ +--点击关闭按钮 +--================ +function XUiRpgTowerRoleListChangeMember:OnClickCancel() + self.Page.RootUi:OpenChildPage(XDataCenter.RpgTowerManager.PARENT_PAGE.ADAPT) +end + +return XUiRpgTowerRoleListChangeMember \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/ChangeMemberPage/XUiRpgTowerRoleListChangeMemberPage.lua b/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/ChangeMemberPage/XUiRpgTowerRoleListChangeMemberPage.lua new file mode 100644 index 00000000..22fcbd13 --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/ChangeMemberPage/XUiRpgTowerRoleListChangeMemberPage.lua @@ -0,0 +1,36 @@ +-- 兵法蓝图养成界面更换成员面板 +local XUiRpgTowerRoleListChangeMemberPage = XClass(nil, "XUiRpgTowerRoleListChangeMemberPage") +local XUiRpgTowerRoleListChangeMember = require("XUi/XUiRpgTower/CharacterPage/ChangeMemberPage/XUiRpgTowerRoleListChangeMember") +function XUiRpgTowerRoleListChangeMemberPage:Ctor(rootUi) + self.RootUi = rootUi + self:CreateChangeMemberWindow() +end +--================ +--创建子面板控件(默认显示控件) +--================ +function XUiRpgTowerRoleListChangeMemberPage:CreateChangeMemberWindow() + local ui = self.RootUi:LoadChildPrefab("ChangeMember", XUiConfigs.GetComponentUrl("RpgTowerRoleListChildWindowChangeMember")) + self.ChangeMember = XUiRpgTowerRoleListChangeMember.New(ui, self) +end +--================ +--打开页面 +--================ +function XUiRpgTowerRoleListChangeMemberPage:ShowPage() + self.RootUi:UpdateCamera(XDataCenter.RpgTowerManager.UiCharacter_Camera.CHANGEMEMBER) + self.ChangeMember:ShowPanel() + self.RootUi:SetModelDragFieldActive(false) +end +--================ +--刷新页面 +--================ +function XUiRpgTowerRoleListChangeMemberPage:RefreshPage() + self.ChangeMember:UpdateData() +end +--================ +--隐藏页面 +--================ +function XUiRpgTowerRoleListChangeMemberPage:HidePage() + self.ChangeMember:HidePanel() +end + +return XUiRpgTowerRoleListChangeMemberPage \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/GrowPage/XUiRpgTowerGrowPageLevelUpPanel.lua b/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/GrowPage/XUiRpgTowerGrowPageLevelUpPanel.lua new file mode 100644 index 00000000..377b631e --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/GrowPage/XUiRpgTowerGrowPageLevelUpPanel.lua @@ -0,0 +1,122 @@ +-- 兵法蓝图角色养成升星页签面板 +local XUiRpgTowerGrowPageLevelUpPanel = XClass(nil, "XUiRpgTowerGrowPageLevelUpPanel") +local XUiRpgTowerStarPanel = require("XUi/XUiRpgTower/Common/XUiRpgTowerStarPanel") +local XUiLevelUpTips = require("XUi/XUiRpgTower/CharacterPage/GrowPage/XUiRpgTowerLevelUpTipsPanel") + +function XUiRpgTowerGrowPageLevelUpPanel:Ctor(ui, page) + XTool.InitUiObjectByUi(self, ui) + self.Page = page + self.RpgTowerStarSuccess.gameObject:SetActiveEx(false) + self.Star = XUiRpgTowerStarPanel.New(self.PanelRpgTowerStars) + self.StarBefore = XUiRpgTowerStarPanel.New(self.PanelRpgTowerStarsBefore) + self.StarAfter = XUiRpgTowerStarPanel.New(self.PanelRpgTowerStarsAfter) + self.LevelUpTips = XUiLevelUpTips.New(self.RpgTowerStarSuccess) + self.BtnLevelUp.CallBack = function() self:OnClickLevelUp() end + self.BtnReset.CallBack = function() self:OnClickReset() end + if self.RImgLevelUpItemIcon then CsXUiHelper.RegisterClickEvent(self.RImgLevelUpItemIcon, function() self:OnClickLevelUpItemIcon() end) end +end +--================ +--显示面板 +--================ +function XUiRpgTowerGrowPageLevelUpPanel:ShowPanel() + self.GameObject:SetActiveEx(true) + self:AddEventListener() +end +--================ +--隐藏面板 +--================ +function XUiRpgTowerGrowPageLevelUpPanel:HidePanel() + self.GameObject:SetActiveEx(false) + self:RemoveEventListener() +end +--================ +--刷新面板数据,显示控件 +--================ +function XUiRpgTowerGrowPageLevelUpPanel:RefreshData(rChara) + self.RCharacter = rChara + self.Star:ShowStar(self.RCharacter:GetLevel()) + self.StarBefore:ShowStar(self.RCharacter:GetLevel()) + if not self.RCharacter:GetIsMaxLevel() then + self.PanelStarsAdvanced.gameObject:SetActiveEx(true) + self.TxtMax.gameObject:SetActiveEx(false) + self.StarAfter:ShowStar(self.RCharacter:GetLevel() + 1) + self.BtnLevelUp:SetButtonState(CS.UiButtonState.Normal) + self.BtnLevelUp.TempState = CS.UiButtonState.Normal + if self.PanelUpgrade then self.PanelUpgrade.gameObject:SetActiveEx(true) end + else + self.PanelStarsAdvanced.gameObject:SetActiveEx(false) + self.TxtMax.gameObject:SetActiveEx(true) + self.BtnLevelUp:SetButtonState(CS.UiButtonState.Disable) + self.BtnLevelUp.TempState = CS.UiButtonState.Disable + if self.PanelUpgrade then self.PanelUpgrade.gameObject:SetActiveEx(false) end + end + self.TxtCharaGrade.text = self.RCharacter:GetGradeName() + self.TxtSkillUp.text = self.RCharacter:GetSkillUpDescription() + local levelUpCondition = self.RCharacter:GetLevelUpCondition() + if string.IsNilOrEmpty(levelUpCondition) then levelUpCondition = CS.XTextManager.GetText("RpgTowerNoUpgradeCondition") end + self.TxtLevelUpCondition.text = levelUpCondition + local costStr + local total = self.RCharacter:GetLevelUpCostItemNum() + local cost = self.RCharacter:GetLevelUpCostNum() + if total >= cost then + costStr = CS.XTextManager.GetText("RpgTowerLevelUpCostStr", total, cost) + else + costStr = CS.XTextManager.GetText("RpgTowerLevelUpCostNotEnoughStr", total, cost) + end + self.TxtCost.text = costStr + if self.RImgLevelUpItemIcon then + local icon = XDataCenter.ItemManager.GetItemIcon(self.RCharacter:GetLevelUpCostItemId()) + self.RImgLevelUpItemIcon:SetRawImage(icon) + end +end +--================ +--角色升级成功时(回调) +--================ +function XUiRpgTowerGrowPageLevelUpPanel:OnLevelUp(rChara) + self.LevelUpTips:ShowTips(rChara) +end +--================ +--面板被回收时(移除UIEvent监听) +--================ +function XUiRpgTowerGrowPageLevelUpPanel:OnCollect() + self:RemoveEventListener() +end +--================ +--当点击升级按钮时 +--================ +function XUiRpgTowerGrowPageLevelUpPanel:OnClickLevelUp() + XDataCenter.RpgTowerManager.CharaUpgrade(self.RCharacter:GetCharacterId()) +end +--================ +--当点击升级道具图标时 +--================ +function XUiRpgTowerGrowPageLevelUpPanel:OnClickLevelUpItemIcon() + if self.RCharacter then XLuaUiManager.Open("UiTip", self.RCharacter:GetLevelUpCostItemId()) end +end +--================ +--当点击重置按钮时 +--================ +function XUiRpgTowerGrowPageLevelUpPanel:OnClickReset() + if self.RCharacter:GetLevel() == 1 then + XUiManager.TipMsg(CS.XTextManager.GetText("RpgTowerNoNeedReset")) + return + end + XDataCenter.RpgTowerManager.CharacterReset(self.RCharacter:GetCharacterId()) +end +--================ +--增加Event监听 +--================ +function XUiRpgTowerGrowPageLevelUpPanel:AddEventListener() + if self.AddEvent == true then return end + self.AddEvent = true + XEventManager.AddEventListener(XEventId.EVENT_RPGTOWER_ON_LEVELUP, self.OnLevelUp, self) +end +--================ +--移除Event监听 +--================ +function XUiRpgTowerGrowPageLevelUpPanel:RemoveEventListener() + if self.AddEvent == false then return end + self.AddEvent = false + XEventManager.RemoveEventListener(XEventId.EVENT_RPGTOWER_ON_LEVELUP, self.OnLevelUp, self) +end +return XUiRpgTowerGrowPageLevelUpPanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/GrowPage/XUiRpgTowerGrowPageNatureItem.lua b/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/GrowPage/XUiRpgTowerGrowPageNatureItem.lua new file mode 100644 index 00000000..646ea787 --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/GrowPage/XUiRpgTowerGrowPageNatureItem.lua @@ -0,0 +1,38 @@ +--兵法蓝图养成界面天赋树天赋节点控件 +local XUiRpgTowerGrowPageNatureItem = XClass(nil, "XUiRpgTowerGrowPageNatureItem") + +function XUiRpgTowerGrowPageNatureItem:Ctor(ui) + XTool.InitUiObjectByUi(self, ui) + self.BtnTalent.CallBack = function() self:OnClick() end +end + +function XUiRpgTowerGrowPageNatureItem:RefreshData(rTalent) + self.Talent = rTalent + self.BtnTalent:SetName(self.Talent:GetTalentName()) + self.BtnTalent:SetRawImage(self.Talent:GetIconPath()) + if self.Talent:GetIsUnLock() then + self.BtnTalent:SetButtonState(CS.UiButtonState.Normal) + self.BtnTalent.TempState = CS.UiButtonState.Normal + elseif self.Talent:GetCanUnLock() then + self.BtnTalent:SetButtonState(CS.UiButtonState.Select) + self.BtnTalent.TempState = CS.UiButtonState.Select + else + self.BtnTalent:SetButtonState(CS.UiButtonState.Disable) + self.BtnTalent.TempState = CS.UiButtonState.Disable + end +end + +function XUiRpgTowerGrowPageNatureItem:OnClick() + if not self.Talent then return end + XLuaUiManager.Open("UiRpgTowerNature", self.Talent) +end + +function XUiRpgTowerGrowPageNatureItem:Show() + self.GameObject:SetActiveEx(true) +end + +function XUiRpgTowerGrowPageNatureItem:Hide() + self.GameObject:SetActiveEx(false) +end + +return XUiRpgTowerGrowPageNatureItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/GrowPage/XUiRpgTowerGrowPageNatureLine.lua b/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/GrowPage/XUiRpgTowerGrowPageNatureLine.lua new file mode 100644 index 00000000..63ea98e9 --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/GrowPage/XUiRpgTowerGrowPageNatureLine.lua @@ -0,0 +1,13 @@ +-- 兵法蓝图天赋树线控件 +local XUiRpgTowerGrowPageNatureLine = XClass(nil, "XUiRpgTowerGrowPageNatureLine") + +function XUiRpgTowerGrowPageNatureLine:Ctor(ui, prepos, pos) + if not ui then XLog.Error(string.format("无法找到天赋树连线Ui:prePos:%d pos:%d", prepos, pos)) return end + self.GrayLine = ui.transform:Find("Gray") +end + +function XUiRpgTowerGrowPageNatureLine:SetLineState(isShow) + self.GrayLine.gameObject:SetActiveEx(not isShow) +end + +return XUiRpgTowerGrowPageNatureLine \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/GrowPage/XUiRpgTowerGrowPageNaturePanel.lua b/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/GrowPage/XUiRpgTowerGrowPageNaturePanel.lua new file mode 100644 index 00000000..23ef7e60 --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/GrowPage/XUiRpgTowerGrowPageNaturePanel.lua @@ -0,0 +1,103 @@ +-- 兵法蓝图角色养成天赋树页签面板 +local XUiRpgTowerGrowPageNaturePanel = XClass(nil, "XUiRpgTowerGrowPageNaturePanel") +local XUiRpgTowerGrowPageNatureItem = require("XUi/XUiRpgTower/CharacterPage/GrowPage/XUiRpgTowerGrowPageNatureItem") +local XUiRpgTowerGrowPageNatureLine = require("XUi/XUiRpgTower/CharacterPage/GrowPage/XUiRpgTowerGrowPageNatureLine") +local XUiRpgTowerItemIcon = require("XUi/XUiRpgTower/Common/XUiRpgTowerItemIcon") +local TalentPrefabPath +function XUiRpgTowerGrowPageNaturePanel:Ctor(ui, page) + XTool.InitUiObjectByUi(self, ui) + TalentPrefabPath = XUiConfigs.GetComponentUrl("RpgTowerTalentComponent") + self.BtnTalentTotal.CallBack = function() self:OnClickTalentTotal() end + self.TalentItemIcon = XUiRpgTowerItemIcon.New(self.RImgTalentPointsIcon) +end +--================ +--显示面板 +--================ +function XUiRpgTowerGrowPageNaturePanel:ShowPanel() + self.GameObject:SetActiveEx(true) +end +--================ +--刷新面板 +--================ +function XUiRpgTowerGrowPageNaturePanel:RefreshData(rChara) + if not self.Talents then self:CreateTalentTree(rChara) end + self.RCharacter = rChara + local talents = rChara:GetTalents() + if not talents then return end + for posId, talent in pairs(talents) do + self.Talents[posId]:RefreshData(talent) + self:SetTalentLine(talent) + end + self.TxtTalentPieces.text = CS.XTextManager.GetText("RpgTowerTalentPiecesDes", rChara:GetTalentPoints()) + self.TalentItemIcon:InitIcon(rChara:GetTalentItem()) +end +--================ +--设置天赋连线状态 +--================ +function XUiRpgTowerGrowPageNaturePanel:SetTalentLine(rTalent) + local prePosIds = rTalent:GetPrePosIds() + if prePosIds then + for _, prePosId in pairs(prePosIds) do + self.TalentsLine[rTalent:GetPosId()][prePosId]:SetLineState(rTalent:GetIsUnLock() and self.RCharacter:GetIsTalentUnlockByPosId(prePosId)) + end + end +end +--================ +--隐藏面板 +--================ +function XUiRpgTowerGrowPageNaturePanel:HidePanel() + self.GameObject:SetActiveEx(false) +end +--================ +--创建天赋树节点 +--================ +function XUiRpgTowerGrowPageNaturePanel:CreateTalentTree(rChara) + self:CreateTalentsParents() + self:CreateTalentsPoints() + self:CreateTalentsLine() +end +--================ +--初始化天赋各个根节点 +--================ +function XUiRpgTowerGrowPageNaturePanel:CreateTalentsParents() + self.TalentsParents = {} + local rootNum = self.PanelTalentRoot.transform.childCount + for i = 1, rootNum - 1 do + local root = self.PanelTalentRoot.transform:Find(tostring(i)) + self.TalentsParents[i] = root + end +end +--================ +--初始化所有节点 +--================ +function XUiRpgTowerGrowPageNaturePanel:CreateTalentsPoints() + self.Talents = {} + for pos, parent in pairs(self.TalentsParents) do + local prefab = parent:LoadPrefab(TalentPrefabPath) + local talent = XUiRpgTowerGrowPageNatureItem.New(prefab) + self.Talents[pos] = talent + end +end +--================ +--初始化所有天赋连线 +--================ +function XUiRpgTowerGrowPageNaturePanel:CreateTalentsLine() + self.TalentsLine = {} + for pos, parent in pairs(self.TalentsParents) do + self.TalentsLine[pos] = {} + local prePos = XRpgTowerConfig.GetTalentPrePosIdsByTalentPosId(pos) + for _, prePosId in pairs(prePos) do + local lineUi = parent:Find(string.format("%d_%d", prePosId, pos)) + local line = XUiRpgTowerGrowPageNatureLine.New(lineUi, prePosId, pos) + self.TalentsLine[pos][prePosId] = line + end + end +end +--================ +--点击天赋汇总 +--================ +function XUiRpgTowerGrowPageNaturePanel:OnClickTalentTotal() + if not self.RCharacter then return end + XLuaUiManager.Open("UiRpgTowerCollect", self.RCharacter) +end +return XUiRpgTowerGrowPageNaturePanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/GrowPage/XUiRpgTowerGrowPageTabsPanel.lua b/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/GrowPage/XUiRpgTowerGrowPageTabsPanel.lua new file mode 100644 index 00000000..fddfef1c --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/GrowPage/XUiRpgTowerGrowPageTabsPanel.lua @@ -0,0 +1,91 @@ +--兵法蓝图成员列表养成页面页签 +local XUiRpgTowerGrowPageTabsPanel = XClass(nil, "XUiRpgTowerGrowPageTabsPanel") +--================ +--页签项枚举 +--================ +local TAB_BTN_INDEX = { + LevelUp = 1, + Nature = 2, +} +--================ +--页签项对应的子面板索引 +--================ +local PANEL_INDEX = { + [TAB_BTN_INDEX.LevelUp] = "LevelUp", + [TAB_BTN_INDEX.Nature] = "Nature" +} +--================ +--子面板to场景相机字典 +--================ +local CAMERA_INDEX + +function XUiRpgTowerGrowPageTabsPanel:Ctor(ui, page, rootUi) + XTool.InitUiObjectByUi(self, ui) + self.Page = page + self.RootUi = rootUi + self:InitCameraIndex() + self:InitTabs() + self.BtnExchange.CallBack = function() self:OnClickChangeMember() end + self.PanelButtons:SelectIndex(TAB_BTN_INDEX.LevelUp) +end + +--================ +--初始化子面板to场景相机字典 +--================ +function XUiRpgTowerGrowPageTabsPanel:InitCameraIndex() + CAMERA_INDEX = { + [TAB_BTN_INDEX.LevelUp] = XDataCenter.RpgTowerManager.UiCharacter_Camera.LEVELUP, + [TAB_BTN_INDEX.Nature] = XDataCenter.RpgTowerManager.UiCharacter_Camera.NATURE + } +end +--================ +--初始化页签组控件 +--================ +function XUiRpgTowerGrowPageTabsPanel:InitTabs() + local tabGroup = { + self.BtnTabLevelUp, + self.BtnTabNature, + } + self.PanelButtons:Init(tabGroup, function(tabIndex) self:OnClickTabCallBack(tabIndex) end) +end +--================ +--点击页签时方法 +--================ +function XUiRpgTowerGrowPageTabsPanel:OnClickTabCallBack(tabIndex) + self.CurrentTab = tabIndex + self:ShowPanel() +end +--================ +--显示面板 +--================ +function XUiRpgTowerGrowPageTabsPanel:ShowPanel() + self.GameObject:SetActiveEx(true) + self.Page:OpenChildWindow(PANEL_INDEX[self.CurrentTab]) + self.RootUi:UpdateCamera(CAMERA_INDEX[self.CurrentTab]) +end +--================ +--刷新面板 +--================ +function XUiRpgTowerGrowPageTabsPanel:RefreshData(rChara) + self:RefreshTabRed(rChara) +end +--================ +--刷新页签红点 +--================ +function XUiRpgTowerGrowPageTabsPanel:RefreshTabRed(rChara) + self.BtnTabLevelUp:ShowReddot(rChara:CheckCanLevelUp()) + self.BtnTabNature:ShowReddot(rChara:CheckCanActiveTalent()) +end +--================ +--隐藏面板 +--================ +function XUiRpgTowerGrowPageTabsPanel:HidePanel() + self.GameObject:SetActiveEx(false) +end +--================ +--点击更换队员按钮 +--================ +function XUiRpgTowerGrowPageTabsPanel:OnClickChangeMember() + self.RootUi:OpenChildPage(XDataCenter.RpgTowerManager.PARENT_PAGE.CHANGEMEMBER) +end +return XUiRpgTowerGrowPageTabsPanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/GrowPage/XUiRpgTowerLevelUpTipsPanel.lua b/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/GrowPage/XUiRpgTowerLevelUpTipsPanel.lua new file mode 100644 index 00000000..c461a0b4 --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/GrowPage/XUiRpgTowerLevelUpTipsPanel.lua @@ -0,0 +1,46 @@ +-- 兵法蓝图升星成功提示页面控件 +local XUiRpgTowerLevelUpTipsPanel = XClass(nil, "XUiRpgTowerLevelUpTipsPanel") +local XUiRpgTowerCharaItem = require("XUi/XUiRpgTower/Common/XUiRpgTowerCharaItem") +local XUiRpgTowerItemIcon = require("XUi/XUiRpgTower/Common/XUiRpgTowerItemIcon") +function XUiRpgTowerLevelUpTipsPanel:Ctor(ui) + XTool.InitUiObjectByUi(self, ui) + self.PreLevelCharaItem = XUiRpgTowerCharaItem.New(self.CharaItemPreLevel, XDataCenter.RpgTowerManager.CharaItemShowType.OnlyIconAndStar) + self.NowLevelCharaItem = XUiRpgTowerCharaItem.New(self.CharaItemNowLevel, XDataCenter.RpgTowerManager.CharaItemShowType.OnlyIconAndStar) + CsXUiHelper.RegisterClickEvent(self.BtnCancel, function() self:HidePanel() end) + self.ItemIcon = XUiRpgTowerItemIcon.New(self.RImgTalentIcon) + self.GradeUpgradeDisable:stopped('+', function(director) self:HidePanelCallBack() end) +end +--================ +--刷新升级提示面板显示控件 +--================ +function XUiRpgTowerLevelUpTipsPanel:ShowTips(rChara) + self.PreLevelCharaItem:RefreshData(rChara) + self.PreLevelCharaItem:SetLevel(rChara:GetLevel() - 1) + self.NowLevelCharaItem:RefreshData(rChara) + self.TxtUnlockTheNumber.text = rChara:GetPreLevelSkillUpDescription() + self.TxtTalentNumber.text = rChara:GetPreUpgradeNaturePoint() + self.ItemIcon:InitIcon(rChara:GetTalentItem()) + self:ShowPanel() +end +--================ +--显示面板 +--================ +function XUiRpgTowerLevelUpTipsPanel:ShowPanel() + self.GradeUpgradeEnable.gameObject:SetActiveEx(false) + self.GradeUpgradeDisable.gameObject:SetActiveEx(false) + self.GameObject:SetActiveEx(true) + self.GradeUpgradeEnable.gameObject:SetActiveEx(true) +end +--================ +--隐藏面板 +--================ +function XUiRpgTowerLevelUpTipsPanel:HidePanel() + self.GradeUpgradeDisable.gameObject:SetActiveEx(true) +end +--================ +--隐藏面板动画结束回调 +--================ +function XUiRpgTowerLevelUpTipsPanel:HidePanelCallBack(director) + self.GameObject:SetActiveEx(false) +end +return XUiRpgTowerLevelUpTipsPanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/GrowPage/XUiRpgTowerRoleListGrowPage.lua b/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/GrowPage/XUiRpgTowerRoleListGrowPage.lua new file mode 100644 index 00000000..8a48732f --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/GrowPage/XUiRpgTowerRoleListGrowPage.lua @@ -0,0 +1,102 @@ +-- 兵法蓝图成员列表养成页面 +local XUiRpgTowerRoleListGrowPage = XClass(nil, "XUiRpgTowerRoleListGrowPage") +local XUiRpgTowerGrowPageTabsPanel = require("XUi/XUiRpgTower/CharacterPage/GrowPage/XUiRpgTowerGrowPageTabsPanel") +local XUiRpgTowerGrowPageNaturePanel = require("XUi/XUiRpgTower/CharacterPage/GrowPage/XUiRpgTowerGrowPageNaturePanel") +local XUiRpgTowerGrowPageLevelUpPanel = require("XUi/XUiRpgTower/CharacterPage/GrowPage/XUiRpgTowerGrowPageLevelUpPanel") +--================ +--子面板索引 +--================ +local ChildIndex = { + LevelUp = "LevelUp", + Nature = "Nature" +} +--================ +--子面板配置 +--================ +local ChildUiWindows + +function XUiRpgTowerRoleListGrowPage:Ctor(rootUi) + self.RootUi = rootUi + self.ChildList = {} + self:InitChildUiWindows() + self:CreateTabs() +end +--================ +--初始化子面板配置 +--================ +function XUiRpgTowerRoleListGrowPage:InitChildUiWindows() + ChildUiWindows = + { + [ChildIndex.LevelUp] = { + ChildClass = XUiRpgTowerGrowPageLevelUpPanel, + AssetPath = XUiConfigs.GetComponentUrl("RpgTowerRoleListChildWindow" .. ChildIndex.LevelUp), + }, + [ChildIndex.Nature] = { + ChildClass = XUiRpgTowerGrowPageNaturePanel, + AssetPath = XUiConfigs.GetComponentUrl("RpgTowerRoleListChildWindow" .. ChildIndex.Nature), + } + } +end +--================ +--创建页签面板(默认显示面板) +--================ +function XUiRpgTowerRoleListGrowPage:CreateTabs() + local ui = self.RootUi:LoadChildPrefab("NatureTabs", XUiConfigs.GetComponentUrl("RpgTowerRoleListChildWindowNatureTabs")) + self.Tabs = XUiRpgTowerGrowPageTabsPanel.New(ui, self, self.RootUi) +end +--================ +--显示页面 +--================ +function XUiRpgTowerRoleListGrowPage:ShowPage() + self.Tabs:ShowPanel() + self.RootUi:SetModelDragFieldActive(true) +end +--================ +--刷新页面 +--================ +function XUiRpgTowerRoleListGrowPage:RefreshPage(rChara) + self.Tabs:RefreshData(rChara) + for _, window in pairs(self.ChildList) do + window:RefreshData(rChara) + end +end +--================ +--隐藏页面 +--================ +function XUiRpgTowerRoleListGrowPage:HidePage() + for _, window in pairs(self.ChildList) do + window:HidePanel() + end + self.Tabs:HidePanel() + self.CurrentChildIndex = nil +end +--================ +--在面板被销毁时 +--================ +function XUiRpgTowerRoleListGrowPage:OnCollect() + for _, window in pairs(self.ChildList) do + if window.OnCollect then window:OnCollect() end + end +end +--================ +--打开子面板 +--================ +function XUiRpgTowerRoleListGrowPage:OpenChildWindow(panelIndex) + if self.CurrentChildIndex == panelIndex then return end + if self.CurrentChildIndex then + self.ChildList[self.CurrentChildIndex]:HidePanel() + end + self.CurrentChildIndex = panelIndex + if not self.ChildList[panelIndex] then self:CreateChild(panelIndex) end + self.ChildList[panelIndex]:ShowPanel() + self.ChildList[panelIndex]:RefreshData(self.RootUi.RCharacter) +end +--================ +--创建子面板 +--================ +function XUiRpgTowerRoleListGrowPage:CreateChild(panelIndex) + local ui = self.RootUi:LoadChildPrefab(panelIndex, ChildUiWindows[panelIndex].AssetPath) + self.ChildList[panelIndex] = ChildUiWindows[panelIndex].ChildClass.New(ui, self) +end + +return XUiRpgTowerRoleListGrowPage \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/MainPage/XUiRpgTowerCharaInfoInfo.lua b/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/MainPage/XUiRpgTowerCharaInfoInfo.lua new file mode 100644 index 00000000..cbed9bf4 --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/MainPage/XUiRpgTowerCharaInfoInfo.lua @@ -0,0 +1,42 @@ +-- 兵器蓝图角色页面角色状态面板人物信息栏 +local XUiRpgTowerCharaInfoInfo = XClass(nil, "XUiRpgTowerCharaInfoInfo") +local XUiRpgTowerStarPanel = require("XUi/XUiRpgTower/Common/XUiRpgTowerStarPanel") +function XUiRpgTowerCharaInfoInfo:Ctor(ui) + XTool.InitUiObjectByUi(self, ui) + XUiHelper.RegisterClickEvent(self, self.BtnCareerTips, function() self:OnClickBtnCareerTips() end) + self.BtnElementDetail.CallBack = function() self:OnClickBtnElementDetail() end +end +--================ +--刷新角色信息 +--================ +function XUiRpgTowerCharaInfoInfo:RefreshInfo(rCharacter) + self.RChara = rCharacter + self.RImgTypeIcon:SetRawImage(rCharacter:GetJobTypeIcon()) + self.TxtName.text = rCharacter:GetCharaName() + self.TxtAbility.text = rCharacter:GetAbility() + self.TxtNameOther.text = rCharacter:GetModelName() + local elementList = rCharacter:GetElements() + for i = 1, 3 do + local rImg = self["RImgCharElement" .. i] + if rImg and elementList[i] then + rImg.transform.gameObject:SetActive(true) + rImg:SetRawImage(elementList[i].Icon) + elseif rImg then + rImg.transform.gameObject:SetActive(false) + end + end +end +--================ +--点击元素信息 +--================ +function XUiRpgTowerCharaInfoInfo:OnClickBtnElementDetail() + if not self.RChara then return end + XLuaUiManager.Open("UiCharacterElementDetail", self.RChara:GetCharacterId()) +end +--================ +--点击职业信息 +--================ +function XUiRpgTowerCharaInfoInfo:OnClickBtnCareerTips() + XLuaUiManager.Open("UiCharacterCarerrTips") +end +return XUiRpgTowerCharaInfoInfo \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/MainPage/XUiRpgTowerCharaInfoSkillGrid.lua b/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/MainPage/XUiRpgTowerCharaInfoSkillGrid.lua new file mode 100644 index 00000000..85bd6d70 --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/MainPage/XUiRpgTowerCharaInfoSkillGrid.lua @@ -0,0 +1,23 @@ +-- 兵器蓝图角色页面角色状态面板技能控件 +local XUiRpgTowerCharaInfoSkillGrid = XClass(nil, "XUiRpgTowerCharaInfoSkillGrid") +function XUiRpgTowerCharaInfoSkillGrid:Ctor(ui) + XTool.InitUiObjectByUi(self, ui) + self.PanelLock.gameObject:SetActiveEx(false) + self.BtnSkill.CallBack = function() self:OnSkillClick() end +end +--================ +--刷新技能数据 +--================ +function XUiRpgTowerCharaInfoSkillGrid:RefreshSkill(skillInfo) + self.SkillInfo = skillInfo + self.BtnSkill:SetRawImage(skillInfo.Icon) + self.TxtLevel.text = skillInfo.Level +end +--================ +--点击此控件时 +--================ +function XUiRpgTowerCharaInfoSkillGrid:OnSkillClick() + if not self.SkillInfo then return end + XLuaUiManager.Open("UiRpgTowerSkillDetails", self.SkillInfo) +end +return XUiRpgTowerCharaInfoSkillGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/MainPage/XUiRpgTowerCharaInfoSkills.lua b/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/MainPage/XUiRpgTowerCharaInfoSkills.lua new file mode 100644 index 00000000..6a015d2f --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/MainPage/XUiRpgTowerCharaInfoSkills.lua @@ -0,0 +1,36 @@ +-- 兵器蓝图角色页面角色状态面板技能栏 +local XUiRpgTowerCharaInfoSkills = XClass(nil, "XUiRpgTowerCharaInfoSkills") +local XUiRpgTowerCharaInfoSkillGrid = require("XUi/XUiRpgTower/CharacterPage/MainPage/XUiRpgTowerCharaInfoSkillGrid") +function XUiRpgTowerCharaInfoSkills:Ctor(ui) + XTool.InitUiObjectByUi(self, ui) + self.GridSkill.gameObject:SetActiveEx(false) + self.SkillList = {} +end +--================ +--刷新技能信息 +--================ +function XUiRpgTowerCharaInfoSkills:RefreshSkills(rCharacter) + local skills = rCharacter:GetRoleListSkill() + self:ResetSkillList() + local index = 1 + for _, skillInfo in pairs(skills) do + if not self.SkillList[index] then + local skillUi = CS.UnityEngine.GameObject.Instantiate(self.GridSkill) + skillUi.transform:SetParent(self.PanelSkills.transform, false) + self.SkillList[index] = XUiRpgTowerCharaInfoSkillGrid.New(skillUi) + end + self.SkillList[index]:RefreshSkill(skillInfo) + self.SkillList[index].GameObject:SetActiveEx(true) + index = index + 1 + end +end +--================ +--刷新技能列表 +--================ +function XUiRpgTowerCharaInfoSkills:ResetSkillList() + for _, grid in pairs(self.SkillList) do + grid.GameObject:SetActiveEx(false) + end +end + +return XUiRpgTowerCharaInfoSkills \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/MainPage/XUiRpgTowerCharaInfoStatus.lua b/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/MainPage/XUiRpgTowerCharaInfoStatus.lua new file mode 100644 index 00000000..3224d768 --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/MainPage/XUiRpgTowerCharaInfoStatus.lua @@ -0,0 +1,17 @@ +-- 兵器蓝图角色页面角色状态面板属性栏 +local XUiRpgTowerCharaInfoStatus = XClass(nil, "XUiRpgTowerCharaInfoStatus") +function XUiRpgTowerCharaInfoStatus:Ctor(ui) + XTool.InitUiObjectByUi(self, ui) +end +--================ +--刷新状态信息 +--================ +function XUiRpgTowerCharaInfoStatus:RefreshStatus(rCharacter) + local attr = rCharacter:GetCharaAttributes() + local attrTypeData = rCharacter:GetDisplayAttrTypeData() + for i = 1, #attrTypeData do + self["TxtAttrib" .. i].text = FixToInt(attr[attrTypeData[i].Type]) + self["TxtAttribName" .. i].text = attrTypeData[i].Name + end +end +return XUiRpgTowerCharaInfoStatus \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/MainPage/XUiRpgTowerRoleListCharaInfo.lua b/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/MainPage/XUiRpgTowerRoleListCharaInfo.lua new file mode 100644 index 00000000..ac9478d9 --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/MainPage/XUiRpgTowerRoleListCharaInfo.lua @@ -0,0 +1,47 @@ +-- 兵器蓝图角色页面角色状态面板 +local XUiRpgTowerRoleListCharaInfo = XClass(nil, "XUiRpgTowerRoleListCharaInfo") +local XUiRpgTowerCharaInfoInfo = require("XUi/XUiRpgTower/CharacterPage/MainPage/XUiRpgTowerCharaInfoInfo") +local XUiRpgTowerCharaInfoStatus = require("XUi/XUiRpgTower/CharacterPage/MainPage/XUiRpgTowerCharaInfoStatus") +local XUiRpgTowerCharaInfoSkills = require("XUi/XUiRpgTower/CharacterPage/MainPage/XUiRpgTowerCharaInfoSkills") +function XUiRpgTowerRoleListCharaInfo:Ctor(ui, page) + XTool.InitUiObjectByUi(self, ui) + self.Page = page + self.InfoPanel = XUiRpgTowerCharaInfoInfo.New(self.PanelCharacterInfo) + self.StatusPanel = XUiRpgTowerCharaInfoStatus.New(self.PanelCharacterStatus) + self.SkillPanel = XUiRpgTowerCharaInfoSkills.New(self.PanelCharacterSkills) + CsXUiHelper.RegisterClickEvent(self.BtnLevelUp, function() self:OnClickBtnLevelUp() end) +end +--================ +--刷新面板数据(刷新子面板) +--================ +function XUiRpgTowerRoleListCharaInfo:RefreshData(rChara) + self.InfoPanel:RefreshInfo(rChara) + self.StatusPanel:RefreshStatus(rChara) + self.SkillPanel:RefreshSkills(rChara) + self.LevelUpRedPoint.gameObject:SetActiveEx(rChara:CheckCanActiveTalent()) + if self.AnimEnable then + self.AnimEnable.time = 0 + self.AnimEnable:Play() + end + self.Page.RootUi:PlayAnimation("SViewCharacterListEnable") +end +--================ +--点击升级按钮 +--================ +function XUiRpgTowerRoleListCharaInfo:OnClickBtnLevelUp() + self.Page.RootUi:OpenChildPage(XDataCenter.RpgTowerManager.PARENT_PAGE.ADAPT) +end +--================ +--显示面板 +--================ +function XUiRpgTowerRoleListCharaInfo:ShowPanel() + self.GameObject:SetActiveEx(true) +end +--================ +--隐藏面板 +--================ +function XUiRpgTowerRoleListCharaInfo:HidePanel() + self.GameObject:SetActiveEx(false) +end + +return XUiRpgTowerRoleListCharaInfo \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/MainPage/XUiRpgTowerRoleListMainPage.lua b/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/MainPage/XUiRpgTowerRoleListMainPage.lua new file mode 100644 index 00000000..2e99d4f1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/MainPage/XUiRpgTowerRoleListMainPage.lua @@ -0,0 +1,80 @@ +-- 兵法蓝图成员列表主页面控件 +local XUiRpgTowerRoleListMainPage = XClass(nil, "XUiRpgTowerRoleListMainPage") +local XUiRpgTowerTeamList = require("XUi/XUiRpgTower/CharacterPage/PanelCharacterList/XUiRpgTowerTeamList") +local XUiRpgTowerRoleListCharaInfo = require("XUi/XUiRpgTower/CharacterPage/MainPage/XUiRpgTowerRoleListCharaInfo") +local XUiRpgTowerTeamBar = require("XUi/XUiRpgTower/Common/XUiRpgTowerTeamBar") +--================ +--子控件索引 +--================ +local ChildIndex = { + CharaInfo = "CharaInfo", +} +--================ +--子控件配置 +--================ +local ChildUiWindows + +function XUiRpgTowerRoleListMainPage:Ctor(rootUi) + self.RootUi = rootUi + self:InitChildUiWindows() + self:InitCharacterList() + self.ChildList = {} +end +--================ +--初始化子控件配置 +--================ +function XUiRpgTowerRoleListMainPage:InitChildUiWindows() + ChildUiWindows = + { + [ChildIndex.CharaInfo] = { + ChildClass = XUiRpgTowerRoleListCharaInfo, + AssetPath = XUiConfigs.GetComponentUrl("RpgTowerRoleListChildWindow" .. ChildIndex.CharaInfo), + } + } +end +--================ +--初始化角色列表(页面默认显示控件) +--================ +function XUiRpgTowerRoleListMainPage:InitCharacterList() + self.TeamBar = XUiRpgTowerTeamBar.New(self.RootUi.PanelTeamLevel, self.RootUi) + self.CharacterList = XUiRpgTowerTeamList.New(self.RootUi.PanelCharacterList, self.RootUi) +end +--================ +--显示子页面 +--================ +function XUiRpgTowerRoleListMainPage:ShowPage() + if not self.ChildList[ChildIndex.CharaInfo] then self:CreateChild(ChildIndex.CharaInfo) end + self.ChildList[ChildIndex.CharaInfo]:ShowPanel() + self.CharacterList:ShowPanel() + self.TeamBar:RefreshBar() + self.TeamBar.GameObject:SetActiveEx(true) + self.RootUi:UpdateCamera(XDataCenter.RpgTowerManager.UiCharacter_Camera.MAIN) + self.RootUi:SetModelDragFieldActive(true) +end +--================ +--刷新子页面 +--================ +function XUiRpgTowerRoleListMainPage:RefreshPage(rChara) + for _, window in pairs(self.ChildList) do + window:RefreshData(rChara) + end +end +--================ +--隐藏子页面 +--================ +function XUiRpgTowerRoleListMainPage:HidePage() + for _, window in pairs(self.ChildList) do + window:HidePanel() + end + self.CharacterList:HidePanel() + self.TeamBar.GameObject:SetActiveEx(false) +end +--================ +--创建子控件 +--================ +function XUiRpgTowerRoleListMainPage:CreateChild(panelIndex) + local ui = self.RootUi:LoadChildPrefab(panelIndex, ChildUiWindows[panelIndex].AssetPath) + self.ChildList[panelIndex] = ChildUiWindows[panelIndex].ChildClass.New(ui, self) +end + +return XUiRpgTowerRoleListMainPage \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/PanelCharacterList/XUiRpgTowerTeamList.lua b/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/PanelCharacterList/XUiRpgTowerTeamList.lua new file mode 100644 index 00000000..0457ad28 --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/PanelCharacterList/XUiRpgTowerTeamList.lua @@ -0,0 +1,72 @@ +-- 兵法蓝图队伍列表面板 +local XUiRpgTowerTeamList = XClass(nil, "XUiRpgTowerTeamList") +local XUiRpgTowerTeamListItem = require("XUi/XUiRpgTower/CharacterPage/PanelCharacterList/XUiRpgTowerTeamListItem") +function XUiRpgTowerTeamList:Ctor(ui, rootUi) + XTool.InitUiObjectByUi(self, ui) + self.RootUi = rootUi + self.GridCharacter.gameObject:SetActiveEx(false) + self.DynamicTable = XDynamicTableNormal.New(self.GameObject) + self.DynamicTable:SetProxy(XUiRpgTowerTeamListItem) + self.DynamicTable:SetDelegate(self) +end +--动态列表事件 +function XUiRpgTowerTeamList:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(grid.DynamicGrid.gameObject, self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + if self.TeamList and self.TeamList[index] then + grid:RefreshData(self.TeamList[index], index) + if self.CurrentIndex == index then + grid:SetSelect(true) + end + end + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + grid:OnClick() + end +end +--================ +--刷新列表 +--================ +function XUiRpgTowerTeamList:UpdateData() + self.TeamList = XDataCenter.RpgTowerManager.GetTeam() + -- 获取当前选中角色在列表中的序号,若没有选中角色则默认列表第一个角色 + local rChara = self.RootUi.RCharacter + if rChara then + for index, member in pairs(self.TeamList) do + if member == rChara then + self.CurrentIndex = index + break + end + end + end + self.CurrentIndex = self.CurrentIndex or 1 + self.DynamicTable:SetDataSource(self.TeamList) + self.DynamicTable:ReloadDataASync(1) +end +--================ +--列表项选中事件 +--================ +function XUiRpgTowerTeamList:SetSelect(grid) + if self.CurGrid == grid then return end + if self.CurGrid then + self.CurGrid:SetSelect(false) + end + self.CurGrid = grid + self.CurrentIndex = grid.GridIndex + self.RootUi:OnCharaSelect(grid.RChara) +end +--================ +--显示面板 +--================ +function XUiRpgTowerTeamList:ShowPanel(isUpdate) + self.GameObject:SetActiveEx(true) + self.RootUi:PlayAnimation("SViewCharacterListEnable") + self:UpdateData() +end +--================ +--隐藏面板 +--================ +function XUiRpgTowerTeamList:HidePanel() + self.GameObject:SetActiveEx(false) +end +return XUiRpgTowerTeamList \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/PanelCharacterList/XUiRpgTowerTeamListItem.lua b/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/PanelCharacterList/XUiRpgTowerTeamListItem.lua new file mode 100644 index 00000000..1ddc302d --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/PanelCharacterList/XUiRpgTowerTeamListItem.lua @@ -0,0 +1,39 @@ +-- 兵法蓝图队伍列表控件 +local XUiRpgTowerTeamListItem = XClass(nil, "XUiRpgTowerTeamListItem") +local XUiRpgTowerCharaItem = require("XUi/XUiRpgTower/Common/XUiRpgTowerCharaItem") +function XUiRpgTowerTeamListItem:Ctor() + +end + +function XUiRpgTowerTeamListItem:Init(ui, list) + XTool.InitUiObjectByUi(self, ui) + self.List = list + self.PanelSelected.gameObject:SetActiveEx(false) + self.CharacterItem = XUiRpgTowerCharaItem.New(ui, + XDataCenter.RpgTowerManager.CharaItemShowType.Normal) +end +--================ +--刷新数据 +--================ +function XUiRpgTowerTeamListItem:RefreshData(rCharacter, gridIndex) + self.CharacterItem:RefreshData(rCharacter) + self.RChara = rCharacter + self.GridIndex = gridIndex + if self.Red then self.Red.gameObject:SetActiveEx(rCharacter:CheckCanActiveTalent()) end +end +--================ +--点击事件 +--================ +function XUiRpgTowerTeamListItem:OnClick() + if self.IsSelect then return end + self:SetSelect(true) +end +--================ +--选中事件 +--================ +function XUiRpgTowerTeamListItem:SetSelect(isSelect) + self.IsSelect = isSelect + self.PanelSelected.gameObject:SetActiveEx(isSelect) + self.List:SetSelect(self) +end +return XUiRpgTowerTeamListItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/SkillDetails/XUiRpgTowerSkillDetails.lua b/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/SkillDetails/XUiRpgTowerSkillDetails.lua new file mode 100644 index 00000000..ccc31abc --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/SkillDetails/XUiRpgTowerSkillDetails.lua @@ -0,0 +1,27 @@ +-- 兵法蓝图技能详细界面 +local XUiRpgTowerSkillDetails = XLuaUiManager.Register(XLuaUi, "UiRpgTowerSkillDetails") + +function XUiRpgTowerSkillDetails:OnAwake() + XTool.InitUiObject(self) + self.BtnTanchuangClose.CallBack = function() self:OnClose() end +end + +function XUiRpgTowerSkillDetails:OnStart(skillInfo) + self.SkillInfo = skillInfo + self:RefreshSkill() +end +--================ +--刷新面板内容控件 +--================ +function XUiRpgTowerSkillDetails:RefreshSkill() + self.RImgSkill:SetRawImage(self.SkillInfo.Icon) + self.TxtCount.text = self.SkillInfo.Level + self.TxtName.text = self.SkillInfo.Name + self.TxtWorldDesc.text = self.SkillInfo.Intro +end +--================ +--点击关闭按钮 +--================ +function XUiRpgTowerSkillDetails:OnClose() + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/TalentDetails/XUiRpgTowerNature.lua b/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/TalentDetails/XUiRpgTowerNature.lua new file mode 100644 index 00000000..301d3172 --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/TalentDetails/XUiRpgTowerNature.lua @@ -0,0 +1,88 @@ +-- 兵法蓝图天赋详细页面 +local XUiRpgTowerNature = XLuaUiManager.Register(XLuaUi, "UiRpgTowerNature") +local ItemIcon = require("XUi/XUiRpgTower/Common/XUiRpgTowerItemIcon") +function XUiRpgTowerNature:OnAwake() + XTool.InitUiObject(self) + self.BtnClose.CallBack = function() self:OnClose() end + self.BtnActive.CallBack = function() self:OnClickActive() end +end + +function XUiRpgTowerNature:OnStart(rTalent) + self.RTalent = rTalent + self:RefreshTalent() +end + +function XUiRpgTowerNature:OnEnable() + self:AddEventListener() +end + +function XUiRpgTowerNature:OnDisable() + self:RemoveEventListener() +end + +function XUiRpgTowerNature:OnDestroy() + self:RemoveEventListener() +end +--================ +--增加Event监听 +--================ +function XUiRpgTowerNature:AddEventListener() + if self.AddEvent == true then return end + self.AddEvent = true + XEventManager.AddEventListener(XEventId.EVENT_RPGTOWER_ON_TALENT_UNLOCK, self.OnUnLockSuccess, self) +end +--================ +--移除Event监听 +--================ +function XUiRpgTowerNature:RemoveEventListener() + if self.AddEvent == false then return end + self.AddEvent = false + XEventManager.RemoveEventListener(XEventId.EVENT_RPGTOWER_ON_TALENT_UNLOCK, self.OnUnLockSuccess, self) +end +--================ +--天赋解锁成功时(回调) +--================ +function XUiRpgTowerNature:OnUnLockSuccess() + self:Close() +end +--================ +--刷新面板内容控件 +--================ +function XUiRpgTowerNature:RefreshTalent() + self.RImgSkill:SetRawImage(self.RTalent:GetIconPath()) + self.TxtCost.text = self.RTalent:GetCostStr() + self.TxtName.text = self.RTalent:GetTalentName() + self.TxtDesc.text = self.RTalent:GetDescription() + local chara = XDataCenter.RpgTowerManager.GetTeamMemberByCharacterId(self.RTalent:GetCharacterId()) + self.ItemIcon = ItemIcon.New(self.RImgTalentIcon, chara:GetTalentItem()) + if self.RTalent:GetIsUnLock() then + self.TxtCost.gameObject:SetActiveEx(false) + self.BtnActive:SetButtonState(CS.UiButtonState.Disable) + self.BtnActive:SetName(CS.XTextManager.GetText("RpgTowerTalentActive")) + elseif not self.RTalent:GetCanUnLock() then + if not self.RTalent:CheckNeedTeamLevel() then + self.TxtCost.gameObject:SetActiveEx(false) + self.BtnActive:SetName(CS.XTextManager.GetText("RpgTowerTalentLock")) + else + self.TxtCost.gameObject:SetActiveEx(true) + self.BtnActive:SetButtonState(CS.UiButtonState.Normal) + self.BtnActive:SetName(CS.XTextManager.GetText("RpgTowerUnlockTalent")) + end + else + self.TxtCost.gameObject:SetActiveEx(true) + self.BtnActive:SetButtonState(CS.UiButtonState.Normal) + self.BtnActive:SetName(CS.XTextManager.GetText("RpgTowerUnlockTalent")) + end +end +--================ +--点击激活按钮 +--================ +function XUiRpgTowerNature:OnClickActive() + XDataCenter.RpgTowerManager.CharaTalentActive(self.RTalent) +end +--================ +--点击关闭按钮 +--================ +function XUiRpgTowerNature:OnClose() + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/TalentTotalView/XUiRpgTowerCollect.lua b/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/TalentTotalView/XUiRpgTowerCollect.lua new file mode 100644 index 00000000..12509a5b --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/TalentTotalView/XUiRpgTowerCollect.lua @@ -0,0 +1,44 @@ +-- 兵法蓝图角色天赋总览页面 +local XUiRpgTowerCollect = XLuaUiManager.Register(XLuaUi, "UiRpgTowerCollect") +local PanelStatus = require("XUi/XUiRpgTower/CharacterPage/TalentTotalView/XUiRpgTowerCollectPanelStatus") +local PanelSkill = require("XUi/XUiRpgTower/CharacterPage/TalentTotalView/XUiRpgTowerCollectPanelSkillInfo") +local PanelTalent = require("XUi/XUiRpgTower/CharacterPage/TalentTotalView/XUiRpgTowerCollectPanelTalent") + +function XUiRpgTowerCollect:OnAwake() + XTool.InitUiObject(self) + self:InitPanels() + self.BtnTanchuangClose.CallBack = function() self:OnClickClose() end +end + +function XUiRpgTowerCollect:OnStart(rCharacter) + self.RCharacter = rCharacter + self:Refresh() +end + +function XUiRpgTowerCollect:InitPanels() + --self:InitPanelStatus() + --self:InitPanelSkillInfo() + self:InitPanelTalent() +end + +function XUiRpgTowerCollect:InitPanelStatus() + self.Status = PanelStatus.New(self.PanelStatus) +end + +function XUiRpgTowerCollect:InitPanelSkillInfo() + self.SkillInfo = PanelSkill.New(self.PanelSkill) +end + +function XUiRpgTowerCollect:InitPanelTalent() + self.Talent = PanelTalent.New(self.GameObject) +end + +function XUiRpgTowerCollect:Refresh() + --self.Status:Refresh(self.RCharacter) + --self.SkillInfo:Refresh(self.RCharacter) + self.Talent:Refresh(self.RCharacter) +end + +function XUiRpgTowerCollect:OnClickClose() + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/TalentTotalView/XUiRpgTowerCollectPanelSkillInfo.lua b/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/TalentTotalView/XUiRpgTowerCollectPanelSkillInfo.lua new file mode 100644 index 00000000..69f71f29 --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/TalentTotalView/XUiRpgTowerCollectPanelSkillInfo.lua @@ -0,0 +1,45 @@ +-- 兵法蓝图天赋总览技能等级面板 +local XUiRpgTowerCollectPanelSkillInfo = XClass(nil, "XUiRpgTowerCollectPanelSkillInfo") +local SkillDic = { -- 技能尾数编号字典 + RedBall = 1, -- 红球 + YellowBall = 6, -- 黄球 + BlueBall = 11, -- 蓝球 + NormalAttack = 16, -- 普通攻击 + FinalSkill = 17, -- 必杀 + CoreSkill = 21 -- 核心被动技能 +} +function XUiRpgTowerCollectPanelSkillInfo:Ctor(ui) + XTool.InitUiObjectByUi(self, ui) +end + +function XUiRpgTowerCollectPanelSkillInfo:Refresh(rChara) + self:ResetLevels() + local skills = rChara:GetSkillPlusData() + for skillId, skillLevel in pairs(skills) do + local skillType = skillId % 100 + if skillType == SkillDic.RedBall then + self.TxtRedNumber.text = skillLevel + elseif skillType == SkillDic.YellowBall then + self.TxtYellowNumber.text = skillLevel + elseif skillType == SkillDic.BlueBall then + self.TxtBlueNumber.text = skillLevel + elseif skillType == SkillDic.NormalAttack then + self.TxtAttackNumber.text = skillLevel + elseif skillType == SkillDic.FinalSkill then + self.TxtSpaceNumber.text = skillLevel + elseif skillType == SkillDic.CoreSkill then + self.TxtPassiveNumber.text = skillLevel + end + end +end + +function XUiRpgTowerCollectPanelSkillInfo:ResetLevels() + self.TxtRedNumber.text = 0 + self.TxtBlueNumber.text = 0 + self.TxtYellowNumber.text = 0 + self.TxtAttackNumber.text = 0 + self.TxtSpaceNumber.text = 0 + self.TxtPassiveNumber.text = 0 +end + +return XUiRpgTowerCollectPanelSkillInfo \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/TalentTotalView/XUiRpgTowerCollectPanelStatus.lua b/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/TalentTotalView/XUiRpgTowerCollectPanelStatus.lua new file mode 100644 index 00000000..610f3843 --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/TalentTotalView/XUiRpgTowerCollectPanelStatus.lua @@ -0,0 +1,19 @@ +-- 兵法蓝图天赋总览页面角色属性面板 +local XUiRpgTowerCollectPanelStatus = XClass(nil, "XUiRpgTowerCollectPanelStatus") + +function XUiRpgTowerCollectPanelStatus:Ctor(ui) + XTool.InitUiObjectByUi(self, ui) +end + +function XUiRpgTowerCollectPanelStatus:Refresh(rChara) + local attr = rChara:GetCharaTalentPlusAttr() + if not attr then + self.TxtAttackNumber.text = 0 + self.TxtLifeNumber.text = 0 + return + end + self.TxtAttackNumber.text = FixToInt(attr[XNpcAttribType.AttackNormal]) + self.TxtLifeNumber.text = FixToInt(attr[XNpcAttribType.Life]) +end + +return XUiRpgTowerCollectPanelStatus \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/TalentTotalView/XUiRpgTowerCollectPanelTalent.lua b/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/TalentTotalView/XUiRpgTowerCollectPanelTalent.lua new file mode 100644 index 00000000..77c7b116 --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/TalentTotalView/XUiRpgTowerCollectPanelTalent.lua @@ -0,0 +1,27 @@ +-- 兵法蓝图天赋总览天赋列表面板 +local XUiRpgTowerCollectPanelTalent = XClass(nil, "XUiRpgTowerCollectPanelTalent") +local TalentItem = require("XUi/XUiRpgTower/CharacterPage/TalentTotalView/XUiRpgTowerCollectTalentGrid") +function XUiRpgTowerCollectPanelTalent:Ctor(ui) + XTool.InitUiObjectByUi(self, ui) + self.TalentGridSample.gameObject:SetActiveEx(false) +end + +function XUiRpgTowerCollectPanelTalent:Refresh(rChara) + local talents = rChara:GetTalents() + local isEmpty = true + for layerId, rTalentLayer in pairs(talents) do + for index, rTalent in pairs(rTalentLayer) do + if rTalent:GetIsUnLock() then + isEmpty = false + local ui = CS.UnityEngine.GameObject.Instantiate(self.TalentGridSample) + ui.transform:SetParent(self.PanelParent, false) + local item = TalentItem.New(ui) + item:Refresh(rTalent) + item.GameObject:SetActiveEx(true) + end + end + end + if self.ImgEmpty then self.ImgEmpty.gameObject:SetActiveEx(isEmpty) end +end + +return XUiRpgTowerCollectPanelTalent \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/TalentTotalView/XUiRpgTowerCollectTalentGrid.lua b/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/TalentTotalView/XUiRpgTowerCollectTalentGrid.lua new file mode 100644 index 00000000..190188fa --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/TalentTotalView/XUiRpgTowerCollectTalentGrid.lua @@ -0,0 +1,13 @@ +-- 兵法蓝图天赋总览技能列表项控件 +local XUiRpgTowerCollectTalentGrid = XClass(nil, "XUiRpgTowerCollectTalentGrid") + +function XUiRpgTowerCollectTalentGrid:Ctor(ui) + XTool.InitUiObjectByUi(self, ui) +end + +function XUiRpgTowerCollectTalentGrid:Refresh(rTalent) + self.RImgSkill:SetRawImage(rTalent:GetIconPath()) + self.TxtDescribe.text = rTalent:GetDescription() +end + +return XUiRpgTowerCollectTalentGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/XUiRpgTowerRoleList.lua b/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/XUiRpgTowerRoleList.lua new file mode 100644 index 00000000..02972257 --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgTower/CharacterPage/XUiRpgTowerRoleList.lua @@ -0,0 +1,227 @@ +-- 兵法蓝图成员列表主页面 +local XUiRpgTowerRoleList = XLuaUiManager.Register(XLuaUi, "UiRpgTowerRoleList") +local XUiRpgTowerRoleListCharaInfo = require("XUi/XUiRpgTower/CharacterPage/MainPage/XUiRpgTowerRoleListCharaInfo") + +local XUiRpgTowerRoleListMainPage = require("XUi/XUiRpgTower/CharacterPage/MainPage/XUiRpgTowerRoleListMainPage") +local XUiRpgTowerRoleListAdaptPage = require("XUi/XUiRpgTower/CharacterPage/AdaptPage/XUiRpgTowerRoleListAdaptPage") +local XUiRpgTowerRoleListChangeMemberPage = require("XUi/XUiRpgTower/CharacterPage/ChangeMemberPage/XUiRpgTowerRoleListChangeMemberPage") +-- 3D场景相机数量 +local CAMERA_NUM = 5 +-- 子页面枚举 +local PARENT_PAGE +-- 子页面控件脚本字典 +local ChildUiPage + +function XUiRpgTowerRoleList:OnAwake() + XTool.InitUiObject(self) + XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self:InitChildUiPageData() + self:InitButtons() + self:InitModel() + self.ChildPage = {} +end + +function XUiRpgTowerRoleList:OnEnable() + self:OnRefresh() +end + +function XUiRpgTowerRoleList:OnDestroy() + self:ChildPageOnCollect() +end + +function XUiRpgTowerRoleList:OnGetEvents() + return { XEventId.EVENT_RPGTOWER_RESET, XEventId.EVENT_RPGTOWER_MEMBERCHANGE } +end + +function XUiRpgTowerRoleList:OnNotify(evt, ...) + local args = { ... } + if evt == XEventId.EVENT_RPGTOWER_RESET then + self:OnActivityReset() + elseif evt == XEventId.EVENT_RPGTOWER_MEMBERCHANGE then + self:OnMemberChange() + end +end + +--================ +--活动周期结束时弹回主界面 +--================ +function XUiRpgTowerRoleList:OnActivityReset() + XLuaUiManager.RunMain() + XUiManager.TipMsg(CS.XTextManager.GetText("RpgTowerFinished")) +end + +--================ +--初始化枚举与字典 +--================ +function XUiRpgTowerRoleList:InitChildUiPageData() + PARENT_PAGE = { + MAIN = XDataCenter.RpgTowerManager.PARENT_PAGE.MAIN, -- 主页面 + ADAPT = XDataCenter.RpgTowerManager.PARENT_PAGE.ADAPT, -- 改造页面 + CHANGEMEMBER = XDataCenter.RpgTowerManager.PARENT_PAGE.CHANGEMEMBER -- 切换队员 + } + ChildUiPage = { + [PARENT_PAGE.MAIN] = XUiRpgTowerRoleListMainPage, + [PARENT_PAGE.ADAPT] = XUiRpgTowerRoleListAdaptPage, + [PARENT_PAGE.CHANGEMEMBER] = XUiRpgTowerRoleListChangeMemberPage + } +end +--================ +--初始化按钮事件 +--================ +function XUiRpgTowerRoleList:InitButtons() + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + self:BindHelpBtn(self.BtnHelp, "RpgTowerHelp") +end +--================ +--返回按钮事件 +--================ +function XUiRpgTowerRoleList:OnBtnBackClick() + if self.CurrentPageIndex == PARENT_PAGE.ADAPT then + self:OpenChildPage(PARENT_PAGE.MAIN) + return + elseif self.CurrentPageIndex == PARENT_PAGE.CHANGEMEMBER then + self:OpenChildPage(PARENT_PAGE.ADAPT) + return + end + self:Close() +end +--================ +--主界面按钮事件 +--================ +function XUiRpgTowerRoleList:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end +--================ +--页面刷新时 +--================ +function XUiRpgTowerRoleList:OnRefresh() + -- 默认第一次打开MAIN页面,若不是第一次打开,则打开最后停留的子页面 + self:OpenChildPage(self.CurrentPageIndex or PARENT_PAGE.MAIN) +end +--================ +--当选择角色时 +--================ +function XUiRpgTowerRoleList:OnCharaSelect(rChara, updateModelCb) + self.RCharacter = rChara + self:UpdateModel(rChara, updateModelCb) + self:ChildPageOnCharaSelect(rChara) +end +--================ +--子页面切换角色选择 +--================ +function XUiRpgTowerRoleList:ChildPageOnCharaSelect(rChara) + if self.ChildPage[self.CurrentPageIndex] then self.ChildPage[self.CurrentPageIndex]:RefreshPage(rChara) end +end +--================ +--当角色数据刷新时 +--================ +function XUiRpgTowerRoleList:OnMemberChange() + -- 刷新当前页面 + self.ChildPage[self.CurrentPageIndex]:RefreshPage(self.RCharacter) + self:UpdateModel(self.RCharacter) +end +--================ +--初始化角色模型和场景相机 +--================ +function XUiRpgTowerRoleList:InitModel() + local root = self.UiModelGo.transform + self.PanelRoleModel = root:FindTransform("PanelRoleModel") + self.ImgEffectHuanren = root:FindTransform("ImgEffectHuanren") + self.ImgEffectHuanren1 = root:FindTransform("ImgEffectHuanren1") + self.ImgEffectLogoGouzao = root:FindTransform("ImgEffectLogoGouzao") + self.ImgEffectLogoGanran = root:FindTransform("ImgEffectLogoGanran") + self.CameraFar = { + root:FindTransform("UiCamFarLv"), + root:FindTransform("UiCamFarGrade"), + root:FindTransform("UiCamFarQuality"), + root:FindTransform("UiCamFarSkill"), + root:FindTransform("UiCamFarrExchange"), + } + self.CameraNear = { + root:FindTransform("UiCamNearLv"), + root:FindTransform("UiCamNearGrade"), + root:FindTransform("UiCamNearQuality"), + root:FindTransform("UiCamNearSkill"), + root:FindTransform("UiCamNearrExchange"), + } + self.RoleModelPanel = XUiPanelRoleModel.New(self.PanelRoleModel, self.Name, nil, true, nil, true) +end +--================ +--刷新场景相机 +--================ +function XUiRpgTowerRoleList:UpdateCamera(cameraIndex) + self.CurCameraIndex = cameraIndex + for i = 1, CAMERA_NUM do + if self.CurCameraIndex ~= i then + self.CameraFar[i].gameObject:SetActiveEx(false) + self.CameraNear[i].gameObject:SetActiveEx(false) + end + end + + if self.CameraFar[self.CurCameraIndex] then + self.CameraFar[self.CurCameraIndex].gameObject:SetActiveEx(true) + end + + if self.CameraNear[self.CurCameraIndex] then + self.CameraNear[self.CurCameraIndex].gameObject:SetActiveEx(true) + end +end +--================ +--刷新模型 +--================ +function XUiRpgTowerRoleList:UpdateModel(rChara, updateModelCb) + self.ImgEffectHuanren.gameObject:SetActiveEx(false) + local cb = function(model) + self.PanelDrag.Target = model.transform + self.ImgEffectHuanren.gameObject:SetActiveEx(true) + if updateModelCb then updateModelCb(model) end + end + local robotCfg = XRobotManager.GetRobotTemplate(rChara:GetRobotId()) + self.RoleModelPanel:UpdateRobotModel(rChara:GetRobotId(), rChara:GetCharacterId(), nil, robotCfg and robotCfg.FashionId, robotCfg and robotCfg.WeaponId, cb) +end +--================ +--打开子页面,打开新页面时会关闭旧的子页面 +--================ +function XUiRpgTowerRoleList:OpenChildPage(pageIndex) + if self.CurrentPageIndex == pageIndex then return end + if self.CurrentPageIndex then + self.ChildPage[self.CurrentPageIndex]:HidePage() + end + if self.ChildPage[pageIndex] then + self.CurrentPageIndex = pageIndex + self.ChildPage[self.CurrentPageIndex]:ShowPage() + self.ChildPage[self.CurrentPageIndex]:RefreshPage(self.RCharacter) + return + end + self.CurrentPageIndex = pageIndex + self.ChildPage[pageIndex] = ChildUiPage[pageIndex].New(self) + self.ChildPage[pageIndex]:ShowPage() + if self.RCharacter then self.ChildPage[pageIndex]:RefreshPage(self.RCharacter) end +end +--================ +--关闭子页面 +--================ +function XUiRpgTowerRoleList:CloseChildPage(pageIndex) + if self.ChildPage[pageIndex] then self.ChildPage[pageIndex]:HidePage() end +end +--================ +--回收子页面 +--================ +function XUiRpgTowerRoleList:ChildPageOnCollect() + for _, page in pairs(self.ChildPage) do + if page.OnCollect then page:OnCollect() end + end +end +--================ +--读取面板控件 +--================ +function XUiRpgTowerRoleList:LoadChildPrefab(pageIndex, assetPath) + return self["Panel" .. pageIndex]:LoadPrefab(assetPath) +end +--================ +--设置滑动 +--================ +function XUiRpgTowerRoleList:SetModelDragFieldActive(isActive) + self.PanelDrag.gameObject:SetActiveEx(isActive) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgTower/Common/XUiRpgTowerCharaItem.lua b/Resources/Scripts/XUi/XUiRpgTower/Common/XUiRpgTowerCharaItem.lua new file mode 100644 index 00000000..1b4e0a4b --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgTower/Common/XUiRpgTowerCharaItem.lua @@ -0,0 +1,55 @@ +--兵法蓝图角色列表角色显示控件 +local XUiRpgTowerCharaItem = XClass(nil, "XUiRpgTowerCharaItem") +local XUiRpgTowerStarPanel = require("XUi/XUiRpgTower/Common/XUiRpgTowerStarPanel") +--[[ +================ +构造函数(一般New对象时) +================ +]] +function XUiRpgTowerCharaItem:Ctor(gameObject, showType, clickCallBack, useBigHeadIcon) + self:Init(gameObject, showType, clickCallBack, useBigHeadIcon) +end +--[[ +================ +初始化函数(动态列表初始化也调用) +================ +]] +function XUiRpgTowerCharaItem:Init(gameObject, showType, clickCallBack, useBigHeadIcon) + XTool.InitUiObjectByUi(self, gameObject) + self.ShowType = showType or XDataCenter.RpgTowerManager.CharaItemShowType.OnlyIconAndStar + self.ClickCb = clickCallBack + if self.BtnCharacter then + CsXUiHelper.RegisterClickEvent(self.BtnCharacter, function() self:OnClick() end) + else + CsXUiHelper.RegisterClickEvent(self.RImgHeadIcon, function() self:OnClick() end) + end + self.UseBigIcon = useBigHeadIcon +end +--[[ +================ +刷新角色数据 +@param rCharacter: XRpgTowerCharacter玩法角色对象 +================ +]] +function XUiRpgTowerCharaItem:RefreshData(rCharacter) + self.RCharacter = rCharacter + if self.ShowType == XDataCenter.RpgTowerManager.CharaItemShowType.Normal then + self.TxtName.text = self.RCharacter:GetCharaName() + end + if self.TxtAbility then self.TxtAbility.text = self.RCharacter:GetAbility() end + if self.UseBigIcon then + self.RImgHeadIcon:SetRawImage(self.RCharacter:GetBigHeadIcon()) + else + self.RImgHeadIcon:SetRawImage(self.RCharacter:GetSmallHeadIcon()) + end +end +--[[ +================ +点击事件 +================ +]] +function XUiRpgTowerCharaItem:OnClick() + if self.ClickCb then self.ClickCb() end +end + +return XUiRpgTowerCharaItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgTower/Common/XUiRpgTowerItemIcon.lua b/Resources/Scripts/XUi/XUiRpgTower/Common/XUiRpgTowerItemIcon.lua new file mode 100644 index 00000000..49a4cd0e --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgTower/Common/XUiRpgTowerItemIcon.lua @@ -0,0 +1,24 @@ +-- 兵法蓝图道具图标控件 +local XUiRpgTowerItemIcon = XClass(nil, "XUiRpgTowerItemIcon") + +function XUiRpgTowerItemIcon:Ctor(rawImg, rItem) + XTool.InitUiObjectByUi(self, rawImg) + self.RawImage = rawImg + if rItem then self:InitIcon(rItem) end +end +--=============== +--初始化图标 +--=============== +function XUiRpgTowerItemIcon:InitIcon(rItem) + self.RItem = rItem + self.RawImage:SetRawImage(rItem:GetIcon()) + CsXUiHelper.RegisterClickEvent(self.RawImage, function() self:OnClick() end) +end +--=============== +--点击事件 +--=============== +function XUiRpgTowerItemIcon:OnClick() + XLuaUiManager.Open("UiTip", self.RItem:GetTempItemData()) +end + +return XUiRpgTowerItemIcon \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgTower/Common/XUiRpgTowerLevelUp.lua b/Resources/Scripts/XUi/XUiRpgTower/Common/XUiRpgTowerLevelUp.lua new file mode 100644 index 00000000..13844c68 --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgTower/Common/XUiRpgTowerLevelUp.lua @@ -0,0 +1,37 @@ +--队伍提升面板 +local XUiRpgTowerLevelUp = XLuaUiManager.Register(XLuaUi, "UiRpgTowerLevelUp") + +function XUiRpgTowerLevelUp:OnAwake() + XTool.InitUiObject(self) +end + +function XUiRpgTowerLevelUp:OnStart() + self.LevelCfg = XDataCenter.RpgTowerManager.GetCurrentLevelCfg() + self:InitPanels() +end + +function XUiRpgTowerLevelUp:InitPanels() + if not self.LevelCfg then return end + self.TxtPreLevel.text = self.LevelCfg.PreLevel + self.TxtCurrentLevel.text = self.LevelCfg.Level + local allLayer = XRpgTowerConfig.GetAllTalentLayerCfgs() + local newLayer = false + for _, layer in pairs(allLayer) do + if layer.NeedTeamLevel == self.LevelCfg.Level then + newLayer = true + break + end + end + self.ObjNewLayerUnlockTips.gameObject:SetActiveEx(newLayer) + self.ObjNoLayerUnlockTips.gameObject:SetActiveEx(not newLayer) + self.TxtLevelUpCount.text = "+" .. self.LevelCfg.AddRoleLevel + local talentId = XDataCenter.RpgTowerManager.GetTalentItemId() + local itemCfg = XRpgTowerConfig.GetRItemConfigByRItemId(talentId) + self.RImgTalentPointIcon:SetRawImage(itemCfg.Icon) + self.TxtGetTalentPoint.text = self.LevelCfg.AddTalentPoint + self.TxtSkillUpCount.text = "+" .. self.LevelCfg.AddSkillLv + XUiHelper.RegisterClickEvent(self, self.BtnDarkBg, function() + self:Close() + XDataCenter.GuideManager.CheckGuideOpen() + end) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgTower/Common/XUiRpgTowerSettleWinExpBar.lua b/Resources/Scripts/XUi/XUiRpgTower/Common/XUiRpgTowerSettleWinExpBar.lua new file mode 100644 index 00000000..ae67ce2d --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgTower/Common/XUiRpgTowerSettleWinExpBar.lua @@ -0,0 +1,108 @@ +-- Rpg玩法队伍结算界面经验面板控件 +local XUiRpgTowerSettleWinExpBar = XClass(nil, "XUiRpgTowerSettleWinExpBar") +local FILL_SPEED = 1 +local CSTime = CS.UnityEngine.Time +local MathfLerp = CS.UnityEngine.Mathf.Lerp + +function XUiRpgTowerSettleWinExpBar:Ctor(uiGameObject, rootUi) + XTool.InitUiObjectByUi(self, uiGameObject) + self.RootUi = rootUi +end + +function XUiRpgTowerSettleWinExpBar:StartRun(expChangeData) + self:SetChangeData(expChangeData) +end + +function XUiRpgTowerSettleWinExpBar:StartFillExp() + self.StartFillTime = 0 + self.ImgPlayerExpFillAdd.fillAmount = 0 + self.TimeId = XScheduleManager.ScheduleForever(function() + if XTool.UObjIsNil(self.Transform) then + self:StopTimer() + return + end + self:LerpExp() + end, 0) +end + +function XUiRpgTowerSettleWinExpBar:SetChangeData(changeData) + local TeamExpNewChange = changeData.TeamExpNewChange + local PreTeamExp = changeData.PreTeamExp + local PreTeamLevel = changeData.PreTeamLevel + local preLevelCfg = XRpgTowerConfig.GetTeamLevelCfgByLevel(PreTeamLevel) + local TeamExp = changeData.TeamExp + local TeamLevel = changeData.TeamLevel + local curLevelCfg = XRpgTowerConfig.GetTeamLevelCfgByLevel(TeamLevel) + local ChangeExp = changeData.ChangeExp + local maxLevel = XDataCenter.RpgTowerManager.GetMaxLevel() + + if TeamExpNewChange and PreTeamLevel ~= maxLevel then + self.PlayLevelUpCount = TeamLevel - PreTeamLevel + self.BeginFillAmount = PreTeamExp / preLevelCfg.Exp + self.TargetFillAmount = TeamExp / curLevelCfg.Exp + self.ToMaxLevel = TeamLevel == maxLevel + self.TxtPlayerLevel.text = tostring(PreTeamLevel) + self.CurrentLevel = PreTeamLevel + self.TxtPlayerExp.text = "+ " .. tostring(ChangeExp) + self.DoingLevelUp = self.PlayLevelUpCount > 0 + self:StartFillExp() + else + if TeamLevel == maxLevel then + self.ImgPlayerExpFill.fillAmount = 1 + self.TxtPlayerLevel.text = "MAX" + else + self.ImgPlayerExpFill.fillAmount = TeamExp / curLevelCfg.Exp + self.TxtPlayerLevel.text = TeamLevel + end + self.ImgPlayerExpFillAdd.fillAmount = 0 + self.TxtPlayerExp.text = "+ 0" + end + +end + +function XUiRpgTowerSettleWinExpBar:LerpExp() + local lerpPercent = self.StartFillTime * FILL_SPEED + self.StartFillTime = self.StartFillTime + CSTime.deltaTime + if lerpPercent >= 1 then lerpPercent = 1 end + if self.PlayLevelUpCount > 0 then + self.ImgPlayerExpFill.fillAmount = MathfLerp(self.BeginFillAmount, 1, lerpPercent) + if lerpPercent >= 1 then + self.PlayLevelUpCount = self.PlayLevelUpCount - 1 + self.StartFillTime = 0 + self.BeginFillAmount = 0 + self.TxtPlayerLevel.text = self.CurrentLevel + 1 + self.CurrentLevel = self.CurrentLevel + 1 + if self.PlayLevelUpCount == 0 then + self.ImgPlayerExpFillAdd.fillAmount = self.TargetFillAmount + end + end + else + if not self.ToMaxLevel then + self.ImgPlayerExpFill.fillAmount = MathfLerp(self.BeginFillAmount, self.TargetFillAmount, lerpPercent) + if lerpPercent >= 1 then + self:StopTimer() + if self.DoingLevelUp then + self.DoingLevelUp = false + self:ShowLevelUpTips() + end + end + else + self.ImgPlayerExpFill.fillAmount = 1 + self.ImgPlayerExpFillAdd.fillAmount = 0 + self.TxtPlayerLevel.text = "MAX" + self:StopTimer() + end + end +end + +function XUiRpgTowerSettleWinExpBar:StopTimer() + if not self.TimerId then return end + XScheduleManager.UnSchedule(self.TimerId) + self.TimerId = nil +end + +function XUiRpgTowerSettleWinExpBar:ShowLevelUpTips() + XLuaUiManager.Open("UiRpgTowerLevelUp") +end + +return XUiRpgTowerSettleWinExpBar \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgTower/Common/XUiRpgTowerStarPanel.lua b/Resources/Scripts/XUi/XUiRpgTower/Common/XUiRpgTowerStarPanel.lua new file mode 100644 index 00000000..b84a074d --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgTower/Common/XUiRpgTowerStarPanel.lua @@ -0,0 +1,22 @@ +-- 兵法蓝图星级列表显示控件 +local XUiRpgTowerStarPanel = XClass(nil, "XUiRpgTowerStarPanel") +--[[ +================ +构造函数 +================ +]] +function XUiRpgTowerStarPanel:Ctor(ui) + XTool.InitUiObjectByUi(self, ui) +end +--[[ +================ +显示星数 +@param starNum:星数 +================ +]] +function XUiRpgTowerStarPanel:ShowStar(starNum) + for i = 1, 6 do + self[string.format("ImgCurLevel%d", i)].gameObject:SetActiveEx(i <= starNum) + end +end +return XUiRpgTowerStarPanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgTower/Common/XUiRpgTowerTeamBar.lua b/Resources/Scripts/XUi/XUiRpgTower/Common/XUiRpgTowerTeamBar.lua new file mode 100644 index 00000000..f2fe86ca --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgTower/Common/XUiRpgTowerTeamBar.lua @@ -0,0 +1,145 @@ +--Rpg玩法队伍经验面板控件 +local XUiRpgTowerTeamBar = XClass(nil, "XUiRpgTowerTeamBar") +local FILL_SPEED = 5 +local CSTime = CS.UnityEngine.Time +function XUiRpgTowerTeamBar:Ctor(ui, rootUi) + self.RootUi = rootUi + XTool.InitUiObjectByUi(self, ui) + self.MaxLevel = XDataCenter.RpgTowerManager.GetMaxLevel() +end +--================ +--设置等级 +--@param number level:等级 +--================ +function XUiRpgTowerTeamBar:SetLevel(level) + if level > self.MaxLevel then return end + self.Level = level + self.TxtLevel.text = level + local cfg = XRpgTowerConfig.GetTeamLevelCfgByLevel(level) + self.NextExp = cfg and cfg.Exp or 0 + self.FillAmountUnit = 1 / self.NextExp +end + +function XUiRpgTowerTeamBar:RefreshBar() + local level = XDataCenter.RpgTowerManager.GetCurrentLevel() + local exp = XDataCenter.RpgTowerManager.GetCurrentExp() + self:SetLevel(level) + self:SetExpText(exp) +end +--================ +--检查是否满级 +--@return bool:已满级true 未满级false +--================ +function XUiRpgTowerTeamBar:CheckIsMaxLevel() + return self.Level >= self.MaxLevel +end +--================ +--设置经验值文本 +--@param number current:现在的经验值 +--================ +function XUiRpgTowerTeamBar:SetExpText(current) + if not (self.Level == self.MaxLevel) then + self.TxtExp.text = CS.XTextManager.GetText("CommonSlashStr", current, self.NextExp) + self.CurrentExp = current + self.ImgProgressbar.fillAmount = current * self.FillAmountUnit + else + self.TxtExp.text = CS.XTextManager.GetText("RpgTowerMaxLevel") + self.ImgProgressbar.fillAmount = 1 + end +end +--================ +--增加经验值 +--@param number addExp:增加的经验值 +--================ +function XUiRpgTowerTeamBar:AddExp(addExp, preExp, preLevel) + if self.IsMaxLevel then return end + self:SetLevel(preLevel) + self:SetExpText(preExp) + local levelUpCount, remainExp = self:CalculateExpOverFlow(addExp, preExp, preLevel) + self.PlayLevelUpCount = levelUpCount + self.DoingLevelUp = self.PlayLevelUpCount > 0 + self.TargetExp = remainExp + self:StartFillTimer() +end +--================ +--计算经验值溢出 +--@param number addExp:增加的经验值 +--@return number:溢出级数(跳级级数) +--@return number:最后剩余的经验值 +--@return bool:是否升至满级 +--================ +function XUiRpgTowerTeamBar:CalculateExpOverFlow(addExp, preExp, preLevel) + local levelUpCount = 0 + local tempExp = preExp or 0 + local tempLevel = preLevel or 1 + while(addExp > 0) do + local levelCfg = XRpgTowerConfig.GetTeamLevelCfgByLevel(tempLevel) + local deltaLevelUpExp = addExp + tempExp - levelCfg.Exp + if tempLevel >= self.MaxLevel then + tempExp = 0 + addExp = 0 + elseif deltaLevelUpExp >= 0 then + levelUpCount = levelUpCount + 1 + tempExp = 0 + tempLevel = tempLevel + 1 + addExp = deltaLevelUpExp + else + tempExp = tempExp + addExp + addExp = 0 + end + end + return levelUpCount, tempExp +end + +function XUiRpgTowerTeamBar:StartFillTimer() + if self.TimerId then return end + --每帧处理 + self.TimerId = XScheduleManager.ScheduleForever(function() + if XTool.UObjIsNil(self.Transform) then + self:StopTimer() + return + end + --若还有剩余的播放升级处理次数,则播放升级处理 + if self.PlayLevelUpCount > 0 or ((not self:CheckIsMaxLevel()) and (self.TargetExp > self.CurrentExp)) then + local nextFillAmount = self.ImgProgressbar.fillAmount + (self.FillAmountUnit * FILL_SPEED) + if nextFillAmount >= 1 then + nextFillAmount = 1 + self.ImgProgressbar.fillAmount = 1 + self:SetExpText(self.NextExp) + self:SetLevel(self.Level + 1) + self:SetExpText(0) + self.PlayLevelUpCount = self.PlayLevelUpCount - 1 + else + local nextFillAmount = self.ImgProgressbar.fillAmount + (self.FillAmountUnit * FILL_SPEED) + self.ImgProgressbar.fillAmount = nextFillAmount + local nextExp = math.floor(self.NextExp * self.ImgProgressbar.fillAmount) + if self.PlayLevelUpCount == 0 and (nextExp > self.TargetExp) then + nextExp = self.TargetExp + end + self:SetExpText(nextExp) + end + else + self:StopTimer() + if self.DoingLevelUp then + self.DoingLevelUp = false + self:ShowLevelUpTips() + end + end + end, 0) +end + +function XUiRpgTowerTeamBar:StopTimer() + if not self.TimerId then return end + XScheduleManager.UnSchedule(self.TimerId) + self.TimerId = nil +end + +function XUiRpgTowerTeamBar:ShowLevelUpTips() + XLuaUiManager.Open("UiRpgTowerLevelUp") +end + +function XUiRpgTowerTeamBar:OnDisable() + self:StopTimer() +end + +return XUiRpgTowerTeamBar \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgTower/MainPage/PanelMonsters/XUiRpgTowerMonsterGrid.lua b/Resources/Scripts/XUi/XUiRpgTower/MainPage/PanelMonsters/XUiRpgTowerMonsterGrid.lua new file mode 100644 index 00000000..191e9659 --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgTower/MainPage/PanelMonsters/XUiRpgTowerMonsterGrid.lua @@ -0,0 +1,69 @@ +-- 兵法蓝图主界面怪物面板:怪物展示控件 +local XUiRpgTowerMonsterGrid = XClass(nil, "XUiRpgTowerMonsterGrid") +function XUiRpgTowerMonsterGrid:Ctor(ui, monsterModel) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.MonsterModel = monsterModel + self.ShowEffect = self.MonsterModel.Transform:Find("ImgEffectHuanren1") +end +--================ +--刷新数据 +--================ +function XUiRpgTowerMonsterGrid:RefreshData(rMonsterId, isBoss) + if not rMonsterId then self:HideGrid() return end + self.GameObject:SetActiveEx(true) + self.MonsterId = rMonsterId + self:RefreshModel() + self:RefreshGrid() + self.MonsterModel:ShowRoleModel() +end +--================ +--刷新模型 +--================ +function XUiRpgTowerMonsterGrid:RefreshModel() + local monsterNpcDataId = XRpgTowerConfig.GetMonsterNpcDataIdByRMonsterId(self.MonsterId) + local modelName = XArchiveConfigs.GetMonsterNpcDataById(monsterNpcDataId).ModelId + self.MonsterModel:UpdateBossModel(modelName, nil, nil, function(model) self:LoadModelCallBack(model) end, true) +end +--================ +--读取模型后回调 +--================ +function XUiRpgTowerMonsterGrid:LoadModelCallBack(model) + self:PlaySwitchEffect() + local rMonsterCfg = XRpgTowerConfig.GetRMonsterCfgById(self.MonsterId) + local scale = rMonsterCfg.Scale > 0 and rMonsterCfg.Scale or 1 + model.transform.localScale = CS.UnityEngine.Vector3(scale, scale, scale) + model.transform.localPosition = CS.UnityEngine.Vector3(rMonsterCfg.PositionX, rMonsterCfg.PositionY, rMonsterCfg.PositionZ) + model.transform.localRotation.eulerAngles = CS.UnityEngine.Vector3(rMonsterCfg.RotationX, rMonsterCfg.RotationY, rMonsterCfg.RotationZ) +end +--================ +--刷新UI控件显示 +--================ +function XUiRpgTowerMonsterGrid:RefreshGrid() + local rMonsterCfg = XRpgTowerConfig.GetRMonsterCfgById(self.MonsterId) + self.PanelNameBoss.gameObject:SetActiveEx(rMonsterCfg.IsBoss == 1) + self.PanelNameNormal.gameObject:SetActiveEx(rMonsterCfg.IsBoss ~= 1) + self.TxtNormalName01.text = rMonsterCfg.Name + self.TxtBossName01.text = rMonsterCfg.Name + self.TxtNormalName02.text = rMonsterCfg.SubName + self.TxtBossName02.text = rMonsterCfg.SubName +end +--================ +--隐藏控件 +--================ +function XUiRpgTowerMonsterGrid:HideGrid() + self.GameObject:SetActiveEx(false) + self.MonsterModel:HideRoleModel() +end +--================ +--播放切换特效 +--================ +function XUiRpgTowerMonsterGrid:PlaySwitchEffect() + if self.ShowEffect then + self.ShowEffect.gameObject:SetActiveEx(false) + self.ShowEffect.gameObject:SetActiveEx(true) + end +end + +return XUiRpgTowerMonsterGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgTower/MainPage/PanelMonsters/XUiRpgTowerMonstersPanel.lua b/Resources/Scripts/XUi/XUiRpgTower/MainPage/PanelMonsters/XUiRpgTowerMonstersPanel.lua new file mode 100644 index 00000000..de5a0b87 --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgTower/MainPage/PanelMonsters/XUiRpgTowerMonstersPanel.lua @@ -0,0 +1,49 @@ +-- 兵法蓝图主页面怪物面板控件 +local XUiRpgTowerMonstersPanel = XClass(nil, "XUiRpgTowerMonstersPanel") +local XUiRpgTowerMonsterGrid = require("XUi/XUiRpgTower/MainPage/PanelMonsters/XUiRpgTowerMonsterGrid") +function XUiRpgTowerMonstersPanel:Ctor(ui, uiModelRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.MonsterGrids = {} + XTool.InitUiObject(self) + self:InitMonstersModel(uiModelRoot) + self:InitPanel() +end +--================ +--初始化怪物模型控件 +--================ +function XUiRpgTowerMonstersPanel:InitMonstersModel(uiModelRoot) + self.MonsterModels = { + [1] = XUiPanelRoleModel.New(uiModelRoot:FindTransform("PanelModelCase1"), self.Name, nil, true, nil, true, true), + [2] = XUiPanelRoleModel.New(uiModelRoot:FindTransform("PanelModelCase2"), self.Name, nil, true, nil, true, true), + [3] = XUiPanelRoleModel.New(uiModelRoot:FindTransform("PanelModelCase3"), self.Name, nil, true, nil, true, true), + } +end +--================ +--初始化面板 +--================ +function XUiRpgTowerMonstersPanel:InitPanel() + self.GridMonster.gameObject:SetActiveEx(false) + for i = 1, 3 do + local roomCharCase = self.MonsterModels[i] + if roomCharCase then + local prefab = CS.UnityEngine.Object.Instantiate(self.GridMonster.gameObject) + prefab.transform:SetParent(self["RoomMonsterCase" .. i], false) + prefab.gameObject:SetActiveEx(true) + self.MonsterGrids[i] = XUiRpgTowerMonsterGrid.New(prefab, self.MonsterModels[i]) + self.MonsterGrids[i]:RefreshData(nil) + end + end +end +--================ +--刷新怪物模型 +--================ +function XUiRpgTowerMonstersPanel:RefreshMonsters(rStage) + local monsterIds = rStage:GetMonsters() + for i = 1, 3 do + local isBoss = XRpgTowerConfig.GetMonsterIsBossByRMonsterId(monsterIds[i]) + self.MonsterGrids[i]:RefreshData(monsterIds[i], isBoss) + end +end + +return XUiRpgTowerMonstersPanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgTower/MainPage/PanelRole/XUiRpgTowerRolePanel.lua b/Resources/Scripts/XUi/XUiRpgTower/MainPage/PanelRole/XUiRpgTowerRolePanel.lua new file mode 100644 index 00000000..d3ea6204 --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgTower/MainPage/PanelRole/XUiRpgTowerRolePanel.lua @@ -0,0 +1,38 @@ +--兵法蓝图 +local XUiRpgTowerRolePanel = XClass(nil, "XUiRpgTowerRolePanel") +local XUiRpgTowerCharaItem = require("XUi/XUiRpgTower/Common/XUiRpgTowerCharaItem") +function XUiRpgTowerRolePanel:Ctor(ui, rootUi) + XTool.InitUiObjectByUi(self, ui) + self.RootUi = rootUi + self.GridRole.gameObject:SetActiveEx(false) + self.RoleGrid = {} +end + +function XUiRpgTowerRolePanel:RefreshRole() + local team = XDataCenter.RpgTowerManager.GetTeam() + self:ResetRoleGrid() + local gridIndex = 0 + for _, rChara in pairs(team) do + gridIndex = gridIndex + 1 + if not self.RoleGrid[gridIndex] then + local ui = CS.UnityEngine.GameObject.Instantiate(self.GridRole) + ui.transform:SetParent(self.Transform, false) + self.RoleGrid[gridIndex] = XUiRpgTowerCharaItem.New(ui, + XDataCenter.RpgTowerManager.CharaItemShowType.OnlyIconAndStar, + self.OnClickRole) + end + self.RoleGrid[gridIndex]:RefreshData(rChara) + self.RoleGrid[gridIndex].GameObject:SetActiveEx(true) + end +end + +function XUiRpgTowerRolePanel:ResetRoleGrid() + for _, grid in pairs(self.RoleGrid) do + grid.GameObject:SetActiveEx(false) + end +end + +function XUiRpgTowerRolePanel:OnClickRole() + XLuaUiManager.Open("UiRpgTowerRoleList") +end +return XUiRpgTowerRolePanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgTower/MainPage/PanelStageDetails/XUiRpgTowerStageBuffIcon.lua b/Resources/Scripts/XUi/XUiRpgTower/MainPage/PanelStageDetails/XUiRpgTowerStageBuffIcon.lua new file mode 100644 index 00000000..64cc9803 --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgTower/MainPage/PanelStageDetails/XUiRpgTowerStageBuffIcon.lua @@ -0,0 +1,26 @@ +-- 兵法蓝图关卡词缀图标控件 +local XUiRpgTowerStageBuffIcon = XClass(nil, "XUiRpgTowerStageBuffIcon") + +function XUiRpgTowerStageBuffIcon:Ctor(ui) + XTool.InitUiObjectByUi(self, ui) +end +--================ +--刷新Buff +--================ +function XUiRpgTowerStageBuffIcon:RefreshBuff(buffCfg) + self.RImgIcon:SetRawImage(buffCfg.Icon) +end +--================ +--显示控件 +--================ +function XUiRpgTowerStageBuffIcon:Show() + self.GameObject:SetActiveEx(true) +end +--================ +--隐藏控件 +--================ +function XUiRpgTowerStageBuffIcon:Hide() + self.GameObject:SetActiveEx(false) +end + +return XUiRpgTowerStageBuffIcon \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgTower/MainPage/PanelStageDetails/XUiRpgTowerStageBuffPanel.lua b/Resources/Scripts/XUi/XUiRpgTower/MainPage/PanelStageDetails/XUiRpgTowerStageBuffPanel.lua new file mode 100644 index 00000000..00cd4910 --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgTower/MainPage/PanelStageDetails/XUiRpgTowerStageBuffPanel.lua @@ -0,0 +1,49 @@ +-- 兵法蓝图主页面关卡详细面板:Buff展示面板 +local XUiRpgTowerStageBuffPanel = XClass(nil, "XUiRpgTowerStageBuffPanel") +local XUiRpgTowerStageBuffIcon = require("XUi/XUiRpgTower/MainPage/PanelStageDetails/XUiRpgTowerStageBuffIcon") +function XUiRpgTowerStageBuffPanel:Ctor(ui, rootUi) + XTool.InitUiObjectByUi(self, ui) + self.RootUi = rootUi + self.RImgBuffIcon.gameObject:SetActiveEx(false) + self.BuffIcons = {} +end +--================ +--刷新Buff数据 +--================ +function XUiRpgTowerStageBuffPanel:RefreshBuff(rStage) + self.BuffList = rStage:GetStageEvents() + self:ResetBuffIcons() + self:ShowBuffIcons() +end +--================ +--重置Buff图标 +--================ +function XUiRpgTowerStageBuffPanel:ResetBuffIcons() + for _, icon in pairs(self.BuffIcons) do + icon:Hide() + end +end +--================ +--显示Buff图标 +--================ +function XUiRpgTowerStageBuffPanel:ShowBuffIcons() + for i = 1, #self.BuffList do + local icon + if not self.BuffIcons[i] then + local ui = CS.UnityEngine.GameObject.Instantiate(self.RImgBuffIcon) + ui.transform:SetParent(self.Transform, false) + self.BuffIcons[i] = XUiRpgTowerStageBuffIcon.New(ui, self) + self.RootUi:RegisterClickEvent(ui, function() self:OnClickIcon() end) + end + icon = self.BuffIcons[i] + self.BuffIcons[i]:RefreshBuff(self.BuffList[i]) + icon:Show() + end +end +--================ +--点击图标 +--================ +function XUiRpgTowerStageBuffPanel:OnClickIcon() + XLuaUiManager.Open("UiCommonStageEvent", self.BuffList) +end +return XUiRpgTowerStageBuffPanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgTower/MainPage/PanelStageDetails/XUiRpgTowerStageDetails.lua b/Resources/Scripts/XUi/XUiRpgTower/MainPage/PanelStageDetails/XUiRpgTowerStageDetails.lua new file mode 100644 index 00000000..f1001e3b --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgTower/MainPage/PanelStageDetails/XUiRpgTowerStageDetails.lua @@ -0,0 +1,67 @@ +--兵法蓝图主界面:关卡详细面板 +local XUiRpgTowerStageDetails = XClass(nil, "XUiRpgTowerStageDetails") +local XUiRpgTowerStageBuffPanel = require("XUi/XUiRpgTower/MainPage/PanelStageDetails/XUiRpgTowerStageBuffPanel") +local XUiRpgTowerStageRewardsPanel = require("XUi/XUiRpgTower/MainPage/PanelStageDetails/XUiRpgTowerStageRewardsPanel") +function XUiRpgTowerStageDetails:Ctor(ui, rootUi) + XTool.InitUiObjectByUi(self, ui) + self.RootUi = rootUi + self.RewardsPanel = XUiRpgTowerStageRewardsPanel.New(self.PanelReward, self.RootUi) + self.BuffPanel = XUiRpgTowerStageBuffPanel.New(self.PanelBuff, self.RootUi) + self.BtnEnter.CallBack = function() self:OnClickBtnEnter() end + XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint) + XUiHelper.RegisterClickEvent(self, self.BtnClose, function() self:HidePanel() end) +end +--================ +--刷新关卡数据 +--================ +function XUiRpgTowerStageDetails:RefreshStage(rStage) + self.TxtTitle.text = rStage:GetStageName() + self.TxtBuff.text = rStage:GetStageBuffDesc() + local tipsText = CS.XTextManager.GetText("RpgTowerStageDetialRecommendLevelTips", rStage:GetRecommendLevel()) + if XDataCenter.RpgTowerManager.GetCurrentLevel() < (self.RootUi.RStage:GetRecommendLevel() or 0) then + self.TxtTips.text = CS.XTextManager.GetText("CommonRedText", tipsText) + else + self.TxtTips.text = tipsText + end + self.RewardsPanel:RefreshRewards(rStage) + self.BuffPanel:RefreshBuff(rStage) + +end +--================ +--进入关卡按钮 +--================ +function XUiRpgTowerStageDetails:OnClickBtnEnter() + local stageCfg = self.RootUi.RStage:GetStageCfg() + if XDataCenter.RpgTowerManager.GetCurrentLevel() < (self.RootUi.RStage:GetRecommendLevel() or 0) then + local tipTitle = CS.XTextManager.GetText("RpgTowerTeamLevelNotEnoughTitle") + local tipContent = CS.XTextManager.GetText("RpgTowerTeamLevelNotEnoughContent") + CsXUiManager.Instance:Open("UiDialog", tipTitle, tipContent, XUiManager.DialogType.Normal, nil, function() + if not XDataCenter.FubenManager.CheckPreFight(stageCfg) then + return + end + self:HidePanel() + XLuaUiManager.Open("UiNewRoomSingle", self.RootUi.RStage:GetStageId()) + end) + else + if not XDataCenter.FubenManager.CheckPreFight(stageCfg) then + return + end + self:HidePanel() + XLuaUiManager.Open("UiNewRoomSingle", self.RootUi.RStage:GetStageId()) + end +end +--================ +--隐藏面板 +--================ +function XUiRpgTowerStageDetails:HidePanel() + self.GameObject:SetActiveEx(false) +end +--================ +--打开面板 +--================ +function XUiRpgTowerStageDetails:ShowPanel() + self.RootUi:PlayAnimation("PanelPopupEnable") + self.GameObject:SetActiveEx(true) +end + +return XUiRpgTowerStageDetails \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgTower/MainPage/PanelStageDetails/XUiRpgTowerStageRewardsPanel.lua b/Resources/Scripts/XUi/XUiRpgTower/MainPage/PanelStageDetails/XUiRpgTowerStageRewardsPanel.lua new file mode 100644 index 00000000..a9314696 --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgTower/MainPage/PanelStageDetails/XUiRpgTowerStageRewardsPanel.lua @@ -0,0 +1,44 @@ +--兵法蓝图主界面:关卡详细面板 +local XUiRpgTowerStageRewardsPanel = XClass(nil, "XUiRpgTowerStageRewardsPanel") +function XUiRpgTowerStageRewardsPanel:Ctor(ui, rootUi) + XTool.InitUiObjectByUi(self, ui) + self.RootUi = rootUi + self.GridCommon.gameObject:SetActiveEx(false) + self.RewardsGrid = {} +end +--================ +--刷新奖励数据 +--================ +function XUiRpgTowerStageRewardsPanel:RefreshRewards(rStage) + local rewardId = rStage:GetStageRewardId() + local isPass = rStage:GetIsPass() + if self.ImgEmpty then self.ImgEmpty.gameObject:SetActiveEx(isPass) end + self:ResetRewards() + if not isPass then self:ShowRewards(rewardId) end +end +--================ +--重置奖励显示 +--================ +function XUiRpgTowerStageRewardsPanel:ResetRewards() + for i = 1, #self.RewardsGrid do + self.RewardsGrid[i].GameObject:SetActiveEx(false) + end +end +--================ +--显示奖励 +--================ +function XUiRpgTowerStageRewardsPanel:ShowRewards(rewardId) + local rewards = XRewardManager.GetRewardList(rewardId) or XRewardManager.GetRewardListNotCount(rewardId) + if rewards then + for i, item in ipairs(rewards) do + if not self.RewardsGrid[i] then + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommon) + self.RewardsGrid[i] = XUiGridCommon.New(self.RootUi, ui) + self.RewardsGrid[i].Transform:SetParent(self.PanelDropContent, false) + end + self.RewardsGrid[i]:Refresh(item) + self.RewardsGrid[i].GameObject:SetActiveEx(true) + end + end +end +return XUiRpgTowerStageRewardsPanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgTower/MainPage/PanelStageList/XUiRpgTowerStageGrid.lua b/Resources/Scripts/XUi/XUiRpgTower/MainPage/PanelStageList/XUiRpgTowerStageGrid.lua new file mode 100644 index 00000000..f2644bd4 --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgTower/MainPage/PanelStageList/XUiRpgTowerStageGrid.lua @@ -0,0 +1,76 @@ +-- 兵法蓝图主页面关卡列表:关卡显示控件 +local XUiRpgTowerStageGrid = XClass(nil, "XUiRpgTowerStageGrid") +function XUiRpgTowerStageGrid:Ctor() + +end +--================ +--关卡项初始化 +--================ +function XUiRpgTowerStageGrid:Init(ui, stageList) + XTool.InitUiObjectByUi(self, ui) + self.StageList = stageList + self.GridStage.CallBack = function() self:OnClick() end + --self.RImgBtnPress:SetSprite(CS.XGame.ClientConfig:GetString("RpgTowerStageBgNormal")) + --self.RImgBtnNormal:SetSprite(CS.XGame.ClientConfig:GetString("RpgTowerStageBgNormal")) + --self.RImgBtnSelect:SetSprite(CS.XGame.ClientConfig:GetString("RpgTowerStageBgSelect")) +end +--================ +--刷新关卡数据 +--================ +function XUiRpgTowerStageGrid:RefreshData(rStageCfg, gridIndex) + local rStage = XDataCenter.RpgTowerManager.GetRStageByStageId(rStageCfg.StageId) + self.RStage = rStage + self.GridIndex = gridIndex + self.DifficultyData = XDataCenter.RpgTowerManager.StageDifficultyData[self.RStage:GetDifficulty()] + self:SetName() + self:SetBg() + self.GridStage:SetDisable(not self.RStage:GetIsUnlock()) + self.GridStage:ShowTag(self.RStage:GetIsPass()) +end +--================ +--关卡点击事件 +--================ +function XUiRpgTowerStageGrid:OnClick() + if self.RStage:GetIsUnlock() then + self:SetSelect(true) + else + XUiManager.TipMsg(CS.XTextManager.GetText("RpgTowerStageNotOpen")) + end + -- 本身UiButton的Bug,选中状态下再选中一次会给TempState赋值Select,这里把临时状态改为Normal避免让OnPointerExit事件中恢复TempState的状态变为Select + self.GridStage.TempState = CS.UiButtonState.Normal +end +--================ +--设置关卡名称 +--================ +function XUiRpgTowerStageGrid:SetName() + self.GridStage:SetNameByGroup(0, self.RStage:GetOrderName()) +end +--================ +--设置图标 +--================ +function XUiRpgTowerStageGrid:SetBg() + self.RImgBtnPress:SetSprite(self.DifficultyData.IconPath) + self.RImgBtnNormal:SetSprite(self.DifficultyData.IconPath) + self.RImgBtnSelect:SetSprite(self.DifficultyData.IconPath) +end +--================ +--选中事件 +--================ +function XUiRpgTowerStageGrid:SetSelect(isSelect) + local uiBtnState + if isSelect then + uiBtnState = CS.UiButtonState.Select + else + if self.RStage:GetIsUnlock() then + uiBtnState = CS.UiButtonState.Normal + -- 本身UiButton的Bug,选中状态下再选中一次会给TempState赋值Select,这里把临时状态改为Normal避免让OnPointerExit事件中恢复TempState的状态变为Select + self.GridStage.TempState = CS.UiButtonState.Normal + else + uiBtnState = CS.UiButtonState.Disable + self.GridStage.TempState = CS.UiButtonState.Disable + end + end + self.GridStage:SetButtonState(uiBtnState) + if isSelect then self.StageList:SetSelect(self) end +end +return XUiRpgTowerStageGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgTower/MainPage/PanelStageList/XUiRpgTowerStageList.lua b/Resources/Scripts/XUi/XUiRpgTower/MainPage/PanelStageList/XUiRpgTowerStageList.lua new file mode 100644 index 00000000..bcabdf31 --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgTower/MainPage/PanelStageList/XUiRpgTowerStageList.lua @@ -0,0 +1,71 @@ +-- 兵法蓝图主页面关卡动态列表控件 +local XUiRpgTowerStageList = XClass(nil, "XUiRpgTowerStageList") +local XUiRpgTowerStageGrid = require("XUi/XUiRpgTower/MainPage/PanelStageList/XUiRpgTowerStageGrid") +--================ +--构造函数 +--================ +function XUiRpgTowerStageList:Ctor(ui, rootUi) + XTool.InitUiObjectByUi(self, ui) + self.RootUi = rootUi + self.GridStage.gameObject:SetActiveEx(false) + self.DynamicTable = XDynamicTableNormal.New(self.GameObject) + self.DynamicTable:SetProxy(XUiRpgTowerStageGrid) + self.DynamicTable:SetDelegate(self) + self.AvailableViewCount = self.GameObject:GetComponent("XDynamicTableNormal").AvailableViewCount +end +--================ +--动态列表事件 +--================ +function XUiRpgTowerStageList:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(grid.DynamicGrid.gameObject, self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + if self.StageList and self.StageList[index] then + grid:RefreshData(self.StageList[index], index) + if self.SetCurrent and self.Chapter:GetCurrentIndex() == index then + grid:SetSelect(true) + elseif self.CurrentIndex == index then + grid:SetSelect(true) + end + end + end +end +--================ +--刷新列表 +--================ +function XUiRpgTowerStageList:UpdateData() + self.Chapter = XDataCenter.RpgTowerManager.GetCurrentChapter() + self.StageList = self.Chapter:GetDynamicRStageList(self.AvailableViewCount, 2) + self.DynamicTable:SetDataSource(self.StageList) + local newStageIndex = self:GetNewStageIndex() + self.SetCurrent = true + self.CurrentIndex = self.Chapter:GetCurrentIndex() + self.DynamicTable:ReloadDataASync(newStageIndex) +end +--================ +--根据最新的关卡序号,获取列表要显示的位置 +--================ +function XUiRpgTowerStageList:GetNewStageIndex() + local newStageIndex = self.Chapter:GetCurrentIndex() + if newStageIndex + 2 > #self.StageList then + newStageIndex = #self.StageList - (self.AvailableViewCount - 1) + elseif newStageIndex - 2 < 1 then + newStageIndex = 1 + else + newStageIndex = newStageIndex - 2 + end + return newStageIndex +end +--================ +--列表项选中事件 +--================ +function XUiRpgTowerStageList:SetSelect(grid) + if self.SetCurrent then self.SetCurrent = false end + if self.CurGrid and self.CurGrid ~= grid then + self.CurGrid:SetSelect(false) + end + self.CurGrid = grid + self.CurrentIndex = grid.GridIndex + self.RootUi:OnClickStageGrid(grid.RStage) +end +return XUiRpgTowerStageList \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgTower/MainPage/XUiRpgTowerMain.lua b/Resources/Scripts/XUi/XUiRpgTower/MainPage/XUiRpgTowerMain.lua new file mode 100644 index 00000000..9611578c --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgTower/MainPage/XUiRpgTowerMain.lua @@ -0,0 +1,247 @@ +--兵法蓝图主页面 +local XUiRpgTowerMain = XLuaUiManager.Register(XLuaUi, "UiRpgTowerMain") +local XUiRpgTowerMonstersPanel = require("XUi/XUiRpgTower/MainPage/PanelMonsters/XUiRpgTowerMonstersPanel") +local XUiRpgTwerStageDetails = require("XUi/XUiRpgTower/MainPage/PanelStageDetails/XUiRpgTowerStageDetails") +local XUiRpgTowerStageList = require("XUi/XUiRpgTower/MainPage/PanelStageList/XUiRpgTowerStageList") +-- ========= ========= +-- =========生命周期方法========= +-- ========= ========= +function XUiRpgTowerMain:OnAwake() + XTool.InitUiObject(self) + XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + XDataCenter.RpgTowerManager.SetNewBegining() + self:InitButtons() + self:InitMonsterPanel() + self:InitStageDetailPanel() + self:InitStageList() + self:InitTeamLevel() + self.RedEvents = {} +end + +function XUiRpgTowerMain:OnEnable() + if self.MainEnable and not XDataCenter.RpgTowerManager.GetIsReset() then + self.MainEnable.gameObject:SetActiveEx(false) + self.MainEnable.gameObject:SetActiveEx(true) + else + self:OnActivityReset() + return + end + self:OnShowPanel() + self:AddRedPointEvents() + if XDataCenter.RpgTowerManager.GetIsFirstIn() then + XUiManager.ShowHelpTip("RpgTowerHelp") + end +end + +function XUiRpgTowerMain:OnDisable() + self:StopTimer() + self:RemoveRedPointEvents() +end + +function XUiRpgTowerMain:OnGetEvents() + return { XEventId.EVENT_RPGTOWER_RESET, XEventId.EVENT_RPGTOWER_REFRESH_DAILYREWARD } +end + +function XUiRpgTowerMain:OnNotify(evt, ...) + local args = { ... } + if evt == XEventId.EVENT_RPGTOWER_RESET then + self:OnActivityReset() + elseif evt == XEventId.EVENT_RPGTOWER_REFRESH_DAILYREWARD then + self:RefreshSupply() + self:RefreshTeamLevel() + end +end + +--================ +--初始化按钮 +--================ +function XUiRpgTowerMain:InitButtons() + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + self:BindHelpBtn(self.BtnHelp, "RpgTowerHelp") + self.BtnEnterStage.CallBack = function() self:OnEnterStageClick() end + self.BtnActivityTask.CallBack = function() self:OnTaskClick() end + self.BtnTeam.CallBack = function() self:OnTeamClick() end + XUiHelper.RegisterClickEvent(self, self.ImgSupply, function() self:OnSupplyClick() end) +end +--================ +--返回按钮 +--================ +function XUiRpgTowerMain:OnBtnBackClick() + self:Close() +end +--================ +--主界面按钮 +--================ +function XUiRpgTowerMain:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end +--================ +--进入关卡按钮 +--================ +function XUiRpgTowerMain:OnEnterStageClick() + self.StageDetail:ShowPanel() +end +--================ +--活动任务按钮 +--================ +function XUiRpgTowerMain:OnTaskClick() + XLuaUiManager.Open("UiRpgTowerTask") +end +--================ +--队伍养成按钮 +--================ +function XUiRpgTowerMain:OnTeamClick() + XLuaUiManager.Open("UiRpgTowerRoleList") +end +--================ +--获取今日补给 +--================ +function XUiRpgTowerMain:OnSupplyClick() + if XDataCenter.RpgTowerManager.GetCanReceiveSupply() then + XDataCenter.RpgTowerManager.ReceiveSupply() + else + XUiManager.TipMsg(CS.XTextManager.GetText("RpgTowerCantGetSupply")) + end +end +--================ +--初始化怪兽模型面板 +--================ +function XUiRpgTowerMain:InitMonsterPanel() + local uiModelRoot = self.UiModelGo.transform + self.MonstersPanel = XUiRpgTowerMonstersPanel.New(self.PanelMonster, uiModelRoot) +end +--================ +--初始化关卡列表 +--================ +function XUiRpgTowerMain:InitStageList() + self.StageList = XUiRpgTowerStageList.New(self.PanelStageList, self) +end +--================ +--初始化关卡详细 +--================ +function XUiRpgTowerMain:InitStageDetailPanel() + self.StageDetail = XUiRpgTwerStageDetails.New(self.PanelStageDetail, self) + self.StageDetail:HidePanel() +end + +function XUiRpgTowerMain:InitTeamLevel() + local teamLevelScript = require("XUi/XUiRpgTower/Common/XUiRpgTowerTeamBar") + self.TeamLevel = teamLevelScript.New(self.PanelTeamBar, self) + self.TeamLevel:RefreshBar() +end +--================ +--点击关卡控件时 +--================ +function XUiRpgTowerMain:OnClickStageGrid(rStage) + if self.RStage == rStage then return end + self.RStage = rStage + self.StageDetail:RefreshStage(rStage) + self.MonstersPanel:RefreshMonsters(rStage) +end + +--================ +--显示界面时 +--================ +function XUiRpgTowerMain:OnShowPanel() + self.StageList:UpdateData() + self:RefreshSupply() + self:RefreshTeamLevel() + self:SetTimer() +end +--================ +--设置界面计时器 +--================ +function XUiRpgTowerMain:SetTimer() + self:StopTimer() + self:SetResetTime() + self.Timer = XScheduleManager.ScheduleForever(function() + self:SetResetTime() + end, XScheduleManager.SECOND, 0) +end +--================ +--显示倒计时与处理倒计时完成时事件 +--================ +function XUiRpgTowerMain:SetResetTime() + local endTimeSecond = XDataCenter.RpgTowerManager.GetEndTime() + local now = XTime.GetServerNowTimestamp() + local leftTime = endTimeSecond - now + local remainTime = XUiHelper.GetTime(leftTime, XUiHelper.TimeFormatType.ACTIVITY) + self.TxtRemainTime.text = CS.XTextManager.GetText("RpgTowerRemainTime", remainTime) + if leftTime <= 0 then + self:OnActivityReset() + end +end +--================ +--停止界面计时器 +--================ +function XUiRpgTowerMain:StopTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end + +--================ +--活动周期结束时弹回主界面 +--================ +function XUiRpgTowerMain:OnActivityReset() + if self.IsReseting then return end + self.IsReseting = true + self:StopTimer() + XLuaUiManager.RunMain() + XUiManager.TipMsg(CS.XTextManager.GetText("RpgTowerFinished")) +end +--================ +--刷新每日补给 +--================ +function XUiRpgTowerMain:RefreshSupply() + local haveSupply = XDataCenter.RpgTowerManager.GetCanReceiveSupply() + self.TxtSupplyNotReceive.gameObject:SetActiveEx(haveSupply) + self.TxtSupplyReceive.gameObject:SetActiveEx(not haveSupply) + self.ObjSupplyRed.gameObject:SetActiveEx(haveSupply) +end +--================ +--刷新队伍经验条 +--================ +function XUiRpgTowerMain:RefreshTeamLevel() + if XDataCenter.RpgTowerManager.CheckExpChange() then + local changes = XDataCenter.RpgTowerManager.GetExpChanges() + self.TeamLevel:AddExp(changes.ChangeExp, changes.PreTeamExp, changes.PreTeamLevel) + else + self.TeamLevel:RefreshBar() + end +end +--================ +--注册页面红点事件 +--================ +function XUiRpgTowerMain:AddRedPointEvents() + if self.AlreadyAddRed then return end + self.AlreadyAddRed = true + table.insert(self.RedEvents, XRedPointManager.AddRedPointEvent(self.BtnActivityTask, self.OnCheckBtnTaskRedPoint, self, { XRedPointConditions.Types.CONDITION_RPGTOWER_TASK_RED })) + table.insert(self.RedEvents, XRedPointManager.AddRedPointEvent(self.BtnTeam, self.OnCheckBtnTeamRedPoint, self, { XRedPointConditions.Types.CONDITION_RPGTOWER_TEAM_RED })) +end +--================ +--注销页面红点事件 +--================ +function XUiRpgTowerMain:RemoveRedPointEvents() + if not self.AlreadyAddRed then return end + for _, eventId in pairs(self.RedEvents) do + XRedPointManager.RemoveRedPointEvent(eventId) + end + self.RedEvents = {} + self.AlreadyAddRed = false +end +--================ +--检查任务按钮红点 +--================ +function XUiRpgTowerMain:OnCheckBtnTaskRedPoint(count) + self.BtnActivityTask:ShowReddot(count >= 0) +end +--================ +--检查养成界面按钮红点 +--================ +function XUiRpgTowerMain:OnCheckBtnTeamRedPoint(count) + self.BtnTeam:ShowReddot(count >= 0) +end +return XUiRpgTowerMain \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgTower/Task/XUiRpgTowerTask.lua b/Resources/Scripts/XUi/XUiRpgTower/Task/XUiRpgTowerTask.lua new file mode 100644 index 00000000..685dccf1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgTower/Task/XUiRpgTowerTask.lua @@ -0,0 +1,135 @@ +-- 兵法蓝图活动任务页面 +local XUiRpgTowerTask = XLuaUiManager.Register(XLuaUi, "UiRpgTowerTask") +local TaskList = require("XUi/XUiRpgTower/Task/XUiRpgTowerTaskList") +function XUiRpgTowerTask:OnAwake() + XTool.InitUiObject(self) + XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self.GridTask.gameObject:SetActiveEx(false) + self:InitButtons() + self:InitTaskList() +end + +function XUiRpgTowerTask:OnEnable() + self:AddEventListeners() + self:OnShowPanel() +end + +function XUiRpgTowerTask:OnDisable() + self:StopTimer() + self:RemoveEventListeners() +end + +function XUiRpgTowerTask:OnDestroy() + self:StopTimer() + self:RemoveEventListeners() +end + +function XUiRpgTowerTask:OnGetEvents() + return { XEventId.EVENT_RPGTOWER_RESET, XEventId.EVENT_RPGTOWER_CHALLENGE_COUNT_CHANGE } +end + +function XUiRpgTowerTask:OnNotify(evt, ...) + local args = { ... } + if evt == XEventId.EVENT_RPGTOWER_RESET then + self:OnActivityReset() + end +end + +--================ +--初始化按钮 +--================ +function XUiRpgTowerTask:InitButtons() + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end +end +--================ +--返回按钮 +--================ +function XUiRpgTowerTask:OnBtnBackClick() + self:Close() +end +--================ +--主界面按钮 +--================ +function XUiRpgTowerTask:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +--================ +--初始化界面面板 +--================ +function XUiRpgTowerTask:InitTaskList() + self.TaskList = TaskList.New(self.SViewTask, self) +end +--================ +--显示界面时 +--================ +function XUiRpgTowerTask:OnShowPanel() + self.TaskList:UpdateData() + --self:SetTimer() +end +--================ +--设置界面计时器 +--================ +function XUiRpgTowerTask:SetTimer() + self:StopTimer() + self:SetResetTime() + self.Timer = XScheduleManager.ScheduleForever(function() + self:SetResetTime() + end, XScheduleManager.SECOND, 0) +end +--================ +--显示倒计时与处理倒计时完成时事件 +--================ +function XUiRpgTowerTask:SetResetTime() + local endTimeSecond = XDataCenter.RpgTowerManager.GetEndTime() + local now = XTime.GetServerNowTimestamp() + local leftTime = endTimeSecond - now + local remainTime = XUiHelper.GetTime(leftTime, XUiHelper.TimeFormatType.ACTIVITY) + self.TxtTime.text = CS.XTextManager.GetText("RpgTowerRemainTime", remainTime) + if leftTime <= 0 then + self:OnActivityReset() + end +end +--================ +--停止界面计时器 +--================ +function XUiRpgTowerTask:StopTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end + +--================ +--活动周期结束时弹回主界面 +--================ +function XUiRpgTowerTask:OnActivityReset() + self:StopTimer() + XLuaUiManager.RunMain() + XUiManager.TipMsg(CS.XTextManager.GetText("RpgTowerFinished")) +end + +--================ +--刷新任务列表 +--================ +function XUiRpgTowerTask:RefreshTasks() + self.TaskList:UpdateData() +end + +--================ +--增加事件监听 +--================ +function XUiRpgTowerTask:AddEventListeners() + if self.AlreadyAddEvents then return end + self.AlreadyAddEvents = true + XEventManager.AddEventListener(XEventId.EVENT_TASK_SYNC, self.RefreshTasks, self) +end +--================ +--移除事件监听 +--================ +function XUiRpgTowerTask:RemoveEventListeners() + if not self.AlreadyAddEvents then return end + self.AlreadyAddEvents = false + XEventManager.RemoveEventListener(XEventId.EVENT_TASK_SYNC, self.RefreshTasks, self) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiRpgTower/Task/XUiRpgTowerTaskList.lua b/Resources/Scripts/XUi/XUiRpgTower/Task/XUiRpgTowerTaskList.lua new file mode 100644 index 00000000..4d9f42ef --- /dev/null +++ b/Resources/Scripts/XUi/XUiRpgTower/Task/XUiRpgTowerTaskList.lua @@ -0,0 +1,47 @@ +-- 兵法蓝图任务页面任务列表控件 +local XUiRpgTowerTaskList = XClass(nil, "XUiRpgTowerTaskList") + +function XUiRpgTowerTaskList:Ctor(ui, rootUi) + XTool.InitUiObjectByUi(self, ui) + self.RootUi = rootUi + self.DynamicTable = XDynamicTableNormal.New(self.GameObject) + self.DynamicTable:SetProxy(XDynamicGridTask) + self.DynamicTable:SetDelegate(self) +end +--动态列表事件 +function XUiRpgTowerTaskList:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.TaskList[index] + if not data then + return + end + grid.RootUi = self.RootUi + grid:ResetData(data) + end +end +function XUiRpgTowerTaskList:UpdateData() + self.TaskList = self:GetTaskList() + self.DynamicTable:SetDataSource(self.TaskList) + self.DynamicTable:ReloadDataASync() + self.RootUi.ImgEmpty.gameObject:SetActiveEx(#self.TaskList <= 0) +end + +function XUiRpgTowerTaskList:GetTaskList() + local taskList = XDataCenter.TaskManager.GetRpgTowerFullTaskList() + for _, v in pairs(taskList or {}) do + v.SortWeight = 2 + if v.State == XDataCenter.TaskManager.TaskState.Achieved then + v.SortWeight = 1 + elseif v.State == XDataCenter.TaskManager.TaskState.Finish or v.State == XDataCenter.TaskManager.TaskState.Invalid then + v.SortWeight = 3 + end + end + table.sort(taskList, function(taskA, taskB) + if taskA.SortWeight == taskB.SortWeight then + return taskA.Id < taskB.Id + end + return taskA.SortWeight < taskB.SortWeight + end) + return taskList +end +return XUiRpgTowerTaskList \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSet/ChildItem/XUiBtnKeyItem.lua b/Resources/Scripts/XUi/XUiSet/ChildItem/XUiBtnKeyItem.lua new file mode 100644 index 00000000..f176c853 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSet/ChildItem/XUiBtnKeyItem.lua @@ -0,0 +1,75 @@ +local XUiBtnKeyItem = XClass(nil, "XUiBtnKeyItem") + +local NpcOperationKey = CS.XNpcOperationClickKey +local XInputManager = CS.XInputManager + +function XUiBtnKeyItem:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + XTool.InitUiObject(self) + self._KeySetType = false +end + +function XUiBtnKeyItem:SetKeySetType(keySetType) + self._KeySetType = keySetType +end + +function XUiBtnKeyItem:IsPcKeyboard() + return self._KeySetType == CS.KeySetType.Keyboard and XDataCenter.UiPcManager.IsPc() +end + +function XUiBtnKeyItem:Refresh(data, cb, resetTextOnly) + if data and not self.Data then + self.Data = data + self.Cb = cb + end + local isPcKeyboard = self:IsPcKeyboard() + + self.TxtTitle.text = self.Data.Title + if self.Data.NpcOperationKey and self._KeySetType then + local keyCode = NpcOperationKey.__CastFrom(self.Data.NpcOperationKey) + + if isPcKeyboard then + self.GroupRecommend.gameObject:SetActiveEx(false) + else + self.GroupRecommend.gameObject:SetActiveEx(true) + end + self.BtnKeyItem.enabled = true + self.BtnKeyItem.CallBack = function() + self.Cb(keyCode, self) + end + + local name = XInputManager.GetKeyCodeString(self._KeySetType, keyCode) + self.BtnKeyItem:SetName(name) + if (resetTextOnly == true) then + return + end + + local recommendKey = XInputManager.GetRecommendKeyIcoPath(self._KeySetType ,keyCode) + + if recommendKey.Count == 0 then + self.ImgGamePad1.gameObject:SetActiveEx(false) + self.TxtPlus.gameObject:SetActiveEx(false) + self.ImgGamePad2.gameObject:SetActiveEx(false) + elseif recommendKey.Count == 1 then + self.UiRoot:SetUiSprite(self.ImgGamePad1, recommendKey[0]) + self.ImgGamePad1.gameObject:SetActiveEx(true) + self.TxtPlus.gameObject:SetActiveEx(false) + self.ImgGamePad2.gameObject:SetActiveEx(false) + elseif recommendKey.Count == 2 then + self.ImgGamePad1.gameObject:SetActiveEx(true) + self.TxtPlus.gameObject:SetActiveEx(true) + self.ImgGamePad2.gameObject:SetActiveEx(true) + self.UiRoot:SetUiSprite(self.ImgGamePad1, recommendKey[0]) + self.UiRoot:SetUiSprite(self.ImgGamePad2, recommendKey[1]) + end + else + + self.GroupRecommend.gameObject:SetActiveEx(false) + self.BtnKeyItem.enabled = false + self.TxtKeyName.text = self.Data.KeyName + end +end + +return XUiBtnKeyItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSet/XUiCombatTask.lua b/Resources/Scripts/XUi/XUiSet/XUiCombatTask.lua new file mode 100644 index 00000000..675c001a --- /dev/null +++ b/Resources/Scripts/XUi/XUiSet/XUiCombatTask.lua @@ -0,0 +1,71 @@ +local XUiCombatTask = XClass(nil, "XUiCombatTask") + +function XUiCombatTask:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + self.TxtBuff.gameObject:SetActiveEx(false) + self:Init() +end + +function XUiCombatTask:Init() + local nowTaskContent = CS.XFight.CurrentCombatTaskInfo + if nowTaskContent then + self.TxtTaskNow.text = nowTaskContent + self.TxtTaskNow.gameObject:SetActiveEx(true) + else + self.TxtTaskNow.text = "" + self.TxtTaskNow.gameObject:SetActiveEx(false) + end + + local nextTaskContent = CS.XFight.NextCombatTaskInfo + if nextTaskContent then + self.TxtTaskNext.text = nextTaskContent + self.TxtTaskNext.gameObject:SetActiveEx(true) + else + self.TxtTaskNext.text = "" + self.TxtTaskNext.gameObject:SetActiveEx(false) + end + + self:GenerateBuff() +end + +function XUiCombatTask:GenerateBuff() + local data = CS.XFight.CombatTaskResultInfos + local buffTable = XTool.CsObjectFields2LuaTable(data) + if buffTable and next(buffTable) then + for i, v in ipairs(buffTable) do + local go = CS.UnityEngine.Object.Instantiate(self.TxtBuff, self.BuffContent) + local buffText = go:GetComponent("Text") + + buffText.text = string.format("%s%s%s", i, ".", v) + go.gameObject:SetActiveEx(true) + end + end +end + +function XUiCombatTask:ShowPanel() + self.IsShow = true + self.GameObject:SetActiveEx(true) +end + +function XUiCombatTask:HidePanel() + self.IsShow = false + self.GameObject:SetActiveEx(false) +end + +function XUiCombatTask:CheckDataIsChange() + return false +end + +function XUiCombatTask:SaveChange() +end + +function XUiCombatTask:CancelChange() +end + +function XUiCombatTask:ResetToDefault() +end + +return XUiCombatTask \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSet/XUiInstruction.lua b/Resources/Scripts/XUi/XUiSet/XUiInstruction.lua new file mode 100644 index 00000000..40f9188c --- /dev/null +++ b/Resources/Scripts/XUi/XUiSet/XUiInstruction.lua @@ -0,0 +1,67 @@ +XUiInstruction = XClass(nil, "XUiInstruction") + +function XUiInstruction:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + self.Npc = {self.Npc1, self.Npc2, self.Npc3} + self.TogPortrait = {self.TogPortrait1, self.TogPortrait2, self.TogPortrait3} + self.PanelNpc:Init(self.Npc, function(index) self:OnPanelNpc(index) end) + self.Core = {} + self.CoreDescription = {} + self:Init() +end + +function XUiInstruction:Init() + local role = CS.XFight.GetActivateClientRole() + local firstIndex = role.Captain and (role.Captain.Index + 1) or 1 + for i = 1, 3 do + local hasNpc, npc = role:GetNpc(i - 1) + if not hasNpc then + self.Npc[i].gameObject:SetActiveEx(false) + else + local characterId = math.floor(npc.TemplateId / 10) + self.Core[i] = XCharacterConfigs.GetCharTeachIconById(characterId) + self.CoreDescription[i] = XCharacterConfigs.GetCharTeachDescriptionById(characterId) + local iconPath = npc.Template.HeadImageName + if npc.FightNpcData ~= nil then + iconPath = XDataCenter.CharacterManager.GetFightCharHeadIcon(npc.FightNpcData.Character) + end + self.TogPortrait[i]:SetSprite(iconPath) + end + end + self.PanelNpc:SelectIndex(firstIndex) +end + +function XUiInstruction:OnPanelNpc(index) + self.ImgCoreSkill:SetRawImage(self.Core[index]) + self.TxtCoreDescription.text = self.CoreDescription[index] +end + +function XUiInstruction:ShowPanel() + self.IsShow = true + self.GameObject:SetActive(true) +end + +function XUiInstruction:HidePanel() + self.IsShow = false + self.GameObject:SetActive(false) +end + +function XUiInstruction:CheckDataIsChange() + + return false +end + +function XUiInstruction:SaveChange() + +end + +function XUiInstruction:CancelChange() + +end + +function XUiInstruction:ResetToDefault() + +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSet/XUiInstructionMonster.lua b/Resources/Scripts/XUi/XUiSet/XUiInstructionMonster.lua new file mode 100644 index 00000000..a485272c --- /dev/null +++ b/Resources/Scripts/XUi/XUiSet/XUiInstructionMonster.lua @@ -0,0 +1,163 @@ +local XUiGridPokemonMonster = require("XUi/XUiPokemon/XUiMonster/XUiGridPokemonMonster") + +local tableInsert = table.insert +local tableSort = table.sort +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate + +local XUiInstructionMonster = XClass(nil, "XUiInstructionMonster") + +function XUiInstructionMonster:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.MonsterIds = {} + self.MonsterGrids = {} + self.SkillGrids = {} + + XTool.InitUiObject(self) + + self:Init() +end + +function XUiInstructionMonster:Init() + local role = CS.XFight.GetActivateClientRole() + if not role then return end + + local monsterIds = self.MonsterIds + local count = role.NpcCount or 0 + for index = 1, count do + local hasNpc, npc = role:GetNpc(index - 1) + if hasNpc and npc.IsCustomNpc then + local monsterId = XPokemonConfigs.GetMonsterIdByNpcId(npc.TemplateId) + tableInsert(monsterIds, monsterId) + end + end + + tableSort(monsterIds, function(aId, bId) + local aIsBoss = XPokemonConfigs.CheckMonsterType(aId, XPokemonConfigs.MonsterType.Boss) + local bIsBoss = XPokemonConfigs.CheckMonsterType(bId, XPokemonConfigs.MonsterType.Boss) + if aIsBoss ~= bIsBoss then + return aIsBoss + end + + local aAbility = XDataCenter.PokemonManager.GetMonsterAbility(aId) + local bAbility = XDataCenter.PokemonManager.GetMonsterAbility(bId) + if aAbility ~= bAbility then + return aAbility > bAbility + end + end) + + for index, monsterId in ipairs(monsterIds) do + local grid = self.MonsterGrids[index] + if not grid then + local go = index == 1 and self.GridMonster or CSUnityEngineObjectInstantiate(self.GridMonster, self.PanelMonster) + grid = XUiGridPokemonMonster.New(go) + self.MonsterGrids[index] = grid + end + + local paramIndex = index + local clickCb = function() + self:OnSelectMonster(paramIndex) + end + grid:Refresh(monsterId, clickCb) + grid.GameObject:SetActiveEx(true) + end + + for index = #monsterIds + 1, #self.MonsterGrids do + local grid = self.MonsterGrids[index] + if grid then + grid.GameObject:SetActiveEx(false) + end + end + + self:OnSelectMonster(1) + local isSpeedUp = XDataCenter.PokemonManager.IsSpeedUp() + self.BtnToggle:SetButtonState(isSpeedUp and XUiButtonState.Select or XUiButtonState.Normal) + self.BtnToggle.CallBack = function() self:OnClickSpeedUpToggle() end +end + +function XUiInstructionMonster:OnSelectMonster(index) + self.SelectIndex = index + + for paramIndex, grid in pairs(self.MonsterGrids) do + grid:SetSelect(paramIndex == index) + end + + self:UpdateSkills() +end + +function XUiInstructionMonster:UpdateSkills() + local monsterId = self.MonsterIds[self.SelectIndex] + + local skillIds = XDataCenter.PokemonManager.GetMonsterUsingSkillIdList(monsterId) + for index, skillId in pairs(skillIds) do + local grid = self.SkillGrids[index] + if not grid then + local go = index == 1 and self.GridSkill or CSUnityEngineObjectInstantiate(self.GridSkill, self.PanelSkillContainer) + grid = XTool.InitUiObjectByUi({}, go) + self.SkillGrids[index] = grid + end + + local icon = XPokemonConfigs.GetMonsterSkillIcon(skillId) + grid.RImgIconSkill:SetRawImage(icon) + + local desc = XPokemonConfigs.GetMonsterSkillDescription(skillId) + grid.TxtSkillDescription.text = desc + + grid.GameObject:SetActiveEx(true) + end + for index = #skillIds + 1, #self.SkillGrids do + local grid = self.SkillGrids[index] + if grid then + grid.GameObject:SetActiveEx(false) + end + end +end + +function XUiInstructionMonster:ShowPanel() + self.IsShow = true + self.GameObject:SetActive(true) +end + +function XUiInstructionMonster:HidePanel() + self.IsShow = false + self.GameObject:SetActive(false) +end + +function XUiInstructionMonster:CheckDataIsChange() + + return false +end + +function XUiInstructionMonster:SaveChange() + +end + +function XUiInstructionMonster:CancelChange() + +end + +function XUiInstructionMonster:ResetToDefault() + +end + +function XUiInstructionMonster:OnClickSpeedUpToggle() + local isSelect = self.BtnToggle:GetToggleState() + self.BtnToggle:SetButtonState(not isSelect and XUiButtonState.Select or XUiButtonState.Normal) + if isSelect then + local content = string.gsub(CSXTextManagerGetText("PokemonSpeedUpTipContent"), "\\n", "\n") + XUiManager.DialogTip(CSXTextManagerGetText("PokemonSpeedUpTipTitle"), content, XUiManager.DialogType.Normal, function() + self.BtnToggle:SetButtonState(XUiButtonState.Normal) + XDataCenter.PokemonManager.ResetSpeed() + XDataCenter.PokemonManager.SetSpeedUp(false) + end, function() + self.BtnToggle:SetButtonState(XUiButtonState.Select) + XDataCenter.PokemonManager.ChangeSpeed() + XDataCenter.PokemonManager.SetSpeedUp(true) + end) + else + self.BtnToggle:SetButtonState(XUiButtonState.Normal) + XDataCenter.PokemonManager.ResetSpeed() + XDataCenter.PokemonManager.SetSpeedUp(false) + end +end +return XUiInstructionMonster \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSet/XUiPanelAccountSet.lua b/Resources/Scripts/XUi/XUiSet/XUiPanelAccountSet.lua new file mode 100644 index 00000000..13842638 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSet/XUiPanelAccountSet.lua @@ -0,0 +1,158 @@ +XUiPanelAccountSet = XClass(nil, "XUiPanelAccountSet") +local Json = require("XCommon/Json") + +function XUiPanelAccountSet:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.MyColor = CS.UnityEngine.Color() + self:AddListener() + self:InitPanelData() +end + +function XUiPanelAccountSet:AddListener() + XUiHelper.RegisterClickEvent(self, self.FacebookBind, self.OnBindFacebook) + XUiHelper.RegisterClickEvent(self, self.GoogleBind, self.OnBindGoogle) + XUiHelper.RegisterClickEvent(self, self.TwitterBind, self.OnBindTwitter) + XUiHelper.RegisterClickEvent(self, self.AppleBind, self.OnBindApple) + XUiHelper.RegisterClickEvent(self, self.BackLogin, self.OnLogout) + + XEventManager.AddEventListener(XEventId.EVENT_HGSDK_GET_BIND, self.OnGetBindState, self) + XEventManager.AddEventListener(XEventId.EVENT_HGSDK_BIND_RESULT, self.OnBindResult, self) + + self.TwitterBind.transform.parent.gameObject:SetActiveEx(false) + self.BtnAccountCancellation.CallBack = function() + XHgSdkManager.AccountCancellation() + end +end + +function XUiPanelAccountSet:OnBindFacebook() + self.CurBindType = XHgSdkManager.UserType.FaceBook + XHgSdkManager.StartBind(XHgSdkManager.UserType.FaceBook) +end + +function XUiPanelAccountSet:OnBindGoogle() + self.CurBindType = XHgSdkManager.UserType.Google + XHgSdkManager.StartBind(XHgSdkManager.UserType.Google) +end + +function XUiPanelAccountSet:OnLogout() + XUserManager.ShowLogout() +end + +function XUiPanelAccountSet:OnLogoutInfo() + XHgSdkManager.AccountCancellation() +end + +function XUiPanelAccountSet:OnBindTwitter() + self.CurBindType = XHgSdkManager.UserType.Twitter + XHgSdkManager.StartBind(XHgSdkManager.UserType.Twitter) +end + +function XUiPanelAccountSet:OnBindApple() + self.CurBindType = XHgSdkManager.UserType.Apple + XHgSdkManager.StartBind(XHgSdkManager.UserType.Apple) +end + +function XUiPanelAccountSet:OnGetBindState(stateJson) + self.BindState = Json.decode(stateJson) + self:SetPanelData() +end + +--由HgSDK绑定的结果回调 +function XUiPanelAccountSet:OnBindResult(success, msg) + msg = msg or "" + if success then + XUiManager.TipSuccess("Account binding successful") + if self.CurBindType == nil then + CS.UnityEngine.Debug.LogError("当前绑定类型为空") + return + elseif self.CurBindType == XHgSdkManager.UserType.FaceBook then + self.BindState.fbBind = 1; + XUserManager.SetUserType(self.CurBindType); + XHgSdkManager.OnBindTaskFinished(); + elseif self.CurBindType == XHgSdkManager.UserType.Google then + self.BindState.googleBind = 1; + XUserManager.SetUserType(self.CurBindType); + XHgSdkManager.OnBindTaskFinished(); + elseif self.CurBindType == XHgSdkManager.UserType.Twitter then + self.BindState.twitterBind = 1 + XUserManager.SetUserType(self.CurBindType) + XHgSdkManager.OnBindTaskFinished() + elseif self.CurBindType == XHgSdkManager.UserType.Line then + self.BindState.lineBind = 1 + XUserManager.SetUserType(self.CurBindType) + XHgSdkManager.OnBindTaskFinished() + elseif self.CurBindType == XHgSdkManager.UserType.Apple then + self.BindState.appleBind = 1 + XUserManager.SetUserType(self.CurBindType) + XHgSdkManager.OnBindTaskFinished() + elseif self.CurBindType == XHgSdkManager.UserType.Suid then + XUserManager.SetPasswordStatus(1) + end + + self:SetPanelData() + self.CurBindType = nil + else + XUiManager.TipSuccess("Account binding failed:" .. msg) + end +end + +function XUiPanelAccountSet:InitPanelData() + --获取绑定的结果 + self.BindState = nil + self.CurBindType = nil + self.AppleGroup.gameObject:SetActiveEx(CS.UnityEngine.Application.platform == CS.UnityEngine.RuntimePlatform.IPhonePlayer); + self.FacebookBind.gameObject:SetActiveEx(false); + self.GoogleBind.gameObject:SetActive(false); + self.TwitterBind.gameObject:SetActiveEx(false) + self.AppleBind.gameObject:SetActiveEx(false) + self.GoogleBinded.gameObject:SetActiveEx(false) + self.FacebookBinded.gameObject:SetActiveEx(false) + self.TwitterBinded.gameObject:SetActiveEx(false) + self.AppleBinded.gameObject:SetActiveEx(false) + self.AccountCancellationItem.gameObject:SetActiveEx(CS.XRemoteConfig.AccountCancellationEnable);--暂时只是IOS + + if self.BindState == nil then + XHgSdkManager.GetBindState() + else + self:SetPanelData() + end +end + +function XUiPanelAccountSet:SetPanelData() + --{"code":0,"msg":"成功","fbBind":0,"googleBind":0,"gcBind":0,"weChatBind":0,"twitterBind":0,"appleBind":0,"lineBind":0} + self.FacebookBind.gameObject:SetActiveEx(self.BindState.fbBind == 0); + self.GoogleBind.gameObject:SetActive(self.BindState.googleBind == 0); + self.TwitterBind.gameObject:SetActiveEx(self.BindState.twitterBind == 0) + self.AppleBind.gameObject:SetActiveEx(self.BindState.appleBind == 0) + + self.FacebookBinded.gameObject:SetActiveEx(self.BindState.fbBind == 1) + self.GoogleBinded.gameObject:SetActiveEx(self.BindState.googleBind == 1) + self.TwitterBinded.gameObject:SetActiveEx(self.BindState.twitterBind == 1) + self.AppleBinded.gameObject:SetActiveEx(self.BindState.appleBind == 1) +end + +function XUiPanelAccountSet:ShowPanel() + self.IsShow = true + self.GameObject:SetActive(true) + if self.BindState == nil then + XHgSdkManager.GetBindState() + else + self:SetPanelData() + end +end + +function XUiPanelAccountSet:HidePanel() + self.IsShow = false + self.GameObject:SetActive(false) +end + +function XUiPanelAccountSet:OnDestroy() + XEventManager.RemoveEventListener(XEventId.EVENT_HGSDK_GET_BIND, self.OnGetBindState, self) + XEventManager.RemoveEventListener(XEventId.EVENT_HGSDK_BIND_RESULT, self.OnBindResult, self) +end + +function XUiPanelAccountSet:CheckDataIsChange() + return false +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSet/XUiPanelFightSet.lua b/Resources/Scripts/XUi/XUiSet/XUiPanelFightSet.lua new file mode 100644 index 00000000..0f3f9587 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSet/XUiPanelFightSet.lua @@ -0,0 +1,405 @@ +XUiPanelFightSet = XClass(nil, "XUiPanelFightSet") + +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate +local XUiBtnKeyItem = require("XUi/XUiSet/ChildItem/XUiBtnKeyItem") + +local XInputManager = CS.XInputManager + +function XUiPanelFightSet:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + XTool.InitUiObject(self) + self.PanelSetKeyTip.gameObject:SetActiveEx(false) + self:GetDataThenLoadSchemeName() + self:RegisterCustomUiEvent() + self.PageType = { + Touch = 1, --触摸设置 + GameController = 2, --外接手柄键位设置 + Keyboard = 3, -- 键盘键位设置 + } + self._CurKeySetType = false + self:UpdateKeySetType() + + self.CurSelectBtn = nil + self.CurSelectKey = nil + + self.BtnTabGroup:Init({ self.BtnTabTouch, self.BtnTabGameController, self.BtnTabKeyboard }, function(index) self:OnTabClick(index) end) + self.PatternGroup:Init({ self.BtnXbox, self.BtnPS4 }, function(index) self:OnPatternGroupClick(index) end) + self.JoystickGroup:Init({ self.TogStatic, self.TogDynamic }, nil) + self.TogStatic.CallBack = function() self:OnTogStaticJoystickClick() end + self.TogDynamic.CallBack = function() self:OnTogDynamicJoystickClick() end + self.BtnCustomUi.CallBack = function() self:OnBtnCustomUiClick() end + self.TogEnableJoystick.CallBack = function() self:OnTogEnableJoystickClick() end + self.TogEnableKeyboard.CallBack = function() self:OnTogEnableKeyboardClick() end + self.BtnCloseInput.CallBack = function() self:OnBtnCloseInputClick() end + + self:InitControllerPanel() + self:RefreshJoystickPanel() + self:InitKeyboardPanel() + + self:RefreshKeyboardPanel() + self.BtnTabGroup:SelectIndex(self:GetDefaultIndex()) + self.PatternGroup:SelectIndex(XInputManager.GetJoystickType()) + local behaviour = self.GameObject:AddComponent(typeof(CS.XLuaBehaviour)) + if self.Update then + behaviour.LuaUpdate = function() self:Update() end + end + + self.CustomUi.gameObject:SetActiveEx(not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.CustomUi)) +end + +function XUiPanelFightSet:GetCurKeySetType() + return self._CurKeySetType or CS.KeySetType.Xbox --默认会显示xbox +end + +function XUiPanelFightSet:GetDefaultIndex() + return self.PageType.Touch +end + +--自定义按键 +function XUiPanelFightSet:OnCheckCustomUiSetNews(count) + self.BtnCustomUi:ShowReddot(count >= 0) +end + +function XUiPanelFightSet:GetCache() + self.DynamicJoystick = XDataCenter.SetManager.DynamicJoystick + self.JoystickGroup:SelectIndex(self.DynamicJoystick + 1) +end + +function XUiPanelFightSet:InitControllerPanel(resetTextOnly) + if self.CtrlPanelInit then + for _, v in ipairs(self.CtrlKeyItemList) do + v:SetKeySetType(self:GetCurKeySetType()) + v:Refresh(nil, nil, resetTextOnly) + end + self.SliderCameraMoveSensitivity.value = self:GetCameraMoveSensitivity() + return + end + self.CtrlKeyItemList = {} + local list = XSetConfigs.GetControllerMapCfg() + + for _, v in ipairs(list) do + if v.Type == XSetConfigs.ControllerSetItemType.SetButton then + local grid = XUiBtnKeyItem.New(CSUnityEngineObjectInstantiate(self.BtnKeyItem, self.ControllerSetContent), self.UiRoot) + table.insert(self.CtrlKeyItemList, grid) + grid.GameObject:SetActiveEx(true) + grid:SetKeySetType(self:GetCurKeySetType()) + grid:Refresh(v, handler(self, self.EditKey), resetTextOnly) + elseif v.Type == XSetConfigs.ControllerSetItemType.Section then + local gridSection = CSUnityEngineObjectInstantiate(self.TxtSection, self.ControllerSetContent) + gridSection.gameObject:SetActiveEx(true) + local txtTitle = gridSection:Find("TxtTitle"):GetComponent("Text") + txtTitle.text = v.Title + elseif v.Type == XSetConfigs.ControllerSetItemType.Slider then + self.GridSlider:SetParent(self.ControllerSetContent, false) + self.GridSlider.gameObject:SetActiveEx(true) + self.SliderCameraMoveSensitivity.value = self:GetCameraMoveSensitivity() + XUiHelper.RegisterSliderChangeEvent(self, self.SliderCameraMoveSensitivity, function(_, value) + self:SetCameraMoveSensitivity(value) + end) + end + end + self.BtnKeyItem.gameObject:SetActiveEx(false) + self.CtrlPanelInit = true +end + +--TODO:键盘自定义 +function XUiPanelFightSet:InitKeyboardPanel() + if self.KeyboardPanelInit then + return + end + + local list = XSetConfigs.GetKeyboardMapCfg() + + for _, item in ipairs(list) do + local grid = XUiBtnKeyItem.New(CSUnityEngineObjectInstantiate(self.BtnKeyItem, self.KeyboardSetContent), self) + grid.GameObject:SetActive(true) + grid:SetKeySetType(CS.KeySetType.Keyboard) + grid:Refresh(item) + end + self.BtnKeyItem.gameObject:SetActiveEx(false) + self.KeyboardPanelInit = true +end + +function XUiPanelFightSet:Update() + if self.CurSelectBtn and self.CurSelectKey and XInputManager.GetCurEditKeyNum() > 0 then + self.TxtInput.text = XInputManager.GetCurEditKeyString() .. CS.XTextManager.GetText("SetInputFirstKey") + end +end + +function XUiPanelFightSet:EditKey(keyCode, targetItem) + XInputManager.EndEdit() + local cb = function(isConflict) + self.CurSelectBtn = nil + self.CurSelectKey = nil + targetItem:Refresh() + self.PanelSetKeyTip.gameObject:SetActiveEx(false) + if isConflict then + local curKeySetType = self:GetCurKeySetType() + local keyCurrent = CS.XInputManager.GetConflictKey1() + local keyConflict = CS.XInputManager.GetConflictKey2() + local textKeyCurrent = XSetConfigs.GetControllerKeyText(keyCurrent) + local textKeyConflict = XSetConfigs.GetControllerKeyText(keyConflict) + if textKeyCurrent and textKeyConflict then + XUiManager.DialogTip( + nil, + XUiHelper.ReplaceTextNewLine(XUiHelper.GetText("SetKeyConflict", textKeyConflict, textKeyCurrent)), + XUiManager.DialogType.Normal, + function() + CS.XInputManager.ClearConflictKey() + end, + function() + CS.XInputManager.SwapConflictKey(curKeySetType) + local gridList + if curKeySetType == CS.KeySetType.Xbox or curKeySetType == CS.KeySetType.Ps4 then + gridList = self.CtrlKeyItemList + elseif curKeySetType == CS.KeySetType.Keyboard then + gridList = self._KeyboardGridList + end + if gridList then + for _, v in ipairs(gridList) do + v:SetKeySetType(self:GetCurKeySetType()) + v:Refresh(nil, nil, true) + end + end + XUiManager.TipSuccess(XUiHelper.GetText("SetJoyStickSuccess")) + end + ) + end + end + end + + if self:GetCurKeySetType() == CS.KeySetType.Keyboard then + self.TxtInput.text = CS.XTextManager.GetText("SetInputStartNoCombine") + else + self.TxtInput.text = CS.XTextManager.GetText("SetInputStart") + end + self.TxtFunction.text = targetItem.Data.Title + XInputManager.StartEditKey(self:GetCurKeySetType(), keyCode, cb) + self.PanelSetKeyTip.gameObject:SetActiveEx(true) + self.CurSelectBtn = targetItem + self.CurSelectKey = keyCode +end + +function XUiPanelFightSet:OnTabClick(index) + self.CurPageType = index + self:UpdateKeySetType() + self:UpdatePanel() +end + +function XUiPanelFightSet:UpdatePanel() + if self.CurPageType == self.PageType.Touch then + self.UiRoot.BtnSave.gameObject:SetActiveEx(true) + self.UiRoot.BtnDefault.gameObject:SetActiveEx(true) + elseif self.CurPageType == self.PageType.GameController then + self.UiRoot.BtnSave.gameObject:SetActiveEx(false) + if XInputManager.EnableInputJoystick then + self.UiRoot.BtnDefault.gameObject:SetActiveEx(true) + else + self.UiRoot.BtnDefault.gameObject:SetActiveEx(false) + end + self:InitControllerPanel() + elseif self.CurPageType == self.PageType.Keyboard then + self.UiRoot.BtnSave.gameObject:SetActiveEx(false) + self.UiRoot.BtnDefault.gameObject:SetActiveEx(false) + self:InitKeyboardPanel() + end + self:ShowSubPanel(self.CurPageType) +end + +function XUiPanelFightSet:ShowSubPanel(type) + self.PanelTouch.gameObject:SetActiveEx(type == self.PageType.Touch) + self.PanelGameController.gameObject:SetActiveEx(type == self.PageType.GameController) + self.PanelKeyboard.gameObject:SetActiveEx(type == self.PageType.Keyboard) +end + +function XUiPanelFightSet:OnPatternGroupClick(index) + self:UpdateKeySetType() + self:InitControllerPanel() +end + +function XUiPanelFightSet:ShowPanel() + self:UpdatePanel() + self:GetCache() + self.GameObject:SetActive(true) + self.RedPoint = XRedPointManager.AddRedPointEvent(self.BtnCustomUi, self.OnCheckCustomUiSetNews, self, { XRedPointConditions.Types.CONDITION_MAIN_SET }, nil, true) + self.IsShow = true +end + +function XUiPanelFightSet:HidePanel() + XInputManager.EndEdit() + self.IsShow = false + self.GameObject:SetActive(false) +end + +function XUiPanelFightSet:OnTogStaticJoystickClick() + self.DynamicJoystick = 0 +end + +function XUiPanelFightSet:OnTogDynamicJoystickClick() + self.DynamicJoystick = 1 +end + +function XUiPanelFightSet:CheckDataIsChange() + return self.DynamicJoystick ~= XDataCenter.SetManager.DynamicJoystick +end + +function XUiPanelFightSet:SaveChange() + if self.DynamicJoystick ~= XDataCenter.SetManager.DynamicJoystick then + XDataCenter.SetManager.SetDynamicJoystick(self.DynamicJoystick) + CS.UnityEngine.PlayerPrefs.SetInt(XPrefs.DynamicJoystick, self.DynamicJoystick) + CS.UnityEngine.PlayerPrefs.Save() + end +end + +function XUiPanelFightSet:CancelChange() + self.JoystickGroup:SelectIndex(self.DynamicJoystick + 1) +end + +function XUiPanelFightSet:ResetToDefault() + if self.CurPageType == self.PageType.Touch then + self.DynamicJoystick = XSetConfigs.DefaultDynamicJoystick + self.JoystickGroup:SelectIndex(self.DynamicJoystick + 1) + elseif self.CurPageType == self.PageType.GameController then + XInputManager.DefaultKeysSetting(self:GetCurKeySetType()) + XInputManager.DefaultCameraMoveSensitivitySetting(self:GetCurKeySetType()) + self.SliderCameraMoveSensitivity.value = self:GetCameraMoveSensitivity() + self:InitControllerPanel(true) + end +end + +function XUiPanelFightSet:OnTogEnableJoystickClick(value) + if value ~= nil then + XInputManager.SetEnableInputJoystick(value) + else + XInputManager.SetEnableInputJoystick(self.TogEnableJoystick:GetToggleState()) + end + + if XInputManager.EnableInputJoystick then + self:SetEnableInputKeyboard(false) + self:RefreshKeyboardPanel() + end + self:InitControllerPanel() + self:RefreshJoystickPanel() +end + +function XUiPanelFightSet:RefreshJoystickPanel() + local enable = XInputManager.EnableInputJoystick + self.TogEnableJoystick:SetButtonState(enable and XUiButtonState.Select or XUiButtonState.Normal) + if enable then + self.PanelJoystickSet.gameObject:SetActiveEx(true) + self.TipDisableJoyStick.gameObject:SetActiveEx(false) + self.UiRoot.BtnDefault.gameObject:SetActiveEx(true) + self:SetEnableInputKeyboard(false) + else + self.PanelJoystickSet.gameObject:SetActiveEx(false) + self.TipDisableJoyStick.gameObject:SetActiveEx(true) + self.UiRoot.BtnDefault.gameObject:SetActiveEx(false) + end +end + +function XUiPanelFightSet:OnTogEnableKeyboardClick(value) + if value ~= nil then + self:SetEnableInputKeyboard(value) + else + self:SetEnableInputKeyboard(self.TogEnableKeyboard:GetToggleState()) + end + + if XInputManager.EnableInputKeyboard then + XInputManager.SetEnableInputJoystick(false) + self:RefreshJoystickPanel() + end + self:InitKeyboardPanel() + self:RefreshKeyboardPanel() +end + +function XUiPanelFightSet:RefreshKeyboardPanel() + local enable = XInputManager.EnableInputKeyboard + self.TogEnableKeyboard:SetButtonState(enable and XUiButtonState.Select or XUiButtonState.Normal) + if enable then + self.PanelKeyboardSet.gameObject:SetActiveEx(true) + self.TipDisableKeyboard.gameObject:SetActiveEx(false) + XInputManager.SetEnableInputJoystick(false) + else + self.PanelKeyboardSet.gameObject:SetActiveEx(false) + self.TipDisableKeyboard.gameObject:SetActiveEx(true) + end + self.UiRoot.BtnDefault.gameObject:SetActiveEx(false) +end + +function XUiPanelFightSet:OnBtnCloseInputClick() + XInputManager.EndEdit() + self.PanelSetKeyTip.gameObject:SetActiveEx(false) +end + +function XUiPanelFightSet:OnBtnCustomUiClick() + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.CustomUi) then + return + end + + XLuaUiManager.Open("UiFightCustom", CS.XFight.Instance) +end + +function XUiPanelFightSet:GetDataThenLoadSchemeName() + CS.XCustomUi.Instance:GetData(function() + self:LoadSchemeName() + end) +end + +function XUiPanelFightSet:LoadSchemeName() + self.TxtScheme.text = CS.XCustomUi.Instance.SchemeName +end + +function XUiPanelFightSet:RegisterCustomUiEvent() + self.LoadSchemeNameFunc = handler(self, self.LoadSchemeName) + CsXGameEventManager.Instance:RegisterEvent(XEventId.EVENT_CUSTOM_UI_SCHEME_CHANGED, self.LoadSchemeNameFunc) +end + +function XUiPanelFightSet:RemoveCustomUiEvent() + CsXGameEventManager.Instance:RemoveEvent(XEventId.EVENT_CUSTOM_UI_SCHEME_CHANGED, self.LoadSchemeNameFunc) + self.LoadSchemeNameFunc = nil +end + +function XUiPanelFightSet:OnDestroy() + self:RemoveCustomUiEvent() +end +function XUiPanelFightSet:SetEnableInputKeyboard(value) + XInputManager.SetEnableInputKeyboard(value) +end + +function XUiPanelFightSet:UpdateKeySetType() + if self.BtnTabGroup.CurSelectId == self.PageType.Touch then + return + end + if self.BtnTabGroup.CurSelectId == self.PageType.Keyboard then + self._CurKeySetType = CS.KeySetType.Keyboard + XInputManager.SetJoystickType(3) + return + end + if self.BtnTabGroup.CurSelectId == self.PageType.GameController then + if self.PatternGroup.CurSelectId == 1 then + self._CurKeySetType = CS.KeySetType.Xbox + XInputManager.SetJoystickType(1) + return + end + if self.PatternGroup.CurSelectId == 2 then + self._CurKeySetType = CS.KeySetType.Ps4 + XInputManager.SetJoystickType(2) + return + end + end +end + +function XUiPanelFightSet:SetCameraMoveSensitivity(value) + value = value + 1 + XInputManager.SetCameraMoveSensitivity(self:GetCurKeySetType(), value) +end + +function XUiPanelFightSet:GetCameraMoveSensitivity() + local value = XInputManager.GetCameraMoveSensitivity(self:GetCurKeySetType()) + return math.max(0, value - 1) +end + + +return XUiPanelFightSet \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSet/XUiPanelFightSetPc.lua b/Resources/Scripts/XUi/XUiSet/XUiPanelFightSetPc.lua new file mode 100644 index 00000000..9fd0fb15 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSet/XUiPanelFightSetPc.lua @@ -0,0 +1,93 @@ +local XInputManager = CS.XInputManager +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate +local XUiBtnKeyItem = require("XUi/XUiSet/ChildItem/XUiBtnKeyItem") +local XUiPanelFightSet = require("XUi/XUiSet/XUiPanelFightSet") + +local XUiPanelFightSetPc = XClass(XUiPanelFightSet, "XUiPanelFightSetPc") + +function XUiPanelFightSetPc:GetDefaultIndex() + return self.PageType.Keyboard +end + +function XUiPanelFightSetPc:RefreshKeyboardPanel() + self.PanelKeyboardSet.gameObject:SetActiveEx(true) +end + +function XUiPanelFightSetPc:UpdatePanel() + if self.CurPageType == self.PageType.Touch then + self.UiRoot.BtnSave.gameObject:SetActiveEx(true) + self.UiRoot.BtnDefault.gameObject:SetActiveEx(true) + elseif self.CurPageType == self.PageType.GameController then + self.UiRoot.BtnSave.gameObject:SetActiveEx(false) + if XInputManager.EnableInputJoystick then + self.UiRoot.BtnDefault.gameObject:SetActiveEx(true) + else + self.UiRoot.BtnDefault.gameObject:SetActiveEx(false) + end + self:InitControllerPanel() + elseif self.CurPageType == self.PageType.Keyboard then + self.UiRoot.BtnSave.gameObject:SetActiveEx(false) + self.UiRoot.BtnDefault.gameObject:SetActiveEx(true) + self:InitKeyboardPanel() + end + self:ShowSubPanel(self.CurPageType) +end + +function XUiPanelFightSetPc:ResetToDefault() + if self.CurPageType == self.PageType.Touch then + self.DynamicJoystick = XSetConfigs.DefaultDynamicJoystick + self.JoystickGroup:SelectIndex(self.DynamicJoystick + 1) + elseif self.CurPageType == self.PageType.GameController then + XInputManager.DefaultKeysSetting(self:GetCurKeySetType()) + XInputManager.DefaultCameraMoveSensitivitySetting(self:GetCurKeySetType()) + self.SliderCameraMoveSensitivityPc.value = self:GetCameraMoveSensitivity() + self:InitControllerPanel(true) + elseif self.CurPageType == self.PageType.Keyboard then + XInputManager.DefaultKeysSetting(CS.KeySetType.Keyboard) + XInputManager.DefaultCameraMoveSensitivitySetting(CS.KeySetType.Keyboard) + self:InitKeyboardPanel(true) + end +end + +function XUiPanelFightSetPc:InitKeyboardPanel(resetTextOnly) + if self.KeyboardPanelInit then + for _, v in ipairs(self._KeyboardGridList) do + v:Refresh(nil, nil, resetTextOnly) + end + self.SliderCameraMoveSensitivityPc.value = self:GetCameraMoveSensitivity() + return + end + + self._KeyboardGridList = {} + local list = XSetConfigs.GetControllerMapCfg() + + for _, item in ipairs(list) do + if item.Type == XSetConfigs.ControllerSetItemType.SetButton then + local grid = XUiBtnKeyItem.New(CSUnityEngineObjectInstantiate(self.BtnKeyItem, self.KeyboardSetContent), self.UiRoot) + grid.GameObject:SetActive(true) + grid:SetKeySetType(CS.KeySetType.Keyboard) + grid:Refresh(item, handler(self, self.EditKey), resetTextOnly) + self._KeyboardGridList[#self._KeyboardGridList + 1] = grid + elseif item.Type == XSetConfigs.ControllerSetItemType.Section then + local gridSection = CSUnityEngineObjectInstantiate(self.TxtSection, self.KeyboardSetContent) + gridSection.gameObject:SetActiveEx(true) + local txtTitle = gridSection:Find("TxtTitle"):GetComponent("Text") + txtTitle.text = item.Title + elseif item.Type == XSetConfigs.ControllerSetItemType.Slider then + self.GridSliderPC:SetParent(self.KeyboardSetContent, false) + self.GridSliderPC.gameObject:SetActiveEx(true) + self.SliderCameraMoveSensitivityPc.value = self:GetCameraMoveSensitivity() + XUiHelper.RegisterSliderChangeEvent(self, self.SliderCameraMoveSensitivityPc, function(_, value) + self:SetCameraMoveSensitivity(value) + end) + end + end + self.BtnKeyItem.gameObject:SetActiveEx(false) + self.KeyboardPanelInit = true +end + +function XUiPanelFightSetPc:SetEnableInputKeyboard(value) + --XInputManager.SetEnableInputKeyboard(value) +end + +return XUiPanelFightSetPc \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSet/XUiPanelGraphicsSet.lua b/Resources/Scripts/XUi/XUiSet/XUiPanelGraphicsSet.lua new file mode 100644 index 00000000..0e642175 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSet/XUiPanelGraphicsSet.lua @@ -0,0 +1,739 @@ +XUiPanelGraphicsSet = XClass(nil, "XUiPanelGraphicsSet") + +local XQualityManager = CS.XQualityManager.Instance + +local function CopyCQualitySettings(luaQuality, cQuality) + luaQuality.UseHdr = cQuality.UseHdr + luaQuality.UseFxaa = cQuality.UseFxaa + + -- luaQuality.UseDistortion = cQuality.UseDistortion + -- luaQuality.HighFrameRate = cQuality.HighFrameRate + luaQuality.EffectLevel = cQuality:GetEffectLevel() + luaQuality.OtherEffectLevel = cQuality:GetOtherEffectLevel() + luaQuality.GraphicsLevel = cQuality:GetGraphicsLevel() + luaQuality.ShadowLevel = cQuality:GetShadowLevel() + luaQuality.MirrorLevel = cQuality:GetMirrorLevel() + luaQuality.ResolutionLevel = cQuality:GetResolutionLevel() + + luaQuality.DistortionLevel = cQuality:GetDistortionLevel() + luaQuality.FrameRateLevel = cQuality:GetFrameRateLevel() + + luaQuality.BloomLevel = cQuality:GetBloomLevel() +end + +local function GetCQualitySettings(luaQuality) + local quality = CS.XQualitySettings() + quality.UseHdr = luaQuality.UseHdr + quality.UseFxaa = luaQuality.UseFxaa + -- quality.UseDistortion = luaQuality.UseDistortion + -- quality.HighFrameRate = luaQuality.HighFrameRate + quality:SetEffectLevel(luaQuality.EffectLevel) + quality:SetOtherEffectLevel(luaQuality.OtherEffectLevel) + quality:SetGraphicsLevel(luaQuality.GraphicsLevel) + quality:SetShadowLevel(luaQuality.ShadowLevel) + quality:SetMirrorLevel(luaQuality.MirrorLevel) + quality:SetResolutionLevel(luaQuality.ResolutionLevel) + quality:SetDistortionLevel(luaQuality.DistortionLevel) + quality:SetFrameRateLevel(luaQuality.FrameRateLevel) + + quality:SetBloomLevel(luaQuality.BloomLevel) + + return quality +end + +local function SetToggleEnable(tog, flag) + if tog.interactable ~= flag then + tog.interactable = flag + end +end + + +function XUiPanelGraphicsSet:Ctor(ui,parent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + self.Parent = parent + self:InitAutoScript() + + self.QualitySettings = { + UseHdr = true, + UseFxaa = true, + -- UseDistortion = true, + -- HighFrameRate = true, + + DistortionLevel = nil, + EffectLevel = nil, + OtherEffectLevel = nil, + GraphicsLevel = nil, + ShadowLevel = nil, + MirrorLevel = nil, + ResolutionLevel = nil, + FrameRateLevel = nil, + BloomLevel = nil + } + + + + self.TogQualityGroup = { + self.TogQuality_0, self.TogQuality_1, self.TogQuality_2, self.TogQuality_3, self.TogQuality_4, self.TogQuality_5, + } + + self.TogGraphicsGroup = { + self.TogGraphics_0, self.TogGraphics_1, self.TogGraphics_2, self.TogGraphics_3, self.TogGraphics_4, + } + + self.TogEffectGroup = { + self.TogEffect_0, self.TogEffect_1, self.TogEffect_2, self.TogEffect_3 + } + + self.TogOtherEffect_0 = self.Transform:Find("SView /Viewport/PanelContent/OtherEffectLevel/Array/TGroupResolution/TogEffect_0"):GetComponent("Toggle") + self.TogOtherEffect_1 = self.Transform:Find("SView /Viewport/PanelContent/OtherEffectLevel/Array/TGroupResolution/TogEffect_1"):GetComponent("Toggle") + self.TogOtherEffect_2 = self.Transform:Find("SView /Viewport/PanelContent/OtherEffectLevel/Array/TGroupResolution/TogEffect_2"):GetComponent("Toggle") + self.TogOtherEffect_3 = self.Transform:Find("SView /Viewport/PanelContent/OtherEffectLevel/Array/TGroupResolution/TogEffect_3"):GetComponent("Toggle") + + self.TogOtherEffectGroup = { + self.TogOtherEffect_0, self.TogOtherEffect_1, self.TogOtherEffect_2, self.TogOtherEffect_3 + } + + self.TogShadowGroup = { + self.TogShadow_0, self.TogShadow_1, self.TogShadow_2, self.TogShadow_3, + } + + self.TogMirrorGroup = { + self.TogMirror_0, self.TogMirror_1, self.TogMirror_2, self.TogMirror_3, + } + + self.TogResolutionGroup = { + self.TogResolution_0, self.TogResolution_1, self.TogResolution_2, self.TogResolution_3 + } + + self.TogFrameRateGroup = { + self.TogFrameRate_0, self.TogFrameRate_1, self.TogFrameRate_2 + } + + self.TogBloom_0 = self.Transform:Find("SView /Viewport/PanelContent/BloomLevel/Array/TGroupBloom/TogBloom_0"):GetComponent("Toggle") + self.TogBloom_1 = self.Transform:Find("SView /Viewport/PanelContent/BloomLevel/Array/TGroupBloom/TogBloom_1"):GetComponent("Toggle") + self.TogBloom_2 = self.Transform:Find("SView /Viewport/PanelContent/BloomLevel/Array/TGroupBloom/TogBloom_2"):GetComponent("Toggle") + + self.TogBloomGroup = { + self.TogBloom_0, self.TogBloom_1, self.TogBloom_2 + } + + + self.TogDistortion_0 = self.Transform:Find("SView /Viewport/PanelContent/DistortionLevel/Array/TGroupResolution/TogDistortion_0"):GetComponent("Toggle") + self.TogDistortion_1 = self.Transform:Find("SView /Viewport/PanelContent/DistortionLevel/Array/TGroupResolution/TogDistortion_1"):GetComponent("Toggle") + self.TogDistortion_2 = self.Transform:Find("SView /Viewport/PanelContent/DistortionLevel/Array/TGroupResolution/TogDistortion_2"):GetComponent("Toggle") + + self.TogDistortionGroup = { + self.TogDistortion_0, self.TogDistortion_1, self.TogDistortion_2 + } + + self.CurQualityLevel = nil + self.Dirty = false + + self.TogHDR = self.TogHDR + self.TogFxaa = self.TogFxaa + -- self.TogDistortion = self.TogDistortion + -- self.TogHighFrameRate = self.TogHighFrameRate + XUiHelper.RegisterClickEvent(self, self.TogHDR, function(isEnable) + self.Dirty = true + self:OnClickHDR(isEnable) + end) + + XUiHelper.RegisterClickEvent(self, self.TogFxaa, function(isEnable) + self.Dirty = true + self:OnClickFXAA(isEnable) + end) + + -- XUiHelper.RegisterClickEvent(self, self.TogDistortion, function(isEnable) + -- self.Dirty = true + -- -- self:OnClickDistortion(isEnable) + -- end) + + -- XUiHelper.RegisterClickEvent(self, self.TogHighFrameRate, function(isEnable) + -- self.Dirty = true + -- self:OnClickHighFrameRate(isEnable) + -- end) + self.lock = false; + + for index, tog in ipairs(self.TogDistortionGroup) do + local qualityId = index - 1 + + XUiHelper.RegisterClickEvent(self, tog, function(open) + + -- if self.lock then return end + if open then + self.Dirty = true + self:OnClickDistortionSettings(qualityId) + end + + if self.CurQualityLevel ~= 0 then + self.CurQualityLevel = 0 + self:OnClickQualitySettings(self.CurQualityLevel) + self:UpdatePanel() + end + end) + end + + + for index, tog in ipairs(self.TogBloomGroup) do + local qualityId = index - 1 + + XUiHelper.RegisterClickEvent(self, tog, function(open) + + -- if self.lock then return end + if open then + self.Dirty = true + self:OnClickBloomSettings(qualityId) + end + + if self.CurQualityLevel ~= 0 then + self.CurQualityLevel = 0 + self:OnClickQualitySettings(self.CurQualityLevel) + self:UpdatePanel() + end + end) + end + + + + for index, tog in ipairs(self.TogQualityGroup) do + local qualityId = index - 1 + + XUiHelper.RegisterClickEvent(self, tog, function(open) + if self.lock then return end + + if open then + self.Dirty = true + self:OnClickQualitySettings(qualityId) + end + end) + end + + for index, tog in ipairs(self.TogResolutionGroup) do + local resolutionId = index - 1 + + XUiHelper.RegisterClickEvent(self, tog, function(open) + + -- if self.lock then return end + if open then + self.Dirty = true + self:OnClickResolutionSettings(resolutionId) + end + + if self.CurQualityLevel ~= 0 then + self.CurQualityLevel = 0 + self:OnClickQualitySettings(self.CurQualityLevel) + self:UpdatePanel() + end + end) + end + + for index, tog in ipairs(self.TogFrameRateGroup) do + local resolutionId = index - 1 + + XUiHelper.RegisterClickEvent(self, tog, function(open) + + -- if self.lock then return end + if open then + self.Dirty = true + self:OnClickFrameRateSettings(resolutionId) + end + + if self.CurQualityLevel ~= 0 then + self.CurQualityLevel = 0 + self:OnClickQualitySettings(self.CurQualityLevel) + self:UpdatePanel() + end + end) + end + + for index, tog in ipairs(self.TogOtherEffectGroup) do + + local effectId = index - 1 + XUiHelper.RegisterClickEvent(self, tog, function(open) + + -- if self.lock then return end + if open then + self.Dirty = true + self:OnClickOtherEffectLevel(effectId) + end + + if self.CurQualityLevel ~= 0 then + self.CurQualityLevel = 0 + self:OnClickQualitySettings(self.CurQualityLevel) + self:UpdatePanel() + end + + end) + end + + + for index, tog in ipairs(self.TogEffectGroup) do + + local effectId = index - 1 + XUiHelper.RegisterClickEvent(self, tog, function(open) + + -- if self.lock then return end + if open then + self.Dirty = true + self:OnClickEffectLevel(effectId) + end + + if self.CurQualityLevel ~= 0 then + self.CurQualityLevel = 0 + self:OnClickQualitySettings(self.CurQualityLevel) + self:UpdatePanel() + end + + end) + end + + for index, tog in ipairs(self.TogShadowGroup) do + + local shadowId = index - 1 + XUiHelper.RegisterClickEvent(self, tog, function(open) + + -- if self.lock then return end + if open then + self.Dirty = true + self:OnClickShadowLevel(shadowId) + end + + if self.CurQualityLevel ~= 0 then + self.CurQualityLevel = 0 + self:OnClickQualitySettings(self.CurQualityLevel) + self:UpdatePanel() + end + end) + end + + for index, tog in ipairs(self.TogGraphicsGroup) do + + local graphicId = index - 1 + XUiHelper.RegisterClickEvent(self, tog, function(open) + + -- if self.lock then return end + + if open then + self.Dirty = true + self:OnClickGraphicsLevel(graphicId) + end + + if self.CurQualityLevel ~= 0 then + self.CurQualityLevel = 0 + self:OnClickQualitySettings(self.CurQualityLevel) + self:UpdatePanel() + end + end) + end + + for index, tog in ipairs(self.TogMirrorGroup) do + + local mirrorId = index - 1 + XUiHelper.RegisterClickEvent(self, tog, function(open) + -- if self.lock then return end + if open then + self.Dirty = true + self:OnClickMirrorLevel(mirrorId) + end + + if self.CurQualityLevel ~= 0 then + self.CurQualityLevel = 0 + self:OnClickQualitySettings(self.CurQualityLevel) + self:UpdatePanel() + end + end) + + end + + local defaultLevel = XQualityManager:GetDefaultLevel() + 1 + + for index, tog in ipairs(self.TogQualityGroup) do + + if index ~= 1 then + local icon = tog.gameObject.transform:Find("Icon").gameObject + + if icon then + icon:SetActive(index == defaultLevel) + end + end + end + + +end + +function XUiPanelGraphicsSet:OnClickFrameRateSettings(id) + self.QualitySettings.FrameRateLevel = id +end + +function XUiPanelGraphicsSet:OnClickResolutionSettings(id) + self.QualitySettings.ResolutionLevel = id +end + +function XUiPanelGraphicsSet:OnClickEffectLevel(id) + self.QualitySettings.EffectLevel = id +end + +function XUiPanelGraphicsSet:OnClickOtherEffectLevel(id) + self.QualitySettings.OtherEffectLevel = id +end + +function XUiPanelGraphicsSet:OnClickShadowLevel(id) + self.QualitySettings.ShadowLevel = id +end + +function XUiPanelGraphicsSet:OnClickGraphicsLevel(id) + self.QualitySettings.GraphicsLevel = id +end + +function XUiPanelGraphicsSet:OnClickMirrorLevel(id) + self.QualitySettings.MirrorLevel = id +end + +function XUiPanelGraphicsSet:OnClickDistortionSettings(id) + self.QualitySettings.DistortionLevel = id +end + +function XUiPanelGraphicsSet:OnClickBloomSettings(id) + self.QualitySettings.BloomLevel = id +end + +function XUiPanelGraphicsSet:OnClickQualitySettings(id) + --检查其他配置 + if self.CurQualityLevel == 0 then + self:SaveCustomQualitySettings() + end + + self.CurQualityLevel = id + self:UpdateByCurrentLevel() +end + +function XUiPanelGraphicsSet:SaveCustomQualitySettings() + if self.CurQualityLevel == 0 then + local c = GetCQualitySettings(self.QualitySettings) + XQualityManager:SaveCustomQualitySettings(c) + end +end + +function XUiPanelGraphicsSet:OnClickHDR() + self.QualitySettings.UseHdr = self.TogHDR.isOn + if self.CurQualityLevel ~= 0 then + self.CurQualityLevel = 0 + self:OnClickQualitySettings(self.CurQualityLevel) + self:UpdatePanel() + end +end + +function XUiPanelGraphicsSet:OnClickFXAA() + self.QualitySettings.UseFxaa = self.TogFxaa.isOn + if self.CurQualityLevel ~= 0 then + self.CurQualityLevel = 0 + self:OnClickQualitySettings(self.CurQualityLevel) + self:UpdatePanel() + end +end + +-- function XUiPanelGraphicsSet:OnClickDistortion(isEnable) +-- -- self.QualitySettings.UseDistortion = self.TogDistortion.isOn +-- end + +-- function XUiPanelPicQualitySet:OnClickHighFrameRate(isEnable) +-- self.QualitySettings.HighFrameRate = self.TogHighFrameRate.isOn +-- end +--on show +function XUiPanelGraphicsSet:ShowPanel() + self.Dirty = false + + self.GameObject:SetActive(true) + + self.CurQualityLevel = XQualityManager:GetCurQualitySettings() + self:UpdatePanel() +end + +function XUiPanelGraphicsSet:UpdatePanel() + self.lock = true + + for i, tog in pairs(self.TogQualityGroup) do + tog.isOn = (i - 1) == self.CurQualityLevel + end + + self.lock = false + + self:UpdateByCurrentLevel() +end + +--on close +function XUiPanelGraphicsSet:HidePanel() + XDataCenter.SetManager.SetUiResolutionEventFlag(false) + self.GameObject:SetActive(false) +end + +function XUiPanelGraphicsSet:SetAllInteractable(flag) + for _, tog in pairs(self.TogEffectGroup) do + SetToggleEnable(tog, flag) + end + + for _, tog in pairs(self.TogOtherEffectGroup) do + SetToggleEnable(tog, flag) + end + + for _, tog in pairs(self.TogFrameRateGroup) do + SetToggleEnable(tog, flag) + end + + for _, tog in pairs(self.TogGraphicsGroup) do + SetToggleEnable(tog, flag) + end + + for _, tog in pairs(self.TogMirrorGroup) do + SetToggleEnable(tog, flag) + end + + for _, tog in pairs(self.TogShadowGroup) do + SetToggleEnable(tog, flag) + end + + for _, tog in pairs(self.TogResolutionGroup) do + SetToggleEnable(tog, flag) + end + + for _, tog in pairs(self.TogDistortionGroup) do + SetToggleEnable(tog, flag) + end + + for _, tog in pairs(self.TogBloomGroup) do + SetToggleEnable(tog, flag) + end + + -- SetToggleEnable(self.TogHDR, flag) + -- SetToggleEnable(self.TogFxaa, flag) + -- SetToggleEnable(self.TogHighFrameRate, flag) + -- SetToggleEnable(self.TogDistortion, flag) + +end + +function XUiPanelGraphicsSet:UpdateByCurrentLevel() + + local cQuality = XQualityManager:GetQualitySettings(self.CurQualityLevel) + + CopyCQualitySettings(self.QualitySettings, cQuality) + + if self.CurQualityLevel == 0 then + self:UpdateCustomSettings() + else + self:UpdateDefaultSettings() + end + +end + +--更新自定义设置 +function XUiPanelGraphicsSet:UpdateCustomSettings() + self:SetAllInteractable(true) + self:UpdateContents() +end + +--更新默认设置 +function XUiPanelGraphicsSet:UpdateDefaultSettings() + self:SetAllInteractable(false) + self:UpdateContents() +end + +function XUiPanelGraphicsSet:UpdateContents() + + self.lock = true + + local info = self.QualitySettings + + self.TogHDR.isOn = info.UseHdr + self.TogFxaa.isOn = info.UseFxaa + -- self.TogDistortion.isOn = info.UseDistortion + -- self.TogHighFrameRate.isOn = info.HighFrameRate + for i, tog in pairs(self.TogFrameRateGroup) do + tog.isOn = info.FrameRateLevel == (i - 1) + end + + for i, tog in pairs(self.TogEffectGroup) do + tog.isOn = info.EffectLevel == (i - 1) + end + + for i, tog in pairs(self.TogOtherEffectGroup) do + tog.isOn = info.OtherEffectLevel == (i - 1) + end + + for i, tog in pairs(self.TogGraphicsGroup) do + tog.isOn = info.GraphicsLevel == (i - 1) + end + + for i, tog in pairs(self.TogShadowGroup) do + tog.isOn = info.ShadowLevel == (i - 1) + end + + for i, tog in pairs(self.TogMirrorGroup) do + tog.isOn = info.MirrorLevel == (i - 1) + end + + for i, tog in pairs(self.TogResolutionGroup) do + tog.isOn = info.ResolutionLevel == (i - 1) + end + + for i, tog in pairs(self.TogDistortionGroup) do + tog.isOn = info.DistortionLevel == (i - 1) + end + + for i, tog in pairs(self.TogBloomGroup) do + tog.isOn = info.BloomLevel == (i - 1) + end + + self.lock = false + +end + +--检测是否有数据变动 +function XUiPanelGraphicsSet:CheckDataIsChange() + return self.Dirty +end + +--保存设置 +function XUiPanelGraphicsSet:SaveChange() + XDataCenter.SetManager.SetUiResolutionEventFlag(true) + + if self.CurQualityLevel == 0 then + local c = GetCQualitySettings(self.QualitySettings) + XQualityManager:SetQualitySettings(self.CurQualityLevel, c) + + -- self:SaveCustomQualitySettings() + else + + XQualityManager:SetQualitySettings(self.CurQualityLevel) + end + + self.Dirty = false +end + +--取消保存 +function XUiPanelGraphicsSet:CancelChange() + +end + +--重置到默认配置 +function XUiPanelGraphicsSet:ResetToDefault() + local defaultLevel = XQualityManager:GetDefaultLevel() + self.CurQualityLevel = defaultLevel + + self:UpdatePanel() + self.Dirty = true +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelGraphicsSet:InitAutoScript() + self:AutoInitUi() +end + +function XUiPanelGraphicsSet:AutoInitUi() + self.TogQuality_0 = self.Transform:Find("MainQuality/TGroupAuto/TogQuality_0"):GetComponent("Toggle") + self.SView = self.Transform:Find("SView "):GetComponent("ScrollRect") + self.PanelContent = self.Transform:Find("SView /Viewport/PanelContent") + self.PanelLiangge2 = self.Transform:Find("SView /Viewport/PanelContent/PanelLiangge2") + self.TogDistortion = self.Transform:Find("SView /Viewport/PanelContent/PanelLiangge2/Distortion/TogDistortion"):GetComponent("Toggle") + self.TxtFxaaA = self.Transform:Find("SView /Viewport/PanelContent/PanelLiangge2/Distortion/TxtFxaa"):GetComponent("Text") + self.TogHighFrameRate = self.Transform:Find("SView /Viewport/PanelContent/PanelLiangge2/HighFrameRate/TogHighFrameRate"):GetComponent("Toggle") + self.TxtFxaaB = self.Transform:Find("SView /Viewport/PanelContent/PanelLiangge2/HighFrameRate/TxtFxaa"):GetComponent("Text") + self.TogMirror_2 = self.Transform:Find("SView /Viewport/PanelContent/MirrorLevel/Array/TGroupResolution/TogMirror_2"):GetComponent("Toggle") + self.ImgResStandN = self.Transform:Find("SView /Viewport/PanelContent/MirrorLevel/Array/TGroupResolution/TogMirror_2/ImgResStand"):GetComponent("Image") + self.TxtResStandN = self.Transform:Find("SView /Viewport/PanelContent/MirrorLevel/Array/TGroupResolution/TogMirror_2/TxtResStand"):GetComponent("Text") + self.TogMirror_1 = self.Transform:Find("SView /Viewport/PanelContent/MirrorLevel/Array/TGroupResolution/TogMirror_1"):GetComponent("Toggle") + self.ImgResStandM = self.Transform:Find("SView /Viewport/PanelContent/MirrorLevel/Array/TGroupResolution/TogMirror_1/ImgResStand"):GetComponent("Image") + self.TxtResStandM = self.Transform:Find("SView /Viewport/PanelContent/MirrorLevel/Array/TGroupResolution/TogMirror_1/TxtResStand"):GetComponent("Text") + self.TogMirror_0 = self.Transform:Find("SView /Viewport/PanelContent/MirrorLevel/Array/TGroupResolution/TogMirror_0"):GetComponent("Toggle") + self.ImgResStandL = self.Transform:Find("SView /Viewport/PanelContent/MirrorLevel/Array/TGroupResolution/TogMirror_0/ImgResStand"):GetComponent("Image") + self.TxtResStandL = self.Transform:Find("SView /Viewport/PanelContent/MirrorLevel/Array/TGroupResolution/TogMirror_0/TxtResStand"):GetComponent("Text") + self.TxtResC = self.Transform:Find("SView /Viewport/PanelContent/MirrorLevel/TxtRes"):GetComponent("Text") + self.TogShadow_3 = self.Transform:Find("SView /Viewport/PanelContent/ShadowLevel/Array/TGroupResolution/TogShadow_3"):GetComponent("Toggle") + self.ImgResStandK = self.Transform:Find("SView /Viewport/PanelContent/ShadowLevel/Array/TGroupResolution/TogShadow_3/ImgResStand"):GetComponent("Image") + self.TxtResStandK = self.Transform:Find("SView /Viewport/PanelContent/ShadowLevel/Array/TGroupResolution/TogShadow_3/TxtResStand"):GetComponent("Text") + self.TogShadow_2 = self.Transform:Find("SView /Viewport/PanelContent/ShadowLevel/Array/TGroupResolution/TogShadow_2"):GetComponent("Toggle") + self.ImgResStandJ = self.Transform:Find("SView /Viewport/PanelContent/ShadowLevel/Array/TGroupResolution/TogShadow_2/ImgResStand"):GetComponent("Image") + self.TxtResStandJ = self.Transform:Find("SView /Viewport/PanelContent/ShadowLevel/Array/TGroupResolution/TogShadow_2/TxtResStand"):GetComponent("Text") + self.TogShadow_1 = self.Transform:Find("SView /Viewport/PanelContent/ShadowLevel/Array/TGroupResolution/TogShadow_1"):GetComponent("Toggle") + self.ImgResStandI = self.Transform:Find("SView /Viewport/PanelContent/ShadowLevel/Array/TGroupResolution/TogShadow_1/ImgResStand"):GetComponent("Image") + self.TxtResStandI = self.Transform:Find("SView /Viewport/PanelContent/ShadowLevel/Array/TGroupResolution/TogShadow_1/TxtResStand"):GetComponent("Text") + self.TogShadow_0 = self.Transform:Find("SView /Viewport/PanelContent/ShadowLevel/Array/TGroupResolution/TogShadow_0"):GetComponent("Toggle") + self.ImgResStandH = self.Transform:Find("SView /Viewport/PanelContent/ShadowLevel/Array/TGroupResolution/TogShadow_0/ImgResStand"):GetComponent("Image") + self.TxtResStandH = self.Transform:Find("SView /Viewport/PanelContent/ShadowLevel/Array/TGroupResolution/TogShadow_0/TxtResStand"):GetComponent("Text") + self.TxtResB = self.Transform:Find("SView /Viewport/PanelContent/ShadowLevel/TxtRes"):GetComponent("Text") + self.TogEffect_2 = self.Transform:Find("SView /Viewport/PanelContent/EffectLevel/Array/TGroupResolution/TogEffect_2"):GetComponent("Toggle") + self.ImgResStandG = self.Transform:Find("SView /Viewport/PanelContent/EffectLevel/Array/TGroupResolution/TogEffect_2/ImgResStand"):GetComponent("Image") + self.TxtResStandG = self.Transform:Find("SView /Viewport/PanelContent/EffectLevel/Array/TGroupResolution/TogEffect_2/TxtResStand"):GetComponent("Text") + self.TogEffect_1 = self.Transform:Find("SView /Viewport/PanelContent/EffectLevel/Array/TGroupResolution/TogEffect_1"):GetComponent("Toggle") + self.ImgResStandF = self.Transform:Find("SView /Viewport/PanelContent/EffectLevel/Array/TGroupResolution/TogEffect_1/ImgResStand"):GetComponent("Image") + self.TxtResStandF = self.Transform:Find("SView /Viewport/PanelContent/EffectLevel/Array/TGroupResolution/TogEffect_1/TxtResStand"):GetComponent("Text") + self.TogEffect_0 = self.Transform:Find("SView /Viewport/PanelContent/EffectLevel/Array/TGroupResolution/TogEffect_0"):GetComponent("Toggle") + self.ImgResStandE = self.Transform:Find("SView /Viewport/PanelContent/EffectLevel/Array/TGroupResolution/TogEffect_0/ImgResStand"):GetComponent("Image") + self.TxtResStandE = self.Transform:Find("SView /Viewport/PanelContent/EffectLevel/Array/TGroupResolution/TogEffect_0/TxtResStand"):GetComponent("Text") + self.TxtResA = self.Transform:Find("SView /Viewport/PanelContent/EffectLevel/TxtRes"):GetComponent("Text") + self.TogGraphics_4 = self.Transform:Find("SView /Viewport/PanelContent/GraphicsLevel/Array/TGroupResolution/TogGraphics_4"):GetComponent("Toggle") + self.ImgResStandD = self.Transform:Find("SView /Viewport/PanelContent/GraphicsLevel/Array/TGroupResolution/TogGraphics_4/ImgResStand"):GetComponent("Image") + self.TxtResStandD = self.Transform:Find("SView /Viewport/PanelContent/GraphicsLevel/Array/TGroupResolution/TogGraphics_4/TxtResStand"):GetComponent("Text") + self.TogGraphics_3 = self.Transform:Find("SView /Viewport/PanelContent/GraphicsLevel/Array/TGroupResolution/TogGraphics_3"):GetComponent("Toggle") + self.ImgResStandC = self.Transform:Find("SView /Viewport/PanelContent/GraphicsLevel/Array/TGroupResolution/TogGraphics_3/ImgResStand"):GetComponent("Image") + self.TxtResStandC = self.Transform:Find("SView /Viewport/PanelContent/GraphicsLevel/Array/TGroupResolution/TogGraphics_3/TxtResStand"):GetComponent("Text") + self.TogGraphics_2 = self.Transform:Find("SView /Viewport/PanelContent/GraphicsLevel/Array/TGroupResolution/TogGraphics_2"):GetComponent("Toggle") + self.ImgResStandB = self.Transform:Find("SView /Viewport/PanelContent/GraphicsLevel/Array/TGroupResolution/TogGraphics_2/ImgResStand"):GetComponent("Image") + self.TxtResStandB = self.Transform:Find("SView /Viewport/PanelContent/GraphicsLevel/Array/TGroupResolution/TogGraphics_2/TxtResStand"):GetComponent("Text") + self.TogGraphics_1 = self.Transform:Find("SView /Viewport/PanelContent/GraphicsLevel/Array/TGroupResolution/TogGraphics_1"):GetComponent("Toggle") + self.ImgResStandA = self.Transform:Find("SView /Viewport/PanelContent/GraphicsLevel/Array/TGroupResolution/TogGraphics_1/ImgResStand"):GetComponent("Image") + self.TxtResStandA = self.Transform:Find("SView /Viewport/PanelContent/GraphicsLevel/Array/TGroupResolution/TogGraphics_1/TxtResStand"):GetComponent("Text") + self.TogGraphics_0 = self.Transform:Find("SView /Viewport/PanelContent/GraphicsLevel/Array/TGroupResolution/TogGraphics_0"):GetComponent("Toggle") + self.ImgResStand = self.Transform:Find("SView /Viewport/PanelContent/GraphicsLevel/Array/TGroupResolution/TogGraphics_0/ImgResStand"):GetComponent("Image") + self.TxtResStand = self.Transform:Find("SView /Viewport/PanelContent/GraphicsLevel/Array/TGroupResolution/TogGraphics_0/TxtResStand"):GetComponent("Text") + self.TxtRes = self.Transform:Find("SView /Viewport/PanelContent/GraphicsLevel/TxtRes"):GetComponent("Text") + self.PanelLiangge = self.Transform:Find("SView /Viewport/PanelContent/PanelLiangge") + self.TxtFxaa = self.Transform:Find("SView /Viewport/PanelContent/PanelLiangge/FXAA/TxtFxaa"):GetComponent("Text") + self.TogFxaa = self.Transform:Find("SView /Viewport/PanelContent/PanelLiangge/FXAA/TogFxaa"):GetComponent("Toggle") + self.TxtHDR = self.Transform:Find("SView /Viewport/PanelContent/PanelLiangge/HDR/TxtHDR"):GetComponent("Text") + self.TogHDR = self.Transform:Find("SView /Viewport/PanelContent/PanelLiangge/HDR/TogHDR"):GetComponent("Toggle") + self.TxtResA = self.Transform:Find("SView /Viewport/PanelContent/ResolutionLevel/TxtRes"):GetComponent("Text") + self.TogResolution_0 = self.Transform:Find("SView /Viewport/PanelContent/ResolutionLevel/Array/TGroupResolution/TogResolution_0"):GetComponent("Toggle") + self.ImgResStandE = self.Transform:Find("SView /Viewport/PanelContent/ResolutionLevel/Array/TGroupResolution/TogResolution_0/ImgResStand"):GetComponent("Image") + self.TxtResStandE = self.Transform:Find("SView /Viewport/PanelContent/ResolutionLevel/Array/TGroupResolution/TogResolution_0/TxtResStand"):GetComponent("Text") + self.TogResolution_1 = self.Transform:Find("SView /Viewport/PanelContent/ResolutionLevel/Array/TGroupResolution/TogResolution_1"):GetComponent("Toggle") + self.ImgResStandF = self.Transform:Find("SView /Viewport/PanelContent/ResolutionLevel/Array/TGroupResolution/TogResolution_1/ImgResStand"):GetComponent("Image") + self.TxtResStandF = self.Transform:Find("SView /Viewport/PanelContent/ResolutionLevel/Array/TGroupResolution/TogResolution_1/TxtResStand"):GetComponent("Text") + self.TogResolution_2 = self.Transform:Find("SView /Viewport/PanelContent/ResolutionLevel/Array/TGroupResolution/TogResolution_2"):GetComponent("Toggle") + self.ImgResStandG = self.Transform:Find("SView /Viewport/PanelContent/ResolutionLevel/Array/TGroupResolution/TogResolution_2/ImgResStand"):GetComponent("Image") + self.TxtResStandG = self.Transform:Find("SView /Viewport/PanelContent/ResolutionLevel/Array/TGroupResolution/TogResolution_2/TxtResStand"):GetComponent("Text") + self.TogResolution_3 = self.Transform:Find("SView /Viewport/PanelContent/ResolutionLevel/Array/TGroupResolution/TogResolution_3"):GetComponent("Toggle") + self.ImgResStandH = self.Transform:Find("SView /Viewport/PanelContent/ResolutionLevel/Array/TGroupResolution/TogResolution_3/ImgResStand"):GetComponent("Image") + self.TxtResStandH = self.Transform:Find("SView /Viewport/PanelContent/ResolutionLevel/Array/TGroupResolution/TogResolution_3/TxtResStand"):GetComponent("Text") + self.TogEffect_3 = self.Transform:Find("SView /Viewport/PanelContent/EffectLevel/Array/TGroupResolution/TogEffect_3"):GetComponent("Toggle") + self.ImgResStandP = self.Transform:Find("SView /Viewport/PanelContent/EffectLevel/Array/TGroupResolution/TogEffect_3/ImgResStand"):GetComponent("Image") + self.TxtResStandP = self.Transform:Find("SView /Viewport/PanelContent/EffectLevel/Array/TGroupResolution/TogEffect_3/TxtResStand"):GetComponent("Text") + self.TogMirror_3 = self.Transform:Find("SView /Viewport/PanelContent/MirrorLevel/Array/TGroupResolution/TogMirror_3"):GetComponent("Toggle") + self.ImgResStandT = self.Transform:Find("SView /Viewport/PanelContent/MirrorLevel/Array/TGroupResolution/TogMirror_3/ImgResStand"):GetComponent("Image") + self.TxtResStandT = self.Transform:Find("SView /Viewport/PanelContent/MirrorLevel/Array/TGroupResolution/TogMirror_3/TxtResStand"):GetComponent("Text") + self.TxtResE = self.Transform:Find("SView /Viewport/PanelContent/FrameRateLevel/TxtRes"):GetComponent("Text") + self.TogFrameRate_0 = self.Transform:Find("SView /Viewport/PanelContent/FrameRateLevel/Array/TGroupResolution/TogFrameRate_0"):GetComponent("Toggle") + self.ImgResStandU = self.Transform:Find("SView /Viewport/PanelContent/FrameRateLevel/Array/TGroupResolution/TogFrameRate_0/ImgResStand"):GetComponent("Image") + self.TxtResStandU = self.Transform:Find("SView /Viewport/PanelContent/FrameRateLevel/Array/TGroupResolution/TogFrameRate_0/TxtResStand"):GetComponent("Text") + self.TogFrameRate_1 = self.Transform:Find("SView /Viewport/PanelContent/FrameRateLevel/Array/TGroupResolution/TogFrameRate_1"):GetComponent("Toggle") + self.ImgResStandV = self.Transform:Find("SView /Viewport/PanelContent/FrameRateLevel/Array/TGroupResolution/TogFrameRate_1/ImgResStand"):GetComponent("Image") + self.TxtResStandV = self.Transform:Find("SView /Viewport/PanelContent/FrameRateLevel/Array/TGroupResolution/TogFrameRate_1/TxtResStand"):GetComponent("Text") + self.TogFrameRate_2 = self.Transform:Find("SView /Viewport/PanelContent/FrameRateLevel/Array/TGroupResolution/TogFrameRate_2"):GetComponent("Toggle") + self.ImgResStandW = self.Transform:Find("SView /Viewport/PanelContent/FrameRateLevel/Array/TGroupResolution/TogFrameRate_2/ImgResStand"):GetComponent("Image") + self.TxtResStandW = self.Transform:Find("SView /Viewport/PanelContent/FrameRateLevel/Array/TGroupResolution/TogFrameRate_2/TxtResStand"):GetComponent("Text") + self.TogQuality_5 = self.Transform:Find("MainQuality/TGroupAuto/TogQuality_5"):GetComponent("Toggle") + self.TogQuality_4 = self.Transform:Find("MainQuality/TGroupAuto/TogQuality_4"):GetComponent("Toggle") + self.TogQuality_3 = self.Transform:Find("MainQuality/TGroupAuto/TogQuality_3"):GetComponent("Toggle") + self.TogAuto = self.Transform:Find("MainQuality/TGroupAuto/TogAuto"):GetComponent("Toggle") + self.TogQuality_2 = self.Transform:Find("MainQuality/TGroupAuto/TogQuality_2"):GetComponent("Toggle") + self.TogQuality_1 = self.Transform:Find("MainQuality/TGroupAuto/TogQuality_1"):GetComponent("Toggle") + + +end + +-- auto +function XUiPanelGraphicsSet:OnTogHighFrameRateClick() + +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSet/XUiPanelGraphicsSetPc.lua b/Resources/Scripts/XUi/XUiSet/XUiPanelGraphicsSetPc.lua new file mode 100644 index 00000000..725bd868 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSet/XUiPanelGraphicsSetPc.lua @@ -0,0 +1,143 @@ +---@class XUiPanelGraphicsSetPc +local XUiPanelGraphicsSetPc = XClass(XUiPanelGraphicsSet, 'XUiPanelGraphicsSetPc') + +function XUiPanelGraphicsSetPc:Ctor(ui, parent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self._FullScreen = self:IsFullScreen() + self._Resolution = self:GetCurrentResolution() + self._DropDownDataProvider = false + self._IsDirtyPc = false + self:InitPc() +end + +function XUiPanelGraphicsSetPc:InitPc() + self:InitDropDownResolution() + self:InitToggleFullScreen() + self:UpdateToggle() + self:UpdateDropDownResolution() +end + +function XUiPanelGraphicsSetPc:InitDropDownResolution() + local dataProvider, index = self:GetResolutionArray() + self._DropDownDataProvider = dataProvider + local UnityDropdown = CS.UnityEngine.UI.Dropdown + local dropDown = self.DrdSort + dropDown:ClearOptions() + for i = 1, #self._DropDownDataProvider do + local op = UnityDropdown.OptionData() + local text = self:GetTextResolution(self._DropDownDataProvider[i]) + op.text = text + dropDown.options:Add(op) + end + dropDown.value = index - 1 + dropDown.onValueChanged:AddListener( + function(index) + self._IsDirtyPc = true + -- dropDown从0开始, 故+1 + local resolutionIndex = index + 1 + local size = self._DropDownDataProvider[resolutionIndex] + self._Resolution = size + end + ) +end + +function XUiPanelGraphicsSetPc:InitToggleFullScreen() + self.TogGraphics_0.onValueChanged:AddListener(function() + if self.TogGraphics_0.isOn then + if self._FullScreen ~= true then + self._FullScreen = true + self._IsDirtyPc = true + self:UpdateDropDownResolution() + end + end + end) + self.TogGraphics_1.onValueChanged:AddListener(function() + if self.TogGraphics_1.isOn then + if self._FullScreen ~= false then + self._FullScreen = false + self._IsDirtyPc = true + self:UpdateDropDownResolution() + end + end + end) +end + +function XUiPanelGraphicsSetPc:UpdateToggle() + local isFullScreen = self:IsFullScreen() + self.TGroupResolution:SetAllTogglesOff() + if isFullScreen then + self.TogGraphics_0.isOn = true + else + self.TogGraphics_1.isOn = true + end +end + +function XUiPanelGraphicsSetPc:IsFullScreen() + return CS.UnityEngine.Screen.fullScreen +end + +function XUiPanelGraphicsSetPc:UpdateDropDownResolution() + local isFullScreen = self._FullScreen + local dropDown = self.DrdSort + if isFullScreen then + dropDown.gameObject:SetActiveEx(false) + else + dropDown.gameObject:SetActiveEx(true) + end +end + +function XUiPanelGraphicsSetPc:GetCurrentResolution() + local UnityScreen = CS.UnityEngine.Screen + return { x = UnityScreen.width, y = UnityScreen.height } +end + +function XUiPanelGraphicsSetPc:GetTextResolution(size) + return string.format('%d x %d', size.x, size.y) +end + +function XUiPanelGraphicsSetPc:GetResolutionArray() + local currentSize = self:GetCurrentResolution() + local defaultSizeArray = XDataCenter.UiPcManager.GetTabUiPcResolution() + local defaultSizeIndex = false + for i = 1, #defaultSizeArray do + if defaultSizeArray[i].x == currentSize.x and defaultSizeArray[i].y == currentSize.y then + defaultSizeIndex = i + break + end + end + if not defaultSizeIndex then + defaultSizeIndex = #defaultSizeArray + end + return defaultSizeArray, defaultSizeIndex +end + +function XUiPanelGraphicsSetPc:SetFullScreen(isFullScreen) + if isFullScreen then + local deviceWidth, deviceHeight = XDataCenter.UiPcManager.GetDeviceScreenResolution() + self:SetResolution(deviceWidth, deviceHeight, true) + else + CS.UnityEngine.Screen.fullScreen = isFullScreen + end +end + +function XUiPanelGraphicsSetPc:SetResolution(x, y, isFullScreen) + CS.UnityEngine.Screen.SetResolution(x, y, isFullScreen or false) +end + +function XUiPanelGraphicsSetPc:CheckDataIsChange() + return self._IsDirtyPc or XUiPanelGraphicsSetPc.Super.CheckDataIsChange(self) +end + +function XUiPanelGraphicsSetPc:SaveChange() + XUiPanelGraphicsSetPc.Super.SaveChange(self) + if self._FullScreen then + self:SetFullScreen(true) + else + self:SetResolution(self._Resolution.x, self._Resolution.y) + end + self._IsDirtyPc = false +end + +return XUiPanelGraphicsSetPc diff --git a/Resources/Scripts/XUi/XUiSet/XUiPanelOtherSet.lua b/Resources/Scripts/XUi/XUiSet/XUiPanelOtherSet.lua new file mode 100644 index 00000000..ebc2d276 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSet/XUiPanelOtherSet.lua @@ -0,0 +1,283 @@ +XUiPanelOtherSet = XClass(nil, "XUiPanelOtherSet") +local XUiSafeAreaAdapter = CS.XUiSafeAreaAdapter +local SetConfigs = XSetConfigs +local MaxOff + +function XUiPanelOtherSet:Ctor(ui, parent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Parent = parent + MaxOff = CS.XGame.ClientConfig:GetFloat("SpecialScreenOff") + XTool.InitUiObject(self) + self:InitUi() +end + +function XUiPanelOtherSet:InitUi() + self.TabObs = {} + self.TabObs[1] = self.TogGraphics_0 + self.TabObs[2] = self.TogGraphics_1 + self.TabObs[3] = self.TogGraphics_2 + self.TabObs[4] = self.TogGraphics_3 + self.TGroupResolution:Init( + self.TabObs, + function(tab) + self:TabSkip(tab) + end + ) + + local focusTypes = {} + focusTypes[1] = self.TogFocusType1 + focusTypes[2] = self.TogFocusType2 + self.TGroupFocusType:Init( + focusTypes, + function(index) + self:OnFocusTypeChanged(index) + end + ) + + self.TxtFocusType1.text = CsXTextManagerGetText("FocusType1") + self.TxtFocusType2.text = CsXTextManagerGetText("FocusType2") + + local weaponTransTypes = {} + weaponTransTypes[1] = self.TogWeaponTransType1 + weaponTransTypes[2] = self.TogWeaponTransType2 + self.TGroupWeaponTransType:Init( + weaponTransTypes, + function(index) + self:OnWeaponTransTypeChanged(index) + end + ) + + self.TxtWeaponTransType1.text = CsXTextManagerGetText("WeaponTransType1") + self.TxtWeaponTransType2.text = CsXTextManagerGetText("WeaponTransType2") + + local rechargeTypes = {} + rechargeTypes[1] = self.TogRechargeType1 + rechargeTypes[2] = self.TogRechargeType2 + self.TGroupRechargeType:Init( + rechargeTypes, + function(index) + self:OnRechargeTypeChanged(index) + end + ) + + self.TxtRechargeType1.text = CsXTextManagerGetText("RechargeType1") + self.TxtRechargeType2.text = CsXTextManagerGetText("RechargeType2") + + self:AddListener() + self:ShowAgreement() +end + +function XUiPanelOtherSet:AddListener() + self.OnSliderValueCb = function(value) + self:OnSliderValueChanged(value) + end + self.OnTogFriEffectsValueCb = function(value) + self:OnTogFriEffectsValueChanged(value) + end + self.OnTogFriNumValueCb = function(value) + self:OnTogFriNumValueChanged(value) + end + self.TogFocusButtonCb = function(value) + self:OnTogFocusButtonChanged(value) + end + self.TogOnlineInviteCb = function(value) + self:OnTogOnlineButtonChanged(value) + end + self.Slider.onValueChanged:AddListener(self.OnSliderValueCb) + self.TogFriEffects.onValueChanged:AddListener(self.OnTogFriEffectsValueCb) + self.TogFriNum.onValueChanged:AddListener(self.OnTogFriNumValueCb) + self.TogFocusButton.onValueChanged:AddListener(self.TogFocusButtonCb) + self.TogOnlineInvite.onValueChanged:AddListener(self.TogOnlineInviteCb) +end + +function XUiPanelOtherSet:ShowAgreement() + self.BtnUserAgreement.CallBack = function() + XUiManager.OpenPopWebview(CS.XGame.ClientConfig:GetString("UserAgreementUrl")) + end + self.BtnPrivacyPolicy.CallBack = function() + XUiManager.OpenPopWebview(CS.XGame.ClientConfig:GetString("PrivacyPolicyUrl")) + end +end + +function XUiPanelOtherSet:GetCache() + self.SelfNumState = XSaveTool.GetData(SetConfigs.SelfNum) or SetConfigs.SelfNumEnum.Middle + self.FriendNumState = XSaveTool.GetData(SetConfigs.FriendNum) or SetConfigs.FriendNumEnum.Close + self.FriendEffectEnumState = XSaveTool.GetData(SetConfigs.FriendEffect) or SetConfigs.FriendEffectEnum.Open + self.ScreenOffValue = XSaveTool.GetData(XSetConfigs.ScreenOff) or 0 + self.TGroupResolution:SelectIndex(self.SelfNumState) + self.TogFriEffects.isOn = self.FriendEffectEnumState == SetConfigs.FriendNumEnum.Open + self.TogFriNum.isOn = self.FriendNumState == SetConfigs.FriendNumEnum.Open + local v = tonumber(self.ScreenOffValue) + self.IsFirstSlider = true + self.Slider.value = v + self.SaveSelfNumState = self.SelfNumState + self.SaveFriendNumState = self.FriendNumState + self.SaveFriendEffectEnumState = self.FriendEffectEnumState + self.SaveScreenOffValue = self.ScreenOffValue + self.FocusType = XDataCenter.SetManager.FocusType + self.TGroupFocusType:SelectIndex(self.FocusType) + self.FocusButton = XDataCenter.SetManager.FocusButton + self.InviteButton = XDataCenter.SetManager.InviteButton + self.TogFocusButton.isOn = self.FocusButton == 1 + self.TogOnlineInvite.isOn = self.InviteButton == 1 + self.WeaponTransType = XDataCenter.SetManager.WeaponTransType + self.TGroupWeaponTransType:SelectIndex(self.WeaponTransType) + self.RechargeType = XDataCenter.SetManager.RechargeType + self.TGroupRechargeType:SelectIndex(self.RechargeType) +end + +function XUiPanelOtherSet:TabSkip(tab) + self.CurSelfNumKey = SetConfigs.SelfNumKeyIndexConfig[tab] + self.SelfNumState = tab + if self.IsPassTab then + self.IsPassTab = false + return + end +end + +function XUiPanelOtherSet:ResetToDefault() + self.SelfNumState = SetConfigs.SelfNumEnum.Middle + self.FriendNumState = SetConfigs.FriendNumEnum.Close + self.FriendEffectEnumState = SetConfigs.FriendEffectEnum.Open + self.TogFriEffects.isOn = self.FriendEffectEnumState == SetConfigs.FriendNumEnum.Open + self.TogFriNum.isOn = self.FriendNumState == SetConfigs.FriendNumEnum.Open + self.IsPassTab = true + self.TGroupResolution:SelectIndex(self.SelfNumState) + self.ScreenOffValue = 0 + self.Slider.value = 0 + self.FocusType = SetConfigs.DefaultFocusType + self.TGroupFocusType:SelectIndex(self.FocusType) + self.FocusButton = SetConfigs.DefaultFocusButton + self.TogFocusButton.isOn = self.FocusButton == 1 + self.InviteButton = SetConfigs.DefaultInviteButton + self.TogOnlineInvite.isOn = self.InviteButton == 1 + self.WeaponTransType = SetConfigs.DefaultWeaponTransType + self.TGroupWeaponTransType:SelectIndex(self.WeaponTransType) +end + +function XUiPanelOtherSet:SaveChange() + self.SaveSelfNumState = self.SelfNumState + self.SaveFriendNumState = self.FriendNumState + self.SaveFriendEffectEnumState = self.FriendEffectEnumState + self.SaveScreenOffValue = self.ScreenOffValue + + XDataCenter.SetManager.SaveSelfNum(self.SelfNumState) + XDataCenter.SetManager.SaveFriendNum(self.FriendNumState) + XDataCenter.SetManager.SaveFriendEffect(self.FriendEffectEnumState) + XDataCenter.SetManager.SaveScreenOff(self.ScreenOffValue) + + XDataCenter.SetManager.SetOwnFontSizeByTab(self.SelfNumState) + XDataCenter.SetManager.SetAllyDamage(self.FriendNumState == SetConfigs.FriendNumEnum.Open) + XDataCenter.SetManager.SetAllyEffect(self.FriendEffectEnumState == SetConfigs.FriendEffectEnum.Open) + + XDataCenter.SetManager.SetFocusType(self.FocusType) + XDataCenter.SetManager.SetFocusButtonActive(self.FocusButton == 1) + XDataCenter.SetManager.SetInviteButtonActive(self.InviteButton == 1) + XDataCenter.SetManager.SetWeaponTransType(self.WeaponTransType) + XDataCenter.SetManager.SetRechargeType(self.RechargeType) +end + +function XUiPanelOtherSet:CheckDataIsChange() + return self.SaveSelfNumState ~= self.SelfNumState or self.SaveFriendNumState ~= self.FriendNumState or + self.SaveFriendEffectEnumState ~= self.FriendEffectEnumState or + self.SaveScreenOffValue ~= self.ScreenOffValue or + self.FocusType ~= XDataCenter.SetManager.FocusType or + self.FocusButton ~=XDataCenter.SetManager.FocusButton or + self.InviteButton ~=XDataCenter.SetManager.InviteButton or + self.WeaponTransType ~= XDataCenter.SetManager.WeaponTransType +end + +function XUiPanelOtherSet:CancelChange() + self.ScreenOffValue = self.SaveScreenOffValue + self:SetSliderValueChanged(self.SaveScreenOffValue) +end + +function XUiPanelOtherSet:OnSliderValueChanged(value) + if value < 0 then + return + end + + if self.IsFirstSlider then + self.IsFirstSlider = false + return + end + self.ScreenOffValue = value + self:SetSliderValueChanged(value) + XDataCenter.SetManager.SetAdaptorScreenChange() +end + +function XUiPanelOtherSet:SetSliderValueChanged(value) + local v = tonumber(value) + XUiSafeAreaAdapter.SetSpecialScreenOff(v * MaxOff) + if self.Parent then + self.Parent:UpdateSpecialScreenOff() + end +end + +function XUiPanelOtherSet:OnTogFriEffectsValueChanged(value) + local v = SetConfigs.FriendEffectEnum.Close + if value then + v = SetConfigs.FriendEffectEnum.Open + end + self.FriendEffectEnumState = v +end + +function XUiPanelOtherSet:OnTogFriNumValueChanged(value) + local v = SetConfigs.FriendNumEnum.Close + if value then + v = SetConfigs.FriendNumEnum.Open + end + self.FriendNumState = v +end + +function XUiPanelOtherSet:OnTogFocusButtonChanged(value) + self.FocusButton = value and 1 or 0 +end + +function XUiPanelOtherSet:OnTogOnlineButtonChanged(value) + self.InviteButton = value and 1 or 0 +end + +function XUiPanelOtherSet:OnFocusTypeChanged(index) + if index == 0 then + return + end + self.FocusType = index + self.DescriptionFocusType1.gameObject:SetActiveEx(index == 1) + self.DescriptionFocusType2.gameObject:SetActiveEx(index == 2) + self.TogFocusButton.gameObject:SetActiveEx(index == 2) +end + +function XUiPanelOtherSet:OnWeaponTransTypeChanged(index) + if index == 0 then + return + end + self.WeaponTransType = index + self.DescriptionWeaponTransType1.gameObject:SetActiveEx(index == 1) + self.DescriptionWeaponTransType2.gameObject:SetActiveEx(index == 2) +end + +function XUiPanelOtherSet:OnRechargeTypeChanged(index) + if index == 0 then + return + end + self.RechargeType = index + self.DescriptionRechargeType1.gameObject:SetActiveEx(index == 1) + self.DescriptionRechargeType2.gameObject:SetActiveEx(index == 2) +end + +function XUiPanelOtherSet:ShowPanel() + self.GameObject:SetActive(true) + if self.Parent then + self.Adaptation.gameObject:SetActiveEx(not self.Parent.IsFight) + end + self:GetCache() + self.IsShow = true +end + +function XUiPanelOtherSet:HidePanel() + self.IsShow = false + self.GameObject:SetActive(false) +end +return XUiPanelOtherSet \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSet/XUiPanelOtherSetPc.lua b/Resources/Scripts/XUi/XUiSet/XUiPanelOtherSetPc.lua new file mode 100644 index 00000000..308da7fe --- /dev/null +++ b/Resources/Scripts/XUi/XUiSet/XUiPanelOtherSetPc.lua @@ -0,0 +1,80 @@ +local XUiPanelOtherSet = require("XUi/XUiSet/XUiPanelOtherSet") +local XUiPanelOtherSetPc = XClass(XUiPanelOtherSet, "XUiPanelOtherSetPc") +local XInputManager = CS.XInputManager + +function XUiPanelOtherSetPc:Ctor() + self._IsShowFPS = CS.XInputManager.GetFPSActive() + self._IsShowJoystick = CS.XInputManager.GetJoystickActive() + self._IsShowFightButton = CS.XInputManager.GetKeyCodeTipActive() + self._IsShowSystemButton = false + self._IsDirtyPc = false + self:InitPc() +end + +function XUiPanelOtherSetPc:InitPc() + self.TogFPS.isOn = self._IsShowFPS + self.TogJoystick.isOn = self._IsShowJoystick + self.TogFightButton.isOn = self._IsShowFightButton + self.TogSystemButton.isOn = self._IsShowSystemButton + self.TogFPS.onValueChanged:AddListener(handler(self, self.OnTogFPSValueChanged)) + self.TogJoystick.onValueChanged:AddListener(handler(self, self.OnTogJoystickValueChanged)) + self.TogFightButton.onValueChanged:AddListener(handler(self, self.OnTogFightButtonValueChanged)) + self.TogSystemButton.onValueChanged:AddListener(handler(self, self.OnTogSystemButtonChanged)) +end + +function XUiPanelOtherSetPc:OnTogFPSValueChanged(value) + if self._IsShowFPS ~= value then + self._IsShowFPS = value + self._IsDirtyPc = true + end +end + +function XUiPanelOtherSetPc:OnTogJoystickValueChanged(value) + if self._IsShowJoystick ~= value then + self._IsShowJoystick = value + self._IsDirtyPc = true + end +end + +function XUiPanelOtherSetPc:OnTogFightButtonValueChanged(value) + if self._IsShowFightButton ~= value then + self._IsShowFightButton = value + self._IsDirtyPc = true + end +end + +function XUiPanelOtherSetPc:OnTogSystemButtonChanged(value) + if self._IsShowSystemButton ~= value then + self._IsShowSystemButton = value + self._IsDirtyPc = true + end +end + +function XUiPanelOtherSetPc:SaveChange() + XUiPanelOtherSetPc.Super.SaveChange(self) + self._IsDirtyPc = false + CS.XInputManager.SetFPSActive(self._IsShowFPS) + CS.XInputManager.SetJoystickActive(self._IsShowJoystick) + CS.XInputManager.SetKeyCodeTipActive(self._IsShowFightButton) +end + +function XUiPanelOtherSetPc:CheckDataIsChange() + return self._IsDirtyPc or XUiPanelOtherSetPc.Super.CheckDataIsChange(self) +end + +function XUiPanelOtherSetPc:ResetToDefault() + XUiPanelOtherSetPc.Super.ResetToDefault(self) + self._IsShowFPS = CS.XInputManager.DEFAULT_KEYCODE_TIP_ACTIVE == 1 + self._IsShowJoystick = CS.XInputManager.DEFAULT_JOYSTICK_ACTIVE == 1 + self._IsShowFightButton = CS.XInputManager.DEFAULT_FPS_ACTIVE == 1 + self._IsShowSystemButton = false + self.TogFPS.isOn = self._IsShowFPS + self.TogJoystick.isOn = self._IsShowJoystick + self.TogFightButton.isOn = self._IsShowFightButton + self.TogSystemButton.isOn = self._IsShowSystemButton + CS.XInputManager.SetFPSActive(self._IsShowFPS) + CS.XInputManager.SetJoystickActive(self._IsShowJoystick) + CS.XInputManager.SetKeyCodeTipActive(self._IsShowFightButton) +end + +return XUiPanelOtherSetPc \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSet/XUiPanelPushSet.lua b/Resources/Scripts/XUi/XUiSet/XUiPanelPushSet.lua new file mode 100644 index 00000000..c6e1c7d3 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSet/XUiPanelPushSet.lua @@ -0,0 +1,112 @@ +XUiPanelPushSet = XClass(nil, "XUiPanelPushSet") + +function XUiPanelPushSet:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self:InitAutoScript() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelPushSet:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiPanelPushSet:AutoInitUi() + self.TogFullHP = self.Transform:Find("FullHP/TogFullHP"):GetComponent("Toggle") + self.TogDonateHP = self.Transform:Find("DonateHP/TogDonateHP"):GetComponent("Toggle") + self.TogHouseUpdate = self.Transform:Find("HouseUpdate/TogHouseUpdate"):GetComponent("Toggle") + self.TogWorkCom = self.Transform:Find("WorkComp/TogWorkCom"):GetComponent("Toggle") + self.TogDispatchBack = self.Transform:Find("DispatchBack/TogDispatchBack"):GetComponent("Toggle") +end + +function XUiPanelPushSet:GetAutoKey(uiNode,eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiPanelPushSet:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiPanelPushSet:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key],eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiPanelPushSet:AutoAddListener() + self.AutoCreateListeners = {} + self:RegisterListener(self.TogFullHP, "onValueChanged", self.OnTogFullHPValueChanged) + self:RegisterListener(self.TogDonateHP, "onValueChanged", self.OnTogDonateHPValueChanged) + self:RegisterListener(self.TogHouseUpdate, "onValueChanged", self.OnTogHouseUpdateValueChanged) + self:RegisterListener(self.TogWorkCom, "onValueChanged", self.OnTogWorkComValueChanged) + self:RegisterListener(self.TogDispatchBack, "onValueChanged", self.OnTogDispatchBackValueChanged) +end +-- auto + +function XUiPanelPushSet:OnTogFullHPValueChanged() + +end + +function XUiPanelPushSet:OnTogDonateHPValueChanged() + +end + +function XUiPanelPushSet:OnTogHouseUpdateValueChanged() + +end + +function XUiPanelPushSet:OnTogWorkComValueChanged() + +end + +function XUiPanelPushSet:OnTogDispatchBackValueChanged() + +end + +function XUiPanelPushSet:OnToggleEValueChanged() + +end + +function XUiPanelPushSet:ShowPanel() + self.IsShow = true + self.GameObject:SetActive(true) +end + +function XUiPanelPushSet:HidePanel() + self.IsShow = false + self.GameObject:SetActive(false) +end + +function XUiPanelPushSet:CheckDataIsChange() + + return false +end + +function XUiPanelPushSet:SaveChange() + +end + +function XUiPanelPushSet:CancelChange() + +end + +function XUiPanelPushSet:ResetToDefault() + +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSet/XUiPanelVoiceSet.lua b/Resources/Scripts/XUi/XUiSet/XUiPanelVoiceSet.lua new file mode 100644 index 00000000..8b2a66c8 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSet/XUiPanelVoiceSet.lua @@ -0,0 +1,251 @@ +XUiPanelVoiceSet = XClass(nil, "XUiPanelVoiceSet") + +function XUiPanelVoiceSet:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.MyColor = CS.UnityEngine.Color() + self:InitPanelData() + self:SetPanel() + self:AddListener() +end + +function XUiPanelVoiceSet:AddListener() + + XUiHelper.RegisterClickEvent(self, self.TogRiwen, self.OnLanguageClick) + XUiHelper.RegisterClickEvent(self, self.TogZhongWen, self.OnLanguageClick) + XUiHelper.RegisterClickEvent(self, self.TogXiangGang, self.OnLanguageClick) + XUiHelper.RegisterClickEvent(self, self.TogControl, self.OnTogControlClick) + + XUiHelper.RegisterSliderChangeEvent(self, self.SliMusic, self.OnSliMusicValueChanged) + XUiHelper.RegisterSliderChangeEvent(self, self.SliSound, self.OnSliSoundValueChanged) + XUiHelper.RegisterSliderChangeEvent(self, self.SliCv, self.OnSliCvValueChanged) + + XUiHelper.RegisterClickEvent(self, self.BtnCanDown, self.OnBtnCanDownClick) + XUiHelper.RegisterClickEvent(self, self.BtnDownload, self.OnBtnDownloadClick) + XUiHelper.RegisterClickEvent(self, self.BtnUpdate, self.OnBtnUpdateClick) +end + +function XUiPanelVoiceSet:OnLanguageClick() + if (self.TogRiwen.isOn) then + self.NewCvType = 1 + elseif (self.TogZhongWen.isOn) then + self.NewCvType = 2 + elseif (self.TogXiangGang.isOn) then + self.NewCvType = 3 + end + CS.XAudioManager.CvType = self.NewCvType +end + +function XUiPanelVoiceSet:OnTogControlClick() + self:SetTogControl(self.TogControl.isOn) + if (self.TogControl.isOn) then + self.NewControl = 1 + else + self.NewControl = 2 + end + self:SetVolume() +end + +function XUiPanelVoiceSet:SetTogControl(IsOn) + if (IsOn) then + self:ChangeObjsTansparent(1.0) + else + self:ChangeObjsTansparent(0.5) + end + self.SliMusic.interactable = IsOn + self.SliSound.interactable = IsOn + self.SliCv.interactable = IsOn +end + + +function XUiPanelVoiceSet:OnSliDownloadValueChanged() + +end + +function XUiPanelVoiceSet:OnBtnCanDownClick() + +end + +function XUiPanelVoiceSet:OnBtnDownloadClick() + +end + +function XUiPanelVoiceSet:OnBtnUpdateClick() + +end + +function XUiPanelVoiceSet:OnSliMusicValueChanged() + self.NewMusicVolume = self.SliMusic.value + CS.XAudioManager.ChangeMusicVolume(self.SliMusic.value) +end + +function XUiPanelVoiceSet:OnSliSoundValueChanged() + self.NewSoundVolume = self.SliSound.value + CS.XAudioManager.ChangeSoundVolume(self.SliSound.value) +end + +function XUiPanelVoiceSet:OnSliCvValueChanged() + self.NewCvVolume = self.SliCv.value + CS.XAudioManager.ChangeCvVolume(self.SliCv.value) +end + +function XUiPanelVoiceSet:InitPanelData() + self.CvType = CS.XAudioManager.CvType + self.MusicVolume = CS.XAudioManager.MusicVolume + self.SoundVolume = CS.XAudioManager.SoundVolume + self.CvVolume = CS.XAudioManager.CvVolume + self.Control = CS.XAudioManager.Control + self.NewCvType = self.CvType + self.NewCvVolume = self.CvVolume + self.NewMusicVolume = self.MusicVolume + self.NewSoundVolume = self.SoundVolume + self.NewControl = self.Control + self.Yuyan = self.Transform:Find("Yuyanshez") + self.TogXiangGang = self.Yuyan:Find("Array/TGroup/TogXiangGang") + + self.TogXiangGang.gameObject:SetActiveEx(false) +end + +function XUiPanelVoiceSet:ResetPanelData() + CS.XAudioManager.ResetToDefault() + self.NewCvType = CS.XAudioManager.CvType + self.NewCvVolume = CS.XAudioManager.CvVolume + self.NewMusicVolume = CS.XAudioManager.MusicVolume + self.NewSoundVolume = CS.XAudioManager.SoundVolume + self.NewControl = CS.XAudioManager.Control +end + +function XUiPanelVoiceSet:SetPanel() + self:SetVolume() + self:SetTogControl(self.TogControl.isOn) + + self.SliMusic.value = self.NewMusicVolume + self.SliSound.value = self.NewSoundVolume + self.SliCv.value = self.NewCvVolume + + if (self.NewCvType == 1) then + self.TogRiwen.isOn = true + elseif (self.NewCvType == 2) then + self.TogZhongWen.isOn = true + elseif (self.NewCvType == 3) then + self.TogXiangGang.isOn = true + end +end + +function XUiPanelVoiceSet:SetVolume() + local XAManager = CS.XAudioManager + if (self.NewControl == 2) then + self.TogControl.isOn = false + XAManager.ChangeMusicVolume(0) + XAManager.ChangeSoundVolume(0) + XAManager.ChangeCvVolume(0) + else + self.TogControl.isOn = true + XAManager.ChangeMusicVolume(self.NewMusicVolume) + XAManager.ChangeSoundVolume(self.NewSoundVolume) + XAManager.ChangeCvVolume(self.NewCvVolume) + end +end + +function XUiPanelVoiceSet:ShowPanel() + self.IsShow = true + self.GameObject:SetActive(true) + self.Transform:Find("Yuyanbao").gameObject:SetActive(false) + + self:InitPanelData() + self:SetPanel() + -- if (self:CheckNeedDownloadSource()==0) then + -- -- self.BtnCanDown.gameObject:SetActive(false) + -- -- self.BtnDownloaded.gameObject:SetActive(true) + -- -- self.PanelDownload.gameObject:SetActive(false) + + -- self.BtnCanDown.gameObject:SetActive(false) + -- self.BtnDownloaded.gameObject:SetActive(false) + -- self.PanelDownload.gameObject:SetActive(false) + + -- end +end + +function XUiPanelVoiceSet:CheckNeedDownloadSource() + return 0 +end + +function XUiPanelVoiceSet:HidePanel() + self.IsShow = false + self.GameObject:SetActive(false) +end + +function XUiPanelVoiceSet:CheckDataIsChange() + if (self.NewCvType ~= self.CvType) then + return true + end + if (self.NewCvVolume ~= self.CvVolume) then + return true + end + if (self.NewMusicVolume ~= self.MusicVolume) then + return true + end + if (self.NewSoundVolume ~= self.SoundVolume) then + return true + end + if (self.NewControl ~= self.Control) then + return true + end + + return false +end + +function XUiPanelVoiceSet:SaveChange() + -- local XAManager = CS.XAudioManager + self.CvType = self.NewCvType + self.MusicVolume = self.NewMusicVolume + self.SoundVolume = self.NewSoundVolume + self.CvVolume = self.NewCvVolume + self.Control = self.NewControl + self:SaveAudioManagerData() +end + +function XUiPanelVoiceSet:CancelChange() + self.NewCvType = self.CvType + self.NewCvVolume = self.CvVolume + self.NewMusicVolume = self.MusicVolume + self.NewSoundVolume = self.SoundVolume + self.NewControl = self.Control + self:SetVolume() + self:SaveAudioManagerData() +end + +function XUiPanelVoiceSet:SaveAudioManagerData() + local XAManager = CS.XAudioManager + XAManager.CvType = self.NewCvType + XAManager.MusicVolume = self.NewMusicVolume + XAManager.SoundVolume = self.NewSoundVolume + XAManager.CvVolume = self.NewCvVolume + XAManager.Control = self.NewControl + XAManager.SaveChange() +end + +function XUiPanelVoiceSet:ResetToDefault() + self:ResetPanelData() + self:SetPanel() +end + +function XUiPanelVoiceSet:ChangeObjsTansparent(alpha) + self.MyColor.a = alpha + + self.TxtMusic.color = self.MyColor + self.ImgMusicON.color = self.MyColor + self.ImgMusicOFF.color = self.MyColor + self.ImgMusicFill.color = self.MyColor + + self.TxtSound.color = self.MyColor + self.ImgSoundON.color = self.MyColor + self.ImgSoundOFF.color = self.MyColor + self.ImgSoundFill.color = self.MyColor + + self.TxtYinliang.color = self.MyColor + self.ImgYinliangON.color = self.MyColor + self.ImgYinliangOFF.color = self.MyColor + self.ImgYinliangFill.color = self.MyColor +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSet/XUiSet.lua b/Resources/Scripts/XUi/XUiSet/XUiSet.lua new file mode 100644 index 00000000..d3a0fda4 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSet/XUiSet.lua @@ -0,0 +1,443 @@ +local XUiInstructionMonster = require("XUi/XUiSet/XUiInstructionMonster") +local XUiPanelGraphicsSetPc = require("XUi/XUiSet/XUiPanelGraphicsSetPc") +local XUiPanelOtherSetPc = require("XUi/XUiSet/XUiPanelOtherSetPc") +local XUiPanelFightSetPc = require("XUi/XUiSet/XUiPanelFightSetPc") +local XUiCombatTask = require("XUi/XUiSet/XUiCombatTask") + +local XUiSet = XLuaUiManager.Register(XLuaUi, "UiSet") + +local PANEL_INDEX = { + CombatTask = 1, + Instruction = 2, + Sound = 3, + Graphics = 4, + Fight = 5, + Push = 6, + Other = 8, + Account = 7, +} + +local CLICK_INTERVAL = 0.3 -- 点击间隔 +local MULTI_CLICK_COUNT_LIMIT = 5 -- 最大点击数 + +function XUiSet:OnAwake() + XTool.InitUiObject(self) + self.BtnRestart.CallBack = function() self:OnBtnRestart() end + self.BtnDefault.CallBack = function() self:OnBtnDefaultClick() end + self.BtnSave.CallBack = function() self:OnBtnSaveClick() end + self.BtnRetreat.CallBack = function() self:OnBtnRetreat() end + self.BtnInfoTip.CallBack = function() self:OnBtnInfoTip() end + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + + local multiClickHelper = require("XUi/XUiCommon/XUiMultClickHelper").New(self, CLICK_INTERVAL, MULTI_CLICK_COUNT_LIMIT) + self.MultiClickHelper = multiClickHelper +end + +function XUiSet:OnNotify(evt, ...) + if evt == XEventId.EVENT_FIGHT_FINISH then + self:Close() + elseif self.CurShowIndex == PANEL_INDEX.Fight and evt == CS.XEventId.EVENT_CUSTOM_UI_SCHEME_CHANGED then + -- 由于C#派发的事件无法触发红点系统绑定的监听,因此需要作出转换 + XEventManager.DispatchEvent(XEventId.EVENT_CUSTOM_UI_SCHEME_CHANGED) + end +end + +function XUiSet:OnGetEvents() + return { XEventId.EVENT_FIGHT_FINISH, CS.XEventId.EVENT_CUSTOM_UI_SCHEME_CHANGED } +end + +function XUiSet:OnStart(isFight, panelIndex) + self.IsFight = isFight + --区分战斗中设置和主页面设置内容 + if self.IsFight then + self.BtnMainUi.gameObject:SetActiveEx(false) + self.PanelAsset.gameObject:SetActiveEx(false) + self.BtnGraphics.gameObject:SetActiveEx(false) + self.BtnAccount.gameObject:SetActiveEx(false) + self.BtnInstruction.gameObject:SetActiveEx(true) + self.BtnInfoTip.gameObject:SetActiveEx(false) + self.BtnCombatTask.gameObject:SetActiveEx(CS.XFight.IsCombatTaskActivate) + else + self.BtnMainUi.gameObject:SetActiveEx(true) + self.PanelAsset.gameObject:SetActiveEx(true) + self.BtnGraphics.gameObject:SetActiveEx(true) + self.BtnAccount.gameObject:SetActiveEx(true) + self.BtnInstruction.gameObject:SetActiveEx(false) + self.BtnRetreat.gameObject:SetActiveEx(false) + self.BtnInfoTip.gameObject:SetActiveEx(true) + self.BtnCombatTask.gameObject:SetActiveEx(false) + end + + if self.IsFight then + if CS.XFight.IsRunning then + CS.XFight.Instance:Pause() + XDataCenter.FightWordsManager.Pause() + end + -- int index = CS.XFight.GetClientRole().Npc.Index; + -- Portraits[index].Select(); + -- XUiAnimationManager.PlayUi(Ui, ANIM_BEGIN, null, null); + -- TxtScheme.text = XCustomUi.Instance.SchemeName; + end + + self.IsStartAnimCommon = true + self.IsStartAnimOther = true + self.SubPanels = {} + if not self.IsFight then + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + end + local tabGroup = { + [PANEL_INDEX.CombatTask] = self.BtnCombatTask, + [PANEL_INDEX.Instruction] = self.BtnInstruction, + [PANEL_INDEX.Sound] = self.BtnVoice, + [PANEL_INDEX.Graphics] = self.BtnGraphics, + [PANEL_INDEX.Fight] = self.BtnFight, + [PANEL_INDEX.Push] = self.BtnPush, + [PANEL_INDEX.Other] = self.BtnOther, + [PANEL_INDEX.Account] = self.BtnAccount + } + self.PanelTabToggles:Init(tabGroup, function(index) self:SwitchSubPanel(index) end) + local defaultIndex + if self.IsFight then + if CS.XFight.IsCombatTaskActivate then + defaultIndex = panelIndex or PANEL_INDEX.CombatTask + else + defaultIndex = panelIndex or PANEL_INDEX.Instruction + end + else + defaultIndex = panelIndex or PANEL_INDEX.Sound + end + self.PanelTabToggles:SelectIndex(defaultIndex) + self.TipTitle = CS.XTextManager.GetText("TipTitle") + self.TipContent = CS.XTextManager.GetText("SettingCheckSave") + + XRedPointManager.AddRedPointEvent(self.BtnFight, self.OnCheckFightSetNews, self, { XRedPointConditions.Types.CONDITION_MAIN_SET }) +end + +--战斗页签红点(自定义按键冲突) +function XUiSet:OnCheckFightSetNews(count) + self.BtnFight:ShowReddot(count >= 0) +end + +function XUiSet:OnDestroy() + if self.SubPanels[PANEL_INDEX.Fight] then + self.SubPanels[PANEL_INDEX.Fight]:OnDestroy() + end + + if self.Timer ~= nil then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end + + if self.MultiClickHelper then + self.MultiClickHelper:OnDestroy() + end + + --子panel中如果有event事件,不清除会有问题 + --每次打开Account,都会重新生成子panel + if self.SubPanels[PANEL_INDEX.Account] then + self.SubPanels[PANEL_INDEX.Account]:OnDestroy() + end +end + +function XUiSet:OnDisable() + if self.CurShowIndex and self.SubPanels[self.CurShowIndex] then + self.SubPanels[self.CurShowIndex]:HidePanel() + end + if self.IsFight then + if CS.XFight.IsRunning then + CS.XFight.Instance:Resume() + XDataCenter.FightWordsManager.Resume() + end + end + + if self.Timer ~= nil then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end + + if self.MultiClickHelper then + self.MultiClickHelper:OnDisable() + end +end + +function XUiSet:OnEnable() + if self.MultiClickHelper then + self.MultiClickHelper:OnEnable() + end + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end + self.Timer = XScheduleManager.ScheduleForever(function() + if self.MultiClickHelper then + local dt = CS.UnityEngine.Time.deltaTime + self.MultiClickHelper:Update(dt) + end + end, 0) + + if self.CurShowIndex and self.SubPanels[self.CurShowIndex] then + self.SubPanels[self.CurShowIndex]:ShowPanel() + end +end + +function XUiSet:OnBtnSaveClick() + self:Save() + XUiManager.TipText("SettingSave") +end + +function XUiSet:OnBtnRetreat() + local title = CS.XTextManager.GetText("TipTitle") + local content = CS.XTextManager.GetText("FightExitMsg") + local confirmCb = function() + if CS.XFight.IsRunning then + CS.XFight.Instance.AutoExitFight = true + CS.XFight.Instance:Exit(true) + end + self:Close() + end + XUiManager.DialogTip(title, content, XUiManager.DialogType.Normal, nil, confirmCb) +end + +function XUiSet:OnBtnRestart() + local title = CS.XTextManager.GetText("TipTitle") + local content = CS.XTextManager.GetText("FightRestartMsg") + local cb = function() + self:Close() + XLuaUiManager.Open("UiLoading", LoadingType.Fight) + end + local confirmCb = function() + if CS.XFight.IsRunning then + CS.XFight.Instance:Restart(cb) + XDataCenter.FightWordsManager.Stop(true) + end + end + XUiManager.DialogTip(title, content, XUiManager.DialogType.Normal, nil, confirmCb) +end + +function XUiSet:OnBtnDefaultClick() + self.SubPanels[self.SelectedIndex]:ResetToDefault() +end + +function XUiSet:OnBtnBackClick() + self:CheckSave(function() + self:Close() + end) +end + +function XUiSet:OnBtnMainUiClick() + self:CheckSave(function() + XLuaUiManager.RunMain() + end) +end + +function XUiSet:OnBtnInfoTip() + self.MultiClickHelper:Click() +end + +function XUiSet:OnBtnUserAgreement() + XUiManager.OpenPopWebview(CS.XGame.ClientConfig:GetString("UserAgreementUrl")) +end + +function XUiSet:OnBtnPrivacyPolicy() + XUiManager.OpenPopWebview(CS.XGame.ClientConfig:GetString("PrivacyPolicyUrl")) +end + +--多点回调 +function XUiSet:OnMultClick(clickTimes) + if clickTimes >= MULTI_CLICK_COUNT_LIMIT then + local content = CS.XInfo.Identifier + XUiManager.UiFubenDialogTip("信息提示", content); + end +end + +function XUiSet:InitSubPanel(index) + if index == PANEL_INDEX.CombatTask then + if self.PanelCombatTaskObj == nil then + self.PanelCombatTaskObj = self.PanelCombatTask:LoadPrefab(XUiConfigs.GetComponentUrl("UiSetCombatTask")) + end + self.SubPanels[PANEL_INDEX.CombatTask] = XUiCombatTask.New(self.PanelCombatTaskObj) + elseif index == PANEL_INDEX.Instruction then + + --口袋妖怪怪物类型战中设置特殊处理 + local role = CS.XFight.GetActivateClientRole() + local isMonsterFight = role and role.RoleData.CustomNpc ~= nil + if isMonsterFight then + + local monsterUi = self.PanelInstruction:LoadPrefab(XUiConfigs.GetComponentUrl("UiSetPanelInstructionMonster")) + self.SubPanels[PANEL_INDEX.Instruction] = XUiInstructionMonster.New(monsterUi) + + else + + if self.PanelInstructionObj == nil then + self.PanelInstructionObj = self.PanelInstruction:LoadPrefab(XUiConfigs.GetComponentUrl("UiSetPanelInstruction")) + end + self.SubPanels[PANEL_INDEX.Instruction] = XUiInstruction.New(self.PanelInstructionObj) + + end + + elseif index == PANEL_INDEX.Sound then + if self.PanelVoiceSetObj == nil then + self.PanelVoiceSetObj = self.PanelVoiceSet:LoadPrefab(XUiConfigs.GetComponentUrl("UiSetPanelVoiceSet")) + end + self.SubPanels[PANEL_INDEX.Sound] = XUiPanelVoiceSet.New(self.PanelVoiceSetObj, self) + elseif index == PANEL_INDEX.Graphics then + if self.PanelGraphicsSetObj == nil then + if XDataCenter.UiPcManager.IsPc() then + self.PanelGraphicsSetObj = self.PanelGraphicsSet:LoadPrefab(XUiConfigs.GetComponentUrl("UiSetPanelGraphicsSetPC")) + else + self.PanelGraphicsSetObj = self.PanelGraphicsSet:LoadPrefab(XUiConfigs.GetComponentUrl("UiSetPanelGraphicsSet")) + end + end + if XDataCenter.UiPcManager.IsPc() then + self.SubPanels[PANEL_INDEX.Graphics] = XUiPanelGraphicsSetPc.New(self.PanelGraphicsSetObj, self) + else + self.SubPanels[PANEL_INDEX.Graphics] = XUiPanelGraphicsSet.New(self.PanelGraphicsSetObj, self) + end + elseif index == PANEL_INDEX.Fight then + if self.PanelFightSetObj == nil then + if XDataCenter.UiPcManager.IsPc() then + self.PanelFightSetObj = self.PanelFightSet:LoadPrefab(XUiConfigs.GetComponentUrl("UiSetPanelFightSetPC")) + else + self.PanelFightSetObj = self.PanelFightSet:LoadPrefab(XUiConfigs.GetComponentUrl("UiSetPanelFightSet")) + end + end + if XDataCenter.UiPcManager.IsPc() then + self.SubPanels[PANEL_INDEX.Fight] = XUiPanelFightSetPc.New(self.PanelFightSetObj, self) + else + self.SubPanels[PANEL_INDEX.Fight] = XUiPanelFightSet.New(self.PanelFightSetObj, self) + end + elseif index == PANEL_INDEX.Push then + if self.PanelPushSetObj == nil then + self.PanelPushSetObj = self.PanelPushSet:LoadPrefab(XUiConfigs.GetComponentUrl("UiSetPanelPushSet")) + end + self.SubPanels[PANEL_INDEX.Push] = XUiPanelPushSet.New(self.PanelPushSetObj, self) + elseif index == PANEL_INDEX.Other then + if self.PanelOtherObj == nil then + if XDataCenter.UiPcManager.IsPc() then + self.PanelOtherObj = self.PanelOther:LoadPrefab(XUiConfigs.GetComponentUrl("UiSetPanelOtherPC")) + else + self.PanelOtherObj = self.PanelOther:LoadPrefab(XUiConfigs.GetComponentUrl("UiSetPanelOther")) + end + end + if XDataCenter.UiPcManager.IsPc() then + self.SubPanels[PANEL_INDEX.Other] = XUiPanelOtherSetPc.New(self.PanelOtherObj, self) + else + self.SubPanels[PANEL_INDEX.Other] = XUiPanelOtherSet.New(self.PanelOtherObj, self) + end + elseif index == PANEL_INDEX.Account then + if self.PanelAccountObj == nil then + self.PanelAccountObj = self.PanelAccountSet:LoadPrefab(XUiConfigs.GetComponentUrl("UiSetPanelAccount")) + end + self.SubPanels[PANEL_INDEX.Account] = XUiPanelAccountSet.New(self.PanelAccountObj, self) + end +end + +function XUiSet:SwitchSubPanel(index) + if not self.SubPanels[index] then + self:InitSubPanel(index) + end + + self:CheckSave(function() + self:ShowSubPanel(index) + end) + self:PlayAnimation("AnimQieHuanEnable") +end + +function XUiSet:ShowSubPanel(index) + if index == PANEL_INDEX.Instruction or index == PANEL_INDEX.CombatTask then + self.BtnSave.gameObject:SetActiveEx(false) + self.BtnDefault.gameObject:SetActiveEx(false) + elseif index == PANEL_INDEX.Fight then + elseif index == PANEL_INDEX.Account then + self.BtnSave.gameObject:SetActiveEx(false) + self.BtnDefault.gameObject:SetActiveEx(false) + else + self.BtnSave.gameObject:SetActive(true) + self.BtnDefault.gameObject:SetActive(true) + if self.IsStartAnimCommon then + self.IsStartAnimCommon = false + self.BtnDefaultAnmation:EnableAnim(XUiButtonState.Normal) + self.BtnSaveAnmation:EnableAnim(XUiButtonState.Normal) + else + -- 可能由于动画未播放完毕,就被setActive(false),导致透明度错误 + local image = XUiHelper.TryGetComponent(self.BtnSave.transform, "Normal/ImgNormal", "Image") + local color = image.color + if color.a ~= 1 then + color.a = 1 + image.color = color + end + end + end + + -- 原来的协议按钮挪至Other页签中 + --if index ~= PANEL_INDEX.Other or self.IsFight then + -- self.BtnUserAgreement.gameObject:SetActiveEx(false) + -- self.BtnPrivacyPolicy.gameObject:SetActiveEx(false) + --else + -- self.BtnUserAgreement.gameObject:SetActive(true) + -- self.BtnPrivacyPolicy.gameObject:SetActive(true) + -- if self.IsStartAnimOther then + -- self.IsStartAnimOther = false + -- self.BtnUserAgreementAnim:EnableAnim(XUiButtonState.Normal) + -- self.BtnPrivacyPolicyAnim:EnableAnim(XUiButtonState.Normal) + -- end + --end + + self.SelectedIndex = index + for i, panel in pairs(self.SubPanels) do + if (i == index) then + self.CurShowIndex = index + panel:ShowPanel() + else + panel:HidePanel() + end + end + self.BtnRetreat.gameObject:SetActiveEx(self.IsFight) + + local showRestartIndex = (index == PANEL_INDEX.Instruction) or (index == PANEL_INDEX.CombatTask) + self.BtnRestart.gameObject:SetActiveEx(showRestartIndex and CS.XFight.Restartable and not CS.XFight.AlreadySettled) +end + +function XUiSet:Save() + self.SubPanels[self.SelectedIndex]:SaveChange() +end + +function XUiSet:Cancel() + self.SubPanels[self.SelectedIndex]:CancelChange() +end + +function XUiSet:CheckUnSaveData() + if self.SelectedIndex and self.SubPanels[self.SelectedIndex]:CheckDataIsChange() then + return true + else + return false + end +end + +function XUiSet:UpdateSpecialScreenOff() + if self.SafeAreaContentPane then + self.SafeAreaContentPane:UpdateSpecialScreenOff() + end +end + +function XUiSet:CheckSave(cb) + local isUnSave = self:CheckUnSaveData() + if isUnSave then + local cancelCb = function() + self:Cancel() + if cb then cb() end + end + local confirmCb = function() + self:Save() + if cb then cb() end + end + self:TipDialog(cancelCb, confirmCb) + else + if cb then cb() end + end +end + +function XUiSet:TipDialog(cancelCb, confirmCb) + CsXUiManager.Instance:Open("UiDialog", self.TipTitle, self.TipContent, XUiManager.DialogType.Normal, cancelCb, confirmCb) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSettleLose/XUiGridLoseTip.lua b/Resources/Scripts/XUi/XUiSettleLose/XUiGridLoseTip.lua new file mode 100644 index 00000000..66cd6428 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSettleLose/XUiGridLoseTip.lua @@ -0,0 +1,67 @@ +local XUiGridLoseTip = XClass(nil, "XUiGridLoseTip") + +--- +--- 'params'结构:{ TipDesc:string, SkipId:int } +function XUiGridLoseTip:Ctor(ui, rootUi, params) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + + if params == nil then + XLog.Error("XUiGridLoseTip:Ctor函数错误,参数params为空") + self.Params = {} + else + self.Params = params + end + + if params.SkipId and params.SkipId ~= 0 then + self.IsCanSkip = true + else + self.IsCanSkip = false + end + + XTool.InitUiObject(self) + self:InitComponent() + self:AddListener() + self:Refresh() +end + +function XUiGridLoseTip:InitComponent() + self.BtnSkip.gameObject:SetActiveEx(self.IsCanSkip) +end + +function XUiGridLoseTip:Refresh() + -- 提示描述 + if self.Params.TipDesc then + self.TxtTip.text = self.Params.TipDesc + else + XLog.Error("XUiGridLoseTip:Refresh函数错误,self.Params没有TipDesc数据") + self.TxtTip.gameObject:SetActiveEx(false) + end + + -- 跳转按钮名称 + if self.IsCanSkip then + self.BtnSkip:SetName(XFunctionConfig.GetExplain(self.Params.SkipId)) + end +end + +function XUiGridLoseTip:AddListener() + if self.IsCanSkip then + self.BtnSkip.CallBack = function() + self:OnBtnSkipClick() + end + end +end + +function XUiGridLoseTip:OnBtnSkipClick() + local title = CsXTextManagerGetText("SettleLoseSkipConfirmTitle") + local content = CsXTextManagerGetText("SettleLoseSkipConfirmContent") + + XUiManager.DialogTip(title, content, XUiManager.DialogType.Normal, nil, + function() + XLuaUiManager.RunMain() + XFunctionManager.SkipInterface(self.Params.SkipId) + end) +end + +return XUiGridLoseTip \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSettleLose/XUiSettleLose.lua b/Resources/Scripts/XUi/XUiSettleLose/XUiSettleLose.lua new file mode 100644 index 00000000..124caf14 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSettleLose/XUiSettleLose.lua @@ -0,0 +1,151 @@ +local XUiSettleLose = XLuaUiManager.Register(XLuaUi, "UiSettleLose") + +local GridLoseTip = require("XUi/XUiSettleLose/XUiGridLoseTip") + +function XUiSettleLose:OnAwake() + self:InitAutoScript() + self.GridLoseTip.gameObject:SetActiveEx(false) +end + +function XUiSettleLose:OnStart() + local beginData = XDataCenter.FubenManager.GetFightBeginData() + local count = 0 + for _, v in pairs(beginData.CharList) do + if v ~= 0 then + count = count + 1 + end + end + self.TxtPeople.text = CS.XTextManager.GetText("BattleLoseActorNum", count) + + local stageId = beginData.StageId + self.StageId = stageId + + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + self.TxtStageName.text = stageCfg.Name + + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + local showBtnRestart = stageInfo.Type == XDataCenter.FubenManager.StageType.BabelTower + self.BtnRestart.gameObject:SetActiveEx(showBtnRestart) + + self:SetTips(stageCfg.SettleLoseTipId) +end + +function XUiSettleLose:OnEnable() + XDataCenter.FunctionEventManager.UnLockFunctionEvent() +end + +function XUiSettleLose:OnDestroy() + XDataCenter.AntiAddictionManager.EndFightAction() + XEventManager.DispatchEvent(XEventId.EVENT_FIGHT_FINISH_LOSEUI_CLOSE) +end + +--- +--- 根据"settleLoseTipId"来生成提示 +function XUiSettleLose:SetTips(settleLoseTipId) + if not self.HadSetTip then + local tipDescList = XFubenConfigs.GetTipDescList(settleLoseTipId) + if tipDescList == nil then + XLog.Error("XUiSettleLose:SetTips函数错误,tipDescList为空") + return + end + local skipIdList = XFubenConfigs.GetSkipIdList(settleLoseTipId) + if tipDescList == nil then + XLog.Error("XUiSettleLose:SetTips函数错误,skipIdList为空") + return + end + + for i, desc in ipairs(tipDescList) do + local obj = CS.UnityEngine.Object.Instantiate(self.GridLoseTip) + obj.transform:SetParent(self.PanelTips.transform, false) + obj.gameObject:SetActiveEx(true) + GridLoseTip.New(obj, self, { ["TipDesc"] = desc, ["SkipId"] = skipIdList[i] }) + end + self.HadSetTip = true + end +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiSettleLose:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiSettleLose:AutoInitUi() + self.BtnLose = self.Transform:Find("SafeAreaContentPane/PanelLose/BtnLose"):GetComponent("Button") +end + +function XUiSettleLose:GetAutoKey(uiNode, eventName) + if not uiNode then + return + end + return eventName .. uiNode:GetHashCode() +end + +function XUiSettleLose:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then + return + end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiSettleLose:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiSettleLose:AutoAddListener() + self.AutoCreateListeners = {} + self:RegisterClickEvent(self.BtnLose, self.OnBtnLoseClick) + self.BtnRestart.CallBack = function() self:OnClickBtnRestart() end +end +-- auto +function XUiSettleLose:OnBtnLoseClick() + --CS.XAudioManager.RemoveCueSheet(CS.XAudioManager.BATTLE_MUSIC_CUE_SHEET_ID) + --CS.XAudioManager.PlayMusic(CS.XAudioManager.MAIN_BGM) + if XDataCenter.ArenaManager.JudgeGotoMainWhenFightOver() then + return + end + + local beginData = XDataCenter.FubenManager.GetFightBeginData() + if XDataCenter.ArenaOnlineManager.JudgeGotoMainWhenFightOver(beginData.StageId) then + return + end + local stageInfo = XDataCenter.FubenManager.GetStageInfo(self.StageId) + if stageInfo.Type == XDataCenter.FubenManager.StageType.Expedition and XDataCenter.ExpeditionManager.GetIfBackMain() then + XLuaUiManager.RunMain() + XUiManager.TipMsg(CS.XTextManager.GetText("ExpeditionOnClose")) + return + end + self:Close() +end + +function XUiSettleLose:OnClickBtnRestart() + self:Close() + + local stageInfo = XDataCenter.FubenManager.GetStageInfo(self.StageId) + if stageInfo.Type == XDataCenter.FubenManager.StageType.BabelTower then + if XLuaUiManager.IsUiLoad("UiBabelTowerSelectDiffcult") then + XLuaUiManager.Remove("UiBabelTowerSelectDiffcult") + end + + local curStageId, curTeamId, curStageGuideId, teamList, challengeBuffList, supportBuffList, captainPos, curStageLevel, firstFightPos = XDataCenter.FubenBabelTowerManager.GetCurStageInfo() + XDataCenter.FubenBabelTowerManager.SelectBabelTowerStage(curStageId, curStageGuideId, teamList, challengeBuffList, supportBuffList, function() + XDataCenter.FubenManager.EnterBabelTowerFight(curStageId, teamList, nil, captainPos, firstFightPos) + end, curStageLevel, curTeamId) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSettleUrgentEvent/XUiSettleUrgentEvent.lua b/Resources/Scripts/XUi/XUiSettleUrgentEvent/XUiSettleUrgentEvent.lua new file mode 100644 index 00000000..16d87e91 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSettleUrgentEvent/XUiSettleUrgentEvent.lua @@ -0,0 +1,41 @@ +local XUiSettleUrgentEvent = XLuaUiManager.Register(XLuaUi, "UiSettleUrgentEvent") + +function XUiSettleUrgentEvent:OnAwake() + self:InitAutoScript() +end + +function XUiSettleUrgentEvent:OnStart(urgentId) + local urgentCfg = XDataCenter.FubenUrgentEventManager.GetUrgentEventCfg(urgentId) + self.TxtUrgentDesc.color = XUiHelper.Hexcolor2Color(urgentCfg.BgColor) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiSettleUrgentEvent:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiSettleUrgentEvent:AutoInitUi() + self.PanelUrgentInfo = self.Transform:Find("Animator/SafeAreaContentPane/PanelUrgentInfo") + self.Panel = self.Transform:Find("Animator/SafeAreaContentPane/PanelUrgentInfo/Panel") + self.PanelEffect = self.Transform:Find("Animator/SafeAreaContentPane/PanelUrgentInfo/Panel/PanelEffect") + self.TxtUrgentDesc = self.Transform:Find("Animator/SafeAreaContentPane/PanelUrgentInfo/Panel/TxtUrgentDesc"):GetComponent("Text") + self.BtnClose = self.Transform:Find("Animator/SafeAreaContentPane/PanelUrgentInfo/BtnClose"):GetComponent("Button") + self.BtnGo = self.Transform:Find("Animator/SafeAreaContentPane/PanelUrgentInfo/BtnGo"):GetComponent("Button") +end + +function XUiSettleUrgentEvent:AutoAddListener() + self:RegisterClickEvent(self.BtnClose, self.OnBtnCloseClick) + self:RegisterClickEvent(self.BtnGo, self.OnBtnGoClick) +end +-- auto +function XUiSettleUrgentEvent:OnBtnCloseClick() + self:Close() +end + +function XUiSettleUrgentEvent:OnBtnGoClick() + -- 跳转到挑战界面 + XLuaUiManager.RunMain() + XFunctionManager.SkipInterface(828) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSettleWin/XUiGridWinRole.lua b/Resources/Scripts/XUi/XUiSettleWin/XUiGridWinRole.lua new file mode 100644 index 00000000..1dbd99d3 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSettleWin/XUiGridWinRole.lua @@ -0,0 +1,105 @@ +local XUiPanelExpBar = require("XUi/XUiSettleWinMainLine/XUiPanelExpBar") + +XUiGridWinRole = XClass(nil, "XUiGridWinRole") + +function XUiGridWinRole:Ctor(rootUi, ui) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +-- 角色经验 +function XUiGridWinRole:UpdateRoleInfo(charExpData, addExp) + local charId = charExpData.Id + local isRobot = XRobotManager.CheckIsRobotId(charId) + local char + if isRobot then + self:UpdateRobotInfo(charId) + return + else + char = XDataCenter.CharacterManager.GetCharacter(charId) + end + + if char == nil then + return + end + + local lastLevel = charExpData.Level + local lastExp = charExpData.Exp + local lastMaxExp = XCharacterConfigs.GetNextLevelExp(charId, lastLevel) + local curLevel = char.Level + local curExp = char.Exp + local curMaxExp = XCharacterConfigs.GetNextLevelExp(charId, curLevel) + self.PlayerExpBar = self.PlayerExpBar or XUiPanelExpBar.New(self.PanelPlayerExpBar) + self.PlayerExpBar:LetsRoll(lastLevel, lastExp, lastMaxExp, curLevel, curExp, curMaxExp, addExp) + self.PlayerExpBar:SetShareTag(false) + + local icon = XDataCenter.CharacterManager.GetCharBigHeadIcon(charId) + if icon then + self.RImgIcon:SetRawImage(icon) + end +end + +-- 机器人 +function XUiGridWinRole:UpdateRobotInfo(robotId) + local data = XRobotManager.GetRobotTemplate(robotId) + local curLevel = data.CharacterLevel + local curExp = 1 + local maxExp = 1 + local addExp = 0 + self.PlayerExpBar = self.PlayerExpBar or XUiPanelExpBar.New(self.PanelPlayerExpBar) + self.PlayerExpBar:LetsRoll(curLevel, curExp, maxExp, curLevel, curExp, maxExp, addExp) + self.PlayerExpBar:SetShareTag(false) + + local icon = XDataCenter.CharacterManager.GetCharBigHeadIcon(data.CharacterId) + if icon then + self.RImgIcon:SetRawImage(icon) + end +end + +-- 共享的角色 +function XUiGridWinRole:UpdateShareRoleInfo(shareRoleInfo) + local charId = shareRoleInfo.Id + local lastLevel = shareRoleInfo.Level + local lastExp = shareRoleInfo.Exp + local lastMaxExp = XCharacterConfigs.GetNextLevelExp(charId, lastLevel) + local curLevel = shareRoleInfo.Level + local curExp = shareRoleInfo.Exp + local curMaxExp = XCharacterConfigs.GetNextLevelExp(charId, curLevel) + + self.PlayerExpBar = self.PlayerExpBar or XUiPanelExpBar.New(self.PanelPlayerExpBar) + self.PlayerExpBar:LetsRoll(lastLevel, lastExp, lastMaxExp, curLevel, curExp, curMaxExp, 0) + self.PlayerExpBar:SetShareTag(true) + + local icon = XDataCenter.CharacterManager.GetCharBigHeadIcon(charId) + if icon then + self.RImgIcon:SetRawImage(icon) + end +end + +-- 机器人 +function XUiGridWinRole:UpdateNieRRobotInfo(robotId) + local data = XRobotManager.GetRobotTemplate(robotId) + local curLevel = data.CharacterLevel + local curExp = 1 + local maxExp = 1 + local addExp = 0 + self.PlayerExpBar = self.PlayerExpBar or XUiPanelExpBar.New(self.PanelPlayerExpBar) + self.PlayerExpBar:LetsRoll(curLevel, curExp, maxExp, curLevel, curExp, maxExp, addExp) + self.PlayerExpBar:SetShareTag(false) + + + local icon + local nierCharacterId = XDataCenter.NieRManager.GetCharacterIdByNieRRobotId(robotId) + if nierCharacterId ~= 0 then + local nierCharacter = XDataCenter.NieRManager.GetNieRCharacterByCharacterId(nierCharacterId) + icon = XDataCenter.FashionManager.GetFashionBigHeadIcon(nierCharacter:GetNieRFashionId()) + else + icon = XDataCenter.CharacterManager.GetCharBigHeadIcon(data.CharacterId) + end + + if icon then + self.RImgIcon:SetRawImage(icon) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSettleWin/XUiPanelSettleWinPokemon.lua b/Resources/Scripts/XUi/XUiSettleWin/XUiPanelSettleWinPokemon.lua new file mode 100644 index 00000000..20d741d1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSettleWin/XUiPanelSettleWinPokemon.lua @@ -0,0 +1,76 @@ +local XUiGridPokemonMonster = require("XUi/XUiPokemon/XUiMonster/XUiGridPokemonMonster") +local XUiPanelExpBar = require("XUi/XUiSettleWinMainLine/XUiPanelExpBar") + +local ipairs = ipairs +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate + +local XUiPanelSettleWinPokemon = XClass(nil, "XUiPanelSettleWinPokemon") + +function XUiPanelSettleWinPokemon:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.MonsterGrids = {} + + XTool.InitUiObject(self) + + self.GridMonster.gameObject:SetActiveEx(false) +end + +function XUiPanelSettleWinPokemon:Refresh(data) + self.Data = data + + self:UpdateMonsters() + self:UpdatePlayerInfo() +end + +function XUiPanelSettleWinPokemon:UpdateMonsters() + local monsterCount = 0 + + local monsterIds = XDataCenter.PokemonManager.GetTeamMonsterIds() + for _, monsterId in ipairs(monsterIds) do + + if monsterId > 0 then + monsterCount = monsterCount + 1 + + local grid = self.MonsterGrids[monsterCount] + if not grid then + local ui = CSUnityEngineObjectInstantiate(self.GridMonster, self.PanelMonsterContent) + grid = XUiGridPokemonMonster.New(ui) + self.MonsterGrids[monsterCount] = grid + end + + grid:Refresh(monsterId) + grid.GameObject:SetActiveEx(true) + + end + + end + + for index = monsterCount + 1, #self.MonsterGrids do + local grid = self.MonsterGrids[index] + if grid then + grid.GameObject:SetActiveEx(false) + end + end + +end + +-- 玩家经验 +function XUiPanelSettleWinPokemon:UpdatePlayerInfo() + local data = self.Data + if XTool.IsTableEmpty(data) then return end + + local lastLevel = data.RoleLevel + local lastExp = data.RoleExp + local lastMaxExp = XPlayerManager.GetMaxExp(lastLevel, XPlayer.IsHonorLevelOpen()) + local curLevel = XPlayer.GetLevelOrHonorLevel() + local curExp = XPlayer.Exp + local curMaxExp = XPlayerManager.GetMaxExp(curLevel, XPlayer.IsHonorLevelOpen()) + local txtLevelName = XPlayer.IsHonorLevelOpen() and CS.XTextManager.GetText("HonorLevel") or nil + local stageCfg = XDataCenter.FubenManager.GetStageCfg(data.StageId) + local addExp = stageCfg.TeamExp + self.PlayerExpBar = self.PlayerExpBar or XUiPanelExpBar.New(self.PanelPlayerExpBar) + self.PlayerExpBar:LetsRoll(lastLevel, lastExp, lastMaxExp, curLevel, curExp, curMaxExp, addExp, txtLevelName) +end + +return XUiPanelSettleWinPokemon \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSettleWin/XUiSettleWin.lua b/Resources/Scripts/XUi/XUiSettleWin/XUiSettleWin.lua new file mode 100644 index 00000000..c910445e --- /dev/null +++ b/Resources/Scripts/XUi/XUiSettleWin/XUiSettleWin.lua @@ -0,0 +1,461 @@ +local XUiPanelExpBar = require("XUi/XUiSettleWinMainLine/XUiPanelExpBar") +local XUiPanelSettleWinPokemon = require("XUi/XUiSettleWin/XUiPanelSettleWinPokemon") + +local XUiSettleWin = XLuaUiManager.Register(XLuaUi, "UiSettleWin") + +function XUiSettleWin:OnAwake() + self:InitAutoScript() + + self.GridReward.gameObject:SetActiveEx(false) + self.PanelPokemon.gameObject:SetActiveEx(false) + self.GridWinRole.gameObject:SetActiveEx(false) + self.PanelLeft.gameObject:SetActiveEx(true) +end + +function XUiSettleWin:OnStart(data, cb, closeCb, onlyTouchBtn) + self.WinData = data + self.StageInfos = XDataCenter.FubenManager.GetStageInfo(data.StageId) + self.StageCfg = XDataCenter.FubenManager.GetStageCfg(data.StageId) + self.CurrentStageId = data.StageId + self.CurrAssistInfo = data.ClientAssistInfo + self.Cb = cb + self.CloseCb = closeCb + self.OnlyTouchBtn = onlyTouchBtn + self.IsFirst = true; + self.Data = data + self:InitInfo(data) + XLuaUiManager.SetMask(true) + self:PlayRewardAnimation() +end + +function XUiSettleWin:OnEnable() + if not self.IsFirst then + XLuaUiManager.SetMask(true) + XScheduleManager.ScheduleOnce(function() + self:PlaySecondAnimation() + end, 0) + end +end + +function XUiSettleWin:OnDestroy() + XDataCenter.AntiAddictionManager.EndFightAction() +end + +-- 奖励动画 +function XUiSettleWin:PlayRewardAnimation() + local delay = XDataCenter.FubenManager.SettleRewardAnimationDelay + local interval = XDataCenter.FubenManager.SettleRewardAnimationInterval + local this = self + + -- 没有奖励则直接播放第二个动画 + if not self.GridRewardList or #self.GridRewardList == 0 then + XScheduleManager.ScheduleOnce(function() + this:PlaySecondAnimation() + end, delay) + return + end + + self.RewardAnimationIndex = 1 + XScheduleManager.Schedule(function() + if XTool.UObjIsNil(self.GridRewardList[this.RewardAnimationIndex].GameObject) then + return + end + if this.RewardAnimationIndex == #self.GridRewardList then + this:PlayReward(this.RewardAnimationIndex, function() + this:PlaySecondAnimation() + end) + else + this:PlayReward(this.RewardAnimationIndex) + end + this.RewardAnimationIndex = this.RewardAnimationIndex + 1 + end, interval, #self.GridRewardList, delay) +end + +function XUiSettleWin:PlaySecondAnimation() + local this = self + self:PlayAnimation("AnimEnable2", function() + XLuaUiManager.SetMask(false) + -- this:PlayTipMission() + XDataCenter.FunctionEventManager.UnLockFunctionEvent() + this:PlayShowFriend() + self.IsFirst = false; + end) +end + +function XUiSettleWin:PlayShowFriend() + if not (self.CurrAssistInfo ~= nil and self.CurrAssistInfo.Id ~= 0 and self.CurrAssistInfo.Id ~= XPlayer.Id) then + if self.Cb then + self.Cb() + end + return + end + + if XDataCenter.SocialManager.CheckIsApplyed(self.CurrAssistInfo.Id) or XDataCenter.SocialManager.CheckIsFriend(self.CurrAssistInfo.Id) then + if self.Cb then + self.Cb() + end + return + end + + self.TxtName.text = self.CurrAssistInfo.Name + self.TxtLv.text = self.CurrAssistInfo.Level + + XUiPLayerHead.InitPortrait(self.CurrAssistInfo.HeadPortraitId, self.CurrAssistInfo.HeadFrameId, self.Head) + + self.PanelFriend.gameObject:SetActiveEx(true) + self:PlayAnimation("PanelFriendEnable", self.Cb) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiSettleWin:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiSettleWin:AutoInitUi() + self.PanelNorWinInfo = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo") + self.PanelNor = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor") + self.PanelBtn = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelBtn") + self.PanelBtns = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelBtn/PanelBtns") + self.BtnLeft = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelBtn/PanelBtns/BtnLeft"):GetComponent("Button") + self.TxtLeft = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelBtn/PanelBtns/BtnLeft/TxtLeft"):GetComponent("Text") + self.BtnRight = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelBtn/PanelBtns/BtnRight"):GetComponent("Button") + self.TxtRight = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelBtn/PanelBtns/BtnRight/TxtRight"):GetComponent("Text") + self.PanelTouch = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelBtn/PanelTouch") + self.BtnBlock = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelBtn/PanelTouch/BtnBlock"):GetComponent("Button") + self.TxtLeftA = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelBtn/PanelTouch/BtnBlock/TxtLeft"):GetComponent("Text") + self.PanelLeft = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelLeft") + self.PanelRoleContent = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelLeft/Team/PanelRoleContent") + self.GridWinRole = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelLeft/Team/PanelRoleContent/GridWinRole") + self.PanelRight = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelRight") + self.TxtChapterName = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelRight/StageInfo/TxtChapterName"):GetComponent("Text") + self.TxtStageName = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelRight/StageInfo/TxtStageName"):GetComponent("Text") + self.PanelRewardContent = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelRight/RewardList/Viewport/PanelRewardContent") + self.GridReward = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelRight/RewardList/Viewport/PanelRewardContent/GridReward") + self.PanelFriend = self.Transform:Find("SafeAreaContentPane/PanelFriend") + self.PanelInf = self.Transform:Find("SafeAreaContentPane/PanelFriend/PanelInf") + self.TxtName = self.Transform:Find("SafeAreaContentPane/PanelFriend/PanelInf/TxtName"):GetComponent("Text") + self.TxtLv = self.Transform:Find("SafeAreaContentPane/PanelFriend/PanelInf/TxtLv"):GetComponent("Text") + self.BtnFriClose = self.Transform:Find("SafeAreaContentPane/PanelFriend/BtnFriClose"):GetComponent("Button") + self.BtnFriAdd = self.Transform:Find("SafeAreaContentPane/PanelFriend/BtnFriAdd"):GetComponent("Button") + self.PanelPlayerExpBar = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelLeft/PlayerExp/PanelPlayerExpBar") +end + +function XUiSettleWin:AutoAddListener() + self:RegisterClickEvent(self.BtnLeft, self.OnBtnLeftClick) + self:RegisterClickEvent(self.BtnRight, self.OnBtnRightClick) + self:RegisterClickEvent(self.BtnBlock, self.OnBtnBlockClick) + self:RegisterClickEvent(self.BtnFriClose, self.OnBtnFriCloseClick) + self:RegisterClickEvent(self.BtnFriAdd, self.OnBtnFriAddClick) +end +-- auto +function XUiSettleWin:OnBtnLeftClick() + self:SetBtnByType(self.StageCfg.FunctionLeftBtn) +end + +function XUiSettleWin:OnBtnFriCloseClick() + self:PlayAnimation("PanelFriendDisable") + self.PanelFriend.gameObject:SetActiveEx(false) +end + +function XUiSettleWin:OnBtnFriAddClick() + if not self.CurrAssistInfo then + return + end + + XDataCenter.SocialManager.ApplyFriend(self.CurrAssistInfo.Id) + + self.CurrAssistInfo = nil + self:PlayAnimation("PanelFriendDisable") + self.PanelFriend.gameObject:SetActiveEx(false) +end + +function XUiSettleWin:InitInfo(data) + self.PanelFriend.gameObject:SetActiveEx(false) + XTipManager.Execute() + + self:SetBtnsInfo(data) + self:SetStageInfo(data) + self:UpdatePlayerInfo(data) + self:InitRewardCharacterList(data) + self:InitRewardList(data.RewardGoodsList) + XTipManager.Add(function() + if data.UrgentId > 0 then + XLuaUiManager.Open("UiSettleUrgentEvent", data.UrgentId) + end + end) +end + +function XUiSettleWin:SetBtnsInfo(data) + local stageData = XDataCenter.FubenManager.GetStageData(data.StageId) + + if (self.StageCfg.HaveFirstPass and stageData and stageData.PassTimesToday < 2) or self.OnlyTouchBtn then + self.PanelTouch.gameObject:SetActiveEx(true) + self.PanelBtns.gameObject:SetActiveEx(false) + else + local leftType = self.StageCfg.FunctionLeftBtn + local rightType = self.StageCfg.FunctionRightBtn + + self.BtnLeft.gameObject:SetActiveEx(leftType > 0) + self.BtnRight.gameObject:SetActiveEx(rightType > 0) + self.TxtLeft.text = XRoomSingleManager.GetBtnText(leftType) + self.TxtRight.text = XRoomSingleManager.GetBtnText(rightType) + + self.PanelTouch.gameObject:SetActiveEx(false) + self.PanelBtns.gameObject:SetActiveEx(true) + end +end + +function XUiSettleWin:SetStageInfo(data) + local chapterName, stageName = XDataCenter.FubenManager.GetFubenNames(data.StageId) + self.TxtChapterName.text = chapterName + self.TxtStageName.text = stageName +end + +-- 角色奖励列表 +function XUiSettleWin:InitRewardCharacterList(data) + if self.StageInfos.Type == XDataCenter.FubenManager.StageType.RogueLike then + local robotInfos = XDataCenter.FubenRogueLikeManager.GetRogueLikeStageRobots(self.StageCfg.StageId) + if robotInfos.IsAssis then + for i = 1, #robotInfos.RobotId do + local id = robotInfos.RobotId[i] + if id > 0 then + local ui = CS.UnityEngine.Object.Instantiate(self.GridWinRole) + local grid = XUiGridWinRole.New(self, ui) + grid.Transform:SetParent(self.PanelRoleContent, false) + grid:UpdateRobotInfo(id) + grid.GameObject:SetActiveEx(true) + end + end + + return + end + end + + -- 巨麻烦的处理,仅狙击战有效 + if self.StageInfos.Type == XDataCenter.FubenManager.StageType.UnionKill then + if self.WinData.SettleData then + local teamCache = XDataCenter.FubenUnionKillManager.GetCacheTeam() + for _, teamItem in pairs(teamCache or {}) do + if teamItem.CharacterId and teamItem.CharacterId > 0 then + local ui = CS.UnityEngine.Object.Instantiate(self.GridWinRole) + local grid = XUiGridWinRole.New(self, ui) + grid.Transform:SetParent(self.PanelRoleContent, false) + grid.GameObject:SetActiveEx(true) + + if teamItem.IsShare then + grid:UpdateShareRoleInfo(teamItem.Character, 0) + else + local character = XDataCenter.CharacterManager.GetCharacter(teamItem.CharacterId) + for _, charExpRecord in pairs(data.CharExp or {}) do + if charExpRecord.Id == teamItem.CharacterId then + character = charExpRecord + break + end + end + grid:UpdateRoleInfo(character, self.StageCfg.CardExp) + end + end + end + end + + return + end + + -- 尼尔玩法特殊处理 + if self.StageInfos.Type == XDataCenter.FubenManager.StageType.NieR and (not self.StageCfg.RobotId or #self.StageCfg.RobotId <= 0) then + if self.WinData.SettleData then + local teamCache = XDataCenter.NieRManager.GetPlayerTeamData(self.StageCfg.StageId) + local teamData = teamCache and teamCache.TeamData or {} + for _, robotId in ipairs(teamData) do + if robotId > 0 then + local ui = CS.UnityEngine.Object.Instantiate(self.GridWinRole) + local grid = XUiGridWinRole.New(self, ui) + grid.Transform:SetParent(self.PanelRoleContent, false) + grid:UpdateNieRRobotInfo(robotId) + grid.GameObject:SetActiveEx(true) + end + end + end + + return + end + + --口袋妖怪 + if self.StageInfos.Type == XDataCenter.FubenManager.StageType.Pokemon then + self.PanelLeft.gameObject:SetActiveEx(false) + + self.PokemonPanel = self.PokemonPanel or XUiPanelSettleWinPokemon.New(self.PanelPokemon) + self.PokemonPanel:Refresh(data) + self.PokemonPanel.GameObject:SetActiveEx(true) + + return + end + + if self.StageCfg.RobotId and #self.StageCfg.RobotId > 0 then + for i = 1, #self.StageCfg.RobotId do + if self.StageCfg.RobotId[i] > 0 then + local ui = CS.UnityEngine.Object.Instantiate(self.GridWinRole) + local grid = XUiGridWinRole.New(self, ui) + grid.Transform:SetParent(self.PanelRoleContent, false) + grid:UpdateRobotInfo(self.StageCfg.RobotId[i]) + grid.GameObject:SetActiveEx(true) + end + end + else + local charExp = data.CharExp + local count = #charExp + if count <= 0 then + return + end + + for i = 1, count do + local ui = CS.UnityEngine.Object.Instantiate(self.GridWinRole) + local grid = XUiGridWinRole.New(self, ui) + local charId = charExp[i].Id + local isRobot = XRobotManager.CheckIsRobotId(charId) + + grid.Transform:SetParent(self.PanelRoleContent, false) + if isRobot then + grid:UpdateRobotInfo(charId) + else + grid:UpdateRoleInfo(charExp[i], self.StageCfg.CardExp) + end + grid.GameObject:SetActiveEx(true) + end + end + +end + +-- 玩家经验 +function XUiSettleWin:UpdatePlayerInfo(data) + if not data or not next(data) then return end + + local lastLevel = data.RoleLevel + local lastExp = data.RoleExp + local lastMaxExp = XPlayerManager.GetMaxExp(lastLevel, XPlayer.IsHonorLevelOpen()) + local curLevel = XPlayer.GetLevelOrHonorLevel() + local curExp = XPlayer.Exp + local curMaxExp = XPlayerManager.GetMaxExp(curLevel, XPlayer.IsHonorLevelOpen()) + local txtLevelName = XPlayer.IsHonorLevelOpen() and CS.XTextManager.GetText("HonorLevel") or nil + local addExp = self.StageCfg.TeamExp + self.PlayerExpBar = self.PlayerExpBar or XUiPanelExpBar.New(self.PanelPlayerExpBar) + self.PlayerExpBar:LetsRoll(lastLevel, lastExp, lastMaxExp, curLevel, curExp, curMaxExp, addExp, txtLevelName) +end + +-- 物品奖励列表 +function XUiSettleWin:InitRewardList(rewardGoodsList) + rewardGoodsList = rewardGoodsList or {} + self.GridRewardList = {} + local rewards = XRewardManager.FilterRewardGoodsList(rewardGoodsList) + rewards = XRewardManager.MergeAndSortRewardGoodsList(rewards) + for _, item in ipairs(rewards) do + local ui = CS.UnityEngine.Object.Instantiate(self.GridReward) + local grid = XUiGridCommon.New(self, ui) + grid.Transform:SetParent(self.PanelRewardContent, false) + grid:Refresh(item, nil, nil, true) + grid.GameObject:SetActiveEx(false) + table.insert(self.GridRewardList, grid) + end +end + +function XUiSettleWin:OnBtnRightClick() + self:SetBtnByType(self.StageCfg.FunctionRightBtn) +end + +function XUiSettleWin:SetBtnByType(btnType) + --CS.XAudioManager.RemoveCueSheet(CS.XAudioManager.BATTLE_MUSIC_CUE_SHEET_ID) + --CS.XAudioManager.PlayMusic(CS.XAudioManager.MAIN_BGM) + if btnType == XRoomSingleManager.BtnType.SelectStage then + self:OnBtnBackClick(false) + elseif btnType == XRoomSingleManager.BtnType.Again then + XLuaUiManager.PopThenOpen("UiNewRoomSingle", self.StageCfg.StageId) + elseif btnType == XRoomSingleManager.BtnType.Next then + self:OnBtnEnterNextClick() + elseif btnType == XRoomSingleManager.BtnType.Main then + self:OnBtnBackClick(true) + end +end + +function XUiSettleWin:OnBtnEnterNextClick() + if self.StageInfos.Type == XDataCenter.FubenManager.StageType.Tower then + local stageId = XDataCenter.TowerManager.GetTowerData().CurrentStageId + if XDataCenter.TowerManager.CheckStageCanEnter(stageId) then + XLuaUiManager.PopThenOpen("UiNewRoomSingle", stageId) + else + local text = CS.XTextManager.GetText("TowerCannotEnter") + XUiManager.TipMsg(text, XUiManager.UiTipType.Tip) + end + else + if self.StageInfos.NextStageId then + local nextStageCfg = XDataCenter.FubenManager.GetStageCfg(self.StageInfos.NextStageId) + self:HidePanel() + XDataCenter.FubenManager.OpenRoomSingle(nextStageCfg) + else + local text = CS.XTextManager.GetText("BattleWinMainCannotEnter") + XUiManager.TipMsg(text, XUiManager.UiTipType.Tip) + end + end +end + +function XUiSettleWin:OnBtnBackClick(isRunMain) + if self.StageInfos.Type == XDataCenter.FubenManager.StageType.Tower then + if XDataCenter.TowerManager.GetChapterLastMapId(self.CurrentStageId) == self.CurrentStageId then + XDataCenter.TowerManager.GetTowerChapterReward(function() + if isRunMain then + XLuaUiManager.RunMain() + else + self:HidePanel() + end + end, self.CurrentStageId) + else + if isRunMain then + XLuaUiManager.RunMain() + else + self:HidePanel() + end + end + elseif self.StageInfos.Type == XDataCenter.FubenManager.StageType.BossSingle then + if isRunMain then + XLuaUiManager.RunMain() + else + self:HidePanel() + end + elseif self.StageInfos.Type == XDataCenter.FubenManager.StageType.Urgent then + if isRunMain then + XLuaUiManager.RunMain() + else + -- 跳转到挑战界面 + XLuaUiManager.RunMain() + XFunctionManager.SkipInterface(600) + end + else + if isRunMain then + XLuaUiManager.RunMain() + else + self:HidePanel() + end + end +end + +function XUiSettleWin:OnBtnBlockClick() + --CS.XAudioManager.RemoveCueSheet(CS.XAudioManager.BATTLE_MUSIC_CUE_SHEET_ID) + --CS.XAudioManager.PlayMusic(CS.XAudioManager.MAIN_BGM) + self:HidePanel() + if self.CloseCb then + self:CloseCb() + end + if self.StageCfg.FirstGotoSkipId > 0 then + XFunctionManager.SkipInterface(self.StageCfg.FirstGotoSkipId) + end +end + +function XUiSettleWin:HidePanel() + self:Close() +end + +function XUiSettleWin:PlayReward(index, cb) + self.GridRewardList[index].GameObject:SetActiveEx(true) + self:PlayAnimation("GridReward", cb) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSettleWinMainLine/XUiGridCond.lua b/Resources/Scripts/XUi/XUiSettleWinMainLine/XUiGridCond.lua new file mode 100644 index 00000000..f8625be6 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSettleWinMainLine/XUiGridCond.lua @@ -0,0 +1,46 @@ +XUiGridCond = XClass(nil, "XUiGridCond") + +function XUiGridCond:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self:InitAutoScript() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiGridCond:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiGridCond:AutoInitUi() + self.TxtFail = self.Transform:Find("TxtFail"):GetComponent("Text") + self.TxtSuccess = self.Transform:Find("TxtSuccess"):GetComponent("Text") + self.TxtDesc = self.Transform:Find("TxtDesc"):GetComponent("Text") +end + +function XUiGridCond:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiGridCond:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiGridCond:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiGridCond:AutoAddListener() +end +-- auto +function XUiGridCond:Refresh(desc, active) + self.TxtDesc.text = desc + self.TxtSuccess.gameObject:SetActive(active) + self.TxtFail.gameObject:SetActive(not active) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSettleWinMainLine/XUiPanelExpBar.lua b/Resources/Scripts/XUi/XUiSettleWinMainLine/XUiPanelExpBar.lua new file mode 100644 index 00000000..a16e26cd --- /dev/null +++ b/Resources/Scripts/XUi/XUiSettleWinMainLine/XUiPanelExpBar.lua @@ -0,0 +1,112 @@ +local FILL_SPEED = 1 +local MathfLerp = CS.UnityEngine.Mathf.Lerp +local CSTime = CS.UnityEngine.Time + +local XUiPanelExpBar = XClass(nil, "XUiPanelExpBar") + +function XUiPanelExpBar:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:InitView() +end + +function XUiPanelExpBar:InitView() + self.ImgPlayerExpFillAdd.fillAmount = 0 + self.GameObject:ScheduleForever(function() + if not self.FullTimes then return end + local beginFillAmount = self.BeginFillAmount + if not beginFillAmount then return end + local finalFillAmount = self.FinalFillAmount + if not finalFillAmount then return end + local curLevel = self.CurLevel + if not curLevel then return end + local lastLevel = self.LastLevel + if not lastLevel then return end + + local lerpPercent = FILL_SPEED * (self.StartTime) + self.StartTime = self.StartTime + CSTime.deltaTime + if curLevel > lastLevel then + local finalFullTimes = curLevel - lastLevel + + if self.FullTimes == 0 then + self.ImgPlayerExpFill.fillAmount = MathfLerp(beginFillAmount, 1, lerpPercent) + elseif self.FullTimes < finalFullTimes then + self.ImgPlayerExpFill.fillAmount = MathfLerp(0, 1, lerpPercent) + else + self.ImgPlayerExpFill.fillAmount = MathfLerp(0, finalFillAmount, lerpPercent) + if lerpPercent >= 1 then + self.FullTimes = nil + end + end + + if self.FullTimes and lerpPercent >= 1 then + -- self.FullTimes = self.FullTimes + 1 --这里是一条条涨上去的动画 + self.FullTimes = finalFullTimes --跳过中间过程,只播首尾 + if self.FullTimes >= finalFullTimes then + self.StartTime = 0 + self.ImgPlayerExpFillAdd.fillAmount = finalFillAmount + end + end + else + self.ImgPlayerExpFill.fillAmount = MathfLerp(beginFillAmount, finalFillAmount, lerpPercent) + if lerpPercent >= 1 then + self.FullTimes = nil + end + end + end, 0) +end + +function XUiPanelExpBar:LetsRoll(lastLevel, lastExp, lastMaxExp, curLevel, curExp, curMaxExp, addExp, txtLevelName) + self.BeginFillAmount = lastExp / lastMaxExp + self.FinalFillAmount = curExp / curMaxExp + self.CurLevel = curLevel + self.LastLevel = lastLevel + self.StartTime = 0 + self.FullTimes = 0 + + if curLevel <= lastLevel then + self.ImgPlayerExpFillAdd.fillAmount = self.FinalFillAmount + end + self.ImgPlayerExpFill.gameObject:SetActiveEx(true) + + if self.TxtPlayerLevel then + self.TxtPlayerLevel.text = curLevel + end + + if self.TextLevel and txtLevelName then + self.TextLevel.text = txtLevelName + end + + if self.TxtPlayerExp then + self.TxtPlayerExp.text = "+ " .. addExp + end +end + +function XUiPanelExpBar:SkipRoll(lastLevel, lastExp, lastMaxExp, curLevel, curExp, curMaxExp, addExp) + local finalFillAmount = curExp / curMaxExp + + self.ImgPlayerExpFill.fillAmount = finalFillAmount + self.ImgPlayerExpFillAdd.fillAmount = finalFillAmount + self.ImgPlayerExpFill.gameObject:SetActiveEx(true) + if self.TxtPlayerExp then + self.TxtPlayerExp.text = "+ " .. addExp + end +end + +function XUiPanelExpBar:PreviewExpBar(curExp, maxExp, addExp) + local curFillAmount = curExp / maxExp + local addFillAmount = addExp / maxExp + + self.ImgPlayerExpFill.fillAmount = curFillAmount + self.ImgPlayerExpFillAdd.fillAmount = addFillAmount + self.ImgPlayerExpFill.gameObject:SetActiveEx(true) +end + +function XUiPanelExpBar:SetShareTag(isShare) + if self.ShareTag then + self.ShareTag.gameObject:SetActiveEx(isShare) + end +end + +return XUiPanelExpBar \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSettleWinMainLine/XUiSettleWinMainLine.lua b/Resources/Scripts/XUi/XUiSettleWinMainLine/XUiSettleWinMainLine.lua new file mode 100644 index 00000000..e4b99252 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSettleWinMainLine/XUiSettleWinMainLine.lua @@ -0,0 +1,450 @@ +local XUiPanelExpBar = require("XUi/XUiSettleWinMainLine/XUiPanelExpBar") + +local XUiSettleWinMainLine = XLuaUiManager.Register(XLuaUi, "UiSettleWinMainLine") + +function XUiSettleWinMainLine:OnAwake() + self:InitAutoScript() + self.GridReward.gameObject:SetActive(false) +end + +function XUiSettleWinMainLine:OnStart(data, cb, closeCb, onlyTouchBtn) + self.WinData = data + self.StageInfos = XDataCenter.FubenManager.GetStageInfo(data.StageId) + self.StageCfg = XDataCenter.FubenManager.GetStageCfg(data.StageId) + self.CurrentStageId = data.StageId + self.CurrAssistInfo = data.ClientAssistInfo + self.Cb = cb + self.CloseCb = closeCb + self.OnlyTouchBtn = onlyTouchBtn + self.IsFirst = true; + self:InitInfo(data) + XLuaUiManager.SetMask(true) + self:PlayRewardAnimation() +end + +function XUiSettleWinMainLine:OnEnable() + if not self.IsFirst then + XLuaUiManager.SetMask(true) + XScheduleManager.ScheduleOnce(function() + self:PlaySecondAnimation() + end, 0) + end +end + +function XUiSettleWinMainLine:OnDestroy() + XDataCenter.AntiAddictionManager.EndFightAction() +end + +-- 奖励动画 +function XUiSettleWinMainLine:PlayRewardAnimation() + local delay = XDataCenter.FubenManager.SettleRewardAnimationDelay + local interval = XDataCenter.FubenManager.SettleRewardAnimationInterval + local this = self + + -- 没有奖励则直接播放第二个动画 + if not self.GridRewardList or #self.GridRewardList == 0 then + XScheduleManager.ScheduleOnce(function() + this:PlaySecondAnimation() + end, delay) + return + end + + self.RewardAnimationIndex = 1 + XScheduleManager.Schedule(function() + if this.RewardAnimationIndex == #self.GridRewardList then + this:PlayReward(this.RewardAnimationIndex, function() + this:PlaySecondAnimation() + end) + else + this:PlayReward(this.RewardAnimationIndex) + end + this.RewardAnimationIndex = this.RewardAnimationIndex + 1 + end, interval, #self.GridRewardList, delay) +end + +-- 第二个动画 +function XUiSettleWinMainLine:PlaySecondAnimation() + local this = self + self:PlayAnimation("AnimEnable2", function() + XLuaUiManager.SetMask(false) + this:PlayTipMission() + XDataCenter.FunctionEventManager.UnLockFunctionEvent() + self.IsFirst = false; + end) +end + +function XUiSettleWinMainLine:PlayTipMission() + if XDataCenter.TaskForceManager.ShowMaxTaskForceTeamCountChangeTips then + local missionData = XDataCenter.TaskForceManager.GetTaskForeInfo() + local taskForeCfg = XDataCenter.TaskForceManager.GetTaskForceConfigById(missionData.ConfigIndex) + XUiManager.TipMsg(string.format(CS.XTextManager.GetText("MissionTaskTeamCountContent"), taskForeCfg.MaxTaskForceCount), nil, handler(self, self.PlayShowFriend)) + XDataCenter.TaskForceManager.ShowMaxTaskForceTeamCountChangeTips = false + else + self:PlayShowFriend() + end +end + +function XUiSettleWinMainLine:PlayShowFriend() + if not (self.CurrAssistInfo ~= nil and self.CurrAssistInfo.Id ~= 0 and self.CurrAssistInfo.Id ~= XPlayer.Id) then + if self.Cb then + self.Cb() + end + return + end + + if XDataCenter.SocialManager.CheckIsApplyed(self.CurrAssistInfo.Id) or XDataCenter.SocialManager.CheckIsFriend(self.CurrAssistInfo.Id) then + if self.Cb then + self.Cb() + end + return + end + + self.TxtName.text = self.CurrAssistInfo.Name + self.TxtLv.text = self.CurrAssistInfo.Level + + XUiPLayerHead.InitPortrait(self.CurrAssistInfo.HeadPortraitId, self.CurrAssistInfo.HeadFrameId, self.Head) + + self.PanelFriend.gameObject:SetActive(true) + self:PlayAnimation("PanelFriendEnable", self.Cb) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiSettleWinMainLine:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiSettleWinMainLine:AutoInitUi() + self.PanelNorWinInfo = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo") + self.PanelNor = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor") + self.PanelBtn = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelBtn") + self.PanelBtns = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelBtn/PanelBtns") + self.BtnLeft = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelBtn/PanelBtns/BtnLeft"):GetComponent("Button") + self.TxtLeft = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelBtn/PanelBtns/BtnLeft/TxtLeft"):GetComponent("Text") + self.BtnRight = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelBtn/PanelBtns/BtnRight"):GetComponent("Button") + self.TxtRight = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelBtn/PanelBtns/BtnRight/TxtRight"):GetComponent("Text") + self.PanelTouch = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelBtn/PanelTouch") + self.BtnBlock = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelBtn/PanelTouch/BtnBlock"):GetComponent("Button") + self.TxtLeftA = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelBtn/PanelTouch/BtnBlock/TxtLeft"):GetComponent("Text") + self.PanelLeft = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelLeft") + self.PanelCond = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelLeft/PanelCond") + self.PanelCondContent = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelLeft/PanelCond/PanelCondContent") + self.GridCond = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelLeft/PanelCond/PanelCondContent/GridCond") + self.PanelRoleContent = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelLeft/Team/PanelRoleContent") + self.GridWinRole = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelLeft/Team/PanelRoleContent/GridWinRole") + self.PanelRight = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelRight") + self.TxtChapterName = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelRight/StageInfo/TxtChapterName"):GetComponent("Text") + self.TxtStageName = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelRight/StageInfo/TxtStageName"):GetComponent("Text") + self.PanelRewardContent = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelRight/RewardList/Viewport/PanelRewardContent") + self.GridReward = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelRight/RewardList/Viewport/PanelRewardContent/GridReward") + self.PanelFriend = self.Transform:Find("SafeAreaContentPane/PanelFriend") + self.PanelInf = self.Transform:Find("SafeAreaContentPane/PanelFriend/PanelInf") + self.PanelHead = self.Transform:Find("SafeAreaContentPane/PanelFriend/PanelInf/PanelHead") + self.TxtName = self.Transform:Find("SafeAreaContentPane/PanelFriend/PanelInf/TxtName"):GetComponent("Text") + self.TxtLv = self.Transform:Find("SafeAreaContentPane/PanelFriend/PanelInf/TxtLv"):GetComponent("Text") + self.BtnFriClose = self.Transform:Find("SafeAreaContentPane/PanelFriend/BtnFriClose"):GetComponent("Button") + self.BtnFriAdd = self.Transform:Find("SafeAreaContentPane/PanelFriend/BtnFriAdd"):GetComponent("Button") + self.PanelPlayerExpBar = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelLeft/PlayerExp/PanelPlayerExpBar") + self.PanelFirst = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelFirst") + self.PaenlRewardList = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelRight/RewardList") + self.PanelAssist = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelRight/PanelAssist") + self.TxtAssist = self.Transform:Find("SafeAreaContentPane/PanelNorWinInfo/PanelNor/PanelRight/PanelAssist/TxtAssist"):GetComponent("Text") +end + +function XUiSettleWinMainLine:AutoAddListener() + self:RegisterClickEvent(self.BtnLeft, self.OnBtnLeftClick) + self:RegisterClickEvent(self.BtnRight, self.OnBtnRightClick) + self:RegisterClickEvent(self.BtnBlock, self.OnBtnBlockClick) + self:RegisterClickEvent(self.BtnFriClose, self.OnBtnFriCloseClick) + self:RegisterClickEvent(self.BtnFriAdd, self.OnBtnFriAddClick) +end +-- auto +function XUiSettleWinMainLine:OnBtnLeftClick() + self:SetBtnByType(self.StageCfg.FunctionLeftBtn) +end + +function XUiSettleWinMainLine:OnBtnFriCloseClick() + self:PlayAnimation("PanelFriendDisable") + self.PanelFriend.gameObject:SetActive(false) +end + +function XUiSettleWinMainLine:OnBtnFriAddClick() + if not self.CurrAssistInfo then + return + end + + XDataCenter.SocialManager.ApplyFriend(self.CurrAssistInfo.Id) + + self.CurrAssistInfo = nil + self:PlayAnimation("PanelFriendDisable") + self.PanelFriend.gameObject:SetActive(false) +end + +function XUiSettleWinMainLine:InitInfo(data) + self.PanelFriend.gameObject:SetActive(false) + XTipManager.Execute() + + self:SetBtnsInfo(data) + self:SetStageInfo(data) + self:UpdatePlayerInfo(data) + self:InitRewardCharacterList(data) + self:InitRewardList(data.RewardGoodsList) + XTipManager.Add(function() + if data.UrgentId > 0 then + XLuaUiManager.Open("UiSettleUrgentEvent", data.UrgentId) + end + end) +end + +function XUiSettleWinMainLine:SetBtnsInfo(data) + local stageData = XDataCenter.FubenManager.GetStageData(data.StageId) + if self.StageInfos.Type == XDataCenter.FubenManager.StageType.Tower or self.StageInfos.Type == XDataCenter.FubenManager.StageType.BossSingle then + self.PanelCond.gameObject:SetActive(false) + elseif self.StageInfos.Type == XDataCenter.FubenManager.StageType.ArenaOnline then + local challengeId = XDataCenter.ArenaOnlineManager.GetCurChallengeId() + local stasMap = XDataCenter.ArenaOnlineManager.GetStageStarsMapByChallengeId(challengeId) + self.PanelCond.gameObject:SetActive(true) + self:UpdateConditions(data.StageId, stasMap) + else + self.PanelCond.gameObject:SetActive(true) + self:UpdateConditions(data.StageId, data.StarsMap) + end + + if (self.StageCfg.HaveFirstPass and stageData and stageData.PassTimesToday < 2) or self.OnlyTouchBtn then + self.PanelTouch.gameObject:SetActive(true) + self.PanelBtns.gameObject:SetActive(false) + else + local leftType = self.StageCfg.FunctionLeftBtn + local rightType = self.StageCfg.FunctionRightBtn + + self.BtnLeft.gameObject:SetActive(leftType > 0) + self.BtnRight.gameObject:SetActive(rightType > 0) + self.TxtLeft.text = XRoomSingleManager.GetBtnText(leftType) + self.TxtRight.text = XRoomSingleManager.GetBtnText(rightType) + + self.PanelTouch.gameObject:SetActive(false) + self.PanelBtns.gameObject:SetActive(true) + end +end + +function XUiSettleWinMainLine:SetStageInfo(data) + if self.StageInfos.Type == XDataCenter.FubenManager.StageType.ArenaOnline then + local beginData = XDataCenter.FubenManager.GetFightBeginData() + self.PanelFirst.gameObject:SetActiveEx(not beginData.LastPassed) + + if not beginData.Passed then + self:PlayAnimation("PanelFirstEnable") + end + else + self.PanelFirst.gameObject:SetActiveEx(false) + end + + local chapterName, stageName = XDataCenter.FubenManager.GetFubenNames(data.StageId) + self.TxtChapterName.text = chapterName + self.TxtStageName.text = stageName +end + +-- 角色奖励列表 +function XUiSettleWinMainLine:InitRewardCharacterList(data) + self.GridWinRole.gameObject:SetActive(false) + if self.StageCfg.RobotId and #self.StageCfg.RobotId > 0 then + for i = 1, #self.StageCfg.RobotId do + if self.StageCfg.RobotId[i] > 0 then + local ui = CS.UnityEngine.Object.Instantiate(self.GridWinRole) + local grid = XUiGridWinRole.New(self, ui) + grid.Transform:SetParent(self.PanelRoleContent, false) + grid:UpdateRobotInfo(self.StageCfg.RobotId[i]) + grid.GameObject:SetActive(true) + end + end + else + local charExp = data.CharExp + local count = #charExp + if count <= 0 then + return + end + + for i = 1, count do + + local ui = CS.UnityEngine.Object.Instantiate(self.GridWinRole) + local grid = XUiGridWinRole.New(self, ui) + grid.Transform:SetParent(self.PanelRoleContent, false) + grid:UpdateRoleInfo(charExp[i], self.StageCfg.CardExp) + grid.GameObject:SetActive(true) + end + end +end + +-- 玩家经验 +function XUiSettleWinMainLine:UpdatePlayerInfo(data) + if not data or not next(data) then return end + + local lastLevel = data.RoleLevel + local lastExp = data.RoleExp + local lastMaxExp = XPlayerManager.GetMaxExp(lastLevel, XPlayer.IsHonorLevelOpen()) + local curLevel = XPlayer.GetLevelOrHonorLevel() + local curExp = XPlayer.Exp + local curMaxExp = XPlayerManager.GetMaxExp(curLevel, XPlayer.IsHonorLevelOpen()) + local txtLevelName = XPlayer.IsHonorLevelOpen() and CS.XTextManager.GetText("HonorLevel") or nil + local addExp = self.StageCfg.TeamExp + self.PlayerExpBar = self.PlayerExpBar or XUiPanelExpBar.New(self.PanelPlayerExpBar) + self.PlayerExpBar:LetsRoll(lastLevel, lastExp, lastMaxExp, curLevel, curExp, curMaxExp, addExp, txtLevelName) +end + +-- 物品奖励列表 +function XUiSettleWinMainLine:InitRewardList(rewardGoodsList) + local beginData = XDataCenter.FubenManager.GetFightBeginData() + if self.StageInfos.Type == XDataCenter.FubenManager.StageType.ArenaOnline and beginData then + -- 联机模式若非首通则显示协助次数面板,跳过显示奖励逻辑 + if not XDataCenter.ArenaOnlineManager.CheckSingleMode() and beginData.LastPassed then + local index = 0 + self.PanelAssist.gameObject:SetActiveEx(true) + self.PaenlRewardList.gameObject:SetActiveEx(false) + for _, _ in pairs(beginData.PlayerList) do + index = index + 1 + end + + if index > 1 then + local lastAssistCount = XDataCenter.ArenaOnlineManager.GetLastAssistCount() + self.TxtAssist.text = CS.XTextManager.GetText("ArenaOnlineSettleAssist", lastAssistCount) + else + local assistCount = XDataCenter.ArenaOnlineManager.GetAssistCount() + self.TxtAssist.text = assistCount + end + return + end + end + + self.PanelAssist.gameObject:SetActiveEx(false) + self.PaenlRewardList.gameObject:SetActiveEx(true) + rewardGoodsList = rewardGoodsList or {} + self.GridRewardList = {} + local rewards = XRewardManager.MergeAndSortRewardGoodsList(rewardGoodsList) + for _, item in ipairs(rewards) do + local ui = CS.UnityEngine.Object.Instantiate(self.GridReward) + local grid = XUiGridCommon.New(self, ui) + grid.Transform:SetParent(self.PanelRewardContent, false) + grid:Refresh(item, nil, nil, true) + grid.GameObject:SetActive(false) + table.insert(self.GridRewardList, grid) + end +end + +-- 显示胜利满足的条件 +function XUiSettleWinMainLine:UpdateConditions(stageId, starMap) + self.GridCond.gameObject:SetActive(false) + if starMap == nil then + return + end + + self.GridCondList = {} + for i = 1, #starMap do + local ui = CS.UnityEngine.Object.Instantiate(self.GridCond) + local grid = XUiGridCond.New(ui) + grid.Transform:SetParent(self.PanelCondContent, false) + grid:Refresh(self.StageCfg.StarDesc[i], starMap[i]) + grid.GameObject:SetActive(true) + self.GridCondList[i] = grid + end +end + +function XUiSettleWinMainLine:OnBtnRightClick() + self:SetBtnByType(self.StageCfg.FunctionRightBtn) +end + +function XUiSettleWinMainLine:SetBtnByType(btnType) + if btnType == XRoomSingleManager.BtnType.SelectStage then + self:OnBtnBackClick(false) + elseif btnType == XRoomSingleManager.BtnType.Again then + XLuaUiManager.PopThenOpen("UiNewRoomSingle", self.StageCfg.StageId) + elseif btnType == XRoomSingleManager.BtnType.Next then + self:OnBtnEnterNextClick() + elseif btnType == XRoomSingleManager.BtnType.Main then + self:OnBtnBackClick(true) + elseif btnType == XRoomSingleManager.BtnType.ArenaOnlineBack then + self:OnArenaOnlineBtnBackClick() + elseif btnType == XRoomSingleManager.BtnType.ArenaOnlineAgain then + self:OnArenaOnlineBtnAgainClick() + end +end + +function XUiSettleWinMainLine:OnBtnEnterNextClick() + if self.StageInfos.Type == XDataCenter.FubenManager.StageType.Tower then + local stageId = XDataCenter.TowerManager.GetTowerData().CurrentStageId + if XDataCenter.TowerManager.CheckStageCanEnter(stageId) then + XLuaUiManager.PopThenOpen("UiNewRoomSingle", stageId) + else + local text = CS.XTextManager.GetText("TowerCannotEnter") + XUiManager.TipMsg(text, XUiManager.UiTipType.Tip) + end + else + if self.StageInfos.NextStageId then + local nextStageCfg = XDataCenter.FubenManager.GetStageCfg(self.StageInfos.NextStageId) + self:HidePanel() + XDataCenter.FubenManager.OpenRoomSingle(nextStageCfg) + else + local text = CS.XTextManager.GetText("BattleWinMainCannotEnter") + XUiManager.TipMsg(text, XUiManager.UiTipType.Tip) + end + end +end + +function XUiSettleWinMainLine:OnBtnBackClick(isRunMain) + if isRunMain then + XLuaUiManager.RunMain() + else + self:HidePanel() + end +end + +-- 区域联机退出队伍 +function XUiSettleWinMainLine:OnArenaOnlineBtnBackClick() + if XDataCenter.ArenaOnlineManager.JudgeGotoMainWhenFightOver(self.WinData.StageId) then + return + end + + local title = CS.XTextManager.GetText("TipTitle") + local cancelMatchMsg = CS.XTextManager.GetText("ArenaOnlineInstanceQuitRoom") + XUiManager.DialogTip(title, cancelMatchMsg, XUiManager.DialogType.Normal, nil, function() + XLuaUiManager.CloseWithCallback("UiSettleWinMainLine", function() + if not XDataCenter.ArenaOnlineManager.CheckSingleMode() then + XDataCenter.RoomManager.Quit(function() + XLuaUiManager.Close("UiMultiplayerRoom") + end) + end + end) + end) +end + +-- 区域联机维持本队 +function XUiSettleWinMainLine:OnArenaOnlineBtnAgainClick() + if XDataCenter.ArenaOnlineManager.JudgeGotoMainWhenFightOver(self.WinData.StageId) then + return + end + + self:HidePanel() +end + +function XUiSettleWinMainLine:OnBtnBlockClick() + self:HidePanel() + if self.CloseCb then + self:CloseCb() + end + if self.StageCfg.FirstGotoSkipId > 0 then + XFunctionManager.SkipInterface(self.StageCfg.FirstGotoSkipId) + end +end + +function XUiSettleWinMainLine:HidePanel() + self:Close() +end + +function XUiSettleWinMainLine:PlayCondition(index, cb) + self:PlayAnimation("GirdCond", cb) +end + +function XUiSettleWinMainLine:PlayReward(index, cb) + self.GridRewardList[index].GameObject:SetActive(true) + self:PlayAnimation("GridReward", cb) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSettleWinSingleBoss/XUiSettleWinSingleBoss.lua b/Resources/Scripts/XUi/XUiSettleWinSingleBoss/XUiSettleWinSingleBoss.lua new file mode 100644 index 00000000..3b658be1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSettleWinSingleBoss/XUiSettleWinSingleBoss.lua @@ -0,0 +1,154 @@ +local XUiSettleWinSingleBoss = XLuaUiManager.Register(XLuaUi, "UiSettleWinSingleBoss") + +function XUiSettleWinSingleBoss:OnAwake() + self:AutoAddListener() +end + +function XUiSettleWinSingleBoss:OnStart(data) + self:ShowPanel(data) + XEventManager.AddEventListener(XEventId.EVENT_FUBEN_SINGLE_BOSS_RESET, self.OnActivityEnd, self) +end + +function XUiSettleWinSingleBoss:OnEnable() + XDataCenter.FunctionEventManager.UnLockFunctionEvent() + self:PlayAnimation("PanelBossSingleinfo") + self:OnActivityEnd() +end + +function XUiSettleWinSingleBoss:OnDestroy() + XDataCenter.AntiAddictionManager.EndFightAction() + XEventManager.RemoveEventListener(XEventId.EVENT_FUBEN_SINGLE_BOSS_RESET, self.OnActivityEnd, self) +end + +function XUiSettleWinSingleBoss:OnActivityEnd() + XDataCenter.FubenBossSingleManager.OnActivityEnd() +end + +function XUiSettleWinSingleBoss:AutoAddListener() + self:RegisterClickEvent(self.BtnLeft, self.OnBtnLeftClick) + self:RegisterClickEvent(self.BtnSave, self.OnBtnSaveClick) + self:RegisterClickEvent(self.BtnCancel, self.OnBtnCancelClick) +end + +function XUiSettleWinSingleBoss:ShowPanel(data) + self.PanelNewTag.gameObject.transform.localScale = CS.UnityEngine.Vector3.zero + self.StageId = data.StageId + + local stageCfg = XDataCenter.FubenManager.GetStageCfg(data.StageId) + local difficultName = XDataCenter.FubenBossSingleManager.GetBossDifficultName(data.StageId) + self.TxtDifficult.text = difficultName + + local settleData = data.SettleData + local result = settleData.BossSingleFightResult + + local showLeftTime = result.MaxTimeScore + self.PanelLeftTime.gameObject:SetActiveEx(showLeftTime > 0) + + + local stageData = XDataCenter.FubenManager.GetStageData(self.StageId) + local myTotalHistory = stageData and stageData.Score or 0 + local stageInfo = XDataCenter.FubenBossSingleManager.GetBossStageInfo(data.StageId) + local bossTotalScore = stageInfo and stageInfo.Score or 0 + local bossLoseHpScore = stageInfo and stageInfo.BossLoseHpScore or 0 + local leftTimeScore = stageInfo and stageInfo.LeftTimeScore or 0 + local leftHpScore = stageInfo and stageInfo.LeftHpScore or 0 + + self.CurAllScore = result.TotalScore + self.TxtBossAllLoseHpScore.text = CS.XTextManager.GetText("BossSingleAutoFightDesc10", result.MaxBossDamageScore) + self.TxAlltLeftTimeScore.text = CS.XTextManager.GetText("BossSingleAutoFightDesc10", showLeftTime) + self.TxtAllCharLeftHpScore.text = CS.XTextManager.GetText("BossSingleAutoFightDesc10", result.MaxHpScore) + + self.GameObject:SetActiveEx(true) + -- 播放音效 + self.AudioInfo = CS.XAudioManager.PlaySound(XSoundManager.UiBasicsMusic.UiSettle_Win_Number) + + local time = CS.XGame.ClientConfig:GetFloat("BossSingleAnimaTime") + XUiHelper.Tween(time, function(f) + if XTool.UObjIsNil(self.Transform) then + return + end + + local totalTimeText = XUiHelper.GetTime(math.floor(f * result.FightTime)) + local bossLoseHpText = math.floor(f * result.BossDamagePer) .. "%" + local bossLoseHpScoreText = '+' .. math.floor(f * result.BossDamageScore) + local leftTimeText = XUiHelper.GetTime(math.floor(f * result.TimeLeft)) + local leftTimeScoreText = '+' .. math.floor(f * result.TimeScore) + local charLeftHpText = math.floor(f * result.HpLeftPer) .. "%" + local charLeftHpScoreText = '+' .. math.floor(f * result.HpScore) + local allScoreText = math.floor(f * result.TotalScore) + local historyScoreText = math.floor(f * myTotalHistory) .. "/" .. bossTotalScore + + self.TxtStageTime.text = totalTimeText + self.TxtBossLoseHp.text = bossLoseHpText + self.TxtBossLoseHpScore.text = bossLoseHpScoreText + self.TxtLeftTime.text = leftTimeText + self.TxtLeftTimeScore.text = leftTimeScoreText + self.TxtCharLeftHp.text = charLeftHpText + self.TxtCharLeftHpScore.text = charLeftHpScoreText + self.TxtAllScore.text = allScoreText + self.TxtHistoryScore.text = historyScoreText + + end, function() + if XTool.UObjIsNil(self.Transform) or XTool.UObjIsNil(self.PanelNewTag) then + return + end + + local tmpStageData = XDataCenter.FubenManager.GetStageData(self.StageId) + local tmpMyTotalHistory = tmpStageData and tmpStageData.Score or 0 + + if self.CurAllScore > tmpMyTotalHistory then + self.PanelNewTag.gameObject.transform.localScale = CS.UnityEngine.Vector3.one + self.PanelNewTag.gameObject:PlayTimelineAnimation() + end + + self:StopAudio() + end) +end + +function XUiSettleWinSingleBoss:SetDefaultText() + self.TxtStageTime.text = XUiHelper.GetTime(0) + self.TxtBossLoseHp.text = 0 + self.TxtBossLoseHpScore.text = '+' .. 0 + self.TxtLeftTime.text = XUiHelper.GetTime(0) + self.TxtLeftTimeScore.text = '+' .. 0 + self.TxtCharLeftHp.text = 0 + self.TxtCharLeftHpScore.text = '+' .. 0 + self.TxtAllScore.text = 0 + self.TxtHistoryScore.text = 0 +end + +function XUiSettleWinSingleBoss:StopAudio() + if self.AudioInfo then + self.AudioInfo:Stop() + end +end + +function XUiSettleWinSingleBoss:OnBtnLeftClick() + self:StopAudio() + XLuaUiManager.Close("UiSettleWinSingleBoss") + XTipManager.Execute() +end + +function XUiSettleWinSingleBoss:OnBtnSaveClick() + XDataCenter.FubenBossSingleManager.SaveScore(self.StageId, function(isTip) + self:OnBtnLeftClick() + if isTip then + XUiManager.TipText("BossSignleBufenTip", XUiManager.UiTipType.Tip) + end + end) +end + +function XUiSettleWinSingleBoss:OnBtnCancelClick() + local stageData = XDataCenter.FubenManager.GetStageData(self.StageId) + local myTotalHistory = stageData and stageData.Score or 0 + + if self.CurAllScore <= myTotalHistory then + self:OnBtnLeftClick() + else + local titletext = CS.XTextManager.GetText("TipTitle") + local contenttext = CS.XTextManager.GetText("BossSingleReslutDesc") + XUiManager.DialogTip(titletext, contenttext, XUiManager.DialogType.Normal, nil, function() + self:OnBtnLeftClick() + end) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiShop/XUiGridFashionShop.lua b/Resources/Scripts/XUi/XUiShop/XUiGridFashionShop.lua new file mode 100644 index 00000000..c03da5f5 --- /dev/null +++ b/Resources/Scripts/XUi/XUiShop/XUiGridFashionShop.lua @@ -0,0 +1,457 @@ +XUiGridFashionShop = XClass(nil, "XUiGridFashionShop") +local Application = CS.UnityEngine.Application +local Platform = Application.platform +local RuntimePlatform = CS.UnityEngine.RuntimePlatform +local BuyCount = 1 +function XUiGridFashionShop:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:SetButtonCallback() + self.PanelPrice = { + self.PanelPrice1 + } + self.TxtOldPrice = { + self.TxtOldPrice1 + } + self.TxtNewPrice = { + self.TxtNewPrice1 + } + self.RImgPrice = { + self.RImgPrice1 + } + self.Timer = nil +end + +function XUiGridFashionShop:Init(parent, rootUi) + self.Parent = parent + self.RootUi = rootUi or parent +end + +function XUiGridFashionShop:OnRecycle() + self:RemoveTimer() + self:RemoveOnSaleTimer() +end + +function XUiGridFashionShop:SetButtonCallback() + self.BtnCondition.CallBack = function() + self:OnBtnConditionClick() + end + self.BtnBuy.CallBack = function() + self:OnBtnBuyClick() + end +end +-- auto +function XUiGridFashionShop:OnBtnConditionClick() + if self.ConditionDesc then + XUiManager.TipError(self.ConditionDesc) + end +end + +function XUiGridFashionShop:OnBtnBuyClick() + if self.IsSellOut then + XUiManager.TipText("ShopItemSellOut") + return + end + if self.IsShopOnSaleLock then + XUiManager.TipError(self.ShopOnSaleLockDecs) + return + end + local buyData = {} + buyData.IsHave = false + buyData.ItemIcon = self.ItemIcon + buyData.ItemCount = self.NeedCount + buyData.GiftRewardId = self.GiftRewardId + buyData.PayKeySuffix = self.Data.PayKeySuffix + buyData.BuyCallBack = function() + if self.Data.PayKeySuffix then + local key + if Platform == RuntimePlatform.Android then + key = string.format("%s%s", XPayConfigs.GetPlatformConfig(1), self.Data.PayKeySuffix) + else + key = string.format("%s%s", XPayConfigs.GetPlatformConfig(2), self.Data.PayKeySuffix) + end + XDataCenter.PayManager.Pay(key, 2, { self.Parent:GetCurShopId(), self.Data.Id }, self.Data.Id, function() + + end) + else + for _, consume in pairs(self.Data.ConsumeList) do + if consume.Id == XDataCenter.ItemManager.ItemId.HongKa then + local result = XDataCenter.ItemManager.CheckItemCountById(consume.Id, consume.Count) + if not result then + XUiManager.TipText("ShopItemHongKaNotEnough") + XLuaUiManager.Open("UiPurchase", XPurchaseConfigs.TabsConfig.Pay) + return + end + elseif consume.Id == XDataCenter.ItemManager.ItemId.PaidGem then + local result = XDataCenter.ItemManager.CheckItemCountById(consume.Id, consume.Count) + if not result then + XUiManager.TipText("ShopItemPaidGemNotEnough") + XLuaUiManager.Open("UiPurchase", XPurchaseConfigs.TabsConfig.HK) + return + end + end + end + + XShopManager.BuyShop(self.Parent:GetCurShopId(), self.Data.Id, BuyCount, function() + self:RefreshSellOut() + self:RefreshCondition() + self:RefreshOnSales() + self:RefreshPrice() + self:RefreshBuyCount() + + local text = CS.XTextManager.GetText("BuySuccess") + XUiManager.TipMsg(text, nil, function() + if buyData.GiftRewardId and buyData.GiftRewardId ~= 0 then + local rewardGoodList = XRewardManager.GetRewardList(buyData.GiftRewardId) + XUiManager.OpenUiObtain(rewardGoodList) + end + end) + self.Parent:RefreshBuy() + end) + end + end + + XLuaUiManager.Open("UiFashionDetail", self.Id, self.IsWeaponFashion, buyData) +end + +function XUiGridFashionShop:UpdateData(data) + self.Data = data + self:RefreshSellOut() + self:RefreshCondition() + self:RefreshIcon() + self:RefreshOnSales() + self:RefreshPrice() + self:RemoveTimer() + self:RemoveOnSaleTimer() + self:RefreshBuyCount() + self:RefreshTimer(self.Data.SelloutTime) + self:RefreshOnSaleTime(self.Data.OnSaleTime) + self:RefreshGift() +end + +function XUiGridFashionShop:RefreshBuyCount() + if not self.ImgLimitLable then + return + end + + if not self.TxtLimitLable then + return + end + + if self.Data.BuyTimesLimit <= 0 then + self.TxtLimitLable.gameObject:SetActiveEx(false) + self.ImgLimitLable.gameObject:SetActiveEx(false) + else + local buynumber = self.Data.BuyTimesLimit - self.Data.TotalBuyTimes + local limitLabel = XShopConfigs.GetBuyLimitLabel(self.Data.AutoResetClockId) + local text = string.format(limitLabel, buynumber) + + self.TxtLimitLable.text = text + self.TxtLimitLable.gameObject:SetActiveEx(true) + self.ImgLimitLable.gameObject:SetActiveEx(true) + end +end + +function XUiGridFashionShop:RefreshCondition() + if not self.BtnCondition then return end + self.BtnCondition.gameObject:SetActiveEx(false) + self.ConditionDesc = nil + local conditionIds = self.Data.ConditionIds + if not conditionIds or #conditionIds <= 0 then return end + + for _, id in pairs(conditionIds) do + local ret, desc = XConditionManager.CheckCondition(id) + if not ret then + self.BtnCondition.gameObject:SetActiveEx(true) + self.ImgSellOut.gameObject:SetActiveEx(false) + self.ConditionDesc = desc + self.ConditionText.text = desc + return + end + end +end + +function XUiGridFashionShop:RefreshSellOut() + if not self.ImgSellOut then + return + end + self.IsSellOut = false + if self.Data.BuyTimesLimit <= 0 then + self.ImgSellOut.gameObject:SetActiveEx(false) + else + if self.Data.TotalBuyTimes >= self.Data.BuyTimesLimit then + self.ImgSellOut.gameObject:SetActiveEx(true) + self.IsSellOut = true + else + self.ImgSellOut.gameObject:SetActiveEx(false) + end + end +end + + +function XUiGridFashionShop:RemoveTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end + +function XUiGridFashionShop:RemoveOnSaleTimer() + if self.OnSaleTimer then + XScheduleManager.UnSchedule(self.OnSaleTimer) + self.OnSaleTimer = nil + end +end + +function XUiGridFashionShop:RefreshIcon() + if type(self.Data.RewardGoods) == "number" then + self.TemplateId = self.Data.RewardGoods + else + self.TemplateId = (self.Data.RewardGoods.TemplateId and self.Data.RewardGoods.TemplateId > 0) and + self.Data.RewardGoods.TemplateId or + self.Data.RewardGoods.Id + end + + self.IsWeaponFashion = XDataCenter.ItemManager.IsWeaponFashion(self.TemplateId) + self.Id = self.IsWeaponFashion and XDataCenter.ItemManager.GetWeaponFashionId(self.TemplateId) or self.TemplateId + + self.GoodsShowParams = XGoodsCommonManager.GetGoodsShowParamsByTemplateId(self.Id) + if self.GoodsShowParams.Name then + if self.GoodsShowParams.RewardType == XArrangeConfigs.Types.Character then + self.TxtName.text = self.GoodsShowParams.TradeName + else + self.TxtName.text = self.GoodsShowParams.Name + end + end + + local characterIcon = self.IsWeaponFashion and self.GoodsShowParams.ShopIcon or self.GoodsShowParams.CharacterIcon + if characterIcon then + self.RImgIcon:SetRawImage(characterIcon) + end +end + +function XUiGridFashionShop:RefreshPrice() + local panelCount = #self.PanelPrice + for i = 1, panelCount do + self.PanelPrice[i].gameObject:SetActiveEx(false) + end + + local index = 1 + if self.Data.PayKeySuffix then + if self.Count and self.Count:Exist() then + self.Count.gameObject:SetActiveEx(false) + end + if self.TxtYuan and self.TxtYuan:Exist() then + self.TxtYuan.gameObject:SetActiveEx(true) + self.TxtYuan.text = self:GetPayAmount() + end + else + if self.Count and self.Count:Exist() then + self.Count.gameObject:SetActiveEx(true) + end + if self.TxtYuan and self.TxtYuan:Exist() then + self.TxtYuan.gameObject:SetActiveEx(false) + end + for _, count in pairs(self.Data.ConsumeList) do + if index > panelCount then + return + end + + local txtOldPrice = self.TxtOldPrice[index] + if txtOldPrice then + if self.Sales == 100 then + txtOldPrice.gameObject:SetActiveEx(false) + else + txtOldPrice.text = count.Count + txtOldPrice.gameObject:SetActiveEx(true) + end + end + + local rImgPrice = self.RImgPrice[index] + if rImgPrice then + self.ItemIcon = XDataCenter.ItemManager.GetItemIcon(count.Id) + if self.ItemIcon ~= nil then + rImgPrice:SetRawImage(self.ItemIcon) + end + end + + local txtNewPrice = self.TxtNewPrice[index] + if txtNewPrice then + self.NeedCount = math.floor(count.Count * self.Sales / 100) + txtNewPrice.text = self.NeedCount + local itemCount = XDataCenter.ItemManager.GetCount(count.Id) + if itemCount < self.NeedCount then + txtNewPrice.color = CS.UnityEngine.Color(1, 0, 0) + else + txtNewPrice.color = CS.UnityEngine.Color(0, 0, 0) + end + end + + self.PanelPrice[index].gameObject:SetActiveEx(true) + index = index + 1 + end + end +end + +function XUiGridFashionShop:GetPayAmount() + local key + if Platform == RuntimePlatform.Android then + key = string.format("%s%s", XPayConfigs.GetPlatformConfig(1), self.Data.PayKeySuffix) + else + key = string.format("%s%s", XPayConfigs.GetPlatformConfig(2), self.Data.PayKeySuffix) + end + + local payConfig = XPayConfigs.GetPayTemplate(key) + return payConfig and payConfig.Amount or 0 +end + +function XUiGridFashionShop:RefreshOnSales() + self.OnSales = {} + self.OnSalesLongTest = {} + XTool.LoopMap(self.Data.OnSales, function(k, sales) + self.OnSales[k] = sales + table.insert(self.OnSalesLongTest, sales) + end) + + self.Sales = 100 + + if #self.OnSalesLongTest ~= 0 then + local sortedKeys = {} + for k, _ in pairs(self.OnSales) do + table.insert(sortedKeys, k) + end + table.sort(sortedKeys) + + for i = 1, #sortedKeys do + if self.Data.TotalBuyTimes >= sortedKeys[i] - 1 then + self.Sales = self.OnSales[sortedKeys[i]] + end + end + end + self:RefreshPanelSale() +end + +function XUiGridFashionShop:RefreshPanelSale() + local hideSales = false + if self.TxtSaleRate then + if self.Data.Tags == XShopManager.ShopTags.DisCount then + if self.Sales < 100 then + self.TxtSaleRate.text = self.Sales / 10 .. CS.XTextManager.GetText("Snap") + else + hideSales = true + end + end + if self.Data.Tags == XShopManager.ShopTags.TimeLimit then + self.TxtSaleRate.text = CS.XTextManager.GetText("TimeLimit") + end + if self.Data.Tags == XShopManager.ShopTags.Recommend then + self.TxtSaleRate.text = CS.XTextManager.GetText("Recommend") + end + if self.Data.Tags == XShopManager.ShopTags.HotSale then + self.TxtSaleRate.text = CS.XTextManager.GetText("HotSell") + end + if self.Data.Tags == XShopManager.ShopTags.Not or hideSales then + self.TxtSaleRate.gameObject:SetActiveEx(false) + self.TxtSaleRate.gameObject.transform.parent.gameObject:SetActiveEx(false) + else + self.TxtSaleRate.gameObject:SetActiveEx(true) + self.TxtSaleRate.gameObject.transform.parent.gameObject:SetActiveEx(true) + + end + end +end + +function XUiGridFashionShop:RefreshTimer(time) + if not self.ImgLeftTime then + return + end + + if not self.TxtLeftTime then + return + end + + if time <= 0 then + self.TxtLeftTime.gameObject:SetActiveEx(false) + self.ImgLeftTime.gameObject:SetActiveEx(false) + return + end + + self.TxtLeftTime.gameObject:SetActiveEx(true) + self.ImgLeftTime.gameObject:SetActiveEx(true) + + local leftTime = XShopManager.GetLeftTime(time) + + local func = function() + leftTime = leftTime > 0 and leftTime or 0 + local dataTime = XUiHelper.GetTime(leftTime, XUiHelper.TimeFormatType.SHOP) + if self.TxtLeftTime then + self.TxtLeftTime.text = CS.XTextManager.GetText("TimeSoldOut", dataTime) + end + if leftTime <= 0 then + self:RemoveTimer() + if self.ImgSellOut then + self.ImgSellOut.gameObject:SetActiveEx(true) + self.IsSellOut = true + end + end + end + + func() + + self.Timer = XScheduleManager.ScheduleForever(function() + leftTime = leftTime - 1 + func() + end, 1000) +end + +function XUiGridFashionShop:RefreshGift() + if self.Data.GiftRewardId and self.Data.GiftRewardId ~= 0 then + self.ImgTabLb.gameObject:SetActiveEx(true) + self.GiftRewardId = self.Data.GiftRewardId + else + self.GiftRewardId = 0 + self.ImgTabLb.gameObject:SetActiveEx(false) + end +end + + +function XUiGridFashionShop:RefreshOnSaleTime(time) + if not self.TxtOnSaleTime then + return + end + + if time <= 0 then + self.TxtOnSaleTime.gameObject:SetActiveEx(false) + return + end + + self.TxtOnSaleTime.gameObject:SetActiveEx(true) + self.ShopOnSaleLockDecs = CS.XTextManager.GetText("ActivityBriefShopOnSaleLock") + + local SaleTime = XShopManager.GetLeftTime(time) + + local func = function() + SaleTime = SaleTime > 0 and SaleTime or 0 + local dataTime = XUiHelper.GetTime(SaleTime, XUiHelper.TimeFormatType.ACTIVITY) + if self.TxtOnSaleTime then + self.TxtOnSaleTime.text = CS.XTextManager.GetText("TimeOnSale", dataTime) + end + if SaleTime <= 0 then + self:RemoveOnSaleTimer() + if self.TxtOnSaleTime then + self.TxtOnSaleTime.gameObject:SetActiveEx(false) + end + self.IsShopOnSaleLock = false + else + self.IsShopOnSaleLock = true + end + end + + func() + + self.OnSaleTimer = XScheduleManager.ScheduleForever(function() + SaleTime = SaleTime - 1 + func() + end, 1000) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiShop/XUiGridShop.lua b/Resources/Scripts/XUi/XUiShop/XUiGridShop.lua new file mode 100644 index 00000000..a83cb580 --- /dev/null +++ b/Resources/Scripts/XUi/XUiShop/XUiGridShop.lua @@ -0,0 +1,417 @@ +XUiGridShop = XClass(nil, "XUiGridShop") + +local Application = CS.UnityEngine.Application +local Platform = Application.platform +local RuntimePlatform = CS.UnityEngine.RuntimePlatform + +function XUiGridShop:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:InitAutoScript() + self.PanelPrice = { + self.PanelPrice1, + self.PanelPrice2, + self.PanelPrice3 + } + self.Timer = nil +end + +function XUiGridShop:Init(parent, rootUi) + self.Parent = parent + self.RootUi = rootUi or parent + self.Grid = XUiGridCommon.New(self.RootUi, self.GridCommon) +end + +function XUiGridShop:OnRecycle() + self:RemoveTimer() + self:RemoveOnSaleTimer() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiGridShop:InitAutoScript() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiGridShop:GetAutoKey(uiNode, eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiGridShop:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiGridShop:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiGridShop:AutoAddListener() + self.AutoCreateListeners = {} + XUiHelper.RegisterClickEvent(self, self.BtnCondition, self.OnBtnConditionClick) + XUiHelper.RegisterClickEvent(self, self.BtnBuy, self.OnBtnBuyClick) +end +-- auto +function XUiGridShop:OnBtnConditionClick() + if self.ConditionDesc then + XUiManager.TipError(self.ConditionDesc) + end +end + +function XUiGridShop:OnBtnBuyClick() + if not self.IsShopLock and not self.IsShopOnSaleLock then + self.Parent:UpdateBuy(self.Data, function() + self:RefreshSellOut() + self:RefreshCondition() + self:RefreshOnSales() + self:RefreshPrice() + self:RefreshBuyCount() + end) + else + if self.ShopLockDecs and self.IsShopLock then + XUiManager.TipError(self.ShopLockDecs) + return + end + if self.ShopOnSaleLockDecs and self.IsShopOnSaleLock then + XUiManager.TipError(self.ShopOnSaleLockDecs) + return + end + end +end + +function XUiGridShop:UpdateData(data,shopItemTextColor) + self.Data = data + self.ShopItemTextColor = shopItemTextColor + self:RefreshSellOut() + self:RefreshCondition() + self:RefreshCommon() + self:RefreshOnSales() + self:RefreshPrice() + self:RemoveTimer() + self:RemoveOnSaleTimer() + self:RefreshBuyCount() + self:RefreshTimer(self.Data.SelloutTime) + self:RefreshOnSaleTime(self.Data.OnSaleTime) +end + +function XUiGridShop:RefreshBuyCount() + if not self.ImgLimitLable then + return + end + + if not self.TxtLimitLable then + return + end + + if self.Data.BuyTimesLimit <= 0 then + self.TxtLimitLable.gameObject:SetActiveEx(false) + self.ImgLimitLable.gameObject:SetActiveEx(false) + else + local buynumber = self.Data.BuyTimesLimit - self.Data.TotalBuyTimes + local limitLabel = XShopConfigs.GetBuyLimitLabel(self.Data.AutoResetClockId) + local text = string.format(limitLabel, buynumber) + + self.TxtLimitLable.text = text + self.TxtLimitLable.gameObject:SetActiveEx(true) + self.ImgLimitLable.gameObject:SetActiveEx(true) + end +end + +function XUiGridShop:RefreshCondition() + if not self.BtnCondition then return end + self.BtnCondition.gameObject:SetActiveEx(false) + self.ConditionDesc = nil + local conditionIds = self.Data.ConditionIds + if not conditionIds or #conditionIds <= 0 then return end + + for _, id in pairs(conditionIds) do + local ret, desc = XConditionManager.CheckCondition(id) + if not ret then + self.BtnCondition.gameObject:SetActiveEx(true) + self.ImgSellOut.gameObject:SetActiveEx(false) + self.ConditionDesc = desc + return + end + end +end + +function XUiGridShop:RefreshSellOut() + if not self.ImgSellOut then + return + end + + if self.Data.BuyTimesLimit <= 0 then + self.ImgSellOut.gameObject:SetActiveEx(false) + else + if self.Data.TotalBuyTimes >= self.Data.BuyTimesLimit then + self.ImgSellOut.gameObject:SetActiveEx(true) + else + self.ImgSellOut.gameObject:SetActiveEx(false) + end + end +end + + +function XUiGridShop:RemoveTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end + +function XUiGridShop:RemoveOnSaleTimer() + if self.OnSaleTimer then + XScheduleManager.UnSchedule(self.OnSaleTimer) + self.OnSaleTimer = nil + end +end + +function XUiGridShop:RefreshCommon() + if self.RImgType then + self.RImgType.gameObject:SetActiveEx(false) + end + + self.Grid:Refresh(self.Data.RewardGoods, nil, true) +end + +function XUiGridShop:RefreshPrice() + local panelCount = #self.PanelPrice + for i = 1, panelCount do + self.PanelPrice[i].gameObject:SetActiveEx(false) + end + + local index = 1 + if self.Data.PayKeySuffix then + if self.PanelCountTxts and self.PanelCountTxts:Exist() then + self.PanelCountTxts.gameObject:SetActiveEx(false) + end + if self.TxtYuan and self.TxtYuan:Exist() then + self.TxtYuan.gameObject:SetActiveEx(true) + self.TxtYuan.text = self:GetPayAmount() + end + else + if self.PanelCountTxts and self.PanelCountTxts:Exist() then + self.PanelCountTxts.gameObject:SetActiveEx(true) + end + if self.TxtYuan and self.TxtYuan:Exist() then + self.TxtYuan.gameObject:SetActiveEx(false) + end + for _, count in pairs(self.Data.ConsumeList) do + if index > panelCount then + return + end + + if self["TxtOldPrice" .. index] then + if self.Sales == 100 then + self["TxtOldPrice" .. index].gameObject:SetActiveEx(false) + else + self["TxtOldPrice" .. index].text = count.Count + self["TxtOldPrice" .. index].gameObject:SetActiveEx(true) + end + end + + if self["RImgPrice" .. index] and self["RImgPrice" .. index]:Exist() then + local icon = XDataCenter.ItemManager.GetItemIcon(count.Id) + if icon ~= nil then + self["RImgPrice" .. index]:SetRawImage(icon) + end + end + + if self["TxtNewPrice" .. index] then + local needCount = math.floor(count.Count * self.Sales / 100) + self["TxtNewPrice" .. index].text = needCount + local itemCount = XDataCenter.ItemManager.GetCount(count.Id) + if itemCount < needCount then + if not self.ShopItemTextColor then + self["TxtNewPrice" .. index].color = CS.UnityEngine.Color(1, 0, 0) + else + self["TxtNewPrice" .. index].color = XUiHelper.Hexcolor2Color(self.ShopItemTextColor.CanNotBuyColor) + end + else + if not self.ShopItemTextColor then + self["TxtNewPrice" .. index].color = CS.UnityEngine.Color(0, 0, 0) + else + self["TxtNewPrice" .. index].color = XUiHelper.Hexcolor2Color(self.ShopItemTextColor.CanBuyColor) + end + end + end + + self.PanelPrice[index].gameObject:SetActiveEx(true) + index = index + 1 + end + end +end + +function XUiGridShop:GetPayAmount() + local key + if Platform == RuntimePlatform.Android then + key = string.format("%s%s", XPayConfigs.GetPlatformConfig(1), self.Data.PayKeySuffix) + else + key = string.format("%s%s", XPayConfigs.GetPlatformConfig(2), self.Data.PayKeySuffix) + end + + local payConfig = XPayConfigs.GetPayTemplate(key) + return payConfig and payConfig.Amount or 0 +end + +function XUiGridShop:RefreshOnSales() + self.OnSales = {} + self.OnSalesLongTest = {} + XTool.LoopMap(self.Data.OnSales, function(k, sales) + self.OnSales[k] = sales + table.insert(self.OnSalesLongTest, sales) + end) + + self.Sales = 100 + + if #self.OnSalesLongTest ~= 0 then + local sortedKeys = {} + for k, _ in pairs(self.OnSales) do + table.insert(sortedKeys, k) + end + table.sort(sortedKeys) + + for i = 1, #sortedKeys do + if self.Data.TotalBuyTimes >= sortedKeys[i] - 1 then + self.Sales = self.OnSales[sortedKeys[i]] + end + end + end + self:RefreshPanelSale() +end + +function XUiGridShop:RefreshPanelSale() + local hideSales = false + if self.TxtSaleRate then + if self.Data.Tags == XShopManager.ShopTags.DisCount then + if self.Sales < 100 then + self.TxtSaleRate.text = CS.XTextManager.GetText("Snap", 100 - self.Sales) + else + hideSales = true + end + end + if self.Data.Tags == XShopManager.ShopTags.TimeLimit then + self.TxtSaleRate.text = CS.XTextManager.GetText("TimeLimit") + end + if self.Data.Tags == XShopManager.ShopTags.Recommend then + self.TxtSaleRate.text = CS.XTextManager.GetText("Recommend") + end + if self.Data.Tags == XShopManager.ShopTags.HotSale then + self.TxtSaleRate.text = CS.XTextManager.GetText("HotSell") + end + if self.Data.Tags == XShopManager.ShopTags.Not or hideSales then + self.TxtSaleRate.gameObject:SetActiveEx(false) + self.TxtSaleRate.gameObject.transform.parent.gameObject:SetActiveEx(false) + else + self.TxtSaleRate.gameObject:SetActiveEx(true) + self.TxtSaleRate.gameObject.transform.parent.gameObject:SetActiveEx(true) + + end + end +end + +function XUiGridShop:RefreshTimer(time) + if not self.ImgLeftTime then + return + end + + if not self.TxtLeftTime then + return + end + + if time <= 0 then + self.TxtLeftTime.gameObject:SetActiveEx(false) + self.ImgLeftTime.gameObject:SetActiveEx(false) + return + end + + self.TxtLeftTime.gameObject:SetActiveEx(true) + self.ImgLeftTime.gameObject:SetActiveEx(true) + + local leftTime = XShopManager.GetLeftTime(time) + + local func = function() + leftTime = leftTime > 0 and leftTime or 0 + local dataTime = XUiHelper.GetTime(leftTime, XUiHelper.TimeFormatType.SHOP) + if self.TxtLeftTime then + self.TxtLeftTime.text = CS.XTextManager.GetText("TimeSoldOut", dataTime) + end + if leftTime <= 0 then + self:RemoveTimer() + if self.ImgSellOut then + self.ImgSellOut.gameObject:SetActiveEx(true) + end + end + end + + func() + + self.Timer = XScheduleManager.ScheduleForever(function() + leftTime = leftTime - 1 + func() + end, 1000) +end + + +function XUiGridShop:RefreshOnSaleTime(time) + if not self.TxtOnSaleTime then + return + end + + if time <= 0 then + self.TxtOnSaleTime.gameObject:SetActiveEx(false) + return + end + + self.TxtOnSaleTime.gameObject:SetActiveEx(true) + self.ShopOnSaleLockDecs = CS.XTextManager.GetText("ActivityBriefShopOnSaleLock") + if self.ImgLock then + self.ImgLock.gameObject:SetActiveEx(true) + end + + local SaleTime = XShopManager.GetLeftTime(time) + + local func = function() + SaleTime = SaleTime > 0 and SaleTime or 0 + local dataTime = XUiHelper.GetTime(SaleTime, XUiHelper.TimeFormatType.ACTIVITY) + if self.TxtOnSaleTime then + self.TxtOnSaleTime.text = CS.XTextManager.GetText("TimeOnSale", dataTime) + end + if SaleTime <= 0 then + self:RemoveOnSaleTimer() + if self.TxtOnSaleTime then + self.TxtOnSaleTime.gameObject:SetActiveEx(false) + end + if self.ImgLock then + self.ImgLock.gameObject:SetActiveEx(false) + end + self.IsShopOnSaleLock = false + else + self.IsShopOnSaleLock = true + end + end + + func() + + self.OnSaleTimer = XScheduleManager.ScheduleForever(function() + SaleTime = SaleTime - 1 + func() + end, 1000) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiShop/XUiPanelActivityAsset.lua b/Resources/Scripts/XUi/XUiShop/XUiPanelActivityAsset.lua new file mode 100644 index 00000000..0ed1bc34 --- /dev/null +++ b/Resources/Scripts/XUi/XUiShop/XUiPanelActivityAsset.lua @@ -0,0 +1,122 @@ +XUiPanelActivityAsset = XClass(nil, "XUiPanelActivityAsset") + +function XUiPanelActivityAsset:Ctor(ui, deleteDes, base ,hideAssetPanel, hideSkipBtn) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.DeleteDes = deleteDes + self.Base = base + self.HideAssetPanel = hideAssetPanel + self.HideSkipBtn = hideSkipBtn + self:InitAutoScript() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelActivityAsset:InitAutoScript() + XTool.InitUiObject(self) + self:AutoAddListener() +end + +function XUiPanelActivityAsset:AutoAddListener() + self.BtnClick1.CallBack = function() + self:OnBtnClick1Click() + end + self.BtnClick2.CallBack = function() + self:OnBtnClick2Click() + end + self.BtnClick3.CallBack = function() + self:OnBtnClick3Click() + end +end +-- auto +function XUiPanelActivityAsset:OnBtnClick1Click() + self:OnBtnClick(1) +end + +function XUiPanelActivityAsset:OnBtnClick2Click() + self:OnBtnClick(2) +end + +function XUiPanelActivityAsset:OnBtnClick3Click() + self:OnBtnClick(3) +end + +function XUiPanelActivityAsset:OnBtnClick(index) + if not self.ItemIds or not self.ItemIds[index] then + return + end + local item = XDataCenter.ItemManager.GetItem(self.ItemIds[index]) + local data = { + Id = self.ItemIds[index], + Count = item ~= nil and tostring(item.Count) or "0" + } + if self.QueryFunc then + local itemId = self.ItemIds[index] + data = XTool.Clone(XGoodsCommonManager.GetGoodsShowParamsByTemplateId(itemId)) + data.IsTempItemData = true + data.Count = self.QueryFunc(item) or data.Count + data.Description = XGoodsCommonManager.GetGoodsDescription(itemId) + data.WorldDesc = XGoodsCommonManager.GetGoodsWorldDesc(itemId) + end + XLuaUiManager.Open("UiTip", data, self.HideSkipBtn) +end + +function XUiPanelActivityAsset:HidePanel() + if not XTool.UObjIsNil(self.GameObject) then + self.GameObject:SetActiveEx(false) + end +end + +function XUiPanelActivityAsset:SetQueryFunc(func) + -- 用于构造本地数据时通过自定义查询器获取 + self.QueryFunc = func +end + +function XUiPanelActivityAsset:Refresh(idlist) + if XTool.UObjIsNil(self.GameObject) then + return + end + + --读取数据 + if idlist == nil then + self.GameObject:SetActive(false) + return + end + self.ItemIds = idlist + self.GameObject:SetActive(true) + for i = 1, 3 do + if i > #self.ItemIds then + self["PanelSpecialTool" .. i].gameObject:SetActive(false) + else + self["PanelSpecialTool" .. i].gameObject:SetActive(true) + end + end + + if self.HideAssetPanel and self.Base then + self.Base.AssetPanel.GameObject:SetActiveEx(not (self.PanelSpecialTool3.gameObject.activeSelf or self.PanelSpecialTool2.gameObject.activeSelf or self.PanelSpecialTool1.gameObject.activeSelf)) + end + self.PanelSpecialTool.gameObject:SetActiveEx(self.PanelSpecialTool3.gameObject.activeSelf or self.PanelSpecialTool2.gameObject.activeSelf or self.PanelSpecialTool1.gameObject.activeSelf) + + local items = {} + for _, id in pairs(self.ItemIds) do + table.insert(items, XDataCenter.ItemManager.GetItem(id)) + end + + for i = 1, #items do + local item = items[i] + local count = item ~= nil and tostring(item.Count) or "0" + if self.QueryFunc then + count = self.QueryFunc(item) or count + end + self["PanelSpecialTool" .. i].gameObject:SetActive(true) + self["TxtSpecialTool" .. i].text = not self.DeleteDes and CS.XTextManager.GetText("ShopActivityItemCount", count) or count + if items[i].Template.ItemType == 2 then + self["TxtSpecialTool" .. i].text = count .. "/" .. XDataCenter.ItemManager.GetMaxActionPoints() + end + + local rImgSpecialTool = self["RImgSpecialTool" .. i] + if rImgSpecialTool and rImgSpecialTool:Exist() then + rImgSpecialTool:SetRawImage(items[i].Template.Icon) + end + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiShop/XUiPanelFashionList.lua b/Resources/Scripts/XUi/XUiShop/XUiPanelFashionList.lua new file mode 100644 index 00000000..621a2bd6 --- /dev/null +++ b/Resources/Scripts/XUi/XUiShop/XUiPanelFashionList.lua @@ -0,0 +1,101 @@ +XUiPanelFashionList = XClass(nil, "XUiPanelFashionList") + +function XUiPanelFashionList:Ctor(ui, parent,rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Ui = ui + self.Parent = parent + self.RootUi = rootUi or parent + self.GoodsList = {} + self.GoodsContainer = {} + self:SetCountUpdateListener() + self:Init() +end + +function XUiPanelFashionList:SetCountUpdateListener() + XDataCenter.ItemManager.AddCountUpdateListener(XDataCenter.ItemManager.ItemId.FreeGem, function() self:RefreshGoodsPrice() end, self.Ui) + XDataCenter.ItemManager.AddCountUpdateListener(XDataCenter.ItemManager.ItemId.Coin,function() self:RefreshGoodsPrice() end, self.Ui) +end + +function XUiPanelFashionList:RefreshGoodsPrice() + for _,v in pairs(self.DynamicTable:GetGrids()) do + v:RefreshPrice() + end +end + +function XUiPanelFashionList:Init() + XTool.InitUiObject(self) + self.DynamicTable = XDynamicTableNormal.New(self.Transform) + self.DynamicTable:SetProxy(XUiGridFashionShop) + self.DynamicTable:SetDelegate(self) +end + +function XUiPanelFashionList:HidePanel() + if not XTool.UObjIsNil(self.GameObject) then + self.GameObject:SetActiveEx(false) + end + XEventManager.RemoveEventListener(XEventId.EVENT_SHOP_BUYUSERIYUAN, self.ShowPanel, self) +end + +function XUiPanelFashionList:ShowPanel(id) + self.GameObject:SetActive(true) + XEventManager.AddEventListener(XEventId.EVENT_SHOP_BUYUSERIYUAN, self.ShowPanel, self) + self.GoodsList = XShopManager.GetShopGoodsList(id) + + self:ShowGoods() + self.DynamicTable:SetDataSource(self.GoodsList) + self.DynamicTable:ReloadDataASync() +end + +function XUiPanelFashionList:ShowScreenPanel(shopId,groupId,selectTag) + local shopShowTypeCfg = XShopConfigs.GetShopShowTypeTemplateById(shopId) + if shopShowTypeCfg and shopShowTypeCfg.ShowType == XShopConfigs.ShowType.Fashion then + self.GameObject:SetActive(true) + self.GoodsList = XShopManager.GetScreenGoodsListByTag(shopId,groupId,selectTag) + + self:ShowGoods() + XEventManager.AddEventListener(XEventId.EVENT_SHOP_BUYUSERIYUAN, self.ShowPanel, self) + self.DynamicTable:SetDataSource(self.GoodsList) + self.DynamicTable:ReloadDataASync() + else + self:HidePanel() + end +end + + +--动态列表事件 +function XUiPanelFashionList:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self.Parent,self.RootUi) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.GoodsList[index] + grid:UpdateData(data) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_RECYCLE then + grid:OnRecycle() + end +end + +--初始化列表 +function XUiPanelFashionList:ShowGoods() + --商品数量显示 + if not self.GoodsList or #self.GoodsList <= 0 then + self.TxtDesc.gameObject:SetActive(true) + self.TxtHint.text = CS.XTextManager.GetText("ShopNoGoodsDesc") + else + self.TxtDesc.gameObject:SetActive(false) + self.TxtHint.text = "" + end + + --self:UpdateGoods() +end + +--更新商品信息 +function XUiPanelFashionList:UpdateGoods(goodsId) + for k, v in pairs(self.GoodsList) do + if v.Id == goodsId then + local grid = self.DynamicTable:GetGridByIndex(k) + grid:UpdateData(v) + end + end +end + diff --git a/Resources/Scripts/XUi/XUiShop/XUiPanelItemList.lua b/Resources/Scripts/XUi/XUiShop/XUiPanelItemList.lua new file mode 100644 index 00000000..67eec9d6 --- /dev/null +++ b/Resources/Scripts/XUi/XUiShop/XUiPanelItemList.lua @@ -0,0 +1,99 @@ +XUiPanelItemList = XClass(nil, "XUiPanelItemList") + +function XUiPanelItemList:Ctor(ui, parent,rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Ui = ui + self.Parent = parent + self.RootUi = rootUi or parent + self.GoodsList = {} + self.GoodsContainer = {} + self:SetCountUpdateListener() + self:Init() +end + +function XUiPanelItemList:SetCountUpdateListener() + XDataCenter.ItemManager.AddCountUpdateListener(XDataCenter.ItemManager.ItemId.FreeGem, function() self:RefreshGoodsPrice() end, self.Ui) + XDataCenter.ItemManager.AddCountUpdateListener(XDataCenter.ItemManager.ItemId.Coin,function() self:RefreshGoodsPrice() end, self.Ui) +end + +function XUiPanelItemList:RefreshGoodsPrice() + for _,v in pairs(self.DynamicTable:GetGrids()) do + v:RefreshPrice() + end +end + +function XUiPanelItemList:Init() + XTool.InitUiObject(self) + self.DynamicTable = XDynamicTableNormal.New(self.Transform) + self.DynamicTable:SetProxy(XUiGridShop) + self.DynamicTable:SetDelegate(self) +end + +function XUiPanelItemList:HidePanel() + if not XTool.UObjIsNil(self.GameObject) then + self.GameObject:SetActiveEx(false) + end + XEventManager.RemoveEventListener(XEventId.EVENT_SHOP_BUYUSERIYUAN, self.ShowPanel, self) +end + +function XUiPanelItemList:ShowPanel(id) + self.GameObject:SetActive(true) + self.GoodsList = XShopManager.GetShopGoodsList(id) + XEventManager.AddEventListener(XEventId.EVENT_SHOP_BUYUSERIYUAN, self.ShowPanel, self) + self:ShowGoods() + self.DynamicTable:SetDataSource(self.GoodsList) + self.DynamicTable:ReloadDataASync() +end + +function XUiPanelItemList:ShowScreenPanel(shopId,groupId,selectTag) + local shopShowTypeCfg = XShopConfigs.GetShopShowTypeTemplateById(shopId) + if not shopShowTypeCfg or shopShowTypeCfg.ShowType == XShopConfigs.ShowType.Normal then + self.GameObject:SetActive(true) + self.GoodsList = XShopManager.GetScreenGoodsListByTag(shopId,groupId,selectTag) + self:ShowGoods() + self.DynamicTable:SetDataSource(self.GoodsList) + self.DynamicTable:ReloadDataASync() + XEventManager.AddEventListener(XEventId.EVENT_SHOP_BUYUSERIYUAN, self.ShowPanel, self) + else + self:HidePanel() + end +end + + +--动态列表事件 +function XUiPanelItemList:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self.Parent,self.RootUi) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.GoodsList[index] + grid:UpdateData(data) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_RECYCLE then + grid:OnRecycle() + end +end + +--初始化列表 +function XUiPanelItemList:ShowGoods() + --商品数量显示 + if not self.GoodsList or #self.GoodsList <= 0 then + self.TxtDesc.gameObject:SetActive(true) + self.TxtHint.text = CS.XTextManager.GetText("ShopNoGoodsDesc") + else + self.TxtDesc.gameObject:SetActive(false) + self.TxtHint.text = "" + end + + --self:UpdateGoods() +end + +--更新商品信息 +function XUiPanelItemList:UpdateGoods(goodsId) + for k, v in pairs(self.GoodsList) do + if v.Id == goodsId then + local grid = self.DynamicTable:GetGridByIndex(k) + grid:UpdateData(v) + end + end +end + diff --git a/Resources/Scripts/XUi/XUiShop/XUiPanelShopItem.lua b/Resources/Scripts/XUi/XUiShop/XUiPanelShopItem.lua new file mode 100644 index 00000000..4c46c506 --- /dev/null +++ b/Resources/Scripts/XUi/XUiShop/XUiPanelShopItem.lua @@ -0,0 +1,553 @@ +XUiPanelShopItem = XClass(nil, "XUiPanelShopItem") + +local MAX_COUNT = CS.XGame.Config:GetInt("ShopBuyGoodsCountLimit") +function XUiPanelShopItem:Ctor(ui, parent, rootUi, isActivityShop) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.IsActivityShop = isActivityShop + self.Parent = parent + self.RootUi = rootUi or parent + self:InitAutoScript() + self:SetSelectTextData() + self.Grid = XUiGridCommon.New(self.RootUi, self.GridBuyCommon) + self.Price = {} + table.insert(self.Price, self.PanelCostItem1) + table.insert(self.Price, self.PanelCostItem2) + table.insert(self.Price, self.PanelCostItem3) + + self.WgtBtnAddSelect = self.BtnAddSelect.gameObject:GetComponent("XUiPointer") + self.WgtBtnMinusSelect = self.BtnMinusSelect.gameObject:GetComponent("XUiPointer") + + XUiButtonLongClick.New(self.WgtBtnAddSelect, 100, self, nil, self.BtnAddSelectLongClickCallback, nil, true) + XUiButtonLongClick.New(self.WgtBtnMinusSelect, 100, self, nil, self.BtnMinusSelectLongClickCallback, nil, true) + + self.MinCount = 1 +end + +local Application = CS.UnityEngine.Application +local Platform = Application.platform +local RuntimePlatform = CS.UnityEngine.RuntimePlatform + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelShopItem:InitAutoScript() + --self:AutoInitUi() + XTool.InitUiObject(self) + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiPanelShopItem:AutoInitUi() +--[[self.BtnBlock = self.Transform:Find("BtnBlock"):GetComponent("Button") + self.GridBuyCommon = self.Transform:Find("GameObject/GridBuyCommon") + self.ImgQuality = self.Transform:Find("GameObject/GridBuyCommon/ImgQuality"):GetComponent("Image") + self.RImgIcon = self.Transform:Find("GameObject/GridBuyCommon/RImgIcon"):GetComponent("RawImage") + self.RImgType = self.Transform:Find("GameObject/GridBuyCommon/RImgType"):GetComponent("RawImage") + self.TxtCount = self.Transform:Find("GameObject/GridBuyCommon/TxtCount"):GetComponent("Text") + self.TxtOwnCount = self.Transform:Find("GameObject/GridBuyCommon/TxtOwnCount"):GetComponent("Text") + self.PanelPrice = self.Transform:Find("GameObject/Count/PanelPrice") + self.PanelCostItem1 = self.Transform:Find("GameObject/Count/PanelPrice/PanelCostItem1") + self.RImgCostIcon1 = self.Transform:Find("GameObject/Count/PanelPrice/PanelCostItem1/RImgCostIcon1"):GetComponent("RawImage") + self.TxtCostCount1 = self.Transform:Find("GameObject/Count/PanelPrice/PanelCostItem1/TxtCostCount1"):GetComponent("Text") + self.PanelCostItem2 = self.Transform:Find("GameObject/Count/PanelPrice/PanelCostItem2") + self.RImgCostIcon2 = self.Transform:Find("GameObject/Count/PanelPrice/PanelCostItem2/RImgCostIcon2"):GetComponent("RawImage") + self.TxtCostCount2 = self.Transform:Find("GameObject/Count/PanelPrice/PanelCostItem2/TxtCostCount2"):GetComponent("Text") + self.PanelCostItem3 = self.Transform:Find("GameObject/Count/PanelPrice/PanelCostItem3") + self.RImgCostIcon3 = self.Transform:Find("GameObject/Count/PanelPrice/PanelCostItem3/RImgCostIcon3"):GetComponent("RawImage") + self.TxtCostCount3 = self.Transform:Find("GameObject/Count/PanelPrice/PanelCostItem3/TxtCostCount3"):GetComponent("Text") + self.BtnAddSelect = self.Transform:Find("GameObject/BtnAddSelect"):GetComponent("Button") + self.BtnMinusSelect = self.Transform:Find("GameObject/BtnMinusSelect"):GetComponent("Button") + self.BtnMax = self.Transform:Find("GameObject/BtnMax"):GetComponent("Button") + self.TxtCanBuy = self.Transform:Find("GameObject/TxtCanBuy"):GetComponent("Text") + self.TxtSelect = self.Transform:Find("GameObject/TxtSelect"):GetComponent("InputField") + self.BtnUse = self.Transform:Find("GameObject/BtnUse"):GetComponent("Button")]] +end + +function XUiPanelShopItem:GetAutoKey(uiNode, eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiPanelShopItem:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiPanelShopItem:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiPanelShopItem:AutoAddListener() + self.AutoCreateListeners = {} + XUiHelper.RegisterClickEvent(self, self.BtnBlock, self.OnBtnBlockClick) + XUiHelper.RegisterClickEvent(self, self.BtnMaxBtnMax, self.OnBtnMaxClick) + + if self.UiBtnMax then + self.UiBtnMax.CallBack = function() + self:OnBtnMaxClick() + end + end + + if self.BtnUse then + self.BtnUse.CallBack = function() + self:OnBtnUseClick() + end + end + + if self.BtnAddSelect then + self.BtnAddSelect.CallBack = function() + self:OnBtnAddSelectClick() + end + end + + if self.BtnMinusSelect then + self.BtnMinusSelect.CallBack = function() + self:OnBtnMinusSelectClick() + end + end + + self.TxtSelect.onValueChanged:AddListener(function() + self:OnSelectTextChange() + end) + + self.TxtSelect.onEndEdit:AddListener(function() + self:OnSelectTextInputEnd() + end) + + if self.BtnTanchuangClose then + self.BtnTanchuangClose.CallBack = function() + self:OnBtnBlockClick() + end + end +end + +function XUiPanelShopItem:SetSelectTextData() + self.TxtSelect.characterLimit = 4 + self.TxtSelect.contentType = CS.UnityEngine.UI.InputField.ContentType.IntegerNumber +end + +-- auto +function XUiPanelShopItem:OnBtnBlockClick() + self.GameObject:SetActiveEx(false) +end + +function XUiPanelShopItem:OnBtnAddSelectClick() + + + + if self.Count + 1 > self.MaxCount then + XDataCenter.EquipManager.ShowBoxOverLimitText() + return + end + self.Count = self.Count + 1 + self:RefreshConsumes() + self:JudgeBuy() + self.TxtSelect.text = self.Count + self:SetCanAddOrMinusBtn() +end + +function XUiPanelShopItem:OnBtnMinusSelectClick() + if self.Count - 1 < self.MinCount then + return + end + self.Count = self.Count - 1 + self:RefreshConsumes() + self:JudgeBuy() + self.TxtSelect.text = self.Count + self:SetCanAddOrMinusBtn() +end + +function XUiPanelShopItem:BtnAddSelectLongClickCallback(time) + if self.Count + 1 > self.MaxCount then + XDataCenter.EquipManager.ShowBoxOverLimitText() + return + end + + local delta = math.max(0, math.floor(time / 150)) + self.Count = self.Count + delta + if self.MaxCount and self.Count >= self.MaxCount then + self.Count = self.MaxCount + end + + self:RefreshConsumes() + self:JudgeBuy() + self.TxtSelect.text = self.Count + self:SetCanAddOrMinusBtn() +end + +function XUiPanelShopItem:BtnMinusSelectLongClickCallback(time) + if self.Count - 1 < self.MinCount then + return + end + local delta = math.max(0, math.floor(time / 150)) + self.Count = self.Count - delta + if self.Count <= 0 then + self.Count = 0 + end + self:RefreshConsumes() + self:JudgeBuy() + self.TxtSelect.text = self.Count + self:SetCanAddOrMinusBtn() +end + + + +function XUiPanelShopItem:OnBtnMaxClick() + if self.Count == self.MaxCount then + return + end + self.Count = math.min(self.MaxCount, self.CanBuyCount) + self:RefreshConsumes() + self:JudgeBuy() + self.TxtSelect.text = self.Count + self:SetCanAddOrMinusBtn() +end + +function XUiPanelShopItem:OnSelectTextChange() + if self.TxtSelect.text == nil or self.TxtSelect.text == "" then + return + end + if self.TxtSelect.text == "0" then + self.TxtSelect.text = 1 + end + local tmp = tonumber(self.TxtSelect.text) + local tmpMax = math.max(math.min(MAX_COUNT, self.MaxCount), 1) + if tmp > tmpMax then + tmp = tmpMax + self.TxtSelect.text = tmp + end + self.Count = tmp + self:RefreshConsumes() + self:JudgeBuy() +end + +function XUiPanelShopItem:OnSelectTextInputEnd() + if self.TxtSelect.text == nil or self.TxtSelect.text == "" then + self.TxtSelect.text = 1 + local tmp = tonumber(self.TxtSelect.text) + self.Count = tmp + self:RefreshConsumes() + self:JudgeBuy() + end +end + +function XUiPanelShopItem:SetCanAddOrMinusBtn() + self.BtnMinusSelect.interactable = self.Count > self.MinCount + self.BtnAddSelect.interactable = self.MaxCount > self.Count + + if self.BtnMax then + self.BtnMax.gameObject:GetComponent("Image").color = self.MaxCount > 1 and CS.UnityEngine.Color(1, 1, 1, 1) or CS.UnityEngine.Color(1, 1, 1, 0.8) + self.BtnMax.interactable = self.MaxCount > 1 + end + + if self.UiBtnMax then + self.UiBtnMax:SetDisable(self.MaxCount <= 1) + end + + if self.PanelTxt then + self.PanelTxt.gameObject:SetActiveEx(self.MaxCount < MAX_COUNT) + end + + if self.BuyHintText then + self.BuyHintText.gameObject:SetActiveEx(self.MaxCount < MAX_COUNT) + end + + if self.TxtCanBuy then + self.TxtCanBuy.gameObject:SetActiveEx(self.MaxCount < MAX_COUNT) + self.TxtCanBuy.text = self.MaxCount + end +end + +function XUiPanelShopItem:OnBtnUseClick() + if not XDataCenter.PayManager.CheckCanBuy(self.Data.Id) then + return + end + if self.HaveNotBuyCount then + if not XDataCenter.EquipManager.ShowBoxOverLimitText() then + XUiManager.TipText("ShopHaveNotBuyCount") + end + return + end + + if not self.Data.PayKeySuffix then + for k,v in pairs(self.NotEnough or {}) do + if not XDataCenter.ItemManager.DoNotEnoughBuyAsset(v.ItemId, + v.UseItemCount, + 1, + function() + self:OnBtnUseClick() + end, + "BuyNeedItemInsufficient") then + return + end + self.NotEnough[k] = nil + end + end + + local func = function() + self.Cb(self.Count) + XUiManager.TipText("BuySuccess") + self.Parent:RefreshBuy() + self.GameObject:SetActiveEx(false) + end + if self.Data.PayKeySuffix then + local key + if Platform == RuntimePlatform.Android then + key = string.format("%s%s", XPayConfigs.GetPlatformConfig(1), self.Data.PayKeySuffix) + else + key = string.format("%s%s", XPayConfigs.GetPlatformConfig(2), self.Data.PayKeySuffix) + end + XDataCenter.PayManager.Pay(key, 2, { self.Parent:GetCurShopId(), self.Data.Id }, self.Data.Id, function() + self.GameObject:SetActiveEx(false) + end) + else + XShopManager.BuyShop(self.Parent:GetCurShopId(), self.Data.Id, self.Count, func) + end +end + +function XUiPanelShopItem:ShowPanel(data, cb) + if data then + self.Data = data + else + return + end + + if cb then + self.Cb = cb + end + + self.Count = 1 + self.Consumes = {} + self.BuyConsumes = {} + + XTool.LoopMap(self.Data.ConsumeList, function(_, consume) + local buyitem = {} + buyitem.Id = consume.Id + buyitem.Count = consume.Count + table.insert(self.Consumes, buyitem) + local consumes = {} + consumes.Id = consume.Id + consumes.Count = 0 + table.insert(self.BuyConsumes, consumes) + end) + + self:RefreshCommon() + self:RefreshPrice() + self:GetSalesInfo() + self:GetMaxCount() + self:RefreshConsumes() + self:SetCanBuyCount() + self:JudgeBuy() + self:HaveItem() + self:SetCanAddOrMinusBtn() + self.GameObject:SetActiveEx(true) + self.TxtSelect.text = self.Count +end + +function XUiPanelShopItem:HaveItem() + if XArrangeConfigs.GetType(self.Data.RewardGoods.TemplateId) == XArrangeConfigs.Types.Furniture then + self.TxtOwnCount.gameObject:SetActiveEx(false) + else + local count = XGoodsCommonManager.GetGoodsCurrentCount(self.Data.RewardGoods.TemplateId) + self.TxtOwnCount.text = CS.XTextManager.GetText("CurrentlyHas", count) + self.TxtOwnCount.gameObject:SetActiveEx(true) + end +end + +function XUiPanelShopItem:RefreshCommon() + self.RImgType.gameObject:SetActiveEx(false) + + local rewardGoods = self.Data.RewardGoods + self.Grid:Refresh(rewardGoods, nil, true) + self.Grid:ShowCount(true) +end + +function XUiPanelShopItem:RefreshPrice() + if self.TxtYuan then + self.TxtYuan.gameObject:SetActiveEx(false) + end + if self.Data.PayKeySuffix then + self.PanelPrice.gameObject:SetActiveEx(false) + if self.TxtYuan then + self.TxtYuan.gameObject:SetActiveEx(true) + self.TxtYuan.text = self:GetPayAmount() + end + else + if self.TxtYuan then + self.TxtYuan.gameObject:SetActiveEx(false) + end + if #self.Consumes ~= 0 then + self.PanelPrice.gameObject:SetActiveEx(true) + for i = 1, #self.Price do + if i <= #self.Consumes then + self.Price[i].gameObject:SetActiveEx(true) + else + self.Price[i].gameObject:SetActiveEx(false) + end + end + else + self.PanelPrice.gameObject:SetActiveEx(false) + end + end +end + +function XUiPanelShopItem:GetPayAmount() + local key + if Platform == RuntimePlatform.Android then + key = string.format("%s%s", XPayConfigs.GetPlatformConfig(1), self.Data.PayKeySuffix) + else + key = string.format("%s%s", XPayConfigs.GetPlatformConfig(2), self.Data.PayKeySuffix) + end + + local payConfig = XPayConfigs.GetPayTemplate(key) + return payConfig and payConfig.Amount or 0 +end + +function XUiPanelShopItem:RefreshOnSales(buyCount) + self.OnSales = {} + XTool.LoopMap(self.Data.OnSales, function(k, sales) + self.OnSales[k] = sales + end) + local sumbuy = buyCount + self.Data.TotalBuyTimes + if #self.OnSales ~= 0 then + local curLevel = 0 + for k, v in pairs(self.OnSales) do + if sumbuy >= k and k > curLevel then + self.Sales = v + curLevel = k + end + end + else + self.Sales = 100 + end +end + +function XUiPanelShopItem:RefreshConsumes() + for i = 1, #self.BuyConsumes do + self.BuyConsumes[i].Count = 0 + end + for k, v in pairs(self.Consumes) do + self.BuyConsumes[k].Id = v.Id + self.BuyConsumes[k].Count = math.floor(v.Count * self.Sales / 100) * self.Count + end + for i = 1, #self.Consumes do + self["RImgCostIcon" .. i]:SetRawImage(XDataCenter.ItemManager.GetItemBigIcon(self.BuyConsumes[i].Id)) + self["TxtCostCount" .. i].text = math.floor(self.BuyConsumes[i].Count) + end +end + +function XUiPanelShopItem:HidePanel() + if not XTool.UObjIsNil(self.GameObject) then + self.GameObject:SetActiveEx(false) + end +end + + +function XUiPanelShopItem:GetSalesInfo() + self.OnSales = {} + XTool.LoopMap(self.Data.OnSales, function(k, sales) + self.OnSales[k] = sales + end) +end + +function XUiPanelShopItem:GetMaxCount() + self.Sales = 100 + local sortedKeys = {} + for k, _ in pairs(self.OnSales) do + table.insert(sortedKeys, k) + end + table.sort(sortedKeys) + + local leftSalesGoods = MAX_COUNT + + for i = 1, #sortedKeys do + if self.Data.TotalBuyTimes >= sortedKeys[i] - 1 then + self.Sales = self.OnSales[sortedKeys[i]] + else + leftSalesGoods = sortedKeys[i] - self.Data.TotalBuyTimes - 1 + break + end + end + + local leftShopTimes = XShopManager.GetShopLeftBuyTimes(self.Parent:GetCurShopId()) + if not leftShopTimes then + leftShopTimes = MAX_COUNT + end + + local leftGoodsTimes = MAX_COUNT + if self.Data.BuyTimesLimit and self.Data.BuyTimesLimit > 0 then + local buyCount = self.Data.TotalBuyTimes and self.Data.TotalBuyTimes or 0 + leftGoodsTimes = self.Data.BuyTimesLimit - buyCount + end + local tmpMaxCount = math.min(leftGoodsTimes, math.min(leftShopTimes, leftSalesGoods)) + self.MaxCount = tmpMaxCount + self.MaxCount = XDataCenter.EquipManager.GetMaxCountOfBoxOverLimit(self.Data.RewardGoods.TemplateId, self.MaxCount, self.Data.RewardGoods.Count) + + if self.MaxCount < tmpMaxCount then + self.BuyHintText.text = CS.XTextManager.GetText("MaxCanBuyText") + else + self.BuyHintText.text = CS.XTextManager.GetText("CanBuyText") + end +end + +function XUiPanelShopItem:SetCanBuyCount() + local canBuyCount = self.MaxCount + for _, v in pairs(self.BuyConsumes) do + local itemCount = XDataCenter.ItemManager.GetCount(v.Id) + local buyCount = math.floor(itemCount / v.Count) + canBuyCount = math.min(buyCount, canBuyCount) + end + canBuyCount = math.max(self.MinCount, canBuyCount) + self.CanBuyCount = canBuyCount +end + +function XUiPanelShopItem:JudgeBuy() + self.HaveNotBuyCount = self.Count > self.MaxCount or self.Count == 0 + if self.HaveNotBuyCount then + return + end + + local index = 1 + local enoughIndex = {} + self.NotEnough = {} + + for _, v in pairs(self.BuyConsumes) do + local itemCount = XDataCenter.ItemManager.GetCount(v.Id) + if v.Count > itemCount then + self:ChangeCostColor(false, index) + if not self.NotEnough[index] then self.NotEnough[index] = {} end + self.NotEnough[index].ItemId = v.Id + self.NotEnough[index].UseItemCount = v.Count + else + table.insert(enoughIndex, index) + end + index = index + 1 + end + + for _, v in pairs(enoughIndex) do + self:ChangeCostColor(true, v) + end +end + + +function XUiPanelShopItem:ChangeCostColor(bool, index) + if bool then + self["TxtCostCount" .. index].color = CS.UnityEngine.Color(0, 0, 0) + else + self["TxtCostCount" .. index].color = CS.UnityEngine.Color(1, 0, 0) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiShop/XUiPanelShopPeriod.lua b/Resources/Scripts/XUi/XUiShop/XUiPanelShopPeriod.lua new file mode 100644 index 00000000..b3b03e80 --- /dev/null +++ b/Resources/Scripts/XUi/XUiShop/XUiPanelShopPeriod.lua @@ -0,0 +1,182 @@ +XUiPanelShopPeriod = XClass(nil, "XUiPanelShopPeriod") + +function XUiPanelShopPeriod:Ctor(ui, parent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Parent = parent + self:InitAutoScript() + self.RefShopTime = nil + self.CloseTimer = nil +end + +function XUiPanelShopPeriod:InitAutoScript() + XTool.InitUiObject(self) + self:AutoAddListener() +end + +function XUiPanelShopPeriod:AutoAddListener() + self.BtnRefresh.CallBack = function() + self:OnBtnRefreshClick() + end +end +-- auto +function XUiPanelShopPeriod:OnBtnRefreshClick() + XShopManager.RefreshShopGoods(self.ShopId, function() + self:UpdateManualRefreshInfo() + self.Parent:RefreshBuy(false) + end) + self.Parent:PlayAnimation("AnimQieHuan") +end + +function XUiPanelShopPeriod:HidePanel() + self.ShopId = nil + self:RemoveTimer() + if not XTool.UObjIsNil(self.GameObject) then + self.GameObject:SetActiveEx(false) + end +end + +function XUiPanelShopPeriod:RemoveTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + end +end + +function XUiPanelShopPeriod:ShowPanel(shopId) + if shopId then + self.ShopId = shopId + end + + self:UpdateShopBuyInfo() + self:UpdateManualRefreshInfo() + self:RemoveTimer() + self:ShowTimer() + self:SetPanelActive() + self.GameObject:SetActive(true) +end + +function XUiPanelShopPeriod:UpdateManualRefreshInfo() + local costInfo = XShopManager.GetManualRefreshCost(self.ShopId) + if not costInfo or not costInfo.ManualResetTimesLimit then + self.BtnRefresh.gameObject:SetActive(false) + return + end + + if costInfo.RefreshCostId and costInfo.RefreshCostId > 0 and + costInfo.RefreshCostCount and costInfo.RefreshCostCount > 0 then + self.TxtRefAsset.text = costInfo.RefreshCostCount + self.RImgRef:SetRawImage(XDataCenter.ItemManager.GetItemIcon(costInfo.RefreshCostId)) + self.TxtRefAsset.gameObject:SetActive(true) + self.RImgRef.gameObject:SetActive(true) + else + self.TxtRefAsset.gameObject:SetActive(false) + self.RImgRef.gameObject:SetActive(false) + end + + if costInfo.ManualResetTimesLimit == - 1 then + self.TxtContent.gameObject:SetActive(false) + else + local leftTimes = costInfo.ManualResetTimesLimit - costInfo.ManualRefreshTimes + self.TxtContent.text = CS.XTextManager.GetText("ShopResetTimes", leftTimes, costInfo.ManualResetTimesLimit) + self.TxtContent.gameObject:SetActive(true) + end + self.BtnRefresh.gameObject:SetActive(true) +end + +function XUiPanelShopPeriod:UpdateShopBuyInfo() + local buyInfo = XShopManager.GetShopBuyInfo(self.ShopId) + if not buyInfo then + self.TxtAllLeftCout.gameObject:SetActive(false) + return + end + + if not buyInfo.BuyTimesLimit or buyInfo.BuyTimesLimit == 0 then + self.TxtAllLeftCout.gameObject:SetActive(false) + else + local buyCount = buyInfo.TotalBuyTimes and buyInfo.BuyTimesLimit - buyInfo.TotalBuyTimes or buyInfo.BuyTimesLimit + self.TxtAllLeftCout.text = CS.XTextManager.GetText("BuyCount", buyCount, buyInfo.BuyTimesLimit) + self.TxtAllLeftCout.gameObject:SetActive(true) + end +end + +--开始倒计时时间 +function XUiPanelShopPeriod:ShowTimer() + self.TxtLeftTime.gameObject:SetActive(false) + self.TxtRefreshTime.gameObject:SetActive(false) + local timeInfo = XShopManager.GetShopTimeInfo(self.ShopId) + + if not timeInfo or not next(timeInfo) then + return + end + + local refreshFunc, closedFunc + + if timeInfo.RefreshLeftTime and timeInfo.RefreshLeftTime > 0 then + refreshFunc = function() + local dataTime = XUiHelper.GetTime(timeInfo.RefreshLeftTime, XUiHelper.TimeFormatType.SHOP) + self.TxtRefreshTime.text = CS.XTextManager.GetText("ShopAutoRefresh") .. dataTime + timeInfo.RefreshLeftTime = timeInfo.RefreshLeftTime - 1 + + if timeInfo.RefreshLeftTime < 0 then + refreshFunc = nil + end + end + end + + if timeInfo.ClosedLeftTime and timeInfo.ClosedLeftTime > 0 then + closedFunc = function() + local dataTime = XUiHelper.GetTime(timeInfo.ClosedLeftTime, XUiHelper.TimeFormatType.SHOP) + self.TxtLeftTime.text = CS.XTextManager.GetText("ActiveTime", dataTime) + timeInfo.ClosedLeftTime = timeInfo.ClosedLeftTime - 1 + + if timeInfo.ClosedLeftTime < 0 then + closedFunc = nil + end + end + end + + if not refreshFunc and not closedFunc then + return + end + + if refreshFunc then + refreshFunc() + self.TxtRefreshTime.gameObject:SetActive(true) + end + + if closedFunc then + closedFunc() + self.TxtLeftTime.gameObject:SetActive(true) + end + + self.Timer = XScheduleManager.ScheduleForever(function() + if timeInfo.ClosedLeftTime and not closedFunc then + self:RemoveTimer() + XShopManager.GetShopInfo(self.ShopId, function() + self.Parent:RefreshBuy(false) + end) + return + end + if timeInfo.RefreshLeftTime and not refreshFunc then + self:RemoveTimer() + XShopManager.GetShopInfo(self.ShopId, function() + self.Parent:RefreshBuy(false) + self:ShowTimer() + end) + return + end + + + if refreshFunc then + refreshFunc() + end + + if closedFunc then + closedFunc() + end + end, 1000) +end + +function XUiPanelShopPeriod:SetPanelActive() + self.PanelTxt.gameObject:SetActive(self.TxtLeftTime.gameObject.activeSelf or self.TxtAllLeftCout.gameObject.activeSelf or self.TxtRefreshTime.gameObject.activeSelf or self.BtnRefresh.gameObject.activeSelf) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiShop/XUiShop.lua b/Resources/Scripts/XUi/XUiShop/XUiShop.lua new file mode 100644 index 00000000..a2506236 --- /dev/null +++ b/Resources/Scripts/XUi/XUiShop/XUiShop.lua @@ -0,0 +1,367 @@ +local XUiShop = XLuaUiManager.Register(XLuaUi, "UiShop") +local Dropdown = CS.UnityEngine.UI.Dropdown +local type = type +local DEFAULT_TOG_INDEX = 1 + +function XUiShop:OnAwake() + self:InitAutoScript() +end + +function XUiShop:OnStart(typeId, cb, configShopId) + + if type(typeId) == "function" then + cb = typeId + typeId = nil + end + + if typeId then + self.Type = typeId + else + self.Type = XShopManager.ShopType.Common + end + + self.cb = cb + self.ConfigShopId = configShopId + + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self.AssetActivityPanel = XUiPanelActivityAsset.New(self.PanelActivityAsset,nil,self,true) + self.ItemList = XUiPanelItemList.New(self.PanelItemList, self) + self.FashionList = XUiPanelFashionList.New(self.PanelFashionList, self) + self.ShopPeriod = XUiPanelShopPeriod.New(self.PanelShopPeriod, self) + + self.AssetActivityPanel:HidePanel() + self.ItemList:HidePanel() + self.FashionList:HidePanel() + self.ShopPeriod:HidePanel() + + self.CallSerber = false + self.BtnGoList = {} + self.ShopTables = {} + self.tagCount = 1 + self.shopGroup = {} + + self.BtnFirst.gameObject:SetActiveEx(false) + self.BtnSecond.gameObject:SetActiveEx(false) + + self.ScreenGroupIDList = {} + self.ScreenNum = 1 + self.IsHasScreen = false + + XShopManager.ClearBaseInfoData() + + XShopManager.GetBaseInfo(function() + self:SetShopBtn(self.Type) + self:UpdateTog() + end) + + self:SetTitleName(typeId) +end +-- auto +-- Automatic generation of code, forbid to edit +function XUiShop:InitAutoScript() + self:AutoAddListener() +end + +function XUiShop:GetAutoKey(uiNode, eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiShop:AutoAddListener() + self.BtnBack.CallBack = function() + self:OnBtnBackClick() + end + self.BtnMainUi.CallBack = function() + self:OnBtnMainUiClick() + end + self.BtnScreenGroup.CallBack = function() + self:OnBtnScreenGroupClick() + end + self.BtnScreenWords.onValueChanged:AddListener(function() + self.SelectTag = self.BtnScreenWords.captionText.text + self:UpdateList(self.CurShopId, false) + end) +end + +function XUiShop:OnBtnBackClick() + self:Close() + if self.cb then + self.cb() + end + self.AssetActivityPanel:HidePanel() + self.ItemList:HidePanel() + self.FashionList:HidePanel() + self.ShopPeriod:HidePanel() +end + +function XUiShop:OnBtnMainUiClick() + XLuaUiManager.RunMain() + self.AssetActivityPanel:HidePanel() + self.ItemList:HidePanel() + self.FashionList:HidePanel() + self.ShopPeriod:HidePanel() +end + +function XUiShop:OnBtnScreenGroupClick() + if self.ScreenGroupIDList and #self.ScreenGroupIDList > 0 then + self.ScreenNum = self.ScreenNum + 1 + if self.ScreenNum > #self.ScreenGroupIDList then + self.ScreenNum = 1 + end + end + self:UpdateDropdown() +end + + +function XUiShop:OnDestroy() + self.AssetActivityPanel:HidePanel() + self.ItemList:HidePanel() + self.FashionList:HidePanel() + self.ShopPeriod:HidePanel() +end + +function XUiShop:SetShopBtn(shopType) + local btnList = {} + + table.insert(btnList, self.BtnEcerdayShop) + table.insert(btnList, self.BtnActivityShop) + self.ShopBtnGroup:Init(btnList, function(index) self:OnSelectedShopBtn(index) end) + + local togActlist = XShopManager.GetShopBaseInfoByTypeAndTag(XShopManager.ShopType.Activity) + if #togActlist <= 0 then + self.BtnActivityShop:SetButtonState(CS.UiButtonState.Disable) + end + + if shopType == XShopManager.ShopType.Common then + self.ShopBtnGroup.gameObject:SetActiveEx(true) + self.ShopBtnGroup:SelectIndex(XShopManager.ShopType.Common) + elseif shopType == XShopManager.ShopType.Activity then + self.ShopBtnGroup.gameObject:SetActiveEx(true) + self.ShopBtnGroup:SelectIndex(XShopManager.ShopType.Activity) + else + self.ShopBtnGroup.gameObject:SetActiveEx(false) + end +end + +function XUiShop:OnSelectedShopBtn(index) + if index == XShopManager.ShopType.Common then + self:OnBtnCommonShopClick() + else + self:OnBtnActivityShopClick() + end +end + +function XUiShop:OnBtnActivityShopClick() + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.ShopActive) then + return + end + if self.Type == XShopManager.ShopType.Activity then + return + end + + local togActlist = XShopManager.GetShopBaseInfoByTypeAndTag(XShopManager.ShopType.Activity) + if #togActlist <= 0 then + XUiManager.TipText("ShopCannotFindActiveShop") + self.ShopBtnGroup:SelectIndex(XShopManager.ShopType.Common) + return + end + + self.Type = XShopManager.ShopType.Activity + self:UpdateTog() + +end + +function XUiShop:OnBtnCommonShopClick() + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.ShopCommon) then + return + end + + if self.Type == XShopManager.ShopType.Common then + return + end + + self.Type = XShopManager.ShopType.Common + self:UpdateTog() + +end + +function XUiShop:UpdateTog() + local shopId = self.ConfigShopId + self.ConfigShopId = nil + local infoList = XShopManager.GetShopBaseInfoByTypeAndTag(self.Type) + local selectIndex = DEFAULT_TOG_INDEX + local SubGroupIndexMemo = 0 + if #infoList == 0 then + self.Type = XShopManager.ShopType.Common + infoList = XShopManager.GetShopBaseInfoByTypeAndTag(self.Type) + end + + for i = 1, #self.BtnGoList do + self.BtnGoList[i].gameObject:SetActiveEx(false) + end + + for index, info in pairs(infoList) do + local btn = self.BtnGoList[self.tagCount] + if self.shopGroup[info.Type] then + if self.shopGroup[info.Type] [index] then + btn = self.BtnGoList[self.shopGroup[info.Type] [index]] + end + end + + if not btn then + local name + local SubGroupIndex + + if info.SecondType == 0 then + if info.IsHasSnd then + btn = CS.UnityEngine.Object.Instantiate(self.BtnFirstHasSnd) + else + btn = CS.UnityEngine.Object.Instantiate(self.BtnFirst) + end + SubGroupIndexMemo = self.tagCount + SubGroupIndex = 0 + else + if info.SecondTagType == XShopManager.SecondTagType.Top then + btn = CS.UnityEngine.Object.Instantiate(self.BtnSecondTop) + elseif info.SecondTagType == XShopManager.SecondTagType.Mid then + btn = CS.UnityEngine.Object.Instantiate(self.BtnSecond) + elseif info.SecondTagType == XShopManager.SecondTagType.Btm then + btn = CS.UnityEngine.Object.Instantiate(self.BtnSecondBottom) + else + btn = CS.UnityEngine.Object.Instantiate(self.BtnSecondAll) + end + + SubGroupIndex = SubGroupIndexMemo + end + + name = info.Name + + if btn then + if not self.shopGroup[info.Type] then + self.shopGroup[info.Type] = {} + end + table.insert(self.shopGroup[info.Type], self.tagCount) + self.tagCount = self.tagCount + 1 + + table.insert(self.ShopTables, info) + + btn.transform:SetParent(self.TabBtnContent, false) + local uiButton = btn:GetComponent("XUiButton") + uiButton.SubGroupIndex = SubGroupIndex + uiButton:SetName(name) + table.insert(self.BtnGoList, uiButton) + btn.gameObject.name = info.Id + end + end + + btn.gameObject:SetActiveEx(true) + + if shopId and info.Id == shopId then + selectIndex = self.shopGroup[info.Type] [index] + end + + if not shopId then + selectIndex = self.shopGroup[info.Type] [1] + end + end + + if #infoList <= 0 then + return + end + + self.TabBtnGroup:Init(self.BtnGoList, function(index) self:OnSelectedTog(index) end) + self.TabBtnGroup:SelectIndex(selectIndex) +end + +function XUiShop:SetTitleName(typeId) + if typeId ~= XShopManager.ShopType.Common and typeId ~= XShopManager.ShopType.Activity then + self.BtnTitle.gameObject:SetActiveEx(true) + else + self.BtnTitle.gameObject:SetActiveEx(false) + end + self.BtnEcerdayShop:SetNameByGroup(0,XShopManager.GetShopTypeDataById(XShopManager.ShopType.Common).TypeName) + self.BtnActivityShop:SetNameByGroup(0,XShopManager.GetShopTypeDataById(XShopManager.ShopType.Activity).TypeName) + self.BtnTitle:SetNameByGroup(0,XShopManager.GetShopTypeDataById(typeId).TypeName) + + self.BtnEcerdayShop:SetNameByGroup(1,XShopManager.GetShopTypeDataById(XShopManager.ShopType.Common).Desc) + self.BtnActivityShop:SetNameByGroup(1,XShopManager.GetShopTypeDataById(XShopManager.ShopType.Activity).Desc) + self.BtnTitle:SetNameByGroup(1,XShopManager.GetShopTypeDataById(typeId).Desc) +end + +function XUiShop:ShowShop(shopId) + XShopManager.GetShopInfo(shopId, function() + self:UpdateInfo(shopId) + end) +end + +--显示商品信息 +function XUiShop:OnSelectedTog(index) + local shopId = self.ShopTables[index].Id + self.CurShopId = shopId + self:ShowShop(shopId) + self:PlayAnimation("AnimQieHuan") +end + +function XUiShop:GetCurShopId() + return self.CurShopId +end + +--初始化列表 +function XUiShop:UpdateInfo(shopId) + self.ShopPeriod:HidePanel() + self.ShopPeriod:ShowPanel(shopId) + self:InitScreen(shopId) + self:UpdateDropdown() + self:UpdateList(shopId,false) + +end + +function XUiShop:InitScreen(shopId) + self.ScreenGroupIDList = XShopManager.GetShopScreenGroupIDList(shopId) + if self.ScreenGroupIDList and #self.ScreenGroupIDList > 0 then + self.IsHasScreen = true + self.ScreenNum = 1 + self.BtnScreenGroup.gameObject:SetActiveEx(#self.ScreenGroupIDList > 1) + else + self.IsHasScreen = false + end + self.PanelShaixuan.gameObject:SetActiveEx(self.IsHasScreen) +end + +function XUiShop:UpdateDropdown() + if not self.IsHasScreen then + return + end + local icon = XShopManager.GetShopScreenGroupIconById(self.ScreenGroupIDList[self.ScreenNum]) + if icon then + self.BtnScreenGroup:SetSprite(icon) + end + self.BtnScreenGroup:SetName(XShopManager.GetShopScreenGroupNameById(self.ScreenGroupIDList[self.ScreenNum])) + self.ScreenTagList = XShopManager.GetScreenTagListById(self.CurShopId,self.ScreenGroupIDList[self.ScreenNum]) + self.BtnScreenWords:ClearOptions() + self.BtnScreenWords.captionText.text = CS.XTextManager.GetText("ScreenAll") + for _,v in pairs(self.ScreenTagList or {}) do + local op = Dropdown.OptionData() + op.text = v.Text + self.BtnScreenWords.options:Add(op) + end + self.BtnScreenWords.value = 0 + self.SelectTag = self.BtnScreenWords.captionText.text +end + +function XUiShop:UpdateList(shopId) + self.AssetActivityPanel:Refresh(XShopManager.GetShopShowIdList(shopId)) + self.ItemList:ShowScreenPanel(shopId,self.ScreenGroupIDList[self.ScreenNum],self.SelectTag) + self.FashionList:ShowScreenPanel(shopId,self.ScreenGroupIDList[self.ScreenNum],self.SelectTag) +end + +function XUiShop:UpdateBuy(data, cb) + XLuaUiManager.Open("UiShopItem",self,data, cb) + self:PlayAnimation("AnimTanChuang") +end + +function XUiShop:RefreshBuy() + self.AssetActivityPanel:Refresh(XShopManager.GetShopShowIdList(self.CurShopId)) + self.ShopPeriod:UpdateShopBuyInfo() + self:UpdateList(self.CurShopId) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiShop/XUiShopItem.lua b/Resources/Scripts/XUi/XUiShop/XUiShopItem.lua new file mode 100644 index 00000000..1bce424a --- /dev/null +++ b/Resources/Scripts/XUi/XUiShop/XUiShopItem.lua @@ -0,0 +1,463 @@ +local XUiShopItem = XLuaUiManager.Register(XLuaUi, "UiShopItem") +local MAX_COUNT = CS.XGame.Config:GetInt("ShopBuyGoodsCountLimit") +local ColorRed = CS.XGame.ClientConfig:GetString("ShopCanNotBuyColor") +local ColorBlack = CS.XGame.ClientConfig:GetString("ShopCanBuyColor") +local Interval = 100 +local SpeedBaseNumber = 150 +local CountBaseNumber = 100 +local Application = CS.UnityEngine.Application +local Platform = Application.platform +local RuntimePlatform = CS.UnityEngine.RuntimePlatform +function XUiShopItem:OnStart(parent, data, cb, shopCanBuyColor) + if data then + self.Data = data + else + return + end + if cb then + self.CallBack = cb + end + self.Parent = parent + self.ShopCanBuyColor = shopCanBuyColor or ColorBlack + + self:AutoAddListener() + self:SetSelectTextData() + self.Grid = XUiGridCommon.New(self, self.GridBuyCommon) + self.Price = {} + table.insert(self.Price, self.PanelCostItem1) + table.insert(self.Price, self.PanelCostItem2) + table.insert(self.Price, self.PanelCostItem3) + + self.WgtBtnAddSelect = self.BtnAddSelect.gameObject:GetComponent("XUiPointer") + self.WgtBtnMinusSelect = self.BtnMinusSelect.gameObject:GetComponent("XUiPointer") + + XUiButtonLongClick.New(self.WgtBtnAddSelect, Interval, self, nil, self.BtnAddSelectLongClickCallback, nil, true) + XUiButtonLongClick.New(self.WgtBtnMinusSelect, Interval, self, nil, self.BtnMinusSelectLongClickCallback, nil, true) + + self:InitPanel() +end + +function XUiShopItem:InitPanel() + + self.MinCount = 1 + self.Count = 1 + self.Consumes = {} + self.BuyConsumes = {} + + XTool.LoopMap(self.Data.ConsumeList, function(_, consume) + local buyitem = {} + buyitem.Id = consume.Id + buyitem.Count = consume.Count + table.insert(self.Consumes, buyitem) + local consumes = {} + consumes.Id = consume.Id + consumes.Count = 0 + table.insert(self.BuyConsumes, consumes) + end) + + self:RefreshCommon() + self:RefreshPrice() + self:GetSalesInfo() + self:GetMaxCount() + self:RefreshConsumes() + self:SetCanBuyCount() + self:JudgeBuy() + self:HaveItem() + self:SetCanAddOrMinusBtn() + self.TxtSelect.text = self.Count +end + +function XUiShopItem:AutoAddListener() + + self.BtnMax.CallBack = function() + self:OnBtnMaxClick() + end + + self.BtnUse.CallBack = function() + self:OnBtnUseClick() + end + + self.BtnAddSelect.CallBack = function() + self:OnBtnAddSelectClick() + end + + self.BtnMinusSelect.CallBack = function() + self:OnBtnMinusSelectClick() + end + + self.TxtSelect.onValueChanged:AddListener(function() + self:OnSelectTextChange() + end) + + self.TxtSelect.onEndEdit:AddListener(function() + self:OnSelectTextInputEnd() + end) + + self.BtnTanchuangClose.CallBack = function() + self:OnBtnBlockClick() + end +end + +function XUiShopItem:SetSelectTextData() + self.TxtSelect.characterLimit = 4 + self.TxtSelect.contentType = CS.UnityEngine.UI.InputField.ContentType.IntegerNumber +end + +-- auto +function XUiShopItem:OnBtnBlockClick() + self:Close() +end + +function XUiShopItem:RemoveUI() + XLuaUiManager.Remove("UiShopItem") +end + +function XUiShopItem:OnBtnAddSelectClick() + if self.Count + 1 > self.MaxCount then + XDataCenter.EquipManager.ShowBoxOverLimitText() + return + end + self.Count = self.Count + 1 + self:RefreshConsumes() + self:JudgeBuy() + self.TxtSelect.text = self.Count + self:SetCanAddOrMinusBtn() +end + +function XUiShopItem:OnBtnMinusSelectClick() + if self.Count - 1 < self.MinCount then + return + end + self.Count = self.Count - 1 + self:RefreshConsumes() + self:JudgeBuy() + self.TxtSelect.text = self.Count + self:SetCanAddOrMinusBtn() +end + +function XUiShopItem:BtnAddSelectLongClickCallback(time) + if self.Count + 1 > self.MaxCount then + XDataCenter.EquipManager.ShowBoxOverLimitText() + return + end + + local delta = math.max(0, math.floor(time / SpeedBaseNumber)) + self.Count = self.Count + delta + if self.MaxCount and self.Count >= self.MaxCount then + self.Count = self.MaxCount + end + + self:RefreshConsumes() + self:JudgeBuy() + self.TxtSelect.text = self.Count + self:SetCanAddOrMinusBtn() +end + +function XUiShopItem:BtnMinusSelectLongClickCallback(time) + if self.Count - 1 < self.MinCount then + return + end + local delta = math.max(0, math.floor(time / SpeedBaseNumber)) + self.Count = self.Count - delta + if self.Count <= 0 then + self.Count = 0 + end + self:RefreshConsumes() + self:JudgeBuy() + self.TxtSelect.text = self.Count + self:SetCanAddOrMinusBtn() +end + +function XUiShopItem:OnBtnMaxClick() + self.Count = math.min(self.MaxCount, self.CanBuyCount) + self:RefreshConsumes() + self:JudgeBuy() + self.TxtSelect.text = self.Count + self:SetCanAddOrMinusBtn() +end + +function XUiShopItem:OnSelectTextChange() + if self.TxtSelect.text == nil or self.TxtSelect.text == "" then + return + end + if self.TxtSelect.text == "0" then + self.TxtSelect.text = 1 + end + local tmp = tonumber(self.TxtSelect.text) + local tmpMax = math.max(math.min(MAX_COUNT, self.MaxCount), 1) + if tmp > tmpMax then + tmp = tmpMax + self.TxtSelect.text = tmp + end + self.Count = tmp + self:RefreshConsumes() + self:JudgeBuy() +end + +function XUiShopItem:OnSelectTextInputEnd() + if self.TxtSelect.text == nil or self.TxtSelect.text == "" then + self.TxtSelect.text = 1 + local tmp = tonumber(self.TxtSelect.text) + self.Count = tmp + self:RefreshConsumes() + self:JudgeBuy() + end +end + +function XUiShopItem:SetCanAddOrMinusBtn() + self.BtnMinusSelect.interactable = self.Count > self.MinCount + self.BtnAddSelect.interactable = self.MaxCount > self.Count + + if self.BtnMax then + self.BtnMax:SetDisable(self.MaxCount <= 1) + end + + if self.PanelTxt then + self.PanelTxt.gameObject:SetActiveEx(self.MaxCount < MAX_COUNT) + end + + if self.TxtCanBuy then + self.TxtCanBuy.text = self.MaxCount + end +end + +function XUiShopItem:OnBtnUseClick() + if self.HaveNotBuyCount then + if not XDataCenter.EquipManager.ShowBoxOverLimitText() then + XUiManager.TipText("ShopHaveNotBuyCount") + end + return + end + + for k, v in pairs(self.NotEnough or {}) do + if v.ItemId == XDataCenter.ItemManager.ItemId.PaidGem then + local result = XDataCenter.ItemManager.CheckItemCountById(v.ItemId, v.UseItemCount) + if not result then + XUiManager.TipText("ShopItemPaidGemNotEnough") + XLuaUiManager.Open("UiPurchase", XPurchaseConfigs.TabsConfig.HK) + return + end + elseif v.ItemId == XDataCenter.ItemManager.ItemId.HongKa then + local result = XDataCenter.ItemManager.CheckItemCountById(v.ItemId, v.UseItemCount) + if not result then + XUiManager.TipText("ShopItemHongKaNotEnough") + XLuaUiManager.Open("UiPurchase", XPurchaseConfigs.TabsConfig.Pay) + return + end + else + if not XDataCenter.ItemManager.DoNotEnoughBuyAsset(v.ItemId, + v.UseItemCount, + 1, + function() + self:OnBtnUseClick() + end, + "BuyNeedItemInsufficient") then + return + end + self.NotEnough[k] = nil + end + end + + local func = function() + if self.Data.PayKeySuffix then + local key + if Platform == RuntimePlatform.Android then + key = string.format("%s%s", XPayConfigs.GetPlatformConfig(1), self.Data.PayKeySuffix) + else + key = string.format("%s%s", XPayConfigs.GetPlatformConfig(2), self.Data.PayKeySuffix) + end + XDataCenter.PayManager.Pay(key, 2, { self.Parent:GetCurShopId(), self.Data.Id }, self.Data.Id, function() + self:RemoveUI() + end) + else + XShopManager.BuyShop(self.Parent:GetCurShopId(), self.Data.Id, self.Count, function () + self.CallBack(self.Count) + XUiManager.TipText("BuySuccess") + self.Parent:RefreshBuy(true) + self:RemoveUI() + end) + end + end + + self:CheckBuyItemTypeOfWeaponFashion(func) +end + +function XUiShopItem:HaveItem() + if XArrangeConfigs.GetType(self.Data.RewardGoods.TemplateId) == XArrangeConfigs.Types.Furniture then + self.TxtOwnCount.gameObject:SetActiveEx(false) + else + local count = XGoodsCommonManager.GetGoodsCurrentCount(self.Data.RewardGoods.TemplateId) + self.TxtOwnCount.text = CS.XTextManager.GetText("CurrentlyHas", count) + self.TxtOwnCount.gameObject:SetActiveEx(true) + end +end + +function XUiShopItem:RefreshCommon() + self.RImgType.gameObject:SetActiveEx(false) + + local rewardGoods = self.Data.RewardGoods + self.Grid:Refresh(rewardGoods, nil, true) + self.Grid:ShowCount(true) +end + +function XUiShopItem:RefreshPrice() + if #self.Consumes ~= 0 then + self.PanelPrice.gameObject:SetActiveEx(true) + for i = 1, #self.Price do + if i <= #self.Consumes then + self.Price[i].gameObject:SetActiveEx(true) + else + self.Price[i].gameObject:SetActiveEx(false) + end + end + else + self.PanelPrice.gameObject:SetActiveEx(false) + end +end + +function XUiShopItem:RefreshOnSales(buyCount) + self.OnSales = {} + XTool.LoopMap(self.Data.OnSales, function(k, sales) + self.OnSales[k] = sales + end) + local sumbuy = buyCount + self.Data.TotalBuyTimes + if #self.OnSales ~= 0 then + local curLevel = 0 + for k, v in pairs(self.OnSales) do + if sumbuy >= k and k > curLevel then + self.Sales = v + curLevel = k + end + end + else + self.Sales = 100 + end +end + +function XUiShopItem:RefreshConsumes() + for i = 1, #self.BuyConsumes do + self.BuyConsumes[i].Count = 0 + end + for k, v in pairs(self.Consumes) do + self.BuyConsumes[k].Id = v.Id + self.BuyConsumes[k].Count = math.floor(v.Count * self.Sales / CountBaseNumber) * self.Count + end + for i = 1, #self.Consumes do + self["RImgCostIcon" .. i]:SetRawImage(XDataCenter.ItemManager.GetItemBigIcon(self.BuyConsumes[i].Id)) + self["TxtCostCount" .. i].text = math.floor(self.BuyConsumes[i].Count) + end +end + +function XUiShopItem:GetSalesInfo() + self.OnSales = {} + XTool.LoopMap(self.Data.OnSales, function(k, sales) + self.OnSales[k] = sales + end) +end + +function XUiShopItem:GetMaxCount() + self.Sales = 100 + local sortedKeys = {} + for k, _ in pairs(self.OnSales) do + table.insert(sortedKeys, k) + end + table.sort(sortedKeys) + + local leftSalesGoods = MAX_COUNT + + for i = 1, #sortedKeys do + if self.Data.TotalBuyTimes >= sortedKeys[i] - 1 then + self.Sales = self.OnSales[sortedKeys[i]] + else + leftSalesGoods = sortedKeys[i] - self.Data.TotalBuyTimes - 1 + break + end + end + + local leftShopTimes = XShopManager.GetShopLeftBuyTimes(self.Parent:GetCurShopId()) + if not leftShopTimes then + leftShopTimes = MAX_COUNT + end + + local leftGoodsTimes = MAX_COUNT + if self.Data.BuyTimesLimit and self.Data.BuyTimesLimit > 0 then + local buyCount = self.Data.TotalBuyTimes and self.Data.TotalBuyTimes or 0 + leftGoodsTimes = self.Data.BuyTimesLimit - buyCount + end + local tmpMaxCount = math.min(leftGoodsTimes, math.min(leftShopTimes, leftSalesGoods)) + self.MaxCount = tmpMaxCount + self.MaxCount = XDataCenter.EquipManager.GetMaxCountOfBoxOverLimit(self.Data.RewardGoods.TemplateId, self.MaxCount, self.Data.RewardGoods.Count) + + if self.MaxCount < tmpMaxCount then + self.BuyHintText.text = CS.XTextManager.GetText("MaxCanBuyText") + else + self.BuyHintText.text = CS.XTextManager.GetText("CanBuyText") + end +end + +function XUiShopItem:SetCanBuyCount() + local canBuyCount = self.MaxCount + for _, v in pairs(self.BuyConsumes) do + local itemCount = XDataCenter.ItemManager.GetCount(v.Id) + local buyCount = math.floor(itemCount / v.Count) + canBuyCount = math.min(buyCount, canBuyCount) + end + canBuyCount = math.max(self.MinCount, canBuyCount) + self.CanBuyCount = canBuyCount +end + +function XUiShopItem:JudgeBuy() + self.HaveNotBuyCount = self.Count > self.MaxCount or self.Count == 0 + if self.HaveNotBuyCount then + return + end + + local index = 1 + local enoughIndex = {} + self.NotEnough = {} + + for _, v in pairs(self.BuyConsumes) do + local itemCount = XDataCenter.ItemManager.GetCount(v.Id) + if v.Count > itemCount then + self:ChangeCostColor(false, index) + if not self.NotEnough[index] then self.NotEnough[index] = {} end + self.NotEnough[index].ItemId = v.Id + self.NotEnough[index].UseItemCount = v.Count + else + table.insert(enoughIndex, index) + end + index = index + 1 + end + + for _, v in pairs(enoughIndex) do + self:ChangeCostColor(true, v) + end +end + +function XUiShopItem:ChangeCostColor(bool, index) + if bool then + self["TxtCostCount" .. index].color = XUiHelper.Hexcolor2Color(self.ShopCanBuyColor) + else + self["TxtCostCount" .. index].color = XUiHelper.Hexcolor2Color(ColorRed) + end +end + +function XUiShopItem:CheckBuyItemTypeOfWeaponFashion(cb) + local templateId = self.Data.RewardGoods.TemplateId + if XDataCenter.ItemManager.IsWeaponFashion(templateId) then + local fashionId = XDataCenter.ItemManager.GetWeaponFashionId(templateId) + if XDataCenter.WeaponFashionManager.CheckHasFashion(fashionId) then + if XDataCenter.ItemManager.IsWeaponFashionTimeLimit(templateId) then + self:TipDialog(nil, cb, "BuyWeaponFashionIsTimeLimit") + else + self:TipDialog(nil, cb, "BuyWeaponFashionIsNotTimeLimit") + end + return + end + end + cb() +end + +function XUiShopItem:TipDialog(cancelCb, confirmCb, TextKey) + CsXUiManager.Instance:Open("UiDialog", CS.XTextManager.GetText("TipTitle"), CS.XTextManager.GetText(TextKey), XUiManager.DialogType.Normal, cancelCb, confirmCb) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSignIn/XUiDiviningLog.lua b/Resources/Scripts/XUi/XUiSignIn/XUiDiviningLog.lua new file mode 100644 index 00000000..e9933918 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSignIn/XUiDiviningLog.lua @@ -0,0 +1,127 @@ +local XUiDiviningLog = XLuaUiManager.Register(XLuaUi, "UiDiviningLog") +local BtnMaxCount = 2 +local IsInit = {} +local AnimeNames = {} +local InitFunctionList = {} + +function XUiDiviningLog:OnStart(id) + self.Id = id + self.SelectIndex = 1 + self.BtnTanchuangClose.CallBack = function() + self:OnBtnTanchuangClose() + end + self.BtnClose.CallBack = function() + self:OnBtnTanchuangClose() + end + + InitFunctionList = { + function () + self:InitBaseRulePanel() + end, + function () + self:InitDrawLogListPanel() + end, + } + IsInit = {false,false} + + AnimeNames = {"QieHuanOne","QieHuanThree"} + self:InitBtnTab() +end + +function XUiDiviningLog:InitDrawLogListPanel() + local PanelObj = {} + PanelObj.Transform = self.Panel2.transform + XTool.InitUiObject(PanelObj) + + PanelObj.GridLogLow.gameObject:SetActiveEx(false) + local records = XDataCenter.SignInManager.GetAllDiviningDatas() + for k, v in pairs(records) do + local diviningCfg = XSignInConfigs.GetDiviningSignRewardConfig(v.DailyLotteryRewardId) + local signName = diviningCfg.RewardSignDesc + local strItemsDesc = "" + local rewards = XRewardManager.GetRewardList(diviningCfg.RewardId) + if rewards then + for i = 1, #rewards do + local count = rewards[i].Count + local name = XGoodsCommonManager.GetGoodsShowParamsByTemplateId(rewards[i].TemplateId).Name + if i < #rewards then + strItemsDesc = string.format("%s%s%s%d%s", strItemsDesc, name, "*", count, ", ") + else + strItemsDesc = string.format("%s%s%s%d", strItemsDesc, name, "*", count) + end + end + end + + local time = XTime.TimestampToGameDateTimeString(v.Time, "yyyy-MM-dd HH:mm") + self:SetLogData(PanelObj, signName, strItemsDesc, time) + end +end + +function XUiDiviningLog:SetLogData(obj, name, itemsDesc, time) + local go = {} + go = CS.UnityEngine.Object.Instantiate(obj.GridLogLow, obj.PanelContent) + + local tmpObj = {} + tmpObj.Transform = go.transform + tmpObj.GameObject = go.gameObject + XTool.InitUiObject(tmpObj) + tmpObj.TxtName.text = name + tmpObj.TxtItems.text = itemsDesc + tmpObj.TxtTime.text = time + tmpObj.GameObject:SetActiveEx(true) +end + +function XUiDiviningLog:InitBaseRulePanel() + local cfg = XSignInConfigs.GetNewYearSignInConfig(self.Id) + local baseRules = cfg.RuleTitle + local baseRuleTitles = cfg.RuleContent + self:SetRuleData(baseRules, baseRuleTitles, self.Panel1) +end + +function XUiDiviningLog:SetRuleData(rules, ruleTitles, panel) + local PanelObj = {} + PanelObj.Transform = panel.transform + XTool.InitUiObject(PanelObj) + PanelObj.PanelTxt.gameObject:SetActiveEx(false) + for k,v in pairs(rules) do + local go = CS.UnityEngine.Object.Instantiate(PanelObj.PanelTxt, PanelObj.PanelContent) + local tmpObj = {} + tmpObj.Transform = go.transform + tmpObj.GameObject = go.gameObject + XTool.InitUiObject(tmpObj) + tmpObj.TxtRuleTittle.text = ruleTitles[k] + tmpObj.TxtRule.text = rules[k] + tmpObj.TxtRuleTittle.text = string.gsub(tmpObj.TxtRuleTittle.text, "\\n", "\n") + tmpObj.TxtRule.text = string.gsub(tmpObj.TxtRule.text, "\\n", "\n") + tmpObj.GameObject:SetActiveEx(true) + end +end + +function XUiDiviningLog:InitBtnTab() + self.TabGroup = self.TabGroup or {} + for i = 1, BtnMaxCount do + if not self.TabGroup[i] then + self.TabGroup[i] = self["BtnTab"..i] + end + end + self.PanelTabTc:Init(self.TabGroup, function(tabIndex) self:OnSelectedTog(tabIndex) end) + self.PanelTabTc:SelectIndex(self.SelectIndex) +end + +function XUiDiviningLog:OnBtnTanchuangClose() + self:Close() +end + +function XUiDiviningLog:OnSelectedTog(index) + for i = 1, BtnMaxCount do + self["Panel"..i].gameObject:SetActiveEx(false) + end + + self["Panel"..index].gameObject:SetActiveEx(true) + if not IsInit[index] then + InitFunctionList[index]() + IsInit[index] = true + end + + self:PlayAnimation(AnimeNames[index]) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSignIn/XUiNewYearSignIn.lua b/Resources/Scripts/XUi/XUiSignIn/XUiNewYearSignIn.lua new file mode 100644 index 00000000..6b781c5e --- /dev/null +++ b/Resources/Scripts/XUi/XUiSignIn/XUiNewYearSignIn.lua @@ -0,0 +1,115 @@ +local XUiNewYearSignIn = XClass(nil, "XUiNewYearSignIn") + +function XUiNewYearSignIn:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + + XTool.InitUiObject(self) + self:InitAddListen() + self.PanelEffectZhanBu.gameObject:SetActiveEx(false) + self.RewardPanelList = {} +end + +function XUiNewYearSignIn:InitAddListen() + self.BtnHelp.CallBack = function() + self:OnBtnHelpClick() + end + self.BtnDivining.CallBack = function() + self:OnBtnDiviningClick() + end +end + +function XUiNewYearSignIn:Refresh(signId, isShow) + self.SignId = signId or self.SignId + local todayDiviningState = XDataCenter.SignInManager.GetTodayDiviningState() + --self.PanelEffectZhanBu.gameObject:SetActiveEx(false) + + if not todayDiviningState then + self.PanelDiviningGroup.gameObject:SetActiveEx(true) + self.PanelDiviningSignGroup.gameObject:SetActiveEx(false) + XEventManager.DispatchEvent(XEventId.EVENT_SING_IN_OPEN_BTN, true) + return + end + + self.PanelEffectGet.gameObject:SetActiveEx(true) + self.PanelDiviningGroup.gameObject:SetActiveEx(false) + self.PanelDiviningSignGroup.gameObject:SetActiveEx(true) + local todayRewardData = XDataCenter.SignInManager.GetDiviningTodayData() + local rewardConfig = XSignInConfigs.GetDiviningSignRewardConfig(todayRewardData.DailyLotteryRewardId) + self.TxtSign.text = rewardConfig.RewardText + self.TxtSign.text = string.gsub(self.TxtSign.text, "\\n", "\n") + + if rewardConfig.RewardSignPath then + self.ImgSign:SetRawImage(rewardConfig.RewardSignPath) + else + self.ImgSign.gameObject:SetActiveEx(false) + end + + self.TxtAward.text = CS.XTextManager.GetText("DiviningRewardsText") + + --显示奖励 + local rewards = XRewardManager.GetRewardList(rewardConfig.RewardId) + if not rewards then + return + end + + for i = 1, #rewards do + local panel = self.RewardPanelList[i] + if not panel then + if #self.RewardPanelList == 0 then + panel = XUiGridCommon.New(self.RootUi, self.GridItem) + else + local ui = CS.UnityEngine.Object.Instantiate(self.GridItem) + ui.transform:SetParent(self.PanelAwardContent, false) + panel = XUiGridCommon.New(self.RootUi, ui) + end + table.insert(self.RewardPanelList, panel) + end + panel:Refresh(rewards[i]) + end + + XEventManager.DispatchEvent(XEventId.EVENT_SING_IN_OPEN_BTN, true) +end + +function XUiNewYearSignIn:OnBtnHelpClick() + XLuaUiManager.Open("UiDiviningLog", self.SignId) +end + +function XUiNewYearSignIn:OnBtnDiviningClick() + local id = XDataCenter.SignInManager.GetDiviningActivityId() or self.SignId + XDataCenter.SignInManager.RequestNewYearDivining(id, function() + self.PanelEffectZhanBu.gameObject:SetActiveEx(false) + self.PanelEffectZhanBu.gameObject:SetActiveEx(true) + self.PanelAnimationZhanBu.gameObject:SetActiveEx(true) + self.DrawTipTimeId = CS.XScheduleManager.ScheduleOnce(function () + if self.PanelAnimationZhanBu:Exist() then + self.PanelAnimationZhanBu.gameObject:SetActiveEx(false) + end + if self.PanelEffectZhanBu:Exist() then + self.PanelEffectZhanBu.gameObject:SetActiveEx(false) + end + end, 2000) + self:Refresh() + end) +end + +function XUiNewYearSignIn:OnShow() + XEventManager.AddEventListener(XEventId.EVENT_CARD_REFRESH_WELFARE_BTN, self.ForceUpdate, self) +end + +function XUiNewYearSignIn:ForceUpdate() + if self.SignId then + self:Refresh(self.SignId) + end +end + +function XUiNewYearSignIn:OnHide() + if self.DrawTipTimeId then + CS.XScheduleManager.UnSchedule(self.DrawTipTimeId) + self.DrawTipTimeId = nil + end + XEventManager.RemoveEventListener(XEventId.EVENT_CARD_REFRESH_WELFARE_BTN, self.ForceUpdate, self) +end + +return XUiNewYearSignIn \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSignIn/XUiSign.lua b/Resources/Scripts/XUi/XUiSignIn/XUiSign.lua new file mode 100644 index 00000000..cd2e36e8 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSignIn/XUiSign.lua @@ -0,0 +1,161 @@ +local XUiSign = XLuaUiManager.Register(XLuaUi, "UiSign") +local XUiSignPrefabContent = require("XUi/XUiSignIn/XUiSignPrefabContent") +local XUiSignFirstRecharge = require("XUi/XUiSignIn/XUiSignFirstRecharge") +local XUiSignCard = require("XUi/XUiSignIn/XUiSignCard") +local XUiNewYearSignIn = require("XUi/XUiSignIn/XUiNewYearSignIn") +local XUiSignNewYearDrawActivity = require("XUi/XUiSignIn/XUiSignNewYearDrawActivity") +local XUiSignEnKrNewyear = require("XUi/XUiSignIn/XUiSignEnKrNewyear") +local XuiSignFireworks = require("XOverseas/XUi/XUiFireworks/XUiFireworks") +function XUiSign:OnAwake() + self:AddListener() + self.PrefabList = {} +end + +function XUiSign:OnStart(defaultIdx) + self:InitTabGroup(defaultIdx) +end + +function XUiSign:OnEnable() + XEventManager.AddEventListener(XEventId.EVENT_CARD_REFRESH_WELFARE_BTN, self.RefrshRedHint, self) + + self:RefrshRedHint() + + if not self.IsFirst then + self.IsFirst = true + return + end + + if self.Index then + self:SetPrefabInfos(self.Index, true) + end +end + +function XUiSign:OnDisable() + XEventManager.RemoveEventListener(XEventId.EVENT_CARD_REFRESH_WELFARE_BTN, self.RefrshRedHint, self) +end + +function XUiSign:AddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) +end + +function XUiSign:OnBtnMainUiClick(...) + XLuaUiManager.RunMain() +end + +function XUiSign:OnBtnBackClick(...) + XEventManager.DispatchEvent(XEventId.EVENT_NEWYEARYUNSHI_CLOSE_REFRESH) + self:Close() +end + +function XUiSign:InitTabGroup(defaultType) + self.WelfareConfigs = XSignInConfigs.GetWelfareConfigs() + if #self.WelfareConfigs <= 0 then + self.BtnTab.gameObject:SetActive(false) + self.PanelNull.gameObject:SetActive(true) + return + end + self.PanelNull.gameObject:SetActive(false) + + local defaultIndex = 1 + self.BtnTab:SetName(self.WelfareConfigs[1].Name) + self.BtnList = {} + table.insert(self.BtnList, self.BtnTab) + for i = 2, #self.WelfareConfigs do + local btn = CS.UnityEngine.Object.Instantiate(self.BtnTab.gameObject) + btn.transform:SetParent(self.PanelTabGroup.gameObject.transform, false) + local xBtn = btn.transform:GetComponent("XUiButton") + table.insert(self.BtnList, xBtn) + xBtn:SetName(self.WelfareConfigs[i].Name) + if defaultType and self.WelfareConfigs[i].WelfareId == defaultType then + defaultIndex = i + end + end + + self.PanelTabGroup:Init(self.BtnList, function(index) + self:SetPrefabInfos(index) + end) + + self.PanelTabGroup:SelectIndex(defaultIndex or 1) +end + +function XUiSign:SetPrefabInfos(index, forceRefresh) + if self.Index == index and not forceRefresh then + return + end + self.Index = index + self:PlayAnimation("QieHuanEnable") + + for k, v in pairs(self.PrefabList) do + v.SignPrefabContent.GameObject:SetActive(false) + end + + local config = self.WelfareConfigs[index] + local signPrefabContent = self.PrefabList[config.PrefabPath] and self.PrefabList[config.PrefabPath].SignPrefabContent or nil + if not signPrefabContent then + local resource = CS.XResourceManager.Load(config.PrefabPath) + local go = CS.UnityEngine.Object.Instantiate(resource.Asset) + go.transform:SetParent(self.PanelSign, false) + go.gameObject:SetLayerRecursively(self.PanelSign.gameObject.layer) + + if config.FunctionType == XAutoWindowConfigs.AutoFunctionType.Sign then + signPrefabContent = XUiSignPrefabContent.New(go, self) + elseif config.FunctionType == XAutoWindowConfigs.AutoFunctionType.FirstRecharge then + signPrefabContent = XUiSignFirstRecharge.New(go, self) + elseif config.FunctionType == XAutoWindowConfigs.AutoFunctionType.Card then + signPrefabContent = XUiSignCard.New(go, self) + elseif config.FunctionType == XAutoWindowConfigs.AutoFunctionType.NewYearZhanBu then + signPrefabContent = XUiNewYearSignIn.New(go, self) + elseif config.FunctionType == XAutoWindowConfigs.AutoFunctionType.NewYearDrawActivity then + signPrefabContent = XUiSignNewYearDrawActivity.New(go, self) + elseif config.FunctionType == XAutoWindowConfigs.AutoFuncitonType.Fireworks then + signPrefabContent = XuiSignFireworks.New(go, self) + end + + signPrefabContent:OnShow() + local info = {} + info.SignPrefabContent = signPrefabContent + info.Resource = resource + self.PrefabList[config.PrefabPath] = info + end + + signPrefabContent:Refresh(config.Id, false) + signPrefabContent.GameObject:SetActive(true) +end + +function XUiSign:RefrshRedHint() + if not self.BtnList then + return + end + + for index, xBtn in pairs(self.BtnList) do + local config = self.WelfareConfigs[index] + if config.FunctionType == XAutoWindowConfigs.AutoFunctionType.FirstRecharge then + xBtn:ShowReddot(not XDataCenter.PayManager.IsGotFirstReCharge()) + elseif config.FunctionType == XAutoWindowConfigs.AutoFunctionType.Card then + local cardConfig = XSignInConfigs.GetSignCardConfig(config.Id) + xBtn:ShowReddot(not XDataCenter.PayManager.IsGotCard(cardConfig.Param[1], cardConfig.Param[2])) + elseif config.FunctionType == XAutoWindowConfigs.AutoFunctionType.NewYearZhanBu then + xBtn:ShowReddot(XDataCenter.SignInManager.CheckTodayDiviningState()) + elseif config.FunctionType == XAutoWindowConfigs.AutoFunctionType.Fireworks then + xBtn:ShowReddot(XDataCenter.FireworksManager.HasRedDot()) + end + end +end + +function XUiSign:OnDestroy() + if not self.PrefabList then + return + end + + for k, v in pairs(self.PrefabList) do + if v.Resource then + v.Resource:Release() + end + + if v.SignPrefabContent then + v.SignPrefabContent:OnHide() + CS.UnityEngine.Object.Destroy(v.SignPrefabContent.GameObject) + end + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSignIn/XUiSignBanner.lua b/Resources/Scripts/XUi/XUiSignIn/XUiSignBanner.lua new file mode 100644 index 00000000..fe5ac15e --- /dev/null +++ b/Resources/Scripts/XUi/XUiSignIn/XUiSignBanner.lua @@ -0,0 +1,90 @@ +local XUiSignBanner = XLuaUiManager.Register(XLuaUi, "UiSignBanner") +local XUiSignPrefabContent = require("XUi/XUiSignIn/XUiSignPrefabContent") +local XUiSignFirstRecharge = require("XUi/XUiSignIn/XUiSignFirstRecharge") +local XUiSignCard = require("XUi/XUiSignIn/XUiSignCard") +local XUiNewYearSignIn = require("XUi/XUiSignIn/XUiNewYearSignIn") +local XUiSignNewYearDrawActivity = require("XUi/XUiSignIn/XUiSignNewYearDrawActivity") +local XUiSignFireworks = require("XOverseas/XUi/XUiFireworks/XUiFireworks") + +function XUiSignBanner:OnAwake() + self:AddListener() + XEventManager.AddEventListener(XEventId.EVENT_SING_IN_OPEN_BTN, self.SetBtnActive, self) +end + +function XUiSignBanner:OnStart(configId) + self.Config = XSignInConfigs.GetWelfareConfig(configId) + self:SetBtnActive(false) + self:SetInfo(configId) +end + +function XUiSignBanner:OnEnable() + if not self.IsFirst then + self.IsFirst = true + return + end + + if self.SignPrefabContent and self.Config.FunctionType == XAutoWindowConfigs.AutoFunctionType.Sign then + self.SignPrefabContent:Refresh(self.Config.SubConfigId, true) + end +end + +function XUiSignBanner:AddListener() + self:RegisterClickEvent(self.BtnClose, self.OnBtnCloseClick) +end + +function XUiSignBanner:OnBtnCloseClick() + self:Close() + XDataCenter.AutoWindowManager.NextAutoWindow() +end + +function XUiSignBanner:SetInfo(configId) + local path = XSignInConfigs.GetPrefabPath(configId) + + self.Resource = CS.XResourceManager.Load(path) + local prefab = CS.UnityEngine.Object.Instantiate(self.Resource.Asset) + prefab.transform:SetParent(self.PanelSigGrid, false) + prefab.gameObject:SetLayerRecursively(self.PanelSigGrid.gameObject.layer) + + if self.Config.FunctionType == XAutoWindowConfigs.AutoFunctionType.Sign then + self.SignPrefabContent = XUiSignPrefabContent.New(prefab, self) + elseif self.Config.FunctionType == XAutoWindowConfigs.AutoFunctionType.FirstRecharge then + self.SignPrefabContent = XUiSignFirstRecharge.New(prefab, self) + elseif self.Config.FunctionType == XAutoWindowConfigs.AutoFunctionType.Card then + self.SignPrefabContent = XUiSignCard.New(prefab, self) + elseif self.Config.FunctionType == XAutoWindowConfigs.AutoFunctionType.NewYearZhanBu then + self.SignPrefabContent = XUiNewYearSignIn.New(prefab, self) + elseif self.Config.FunctionType == XAutoWindowConfigs.AutoFunctionType.NewYearDrawActivity then + self.SignPrefabContent = XUiSignNewYearDrawActivity.New(prefab, self) + elseif self.Config.FunctionType == XAutoWindowConfigs.AutoFuncitonType.Fireworks then + self.SignPrefabContent = XUiSignFireworks.New(prefab, self) + end + + self.SignPrefabContent:Refresh(self.Config.SubConfigId, true) +end + +function XUiSignBanner:SetBtnActive(active, dayRewardConfig) + if dayRewardConfig and self.SignPrefabContent then + self.SignPrefabContent:SetTomorrowOpen(dayRewardConfig) + end + + if self.Config.FunctionType == XAutoWindowConfigs.AutoFunctionType.Sign then + self.PanelMask.gameObject:SetActive(not active) + else + self.PanelMask.gameObject:SetActive(false) + end + + self.BtnClose.gameObject:SetActive(active) + self.PanelCloseDesc.gameObject:SetActive(active) +end + +function XUiSignBanner:OnDestroy() + XEventManager.RemoveEventListener(XEventId.EVENT_SING_IN_OPEN_BTN, self.SetBtnActive, self) + + if self.Resource then + self.Resource:Release() + end + + if self.SignPrefabContent then + CS.UnityEngine.Object.Destroy(self.SignPrefabContent.GameObject) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSignIn/XUiSignCard.lua b/Resources/Scripts/XUi/XUiSignIn/XUiSignCard.lua new file mode 100644 index 00000000..94e6d263 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSignIn/XUiSignCard.lua @@ -0,0 +1,118 @@ +local XUiSignCard = XClass(nil, "XUiSignCard") + +function XUiSignCard:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + + XTool.InitUiObject(self) + self:InitAddListen() +end + +function XUiSignCard:OnHide() + XEventManager.RemoveEventListener(XEventId.EVENT_CARD_REFRESH_WELFARE_BTN, self.Refresh, self) +end + +function XUiSignCard:OnShow() + XEventManager.AddEventListener(XEventId.EVENT_CARD_REFRESH_WELFARE_BTN, self.Refresh, self) +end + +function XUiSignCard:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiSignCard:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiSignCard:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiSignCard:InitAddListen() + self:RegisterClickEvent(self.BtnSkip, self.OnBtnSkipClick) + self:RegisterClickEvent(self.BtnHelp, self.OnBtnHelpClick) + self:RegisterClickEvent(self.BtnContinue, self.OnBtnContinueClick) + self:RegisterClickEvent(self.BtnGet, self.OnBtnGetClick) +end + +function XUiSignCard:OnBtnSkipClick() + XDataCenter.AutoWindowManager.StopAutoWindow() + XLuaUiManager.Open("UiPurchase", XPurchaseConfigs.TabsConfig.YK, false) +end + +function XUiSignCard:OnBtnHelpClick() + XUiManager.UiFubenDialogTip("", self.Config.Description or "") +end + +function XUiSignCard:OnBtnContinueClick() + XDataCenter.AutoWindowManager.StopAutoWindow() + XLuaUiManager.Open("UiPurchase", XPurchaseConfigs.TabsConfig.YK, false) +end + +function XUiSignCard:OnBtnGetClick() + XDataCenter.PurchaseManager.YKInfoDataReq(function() + local data = XDataCenter.PurchaseManager.GetYKInfoData(self.Config.Param[1], self.Config.Param[2]) + if not data then + return + end + + if data.IsDailyRewardGet then + XUiManager.TipText("ChallengeRewardIsGetted") + else + XDataCenter.PurchaseManager.PurchaseGetDailyRewardRequest(data.Id, function(rewardItems) + self:RefreshGet() + XUiManager.OpenUiObtain(rewardItems) + end) + end + end) +end + +function XUiSignCard:Refresh(configId) + XDataCenter.PurchaseManager.YKInfoDataReq(function() + if not configId then + configId = self.ConfigId + end + self.ConfigId = configId + + self.PanelBuy.gameObject:SetActive(false) + self.PanelGet.gameObject:SetActive(false) + + self.Config = XSignInConfigs.GetSignCardConfig(configId) + local isBuy = XDataCenter.PurchaseManager.IsYkBuyed(self.Config.Param[1], self.Config.Param[2]) + if isBuy then + self:RefreshGet() + else + self:RefreshBuy() + end + XEventManager.DispatchEvent(XEventId.EVENT_SING_IN_OPEN_BTN, true) + end) +end + +function XUiSignCard:RefreshBuy() + self.PanelBuy.gameObject:SetActive(true) +end + +function XUiSignCard:RefreshGet() + local data = XDataCenter.PurchaseManager.GetYKInfoData(self.Config.Param[1], self.Config.Param[2]) + if not data then + return + end + + self.TxtLeftDay.text = data.DailyRewardRemainDay > 0 and data.DailyRewardRemainDay - 1 or 0 + self.BtnContinue.gameObject:SetActive(data.DailyRewardRemainDay < self.Config.CanBuyDay) + if data.IsDailyRewardGet then + self.BtnGet:SetButtonState(CS.UiButtonState.Disable) + else + self.BtnGet:SetButtonState(CS.UiButtonState.Normal) + end + + self.PanelGet.gameObject:SetActive(true) +end + +return XUiSignCard \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSignIn/XUiSignEnKrNewyear.lua b/Resources/Scripts/XUi/XUiSignIn/XUiSignEnKrNewyear.lua new file mode 100644 index 00000000..26c00bbc --- /dev/null +++ b/Resources/Scripts/XUi/XUiSignIn/XUiSignEnKrNewyear.lua @@ -0,0 +1,12 @@ +local XUiSignEnKrNewyear = XClass(nil, "XUiSignEnKrNewyear") + +function XUiSignEnKrNewyear:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + + XTool.InitUiObject(self) + +end + +return XUiSignEnKrNewyear \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSignIn/XUiSignFirstRecharge.lua b/Resources/Scripts/XUi/XUiSignIn/XUiSignFirstRecharge.lua new file mode 100644 index 00000000..fde1d59c --- /dev/null +++ b/Resources/Scripts/XUi/XUiSignIn/XUiSignFirstRecharge.lua @@ -0,0 +1,136 @@ +local XUiSignFirstRecharge = XClass(nil, "XUiSignFirstRecharge") + +function XUiSignFirstRecharge:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + + XTool.InitUiObject(self) + self:InitAddListen() + + self.SmallGrids = {} + self.BigGrids = {} +end + +function XUiSignFirstRecharge:OnHide() + XEventManager.RemoveEventListener(XEventId.EVENT_CARD_REFRESH_WELFARE_BTN, self.Refresh, self) +end + +function XUiSignFirstRecharge:OnShow() + XEventManager.AddEventListener(XEventId.EVENT_CARD_REFRESH_WELFARE_BTN, self.Refresh, self) +end + +function XUiSignFirstRecharge:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiSignFirstRecharge:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiSignFirstRecharge:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiSignFirstRecharge:InitAddListen() + self:RegisterClickEvent(self.BtnSkip, self.OnBtnSkipClick) + self:RegisterClickEvent(self.BtnHelp, self.OnBtnHelpClick) + self:RegisterClickEvent(self.BtnGet, self.OnBtnGetClick) + self:RegisterClickEvent(self.BtnAlreadyGet, self.OnBtnAlreadyGetClick) +end + +function XUiSignFirstRecharge:OnBtnSkipClick() + XLuaUiManager.Open("UiPurchase", 1, nil, nil) -- 海外修改(跳转到充值界面) + XDataCenter.AutoWindowManager.StopAutoWindow() +end + +function XUiSignFirstRecharge:OnBtnHelpClick() + XUiManager.UiFubenDialogTip("", self.Config.Description or "") +end + +function XUiSignFirstRecharge:OnBtnAlreadyGetClick() + XUiManager.TipText("ChallengeRewardIsGetted") +end + +function XUiSignFirstRecharge:OnBtnGetClick() + XDataCenter.PayManager.GetFirstPayRewardReq(function() + self.BtnGet.gameObject:SetActive(false) + self.BtnAlreadyGet.gameObject:SetActive(true) + end) +end + +function XUiSignFirstRecharge:Refresh(configId) + if not configId then + configId = self.ConfigId + end + self.ConfigId = configId + + self.Config = XSignInConfigs.GetFirstRechargeConfig(configId) + + if XDataCenter.PayManager.GetFirstRecharge() then + self.BtnSkip.gameObject:SetActive(false) + + local isGet = XDataCenter.PayManager.GetFirstRechargeReward() + self.BtnGet.gameObject:SetActive(not isGet) + self.BtnAlreadyGet.gameObject:SetActive(isGet) + else + self.BtnSkip.gameObject:SetActive(true) + self.BtnGet.gameObject:SetActive(false) + self.BtnAlreadyGet.gameObject:SetActive(false) + end + + self.GridCommon.gameObject:SetActive(false) + local smallRewardItems = XRewardManager.GetRewardList(XPayConfigs.GetSmallRewards()) + local bigRewardItems = XRewardManager.GetRewardList(XPayConfigs.GetBigRewards()) + + for _, v in ipairs(self.SmallGrids) do + v.GameObject:SetActive(false) + end + + for _, v in ipairs(self.BigGrids) do + v.GameObject:SetActive(false) + end + + -- 大奖要放到前面 + for i = 1, #bigRewardItems do + self:SetRewardInfo(bigRewardItems, i, true) + end + + for i = 1, #smallRewardItems do + self:SetRewardInfo(smallRewardItems, i) + end + + XEventManager.DispatchEvent(XEventId.EVENT_SING_IN_OPEN_BTN, true) +end + +function XUiSignFirstRecharge:SetRewardInfo(rewardItems, i, isBig) + local ui + if isBig then + ui = self.BigGrids[i] + else + ui = self.SmallGrids[i] + end + + if not ui then + local grid = CS.UnityEngine.Object.Instantiate(self.GridCommon) + grid.transform:SetParent(self.PnanelGrid, false) + local bigReward = XUiHelper.TryGetComponent(grid, "ImgBigReward", "Image") + bigReward.gameObject:SetActive(isBig) + ui = XUiGridCommon.New(self.RootUi, grid) + + if isBig then + table.insert(self.BigGrids, ui) + else + table.insert(self.SmallGrids, ui) + end + end + + ui:Refresh(rewardItems[i]) +end + +return XUiSignFirstRecharge \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSignIn/XUiSignGridDay.lua b/Resources/Scripts/XUi/XUiSignIn/XUiSignGridDay.lua new file mode 100644 index 00000000..c7f174b5 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSignIn/XUiSignGridDay.lua @@ -0,0 +1,219 @@ +local XUiSignGridDay = XClass(nil, "XUiSignGridDay") + +function XUiSignGridDay:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self.Grid = nil + + XTool.InitUiObject(self) + self:InitComponent() + self:InitAddListen() +end + +function XUiSignGridDay:InitComponent() + self.PanelNext.gameObject:SetActiveEx(false) +end + +function XUiSignGridDay:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiSignGridDay:RegisterClickEvent函数参数错误:参数func不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiSignGridDay:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiSignGridDay:InitAddListen() + if not self.BtnCard then return end + self:RegisterClickEvent(self.BtnCard, self.OnBtnCardClick) +end + +function XUiSignGridDay:OnBtnCardClick() + XDataCenter.AutoWindowManager.StopAutoWindow() + XLuaUiManager.Open("UiPurchase", XPurchaseConfigs.TabsConfig.YK, false) +end + +--- +--- 福利界面打开时'isShow'为false:不领取奖励、设置明日奖励标识 +--- 打脸时为true:领取奖励、不设置明日奖励标识(领取奖励之后再利用'forceSetTomorrow'来设置明日奖励标识) +--- +--- 打脸时设置对应的奖励的'forceSetTomorrow'为true,设置明日奖励标识 +function XUiSignGridDay:Refresh(config, isShow, forceSetTomorrow) + self.IsShow = isShow + self.Config = config + self.ForceSetTomorrow = forceSetTomorrow + + self.TxtDay.text = string.format("%02d", config.Pre) + if not isShow or forceSetTomorrow then + self:SetTomorrow() + end + + local isAlreadyGet = XDataCenter.SignInManager.JudgeAlreadyGet(config.SignId, config.Round, config.Day) + self.PanelHaveGroup.alpha = isAlreadyGet and 1 or 0 + self.PanelHaveReceive.gameObject:SetActiveEx(isAlreadyGet) + self:SetEffectActive(false) + + local rewardList = XRewardManager.GetRewardList(config.ShowRewardId) + if not rewardList or #rewardList <= 0 then + XEventManager.DispatchEvent(XEventId.EVENT_SING_IN_OPEN_BTN, true) + return + end + + if not self.Grid then + self.Grid = XUiGridCommon.New(self.RootUi, self.GridCommon) + end + + self:SetCardInfo(isAlreadyGet) + self.Grid:Refresh(rewardList[1]) + self.GameObject:SetActiveEx(true) + self:AnimaStart() +end + +--- +--- 设置明日奖励标识 +function XUiSignGridDay:SetTomorrow() + local isTomorrow = XDataCenter.SignInManager.JudgeTomorrow(self.Config.SignId, self.Config.Round, self.Config.Day) + self.PanelNext.gameObject:SetActiveEx(isTomorrow) +end + +--- +--- 检测是否领取奖励 +--- 如果当前是今日奖励,并且已领取,则派发事件,然后开启打脸界面的关闭按钮,并设置明日奖励标识 +function XUiSignGridDay:AnimaStart() + if not self.IsShow then + return + end + + local isToday, isGet = XDataCenter.SignInManager.JudgeTodayGet(self.Config.SignId, self.Config.Round, self.Config.Day) + if not isToday then + return + end + + -- 已经领取奖励,派发事件 + -- XUiSignPrefab:SetTomorrowOpen()不会进入v:SetTomorrow(),因为后面的奖励格子还未初始化 + -- 但是XUiSignPrefab的self.SetTomorrow被设置为true(forceSetTomorrow),所以后面格子的初始化刷新会进行明日奖励的设置 + if isToday and isGet then + XEventManager.DispatchEvent(XEventId.EVENT_SING_IN_OPEN_BTN, true, self.Config) + return + end + + -- 还未领取奖励,将会在签到动画播放完后才派发事件 + -- 这时候奖励格子已经全部初始化完成,会进入XUiSignPrefab:SetTomorrowOpen()的v:SetTomorrow() + self:SetEffectActive(true) + XDataCenter.SignInManager.SignInRequest(self.Config.SignId, function(rewardItems) + self:GetYK(rewardItems) + end, + function() + self:GetYK() + end) +end + +function XUiSignGridDay:SetEffectActive(active) + self.PanelEffect.gameObject:SetActiveEx(active) +end + +-- 设置月卡信息 +function XUiSignGridDay:SetCardInfo() + if not self.BtnCard then return end + + + local isAlreadyGet = XDataCenter.SignInManager.JudgeAlreadyGet(self.Config.SignId, self.Config.Round, self.Config.Day) + local isGot = true + local remainDay = -1 + local ykData = XDataCenter.PurchaseManager.GetCurBoughtYKData() -- 海外修改 + if ykData then + isGot = ykData.IsDailyRewardGet + remainDay = ykData.DailyRewardRemainDay + end + + local isOverdue, canClickYk = XDataCenter.SignInManager.JudgeYKInSignOverdue(self.Config.SignId, self.Config.Round, self.Config.Day, remainDay) + local isToday, _ = XDataCenter.SignInManager.JudgeTodayGet(self.Config.SignId, self.Config.Round, self.Config.Day) + if isOverdue then + self.PanelEnable.gameObject:SetActiveEx(false) + self.PanelDisable.gameObject:SetActiveEx(true) + self.BtnCard.gameObject:SetActiveEx(canClickYk and not isToday) + self.PanelDisable.transform.parent.gameObject:SetActiveEx(not isAlreadyGet or isToday) + return + end + + + self.PanelEnable.gameObject:SetActiveEx(true) + self.PanelDisable.gameObject:SetActiveEx(false) + self.BtnCard.gameObject:SetActiveEx(true) + self.PanelDisable.transform.parent.gameObject:SetActiveEx(not isAlreadyGet or isToday) +end + +-- 领取月卡 +function XUiSignGridDay:GetYK(rewardItems) + local data = XDataCenter.PurchaseManager.GetCurBoughtYKData() -- 海外修改 + XLog.Warning(data) + if not self.BtnCard then + self:HandlerReward(rewardItems) + return + end + + if not data then -- 海外修改 + self:HandlerReward(rewardItems) + return + end + + XDataCenter.PurchaseManager.YKInfoDataReq(function() + if not data or data.IsDailyRewardGet then + self:HandlerReward(rewardItems) + return + end + + XDataCenter.PurchaseManager.PurchaseGetDailyRewardRequest(data.Id, function(rewards) + for _, v in ipairs(rewards) do + if not rewardItems then + rewardItems = {} + end + + table.insert(rewardItems, v) + end + self:HandlerReward(rewardItems) + end, function() + self:HandlerReward(rewardItems) + end) + end) +end + +function XUiSignGridDay:HandlerReward(rewardItems) + if rewardItems and #rewardItems > 0 then + self:SetReward(rewardItems) + else + self:SetNoReward() + end +end + +function XUiSignGridDay:SetReward(rewardItems) + self.PanelHaveGroup.alpha = 1 + self.PanelHaveReceive.gameObject:SetActiveEx(true) + self.GameObject:PlayTimelineAnimation(function() + XUiManager.OpenUiObtain(rewardItems) + self:SetEffectActive(false) + self:SetCardInfo() + XEventManager.DispatchEvent(XEventId.EVENT_SING_IN_OPEN_BTN, true, self.Config) + end) +end + +function XUiSignGridDay:SetNoReward() + self:SetEffectActive(false) + if self.BtnCard then + self.PanelEnable.gameObject:SetActiveEx(false) + self.PanelDisable.gameObject:SetActiveEx(true) + self.BtnCard.gameObject:SetActiveEx(true) + end + XEventManager.DispatchEvent(XEventId.EVENT_SING_IN_OPEN_BTN, true) +end + +return XUiSignGridDay \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSignIn/XUiSignNewYearDrawActivity.lua b/Resources/Scripts/XUi/XUiSignIn/XUiSignNewYearDrawActivity.lua new file mode 100644 index 00000000..cd3157f0 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSignIn/XUiSignNewYearDrawActivity.lua @@ -0,0 +1,36 @@ +local XUiSignNewYearDrawActivity = XClass(nil, "XUiSignNewYearDrawActivity") + +function XUiSignNewYearDrawActivity:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + + XTool.InitUiObject(self) + self:InitAddListen() +end + +function XUiSignNewYearDrawActivity:InitAddListen() + self.BtnGo.CallBack = function() + self:OnBtnGoClick() + end +end + +function XUiSignNewYearDrawActivity:Refresh(signId, isShow) + self.SignId = signId or self.SignId + XEventManager.DispatchEvent(XEventId.EVENT_SING_IN_OPEN_BTN, true) +end + +function XUiSignNewYearDrawActivity:OnBtnGoClick() + local gachaId = XSignInConfigs.GetSignDrawNewYearConfig(self.SignId).GaChaId + XDataCenter.GachaManager.GetGachaRewardInfoRequest(gachaId, function() + XLuaUiManager.Open("UiDrawNewYear", gachaId, self.SignId) + end) +end + +function XUiSignNewYearDrawActivity:OnShow() +end + +function XUiSignNewYearDrawActivity:OnHide() +end + +return XUiSignNewYearDrawActivity \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSignIn/XUiSignPrefab.lua b/Resources/Scripts/XUi/XUiSignIn/XUiSignPrefab.lua new file mode 100644 index 00000000..453fe244 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSignIn/XUiSignPrefab.lua @@ -0,0 +1,250 @@ +local XUiSignGridDay = require("XUi/XUiSignIn/XUiSignGridDay") +local XUiSignPrefab = XClass(nil, "XUiSignPrefab") + + +function XUiSignPrefab:Ctor(ui, rootUi, parent, setTomorrow) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self.Parent = parent + self.SetTomorrow = setTomorrow + + self.OnBtnHelpClickCb = function() self:OnBtnHelpClick() end + XTool.InitUiObject(self) + self:InitAddListen() + + self.DaySmallGrids = {} + table.insert(self.DaySmallGrids, XUiSignGridDay.New(self.GridDaySmall, self.RootUi)) + self.DayBigGrids = {} + table.insert(self.DayBigGrids, XUiSignGridDay.New(self.GridDayBig, self.RootUi)) + self.BtnList = {} + table.insert(self.BtnList, self.BtnTab) +end + +function XUiSignPrefab:InitAddListen() + self.RootUi:RegisterClickEvent(self.BtnHelp, self.OnBtnHelpClickCb) +end + +function XUiSignPrefab:OnBtnHelpClick() + XUiManager.UiFubenDialogTip("", self.SignInInfos[1].Description or "") +end + +--- +--- 福利界面打开时'isShow'为false,打脸打开时为true +function XUiSignPrefab:Refresh(signId, round, isShow) + self.IsShow = isShow + self.SignId = signId + self.Round = round + + local signType = XSignInConfigs.GetSignInType(signId) + if signType == XSignInConfigs.SignType.PurchasePackage then + if self.PanelPrice then + self.PanelPrice.gameObject:SetActiveEx(false) + end + if self.BtnPurchase then + self.BtnPurchase.gameObject:SetActiveEx(false) + end + if self.OffShelf then + self.OffShelf.gameObject:SetActiveEx(false) + end + if self.PanelPurchaseLimit then + self.PanelPurchaseLimit.gameObject:SetActiveEx(false) + end + if self.PanelPurchaseRemain then + self.PanelPurchaseRemain.gameObject:SetActiveEx(false) + end + if not isShow then + self:SetBtnReceiveDisable() + end + end + + local timeId = XSignInConfigs.GetSignTimeId(signId) + local beginTimeStamp, endTimeStamp = XFunctionManager.GetTimeByTimeId(timeId) + self:SetSignTime(self.BeginTime, beginTimeStamp,"MM/dd") + self:SetSignTime(self.EndTime1, endTimeStamp,"MM/dd") + self:SetSignTime(self.EndTime2, endTimeStamp,"HH:mm") + + self:InitTabGroup() +end + +--- +--- 设置签到时间 +---@param textComponent userdata 字符串控件 +---@param timeStamp number 时间戳 +---@param format string 显示的格式 +function XUiSignPrefab:SetSignTime(textComponent, timeStamp, format) + if not textComponent then + return + end + + local timeStr = XTime.TimestampToGameDateTimeString(timeStamp, format) + if timeStr then + textComponent.text = timeStr + else + XLog.Error("XUiSignPrefab:SetSignTime函数错误,formatTimeStr为空") + end +end + +function XUiSignPrefab:InitTabGroup() + for _, v in ipairs(self.BtnList) do + v.gameObject:SetActiveEx(false) + end + + self.SignInInfos = XSignInConfigs.GetSignInInfos(self.SignId) + self:SetRewardInfos(self.Round) + if #self.SignInInfos <= 1 then + return + end + + local btnGroupList = {} + for i = 1, #self.SignInInfos do + local grid = self.BtnList[i] + if not grid then + grid = CS.UnityEngine.Object.Instantiate(self.BtnTab.gameObject) + grid.transform:SetParent(self.PanelTabContent.gameObject.transform, false) + table.insert(self.BtnList, grid) + end + local xBtn = grid.transform:GetComponent("XUiButton") + local rowImg = XUiHelper.TryGetComponent(grid.transform, "RImgIcon", "RawImage") + + table.insert(btnGroupList, xBtn) + xBtn:SetName(self.SignInInfos[i].RoundName) + rowImg:SetRawImage(self.SignInInfos[i].Icon) + xBtn.gameObject:SetActiveEx(true) + end + + self.PanelTabContent:Init(btnGroupList, function(index) + self:SelectPanelRound(index) + end) + + local curRound = XDataCenter.SignInManager.GetSignRound(self.SignId, true) + if curRound then + self.PanelTabContent:SelectIndex(curRound, false) + end +end + +function XUiSignPrefab:SelectPanelRound(index) + self.Parent:RefreshPanel(index) +end + +function XUiSignPrefab:SetRewardInfos(index) + local signInInfo = self.SignInInfos[index] + local rewardConfigs = XSignInConfigs.GetSignInRewardConfigs(self.SignId, signInInfo.Round, false) + + for _, v in ipairs(self.DaySmallGrids) do + v.GameObject:SetActiveEx(false) + end + + for _, v in ipairs(self.DayBigGrids) do + v.GameObject:SetActiveEx(false) + end + + local smallIndex = 1 + local bigIndex = 1 + + for _, config in ipairs(rewardConfigs) do + if config.IsGrandPrix then -- 设置大奖励 + local dayGrid = self.DayBigGrids[bigIndex] + if not dayGrid then + local grid = CS.UnityEngine.GameObject.Instantiate(self.GridDayBig) + grid.transform:SetParent(self.PanelDayContent, false) + dayGrid = XUiSignGridDay.New(grid, self.RootUi) + table.insert(self.DayBigGrids, dayGrid) + end + + dayGrid:Refresh(config, self.IsShow, self.SetTomorrow) + dayGrid.Transform:SetAsLastSibling() + bigIndex = bigIndex + 1 + else -- 设置小奖励 + local dayGrid = self.DaySmallGrids[smallIndex] + if not dayGrid then + local grid = CS.UnityEngine.GameObject.Instantiate(self.GridDaySmall) + grid.transform:SetParent(self.PanelDayContent, false) + dayGrid = XUiSignGridDay.New(grid, self.RootUi) + table.insert(self.DaySmallGrids, dayGrid) + end + + dayGrid:Refresh(config, self.IsShow, self.SetTomorrow) + dayGrid.Transform:SetAsLastSibling() + smallIndex = smallIndex + 1 + end + end +end + +function XUiSignPrefab:SetTomorrowOpen(dayRewardConfig, isRoundLastDay) + local t = XSignInConfigs.GetSignInConfig(dayRewardConfig.SignId) + local isActive = t.Type == XSignInConfigs.SignType.Activity + + if isRoundLastDay and isActive then + for _, v in ipairs(self.DaySmallGrids) do + if v.GameObject.activeSelf and v.Config and + v.Config.SignId == dayRewardConfig.SignId and + v.Config.Round == dayRewardConfig.Round + 1 and + v.Config.Day == 1 then + v:SetTomorrow() + return + end + end + + for _, v in ipairs(self.DayBigGrids) do + if v.GameObject.activeSelf and v.Config and + v.Config.SignId == dayRewardConfig.SignId and + v.Config.Round == dayRewardConfig.Round + 1 and + v.Config.Day == 1 then + v:SetTomorrow() + return + end + end + + return + end + + for _, v in ipairs(self.DaySmallGrids) do + if v.GameObject.activeSelf and v.Config and + v.Config.SignId == dayRewardConfig.SignId and + v.Config.Round == dayRewardConfig.Round and + v.Config.Day - 1 == dayRewardConfig.Day then + v:SetTomorrow() + return + end + end + + for _, v in ipairs(self.DayBigGrids) do + if v.GameObject.activeSelf and v.Config and + v.Config.SignId == dayRewardConfig.SignId and + v.Config.Round == dayRewardConfig.Round and + v.Config.Day - 1 == dayRewardConfig.Day then + v:SetTomorrow() + return + end + end +end + +function XUiSignPrefab:SetBtnReceiveDisable() + if self.BtnReceive then + self.BtnReceive:SetButtonState(XUiButtonState.Disable) + end +end + + +function XUiSignPrefab:SetSignActive(active, round) + if active and self.GameObject.activeSelf then + return + end + + if not active and not self.GameObject.activeSelf then + return + end + + if #self.SignInInfos > 1 then + self.PanelTabContent:SelectIndex(round, false) + end + + self.GameObject:SetActiveEx(active) +end + +function XUiSignPrefab:SetTomorrowForce(isForce) + self.SetTomorrow = isForce +end + +return XUiSignPrefab \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSignIn/XUiSignPrefabContent.lua b/Resources/Scripts/XUi/XUiSignIn/XUiSignPrefabContent.lua new file mode 100644 index 00000000..f4f37b82 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSignIn/XUiSignPrefabContent.lua @@ -0,0 +1,74 @@ +local XUiSignPrefabContent = XClass(nil, "XUiSignPrefabContent") +local XUiSignPrefab = require("XUi/XUiSignIn/XUiSignPrefab") +local MAX_COUNT = 10 + +function XUiSignPrefabContent:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self.PanelSignPrefabs = {} + self.SetTomorrowRound = -1 +end + +function XUiSignPrefabContent:Refresh(signId, isShow) + local panelRounds = {} + + for i = 1, MAX_COUNT do + local panelRound = XUiHelper.TryGetComponent(self.Transform, "PanelRound" .. i, nil) + if not panelRound then + break + end + panelRound.gameObject:SetActiveEx(false) + table.insert(panelRounds, panelRound) + end + + local signInInfos = XSignInConfigs.GetSignInInfos(signId) + for i = 1, #signInInfos do + local panelRound = panelRounds[i] + if not panelRound then + XLog.Error("XUiSignPrefabContent Init Error prefab is not enough round is " .. tostring(i)) + break + end + local signPrefab = self.PanelSignPrefabs[i] + if not signPrefab then + signPrefab = XUiSignPrefab.New(panelRound, self.RootUi, self) + end + self.PanelSignPrefabs[i] = signPrefab + + signPrefab:SetTomorrowForce(self.SetTomorrowRound == i) + signPrefab:Refresh(signId, i, isShow) + end + + local curRound = XDataCenter.SignInManager.GetSignRound(signId, true) + self:RefreshPanel(curRound) +end + +function XUiSignPrefabContent:RefreshPanel(round) + for k,v in pairs(self.PanelSignPrefabs) do + v:SetSignActive(k == round, round) + end +end + +function XUiSignPrefabContent:SetTomorrowOpen(dayRewardConfig) + local isRoundLastDay, curRound = XSignInConfigs.JudgeLastRoundDay(dayRewardConfig.SignId, dayRewardConfig.Round, dayRewardConfig.Day) + if isRoundLastDay then + self.SetTomorrowRound = curRound + 1 + end + + local round = isRoundLastDay and curRound + 1 or curRound + for _,v in pairs(self.PanelSignPrefabs) do + if v.Round == round then + v:SetTomorrowForce(true) + v:SetTomorrowOpen(dayRewardConfig, isRoundLastDay, curRound) + end + v:SetBtnReceiveDisable() + end +end + +function XUiSignPrefabContent:OnHide() +end + +function XUiSignPrefabContent:OnShow() +end + +return XUiSignPrefabContent \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSkip/XUiSkip.lua b/Resources/Scripts/XUi/XUiSkip/XUiSkip.lua new file mode 100644 index 00000000..941e3bc6 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSkip/XUiSkip.lua @@ -0,0 +1,111 @@ +local XUiSkip = XLuaUiManager.Register(XLuaUi, "UiSkip") + +function XUiSkip:OnAwake() + self:InitAutoScript() +end + +--- +--- showSkipList为需要显示的跳转,包含过期但IsShowExplain字段为true的跳转 +function XUiSkip:OnStart(templateId, skipCb, hideSkipBtn, showSkipList) + self.TemplateId = templateId + self.SkipCb = skipCb + self.HideSkipBtn = hideSkipBtn + self.ShowSkipList = showSkipList + self.GridPool = {} + local musicKey = self:GetAutoKey(self.BtnBack, "onClick") + self.SpecialSoundMap[musicKey] = XSoundManager.UiBasicsMusic.Return + self:PlayAnimation("AniSkip") +end + +function XUiSkip:OnEnable() + self:Refresh(self.TemplateId) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiSkip:InitAutoScript() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiSkip:GetAutoKey(uiNode, eventName) + if not uiNode then + return + end + return eventName .. uiNode:GetHashCode() +end + +function XUiSkip:AutoAddListener() + self.AutoCreateListeners = {} + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) +end +-- auto +function XUiSkip:OnBtnBackClick() + self:Close() +end + +function XUiSkip:Refresh(templateId) + self.GameObject:SetActive(templateId) + + if not templateId then + return + end + + local skipIdList = self.ShowSkipList or XGoodsCommonManager.GetGoodsSkipIdParams(templateId) + if not skipIdList or #skipIdList <= 0 then + self:Close() + end + + local hideSkipBtn = {} + if self.HideSkipBtn == true or not self.ShowSkipList then + -- HideSkipBtn为true隐藏 或 没有ShowSkipList数据时,使用HideSkipBtn + for _, skipId in ipairs(skipIdList) do + hideSkipBtn[skipId] = self.HideSkipBtn + end + else + -- HideSkipBtn为false显示 并且有ShowSkipList数据,需要判断跳转有没有过期(隐藏跳转按钮) + for _, skipId in ipairs(skipIdList) do + if XFunctionManager.CheckSkipInDuration(skipId) then + hideSkipBtn[skipId] = false + else + hideSkipBtn[skipId] = true + end + end + end + + local goodsShowParams = XGoodsCommonManager.GetGoodsShowParamsByTemplateId(templateId) + local icon = goodsShowParams.Icon + if goodsShowParams.BigIcon then + icon = goodsShowParams.BigIcon + end + + self.RImgIcon:SetRawImage(icon) + self.TxtIconName.text = goodsShowParams.Name + self.TxtIconNum.text = XGoodsCommonManager.GetGoodsCurrentCount(templateId) + + if goodsShowParams.RewardType == XRewardManager.XRewardType.Equip then + local equipSite = XDataCenter.EquipManager.GetEquipSiteByTemplateId(templateId) + if equipSite and equipSite ~= XEquipConfig.EquipSite.Weapon then + self.TxtSite.text = equipSite + self.PanelSite.gameObject:SetActive(true) + else + self.PanelSite.gameObject:SetActive(false) + end + else + self.PanelSite.gameObject:SetActive(false) + end + + self.PanelGridSkip.gameObject:SetActive(false) + local onCreate = function(grid, data) + grid:Refresh(data, hideSkipBtn[data], function() + --self:Close() + -- 暂停自动弹窗 + XDataCenter.AutoWindowManager.StopAutoWindow() + if self.SkipCb then + self.SkipCb() + end + end) + end + + XUiHelper.CreateTemplates(self, self.GridPool, skipIdList, XUiGridSkip.New, self.PanelGridSkip, self.PanelContent, onCreate) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSocial/AddContactModel/XUiGridAddContactItem.lua b/Resources/Scripts/XUi/XUiSocial/AddContactModel/XUiGridAddContactItem.lua new file mode 100644 index 00000000..5aadbe34 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSocial/AddContactModel/XUiGridAddContactItem.lua @@ -0,0 +1,142 @@ +local XUiGridAddContactItem = XClass(nil, "XUiGridAddContactItem") + +function XUiGridAddContactItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Parent = nil + XTool.InitUiObject(self) + self:InitAutoScript() + self.GameObject:SetActive(false) +end + +function XUiGridAddContactItem:Init(parent) + self.Parent = parent + self.RootUi = parent.RootUi +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiGridAddContactItem:InitAutoScript() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiGridAddContactItem:GetAutoKey(uiNode, eventName) + if not uiNode then + return + end + return eventName .. uiNode:GetHashCode() +end + +function XUiGridAddContactItem:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then + return + end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiGridAddContactItem:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiGridAddContactItem:AutoAddListener() + self.AutoCreateListeners = {} + self.BtnApplyFor.CallBack = function() + self:OnBtnApplyForClick() + end + XUiHelper.RegisterClickEvent(self, self.BtnView, self.OnBtnViewClick) +end +-- auto +function XUiGridAddContactItem:OnBtnApplyForClick() + local successCallBack = function() + XDataCenter.SocialManager.RemoveRecommendPlay(self.Id) + self.Parent:InitDynamicList() + end + XDataCenter.SocialManager.ApplyFriend(self.Id, successCallBack, successCallBack) +end + +function XUiGridAddContactItem:OnBtnViewClick() + --个人信息 + XDataCenter.PersonalInfoManager.ReqShowInfoPanel(self.Id) +end + +function XUiGridAddContactItem:Hide() + if self.GameObject:Exist() then + self.GameObject:SetActive(false) + end +end + +function XUiGridAddContactItem:Show() + if self.GameObject:Exist() then + self.GameObject:SetActive(true) + end +end + +function XUiGridAddContactItem:Refresh(info) + + local medalConfig = XMedalConfigs.GetMeadalConfigById(info.CurrMedalId) + local medalIcon = nil + if medalConfig then + medalIcon = medalConfig.MedalIcon + end + if medalIcon ~= nil then + self.MedalRawImage:SetRawImage(medalIcon) + self.MedalRawImage.gameObject:SetActiveEx(true) + else + self.MedalRawImage.gameObject:SetActiveEx(false) + end + + self.Id = info.FriendId + self.TxtName.text = info.NickName + if info.Sign == nil or (string.len(info.Sign) == 0) then + local text = CS.XTextManager.GetText('CharacterSignTip') + self.TxtSign.text = text + else + self.TxtSign.text = info.Sign + end + + XUiPlayerLevel.UpdateLevel(info.Level, self.TxtLevel) + + if XDataCenter.SocialManager.CheckIsFriend(self.Id) then + self.BtnApplyFor:SetName(CS.XTextManager.GetText("ApplyButtonName2")) + --好友 + self.BtnApplyFor:SetDisable(true, false) + else + self.BtnApplyFor:SetName(CS.XTextManager.GetText("ApplyButtonName1")) + -- 申请 + self.BtnApplyFor:SetDisable(false, true) + end + + if info.IsOnline then + self.TxtOnline.gameObject:SetActive(true) + self.PanelRoleOffLine.gameObject:SetActive(false) + self.PanelRoleOnLine.gameObject:SetActive(true) + self.TxtTime.text = "" + else + self.TxtOnline.gameObject:SetActive(false) + self.PanelRoleOffLine.gameObject:SetActive(true) + self.PanelRoleOnLine.gameObject:SetActive(false) + self.TxtTime.text = CS.XTextManager.GetText("FriendLatelyLogin") .. XUiHelper.CalcLatelyLoginTime(info.LastLoginTime) + end + + XUiPLayerHead.InitPortrait(info.Icon, info.HeadFrameId, self.PanelRoleOnLine) + XUiPLayerHead.InitPortrait(info.Icon, info.HeadFrameId, self.PanelRoleOffLine) + + self:Show() +end + +return XUiGridAddContactItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSocial/AddContactModel/XUiPanelAddContactView.lua b/Resources/Scripts/XUi/XUiSocial/AddContactModel/XUiPanelAddContactView.lua new file mode 100644 index 00000000..1e7f3eb3 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSocial/AddContactModel/XUiPanelAddContactView.lua @@ -0,0 +1,184 @@ +XUiPanelAddContactView = XClass(nil, "XUiPanelAddContactView") +local XUiGridAddContactItem = require("XUi/XUiSocial/AddContactModel/XUiGridAddContactItem") + +function XUiPanelAddContactView:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + self:InitAutoScript() + + self.RecommendedList = {} + + self.DynamicListManager = XDynamicTableNormal.New(self.GameObject) + self.DynamicListManager:SetProxy(XUiGridAddContactItem) + self.DynamicListManager:SetDelegate(self) + self.PanelAddContactViewPools.gameObject:SetActive(false) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelAddContactView:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiPanelAddContactView:AutoInitUi() + -- self.TxtMyId = self.Transform:Find("AddPanelOther/TxtMyId"):GetComponent("Text") + -- self.BtnRefresh = self.Transform:Find("AddPanelOther/BtnRefresh"):GetComponent("Button") + -- self.BtnCopy = self.Transform:Find("AddPanelOther/BtnCopy"):GetComponent("Button") + -- self.BtnSerach = self.Transform:Find("AddPanelOther/BtnSerach"):GetComponent("Button") + -- self.InFSerach = self.Transform:Find("AddPanelOther/InFSerach"):GetComponent("InputField") + -- self.PanelAddContactViewPools = self.Transform:Find("PanelAddContactViewPools") +end + +function XUiPanelAddContactView:GetAutoKey(uiNode, eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiPanelAddContactView:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiPanelAddContactView:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiPanelAddContactView:AutoAddListener() + self.AutoCreateListeners = {} + XUiHelper.RegisterClickEvent(self, self.BtnRefresh, self.OnBtnRefreshClick) + XUiHelper.RegisterClickEvent(self, self.BtnCopy, self.OnBtnCopyClick) + XUiHelper.RegisterClickEvent(self, self.BtnSerach, self.OnBtnSerachClick) +end +-- auto +function XUiPanelAddContactView:OnBtnRefreshClick()--刷新推荐 + self:RefreshList(true) + self.RootUi:PlayAnimation("ContactListShuaXin") +end + +function XUiPanelAddContactView:OnBtnCopyClick()--CopyId + local id = XPlayer.Id + if id ~= nil then + CS.XAppPlatBridge.CopyStringToClipboard(tostring(id)) + end + XUiManager.TipSuccess(CS.XTextManager.GetText("CopySuccess")) +end + +function XUiPanelAddContactView:OnBtnSerachClick()--搜索玩家 + local callback = function(serachFriend) + local temp = {} + table.insert(temp, serachFriend) + self:InitDynamicList(temp) + end + + local inputid = self:GetInputId() + if inputid ~= nil and inputid ~= '' then + if inputid == XPlayer.Id then + XUiManager.TipText("FriendNotAddSelf") + else + XDataCenter.SocialManager.SearchPlayer(inputid, callback) + end + end +end +--------------------------End Btn Event-------------------------- +function XUiPanelAddContactView:RefreshList(isButton) + local callback = function(code) + if code == XCode.Success then + self:InitDynamicList() + if isButton then + XUiManager.TipText("FrienRefreshSuccess") + end + end + end + XDataCenter.SocialManager.GetRecommendPlayers(callback) +end + +function XUiPanelAddContactView:InitDynamicList(contactData) + self.ContactData = contactData or XDataCenter.SocialManager.GetRecommendList() + if not self.ContactData then + return + end + + + self.DynamicListManager:SetDataSource(self.ContactData) + self.DynamicListManager:ReloadDataASync(1) +end + +function XUiPanelAddContactView:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:Refresh(self.ContactData[index]) + end +end + +function XUiPanelAddContactView:StartCountDown() + +end + +function XUiPanelAddContactView:GetInputId() + if self.InFSerach.text ~= '' then + local num = tonumber(self.InFSerach.text) + if num then + return num + end + end + return nil +end + +function XUiPanelAddContactView:Show() + if not self.GameObject:Exist() then + return + end + self.GameObject:SetActive(true) + self.RootUi:PlayAnimation("AddContactViewQieHuan") + self:RefreshSelfInfo() + self:RefreshList(false) + + XEventManager.AddEventListener(XEventId.EVENT_BLACK_DATA_CHANGE, self.RefreshList, self) +end + +function XUiPanelAddContactView:Hide() + if not self.GameObject:Exist() then + return + end + + self.GameObject:SetActive(false) + XEventManager.RemoveEventListener(XEventId.EVENT_BLACK_DATA_CHANGE, self.RefreshList, self) +end + +function XUiPanelAddContactView:RefreshSelfInfo() + local myIdText = CS.XTextManager.GetText("FriendMyId") + self.TxtMyId.text = string.format("%s %d", myIdText, XPlayer.Id) +end + +function XUiPanelAddContactView:OnClose() + self:Hide() + + if self.RecommendTimer ~= nil then + XScheduleManager.UnSchedule(self.RecommendTimer) + self.RecommendTimer = nil + end + + if self.SearchTimer ~= nil then + XScheduleManager.UnSchedule(self.SearchTimer) + self.SearchTimer = nil + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSocial/AddContactModel/XUiPanelAddContactViewPools.lua b/Resources/Scripts/XUi/XUiSocial/AddContactModel/XUiPanelAddContactViewPools.lua new file mode 100644 index 00000000..cd08a03f --- /dev/null +++ b/Resources/Scripts/XUi/XUiSocial/AddContactModel/XUiPanelAddContactViewPools.lua @@ -0,0 +1,56 @@ +XUiPanelAddContactViewPools = XClass(nil, "XUiPanelAddContactViewPools") + +function XUiPanelAddContactViewPools:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self:InitAutoScript() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelAddContactViewPools:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiPanelAddContactViewPools:AutoInitUi() + self.GridAddContact = self.Transform:Find("GridAddContact") +end + +function XUiPanelAddContactViewPools:GetAutoKey(uiNode, eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiPanelAddContactViewPools:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiPanelAddContactViewPools:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiPanelAddContactViewPools:AutoAddListener() + self.AutoCreateListeners = {} +end +-- auto +function XUiPanelAddContactViewPools:InitData(dynamicList) + self.GameObject:SetActive(false) + dynamicList:AddObjectPools("contactItem", self.GridAddContact.gameObject) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSocial/Black/XUiBlackGrid.lua b/Resources/Scripts/XUi/XUiSocial/Black/XUiBlackGrid.lua new file mode 100644 index 00000000..e9c4d11a --- /dev/null +++ b/Resources/Scripts/XUi/XUiSocial/Black/XUiBlackGrid.lua @@ -0,0 +1,136 @@ +local XUiBlackGrid = XClass(nil, "XUiBlackGrid") + +function XUiBlackGrid:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + self.TxtRemark.text = "" + self:AutoAddListener() +end + +function XUiBlackGrid:Init(cb, insertPanelTipsDescCb, isLockRequestRemoveBlacklistFunc) + self.Cb = cb --移除被拉黑的玩家成功后的回调方法 + self.InsertPanelTipsDescCb = insertPanelTipsDescCb --移除被拉黑的玩家成功后插入文本内容的回调方法 + self.IsLockRequestRemoveBlacklistFunc = isLockRequestRemoveBlacklistFunc --是否正在播放动画中 +end + +function XUiBlackGrid:AutoAddListener() + XUiHelper.RegisterClickEvent(self, self.PanelChat, self.OnPanelChatClick) + XUiHelper.RegisterClickEvent(self, self.BtnView, self.OnBtnViewClick) +end + +function XUiBlackGrid:Refresh(playerId, index) + self.PlayerId = playerId + self.Index = index + + local data = XDataCenter.SocialManager.GetBlackData(playerId) + if not data then + return + end + + local medalConfig = XMedalConfigs.GetMeadalConfigById(data.CurrMedalId) + local medalIcon = nil + if medalConfig then + medalIcon = medalConfig.MedalIcon + end + if medalIcon ~= nil then + self.MedalRawImage:SetRawImage(medalIcon) + self.MedalRawImage.gameObject:SetActiveEx(true) + else + self.MedalRawImage.gameObject:SetActiveEx(false) + end + + self.TxtName.text = data.NickName + if data.Sign == nil or (string.len(data.Sign) == 0) then + local text = CS.XTextManager.GetText("CharacterSignTip") + self.TxtNewMessage.text = text + else + self.TxtNewMessage.text = data.Sign + end + self.TxtTime.text = CS.XTextManager.GetText("FriendLatelyLogin") .. XUiHelper.CalcLatelyLoginTime(data.LastLoginTime) + + XUiPlayerLevel.UpdateLevel(data.Level, self.TxtLevel) + + if data.IsOnline then + self.TxtOnline.gameObject:SetActiveEx(true) + self.PanelRoleOffLine.gameObject:SetActiveEx(false) + self.PanelRoleOnLine.gameObject:SetActiveEx(true) + self.TxtTime.gameObject:SetActiveEx(false) + else + self.TxtOnline.gameObject:SetActiveEx(false) + self.PanelRoleOffLine.gameObject:SetActiveEx(true) + self.PanelRoleOnLine.gameObject:SetActiveEx(false) + self.TxtTime.gameObject:SetActiveEx(true) + end + + XUiPLayerHead.InitPortrait(data.Icon, data.HeadFrameId, self.PanelRoleOnLine) + XUiPLayerHead.InitPortrait(data.Icon, data.HeadFrameId, self.PanelRoleOffLine) + + self.CanvasGroup.alpha = 1 + self.Transform.localScale = CS.UnityEngine.Vector3.one + + self:Show() +end + +function XUiBlackGrid:Show() + if self.GameObject:Exist() then + self.GameObject:SetActiveEx(true) + end +end + +function XUiBlackGrid:OnPanelChatClick() + if self.IsLockRequestRemoveBlacklistFunc and self.IsLockRequestRemoveBlacklistFunc() then + return + end + + local playerId = self:GetPlayerId() + local cb = function() + if self.InsertPanelTipsDescCb then + self.InsertPanelTipsDescCb(CS.XTextManager.GetText("SocialBlackRemoveDesc")) + end + + local index = self:GetIndex() + if self.Cb then + self.Cb(index) + end + end + XDataCenter.SocialManager.RequestRemoveBlacklist(playerId, cb) +end + +function XUiBlackGrid:OnBtnViewClick() + --个人信息 + local playerId = self:GetPlayerId() + XDataCenter.PersonalInfoManager.ReqShowInfoPanel(playerId) +end + +function XUiBlackGrid:GetPlayerId() + return self.PlayerId +end + +function XUiBlackGrid:GetIndex() + return self.Index +end + +function XUiBlackGrid:SetPositionY(positionY) + if XTool.UObjIsNil(self.Transform) then + return + end + self.Transform.localPosition = CS.UnityEngine.Vector3(self.Transform.localPosition.x, positionY, 0) +end + +function XUiBlackGrid:GetPositionY() + if XTool.UObjIsNil(self.Transform) then + return + end + return self.Transform.localPosition.y +end + +function XUiBlackGrid:PlayDisableAnimation() + self.GridContactDisable.gameObject:SetActiveEx(true) + self.GridContactDisable:PlayTimelineAnimation(function() + self.GridContactDisable.gameObject:SetActiveEx(false) + end) +end + +return XUiBlackGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSocial/Black/XUiPanelBlackView.lua b/Resources/Scripts/XUi/XUiSocial/Black/XUiPanelBlackView.lua new file mode 100644 index 00000000..7c796606 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSocial/Black/XUiPanelBlackView.lua @@ -0,0 +1,126 @@ +local XUiBlackGrid = require("XUi/XUiSocial/Black/XUiBlackGrid") + +local XUiPanelBlackView = XClass(nil, "XUiPanelBlackView") + +local ANIMATION_TIME = CS.XGame.ClientConfig:GetFloat("SocialBlackAnimationContentShowTime") + +--黑名单界面 +function XUiPanelBlackView:Ctor(ui, rootUi, insertPanelTipsDescCb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + + self.InsertPanelTipsDescCb = insertPanelTipsDescCb + + self.BlackPlayerIdList = {} + + self.ScrollRect = self.PanelBlacklist:GetComponent(typeof(CS.UnityEngine.UI.ScrollRect)) + + self.DynamicListManager = XDynamicTableNormal.New(self.PanelBlacklist) + self.DynamicListManager:SetProxy(XUiBlackGrid) + self.DynamicListManager:SetDelegate(self) + self.GridContact.gameObject:SetActiveEx(false) +end + +function XUiPanelBlackView:Show() + if not self.GameObject:Exist() then + return + end + + self.GameObject:SetActiveEx(true) + self.RootUi:PlayAnimation("AddContactViewQieHuan") + self.ScrollRect.enabled = true + self:Refresh() +end + +function XUiPanelBlackView:OnClose() + self:Hide() +end + +function XUiPanelBlackView:Hide() + if not self.GameObject:Exist() then + return + end + + self.GameObject:SetActive(false) +end + +function XUiPanelBlackView:Refresh() + self:RefreshDynamicList() +end + +function XUiPanelBlackView:RefreshDynamicList() + self:RefreshBlackCount() + + XDataCenter.SocialManager.GetBlacksInfo(function() + self.BlackPlayerIdList = XDataCenter.SocialManager.GetBlackPlayerIdList() + self.DynamicListManager:SetDataSource(self.BlackPlayerIdList) + self.DynamicListManager:ReloadDataSync() + + self.Tips.gameObject:SetActiveEx(#self.BlackPlayerIdList <= 0) + self:RefreshBlackCount() + end) +end + +function XUiPanelBlackView:RefreshBlackCount() + local blackCount = #self.BlackPlayerIdList + local maxCount = CS.XGame.Config:GetInt("FriendMaxBlacklistCount") + self.TxtFriendCount.text = CS.XTextManager.GetText("SocialBlackMaxCountDesc", blackCount, maxCount) +end + +--移除黑名单播放动画后刷新 +function XUiPanelBlackView:RemoveBlackRefresh(index) + self.ScrollRect.enabled = false + + local movePositionYMap = {} + local preGrid + local currGrid + for i = index + 1, #self.BlackPlayerIdList do + preGrid = self.DynamicListManager:GetGridByIndex(i - 1) + currGrid = self.DynamicListManager:GetGridByIndex(i) + if currGrid and preGrid then + movePositionYMap[i] = { + originPositionY = currGrid:GetPositionY(), + movePositionY = preGrid:GetPositionY() - currGrid:GetPositionY() + } + end + end + + local removeGrid = self.DynamicListManager:GetGridByIndex(index) + if removeGrid then + removeGrid:PlayDisableAnimation() + end + + XUiHelper.Tween(ANIMATION_TIME, function(f) + for index, data in pairs(movePositionYMap) do + currGrid = self.DynamicListManager:GetGridByIndex(index) + if currGrid then + currGrid:SetPositionY(data.originPositionY + data.movePositionY * f) + end + end + end, function () + if (XTool.UObjIsNil(self.GameObject)) or not self.GameObject.activeSelf then + return + end + self.ScrollRect.enabled = true + self:Refresh() + end) +end + +function XUiPanelBlackView:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(handler(self, self.RemoveBlackRefresh), self.InsertPanelTipsDescCb, handler(self, self.IsLockRequestRemoveBlacklist)) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:Refresh(self.BlackPlayerIdList[index], index) + end +end + +function XUiPanelBlackView:IsLockRequestRemoveBlacklist() + if XTool.UObjIsNil(self.ScrollRect) then + return false + end + return not self.ScrollRect.enabled +end + +return XUiPanelBlackView \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSocial/ContactModel/XUiGridContactItem.lua b/Resources/Scripts/XUi/XUiSocial/ContactModel/XUiGridContactItem.lua new file mode 100644 index 00000000..92f50937 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSocial/ContactModel/XUiGridContactItem.lua @@ -0,0 +1,236 @@ +local XUiGridContactItem = XClass(nil, "XUiGridContactItem") + +function XUiGridContactItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:InitAutoScript() +end + +function XUiGridContactItem:ResetStatus() + self.TogSelect.gameObject:SetActiveEx(false) +end + +function XUiGridContactItem:Init(mainPanel, parent) + self.MainPanel = mainPanel + self.Parent = parent + + XEventManager.AddEventListener(XEventId.EVENT_CHAT_RECEIVE_PRIVATECHAT, self.NewChatMsgHandler, self) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiGridContactItem:InitAutoScript() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiGridContactItem:GetAutoKey(uiNode, eventName) + if not uiNode then + return + end + return eventName .. uiNode:GetHashCode() +end + +function XUiGridContactItem:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then + return + end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiGridContactItem:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiGridContactItem:AutoAddListener() + self.AutoCreateListeners = {} + XUiHelper.RegisterClickEvent(self, self.BtnView, self.OnBtnViewClick) + self:RegisterListener(self.TogSelect, "onValueChanged", self.OnTogSelectValueChanged) + self.PanelChat.CallBack = function() self:OnBtnChatClick() end + self.BtnRename.CallBack = function() self:OnBtnRenameClick() end +end +-- auto +function XUiGridContactItem:OnTogSelectValueChanged() + if self.IsDeleting then + self.Parent:SetSelectDeleteId(self.Id, self.TogSelect.isOn) + end +end + +function XUiGridContactItem:OnBtnChatClick() + --进入私聊 + --关闭新消息提示 + self.TxtNewMessage.text = '' + self.MainPanel:OpenPrivateChatView(self.Id) + + XDataCenter.ChatManager.SetPrivateChatReadByFriendId(self.Id) +end + +function XUiGridContactItem:OnBtnRenameClick() + if self.Data then + XLuaUiManager.Open("UiSocialRename", self.Data.FriendId, self.Data.NickName, function() + self:RefreshFriendRemark() + end) + end +end + +function XUiGridContactItem:OnBtnViewClick() + --个人信息 + XDataCenter.PersonalInfoManager.ReqShowInfoPanel(self.Id, nil, function() + -- body + end) +end + +function XUiGridContactItem:RefreshFriendRemark() + if self.Data then + local remark = XDataCenter.SocialManager.GetFriendRemark(self.Data.FriendId) + if remark ~= "" then + self.TxtName.text = remark + self.TxtRemark.text = string.format("(%s)", self.Data.NickName) + else + self.TxtName.text = self.Data.NickName + self.TxtRemark.text = "" + end + self:Show() + end +end + +function XUiGridContactItem:ShowDeleteState(isDelete, selectDelete) + self.IsDeleting = isDelete + self.TogSelect.gameObject:SetActiveEx(isDelete) + self.TogSelect.isOn = selectDelete + self:ShowGift(not isDelete) +end + +function XUiGridContactItem:SetSelectDelete(isSelect) + self.TogSelect.isOn = isSelect +end + +function XUiGridContactItem:Refresh(data, isDelete, selectDelete) + if data == nil then + return + end + + local medalConfig = XMedalConfigs.GetMeadalConfigById(data.CurrMedalId) + local medalIcon = nil + if medalConfig then + medalIcon = medalConfig.MedalIcon + end + if medalIcon ~= nil then + self.MedalRawImage:SetRawImage(medalIcon) + self.MedalRawImage.gameObject:SetActiveEx(true) + else + self.MedalRawImage.gameObject:SetActiveEx(false) + end + + self:ResetStatus() + self.Data = data + self.Id = data.FriendId + + self:RefreshFriendRemark() + + XUiPlayerLevel.UpdateLevel(data.Level, self.TxtLevel) + + self.TxtFetterLevel.text = XDataCenter.SocialManager.GetFriendExpLevel(data.FriendId) + + if data.IsOnline then + self.TxtOnline.gameObject:SetActiveEx(true) + self.PanelRoleOffLine.gameObject:SetActiveEx(false) + self.PanelRoleOnLine.gameObject:SetActiveEx(true) + self.TxtRecentLoginTime.text = "" + else + self.TxtOnline.gameObject:SetActiveEx(false) + self.PanelRoleOffLine.gameObject:SetActiveEx(true) + self.PanelRoleOnLine.gameObject:SetActiveEx(false) + self.TxtRecentLoginTime.text = CS.XTextManager.GetText("FriendLatelyLogin") .. XUiHelper.CalcLatelyLoginTime(data.LastLoginTime) + end + + XUiPLayerHead.InitPortrait(data.Icon, data.HeadFrameId, self.PanelRoleOnLine) + XUiPLayerHead.InitPortrait(data.Icon, data.HeadFrameId, self.PanelRoleOffLine) + + self:ShowDeleteState(isDelete, selectDelete) +end + +function XUiGridContactItem:ShowGift(show) + --是否有礼物标识 + if show then + local haveGift = XDataCenter.ChatManager.CheckDoesHaveGiftByFriendId(self.Id) + self.GridCommon.gameObject:SetActiveEx(haveGift) + self.ImgNone.gameObject:SetActiveEx(not haveGift) + else + self.GridCommon.gameObject:SetActiveEx(false) + self.ImgNone.gameObject:SetActiveEx(false) + end +end + +function XUiGridContactItem:Show() + self.GameObject:SetActiveEx(true) + + local chatDataList = XDataCenter.ChatManager.GetPrivateDynamicList(self.Id) + if not chatDataList or #chatDataList <= 0 then + self.TxtNewMessage.text = "" + self:UpdateReadStatus() + return + end + + local msg = chatDataList[1] + if msg then + self:NewChatMsgHandler(msg) + end + self:UpdateReadStatus() +end + +function XUiGridContactItem:NewChatMsgHandler(chatData) + --接收到新消息 + if (chatData:GetChatTargetId() ~= self.Id) then + return + end + if XTool.UObjIsNil(self.GameObject) then + return + end + + self:UpdateReadStatus() + + if chatData.MsgType == ChatMsgType.Emoji then + self.TxtNewMessage.text = CS.XTextManager.GetText("EmojiText") + elseif chatData.MsgType == ChatMsgType.Tips then + self.TxtNewMessage.text = XDataCenter.ChatManager.CreateGiftTips(chatData) + elseif chatData.MsgType == ChatMsgType.Gift then + self.TxtNewMessage.text = XDataCenter.ChatManager.CreateGiftTips(chatData) + elseif chatData.MsgType == ChatMsgType.RoomMsg then + self.TxtNewMessage.text = chatData:GetRoomMsgContent() + else + self.TxtNewMessage.text = chatData.Content + if not string.IsNilOrEmpty(chatData.CustomContent) then + self.TxtNewMessage.supportRichText = true + else + self.TxtNewMessage.supportRichText = false + end + + end + + self:ShowGift(true) +end + +function XUiGridContactItem:UpdateReadStatus() + local code = XDataCenter.ChatManager.GetPrivateUnreadChatCountByFriendId(self.Id) > 0 + + self.ImgNewChatOff.gameObject:SetActiveEx(not code) + self.ImgNewChatOn.gameObject:SetActiveEx(code) +end + +return XUiGridContactItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSocial/ContactModel/XUiPanelContactView.lua b/Resources/Scripts/XUi/XUiSocial/ContactModel/XUiPanelContactView.lua new file mode 100644 index 00000000..6ff5a34e --- /dev/null +++ b/Resources/Scripts/XUi/XUiSocial/ContactModel/XUiPanelContactView.lua @@ -0,0 +1,330 @@ +XUiPanelContactView = XClass(nil, "XUiPanelContactView") +local XUiGridContactItem = require("XUi/XUiSocial/ContactModel/XUiGridContactItem") + +function XUiPanelContactView:Ctor(ui, mainPanel) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.MainPanel = mainPanel + XTool.InitUiObject(self) + self:InitAutoScript() + + + self.FriendList = {} + self.IsDeleteFriendState = false + self.BtnGroupThrowCb = function() XUiManager.TipText("FriendThrowSuccess") end + + self.FriendDatas = {} + self.RemoveIds = {} + + self.DynamicListManager = XDynamicTableNormal.New(self.GameObject) + self.DynamicListManager:SetProxy(XUiGridContactItem) + self.DynamicListManager:SetDelegate(self) + + -- 收到私聊就更新好友排序 + XEventManager.AddEventListener(XEventId.EVENT_CHAT_RECEIVE_PRIVATECHAT, self.RefreshDynamicList, self) + XEventManager.AddEventListener(XEventId.EVENT_BLACK_DATA_CHANGE, self.RefreshDynamicList, self) +end + +function XUiPanelContactView:ResetStatus() + self.IsDeleteFriendState = false + self.PanelShare.gameObject:SetActiveEx(true) + self.PanelFriendList.gameObject:SetActiveEx(true) + self.PanelDeleteFriend.gameObject:SetActiveEx(false) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelContactView:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiPanelContactView:AutoInitUi() + -- self.GridContact = self.Transform:Find("Viewport/ContactList/GridContact") + -- self.PanelDeleteFriend = self.Transform:Find("PanelDeleteFriend") + -- self.BtnRemove = self.Transform:Find("PanelDeleteFriend/BtnRemove"):GetComponent("Button") + -- self.BtnClose = self.Transform:Find("PanelDeleteFriend/BtnClose"):GetComponent("XUiButton") + -- self.PanelShare = self.Transform:Find("Share") + -- self.PanelFriendList = self.Transform:Find("PanelFriendList") + -- self.TxtFriendCount = self.Transform:Find("Share/TxtFriendCount"):GetComponent("Text") + -- self.Tips = self.Transform:Find("Tips") + -- self.BtnAdd = self.Transform:Find("Tips/BtnAdd"):GetComponent("Button") + -- self.BtnDelete = self.Transform:Find("Share/BtnDelete"):GetComponent("XUiButton") + -- self.BtnAllCharge = self.Transform:Find("PanelFriendList/BtnAllCharge"):GetComponent("XUiButton") + -- self.BtnGroupThrow = self.Transform:Find("PanelFriendList/BtnGroupThrow"):GetComponent("XUiButton") +end + +function XUiPanelContactView:GetAutoKey(uiNode, eventName) + if not uiNode then + return + end + return eventName .. uiNode:GetHashCode() +end + +function XUiPanelContactView:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then + return + end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiPanelContactView:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiPanelContactView:AutoAddListener() + self.AutoCreateListeners = {} + XUiHelper.RegisterClickEvent(self, self.BtnAdd, self.OnBtnAddClick) + + self.BtnDelete.CallBack = function() self:OnBtnDeleteClick() end + self.BtnClose.CallBack = function() self:OnBtnCloseClick() end + self.BtnAllCharge.CallBack = function() self:OnBtnAllChargeClick() end + self.BtnGroupThrow.CallBack = function() self:OnBtnGroupThrowClick() end + self.BtnRemove.CallBack = function() self:OnBtnRemoveClick() end +end +-- auto +function XUiPanelContactView:OnBtnAddClick() + --跳转去添加好友 + self.MainPanel:SetSelectedIndex(self.MainPanel.BtnTabIndex.MainAddContact) +end + +function XUiPanelContactView:SetSelectDeleteId(id, isDelete) + self.RemoveIds[id] = isDelete +end + +function XUiPanelContactView:OnBtnRemoveClick() + --确认删除好友 + if not self.IsDeleteFriendState then + return + end + + local removeIds = {} + for k, v in pairs(self.RemoveIds) do + if v then + table.insert(removeIds, k) + end + end + + if #removeIds <= 0 then + XUiManager.TipText("FriendSelectRemoveTip") + self.RemoveIds = {} + return + end + + --确认删除好友的回调 + local removeTip = CS.XTextManager.GetText("FriendRemoveTip") + XUiManager.DialogTip("", removeTip, XUiManager.DialogType.Normal, nil, function() + local callBack = function() + self:UpdateDeleteState(false) + self:RefreshFriendCount() + self:RefreshDynamicList() + end + XDataCenter.SocialManager.DeleteFriends(removeIds, callBack) + self.RemoveIds = {} + end) +end + +function XUiPanelContactView:OnBtnAllChargeClick() + --群收礼物 + local callback = function(giftInfoList, rewardGoodsList) + for i, info in ipairs(giftInfoList) do + local giftCount + if rewardGoodsList and rewardGoodsList[i] then + giftCount = rewardGoodsList[i].Count + end + XDataCenter.ChatManager.UpdateGiftData(info.FriendId, info.GiftId, ChatGiftState.Received, giftCount) + end + + if not rewardGoodsList or #rewardGoodsList < 0 then + return + end + + XUiManager.OpenUiObtain(rewardGoodsList, nil, function() + self:Refresh() + CS.UnityEngine.UI.LayoutRebuilder.ForceRebuildLayoutImmediate(self.Tips) + end, nil) + end + XDataCenter.ChatManager.GetAllGiftsRequest(callback) +end + +function XUiPanelContactView:OnBtnGroupThrowClick() + -- 判断是否有好友 + local targetIds = XDataCenter.SocialManager.GetFriendIds() + if targetIds == nil or #targetIds <= 0 then + return + end + + --群发礼物 + local sendChat = {} + sendChat.ChannelType = ChatChannelType.Private + sendChat.MsgType = ChatMsgType.Gift + sendChat.Content = "" + sendChat.TargetIds = targetIds + + XDataCenter.ChatManager.SendChat(sendChat, self.BtnGroupThrowCb) +end + +function XUiPanelContactView:OnBtnDeleteClick() + self:UpdateDeleteState(not self.IsDeleteFriendState) +end + +function XUiPanelContactView:OnBtnCloseClick() + self:UpdateDeleteState(false) +end + +function XUiPanelContactView:UpdateDeleteState(State) + self.RemoveIds = {} + --点击删除好友(状态改变) + self.IsDeleteFriendState = State + if #self.FriendDatas == 0 then + return + end + + self.PanelDeleteFriend.gameObject:SetActiveEx(State) + self.PanelFriendList.gameObject:SetActiveEx(not State) + + for i, v in ipairs(self.FriendDatas) do + local grid = self.DynamicListManager:GetGridByIndex(i) + if grid ~= nil then + grid:ShowDeleteState(State, self.RemoveIds[v.FriendId]) + end + end + if State then + self.MainPanel:PlayAnimation("DeleteFriendEnable") + end +end + +function XUiPanelContactView:Show() + if not self.GameObject:Exist() then + return + end + + if self.GameObject.activeSelf == false then + self.GameObject:SetActiveEx(true) + end + self.MainPanel:PlayAnimation("ContactViewQieHuan") + self:Refresh() + + XDataCenter.SocialManager.GetFriendsInfo(function() self:Refresh() end) + + CS.UnityEngine.UI.LayoutRebuilder.ForceRebuildLayoutImmediate(self.Tips) +end + +function XUiPanelContactView:RefreshGiftCount() + self.BtnAllCharge:SetName(CS.XTextManager.GetText("SocialGiftTips", XPlayer.DailyReceiveGiftCount, XDataCenter.SocialManager.GetGiftMaxCount())) +end + +function XUiPanelContactView:Hide() + if not self.GameObject:Exist() then + return + end + + if self.GameObject.activeSelf then + self.GameObject:SetActiveEx(false) + end +end + +function XUiPanelContactView:Refresh() + XDataCenter.ChatManager.UpdateGiftStatus() + + self:RefreshFriendCount() + self:RefreshGiftCount() + self:ResetStatus() + + self:RefreshDynamicList() +end + +function XUiPanelContactView:RefreshDynamicList() + local friendDatas = XDataCenter.SocialManager.GetFriendList() + if #friendDatas > 0 then + self.Tips.gameObject:SetActiveEx(false) + else + self.Tips.gameObject:SetActiveEx(true) + end + + self.FriendDatas = self:SortFriendList(friendDatas) + + self.DynamicListManager:SetDataSource(self.FriendDatas) + self.DynamicListManager:ReloadDataASync() +end + +function XUiPanelContactView:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self.MainPanel, self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local friend = self.FriendDatas[index] + if friend then + grid:Refresh(friend, self.IsDeleteFriendState, self.RemoveIds[friend.FriendId]) + end + end +end + +function XUiPanelContactView:IsDeletingIds(friendId) + return self.RemoveIds[friendId] +end + +function XUiPanelContactView:SortFriendList(friendDatas) + --对好友进行排序 + if friendDatas == nil or #friendDatas <= 1 then + return friendDatas + end + + local function FriendSort(item1, item2) + -- 是否有未读消息 + local item1UnreadChat = XDataCenter.ChatManager.GetPrivateUnreadChatCountByFriendId(item1.FriendId) > 0 + local item2UnreadChat = XDataCenter.ChatManager.GetPrivateUnreadChatCountByFriendId(item2.FriendId) > 0 + + if item1UnreadChat == item2UnreadChat then + if item1.IsOnline == item2.IsOnline then + if item1.IsOnline then + -- 双方都在线 + if item1.FriendExp == item2.FriendExp then + return item1.Level > item2.Level + end + return item1.FriendExp > item2.FriendExp + else + -- 双方都不在线 + if item1.LastLoginTime == item2.LastLoginTime then + if item1.FriendExp == item2.FriendExp then + return item1.Level > item2.Level + end + return item1.FriendExp > item2.FriendExp + end + return item1.LastLoginTime > item2.LastLoginTime + end + end + return item1.IsOnline + end + return item1UnreadChat + end + table.sort(friendDatas, FriendSort) + + return friendDatas +end + +function XUiPanelContactView:RefreshFriendCount() + local friendCountText = CS.XTextManager.GetText("FriendCount") + local maxCount = XPlayerManager.GetMaxFriendCount(XPlayer.GetLevelOrHonorLevel(), XPlayer.IsHonorLevelOpen()) + self.TxtFriendCount.text = string.format('%s %d / %d', friendCountText, XDataCenter.SocialManager.GetFriendCount(), maxCount) +end + +--当离开面板的时候调用 +function XUiPanelContactView:OnClose() + XEventManager.RemoveEventListener(XEventId.EVENT_CHAT_RECEIVE_PRIVATECHAT, self.RefreshDynamicList, self) + XEventManager.RemoveEventListener(XEventId.EVENT_BLACK_DATA_CHANGE, self.RefreshDynamicList, self) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSocial/PanelTips/XUiPanelTips.lua b/Resources/Scripts/XUi/XUiSocial/PanelTips/XUiPanelTips.lua new file mode 100644 index 00000000..75031cf2 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSocial/PanelTips/XUiPanelTips.lua @@ -0,0 +1,115 @@ +local XUiTipContent = require("XUi/XUiSocial/PanelTips/XUiTipContent") + +local XUiPanelTips = XClass(nil, "XUiPanelTips") + +local MAX_ANIMATION_NUMBER = 2 +local ANIMATION_DELAY = CS.XGame.ClientConfig:GetFloat("SocialBlackAnimationContentShowTime") +local SECOND = XScheduleManager.SECOND +local HINT_DISABLE_TIME = CS.XGame.ClientConfig:GetInt("SocialHintDisableTime") + +function XUiPanelTips:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + + self.DescList = {} + self.AnimationGridList = {} + self.AnimationIndex = 1 + self.View.gameObject:SetActiveEx(false) + self.Showing = false +end + +function XUiPanelTips:InsertDesc(desc) + self:StopRemoveTipTimer() + table.insert(self.DescList, desc) + self:Show() + self:Refresh() +end + +function XUiPanelTips:GetDesc() + return table.remove(self.DescList, 1) +end + +function XUiPanelTips:Refresh() + local desc = self:GetDesc() + if not desc or self.Showing then + self:StartRemoveTipTimer() + return + end + + self.Showing = true + + if #self.AnimationGridList < MAX_ANIMATION_NUMBER then + self:ShowNewTip(desc) + else + self:PlayDisableAnimation(function() self:ShowNewTip(desc) end) + end +end + +function XUiPanelTips:ShowNewTip(desc) + local obj = CS.UnityEngine.GameObject.Instantiate(self.View.gameObject, self.Transform) + local grid = XUiTipContent.New(obj) + grid:SetAsLastSibling() + grid:Refresh(desc) + grid:SetActive(true) + table.insert(self.AnimationGridList, grid) + + grid:PlayEnableAnimation(function() + self.Showing = false + self:Refresh() + end) +end + +function XUiPanelTips:PlayDisableAnimation(cb) + local obj = self.AnimationGridList[1] + if obj then + obj:PlayDisableAnimation(function() + if (XTool.UObjIsNil(self.GameObject)) or not self.GameObject.activeInHierarchy then + return + end + CS.UnityEngine.GameObject.Destroy(obj:GetGameObject()) + table.remove(self.AnimationGridList, 1) + + if cb then + cb() + end + end) + end +end + +function XUiPanelTips:StartRemoveTipTimer() + self:StopRemoveTipTimer() + self.RemoveTipTimer = XScheduleManager.ScheduleForever(function() + if XTool.IsTableEmpty(self.AnimationGridList[1]) then + self:StopRemoveTipTimer() + return + end + + self:PlayDisableAnimation() + end, HINT_DISABLE_TIME) +end + +function XUiPanelTips:StopRemoveTipTimer() + if self.RemoveTipTimer then + XScheduleManager.UnSchedule(self.RemoveTipTimer) + self.RemoveTipTimer = nil + end +end + +function XUiPanelTips:Show() + self.GameObject.gameObject:SetActiveEx(true) +end + +function XUiPanelTips:Hide() + self:StopRemoveTipTimer() + self.DescList = {} + for _, v in pairs(self.AnimationGridList) do + CS.UnityEngine.GameObject.Destroy(v:GetGameObject()) + end + self.AnimationGridList = {} + self.AnimationIndex = 1 + self.GameObject.gameObject:SetActive(false) +end + +return XUiPanelTips \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSocial/PanelTips/XUiTipContent.lua b/Resources/Scripts/XUi/XUiSocial/PanelTips/XUiTipContent.lua new file mode 100644 index 00000000..41c3aec2 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSocial/PanelTips/XUiTipContent.lua @@ -0,0 +1,45 @@ +local XUiTipContent = XClass(nil, "XUiTipContent") + +function XUiTipContent:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiTipContent:Refresh(desc) + self.Txt.text = desc +end + +function XUiTipContent:SetAlpha(alpha) + self.CanvasGroup.alpha = alpha +end + +function XUiTipContent:SetActive(isActive) + self.GameObject:SetActiveEx(isActive) +end + +function XUiTipContent:SetAsLastSibling() + self.Transform:SetAsLastSibling() +end + +function XUiTipContent:GetDesc() + return self.Txt.text +end + +function XUiTipContent:GetGameObject() + return self.GameObject +end + +function XUiTipContent:PlayEnableAnimation(cb) + if self.GridTipsEnable.gameObject.activeInHierarchy then + self.GridTipsEnable:PlayTimelineAnimation(cb) + end +end + +function XUiTipContent:PlayDisableAnimation(cb) + if self.GridTipsDisable.gameObject.activeInHierarchy then + self.GridTipsDisable:PlayTimelineAnimation(cb) + end +end + +return XUiTipContent \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSocial/PrivateChatModel/ItemModel/XUiGridTishi.lua b/Resources/Scripts/XUi/XUiSocial/PrivateChatModel/ItemModel/XUiGridTishi.lua new file mode 100644 index 00000000..2bbcfcfa --- /dev/null +++ b/Resources/Scripts/XUi/XUiSocial/PrivateChatModel/ItemModel/XUiGridTishi.lua @@ -0,0 +1,89 @@ +XUiGridTishi = XClass(nil, "XUiGridTishi") + +function XUiGridTishi:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self:InitAutoScript() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiGridTishi:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiGridTishi:AutoInitUi() + self.TxtInfo = self.Transform:Find("ImageBg/TxtInfo"):GetComponent("Text") + -- self.TxtTime = XUiHelper.TryGetComponent(self.Transform, "TxtTime", "Text") +end + +function XUiGridTishi:GetAutoKey(uiNode, eventName) + if not uiNode then + return + end + return eventName .. uiNode:GetHashCode() +end + +function XUiGridTishi:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then + return + end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiGridTishi:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiGridTishi:AutoAddListener() + self.AutoCreateListeners = {} +end +-- auto +function XUiGridTishi:Refresh(chatData) + self.CreateTime = chatData.CreateTime + self.SenderId = chatData.SenderId + -- self.TxtTime.text = chatData:GetSendTime() + -- local friend = XDataCenter.SocialManager.GetFriendInfo(chatData.TargetId) + local text = "" + -- if chatData:CheckIsSelfChat() then + -- if (chatData:GetGiftChatType() == GiftChatType.Send) then + -- text = CS.XTextManager.GetText("GiftMoneySendNotReceive", friend.Nickname, chatData.Content) + -- else + -- text = CS.XTextManager.GetText("GiftMoneySendHaveReceive", friend.Nickname, chatData.Content) + -- end + -- else + -- if (chatData:GetGiftChatType() == GiftChatType.Send) then + -- text = CS.XTextManager.GetText("GiftMoneyReceiveNotReceive", chatData.NickName, chatData.Content) + -- else + -- text = CS.XTextManager.GetText("GiftMoneyReceiveHaveReceive", chatData.NickName, chatData.Content) + -- end + -- end + self.TxtInfo.text = text +end + +function XUiGridTishi:Show() + self.GameObject:SetActive(true) +end + +function XUiGridTishi:Hide() + self.GameObject:SetActive(false) +end +function XUiGridTishi:SetShow(code) + self.GameObject:SetActive(code) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSocial/PrivateChatModel/ItemModel/XUiTogFriendBox.lua b/Resources/Scripts/XUi/XUiSocial/PrivateChatModel/ItemModel/XUiTogFriendBox.lua new file mode 100644 index 00000000..3e88975f --- /dev/null +++ b/Resources/Scripts/XUi/XUiSocial/PrivateChatModel/ItemModel/XUiTogFriendBox.lua @@ -0,0 +1,67 @@ +local XUiTogFriendBox = XClass(nil, "XUiTogFriendBox") + +function XUiTogFriendBox:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiTogFriendBox:Init(rootUi) + self.RootUi = rootUi + self.ImgNewTag.gameObject:SetActive(false) + self.RedPointId = XRedPointManager.AddRedPointEvent(self.ImgNewTag, self.OnCheckUnReadMsgCount, self, { XRedPointConditions.Types.CONDITION_FRIEND_CHAT_PRIVATE }, nil, false) +end + +function XUiTogFriendBox:OnCheckUnReadMsgCount(count, args) + if args == self.FriendId then + self.ImgNewTag.gameObject:SetActive(count >= 0) + self.TxtUnMsgCount.text = tostring(count) + end +end + +function XUiTogFriendBox:SetSelect(isSelect) + if isSelect then + self.BtnBackground:SetButtonState(CS.UiButtonState.Select) + else + self.BtnBackground:SetButtonState(CS.UiButtonState.Normal) + end + + self.isSelect = isSelect +end + +function XUiTogFriendBox:UpdateLastChatText() + local chatDataList = XDataCenter.ChatManager.GetPrivateDynamicList(self.FriendId) + if not chatDataList or #chatDataList <= 0 then + self.BtnBackground:SetTxtByObjName("TxtNewChat", "") + return + end + + local chatData = chatDataList[1] + if chatData.MsgType == ChatMsgType.Emoji then + self.BtnBackground:SetTxtByObjName("TxtNewChat", CS.XTextManager.GetText("EmojiText")) + elseif chatData.MsgType == ChatMsgType.Tips then + self.BtnBackground:SetTxtByObjName("TxtNewChat", XDataCenter.ChatManager.CreateGiftTips(chatData)) + elseif chatData.MsgType == ChatMsgType.Gift then + self.BtnBackground:SetTxtByObjName("TxtNewChat", XDataCenter.ChatManager.CreateGiftTips(chatData)) + elseif chatData.MsgType == ChatMsgType.RoomMsg then + self.BtnBackground:SetTxtByObjName("TxtNewChat", chatData:GetRoomMsgContent()) + else + self.BtnBackground:SetTxtByObjName("TxtNewChat", chatData.Content) + end +end + +function XUiTogFriendBox:Refresh(friendData, isSelect) + if friendData == nil then + return + end + + self.FriendId = friendData.FriendId + self:SetSelect(isSelect) + self:UpdateLastChatText() + XUiPLayerHead.InitPortrait(friendData.Icon, friendData.HeadFrameId, self.Head) + self.BtnBackground:SetTxtByObjName("TxtFriendName", XDataCenter.SocialManager.GetPlayerRemark(self.FriendId, friendData.NickName)) + XRedPointManager.Check(self.RedPointId, self.FriendId) +end + + +return XUiTogFriendBox \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSocial/PrivateChatModel/NewItemModel/XUiPanelSocialMyMsgEmojiItem.lua b/Resources/Scripts/XUi/XUiSocial/PrivateChatModel/NewItemModel/XUiPanelSocialMyMsgEmojiItem.lua new file mode 100644 index 00000000..61fb7ebf --- /dev/null +++ b/Resources/Scripts/XUi/XUiSocial/PrivateChatModel/NewItemModel/XUiPanelSocialMyMsgEmojiItem.lua @@ -0,0 +1,83 @@ +XUiPanelSocialMyMsgEmojiItem = XClass(nil, "XUiPanelSocialMyMsgEmojiItem") + +function XUiPanelSocialMyMsgEmojiItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:InitAutoScript() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelSocialMyMsgEmojiItem:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiPanelSocialMyMsgEmojiItem:AutoInitUi() + -- self.PanelRole = self.Transform:Find("PanelRole") + -- self.RImgIcon = self.Transform:Find("PanelRole/RImgIcon"):GetComponent("RawImage") + -- self.HeadIconEffect = self.Transform:Find("PanelRole/RImgIcon/Effect"):GetComponent("XUiEffectLayer") + -- self.BtnView = self.Transform:Find("PanelRole/BtnView"):GetComponent("Button") + -- self.PanelMsg = self.Transform:Find("PanelMsg") + -- self.TxtName = self.Transform:Find("PanelMsg/TxtName"):GetComponent("Text") + -- self.RImgEmoji = self.Transform:Find("PanelMsg/Content/RImgEmoji"):GetComponent("RawImage") +end + +function XUiPanelSocialMyMsgEmojiItem:GetAutoKey(uiNode, eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiPanelSocialMyMsgEmojiItem:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiPanelSocialMyMsgEmojiItem:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiPanelSocialMyMsgEmojiItem:AutoAddListener() + self.AutoCreateListeners = {} + XUiHelper.RegisterClickEvent(self, self.BtnView, self.OnBtnViewClick) +end +-- auto +function XUiPanelSocialMyMsgEmojiItem:OnBtnViewClick() + if XDataCenter.RoomManager.RoomData and self.PlayerId == XPlayer.Id then + --在房间中不能在聊天打开自己详情面板 + return + end + if self.PlayerId then + XDataCenter.PersonalInfoManager.ReqShowInfoPanel(self.PlayerId) + end +end + +function XUiPanelSocialMyMsgEmojiItem:Refresh(chatData) + local icon = XDataCenter.ChatManager.GetEmojiIcon(chatData.Content) + if icon ~= nil then + self.RImgEmoji:SetRawImage(icon) + end + self.TxtName.text = XDataCenter.SocialManager.GetPlayerRemark(chatData.SenderId, chatData.NickName) + XUiPLayerHead.InitPortrait(chatData.Icon, chatData.HeadFrameId, self.Head) + self.PlayerId = chatData.SenderId +end + +function XUiPanelSocialMyMsgEmojiItem:SetShow() + +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSocial/PrivateChatModel/NewItemModel/XUiPanelSocialMyMsgGiftItem.lua b/Resources/Scripts/XUi/XUiSocial/PrivateChatModel/NewItemModel/XUiPanelSocialMyMsgGiftItem.lua new file mode 100644 index 00000000..528e847e --- /dev/null +++ b/Resources/Scripts/XUi/XUiSocial/PrivateChatModel/NewItemModel/XUiPanelSocialMyMsgGiftItem.lua @@ -0,0 +1,128 @@ +XUiPanelSocialMyMsgGiftItem = XClass(nil, "XUiPanelSocialMyMsgGiftItem") + +function XUiPanelSocialMyMsgGiftItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:InitAutoScript() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelSocialMyMsgGiftItem:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiPanelSocialMyMsgGiftItem:AutoInitUi() + -- self.PanelRole = self.Transform:Find("PanelRole") + -- self.RImgHead = self.Transform:Find("PanelRole/RImgHead"):GetComponent("RawImage") + -- self.HeadIconEffect = self.Transform:Find("PanelRole/RImgHead/Effect"):GetComponent("XUiEffectLayer") + -- self.BtnView = self.Transform:Find("PanelRole/BtnView"):GetComponent("Button") + -- self.PanelMsg = self.Transform:Find("PanelMsg") + -- self.TxtName = self.Transform:Find("PanelMsg/TxtName"):GetComponent("Text") + -- self.RImgIcon = self.Transform:Find("PanelMsg/Content/RImgIcon"):GetComponent("RawImage") + -- self.BtnClick = self.Transform:Find("PanelMsg/Content/BtnClick"):GetComponent("Button") + -- self.ImgGet = self.Transform:Find("PanelMsg/Content/ImgGet"):GetComponent("Image") + -- self.ImgNoGet = self.Transform:Find("PanelMsg/Content/ImgNoGet"):GetComponent("Image") + -- self.ImgFetch = self.Transform:Find("PanelMsg/Content/ImgFetch"):GetComponent("Image") +end + +function XUiPanelSocialMyMsgGiftItem:GetAutoKey(uiNode, eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiPanelSocialMyMsgGiftItem:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiPanelSocialMyMsgGiftItem:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiPanelSocialMyMsgGiftItem:AutoAddListener() + self.AutoCreateListeners = {} + XUiHelper.RegisterClickEvent(self, self.BtnView, self.OnBtnViewClick) + XUiHelper.RegisterClickEvent(self, self.BtnClick, self.OnBtnClickClick) +end +-- auto +function XUiPanelSocialMyMsgGiftItem:OnBtnViewClick()--查看个人信息 + if XDataCenter.RoomManager.RoomData and self.playerId == XPlayer.Id then + --在房间中不能在聊天打开自己详情面板 + return + end + XDataCenter.PersonalInfoManager.ReqShowInfoPanel(self.playerId) +end + +function XUiPanelSocialMyMsgGiftItem:OnBtnClickClick() + if self.playerId == XPlayer.Id then + return + end + + local callback = function(rewardGoodsList) + XUiManager.OpenUiObtain(rewardGoodsList, nil, function() + self.ImgGet.gameObject:SetActive(false) + self.ImgNoGet.gameObject:SetActive(true) + + local giftCount + if rewardGoodsList and rewardGoodsList[1] then + giftCount = rewardGoodsList[1].Count + end + XDataCenter.ChatManager.UpdateGiftData(self.playerId, self.ChatData.GiftId, ChatGiftState.Received, giftCount) + + self.Parent:UpdatePrivateDynamicList() + end, nil) + end + XDataCenter.ChatManager.GetGift(self.ChatData.GiftId, callback) +end + +function XUiPanelSocialMyMsgGiftItem:Refresh(chatData) + self.playerId = chatData.SenderId + self:SetShow(true) + self.ChatData = chatData + self.CreateTime = chatData.CreateTime + self.SenderId = chatData.SenderId + self.TxtName.text = XDataCenter.SocialManager.GetPlayerRemark(chatData.SenderId, chatData.NickName) + XUiPLayerHead.InitPortrait(chatData.Icon, chatData.HeadFrameId, self.Head) + + if chatData:CheckIsSelfChat() then + self.ImgGet.gameObject:SetActive(false) + self.ImgNoGet.gameObject:SetActive(false) + self.ImgFetch.gameObject:SetActive(false) + return + end + if chatData.GiftStatus == ChatGiftState.WaitReceive then + self.ImgGet.gameObject:SetActive(true) + self.ImgNoGet.gameObject:SetActive(false) + self.ImgFetch.gameObject:SetActive(false) + elseif chatData.GiftStatus == ChatGiftState.Fetched then + self.ImgGet.gameObject:SetActive(false) + self.ImgNoGet.gameObject:SetActive(false) + self.ImgFetch.gameObject:SetActive(true) + else + self.ImgGet.gameObject:SetActive(false) + self.ImgNoGet.gameObject:SetActive(true) + self.ImgFetch.gameObject:SetActive(false) + end +end + +function XUiPanelSocialMyMsgGiftItem:SetShow(code) + self.GameObject.gameObject:SetActive(code) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSocial/PrivateChatModel/NewItemModel/XUiPanelSocialMyMsgItem.lua b/Resources/Scripts/XUi/XUiSocial/PrivateChatModel/NewItemModel/XUiPanelSocialMyMsgItem.lua new file mode 100644 index 00000000..9207a6a0 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSocial/PrivateChatModel/NewItemModel/XUiPanelSocialMyMsgItem.lua @@ -0,0 +1,110 @@ +XUiPanelSocialMyMsgItem = XClass(nil, "XUiPanelSocialMyMsgItem") + +function XUiPanelSocialMyMsgItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:InitAutoScript() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelSocialMyMsgItem:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiPanelSocialMyMsgItem:AutoInitUi() + +end + +function XUiPanelSocialMyMsgItem:GetAutoKey(uiNode, eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiPanelSocialMyMsgItem:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiPanelSocialMyMsgItem:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiPanelSocialMyMsgItem:AutoAddListener() + self.AutoCreateListeners = {} + XUiHelper.RegisterClickEvent(self, self.BtnView, self.OnBtnViewClick) + self:RegisterListener(self.TxtWord, "onHrefClick", self.OnBtnHrefClick) +end +-- auto +function XUiPanelSocialMyMsgItem:OnBtnViewClick() + if XDataCenter.RoomManager.RoomData and self.playerId == XPlayer.Id then + --在房间中不能在聊天打开自己详情面板 + return + end + XDataCenter.PersonalInfoManager.ReqShowInfoPanel(self.playerId, nil, nil, self.ChatContent) +end + +function XUiPanelSocialMyMsgItem:OnBtnHrefClick(param) + XDataCenter.RoomManager.ClickEnterRoomHref(param, self.CreateTime) +end + +function XUiPanelSocialMyMsgItem:Refresh(chatData) + if chatData == nil then + return + end + self.playerId = chatData.SenderId + self.ChatContent = chatData.Content + + self.TxtName.text = XDataCenter.SocialManager.GetPlayerRemark(chatData.SenderId, chatData.NickName) + XUiPLayerHead.InitPortrait(chatData.Icon, chatData.HeadFrameId, self.Head) + + self.CreateTime = chatData.CreateTime + self:SetText(chatData) + self:SetShow(true) +end + +function XUiPanelSocialMyMsgItem:SetText(chatData) + if chatData.MsgType == ChatMsgType.RoomMsg then + self:SetRoomMsgText(chatData) + else + self:SetNormalMsgText(chatData) + end + +end + +function XUiPanelSocialMyMsgItem:SetRoomMsgText(chatData) + self.TxtWord.supportRichText = true + + self.TxtWord.text = chatData:GetRoomMsgContent() +end + +function XUiPanelSocialMyMsgItem:SetNormalMsgText(chatData) + if not string.IsNilOrEmpty(chatData.CustomContent) then + self.TxtWord.supportRichText = true + else + self.TxtWord.supportRichText = false + end + + self.TxtWord.text = chatData.Content +end + +function XUiPanelSocialMyMsgItem:SetShow(code) + self.GameObject.gameObject:SetActive(code) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSocial/PrivateChatModel/NewItemModel/XUiPanelSocialTipsItem.lua b/Resources/Scripts/XUi/XUiSocial/PrivateChatModel/NewItemModel/XUiPanelSocialTipsItem.lua new file mode 100644 index 00000000..73c1646f --- /dev/null +++ b/Resources/Scripts/XUi/XUiSocial/PrivateChatModel/NewItemModel/XUiPanelSocialTipsItem.lua @@ -0,0 +1,18 @@ +XUiPanelSocialTipsItem = XClass(nil, "XUiPanelSocialTipsItem") + +function XUiPanelSocialTipsItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiPanelSocialTipsItem:Refresh(chatData) + self.CreateTime = chatData.CreateTime + self.SenderId = chatData.SenderId + + self.TxtInfo.text = XDataCenter.ChatManager.CreateGiftTips(chatData) +end + +function XUiPanelSocialTipsItem:SetShow(code) + self.GameObject:SetActiveEx(code) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSocial/PrivateChatModel/Pools/XUiPanelGroupPools.lua b/Resources/Scripts/XUi/XUiSocial/PrivateChatModel/Pools/XUiPanelGroupPools.lua new file mode 100644 index 00000000..175592d0 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSocial/PrivateChatModel/Pools/XUiPanelGroupPools.lua @@ -0,0 +1,57 @@ +XUiPanelGroupPools = XClass(nil, "XUiPanelGroupPools") + +function XUiPanelGroupPools:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self:InitAutoScript() +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelGroupPools:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiPanelGroupPools:AutoInitUi() + self.TogFriendBox = self.Transform:Find("TogFriendBox"):GetComponent("Toggle") +end + +function XUiPanelGroupPools:GetAutoKey(uiNode, eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiPanelGroupPools:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiPanelGroupPools:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiPanelGroupPools:AutoAddListener() + self.AutoCreateListeners = {} + self:RegisterListener(self.TogFriendBox, "onValueChanged", self.OnTogFriendBoxValueChanged) +end +-- auto +function XUiPanelGroupPools:InitData(dynamicList) + self.GameObject:SetActive(false) + dynamicList:AddObjectPools("groupItem", self.TogFriendBox.gameObject) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSocial/PrivateChatModel/Pools/XUiPanelSocialPools.lua b/Resources/Scripts/XUi/XUiSocial/PrivateChatModel/Pools/XUiPanelSocialPools.lua new file mode 100644 index 00000000..9ba42e9b --- /dev/null +++ b/Resources/Scripts/XUi/XUiSocial/PrivateChatModel/Pools/XUiPanelSocialPools.lua @@ -0,0 +1,67 @@ +XUiPanelSocialPools = XClass(nil, "XUiPanelSocialPools") + +function XUiPanelSocialPools:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self:InitAutoScript() +end +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelSocialPools:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiPanelSocialPools:AutoInitUi() + self.PanelOtherMsgItem = self.Transform:Find("PanelSocialOhterMsgItem") + self.PanelMyMsgItem = self.Transform:Find("PanelSocialMyMsgItem") + self.PanelTipsItem = self.Transform:Find("PanelSocialTipsItem") + self.PanelMyMsgGiftItem = self.Transform:Find("PanelSocialMyMsgGiftItem") + self.PanelOtherMsgGiftItem = self.Transform:Find("PanelSocialOhterMsgGiftItem") + self.PanelMyMsgEmojiItem = self.Transform:Find("PanelSocialMyMsgEmojiItem") + self.PanelOtherMsgEmojiItem = self.Transform:Find("PanelSocialOhterMsgEmojiItem") +end + +function XUiPanelSocialPools:GetAutoKey(uiNode, eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiPanelSocialPools:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiPanelSocialPools:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiPanelSocialPools:AutoAddListener() + self.AutoCreateListeners = {} +end + +function XUiPanelSocialPools:InitData(dynamicList) + self.GameObject:SetActive(false) + dynamicList:AddObjectPools("myMsg", self.PanelMyMsgItem.gameObject) + dynamicList:AddObjectPools("otherMsg", self.PanelOtherMsgItem.gameObject) + dynamicList:AddObjectPools("myEmoji", self.PanelMyMsgEmojiItem.gameObject) + dynamicList:AddObjectPools("otherEmoji", self.PanelOtherMsgEmojiItem.gameObject) + dynamicList:AddObjectPools("myGift", self.PanelMyMsgGiftItem.gameObject) + dynamicList:AddObjectPools("otherGift", self.PanelOtherMsgGiftItem.gameObject) + dynamicList:AddObjectPools("tips", self.PanelTipsItem.gameObject) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSocial/PrivateChatModel/XUiPanelPrivateChatView.lua b/Resources/Scripts/XUi/XUiSocial/PrivateChatModel/XUiPanelPrivateChatView.lua new file mode 100644 index 00000000..d0c8629a --- /dev/null +++ b/Resources/Scripts/XUi/XUiSocial/PrivateChatModel/XUiPanelPrivateChatView.lua @@ -0,0 +1,321 @@ +XUiPanelPrivateChatView = XClass(nil, "XUiPanelPrivateChatView") +local XUiTogFriendBox = require("XUi/XUiSocial/PrivateChatModel/ItemModel/XUiTogFriendBox") + +-- WorldChatBoxType = { +-- OtherChatBox = 1, +-- OtherChatBoxEmoji = 2, +-- SelfChatBox = 3, +-- SelfChatBoxEmoji = 4 +-- } + +function XUiPanelPrivateChatView:Ctor(rootUi, ui, onBtnBackClick) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.OnBtnBackClick = onBtnBackClick + XTool.InitUiObject(self) + self:InitAutoScript() + self.ChatButtonGroups = {} + self.FriendId = 0 + self:InitView() + self:Hide() + self.XUiPanelFriendEmoji = XUiPanelEmoji.New(self.RootUi, self.PanelEmoji, self) + local clickCallBack = function(content) + self.XUiPanelFriendEmoji:Hide() + self:OnClickEmoji(content) + end + self.XUiPanelFriendEmoji:SetClickCallBack(clickCallBack) + + self.XUiPanelSocialPools = XUiPanelSocialPools.New(self.PanelSocialPools) + + self.PrivateDynamicList = XDynamicList.New(self.PanelChatView.transform, self) + self.PrivateDynamicList:SetReverse(true) + + self.PanelMsgListPools = XUiPanelSocialPools.New(self.PanelMsgListPools) + self.PanelMsgListPools:InitData(self.PrivateDynamicList) + + self.GroupDynamicListManager = XDynamicTableNormal.New(self.ContactGroupList) + self.GroupDynamicListManager:SetProxy(XUiTogFriendBox) + self.GroupDynamicListManager:SetDelegate(self) + self.GroupDynamicListManager:SetDynamicEventDelegate(function(...) self:OnGroupDynamicTableEvent(...) end) +end + +function XUiPanelPrivateChatView:InitView() + --初始化View + self.PanelEmoji.gameObject:SetActive(false) + self.PanelInputField.characterLimit = CS.XGame.ClientConfig:GetInt("PrivateChatTextLimit") +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelPrivateChatView:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiPanelPrivateChatView:AutoInitUi() + -- self.PanelChatView = self.Transform:Find("Content/MsgList/Content/PanelChatView"):GetComponent("XVerticalDynamicList") + -- self.PanelSocialPools = self.Transform:Find("Content/MsgList/Content/PanelChatView/PanelSocialPools") + -- self.PanelInputField = self.Transform:Find("Content/MsgList/Share/PanelInputField"):GetComponent("InputField") + -- self.ContactGroupList = self.Transform:Find("Content/ContactGroupList") + -- self.PanelEmoji = self.Transform:Find("Content/MsgList/Share/PanelEmoji") + -- self.PanelMsgListPools = self.Transform:Find("Content/MsgList/Content/PanelChatView/PanelSocialPools") + -- self.BtnSendMsg = self.Transform:Find("Content/MsgList/Share/BtnSendMsg"):GetComponent("XUiButton") + -- self.BtnEmoji = self.Transform:Find("Content/MsgList/Share/BtnEmoji"):GetComponent("XUiButton") + -- self.BtnLuomu = self.Transform:Find("Content/MsgList/Share/BtnLuomu"):GetComponent("XUiButton") +end + +function XUiPanelPrivateChatView:GetAutoKey(uiNode, eventName) + if not uiNode then + return + end + return eventName .. uiNode:GetHashCode() +end + +function XUiPanelPrivateChatView:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then + return + end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiPanelPrivateChatView:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiPanelPrivateChatView:AutoAddListener() + self.AutoCreateListeners = {} + XUiHelper.RegisterClickEvent(self, self.BtnSendMsg, self.OnBtnSendMsgClick) + + self.BtnSendMsg.CallBack = function() self:OnBtnSendMsgClick() end + self.BtnEmoji.CallBack = function() self:OnBtnEmojiPanelClick() end + self.BtnLuomu.CallBack = function() self:OnBtnCoinPanelClick() end +end +-- auto +function XUiPanelPrivateChatView:OnBtnSendMsgClick() + --发送聊天消息 + local text = self.PanelInputField.text + if text == nil or text == "" then + return + end + + self.PanelInputField.text = "" + + -- 替换空白控制符 + text = string.gsub(text, "%s", " ") + + local sendChat = {} + sendChat.ChannelType = ChatChannelType.Private + sendChat.MsgType = ChatMsgType.Normal + sendChat.Content = text + sendChat.TargetIds = { self.FriendId } + XDataCenter.ChatManager.SendChat(sendChat, nil, true) +end + +function XUiPanelPrivateChatView:OnBtnAddClick() + if self.PanelEmoji.gameObject.activeInHierarchy then + self.PanelEmoji.gameObject:SetActive(false) + end +end + +function XUiPanelPrivateChatView:OnBtnEmojiPanelClick() + --打开表情面板 + self.XUiPanelFriendEmoji:OpenOrClosePanel() +end + +function XUiPanelPrivateChatView:OnBtnCoinPanelClick() + --发送螺母 + if XDataCenter.SocialManager.GetFriendInfo(self.FriendId) == nil then + XUiManager.TipError(CS.XTextManager.GetText("ChatManagerNotSendCoinToNotFriend")) + return + end + + local sendChat = {} + sendChat.ChannelType = ChatChannelType.Private + sendChat.MsgType = ChatMsgType.Gift + sendChat.Content = "" + sendChat.TargetIds = { self.FriendId } + + XDataCenter.ChatManager.SendChat(sendChat) +end + +function XUiPanelPrivateChatView:OnBtnPanelChooseBackClick() + self.XUiPanelFriendEmoji:Hide() +end + +function XUiPanelPrivateChatView:OnClickEmoji(content) + --发送表情 + local sendChat = {} + sendChat.ChannelType = ChatChannelType.Private + sendChat.MsgType = ChatMsgType.Emoji + sendChat.Content = content + sendChat.TargetIds = { self.FriendId } + XDataCenter.ChatManager.SendChat(sendChat) +end + +----------------------------------------------------------------------------------- +function XUiPanelPrivateChatView:OnEnable() + if self.GameObject.activeSelf == false then + return + end + self:InitData() +end + +function XUiPanelPrivateChatView:Refresh(friendId) + --friend为选中的玩家ID + self.GameObject:SetActive(true) + self.RootUi:PlayAnimation("PrivateChatViewEnable") + self.FriendId = friendId + self:InitData() + + XEventManager.AddEventListener(XEventId.EVENT_CHAT_RECEIVE_PRIVATECHAT, self.NewChatMsgHandler, self) + XEventManager.AddEventListener(XEventId.EVENT_BLACK_DATA_CHANGE, self.OnBtnBackClick, self) +end + +function XUiPanelPrivateChatView:InitData() + XDataCenter.ChatManager.UpdateGiftStatus() + + self:UpdatePrivateDynamicList() + + self:UpdateGroupDynamicList() +end + +function XUiPanelPrivateChatView:UpdatePrivateDynamicList() + local msgData = XDataCenter.ChatManager.GetPrivateDynamicList(self.FriendId) + --初始化私聊动态列表数据 + self.PrivateDynamicList:SetData(msgData, function(data, cb) + local poolName = nil + local ctor = nil + if (data.MsgType == ChatMsgType.Normal or data.MsgType == ChatMsgType.RoomMsg) and data.SenderId == XPlayer.Id then + poolName = "myMsg" + ctor = XUiPanelSocialMyMsgItem.New + elseif (data.MsgType == ChatMsgType.Normal or data.MsgType == ChatMsgType.RoomMsg) and data.SenderId ~= XPlayer.Id then + poolName = "otherMsg" + ctor = XUiPanelSocialMyMsgItem.New + elseif data.MsgType == ChatMsgType.Emoji and data.SenderId == XPlayer.Id then + poolName = "myEmoji" + ctor = XUiPanelSocialMyMsgEmojiItem.New + elseif data.MsgType == ChatMsgType.Emoji and data.SenderId ~= XPlayer.Id then + poolName = "otherEmoji" + ctor = XUiPanelSocialMyMsgEmojiItem.New + elseif data.MsgType == ChatMsgType.Gift and data.SenderId == XPlayer.Id then + poolName = "myGift" + ctor = XUiPanelSocialMyMsgGiftItem.New + elseif data.MsgType == ChatMsgType.Gift and data.SenderId ~= XPlayer.Id then + poolName = "otherGift" + ctor = XUiPanelSocialMyMsgGiftItem.New + elseif data.MsgType == ChatMsgType.Tips then + poolName = "tips" + ctor = XUiPanelSocialTipsItem.New + end + if cb and poolName and ctor then + local item = cb(poolName, ctor) + item.RootUi = self.RootUi + item.Parent = self + item:Refresh(data) + else + XLog.Error("------Init social privateChatData item is error!------") + end + end) + + XDataCenter.ChatManager.SetPrivateChatReadByFriendId(self.FriendId) +end + +function XUiPanelPrivateChatView:UpdateGroupDynamicList() + self.FriendGroupData = XDataCenter.ChatManager.GetPrivateChatGroupData(self.FriendId) + + self.GroupDynamicListManager:SetDataSource(self.FriendGroupData) + self.GroupDynamicListManager:ReloadDataASync() +end + +function XUiPanelPrivateChatView:OnDynamicTableEvent() + +end + +function XUiPanelPrivateChatView:OnGroupDynamicTableEvent(event, index, grid) + local friend = self.FriendGroupData[index] + + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self.RootUi) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:Refresh(friend, friend.FriendId == self.FriendId) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + local lastIndex, lastFriend = self:GetGroupDataByFriendId(self.FriendId) + local lastGrid = self.GroupDynamicListManager:GetGridByIndex(lastIndex) + if lastGrid then + lastGrid:Refresh(lastFriend, false) + end + + self.FriendId = friend.FriendId + self:UpdatePrivateDynamicList() + grid:Refresh(friend, true) + end +end + +function XUiPanelPrivateChatView:GetGroupDataByFriendId(friendId) + for k, friend in pairs(self.FriendGroupData) do + if friendId == friend.FriendId then + return k, friend + end + end +end + +function XUiPanelPrivateChatView:Hide() + XEventManager.RemoveEventListener(XEventId.EVENT_CHAT_RECEIVE_PRIVATECHAT, self.NewChatMsgHandler, self) + XEventManager.RemoveEventListener(XEventId.EVENT_BLACK_DATA_CHANGE, self.BlackDataChange, self) + + if not XTool.UObjIsNil(self.GameObject) and self.GameObject.activeSelf then + self.GameObject:SetActive(false) + end +end + +--当有新的私聊进来的时候调用 +function XUiPanelPrivateChatView:NewChatMsgHandler(chatData) + if chatData == nil then + return + end + + if (chatData.ChannelType ~= ChatChannelType.Private and chatData.ChaneelType ~= ChatChannelType.PrivateInvite) then + return + end + + self:UpdateGroupDynamicList() + + if self.FriendId ~= chatData.TargetId and self.FriendId ~= chatData.SenderId then + return + end + + self:UpdatePrivateDynamicList() +end + +function XUiPanelPrivateChatView:OnClose() + self:StopPanelEmojiTimer() + XEventManager.RemoveEventListener(XEventId.EVENT_CHAT_RECEIVE_PRIVATECHAT, self.NewChatMsgHandler, self) + XEventManager.RemoveEventListener(XEventId.EVENT_BLACK_DATA_CHANGE, self.OnBtnBackClick, self) +end + +function XUiPanelPrivateChatView:StopPanelEmojiTimer() + if self.XUiPanelFriendEmoji then + self.XUiPanelFriendEmoji:EmojiUnScheduleTime() + end +end + +function XUiPanelPrivateChatView:BlackDataChange() + self:UpdateGroupDynamicList() + self:UpdatePrivateDynamicList() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSocial/WaitPassModel/XUiGridWaitPassItem.lua b/Resources/Scripts/XUi/XUiSocial/WaitPassModel/XUiGridWaitPassItem.lua new file mode 100644 index 00000000..46708c95 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSocial/WaitPassModel/XUiGridWaitPassItem.lua @@ -0,0 +1,133 @@ +local XUiGridWaitPassItem = XClass(nil, "XUiGridWaitPassItem") + +function XUiGridWaitPassItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:InitAutoScript() +end + +function XUiGridWaitPassItem:Init(mainPanel) + self.MainPanel = mainPanel +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiGridWaitPassItem:InitAutoScript() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiGridWaitPassItem:GetAutoKey(uiNode, eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiGridWaitPassItem:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiGridWaitPassItem:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiGridWaitPassItem:AutoAddListener() + self.AutoCreateListeners = {} + + XUiHelper.RegisterClickEvent(self, self.BtnView, self.OnBtnViewClick) + + self.BtnRefused.CallBack = function() self:OnBtnRefusedClick() end + self.BtnAgreed.CallBack = function() self:OnBtnAgreedClick() end +end +-- auto +function XUiGridWaitPassItem:OnBtnRefusedClick() + local callBack = function() + self.MainPanel:RefreshApplyList() + end + XDataCenter.SocialManager.AcceptApplyFriend(self.Id, false, callBack) +end + +function XUiGridWaitPassItem:OnBtnAgreedClick() + local callBack = function() + if self.Callback then + self.Callback() + end + self.MainPanel:RefreshApplyList() + end + XDataCenter.SocialManager.AcceptApplyFriend(self.Id, true, callBack) +end + +function XUiGridWaitPassItem:OnBtnViewClick()--个人信息 + XDataCenter.PersonalInfoManager.ReqShowInfoPanel(self.Id) +end + +function XUiGridWaitPassItem:Refresh(data, cb) + if data == nil then + return + end + + local medalConfig = XMedalConfigs.GetMeadalConfigById(data.CurrMedalId) + local medalIcon = nil + if medalConfig then + medalIcon = medalConfig.MedalIcon + end + if medalIcon ~= nil then + self.MedalRawImage:SetRawImage(medalIcon) + self.MedalRawImage.gameObject:SetActiveEx(true) + else + self.MedalRawImage.gameObject:SetActiveEx(false) + end + + self.Callback = cb + self.TxtName.text = data.NickName + self.Id = data.FriendId + if data.Sign == nil or (string.len(data.Sign) == 0) then + local text = CS.XTextManager.GetText("CharacterSignTip") + self.TxtSign.text = text + else + self.TxtSign.text = data.Sign + end + self.TxtTime.text = CS.XTextManager.GetText("FriendLatelyLogin") .. XUiHelper.CalcLatelyLoginTime(data.LastLoginTime) + + XUiPlayerLevel.UpdateLevel(data.Level, self.TxtLevel) + + if data.IsOnline then + self.TxtOnline.gameObject:SetActiveEx(true) + self.PanelRoleOffLine.gameObject:SetActiveEx(false) + self.PanelRoleOnLine.gameObject:SetActiveEx(true) + self.TxtTime.gameObject:SetActiveEx(false) + else + self.TxtOnline.gameObject:SetActiveEx(false) + self.PanelRoleOffLine.gameObject:SetActiveEx(true) + self.PanelRoleOnLine.gameObject:SetActiveEx(false) + self.TxtTime.gameObject:SetActiveEx(true) + end + + XUiPLayerHead.InitPortrait(data.Icon, data.HeadFrameId, self.PanelRoleOnLine) + XUiPLayerHead.InitPortrait(data.Icon, data.HeadFrameId, self.PanelRoleOffLine) + + self:Show() +end + +function XUiGridWaitPassItem:Show() + if self.GameObject:Exist() then + self.GameObject:SetActiveEx(true) + end +end + +return XUiGridWaitPassItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSocial/WaitPassModel/XUiPanelWaitForPassView.lua b/Resources/Scripts/XUi/XUiSocial/WaitPassModel/XUiPanelWaitForPassView.lua new file mode 100644 index 00000000..de63a42d --- /dev/null +++ b/Resources/Scripts/XUi/XUiSocial/WaitPassModel/XUiPanelWaitForPassView.lua @@ -0,0 +1,134 @@ +XUiPanelWaitForPassView = XClass(nil, "XUiPanelWaitForPassView") +local XUiGridWaitPassItem = require("XUi/XUiSocial/WaitPassModel/XUiGridWaitPassItem") + +function XUiPanelWaitForPassView:Ctor(ui, parent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Parent = parent + XTool.InitUiObject(self) + self:InitAutoScript() + + self.GameObject:SetActive(false) + self.GridWaitPassPlayer.gameObject:SetActive(false) + self.PassList = {} + self.Tips.gameObject:SetActive(false) + + + self.DynamicListManager = XDynamicTableNormal.New(self.GameObject) + self.DynamicListManager:SetProxy(XUiGridWaitPassItem) + self.DynamicListManager:SetDelegate(self) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelWaitForPassView:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiPanelWaitForPassView:AutoInitUi() + -- self.GridWaitPassPlayer = self.Transform:Find("Viewport/WaitPassList/GridWaitPassPlayer") + -- self.TxtChargeDay = self.Transform:Find("WaitPassPanelOther/TxtChargeDay"):GetComponent("Text") + -- self.TxtFriendCountA = self.Transform:Find("WaitPassPanelOther/TxtFriendCount"):GetComponent("Text") + -- self.BtnAdd = self.Transform:Find("Tips/BtnAdd"):GetComponent("Button") + -- self.Tips = self.Transform:Find("Tips") +end + +function XUiPanelWaitForPassView:GetAutoKey(uiNode, eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiPanelWaitForPassView:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiPanelWaitForPassView:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiPanelWaitForPassView:AutoAddListener() + self.AutoCreateListeners = {} + XUiHelper.RegisterClickEvent(self, self.BtnAdd, self.OnBtnAddClick) +end + + +-- auto +function XUiPanelWaitForPassView:OnBtnAddClick() + self.Parent:SetSelectedIndex(self.Parent.BtnTabIndex.MainAddContact) +end + + +function XUiPanelWaitForPassView:Show() + if not self.GameObject:Exist() then + return + end + + self.GameObject:SetActive(true) + self.Parent:PlayAnimation("WaitForPassViewQieHuan") + self:RefreshFriendCount() + self:RefreshApplyList() + + XEventManager.AddEventListener(XEventId.EVENT_BLACK_DATA_CHANGE, self.RefreshApplyList, self) +end + +function XUiPanelWaitForPassView:Hide() + if not self.GameObject:Exist() then + return + end + + self.GameObject:SetActive(false) + XEventManager.RemoveEventListener(XEventId.EVENT_BLACK_DATA_CHANGE, self.RefreshApplyList, self) +end + +--刷新好友数量 和收取数量 +function XUiPanelWaitForPassView:RefreshFriendCount() + local friendCountText = CS.XTextManager.GetText("FriendCount") + local dayChargeText = CS.XTextManager.GetText("FriendDayCharge") + local maxCount = XPlayerManager.GetMaxFriendCount(XPlayer.GetLevelOrHonorLevel(), XPlayer.IsHonorLevelOpen()) + self.TxtFriendCountA.text = string.format("%s %d / %d", friendCountText, XDataCenter.SocialManager.GetFriendCount(), maxCount) + self.TxtChargeDay.text = string.format("%s %d / %d", dayChargeText, 0, 0) +end + +function XUiPanelWaitForPassView:RefreshApplyList() + XDataCenter.SocialManager.GetApplyFriendsInfo(function() + self.ApplyList = XDataCenter.SocialManager.GetApplyFriendList() + if not self.ApplyList or #self.ApplyList <= 0 then + self.Tips.gameObject:SetActive(true) + else + self.Tips.gameObject:SetActive(false) + end + + self.DynamicListManager:SetDataSource(self.ApplyList) + self.DynamicListManager:ReloadDataASync() + end) +end + + +function XUiPanelWaitForPassView:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:Refresh(self.ApplyList[index], function() self:RefreshFriendCount() end) + end +end + +function XUiPanelWaitForPassView:OnClose() + XEventManager.RemoveEventListener(XEventId.EVENT_BLACK_DATA_CHANGE, self.RefreshApplyList, self) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSocial/XUiPanelDaily.lua b/Resources/Scripts/XUi/XUiSocial/XUiPanelDaily.lua new file mode 100644 index 00000000..c9cac984 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSocial/XUiPanelDaily.lua @@ -0,0 +1,92 @@ +XUiPanelDaily = XClass(nil, "XUiPanelDaily") + +function XUiPanelDaily:Ctor(ui,rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + self:InitAutoScript() + self.XUiPanelMsgBoard = XUiPanelMsgBoard.New(self.PanelMsgBoard,self.RootUi) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelDaily:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiPanelDaily:AutoInitUi() + -- self.BtnBack = self.Transform:Find("BtnBack"):GetComponent("Button") + -- self.PanelMsgBoard = self.Transform:Find("PanelMsgBoard") + -- self.PanelWrite = self.Transform:Find("PanelWrite") + -- self.BtnWriteMsg = self.Transform:Find("BtnWriteMsg"):GetComponent("Button") +end + +function XUiPanelDaily:GetAutoKey(uiNode,eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiPanelDaily:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiPanelDaily:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key],eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiPanelDaily:AutoAddListener() + self.AutoCreateListeners = {} + XUiHelper.RegisterClickEvent(self, self.BtnBack, self.OnBtnBackClick) + XUiHelper.RegisterClickEvent(self, self.BtnWriteMsg, self.OnBtnWriteMsgClick) +end +-- auto + +function XUiPanelDaily:OnBtnBackClick() + self:PlayAnimation("DailyOut", function () + self:SetIsShow(false) + end, function () + + end) +end + +function XUiPanelDaily:OnBtnWriteMsgClick() + XDataCenter.PersonalInfoManager.OpenInputView(function( content ) + XDataCenter.PersonalInfoManager.WriteDaily(content,function() + XDataCenter.PersonalInfoManager.RefreshDailyData(1, + function() + XDataCenter.PersonalInfoManager.PanelMsgBoard:Refresh() + end) + end)--写日记 + end) +end + +function XUiPanelDaily:SetIsShow( code ) + if code then + XDataCenter.PersonalInfoManager.GetDailys(XPlayer.Id,1,function() + self.XUiPanelMsgBoard:Refresh() + end) + end + self.GameObject.gameObject:SetActive(code) +end + +function XUiPanelDaily:OnClose() + -- body +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSocial/XUiSocial.lua b/Resources/Scripts/XUi/XUiSocial/XUiSocial.lua new file mode 100644 index 00000000..dea336ae --- /dev/null +++ b/Resources/Scripts/XUi/XUiSocial/XUiSocial.lua @@ -0,0 +1,239 @@ +local XUiPanelBlackView = require("XUi/XUiSocial/Black/XUiPanelBlackView") +local XUiPanelTips = require("XUi/XUiSocial/PanelTips/XUiPanelTips") + +local XUiSocial = XLuaUiManager.Register(XLuaUi, "UiSocial") + +XUiSocial.BtnTabIndex = { + MainContact = 1, + WaitPass = 2, + MainAddContact = 3, + Black = 4, +} + +function XUiSocial:OnAwake() + XTool.InitUiObject(self) + self:InitAutoScript() +end + +function XUiSocial:OnStart(onLoadCompleteCB, defaultIndex) + self.PrivateChatViewPanel = XUiPanelPrivateChatView.New(self, self.PanelPrivateChatView, handler(self, self.OnBtnBackClick)) + self.ContactViewPanel = XUiPanelContactView.New(self.PanelContactView, self) + self.WaitForPassViewPanel = XUiPanelWaitForPassView.New(self.PanelWaitForPassView, self) + self.AddContactViewPanel = XUiPanelAddContactView.New(self.PanelAddContactView, self) + self.BlackViewPanel = XUiPanelBlackView.New(self.PanelBlacklistView, self, handler(self, self.InsertPanelTipsDesc)) + self.XUiPanelDaily = XUiPanelDaily.New(self.PanelDaily, self) + self.XUiPanelDaily:SetIsShow(false) + self.XUiPanelTips = XUiPanelTips.New(self.PanelTips, self) + self.XUiPanelTips:Hide() + + self.OnLoadCompleteCB = onLoadCompleteCB + + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + + self:InitSubPanel() + + local tabGroup = { + self.BtnMainContact, + self.BtnMainWaitPass, + self.BtnMainAddContact, + self.BtnMainBlacklist, + } + self.PanelButtons:Init(tabGroup, function(tabIndex) self:OnClickTabCallBack(tabIndex) end) + + XRedPointManager.AddRedPointEvent(self.BtnMainContact, self.RefreshContactRedDot, self, { XRedPointConditions.Types.CONDITION_FRIEND_CONTACT }) + XRedPointManager.AddRedPointEvent(self.BtnMainWaitPass, self.RefreshWaitPassRedDot, self, { XRedPointConditions.Types.CONDITION_FRIEND_WAITPASS }) + + local selectIndex = defaultIndex or self.BtnTabIndex.MainContact + self.PanelButtons:SelectIndex(selectIndex) +end + +function XUiSocial:SetSelectedIndex(index) + self.PanelButtons:SelectIndex(index) +end + +function XUiSocial:OnEnable() + XEventManager.AddEventListener(XEventId.EVENT_FRIEND_OPEN_PRIVATE_VIEW, self.OpenPrivateChatView, self) + if self.OnLoadCompleteCB then + self.OnLoadCompleteCB() + self.OnLoadCompleteCB = nil + end + + CS.XScheduleManager.ScheduleOnce(function() + self.PrivateChatViewPanel:OnEnable() + end, 1) +end + +function XUiSocial:OnDestroy() + self.PrivateChatViewPanel:OnClose() + self.ContactViewPanel:OnClose() + self.WaitForPassViewPanel:OnClose() + self.AddContactViewPanel:OnClose() + self.XUiPanelDaily:OnClose() + self.BlackViewPanel:OnClose() + self.XUiPanelTips:Hide() + XDataCenter.PersonalInfoManager.OnDispose() + XEventManager.RemoveEventListener(XEventId.EVENT_FRIEND_OPEN_PRIVATE_VIEW, self.OpenPrivateChatView, self) +end + +function XUiSocial:OnOpenSubPanel(panel) + for index = 1, #self.PanelViews do + self.PanelViews[index]:Hide() + end + panel:Show() +end + +--更新社交界面的 联系人红点 +function XUiSocial:RefreshContactRedDot(count) + self.BtnMainContact:ShowReddot(count >= 0) +end + +--更新等待通过界面的 红点 +function XUiSocial:RefreshWaitPassRedDot(count) + self.BtnMainWaitPass:ShowReddot(count >= 0) +end + +function XUiSocial:OnClickTabCallBack(tabIndex) + if self.SelectedIndex and self.SelectedIndex == tabIndex then + return + end + self.SelectedIndex = tabIndex + + if tabIndex == self.BtnTabIndex.MainContact then + --点击联系人 + self:OnOpenSubPanel(self.ContactViewPanel) + elseif tabIndex == self.BtnTabIndex.WaitPass then + --等待通过 + self:OnOpenSubPanel(self.WaitForPassViewPanel) + XDataCenter.SocialManager.ResetWaitPassLocalMap() + XDataCenter.SocialManager.ResetApplyCount() + elseif tabIndex == self.BtnTabIndex.MainAddContact then + --增加联系人 + self:OnOpenSubPanel(self.AddContactViewPanel) + elseif tabIndex == self.BtnTabIndex.Black then + --黑名单 + self:OnOpenSubPanel(self.BlackViewPanel) + end + + self.XUiPanelTips:Hide() + if self.BtnHelp then + self.BtnHelp.gameObject:SetActiveEx(tabIndex == self.BtnTabIndex.Black) + end +end + +function XUiSocial:InitSubPanel() + self.PanelViews = {} + table.insert(self.PanelViews, self.ContactViewPanel) + table.insert(self.PanelViews, self.WaitForPassViewPanel) + table.insert(self.PanelViews, self.AddContactViewPanel) + table.insert(self.PanelViews, self.BlackViewPanel) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiSocial:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiSocial:AutoInitUi() + -- self.PanelAddContactView = self.Transform:Find("SafeAreaContentPane/PanelAddContactView") + -- self.PanelContactView = self.Transform:Find("SafeAreaContentPane/PanelContactView") + -- self.BtnBack = self.Transform:Find("SafeAreaContentPane/PanelCharTopButton/BtnBack"):GetComponent("Button") + -- self.PanelWaitForPassView = self.Transform:Find("SafeAreaContentPane/PanelWaitForPassView") + -- self.PanelBg3d = self.Transform:Find("FullScreenBackground/PanelBg3d") + -- self.BtnMainUi = self.Transform:Find("SafeAreaContentPane/PanelCharTopButton/BtnMainUi"):GetComponent("Button") + -- self.PanelAsset = self.Transform:Find("SafeAreaContentPane/PanelAsset") + -- self.PanelAllChatView = self.Transform:Find("SafeAreaContentPane/PanelAllChatView") + -- self.PanelPrivateChatView = self.Transform:Find("SafeAreaContentPane/PanelPrivateChatView") + -- self.PanelEmoji = self.Transform:Find("SafeAreaContentPane/PanelEmoji") + -- self.GridEmoji = self.Transform:Find("SafeAreaContentPane/PanelEmoji/EmojiList/GridEmoji") + -- self.PanelDaily = self.Transform:Find("SafeAreaContentPane/PanelDaily") + -- self.BtnDaily = self.Transform:Find("SafeAreaContentPane/PanelButtons/BtnDaily"):GetComponent("Button") + -- self.PanelButtons = self.Transform:Find("SafeAreaContentPane/PanelButtons"):GetComponent("XUiButtonGroup") +end + +function XUiSocial:GetAutoKey(uiNode, eventName) + if not uiNode then + return + end + return eventName .. uiNode:GetHashCode() +end + +function XUiSocial:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then + return + end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiSocial:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiSocial:AutoAddListener() + self.AutoCreateListeners = {} + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:RegisterClickEvent(self.BtnDaily, self.OnBtnBtnDailyClick) + if self.BtnHelp then + self:RegisterClickEvent(self.BtnHelp, self.OnBtnHelpClick) + end +end +-- auto + +function XUiSocial:OnBtnHelpClick() + XUiManager.ShowHelpTip("SocialBlack") +end + +function XUiSocial:OnBtnBackClick() + if self.PrivatePanelIsOpen then + if self.PrivateChatViewPanel ~= nil then + self.PrivateChatViewPanel:Hide() + self.PanelButtons.gameObject:SetActive(true) + self.ContactViewPanel:Show() + self.PrivatePanelIsOpen = false + end + else + self:Close() + end +end + +function XUiSocial:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiSocial:OnBtnBtnDailyClick() + self:PlayAnimation("DailyIn", function() + + end, function() + self.XUiPanelDaily:SetIsShow(true) + end) +end + +function XUiSocial:OpenPrivateChatView(friendId) + if self.PrivateChatViewPanel ~= nil then + self.PanelButtons.gameObject:SetActive(false) + self.ContactViewPanel:Hide() + self.PrivateChatViewPanel:Refresh(friendId) + end + self.PrivatePanelIsOpen = true +end + +function XUiSocial:InsertPanelTipsDesc(desc) + self.XUiPanelTips:InsertDesc(desc) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSocial/XUiSocialRename.lua b/Resources/Scripts/XUi/XUiSocial/XUiSocialRename.lua new file mode 100644 index 00000000..cfdefcc0 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSocial/XUiSocialRename.lua @@ -0,0 +1,50 @@ +local XUiSocialRename = XLuaUiManager.Register(XLuaUi, "UiSocialRename") + + +function XUiSocialRename:OnAwake() + self.BtnClose.CallBack = function() self:OnDialogClose() end + self.BtnTanchuangClose.CallBack = function() self:OnDialogClose() end + self.BtnNameSure.CallBack = function() self:OnBtnNameSureClick() end + self.BtnNameCancel.CallBack = function() self:OnDialogClose() end +end + +function XUiSocialRename:OnStart(friendId, defaultName, callBack) + self.FriendId = friendId + self.DefaultName = defaultName + self.CallBack = callBack + self.InFSigm.placeholder.text = XDataCenter.SocialManager.GetFriendRemark(self.FriendId) +end + +function XUiSocialRename:OnBtnNameSureClick() + if self.FriendId then + local editName = self.TxtName.text + -- if editName == "" then + -- XUiManager.TipError(CS.XTextManager.GetText("XSocialNameEmpty")) + -- return + -- end + local MaxNameLength = CS.XGame.ClientConfig:GetInt("MaxNameLength") + local utf8Count = self.InFSigm.textComponent.cachedTextGenerator.characterCount - 1 + if utf8Count > MaxNameLength then + XUiManager.TipError(CS.XTextManager.GetText("MaxNameLengthTips", MaxNameLength)) + return + end + + -- 两次空处理 + local friendRemark = XDataCenter.SocialManager.GetFriendRemark(self.FriendId) + if (friendRemark == nil or friendRemark == "") and (editName == nil or editName == "") then + self:OnDialogClose() + return + end + + XDataCenter.SocialManager.RemarkFriendName(self.FriendId, editName, function() + if self.CallBack then + self.CallBack() + end + self:OnDialogClose() + end) + end +end + +function XUiSocialRename:OnDialogClose() + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSpecialFashionShop/XUiCommodity.lua b/Resources/Scripts/XUi/XUiSpecialFashionShop/XUiCommodity.lua new file mode 100644 index 00000000..c672d7ff --- /dev/null +++ b/Resources/Scripts/XUi/XUiSpecialFashionShop/XUiCommodity.lua @@ -0,0 +1,370 @@ +local XUiCommodity = XClass(nil,"XUiCommodity") + +local BuyCount = 1 + +function XUiCommodity:Ctor(ui, parent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Parent = parent + + XTool.InitUiObject(self) + self:InitComponent() + self:AddListener() +end + +function XUiCommodity:Refresh(data) + if not data then + self.GameObject:SetActiveEx(false) + else + self.Data = data + self:RefreshSellOut() + self:RefreshCondition() + self:RefreshIcon() + self:RefreshOnSales() + self:RefreshPrice() + self:RefreshBuyCount() + self:RefreshGift() + + self:RefreshTimer(self.Data.Id, self.Data.SelloutTime) + + self.GameObject:SetActiveEx(true) + end +end + +function XUiCommodity:InitComponent() + self.PanelPrice = { + self.PanelPrice1 + } + self.TxtOldPrice = { + self.TxtOldPrice1 + } + self.TxtNewPrice = { + self.TxtNewPrice1 + } + self.RImgPrice = { + self.RImgPrice1 + } +end + +function XUiCommodity:RefreshCondition() + if not self.BtnCondition then return end + self.BtnCondition.gameObject:SetActiveEx(false) + self.ConditionDesc = nil + local conditionIds = self.Data.ConditionIds + if not conditionIds or #conditionIds <= 0 then return end + + for _, id in pairs(conditionIds) do + local ret, desc = XConditionManager.CheckCondition(id) + if not ret then + self.BtnCondition.gameObject:SetActiveEx(true) + self.ImgSellOut.gameObject:SetActiveEx(false) + self.ConditionDesc = desc + self.ConditionText.text = desc + return + end + end +end + +function XUiCommodity:RefreshSellOut() + if not self.ImgSellOut then + return + end + self.IsSellOut = false + if self.Data.BuyTimesLimit <= 0 then + self.ImgSellOut.gameObject:SetActiveEx(false) + else + if self.Data.TotalBuyTimes >= self.Data.BuyTimesLimit then + self.ImgSellOut.gameObject:SetActiveEx(true) + self.IsSellOut = true + else + self.ImgSellOut.gameObject:SetActiveEx(false) + end + end +end + +function XUiCommodity:RefreshIcon() + if type(self.Data.RewardGoods) == "number" then + self.TemplateId = self.Data.RewardGoods + else + self.TemplateId = (self.Data.RewardGoods.TemplateId and self.Data.RewardGoods.TemplateId > 0) and + self.Data.RewardGoods.TemplateId or + self.Data.RewardGoods.Id + end + + self.IsWeaponFashion = XDataCenter.ItemManager.IsWeaponFashion(self.TemplateId) + self.Id = self.IsWeaponFashion and XDataCenter.ItemManager.GetWeaponFashionId(self.TemplateId) or self.TemplateId + + self.GoodsShowParams = XGoodsCommonManager.GetGoodsShowParamsByTemplateId(self.Id) + if self.GoodsShowParams.Name then + if self.GoodsShowParams.RewardType == XArrangeConfigs.Types.Character then + self.TxtName.text = self.GoodsShowParams.TradeName + else + self.TxtName.text = self.GoodsShowParams.Name + end + end + + local characterIcon = self.IsWeaponFashion and self.GoodsShowParams.ShopIcon or self.GoodsShowParams.CharacterIcon + if characterIcon then + self.RImgIcon:SetRawImage(characterIcon) + end +end + +function XUiCommodity:RefreshOnSales() + self.OnSales = {} + self.OnSalesLongTest = {} + XTool.LoopMap(self.Data.OnSales, function(k, sales) + self.OnSales[k] = sales + table.insert(self.OnSalesLongTest, sales) + end) + + self.Sales = 100 + + if #self.OnSalesLongTest ~= 0 then + local sortedKeys = {} + for k, _ in pairs(self.OnSales) do + table.insert(sortedKeys, k) + end + table.sort(sortedKeys) + + for i = 1, #sortedKeys do + if self.Data.TotalBuyTimes >= sortedKeys[i] - 1 then + self.Sales = self.OnSales[sortedKeys[i]] + end + end + end + self:RefreshPanelSale() +end + +function XUiCommodity:RefreshPanelSale() + local hideSales = false + if self.TxtSaleRate then + if self.Data.Tags == XShopManager.ShopTags.DisCount then + if self.Sales < 100 then + self.TxtSaleRate.text = self.Sales / 10 .. CS.XTextManager.GetText("Snap") + else + hideSales = true + end + end + if self.Data.Tags == XShopManager.ShopTags.TimeLimit then + self.TxtSaleRate.text = CS.XTextManager.GetText("TimeLimit") + end + if self.Data.Tags == XShopManager.ShopTags.Recommend then + self.TxtSaleRate.text = CS.XTextManager.GetText("Recommend") + end + if self.Data.Tags == XShopManager.ShopTags.HotSale then + self.TxtSaleRate.text = CS.XTextManager.GetText("HotSell") + end + + if self.Data.Tags == XShopManager.ShopTags.Not or hideSales then + self.TxtSaleRate.gameObject:SetActiveEx(false) + self.TxtSaleRate.gameObject.transform.parent.gameObject:SetActiveEx(false) + else + self.TxtSaleRate.gameObject:SetActiveEx(true) + self.TxtSaleRate.gameObject.transform.parent.gameObject:SetActiveEx(true) + end + end +end + +function XUiCommodity:RefreshPrice() + local panelCount = #self.PanelPrice + for i = 1, panelCount do + self.PanelPrice[i].gameObject:SetActiveEx(false) + end + + local index = 1 + for _, count in pairs(self.Data.ConsumeList) do + if index > panelCount then + return + end + + local txtOldPrice = self.TxtOldPrice[index] + if txtOldPrice then + if self.Sales == 100 then + txtOldPrice.gameObject:SetActiveEx(false) + else + txtOldPrice.text = count.Count + txtOldPrice.gameObject:SetActiveEx(true) + end + end + + local rImgPrice = self.RImgPrice[index] + if rImgPrice then + self.ItemIcon = XDataCenter.ItemManager.GetItemIcon(count.Id) + if self.ItemIcon ~= nil then + rImgPrice:SetRawImage(self.ItemIcon) + end + end + + local txtNewPrice = self.TxtNewPrice[index] + if txtNewPrice then + self.NeedCount = math.floor(count.Count * self.Sales / 100) + txtNewPrice.text = self.NeedCount + local itemCount = XDataCenter.ItemManager.GetCount(count.Id) + if itemCount < self.NeedCount then + txtNewPrice.color = CS.UnityEngine.Color(1, 0, 0) + else + txtNewPrice.color = CS.UnityEngine.Color(0, 0, 0) + end + end + + self.PanelPrice[index].gameObject:SetActiveEx(true) + index = index + 1 + end +end + +function XUiCommodity:RefreshBuyCount() + if not self.ImgLimitLable then + return + end + + if not self.TxtLimitLable then + return + end + + if self.Data.BuyTimesLimit <= 0 then + self.TxtLimitLable.gameObject:SetActiveEx(false) + self.ImgLimitLable.gameObject:SetActiveEx(false) + else + local buynumber = self.Data.BuyTimesLimit - self.Data.TotalBuyTimes + local limitLabel = XShopConfigs.GetBuyLimitLabel(self.Data.AutoResetClockId) + local text = string.format(limitLabel, buynumber) + + self.TxtLimitLable.text = text + self.TxtLimitLable.gameObject:SetActiveEx(true) + self.ImgLimitLable.gameObject:SetActiveEx(true) + end +end + +function XUiCommodity:RefreshGift() + if self.Data.GiftRewardId and self.Data.GiftRewardId ~= 0 then + self.ImgTabLb.gameObject:SetActiveEx(true) + self.GiftRewardId = self.Data.GiftRewardId + else + self.GiftRewardId = 0 + self.ImgTabLb.gameObject:SetActiveEx(false) + end +end + +function XUiCommodity:OnRecycle() + if self.Data then + self:RemoveTimer(self.Data.Id) + end +end + +---------------------------------------------------计时器--------------------------------------------------------- + +function XUiCommodity:RemoveTimer(funId) + self.Parent:RemoveTimerFun(funId) +end + +function XUiCommodity:RefreshTimer(funId, time) + if not self.ImgLeftTime then + return + end + + if not self.TxtLeftTime then + return + end + + if time <= 0 then + self.TxtLeftTime.gameObject:SetActiveEx(false) + self.ImgLeftTime.gameObject:SetActiveEx(false) + return + end + + self.TxtLeftTime.gameObject:SetActiveEx(true) + --self.ImgLeftTime.gameObject:SetActiveEx(true)暂时关闭 + self.ImgLeftTime.gameObject:SetActiveEx(false) + + local leftTime = XShopManager.GetLeftTime(time) + + local func = function() + leftTime = leftTime > 0 and leftTime or 0 + local dataTime = XUiHelper.GetTime(leftTime, XUiHelper.TimeFormatType.SHOP) + if self.TxtLeftTime then + self.TxtLeftTime.text = CS.XTextManager.GetText("TimeSoldOut", dataTime) + end + if leftTime <= 0 then + self:RemoveTimer(funId) + if self.ImgSellOut then + self.ImgSellOut.gameObject:SetActiveEx(true) + self.IsSellOut = true + end + end + end + + func() + self.Parent:RegisterTimerFun(funId, function() + leftTime = leftTime - 1 + func() + end) +end + +---------------------------------------------------添加监听函数--------------------------------------------------------- + +function XUiCommodity:AddListener() + self.BtnCondition.CallBack = function() + self:OnBtnConditionClick() + end + self.BtnBuy.CallBack = function() + self:OnBtnBuyClick() + end +end + +function XUiCommodity:OnBtnConditionClick() + if self.ConditionDesc then + XUiManager.TipError(self.ConditionDesc) + end +end + +function XUiCommodity:OnBtnBuyClick() + if self.IsSellOut then + XUiManager.TipText("ShopItemSellOut") + return + end + if self.IsShopOnSaleLock then + XUiManager.TipError(self.ShopOnSaleLockDecs) + return + end + local buyData = {} + buyData.IsHave = false + buyData.ItemIcon = self.ItemIcon + buyData.ItemCount = self.NeedCount + + buyData.GiftRewardId = self.GiftRewardId + buyData.BuyCallBack = function() + for _, consume in pairs(self.Data.ConsumeList) do + if consume.Id == XDataCenter.ItemManager.ItemId.HongKa then + local result = XDataCenter.ItemManager.CheckItemCountById(consume.Id, self.NeedCount) + if not result then + XUiManager.TipText("ShopItemHongKaNotEnough") + XLuaUiManager.Open("UiPurchase", XPurchaseConfigs.TabsConfig.Pay) + return + end + elseif consume.Id == XDataCenter.ItemManager.ItemId.PaidGem then + local result = XDataCenter.ItemManager.CheckItemCountById(consume.Id, self.NeedCount) + if not result then + XUiManager.TipText("ShopItemPaidGemNotEnough") + XLuaUiManager.Open("UiPurchase", XPurchaseConfigs.TabsConfig.HK) + return + end + end + end + + XShopManager.BuyShop(self.Parent:GetCurShopId(), self.Data.Id, BuyCount, function () + local text = CS.XTextManager.GetText("BuySuccess") + XUiManager.TipMsg(text, nil, function() + if buyData.GiftRewardId and buyData.GiftRewardId ~= 0 then + local rewardGoodList = XRewardManager.GetRewardList(buyData.GiftRewardId) + XUiManager.OpenUiObtain(rewardGoodList) + end + end) + + self.Parent:RefreshBuy() + end) + end + + XLuaUiManager.Open("UiFashionDetail", self.Id, self.IsWeaponFashion, buyData) +end + +return XUiCommodity \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSpecialFashionShop/XUiGridCommodityLine.lua b/Resources/Scripts/XUi/XUiSpecialFashionShop/XUiGridCommodityLine.lua new file mode 100644 index 00000000..0464d309 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSpecialFashionShop/XUiGridCommodityLine.lua @@ -0,0 +1,75 @@ +local XUiGridCommodityLine = XClass(nil,"XUiGridCommodityLine") + +local XUiCommodity = require("XUi/XUiSpecialFashionShop/XUiCommodity") + +function XUiGridCommodityLine:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + + self.CommodityList = {} + + XTool.InitUiObject(self) + self:InitComponent() +end + +function XUiGridCommodityLine:Init(parent) + self.Parent = parent +end + +function XUiGridCommodityLine:Refresh(commodityData) + if #commodityData > XSpecialShopConfigs.MAX_COUNT then + XLog.Error("XUiGridCommodityLine:Refresh函数错误,commodityData长度大于XSpecialShopConfigs.MAX_COUNT") + return + end + + self.CommodityData = commodityData + + if commodityData.First then + self.PanelSeriesSymbol.gameObject:SetActiveEx(true) + self.TxtSeries.text = XFashionConfigs.GetSeriesName(commodityData.SeriesId) + else + self.PanelSeriesSymbol.gameObject:SetActiveEx(false) + end + + self.SymbolLayoutNode:SetDirty() + self.LineLayoutNode:SetDirty() + + for i, commodity in pairs(self.CommodityList) do + commodity:Refresh(commodityData[i]) + end +end + +function XUiGridCommodityLine:OnRecycle() + for _, commodity in pairs(self.CommodityList) do + commodity:OnRecycle() + end +end + +function XUiGridCommodityLine:InitComponent() + for i = 1, XSpecialShopConfigs.MAX_COUNT do + local commodity = string.format("Commodity%s", tostring(i)) + self[commodity].gameObject:SetActiveEx(false) + + local commodityInst = XUiCommodity.New(self[commodity], self) + self.CommodityList[i] = commodityInst + end +end + +function XUiGridCommodityLine:GetCurShopId() + return self.Parent:GetCurShopId() +end + +function XUiGridCommodityLine:RefreshBuy() + self.Parent:RefreshBuy() +end + +function XUiGridCommodityLine:RegisterTimerFun(id, fun) + self.Parent:RegisterTimerFun(id, fun) +end + +function XUiGridCommodityLine:RemoveTimerFun(id) + self.Parent:RemoveTimerFun(id) +end + +return XUiGridCommodityLine \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSpecialFashionShop/XUiSpecialFashionShop.lua b/Resources/Scripts/XUi/XUiSpecialFashionShop/XUiSpecialFashionShop.lua new file mode 100644 index 00000000..0ca7dfd3 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSpecialFashionShop/XUiSpecialFashionShop.lua @@ -0,0 +1,178 @@ +local XUiSpecialFashionShop = XLuaUiManager.Register(XLuaUi, "UiSpecialFashionShop") + +local XUiCommodityLine = require("XUi/XUiSpecialFashionShop/XUiGridCommodityLine") +local Dropdown = CS.UnityEngine.UI.Dropdown +local CurrentSchedule + +function XUiSpecialFashionShop:OnAwake() + self.TimerFunctions = {} + + self:InitComponent() + self:AddListener() +end + +function XUiSpecialFashionShop:OnStart(shopId) + self.ShopId = shopId + self.ScreenGroupIDList = {} + + -- 初始化筛选标签 + self:InitScreen(self.ShopId) + self:InitDropFilter() +end + +function XUiSpecialFashionShop:OnEnable() + self:Refresh() +end + +function XUiSpecialFashionShop:OnDestroy() + self:DestroyTimer() +end + +function XUiSpecialFashionShop:Refresh() + -- 货币 + self.AssetActivityPanel:Refresh(XShopManager.GetShopShowIdList(self.ShopId)) + + -- 活动时间 + local startTimeStr, endTimeStr = XSpecialShopConfigs.GetDurationTimeStr() + self.TxtTime.text = CsXTextManagerGetText("SpecialFashionShopDurationTime", startTimeStr, endTimeStr) + + -- 商品数据,筛选标签为全部则需要区分系列 + local isSeries = self.DropFilter.value == 0 + self.CommodityLineData = XDataCenter.SpecialShopManager.GetCommodityLineData(self.ShopId, self.ScreenGroupIDList[self.ScreenNum], self.SelectTag, isSeries) + self.DynamicTable:SetDataSource(self.CommodityLineData) + self.DynamicTable:ReloadDataASync() + + if next(self.CommodityLineData) then + self.TxtEmptyDesc.gameObject:SetActiveEx(false) + else + self.TxtEmptyDesc.gameObject:SetActiveEx(true) + self.TxtHint.text = CS.XTextManager.GetText("ShopNoGoodsDesc") + end + + self.DynamicTable.Imp.IsLocked = true --动态表锁定(控制滑动,大小适配等)(不需要滑动时的逻辑) +end + +function XUiSpecialFashionShop:InitComponent() + self.GridCommodityLine.gameObject:SetActiveEx(false) + self.TxtEmptyDesc.gameObject:SetActiveEx(false) + self.BtnSearch.gameObject:SetActiveEx(false) + + self:StartTimer() + self.AssetActivityPanel = XUiPanelActivityAsset.New(self.PanelSpecialTool) + + self.DynamicTable = XDynamicTableIrregular.New(self.PanelFashionList) + self.DynamicTable:SetProxy("XUiCommodityLine", XUiCommodityLine, self.GridCommodityLine.gameObject) + self.DynamicTable:SetDelegate(self) + +end + +function XUiSpecialFashionShop:StartTimer() + if self.IsStart then + return + end + + self.IsStart = true + CurrentSchedule = XScheduleManager.ScheduleForever(function() + self:UpdateTimer() + end, 1000) +end + +function XUiSpecialFashionShop:UpdateTimer() + if next(self.TimerFunctions) then + for _, timerFun in pairs(self.TimerFunctions) do + if timerFun then + timerFun() + end + end + end +end + +function XUiSpecialFashionShop:RegisterTimerFun(id, fun) + self.TimerFunctions[id] = fun +end + +function XUiSpecialFashionShop:RemoveTimerFun(id) + self.TimerFunctions[id] = nil +end + +function XUiSpecialFashionShop:DestroyTimer() + if CurrentSchedule then + self.IsStart = false + XScheduleManager.UnSchedule(CurrentSchedule) + CurrentSchedule = nil + end +end + +function XUiSpecialFashionShop:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.CommodityLineData[index] + grid:Refresh(data) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_RECYCLE then + grid:OnRecycle() + end +end + +function XUiSpecialFashionShop:GetProxyType() + return "XUiCommodityLine" +end + +function XUiSpecialFashionShop:GetCurShopId() + return self.ShopId +end + +function XUiSpecialFashionShop:RefreshBuy() + self:Refresh() +end + +function XUiSpecialFashionShop:InitScreen(shopId) + self.ScreenGroupIDList = XShopManager.GetShopScreenGroupIDList(shopId) + if self.ScreenGroupIDList and #self.ScreenGroupIDList > 0 then + self.IsHasScreen = true + self.ScreenNum = 1 + else + self.IsHasScreen = false + end + + self.DropFilter.gameObject:SetActiveEx(self.IsHasScreen) +end + +function XUiSpecialFashionShop:InitDropFilter() + self.ScreenTagList = XShopManager.GetScreenTagListById(self.ShopId,self.ScreenGroupIDList[self.ScreenNum]) + + self.DropFilter:ClearOptions() + self.DropFilter.captionText.text = CS.XTextManager.GetText("ScreenAll") + + for _,v in pairs(self.ScreenTagList or {}) do + local op = Dropdown.OptionData() + op.text = v.Text + self.DropFilter.options:Add(op) + end + self.DropFilter.value = 0 + self.SelectTag = self.DropFilter.captionText.text +end + + +---------------------------------------------------添加监听函数--------------------------------------------------------- + +function XUiSpecialFashionShop:AddListener() + self.BtnBack.CallBack = function() + self:OnBtnBackClick() + end + self.BtnMainUi.CallBack = function() + self:OnBtnMainUiClick() + end + self.DropFilter.onValueChanged:AddListener(function() + self.SelectTag = self.DropFilter.captionText.text + self:Refresh() + end) +end + +function XUiSpecialFashionShop:OnBtnBackClick() + self:Close() +end + +function XUiSpecialFashionShop:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSpringFestival/CollectCard/XUiGridSpringFestivalBagItem.lua b/Resources/Scripts/XUi/XUiSpringFestival/CollectCard/XUiGridSpringFestivalBagItem.lua new file mode 100644 index 00000000..b7c195d1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSpringFestival/CollectCard/XUiGridSpringFestivalBagItem.lua @@ -0,0 +1,53 @@ +local XUiGridSpringFestivalBagItem = XClass(nil, "XUiGridSpringFestivalBagItem") + +function XUiGridSpringFestivalBagItem:Ctor(ui,parent) + self.GameObject = ui + self.Transform = ui.transform + self.Parent = parent + XTool.InitUiObject(self) +end + +function XUiGridSpringFestivalBagItem:RegisterButtonEvent() + self.BtnReceive.CallBack = function() + self:OnClickReceive() + end +end + +function XUiGridSpringFestivalBagItem:Refresh(index) + self.DataInfo = XDataCenter.SpringFestivalActivityManager.GetGiftBoxDataByIndex(index) + self:RefreshPlayerInfo() +end + +function XUiGridSpringFestivalBagItem:RefreshPlayerInfo() + self.TxtLevel.text = self.DataInfo:GetFriendLevel() + self.TxtName.text = self.DataInfo:GetSenderName() + self.TxtRemark.text = self.DataInfo:GetFriendRemark() + self.TxtTime.text = CS.XTextManager.GetText("FriendLatelyLogin") .. XUiHelper.CalcLatelyLoginTime(self.DataInfo:GetFriendLastLoginTime()) + local isOnline = self.DataInfo:IsFriendOnline() + if isOnline then + self.PanelRoleOffLine.gameObject:SetActive(false) + self.PanelRoleOnLine.gameObject:SetActive(true) + self.TxtTime.gameObject:SetActive(false) + self.TxtOnline.gameObject:SetActive(false) + else + self.PanelRoleOffLine.gameObject:SetActive(true) + self.PanelRoleOnLine.gameObject:SetActive(false) + self.TxtTime.gameObject:SetActive(true) + self.TxtOnline.gameObject:SetActive(false) + end + self.GiftGrid = XUiGridCommon.New(self.Parent,self.GridCommon) + local itemData = XDataCenter.ItemManager.GetItemTemplate(self.DataInfo:GetWordId()) + if itemData then + self.GiftGrid:Refresh(itemData) + end + + if self.TxtNewMessage then + local message = CS.XTextManager.GetText("SpringFestivalSendWordMessage",XDataCenter.ItemManager.GetItemName(self.DataInfo:GetWordId())) + self.TxtNewMessage.text = message + end + self.GridReceived.gameObject:SetActiveEx(self.DataInfo:IsReceive()) + XUiPLayerHead.InitPortrait(self.DataInfo:GetFriendIcon(), self.DataInfo:GetFriendHeadFrameId(), self.PanelRoleOnLine) + XUiPLayerHead.InitPortrait(self.DataInfo:GetFriendIcon(), self.DataInfo:GetFriendHeadFrameId(), self.PanelRoleOffLine) +end + +return XUiGridSpringFestivalBagItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSpringFestival/CollectCard/XUiGridSpringFestivalCollectCard.lua b/Resources/Scripts/XUi/XUiSpringFestival/CollectCard/XUiGridSpringFestivalCollectCard.lua new file mode 100644 index 00000000..f780293b --- /dev/null +++ b/Resources/Scripts/XUi/XUiSpringFestival/CollectCard/XUiGridSpringFestivalCollectCard.lua @@ -0,0 +1,197 @@ +local XUiGridSpringFestivalCollectCard = XClass(nil, "XUiGridSpringFestivalCollectCard") +local CSXTextManagerGetText = CS.XTextManager.GetText +function XUiGridSpringFestivalCollectCard:Ctor(ui, type) + self.GameObject = ui + self.Transform = ui.transform + self.Type = type + self.WordsList = XSpringFestivalActivityConfigs.GetWordsItemListByType(self.Type) or {} + XTool.InitUiObject(self) + self:RegisterButtonEvent() + self:RegisterCountChangeEvent() + self:Refresh() + XRedPointManager.AddRedPointEvent(self.BtnReceive, self.CheckReddot, self, { XRedPointConditions.Types.CONDITION_SPRINGFESTIVAL_GET_REWARD_RED }, self.Type) +end + +function XUiGridSpringFestivalCollectCard:CheckReddot(count) + self.BtnReceive:ShowReddot(count >= 0) +end + +function XUiGridSpringFestivalCollectCard:RegisterButtonEvent() + self.BtnReceive.CallBack = function() + self:OnClickGetRewardBtn() + end + if self.Btn then + self.Btn.CallBack = function() + self:OnClickRewardIconBtn() + end + end + if self.Type ~= XSpringFestivalActivityConfigs.CollectWordsRewardType.Final then + for i = 1, #self.WordsList do + local index = i + self["BtnText" .. i].CallBack = function() + self:OnClickBtnWord(index) + end + end + end +end + +function XUiGridSpringFestivalCollectCard:RegisterCountChangeEvent() + if self.Type ~= XSpringFestivalActivityConfigs.CollectWordsRewardType.Final then + for i = 1, #self.WordsList do + local index = i + local func = function() + local count = XDataCenter.ItemManager.GetCount(self.WordsList[index].Id) + self["WordText" .. index].text = count + self:RefreshReceiveText() + self["BtnText"..index]:SetDisable(count == 0, true) + end + self["BtnText" .. i]:SetRawImage(XDataCenter.ItemManager.GetItemIcon(self.WordsList[index].Id)) + XDataCenter.ItemManager.AddCountUpdateListener(self.WordsList[i].Id, func, self["WordText" .. i]) + func() + end + end +end + +function XUiGridSpringFestivalCollectCard:OnClickGetRewardBtn() + local canGetReward, needUniversalCount = XDataCenter.SpringFestivalActivityManager.CheckCanGetCollectWordsReward(self.Type) + if not canGetReward then + if self.Type ~= XSpringFestivalActivityConfigs.CollectWordsRewardType.Final then + XUiManager.TipText("SpringFestivalItemNotEnough") + else + XUiManager.TipText("SpringFestivalCanNotGetFinalReward") + end + return + end + if needUniversalCount and needUniversalCount > 0 then + XUiManager.DialogTip(CS.XTextManager.GetText("TipTitle"), CS.XTextManager.GetText("SpringFestivalUniversalTips", needUniversalCount), XUiManager.DialogType.Normal, nil, function() + self:SendGetRewardRequest() + end) + else + self:SendGetRewardRequest() + end + +end + +function XUiGridSpringFestivalCollectCard:OnClickRewardIconBtn() + local itemData = XDataCenter.ItemManager.GetItem(XSpringFestivalActivityConfigs.ShowItem[self.Type]) + XLuaUiManager.Open("UiTip", itemData, true, "") +end + +function XUiGridSpringFestivalCollectCard:SendGetRewardRequest() + if self.Type == XSpringFestivalActivityConfigs.CollectWordsRewardType.Up + or self.Type == XSpringFestivalActivityConfigs.CollectWordsRewardType.Down then + XDataCenter.SpringFestivalActivityManager.CollectWordsRecvRewardRequest(self.Type, function(rewards) + if not rewards then + return + end + self:OnReceiveReward(rewards) + end) + elseif self.Type == XSpringFestivalActivityConfigs.CollectWordsRewardType.Final then + XDataCenter.SpringFestivalActivityManager.CollectWordsRecvGrandPrizeRewardRequest(function(rewards) + if not rewards then + return + end + XEventManager.DispatchEvent(XEventId.EVENT_SPRING_FESTIVAL_REWARD_RED) + self:OnReceiveReward(rewards) + self:RefreshReceiveText() + end) + end +end + +function XUiGridSpringFestivalCollectCard:OnReceiveReward(rewards) + + XUiManager.OpenUiTipReward(rewards,CS.XTextManager.GetText("SpringFestivalGetRewardTitle")) +end + +function XUiGridSpringFestivalCollectCard:Refresh() + self:RefreshReceiveText() + self:RefreshReceiveProcess() + self:RefreshTextDetail() +end + +function XUiGridSpringFestivalCollectCard:RefreshTextDetail() + local str = CSXTextManagerGetText("SpringFestivalRewardDesc" .. self.Type) + if self.TxtDetails then + self.TxtDetails.text = str + end +end + +function XUiGridSpringFestivalCollectCard:RefreshReceiveProcess() + local str = "" + if self.Type ~= XSpringFestivalActivityConfigs.CollectWordsRewardType.Final then + str = CSXTextManagerGetText("SpringFestivalCollectWordProcess", XDataCenter.SpringFestivalActivityManager.GetAlreadyRecvTimes(self.Type), XDataCenter.SpringFestivalActivityManager.GetCollectWordDuringDay()) + else + str = CSXTextManagerGetText("SpringFestivalCollectWordProcess", XDataCenter.SpringFestivalActivityManager.GetRecvFinalRewardTimes(), XDataCenter.SpringFestivalActivityManager.GetCollectWordDuringDay()) + end + if self.TxtReceive then + self.TxtReceive.text = str + end +end + +function XUiGridSpringFestivalCollectCard:RefreshReceiveText() + if self.Type ~= XSpringFestivalActivityConfigs.CollectWordsRewardType.Final then + local receiveTime = XDataCenter.SpringFestivalActivityManager.GetAlreadyRecvTimes(self.Type) + local canReceiveTime = XDataCenter.SpringFestivalActivityManager.GetCollectWordDuringDay() + local maxReceiveTime = XSpringFestivalActivityConfigs.GetCollectWordsRewardMaxCount(self.Type) + if receiveTime < canReceiveTime then + self.BtnReceive.gameObject:SetActiveEx(true) + self.BtnReceive:SetButtonState(CS.UiButtonState.Normal) + self.TxtTime.gameObject:SetActiveEx(false) + elseif receiveTime == canReceiveTime and canReceiveTime < maxReceiveTime then + self.BtnReceive.gameObject:SetActiveEx(false) + if self.TxtTime then + self.TxtTime.gameObject:SetActiveEx(true) + self.TxtTime.text = CSXTextManagerGetText("SpringFestivalNextGetRewardTime") + end + elseif receiveTime == maxReceiveTime then + self.BtnReceive.gameObject:SetActiveEx(true) + self.BtnReceive:SetDisable(true, false) + self.TxtTime.gameObject:SetActiveEx(false) + end + else + local times = XDataCenter.SpringFestivalActivityManager.GetRecvFinalRewardTimes() + local maxCount = XSpringFestivalActivityConfigs.GetCollectWordsRewardMaxCount(XSpringFestivalActivityConfigs.CollectWordsRewardType.Up) + if times >= maxCount then + self.BtnReceive.gameObject:SetActiveEx(true) + self.BtnReceive:SetDisable(true, false) + self.TxtTime.gameObject:SetActiveEx(false) + end + end +end + +function XUiGridSpringFestivalCollectCard:OnClickBtnWord(index) + local wordId = self.WordsList[index] + if not wordId then + XLog.Error("XUiGridSpringFestivalCollectCard:OnClickBtnWord:点击的字不存在") + return + end + XLuaUiManager.Open("UiSpringFestivalTip", wordId.Id) +end + +function XUiGridSpringFestivalCollectCard:StartTimer() + if self.Timer then + self:StopTimer() + end + self.Timer = XScheduleManager.ScheduleForever(function() + if XTool.UObjIsNil(self.TxtTime) then + self:StopTimer() + return + end + local time = XDataCenter.SpringFestivalActivityManager.GetNextRequestRefreshTime() + time = XMath.Clamp(time, 0, time) + if time == 0 then + self.BtnReceive.gameObject:SetActiveEx(true) + self.BtnReceive:SetDisable(false,true) + end + self.TxtTime.text = CSXTextManagerGetText("SpringFestivalNextGetRewardTime", XTime.TimestampToGameDateTimeString(time, "HH:mm:ss")) + end, XScheduleManager.SECOND, 0) +end + +function XUiGridSpringFestivalCollectCard:StopTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + end + self.Timer = nil +end + +return XUiGridSpringFestivalCollectCard \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSpringFestival/CollectCard/XUiGridSpringFestivalFriend.lua b/Resources/Scripts/XUi/XUiSpringFestival/CollectCard/XUiGridSpringFestivalFriend.lua new file mode 100644 index 00000000..14a57297 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSpringFestival/CollectCard/XUiGridSpringFestivalFriend.lua @@ -0,0 +1,60 @@ +local XUiGridSpringFestivalFriend = XClass(nil, "XUiGridSpringFestivalFriend") + +function XUiGridSpringFestivalFriend:Ctor(ui, callback) + self.GameObject = ui + self.Transform = ui.transform + self.CallBack = callback + XTool.InitUiObject(self) + self.BtnGive.CallBack = function() + self:OnClickGiveBtn() + end +end + +function XUiGridSpringFestivalFriend:Refresh(friendRequestInfo) + if not friendRequestInfo then + return + end + self.FriendRequestInfo = friendRequestInfo + self.WordId = friendRequestInfo:GetWordId() + self.RequesterId = friendRequestInfo:GetRequesterId() + if self.TxtNumber then + local f = function() + local number = XDataCenter.ItemManager.GetCount(self.WordId) + self.TxtNumber.text = number + end + XDataCenter.ItemManager.AddCountUpdateListener(self.WordId, f, self.TxtNumber) + f() + end + + local friendName = friendRequestInfo:GetRequesterName() + if friendName and self.TxtName then + self.TxtName.text = friendName + end + + if self.TxtFriend then + if friendRequestInfo:GetFromType() == XSpringFestivalActivityConfigs.WordsGiftFromType.Friend then + self.TxtFriend.text = CS.XTextManager.GetText("SpringFestivalFromFriend") + elseif friendRequestInfo:GetFromType() == XSpringFestivalActivityConfigs.WordsGiftFromType.Guild then + self.TxtFriend.text = CS.XTextManager.GetText("SpringFestivalFromGuild") + end + end + + local icon = XDataCenter.ItemManager.GetItemIcon(self.WordId) + if icon and self.RImgIcon then + self.RImgIcon:SetRawImage(icon) + end +end + +function XUiGridSpringFestivalFriend:OnClickGiveBtn() + XDataCenter.SpringFestivalActivityManager.CollectWordsGiveWordToOthersRequest(self.WordId, self.RequesterId,true, function(rewards) + if rewards then + XUiManager.OpenUiTipReward(rewards) + end + XUiManager.TipText("SpringFestivalSendWordSuccess") + if self.CallBack then + self.CallBack() + end + end) +end + +return XUiGridSpringFestivalFriend \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSpringFestival/CollectCard/XUiGridSpringFestivalGiveFriend.lua b/Resources/Scripts/XUi/XUiSpringFestival/CollectCard/XUiGridSpringFestivalGiveFriend.lua new file mode 100644 index 00000000..8d04c328 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSpringFestival/CollectCard/XUiGridSpringFestivalGiveFriend.lua @@ -0,0 +1,62 @@ +local XUiGridSpringFestivalGiveFriend = XClass(nil, "XUiGridSpringFestivalGiveFriend") + +function XUiGridSpringFestivalGiveFriend:Ctor(ui) + self.GameObject = ui + self.Transform = ui.transform + XTool.InitUiObject(self) + if self.BtnGive then + self.BtnGive.CallBack = function() + self:OnClickBtnGive() + end + end +end + +function XUiGridSpringFestivalGiveFriend:Refresh(friendInfo, wordId) + self.WordId = wordId + self.RequesterId = friendInfo.FriendId + + local name = friendInfo.NickName + if self.TxtName then + self.TxtName.text = name + end + + local isOnline = friendInfo.IsOnline + if self.TxtOnline then + self.TxtOnline.gameObject:SetActiveEx(isOnline) + end + if self.TxtTime then + self.TxtTime.gameObject:SetActiveEx(not isOnline) + end + + if isOnline then + self.PanelRoleOnLine.gameObject:SetActiveEx(true) + self.PanelRoleOffLine.gameObject:SetActiveEx(false) + else + self.PanelRoleOnLine.gameObject:SetActiveEx(false) + self.PanelRoleOffLine.gameObject:SetActiveEx(true) + end + + if isOnline and self.TxtTime then + self.TxtTime.text = CS.XTextManager.GetText("FriendLatelyLogin") .. XUiHelper.CalcLatelyLoginTime(friendInfo.LastLoginTime) + end + + local itemName = XDataCenter.ItemManager.GetItemName(self.WordId) + if self.TxtNewMessage then + self.TxtNewMessage.text = CS.XTextManager.GetText("SpringFestivalSendWordTip", itemName) + end + + XUiPLayerHead.InitPortrait(friendInfo.Icon, friendInfo.HeadFrameId, self.PanelRoleOnLine) + XUiPLayerHead.InitPortrait(friendInfo.Icon, friendInfo.HeadFrameId, self.PanelRoleOffLine) +end + +function XUiGridSpringFestivalGiveFriend:OnClickBtnGive() + XDataCenter.SpringFestivalActivityManager.CollectWordsGiveWordToOthersRequest(self.WordId, self.RequesterId,false, function(rewards) + XUiManager.TipText("SpringFestivalSendWordSuccess") + if not rewards then + return + end + XUiManager.OpenUiTipReward(rewards) + end) +end + +return XUiGridSpringFestivalGiveFriend \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSpringFestival/CollectCard/XUiGridSpringFestivalGiveItem.lua b/Resources/Scripts/XUi/XUiSpringFestival/CollectCard/XUiGridSpringFestivalGiveItem.lua new file mode 100644 index 00000000..020df10f --- /dev/null +++ b/Resources/Scripts/XUi/XUiSpringFestival/CollectCard/XUiGridSpringFestivalGiveItem.lua @@ -0,0 +1,58 @@ +local XUiGridSpringFestivalGiveItem = XClass(nil, "XUiGridSpringFestivalGiveItem") + +function XUiGridSpringFestivalGiveItem:Ctor(ui) + self.GameObject = ui + self.Transform = ui.transform + XTool.InitUiObject(self) + if self.BtnHelp then + self.BtnHelp.CallBack = function() + self:OnClickBtnHelp() + end + end +end + +function XUiGridSpringFestivalGiveItem:Refresh(friendInfo,wordId) + self.WordId = wordId + self.RequesterId = friendInfo.FriendId + + local name = friendInfo.NickName + if self.TxtName then + self.TxtName.text = name + end + + local isOnline = friendInfo.IsOnline + if self.TxtOnline then + self.TxtOnline.gameObject:SetActiveEx(isOnline) + end + if self.TxtTime then + self.TxtTime.gameObject:SetActiveEx(not isOnline) + end + + if isOnline then + self.PanelRoleOnLine.gameObject:SetActiveEx(true) + self.PanelRoleOffLine.gameObject:SetActiveEx(false) + else + self.PanelRoleOnLine.gameObject:SetActiveEx(false) + self.PanelRoleOffLine.gameObject:SetActiveEx(true) + end + + if isOnline and self.TxtTime then + self.TxtTime.text = CS.XTextManager.GetText("FriendLatelyLogin") .. XUiHelper.CalcLatelyLoginTime(friendInfo.LastLoginTime) + end + + local itemName = XDataCenter.ItemManager.GetItemName(self.WordId) + if self.TxtNewMessage then + self.TxtNewMessage = CS.XTextManager.GetText("SpringFestivalRequestWordTip", itemName) + end + + XUiPLayerHead.InitPortrait(friendInfo.Icon, friendInfo.HeadFrameId, self.PanelRoleOnLine) + XUiPLayerHead.InitPortrait(friendInfo.Icon, friendInfo.HeadFrameId, self.PanelRoleOffLine) +end + +function XUiGridSpringFestivalGiveItem:OnClickBtnHelp() + XDataCenter.SpringFestivalActivityManager.CollectWordsRequestWordToFriendRequest(self.RequesterId, function() + XUiManager.TipText("SpringFestivalRequestFriendSuccess") + end) +end + +return XUiGridSpringFestivalGiveItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSpringFestival/CollectCard/XUiGridSpringFestivalRequestItem.lua b/Resources/Scripts/XUi/XUiSpringFestival/CollectCard/XUiGridSpringFestivalRequestItem.lua new file mode 100644 index 00000000..3dc2b49b --- /dev/null +++ b/Resources/Scripts/XUi/XUiSpringFestival/CollectCard/XUiGridSpringFestivalRequestItem.lua @@ -0,0 +1,49 @@ +local XUiGridSpringFestivalRequestItem = XClass(nil, "XUiGridSpringFestivalRequestItem") + +function XUiGridSpringFestivalRequestItem:Ctor(ui, callback) + self.GameObject = ui + self.Transform = ui.transform + self.CallBack = callback + XTool.InitUiObject(self) + self:RegisterButtonEvent() +end + +function XUiGridSpringFestivalRequestItem:RegisterButtonEvent() + XUiHelper.RegisterClickEvent(self, self.Btn, self.OnSelect) + XUiHelper.RegisterClickEvent(self, self.Btn2, self.OnClickBtnWord) +end + +function XUiGridSpringFestivalRequestItem:OnClickBtnWord() + local itemData = XDataCenter.ItemManager.GetItemTemplate(self.WordId) + XLuaUiManager.Open("UiTip", itemData, false) +end + +function XUiGridSpringFestivalRequestItem:OnSelect() + if self.CallBack then + self.CallBack(self.WordId) + end +end + +function XUiGridSpringFestivalRequestItem:ShowSelectBg(isShow) + self.ImgSelect.gameObject:SetActive(isShow) +end + +function XUiGridSpringFestivalRequestItem:Refresh(wordId) + self.WordId = wordId + self:RefreshIcon() + self:RefreshCount() +end + +function XUiGridSpringFestivalRequestItem:RefreshIcon() + local icon = XDataCenter.ItemManager.GetItemIcon(self.WordId) + if icon then + self.RImgIcon:SetRawImage(icon) + end +end + +function XUiGridSpringFestivalRequestItem:RefreshCount() + local count = XDataCenter.ItemManager.GetCount(self.WordId) + self.TxtCount.text = count +end + +return XUiGridSpringFestivalRequestItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSpringFestival/CollectCard/XUiSpringFestivalBagTips.lua b/Resources/Scripts/XUi/XUiSpringFestival/CollectCard/XUiSpringFestivalBagTips.lua new file mode 100644 index 00000000..f7a6d3c8 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSpringFestival/CollectCard/XUiSpringFestivalBagTips.lua @@ -0,0 +1,65 @@ +local XUiSpringFestivalBagTips = XLuaUiManager.Register(XLuaUi, "UiSpringFestivalBagTips") +local XUiGridSpringFestivalBagItem = require("XUi/XUiSpringFestival/CollectCard/XUiGridSpringFestivalBagItem") + +function XUiSpringFestivalBagTips:OnStart() + self:RegisterButtonEvent() + self:InitDynamicTable() + self:SetupDynamicTable() +end + +function XUiSpringFestivalBagTips:OnGetEvents() + return { + XEventId.EVENT_SPRING_FESTIVAL_GIFT_BAG_REFRESH, + } +end + +function XUiSpringFestivalBagTips:OnNotify(event, ...) + if event == XEventId.EVENT_SPRING_FESTIVAL_GIFT_BAG_REFRESH then + self:SetupDynamicTable() + end +end + +function XUiSpringFestivalBagTips:RegisterButtonEvent() + self.BtnTanchuangClose.CallBack = function() + self:OnClickCloseBtn() + end + self.BtnOneReceive.CallBack = function() + self:OnClickGetRewardBtn() + end +end + +function XUiSpringFestivalBagTips:OnClickGetRewardBtn() + XDataCenter.SpringFestivalActivityManager.CollectWordsRecvWordGiftFromGiftBoxRequest(function() + XUiManager.TipText("SpringFestivalGetWordSuccess") + XEventManager.DispatchEvent(XEventId.EVENT_SPRING_FESTIVAL_GIFT_BAG_RED) + self:SetupDynamicTable() + end) +end + +function XUiSpringFestivalBagTips:OnClickCloseBtn() + XLuaUiManager.Close("UiSpringFestivalBagTips") +end + +function XUiSpringFestivalBagTips:SetupDynamicTable() + local dataCount = XDataCenter.SpringFestivalActivityManager.GetGiftCount() + if self.ImgEmpty then + self.ImgEmpty.gameObject:SetActiveEx(dataCount == 0) + end + self.DynamicTable:SetTotalCount(dataCount) + self.DynamicTable:ReloadDataASync() +end + +function XUiSpringFestivalBagTips:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelContactView) + self.DynamicTable:SetProxy(XUiGridSpringFestivalBagItem,self) + self.DynamicTable:SetDelegate(self) +end + +function XUiSpringFestivalBagTips:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:Refresh(index) + end +end + + +return XUiSpringFestivalBagTips \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSpringFestival/CollectCard/XUiSpringFestivalCollectCard.lua b/Resources/Scripts/XUi/XUiSpringFestival/CollectCard/XUiSpringFestivalCollectCard.lua new file mode 100644 index 00000000..a943a425 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSpringFestival/CollectCard/XUiSpringFestivalCollectCard.lua @@ -0,0 +1,172 @@ +local XUiSpringFestivalCollectCard = XLuaUiManager.Register(XLuaUi, "UiSpringFestivalCollectCard") +local XUiGridSpringFestivalCollectCard = require("XUi/XUiSpringFestival/CollectCard/XUiGridSpringFestivalCollectCard") + +function XUiSpringFestivalCollectCard:OnStart() + self.EndTime = XDataCenter.SpringFestivalActivityManager.GetActivityEndTime() + self:Init() +end + +function XUiSpringFestivalCollectCard:OnEnable() + self:RefreshRemainingTime() + self:StartTimer() + self:RefreshGridPanel() + XRedPointManager.AddRedPointEvent(self.BtnActivity, self.CheckTaskRedPoint, self, { XRedPointConditions.Types.CONDITION_SPRINGFESTIVAL_TASK_RED },XSpringFestivalActivityConfigs.GetSpringFestivalCollectActivityId()) + XRedPointManager.AddRedPointEvent(self.BtnMail, self.CheckBtnMailRedPoint, self, { XRedPointConditions.Types.CONDITION_SPRINGFESTIVAL_BAG_RED }) + local isShowHelp = XSaveTool.GetData(string.format("%s%s",XSpringFestivalActivityConfigs.COLLECT_WORD_HELP_KEY,XPlayer.Id)) + if not isShowHelp then + self:ShowHelp() + XSaveTool.SaveData(string.format("%s%s",XSpringFestivalActivityConfigs.COLLECT_WORD_HELP_KEY,XPlayer.Id),true) + end +end + +function XUiSpringFestivalCollectCard:OnDisable() + self:StopTimer() +end + +function XUiSpringFestivalCollectCard:OnDestroy() + +end + +function XUiSpringFestivalCollectCard:OnGetEvents() + return { + XEventId.EVENT_SPRING_FESTIVAL_COLLECT_CARD_REFRESH, + } +end + +function XUiSpringFestivalCollectCard:OnNotify(event, ...) + if event == XEventId.EVENT_SPRING_FESTIVAL_COLLECT_CARD_REFRESH then + self:RefreshGridPanel() + end +end + +function XUiSpringFestivalCollectCard:Init() + self.PanelAsset = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.UniversalWord) + if self.BtnHelpCourse then + self.BtnHelpCourse.gameObject:SetActiveEx(XSpringFestivalActivityConfigs.GetCollectHelpId() > 0) + end + self:RegisterButtonEvent() + self.GridReward = {} + self.GridReward[XSpringFestivalActivityConfigs.CollectWordsRewardType.Up] = XUiGridSpringFestivalCollectCard.New(self.GridReward01, XSpringFestivalActivityConfigs.CollectWordsRewardType.Up) + self.GridReward[XSpringFestivalActivityConfigs.CollectWordsRewardType.Down] = XUiGridSpringFestivalCollectCard.New(self.GridReward02, XSpringFestivalActivityConfigs.CollectWordsRewardType.Down) + self.GridReward[XSpringFestivalActivityConfigs.CollectWordsRewardType.Final] = XUiGridSpringFestivalCollectCard.New(self.GridReward03, XSpringFestivalActivityConfigs.CollectWordsRewardType.Final) +end + +function XUiSpringFestivalCollectCard:CheckTaskRedPoint(count) + self.BtnActivity:ShowReddot(count >= 0) +end + +function XUiSpringFestivalCollectCard:CheckBtnMailRedPoint(count) + self.BtnMail:ShowReddot(count >= 0) +end + +function XUiSpringFestivalCollectCard:RegisterButtonEvent() + self.BtnBack.CallBack = function() + self:OnClickBackBtn() + end + self.BtnMainUi.CallBack = function() + self:OnClickMainBtn() + end + self.BtnActivity.CallBack = function() + self:OnClickBtnActivity() + end + self.BtnGive.CallBack = function() + self:OnClickBtnGive() + end + self.BtnHelp.CallBack = function() + self:OnClickBtnHelp() + end + self.BtnMail.CallBack = function() + self:OnClickBtnMail() + end + + if self.BtnTool then + self.BtnTool.CallBack = function() + local universalWord = XDataCenter.ItemManager.GetItem(XDataCenter.ItemManager.ItemId.UniversalWord) + XLuaUiManager.Open("UiTip", universalWord, true, "") + end + end + if self.BtnHelpCourse then + local template = XHelpCourseConfig.GetHelpCourseTemplateById(XSpringFestivalActivityConfigs.GetCollectHelpId()) + self:BindHelpBtn(self.BtnHelpCourse,template.Function) + end +end + +function XUiSpringFestivalCollectCard:OnClickBackBtn() + XLuaUiManager.Close("UiSpringFestivalCollectCard") +end + +function XUiSpringFestivalCollectCard:OnClickMainBtn() + XLuaUiManager.RunMain() +end + +function XUiSpringFestivalCollectCard:OnClickBtnHelp() + if XDataCenter.SpringFestivalActivityManager.HasRequestWord() then + XLuaUiManager.Open("UiSpringFestivalHelpTips2") + else + XLuaUiManager.Open("UiSpringFestivalHelpTips1") + end +end + +function XUiSpringFestivalCollectCard:OnClickBtnMail() + XLuaUiManager.Open("UiSpringFestivalBagTips") +end + +function XUiSpringFestivalCollectCard:OnClickBtnActivity() + XLuaUiManager.Remove("UiFubenSpringFestivalChapter") + XLuaUiManager.Remove("UiSpringFestivalCollectCard") + local skipId = XSpringFestivalActivityConfigs.GetSpringFestivalActivityCollectSkipId() + XFunctionManager.SkipInterface(skipId) +end + +function XUiSpringFestivalCollectCard:OnClickBtnGive() + XLuaUiManager.Open("UiSpringFestivalGiveTips") +end + +function XUiSpringFestivalCollectCard:ShowHelp() + local helpId = XSpringFestivalActivityConfigs.GetCollectHelpId() + if helpId > 0 then + local template = XHelpCourseConfig.GetHelpCourseTemplateById(helpId) + XUiManager.ShowHelpTip(template.Function) + end +end + +function XUiSpringFestivalCollectCard:RefreshGridPanel() + for _, grid in pairs(self.GridReward) do + grid:Refresh() + end +end + +function XUiSpringFestivalCollectCard:StartTimer() + if self.Timer then + self:StopTimer() + end + self.Timer = XScheduleManager.ScheduleForever(function() + if XTool.UObjIsNil(self.TxtTime) then + self:StopTimer() + return + end + local currentTime = XTime.GetServerNowTimestamp() + if currentTime > self.EndTime then + XDataCenter.SpringFestivalActivityManager.OnActivityEnd() + return + end + self:RefreshRemainingTime() + end,XScheduleManager.SECOND) +end + +function XUiSpringFestivalCollectCard:StopTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end + +function XUiSpringFestivalCollectCard:RefreshRemainingTime() + local endTime = XDataCenter.SpringFestivalActivityManager.GetActivityEndTime() + local startTime = XDataCenter.SpringFestivalActivityManager.GetActivityStartTime() + local now = XTime.GetServerNowTimestamp() + local offset = XMath.Clamp(endTime - now,0,endTime-startTime) + self.TxtTime.text = XUiHelper.GetTime(offset,XUiHelper.TimeFormatType.ACTIVITY) +end + +return XUiSpringFestivalCollectCard \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSpringFestival/CollectCard/XUiSpringFestivalFriendsTip.lua b/Resources/Scripts/XUi/XUiSpringFestival/CollectCard/XUiSpringFestivalFriendsTip.lua new file mode 100644 index 00000000..c461204e --- /dev/null +++ b/Resources/Scripts/XUi/XUiSpringFestival/CollectCard/XUiSpringFestivalFriendsTip.lua @@ -0,0 +1,46 @@ +local XUiSpringFestivalFriendTip = XLuaUiManager.Register(XLuaUi,"UiSpringFestivalFriendTip") +local XUiGridSpringFestivalGiveFriend = require("XUi/XUiSpringFestival/CollectCard/XUiGridSpringFestivalGiveFriend") + +function XUiSpringFestivalFriendTip:OnStart(wordId) + self.WordId = wordId +end + +function XUiSpringFestivalFriendTip:OnEnable() + self:RegisterButtonEvent() + XDataCenter.SpringFestivalActivityManager.CollectWordsRefreshRequestWordListRequest(function() + self:InitDynamicTable() + self:SetupDynamicTable() + end) +end + +function XUiSpringFestivalFriendTip:RegisterButtonEvent() + self.BtnTanchuangClose.CallBack = function() + self.OnClickBackBtn() + end +end + +function XUiSpringFestivalFriendTip:OnClickBackBtn() + XLuaUiManager.Close("UiSpringFestivalFriendTip") +end + +function XUiSpringFestivalFriendTip:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelFriendList) + self.DynamicTable:SetProxy(XUiGridSpringFestivalGiveFriend) + self.DynamicTable:SetDelegate(self) +end + +function XUiSpringFestivalFriendTip:SetupDynamicTable() + self.FriendList = XDataCenter.SocialManager.GetFriendList() + self.ImgEmpty.gameObject:SetActiveEx(#self.FriendList == 0) + self.DynamicTable:SetTotalCount(#self.FriendList) + self.DynamicTable:ReloadDataASync() +end + +function XUiSpringFestivalFriendTip:OnDynamicTableEvent(event,index,grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:Refresh(self.FriendList[index],self.WordId) + end +end + + +return XUiSpringFestivalFriendTip \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSpringFestival/CollectCard/XUiSpringFestivalGiveTips.lua b/Resources/Scripts/XUi/XUiSpringFestival/CollectCard/XUiSpringFestivalGiveTips.lua new file mode 100644 index 00000000..1b69113f --- /dev/null +++ b/Resources/Scripts/XUi/XUiSpringFestival/CollectCard/XUiSpringFestivalGiveTips.lua @@ -0,0 +1,55 @@ +local XUiSpringFestivalGiveTips = XLuaUiManager.Register(XLuaUi, "UiSpringFestivalGiveTips") +local XUiGridSpringFestivalFriend = require("XUi/XUiSpringFestival/CollectCard/XUiGridSpringFestivalFriend") + +function XUiSpringFestivalGiveTips:OnStart() + +end + +function XUiSpringFestivalGiveTips:OnEnable() + self:RegisterButtonEvent() + self:InitDynamicTable() + XDataCenter.SpringFestivalActivityManager.CollectWordsRefreshRequestWordListRequest(function() + self:SetupDynamicTable() + end) +end + +function XUiSpringFestivalGiveTips:OnDisable() + +end + +function XUiSpringFestivalGiveTips:OnDestroy() + +end + +function XUiSpringFestivalGiveTips:RegisterButtonEvent() + self.BtnTanchuangClose.CallBack = function() + self:OnClickCloseBtn() + end +end + +function XUiSpringFestivalGiveTips:OnClickCloseBtn() + XLuaUiManager.Close("UiSpringFestivalGiveTips") +end + +function XUiSpringFestivalGiveTips:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelFriendList) + self.DynamicTable:SetProxy(XUiGridSpringFestivalFriend) + self.DynamicTable:SetDelegate(self) +end + +function XUiSpringFestivalGiveTips:SetupDynamicTable() + self.RequestList = XDataCenter.SpringFestivalActivityManager.GetFriendRequestList() + if self.ImgEmpty then + self.ImgEmpty.gameObject:SetActiveEx(#self.RequestList == 0) + end + self.DynamicTable:SetTotalCount(#self.RequestList) + self.DynamicTable:ReloadDataASync() +end + +function XUiSpringFestivalGiveTips:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:Refresh(self.RequestList[index]) + end +end + +return XUiSpringFestivalGiveTips \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSpringFestival/CollectCard/XUiSpringFestivalHelpTips1.lua b/Resources/Scripts/XUi/XUiSpringFestival/CollectCard/XUiSpringFestivalHelpTips1.lua new file mode 100644 index 00000000..474e01c4 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSpringFestival/CollectCard/XUiSpringFestivalHelpTips1.lua @@ -0,0 +1,84 @@ +local XUiSpringFestivalHelpTips1 = XLuaUiManager.Register(XLuaUi, "UiSpringFestivalHelpTips1") +local XUiGridSpringFestivalRequestItem = require("XUi/XUiSpringFestival/CollectCard/XUiGridSpringFestivalRequestItem") +function XUiSpringFestivalHelpTips1:OnStart() + self.RequestItemsDic = {} + self:InitItemList() + self:RegisterButtonEvent() + self.LastSelectId = 0 +end + +function XUiSpringFestivalHelpTips1:OnEnable() + +end + +function XUiSpringFestivalHelpTips1:OnDisable() + +end + +function XUiSpringFestivalHelpTips1:OnDestroy() + +end + +function XUiSpringFestivalHelpTips1:InitItemList() + local wordTemplates = XSpringFestivalActivityConfigs.GetCollectWordsTemplateOrderFunc(function(a, b) + local countA = XDataCenter.ItemManager.GetCount(a.Id) + local countB = XDataCenter.ItemManager.GetCount(b.Id) + return countA < countB + end) + for i = 1 ,#wordTemplates do + if not self.RequestItemsDic[wordTemplates[i].Id] and wordTemplates[i].Type ~= XSpringFestivalActivityConfigs.CollectCardType.Universal then + local obj = CS.UnityEngine.Object.Instantiate(self.GridRewardItem, self.PanelReward) + obj.gameObject:SetActive(true) + local item = XUiGridSpringFestivalRequestItem.New(obj, function(newWordId) + self:OnSelectRequestItem(newWordId) + end) + item:Refresh(wordTemplates[i].Id) + self.RequestItemsDic[wordTemplates[i].Id] = item + end + end +end + +function XUiSpringFestivalHelpTips1:OnSelectRequestItem(newWordId) + local item = self.RequestItemsDic[newWordId] + if item then + item:ShowSelectBg(true) + end + + local lastSelectItem = self.RequestItemsDic[self.LastSelectId] + if lastSelectItem then + lastSelectItem:ShowSelectBg(false) + end + if newWordId == self.LastSelectId then + self.LastSelectId = 0 + else + self.LastSelectId = newWordId + end +end + +function XUiSpringFestivalHelpTips1:RegisterButtonEvent() + self.BtnTanchuangClose.CallBack = function() + self:OnClickCloseBtn() + end + self.BtnYes.CallBack = function() + self:OnClickYesBtn() + end + self.BtnNo.CallBack = function() + self:OnClickCloseBtn() + end +end + +function XUiSpringFestivalHelpTips1:OnClickCloseBtn() + XLuaUiManager.Close("UiSpringFestivalHelpTips1") +end + +function XUiSpringFestivalHelpTips1:OnClickYesBtn() + if self.LastSelectId == 0 then + return + end + XDataCenter.SpringFestivalActivityManager.CollectWordsRequestWordRequest(self.LastSelectId, function() + XLuaUiManager.Close("UiSpringFestivalHelpTips1") + XLuaUiManager.Open("UiSpringFestivalHelpTips2") + end) +end + +return XUiSpringFestivalHelpTips1 \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSpringFestival/CollectCard/XUiSpringFestivalHelpTips2.lua b/Resources/Scripts/XUi/XUiSpringFestival/CollectCard/XUiSpringFestivalHelpTips2.lua new file mode 100644 index 00000000..be4bc49d --- /dev/null +++ b/Resources/Scripts/XUi/XUiSpringFestival/CollectCard/XUiSpringFestivalHelpTips2.lua @@ -0,0 +1,122 @@ +local XUiSpringFestivalHelpTips2 = XLuaUiManager.Register(XLuaUi, "UiSpringFestivalHelpTips2") +local XUiGridSpringFestivalGiveItem = require("XUi/XUiSpringFestival/CollectCard/XUiGridSpringFestivalGiveItem") +function XUiSpringFestivalHelpTips2:OnStart() + self:RegisterButtonEvent() + self:InitDynamicTable() + self:SetupDynamicTable() +end + +function XUiSpringFestivalHelpTips2:OnEnable() + local isJoinGuild = XDataCenter.GuildManager.IsJoinGuild() + self.GridContact.gameObject:SetActiveEx(isJoinGuild) + if isJoinGuild then + self:RefreshGuildRequestInfo() + end + self:RefreshRequestInfo() + self:SetRemainingTime() + self:StartTimer() +end + +function XUiSpringFestivalHelpTips2:OnDisable() + +end + +function XUiSpringFestivalHelpTips2:OnDestroy() + self:StopTimer() +end + +function XUiSpringFestivalHelpTips2:StartTimer() + if self.Timer then + self:StopTimer() + end + self.Timer = XScheduleManager.ScheduleForever(function() + if XTool.UObjIsNil(self.TxtTime) then + self.StopTimer() + return + end + self:SetRemainingTime() + end, XScheduleManager.SECOND) +end + +function XUiSpringFestivalHelpTips2:StopTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end + +function XUiSpringFestivalHelpTips2:SetRemainingTime() + local offset = XDataCenter.SpringFestivalActivityManager.GetNextRequestTime() + if offset <= 0 then + XUiManager.TipText("SpringFestivalGuildRequestRefresh") + XLuaUiManager.Close("UiSpringFestivalHelpTips2") + return + end + if self.TxtTime then + self.TxtTime.text = XUiHelper.GetTime(offset,XUiHelper.TimeFormatType.GUILDCD) + end +end + +function XUiSpringFestivalHelpTips2:RegisterButtonEvent() + self.BtnTanchuangClose.CallBack = function() + self:OnClickCloseBtn() + end + self.BtnHelp.CallBack = function() + self:OnClickBtnSendGuildRequest() + end +end + +function XUiSpringFestivalHelpTips2:OnClickCloseBtn() + XLuaUiManager.Close("UiSpringFestivalHelpTips2") +end + +function XUiSpringFestivalHelpTips2:OnClickBtnSendGuildRequest() + local isCd,cd = XDataCenter.SpringFestivalActivityManager.CheckIsInGuildRequestCd() + if isCd then + XUiManager.TipMsg(CS.XTextManager.GetText("SpringFestivalGuildCdTip",XUiHelper.GetTimeDesc(cd))) + return + end + XDataCenter.SpringFestivalActivityManager.CollectWordsRequestWordToGuildRequest(function() + XUiManager.TipText("SpringFestivalGuildRequestSuccess") + end) +end + +function XUiSpringFestivalHelpTips2:RefreshRequestInfo() + local wordId = XDataCenter.SpringFestivalActivityManager.GetRequestWordId() + local itemIcon = XDataCenter.ItemManager.GetItemIcon(wordId) + self.RequestWordIcon:SetRawImage(itemIcon) +end + +function XUiSpringFestivalHelpTips2:RefreshGuildRequestInfo() + local guildIcon = XDataCenter.GuildManager.GetGuildIconId() + if self.RImgIcon then + self.RImgIcon:SetRawImage(guildIcon) + end + local guildName = XDataCenter.GuildManager.GetGuildName() + if self.TxtName then + self.TxtName.text = guildName + end +end + +function XUiSpringFestivalHelpTips2:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelFriendList) + self.DynamicTable:SetProxy(XUiGridSpringFestivalGiveItem) + self.DynamicTable:SetDelegate(self) +end + +function XUiSpringFestivalHelpTips2:SetupDynamicTable() + self.FriendList = XDataCenter.SocialManager.GetFriendList() + if self.ImgEmpty then + self.ImgEmpty.gameObject:SetActiveEx(#self.FriendList == 0) + end + self.DynamicTable:SetTotalCount(#self.FriendList) + self.DynamicTable:ReloadDataASync() +end + +function XUiSpringFestivalHelpTips2:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:Refresh(self.FriendList[index],XDataCenter.SpringFestivalActivityManager.GetRequestWordId()) + end +end + +return XUiSpringFestivalHelpTips2 \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSpringFestival/CollectCard/XUiSpringFestivalTip.lua b/Resources/Scripts/XUi/XUiSpringFestival/CollectCard/XUiSpringFestivalTip.lua new file mode 100644 index 00000000..54374599 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSpringFestival/CollectCard/XUiSpringFestivalTip.lua @@ -0,0 +1,61 @@ +local XUiSpringFestivalTip = XLuaUiManager.Register(XLuaUi,"UiSpringFestivalTip") +function XUiSpringFestivalTip:OnStart(wordId) + self.WordId = wordId + self:RegisterButtonClick() +end + +function XUiSpringFestivalTip:OnEnable() + self:RefreshWordInfo() +end + +function XUiSpringFestivalTip:RefreshWordInfo() + local icon = XDataCenter.ItemManager.GetItemIcon(self.WordId) + if icon and self.RImgIcon then + self.RImgIcon:SetRawImage(icon) + end + + local name = XDataCenter.ItemManager.GetItemName(self.WordId) + if self.TxtName then + self.TxtName.text = name + end + + local func = function() + local count = XDataCenter.ItemManager.GetCount(self.WordId) + if self.TxtCount then + self.TxtCount.text = count + end + end + XDataCenter.ItemManager.AddCountUpdateListener(self.WordId,func,self.TxtCount) + func() + + local desc = XDataCenter.ItemManager.GetItemDescription(self.WordId) + if self.TxtDescription then + self.TxtDescription.text = desc + end + + local worldDesc = XDataCenter.ItemManager.GetItemWorldDesc(self.WordId) + if self.TxtWorldDesc then + self.TxtWorldDesc.text = worldDesc + end +end + +function XUiSpringFestivalTip:RegisterButtonClick() + if self.BtnBack then + XUiHelper.RegisterClickEvent(self,self.BtnBack,self.OnClickBtnBack) + end + if self.BtnGive then + self.BtnGive.CallBack = function() + self:OnClickBtnGive() + end + end +end + +function XUiSpringFestivalTip:OnClickBtnBack() + XLuaUiManager.Close("UiSpringFestivalTip") +end + +function XUiSpringFestivalTip:OnClickBtnGive() + XLuaUiManager.Open("UiSpringFestivalFriendTip",self.WordId) +end + +return XUiSpringFestivalTip \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSpringFestival/SmashEggs/XUiGridSpringFestivalBuffEffectItem.lua b/Resources/Scripts/XUi/XUiSpringFestival/SmashEggs/XUiGridSpringFestivalBuffEffectItem.lua new file mode 100644 index 00000000..0f25a506 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSpringFestival/SmashEggs/XUiGridSpringFestivalBuffEffectItem.lua @@ -0,0 +1,18 @@ +local XUiGridSpringFestivalBuffEffectItem = XClass(nil, "XUiGridSpringFestivalBuffEffectItem") + +function XUiGridSpringFestivalBuffEffectItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui + XTool.InitUiObject(self) +end + +function XUiGridSpringFestivalBuffEffectItem:Refresh(itemId) + self.GameObject:SetActiveEx(itemId > 0) + if itemId == 0 then return end + local desc = XSpringFestivalActivityConfigs.GetBuffItemDesc(itemId) + if self.TxtDescribe then + self.TxtDescribe.text = desc + end +end + +return XUiGridSpringFestivalBuffEffectItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSpringFestival/SmashEggs/XUiGridSpringFestivalSmashEggsReward.lua b/Resources/Scripts/XUi/XUiSpringFestival/SmashEggs/XUiGridSpringFestivalSmashEggsReward.lua new file mode 100644 index 00000000..e582ffcf --- /dev/null +++ b/Resources/Scripts/XUi/XUiSpringFestival/SmashEggs/XUiGridSpringFestivalSmashEggsReward.lua @@ -0,0 +1,74 @@ +local XUiGridSpringFestivalSmashEggsReward = XClass(nil, "XUiGridSpringFestivalSmashEggsReward") + +function XUiGridSpringFestivalSmashEggsReward:Ctor(ui, callback) + self.GameObject = ui + self.Transform = ui.transform + self.Callback = callback + XTool.InitUiObject(self) + self.BtnActive.CallBack = function() + self:OnClickBtnActive() + end +end + +function XUiGridSpringFestivalSmashEggsReward:Refresh(data) + if not data then + return + end + self.Index = data.Index + self.TargetScore = data.TargetScore + self.IsReceive = XDataCenter.SpringFestivalActivityManager.CheckRewardIsReceive(self.Index) + self.ImgRe.gameObject:SetActiveEx(self.IsReceive) + if not self.IsReceive then + local todayScore = XDataCenter.SpringFestivalActivityManager.GetSmashEggsTodayScore() + if self.PanelEffect then + self.PanelEffect.gameObject:SetActiveEx(data.TargetScore <= todayScore) + end + else + if self.PanelEffect then + self.PanelEffect.gameObject:SetActiveEx(false) + end + end + if self.TargetScore and self.TxtValue then + self.TxtValue.text = self.TargetScore + end + local day = XDataCenter.SpringFestivalActivityManager.GetSmashEggsActivityDay() + local rewards = XRewardManager.GetRewardList(XSpringFestivalActivityConfigs.GetSmashEggsRewardRewardId(day,self.Index)) + + if #rewards > 0 then + local reward = rewards[1] + if self.TxtNumber then + self.TxtNumber.text = reward.Count + end + if self.RImgIcon then + local icon = XGoodsCommonManager.GetGoodsIcon(reward.TemplateId) + if icon then + self.RImgIcon:SetRawImage(icon) + end + end + end +end + +function XUiGridSpringFestivalSmashEggsReward:OnClickBtnActive() + if self.IsReceive then + XUiManager.TipText("SpringFestivalHasGetReward") + return + end + if XDataCenter.SpringFestivalActivityManager.GetSmashEggsTodayScore() < self.TargetScore then + local day = XDataCenter.SpringFestivalActivityManager.GetSmashEggsActivityDay() + local rewards = XRewardManager.GetRewardList(XSpringFestivalActivityConfigs.GetSmashEggsRewardRewardId(day,self.Index)) + XUiManager.OpenUiTipReward(rewards) + return + end + + XDataCenter.SpringFestivalActivityManager.SmashEggsGetActivationDailyRewardRequest(self.Index, function(rewards) + if not rewards or #rewards == 0 then + return + end + XUiManager.OpenUiTipReward(rewards,CS.XTextManager.GetText("SpringFestivalGetRewardTitle")) + if self.Callback then + self.Callback() + end + end) +end + +return XUiGridSpringFestivalSmashEggsReward \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSpringFestival/SmashEggs/XUiSpringFestivalSmashEggs.lua b/Resources/Scripts/XUi/XUiSpringFestival/SmashEggs/XUiSpringFestivalSmashEggs.lua new file mode 100644 index 00000000..789735c7 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSpringFestival/SmashEggs/XUiSpringFestivalSmashEggs.lua @@ -0,0 +1,589 @@ +local XUiSpringFestivalSmashEggs = XLuaUiManager.Register(XLua, "UiSpringFestivalSmashEggs") +local XUiGridSpringFestivalSmashEggsReward = require("XUi/XUiSpringFestival/SmashEggs/XUiGridSpringFestivalSmashEggsReward") +local XUiGridSpringFestivalBuffEffectItem = require("XUi/XUiSpringFestival/SmashEggs/XUiGridSpringFestivalBuffEffectItem") +local tableInsert = table.insert +local MODEL_COUNT = 3 +local HAMMER_COUNT = 2 +local SHOW_TIP_DELAY = 3 * XScheduleManager.SECOND +local SHOW_REWARD_DELAY = 4 * XScheduleManager.SECOND +local HammerPosOffset = { + x = 0, + y = 0.1, + z = 0.2 +} + +function XUiSpringFestivalSmashEggs:OnStart() + self:InitSceneRoot() + self:RegisterButtonClick() + self.RewardGrid = {} + self.BuffItemBtn = {} + self.BuffEffectGrid = {} + self.CurrentSelectHammer = XDataCenter.SpringFestivalActivityManager.GetCurrHammer() + self.CurrentSelectBuffItem = XDataCenter.SpringFestivalActivityManager.GetCurrBuffItem() + self.CurrentSafetyProtect = XDataCenter.SpringFestivalActivityManager.GetCurrSafetyProtect() + self.SkipAnimation = false + self.EndTime = XDataCenter.SpringFestivalActivityManager.GetActivityEndTime() +end + +function XUiSpringFestivalSmashEggs:OnEnable() + self:RefreshRemainingTime() + self:StartTimer() + local protectId = XSpringFestivalActivityConfigs.GetBuffItemItemId(XSpringFestivalActivityConfigs.BuffItem.Money) + self.BaodiGrid:SetButtonState(self.CurrentSafetyProtect == 0 and CS.UiButtonState.Normal or CS.UiButtonState.Select) + self.BaodiGrid:SetRawImage(XDataCenter.ItemManager.GetItemIcon(protectId)) + self.AssetPanel = XUiPanelAsset.New(self, self.BtnShop, XSpringFestivalActivityConfigs.GetScoreConvertItemId()) + local sliverText = self.GridTips01:Find("TxtTips"):GetComponent("Text") + sliverText.text = XDataCenter.ItemManager.GetItemDescription(XSpringFestivalActivityConfigs.GetBuffItemItemId(XSpringFestivalActivityConfigs.BuffItem.SilverHammer)) + local goldText = self.GridTips02:Find("TxtTips"):GetComponent("Text") + goldText.text = XDataCenter.ItemManager.GetItemDescription(XSpringFestivalActivityConfigs.GetBuffItemItemId(XSpringFestivalActivityConfigs.BuffItem.GoldHammer)) + self:InitHammerBtnGroup() + self:InitBuffItemPanel() + self:Refresh() + self.BtnHelpCourse.gameObject:SetActiveEx(XSpringFestivalActivityConfigs.GetSmashEggsHelpId() > 0) + local isShowHelp = XSaveTool.GetData(string.format("%s%s", XSpringFestivalActivityConfigs.SMASH_EGGS_HELP_KEY, XPlayer.Id)) + if not isShowHelp then + self:ShowHelp() + XSaveTool.SaveData(string.format("%s%s", XSpringFestivalActivityConfigs.SMASH_EGGS_HELP_KEY, XPlayer.Id), true) + end +end + +function XUiSpringFestivalSmashEggs:OnDisable() + self:StopTimer() +end + +function XUiSpringFestivalSmashEggs:OnDestroy() + +end + +function XUiSpringFestivalSmashEggs:InitSceneRoot() + local root = self.UiModelGo.transform + for i = 1, MODEL_COUNT do + local model = root:FindTransform("Model" .. i).gameObject + CS.XShadowHelper.AddShadow(model) + self["UIMonsterFaint" .. i] = root:FindTransform("UIMonsterFaint" .. i).gameObject + self["UIMonsterAngry" .. i] = root:FindTransform("UIMonsterAngry" .. i).gameObject + self["UISuccessed" .. i] = root:FindTransform("UISuccessed" .. i).gameObject + self["FxUIHammerHit" .. i] = root:FindTransform("FxUIHammerHit" .. i).gameObject + self["FxHongbao" .. i] = root:FindTransform("FxHongbao" .. i).gameObject + self["Model" .. i] = model:GetComponent("Animator") + local inputHandler = model:GetComponent(typeof(CS.XGoInputHandler)) + if not inputHandler then + inputHandler = model:AddComponent(typeof(CS.XGoInputHandler)) + end + self["InputHandler" .. i] = inputHandler + end + for i = 1, HAMMER_COUNT do + self["Hammer" .. i] = root:FindTransform("Hammer" .. i):GetComponent("Animator") + self["Hammer" .. i].gameObject:SetActive(false) + end +end + +function XUiSpringFestivalSmashEggs:OnGetEvents() + return { + XEventId.EVENT_SPRING_FESTIVAL_SMASH_EGGS_REFRESH, + } +end + +function XUiSpringFestivalSmashEggs:OnNotify(event, ...) + if event == XEventId.EVENT_SPRING_FESTIVAL_SMASH_EGGS_REFRESH then + self:RefreshPanel() + end +end + +function XUiSpringFestivalSmashEggs:RegisterButtonClick() + self.BtnBack.CallBack = function() + self:OnClickBackBtn() + end + self.BtnMainUi.CallBack = function() + self:OnClickMainBtn() + end + self.BtnSkip.CallBack = function() + self:OnClickBtnSkipAnimation() + end + self.BaodiGrid.CallBack = function() + self:OnClickBaodiGrid() + end + + self.BtnExchange.CallBack = function() + self:OnClickBtnExchange() + end + + self.BtnShop.CallBack = function() + self:OnClickBtnShop() + end + + if self.BtnHelpCourse then + local template = XHelpCourseConfig.GetHelpCourseTemplateById(XSpringFestivalActivityConfigs.GetSmashEggsHelpId()) + self:BindHelpBtn(self.BtnHelpCourse, template.Function) + end + for i = 1, MODEL_COUNT do + local index = i + self["InputHandler" .. i]:AddPointerClickListener(function(eventData) + self:OnClickModel(eventData, index) + end) + self["BtnSupply" .. i].CallBack = function() + self:OnClickBtnSupply(index) + end + end +end + +function XUiSpringFestivalSmashEggs:OnClickModel(eventData, index) + + if not self:CheckItemCount() then + XUiManager.TipText("SpringFestivalItemNotEnough") + return + end + if XDataCenter.SpringFestivalActivityManager.CheckIsNeedTip() and self.CurrentSafetyProtect == 0 then + XUiManager.DialogTip(CS.XTextManager.GetText("TipTitle"), CS.XTextManager.GetText("SpringFestivalSequenceSuccessTip", XDataCenter.SpringFestivalActivityManager.GetSequenceSuccessCount()), XUiManager.DialogType.Normal, nil, function() + self:SendSmashRequest(index) + end) + else + self:SendSmashRequest(index) + end +end + +function XUiSpringFestivalSmashEggs:ShowHelp() + local helpId = XSpringFestivalActivityConfigs.GetSmashEggsHelpId() + if helpId > 0 then + local template = XHelpCourseConfig.GetHelpCourseTemplateById(helpId) + XUiManager.ShowHelpTip(template.Function) + end +end + +function XUiSpringFestivalSmashEggs:SendSmashRequest(index) + local place = index - 1 + local useItem = { + Buff = self.CurrentSelectBuffItem, + Hammer = self.CurrentSelectHammer, + SafetyProtect = self.CurrentSafetyProtect } + XDataCenter.SpringFestivalActivityManager.SmashEggRequest(place, useItem, function(isSuccess, rewards, addScore) + + if self.SkipAnimation then + self:PlaySkipAnimation(index) + else + if isSuccess then + self:PlaySuccessAnimation(index) + else + self:PlayFailAnimation(index) + end + end + local tipDelay = not self.SkipAnimation and SHOW_TIP_DELAY or 0 + local rewardDelay = not self.SkipAnimation and SHOW_REWARD_DELAY or 1000 + if not rewards or #rewards == 0 then + if isSuccess then + self.TipTimer = XScheduleManager.ScheduleOnce(function ()XUiManager.TipMsg(CsXTextManagerGetText("SpringFestivalSuccessNoItem", addScore))end ,tipDelay) + else + if self.CurrentSafetyProtect > 0 then + self.TipTimer = XScheduleManager.ScheduleOnce(function()XUiManager.TipMsg(CsXTextManagerGetText("SpringFestivalFailWithProtect"))end,tipDelay) + else + self.TipTimer = XScheduleManager.ScheduleOnce(function()XUiManager.TipMsg(CsXTextManagerGetText("SpringFestivalFailNoItem"))end,tipDelay) + end + end + return + else + if isSuccess then + self.TipTimer = XScheduleManager.ScheduleOnce(function ()XUiManager.TipMsg(CsXTextManagerGetText("SpringFestivalSuccessHasItem", addScore))end ,tipDelay) + else + if self.CurrentSafetyProtect > 0 then + self.TipTimer = XScheduleManager.ScheduleOnce(function()XUiManager.TipMsg(CsXTextManagerGetText("SpringFestivalFailWithProtectAndItem"))end,tipDelay) + else + self.TipTimer = XScheduleManager.ScheduleOnce(function()XUiManager.TipMsg(CsXTextManagerGetText("SpringFestivalFailHasItem"))end,tipDelay) + end + end + self.RewardTimer = XScheduleManager.ScheduleOnce(function()XUiManager.OpenUiTipReward(rewards,CS.XTextManager.GetText("SpringFestivalGetRewardTitle")) end,rewardDelay) + end + end) +end + +function XUiSpringFestivalSmashEggs:OnClickBtnSupply(index) + local list = {} + for i = 1, MODEL_COUNT do + tableInsert(list, i - 1) + end + XDataCenter.SpringFestivalActivityManager.SmashEggsResetEggsRequest(list, function() + self:PlayRebornAnimation() + end) +end + +function XUiSpringFestivalSmashEggs:OnClickBaodiGrid() + local isSelect = self.BaodiGrid:GetToggleState() + if isSelect then + self.CurrentSafetyProtect = XSpringFestivalActivityConfigs.BuffItem.Money + else + self.CurrentSafetyProtect = 0 + end + self:RefreshBuffEffectPanel() +end + +function XUiSpringFestivalSmashEggs:OnClickBackBtn() + XLuaUiManager.Close("UiSpringFestivalSmashEggs") +end + +function XUiSpringFestivalSmashEggs:OnClickMainBtn() + XLuaUiManager.RunMain() +end + +function XUiSpringFestivalSmashEggs:OnClickBtnExchange() + XDataCenter.SpringFestivalActivityManager.SmashEggsConvertScoreRequest(function() + self:PlayAnimation("EffectEnable") + XUiManager.TipText("SpringFestivalConvertItem") + end) +end + +function XUiSpringFestivalSmashEggs:InitHammerBtnGroup() + local hammerBtns = { + self.BtnHammer01, + self.BtnHammer02, + } + self.HammerBtnGroup:Init(hammerBtns, function(index) + self:OnSelectHammer(index) + end) + self.HammerBtnGroup:SelectIndex(self.CurrentSelectHammer) +end + +function XUiSpringFestivalSmashEggs:OnSelectHammer(index) + if index < 0 then + return + end + self:PlayAnimation("GridTipsEnable") + local hammerList = XSpringFestivalActivityConfigs.GetBuffItemsByType(XSpringFestivalActivityConfigs.BuffType.Hammer) + self.CurrentSelectHammer = hammerList[index].Id + self:RefreshBuffEffectPanel() +end + +function XUiSpringFestivalSmashEggs:OnClickBtnSkipAnimation() + self.SkipAnimation = self.BtnSkip:GetToggleState() +end + +function XUiSpringFestivalSmashEggs:OnClickBtnShop() + local skipId = XSpringFestivalActivityConfigs.GetSpringFestivalActivityShopSkipId() + XFunctionManager.SkipInterface(skipId) +end + +function XUiSpringFestivalSmashEggs:Refresh() + self:RefreshPanel() + self:RefreshEgg() +end + +function XUiSpringFestivalSmashEggs:RefreshPanel() + self:RefreshRewardList() + self:RefreshTextInfo() + self:RefreshBuffItemPanel() + self:RefreshBuffEffectPanel() + self:RefreshProtectItem() + self:RefreshHammerCount() + self:RefreshProcessBar() +end + +function XUiSpringFestivalSmashEggs:RefreshTextInfo() + local todayScore = XDataCenter.SpringFestivalActivityManager.GetSmashEggsTodayScore() + if self.TxtDailyActive then + self.TxtDailyActive.text = todayScore + end + + local highestScore = XDataCenter.SpringFestivalActivityManager.GetSmashEggsHighestScore() + if self.TxtIntegralTop then + self.TxtIntegralTop.text = CS.XTextManager.GetText("SpringFestivalSmashEggsHighestScore", highestScore) + end + + local currentScore = XDataCenter.SpringFestivalActivityManager.GetSmashEggsCurrentScore() + if self.TxtIntegral then + self.TxtIntegral.text = currentScore + end +end + +function XUiSpringFestivalSmashEggs:RefreshEgg() + local eggList = XDataCenter.SpringFestivalActivityManager.GetSmashEggsEggList() + local isReborn = true + for i = 1, #eggList do + if not eggList[i].IsBroken then + self:ResetModel(i) + else + self["Model" .. i].gameObject:SetActiveEx(false) + self["BtnSupply" .. i].gameObject:SetActiveEx(true) + end + isReborn = isReborn and eggList[i].IsBroken + end + + if isReborn then + local list = {} + for i = 1, MODEL_COUNT do + tableInsert(list, i - 1) + end + XDataCenter.SpringFestivalActivityManager.SmashEggsResetEggsRequest(list, function() + self:RefreshEgg() + self:PlayRebornAnimation() + end) + end +end + +function XUiSpringFestivalSmashEggs:RefreshProtectItem() + local itemId = XSpringFestivalActivityConfigs.GetBuffItemItemId(XSpringFestivalActivityConfigs.BuffItem.Money) + local itemCount = XDataCenter.ItemManager.GetCount(itemId) + self.BaodiGrid:SetName(itemCount) +end + +function XUiSpringFestivalSmashEggs:RefreshBuffEffectPanel() + local buffList = { + self.CurrentSelectBuffItem, + self.CurrentSafetyProtect + } + local isEmpty = true + for i = 1, #buffList do + local grid = self.BuffEffectGrid[i] + if not grid then + local obj = CS.UnityEngine.Object.Instantiate(self.GridEffect, self.Content) + grid = XUiGridSpringFestivalBuffEffectItem.New(obj) + self.BuffEffectGrid[i] = grid + end + grid:Refresh(buffList[i]) + isEmpty = buffList[i] == 0 and isEmpty + end + self.ImgEmpty.gameObject:SetActiveEx(isEmpty) +end + +function XUiSpringFestivalSmashEggs:InitBuffItemPanel() + local buffItems = XSpringFestivalActivityConfigs.GetBuffItemsByType(XSpringFestivalActivityConfigs.BuffType.Additive) + local defaultSelect = -1 + for i = 1, #buffItems do + local buffItemsButton = self.BuffItemBtn[i] + if not buffItemsButton then + local obj = CS.UnityEngine.Object.Instantiate(self.GridProp, self.PanelProp) + obj.gameObject:SetActiveEx(true) + buffItemsButton = obj:GetComponent("XUiButton") + local itemIcon = XDataCenter.ItemManager.GetItemIcon(buffItems[i].ItemId) + buffItemsButton:SetRawImage(itemIcon) + local itemCount = XDataCenter.ItemManager.GetCount(buffItems[i].ItemId) + buffItemsButton:SetName(itemCount) + tableInsert(self.BuffItemBtn, buffItemsButton) + end + if buffItems[i].Id == self.CurrentSelectBuffItem then + defaultSelect = i + end + end + self.BuffItemBtnGroup:Init(self.BuffItemBtn, function(index) + self:OnSelectBuffItem(index) + end) + if self.BuffItemBtnGroup.CurSelectId ~= defaultSelect then + if defaultSelect == -1 then + self.BuffItemBtnGroup:CancelSelect() + self.CurrentSelectBuffItem = 0 + else + self.BuffItemBtnGroup:SelectIndex(defaultSelect) + end + end +end + +function XUiSpringFestivalSmashEggs:RefreshBuffItemPanel() + local buffItems = XSpringFestivalActivityConfigs.GetBuffItemsByType(XSpringFestivalActivityConfigs.BuffType.Additive) + for i = 1, #self.BuffItemBtn do + local itemCount = XDataCenter.ItemManager.GetCount(buffItems[i].ItemId) + self.BuffItemBtn[i]:SetName(itemCount) + end +end + +function XUiSpringFestivalSmashEggs:RefreshHammerCount() + local silverHammer = XSpringFestivalActivityConfigs.GetBuffItemItemId(XSpringFestivalActivityConfigs.BuffItem.SilverHammer) + local goldHammer = XSpringFestivalActivityConfigs.GetBuffItemItemId(XSpringFestivalActivityConfigs.BuffItem.GoldHammer) + local silverCount = XDataCenter.ItemManager.GetCount(silverHammer) + local goldCount = XDataCenter.ItemManager.GetCount(goldHammer) + self.BtnHammer01:SetNameByGroup(1, silverCount) + self.BtnHammer02:SetNameByGroup(1, goldCount) +end + +function XUiSpringFestivalSmashEggs:RefreshProcessBar() + local today = XDataCenter.SpringFestivalActivityManager.GetSmashEggsTodayScore() + local day = XDataCenter.SpringFestivalActivityManager.GetSmashEggsActivityDay() + local rewardList = XSpringFestivalActivityConfigs.GetSmashRewardTemplateByNowDay(day) + table.sort(rewardList, function(a, b) + return a.Index < b.Index + end) + --分段计算实际进度条,适配不按比例的目标分数 + local process = 0 + local preValue = 0 + for i = 1, #rewardList do + if today <= 0 then + break + end + local offset = rewardList[i].TargetScore - preValue + local pow = 1 / (#rewardList * offset) + if today < offset then + process = process + today * pow + else + process = process + offset * pow + end + preValue = rewardList[i].TargetScore + today = today - offset + end + + self.ImgDailyActiveProgress.fillAmount = process / 1 +end + +function XUiSpringFestivalSmashEggs:OnSelectBuffItem(index) + local buffItems = XSpringFestivalActivityConfigs.GetBuffItemsByType(XSpringFestivalActivityConfigs.BuffType.Additive) + local isSelect = self.BuffItemBtn[index]:GetToggleState() + if isSelect then + self.CurrentSelectBuffItem = buffItems[index].Id + else + self.CurrentSelectBuffItem = 0 + end + self:RefreshBuffEffectPanel() +end + +function XUiSpringFestivalSmashEggs:RefreshRewardList() + local day = XDataCenter.SpringFestivalActivityManager.GetSmashEggsActivityDay() + local rewardList = XSpringFestivalActivityConfigs.GetSmashRewardTemplateByNowDay(day) + table.sort(rewardList, function(a, b) + return a.Index > b.Index + end) + for i = 1, #rewardList do + local grid = self.RewardGrid[i] + if not grid then + local obj = CS.UnityEngine.Object.Instantiate(self.PanelActive, self.PanelGift) + obj.gameObject:SetActiveEx(true) + grid = XUiGridSpringFestivalSmashEggsReward.New(obj, function() + self:RefreshPanel() + end) + self.RewardGrid[i] = grid + end + grid:Refresh(rewardList[i]) + end +end + +function XUiSpringFestivalSmashEggs:PlaySuccessAnimation(index) + local modelAnimator = self["Model" .. index] + local hammerAnimator = self["Hammer" .. self.CurrentSelectHammer] + local faintEffect = self["UIMonsterFaint" .. index] + local successEffect = self["UISuccessed" .. index] + local effect = self["FxUIHammerHit" .. index] + local hongbaoEffect = self["FxHongbao" .. index] + local modelPos = modelAnimator.transform.position + hammerAnimator.transform.position = CS.UnityEngine.Vector3(modelPos.x + HammerPosOffset.x, modelPos.y + HammerPosOffset.y, modelPos.z + HammerPosOffset.z) + XLuaUiManager.SetMask(true) + XScheduleManager.ScheduleOnce(function() + hammerAnimator.gameObject:SetActive(true) + hammerAnimator:Play("Break") + XSoundManager.PlaySoundByType(XSpringFestivalActivityConfigs.SmashSoundId.HammerSuccess,XSoundManager.SoundType.Sound) + XSoundManager.PlaySoundByType(XSpringFestivalActivityConfigs.SmashSoundId.EggSuccess,XSoundManager.SoundType.Sound) + effect:SetActiveEx(true) + end, 100) + XScheduleManager.ScheduleOnce(function() + hammerAnimator.gameObject:SetActive(false) + end,1000) + XScheduleManager.ScheduleOnce(function() + self["BtnSupply" .. index].gameObject:SetActiveEx(true) + XSoundManager.PlaySoundByType(XSpringFestivalActivityConfigs.SmashSoundId.SuccessEffectSound,XSoundManager.SoundType.Sound) + successEffect:SetActiveEx(true) + hongbaoEffect:SetActiveEx(true) + modelAnimator.gameObject:SetActiveEx(false) + end, 3000) + faintEffect:SetActiveEx(true) + modelAnimator:Play("UIFaint") + + XScheduleManager.ScheduleOnce(function() + XLuaUiManager.SetMask(false) + self:RefreshEgg() + end, 4000) +end + +function XUiSpringFestivalSmashEggs:PlayFailAnimation(index) + local modelAnimator = self["Model" .. index] + local hammerAnimator = self["Hammer" .. self.CurrentSelectHammer] + local angryEffect = self["UIMonsterAngry" .. index] + local modelPos = modelAnimator.transform.position + hammerAnimator.transform.position = CS.UnityEngine.Vector3(modelPos.x + HammerPosOffset.x, modelPos.y + HammerPosOffset.y, modelPos.z + HammerPosOffset.z) + XLuaUiManager.SetMask(true) + XScheduleManager.ScheduleOnce(function() + hammerAnimator.gameObject:SetActive(true) + hammerAnimator:Play("Break") + XSoundManager.PlaySoundByType(XSpringFestivalActivityConfigs.SmashSoundId.HammerFail,XSoundManager.SoundType.Sound) + end, 200) + XScheduleManager.ScheduleOnce(function() + hammerAnimator.gameObject:SetActive(false) + end,1000) + XScheduleManager.ScheduleOnce(function() + modelAnimator.gameObject:SetActiveEx(false) + self["BtnSupply" .. index].gameObject:SetActiveEx(true) + end, 3000) + angryEffect:SetActiveEx(true) + modelAnimator:Play("UIGainst") + XSoundManager.PlaySoundByType(XSpringFestivalActivityConfigs.SmashSoundId.EggFail,XSoundManager.SoundType.Sound) + XScheduleManager.ScheduleOnce(function() + XLuaUiManager.SetMask(false) + self:RefreshEgg() + end, 4000) +end + +function XUiSpringFestivalSmashEggs:PlayRebornAnimation() + for i = 1, MODEL_COUNT do + self:ResetModel(i) + end +end + +function XUiSpringFestivalSmashEggs:ResetModel(i) + self["UIMonsterFaint" .. i]:SetActiveEx(false) + self["UIMonsterAngry" .. i]:SetActiveEx(false) + self["UISuccessed" .. i]:SetActiveEx(false) + self["FxUIHammerHit" .. i]:SetActiveEx(false) + self["FxHongbao" .. i]:SetActiveEx(false) + self["Model" .. i].gameObject:SetActiveEx(true) + self["BtnSupply" .. i].gameObject:SetActiveEx(false) +end + +function XUiSpringFestivalSmashEggs:PlaySkipAnimation(index) + self["Model" .. index].gameObject:SetActiveEx(false) + self["BtnSupply" .. index].gameObject:SetActiveEx(true) + self:RefreshEgg() +end + +function XUiSpringFestivalSmashEggs:StartTimer() + if self.Timer then + self:StopTimer() + end + self.Timer = XScheduleManager.ScheduleForever(function() + if XTool.UObjIsNil(self.TxtTime) then + self:StopTimer() + return + end + local currentTime = XTime.GetServerNowTimestamp() + if currentTime > self.EndTime then + XDataCenter.SpringFestivalActivityManager.OnActivityEnd() + return + end + self:RefreshRemainingTime() + end, XScheduleManager.SECOND) +end + +function XUiSpringFestivalSmashEggs:StopTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end + if self.TipTimer then + XScheduleManager.UnSchedule(self.TipTimer) + self.TipTimer = nil + end + if self.RewardTimer then + XScheduleManager.UnSchedule(self.RewardTimer) + self.RewardTimer = nil + end +end + +function XUiSpringFestivalSmashEggs:RefreshRemainingTime() + local endTime = XDataCenter.SpringFestivalActivityManager.GetActivityEndTime() + local startTime = XDataCenter.SpringFestivalActivityManager.GetActivityStartTime() + local now = XTime.GetServerNowTimestamp() + local offset = XMath.Clamp(endTime - now, 0, endTime - startTime) + self.TxtTime.text = XUiHelper.GetTime(offset, XUiHelper.TimeFormatType.ACTIVITY) +end + +function XUiSpringFestivalSmashEggs:CheckItemCount() + local buffCount = self.CurrentSelectBuffItem == 0 and 0 or XDataCenter.ItemManager.GetCount(XSpringFestivalActivityConfigs.GetBuffItemItemId(self.CurrentSelectBuffItem)) + local protectCount = self.CurrentSafetyProtect == 0 and 0 or XDataCenter.ItemManager.GetCount(XSpringFestivalActivityConfigs.GetBuffItemItemId(self.CurrentSafetyProtect)) + local hammerCount = self.CurrentSelectHammer == 0 and 0 or XDataCenter.ItemManager.GetCount(XSpringFestivalActivityConfigs.GetBuffItemItemId(self.CurrentSelectHammer)) + + return (self.CurrentSelectBuffItem == 0 or buffCount > 0) and (self.CurrentSafetyProtect == 0 or protectCount > 0) and (self.CurrentSelectHammer == 0 or + hammerCount > 0) +end + +return XUiSpringFestivalSmashEggs \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSpringFestival/XUiFubenSpringFestivalChapter.lua b/Resources/Scripts/XUi/XUiSpringFestival/XUiFubenSpringFestivalChapter.lua new file mode 100644 index 00000000..5e42118e --- /dev/null +++ b/Resources/Scripts/XUi/XUiSpringFestival/XUiFubenSpringFestivalChapter.lua @@ -0,0 +1,112 @@ +local XUiFubenSpringFestivalChapter = XLuaUiManager.Register(XLuaUi, "UiFubenSpringFestivalChapter") +local XUiPanelFubenSpringFestivalStage = require("XUi/XUiSpringFestival/XUiPanelFubenSpringFestivalStage") +function XUiFubenSpringFestivalChapter:OnStart() + self.Chapter = XDataCenter.FubenFestivalActivityManager.GetFestivalChapterById(XSpringFestivalActivityConfigs.GetSpringFestivalActivityChapterId()) + self.EndTime = XDataCenter.SpringFestivalActivityManager.GetActivityEndTime() + self:Init() +end + +function XUiFubenSpringFestivalChapter:OnEnable() + self:RefreshRemainingTime() + self:StartTimer() + self.StagePanel:Refresh() + XRedPointManager.AddRedPointEvent(self.BtnReward, self.CheckTaskRedPoint, self, { XRedPointConditions.Types.CONDITION_SPRINGFESTIVAL_TASK_RED },XSpringFestivalActivityConfigs.GetSpringFestivalActivityTaskActivityId()) +end + + function XUiFubenSpringFestivalChapter:OnDisable() + self:StopTimer() + end + + function XUiFubenSpringFestivalChapter:OnDestroy() + + end + + function XUiFubenSpringFestivalChapter:Init() + self.PanelAsset = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self:InitChapter() + self:RegisterBtnEvent() + end + + function XUiFubenSpringFestivalChapter:InitChapter() + local chapterGameObject = self.PanelChapter:LoadPrefab(self.Chapter:GetFubenPrefab()) + self.StagePanel = XUiPanelFubenSpringFestivalStage.New(self,chapterGameObject,self.Chapter) +end + +function XUiFubenSpringFestivalChapter:CheckTaskRedPoint(count) + self.BtnReward:ShowReddot(count >= 0) +end + +function XUiFubenSpringFestivalChapter:RegisterBtnEvent() + self.SceneBtnBack.CallBack = function() + self:OnClickBackBtn() + end + self.SceneBtnMainUi.CallBack = function() + self:OnClickMainBtn() + end + self.BtnReward.CallBack = function() + self:OnClickRewardBtn() + end + self.BtnCollectCard.CallBack = function() + self:OnClickCollectCardBtn() + end + self.BtnSmashEggs.CallBack = function() + self:OnClickSmashEggsBtn() + end +end + +function XUiFubenSpringFestivalChapter:OnClickBackBtn() + XLuaUiManager.Close("UiFubenSpringFestivalChapter") +end + +function XUiFubenSpringFestivalChapter:OnClickMainBtn() + XLuaUiManager.RunMain() +end + +function XUiFubenSpringFestivalChapter:OnClickRewardBtn() + XLuaUiManager.Remove("UiFubenSpringFestivalChapter") + local activitySkipId = XSpringFestivalActivityConfigs.GetSpringFestivalActivitySkipId() + XFunctionManager.SkipInterface(activitySkipId) +end + +function XUiFubenSpringFestivalChapter:OnClickCollectCardBtn() + XLuaUiManager.Open("UiSpringFestivalCollectCard") +end + +function XUiFubenSpringFestivalChapter:OnClickSmashEggsBtn() + XLuaUiManager.Open("UiSpringFestivalSmashEggs") +end + +function XUiFubenSpringFestivalChapter:StartTimer() + if self.Timer then + self:StopTimer() + end + self.Timer = XScheduleManager.ScheduleForever(function() + if XTool.UObjIsNil(self.TxtDay) then + self:StopTimer() + return + end + local currentTime = XTime.GetServerNowTimestamp() + if currentTime > self.EndTime then + XDataCenter.SpringFestivalActivityManager.OnActivityEnd() + return + end + self:RefreshRemainingTime() + end,XScheduleManager.SECOND) +end + +function XUiFubenSpringFestivalChapter:StopTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end + +function XUiFubenSpringFestivalChapter:RefreshRemainingTime() + local endTime = XDataCenter.SpringFestivalActivityManager.GetActivityEndTime() + local startTime = XDataCenter.SpringFestivalActivityManager.GetActivityStartTime() + local now = XTime.GetServerNowTimestamp() + local offset = XMath.Clamp(endTime - now,0,endTime-startTime) + self.TxtDay.text = XUiHelper.GetTime(offset,XUiHelper.TimeFormatType.ACTIVITY) +end + +return XUiFubenSpringFestivalChapter \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSpringFestival/XUiFubenSpringFestivalStageDetail.lua b/Resources/Scripts/XUi/XUiSpringFestival/XUiFubenSpringFestivalStageDetail.lua new file mode 100644 index 00000000..49e1e910 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSpringFestival/XUiFubenSpringFestivalStageDetail.lua @@ -0,0 +1,138 @@ +local XUiFubenSpringFestivalStageDetail = XLuaUiManager.Register(XLuaUi, "UiFubenSpringFestivalStageDetail") + +function XUiFubenSpringFestivalStageDetail:OnAwake() + self.StarGridList = {} + self.CommonGridList = {} + self.GridList = {} + + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint) + self:InitStarPanels() + self.BtnEnter.CallBack = function() self:OnBtnEnterClick() end +end + +function XUiFubenSpringFestivalStageDetail:InitStarPanels() + for i = 1, 3 do + self.StarGridList[i] = XUiGridStageStar.New(self[string.format("GridStageStar%d", i)]) + end +end + +function XUiFubenSpringFestivalStageDetail:OnStart(rootUi) + self.RootUi = rootUi +end + +function XUiFubenSpringFestivalStageDetail:SetStageDetail(stageId, festivalId) + local fStage = XDataCenter.FubenFestivalActivityManager.GetFestivalStageByFestivalIdAndStageId(festivalId, stageId) + if not fStage then return end + self.FStage = fStage + local maxChallengeNum = fStage:GetMaxChallengeNum() + local isLimitCount = maxChallengeNum > 0 + self.PanelNums.gameObject:SetActiveEx(isLimitCount) + self.PanelNoLimitCount.gameObject:SetActiveEx(not isLimitCount) + -- 有次数限制 + if isLimitCount then + self.TxtAllNums.text = string.format("/%d", maxChallengeNum) + self.TxtLeftNums.text = maxChallengeNum - fStage:GetPassCount() + end + self.TxtTitle.text = fStage:GetName() + for i = 1, 3 do + self.StarGridList[i]:Refresh(fStage:GetStarDescByIndex(i), fStage:GetStarMapsByIndex(i)) + end + self.ImgCostIcon:SetRawImage(XDataCenter.ItemManager.GetItemIcon(XDataCenter.ItemManager.ItemId.ActionPoint)) + self.TxtATNums.text = fStage:GetRequireActionPoint() + self:UpdateRewards() +end + +function XUiFubenSpringFestivalStageDetail:UpdateRewardTitle(isFirstDrop) + self.TxtDrop.gameObject:SetActive(not isFirstDrop) + self.TxtFirstDrop.gameObject:SetActive(isFirstDrop) +end + +function XUiFubenSpringFestivalStageDetail:UpdateRewards() + if not self.FStage then return end + local rewardId = self.FStage:GetFinishRewardShow() + local IsFirst = false + -- 首通有没有填 + local controlCfg = XDataCenter.FubenManager.GetStageLevelControl(self.FStage:GetStageId()) + -- 有首通 + if not self.FStage:GetIsPass() then + if controlCfg and controlCfg.FirstRewardShow > 0 then + rewardId = controlCfg.FirstRewardShow + IsFirst = true + elseif self.FStage:GetFirstRewardShow() > 0 then + rewardId = self.FStage:GetFirstRewardShow() + IsFirst = true + end + end + -- 没首通 + if not IsFirst then + if controlCfg and controlCfg.FinishRewardShow > 0 then + rewardId = controlCfg.FinishRewardShow + else + rewardId = self.FStage:GetFinishRewardShow() + end + end + self:UpdateRewardTitle(IsFirst) + + local rewards = {} + if rewardId > 0 then + rewards = IsFirst and XRewardManager.GetRewardList(rewardId) or XRewardManager.GetRewardListNotCount(rewardId) + end + + if rewards then + for i, item in ipairs(rewards) do + local grid + if self.GridList[i] then + grid = self.GridList[i] + else + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommon) + grid = XUiGridCommon.New(self, ui) + grid.Transform:SetParent(self.PanelDropContent, false) + self.GridList[i] = grid + end + grid:Refresh(item) + grid.GameObject:SetActive(true) + end + end + + local rewardsCount = 0 + if rewards then + rewardsCount = #rewards + end + + for j = 1, #self.GridList do + if j > rewardsCount then + self.GridList[j].GameObject:SetActive(false) + end + end +end + +function XUiFubenSpringFestivalStageDetail:OnBtnEnterClick() + if not self.FStage then + XLog.Error("XUiFubenSpringFestivalStageDetail:OnBtnEnterClick 函数错误: 关卡信息为空 ") + return + end + local isInTime, tips = self.FStage:GetChapter():GetIsInTimeAndTips() + if not isInTime then + XUiManager.TipMsg(tips) + return + end + local passedCounts = self.FStage:GetPassCount() + local maxChallengeNum = self.FStage:GetMaxChallengeNum() + if maxChallengeNum > 0 and passedCounts >= maxChallengeNum then + XUiManager.TipMsg(CS.XTextManager.GetText("FubenChallengeCountNotEnough")) + return + end + if XDataCenter.FubenManager.CheckPreFight(self.FStage:GetStageCfg()) then + if self.RootUi then + self.RootUi:ClearNodesSelect() + self.RootUi:CloseStageDetails() + end + XLuaUiManager.Open("UiNewRoomSingle", self.FStage:GetStageId()) + end +end + +function XUiFubenSpringFestivalStageDetail:CloseDetailWithAnimation() + self:PlayAnimation("AnimDisableEnd", function() + self:Close() + end) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSpringFestival/XUiPanelFubenSpringFestivalStage.lua b/Resources/Scripts/XUi/XUiSpringFestival/XUiPanelFubenSpringFestivalStage.lua new file mode 100644 index 00000000..3accd9bc --- /dev/null +++ b/Resources/Scripts/XUi/XUiSpringFestival/XUiPanelFubenSpringFestivalStage.lua @@ -0,0 +1,190 @@ +local XUiPanelFubenSpringFestivalStage = XClass(nil, "XUiPanelFubenSpringFestivalStage") +local XUiSpringFestivalStageItem = require("XUi/XUiSpringFestival/XUiSpringFestivalStageItem") +local XUguiDragProxy = CS.XUguiDragProxy + +local FESTIVAL_FIGHT_DETAIL = "UiFubenSpringFestivalStageDetail" +local FESTIVAL_STORY_DETAIL = "UiStorySpringFestivalStageDetail" +function XUiPanelFubenSpringFestivalStage:Ctor(rootUi, transform, chapter) + self.RootUi = rootUi + self.GameObject = transform.gameObject + self.Transform = transform + self.Chapter = chapter + self.StageCount = self.Chapter:GetStageTotalCount() + self.LineCount = self.StageCount - 1 + XTool.InitUiObject(self) + self:InitUi() +end + +function XUiPanelFubenSpringFestivalStage:InitUi() + self.Stages = {} + self.Lines = {} + local stageIds = self.Chapter:GetStageIdList() + for i = 1, self.StageCount do + local itemStage = self.PanelStageContent:Find("Stage" .. i) + self.Stages[i] = XUiSpringFestivalStageItem.New(self, itemStage) + self.Stages[i]:UpdateNode(self.Chapter:GetChapterId(), stageIds[i]) + end + + for i = 1, self.LineCount do + self.Lines[i] = self.PanelStageContent:Find("Line" .. i) + end + + self.BtnCloseDetail.CallBack = function() self:OnBtnCloseDetailClick() end + self:Refresh() +end + +function XUiPanelFubenSpringFestivalStage:Refresh() + local dragProxy = self.PaneStageList:GetComponent(typeof(XUguiDragProxy)) + if not dragProxy then + dragProxy = self.PaneStageList.gameObject:AddComponent(typeof(XUguiDragProxy)) + end + dragProxy:RegisterHandler(handler(self, self.OnDragProxy)) + self.Chapter:RefreshChapterStageInfos() + self:RefreshStages() +end + +function XUiPanelFubenSpringFestivalStage:RefreshStages() + local stageIds = self.Chapter:GetStageIdList() + for i = 1, self.StageCount do + if self.Stages[i] then + self.Stages[i]:UpdateNode(self.Chapter:GetChapterId(), stageIds[i]) + end + end + self:RefreshLines() +end + +function XUiPanelFubenSpringFestivalStage:RefreshLines() + local passCount = self.Chapter:GetStagePassCount() + for i = 1, self.LineCount do + self.Lines[i].gameObject:SetActiveEx(i <= passCount) + end +end + +-- 选中关卡 +function XUiPanelFubenSpringFestivalStage:UpdateNodesSelect(stageId) + local stageIds = self.Chapter:GetStageIdList() + for i = 1, #stageIds do + if self.Stages[i] then + self.Stages[i]:SetNodeSelect(stageIds[i] == stageId) + end + end +end + +-- 取消选中 +function XUiPanelFubenSpringFestivalStage:ClearNodesSelect() + local stageIds = self.Chapter:GetStageIdList() + for i = 1, #stageIds do + if self.Stages[i] then + self.Stages[i]:SetNodeSelect(false) + end + end + self.IsOpenDetails = false +end + +-- 打开剧情,战斗详情 +function XUiPanelFubenSpringFestivalStage:OpenStageDetails(stageId, festivalId) + local fStage = XDataCenter.FubenFestivalActivityManager.GetFestivalStageByFestivalIdAndStageId(festivalId, stageId) + local detailType = XDataCenter.FubenFestivalActivityManager.StageFuben + self.BtnCloseDetail.gameObject:SetActiveEx(true) + if not fStage then + self.IsOpenDetails = true + self.StageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + local stageType = self.StageCfg.StageType + if stageType == XFubenConfigs.STAGETYPE_FIGHT or stageType == XFubenConfigs.STAGETYPE_FIGHTEGG then + detailType = XDataCenter.FubenFestivalActivityManager.StageFuben + elseif stageType == XFubenConfigs.STAGETYPE_STORY or stageType == XFubenConfigs.STAGETYPE_STORYEGG then + detailType = XDataCenter.FubenFestivalActivityManager.StageStory + end + else + self.FStage = fStage + self.IsOpenDetails = true + detailType = self.FStage:GetStageShowType() + end + + if detailType == XDataCenter.FubenFestivalActivityManager.StageFuben then + self.RootUi:OpenOneChildUi(FESTIVAL_FIGHT_DETAIL, self) + self.RootUi:FindChildUiObj(FESTIVAL_FIGHT_DETAIL):SetStageDetail(stageId, festivalId) + if XLuaUiManager.IsUiShow(FESTIVAL_STORY_DETAIL) then + self.RootUi:FindChildUiObj(FESTIVAL_STORY_DETAIL):Close() + end + elseif detailType == XDataCenter.FubenFestivalActivityManager.StageStory then + self.RootUi:OpenOneChildUi(FESTIVAL_STORY_DETAIL, self) + self.RootUi:FindChildUiObj(FESTIVAL_STORY_DETAIL):SetStageDetail(stageId, festivalId) + if XLuaUiManager.IsUiShow(FESTIVAL_FIGHT_DETAIL) then + self.RootUi:FindChildUiObj(FESTIVAL_FIGHT_DETAIL):Close() + end + end + if self.AssetPanel then + self.AssetPanel.GameObject:SetActiveEx(false) + end + self.PanelStageContentRaycast.raycastTarget = false + self.RootUi:PlayAnimation("PanelTitleDisable") +end + +-- 关闭剧情,战斗详情 +function XUiPanelFubenSpringFestivalStage:CloseStageDetails() + self.IsOpenDetails = false + self.BtnCloseDetail.gameObject:SetActiveEx(false) + self.PanelStageContentRaycast.raycastTarget = true + if XLuaUiManager.IsUiShow(FESTIVAL_STORY_DETAIL) then + self.RootUi:FindChildUiObj(FESTIVAL_STORY_DETAIL):CloseDetailWithAnimation() + end + + if XLuaUiManager.IsUiShow(FESTIVAL_FIGHT_DETAIL) then + self.RootUi:FindChildUiObj(FESTIVAL_FIGHT_DETAIL):CloseDetailWithAnimation() + end + self:ClearNodesSelect() + self.PaneStageList.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Elastic + self.RootUi:PlayAnimation("PanelTitleEnable") +end + +function XUiPanelFubenSpringFestivalStage:OnBtnCloseDetailClick() + self:CloseStageDetails() +end + +function XUiPanelFubenSpringFestivalStage:PlayScrollViewMove(gridTransform) + self.PaneStageList.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Unrestricted + local gridRect = gridTransform:GetComponent("RectTransform") + local diffX = gridRect.localPosition.x + self.PanelStageContent.localPosition.x + if diffX < XDataCenter.FubenMainLineManager.UiGridChapterMoveMinX or diffX > XDataCenter.FubenMainLineManager.UiGridChapterMoveMaxX then + local tarPosX = XDataCenter.FubenMainLineManager.UiGridChapterMoveTargetX - gridRect.localPosition.x + local tarPos = self.PanelStageContent.localPosition + tarPos.x = tarPosX + XLuaUiManager.SetMask(true) + XUiHelper.DoMove(self.PanelStageContent, tarPos, XDataCenter.FubenMainLineManager.UiGridChapterMoveDuration, XUiHelper.EaseType.Sin, function() + XLuaUiManager.SetMask(false) + end) + end +end + +function XUiPanelFubenSpringFestivalStage:MoveIntoStage(stageIndex) + local gridRect = self.StageGroup[stageIndex] + local diffX = gridRect.localPosition.x + self.PanelStageContent.localPosition.x + if diffX > CS.XResolutionManager.OriginWidth / 2 then + local tarPosX = (CS.XResolutionManager.OriginWidth / 4) - gridRect.localPosition.x + local tarPos = self.PanelStageContent.localPosition + tarPos.x = tarPosX + XLuaUiManager.SetMask(true) + self.PaneStageList.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Unrestricted + XUiHelper.DoMove(self.PanelStageContent, tarPos, XDataCenter.FubenMainLineManager.UiGridChapterMoveDuration, XUiHelper.EaseType.Sin, function() + XLuaUiManager.SetMask(false) + self.PaneStageList.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Elastic + end) + end +end + +function XUiPanelFubenSpringFestivalStage:EndScrollViewMove() + self.PaneStageList.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Elastic +end + +function XUiPanelFubenSpringFestivalStage:OnDragProxy(dragType) + if self.IsOpenDetails and dragType == 0 then + self:CloseStageDetails() + end +end + +function XUiPanelFubenSpringFestivalStage:ShowPanel(isShow) + self.GameObject:SetActiveEx(isShow) +end + +return XUiPanelFubenSpringFestivalStage \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSpringFestival/XUiSpringFestivalStageItem.lua b/Resources/Scripts/XUi/XUiSpringFestival/XUiSpringFestivalStageItem.lua new file mode 100644 index 00000000..00f4be69 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSpringFestival/XUiSpringFestivalStageItem.lua @@ -0,0 +1,69 @@ +local XUiSpringFestivalStageItem = XClass(nil, "XUiSpringFestivalStageItem") + +function XUiSpringFestivalStageItem:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) +end + +function XUiSpringFestivalStageItem:SetNormalStage() + + if self.IsLock then + self.BtnStage:SetButtonState(CS.UiButtonState.Disable) + else + self.BtnStage:SetButtonState(CS.UiButtonState.Normal) + self.BtnStage:SetRawImage(self.FStage:GetIcon()) + end + self.BtnStage:SetName(self.FStage:GetOrderName()) +end + + +function XUiSpringFestivalStageItem:SetPassStage() + self.ImgFubenEnd.gameObject:SetActiveEx(self.FStage:GetIsPass()) +end + +function XUiSpringFestivalStageItem:UpdateNode(festivalId, stageId) + local fStage = XDataCenter.FubenFestivalActivityManager.GetFestivalStageByFestivalIdAndStageId(festivalId, stageId) + if not fStage then return end + self.FestivalId = festivalId + self.StageId = stageId + self.FStage = fStage + self.FChapter = fStage:GetChapter() + self.StageIndex = fStage:GetOrderIndex() + local stagePrefabName = fStage:GetStagePrefab() + local isOpen, description = self.FStage:GetCanOpen() + self.GameObject:SetActiveEx(isOpen) + local gridGameObject = self.Transform:LoadPrefab(stagePrefabName) + local uiObj = gridGameObject.transform:GetComponent("UiObject") + for i = 0, uiObj.NameList.Count - 1 do + self[uiObj.NameList[i]] = uiObj.ObjList[i] + end + self.BtnStage.CallBack = function() self:OnBtnStageClick() end + self.IsLock = not isOpen + self.Description = description + self:SetNormalStage() + self:SetPassStage() +end + +function XUiSpringFestivalStageItem:OnBtnStageClick() + if self.FStage then + if not self.IsLock then + self.RootUi:UpdateNodesSelect(self.StageId) + -- 打开详细界面 + self.RootUi:OpenStageDetails(self.StageId, self.FestivalId) + self.RootUi:PlayScrollViewMove(self.Transform) + else + XUiManager.TipMsg(self.Description) + end + + end +end + +function XUiSpringFestivalStageItem:SetNodeSelect(isSelect) + if not self.IsLock then + self.BtnStage:SetButtonState(isSelect and CS.UiButtonState.Select or CS.UiButtonState.Normal) + end +end + +return XUiSpringFestivalStageItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSpringFestival/XUiStorySpringFestivalStageDetail.lua b/Resources/Scripts/XUi/XUiSpringFestival/XUiStorySpringFestivalStageDetail.lua new file mode 100644 index 00000000..caad2a0d --- /dev/null +++ b/Resources/Scripts/XUi/XUiSpringFestival/XUiStorySpringFestivalStageDetail.lua @@ -0,0 +1,59 @@ +local XUiStorySpringFestivalStageDetail = XLuaUiManager.Register(XLuaUi, "UiStorySpringFestivalStageDetail") + +function XUiStorySpringFestivalStageDetail:OnAwake() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint) + self.BtnEnter.CallBack = function() self:OnBtnEnterClick() end +end + +function XUiStorySpringFestivalStageDetail:OnStart(rootUi) + self.RootUi = rootUi +end + +function XUiStorySpringFestivalStageDetail:SetStageDetail(stageId, festivalId) + self.StageId = stageId + self.FestivalId = festivalId + local chapterTemplate = XFestivalActivityConfig.GetFestivalById(festivalId) + local stageCfg = XDataCenter.FubenManager.GetStageCfg(self.StageId) + + self.TxtTitle.text = stageCfg.Name + self.TxtStoryDes.text = stageCfg.Description + self.RImgNandu:SetRawImage(chapterTemplate.TitleIcon) + self.RImgTitleBg:SetRawImage(chapterTemplate.TitleBg) +end + +function XUiStorySpringFestivalStageDetail:OnBtnEnterClick() + if not self.StageId then return end + + local stageCfg = XDataCenter.FubenManager.GetStageCfg(self.StageId) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(self.StageId) + if not stageCfg or not stageInfo then return end + + if stageInfo.Passed then + self:PlayStoryId(stageCfg.BeginStoryId, self.StageId) + else + XDataCenter.FubenFestivalActivityManager.FinishStoryRequest(self.StageId, function() + XDataCenter.FubenFestivalActivityManager.RefreshStagePassedBySettleDatas({ StageId = self.StageId }) + self:PlayStoryId(stageCfg.BeginStoryId, self.StageId) + end) + end +end + +function XUiStorySpringFestivalStageDetail:PlayStoryId(movieId) + self.RootUi:ClearNodesSelect() + self.RootUi:ShowPanel(false) + XDataCenter.MovieManager.PlayMovie(movieId, function() + self.RootUi:EndScrollViewMove() + self.RootUi:CloseStageDetails() + self.RootUi:Refresh() + self.RootUi:ShowPanel(true) + end) +end + +function XUiStorySpringFestivalStageDetail:CloseDetailWithAnimation() + self:PlayAnimation("AnimDisableEnd", function() + self:Close() + end) +end + +function XUiStorySpringFestivalStageDetail:OnDestroy() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiStoryStageDetail/XUiStoryStageDetail.lua b/Resources/Scripts/XUi/XUiStoryStageDetail/XUiStoryStageDetail.lua new file mode 100644 index 00000000..cc768aae --- /dev/null +++ b/Resources/Scripts/XUi/XUiStoryStageDetail/XUiStoryStageDetail.lua @@ -0,0 +1,62 @@ +local XUiStoryStageDetail = XLuaUiManager.Register(XLuaUi, "UiStoryStageDetail") + +function XUiStoryStageDetail:OnAwake() + self:InitAutoScript() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) +end + +function XUiStoryStageDetail:OnStart(rootUi) + self.RootUi = rootUi +end + +function XUiStoryStageDetail:OnEnable() + self:Refresh() +end + +function XUiStoryStageDetail:Refresh() + local stageCfg = self.RootUi.Stage + local stageId = stageCfg.StageId + local chapterOrderId = XDataCenter.FubenMainLineManager.GetChapterOrderIdByStageId(stageId) + + self.TxtTitle.text = chapterOrderId .. "-" .. stageCfg.OrderId .. " " .. stageCfg.Name + self.TxtStoryDes.text = stageCfg.Description + if stageCfg.Icon then + self.RImgNandu:SetRawImage(stageCfg.Icon) + end + if stageCfg.StoryIcon then + self.RImgTitleBg:SetRawImage(stageCfg.StoryIcon) + end +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiStoryStageDetail:InitAutoScript() + self:AutoAddListener() +end + +function XUiStoryStageDetail:AutoAddListener() + self.BtnEnter.CallBack = function() + self:OnBtnEnterClick() + end +end +-- auto +function XUiStoryStageDetail:OnBtnEnterClick() + local stageCfg = self.RootUi.Stage + local stageId = stageCfg.StageId + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + self:Hide() + if stageInfo.Passed then + XDataCenter.MovieManager.PlayMovie(stageCfg.BeginStoryId) + else + XDataCenter.FubenManager.FinishStoryRequest(stageId, function() + XDataCenter.MovieManager.PlayMovie(stageCfg.BeginStoryId, function() + self.RootUi:RefreshForChangeDiff() + end) + end) + end +end + +function XUiStoryStageDetail:Hide() + self:Close() + CsXGameEventManager.Instance:Notify(XEventId.EVENT_FUBEN_CLOSE_FUBENSTAGEDETAIL) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiStronghold/XUiGridQuickDeployMember.lua b/Resources/Scripts/XUi/XUiStronghold/XUiGridQuickDeployMember.lua new file mode 100644 index 00000000..f793e160 --- /dev/null +++ b/Resources/Scripts/XUi/XUiStronghold/XUiGridQuickDeployMember.lua @@ -0,0 +1,83 @@ +local MEMBER_POS_COLOR = { + "FF1111FF", -- red + "4F99FFFF", -- blue + "F9CB35FF", -- yellow +} + +local XUiGridQuickDeployMember = XClass(nil, "XUiGridQuickDeployMember") + +function XUiGridQuickDeployMember:Ctor(ui, clickCb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.ClickCb = clickCb + + XTool.InitUiObject(self) + self:InitComponent() +end + +function XUiGridQuickDeployMember:InitComponent() + self.RImgRole.gameObject:SetActiveEx(false) + self.ImgLeader.gameObject:SetActiveEx(false) + self.ImgFirstRole.gameObject:SetActiveEx(false) + self.ImgAbility.gameObject:SetActiveEx(false) + self.ImgSelect.gameObject:SetActiveEx(false) + self.PanelEffect.gameObject:SetActiveEx(false) + self.BtnMember.CallBack = function() self:OnMemberClick() end +end + +function XUiGridQuickDeployMember:Refresh(teamList, teamId, memberIndex) + self.MemberIndex = memberIndex + self.TeamList = teamList + self.TeamId = teamId + + local color = XUiHelper.Hexcolor2Color(MEMBER_POS_COLOR[self.MemberIndex]) + self.ImgLeftSkill.color = color + self.ImgRightSkill.color = color + + local member = self:GetMember() + if not member:IsEmpty() then + local characterId = member:GetShowCharacterId() + self.RImgRole.gameObject:SetActiveEx(true) + self.RImgRole:SetRawImage(XDataCenter.CharacterManager.GetCharSmallHeadIcon(characterId)) + else + self.RImgRole.gameObject:SetActiveEx(false) + end + + self.PanelEffect.gameObject:SetActiveEx(false) + + self.TryTag.gameObject:SetActiveEx(member:IsRobot()) +end + +function XUiGridQuickDeployMember:OnMemberClick() + if self.ClickCb then + self.ClickCb(self, self.MemberIndex) + end +end + +function XUiGridQuickDeployMember:ShowEffect() + self.PanelEffect.gameObject:SetActiveEx(false) + self.PanelEffect.gameObject:SetActiveEx(true) +end + +function XUiGridQuickDeployMember:SetSelect(value) + self.ImgSelect.gameObject:SetActiveEx(value) +end + +function XUiGridQuickDeployMember:RefreshCaptainPos(captainPos) + self.ImgLeader.gameObject:SetActiveEx(self.MemberIndex == captainPos) +end + +function XUiGridQuickDeployMember:RefreshFirstFightPos(firstFightPos) + self.ImgFirstRole.gameObject:SetActiveEx(self.MemberIndex == firstFightPos) +end + +function XUiGridQuickDeployMember:GetTeam() + return self.TeamList[self.TeamId] +end + +function XUiGridQuickDeployMember:GetMember() + local team = self:GetTeam() + return team:GetMember(self.MemberIndex) +end + +return XUiGridQuickDeployMember \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiStronghold/XUiGridQuickDeployTeam.lua b/Resources/Scripts/XUi/XUiStronghold/XUiGridQuickDeployTeam.lua new file mode 100644 index 00000000..74582869 --- /dev/null +++ b/Resources/Scripts/XUi/XUiStronghold/XUiGridQuickDeployTeam.lua @@ -0,0 +1,121 @@ +local XUiGridQuickDeployMember = require("XUi/XUiStronghold/XUiGridQuickDeployMember") + +local CsXTextManagerGetText = CsXTextManagerGetText +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate + +local XUiGridQuickDeployTeam = XClass(nil, "XUiGridQuickDeployTeam") + +function XUiGridQuickDeployTeam:Ctor(ui, memberClickCb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.MemberGridList = {} + self.MemberClickCb = memberClickCb + + XTool.InitUiObject(self) + self.TabGroup = { + self.BtnRed, + self.BtnBlue, + self.BtnYellow, + } + self.PanelTabFirst:Init(self.TabGroup, function(tabIndex) self:OnClickTabCallBack(tabIndex) end) + + self.TabGroupCT = { + self.BtnCaptainRed, + self.BtnCaptainBlue, + self.BtnCaptainYellow, + } + self.PanelTabCaptain:Init(self.TabGroupCT, function(tabIndex) self:OnClickTabCallBackCT(tabIndex) end) + + self.GridTeamMember.gameObject:SetActiveEx(false) +end + +function XUiGridQuickDeployTeam:Refresh(teamList, teamId, groupId) + self.TeamList = teamList + self.TeamId = teamId + local team = self:GetTeam() + + self.TextTitle.text = CsXTextManagerGetText("StrongholdTeamTitle", teamId) + + local gridList = self.MemberGridList + local requireTeamMemberNum = XStrongholdConfigs.GetGroupRequireTeamMemberNum(groupId, teamId) + for memberIndex = 1, requireTeamMemberNum do + local grid = gridList[memberIndex] + if not grid then + local go = CSUnityEngineObjectInstantiate(self.GridTeamMember, self.PanelRole) + local clickCb = function(paramGrid, paramMemberIndex) + self.MemberClickCb(paramGrid, paramMemberIndex, self.TeamId) + end + + grid = XUiGridQuickDeployMember.New(go, clickCb) + gridList[memberIndex] = grid + end + + grid:Refresh(teamList, teamId, memberIndex) + + local captainPos = team:GetCaptainPos() + grid:RefreshCaptainPos(captainPos) + + --蓝色放到第一位 + if memberIndex == 2 then + grid.Transform:SetAsFirstSibling() + end + + grid.GameObject:SetActiveEx(true) + + end + + for index, tabBtn in pairs(self.TabGroup) do + tabBtn.gameObject:SetActiveEx(index <= requireTeamMemberNum) + end + local firstFightPos = team:GetFirstPos() + self.PanelTabFirst:SelectIndex(firstFightPos) + + for index, tabBtn in pairs(self.TabGroupCT) do + tabBtn.gameObject:SetActiveEx(index <= requireTeamMemberNum) + end + local captainPos = team:GetCaptainPos() + self.PanelTabCaptain:SelectIndex(captainPos) + + local isFinished = XDataCenter.StrongholdManager.IsGroupStageFinished(groupId, teamId) + self.TagDis.gameObject:SetActiveEx(isFinished) +end + +function XUiGridQuickDeployTeam:OnClickTabCallBack(firstFightPos) + if self.SelectedIndex and self.SelectedIndex == firstFightPos then + return + end + self.SelectedIndex = firstFightPos + + local team = self:GetTeam() + team:SetFirstPos(firstFightPos) + + local gridList = self.MemberGridList + local gridNum = #gridList + for index = 1, gridNum do + local grid = gridList[index] + grid:RefreshFirstFightPos(firstFightPos) + end +end + +function XUiGridQuickDeployTeam:OnClickTabCallBackCT(captainPos) + if self.SelectedIndexCT and self.SelectedIndexCT == captainPos then + return + end + self.SelectedIndexCT = captainPos + + local team = self:GetTeam() + team:SetCaptainPos(captainPos) + + local gridList = self.MemberGridList + local gridNum = #gridList + for index = 1, gridNum do + local grid = gridList[index] + grid:RefreshCaptainPos(captainPos) + end +end + +function XUiGridQuickDeployTeam:GetTeam() + return self.TeamList[self.TeamId] +end + +return XUiGridQuickDeployTeam \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiStronghold/XUiGridRewardLine.lua b/Resources/Scripts/XUi/XUiStronghold/XUiGridRewardLine.lua new file mode 100644 index 00000000..eab54303 --- /dev/null +++ b/Resources/Scripts/XUi/XUiStronghold/XUiGridRewardLine.lua @@ -0,0 +1,45 @@ +local XUiGridRewardLine = XClass(nil, "XUiGridRewardLine") + +function XUiGridRewardLine:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.GridReward.gameObject:SetActiveEx(false) + self.RewardGrids = {} +end + +function XUiGridRewardLine:InitRootUi(rootUi) + self.RootUi = rootUi +end + +--[[ [MessagePackObject(keyAsPropertyName: true)] +public class StrongholdFightResultInfo +{ + public int GroupId; + public List RewardGoodsList; +} +]] +function XUiGridRewardLine:Refresh(info) + local groupId = info.GroupId + self.TxtOrder.text = XStrongholdConfigs.GetGroupOrder(groupId) + + local rewardGoodsList = info.RewardGoodsList or {} + local rewards = XRewardManager.MergeAndSortRewardGoodsList(rewardGoodsList) + for idx, item in ipairs(rewards) do + local grid = self.RewardGrids[idx] + if not grid then + local ui = CS.UnityEngine.Object.Instantiate(self.GridReward) + grid = XUiGridCommon.New(self.RootUi, ui) + grid.Transform:SetParent(self.PanelRewardContent, false) + grid.GameObject:SetActiveEx(true) + self.RewardGrids[idx] = grid + end + grid:Refresh(item, nil, nil, true) + end + + for i = #rewards + 1, #self.RewardGrids do + self.RewardGrids[i].GameObject:SetActiveEx(false) + end +end + +return XUiGridRewardLine \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiStronghold/XUiGridStrongHoldTeamMember.lua b/Resources/Scripts/XUi/XUiStronghold/XUiGridStrongHoldTeamMember.lua new file mode 100644 index 00000000..ee0e5dd2 --- /dev/null +++ b/Resources/Scripts/XUi/XUiStronghold/XUiGridStrongHoldTeamMember.lua @@ -0,0 +1,80 @@ +local XUiGridStrongHoldTeamMember = XClass(nil, "XUiGridStrongHoldTeamMember") + +local CONDITION_COLOR = { + [true] = CS.UnityEngine.Color.white, + [false] = CS.UnityEngine.Color.red, +} + +--位置对应的颜色框 +local MEMBER_POS_COLOR = { + [1] = "ImgRed", + [2] = "ImgBlue", + [3] = "ImgYellow", +} + +function XUiGridStrongHoldTeamMember:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + + self.BtnClick.CallBack = function() self:OnMemberClick() end +end + +function XUiGridStrongHoldTeamMember:Refresh(teamList, teamId, index, groupId) + self.TeamList = teamList + self.TeamId = teamId + self.MemberIndex = index + self.GroupId = groupId + + local team = teamList[teamId] + + local leaderIndex = team:GetCaptainPos() + self.ImgLeaderTag.gameObject:SetActiveEx(index == leaderIndex) + + local firstFightIndex = team:GetFirstPos() + self.ImgFirstRole.gameObject:SetActiveEx(index == firstFightIndex) + + for i, goName in pairs(MEMBER_POS_COLOR) do + self[goName].gameObject:SetActiveEx(index == i) + end + + local member = team:GetMember(index) + + local isEmpty = member:IsEmpty() + self.PanelEmpty.gameObject:SetActiveEx(isEmpty) + self.PanelNotEmpty.gameObject:SetActiveEx(not isEmpty) + + local isAssitant = member:IsAssitant() + self.PanelHelp.gameObject:SetActiveEx(isAssitant) + + local isRobot = member:IsRobot() + self.PanelTrial.gameObject:SetActiveEx(isRobot) + + local ability = team:GetTeamMemberAbility(self.MemberIndex) + self.TxtAbility.text = ability + if groupId then + local requireAbility = XDataCenter.StrongholdManager.GetGroupRequireAbility(groupId) + self.TxtAbility.color = CONDITION_COLOR[ability >= requireAbility] + end + + if not isEmpty then + local headIcon = member:GetSmallHeadIcon() + self.RImgRoleHead:SetRawImage(headIcon) + end + self.RImgRoleHead.gameObject:SetActiveEx(not isEmpty) +end + +function XUiGridStrongHoldTeamMember:OnMemberClick() + local cb = function() + XLuaUiManager.Open("UiStrongholdRoomCharacter", self.TeamList, self.TeamId, self.MemberIndex, self.GroupId) + end + + if XDataCenter.StrongholdManager.CheckAssitantListWaitInit() then + XDataCenter.StrongholdManager.GetStrongholdAssistCharacterListRequest(cb) + else + cb() + end +end + +return XUiGridStrongHoldTeamMember \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiStronghold/XUiGridStrongholdBanner.lua b/Resources/Scripts/XUi/XUiStronghold/XUiGridStrongholdBanner.lua new file mode 100644 index 00000000..e250dff3 --- /dev/null +++ b/Resources/Scripts/XUi/XUiStronghold/XUiGridStrongholdBanner.lua @@ -0,0 +1,31 @@ +local CsXTextManagerGetText = CsXTextManagerGetText + +local XUiGridStrongholdBanner = XClass(nil, "XUiGridStrongholdBanner") + +function XUiGridStrongholdBanner:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) +end + +function XUiGridStrongholdBanner:Refresh(chapterId) + local icon = XStrongholdConfigs.GetChapterBg(chapterId) + self.RImgDz:SetRawImage(icon) + + local name = XStrongholdConfigs.GetChapterName(chapterId) + self.TxtName.text = name + + local finishCount, totalCount = XDataCenter.StrongholdManager.GetChapterGroupProgress(chapterId) + self.TxtProgress.text = CsXTextManagerGetText("StrongholdChapterProgress", finishCount, totalCount) + + local isUnlock, conditionDes = XDataCenter.StrongholdManager.CheckChapterUnlock(chapterId) + if isUnlock then + self.Imglock.gameObject:SetActiveEx(false) + else + self.TxtUnlockCondition.text = conditionDes + self.Imglock.gameObject:SetActiveEx(true) + end +end + +return XUiGridStrongholdBanner \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiStronghold/XUiGridStrongholdBuff.lua b/Resources/Scripts/XUi/XUiStronghold/XUiGridStrongholdBuff.lua new file mode 100644 index 00000000..d4df0a9b --- /dev/null +++ b/Resources/Scripts/XUi/XUiStronghold/XUiGridStrongholdBuff.lua @@ -0,0 +1,81 @@ +local handler = handler + +local XUiGridStrongholdBuff = XClass(nil, "XUiGridStrongholdBuff") + +function XUiGridStrongholdBuff:Ctor(ui, hideClick, skipCb, openSkillDetailsCb, closeSkillDetailsCb, isClickBtnUseDialog) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + + self.SkipCb = skipCb + self.OpenSkillDetailsCb = openSkillDetailsCb --开启技能说明界面回调 + self.CloseSkillDetailsCb = closeSkillDetailsCb --关闭技能说明界面回调 + self.IsClickBtnUseDialog = isClickBtnUseDialog --开启技能说明界面时是否使用Dialog的界面类型 + + self:SetDisable(false) + + if self.BtnClick then + self.BtnClick.CallBack = handler(self, self.OnClickBtnClick) + end + + if hideClick then + self.BtnClick.gameObject:SetActiveEx(false) + end + + if self.Effect then + self.Effect.gameObject:SetActiveEx(false) + end +end + +--isBossBuff为true时条件取反,即满足条件后设置为关闭 +function XUiGridStrongholdBuff:Refresh(buffId, isBossBuff) + self.BuffId = buffId + + if self.RImgIconBuff1 then + local icon = XStrongholdConfigs.GetBuffIcon(buffId) + self.RImgIconBuff1:SetRawImage(icon) + end + + if self.RImgIconBuff2 then + local icon = XStrongholdConfigs.GetBuffIcon(buffId) + self.RImgIconBuff2:SetRawImage(icon) + end + + local isBuffActive = XDataCenter.StrongholdManager.CheckBuffActive(buffId, isBossBuff) + self:SetDisable(not isBuffActive) + + if self.Effect then + self.Effect.gameObject:SetActiveEx(false) + + if self.OldIsActive ~= nil then + if self.OldIsActive ~= isBuffActive then + XScheduleManager.ScheduleOnce(function() + if XTool.UObjIsNil(self.Effect) then return end + self.Effect.gameObject:SetActiveEx(true) + end, 0.5 * XScheduleManager.SECOND) + end + end + self.OldIsActive = isBuffActive + end +end + +function XUiGridStrongholdBuff:SetDisable(value) + if self.BuffDisable then + self.BuffDisable.gameObject:SetActiveEx(value) + end + + if self.BuffNormal then + self.BuffNormal.gameObject:SetActiveEx(not value) + end +end + +function XUiGridStrongholdBuff:OnClickBtnClick() + if self.OpenSkillDetailsCb then + self.OpenSkillDetailsCb() + end + local uiName = self.IsClickBtnUseDialog and "UiStrongholdSkillDetailsDialog" or "UiStrongholdSkillDetails" + XLuaUiManager.Open(uiName, self.BuffId, self.SkipCb, self.CloseSkillDetailsCb) +end + +return XUiGridStrongholdBuff \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiStronghold/XUiGridStrongholdCharacter.lua b/Resources/Scripts/XUi/XUiStronghold/XUiGridStrongholdCharacter.lua new file mode 100644 index 00000000..c008e568 --- /dev/null +++ b/Resources/Scripts/XUi/XUiStronghold/XUiGridStrongholdCharacter.lua @@ -0,0 +1,270 @@ +local mathFloor = math.floor +local IsNumberValid = XTool.IsNumberValid +local CsXTextManagerGetText = CsXTextManagerGetText + +local XUiGridStrongholdCharacter = XClass(nil, "XUiGridStrongholdCharacter") + +function XUiGridStrongholdCharacter:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + + self:SetSelect(false) +end + +function XUiGridStrongholdCharacter:Refresh(characterId, groupId, teamId, teamList, playerId) + self.CharacterId = characterId + self.GroupId = groupId + self.TeamId = teamId + self.TeamList = teamList + self.PlayerId = playerId + + if XRobotManager.CheckIsRobotId(characterId) then + self:UpdateRobot() + elseif IsNumberValid(playerId) then + self:UpdateAssistant() + else + self:UpdateCharacter() + end +end + +function XUiGridStrongholdCharacter:UpdateRobot() + local teamList = self.TeamList + local groupId = self.GroupId + local robotId = self.CharacterId + local robotTemplate = XRobotManager.GetRobotTemplate(robotId) + local characterId = XRobotManager.GetCharacterId(robotId) + + if self.PanelCharElement then + local detailConfig = XCharacterConfigs.GetCharDetailTemplate(characterId) + local elementList = detailConfig.ObtainElementList + for i = 1, 3 do + local rImg = self["RImgCharElement" .. i] + if elementList[i] then + rImg.gameObject:SetActiveEx(true) + local elementConfig = XCharacterConfigs.GetCharElement(elementList[i]) + rImg:SetRawImage(elementConfig.Icon) + else + rImg.gameObject:SetActiveEx(false) + end + end + end + + if self.RImgHeadIcon then + local head = XDataCenter.CharacterManager.GetCharSmallHeadIcon(characterId, robotTemplate.LiberateLv, true) + self.RImgHeadIcon:SetRawImage(head) + end + + if self.TxtLevel then + local level = robotTemplate.CharacterLevel + self.TxtLevel.text = level + end + + if self.PanelFight then + local ability = XRobotManager.GetRobotAbility(robotId) + self.TxtFight.text = mathFloor(ability) + self.PanelFight.gameObject:SetActiveEx(true) + end + + if self.RImgQuality then + local quality = XCharacterConfigs.GetCharacterQualityIcon(robotTemplate.CharacterQuality) + self.RImgQuality:SetRawImage(quality) + end + + local isInTeam = XDataCenter.StrongholdManager.CheckInTeamList(robotId, teamList) + local isInTeamLock = XDataCenter.StrongholdManager.CheckInTeamListLock(groupId, robotId, teamList) + if self.ImgInTeam then + local showInTeam = not isInTeamLock and isInTeam + if showInTeam then + local oldTeamId = XDataCenter.StrongholdManager.GetCharacterInTeamId(robotId, teamList) + self.TxtInTeam.text = CsXTextManagerGetText("StrongholdTeamIndex", oldTeamId) + self.ImgInTeam.gameObject:SetActiveEx(true) + else + self.ImgInTeam.gameObject:SetActiveEx(false) + end + end + if self.PanelInTeamLock then + self.PanelInTeamLock.gameObject:SetActiveEx(isInTeamLock) + end + + if self.PanelTeamSupport then + self.PanelTeamSupport.gameObject:SetActiveEx(false) + end + + if self.PanelTry then + self.PanelTry.gameObject:SetActiveEx(true) + end + + if self.PanelRecommend then + local stageId = groupId and XDataCenter.StrongholdManager.GetGroupStageId(groupId, self.TeamId) or nil + local isStageRecomend = XFubenConfigs.IsStageRecommendCharacterType(stageId, characterId) + self.PanelRecommend.gameObject:SetActiveEx(isStageRecomend) + end +end + +function XUiGridStrongholdCharacter:UpdateAssistant() + local teamList = self.TeamList + local groupId = self.GroupId + local playerId = self.PlayerId + local assistantInfo = XDataCenter.StrongholdManager.GetAssistantInfo(playerId) + local character = assistantInfo.Character + local characterId = character.Id + + if self.TxtPlayerName then + self.TxtPlayerName.text = assistantInfo.Name or "" + end + + if self.PanelCharElement then + local detailConfig = XCharacterConfigs.GetCharDetailTemplate(characterId) + local elementList = detailConfig.ObtainElementList + for i = 1, 3 do + local rImg = self["RImgCharElement" .. i] + if elementList[i] then + rImg.gameObject:SetActiveEx(true) + local elementConfig = XCharacterConfigs.GetCharElement(elementList[i]) + rImg:SetRawImage(elementConfig.Icon) + else + rImg.gameObject:SetActiveEx(false) + end + end + end + + if self.RImgHeadIcon then + local head = XDataCenter.CharacterManager.GetCharSmallHeadIcon(characterId, character.LiberateLv, true) + self.RImgHeadIcon:SetRawImage(head) + end + + if self.TxtLevel then + local level = character.Level + self.TxtLevel.text = level + end + + if self.PanelFight then + local ability = character.Ability + self.TxtFight.text = mathFloor(ability) + self.PanelFight.gameObject:SetActiveEx(true) + end + + if self.RImgQuality then + self.RImgQuality:SetRawImage(XCharacterConfigs.GetCharacterQualityIcon(character.Quality)) + end + + local isInTeam = XDataCenter.StrongholdManager.CheckInTeamList(characterId, teamList, playerId) + local isInTeamLock = XDataCenter.StrongholdManager.CheckInTeamListLock(groupId, characterId, teamList, playerId) + if self.ImgInTeam then + local showInTeam = not isInTeamLock and isInTeam + if showInTeam then + local oldTeamId = XDataCenter.StrongholdManager.GetCharacterInTeamId(characterId, teamList, playerId) + self.TxtInTeam.text = CsXTextManagerGetText("StrongholdTeamIndex", oldTeamId) + self.ImgInTeam.gameObject:SetActiveEx(true) + else + self.ImgInTeam.gameObject:SetActiveEx(false) + end + end + if self.PanelInTeamLock then + self.PanelInTeamLock.gameObject:SetActiveEx(isInTeamLock) + end + + if self.PanelTeamSupport then + self.PanelTeamSupport.gameObject:SetActiveEx(false) + end + + if self.PanelTry then + self.PanelTry.gameObject:SetActiveEx(true) + end + + if self.PanelRecommend then + local stageId = groupId and XDataCenter.StrongholdManager.GetGroupStageId(groupId, self.TeamId) or nil + local isStageRecomend = XFubenConfigs.IsStageRecommendCharacterType(stageId, characterId) + self.PanelRecommend.gameObject:SetActiveEx(isStageRecomend) + end +end + +function XUiGridStrongholdCharacter:UpdateCharacter() + local teamId = self.TeamId + local teamList = self.TeamList + local groupId = self.GroupId + local characterId = self.CharacterId + local character = XDataCenter.CharacterManager.GetCharacter(characterId) + + if self.PanelCharElement then + local detailConfig = XCharacterConfigs.GetCharDetailTemplate(characterId) + local elementList = detailConfig.ObtainElementList + for i = 1, 3 do + local rImg = self["RImgCharElement" .. i] + if elementList[i] then + rImg.gameObject:SetActiveEx(true) + local elementConfig = XCharacterConfigs.GetCharElement(elementList[i]) + rImg:SetRawImage(elementConfig.Icon) + else + rImg.gameObject:SetActiveEx(false) + end + end + end + + if self.RImgHeadIcon then + self.RImgHeadIcon:SetRawImage(XDataCenter.CharacterManager.GetCharSmallHeadIcon(characterId)) + end + + if self.TxtLevel then + self.TxtLevel.text = character.Level + end + + if self.PanelFight then + self.PanelFight.gameObject:SetActiveEx(true) + local ability = XDataCenter.CharacterManager.GetCharacterAbilityById(characterId) + self.TxtFight.text = mathFloor(ability) + end + + if self.RImgQuality then + self.RImgQuality:SetRawImage(XCharacterConfigs.GetCharacterQualityIcon(character.Quality)) + end + + local isInTeam = XDataCenter.StrongholdManager.CheckInTeamList(characterId, teamList) + local isInTeamLock = XDataCenter.StrongholdManager.CheckInTeamListLock(groupId, characterId, teamList) + if self.ImgInTeam then + local showInTeam = not isInTeamLock and isInTeam + if showInTeam then + local oldTeamId, oldTeamPos = XDataCenter.StrongholdManager.GetCharacterInTeamId(characterId, teamList) + local desc = CsXTextManagerGetText("StrongholdTeamIndex", oldTeamId) + if IsNumberValid(groupId) then + local requireTeamMemberDic = XDataCenter.StrongholdManager.GetGroupRequireTeamMemberDic(groupId) + local memberNum = requireTeamMemberDic[teamId] + if memberNum < oldTeamPos and oldTeamId == teamId then + desc = CsXTextManagerGetText("StrongholdGridInPrefab") + end + end + self.TxtInTeam.text = desc + self.ImgInTeam.gameObject:SetActiveEx(true) + else + self.ImgInTeam.gameObject:SetActiveEx(false) + end + end + if self.PanelInTeamLock then + self.PanelInTeamLock.gameObject:SetActiveEx(isInTeamLock) + end + + if self.PanelTeamSupport then + local IsElectric = XDataCenter.StrongholdManager.CheckInElectricTeam(characterId) + self.PanelTeamSupport.gameObject:SetActiveEx(IsElectric) + end + + if self.PanelTry then + self.PanelTry.gameObject:SetActiveEx(false) + end + + if self.PanelRecommend then + local stageId = groupId and XDataCenter.StrongholdManager.GetGroupStageId(groupId, self.TeamId) or nil + local isStageRecomend = XFubenConfigs.IsStageRecommendCharacterType(stageId, characterId) + self.PanelRecommend.gameObject:SetActiveEx(isStageRecomend) + end +end + +function XUiGridStrongholdCharacter:SetSelect(value) + if self.PanelSelected then + self.PanelSelected.gameObject:SetActiveEx(value) + end +end + +return XUiGridStrongholdCharacter \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiStronghold/XUiGridStrongholdGroup.lua b/Resources/Scripts/XUi/XUiStronghold/XUiGridStrongholdGroup.lua new file mode 100644 index 00000000..723e93ca --- /dev/null +++ b/Resources/Scripts/XUi/XUiStronghold/XUiGridStrongholdGroup.lua @@ -0,0 +1,107 @@ +local XUiGridStrongholdBuff = require("XUi/XUiStronghold/XUiGridStrongholdBuff") + +local handler = handler +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate + +local XUiGridStrongholdGroup = XClass(nil, "XUiGridStrongholdGroup") + +function XUiGridStrongholdGroup:Ctor(ui, index, clickStageCb, skipCb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.BuffGrids = {} + self.Index = index + self.ClickStageCb = clickStageCb + self.SkipCb = skipCb + + XTool.InitUiObject(self) + + self:SetSelect(false) + + if self.BtnClick then self.BtnClick.CallBack = handler(self, self.OnClickBtnClick) end +end + +function XUiGridStrongholdGroup:Refresh(groupId) + self.GroupId = groupId + + if self.RImgBg then + local icon = XStrongholdConfigs.GetGroupIconBg(groupId) + if icon then + self.RImgBg:SetRawImage(icon) + end + end + + if self.RImgBossIcon then + local icon = XStrongholdConfigs.GetGroupIconBoss(groupId) + if icon then + self.RImgBossIcon:SetRawImage(icon) + end + end + + if self.TxtName then + local name = XStrongholdConfigs.GetGroupName(groupId) + self.TxtName.text = name + end + + if self.TxtOrder then + local name = XStrongholdConfigs.GetGroupOrder(groupId) + self.TxtOrder.text = name + end + + if self.TxtStageNum then + local stageNum = XDataCenter.StrongholdManager.GetGroupStageNum(groupId) + self.TxtStageNum.text = "x" .. stageNum + end + + if self.CommonFuBenClear then + local isFinished = XDataCenter.StrongholdManager.IsGroupFinished(groupId) + self.CommonFuBenClear.gameObject:SetActiveEx(isFinished) + end + + if self.PanelBuff then + self:RefreshBuffs() + end +end + +function XUiGridStrongholdGroup:RefreshBuffs() + local groupId = self.GroupId + + local buffIds = XDataCenter.StrongholdManager.GetGroupBossBuffIds(groupId) + if self.PanelBuff.gameObject then + self.PanelBuff.gameObject:SetActiveEx(#buffIds > 0) + end + + local isBossBuff = true + for index, buffId in ipairs(buffIds) do + local grid = self.BuffGrids[index] + if not grid then + local go = index == 1 and self.GridBuff or CSUnityEngineObjectInstantiate(self.GridBuff, self.PanelBuff) + grid = XUiGridStrongholdBuff.New(go, nil, self.SkipCb) + self.BuffGrids[index] = grid + end + + local showEffect = true + + + grid:Refresh(buffId, isBossBuff, showEffect) + grid.GameObject:SetActiveEx(true) + end + + for index = #buffIds + 1, #self.BuffGrids do + local grid = self.BuffGrids[index] + if grid then + grid.GameObject:SetActiveEx(false) + end + end +end + +function XUiGridStrongholdGroup:SetSelect(value) + if self.ImgSelect then + self.ImgSelect.gameObject:SetActiveEx(value) + end +end + +function XUiGridStrongholdGroup:OnClickBtnClick() + if self.ClickStageCb then self.ClickStageCb(self.Index) end +end + +return XUiGridStrongholdGroup \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiStronghold/XUiGridStrongholdPlugin.lua b/Resources/Scripts/XUi/XUiStronghold/XUiGridStrongholdPlugin.lua new file mode 100644 index 00000000..48f1b692 --- /dev/null +++ b/Resources/Scripts/XUi/XUiStronghold/XUiGridStrongholdPlugin.lua @@ -0,0 +1,32 @@ +local XUiGridStrongholdPlugin = XClass(nil, "XUiGridStrongholdPlugin") + +function XUiGridStrongholdPlugin:Ctor(ui, clickCb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + + if self.BtnClick then self.BtnClick.CallBack = clickCb end + + self.Effect.gameObject:SetActiveEx(false) +end + +function XUiGridStrongholdPlugin:Refresh(plugin, isAllPluginEmpty, doNotShowEffect) + self.Plugin = plugin + + self.PanelEmpty.gameObject:SetActiveEx(isAllPluginEmpty) + self.PanelPlugin.gameObject:SetActiveEx(not isAllPluginEmpty) + + local icon = plugin:GetIcon() + self.RImgIcon:SetRawImage(icon) + + local count = plugin:GetCount() + self.TxtNum.text = "x" .. count + + if not doNotShowEffect and not isAllPluginEmpty then + self.Effect.gameObject:SetActiveEx(false) + self.Effect.gameObject:SetActiveEx(true) + end +end + +return XUiGridStrongholdPlugin \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiStronghold/XUiGridStrongholdPluginSet.lua b/Resources/Scripts/XUi/XUiStronghold/XUiGridStrongholdPluginSet.lua new file mode 100644 index 00000000..178402e5 --- /dev/null +++ b/Resources/Scripts/XUi/XUiStronghold/XUiGridStrongholdPluginSet.lua @@ -0,0 +1,110 @@ +local handler = handler + +local LongClickIntervel = 100 +local AddCountPerPressTime = 1 / 150 + +local XUiGridStrongholdPluginSet = XClass(nil, "XUiGridStrongholdPluginSet") + +function XUiGridStrongholdPluginSet:Ctor(ui, checkCountCb, countChangeCb, getMaxCountCb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.CheckCountCb = checkCountCb + self.CountChangeCb = countChangeCb + self.GetMaxCountCb = getMaxCountCb + self.Count = 0 + + XTool.InitUiObject(self) + + if self.BtnAdd then self.BtnAdd.CallBack = handler(self, self.OnClickBtnAdd) end + if self.BtnReduce then self.BtnReduce.CallBack = handler(self, self.OnClickBtnSub) end + + XUiButtonLongClick.New(self.BtnAdd, LongClickIntervel, self, nil, self.OnLongClickBtnAdd, nil, true) + XUiButtonLongClick.New(self.BtnReduce, LongClickIntervel, self, nil, self.OnLongClickBtnReduce, nil, true) +end + +function XUiGridStrongholdPluginSet:Refresh(plugin) + self.Plugin = plugin + self.Count = plugin:GetCount() + + local icon = plugin:GetIcon() + self.RImgIconCore:SetRawImage(icon) + + local name = plugin:GetName() + self.TxtName.text = name + + local desc = plugin:GetDesc() + self.TxtDetails.text = desc + + self:UpdateCount() +end + +function XUiGridStrongholdPluginSet:UpdateCount() + self.TxtNumber.text = self.Count +end + +function XUiGridStrongholdPluginSet:OnLongClickBtnAdd(pressingTime) + local maxCount = self.GetMaxCountCb(self.Plugin:GetCostElectricSingle()) + local addCount = XMath.Clamp(math.floor(pressingTime * AddCountPerPressTime), 1, maxCount) + local countLimitLeft = self.Plugin:GetCountLimit() - self.Count + if countLimitLeft < 1 then + countLimitLeft = 1 + end + addCount = XMath.Clamp(addCount, 1, countLimitLeft) + + if addCount > 0 then + self:AddCount(addCount) + else + XUiManager.TipText("StrongholdPluginAddFail") + end +end + +function XUiGridStrongholdPluginSet:OnLongClickBtnReduce(pressingTime) + local subCount = XMath.Clamp(math.floor(pressingTime * AddCountPerPressTime), 0, self.Count) + self:SubCount(subCount) +end + +function XUiGridStrongholdPluginSet:OnClickBtnAdd() + self:AddCount(1) +end + +function XUiGridStrongholdPluginSet:OnClickBtnSub() + self:SubCount(1) +end + +function XUiGridStrongholdPluginSet:GetCount() + return self.Count or 0 +end + +function XUiGridStrongholdPluginSet:AddCount(addCount) + local costElectric = self.Plugin:GetCostElectricSingle() * addCount + if not self.CheckCountCb(costElectric) then + XUiManager.TipText("StrongholdPluginAddFail") + return + end + + local newCount = self.Count + addCount + local countLimit = self.Plugin:GetCountLimit() + if newCount > countLimit then + XUiManager.TipText("StrongholdPluginAddOverLimit") + return + end + + self.Count = newCount + self.CountChangeCb(costElectric) + self:UpdateCount() +end + +function XUiGridStrongholdPluginSet:SubCount(subCount) + local newCount = self.Count - subCount + if newCount < 0 then + return + end + + local costElectric = self.Plugin:GetCostElectricSingle() * subCount + self.Count = newCount + self.CountChangeCb(-costElectric) + + self:UpdateCount() +end + +return XUiGridStrongholdPluginSet \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiStronghold/XUiGridStrongholdTeam.lua b/Resources/Scripts/XUi/XUiStronghold/XUiGridStrongholdTeam.lua new file mode 100644 index 00000000..a6b1c461 --- /dev/null +++ b/Resources/Scripts/XUi/XUiStronghold/XUiGridStrongholdTeam.lua @@ -0,0 +1,195 @@ +local XUiGridStrongHoldTeamMember = require("XUi/XUiStronghold/XUiGridStrongHoldTeamMember") +local XUiGridStrongholdPlugin = require("XUi/XUiStronghold/XUiGridStrongholdPlugin") + +local CsXTextManagerGetText = CsXTextManagerGetText +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate + +local XUiGridStrongholdTeam = XClass(nil, "XUiGridStrongholdTeam") + +function XUiGridStrongholdTeam:Ctor(ui, fightCb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.MemberGrids = {} + self.PluginGrids = {} + self.FightCb = fightCb + + XTool.InitUiObject(self) + + self.BtnLeader.CallBack = function() self:OnBtnLeaderClick() end + self.BtnRune.CallBack = function() self:OnBtnRuneClick() end + self.BtnFight.CallBack = function() self:OnBtnFightClick() end + self.BtnReset.CallBack = function() self:OnBtnResetClick() end + + self.GridDeployMember.gameObject:SetActiveEx(false) + self.GridPlugin.gameObject:SetActiveEx(false) + + XEventManager.AddEventListener(XEventId.EVENT_STRONGHOLD_PLUGIN_CHANGE_ACK, self.UpdateView, self) +end + +function XUiGridStrongholdTeam:OnDestroy() + XEventManager.RemoveEventListener(XEventId.EVENT_STRONGHOLD_PLUGIN_CHANGE_ACK, self.UpdateView, self) +end + +function XUiGridStrongholdTeam:Refresh(teamList, teamId, groupId, isPrefab) + self.TeamList = teamList--队伍数据更改赋值 + self.TeamListClip = XDataCenter.StrongholdManager.GetTeamListClipTemp(groupId, teamList)--仅显示用 + self.TeamId = teamId + self.GroupId = groupId + local team = self:GetTeam() + + if isPrefab then + --队伍预设 + self.TxtTitle.text = CsXTextManagerGetText("StrongholdTeamTitle", teamId) + + local runeDesc = team:GetRuneDesc() + self.TxtBuff.text = runeDesc + self.TxtBuff.gameObject:SetActiveEx(true) + + self.PanelRequire.gameObject:SetActiveEx(false) + self.PanelVictory.gameObject:SetActiveEx(false) + self.BtnFight.gameObject:SetActiveEx(false) + else + --战斗编队 + local stageIndex = teamId + + self.TxtTitle.text = XDataCenter.StrongholdManager.GetGroupStageName(groupId, stageIndex) + + local requireAbility = XDataCenter.StrongholdManager.GetGroupRequireAbility(groupId) + self.TxtRequireAbility.text = requireAbility + self.PanelRequire.gameObject:SetActiveEx(true) + + local buffDes = XDataCenter.StrongholdManager.GetGroupStageBuffDesc(groupId, stageIndex) + local runeDesc = team:GetRuneDesc() + self.TxtBuff.text = buffDes .. runeDesc + self.TxtBuff.gameObject:SetActiveEx(true) + + local isFinished = XDataCenter.StrongholdManager.IsGroupStageFinished(groupId, stageIndex) + self.PanelVictory.gameObject:SetActiveEx(isFinished) + + self.BtnFight.gameObject:SetActiveEx(true) + end + + local hasRune = team:HasRune() + self.PanelNor.gameObject:SetActiveEx(hasRune) + self.PanelEmpty.gameObject:SetActiveEx(not hasRune) + if hasRune then + local runeId, subRuneId = team:GetRune() + self.ImgRune:SetSprite(XStrongholdConfigs.GetRuneIcon(runeId)) + self.ImgSubRune:SetSprite(XStrongholdConfigs.GetSubRuneIcon(subRuneId)) + self.ImgColor.color = team:GetRuneColor() + end + + local doNotShowEffect = true + self:UpdateView(doNotShowEffect) +end + +function XUiGridStrongholdTeam:UpdateView(doNotShowEffect) + self:UpdateTeam() + self:UpdatePlugins(doNotShowEffect) +end + +function XUiGridStrongholdTeam:UpdateTeam() + local groupId = self.GroupId + local teamId = self.TeamId + local teamList = self.TeamList + + local team = self:GetTeam(true) + self.TxtLeaderSkill.text = team:GetCaptainSkillDesc() + + local requireMemberNum = XStrongholdConfigs.GetGroupRequireTeamMemberNum(groupId, teamId) + for index = 1, requireMemberNum do + local grid = self.MemberGrids[index] + if not grid then + local go = index == 1 and self.GridDeployMember or CSUnityEngineObjectInstantiate(self.GridDeployMember, self.PanelDeployMembers) + grid = XUiGridStrongHoldTeamMember.New(go) + self.MemberGrids[index] = grid + end + + grid:Refresh(teamList, teamId, index, groupId) + + --蓝色放到第一位 + if index == 2 then + grid.Transform:SetAsFirstSibling() + end + + grid.GameObject:SetActiveEx(true) + end + + for index = requireMemberNum + 1, #self.MemberGrids do + self.MemberGrids[index].GameObject:SetActiveEx(false) + end +end + +function XUiGridStrongholdTeam:UpdatePlugins(doNotShowEffect) + local team = self:GetTeam() + local plugins = team:GetAllPlugins() + + for index = 1, #plugins do + local grid = self.PluginGrids[index] + if not grid then + local go = index == 1 and self.GridPlugin or CSUnityEngineObjectInstantiate(self.GridPlugin, self.PanelCoreContent) + local clickCb = handler(self, self.OnClickPlugin) + grid = XUiGridStrongholdPlugin.New(go, clickCb) + self.PluginGrids[index] = grid + end + + local plugin = plugins[index] + local isAllPluginEmpty = team:IsAllPluginEmpty() + grid:Refresh(plugin, isAllPluginEmpty, doNotShowEffect) + grid.GameObject:SetActiveEx(true) + end + for index = #plugins + 1, #self.PluginGrids do + self.PluginGrids[index].GameObject:SetActiveEx(false) + end +end + +function XUiGridStrongholdTeam:OnBtnLeaderClick() + local groupId = self.GroupId + local teamId = self.TeamId + local requireMemberNum = XStrongholdConfigs.GetGroupRequireTeamMemberNum(groupId, teamId) + local team = self:GetTeam() + local teamClip = self:GetTeam(true) + local characterIdList, characterIdToIsIsAssitantDic = team:GenarateTeamCharacterList(requireMemberNum) + local captainPos = team:GetCaptainPos() + XLuaUiManager.Open("UiNewRoomSingleTip", self, characterIdList, captainPos, function(index) + team:SetCaptainPos(index) + teamClip:SetCaptainPos(index) + self:UpdateTeam() + end, characterIdToIsIsAssitantDic) +end + +function XUiGridStrongholdTeam:OnClickPlugin() + XLuaUiManager.Open("UiStrongholdCoreTips", self.TeamList, self.TeamId, self.GroupId) +end + +function XUiGridStrongholdTeam:GetTeam(isUseClip) + -- isUseClip时仅显示队伍数据用 + return isUseClip and self.TeamListClip[self.TeamId] or self.TeamList[self.TeamId] +end + +function XUiGridStrongholdTeam:OnBtnRuneClick() + local runeIdList = XDataCenter.StrongholdManager.GetAllRuneIds() + if XTool.IsTableEmpty(runeIdList) then + XLog.Error("XUiStrongholdRune:InitTabBtnGroup error, 服务器下发可用符文列表为空") + return + end + XLuaUiManager.Open("UiStrongholdRune", self.TeamList, self.TeamId, self.GroupId) +end + +function XUiGridStrongholdTeam:OnBtnFightClick() + if self.FightCb then self.FightCb() end + XDataCenter.StrongholdManager.TryEnterFight(self.GroupId, self.TeamId, self.TeamList) +end + +function XUiGridStrongholdTeam:OnBtnResetClick() + local callFunc = function() + local groupId = self.GroupId + local stageId = XDataCenter.StrongholdManager.GetGroupStageId(groupId, self.TeamId) + XDataCenter.StrongholdManager.ResetStrongholdStageRequest(groupId, stageId) + end + local title = CSXTextManagerGetText("StrongholdTeamResetStageConfirmTitle") + local content = CSXTextManagerGetText("StrongholdTeamResetStageConfirmContent") + XUiManager.DialogTip(title, content, XUiManager.DialogType.Normal, nil, callFunc) +end + +return XUiGridStrongholdTeam \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiStronghold/XUiGridTeamCharacter.lua b/Resources/Scripts/XUi/XUiStronghold/XUiGridTeamCharacter.lua new file mode 100644 index 00000000..e9bb4dc3 --- /dev/null +++ b/Resources/Scripts/XUi/XUiStronghold/XUiGridTeamCharacter.lua @@ -0,0 +1,106 @@ +local handler = handler +local tableInsert = table.insert +local tableRemove = table.remove +local CsXTextManagerGetText = CsXTextManagerGetText + +local XUiGridTeamCharacter = XClass(nil, "XUiGridTeamCharacter") + +function XUiGridTeamCharacter:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + + self.BtnClick.CallBack = handler(self, self.OnClickBtnClick) +end + +function XUiGridTeamCharacter:Refresh(characterId) + self.CharacterId = characterId + + if not XTool.IsNumberValid(characterId) then + self.ImgTianJia.gameObject:SetActiveEx(true) + self.PanelTouXiang.gameObject:SetActiveEx(false) + else + local icon = XDataCenter.CharacterManager.GetCharSmallHeadIcon(characterId) + self.ImgTouXiang:SetRawImage(icon) + + self.TxtAbility.text = XDataCenter.CharacterManager.GetCharacterAbilityById(characterId) + + self.ImgTianJia.gameObject:SetActiveEx(false) + self.PanelTouXiang.gameObject:SetActiveEx(true) + end +end + +function XUiGridTeamCharacter:OnClickBtnClick() + local characterId = nil + local supportData = { + OldCharacterId = self.CharacterId, + CanSupportCancel = true, + CheckLockSupportCb = function(characterId) + return XDataCenter.StrongholdManager.CheckInTeamList(characterId) + end, + CheckInSupportCb = function(characterId) + return XDataCenter.StrongholdManager.CheckInElectricTeam(characterId) + end, + GetCharacters = function(characterType) + return XDataCenter.StrongholdManager.GetCanElectricCharacters(characterType) + end, + SetCharacterCb = function(characterId, cb, oldCharacterId) + if XDataCenter.StrongholdManager.CheckInElectricTeam(characterId) then + XUiManager.TipText("StrongholdElectricSupportInElectricTeam") + return + end + + if XDataCenter.StrongholdManager.CheckInTeamList(characterId) then + XUiManager.TipText("StrongholdElectricSupportInTeamList") + return + end + + local characterIds = XDataCenter.StrongholdManager.GetElectricCharacterIds() + if XDataCenter.StrongholdManager.CheckElectricMaxNum(characterId) then + if oldCharacterId then + for index, inCharacterId in ipairs(characterIds) do + if inCharacterId == oldCharacterId then + tableRemove(characterIds, index) + break + end + end + else + XUiManager.TipText("StrongholdElectricTeamMaxNum") + return + end + end + tableInsert(characterIds, characterId) + + XDataCenter.StrongholdManager.SetStrongholdElectricTeamRequest(characterIds, cb) + + return true + end, + CancelCharacterCb = function(characterId, cb) + local callFunc = function() + local characterIds = XDataCenter.StrongholdManager.GetElectricCharacterIds() + for index, inCharacterId in pairs(characterIds) do + if inCharacterId == characterId then + tableRemove(characterIds, index) + break + end + end + XDataCenter.StrongholdManager.SetStrongholdElectricTeamRequest(characterIds) + + XLuaUiManager.Close("UiCharacter") + end + + if XDataCenter.StrongholdManager.CheckElectricOverLimit(characterId) then + local title = CSXTextManagerGetText("ElectricTeamCancelTipTitle") + local content = CSXTextManagerGetText("ElectricTeamCancelTipContent") + XUiManager.DialogTip(title, content, XUiManager.DialogType.Normal, nil, callFunc) + else + callFunc() + end + + end, + } + XLuaUiManager.Open("UiCharacter", characterId, nil, nil, nil, nil, nil, supportData) +end + +return XUiGridTeamCharacter \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiStronghold/XUiPanelStrongholdChapter.lua b/Resources/Scripts/XUi/XUiStronghold/XUiPanelStrongholdChapter.lua new file mode 100644 index 00000000..ebfe480e --- /dev/null +++ b/Resources/Scripts/XUi/XUiStronghold/XUiPanelStrongholdChapter.lua @@ -0,0 +1,168 @@ +local XUiGridStrongholdGroup = require("XUi/XUiStronghold/XUiGridStrongholdGroup") + +local Lerp = CS.UnityEngine.Mathf.Lerp +local Vector3 = CS.UnityEngine.Vector3 +local CSXScheduleManagerUnSchedule = XScheduleManager.UnSchedule + +local ANIM_DURATION = 0.2--关卡滑动动画持续时间 +local CENTER_PERCENT = 0.3--关卡要滑动到的位置占屏幕宽度百分比 + +local XUiPanelStrongholdChapter = XClass(nil, "XUiPanelStrongholdChapter") + +function XUiPanelStrongholdChapter:Ctor(ui, clickStageCb, skipCb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.GroupGrids = {} + self.ClickStageCb = clickStageCb + self.SkipCb = skipCb + + XTool.InitUiObject(self) + + self.ViewPort = self.Transform:FindTransform("ViewPort") + self.PanelStageContent = self.Transform:FindTransform("PanelStageContent") + self.ScrollRect = self.Transform:FindTransform("PaneStageList"):GetComponent("ScrollRect") +end + +function XUiPanelStrongholdChapter:Refresh(chapterId) + local groupIds = XStrongholdConfigs.GetGroupIds(chapterId) + self.GroupIds = groupIds + + for index, groupId in ipairs(groupIds) do + local grid = self.GroupGrids[index] + if not grid then + local prefabPath = XStrongholdConfigs.GetGroupPrefabPath(groupId) + local parent = self["Stage" .. index] + if not parent then + XLog.Error("XUiPanelStrongholdChapter:Refresh error:stage num error: chapterId is: " .. chapterId .. ", prefabPath: " .. prefabPath .. ", groupIds:", groupIds) + return + end + local go = parent:LoadPrefab(prefabPath) + local clickStageCb = handler(self, self.OnClickStage) + grid = XUiGridStrongholdGroup.New(go, index, clickStageCb, self.SkipCb) + self.GroupGrids[index] = grid + end + + grid:Refresh(groupId) + grid.GameObject:SetActiveEx(true) + + self:RefreshClearLine(index, groupId) + end + + for index = #groupIds + 1, #self.GroupGrids do + local grid = self.GroupGrids[index] + if grid then + grid.GameObject:SetActiveEx(false) + end + end +end + +function XUiPanelStrongholdChapter:RefreshClearLine(index, groupId) + local isFinished = XDataCenter.StrongholdManager.IsGroupFinished(groupId) + local clearLine = self["ClearLine" .. index] + local notClearLine = self["NotClearLine" .. index] + if clearLine then + clearLine.gameObject:SetActiveEx(isFinished) + end + if notClearLine then + notClearLine.gameObject:SetActiveEx(not isFinished) + end + + local preClearLine = self["PreClearLine" .. index] + local preNotClearLine = self["PreNotClearLine" .. index] + if preClearLine and preNotClearLine then + local buffIds = XDataCenter.StrongholdManager.GetGroupBossBuffIds(groupId) + local isBuffActive + local preIsAllClear = true + for index, buffId in ipairs(buffIds) do + isBuffActive = XDataCenter.StrongholdManager.CheckBuffActive(buffId) + if isBuffActive then + preIsAllClear = false + break + end + end + preClearLine.gameObject:SetActiveEx(preIsAllClear) + preNotClearLine.gameObject:SetActiveEx(not preIsAllClear) + end +end + +function XUiPanelStrongholdChapter:OnClickStage(gridIndex) + self.SelectGridIndex = gridIndex + if not gridIndex then return end + + local groupId = self.GroupIds[gridIndex] + if self.ClickStageCb then self.ClickStageCb(groupId) end + + for index, grid in pairs(self.GroupGrids) do + grid:SetSelect(index == gridIndex) + end + + self.ScrollRect.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Unrestricted + self:CenterToGrid(gridIndex) +end + +function XUiPanelStrongholdChapter:OnStageDetailClose() + self.SelectGridIndex = nil + self.ScrollRect.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Elastic + + for index, grid in pairs(self.GroupGrids) do + grid:SetSelect(false) + end +end + +function XUiPanelStrongholdChapter:CenterToGrid(gridIndex) + local parent = self["Stage" .. gridIndex] + if not parent then return end + + local gridPosX = parent.transform.anchoredPosition3D.x + local limitX = self.ViewPort.rect.width * CENTER_PERCENT + local delta = limitX - gridPosX + + local startPos = self.PanelStageContent.anchoredPosition3D + local endPosX = delta + + local onRefresh = function(time) + if XTool.UObjIsNil(self.PanelStageContent) then + self:DestroyTimer() + return true + end + + if startPos.x == endPosX then + return true + end + + local posX = Lerp(startPos.x, endPosX, time) + self.PanelStageContent.anchoredPosition3D = Vector3(posX, startPos.y, startPos.z) + end + + local onFinish = function() + XLuaUiManager.SetMask(false) + end + + XLuaUiManager.SetMask(true) + + self.Timer = XUiHelper.Tween(ANIM_DURATION, onRefresh, onFinish) +end + +function XUiPanelStrongholdChapter:DestroyTimer() + if self.Timer then + CSXScheduleManagerUnSchedule(self.Timer) + self.Timer = nil + end +end + +function XUiPanelStrongholdChapter:CenterToLastGrid() + local gridIndex = #self.GroupIds + self:OnClickStage(gridIndex) +end + +function XUiPanelStrongholdChapter:OnSkipStage(skipGroupId) + for index, groupId in ipairs(self.GroupIds) do + if groupId == skipGroupId then + self:OnClickStage(index) + return + end + end + XLog.Error(string.format("当前组没有找到可跳转的关卡id。GroupId:%s", skipGroupId)) +end + +return XUiPanelStrongholdChapter \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiStronghold/XUiPanelStrongholdRoomCharacterOthers.lua b/Resources/Scripts/XUi/XUiStronghold/XUiPanelStrongholdRoomCharacterOthers.lua new file mode 100644 index 00000000..bd9daa89 --- /dev/null +++ b/Resources/Scripts/XUi/XUiStronghold/XUiPanelStrongholdRoomCharacterOthers.lua @@ -0,0 +1,407 @@ +local XUiExpeditionEquipGrid = require("XUi/XUiExpedition/RoleList/XUiExpeditionEquipGrid/XUiExpeditionEquipGrid") +local XUiGridStrongholdCharacter = require("XUi/XUiStronghold/XUiGridStrongholdCharacter") + +local handler = handler +local CsXUiHelper = CsXUiHelper +local CsXTextManagerGetText = CsXTextManagerGetText +local IsNumberValid = XTool.IsNumberValid +local IsTableEmpty = XTool.IsTableEmpty +local tableRemove = table.remove +local tableInsert = table.insert + +local CONDITION_COLOR = { + [true] = CS.UnityEngine.Color.red, + [false] = XUiHelper.Hexcolor2Color("0E70BDFF"), +} + +local XUiPanelStrongholdRoomCharacterOthers = XClass(nil, "XUiPanelStrongholdRoomCharacterOthers") + +function XUiPanelStrongholdRoomCharacterOthers:Ctor(ui, selectCharacterCb, closeUiFunc, playAnimationCb, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.SelectCharacterCb = selectCharacterCb + self.CloseUiFunc = closeUiFunc + self.PlayAnimationCb = playAnimationCb + self.RootUi = rootUi + self.WearingAwarenessGrids = {} + + XTool.InitUiObject(self) + self.PanelEquip = self.GameObject:FindTransform("TeamBtn2") + + self:InitDynamicTable() + self:AutoAddListener() + + self.GridCharacter.gameObject:SetActiveEx(false) +end + +function XUiPanelStrongholdRoomCharacterOthers:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.SViewCharacterList) + self.DynamicTable:SetProxy(XUiGridStrongholdCharacter) + self.DynamicTable:SetDelegate(self) +end + +function XUiPanelStrongholdRoomCharacterOthers:Hide() + self.GameObject:SetActiveEx(false) +end + +function XUiPanelStrongholdRoomCharacterOthers:Show(teamList, teamId, memberIndex, groupId) + self.TeamList = teamList + self.TeamId = teamId + self.MemberIndex = memberIndex + self.GroupId = groupId + + self:UpdateUseTimes() + self:UpdateCharacters() + + self.GameObject:SetActiveEx(true) +end + +function XUiPanelStrongholdRoomCharacterOthers:UpdateUseTimes() + local times = XDataCenter.StrongholdManager.GetBorrowCount() + local maxTimes = XStrongholdConfigs.GetBorrowMaxTimes() + + local isOverTimes = times >= maxTimes + if not isOverTimes then + local itemId, count = XStrongholdConfigs.GetBorrowCostItemInfo(times) + local icon = XItemConfigs.GetItemIconById(itemId) + self.RImgIcon:SetRawImage(icon) + self.TxtNumber.text = count + self.TxtNumber.gameObject:SetActiveEx(true) + else + self.TxtNumber.gameObject:SetActiveEx(false) + end + + self.TxtTimes.text = times .. "/" .. maxTimes + self.TxtTimes.color = CONDITION_COLOR[isOverTimes] +end + +function XUiPanelStrongholdRoomCharacterOthers:UpdateCharacters() + local teamList = self.TeamList + local groupId = self.GroupId + local stageIndex = self.TeamId + + self.PlayerIds = XDataCenter.StrongholdManager.GetAssistantPlayerIds(groupId, stageIndex, teamList) + if not self:CheckInPlayerIds(self.PlayerId) then + self.PlayerId = self.PlayerIds[1] + end + + --将选中角色提到第一位 + local find = false + local selectCharacterId = self.PlayerId + for index, inCharacterId in pairs(self.PlayerIds) do + if inCharacterId == selectCharacterId then + tableRemove(self.PlayerIds, index) + find = true + break + end + end + if find then + tableInsert(self.PlayerIds, 1, selectCharacterId) + end + + local index = self:GetPlayerIndex() + self.DynamicTable:SetDataSource(self.PlayerIds) + self.DynamicTable:ReloadDataASync(index) + + local isEmpty = IsTableEmpty(self.PlayerIds) + self.PanelEmptyListOthers.gameObject:SetActiveEx(isEmpty) + + self.PlayAnimationCb("ShuaXin") +end + +function XUiPanelStrongholdRoomCharacterOthers:IsLoading() + return self.DynamicTable and self.DynamicTable:IsAsyncLoading() +end + +function XUiPanelStrongholdRoomCharacterOthers:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local playerId = self.PlayerIds[index] + local characterId = XDataCenter.StrongholdManager.GetAssistantPlayerCharacterId(playerId) + local groupId = self.GroupId + grid:Refresh(characterId, groupId, self.TeamId, self.TeamList, playerId) + + local isSelected = playerId == self.PlayerId + grid:SetSelect(isSelected) + if isSelected then + self.LastSelectGrid = grid + end + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + local playerId = self.PlayerIds[index] + + if self.LastSelectGrid then + self.LastSelectGrid:SetSelect(false) + end + self.LastSelectGrid = grid + self.LastSelectGrid:SetSelect(true) + + self:SelectCharacter(playerId) + end +end + +function XUiPanelStrongholdRoomCharacterOthers:SelectCharacter(playerId) + if not self:CheckInPlayerIds(playerId) then + playerId = self.PlayerIds[1] + end + self.PlayerId = playerId + + local characterId = XDataCenter.StrongholdManager.GetAssistantPlayerCharacterId(playerId) + local teamList = self.TeamList + local oldTeamId = XDataCenter.StrongholdManager.GetCharacterInTeamId(characterId, teamList, playerId) + local isInCurTeam = oldTeamId == self.TeamId + + local times = XDataCenter.StrongholdManager.GetBorrowCount() + local maxTimes = XStrongholdConfigs.GetBorrowMaxTimes() + local isOverTimes = times >= maxTimes + self.BtnJoinTeam.gameObject:SetActiveEx(not isInCurTeam and not isOverTimes) + self.BtnJoinDisable.gameObject:SetActiveEx(not isInCurTeam and isOverTimes) + self.BtnQuitTeam.gameObject:SetActiveEx(isInCurTeam) + + self:UpdateEquips() + self.SelectCharacterCb(characterId, playerId) +end + +function XUiPanelStrongholdRoomCharacterOthers:UpdateEquips() + if self:IsEmpty() then + self.PanelEquip.gameObject:SetActiveEx(false) + return + end + self.PanelEquip.gameObject:SetActiveEx(true) + + local isCheckEquipPosResonanced = false + local playerId = self.PlayerId + local assistantInfo = XDataCenter.StrongholdManager.GetAssistantInfo(playerId) + local equips = assistantInfo.Equips + + local weapon = {} + local equipSiteDic = {} + local weaponResonanceCount = 0 + for _, equip in pairs(equips) do + if XDataCenter.EquipManager.IsWeaponByTemplateId(equip.TemplateId) then + weapon = equip + weaponResonanceCount = #equip.ResonanceInfo + else + local site = XDataCenter.EquipManager.GetEquipSiteByEquipData(equip) + equipSiteDic[site] = equip + end + end + + self.WeaponGrid = self.WeaponGrid or XUiExpeditionEquipGrid.New(self.GridWeapon, nil, self.RootUi) + local usingWeaponId = weapon.TemplateId + if usingWeaponId then + self.WeaponGrid:Refresh(usingWeaponId, weapon.Breakthrough, 0, true, weapon.Level, weaponResonanceCount) + end + + for i = 1, 6 do + self.WearingAwarenessGrids[i] = self.WearingAwarenessGrids[i] or XUiExpeditionEquipGrid.New(CS.UnityEngine.Object.Instantiate(self.GridAwareness), nil, self.RootUi) + self.WearingAwarenessGrids[i].Transform:SetParent(self["PanelAwareness" .. i], false) + + local equip = equipSiteDic[i] + if not equip then + self.WearingAwarenessGrids[i].GameObject:SetActiveEx(false) + else + local resonanceCount = #equip.ResonanceInfo + self.WearingAwarenessGrids[i].GameObject:SetActiveEx(true) + self.WearingAwarenessGrids[i]:Refresh(equip.TemplateId, equip.Breakthrough, i, false, equip.Level, resonanceCount) + end + end + +end + +function XUiPanelStrongholdRoomCharacterOthers:AutoAddListener() + CsXUiHelper.RegisterClickEvent(self.BtnJoinTeam, handler(self, self.OnClickBtnJoinTeam)) + CsXUiHelper.RegisterClickEvent(self.BtnQuitTeam, handler(self, self.OnBtnQuitTeamClick)) + CsXUiHelper.RegisterClickEvent(self.BtnRefresh, handler(self, self.OnClickBtnRefresh)) + CsXUiHelper.RegisterClickEvent(self.BtnJoinDisable, handler(self, self.OnBtnJoinDisableClick)) +end + +function XUiPanelStrongholdRoomCharacterOthers:OnClickBtnRefresh() + local cb = function() + local groupId = self.GroupId + local teamList = self.TeamList + XDataCenter.StrongholdManager.KickOutInvalidMembersInTeamList(teamList, groupId) + self:UpdateCharacters() + self:SelectCharacter() + end + XDataCenter.StrongholdManager.GetStrongholdAssistCharacterListRequest(cb) +end + +function XUiPanelStrongholdRoomCharacterOthers:OnClickBtnJoinTeam() + local groupId = self.GroupId + local teamList = self.TeamList + local teamId = self.TeamId + local playerId = self.PlayerId + local characterId = XDataCenter.StrongholdManager.GetAssistantPlayerCharacterId(playerId) + local team = self:GetTeam() + local member = self:GetMember() + + --队伍已上阵支援角色 + local overCount = XDataCenter.StrongholdManager.CheckTeamListExistAssitantCharacter(teamList) + if overCount then + XUiManager.TipText("StrongholdBorrowCountOver") + return + end + + --在有关卡进度的队伍中 + local isInTeamLock = XDataCenter.StrongholdManager.CheckInTeamListLock(groupId, characterId, teamList, playerId) + if isInTeamLock then + XUiManager.TipText("StrongholdElectricDeployInTeamLock") + return + end + + --队伍是否已上阵相同型号角色 + local sameCharacter = XDataCenter.StrongholdManager.CheckTeamListExistSameCharacter(characterId, teamList, playerId, teamId, self.MemberIndex) + if sameCharacter then + XUiManager.TipText("StrongholdElectricDeploySameCharacter") + return + end + + local swapFunc = function() + local oldTeamId = XDataCenter.StrongholdManager.GetCharacterInTeamId(characterId, teamList, playerId) + if IsNumberValid(oldTeamId) then + --switch team + local oldCharacterId = member:GetInTeamCharacterId() + local oldPlayerId = member:GetPlayerId() + local oldTeam = teamList[oldTeamId] + local oldMember = oldTeam:GetInTeamMemberByCharacterId(characterId, playerId) + + local oldCharacterType = self:GetCharacterType(oldCharacterId) + if oldTeam:ExistDifferentCharacterType(oldCharacterType) then + oldTeam:Clear() + end + + oldMember:SetInTeam(oldCharacterId, oldPlayerId) + end + + local characterType = self:GetCharacterType() + if team:ExistDifferentCharacterType(characterType) then + --队伍中已经存在其他类型的角色(构造体/授格者)时,清空队伍 + team:Clear() + end + + member:SetInTeam(characterId, playerId) + + self.CloseUiFunc() + end + + local setTeamFunc = function() + local characterType = self:GetCharacterType() + if team:ExistDifferentCharacterType(characterType) then + --队伍中已经存在其他类型的角色(构造体/授格者) + local content = CSXTextManagerGetText("TeamCharacterTypeNotSame") + XUiManager.DialogTip(nil, content, XUiManager.DialogType.Normal, nil, swapFunc) + else + swapFunc() + end + end + + local callFunc = function() + local isInTeam = XDataCenter.StrongholdManager.CheckInTeamList(characterId, teamList, playerId) + if isInTeam then + --在别的队伍中,可以交换 + local inTeamId = XDataCenter.StrongholdManager.GetCharacterInTeamId(characterId, teamList, playerId) + local title = CsXTextManagerGetText("StrongholdDeployTipTitle") + local showCharacterId = XRobotManager.GetCharacterId(characterId) + local characterName = XCharacterConfigs.GetCharacterName(showCharacterId) + local content = CsXTextManagerGetText("StrongholdDeployTipContent", characterName, inTeamId, teamId) + XUiManager.DialogTip(title, content, XUiManager.DialogType.Normal, nil, setTeamFunc) + else + --不在在别的队伍中,直接上阵 + setTeamFunc() + end + end + + local times = XDataCenter.StrongholdManager.GetBorrowCount() + local maxTimes = XStrongholdConfigs.GetBorrowMaxTimes() + if times >= maxTimes then + XUiManager.TipText("StrongholdBorrowMaxTimes") + return + end + + local itemId, count = XStrongholdConfigs.GetBorrowCostItemInfo(times) + if not XDataCenter.ItemManager.CheckItemCountById(itemId, count) then + XUiManager.TipText("StrongholdBorrowCostLack") + return + end + + local itemName = XItemConfigs.GetItemNameById(itemId) + local title = CsXTextManagerGetText("StrongholdDeployAssistantTipTitle") + local content = CsXTextManagerGetText("StrongholdDeployAssistantTipContent", itemName, count) + XUiManager.DialogTip(title, content, XUiManager.DialogType.Normal, nil, callFunc) +end + +function XUiPanelStrongholdRoomCharacterOthers:OnBtnJoinDisableClick() + XUiManager.TipText("StrongholdBorrowMaxTimes") +end + +function XUiPanelStrongholdRoomCharacterOthers:OnBtnQuitTeamClick() + local teamList = self.TeamList + local teamId = self.TeamId + local playerId = self.PlayerId + local characterId = XDataCenter.StrongholdManager.GetAssistantPlayerCharacterId(playerId) + local inTeamId = XDataCenter.StrongholdManager.GetCharacterInTeamId(characterId, teamList, playerId) + if teamId ~= inTeamId then return end + + local team = self:GetTeam() + local member = team:GetInTeamMemberByCharacterId(characterId, playerId) + member:KickOutTeam() + + self.CloseUiFunc() +end + +function XUiPanelStrongholdRoomCharacterOthers:GetTeam() + return self.TeamList[self.TeamId] +end + +function XUiPanelStrongholdRoomCharacterOthers:GetMember() + local team = self:GetTeam() + return team:GetMember(self.MemberIndex) +end + +function XUiPanelStrongholdRoomCharacterOthers:GetPlayerCharacterId() + return XDataCenter.StrongholdManager.GetAssistantPlayerCharacterId(self.PlayerId) +end + +function XUiPanelStrongholdRoomCharacterOthers:GetPlayerIndex() + local selectPlayerId = self.PlayerId + if not IsNumberValid(selectPlayerId) then return -1 end + + local playerIds = self.PlayerIds + if IsTableEmpty(playerIds) then return -1 end + + for index, inPlayerId in ipairs(playerIds) do + if selectPlayerId == inPlayerId then + return index + end + end + + return -1 +end + +function XUiPanelStrongholdRoomCharacterOthers:CheckInPlayerIds(playerId) + if not IsNumberValid(playerId) then return false end + + local playerIds = self.PlayerIds + if IsTableEmpty(playerIds) then return false end + + for _, inPlayerId in pairs(playerIds) do + if playerId == inPlayerId then + return true + end + end + + return false +end + +function XUiPanelStrongholdRoomCharacterOthers:IsEmpty() + return XTool.IsTableEmpty(self.PlayerIds) +end + +function XUiPanelStrongholdRoomCharacterOthers:GetCharacterType(characterId) + characterId = characterId or XDataCenter.StrongholdManager.GetAssistantPlayerCharacterId(self.PlayerId) + if not IsNumberValid(characterId) then return end + + local showCharacterId = XRobotManager.GetCharacterId(characterId) + return XCharacterConfigs.GetCharacterType(showCharacterId) +end + +return XUiPanelStrongholdRoomCharacterOthers \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiStronghold/XUiPanelStrongholdRoomCharacterSelf.lua b/Resources/Scripts/XUi/XUiStronghold/XUiPanelStrongholdRoomCharacterSelf.lua new file mode 100644 index 00000000..d4281e1f --- /dev/null +++ b/Resources/Scripts/XUi/XUiStronghold/XUiPanelStrongholdRoomCharacterSelf.lua @@ -0,0 +1,464 @@ +local XUiGridStrongholdCharacter = require("XUi/XUiStronghold/XUiGridStrongholdCharacter") + +local handler = handler +local CsXUiHelper = CsXUiHelper +local CsXTextManagerGetText = CsXTextManagerGetText +local IsNumberValid = XTool.IsNumberValid +local IsTableEmpty = XTool.IsTableEmpty +local tableRemove = table.remove +local tableInsert = table.insert + +local XUiPanelStrongholdRoomCharacterSelf = XClass(nil, "XUiPanelStrongholdRoomCharacterSelf") + +function XUiPanelStrongholdRoomCharacterSelf:Ctor(ui, selectCharacterCb, closeUiFunc, playAnimationCb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.SelectCharacterCb = selectCharacterCb + self.CloseUiFunc = closeUiFunc + self.PlayAnimationCb = playAnimationCb + + XTool.InitUiObject(self) + + self.IsUpdateTeamPrefab = false --是否来自预设的更新队伍 + self.DialogTipCount = 0 --打开弹窗的数量,确定时不减少 + self.IsHasOpenDialogTip = false --是否有打开过弹窗 + + self:InitDynamicTable() + self:AutoAddListener() + + self.GridCharacter.gameObject:SetActiveEx(false) +end + +function XUiPanelStrongholdRoomCharacterSelf:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.SViewCharacterList) + self.DynamicTable:SetProxy(XUiGridStrongholdCharacter) + self.DynamicTable:SetDelegate(self) +end + +function XUiPanelStrongholdRoomCharacterSelf:Hide() + self.GameObject:SetActiveEx(false) +end + +function XUiPanelStrongholdRoomCharacterSelf:Show(teamList, teamId, memberIndex, groupId, isSelectIsomer) + self.TeamList = teamList + self.TeamId = teamId + self.MemberIndex = memberIndex + self.GroupId = groupId + self.IsSelectIsomer = isSelectIsomer + + + if self:IsPrefab() then + self.TxtEchelonName.text = CsXTextManagerGetText("StrongholdTeamTitle", teamId) + + self.PanelTxt.gameObject:SetActiveEx(false) + else + local stageIndex = self.TeamId + self.TxtEchelonName.text = XDataCenter.StrongholdManager.GetGroupStageName(groupId, stageIndex) + + local requireAbility = XDataCenter.StrongholdManager.GetGroupRequireAbility(groupId) + self.TxtRequireAbility.text = requireAbility + + self.PanelTxt.gameObject:SetActiveEx(true) + + self:RefreshCharacterTypeTips() + end + + self:UpdateCharacters() + + self.GameObject:SetActiveEx(true) +end + +function XUiPanelStrongholdRoomCharacterSelf:RefreshCharacterTypeTips() + if self:IsPrefab() then return end + + local groupId = self.GroupId + local stageIndex = self.TeamId + local stageId = XDataCenter.StrongholdManager.GetGroupStageId(groupId, stageIndex) + local characterLimitType = XFubenConfigs.GetStageCharacterLimitType(stageId) + + if not XFubenConfigs.IsStageCharacterLimitConfigExist(characterLimitType) then + self.PanelRequireCharacter.gameObject:SetActiveEx(false) + return + end + + local icon = XFubenConfigs.GetStageCharacterLimitImageTeamEdit(characterLimitType) + self.ImgRequireCharacter:SetSprite(icon) + + local limitBuffId = nil + local characterType = self:GetSelectCharacterType() + local text = XFubenConfigs.GetStageCharacterLimitTextSelectCharacter(characterLimitType, characterType, limitBuffId) + self.TxtRequireCharacter.text = text + + self.PanelRequireCharacter.gameObject:SetActiveEx(true) +end + +function XUiPanelStrongholdRoomCharacterSelf:UpdateCharacters() + local teamList = self.TeamList + local groupId = self.GroupId + local stageIndex = self.TeamId + local characterType = self:GetSelectCharacterType() + self.CharacterIds = XDataCenter.StrongholdManager.GetCanUseCharacterOrRobotIds(groupId, stageIndex, characterType, teamList) + + if not self:CheckInCharacterIds(self.CharacterId) then + self.CharacterId = self.CharacterIds[1] + end + + --将选中角色提到第一位 + local find = false + local selectCharacterId = self.CharacterId + for index, inCharacterId in pairs(self.CharacterIds) do + if inCharacterId == selectCharacterId then + tableRemove(self.CharacterIds, index) + find = true + break + end + end + if find then + tableInsert(self.CharacterIds, 1, selectCharacterId) + end + + local index = self:GetCharacterIndex() + self.DynamicTable:SetDataSource(self.CharacterIds) + self.DynamicTable:ReloadDataASync(index) + + local isEmpty = IsTableEmpty(self.CharacterIds) + self.PanelEmptyList.gameObject:SetActiveEx(isEmpty) + + self.PlayAnimationCb("ShuaXin") +end + +function XUiPanelStrongholdRoomCharacterSelf:IsLoading() + return self.DynamicTable and self.DynamicTable:IsAsyncLoading() +end + +function XUiPanelStrongholdRoomCharacterSelf:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local characterId = self.CharacterIds[index] + local groupId = self.GroupId + grid:Refresh(characterId, groupId, self.TeamId, self.TeamList) + + local isSelected = characterId == self.CharacterId + grid:SetSelect(isSelected) + if isSelected then + self.LastSelectGrid = grid + end + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + local characterId = self.CharacterIds[index] + + if self.LastSelectGrid then + self.LastSelectGrid:SetSelect(false) + end + self.LastSelectGrid = grid + self.LastSelectGrid:SetSelect(true) + + self:SelectCharacter(characterId) + end +end + +function XUiPanelStrongholdRoomCharacterSelf:SelectCharacter(characterId) + if not self:CheckInCharacterIds(characterId) then + characterId = self.CharacterIds[1] + end + self.CharacterId = characterId + + local teamList = self.TeamList + local oldTeamId = XDataCenter.StrongholdManager.GetCharacterInTeamId(characterId, teamList) + local isInCurTeam = oldTeamId == self.TeamId + self.BtnJoinTeam.gameObject:SetActiveEx(not isInCurTeam) + self.BtnQuitTeam.gameObject:SetActiveEx(isInCurTeam) + + self.SelectCharacterCb(characterId) +end + +function XUiPanelStrongholdRoomCharacterSelf:AutoAddListener() + CsXUiHelper.RegisterClickEvent(self.BtnPartner, handler(self, self.OnClickBtnPartner)) + CsXUiHelper.RegisterClickEvent(self.BtnFashion, handler(self, self.OnClickBtnFashion)) + CsXUiHelper.RegisterClickEvent(self.BtnConsciousness, handler(self, self.OnBtnConsciousnessClick)) + CsXUiHelper.RegisterClickEvent(self.BtnWeapon, handler(self, self.OnBtnWeaponClick)) + CsXUiHelper.RegisterClickEvent(self.BtnJoinTeam, handler(self, self.OnClickBtnJoinTeam)) + CsXUiHelper.RegisterClickEvent(self.BtnQuitTeam, handler(self, self.OnBtnQuitTeamClick)) + CsXUiHelper.RegisterClickEvent(self.BtnTeamPrefab, handler(self, self.OnBtnTeamPrefabClick)) +end + +function XUiPanelStrongholdRoomCharacterSelf:OnClickBtnPartner() + if self:IsRobot() then + XUiManager.TipText("StrongholdRobotRefusePartner") + return + end + XDataCenter.PartnerManager.GoPartnerCarry(self.CharacterId, false) +end + +function XUiPanelStrongholdRoomCharacterSelf:OnBtnConsciousnessClick() + if self:IsRobot() then + XUiManager.TipText("StrongholdRobotRefuseAwareness") + return + end + XLuaUiManager.Open("UiEquipAwarenessReplace", self.CharacterId, nil, true) +end + +function XUiPanelStrongholdRoomCharacterSelf:OnBtnWeaponClick() + if self:IsRobot() then + XUiManager.TipText("StrongholdRobotRefuseWeapon") + return + end + XLuaUiManager.Open("UiEquipReplaceNew", self.CharacterId, nil, true) +end + +function XUiPanelStrongholdRoomCharacterSelf:OnClickBtnFashion() + if self:IsRobot() then + XUiManager.TipText("StrongholdRobotRefuseFashion") + return + end + XLuaUiManager.Open("UiFashion", self.CharacterId) +end + +function XUiPanelStrongholdRoomCharacterSelf:OnClickBtnJoinTeam(btnSelfObj, prefabCharId, prefabMemberIndex) + local groupId = self.GroupId + local teamList = self.TeamList + local teamId = self.TeamId + + local characterId = prefabCharId or self.CharacterId + local team = self:GetTeam() + local member = self:GetMember(prefabMemberIndex) + + --电能支援 + local isElectric = XDataCenter.StrongholdManager.CheckInElectricTeam(characterId) + if isElectric then + XUiManager.TipText("StrongholdElectricDeployInElectricTeam") + return + end + + --队伍是否已上阵相同型号角色 + local sameCharacter = XDataCenter.StrongholdManager.CheckTeamListExistSameCharacter(characterId, teamList) + if sameCharacter then + local key = prefabMemberIndex and "StrongholdElectricDeployUsePrefabSameCharacter" or "StrongholdElectricDeploySameCharacter" + XUiManager.TipText(key) + return + end + + --在有关卡进度的队伍中 + local isInTeamLock = XDataCenter.StrongholdManager.CheckInTeamListLock(groupId, characterId, teamList) + if isInTeamLock then + XUiManager.TipText("StrongholdElectricDeployInTeamLock") + return + end + + local swapFunc = function() + local oldCharacterId = member:GetInTeamCharacterId() + local oldTeamId = XDataCenter.StrongholdManager.GetCharacterInTeamId(characterId, teamList) + if IsNumberValid(oldTeamId) then + --switch team + local oldTeam = teamList[oldTeamId] + local oldMember = oldTeam:GetInTeamMemberByCharacterId(characterId) + + local oldCharacterType = self:GetCharacterType(oldCharacterId) + if oldTeam:ExistDifferentCharacterType(oldCharacterType) then + oldTeam:Clear() + end + + oldMember:SetInTeam(oldCharacterId) + end + + local characterType = self:GetCharacterType(characterId) + if team:ExistDifferentCharacterType(characterType) then + --队伍中已经存在其他类型的角色(构造体/授格者)时,清空队伍 + team:Clear() + end + + member:SetInTeam(characterId) + + if self.IsUpdateTeamPrefab then + self:CheckIsCloseView() + else + self.CloseUiFunc() + end + end + + local setTeamFunc = function() + local characterType = self:GetCharacterType(characterId) + if team:ExistDifferentCharacterType(characterType) then + --队伍中已经存在其他类型的角色(构造体/授格者) + local content = CSXTextManagerGetText("TeamCharacterTypeNotSame") + self:AddDialogTipCount() + + XUiManager.DialogTip(nil, content, XUiManager.DialogType.Normal, handler(self, self.DialogCloseCallback), swapFunc) + else + swapFunc() + end + end + + local isInTeam = XDataCenter.StrongholdManager.CheckInTeamList(characterId, teamList, nil, teamId) + if isInTeam then + --在别的队伍中,可以交换 + local inTeamId = XDataCenter.StrongholdManager.GetCharacterInTeamId(characterId, teamList) + local title = CsXTextManagerGetText("StrongholdDeployTipTitle") + local showCharacterId = XRobotManager.GetCharacterId(characterId) + local characterName = XCharacterConfigs.GetCharacterName(showCharacterId) + local content = CsXTextManagerGetText("StrongholdDeployTipContent", characterName, inTeamId, teamId) + self:AddDialogTipCount() + + XUiManager.DialogTip(title, content, XUiManager.DialogType.Normal, handler(self, self.DialogCloseCallback), setTeamFunc) + else + --不在在别的队伍中,直接上阵 + setTeamFunc() + end +end + +function XUiPanelStrongholdRoomCharacterSelf:OnBtnQuitTeamClick() + local teamList = self.TeamList + local teamId = self.TeamId + local characterId = self.CharacterId + local inTeamId = XDataCenter.StrongholdManager.GetCharacterInTeamId(characterId, teamList) + if teamId ~= inTeamId then return end + + local team = self:GetTeam() + local member = team:GetInTeamMemberByCharacterId(characterId) + member:KickOutTeam() + + self.CloseUiFunc() +end + +function XUiPanelStrongholdRoomCharacterSelf:OnBtnTeamPrefabClick() + local groupId = self.GroupId + local stageIndex = self.TeamId + local stageId = not self:IsPrefab() and XDataCenter.StrongholdManager.GetGroupStageId(groupId, stageIndex) + local characterLimitType = IsNumberValid(stageId) and XFubenConfigs.GetStageCharacterLimitType(stageId) + local limitBuffId = IsNumberValid(stageId) and XFubenConfigs.GetStageCharacterLimitBuffId(stageId) + local stageType = IsNumberValid(stageId) and XFubenConfigs.GetStageType(stageId) + local closeCb = function() + if self.IsUpdateTeamPrefab and (XTool.IsNumberValid(self.DialogTipCount) or not self.IsHasOpenDialogTips) then + self.CloseUiFunc() + end + self.IsUpdateTeamPrefab = false + self.DialogTipCount = 0 + end + XLuaUiManager.Open("UiRoomTeamPrefab", nil, nil, characterLimitType, limitBuffId, stageType, nil, closeCb) +end + +function XUiPanelStrongholdRoomCharacterSelf:GetTeam() + return self.TeamList[self.TeamId] +end + +function XUiPanelStrongholdRoomCharacterSelf:GetMember(prefabMemberIndex) + local team = self:GetTeam() + local memberIndex = prefabMemberIndex or self.MemberIndex + return team:GetMember(memberIndex) +end + +function XUiPanelStrongholdRoomCharacterSelf:GetSelectCharacterType() + return self.IsSelectIsomer and XCharacterConfigs.CharacterType.Isomer or XCharacterConfigs.CharacterType.Normal +end + +function XUiPanelStrongholdRoomCharacterSelf:GetCharacterType(characterId) + characterId = characterId or self.CharacterId + if not IsNumberValid(characterId) then return end + + local showCharacterId = XRobotManager.GetCharacterId(characterId) + return XCharacterConfigs.GetCharacterType(showCharacterId) +end + +function XUiPanelStrongholdRoomCharacterSelf:IsPrefab() + return not IsNumberValid(self.GroupId) +end + +function XUiPanelStrongholdRoomCharacterSelf:IsRobot() + return XRobotManager.CheckIsRobotId(self.CharacterId) +end + +function XUiPanelStrongholdRoomCharacterSelf:GetCharacterIndex() + local selectCharacterId = self.CharacterId + if not IsNumberValid(selectCharacterId) then return -1 end + + local characterIds = self.CharacterIds + if IsTableEmpty(characterIds) then return -1 end + + for index, characterId in ipairs(characterIds) do + if selectCharacterId == characterId then + return index + end + end + + return -1 +end + +function XUiPanelStrongholdRoomCharacterSelf:CheckInCharacterIds(characterId) + if not IsNumberValid(characterId) then return false end + + local characterIds = self.CharacterIds + if IsTableEmpty(characterIds) then return false end + + for _, inCharacterId in pairs(characterIds) do + if characterId == inCharacterId then + return true + end + end + + return false +end + +function XUiPanelStrongholdRoomCharacterSelf:UpdateTeamPrefab(team) + self.IsUpdateTeamPrefab = true + self.IsCloseRoomTeamPrefab = true + + local teamData = team and team.TeamData + local firstFightPos = team and team.FirstFightPos + local captainPos = team and team.CaptainPos + + local updateTeam = function(teamData, firstFightPos, captainPos) + for index, characterId in ipairs(teamData or {}) do + self:OnClickBtnJoinTeam(nil, characterId, index) + end + + local team = self:GetTeam() + team:SetCaptainPos(captainPos) + team:SetFirstPos(firstFightPos) + end + + for _, characterId in ipairs(teamData or {}) do + if characterId > 0 then + local characterType = self:GetCharacterType(characterId) + local team = self:GetTeam() + if team:ExistDifferentCharacterType(characterType) then + local content = CSXTextManagerGetText("TeamCharacterTypeNotSame") + local sureCallback = function() + team:Clear() + updateTeam(teamData, firstFightPos, captainPos) + end + self:AddDialogTipCount() + + XUiManager.DialogTip(nil, content, XUiManager.DialogType.Normal, handler(self, self.DialogCloseCallback), sureCallback) + return + end + updateTeam(teamData, firstFightPos, captainPos) + return + end + end +end + +function XUiPanelStrongholdRoomCharacterSelf:AddDialogTipCount() + self.IsHasOpenDialogTips = true + self.DialogTipCount = self.DialogTipCount + 1 +end + +function XUiPanelStrongholdRoomCharacterSelf:DeleteDialogTipCount() + self.DialogTipCount = self.DialogTipCount - 1 +end + +function XUiPanelStrongholdRoomCharacterSelf:CheckIsCloseView() + if not self.IsUpdateTeamPrefab then + return + end + + if not XLuaUiManager.IsUiShow("UiDialog") and XTool.IsNumberValid(self.DialogTipCount) and self.IsHasOpenDialogTips then + if XLuaUiManager.IsUiShow("UiRoomTeamPrefab") then + XLuaUiManager.Close("UiRoomTeamPrefab") + end + end +end + +function XUiPanelStrongholdRoomCharacterSelf:DialogCloseCallback() + self:DeleteDialogTipCount() + self:CheckIsCloseView() +end + +return XUiPanelStrongholdRoomCharacterSelf \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdActivityResult.lua b/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdActivityResult.lua new file mode 100644 index 00000000..6c494517 --- /dev/null +++ b/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdActivityResult.lua @@ -0,0 +1,31 @@ +local CsXTextManagerGetText = CsXTextManagerGetText + +local XUiStrongholdActivityResult = XLuaUiManager.Register(XLuaUi, "UiStrongholdActivityResult") + +function XUiStrongholdActivityResult:OnAwake() + self:AutoAddListener() +end + +function XUiStrongholdActivityResult:OnStart() + self:InitView() +end + +function XUiStrongholdActivityResult:InitView() + local finishCount = XDataCenter.StrongholdManager.GetLastFinishCount() + local totalCount = XDataCenter.StrongholdManager.GetAllGroupCount() + self.TxtEndProgress.text = finishCount .. "/" .. totalCount + + local minerCount = XDataCenter.StrongholdManager.GetLastMinerCount() + self.TxtEndPeople.text = minerCount + + local totalMineral = XDataCenter.StrongholdManager.GetLastMineralCount() + self.TxtEndMineral.text = totalMineral + + local assistNum = XDataCenter.StrongholdManager.GetLastAssistCount() + local assistRewardValue = XDataCenter.StrongholdManager.GetLastAssistRewardValue() + self.TxtEndAssist.text = CsXTextManagerGetText("StrongholdRecordAssist", assistNum, assistRewardValue) +end + +function XUiStrongholdActivityResult:AutoAddListener() + self.BtnTanchuangCloseBig.CallBack = function() self:Close() end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdAnimation.lua b/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdAnimation.lua new file mode 100644 index 00000000..6c6e86a6 --- /dev/null +++ b/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdAnimation.lua @@ -0,0 +1,105 @@ +local XUiGridStrongholdBuff = require("XUi/XUiStronghold/XUiGridStrongholdBuff") + +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate +local CSXTextManagerGetText = CS.XTextManager.GetText + +local INTERVAL = XScheduleManager.SECOND + +local XUiStrongholdAnimation = XLuaUiManager.Register(XLuaUi, "UiStrongholdAnimation") + +function XUiStrongholdAnimation:OnAwake() + self.GridBuffBase.gameObject:SetActiveEx(false) + self.GridBuffBoss.gameObject:SetActiveEx(false) +end + +function XUiStrongholdAnimation:OnStart(groupId, closeCb) + self.CloseCb = closeCb + self.BossBuffGrids = {} + self.BaseBuffGrids = {} + + self.TxtNameTitle.text = XStrongholdConfigs.GetGroupName(groupId) + local isClickBtnUseDialog = true + + --据点BossBuff + local bossBuffIds = XDataCenter.StrongholdManager.GetGroupBossBuffIds(groupId) + local showBossBuff = #bossBuffIds > 0 + self.PanelBossBuffs.gameObject:SetActiveEx(showBossBuff) + + local isBossBuff = true + for index, buffId in ipairs(bossBuffIds) do + local grid = self.BossBuffGrids[index] + if not grid then + local go = index == 1 and self.GridBuffBoss or CSUnityEngineObjectInstantiate(self.GridBuffBoss, self.PanelBossBuffs) + grid = XUiGridStrongholdBuff.New(go, nil, nil, handler(self, self.StopTimes), handler(self, self.StartTimes), isClickBtnUseDialog) + self.BossBuffGrids[index] = grid + end + + grid:Refresh(buffId, isBossBuff) + grid.GameObject:SetActiveEx(true) + end + + for index = #bossBuffIds + 1, #self.BossBuffGrids do + local grid = self.BossBuffGrids[index] + if grid then + grid.GameObject:SetActiveEx(false) + end + end + + --据点BaseBuff + local baseBuffIds = XDataCenter.StrongholdManager.GetGroupBaseBuffIds(groupId) + local showBaseBuff = #baseBuffIds > 0 + self.PanelBaseBuffs.gameObject:SetActiveEx(showBaseBuff) + + local isBossBuff = false + for index, buffId in ipairs(baseBuffIds) do + local grid = self.BaseBuffGrids[index] + if not grid then + local go = index == 1 and self.GridBuffBase or CSUnityEngineObjectInstantiate(self.GridBuffBase, self.PanelBaseBuffs) + grid = XUiGridStrongholdBuff.New(go, nil, nil, handler(self, self.StopTimes), handler(self, self.StartTimes), isClickBtnUseDialog) + self.BaseBuffGrids[index] = grid + end + + grid:Refresh(buffId, isBossBuff) + grid.GameObject:SetActiveEx(true) + end + + for index = #baseBuffIds + 1, #self.BaseBuffGrids do + local grid = self.BaseBuffGrids[index] + if grid then + grid.GameObject:SetActiveEx(false) + end + end + + self.TimeSecond = XStrongholdConfigs.GetCommonConfig("UiStrongholdAnimationCloseTime") + self:StartTimes() +end + +function XUiStrongholdAnimation:OnDisable() + self:StopTimes() +end + +function XUiStrongholdAnimation:StartTimes() + self:StopTimes() + self.TxtTime.text = CSXTextManagerGetText("StrongholdAnimationClose", self.TimeSecond) + self.Times = XScheduleManager.ScheduleForever(function() + self.TimeSecond = self.TimeSecond - 1 + if self.TimeSecond == 0 then + self.CloseCb() + return + end + + if self.TimeSecond < 0 then + self:Close() + return + end + + self.TxtTime.text = CSXTextManagerGetText("StrongholdAnimationClose", self.TimeSecond) + end, INTERVAL) +end + +function XUiStrongholdAnimation:StopTimes() + if self.Times then + XScheduleManager.UnSchedule(self.Times) + self.Times = nil + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdChooseLevelType.lua b/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdChooseLevelType.lua new file mode 100644 index 00000000..c7894e3a --- /dev/null +++ b/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdChooseLevelType.lua @@ -0,0 +1,49 @@ +local CsXTextManagerGetText = CsXTextManagerGetText + +local XUiStrongholdChooseLevelType = XLuaUiManager.Register(XLuaUi, "UiStrongholdChooseLevelType") + +function XUiStrongholdChooseLevelType:OnAwake() + self:AutoAddListener() +end + +function XUiStrongholdChooseLevelType:OnStart(cb) + self.Cb = cb + self.BtnNormal:SetName(CsXTextManagerGetText("StrongholdChooseLevelTypeOne")) + self.BtnHard:SetName(CsXTextManagerGetText("StrongholdChooseLevelTypeTwo")) +end + +function XUiStrongholdChooseLevelType:AutoAddListener() + self.BtnTanchuangClose.CallBack = function() self:Close() end + self.BtnCancel.CallBack = function() self:Close() end + self.BtnNormal.CallBack = function() self:OnSelectLevelType(XStrongholdConfigs.LevelType.Medium) end + self.BtnHard.CallBack = function() self:OnSelectLevelType(XStrongholdConfigs.LevelType.High) end + self.BtnDetailsNormal.CallBack = function() self:OpenTipsUi(XStrongholdConfigs.LevelType.Medium) end + self.BtnDetailsHard.CallBack = function() self:OpenTipsUi(XStrongholdConfigs.LevelType.High) end + self.BtnConfirm.CallBack = function() self:OnClickBtnConfirm() end +end + +function XUiStrongholdChooseLevelType:OnSelectLevelType(levelType) + self.LevelType = levelType + + if levelType == XStrongholdConfigs.LevelType.Medium then + self.BtnNormal:SetButtonState(CS.UiButtonState.Select) + self.BtnHard:SetButtonState(CS.UiButtonState.Normal) + elseif levelType == XStrongholdConfigs.LevelType.High then + self.BtnNormal:SetButtonState(CS.UiButtonState.Normal) + self.BtnHard:SetButtonState(CS.UiButtonState.Select) + end +end + +function XUiStrongholdChooseLevelType:OpenTipsUi(levelType) + XLuaUiManager.Open("UiStrongholdRewardTip", levelType) +end + +function XUiStrongholdChooseLevelType:OnClickBtnConfirm() + if not self.LevelType then + XUiManager.TipText("StrongholdChooseLevelTypeEmpty") + return + end + + XDataCenter.StrongholdManager.SelectStrongholdLevelRequest(self.LevelType, self.Cb) + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdCoreTips.lua b/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdCoreTips.lua new file mode 100644 index 00000000..5552bdc3 --- /dev/null +++ b/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdCoreTips.lua @@ -0,0 +1,145 @@ +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate +local XUiGridStrongholdPluginSet = require("XUi/XUiStronghold/XUiGridStrongholdPluginSet") + +local handler = handler + +local CONDITION_COLOR = { + [true] = CS.UnityEngine.Color.red, + [false] = CS.UnityEngine.Color.black, +} + +local XUiStrongholdCoreTips = XLuaUiManager.Register(XLuaUi, "UiStrongholdCoreTips") + +function XUiStrongholdCoreTips:OnAwake() + self:AutoAddListener() + + self.GridCore.gameObject:SetActiveEx(false) +end + +function XUiStrongholdCoreTips:OnStart(teamList, teamId, groupId) + self.TeamList = teamList + self.TeamId = teamId + self.GroupId = groupId + self.PluginGrids = {} + + self:InitView() +end + +function XUiStrongholdCoreTips:OnEnable() + self.UseElectric = XDataCenter.StrongholdManager.GetTotalUseElectricEnergy(self.TeamList) + self:UpdateElectric() + self:UpdateView() +end + +function XUiStrongholdCoreTips:InitView() + local icon = XStrongholdConfigs.GetElectricIcon() + self.RImgTool1:SetRawImage(icon) + + local teamId = self.TeamId + local groupId = self.GroupId + if groupId then + self.TxtName.text = XDataCenter.StrongholdManager.GetGroupStageName(groupId, teamId) + else + self.TxtName.text = CsXTextManagerGetText("StrongholdTeamTitle", teamId) + end +end + +function XUiStrongholdCoreTips:UpdateElectric() + local useElectric = self.UseElectric + local totalElectric = XDataCenter.StrongholdManager.GetTotalElectricEnergy() + self.TxtTool1.text = useElectric .. "/" .. totalElectric + self.TxtTool1.color = CONDITION_COLOR[useElectric > totalElectric] +end + +function XUiStrongholdCoreTips:UpdateView() + local team = self:GetTeam() + local plugins = team:GetAllPlugins() + for index, plugin in ipairs(plugins) do + local grid = self.PluginGrids[index] + if not grid then + local ui = index == 1 and self.GridCore or CSUnityEngineObjectInstantiate(self.GridCore, self.PanelContent) + local checkCountCb = handler(self, self.OnCheckElectric) + local countChangeCb = handler(self, self.OnCountChange) + local getMaxCountCb = handler(self, self.GetMaxPluginCount) + grid = XUiGridStrongholdPluginSet.New(ui, checkCountCb, countChangeCb, getMaxCountCb) + self.PluginGrids[index] = grid + end + + grid:Refresh(plugin) + grid.GameObject:SetActiveEx(true) + end + for index = #plugins + 1, #self.PluginGrids do + self.PluginGrids[index].GameObject:SetActiveEx(false) + end +end + +function XUiStrongholdCoreTips:AutoAddListener() + self.BtnClose.CallBack = function() self:OnClickBtnClose() end + self.BtnTanchuangClose.CallBack = function() self:OnClickBtnClose() end + self.BtnTongBlue.CallBack = function() self:OnClickBtnConfirm() end + if self.BtnTool1 then + self.BtnTool1.CallBack = function() self:OnClickBtnTool1() end + end +end + +function XUiStrongholdCoreTips:OnClickBtnClose() + self:Close() +end + +function XUiStrongholdCoreTips:OnClickBtnConfirm() + if self:SaveChange() then + XUiManager.TipText("StrongholdPluginSetSaveSuc") + else + XUiManager.TipText("StrongholdPluginSaveFail") + end + + self:Close() +end + +function XUiStrongholdCoreTips:GetTeam() + return self.TeamList[self.TeamId] +end + +function XUiStrongholdCoreTips:OnCheckElectric(costElectric) + costElectric = costElectric or 0 + local useElectric = self.UseElectric + local totalElectric = XDataCenter.StrongholdManager.GetTotalElectricEnergy() + return useElectric + costElectric <= totalElectric +end + +function XUiStrongholdCoreTips:GetMaxPluginCount(costElectric) + costElectric = costElectric or 0 + local useElectric = self.UseElectric + local totalElectric = XDataCenter.StrongholdManager.GetTotalElectricEnergy() + return math.floor((totalElectric - useElectric) / costElectric) +end + +function XUiStrongholdCoreTips:OnCountChange(addElectric) + self.UseElectric = self.UseElectric + addElectric + self:UpdateElectric() +end + +function XUiStrongholdCoreTips:SaveChange() + -- local totalElectric = XDataCenter.StrongholdManager.GetTotalElectricEnergy() + -- if self.UseElectric > totalElectric then + -- return false + -- end + + local team = self:GetTeam() + local plugins = team:GetAllPlugins() + for index, plugin in ipairs(plugins) do + local grid = self.PluginGrids[index] + local newCount = grid and grid:GetCount() + plugin:SetCount(newCount) + end + + XEventManager.DispatchEvent(XEventId.EVENT_STRONGHOLD_PLUGIN_CHANGE_ACK) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_STRONGHOLD_PLUGIN_CHANGE_ACK) + + return true +end + +function XUiStrongholdCoreTips:OnClickBtnTool1() + local itemId = XDataCenter.StrongholdManager.GetBatteryItemId() + XLuaUiManager.Open("UiTip", itemId) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdDeploy.lua b/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdDeploy.lua new file mode 100644 index 00000000..714012d3 --- /dev/null +++ b/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdDeploy.lua @@ -0,0 +1,233 @@ +local XUiGridStrongholdTeam = require("XUi/XUiStronghold/XUiGridStrongholdTeam") + +local CsXTextManagerGetText = CsXTextManagerGetText +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate + +local CONDITION_COLOR = { + [true] = CS.UnityEngine.Color.red, + [false] = CS.UnityEngine.Color.black, +} + +local XUiStrongholdDeploy = XLuaUiManager.Register(XLuaUi, "UiStrongholdDeploy") + +function XUiStrongholdDeploy:OnAwake() + self:AutoAddListener() + + self.GridDeployTeam.gameObject:SetActiveEx(false) +end + +function XUiStrongholdDeploy:OnStart(groupId) + self.GroupId = groupId + self.TeamGrids = {} + + if self:IsPrefab() then + self.TeamList = XDataCenter.StrongholdManager.GetTeamListClipTemp(groupId) + else + self.TeamList = XDataCenter.StrongholdManager.GetTeamListTemp() + XDataCenter.StrongholdManager.KickOutInvalidMembersInTeamList(self.TeamList, groupId) + end + + self:InitView() +end + +function XUiStrongholdDeploy:OnEnable() + if self.IsEnd then return end + + if XDataCenter.StrongholdManager.OnActivityEnd() then + self.IsEnd = true + return + end + + self:UpdateElectric() + self:UpdateTeamList() +end + +function XUiStrongholdDeploy:OnDestroy() + for _, grid in pairs(self.TeamGrids) do + if grid.OnDestroy then + grid:OnDestroy() + end + end + + if not self.IsEnd and not self.IsFighting then + if self:IsPrefab() then + --预设模式下同步修改到服务端 + XDataCenter.StrongholdManager.SetStrongholdTeamRequest(self.TeamList) + else + --战斗模式下同步修改到服务端 + local isOwn = false + XDataCenter.StrongholdManager.SetStrongholdTeamRequest(self.TeamList, isOwn) + end + end +end + +function XUiStrongholdDeploy:OnGetEvents() + return { + XEventId.EVENT_STRONGHOLD_FINISH_GROUP_CHANGE, + XEventId.EVENT_STRONGHOLD_PLUGIN_CHANGE_ACK, + XEventId.EVENT_STRONGHOLD_ACTIVITY_END, + XEventId.EVENT_STRONGHOLD_RUNE_CHANGE, + } +end + +function XUiStrongholdDeploy:OnNotify(evt, ...) + if self.IsEnd then return end + + if evt == XEventId.EVENT_STRONGHOLD_FINISH_GROUP_CHANGE then + self:UpdateTeamList() + elseif evt == XEventId.EVENT_STRONGHOLD_PLUGIN_CHANGE_ACK then + self:UpdateElectric() + self:UpdateTeamList() + elseif evt == XEventId.EVENT_STRONGHOLD_RUNE_CHANGE then + self:UpdateTeamList() + elseif evt == XEventId.EVENT_STRONGHOLD_ACTIVITY_END then + if XDataCenter.StrongholdManager.OnActivityEnd() then + self.IsEnd = true + return + end + end +end + +function XUiStrongholdDeploy:InitView() + local isPrefab = self:IsPrefab() + self.TxtTiltlePrefab.gameObject:SetActiveEx(isPrefab) + self.TxtTiltle.gameObject:SetActiveEx(not isPrefab) + + local icon = XStrongholdConfigs.GetElectricIcon() + self.RImgTool1:SetRawImage(icon) +end + +function XUiStrongholdDeploy:UpdateElectric() + local useElectric = XDataCenter.StrongholdManager.GetTotalUseElectricEnergy(self.TeamList) + local totalElectric = XDataCenter.StrongholdManager.GetTotalElectricEnergy() + self.TxtTool1.text = useElectric .. "/" .. totalElectric + self.TxtTool1.color = CONDITION_COLOR[useElectric > totalElectric] +end + +function XUiStrongholdDeploy:UpdateTeamList() + local groupId = self.GroupId + local teamList = self.TeamList + + local isPrefab = self:IsPrefab() + self.BtnSupport.gameObject:SetActiveEx(not isPrefab) + self.BtnFight.gameObject:SetActiveEx(not isPrefab) + self.BtnAutoTeam.gameObject:SetActiveEx(isPrefab) + self.BtnRetreat.gameObject:SetActiveEx(not isPrefab and XDataCenter.StrongholdManager.CheckGroupHasFinishedStage(self.GroupId)) + + if not isPrefab then + --支援方案预设模式下不显示 + local isSupportActive = XDataCenter.StrongholdManager.CheckGroupSupportAcitve(groupId, teamList) + self.TxtOn.gameObject:SetActiveEx(isSupportActive) + self.TxtOff.gameObject:SetActiveEx(not isSupportActive) + end + + local requireTeamIds = XDataCenter.StrongholdManager.GetGroupRequireTeamIds(groupId) + for index, teamId in ipairs(requireTeamIds) do + local team = teamList[teamId] + + local grid = self.TeamGrids[index] + if not grid then + local go = CSUnityEngineObjectInstantiate(self.GridDeployTeam, self.PanelTeamContent) + grid = XUiGridStrongholdTeam.New(go, function() + self.IsFighting = true + end) + self.TeamGrids[index] = grid + end + + grid:Refresh(teamList, teamId, groupId, isPrefab) + grid.GameObject:SetActiveEx(true) + end + for index = #requireTeamIds + 1, #self.TeamGrids do + local grid = self.TeamGrids[index] + if grid then + grid.GameObject:SetActiveEx(false) + end + end +end + +function XUiStrongholdDeploy:AutoAddListener() + self.BtnBack.CallBack = function() self:OnClickBtnBack() end + self.BtnMainUi.CallBack = function() self:OnClickBtnMainUi() end + self.BtnFormation.CallBack = function() self:OnClickBtnFormation() end + self.BtnSupport.CallBack = function() self:OnClickBtnSupport() end + self.BtnFight.CallBack = function() self:OnClickBtnFight() end + self.BtnRetreat.CallBack = function() self:OnClickBtnRetreat() end + self.BtnAutoTeam.CallBack = function() self:OnClickBtnAutoTeam() end + if self.BtnTool1 then + self.BtnTool1.CallBack = function() self:OnClickBtnTool1() end + end +end + +function XUiStrongholdDeploy:OnClickBtnBack() + local groupId = self.GroupId + if groupId then + --返回、作战开始、主界面都会保存队伍,区别在于有关卡进度的时候:作战开始/主界面会保存当前对其他梯队的修改,返回会触发撤退的二次确认弹窗 + if not XDataCenter.StrongholdManager.CheckGroupHasFinishedStage(self.GroupId) then + self:Close() + else + self:OnClickBtnRetreat() + end + else + self:Close() + end +end + +function XUiStrongholdDeploy:OnClickBtnMainUi() + XLuaUiManager.RunMain() +end + +function XUiStrongholdDeploy:OnClickBtnFormation() + if XDataCenter.StrongholdManager.CheckTeamListEmpty(self.TeamList) then + XUiManager.TipText("StrongholdDeployQucikDeployEmpty") + return + end + + local teamList = XTool.Clone(self.TeamList) + local cb = function() + self.TeamList = teamList + self:UpdateTeamList() + end + XLuaUiManager.Open("UiStrongholdQuickDeploy", self.GroupId, teamList, cb) +end + +function XUiStrongholdDeploy:OnClickBtnSupport() + XDataCenter.StrongholdManager.OpenUiSupport(self.GroupId, self.TeamList) +end + +function XUiStrongholdDeploy:OnClickBtnFight() + self.IsFighting = true + XDataCenter.StrongholdManager.TryEnterFight(self.GroupId, nil, self.TeamList) +end + +function XUiStrongholdDeploy:OnClickBtnRetreat() + local callFunc = function() + if not XDataCenter.StrongholdManager.CheckAnyGroupHasFinishedStage() then + self:Close() + return + end + + local groupId = self.GroupId + local cb = function() + self:Close() + end + XDataCenter.StrongholdManager.ResetStrongholdGroupRequest(groupId, cb) + end + local title = CSXTextManagerGetText("StrongholdTeamRestartConfirmTitle") + local content = CSXTextManagerGetText("StrongholdTeamRestartConfirmContent") + XUiManager.DialogTip(title, content, XUiManager.DialogType.Normal, nil, callFunc) +end + +function XUiStrongholdDeploy:OnClickBtnAutoTeam() + XDataCenter.StrongholdManager.AutoTeam(self.TeamList) + self:UpdateTeamList() +end + +--预设模式 +function XUiStrongholdDeploy:IsPrefab() + return not XTool.IsNumberValid(self.GroupId) +end + +function XUiStrongholdDeploy:OnClickBtnTool1() + local itemId = XDataCenter.StrongholdManager.GetBatteryItemId() + XLuaUiManager.Open("UiTip", itemId) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdDetail.lua b/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdDetail.lua new file mode 100644 index 00000000..3b2c7e9b --- /dev/null +++ b/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdDetail.lua @@ -0,0 +1,193 @@ +local XUiGridStrongholdBuff = require("XUi/XUiStronghold/XUiGridStrongholdBuff") + +local CsXTextManagerGetText = CsXTextManagerGetText +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate + +local XUiStrongholdDetail = XLuaUiManager.Register(XLuaUi, "UiStrongholdDetail") + +function XUiStrongholdDetail:OnAwake() + self:AutoAddListener() + + self.GridCommon.gameObject:SetActiveEx(false) + self.GridBossBuff.gameObject:SetActiveEx(false) + self.GridBaseBuff.gameObject:SetActiveEx(false) + self.PanelSpecialTool.gameObject:SetActiveEx(false) +end + +function XUiStrongholdDetail:OnStart(groupId, closeCb, skipCb) + self.CloseCb = closeCb + self.SkipCb = skipCb + self.RewardGrids = {} + self.BossBuffGrids = {} + self.BaseBuffGrids = {} + + self:UpdateData(groupId) +end + +function XUiStrongholdDetail:UpdateData(groupId) + self.GroupId = groupId + XDataCenter.StrongholdManager.SetCurrentSelectGroupId(groupId) +end + +function XUiStrongholdDetail:OnEnable() + self:UpdateView() + self:UpdateEndurance() + self:UpdateSupport() +end + +function XUiStrongholdDetail:OnGetEvents() + return { + XEventId.EVENT_STRONGHOLD_FINISH_GROUP_CHANGE, + XEventId.EVENT_STRONGHOLD_ENDURANCE_CHANGE, + XEventId.EVENT_STRONGHOLD_TEAMLIST_CHANGE, + } +end + +function XUiStrongholdDetail:OnNotify(evt, ...) + if evt == XEventId.EVENT_STRONGHOLD_FINISH_GROUP_CHANGE then + self:UpdateView() + elseif evt == XEventId.EVENT_STRONGHOLD_ENDURANCE_CHANGE then + self:UpdateEndurance() + elseif evt == XEventId.EVENT_STRONGHOLD_TEAMLIST_CHANGE then + self:UpdateSupport() + end +end + +function XUiStrongholdDetail:UpdateView() + local groupId = self.GroupId + + --只有首通奖励 + local firstDrop = not XDataCenter.StrongholdManager.IsGroupFinished(groupId) + if firstDrop then + local rewardId = XDataCenter.StrongholdManager.GetGroupRewardId(groupId) + local rewards = XRewardManager.GetRewardList(rewardId) + if rewards then + for index, item in ipairs(rewards) do + local grid = self.RewardGrids[index] + + if not grid then + local ui = index == 1 and self.GridCommon or CSUnityEngineObjectInstantiate(self.GridCommon, self.PanelDropContent) + grid = XUiGridCommon.New(self, ui) + self.RewardGrids[index] = grid + end + + grid:Refresh(item) + grid.GameObject:SetActiveEx(true) + end + end + + for index = #rewards + 1, #self.RewardGrids do + self.RewardGrids[index].GameObject:SetActiveEx(false) + end + end + self.PanelDrop.gameObject:SetActiveEx(firstDrop) + + --据点描述 + local detailBg = XStrongholdConfigs.GetGroupDetailBg(groupId) + local showBg = not string.IsNilOrEmpty(detailBg) + if showBg then + self.RImgTitleBg:SetRawImage(detailBg) + self.TxtTitleWithBg.text = XStrongholdConfigs.GetGroupName(groupId) + self.TxtTipWithBg.text = XStrongholdConfigs.GetGroupDetailDesc(groupId) + else + self.TxtTitle.text = XStrongholdConfigs.GetGroupName(groupId) + self.TxtTip.text = XStrongholdConfigs.GetGroupDetailDesc(groupId) + end + self.TxtTip.gameObject:SetActiveEx(not showBg) + self.TxtTitle.gameObject:SetActiveEx(not showBg) + self.TxtTipWithBg.gameObject:SetActiveEx(showBg) + self.TxtTitleWithBg.gameObject:SetActiveEx(showBg) + self.RImgTitleBg.gameObject:SetActiveEx(showBg) + + local teamNum = XDataCenter.StrongholdManager.GetGroupRequireTeamNum(groupId) + self.TxtRequrireTeamNum.text = teamNum + + --据点BossBuff + local bossBuffIds = XDataCenter.StrongholdManager.GetGroupBossBuffIds(groupId) + local showBossBuff = #bossBuffIds > 0 + self.TxtBossBuff.gameObject:SetActiveEx(showBossBuff) + self.PanelBossBuff.gameObject:SetActiveEx(showBossBuff) + + local isBossBuff = true + for index, buffId in ipairs(bossBuffIds) do + local grid = self.BossBuffGrids[index] + if not grid then + local go = index == 1 and self.GridBossBuff or CSUnityEngineObjectInstantiate(self.GridBossBuff, self.PanelBossBuff) + grid = XUiGridStrongholdBuff.New(go, nil, self.SkipCb) + self.BossBuffGrids[index] = grid + end + + grid:Refresh(buffId, isBossBuff) + grid.GameObject:SetActiveEx(true) + end + + for index = #bossBuffIds + 1, #self.BossBuffGrids do + local grid = self.BossBuffGrids[index] + if grid then + grid.GameObject:SetActiveEx(false) + end + end + + --据点BaseBuff + local baseBuffIds = XDataCenter.StrongholdManager.GetGroupBaseBuffIds(groupId) + local showBaseBuff = #baseBuffIds > 0 + self.TxtBaseBuff.gameObject:SetActiveEx(showBaseBuff) + self.PanelBaseBuff.gameObject:SetActiveEx(showBaseBuff) + + local isBossBuff = false + for index, buffId in ipairs(baseBuffIds) do + local grid = self.BaseBuffGrids[index] + if not grid then + local go = index == 1 and self.GridBaseBuff or CSUnityEngineObjectInstantiate(self.GridBaseBuff, self.PanelBaseBuff) + grid = XUiGridStrongholdBuff.New(go, nil, self.SkipCb) + self.BaseBuffGrids[index] = grid + end + + grid:Refresh(buffId, isBossBuff) + grid.GameObject:SetActiveEx(true) + end + + for index = #baseBuffIds + 1, #self.BaseBuffGrids do + local grid = self.BaseBuffGrids[index] + if grid then + grid.GameObject:SetActiveEx(false) + end + end + +end + +function XUiStrongholdDetail:UpdateEndurance() + local groupId = self.GroupId + local costEndurance = XDataCenter.StrongholdManager.GetGroupCostEndurance(groupId) + local curEndurance = XDataCenter.StrongholdManager.GetCurEndurance() + self.TxtEndurance.text = costEndurance .. "/" .. curEndurance +end + +function XUiStrongholdDetail:UpdateSupport() + local groupId = self.GroupId + local isActive = XDataCenter.StrongholdManager.CheckGroupSupportAcitve(groupId) + self.BtnAssitantBuff:SetDisable(not isActive) +end + +function XUiStrongholdDetail:AutoAddListener() + self.BtnClose.CallBack = function() self:OnClickBtnClose() end + self.BtnEnter.CallBack = function() self:OnClickBtnEnter() end + self.BtnAssitantBuff.CallBack = function() self:OnClickBtnAssitantBuff() end +end + +function XUiStrongholdDetail:OnClickBtnClose() + self:Close() + if self.CloseCb then self.CloseCb() end +end + +function XUiStrongholdDetail:OnClickBtnEnter() + local groupId = self.GroupId + self:Close() + if self.CloseCb then self.CloseCb() end + XLuaUiManager.Open("UiStrongholdDeploy", groupId) +end + +function XUiStrongholdDetail:OnClickBtnAssitantBuff() + local groupId = self.GroupId + XDataCenter.StrongholdManager.OpenUiSupport(groupId) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdFightMain.lua b/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdFightMain.lua new file mode 100644 index 00000000..09d6bd18 --- /dev/null +++ b/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdFightMain.lua @@ -0,0 +1,141 @@ +local XUiPanelStrongholdChapter = require("XUi/XUiStronghold/XUiPanelStrongholdChapter") + +local handler = handler +local CsXTextManagerGetText = CsXTextManagerGetText + +local XUiStrongholdFightMain = XLuaUiManager.Register(XLuaUi, "UiStrongholdFightMain") + +function XUiStrongholdFightMain:OnAwake() + self:AutoAddListener() + + self.AssetActivityPanel = XUiPanelActivityAsset.New(self.PanelSpecialTool) + local itemId = XDataCenter.StrongholdManager.GetMineralItemId() + XDataCenter.ItemManager.AddCountUpdateListener(itemId, function() + self.AssetActivityPanel:Refresh({ itemId }) + end, self.AssetActivityPanel) +end + +function XUiStrongholdFightMain:OnStart(chapterId) + self.ChapterId = chapterId + + self:InitView() +end + +function XUiStrongholdFightMain:OnEnable() + if self.IsEnd then return end + + if XDataCenter.StrongholdManager.OnActivityEnd() then + self.IsEnd = true + return + end + + self.AssetActivityPanel:Refresh({ XDataCenter.StrongholdManager.GetMineralItemId() }) + + self:UpdateEndurance() + self:UpdateChapter() + + XDataCenter.StrongholdManager.CheckNewFinishGroupIds() +end + +function XUiStrongholdFightMain:OnGetEvents() + return { + XEventId.EVENT_STRONGHOLD_FINISH_GROUP_CHANGE, + XEventId.EVENT_STRONGHOLD_ENDURANCE_CHANGE, + XEventId.EVENT_STRONGHOLD_NEW_FINISH_GROUP_CHANGE, + XEventId.EVENT_STRONGHOLD_ACTIVITY_END, + } +end + +function XUiStrongholdFightMain:OnNotify(evt, ...) + if self.IsEnd then return end + + if evt == XEventId.EVENT_STRONGHOLD_FINISH_GROUP_CHANGE then + self:UpdateChapter() + elseif evt == XEventId.EVENT_STRONGHOLD_ENDURANCE_CHANGE then + self:UpdateEndurance() + elseif evt == XEventId.EVENT_STRONGHOLD_NEW_FINISH_GROUP_CHANGE then + XDataCenter.StrongholdManager.CheckNewFinishGroupIds() + elseif evt == XEventId.EVENT_STRONGHOLD_ACTIVITY_END then + if XDataCenter.StrongholdManager.OnActivityEnd() then + self.IsEnd = true + return + end + end +end + +function XUiStrongholdFightMain:InitView() + local chapterId = self.ChapterId + local name = XStrongholdConfigs.GetChapterName(chapterId) + self.TxtChapterName.text = name +end + +function XUiStrongholdFightMain:UpdateEndurance() + local curEndurance = XDataCenter.StrongholdManager.GetCurEndurance() + self.TxtEndurance.text = curEndurance +end + +function XUiStrongholdFightMain:UpdateChapter() + local chapterId = self.ChapterId + + local finishCount, totalCount = XDataCenter.StrongholdManager.GetChapterGroupProgress(chapterId) + self.TxtProgress.text = finishCount .. "/" .. totalCount + + if not self.ChapterPanel then + local prefabPath = XStrongholdConfigs.GetChapterPrefabPath(chapterId) + local ui = self.PanelNormalStageList:LoadPrefab(prefabPath) + local clickStageCb = handler(self, self.OnClickStage) + local skipCb = handler(self, self.OnSkipStage) + self.ChapterPanel = XUiPanelStrongholdChapter.New(ui, clickStageCb, skipCb) + end + + self.ChapterPanel:Refresh(chapterId) +end + +function XUiStrongholdFightMain:AutoAddListener() + self.BtnBack.CallBack = function() self:OnClickBtnBack() end + self.BtnMainUi.CallBack = function() self:OnClickBtnMainUi() end + self.BtnToEnd.CallBack = function() self:OnClickBtnToEnd() end + self.BtnActDesc.CallBack = function() self:OnClickBtnActDesc() end + self:BindHelpBtn(self.BtnHelp, "StrongholdFight") +end + +function XUiStrongholdFightMain:OnClickBtnBack() + self:Close() +end + +function XUiStrongholdFightMain:OnClickBtnMainUi() + XLuaUiManager.RunMain() +end + +function XUiStrongholdFightMain:OnClickBtnToEnd() + if self.ChapterPanel then + self.ChapterPanel:CenterToLastGrid() + end +end + +function XUiStrongholdFightMain:OnClickBtnActDesc() + local description = XUiHelper.ConvertLineBreakSymbol(CsXTextManagerGetText("StrongholdUiFightMainActDes")) + XUiManager.UiFubenDialogTip("", description) +end + +function XUiStrongholdFightMain:OnClickStage(groupId) + local closeCb = handler(self, self.OnStageDetailClose) + local skipCb = handler(self, self.OnSkipStage) + local childUi = self:FindChildUiObj("UiStrongholdDetail") + if childUi then + childUi:UpdateData(groupId) + end + self:OpenOneChildUi("UiStrongholdDetail", groupId, closeCb, skipCb) +end + +function XUiStrongholdFightMain:OnStageDetailClose() + self.ChapterPanel:OnStageDetailClose() +end + +function XUiStrongholdFightMain:OnSkipStage(skipGroupId) + local childUi = self:FindChildUiObj("UiStrongholdDetail") + if childUi then + childUi:OnClickBtnClose() + end + self.ChapterPanel:OnSkipStage(skipGroupId) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdFightSettleWin.lua b/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdFightSettleWin.lua new file mode 100644 index 00000000..9de7f64e --- /dev/null +++ b/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdFightSettleWin.lua @@ -0,0 +1,120 @@ +local XUiPanelExpBar = require("XUi/XUiSettleWinMainLine/XUiPanelExpBar") +local XUiGridRewardLine = require("XUi/XUiStronghold/XUiGridRewardLine") + +local handler = handler +local CsXTextManagerGetText = CsXTextManagerGetText + +local XUiStrongholdFightSettleWin = XLuaUiManager.Register(XLuaUi, "UiStrongholdFightSettleWin") + +function XUiStrongholdFightSettleWin:OnAwake() + self:AutoAddListener() + self:InitDynamicTable() + + self.GridRewardLine.gameObject:SetActiveEx(false) +end + +function XUiStrongholdFightSettleWin:OnStart(data) + self.WinData = data + self:InitInfo(data) +end + +function XUiStrongholdFightSettleWin:OnDestroy() + XDataCenter.AntiAddictionManager.EndFightAction() +end + +function XUiStrongholdFightSettleWin:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelRewards) + self.DynamicTable:SetDelegate(self) + self.DynamicTable:SetProxy(XUiGridRewardLine) +end + +function XUiStrongholdFightSettleWin:AutoAddListener() + self.BtnConfirm.CallBack = handler(self, self.OnClickBtnConfirm) +end + +function XUiStrongholdFightSettleWin:OnClickBtnConfirm() + self:Close() +end + +function XUiStrongholdFightSettleWin:InitInfo(data) + self:UpdatePlayerInfo(data) + self:UpdateDynamicTable(data.SettleData.StrongholdFightResult) + self:CheckIsOpenStrongholdMinerUp(data.SettleData.StrongholdFightResult.GroupFightResultInfos) +end + +-- 玩家经验 +function XUiStrongholdFightSettleWin:UpdatePlayerInfo(data) + if not data or not next(data) then return end + + local lastLevel = data.RoleLevel + local lastExp = data.RoleExp + local lastMaxExp = XPlayerManager.GetMaxExp(lastLevel, XPlayer.IsHonorLevelOpen()) + local curLevel = XPlayer.GetLevelOrHonorLevel() + local curExp = XPlayer.Exp + local curMaxExp = XPlayerManager.GetMaxExp(curLevel, XPlayer.IsHonorLevelOpen()) + local txtLevelName = XPlayer.IsHonorLevelOpen() and CS.XTextManager.GetText("HonorLevel") or nil + + local addExp = 0--你知道有多恶心? + local rewardLineList = data.SettleData.StrongholdFightResult.GroupFightResultInfos + for _, info in pairs(rewardLineList or {}) do + local rewardGoodsList = info.RewardGoodsList or {} + local rewards = XRewardManager.MergeAndSortRewardGoodsList(rewardGoodsList) + for idx, item in ipairs(rewards) do + if item.Id == XDataCenter.ItemManager.ItemId.TeamExp then + addExp = addExp + XDataCenter.ItemManager.GetTeamExp() * item.Count + end + end + end + + self.PlayerExpBar = self.PlayerExpBar or XUiPanelExpBar.New(self.PanelPlayerExpBar) + self.PlayerExpBar:LetsRoll(lastLevel, lastExp, lastMaxExp, curLevel, curExp, curMaxExp, addExp, txtLevelName) +end + +--[[ +// 战斗结算数据 +[MessagePackObject(keyAsPropertyName: true)] +public class StrongholdFightResult +{ + public List GroupFightResultInfos = new List(); +} +]] +function XUiStrongholdFightSettleWin:UpdateDynamicTable(result) + local rewardLineList = result.GroupFightResultInfos + + local isMulti = #rewardLineList > 1 + self.TxtStageName.gameObject:SetActiveEx(isMulti) + + self.RewardLineList = rewardLineList + self.DynamicTable:SetDataSource(self.RewardLineList) + self.DynamicTable:ReloadDataSync(-1) +end + +function XUiStrongholdFightSettleWin:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:InitRootUi(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local rewardGoodsList = self.RewardLineList[index] + grid:Refresh(rewardGoodsList) + end +end + +function XUiStrongholdFightSettleWin:CheckIsOpenStrongholdMinerUp(groupFightResultInfos) + local minerItemId = XDataCenter.StrongholdManager.GetMinerItemId() + local oldMinerCount = XDataCenter.StrongholdManager.GetCookieMinerCount() + local maxCount = XDataCenter.ItemManager.GetMaxCount(minerItemId) + + local addMinerCount = 0 + for _, groupFightResultInfo in ipairs(groupFightResultInfos) do + for _, v in ipairs(groupFightResultInfo.RewardGoodsList) do + if v.TemplateId == minerItemId then + addMinerCount = addMinerCount + v.Count + end + end + end + + if oldMinerCount ~= maxCount and addMinerCount > 0 then + local lastGroupFightResultInfos = groupFightResultInfos and groupFightResultInfos[#groupFightResultInfos] + local groupId = lastGroupFightResultInfos and lastGroupFightResultInfos.GroupId + XLuaUiManager.Open("UiStrongholdMinerUp", groupId) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdHelp.lua b/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdHelp.lua new file mode 100644 index 00000000..4d3a6770 --- /dev/null +++ b/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdHelp.lua @@ -0,0 +1,105 @@ +local CsXTextManagerGetText = CsXTextManagerGetText + +local XUiStrongholdHelp = XLuaUiManager.Register(XLuaUi, "UiStrongholdHelp") + +function XUiStrongholdHelp:OnAwake() + self:AutoAddListener() + self:InitDynamicTable() + + self.TxtReward.gameObject:SetActiveEx(false) + + self.ImgEmpty = self.GameObject:FindTransform("ImgEmpty") +end + +function XUiStrongholdHelp:OnEnable() + self:UpdateView() +end + +function XUiStrongholdHelp:OnGetEvents() + return { + XEventId.EVENT_STRONGHOLD_ASSISTANT_CHARACTER_SET_CHANGE, + } +end + +function XUiStrongholdHelp:OnNotify(evt, ...) + local args = { ... } + if evt == XEventId.EVENT_STRONGHOLD_ASSISTANT_CHARACTER_SET_CHANGE then + self:UpdateView() + end +end + +function XUiStrongholdHelp:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.ScrollReward) + local class = XClass(nil, "") + class.Ctor = function(o, go) XTool.InitUiObjectByUi(o, go) end + self.DynamicTable:SetProxy(class) + self.DynamicTable:SetDelegate(self) +end + +function XUiStrongholdHelp:UpdateView() + if not XDataCenter.StrongholdManager.IsHaveAssistantCharacter() then + + self.TxtTips.text = XUiHelper.ConvertLineBreakSymbol(CsXTextManagerGetText("StrongholdSetAssistTips")) + + self.ImgAdd.gameObject:SetActiveEx(true) + self.ImgEmptyRole.gameObject:SetActiveEx(true) + self.PanelRoleInformation.gameObject:SetActiveEx(false) + self.RImgRole.gameObject:SetActiveEx(false) + self.PanelHint.gameObject:SetActiveEx(false) + + else + + local characterId = XDataCenter.StrongholdManager.GetAssistantCharacterId() + + local icon = XDataCenter.CharacterManager.GetCharHalfBodyBigImage(characterId) + self.RImgRole:SetRawImage(icon) + + local ability = XDataCenter.CharacterManager.GetCharacterAbilityById(characterId) + self.TxtAbility.text = ability + + local name = XCharacterConfigs.GetCharacterFullNameStr(characterId) + self.TxtName.text = name + + self.Records = XDataCenter.StrongholdManager.GetAssitantRecordStrList() + self.DynamicTable:SetDataSource(self.Records) + self.DynamicTable:ReloadDataASync() + + local isEmpty = XTool.IsTableEmpty(self.Records) + self.ImgAdd.gameObject:SetActiveEx(isEmpty) + self.ImgEmpty.gameObject:SetActiveEx(isEmpty) + + self.ImgAdd.gameObject:SetActiveEx(false) + self.ImgEmptyRole.gameObject:SetActiveEx(false) + self.PanelRoleInformation.gameObject:SetActiveEx(true) + self.RImgRole.gameObject:SetActiveEx(true) + self.PanelHint.gameObject:SetActiveEx(true) + end +end + +function XUiStrongholdHelp:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local record = self.Records[index] + grid.TxtReward.text = record + end +end + +function XUiStrongholdHelp:AutoAddListener() + self.BtnClose.CallBack = function() self:Close() end + self.BtnTanchuangClose.CallBack = function() self:Close() end + self.BtnOccupy.CallBack = function() self:OnClickBtnOccupy() end +end + +function XUiStrongholdHelp:OnClickBtnOccupy() + local characterId = nil + local supportData = { + CanSupportCancel = false, + CheckInSupportCb = function(characterId) + return XDataCenter.StrongholdManager.CheckIsAssistantCharacter(characterId) + end, + SetCharacterCb = function(characterId, cb) + XDataCenter.StrongholdManager.SetStrongholdAssistCharacterRequest(characterId, cb) + return true + end, + } + XLuaUiManager.Open("UiCharacter", characterId, nil, nil, nil, nil, nil, supportData) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdInfo.lua b/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdInfo.lua new file mode 100644 index 00000000..e106fec3 --- /dev/null +++ b/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdInfo.lua @@ -0,0 +1,35 @@ +local pairs = pairs + +local CHARACTER_NUM = 3 +local ANIMATION_PANEL = { + "PanelStageList01", + "PanelStageList02", + "PanelStageList03", + "PanelStageList04", + "PanelStageList05", +} + +local XUiStrongholdInfo = XLuaUiManager.Register(XLuaUi, "UiStrongholdInfo") + +function XUiStrongholdInfo:OnStart(groupId, stageIndex) + for index, name in pairs(ANIMATION_PANEL) do + self[name].gameObject:SetActiveEx(index == stageIndex) + end + + local teamId = stageIndex + local teamList = XDataCenter.StrongholdManager.GetTeamListClipTemp(groupId) + local characterIds = XDataCenter.StrongholdManager.GetTeamShowCharacterIds(teamId, teamList) + for index = 1, CHARACTER_NUM do + local characterId = characterIds[index] + if XTool.IsNumberValid(characterId) then + self["RImgCharIcon" .. index]:SetRawImage(XDataCenter.CharacterManager.GetCharBigRoundnessNotItemHeadIcon(characterId)) + self["PanelCharIcon" .. index].gameObject:SetActiveEx(true) + else + self["PanelCharIcon" .. index].gameObject:SetActiveEx(false) + end + end + + self.TxtZhangjie.text = XStrongholdConfigs.GetGroupOrder(groupId) + self.TxtGroupName.text = XStrongholdConfigs.GetGroupName(groupId) + self.TxtName.text = CsXTextManagerGetText("StrongholdTeamIndex", stageIndex) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdJournal/XUiGridRecord.lua b/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdJournal/XUiGridRecord.lua new file mode 100644 index 00000000..546b5e88 --- /dev/null +++ b/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdJournal/XUiGridRecord.lua @@ -0,0 +1,51 @@ +local CsXTextManagerGetText = CsXTextManagerGetText + +local XUiGridRecord = XClass(nil, "XUiGridRecord") + +function XUiGridRecord:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + + self.OldPanel = XTool.InitUiObjectByUi({}, self.PanelOld) + self.CurPanel = XTool.InitUiObjectByUi({}, self.PanelCur) + self.FururePanel = XTool.InitUiObjectByUi({}, self.PanelFuture) +end + +function XUiGridRecord:Refresh(record) + self.Record = record + + local day = record.Day + local curDay = XDataCenter.StrongholdManager.GetCurDay() + if day < curDay then + self.SelectPanel = self.OldPanel + self.OldPanel.GameObject:SetActiveEx(true) + self.CurPanel.GameObject:SetActiveEx(false) + self.FururePanel.GameObject:SetActiveEx(false) + elseif day == curDay then + self.SelectPanel = self.CurPanel + self.OldPanel.GameObject:SetActiveEx(false) + self.CurPanel.GameObject:SetActiveEx(true) + self.FururePanel.GameObject:SetActiveEx(false) + else + self.SelectPanel = self.FururePanel + self.OldPanel.GameObject:SetActiveEx(false) + self.CurPanel.GameObject:SetActiveEx(false) + self.FururePanel.GameObject:SetActiveEx(true) + end + + self:RefreshPanel() +end + +function XUiGridRecord:RefreshPanel() + local panel = self.SelectPanel + local record = self.Record + + panel.TxtDay.text = CsXTextManagerGetText("StrongholdJournalDay", XTool.ConvertNumberString(record.Day)) + panel.TxtPeople.text = record.MinerCount + panel.TxtMineral.text = record.MineralCount + panel.TxtMineralTotal.text = record.TotalMineralCount +end + +return XUiGridRecord \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdJournal/XUiStrongholdJournal.lua b/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdJournal/XUiStrongholdJournal.lua new file mode 100644 index 00000000..3a41128c --- /dev/null +++ b/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdJournal/XUiStrongholdJournal.lua @@ -0,0 +1,72 @@ +local XUiGridRecord = require("XUi/XUiStronghold/XUiStrongholdJournal/XUiGridRecord") + +local CsXTextManagerGetText = CsXTextManagerGetText + +local CONDITION_COLOR_FOR_TEXT = { + [true] = XUiHelper.Hexcolor2Color("ff3f3f"), + [false] = XUiHelper.Hexcolor2Color("000000"), +} + +local XUiStrongholdJournal = XLuaUiManager.Register(XLuaUi, "UiStrongholdJournal") + +function XUiStrongholdJournal:OnAwake() + self:AutoAddListener() + self:InitDynamicTable() + + self.GridRecord.gameObject:SetActiveEx(false) +end + +function XUiStrongholdJournal:OnEnable() + self:UpdatePauseDays() + self:UpdateView() +end + +function XUiStrongholdJournal:OnGetEvents() + return { + XEventId.EVENT_STRONGHOLD_MINERAL_RECORD_CHANGE, + XEventId.EVENT_STRONGHOLD_PAUSE_DAY_CHANGE, + } +end + +function XUiStrongholdJournal:OnNotify(evt, ...) + if evt == XEventId.EVENT_STRONGHOLD_MINERAL_RECORD_CHANGE then + self:UpdateView() + elseif evt == XEventId.EVENT_STRONGHOLD_PAUSE_DAY_CHANGE then + self:UpdatePauseDays() + end +end + +function XUiStrongholdJournal:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.SView) + self.DynamicTable:SetProxy(XUiGridRecord) + self.DynamicTable:SetDelegate(self) +end + +function XUiStrongholdJournal:UpdatePauseDays() + local isPaused = XDataCenter.StrongholdManager.IsDayPaused() + if isPaused then + local countTime = XDataCenter.StrongholdManager.GetDelayCountTimeStr() + self.TxtTips.text = CsXTextManagerGetText("StrongholdJournalTipsDelay", countTime) + else + local countTime = XDataCenter.StrongholdManager.GetCountTimeStr() + self.TxtTips.text = CsXTextManagerGetText("StrongholdJournalTips", countTime) + end + self.TxtTips.color = CONDITION_COLOR_FOR_TEXT[isPaused] +end + +function XUiStrongholdJournal:UpdateView() + self.Records = XDataCenter.StrongholdManager.GetMineRecordsForShow() + self.DynamicTable:SetDataSource(self.Records) + self.DynamicTable:ReloadDataASync() +end + +function XUiStrongholdJournal:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local record = self.Records[index] + grid:Refresh(record) + end +end + +function XUiStrongholdJournal:AutoAddListener() + self.BtnClose.CallBack = function() self:Close() end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdMain.lua b/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdMain.lua new file mode 100644 index 00000000..0bd8c86e --- /dev/null +++ b/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdMain.lua @@ -0,0 +1,560 @@ +local mathFloor = math.floor +local Lerp = CS.UnityEngine.Mathf.Lerp +local CSXScheduleManagerUnSchedule = XScheduleManager.UnSchedule +local CsXTextManagerGetText = CsXTextManagerGetText + +local SCORE_ANIM_DURATION = 1--分数滚动动画时间 +local CONDITION_COLOR = { + [true] = CS.UnityEngine.Color.red, + [false] = CS.UnityEngine.Color.white, +} +local CONDITION_COLOR_FOR_TEXT = { + [true] = XUiHelper.Hexcolor2Color("ff3f3f"), + [false] = XUiHelper.Hexcolor2Color("59f5ff"), +} + +local XUiStrongholdMain = XLuaUiManager.Register(XLuaUi, "UiStrongholdMain") + +function XUiStrongholdMain:OnAwake() + self:AutoAddListener() + + self.AssetActivityPanel = XUiPanelActivityAsset.New(self.PanelSpecialTool) + local itemId = XDataCenter.StrongholdManager.GetMineralItemId() + XDataCenter.ItemManager.AddCountUpdateListener(itemId, function() + self.AssetActivityPanel:Refresh({ itemId }) + end, self.AssetActivityPanel) + + self.ImgUpEnergy.gameObject:SetActiveEx(false) + self.ImgUpMine.gameObject:SetActiveEx(false) + self.ImgUpPeople.gameObject:SetActiveEx(false) +end + +function XUiStrongholdMain:OnStart() + self:InitView() + + --上期战报 + if XDataCenter.StrongholdManager.CheckShowLastActivityRecord() then + XLuaUiManager.Open("UiStrongholdActivityResult") + XDataCenter.StrongholdManager.SetCookieGetCookieLastActivityRecord() + end + + --在线重置后若重新进入活动,清除Flag + XDataCenter.StrongholdManager.ClearActivityEnd() +end + +function XUiStrongholdMain:OnEnable() + if self.IsEnd then return end + + --当从其他界面返回时检查活动是否被在线重置过 + if XDataCenter.StrongholdManager.OnActivityEnd() then + self.IsEnd = true + return + end + + self.AssetActivityPanel:Refresh({ XDataCenter.StrongholdManager.GetMineralItemId() }) + self:UpdateLeftTime() + self:UpdateCurDay() + self:UpdateEndurance() + self:UpdateActivityStatus() + self:UpdateMine() + self:UpdateElectric() + self:UpdateAssistant() + self:UpdateProgress() + self:UpdateRewards() + + XDataCenter.StrongholdManager.CheckCookieAssistantFirstOpen() +end + +function XUiStrongholdMain:OnDisable() + XCountDown.UnBindTimer(self, XCountDown.GTimerName.Stronghold) + self:DestroyMineTimer() + self:DestroyElectricTimer() + + self.ImgUpEnergy.gameObject:SetActiveEx(false) + self.ImgUpMine.gameObject:SetActiveEx(false) + self.ImgUpPeople.gameObject:SetActiveEx(false) +end + +function XUiStrongholdMain:OnGetEvents() + return { + XEventId.EVENT_STRONGHOLD_CUR_DAY_CHANGE, + XEventId.EVENT_STRONGHOLD_ACTIVITY_STATUS_CHANGE, + XEventId.EVENT_STRONGHOLD_PAUSE_DAY_CHANGE, + XEventId.EVENT_STRONGHOLD_MINERAL_LEFT_CHANGE, + XEventId.EVENT_STRONGHOLD_ENDURANCE_CHANGE, + XEventId.EVENT_STRONGHOLD_MAX_ELECTRIC_CHANGE, + XEventId.EVENT_STRONGHOLD_TEAMLIST_CHANGE, + XEventId.EVENT_STRONGHOLD_SHARE_CHARACTER_CHANGE, + XEventId.EVENT_STRONGHOLD_FINISH_GROUP_CHANGE, + XEventId.EVENT_STRONGHOLD_FINISH_REWARDS_CHANGE, + XEventId.EVENT_STRONGHOLD_ACTIVITY_END, + XEventId.EVENT_STRONGHOLD_ACTIVITY_RESULT_CHANGE, + } +end + +function XUiStrongholdMain:OnNotify(evt, ...) + if self.IsEnd then return end + + local args = { ... } + if evt == XEventId.EVENT_STRONGHOLD_CUR_DAY_CHANGE then + self:UpdateCurDay() + elseif evt == XEventId.EVENT_STRONGHOLD_ACTIVITY_STATUS_CHANGE + or evt == XEventId.EVENT_STRONGHOLD_PAUSE_DAY_CHANGE then + self.AssetActivityPanel:Refresh({ XDataCenter.StrongholdManager.GetMineralItemId() }) + self:UpdateActivityStatus() + self:UpdateMine() + self:UpdateElectric() + self:UpdateLeftTime() + self:UpdateAssistant() + self:UpdateRewards() + self:UpdateEndurance() + elseif evt == XEventId.EVENT_STRONGHOLD_MINERAL_LEFT_CHANGE then + self:UpdateMine() + elseif evt == XEventId.EVENT_STRONGHOLD_ENDURANCE_CHANGE then + self:UpdateEndurance() + elseif evt == XEventId.EVENT_STRONGHOLD_TEAMLIST_CHANGE + or evt == XEventId.EVENT_STRONGHOLD_MAX_ELECTRIC_CHANGE then + self:UpdateElectric() + elseif evt == XEventId.EVENT_STRONGHOLD_SHARE_CHARACTER_CHANGE then + self:UpdateAssistant() + elseif evt == XEventId.EVENT_STRONGHOLD_FINISH_GROUP_CHANGE then + self:UpdateProgress() + elseif evt == XEventId.EVENT_STRONGHOLD_FINISH_REWARDS_CHANGE then + self:UpdateRewards() + elseif evt == XEventId.EVENT_STRONGHOLD_ACTIVITY_END then + if XDataCenter.StrongholdManager.OnActivityEnd() then + self.IsEnd = true + return + end + elseif evt == XEventId.EVENT_STRONGHOLD_ACTIVITY_RESULT_CHANGE then + self:UpdatePanelEnd() + end +end + +function XUiStrongholdMain:InitView() + local name = XStrongholdConfigs.GetActivityName() + self.TxtName = name + self.TxtTitleEnd = name + + local levelId = XDataCenter.StrongholdManager.GetLevelId() + + local levelName = XStrongholdConfigs.GetLevelName(levelId) + self.TxtLevelName.text = levelName + + local minLevel, maxLevel = XStrongholdConfigs.GetLevelLimit(levelId) + self.TxtLevel.text = CsXTextManagerGetText("StrongholdLevelLimit", minLevel, maxLevel) + + local levelIcon = XStrongholdConfigs.GetLevelIcon(levelId) + self:SetUiSprite(self.ImgIconLevel, levelIcon) +end + +function XUiStrongholdMain:UpdateLeftTime() + if XDataCenter.StrongholdManager.IsActivityBegin() then + self.TxtSection.text = CsXTextManagerGetText("StrongholdSectionOne") + self.TxtSection.gameObject:SetActiveEx(true) + elseif XDataCenter.StrongholdManager.IsFightBegin() then + self.TxtSection.text = CsXTextManagerGetText("StrongholdSectionTwo") + self.TxtSection.gameObject:SetActiveEx(true) + else + self.TxtSection.gameObject:SetActiveEx(false) + end + + XCountDown.UnBindTimer(self, XCountDown.GTimerName.Stronghold) + XCountDown.BindTimer(self, XCountDown.GTimerName.Stronghold, function(time) + time = time > 0 and time or 0 + local timeText = XUiHelper.GetTime(time, XUiHelper.TimeFormatType.STRONGHOLD) + if XDataCenter.StrongholdManager.IsActivityBegin() then + self.TxtTime.text = CsXTextManagerGetText("StrongholdActivityTimeActivityBegin", timeText) + elseif XDataCenter.StrongholdManager.IsFightBegin() then + self.TxtTime.text = CsXTextManagerGetText("StrongholdActivityTimeFightBegin", timeText) + elseif XDataCenter.StrongholdManager.IsFightEnd() then + self.TxtTimeEnd.text = CsXTextManagerGetText("StrongholdActivityTimeFightEndExtra", timeText) + end + end) +end + +function XUiStrongholdMain:UpdateCurDay() + local curDay = XDataCenter.StrongholdManager.GetCurDay() + self.TxtDay.text = curDay + + local totalDay = XDataCenter.StrongholdManager.GetTotalDay() + self.TxtTotalDay.text = "/" .. totalDay +end + +function XUiStrongholdMain:UpdateEndurance() + local curEndurance = XDataCenter.StrongholdManager.GetCurEndurance() + self.TxtEndurance.text = CsXTextManagerGetText("StrongholdEndurance", curEndurance) + + local maxEndurance = XDataCenter.StrongholdManager.GetMaxEndurance() + local maxLimitEndurance = XDataCenter.StrongholdManager.GetMaxLimitEndurance() + + if maxEndurance < maxLimitEndurance then + local isPaused = XDataCenter.StrongholdManager.IsDayPaused() + if isPaused then + local countTime = XDataCenter.StrongholdManager.GetDelayCountTimeStr() + self.TxtEnduranceTime.text = CsXTextManagerGetText("StrongholdEnduranceTimeDelay", countTime) + else + local countTime = XDataCenter.StrongholdManager.GetCountTimeStr() + self.TxtEnduranceTime.text = CsXTextManagerGetText("StrongholdEnduranceTime", countTime) + end + self.TxtEnduranceTime.color = CONDITION_COLOR_FOR_TEXT[isPaused] + self.TxtEnduranceTime.gameObject:SetActiveEx(true) + else + self.TxtEnduranceTime.gameObject:SetActiveEx(false) + end +end + +function XUiStrongholdMain:UpdateProgress() + local finishCount = XDataCenter.StrongholdManager.GetFinishGroupCount() + local totalCount = XDataCenter.StrongholdManager.GetAllGroupCount() + self.TxtJd.text = finishCount .. "/" .. totalCount + self.ImgJd.fillAmount = totalCount ~= 0 and finishCount / totalCount or 0 +end + +function XUiStrongholdMain:UpdateRewards() + local isShowRed = XDataCenter.StrongholdManager.IsAnyRewardCanGet() + self.BtnReward:ShowReddot(isShowRed) +end + +function XUiStrongholdMain:UpdateActivityStatus() + if XDataCenter.StrongholdManager.IsActivityBegin() then + + self.PanelFighting.gameObject:SetActiveEx(true) + self.PanelEnd.gameObject:SetActiveEx(false) + self.PanelTime.gameObject:SetActiveEx(false) + self.PanelEndurance.gameObject:SetActiveEx(false) + self.BtnFight.gameObject:SetActiveEx(true) + self.BtnTeam.gameObject:SetActiveEx(true) + self.BtnReward.gameObject:SetActiveEx(true) + if self.PanelMineTime then + self.PanelMineTime.gameObject:SetActiveEx(false) + end + self.BtnPower:ShowTag(false) + self.BtnStop.gameObject:SetActiveEx(false) + elseif XDataCenter.StrongholdManager.IsFightBegin() then + + self.PanelFighting.gameObject:SetActiveEx(true) + self.PanelEnd.gameObject:SetActiveEx(false) + self.PanelTime.gameObject:SetActiveEx(true) + self.PanelEndurance.gameObject:SetActiveEx(true) + self.BtnFight.gameObject:SetActiveEx(true) + self.BtnTeam.gameObject:SetActiveEx(true) + self.BtnReward.gameObject:SetActiveEx(true) + if self.PanelMineTime then + self.PanelMineTime.gameObject:SetActiveEx(true) + end + self.BtnPower:ShowTag(true) + self.BtnStop.gameObject:SetActiveEx(true) + elseif XDataCenter.StrongholdManager.IsFightEnd() then + + self.PanelFighting.gameObject:SetActiveEx(false) + self.PanelEnd.gameObject:SetActiveEx(true) + self.PanelTime.gameObject:SetActiveEx(false) + self.PanelEndurance.gameObject:SetActiveEx(false) + self.BtnFight.gameObject:SetActiveEx(false) + self.BtnTeam.gameObject:SetActiveEx(false) + self.BtnReward.gameObject:SetActiveEx(false) + if self.PanelMineTime then + self.PanelMineTime.gameObject:SetActiveEx(true) + end + self.BtnPower:ShowTag(true) + self.BtnStop.gameObject:SetActiveEx(false) + + self:UpdatePanelEnd() + + end +end + +--矿场相关 +function XUiStrongholdMain:UpdateMine() + local isPaused = XDataCenter.StrongholdManager.IsDayPaused() + if isPaused then + local countTime = XDataCenter.StrongholdManager.GetDelayCountTimeStr() + self.TxtMineTime.text = CsXTextManagerGetText("StrongholdMineTimeDelay", countTime) + else + local countTime = XDataCenter.StrongholdManager.GetCountTimeStr() + self.TxtMineTime.text = CsXTextManagerGetText("StrongholdMineTime", countTime) + end + self.TxtMineTime.color = CONDITION_COLOR_FOR_TEXT[isPaused] + + local oldMinerCount = XDataCenter.StrongholdManager.GetCookieMinerCount() + local minerCount = XDataCenter.StrongholdManager.GetMinerCount() + local changeCount = oldMinerCount > 0 and minerCount - oldMinerCount or 0 + if changeCount > 0 then + self:PlayMineUpAnim(oldMinerCount, minerCount) + else + local mineralCount = XDataCenter.StrongholdManager.GetMineralOutput(minerCount) + self.TxtPeople.text = minerCount + self.TxtMine.text = mineralCount + end + + XDataCenter.StrongholdManager.SetCookieMinerCount(minerCount) + + local isShow = XRedPointConditionStrongholdMineralLeft.Check() + self.BtnMine:ShowReddot(isShow) +end + +--电厂相关 +function XUiStrongholdMain:UpdateElectric() + local isPaused = XDataCenter.StrongholdManager.IsDayPaused() + if isPaused then + local countTime = XDataCenter.StrongholdManager.GetDelayCountTimeStr() + self.TxtElectricTime.text = CsXTextManagerGetText("StrongholdElectricTimeDelay", countTime) + else + local countTime = XDataCenter.StrongholdManager.GetCountTimeStr() + self.TxtElectricTime.text = CsXTextManagerGetText("StrongholdElectricTime", countTime) + end + self.TxtElectricTime.color = CONDITION_COLOR_FOR_TEXT[isPaused] + + local oldCount = XDataCenter.StrongholdManager.GetCookieElectricEnergy() + local curCount = XDataCenter.StrongholdManager.GetTotalElectricEnergy() + local changeCount = oldCount > 0 and curCount - oldCount or 0 + if changeCount > 0 then + self:PlayElectricUpAnim(oldCount, curCount) + else + self.TxtEnergyLimit.text = curCount + end + + XDataCenter.StrongholdManager.SetCookieElectricEnergy(curCount) + + local useElectric = XDataCenter.StrongholdManager.GetTotalUseElectricEnergy() + self.TxtEnergyUse.text = useElectric + self.TxtEnergyUse.color = CONDITION_COLOR[useElectric > curCount] +end + +--支援角色 +function XUiStrongholdMain:UpdateAssistant() + if not XDataCenter.StrongholdManager.CheckAssistantOpen() then + self.BtnAssistance.gameObject:SetActiveEx(false) + return + end + self.BtnAssistance.gameObject:SetActiveEx(true) + + if XDataCenter.StrongholdManager.IsHaveAssistantCharacter() then + local characterId = XDataCenter.StrongholdManager.GetAssistantCharacterId() + local icon = XDataCenter.CharacterManager.GetCharBigRoundnessNotItemHeadIcon(characterId) + self.RImgAssistantRole:SetRawImage(icon) + self.RImgAssistantRole.gameObject:SetActiveEx(true) + else + self.RImgAssistantRole.gameObject:SetActiveEx(false) + end +end + +--活动战报 +function XUiStrongholdMain:UpdatePanelEnd() + local finishCount = XDataCenter.StrongholdManager.GetLastFinishCount() + local totalCount = XDataCenter.StrongholdManager.GetAllGroupCount() + self.TxtEndProgress.text = finishCount .. "/" .. totalCount + + local minerCount = XDataCenter.StrongholdManager.GetLastMinerCount() + self.TxtEndPeople.text = minerCount + + local totalMineral = XDataCenter.StrongholdManager.GetLastMineralCount() + self.TxtEndMineral.text = totalMineral + + local assistNum = XDataCenter.StrongholdManager.GetLastAssistCount() + self.TxtEndAssist.text = assistNum +end + +function XUiStrongholdMain:AutoAddListener() + self.BtnBack.CallBack = function() self:OnClickBtnBack() end + self.BtnMainUi.CallBack = function() self:OnClickBtnMainUi() end + self:BindHelpBtn(self.BtnHelp, "StrongholdMain") + self.BtnShop.CallBack = function() self:OnClickBtnShop() end + self.BtnReward.CallBack = function() self:OnClickBtnReward() end + self.BtnMine.CallBack = function() self:OnClickBtnMine() end + self.BtnPower.CallBack = function() self:OnClickBtnPower() end + self.BtnTeam.CallBack = function() self:OnClickBtnTeam() end + self.BtnAssistance.CallBack = function() self:OnClickBtnAssistance() end + self.BtnFight.CallBack = function() self:OnClickBtnFight() end + self.BtnStop.CallBack = function() self:OnClickBtnStop() end +end + +function XUiStrongholdMain:OnClickBtnBack() + self:Close() +end + +function XUiStrongholdMain:OnClickBtnMainUi() + XLuaUiManager.RunMain() +end + +function XUiStrongholdMain:OnClickBtnShop() + if XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.ShopCommon) + or XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.ShopActive) then + local skipId = XStrongholdConfigs.GetCommonConfig("ShopSkipId") + XFunctionManager.SkipInterface(skipId) + end +end + +function XUiStrongholdMain:OnClickBtnReward() + XLuaUiManager.Open("UiStrongholdRewardTip") +end + +function XUiStrongholdMain:OnClickBtnMine() + if XDataCenter.StrongholdManager.HasMineralLeft() then + local cb = function(mineralCount) + if mineralCount <= 0 then return end + local msg = CsXTextManagerGetText("StrongholdGetMianralLeft", mineralCount) + XUiManager.TipMsg(msg) + end + XDataCenter.StrongholdManager.GetStrongholdMineralRequest(cb) + else + XDataCenter.StrongholdManager.EnterUiMine() + end +end + +function XUiStrongholdMain:OnClickBtnPower() + XLuaUiManager.Open("UiStrongholdPower") +end + +function XUiStrongholdMain:OnClickBtnFight() + local fightingGroupId = XDataCenter.StrongholdManager.CheckAnyGroupHasFinishedStage() + if XTool.IsNumberValid(fightingGroupId) then + XDataCenter.StrongholdManager.SetCurrentSelectGroupId(fightingGroupId) + XLuaUiManager.Open("UiStrongholdDeploy", fightingGroupId) + else + XLuaUiManager.Open("UiStrongholdMainLineBanner") + end +end + +function XUiStrongholdMain:OnClickBtnTeam() + local groupId = XDataCenter.StrongholdManager.CheckAnyGroupHasFinishedStage() + if groupId then + local callFunc = function() + local cb = function() + XLuaUiManager.Open("UiStrongholdDeploy") + end + XDataCenter.StrongholdManager.ResetStrongholdGroupRequest(groupId, cb) + end + local title = CSXTextManagerGetText("StrongholdTeamRestartConfirmTitle") + local content = CSXTextManagerGetText("StrongholdTeamRestartConfirmContent") + XUiManager.DialogTip(title, content, XUiManager.DialogType.Normal, nil, callFunc) + else + XLuaUiManager.Open("UiStrongholdDeploy") + end +end + +function XUiStrongholdMain:OnClickBtnAssistance() + XDataCenter.StrongholdManager.EnterUiAssistant() +end + +function XUiStrongholdMain:OnClickBtnStop() + if not XDataCenter.StrongholdManager.CheckPauseTimeAfterFightBegin() then + XUiManager.TipText("StrongholdPauseTimeAfterFightBegin") + return + end + + if not XDataCenter.StrongholdManager.CheckPauseTimeBeforeFightEnd() then + XUiManager.TipText("StrongholdPauseTimeBeforeFightEnd") + return + end + + local callFunc = function() + if not XDataCenter.StrongholdManager.CheckSetStrongholdStayRequestCD() then return end + XDataCenter.StrongholdManager.SetStrongholdStayRequest() + end + local title = CSXTextManagerGetText("StrongholdPauseConfirmTitle") + local content = CSXTextManagerGetText("StrongholdPauseConfirmContent") + XUiManager.DialogTip(title, content, XUiManager.DialogType.Normal, nil, callFunc) +end + +function XUiStrongholdMain:PlayMineUpAnim(startNum, targetNum) + local asynPlayAnim = asynTask(self.PlayAnimation, self) + local asynLetMineRoll = asynTask(self.LetMineRoll, self) + + RunAsyn(function() + local startMinerCount = startNum or 0 + local targetMinerCount = targetNum or 0 + local startMine = XDataCenter.StrongholdManager.GetMineralOutput(startMinerCount) + local targetMine = XDataCenter.StrongholdManager.GetMineralOutput(targetMinerCount) + + local deltaHp = targetMinerCount - startMinerCount + self.TxtUpPeople.text = "+" .. deltaHp + local deltaAttack = targetMine - startMine + self.TxtUpMine.text = "+" .. deltaAttack + + self.ImgUpMine.gameObject:SetActiveEx(true) + self.ImgUpPeople.gameObject:SetActiveEx(true) + self:PlayAnimation("ImgUpPeopleEnable") + self:PlayAnimation("ImgUpMineEnable") + asynLetMineRoll(startMinerCount, targetMinerCount, startMine, targetMine) + self:PlayAnimation("ImgUpPeopleDisable") + self:PlayAnimation("ImgUpMineDisable") + self.ImgUpMine.gameObject:SetActiveEx(false) + self.ImgUpPeople.gameObject:SetActiveEx(false) + end) +end + +function XUiStrongholdMain:LetMineRoll(startMinerCount, targetMinerCount, startMine, targetMine, finishCb) + if not targetMinerCount then return end + if not targetMine then return end + local onRefreshFunc = function(time) + if XTool.UObjIsNil(self.TxtPeople) + or XTool.UObjIsNil(self.TxtMine) + then + self:DestroyMineTimer() + return true + end + if startMinerCount == targetMinerCount + and startMine == targetMine + then + return true + end + self.TxtPeople.text = mathFloor(Lerp(startMinerCount, targetMinerCount, time)) + self.TxtMine.text = mathFloor(Lerp(startMine, targetMine, time)) + end + self:DestroyMineTimer() + self.MineTimer = XUiHelper.Tween(SCORE_ANIM_DURATION, onRefreshFunc, finishCb) +end + +function XUiStrongholdMain:DestroyMineTimer() + if self.MineTimer then + CSXScheduleManagerUnSchedule(self.MineTimer) + self.MineTimer = nil + end +end + +function XUiStrongholdMain:PlayElectricUpAnim(startNum, targetNum) + local asynPlayAnim = asynTask(self.PlayAnimation, self) + local asynLetElectricRoll = asynTask(self.LetElectricRoll, self) + + RunAsyn(function() + local startElectric = startNum or 0 + local targetElectric = targetNum or 0 + local deltaHp = targetElectric - startElectric + + self.TxtUpEnergy.text = "+" .. deltaHp + + self.ImgUpEnergy.gameObject:SetActiveEx(true) + self:PlayAnimation("ImgUpEnergyEnable") + asynLetElectricRoll(startElectric, targetElectric) + self:PlayAnimation("ImgUpEnergyDisable") + self.ImgUpEnergy.gameObject:SetActiveEx(false) + end) +end + +function XUiStrongholdMain:LetElectricRoll(startElectric, targetElectric, finishCb) + if not targetElectric then return end + if not startElectric then return end + local onRefreshFunc = function(time) + if XTool.UObjIsNil(self.TxtEnergyLimit) + then + self:DestroyElectricTimer() + return true + end + if startElectric == targetElectric + then + return true + end + self.TxtEnergyLimit.text = mathFloor(Lerp(startElectric, targetElectric, time)) + end + self:DestroyElectricTimer() + self.ElectricTimer = XUiHelper.Tween(SCORE_ANIM_DURATION, onRefreshFunc, finishCb) +end + +function XUiStrongholdMain:DestroyElectricTimer() + if self.ElectricTimer then + CSXScheduleManagerUnSchedule(self.ElectricTimer) + self.ElectricTimer = nil + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdMainLineBanner.lua b/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdMainLineBanner.lua new file mode 100644 index 00000000..01ea6d60 --- /dev/null +++ b/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdMainLineBanner.lua @@ -0,0 +1,110 @@ +local XUiGridStrongholdBanner = require("XUi/XUiStronghold/XUiGridStrongholdBanner") + +local CsXTextManagerGetText = CsXTextManagerGetText + +local XUiStrongholdMainLineBanner = XLuaUiManager.Register(XLuaUi, "UiStrongholdMainLineBanner") + +function XUiStrongholdMainLineBanner:OnAwake() + self:AutoAddListener() + self:InitDynamicTable() + + self.AssetActivityPanel = XUiPanelActivityAsset.New(self.PanelSpecialTool) + local itemId = XDataCenter.StrongholdManager.GetMineralItemId() + XDataCenter.ItemManager.AddCountUpdateListener(itemId, function() + self.AssetActivityPanel:Refresh({ itemId }) + end, self.AssetActivityPanel) + + self.GridChapterDz.gameObject:SetActiveEx(false) +end + +function XUiStrongholdMainLineBanner:OnStart() + self:InitView() +end + +function XUiStrongholdMainLineBanner:OnEnable() + if self.IsEnd then return end + + if XDataCenter.StrongholdManager.OnActivityEnd() then + self.IsEnd = true + return + end + + self.AssetActivityPanel:Refresh({ XDataCenter.StrongholdManager.GetMineralItemId() }) + self:UpdateEndurance() + self:UpdateChapters() +end + +function XUiStrongholdMainLineBanner:OnGetEvents() + return { + XEventId.EVENT_STRONGHOLD_FINISH_GROUP_CHANGE, + XEventId.EVENT_STRONGHOLD_ENDURANCE_CHANGE, + XEventId.EVENT_STRONGHOLD_ACTIVITY_END, + } +end + +function XUiStrongholdMainLineBanner:OnNotify(evt, ...) + if self.IsEnd then return end + + if evt == XEventId.EVENT_STRONGHOLD_FINISH_GROUP_CHANGE then + self:UpdateChapters() + elseif evt == XEventId.EVENT_STRONGHOLD_ENDURANCE_CHANGE then + self:UpdateEndurance() + elseif evt == XEventId.EVENT_STRONGHOLD_ACTIVITY_END then + if XDataCenter.StrongholdManager.OnActivityEnd() then + self.IsEnd = true + return + end + end +end + +function XUiStrongholdMainLineBanner:InitView() + self.TxtTitle.text = CsXTextManagerGetText("StrongholdActivityNameFight") +end + +function XUiStrongholdMainLineBanner:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelChapterDz) + self.DynamicTable:SetProxy(XUiGridStrongholdBanner) + self.DynamicTable:SetDelegate(self) +end + +function XUiStrongholdMainLineBanner:UpdateEndurance() + local curEndurance = XDataCenter.StrongholdManager.GetCurEndurance() + self.TxtEndurance.text = curEndurance +end + +function XUiStrongholdMainLineBanner:UpdateChapters() + self.ChapterIds = XStrongholdConfigs.GetAllChapterIds() + self.DynamicTable:SetDataSource(self.ChapterIds) + self.DynamicTable:ReloadDataASync() +end + +function XUiStrongholdMainLineBanner:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local chapterId = self.ChapterIds[index] + grid:Refresh(chapterId) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + local chapterId = self.ChapterIds[index] + + local isUnlock, conditionDes = XDataCenter.StrongholdManager.CheckChapterUnlock(chapterId) + if not isUnlock then + XUiManager.TipMsg(conditionDes) + return + end + + XLuaUiManager.Open("UiStrongholdFightMain", chapterId) + end +end + +function XUiStrongholdMainLineBanner:AutoAddListener() + self.BtnBack.CallBack = function() self:OnClickBtnBack() end + self.BtnMainUi.CallBack = function() self:OnClickBtnMainUi() end + self:BindHelpBtn(self.BtnHelp, "StrongholdFight") +end + +function XUiStrongholdMainLineBanner:OnClickBtnBack() + self:Close() +end + +function XUiStrongholdMainLineBanner:OnClickBtnMainUi() + XLuaUiManager.RunMain() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdMinerUp.lua b/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdMinerUp.lua new file mode 100644 index 00000000..ec9a8abb --- /dev/null +++ b/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdMinerUp.lua @@ -0,0 +1,54 @@ +local CSXTextManagerGetText = CS.XTextManager.GetText +local stringFormat = string.format + +--战斗胜利后,矿工数量变动时的提示界面 +local XUiStrongholdMinerUp = XLuaUiManager.Register(XLuaUi, "UiStrongholdMinerUp") + +function XUiStrongholdMinerUp:OnAwake() + self:AutoAddListener() +end + +function XUiStrongholdMinerUp:OnStart(groupId) + self.BtnCloseTs.gameObject:SetActiveEx(false) + + if not groupId then + self:Close() + return + end + + local stageName = XStrongholdConfigs.GetGroupName(groupId) + self.TxtLevelName.text = CSXTextManagerGetText("StrongholdStageClear", stageName) + + local oldMinerCount = XDataCenter.StrongholdManager.GetCookieMinerCount() + local minerCount = XDataCenter.StrongholdManager.GetMinerCount() + self.TxtLv1.text = oldMinerCount + self.TxtLv2.text = minerCount + + --获得矿石 + local itemId = XDataCenter.StrongholdManager.GetMineralItemId() + local oldItemCount = XDataCenter.StrongholdManager.GetOldItemCount() + local itemCount = XDataCenter.ItemManager.GetCount(itemId) + local changeCount = itemCount - oldItemCount + self.TxtFreeActionPoint.text = stringFormat("%s (+%s)", oldItemCount, changeCount) + + --预期总产出 + local oldTotalMineralCount = XDataCenter.StrongholdManager.GetOldTotalMineralCount() + local totalMineralCount = XDataCenter.StrongholdManager.GetPredictTotalMineralCount() + local changeTotalMineralCount = totalMineralCount - oldTotalMineralCount + self.TxtMaxFriendCount.text = stringFormat("%s (+%s)", oldTotalMineralCount, changeTotalMineralCount) + + self.Timer = XScheduleManager.ScheduleOnce(function() + self.BtnCloseTs.gameObject:SetActiveEx(true) + end, 1000) +end + +function XUiStrongholdMinerUp:OnDisable() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end + +function XUiStrongholdMinerUp:AutoAddListener() + self:RegisterClickEvent(self.BtnClose, handler(self, self.Close)) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdMining.lua b/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdMining.lua new file mode 100644 index 00000000..9023818b --- /dev/null +++ b/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdMining.lua @@ -0,0 +1,90 @@ +local stringGsub = string.gsub +local CsXTextManagerGetText = CsXTextManagerGetText + +local XUiStrongholdMining = XLuaUiManager.Register(XLuaUi, "UiStrongholdMining") + +function XUiStrongholdMining:OnAwake() + self:AutoAddListener() + + self.AssetActivityPanel = XUiPanelActivityAsset.New(self.PanelSpecialTool) + local itemId = XDataCenter.StrongholdManager.GetMineralItemId() + XDataCenter.ItemManager.AddCountUpdateListener(itemId, function() + self.AssetActivityPanel:Refresh({ itemId }) + end, self.AssetActivityPanel) +end + +function XUiStrongholdMining:OnStart() + self:InitView() +end + +function XUiStrongholdMining:OnEnable() + self.AssetActivityPanel:Refresh({ XDataCenter.StrongholdManager.GetMineralItemId() }) + self:UpdateView() +end + +function XUiStrongholdMining:OnGetEvents() + return { + XEventId.EVENT_STRONGHOLD_MINERAL_RECORD_CHANGE, + } +end + +function XUiStrongholdMining:OnNotify(evt, ...) + if evt == XEventId.EVENT_STRONGHOLD_MINERAL_RECORD_CHANGE then + self:UpdateView() + end +end + +function XUiStrongholdMining:InitView() + local itemId = XDataCenter.StrongholdManager.GetMinerItemId() + + local name = XItemConfigs.GetItemNameById(itemId) + self.TxtName.text = name + + local icon = XItemConfigs.GetItemIconById(itemId) + self.RImgIcon:SetRawImage(icon) + + local efficiency = XDataCenter.StrongholdManager.GetTotalMinerEfficiency() + self.TxtEfficiency.text = CsXTextManagerGetText("StrongholdMineEfficiencyDesc", efficiency) + + local growRate = XDataCenter.StrongholdManager.GetTotalMinerGrowRate() + self.TxtProliferation.text = CsXTextManagerGetText("StrongholdMinerGrowRateDesc", growRate) + + self.TxtExplain1.text = CsXTextManagerGetText("StrongholdMinerExplainOne") + self.TxtExplain2.text = CsXTextManagerGetText("StrongholdMinerExplainTwo") +end + +function XUiStrongholdMining:UpdateView() + local minerCount = XDataCenter.StrongholdManager.GetMinerCount() + self.TxtPeople.text = minerCount + + local mineralCount = XDataCenter.StrongholdManager.GetMineralOutput(minerCount) + self.TxtMineral.text = mineralCount + + local mineralTotalCount = XDataCenter.StrongholdManager.GetPredictTotalMineralCount() + self.TxtMineralTotal.text = mineralTotalCount +end + +function XUiStrongholdMining:AutoAddListener() + self.BtnBack.CallBack = function() self:OnClickBtnBack() end + self.BtnMainUi.CallBack = function() self:OnClickBtnMainUi() end + -- self.BtnActDesc.CallBack = function() self:OnClickBtnActDesc() end + self:BindHelpBtn(self.BtnActDesc, "StrongholdMain") + self.BtnApply.CallBack = function() self:OnClickBtnApply() end +end + +function XUiStrongholdMining:OnClickBtnBack() + self:Close() +end + +function XUiStrongholdMining:OnClickBtnMainUi() + XLuaUiManager.RunMain() +end + +function XUiStrongholdMining:OnClickBtnActDesc() + local description = XUiHelper.ConvertLineBreakSymbol(CsXTextManagerGetText("StrongholdUiMineActDes")) + XUiManager.UiFubenDialogTip("", description) +end + +function XUiStrongholdMining:OnClickBtnApply() + XLuaUiManager.Open("UiStrongholdJournal") +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdPower.lua b/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdPower.lua new file mode 100644 index 00000000..e158820c --- /dev/null +++ b/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdPower.lua @@ -0,0 +1,196 @@ +local XUiGridTeamCharacter = require("XUi/XUiStronghold/XUiGridTeamCharacter") + +local tableRemove = table.remove +local tableInsert = table.insert +local CsXTextManagerGetText = CsXTextManagerGetText +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate + +local CONDITION_COLOR = { + [true] = XUiHelper.Hexcolor2Color("77E8F9FF"), + [false] = XUiHelper.Hexcolor2Color("FCFA68FF"), +} + +local CONDITION_COLOR_2 = { + [true] = XUiHelper.Hexcolor2Color("56E8F3FF"), + [false] = XUiHelper.Hexcolor2Color("FFFFFFFF"), +} + +local CONDITION_COLOR_FOR_TEXT = { + [true] = XUiHelper.Hexcolor2Color("ff3f3f"), + [false] = XUiHelper.Hexcolor2Color("59f5ff"), +} + +local XUiStrongholdPower = XLuaUiManager.Register(XLuaUi, "UiStrongholdPower") + +function XUiStrongholdPower:OnAwake() + self:AutoAddListener() + self:InitDynamicTable() + + self.AssetActivityPanel = XUiPanelActivityAsset.New(self.PanelSpecialTool) + local itemId = XDataCenter.StrongholdManager.GetMineralItemId() + XDataCenter.ItemManager.AddCountUpdateListener(itemId, function() + self.AssetActivityPanel:Refresh({ itemId }) + end, self.AssetActivityPanel) + + self.GridData.gameObject:SetActiveEx(false) +end + +function XUiStrongholdPower:OnStart() + self.CharacterGrids = {} +end + +function XUiStrongholdPower:OnEnable() + self.AssetActivityPanel:Refresh({ XDataCenter.StrongholdManager.GetMineralItemId() }) + self:UpdateElectric() + self:UpdateTeam() +end + +function XUiStrongholdPower:OnGetEvents() + return { + XEventId.EVENT_STRONGHOLD_MAX_ELECTRIC_CHANGE, + XEventId.EVENT_STRONGHOLD_ELECTRIC_CHARACTER_CHANGE, + } +end + +function XUiStrongholdPower:OnNotify(evt, ...) + local args = { ... } + if evt == XEventId.EVENT_STRONGHOLD_MAX_ELECTRIC_CHANGE then + self:UpdateElectric() + elseif evt == XEventId.EVENT_STRONGHOLD_ELECTRIC_CHARACTER_CHANGE then + self:UpdateTeam() + end +end + +function XUiStrongholdPower:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.SView) + local class = XClass(nil, "") + class.Ctor = function(o, go) XTool.InitUiObjectByUi(o, go) end + self.DynamicTable:SetProxy(class) + self.DynamicTable:SetDelegate(self) +end + +function XUiStrongholdPower:UpdateElectric() + local useElectric = XDataCenter.StrongholdManager.GetTotalUseElectricEnergy() + local totalElectric = XDataCenter.StrongholdManager.GetTotalElectricEnergy() + + local isUp = useElectric <= totalElectric + self.PanelZheng.gameObject:SetActiveEx(isUp) + self.PanelFu.gameObject:SetActiveEx(not isUp) + self.PanelFu1.gameObject:SetActiveEx(not isUp) + self.PanelZheng1.gameObject:SetActiveEx(isUp) + + self.TxtYiyong.color = CONDITION_COLOR[isUp] + self.TxtZong.color = CONDITION_COLOR[isUp] + + self.TxtNumberZheng.text = useElectric .. "/" .. totalElectric + self.TxtNumberFu.text = useElectric .. "/" .. totalElectric + self.TxtYiyong.text = CsXTextManagerGetText("StrongholdUseElectricDes", useElectric) + self.TxtZong.text = CsXTextManagerGetText("StrongholdTotalElectricDes", totalElectric) + + self.ImgJinduZheng.fillAmount = totalElectric ~= 0 and (totalElectric - useElectric) / totalElectric or 0 + + local maxElectric = XDataCenter.StrongholdManager.GetMaxElectricEnergy() + local extraElectric = XDataCenter.StrongholdManager.GetExtraElectricEnergy() + + self.TxtElectricMax.text = maxElectric ~= 0 and "+" .. maxElectric or 0 + self.TxtElectricExtra.text = extraElectric ~= 0 and "+" .. extraElectric or 0 + + local isPaused = XDataCenter.StrongholdManager.IsDayPaused() + if isPaused then + local countTime = XDataCenter.StrongholdManager.GetDelayCountTimeStr() + self.TxtTipTime.text = CsXTextManagerGetText("StrongholdElectricTimeTwoDelay", countTime) + else + local countTime = XDataCenter.StrongholdManager.GetCountTimeStr() + self.TxtTipTime.text = CsXTextManagerGetText("StrongholdElectricTimeTwo", countTime) + end + self.TxtTipTime.color = CONDITION_COLOR_FOR_TEXT[isPaused] + + local addElectric = XDataCenter.StrongholdManager.GetAddElectricEnergy() + self.TxtTipEnergy.text = CsXTextManagerGetText("StrongholdElectricAdd", addElectric) + + self.Effect.gameObject:SetActiveEx(false) + if self.OldAddElectric then + if self.OldAddElectric ~= extraElectric then + self.Effect.gameObject:SetActiveEx(true) + end + end + self.OldAddElectric = extraElectric + + self.CurIndex = nil + local totalAbility = XDataCenter.StrongholdManager.GetElectricCharactersTotalAbility() + self.Records = XStrongholdConfigs.GetTeamAbilityExtraElectricList() + for index, record in pairs(self.Records) do + if totalAbility >= record.Ability then + self.CurIndex = index + end + end + + self.DynamicTable:SetDataSource(self.Records) + self.DynamicTable:ReloadDataASync(self.CurIndex or -1) +end + +function XUiStrongholdPower:UpdateTeam() + local totalAbility = XDataCenter.StrongholdManager.GetElectricCharactersTotalAbility() + self.TxtTotalAbility.text = CsXTextManagerGetText("StrongholdElectricAbility", totalAbility) + + local characterIds = XDataCenter.StrongholdManager.GetElectricCharacterIds() + self.CharacterIds = characterIds + local maxNum = XDataCenter.StrongholdManager.GetElectricTeamMaxCharacterNum() + for pos = 1, maxNum do + local grid = self.CharacterGrids[pos] + if not grid then + local ui = pos == 1 and self.GridCharacter or CSUnityEngineObjectInstantiate(self.GridCharacter, self.Layout) + grid = XUiGridTeamCharacter.New(ui) + self.CharacterGrids[pos] = grid + end + + local characterId = characterIds[pos] + grid:Refresh(characterId) + grid.GameObject:SetActiveEx(true) + end + + for pos = maxNum + 1, #self.CharacterGrids do + local grid = self.CharacterGrids[pos] + if grid then + grid.GameObject:SetActiveEx(false) + end + end +end + +function XUiStrongholdPower:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local record = self.Records[index] + grid.TxtZhanLi.text = record.Ability + grid.TxtKuoRong.text = record.Electric + + local isCurrent = index and self.CurIndex == index + grid.TxtZhanLi.color = CONDITION_COLOR_2[isCurrent] + grid.TxtKuoRong.color = CONDITION_COLOR_2[isCurrent] + end +end + +function XUiStrongholdPower:AutoAddListener() + self.BtnBack.CallBack = function() self:OnClickBtnBack() end + self.BtnMainUi.CallBack = function() self:OnClickBtnMainUi() end + if self.BtnHelp then + self.BtnHelp.CallBack = function() self:OnClickBtnHelp() end + end + self:BindHelpBtn(self.BtnActDesc, "StrongholdMain") +end + +function XUiStrongholdPower:OnClickBtnBack() + self:Close() +end + +function XUiStrongholdPower:OnClickBtnMainUi() + XLuaUiManager.RunMain() +end + +function XUiStrongholdPower:OnClickBtnActDesc() + local description = XUiHelper.ConvertLineBreakSymbol(CsXTextManagerGetText("StrongholdUiElectricActDes")) + XUiManager.UiFubenDialogTip("", description) +end + +function XUiStrongholdPower:OnClickBtnHelp() + XLuaUiManager.Open("UiStrongholdPowerExpectTips") +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdPowerExpectTips/XUiStrongholdPowerExpectTips.lua b/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdPowerExpectTips/XUiStrongholdPowerExpectTips.lua new file mode 100644 index 00000000..12b98621 --- /dev/null +++ b/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdPowerExpectTips/XUiStrongholdPowerExpectTips.lua @@ -0,0 +1,47 @@ +local XUiStrongholdPowerExpectTipsGrid = require("XUi/XUiStronghold/XUiStrongholdPowerExpectTips/XUiStrongholdPowerExpectTipsGrid") + +local XUiStrongholdPowerExpectTips = XLuaUiManager.Register(XLuaUi, "UiStrongholdPowerExpectTips") + +function XUiStrongholdPowerExpectTips:OnAwake() + self:AutoAddListener() + self:InitDynamicTable() + + self.GridDay.gameObject:SetActiveEx(false) +end + +function XUiStrongholdPowerExpectTips:OnEnable() + self:Refresh() +end + +function XUiStrongholdPowerExpectTips:AutoAddListener() + self:RegisterClickEvent(self.BtnBack, self.Close) + self:RegisterClickEvent(self.BtnTanchuangClose, self.Close) +end + +function XUiStrongholdPowerExpectTips:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelDay) + self.DynamicTable:SetProxy(XUiStrongholdPowerExpectTipsGrid) + self.DynamicTable:SetDelegate(self) +end + +function XUiStrongholdPowerExpectTips:Refresh() + self.List = XStrongholdConfigs.GetElectricIdList() + local curDay = XDataCenter.StrongholdManager.GetCurDay() + local startIndex + for i, electricId in ipairs(self.List) do + if electricId == curDay then + startIndex = i + break + end + end + + self.DynamicTable:SetDataSource(self.List) + self.DynamicTable:ReloadDataSync(startIndex) +end + +function XUiStrongholdPowerExpectTips:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:Refresh(index, self.List[index]) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdPowerExpectTips/XUiStrongholdPowerExpectTipsGrid.lua b/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdPowerExpectTips/XUiStrongholdPowerExpectTipsGrid.lua new file mode 100644 index 00000000..5988f828 --- /dev/null +++ b/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdPowerExpectTips/XUiStrongholdPowerExpectTipsGrid.lua @@ -0,0 +1,28 @@ +local CsXTextManagerGetText = CsXTextManagerGetText + +local XUiStrongholdPowerExpectTipsGrid = XClass(nil, "XUiStrongholdPowerExpectTipsGrid") + +function XUiStrongholdPowerExpectTipsGrid:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) +end + +function XUiStrongholdPowerExpectTipsGrid:Refresh(index, electricId) + local levelId = XDataCenter.StrongholdManager.GetLevelId() + local electric = index == 1 and XStrongholdConfigs.GetLevelInitElectricEnergy(levelId) or XStrongholdConfigs.GetElectricAdd(electricId - 1, levelId) + local curDay = XDataCenter.StrongholdManager.GetCurDay() + + self.TxtDayNormal.text = CsXTextManagerGetText("StrongholdJournalDay", XTool.ConvertNumberString(index)) + self.TxtNumberNormal.text = electric + self.TxtDayDisable.text = CsXTextManagerGetText("StrongholdJournalDay", XTool.ConvertNumberString(index)) + self.TxtNumberDisable.text = electric + + self.Normal.gameObject:SetActiveEx(curDay >= index) + self.Disable.gameObject:SetActiveEx(curDay < index) + + self.ImgSelect.gameObject:SetActiveEx(curDay == index) +end + +return XUiStrongholdPowerExpectTipsGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdQuickDeploy.lua b/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdQuickDeploy.lua new file mode 100644 index 00000000..8a83c949 --- /dev/null +++ b/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdQuickDeploy.lua @@ -0,0 +1,152 @@ +local XUiGridQuickDeployTeam = require("XUi/XUiStronghold/XUiGridQuickDeployTeam") + +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate + +local XUiStrongholdQuickDeploy = XLuaUiManager.Register(XLuaUi, "UiStrongholdQuickDeploy") + +function XUiStrongholdQuickDeploy:OnAwake() + self.GridQuickDeployTeam.gameObject:SetActiveEx(false) + self:AutoAddListener() +end + +function XUiStrongholdQuickDeploy:OnStart(groupId, teamList, saveCb) + self.TeamList = teamList + self.GroupId = groupId + self.SaveCb = saveCb + self.TeamListClip = XDataCenter.StrongholdManager.GetTeamListClipTemp(groupId, teamList) + + self.TeamGridList = {} +end + +function XUiStrongholdQuickDeploy:OnEnable() + self:UpdateView() +end + +function XUiStrongholdQuickDeploy:OnDisable() + self.OldTeamId = nil + self.OldPos = nil + + if self.LastSelectGrid then + self.LastSelectGrid:SetSelect(false) + self.LastSelectGrid = nil + end +end + +function XUiStrongholdQuickDeploy:UpdateView() + local teamList = self.TeamList + local teamListClip = self.TeamListClip + + local memberClickCb = function(grid, pos, teamId) + + local grid = grid + + local oldTeamId = self.OldTeamId + local oldPos = self.OldPos + + --队伍中有关卡进度 + local groupId = self.GroupId + if groupId then + if XDataCenter.StrongholdManager.IsGroupStageFinished(groupId, oldTeamId) + or XDataCenter.StrongholdManager.IsGroupStageFinished(groupId, teamId) + then + XUiManager.TipText("StrongholdQuickDeployTeamLock") + return + end + end + + local sucCb = function() + self:UpdateView() + + grid:ShowEffect() + self.LastSelectGrid:ShowEffect() + self.LastSelectGrid:SetSelect(false) + self.LastSelectGrid = nil + + self.OldTeamId = nil + self.OldPos = nil + end + + local failCb = function() + if self.LastSelectGrid then + self.LastSelectGrid:SetSelect(false) + end + self.LastSelectGrid = grid + + self.LastSelectGrid:SetSelect(true) + self.OldTeamId = teamId + self.OldPos = pos + end + + self:SwapTeamPos(oldTeamId, oldPos, teamId, pos, sucCb, failCb) + end + + local teamGridList = self.TeamGridList + for index, team in ipairs(teamListClip) do + local teamGrid = teamGridList[index] + if not teamGrid then + local go = CSUnityEngineObjectInstantiate(self.GridQuickDeployTeam, self.PanelFormationTeamContent) + teamGrid = XUiGridQuickDeployTeam.New(go, memberClickCb) + teamGridList[index] = teamGrid + end + + local teamId = index + teamGrid:Refresh(teamList, teamId, self.GroupId) + teamGrid.GameObject:SetActiveEx(true) + end + for i = #teamListClip + 1, #teamGridList do + teamGridList.GameObject:SetActiveEx(false) + end +end + +function XUiStrongholdQuickDeploy:AutoAddListener() + self.BtnConfirm.CallBack = function() self:OnClickBtnConfirm() end +end + +function XUiStrongholdQuickDeploy:OnClickBtnConfirm() + self.SaveCb() + self:Close() +end + +function XUiStrongholdQuickDeploy:SwapTeamPos(oldTeamId, oldPos, newTeamId, newPos, sucCb, failCb) + if not oldTeamId then failCb() return false end + + if oldTeamId == newTeamId and oldPos == newPos then failCb() return false end + + local teamList = self.TeamList + + local oldTeam = teamList[oldTeamId] + local oldMember = XTool.Clone(oldTeam:GetMember(oldPos)) + local newTeam = teamList[newTeamId] + local newMember = XTool.Clone(newTeam:GetMember(newPos)) + + if oldMember:IsEmpty() and newMember:IsEmpty() then failCb() return false end + + local oldCharacterType = oldMember:GetCharacterType() + local newCharacterType = newMember:GetCharacterType() + + local swapFunc = function() + if newTeam:ExistDifferentCharacterType(oldCharacterType) then + newTeam:Clear() + end + if oldTeam:ExistDifferentCharacterType(newCharacterType) then + oldTeam:Clear() + end + + oldTeam:SetMemberForce(oldPos, newMember) + newTeam:SetMemberForce(newPos, oldMember) + + sucCb() + end + + if newTeam:ExistDifferentCharacterType(oldCharacterType) + or oldTeam:ExistDifferentCharacterType(newCharacterType) + then + --队伍中已经存在其他类型的角色(构造体/授格者) + local content = CSXTextManagerGetText("TeamCharacterTypeNotSame") + XUiManager.DialogTip(nil, content, XUiManager.DialogType.Normal, nil, swapFunc) + + else + swapFunc() + end + +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdReward/XUiGridRewardTip.lua b/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdReward/XUiGridRewardTip.lua new file mode 100644 index 00000000..cbef17a1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdReward/XUiGridRewardTip.lua @@ -0,0 +1,103 @@ +local handler = handler +local CsXTextManagerGetText = CsXTextManagerGetText +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate + +local XUiGridRewardTip = XClass(nil, "XUiGridRewardTip") + +function XUiGridRewardTip:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + + self.BtnFinish.CallBack = handler(self, self.OnClickBtnFinish) + self.BtnGo.CallBack = handler(self, self.OnClickBtnGo) + + self.GridCommon.gameObject:SetActiveEx(false) + + self.RewardGrids = {} +end + +function XUiGridRewardTip:InitRootUi(rootUi) + self.RootUi = rootUi +end + +function XUiGridRewardTip:Refresh(rewardId, levelId) + self.RewardId = rewardId + + local name = XStrongholdConfigs.GetRewardDesc(rewardId) + self.TxtTaskName.text = name + + local conditionId = XStrongholdConfigs.GetRewardConditionId(rewardId) + local ret, des, haveCount, requireCount = XConditionManager.CheckCondition(conditionId) + + if haveCount and XTool.IsNumberValid(requireCount) then + self.TxtTaskNumQian.text = CsXTextManagerGetText("StrongholdRewardProgress", haveCount, requireCount) + self.TxtTaskNumQian.gameObject:SetActiveEx(true) + + self.ImgProgress.fillAmount = haveCount / requireCount + self.ProgressBg.gameObject:SetActiveEx(true) + else + self.TxtTaskNumQian.gameObject:SetActiveEx(false) + self.ProgressBg.gameObject:SetActiveEx(false) + end + + local isFinished = XDataCenter.StrongholdManager.IsRewardFinished(rewardId) + self.BtnFinish:SetDisable(not ret) + self.BtnFinish.gameObject:SetActiveEx(not isFinished) + local skipId = XStrongholdConfigs.GetRewardSkipId(rewardId) + self.BtnGo.gameObject:SetActiveEx(not isFinished and not ret and XTool.IsNumberValid(skipId)) + self.ImgAlreadyFinish.gameObject:SetActiveEx(isFinished) + + local rewardGoodsId = XStrongholdConfigs.GetRewardGoodsId(rewardId) + local rewards = XRewardManager.GetRewardList(rewardGoodsId) or {} + for index, reward in ipairs(rewards or {}) do + local grid = self.RewardGrids[index] + if not grid then + local ui = index == 1 and self.GridCommon or CSUnityEngineObjectInstantiate(self.GridCommon, self.PanelRewardContent) + grid = XUiGridCommon.New(self.RootUi, ui) + self.RewardGrids[index] = grid + end + + grid:Refresh(reward) + grid.GameObject:SetActiveEx(true) + end + for index = #rewards + 1, #self.RewardGrids do + local grid = self.RewardGrids[index] + if grid then + grid.GameObject:SetActiveEx(false) + end + end + + local isShow = XRedPointConditionStrongholdMineralLeft.Check(self.RewardId) + self.BtnFinish:ShowReddot(isShow) + + --预览模式不显示按钮 + if XTool.IsNumberValid(levelId) then + self.BtnFinish.gameObject:SetActiveEx(false) + self.BtnGo.gameObject:SetActiveEx(false) + self.ImgAlreadyFinish.gameObject:SetActiveEx(false) + end +end + +function XUiGridRewardTip:OnClickBtnFinish() + local rewardId = self.RewardId + + local conditionId = XStrongholdConfigs.GetRewardConditionId(rewardId) + local ret = XConditionManager.CheckCondition(conditionId) + if not ret then return end + + local cb = function(rewardGoods) + if not XTool.IsTableEmpty(rewardGoods) then + XUiManager.OpenUiObtain(rewardGoods) + end + end + XDataCenter.StrongholdManager.GetStrongholdRewardRequest(rewardId, cb) +end + +function XUiGridRewardTip:OnClickBtnGo() + local skipId = XStrongholdConfigs.GetRewardSkipId(self.RewardId) + XFunctionManager.SkipInterface(skipId) +end + +return XUiGridRewardTip \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdReward/XUiStrongholdRewardTip.lua b/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdReward/XUiStrongholdRewardTip.lua new file mode 100644 index 00000000..09896eec --- /dev/null +++ b/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdReward/XUiStrongholdRewardTip.lua @@ -0,0 +1,64 @@ +local XUiGridRewardTip = require("XUi/XUiStronghold/XUiStrongholdReward/XUiGridRewardTip") + +local CsXTextManagerGetText = CsXTextManagerGetText + +local XUiStrongholdRewardTip = XLuaUiManager.Register(XLuaUi, "UiStrongholdRewardTip") + +function XUiStrongholdRewardTip:OnAwake() + self:AutoAddListener() + self:InitDynamicTable() + + self.GridPrequelCheckPointReward.gameObject:SetActiveEx(false) +end + +function XUiStrongholdRewardTip:OnStart(levelId) + if XTool.IsNumberValid(levelId) then + self.LevelId = levelId + + local levelName = XStrongholdConfigs.GetLevelName(levelId) + self.TxtTitle.text = CsXTextManagerGetText("StrongholdRewardTipTitle", levelName) + else + self.TxtTitle.text = CsXTextManagerGetText("StrongholdRewardTipTitleDefault") + end +end + +function XUiStrongholdRewardTip:OnEnable() + self:UpdateRewards() +end + +function XUiStrongholdRewardTip:OnGetEvents() + return { + XEventId.EVENT_STRONGHOLD_FINISH_REWARDS_CHANGE, + } +end + +function XUiStrongholdRewardTip:OnNotify(evt, ...) + if evt == XEventId.EVENT_STRONGHOLD_FINISH_REWARDS_CHANGE then + self:UpdateRewards() + end +end + +function XUiStrongholdRewardTip:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.SViewRewardList) + self.DynamicTable:SetProxy(XUiGridRewardTip) + self.DynamicTable:SetDelegate(self) +end + +function XUiStrongholdRewardTip:UpdateRewards() + self.RewardIds = XDataCenter.StrongholdManager.GetAllRewardIds(self.LevelId) + self.DynamicTable:SetDataSource(self.RewardIds) + self.DynamicTable:ReloadDataASync() +end + +function XUiStrongholdRewardTip:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:InitRootUi(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local rewardId = self.RewardIds[index] + grid:Refresh(rewardId, self.LevelId) + end +end + +function XUiStrongholdRewardTip:AutoAddListener() + self.BtnTanchuangClose.CallBack = function() self:Close() end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdRoomCharacter.lua b/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdRoomCharacter.lua new file mode 100644 index 00000000..eb3ed399 --- /dev/null +++ b/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdRoomCharacter.lua @@ -0,0 +1,218 @@ +local XUiPanelStrongholdRoomCharacterOthers = require("XUi/XUiStronghold/XUiPanelStrongholdRoomCharacterOthers") +local XUiPanelStrongholdRoomCharacterSelf = require("XUi/XUiStronghold/XUiPanelStrongholdRoomCharacterSelf") + +local handler = handler +local IsNumberValid = XTool.IsNumberValid + +local TabBtnIndex = { + Normal = 1, --构造体 + Isomer = 2, --授格者 + Others = 3, --援助角色 +} + +local XUiStrongholdRoomCharacter = XLuaUiManager.Register(XLuaUi, "UiStrongholdRoomCharacter") + +function XUiStrongholdRoomCharacter:OnAwake() + self:AutoAddListener() + + local selectCharacterCb = handler(self, self.OnSelectCharacter) + local closeUiFunc = handler(self, self.Close) + local playAnimationCb = function(animName) + self:PlayAnimationWithMask(animName) + end + self.OthersPanel = XUiPanelStrongholdRoomCharacterOthers.New(self.PanelOthers, selectCharacterCb, closeUiFunc, playAnimationCb, self) + self.SelfPanel = XUiPanelStrongholdRoomCharacterSelf.New(self.PanelSelf, selectCharacterCb, closeUiFunc, playAnimationCb) + + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self.BtnFilter.gameObject:SetActiveEx(false) +end + +function XUiStrongholdRoomCharacter:OnStart(teamList, teamId, memberIndex, groupId) + self.TeamList = teamList + self.TeamId = teamId + self.MemberIndex = memberIndex + self.GroupId = groupId + + local member = self:GetMember() + self.CharacterId = member:GetInTeamCharacterId() + self.PlayerId = member:GetOthersPlayerId() + + self:InitModel() + self:InitCharacterTypeBtns() + + XEventManager.AddEventListener(XEventId.EVENT_TEAM_PREFAB_SELECT, self.UpdateTeamPrefab, self) +end + +function XUiStrongholdRoomCharacter:OnEnable() + CS.XGraphicManager.UseUiLightDir = true + + if self.SelectTabIndex then + self.PanelCharacterTypeBtns:SelectIndex(self.SelectTabIndex) + end +end + +function XUiStrongholdRoomCharacter:OnDisable() + CS.XGraphicManager.UseUiLightDir = false +end + +function XUiStrongholdRoomCharacter:OnDestroy() + XEventManager.RemoveEventListener(XEventId.EVENT_TEAM_PREFAB_SELECT, self.UpdateTeamPrefab, self) +end + +function XUiStrongholdRoomCharacter:InitCharacterTypeBtns() + local lockShougezhe = not XFunctionManager.JudgeOpen(XFunctionManager.FunctionName.Isomer) + self.BtnTabShougezhe:SetDisable(lockShougezhe, not lockShougezhe) + self.BtnTabShougezhe.gameObject:SetActiveEx(not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.Isomer)) + + local isPrefab = self:IsPrefab() + self.BtnTabHelp.gameObject:SetActiveEx(not isPrefab) + + local tabBtns = { self.BtnTabGouzaoti, self.BtnTabShougezhe, self.BtnTabHelp } + self.PanelCharacterTypeBtns:Init(tabBtns, function(index) self:SelectPanel(index) end) + + local defaultIndex = self:GetDefaultTabBtnIndex() + self.PanelCharacterTypeBtns:SelectIndex(defaultIndex) +end + +function XUiStrongholdRoomCharacter:SelectPanel(index) + if index == TabBtnIndex.Isomer then + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.Isomer) then return end + end + + if self.CurPanel and self.CurPanel:IsLoading() then + self.PanelCharacterTypeBtns:SelectIndex(self.SelectTabIndex, false) + return + end + + self.SelectTabIndex = index + if index == TabBtnIndex.Normal then + self.SelfPanel:Show(self.TeamList, self.TeamId, self.MemberIndex, self.GroupId) + self.OthersPanel:Hide() + self.CurPanel = self.SelfPanel + elseif index == TabBtnIndex.Isomer then + local isSelectIsomer = true + self.SelfPanel:Show(self.TeamList, self.TeamId, self.MemberIndex, self.GroupId, isSelectIsomer) + self.OthersPanel:Hide() + self.CurPanel = self.SelfPanel + elseif index == TabBtnIndex.Others then + self.SelfPanel:Hide() + self.OthersPanel:Show(self.TeamList, self.TeamId, self.MemberIndex, self.GroupId) + self.CurPanel = self.OthersPanel + end + + local id = IsNumberValid(self.PlayerId) and self.PlayerId or self.CharacterId + self.CurPanel:SelectCharacter(id) +end + +function XUiStrongholdRoomCharacter:OnSelectCharacter(characterId, playerId) + self.CharacterId = characterId + self.PlayerId = playerId + self:UpdateRoleModel() +end + +function XUiStrongholdRoomCharacter:UpdateRoleModel() + local playerId = self.PlayerId + + local characterId = self.CharacterId + if XRobotManager.CheckIsRobotId(self.CharacterId) then + characterId = XRobotManager.GetCharacterId(self.CharacterId) + end + + if not IsNumberValid(characterId) then + self.RoleModelPanel.GameObject:SetActiveEx(false) + return + end + self.RoleModelPanel.GameObject:SetActiveEx(true) + + local targetPanelRole = self.PanelRoleModel + local targetUiName = self.Name + local cb = function(model) + if not model then return end + self.PanelDrag.Target = model.transform + if self.SelectTabIndex == TabBtnIndex.Normal then + self.ImgEffectHuanren.gameObject:SetActiveEx(true) + elseif self.SelectTabIndex == TabBtnIndex.Isomer then + self.ImgEffectHuanren1.gameObject:SetActiveEx(true) + end + end + + if XRobotManager.CheckIsRobotId(self.CharacterId) then + local robotId = self.CharacterId + local robotCfg = XRobotManager.GetRobotTemplate(robotId) + local fashionId = robotCfg.FashionId + local weaponId = robotCfg.WeaponId + + self.ImgEffectHuanren.gameObject:SetActiveEx(false) + self.ImgEffectHuanren1.gameObject:SetActiveEx(false) + self.RoleModelPanel:UpdateRobotModel(robotId, characterId, nil, fashionId, weaponId, cb) + + else + local fashionId = nil + local growUpLevel = nil + if IsNumberValid(playerId) then + --别人的角色信息 + fashionId = XDataCenter.StrongholdManager.GetAssistantPlayerFashionId(playerId) + growUpLevel = XDataCenter.StrongholdManager.GetAssistantPlayerLiberateLv(playerId) + end + + self.ImgEffectHuanren.gameObject:SetActiveEx(false) + self.ImgEffectHuanren1.gameObject:SetActiveEx(false) + self.RoleModelPanel:UpdateCharacterModel(characterId, targetPanelRole, targetUiName, cb, nil, fashionId, growUpLevel) + end +end + +function XUiStrongholdRoomCharacter:InitModel() + local root = self.UiModelGo.transform + self.PanelRoleModel = root:FindTransform("PanelRoleModel") + self.ImgEffectHuanren = root:FindTransform("ImgEffectHuanren") + self.ImgEffectHuanren1 = root:FindTransform("ImgEffectHuanren1") + self.RoleModelPanel = XUiPanelRoleModel.New(self.PanelRoleModel, self.Name, nil, true) +end + +function XUiStrongholdRoomCharacter:AutoAddListener() + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end +end + +function XUiStrongholdRoomCharacter:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiStrongholdRoomCharacter:OnBtnBackClick() + self:Close() +end + +function XUiStrongholdRoomCharacter:GetTeam() + return self.TeamList[self.TeamId] +end + +function XUiStrongholdRoomCharacter:GetMember() + local team = self:GetTeam() + return team:GetMember(self.MemberIndex) +end + +function XUiStrongholdRoomCharacter:GetDefaultTabBtnIndex() + local tabIndex = TabBtnIndex.Normal + + local member = self:GetMember() + local groupId = self.GroupId + local stageIndex = self.TeamId + local stageId = groupId and stageIndex and XDataCenter.StrongholdManager.GetGroupStageId(groupId, stageIndex) + local characterLimitType = stageId and XFubenConfigs.GetStageCharacterLimitType(stageId) + + if member:IsAssitant() and not self:IsPrefab() then + tabIndex = TabBtnIndex.Others + elseif member:IsIsomer() or (self.CharacterId == 0 and (characterLimitType == XFubenConfigs.CharacterLimitType.Isomer or characterLimitType == XFubenConfigs.CharacterLimitType.NormalDebuff)) then + tabIndex = TabBtnIndex.Isomer + end + + return tabIndex +end + +function XUiStrongholdRoomCharacter:IsPrefab() + return not IsNumberValid(self.GroupId) +end + +function XUiStrongholdRoomCharacter:UpdateTeamPrefab(team) + self.SelfPanel:UpdateTeamPrefab(team) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdRune/XUiGridSubRune.lua b/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdRune/XUiGridSubRune.lua new file mode 100644 index 00000000..d22619d5 --- /dev/null +++ b/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdRune/XUiGridSubRune.lua @@ -0,0 +1,34 @@ +local XUiGridSubRune = XClass(nil, "XUiGridSubRune") + +function XUiGridSubRune:Ctor(ui, clickCb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.ClickCb = clickCb + + XTool.InitUiObject(self) + self:SetSelect(false) + self.BtnClick.CallBack = function() + clickCb(self.SubRuneId) + end +end + +function XUiGridSubRune:Refresh(runeId, subRuneId, groupId) + self.SubRuneId = subRuneId + + local isUsing = XDataCenter.StrongholdManager.IsSubRuneUsing(subRuneId) + self.PanelUsing.gameObject:SetActiveEx(isUsing) + + self.ImgBg.color = XStrongholdConfigs.GetRuneColor(runeId) + self.ImgIcon:SetSprite(XStrongholdConfigs.GetSubRuneIcon(subRuneId)) + self.TxtName.text = XStrongholdConfigs.GetSubRuneName(subRuneId) + self.TxtDesc.text = XStrongholdConfigs.GetSubRuneDesc(subRuneId) + + local isLock = XDataCenter.StrongholdManager.IsRuneLock(runeId, groupId, subRuneId) + self.PanelLock.gameObject:SetActiveEx(isLock) +end + +function XUiGridSubRune:SetSelect(value) + self.PanelSelect.gameObject:SetActiveEx(value) +end + +return XUiGridSubRune \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdRune/XUiStrongholdRune.lua b/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdRune/XUiStrongholdRune.lua new file mode 100644 index 00000000..813a54c0 --- /dev/null +++ b/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdRune/XUiStrongholdRune.lua @@ -0,0 +1,161 @@ +local XUiGridSubRune = require("XUi/XUiStronghold/XUiStrongholdRune/XUiGridSubRune") + +local CsXTextManagerGetText = CsXTextManagerGetText + +local XUiStrongholdRune = XLuaUiManager.Register(XLuaUi, "UiStrongholdRune") + +function XUiStrongholdRune:OnAwake() + self:AutoAddListener() + + self.GridSubRune.gameObject:SetActiveEx(false) + self.BtnRune.gameObject:SetActiveEx(false) +end + +function XUiStrongholdRune:OnStart(teamList, teamId, groupId) + self.TeamList = teamList + self.TeamId = teamId + self.GroupId = groupId + self.TabBtnList = {} + self.SubRuneGrids = {} +end + +function XUiStrongholdRune:OnEnable() + self:InitTabBtnGroup() +end + +function XUiStrongholdRune:OnGetEvents() + return { + XEventId.EVENT_STRONGHOLD_RUNE_CHANGE, + } +end + +function XUiStrongholdRune:OnNotify(evt, ...) + if evt == XEventId.EVENT_STRONGHOLD_RUNE_CHANGE then + self:InitTabBtnGroup() + end +end + +function XUiStrongholdRune:InitTabBtnGroup() + self.RuneIdList = XDataCenter.StrongholdManager.GetAllRuneIds() + if XTool.IsTableEmpty(self.RuneIdList) then + XLog.Error("XUiStrongholdRune:InitTabBtnGroup error, 服务器下发可用符文列表为空") + return + end + + for index, runeId in ipairs(self.RuneIdList) do + local btn = self.TabBtnList[index] + if not btn then + local go = CS.UnityEngine.Object.Instantiate(self.BtnRune, self.PanelTabBtns.transform) + btn = go:GetComponent("XUiButton") + self.TabBtnList[index] = btn + end + + btn:SetSprite(XStrongholdConfigs.GetRuneIcon(runeId)) + btn:SetNameByGroup(0, XStrongholdConfigs.GetRuneName(runeId)) + + local usingTeamId = XDataCenter.StrongholdManager.GetRuneUsingTeamId(runeId) + if XTool.IsNumberValid(usingTeamId) then + btn:SetNameByGroup(1, CsXTextManagerGetText("StrongholdTeamIndex", usingTeamId)) + else + btn:SetNameByGroup(1, "") + end + + local hasRecord = XDataCenter.StrongholdManager.IsRuneLock(runeId, self.GroupId) + btn:ShowTag(hasRecord) + + btn.gameObject:SetActiveEx(true) + end + + self.PanelTabBtns:Init(self.TabBtnList, handler(self, self.OnTabBtnGroupClick)) + self.PanelTabBtns:SelectIndex(self.SelectTabIndex or 1) +end + +function XUiStrongholdRune:OnTabBtnGroupClick(index) + self.SelectTabIndex = index + self.SubRuneId = nil + + local runeId = self.RuneIdList[index] + self.ImgBg.color = XStrongholdConfigs.GetRuneColor(runeId) + self.ImgIcon:SetSprite(XStrongholdConfigs.GetRuneIcon(runeId)) + self.TxtName.text = XStrongholdConfigs.GetRuneName(runeId) + self.TxtDesc.text = XStrongholdConfigs.GetRuneDesc(runeId) + + local subRuneIds = XStrongholdConfigs.GetSubRuneIds(runeId) + for index, subRuneId in ipairs(subRuneIds) do + local grid = self.SubRuneGrids[index] + if not grid then + local go = CS.UnityEngine.Object.Instantiate(self.GridSubRune.gameObject, self.PanelContent) + local clickCb = handler(self, self.OnClickSubRune) + grid = XUiGridSubRune.New(go, clickCb) + self.SubRuneGrids[index] = grid + end + + grid:Refresh(runeId, subRuneId, self.GroupId) + grid:SetSelect(self.SubRuneId == subRuneId) + grid.GameObject:SetActiveEx(true) + end + for index = #subRuneIds + 1, #self.SubRuneGrids do + self.SubRuneGrids[index].GameObject:SetActiveEx(false) + end + + local isLock = XDataCenter.StrongholdManager.IsRuneLock(runeId, self.GroupId) + if isLock then + self.BtnSave:SetDisable(true, false) + self.TxtTips.text = CsXTextManagerGetText("StrongholdTeamRuneLockTip") + self.TxtTips.gameObject:SetActiveEx(true) + else + self.BtnSave:SetDisable(false, true) + self.TxtTips.gameObject:SetActiveEx(false) + end + + self:PlayAnimationWithMask("QieHuan") +end + +function XUiStrongholdRune:OnClickSubRune(subRuneId) + self.SubRuneId = subRuneId + for index, grid in pairs(self.SubRuneGrids) do + grid:SetSelect(grid.SubRuneId == subRuneId) + end +end + +function XUiStrongholdRune:AutoAddListener() + self.BtnClose.CallBack = handler(self, self.Close) + self.BtnSave.CallBack = handler(self, self.OnClickBtnSave) +end + +function XUiStrongholdRune:OnClickBtnSave() + local runeId = self.RuneIdList[self.SelectTabIndex] + local subRuneId = self.SubRuneId + if not subRuneId then + XUiManager.TipText("StrongholdTeamSelectSubRuneEmpty") + return + end + + local oldTeamId + for teamId, team in pairs(self.TeamList) do + if team:IsRuneUsing(runeId) then + oldTeamId = teamId + break + end + end + + local callFunc = function() + if oldTeamId then + local oldTeam = self.TeamList[oldTeamId] + oldTeam:ClearRune() + end + + local curTeam = self.TeamList[self.TeamId] + curTeam:SetRune(runeId, subRuneId) + + self:Close() + end + + if oldTeamId and oldTeamId ~= self.TeamId then + local title = CSXTextManagerGetText("StrongholdTeamSelectRuneConfirmTitle") + local content = CSXTextManagerGetText("StrongholdTeamSelectRuneConfirmContent", oldTeamId) + XUiManager.DialogTip(title, content, XUiManager.DialogType.Normal, nil, callFunc) + else + callFunc() + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdSkillDetails.lua b/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdSkillDetails.lua new file mode 100644 index 00000000..6bcbfbea --- /dev/null +++ b/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdSkillDetails.lua @@ -0,0 +1,72 @@ +local CsXTextManagerGetText = CsXTextManagerGetText + +local XUiStrongholdSkillDetails = XLuaUiManager.Register(XLuaUi, "UiStrongholdSkillDetails") + +function XUiStrongholdSkillDetails:OnAwake() + self:AutoAddListener() +end + +function XUiStrongholdSkillDetails:OnStart(buffId, skipCb, closeCb) + self.BuffId = buffId + self.SkipCb = skipCb + self.CloseCb = closeCb +end + +function XUiStrongholdSkillDetails:OnEnable() + self:UpdateView() +end + +function XUiStrongholdSkillDetails:OnDestroy() + if self.CloseCb then + self.CloseCb() + end +end + +function XUiStrongholdSkillDetails:UpdateView() + local buffId = self.BuffId + + local icon = XStrongholdConfigs.GetBuffIcon(buffId) + self.RImgIcon:SetRawImage(icon) + + local name = XStrongholdConfigs.GetBuffName(buffId) + self.TxtName.text = name + + local desc = XStrongholdConfigs.GetBuffDesc(buffId) + self.TxtDesc.text = desc + + local hasCondition = XStrongholdConfigs.CheckBuffHasCondition(buffId) + if hasCondition then + local _, desc = XDataCenter.StrongholdManager.CheckBuffActive(buffId) + self.TxtRequirement.text = CsXTextManagerGetText("StrongholdBuffConditionDes", desc) + + local condition = XStrongholdConfigs.GetBuffConditionId(buffId) + local groupId = XConditionManager.GetConditionParams(condition) + local order = XStrongholdConfigs.GetGroupOrder(groupId) + self.TxtSkip.text = CsXTextManagerGetText("StrongholdBtnSkipDesc", order) + self.BtnSkip.gameObject:SetActiveEx(self.SkipCb and true or false) + + self.PanelRequirement.gameObject:SetActiveEx(true) + else + self.PanelRequirement.gameObject:SetActiveEx(false) + end +end + +function XUiStrongholdSkillDetails:AutoAddListener() + self.BtnTanchuangClose.CallBack = function() self:Close() end + self.BtnSkip.CallBack = function() self:OnClickBtnSkip() end +end + +function XUiStrongholdSkillDetails:OnClickBtnSkip() + local buffId = self.BuffId + local hasCondition = XStrongholdConfigs.CheckBuffHasCondition(buffId) + if not hasCondition then + return + end + + if self.SkipCb then + local condition = XStrongholdConfigs.GetBuffConditionId(buffId) + local groupId = XConditionManager.GetConditionParams(condition) + self:Close() + self.SkipCb(groupId) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdSkillDetailsDialog.lua b/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdSkillDetailsDialog.lua new file mode 100644 index 00000000..b009d3fd --- /dev/null +++ b/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdSkillDetailsDialog.lua @@ -0,0 +1,72 @@ +local CsXTextManagerGetText = CsXTextManagerGetText + +local XUiStrongholdSkillDetailsDialog = XLuaUiManager.Register(XLuaUi, "UiStrongholdSkillDetailsDialog") + +function XUiStrongholdSkillDetailsDialog:OnAwake() + self:AutoAddListener() +end + +function XUiStrongholdSkillDetailsDialog:OnStart(buffId, skipCb, closeCb) + self.BuffId = buffId + self.SkipCb = skipCb + self.CloseCb = closeCb +end + +function XUiStrongholdSkillDetailsDialog:OnEnable() + self:UpdateView() +end + +function XUiStrongholdSkillDetailsDialog:OnDestroy() + if self.CloseCb then + self.CloseCb() + end +end + +function XUiStrongholdSkillDetailsDialog:UpdateView() + local buffId = self.BuffId + + local icon = XStrongholdConfigs.GetBuffIcon(buffId) + self.RImgIcon:SetRawImage(icon) + + local name = XStrongholdConfigs.GetBuffName(buffId) + self.TxtName.text = name + + local desc = XStrongholdConfigs.GetBuffDesc(buffId) + self.TxtDesc.text = desc + + local hasCondition = XStrongholdConfigs.CheckBuffHasCondition(buffId) + if hasCondition then + local _, desc = XDataCenter.StrongholdManager.CheckBuffActive(buffId) + self.TxtRequirement.text = CsXTextManagerGetText("StrongholdBuffConditionDes", desc) + + local condition = XStrongholdConfigs.GetBuffConditionId(buffId) + local groupId = XConditionManager.GetConditionParams(condition) + local order = XStrongholdConfigs.GetGroupOrder(groupId) + self.TxtSkip.text = CsXTextManagerGetText("StrongholdBtnSkipDesc", order) + self.BtnSkip.gameObject:SetActiveEx(self.SkipCb and true or false) + + self.PanelRequirement.gameObject:SetActiveEx(true) + else + self.PanelRequirement.gameObject:SetActiveEx(false) + end +end + +function XUiStrongholdSkillDetailsDialog:AutoAddListener() + self.BtnTanchuangClose.CallBack = function() self:Close() end + self.BtnSkip.CallBack = function() self:OnClickBtnSkip() end +end + +function XUiStrongholdSkillDetailsDialog:OnClickBtnSkip() + local buffId = self.BuffId + local hasCondition = XStrongholdConfigs.CheckBuffHasCondition(buffId) + if not hasCondition then + return + end + + if self.SkipCb then + local condition = XStrongholdConfigs.GetBuffConditionId(buffId) + local groupId = XConditionManager.GetConditionParams(condition) + self:Close() + self.SkipCb(groupId) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdSupportTips.lua b/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdSupportTips.lua new file mode 100644 index 00000000..c9aa1f0b --- /dev/null +++ b/Resources/Scripts/XUi/XUiStronghold/XUiStrongholdSupportTips.lua @@ -0,0 +1,82 @@ +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate + +local XUiStrongholdSupportTips = XLuaUiManager.Register(XLuaUi, "UiStrongholdSupportTips") + +function XUiStrongholdSupportTips:OnAwake() + self:AutoAddListener() + + self.GridCondition.gameObject:SetActiveEx(false) + self.GridSupport.gameObject:SetActiveEx(false) +end + +function XUiStrongholdSupportTips:OnStart(supportId, teamList) + self.SupportId = supportId + self.TeamList = teamList + self.ConditionGrids = {} + self.SupportGrids = {} +end + +function XUiStrongholdSupportTips:OnEnable() + self:UpdateView() +end + +function XUiStrongholdSupportTips:UpdateView() + local supportId = self.SupportId + local teamList = self.TeamList + + --支援方案条件 + local conditionIds = XStrongholdConfigs.GetSupportConditionIds(supportId) + for index, conditionId in ipairs(conditionIds) do + local grid = self.ConditionGrids[index] + if not grid then + local ui = index == 1 and self.GridCondition or CSUnityEngineObjectInstantiate(self.GridCondition, self.SviewCondition) + grid = XTool.InitUiObjectByUi({}, ui) + self.ConditionGrids[index] = grid + end + + local isActive, desc = XConditionManager.CheckCondition(conditionId, teamList) + grid.TxtON.text = desc + grid.TxtOFF.text = desc + grid.PanelON.gameObject:SetActiveEx(isActive) + grid.PanelOFF.gameObject:SetActiveEx(not isActive) + + grid.GameObject:SetActiveEx(true) + end + for index = #conditionIds + 1, #self.ConditionGrids do + self.ConditionGrids[index].GameObject:SetActiveEx(false) + end + + --支援方案BUFF + local isActive = XDataCenter.StrongholdManager.CheckSupportActive(supportId, teamList) + self.PanelOn.gameObject:SetActiveEx(isActive) + self.PanelOff.gameObject:SetActiveEx(not isActive) + + local buffIds = XStrongholdConfigs.GetSupportBuffIds(supportId) + for index, buffId in ipairs(buffIds) do + local grid = self.SupportGrids[index] + if not grid then + local ui = index == 1 and self.GridSupport or CSUnityEngineObjectInstantiate(self.GridSupport, self.SviewSupport) + grid = XTool.InitUiObjectByUi({}, ui) + self.SupportGrids[index] = grid + end + + local desc = XStrongholdConfigs.GetBuffDesc(buffId) + grid.TxtON.text = desc + grid.TxtOFF.text = desc + grid.TxtON.gameObject:SetActiveEx(isActive) + grid.TxtOFF.gameObject:SetActiveEx(not isActive) + + grid.GameObject:SetActiveEx(true) + end + for index = #buffIds + 1, #self.SupportGrids do + self.SupportGrids[index].GameObject:SetActiveEx(false) + end +end + +function XUiStrongholdSupportTips:AutoAddListener() + self.BtnTanchuangCloseBig.CallBack = function() self:OnClickBtnClose() end +end + +function XUiStrongholdSupportTips:OnClickBtnClose() + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSummerEpisode/Settle/XUiGridSummerEpisodeSettleDataItem.lua b/Resources/Scripts/XUi/XUiSummerEpisode/Settle/XUiGridSummerEpisodeSettleDataItem.lua new file mode 100644 index 00000000..ff804510 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSummerEpisode/Settle/XUiGridSummerEpisodeSettleDataItem.lua @@ -0,0 +1,15 @@ +local XUiSummerEpisodeSettleDataItem = XClass(nil, "XUiSummerEpisodeSettleDataItem") + +function XUiSummerEpisodeSettleDataItem:Ctor(ui, name) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.TxtTitle.text = name +end + +function XUiSummerEpisodeSettleDataItem:Refresh(mvp, value) + self.ImgMvp.gameObject:SetActive(mvp and true or false) + self.TxtValue.text = value +end + +return XUiSummerEpisodeSettleDataItem diff --git a/Resources/Scripts/XUi/XUiSummerEpisode/Settle/XUiGridSummerEpisodeSettleItem.lua b/Resources/Scripts/XUi/XUiSummerEpisode/Settle/XUiGridSummerEpisodeSettleItem.lua new file mode 100644 index 00000000..a7973a1d --- /dev/null +++ b/Resources/Scripts/XUi/XUiSummerEpisode/Settle/XUiGridSummerEpisodeSettleItem.lua @@ -0,0 +1,99 @@ +local XUiGridSummerEpisodeSettleItem = XClass(nil, "UiGridSummerEpisodeSettleItem") +local XUiGridFightDataItem = require("XUi/XUiSummerEpisode/Settle/XUiGridSummerEpisodeSettleDataItem") + +function XUiGridSummerEpisodeSettleItem:Ctor(ui, parent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Parent = parent + XTool.InitUiObject(self) + XUiHelper.RegisterClickEvent(self, self.BtnReport, self.OnBtnReportClick) + XUiHelper.RegisterClickEvent(self, self.BtnLike, self.OnBtnLikeClick) + XUiHelper.RegisterClickEvent(self, self.BtnAddFriend, self.OnBtnAddFriendClick) +end + +function XUiGridSummerEpisodeSettleItem:OnBtnReportClick() + if self.IsAlreadyReport then + return + end + XUiManager.TipText("ReportFinish") + self.BtnReport.ButtonState = CS.UiButtonState.Disable + self.IsAlreadyReport = true +end + +function XUiGridSummerEpisodeSettleItem:OnBtnLikeClick() + self.Parent:OnAddLike(self.PlayerData.Id) +end + +function XUiGridSummerEpisodeSettleItem:OnBtnAddFriendClick() + self.Parent:OnApplyFriend(self.PlayerData.Id) +end + +function XUiGridSummerEpisodeSettleItem:Init(playerData, playerCount) + local medalConfig = XMedalConfigs.GetMeadalConfigById(playerData.MedalId) + local medalIcon = nil + if medalConfig then + medalIcon = medalConfig.MedalIcon + end + if medalIcon ~= nil then + self.ImgMedalIcon:SetRawImage(medalIcon) + self.ImgMedalIcon.gameObject:SetActiveEx(true) + else + self.ImgMedalIcon.gameObject:SetActiveEx(false) + end + + self.PlayerData = playerData + local character = playerData.Character + local headInfo = character.CharacterHeadInfo or {} + local headIcon = XDataCenter.CharacterManager.GetCharSmallHeadIcon(character.Id, true, headInfo.HeadFashionId, headInfo.HeadFashionType) + self.RImgIcon:SetRawImage(headIcon) + self.TxtName.text = XDataCenter.SocialManager.GetPlayerRemark(playerData.Id, playerData.Name) + local isArenaOnline = playerData.StageType and playerData.StageType == XDataCenter.FubenManager.StageType.ArenaOnline + local isPass = playerData.HaveFirstPass and playerCount > 1 + self.PanelArenaOnline.gameObject:SetActiveEx(isArenaOnline and isPass) + + local item1 = CS.UnityEngine.GameObject.Instantiate(self.GridFightDataItem, self.PanelFightDataContainer) + self.GridFightDataList = { + XUiGridFightDataItem.New(self.GridFightDataItem, CSXTextManagerGetText("SummerEpisodePhotoScore")), + XUiGridFightDataItem.New(item1, CSXTextManagerGetText("SummerEpisodeMischiefScore")), + } +end + +function XUiGridSummerEpisodeSettleItem:Refresh(dpsData) + if dpsData then + self.GridFightDataList[1]:Refresh(dpsData.IsPhotoMvp, dpsData.ScorePhoto) + self.GridFightDataList[2]:Refresh(dpsData.IsMischiefMvp, dpsData.ScoreByMischief) + else + self.GridFightDataList[1]:Refresh(false, 0) + self.GridFightDataList[2]:Refresh(false, 0) + end +end + +function XUiGridSummerEpisodeSettleItem:SwitchNormal() + self.PanelOperation.gameObject:SetActiveEx(true) + self.TxtMyself.gameObject:SetActiveEx(false) + self.BtnLike.gameObject:SetActiveEx(true) + self.ImgLikeDisabled.gameObject:SetActiveEx(false) + self.ImgLikeAlready.gameObject:SetActiveEx(false) +end + +function XUiGridSummerEpisodeSettleItem:SwitchMyself() + self.PanelOperation.gameObject:SetActiveEx(false) + self.TxtMyself.gameObject:SetActiveEx(true) + self.BtnLike.gameObject:SetActiveEx(false) + self.ImgLikeDisabled.gameObject:SetActiveEx(false) + self.ImgLikeAlready.gameObject:SetActiveEx(false) +end + +function XUiGridSummerEpisodeSettleItem:SwitchDisabledLike() + self.ImgLikeDisabled.gameObject:SetActiveEx(true) + self.ImgLikeAlready.gameObject:SetActiveEx(false) + self.BtnLike.gameObject:SetActiveEx(false) +end + +function XUiGridSummerEpisodeSettleItem:SwitchAlreadyLike() + self.ImgLikeDisabled.gameObject:SetActiveEx(false) + self.ImgLikeAlready.gameObject:SetActiveEx(true) + self.BtnLike.gameObject:SetActiveEx(false) +end + +return XUiGridSummerEpisodeSettleItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSummerEpisode/Settle/XUiSummerEpisodeSettle.lua b/Resources/Scripts/XUi/XUiSummerEpisode/Settle/XUiSummerEpisodeSettle.lua new file mode 100644 index 00000000..8883b843 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSummerEpisode/Settle/XUiSummerEpisodeSettle.lua @@ -0,0 +1,105 @@ +local XUiSummerEpisodeSettle = XLuaUiManager.Register(XLuaUi, "UiSummerEpisodeSettle") +local XUiGridFightGradeItem = require("XUi/XUiSummerEpisode/Settle/XUiGridSummerEpisodeSettleItem") + +local countDownTime = CS.XGame.Config:GetInt("OnlinePraiseCountDown") + +function XUiSummerEpisodeSettle:OnAwake() + self:RegisterClickEvent(self.BtnContinue, self.OnBtnContinueClick) +end + +function XUiSummerEpisodeSettle:OnStart(cb) + self:Init() + XEventManager.AddEventListener(XEventId.EVENT_ROOM_KICKOUT, self.OnKickOut, self) + self.Cb = cb +end + +function XUiSummerEpisodeSettle:OnDestroy() + XEventManager.RemoveEventListener(XEventId.EVENT_ROOM_KICKOUT, self.OnKickOut, self) +end + +function XUiSummerEpisodeSettle:OnKickOut() + XLuaUiManager.Remove("UiMultiplayerRoom") +end + +function XUiSummerEpisodeSettle:OnBtnContinueClick() + if not self.IsCountDownFinish then + return + end + self:Close() +end + +function XUiSummerEpisodeSettle:Init() + local beginData = XDataCenter.FubenManager.GetFightBeginData() + local PlayerList = beginData.PlayerList + local dpsTable = XDataCenter.FubenManager.SummerEpisodeDpsTable + if not dpsTable then + return + end + local index = 0 + self.GridList = {} + for _, v in pairs(PlayerList) do + local ui + if index == 0 then + ui = self.GridFightGradeItem + else + ui = CS.UnityEngine.GameObject.Instantiate(self.GridFightGradeItem, self.PanelFightGradeContainer) + end + self.GridList[v.Id] = XUiGridFightGradeItem.New(ui, self) + index = index + 1 + end + + for _, v in pairs(PlayerList) do + local dps = dpsTable[v.Id] + local grid = self.GridList[v.Id] + grid:Init(v, index) + grid:Refresh(dps) + if v.Id == XPlayer.Id then + grid:SwitchMyself() + else + grid:SwitchNormal() + end + end + + self:StartCountDown() +end + +function XUiSummerEpisodeSettle:StartCountDown() + self.IsCountDownFinish = false + self.TxtContinue.gameObject:SetActive(false) + self.PanelCountDown.gameObject:SetActive(true) + local startTicks = CS.XTimerManager.Ticks + local refresh = function(timer) + if not self.GameObject or not self.GameObject:Exist() then + self.IsCountDownFinish = true + XScheduleManager.UnSchedule(timer) + return + end + local t = countDownTime - (CS.XTimerManager.Ticks - startTicks) / CS.System.TimeSpan.TicksPerSecond + self.ImgCountDownBarRight.fillAmount = t / countDownTime + self.ImgCountDownBarLeft.fillAmount = t / countDownTime + if t <= 0 then + self.IsCountDownFinish = true + XScheduleManager.UnSchedule(timer) + self.TxtContinue.gameObject:SetActive(true) + self.PanelCountDown.gameObject:SetActive(false) + end + end + XScheduleManager.ScheduleForever(refresh, 0) +end + +function XUiSummerEpisodeSettle:OnAddLike(playerId) + XDataCenter.RoomManager.AddLike(playerId) + for k, v in pairs(self.GridList) do + if k ~= XPlayer.Id then + if k == playerId then + v:SwitchAlreadyLike() + else + v:SwitchDisabledLike() + end + end + end +end + +function XUiSummerEpisodeSettle:OnApplyFriend(playerId) + XDataCenter.SocialManager.ApplyFriend(playerId) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSummerEpisode/XUiGridEliminate.lua b/Resources/Scripts/XUi/XUiSummerEpisode/XUiGridEliminate.lua new file mode 100644 index 00000000..f8e504cd --- /dev/null +++ b/Resources/Scripts/XUi/XUiSummerEpisode/XUiGridEliminate.lua @@ -0,0 +1,118 @@ +local XUiGridEliminate = XClass(nil, "XUiGridEliminate") + +function XUiGridEliminate:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + self.BtnMatch.CallBack = function() + self:OnBtnMatchClick() + end + self.PanelSelect.gameObject:SetActiveEx(false) + self.PanelNeighSelected.gameObject:SetActiveEx(false) + self.FlipEffect.gameObject:SetActiveEx(false) + self.IsSelected = false + self.NeighborSelected = false + self.SelectEnable = false +end + +function XUiGridEliminate:SetData(data, gameId) + self.GameId = gameId + self.GridData = data +end + +--覆盖 +function XUiGridEliminate:SetupFlip() + self.PanelForbidden.gameObject:SetActiveEx(false) + self.PanelMask.gameObject:SetActiveEx(true) + self.PanelNeighSelected.gameObject:SetActiveEx(false) + self.SelectEnable = false + self.MaskEffect.gameObject:SetActiveEx(self:CheckCanFlipGrid()) +end + +function XUiGridEliminate:CheckCanFlipGrid() + + local gameData = XDataCenter.EliminateGameManager.GetEliminateGameData(self.GameId) + if not gameData then + return + end + + local flipCostItem = gameData.Config.FlipItemId + local count = XDataCenter.ItemManager.GetCount(flipCostItem) + local name = XDataCenter.ItemManager.GetItemName(flipCostItem) + if count <= 0 or count < gameData.Config.FlipItemCount then + --XUiManager.TipMsg(string.format(CS.XTextManager.GetText("EliminateFlipItemLack"), gameData.Config.FlipItemCount, name)) + return false + end + + return true +end + + +--障碍 +function XUiGridEliminate:SetupForbidden() + self.PanelForbidden.gameObject:SetActiveEx(true) + self.PanelMask.gameObject:SetActiveEx(false) + self.PanelNeighSelected.gameObject:SetActiveEx(false) + + self.SelectEnable = false +end + +--一般 +function XUiGridEliminate:SetupNormal() + self.PanelForbidden.gameObject:SetActiveEx(false) + self.PanelMask.gameObject:SetActiveEx(false) + self.PanelNeighSelected.gameObject:SetActiveEx(false) +end + +--消除了 +function XUiGridEliminate:SetupReward() + self.PanelForbidden.gameObject:SetActiveEx(false) + self.PanelMask.gameObject:SetActiveEx(false) + self.PanelNeighSelected.gameObject:SetActiveEx(false) +end + +--空的 +function XUiGridEliminate:SetupEmpty() + self.PanelForbidden.gameObject:SetActiveEx(false) + self.PanelMask.gameObject:SetActiveEx(false) + self.PanelNeighSelected.gameObject:SetActiveEx(false) +end + +function XUiGridEliminate:SetSelectedEnable(enable) + self.SelectEnable = enable +end + + +function XUiGridEliminate:SetSelected(selected) + self.PanelSelect.gameObject:SetActiveEx(selected) + self.IsSelected = selected +end + +function XUiGridEliminate:SetNeighBorSelected(selected) + self.PanelNeighSelected.gameObject:SetActiveEx(selected) + self.NeighborSelected = selected +end + +function XUiGridEliminate:OnBtnMatchClick() + self.RootUi:OnClickGrid(self.GridData) +end + +function XUiGridEliminate:IsObstacle() + local id = self.GridData.Id + local gridCfg = XEliminateGameConfig.GetEliminateGameGrid(id) + return gridCfg.Type == 0 +end + + +function XUiGridEliminate:PlayFlipTimeline(cb) + self.Timeline:PlayTimelineAnimation(function() + self.FlipEffect.gameObject:SetActiveEx(true) + if cb then + cb() + end + end) + +end + +return XUiGridEliminate \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSummerEpisode/XUiGridEliminateIcon.lua b/Resources/Scripts/XUi/XUiSummerEpisode/XUiGridEliminateIcon.lua new file mode 100644 index 00000000..186b504a --- /dev/null +++ b/Resources/Scripts/XUi/XUiSummerEpisode/XUiGridEliminateIcon.lua @@ -0,0 +1,30 @@ +local XUiGridEliminateIcon = XClass(nil, "XUiGridEliminateIcon") + +function XUiGridEliminateIcon:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + + self.Effect.gameObject:SetActiveEx(false) +end + +function XUiGridEliminateIcon:SetIcon(path) + self.ImgIcon:SetSprite(path) +end + +function XUiGridEliminateIcon:PlayTime(callback) + self.Timeline:PlayTimelineAnimation(callback) + self.Effect.gameObject:SetActiveEx(true) +end + + +function XUiGridEliminateIcon:PlayTimelineEnd() + self.Timeline.gameObject:SetActiveEx(false) + self.Effect.gameObject:SetActiveEx(false) + + self.Transform.localScale = CS.UnityEngine.Vector3.one + self.GameObject:SetActiveEx(false) +end + +return XUiGridEliminateIcon \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSummerEpisode/XUiGridMatchReward.lua b/Resources/Scripts/XUi/XUiSummerEpisode/XUiGridMatchReward.lua new file mode 100644 index 00000000..1ac619d4 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSummerEpisode/XUiGridMatchReward.lua @@ -0,0 +1,48 @@ +local XUiGridMatchReward = XClass(nil, "XUiGridMatchReward") + +function XUiGridMatchReward:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.BtnFinish.CallBack = function() + self:OnBtnFinishClick() + end + +end + + +function XUiGridMatchReward:Refresh(rewardData) + self.RewardData = rewardData + local gridType = rewardData.GridType + local grid = XEliminateGameConfig.GetEliminateGameGridByType(gridType) + + self.TxtName.text = CS.XTextManager.GetText("Eliminate") + self.ImgIcon:SetSprite(grid.TypePic) + local isRewarded = XDataCenter.EliminateGameManager.IsRewarded(rewardData.GameId, rewardData.Id) + local isFinish = XDataCenter.EliminateGameManager.IsRewardFinish(rewardData) + self.PanelReceiveRewards.gameObject:SetActiveEx(isFinish and not isRewarded) + self.PanelFinish.gameObject:SetActiveEx(isRewarded) + self.PanelNor.gameObject:SetActiveEx(not isRewarded and not isFinish) + + if not self.RewarDItem then + self.RewardItem = XUiGridCommon.New(self.RootUi, self.GridCommon) + end + + local rewards = XRewardManager.GetRewardList(rewardData.RewardId) + if not rewards then + self.GridCommon.gameObject:SetActiveEx(false) + else + self.GridCommon.gameObject:SetActiveEx(true) + self.RewardItem:Refresh(rewards[1]) + end +end + +function XUiGridMatchReward:OnBtnFinishClick() + local isRewarded = XDataCenter.EliminateGameManager.IsRewarded(self.RewardData.GameId, self.RewardData.Id) + local isFinish = XDataCenter.EliminateGameManager.IsRewardFinish(self.RewardData) + if isFinish and not isRewarded then + XDataCenter.EliminateGameManager.RequestEliminateGameGetReward(self.RewardData.GameId, self.RewardData.Id) + end +end + +return XUiGridMatchReward \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSummerEpisode/XUiGridNewSpecialReward.lua b/Resources/Scripts/XUi/XUiSummerEpisode/XUiGridNewSpecialReward.lua new file mode 100644 index 00000000..53ed1964 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSummerEpisode/XUiGridNewSpecialReward.lua @@ -0,0 +1,81 @@ +local XUiGridNewSpecialReward = XClass(nil, "XUiGridNewSpecialReward") + +function XUiGridNewSpecialReward:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + + self.BtnClick.CallBack = function() self:OnBtnRewardClick() end +end + +function XUiGridNewSpecialReward:UpdateData(data, nextData, pointCounts) + self.PointRewardId = data.Id + self.NeedPoint = data.NeedPoint + self.RewardId = data.RewardId + self.ShowItem = data.ShowItem + self.TxtCurStage.text = self.NeedPoint + self.PointCounts = pointCounts + local nextNeedPoint + if nextData then + nextNeedPoint = nextData.NeedPoint + end + self.Red.gameObject:SetActiveEx(false) + self.PanelFinish.gameObject:SetActiveEx(false) + + if self.ShowItem and self.ShowItem ~= 0 then + local item = {} + item.Id = self.ShowItem + item.Count = data.ShowItemNum + self.GridCommon.gameObject:SetActiveEx(true) + self.ImgActive.gameObject:SetActiveEx(false) + self.Grid = XUiGridCommon.New(self.RootUi, self.GridCommon) + self.Grid:Refresh(item) + else + self.GridCommon.gameObject:SetActiveEx(false) + self.ImgActive.gameObject:SetActiveEx(true) + end + + if pointCounts >= self.NeedPoint then + if not XDataCenter.FubenSpecialTrainManager.CheckPointRewardGet(self.PointRewardId) then + self.Red.gameObject:SetActiveEx(true) + else + self.PanelFinish.gameObject:SetActiveEx(true) + end + if not nextNeedPoint then + self.PanelPassedLine.fillAmount = 0 + elseif pointCounts < nextNeedPoint then + self.PanelPassedLine.fillAmount = (pointCounts - self.NeedPoint) / (nextNeedPoint - self.NeedPoint) + else + self.PanelPassedLine.fillAmount = 1 + end + else + self.PanelPassedLine.fillAmount = 0 + end +end + +function XUiGridNewSpecialReward:OnBtnRewardClick() + local itemList = XRewardManager.GetRewardList(self.RewardId) + + if self.PointCounts >= self.NeedPoint then + if not XDataCenter.FubenSpecialTrainManager.CheckPointRewardGet(self.PointRewardId) then + XDataCenter.FubenSpecialTrainManager.SpecialTrainPointRewardRequest(self.PointRewardId, function(reward) + XUiManager.OpenUiObtain(reward, CS.XTextManager.GetText("Award")) + end) + else + XUiManager.TipError(CS.XTextManager.GetText("SpecialPointRewardIsGet")) + end + elseif self.ShowItem and self.ShowItem ~= 0 then + -- local item = XDataCenter.ItemManager.GetItem(self.ShowItem) + -- local data = { + -- Id = item.Id, + -- Count = item ~= nil and tostring(item.Count) or "0" + -- } + -- XLuaUiManager.Open("UiTip", data) + self.Grid:OnBtnClickClick() + else + XUiManager.OpenUiTipReward(itemList) + end +end + +return XUiGridNewSpecialReward \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSummerEpisode/XUiGridStageSpecialTrain.lua b/Resources/Scripts/XUi/XUiSummerEpisode/XUiGridStageSpecialTrain.lua new file mode 100644 index 00000000..c57311a2 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSummerEpisode/XUiGridStageSpecialTrain.lua @@ -0,0 +1,50 @@ +local XUiGridStageSpecialTrain = XClass(nil, "XUiGridStageSpecialTrain") + +function XUiGridStageSpecialTrain:Ctor(ui, parent, rootUi) + + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.ParentUi = parent + + XTool.InitUiObject(self) + CsXUiHelper.RegisterClickEvent(self.BtnStage, handler(self, self.OnBtnStageClick)) + self.Star = {} + for i = 1, 3, 1 do + self.Star[i] = self["ImgDone" .. i].gameObject + end +end + +function XUiGridStageSpecialTrain:Refresh(stageId, chapterData, index) + self.StageId = stageId + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + + self.StageCfg = stageCfg + self.StageInfo = stageInfo + + self.TxtStage.text = stageCfg.Name + self.RawImgBg:SetRawImage(stageCfg.Icon) + self.TextOderNum.text = string.format("%s -%s", chapterData.PrefixName, index) + if stageCfg.IsMultiplayer then + self.PanelStar.gameObject:SetActiveEx(false) + else + self.PanelStar.gameObject:SetActiveEx(true) + local starsMap = stageInfo.StarsMap + for i, v in ipairs(self.Star) do + self.Star[i]:SetActiveEx(starsMap[i] or false) + end + end + + self.PanelKillParent.gameObject:SetActiveEx(stageInfo.Passed) +end + +function XUiGridStageSpecialTrain:OnBtnStageClick() + if self.ClickCb then + self.ClickCb(self) + end + + self.ParentUi:ClickStageGrid(self) +end + +return XUiGridStageSpecialTrain \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSummerEpisode/XUiGridStarReward.lua b/Resources/Scripts/XUi/XUiSummerEpisode/XUiGridStarReward.lua new file mode 100644 index 00000000..74f25392 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSummerEpisode/XUiGridStarReward.lua @@ -0,0 +1,101 @@ +XUiGridStarReward = XClass(nil, "XUiGridStarReward") + +function XUiGridStarReward:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + self.GridCommon.gameObject:SetActive(false) + + self.GridList = {} + + self.BtnReceive.CallBack = function() self:OnBtnReceiveClick() end +end + +-- auto +function XUiGridStarReward:OnBtnReceiveClick() + + if not self.Data.IsFinish then + return + end + + XDataCenter.FubenSpecialTrainManager.SpecialTrainGetRewardRequest(self.Data.Id, function(reward) + XUiManager.OpenUiObtain(reward, CS.XTextManager.GetText("Award")) + self:Refresh(self.Data, self.ChapterId) + end) +end + +function XUiGridStarReward:Refresh(data, chapterId) + self.Data = data + self.ChapterId = chapterId + local totalStar = XDataCenter.FubenSpecialTrainManager.GetSpecialTrainNormalChapterStar(chapterId) + local requireStars = data.RequireStar + local curStars = totalStar > requireStars and requireStars or totalStar + self.TxtGradeStarNums.text = CS.XTextManager.GetText("GradeStarNum", curStars, requireStars) + if data.IsFinish then + self:SetStarsActive(true) + local isGet = XDataCenter.FubenSpecialTrainManager.IsReward(data.Id) + if isGet then + self:SetBtnAlreadyReceive() + else + self:SetBtnActive() + end + else + self:SetStarsActive(false) + self:SetBtnCannotReceive() + end + + self:SetupTreasureList() +end + +function XUiGridStarReward:SetBtnActive() + self.BtnReceive.gameObject:SetActive(true) + self.ImgAlreadyReceived.gameObject:SetActive(false) + self.ImgCannotReceive.gameObject:SetActive(false) +end + +function XUiGridStarReward:SetBtnCannotReceive() + self.BtnReceive.gameObject:SetActive(false) + self.ImgAlreadyReceived.gameObject:SetActive(false) + self.ImgCannotReceive.gameObject:SetActive(true) +end + +function XUiGridStarReward:SetBtnAlreadyReceive() + self.BtnReceive.gameObject:SetActive(false) + self.ImgAlreadyReceived.gameObject:SetActive(true) + self.ImgCannotReceive.gameObject:SetActive(false) +end + +function XUiGridStarReward:SetStarsActive(flag) + self.ImgGradeStarActive.gameObject:SetActive(flag) + self.ImgGradeStarUnactive.gameObject:SetActive(not flag) +end + +-- 初始化 +function XUiGridStarReward:SetupTreasureList() + if self.Data == nil or self.Data.RewardId == 0 then + XLog.Error("treasure have no RewardId ") + return + end + + local rewards = XRewardManager.GetRewardList(self.Data.RewardId) + for i, item in ipairs(rewards) do + local grid = self.GridList[i] + if not grid then + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommon) + grid = XUiGridCommon.New(self.RootUi, ui) + grid.Transform:SetParent(self.PanelTreasureContent, false) + self.GridList[i] = grid + end + grid:Refresh(item) + grid.GameObject:SetActive(true) + end + + for j = 1, #self.GridList do + if j > #rewards then + self.GridList[j].GameObject:SetActive(false) + end + end +end + +return XUiGridStarReward \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSummerEpisode/XUiGridSummerEpisodeMap.lua b/Resources/Scripts/XUi/XUiSummerEpisode/XUiGridSummerEpisodeMap.lua new file mode 100644 index 00000000..ff6d6e81 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSummerEpisode/XUiGridSummerEpisodeMap.lua @@ -0,0 +1,30 @@ +local XUiGridSummerEpisodeMap = XClass(nil, "XUiGridSummerEpisodeMap") + +function XUiGridSummerEpisodeMap:Ctor(ui,stageId,rootUi) + self.GameObject = ui + self.Transform = ui.transform + self.StageId = stageId + self.RootUi = rootUi + XTool.InitUiObject(self) + self:InitUiView() +end + +function XUiGridSummerEpisodeMap:InitUiView() + self.TxtMapName.text = XDataCenter.FubenManager.GetStageName(self.StageId) + local config = XDataCenter.FubenManager.GetStageCfg(self.StageId) + if config then + self.RImgMap:SetRawImage(config.StoryIcon) + end +end + +function XUiGridSummerEpisodeMap:SetClickEvent(event) + self.RootUi:RegisterClickEvent(self.BtnMap, function() + event(self.StageId) + end) +end + +function XUiGridSummerEpisodeMap:SetSelect(isSelect) + self.Activate.gameObject:SetActiveEx(isSelect) +end + +return XUiGridSummerEpisodeMap \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSummerEpisode/XUiGridSummerEpisodePicture.lua b/Resources/Scripts/XUi/XUiSummerEpisode/XUiGridSummerEpisodePicture.lua new file mode 100644 index 00000000..635868c6 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSummerEpisode/XUiGridSummerEpisodePicture.lua @@ -0,0 +1,14 @@ +local XUiGridSummerEpisodePicture = XClass(nil,"XUiGridSummerEpisodePicture") + +function XUiGridSummerEpisodePicture:Ctor(ui) + self.GameObject = ui + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiGridSummerEpisodePicture:Refresh(imgPath) + if not imgPath then return end + self.RImgPicture:SetRawImage(imgPath) +end + +return XUiGridSummerEpisodePicture \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSummerEpisode/XUiGridSummerRank.lua b/Resources/Scripts/XUi/XUiSummerEpisode/XUiGridSummerRank.lua new file mode 100644 index 00000000..16249664 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSummerEpisode/XUiGridSummerRank.lua @@ -0,0 +1,100 @@ +local XUiGridSummerRank = XClass(nil, "XUiGridSummerRank") + +local stringOther = "%s" +local stringSelf = "%s" + +function XUiGridSummerRank:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + self.BtnAdd.CallBack = function() + self:OnBtnAddFriendClick() + end + + self.BtnTipOff.CallBack = function() + self:OnBtnReport() + end +end + +function XUiGridSummerRank:Refresh(playerData, index) + local player = playerData.Player + self.PlayerData = player + + local isSelf = player.Id == XPlayer.Id + self.PanelSelf.gameObject:SetActiveEx(isSelf) + + XUiPLayerHead.InitPortrait(player.HeadPortraitId, player.HeadFrameId, self.Head) + + local colorFormat = stringOther + if isSelf then + colorFormat = stringSelf + end + + self.TxtName.text = string.format(colorFormat, XDataCenter.SocialManager.GetPlayerRemark(player.Id, player.Name)) + + if playerData.RankType == XFubenSpecialTrainConfig.StageType.Broadsword then + self.TxtTime.gameObject:SetActiveEx(false) + self.Txtkill.gameObject:SetActiveEx(true) + self.Txtkill.text = string.format(colorFormat, playerData.Count) + if playerData.Count and playerData.Count ~= 0 then + self.Txtkill.gameObject:SetActiveEx(true) + else + self.Txtkill.gameObject:SetActiveEx(false) + end + elseif playerData.RankType == XFubenSpecialTrainConfig.StageType.Alive then + + self.Txtkill.gameObject:SetActiveEx(false) + self.TxtTime.text = string.format(colorFormat, XUiHelper.GetTime(playerData.Time, XUiHelper.TimeFormatType.TOWER_RANK)) + if playerData.Time and playerData.Time ~= 0 then + self.TxtTime.gameObject:SetActiveEx(true) + else + self.TxtTime.gameObject:SetActiveEx(false) + end + end + + self.TxtOrder.text = string.format(colorFormat, index) + if index == 1 then + self.TxtOrderName.text = string.format(colorFormat, "st") + elseif index == 2 then + self.TxtOrderName.text = string.format(colorFormat, "nd") + elseif index == 3 then + self.TxtOrderName.text = string.format(colorFormat, "rd") + else + self.TxtOrderName.text = string.format(colorFormat, "th") + end + + self.TxtKillDesc.text = string.format(colorFormat, self.TxtKillDesc.text) + self.TxtTimeDesc.text = string.format(colorFormat, self.TxtTimeDesc.text) + self.TxtKillDesc1.text = string.format(colorFormat, self.TxtKillDesc1.text) + + self.BtnAdd.gameObject:SetActiveEx(not XDataCenter.SocialManager.CheckIsFriend(self.PlayerData.Id)) +end + +-- 加好友 +function XUiGridSummerRank:OnBtnAddFriendClick() + if self.IsAddFriend then + return + end + + self.IsAddFriend = true + + XDataCenter.SocialManager.ApplyFriend(self.PlayerData.Id, function() + self.BtnAdd.ButtonState = CS.UiButtonState.Disable + end) +end + +--举报 +function XUiGridSummerRank:OnBtnReport() + + if self.IsReport then + return + end + + XLuaUiManager.Open("UiReport", self.PlayerData.Id, self.PlayerData.Name, self.PlayerData.Level, nil, function() + self.BtnTipOff.ButtonState = CS.UiButtonState.Disable + self.IsReport = true + end) +end + +return XUiGridSummerRank \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSummerEpisode/XUiSummerEpisode.lua b/Resources/Scripts/XUi/XUiSummerEpisode/XUiSummerEpisode.lua new file mode 100644 index 00000000..e016a3dd --- /dev/null +++ b/Resources/Scripts/XUi/XUiSummerEpisode/XUiSummerEpisode.lua @@ -0,0 +1,535 @@ +local XUiSummerEpisode = XLuaUiManager.Register(XLuaUi, "UiSummerEpisode") +local XUiSummerEpisodeChapter = require("XUi/XUiSummerEpisode/XUiSummerEpisodeChapter") +local XUiGridNewSpecialReward = require("XUi/XUiSummerEpisode/XUiGridNewSpecialReward") +function XUiSummerEpisode:OnAwake() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self.TabPool = {} + self.CurChapterIndex = 1 + + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + -- self.BtnHelpCourse.CallBack = function() self:OnBtnHelpCourseClick() end + self.HelpDataFunc = function () return self:GetHelpDataFunc() end + self:BindHelpBtnNew(self.BtnHelpCourse, self.HelpDataFunc) + self.BtnMatchGame.CallBack = function() self:OnBtnHMatchGameClick() end + self.BtnTemplate.gameObject:SetActiveEx(false) + + self.Red.gameObject:SetActiveEx(false) + self.PanelAsset.gameObject:SetActiveEx(false) + + CsXUiHelper.RegisterClickEvent(self.BtnTreasure, handler(self, self.OnBtnTreasure)) + + self.BtnTask.CallBack = function() self:OnBtnTreasure() end +end + +function XUiSummerEpisode:OnStart(id, chapterId, bOpenTask) + self.CurActivityId = id + self.NewRewardGridList = {} + + XDataCenter.FubenSpecialTrainManager.CurActiveId = id + self.ActivityConfig = XFubenSpecialTrainConfig.GetActivityConfigById(id) + self.Chapters = self.ActivityConfig.ChapterIds + self.ChapterConfig = {} + for i, v in ipairs(self.Chapters) do + if chapterId and chapterId == v then + self.CurChapterIndex = i + end + + local chapeter = XFubenSpecialTrainConfig.GetChapterConfigById(v) + table.insert(self.ChapterConfig, chapeter) + end + + if self.ActivityConfig.EliminateGameId == 0 then + self.BtnMatchGame.gameObject:SetActiveEx(false) + else + self.BtnMatchGame.gameObject:SetActiveEx(true) + end + + self.ChapterPanel = XUiSummerEpisodeChapter.New(self.FubenChapter, self) + self.CurChapter = self.ChapterConfig[self.CurChapterIndex] + + self:SetupPanel() + self:TryShowHelpTip() + + if bOpenTask and bOpenTask > 0 then + self:OnBtnTreasure() + end +end + +--设置面板 +function XUiSummerEpisode:SetupPanel() + self:SetupTitle() + self:SetupChapter() + self:SetupEliminateGame() +end + +--弹出帮助 +function XUiSummerEpisode:TryShowHelpTip() + local value = XDataCenter.FubenSpecialTrainManager.GetSpecialTrainPrefs(self.CurActivityId, self.CurChapter.Id) + if value == 0 then + XUiManager.ShowHelpTipNew(self.HelpDataFunc) + XDataCenter.FubenSpecialTrainManager.SaveSpecialTrainPrefs(1, self.CurActivityId, self.CurChapter.Id) + end +end + +function XUiSummerEpisode:SetupEliminateGame() + self.Red.gameObject:SetActiveEx(false) + + self.TxtGame.gameObject:SetActiveEx(false) + if not XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.EliminateGame) then + return + end + + local id = self.ActivityConfig.EliminateGameId + if XDataCenter.EliminateGameManager.CheckTimeOut(id) then + return + end + + XDataCenter.EliminateGameManager.TryGetEliminateGameData(id, function() + local gameData = XDataCenter.EliminateGameManager.GetEliminateGameData(id) + + local totalRewardCount = #gameData.Rewards + local finish = #gameData.RewardIds + self.TxtGame.text = string.format("%s/%s", finish, totalRewardCount) + self.TxtGame.gameObject:SetActiveEx(true) + self.Red.gameObject:SetActiveEx(XDataCenter.EliminateGameManager.CheckGameHasReward(id)) + end) +end + +--设置标题 +function XUiSummerEpisode:SetupTitle() + self:SetTimer() +end + +--停止计时器 +function XUiSummerEpisode:StopTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end + +--活动时间倒计时 +function XUiSummerEpisode:SetTimer() + local endTimeSecond = XFunctionManager.GetEndTimeByTimeId(self.ActivityConfig.TimeId) + local now = XTime.GetServerNowTimestamp() + if now <= endTimeSecond then + local activeOverStr = CS.XTextManager.GetText("ArenaOnlineLeftTimeOver") + self:StopTimer() + if now <= endTimeSecond then + self.TextTime.text = string.format("%s", XUiHelper.GetTime(endTimeSecond - now, XUiHelper.TimeFormatType.ACTIVITY)) + else + self.TextTime.text = activeOverStr + end + + self.Timer = XScheduleManager.ScheduleForever(function() + now = XTime.GetServerNowTimestamp() + if now > endTimeSecond then + self:OnActivityEnd() + return + end + if now <= endTimeSecond then + self.TextTime.text = string.format("%s", XUiHelper.GetTime(endTimeSecond - now, XUiHelper.TimeFormatType.ACTIVITY)) + else + self.TextTime.text = activeOverStr + end + end, XScheduleManager.SECOND, 0) + end +end + +--活动结束 +function XUiSummerEpisode:OnActivityEnd() + XUiManager.TipMsg(CS.XTextManager.GetText("SpecialTrainTimeOut")) + self:StopTimer() + self:Close() +end + + +function XUiSummerEpisode:OnDestroy() + --XDataCenter.FubenSpecialTrainManager.CurActiveId = -1 +end + +--设置奖励 +function XUiSummerEpisode:SetupReward() + if self.ActivityConfig.PointItemId ~= 0 then + self.PanelBottom.gameObject:SetActiveEx(false) + self.PanelCourse.gameObject:SetActiveEx(true) + local func = function () + self:SetupRewardNew() + end + XDataCenter.ItemManager.AddCountUpdateListener(self.ActivityConfig.PointItemId, func, self.GameObject) + self:SetupRewardNew() + end + self:SetupRewardOld() +end + +function XUiSummerEpisode:SetupRewardNew() + local pointCount = XDataCenter.ItemManager.GetCount(self.ActivityConfig.PointItemId) + self.TxtPoint.text = pointCount + local defaultIndex + for index, pointId in ipairs(self.ActivityConfig.PointRewardId) do + local tmpPointCfg = XFubenSpecialTrainConfig.GetSpecialPointRewardConfig(pointId) + local nextPointCfg = self.ActivityConfig.PointRewardId[index + 1] and XFubenSpecialTrainConfig.GetSpecialPointRewardConfig(self.ActivityConfig.PointRewardId[index + 1]) or nil + local grid + if not self.NewRewardGridList[index] then + if index == 1 then + grid = XUiGridNewSpecialReward.New(self.GridCourse, self) + self.GridCourse.gameObject:SetActiveEx(true) + self.GridCourse.transform:SetParent(self.PanelCourseContainer, false) + else + local ui = CS.UnityEngine.Object.Instantiate(self.GridCourse) + ui.gameObject:SetActiveEx(true) + ui.transform:SetParent(self.PanelCourseContainer, false) + grid = XUiGridNewSpecialReward.New(ui, self) + end + self.NewRewardGridList[index] = grid + else + grid = self.NewRewardGridList[index] + end + grid:UpdateData(tmpPointCfg, nextPointCfg, pointCount) + if not defaultIndex and not XDataCenter.FubenSpecialTrainManager.CheckPointRewardGet(pointId) then + defaultIndex = index + end + end + -- 针对全部领取的情况处理滑动 + if not defaultIndex then + defaultIndex = #self.ActivityConfig.PointRewardId + local pointId = self.ActivityConfig.PointRewardId[defaultIndex] + --如果最后一个没有被领取则不是全部被领取 + if not XDataCenter.FubenSpecialTrainManager.CheckPointRewardGet(pointId) then + defaultIndex = nil + end + end + + if defaultIndex then + self:SetSViewIndex(defaultIndex) + end +end + +function XUiSummerEpisode:SetSViewIndex(defaultIndex) + local length = #self.ActivityConfig.PointRewardId or 0 + if defaultIndex then + if defaultIndex <= 1 then + defaultIndex = 0 + elseif defaultIndex >= 16 then + defaultIndex = 1 + end + + local percentage = 0 + if length > 0 then + percentage = (defaultIndex - 1) / length + end + self.SViewCourse.horizontalNormalizedPosition = percentage + CS.UnityEngine.Canvas.ForceUpdateCanvases() + end +end + +function XUiSummerEpisode:SetupRewardOld() + if self.CurChapter.RewardType == XDataCenter.FubenSpecialTrainManager.RewardType.StarReward then + local totalStars = 0 + local isRed = false + local curStars = XDataCenter.FubenSpecialTrainManager.GetSpecialTrainNormalChapterStar(self.CurChapter.Id) + local starRewardList = XDataCenter.FubenSpecialTrainManager.GetSpecialTrainNormalChapterReward(self.CurChapter.Id) + + for i, v in ipairs(starRewardList) do + totalStars = totalStars < v.RequireStar and v.RequireStar or totalStars + if v.IsFinish and not v.IsReward then + isRed = true + end + end + + self.ImgJindu.fillAmount = totalStars > 0 and curStars / totalStars or 0 + self.ImgJindu.gameObject:SetActiveEx(true) + self.ImgLingqu.gameObject:SetActiveEx(totalStars <= curStars and (not isRed)) + self.ImgRedProgress.gameObject:SetActiveEx(isRed) + + self.MultiyPlayerNum.gameObject:SetActiveEx(false) + self.SinglePlayerNum.gameObject:SetActiveEx(true) + + self.TxtSinglePlayerFinishNum.text = string.format("%s/%s", curStars, totalStars) + -- self.TxtSinglePlayerTotalNum.text = "/" .. tostring(totalStars) + elseif self.CurChapter.RewardType == XDataCenter.FubenSpecialTrainManager.RewardType.Task then + local isRed = false + local tasks = XDataCenter.FubenSpecialTrainManager.GetSpecialTrainChapterTask(self.CurChapter.Id) + local finishCount = 0 + local achievedCount = 0 + + for i, v in ipairs(tasks) do + local task = XDataCenter.TaskManager.GetTaskDataById(v) + if task.State == XDataCenter.TaskManager.TaskState.Achieved then + achievedCount = achievedCount + 1 + isRed = true + end + + if task.State == XDataCenter.TaskManager.TaskState.Finish then + finishCount = finishCount + 1 + end + end + + local taskCount = #tasks + + self.ImgJindu.fillAmount = taskCount > 0 and (finishCount + achievedCount) / taskCount or 0 + self.ImgLingqu.gameObject:SetActiveEx(taskCount == finishCount) + self.ImgRedProgress.gameObject:SetActiveEx(isRed) + + self.TaskRed.gameObject:SetActiveEx(isRed) + + self.MultiyPlayerNum.gameObject:SetActiveEx(true) + self.SinglePlayerNum.gameObject:SetActiveEx(false) + + self.TxtMultiyPlayerFinishNum.text = tostring(finishCount) + self.TxtMultiyPlayerTotalNum.text = tostring(taskCount) + end +end + + + +--设置章节 +function XUiSummerEpisode:SetupChapter() + if not self.ChapterConfig then + return + end + + --self.HelpIds = {} + --小型缓冲池 + if self.BtnTabList and #self.BtnTabList then + for i, v in ipairs(self.BtnTabList) do + table.insert(self.TabPool, v) + v.gameObject:SetActive(false) + end + end + + self.BtnTabList = {} + local chapterCount = 0 + + for i, v in ipairs(self.ChapterConfig) do + if not self.TabPool or #self.TabPool <= 0 then + local go = CS.UnityEngine.GameObject.Instantiate(self.BtnTemplate.gameObject) + go.transform:SetParent(self.PanelTab.transform, false) + local btn = go:GetComponent("XUiButton") + table.insert(self.TabPool, btn) + end + + local tab = table.remove(self.TabPool, 1) + tab.gameObject:SetActive(true) + table.insert(self.BtnTabList, tab) + + tab:SetSprite(v.TabImage) + tab:SetNameByGroup(0, v.Name) + tab:SetNameByGroup(1, v.SecondName) + + chapterCount = chapterCount + 1 + end + + -- 初始化按钮 + self.PanelTab:Init(self.BtnTabList, function(index) self:OnBtnTabListClick(index) end) + self.PanelTab:SelectIndex(self.CurChapterIndex) + + self.PanelTab.gameObject:SetActiveEx(chapterCount > 1) + +end + +function XUiSummerEpisode:OnBtnTabListClick(index) + if self.CurChapterIndex == index then + return + end + + if XDataCenter.RoomManager.Matching then + local title = CS.XTextManager.GetText("TipTitle") + local cancelMatchMsg = CS.XTextManager.GetText("OnlineInstanceCancelMatch") + XUiManager.DialogTip(title, cancelMatchMsg, XUiManager.DialogType.Normal, function() self.PanelTab:SelectIndex(self.CurChapterIndex) end, function() + XDataCenter.RoomManager.CancelMatch(function() + self:ChangeChapter(index) + end) + end) + else + self:ChangeChapter(index) + end +end + +function XUiSummerEpisode:ChangeChapter(index) + self.CurChapterIndex = index + self.CurChapter = self.ChapterConfig[self.CurChapterIndex] + self:SetupChapterStage() + + self:TryShowHelpTip() + + self:PlayAnimation("AnimStartEnable", function() + XLuaUiManager.SetMask(false) + end, function() + XLuaUiManager.SetMask(true) + end) +end + +--设置关卡 +function XUiSummerEpisode:SetupChapterStage() + if not self.CurChapter then + return + end + + self:SwitchChapterBg() + self:SetupReward() + self.ChapterPanel:SetupChapterStage(self.CurChapter) +end + +--切换背景 +function XUiSummerEpisode:SwitchChapterBg() + local icon = self.CurChapter.BgIcon + self.Background:SetRawImage(icon) +end + + +function XUiSummerEpisode:OnEnable() + if XDataCenter.FubenSpecialTrainManager.CheckActivityTimeout(self.CurActivityId, true) then + XLuaUiManager.RunMain() + return + end + + self:SetupChapterStage() + self:SetupEliminateGame() + self:SetTimer() + + self:PlayAnimation("AnimStartEnable", function() + XLuaUiManager.SetMask(false) + end, function() + XLuaUiManager.SetMask(true) + end) +end + +function XUiSummerEpisode:OnDisable() + self:StopTimer() +end + +function XUiSummerEpisode:OnNotify(evt, ...) + if evt == XEventId.EVENT_FUBEN_CLOSE_FUBENSTAGEDETAIL then + self.StageDetailOpen = false + self.ChildUi = nil + -- self.PanelAsset.gameObject:SetActiveEx(true) + elseif evt == XEventId.EVENT_FUBEN_SPECIAL_TRAIN_REWARD or evt == XEventId.EVENT_TASK_SYNC then + self:SetupReward() + end +end + +function XUiSummerEpisode:OnGetEvents() + return { XEventId.EVENT_FUBEN_CLOSE_FUBENSTAGEDETAIL, XEventId.EVENT_FUBEN_SPECIAL_TRAIN_ACTIVITY_CHANGE, XEventId.EVENT_FUBEN_SPECIAL_TRAIN_REWARD, XEventId.EVENT_TASK_SYNC } +end + +function XUiSummerEpisode:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiSummerEpisode:OnBtnBackClick() + if XDataCenter.RoomManager.Matching then + local title = CS.XTextManager.GetText("TipTitle") + local cancelMatchMsg = CS.XTextManager.GetText("OnlineInstanceCancelMatch") + XUiManager.DialogTip(title, cancelMatchMsg, XUiManager.DialogType.Normal, nil, function() + XDataCenter.RoomManager.CancelMatch(function() + self:Close() + end) + end) + else + self:Close() + end +end + +-- 获取教程数据函数 +function XUiSummerEpisode:GetHelpDataFunc() + self.ChapterPanel:CancelSelect() + + local helpIds = {} + for _, var in ipairs(self.CurChapter.HelpId) do + table.insert(helpIds, var) + end + + if not helpIds then + return + end + + local helpConfigs = {} + for i = 1, #helpIds do + helpConfigs[i] = XHelpCourseConfig.GetHelpCourseTemplateById(helpIds[i]) + end + + return helpConfigs +end + +--打开小游戏 +function XUiSummerEpisode:OnBtnHMatchGameClick() + if XDataCenter.RoomManager.Matching then + local title = CS.XTextManager.GetText("TipTitle") + local cancelMatchMsg = CS.XTextManager.GetText("OnlineInstanceCancelMatch") + XUiManager.DialogTip(title, cancelMatchMsg, XUiManager.DialogType.Normal, nil, function() + XDataCenter.RoomManager.CancelMatch(function() + self:OpenMatchGame() + end) + end) + else + self:OpenMatchGame() + end +end + +function XUiSummerEpisode:OpenMatchGame() + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.EliminateGame) then + return + end + + self.ChapterPanel:CancelSelect() + + local id = self.ActivityConfig.EliminateGameId + if XDataCenter.EliminateGameManager.CheckTimeOut(id, true) then + return + end + XDataCenter.EliminateGameManager.TryGetEliminateGameData(id, function() + XLuaUiManager.Open("UiSummerMatch", self.ActivityConfig.EliminateGameId) + end) +end + +--打开关卡详情 +function XUiSummerEpisode:OpenStageDetail(stage) + if not stage then + return + end + + local childUi + + if stage.IsMultiplayer then + childUi = "UiSummerOnlineSection" + else + childUi = "UiSummerStageDetail" + end + + + -- if self.StageDetailOpen and childUi == self.ChildUi then + -- return + -- end + self.StageDetailOpen = true + + self.ChildUi = childUi + + self.Stage = stage + + self:OpenOneChildUi(self.ChildUi, self, stage) + + --self.PanelAsset.gameObject:SetActiveEx(false) +end + +--关闭关卡详情 +function XUiSummerEpisode:CloseStageDetail() + if self.StageDetailOpen and self.ChildUi then + self:CloseChildUi(self.ChildUi) + self.StageDetailOpen = false + self.ChildUi = nil + + --self.PanelAsset.gameObject:SetActiveEx(true) + end +end + +--打开任务或者任务 +function XUiSummerEpisode:OnBtnTreasure() + self.ChapterPanel:CancelSelect() + if self.CurChapter.RewardType == XDataCenter.FubenSpecialTrainManager.RewardType.StarReward then + self:OpenOneChildUi("UiSummerStarReward", self) + else + self:OpenOneChildUi("UiSummerTaskReward", self) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSummerEpisode/XUiSummerEpisodeChapter.lua b/Resources/Scripts/XUi/XUiSummerEpisode/XUiSummerEpisodeChapter.lua new file mode 100644 index 00000000..ca59b8ed --- /dev/null +++ b/Resources/Scripts/XUi/XUiSummerEpisode/XUiSummerEpisodeChapter.lua @@ -0,0 +1,161 @@ +local XUiGridStageSpecialTrain = require("XUi/XUiSummerEpisode/XUiGridStageSpecialTrain") + +local XUiSummerEpisodeChapter = XClass(nil, "XUiSummerEpisodeChapter") + +local MAX_STAGE_COUNT = CS.XGame.ClientConfig:GetInt("MainLineStageMaxCount") + +function XUiSummerEpisodeChapter:Ctor(ui, rootUi) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.StageList = {} + self.GridStageList = {} + self.LineList = {} + + XTool.InitUiObject(self) + + -- ScrollRect的点击和拖拽会触发关闭详细面板 + CsXUiHelper.RegisterClickEvent(self.ScrollRect, handler(self, self.CancelSelect)) + local dragProxy = self.ScrollRect.gameObject:AddComponent(typeof(CS.XUguiDragProxy)) + dragProxy:RegisterHandler(handler(self, self.OnDragProxy)) + + --初始化StageUI + for i = 1, 3, 1 do + self.StageList[i] = self["Stage" .. i] + self.GridStageList[i] = XUiGridStageSpecialTrain.New(self["StageGrid" .. i], self, self.RootUi) + self.GridStageList[i].Parent = self.StageList[i] + self.StageList[i].gameObject:SetActiveEx(false) + end + +end + +function XUiSummerEpisodeChapter:SetupChapterStage(chapterData) + self.ChapterData = chapterData + self.StageIds = chapterData.StageIds + + for i, v in ipairs(self.StageIds) do + local grid = self.GridStageList[i] + if grid then + grid:Refresh(v, chapterData, i) + self.StageList[i].gameObject:SetActiveEx(true) + end + end + + self.ScrollRect.horizontalNormalizedPosition = 0 +end + + +function XUiSummerEpisodeChapter:OnDragProxy(dragType) + if dragType == 0 then + self:OnScrollRectBeginDrag() + elseif dragType == 2 then + self:OnScrollRectEndDrag() + end +end + +function XUiSummerEpisodeChapter:OnScrollRectBeginDrag() + if self:CancelSelect() then + self.ScrollRect.enabled = false + end +end + +function XUiSummerEpisodeChapter:OnScrollRectEndDrag() + self.ScrollRect.enabled = true +end + +-- 返回滚动容器是否动画回弹 +function XUiSummerEpisodeChapter:CancelSelect() + if not self.CurStageGrid then + return false + end + + self.CurStageGrid = nil + + self.RootUi:CloseStageDetail() + + local result = self:ScrollRectRollBack() + + return result +end + +-- 滚动容器回弹 +function XUiSummerEpisodeChapter:ScrollRectRollBack() + + local width = self.RectTransform.rect.width + local innerWidth = self.PanelStageContent.rect.width + innerWidth = innerWidth < width and width or innerWidth + local diff = innerWidth - width + local tarPosX + if self.PanelStageContent.localPosition.x < -width / 2 - diff then + tarPosX = -width / 2 - diff + elseif self.PanelStageContent.localPosition.x > -width / 2 then + tarPosX = -width / 2 + else + self.ScrollRect.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Elastic + return false + end + + self:PlayScrollViewMoveBack(tarPosX) + + return true +end + +--播放回弹动画 +function XUiSummerEpisodeChapter:PlayScrollViewMoveBack(tarPosX) + local tarPos = self.PanelStageContent.localPosition + tarPos.x = tarPosX + XLuaUiManager.SetMask(true) + + XUiHelper.DoMove(self.PanelStageContent, tarPos, XDataCenter.FubenMainLineManager.UiGridChapterMoveDuration, XUiHelper.EaseType.Sin, function() + self.ScrollRect.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Elastic + XLuaUiManager.SetMask(false) + end) +end + + +function XUiSummerEpisodeChapter:PlayScrollViewMove(grid) + -- 动画 + local gridTf = grid.Parent + local diffX = gridTf.localPosition.x + self.PanelStageContent.localPosition.x + if diffX < XDataCenter.FubenMainLineManager.UiGridChapterMoveMinX or diffX > XDataCenter.FubenMainLineManager.UiGridChapterMoveMaxX then + local tarPosX = XDataCenter.FubenMainLineManager.UiGridChapterMoveTargetX - gridTf.localPosition.x + local tarPos = self.PanelStageContent.localPosition + tarPos.x = tarPosX + XLuaUiManager.SetMask(true) + XUiHelper.DoMove(self.PanelStageContent, tarPos, XDataCenter.FubenMainLineManager.UiGridChapterMoveDuration, XUiHelper.EaseType.Sin, function() + XLuaUiManager.SetMask(false) + end) + end +end + + +-- 选中关卡 +function XUiSummerEpisodeChapter:ClickStageGrid(grid) + + local stageCfg = grid.StageCfg + local stageInfo = grid.StageInfo + + local curGrid = self.CurStageGrid + if curGrid and curGrid.StageId == grid.StageId then + return + end + + if not stageInfo.Unlock then + XUiManager.TipMsg(XDataCenter.FubenManager.GetFubenOpenTips(grid.StageId)) + return + end + + + -- 滚动容器自由移动 + self.ScrollRect.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Unrestricted + -- 面板移动 + self:PlayScrollViewMove(grid) + + self.CurStageGrid = grid + + self.RootUi:OpenStageDetail(stageCfg) +end + + + +return XUiSummerEpisodeChapter \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSummerEpisode/XUiSummerEpisodeMap.lua b/Resources/Scripts/XUi/XUiSummerEpisode/XUiSummerEpisodeMap.lua new file mode 100644 index 00000000..d475ac43 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSummerEpisode/XUiSummerEpisodeMap.lua @@ -0,0 +1,60 @@ +local XUiSummerEpisodeMap = XLuaUiManager.Register(XLuaUi, "UiSummerEpisodeMap") +local XUiGridSummerEpisodeMap = require("XUi/XUiSummerEpisode/XUiGridSummerEpisodeMap") +function XUiSummerEpisodeMap:OnStart(stageId, closeCb) + self.StageId = stageId + self.Lock = false + self.CloseCallback = closeCb + self:InitUiView() +end + +function XUiSummerEpisodeMap:OnEnable() + +end + +function XUiSummerEpisodeMap:OnDestroy() + if self.CloseCallback then + self.CloseCallback() + end +end + +function XUiSummerEpisodeMap:InitUiView() + self.TxtTitle.text = CS.XTextManager.GetText("SummerEpisodeMapSelectTitle") + self:RegisterButtonEvent() + self:InitScrollList() +end + +function XUiSummerEpisodeMap:InitScrollList() + self.GridList = {} + self.Stages = XDataCenter.FubenSpecialTrainManager.GetPhotoStages() + for _, stageId in pairs(self.Stages) do + local obj = CS.UnityEngine.GameObject.Instantiate(self.GridMap, self.Content) + local grid = XUiGridSummerEpisodeMap.New(obj, stageId, self) + grid:SetClickEvent(handler(self, self.OnClickGrid)) + if stageId == self.StageId then + grid:SetSelect(true) + end + table.insert(self.GridList, grid) + end + self.GridMap.gameObject:SetActiveEx(false) +end + +function XUiSummerEpisodeMap:RegisterButtonEvent() + self.BtnTanchuangClose.CallBack = function() + self:Close() + end +end + +function XUiSummerEpisodeMap:OnClickGrid(stageId) + if self.Lock then return end + self.Lock = true + XDataCenter.RoomManager.PhotoChangeMapRequest(stageId, function() + self.Lock = false + self.StageId = stageId + for _, grid in pairs(self.GridList) do + grid:SetSelect(stageId == grid.StageId) + end + self:Close() + end) +end + +return XUiSummerEpisodeMap \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSummerEpisode/XUiSummerEpisodeNew.lua b/Resources/Scripts/XUi/XUiSummerEpisode/XUiSummerEpisodeNew.lua new file mode 100644 index 00000000..82992953 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSummerEpisode/XUiSummerEpisodeNew.lua @@ -0,0 +1,193 @@ +local XUiSummerEpisodeNew = XLuaUiManager.Register(XLuaUi, "UiSummerEpisodeNew") +local XUiGridSummerEpisodePicture = require("XUi/XUiSummerEpisode/XUiGridSummerEpisodePicture") +local HELP_KEY = "SummerEpisodeHelp" +function XUiSummerEpisodeNew:OnAwake() + self.GameObject.transform:FindGameObject("BtnPhotograph"):SetActiveEx(false) -- 海外屏蔽自动存图 +end + +function XUiSummerEpisodeNew:OnStart() + self.Lock = false + self:InitUiView() + self:RegisterButtonEvent() + XEventManager.AddEventListener(XEventId.EVENT_ROOM_ENTER_ROOM, self.OnCancelMatching, self) + XEventManager.AddEventListener(XEventId.EVENT_ROOM_CANCEL_MATCH, self.OnCancelMatching, self) + self.TaskRedEventId = XRedPointManager.AddRedPointEvent(self.BtnTask, self.OnCheckRedPoint, self, { XRedPointConditions.Types.CONDITION_SPECIALTRAIN_RED }) +end + +function XUiSummerEpisodeNew:OnEnable() + self:UpdateActivityTime() + self:UpdateStageDetail() + self:StartTimer() + self.BtnMatching.gameObject:SetActiveEx(XDataCenter.RoomManager.Matching) + self.BtnMatch.gameObject:SetActiveEx(not XDataCenter.RoomManager.Matching) +end + +function XUiSummerEpisodeNew:OnDisable() + self:StopTimer() +end + +function XUiSummerEpisodeNew:OnDestroy() + XEventManager.RemoveEventListener(XEventId.EVENT_ROOM_ENTER_ROOM, self.OnCancelMatching, self) + XEventManager.RemoveEventListener(XEventId.EVENT_ROOM_CANCEL_MATCH, self.OnCancelMatching, self) + if self.TaskRedEventId then + XRedPointManager.RemoveRedPointEvent(self.TaskRedEventId) + end +end + +function XUiSummerEpisodeNew:OnCancelMatching() + self.BtnMatch.gameObject:SetActiveEx(true) + self.BtnMatching.gameObject:SetActiveEx(false) +end + +function XUiSummerEpisodeNew:InitUiView() + local activityConfig = XFubenSpecialTrainConfig.GetActivityConfigById(XDataCenter.FubenSpecialTrainManager.GetCurActivityId()) + if not activityConfig then + return + end + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + self.EndTime = XFunctionManager.GetEndTimeByTimeId(activityConfig.TimeId) + self.Chapters = activityConfig.ChapterIds + self.CurChapter = {Id = self.Chapters[1]} + self.TxtName.text = activityConfig.Name + self.HelpDataFunc = function () return self:GetHelpDataFunc() end + self:BindHelpBtnNew(self.BtnHelpCourse, self.HelpDataFunc) + local isSave = XDataCenter.FubenSpecialTrainManager.GetSavePhotoValue() + if isSave == true then + self.BtnCircuit:SetButtonState(CS.UiButtonState.Select) + else + self.BtnCircuit:SetButtonState(CS.UiButtonState.Normal) + end + self:InitDynamicTable() +end + +function XUiSummerEpisodeNew:InitDynamicTable() + self.DynamicTable = XDynamicTableCurve.New(self.PanelMapList) + self.DynamicTable:SetDelegate(self) + self.DynamicTable:SetProxy(XUiGridSummerEpisodePicture) + self:SetupDynamicTable() +end + +function XUiSummerEpisodeNew:SetupDynamicTable() + local stages = XDataCenter.FubenSpecialTrainManager.GetPhotoStages() + self.DynamicTable:SetDataSource(stages) + self.DynamicTable:ReloadData(1) +end + +function XUiSummerEpisodeNew:OnDynamicTableEvent(event,index,grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + self.CurIndex = index + local i = (index - 1) % #self.DynamicTable.DataSource + 1 + self.StageId = self.DynamicTable.DataSource[i] + grid:Refresh(XDataCenter.FubenManager.GetStageIcon(self.StageId)) + self:UpdateStageDetail() + end +end + +function XUiSummerEpisodeNew:UpdateStageDetail() + --照相特训关只有一关直接取第一章节第一关的数据作为展示 + if not self.StageId then return end + local stageConfig = XDataCenter.FubenManager.GetStageCfg(self.StageId) + self:PlayAnimation("TxtMapNameEnable") + self.TxtStageDesc.text = stageConfig.Description + self.TxtCostNum.text = stageConfig.RequireActionPoint + self.TxtPeople.text = stageConfig.OnlinePlayerLeast + self.TxtMapName.text = stageConfig.Name +end + +function XUiSummerEpisodeNew:RegisterButtonEvent() + self.BtnBack.CallBack = function() + if XDataCenter.RoomManager.Matching then + XDataCenter.RoomManager.CancelMatch(function() + self:Close() + end) + else + self:Close() + end + end + self:BindHelpBtn(self.BtnHelpCourse, HELP_KEY) + self.BtnMainUi.CallBack = function() XLuaUiManager.RunMain() end + self.BtnTask.CallBack = function() self:OpenOneChildUi("UiSummerTaskReward",self) end + self.BtnMatch.CallBack = function() self:OnClickBtnMatch() end + self.BtnCreateRoom.CallBack = function() self:OnClickBtnCreateRoom() end + self.BtnCircuit.CallBack = function() self:OnClickBtnCircuit() end + self.BtnSwitch.CallBack = function() self.DynamicTable:TweenToIndex(self.CurIndex + 1) end + if self.BtnMatching then + self:RegisterClickEvent(self.BtnMatching,self.OnClickBtnMatching) + end +end +function XUiSummerEpisodeNew:OnClickBtnMatching() + XDataCenter.RoomManager.CancelMatch(function() + self.BtnMatch.gameObject:SetActiveEx(true) + self.BtnMatching.gameObject:SetActiveEx(false) + end) +end + +function XUiSummerEpisodeNew:OnClickBtnMatch() + self.BtnMatching.gameObject:SetActiveEx(true) + self.BtnMatch.gameObject:SetActiveEx(false) + XDataCenter.RoomManager.PhotoMatch(self.StageId,function() + XLuaUiManager.Open("UiOnLineMatching",self.StageId) + end) +end + +function XUiSummerEpisodeNew:OnClickBtnCreateRoom() + XDataCenter.RoomManager.PhotoCreateRoom(self.StageId) +end + +function XUiSummerEpisodeNew:OnClickBtnCircuit() + local isSave = self.BtnCircuit:GetToggleState() + XDataCenter.FubenSpecialTrainManager.SetSavePhotoValue(isSave) +end + +function XUiSummerEpisodeNew:UpdateActivityTime() + if XTool.UObjIsNil(self.TxtTime) then + self:StopTimer() + return + end + local now = XTime.GetServerNowTimestamp() + local offset = self.EndTime - now + if offset < 0 then + offset = 0 + XUiManager.TipText("SummerEpisodeActivityEnd") + XLuaUiManager.RunMain() + self:StopTimer() + return + end + self.TxtTime.text = XUiHelper.GetTime(offset, XUiHelper.TimeFormatType.ACTIVITY) +end + +function XUiSummerEpisodeNew:StartTimer() + if self.Timer then self:StopTimer() end + self.Timer = XScheduleManager.ScheduleForever(handler(self, self.UpdateActivityTime), XScheduleManager.SECOND) +end + +function XUiSummerEpisodeNew:StopTimer() + if not self.Timer then return end + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil +end + +-- 获取教程数据函数 +function XUiSummerEpisodeNew:GetHelpDataFunc() + local helpIds = {} + for _, var in ipairs(self.CurChapter.HelpId) do + table.insert(helpIds, var) + end + + if not helpIds then + return + end + + local helpConfigs = {} + for i = 1, #helpIds do + helpConfigs[i] = XHelpCourseConfig.GetHelpCourseTemplateById(helpIds[i]) + end + + return helpConfigs +end + +function XUiSummerEpisodeNew:OnCheckRedPoint(count) + self.BtnTask:ShowReddot(count >= 0) +end + +return XUiSummerEpisodeNew \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSummerEpisode/XUiSummerGridTask.lua b/Resources/Scripts/XUi/XUiSummerEpisode/XUiSummerGridTask.lua new file mode 100644 index 00000000..1243788b --- /dev/null +++ b/Resources/Scripts/XUi/XUiSummerEpisode/XUiSummerGridTask.lua @@ -0,0 +1,198 @@ +XUiSummerGridTask = XClass(nil, "XUiSummerGridTask") + +function XUiSummerGridTask:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RewardPanelList = {} + self:InitAutoScript() + self.GridCommon.gameObject:SetActive(false) + self.ImgComplete.gameObject:SetActive(false) + self.PanelAnimation.gameObject:SetActive(true) +end + +function XUiSummerGridTask:PlayAnimation() + if self.IsAnimation then + return + end + + self.IsAnimation = true + self.GridTaskTimeline:PlayTimelineAnimation() +end + +function XUiSummerGridTask:ResetData(data) + self.ImgComplete.gameObject:SetActive(data.State == XDataCenter.TaskManager.TaskState.Finish) + self.Data = data + + local config = XDataCenter.TaskManager.GetTaskTemplate(self.Data.Id) + self.tableData = config + self.TxtTaskName.text = config.Title + self.TxtTaskDescribe.text = config.Desc + self.TxtSubTypeTip.text = config.Suffix or "" + self.RImgTaskType:SetRawImage(config.Icon) + self:UpdateProgress(self.Data) + local rewards = XRewardManager.GetRewardList(config.RewardId) + for i = 1, #self.RewardPanelList do + self.RewardPanelList[i]:Refresh() + end + + if not rewards then + return + end + + for i = 1, #rewards do + local panel = self.RewardPanelList[i] + if not panel then + if #self.RewardPanelList == 0 then + panel = XUiGridCommon.New(self.RootUi, self.GridCommon) + else + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommon) + ui.transform:SetParent(self.GridCommon.parent, false) + panel = XUiGridCommon.New(self.RootUi, ui) + end + table.insert(self.RewardPanelList, panel) + end + + panel:Refresh(rewards[i]) + end + if self.PanelAnimationGroup then + self.PanelAnimationGroup.alpha = 1 + end + +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiSummerGridTask:InitAutoScript() + XTool.InitUiObject(self) + self.SpecialSoundMap = {} + self:AutoAddListener() +end + + + +function XUiSummerGridTask:GetAutoKey(uiNode, eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiSummerGridTask:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiGridTask:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiSummerGridTask:AutoAddListener() + self.AutoCreateListeners = {} + + local finishXUiBtn = self.BtnFinish:GetComponent("XUiButton") + if not finishXUiBtn then + XUiHelper.RegisterClickEvent(self, self.BtnFinish, self.OnBtnFinishClick) + else + self.BtnFinish = finishXUiBtn + self.BtnFinish.CallBack = function() self:OnBtnFinishClick() end + end + + local skipXUiBtn = self.BtnSkip:GetComponent("XUiButton") + if not skipXUiBtn then + XUiHelper.RegisterClickEvent(self, self.BtnSkip, self.OnBtnSkipClick) + else + self.BtnSkip = skipXUiBtn + self.BtnSkip.CallBack = function() self:OnBtnSkipClick() end + end +end + +function XUiSummerGridTask:OnBtnFinishClick() + local weaponCount = 0 + local chipCount = 0 + for i = 1, #self.RewardPanelList do + local rewardsId = self.RewardPanelList[i].TemplateId + if XDataCenter.EquipManager.IsClassifyEqualByTemplateId(rewardsId, XEquipConfig.Classify.Weapon) then + weaponCount = weaponCount + 1 + elseif XDataCenter.EquipManager.IsClassifyEqualByTemplateId(rewardsId, XEquipConfig.Classify.Awareness) then + chipCount = chipCount + 1 + end + end + if weaponCount > 0 and XDataCenter.EquipManager.CheckBagCount(weaponCount, XEquipConfig.Classify.Weapon) == false or + chipCount > 0 and XDataCenter.EquipManager.CheckBagCount(chipCount, XEquipConfig.Classify.Awareness) == false then + return + end + XDataCenter.TaskManager.FinishTask(self.Data.Id, function(rewardGoodsList) + XUiManager.OpenUiObtain(rewardGoodsList) + end) +end + +function XUiSummerGridTask:OnBtnSkipClick() + if XDataCenter.RoomManager.RoomData ~= nil then + local title = CS.XTextManager.GetText("TipTitle") + local cancelMatchMsg = CS.XTextManager.GetText("OnlineInstanceQuitRoom") + XUiManager.DialogTip(title, cancelMatchMsg, XUiManager.DialogType.Normal, nil, function() + XLuaUiManager.RunMain() + local skipId = XDataCenter.TaskManager.GetTaskTemplate(self.Data.Id).SkipId + XFunctionManager.SkipInterface(skipId) + end) + else + local skipId = XDataCenter.TaskManager.GetTaskTemplate(self.Data.Id).SkipId + XFunctionManager.SkipInterface(skipId) + end +end + +function XUiSummerGridTask:UpdateProgress(data) + self.Data = data + local config = XDataCenter.TaskManager.GetTaskTemplate(data.Id) + if #config.Condition < 2 then--显示进度 + self.ImgProgress.transform.parent.gameObject:SetActive(true) + self.TxtTaskNumQian.gameObject:SetActive(true) + local result = config.Result > 0 and config.Result or 1 + XTool.LoopMap(self.Data.Schedule, function(_, pair) + self.ImgProgress.fillAmount = pair.Value / result + pair.Value = (pair.Value >= result) and result or pair.Value + self.TxtTaskNumQian.text = pair.Value .. "/" .. result + end) + else + self.ImgProgress.transform.parent.gameObject:SetActive(false) + self.TxtTaskNumQian.gameObject:SetActive(false) + end + + self.BtnFinish.gameObject:SetActive(false) + self.BtnSkip.gameObject:SetActive(false) + if self.BtnReceiveHave then + self.BtnReceiveHave.gameObject:SetActive(false) + end + if self.Data.State == XDataCenter.TaskManager.TaskState.Achieved then + self.BtnFinish.gameObject:SetActive(true) + elseif self.Data.State ~= XDataCenter.TaskManager.TaskState.Achieved and self.Data.State ~= XDataCenter.TaskManager.TaskState.Finish then + self.BtnSkip.gameObject:SetActive(true) + + if self.BtnSkip["SetButtonState"] then + local skipId = XDataCenter.TaskManager.GetTaskTemplate(self.Data.Id).SkipId + if skipId == nil or skipId == 0 then + self.BtnSkip:SetButtonState(CS.UiButtonState.Disable) + else + self.BtnSkip:SetButtonState(CS.UiButtonState.Normal) + end + end + elseif self.Data.State == XDataCenter.TaskManager.TaskState.Finish then + if self.BtnReceiveHave then + self.BtnReceiveHave.gameObject:SetActive(true) + end + end +end + +return XUiSummerGridTask \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSummerEpisode/XUiSummerMatch.lua b/Resources/Scripts/XUi/XUiSummerEpisode/XUiSummerMatch.lua new file mode 100644 index 00000000..e220cde6 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSummerEpisode/XUiSummerMatch.lua @@ -0,0 +1,566 @@ +local XUiSummerMatch = XLuaUiManager.Register(XLuaUi, "UiSummerMatch") +local XUiGridMatchReward = require("XUi/XUiSummerEpisode/XUiGridMatchReward") +local XUiGridEliminate = require("XUi/XUiSummerEpisode/XUiGridEliminate") +local XUiGridEliminateIcon = require("XUi/XUiSummerEpisode/XUiGridEliminateIcon") + +function XUiSummerMatch:OnAwake() + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + self.BtnRollBack.CallBack = function() self:OnBtnRollBackClick() end + self.BtnRes.CallBack = function() self:OnBtnResClick() end + + self.GridReward.gameObject:SetActiveEx(false) +end + +function XUiSummerMatch:OnStart(gameId) + self.DynamicTable = XDynamicTableNormal.New(self.PanelRewardList) + self.DynamicTable:SetDelegate(self) + self.DynamicTable:SetProxy(XUiGridMatchReward) + + self.ImgIcon.gameObject:SetActiveEx(false) + + self.Point = {} + self.GridEliminate = {} + self.PointIcons = {} + for i = 1, 16 do + self.Point[i] = self["Pos" .. tostring(i)] + self.GridEliminate[i] = XUiGridEliminate.New(self.Point[i], self) + local go = CS.UnityEngine.GameObject.Instantiate(self.ImgIcon.gameObject) + go.transform:SetParent(self.PanelPos, false) + go.transform.position = self.Point[i].position + self.PointIcons[i] = XUiGridEliminateIcon.New(go) + --self.PointIcons[i] = go:GetComponent("Image") + end + + self.GameId = gameId + + self:SetupGameData() + self:RegisterHelpBtn() + self:SetTimer() + self:TryShowHelpTip() +end + +--弹出帮助 +function XUiSummerMatch:TryShowHelpTip() + local value = XDataCenter.EliminateGameManager.GetEliminateGamePrefs(self.GameId) + if value == 0 then + local config = XHelpCourseConfig.GetHelpCourseTemplateById(self.GameData.Config.HelpId) + XUiManager.ShowHelpTip(config.Function) + XDataCenter.EliminateGameManager.SaveEliminateGamePrefs(1, self.GameId) + end +end + + +function XUiSummerMatch:SetupGameData() + + local gameData = XDataCenter.EliminateGameManager.GetEliminateGameData(self.GameId) + if not gameData then + return + end + + self.GameData = gameData + self:SetupReward() + self:SetupDesc() + self:SetupGrid() +end + +function XUiSummerMatch:SetupDesc() + self.PanelFlip.gameObject:SetActiveEx(self.GameData.State == XDataCenter.EliminateGameManager.EliminateGameState.Flip) + self.PanelExchange.gameObject:SetActiveEx(self.GameData.State == XDataCenter.EliminateGameManager.EliminateGameState.Move) + self.BtnRollBack.gameObject:SetActiveEx(not self.GameData.IsEliminateAll) + if self.GameData.State == XDataCenter.EliminateGameManager.EliminateGameState.Flip then + local flipCostItem = self.GameData.Config.FlipItemId + local count = XDataCenter.ItemManager.GetCount(flipCostItem) + self.TxtRewardCount.text = tostring(count) + local icon = XDataCenter.ItemManager.GetItemIcon(flipCostItem) + self.FlipRawImage:SetRawImage(icon) + elseif self.GameData.State == XDataCenter.EliminateGameManager.EliminateGameState.Move then + local costItem = self.GameData.Config.MoveItemId + local count = XDataCenter.ItemManager.GetCount(costItem) + self.TxtCount.text = tostring(count) + local icon = XDataCenter.ItemManager.GetItemIcon(costItem) + self.ExchangeRawImage:SetRawImage(icon) + end +end + +function XUiSummerMatch:SetupGrid() + local lineCount = self.GameData.Config.LineCount + local curGrids = self.GameData.CurGrids + for i, v in ipairs(curGrids) do + local index = v.X + (v.Y - 1) * lineCount + local config = XEliminateGameConfig.GetEliminateGameGrid(v.Id) + local girdTypeCfg = XEliminateGameConfig.GetEliminateGameGridByType(config.Type) + self.GridEliminate[index]:SetSelected(false) + self.GridEliminate[index]:SetData(v, self.GameId) + + if config.Type ~= XDataCenter.EliminateGameManager.EliminateGameSpecialType.Obstacle and config.Type ~= XDataCenter.EliminateGameManager.EliminateGameSpecialType.Space then + self.PointIcons[index]:SetIcon(girdTypeCfg.TypePic) + else + self.PointIcons[index].GameObject:SetActiveEx(false) + end + + if self.GameData.State == XDataCenter.EliminateGameManager.EliminateGameState.Flip then + self.GridEliminate[index]:SetSelectedEnable(false) + if v.State == XDataCenter.EliminateGameManager.EliminateGridState.Cover then + self.GridEliminate[index]:SetupFlip() + elseif v.State == XDataCenter.EliminateGameManager.EliminateGridState.Normal then + if config.Type == XDataCenter.EliminateGameManager.EliminateGameSpecialType.Obstacle then + self.GridEliminate[index]:SetupForbidden() + elseif config.Type == XDataCenter.EliminateGameManager.EliminateGameSpecialType.Space then + self.GridEliminate[index]:SetupNormal() + self.PointIcons[index].GameObject:SetActiveEx(false) + else + self.GridEliminate[index]:SetupNormal() + self.PointIcons[index].GameObject:SetActiveEx(true) + end + elseif v.State == XDataCenter.EliminateGameManager.EliminateGridState.Reward then + self.GridEliminate[index]:SetupReward() + self.GridEliminate[index]:SetSelectedEnable(true) + + self.PointIcons[index].GameObject:SetActiveEx(false) + end + elseif self.GameData.State == XDataCenter.EliminateGameManager.EliminateGameState.Move then + if v.State == XDataCenter.EliminateGameManager.EliminateGridState.Normal then + if config.Type == XDataCenter.EliminateGameManager.EliminateGameSpecialType.Obstacle then + self.GridEliminate[index]:SetupForbidden() + elseif config.Type == XDataCenter.EliminateGameManager.EliminateGameSpecialType.Space then + self.GridEliminate[index]:SetupNormal() + self.GridEliminate[index]:SetSelectedEnable(true) + else + self.GridEliminate[index]:SetupNormal() + self.PointIcons[index].GameObject:SetActiveEx(true) + self.GridEliminate[index]:SetSelectedEnable(true) + end + elseif v.State == XDataCenter.EliminateGameManager.EliminateGridState.Reward then + self.GridEliminate[index]:SetupReward() + self.GridEliminate[index]:SetSelectedEnable(true) + self.PointIcons[index].GameObject:SetActiveEx(false) + end + + -- if config.Type == 0 then + -- self.GridEliminate[index]:SetupForbidden() + -- end + end + end +end + +function XUiSummerMatch:OnClickGrid(gridData) + + if not gridData then + return + end + + local config = XEliminateGameConfig.GetEliminateGameGrid(gridData.Id) + + + local lineCount = self.GameData.Config.LineCount + + if self.GameData.State == XDataCenter.EliminateGameManager.EliminateGameState.Flip then + + if gridData.State == XDataCenter.EliminateGameManager.EliminateGridState.Cover then + if XDataCenter.EliminateGameManager.CheckCanFlipGrid(self.GameId) then + XDataCenter.EliminateGameManager.RequestEliminateGameFlip(self.GameId, gridData.X, gridData.Y, function() + + local index = gridData.X + (gridData.Y - 1) * lineCount + + self.GridEliminate[index]:PlayFlipTimeline(function() + + if config.Type == XDataCenter.EliminateGameManager.EliminateGameSpecialType.Obstacle then + self.GridEliminate[index]:SetupForbidden() + elseif config.Type == XDataCenter.EliminateGameManager.EliminateGameSpecialType.Space then + self.GridEliminate[index]:SetupNormal() + self.PointIcons[index].GameObject:SetActiveEx(false) + else + self.GridEliminate[index]:SetupNormal() + self.PointIcons[index].GameObject:SetActiveEx(true) + end + + self:OnGridFilp(self.GridEliminate[index]) + end) + end) + end + end + elseif self.GameData.State == XDataCenter.EliminateGameManager.EliminateGameState.Move then + local index = gridData.X + (gridData.Y - 1) * lineCount + + if not XDataCenter.EliminateGameManager.CheckCanExchangeGrid(self.GameId, true) then + return + end + + if gridData.State == XDataCenter.EliminateGameManager.EliminateGridState.Normal then + + + if self.CurSelectedGrid then + if self.CurSelectedGrid.X == gridData.X and self.CurSelectedGrid.Y == gridData.Y then + self:ResetNeighBor() + self.GridEliminate[index]:SetSelected(false) + self.CurSelectedGrid = nil + elseif self:IsNeighBor(gridData) then + self:ResetNeighBor() + XDataCenter.EliminateGameManager.RequestEliminateGameMove(self.GameId, self.CurSelectedGrid.X, self.CurSelectedGrid.Y, gridData.X, gridData.Y, function(eliminateGrids) + self:ExChangeGrid(self.CurSelectedGrid, gridData, eliminateGrids) + end) + -- end + else + self:ResetNeighBor() + local selectedIndex = self.CurSelectedGrid.X + (self.CurSelectedGrid.Y - 1) * lineCount + self.GridEliminate[selectedIndex]:SetSelected(false) + self.CurSelectedGrid = nil + if config.Type ~= XDataCenter.EliminateGameManager.EliminateGameSpecialType.Space and config.Type ~= XDataCenter.EliminateGameManager.EliminateGameSpecialType.Obstacle then + self.CurSelectedGrid = gridData + self.GridEliminate[index]:SetSelected(true) + self:HighLightNeighBor(gridData) + end + end + else + if config.Type ~= XDataCenter.EliminateGameManager.EliminateGameSpecialType.Space and config.Type ~= XDataCenter.EliminateGameManager.EliminateGameSpecialType.Obstacle then + self.CurSelectedGrid = gridData + self.GridEliminate[index]:SetSelected(true) + self:HighLightNeighBor(gridData) + end + end + elseif gridData.State == XDataCenter.EliminateGameManager.EliminateGridState.Reward then + if self.CurSelectedGrid then + if self.CurSelectedGrid.X == gridData.X and self.CurSelectedGrid.Y == gridData.Y then + self:ResetNeighBor() + self.GridEliminate[index]:SetSelected(false) + self.CurSelectedGrid = nil + elseif self:IsNeighBor(gridData) then + self:ResetNeighBor() + XDataCenter.EliminateGameManager.RequestEliminateGameMove(self.GameId, self.CurSelectedGrid.X, self.CurSelectedGrid.Y, gridData.X, gridData.Y, function(eliminateGrids) + self:ExChangeGrid(self.CurSelectedGrid, gridData, eliminateGrids) + end) + else + self:ResetNeighBor() + local selectedIndex = self.CurSelectedGrid.X + (self.CurSelectedGrid.Y - 1) * lineCount + self.GridEliminate[selectedIndex]:SetSelected(false) + self.CurSelectedGrid = nil + end + end + end + end +end + +--判断是否相邻 +function XUiSummerMatch:IsNeighBor(gridData) + if not self.NeighBors then + return false + end + + for _, v in ipairs(self.NeighBors) do + if v.X == gridData.X and v.Y == gridData.Y then + return true + end + end + + return false +end + +--交换 +function XUiSummerMatch:ExChangeGrid(girdA, girdB, eliminateGrids) + + local lineCount = self.GameData.Config.LineCount + local indexA = girdA.X + (girdA.Y - 1) * lineCount + local indexB = girdB.X + (girdB.Y - 1) * lineCount + local iconA = self.PointIcons[indexA] + local iconB = self.PointIcons[indexB] + + self.GridEliminate[indexA]:SetSelected(false) + self.GridEliminate[indexB]:SetSelected(false) + + XLuaUiManager.SetMask(true) + + XUiHelper.DoMove(iconA.Transform, self.Point[indexB].localPosition, 0.5, XUiHelper.EaseType.Sin, function() + self.CurSelectedGrid = nil + if eliminateGrids and #eliminateGrids > 0 then + self:EliminateGrid(eliminateGrids) + else + + if XDataCenter.EliminateGameManager.CheckCanExchangeGrid(self.GameId) then + self.CurSelectedGrid = girdA + self.GridEliminate[indexA]:SetSelected(true) + self:HighLightNeighBor(girdA) + end + XLuaUiManager.SetMask(false) + self:Refresh() + end + end) + + + XUiHelper.DoMove(iconB.Transform, self.Point[indexA].localPosition, 0.5, XUiHelper.EaseType.Sin) + self.CurSelectedGrid = self.GridEliminate[indexA] + + + self.GridEliminate[indexA].GridData = girdA + self.GridEliminate[indexB].GridData = girdB + + + + + self.PointIcons[indexA] = iconB + self.PointIcons[indexB] = iconA +end + +function XUiSummerMatch:EliminateGrid(eliminateGrids) + local lineCount = self.GameData.Config.LineCount + + XScheduleManager.ScheduleOnce(function() + for i, v in ipairs(eliminateGrids) do + local index = v.X + (v.Y - 1) * lineCount + self.PointIcons[index]:PlayTime(function() + self.GridEliminate[index]:SetupReward() + if i == #eliminateGrids then + XLuaUiManager.SetMask(false) + self:Refresh() + self:SetupReward() + + if self.GameData.IsEliminateAll then + XUiManager.TipText("EliminateEnd", XUiManager.UiTipType.Tip) + end + end + self.PointIcons[index]:PlayTimelineEnd() + + end) + end + end, 0) +end + + +function XUiSummerMatch:Refresh() + self.GameData = XDataCenter.EliminateGameManager.GetEliminateGameData(self.GameId) + self:SetupDesc() +end + +--高亮旁边的 +function XUiSummerMatch:HighLightNeighBor(gridData) + local lineCount = self.GameData.Config.LineCount + self.NeighBors = {} + + local centerIndex = gridData.X + (gridData.Y - 1) * lineCount + + local upIndex = gridData.X + (gridData.Y - 2) * lineCount + local y = gridData.Y - 2 + local grid = self.GridEliminate[upIndex] + if y >= 0 and y <= lineCount and grid and (not grid:IsObstacle()) then + grid:SetNeighBorSelected(true) + table.insert(self.NeighBors, grid.GridData) + end + + local downIndex = gridData.X + gridData.Y * lineCount + y = gridData.Y + grid = self.GridEliminate[downIndex] + if y >= 0 and y <= lineCount and grid and (not grid:IsObstacle()) then + grid:SetNeighBorSelected(true) + table.insert(self.NeighBors, grid.GridData) + end + + local leftIndex = (gridData.X - 1) + (gridData.Y - 1) * lineCount + local x = (gridData.X - 1) + grid = self.GridEliminate[leftIndex] + + if x > 0 and x <= #self.GridEliminate / lineCount and grid and (not grid:IsObstacle()) then + grid:SetNeighBorSelected(true) + table.insert(self.NeighBors, grid.GridData) + end + + local rightIndex = (gridData.X + 1) + (gridData.Y - 1) * lineCount + local x = (gridData.X + 1) + grid = self.GridEliminate[rightIndex] + + if x > 0 and x <= #self.GridEliminate / lineCount and grid and (not grid:IsObstacle()) then + grid:SetNeighBorSelected(true) + table.insert(self.NeighBors, grid.GridData) + end +end + +--重置高亮 +function XUiSummerMatch:ResetNeighBor() + if not self.NeighBors then + return + end + local lineCount = self.GameData.Config.LineCount + + for _, v in ipairs(self.NeighBors) do + local index = v.X + (v.Y - 1) * lineCount + self.GridEliminate[index]:SetNeighBorSelected(false) + end + + self.NeighBors = {} +end + +--翻转 +function XUiSummerMatch:OnGridFilp(grid) + + self:SetupGrid() + self:SetupDesc() +end + + +function XUiSummerMatch:SetupReward() + local rewardList = self.GameData.Rewards + if not rewardList then + return + end + + + table.sort(rewardList, function(a, b) + local isARewarded = XDataCenter.EliminateGameManager.IsRewarded(a.GameId, a.Id) + local isAFinish = XDataCenter.EliminateGameManager.IsRewardFinish(a) + + local isBRewarded = XDataCenter.EliminateGameManager.IsRewarded(b.GameId, b.Id) + local isBFinish = XDataCenter.EliminateGameManager.IsRewardFinish(b) + local pA = 1 + local pB = 1 + + if isAFinish then + pA = pA + 2 + end + + if isARewarded then + pA = pA - 3 + end + + if isBFinish then + pB = pB + 2 + end + + if isBRewarded then + pB = pB - 3 + end + + if pA == pB then + return a.Id < b.Id + end + + return pA > pB + + end) + + + self.RewardList = rewardList + + + self.DynamicTable:SetDataSource(self.RewardList) + self.DynamicTable:ReloadDataSync() +end + + +function XUiSummerMatch:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiSummerMatch:OnBtnRollBackClick() + if not self.GameData.MoveCost or self.GameData.MoveCost <= 0 then + XUiManager.TipText("EliminateCannotReset", XUiManager.UiTipType.Tip) + return + end + + local title = CS.XTextManager.GetText("EliminateResetTitle") + local content = CS.XTextManager.GetText("EliminateResetContent") + XUiManager.DialogTip(title, content, XUiManager.DialogType.Normal, function() + end, function() + XDataCenter.EliminateGameManager.RequestEliminateGameReset(self.GameId, function() + XUiManager.TipText("EliminateResetSuccess", XUiManager.UiTipType.Tip) + self.CurSelectedGrid = nil + self:SetupGameData() + end) + end) + +end + +function XUiSummerMatch:RegisterHelpBtn() + local config = XHelpCourseConfig.GetHelpCourseTemplateById(self.GameData.Config.HelpId) + self:BindHelpBtn(self.BtnHelpCourse, config.Function) +end + +function XUiSummerMatch:OnBtnResClick() + local itemId = -1 + if self.GameData.State == XDataCenter.EliminateGameManager.EliminateGameState.Flip then + itemId = self.GameData.Config.FlipItemId + elseif self.GameData.State == XDataCenter.EliminateGameManager.EliminateGameState.Move then + itemId = self.GameData.Config.MoveItemId + end + + XLuaUiManager.Open("UiTip", itemId, self.HideSkipBtn) + +end + + +function XUiSummerMatch:OnBtnBackClick() + self:Close() +end + +function XUiSummerMatch:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid.RootUi = self + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.RewardList[index] + if not data then return end + grid:Refresh(data) + end +end + + +function XUiSummerMatch:OnNotify(evt, ...) + if evt == XEventId.EVENT_ELIMINATEGAME_GET_REWARD then + self:SetupReward() + --elseif evt == XEventId.EVENT_ELIMINATEGAME_RESET then + -- self:SetupReward() + end +end + +function XUiSummerMatch:OnGetEvents() + return { XEventId.EVENT_ELIMINATEGAME_GET_REWARD, XEventId.EVENT_ELIMINATEGAME_RESET } +end + + +--停止计时器 +function XUiSummerMatch:StopTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end + +--活动时间倒计时 +function XUiSummerMatch:SetTimer() + local endTimeSecond = XTime.ParseToTimestamp(self.GameData.Config.EndTimeStr) + local now = XTime.GetServerNowTimestamp() + if now <= endTimeSecond then + local activeOverStr = CS.XTextManager.GetText("ArenaOnlineLeftTimeOver") + self:StopTimer() + if now <= endTimeSecond then + self.TxtLeft.text = string.format("%s", XUiHelper.GetTime(endTimeSecond - now, XUiHelper.TimeFormatType.ACTIVITY)) + else + self.TxtLeft.text = activeOverStr + end + + self.Timer = XScheduleManager.ScheduleForever(function() + now = XTime.GetServerNowTimestamp() + if now > endTimeSecond then + self:StopTimer() + XUiManager.TipMsg(CS.XTextManager.GetText("EliminateTimeOut")) + self:Close() + return + end + if now <= endTimeSecond then + self.TxtLeft.text = string.format("%s", XUiHelper.GetTime(endTimeSecond - now, XUiHelper.TimeFormatType.ACTIVITY)) + else + self.TxtLeft.text = activeOverStr + end + end, XScheduleManager.SECOND, 0) + end +end + +function XUiSummerMatch:OnDisable() + self:StopTimer() +end + + +function XUiSummerMatch:OnEnable() + if XDataCenter.EliminateGameManager.CheckTimeOut(self.GameId, true) then + XLuaUiManager.RunMain() + end + + self:SetTimer() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSummerEpisode/XUiSummerOnlineSection.lua b/Resources/Scripts/XUi/XUiSummerEpisode/XUiSummerOnlineSection.lua new file mode 100644 index 00000000..55ed5751 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSummerEpisode/XUiSummerOnlineSection.lua @@ -0,0 +1,190 @@ +local XUiSummerOnlineSection = XLuaUiManager.Register(XLuaUi, "UiSummerOnlineSection") + +function XUiSummerOnlineSection:OnAwake() + self.TxtDesc = {} + self.GridList = {} + self.GridCommon.gameObject:SetActiveEx(false) + for i = 1, 3, 1 do + self.TxtDesc[i] = self["Txt" .. i] + end + + self.BtnMatch.CallBack = function() self:OnBtnMatchClick() end + self.BtnCreateRoom.CallBack = function() self:OnBtnCreateRoomClick() end +end + +function XUiSummerOnlineSection:OnStart(rootUi, stage) + self.RootUi = rootUi + self.Stage = stage + self.StageId = stage.StageId + + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint) +end + +function XUiSummerOnlineSection:OnEnable() + XEventManager.AddEventListener(XEventId.EVENT_ROOM_CANCEL_MATCH, self.OnCancelMatch, self) + XEventManager.AddEventListener(XEventId.EVENT_ROOM_ENTER_ROOM, self.EnterRoom, self) + + self.Stage = self.RootUi.Stage + self.StageId = self.Stage.StageId + self.Chapter = self.RootUi.CurChapter + + self:Refresh() +end + +function XUiSummerOnlineSection:OnDisable() + XEventManager.RemoveEventListener(XEventId.EVENT_ROOM_CANCEL_MATCH, self.OnCancelMatch, self) + XEventManager.RemoveEventListener(XEventId.EVENT_ROOM_ENTER_ROOM, self.EnterRoom, self) +end + +function XUiSummerOnlineSection:EnterRoom() + self:ResetState() +end + +--刷新联机详情面板 +function XUiSummerOnlineSection:Refresh() + if not self.StageId then return end + + self.StageCfg = XDataCenter.FubenManager.GetStageCfg(self.StageId) + local leastPlayer = self.StageCfg.OnlinePlayerLeast <= 0 and 1 or self.StageCfg.OnlinePlayerLeast + local orderId = self.StageCfg.OrderId + for i, v in ipairs(self.Chapter.StageIds) do + if v == self.StageId then + orderId = i + break + end + end + self.TxtTitle.text = self.Chapter.PrefixName .. "-" .. tostring(orderId) .. self.Stage.Name + self.TxtPeople.text = leastPlayer + local stageInfo = XDataCenter.FubenManager.GetStageInfo(self.StageId) + -- local atNums = stageInfo.Passed and 0 or + self.TxtATNums.text = self.StageCfg.RequireActionPoint + self.PanelMatching.gameObject:SetActiveEx(false) + + for i = 1, #self.TxtDesc do + local txtDesc = self.TxtDesc[i] + local desc = self.StageCfg.StarDesc[i] + if desc then + txtDesc.text = desc + txtDesc.gameObject:SetActiveEx(true) + else + txtDesc.gameObject:SetActiveEx(false) + end + end + + local isMatching = XDataCenter.RoomManager.Matching + self.BtnMatch.gameObject:SetActive(not isMatching) + self.PanelMatching.gameObject:SetActive(isMatching) + self.BtnCreateRoom.interactable = not isMatching + + self:SetDropList() +end + +--创建房间 +function XUiSummerOnlineSection:OnBtnCreateRoomClick() + if XDataCenter.RoomManager.Matching then + XUiManager.TipMsg(CS.XTextManager.GetText("OnlineInstanceMatching")) + return + end + + + if XDataCenter.FubenSpecialTrainManager.CheckActivityTimeout(XDataCenter.FubenSpecialTrainManager.CurActiveId, true) then + return + end + + XDataCenter.FubenManager.RequestCreateRoom(self.StageCfg) +end + + +--匹配 +function XUiSummerOnlineSection:OnBtnMatchClick() + if XDataCenter.FubenSpecialTrainManager.CheckActivityTimeout(XDataCenter.FubenSpecialTrainManager.CurActiveId, true) then + return + end + + if XDataCenter.RoomManager.Matching then + return + end + + XDataCenter.FubenManager.RequestMatchRoom(self.StageCfg, function() + --匹配房间 + if XDataCenter.RoomManager.Matching then + XLuaUiManager.Open("UiOnLineMatching", self.StageCfg) + end + + self.BtnCreateRoom.interactable = false + self.BtnMatch.gameObject:SetActiveEx(false) + self.PanelMatching.gameObject:SetActiveEx(true) + end) +end + +--取消匹配 +function XUiSummerOnlineSection:OnCancelMatch() + self.BtnCreateRoom.interactable = true + self.BtnMatch.gameObject:SetActiveEx(true) + self.PanelMatching.gameObject:SetActiveEx(false) +end + +--重置 +function XUiSummerOnlineSection:ResetState() + self.BtnMatch.gameObject:SetActive(true) + self.PanelMatching.gameObject:SetActive(false) + self.BtnCreateRoom.interactable = true +end + +-- 获取显示奖励 +function XUiSummerOnlineSection:SetDropList() + local IsFirst = false + local stageInfo = XDataCenter.FubenManager.GetStageInfo(self.StageId) + -- 获取显示奖励Id + local rewardId = 0 + local cfg = XDataCenter.FubenManager.GetStageLevelControl(self.StageId) + if not stageInfo.Passed then + rewardId = cfg and cfg.FirstRewardShow or self.StageCfg.FirstRewardShow + if cfg and cfg.FirstRewardShow > 0 or self.StageCfg.FirstRewardShow > 0 then + IsFirst = true + end + end + + + self.TxtDrop.gameObject:SetActiveEx(not IsFirst) + self.TxtFirstDrop.gameObject:SetActiveEx(IsFirst) + + if rewardId == 0 then + rewardId = cfg and cfg.FinishRewardShow or self.StageCfg.FinishRewardShow + end + + if rewardId == 0 then + for j = 1, #self.GridList do + self.GridList[j].GameObject:SetActiveEx(false) + end + return + end + + local rewards = IsFirst and XRewardManager.GetRewardList(rewardId) or XRewardManager.GetRewardListNotCount(rewardId) + if rewards then + for i, item in ipairs(rewards) do + local grid + if self.GridList[i] then + grid = self.GridList[i] + else + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommon) + grid = XUiGridCommon.New(self, ui) + grid.Transform:SetParent(self.PanelDropContent, false) + self.GridList[i] = grid + end + grid:Refresh(item) + grid.GameObject:SetActiveEx(true) + end + end + + local rewardsCount = 0 + if rewards then + rewardsCount = #rewards + end + + for j = 1, #self.GridList do + if j > rewardsCount then + self.GridList[j].GameObject:SetActiveEx(false) + end + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSummerEpisode/XUiSummerRank.lua b/Resources/Scripts/XUi/XUiSummerEpisode/XUiSummerRank.lua new file mode 100644 index 00000000..3210b98f --- /dev/null +++ b/Resources/Scripts/XUi/XUiSummerEpisode/XUiSummerRank.lua @@ -0,0 +1,105 @@ +local XUiSummerRank = XLuaUiManager.Register(XLuaUi, "UiSummerRank") + +local XUiGridSummerRank = require("XUi/XUiSummerEpisode/XUiGridSummerRank") +local RankType = { + Broadsword = 1, + Alive = 2 +} + + +function XUiSummerRank:OnAwake() + + self.DynamicTable = XDynamicTableNormal.New(self.RankList) + self.DynamicTable:SetDelegate(self) + self.DynamicTable:SetProxy(XUiGridSummerRank) + + CsXUiHelper.RegisterClickEvent(self.BtnClose, handler(self, self.OnClickClose)) + self.Gridplayer.gameObject:SetActiveEx(false) +end + +function XUiSummerRank:OnStart(cb, winData) + + self.Cb = cb + self.WinData = winData + self.StageId = winData.StageId + self.BeginData = XDataCenter.FubenManager.GetFightBeginData() + local playerList = self.BeginData.PlayerList + + local roleData = self.BeginData.RoleData + local record = XDataCenter.FubenManager.CurFightResult.StringToIntRecord + + self.PlayerList = {} + if XFubenSpecialTrainConfig.CheckIsSpecialTrainBroadswordStage(self.StageId) then + local totalTime = record.jianshengdadaogametime + for i, v in ipairs(roleData) do + local data = {} + for _, var in pairs(playerList) do + if var.Id == v then + data.Player = var + end + end + + data.Count = record["jianshengdadaokills" .. tostring(i)] or 0 + data.Time = record["jianshengdadaoalive" .. tostring(i)] or (totalTime + 1) + + data.RankType = RankType.Broadsword + + -- if v == XPlayer.Id then + -- myData = data + -- else + self.PlayerList[i] = data + --end + end + + + table.sort(self.PlayerList, function(a, b) + return a.Time > b.Time + end) + + -- table.insert(self.PlayerList, myData) + else + for i, v in ipairs(roleData) do + local data = {} + for _, var in pairs(playerList) do + if var.Id == v then + data.Player = var + end + end + + data.Time = record["keepwatermelon" .. tostring(i)] or 0 + data.RankType = RankType.Alive + + self.PlayerList[i] = data + end + + + table.sort(self.PlayerList, function(a, b) + return a.Time > b.Time + end) + end + + + self:SetupStarReward() +end + +function XUiSummerRank:SetupStarReward() + self.DynamicTable:SetDataSource(self.PlayerList) + self.DynamicTable:ReloadDataASync() +end + +function XUiSummerRank:OnDynamicTableEvent(event, index, grid) + + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local player = self.PlayerList[index] + grid:Refresh(player, index) + end +end + + +function XUiSummerRank:OnClickClose() + if self.Cb then + self.Cb() + else + self:Close() + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSummerEpisode/XUiSummerStageDetail.lua b/Resources/Scripts/XUi/XUiSummerEpisode/XUiSummerStageDetail.lua new file mode 100644 index 00000000..0b3e9cfe --- /dev/null +++ b/Resources/Scripts/XUi/XUiSummerEpisode/XUiSummerStageDetail.lua @@ -0,0 +1,309 @@ +local XUiSummerStageDetail = XLuaUiManager.Register(XLuaUi, "UiSummerStageDetail") + +function XUiSummerStageDetail:OnAwake() + self:InitAutoScript() + self.GridStageStar.gameObject:SetActive(false) + self.GridCommon.gameObject:SetActive(false) + self:InitStarPanels() +end + +function XUiSummerStageDetail:OnStart(rootUi, stage) + self.GridList = {} + self.RootUi = rootUi + self.Stage = stage + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) +end + +function XUiSummerStageDetail:OnEnable() + -- 动画 + self.IsPlaying = true + self:PlayAnimation("AnimBegin", handler(self, function() + self.IsPlaying = false + end)) + + self:AddEventListener() + self.IsOpen = true + self.Stage = self.RootUi.Stage + self.Chapter = self.RootUi.CurChapter + self:Refresh() +end + +function XUiSummerStageDetail:OnDisable() + self:RemoveEventListener() + self.IsOpen = false +end + +function XUiSummerStageDetail:InitStarPanels() + self.GridStarList = {} + for i = 1, 3 do + local ui = self.Transform:Find("SafeAreaContentPane/PanelDetail/PanelTargetList/GridStageStar" .. i) + ui.gameObject:SetActive(true) + local grid = XUiGridStageStar.New(ui) + self.GridStarList[i] = grid + end +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiSummerStageDetail:InitAutoScript() + self:AutoAddListener() +end + +function XUiSummerStageDetail:AutoAddListener() + self:RegisterClickEvent(self.BtnAddNum, self.OnBtnAddNumClick) + self:RegisterClickEvent(self.BtnEnter, self.OnBtnEnterClick) + self:RegisterClickEvent(self.BtnEnterB, self.OnBtnEnterBClick) + self:RegisterClickEvent(self.BtnAutoFight, self.OnBtnAutoFightClick) + self:RegisterClickEvent(self.BtnAutoFightComplete, self.OnBtnAutoFightCompleteClick) +end +-- auto +function XUiSummerStageDetail:OnBtnEnterBClick() + self:OnBtnEnterClick() +end + +function XUiSummerStageDetail:OnBtnAutoFightClick() + XLuaUiManager.Open("UiAutoFightEnter", self.Stage.StageId, self.Stage) +end + +function XUiSummerStageDetail:OnBtnAutoFightCompleteClick() + local index = XDataCenter.AutoFightManager.GetIndexByStageId(self.Stage.StageId) + XDataCenter.AutoFightManager.ObtainRewards(index) +end + +function XUiSummerStageDetail:OnBtnCloseClick() + self:Hide() +end + +function XUiSummerStageDetail:OnBtnAddNumClick() + local challengeData = XDataCenter.FubenMainLineManager.GetStageBuyChallengeData(self.Stage.StageId) + XLuaUiManager.Open("UiBuyAsset", 1, function() + self:UpdateCommon() + end, challengeData) +end + +function XUiSummerStageDetail:OnBtnEnterClick() + + if XDataCenter.FubenSpecialTrainManager.CheckActivityTimeout(XDataCenter.FubenSpecialTrainManager.CurActiveId, true) then + return + end + + if self.IsPlaying then + return + end + + if self.Stage == nil then + XLog.Error("XUiSummerStageDetail.OnBtnEnterClick: Can not find stage!") + return + end + + + if XDataCenter.FubenManager.OpenRoomSingle(self.Stage) then + --self:Close() + CsXGameEventManager.Instance:Notify(XEventId.EVENT_FUBEN_CLOSE_FUBENSTAGEDETAIL) + end +end + +function XUiSummerStageDetail:Hide() + if self.IsPlaying or not self.IsOpen then + return + end + + self.IsPlaying = true + self:PlayAnimation("AnimEnd", handler(self, function() + if XTool.UObjIsNil(self.GameObject) then + return + end + self.IsPlaying = false + self:Close() + end)) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_FUBEN_CLOSE_FUBENSTAGEDETAIL) +end + +function XUiSummerStageDetail:Refresh() + self:UpdateCommon() + self:UpdateRewards() + self:UpdateDifficulty() + self:UpdateStageFightControl()--更新战力限制提示 +end + +function XUiSummerStageDetail:UpdateCommon() + local stageCfg = XDataCenter.FubenManager.GetStageCfg(self.Stage.StageId) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(self.Stage.StageId) + local chapterOrderId = stageCfg.OrderId + for i, v in ipairs(self.Chapter.StageIds) do + if v == self.StageId then + chapterOrderId = i + break + end + end + self.TxtTitle.text = self.Chapter.PrefixName .. "-" .. tostring(chapterOrderId) .. self.Stage.Name + self.TxtDesc.text = self.Stage.Description + self.TxtATNums.text = self.Stage.RequireActionPoint + + local maxChallengeNum = XDataCenter.FubenManager.GetStageMaxChallengeNums(self.Stage.StageId) + local buyChallengeCount = XDataCenter.FubenManager.GetStageBuyChallengeCount(self.Stage.StageId) + + self.PanelNums.gameObject:SetActive(maxChallengeNum > 0) + self.PanelNoLimitCount.gameObject:SetActive(maxChallengeNum <= 0) + self.BtnAddNum.gameObject:SetActive(buyChallengeCount > 0) + local showAutoFightBtn = false + if stageCfg.AutoFightId > 0 then + local record = XDataCenter.AutoFightManager.GetRecordByStageId(self.Stage.StageId) + if record then + local now = XTime.GetServerNowTimestamp() + if now >= record.CompleteTime then + self:SetAutoFightState(XDataCenter.AutoFightManager.State.Complete) + else + self:SetAutoFightState(XDataCenter.AutoFightManager.State.Fighting) + end + showAutoFightBtn = true + else + local autoFightAvailable = XDataCenter.AutoFightManager.CheckAutoFightAvailable(self.Stage.StageId) == XCode.Success + if autoFightAvailable then + self:SetAutoFightState(XDataCenter.AutoFightManager.State.None) + showAutoFightBtn = true + end + end + end + self:SetAutoFightActive(showAutoFightBtn) + + if maxChallengeNum > 0 then + local stageData = XDataCenter.FubenManager.GetStageData(self.Stage.StageId) + local chanllengeNum = stageData and stageData.PassTimesToday or 0 + self.TxtAllNums.text = "/" .. maxChallengeNum + self.TxtLeftNums.text = maxChallengeNum - chanllengeNum + end + + local firstDrop = false + if not stageInfo.Passed then + local cfg = XDataCenter.FubenManager.GetStageLevelControl(self.Stage.StageId) + if cfg and cfg.FirstRewardShow > 0 or self.Stage.FirstRewardShow > 0 then + firstDrop = true + end + end + self.TxtFirstDrop.gameObject:SetActive(firstDrop) + self.TxtDrop.gameObject:SetActive(not firstDrop) + + for i = 1, 3 do + self.GridStarList[i]:Refresh(self.Stage.StarDesc[i], stageInfo.StarsMap[i]) + end +end + +function XUiSummerStageDetail:UpdateDifficulty() + local nanDuIcon = XDataCenter.FubenManager.GetDifficultIcon(self.Stage.StageId) + --赏金任务 + local IsBountyTaskPreFight, task = XDataCenter.BountyTaskManager.CheckBountyTaskPreFight(self.Stage.StageId) + if IsBountyTaskPreFight then + local config = XDataCenter.BountyTaskManager.GetBountyTaskConfig(task.Id) + nanDuIcon = config.StageIcon + end + self.RImgNandu:SetRawImage(nanDuIcon) +end + +function XUiSummerStageDetail:UpdateRewards() + local stage = self.Stage + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stage.StageId) + + -- 获取显示奖励Id + local rewardId = 0 + local IsFirst = false + local cfg = XDataCenter.FubenManager.GetStageLevelControl(stage.StageId) + if not stageInfo.Passed then + rewardId = cfg and cfg.FirstRewardShow or stage.FirstRewardShow + if cfg and cfg.FirstRewardShow > 0 or stage.FirstRewardShow > 0 then + IsFirst = true + end + end + if rewardId == 0 then + rewardId = cfg and cfg.FinishRewardShow or stage.FinishRewardShow + end + if rewardId == 0 then + for j = 1, #self.GridList do + self.GridList[j].GameObject:SetActive(false) + end + return + end + + local rewards = IsFirst and XRewardManager.GetRewardList(rewardId) or XRewardManager.GetRewardListNotCount(rewardId) + if rewards then + for i, item in ipairs(rewards) do + local grid + if self.GridList[i] then + grid = self.GridList[i] + else + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommon) + grid = XUiGridCommon.New(self, ui) + grid.Transform:SetParent(self.PanelDropContent, false) + self.GridList[i] = grid + end + grid:Refresh(item) + grid.GameObject:SetActive(true) + end + end + + local rewardsCount = 0 + if rewards then + rewardsCount = #rewards + end + + for j = 1, #self.GridList do + if j > rewardsCount then + self.GridList[j].GameObject:SetActive(false) + end + end +end + +function XUiSummerStageDetail:UpdateStageFightControl() + local stageInfo = XDataCenter.FubenManager.GetStageInfo(self.Stage.StageId) + if self.StageFightControl == nil then + self.StageFightControl = XUiStageFightControl.New(self.PanelStageFightControl, self.Stage.FightControlId) + end + if not stageInfo.Passed and stageInfo.Unlock then + self.StageFightControl.GameObject:SetActive(true) + self.StageFightControl:UpdateInfo(self.Stage.FightControlId) + else + self.StageFightControl.GameObject:SetActive(false) + end +end + +function XUiSummerStageDetail:SetAutoFightActive(value) + self.PanelAutoFightButton.gameObject:SetActive(value) + self.BtnEnter.gameObject:SetActive(not value) +end + +function XUiSummerStageDetail:SetAutoFightState(value) + local state = XDataCenter.AutoFightManager.State + self.BtnAutoFight.gameObject:SetActive(value == state.None) + self.ImgAutoFighting.gameObject:SetActive(value == state.Fighting) + self.BtnAutoFightComplete.gameObject:SetActive(value == state.Complete) +end + +function XUiSummerStageDetail:OnAutoFightStart(stageId) + if self.Stage.StageId == stageId then + self.ParentUi:CloseStageDetail() + end +end + +function XUiSummerStageDetail:OnAutoFightRemove(stageId) + if self.Stage.StageId == stageId then + self:SetAutoFightState(XDataCenter.AutoFightManager.State.None) + end +end + +function XUiSummerStageDetail:OnAutoFightComplete(stageId) + if self.Stage.StageId == stageId then + self:SetAutoFightState(XDataCenter.AutoFightManager.State.Complete) + end +end + +function XUiSummerStageDetail:AddEventListener() + XEventManager.AddEventListener(XEventId.EVENT_AUTO_FIGHT_START, self.OnAutoFightStart, self) + XEventManager.AddEventListener(XEventId.EVENT_AUTO_FIGHT_REMOVE, self.OnAutoFightRemove, self) + XEventManager.AddEventListener(XEventId.EVENT_AUTO_FIGHT_COMPLETE, self.OnAutoFightComplete, self) +end + +function XUiSummerStageDetail:RemoveEventListener() + XEventManager.RemoveEventListener(XEventId.EVENT_AUTO_FIGHT_START, self.OnAutoFightStart, self) + XEventManager.RemoveEventListener(XEventId.EVENT_AUTO_FIGHT_REMOVE, self.OnAutoFightRemove, self) + XEventManager.RemoveEventListener(XEventId.EVENT_AUTO_FIGHT_COMPLETE, self.OnAutoFightComplete, self) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSummerEpisode/XUiSummerStarReward.lua b/Resources/Scripts/XUi/XUiSummerEpisode/XUiSummerStarReward.lua new file mode 100644 index 00000000..453b1e98 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSummerEpisode/XUiSummerStarReward.lua @@ -0,0 +1,57 @@ +local XUiSummerStarReward = XLuaUiManager.Register(XLuaUi, "UiSummerStarReward") + +local XUiGridStarReward = require("XUi/XUiSummerEpisode/XUiGridStarReward") +function XUiSummerStarReward:OnAwake() + + self.GridTreasureGrade.gameObject:SetActive(false) + + self.DynamicTable = XDynamicTableNormal.New(self.PanelTreasureGrade) + self.DynamicTable:SetDelegate(self) + self.DynamicTable:SetProxy(XUiGridStarReward) + + CsXUiHelper.RegisterClickEvent(self.BtnTreasureBg, handler(self, self.Close)) + self.BtnTanchuangClose.CallBack = function() self:Close() end +end + +function XUiSummerStarReward:OnStart(rootUi) + self.RootUi = rootUi +end + +function XUiSummerStarReward:SetupStarReward() + local starRewardList = XDataCenter.FubenSpecialTrainManager.GetSpecialTrainNormalChapterReward(self.ChapterId) + if not starRewardList then + return + end + + self.StarRewardList = starRewardList + + self.DynamicTable:SetDataSource(self.StarRewardList) + self.DynamicTable:ReloadDataSync() +end + +function XUiSummerStarReward:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid.RootUi = self + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.StarRewardList[index] + if not data then return end + grid:Refresh(data, self.ChapterId) + end +end + +function XUiSummerStarReward:OnEnable() + local chapter = self.RootUi.CurChapter + self.ChapterId = chapter.Id + self:SetupStarReward() +end + + +function XUiSummerStarReward:OnNotify(evt, ...) + if evt == XEventId.EVENT_FUBEN_SPECIAL_TRAIN_REWARD then + + end +end + +function XUiSummerStarReward:OnGetEvents() + return { XEventId.EVENT_FUBEN_SPECIAL_TRAIN_REWARD } +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSummerEpisode/XUiSummerTaskReward.lua b/Resources/Scripts/XUi/XUiSummerEpisode/XUiSummerTaskReward.lua new file mode 100644 index 00000000..2b2beaa3 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSummerEpisode/XUiSummerTaskReward.lua @@ -0,0 +1,133 @@ +local XUiSummerTaskReward = XLuaUiManager.Register(XLuaUi, "UiSummerTaskReward") + +local XUiSummerGridTask = require("XUi/XUiSummerEpisode/XUiSummerGridTask") + +function XUiSummerTaskReward:OnAwake() + + self.DynamicTable = XDynamicTableNormal.New(self.PanelTaskList) + self.DynamicTable:SetDelegate(self) + self.DynamicTable:SetProxy(XDynamicGridTask) + + CsXUiHelper.RegisterClickEvent(self.BtnBg, handler(self, self.Close)) + self.BtnClose.CallBack = function() self:Close() end + self.GridTask.gameObject:SetActiveEx(false) +end + +function XUiSummerTaskReward:OnStart(rootUi) + self.RootUi = rootUi + +end + + +--停止计时器 +function XUiSummerTaskReward:StopTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end + +--活动时间倒计时 +function XUiSummerTaskReward:SetTimer() + local endTimeSecond = XTime.GetSeverTomorrowFreshTime() + local now = XTime.GetServerNowTimestamp() + if now <= endTimeSecond then + self:StopTimer() + if now <= endTimeSecond then + self.TxtTime.text = string.format("%s", XUiHelper.GetTime(endTimeSecond - now, XUiHelper.TimeFormatType.DAILY_TASK)) + else + self.TxtTime.text = "" + end + + self.Timer = XScheduleManager.ScheduleForever(function() + now = XTime.GetServerNowTimestamp() + if now > endTimeSecond then + self:StopTimer() + return + end + if now <= endTimeSecond then + self.TxtTime.text = string.format("%s", XUiHelper.GetTime(endTimeSecond - now, XUiHelper.TimeFormatType.DAILY_TASK)) + else + self.TxtTime.text = "" + end + end, XScheduleManager.SECOND, 0) + end +end + +function XUiSummerTaskReward:OnDisable() + self:StopTimer() +end + +function XUiSummerTaskReward:SetupStarReward() + local taskList = XDataCenter.FubenSpecialTrainManager.GetSpecialTrainChapterTask(self.ChapterId) + if not taskList then + return + end + + table.sort(taskList, function(a, b) + local priorityA = 0 + local priorityB = 0 + + + local taskA = XDataCenter.TaskManager.GetTaskDataById(a) + local taskB = XDataCenter.TaskManager.GetTaskDataById(b) + + if taskA.State == XDataCenter.TaskManager.TaskState.Achieved then + priorityA = priorityA + 2 + end + + if taskA.State == XDataCenter.TaskManager.TaskState.Finish then + priorityA = priorityA - 3 + end + + if taskB.State == XDataCenter.TaskManager.TaskState.Achieved then + priorityB = priorityB + 2 + end + + if taskB.State == XDataCenter.TaskManager.TaskState.Finish then + priorityB = priorityB - 3 + end + if priorityA > priorityB then + return true + elseif priorityA == priorityB then + return a < b + end + return false + end) + + self.TaskList = taskList + + self.DynamicTable:SetDataSource(self.TaskList) + self.DynamicTable:ReloadDataSync() +end + +function XUiSummerTaskReward:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid.RootUi = self + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local id = self.TaskList[index] + if not id then return end + local task = XDataCenter.TaskManager.GetTaskDataById(id) + grid:ResetData(task) + end +end + +function XUiSummerTaskReward:OnEnable() + local chapter = self.RootUi.CurChapter + self.ChapterId = chapter.Id + + self:SetupStarReward() + self:SetTimer() +end + + +function XUiSummerTaskReward:OnNotify(evt, ...) + if evt == XEventId.EVENT_TASK_SYNC then + self:SetupStarReward() + self:SetTimer() + end +end + +function XUiSummerTaskReward:OnGetEvents() + return { XEventId.EVENT_TASK_SYNC } +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSTBagButton.lua b/Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSTBagButton.lua new file mode 100644 index 00000000..52defe6c --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSTBagButton.lua @@ -0,0 +1,19 @@ +local BaseButton = require("XUi/XUiSuperTower/Common/XUiSTFunctionButton") +--=========================== +--超级爬塔按钮 +--=========================== +local XUiSTBagButton = XClass(BaseButton, "XUiSTBagButton") +--============== +--显示(用于统一背包控件接口) +--============== +function XUiSTBagButton:ShowPanel() + self:Show() +end +--============== +--隐藏(用于统一背包控件接口) +--============== +function XUiSTBagButton:HidePanel() + self:Hide() +end + +return XUiSTBagButton \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSTBagCapacityPanel.lua b/Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSTBagCapacityPanel.lua new file mode 100644 index 00000000..b7a56309 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSTBagCapacityPanel.lua @@ -0,0 +1,24 @@ +local ChildPanel = require("XUi/XUiSuperTower/Common/XUiSTChildPanel") +--=========================== +--超级爬塔背包容量面板 +--=========================== +local XUiSTBagCapacityPanel = XClass(ChildPanel, "XUiSTBagCapacityPanel") + +function XUiSTBagCapacityPanel:InitPanel() + +end + +function XUiSTBagCapacityPanel:Refresh() + self.TxtNowCapacity.text = self.RootUi.BagManager:GetCurrentCapacity() + self.TxtMaxCapacity.text = "/" .. self.RootUi.BagManager:GetMaxCapacity() +end + +function XUiSTBagCapacityPanel:AddEventListener() + XEventManager.AddEventListener(XEventId.EVENT_ST_PLUGIN_REFRESH, self.Refresh, self) +end + +function XUiSTBagCapacityPanel:RemoveEventListener() + XEventManager.RemoveEventListener(XEventId.EVENT_ST_PLUGIN_REFRESH, self.Refresh, self) +end + +return XUiSTBagCapacityPanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSTBagCapacityUpgrade.lua b/Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSTBagCapacityUpgrade.lua new file mode 100644 index 00000000..0a322e9b --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSTBagCapacityUpgrade.lua @@ -0,0 +1,32 @@ +--================ +--背包扩容弹窗 +--================ +local XUiSTBagCapacityUpGrade = XLuaUiManager.Register(XLuaUi, "UiSupertowerUpTips") + +function XUiSTBagCapacityUpGrade:OnAwake() + XTool.InitUiObject(self) + self.BtnClose.CallBack = function() self:Close() end +end + +function XUiSTBagCapacityUpGrade:OnStart(old, new, closeCallback) + self.TxtCurLevel.text = new + self.TxtOldLevel.text = old + if self.TxtTips then self.TxtTips.text = XUiHelper.GetText("STBagPopText") end + self.CloseCb = closeCallback +end + +function XUiSTBagCapacityUpGrade:OnDisable() + self:OnClose() +end + +function XUiSTBagCapacityUpGrade:OnDestroy() + self:OnClose() +end + +function XUiSTBagCapacityUpGrade:OnClose() + if self.CloseCb then + local cb = self.CloseCb + self.CloseCb = nil + cb() + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSTBagDecomposionBtnPanel.lua b/Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSTBagDecomposionBtnPanel.lua new file mode 100644 index 00000000..99476d4a --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSTBagDecomposionBtnPanel.lua @@ -0,0 +1,20 @@ +local ChildPanel = require("XUi/XUiSuperTower/Common/XUiSTChildPanel") +--======================= +--超级爬塔分解按钮面板 +--======================= +local XUiSTBagDecomposionBtnPanel = XClass(ChildPanel, "XUiSTBagDecomposionBtnPanel") + +function XUiSTBagDecomposionBtnPanel:InitPanel() + self:InitButton() +end + +function XUiSTBagDecomposionBtnPanel:InitButton() + local script = require("XUi/XUiSuperTower/Bag/XUiSTBagButton") + self.Button = script.New(self.BtnDecomposion, function() self:OnClick() end) +end + +function XUiSTBagDecomposionBtnPanel:OnClick() + self.RootUi:ShowDecomposion() +end + +return XUiSTBagDecomposionBtnPanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSTBagDecomposionGrid.lua b/Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSTBagDecomposionGrid.lua new file mode 100644 index 00000000..ec803549 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSTBagDecomposionGrid.lua @@ -0,0 +1,34 @@ +--=========================== +--超级爬塔背包分解插件控件 +--=========================== +local XUiSTBagDecomposionGrid = XClass(nil, "XUiSTBagDecomposionGrid") + +function XUiSTBagDecomposionGrid:Ctor(uiGameObject, onClickCallBack) + self:Init(uiGameObject, onClickCallBack) +end + +function XUiSTBagDecomposionGrid:Init(uiGameObject, onClickCallBack) + XTool.InitUiObjectByUi(self, uiGameObject) + if onClickCallBack then + self.OnClickCb = onClickCallBack + end + XUiHelper.RegisterClickEvent(self, self.BtnClick, function() + self:OnClick() + end) +end + +function XUiSTBagDecomposionGrid:RefreshData(decomposionData) + self.ItemId = decomposionData.ItemId + self.RImgIcon:SetRawImage(XDataCenter.ItemManager.GetItemIcon(self.ItemId)) + local quality = XDataCenter.ItemManager.GetItemQuality(self.ItemId) + local qualityPath = XArrangeConfigs.GeQualityPath(quality) + self.ImgQuality:SetSprite(qualityPath) + self.TxtCount.text = CS.XTextManager.GetText("STBagDecomposionNum", decomposionData.Count) +end + +function XUiSTBagDecomposionGrid:OnClick() + if not self.ItemId then return end + XLuaUiManager.Open("UiTip", self.ItemId) +end + +return XUiSTBagDecomposionGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSTBagDecomposionPanel.lua b/Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSTBagDecomposionPanel.lua new file mode 100644 index 00000000..22ad41a1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSTBagDecomposionPanel.lua @@ -0,0 +1,134 @@ +local ChildPanel = require("XUi/XUiSuperTower/Common/XUiSTChildPanel") +--=========================== +--超级爬塔容量条形图面板 +--=========================== +local XUiSTBagDecomposionPanel = XClass(ChildPanel, "XUiSTBagDecomposionPanel") +local QUALITY_START_NUM = 2 +function XUiSTBagDecomposionPanel:InitPanel() + self:InitToggleButtons() + self:InitDynamicTable() + self:InitButtons() +end + +function XUiSTBagDecomposionPanel:InitToggleButtons() + self.ToggleButtons = {} + local index = 1 + local btn = self["BtnTog" .. index] + local toggleScript = require("XUi/XUiSuperTower/Bag/XUiSTBagToggleButton") + while btn ~= nil do + self.ToggleButtons[index] = toggleScript.New(btn, self, (index - 1) + QUALITY_START_NUM) + index = index + 1 + btn = self["BtnTog" .. index] + end +end + +function XUiSTBagDecomposionPanel:InitDynamicTable() + local GridProxy = require("XUi/XUiSuperTower/Bag/XUiSTBagDecomposionGrid") + self.DynamicTable = XDynamicTableNormal.New(self.PanelDynamicTable) + self.DynamicTable:SetProxy(GridProxy) + self.DynamicTable:SetDelegate(self) +end + +function XUiSTBagDecomposionPanel:InitButtons() + XUiHelper.RegisterClickEvent(self, self.BtnCha, function() self:Close() end) + XUiHelper.RegisterClickEvent(self, self.BtnDecomposion, function() self:Decomposion() end) +end +--============= +--动态列表事件 +--============= +function XUiSTBagDecomposionPanel:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(grid.DynamicGrid.gameObject, function() grid:OnGridClick() end) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + if self.DecomposionDataList and self.DecomposionDataList[index] then + grid:RefreshData(self.DecomposionDataList[index]) + end + --elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + --grid:OnClick() + end +end + +function XUiSTBagDecomposionPanel:OnShowPanel() + self:ResetPanel() +end + +function XUiSTBagDecomposionPanel:ResetPanel() + self:ResetToggles() + self:OnDecomposeListRefresh({}) + self.TxtSelectNum.text = 0 +end + +function XUiSTBagDecomposionPanel:ResetToggles() + for _, toggle in pairs(self.ToggleButtons) do + toggle:Reset() + end +end + +function XUiSTBagDecomposionPanel:Decomposion() + if self.DecomposionData and next(self.DecomposionData) then + self.RootUi.BagManager:RequestResolvePlugin(self.DecomposionData) + self:Close() + else + XUiManager.TipMsg(CS.XTextManager.GetText("STBagDecomposionDataIsNull")) + end +end +--============= +--星数Toggle单选时 +--============= +function XUiSTBagDecomposionPanel:OnTogSelect(index) + self.RootUi:PluginsSelectStar(index) +end +--============= +--星数Toggle反选时 +--============= +function XUiSTBagDecomposionPanel:OnTogUnSelect(index) + self.RootUi:PluginsUnSelectStar(index) +end + +function XUiSTBagDecomposionPanel:OnDecomposeListRefresh(decomposionList) + local decomposionData = {} + self.DecomposionData = {} + local selectNum = 0 + for _, plugin in pairs(decomposionList) do + -- 存储分解后道具信息用于展示预览 key = itemId value = 分解数量 + if not decomposionData[plugin:GetResolveId()] then + decomposionData[plugin:GetResolveId()] = plugin:GetResolveCount() + else + decomposionData[plugin:GetResolveId()] = decomposionData[plugin:GetResolveId()] + plugin:GetResolveCount() + end + -- 存储分解插件信息用于请求 key = 插件Id value = 插件数 + if not self.DecomposionData[plugin:GetId()] then + self.DecomposionData[plugin:GetId()] = 0 + end + self.DecomposionData[plugin:GetId()] = self.DecomposionData[plugin:GetId()] + 1 + + -- 统计选中个数 + selectNum = selectNum + 1 + end + self.TxtSelectNum.text = selectNum + self.DecomposionDataList = {} + for itemId, count in pairs(decomposionData) do + local data = { ItemId = itemId, Count = count} + table.insert(self.DecomposionDataList, data) + end + self.DynamicTable:SetDataSource(self.DecomposionDataList) + self.DynamicTable:ReloadDataASync(1) +end + +function XUiSTBagDecomposionPanel:Close() + self.RootUi:ShowPageBag() +end + +function XUiSTBagDecomposionPanel:OnPluginRefresh() + self:ResetPanel() +end + +function XUiSTBagDecomposionPanel:AddEventListener() + XEventManager.AddEventListener(XEventId.EVENT_ST_PLUGIN_REFRESH, self.OnPluginRefresh, self) +end + +function XUiSTBagDecomposionPanel:RemoveEventListener() + XEventManager.RemoveEventListener(XEventId.EVENT_ST_PLUGIN_REFRESH, self.OnPluginRefresh, self) +end + +return XUiSTBagDecomposionPanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSTBagIllusBookGrid.lua b/Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSTBagIllusBookGrid.lua new file mode 100644 index 00000000..f3ab2a59 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSTBagIllusBookGrid.lua @@ -0,0 +1,18 @@ +local BasePluginsGrid = require("XUi/XUiSuperTower/Plugins/XUiSuperTowerPluginGrid") +--=========================== +--超级爬塔背包图鉴芯片控件 +--=========================== +local XUiSTBagIllusBookGrid = XClass(BasePluginsGrid, "XUiSTBagIllusBookGrid") + +function XUiSTBagIllusBookGrid:RefreshData(pluginData, index) + self.Plugin = pluginData.Plugin + self.RImgIcon:SetRawImage(self.Plugin:GetIcon()) + self.ImgQuality:SetSprite(self.Plugin:GetQualityIcon()) + self.TxtName.text = self.Plugin:GetName() + self.ImgQualityBg:SetSprite(self.Plugin:GetQualityBg()) + self.Index = index + self:SetActiveStatus(false) + self:SetNormalLock(pluginData.IsLock) +end + +return XUiSTBagIllusBookGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSTBagIllusFilterButton.lua b/Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSTBagIllusFilterButton.lua new file mode 100644 index 00000000..5af4679f --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSTBagIllusFilterButton.lua @@ -0,0 +1,29 @@ +--============= +--筛选框选项 +--============= +local XUiSTBagIllusFilterButton = XClass(nil, "XUiSTBagIllusFilterButton") + +function XUiSTBagIllusFilterButton:Ctor(btn, panel, index) + self.Btn = btn + self.Panel = panel + self.Index = index + self.IsSelect = false + self.Btn.CallBack = function() self:OnClick() end +end + +function XUiSTBagIllusFilterButton:Reset() + self.IsSelect = false + self.Btn:SetButtonState(CS.UiButtonState.Normal) +end + +function XUiSTBagIllusFilterButton:OnClick() + self.IsSelect = not self.IsSelect + self.Btn:SetButtonState(self.IsSelect and CS.UiButtonState.Disable or CS.UiButtonState.Normal) + if self.IsSelect then + self.Panel:OnTogSelect(self.Index) + else + self.Panel:OnTogUnSelect(self.Index) + end +end + +return XUiSTBagIllusFilterButton \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSTBagIllustratedBookPanel.lua b/Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSTBagIllustratedBookPanel.lua new file mode 100644 index 00000000..33e2706e --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSTBagIllustratedBookPanel.lua @@ -0,0 +1,101 @@ +local ChildPanel = require("XUi/XUiSuperTower/Common/XUiSTChildPanel") +--=========================== +--超级爬塔芯片列表面板 +--=========================== +local XUiSTBagIllustratedBookPanel = XClass(ChildPanel, "XUiSTBagIllustratedBookPanel") + +function XUiSTBagIllustratedBookPanel:InitPanel() + self:InitDynamicTable() + self:InitFilter() +end + +function XUiSTBagIllustratedBookPanel:InitDynamicTable() + local GridProxy = require("XUi/XUiSuperTower/Bag/XUiSTBagIllusBookGrid") + self.DynamicTable = XDynamicTableNormal.New(self.GameObject) + self.DynamicTable:SetProxy(GridProxy) + self.DynamicTable:SetDelegate(self) +end + +--============= +--动态列表事件 +--============= +function XUiSTBagIllustratedBookPanel:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(grid.DynamicGrid.gameObject, function() self:OnGridClick(grid) end) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + if self.PluginsList and self.PluginsList[index] then + grid:RefreshData(self.PluginsList[index], index, self.ListType) + end + end +end + +function XUiSTBagIllustratedBookPanel:Refresh() + --local currentList, otherList = self.RootUi.BagManager:GetIllusPluginList() + --self:CreatePluginsList(currentList, otherList) + local currentList = self.RootUi.BagManager:GetIllusPluginList(self.SelectFilterIndex) + self:CreatePluginsList(currentList) + self.DynamicTable:SetDataSource(self.PluginsList) + self.DynamicTable:ReloadDataASync(1) +end + +--[[function XUiSTBagIllustratedBookPanel:CreatePluginsList(currentList, otherList) + self.PluginsList = {} + for _, plugin in pairs(currentList) do + local data = {Plugin = plugin, IsLock = true} + table.insert(self.PluginsList, data) + end + for _, plugin in pairs(otherList) do + local data = {Plugin = plugin, IsLock = true} + table.insert(self.PluginsList, data) + end +end]] --注释掉需要区分历史有无获得过的条件 + +function XUiSTBagIllustratedBookPanel:CreatePluginsList(list) + self.PluginsList = {} + for _, plugin in pairs(list) do + local data = {Plugin = plugin, IsLock = false} + table.insert(self.PluginsList, data) + end +end + +function XUiSTBagIllustratedBookPanel:InitFilter() + self.Filters = {} + self.FilterButtons = {} + self.SelectFilterIndex = {} + local togButtonScript = require("XUi/XUiSuperTower/Bag/XUiSTBagIllusFilterButton") + XTool.InitUiObjectByUi(self.Filters, self.PanelFilter) + for i = 1, 6 do + local togButton = self.Filters["TogStar" .. i] + if togButton then + self.FilterButtons[i] = togButtonScript.New(togButton, self, i) + end + end +end + +function XUiSTBagIllustratedBookPanel:OnGridClick(grid) + grid:SetActiveStatus(true) + XLuaUiManager.Open("UiSuperTowerPluginDetails", grid.Plugin, 0, function() if not XTool.UObjIsNil(self.Transform) then grid:SetActiveStatus(false) end end) +end + +function XUiSTBagIllustratedBookPanel:OnTogSelect(togIndex) + if self.SelectFilterIndex[togIndex] then return end + --3星的情况是3星以下所有 + if togIndex == 3 then + self.SelectFilterIndex[1] = true + self.SelectFilterIndex[2] = true + end + self.SelectFilterIndex[togIndex] = true + self:Refresh() +end + +function XUiSTBagIllustratedBookPanel:OnTogUnSelect(togIndex) + if not self.SelectFilterIndex[togIndex] then return end + --3星的情况是3星以下所有 + if togIndex == 3 then + self.SelectFilterIndex[1] = nil + self.SelectFilterIndex[2] = nil + end + self.SelectFilterIndex[togIndex] = nil + self:Refresh() +end +return XUiSTBagIllustratedBookPanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSTBagLineGraphPanel.lua b/Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSTBagLineGraphPanel.lua new file mode 100644 index 00000000..b47b93b5 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSTBagLineGraphPanel.lua @@ -0,0 +1,38 @@ +local ChildPanel = require("XUi/XUiSuperTower/Common/XUiSTChildPanel") +local MAX_STAR = 6 +--=========================== +--超级爬塔容量条形图面板 +--=========================== +local XUiSTBagLineGraphPanel = XClass(ChildPanel, "XUiSTBagLineGraphPanel") + +function XUiSTBagLineGraphPanel:InitPanel() + self.BtnAdd.CallBack = function() self:OnClickBtnAdd() end +end + +function XUiSTBagLineGraphPanel:Refresh() + self:RefreshImgStars() +end + +function XUiSTBagLineGraphPanel:RefreshImgStars() + local amount = 0 --算累积百分比 + for i = 1, MAX_STAR do + if self["ImgStar" .. i] then + amount = amount + self.RootUi.BagManager:GetCapacityPercentsByStar(i) + self["ImgStar" .. i].fillAmount = amount + end + end +end + +function XUiSTBagLineGraphPanel:OnClickBtnAdd() + XLuaUiManager.Open("UiTip", XDataCenter.ItemManager.ItemId.SuperTowerBagItemId) +end + +function XUiSTBagLineGraphPanel:AddEventListener() + XEventManager.AddEventListener(XEventId.EVENT_ST_PLUGIN_REFRESH, self.Refresh, self) +end + +function XUiSTBagLineGraphPanel:RemoveEventListener() + XEventManager.RemoveEventListener(XEventId.EVENT_ST_PLUGIN_REFRESH, self.Refresh, self) +end + +return XUiSTBagLineGraphPanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSTBagPluginsGrid.lua b/Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSTBagPluginsGrid.lua new file mode 100644 index 00000000..4136c2b6 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSTBagPluginsGrid.lua @@ -0,0 +1,33 @@ +local BasePluginsGrid = require("XUi/XUiSuperTower/Plugins/XUiSuperTowerPluginGrid") +local LIST_TYPE = { + Bag = 1, --背包列表 + Decomposion = 2, --分解列表 +} +--=========================== +--超级爬塔背包芯片控件 +--=========================== +local XUiSTBagPluginsGrid = XClass(BasePluginsGrid, "XUiSTBagPluginsGrid") + +function XUiSTBagPluginsGrid:RefreshData(plugin, index, listType) + self.Plugin = plugin + self.RImgIcon:SetRawImage(plugin:GetIcon()) + self.ImgQuality:SetSprite(self.Plugin:GetQualityIcon()) + self.ImgQualityBg:SetSprite(self.Plugin:GetQualityBg()) + self.Index = index + self.ListType = listType + self.TxtName.gameObject:SetActiveEx(false) + self.TxtCapacity.gameObject:SetActiveEx(true) + self.TxtCapacity.text = CS.XTextManager.GetText("STBagPluginCapacity", plugin:GetCapacity()) + self:SetActiveStatus(false) + self:SetSelectStatus(false) +end + +function XUiSTBagPluginsGrid:SetSelect(isSelect) + if self.ListType == LIST_TYPE.Bag then + self:SetActiveStatus(isSelect) + elseif self.ListType == LIST_TYPE.Decomposion then + self:SetSelectStatus(isSelect) + end +end + +return XUiSTBagPluginsGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSTBagPluginsPanel.lua b/Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSTBagPluginsPanel.lua new file mode 100644 index 00000000..9214453b --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSTBagPluginsPanel.lua @@ -0,0 +1,155 @@ +local ChildPanel = require("XUi/XUiSuperTower/Common/XUiSTChildPanel") +local LIST_TYPE = { + Bag = 1, --背包列表 + Decomposion = 2, --分解列表 +} +--local DETAIL_OFFSET = 300 --详细窗口离屏幕边缘的像素距离 +--=========================== +--超级爬塔芯片列表面板 +--=========================== +local XUiSTBagPluginsPanel = XClass(ChildPanel, "XUiSTBagPluginsPanel") + +function XUiSTBagPluginsPanel:InitPanel() + self:InitDynamicTable() + self.ListType = LIST_TYPE.Bag +end + +function XUiSTBagPluginsPanel:InitDynamicTable() + local GridProxy = require("XUi/XUiSuperTower/Bag/XUiSTBagPluginsGrid") + self.DynamicTable = XDynamicTableNormal.New(self.GameObject) + self.DynamicTable:SetProxy(GridProxy) + self.DynamicTable:SetDelegate(self) +end +--============= +--动态列表事件 +--============= +function XUiSTBagPluginsPanel:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(grid.DynamicGrid.gameObject, function(pluginGrid) self:OnGridClick(pluginGrid) end) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + if self.PluginsList and self.PluginsList[index] then + grid:RefreshData(self.PluginsList[index], index, self.ListType) + if self.ListType == LIST_TYPE.Decomposion then + if self.SelectIndex[index] then + grid:SetSelect(true) + else + grid:SetSelect(false) + end + end + end + end +end + +function XUiSTBagPluginsPanel:RefreshBag() + self.ListType = LIST_TYPE.Bag + self.PluginsList = self.RootUi.BagManager:GetPluginsByPrior() + self.ObjEmpty.gameObject:SetActiveEx(not next(self.PluginsList)) + self.DynamicTable:SetDataSource(self.PluginsList) + self.DynamicTable:ReloadDataASync(1) +end + +function XUiSTBagPluginsPanel:RefreshDecomposion() + self.ListType = LIST_TYPE.Decomposion + self.SelectIndex = {} + self.PluginsList = self.RootUi.BagManager:GetPluginsByPrior() + self.DynamicTable:SetDataSource(self.PluginsList) + self.DynamicTable:ReloadDataASync(1) +end + +function XUiSTBagPluginsPanel:ResetDecomposion() + self.SelectIndex = {} + for index, plugin in ipairs(self.PluginsList or {}) do + if self.SelectIndex[index] then + local grid = self.DynamicTable:GetGridByIndex(index) + if grid then + self:OnDecomposionGridClick(grid, true) + end + end + end +end + +function XUiSTBagPluginsPanel:SelectStar(star) + if self.ListType ~= LIST_TYPE.Decomposion then return end + for index, plugin in ipairs(self.PluginsList or {}) do + if plugin:GetStar() == star then + if not self.SelectIndex[index] then + local grid = self.DynamicTable:GetGridByIndex(index) + if grid then + self:OnDecomposionGridClick(grid, true) + end + end + end + end + self.RootUi:OnDecomposeListRefresh(self:GetSelectPlugins()) +end + +function XUiSTBagPluginsPanel:UnSelectStar(star) + if self.ListType ~= LIST_TYPE.Decomposion then return end + for index, plugin in ipairs(self.PluginsList or {}) do + if plugin:GetStar() == star then + if self.SelectIndex[index] then + local grid = self.DynamicTable:GetGridByIndex(index) + if grid then + self:OnDecomposionGridClick(grid, true) + end + end + end + end + self.RootUi:OnDecomposeListRefresh(self:GetSelectPlugins()) +end + +function XUiSTBagPluginsPanel:OnGridClick(grid) + if self.ListType == LIST_TYPE.Bag then + self:OnBagGridClick(grid) + elseif self.ListType == LIST_TYPE.Decomposion then + self:OnDecomposionGridClick(grid) + end +end + +function XUiSTBagPluginsPanel:OnBagGridClick(grid) + grid:SetSelect(true) + --local offset = CS.UnityEngine.Screen.width / 2 - DETAIL_OFFSET + XLuaUiManager.Open("UiSuperTowerPluginDetails", grid.Plugin, 0, function() if not XTool.UObjIsNil(self.Transform) then grid:SetSelect(false) end end) +end + +function XUiSTBagPluginsPanel:OnDecomposionGridClick(grid, noEvent) + if self.SelectIndex[grid.Index] then + grid:SetSelect(false) + self.SelectIndex[grid.Index] = nil + else + grid:SetSelect(true) + self.SelectIndex[grid.Index] = true + end + if not noEvent then + self.RootUi:OnDecomposeListRefresh(self:GetSelectPlugins()) + end +end + +function XUiSTBagPluginsPanel:GetSelectPlugins() + local selectPlugins = {} + for index, plugin in pairs(self.PluginsList or {}) do + if self.SelectIndex[index] then + table.insert(selectPlugins, plugin) + end + end + return selectPlugins +end + +function XUiSTBagPluginsPanel:OnPluginRefresh() + if self.ListType == LIST_TYPE.Bag then + self:RefreshBag() + elseif self.ListType == LIST_TYPE.Decomposion then + self:RefreshDecomposion() + end +end + +function XUiSTBagPluginsPanel:AddEventListener() + XEventManager.AddEventListener(XEventId.EVENT_ST_PLUGIN_REFRESH, self.OnPluginRefresh, self) +end + +function XUiSTBagPluginsPanel:RemoveEventListener() + XEventManager.RemoveEventListener(XEventId.EVENT_ST_PLUGIN_REFRESH, self.OnPluginRefresh, self) +end + + +return XUiSTBagPluginsPanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSTBagShopBtnPanel.lua b/Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSTBagShopBtnPanel.lua new file mode 100644 index 00000000..ae543516 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSTBagShopBtnPanel.lua @@ -0,0 +1,20 @@ +local ChildPanel = require("XUi/XUiSuperTower/Common/XUiSTChildPanel") +--======================= +--超级爬塔商店按钮面板 +--======================= +local XUiSTBagShopBtnPanel = XClass(ChildPanel, "XUiSTBagShopBtnPanel") + +function XUiSTBagShopBtnPanel:InitPanel() + self:InitButton() +end + +function XUiSTBagShopBtnPanel:InitButton() + local script = require("XUi/XUiSuperTower/Bag/XUiSTBagButton") + self.Button = script.New(self.BtnShop, function() self:OnClick() end, XDataCenter.SuperTowerManager.FunctionName.Shop) +end + +function XUiSTBagShopBtnPanel:OnClick() + XLuaUiManager.Open("UiSuperTowerShop") +end + +return XUiSTBagShopBtnPanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSTBagToggleButton.lua b/Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSTBagToggleButton.lua new file mode 100644 index 00000000..e801cbad --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSTBagToggleButton.lua @@ -0,0 +1,29 @@ +--============= +--单选框选项 +--============= +local XUiSTBagToggleButton = XClass(nil, "XUiSTBagToggleButton") + +function XUiSTBagToggleButton:Ctor(btn, panel, index) + self.Btn = btn + self.Panel = panel + self.Index = index + self.IsSelect = false + self.Btn.CallBack = function() self:OnClick() end +end + +function XUiSTBagToggleButton:Reset() + self.IsSelect = false + self.Btn:SetButtonState(CS.UiButtonState.Normal) +end + +function XUiSTBagToggleButton:OnClick() + self.IsSelect = not self.IsSelect + self.Btn:SetButtonState(self.IsSelect and CS.UiButtonState.Disable or CS.UiButtonState.Normal) + if self.IsSelect then + self.Panel:OnTogSelect(self.Index) + else + self.Panel:OnTogUnSelect(self.Index) + end +end + +return XUiSTBagToggleButton \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSTBagTogglePanel.lua b/Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSTBagTogglePanel.lua new file mode 100644 index 00000000..2b8e7a9b --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSTBagTogglePanel.lua @@ -0,0 +1,38 @@ +local ChildPanel = require("XUi/XUiSuperTower/Common/XUiSTChildPanel") +local TOGGLE_TYPE_NAME = { + [1] = "Bag", --背包 + [2] = "IllustratedBook", --图鉴 + } +--=========================== +--超级爬塔背包页签面板 +--=========================== +local XUiSTBagTogglePanel = XClass(ChildPanel, "XUiSTBagTogglePanel") + +function XUiSTBagTogglePanel:InitPanel() + local toggleGroup = {} + table.insert(toggleGroup, self.BtnTogBag) + table.insert(toggleGroup, self.BtnTogIllustratedBook) + self.BtnGroupToggle:Init(toggleGroup, function(index) self:OnClickToggle(index) end) +end + +function XUiSTBagTogglePanel:SelectToggle(index) + self.BtnGroupToggle:SelectIndex(index) +end + +function XUiSTBagTogglePanel:OnClickToggle(index) + --工厂 + local typeName = TOGGLE_TYPE_NAME[index] + if not typeName then return end + local func = self["OnClickBtn" .. TOGGLE_TYPE_NAME[index]] + if func then func(self) end +end + +function XUiSTBagTogglePanel:OnClickBtnBag() + self.RootUi:ShowPageBag() +end + +function XUiSTBagTogglePanel:OnClickBtnIllustratedBook() + self.RootUi:ShowPageIllustratedBook() +end + +return XUiSTBagTogglePanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSuperTowerBag.lua b/Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSuperTowerBag.lua new file mode 100644 index 00000000..1d467654 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Bag/XUiSuperTowerBag.lua @@ -0,0 +1,203 @@ +--=========================== +--超级爬塔背包页面 +--=========================== +local XUiSuperTowerBag = XLuaUiManager.Register(XLuaUi, "UiSuperTowerCall") +--子面板序号 +local CHILD_PANEL_INDEX = { + Toggle = 1, --页签 + Capacity = 2, --容量显示 + Plugins = 3, --背包芯片列表 + ShopBtn = 4, --商店按钮 + DecomposionBtn = 5, --分解按钮 + LineGraph = 6, --容量条形示意图 + IllustratedBook = 7, --图鉴 + Decomposion = 8, --分解 + } +--子面板路径 +local CHILD_PANEL_SCRIPT_PATH = "XUi/XUiSuperTower/Bag/XUiSTBag" +--页签类型 +local TOGGLE_TYPE_INDEX = { + Bag = 1, --背包 + IllustratedBook = 2, --图鉴 +} +--页面类型 +local PAGE_TYPE = { + Bag = 1, -- 背包 + IllustratedBook = 2, -- 图鉴 + Decomposion = 3, -- 分解 + } +--显示资源键值 +local ASSETS_KEY = "BagAssetsPanelItem" + +function XUiSuperTowerBag:OnAwake() + XTool.InitUiObject(self) + self.FirstIn = true +end + +function XUiSuperTowerBag:OnStart() + self:InitBagData() + self:InitTopBtns() + self:InitPanelAssets() + self:InitChildPanelControl() + self:ShowPanels() + self:SetActivityTimeLimit() +end + +function XUiSuperTowerBag:InitBagData() + self.BagManager = XDataCenter.SuperTowerManager.GetBagManager() +end + +function XUiSuperTowerBag:InitChildPanelControl() + local script = require("XUi/XUiSuperTower/Common/XUiSTMainPage") + self.ChildPanelControl = script.New(self) + self.ChildPanelControl:RegisterChildPanels(CHILD_PANEL_INDEX, CHILD_PANEL_SCRIPT_PATH) +end + +function XUiSuperTowerBag:InitTopBtns() + self.BtnBack.CallBack = function() self:OnClickBackBtn() end + self.BtnMainUi.CallBack = function() self:OnClickMainUiBtn() end + self:BindHelpBtn(self.BtnHelp, "SuperTowerBagHelp") +end + +function XUiSuperTowerBag:InitPanelAssets() + local itemIds = {} + for i = 1, 3 do + local itemId = XSuperTowerConfigs.GetClientBaseConfigByKey(XDataCenter.SuperTowerManager.BaseCfgKey[ASSETS_KEY .. i], true) + if itemId and itemId ~= 0 then + table.insert(itemIds, itemId) + end + end + local asset = XUiPanelAsset.New(self, self.PanelAssets, itemIds[1], itemIds[2], itemIds[3]) + asset:RegisterJumpCallList({ + [1] = function() + XLuaUiManager.Open("UiTip", itemIds[1]) + end, + [2] = function() + XLuaUiManager.Open("UiTip", itemIds[2]) + end, + [3] = function() + XLuaUiManager.Open("UiTip", itemIds[3]) + end + }) +end + +function XUiSuperTowerBag:OnClickBackBtn() + if self.PageType == PAGE_TYPE.Decomposion then + self:ShowPageBag() + else + self:Close() + end +end + +function XUiSuperTowerBag:OnClickMainUiBtn() + XLuaUiManager.RunMain() +end + +function XUiSuperTowerBag:ShowPageBag() + self.PageType = PAGE_TYPE.Bag + local showIndexGroup = { + [CHILD_PANEL_INDEX.Toggle] = true, + [CHILD_PANEL_INDEX.Capacity] = true, + [CHILD_PANEL_INDEX.Plugins] = true, + [CHILD_PANEL_INDEX.LineGraph] = true, + [CHILD_PANEL_INDEX.ShopBtn] = true, + [CHILD_PANEL_INDEX.DecomposionBtn] = true, + } + self.ChildPanelControl:ShowChildPanel(showIndexGroup) + self.ChildPanelControl:DoFunction(CHILD_PANEL_INDEX.Plugins, "RefreshBag") + self.ChildPanelControl:DoFunction(CHILD_PANEL_INDEX.LineGraph, "Refresh") + self.ChildPanelControl:DoFunction(CHILD_PANEL_INDEX.Capacity, "Refresh") + if self.FirstIn then + self.FirstIn = false + else + self:PlayAnimation("QieHuan") + end +end + +function XUiSuperTowerBag:ShowPageIllustratedBook() + self.PageType = PAGE_TYPE.IllustratedBook + local showIndexGroup = { + [CHILD_PANEL_INDEX.Toggle] = true, + [CHILD_PANEL_INDEX.IllustratedBook] = true, + } + self.ChildPanelControl:ShowChildPanel(showIndexGroup) + self.ChildPanelControl:DoFunction(CHILD_PANEL_INDEX.IllustratedBook, "Refresh") + if self.FirstIn then + self.FirstIn = false + else + self:PlayAnimation("QieHuan") + end +end + +function XUiSuperTowerBag:ShowDecomposion() + self.PageType = PAGE_TYPE.Decomposion + local showIndexGroup = { + [CHILD_PANEL_INDEX.Capacity] = true, + [CHILD_PANEL_INDEX.Plugins] = true, + [CHILD_PANEL_INDEX.LineGraph] = true, + [CHILD_PANEL_INDEX.Decomposion] = true, + } + self.ChildPanelControl:ShowChildPanel(showIndexGroup) + self.ChildPanelControl:DoFunction(CHILD_PANEL_INDEX.Plugins, "RefreshDecomposion") + self:PlayAnimation("PanelDecomposionEanble") +end + +function XUiSuperTowerBag:ShowPanels() + self.ChildPanelControl:DoFunction(CHILD_PANEL_INDEX.Toggle, "SelectToggle", TOGGLE_TYPE_INDEX.Bag) +end +--============= +--背包插件列表选中对应星数 +--============= +function XUiSuperTowerBag:PluginsSelectStar(star) + self.ChildPanelControl:DoFunction(CHILD_PANEL_INDEX.Plugins, "SelectStar", star) +end +--============= +--背包插件列表反选对应星数 +--============= +function XUiSuperTowerBag:PluginsUnSelectStar(star) + self.ChildPanelControl:DoFunction(CHILD_PANEL_INDEX.Plugins, "UnSelectStar", star) +end + +function XUiSuperTowerBag:OnDecomposeListRefresh(decomposionList) + self.ChildPanelControl:DoFunction(CHILD_PANEL_INDEX.Decomposion, "OnDecomposeListRefresh", decomposionList) +end + +function XUiSuperTowerBag:ResetDecomposion() + self.ChildPanelControl:DoFunction(CHILD_PANEL_INDEX.Plugins, "ResetDecomposion") +end + +function XUiSuperTowerBag:OnEnable() + XUiSuperTowerBag.Super.OnEnable(self) + self.ChildPanelControl:OnEnable() + self:AddEventListener() +end + +function XUiSuperTowerBag:OnDisable() + XUiSuperTowerBag.Super.OnDisable(self) + self.ChildPanelControl:OnDisable() + self:RemoveEventListener() +end + +function XUiSuperTowerBag:OnDestroy() + self.ChildPanelControl:OnDestroy() + self:RemoveEventListener() +end + +function XUiSuperTowerBag:AddEventListener() + if self.EventAdded then return end + +end + +function XUiSuperTowerBag:RemoveEventListener() + if not self.EventAdded then return end +end + +function XUiSuperTowerBag:SetActivityTimeLimit() + -- 自动关闭 + local endTime = XDataCenter.SuperTowerManager.GetActivityEndTime() + self:SetAutoCloseInfo(endTime, function(isClose) + if isClose then + XDataCenter.SuperTowerManager.HandleActivityEndTime() + end + end) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Common/XUiSTChildPanel.lua b/Resources/Scripts/XUi/XUiSuperTower/Common/XUiSTChildPanel.lua new file mode 100644 index 00000000..f19dccb6 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Common/XUiSTChildPanel.lua @@ -0,0 +1,86 @@ +--=========================== +--超级爬塔子面板控件基类 +--=========================== +local XUiSTChildPanel = XClass(nil, "XUiSTChildPanel") + +function XUiSTChildPanel:Ctor(uiGameObject, rootUi) + XTool.InitUiObjectByUi(self, uiGameObject) + self.RootUi = rootUi + self:InitPanel() +end +--=============== +--初始化面板(在构筑函数最后调用) +--=============== +function XUiSTChildPanel:InitPanel() + +end +--=============== +--刷新面板 +--=============== +function XUiSTChildPanel:RefreshPanel() + +end +--=============== +--显示面板(会调用AddEventListener加入事件,OnEnable方法) +--=============== +function XUiSTChildPanel:ShowPanel() + self.GameObject:SetActiveEx(true) + if not self.EventAdded then + self.EventAdded = true + self:AddEventListener() + end + self:OnEnable() + self:OnShowPanel() +end +--=============== +--隐藏面板(会调用RemoveEventListener移除事件,OnDisable方法) +--=============== +function XUiSTChildPanel:HidePanel() + self.GameObject:SetActiveEx(false) + if self.EventAdded then + self:RemoveEventListener() + self.EventAdded = false + end + self:OnDisable() + self:OnHidePanel() +end +--=============== +--子类复写用,在ShowPanel里面AddEventListener,OnEnable之后调用 +--=============== +function XUiSTChildPanel:OnShowPanel() + +end +--=============== +--子类复写用,在HidePanel里面RemoveEventListener,OnDisable之后调用 +--=============== +function XUiSTChildPanel:OnHidePanel() + +end +--=============== +--面板对象OnEnble时,若用作生命周期需外部统一调用 +--=============== +function XUiSTChildPanel:OnEnable() + +end +--=============== +--面板对象OnDisable时,若用作生命周期需外部统一调用 +--=============== +function XUiSTChildPanel:OnDisable() + +end +--=============== +--面板对象OnDestroy时,若用作生命周期需外部统一调用 +--=============== +function XUiSTChildPanel:OnDestroy() + self:RemoveEventListener() +end + +function XUiSTChildPanel:AddEventListener() + +end + +function XUiSTChildPanel:RemoveEventListener() + +end + +return XUiSTChildPanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Common/XUiSTFunctionButton.lua b/Resources/Scripts/XUi/XUiSuperTower/Common/XUiSTFunctionButton.lua new file mode 100644 index 00000000..85329573 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Common/XUiSTFunctionButton.lua @@ -0,0 +1,124 @@ +--=========================== +--超级爬塔特权绑定按钮(只支持UiButton组件) +--=========================== +local XUiSTFunctionButton = XClass(nil, "XUiSTFunctionButton") +--================== +--构造函数 +--@param uibutton:对象的UiButton +--@param onClickCallBack:点击按钮时回调 +--@param functionKey:绑定按钮的特权键值,不填即不绑定 XSuperTowerManager.FunctionName +--@param reddotEventId:红点事件Id Table +--================== +function XUiSTFunctionButton:Ctor(uibutton, onClickCallBack, functionKey, reddotEventId) + self.UiButton = uibutton + self.OnClickCb = onClickCallBack + self.UiButton.CallBack = function() self:OnClick() end + self.ReddotEventId = reddotEventId + self:InitFunction(functionKey) + self:AddEventListener() +end +--================== +--初始化特权,没有特权绑定时会跳过 +--================== +function XUiSTFunctionButton:InitFunction(functionKey) + if functionKey then + local funcManager = XDataCenter.SuperTowerManager.GetFunctionManager() + self.Function = funcManager:GetFunctionByKey(functionKey) + end + self:RefreshFunction() +end +--================== +--刷新特权按钮状态 +--================== +function XUiSTFunctionButton:RefreshFunction() + if XTool.UObjIsNil(self.UiButton) then + self:OnDestroy() + return + end + self.UiButton:SetDisable(self.Function and not self.Function:CheckIsUnlock() or false) +end +--================== +--检查绑定特权有没解锁 +--================== +function XUiSTFunctionButton:CheckIsUnlock() + if self.Function then + return self.Function:CheckIsUnlock() + end + return true +end +--================== +--点击方法 +--================== +function XUiSTFunctionButton:OnClick() + if not self:CheckIsUnlock() then + local tips = self.Function:GetUnLockDescription() + XUiManager.TipMsg(tips) + return + end + if self.OnClickCb then + self.OnClickCb() + end +end +--================== +--显示红点 +--================== +function XUiSTFunctionButton:ShowReddot(count) + self.UiButton:ShowReddot(count >= 0) +end +--================== +--OnEnable时(需外部调用) +--================== +function XUiSTFunctionButton:OnEnable() + self:AddEventListener() +end +--================== +--显示时 +--================== +function XUiSTFunctionButton:Show() + self:RefreshFunction() + self:AddEventListener() + self.UiButton.gameObject:SetActiveEx(true) +end +--================== +--隐藏时 +--================== +function XUiSTFunctionButton:Hide() + self.UiButton.gameObject:SetActiveEx(false) + self:RemoveEventListener() +end +--================== +--OnDisable时(需外部调用) +--================== +function XUiSTFunctionButton:OnDisable() + self:RemoveEventListener() +end +--================== +--OnDestroy时(需外部调用) +--================== +function XUiSTFunctionButton:OnDestroy() + self:RemoveEventListener() +end +--================== +--加入特权解锁事件监测 +--================== +function XUiSTFunctionButton:AddEventListener() + if self.EventAdded then return end + self.EventAdded = true + XEventManager.AddEventListener(XEventId.EVENT_ST_FUNCTION_UNLOCK, function() self:RefreshFunction() end) + if self.ReddotEventId then + self.RedId = XRedPointManager.AddRedPointEvent(self.UiButton, self.OnCheckBtnTaskRedPoint, self, self.ReddotEventId) + end +end +--================== +--移除事件 +--================== +function XUiSTFunctionButton:RemoveEventListener() + if not self.EventAdded then return end + XEventManager.RemoveEventListener(XEventId.EVENT_ST_FUNCTION_UNLOCK, function() self:RefreshFunction() end) + self.EventAdded = false + if self.ReddotEventId then + XRedPointManager.RemoveRedPointEvent(self.RedId) + end +end + +return XUiSTFunctionButton \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Common/XUiSTMainPage.lua b/Resources/Scripts/XUi/XUiSuperTower/Common/XUiSTMainPage.lua new file mode 100644 index 00000000..787559b0 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Common/XUiSTMainPage.lua @@ -0,0 +1,87 @@ +--=========================== +--超级爬塔主要页面子面板控制集成控件 +--=========================== +local XUiSTMainPage = XClass(nil, "XUiSTMainPage") + +function XUiSTMainPage:Ctor(RootUi) + self.RootUi = RootUi +end +--==================================== +--根据子面板名<->序号字典,和脚本统一父路径注册所有子面板 +--@param panelDic:枚举字典{Key = 子面板名, Value = 子面板序号} +--@param scriptPath:所有子面板统一父路径 +--所有子面板脚本取名都应为 父路径 + Key + "Panel" +--所有子面板GameObject/Transform都应在RootUi中使用"Panel" + Key的名字来索引 +--==================================== +function XUiSTMainPage:RegisterChildPanels(panelDic, scriptPath) + if not self.ChildPanel then self.ChildPanel = {} end + for key, index in pairs(panelDic) do + local script = require(scriptPath .. key .. "Panel") + if script and type(script) == "table" then + self.ChildPanel[index] = script.New(self.RootUi["Panel" .. key], self.RootUi) + end + end +end +--======================== +--根据显示面板序号字典来显隐所有子面板 +--@param showIndexDic:{Key = 子面板序号, Value = true or nil/false面板显隐} +--序号字典中没有包含的子面板会被默认隐藏 +--======================== +function XUiSTMainPage:ShowChildPanel(showIndexDic) + for index, panel in pairs(self.ChildPanel) do + if showIndexDic[index]then + panel:ShowPanel() + else + panel:HidePanel() + end + end +end +--======================== +--显示所有面板 +--======================== +function XUiSTMainPage:ShowAllPanels() + self:AllDoFunction("ShowPanel") +end +--======================== +--根据子面板序号获取子面板 +--======================== +function XUiSTMainPage:GetChildPanelByIndex(index) + return self.ChildPanel[index] +end +--======================== +--根据子面板序号和方法名调用子面板控件方法 +--@param index:子面板序号 +--@param funcName:方法名 +--@param ... :方法需要使用的所有参数 +--======================== +function XUiSTMainPage:DoFunction(index, funcName, ...) + local panel = self.ChildPanel[index] + if panel and panel[funcName] then + return panel[funcName](panel, ...) + end +end +--======================== +--根据方法名调用所有子面板控件方法(通常用于模拟UI生命周期) +--@param funcName:方法名 +--======================== +function XUiSTMainPage:AllDoFunction(funcName) + for _, panel in pairs(self.ChildPanel) do + if panel[funcName] then + panel[funcName](panel) + end + end +end + +function XUiSTMainPage:OnEnable() + self:AllDoFunction("OnEnable") +end + +function XUiSTMainPage:OnDisable() + self:AllDoFunction("OnDisable") +end + +function XUiSTMainPage:OnDestroy() + self:AllDoFunction("OnDestroy") +end + +return XUiSTMainPage \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Function/XUiSTFunctionIcon.lua b/Resources/Scripts/XUi/XUiSuperTower/Function/XUiSTFunctionIcon.lua new file mode 100644 index 00000000..f4c4ed73 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Function/XUiSTFunctionIcon.lua @@ -0,0 +1,28 @@ +--===================== +--解锁特权弹窗 特权图标控件 +--===================== +local XUiSTFunctionIcon = XClass(nil, "XUiSTFunctionIcon") + +function XUiSTFunctionIcon:Ctor(uiGameObject, func) + XTool.InitUiObjectByUi(self, uiGameObject) + self.Func = func + self:Init() +end + +function XUiSTFunctionIcon:Init() + self.RImgIcon:SetRawImage(self.Func:GetIcon()) + self.TxtName.text = self.Func:GetName() + XUiHelper.RegisterClickEvent(self, self.RImgIcon, function() self:OnClick() end) +end + +function XUiSTFunctionIcon:Show() + self.GameObject:SetActiveEx(true) +end + +function XUiSTFunctionIcon:OnClick() + if self.Func then + XLuaUiManager.Open("UiTip", self.Func:GetItemId()) + end +end + +return XUiSTFunctionIcon \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Function/XUiSTFunctionUnlock.lua b/Resources/Scripts/XUi/XUiSuperTower/Function/XUiSTFunctionUnlock.lua new file mode 100644 index 00000000..0e04bdda --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Function/XUiSTFunctionUnlock.lua @@ -0,0 +1,40 @@ +--================ +--解锁特权弹窗 +--================ +local XUiSTFunctionUnlock = XLuaUiManager.Register(XLuaUi, "UiSuperTowerUnlockTips") + +function XUiSTFunctionUnlock:OnAwake() + XTool.InitUiObject(self) + self.BtnClose.CallBack = function() self:Close() end +end + +function XUiSTFunctionUnlock:OnStart(funcList, closeCallback) + self.CloseCb = closeCallback + self:ShowFuncList(funcList) +end + +function XUiSTFunctionUnlock:ShowFuncList(funcList) + self.GridUnlockIcon.gameObject:SetActiveEx(false) + local gridScript = require("XUi/XUiSuperTower/Function/XUiSTFunctionIcon") + for _, func in pairs(funcList) do + local gridGo = CS.UnityEngine.Object.Instantiate(self.GridUnlockIcon.gameObject, self.PanelUnlockInfo) + local grid = gridScript.New(gridGo, func) + grid:Show() + end +end + +function XUiSTFunctionUnlock:OnDisable() + self:OnClose() +end + +function XUiSTFunctionUnlock:OnDestroy() + self:OnClose() +end + +function XUiSTFunctionUnlock:OnClose() + if self.CloseCb then + local cb = self.CloseCb + self.CloseCb = nil + cb() + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Map/XUiGrid3DMapStage.lua b/Resources/Scripts/XUi/XUiSuperTower/Map/XUiGrid3DMapStage.lua new file mode 100644 index 00000000..472a6841 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Map/XUiGrid3DMapStage.lua @@ -0,0 +1,119 @@ +local XUiGrid3DMapStage = XClass(nil, "XUiGrid3DMapStage") +local CSTextManagerGetText = CS.XTextManager.GetText +function XUiGrid3DMapStage:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:SetButtonCallBack() + self.IsSelect = false + self.IsFirstShow = true + self.Effect.gameObject:SetActiveEx(false) +end + +function XUiGrid3DMapStage:SetButtonCallBack() + self.BtnClick.CallBack = function() + self:OnBtnClick() + end +end + +function XUiGrid3DMapStage:OnBtnClick() + if not self.STStage:CheckStageIsOpen() then + XUiManager.TipMsg(self:GetUnLockDesc(true)) + return + end + + self:DoSelect(true) + local uiName = self.STStage:CheckIsSingleTeamOneWave() and "UiSuperTowerSingleStageDetail" or "UiSuperTowerMultiStageDetail" + XLuaUiManager.Open(uiName, self.STStage, self.ThemeIndex, function () + self:DoSelect(false) + end) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_ST_MAP_THEME_SELECT, self.ThemeIndex, self.StageIndex) +end + +function XUiGrid3DMapStage:UpdateGrid(stTheme, stStage, themeIndex, stageIndex, IsCurrent, IsCurrentLock) + self.STTheme = stTheme + self.STStage = stStage + self.ThemeIndex = themeIndex + self.StageIndex = stageIndex + self.IsCurrent = IsCurrent + self.IsCurrentLock = IsCurrentLock + self:UpdateInfo() + self:UpdateEffect() +end + +function XUiGrid3DMapStage:UpdateInfo() + self.TxtName.text = self.STStage:GetSimpleName() + self.TxtProgress.text = CSTextManagerGetText("STStageProgress", self.STStage:GetProgressStr()) + self.TxtLockDesc.text = self:GetUnLockDesc(false) + + self.ImgClear.gameObject:SetActiveEx(self.STStage:CheckIsClear()) + self.TxtLockDesc.gameObject:SetActiveEx(not self.STStage:CheckStageIsOpen() and self.IsCurrentLock) + + self.TxtProgress.gameObject:SetActiveEx(self.STStage:CheckIsMultiWave() and + not self.STStage:CheckIsClear() + and self.STStage:CheckStageIsOpen()) +end + +function XUiGrid3DMapStage:UpdateEffect() + local effectPath + local IsSp = self.StageIndex > 5 + if self.STStage:CheckStageIsOpen() then + if self.IsSelect then + effectPath = self.STTheme:GetStageSelectEffect(IsSp) + else + if self.IsCurrent then + effectPath = self.STTheme:GetStageCurrentEffect(IsSp) + else + effectPath = self.STTheme:GetStageUnLockEffect(IsSp) + end + end + else + effectPath = self.STTheme:GetStageLockEffect(IsSp) + end + + self.Effect.gameObject:LoadPrefab(effectPath) +end + +function XUiGrid3DMapStage:GetUnLockDesc(IsFullTime) + if not self.STStage:CheckIsInTime() then + return CSTextManagerGetText("STThemeUnlock", self.STStage:GetStartTimeStr(IsFullTime)) + end + + if not self.STStage:CheckStagePreCondition() then + + if self.STStage:GetPreStageType() == XDataCenter.SuperTowerManager.StageType.SingleTeamMultiWave or + self.STStage:GetPreStageType() == XDataCenter.SuperTowerManager.StageType.MultiTeamMultiWave then + return CSTextManagerGetText("STMultiWavePreUnlock", self.STStage:GetPreStageSimpleName(), self.STStage:GetPreStageProgress()) + else + return CSTextManagerGetText("STSingleWavePreUnlock", self.STStage:GetPreStageSimpleName()) + end + + end + return "" +end + +function XUiGrid3DMapStage:DoSelect(IsSelect) + self.IsSelect = IsSelect + self.IsFirstShow = not IsSelect + self:UpdateEffect() +end + +function XUiGrid3DMapStage:ShowEffect(IsShow) + if self.IsFirstShow and IsShow then + self:StopTimer() + self.Timer = XScheduleManager.ScheduleOnce(function() + self.Effect.gameObject:SetActiveEx(true) + end, XScheduleManager.SECOND / 10 * self.StageIndex) + else + self.Effect.gameObject:SetActiveEx(IsShow) + end +end + +function XUiGrid3DMapStage:StopTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end + +return XUiGrid3DMapStage \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Map/XUiGrid3DMapTheme.lua b/Resources/Scripts/XUi/XUiSuperTower/Map/XUiGrid3DMapTheme.lua new file mode 100644 index 00000000..37977feb --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Map/XUiGrid3DMapTheme.lua @@ -0,0 +1,66 @@ +local XUiGrid3DMapTheme = XClass(nil, "XUiGrid3DMapTheme") +local CSTextManagerGetText = CS.XTextManager.GetText +function XUiGrid3DMapTheme:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:SetButtonCallBack() +end + +function XUiGrid3DMapTheme:SetButtonCallBack() + self.PanelNormal:GetObject("BtnClick").CallBack = function() + self:OnBtnClick() + end + self.PanelSelect:GetObject("BtnClick").CallBack = function() + self:OnBtnClick() + end + self.PanelDisable:GetObject("BtnClick").CallBack = function() + self:OnBtnClick() + end +end + +function XUiGrid3DMapTheme:OnBtnClick() + if not self.STTheme:CheckIsOpen() then + XUiManager.TipMsg(CSTextManagerGetText("STThemeUnlock", self.STTheme:GetStartTimeStr(true))) + return + end + + CsXGameEventManager.Instance:Notify(XEventId.EVENT_ST_MAP_THEME_SELECT, self.ThemeIndex) +end + +function XUiGrid3DMapTheme:UpdateGrid(data, index, isNewTheme) + self.STTheme = data + self.ThemeIndex = index + self.IsNewTheme = isNewTheme + self:UpdateInfo() +end + +function XUiGrid3DMapTheme:UpdateInfo() + local IsNormal = self.STTheme:CheckIsOpen() and not self.IsNewTheme + local IsSelect = self.STTheme:CheckIsOpen() and self.IsNewTheme + local IsDisable = not self.STTheme:CheckIsOpen() + self.PanelNormal.gameObject:SetActiveEx(IsNormal) + self.PanelSelect.gameObject:SetActiveEx(IsSelect) + self.PanelDisable.gameObject:SetActiveEx(IsDisable) + + if IsDisable then + self.PanelDisable:GetObject("BtnClick"):SetName(self.STTheme:GetName()) + self.PanelDisable:GetObject("TxtOpenTime").text = CSTextManagerGetText("STThemeUnlock", self.STTheme:GetStartTimeStr()) + else + local panel + if IsNormal then + panel = self.PanelNormal + elseif IsSelect then + panel = self.PanelSelect + end + if panel then + panel:GetObject("BtnClick"):SetName(self.STTheme:GetName()) + panel:GetObject("TxtHonor").text = self.STTheme:GetStageClearStr() + panel:GetObject("TxtLayer").text = CSTextManagerGetText("STThemeLayer", self.STTheme:GetHistoryTierStr()) + panel:GetObject("TxtLayerName").text = CSTextManagerGetText("ST3DMainThemeTierLevel") + panel:GetObject("TxtHonorName").text = CSTextManagerGetText("ST3DMainThemeStageLevel") + end + end +end + +return XUiGrid3DMapTheme \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Map/XUiGridStageReward.lua b/Resources/Scripts/XUi/XUiSuperTower/Map/XUiGridStageReward.lua new file mode 100644 index 00000000..a4063453 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Map/XUiGridStageReward.lua @@ -0,0 +1,41 @@ +local XUiGridStageReward = XClass(nil, "XUiGridStageReward") +local CSTextManagerGetText = CS.XTextManager.GetText +local CSObjectInstantiate = CS.UnityEngine.Object.Instantiate +function XUiGridStageReward:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.Grid256.gameObject:SetActiveEx(false) + self.GridRewardList = {} +end + +function XUiGridStageReward:UpdateGrid(root, rewardId, index, sTStage) + local rewards = XRewardManager.GetRewardList(rewardId) + if rewards then + for i, item in pairs(rewards) do + local grid = self.GridRewardList[i] + if not grid then + local ui = CSObjectInstantiate(self.Grid256,self.PanelRewardList) + grid = XUiGridCommon.New(root, ui) + self.GridRewardList[i] = grid + end + grid:Refresh(item) + grid.GameObject:SetActiveEx(true) + end + + for i = #rewards + 1, #self.GridRewardList do + self.GridRewardList[i].GameObject:SetActiveEx(false) + end + end + + local formatStr = index > 9 and "%d" or "0%d" + self.TxtNumber.text = string.format(formatStr, index) + + local IsSingleTeam = sTStage:CheckIsSingleTeamMultiWave() + local titleStr = IsSingleTeam and CSTextManagerGetText("STMultiWaveRewardTitle") or CSTextManagerGetText("STMultiTeamRewardTitle") + self.TxtName.text = CSTextManagerGetText("STRewardText", titleStr) + + self.PanelClear.gameObject:SetActiveEx(sTStage:GetCurrentProgress() >= index) +end + +return XUiGridStageReward \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Map/XUiPanel3DMap.lua b/Resources/Scripts/XUi/XUiSuperTower/Map/XUiPanel3DMap.lua new file mode 100644 index 00000000..8ee26e98 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Map/XUiPanel3DMap.lua @@ -0,0 +1,114 @@ +local XUiPanel3DMap = XClass(nil, "XUiPanel3DMap") +local XUiPanel3DMapChapter = require("XUi/XUiSuperTower/Map/XUiPanel3DMapChapter") + +function XUiPanel3DMap:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.StageManager = XDataCenter.SuperTowerManager.GetStageManager() + self.ChapterList = {} + self.NewestThemeIndex = 0 + self:InitPanel() +end + +function XUiPanel3DMap:InitPanel() + self:InitChapter() +end + +function XUiPanel3DMap:InitChapter() + local themeList = self.StageManager:GetAllThemeList() + for index,data in pairs(themeList) do + if not self.ChapterList[index] then + self:CreateChapter(index) + end + end +end + +function XUiPanel3DMap:UpdatePanel() + self:UpdateNewestThemeIndex() + self:UpdateChapter() + self:CheckCurShowChapterSaveData() +end + +function XUiPanel3DMap:UpdateChapter() + local themeList = self.StageManager:GetAllThemeList() + for index,data in pairs(themeList) do + local IsNew = self.NewestThemeIndex > 0 and self.NewestThemeIndex == index + self.ChapterList[index]:UpdatePanel(data, index, IsNew) + end +end + +function XUiPanel3DMap:CheckCurShowChapterSaveData() + local saveThemeIndex = XDataCenter.SuperTowerManager.GetCurSelectThemeIndex() or 0 + if saveThemeIndex ~= self.NewestThemeIndex then + XDataCenter.SuperTowerManager.RemoveCurSelectThemeIndex() + end +end + +function XUiPanel3DMap:CreateChapter(index) + local str = index < 10 and "Chapter0%d" or "Chapter%d" + local panelName = string.format(str,index) + local chapterObj = self.PanelChapterParent:GetObject(panelName) + local effectObj = self.PanelChapterEffect:GetObject(panelName) + if not chapterObj or not effectObj then + XLog.Error("Is Not Exist Chapter".. panelName .." In 3DUI") + else + self.ChapterList[index] = XUiPanel3DMapChapter.New(chapterObj, effectObj, self.GridTheme, self.GridStage) + end +end + +function XUiPanel3DMap:UpdateNewestThemeIndex() + local themeList = self.StageManager:GetAllThemeList() + for index = #themeList , 1, -1 do + local theme = themeList[index] + if theme:CheckIsOpen() then + local exTheme = themeList[index - 1] + if not exTheme or (exTheme and exTheme:CheckIsAllClear()) then + self.NewestThemeIndex = index + break + end + end + end +end + +function XUiPanel3DMap:SelectTheme(index) + local themeAllIndex = XDataCenter.SuperTowerManager.ThemeIndex.ThemeAll + if index == themeAllIndex then + for _,chapter in pairs(self.ChapterList) do + chapter:StopStageTimer() + chapter:ShowThemeInfo(true) + chapter:ShowStageInfo(false) + end + else + for _,chapter in pairs(self.ChapterList) do + if chapter then + chapter:StopStageTimer() + chapter:ShowThemeInfo(false and index == chapter:GetIndex()) + chapter:ShowStageInfo(true and index == chapter:GetIndex()) + end + end + self:SaveCurShowChapterSaveData(index) + end + self.AnimeChapterParentEnable:PlayTimelineAnimation() +end + +function XUiPanel3DMap:SaveCurShowChapterSaveData(index) + if self.NewestThemeIndex == index then + XDataCenter.SuperTowerManager.SaveCurSelectThemeIndex(index) + end +end + +function XUiPanel3DMap:StopAllStageTimer() + for _,chapter in pairs(self.ChapterList) do + if chapter then + chapter:StopStageTimer() + end + end +end + +function XUiPanel3DMap:GetChapterByIndex(index) + return self.ChapterList[index] +end + + +return XUiPanel3DMap \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Map/XUiPanel3DMapChapter.lua b/Resources/Scripts/XUi/XUiSuperTower/Map/XUiPanel3DMapChapter.lua new file mode 100644 index 00000000..a3f1852e --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Map/XUiPanel3DMapChapter.lua @@ -0,0 +1,151 @@ +local XUiPanel3DMapChapter = XClass(nil, "XUiPanel3DMapChapter") +local XUiGrid3DMapStage = require("XUi/XUiSuperTower/Map/XUiGrid3DMapStage") +local XUiGrid3DMapTheme = require("XUi/XUiSuperTower/Map/XUiGrid3DMapTheme") +local CSTextManagerGetText = CS.XTextManager.GetText +local CSObjectInstantiate = CS.UnityEngine.Object.Instantiate +local CSUnityEngineGameObject = CS.UnityEngine.GameObject +local Vector3 = CS.UnityEngine.Vector3 +function XUiPanel3DMapChapter:Ctor(ui, effectParent, gridTheme, gridStage) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.EffectParent = effectParent + XTool.InitUiObject(self) + self.MapStageList = {} + self.MapTheme = {} + self.GridTheme = gridTheme + self.GridStage = gridStage + self.GridTheme.gameObject:SetActiveEx(false) + self.GridStage.gameObject:SetActiveEx(false) + + self.TerrainEffect = CSUnityEngineGameObject("TerrainEffect") + self.TerrainEffect.transform:SetParent(effectParent.transform, false) + self.MapEffect = CSUnityEngineGameObject("MapEffect") + self.MapEffect.transform:SetParent(effectParent.transform, false) +end + +function XUiPanel3DMapChapter:UpdatePanel(data, index, IsNewTheme) + self.STTheme = data + self.IsNewTheme = IsNewTheme + self.ThemeIndex = index + self:UpdateStage(index) + self:UpdateTheme(index, IsNewTheme) +end + +function XUiPanel3DMapChapter:UpdateStage(themeIndex) + local stageDataList = self.STTheme:GetTargetStageList() + local curIndex = self:GetCurStageIndex() + for index,data in pairs(stageDataList) do + if not self.MapStageList[index] then + self:CreateStage(index) + end + self.MapStageList[index]:UpdateGrid(self.STTheme, data, themeIndex, index, index == curIndex, index == curIndex + 1) + end +end + +function XUiPanel3DMapChapter:GetCurStageIndex() + local stageDataList = self.STTheme:GetTargetStageList() + for index,data in pairs(stageDataList) do + if data:CheckStageIsOpen() and not data:CheckIsClear() then + return index + end + end + return 0 +end + +function XUiPanel3DMapChapter:CreateStage(index) + local str = index < 10 and "Stage0%d" or "Stage%d" + local panelName = string.format(str,index) + local parentObj = self.PanelStageParent:GetObject(panelName) + if not parentObj then + XLog.Error("Is Not Exist Stage:".. panelName .." In 3DUI") + else + local obj = CSObjectInstantiate(self.GridStage, parentObj) + obj.transform.localPosition = Vector3(0, 0, 0) + obj.gameObject:SetActiveEx(true) + self.MapStageList[index] = XUiGrid3DMapStage.New(obj) + end +end + +function XUiPanel3DMapChapter:UpdateTheme(index, isNewTheme) + if not self.MapTheme or not next(self.MapTheme) then + self:CreateTheme() + end + self.MapTheme:UpdateGrid(self.STTheme, index, isNewTheme) + + local terrainEffect = self.STTheme:GetMapTerrainEffect() + + local mapEffect + if not self.STTheme:CheckIsOpen() then + mapEffect = self.STTheme:GetMapLockEffect() + else + mapEffect = self.IsNewTheme and self.STTheme:GetMapCurrentEffect() or self.STTheme:GetMapNormalEffect() + end + + self:LoadEffect(terrainEffect, self.TerrainEffect) + self:LoadEffect(mapEffect, self.MapEffect) +end + +function XUiPanel3DMapChapter:CreateTheme() + local obj = CSObjectInstantiate(self.GridTheme, self.PanelInfoParent) + obj.transform.localPosition = Vector3(0, 0, 0) + obj.gameObject:SetActiveEx(true) + self.MapTheme = XUiGrid3DMapTheme.New(obj) +end + +function XUiPanel3DMapChapter:ShowThemeInfo(IsShow) + self.PanelInfoParent.gameObject:SetActiveEx(IsShow) + self:ShowEffect(self.MapEffect, IsShow) +end + +function XUiPanel3DMapChapter:ShowStageInfo(IsShow) + self.PanelStageParent.gameObject:SetActiveEx(IsShow) + self:ShowEffect(self.TerrainEffect, IsShow) + self:ShowStageEffect(IsShow) +end + +function XUiPanel3DMapChapter:LoadEffect(effectPath, effectParent) + if effectPath then + self.Effect = self.Effect or {} + local effect = self.Effect[effectParent] + + if effect == nil or XTool.UObjIsNil(effect) then + effect = effectParent.gameObject:LoadPrefab(effectPath) + self.Effect[effectParent] = effect + end + + effect.gameObject:SetActiveEx(false) + effect.gameObject:SetActiveEx(true) + end +end + +function XUiPanel3DMapChapter:ShowEffect(effectParent, IsShow) + if effectParent then + effectParent.gameObject:SetActiveEx(IsShow) + end +end + +function XUiPanel3DMapChapter:ShowStageEffect(IsShow) + for _,mapStage in pairs(self.MapStageList) do + mapStage:ShowEffect(IsShow) + end +end + +function XUiPanel3DMapChapter:GetIndex() + return self.ThemeIndex +end + +function XUiPanel3DMapChapter:StopStageTimer() + for _,mapStage in pairs(self.MapStageList) do + mapStage:StopTimer() + end +end + +function XUiPanel3DMapChapter:GetStageByIndex(index) + return self.MapStageList and self.MapStageList[index] +end + +function XUiPanel3DMapChapter:GetTheme() + return self.MapTheme +end + +return XUiPanel3DMapChapter \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Map/XUiPanelStageSelect.lua b/Resources/Scripts/XUi/XUiSuperTower/Map/XUiPanelStageSelect.lua new file mode 100644 index 00000000..9c36f298 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Map/XUiPanelStageSelect.lua @@ -0,0 +1,122 @@ +local XUiPanelStageSelect = XClass(nil, "XUiPanelStageSelect") +local CSTextManagerGetText = CS.XTextManager.GetText +local XUiSTFunctionButton = require("XUi/XUiSuperTower/Common/XUiSTFunctionButton") +function XUiPanelStageSelect:Ctor(ui, base) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Base = base + XTool.InitUiObject(self) + self:SetButtonCallBack() +end + +function XUiPanelStageSelect:SetButtonCallBack() + self.BtnMap.CallBack = function() + self:OnBtnMapClick() + end + self.BtnAdventure.CallBack = function() + self:OnBtnAdventureClick() + end + + self.FunctionBtnSpecial = XUiSTFunctionButton.New(self.BtnSpecial, function() self:OnBtnSpecialClick() end, "CheckSpecialCharacterIsOpen") + + self.BtnGacha.CallBack = function() + self:OnBtnGachaClick() + end + + self.PanelTask:GetObject("BtnClick").CallBack = function() + self:OnTagetInfoClick() + end +end + +function XUiPanelStageSelect:OnBtnMapClick() + local index = XDataCenter.SuperTowerManager.ThemeIndex.ThemeAll + CsXGameEventManager.Instance:Notify(XEventId.EVENT_ST_MAP_THEME_SELECT, index) +end + +function XUiPanelStageSelect:OnBtnAdventureClick() + local playingId = XDataCenter.SuperTowerManager.GetStageManager():GetPlayingTierId() + if playingId == 0 or playingId == self.STTheme:GetId() then + XLuaUiManager.Open("UiSuperTowerStageDetail04", self.STTheme) + else + local tierTheme = XDataCenter.SuperTowerManager.GetStageManager():GetThemeById(playingId) + XUiManager.TipMsg(CSTextManagerGetText("STTierCanNotPlayHint", tierTheme:GetName())) + end +end + +function XUiPanelStageSelect:UpdatePanel(data) + self.STTheme = data + self:UpdateInfo() + self:UpdateAdventure() + self:UpdatePanelTask() + self:UpdateGachaRed() + XRedPointManager.CheckOnceByButton(self.BtnSpecial, { XRedPointConditions.Types.CONDITION_SUPERTOWER_ROLE_INDULT }) +end + +function XUiPanelStageSelect:UpdateInfo() + self.TxtName.text = self.STTheme:GetName() + self.BtnMap:SetName(CSTextManagerGetText("STMainBtnMapName")) + self.BtnSpecial:SetName(CSTextManagerGetText("STMainBtnSpecialName")) + self.BtnGacha:SetName(CSTextManagerGetText("STMainBtnGachaName")) +end + +function XUiPanelStageSelect:UpdateGachaRed() + local gachaNeedItemCount = XSuperTowerConfigs.GetClientBaseConfigByKey("GachaNeedItemCount", true) + local gachaItem = XSuperTowerConfigs.GetClientBaseConfigByKey("GachaItemId", true) + local gachaItemCount = XDataCenter.ItemManager.GetCount(gachaItem) + self:ShowGachaRed(gachaItemCount >= gachaNeedItemCount) +end + +function XUiPanelStageSelect:UpdateTime(time) + self.TxtTime.text = XUiHelper.GetTime(time, XUiHelper.TimeFormatType.ACTIVITY) +end + +function XUiPanelStageSelect:UpdateAdventure() + self.TxtLayer.text = CSTextManagerGetText("STThemeLayer", self.STTheme:GetTierStr()) + self.TxtLayerTop.text = CSTextManagerGetText("STThemeLayer", self.STTheme:GetHistoryTierStr()) + self.TxtHonorName.text = CSTextManagerGetText("STHonorNameText") + self.TxtHonor.text = self.STTheme:GetTierScore() + + self.BtnAdventure:SetName(self.STTheme:GetTierName()) + self.BtnAdventure:ShowTag(self.STTheme:CheckTierIsPlaying()) +end + +function XUiPanelStageSelect:UpdatePanelTask() + local functionManager = XDataCenter.SuperTowerManager.GetFunctionManager() + local newFunction = functionManager:GetTheNewFunction() + self.PanelTask:GetObject("TxtTarget").text = newFunction and newFunction:GetUnLockDescription() or "" + self.PanelTask:GetObject("TxtName").text = CSTextManagerGetText("STTagetFunctionTitleText") + self.PanelTask.gameObject:SetActiveEx(newFunction) +end + +function XUiPanelStageSelect:ShowPanel(IsShow) + self.GameObject:SetActiveEx(IsShow) +end + +function XUiPanelStageSelect:OnBtnSpecialClick() + XLuaUiManager.Open("UiSuperTowerTedianUP") + XRedPointManager.CheckOnceByButton(self.BtnSpecial, { XRedPointConditions.Types.CONDITION_SUPERTOWER_ROLE_INDULT }) +end + +function XUiPanelStageSelect:OnBtnGachaClick() + local gachaSkipId = XSuperTowerConfigs.GetClientBaseConfigByKey("GachaSkipId") + if gachaSkipId then + XFunctionManager.SkipInterface(gachaSkipId) + end +end + +function XUiPanelStageSelect:OnTagetInfoClick() + local functionManager = XDataCenter.SuperTowerManager.GetFunctionManager() + local newFunction = functionManager:GetTheNewFunction() + local itemId = newFunction:GetItemId() + if itemId then + local ownCount = XDataCenter.ItemManager.GetCount(itemId) + local data = {Id = itemId, Count = ownCount} + XLuaUiManager.Open("UiTip", data) + end +end + +function XUiPanelStageSelect:ShowGachaRed(IsShow) + self.BtnGacha:ShowReddot(IsShow) +end + +return XUiPanelStageSelect \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Map/XUiPanelThemeSelect.lua b/Resources/Scripts/XUi/XUiSuperTower/Map/XUiPanelThemeSelect.lua new file mode 100644 index 00000000..e54e4f66 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Map/XUiPanelThemeSelect.lua @@ -0,0 +1,27 @@ +local XUiPanelThemeSelect = XClass(nil, "XUiPanelThemeSelect") +local CSTextManagerGetText = CS.XTextManager.GetText + +function XUiPanelThemeSelect:Ctor(ui, base) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Base = base + XTool.InitUiObject(self) +end + +function XUiPanelThemeSelect:UpdatePanel() + self:UpdateInfo() +end + +function XUiPanelThemeSelect:UpdateInfo() + self.TxtName.text = XDataCenter.SuperTowerManager.GetActivityName() +end + +function XUiPanelThemeSelect:UpdateTime(time) + self.TxtTime.text = XUiHelper.GetTime(time, XUiHelper.TimeFormatType.ACTIVITY) +end + +function XUiPanelThemeSelect:ShowPanel(IsShow) + self.GameObject:SetActiveEx(IsShow) +end + +return XUiPanelThemeSelect \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Map/XUiSuperTowerMain.lua b/Resources/Scripts/XUi/XUiSuperTower/Map/XUiSuperTowerMain.lua new file mode 100644 index 00000000..57752a09 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Map/XUiSuperTowerMain.lua @@ -0,0 +1,290 @@ +--=========================== +--超级爬塔主页面 +--=========================== +local XUiSuperTowerMain = XLuaUiManager.Register(XLuaUi, "UiSuperTowerMain") +local XUiPanel3DMap = require("XUi/XUiSuperTower/Map/XUiPanel3DMap") +local XUiPanelStageSelect = require("XUi/XUiSuperTower/Map/XUiPanelStageSelect") +local XUiPanelThemeSelect = require("XUi/XUiSuperTower/Map/XUiPanelThemeSelect") +local XUiSTFunctionButton = require("XUi/XUiSuperTower/Common/XUiSTFunctionButton") +local CSTextManagerGetText = CS.XTextManager.GetText +local Tablepack = table.pack +local DefaultIndex = 1 +function XUiSuperTowerMain:OnStart() + self:InitSceneRoot() + self:InitPanel() + self:SetButtonCallBack() + -- 自动关闭 + local endTime = XDataCenter.SuperTowerManager.GetActivityEndTime() + self:SetAutoCloseInfo(endTime, function(isClose) + if isClose then + XLuaUiManager.Close("UiSuperTowerTedianUP") + XDataCenter.SuperTowerManager.HandleActivityEndTime() + else + self:CheckTime() + end + end) +end + +function XUiSuperTowerMain:OnDestroy() + self.Panel3DMap:StopAllStageTimer() + + if self.FunctionBtnShop then + self.FunctionBtnShop:OnDestroy() + end + + if self.StageSelectPanel and self.StageSelectPanel.FunctionBtnSpecial then + self.StageSelectPanel.FunctionBtnSpecial:OnDestroy() + end + +end + +function XUiSuperTowerMain:OnEnable() + XUiSuperTowerMain.Super.OnEnable(self) + local IsShowSettleDark = XDataCenter.SuperTowerManager.CheckShowSettleDark() + self:ShowSettleDark(IsShowSettleDark) + self:UpdatePanel() + self:CheckTime() + -- self:CreatrTimer() + self:CheckHitFaceStory() + XRedPointManager.CheckOnceByButton(self.BtnRole, { + XRedPointConditions.Types.CONDITION_SUPERTOWER_ROLE_LEVELUP + , XRedPointConditions.Types.CONDITION_SUPERTOWER_ROLE_PLUGIN }) + self:PlayAnimation("ButtonEnable") + XDataCenter.GuideManager.CheckGuideOpen() +end + +function XUiSuperTowerMain:OnDisable() + XUiSuperTowerMain.Super.OnDisable(self) + -- if self.Timer then + -- XScheduleManager.UnSchedule(self.Timer) + -- end +end + +function XUiSuperTowerMain:OnGetEvents() + return { + XEventId.EVENT_ST_MAP_THEME_SELECT, + XEventId.EVENT_ST_FINISH_FIGHT_COMPLETE + } +end + +function XUiSuperTowerMain:OnNotify(evt, ...) + local args = Tablepack(...) + if evt == XEventId.EVENT_ST_MAP_THEME_SELECT then + self:SelectTheme(args[1], args[2]) + elseif evt == XEventId.EVENT_ST_FINISH_FIGHT_COMPLETE then + self:ShowSettleDark(false) + end +end + +function XUiSuperTowerMain:ShowSettleDark(IsShow) + self.SettleDark.gameObject:SetActiveEx(IsShow) +end + +local CreateCameraKey = function(themeIndex, stageIndex) + local str + if stageIndex then + str = themeIndex > 9 and "%d_%d" or "0%d_%d" + return string.format(str, themeIndex, stageIndex) + else + str = themeIndex > 9 and "%d" or "0%d" + return string.format(str, themeIndex) + end +end + +function XUiSuperTowerMain:InitSceneRoot() + local root = self.UiModelGo.transform + + self.PanelRoleModel = root:FindTransform("PanelRoleModel") + self.PanelMapMain = root:FindTransform("PanelMapMain") + + self.CameraNear = {} + self.Camera3DUi = {} + + self:InitCamera(root, self.CameraNear, "UiCamNearMain", "UiCamNearGrid") + self:InitCamera(root, self.Camera3DUi, "UiCamMain", "UiCamGrid") +end + +function XUiSuperTowerMain:InitCamera(root, cameraDic, cameraMainName, cameraName) + local themeList = XDataCenter.SuperTowerManager.GetStageManager():GetAllThemeList() + + cameraDic[CreateCameraKey(0)] = root:FindTransform(cameraMainName) + + for themeIndex,theme in pairs(themeList or {}) do + + local key = CreateCameraKey(themeIndex) + cameraDic[key] = root:FindTransform(string.format("%s%s", cameraName, key)) + + for stageIndex,_ in pairs(theme:GetTargetStageList() or {}) do + + key = CreateCameraKey(themeIndex, stageIndex) + cameraDic[key] = root:FindTransform(string.format("%s%s", cameraName, key)) + end + end +end + +function XUiSuperTowerMain:InitPanel() + self.Panel3DMap = XUiPanel3DMap.New(self.PanelMapMain) + self.StageSelectPanel = XUiPanelStageSelect.New(self.PanelStageSelect, self) + self.ThemeSelectPanel = XUiPanelThemeSelect.New(self.PanelThemeSelect, self) + + local itemIds = XSuperTowerConfigs.GetMainAssetsPanelItemIds() + self.AssetActivityPanel = XUiPanelActivityAsset.New(self.PanelSpecialTool) + XDataCenter.ItemManager.AddCountUpdateListener(itemIds, function() + self.AssetActivityPanel:Refresh(itemIds) + end, self.AssetActivityPanel) + self.AssetActivityPanel:Refresh(itemIds) + + self.IsInitSelect = true +end + +function XUiSuperTowerMain:SetButtonCallBack() + self.BtnBack.CallBack = function() + self:OnBtnBackClick() + end + self.BtnMainUi.CallBack = function() + self:OnBtnMainUiClick() + end + self.BtnBag.CallBack = function() + self:OnBtnBagClick() + end + + self.FunctionBtnShop = XUiSTFunctionButton.New(self.BtnShop, function() self:OnBtnShopClick() end, XDataCenter.SuperTowerManager.FunctionName.Shop) + self.FunctionBtnRole = XUiSTFunctionButton.New(self.BtnRole, function() self:OnBtnRoleClick() end, XDataCenter.SuperTowerManager.FunctionName.Transfinite) + self:BindHelpBtn(self.BtnHelp, "SuperTowerMainHelp") + + self.PanelGuideButton:GetObject("Open01").CallBack = function() + self:OnBtnGuideThemeClick() + end + + self.PanelGuideButton:GetObject("Stage01").CallBack = function() + self:OnBtnGuideStageClick() + end +end + +function XUiSuperTowerMain:OnBtnBackClick() + if self:IsThemeSelect() then + self:Close() + else + self:SelectTheme(XDataCenter.SuperTowerManager.ThemeIndex.ThemeAll) + end +end + +function XUiSuperTowerMain:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiSuperTowerMain:OnBtnBagClick() + XLuaUiManager.Open("UiSuperTowerCall") +end + +function XUiSuperTowerMain:OnBtnShopClick() + XLuaUiManager.Open("UiSuperTowerShop") +end + +function XUiSuperTowerMain:OnBtnRoleClick() + XLuaUiManager.Open("UiSuperTowerRoleOverrun") +end + +function XUiSuperTowerMain:OnBtnGuideThemeClick() + local chapterData = self.Panel3DMap:GetChapterByIndex(DefaultIndex) + local themeData = chapterData:GetTheme() + themeData:OnBtnClick() +end + +function XUiSuperTowerMain:OnBtnGuideStageClick() + local chapterData = self.Panel3DMap:GetChapterByIndex(DefaultIndex) + local stageData = chapterData:GetStageByIndex(DefaultIndex) + stageData:OnBtnClick() +end + +function XUiSuperTowerMain:CheckTime() + local timeLeft = XDataCenter.SuperTowerManager.GetActivityEndTime() - XTime.GetServerNowTimestamp() + self.StageSelectPanel:UpdateTime(timeLeft) + self.ThemeSelectPanel:UpdateTime(timeLeft) +end + +function XUiSuperTowerMain:CheckHitFaceStory() + local activityId = XDataCenter.SuperTowerManager.GetActivityId() + local hitFaceData = XSaveTool.GetData(string.format( "%sSuperTowerStory%s", XPlayer.Id, activityId)) + if not hitFaceData then + XSaveTool.SaveData(string.format("%sSuperTowerStory%s", XPlayer.Id, activityId), true) + local storyId = XDataCenter.SuperTowerManager.GetPrefaceStoryId() + if storyId and not string.IsNilOrEmpty(storyId) then + XDataCenter.MovieManager.PlayMovie(storyId) + end + end +end + +function XUiSuperTowerMain:UpdatePanel() + --XDataCenter.SuperTowerManager.GetStageManager():CheckReset() + self.Panel3DMap:UpdatePanel() + + if self.IsInitSelect then + if self.InitThemeIndex then + self:SelectTheme(self.InitThemeIndex) + else + local index = XDataCenter.SuperTowerManager.GetCurSelectThemeIndex() + self:SelectTheme(index or XDataCenter.SuperTowerManager.ThemeIndex.ThemeAll) + end + end + + if self:IsThemeSelect() then + self.ThemeSelectPanel:UpdatePanel() + else + local stTheme = XDataCenter.SuperTowerManager.GetStageManager():GetAllThemeList()[self.CurThemeIndex] + self.StageSelectPanel:UpdatePanel(stTheme) + end + + self.ThemeSelectPanel:ShowPanel(self:IsThemeSelect()) + self.StageSelectPanel:ShowPanel(not self:IsThemeSelect()) + + self.BtnBag:SetName(CSTextManagerGetText("STMainBtnBagName")) + self.BtnShop:SetName(CSTextManagerGetText("STMainBtnShopName")) + self.BtnRole:SetName(CSTextManagerGetText("STMainBtnRoleName")) +end + +function XUiSuperTowerMain:SetCameraType(index, stageIndex) + for k, _ in pairs(self.CameraNear) do + self.CameraNear[k].gameObject:SetActiveEx(k == CreateCameraKey(index, stageIndex)) + end + for k, _ in pairs(self.Camera3DUi) do + self.Camera3DUi[k].gameObject:SetActiveEx(k == CreateCameraKey(index, stageIndex)) + end +end + +function XUiSuperTowerMain:SelectTheme(themeIndex, stageIndex) + if stageIndex then + self:PlayAnimation("ButtonDisable") + self.ButtonDisable = true + else + if self.ButtonDisable then + self:PlayAnimation("ButtonEnable") + self.ButtonDisable = false + end + self:PlayAnimation("QieHuan") + end + + self:SetCameraType(themeIndex, stageIndex) + + if self.CurThemeIndex == themeIndex then + return + end + + self.CurThemeIndex = themeIndex + self.Panel3DMap:SelectTheme(themeIndex) + self:UpdatePanel() + self.IsInitSelect = false +end + +function XUiSuperTowerMain:IsThemeSelect() + return self.CurThemeIndex == XDataCenter.SuperTowerManager.ThemeIndex.ThemeAll +end + +function XUiSuperTowerMain:OnReleaseInst() + return self.CurThemeIndex +end + +function XUiSuperTowerMain:OnResume(data) + self:ShowSettleDark(true) + self.InitThemeIndex = data +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Map/XUiSuperTowerMultiStageDetail.lua b/Resources/Scripts/XUi/XUiSuperTower/Map/XUiSuperTowerMultiStageDetail.lua new file mode 100644 index 00000000..69e00e17 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Map/XUiSuperTowerMultiStageDetail.lua @@ -0,0 +1,114 @@ +--=========================== +--超级爬塔多波关卡详情 +--=========================== +local XUiSuperTowerMultiStageDetail = XLuaUiManager.Register(XLuaUi, "UiSuperTowerMultiStageDetail") +local CSTextManagerGetText = CS.XTextManager.GetText +local XUiGridStageReward = require("XUi/XUiSuperTower/Map/XUiGridStageReward") +local XUiSuperTowerBattleRoleRoom = require("XUi/XUiSuperTower/Room/XUiSuperTowerBattleRoleRoom") +function XUiSuperTowerMultiStageDetail:OnStart(stageData, themeIndex, callBack) + self.STStage = stageData + self.ThemeIndex = themeIndex + self.CallBack = callBack + self:SetButtonCallBack() + self:InitPanelReward() +end + +function XUiSuperTowerMultiStageDetail:OnDestroy() + +end + +function XUiSuperTowerMultiStageDetail:OnEnable() + self:UpdatePanel() +end + +function XUiSuperTowerMultiStageDetail:OnDisable() + +end + +function XUiSuperTowerMultiStageDetail:SetButtonCallBack() + self.BtnFight.CallBack = function() + self:OnBtnFightClick() + end + self.BtnCloseMask.CallBack = function() + self:OnBtnCloseMaskClick() + end +end + +function XUiSuperTowerMultiStageDetail:OnBtnFightClick() + self:OnBtnCloseMaskClick() + if self.STStage:CheckIsMultiTeamMultiWave() then + XLuaUiManager.Open("UiSuperTowerDeploy", self.STStage) + elseif self.STStage:CheckIsSingleTeamMultiWave() then + XLuaUiManager.Open("UiBattleRoleRoom", + XDataCenter.SuperTowerManager.GetTeamByStageId(self.STStage:GetFirstStageId()), + self.STStage:GetFirstStageId(), + require("XUi/XUiSuperTower/Room/XUiSuperTowerBattleRoleRoom")) + end + +end + +function XUiSuperTowerMultiStageDetail:OnBtnCloseMaskClick() + self:Close() + if self.CallBack then self.CallBack() end + CsXGameEventManager.Instance:Notify(XEventId.EVENT_ST_MAP_THEME_SELECT, self.ThemeIndex) +end + +function XUiSuperTowerMultiStageDetail:InitPanelReward() + self.DynamicTable = XDynamicTableNormal.New(self.PanelReward) + self.DynamicTable:SetProxy(XUiGridStageReward) + self.DynamicTable:SetDelegate(self) + self.GridReward.gameObject:SetActiveEx(false) +end + +function XUiSuperTowerMultiStageDetail:UpdatePanel() + self:UpdatePanelSingleTeam() + self:UpdatePanelMultiTeam() + self:UpdatePanelInfo() + self:UpdatePanelReward() + self:UpdateAssetsPanel() +end + +function XUiSuperTowerMultiStageDetail:UpdatePanelMultiTeam() + local IsMultiTeam = self.STStage:CheckIsMultiTeamMultiWave() + if IsMultiTeam then + self.PanelMultiTeam:GetObject("TxtProgress").text = self.STStage:GetProgressStr() + self.PanelMultiTeam:GetObject("TxtTeamCount").text = #self.STStage:GetStageId() + end + self.PanelMultiTeam.gameObject:SetActiveEx(IsMultiTeam) +end + +function XUiSuperTowerMultiStageDetail:UpdatePanelSingleTeam() + local IsSingleTeam = self.STStage:CheckIsSingleTeamMultiWave() + if IsSingleTeam then + self.PanelSingleTeam:GetObject("TxtProgress").text = self.STStage:GetProgressStr() + end + self.PanelSingleTeam.gameObject:SetActiveEx(IsSingleTeam) +end + +function XUiSuperTowerMultiStageDetail:UpdatePanelInfo() + self.PanelInfo:GetObject("TxtName").text = self.STStage:GetStageName() + self.PanelInfo:GetObject("TxtNumber").text = self.STStage:GetSimpleName() + self.PanelInfo:GetObject("RImgIcon"):SetRawImage(self.STStage:GetStageBg()) +end + +function XUiSuperTowerMultiStageDetail:UpdatePanelReward() + self.PageDatas = self.STStage:GetRewardId() + self.DynamicTable:SetDataSource(self.PageDatas) + self.DynamicTable:ReloadDataASync(1) +end + +function XUiSuperTowerMultiStageDetail:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:UpdateGrid(self, self.PageDatas[index], index, self.STStage) + end +end + +function XUiSuperTowerMultiStageDetail:UpdateAssetsPanel() + if not self.PanelSpecialTool then return end + local itemIds = XSuperTowerConfigs.GetMainAssetsPanelItemIds() + self.AssetActivityPanel = XUiPanelActivityAsset.New(self.PanelSpecialTool) + XDataCenter.ItemManager.AddCountUpdateListener(itemIds, function() + self.AssetActivityPanel:Refresh(itemIds) + end, self.AssetActivityPanel) + self.AssetActivityPanel:Refresh(itemIds) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Map/XUiSuperTowerSingleStageDetail.lua b/Resources/Scripts/XUi/XUiSuperTower/Map/XUiSuperTowerSingleStageDetail.lua new file mode 100644 index 00000000..ec8cf2b0 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Map/XUiSuperTowerSingleStageDetail.lua @@ -0,0 +1,101 @@ +--=========================== +--超级爬塔单波关卡详情 +--=========================== +local XUiSuperTowerSingleStageDetail = XLuaUiManager.Register(XLuaUi, "UiSuperTowerSingleStageDetail") +local CSTextManagerGetText = CS.XTextManager.GetText +local CSObjectInstantiate = CS.UnityEngine.Object.Instantiate +local DefaultIndex = 1 +function XUiSuperTowerSingleStageDetail:OnStart(stStage, themeIndex, callBack) + self.STStage = stStage + self.ThemeIndex = themeIndex + self.CallBack = callBack + self:SetButtonCallBack() + self.PanelReward:GetObject("Grid128").gameObject:SetActiveEx(false) + self.GridRewardList = {} +end + +function XUiSuperTowerSingleStageDetail:OnDestroy() + +end + +function XUiSuperTowerSingleStageDetail:OnEnable() + self:UpdatePanel() +end + +function XUiSuperTowerSingleStageDetail:OnDisable() + +end + +function XUiSuperTowerSingleStageDetail:SetButtonCallBack() + self.BtnFight.CallBack = function() + self:OnBtnFightClick() + end + self.BtnCloseMask.CallBack = function() + self:OnBtnCloseMaskClick() + end +end + +function XUiSuperTowerSingleStageDetail:OnBtnFightClick() + local team = XDataCenter.SuperTowerManager.GetTeamByStageId(self.STStage:GetFirstStageId()) + local extraData = team:GetExtraData() + extraData:SetStageId(self.STStage:GetFirstStageId()) + self:OnBtnCloseMaskClick() + XLuaUiManager.Open("UiBattleRoleRoom", + XDataCenter.SuperTowerManager.GetTeamByStageId(self.STStage:GetFirstStageId()), + self.STStage:GetFirstStageId(), + require("XUi/XUiSuperTower/Room/XUiSuperTowerBattleRoleRoom")) +end + +function XUiSuperTowerSingleStageDetail:OnBtnCloseMaskClick() + self:Close() + if self.CallBack then self.CallBack() end + CsXGameEventManager.Instance:Notify(XEventId.EVENT_ST_MAP_THEME_SELECT, self.ThemeIndex) +end + +function XUiSuperTowerSingleStageDetail:UpdatePanel() + self:UpdatePanelReward() + self:UpdatePanelInfo() + self:UpdateAssetsPanel() +end + +function XUiSuperTowerSingleStageDetail:UpdatePanelReward() + local rewardIds = self.STStage:GetRewardId() + local rewards = XRewardManager.GetRewardList(rewardIds[DefaultIndex])--单波只存在一个奖励ID + if rewards then + for i, item in pairs(rewards) do + local grid = self.GridRewardList[i] + if not grid then + local ui = CSObjectInstantiate(self.PanelReward:GetObject("Grid128"),self.PanelReward:GetObject("RewardParent")) + grid = XUiGridCommon.New(self, ui) + self.GridRewardList[i] = grid + end + grid:Refresh(item) + grid.GameObject:SetActiveEx(true) + end + + for i = #rewards + 1, #self.GridRewardList do + self.GridRewardList[i].GameObject:SetActiveEx(false) + end + end + + self.PanelReward:GetObject("PanelClear").gameObject:SetActiveEx(self.STStage:CheckIsClear()) +end + +function XUiSuperTowerSingleStageDetail:UpdatePanelInfo() + local description = self.STStage:GetStageDescription() or "" + description = string.gsub(description, "\\n", "\n") + self.PanelInfo:GetObject("TxtStageInfo").text = description + self.PanelInfo:GetObject("TxtName").text = self.STStage:GetStageName() + self.PanelInfo:GetObject("TxtNumber").text = self.STStage:GetSimpleName() + self.PanelInfo:GetObject("RImgIcon"):SetRawImage(self.STStage:GetStageBg()) +end + +function XUiSuperTowerSingleStageDetail:UpdateAssetsPanel() + if not self.PanelSpecialTool then return end + local itemIds = XSuperTowerConfigs.GetMainAssetsPanelItemIds() + self.AssetActivityPanel = XUiPanelActivityAsset.New(self.PanelSpecialTool) + XDataCenter.ItemManager.AddCountUpdateListener(itemIds, function() + self.AssetActivityPanel:Refresh(itemIds) + end, self.AssetActivityPanel) + self.AssetActivityPanel:Refresh(itemIds) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Plugins/XUiSTPluginDetailsRoleHead.lua b/Resources/Scripts/XUi/XUiSuperTower/Plugins/XUiSTPluginDetailsRoleHead.lua new file mode 100644 index 00000000..f0170528 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Plugins/XUiSTPluginDetailsRoleHead.lua @@ -0,0 +1,33 @@ +--=========================== +--超级爬塔角色头像控件 +--=========================== +local XUiSTPluginDetailsRoleHead = XClass(nil, "XUiSTPluginDetailsRoleHead") + +function XUiSTPluginDetailsRoleHead:Ctor(uiGameObject) + XTool.InitUiObjectByUi(self, uiGameObject) +end + +function XUiSTPluginDetailsRoleHead:RefreshData(characterId) + self.CharacterId = characterId + self:RefreshName() + self:RefreshIcon() +end + +function XUiSTPluginDetailsRoleHead:RefreshName() + self.TxtName.text = XCharacterConfigs.GetCharacterTradeName(self.CharacterId) +end + +function XUiSTPluginDetailsRoleHead:RefreshIcon() + local headIcon = XDataCenter.CharacterManager.GetDefaultCharSmallHeadIcon(self.CharacterId) + self.RImgIcon:SetRawImage(headIcon) +end + +function XUiSTPluginDetailsRoleHead:Show() + self.GameObject:SetActiveEx(true) +end + +function XUiSTPluginDetailsRoleHead:Hide() + self.GameObject:SetActiveEx(false) +end + +return XUiSTPluginDetailsRoleHead \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Plugins/XUiSTPluginLevelUp.lua b/Resources/Scripts/XUi/XUiSuperTower/Plugins/XUiSTPluginLevelUp.lua new file mode 100644 index 00000000..5500a084 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Plugins/XUiSTPluginLevelUp.lua @@ -0,0 +1,52 @@ +--=========================== +--超级爬塔芯片升级弹窗页面 +--=========================== +local XUiSTPluginLevelUp = XLuaUiManager.Register(XLuaUi, "UiSuperTowerPlugUp") + +function XUiSTPluginLevelUp:OnAwake() + XTool.InitUiObject(self) + self.GridPlugin.gameObject:SetActiveEx(false) + self.PluginGrids = {} + self.BtnClose.CallBack = function() self:Close() end +end + +function XUiSTPluginLevelUp:OnStart(oldList, newList, closeCallback) + self.PrePluginList = oldList + self.NewPluginList = newList + self.OnCloseCallBack = closeCallback + self:ShowPanel() +end + +function XUiSTPluginLevelUp:ShowPanel() + self:ShowPlugins(self.PrePluginList, self.Panelup.transform) + self:ShowPlugins(self.NewPluginList, self.PanelUpNew.transform) +end + +function XUiSTPluginLevelUp:ShowPlugins(pluginList, parent) + if not pluginList or not parent then return end + local gridScript = require("XUi/XUiSuperTower/Plugins/XUiSuperTowerPluginGrid") + for _, plugin in pairs(pluginList) do + local gridGO = CS.UnityEngine.Object.Instantiate(self.GridPlugin.gameObject) + gridGO.transform:SetParent(parent, false) + local grid = gridScript.New(gridGO) + grid:RefreshData(plugin) + grid:ShowPanel() + end +end + +function XUiSTPluginLevelUp:OnClose() + self:Close() + if self.OnCloseCallBack then + local cb = self.OnCloseCallBack + self.OnCloseCallBack = nil + cb() + end +end + +function XUiSTPluginLevelUp:OnDisable() + self:OnClose() +end + +function XUiSTPluginLevelUp:OnDestroy() + self:OnClose() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Plugins/XUiStCpPluginListPanel.lua b/Resources/Scripts/XUi/XUiSuperTower/Plugins/XUiStCpPluginListPanel.lua new file mode 100644 index 00000000..100244c5 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Plugins/XUiStCpPluginListPanel.lua @@ -0,0 +1,222 @@ +local Base = require("XUi/XUiSuperTower/Common/XUiSTChildPanel") +local COST_MAX_NUM = 9 +--===================== +--爬塔掉落页面详细信息面板 +--===================== +local XUiStCpPluginListPanel = XClass(Base, "XUiStCpPluginListPanel") + +--===================== +--插件排序方法 +--===================== +local SortPlugin = function(dataA, dataB) + --先比较插件品质 + local qualityA = dataA.Plugin:GetQuality() + local qualityB = dataB.Plugin:GetQuality() + if qualityA ~= qualityB then + return qualityA > qualityB + end + --再比较适合的角色战力 + if dataA.AbilityIndex ~= dataB.AbilityIndex then + return dataA.AbilityIndex > dataB.AbilityIndex + end + --最后比较排序配置 + return dataA.Plugin:GetPriority() < dataB.Plugin:GetPriority() + end +function XUiStCpPluginListPanel:InitPanel() + COST_MAX_NUM = XSuperTowerConfigs.GetBaseConfigByKey("MaxTeamPluginCount") + self:InitDynamicTable() +end + +function XUiStCpPluginListPanel:InitDynamicTable() + local GridProxy = require("XUi/XUiSuperTower/Plugins/XUiSuperTowerPluginGrid") + self.DynamicTable = XDynamicTableNormal.New(self.GameObject) + self.DynamicTable:SetProxy(GridProxy) + self.DynamicTable:SetDelegate(self) +end + +--============= +--动态列表事件 +--============= +function XUiStCpPluginListPanel:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(grid.DynamicGrid.gameObject, function(pluginGrid) self:OnGridClick(pluginGrid) end) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + if self.DataList and self.DataList[index] then + grid:RefreshData(self.DataList[index].Plugin, index) + if self.DataList[index].IsCost then + grid:SetFloorLock(true) + grid:SetLockText(CS.XTextManager.GetText("STPcLockText")) + else + grid:SetFloorLock(false) + end + if self.SelectIndex[index] then + grid:SetSelectStatus(true) + else + grid:SetSelectStatus(false) + end + end + end +end +--================== +--设置选择列表 +--================== +function XUiStCpPluginListPanel:SetList() + --获取背包的所有插件列表 + local bagPluginList = XDataCenter.SuperTowerManager.GetBagManager():GetPlugins(true) + local havePlugin = next(bagPluginList) ~= nil + self.PanelNoPlugin.gameObject:SetActiveEx(not havePlugin) + self.DataList = {}--最终的插件数据列表 + if havePlugin then + local targetStage = XDataCenter.SuperTowerManager.GetTargetStageByStageId(self.RootUi.StageId) + --获取目标关卡的所有关卡 + local stageIds = targetStage:GetStageId() + --获取所有现在要调整的队伍以外的所有其他队伍 + local teams = {} + for index, stageId in pairs(stageIds) do + --若StageId不是当前队伍所属的关卡即为其他队伍 + if stageId ~= self.RootUi.StageId then + teams[index] = XDataCenter.SuperTowerManager.GetTeamByStageId(stageId) + end + end + --创建选择其他队的装备插件槽汇总对象 + local script = require("XEntity/XSuperTower/XSuperTowerPluginSlotManager") + local costTotalSlot = script.New() + --设置插件槽的总容量 + costTotalSlot:SetMaxCapacity(COST_MAX_NUM * #stageIds) + --把其他队的装备插件汇总 + for _, team in pairs(teams) do + costTotalSlot:AddSlot(team:GetExtraData()) + end + --获取合并后的消耗插件列表 + local costPluginList = costTotalSlot:GetPluginsNotSplit() + --生成后面比照用的消耗插件字典 + local costCountDic = {} + for _, costPlugin in pairs(costPluginList) do + costCountDic[costPlugin:GetId()] = costPlugin:GetCount() + end + --获取角色ID对应的战力排行顺序字典(战力越高越大) + local roleDic = self:GetCurrentTeamRoleDic() + for _, plugin in pairs(bagPluginList) do + --遍历背包所有插件列表,对照消耗插件字典,标记被消耗的插件 + local costCount = costCountDic[plugin:GetId()] + local charaId = plugin:GetCharacterId() + local data = { + Plugin = plugin, + IsCost = costCount and costCount > 0 or false, + AbilityIndex = ((not charaId or charaId == 0) and 0) or roleDic[charaId] or 0--根据当前队伍角色的战力排序对应插件 + } + if data.IsCost then costCountDic[plugin:GetId()] = costCount - 1 end + table.insert(self.DataList, data) + end + table.sort(self.DataList, SortPlugin) + end + --初始化当前队伍已经装备的插件状态 + self:InitSelectIndex() + self.DynamicTable:SetDataSource(self.DataList) + self.DynamicTable:ReloadDataASync(1) +end +--=============== +--根据当前队伍获取角色ID对应的战力排行顺序字典(战力越高越大) +--=============== +function XUiStCpPluginListPanel:GetCurrentTeamRoleDic() + --获取当前队伍,用于后面排序操作 + local currentTeam = XDataCenter.SuperTowerManager.GetTeamByStageId(self.RootUi.StageId) + --队伍角色列表(按战力从小到大排列,无上阵的视为战力最小) + local teamRoles = {} + for _, entityId in pairs(currentTeam:GetEntityIds()) do + if entityId > 0 then + local role = XDataCenter.SuperTowerManager.GetRoleManager():GetRole(entityId) + table.insert(teamRoles, role) + else + table.insert(teamRoles, 0) + end + end + --按战力排序 + table.sort(teamRoles, function(roleA, roleB) + if roleA == 0 then + return true + end + if roleB == 0 then + return false + end + return roleA:GetCharacterViewModel():GetAbility() < roleB:GetCharacterViewModel():GetAbility() + end) + local roleDic = {} + for index, role in pairs(teamRoles) do + if role ~= 0 then + roleDic[role:GetCharacterId()] = index + end + end + return roleDic +end +--=============== +--初始化当前队伍已经装备的插件状态 +--=============== +function XUiStCpPluginListPanel:InitSelectIndex() + self.SelectIndex = {} + local team = XDataCenter.SuperTowerManager.GetTeamByStageId(self.RootUi.StageId) + --获取当前队伍以及装备的合并插件列表 + local teamPlugins = team:GetExtraData():GetPluginsNotSplit() + for _, teamPlugin in pairs(teamPlugins) do + for index, plugin in ipairs(self.DataList or {}) do + if not plugin.IsCost and teamPlugin:GetId() == plugin.Plugin:GetId() and teamPlugin:GetCount() > 0 then + if not self.SelectIndex[index] then + self.SelectIndex[index] = true + teamPlugin:UpdateCount(teamPlugin:GetCount() - 1) + end + end + end + end +end + +function XUiStCpPluginListPanel:OnShowPanel() + self:SetList() + for index, plugin in ipairs(self.DataList or {}) do + if self.SelectIndex[index] then + self.RootUi:EquipPlugin(index, plugin.Plugin) + end + end +end + +function XUiStCpPluginListPanel:OnGridClick(pluginGrid) + if pluginGrid.IsLock or pluginGrid.IsSelect then return end + self.EquipGrid = pluginGrid + self.EquipGrid:SetActiveStatus(true) + XLuaUiManager.Open("UiSuperTowerPluginDetails", + self.EquipGrid.Plugin, 0, + function() + if not XTool.UObjIsNil(self.Transform) then + self.EquipGrid:SetActiveStatus(false) + self.EquipGrid = nil + end + end, true, + function() + self:OnEquip() + end) +end + +function XUiStCpPluginListPanel:OnEquip() + local count = 0 + for _, isSelect in pairs(self.SelectIndex) do + if isSelect then + count = count + 1 + end + end + if count >= COST_MAX_NUM then + XUiManager.TipMsg(CS.XTextManager.GetText("STCostPluginNumberOver")) + return + end + self.EquipGrid:SetSelectStatus(true) + self.SelectIndex[self.EquipGrid.Index] = true + self.RootUi:EquipPlugin(self.EquipGrid.Index, self.EquipGrid.Plugin) +end + +function XUiStCpPluginListPanel:OnUnEquip(gridIndex) + local grid = self.DynamicTable:GetGridByIndex(gridIndex) + if grid then + grid:SetSelectStatus(false) + end + self.SelectIndex[gridIndex] = false +end + +return XUiStCpPluginListPanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Plugins/XUiStCpPluginSlotPanel.lua b/Resources/Scripts/XUi/XUiSuperTower/Plugins/XUiStCpPluginSlotPanel.lua new file mode 100644 index 00000000..708abf84 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Plugins/XUiStCpPluginSlotPanel.lua @@ -0,0 +1,71 @@ +local Base = require("XUi/XUiSuperTower/Common/XUiSTChildPanel") +local Grid = require("XUi/XUiSuperTower/Plugins/XUiStCpSlotGrid") +local SlotScript = require("XEntity/XSuperTower/XSuperTowerPluginSlotManager") +local COST_MAX_NUM = 9 +--=========================== +--爬塔掉落页面 插件插槽 面板控件 +--=========================== +local XUiStCpPluginSlotPanel = XClass(Base, "XUiStCpPluginSlotPanel") + +function XUiStCpPluginSlotPanel:InitPanel() + self.PluginSlot = SlotScript.New() + self.SlotIndex = {} + COST_MAX_NUM = XSuperTowerConfigs.GetBaseConfigByKey("MaxTeamPluginCount") + self:InitSlotGrids() +end + +function XUiStCpPluginSlotPanel:InitSlotGrids() + self.GridPos.gameObject:SetActiveEx(false) + self.SlotGrids = {} + for i = 1, COST_MAX_NUM do + local gridGo = CS.UnityEngine.Object.Instantiate(self.GridPos, self.PanelContent) + self.SlotGrids[i] = Grid.New(gridGo, i, function(grid) self:UnEquip(grid) end) + self.SlotGrids[i]:Show() + end + self.RootUi.BtnClear.gameObject:SetActiveEx(false) +end + +function XUiStCpPluginSlotPanel:EquipPlugin(gridIndex, plugin) + if not plugin then return end + local addIndex = self.PluginSlot:AddPlugin(plugin) + self.SlotIndex[addIndex] = gridIndex + self.SlotGrids[addIndex]:RefreshData(plugin, self.RootUi.IsStartShow) + self:CheckSlotEmpty() +end + +function XUiStCpPluginSlotPanel:SetGrids() + local plugins = self.PluginSlot:GetPlugins() + for index, pluginData in pairs(plugins) do + self.SlotGrids[index]:RefreshData(pluginData) + end + self:CheckSlotEmpty() +end + +function XUiStCpPluginSlotPanel:UnEquip(slotGrid) + local index = slotGrid.Index + self.RootUi:UnEquip(self.SlotIndex[index]) + self.SlotIndex[index] = 0 + self.PluginSlot:DeletePlugin(index) + slotGrid:Reset() + self:CheckSlotEmpty() +end + +function XUiStCpPluginSlotPanel:Clear() + for i = 1, COST_MAX_NUM do + if self.SlotIndex[i] and self.SlotIndex[i] > 0 then + self:UnEquip(self.SlotGrids[i]) + end + end + self:Confirm() + self:CheckSlotEmpty() +end + +function XUiStCpPluginSlotPanel:Confirm() + self.RootUi.Team:UpdateExtraData(XTool.Clone(self.PluginSlot)) +end + +function XUiStCpPluginSlotPanel:CheckSlotEmpty() + self.RootUi.BtnClear.gameObject:SetActiveEx(not self.PluginSlot:GetIsEmpty()) +end + +return XUiStCpPluginSlotPanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Plugins/XUiStCpRolePanel.lua b/Resources/Scripts/XUi/XUiSuperTower/Plugins/XUiStCpRolePanel.lua new file mode 100644 index 00000000..dd06f220 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Plugins/XUiStCpRolePanel.lua @@ -0,0 +1,27 @@ +local Base = require("XUi/XUiSuperTower/Common/XUiSTChildPanel") +--===================== +--爬塔掉落页面详细信息面板 +--===================== +local XUiStCpRolePanel = XClass(Base, "XUiStCpRolePanel") + +function XUiStCpRolePanel:InitPanel() + self:InitRole() +end + +function XUiStCpRolePanel:InitRole() + for i = 1, 3 do + local headIcon = self["RImgRole" .. i] + if headIcon then + local roleId = self.RootUi.Team:GetEntityIdByTeamPos(i) + if roleId and roleId > 0 then + local role = XDataCenter.SuperTowerManager.GetRoleManager():GetRole(roleId) + headIcon:SetRawImage(role:GetCharacterViewModel():GetBigHeadIcon()) + headIcon.gameObject:SetActiveEx(true) + else + headIcon.gameObject:SetActiveEx(false) + end + end + end +end + +return XUiStCpRolePanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Plugins/XUiStCpSlotGrid.lua b/Resources/Scripts/XUi/XUiSuperTower/Plugins/XUiStCpSlotGrid.lua new file mode 100644 index 00000000..7d77abb7 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Plugins/XUiStCpSlotGrid.lua @@ -0,0 +1,67 @@ +--=========================== +--爬塔掉落页面 插件插槽 控件 +--=========================== +local XUiStCpSlotGrid = XClass(nil, "XUiStCpSlotGrid") +local GridPlugin = require("XUi/XUiSuperTower/Plugins/XUiSuperTowerPluginGrid") +function XUiStCpSlotGrid:Ctor(uiGameObject, index, onUnEquipCallBack) + XTool.InitUiObjectByUi(self, uiGameObject) + self.Index = index + self.PluginGrid = GridPlugin.New(self.GridPlugin) + self.UnEquipCallBack = onUnEquipCallBack + self.BtnPos.CallBack = function() self:OnClick() end + self:Reset() +end + +function XUiStCpSlotGrid:RefreshData(data, isStartShow) + if not data then self:Reset() end + if type(data) == "table" then --data可能是占位符0或plugin对象 + self.Plugin = data + --self.PanelNoPlugin.gameObject:SetActiveEx(false) + self.PluginGrid:RefreshData(self.Plugin) + self.PluginGrid:ShowPanel() + if not isStartShow then + self.PanelEffect.gameObject:SetActiveEx(true) + end + else + self:Reset() + end +end + +function XUiStCpSlotGrid:Reset() + self.Plugin = nil + self.PanelNoPlugin.gameObject:SetActiveEx(true) + self.PluginGrid:HidePanel() + self.ImgSelect.gameObject:SetActiveEx(false) + self.PanelEffect.gameObject:SetActiveEx(false) +end + +function XUiStCpSlotGrid:SetSelect(value) + self.ImgSelect.gameObject:SetActiveEx(value) +end + +function XUiStCpSlotGrid:Show() + self.GameObject:SetActiveEx(true) +end + +function XUiStCpSlotGrid:Hide() + self.GameObject:SetActiveEx(false) +end + +function XUiStCpSlotGrid:OnClick() + if not self.Plugin then return end + self:SetSelect(true) + XLuaUiManager.Open("UiSuperTowerPluginDetails", + self.Plugin, 0, + function() + if not XTool.UObjIsNil(self.Transform) then + self:SetSelect(false) + end + end, false, + function(pluginId) + if self.UnEquipCallBack then + self.UnEquipCallBack(self) + end + end) +end + +return XUiStCpSlotGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Plugins/XUiSuperTowerChoosePlugin.lua b/Resources/Scripts/XUi/XUiSuperTower/Plugins/XUiSuperTowerChoosePlugin.lua new file mode 100644 index 00000000..dabce248 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Plugins/XUiSuperTowerChoosePlugin.lua @@ -0,0 +1,113 @@ +--=========================== +--超级爬塔选择插件页面 +--=========================== +local XUiSuperTowerChoosePlugin = XLuaUiManager.Register(XLuaUi, "UiSuperTowerChooseCore") + +local ASSETS_KEY = "MainAssetsPanelItem" +local CHILD_PANEL = { + Role = 1, --队伍信息 + PluginSlot = 2, --插件插槽 + PluginList = 3, --插件列表 +} + +local CHILD_PANEL_PATH = "XUi/XUiSuperTower/Plugins/XUiStCp" + +function XUiSuperTowerChoosePlugin:OnAwake() + XTool.InitUiObject(self) + self:SetActivityTimeLimit() +end + +function XUiSuperTowerChoosePlugin:OnStart(stageId) + self.StageId = stageId + self.StageType = XDataCenter.SuperTowerManager.GetStageTypeByStageId(stageId) + self.Team = XDataCenter.SuperTowerManager.GetTeamByStageId(stageId) + self.IsStartShow = true + self:InitPanelAssets() + self:InitBtns() + self:InitChildPanels() + self.IsStartShow = false +end + +function XUiSuperTowerChoosePlugin:InitPanelAssets() + local itemIds = {} + for i = 1, 3 do + local itemId = XSuperTowerConfigs.GetClientBaseConfigByKey(XDataCenter.SuperTowerManager.BaseCfgKey[ASSETS_KEY .. i], true) + if itemId and itemId > 0 then + table.insert(itemIds, itemId) + end + end + local asset = XUiPanelAsset.New(self, self.PanelAsset, itemIds[1], itemIds[2], itemIds[3]) + asset:RegisterJumpCallList({[1] = function() + XLuaUiManager.Open("UiTip", itemIds[1]) + end, + [2] = function() + XLuaUiManager.Open("UiTip", itemIds[2]) + end, + [3] = function() + XLuaUiManager.Open("UiTip", itemIds[3]) + end}) +end + +function XUiSuperTowerChoosePlugin:InitChildPanels() + local controlScript = require("XUi/XUiSuperTower/Common/XUiSTMainPage") + self.PanelControl = controlScript.New(self) + self.PanelControl:RegisterChildPanels(CHILD_PANEL, CHILD_PANEL_PATH) + self.PanelControl:ShowAllPanels() +end + +function XUiSuperTowerChoosePlugin:InitBtns() + self.BtnBack.CallBack = function() self:OnClickBack() end + self.BtnMainUi.CallBack = function() self:OnClickMainUi() end + self.BtnClear.CallBack = function() self:OnClickClear() end + self.BtnInstantEquip.CallBack = function() self:OnClickInstantEquip() end + self.BtnDetermine.CallBack = function() self:OnClickDetermine() end +end + +function XUiSuperTowerChoosePlugin:OnClickBack() + self:Close() +end + +function XUiSuperTowerChoosePlugin:OnClickMainUi() + XLuaUiManager.RunMain() +end + +function XUiSuperTowerChoosePlugin:OnClickClear() + self.PanelControl:DoFunction(CHILD_PANEL.PluginSlot, "Clear") +end + +function XUiSuperTowerChoosePlugin:OnClickInstantEquip() + self.PanelControl:DoFunction(CHILD_PANEL.PluginSlot, "Confirm") + local stStage = XDataCenter.SuperTowerManager.GetTargetStageByStageId(self.StageId) + self.PanelControl:DoFunction(CHILD_PANEL.PluginSlot, "Clear") + local team = XDataCenter.SuperTowerManager.GetTeamByStageId(self.StageId) + local teamManager = XDataCenter.SuperTowerManager.GetTeamManager() + local isNew = teamManager:AutoSelectPlugins2Teams({team}) + if isNew then self.PanelControl:DoFunction(CHILD_PANEL.PluginList, "OnShowPanel") end +end + +function XUiSuperTowerChoosePlugin:OnClickDetermine() + self:Close() +end + +function XUiSuperTowerChoosePlugin:EquipPlugin(gridIndex, plugin) + self.PanelControl:DoFunction(CHILD_PANEL.PluginSlot, "EquipPlugin", gridIndex, plugin) +end + +function XUiSuperTowerChoosePlugin:UnEquip(gridIndex) + self.PanelControl:DoFunction(CHILD_PANEL.PluginList, "OnUnEquip", gridIndex) +end + +function XUiSuperTowerChoosePlugin:OnDisable() + XUiSuperTowerChoosePlugin.Super.OnDisable(self) + self.PanelControl:DoFunction(CHILD_PANEL.PluginSlot, "Confirm") +end + +function XUiSuperTowerChoosePlugin:SetActivityTimeLimit() + -- 自动关闭 + local endTime = XDataCenter.SuperTowerManager.GetActivityEndTime() + self:SetAutoCloseInfo(endTime, function(isClose) + if isClose then + XDataCenter.SuperTowerManager.HandleActivityEndTime() + end + end) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Plugins/XUiSuperTowerEnhanceDetails.lua b/Resources/Scripts/XUi/XUiSuperTower/Plugins/XUiSuperTowerEnhanceDetails.lua new file mode 100644 index 00000000..78286cbe --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Plugins/XUiSuperTowerEnhanceDetails.lua @@ -0,0 +1,100 @@ +--=========================== +--超级爬塔增益详细页面 +--=========================== +local XUiSuperTowerEnhanceDetails = XLuaUiManager.Register(XLuaUi, "UiSuperTowerEnhanceDetails") +local Vector3 = CS.UnityEngine.Vector3 +function XUiSuperTowerEnhanceDetails:OnAwake() + XTool.InitUiObject(self) + self.BtnEquip.gameObject:SetActiveEx(false) + self.BtnUnEquip.gameObject:SetActiveEx(false) +end +--================== +--界面显示时 +--@param pluginId: 插件Id +--@param posXOffset: 左右位置偏移(0或不填为屏幕中间,往右移为正数,左移为负数) +--================== +function XUiSuperTowerEnhanceDetails:OnStart(enhanceId, posXOffset, closeCallBack) + self:FixPos(posXOffset or 0) + self:InitEnhanceCfg(enhanceId) + self:InitGrids() + self.CloseCallBack = closeCallBack + XUiHelper.RegisterClickEvent(self, self.BtnClose, function() self:OnClose() end) + self:ShowPanel() +end +--================== +--调整界面X轴(左右)位置 +--================== +function XUiSuperTowerEnhanceDetails:FixPos(posXOffset) + self.Transform.localPosition = self.Transform.localPosition + Vector3(posXOffset, 0, 0) +end +--================== +--初始化插件配置 +--================== +function XUiSuperTowerEnhanceDetails:InitEnhanceCfg(enhanceId) + self.EnhanceId = enhanceId + self.EnhanceCfg = XSuperTowerConfigs.GetEnhanceCfgById(enhanceId) +end +--================== +--初始化控件 +--================== +function XUiSuperTowerEnhanceDetails:InitGrids() + local gridScript = require("XUi/XUiSuperTower/Plugins/XUiSuperTowerEnhanceGrid") + self.EnhanceGrid = gridScript.New(self.GridPlugin) + local characterScript = require("XUi/XUiSuperTower/Plugins/XUiSTPluginDetailsRoleHead") + self.RoleGrid = characterScript.New(self.GridRole) +end +--================== +--显示面板 +--================== +function XUiSuperTowerEnhanceDetails:ShowPanel() + self:ShowName() + self:ShowDescription() + self:ShowGrid() + self:ShowRoleHead() +end +--================== +--显示插件名称 +--================== +function XUiSuperTowerEnhanceDetails:ShowName() + if self.TxtName then + self.TxtName.text = self.EnhanceCfg.Name + end +end +--================== +--显示插件效果 +--================== +function XUiSuperTowerEnhanceDetails:ShowDescription() + if self.TxtDesc then + self.TxtDesc.text = self.EnhanceCfg.Description + end +end +--================== +--显示图标 +--================== +function XUiSuperTowerEnhanceDetails:ShowGrid() + self.EnhanceGrid:RefreshData(self.EnhanceId) +end +--================== +--显示头像 +--================== +function XUiSuperTowerEnhanceDetails:ShowRoleHead() + local characterId = self.EnhanceCfg.CharacterId + local haveCharacter = characterId and characterId > 0 + if haveCharacter then + self.RoleGrid:Show() + self.RoleGrid:RefreshData(characterId) + else + self.RoleGrid:Hide() + end +end +--================== +--关闭面板时 +--================== +function XUiSuperTowerEnhanceDetails:OnClose() + self:Close() + if self.CloseCallBack then + local cb = self.CloseCallBack + self.CloseCallBack = nil + cb() + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Plugins/XUiSuperTowerEnhanceGrid.lua b/Resources/Scripts/XUi/XUiSuperTower/Plugins/XUiSuperTowerEnhanceGrid.lua new file mode 100644 index 00000000..69f64d6a --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Plugins/XUiSuperTowerEnhanceGrid.lua @@ -0,0 +1,43 @@ +--=========================== +--超级爬塔增益控件 +--=========================== +local XUiSuperTowerEnhanceGrid = XClass(nil, "XUiSuperTowerEnhanceGrid") + +function XUiSuperTowerEnhanceGrid:Ctor(uiGameObject, onClickCallBack) + self:Init(uiGameObject, onClickCallBack) +end + +function XUiSuperTowerEnhanceGrid:Init(uiGameObject, onClickCallBack) + XTool.InitUiObjectByUi(self, uiGameObject) + if onClickCallBack then + self.OnClickCb = onClickCallBack + end + XUiHelper.RegisterClickEvent(self, self.BtnClick or self.RImgIcon, function() + self:OnClick() + end) +end + +function XUiSuperTowerEnhanceGrid:RefreshData(enhanceId) + self.EnhanceId = enhanceId + self.EnhanceCfg = XSuperTowerConfigs.GetEnhanceCfgById(enhanceId) + if self.RImgIcon then self.RImgIcon:SetRawImage(self.EnhanceCfg.Icon) end + if self.ImgQuality then self.ImgQuality:SetSprite(XSuperTowerConfigs.GetStarIconByQuality(self.EnhanceCfg.Quality)) end + if self.TxtName then self.TxtName.text = self.EnhanceCfg.Name end + if self.ImgQualityBg then self.ImgQualityBg:SetSprite(XSuperTowerConfigs.GetStarBgByQuality(self.EnhanceCfg.Quality)) end +end + +function XUiSuperTowerEnhanceGrid:OnClick() + if self.OnClickCb then + self.OnClickCb(self) + end +end + +function XUiSuperTowerEnhanceGrid:ShowPanel() + self.GameObject:SetActiveEx(true) +end + +function XUiSuperTowerEnhanceGrid:HidePanel() + self.GameObject:SetActiveEx(false) +end + +return XUiSuperTowerEnhanceGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Plugins/XUiSuperTowerMixGrid.lua b/Resources/Scripts/XUi/XUiSuperTower/Plugins/XUiSuperTowerMixGrid.lua new file mode 100644 index 00000000..e398dc47 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Plugins/XUiSuperTowerMixGrid.lua @@ -0,0 +1,91 @@ +--================= +--混合型插件\增益类控件 +--================= +local XUiSuperTowerMixGrid = XClass(nil, "XUiSuperTowerMixGrid") + +function XUiSuperTowerMixGrid:Ctor(uiGameObject, onClickCallBack) + self:Init(uiGameObject, onClickCallBack) +end + +function XUiSuperTowerMixGrid:Init(uiGameObject, onClickCallBack) + XTool.InitUiObjectByUi(self, uiGameObject) + if onClickCallBack then + self.OnClickCb = onClickCallBack + end + XUiHelper.RegisterClickEvent(self, self.BtnClick, function() + self:OnClick() + end) +end + +--=================== +--使用配置更新UI +--@param itemType道具类型:XSuperTowerManager.ItemType +--=================== +function XUiSuperTowerMixGrid:RefreshCfg(cfg, itemType) + local ITEM_TYPE = XDataCenter.SuperTowerManager.ItemType + self.ItemType = itemType + self.ItemCfg = cfg + if self.ItemType == ITEM_TYPE.Enhance then + self.EnhanceId = self.ItemCfg.Id + self.EnhanceCfg = self.ItemCfg + elseif self.ItemType == ITEM_TYPE.Plugin then + local pluginScript = require("XEntity/XSuperTower/Plugin/XSuperTowerPlugin") + self.Plugin = pluginScript.New(self.ItemCfg.Id) + end + if self.RImgIcon then + self.RImgIcon:SetRawImage(self.ItemCfg.Icon) + end + if self.TxtName then + self.TxtName.text = self.ItemCfg.Name + end + if self.ImgQuality then + self.ImgQuality:SetSprite(XSuperTowerConfigs.GetStarIconByQuality(self.ItemCfg.Quality)) + end + if self.ImgQualityBg then + self.ImgQualityBg:SetSprite(XSuperTowerConfigs.GetStarBgByQuality(self.ItemCfg.Quality)) + end +end + +function XUiSuperTowerMixGrid:OnClick() + if self.OnClickCb then + self.OnClickCb(self) + end +end + +function XUiSuperTowerMixGrid:SetIndex(index) + self.Index = index +end + +function XUiSuperTowerMixGrid:ShowPanel() + self.GameObject:SetActiveEx(true) +end + +function XUiSuperTowerMixGrid:HidePanel() + self.GameObject:SetActiveEx(false) +end + +function XUiSuperTowerMixGrid:SetNormalLock(value) + self.ImgNormalLock.gameObject:SetActiveEx(value) +end + +function XUiSuperTowerMixGrid:SetFloorLock(value, text) + self.ImgFloorLock.gameObject:SetActiveEx(value) +end + +function XUiSuperTowerMixGrid:SetActiveStatus(value) + self.ImgActive.gameObject:SetActiveEx(value) +end + +function XUiSuperTowerMixGrid:SetSelectStatus(value) + self.ImgSelect.gameObject:SetActiveEx(value) +end + +function XUiSuperTowerMixGrid:SetLockText(text) + if self.TxtLock then self.TxtLock.text = text end +end + +function XUiSuperTowerMixGrid:SetClickCallBack(callback) + self.OnClickCb = callback +end + +return XUiSuperTowerMixGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Plugins/XUiSuperTowerPluginDetails.lua b/Resources/Scripts/XUi/XUiSuperTower/Plugins/XUiSuperTowerPluginDetails.lua new file mode 100644 index 00000000..e22b30e7 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Plugins/XUiSuperTowerPluginDetails.lua @@ -0,0 +1,140 @@ +--=========================== +--超级爬塔芯片详细页面 +--=========================== +local XUiSuperTowerPluginDetails = XLuaUiManager.Register(XLuaUi, "UiSuperTowerPluginDetails") +local Vector3 = CS.UnityEngine.Vector3 +function XUiSuperTowerPluginDetails:OnAwake() + XTool.InitUiObject(self) +end +--================== +--界面显示时 +--@param pluginId: 插件Id +--@param posXOffset: 左右位置偏移(0或不填为屏幕中间,往右移为正数,左移为负数) +--================== +function XUiSuperTowerPluginDetails:OnStart(plugin, posXOffset, closeCallBack, isEquip, equipCallBack) + self:FixPos(posXOffset or 0) + self:InitPluginCfg(plugin) + self:InitGrids() + self.CloseCallBack = closeCallBack + if isEquip ~= nil then + self.IsEquipment = isEquip + self.BtnEquip.CallBack = function() self:OnClickBtnEquip() end + self.BtnUnEquip.CallBack = function() self:OnClickBtnUnEquip() end + self.EquipCallBack = equipCallBack + self.UnEquipCallBack = equipCallBack + end + XUiHelper.RegisterClickEvent(self, self.BtnClose, function() self:OnClose() end) + self:ShowPanel() +end +--================== +--调整界面X轴(左右)位置 +--================== +function XUiSuperTowerPluginDetails:FixPos(posXOffset) + self.PanelDetail.transform.localPosition = self.PanelDetail.transform.localPosition + Vector3(posXOffset, 0, 0) +end +--================== +--初始化插件配置 +--================== +function XUiSuperTowerPluginDetails:InitPluginCfg(plugin) + self.PluginId = plugin:GetId() + self.Plugin = plugin +end +--================== +--初始化控件 +--================== +function XUiSuperTowerPluginDetails:InitGrids() + local gridScript = require("XUi/XUiSuperTower/Plugins/XUiSuperTowerPluginGrid") + self.PluginGrid = gridScript.New(self.GridPlugin) + local characterScript = require("XUi/XUiSuperTower/Plugins/XUiSTPluginDetailsRoleHead") + self.RoleGrid = characterScript.New(self.GridRole) +end +--================== +--显示面板 +--================== +function XUiSuperTowerPluginDetails:ShowPanel() + self:ShowPluginName() + self:ShowDescription() + self:ShowPluginGrid() + self:ShowBtnEquip() + self:ShowRoleHead() +end +--================== +--显示插件名称 +--================== +function XUiSuperTowerPluginDetails:ShowPluginName() + if self.TxtName then + self.TxtName.text = self.Plugin:GetName() + end + if self.TxtQuality then + self.TxtQuality.text = XUiHelper.GetText("STPluginDetailsStarStr", self.Plugin:GetQuality()) + end +end +--================== +--显示插件效果 +--================== +function XUiSuperTowerPluginDetails:ShowDescription() + if self.TxtDesc then + self.TxtDesc.text = self.Plugin:GetDesc() + end +end +--================== +--显示图标 +--================== +function XUiSuperTowerPluginDetails:ShowPluginGrid() + self.PluginGrid:RefreshData(self.Plugin) +end +--================== +--显示装备按钮 +--================== +function XUiSuperTowerPluginDetails:ShowBtnEquip() + self.BtnEquip.gameObject:SetActiveEx(self.IsEquipment ~= nil and self.IsEquipment == true) + self.BtnUnEquip.gameObject:SetActiveEx(self.IsEquipment ~= nil and self.IsEquipment == false) +end +--================== +--显示头像 +--================== +function XUiSuperTowerPluginDetails:ShowRoleHead() + local characterId = self.Plugin:GetCharacterId() + local haveCharacter = characterId and characterId > 0 + if haveCharacter then + if self.PanelChara then self.PanelChara.gameObject:SetActiveEx(true) end + self.RoleGrid:RefreshData(characterId) + else + if self.PanelChara then self.PanelChara.gameObject:SetActiveEx(false) end + end +end +--================== +--点击装备时 +--================== +function XUiSuperTowerPluginDetails:OnClickBtnEquip() + if self.IsEquipment == nil then return end + if self.EquipCallBack then + local cb = self.EquipCallBack + self.EquipCallBack = nil + cb(self.PluginId) + self:OnClose() + end +end +--================== +--点击卸下时 +--================== +function XUiSuperTowerPluginDetails:OnClickBtnUnEquip() + if self.IsEquipment == nil then return end + if self.UnEquipCallBack then + local cb = self.UnEquipCallBack + self.UnEquipCallBack = nil + cb(self.PluginId) + self:OnClose() + end +end +--================== +--关闭面板时 +--================== +function XUiSuperTowerPluginDetails:OnClose() + self:Close() + if self.CloseCallBack then + local cb = self.CloseCallBack + self.CloseCallBack = nil + cb() + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Plugins/XUiSuperTowerPluginGrid.lua b/Resources/Scripts/XUi/XUiSuperTower/Plugins/XUiSuperTowerPluginGrid.lua new file mode 100644 index 00000000..8210bf67 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Plugins/XUiSuperTowerPluginGrid.lua @@ -0,0 +1,131 @@ +--=========================== +--超级爬塔芯片控件 +--=========================== +local XUiSuperTowerPluginGrid = XClass(nil, "XUiSuperTowerPluginGrid") + +function XUiSuperTowerPluginGrid:Ctor(uiGameObject, onClickCallBack) + self.IsClickShowDetail = false + self:Init(uiGameObject, onClickCallBack) +end + +function XUiSuperTowerPluginGrid:Init(uiGameObject, onClickCallBack) + XTool.InitUiObjectByUi(self, uiGameObject) + if onClickCallBack then + self.OnClickCb = onClickCallBack + end + XUiHelper.RegisterClickEvent(self, self.BtnClick, function() + self:OnClick() + end) +end +--=================== +--设置点击是否展示详情 +--=================== +function XUiSuperTowerPluginGrid:SetClickIsShowDetail(value) + self.IsClickShowDetail = value +end +--=================== +--使用插件配置更新UI +--=================== +function XUiSuperTowerPluginGrid:RefreshCfg(pluginCfg) + self.PluginCfg = pluginCfg + local pluginScript = require("XEntity/XSuperTower/Plugin/XSuperTowerPlugin") + self.Plugin = pluginScript.New(pluginCfg.Id) + if self.RImgIcon then + self.RImgIcon:SetRawImage(pluginCfg.Icon) + end + if self.TxtName then + self.TxtName.text = pluginCfg.Name + end + if self.ImgQuality then + self.ImgQuality:SetSprite(XSuperTowerConfigs.GetStarIconByQuality(pluginCfg.Quality)) + end + if self.ImgQualityBg then + self.ImgQualityBg:SetSprite(XSuperTowerConfigs.GetStarBgByQuality(pluginCfg.Quality)) + end + self:RefreshOtherCfg(pluginCfg) +end + +--=================== +--使用插件对象更新UI +--=================== +function XUiSuperTowerPluginGrid:RefreshData(plugin, index) + self.Plugin = plugin + self.Index = index + if self.RImgIcon then + self.RImgIcon:SetRawImage(plugin:GetIcon()) + end + if self.TxtName then + self.TxtName.text = plugin:GetName() + end + if self.ImgQualityBg then + self.ImgQuality:SetSprite(self.Plugin:GetQualityIcon()) + end + if self.ImgQualityBg then + self.ImgQualityBg:SetSprite(self.Plugin:GetQualityBg()) + end + self:RefreshOtherData(plugin) +end +--=================== +--供子类使用的更新方法,如需执行一次父类时就复写这个方法,不需要则复写RefreshData +--=================== +function XUiSuperTowerPluginGrid:RefreshOtherData(plugin) + +end +--=================== +--供子类使用的更新方法,如需执行一次父类时就复写这个方法,不需要则复写RefreshData +--=================== +function XUiSuperTowerPluginGrid:RefreshOtherCfg(pluginCfg) + +end + +function XUiSuperTowerPluginGrid:OnClick() + if self.IsClickShowDetail then + XLuaUiManager.Open("UiSuperTowerPluginDetails", self.Plugin) + end + if self.OnClickCb then + self.OnClickCb(self) + end +end + +function XUiSuperTowerPluginGrid:ShowPanel() + self.GameObject:SetActiveEx(true) +end + +function XUiSuperTowerPluginGrid:HidePanel() + self.GameObject:SetActiveEx(false) +end + +function XUiSuperTowerPluginGrid:SetNormalLock(value) + self.IsLock = value + self.ImgNormalLock.gameObject:SetActiveEx(value) +end + +function XUiSuperTowerPluginGrid:SetFloorLock(value, text) + self.IsLock = value + self.ImgFloorLock.gameObject:SetActiveEx(value) + self:SetLockText(text) +end + +function XUiSuperTowerPluginGrid:SetActiveStatus(value) + self.IsActive = value + self.ImgActive.gameObject:SetActiveEx(value) +end + +function XUiSuperTowerPluginGrid:SetSelectStatus(value) + self.IsSelect = value + self.ImgSelect.gameObject:SetActiveEx(value) +end + +function XUiSuperTowerPluginGrid:GetPlugin() + return self.Plugin +end + +function XUiSuperTowerPluginGrid:SetLockText(text) + if self.TxtLock then self.TxtLock.text = text end +end + +function XUiSuperTowerPluginGrid:SetClickCallBack(callback) + self.OnClickCb = callback +end + +return XUiSuperTowerPluginGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Role/XUiRoleLevelUpPanel.lua b/Resources/Scripts/XUi/XUiSuperTower/Role/XUiRoleLevelUpPanel.lua new file mode 100644 index 00000000..229dabf8 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Role/XUiRoleLevelUpPanel.lua @@ -0,0 +1,262 @@ +local XUiSuperTowerPluginGrid = require("XUi/XUiSuperTower/Plugins/XUiSuperTowerPluginGrid") + +local XUiRoleLevelUpPanel = XClass(nil, "XUiRoleLevelUpPanel") + +local AUTO_SELECT_MIN_STAR = 2 +local AUTO_SELECT_MAX_STAR = 4 + +function XUiRoleLevelUpPanel:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + -- XSuperTowerRole + self.SuperTowerRole = nil + -- XSuperPlugin Dic + self.UsedSuperPluginDic = nil + -- 插件选择状态 + self.PluginGridSelectStatusDic = nil + -- 插件筛选星级状态 + self.PluginStarSelectStatusDic = nil + -- 插件列表 + self.DynamicTable = XDynamicTableNormal.New(self.PanelEquipScroll) + self.DynamicTable:SetProxy(XUiSuperTowerPluginGrid) + self.DynamicTable:SetDelegate(self) + self.GridCore.gameObject:SetActiveEx(false) + self.CurrentPlugins = nil + self.ImgAscend.gameObject:SetActiveEx(true) + self.ImgDescend.gameObject:SetActiveEx(false) + self:RegisterUiEvents() +end + +-- superTowerRole : XSuperTowerRole +function XUiRoleLevelUpPanel:SetData(superTowerRoleId) + self.GameObject:SetActiveEx(true) + self.SuperTowerRole = XDataCenter.SuperTowerManager.GetRoleManager():GetRole(superTowerRoleId) + self:Reset() +end + +--######################## 私有方法 ######################## + +function XUiRoleLevelUpPanel:Reset() + self.PluginStarSelectStatusDic = { + [2] = false, + [3] = false, + [4] = false, + } + self.UsedSuperPluginDic = {} + self.PluginGridSelectStatusDic = {} + self.CurrentBarExp = self.SuperTowerRole:GetCurrentExp() + self.CurrentLevel = self.SuperTowerRole:GetSuperLevel() + self.TotalAddExp = 0 + -- 初始化toggle的状态 + for k, v in pairs(self.PluginStarSelectStatusDic) do + self["TogStar" .. k].isOn = v + end + self:ResetBaseInfo() +end + +function XUiRoleLevelUpPanel:RegisterUiEvents() + self.BtnGetPlugins.CallBack = function() self:OnBtnGetPluginsClicked() end + self.BtnUpgrade.CallBack = function() self:OnBtnUpgradeClicked() end + self.BtnAutoSelect.CallBack = function() self:OnBtnAutoSelectClicked() end + self.BtnStar4.CallBack = function() self:OnBtnTogStarValueChanged(4) end + self.BtnStar3.CallBack = function() self:OnBtnTogStarValueChanged(3) end + self.BtnStar2.CallBack = function() self:OnBtnTogStarValueChanged(2) end + self.BtnOrder.CallBack = function() self:OnBtnOrderClicked() end +end + +function XUiRoleLevelUpPanel:OnBtnOrderClicked() + local isAscend = self.ImgAscend.gameObject.activeSelf + self.ImgAscend.gameObject:SetActiveEx(not isAscend) + self.ImgDescend.gameObject:SetActiveEx(isAscend) + self:Reset() +end + +function XUiRoleLevelUpPanel:OnBtnTogStarValueChanged(star, isOn) + if isOn == self["TogStar" .. star].isOn then + return + end + if isOn == nil then isOn = not self["TogStar" .. star].isOn end + -- 设置toggle状态 + -- isOn为true时检查是否超过最大等级 + if isOn and self.CurrentLevel >= self.SuperTowerRole:GetMaxSuperLevel() then + XUiManager.TipError(XUiHelper.GetText("STTransfiniteMaxLevel")) + self["TogStar" .. star].isOn = false + return + end + self["TogStar" .. star].isOn = isOn + self.PluginStarSelectStatusDic[star] = isOn + -- 找到相同星级的做点击或取消点击的处理 + local plugins = {} + for _, plugin in ipairs(self.CurrentPlugins) do + if star == plugin:GetStar() then + table.insert(plugins, plugin) + end + end + self:AutoSelectPlugin(plugins, isOn) +end + +function XUiRoleLevelUpPanel:RefreshPlugins() + self.CurrentPlugins = XDataCenter.SuperTowerManager.GetBagManager():GetPlugins(not self.ImgAscend.gameObject.activeSelf) + self.DynamicTable:SetDataSource(self.CurrentPlugins) + self.DynamicTable:ReloadDataSync(1) +end + +function XUiRoleLevelUpPanel:OnDynamicTableEvent(event, index, grid) + if index <= 0 or index > #self.DynamicTable.DataSource then return end + local data = self.DynamicTable.DataSource[index] + local pluginId = data:GetId() + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:RefreshData(data) + grid:SetActiveStatus(self:GetPluginSelectStatus(data)) + grid:SetClickCallBack(function(selfGrid) + self:HandlePluginClicked(selfGrid:GetPlugin(), selfGrid) + end) + end +end + +function XUiRoleLevelUpPanel:HandlePluginClicked(plugin, grid, selectStatus, isShowMaxLevelTip) + if isShowMaxLevelTip == nil then isShowMaxLevelTip = true end + if selectStatus == nil then selectStatus = not self:GetPluginSelectStatus(plugin) end + -- 检查是否超过最大等级 + if selectStatus then + if self.CurrentLevel >= self.SuperTowerRole:GetMaxSuperLevel() then + if isShowMaxLevelTip then + XUiManager.TipError(XUiHelper.GetText("STTransfiniteMaxLevel")) + end + return false + end + end + local pluginId = plugin:GetId() + -- 设置选中状态 + if grid then + grid:SetActiveStatus(selectStatus) + end + -- 已经是选中的状态,不需要处理 + if selectStatus == self:GetPluginSelectStatus(plugin) then + return true + end + local addExp = 0 + if selectStatus then + addExp = plugin:GetExp() + else + addExp = plugin:GetExp() * -1 + end + self.TotalAddExp = self.TotalAddExp + addExp + local nextLevelExp = self.SuperTowerRole:GetMaxExp(self.CurrentLevel) + self.CurrentBarExp = self.CurrentBarExp + addExp + -- 升级 + if self.CurrentBarExp >= nextLevelExp then + self.CurrentLevel = self.CurrentLevel + 1 + self.CurrentBarExp = self.CurrentBarExp - nextLevelExp + -- 降级 + elseif self.CurrentBarExp < 0 then + self.CurrentLevel = self.CurrentLevel - 1 + self.CurrentBarExp = self.CurrentBarExp + self.SuperTowerRole:GetMaxExp(self.CurrentLevel) + end + self.TxtAddExp.text = self.TotalAddExp + if self.CurrentLevel > self.SuperTowerRole:GetSuperLevel() then + self.ImgExpAddBar.fillAmount = 1 + else + self.ImgExpAddBar.fillAmount = self.CurrentBarExp / self.SuperTowerRole:GetMaxExp(self.CurrentLevel) + end + self.TxtLevelInfo.text = string.format("%s/%s", self.CurrentLevel, self.SuperTowerRole:GetMaxSuperLevel()) + self.TxtExpCompare.text = string.format("%s/%s", self.CurrentBarExp, self.SuperTowerRole:GetMaxExp(self.CurrentLevel)) + self.PluginGridSelectStatusDic[plugin] = selectStatus + return true +end + +function XUiRoleLevelUpPanel:OnBtnGetPluginsClicked() + local skipIds = {} + local index = 1 + local skipId = XSuperTowerConfigs.GetClientBaseConfigByKey("GetPluginSkipId" .. index) + while skipId ~= nil do + table.insert(skipIds, skipId) + index = index + 1 + skipId = XSuperTowerConfigs.GetClientBaseConfigByKey("GetPluginSkipId" .. index, true) + end + XLuaUiManager.Open("UiSkipTip", skipIds) +end + +function XUiRoleLevelUpPanel:OnBtnUpgradeClicked() + local curLevel = self.SuperTowerRole:GetSuperLevel() + local usedSuperPluginDic = {} + local pluginId + local showTip = false + local star = XSuperTowerConfigs.GetClientBaseConfigByKey("RoleLevelUpPluginStarLevel") or 5 + for plugin, status in pairs(self.PluginGridSelectStatusDic) do + if status then + pluginId = plugin:GetId() + usedSuperPluginDic[pluginId] = usedSuperPluginDic[pluginId] or 0 + usedSuperPluginDic[pluginId] = usedSuperPluginDic[pluginId] + 1 + if plugin:GetStar() >= star and not showTip then + showTip = true + end + end + end + local okCallback = function() + if XTool.IsTableEmpty(usedSuperPluginDic) then + XUiManager.TipError(CS.XTextManager.GetText("STRoleLevelUpNotPluginTip")) + return + end + XDataCenter.SuperTowerManager.GetRoleManager():RequestUpgradeCharacter(self.SuperTowerRole:GetCharacterId(), usedSuperPluginDic + , function() + if curLevel ~= self.SuperTowerRole:GetSuperLevel() then + XLuaUiManager.Open("UiSupertowerExpansion", self.SuperTowerRole:GetId(), curLevel, self.SuperTowerRole:GetSuperLevel()) + end + -- 刷新下页面 + self:Reset() + end) + end + -- 判断是否含有5星以上的插件 + if showTip then + local content = CS.XTextManager.GetText("ExpeditionFireConfirmContent") + CsXUiManager.Instance:Open("UiDialog", CS.XTextManager.GetText("TipTitle") + , CS.XTextManager.GetText("STRoleLevelUpUsePluginTip", star) + , XUiManager.DialogType.Normal, nil, okCallback) + else + okCallback() + end +end + +function XUiRoleLevelUpPanel:ResetBaseInfo() + -- 超限信息 + local currentExp = self.SuperTowerRole:GetCurrentExp() + local maxExp = self.SuperTowerRole:GetMaxExp() + self.TxtLevelInfo.text = string.format("%s/%s" + , self.SuperTowerRole:GetSuperLevel(), self.SuperTowerRole:GetMaxSuperLevel()) + self.TxtExpCompare.text = string.format("%s/%s", currentExp, maxExp) + self.ImgExpBar.fillAmount = currentExp / maxExp + self.TxtAddExp.text = 0 + self.ImgExpAddBar.fillAmount = self.ImgExpBar.fillAmount + -- 背包插件 + self:RefreshPlugins() +end + +function XUiRoleLevelUpPanel:OnBtnAutoSelectClicked() + for i = AUTO_SELECT_MIN_STAR, AUTO_SELECT_MAX_STAR do + self:OnBtnTogStarValueChanged(i, true) + end +end + +function XUiRoleLevelUpPanel:AutoSelectPlugin(plugins, isSelect) + for i, plugin in ipairs(plugins) do + if not self:HandlePluginClicked(plugin, nil, isSelect, false) then + break + end + end + local plugin + for _, grid in pairs(self.DynamicTable:GetGrids()) do + plugin = grid:GetPlugin() + grid:SetActiveStatus(self.PluginGridSelectStatusDic[plugin] or false) + end +end + +function XUiRoleLevelUpPanel:GetPluginSelectStatus(plugin) + if self.PluginGridSelectStatusDic[plugin] == nil then + self.PluginGridSelectStatusDic[plugin] = false + end + return self.PluginGridSelectStatusDic[plugin] +end + +return XUiRoleLevelUpPanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Role/XUiSuperTowerRoleDetail.lua b/Resources/Scripts/XUi/XUiSuperTower/Role/XUiSuperTowerRoleDetail.lua new file mode 100644 index 00000000..cbb49c56 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Role/XUiSuperTowerRoleDetail.lua @@ -0,0 +1,410 @@ +local CsXTextManager = CS.XTextManager +local XUiSuperTowerRoleGrid = require("XUi/XUiSuperTower/Role/XUiSuperTowerRoleGrid") +local XUiSuperTowerRoleLevelUpPanel = require("XUi/XUiSuperTower/Role/XUiSuperTowerRoleLevelUpPanel") +local XUiSTFunctionButton = require("XUi/XUiSuperTower/Common/XUiSTFunctionButton") + +--######################## XUiSuperTowerRoleDetail ######################## + +local XUiSuperTowerRoleDetail = XLuaUiManager.Register(XLuaUi, "UiSuperTowerRoleOverrun") + +local CHILD_PANEL_TYPE = { + Default = 1, + Level = 2 +} + +function XUiSuperTowerRoleDetail:OnAwake() + self.CurrentListRoles = nil + self.CurrentRoleId = nil + self.CurrentPanelType = CHILD_PANEL_TYPE.Default + self.CurrentCharacterType = XCharacterConfigs.CharacterType.Normal + self.CurrentIsAscendOrder = true + self.CurrentSortTagType = XRoomCharFilterTipsConfigs.EnumSortTag.Default + self.CurrentSelectTagGroup = { + [XCharacterConfigs.CharacterType.Normal] = {}, + [XCharacterConfigs.CharacterType.Isomer] = {}, + } + -- XUiSuperTowerRoleLevelUpPanel + self.UiRoleLevelUpPanel = nil + -- 角色列表 + self.DynamicTable = XDynamicTableNormal.New(self.SViewCharacterList) + self.DynamicTable:SetProxy(XUiSuperTowerRoleGrid) + self.DynamicTable:SetDelegate(self) + self.GridCharacter.gameObject:SetActiveEx(false) + -- 模型相关 + local root = self.UiModelGo.transform + local panelRoleModel = root:FindTransform("PanelRoleModel") + -- XCharacterConfigs.XUiCharacter_Camera.MAIN + self.CameraFar = { + root:FindTransform("CamFarMain"), + root:FindTransform("UiCamFarLv"), + } + self.CameraNear = { + root:FindTransform("CamNearMain"), + root:FindTransform("UiCamNearLv"), + } + -- 子面板信息配置 + self.ChillPanelInfoDic = { + [CHILD_PANEL_TYPE.Level] = { + uiParent = self.PanelLevelChid, + assetPath = XUiConfigs.GetComponentUrl("UiPanelSuperTowerChip"), + proxy = XUiSuperTowerRoleLevelUpPanel, + -- 代理设置参数 + proxyArgs = { + "CurrentRoleId", + } + }, + } + self.ImgEffectHuanren = root:FindTransform("ImgEffectHuanren") + self.ImgEffectHuanren1 = root:FindTransform("ImgEffectHuanren1") + self.UiPanelRoleModel = XUiPanelRoleModel.New(panelRoleModel, self.Name, nil, true, nil, true) + self:RegisterUiEvents() + self.BtnTabShougezhe:SetDisable(not XFunctionManager.JudgeOpen(XFunctionManager.FunctionName.Isomer)) + local itemIds = XSuperTowerConfigs.GetMainAssetsPanelItemIds() + self.AssetActivityPanel = XUiPanelActivityAsset.New(self.PanelSpecialTool) + XDataCenter.ItemManager.AddCountUpdateListener(itemIds, function() + self.AssetActivityPanel:Refresh(itemIds) + end, self.AssetActivityPanel) + self.AssetActivityPanel:Refresh(itemIds) + -- XUiPanelAsset.New(self, self.PanelAsset, XDataCenter.ItemManager.ItemId.FreeGem + -- , XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) +end + +-- currentRoleId : 默认显示的角色Id +function XUiSuperTowerRoleDetail:OnStart(currentRoleId) + self.CurrentRoleId = currentRoleId + -- 刷新列表 + self.BtnGroupCharacterType:SelectIndex(XCharacterConfigs.CharacterType.Normal) + self.BtnUpSort.gameObject:SetActiveEx(not self.CurrentIsAscendOrder) + self.BtnDownSort.gameObject:SetActiveEx(self.CurrentIsAscendOrder) + self:SetCameraType(CHILD_PANEL_TYPE.Default) + XRedPointManager.CheckOnceByButton(self.BtnSpecial, { XRedPointConditions.Types.CONDITION_SUPERTOWER_ROLE_INDULT }) + -- 自动关闭 + local endTime = XDataCenter.SuperTowerManager.GetActivityEndTime() + self:SetAutoCloseInfo(endTime, function(isClose) + if isClose then + XLuaUiManager.Close("UiSuperTowerTedianUP") + XDataCenter.SuperTowerManager.HandleActivityEndTime() + end + end) +end + +--######################## 私有方法 ######################## + +function XUiSuperTowerRoleDetail:RegisterUiEvents() + local superTowerManager = XDataCenter.SuperTowerManager + self.BtnBack.CallBack = function() self:OnBtnBackClicked() end + self.BtnMainUi.CallBack = function() XLuaUiManager.RunMain() end + self.BtnCareerTips.CallBack = function() XLuaUiManager.Open("UiCharacterCarerrTips") end + self.BtnPluginUnlock.CallBack = function() self:OnBtnPluginUnlockClicked() end + self.BtnFilter.CallBack = function() self:OnBtnFilterClicked() end + self.BtnDownSort.CallBack = function() self:OnBtnDownSortClicked() end + self.BtnUpSort.CallBack = function() self:OnBtnUpSortClicked() end + -- self.BtnSpecial.CallBack = function() self:OnBtnSpecialClicked() end + XUiSTFunctionButton.New(self.BtnSpecial, function() self:OnBtnSpecialClicked() end, superTowerManager.FunctionName.BonusChara) + -- self.BtnLevelUp.CallBack = function() self:OnBtnLevelUpClicked() end + XUiSTFunctionButton.New(self.BtnLevelUp, function() self:OnBtnLevelUpClicked() end, superTowerManager.FunctionName.Transfinite) + XUiSTFunctionButton.New(self.BtnUnlockPluginMask, nil, superTowerManager.FunctionName.Exclusive) + self.BtnElementDetail.CallBack = function() self:OnBtnElementDetailClicked() end + -- 角色类型按钮组 + self.BtnGroupCharacterType:Init({ + [XCharacterConfigs.CharacterType.Normal] = self.BtnTabGouzaoti, + [XCharacterConfigs.CharacterType.Isomer] = self.BtnTabShougezhe + }, function(tabIndex) self:OnBtnGroupCharacterTypeClicked(tabIndex) end) + self:BindHelpBtn(self.BtnHelp, "SuperTowerCharaHelp") + self.BtnPluginClick.CallBack = function() self:OnBtnPluginClicked() end +end + +function XUiSuperTowerRoleDetail:OnBtnPluginClicked() + local superTowerRole = XDataCenter.SuperTowerManager.GetRoleManager():GetRole(self.CurrentRoleId) + XLuaUiManager.Open("UiSuperTowerPluginDetails", superTowerRole:GetTransfinitePlugin()) +end + +function XUiSuperTowerRoleDetail:OnBtnElementDetailClicked() + XLuaUiManager.Open("UiCharacterElementDetail", XEntityHelper.GetCharacterIdByEntityId(self.CurrentRoleId)) +end + +function XUiSuperTowerRoleDetail:OnBtnBackClicked() + if self.CurrentPanelType ~= CHILD_PANEL_TYPE.Default then + self:OpenChildPanel(CHILD_PANEL_TYPE.Default) + else + self:Close() + end +end + +function XUiSuperTowerRoleDetail:OnBtnLevelUpClicked() + local superTowerRole = XDataCenter.SuperTowerManager.GetRoleManager():GetRole(self.CurrentRoleId) + if superTowerRole:GetSuperLevel() >= superTowerRole:GetMaxSuperLevel() then + XUiManager.TipError(XUiHelper.GetText("STTransfiniteMaxLevel")) + return + end + self:SetChildGosActive(false) + self:OpenChildPanel(CHILD_PANEL_TYPE.Level) +end + +function XUiSuperTowerRoleDetail:SetChildGosActive(value) + self.PanelRoleOverrun.gameObject:SetActiveEx(value) +end + +function XUiSuperTowerRoleDetail:OnBtnSpecialClicked() + XLuaUiManager.Open("UiSuperTowerTedianUP") + XRedPointManager.CheckOnceByButton(self.BtnSpecial, { XRedPointConditions.Types.CONDITION_SUPERTOWER_ROLE_INDULT }) +end + +function XUiSuperTowerRoleDetail:OnBtnDownSortClicked() + self.BtnDownSort.gameObject:SetActiveEx(false) + self.BtnUpSort.gameObject:SetActiveEx(true) + self.CurrentIsAscendOrder = false + local roleManager = XDataCenter.SuperTowerManager.GetRoleManager() + self.CurrentListRoles = roleManager:SortRoles(self.CurrentListRoles, self.CurrentSortTagType, self.CurrentIsAscendOrder) + self.CurrentRoleId = nil + self:RefreshCharacterList(self.CurrentListRoles) +end + +function XUiSuperTowerRoleDetail:OnBtnUpSortClicked() + self.BtnUpSort.gameObject:SetActiveEx(false) + self.BtnDownSort.gameObject:SetActiveEx(true) + self.CurrentIsAscendOrder = true + local roleManager = XDataCenter.SuperTowerManager.GetRoleManager() + self.CurrentListRoles = roleManager:SortRoles(self.CurrentListRoles, self.CurrentSortTagType, self.CurrentIsAscendOrder) + self.CurrentRoleId = nil + self:RefreshCharacterList(self.CurrentListRoles) +end + +function XUiSuperTowerRoleDetail:OnBtnFilterClicked() + local superTowerManager = XDataCenter.SuperTowerManager + local isOpen = superTowerManager.CheckFunctionUnlockByKey(superTowerManager.FunctionName.Transfinite) + XLuaUiManager.Open("UiRoomCharacterFilterTips", self, + XRoomCharFilterTipsConfigs.EnumFilterType.SuperTower, + XRoomCharFilterTipsConfigs.EnumSortType.SuperTower, + self.CurrentCharacterType, nil, nil, + { [XRoomCharFilterTipsConfigs.EnumSortTag.SuperLevel] = not isOpen }) +end + +function XUiSuperTowerRoleDetail:Filter(selectTagGroupDic, sortTagId, isThereFilterDataCb) + local roleManager = XDataCenter.SuperTowerManager.GetRoleManager() + if self.TagCacheDic == nil then self.TagCacheDic = {} end + XDataCenter.RoomCharFilterTipsManager.Filter(self.TagCacheDic, selectTagGroupDic + , roleManager:GetCanFightRoles(self.CurrentCharacterType) + , roleManager:GetFilterJudge() + , function(filteredData) + self.CurrentSelectTagGroup[self.CurrentCharacterType].TagGroupDic = selectTagGroupDic + self.CurrentSelectTagGroup[self.CurrentCharacterType].SortType = sortTagId + self:FilterRefresh(filteredData, sortTagId) + end + , isThereFilterDataCb) +end + +function XUiSuperTowerRoleDetail:FilterRefresh(filteredData, sortTagType) + local roleManager = XDataCenter.SuperTowerManager.GetRoleManager() + filteredData = XDataCenter.SuperTowerManager.GetRoleManager():SortRoles(filteredData, sortTagType, self.CurrentIsAscendOrder) + self.CurrentRoleId = nil + self:RefreshCharacterList(filteredData) +end + +function XUiSuperTowerRoleDetail:OnBtnPluginUnlockClicked() + local roleManager = XDataCenter.SuperTowerManager.GetRoleManager() + local role = roleManager:GetRole(self.CurrentRoleId) + local plugin = role:GetTransfinitePlugin() + -- 检查是否有足够的插件 + if not XDataCenter.SuperTowerManager.GetBagManager():GetIsHaveData(plugin:GetId()) then + XUiManager.TipError(CS.XTextManager.GetText("STPluginCountNotEnough")) + return false + end + local okCallback = function() + roleManager:RequestMountPlugin(role:GetCharacterId(), plugin:GetId(), function() + self:RefreshPluginInfo(role) + self.DynamicTable:ReloadDataSync(nil, false) + XLuaUiManager.Open("UiSuperTowerUnlocking", role) + end) + end + CsXUiManager.Instance:Open("UiDialog", CS.XTextManager.GetText("TipTitle") + , CS.XTextManager.GetText("STPluginUnlockTipContent", plugin:GetName() .. " " .. plugin:GetStar(), role:GetCharacterViewModel():GetTradeName()) + , XUiManager.DialogType.Normal, nil, okCallback) +end + +function XUiSuperTowerRoleDetail:OnBtnGroupCharacterTypeClicked(index) + if index == XCharacterConfigs.CharacterType.Isomer + and not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.Isomer) then + return + end + self.CurrentCharacterType = index + local selectTagGroupDic = self.CurrentSelectTagGroup[index].TagGroupDic or {} + local sortTagId = self.CurrentSelectTagGroup[index].SortType or XRoomCharFilterTipsConfigs.EnumSortTag.Default + local roles = XDataCenter.SuperTowerManager.GetRoleManager():GetCanFightRoles(self.CurrentCharacterType) + if #roles <= 0 then + XUiManager.TipError(XUiHelper.GetText("IsomerLimitTip")) + self.BtnGroupCharacterType:SelectIndex(XCharacterConfigs.CharacterType.Normal) + return + end + self:Filter(selectTagGroupDic, sortTagId, function(roles) + if #roles <= 0 then + XUiManager.TipError(XUiHelper.GetText("IsomerLimitTip")) + self.BtnGroupCharacterType:SelectIndex(XCharacterConfigs.CharacterType.Normal) + return false + end + return true + end) +end + +-- characterType : XCharacterConfigs.CharacterType +function XUiSuperTowerRoleDetail:RefreshCharacterList(roles) + local index = 1 + for i, value in ipairs(roles) do + if self.CurrentRoleId == value:GetId() then + index = i + end + end + self.CurrentRoleId = roles[index]:GetId() + self.CurrentListRoles = roles + self.DynamicTable:SetDataSource(roles) + self.DynamicTable:ReloadDataSync(index) + -- 刷新基本信息 + self:RefreshCharacterInfo(roles[index]) +end + +function XUiSuperTowerRoleDetail:OnDynamicTableEvent(event, index, grid) + local data = self.CurrentListRoles[index] + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:SetData(data) + grid:SetSelectStatus(self.CurrentRoleId == data:GetId()) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + self.CurrentRoleId = data:GetId() + for _, tmpGrid in pairs(self.DynamicTable:GetGrids()) do + tmpGrid:SetSelectStatus(false) + end + grid:SetSelectStatus(true) + -- 刷新基本信息 + self:RefreshCharacterInfo(data) + end +end + +function XUiSuperTowerRoleDetail:RefreshCharacterInfo(superTowerRole) + local characterViewModel = superTowerRole:GetCharacterViewModel() + local roleId = superTowerRole:GetId() + -- 模型 + self.ImgEffectHuanren.gameObject:SetActiveEx(false) + self.ImgEffectHuanren1.gameObject:SetActiveEx(false) + local finishedCallback = function(model) + self.PanelDrag.Target = model.transform + self.PanelDrag2.Target = model.transform + self.ImgEffectHuanren.gameObject:SetActiveEx(self.CurrentCharacterType == XCharacterConfigs.CharacterType.Normal) + self.ImgEffectHuanren1.gameObject:SetActiveEx(self.CurrentCharacterType == XCharacterConfigs.CharacterType.Isomer) + end + if XRobotManager.CheckIsRobotId(roleId) then + local robotConfig = XRobotManager.GetRobotTemplate(roleId) + self.UiPanelRoleModel:UpdateRobotModel(roleId, robotConfig.CharacterId + , nil, robotConfig.FashionId, robotConfig.WeaponId, finishedCallback) + else + self.UiPanelRoleModel:UpdateCharacterModel(roleId, nil, nil, finishedCallback, nil, characterViewModel:GetFashionId()) + end + -- 头部基本信息 + self.RImgTypeIcon:SetRawImage(characterViewModel:GetProfessionIcon()) + self.TxtName.text = characterViewModel:GetName() + self.TxtNameOther.text = characterViewModel:GetTradeName() + self.TxtFightPower.text = superTowerRole:GetAbility() + local obtainElementIcons = characterViewModel:GetObtainElementIcons() + local obtainElementIcon + for i = 1, 3 do + obtainElementIcon = obtainElementIcons[i] + self["RImgCharElement" .. i].gameObject:SetActiveEx(obtainElementIcon ~= nil) + if obtainElementIcon then + self["RImgCharElement" .. i]:SetRawImage(obtainElementIcon) + end + end + -- 超限信息 + local currentExp = superTowerRole:GetCurrentExp() + local maxExp = superTowerRole:GetMaxExp() + local currentLevel = superTowerRole:GetSuperLevel() + local maxLevel = superTowerRole:GetMaxSuperLevel() + if currentLevel >= maxLevel then + currentLevel = maxLevel + currentExp = maxExp + end + self.TxtRoleLevelInfo.text = string.format("%s/%s", currentLevel, maxLevel) + self.TxtExpInfo.text = string.format("%s/%s", currentExp, maxExp) + self.ImgExpBar.fillAmount = currentExp / maxExp + -- 属性信息 + local attributeDic = characterViewModel:GetAttributes(superTowerRole:GetEquipViewModels()) + self.TxtLife.text = FixToInt(attributeDic[XNpcAttribType.Life]) + superTowerRole:GetAttributeValue(XNpcAttribType.Life) + self.TxtAttack.text = FixToInt(attributeDic[XNpcAttribType.AttackNormal]) + superTowerRole:GetAttributeValue(XNpcAttribType.AttackNormal) + self.TxtDefense.text = FixToInt(attributeDic[XNpcAttribType.DefenseNormal]) + superTowerRole:GetAttributeValue(XNpcAttribType.DefenseNormal) + self.TxtCrit.text = FixToInt(attributeDic[XNpcAttribType.Crit]) + superTowerRole:GetAttributeValue(XNpcAttribType.Crit) + -- 专属插件 + local plugin = superTowerRole:GetTransfinitePlugin() + self.TxtPluginName.text = superTowerRole:GetTransfinitePluginName() --plugin:GetName() + self.TxtPluginDes.text = superTowerRole:GetTransfinitePluginDesc() + self.RImgPluginIcon:SetRawImage(plugin:GetIcon()) + self.ImgPluginQuality:SetSprite(plugin:GetQualityIcon()) + self.TxtLockPluginName.text = plugin:GetName() + self:RefreshPluginInfo(superTowerRole) + -- 超限按钮状态 + self.BtnLevelUp:SetDisable(currentLevel >= maxLevel) + XRedPointManager.CheckOnceByButton(self.BtnLevelUp, { XRedPointConditions.Types.CONDITION_SUPERTOWER_ROLE_LEVELUP }, roleId) + XRedPointManager.CheckOnceByButton(self.BtnPluginUnlock, { XRedPointConditions.Types.CONDITION_SUPERTOWER_ROLE_PLUGIN }, roleId) + self.DynamicTable:ReloadDataSync(nil, false) +end + +function XUiSuperTowerRoleDetail:RefreshPluginInfo(superTowerRole) + local isActive = superTowerRole:GetTransfinitePluginIsActive() + -- 通过特权解锁来决定 + local isUnlock = XDataCenter.SuperTowerManager.CheckFunctionUnlockByKey(XDataCenter.SuperTowerManager.FunctionName.Exclusive) + self.BtnPluginUnlock.gameObject:SetActiveEx(isUnlock and not isActive) + self.PanelPluginLock.gameObject:SetActiveEx(not isUnlock) + self.ImgNormalLock.gameObject:SetActiveEx(isUnlock and not isActive) + self.TxtPluginActive.gameObject:SetActiveEx(isUnlock and isActive) + local hasPlugin = XDataCenter.SuperTowerManager.GetBagManager():GetIsHaveData(superTowerRole:GetTransfinitePluginId()) + self.UnlockPluginEffect.gameObject:SetActiveEx(isUnlock and not isActive and hasPlugin) +end + +function XUiSuperTowerRoleDetail:OpenChildPanel(index) + self:SetChildGosActive(index == CHILD_PANEL_TYPE.Default) + self.PanelDrag.gameObject:SetActiveEx(index == CHILD_PANEL_TYPE.Default) + self.PanelDrag2.gameObject:SetActiveEx(index == CHILD_PANEL_TYPE.Level) + if index == CHILD_PANEL_TYPE.Default then + self.CurrentPanelType = index + self:RefreshCharacterInfo(XDataCenter.SuperTowerManager.GetRoleManager():GetRole(self.CurrentRoleId)) + end + -- 显示/隐藏关联子面板 + for key, data in pairs(self.ChillPanelInfoDic) do + data.uiParent.gameObject:SetActiveEx(key == index) + end + local childPanelData = self.ChillPanelInfoDic[index] + self:SetCameraType(index) + if not childPanelData then return end + self.CurrentPanelType = index + -- 加载panel asset + local instanceGo = childPanelData.instanceGo + if instanceGo == nil then + instanceGo = childPanelData.uiParent:LoadPrefab(childPanelData.assetPath) + childPanelData.instanceGo = instanceGo + end + -- 加载panel proxy + local instanceProxy = childPanelData.instanceProxy + if instanceProxy == nil then + instanceProxy = childPanelData.proxy.New(instanceGo) + childPanelData.instanceProxy = instanceProxy + end + -- 加载proxy参数 + local proxyArgs = {} + if childPanelData.proxyArgs then + for _, argName in ipairs(childPanelData.proxyArgs) do + if type(argName) == "string" then + proxyArgs[#proxyArgs + 1] = self[argName] + else + proxyArgs[#proxyArgs + 1] = argName + end + end + end + instanceProxy:SetData(table.unpack(proxyArgs)) +end + +function XUiSuperTowerRoleDetail:SetCameraType(index) + for k, _ in pairs(self.CameraFar) do + self.CameraFar[k].gameObject:SetActiveEx(k == index) + end + for k, _ in pairs(self.CameraNear) do + self.CameraNear[k].gameObject:SetActiveEx(k == index) + end +end + +return XUiSuperTowerRoleDetail \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Role/XUiSuperTowerRoleGrid.lua b/Resources/Scripts/XUi/XUiSuperTower/Role/XUiSuperTowerRoleGrid.lua new file mode 100644 index 00000000..e6b4ed82 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Role/XUiSuperTowerRoleGrid.lua @@ -0,0 +1,53 @@ +local CsXTextManager = CS.XTextManager + +--######################## UiSuperTowerRoleGrid ######################## +local XUiSuperTowerRoleGrid = XClass(nil, "XUiSuperTowerRoleGrid") + +function XUiSuperTowerRoleGrid:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + -- XSuperTowerRole + self.SuperTowerRole = nil +end + +-- superTowerRole : XSuperTowerRole +function XUiSuperTowerRoleGrid:SetData(superTowerRole) + local superTowerManager = XDataCenter.SuperTowerManager + self.SuperTowerRole = superTowerRole + local characterViewModel = superTowerRole:GetCharacterViewModel() + self.RImgHeadIcon:SetRawImage(characterViewModel:GetSmallHeadIcon()) + self.TxtPower.text = superTowerRole:GetAbility() + self.TxtLevel.text = characterViewModel:GetLevel() + self.RImgQuality:SetRawImage(characterViewModel:GetQualityIcon()) + -- 超限 + self.TxtSuperLevel.text = superTowerRole:GetSuperLevel() + local isOpenTransfinite = superTowerManager.CheckFunctionUnlockByKey(superTowerManager.FunctionName.Transfinite) + self.PanelSuperLevel.gameObject:SetActiveEx(isOpenTransfinite) + -- 试玩 + self.PanelSw.gameObject:SetActiveEx(superTowerRole:GetIsRobot()) + -- 特典 + local isOpenBonusChara = superTowerManager.CheckFunctionUnlockByKey(superTowerManager.FunctionName.BonusChara) + self.PanalTedianyq.gameObject:SetActiveEx(isOpenBonusChara and superTowerRole:GetIsInDult()) + -- 小红点 + self.ImgRedPoint.gameObject:SetActiveEx( + superTowerManager.GetRoleManager():CheckRoleShowRedDot(superTowerRole:GetId())) + -- 是否在队伍中, 不会有这种情况,暂时保留 + self.ImgInTeam.gameObject:SetActiveEx(false) + -- 元素图标 + local obtainElementIcons = characterViewModel:GetObtainElementIcons() + local elementIcon + for i = 1, 2 do + elementIcon = obtainElementIcons[i] + self["RImgElement" .. i].gameObject:SetActiveEx(elementIcon ~= nil) + if elementIcon then + self["RImgElement" .. i]:SetRawImage(elementIcon) + end + end +end + +function XUiSuperTowerRoleGrid:SetSelectStatus(value) + self.PanelSelected.gameObject:SetActiveEx(value) +end + +return XUiSuperTowerRoleGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Role/XUiSuperTowerRoleLevelUpPanel.lua b/Resources/Scripts/XUi/XUiSuperTower/Role/XUiSuperTowerRoleLevelUpPanel.lua new file mode 100644 index 00000000..3f926bc9 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Role/XUiSuperTowerRoleLevelUpPanel.lua @@ -0,0 +1,263 @@ +local XUiSuperTowerPluginGrid = require("XUi/XUiSuperTower/Plugins/XUiSuperTowerPluginGrid") + +local XUiSuperTowerRoleLevelUpPanel = XClass(nil, "XUiSuperTowerRoleLevelUpPanel") + +local AUTO_SELECT_MIN_STAR = 2 +local AUTO_SELECT_MAX_STAR = 4 + +function XUiSuperTowerRoleLevelUpPanel:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + -- XSuperTowerRole + self.SuperTowerRole = nil + -- XSuperPlugin Dic + self.UsedSuperPluginDic = nil + -- 插件选择状态 + self.PluginGridSelectStatusDic = nil + -- 插件筛选星级状态 + self.PluginStarSelectStatusDic = nil + -- 插件列表 + self.DynamicTable = XDynamicTableNormal.New(self.PanelEquipScroll) + self.DynamicTable:SetProxy(XUiSuperTowerPluginGrid) + self.DynamicTable:SetDelegate(self) + self.GridCore.gameObject:SetActiveEx(false) + self.CurrentPlugins = nil + self.ImgAscend.gameObject:SetActiveEx(true) + self.ImgDescend.gameObject:SetActiveEx(false) + self:RegisterUiEvents() +end + +-- superTowerRole : XSuperTowerRole +function XUiSuperTowerRoleLevelUpPanel:SetData(superTowerRoleId) + self.GameObject:SetActiveEx(true) + self.SuperTowerRole = XDataCenter.SuperTowerManager.GetRoleManager():GetRole(superTowerRoleId) + self:Reset() +end + +--######################## 私有方法 ######################## + +function XUiSuperTowerRoleLevelUpPanel:Reset() + self.PluginStarSelectStatusDic = { + [2] = false, + [3] = false, + [4] = false, + } + self.UsedSuperPluginDic = {} + self.PluginGridSelectStatusDic = {} + self.TotalAddExp = 0 + -- 初始化toggle的状态 + for k, v in pairs(self.PluginStarSelectStatusDic) do + self["TogStar" .. k].isOn = v + end + self:ResetBaseInfo() +end + +function XUiSuperTowerRoleLevelUpPanel:RegisterUiEvents() + self.BtnGetPlugins.CallBack = function() self:OnBtnGetPluginsClicked() end + self.BtnUpgrade.CallBack = function() self:OnBtnUpgradeClicked() end + self.BtnAutoSelect.CallBack = function() self:OnBtnAutoSelectClicked() end + self.BtnStar4.CallBack = function() self:OnBtnTogStarValueChanged(4) end + self.BtnStar3.CallBack = function() self:OnBtnTogStarValueChanged(3) end + self.BtnStar2.CallBack = function() self:OnBtnTogStarValueChanged(2) end + self.BtnOrder.CallBack = function() self:OnBtnOrderClicked() end +end + +function XUiSuperTowerRoleLevelUpPanel:OnBtnOrderClicked() + local isAscend = self.ImgAscend.gameObject.activeSelf + self.ImgAscend.gameObject:SetActiveEx(not isAscend) + self.ImgDescend.gameObject:SetActiveEx(isAscend) + self:Reset() +end + +function XUiSuperTowerRoleLevelUpPanel:OnBtnTogStarValueChanged(star, isOn) + if isOn == self["TogStar" .. star].isOn then + return + end + if isOn == nil then isOn = not self["TogStar" .. star].isOn end + -- 设置toggle状态 + -- isOn为true时检查是否超过最大等级 + if isOn and self.SuperTowerRole:GetSuperLevel() >= self.SuperTowerRole:GetMaxSuperLevel() then + XUiManager.TipError(XUiHelper.GetText("STTransfiniteMaxLevel")) + self["TogStar" .. star].isOn = false + return + end + self["TogStar" .. star].isOn = isOn + self.PluginStarSelectStatusDic[star] = isOn + -- 找到相同星级的做点击或取消点击的处理 + local plugins = {} + for _, plugin in ipairs(self.CurrentPlugins) do + if star == plugin:GetStar() then + table.insert(plugins, plugin) + end + end + self:AutoSelectPlugin(plugins, isOn) +end + +function XUiSuperTowerRoleLevelUpPanel:RefreshPlugins() + self.CurrentPlugins = XDataCenter.SuperTowerManager.GetBagManager():GetPlugins(not self.ImgAscend.gameObject.activeSelf) + self.DynamicTable:SetDataSource(self.CurrentPlugins) + self.DynamicTable:ReloadDataSync(1) +end + +function XUiSuperTowerRoleLevelUpPanel:OnDynamicTableEvent(event, index, grid) + if index <= 0 or index > #self.DynamicTable.DataSource then return end + local data = self.DynamicTable.DataSource[index] + local pluginId = data:GetId() + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:RefreshData(data) + grid:SetActiveStatus(self:GetPluginSelectStatus(data)) + grid:SetClickCallBack(function(selfGrid) + self:HandlePluginClicked(selfGrid:GetPlugin(), selfGrid) + end) + end +end + +function XUiSuperTowerRoleLevelUpPanel:HandlePluginClicked(plugin, grid, selectStatus, isShowMaxLevelTip) + if isShowMaxLevelTip == nil then isShowMaxLevelTip = true end + if selectStatus == nil then selectStatus = not self:GetPluginSelectStatus(plugin) end + -- 检查是否超过最大等级 + if selectStatus then + local showLevel = tonumber(string.Split(self.TxtLevelInfo.text, '/')[1]) + if showLevel >= self.SuperTowerRole:GetMaxSuperLevel() then + if isShowMaxLevelTip then + XUiManager.TipError(XUiHelper.GetText("STTransfiniteMaxLevel")) + end + return false + end + end + local pluginId = plugin:GetId() + -- 设置选中状态 + if grid then + grid:SetActiveStatus(selectStatus) + end + -- 已经是选中的状态,不需要处理 + if selectStatus == self:GetPluginSelectStatus(plugin) then + return true + end + local addExp = 0 + if selectStatus then + addExp = plugin:GetExp() + else + addExp = plugin:GetExp() * -1 + end + self.PluginGridSelectStatusDic[plugin] = selectStatus + self.TotalAddExp = self.TotalAddExp + addExp + local currentExp = self.SuperTowerRole:GetCurrentExp() + local currentLevel = self.SuperTowerRole:GetSuperLevel() + local nextLevelExp = self.SuperTowerRole:GetMaxExp(currentLevel) + local newCurrentExp = currentExp + self.TotalAddExp + while newCurrentExp >= nextLevelExp do + newCurrentExp = newCurrentExp - nextLevelExp + currentLevel = currentLevel + 1 + nextLevelExp = self.SuperTowerRole:GetMaxExp(currentLevel) + end + self.TxtAddExp.text = self.TotalAddExp + if currentLevel > self.SuperTowerRole:GetSuperLevel() then + self.ImgExpAddBar.fillAmount = 1 + else + self.ImgExpAddBar.fillAmount = newCurrentExp / nextLevelExp + end + self.TxtLevelInfo.text = string.format("%s/%s", currentLevel, self.SuperTowerRole:GetMaxSuperLevel()) + self.TxtExpCompare.text = string.format("%s/%s", newCurrentExp, nextLevelExp) + return true +end + +function XUiSuperTowerRoleLevelUpPanel:OnBtnGetPluginsClicked() + local skipIds = {} + local index = 1 + local skipId = XSuperTowerConfigs.GetClientBaseConfigByKey("GetPluginSkipId" .. index) + while skipId ~= nil do + table.insert(skipIds, skipId) + index = index + 1 + skipId = XSuperTowerConfigs.GetClientBaseConfigByKey("GetPluginSkipId" .. index, true) + end + XLuaUiManager.Open("UiSkipTip", skipIds) +end + +function XUiSuperTowerRoleLevelUpPanel:OnBtnUpgradeClicked() + local curLevel = self.SuperTowerRole:GetSuperLevel() + local usedSuperPluginDic = {} + local pluginId + local showTip = false + local star = XSuperTowerConfigs.GetClientBaseConfigByKey("RoleLevelUpPluginStarLevel") or 5 + for plugin, status in pairs(self.PluginGridSelectStatusDic) do + if status then + pluginId = plugin:GetId() + usedSuperPluginDic[pluginId] = usedSuperPluginDic[pluginId] or 0 + usedSuperPluginDic[pluginId] = usedSuperPluginDic[pluginId] + 1 + if plugin:GetStar() >= star and not showTip then + showTip = true + end + end + end + local okCallback = function() + if XTool.IsTableEmpty(usedSuperPluginDic) then + XUiManager.TipError(CS.XTextManager.GetText("STRoleLevelUpNotPluginTip")) + return + end + XDataCenter.SuperTowerManager.GetRoleManager():RequestUpgradeCharacter(self.SuperTowerRole:GetCharacterId(), usedSuperPluginDic + , function() + if curLevel ~= self.SuperTowerRole:GetSuperLevel() then + XLuaUiManager.Open("UiSupertowerExpansion", self.SuperTowerRole:GetId(), curLevel, self.SuperTowerRole:GetSuperLevel()) + end + -- 刷新下页面 + self:Reset() + end) + end + -- 判断是否含有5星以上的插件 + if showTip then + CsXUiManager.Instance:Open("UiDialog", CS.XTextManager.GetText("TipTitle") + , CS.XTextManager.GetText("STRoleLevelUpUsePluginTip", star) + , XUiManager.DialogType.Normal, nil, okCallback) + else + okCallback() + end +end + +function XUiSuperTowerRoleLevelUpPanel:ResetBaseInfo() + -- 超限信息 + local currentExp = self.SuperTowerRole:GetCurrentExp() + local maxExp = self.SuperTowerRole:GetMaxExp() + local currentLevel = self.SuperTowerRole:GetSuperLevel() + local maxLevel = self.SuperTowerRole:GetMaxSuperLevel() + if currentLevel >= maxLevel then + currentLevel = maxLevel + currentExp = maxExp + end + self.TxtLevelInfo.text = string.format("%s/%s", currentLevel, maxLevel) + self.TxtExpCompare.text = string.format("%s/%s", currentExp, maxExp) + self.ImgExpBar.fillAmount = currentExp / maxExp + self.TxtAddExp.text = 0 + self.ImgExpAddBar.fillAmount = self.ImgExpBar.fillAmount + -- 背包插件 + self:RefreshPlugins() +end + +function XUiSuperTowerRoleLevelUpPanel:OnBtnAutoSelectClicked() + for i = AUTO_SELECT_MIN_STAR, AUTO_SELECT_MAX_STAR do + self:OnBtnTogStarValueChanged(i, true) + end +end + +function XUiSuperTowerRoleLevelUpPanel:AutoSelectPlugin(plugins, isSelect) + for i, plugin in ipairs(plugins) do + if not self:HandlePluginClicked(plugin, nil, isSelect, false) then + break + end + end + local plugin + for _, grid in pairs(self.DynamicTable:GetGrids()) do + plugin = grid:GetPlugin() + grid:SetActiveStatus(self.PluginGridSelectStatusDic[plugin] or false) + end +end + +function XUiSuperTowerRoleLevelUpPanel:GetPluginSelectStatus(plugin) + if self.PluginGridSelectStatusDic[plugin] == nil then + self.PluginGridSelectStatusDic[plugin] = false + end + return self.PluginGridSelectStatusDic[plugin] +end + +return XUiSuperTowerRoleLevelUpPanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Role/XUiSuperTowerRolePluginUnlockTip.lua b/Resources/Scripts/XUi/XUiSuperTower/Role/XUiSuperTowerRolePluginUnlockTip.lua new file mode 100644 index 00000000..3b10062b --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Role/XUiSuperTowerRolePluginUnlockTip.lua @@ -0,0 +1,19 @@ +local XUiSuperTowerPluginGrid = require("XUi/XUiSuperTower/Plugins/XUiSuperTowerPluginGrid") +local XUiSuperTowerRolePluginUnlockTip = XLuaUiManager.Register(XLuaUi, "UiSuperTowerUnlocking") + +function XUiSuperTowerRolePluginUnlockTip:OnAwake() + self.BtnClose.CallBack = function() self:Close() end +end + +-- superTowerRole : XSuperTowerRole +function XUiSuperTowerRolePluginUnlockTip:OnStart(superTowerRole) + local characterViewModel = superTowerRole:GetCharacterViewModel() + -- 标题 + self.TxtTitle.text = string.format("%s"..CS.XTextManager.GetText("STCharacterPluginUnlockTip"), characterViewModel:GetLogName()) -- 海外修改(替换代码中中文文本) + -- 插件 + local plugin = superTowerRole:GetTransfinitePlugin() + local grid = XUiSuperTowerPluginGrid.New(self.GridPlugin) + grid:RefreshData(plugin) +end + +return XUiSuperTowerRolePluginUnlockTip \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Role/XUiSuperTowerTedianUP.lua b/Resources/Scripts/XUi/XUiSuperTower/Role/XUiSuperTowerTedianUP.lua new file mode 100644 index 00000000..86a8fb26 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Role/XUiSuperTowerTedianUP.lua @@ -0,0 +1,72 @@ +local CsXTextManager = CS.XTextManager + +local XUiPanelHeadGrid = XClass(nil, "XUiSuperTowerTedianUP") + +function XUiPanelHeadGrid:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiPanelHeadGrid:SetData(name, icon) + self.TxtName.text = name + self.RImgIcon:SetRawImage(icon) +end + +--######################## XUiSuperTowerTedianUP ######################## +local XUiSuperTowerTedianUP = XLuaUiManager.Register(XLuaUi, "UiSuperTowerTedianUP") + +function XUiSuperTowerTedianUP:OnAwake() + self.InDultConfig = nil + self:RegisterUiEvents() +end + +function XUiSuperTowerTedianUP:OnStart() + local roleManager = XDataCenter.SuperTowerManager.GetRoleManager() + self.InDultConfig = roleManager:GetCurrentInDultConfig() + if not self.InDultConfig then return end + roleManager:SetInDultHistoryId(self.InDultConfig.Id) + -- 特典列表 + self:RefreshCharacterGrids() + -- 特典描述 + self.TxtBuffTip.text = self.InDultConfig.Desc + -- 自动关闭 + self:RefreshTimeTip() + local endTime = XFunctionManager.GetEndTimeByTimeId(self.InDultConfig.TimeId) + self:SetAutoCloseInfo(endTime, function(isClose) + if isClose then + self:Close() + else + self:RefreshTimeTip() + end + end) +end + +function XUiSuperTowerTedianUP:RefreshTimeTip() + self.TxtTimeTip.text = CS.XTextManager.GetText("CommonRemainTime", self:GetTimeStr()) +end + +function XUiSuperTowerTedianUP:RefreshCharacterGrids() + self.PanelHeadGrid.gameObject:SetActiveEx(false) + local go + local grid + for _, id in ipairs(self.InDultConfig.CharacterId) do + go = CS.UnityEngine.Object.Instantiate(self.PanelHeadGrid, self.PanelHead) + go.gameObject:SetActiveEx(true) + grid = XUiPanelHeadGrid.New(go) + grid:SetData(XEntityHelper.GetCharacterTradeName(id), + XEntityHelper.GetCharacterSmallIcon(id)) + end +end + +function XUiSuperTowerTedianUP:GetTimeStr() + local endTime = XFunctionManager.GetEndTimeByTimeId(self.InDultConfig.TimeId) + local nowTime = XTime.GetServerNowTimestamp() + return XUiHelper.GetTime(endTime - nowTime, XUiHelper.TimeFormatType.ACTIVITY) +end + +function XUiSuperTowerTedianUP:RegisterUiEvents() + self.BtnClose.CallBack = function() self:Close() end +end + +return XUiSuperTowerTedianUP diff --git a/Resources/Scripts/XUi/XUiSuperTower/Role/XUiSupertowerExpansion.lua b/Resources/Scripts/XUi/XUiSuperTower/Role/XUiSupertowerExpansion.lua new file mode 100644 index 00000000..8be0d8c9 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Role/XUiSupertowerExpansion.lua @@ -0,0 +1,33 @@ +local XUiSupertowerExpansion = XLuaUiManager.Register(XLuaUi, "UiSupertowerExpansion") + +function XUiSupertowerExpansion:OnAwake() + -- XSuperTowerRole + self.SuperTowerRole = nil + self:RegisterUiEvents() +end + +function XUiSupertowerExpansion:OnStart(superTowerRoleId, oldLevel, newLevel) + self.SuperTowerRole = XDataCenter.SuperTowerManager.GetRoleManager():GetRole(superTowerRoleId) + if newLevel == nil then newLevel = self.SuperTowerRole:GetSuperLevel() end + -- local characterViewModel = self.SuperTowerRole:GetCharacterViewModel() + -- local attributeDic = characterViewModel:GetAttributes(self.SuperTowerRole:GetEquipViewModels()) + local levelText = CS.XTextManager.GetText("STExpansionLevelTitle") + -- 旧的信息 + self.TxtOldLevel.text = string.format("%s %s", levelText, oldLevel) + self.TxtOldLife.text = self.SuperTowerRole:GetAttributeValue(XNpcAttribType.Life, oldLevel) -- FixToInt(attributeDic[XNpcAttribType.Life]) + + self.TxtOldAttack.text = self.SuperTowerRole:GetAttributeValue(XNpcAttribType.AttackNormal, oldLevel) -- FixToInt(attributeDic[XNpcAttribType.AttackNormal]) + + self.TxtOldDefense.text = self.SuperTowerRole:GetAttributeValue(XNpcAttribType.DefenseNormal, oldLevel) -- FixToInt(attributeDic[XNpcAttribType.DefenseNormal]) + + self.TxtOldCrit.text = self.SuperTowerRole:GetAttributeValue(XNpcAttribType.Crit, oldLevel) -- FixToInt(attributeDic[XNpcAttribType.Crit]) + + -- 新的信息 + self.TxtCurLevel.text = string.format("%s %s", levelText, newLevel) + self.TxtCurLife.text = self.SuperTowerRole:GetAttributeValue(XNpcAttribType.Life, newLevel) -- FixToInt(attributeDic[XNpcAttribType.Life]) + + self.TxtCurAttack.text = self.SuperTowerRole:GetAttributeValue(XNpcAttribType.AttackNormal, newLevel) -- FixToInt(attributeDic[XNpcAttribType.AttackNormal]) + + self.TxtCurDefense.text = self.SuperTowerRole:GetAttributeValue(XNpcAttribType.DefenseNormal, newLevel) -- FixToInt(attributeDic[XNpcAttribType.DefenseNormal]) + + self.TxtCurCrit.text = self.SuperTowerRole:GetAttributeValue(XNpcAttribType.Crit, newLevel) -- FixToInt(attributeDic[XNpcAttribType.Crit]) + +end + +function XUiSupertowerExpansion:RegisterUiEvents() + self.BtnClose.CallBack = function() self:Close() end +end + +return XUiSupertowerExpansion \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Room/XUiSuperTowerBattleRoleRoom.lua b/Resources/Scripts/XUi/XUiSuperTower/Room/XUiSuperTowerBattleRoleRoom.lua new file mode 100644 index 00000000..edd68505 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Room/XUiSuperTowerBattleRoleRoom.lua @@ -0,0 +1,78 @@ +local XUiBattleRoleRoomDefaultProxy = require("XUi/XUiNewRoomSingle/XUiBattleRoleRoomDefaultProxy") +local XUiSuperTowerBattleRoomExpand = require("XUi/XUiSuperTower/Room/XUiSuperTowerBattleRoomExpand") +local XUiSuperTowerBattleRoleRoom = XClass(XUiBattleRoleRoomDefaultProxy, "XUiSuperTowerBattleRoleRoom") + +function XUiSuperTowerBattleRoleRoom:Ctor() + self.SuperTowerRoleManager = XDataCenter.SuperTowerManager.GetRoleManager() +end + +function XUiSuperTowerBattleRoleRoom:GetCharacterViewModelByEntityId(id) + local role = self.SuperTowerRoleManager:GetRole(id) + if not role then return nil end + return role:GetCharacterViewModel() +end + +function XUiSuperTowerBattleRoleRoom:GetRoleAbility(entityId) + local role = self.SuperTowerRoleManager:GetRole(entityId) + if role == nil then return 0 end + return role:GetAbility() +end + +function XUiSuperTowerBattleRoleRoom:GetPartnerByEntityId(id) + local role = self.SuperTowerRoleManager:GetRole(id) + if not role then return nil end + return role:GetPartner() +end + +function XUiSuperTowerBattleRoleRoom:GetChildPanelData() + if self.ChildPanelData == nil then + self.ChildPanelData = { + assetPath = XUiConfigs.GetComponentUrl("UiSuperTowerBattleRoleRoom"), + proxy = XUiSuperTowerBattleRoomExpand, + proxyArgs = { "Team", "StageId" } + } + end + return self.ChildPanelData +end + +function XUiSuperTowerBattleRoleRoom:GetRoleDetailProxy() + return require("XUi/XUiSuperTower/Room/XUiSuperTowerBattleRoomRoleDetail") +end + +-- team : XTeam +-- stageId : number +function XUiSuperTowerBattleRoleRoom:EnterFight(team, stageId) + if XDataCenter.SuperTowerManager.GetStageTypeByStageId(stageId) == XDataCenter.SuperTowerManager.StageType.LllimitedTower then + XDataCenter.SuperTowerManager.EnterFight(stageId) + else + XDataCenter.SuperTowerManager.GetStageManager():ResetTempProgress() + XDataCenter.SuperTowerManager.GetTeamManager():SetTargetFightTeam({team}, stageId, function() + XDataCenter.SuperTowerManager.EnterFight(stageId) + end) + end +end + +function XUiSuperTowerBattleRoleRoom:GetAutoCloseInfo() + return true, XDataCenter.SuperTowerManager.GetActivityEndTime(), function(isClose) + if isClose then + XDataCenter.SuperTowerManager.HandleActivityEndTime() + end + end +end + +--######################## AOP ######################## + +function XUiSuperTowerBattleRoleRoom:AOPOnStartBefore(rootUi) + -- 清理插件槽数据 + local extra = rootUi.Team:GetExtraData() + if extra then extra:Clear() end + -- 显示黑背景 + rootUi.DarkBottom.gameObject:SetActiveEx(true) + rootUi.ImgSkillLine.gameObject:SetActiveEx(false) +end + +function XUiSuperTowerBattleRoleRoom:AOPOnStartAfter(rootUi) + +end + +return XUiSuperTowerBattleRoleRoom \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Room/XUiSuperTowerBattleRoomChildPanel.lua b/Resources/Scripts/XUi/XUiSuperTower/Room/XUiSuperTowerBattleRoomChildPanel.lua new file mode 100644 index 00000000..ffec55c5 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Room/XUiSuperTowerBattleRoomChildPanel.lua @@ -0,0 +1,90 @@ +local XUiSuperTowerPluginGrid = require("XUi/XUiSuperTower/Plugins/XUiSuperTowerPluginGrid") +local XUiSuperTowerBattleRoomChildPanel = XClass(nil, "XUiSuperTowerBattleRoomChildPanel") + +function XUiSuperTowerBattleRoomChildPanel:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + -- XTeam + self.Team = nil + self.StageId = nil + self.CurrentCharacterId = nil + self.GridPlugins = {} + self.GridSuperTowerCore.gameObject:SetActiveEx(false) + self:RegisterUiEvents() + local itemIds = XSuperTowerConfigs.GetMainAssetsPanelItemIds() + self.AssetActivityPanel = XUiPanelActivityAsset.New(self.PanelSpecialTool) + XDataCenter.ItemManager.AddCountUpdateListener(itemIds, function() + self.AssetActivityPanel:Refresh(itemIds) + end, self.AssetActivityPanel) + self.AssetActivityPanel:Refresh(itemIds) +end + +-- team : XTeam +function XUiSuperTowerBattleRoomChildPanel:SetData(team, stageId, currentEntityId) + self.Team = team + self.StageId = stageId + local currentCharacterId = XEntityHelper.GetCharacterIdByEntityId(currentEntityId) + self.CurrentCharacterId = currentCharacterId + local roleManager = XDataCenter.SuperTowerManager.GetRoleManager() + local stageType = XDataCenter.SuperTowerManager.GetStageTypeByStageId(stageId) + local isLllimitedTower = stageType == XDataCenter.SuperTowerManager.StageType.LllimitedTower + self.GameObject:SetActiveEx(not isLllimitedTower) + -- 爬塔不需要处理 + if isLllimitedTower then return end + local teamPluginSlotManager = team:GetExtraData() + -- 队伍插件消耗管理 + local plugins = teamPluginSlotManager:GetPlugins(true) + local isEmpty = teamPluginSlotManager:GetIsEmpty() + self.BtnCore.gameObject:SetActiveEx(isEmpty) + self.PanelCore.gameObject:SetActiveEx(not isEmpty) + for _, grid in pairs(self.GridPlugins) do + grid.GameObject:SetActiveEx(false) + end + if isEmpty then return end + local go, grid, plugin, uiObj, pluginCharacterId + for i = #plugins, 1, -1 do + plugin = plugins[i] + if plugin ~= 0 then + grid = self.GridPlugins[i] + if grid == nil then + go = CS.UnityEngine.Object.Instantiate(self.GridSuperTowerCore.gameObject, self.Content) + grid = XUiSuperTowerPluginGrid.New(go) + self.GridPlugins[i] = grid + grid:SetClickIsShowDetail(true) + else + go = grid.GameObject + end + grid.GameObject:SetActiveEx(true) + grid.Transform:SetAsFirstSibling() + pluginCharacterId = plugin:GetCharacterId() + uiObj = go:GetComponent("UiObject") + uiObj:GetObject("ImgUp").gameObject:SetActiveEx(pluginCharacterId > 0 and currentCharacterId == pluginCharacterId) + uiObj:GetObject("ImgDown").gameObject:SetActiveEx(pluginCharacterId > 0 and currentCharacterId ~= pluginCharacterId) + grid:RefreshData(plugin) + end + end +end + +function XUiSuperTowerBattleRoomChildPanel:Refresh(currentEntityId) + self.CurrentCharacterId = XEntityHelper.GetCharacterIdByEntityId(currentEntityId) + local uiObj, plugin, pluginCharacterId + for _, grid in pairs(self.GridPlugins) do + plugin = grid:GetPlugin() + uiObj = grid.GameObject:GetComponent("UiObject") + pluginCharacterId = plugin:GetCharacterId() + uiObj:GetObject("ImgUp").gameObject:SetActiveEx(pluginCharacterId > 0 and self.CurrentCharacterId == pluginCharacterId) + uiObj:GetObject("ImgDown").gameObject:SetActiveEx(pluginCharacterId > 0 and self.CurrentCharacterId ~= pluginCharacterId) + end +end + +function XUiSuperTowerBattleRoomChildPanel:RegisterUiEvents() + self.BtnConsume.CallBack = function() self:OnBtnCoreClicked() end + self.BtnCore.CallBack = function() self:OnBtnCoreClicked() end +end + +function XUiSuperTowerBattleRoomChildPanel:OnBtnCoreClicked() + XLuaUiManager.Open("UiSuperTowerChooseCore", self.StageId) +end + +return XUiSuperTowerBattleRoomChildPanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Room/XUiSuperTowerBattleRoomExpand.lua b/Resources/Scripts/XUi/XUiSuperTower/Room/XUiSuperTowerBattleRoomExpand.lua new file mode 100644 index 00000000..6063036d --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Room/XUiSuperTowerBattleRoomExpand.lua @@ -0,0 +1,101 @@ +local XUiSuperTowerPluginGrid = require("XUi/XUiSuperTower/Plugins/XUiSuperTowerPluginGrid") +local XUiSuperTowerBattleRoomExpand = XClass(nil, "XUiSuperTowerBattleRoomExpand") + +function XUiSuperTowerBattleRoomExpand:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.GridPlugin.gameObject:SetActiveEx(false) + -- XTeam + self.Team = nil + self.GridPluginGos = {} + self:RegisterUiEvents() +end + +-- team : XTeam +function XUiSuperTowerBattleRoomExpand:SetData(team, stageId) + self.Team = team + self.StageId = stageId + local superTowerManager = XDataCenter.SuperTowerManager + local roleManager = superTowerManager.GetRoleManager() + local stageType = superTowerManager.GetStageTypeByStageId(stageId) + self.PanelTeam.gameObject:SetActiveEx(superTowerManager.CheckFunctionUnlockByKey(superTowerManager.FunctionName.Transfinite)) + -- 要识别冒险爬塔类型 + local isLllimitedTower = stageType == superTowerManager.StageType.LllimitedTower + -- 等级 + local superTowerRole = nil + local entityId = nil + for pos = 1, 3 do + entityId = team:GetEntityIdByTeamPos(pos) + superTowerRole = roleManager:GetRole(entityId) + self["BtnChar" .. pos].gameObject:SetActiveEx(superTowerRole ~= nil) + if superTowerRole then + local hpLeft = superTowerRole:GetHpLeft() + self["ImgLife" .. pos].fillAmount = hpLeft / 100 + self["TxtLife" .. pos].text = string.format( "%s%%", hpLeft) + self["TxtLevel" .. pos].text = superTowerRole:GetSuperLevel() + self["PanelLife" .. pos].gameObject:SetActiveEx(isLllimitedTower) + self["ImgTdIcon" .. pos].gameObject:SetActiveEx(superTowerRole:GetIsInDult()) + end + end + -- 超级爬塔 + self.BtnBuff01.gameObject:SetActiveEx(isLllimitedTower) + self.BtnBuff02.gameObject:SetActiveEx(isLllimitedTower) + -- n波和多队伍 + -- XSuperTowerPluginSlotManager + local teamPluginSlotManager = team:GetExtraData() + if teamPluginSlotManager and not isLllimitedTower then + -- 队伍插件消耗管理 + local isEmpty = teamPluginSlotManager:GetIsEmpty() + local plugins = teamPluginSlotManager:GetPlugins(true) + self.BtnCore.gameObject:SetActiveEx(isEmpty) + self.PanelCore.gameObject:SetActiveEx(not isEmpty) + for _, go in pairs(self.GridPluginGos) do + go.gameObject:SetActiveEx(false) + end + if not isEmpty then + local go, grid, plugin + for i = #plugins, 1, -1 do + plugin = plugins[i] + if plugin ~= 0 then + go = self.GridPluginGos[i] + if go == nil then + go = CS.UnityEngine.Object.Instantiate(self.GridPlugin, self.PluginContent) + self.GridPluginGos[i] = go + end + go.gameObject:SetActiveEx(true) + go.transform:SetAsFirstSibling() + grid = XUiSuperTowerPluginGrid.New(go) + grid:SetClickIsShowDetail(true) + grid:RefreshData(plugin) + end + end + end + else + self.BtnCore.gameObject:SetActiveEx(false) + self.PanelCore.gameObject:SetActiveEx(false) + end +end + +function XUiSuperTowerBattleRoomExpand:RegisterUiEvents() + self.BtnBuff01.CallBack = function() self:OnBtnBuff01Clicked() end + self.BtnBuff02.CallBack = function() self:OnBtnBuff02Clicked() end + self.BtnCore.CallBack = function() self:OnBtnCoreClicked() end + self.BtnConsume.CallBack = function() self:OnBtnCoreClicked() end +end + +function XUiSuperTowerBattleRoomExpand:OnBtnBuff01Clicked() + local theme = XDataCenter.SuperTowerManager.GetStageManager():GetThemeByStageId(self.StageId) + XLuaUiManager.Open("UiSuperTowerItemTip", theme, XDataCenter.SuperTowerManager.ItemType.Enhance) +end + +function XUiSuperTowerBattleRoomExpand:OnBtnBuff02Clicked() + local theme = XDataCenter.SuperTowerManager.GetStageManager():GetThemeByStageId(self.StageId) + XLuaUiManager.Open("UiSuperTowerItemTip", theme, XDataCenter.SuperTowerManager.ItemType.Plugin) +end + +function XUiSuperTowerBattleRoomExpand:OnBtnCoreClicked() + XLuaUiManager.Open("UiSuperTowerChooseCore", self.StageId) +end + +return XUiSuperTowerBattleRoomExpand \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Room/XUiSuperTowerBattleRoomRoleDetail.lua b/Resources/Scripts/XUi/XUiSuperTower/Room/XUiSuperTowerBattleRoomRoleDetail.lua new file mode 100644 index 00000000..1ec4b253 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Room/XUiSuperTowerBattleRoomRoleDetail.lua @@ -0,0 +1,208 @@ +local CsGetText = CS.XTextManager.GetText +local XUiBattleRoomRoleGrid = require("XUi/XUiNewRoomSingle/XUiBattleRoomRoleGrid") +--######################## XUiSuperTowerBattleRoomRoleGrid ######################## +local XUiSuperTowerBattleRoomRoleGrid = XClass(XUiBattleRoomRoleGrid, "XUiSuperTowerBattleRoomRoleGrid") + +-- superTowerRole : XSuperTowerRole +-- team : XTeam +function XUiSuperTowerBattleRoomRoleGrid:SetData(superTowerRole, team, stageId) + XUiSuperTowerBattleRoomRoleGrid.Super.SetData(self, superTowerRole) + local superTowerManager = XDataCenter.SuperTowerManager + self.TxtPower.text = superTowerRole:GetAbility() + -- 超限等级 + self.TxtSuperLevel.text = superTowerRole:GetSuperLevel() + local isOpenTransfinite = superTowerManager.CheckFunctionUnlockByKey(superTowerManager.FunctionName.Transfinite) + self.PanelSuperLevel.gameObject:SetActiveEx(isOpenTransfinite) + -- 试玩 + self.PanelTry.gameObject:SetActiveEx(superTowerRole:GetIsRobot()) + -- 是否上阵了同一角色 + local isInTeam = team:GetEntityIdIsInTeam(superTowerRole:GetId()) + local isHasSameCharacterInTeam = team:CheckHasSameCharacterId(superTowerRole:GetId()) + if not isInTeam and isHasSameCharacterInTeam then + self.PanelSameRole.gameObject:SetActiveEx(true) + else + self.PanelSameRole.gameObject:SetActiveEx(false) + end + -- 特典 + local isOpenBonusChara = superTowerManager.CheckFunctionUnlockByKey(superTowerManager.FunctionName.BonusChara) + self.PanelRogueLikeTheme.gameObject:SetActiveEx(isOpenBonusChara and superTowerRole:GetIsInDult()) + -- 其他梯队信息 + local targetStage = superTowerManager.GetTargetStageByStageId(stageId) + if targetStage then + local index = superTowerManager.GetTeamManager():CheckMemberIsInTeam( + superTowerManager.TeamId[targetStage:GetStageType()] + , XSuperTowerConfigs.MaxMultiTeamCount + , superTowerRole:GetId()) + self.PanelTeamSupport.gameObject:SetActiveEx(index > 0) + if index > 0 then + self.TxtEchelonIndex.text = CsGetText("STMultiTeamInHint", index) + end + else + self.PanelTeamSupport.gameObject:SetActiveEx(false) + end +end + +function XUiSuperTowerBattleRoomRoleGrid:SetInTeamStatus(value) + self.ImgInTeam.gameObject:SetActiveEx(value) + if value then + self.PanelTeamSupport.gameObject:SetActiveEx(false) + end +end + +--######################## XUiSuperTowerBattleRoomRoleDetail ######################## +local XUiBattleRoomRoleDetailDefaultProxy = require("XUi/XUiNewRoomSingle/XUiBattleRoomRoleDetailDefaultProxy") +local XUiSuperTowerBattleRoomRoleDetail = XClass(XUiBattleRoomRoleDetailDefaultProxy, "XUiSuperTowerBattleRoomRoleDetail") + +-- characterType : XCharacterConfigs.CharacterType +function XUiSuperTowerBattleRoomRoleDetail:GetEntities(characterType) + return XDataCenter.SuperTowerManager.GetRoleManager():GetCanFightRoles(characterType) +end + +function XUiSuperTowerBattleRoomRoleDetail:GetFilterJudge() + return XDataCenter.SuperTowerManager.GetRoleManager():GetFilterJudge() +end + +function XUiSuperTowerBattleRoomRoleDetail:GetGridProxy() + return XUiSuperTowerBattleRoomRoleGrid +end + +function XUiSuperTowerBattleRoomRoleDetail:GetChildPanelData() + if self.ChildPanelData == nil then + self.ChildPanelData = { + assetPath = XUiConfigs.GetComponentUrl("UiSuperTowerBattleRoomRoleDetail"), + proxy = require("XUi/XUiSuperTower/Room/XUiSuperTowerBattleRoomChildPanel"), + proxyArgs = { "Team", "StageId", "CurrentEntityId" } + } + end + return self.ChildPanelData +end + +function XUiSuperTowerBattleRoomRoleDetail:GetCharacterViewModelByEntityId(entityId) + return XDataCenter.SuperTowerManager.GetRoleManager():GetRole(entityId):GetCharacterViewModel() +end + +-- team : XTeam +-- sortTagType : XRoomCharFilterTipsConfigs.EnumSortTag +function XUiSuperTowerBattleRoomRoleDetail:SortEntitiesWithTeam(team, entities, sortTagType) + if sortTagType == nil then + entities = XUiSuperTowerBattleRoomRoleDetail.Super.SortEntitiesWithTeam(self, team, entities) + else + entities = XDataCenter.SuperTowerManager.GetRoleManager():SortRoles(entities, sortTagType, true) + local roleManager = XDataCenter.SuperTowerManager.GetRoleManager() + local role, entityId + local entityIds = team:GetEntityIds() + for pos = XEntityHelper.TEAM_MAX_ROLE_COUNT, 1, -1 do + entityId = entityIds[pos] + role = roleManager:GetRole(entityId) + if role then + local index = table.indexof(entities, role) + if index ~= false then + table.remove(entities, index) + table.insert(entities, 1, role) + end + end + end + end + return entities +end + +function XUiSuperTowerBattleRoomRoleDetail:GetAutoCloseInfo() + return true, XDataCenter.SuperTowerManager.GetActivityEndTime(), function(isClose) + if isClose then + XDataCenter.SuperTowerManager.HandleActivityEndTime() + end + end +end + +function XUiSuperTowerBattleRoomRoleDetail:GetRoleDynamicGrid(rootUi) + return rootUi.GridCharacterSupertower +end + +-- return { [XRoomCharFilterTipsConfigs.EnumSortTag.xxx] = true } 即为隐藏 +function XUiBattleRoomRoleDetailDefaultProxy:GetHideSortTagDic() + local superTowerManager = XDataCenter.SuperTowerManager + local isOpen = superTowerManager.CheckFunctionUnlockByKey(superTowerManager.FunctionName.Transfinite) + return { [XRoomCharFilterTipsConfigs.EnumSortTag.SuperLevel] = not isOpen } +end + +--######################## AOP ######################## + +function XUiSuperTowerBattleRoomRoleDetail:AOPOnStartBefore(rootUi) + rootUi.PanelAsset.gameObject:SetActiveEx(false) +end + +function XUiSuperTowerBattleRoomRoleDetail:AOPOnStartAfter(rootUi) + +end + +function XUiSuperTowerBattleRoomRoleDetail:AOPOnBtnJoinTeamClickedBefore(rootUi) + local currentEntityId = rootUi.CurrentEntityId + local targetStage = XDataCenter.SuperTowerManager.GetTargetStageByStageId(rootUi.StageId) + if not targetStage then return end + if targetStage:GetStageType() ~= XDataCenter.SuperTowerManager.StageType.MultiTeamMultiWave then + return + end + -- 多队伍情况下不能上阵同一个角色 + local teams = XDataCenter.SuperTowerManager.GetTeamManager():GetTeamsByIdAndCount( + XDataCenter.SuperTowerManager.TeamId[targetStage:GetStageType()], XSuperTowerConfigs.MaxMultiTeamCount) + local exchangeTeam = nil + local exchangePos = nil + for teamIndex, team in ipairs(teams) do + if team:GetId() ~= rootUi.Team:GetId() then + local hasSame, pos = team:CheckHasSameCharacterId(currentEntityId) + if hasSame then + exchangeTeam = team + exchangePos = pos + break + end + end + end + -- 其他队伍有相同的角色 + if exchangeTeam ~= nil then + -- 如果该角色的实体id不在任何一个队伍里,弹特殊提示 + local teamIndex = XDataCenter.SuperTowerManager.GetTeamManager():CheckMemberIsInTeam( + XDataCenter.SuperTowerManager.TeamId[targetStage:GetStageType()] + , XSuperTowerConfigs.MaxMultiTeamCount + , currentEntityId) + if teamIndex <= 0 then + XUiManager.TipError(CsGetText("STSameCharacterNotInTeamTip")) + return true + end + local finishedCallback = function() + local characterName = XDataCenter.SuperTowerManager:GetRoleManager():GetRole(currentEntityId):GetCharacterViewModel():GetName() + local currentTeamIndex = nil + for teamIndex, team in ipairs(teams) do + if team:GetId() == rootUi.Team:GetId() then + currentTeamIndex = teamIndex + break + end + end + CsXUiManager.Instance:Open("UiDialog", CsGetText("ExchangeTeamMemberTitle") + , CsGetText("ExchangeTeamMemberContent", characterName, CsGetText("BattleTeamTitle", teamIndex), CsGetText("BattleTeamTitle", currentTeamIndex)) + , XUiManager.DialogType.Normal, nil, function() + local currentTeam = rootUi.Team + local currentPos = rootUi.Pos + local currentPosEntityId = currentTeam:GetEntityIdByTeamPos(currentPos) + exchangeTeam:UpdateEntityTeamPos(currentPosEntityId, exchangePos, true) + rootUi.Team:UpdateEntityTeamPos(currentEntityId, currentPos, true) + rootUi:Close() + end) + end + if rootUi:CheckCanJoin(currentEntityId, finishedCallback) then + finishedCallback() + end + return true + end + -- 当前的实体是否在其他梯队中 + self.__AOP_OtherTeam = exchangeTeam +end + +function XUiSuperTowerBattleRoomRoleDetail:AOPOnBtnJoinTeamClickedAfter(rootUi) + local team = self.__AOP_OtherTeam + if not team then return nil end + if team:GetId() == rootUi.Team:GetId() then return nil end + team:UpdateEntityTeamPos(rootUi.CurrentEntityId, nil, false) + self.__AOP_OtherTeam = nil +end + +return XUiSuperTowerBattleRoomRoleDetail \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Shop/XUiGridSuperTowerShopItem.lua b/Resources/Scripts/XUi/XUiSuperTower/Shop/XUiGridSuperTowerShopItem.lua new file mode 100644 index 00000000..ab3bd936 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Shop/XUiGridSuperTowerShopItem.lua @@ -0,0 +1,36 @@ +local XUiGridSuperTowerShopItem = XClass(nil, "XUiGridSuperTowerShopItem") +local PluginScript = require("XEntity/XSuperTower/Plugin/XSuperTowerPlugin") + +function XUiGridSuperTowerShopItem:Ctor(ui, rootUi) + self.GameObject = ui + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + self.BtnClick.CallBack = function() + if not self.Plugin then + return + end + XLuaUiManager.Open("UiSuperTowerPluginDetails", self.Plugin) + end +end + +function XUiGridSuperTowerShopItem:Refresh(itemInfo) + if not itemInfo then + return + end + local mallPluginConfig = XSuperTowerConfigs.GetMallPluginConfig(itemInfo.Id) + local pluginConfig = XSuperTowerConfigs.GetPluginCfgById(mallPluginConfig.PluginId) + local mallConfig = XSuperTowerConfigs.GetMallConfig(mallPluginConfig.MallId) + local starBg = XSuperTowerConfigs.GetStarBgByQuality(pluginConfig.Quality) + local starIcon = XSuperTowerConfigs.GetStarIconByQuality(pluginConfig.Quality) + self.Plugin = PluginScript.New(mallPluginConfig.PluginId) + self.TxtCostItemCount.text = mallPluginConfig.Price + self.TxtBuyItemName.text = pluginConfig.Name + self.PanelYishouqin.gameObject:SetActiveEx(itemInfo.Sell) + self.RImgCostItemIcon:SetRawImage(XDataCenter.ItemManager.GetItemIcon(mallConfig.SpendItemId)) + self.ImgQuality:SetSprite(starIcon) + self.BgKuang:SetSprite(starBg) + self.RImgIcon:SetRawImage(pluginConfig.Icon) +end + +return XUiGridSuperTowerShopItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Shop/XUiSuperTowerShop.lua b/Resources/Scripts/XUi/XUiSuperTower/Shop/XUiSuperTowerShop.lua new file mode 100644 index 00000000..c3cb4094 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Shop/XUiSuperTowerShop.lua @@ -0,0 +1,197 @@ +local XUiSuperTowerShop = XLuaUiManager.Register(XLuaUi, "UiSuperTowerShop") +local XUiGridSuperTowerShopItem = require("XUi/XUiSuperTower/Shop/XUiGridSuperTowerShopItem") +local SortShopItem = function(itemA, itemB) + if not itemA.Sell and itemB.Sell then + return true + elseif itemA.Sell and not itemB.Sell then + return false + else + return itemA.Index < itemB.Index + end +end + +function XUiSuperTowerShop:OnStart() + self.AssetActivityPanel = XUiPanelActivityAsset.New(self.PanelSpecialTool) + local itemIds = {} + for i = 1, 3 do + local itemId = XSuperTowerConfigs.GetClientBaseConfigByKey("CurrencyItemOther" .. i, true) + if itemId and itemId ~= 0 then + table.insert(itemIds, itemId) + end + end + XDataCenter.ItemManager.AddCountUpdateListener(itemIds, function() + self.AssetActivityPanel:Refresh(itemIds) + end, self.AssetActivityPanel) + self.AssetActivityPanel:Refresh(itemIds) + local shopManager = XDataCenter.SuperTowerManager.GetShopManager() + local mallConfig = XSuperTowerConfigs.GetMallConfig(shopManager:GetMallId()) + XDataCenter.ItemManager.AddCountUpdateListener(mallConfig.ManualRefreshSpendItemId, function() + self:RefreshSpendCount() + end, self) + if self.TxtBt and self.TxtBt2 then + self.TxtBt.text = CSXTextManagerGetText("STShopTitle") + self.TxtBt2.text = CSXTextManagerGetText("STShopTitle") + end + self:RegisterButtonEvent() + self:RefreshTime() + self:InitDynamicTable() + self:SetActivityTimeLimit() +end + +function XUiSuperTowerShop:OnEnable() + XUiSuperTowerShop.Super.OnEnable(self) + self:Refresh() + self:StartTimer() +end + +function XUiSuperTowerShop:OnDisable() + XUiSuperTowerShop.Super.OnDisable(self) + self:StopTimer() +end + +function XUiSuperTowerShop:Refresh() + self:SetupDynamicTable() + self:RefreshPanel() + self:RefreshSpendCount() + if XLuaUiManager.IsUiShow("UiSuperTowerPluginDetails") then + XLuaUiManager.Close("UiSuperTowerPluginDetails") + end +end + +function XUiSuperTowerShop:OnGetEvents() + return { + XEventId.EVENT_ST_SHOP_REFRESH + } +end + +function XUiSuperTowerShop:OnNotify(event, ...) + if event == XEventId.EVENT_ST_SHOP_REFRESH then + self:Refresh() + end +end + +function XUiSuperTowerShop:RegisterButtonEvent() + self.BtnBack.CallBack = function() + self:Close() + end + self.BtnRefresh.CallBack = function() + self:OnClickBtnRefresh() + end +end + +function XUiSuperTowerShop:InitDynamicTable() + ---@type XDynamicTableNormal + self.DynamicTable = XDynamicTableNormal.New(self.PanelItemList) + self.DynamicTable:SetDelegate(self) + self.DynamicTable:SetProxy(XUiGridSuperTowerShopItem) +end + +function XUiSuperTowerShop:SetupDynamicTable() + local shopManager = XDataCenter.SuperTowerManager.GetShopManager() + self.DataList = shopManager:GetBuyList() + table.sort(self.DataList, SortShopItem) + self.DynamicTable:SetDataSource(self.DataList) + self.DynamicTable:ReloadDataASync() +end + +function XUiSuperTowerShop:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:Refresh(self.DynamicTable.DataSource[index]) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + local shopInfo = self.DynamicTable.DataSource[index] + if shopInfo.Sell then + return + end + XLuaUiManager.Open("UiSuperTowerShopItem", shopInfo, function() + shopInfo.Sell = true + table.sort(self.DataList, SortShopItem) + self:SetupDynamicTable() + self:CheckPluginSyn() + end) + end +end + +function XUiSuperTowerShop:OnClickBtnRefresh() + local shopManager = XDataCenter.SuperTowerManager.GetShopManager() + local freeRefreshCount = shopManager:GetRefreshCount() + local mallConfig = XSuperTowerConfigs.GetMallConfig(shopManager:GetMallId()) + if freeRefreshCount >= mallConfig.FreeRefreshCount then + local spendCount,spendItemCount = shopManager:GetSpendItemCountInfo() + if spendItemCount < spendCount then + XUiManager.TipText("STShopRefreshItemNotEnoughTips") + return + end + end + shopManager:RequestRefreshMall(function() + self:Refresh() + end) +end + +function XUiSuperTowerShop:RefreshPanel() + local shopManager = XDataCenter.SuperTowerManager.GetShopManager() + local refreshCount = shopManager:GetRefreshCount() + local mallConfig = XSuperTowerConfigs.GetMallConfig(shopManager:GetMallId()) + self.RImgCostItemIcon:SetRawImage(XDataCenter.ItemManager.GetItemIcon(mallConfig.ManualRefreshSpendItemId)) + local remainCount = mallConfig.FreeRefreshCount - refreshCount + self.BtnRefresh:SetName(CSXTextManagerGetText("STShopRefreshBtnText", remainCount, mallConfig.FreeRefreshCount)) + self.TxtCostItemCount.gameObject:SetActiveEx(remainCount == 0) + self.TxtRefreshTime.gameObject:SetActiveEx(remainCount ~= mallConfig.FreeRefreshCount) + self:RefreshTime() +end + +function XUiSuperTowerShop:RefreshSpendCount() + local shopManager = XDataCenter.SuperTowerManager.GetShopManager() + local spendCount, spendItemCount = shopManager:GetSpendItemCountInfo() + if spendItemCount < spendCount then + self.TxtCostItemCount.text = CSXTextManagerGetText("STShopRefreshItemNotEnoughStyle", spendCount) + else + self.TxtCostItemCount.text = spendCount + end +end + +function XUiSuperTowerShop:RefreshTime() + if XTool.UObjIsNil(self.TxtRefreshTime) then + self:StopTimer() + return + end + local shopManager = XDataCenter.SuperTowerManager.GetShopManager() + local nextRefreshTime = shopManager:GetRefreshCd() + local now = XTime.GetServerNowTimestamp() + local offset = nextRefreshTime - now + if offset < 0 then + offset = 0 + end + local text = CS.XTextManager.GetText("STShopRefreshTime", XUiHelper.GetTime(offset, XUiHelper.TimeFormatType.SHOP)) + self.TxtRefreshTime.text = string.gsub(text, "\\n", "\n") +end + +function XUiSuperTowerShop:StartTimer() + if self.Timer then + self:StopTimer() + end + self.Timer = XScheduleManager.ScheduleForever(handler(self, self.RefreshTime), XScheduleManager.SECOND, 0) +end + +function XUiSuperTowerShop:StopTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end + +function XUiSuperTowerShop:CheckPluginSyn() + local oldList, newList = XDataCenter.SuperTowerManager.GetBagManager():GetPluginSyn() + if oldList and newList then + XLuaUiManager.Open("UiSuperTowerPlugUp", oldList, newList, function() self:CheckPluginSyn() end) + end +end + +function XUiSuperTowerShop:SetActivityTimeLimit() + -- 自动关闭 + local endTime = XDataCenter.SuperTowerManager.GetActivityEndTime() + self:SetAutoCloseInfo(endTime, function(isClose) + if isClose then + XDataCenter.SuperTowerManager.HandleActivityEndTime() + end + end) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Shop/XUiSuperTowerShopItem.lua b/Resources/Scripts/XUi/XUiSuperTower/Shop/XUiSuperTowerShopItem.lua new file mode 100644 index 00000000..bbb5cc60 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Shop/XUiSuperTowerShopItem.lua @@ -0,0 +1,111 @@ +local XUiSuperTowerShopItem = XLuaUiManager.Register(XLuaUi, "UiSuperTowerShopItem") +local CSXTextManagerGetText = CS.XTextManager.GetText +function XUiSuperTowerShopItem:OnStart(shopInfo, callback) + self.ShopInfo = shopInfo + self.Callback = callback + self:InitView() +end + +function XUiSuperTowerShopItem:OnEnable() + +end + +function XUiSuperTowerShopItem:OnDisable() + +end + +function XUiSuperTowerShopItem:OnGetEvents() + return { + XEventId.EVENT_ST_SHOP_REFRESH + } +end + +function XUiSuperTowerShopItem:OnNotify(event, ...) + if event == XEventId.EVENT_ST_SHOP_REFRESH then + self:Close() + end +end + + +function XUiSuperTowerShopItem:InitView() + local mallPluginConfig = XSuperTowerConfigs.GetMallPluginConfig(self.ShopInfo.Id) + local mallConfig = XSuperTowerConfigs.GetMallConfig(mallPluginConfig.MallId) + self.PluginCfg = XSuperTowerConfigs.GetPluginCfgById(mallPluginConfig.PluginId) + local pluginEntity = XDataCenter.SuperTowerManager.GetBagManager():GetPlugin(mallPluginConfig.PluginId) + local count = 0 + if pluginEntity then + count = pluginEntity:GetCount() + end + self.TxtOwnCount.text = CSXTextManagerGetText("SuperTowerShopOwnerText", count) + self.TxtName.text = self.PluginCfg.Name + self.RImgIcon:SetRawImage(self.PluginCfg.Icon) + local starBg = XSuperTowerConfigs.GetStarBgByQuality(self.PluginCfg.Quality) + local starIcon = XSuperTowerConfigs.GetStarIconByQuality(self.PluginCfg.Quality) + self.ImgQuality:SetSprite(starIcon) + self.BgKuang:SetSprite(starBg) + self.RImgCostIcon1:SetRawImage(XDataCenter.ItemManager.GetItemIcon(mallConfig.SpendItemId)) + self.TxtCostCount1.text = mallPluginConfig.Price + + -- 加减按钮和最大数量按钮暂时无用先设置disable状态 + self.BtnAddSelect:SetDisable(true, false) + self.BtnMinusSelect:SetDisable(true, false) + self.BtnMax:SetDisable(true, false) + self:RegisterButtonEvent() +end + +function XUiSuperTowerShopItem:RegisterButtonEvent() + self.BtnTanchuangClose.CallBack = function() + self:Close() + end + self.BtnUse.CallBack = function() + self:OnClickBtnBuy() + end + self.BtnMax.CallBack = function() + self:OnClickBtnMax() + end + self.BtnAddSelect.CallBack = function() + self:OnClickBtnAdd() + end + self.BtnMinusSelect.CallBack = function() + self:OnClickBtnReduce() + end +end + +function XUiSuperTowerShopItem:OnClickBtnAdd() + --todo 目前插件购买限制为1,暂时无用 +end + +function XUiSuperTowerShopItem:OnClickBtnReduce() + --todo 目前插件购买限制为1,暂时无用 +end + +function XUiSuperTowerShopItem:OnClickBtnMax() + --todo 目前插件购买限制为1,暂时无用 +end + +function XUiSuperTowerShopItem:OnClickBtnBuy() + local shopManager = XDataCenter.SuperTowerManager.GetShopManager() + local mallPluginConfig = XSuperTowerConfigs.GetMallPluginConfig(self.ShopInfo.Id) + local mallConfig = XSuperTowerConfigs.GetMallConfig(mallPluginConfig.MallId) + local spendItemCount = XDataCenter.ItemManager.GetCount(mallConfig.SpendItemId) + if spendItemCount < mallPluginConfig.Price then + XUiManager.TipText("STShopBuyItemNotEnoughTips") + return + end + local bagManager = XDataCenter.SuperTowerManager.GetBagManager() + if bagManager:GetCurrentCapacity() + self.PluginCfg.Capacity > bagManager:GetMaxCapacity() then + XUiManager.TipText("STShopOverCapacity") + return + end + shopManager:RequestBugPlugin(self.ShopInfo.Index, 1, function() + XUiManager.TipText("BuySuccess") + self:Close() + if self.Callback then + self.Callback() + end + end) +end + +function XUiSuperTowerShopItem:CheckLimit() + return true +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Stages/Target/XUiGridSTQuickDeployMember.lua b/Resources/Scripts/XUi/XUiSuperTower/Stages/Target/XUiGridSTQuickDeployMember.lua new file mode 100644 index 00000000..aaaf2d69 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Stages/Target/XUiGridSTQuickDeployMember.lua @@ -0,0 +1,68 @@ +local XUiGridSTQuickDeployMember = XClass(nil, "XUiGridSTQuickDeployMember") +local MEMBER_POS_COLOR = { + "FF1111FF", -- red + "4F99FFFF", -- blue + "F9CB35FF", -- yellow +} + +function XUiGridSTQuickDeployMember:Ctor(ui, clickCb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.ClickCb = clickCb + + XTool.InitUiObject(self) + self:InitComponent() +end + +function XUiGridSTQuickDeployMember:InitComponent() + self.RImgRole.gameObject:SetActiveEx(false) + self.ImgLeader.gameObject:SetActiveEx(false) + self.ImgFirstRole.gameObject:SetActiveEx(false) + self.ImgAbility.gameObject:SetActiveEx(false) + self.ImgSelect.gameObject:SetActiveEx(false) + self.PanelEffect.gameObject:SetActiveEx(false) + self.BtnMember.CallBack = function() self:OnMemberClick() end +end + +function XUiGridSTQuickDeployMember:Refresh(memberRole, memberPos) + local color = XUiHelper.Hexcolor2Color(MEMBER_POS_COLOR[memberPos]) + self.ImgLeftSkill.color = color + self.ImgRightSkill.color = color + self.MemberPos = memberPos + local isEmpty = not memberRole + if not isEmpty then + self.RImgRole.gameObject:SetActiveEx(true) + self.RImgRole:SetRawImage(memberRole:GetSmallHeadIcon()) + self.TryTag.gameObject:SetActiveEx(memberRole:GetIsRobot()) + else + self.RImgRole.gameObject:SetActiveEx(false) + self.TryTag.gameObject:SetActiveEx(false) + end + + self.PanelEffect.gameObject:SetActiveEx(false) +end + +function XUiGridSTQuickDeployMember:OnMemberClick() + if self.ClickCb then + self.ClickCb(self, self.MemberPos) + end +end + +function XUiGridSTQuickDeployMember:ShowEffect() + self.PanelEffect.gameObject:SetActiveEx(false) + self.PanelEffect.gameObject:SetActiveEx(true) +end + +function XUiGridSTQuickDeployMember:SetSelect(value) + self.ImgSelect.gameObject:SetActiveEx(value) +end + +function XUiGridSTQuickDeployMember:RefreshCaptainPos(captainPos) + self.ImgLeader.gameObject:SetActiveEx(self.MemberPos == captainPos) +end + +function XUiGridSTQuickDeployMember:RefreshFirstFightPos(firstFightPos) + self.ImgFirstRole.gameObject:SetActiveEx(self.MemberPos == firstFightPos) +end + +return XUiGridSTQuickDeployMember \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Stages/Target/XUiGridSTQuickDeployTeam.lua b/Resources/Scripts/XUi/XUiSuperTower/Stages/Target/XUiGridSTQuickDeployTeam.lua new file mode 100644 index 00000000..9fc921d1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Stages/Target/XUiGridSTQuickDeployTeam.lua @@ -0,0 +1,114 @@ +local XUiGridSTQuickDeployMember = require("XUi/XUiSuperTower/Stages/Target/XUiGridSTQuickDeployMember") +local CSTextManagerGetText = CS.XTextManager.GetText +local CSObjectInstantiate = CS.UnityEngine.Object.Instantiate + +local XUiGridSTQuickDeployTeam = XClass(nil, "XUiGridSTQuickDeployTeam") + +function XUiGridSTQuickDeployTeam:Ctor(ui, memberClickCb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.MemberGridList = {} + self.MemberClickCb = memberClickCb + + XTool.InitUiObject(self) + self.TabGroup = { + self.BtnRed, + self.BtnBlue, + self.BtnYellow, + } + self.PanelTabFirst:Init(self.TabGroup, function(tabIndex) self:OnClickTabCallBack(tabIndex) end) + + self.TabGroupCT = { + self.BtnCaptainRed, + self.BtnCaptainBlue, + self.BtnCaptainYellow, + } + self.PanelTabCaptain:Init(self.TabGroupCT, function(tabIndex) self:OnClickTabCallBackCT(tabIndex) end) + + self.GridTeamMember.gameObject:SetActiveEx(false) +end + +function XUiGridSTQuickDeployTeam:Refresh(stageIndex, stStage, team) + local roleManager = XDataCenter.SuperTowerManager.GetRoleManager() + local memberEntityIdList = team:GetEntityIds() + self.Team = team + + local memberNum = stStage:GetMemberCountByIndex(stageIndex) + for memberIndex = 1, memberNum do + local grid = self.MemberGridList[memberIndex] + if not grid then + local go = CSObjectInstantiate(self.GridTeamMember, self.PanelRole) + local clickCb = function(paramGrid, paramMemberIndex) + self.MemberClickCb(paramGrid, paramMemberIndex, stageIndex) + end + + grid = XUiGridSTQuickDeployMember.New(go, clickCb) + self.MemberGridList[memberIndex] = grid + end + + local memberEntityId = memberEntityIdList[memberIndex] or 0 + local memberRole = roleManager:GetRole(memberEntityId) + grid:Refresh(memberRole, memberIndex) + + --local captainPos = team:GetCaptainPos() + --grid:RefreshCaptainPos(captainPos) + + --local captainPos = team:GetFirstFightPos() + --grid:RefreshFirstFightPos(captainPos) + --蓝色放到第一位 + if memberIndex == 2 then + grid.Transform:SetAsFirstSibling() + end + grid.GameObject:SetActiveEx(true) + end + + for index = memberNum + 1, #self.MemberGridList do + self.MemberGridList[index].GameObject:SetActiveEx(false) + end + + for index, tabBtn in pairs(self.TabGroup) do + tabBtn.gameObject:SetActiveEx(index <= memberNum) + end + local firstFightPos = team:GetFirstFightPos() + self.PanelTabFirst:SelectIndex(firstFightPos) + + for index, tabBtn in pairs(self.TabGroupCT) do + tabBtn.gameObject:SetActiveEx(index <= memberNum) + end + local captainPos = team:GetCaptainPos() + self.PanelTabCaptain:SelectIndex(captainPos) + + self.TextTitle.text = CSTextManagerGetText("STFightLoadingTeamText", stageIndex) +end + +function XUiGridSTQuickDeployTeam:OnClickTabCallBack(firstFightPos) + if self.SelectedIndex and self.SelectedIndex == firstFightPos then + return + end + self.SelectedIndex = firstFightPos + + self.Team:UpdateFirstFightPos(firstFightPos) + + local gridNum = #self.MemberGridList + for index = 1, gridNum do + local grid = self.MemberGridList[index] + grid:RefreshFirstFightPos(firstFightPos) + end +end + +function XUiGridSTQuickDeployTeam:OnClickTabCallBackCT(captainPos) + if self.SelectedIndexCT and self.SelectedIndexCT == captainPos then + return + end + self.SelectedIndexCT = captainPos + + self.Team:UpdateCaptianPos(captainPos) + + local gridNum = #self.MemberGridList + for index = 1, gridNum do + local grid = self.MemberGridList[index] + grid:RefreshCaptainPos(captainPos) + end +end + +return XUiGridSTQuickDeployTeam \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Stages/Target/XUiGridSettleReward.lua b/Resources/Scripts/XUi/XUiSuperTower/Stages/Target/XUiGridSettleReward.lua new file mode 100644 index 00000000..73f0ec6b --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Stages/Target/XUiGridSettleReward.lua @@ -0,0 +1,70 @@ +local XUiGridSettleReward = XClass(nil, "XUiGridSettleReward") +local CSTextManagerGetText = CS.XTextManager.GetText + +function XUiGridSettleReward:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.GridRewardList = {} +end + +function XUiGridSettleReward:UpdateGrid(root, rewardId, index, rewardState, sTStage) + local panel + + if self.PanelComplete then + self.PanelComplete.gameObject:SetActiveEx(false) + end + if self.PanelGet then + self.PanelGet.gameObject:SetActiveEx(false) + end + if self.PanelLock then + self.PanelLock.gameObject:SetActiveEx(false) + end + + if rewardState == XDataCenter.SuperTowerManager.StageRewardState.Complete then + panel = self.PanelComplete + elseif rewardState == XDataCenter.SuperTowerManager.StageRewardState.CanGet then + panel = self.PanelGet + elseif rewardState == XDataCenter.SuperTowerManager.StageRewardState.Lock then + panel = self.PanelLock + end + + self:UpdatePanelReward(root, rewardId, index, sTStage, panel) +end + +function XUiGridSettleReward:UpdatePanelReward(root, rewardId, index, sTStage, panel) + local rewards = XRewardManager.GetRewardList(rewardId) + local gridObj = panel:GetObject("Grid256New") + local parentObj = panel:GetObject("Content") + + panel.gameObject:SetActiveEx(true) + gridObj.gameObject:SetActiveEx(false) + if rewards then + for i, item in pairs(rewards) do + local grid = self.GridRewardList[i] + if not grid then + local ui = CS.UnityEngine.Object.Instantiate(gridObj) + grid = XUiGridCommon.New(root, ui) + self.GridRewardList[i] = grid + end + grid:Refresh(item) + grid.Transform:SetParent(parentObj, false) + grid.GameObject:SetActiveEx(true) + end + + for i = #rewards + 1, #self.GridRewardList do + self.GridRewardList[i].GameObject:SetActiveEx(false) + end + end + + if sTStage:CheckIsMultiWave() then + local IsSingleTeam = sTStage:CheckIsSingleTeamMultiWave() + local txtNumObj = panel:GetObject("TxtNum") + local txtNameObj = panel:GetObject("TxtName") + local formatStr = index > 9 and "%d" or "0%d" + txtNumObj.text = string.format(formatStr,index) + txtNameObj.text = IsSingleTeam and CSTextManagerGetText("STMultiWaveRewardTitle") or CSTextManagerGetText("STMultiTeamRewardTitle") + end +end + +return XUiGridSettleReward \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Stages/Target/XUiGridTargetStageTeam.lua b/Resources/Scripts/XUi/XUiSuperTower/Stages/Target/XUiGridTargetStageTeam.lua new file mode 100644 index 00000000..9a93fa1e --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Stages/Target/XUiGridTargetStageTeam.lua @@ -0,0 +1,144 @@ +local XUiGridTargetStageTeamMember = require("XUi/XUiSuperTower/Stages/Target/XUiGridTargetStageTeamMember") +local XUiSuperTowerPluginGrid = require("XUi/XUiSuperTower/Plugins/XUiSuperTowerPluginGrid") +local CSTextManagerGetText = CS.XTextManager.GetText +local CSObjectInstantiate = CS.UnityEngine.Object.Instantiate +local DefaultElement = 0 +local IsomerElement = 6 +local XUiGridTargetStageTeam = XClass(nil, "XUiGridTargetStageTeam") + +function XUiGridTargetStageTeam:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.MemberGrids = {} + self.PluginGrids = {} + + XTool.InitUiObject(self) + self:SetButtonCallBack() + + self.GridDeployMember.gameObject:SetActiveEx(false) + self.GridSuperTowerCore.gameObject:SetActiveEx(false) +end + +function XUiGridTargetStageTeam:OnDestroy() + +end + +function XUiGridTargetStageTeam:SetButtonCallBack() + self.BtnLeader.CallBack = function() self:OnBtnLeaderClick() end + self.BtnCore.CallBack = function() self:OnSelectPulginClick() end + self.BtnConsume.CallBack = function() self:OnSelectPulginClick() end +end + +function XUiGridTargetStageTeam:UpdataGrid(stageIndex, stStage) + local stageId = stStage:GetStageId()[stageIndex] + self.Team = stageId and XDataCenter.SuperTowerManager.GetTeamByStageId(stageId) + self.STStage = stStage + self.StageIndex = stageIndex + + self:UpdateTeam() + self:UpdatePlugins() + self:UpdateInfo() +end + +function XUiGridTargetStageTeam:UpdateInfo() + self.TxtTitle.text = CSTextManagerGetText("STFightLoadingTeamText", self.StageIndex) + local requireAbility = self.STStage:GetStageAbilityByIndex(self.StageIndex) + self.TxtRequireAbility.text = requireAbility + if self.ImgTitleBgFight then--倾向 + local stageId = self.STStage:GetStageIdByIndex(self.StageIndex) + local element = DefaultElement + local recommendType = XFubenConfigs.GetStageRecommendCharacterType(stageId) + + if recommendType == XCharacterConfigs.CharacterType.Isomer then + element = IsomerElement + elseif recommendType == XCharacterConfigs.CharacterType.Normal then + element = XFubenConfigs.GetStageRecommendCharacterElement(stageId) or DefaultElement + end + + local icon = XSuperTowerConfigs.GetElementIconByKey(element) + self.ImgTitleBgFight:SetSprite(icon) + end +end + +function XUiGridTargetStageTeam:UpdateTeam() + local roleManager = XDataCenter.SuperTowerManager.GetRoleManager() + local memberEntityIdList = self.Team:GetEntityIds() + local memberNum = self.STStage:GetMemberCountByIndex(self.StageIndex) + + for index = 1, memberNum do + local grid = self.MemberGrids[index] + if not grid then + local go = CSObjectInstantiate(self.GridDeployMember, self.PanelDeployMembers) + grid = XUiGridTargetStageTeamMember.New(go) + self.MemberGrids[index] = grid + end + + local memberEntityId = memberEntityIdList[index] or 0 + local memberRole = roleManager:GetRole(memberEntityId) + grid:Refresh(self.StageIndex, memberRole, index, self.STStage) + + --蓝色放到第一位 + if index == 2 then + grid.Transform:SetAsFirstSibling() + end + + grid.GameObject:SetActiveEx(true) + end + + for index = memberNum + 1, #self.MemberGrids do + self.MemberGrids[index].GameObject:SetActiveEx(false) + end + + local captainId = self.Team:GetCaptainPosEntityId() or 0 + local captainRole = roleManager:GetRole(captainId) + self.TxtLeaderSkill.text = captainRole and captainRole:GetCaptainSkillDesc() or "" +end + +function XUiGridTargetStageTeam:UpdatePlugins() + local extraData = self.Team:GetExtraData() + local pluginList = extraData and extraData:GetPlugins() or {} + local IsPluginEmpty = extraData:GetIsEmpty() + self.PanelCoreContent.gameObject:SetActiveEx(not IsPluginEmpty) + self.BtnCore.gameObject:SetActiveEx(IsPluginEmpty) + + for index, plugin in pairs(pluginList) do + if plugin ~= 0 then + local grid = self.PluginGrids[index] + if not grid then + local go = CSObjectInstantiate(self.GridSuperTowerCore, self.PanelCoreContent) + grid = XUiSuperTowerPluginGrid.New(go) + self.PluginGrids[index] = grid + end + grid:RefreshData(plugin) + grid.GameObject:SetActiveEx(true) + end + end + for index = extraData:GetCurrentCapacity() + 1, #self.PluginGrids do + self.PluginGrids[index].GameObject:SetActiveEx(false) + end + +end + +function XUiGridTargetStageTeam:OnBtnLeaderClick() + local characterViewModelDic = {} + for pos, entityId in ipairs(self.Team:GetEntityIds()) do + characterViewModelDic[pos] = self:GetCharacterViewModelByEntityId(entityId) + end + XLuaUiManager.Open("UiBattleRoleRoomCaptain", characterViewModelDic, self.Team:GetCaptainPos(), function(newCaptainPos) + self.Team:UpdateCaptianPos(newCaptainPos) + self:UpdateTeam() + end) +end + +function XUiGridTargetStageTeam:GetCharacterViewModelByEntityId(id) + local roleManager = XDataCenter.SuperTowerManager.GetRoleManager() + local role = roleManager:GetRole(id) + if not role then return nil end + return role:GetCharacterViewModel() +end + +function XUiGridTargetStageTeam:OnSelectPulginClick() + XLuaUiManager.Open("UiSuperTowerChooseCore", self.STStage:GetStageIdByIndex(self.StageIndex)) +end + +return XUiGridTargetStageTeam \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Stages/Target/XUiGridTargetStageTeamMember.lua b/Resources/Scripts/XUi/XUiSuperTower/Stages/Target/XUiGridTargetStageTeamMember.lua new file mode 100644 index 00000000..16ac2f7d --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Stages/Target/XUiGridTargetStageTeamMember.lua @@ -0,0 +1,73 @@ +local XUiGridTargetStageTeamMember = XClass(nil, "XUiGridTargetStageTeamMember") + +local CONDITION_COLOR = { + [true] = CS.UnityEngine.Color.white, + [false] = CS.UnityEngine.Color.red, +} + +--位置对应的颜色框 +local MEMBER_POS_COLOR = { + [1] = "ImgRed", + [2] = "ImgBlue", + [3] = "ImgYellow", +} + +function XUiGridTargetStageTeamMember:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + + self.BtnClick.CallBack = function() self:OnMemberClick() end + + self.StageId = nil +end + +function XUiGridTargetStageTeamMember:Refresh(stageIndex, memberRole, memberPos, stStage) + local stageId = stStage:GetStageId()[stageIndex] + local team = stageId and XDataCenter.SuperTowerManager.GetTeamByStageId(stageId) + self.MemberPos = memberPos + self.Team = team + self.StageId = stageId + + local leaderIndex = team:GetCaptainPos() + self.ImgLeaderTag.gameObject:SetActiveEx(memberPos == leaderIndex) + + local firstFightIndex = team:GetFirstFightPos() + self.ImgFirstRole.gameObject:SetActiveEx(memberPos == firstFightIndex) + + for i, goName in pairs(MEMBER_POS_COLOR) do + self[goName].gameObject:SetActiveEx(memberPos == i) + end + + local isEmpty = not memberRole + self.PanelEmpty.gameObject:SetActiveEx(isEmpty) + self.PanelNotEmpty.gameObject:SetActiveEx(not isEmpty) + self.RImgRoleHead.gameObject:SetActiveEx(not isEmpty) + if not isEmpty then + local isRobot = memberRole:GetIsRobot() + self.PanelTrial.gameObject:SetActiveEx(isRobot) + + local ability = memberRole:GetAbility() + self.TxtAbility.text = ability + + local requireAbility = stStage:GetStageAbilityByIndex(stageIndex) + self.TxtAbility.color = CONDITION_COLOR[ability >= requireAbility] + + local headIcon = memberRole:GetSmallHeadIcon() + self.RImgRoleHead:SetRawImage(headIcon) + + local IsInDult = memberRole:GetIsInDult() + self.ImgTedianyq.gameObject:SetActiveEx(IsInDult) + end +end + +function XUiGridTargetStageTeamMember:OnMemberClick() + XLuaUiManager.Open("UiBattleRoomRoleDetail", + self.StageId, + self.Team, + self.MemberPos, + require("XUi/XUiSuperTower/Room/XUiSuperTowerBattleRoomRoleDetail")) +end + +return XUiGridTargetStageTeamMember \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Stages/Target/XUiSuperTowerDeploy.lua b/Resources/Scripts/XUi/XUiSuperTower/Stages/Target/XUiSuperTowerDeploy.lua new file mode 100644 index 00000000..df9fa10d --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Stages/Target/XUiSuperTowerDeploy.lua @@ -0,0 +1,146 @@ +--=========================== +--超级爬塔多波关卡准备界面 +--=========================== +local XUiGridTargetStageTeam = require("XUi/XUiSuperTower/Stages/Target/XUiGridTargetStageTeam") +local XUiSuperTowerDeploy = XLuaUiManager.Register(XLuaUi, "UiSuperTowerDeploy") +local CSTextManagerGetText = CS.XTextManager.GetText +local CSObjectInstantiate = CS.UnityEngine.Object.Instantiate +local StartIndex = 1 +function XUiSuperTowerDeploy:OnStart(stStage) + self.STStage = stStage + self:SetButtonCallBack() + self.TeanGrids = {} + self.GridDeployTeam.gameObject:SetActiveEx(false) + self:ClearTeamExtraData() + local endTime = XDataCenter.SuperTowerManager.GetActivityEndTime() + self:SetAutoCloseInfo(endTime, function(isClose) + if isClose then + XDataCenter.SuperTowerManager.HandleActivityEndTime() + end + end) +end + +function XUiSuperTowerDeploy:OnDestroy() + +end + +function XUiSuperTowerDeploy:OnEnable() + XUiSuperTowerDeploy.Super.OnEnable(self) + self:UpdatePanel() +end + +function XUiSuperTowerDeploy:OnDisable() + XUiSuperTowerDeploy.Super.OnDisable(self) +end + +function XUiSuperTowerDeploy:SetButtonCallBack() + self.BtnBack.CallBack = function() + self:OnBtnBackClick() + end + self.BtnMainUi.CallBack = function() + self:OnBtnMainUiClick() + end + self.BtnFight.CallBack = function() + self:OnBtnFightClick() + end + self.BtnAutoTeam.CallBack = function() + self:OnBtnAutoTeamClick() + end + self.BtnQuickDeploy.CallBack = function() + self:OnBtnQuickDeployClick() + end + self.BtnAutoPulgin.CallBack = function() + self:OnBtnAutoPulginClick() + end +end + +function XUiSuperTowerDeploy:UpdatePanel() + self:UpdatePaneTeam() +end + +function XUiSuperTowerDeploy:UpdatePaneTeam() + local stageIdList = self.STStage:GetStageId() + + for index,stageId in pairs(stageIdList) do + local grid = self.TeanGrids[index] + if not grid then + local go = CSObjectInstantiate(self.GridDeployTeam, self.PanelTeamContent) + grid = XUiGridTargetStageTeam.New(go) + self.TeanGrids[index] = grid + end + grid:UpdataGrid(index, self.STStage) + grid.GameObject:SetActiveEx(true) + end + + for index = #stageIdList + 1, #self.TeanGrids do + self.TeanGrids[index].GameObject:SetActiveEx(false) + end +end + +function XUiSuperTowerDeploy:OnBtnBackClick() + self:Close() +end + +function XUiSuperTowerDeploy:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiSuperTowerDeploy:OnBtnFightClick() + if not XDataCenter.SuperTowerManager.CheckActivityIsInTime() then + XUiManager.TipText("STOverTimeHint") + self:OnBtnMainUiClick() + return + end + + --检查队伍列表中所有需要的队伍是否均有队长/首发 + local allHasCaptain, allHasFirstPos = XDataCenter.SuperTowerManager.CheckTeamListAllHasCaptainAndFirstPos(self.STStage) + if not allHasCaptain then + XUiManager.TipText("STMultiTeamTeamListNoCaptain") + return + end + if not allHasFirstPos then + XUiManager.TipText("STMultiTeamTeamListNoFirstPos") + return + end + + local targetStageId = self.STStage:GetStageId()[StartIndex] + local teamList = {} + for index,stageId in pairs(self.STStage:GetStageId() or {}) do + local team = stageId and XDataCenter.SuperTowerManager.GetTeamByStageId(stageId) + teamList[index] = team + end + + XDataCenter.SuperTowerManager.GetStageManager():ResetTempProgress() + XDataCenter.SuperTowerManager.GetTeamManager():SetTargetFightTeam(teamList, targetStageId, function() + XDataCenter.SuperTowerManager.EnterFight(targetStageId) + self:Close() + end) + +end + +function XUiSuperTowerDeploy:OnBtnAutoTeamClick() + XDataCenter.SuperTowerManager.AutoTeam(self.STStage) + self:UpdatePanel() +end + +function XUiSuperTowerDeploy:OnBtnQuickDeployClick() + XLuaUiManager.Open("UiSuperTowerQuickDeploy", self.STStage, function () + self:UpdatePanel() + end) +end + +function XUiSuperTowerDeploy:OnBtnAutoPulginClick() + XDataCenter.SuperTowerManager.AutoPulgin(self.STStage) + self:UpdatePanel() +end + +function XUiSuperTowerDeploy:ClearTeamExtraData() + --获取目标关卡的所有关卡 + local stageIds = self.STStage:GetStageId() + --获取所有对应队伍,清除其插件纪录 + for index, stageId in pairs(stageIds) do + local team = XDataCenter.SuperTowerManager.GetTeamByStageId(stageId) + local extraData = team:GetExtraData() + if extraData then extraData:Clear() end + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Stages/Target/XUiSuperTowerLoading.lua b/Resources/Scripts/XUi/XUiSuperTower/Stages/Target/XUiSuperTowerLoading.lua new file mode 100644 index 00000000..0e029c02 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Stages/Target/XUiSuperTowerLoading.lua @@ -0,0 +1,57 @@ +local XUiSuperTowerLoading = XLuaUiManager.Register(XLuaUi, "UiSuperTowerLoading") +local CSTextManagerGetText = CS.XTextManager.GetText +local CHARACTER_NUM = 3 + +local ANIMATION_OPEN = "UiBfrtInfoBegan%d" +local ANIMATION_LOOP = "UiBfrtInfoLoop%d" + +local ANIMATION_PANEL = { + "PanelStageList01", + "PanelStageList02", + "PanelStageList03", + "PanelStageList04", + "PanelStageList05", +} + +function XUiSuperTowerLoading:OnStart(stStage, stageIndex) + self.CurIndex = stageIndex + + for index, name in pairs(ANIMATION_PANEL) do + self[name].gameObject:SetActiveEx(index == stageIndex) + end + + local roleManager = XDataCenter.SuperTowerManager.GetRoleManager() + local stageId = stStage:GetStageId()[stageIndex] + local team = XDataCenter.SuperTowerManager.GetTeamByStageId(stageId) + local characterIds = XDataCenter.SuperTowerManager.GetCharacterIdListByTeamEntity(team) + + for index = 1, CHARACTER_NUM do + local characterId = characterIds[index] + if XTool.IsNumberValid(characterId) and characterId > 0 then + self["RImgCharIcon" .. index]:SetRawImage(XDataCenter.CharacterManager.GetCharBigRoundnessNotItemHeadIcon(characterId)) + self["PanelCharIcon" .. index].gameObject:SetActiveEx(true) + else + self["PanelCharIcon" .. index].gameObject:SetActiveEx(false) + end + end + + self.TxtZhangjie.text = stStage:GetSimpleName() + self.TxtGroupName.text = stStage:GetStageName() + self.TxtName.text = CsXTextManagerGetText("STFightLoadingTeamText", stageIndex) + + self:PlayBeginAnimation() +end + +function XUiSuperTowerLoading:PlayBeginAnimation() + local endCb = function() + self:PlayLoopAnimation() + end + + local animName = string.format(ANIMATION_OPEN, self.CurIndex) + self:PlayAnimation(animName, endCb) +end + +function XUiSuperTowerLoading:PlayLoopAnimation() + local animName = string.format(ANIMATION_LOOP, self.CurIndex) + self:PlayAnimation(animName, nil, nil, CS.UnityEngine.Playables.DirectorWrapMode.Loop) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Stages/Target/XUiSuperTowerQuickDeploy.lua b/Resources/Scripts/XUi/XUiSuperTower/Stages/Target/XUiSuperTowerQuickDeploy.lua new file mode 100644 index 00000000..d62e1798 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Stages/Target/XUiSuperTowerQuickDeploy.lua @@ -0,0 +1,184 @@ +--=========================== +--超级爬塔多波关卡快速设置界面 +--=========================== +local XUiSuperTowerQuickDeploy = XLuaUiManager.Register(XLuaUi, "UiSuperTowerQuickDeploy") +local XUiGridSTQuickDeployTeam = require("XUi/XUiSuperTower/Stages/Target/XUiGridSTQuickDeployTeam") +local XTeam = require("XEntity/XTeam/XTeam") +local CSTextManagerGetText = CS.XTextManager.GetText +local CSObjectInstantiate = CS.UnityEngine.Object.Instantiate +function XUiSuperTowerQuickDeploy:OnStart(stStage, callBack) + self.STStage = stStage + self.CallBack = callBack + self:SetButtonCallBack() + self.TeamGridList = {} + self:InitPanel() +end + +function XUiSuperTowerQuickDeploy:OnDestroy() + +end + +function XUiSuperTowerQuickDeploy:OnEnable() + self:UpdatePanel() +end + +function XUiSuperTowerQuickDeploy:OnDisable() + self.OldStageId = nil + self.OldPos = nil + + if self.LastSelectGrid then + self.LastSelectGrid:SetSelect(false) + self.LastSelectGrid = nil + end +end + +function XUiSuperTowerQuickDeploy:SetButtonCallBack() + self.BtnConfirm.CallBack = function() + self:OnBtnConfirmClick() + end + self.BtnClose.CallBack = function() + self:OnBtnCloseClick() + end +end + +function XUiSuperTowerQuickDeploy:InitPanel() + self.TeamList = {} + self.TmpTeamList = {} + local stageIdList = self.STStage:GetStageId() + for index, stageId in ipairs(stageIdList) do + local team = XDataCenter.SuperTowerManager.GetTeamByStageId(stageId) + local tmpTeam = XTeam.New() + tmpTeam:CopyData(team) + + self.TeamList[index] = team + self.TmpTeamList[index] = tmpTeam + end + self.GridQuickDeployTeam.gameObject:SetActiveEx(false) +end + +function XUiSuperTowerQuickDeploy:UpdatePanel() + local stageIdList = self.STStage:GetStageId() + for index, stageId in ipairs(stageIdList) do + local teamGrid = self.TeamGridList[index] + if not teamGrid then + local go = CSObjectInstantiate(self.GridQuickDeployTeam, self.PanelFormationTeamContent) + teamGrid = XUiGridSTQuickDeployTeam.New(go, function(grid, pos, stageIndex) + self:memberClick(grid, pos, stageIndex) + end) + self.TeamGridList[index] = teamGrid + end + local tmpTeam = self.TmpTeamList[index] + teamGrid:Refresh(index, self.STStage, tmpTeam) + teamGrid.GameObject:SetActiveEx(true) + end + for i = #stageIdList + 1, #self.TeamGridList do + self.TeamGridList[i].GameObject:SetActiveEx(false) + end + +end + +function XUiSuperTowerQuickDeploy:memberClick(grid, pos, stageIndex) + + local oldStageIndex = self.OldStageIndex + local oldPos = self.OldPos + + local sucCb = function() + self:UpdatePanel() + + grid:ShowEffect() + self.LastSelectGrid:ShowEffect() + self.LastSelectGrid:SetSelect(false) + self.LastSelectGrid = nil + + self.OldStageIndex = nil + self.OldPos = nil + end + + local failCb = function() + if self.LastSelectGrid then + self.LastSelectGrid:SetSelect(false) + end + self.LastSelectGrid = grid + + self.LastSelectGrid:SetSelect(true) + self.OldStageIndex = stageIndex + self.OldPos = pos + end + + self:SwapTeamPos(oldStageIndex, oldPos, stageIndex, pos, sucCb, failCb) +end + +function XUiSuperTowerQuickDeploy:SwapTeamPos(oldStageIndex, oldPos, newStageIndex, newPos, sucCb, failCb) + if not oldStageIndex then failCb() return false end + + if oldStageIndex == newStageIndex and oldPos == newPos then failCb() return false end + + local roleManager = XDataCenter.SuperTowerManager.GetRoleManager() + local oldTeam = self.TmpTeamList[oldStageIndex] + local oldMemberId = oldTeam:GetEntityIdByTeamPos(oldPos) or 0 + local oldMember = roleManager:GetRole(oldMemberId) + local newTeam = self.TmpTeamList[newStageIndex] + local newMemberId = newTeam:GetEntityIdByTeamPos(newPos) or 0 + local newMember = roleManager:GetRole(newMemberId) + + if not oldMember and not newMember then failCb() return false end + + local oldCharacterType = oldMember and oldMember:GetCharacterType() or 0 + local newCharacterType = newMember and newMember:GetCharacterType() or 0 + + local swapFunc = function() + if self:ExistDifferentCharacterType(newTeam, oldCharacterType) then + newTeam:Clear() + end + if self:ExistDifferentCharacterType(oldTeam, newCharacterType) then + oldTeam:Clear() + end + + oldTeam:UpdateEntityTeamPos(newMemberId, oldPos, true) + newTeam:UpdateEntityTeamPos(oldMemberId, newPos, true) + + sucCb() + end + + if self:ExistDifferentCharacterType(newTeam, oldCharacterType) + or self:ExistDifferentCharacterType(oldTeam, newCharacterType) + then + --队伍中已经存在其他类型的角色(构造体/授格者) + local content = CSXTextManagerGetText("TeamCharacterTypeNotSame") + XUiManager.DialogTip(nil, content, XUiManager.DialogType.Normal, nil, swapFunc) + else + swapFunc() + end +end + +function XUiSuperTowerQuickDeploy:ExistDifferentCharacterType(team, characterType) + local roleManager = XDataCenter.SuperTowerManager.GetRoleManager() + local entityIdList = team:GetEntityIds() + if characterType > 0 then + for _,id in pairs(entityIdList) do + local member = roleManager:GetRole(id) + if member and member:GetCharacterType() ~= characterType then + return true + end + end + end + return false +end + +function XUiSuperTowerQuickDeploy:OnBtnConfirmClick() + local stageIdList = self.STStage:GetStageId() + for index, stageId in ipairs(stageIdList) do + local team = self.TeamList[index] + local tmpTeam = self.TmpTeamList[index] + team:CopyData(tmpTeam) + end + + self:Close() + if self.CallBack then + self.CallBack() + end +end + +function XUiSuperTowerQuickDeploy:OnBtnCloseClick() + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Stages/Target/XUiSuperTowerSettleWin.lua b/Resources/Scripts/XUi/XUiSuperTower/Stages/Target/XUiSuperTowerSettleWin.lua new file mode 100644 index 00000000..64dc02dc --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Stages/Target/XUiSuperTowerSettleWin.lua @@ -0,0 +1,173 @@ +--=========================== +--超级爬塔多波关卡详情 +--=========================== +local XUiSuperTowerSettleWin = XLuaUiManager.Register(XLuaUi, "UiSuperTowerSettleWin") +local XUiGridSettleReward = require("XUi/XUiSuperTower/Stages/Target/XUiGridSettleReward") +local XUiSuperTowerPluginGrid = require("XUi/XUiSuperTower/Plugins/XUiSuperTowerPluginGrid") +local CSTextManagerGetText = CS.XTextManager.GetText +local CSObjectInstantiate = CS.UnityEngine.Object.Instantiate +function XUiSuperTowerSettleWin:OnStart(stStage, pluginList, tempProgress, battledTeamList) + self.STStage = stStage + self.PluginList = pluginList + self.TempProgress = tempProgress + self.BattledTeamList = battledTeamList + self.GridItemMultiList = {} + self.GridItemSingleList = {} + self.PanelItemInfo:GetObject("GridItemMulti").gameObject:SetActiveEx(false) + self.PanelItemInfo:GetObject("GridItemSingle").gameObject:SetActiveEx(false) + self:SetButtonCallBack() + self:InitPanelPlugin() + local endTime = XDataCenter.SuperTowerManager.GetActivityEndTime() + self:SetAutoCloseInfo(endTime, function(isClose) + if isClose then + XDataCenter.SuperTowerManager.HandleActivityEndTime() + end + end) +end + +function XUiSuperTowerSettleWin:OnDestroy() + +end + +function XUiSuperTowerSettleWin:OnEnable() + XUiSuperTowerSettleWin.Super.OnEnable(self) + self:UpdatePanel() +end + +function XUiSuperTowerSettleWin:OnDisable() + XUiSuperTowerSettleWin.Super.OnDisable(self) +end + +function XUiSuperTowerSettleWin:SetButtonCallBack() + self.BtnNo.CallBack = function() + self:OnBtnCancelClick() + end + self.BtnYes.CallBack = function() + self:OnBtnGetRewardClick() + end + self.BtnClose.CallBack = function() + self:OnBtnCloseClick() + end +end + +function XUiSuperTowerSettleWin:OnBtnGetRewardClick() + local confirmCb = function() + XDataCenter.SuperTowerManager.ConfirmTargetResultRequest(self.STStage:GetId(), function (rewardGoodsList) + self:ClearBattledTeamPlugin() + XUiManager.OpenUiObtain(rewardGoodsList, nil, function() + XDataCenter.SuperTowerManager.CheckPopupWindow(function() + self:OnBtnCloseClick() + end) + end) + end) + end + + local desc = CSTextManagerGetText("STSettleConfirmHint") + CsXUiManager.Instance:Open("UiDialog", CSTextManagerGetText("TipTitle"), desc, + XUiManager.DialogType.Normal, nil, confirmCb) +end + +function XUiSuperTowerSettleWin:OnBtnCancelClick() + local confirmCb = function() + self:Close() + end + + local desc = CSTextManagerGetText("STSettleCancelHint") + CsXUiManager.Instance:Open("UiDialog", CSTextManagerGetText("TipTitle"), desc, + XUiManager.DialogType.Normal, nil, confirmCb) +end + + +function XUiSuperTowerSettleWin:OnBtnCloseClick() + self:Close() +end + +function XUiSuperTowerSettleWin:ClearBattledTeamPlugin() + for _,team in pairs(self.BattledTeamList or {}) do + local extraData = team:GetExtraData() + extraData:Clear() + end +end + +function XUiSuperTowerSettleWin:InitPanelPlugin() + self.DynamicTable = XDynamicTableNormal.New(self.PanelPlugin:GetObject("PanelPluginScrollView")) + self.DynamicTable:SetProxy(XUiSuperTowerPluginGrid) + self.DynamicTable:SetDelegate(self) + self.PanelPlugin:GetObject("GridSuperTowerCore").gameObject:SetActiveEx(false) +end + +function XUiSuperTowerSettleWin:UpdatePanel() + self:UpdateInfo() + self:UpdatePanelItem() + self:UpdatePanelPlugin() +end + +function XUiSuperTowerSettleWin:UpdateInfo() + self.TxtName.text = self.STStage:GetFullStageName() + self.BtnNo.gameObject:SetActiveEx(self:IsNewProgress()) + self.BtnYes.gameObject:SetActiveEx(self:IsNewProgress()) + self.BtnClose.gameObject:SetActiveEx(not self:IsNewProgress()) +end + +function XUiSuperTowerSettleWin:UpdatePanelItem() + local gridMultiObj = self.PanelItemInfo:GetObject("GridItemMulti") + local gridSingleObj = self.PanelItemInfo:GetObject("GridItemSingle") + local contentObj = self.PanelItemInfo:GetObject("Content") + for index,rewardId in pairs(self.STStage:GetRewardId()) do + local rewardState + if index <= self.STStage:GetCurrentProgress() then + rewardState = XDataCenter.SuperTowerManager.StageRewardState.Complete + elseif index > self.STStage:GetCurrentProgress() and index <= self.TempProgress then + rewardState = XDataCenter.SuperTowerManager.StageRewardState.CanGet + else + rewardState = XDataCenter.SuperTowerManager.StageRewardState.Lock + end + + if self.STStage:CheckIsMultiWave() then + self:UpdateGrid(index, rewardId, rewardState, gridMultiObj, contentObj, self.GridItemMultiList, self.STStage) + else + self:UpdateGrid(index, rewardId, rewardState, gridSingleObj, contentObj, self.GridItemSingleList, self.STStage) + end + end +end + +function XUiSuperTowerSettleWin:UpdateGrid(index, rewardId, rewardState, gridObj, contentObj, gridList, IsMulti) + local grid = gridList[index] + if not grid then + local obj = CSObjectInstantiate(gridObj, contentObj) + grid = XUiGridSettleReward.New(obj) + gridList[index] = grid + end + grid.GameObject:SetActiveEx(true) + grid:UpdateGrid(self, rewardId, index, rewardState, IsMulti) +end + +function XUiSuperTowerSettleWin:UpdatePanelPlugin() + local text = CSTextManagerGetText("STFightFinishUsePluginText") + local hint + if self:IsNewProgress() then + hint = CSTextManagerGetText("STFightFinishUsePluginHint") + else + hint = "" + end + self.PanelPlugin:GetObject("TxtListName").text = text + self.PanelPlugin:GetObject("TxtListHint").text = hint + self.PanelPlugin:GetObject("PanelPluginNone").gameObject:SetActiveEx(#self.PluginList == 0 or not self:IsNewProgress()) + + self.PanelPlugin:GetObject("TxtNone").text = (self:IsNewProgress() and #self.PluginList == 0) and + CSTextManagerGetText("STNotSelectPlugin") or CSTextManagerGetText("STNotUsePlugin") + + local dataSource = self:IsNewProgress() and self.PluginList or {} + self.DynamicTable:SetDataSource(dataSource) + self.DynamicTable:ReloadDataASync(1) +end + +function XUiSuperTowerSettleWin:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:RefreshData(self.PluginList[index]) + end +end + +function XUiSuperTowerSettleWin:IsNewProgress() + return self.TempProgress > self.STStage:GetCurrentProgress() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiSTTierPrepare.lua b/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiSTTierPrepare.lua new file mode 100644 index 00000000..dcf097a3 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiSTTierPrepare.lua @@ -0,0 +1,126 @@ +--=========================== +--超级爬塔 爬塔进入关卡准备 页面 +--=========================== +local XUiSTTierPrepare = XLuaUiManager.Register(XLuaUi, "UiSuperTowerStageDetail04") +local SHOW_TYPE = { --显示类型 + Start = 1, --开始爬塔 + Continue = 2 --继续爬塔 + } +--子面板序号 +local CHILD_PANEL_INDEX = { + Enhance = 1, --爬塔增益面板 + Plugins = 2, --插件掉落面板 + Progress = 3, --进度面板 + Score = 4, --荣誉分数面板 + Team = 5, --队伍面板 +} +--子面板脚本地址 +local CHILD_PANEL_SCRIPT_PATH = "XUi/XUiSuperTower/Stages/Tier/XUiStTp" + +function XUiSTTierPrepare:OnAwake() + XTool.InitUiObject(self) +end + +function XUiSTTierPrepare:InitChildPanelControl() + local script = require("XUi/XUiSuperTower/Common/XUiSTMainPage") + self.ChildPanelControl = script.New(self) +end + +function XUiSTTierPrepare:InitBtns() + self.BtnFight.CallBack = function() self:OnBtnFightClick() end + self.BtnDrop.CallBack = function() self:OnBtnDropClick() end + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + self:BindHelpBtn(self.BtnHelp, "SuperTowerTierHelp") +end + +function XUiSTTierPrepare:OnStart(theme) + self.Theme = theme + self:InitChildPanelControl() + self:InitPanelAssets() + self.ChildPanelControl:RegisterChildPanels(CHILD_PANEL_INDEX, CHILD_PANEL_SCRIPT_PATH) + self:InitBtns() + self:SetActivityTimeLimit() +end + +function XUiSTTierPrepare:OnEnable() + XUiSTTierPrepare.Super.OnEnable(self) + self.ShowType = self.Theme:CheckTierIsPlaying() and SHOW_TYPE.Continue or SHOW_TYPE.Start + self:ShowPanel() +end + +function XUiSTTierPrepare:InitPanelAssets() + self.AssetActivityPanel = XUiPanelActivityAsset.New(self.PanelSpecialTool) + local itemIds = XSuperTowerConfigs.GetMainAssetsPanelItemIds() + XDataCenter.ItemManager.AddCountUpdateListener(itemIds, function() + self.AssetActivityPanel:Refresh(itemIds) + end, self.AssetActivityPanel) + self.AssetActivityPanel:Refresh(itemIds) +end + +function XUiSTTierPrepare:ShowPanel() + self:SetIconAlphaByShowType() + self:SetBtnsByType() + self:ShowChildPanelsByType() +end + +function XUiSTTierPrepare:SetIconAlphaByShowType() + self.RImgIcon.gameObject:SetActiveEx(self:GetIsStart()) + if self.ImgThemeIndex then self.ImgThemeIndex:SetSprite(XUiHelper.GetClientConfig("SuperTowerThemeIndexLogo" .. self.Theme:GetIndex(), XUiHelper.ClientConfigType.String)) end +end + +function XUiSTTierPrepare:SetBtnsByType() + self.BtnFight:SetName(self:GetIsStart() and CS.XTextManager.GetText("STStartTier") or CS.XTextManager.GetText("STContinueTier")) + self.BtnDrop.gameObject:SetActiveEx(not self:GetIsStart()) +end + +function XUiSTTierPrepare:ShowChildPanelsByType() + local showIndex = { + [CHILD_PANEL_INDEX.Enhance] = true, --爬塔增益面板 + [CHILD_PANEL_INDEX.Plugins] = true, --插件掉落面板 + [CHILD_PANEL_INDEX.Progress] = true, --进度面板 + [CHILD_PANEL_INDEX.Score] = true, --荣誉分数面板 + [CHILD_PANEL_INDEX.Team] = not self:GetIsStart(), --队伍面板 + } + self.ChildPanelControl:ShowChildPanel(showIndex) +end + +function XUiSTTierPrepare:OnBtnBackClick() + self:Close() +end + +function XUiSTTierPrepare:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiSTTierPrepare:GetIsStart() + return self.ShowType == SHOW_TYPE.Start +end + +function XUiSTTierPrepare:OnBtnFightClick() + local isStart = self:GetIsStart() + if isStart then + XLuaUiManager.Open("UiBattleRoleRoom", XDataCenter.SuperTowerManager.GetTeamByStageType(XDataCenter.SuperTowerManager.StageType.LllimitedTower), + self.Theme:GetCurrentTierStageId() + , require("XUi/XUiSuperTower/Room/XUiSuperTowerBattleRoleRoom")) + else + local stageConfig = XDataCenter.FubenManager.GetStageCfg(self.Theme:GetCurrentTierStageId()) + local isAssist = false + local challengeCount = 1 + XDataCenter.FubenManager.EnterFight(stageConfig, nil, isAssist, challengeCount) + end +end + +function XUiSTTierPrepare:OnBtnDropClick() + XLuaUiManager.Open("UiSuperTowerFubenCloseTip", self.Theme) +end + +function XUiSTTierPrepare:SetActivityTimeLimit() + -- 自动关闭 + local endTime = XDataCenter.SuperTowerManager.GetActivityEndTime() + self:SetAutoCloseInfo(endTime, function(isClose) + if isClose then + XDataCenter.SuperTowerManager.HandleActivityEndTime() + end + end) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTdDynamicTablePanel.lua b/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTdDynamicTablePanel.lua new file mode 100644 index 00000000..e5fe3b3e --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTdDynamicTablePanel.lua @@ -0,0 +1,91 @@ +local Base = require("XUi/XUiSuperTower/Common/XUiSTChildPanel") +--===================== +--爬塔掉落页面动态列表面板 +--===================== +local XUiStTdDynamicTablePanel = XClass(Base, "XUiStTdDynamicTablePanel") +local SHOW_TYPE = { + Enhance = 1, --增益页面 + Plugin = 2, --插件掉落页面 +} +function XUiStTdDynamicTablePanel:InitPanel() + self:InitDynamicTable() +end + +function XUiStTdDynamicTablePanel:InitDynamicTable() + local GridProxy = require("XUi/XUiSuperTower/Plugins/XUiSuperTowerMixGrid") + self.DynamicTable = XDynamicTableNormal.New(self.GameObject) + self.DynamicTable:SetProxy(GridProxy) + self.DynamicTable:SetDelegate(self) +end + +--============= +--动态列表事件 +--============= +function XUiStTdDynamicTablePanel:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(grid.DynamicGrid.gameObject, function(mixGrid) self:OnGridClick(mixGrid) end) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_RELOAD_COMPLETED then + self:SetFirstGridActive() --每次重新加载列表时默认选择第一个显示 + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + if self.DataList and self.DataList[index] then + grid:RefreshCfg(self:GetDataCfg(self.DataList[index])) + grid:SetIndex(index) + if self.RootUi.ShowType == SHOW_TYPE.Enhance then + grid:SetFloorLock(not self.DataList[index].IsExist) + grid:SetLockText(CS.XTextManager.GetText("STTdEnhanceLock")) + elseif self.RootUi.ShowType == SHOW_TYPE.Plugin then + grid:SetFloorLock(not self.DataList[index].IsExist) + grid:SetLockText(CS.XTextManager.GetText("STTdPluginLock", self.DataList[index].Level)) + end + if self.SelectIndex == index then + grid:SetActiveStatus(true) + else + grid:SetActiveStatus(false) + end + end + end +end + +function XUiStTdDynamicTablePanel:GetDataCfg(data) + if self.RootUi.ShowType == SHOW_TYPE.Enhance then + return XSuperTowerConfigs.GetEnhanceCfgById(data.EnhanceId) + elseif self.RootUi.ShowType == SHOW_TYPE.Plugin then + return XSuperTowerConfigs.GetPluginCfgById(data.PluginId) + end +end + +function XUiStTdDynamicTablePanel:Refresh() + self.SelectIndex = nil + self.SelectGrid = nil + self:SetList() +end + +function XUiStTdDynamicTablePanel:SetList() + if self.RootUi.ShowType == SHOW_TYPE.Enhance then + self.DataList = self.RootUi.Theme:GetTierEnhanceDropShowList(self.RootUi.ShowAll) + elseif self.RootUi.ShowType == SHOW_TYPE.Plugin then + self.DataList = self.RootUi.Theme:GetTierPluginDropShowList(true) + end + self.DynamicTable:SetDataSource(self.DataList) + self.DynamicTable:ReloadDataASync(1) +end + +function XUiStTdDynamicTablePanel:OnGridClick(grid) + if self.SelectIndex ~= grid.Index then + if self.SelectGrid then self.SelectGrid:SetActiveStatus(false) end + self.SelectGrid = grid + self.SelectIndex = grid.Index + self.SelectGrid:SetActiveStatus(true) + end + self.RootUi:OnSelectGrid(grid.ItemCfg) +end +--================= +--每次刷新页签默认选取第一个插件显示 +--================= +function XUiStTdDynamicTablePanel:SetFirstGridActive() + local grid = self.DynamicTable:GetGridByIndex(1) + if grid then + self:OnGridClick(grid) + end +end +return XUiStTdDynamicTablePanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTdInfoPanel.lua b/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTdInfoPanel.lua new file mode 100644 index 00000000..a52902d5 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTdInfoPanel.lua @@ -0,0 +1,26 @@ +local Base = require("XUi/XUiSuperTower/Common/XUiSTChildPanel") +--===================== +--爬塔掉落页面详细信息面板 +--===================== +local XUiStTdInfoPanel = XClass(Base, "XUiStTdInfoPanel") + +function XUiStTdInfoPanel:InitPanel() + local mixGridScript = require("XUi/XUiSuperTower/Plugins/XUiSuperTowerMixGrid") + self.Grid = mixGridScript.New(self.GridItem) +end + +function XUiStTdInfoPanel:OnSelectGrid(cfg) + self.ItemCfg = cfg + self:ShowPanel() +end + +function XUiStTdInfoPanel:Refresh() + self:HidePanel() +end + +function XUiStTdInfoPanel:OnShowPanel() + self.Grid:RefreshCfg(self.ItemCfg) + self.TxtDecs.text = self.ItemCfg.Description +end + +return XUiStTdInfoPanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTdTabPanel.lua b/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTdTabPanel.lua new file mode 100644 index 00000000..eca1bcf0 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTdTabPanel.lua @@ -0,0 +1,43 @@ +local Base = require("XUi/XUiSuperTower/Common/XUiSTChildPanel") +local SHOW_TYPE = { + Enhance = 1, --增益页面 + Plugin = 2, --插件掉落页面 +} +local TYPE_NAME = { + [SHOW_TYPE.Enhance] = "Enhance", + [SHOW_TYPE.Plugin] = "Plugin", + } +--===================== +--爬塔掉落页面页签面板 +--===================== +local XUiStTdTabPanel = XClass(Base, "XUiStTdTabPanel") + +function XUiStTdTabPanel:InitPanel() + self:InitBtnGroup() +end + +function XUiStTdTabPanel:InitBtnGroup() + local btns = {} + btns[SHOW_TYPE.Enhance] = self.BtnEnhance + btns[SHOW_TYPE.Plugin] = self.BtnPlugin + self.BtnGroupTab:Init(btns, function(index) self:SelectIndex(index) end) +end + +function XUiStTdTabPanel:SelectIndex(index) + local func = self["OnClick" .. TYPE_NAME[index]] + if func then func(self) end +end + +function XUiStTdTabPanel:OnClickEnhance() + self.RootUi:ShowEnhance() +end + +function XUiStTdTabPanel:OnClickPlugin() + self.RootUi:ShowPlugin() +end + +function XUiStTdTabPanel:OnShowPanel() + self.BtnGroupTab:SelectIndex(self.RootUi.ShowType) +end + +return XUiStTdTabPanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTdTitlePanel.lua b/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTdTitlePanel.lua new file mode 100644 index 00000000..e2d099fa --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTdTitlePanel.lua @@ -0,0 +1,24 @@ +local Base = require("XUi/XUiSuperTower/Common/XUiSTChildPanel") +--===================== +--爬塔掉落页面标题面板 +--===================== +local XUiStTdTitlePanel = XClass(Base, "XUiStTdTitlePanel") +local SHOW_TYPE = { + Enhance = 1, --增益页面 + Plugin = 2, --插件掉落页面 +} +local TYPE_NAME = { + [SHOW_TYPE.Enhance] = "Enhance", + [SHOW_TYPE.Plugin] = "Plugin", +} + +function XUiStTdTitlePanel:OnShowPanel() + self:Refresh() +end + +function XUiStTdTitlePanel:Refresh() + self.TxtTitleMain.text = CS.XTextManager.GetText("STTd".. TYPE_NAME[self.RootUi.ShowType] .. "TitleMain") + self.TxtTitleSub.text = CS.XTextManager.GetText("STTd".. TYPE_NAME[self.RootUi.ShowType] .. "TitleSub") +end + +return XUiStTdTitlePanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTierDrop.lua b/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTierDrop.lua new file mode 100644 index 00000000..c8d8f13b --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTierDrop.lua @@ -0,0 +1,66 @@ +--=========================== +--超级爬塔 爬塔关卡掉落页面 +--=========================== +local XUiStTierDrop = XLuaUiManager.Register(XLuaUi, "UiSuperTowerItemTip") + +local SHOW_TYPE = { + Enhance = 1, --增益页面 + Plugin = 2, --插件掉落页面 + } +local CHILD_PANEL_PATH = "XUi/XUiSuperTower/Stages/Tier/XUiStTd" +local CHILD_PANEL = { + Tab = 1, --页签面板 + Title = 2, --标题面板 + Info = 3, --详细信息面板 + DynamicTable = 4, --动态列表面板 + } + +function XUiStTierDrop:OnAwake() + XTool.InitUiObject(self) + self.BtnClose.CallBack = function() self:Close() end + self.FirstIn = true +end + +function XUiStTierDrop:OnStart(theme, showType, showAll) + self.Theme = theme + self.ShowType = showType + self.ShowAll = showAll + self:InitChildPanels() +end + +function XUiStTierDrop:InitChildPanels() + local panelControlScript = require("XUi/XUiSuperTower/Common/XUiSTMainPage") + self.PanelControl = panelControlScript.New(self) + self.PanelControl:RegisterChildPanels(CHILD_PANEL, CHILD_PANEL_PATH) + local showPanelsDic = { + [CHILD_PANEL.Tab] = true, --页签面板 + [CHILD_PANEL.Title] = true, --标题面板 + [CHILD_PANEL.Info] = false, --详细信息面板 + [CHILD_PANEL.DynamicTable] = true, --动态列表面板 + } + self.PanelControl:ShowChildPanel(showPanelsDic) +end + +function XUiStTierDrop:ShowEnhance() + self.ShowType = SHOW_TYPE.Enhance + self.PanelControl:AllDoFunction("Refresh") + if self.FirstIn then + self.FirstIn = false + else + self:PlayAnimation("QieHuan") + end +end + +function XUiStTierDrop:ShowPlugin() + self.ShowType = SHOW_TYPE.Plugin + self.PanelControl:AllDoFunction("Refresh") + if self.FirstIn then + self.FirstIn = false + else + self:PlayAnimation("QieHuan") + end +end + +function XUiStTierDrop:OnSelectGrid(cfg) + self.PanelControl:DoFunction(CHILD_PANEL.Info, "OnSelectGrid", cfg) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTierGiveUp.lua b/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTierGiveUp.lua new file mode 100644 index 00000000..ad7cad9f --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTierGiveUp.lua @@ -0,0 +1,79 @@ +--=========================== +--超级爬塔 爬塔关卡放弃 页面 +--=========================== +local XUiStTierGiveUp = XLuaUiManager.Register(XLuaUi, "UiSuperTowerFubenCloseTip") + +function XUiStTierGiveUp:OnAwake() + XTool.InitUiObject(self) +end + +function XUiStTierGiveUp:OnStart(theme, onGiveUpCallBack) + self.Theme = theme + self.OnGiveUpCb = onGiveUpCallBack + self:InitTier() + self:InitDynamicTable() + self:InitBtns() + self:ShowList() +end + +function XUiStTierGiveUp:InitTier() + self.TxtCurrentTier.text = self.Theme:GetCurrentTier() + self.TxtMaxTier.text = "/" .. self.Theme:GetMaxTier() +end + +function XUiStTierGiveUp:InitBtns() + self.BtnTanchuangClose.CallBack = function() self:OnClickClose() end + self.BtnNo.CallBack = function() self:OnClickClose() end + self.BtnYes.CallBack = function() self:OnClickGiveUp() end +end + +function XUiStTierGiveUp:OnClickClose() + self:Close() +end + +function XUiStTierGiveUp:OnClickGiveUp() + self.Theme:RequestReset(function() self:OnGiveUpSuccess() end) +end + +function XUiStTierGiveUp:InitDynamicTable() + local GridProxy = require("XUi/XUiSuperTower/Plugins/XUiSuperTowerPluginGrid") + self.DynamicTable = XDynamicTableNormal.New(self.PanelDynamicTable.gameObject) + self.DynamicTable:SetProxy(GridProxy) + self.DynamicTable:SetDelegate(self) +end + +--============= +--动态列表事件 +--============= +function XUiStTierGiveUp:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(grid.DynamicGrid.gameObject, function(pluginGrid) self:OnGridClick(pluginGrid) end) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + if self.PluginList and self.PluginList[index] then + grid:RefreshData(self.PluginList[index]) + end + end +end + +function XUiStTierGiveUp:ShowList() + self.PluginData = self.Theme:GetTierPluginInfos() + local pluginSlotScript = require("XEntity/XSuperTower/XSuperTowerPluginSlotManager") + self.PluginSlot = pluginSlotScript.New() + for _, data in pairs(self.PluginData) do + self.PluginSlot:AddPluginById(data.Id, data.Count) + end + self.PluginList = self.PluginSlot:GetPluginsSplit() + self.DynamicTable:SetDataSource(self.PluginList) + self.DynamicTable:ReloadDataASync(1) +end + +function XUiStTierGiveUp:OnGridClick(grid) + XLuaUiManager.Open("UiSuperTowerPluginDetails", grid:GetPlugin(), 0) +end + +function XUiStTierGiveUp:OnGiveUpSuccess() + self:Close() + if self.OnGiveUpCb then + self.OnGiveUpCb() + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTierSettle.lua b/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTierSettle.lua new file mode 100644 index 00000000..76484680 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTierSettle.lua @@ -0,0 +1,63 @@ +--================ +--超级爬塔 爬塔关卡 结算界面 +--================ +local XUiStTierSettle = XLuaUiManager.Register(XLuaUi, "UiSuperTowerInfiniteSettleWin") +local PANELS_DIC = { + Floor = 1, + EnhanceInfo = 2, + PluginInfo = 3, + RoleInfo = 4, + Score = 5 + } +local PANEL_PATH = "XUi/XUiSuperTower/Stages/Tier/XUiStTs" +function XUiStTierSettle:OnAwake() + XTool.InitUiObject(self) +end + +function XUiStTierSettle:OnStart(settleData, theme) + self.SettleData = settleData + self.Theme = theme or XDataCenter.SuperTowerManager.GetStageManager():GetThemeByStageId(self.SettleData.StageId) + if self.TxtStageName then self.TxtStageName.text = self.Theme:GetTierName() end + self:InitPanelsDic() + self.BtnStopAnim.CallBack = function() self:OnClickStopAnim() end + self.BtnClose.CallBack = function() self:OnClickClose() end +end + +function XUiStTierSettle:InitPanelsDic() + local script = require("XUi/XUiSuperTower/Common/XUiSTMainPage") + self.PanelControl = script.New(self) + self.PanelControl:RegisterChildPanels(PANELS_DIC, PANEL_PATH) + self.PanelControl:ShowAllPanels() +end + +function XUiStTierSettle:CheckPluginSyn() + local oldList, newList = XDataCenter.SuperTowerManager.GetBagManager():GetPluginSyn() + if oldList and newList then + XLuaUiManager.Open("UiSuperTowerPlugUp", oldList, newList, function() self:CheckPluginSyn() end) + end +end + +function XUiStTierSettle:OnClickStopAnim() + self.PanelControl:DoFunction(PANELS_DIC.Score, "StopTimer") +end + +function XUiStTierSettle:OnClickClose() + self:Close() +end + +function XUiStTierSettle:GetPluginGetNum() + return self.PanelControl:DoFunction(PANELS_DIC.PluginInfo, "GetPluginGetNum") +end + +function XUiStTierSettle:SetCloseBtnActive(value) + self.BtnClose.gameObject:SetActiveEx(value) +end + +function XUiStTierSettle:SetStopAnimBtnActive(value) + self.BtnStopAnim.gameObject:SetActiveEx(value) +end + +function XUiStTierSettle:OnDestroy() + self.Theme:CheckReset() + self.PanelControl:OnDestroy() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTpDropGrid.lua b/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTpDropGrid.lua new file mode 100644 index 00000000..83a04088 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTpDropGrid.lua @@ -0,0 +1,13 @@ +local BasePluginsGrid = require("XUi/XUiSuperTower/Plugins/XUiSuperTowerPluginGrid") +--=========================== +--超级爬塔爬塔准备界面插件掉落控件 +--=========================== +local XUiStTpDropGrid = XClass(BasePluginsGrid, "XUiStTpDropGrid") + +function XUiStTpDropGrid:RefreshData(prePluginData) + self.TxtTier.text = prePluginData.Name + self.PluginCfg = XSuperTowerConfigs.GetPluginCfgById(prePluginData.PluginId) + self:RefreshCfg(self.PluginCfg) +end + +return XUiStTpDropGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTpEnhancePanel.lua b/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTpEnhancePanel.lua new file mode 100644 index 00000000..4d84d53e --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTpEnhancePanel.lua @@ -0,0 +1,65 @@ +local Base = require("XUi/XUiSuperTower/Common/XUiSTChildPanel") +--===================== +--爬塔准备增益掉落面板 +--===================== +local XUiStTpEnhancePanel = XClass(Base, "XUiStTpEnhancePanel") +--=============== +--初始化面板(在构筑函数最后调用) +--=============== +function XUiStTpEnhancePanel:InitPanel() + self.GridEnhance.gameObject:SetActiveEx(false) + self.BtnDetails.CallBack = function() self:OnClickBtnDetails() end + self.TxtDetails.text = XUiHelper.GetText("STTierPrepareEnhanceTip") +end + +function XUiStTpEnhancePanel:OnShowPanel() + local isStart = self.RootUi:GetIsStart() + self.TxtDetails.gameObject:SetActiveEx(isStart) + self.ObjEnhance.gameObject:SetActiveEx(not isStart) + if not isStart then + self:ShowEnhanceList() + end +end + +function XUiStTpEnhancePanel:ShowEnhanceList() + local list = self.RootUi.Theme:GetTierEnhanceIds() + if not self.EnhanceList then self.EnhanceList = {} end + table.sort(list, function(idA, idB) + local cfgA = XSuperTowerConfigs.GetEnhanceCfgById(idA) + local cfgB = XSuperTowerConfigs.GetEnhanceCfgById(idB) + if not cfgA then + return true + end + if not cfgB then + return false + end + return cfgA.Priority < cfgB.Priority + end) + if list then + for i = 1, #list do + if list[i] then + if not self.EnhanceList[i] then + local script = require("XUi/XUiSuperTower/Plugins/XUiSuperTowerEnhanceGrid") + local enhanceGo = CS.UnityEngine.Object.Instantiate(self.GridEnhance, self.PanelEnhance) + self.EnhanceList[i] = script.New(enhanceGo, function(enhance) self:OnClickEnhance(enhance) end) + end + self.EnhanceList[i]:ShowPanel() + self.EnhanceList[i]:RefreshData(list[i]) + else + if self.EnhanceList[i] then + self.EnhanceList[i]:HidePanel() + end + end + end + end +end + +function XUiStTpEnhancePanel:OnClickEnhance(enhanceGrid) + XLuaUiManager.Open("UiSuperTowerEnhanceDetails", enhanceGrid.EnhanceId) +end + +function XUiStTpEnhancePanel:OnClickBtnDetails() + XLuaUiManager.Open("UiSuperTowerItemTip", self.RootUi.Theme, XDataCenter.SuperTowerManager.ItemType.Enhance, not self.RootUi.Theme:CheckTierIsPlaying()) +end + +return XUiStTpEnhancePanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTpMemberGrid.lua b/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTpMemberGrid.lua new file mode 100644 index 00000000..dc01ed5e --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTpMemberGrid.lua @@ -0,0 +1,60 @@ +--=========================== +--超级爬塔队伍列表角色控件 +--=========================== +local XUiStTpMemberGrid = XClass(nil, "XUiStTpMemberGrid") + +function XUiStTpMemberGrid:Ctor(uiGameObject, rootUi) + XTool.InitUiObjectByUi(self, uiGameObject) + self.RootUi = rootUi + self.BtnClick.CallBack = function() self:OnClick() end +end + +function XUiStTpMemberGrid:Reset() + --self.ImgLock.gameObject:SetActiveEx(true) +end + +function XUiStTpMemberGrid:RefreshData(role) + if not role then + self:Reset() + return + end + self.Role = role + self:RefreshImg() + self:RefreshHp() + self:RefreshSp() + self:RefreshSuperLevel() +end + +function XUiStTpMemberGrid:RefreshImg() + self.RImgRole:SetRawImage(self.Role:GetCharacterViewModel():GetHalfBodyCommonIcon()) + self.GridLv.gameObject:SetActiveEx(XDataCenter.SuperTowerManager.GetFunctionManager():CheckFunctionUnlockByKey(XDataCenter.SuperTowerManager.FunctionName.Transfinite)) + self.ImgSpRoleIcon.gameObject:SetActiveEx(self.Role:GetIsInDult()) + --self.ImgLock.gameObject:SetActiveEx(false) +end + +function XUiStTpMemberGrid:RefreshHp() + self.TxtHpPercent.text = self.Role:GetHpLeft() .. "%" + self.ImgHpProgress.fillAmount = self.Role:GetHpLeft() / 100 +end + +function XUiStTpMemberGrid:RefreshSp() + self.ImgSpRoleIcon.gameObject:SetActiveEx(self.Role:GetIsInDult()) +end + +function XUiStTpMemberGrid:RefreshSuperLevel() + self.TxtLevel.text = self.Role:GetSuperLevel() +end + +function XUiStTpMemberGrid:SetLeader(isShow) + self.ImgLeader.gameObject:SetActiveEx(isShow) +end + +function XUiStTpMemberGrid:SetFirst(isShow) + self.ImgFirstRole.gameObject:SetActiveEx(isShow) +end + +function XUiStTpMemberGrid:OnClick() + +end + +return XUiStTpMemberGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTpPluginsPanel.lua b/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTpPluginsPanel.lua new file mode 100644 index 00000000..be94009a --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTpPluginsPanel.lua @@ -0,0 +1,124 @@ +local Base = require("XUi/XUiSuperTower/Common/XUiSTChildPanel") +--===================== +--爬塔准备插件掉落面板 +--===================== +local XUiStTpPluginsPanel = XClass(Base, "XUiStTpPluginsPanel") + +function XUiStTpPluginsPanel:InitPanel() + self.GridDrop.gameObject:SetActiveEx(false) + self.GridGet.gameObject:SetActiveEx(false) + self.BtnDrop.CallBack = function() self:OnClickBtnDrop() end +end + +function XUiStTpPluginsPanel:OnShowPanel() + local isStart = self.RootUi:GetIsStart() + self.ObjDropList.gameObject:SetActiveEx(isStart) + self.ObjGetList.gameObject:SetActiveEx(not isStart) + if isStart then + self:ShowDrop() + else + self:ShowGet() + end +end + +function XUiStTpPluginsPanel:ShowDrop() + if not self.DropGridList then self.DropGridList = {} end + --[[ + List + { + Name = name, + PluginId = previewPluginsPreviewId[index] + } + ]] + local dropList = self.RootUi.Theme:GetPluginsDropPreview() + if dropList then + for i = 1, 5 do + if dropList[i] then + if not self.DropGridList[i] then + local script = require("XUi/XUiSuperTower/Stages/Tier/XUiStTpDropGrid") + local dropGo = CS.UnityEngine.Object.Instantiate(self.GridDrop, self.PanelDropList) + self.DropGridList[i] = script.New(dropGo, function(grid) self:OnClickGrid(grid) end) + end + self.DropGridList[i]:ShowPanel() + self.DropGridList[i]:RefreshData(dropList[i]) + else + if self.DropGridList[i] then + self.DropGridList[i]:HidePanel() + end + end + end + end +end + +function XUiStTpPluginsPanel:ShowGet() + if not self.GetGridList then self.GetGridList = {} end + --[[ + List + { + // 插件id + public int Id; + // 数量 + public int Count; + } + ]] + local getList = self.RootUi.Theme:GetTierPluginInfos() + table.sort(getList, function(infoA, infoB) + local cfgA = XSuperTowerConfigs.GetPluginCfgById(infoA.Id) + local cfgB = XSuperTowerConfigs.GetPluginCfgById(infoB.Id) + if not cfgA then + return true + end + if not cfgB then + return false + end + if cfgA.Quality ~= cfgB.Quality then + return cfgA.Quality < cfgB.Quality + end + return cfgA.Priority < cfgB.Priority + end) + if getList then + local count = 1 + for _, plugin in pairs(getList) do + for i = 1, plugin.Count do + if not self.GetGridList[count] then + local script = require("XUi/XUiSuperTower/Plugins/XUiSuperTowerPluginGrid") + local getGo = CS.UnityEngine.Object.Instantiate(self.GridGet, self.PanelGetList) + self.GetGridList[count] = script.New(getGo, function(grid) self:OnClickGrid(grid) end) + end + self.GetGridList[count]:ShowPanel() + self.GetGridList[count]:RefreshCfg(XSuperTowerConfigs.GetPluginCfgById(plugin.Id)) + count = count + 1 + end + end + for i = count + 1, #self.GetGridList do + self.GetGridList[i]:HidePanel() + end + --[[ 这里是只显示相同种类插件合并的列表,且只显示前5个 + for i = 1, 5 do + if getList[i] then + if not self.GetGridList[i] then + local script = require("XUi/XUiSuperTower/Plugins/XUiSuperTowerPluginGrid") + local getGo = CS.UnityEngine.Object.Instantiate(self.GridGet, self.PanelGetList) + self.GetGridList[i] = script.New(getGo, function(grid) self:OnClickGrid(grid) end) + end + self.GetGridList[i]:ShowPanel() + self.GetGridList[i]:RefreshCfg(XSuperTowerConfigs.GetPluginCfgById(getList[i].Id)) + else + if self.GetGridList[i] then + self.GetGridList[i]:HidePanel() + end + end + end + ]] + end +end + +function XUiStTpPluginsPanel:OnClickBtnDrop() + XLuaUiManager.Open("UiSuperTowerItemTip", self.RootUi.Theme, XDataCenter.SuperTowerManager.ItemType.Plugin, not self.RootUi.Theme:CheckTierIsPlaying()) +end + +function XUiStTpPluginsPanel:OnClickGrid(grid) + XLuaUiManager.Open("UiSuperTowerPluginDetails", grid.Plugin, 0) +end + +return XUiStTpPluginsPanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTpProgressPanel.lua b/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTpProgressPanel.lua new file mode 100644 index 00000000..966751b7 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTpProgressPanel.lua @@ -0,0 +1,11 @@ +local Base = require("XUi/XUiSuperTower/Common/XUiSTChildPanel") +--===================== +--爬塔准备当前进度显示面板 +--===================== +local XUiStTpProgressPanel = XClass(Base, "XUiStTpProgressPanel") + +function XUiStTpProgressPanel:OnShowPanel() + self.TxtProgress.text = CS.XTextManager.GetText("STTpProgress", self.RootUi.Theme:GetCurrentTier(), self.RootUi.Theme:GetMaxTier()) +end + +return XUiStTpProgressPanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTpScorePanel.lua b/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTpScorePanel.lua new file mode 100644 index 00000000..171f878b --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTpScorePanel.lua @@ -0,0 +1,11 @@ +local Base = require("XUi/XUiSuperTower/Common/XUiSTChildPanel") +--===================== +--爬塔准备积分显示面板 +--===================== +local XUiStTpScorePanel = XClass(Base, "XUiStTpScorePanel") + +function XUiStTpScorePanel:OnShowPanel() + self.TxtScore.text = self.RootUi.Theme:GetCurrentTierScore() +end + +return XUiStTpScorePanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTpTeamPanel.lua b/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTpTeamPanel.lua new file mode 100644 index 00000000..e3854533 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTpTeamPanel.lua @@ -0,0 +1,42 @@ +local Base = require("XUi/XUiSuperTower/Common/XUiSTChildPanel") +--===================== +--爬塔准备当前进度显示面板 +--===================== +local XUiStTpTeamPanel = XClass(Base, "XUiStTpTeamPanel") + +function XUiStTpTeamPanel:InitPanel() + self.Member = {} + local script = require("XUi/XUiSuperTower/Stages/Tier/XUiStTpMemberGrid") + for i = 1, 3 do + local member = self["TeamMember" .. i] + if member then + self.Member[i] = script.New(member, self.RootUi) + end + end +end + +function XUiStTpTeamPanel:OnShowPanel() + local team = XDataCenter.SuperTowerManager.GetTeamByStageType(XDataCenter.SuperTowerManager.StageType.LllimitedTower) + if team then + for i = 1, 3 do + local role = XDataCenter.SuperTowerManager.GetRoleManager():GetRole(team:GetEntityIdByTeamPos(i)) + if role then + self.Member[i]:RefreshData(role) + self.Member[i]:SetLeader(i == team:GetCaptainPos()) + self.Member[i]:SetFirst(i == team:GetFirstFightPos()) + else + self.Member[i]:Reset() + self.Member[i]:SetLeader(false) + self.Member[i]:SetFirst(false) + end + end + local leaderPos = team:GetCaptainPos() + local leaderRole = XDataCenter.SuperTowerManager.GetRoleManager():GetRole(team:GetEntityIdByTeamPos(leaderPos)) + local captainSkillInfo = leaderRole:GetCharacterViewModel():GetCaptainSkillInfo() + self.RImgIconLeader:SetRawImage(leaderRole:GetCharacterViewModel():GetSmallHeadIcon()) + self.TxtLeaderSkillName.text = captainSkillInfo.Name + self.TxtLeaderSkillDesc.text = captainSkillInfo.Level > 0 and captainSkillInfo.Intro or CS.XTextManager.GetText("CaptainSkillLock") + end +end + +return XUiStTpTeamPanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTsEnhanceInfoPanel.lua b/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTsEnhanceInfoPanel.lua new file mode 100644 index 00000000..9b835c76 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTsEnhanceInfoPanel.lua @@ -0,0 +1,31 @@ +local BasePanel = require("XUi/XUiSuperTower/Common/XUiSTChildPanel") +--================== +--超级爬塔 爬塔 结算界面增益面板控件 +--================== +local XUiStTsEnhanceInfoPanel = XClass(BasePanel, "XUiStTsEnhanceInfoPanel") + +function XUiStTsEnhanceInfoPanel:InitPanel() + self:InitEnhanceInfos() + self.GridEnhance.gameObject:SetActiveEx(false) + self:InitEnhanceList() +end + +function XUiStTsEnhanceInfoPanel:InitEnhanceInfos() + self.EnhanceIds = self.RootUi.Theme:GetTierEnhanceIds() +end + +function XUiStTsEnhanceInfoPanel:InitEnhanceList() + local gridScript = require("XUi/XUiSuperTower/Plugins/XUiSuperTowerEnhanceGrid") + for _, id in pairs(self.EnhanceIds) do + local enhanceGo = CS.UnityEngine.Object.Instantiate(self.GridEnhance.gameObject, self.GridContent) + local grid = gridScript.New(enhanceGo, function(enhanceGrid) self:OnClickEnhance(enhanceGrid) end) + grid:RefreshData(id) + grid:ShowPanel() + end +end + +function XUiStTsEnhanceInfoPanel:OnClickEnhance(enhanceGrid) + XLuaUiManager.Open("UiSuperTowerEnhanceDetails", enhanceGrid.EnhanceId) +end + +return XUiStTsEnhanceInfoPanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTsFloorPanel.lua b/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTsFloorPanel.lua new file mode 100644 index 00000000..c6dd7988 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTsFloorPanel.lua @@ -0,0 +1,15 @@ +local BasePanel = require("XUi/XUiSuperTower/Common/XUiSTChildPanel") +--================== +--超级爬塔 爬塔 结算界面层数面板控件 +--================== +local XUiStTsFloorPanel = XClass(BasePanel, "XUiStTsFloorPanel") + +function XUiStTsFloorPanel:InitPanel() + local currentT = self.RootUi.Theme:GetCurrentTier() + local historyT = self.RootUi.Theme:GetHistoryHighestTier() + self.TxtCurrentNum.text = currentT + self.TxtBeforeNum.text = CS.XTextManager.GetText("STTsHistoryFloorStr", historyT) + self.NewTag.gameObject:SetActiveEx(self.RootUi.Theme:CheckIsNewTierRecord()) +end + +return XUiStTsFloorPanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTsPluginInfoPanel.lua b/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTsPluginInfoPanel.lua new file mode 100644 index 00000000..bde1367b --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTsPluginInfoPanel.lua @@ -0,0 +1,57 @@ +local BasePanel = require("XUi/XUiSuperTower/Common/XUiSTChildPanel") +--================== +--超级爬塔 爬塔 结算界面插件面板控件 +--================== +local XUiStTsPluginInfoPanel = XClass(BasePanel, "XUiStTsPluginInfoPanel") +function XUiStTsPluginInfoPanel:InitPanel() + self.GridPlugin.gameObject:SetActiveEx(false) + self:InitPluginInfos() + self:InitDynamicTable() + self:ShowList() +end + +function XUiStTsPluginInfoPanel:InitPluginInfos() + self.PluginData = self.RootUi.Theme:GetTierPluginInfos() + local pluginSlotScript = require("XEntity/XSuperTower/XSuperTowerPluginSlotManager") + self.PluginSlot = pluginSlotScript.New() + self.PluginSlot:SetMaxCapacity(100) --设定一个奖励上限 + for _, data in pairs(self.PluginData) do + self.PluginSlot:AddPluginById(data.Id, data.Count) + end +end + +function XUiStTsPluginInfoPanel:InitDynamicTable() + local GridProxy = require("XUi/XUiSuperTower/Plugins/XUiSuperTowerPluginGrid") + self.DynamicTable = XDynamicTableNormal.New(self.PanelItemScrollView.gameObject) + self.DynamicTable:SetProxy(GridProxy) + self.DynamicTable:SetDelegate(self) +end + +function XUiStTsPluginInfoPanel:ShowList() + self.PluginList = self.PluginSlot:GetPluginsSplit() + self.DynamicTable:SetDataSource(self.PluginList) + self.DynamicTable:ReloadDataASync(1) +end + +--============= +--动态列表事件 +--============= +function XUiStTsPluginInfoPanel:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(grid.DynamicGrid.gameObject, function(pluginGrid) self:OnGridClick(pluginGrid) end) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + if self.PluginList and self.PluginList[index] then + grid:RefreshData(self.PluginList[index]) + end + end +end + +function XUiStTsPluginInfoPanel:GetPluginGetNum() + return self.PluginList and #self.PluginList or 0 +end + +function XUiStTsPluginInfoPanel:OnGridClick(grid) + XLuaUiManager.Open("UiSuperTowerPluginDetails", grid.Plugin, 0) +end + +return XUiStTsPluginInfoPanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTsRoleInfoPanel.lua b/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTsRoleInfoPanel.lua new file mode 100644 index 00000000..ae7e9373 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTsRoleInfoPanel.lua @@ -0,0 +1,49 @@ +local BasePanel = require("XUi/XUiSuperTower/Common/XUiSTChildPanel") +--================== +--超级爬塔 爬塔 结算界面信息面板控件 +--================== +local XUiStTsRoleInfoPanel = XClass(BasePanel, "XUiStTsRoleInfoPanel") + +function XUiStTsRoleInfoPanel:InitPanel() + self:InitTeamInfo() + self:InitRoleList() + self:InitText() +end + +function XUiStTsRoleInfoPanel:InitTeamInfo() + self.Team = XDataCenter.SuperTowerManager.GetTeamByStageType(XDataCenter.SuperTowerManager.StageType.LllimitedTower) + self.TeamMember = {} + for i = 1,3 do + local entityId = self.Team:GetEntityIdByTeamPos(i) + local entityRole = XDataCenter.SuperTowerManager.GetRoleManager():GetRole(entityId) + self.TeamMember[i] = entityRole + end +end + +function XUiStTsRoleInfoPanel:InitRoleList() + self.GridRole.gameObject:SetActiveEx(false) + for i = 1, 3 do + local newRoleGo = CS.UnityEngine.Object.Instantiate(self.GridRole.gameObject, self.RoleContent) + local role = {} + XTool.InitUiObjectByUi(role, newRoleGo) + if self.TeamMember[i] then + role.RImgIcon:SetRawImage(self.TeamMember[i]:GetCharacterViewModel():GetBigHeadIcon()) + role.GameObject:SetActiveEx(true) + end + end +end + +function XUiStTsRoleInfoPanel:InitText() + self.TxtPlayerName.text = XPlayer.Name + for i = 1, 3 do + if self.TeamMember[i] and self["TxtMemberName" .. i] then + self["TxtMemberName" .. i].text = self.TeamMember[i]:GetCharacterViewModel():GetTradeName() + end + end + local timeStr = XTime.TimestampToLocalDateTimeString(XTime.GetServerNowTimestamp()) + local strs = string.Split(timeStr, " ") + self.TxtTimeDay.text = strs and strs[1] or "" + self.TxtTimeHour.text = strs and strs[2] or "" +end + +return XUiStTsRoleInfoPanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTsScoreItem.lua b/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTsScoreItem.lua new file mode 100644 index 00000000..ad92c961 --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTsScoreItem.lua @@ -0,0 +1,30 @@ +--================ +--超级爬塔 爬塔关卡 结算界面 分数计算项控件 +--================ +local XUiStTsScoreItem = XClass(nil, "XUiStTsScoreItem") + +function XUiStTsScoreItem:Ctor(uiGameObject, scoreRateId) + XTool.InitUiObjectByUi(self, uiGameObject) + self.RatioCfg = XSuperTowerConfigs.GetTierScoreRatioCfgById(scoreRateId) +end + +function XUiStTsScoreItem:Refresh(count, score) + self.Score = score + self.TxtName.text = self.RatioCfg.Desc + self.TxtCount.text = count + self.TxtScore.text = "+" .. self.Score +end + +function XUiStTsScoreItem:GetScore() + return self.Score +end + +function XUiStTsScoreItem:Show() + self.GameObject:SetActiveEx(true) +end + +function XUiStTsScoreItem:Hide() + self.GameObject:SetActiveEx(false) +end + +return XUiStTsScoreItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTsScorePanel.lua b/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTsScorePanel.lua new file mode 100644 index 00000000..51aa6b9b --- /dev/null +++ b/Resources/Scripts/XUi/XUiSuperTower/Stages/Tier/XUiStTsScorePanel.lua @@ -0,0 +1,92 @@ +local BasePanel = require("XUi/XUiSuperTower/Common/XUiSTChildPanel") +--================== +--超级爬塔 爬塔 结算界面分数面板控件 +--================== +local XUiStTsScorePanel = XClass(BasePanel, "XUiStTsScorePanel") + +function XUiStTsScorePanel:InitPanel() + self:InitGrids() +end + +function XUiStTsScorePanel:InitGrids() + self.GridScoreItem.gameObject:SetActiveEx(false) + self.ScoreItems = {} + local allScoreItemCfg = XSuperTowerConfigs.GetAllTierScoreRatioCfg() + local itemScript = require("XUi/XUiSuperTower/Stages/Tier/XUiStTsScoreItem") + for id, _ in pairs(allScoreItemCfg) do + local newItemGo = CS.UnityEngine.Object.Instantiate(self.GridScoreItem.gameObject, self.GridContent) + self.ScoreItems[id] = itemScript.New(newItemGo, id) + self.ScoreItems[id]:Show() + end +end + +function XUiStTsScorePanel:OnShowPanel() + self.TxtMaxScore.text = self.RootUi.Theme:GetTierMaxScore() + self.TxtHistoryScore.text = 0 + self:StartTween() + --self:SetGrids() + --self:SetTotalScore() +end + +function XUiStTsScorePanel:StartTween() + local time = CS.XGame.ClientConfig:GetFloat("SuperTowerTierSettleAnimeTime") + local ScoreType = XDataCenter.SuperTowerManager.ScoreType + self.ScoreValue = {} + for key, value in pairs(ScoreType) do + self.ScoreValue[value] = {} + local count, score = self.RootUi.Theme:GetTierScoreCountByScoreType(value) + self.ScoreValue[value].Count = count + self.ScoreValue[value].Score = score + end + local totalScore = 0 + for _, data in pairs(self.ScoreValue) do + totalScore = totalScore + data.Score + end + self.AudioInfo = CS.XAudioManager.PlaySound(XSoundManager.UiBasicsMusic.UiSettle_Win_Number) + XLuaUiManager.SetMask(true) + self.Timer = XUiHelper.Tween(time, function(f) + if XTool.UObjIsNil(self.RootUi.Transform) then + return + end + + for _, value in pairs(ScoreType) do + self.ScoreItems[value]:Refresh(self.ScoreValue[value].Count, math.floor(f * self.ScoreValue[value].Score)) + end + self:SetTotalScore(math.floor(f * totalScore)) + end, function() + self:StopAudio() + self.TxtHistoryScore.text = self.RootUi.Theme:GetHistoryTierScore() + XLuaUiManager.SetMask(false) + self.RootUi:CheckPluginSyn() + end) +end + +--[[function XUiStTsScorePanel:SetGrids() + ScoreType = XDataCenter.SuperTowerManager.ScoreType + for _, value in pairs(ScoreType) do + self.ScoreItems[value]:Refresh(self.RootUi.Theme:GetTierScoreCountByScoreType(value)) + end +end]] + +function XUiStTsScorePanel:SetTotalScore(totalScore) + self.TxtTotalScore.text = totalScore +end + +function XUiStTsScorePanel:StopAudio() + if self.AudioInfo then + self.AudioInfo:Stop() + end +end + +function XUiStTsScorePanel:StopTimer() + if self.Timer then + XScheduleManager.UnSchedule(self.Timer) + self.Timer = nil + end +end + +function XUiStTsScorePanel:OnDestroy() + self:StopTimer() +end + +return XUiStTsScorePanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTRPG/UiTRPGMapTips.lua b/Resources/Scripts/XUi/XUiTRPG/UiTRPGMapTips.lua new file mode 100644 index 00000000..cac58c73 --- /dev/null +++ b/Resources/Scripts/XUi/XUiTRPG/UiTRPGMapTips.lua @@ -0,0 +1,150 @@ +local XUiGridTRPGMapNode = require("XUi/XUiTRPG/XUiGridTRPGMapNode") +local XUiGridTRPGCardRecord = require("XUi/XUiTRPG/XUiGridTRPGCardRecord") + +local CSXTextManagerGetText = CS.XTextManager.GetText +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate +local mathFloor = math.floor + +local XUiTRPGMapTips = XLuaUiManager.Register(XLuaUi, "UiTRPGMapTips") + +function XUiTRPGMapTips:OnAwake() + self:AutoAddListener() + self.GridNode.gameObject:SetActiveEx(false) +end + +function XUiTRPGMapTips:OnStart(mazeId) + self.MazeId = mazeId + self.LayerIds = XTRPGConfigs.GetMazeLayerIds(mazeId) + self.LayerId = XDataCenter.TRPGManager.GetMazeCurrentLayerId(mazeId) + self.RecordGrids = {} + self.LayerBtns = {} + + self:InitMaze() +end + +function XUiTRPGMapTips:OnEnable() + self.PanelLayer:SelectIndex(self:GetLayerIndex(self.LayerId)) + self:UpdateCardRecords() +end + +function XUiTRPGMapTips:OnGetEvents() + return { XEventId.EVENT_TRPG_MAZE_RECORD_CARD } +end + +function XUiTRPGMapTips:OnNotify(evt, ...) + if evt == XEventId.EVENT_TRPG_MAZE_RECORD_CARD then + self:UpdateProgress() + self:UpdateCardRecords() + end +end + +function XUiTRPGMapTips:InitMaze() + local mazeId = self.MazeId + self.TxtMazeName.text = XTRPGConfigs.GetMazeName(mazeId) + + local btns = {} + for index in pairs(self.LayerIds) do + local btn = index == 1 and self.BtnTabLayer or CSUnityEngineObjectInstantiate(self.BtnTabLayer, self.PanelLayer.transform) + btns[index] = btn + btn:SetName(CSXTextManagerGetText("TRPGMazeMapBtnName", index)) + end + self.PanelLayer:Init(btns, function(index) self:OnSelectLayer(index) end) + self.LayerBtns = btns + + self.DynamicTable = XDynamicTableNormal.New(self.SViewStage) + self.DynamicTable:SetDelegate(self) + self.DynamicTable:SetProxy(XUiGridTRPGMapNode) +end + +function XUiTRPGMapTips:OnSelectLayer(index) + self:PlayAnimation("QieHuan") + + local layerId = self.LayerIds[index] + self.LayerId = layerId + + self:UpdateMap() + self:UpdateProgress() +end + +function XUiTRPGMapTips:UpdateProgress() + local mazeId = self.MazeId + local layerId = self.LayerId + + local mazeProgress = XDataCenter.TRPGManager.GetMazeProgress(mazeId, layerId) + self.TxtProgress.text = mathFloor(mazeProgress * 100) .. "%" +end + +function XUiTRPGMapTips:UpdateMap() + local mazeId = self.MazeId + local layerId = self.LayerId + + self.TxtMazeName.text = XTRPGConfigs.GetMazeLayerName(layerId) + + local isCurrentLayer = XDataCenter.TRPGManager.IsCurrentLayer(mazeId, layerId) + + + local curStandNodeIndex = isCurrentLayer and XDataCenter.TRPGManager.GetMazeCurrentStandNodeIndex(mazeId, layerId) or 1 + local nodeIdList = XDataCenter.TRPGManager.GetMazeNodeIdList(mazeId, layerId, true) + self.NodeIdList = nodeIdList + self.DynamicTable:SetDataSource(nodeIdList) + self.DynamicTable:ReloadDataSync(curStandNodeIndex) + + for index, layerId in pairs(self.LayerIds) do + local isCurrentLayer = XDataCenter.TRPGManager.IsCurrentLayer(mazeId, layerId) + local btn = self.LayerBtns[index] + btn:ShowTag(isCurrentLayer) + end +end + +function XUiTRPGMapTips:OnDynamicTableEvent(event, index, grid) + local mazeId = self.MazeId + local layerId = self.LayerId + local nodeIdList = self.NodeIdList + + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local nodeId = nodeIdList[index] + grid:Refresh(mazeId, layerId, nodeId) + end +end + +function XUiTRPGMapTips:UpdateCardRecords() + local mazeId = self.MazeId + local grids = self.RecordGrids + + local cardRecordGroupIds = XTRPGConfigs.GetMazeCardRecordGroupIdList() + for i, groupId in ipairs(cardRecordGroupIds) do + local grid = grids[i] + if not grid then + local ui = i == 1 and self.GridReward or CSUnityEngineObjectInstantiate(self.GridReward, self.PanelContent) + grid = XUiGridTRPGCardRecord.New(ui, self) + grids[i] = grid + end + grid:Refresh(mazeId, groupId) + grid.GameObject:SetActiveEx(true) + end + + for i = #cardRecordGroupIds + 1, #grids do + if grids[i] then + grids[i].GameObject:SetActiveEx(false) + end + end +end + +function XUiTRPGMapTips:AutoAddListener() + self.BtnTanchuangCloseBig.CallBack = function() self:OnBtnBackClick() end +end + +function XUiTRPGMapTips:OnBtnBackClick() + self:Close() +end + +function XUiTRPGMapTips:GetLayerIndex(targetLayerId) + for index, layerId in pairs(self.LayerIds or {}) do + if layerId == targetLayerId then + return index + end + end + return 1 +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTRPG/XUiGridTRPGBuff.lua b/Resources/Scripts/XUi/XUiTRPG/XUiGridTRPGBuff.lua new file mode 100644 index 00000000..60ca7a8b --- /dev/null +++ b/Resources/Scripts/XUi/XUiTRPG/XUiGridTRPGBuff.lua @@ -0,0 +1,31 @@ +local handler = handler + +local XUiGridTRPGBuff = XClass(nil, "XUiGridTRPGBuff") + +function XUiGridTRPGBuff:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + + XTool.InitUiObject(self) + + if self.BtnClick then + self.BtnClick.CallBack = handler(self, self.OnClickBtnClick) + end +end + +function XUiGridTRPGBuff:Refresh(buffId) + self.BuffId = buffId + + if self.ImgIcon then + local icon = XTRPGConfigs.GetBuffIcon(buffId) + self.RootUi:SetUiSprite(self.ImgIcon, icon) + end +end + +function XUiGridTRPGBuff:OnClickBtnClick() + local buffId = self.BuffId + XLuaUiManager.Open("UiTRPGBuffDetail", buffId) +end + +return XUiGridTRPGBuff \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTRPG/XUiGridTRPGCard.lua b/Resources/Scripts/XUi/XUiTRPG/XUiGridTRPGCard.lua new file mode 100644 index 00000000..efb61b4d --- /dev/null +++ b/Resources/Scripts/XUi/XUiTRPG/XUiGridTRPGCard.lua @@ -0,0 +1,105 @@ +local XUiGridTRPGCard = XClass(nil, "XUiGridTRPGCard") + +function XUiGridTRPGCard:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + + XTool.InitUiObject(self) + self.BtnClick.CallBack = function() self:OnClickBtnClick() end +end + +function XUiGridTRPGCard:Refresh(cardId, isNodeReachable, isCardReachable, clickCb, finishedCardId) + self.IsCardReachable = isCardReachable + self.ClickCb = clickCb + self.CardId = cardId + self.IsFinished = finishedCardId and true or nil + cardId = finishedCardId or cardId + + if self.RImgBg then + if isNodeReachable then + local cardIconR = XTRPGConfigs.GetMazeCardIconR(cardId) + if cardIconR then + self.RImgBg:SetRawImage(cardIconR) + end + self.RImgBg.gameObject:SetActiveEx(true) + else + self.RImgBg.gameObject:SetActiveEx(false) + end + end + + if self.ImgBg then + if not isNodeReachable then + local cardIcon = XTRPGConfigs.GetMazeCardIcon(cardId) + if cardIcon then + self.UiRoot:SetUiSprite(self.ImgBg, cardIcon) + end + self.ImgBg.gameObject:SetActiveEx(true) + else + self.ImgBg.gameObject:SetActiveEx(false) + end + end + + if self.ImgTypeIcon then + local cardTypeIcon = XTRPGConfigs.GetMazeCardTypeIcon(cardId) + if cardTypeIcon then + self.UiRoot:SetUiSprite(self.ImgTypeIcon, cardTypeIcon) + end + end + + if self.Tag then + local showTag = XTRPGConfigs.IsMazeCardShowTag(cardId) + self.Tag.gameObject:SetActiveEx(showTag) + end + + if self.RImgBgDisable then + self.RImgBgDisable.enabled = false--not isCardReachable + end + + local cardOrder = XTRPGConfigs.GetMazeCardOrder(cardId) + self.BtnClick:SetNameByGroup(0, cardOrder) + + local cardName = XTRPGConfigs.GetMazeCardName(cardId) + self.BtnClick:SetNameByGroup(1, cardName) + + self.BtnClick:SetDisable(not isCardReachable) +end + +function XUiGridTRPGCard:OnClickBtnClick() + if not self.IsCardReachable then + XUiManager.TipText("TRPGMazeCardUnReach") + return + end + + local cardId = self.CardId + if XTRPGConfigs.CheckMazeCardType(cardId, XTRPGConfigs.CardType.Random) + and not self.IsFinished + then + if self.AnimRImgBgDisable then + + local stopCb + stopCb = function(director) + self.ClickCb() + self.AnimRImgBgDisable.gameObject:SetActiveEx(false) + self.AnimRImgBgDisable:stopped('-', stopCb) + + XLuaUiManager.SetMask(false) + + end + + XLuaUiManager.SetMask(true) + + self.AnimRImgBgDisable:stopped('+', stopCb) + self.AnimRImgBgDisable.gameObject:SetActiveEx(true) + + else + self.ClickCb() + end + elseif XTRPGConfigs.CheckMazeCardType(cardId, XTRPGConfigs.CardType.Over) then + XDataCenter.TRPGManager.TipQuitMaze(self.ClickCb) + else + self.ClickCb() + end +end + +return XUiGridTRPGCard \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTRPG/XUiGridTRPGCardRecord.lua b/Resources/Scripts/XUi/XUiTRPG/XUiGridTRPGCardRecord.lua new file mode 100644 index 00000000..2954460c --- /dev/null +++ b/Resources/Scripts/XUi/XUiTRPG/XUiGridTRPGCardRecord.lua @@ -0,0 +1,22 @@ +local CSXTextManagerGetText = CS.XTextManager.GetText + +local XUiGridTRPGCardRecord = XClass(nil, "XUiGridTRPGCardRecord") + +function XUiGridTRPGCardRecord:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + + XTool.InitUiObject(self) +end + +function XUiGridTRPGCardRecord:Refresh(mazeId, cardRecordGroupId) + local icon = XTRPGConfigs.GetMazeCardRecordGroupMiniIcon(cardRecordGroupId) + self.UiRoot:SetUiSprite(self.ImgIconContent, icon) + + local name = XTRPGConfigs.GetMazeCardRecordGroupName(cardRecordGroupId) + local finishCount, totalCount = XDataCenter.TRPGManager.GetMazeRecordGroupCardCount(mazeId, cardRecordGroupId) + self.TxtContent.text = CSXTextManagerGetText("TRPGMazeCardRecord", name, finishCount, totalCount) +end + +return XUiGridTRPGCardRecord \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTRPG/XUiGridTRPGItem.lua b/Resources/Scripts/XUi/XUiTRPG/XUiGridTRPGItem.lua new file mode 100644 index 00000000..a4700df5 --- /dev/null +++ b/Resources/Scripts/XUi/XUiTRPG/XUiGridTRPGItem.lua @@ -0,0 +1,95 @@ +local handler = handler +local CSXTextManagerGetText = CS.XTextManager.GetText + +local XUiGridTRPGItem = XClass(nil, "XUiGridTRPGItem") + +function XUiGridTRPGItem:Ctor(ui, rootUi, clickCb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self.ClickCb = clickCb + + XTool.InitUiObject(self) + + if self.PanelSite then + self.PanelSite.gameObject:SetActiveEx(false) + end + + if self.BtnClick then + self.BtnClick.CallBack = handler(self, self.OnClickBtnClick) + end +end + +function XUiGridTRPGItem:Refresh(itemId, itemCount) + if self.RImgIcon then + local iconPath = XItemConfigs.GetItemIconById(itemId) + self.RImgIcon:SetRawImage(iconPath) + end + + if self.TxtCount then + local haveCount = itemCount or XDataCenter.ItemManager.GetCount(itemId) + self.TxtCount.text = haveCount + end + + if self.TxtCountDes then + local haveCount = XDataCenter.ItemManager.GetCount(itemId) + self.TxtCountDes.text = CSXTextManagerGetText("TRPGItemCount", haveCount)--(拥有: {0}) + end + + if self.TxtMax then + local isMaxCount = XDataCenter.TRPGManager.IsItemMaxCount(itemId) + self.TxtMax.gameObject:SetActiveEx(isMaxCount) + end + + if self.ImgQuality then + local quality = XDataCenter.ItemManager.GetItemQuality(itemId) + local qualityPath = XArrangeConfigs.GeQualityPath(quality) + self.RootUi:SetUiSprite(self.ImgQuality, qualityPath) + end + + if self.TxtName then + local itemName = XDataCenter.ItemManager.GetItemName(itemId) + self.TxtName.text = itemName + end + + if self.TxtDetails then + local desc = XDataCenter.ItemManager.GetItemDescription(itemId) + self.TxtDetails.text = desc + end + + if self.PanelTag1 then + if not XTRPGConfigs.CheckItemConfig(itemId) then + self.PanelTag1.gameObject:SetActiveEx(false) + else + + local isPrecious = XTRPGConfigs.IsItemPrecious(itemId) + if not isPrecious then + if self.ImgTag then + local tagIcon = XTRPGConfigs.GetItemTagIcon(itemId) + self.RootUi:SetUiSprite(self.ImgTag, tagIcon) + end + self.PanelTag1.gameObject:SetActiveEx(true) + else + self.PanelTag1.gameObject:SetActiveEx(false) + end + + end + end + + if self.PanelTag2 then + if not XTRPGConfigs.CheckItemConfig(itemId) then + self.PanelTag2.gameObject:SetActiveEx(false) + else + local isPrecious = XTRPGConfigs.IsItemPrecious(itemId) + self.PanelTag2.gameObject:SetActiveEx(isPrecious) + end + end +end + +function XUiGridTRPGItem:OnClickBtnClick(itemId) + if self.ClickCb then + self.ClickCb() + end +end + +return XUiGridTRPGItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTRPG/XUiGridTRPGMapCardMini.lua b/Resources/Scripts/XUi/XUiTRPG/XUiGridTRPGMapCardMini.lua new file mode 100644 index 00000000..e5cf8b12 --- /dev/null +++ b/Resources/Scripts/XUi/XUiTRPG/XUiGridTRPGMapCardMini.lua @@ -0,0 +1,33 @@ +local XUiGridTRPGMapCardMini = XClass(nil, "XUiGridTRPGMapCardMini") + +function XUiGridTRPGMapCardMini:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + + XTool.InitUiObject(self) +end + +function XUiGridTRPGMapCardMini:Refresh(cardId, isCurrentStand, isNextPos, isDisposeableForeverFinished) + local icon = XTRPGConfigs.GetMazeCardMiniIcon(cardId) + if icon then + self.UiRoot:SetUiSprite(self.ImgIcon, icon) + self.ImgIcon.gameObject:SetActiveEx(not isCurrentStand) + else + self.ImgIcon.gameObject:SetActiveEx(false) + end + + if self.ImgBg then + local showBg = not XTRPGConfigs.CheckMazeCardType(cardId, XTRPGConfigs.CardType.Block) + self.ImgBg.gameObject:SetActiveEx(showBg) + end + + self.ImgIconMe.gameObject:SetActiveEx(isCurrentStand) + self.ImgKuang.gameObject:SetActiveEx(isNextPos) + + if self.PaneCompleted then + self.PaneCompleted.gameObject:SetActiveEx(isDisposeableForeverFinished) + end +end + +return XUiGridTRPGMapCardMini \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTRPG/XUiGridTRPGMapNode.lua b/Resources/Scripts/XUi/XUiTRPG/XUiGridTRPGMapNode.lua new file mode 100644 index 00000000..525d42aa --- /dev/null +++ b/Resources/Scripts/XUi/XUiTRPG/XUiGridTRPGMapNode.lua @@ -0,0 +1,46 @@ +local XUiGridTRPGMapCardMini = require("XUi/XUiTRPG/XUiGridTRPGMapCardMini") + +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate + +local XUiGridTRPGMapNode = XClass(nil, "XUiGridTRPGMapNode") + +function XUiGridTRPGMapNode:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.CardGrids = {} + + XTool.InitUiObject(self) +end + +function XUiGridTRPGMapNode:Init(uiRoot) + self.UiRoot = uiRoot +end + +function XUiGridTRPGMapNode:Refresh(mazeId, layerId, nodeId) + local cardGrids = self.CardGrids + + local cardNum = XDataCenter.TRPGManager.GetMazeCardNum(mazeId, layerId, nodeId) + for cardIndex = 1, cardNum do + local cardId = XDataCenter.TRPGManager.GetMazeCardId(mazeId, layerId, nodeId, cardIndex) + local isCurrentStand = XDataCenter.TRPGManager.IsCardCurrentStand(mazeId, layerId, nodeId, cardIndex) + local isNextPos = XDataCenter.TRPGManager.IsCardAfterCurrentStand(mazeId, layerId, nodeId, cardIndex) + local isDisposeableForeverFinished = XDataCenter.TRPGManager.IsMazeCardDisposeableForeverFinished(mazeId, layerId, cardId) + + local grid = cardGrids[cardIndex] + if not grid then + local ui = cardIndex == 1 and self.GridCardMini or CSUnityEngineObjectInstantiate(self.GridCardMini, self.Transform) + grid = XUiGridTRPGMapCardMini.New(ui, self.UiRoot) + cardGrids[cardIndex] = grid + end + grid:Refresh(cardId, isCurrentStand, isNextPos, isDisposeableForeverFinished) + grid.GameObject:SetActiveEx(true) + end + + for i = cardNum + 1, #cardGrids do + if cardGrids[i] then + cardGrids[i].GameObject:SetActiveEx(false) + end + end +end + +return XUiGridTRPGMapNode \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTRPG/XUiGridTRPGRole.lua b/Resources/Scripts/XUi/XUiTRPG/XUiGridTRPGRole.lua new file mode 100644 index 00000000..e7e2a9ad --- /dev/null +++ b/Resources/Scripts/XUi/XUiTRPG/XUiGridTRPGRole.lua @@ -0,0 +1,34 @@ +local XUiGridTRPGRole = XClass(nil, "XUiGridTRPGRole") + +function XUiGridTRPGRole:Ctor(ui, rootUi, clickCb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + self.BtnGridRole.CallBack = function() self:OnClickBtnRole() end +end + +function XUiGridTRPGRole:Refresh(roleId) + if not roleId then + self.BtnGridRole:ShowTag(false) + self.BtnGridRole:SetDisable(true, false) + return + end + + self.BtnGridRole:ShowTag(true) + self.BtnGridRole:SetDisable(false) + + local image = XTRPGConfigs.GetRoleHeadIcon(roleId) + self.RImgRole1:SetRawImage(image) + self.RImgRole2:SetRawImage(image) + + local isUp = XDataCenter.TRPGManager.IsRoleHaveBuffUp(roleId) + self.PanelUp.gameObject:SetActiveEx(isUp) + local isDown = XDataCenter.TRPGManager.IsRoleHaveBuffDown(roleId) + self.PanelDown.gameObject:SetActiveEx(isDown) +end + +function XUiGridTRPGRole:OnClickBtnRole() +end + +return XUiGridTRPGRole \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTRPG/XUiGridTRPGRoleDetail.lua b/Resources/Scripts/XUi/XUiTRPG/XUiGridTRPGRoleDetail.lua new file mode 100644 index 00000000..2802bb38 --- /dev/null +++ b/Resources/Scripts/XUi/XUiTRPG/XUiGridTRPGRoleDetail.lua @@ -0,0 +1,94 @@ +local pairs = pairs +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate + +local CONDITION_COLOR = { + [true] = CS.UnityEngine.Color.red, + [false] = CS.UnityEngine.Color.white, +} + +local XUiGridTRPGRoleDetail = XClass(nil, "XUiGridTRPGRoleDetail") + +function XUiGridTRPGRoleDetail:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self.TalentGrids = {} + + XTool.InitUiObject(self) +end + +function XUiGridTRPGRoleDetail:Refresh(roleId, showBuffEffect) + if self.TxtName then + local roleName = XTRPGConfigs.GetRoleName(roleId) + self.TxtName.text = roleName + end + + if self.RImgHead then + local roleIcon = XTRPGConfigs.GetRoleHeadIcon(roleId) + self.RImgHead:SetRawImage(roleIcon) + end + + if self.PanelUp then + local isUp = XDataCenter.TRPGManager.IsRoleHaveBuffUp(roleId) + self.PanelUp.gameObject:SetActiveEx(isUp) + end + + if self.PanelDown then + local isDown = XDataCenter.TRPGManager.IsRoleHaveBuffDown(roleId) + self.PanelDown.gameObject:SetActiveEx(isDown) + end + + local attributes = XDataCenter.TRPGManager.GetRoleAttributes(roleId) + for index, attr in pairs(attributes) do + + local img = self["ImgAttr" .. index] + if img then + local attrIcon = XTRPGConfigs.GetRoleAttributeIcon(attr.Type) + self.RootUi:SetUiSprite(img, attrIcon) + + if showBuffEffect then + local isDown = XDataCenter.TRPGManager.IsRoleHaveBuffDown(roleId) + img.color = CONDITION_COLOR[isDown] + end + end + + local textAttr = self["TxtAttr" .. index] + if textAttr then + textAttr.text = attr.Value + + if showBuffEffect then + local isDown = XDataCenter.TRPGManager.IsRoleHaveBuffDown(roleId) + textAttr.color = CONDITION_COLOR[isDown] + end + end + + end + + if self.TxtTalent and self.PanelTalent then + self.TxtTalent.gameObject:SetActiveEx(false) + local talentIds = XDataCenter.TRPGManager.GetRoleCommonTalentIds(roleId) + for index, talentId in pairs(talentIds) do + local grid = self.TalentGrids[index] + if not grid then + local ui = index == 1 and self.TxtTalent or CSUnityEngineObjectInstantiate(self.TxtTalent.gameObject, self.PanelTalent) + grid = { + GameObject = ui.gameObject, + Transform = ui.transform, + } + XTool.InitUiObject(grid) + self.TalentGrids[index] = grid + end + grid.Txt.text = XTRPGConfigs.GetRoleTalentDescription(roleId, talentId) + grid.GameObject:SetActiveEx(true) + end + + for i = #talentIds + 1, #self.TalentGrids do + local grid = self.TalentGrids[i] + if grid then + grid.GameObject:SetActiveEx(false) + end + end + end +end + +return XUiGridTRPGRoleDetail \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTRPG/XUiGridTRPGRoleTalent.lua b/Resources/Scripts/XUi/XUiTRPG/XUiGridTRPGRoleTalent.lua new file mode 100644 index 00000000..41c3a01c --- /dev/null +++ b/Resources/Scripts/XUi/XUiTRPG/XUiGridTRPGRoleTalent.lua @@ -0,0 +1,45 @@ +local ICON_NUM = 3 + +local handler = handler + +local XUiGridTRPGRoleTalent = XClass(nil, "XUiGridTRPGRoleTalent") + +function XUiGridTRPGRoleTalent:Ctor(ui, clickCb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.ClickCb = clickCb + + XTool.InitUiObject(self) + self.BtnClick.CallBack = handler(self, self.OnClickBtnClick) + self.PanelSelect2 = self.Transform:FindTransform("PanelSelect2") +end + +function XUiGridTRPGRoleTalent:Refresh(roleId, talentId) + self.RoleId = roleId + self.TalentId = talentId + + local icon = XTRPGConfigs.GetRoleTalentIcon(roleId, talentId) + for i = 1, ICON_NUM do + self["RImgTalentIcon" .. i]:SetRawImage(icon) + end + + local isActive = XDataCenter.TRPGManager.IsRoleTalentActive(roleId, talentId) + local canActive = XDataCenter.TRPGManager.IsRoleTalentCanActive(roleId, talentId) + self.PanelSelect.gameObject:SetActiveEx(isActive) + self.PanelLock.gameObject:SetActiveEx(not canActive) + self.PanelNormal.gameObject:SetActiveEx(not isActive and canActive) +end + +function XUiGridTRPGRoleTalent:OnClickBtnClick() + if self.ClickCb then + self.ClickCb(self.RoleId, self.TalentId) + end +end + +function XUiGridTRPGRoleTalent:SetSelect(value) + if self.PanelSelect2 then + self.PanelSelect2.gameObject:SetActiveEx(value) + end +end + +return XUiGridTRPGRoleTalent \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTRPG/XUiGridTRPGTestAction.lua b/Resources/Scripts/XUi/XUiTRPG/XUiGridTRPGTestAction.lua new file mode 100644 index 00000000..f8eccd98 --- /dev/null +++ b/Resources/Scripts/XUi/XUiTRPG/XUiGridTRPGTestAction.lua @@ -0,0 +1,61 @@ +local CSXTextManagerGetText = CS.XTextManager.GetText + +local CONDITION_COLOR = { + [true] = XUiHelper.Hexcolor2Color("59F5FFFF"), + [false] = CS.UnityEngine.Color.red, +} + +local XUiGridTRPGTestAction = XClass(nil, "XUiGridTRPGTestAction") + +function XUiGridTRPGTestAction:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + self:SetSelect(false) +end + +function XUiGridTRPGTestAction:Refresh(actionId) + self.ActionId = actionId + + local desc = XTRPGConfigs.GetExamineActionDesc(actionId) + self.TxtName.text = desc + + local icon = XTRPGConfigs.GetExamineActionIcon(actionId) + self.RImgAttributeIcon:SetRawImage(icon) + + if XTRPGConfigs.CheckExamineActionType(actionId, XTRPGConfigs.TRPGExamineActionType.ConsumeItem) then + self.TxtDifficulty.gameObject:SetActiveEx(false) + self.TxtRound.transform.parent.gameObject:SetActiveEx(false) + + + local itemId = XTRPGConfigs.GetExamineActionItemId(actionId) + local itemCount = 1 + local pass = XDataCenter.ItemManager.CheckItemCountById(itemId, itemCount) + local desc = pass and CSXTextManagerGetText("TRPGExploreExmaineUseItemReqValue") or CSXTextManagerGetText("TRPGExploreExmaineUseItemReqValueDeny") + self.TxtReqPoints.text = desc + self.TxtReqPoints.color = CONDITION_COLOR[pass] + + else + local difficulty = XDataCenter.TRPGManager.GetExamineActionDifficult(actionId) + local difficultyDes = XTRPGConfigs.GetExamineActionDifficultDesc(difficulty) + self.TxtDifficulty.text = difficultyDes + self.TxtDifficulty.gameObject:SetActiveEx(true) + + local reqPoints = XTRPGConfigs.GetExamineActionNeedValue(actionId) + self.TxtReqPoints.text = reqPoints + + local totalRound = XTRPGConfigs.GetExamineActionRound(actionId) + self.TxtRound.text = CSXTextManagerGetText("TRPGExploreExmaineTotalRound", totalRound) + self.TxtRound.transform.parent.gameObject:SetActiveEx(true) + end + + local desc = XTRPGConfigs.GetExamineActionTypeDesc(actionId) + self.TxtAttribute.text = desc +end + +function XUiGridTRPGTestAction:SetSelect(value) + self.ImgSelect.gameObject:SetActiveEx(value) +end + +return XUiGridTRPGTestAction \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTRPG/XUiGridTRPGTestItem.lua b/Resources/Scripts/XUi/XUiTRPG/XUiGridTRPGTestItem.lua new file mode 100644 index 00000000..95c83fa0 --- /dev/null +++ b/Resources/Scripts/XUi/XUiTRPG/XUiGridTRPGTestItem.lua @@ -0,0 +1,62 @@ +local CSXTextManagerGetText = CS.XTextManager.GetText + +local XUiGridTRPGTestItem = XClass(nil, "XUiGridTRPGTestItem") + +function XUiGridTRPGTestItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + self:SetSelect(false) +end + +function XUiGridTRPGTestItem:InitClickCb(clickCb) + self.BtnClick.CallBack = clickCb +end + +function XUiGridTRPGTestItem:Refresh(itemId, actionId) + self.ItemId = itemId + + if XTRPGConfigs.CheckDefaultEffectItemId(itemId) then + + local desc = XTRPGConfigs.GetExamineActionTypeDefaultItemDesc(actionId) + self.BtnClick:SetNameByGroup(0, desc) + + local desc1 = "" + self.BtnClick:SetNameByGroup(1, desc1) + + local icon = XTRPGConfigs.GetExamineActionIcon(actionId) + self.BtnClick:SetRawImage(icon) + + else + + local desc = XTRPGConfigs.GetItemParamDesc(itemId) + self.BtnClick:SetNameByGroup(0, desc) + + local curNum = XDataCenter.ItemManager.GetCount(itemId) + local maxNum = XDataCenter.TRPGManager.GetItemMaxCount(itemId) + local desc1 = curNum .. "/" .. maxNum + self.BtnClick:SetNameByGroup(1, desc1) + + local icon = XItemConfigs.GetItemIconById(itemId) + self.BtnClick:SetRawImage(icon) + + local isDis = XDataCenter.ItemManager.GetCount(itemId) <= 0 + self.BtnClick:SetDisable(isDis) + + end +end + +function XUiGridTRPGTestItem:SetSelect(value) + local itemId = self.ItemId + local isDis = not XTRPGConfigs.CheckDefaultEffectItemId(itemId) and XDataCenter.ItemManager.GetCount(itemId) <= 0 + + if value then + self.BtnClick:SetButtonState(isDis and CS.UiButtonState.Disable or CS.UiButtonState.Select) + else + self.BtnClick:SetButtonState(isDis and CS.UiButtonState.Disable or CS.UiButtonState.Normal) + end + +end + +return XUiGridTRPGTestItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTRPG/XUiGridTRPGTestRole.lua b/Resources/Scripts/XUi/XUiTRPG/XUiGridTRPGTestRole.lua new file mode 100644 index 00000000..49bacc51 --- /dev/null +++ b/Resources/Scripts/XUi/XUiTRPG/XUiGridTRPGTestRole.lua @@ -0,0 +1,148 @@ +local handler = handler +local CSXTextManagerGetText = CS.XTextManager.GetText +local Lerp = CS.UnityEngine.Mathf.Lerp +local mathFloor = math.floor +local CSXScheduleManagerUnSchedule = XScheduleManager.UnSchedule + +local SCORE_ANIM_DURATION = 0.5--分数滚动动画时间 +local CONDITION_COLOR = { + [true] = XUiHelper.Hexcolor2Color("59f5ffff"), + [false] = XUiHelper.Hexcolor2Color("0E70BDFF"), +} + +local stringGsub = string.gsub + +local XUiGridTRPGTestRole = XClass(nil, "XUiGridTRPGTestRole") + +function XUiGridTRPGTestRole:Ctor(ui, clickCb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + + XTool.InitUiObject(self) + + self.BtnClick.CallBack = clickCb + self.BtnReset.CallBack = handler(self, self.OnClickBtnReset) +end + +function XUiGridTRPGTestRole:Refresh(roleId, actionId, addAttribute, needScoreChangeAnim, needEffect) + self.RoleId = roleId + self.ActionId = actionId + + local score = XDataCenter.TRPGManager.GetCurExamineRoleScore(roleId) + if score == 0 then + self.TxtAttributeNumber.gameObject:SetActiveEx(false) + self.TxtDoubt.gameObject:SetActiveEx(true) + else + self.TxtDoubt.gameObject:SetActiveEx(false) + self.TxtAttributeNumber.gameObject:SetActiveEx(true) + if needScoreChangeAnim then + local startScore = tonumber(self.TxtAttributeNumber.text) or 0 + self:LetScoreRoll(startScore, score) + else + self.TxtAttributeNumber.text = score + end + end + + local roleIcon = XTRPGConfigs.GetRoleHeadIcon(roleId) + self.RImgRole:SetRawImage(roleIcon) + + local icon = XTRPGConfigs.GetExamineActionIcon(actionId) + self.BtnClick:SetRawImage(icon) + + local attributeType = XTRPGConfigs.GetExamineActionNeedAttrType(actionId) + local minValue = XDataCenter.TRPGManager.GetRoleAttributeMinRollValue(roleId, attributeType) + local maxValue = XDataCenter.TRPGManager.GetRoleAttributeMaxRollValue(roleId, attributeType) + if addAttribute > 0 then + minValue = minValue + addAttribute + maxValue = maxValue + addAttribute + end + local rangeStr = minValue .. "~" .. maxValue + local passCondition = addAttribute and addAttribute > 0 or false + local color = CONDITION_COLOR[passCondition] + self.BtnClick:SetNameAndColorByGroup(0, rangeStr, color) + + local isRolled = XDataCenter.TRPGManager.IsExamineRoleAlreadyRolled(roleId) + self.BtnReset.gameObject:SetActiveEx(isRolled) + + if needEffect then + self.Effect.gameObject:SetActiveEx(false) + self.Effect.gameObject:SetActiveEx(true) + end +end + +function XUiGridTRPGTestRole:OnClickBtnReset() + local roleId = self.RoleId + local actionId = self.ActionId + + local costItemId, costItemCount = XTRPGConfigs.GetExamineActionResetCostItemInfo(actionId) + if not XDataCenter.ItemManager.CheckItemCountById(costItemId, costItemCount) then + XUiManager.TipText("TRPGExploreExmaineResetLackItem") + return + end + + local curRoleScore = XDataCenter.TRPGManager.GetCurExamineRoleScore(roleId) + if curRoleScore == 0 then + XUiManager.TipText("TRPGExploreExmaineResetDoNotNeed") + return + end + + local itemName = XDataCenter.ItemManager.GetItemName(costItemId) + local itemCount = XDataCenter.ItemManager.GetCount(costItemId) + local title = CSXTextManagerGetText("TRPGExploreExmaineResetTipsTitle") + local content = CSXTextManagerGetText("TRPGExploreExmaineResetTipsContent", itemName, costItemCount, itemCount) + content = stringGsub(content, "\\n", "\n") + local callFunc = function() + XDataCenter.TRPGManager.TRPGExamineCharacterResetRequest(roleId) + + end + XUiManager.SystemDialogTip(title, content, XUiManager.DialogType.Normal, nil, callFunc) +end + +function XUiGridTRPGTestRole:SetSelect(value) + if self._IsDisable then return end + self._IsSelect = value + + self.BtnClick:SetButtonState(value and CS.UiButtonState.Select or CS.UiButtonState.Normal) +end + +function XUiGridTRPGTestRole:IsDisable() + return self._IsDisable or false +end + +function XUiGridTRPGTestRole:SetDisable(value) + self._IsDisable = value + + local originStatus = self._IsSelect and CS.UiButtonState.Select or CS.UiButtonState.Normal + self.BtnClick:SetButtonState(value and CS.UiButtonState.Disable or originStatus) + + self.RImgRole.gameObject:SetActiveEx(not value) +end + +function XUiGridTRPGTestRole:LetScoreRoll(startScore, targetScore) + if not startScore or not targetScore then return end + + local onRefreshFunc = function(time) + if XTool.UObjIsNil(self.TxtAttributeNumber) then + self:DestroyTimer() + return true + end + + if startScore == targetScore then + return true + end + + self.TxtAttributeNumber.text = mathFloor(Lerp(startScore, targetScore, time)) + end + + self:DestroyTimer() + self.Timer = XUiHelper.Tween(SCORE_ANIM_DURATION, onRefreshFunc) +end + +function XUiGridTRPGTestRole:DestroyTimer() + if self.Timer then + CSXScheduleManagerUnSchedule(self.Timer) + self.Timer = nil + end +end + +return XUiGridTRPGTestRole \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTRPG/XUiTRPGBag/XUiTRPGBag.lua b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGBag/XUiTRPGBag.lua new file mode 100644 index 00000000..329ec265 --- /dev/null +++ b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGBag/XUiTRPGBag.lua @@ -0,0 +1,100 @@ +--背包 +local XUiTRPGGridItem = require("XUi/XUiTRPG/XUiGridTRPGItem") +local XUiTRPGItemUsePanel = require("XUi/XUiTRPG/XUiTRPGBag/XUiTRPGItemUsePanel") + +local XUiTRPGBag = XLuaUiManager.Register(XLuaUi, "UiTRPGBag") +local AllUseCharacterId = 0 + +function XUiTRPGBag:OnAwake() + self:AutoAddListener() + self:InitTabGroup() + self.ItemUsePanel = XUiTRPGItemUsePanel.New(self.PanelPick, self, function() self:Refresh() end) + self.ItemUsePanel:Close() + + self.GridTRPGSpecialItem.gameObject:SetActiveEx(false) + + self.AssetActivityPanel = XUiPanelActivityAsset.New(self.PanelSpecialTool) + XDataCenter.ItemManager.AddCountUpdateListener(XDataCenter.ItemManager.ItemId.TRPGMoney, function() + self.AssetActivityPanel:Refresh({XDataCenter.ItemManager.ItemId.TRPGMoney}) + end, self.AssetActivityPanel) + self.AssetActivityPanel:Refresh({XDataCenter.ItemManager.ItemId.TRPGMoney}) +end + +function XUiTRPGBag:OnStart() + self:InitDynamicTable() +end + +function XUiTRPGBag:OnEnable() + self:Refresh() +end + +function XUiTRPGBag:AutoAddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) +end + +function XUiTRPGBag:InitTabGroup() + self.CurGroupIndex = XTRPGConfigs.ItemType.Normal + self.TabGroup = {} + self.TabGroup[XTRPGConfigs.ItemType.Normal] = self.TabNor + self.TabGroup[XTRPGConfigs.ItemType.Special] = self.TabSpec + + self.PanelTab:Init(self.TabGroup, function(groupIndex) self:TabGroupSkip(groupIndex) end) + self.PanelTab:SelectIndex(self.CurGroupIndex) +end + +function XUiTRPGBag:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelItemList) + self.DynamicTable:SetProxy(XUiTRPGGridItem, self) + self.DynamicTable:SetDelegate(self) +end + +function XUiTRPGBag:Refresh() + self.Data = XDataCenter.TRPGManager.GetItemListByType(self.CurGroupIndex) + self.TxtNone.gameObject:SetActiveEx(#self.Data == 0) + self.DynamicTable:SetDataSource(self.Data) + self.DynamicTable:ReloadDataSync() +end + +function XUiTRPGBag:TabGroupSkip(groupIndex) + if self.CurGroupIndex == groupIndex then + return + end + self.CurGroupIndex = groupIndex + self:Refresh() +end + +function XUiTRPGBag:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local itemId = self.Data[index].Id + grid:Refresh(itemId) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + local itemId = self.Data[index].Id + if XTRPGConfigs.IsItemSelectCharacter(itemId) then + self.ItemUsePanel:Open(itemId) + else + local itemData = { + Data = XDataCenter.ItemManager.GetItem(itemId) + } + local isShowUse = XTRPGConfigs.IsItemShowUse(itemId) + XLuaUiManager.Open("UiBagItemInfoPanel", itemData, function(itemId, selectCount) + self:AllCharacterUseCallback(itemId, selectCount) + end, isShowUse) + end + end +end + +function XUiTRPGBag:AllCharacterUseCallback(itemId, selectCount) + local cb = function() + self:Refresh() + end + XDataCenter.TRPGManager.RequestUseItemRequestSend(itemId, selectCount, AllUseCharacterId, cb) +end + +function XUiTRPGBag:OnBtnBackClick() + self:Close() +end + +function XUiTRPGBag:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTRPG/XUiTRPGBag/XUiTRPGBagGrid.lua b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGBag/XUiTRPGBagGrid.lua new file mode 100644 index 00000000..072dac4c --- /dev/null +++ b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGBag/XUiTRPGBagGrid.lua @@ -0,0 +1,16 @@ +local XUiTRPGBagGrid = XClass(nil, "XUiTRPGBagGrid") + +function XUiTRPGBagGrid:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiTRPGBagGrid:Refresh() + -- self.TxtNum.text = --拥有数量 + -- self.TxtItemName.text = + -- self.TextItemDesc = + -- self.RImgIcon:SetRawImage() +end + +return XUiTRPGBagGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTRPG/XUiTRPGBag/XUiTRPGItemUsePanel.lua b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGBag/XUiTRPGItemUsePanel.lua new file mode 100644 index 00000000..f52d9334 --- /dev/null +++ b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGBag/XUiTRPGItemUsePanel.lua @@ -0,0 +1,165 @@ +local HeadMaxNum = 4 +local CSXTextManagerGetText = CS.XTextManager.GetText +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate + +local XUiGridTRPGBuff = require("XUi/XUiTRPG/XUiGridTRPGBuff") + +--使用道具界面 +local XUiTRPGItemUsePanel = XClass(nil, "XUiTRPGItemUsePanel") + +function XUiTRPGItemUsePanel:Ctor(ui, rootUi, cb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self.Cb = cb + XTool.InitUiObject(self) + + self:Init() + self:AutoAddListener() +end + +function XUiTRPGItemUsePanel:Init() + self.ButtonGroup = {} + local headIcon + local allRoleIds = XTRPGConfigs.GetAllRoleIds() + local roleId + for i = 1, HeadMaxNum do + roleId = allRoleIds[i] + headIcon = XTRPGConfigs.GetRoleHeadIcon(roleId) + self["head" .. i]:SetRawImage(headIcon) + self.ButtonGroup[i] = self["head" .. i] + end + + self.PanelHead:Init(self.ButtonGroup, function(groupIndex) self:ButtonGroupSkip(groupIndex) end) + + self.BuffGrids = {} +end + +function XUiTRPGItemUsePanel:AutoAddListener() + CsXUiHelper.RegisterClickEvent(self.BtnTongBlack, function() self:OnBtnUseClick() end) + CsXUiHelper.RegisterClickEvent(self.BtnTongBlue, function() self:Close() end) + CsXUiHelper.RegisterClickEvent(self.BtnTanchuangClose, function() self:Close() end) +end + +function XUiTRPGItemUsePanel:OnBtnUseClick() + local allRoleIds = XTRPGConfigs.GetAllRoleIds() + local roleId = allRoleIds[self.SelectCharacter] + XDataCenter.TRPGManager.RequestUseItemRequestSend(self.ItemId, 1, roleId, self.Cb) + self:Close() +end + +function XUiTRPGItemUsePanel:ButtonGroupSkip(groupIndex) + if self.SelectCharacter == groupIndex then return end + + local allRoleIds = XTRPGConfigs.GetAllRoleIds() + local roleId = allRoleIds[groupIndex] + local isRoleOwn = XDataCenter.TRPGManager.IsRoleOwn(roleId) + if not isRoleOwn then return end + + self.SelectCharacter = groupIndex + self:UpdateBuff() +end + +function XUiTRPGItemUsePanel:Open(itemId) + self.RootUi:PlayAnimation("AnimPanelPickEnable") + self.ItemId = itemId + self:Refresh() + self.GameObject:SetActiveEx(true) + self:SelectOwnCharacter() +end + +function XUiTRPGItemUsePanel:SelectOwnCharacter() + local allRoleIds = XTRPGConfigs.GetAllRoleIds() + local roleId + for i = 1, HeadMaxNum do + roleId = allRoleIds[i] + if XDataCenter.TRPGManager.IsRoleOwn(roleId) then + self.PanelHead:SelectIndex(i) + return + end + end +end + +function XUiTRPGItemUsePanel:Refresh() + local ownItemCount = XDataCenter.ItemManager.GetCount(self.ItemId) + self.TxtCount.text = CSXTextManagerGetText("TRPGUseNum", 1) + self.TextDesc.text = XDataCenter.ItemManager.GetItemDescription(self.ItemId) + self.TextOwn.text = CSXTextManagerGetText("TRPGHaveDesc", ownItemCount) + + local quality = XDataCenter.ItemManager.GetItemQuality(self.ItemId) + local qualityPath = XArrangeConfigs.GeQualityPath(quality) + self.RootUi:SetUiSprite(self.ImgQuality, qualityPath) + + local itemIcon = XDataCenter.ItemManager.GetItemBigIcon(self.ItemId) + self.RImgIcon:SetRawImage(itemIcon) + + self:UpdateHead() +end + +function XUiTRPGItemUsePanel:UpdateHead() + local isRoleOwn + local allRoleIds = XTRPGConfigs.GetAllRoleIds() + local roleId + for i = 1, HeadMaxNum do + roleId = allRoleIds[i] + isRoleOwn = XDataCenter.TRPGManager.IsRoleOwn(roleId) + self.ButtonGroup[i]:SetDisable(not isRoleOwn) + self:UpdateBuffTag(roleId, isRoleOwn, i) + end +end + +function XUiTRPGItemUsePanel:UpdateBuff() + if not self.FuBenTRPGBuff or not self.PanelBuffContent then + return + end + local allRoleIds = XTRPGConfigs.GetAllRoleIds() + local roleId = allRoleIds[self.SelectCharacter] + local buffIds = XDataCenter.TRPGManager.GetRoleBuffIds(roleId) + local buffGrids = self.BuffGrids + for index, buffId in pairs(buffIds) do + local grid = buffGrids[index] + if not grid then + local ui = index == 1 and self.FuBenTRPGBuff or CSUnityEngineObjectInstantiate(self.FuBenTRPGBuff, self.PanelBuffContent) + grid = XUiGridTRPGBuff.New(ui, self.RootUi) + buffGrids[index] = grid + end + + grid:Refresh(buffId) + grid.GameObject:SetActiveEx(true) + end + for index = #buffIds + 1, #buffGrids do + local grid = buffGrids[index] + if grid then + grid.GameObject:SetActiveEx(false) + end + end +end + +function XUiTRPGItemUsePanel:UpdateBuffTag(roleId, isRoleOwn, index) + local imgUp = self["ImgUp" .. index] + local imgDown = self["ImgDown" .. index] + if not roleId or not isRoleOwn then + if imgUp then + imgUp.gameObject:SetActiveEx(false) + end + if imgDown then + imgDown.gameObject:SetActiveEx(false) + end + return + end + + local isUp = XDataCenter.TRPGManager.IsRoleHaveBuffUp(roleId) + if imgUp then + imgUp.gameObject:SetActiveEx(isUp) + end + local isDown = XDataCenter.TRPGManager.IsRoleHaveBuffDown(roleId) + if imgDown then + imgDown.gameObject:SetActiveEx(isDown) + end +end + +function XUiTRPGItemUsePanel:Close() + self.GameObject:SetActiveEx(false) +end + +return XUiTRPGItemUsePanel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTRPG/XUiTRPGBuffDetail.lua b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGBuffDetail.lua new file mode 100644 index 00000000..a61ea456 --- /dev/null +++ b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGBuffDetail.lua @@ -0,0 +1,32 @@ +local XUiTRPGBuffDetail = XLuaUiManager.Register(XLuaUi, "UiTRPGBuffDetail") + +function XUiTRPGBuffDetail:OnAwake() + self:AutoAddListener() +end + +function XUiTRPGBuffDetail:OnStart(buffId) + self.BuffId = buffId + + self:InitUi() +end + +function XUiTRPGBuffDetail:InitUi() + local buffId = self.BuffId + + local icon = XTRPGConfigs.GetBuffIcon(buffId) + self:SetUiSprite(self.ImgIcon, icon) + + local name = XTRPGConfigs.GetBuffName(buffId) + self.TxtName.text = name + + local desc = XTRPGConfigs.GetBuffDesc(buffId) + self.TxtWorldDesc.text = desc +end + +function XUiTRPGBuffDetail:AutoAddListener() + self:RegisterClickEvent(self.BtnTanchuangCloseBig, self.OnBtnBackClick) +end + +function XUiTRPGBuffDetail:OnBtnBackClick() + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTRPG/XUiTRPGCollection.lua b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGCollection.lua new file mode 100644 index 00000000..3f62f4a4 --- /dev/null +++ b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGCollection.lua @@ -0,0 +1,120 @@ +local CSXTextManagerGetText = CS.XTextManager.GetText + +--探索营地界面-珍藏界面 +local XUiTRPGCollection = XLuaUiManager.Register(XLuaUi, "UiTRPGCollection") + +function XUiTRPGCollection:OnAwake() + XDataCenter.TRPGManager.SaveIsAlreadyOpenCollection() + + self:InitTabGroup() + self:AutoAddListener() + + self.AssetActivityPanel = XUiPanelActivityAsset.New(self.PanelSpecialTool) + XDataCenter.ItemManager.AddCountUpdateListener(XDataCenter.ItemManager.ItemId.TRPGMoney, function() + self.AssetActivityPanel:Refresh({XDataCenter.ItemManager.ItemId.TRPGMoney}) + end, self.AssetActivityPanel) + self.AssetActivityPanel:Refresh({XDataCenter.ItemManager.ItemId.TRPGMoney}) +end + +function XUiTRPGCollection:OnEnable() + self:Refresh() +end + +function XUiTRPGCollection:Refresh() + local itemId = XTRPGConfigs.GetMemoireStoryUnlockItemId(self.CurGroupIndex) + local ownCount = XDataCenter.ItemManager.GetCount(itemId) + local maxCount = XTRPGConfigs.GetMemoireStoryUnlockItemCount(self.CurGroupIndex) + self.TxtSuiPian.text = CSXTextManagerGetText("TRPGMemoryChip", ownCount, maxCount) + + self.TxtTitle.text = XTRPGConfigs.GetMemoireStoryName(self.CurGroupIndex) + self.TxtDesc.text = XTRPGConfigs.GetMemoireStoryDesc(self.CurGroupIndex) + + local icon = XDataCenter.ItemManager.GetItemBigIcon(itemId) + self.Icon:SetRawImage(icon) + + local imgCG = XTRPGConfigs.GetMemoireStoryImgCG(self.CurGroupIndex) + self.ImgCG:SetRawImage(imgCG) + + self.ImgDark.gameObject:SetActiveEx(ownCount < maxCount) + + self:OnCheckTabGroupRedPoint() + self:OnCheckBtnTongBlackRedPoint() +end + +function XUiTRPGCollection:InitTabGroup() + self.CurGroupIndex = 1 + self.TabGroup = {} + local tabName + local maxNum = XTRPGConfigs.GetMemoirStoryMaxNum() + for i = 1, maxNum do + self.TabGroup[i] = self["TabStory" .. i] + tabName = XTRPGConfigs.GetMemoireStoryTabName(i) + self.TabGroup[i]:SetName(tabName) + end + + self.PanelStoryTab:Init(self.TabGroup, function(groupIndex) self:TabGroupSkip(groupIndex) end) + self.PanelStoryTab:SelectIndex(self.CurGroupIndex) +end + +function XUiTRPGCollection:TabGroupSkip(groupIndex) + self:PlayAnimation("QieHuan") + + if self.CurGroupIndex == groupIndex then return end + self.CurGroupIndex = groupIndex + self:Refresh() +end + +function XUiTRPGCollection:AutoAddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:RegisterClickEvent(self.BtnTongBlack, self.OnBtnTongBlackClick) + self:RegisterClickEvent(self.BtnIcon, self.OnBtnIconClick) +end + +function XUiTRPGCollection:OnBtnIconClick() + local itemId = XTRPGConfigs.GetMemoireStoryUnlockItemId(self.CurGroupIndex) + local ownCount = XDataCenter.ItemManager.GetCount(itemId) + local data = {Id = itemId, Count = ownCount} + XLuaUiManager.Open("UiTip", data) +end + +function XUiTRPGCollection:OnBtnTongBlackClick() + local isCanPlay = XDataCenter.TRPGManager.IsCanPlayMemoir(self.CurGroupIndex) + if not isCanPlay then + XUiManager.TipText("TRPGMemoryNotPlayTipsDesc") + return + end + + local cb + local movieId = XTRPGConfigs.GetMemoireStoryId(self.CurGroupIndex) + if not XDataCenter.TRPGManager.IsPlayedMemoir(self.CurGroupIndex) then + cb = function() + XDataCenter.TRPGManager.RequestTRPGOpenMemoirSend(self.CurGroupIndex, function() self:Refresh() end) + end + end + XDataCenter.MovieManager.PlayMovie(movieId, cb) +end + +function XUiTRPGCollection:OnBtnBackClick() + self:Close() +end + +function XUiTRPGCollection:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiTRPGCollection:OnCheckTabGroupRedPoint() + local maxNum = XTRPGConfigs.GetMemoirStoryMaxNum() + local isShow + for i = 1, maxNum do + if self.TabGroup[i] then + isShow = XDataCenter.TRPGManager.CheckFirstPlayMemoirStoryById(i) + self.TabGroup[i]:ShowReddot(isShow) + end + end +end + +function XUiTRPGCollection:OnCheckBtnTongBlackRedPoint() + local isShow = XDataCenter.TRPGManager.CheckFirstPlayMemoirStoryById(self.CurGroupIndex) + self.BtnTongBlack:ShowReddot(isShow) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTRPG/XUiTRPGCommitItem.lua b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGCommitItem.lua new file mode 100644 index 00000000..77689bed --- /dev/null +++ b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGCommitItem.lua @@ -0,0 +1,40 @@ +local XUiGridTRPGItem = require("XUi/XUiTRPG/XUiGridTRPGItem") + +local CSXTextManagerGetText = CS.XTextManager.GetText + +local XUiTRPGCommitItem = XLuaUiManager.Register(XLuaUi, "UiTRPGCommitItem") + +function XUiTRPGCommitItem:OnAwake() + self:AutoAddListener() +end + +function XUiTRPGCommitItem:OnStart(itemId) + self.ItemId = itemId +end + +function XUiTRPGCommitItem:OnEnable() + self:UpdateItem() +end + +function XUiTRPGCommitItem:UpdateItem() + local itemId = self.ItemId + + local grid = self.ItemGrid + if not grid then + grid = XUiGridTRPGItem.New(self.GridItem, self) + self.ItemGrid = grid + end + grid:Refresh(itemId) + + local itemName = XDataCenter.ItemManager.GetItemName(itemId) + self.TxtInfo.text = CSXTextManagerGetText("TRPGItemCommited", itemName) +end + +function XUiTRPGCommitItem:AutoAddListener() + self:RegisterClickEvent(self.BtnTanchuangCloseBig, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnConfirm, self.OnBtnBackClick) +end + +function XUiTRPGCommitItem:OnBtnBackClick() + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTRPG/XUiTRPGDialog.lua b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGDialog.lua new file mode 100644 index 00000000..644d5bbb --- /dev/null +++ b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGDialog.lua @@ -0,0 +1,37 @@ +--等级天赋说明弹窗 +local XUiTRPGDialog = XLuaUiManager.Register(XLuaUi, "UiTRPGDialog") + +function XUiTRPGDialog:OnAwake() + XDataCenter.TRPGManager.CheckSaveIsAlreadyOpenPanelLevel() + self:AutoAddListener() +end + +function XUiTRPGDialog:OnStart() + XEventManager.DispatchEvent(XEventId.EVENT_TRPG_OPEN_LEVEL_DIALOG) +end + +function XUiTRPGDialog:OnEnable() + local curLevel = XDataCenter.TRPGManager.GetExploreLevel() + local isMaxLevel = XTRPGConfigs.IsMaxLevel(curLevel) + --当前等级和天赋点 + self.TextNum1.text = curLevel + self.TextTianfuNum1.text = XTRPGConfigs.GetMaxTalentPoint(curLevel) + if isMaxLevel then + self.Image.gameObject:SetActiveEx(false) + self.PanelNextLv.gameObject:SetActiveEx(false) + else + --下一级等级和天赋点 + self.TextNum2.text = curLevel + 1 + self.TextTianfuNum2.text = XTRPGConfigs.GetMaxTalentPoint(curLevel + 1) + self.Image.gameObject:SetActiveEx(true) + self.PanelNextLv.gameObject:SetActiveEx(true) + end +end + +function XUiTRPGDialog:AutoAddListener() + self:RegisterClickEvent(self.BtnTanchuangCloseBig, self.OnBtnTanchuangCloseBigClick) +end + +function XUiTRPGDialog:OnBtnTanchuangCloseBigClick() + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTRPG/XUiTRPGExploreChapter.lua b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGExploreChapter.lua new file mode 100644 index 00000000..6a6a5e51 --- /dev/null +++ b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGExploreChapter.lua @@ -0,0 +1,109 @@ +--城市内地图 +local XUiTRPGExploreChapter = XLuaUiManager.Register(XLuaUi, "UiTRPGExploreChapter") + +local XUiTRPGPanelTask = require("XUi/XUiTRPG/XUiTRPGPanel/XUiTRPGPanelTask") +local XUiTRPGPanelPlotTab = require("XUi/XUiTRPG/XUiTRPGPanel/XUiTRPGPanelPlotTab") +local XUiTRPGPanelLevel = require("XUi/XUiTRPG/XUiTRPGPanel/XUiTRPGPanelLevel") + +function XUiTRPGExploreChapter:OnAwake() + self.GridList = {} + self:AutoAddListener() + XUiTRPGPanelPlotTab.New(self.PanelPlotTab) + self.TaskPanel = XUiTRPGPanelTask.New(self.PanelTask, self) + self.LevelPanel = XUiTRPGPanelLevel.New(self.PanelLevel) +end + +function XUiTRPGExploreChapter:OnStart(secondAreaId, mainAreaId) + XDataCenter.TRPGManager.SaveIsAlreadyOpenExploreChapter(secondAreaId, mainAreaId) + self.SecondAreaId = secondAreaId + self.MainAreaId = mainAreaId + + self.TxtName.text = XTRPGConfigs.GetSecondAreaName(secondAreaId) + + local bgPath = XTRPGConfigs.GetExploreChapterBg(secondAreaId) + self.Background:SetRawImage(bgPath) + + local btnName, iconPath + local thirdAreaIdList = XTRPGConfigs.GetThirdAreaIdList(secondAreaId) + for i, thirdAreaId in ipairs(thirdAreaIdList) do + if not self.GridList[i] then + local grid + if i == 1 then + grid = self.GridPanelChapter + else + grid = CS.UnityEngine.Object.Instantiate(self.GridPanelChapter) + grid.transform:SetParent(self.PanelChapter, false) + end + local thirdAreaIdTemp = thirdAreaId + self:RegisterClickEvent(grid, function() self:OnGridClick(thirdAreaIdTemp) end) + self.GridList[i] = grid + end + btnName = XTRPGConfigs.GetThirdAreaName(thirdAreaId) + iconPath = XTRPGConfigs.GetThirdAreaIcon(thirdAreaId) + self.GridList[i]:SetName(btnName) + self.GridList[i]:SetRawImage(iconPath) + end +end + +function XUiTRPGExploreChapter:OnEnable() + XDataCenter.TRPGManager.CheckActivityEnd() + XDataCenter.TRPGManager.CheckOpenNewMazeTips() + self:Refresh() + self.TaskPanel:OnEnable() +end + +function XUiTRPGExploreChapter:OnDisable() + self.TaskPanel:OnDisable() +end + +function XUiTRPGExploreChapter:OnDestroy() + self.TaskPanel:Delete() + self.LevelPanel:Delete() +end + +function XUiTRPGExploreChapter:Refresh() + self:UpdateGridList() +end + +function XUiTRPGExploreChapter:UpdateGridList() + local thirdAreaIdList = XTRPGConfigs.GetThirdAreaIdList(self.SecondAreaId) + local conditionId + local ret + local isThirdAreaFunctionAllFinish + for i, thirdAreaId in ipairs(thirdAreaIdList) do + conditionId = XTRPGConfigs.GetThirdAreaCondition(thirdAreaId) + ret = XConditionManager.CheckCondition(conditionId) + isThirdAreaFunctionAllFinish = XDataCenter.TRPGManager.IsThirdAreaFunctionAllFinish(thirdAreaId) + self.GridList[i].gameObject:SetActiveEx(ret and not isThirdAreaFunctionAllFinish) + end +end + +function XUiTRPGExploreChapter:AutoAddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:BindHelpBtn(self.BtnHelpCourse, "TRPGMainLine") +end + +function XUiTRPGExploreChapter:OnGridClick(thirdAreaId) + local secondAreaId = self.SecondAreaId + local mainAreaId = self.MainAreaId + XLuaUiManager.Open("UiTRPGExploreChapterStage", thirdAreaId, secondAreaId, mainAreaId) +end + +function XUiTRPGExploreChapter:OnBtnBackClick() + self:Close() +end + +function XUiTRPGExploreChapter:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiTRPGExploreChapter:OnGetEvents() + return {XEventId.EVENT_ACTIVITY_MAINLINE_STATE_CHANGE} +end + +function XUiTRPGExploreChapter:OnNotify(evt, ...) + if evt == XEventId.EVENT_ACTIVITY_MAINLINE_STATE_CHANGE then + XDataCenter.TRPGManager.OnActivityMainLineStateChange(...) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTRPG/XUiTRPGExploreChapterStage.lua b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGExploreChapterStage.lua new file mode 100644 index 00000000..d03322ca --- /dev/null +++ b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGExploreChapterStage.lua @@ -0,0 +1,150 @@ +local XUiTRPGPanelTask = require("XUi/XUiTRPG/XUiTRPGPanel/XUiTRPGPanelTask") +local XUiTRPGPanelPlotTab = require("XUi/XUiTRPG/XUiTRPGPanel/XUiTRPGPanelPlotTab") +local XUiTRPGPanelLevel = require("XUi/XUiTRPG/XUiTRPGPanel/XUiTRPGPanelLevel") + +local tonumber = tonumber +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate + +local XUiTRPGExploreChapterStage = XLuaUiManager.Register(XLuaUi, "UiTRPGExploreChapterStage") + +function XUiTRPGExploreChapterStage:OnAwake() + self:AutoAddListener() + XUiTRPGPanelPlotTab.New(self.PanelPlotTab) + self.TaskPanel = XUiTRPGPanelTask.New(self.PanelTask, self) + self.LevelPanel = XUiTRPGPanelLevel.New(self.PanelLevel) + self.GridPanelChapterStage.gameObject:SetActiveEx(false) +end + +function XUiTRPGExploreChapterStage:OnStart(thirdAreaId, secondAreaId, mainAreaId) + self.SecondAreaId = secondAreaId + self.MainAreaId = mainAreaId + self.ThirdAreaId = thirdAreaId + self.FunctionGrids = {} + + self:InitUi() +end + +function XUiTRPGExploreChapterStage:OnEnable() + self.TaskPanel:OnEnable() + XEventManager.AddEventListener(XEventId.EVENT_TRPG_FUNCTION_FINISH_SYN, self.UpdateFunctionBtns, self) + XDataCenter.TRPGManager.CheckActivityEnd() + self:UpdateFunctionBtns() +end + +function XUiTRPGExploreChapterStage:OnDisable() + self.TaskPanel:OnDisable() + XEventManager.RemoveEventListener(XEventId.EVENT_TRPG_FUNCTION_FINISH_SYN, self.UpdateFunctionBtns, self) +end + +function XUiTRPGExploreChapterStage:OnDestroy() + self.TaskPanel:Delete() + self.LevelPanel:Delete() +end + +function XUiTRPGExploreChapterStage:InitUi() + local secondAreaId = self.SecondAreaId + local mainAreaId = self.MainAreaId + local thirdAreaId = self.ThirdAreaId + + local bg = XTRPGConfigs.GetThirdAreaBg(thirdAreaId) + self.RImgBg:SetRawImage(bg) + + local name = XTRPGConfigs.GetThirdAreaName(thirdAreaId) + self.TxtName.text = name + + local enName = XTRPGConfigs.GetThirdAreaEnName(thirdAreaId) + self.TxtEnName.text = enName +end + +function XUiTRPGExploreChapterStage:UpdateFunctionBtns() + local thirdAreaId = self.ThirdAreaId + + if XDataCenter.TRPGManager.IsThirdAreaFunctionAllFinish(thirdAreaId) then + self:Close() + return + end + + local functionIdList = XDataCenter.TRPGManager.GetUnFinishedFunctionIdList(thirdAreaId) + for index, functionId in ipairs(functionIdList) do + local grid = self.FunctionGrids[index] + if not grid then + local ui = index == 1 and self.GridPanelChapterStage or CSUnityEngineObjectInstantiate(self.GridPanelChapterStage.gameObject, self.PanelChapter) + grid = {} + XTool.InitUiObjectByUi(grid, ui) + self.FunctionGrids[index] = grid + end + + local uiButton = grid.BtnClick + + local icon = XTRPGConfigs.GetFunctionIcon(functionId) + uiButton:SetSprite(icon) + + local name = XTRPGConfigs.GetFunctionDesc(functionId) + uiButton:SetName(name) + + local showTag = XTRPGConfigs.IsFunctionShowTag(functionId) + uiButton:ShowTag(showTag) + + local paramFunctionId = functionId + uiButton.CallBack = function() + self:OnClickBtnStage(paramFunctionId) + end + + grid.GameObject:SetActiveEx(true) + end + + for index = #functionIdList + 1, #self.FunctionGrids do + local grid = self.FunctionGrids[index] + if grid then + grid.GameObject:SetActiveEx(false) + end + end + + XDataCenter.TRPGManager.CheckOpenNewMazeTips() +end + +function XUiTRPGExploreChapterStage:AutoAddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:BindHelpBtn(self.BtnHelpCourse, "TRPGMainLine") +end + +function XUiTRPGExploreChapterStage:OnClickBtnStage(functionId) + local params = XTRPGConfigs.GetFunctionParams(functionId) + + if XTRPGConfigs.CheckFunctionType(functionId, XTRPGConfigs.TRPGFunctionType.Story) then + local movieId = params[1] + local cb = function() + XDataCenter.TRPGManager.RequestFunctionFinishSend(nil, functionId) + end + XDataCenter.MovieManager.PlayMovie(movieId, cb) + elseif XTRPGConfigs.CheckFunctionType(functionId, XTRPGConfigs.TRPGFunctionType.Shop) then + local shopId = tonumber(params[1]) + XLuaUiManager.Open("UiTRPGExploreShop", shopId, self.SecondAreaId, self.ThirdAreaId) + elseif XTRPGConfigs.CheckFunctionType(functionId, XTRPGConfigs.TRPGFunctionType.CommitItem) then + XDataCenter.TRPGManager.RequestFunctionFinishSend(nil, functionId) + elseif XTRPGConfigs.CheckFunctionType(functionId, XTRPGConfigs.TRPGFunctionType.FinishStage) then + XDataCenter.TRPGManager.EnterFunctionFight(functionId) + elseif XTRPGConfigs.CheckFunctionType(functionId, XTRPGConfigs.TRPGFunctionType.Examine) then + local examineId = tonumber(params[1]) + XDataCenter.TRPGManager.EnterFunctionFight(examineId) + end +end + +function XUiTRPGExploreChapterStage:OnBtnBackClick() + self:Close() +end + +function XUiTRPGExploreChapterStage:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiTRPGExploreChapterStage:OnGetEvents() + return {XEventId.EVENT_ACTIVITY_MAINLINE_STATE_CHANGE} +end + +function XUiTRPGExploreChapterStage:OnNotify(evt, ...) + if evt == XEventId.EVENT_ACTIVITY_MAINLINE_STATE_CHANGE then + XDataCenter.TRPGManager.OnActivityMainLineStateChange(...) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTRPG/XUiTRPGExploreRegion/XUiTRPGExploreRegion.lua b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGExploreRegion/XUiTRPGExploreRegion.lua new file mode 100644 index 00000000..88c721c9 --- /dev/null +++ b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGExploreRegion/XUiTRPGExploreRegion.lua @@ -0,0 +1,145 @@ +local Object +local XUiTRPGPanelTask = require("XUi/XUiTRPG/XUiTRPGPanel/XUiTRPGPanelTask") +local XUiTRPGPanelPlotTab = require("XUi/XUiTRPG/XUiTRPGPanel/XUiTRPGPanelPlotTab") +local XUiTRPGPanelLevel = require("XUi/XUiTRPG/XUiTRPGPanel/XUiTRPGPanelLevel") +local XUiTRPGExploreRegionChapter = require("XUi/XUiTRPG/XUiTRPGExploreRegion/XUiTRPGExploreRegionChapter") + +--区域(城市和迷宫)地图 +local XUiTRPGExploreRegion = XLuaUiManager.Register(XLuaUi, "UiTRPGExploreRegion") + +function XUiTRPGExploreRegion:OnAwake() + Object = CS.UnityEngine.Object + self:AutoAddListener() + XUiTRPGPanelPlotTab.New(self.PanelPlotTab) + self.TaskPanel = XUiTRPGPanelTask.New(self.PanelTask, self) + self.LevelPanel = XUiTRPGPanelLevel.New(self.PanelLevel) + + self.GridExploreChapter.gameObject:SetActiveEx(false) + XEventManager.AddEventListener(XEventId.EVENT_TRPG_GET_REWARD, self.OnCheckBtnTreasureRedPoint, self) +end + +function XUiTRPGExploreRegion:OnStart(areaId) + self.PanelChapterList = {} + self.ChapterList = {} + self.AreaId = areaId + + local bgPath = XTRPGConfigs.GetSecondAreaBg(areaId) + self.Background:SetRawImage(bgPath) + + self:PlayStartStory() +end + +function XUiTRPGExploreRegion:OnEnable() + XDataCenter.TRPGManager.CheckActivityEnd() + XDataCenter.TRPGManager.CheckOpenNewMazeTips() + self:Refresh() + self.TaskPanel:OnEnable() +end + +function XUiTRPGExploreRegion:OnDisable() + self.TaskPanel:OnDisable() +end + +function XUiTRPGExploreRegion:OnDestroy() + self.TaskPanel:Delete() + self.LevelPanel:Delete() + XEventManager.RemoveEventListener(XEventId.EVENT_TRPG_GET_REWARD, self.OnCheckBtnTreasureRedPoint, self) +end + +function XUiTRPGExploreRegion:AutoAddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:BindHelpBtn(self.BtnHelpCourse, "TRPGMainLine") + self:RegisterClickEvent(self.BtnTreasure, self.OnBtnTreasureClick) +end + +function XUiTRPGExploreRegion:OnCheckRewards(count, chapterId) + if self.ImgRedProgress and chapterId == self.Chapter.ChapterId then + self.ImgRedProgress.gameObject:SetActiveEx(count >= 0) + end +end + +function XUiTRPGExploreRegion:Refresh() + self.TxtName.text = XTRPGConfigs.GetMainAreaName(self.AreaId) + self:UpdateProgress() + self:UpdateChapter() + self:OnCheckBtnTreasureRedPoint() +end + +function XUiTRPGExploreRegion:UpdateProgress() + local percent = XDataCenter.TRPGManager.GetAreaRewardPercent(self.AreaId) + self.TxtBfrtTaskTotalNum.text = math.floor(percent * 100) .. "%" + self.ImgJindu.fillAmount = percent +end + +function XUiTRPGExploreRegion:UpdateChapter() + if not self.ChapterList[self.AreaId] then + self.ChapterList[self.AreaId] = {} + end + for i = 1, XTRPGConfigs.GetMainAreaMaxNum() do + self["PanelChapter" .. i].gameObject:SetActiveEx(i == self.AreaId) + end + + local secondAreaIdList = XTRPGConfigs.GetSecondAreaIdList(self.AreaId) + for i, secondAreaId in ipairs(secondAreaIdList) do + if not self.ChapterList[self.AreaId][i] and self["Chapter" .. self.AreaId .. i] then + local gridExploreChapter = XUiTRPGExploreRegionChapter.New(Object.Instantiate(self.GridExploreChapter), secondAreaId, self.AreaId) + gridExploreChapter.Transform:SetParent(self["Chapter" .. self.AreaId .. i].transform, false) + gridExploreChapter.GameObject:SetActiveEx(true) + self.ChapterList[self.AreaId][i] = gridExploreChapter + end + self.ChapterList[self.AreaId][i]:Refresh() + end +end + +--进度领奖 +function XUiTRPGExploreRegion:OnBtnTreasureClick() + local rewardIdList = XTRPGConfigs.GetAreaRewardIdList(self.AreaId) + XLuaUiManager.Open("UiTRPGRewardTip", rewardIdList) +end + +function XUiTRPGExploreRegion:OnBtnBackClick() + self:Close() +end + +function XUiTRPGExploreRegion:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiTRPGExploreRegion:PlayStartStory() + local firstOpenFunctionGroupId = XTRPGConfigs.GetMainAreaFirstOpenFunctionGroupId(self.AreaId) + if firstOpenFunctionGroupId == 0 then return end + + if not XDataCenter.TRPGManager.IsFunctionGroupConditionFinish(firstOpenFunctionGroupId) then + return + end + + local functionIds = XTRPGConfigs.GetFunctionGroupFunctionIds(firstOpenFunctionGroupId) + for _, functionId in ipairs(functionIds) do + if not XDataCenter.TRPGManager.IsThirdAreaFunctionFinish(nil, functionId) then + if XTRPGConfigs.CheckFunctionType(functionId, XTRPGConfigs.TRPGFunctionType.Story) then + local params = XTRPGConfigs.GetFunctionParams(functionId) + local movieId = params[1] + local cb = function() + XDataCenter.TRPGManager.RequestFunctionFinishSend(nil, functionId) + end + XDataCenter.MovieManager.PlayMovie(movieId, cb) + end + end + end +end + +function XUiTRPGExploreRegion:OnCheckBtnTreasureRedPoint() + local isShow = XDataCenter.TRPGManager.CheckAreaRewardByAreaId(self.AreaId) + self.ImgRedProgress.gameObject:SetActiveEx(isShow) +end + +function XUiTRPGExploreRegion:OnGetEvents() + return {XEventId.EVENT_ACTIVITY_MAINLINE_STATE_CHANGE} +end + +function XUiTRPGExploreRegion:OnNotify(evt, ...) + if evt == XEventId.EVENT_ACTIVITY_MAINLINE_STATE_CHANGE then + XDataCenter.TRPGManager.OnActivityMainLineStateChange(...) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTRPG/XUiTRPGExploreRegion/XUiTRPGExploreRegionChapter.lua b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGExploreRegion/XUiTRPGExploreRegionChapter.lua new file mode 100644 index 00000000..f83adb3a --- /dev/null +++ b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGExploreRegion/XUiTRPGExploreRegionChapter.lua @@ -0,0 +1,80 @@ +local Object + +local XUiTRPGExploreRegionChapter = XClass(nil, "XUiTRPGExploreRegionChapter") + +function XUiTRPGExploreRegionChapter:Ctor(ui, secondAreaId, mainAreaId) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + Object = CS.UnityEngine.Object + self.MainAreaId = mainAreaId + self.SecondAreaId = secondAreaId + self:Init() + + XUiHelper.RegisterClickEvent(self, self.BtnClick, self.OnBtnClick) +end + +function XUiTRPGExploreRegionChapter:Init() + local secondAreaName = XTRPGConfigs.GetSecondAreaName(self.SecondAreaId) + self.BtnClick:SetName(secondAreaName) + + local type = XTRPGConfigs.GetSecondAreaType(self.SecondAreaId) + self.PanelNormalImgMigong.gameObject:SetActiveEx(type == XTRPGConfigs.TRPGSecondAreaType.Maze) + self.PanelNormalImgPutong.gameObject:SetActiveEx(type == XTRPGConfigs.TRPGSecondAreaType.Normal) + self.PanelPreImgMigong.gameObject:SetActiveEx(type == XTRPGConfigs.TRPGSecondAreaType.Maze) + self.PanelPreImgPutong.gameObject:SetActiveEx(type == XTRPGConfigs.TRPGSecondAreaType.Normal) + if self.ImgMigongDis then + self.ImgMigongDis.gameObject:SetActiveEx(type == XTRPGConfigs.TRPGSecondAreaType.Maze) + end + if self.ImgputongDis then + self.ImgputongDis.gameObject:SetActiveEx(type == XTRPGConfigs.TRPGSecondAreaType.Normal) + end +end + +function XUiTRPGExploreRegionChapter:OnBtnClick() + local conditionId = XTRPGConfigs.GetSecondAreaCondition(self.SecondAreaId) + local ret, desc = XConditionManager.CheckCondition(conditionId) + if not ret then + XUiManager.TipError(desc) + return + end + + local type = XTRPGConfigs.GetSecondAreaType(self.SecondAreaId) + if type == XTRPGConfigs.TRPGSecondAreaType.Maze then + local mazeId = XTRPGConfigs.GetSecondAreaMazeId(self.SecondAreaId) + XDataCenter.TRPGManager.TRPGEnterMazeRequest(mazeId) + else + XLuaUiManager.Open("UiTRPGExploreChapter", self.SecondAreaId, self.MainAreaId) + end +end + +function XUiTRPGExploreRegionChapter:Refresh() + local conditionId = XTRPGConfigs.GetSecondAreaCondition(self.SecondAreaId) + local ret = XConditionManager.CheckCondition(conditionId) + self.BtnClick:SetDisable(not ret) + self:CheckShowNewHint(ret) +end + +function XUiTRPGExploreRegionChapter:CheckShowNewHint(isConditionComplete) + if not self.TagNew1 or not self.TagNew2 then + return + end + if not isConditionComplete then + self.TagNew1.gameObject:SetActiveEx(false) + self.TagNew2.gameObject:SetActiveEx(false) + return + end + local type = XTRPGConfigs.GetSecondAreaType(self.SecondAreaId) + local isAlreadyEnter + if type == XTRPGConfigs.TRPGSecondAreaType.Maze then + local mazeId = XTRPGConfigs.GetSecondAreaMazeId(self.SecondAreaId) + isAlreadyEnter = XDataCenter.TRPGManager.CheckIsAlreadyEnterMaze(mazeId) + else + isAlreadyEnter = XDataCenter.TRPGManager.CheckIsAlreadyOpenExploreChapter(self.SecondAreaId, self.MainAreaId) + end + self.TagNew1.gameObject:SetActiveEx(not isAlreadyEnter) + self.TagNew2.gameObject:SetActiveEx(not isAlreadyEnter) +end + +return XUiTRPGExploreRegionChapter \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTRPG/XUiTRPGExploreShop/XUiTRPGExploreShop.lua b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGExploreShop/XUiTRPGExploreShop.lua new file mode 100644 index 00000000..628be965 --- /dev/null +++ b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGExploreShop/XUiTRPGExploreShop.lua @@ -0,0 +1,95 @@ +local CSXTextManagerGetText = CS.XTextManager.GetText + +local XUiTRPGExploreShopRewardGrid = require("XUi/XUiTRPG/XUiTRPGExploreShop/XUiTRPGExploreShopRewardGrid") + +--商店 +local XUiTRPGExploreShop = XLuaUiManager.Register(XLuaUi, "UiTRPGExploreShop") + +function XUiTRPGExploreShop:OnAwake() + self.GridReward.gameObject:SetActiveEx(false) + self:InitCb() + self:AutoAddListener() + self:InitDynamicTable() + + self.AssetActivityPanel = XUiPanelActivityAsset.New(self.PanelSpecialTool) + XDataCenter.ItemManager.AddCountUpdateListener(XDataCenter.ItemManager.ItemId.TRPGMoney, function() + self.AssetActivityPanel:Refresh({XDataCenter.ItemManager.ItemId.TRPGMoney}) + end, self.AssetActivityPanel) + self.AssetActivityPanel:Refresh({XDataCenter.ItemManager.ItemId.TRPGMoney}) +end + +function XUiTRPGExploreShop:OnStart(shopId, secondAreaId, thirdAreaId) + self.ShopId = shopId + + local secondAreaName = XTRPGConfigs.GetSecondAreaName(secondAreaId) + local thirdAreaName = XTRPGConfigs.GetThirdAreaName(thirdAreaId) + self.TxtName.text = secondAreaName .. "-" .. thirdAreaName .. "-" .. CSXTextManagerGetText("ShopTitle") +end + +function XUiTRPGExploreShop:OnEnable() + XDataCenter.TRPGManager.CheckActivityEnd() + self:Refresh() +end + +function XUiTRPGExploreShop:InitCb() + self.RefreshCb = function() self:Refresh() end +end + +function XUiTRPGExploreShop:AutoAddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:BindHelpBtn(self.BtnHelpCourse, "TRPGMainLine") +end + +function XUiTRPGExploreShop:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.SViewRewardList) + self.DynamicTable:SetDelegate(self) + self.DynamicTable:SetProxy(XUiTRPGExploreShopRewardGrid, self) +end + +function XUiTRPGExploreShop:Refresh() + self.ShopItemIdList = XDataCenter.TRPGManager.GetShopItemIdList(self.ShopId) + self.DynamicTable:SetDataSource(self.ShopItemIdList) + self.DynamicTable:ReloadDataSync() +end + +function XUiTRPGExploreShop:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local shopItemId = self.ShopItemIdList[index] + grid:Refresh(self.ShopId, shopItemId, index) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + local shopItemId = self.ShopItemIdList[index] + local canBuyCount = XDataCenter.TRPGManager.GetShopItemCanBuyCount(self.ShopId, shopItemId) + local itemId = XTRPGConfigs.GetItemIdByShopItemId(shopItemId) + local isItemMax = XDataCenter.TRPGManager.IsItemMaxCount(itemId) + if isItemMax then + XUiManager.TipText("TRPGItemMaxNumCantBuy") + elseif canBuyCount > 0 then + XLuaUiManager.Open("UiTRPGShopItem", self.ShopId, shopItemId, self.RefreshCb) + else + local resetType = XTRPGConfigs.GetItemResetType(shopItemId) + local tipKey = resetType == XTRPGConfigs.ShopItemResetType.Reset and "TRPGShopItemOversell" or "TRPGShopItemForeverOversell" + XUiManager.TipText(tipKey) + end + end +end + +function XUiTRPGExploreShop:OnBtnBackClick() + self:Close() +end + +function XUiTRPGExploreShop:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiTRPGExploreShop:OnGetEvents() + return {XEventId.EVENT_TRPG_SHOP_INFO_CHANGE, XEventId.EVENT_ACTIVITY_MAINLINE_STATE_CHANGE} +end + +function XUiTRPGExploreShop:OnNotify(evt, ...) + if evt == XEventId.EVENT_TRPG_SHOP_INFO_CHANGE then + self:Refresh() + elseif evt == XEventId.EVENT_ACTIVITY_MAINLINE_STATE_CHANGE then + XDataCenter.TRPGManager.OnActivityMainLineStateChange(...) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTRPG/XUiTRPGExploreShop/XUiTRPGExploreShopRewardGrid.lua b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGExploreShop/XUiTRPGExploreShopRewardGrid.lua new file mode 100644 index 00000000..f2ea4f36 --- /dev/null +++ b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGExploreShop/XUiTRPGExploreShopRewardGrid.lua @@ -0,0 +1,44 @@ +local CONDITION_COLOR = { + [true] = CS.UnityEngine.Color.red, + [false] = XUiHelper.Hexcolor2Color("2b2b2bff"), +} + +local XUiTRPGExploreShopRewardGrid = XClass(nil, "XUiTRPGExploreShopRewardGrid") + +function XUiTRPGExploreShopRewardGrid:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) +end + +function XUiTRPGExploreShopRewardGrid:Refresh(shopId, shopItemId) + local consumeId = XTRPGConfigs.GetShopItemConsumeId(shopItemId) + local consumeIconPath = XItemConfigs.GetItemIconById(consumeId) + self.TextPayNum.text = XDataCenter.TRPGManager.GetShopItemConsumeCount(shopId, shopItemId) + self.PayRawImg:SetRawImage(consumeIconPath) + + local canBuyCount = XDataCenter.TRPGManager.GetShopItemCanBuyCount(shopId, shopItemId) + self.XiangouTextName.text = canBuyCount + self.ImgLock.gameObject:SetActiveEx(canBuyCount <= 0) + + self.PanelTxt.gameObject:SetActiveEx(false) + self.PanelSite.gameObject:SetActiveEx(false) + + local itemId = XTRPGConfigs.GetItemIdByShopItemId(shopItemId) + self.TextNum.text = XDataCenter.ItemManager.GetCount(itemId) + self.TextName.text = XDataCenter.ItemManager.GetItemName(itemId) + self.TextInfo.text = XDataCenter.ItemManager.GetItemDescription(itemId) + + local isItemMax = XDataCenter.TRPGManager.IsItemMaxCount(itemId) + self.TextNum.color = CONDITION_COLOR[isItemMax] + + local quality = XDataCenter.ItemManager.GetItemQuality(itemId) + local qualityPath = XArrangeConfigs.GeQualityPath(quality) + self.RootUi:SetUiSprite(self.ImgQuality, qualityPath) + + local iconPath = XItemConfigs.GetItemIconById(itemId) + self.RImgIcon:SetRawImage(iconPath) +end + +return XUiTRPGExploreShopRewardGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTRPG/XUiTRPGExploreShop/XUiTRPGShopItem.lua b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGExploreShop/XUiTRPGShopItem.lua new file mode 100644 index 00000000..2b04c710 --- /dev/null +++ b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGExploreShop/XUiTRPGShopItem.lua @@ -0,0 +1,100 @@ +local CSXTextManagerGetText = CS.XTextManager.GetText + +--商店购买弹窗 +local XUiTRPGShopItem = XLuaUiManager.Register(XLuaUi, "UiTRPGShopItem") + +function XUiTRPGShopItem:OnAwake() + self:AutoAddListener() + self.PanelCostItem2.gameObject:SetActive(false) + self.PanelCostItem3.gameObject:SetActive(false) + self.PanelSite.gameObject:SetActive(false) +end + +function XUiTRPGShopItem:OnStart(shopId, shopItemId, requestSendCb) + self.ShopId = shopId + self.ShopItemId = shopItemId + self.RequestSendCb = requestSendCb + self.CurSelectNum = 1 +end + +function XUiTRPGShopItem:OnEnable() + self:Refresh() +end + +function XUiTRPGShopItem:AutoAddListener() + self:RegisterClickEvent(self.BtnTanchuangClose, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnAddSelect, self.OnBtnAddSelectClick) + self:RegisterClickEvent(self.BtnMinusSelect, self.OnBtnMinusSelectClick) + self:RegisterClickEvent(self.BtnMax, self.OnBtnMaxClick) + self:RegisterClickEvent(self.BtnUse, self.OnBtnUseClick) +end + +function XUiTRPGShopItem:Refresh() + local canBuyCount = XDataCenter.TRPGManager.GetShopItemCanBuyCount(self.ShopId, self.ShopItemId) + self.TxtCanBuy.text = canBuyCount + + --拥有的数量 + local itemId = XTRPGConfigs.GetItemIdByShopItemId(self.ShopItemId) + self.TxtOwnCount.text = CSXTextManagerGetText("TRPGShopTipsAlready", XDataCenter.ItemManager.GetCount(itemId)) + + local shopItemName = XDataCenter.ItemManager.GetItemName(itemId) + self.TxtName.text = shopItemName + + local bigIcon = XItemConfigs.GetItemIconById(itemId) + self.RImgIcon:SetRawImage(bigIcon) + + --消费图标 + local consumeId = XTRPGConfigs.GetShopItemConsumeId(self.ShopItemId) + local iconPath = XItemConfigs.GetItemIconById(consumeId) + self.RImgCostIcon1:SetRawImage(iconPath) + + local consumeCount = XDataCenter.TRPGManager.GetShopItemConsumeCount(self.ShopId, self.ShopItemId) + self.TxtCostCount1.text = consumeCount * self.CurSelectNum + + local quality = XDataCenter.ItemManager.GetItemQuality(itemId) + local qualityPath = XArrangeConfigs.GeQualityPath(quality) + self:SetUiSprite(self.ImgQuality, qualityPath) + + self.TxtSelect.text = self.CurSelectNum +end + +function XUiTRPGShopItem:OnBtnAddSelectClick() + local canBuyCount = XDataCenter.TRPGManager.GetShopItemCanBuyCount(self.ShopId, self.ShopItemId) + if self.CurSelectNum + 1 <= canBuyCount then + self.CurSelectNum = self.CurSelectNum + 1 + self:Refresh() + end +end + +function XUiTRPGShopItem:OnBtnMinusSelectClick() + if self.CurSelectNum - 1 > 0 then + self.CurSelectNum = self.CurSelectNum - 1 + self:Refresh() + end +end + +function XUiTRPGShopItem:OnBtnMaxClick() + local canBuyCount = XDataCenter.TRPGManager.GetShopItemCanBuyCount(self.ShopId, self.ShopItemId) + if self.CurSelectNum ~= canBuyCount then + self.CurSelectNum = canBuyCount + self:Refresh() + end +end + +function XUiTRPGShopItem:OnBtnUseClick() + local itemId = XTRPGConfigs.GetItemIdByShopItemId(self.ShopItemId) + local itemMaxCount = XDataCenter.TRPGManager.GetItemMaxCount(itemId) + local haveCount = XDataCenter.ItemManager.GetCount(itemId) + local buyCount = haveCount + self.CurSelectNum + if buyCount > itemMaxCount then + XUiManager.TipText("TRPGShopTipItemMaxNumCantBuy") + return + end + + XDataCenter.TRPGManager.RequestShopBuyItemSend(self.ShopId, self.ShopItemId, self.CurSelectNum, self.RequestSendCb) + self:Close() +end + +function XUiTRPGShopItem:OnBtnBackClick() + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTRPG/XUiTRPGFightTips.lua b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGFightTips.lua new file mode 100644 index 00000000..ff31e263 --- /dev/null +++ b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGFightTips.lua @@ -0,0 +1,140 @@ +-- local XUiGridTRPGTestAction = require("XUi/XUiTRPG/XUiGridTRPGTestAction") +local tonumber = tonumber +local CSXTextManagerGetText = CS.XTextManager.GetText +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate + +local XUiTRPGFightTips = XLuaUiManager.Register(XLuaUi, "UiTRPGFightTips") + +function XUiTRPGFightTips:OnAwake() + self:AutoAddListener() + self.GridCommon.gameObject:SetActiveEx(false) +end + +function XUiTRPGFightTips:OnStart(cardId, cardIndex, stageId, challengeLevel, qucikRewardId) + self.CardId = cardId + self.CardIndex = cardIndex + self.StageId = stageId + self.ChallengeLevel = challengeLevel + self.QucikRewardId = qucikRewardId + self.ItemGrids = {} +end + +function XUiTRPGFightTips:OnEnable() + self:UpdateUi() +end + +function XUiTRPGFightTips:OnDestroy() + local cardIndex = self.CardIndex +end + +function XUiTRPGFightTips:UpdateUi() + local cardId = self.CardId + local stageId = self.StageId + local challengeLevel = self.ChallengeLevel + + local icon = XTRPGConfigs.GetMazeCardIconR(cardId) + self.RImgBg:SetRawImage(icon) + + local isQuickFight = XDataCenter.TRPGManager.CheckQuickFight(challengeLevel) + self.BtnEnter.gameObject:SetActiveEx(not isQuickFight) + self.BtnQuickFight.gameObject:SetActiveEx(isQuickFight) + + local canGiveUp = XTRPGConfigs.CheckMazeCardType(cardId, XTRPGConfigs.CardType.Fight) + self.BtnGiveUp.gameObject:SetActiveEx(canGiveUp) + + local des = isQuickFight and XTRPGConfigs.GetMazeCardQuickFightDes(cardId) or XTRPGConfigs.GetMazeCardFightDes(cardId) + self.TxtDes.text = des + + local name = XDataCenter.FubenManager.GetStageName(stageId) + self.TxtChapter.text = name + + if self.TxtCardOrder then + local cardOrder = XTRPGConfigs.GetMazeCardOrder(cardId) + self.TxtCardOrder.text = cardOrder + end + + if self.TxtCardName then + local cardName = XTRPGConfigs.GetMazeCardName(cardId) + self.TxtCardName.text = cardName + end + + if self.TxtLevel then + if challengeLevel and challengeLevel > 0 then + self.TxtLevel.text = challengeLevel + self.TxtLevel.transform.parent.gameObject:SetActiveEx(true) + else + self.TxtLevel.transform.parent.gameObject:SetActiveEx(false) + end + end + + local rewardId + if isQuickFight then + rewardId = self.QucikRewardId + else + local cfg = XDataCenter.FubenManager.GetStageLevelControl(stageId) + rewardId = cfg and cfg.FinishRewardShow + if not rewardId or rewardId == 0 then + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + rewardId = stageCfg.FinishRewardShow + end + end + + local rewardCount = 0 + if rewardId and rewardId ~= 0 then + local rewards = XRewardManager.GetRewardList(rewardId) + for index, item in ipairs(rewards) do + local grid = self.ItemGrids[index] + if not grid then + local ui = CSUnityEngineObjectInstantiate(self.GridCommon, self.PanelRewardContent) + grid = XUiGridCommon.New(self, ui) + self.ItemGrids[index] = grid + end + + grid:Refresh(item) + grid.GameObject:SetActiveEx(true) + rewardCount = rewardCount + 1 + end + end + + for index = rewardCount + 1, #self.ItemGrids do + local grid = self.ItemGrids[index] + if grid then + grid.GameObject:SetActiveEx(false) + end + end + +end + +function XUiTRPGFightTips:AutoAddListener() + self:RegisterClickEvent(self.BtnTanchuangClose, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnGiveUp, self.OnBtnBtnGiveUp) + self:RegisterClickEvent(self.BtnEnter, self.OnClickBtnEnter) + self:RegisterClickEvent(self.BtnQuickFight, self.OnClickBtnQuickFight) +end + +function XUiTRPGFightTips:OnBtnBackClick() + self:Close() +end + +function XUiTRPGFightTips:OnBtnBtnGiveUp() + local callBack = function() + self:Close() + local cardIndex = self.CardIndex + XDataCenter.TRPGManager.TRPGMazeGiveUpChallengeRequest(cardIndex) + end + local title = CSXTextManagerGetText("TRPGMazeGiveUpFightTipTitle") + local content = CSXTextManagerGetText("TRPGMazeGiveUpFightTipContent") + XUiManager.DialogTip(title, content, XUiManager.DialogType.Normal, nil, callBack) +end + +function XUiTRPGFightTips:OnClickBtnEnter() + self:Close() + local stageId = self.StageId + XLuaUiManager.Open("UiNewRoomSingle", stageId) +end + +function XUiTRPGFightTips:OnClickBtnQuickFight() + local cardIndex = self.CardIndex + XDataCenter.TRPGManager.TRPGMazeQuickChallengeRequest(cardIndex) + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTRPG/XUiTRPGMain.lua b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGMain.lua new file mode 100644 index 00000000..697ec90b --- /dev/null +++ b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGMain.lua @@ -0,0 +1,223 @@ +local XUiTRPGPanelPlotTab = require("XUi/XUiTRPG/XUiTRPGPanel/XUiTRPGPanelPlotTab") +local XUiTRPGPanelLevel = require("XUi/XUiTRPG/XUiTRPGPanel/XUiTRPGPanelLevel") + +local CSXTextManagerGetText = CS.XTextManager.GetText +local TRPGFirstOpenFunctionGroupId = CS.XGame.ClientConfig:GetInt("TRPGFirstOpenFunctionGroupId") +local ButtonStateDisable = CS.UiButtonState.Disable + +--主界面 +local XUiTRPGMain = XLuaUiManager.Register(XLuaUi, "UiTRPGMain") + +function XUiTRPGMain:OnAwake() + self.IsSwitchStatusOpenView = false --是否从切换模式按钮打开本界面 + + self.PanelPlotTab = XUiTRPGPanelPlotTab.New(self.PanelPlotTab, true) + self.LevelPanel = XUiTRPGPanelLevel.New(self.PanelLevel) + self:Init() + self:AutoAddListener() +end + +function XUiTRPGMain:OnStart(isSwitchStatusOpenView) + self.IsSwitchStatusOpenView = isSwitchStatusOpenView + self:PlayStartStory() +end + +function XUiTRPGMain:OnEnable() + local openAnimaName = self.IsSwitchStatusOpenView and "QieHuan" or "Enable" + self:PlayAnimation(openAnimaName) + self.IsSwitchStatusOpenView = false + + XDataCenter.TRPGManager.CheckActivityEnd() + XDataCenter.TRPGManager.CheckOpenNewMazeTips() + XEventManager.AddEventListener(XEventId.EVENT_TRPG_FUNCTION_FINISH_SYN, XDataCenter.TRPGManager.CheckOpenNewMazeTips, XDataCenter.TRPGManager) + self.AreaOpenSchedule = XScheduleManager.ScheduleForever(function() self:UpdateAreaCanOpenTime() end, XScheduleManager.SECOND) + self:Refresh() + self:UpdateAreaCanOpenTime() + self:OnCheckGridPanelChapterRedPoint() + self:OnCheckSecondMainRedPoint() + self.PanelPlotTab:Refresh() +end + +function XUiTRPGMain:OnDisable() + XEventManager.RemoveEventListener(XEventId.EVENT_TRPG_FUNCTION_FINISH_SYN, XDataCenter.TRPGManager.CheckOpenNewMazeTips, XDataCenter.TRPGManager) + XScheduleManager.UnSchedule(self.AreaOpenSchedule) +end + +function XUiTRPGMain:OnDestroy() + self.LevelPanel:Delete() +end + +function XUiTRPGMain:Init() + local areaMaxNum = XTRPGConfigs.GetMainAreaMaxNum() + for gridPanelChapterIndex = 1, areaMaxNum do + local name = XTRPGConfigs.GetMainAreaName(gridPanelChapterIndex) + self["GridPanelChapter" .. gridPanelChapterIndex]:SetNameByGroup(0, name) + self["TagWending" .. gridPanelChapterIndex] = XUiHelper.TryGetComponent(self["GridPanelChapter" .. gridPanelChapterIndex].transform, "TagWending") + self["TagZhenya" .. gridPanelChapterIndex] = XUiHelper.TryGetComponent(self["GridPanelChapter" .. gridPanelChapterIndex].transform, "TagZhenya") + self["TagHundun" .. gridPanelChapterIndex] = XUiHelper.TryGetComponent(self["GridPanelChapter" .. gridPanelChapterIndex].transform, "TagHundun") + self["TagHundun2" .. gridPanelChapterIndex] = XUiHelper.TryGetComponent(self["GridPanelChapter" .. gridPanelChapterIndex].transform, "TagHundun2") + end + + local bossHideEntranceTimeStr = XTRPGConfigs.GetBossHideEntranceTimeStr() + local bossHideEntranceTime = XTime.ParseToTimestamp(bossHideEntranceTimeStr) + local serverNowTimestamp = XTime.GetServerNowTimestamp() + self.BtnWorldBoss.gameObject:SetActiveEx(serverNowTimestamp < bossHideEntranceTime) +end + +function XUiTRPGMain:Refresh() + local areaMaxNum = XTRPGConfigs.GetMainAreaMaxNum() + for gridPanelChapterIndex = 1, areaMaxNum do + local percent = XDataCenter.TRPGManager.GetAreaRewardPercent(gridPanelChapterIndex) + self["GridPanelChapter" .. gridPanelChapterIndex]:SetNameByGroup(1, math.floor(percent * 100) .. "%") + end +end + +function XUiTRPGMain:UpdateAreaCanOpenTime() + local isAllOpen = true + + local areaMaxNum = XTRPGConfigs.GetMainAreaMaxNum() + for gridPanelChapterIndex = 1, areaMaxNum do + local state = XDataCenter.TRPGManager.GetAreaState(gridPanelChapterIndex) + local isNotOpen = state == XTRPGConfigs.AreaStateType.NotOpen + self["GridPanelChapter" .. gridPanelChapterIndex]:SetDisable(isNotOpen, not isNotOpen) + + local percent = XDataCenter.TRPGManager.GetAreaRewardPercent(gridPanelChapterIndex) + self["TagWending" .. gridPanelChapterIndex].gameObject:SetActiveEx((state == XTRPGConfigs.AreaStateType.Open or state == XTRPGConfigs.AreaStateType.Over) and percent == 1) + self["TagZhenya" .. gridPanelChapterIndex].gameObject:SetActiveEx(state == XTRPGConfigs.AreaStateType.Open and percent > 0 and percent < 1) + self["TagHundun" .. gridPanelChapterIndex].gameObject:SetActiveEx(state == XTRPGConfigs.AreaStateType.NotOpen) + self["TagHundun2" .. gridPanelChapterIndex].gameObject:SetActiveEx(state == XTRPGConfigs.AreaStateType.Open and percent == 0) + + if isNotOpen then + isAllOpen = false + local timeStamp = XTRPGConfigs.GetAreaOpenLastTimeStamp(gridPanelChapterIndex) + local timeStr = XUiHelper.GetTime(timeStamp, XUiHelper.TimeFormatType.ACTIVITY) + local str = CSXTextManagerGetText("TRPGMainAreaCanOpenTime", timeStr) + self["GridPanelChapter" .. gridPanelChapterIndex]:SetNameByGroup(2, str) + end + end + + local openState, time = XDataCenter.TRPGManager.GetWorldBossOpenState() + local timeStr = XUiHelper.GetTime(time, XUiHelper.TimeFormatType.ACTIVITY) + local str + if openState == XTRPGConfigs.AreaStateType.NotOpen then + str = CSXTextManagerGetText("TRPGBossOpenTime", timeStr) + self.BtnWorldBoss:SetNameByGroup(1, str) + if self.BtnWorldBoss.ButtonState ~= ButtonStateDisable then --防止定时器频繁设置按钮状态影响特效播放 + self.BtnWorldBoss:SetDisable(true) + end + self.BtnWorldBoss:ShowTag(false) + isAllOpen = false + elseif openState == XTRPGConfigs.AreaStateType.Open then + str = CSXTextManagerGetText("TRPGBossCloseTime", timeStr) + self.BtnWorldBoss:SetNameByGroup(1, str) + if self.BtnWorldBoss.ButtonState == ButtonStateDisable then + self.BtnWorldBoss:SetDisable(false) + end + self.BtnWorldBoss:ShowTag(false) + isAllOpen = false + else + self.BtnWorldBoss:SetNameByGroup(1, "") + if self.BtnWorldBoss.ButtonState ~= ButtonStateDisable then + self.BtnWorldBoss:SetDisable(true) + end + self.BtnWorldBoss:ShowTag(true) + end + + if isAllOpen then + XScheduleManager.UnSchedule(self.AreaOpenSchedule) + end +end + +function XUiTRPGMain:AutoAddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:BindHelpBtn(self.BtnHelpCourse, "TRPGMainLine") + self.BtnWorldBoss.CallBack = function() self:OnBtnWorldBossClick() end + self:RegisterClickEvent(self.PanelCut, self.OnPanelCutClick) + + local areaMaxNum = XTRPGConfigs.GetMainAreaMaxNum() + for i = 1, areaMaxNum do + self["GridPanelChapter" .. i].CallBack = function() self:OnGridPanelChapterClick(i) end + end +end + +--切换模式 +function XUiTRPGMain:OnPanelCutClick() + XDataCenter.TRPGManager.RequestTRPGChangePageStatus(true) + XLuaUiManager.PopThenOpen("UiTRPGSecondMain", true) +end + +function XUiTRPGMain:OnBtnWorldBossClick() + local openState = XDataCenter.TRPGManager.GetWorldBossOpenState() + if openState ~= XTRPGConfigs.AreaStateType.Open then + XUiManager.TipText("TPRGWorldBossNotInActivityTime") + return + end + XLuaUiManager.Open("UiTRPGWorldBossBossArea") +end + +function XUiTRPGMain:OnGridPanelChapterClick(index) + local condition = XTRPGConfigs.GetMainAreaCondition(index) + local ret, desc = XConditionManager.CheckCondition(condition) + if not ret then + XUiManager.TipError(desc) + return + end + XLuaUiManager.Open("UiTRPGExploreRegion", index) +end + +function XUiTRPGMain:OnBtnBackClick() + self:Close() +end + +function XUiTRPGMain:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiTRPGMain:PlayStartStory() + if not XDataCenter.TRPGManager.IsFunctionGroupConditionFinish(TRPGFirstOpenFunctionGroupId) then + return + end + + local functionIds = XTRPGConfigs.GetFunctionGroupFunctionIds(TRPGFirstOpenFunctionGroupId) + for _, functionId in ipairs(functionIds) do + if not XDataCenter.TRPGManager.IsThirdAreaFunctionFinish(nil, functionId) then + if XTRPGConfigs.CheckFunctionType(functionId, XTRPGConfigs.TRPGFunctionType.Story) then + local params = XTRPGConfigs.GetFunctionParams(functionId) + local movieId = params[1] + local cb = function() + XDataCenter.TRPGManager.RequestFunctionFinishSend(nil, functionId) + end + XDataCenter.MovieManager.PlayMovie(movieId, cb) + end + end + end +end + +function XUiTRPGMain:OnCheckGridPanelChapterRedPoint() + local areaMaxNum = XTRPGConfigs.GetMainAreaMaxNum() + local isShow + for areaId = 1, areaMaxNum do + if self["GridPanelChapter" .. areaId] then + isShow = XDataCenter.TRPGManager.CheckAreaRewardByAreaId(areaId) + self["GridPanelChapter" .. areaId]:ShowReddot(isShow) + end + end + isShow = XDataCenter.TRPGManager.CheckWorldBossReward() + self.BtnWorldBoss:ShowReddot(isShow) +end + +function XUiTRPGMain:OnCheckSecondMainRedPoint() + local isShowRedPoint = XDataCenter.TRPGManager.IsSecondMainReward() + self.PanelCut:ShowReddot(isShowRedPoint) +end + +function XUiTRPGMain:OnGetEvents() + return {XEventId.EVENT_ACTIVITY_MAINLINE_STATE_CHANGE} +end + +function XUiTRPGMain:OnNotify(evt, ...) + if evt == XEventId.EVENT_ACTIVITY_MAINLINE_STATE_CHANGE then + XDataCenter.TRPGManager.OnActivityMainLineStateChange(...) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTRPG/XUiTRPGMainLineTreasure.lua b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGMainLineTreasure.lua new file mode 100644 index 00000000..6054633f --- /dev/null +++ b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGMainLineTreasure.lua @@ -0,0 +1,34 @@ +--区域探索主线奖励界面 +local XUiTRPGMainLineTreasure = XClass(nil, "XUiTRPGMainLineTreasure") + +function XUiTRPGMainLineTreasure:Ctor(rootUi, chapterId, nodeId, clickCb) + self.RootUi = rootUi + self.ChapterId = chapterId + self.NodeId = nodeId + self.ClickCb = clickCb +end + +function XUiTRPGMainLineTreasure:UpdateBfrtRewards() + local chapterId = self.Chapter.ChapterId + local taskId = XDataCenter.BfrtManager.GetBfrtTaskId(chapterId) + local taskConfig = XDataCenter.TaskManager.GetTaskTemplate(taskId) + local rewardId = taskConfig.RewardId + local rewards = XRewardManager.GetRewardList(rewardId) + + self.BfrtRewardGrids = self.BfrtRewardGrids or {} + local rewardsNum = #rewards + for i = 1, rewardsNum do + local grid = self.BfrtRewardGrids[i] + if not grid then + local go = i == 1 and self.GridCommonPopUp or CS.UnityEngine.Object.Instantiate(self.GridCommonPopUp) + grid = XUiGridCommon.New(self, go) + self.BfrtRewardGrids[i] = grid + end + grid:Refresh(rewards[i]) + grid.Transform:SetParent(self.PanelBfrtRewrds, false) + grid.GameObject:SetActiveEx(true) + end + for i = rewardsNum + 1, #self.BfrtRewardGrids do + self.BfrtRewardGrids[i].GameObject:SetActiveEx(false) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTRPG/XUiTRPGMaze.lua b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGMaze.lua new file mode 100644 index 00000000..f7f285e3 --- /dev/null +++ b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGMaze.lua @@ -0,0 +1,481 @@ +local XUiGridTRPGRole = require("XUi/XUiTRPG/XUiGridTRPGRole") +local XUiGridTRPGCard = require("XUi/XUiTRPG/XUiGridTRPGCard") +local XUiTRPGPanelTask = require("XUi/XUiTRPG/XUiTRPGPanel/XUiTRPGPanelTask") +local XUiTRPGPanelPlotTab = require("XUi/XUiTRPG/XUiTRPGPanel/XUiTRPGPanelPlotTab") +local XUiTRPGPanelLevel = require("XUi/XUiTRPG/XUiTRPGPanel/XUiTRPGPanelLevel") + +local CSXTextManagerGetText = CS.XTextManager.GetText +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate +local CSXScheduleManagerUnSchedule = XScheduleManager.UnSchedule +local mathFloor = math.floor +local tableInsert = table.insert +local Lerp = CS.UnityEngine.Vector3.Lerp +local Vector3 = CS.UnityEngine.Vector3 + +local MAX_ROLE_NUM = 4 +local MAX_NODE_NUM = 5 --地图中显示最大行数 +local HORIZONTAL_ANIM_DURATION = 0.3 --* XScheduleManager.SECOND --卡牌水平移动动画时间 +local LINE_ANIM_DURATION = 0.3 --* XScheduleManager.SECOND --卡牌换行推进动画时间 + +local XUiTRPGMaze = XLuaUiManager.Register(XLuaUi, "UiTRPGMaze") + +function XUiTRPGMaze:OnAwake() + self:AutoAddListener() + + XUiTRPGPanelPlotTab.New(self.PanelPlotTab) + self.TaskPanel = XUiTRPGPanelTask.New(self.PanelTask, self) + self.LevelPanel = XUiTRPGPanelLevel.New(self.PanelLevel) + + self.ImgJindu = self.Transform:FindTransform("ImgJindu"):GetComponent("Image") +end + +function XUiTRPGMaze:OnStart(mazeId) + XDataCenter.TRPGManager.SaveIsAlreadyEnterMaze(mazeId) + self.MazeId = mazeId + self.RoleGrids = {} + self.MapGridToCardIdDic = {} + self.CardGridPool = {} + + self:InitMaze() + + XDataCenter.TRPGManager.TipCurrentMaze() +end + +function XUiTRPGMaze:OnEnable() + XDataCenter.TRPGManager.CheckActivityEnd() + self:UpdateRoles() + self:UpdateEndurance() + self:UpdateMap() + self:UpdateProgress() + + local toMoveCardIndex, toPlayMovieId = XDataCenter.TRPGManager.GetMazeNeedMoveNextCardIndex() + if toMoveCardIndex then + + local moveFunc = function() + self:MoveNext(toMoveCardIndex) + XDataCenter.TRPGManager.CheckOpenNewMazeTips() + end + + if toPlayMovieId then + XDataCenter.MovieManager.PlayMovie(toPlayMovieId, moveFunc) + else + moveFunc() + end + + XDataCenter.TRPGManager.ClearMazeNeedMoveNextCardIndex() + elseif not toPlayMovieId then + XDataCenter.TRPGManager.CheckOpenNewMazeTips() + end + + local isMazeNeedRestart = XDataCenter.TRPGManager.IsMazeNeedRestart() + if isMazeNeedRestart then + self:RestartCurrentLayer() + XDataCenter.TRPGManager.ClearMazeNeedRestart() + end + + self.TaskPanel:OnEnable() +end + +function XUiTRPGMaze:OnDisable() + self:DestroyHTimer() + self:DestroyLTimer() + self.TaskPanel:OnDisable() +end + +function XUiTRPGMaze:OnDestroy() + self.TaskPanel:Delete() + self.LevelPanel:Delete() +end + +function XUiTRPGMaze:OnGetEvents() + return { XEventId.EVENT_TRPG_MAZE_MOVE_NEXT + , XEventId.EVENT_TRPG_MAZE_MOVE_TO + , XEventId.EVENT_TRPG_MAZE_RECORD_CARD + , XEventId.EVENT_TRPG_BASE_INFO_CHANGE + , XEventId.EVENT_TRPG_MAZE_RESTART + , XEventId.EVENT_TRPG_ROLES_DATA_CHANGE + , XEventId.EVENT_ACTIVITY_MAINLINE_STATE_CHANGE } +end + +function XUiTRPGMaze:OnNotify(evt, ...) + local args = { ... } + if evt == XEventId.EVENT_TRPG_MAZE_MOVE_NEXT then + local cardIndex = args[1] + self:MoveNext(cardIndex) + elseif evt == XEventId.EVENT_TRPG_MAZE_MOVE_TO then + local layerId = args[1] + local nodeId = args[2] + local cardIndex = args[3] + self:MoveTo(layerId, nodeId, cardIndex) + elseif evt == XEventId.EVENT_TRPG_MAZE_RESTART then + self:RestartCurrentLayer() + elseif evt == XEventId.EVENT_TRPG_BASE_INFO_CHANGE then + self:UpdateEndurance() + elseif evt == XEventId.EVENT_TRPG_MAZE_RECORD_CARD then + self:UpdateProgress() + elseif evt == XEventId.EVENT_TRPG_ROLES_DATA_CHANGE then + self:UpdateRoles() + elseif evt == XEventId.EVENT_ACTIVITY_MAINLINE_STATE_CHANGE then + XDataCenter.TRPGManager.OnActivityMainLineStateChange(...) + end +end + +function XUiTRPGMaze:InitMaze() + local mazeId = self.MazeId + self.TxtName.text = XTRPGConfigs.GetMazeName(mazeId) +end + +function XUiTRPGMaze:UpdateRoles() + local roleIds = XDataCenter.TRPGManager.GetOwnRoleIds() + for index = 1, MAX_ROLE_NUM do + local grid = self.RoleGrids[index] + if not grid then + local ui = index == 1 and self.GridRole or CSUnityEngineObjectInstantiate(self.GridRole, self.PanelRole) + grid = XUiGridTRPGRole.New(ui) + self.RoleGrids[index] = grid + end + grid:Refresh(roleIds[index]) + end +end + +function XUiTRPGMaze:UpdateEndurance() + local curEndurance = XDataCenter.TRPGManager.GetExploreCurEndurance() + local maxEndurance = XDataCenter.TRPGManager.GetExploreMaxEndurance() + + self.ImgJindu.fillAmount = maxEndurance == 0 and 1 or curEndurance / maxEndurance + self.TxtAction.text = CSXTextManagerGetText("TRPGExploreEndurance", curEndurance, maxEndurance) +end + +function XUiTRPGMaze:UpdateProgress() + local mazeId = self.MazeId + local layerId = self.LayerId + + local mazeProgress = XDataCenter.TRPGManager.GetMazeProgress(mazeId, layerId) + self.TxtLayerProgress.text = mathFloor(mazeProgress * 100) + self.ImgLayerJindu.fillAmount = mazeProgress +end + +function XUiTRPGMaze:UpdateMap() + local mazeId = self.MazeId + + local layerId = XDataCenter.TRPGManager.GetMazeCurrentLayerId(mazeId) + self.TxtLayer.text = XTRPGConfigs.GetMazeLayerName(layerId) + + local bgImage = XTRPGConfigs.GetMazeLayerBgImage(layerId) + self.RImgChapterBg:SetRawImage(bgImage) + + local nodeIdList = XDataCenter.TRPGManager.GetMazeNodeIdList(mazeId, layerId) + self.NodeIdList = nodeIdList + + for _, grid in pairs(self.CardGridPool) do + grid.GameObject:SetActiveEx(false) + end + + for nodeIndex = 1, MAX_NODE_NUM do + local nodeId = nodeIdList[nodeIndex] + if not nodeId then break end + + local cardBeginPos, cardEndPos = XDataCenter.TRPGManager.GetMazeCardBeginEndPos(mazeId, layerId, nodeId) + + local cardNum = XDataCenter.TRPGManager.GetMazeCardNum(mazeId, layerId, nodeId) + for cardIndex = 1, cardNum do + local cardId = XDataCenter.TRPGManager.GetMazeCardId(mazeId, layerId, nodeId, cardIndex) + + local nodeGridKey = self:GetNodeGridKey(nodeIndex, cardIndex) + self.MapGridToCardIdDic[nodeGridKey] = cardId + + local grid = self:GetMapGrid(nodeIndex, cardIndex) + local isNodeReachable = XDataCenter.TRPGManager.IsNodeReachable(mazeId, layerId, nodeId) + local isCardReachable = XDataCenter.TRPGManager.IsCardReachable(mazeId, layerId, nodeId, cardIndex) + local finishedCardId = XDataCenter.TRPGManager.GetCardFinishedId(mazeId, layerId, nodeId, cardIndex) + local clickCb = function() XDataCenter.TRPGManager.SelectCard(cardIndex) end + grid:Refresh(cardId, isNodeReachable, isCardReachable, clickCb, finishedCardId) + + local cardPos = cardBeginPos + cardIndex - 1 + local nodeParentKey = self:GetNodeGridKey(nodeIndex, cardPos) + local cardParent = self[nodeParentKey] + if not cardParent then + XLog.Error("XUiTRPGMaze:UpdateMap Error: can not find cardParent, nodeIndex: " .. nodeIndex .. ", cardPos: " .. cardPos .. ", cardIndex: " .. cardIndex) + return + end + grid.Transform:SetParent(cardParent, false) + grid.Transform:Reset() + + local prefabPath = XTRPGConfigs.GetMazeCardPrefab(cardId) + grid.GameObject.name = nodeIndex .. cardIndex + grid.GameObject:SetActiveEx(true) + end + end +end + +function XUiTRPGMaze:MoveNext(cardIndex) + local asynPlayAnim = asynTask(self.PlayAnimation, self) + local asynMoveHorizontal = asynTask(self.MoveHorizontal, self) + local asynMoveNextLine = asynTask(self.MoveNextLine, self) + + RunAsyn(function() + local mazeId = self.MazeId + local layerId = XDataCenter.TRPGManager.GetMazeCurrentLayerId(mazeId) + local nodeId = XDataCenter.TRPGManager.GetMazeCurrentNodeId(mazeId) + local cardId = XDataCenter.TRPGManager.GetMazeCardId(mazeId, layerId, nodeId, cardIndex) + local cardDelta = XDataCenter.TRPGManager.GetMazeCardMoveDelta(cardIndex) + + XLuaUiManager.SetMask(true) + + --框消失anim + self:PlayAnimation("PanelSelectDisable") + + --move horizontal + asynMoveHorizontal(cardDelta) + + --move line + asynMoveNextLine(cardDelta) + + --框出现anim + self:PlayAnimation("PanelSelectEnable") + + --data refresh + XDataCenter.TRPGManager.MazeMoveNext(cardIndex) + + --ui refresh + self:UpdateMap() + + XLuaUiManager.SetMask(false) + end) +end + +function XUiTRPGMaze:MoveTo(layerId, nodeId, cardIndex) + coroutine.wrap(function() + local co = coroutine.running() + local callBack = function() coroutine.resume(co) end + + XLuaUiManager.SetMask(true) + + --maze disappear anim + self:PlayAnimation("FubenTRPGMazeDisable", callBack) + coroutine.yield() + + --data refresh + XDataCenter.TRPGManager.MazeMoveTo(layerId, nodeId, cardIndex) + + --ui refresh + self:UpdateMap() + + --maze appear anim + self:PlayAnimation("FubenTRPGMazeEnable", callBack) + coroutine.yield() + + XLuaUiManager.SetMask(false) + + XDataCenter.TRPGManager.TipCurrentMaze() + end)() +end + +function XUiTRPGMaze:RestartCurrentLayer() + coroutine.wrap(function() + local co = coroutine.running() + local callBack = function() coroutine.resume(co) end + + XLuaUiManager.SetMask(true) + + --maze disappear anim + self:PlayAnimation("FubenTRPGMazeDisable", callBack) + coroutine.yield() + + --ui refresh + self:UpdateMap() + + --maze appear anim + self:PlayAnimation("FubenTRPGMazeEnable", callBack) + coroutine.yield() + + XLuaUiManager.SetMask(false) + + XDataCenter.TRPGManager.TipCurrentMaze() + end)() +end + +function XUiTRPGMaze:AutoAddListener() + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + self.BtnMapDetails.CallBack = function() self:OnClickBtnMapDetails() end +end + +function XUiTRPGMaze:OnBtnBackClick() + XDataCenter.TRPGManager.TipQuitMaze(function() + self:Close() + end) +end + +function XUiTRPGMaze:OnBtnMainUiClick() + XDataCenter.TRPGManager.TipQuitMaze(function() + XLuaUiManager.RunMain() + end) +end + +function XUiTRPGMaze:OnClickBtnMapDetails() + XLuaUiManager.Open("UiTRPGMapTips", self.MazeId) +end + +function XUiTRPGMaze:GetNodeGridKey(nodeIndex, cardPos) + return nodeIndex .. "_" .. cardPos +end + +function XUiTRPGMaze:MoveHorizontal(cardDelta, finishCb) + local mazeId = self.MazeId + local nodeIdList = self.NodeIdList + local layerId = XDataCenter.TRPGManager.GetMazeCurrentLayerId(mazeId) + local deltaH = cardDelta + + local toMoveGridInfos = {} + + for nodeIndex = 1, MAX_NODE_NUM do + local nodeId = nodeIdList[nodeIndex] + if not nodeId then break end + + local cardBeginPos, cardEndPos = XDataCenter.TRPGManager.GetMazeCardBeginEndPos(mazeId, layerId, nodeId) + local cardNum = XDataCenter.TRPGManager.GetMazeCardNum(mazeId, layerId, nodeId) + local targetNodeIndex = nodeIndex + + for cardIndex = 1, cardNum do + local targetCardPos = cardBeginPos + cardIndex - 1 + deltaH + + local nodeParentKey = self:GetNodeGridKey(targetNodeIndex, targetCardPos) + local cardParent = self[nodeParentKey] + if not cardParent then + XLog.Error("XUiTRPGMaze:MoveHorizontal Error: can not find cardParent, targetNodeIndex: " .. targetNodeIndex .. ", targetCardPos: " .. targetCardPos) + return + end + + local grid = self:GetMapGrid(nodeIndex, cardIndex) + grid.Transform:SetParent(cardParent, true) + tableInsert(toMoveGridInfos, { + Transform = grid.Transform, + StartPos = grid.Transform.localPosition, + }) + end + end + + local onRefreshFunc = function(time) + local targetPos = Vector3.zero + for _, toMoveGridInfo in pairs(toMoveGridInfos) do + if XTool.UObjIsNil(toMoveGridInfo.Transform) then + self:DestroyHTimer() + return true + end + + local tf = toMoveGridInfo.Transform + if tf.localPosition == targetPos then + return true + end + + tf.localPosition = Lerp(toMoveGridInfo.StartPos, targetPos, time) + end + end + + self:DestroyHTimer() + self.HTimer = XUiHelper.Tween(HORIZONTAL_ANIM_DURATION, onRefreshFunc, finishCb) +end + +function XUiTRPGMaze:MoveNextLine(cardDelta, finishCb) + local mazeId = self.MazeId + local nodeIdList = self.NodeIdList + local layerId = XDataCenter.TRPGManager.GetMazeCurrentLayerId(mazeId) + local deltaH = cardDelta + local deltaL = -1 + + local toMoveGridInfos = {} + + for nodeIndex = 1, MAX_NODE_NUM do + local nodeId = nodeIdList[nodeIndex] + if not nodeId then break end + + local cardBeginPos, cardEndPos = XDataCenter.TRPGManager.GetMazeCardBeginEndPos(mazeId, layerId, nodeId) + + local cardNum = XDataCenter.TRPGManager.GetMazeCardNum(mazeId, layerId, nodeId) + local targetNodeIndex = nodeIndex + deltaL + + for cardIndex = 1, cardNum do + local targetCardPos = cardBeginPos + cardIndex - 1 + deltaH + + local nodeParentKey = self:GetNodeGridKey(targetNodeIndex, targetCardPos) + local cardParent = self[nodeParentKey] + if not cardParent then + XLog.Error("XUiTRPGMaze:MoveNextLine Error: can not find cardParent, targetNodeIndex: " .. targetNodeIndex .. ", targetCardPos: " .. targetCardPos) + return + end + + local grid = self:GetMapGrid(nodeIndex, cardIndex) + grid.Transform:SetParent(cardParent, true) + tableInsert(toMoveGridInfos, { + Transform = grid.Transform, + StartPos = grid.Transform.localPosition, + StartScale = grid.Transform.localScale, + }) + end + end + + local onRefreshFunc = function(time) + local targetPos = Vector3.zero + local targetScale = Vector3(1, 1, 1) + for _, toMoveGridInfo in pairs(toMoveGridInfos) do + if XTool.UObjIsNil(toMoveGridInfo.Transform) then + self:DestroyLTimer() + return + end + + local tf = toMoveGridInfo.Transform + + if tf.localPosition == targetPos then + return true + end + + tf.localPosition = Lerp(toMoveGridInfo.StartPos, targetPos, time) + tf.localScale = Lerp(toMoveGridInfo.StartScale, targetScale, time) + end + end + + self:DestroyLTimer() + self.LTimer = XUiHelper.Tween(LINE_ANIM_DURATION, onRefreshFunc, finishCb) +end + +function XUiTRPGMaze:DestroyHTimer() + if self.HTimer then + CSXScheduleManagerUnSchedule(self.HTimer) + self.HTimer = nil + end +end + +function XUiTRPGMaze:DestroyLTimer() + if self.LTimer then + CSXScheduleManagerUnSchedule(self.LTimer) + self.LTimer = nil + end +end + +function XUiTRPGMaze:GetMapGrid(nodeIndex, cardIndex) + local nodeGridKey = self:GetNodeGridKey(nodeIndex, cardIndex) + local gridCardId = self.MapGridToCardIdDic[nodeGridKey] + if not gridCardId then return end + return self:GetGridFromPool(gridCardId, nodeIndex, cardIndex) +end + +function XUiTRPGMaze:GetGridFromPool(cardId, nodeIndex, cardIndex) + local nodeParentKey = self:GetNodeGridKey(nodeIndex, cardIndex) + local prefabPath = XTRPGConfigs.GetMazeCardPrefab(cardId) + nodeParentKey = nodeParentKey .. prefabPath + + local grid = self.CardGridPool[nodeParentKey] + if not grid then + local ui = self[prefabPath] + if not ui then + XLog.Error("XUiTRPGMaze:GetGridFromPool error: prefab not exist, 请检查迷宫卡牌配置 Prefab 字段 ,prefabPath:", prefabPath) + return + end + + local prefab = CSUnityEngineObjectInstantiate(ui) + grid = XUiGridTRPGCard.New(prefab, self) + self.CardGridPool[nodeParentKey] = grid + end + return grid +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTRPG/XUiTRPGNewCharacter.lua b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGNewCharacter.lua new file mode 100644 index 00000000..ab9f5314 --- /dev/null +++ b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGNewCharacter.lua @@ -0,0 +1,48 @@ +local XUiTRPGNewCharacter = XLuaUiManager.Register(XLuaUi, "UiTRPGNewCharacter") + +function XUiTRPGNewCharacter:OnAwake() + self:AutoAddListener() +end + +function XUiTRPGNewCharacter:OnStart(roleId) + self.RoleId = roleId + + self:InitUi() +end + +function XUiTRPGNewCharacter:InitUi() + local roleId = self.RoleId + + local name = XTRPGConfigs.GetRoleName(roleId) + self.TxtName.text = name + + local desc = XTRPGConfigs.GetRoleDesc(roleId) + self.TxtInformation.text = desc + + local image = XTRPGConfigs.GetRoleImage(roleId) + self.RImgCharacter:SetRawImage(image) + + local attributes = XDataCenter.TRPGManager.GetRoleAttributes(roleId) + for index, attr in pairs(attributes) do + local value = attr.Value + self["TxtValue" .. index].text = value + + local maxValue = XTRPGConfigs.GetRoleAttributeMaxValue(attr.Type) + local rate = value / maxValue + + local center = self.Transform:FindTransform("Center") + local cPos = center.transform.localPosition + local pos = self["Point" .. index].transform.localPosition + self["Point" .. index].transform.localPosition = (pos - cPos) * rate + cPos + end + + self.GraphPolygon:Refresh() +end + +function XUiTRPGNewCharacter:AutoAddListener() + self:RegisterClickEvent(self.BtnClose, self.OnBtnBackClick) +end + +function XUiTRPGNewCharacter:OnBtnBackClick() + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTRPG/XUiTRPGObtain.lua b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGObtain.lua new file mode 100644 index 00000000..a844d053 --- /dev/null +++ b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGObtain.lua @@ -0,0 +1,49 @@ +local XUiGridTRPGItem = require("XUi/XUiTRPG/XUiGridTRPGItem") + +local XUiTRPGObtain = XLuaUiManager.Register(XLuaUi, "UiTRPGObtain") + +function XUiTRPGObtain:OnAwake() + self:AutoAddListener() +end + +function XUiTRPGObtain:OnStart(itemId, itemCount, closeCb) + self.ItemId = itemId + self.ItemCount = itemCount + self.CloseCb = closeCb +end + +function XUiTRPGObtain:OnEnable() + self:UpdateItem() +end + +function XUiTRPGObtain:OnDestroy() + if self.CloseCb then + self.CloseCb() + end +end + +function XUiTRPGObtain:UpdateItem() + local itemId = self.ItemId + local itemCount = self.ItemCount + + local grid = self.ItemGrid + if not grid then + grid = XUiGridTRPGItem.New(self.GridItem, self) + self.ItemGrid = grid + end + grid:Refresh(itemId, itemCount) +end + +function XUiTRPGObtain:AutoAddListener() + self:RegisterClickEvent(self.BtnCancel, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:RegisterClickEvent(self.BtnHelpCourse, self.OnBtnHelpClick) +end + +function XUiTRPGObtain:OnBtnBackClick() + self:Close() +end + +function XUiTRPGObtain:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTRPG/XUiTRPGPanel/XUiTRPGPanelLevel.lua b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGPanel/XUiTRPGPanelLevel.lua new file mode 100644 index 00000000..5b35cb50 --- /dev/null +++ b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGPanel/XUiTRPGPanelLevel.lua @@ -0,0 +1,95 @@ +local XUiTRPGPanelLevel = XClass(nil, "XUiTRPGPanelLevel") + +local CSXTextManagerGetText = CS.XTextManager.GetText +local stringGsub = string.gsub + +function XUiTRPGPanelLevel:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + self:InitUi() + self:AutoAddListener() + self:Refresh() + + XEventManager.AddEventListener(XEventId.EVENT_TRPG_BASE_INFO_CHANGE, self.Refresh, self) + XEventManager.AddEventListener(XEventId.EVENT_TRPG_OPEN_LEVEL_DIALOG, self.CheckRedPoint, self) +end + +function XUiTRPGPanelLevel:Delete() + XEventManager.RemoveEventListener(XEventId.EVENT_TRPG_BASE_INFO_CHANGE, self.Refresh, self) + XEventManager.RemoveEventListener(XEventId.EVENT_TRPG_OPEN_LEVEL_DIALOG, self.CheckRedPoint, self) +end + +function XUiTRPGPanelLevel:InitUi() + self.TxtLevel = XUiHelper.TryGetComponent(self.Transform, "TxtLevel", "Text") + self.Btn = XUiHelper.TryGetComponent(self.Transform, "Btn", "XUiButton") + self.ImgLevel = XUiHelper.TryGetComponent(self.Transform, "PanelJindu/ImgLevel", "Image") + self.TxtEXP = XUiHelper.TryGetComponent(self.Transform, "TxtEXP", "Text") + self.TxtEndurance = XUiHelper.TryGetComponent(self.Transform, "TxtEndurance", "Text") + self.BtnXq = XUiHelper.TryGetComponent(self.Transform, "BtnXq", "XUiButton") + self.Red = XUiHelper.TryGetComponent(self.Transform, "Red") +end + +function XUiTRPGPanelLevel:AutoAddListener() + if self.Btn then + XUiHelper.RegisterClickEvent(self, self.Btn, self.OnBtnClick) + end + if self.BtnXq then + XUiHelper.RegisterClickEvent(self, self.BtnXq, self.OnClickBtnDesc) + end +end + +function XUiTRPGPanelLevel:Refresh() + self:UpdateExploreLevel() + self:UpdateEndurance() + self:CheckRedPoint() +end + +function XUiTRPGPanelLevel:UpdateExploreLevel() + local level = XDataCenter.TRPGManager.GetExploreLevel() + local curExp = XDataCenter.TRPGManager.GetExploreCurExp() + local maxExp = XDataCenter.TRPGManager.GetExploreMaxExp() + if self.ImgLevel and maxExp > 0 then + self.ImgLevel.fillAmount = curExp / maxExp + end + if self.TxtLevel then + self.TxtLevel.text = level + end + + if self.TxtEXP then + local isMaxLevel = XTRPGConfigs.IsMaxLevel(level) + if isMaxLevel then + self.TxtEXP.text = CSXTextManagerGetText("TRPGExploreExp", "-", "-") + else + self.TxtEXP.text = CSXTextManagerGetText("TRPGExploreExp", curExp, maxExp) + end + end +end + +function XUiTRPGPanelLevel:UpdateEndurance() + if not self.TxtEndurance then return end + local curEndurance = XDataCenter.TRPGManager.GetExploreCurEndurance() + local maxEndurance = XDataCenter.TRPGManager.GetExploreMaxEndurance() + self.TxtEndurance.text = CSXTextManagerGetText("TRPGExploreEndurance", curEndurance, maxEndurance) +end + +function XUiTRPGPanelLevel:OnBtnClick() + XLuaUiManager.Open("UiTRPGDialog") +end + +function XUiTRPGPanelLevel:OnClickBtnDesc() + local title = CSXTextManagerGetText("TRPGEnduranceTitle") + local desc = CSXTextManagerGetText("TRPGEnduranceDesc") + desc = stringGsub(desc, "\\n", "\n") + XUiManager.UiFubenDialogTip(title, desc) +end + +function XUiTRPGPanelLevel:CheckRedPoint() + if self.Red then + local isShow = XDataCenter.TRPGManager.IsShowExploreRedPointLevel() + self.Red.gameObject:SetActiveEx(isShow) + end +end + +return XUiTRPGPanelLevel \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTRPG/XUiTRPGPanel/XUiTRPGPanelPlotTab.lua b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGPanel/XUiTRPGPanelPlotTab.lua new file mode 100644 index 00000000..b5956144 --- /dev/null +++ b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGPanel/XUiTRPGPanelPlotTab.lua @@ -0,0 +1,134 @@ +local Object +local CSXTextManagerGetText = CS.XTextManager.GetText +local UiIndex = { + TRPGTruthRoadMain = 1, --求真之路 + TRPGYingDi = 2, --营地 +} + +--求真之路和探索营地入口 +local XUiTRPGPanelPlotTab = XClass(nil, "XUiTRPGPanelPlotTab") + +function XUiTRPGPanelPlotTab:Ctor(ui, isShowTRPGTruthRoadMain) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + Object = CS.UnityEngine.Object + self:InitUiOpenCheckList() + self:InitTab(isShowTRPGTruthRoadMain) +end + +function XUiTRPGPanelPlotTab:InitUiOpenCheckList() + self.UiOpenCheckList = { + [UiIndex.TRPGTruthRoadMain] = self.CheckIsOpenTruthRoad, + } + + self.BtnPrequelPlotTabRedPointConditions = { + [UiIndex.TRPGTruthRoadMain] = { + func = self.OnCheckTRPGTruthRoadRedPoint, + conditionGroup = {XRedPointConditions.Types.CONDITION_TRPG_TRUTH_ROAD_REWARD} + }, + [UiIndex.TRPGYingDi] = { + func = self.OnCheckTRPGYingDiRedPoint, + conditionGroup = {XRedPointConditions.Types.CONDITION_TRPG_COLLECTION_MEMOIR} + }, + } +end + +function XUiTRPGPanelPlotTab:InitTab(isShowTRPGTruthRoadMain) + self.GroupTabBtns = {} + local config = XTRPGConfigs.GetPanelPlotTabTemplate() + local name, bg + for i in ipairs(config) do + if not self.GroupTabBtns[i] then + if i == 1 then + self.GroupTabBtns[i] = self.BtnPrequelPlotTab + else + local btn = Object.Instantiate(self.BtnPrequelPlotTab) + btn.transform:SetParent(self.UiContent.transform, false) + self.GroupTabBtns[i] = btn + end + end + name = XTRPGConfigs.GetPanelPlotTabName(i) + bg = XTRPGConfigs.GetPanelPlotTabBg(i) + if i == UiIndex.TRPGTruthRoadMain then + self.GroupTabBtns[i].gameObject:SetActiveEx(isShowTRPGTruthRoadMain and true or false) + else + self.GroupTabBtns[i].gameObject:SetActiveEx(true) + end + self.GroupTabBtns[i]:SetName(name) + self.GroupTabBtns[i]:SetRawImage(bg) + self:AddRedPointEvent(i) + end + + self.UiContent:Init(self.GroupTabBtns, function(groupIndex) self:OnTabsClick(groupIndex) end) +end + +function XUiTRPGPanelPlotTab:Refresh() + local ret + for i, groupTabBtn in ipairs(self.GroupTabBtns) do + ret = XTRPGConfigs.CheckPanelPlotTabCondition(i) + groupTabBtn:SetDisable(not ret) + end +end + +function XUiTRPGPanelPlotTab:OnTabsClick(groupIndex) + local openUiName = XTRPGConfigs.GetPanelPlotTabOpenUiName(groupIndex) + local isOpen, desc, param = self:CheckIsOpen(groupIndex) + if isOpen then + XLuaUiManager.Open(openUiName, param) + else + XUiManager.TipMsg(desc) + end +end + +function XUiTRPGPanelPlotTab:AddRedPointEvent(index) + local tabBtn = self.GroupTabBtns[index] + local redPointConditions = self.BtnPrequelPlotTabRedPointConditions[index] + local func = redPointConditions and redPointConditions.func + local conditionGroup = redPointConditions and redPointConditions.conditionGroup + if tabBtn and func and conditionGroup then + XRedPointManager.AddRedPointEvent(tabBtn, func, self, conditionGroup) + end +end + +function XUiTRPGPanelPlotTab:CheckIsOpen(index) + if self.UiOpenCheckList[index] then + return self.UiOpenCheckList[index]() + end + return true, "" +end + +function XUiTRPGPanelPlotTab:CheckIsOpenTruthRoad() + local ret, desc = XTRPGConfigs.CheckPanelPlotTabCondition(UiIndex.TRPGTruthRoadMain) + if ret then + local mainAreaMaxNum = XTRPGConfigs.GetMainAreaMaxNum() + local isTruthRoadOpenArea + for mainAreaId = 1, mainAreaMaxNum do + isTruthRoadOpenArea = XDataCenter.TRPGManager.IsTruthRoadOpenArea(mainAreaId) + if isTruthRoadOpenArea then + return true, "", {mainAreaId} + end + end + end + return false, desc +end + +--更新求真之路红点显示 +function XUiTRPGPanelPlotTab:OnCheckTRPGTruthRoadRedPoint(count) + local tabBtn = self.GroupTabBtns[UiIndex.TRPGTruthRoadMain] + if tabBtn then + local ret = XTRPGConfigs.CheckPanelPlotTabCondition(UiIndex.TRPGTruthRoadMain) + tabBtn:ShowReddot(ret and count >= 0) + end +end + +--更新营地红点显示 +function XUiTRPGPanelPlotTab:OnCheckTRPGYingDiRedPoint(count) + local tabBtn = self.GroupTabBtns[UiIndex.TRPGYingDi] + if tabBtn then + tabBtn:ShowReddot(count >= 0) + end +end + +return XUiTRPGPanelPlotTab \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTRPG/XUiTRPGPanel/XUiTRPGPanelTask.lua b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGPanel/XUiTRPGPanelTask.lua new file mode 100644 index 00000000..c25ab1b4 --- /dev/null +++ b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGPanel/XUiTRPGPanelTask.lua @@ -0,0 +1,329 @@ +local DefaultRoleIcon = CS.XGame.ClientConfig:GetString("TRPGNotTargetDefaultRoleIcon") +local Second = 500 +local TRPGPanelTaskEnableTime = CS.XGame.ClientConfig:GetFloat("TRPGPanelTaskEnableTime") +local TRPGPanelTaskDisableTime = CS.XGame.ClientConfig:GetFloat("TRPGPanelTaskDisableTime") +local CSXScheduleManagerScheduleForever = XScheduleManager.ScheduleForever +local CSXScheduleManagerUnSchedule = XScheduleManager.UnSchedule +local PlayAnimaState = { + Stop = 0, + AnimaOne = 1, + AnimaTwo = 2, + AnimaThree = 3, + AnimaFour = 4, + ShowNewPanel = 5 +} + +--当前的任务引导 +local XUiTRPGPanelTask = XClass(nil, "XUiTRPGPanelTask") + +function XUiTRPGPanelTask:Ctor(ui, rootUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + + self.EndTimeSecond = 0 + self.CurrPlayAnimaState = PlayAnimaState.Stop + self.IsPlaying = false + self.PlayAnimaPauseTime = 0 --动画播完一个后等待一段时间再播下一个 + + self:InitUi() + self:AutoAddListener() + self:Refresh() +end + +function XUiTRPGPanelTask:AddEventListeners() + XEventManager.AddEventListener(XEventId.EVENT_TRPG_UPDATE_TARGET, self.Refresh, self) + XEventManager.AddEventListener(XEventId.EVENT_MOVIE_BEGIN, self.SetNewTargetTime, self) + XEventManager.AddEventListener(XEventId.EVENT_MOVIE_END, self.Refresh, self) +end + +function XUiTRPGPanelTask:Delete() + XDataCenter.TRPGManager.ClearNewTargetTime() +end + +function XUiTRPGPanelTask:OnEnable() + self.RootUi:PlayAnimation("PanelTaskEnable") + self:AddEventListeners() + self:Refresh() +end + +function XUiTRPGPanelTask:OnDisable() + self:RePlayAnima() + XEventManager.RemoveEventListener(XEventId.EVENT_TRPG_UPDATE_TARGET, self.Refresh, self) + XEventManager.RemoveEventListener(XEventId.EVENT_MOVIE_BEGIN, self.SetNewTargetTime, self) + XEventManager.RemoveEventListener(XEventId.EVENT_MOVIE_END, self.Refresh, self) +end + +function XUiTRPGPanelTask:InitUi() + self.Text = XUiHelper.TryGetComponent(self.Transform, "PanelNormal/Text", "Text") + self.Btn = XUiHelper.TryGetComponent(self.Transform, "Btn", "XUiButton") + self.TxtTask = XUiHelper.TryGetComponent(self.Transform, "PanelNormal/TxtTask", "Text") + self.RImgIcon = XUiHelper.TryGetComponent(self.Transform, "PanelNormal/RImgIcon", "RawImage") + self.ImgIcon = XUiHelper.TryGetComponent(self.Transform, "PanelNormal/Text/ImgIcon", "Image") + self.ImgEmpty = XUiHelper.TryGetComponent(self.Transform, "PanelNormal/ImgEmpty") + self.TxtNone = XUiHelper.TryGetComponent(self.Transform, "PanelNormal/ImgEmpty/TxtNone", "Text") + self.PanelNew = XUiHelper.TryGetComponent(self.Transform, "PanelNormal/PanelNew") + self.Effect = XUiHelper.TryGetComponent(self.Transform, "Effect") + self.PanelNormal = XUiHelper.TryGetComponent(self.Transform, "PanelNormal") + self.PanelComplete = XUiHelper.TryGetComponent(self.Transform, "PanelComplete") + + if self.PanelNew then + self.PanelNew.gameObject:SetActiveEx(false) + end +end + +function XUiTRPGPanelTask:AutoAddListener() + if self.Btn then + XUiHelper.RegisterClickEvent(self, self.Btn, self.OnBtnTaskClick) + end +end + +--isNotPlayNewAnima:XUiTRPGTaskTip主动切换目标不播放新目标动画 +function XUiTRPGPanelTask:Refresh(isNotPlayNewAnima) + if self:CheckStopRefresh() then return end + + local currTargetLinkId = XDataCenter.TRPGManager.GetCurrTargetLinkId() + local targetLinkIsFinish = XDataCenter.TRPGManager.GetTargetLinkIsFinish(currTargetLinkId) + local currTargetId = XDataCenter.TRPGManager.GetCurrTargetId() + if self.Text then + if targetLinkIsFinish then + self.Text.text = "" + else + self.Text.text = XTRPGConfigs.GetTargetName(currTargetId) + end + end + + local targetDesc = XTRPGConfigs.GetTargetDesc(currTargetId) + if self.TxtTask then + if targetLinkIsFinish then + self.TxtTask.text = "" + else + self.TxtTask.text = targetDesc + end + end + + if self.ImgEmpty then + if targetLinkIsFinish then + if self.TxtNone then + self.TxtNone.text = targetDesc + end + self.ImgEmpty.gameObject:SetActiveEx(true) + else + self.ImgEmpty.gameObject:SetActiveEx(false) + end + end + + --角色头像 + if self.RImgIcon then + local areaIconPath = XTRPGConfigs.GetTargetAreaIcon(currTargetId) + if areaIconPath and "" ~= areaIconPath then + self.RImgIcon:SetRawImage(areaIconPath) + else + self.RImgIcon:SetRawImage(DefaultRoleIcon) + end + end + + --卡牌图标 + if self.ImgIcon and self.RootUi then + local cardIconPath = XTRPGConfigs.GetTargetCardIcon(currTargetId) + if cardIconPath then + self.RootUi:SetUiSprite(self.ImgIcon, cardIconPath) + self.ImgIcon.gameObject:SetActiveEx(true) + else + self.ImgIcon.gameObject:SetActiveEx(false) + end + end + + self:RefreshPanelNew(isNotPlayNewAnima) +end + +function XUiTRPGPanelTask:RefreshPanelNew(isNotPlayNewAnima) + local isPlayNewAnima, endTimeSecond = self:GetIsPlayNewAnima() + if isPlayNewAnima and not isNotPlayNewAnima then + self:PlayNewAnima(endTimeSecond) + end +end + +function XUiTRPGPanelTask:PlayNewAnima(endTimeSecond) + if self:CheckStopRefresh() then + return + end + + self:RePlayAnima() + self.Timer = CSXScheduleManagerScheduleForever(function() + self:RefreshNew(endTimeSecond) + end, Second, 0) + self:PlayOneAnima() +end + +function XUiTRPGPanelTask:RefreshNew(endTimeSecond) + if self.IsPlaying then + return + end + + local nowTime = XTime.GetServerNowTimestamp() + if nowTime < self.PlayAnimaPauseTime then + return + end + + if self.CurrPlayAnimaState == PlayAnimaState.AnimaTwo then + self:PlayTwoAnima() + elseif self.CurrPlayAnimaState == PlayAnimaState.AnimaThree then + self:PlayThreeAnima() + elseif self.CurrPlayAnimaState == PlayAnimaState.AnimaFour then + self:PlayFourAnima() + elseif self.CurrPlayAnimaState == PlayAnimaState.ShowNewPanel then + self:RefreshNewTag(endTimeSecond) + end +end + +function XUiTRPGPanelTask:PlayOneAnima() + if self:CheckStopRefresh() then + return + end + if self.RootUi then + self:SetIsPlaying(true) + self.RootUi:PlayAnimation("PanelTaskDisable", function() + self:SetIsPlaying(false) + self:SetCurrPlayAnimaState(PlayAnimaState.AnimaTwo) + end) + end +end + +function XUiTRPGPanelTask:PlayTwoAnima() + if self:CheckStopRefresh() then + return + end + self:PanelNormalSwitchComplete(true) + self:ShowEffect(true) + if self.RootUi then + self:SetIsPlaying(true) + self.RootUi:PlayAnimation("PanelTaskEnable", function() + self:SetAnimaPauseTime(TRPGPanelTaskEnableTime) + self:SetIsPlaying(false) + self:SetCurrPlayAnimaState(PlayAnimaState.AnimaThree) + end) + end +end + +function XUiTRPGPanelTask:PlayThreeAnima() + if self:CheckStopRefresh() then + return + end + + if self.RootUi then + self:SetIsPlaying(true) + self.RootUi:PlayAnimation("PanelTaskDisable", function() + self:SetAnimaPauseTime(TRPGPanelTaskDisableTime) + self:ShowEffect(false) + self:SetIsPlaying(false) + self:SetCurrPlayAnimaState(PlayAnimaState.AnimaFour) + end) + end +end + +function XUiTRPGPanelTask:PlayFourAnima() + if self:CheckStopRefresh() then + return + end + if self.RootUi then + self:PanelNormalSwitchComplete(false) + self:ShowEffect(true) + self:SetCurrPlayAnimaState(PlayAnimaState.ShowNewPanel) + self.RootUi:PlayAnimation("PanelTaskEnable") + end +end + +function XUiTRPGPanelTask:GetIsPlayNewAnima() + self.EndTimeSecond = XDataCenter.TRPGManager.GetTaskPanelNewShowTime() + local newTargetTime = XDataCenter.TRPGManager.GetNewTargetTime() + local now = XTime.GetServerNowTimestamp() + local endTimeSecond = newTargetTime > 0 and newTargetTime + now or self.EndTimeSecond + return now < endTimeSecond, endTimeSecond +end + +function XUiTRPGPanelTask:RefreshNewTag(endTimeSecond) + local now = XTime.GetServerNowTimestamp() + if now >= endTimeSecond then + self:ShowNew(false) + self:StopTimer() + + XDataCenter.TRPGManager.ClearNewTargetTime() + return + end + self:ShowNew(true) +end + +function XUiTRPGPanelTask:StopTimer() + if self.Timer then + CSXScheduleManagerUnSchedule(self.Timer) + self.Timer = nil + end +end + +function XUiTRPGPanelTask:OnBtnTaskClick() + XLuaUiManager.Open("UiTRPGTaskTip") +end + +function XUiTRPGPanelTask:SetNewTargetTime() + self:StopTimer() + local nowTime = XTime.GetServerNowTimestamp() + if nowTime < self.EndTimeSecond then + XDataCenter.TRPGManager.SetNewTargetTime(self.EndTimeSecond - nowTime) + end + self:ShowNew(false) +end + +function XUiTRPGPanelTask:ShowNew(isShow) + if self.PanelNew then + self.PanelNew.gameObject:SetActiveEx(isShow) + end + self:ShowEffect(isShow) +end + +function XUiTRPGPanelTask:ShowEffect(isShow) + if self.Effect then + self.Effect.gameObject:SetActiveEx(isShow) + end +end + +function XUiTRPGPanelTask:CheckStopRefresh() + if XTool.UObjIsNil(self.GameObject) or not self.GameObject.activeInHierarchy or XDataCenter.MovieManager.IsPlayingMovie() then + self:RePlayAnima() + return true + end + return false +end + +function XUiTRPGPanelTask:PanelNormalSwitchComplete(isShowComplete) + if self.PanelNormal then + self.PanelNormal.gameObject:SetActiveEx(not isShowComplete) + end + if self.PanelComplete then + self.PanelComplete.gameObject:SetActiveEx(isShowComplete) + end +end + +function XUiTRPGPanelTask:SetCurrPlayAnimaState(animaState) + self.CurrPlayAnimaState = animaState +end + +function XUiTRPGPanelTask:SetIsPlaying(isPlaying) + self.IsPlaying = isPlaying +end + +function XUiTRPGPanelTask:SetAnimaPauseTime(pauseTime) + local nowTime = XTime.GetServerNowTimestamp() + self.PlayAnimaPauseTime = nowTime + pauseTime +end + +function XUiTRPGPanelTask:RePlayAnima() + self:StopTimer() + self:ShowNew(false) + self:SetCurrPlayAnimaState(PlayAnimaState.Stop) + self:SetIsPlaying(false) + self:PanelNormalSwitchComplete(false) +end + +return XUiTRPGPanelTask \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTRPG/XUiTRPGRewardTip/XUiTRPGRewardGrid.lua b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGRewardTip/XUiTRPGRewardGrid.lua new file mode 100644 index 00000000..e1d5c300 --- /dev/null +++ b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGRewardTip/XUiTRPGRewardGrid.lua @@ -0,0 +1,115 @@ +local XUiTRPGRewardGrid = XClass(nil, "XUiTRPGRewardGrid") + +function XUiTRPGRewardGrid:Ctor(ui, rootUi, truthRoadGroupId, secondMainId) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self.TruthRoadGroupId = truthRoadGroupId + self.SecondMainId = secondMainId + XTool.InitUiObject(self) + + self.BtnFinish.CallBack = function() self:OnBtnFinishClick() end + + self.GridList = {} +end + +function XUiTRPGRewardGrid:Refresh(trpgRewardId) + self.TRPGRewardId = trpgRewardId + + local ret = XDataCenter.TRPGManager.CheckRewardCondition(trpgRewardId, self.SecondMainId) + self.TxtTaskName.text = self.SecondMainId and XTRPGConfigs.GetSecondMainReceiveDesc(trpgRewardId) or XTRPGConfigs.GetRewardReceiveDesc(trpgRewardId) + + local isReceiveReward = XDataCenter.TRPGManager.IsReceiveReward(trpgRewardId) + self.BtnFinish:SetDisable(not ret, ret) + self.BtnFinish.gameObject:SetActiveEx(not isReceiveReward) + self.ImgAlreadyFinish.gameObject:SetActiveEx(isReceiveReward) + + local rewardId = XTRPGConfigs.GetRewardId(trpgRewardId) + self:RefreshTreasureList(rewardId) + + self:CheckRefreshProgress() +end + +function XUiTRPGRewardGrid:CheckRefreshProgress() + local curPercent + local receivePercent + if self.TruthRoadGroupId then + curPercent = XDataCenter.TRPGManager.GetTruthRoadPercent(self.TruthRoadGroupId) + receivePercent = XTRPGConfigs.GetTruthRoadRewardRecivePercent(self.TruthRoadGroupId, self.TRPGRewardId) + elseif self.SecondMainId then + curPercent = XDataCenter.TRPGManager.GetSecondMainStagePercent(self.SecondMainId) + receivePercent = XTRPGConfigs.GetSecondMainRewardRecivePercent(self.SecondMainId, self.TRPGRewardId) + else + self.ProgressBg.gameObject:SetActiveEx(false) + self.TxtTaskNumQian.gameObject:SetActiveEx(false) + return + end + self:RefreshProgress(curPercent, receivePercent) +end + +function XUiTRPGRewardGrid:RefreshProgress(curPercent, receivePercent) + if receivePercent <= 0 then + self.ImgProgress.fillAmount = 0 + else + self.ImgProgress.fillAmount = math.min(curPercent / receivePercent, 1) + end + self.TxtTaskNumQian.text = CS.XTextManager.GetText("TRPGAlreadyobtainedCount", math.floor(curPercent * 100) .. "%", math.floor(receivePercent * 100) .. "%") + + self.ProgressBg.gameObject:SetActiveEx(true) + self.TxtTaskNumQian.gameObject:SetActiveEx(true) +end + +function XUiTRPGRewardGrid:RefreshTreasureList(rewardId) + local rewards = XRewardManager.GetRewardList(rewardId) + if not rewards then return end + + for i, item in ipairs(rewards) do + local grid = self.GridList[i] + if not grid then + if i == 1 then + grid = XUiGridCommon.New(self.RootUi, self.GridCommon) + else + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommon) + grid = XUiGridCommon.New(self.RootUi, ui) + grid.Transform:SetParent(self.PanelRewardContent, false) + end + self.GridList[i] = grid + end + grid:Refresh(item) + grid.GameObject:SetActiveEx(true) + end + + for j = 1, #self.GridList do + if j > #rewards then + self.GridList[j].GameObject:SetActive(false) + end + end +end + +function XUiTRPGRewardGrid:OnBtnFinishClick() + local rewardId = XTRPGConfigs.GetRewardId(self.TRPGRewardId) + local rewards = XRewardManager.GetRewardList(rewardId) + if not rewards then return end + + --如果成功获得奖励时是否有道具会超出最大限制 + local isOpenTips = false + local itemMaxCount + local itemCount + for _, v in ipairs(rewards) do + itemMaxCount = XTRPGConfigs.GetItemMaxCount(v.TemplateId) + itemCount = XDataCenter.ItemManager.GetCount(v.TemplateId) + if itemCount + v.Count > itemMaxCount then + isOpenTips = true + break + end + end + + XDataCenter.TRPGManager.RequestRewardSend(self.TRPGRewardId, function () + self:Refresh(self.TRPGRewardId) + if isOpenTips then + XUiManager.TipText("TRPGGetRewardMaxTips") + end + end) +end + +return XUiTRPGRewardGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTRPG/XUiTRPGRewardTip/XUiTRPGRewardTip.lua b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGRewardTip/XUiTRPGRewardTip.lua new file mode 100644 index 00000000..284dc72c --- /dev/null +++ b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGRewardTip/XUiTRPGRewardTip.lua @@ -0,0 +1,40 @@ +local XUiTRPGRewardGrid = require("XUi/XUiTRPG/XUiTRPGRewardTip/XUiTRPGRewardGrid") + +--领取奖励弹窗 +local XUiTRPGRewardTip = XLuaUiManager.Register(XLuaUi, "UiTRPGRewardTip") + +function XUiTRPGRewardTip:OnAwake() + self:AutoAddListener() + self.GridPrequelCheckPointReward.gameObject:SetActiveEx(false) +end + +function XUiTRPGRewardTip:OnStart(rewardIdList, truthRoadGroupId, secondMainId) + self.RewardIdList = rewardIdList + self.TruthRoadGroupId = truthRoadGroupId + self.SecondMainId = secondMainId + self:InitDynamicTable() + self:Refresh() +end + +function XUiTRPGRewardTip:AutoAddListener() + self:RegisterClickEvent(self.BtnMask, self.Close) + self:RegisterClickEvent(self.BtnTanchuangClose, self.Close) +end + +function XUiTRPGRewardTip:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.SViewRewardList) + self.DynamicTable:SetDelegate(self) + self.DynamicTable:SetProxy(XUiTRPGRewardGrid, self, self.TruthRoadGroupId, self.SecondMainId) +end + +function XUiTRPGRewardTip:Refresh() + self.DynamicTable:SetDataSource(self.RewardIdList) + self.DynamicTable:ReloadDataSync() +end + +function XUiTRPGRewardTip:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local rewardId = self.RewardIdList[index] + grid:Refresh(rewardId) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTRPG/XUiTRPGSecondMain/XUiTRPGSecondMain.lua b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGSecondMain/XUiTRPGSecondMain.lua new file mode 100644 index 00000000..8bcd36c7 --- /dev/null +++ b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGSecondMain/XUiTRPGSecondMain.lua @@ -0,0 +1,86 @@ +--常规主线主界面 +local XUiTRPGSecondMain = XLuaUiManager.Register(XLuaUi, "UiTRPGSecondMain") + +function XUiTRPGSecondMain:OnAwake() + self.IsSwitchStatusOpenView = false --是否从切换模式按钮打开本界面 + self:AutoAddListener() +end + +function XUiTRPGSecondMain:OnStart(isSwitchStatusOpenView) + self.IsSwitchStatusOpenView = isSwitchStatusOpenView + self.RedMain = XRedPointManager.AddRedPointEvent(self.PanelCut, self.OnCheckMainRedPoint, self, { XRedPointConditions.Types.CONDITION_TRPG_MAIN_MODE }, nil, true) +end + +function XUiTRPGSecondMain:OnEnable() + local openAnimaName = self.IsSwitchStatusOpenView and "QieHuan" or "Enable" + self:PlayAnimation(openAnimaName) + self.IsSwitchStatusOpenView = false + + self:Refresh() + self:OnCheckRedPoint() +end + +function XUiTRPGSecondMain:Refresh() + local percent + local condition + local secondMainIdList = XTRPGConfigs.GetSecondMainIdList() + local ret + for i, secondMainId in ipairs(secondMainIdList) do + percent = XDataCenter.TRPGManager.GetSecondMainStagePercent(secondMainId) + self["PanelEntrance" .. i]:SetName(math.floor(percent * 100) .. "%") + + ret = XDataCenter.TRPGManager.CheckSecondMainCondition(secondMainId) + self["PanelEntrance" .. i]:SetDisable(not ret) + end +end + +function XUiTRPGSecondMain:AutoAddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:BindHelpBtn(self.BtnHelpCourse, "TRPGMainLine") + self:RegisterClickEvent(self.PanelCut, self.OnPanelCutClick) + + local secondMainIdList = XTRPGConfigs.GetSecondMainIdList() + for i, secondMainId in ipairs(secondMainIdList) do + self["PanelEntrance" .. i].CallBack = function() self:OnGridPanelChapterClick(secondMainId) end + end +end + +function XUiTRPGSecondMain:OnGridPanelChapterClick(secondMainId) + local ret, desc = XDataCenter.TRPGManager.CheckSecondMainCondition(secondMainId) + if not ret then + XUiManager.TipError(desc) + return + end + XLuaUiManager.Open("UiTRPGTruthRoadSecondMain", secondMainId) +end + +function XUiTRPGSecondMain:OnCheckRedPoint() + local secondMainIdList = XTRPGConfigs.GetSecondMainIdList() + local isShowRedPoint + for i, secondMainId in ipairs(secondMainIdList) do + isShowRedPoint = XDataCenter.TRPGManager.IsSecondMainCanReward(secondMainId) + self["PanelEntrance" .. i]:ShowReddot(isShowRedPoint) + end + + if self.RedMain then + XRedPointManager.Check(self.RedMain) + end +end + +function XUiTRPGSecondMain:OnCheckMainRedPoint(count) + self.PanelCut:ShowReddot(count >= 0) +end + +function XUiTRPGSecondMain:OnPanelCutClick() + XDataCenter.TRPGManager.RequestTRPGChangePageStatus(false) + XLuaUiManager.PopThenOpen("UiTRPGMain", true) +end + +function XUiTRPGSecondMain:OnBtnBackClick() + self:Close() +end + +function XUiTRPGSecondMain:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTRPG/XUiTRPGSecondMain/XUiTRPGTruthRoadSecondMain.lua b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGSecondMain/XUiTRPGTruthRoadSecondMain.lua new file mode 100644 index 00000000..8a76bb81 --- /dev/null +++ b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGSecondMain/XUiTRPGTruthRoadSecondMain.lua @@ -0,0 +1,178 @@ +local Object + +local XUiTRPGTruthRoadSecondMainStages = require("XUi/XUiTRPG/XUiTRPGSecondMain/XUiTRPGTruthRoadSecondMainStages") + +--常规主线的关卡界面 +local XUiTRPGTruthRoadSecondMain = XLuaUiManager.Register(XLuaUi, "UiTRPGTruthRoadSecondMain") + +function XUiTRPGTruthRoadSecondMain:OnAwake() + XDataCenter.TRPGManager.SaveIsAlreadyOpenTruthRoad() + + self.TopTabBtns = {} + Object = CS.UnityEngine.Object + self.CurStages = nil + self.StageId = 0 + self.CurrSelectSecondMainStageId = nil --当前选择的关卡id + + self:InitAutoScript() + + self.PanelSpecialTool.gameObject:SetActiveEx(false) + + XEventManager.AddEventListener(XEventId.EVENT_TRPG_GET_REWARD, self.OnCheckRedPoint, self) +end + +function XUiTRPGTruthRoadSecondMain:OnStart(secondMainId) + self.SecondMainId = secondMainId + + local secondMainBg = XTRPGConfigs.GetSecondMainBG(secondMainId) + self.RImgBg:SetRawImage(secondMainBg) + + self:OnCheckRedPoint() + self:InitStagesMap() +end + +function XUiTRPGTruthRoadSecondMain:OnEnable() + self:Refresh() +end + +function XUiTRPGTruthRoadSecondMain:OnDestroy() + XEventManager.RemoveEventListener(XEventId.EVENT_TRPG_GET_REWARD, self.OnCheckRedPoint, self) +end + +function XUiTRPGTruthRoadSecondMain:InitStagesMap() + local secondMainId = self.SecondMainId + local prefabName = XTRPGConfigs.GetSecondMainPrefab(secondMainId) + local prefab = self.PanelPrequelStages:LoadPrefab(prefabName) + if prefab == nil or not prefab:Exist() then + return + end + self.CurStages = XUiTRPGTruthRoadSecondMainStages.New(prefab, secondMainId, function(secondMainStageId) self:OpenEnterDialog(secondMainStageId) end, self.CurrSelectSecondMainStageId) + self.CurStages:SetParent(self.PanelPrequelStages) +end + +function XUiTRPGTruthRoadSecondMain:InitAutoScript() + self:AutoAddListener() +end + +function XUiTRPGTruthRoadSecondMain:AutoAddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:RegisterClickEvent(self.BtnTreasure, self.OnBtnTreasureClick) + self:RegisterClickEvent(self.BtnMask, self.OnBtnMaskClick) + self:RegisterClickEvent(self.BtnEnterStory, self.OnBtnEnterStoryClick) + self:RegisterClickEvent(self.BtnEnterFight, self.OnBtnEnterFightClick) +end + +function XUiTRPGTruthRoadSecondMain:OnBtnEnterStoryClick() + self:CloseEnterDialog() + local stageId = self.StageId + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(stageId) + if stageInfo.Passed then + XDataCenter.MovieManager.PlayMovie(stageCfg.BeginStoryId) + else + XDataCenter.FubenManager.FinishStoryRequest(stageId, function() + XDataCenter.TRPGManager.SetStagePass(stageId) + XDataCenter.MovieManager.PlayMovie(stageCfg.BeginStoryId, function() + self:Refresh() + end) + end) + end +end + +function XUiTRPGTruthRoadSecondMain:OnBtnEnterFightClick() + self:CloseEnterDialog() + XLuaUiManager.Open("UiNewRoomSingle", self.StageId) +end + +function XUiTRPGTruthRoadSecondMain:OnBtnMaskClick() + self:CloseEnterDialog() +end + +function XUiTRPGTruthRoadSecondMain:OnBtnBackClick() + self:Close() +end + +function XUiTRPGTruthRoadSecondMain:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiTRPGTruthRoadSecondMain:Refresh() + self:UpdateStagesMap() + self:UpdateProgress() +end + +function XUiTRPGTruthRoadSecondMain:UpdateStagesMap() + self.CurStages:UpdateStagesMap() +end + +function XUiTRPGTruthRoadSecondMain:UpdateProgress() + local secondMainId = self.SecondMainId + local rewardIdList = XTRPGConfigs.GetSecondMainStageRewardIdList(secondMainId) + if #rewardIdList > 0 then + local percent = XDataCenter.TRPGManager.GetSecondMainStagePercent(secondMainId) + self.TxtBfrtTaskTotalNum.text = math.floor(percent * 100) .. "%" + self.ImgJindu.fillAmount = percent + self:OnCheckRedPoint() + self.PanelBottom.gameObject:SetActiveEx(true) + else + self.PanelBottom.gameObject:SetActiveEx(false) + end +end + +--进度领奖 +function XUiTRPGTruthRoadSecondMain:OnBtnTreasureClick() + local secondMainId = self.SecondMainId + local rewardIdList = XTRPGConfigs.GetSecondMainStageRewardIdList(secondMainId) + XLuaUiManager.Open("UiTRPGRewardTip", rewardIdList, nil, secondMainId) +end + +function XUiTRPGTruthRoadSecondMain:OpenEnterDialog(secondMainStageId) + self:SetCurrSelectSecondMainStageId(secondMainStageId) + + local name = XTRPGConfigs.GetSecondMainStageName(secondMainStageId) + local desc = XTRPGConfigs.GetSecondMainStageDesc(secondMainStageId) + local dialogIcon = XTRPGConfigs.GetSecondMainStageDialogIcon(secondMainStageId) + local stageId = XTRPGConfigs.GetSecondMainStageStageId(secondMainStageId) + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + + if stageCfg.StageType == XFubenConfigs.STAGETYPE_FIGHT or stageCfg.StageType == XFubenConfigs.STAGETYPE_FIGHTEGG or stageCfg.StageType == XFubenConfigs.STAGETYPE_COMMON then + self.TxtFightName.text = name + self.TxtFightDec.text = desc + self.RImgFight:SetRawImage(dialogIcon) + self.PanelStory.gameObject:SetActiveEx(false) + self.PanelFight.gameObject:SetActiveEx(true) + else + self.TxtStoryName.text = name + self.TxtStoryDec.text = desc + self.RImgStory:SetRawImage(dialogIcon) + self.PanelStory.gameObject:SetActiveEx(true) + self.PanelFight.gameObject:SetActiveEx(false) + end + + self.StageId = stageId + self.PanelEnterDialog.gameObject:SetActiveEx(true) +end + +function XUiTRPGTruthRoadSecondMain:CloseEnterDialog() + self.PanelEnterDialog.gameObject:SetActiveEx(false) + self.CurStages:CancalSelectLastGrid() +end + +function XUiTRPGTruthRoadSecondMain:OnCheckRedPoint() + local secondMainId = self.SecondMainId + local isShowRedPoint = XDataCenter.TRPGManager.IsSecondMainCanReward(secondMainId) + self.ImgRedProgress.gameObject:SetActiveEx(isShowRedPoint) +end + +function XUiTRPGTruthRoadSecondMain:OnResume(data) + self:SetCurrSelectSecondMainStageId(data) +end + +function XUiTRPGTruthRoadSecondMain:OnReleaseInst() + return self.CurrSelectSecondMainStageId +end + +function XUiTRPGTruthRoadSecondMain:SetCurrSelectSecondMainStageId(currSelectSecondMainStageId) + self.CurrSelectSecondMainStageId = currSelectSecondMainStageId +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTRPG/XUiTRPGSecondMain/XUiTRPGTruthRoadSecondMainStage.lua b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGSecondMain/XUiTRPGTruthRoadSecondMainStage.lua new file mode 100644 index 00000000..6804b830 --- /dev/null +++ b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGSecondMain/XUiTRPGTruthRoadSecondMainStage.lua @@ -0,0 +1,44 @@ +local XUiTRPGTruthRoadSecondMainStage = XClass(nil, "XUiTRPGTruthRoadSecondMainStage") + +function XUiTRPGTruthRoadSecondMainStage:Ctor(ui, rootUi, secondMainStageId, clickCb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + self.RootUi = rootUi + self.SecondMainStageId = secondMainStageId + self.ClickCb = clickCb + CsXUiHelper.RegisterClickEvent(self.BtnStage, function() self:OnClickBtnClick() end) +end + +function XUiTRPGTruthRoadSecondMainStage:Refresh() + self:SetSelect(false) + local secondMainStageId = self:GetSecondMainStageId() + + if self.RImgFightActiveNor then + local icon = XTRPGConfigs.GetSecondMainStageIcon(secondMainStageId) + self.RImgFightActiveNor:SetRawImage(icon) + self.RImgFightActiveNor.gameObject:SetActiveEx(true) + end + + if self.TxtStageOrder then + local name = XTRPGConfigs.GetSecondMainStageName(secondMainStageId) + self.TxtStageOrder.text = name + end +end + +function XUiTRPGTruthRoadSecondMainStage:OnClickBtnClick() + if self.ClickCb then + self.ClickCb(self) + end +end + +function XUiTRPGTruthRoadSecondMainStage:SetSelect(isSelect) + self.ImageSelected.gameObject:SetActiveEx(isSelect) +end + +function XUiTRPGTruthRoadSecondMainStage:GetSecondMainStageId() + return self.SecondMainStageId +end + +return XUiTRPGTruthRoadSecondMainStage \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTRPG/XUiTRPGSecondMain/XUiTRPGTruthRoadSecondMainStages.lua b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGSecondMain/XUiTRPGTruthRoadSecondMainStages.lua new file mode 100644 index 00000000..e80b9aae --- /dev/null +++ b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGSecondMain/XUiTRPGTruthRoadSecondMainStages.lua @@ -0,0 +1,157 @@ +--常规主线的关卡格子 +local XUiTRPGTruthRoadSecondMainStage = require("XUi/XUiTRPG/XUiTRPGSecondMain/XUiTRPGTruthRoadSecondMainStage") + +local ipairs = ipairs +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate +local TWEE_DURATION +local MAX_STAGE_NUM = CS.XGame.ClientConfig:GetInt("TRPGTruthRoadStageMaxCount") + +local XUiTRPGTruthRoadSecondMainStages = XClass(nil, "XUiTRPGTruthRoadSecondMainStages") + +function XUiTRPGTruthRoadSecondMainStages:Ctor(ui, secondMainId, cb, currSelectSecondMainStageId) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + self.CurrSelectSecondMainStageId = currSelectSecondMainStageId + self.SecondMainId = secondMainId + self.CallBack = cb + self.MarkX = self.ViewPort.rect.width * 0.5 + self.InitPosX = self.PanelStageContent.localPosition.x + TWEE_DURATION = XDataCenter.FubenMainLineManager.UiGridChapterMoveDuration + self.LineList = {} + self.StageList = {} + + self:InitStagesMap() +end + +function XUiTRPGTruthRoadSecondMainStages:InitStagesMap() + for i = 1, MAX_STAGE_NUM do + if self["Stage" .. i] then + self.StageList[i] = self["Stage" .. i] + end + if self["Line" .. i - 1] then + self.LineList[i - 1] = self["Line" .. i - 1] + end + end + + self.LastSelectGrid = nil + local clickCb = function(grid) + grid:SetSelect(true) + self.LastSelectGrid = grid + self:PlayScrollViewMove(grid) + end + + self.GridStages = {} + local secondMainStageIdList = XTRPGConfigs.GetSecondMainStageId(self.SecondMainId) + local lastUnlockSecondMainStageId + local stageId + for i, secondMainStageId in ipairs(secondMainStageIdList) do + local stageParent = self["Stage" .. i] + if XTool.UObjIsNil(stageParent) then + XLog.Error(string.format("ui界面 %s 不存在 stage%s,检测TRPGSecondMain配置和该场景", self.GameObject.name, i)) + else + local prefabPath = XTRPGConfigs.GetSecondMainStagePrefabName(secondMainStageId) + local ui = stageParent:LoadPrefab(prefabPath) + self.GridStages[i] = XUiTRPGTruthRoadSecondMainStage.New(ui, self, secondMainStageId, clickCb) + + stageId = XTRPGConfigs.GetSecondMainStageStageId(secondMainStageId) + if XDataCenter.TRPGManager.IsStagePass(stageId) then + lastUnlockSecondMainStageId = secondMainStageId + end + end + end + + --自动滑动到当前列表中选择的关卡或已解锁的最后1个关卡 + local secondMainStageId + for _, v in ipairs(self.GridStages) do + secondMainStageId = v:GetSecondMainStageId() + if secondMainStageId == self.CurrSelectSecondMainStageId or secondMainStageId == lastUnlockSecondMainStageId then + self:PlayScrollViewMove(v, true) + return + end + end +end + +function XUiTRPGTruthRoadSecondMainStages:UpdateStagesMap() + self.GameObject:SetActiveEx(false) + for i, grid in ipairs(self.GridStages) do + grid:Refresh() + end + self:UpdateStagesActiveState() + self.GameObject:SetActiveEx(true) +end + +function XUiTRPGTruthRoadSecondMainStages:UpdateStagesActiveState() + for i = 1, MAX_STAGE_NUM do + self:SetStageActive(i, false) + self:SetLineActive(i - 1, false) + end + + local secondMainStageList = XTRPGConfigs.GetSecondMainStageId(self.SecondMainId) + local conditionIsFinish + + for i, secondMainStage in ipairs(secondMainStageList) do + conditionIsFinish = XDataCenter.TRPGManager.CheckSecondMainStageCondition(secondMainStage) + if self.GridStages[i] and conditionIsFinish then + self:SetStageActive(i, true) + self:SetLineActive(i - 1, true) + end + end +end + +function XUiTRPGTruthRoadSecondMainStages:SetStageActive(index, active) + local stage = self.StageList[index] + if stage then + stage.gameObject:SetActiveEx(active) + end +end + +function XUiTRPGTruthRoadSecondMainStages:SetLineActive(index, active) + local line = self.LineList[index] + if line then + line.gameObject:SetActive(active) + end +end + +function XUiTRPGTruthRoadSecondMainStages:PlayScrollViewMove(grid, ignoreAnim) + local gridX = grid.Transform.parent:GetComponent("RectTransform").localPosition.x + local contentPos = self.PanelStageContent.localPosition + local markX = self.MarkX + local diffX = gridX - markX + if diffX ~= 0 then + local targetPosX = self.InitPosX - diffX + local tarPos = contentPos + tarPos.x = targetPosX + + if not ignoreAnim then + XLuaUiManager.SetMask(true) + self.PaneStageList.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Unrestricted + XUiHelper.DoMove(self.PanelStageContent, tarPos, TWEE_DURATION, XUiHelper.EaseType.Sin, function() + XLuaUiManager.SetMask(false) + if self.CallBack and self.LastSelectGrid then + self.CallBack(self.LastSelectGrid:GetSecondMainStageId()) + end + end) + else + self.PanelStageContent.localPosition = tarPos + end + end +end + +function XUiTRPGTruthRoadSecondMainStages:SetActive(isActive) + self.GameObject:SetActiveEx(isActive) +end + +function XUiTRPGTruthRoadSecondMainStages:SetParent(parent) + self.Transform:SetParent(parent, false) +end + +function XUiTRPGTruthRoadSecondMainStages:CancalSelectLastGrid() + if self.LastSelectGrid then + self.LastSelectGrid:SetSelect(false) + end + self.PaneStageList.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Elastic +end + +return XUiTRPGTruthRoadSecondMainStages \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTRPG/XUiTRPGTalenTree.lua b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGTalenTree.lua new file mode 100644 index 00000000..35800b0f --- /dev/null +++ b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGTalenTree.lua @@ -0,0 +1,264 @@ +local XUiGridTRPGRoleTalent = require("XUi/XUiTRPG/XUiGridTRPGRoleTalent") + +local CSXTextManagerGetText = CS.XTextManager.GetText +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate +local ipairs = ipairs +local handler = handler + +local CONDITION_COLOR = { + [true] = XUiHelper.Hexcolor2Color("0F70BCFF"), + [false] = CS.UnityEngine.Color.red, +} + +local XUiTRPGTalenTree = XLuaUiManager.Register(XLuaUi, "UiTRPGTalenTree") + +function XUiTRPGTalenTree:RefreshData(roleId, notNext, notLast) + self.RoleId = roleId + self.NotNext = notNext + self.NotLast = notLast +end + +function XUiTRPGTalenTree:OnAwake() + self.BtnCloseDetail.gameObject:SetActiveEx(false) + self:AutoAddListener() +end + +function XUiTRPGTalenTree:OnStart(roleId, closeCb, showDetailCb, hideDetailCb, selectNextCb, selectLastCb, notNext, notLast) + self.RoleId = roleId + self.CloseCb = closeCb + self.ShowDetailCb = showDetailCb + self.HideDetailCb = hideDetailCb + self.SelectNextCb = selectNextCb + self.SelectLastCb = selectLastCb + self.NotNext = notNext + self.NotLast = notLast + self.TalentGrids = {} + + self:InitUi() +end + +function XUiTRPGTalenTree:OnEnable() + self:UpdateTalents() + self:UpdateTalentDetail() + self:UpdateSwitchBtns() +end + +function XUiTRPGTalenTree:OnDisable() + if self.CloseCb then + self.CloseCb() + end +end + +function XUiTRPGTalenTree:OnGetEvents() + return { XEventId.EVENT_TRPG_ROLES_DATA_CHANGE } +end + +function XUiTRPGTalenTree:OnNotify(evt, ...) + if evt == XEventId.EVENT_TRPG_ROLES_DATA_CHANGE then + self:UpdateTalents() + self:UpdateTalentDetail() + end +end + +function XUiTRPGTalenTree:InitUi() + local resetCostItemIcon = XTRPGConfigs.GetTalentResetCostItemIcon() + self.RImgCostItemIcon:SetRawImage(resetCostItemIcon) + + local resetCostCount = XTRPGConfigs.GetTalentResetCostItemCount() + self.TxtResetCostItemNum.text = resetCostCount + + local talentIcon = XTRPGConfigs.GetTalentPointIcon() + self.RImgTalentIcon:SetRawImage(talentIcon) + self.RImgCostTalentIcon:SetRawImage(talentIcon) + self.RImgAssetTalentIcon:SetRawImage(talentIcon) +end + +function XUiTRPGTalenTree:UpdateSwitchBtns() + self.BtnNext.gameObject:SetActiveEx(not self.NotNext) + self.BtnLast.gameObject:SetActiveEx(not self.NotLast) +end + +function XUiTRPGTalenTree:UpdateTalents() + local roleId = self.RoleId + + local usedTalent = XDataCenter.TRPGManager.GetRoleUsedTalentPoints(roleId) + self.TxtTalentCount.text = usedTalent + + local haveTalent = XDataCenter.TRPGManager.GetRoleHaveTalentPoints() + local maxTalentPoint = XDataCenter.TRPGManager.GetMaxTalentPoint() + self.TxtHaveTalentNum.text = CSXTextManagerGetText("TRPGTalent", haveTalent, maxTalentPoint) + self.TxtAssetHaveTalentNum.text = CSXTextManagerGetText("TRPGTalent", haveTalent, maxTalentPoint) + + local prefab = XTRPGConfigs.GetRoleTalentTreePrefab(roleId) + local parentUi = self.PanelTalentTree:LoadPrefab(prefab) + local tree = {} + XTool.InitUiObjectByUi(tree, parentUi) + + local talentIds = XDataCenter.TRPGManager.GetRoleTalentIds(roleId) + for index, talentId in ipairs(talentIds) do + local grid = self.TalentGrids[talentId] + if not grid then + local ui = index == 1 and self.GridStageTRPGTalent or CSUnityEngineObjectInstantiate(self.GridStageTRPGTalent) + local clickCb = handler(self, self.ShowUiDetail) + grid = XUiGridTRPGRoleTalent.New(ui, clickCb) + self.TalentGrids[talentId] = grid + end + + local gridParent = tree["talent" .. index] + grid.Transform:SetParent(gridParent, false) + + local isActive = XDataCenter.TRPGManager.IsRoleTalentActive(roleId, talentId) + local canActive = XDataCenter.TRPGManager.IsRoleTalentCanActive(roleId, talentId) + local showLine = isActive + local line = tree["line" .. index] + if line then + line.gameObject:SetActiveEx(showLine) + end + + grid:Refresh(roleId, talentId) + grid:SetSelect(talentId == self.TalentId) + grid.GameObject:SetActiveEx(true) + end +end + +function XUiTRPGTalenTree:UpdateTalentDetail() + local talentId = self.TalentId + if not talentId then return end + local roleId = self.RoleId + + self.TxtTalentDesc.text = XTRPGConfigs.GetRoleTalentDescription(roleId, talentId) + self.TxtTalentName.text = XTRPGConfigs.GetRoleTalentTitle(roleId, talentId) + self.TxtTalentInto.text = XTRPGConfigs.GetRoleTalentIntro(roleId, talentId) + + local costPoint = XDataCenter.TRPGManager.GetActiveTalentCostPoint(roleId, talentId) + self.TxtCostTalent.text = costPoint + + local isCostEnough = XDataCenter.TRPGManager.IsActiveTalentCostEnough(roleId, talentId) + self.TxtCostTalent.color = CONDITION_COLOR[isCostEnough] + + local isActive = XDataCenter.TRPGManager.IsRoleTalentActive(roleId, talentId) + self.PanelBottom.gameObject:SetActiveEx(not isActive) + + if self.RImgIconTalent then + local icon = XTRPGConfigs.GetRoleTalentIcon(roleId, talentId) + self.RImgIconTalent:SetRawImage(icon) + end +end + +function XUiTRPGTalenTree:AutoAddListener() + self:RegisterClickEvent(self.BtnBack, self.OnClickBtnBack) + self:RegisterClickEvent(self.BtnResetTalent, self.OnClickBtnResetTalent) + self:RegisterClickEvent(self.BtnActiveTalent, self.OnClickBtnActiveTalent) + self:RegisterClickEvent(self.BtnCloseDetail, self.OnClickBtnCloseDetail) + self:RegisterClickEvent(self.BtnNext, self.OnClickBtnNext) + self:RegisterClickEvent(self.BtnLast, self.OnClickBtnLast) + self:RegisterClickEvent(self.BtnRimgAssetTalentIcon, self.OnClickRimgTalentIcon) + self:RegisterClickEvent(self.BtnRimgDetailTalentIcon, self.OnClickRimgTalentIcon) +end + +function XUiTRPGTalenTree:OnClickBtnBack() + self:Close() +end + +function XUiTRPGTalenTree:OnClickBtnResetTalent() + local roleId = self.RoleId + local talentId = self.TalentId + + if not XDataCenter.TRPGManager.IsRoleAnyTalentActive(roleId) then + XUiManager.TipText("TRPGRoleTalentResetNotTalentActive") + return + end + + if not XDataCenter.TRPGManager.IsTalentResetCostEnough() then + XUiManager.TipText("TRPGRoleTalentResetCostLack") + return + end + + local costItemId = XTRPGConfigs.GetTalentResetCostItemId() + local costItemCount = XTRPGConfigs.GetTalentResetCostItemCount() + local itemName = XDataCenter.ItemManager.GetItemName(costItemId) + local title = CSXTextManagerGetText("TRPGExploreTalentResetTipsTitle") + local content = CSXTextManagerGetText("TRPGExploreTalentResetTipsContent", itemName, costItemCount) + local callFunc = function() + XDataCenter.TRPGManager.TRPGResetTalentRequest(roleId) + end + XUiManager.DialogTip(title, content, XUiManager.DialogType.Normal, nil, callFunc) +end + +function XUiTRPGTalenTree:OnClickBtnActiveTalent() + local roleId = self.RoleId + local talentId = self.TalentId + + if not XDataCenter.TRPGManager.IsRoleTalentCanActive(roleId, talentId) then + XUiManager.TipText("TRPGRoleTalentNeedPreTalentActive") + return + end + + if not XDataCenter.TRPGManager.IsActiveTalentCostEnough(roleId, talentId) then + XUiManager.TipText("TRPGRoleTalentActiveCostLack") + return + end + + local cb = function() + -- self:HideUiDetail()--他不要了 + end + XDataCenter.TRPGManager.TRPGActivateTalentRequest(roleId, talentId, cb) +end + +function XUiTRPGTalenTree:OnClickBtnCloseDetail() + self:HideUiDetail() +end + +function XUiTRPGTalenTree:OnClickBtnNext() + self.SelectNextCb() + + self:UpdateTalents() + self:UpdateTalentDetail() + self:UpdateSwitchBtns() +end + +function XUiTRPGTalenTree:OnClickBtnLast() + self.SelectLastCb() + + self:UpdateTalents() + self:UpdateTalentDetail() + self:UpdateSwitchBtns() +end + +function XUiTRPGTalenTree:OnClickRimgTalentIcon() + local data = XDataCenter.TRPGManager.GetTalentPointTipsData() + XLuaUiManager.Open("UiTip", data) +end + +function XUiTRPGTalenTree:ShowUiDetail(roleId, talentId) + self.TalentId = talentId + + self:UpdateTalentDetail() + + for paramTalentId, grid in pairs(self.TalentGrids) do + grid:SetSelect(talentId == paramTalentId) + end + + if self.ShowDetailCb then self.ShowDetailCb() end + + if not self.IsDetailShow then + self:PlayAnimationWithMask("PanelDetailEnable") + end + self.BtnCloseDetail.gameObject:SetActiveEx(true) + + self.IsDetailShow = true +end + +function XUiTRPGTalenTree:HideUiDetail() + if not self.IsDetailShow then return end + self.IsDetailShow = nil + + for _, grid in pairs(self.TalentGrids) do + grid:SetSelect(false) + end + + if self.HideDetailCb then self.HideDetailCb() end + + self:PlayAnimationWithMask("PanelDetailDisable") + self.BtnCloseDetail.gameObject:SetActiveEx(false) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTRPG/XUiTRPGTalentOverView.lua b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGTalentOverView.lua new file mode 100644 index 00000000..0fb432ea --- /dev/null +++ b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGTalentOverView.lua @@ -0,0 +1,53 @@ +local XUiGridTRPGRoleDetail = require("XUi/XUiTRPG/XUiGridTRPGRoleDetail") + +local CSXTextManagerGetText = CS.XTextManager.GetText +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate + +local XUiTRPGTalentOverView = XLuaUiManager.Register(XLuaUi, "UiTRPGTalentOverView") + +function XUiTRPGTalentOverView:OnAwake() + self:AutoAddListener() +end + +function XUiTRPGTalentOverView:OnStart() + self.RoleGrids = {} +end + +function XUiTRPGTalentOverView:OnEnable() + self:UpdateRoles() +end + +function XUiTRPGTalentOverView:UpdateRoles() + local roleIds = XDataCenter.TRPGManager.GetOwnRoleIds() + if XTool.IsTableEmpty(roleIds) then + XLog.Error("XUiTRPGTalentOverView:UpdateRoles error: 调查员数据不存在") + self:Close() + return + end + + for index, roleId in ipairs(roleIds) do + local grid = self.RoleGrids[index] + if not grid then + local ui = index == 1 and self.GridTreasureGrade or CSUnityEngineObjectInstantiate(self.GridTreasureGrade, self.PanelGradeContent) + grid = XUiGridTRPGRoleDetail.New(ui, self) + self.RoleGrids[index] = grid + end + grid:Refresh(roleId) + grid.GameObject:SetActiveEx(true) + end + + for index = #roleIds + 1, #self.RoleGrids do + local grid = self.RoleGrids[index] + if grid then + grid.GameObject:SetActiveEx(false) + end + end +end + +function XUiTRPGTalentOverView:AutoAddListener() + self:RegisterClickEvent(self.BtnMask, self.OnBtnBackClick) +end + +function XUiTRPGTalentOverView:OnBtnBackClick() + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTRPG/XUiTRPGTaskTip.lua b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGTaskTip.lua new file mode 100644 index 00000000..b084620c --- /dev/null +++ b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGTaskTip.lua @@ -0,0 +1,159 @@ +local XUiTRPGTaskTip = XLuaUiManager.Register(XLuaUi, "UiTRPGTaskTip") + +local CSXTextManagerGetText = CS.XTextManager.GetText +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate +local next = next +local tableInsert = table.insert + +local BTN_INDEX = { + First = 1, + Second = 2, +} + +function XUiTRPGTaskTip:OnAwake() + self:AutoAddListener() + XEventManager.AddEventListener(XEventId.EVENT_TRPG_UPDATE_TARGET, self.Refresh, self) +end + +function XUiTRPGTaskTip:OnStart() + self:UpdateLeftTabBtns() + self:InitSelect() +end + +function XUiTRPGTaskTip:OnEnable() + if self.SelectIndex then + self.PanelNoticeTitleBtnGroup:SelectIndex(self.SelectIndex) + end +end + +function XUiTRPGTaskTip:OnDestroy() + XEventManager.RemoveEventListener(XEventId.EVENT_TRPG_UPDATE_TARGET, self.Refresh, self) +end + +function XUiTRPGTaskTip:AutoAddListener() + self.BtnZhuizong.CallBack = function() self:OnBtnZhuizongClick() end + self:RegisterClickEvent(self.BtnTanchuangCloseBig, self.Close) +end + +function XUiTRPGTaskTip:InitSelect() + local currTargetLinkId = XDataCenter.TRPGManager.GetCurrTargetLinkId() + for btnIndex, targetTable in pairs(self.TabIndexDic) do + if currTargetLinkId == targetTable.TargetLinkId then + self.PanelNoticeTitleBtnGroup:SelectIndex(btnIndex) + return + end + end + self.PanelNoticeTitleBtnGroup:SelectIndex(1) +end + +function XUiTRPGTaskTip:Refresh() + local currTargetId = XDataCenter.TRPGManager.GetCurrTargetId() + local isCurrTarget = self.SelectTargetId == currTargetId + local targetLinkIsFinish = XDataCenter.TRPGManager.GetTargetLinkIsFinish(self.SelectTargetLinkId) + + self.TextName.text = targetLinkIsFinish and XTRPGConfigs.GetTargetLinkName(self.SelectTargetLinkId) or XTRPGConfigs.GetTargetName(self.SelectTargetId) + self.TextInfo.text = XTRPGConfigs.GetTargetDesc(self.SelectTargetId, self.SelectTargetLinkId) + + if self.PanelFinish then + self.PanelFinish.gameObject:SetActiveEx(targetLinkIsFinish) + end + + if targetLinkIsFinish then + self.BtnZhuizong.gameObject:SetActiveEx(false) + else + self.BtnZhuizong.gameObject:SetActiveEx(true) + self.BtnZhuizong:SetDisable(isCurrTarget, not isCurrTarget) + end + + --卡牌图标 + if self.ImgIcon then + local cardIconPath = XTRPGConfigs.GetTargetCardIcon(self.SelectTargetId) + if cardIconPath then + self:SetUiSprite(self.ImgIcon, cardIconPath) + self.ImgIcon.gameObject:SetActiveEx(true) + else + self.ImgIcon.gameObject:SetActiveEx(false) + end + end +end + +function XUiTRPGTaskTip:UpdateLeftTabBtns() + self.TabBtns = {} + self.TabIndexDic = {} + local btnIndex = 0 + local allCanFindTargetLink = XDataCenter.TRPGManager.GetAllCanFindTargetLink() + local btnModel + local btn + local uiButton + + for missionType, targetTableList in ipairs(allCanFindTargetLink) do + --一级标题 + btnModel = self:GetCertainBtnModel(BTN_INDEX.First, #targetTableList > 0) + btn = CSUnityEngineObjectInstantiate(btnModel) + btn.transform:SetParent(self.PanelNoticeTitleBtnGroup.transform, false) + btn.gameObject:SetActiveEx(true) + local name = XTRPGConfigs.GetTargetLinkMissionTypeName(missionType) + btn:SetName(name) + uiButton = btn:GetComponent("XUiButton") + tableInsert(self.TabBtns, uiButton) + btnIndex = btnIndex + 1 + + --二级标题 + local firstIndex = btnIndex + for i, targetTable in ipairs(targetTableList) do + btnModel = self:GetCertainBtnModel(BTN_INDEX.Second, true, i, #targetTableList) + btn = CSUnityEngineObjectInstantiate(btnModel) + btn.transform:SetParent(self.PanelNoticeTitleBtnGroup.transform, false) + btn.gameObject:SetActiveEx(true) + btn:SetName(XTRPGConfigs.GetTargetLinkName(targetTable.TargetLinkId)) + uiButton = btn:GetComponent("XUiButton") + uiButton.SubGroupIndex = firstIndex + tableInsert(self.TabBtns, uiButton) + btnIndex = btnIndex + 1 + self.TabIndexDic[btnIndex] = targetTable + end + end + self.PanelNoticeTitleBtnGroup:Init(self.TabBtns, function(index) self:OnSelectedTog(index) end) +end + +function XUiTRPGTaskTip:GetCertainBtnModel(index, hasChild, pos, totalNum) + if index == BTN_INDEX.First then + if hasChild then + return self.BtnFirstHasSnd + else + return self.BtnFirst + end + elseif index == BTN_INDEX.Second then + if totalNum == 1 then + return self.BtnSecondAll + end + + if pos == 1 then + return self.BtnSecondTop + elseif pos == totalNum then + return self.BtnSecondBottom + else + return self.BtnSecond + end + end +end + +function XUiTRPGTaskTip:OnSelectedTog(index) + if self.SelectIndex == index then return end + + self.SelectIndex = index + if self.TabIndexDic[index] then + self.SelectTargetId = self.TabIndexDic[index]["TargetId"] + self.SelectTargetLinkId = self.TabIndexDic[index]["TargetLinkId"] + else + --默认显示主线完成的标题和内容 + self.SelectTargetId = 0 + self.SelectTargetLinkId = 0 + end + + self:Refresh() +end + +function XUiTRPGTaskTip:OnBtnZhuizongClick() + XDataCenter.TRPGManager.RequestSelectTargetLinkSend(self.SelectTargetLinkId, false, true) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTRPG/XUiTRPGTest.lua b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGTest.lua new file mode 100644 index 00000000..3e415119 --- /dev/null +++ b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGTest.lua @@ -0,0 +1,471 @@ +local XUiGridTRPGTestItem = require("XUi/XUiTRPG/XUiGridTRPGTestItem") +local XUiGridTRPGTestRole = require("XUi/XUiTRPG/XUiGridTRPGTestRole") +local XUiGridTRPGRoleDetail = require("XUi/XUiTRPG/XUiGridTRPGRoleDetail") + +local CSXTextManagerGetText = CS.XTextManager.GetText +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate +local stringGsub = string.gsub +local Lerp = CS.UnityEngine.Mathf.Lerp +local mathFloor = math.floor +local tonumber = tonumber +local CSXScheduleManagerUnSchedule = XScheduleManager.UnSchedule +local CSXScheduleManagerScheduleOnce = XScheduleManager.ScheduleOnce + +local MAX_ROLE_NUM = 4 +local SCORE_ANIM_DURATION = 1 + +local XUiTRPGTest = XLuaUiManager.Register(XLuaUi, "UiTRPGTest") + +function XUiTRPGTest:OnAwake() + self:AutoAddListener() + self.GridChoose.gameObject:SetActiveEx(false) + self.GridRoleAttribute.gameObject:SetActiveEx(false) + self.GridTrackRole.gameObject:SetActiveEx(false) +end + +function XUiTRPGTest:OnStart(examineId) + self.SelectRoleIndex = 1 + self.RoleGrids = {} + self.TrackRoleGrids = {} + + self:InitUi() +end + +function XUiTRPGTest:OnEnable() + self:UpdateUi() +end + +function XUiTRPGTest:OnDisable() + self:DestroyTimer() + self:DestroyEffectTimer() +end + +function XUiTRPGTest:OnDestroy() + XDataCenter.TRPGManager.FinishExamine() +end + +function XUiTRPGTest:OnGetEvents() + return { + XEventId.EVENT_TRPG_EXAMINE_DATA_CHANGE + , XEventId.EVENT_TRPG_ROLES_DATA_CHANGE + , XEventId.EVENT_TRPG_EXAMINE_ROUND_CHANGE + , XEventId.EVENT_TRPG_EXAMINE_RESULT_SYN + } +end + +function XUiTRPGTest:OnNotify(evt, ...) + local args = { ... } + if evt == XEventId.EVENT_TRPG_EXAMINE_DATA_CHANGE then + self.SelectRoleIndex = self:GetNextRoleIndex() + self.NeedScoreChangeAnim = true + self:UpdateUi() + elseif evt == XEventId.EVENT_TRPG_ROLES_DATA_CHANGE then + self:UpdateTrackRoles() + elseif evt == XEventId.EVENT_TRPG_EXAMINE_ROUND_CHANGE then + self.SelectRoleIndex = 1 + self:UpdateUi() + elseif evt == XEventId.EVENT_TRPG_EXAMINE_RESULT_SYN then + self:UpdateUi() + end +end + +function XUiTRPGTest:GetNextRoleIndex() + local paramIndex = self.SelectRoleIndex + + for index, roleId in ipairs(self.RoleIds) do + if not XDataCenter.TRPGManager.IsExamineRoleAlreadyRolled(roleId) then + paramIndex = index + break + end + end + + return paramIndex +end + +function XUiTRPGTest:InitUi() + self.DynamicTable = XDynamicTableNormal.New(self.PanelChoose) + self.DynamicTable:SetDelegate(self) + self.DynamicTable:SetProxy(XUiGridTRPGTestItem) +end + +function XUiTRPGTest:UpdateUi() + local examineId = XDataCenter.TRPGManager.GetCurExamineId() + self.ExamineId = examineId + + local actionId = XDataCenter.TRPGManager.GetCurExamineActionId() + self.ActionId = actionId + + local icon = XTRPGConfigs.GetExamineActionIcon(actionId) + self.RImgAttributeIcon:SetRawImage(icon) + + local des = XTRPGConfigs.GetExamineActionTypeDesc(actionId) + self.TxtAttribute.text = des + + local desEn = XTRPGConfigs.GetExamineActionTypeDescEn(actionId) + self.TxtAttribute2.text = desEn + + local curScore, reqScore = XDataCenter.TRPGManager.GetCurExamineCurAndReqScore() + local fillAmount = reqScore == 0 and 1 or curScore / reqScore + local targetScore = curScore > reqScore and reqScore or curScore + if self.NeedScoreChangeAnim then + self:LetScoreRoll(targetScore, fillAmount) + else + self.TxtJdNumber.text = targetScore + self.ImgJd.fillAmount = fillAmount + end + self.TxtJd.text = "/" .. reqScore + + local isPassed = XDataCenter.TRPGManager.IsExaminePassed() + self.ImgJdSuc.gameObject:SetActiveEx(isPassed) + self.ImgJdFail.gameObject:SetActiveEx(not isPassed) + + local curRound = XDataCenter.TRPGManager.GetCurExamineCurRound() + local maxRound = XTRPGConfigs.GetExamineActionRound(actionId) + self.TxtRound.text = curRound .. "/" .. maxRound + + local resetItemId = XTRPGConfigs.GetExamineActionResetCostItemInfo(actionId) + local icon = XItemConfigs.GetItemIconById(resetItemId) + self.RImgIconResetItem:SetRawImage(icon) + local haveCount = XDataCenter.ItemManager.GetCount(resetItemId) + self.TxtResetItemNum.text = haveCount + local name = XItemConfigs.GetItemNameById(resetItemId) + self.TxtResetItemName.text = name + + if XDataCenter.TRPGManager.CheckExamineStatus(XTRPGConfigs.ExmaineStatus.Normal) then + self:UpdateNormalUi() + elseif XDataCenter.TRPGManager.CheckExamineStatus(XTRPGConfigs.ExmaineStatus.Suc) then + self:UpdateSucUi() + elseif XDataCenter.TRPGManager.CheckExamineStatus(XTRPGConfigs.ExmaineStatus.Fail) then + self:UpdateFailUi() + end +end + +function XUiTRPGTest:UpdateNormalUi() + local actionId = self.ActionId + self.ItemIds = XTRPGConfigs.GetExamineBuffItemIds(actionId) + + local defaultItemIndex = #self.ItemIds + local itemIndex = self.SelectItemIndex or defaultItemIndex + if itemIndex ~= defaultItemIndex then + local itemCount = XDataCenter.ItemManager.GetCount(self.ItemIds[itemIndex]) + if itemCount <= 0 then + itemIndex = defaultItemIndex + end + end + self.SelectItemIndex = itemIndex + + self.DynamicTable:SetDataSource(self.ItemIds) + self.DynamicTable:ReloadDataSync() + self:OnSelectItem(self.SelectItemIndex) + self:OnSelectRole(self.SelectRoleIndex) + + local showBtnNext = XDataCenter.TRPGManager.IsExamineCanEnterNextRound() + self.BtnNext:SetDisable(not showBtnNext) + + local isLastRound = XDataCenter.TRPGManager.IsExamineLastRound() + self.BtnNext.gameObject:SetActiveEx(not isLastRound) + self.BtnFinish.gameObject:SetActiveEx(isLastRound) + + self.PanelRight.gameObject:SetActiveEx(true) + self.PanelSuc.gameObject:SetActiveEx(false) + self.PanelFail.gameObject:SetActiveEx(false) + + self.NeedScoreChangeAnim = nil +end + +function XUiTRPGTest:UpdateSucUi() + local examineId = self.ExamineId + local actionId = self.ActionId + + local sucDesc = XTRPGConfigs.GetExamineSucDesc(examineId) + self.TxtDescribeSuc.text = sucDesc + + if XTRPGConfigs.CheckExamineActionType(actionId, XTRPGConfigs.TRPGExamineActionType.ConsumeItem) then + self.TxtRound.text = "0/0" + self.TxtJdNumber.text = 0 + self.TxtJd.text = "/0" + self.ImgJd.fillAmount = 1 + self.ImgJdSuc.gameObject:SetActiveEx(true) + self.ImgJdFail.gameObject:SetActiveEx(false) + end + + self.PanelRight.gameObject:SetActiveEx(false) + self.PanelSuc.gameObject:SetActiveEx(true) + self.PanelFail.gameObject:SetActiveEx(false) + + self:PlayAnimation("PanelSucEnable") +end + +function XUiTRPGTest:UpdateFailUi() + local punishId = XDataCenter.TRPGManager.GetCurExaminePunishId() + if punishId > 0 then + + if XTRPGConfigs.CheckPunishType(punishId, XTRPGConfigs.PunishType.DeBuff) then + self:UpdateTrackRoles() + end + local failDesc = XTRPGConfigs.GetPunishDesc(punishId) + self.TxtDescribeFail.text = failDesc + + else + + local examineId = self.ExamineId + local failDesc = XTRPGConfigs.GetExamineFailDesc(examineId) + self.TxtDescribeFail.text = failDesc + for _, grid in pairs(self.TrackRoleGrids) do + grid.GameObject:SetActiveEx(false) + end + + end + + self.PanelRight.gameObject:SetActiveEx(false) + self.PanelSuc.gameObject:SetActiveEx(false) + self.PanelFail.gameObject:SetActiveEx(true) + + self:PlayAnimation("PanelFailEnable") +end + +function XUiTRPGTest:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local actionId = self.ActionId + + local itemId = self.ItemIds[index] + grid:Refresh(itemId, actionId) + + local isSelect = index == self.SelectItemIndex + if isSelect then + self.LastSelectItemGrid = grid + grid:SetSelect(true) + else + grid:SetSelect(false) + end + + local clickCb = function() + local paramindex = index + + local itemId = self.ItemIds[index] + if not XTRPGConfigs.CheckDefaultEffectItemId(itemId) and XDataCenter.ItemManager.GetCount(itemId) <= 0 then + return + end + + if self.LastSelectItemGrid then + self.LastSelectItemGrid:SetSelect(false) + end + self.LastSelectItemGrid = grid + grid:SetSelect(true) + + self:OnSelectItem(index) + + self.NeedEffect = true + end + grid:InitClickCb(clickCb) + end +end + +function XUiTRPGTest:OnSelectItem(index) + self.SelectItemIndex = index + self:UpdateRoles() +end + +function XUiTRPGTest:UpdateRoles() + local actionId = self.ActionId + local totalMinValue, totalMaxValue = XDataCenter.TRPGManager.GetExamineActionTotalCallRollValue(actionId) + + local addAttribute = 0 + if self.SelectItemIndex then + local itemId = self.ItemIds[self.SelectItemIndex] + addAttribute = XTRPGConfigs.GetItemAddAttribute(itemId) + end + + local roleIds = XDataCenter.TRPGManager.GetOwnRoleIds() + self.RoleIds = roleIds + for index = 1, MAX_ROLE_NUM do + + local grid = self.RoleGrids[index] + if not grid then + local ui = index == 1 and self.GridRoleAttribute or CSUnityEngineObjectInstantiate(self.GridRoleAttribute, self.PanelRoleContent) + local clickCb = function() self:OnSelectRole(index) end + grid = XUiGridTRPGTestRole.New(ui, clickCb) + self.RoleGrids[index] = grid + end + + local roleId = roleIds[index] + if roleId then + grid:Refresh(roleId, actionId, addAttribute, self.NeedScoreChangeAnim, self.NeedEffect) + grid.GameObject:SetActiveEx(true) + grid:SetDisable(false) + else + grid.TxtDoubt.gameObject:SetActiveEx(false) + grid:SetDisable(true) + end + + end + + self.NeedEffect = nil +end + +function XUiTRPGTest:UpdateTrackRoles() + local roleIds = self.RoleIds + for index, roleId in ipairs(roleIds) do + local grid = self.TrackRoleGrids[index] + if not grid then + local ui = index == 1 and self.GridTrackRole or CSUnityEngineObjectInstantiate(self.GridTrackRole, self.PanelTrackContent) + grid = XUiGridTRPGRoleDetail.New(ui, self) + self.TrackRoleGrids[index] = grid + end + + local showBuffEffect = true + grid:Refresh(roleId, showBuffEffect) + grid.GameObject:SetActiveEx(true) + end + + for index = #roleIds + 1, #self.TrackRoleGrids do + local grid = self.TrackRoleGrids[index] + if grid then + grid.GameObject:SetActiveEx(false) + end + end +end + +function XUiTRPGTest:OnSelectRole(index) + if self.RoleGrids[index]:IsDisable() then + return + end + + self.SelectRoleIndex = index + + for index, grid in pairs(self.RoleGrids) do + grid:SetSelect(index == self.SelectRoleIndex) + end + + local roleId = self.SelectRoleIndex + local isRolled = XDataCenter.TRPGManager.IsExamineRoleAlreadyRolled(roleId) + self.BtnStart:SetDisable(isRolled) +end + +function XUiTRPGTest:AutoAddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnConfirm, self.OnClickBtnConfirm) + self:RegisterClickEvent(self.BtnFinish, self.OnClickBtnFinish) + self:RegisterClickEvent(self.BtnFail, self.OnClickBtnFail) + self:RegisterClickEvent(self.BtnNext, self.OnClickBtnNext) + self:RegisterClickEvent(self.BtnStart, self.OnClickBtnStart) + self:RegisterClickEvent(self.BtnResetItem, self.OnClickBtnResetItem) +end + +function XUiTRPGTest:OnBtnBackClick() + local examineId = self.ExamineId + + if XDataCenter.TRPGManager.CheckExamineStatus(XTRPGConfigs.ExmaineStatus.Normal) then + local title = CSXTextManagerGetText("TRPGExploreExmaineBackTipsTitle") + local content = CSXTextManagerGetText("TRPGExploreExmaineBackTipsContent") + content = stringGsub(content, "\\n", "\n") + local callFunc = function() + XDataCenter.TRPGManager.RequestExamineResult(examineId) + end + XUiManager.SystemDialogTip(title, content, XUiManager.DialogType.Normal, nil, callFunc) + else + XDataCenter.TRPGManager.EnterExaminePunish() + self:Close() + end +end + +function XUiTRPGTest:OnClickBtnConfirm() + self:Close() +end + +function XUiTRPGTest:OnClickBtnFail() + XDataCenter.TRPGManager.EnterExaminePunish() + XLuaUiManager.Remove("UiTRPGTest") +end + +function XUiTRPGTest:OnClickBtnFinish() + if not XDataCenter.TRPGManager.IsExamineCanEnterNextRound() then + XUiManager.TipText("TRPGExploreExmaineCantEnterNextRound") + return + end + + local examineId = self.ExamineId + XDataCenter.TRPGManager.RequestExamineResult(examineId) +end + +function XUiTRPGTest:OnClickBtnNext() + if not XDataCenter.TRPGManager.IsExamineCanEnterNextRound() then + XUiManager.TipText("TRPGExploreExmaineCantEnterNextRound") + return + end + + XDataCenter.TRPGManager.TRPGExamineChangeRoundRequest() + + self:PlayAnimation("PanelRightEnable") +end + +function XUiTRPGTest:OnClickBtnStart() + local roleId = self.SelectRoleIndex + if XDataCenter.TRPGManager.IsExamineRoleAlreadyRolled(roleId) then + XUiManager.TipText("TRPGExploreExmaineRoleAlreadyRolled") + return + end + + local examineId = self.ExamineId + local actionId = self.ActionId + local useItemId = self.SelectItemIndex and self.ItemIds[self.SelectItemIndex] + XDataCenter.TRPGManager.RequestExamineCharacterSend(examineId, actionId, roleId, useItemId) +end + +function XUiTRPGTest:OnClickBtnResetItem() + local actionId = self.ActionId + local resetItemId = XTRPGConfigs.GetExamineActionResetCostItemInfo(actionId) + -- XLuaUiManager.Open("UiTip", resetItemId)--UI层级不符,暂时不要 +end + +function XUiTRPGTest:LetScoreRoll(targetScore, targetFillAmount) + if not targetScore then return end + local startScore = tonumber(self.TxtJdNumber.text) or 0 + + local onRefreshFunc = function(time) + if XTool.UObjIsNil(self.TxtJdNumber) + or XTool.UObjIsNil(self.ImgJd) + then + self:DestroyTimer() + return true + end + + if startScore == targetScore then + return true + end + self.TxtJdNumber.text = mathFloor(Lerp(startScore, targetScore, time)) + + local startFillAmount = self.ImgJd.fillAmount + self.ImgJd.fillAmount = Lerp(startFillAmount, targetFillAmount, time) + + end + + XLuaUiManager.SetMask(true) + local finishCb = function() + XLuaUiManager.SetMask(false) + end + self:DestroyTimer() + self.Timer = XUiHelper.Tween(SCORE_ANIM_DURATION, onRefreshFunc, finishCb) + + self.Effect1.gameObject:SetActiveEx(true) + self:DestroyEffectTimer() + self.EffectTimer = CSXScheduleManagerScheduleOnce(function() + if XTool.UObjIsNil(self.Effect1.gameObject) then return end + self.Effect1.gameObject:SetActiveEx(false) + + end, SCORE_ANIM_DURATION * XScheduleManager.SECOND) +end + +function XUiTRPGTest:DestroyEffectTimer() + if self.EffectTimer then + CSXScheduleManagerUnSchedule(self.EffectTimer) + self.EffectTimer = nil + end +end + +function XUiTRPGTest:DestroyTimer() + if self.Timer then + CSXScheduleManagerUnSchedule(self.Timer) + self.Timer = nil + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTRPG/XUiTRPGTestDetailsTips.lua b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGTestDetailsTips.lua new file mode 100644 index 00000000..13cadf74 --- /dev/null +++ b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGTestDetailsTips.lua @@ -0,0 +1,173 @@ +local XUiGridTRPGTestAction = require("XUi/XUiTRPG/XUiGridTRPGTestAction") +local XUiGridTRPGRoleDetail = require("XUi/XUiTRPG/XUiGridTRPGRoleDetail") + +local CSXTextManagerGetText = CS.XTextManager.GetText +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate + +local CONDITION_COLOR = { + [true] = XUiHelper.Hexcolor2Color("0E70BDFF"), + [false] = CS.UnityEngine.Color.red, +} + +local XUiTRPGTestDetailsTips = XLuaUiManager.Register(XLuaUi, "UiTRPGTestDetailsTips") + +function XUiTRPGTestDetailsTips:OnAwake() + self:AutoAddListener() + self.GridExamine.gameObject:SetActiveEx(false) + self.GridExamineRole.gameObject:SetActiveEx(false) +end + +function XUiTRPGTestDetailsTips:OnStart(examineId) + self.ExamineId = examineId + self.SelectActionIndex = 1 + self.RoleGrids = {} + + self:InitUi() +end + +function XUiTRPGTestDetailsTips:OnEnable() + self:UpdateUi() +end + +function XUiTRPGTestDetailsTips:InitUi() + local examineId = self.ExamineId + + local costEndurance = XTRPGConfigs.GetExamineCostEndurance(examineId) + if costEndurance > 0 then + self.TxtTips.text = CSXTextManagerGetText("TRPGExploreExamineCostEnduranceTips", costEndurance) + self.TxtTips.gameObject:SetActiveEx(true) + else + self.TxtTips.gameObject:SetActiveEx(false) + end + + local desc = XTRPGConfigs.GetExamineDescription(examineId) + self.TxtDescribe.text = desc + + local title = XTRPGConfigs.GetExamineTitle(examineId) + if not string.IsNilOrEmpty(title) then + self.TxtTitle = self.Transform:FindTransformWithSplit("Tanchuang01/Text"):GetComponent("Text") + self.TxtTitle.text = title + end + + self.DynamicTable = XDynamicTableNormal.New(self.PanelTestList) + self.DynamicTable:SetDelegate(self) + self.DynamicTable:SetProxy(XUiGridTRPGTestAction) +end + +function XUiTRPGTestDetailsTips:UpdateUi() + local examineId = self.ExamineId + + local curEndurance = XDataCenter.TRPGManager.GetExploreCurEndurance() + local maxEndurance = XDataCenter.TRPGManager.GetExploreMaxEndurance() + self.TxtEndurance.text = CSXTextManagerGetText("TRPGExploreEnduranceValue", curEndurance, maxEndurance) + + self.ActionIds = XTRPGConfigs.GetExamineActionIds(examineId) + self.DynamicTable:SetDataSource(self.ActionIds) + self.DynamicTable:ReloadDataSync() + + self:OnSelectAction(self.SelectActionIndex) +end + +function XUiTRPGTestDetailsTips:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local actionId = self.ActionIds[index] + grid:Refresh(actionId) + + local isSelect = index == self.SelectActionIndex + if isSelect then + self.LastSelectActionGrid = grid + grid:SetSelect(true) + else + grid:SetSelect(false) + end + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + if self.LastSelectActionGrid then + self.LastSelectActionGrid:SetSelect(false) + end + self.LastSelectActionGrid = grid + grid:SetSelect(true) + + self:OnSelectAction(index) + end +end + +function XUiTRPGTestDetailsTips:OnSelectAction(index) + self.SelectActionIndex = index + self:UpdateCurAction() +end + +function XUiTRPGTestDetailsTips:UpdateCurAction() + local actionId = self.ActionIds[self.SelectActionIndex] + + if XTRPGConfigs.CheckExamineActionType(actionId, XTRPGConfigs.TRPGExamineActionType.ConsumeItem) then + local itemName = XTRPGConfigs.GetExamineActionItemName(actionId) + local tips = CSXTextManagerGetText("TRPGExploreExmaineCostItemTips", itemName) + self.TxtItemTips.text = tips + + self.TxtItemTips.gameObject:SetActiveEx(true) + self.PanelAttribute.gameObject:SetActiveEx(false) + else + local icon = XTRPGConfigs.GetExamineActionIcon(actionId) + self.RImgAttributeIcon:SetRawImage(icon) + + local rangeDesc = XTRPGConfigs.GetExamineActionTypeRangeDesc(actionId) + self.TxtRange.text = rangeDesc + + local rangeDesc = XTRPGConfigs.GetExamineActionTypeAttrDesc(actionId) + self.TxtAttrDesc.text = rangeDesc + + local totalMinValue, totalMaxValue = XDataCenter.TRPGManager.GetExamineActionTotalCallRollValue(actionId) + self.TxtNumber.text = totalMinValue .. "~" .. totalMaxValue + + local reqPoints = XTRPGConfigs.GetExamineActionNeedValue(actionId) + local passCondition = totalMaxValue >= reqPoints + self.TxtNumber.color = CONDITION_COLOR[passCondition] + + local roleIds = XDataCenter.TRPGManager.GetOwnRoleIds() + for index, roleId in ipairs(roleIds) do + local grid = self.RoleGrids[index] + if not grid then + local ui = index == 1 and self.GridExamineRole or CSUnityEngineObjectInstantiate(self.GridExamineRole, self.PanelRoleContent) + grid = XUiGridTRPGRoleDetail.New(ui, self) + self.RoleGrids[index] = grid + end + + grid:Refresh(roleId) + grid.GameObject:SetActiveEx(true) + end + + for index = #roleIds + 1, #self.RoleGrids do + local grid = self.RoleGrids[index] + if grid then + grid.GameObject:SetActiveEx(false) + end + end + + self.TxtItemTips.gameObject:SetActiveEx(false) + self.PanelAttribute.gameObject:SetActiveEx(true) + end +end + +function XUiTRPGTestDetailsTips:AutoAddListener() + self:RegisterClickEvent(self.BtnTanchuangCloseBig, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnConfirm, self.OnClickBtnConfirm) +end + +function XUiTRPGTestDetailsTips:OnBtnBackClick() + self:Close() + XDataCenter.MovieManager.StopMovie() +end + +function XUiTRPGTestDetailsTips:OnClickBtnConfirm() + local examineId = self.ExamineId + if not XDataCenter.TRPGManager.CheckExamineCostEnduranceEnough(examineId) then + XUiManager.TipText("TRPGExploreExmaineLackEndurance") + return + end + + local actionId = self.ActionIds[self.SelectActionIndex] + local cb = function() + self:Close() + end + XDataCenter.TRPGManager.RequestExamineSend(examineId, actionId, cb) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTRPG/XUiTRPGTruthRoad/XUiTRPGTruthRoadMain.lua b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGTruthRoad/XUiTRPGTruthRoadMain.lua new file mode 100644 index 00000000..2070c6b2 --- /dev/null +++ b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGTruthRoad/XUiTRPGTruthRoadMain.lua @@ -0,0 +1,301 @@ +local Object + +local XUiTRPGTruthRoadStages = require("XUi/XUiTRPG/XUiTRPGTruthRoad/XUiTRPGTruthRoadStages") + +--求真之路主界面 +local XUiTRPGTruthRoadMain = XLuaUiManager.Register(XLuaUi, "UiTRPGTruthRoadMain") + +function XUiTRPGTruthRoadMain:OnAwake() + XDataCenter.TRPGManager.SaveIsAlreadyOpenTruthRoad() + + self.TopTabBtns = {} + Object = CS.UnityEngine.Object + self.CurStages = nil + self.DialogId = 0 + self.CurrSelectTruthRoadId = nil --当前选择的求真之路id + + self:InitAutoScript() + + self.AssetActivityPanel = XUiPanelActivityAsset.New(self.PanelSpecialTool) + XDataCenter.ItemManager.AddCountUpdateListener(XDataCenter.ItemManager.ItemId.TRPGMoney, function() + self.AssetActivityPanel:Refresh({XDataCenter.ItemManager.ItemId.TRPGMoney}) + end, self.AssetActivityPanel) + self.AssetActivityPanel:Refresh({XDataCenter.ItemManager.ItemId.TRPGMoney}) + + XEventManager.AddEventListener(XEventId.EVENT_TRPG_GET_REWARD, self.OnCheckRedPoint, self) +end + +function XUiTRPGTruthRoadMain:OnStart(param) + local defaltBottomIndex = param[1] + self.BottomTabGroup:SelectIndex(defaltBottomIndex) + self:OnCheckRedPoint() +end + +function XUiTRPGTruthRoadMain:OnDestroy() + XEventManager.RemoveEventListener(XEventId.EVENT_TRPG_GET_REWARD, self.OnCheckRedPoint, self) +end + +function XUiTRPGTruthRoadMain:InitAutoScript() + self:InitTopTabGroup() + self:InitBottomTabGroup() + self:AutoAddListener() +end + +function XUiTRPGTruthRoadMain:AutoAddListener() + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnMainUi, self.OnBtnMainUiClick) + self:RegisterClickEvent(self.BtnTreasure, self.OnBtnTreasureClick) + self:BindHelpBtn(self.BtnActDesc, "TRPGMainLine") + self:RegisterClickEvent(self.BtnMask, self.OnBtnMaskClick) + self:RegisterClickEvent(self.BtnEnterStory, self.OnBtnEnterStoryClick) + self:RegisterClickEvent(self.BtnEnterFight, self.OnBtnEnterFightClick) +end + +function XUiTRPGTruthRoadMain:OnBtnEnterStoryClick() + self:CloseEnterDialog() + XDataCenter.MovieManager.PlayMovie(self.DialogId) +end + +function XUiTRPGTruthRoadMain:OnBtnEnterFightClick() + self:CloseEnterDialog() + XLuaUiManager.Open("UiNewRoomSingle", self.DialogId) +end + +function XUiTRPGTruthRoadMain:OnBtnMaskClick() + self:CloseEnterDialog() +end + +function XUiTRPGTruthRoadMain:OnBtnBackClick() + self:Close() +end + +function XUiTRPGTruthRoadMain:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +--初始化区域按钮组 +function XUiTRPGTruthRoadMain:InitBottomTabGroup() + self.BottomTabBtns = {} + local mainAreaMaxNum = XTRPGConfigs.GetMainAreaMaxNum() + local btnName, imagePath + local isOpen + for i = 1, mainAreaMaxNum do + if not self.BottomTabBtns[i] then + if i == 1 then + self.BottomTabBtns[i] = self.BtnPrequelPlotTab + else + local btn = Object.Instantiate(self.BtnPrequelPlotTab) + btn.transform:SetParent(self.BottomTabGroup.transform, false) + self.BottomTabBtns[i] = btn + end + end + btnName = XTRPGConfigs.GetMainAreaName(i) + imagePath = XTRPGConfigs.GetTruthRoadTabBg(i) + isOpen = XDataCenter.TRPGManager.IsTruthRoadOpenArea(i) + self.BottomTabBtns[i]:SetName(btnName) + self.BottomTabBtns[i]:ShowTag(false) + self.BottomTabBtns[i]:SetRawImage(imagePath) + self.BottomTabBtns[i]:SetDisable(not isOpen) + self.BottomTabBtns[i].gameObject:SetActiveEx(true) + end + + self.BottomTabGroup:Init(self.BottomTabBtns, function(groupIndex) self:BottomTabGroupSkip(groupIndex) end) +end + +function XUiTRPGTruthRoadMain:BottomTabGroupSkip(groupIndex) + if self.CurAreaId == groupIndex then + return + end + + local isOpen, topTapGroupIndex = XDataCenter.TRPGManager.IsTruthRoadOpenArea(groupIndex) + if not isOpen then + self.BottomTabGroup:SelectIndex(self.CurAreaId) + XUiManager.TipText("TRPGTruthRoadAreaNotOpen") + return + end + + self.CurAreaId = groupIndex + self.TxtName.text = XTRPGConfigs.GetMainAreaName(groupIndex) + self.EnName.text = XTRPGConfigs.GetMainAreaEnName(groupIndex) + local bgPath = XTRPGConfigs.GetTruthRoadBg(groupIndex) + self.RImgBg:SetRawImage(bgPath) + + self:RefreshTopTabGroup(topTapGroupIndex) + self:OnCheckTopTabRedPoint() + self:PlayAnimation("QieHuan2") +end + +--初始化任务按钮组 +function XUiTRPGTruthRoadMain:InitTopTabGroup() + local truthGroupMaxNum = XTRPGConfigs.GetTruthRoadGroupMaxNum() + for i = 1, truthGroupMaxNum do + if i == 1 then + self.TopTabBtns[i] = self.BtnTab01 + else + local btn = Object.Instantiate(self.BtnTab01) + btn.transform:SetParent(self.PanelTab.transform, false) + self.TopTabBtns[i] = btn + end + end + + self.TopTabButtonGroup = self.PanelTab:GetComponent("XUiButtonGroup") + self.TopTabButtonGroup:Init(self.TopTabBtns, function(groupIndex) self:TopTabGroupSkip(groupIndex) end) +end + +function XUiTRPGTruthRoadMain:RefreshTopTabGroup(topTapGroupIndex) + for _, v in ipairs(self.TopTabBtns) do + v.gameObject:SetActiveEx(false) + end + + local truthGroupIdList = XTRPGConfigs.GetTruthRoadGroupIdList(self.CurAreaId) + local tabName, tabSmallName + local isOpen + for i, truthGroupId in ipairs(truthGroupIdList) do + tabName = XTRPGConfigs.GetTruthRoadGroupName(truthGroupId) + tabSmallName = XTRPGConfigs.GetTruthRoadGroupSmallName(truthGroupId) + isOpen = XDataCenter.TRPGManager.IsTruthRoadGroupConditionFinish(self.CurAreaId, i) + self.TopTabBtns[i].gameObject:SetActiveEx(true) + self.TopTabBtns[i]:SetNameByGroup(0, tabName) + self.TopTabBtns[i]:SetNameByGroup(1, tabSmallName) + self.TopTabBtns[i]:SetDisable(not isOpen) + end + + if self.TopTabGroupIndex == topTapGroupIndex then + self:Refresh() + end + self.TopTabButtonGroup:SelectIndex(topTapGroupIndex) +end + +function XUiTRPGTruthRoadMain:TopTabGroupSkip(groupIndex) + if self.TopTabGroupIndex == groupIndex then + return + end + + local ret, desc = XDataCenter.TRPGManager.IsTruthRoadGroupConditionFinish(self.CurAreaId, groupIndex) + if not ret then + self.TopTabButtonGroup:SelectIndex(self.TopTabGroupIndex) + XUiManager.TipMsg(desc) + return + end + + self.TopTabGroupIndex = groupIndex + self:Refresh() + self:PlayAnimation("QieHuan1") +end + +function XUiTRPGTruthRoadMain:Refresh() + self:UpdateStagesMap() + self:UpdateProgress() +end + +function XUiTRPGTruthRoadMain:UpdateStagesMap() + local truthRoadGroupId = XTRPGConfigs.GetTruthRoadGroupId(self.CurAreaId, self.TopTabGroupIndex) + if truthRoadGroupId ~= self.TruthRoadGroupId then + local prefabName = XTRPGConfigs.GetTruthRoadGroupPrefab(truthRoadGroupId) + local prefab = self.PanelPrequelStages:LoadPrefab(prefabName) + if prefab == nil or not prefab:Exist() then + return + end + self.TruthRoadGroupId = truthRoadGroupId + self.CurStages = XUiTRPGTruthRoadStages.New(prefab, truthRoadGroupId, function(truthRoadId) self:OpenEnterDialog(truthRoadId) end, self.CurrSelectTruthRoadId) + self.CurStages:SetParent(self.PanelPrequelStages) + end + self.CurStages:UpdateStagesMap() +end + +function XUiTRPGTruthRoadMain:UpdateProgress() + local rewardIdList = XTRPGConfigs.GetTruthRoadRewardIdList(self.TruthRoadGroupId) + if #rewardIdList > 0 then + local percent = XDataCenter.TRPGManager.GetTruthRoadPercent(self.TruthRoadGroupId) + self.TxtBfrtTaskTotalNum.text = math.floor(percent * 100) .. "%" + self.ImgJindu.fillAmount = percent + self:OnCheckPanelBottomRedPoint() + self.PanelBottom.gameObject:SetActiveEx(true) + else + self.PanelBottom.gameObject:SetActiveEx(false) + end +end + +--进度领奖 +function XUiTRPGTruthRoadMain:OnBtnTreasureClick() + local rewardIdList = XTRPGConfigs.GetTruthRoadRewardIdList(self.TruthRoadGroupId) + XLuaUiManager.Open("UiTRPGRewardTip", rewardIdList, self.TruthRoadGroupId) +end + +function XUiTRPGTruthRoadMain:OpenEnterDialog(truthRoadId) + self:SetCurrSelectTruthRoadId(truthRoadId) + + local name = XTRPGConfigs.GetTruthRoadName(truthRoadId) + local icon = XTRPGConfigs.GetTruthRoadIcon(truthRoadId) + local desc = XTRPGConfigs.GetTruthRoadDesc(truthRoadId) + local dialogIcon = XTRPGConfigs.GetTruthRoadDialogIcon(truthRoadId) + local stageId = XTRPGConfigs.GetTruthRoadStageId(truthRoadId) + if stageId and stageId > 0 then + self.DialogId = stageId + self.TxtFightName.text = name + self.TxtFightDec.text = desc + self.RImgFight:SetRawImage(dialogIcon) + self.PanelStory.gameObject:SetActiveEx(false) + self.PanelFight.gameObject:SetActiveEx(true) + else + self.DialogId = XTRPGConfigs.GetTruthRoadStoryId(truthRoadId) + self.TxtStoryName.text = name + self.TxtStoryDec.text = desc + self.RImgStory:SetRawImage(dialogIcon) + self.PanelStory.gameObject:SetActiveEx(true) + self.PanelFight.gameObject:SetActiveEx(false) + end + + self.PanelEnterDialog.gameObject:SetActiveEx(true) +end + +function XUiTRPGTruthRoadMain:CloseEnterDialog() + self.PanelEnterDialog.gameObject:SetActiveEx(false) + self.CurStages:CancalSelectLastGrid() +end + +--下面区域按钮红点 +function XUiTRPGTruthRoadMain:OnCheckBottomTabRedPoint() + local isShowRedPoint + for areaId, bottomTabBtn in ipairs(self.BottomTabBtns) do + isShowRedPoint = XDataCenter.TRPGManager.CheckTruthRoadAreaReward(areaId) + bottomTabBtn:ShowReddot(isShowRedPoint) + end +end + +--上面任务按钮红点 +function XUiTRPGTruthRoadMain:OnCheckTopTabRedPoint() + local truthGroupIdList = XTRPGConfigs.GetTruthRoadGroupIdList(self.CurAreaId) + local isShowRedPoint + for i, truthGroupId in ipairs(truthGroupIdList) do + if self.TopTabBtns[i] then + isShowRedPoint = XDataCenter.TRPGManager.CheckTruthRoadReward(truthGroupId) + self.TopTabBtns[i]:ShowReddot(isShowRedPoint) + end + end +end + +--区域进度红点 +function XUiTRPGTruthRoadMain:OnCheckPanelBottomRedPoint() + local truthGroupId = XTRPGConfigs.GetTruthRoadGroupId(self.CurAreaId, self.TopTabGroupIndex) + local isShowRedPoint = XDataCenter.TRPGManager.CheckTruthRoadReward(truthGroupId) + self.ImgRedProgress.gameObject:SetActiveEx(isShowRedPoint) +end + +function XUiTRPGTruthRoadMain:OnCheckRedPoint() + self:OnCheckPanelBottomRedPoint() + self:OnCheckBottomTabRedPoint() + self:OnCheckTopTabRedPoint() +end + +function XUiTRPGTruthRoadMain:OnResume(data) + self:SetCurrSelectTruthRoadId(data) +end + +function XUiTRPGTruthRoadMain:OnReleaseInst() + return self.CurrSelectTruthRoadId +end + +function XUiTRPGTruthRoadMain:SetCurrSelectTruthRoadId(currSelectTruthRoadId) + self.CurrSelectTruthRoadId = currSelectTruthRoadId +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTRPG/XUiTRPGTruthRoad/XUiTRPGTruthRoadStage.lua b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGTruthRoad/XUiTRPGTruthRoadStage.lua new file mode 100644 index 00000000..2371f073 --- /dev/null +++ b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGTruthRoad/XUiTRPGTruthRoadStage.lua @@ -0,0 +1,44 @@ +local XUiTRPGTruthRoadStage = XClass(nil, "XUiTRPGTruthRoadStage") + +function XUiTRPGTruthRoadStage:Ctor(ui, rootUi, truthRoadGroupId, truthRoadId, clickCb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + self.RootUi = rootUi + self.TruthRoadGroupId = truthRoadGroupId + self.TruthRoadId = truthRoadId + self.ClickCb = clickCb + CsXUiHelper.RegisterClickEvent(self.BtnStage, function() self:OnClickBtnClick() end) +end + +function XUiTRPGTruthRoadStage:Refresh() + self:SetSelect(false) + + if self.RImgFightActiveNor then + local icon = XTRPGConfigs.GetTruthRoadIcon(self.TruthRoadId) + self.RImgFightActiveNor:SetRawImage(icon) + self.RImgFightActiveNor.gameObject:SetActiveEx(true) + end + + if self.TxtStageOrder then + local name = XTRPGConfigs.GetTruthRoadName(self.TruthRoadId) + self.TxtStageOrder.text = name + end +end + +function XUiTRPGTruthRoadStage:OnClickBtnClick() + if self.ClickCb then + self.ClickCb(self) + end +end + +function XUiTRPGTruthRoadStage:SetSelect(isSelect) + self.ImageSelected.gameObject:SetActiveEx(isSelect) +end + +function XUiTRPGTruthRoadStage:GetTruthRoadId() + return self.TruthRoadId +end + +return XUiTRPGTruthRoadStage \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTRPG/XUiTRPGTruthRoad/XUiTRPGTruthRoadStages.lua b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGTruthRoad/XUiTRPGTruthRoadStages.lua new file mode 100644 index 00000000..eecf8ecd --- /dev/null +++ b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGTruthRoad/XUiTRPGTruthRoadStages.lua @@ -0,0 +1,160 @@ +local XUiTRPGTruthRoadStage = require("XUi/XUiTRPG/XUiTRPGTruthRoad/XUiTRPGTruthRoadStage") + +local ipairs = ipairs +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate +local TWEE_DURATION +local MAX_STAGE_NUM = CS.XGame.ClientConfig:GetInt("TRPGTruthRoadStageMaxCount") + +local XUiTRPGTruthRoadStages = XClass(nil, "XUiTRPGTruthRoadStages") + +function XUiTRPGTruthRoadStages:Ctor(ui, truthRoadGroupId, cb, currSelectTruthRoadId) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + self.CurrSelectTruthRoadId = currSelectTruthRoadId + self.TruthRoadGroupId = truthRoadGroupId + self.CallBack = cb + self.MarkX = self.ViewPort.rect.width * 0.6 + self.InitPosX = -960 --self.PanelStageContent.localPosition.x + TWEE_DURATION = XDataCenter.FubenMainLineManager.UiGridChapterMoveDuration + self.LineList = {} + self.StageList = {} + + self:InitStagesMap() +end + +function XUiTRPGTruthRoadStages:InitStagesMap() + for i = 1, MAX_STAGE_NUM do + if self["Stage" .. i] then + self.StageList[i] = self["Stage" .. i] + end + if self["Line" .. i - 1] then + self.LineList[i - 1] = self["Line" .. i - 1] + end + end + + self.LastSelectGrid = nil + local clickCb = function(grid) + grid:SetSelect(true) + self.LastSelectGrid = grid + self:PlayScrollViewMove(grid) + end + + self.GridStages = {} + local truthRoadIdList = XTRPGConfigs.GetTruthRoadIdList(self.TruthRoadGroupId) + local lastUnlockTruthRoadId + local condition + local conditionIsFinish + for i, truthRoadId in ipairs(truthRoadIdList) do + local stageParent = self["Stage" .. i] + if XTool.UObjIsNil(stageParent) then + XLog.Error("ui界面 stage" .. i .. "不存在,检测TRPGTruthRoadGroup配置") + else + local prefabPath = XTRPGConfigs.GetTruthRoadPrafabName(truthRoadId) + local ui = stageParent:LoadPrefab(prefabPath) + self.GridStages[i] = XUiTRPGTruthRoadStage.New(ui, self, self.TruthRoadGroupId, truthRoadId, clickCb) + + condition = XTRPGConfigs.GetTruthRoadCondition(truthRoadId) + conditionIsFinish = XConditionManager.CheckCondition(condition) + if conditionIsFinish then + lastUnlockTruthRoadId = truthRoadId + end + end + end + + --自动滑动到当前列表中选择的关卡或已解锁的最后1个关卡 + local truthRoadId + for _, v in ipairs(self.GridStages) do + truthRoadId = v:GetTruthRoadId() + if truthRoadId == self.CurrSelectTruthRoadId or truthRoadId == lastUnlockTruthRoadId then + self:PlayScrollViewMove(v, true) + return + end + end +end + +function XUiTRPGTruthRoadStages:UpdateStagesMap() + self.GameObject:SetActiveEx(false) + for i, grid in ipairs(self.GridStages) do + grid:Refresh() + end + self:UpdateStagesActiveState() + self.GameObject:SetActiveEx(true) +end + +function XUiTRPGTruthRoadStages:UpdateStagesActiveState() + for i = 1, MAX_STAGE_NUM do + self:SetStageActive(i, false) + self:SetLineActive(i - 1, false) + end + + local truthRoadIdList = XTRPGConfigs.GetTruthRoadIdList(self.TruthRoadGroupId) + local condition + local conditionIsFinish + + for i, truthRoadId in ipairs(truthRoadIdList) do + condition = XTRPGConfigs.GetTruthRoadCondition(truthRoadId) + conditionIsFinish = XConditionManager.CheckCondition(condition) + if self.GridStages[i] and conditionIsFinish then + self:SetStageActive(i, true) + self:SetLineActive(i - 1, true) + end + end +end + +function XUiTRPGTruthRoadStages:SetStageActive(index, active) + local stage = self.StageList[index] + if stage then + stage.gameObject:SetActiveEx(active) + end +end + +function XUiTRPGTruthRoadStages:SetLineActive(index, active) + local line = self.LineList[index] + if line then + line.gameObject:SetActive(active) + end +end + +function XUiTRPGTruthRoadStages:PlayScrollViewMove(grid, ignoreAnim) + local gridX = grid.Transform.parent:GetComponent("RectTransform").localPosition.x + local contentPos = self.PanelStageContent.localPosition + local markX = self.MarkX + local diffX = gridX - markX + if diffX ~= 0 then + local targetPosX = self.InitPosX - diffX + local tarPos = contentPos + tarPos.x = targetPosX + + if not ignoreAnim then + XLuaUiManager.SetMask(true) + self.PaneStageList.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Unrestricted + XUiHelper.DoMove(self.PanelStageContent, tarPos, TWEE_DURATION, XUiHelper.EaseType.Sin, function() + XLuaUiManager.SetMask(false) + if self.CallBack and self.LastSelectGrid then + self.CallBack(self.LastSelectGrid:GetTruthRoadId()) + end + end) + else + self.PanelStageContent.localPosition = tarPos + end + end +end + +function XUiTRPGTruthRoadStages:SetActive(isActive) + self.GameObject:SetActiveEx(isActive) +end + +function XUiTRPGTruthRoadStages:SetParent(parent) + self.Transform:SetParent(parent, false) +end + +function XUiTRPGTruthRoadStages:CancalSelectLastGrid() + if self.LastSelectGrid then + self.LastSelectGrid:SetSelect(false) + end + self.PaneStageList.movementType = CS.UnityEngine.UI.ScrollRect.MovementType.Elastic +end + +return XUiTRPGTruthRoadStages \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTRPG/XUiTRPGWorldBoss/XUiTRPGGridBossReward.lua b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGWorldBoss/XUiTRPGGridBossReward.lua new file mode 100644 index 00000000..b7a8cf0c --- /dev/null +++ b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGWorldBoss/XUiTRPGGridBossReward.lua @@ -0,0 +1,60 @@ +local XUiTRPGGridBossReward = XClass(nil, "XUiTRPGGridBossReward") +local CSTextManagerGetText = CS.XTextManager.GetText +function XUiTRPGGridBossReward:Ctor(ui, updatePanelPhasesRewardCb, id) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UpdatePanelPhasesRewardCb = updatePanelPhasesRewardCb + self.Id = id + XTool.InitUiObject(self) + + self:Init() + self:SetButtonCallBack() +end + +function XUiTRPGGridBossReward:Init() + local icon = XTRPGConfigs.GetBossIcon(self.Id) + self.ImgActive:SetRawImage(icon) +end + +function XUiTRPGGridBossReward:SetButtonCallBack() + self.BtnActive.CallBack = function() + self:OnBtnActiveClick() + end +end + +function XUiTRPGGridBossReward:OnBtnActiveClick() + local rewardId = XTRPGConfigs.GetBossPhasesRewardId(self.Id) + local isAleardyReceive = XDataCenter.TRPGManager.IsWorldBossAleardyReceiveReward(self.Id) + local isCanReceive = XDataCenter.TRPGManager.IsWorldBossCanReceiveReward(self.Id) + local rewardData = XRewardManager.GetRewardList(rewardId) + + if isCanReceive then + if isAleardyReceive then + return + end + XDataCenter.TRPGManager.RequestTRPGBossPhasesRewardSend(self.Id, function() + if self.UpdatePanelPhasesRewardCb then + self.UpdatePanelPhasesRewardCb() + end + end) + else + XUiManager.OpenUiTipReward(rewardData, CSTextManagerGetText("DailyActiveRewardTitle")) + end +end + +function XUiTRPGGridBossReward:UpdateData() + local isAleardyReceive = XDataCenter.TRPGManager.IsWorldBossAleardyReceiveReward(self.Id) + local isCanReceive = XDataCenter.TRPGManager.IsWorldBossCanReceiveReward(self.Id) + if isCanReceive then + self.PanelEffect.gameObject:SetActiveEx(not isAleardyReceive) + self.ImgRe.gameObject:SetActiveEx(isAleardyReceive) + else + self.PanelEffect.gameObject:SetActiveEx(false) + self.ImgRe.gameObject:SetActiveEx(false) + end + + local hpPercent = XTRPGConfigs.GetBossPhasesRewardPercent(self.Id) + self.ScheduleCount.text = string.format("%d%s", hpPercent, "%") +end + +return XUiTRPGGridBossReward \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTRPG/XUiTRPGWorldBoss/XUiTRPGPanelDetail.lua b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGWorldBoss/XUiTRPGPanelDetail.lua new file mode 100644 index 00000000..8e03178a --- /dev/null +++ b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGWorldBoss/XUiTRPGPanelDetail.lua @@ -0,0 +1,78 @@ +local XUiTRPGPanelDetail = XClass(nil, "XUiTRPGPanelDetail") +local CSTextManagerGetText = CS.XTextManager.GetText + +function XUiTRPGPanelDetail:Ctor(ui, base) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Base = base + XTool.InitUiObject(self) + + self:SetButtonCallBack() + self:SetActivityInfo() +end + +function XUiTRPGPanelDetail:SetButtonCallBack() + self.BtnBoss.CallBack = function() + self:OnBtnBossClick() + end +end + +function XUiTRPGPanelDetail:UpdateActivityInfo() + local challengeCount = XDataCenter.TRPGManager.GetWorldBossChallengeCount() + local maxChallengeCount = XTRPGConfigs.GetBossChallengeCount() + self.ChallengeText.text = CSTextManagerGetText("WorldBossBossChallengeText") + self.ChallengeCount.text = string.format("%d/%d", maxChallengeCount - challengeCount, maxChallengeCount) +end + +function XUiTRPGPanelDetail:SetActivityInfo() + local desc = XTRPGConfigs.GetBossDesc() + self.TxtDesc.text = desc + + self.GridRewardList = {} + self.GridCommon.gameObject:SetActiveEx(false) + self:UpdateRewardList() +end + +function XUiTRPGPanelDetail:UpdateRewardList() + local stageId = XTRPGConfigs.GetBossStageId() + local stageCfg = XDataCenter.FubenManager.GetStageCfg(stageId) + local rewardId = stageCfg.FinishRewardShow + local rewards = XRewardManager.GetRewardList(rewardId) + + for _, grid in pairs(self.GridRewardList) do + grid.GameObject:SetActiveEx(false) + end + + if rewards then + for index, item in pairs(rewards) do + if not self.GridRewardList[index] then + local obj = CS.UnityEngine.Object.Instantiate(self.GridCommon, self.PanelDropContent) + local grid = XUiGridCommon.New(self.Base, obj) + grid:Refresh(item) + grid.GameObject:SetActive(true) + self.GridRewardList[index] = grid + else + self.GridRewardList[index]:Refresh(item) + self.GridRewardList[index].GameObject:SetActive(true) + end + end + end +end + +function XUiTRPGPanelDetail:OnBtnBossClick() + local challengeCount = XDataCenter.TRPGManager.GetWorldBossChallengeCount() + local maxChallengeCount = XTRPGConfigs.GetBossChallengeCount() + if maxChallengeCount - challengeCount == 0 then + XUiManager.TipText("WorldBossNoChallengeCount") + return + end + + local stageId = XTRPGConfigs.GetBossStageId() + XLuaUiManager.Open("UiNewRoomSingle", stageId) +end + +function XUiTRPGPanelDetail:SetShow(IsShow) + self.GameObject:SetActiveEx(IsShow) +end + +return XUiTRPGPanelDetail \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTRPG/XUiTRPGWorldBoss/XUiTRPGPanelEnter.lua b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGWorldBoss/XUiTRPGPanelEnter.lua new file mode 100644 index 00000000..9e747840 --- /dev/null +++ b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGWorldBoss/XUiTRPGPanelEnter.lua @@ -0,0 +1,87 @@ +local XUiTRPGPanelEnter = XClass(nil, "XUiTRPGPanelEnter") +local XUiTRPGGridBossReward = require("XUi/XUiTRPG/XUiTRPGWorldBoss/XUiTRPGGridBossReward") +local CSTextManagerGetText = CS.XTextManager.GetText +local PanelState = { + Enter = 1, + Detail = 2 +} + +function XUiTRPGPanelEnter:Ctor(ui, setPanelStateCb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.SetPanelStateCb = setPanelStateCb + XTool.InitUiObject(self) + self:SetButtonCallBack() + self:SetPanelTime() + self:InitPhasesRewardGrid() +end + +function XUiTRPGPanelEnter:SetButtonCallBack() + self.BtnBoss.CallBack = function() + self:OnBtnBossClick() + end + self.BtnTalent.CallBack = function() + self:OnBtnTalentClick() + end +end + +function XUiTRPGPanelEnter:OnBtnBossClick() + if self.SetPanelStateCb then + self.SetPanelStateCb(PanelState.Detail) + end +end + +function XUiTRPGPanelEnter:OnBtnTalentClick() + XLuaUiManager.Open("UiTRPGTalentOverView") +end + +function XUiTRPGPanelEnter:SetPanelTime() + local openState, time = XDataCenter.TRPGManager.GetWorldBossOpenState() + self.TimeText.text = XUiHelper.GetTime(time, XUiHelper.TimeFormatType.ACTIVITY) +end + +function XUiTRPGPanelEnter:InitPhasesRewardGrid() + local UpdatePanelPhasesRewardCb = function() + self:UpdatePanelPhasesReward() + end + + self.PhasesRewardGrids = {} + self.PhasesRewardGridRects = {} + self.RewardItem.gameObject:SetActiveEx(false) + local rewardCount = XTRPGConfigs.GetBossPhasesRewardMaxNum() + for i = 1, rewardCount do + local grid = self.PhasesRewardGrids[i] + if not grid then + local obj = CS.UnityEngine.Object.Instantiate(self.RewardItem) + obj.gameObject:SetActiveEx(true) + obj.transform:SetParent(self.PanelReward, false) + grid = XUiTRPGGridBossReward.New(obj, UpdatePanelPhasesRewardCb, i) + self.PhasesRewardGrids[i] = grid + self.PhasesRewardGridRects[i] = grid.Transform:GetComponent("RectTransform") + end + end +end + +function XUiTRPGPanelEnter:UpdatePanelPhasesReward() + local percent = XDataCenter.TRPGManager.GetWorldBossCurHpPercer() + self.ScheduleImg.fillAmount = percent + self.TxtDailyActive.text = string.format("%d%s", math.ceil(percent * 100), "%") + self.ScheduleText.text = CSTextManagerGetText("WorldBossBossAreaSchedule") + + -- 自适应 + local activeProgressRectSize = self.PanelReward.rect.size + for i = 1, #self.PhasesRewardGrids do + local rewardPercent = XTRPGConfigs.GetBossPhasesRewardPercent(i) + local valOffset = 1 - rewardPercent * 0.01 + local adjustPosition = CS.UnityEngine.Vector3(activeProgressRectSize.x * valOffset - activeProgressRectSize.x / 2, 0, 0) + self.PhasesRewardGridRects[i].anchoredPosition3D = adjustPosition + + self.PhasesRewardGrids[i]:UpdateData() + end +end + +function XUiTRPGPanelEnter:SetShow(IsShow) + self.GameObject:SetActiveEx(IsShow) +end + +return XUiTRPGPanelEnter \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTRPG/XUiTRPGWorldBoss/XUiTRPGWinWorldBoss.lua b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGWorldBoss/XUiTRPGWinWorldBoss.lua new file mode 100644 index 00000000..a5c18b33 --- /dev/null +++ b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGWorldBoss/XUiTRPGWinWorldBoss.lua @@ -0,0 +1,110 @@ +local XUiTRPGWinWorldBoss = XLuaUiManager.Register(XLuaUi, "UiTRPGWinWorldBoss") + +function XUiTRPGWinWorldBoss:OnStart(data) + self.GridReward.gameObject:SetActiveEx(false) + self:InitRewardList(data.RewardGoodsList) + self:SetButtonCallback() + self:ShowPanel(data) +end + +function XUiTRPGWinWorldBoss:OnEnable() + self:PlayAnimation("PanelBossSingleinfo", function() + XDataCenter.FunctionEventManager.UnLockFunctionEvent() + end) +end + +function XUiTRPGWinWorldBoss:OnDestroy() + XDataCenter.AntiAddictionManager.EndFightAction() +end + +-- 物品奖励列表 +function XUiTRPGWinWorldBoss:InitRewardList(rewardGoodsList) + rewardGoodsList = rewardGoodsList or {} + self.GridRewardList = {} + local rewards = XRewardManager.MergeAndSortRewardGoodsList(rewardGoodsList) + for i, item in ipairs(rewards) do + local grid + if i == 1 then + grid = XUiGridCommon.New(self, self.GridReward) + else + local ui = CS.UnityEngine.Object.Instantiate(self.GridReward) + grid = XUiGridCommon.New(self, ui) + end + grid.Transform:SetParent(self.PanelRewardContent, false) + grid:Refresh(item, nil, nil, true) + grid.GameObject:SetActive(false) + table.insert(self.GridRewardList, grid) + end +end + +function XUiTRPGWinWorldBoss:SetButtonCallback() + self:RegisterClickEvent(self.BtnBlock, self.OnBtnBlockClick) +end + +function XUiTRPGWinWorldBoss:ShowPanel(data) + self.StageId = data.StageId + self.RewardGoodsList = data.RewardGoodsList + self.TRPGBossFightResult = data.SettleData and data.SettleData.TRPGBossFightResult + + local _, name = XDataCenter.FubenManager.GetFubenNames(data.StageId) + self.TxtDifficult.text = name + + self:PlayRewardAnimation() + self:PlayScoreAndTimeAnimation() +end + +-- 奖励动画 +function XUiTRPGWinWorldBoss:PlayRewardAnimation() + local delay = XDataCenter.FubenManager.SettleRewardAnimationDelay + local interval = XDataCenter.FubenManager.SettleRewardAnimationInterval + local this = self + + if not self.GridRewardList or #self.GridRewardList == 0 then + return + end + + self.RewardAnimationIndex = 1 + XScheduleManager.Schedule(function() + this:PlayReward(this.RewardAnimationIndex) + this.RewardAnimationIndex = this.RewardAnimationIndex + 1 + end, interval, #self.GridRewardList, delay) +end + +function XUiTRPGWinWorldBoss:PlayReward(index, cb) + self.GridRewardList[index].GameObject:SetActive(true) +end + +function XUiTRPGWinWorldBoss:PlayScoreAndTimeAnimation() + if not self.TRPGBossFightResult then return end + -- 播放音效 + self.AudioInfo = CS.XAudioManager.PlaySound(XSoundManager.UiBasicsMusic.UiSettle_Win_Number) + local totalTime = self.TRPGBossFightResult.FightTime + local time = CS.XGame.ClientConfig:GetFloat("BossSingleAnimaTime") + XUiHelper.Tween(time, function(f) + if XTool.UObjIsNil(self.Transform) then + return + end + + local totalTimeText = XUiHelper.GetTime(math.floor(f * totalTime)) + local bossLoseHpText = math.floor(f * self.TRPGBossFightResult.BossDamage) + self.TxtStageTime.text = totalTimeText + self.TxtBossLoseHpScore.text = bossLoseHpText + end, function() + if XTool.UObjIsNil(self.Transform) then + return + end + self:StopAudio() + end) +end + +function XUiTRPGWinWorldBoss:StopAudio() + if self.AudioInfo then + self.AudioInfo:Stop() + end +end + +function XUiTRPGWinWorldBoss:OnBtnBlockClick() + self:StopAudio() + self:Close() + XTipManager.Execute() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTRPG/XUiTRPGWorldBoss/XUiTRPGWorldBossBossArea.lua b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGWorldBoss/XUiTRPGWorldBossBossArea.lua new file mode 100644 index 00000000..bc324d1c --- /dev/null +++ b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGWorldBoss/XUiTRPGWorldBossBossArea.lua @@ -0,0 +1,134 @@ +local XUiTRPGWorldBossBossArea = XLuaUiManager.Register(XLuaUi, "UiTRPGWorldBossBossArea") +local XUiTRPGPanelEnter = require("XUi/XUiTRPG/XUiTRPGWorldBoss/XUiTRPGPanelEnter") +local XUiTRPGPanelDetail = require("XUi/XUiTRPG/XUiTRPGWorldBoss/XUiTRPGPanelDetail") + +local PanelState = { + Enter = 1, + Detail = 2 +} + +local CameraIndex = { + Main = 1, + Detail = 2 +} + +local TRPGWorldBossFirstStoryKey = "TRPGWorldBossFirstStoryKey" + +function XUiTRPGWorldBossBossArea:OnAwake() + self:Init3DScene() +end + +function XUiTRPGWorldBossBossArea:OnStart() + self.PanelEnter = XUiTRPGPanelEnter.New(self.PanelEnterObj, function(panelState) self:SetPanelState(panelState) end) + self.PanelDetail = XUiTRPGPanelDetail.New(self.PanelDetailObj, self) + self:SetPanelState(PanelState.Enter) + self:SetButtonCallBack() + self:RefreshModel() + self:PlayStartStory() +end + +function XUiTRPGWorldBossBossArea:OnEnable() + self.Schedule = XScheduleManager.ScheduleForever(function() self:CheckCloseWorldBossArea() end, XScheduleManager.SECOND) + XDataCenter.TRPGManager.RequestTRPGBossDetailSend(function() self:Refresh() end) +end + +function XUiTRPGWorldBossBossArea:OnDisable() + XScheduleManager.UnSchedule(self.Schedule) +end + +function XUiTRPGWorldBossBossArea:Refresh() + self.PanelEnter:UpdatePanelPhasesReward() + self.PanelDetail:UpdateActivityInfo() +end + +function XUiTRPGWorldBossBossArea:CheckCloseWorldBossArea() + local openState = XDataCenter.TRPGManager.GetWorldBossOpenState() + if openState == XTRPGConfigs.AreaStateType.NotOpen or openState == XTRPGConfigs.AreaStateType.Over then + local msg = CS.XTextManager.GetText("TRPGWorldBossOver") + XUiManager.TipMsg(msg, nil, function() self:Close() end) + end +end + +function XUiTRPGWorldBossBossArea:Init3DScene() + local root = self.UiModelGo.transform + self.RoleModelPanel = XUiPanelRoleModel.New(root:FindTransform("PanelModel"), self.Name, nil, true, nil, true) + self.CameraNear = { + [CameraIndex.Main] = root:FindTransform("NearCameraMain"), + [CameraIndex.Detail] = root:FindTransform("NearCameraDetail"), + } + self.CameraFar = { + [CameraIndex.Main] = root:FindTransform("FarCameraMain"), + [CameraIndex.Detail] = root:FindTransform("FarCameraDetail"), + } +end + +function XUiTRPGWorldBossBossArea:SetButtonCallBack() + self.BtnBack.CallBack = function() + self:OnBtnBackClick() + end + + self.BtnMainUi.CallBack = function() + self:OnBtnMainUiClick() + end + self:BindHelpBtn(self.BtnHelp, "TRPGMainLine") +end + +function XUiTRPGWorldBossBossArea:SetPanelState(state) + if state == PanelState.Enter then + self.PanelEnter:SetShow(true) + self.PanelDetail:SetShow(false) + self.CameraNear[CameraIndex.Main].gameObject:SetActiveEx(true) + self.CameraNear[CameraIndex.Detail].gameObject:SetActiveEx(false) + self.CameraFar[CameraIndex.Main].gameObject:SetActiveEx(true) + self.CameraFar[CameraIndex.Detail].gameObject:SetActiveEx(false) + self:PlayAnimation("PanelEnterAnimEnable") + elseif state == PanelState.Detail then + self.PanelEnter:SetShow(false) + self.PanelDetail:SetShow(true) + self.CameraNear[CameraIndex.Main].gameObject:SetActiveEx(false) + self.CameraNear[CameraIndex.Detail].gameObject:SetActiveEx(true) + self.CameraFar[CameraIndex.Main].gameObject:SetActiveEx(false) + self.CameraFar[CameraIndex.Detail].gameObject:SetActiveEx(true) + self:PlayAnimation("PanlDetailAnimEnable2") + end + self.CurPanelState = state +end + +function XUiTRPGWorldBossBossArea:OnBtnBackClick() + if self.CurPanelState == PanelState.Detail then + self:SetPanelState(PanelState.Enter) + else + self:Close() + end +end + +function XUiTRPGWorldBossBossArea:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiTRPGWorldBossBossArea:RefreshModel() + local modelId = XTRPGConfigs.GetBossModelId() + self.RoleModelPanel:UpdateBossModel(modelId, XModelManager.MODEL_UINAME.XUiTRPGWorldBossBossArea, nil, nil, true) + self.RoleModelPanel:ShowRoleModel() +end + +function XUiTRPGWorldBossBossArea:PlayStartStory() + local startStroy = XTRPGConfigs.GetBossStartStoryId() + if not startStroy then return end + + local IsCanPlay = XDataCenter.TRPGManager.CheckIsNewStoryID(startStroy, TRPGWorldBossFirstStoryKey) + if IsCanPlay then + XDataCenter.MovieManager.PlayMovie(startStroy) + XDataCenter.TRPGManager.MarkStoryID(startStroy, TRPGWorldBossFirstStoryKey) + end +end + +function XUiTRPGWorldBossBossArea:OnGetEvents() + return { XEventId.EVENT_TRPG_WORLDBOSS_SYNCDATA } +end + +function XUiTRPGWorldBossBossArea:OnNotify(evt) + if evt == XEventId.EVENT_TRPG_WORLDBOSS_SYNCDATA then + self:Refresh() + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTRPG/XUiTRPGYingDi.lua b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGYingDi.lua new file mode 100644 index 00000000..ff3e44f0 --- /dev/null +++ b/Resources/Scripts/XUi/XUiTRPG/XUiTRPGYingDi.lua @@ -0,0 +1,308 @@ +local XUiGridTRPGRoleDetail = require("XUi/XUiTRPG/XUiGridTRPGRoleDetail") +local XUiGridTRPGBuff = require("XUi/XUiTRPG/XUiGridTRPGBuff") +local XUiTRPGPanelLevel = require("XUi/XUiTRPG/XUiTRPGPanel/XUiTRPGPanelLevel") + +local CSUnityEngineObjectInstantiate = CS.UnityEngine.Object.Instantiate +local CSXTextManagerGetText = CS.XTextManager.GetText +local stringGsub = string.gsub + +--虚拟相机Index +local CAMERA_INDEX = { + MAIN = 1, --主界面 + TALENT = 2, --天赋界面 + TALENT_DETAIL = 3, --天赋详情界面 +} + +local XUiTRPGYingDi = XLuaUiManager.Register(XLuaUi, "UiTRPGYingDi") + +function XUiTRPGYingDi:OnAwake() + self:AutoAddListener() + self.GridBuff.gameObject:SetActiveEx(false) + self.LevelPanel = XUiTRPGPanelLevel.New(self.PanelLevel) + + self.AssetActivityPanel = XUiPanelActivityAsset.New(self.PanelSpecialTool) + XDataCenter.ItemManager.AddCountUpdateListener(XDataCenter.ItemManager.ItemId.TRPGMoney, function() + self.AssetActivityPanel:Refresh({ XDataCenter.ItemManager.ItemId.TRPGMoney }) + end, self.AssetActivityPanel) + self.AssetActivityPanel:Refresh({ XDataCenter.ItemManager.ItemId.TRPGMoney }) +end + +function XUiTRPGYingDi:OnStart() + self.TabBtns = {} + self.BuffGrids = {} + self.SelectIndex = 1 + + self:InitSceneRoot() + self:InitRoles() + self:RegisterRedPointEvent() +end + +function XUiTRPGYingDi:OnEnable() + XDataCenter.TRPGManager.CheckActivityEnd() + self:UpdateRoles() + self:UpdateCamera(CAMERA_INDEX.MAIN) + self:UpdateBtnState() +end + +function XUiTRPGYingDi:OnDestroy() + self.LevelPanel:Delete() +end + +function XUiTRPGYingDi:OnGetEvents() + return { XEventId.EVENT_TRPG_ROLES_DATA_CHANGE, XEventId.EVENT_ACTIVITY_MAINLINE_STATE_CHANGE } +end + +function XUiTRPGYingDi:OnNotify(evt, ...) + if evt == XEventId.EVENT_TRPG_ROLES_DATA_CHANGE then + self:UpdateRoles() + elseif evt == XEventId.EVENT_ACTIVITY_MAINLINE_STATE_CHANGE then + XDataCenter.TRPGManager.OnActivityMainLineStateChange(...) + end +end + +function XUiTRPGYingDi:InitSceneRoot() + local root = self.UiModelGo.transform + + self.PanelRoleModel = root:FindTransform("UiModelParent") + self.ImgEffectHuanren = root:FindTransform("ImgEffectHuanren") + self.CameraNear = { + [CAMERA_INDEX.MAIN] = root:FindTransform("YingdiNear01"), + [CAMERA_INDEX.TALENT] = root:FindTransform("YingdiNear02"), + [CAMERA_INDEX.TALENT_DETAIL] = root:FindTransform("YingdiNear03"), + } + self.CameraFar = { + [CAMERA_INDEX.MAIN] = root:FindTransform("YingdiFar01"), + [CAMERA_INDEX.TALENT] = root:FindTransform("YingdiFar02"), + [CAMERA_INDEX.TALENT_DETAIL] = root:FindTransform("YingdiFar03"), + } + self.RoleModelPanel = XUiPanelRoleModel.New(self.PanelRoleModel, self.Name, nil, true, nil, true) +end + +function XUiTRPGYingDi:InitRoles() + if XDataCenter.TRPGManager.IsRolesEmpty() then + XLog.Error("XUiTRPGYingDi:InitRoles error: 调查员数据不存在") + self:Close() + return + end + + local roleIds = XDataCenter.TRPGManager.GetSortedAllRoleIds() + if XTool.IsTableEmpty(roleIds) then + self:Close() + return + end + self.RoleIds = roleIds + + local btns = {} + for index, roleId in pairs(roleIds) do + local btn = index == 1 and self.BtnHead or CSUnityEngineObjectInstantiate(self.BtnHead, self.PanelHead.transform) + btns[index] = btn + end + self.PanelHead:Init(btns, function(index) self:OnSelectRole(index) end) + self.TabBtns = btns +end + +function XUiTRPGYingDi:UpdateRoles() + local roleIds = self.RoleIds + if XTool.IsTableEmpty(roleIds) then + return + end + + local firstOwnIndex + self.RoleCount = 0 + for index, roleId in pairs(roleIds) do + local btn = self.TabBtns[index] + local isLock = not XDataCenter.TRPGManager.IsRoleOwn(roleId) + + if isLock then + btn:SetDisable(true) + else + btn:SetDisable(false) + local icon = XTRPGConfigs.GetRoleHeadIcon(roleId) + btn:SetRawImage(icon) + + self.RoleCount = self.RoleCount + 1 + + firstOwnIndex = firstOwnIndex or index + end + end + + if not XDataCenter.TRPGManager.IsRoleOwn(roleIds[self.SelectIndex]) then + self.SelectIndex = firstOwnIndex + end + self.PanelHead:SelectIndex(self.SelectIndex) +end + +function XUiTRPGYingDi:UpdateRoleDetail() + local roleId = self.RoleIds[self.SelectIndex] + + local isLock = not XDataCenter.TRPGManager.IsRoleOwn(roleId) + if isLock then + XUiManager.TipText("TRPGRoleUnlockTip") + return + end + + local attributes = XDataCenter.TRPGManager.GetRoleAttributes(roleId) + for index, attr in pairs(attributes) do + local attrName = XTRPGConfigs.GetRoleAttributeName(attr.Type) + self["TxtAttrType" .. index].text = attrName + self["TxtValue" .. index].text = attr.Value + end + + local buffGrids = self.BuffGrids + local buffIds = XDataCenter.TRPGManager.GetRoleBuffIds(roleId) + for index, buffId in pairs(buffIds) do + local grid = buffGrids[index] + if not grid then + local ui = index == 1 and self.GridBuff or CSUnityEngineObjectInstantiate(self.GridBuff, self.PanelBuffContent) + grid = XUiGridTRPGBuff.New(ui, self) + buffGrids[index] = grid + end + + grid:Refresh(buffId) + grid.GameObject:SetActiveEx(true) + end + for index = #buffIds + 1, #buffGrids do + local grid = buffGrids[index] + if grid then + grid.GameObject:SetActiveEx(false) + end + end + + local modelId = XTRPGConfigs.GetRoleModelId(roleId) + self.ImgEffectHuanren.gameObject:SetActiveEx(false) + self.RoleModelPanel:UpdateRoleModel(modelId, self.PanelRoleModel, XModelManager.MODEL_UINAME.XUiTRPGYingDi, function(model) + self.ImgEffectHuanren.gameObject:SetActiveEx(true) + end, nil, true) +end + +function XUiTRPGYingDi:UpdateCamera(selectIndex) + for index, camera in pairs(self.CameraNear) do + camera.gameObject:SetActiveEx(index == selectIndex) + end + + for index, camera in pairs(self.CameraFar) do + camera.gameObject:SetActiveEx(index == selectIndex) + end +end + +function XUiTRPGYingDi:OnSelectRole(index) + local roleId = self.RoleIds[index] + + local isLock = not XDataCenter.TRPGManager.IsRoleOwn(roleId) + if isLock then return end + + self.SelectIndex = index + + self:UpdateRoleDetail() + + local notNext = index + 1 > self.RoleCount + local notLast = index - 1 < 1 + self:FindChildUiObj("UiTRPGTalenTree"):RefreshData(roleId, notNext, notLast) +end + +function XUiTRPGYingDi:OnSelectNextRole() + local index = self.SelectIndex + 1 + if index > self.RoleCount then + index = 1 + end + + self.PanelHead:SelectIndex(index) +end + +function XUiTRPGYingDi:OnSelectLastRole() + local index = self.SelectIndex - 1 + if index < 1 then + index = self.SelectIndex + end + + self.PanelHead:SelectIndex(index) +end + +function XUiTRPGYingDi:AutoAddListener() + self:RegisterClickEvent(self.BtnOverview, self.OnClickBtnOverview) + self:RegisterClickEvent(self.BtnBlackCollection, self.OnClickBtnBlackCollection) + self:RegisterClickEvent(self.BtniBag, self.OnClickBtnBag) + self:RegisterClickEvent(self.BtnBack, self.OnClickBtnBack) + self:RegisterClickEvent(self.BtnMainUi, self.OnClickBtnMainUi) + self:RegisterClickEvent(self.BtnTalent, self.OnClickBtnTalent) + self:RegisterClickEvent(self.BtnDesc, self.OnClickBtnDesc) +end + +function XUiTRPGYingDi:OnClickBtnOverview() + XLuaUiManager.Open("UiTRPGTalentOverView") +end + +function XUiTRPGYingDi:OnClickBtnBlackCollection() + local ret, desc = XTRPGConfigs.CheckButtonCondition(XTRPGConfigs.ButtonConditionId.Collection) + if not ret then + XUiManager.TipError(desc) + return + end + XLuaUiManager.Open("UiTRPGCollection") +end + +function XUiTRPGYingDi:OnClickBtnBag() + self:UpdateCamera(CAMERA_INDEX.TALENT_DETAIL) + XLuaUiManager.Open("UiTRPGBag") +end + +function XUiTRPGYingDi:OnClickBtnBack() + self:Close() +end + +function XUiTRPGYingDi:OnClickBtnMainUi() + XLuaUiManager.RunMain() +end + +function XUiTRPGYingDi:OnClickBtnDesc() + local title = CSXTextManagerGetText("TRPGYingdiDescTitle") + local desc = CSXTextManagerGetText("TRPGYingdiDesc") + desc = stringGsub(desc, "\\n", "\n") + XUiManager.UiFubenDialogTip(title, desc) +end + +function XUiTRPGYingDi:OnClickBtnTalent() + local ret, desc = XTRPGConfigs.CheckButtonCondition(XTRPGConfigs.ButtonConditionId.Talent) + if not ret then + XUiManager.TipError(desc) + return + end + self:UpdateCamera(CAMERA_INDEX.TALENT) + + local index = self.SelectIndex + local roleId = self.RoleIds[index] + local showDetailCb = function() self:UpdateCamera(CAMERA_INDEX.TALENT_DETAIL) end + local hideDetailCb = function() self:UpdateCamera(CAMERA_INDEX.TALENT) end + local selectNextCb = function() self:OnSelectNextRole() end + local selectLastCb = function() self:OnSelectLastRole() end + local notNext = index + 1 > self.RoleCount or not XDataCenter.TRPGManager.IsRoleOwn(self.RoleIds[index + 1]) + local notLast = index - 1 < 1 or not XDataCenter.TRPGManager.IsRoleOwn(self.RoleIds[index - 1]) + + local closeCb = function() + self:UpdateCamera(CAMERA_INDEX.MAIN) + self:PlayAnimation("PanelYingDiEnable") + end + self:OpenChildUi("UiTRPGTalenTree", roleId, closeCb, showDetailCb, hideDetailCb, selectNextCb, selectLastCb, notNext, notLast) + + self:PlayAnimation("PanelYingDiDisable") +end + +function XUiTRPGYingDi:RegisterRedPointEvent() + XRedPointManager.AddRedPointEvent(self.BtnBlackCollection, self.OnCheckBtnBlackCollectionRedPoint, self, { XRedPointConditions.Types.CONDITION_TRPG_COLLECTION_MEMOIR }) + XRedPointManager.AddRedPointEvent(self.BtnTalent, self.OnCheckBtnTalentRedPoint, self, { XRedPointConditions.Types.CONDITION_TRPG_ROLE_TALENT }) +end + +function XUiTRPGYingDi:OnCheckBtnBlackCollectionRedPoint(count) + self.BtnBlackCollection:ShowReddot(count >= 0) +end + +function XUiTRPGYingDi:OnCheckBtnTalentRedPoint(count) + self.BtnTalent:ShowReddot(count >= 0) +end + +function XUiTRPGYingDi:UpdateBtnState() + local ret = XTRPGConfigs.CheckButtonCondition(XTRPGConfigs.ButtonConditionId.Collection) + self.BtnBlackCollection:SetDisable(not ret) + ret = XTRPGConfigs.CheckButtonCondition(XTRPGConfigs.ButtonConditionId.Talent) + self.BtnTalent:SetDisable(not ret) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTask/XDynamicActivityTask.lua b/Resources/Scripts/XUi/XUiTask/XDynamicActivityTask.lua new file mode 100644 index 00000000..b9ffccf0 --- /dev/null +++ b/Resources/Scripts/XUi/XUiTask/XDynamicActivityTask.lua @@ -0,0 +1,130 @@ +XDynamicActivityTask = XClass(nil, "XDynamicActivityTask") + +function XDynamicActivityTask:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RewardPanelList = {} + XTool.InitUiObject(self) + self.GridCommon.gameObject:SetActiveEx(false) + self.ImgComplete.gameObject:SetActiveEx(false) + self.PanelAnimation.gameObject:SetActiveEx(true) + self.ImgNotFinish.gameObject:SetActiveEx(true) + self.BtnFinish.CallBack = function() self:OnBtnFinishClick() end +end + +function XDynamicActivityTask:PlayAnimation() + if self.IsAnimation then + return + end + + self.IsAnimation = true + self.GridTaskTimeline:PlayTimelineAnimation() +end + +function XDynamicActivityTask:ResetData(data, base) + self.Data = data + self.Base = base + local config = XDataCenter.TaskManager.GetTaskTemplate(self.Data.Id) + self.tableData = config + self.TxtTaskDescribe.text = config.Desc + self.RImgTaskType:SetRawImage(self.Base.TaskVipBg) + self.RImgTaskTypeNa:SetRawImage(self.Base.TaskBg) + self.RImgTaskTypeFihsh:SetRawImage(self.Base.TaskVipGotBg) + self.RImgTaskTypeNaFinsh:SetRawImage(self.Base.TaskGotBg) + + if self.Data.PointId then + local itemIcon = XDataCenter.ItemManager.GetItemIcon(self.Data.PointId) + self.ImgIcon:SetRawImage(itemIcon) + end + self:UpdateProgress(self.Data) + local rewards = XRewardManager.GetRewardList(config.RewardId) + for i = 1, #self.RewardPanelList do + self.RewardPanelList[i]:Refresh() + end + + if rewards then + for i = 1, #rewards do + local panel = self.RewardPanelList[i] + if not panel then + if #self.RewardPanelList == 0 then + panel = XUiGridCommon.New(self.RootUi, self.GridCommon) + else + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommon) + ui.transform:SetParent(self.GridCommon.parent, false) + panel = XUiGridCommon.New(self.RootUi, ui) + end + table.insert(self.RewardPanelList, panel) + end + + panel:Refresh(rewards[i]) + end + end + + local isFinish = self.Data.State == XDataCenter.TaskManager.TaskState.Finish + self.ImgComplete.gameObject:SetActiveEx(isFinish) + + local canGet = self.Data.State == XDataCenter.TaskManager.TaskState.Achieved + self.ImgNotFinish.gameObject:SetActiveEx(not isFinish and not canGet) + + self.ImgNotFinish.gameObject:SetActiveEx(not isFinish and self.Data.State ~= XDataCenter.TaskManager.TaskState.Achieved) + + if self.PanelAnimationGroup then + self.PanelAnimationGroup.alpha = 1 + end +end + +function XDynamicActivityTask:OnBtnFinishClick() + local weaponCount = 0 + local chipCount = 0 + for i = 1, #self.RewardPanelList do + local rewardsId = self.RewardPanelList[i].TemplateId + if XDataCenter.EquipManager.IsClassifyEqualByTemplateId(rewardsId, XEquipConfig.Classify.Weapon) then + weaponCount = weaponCount + 1 + elseif XDataCenter.EquipManager.IsClassifyEqualByTemplateId(rewardsId, XEquipConfig.Classify.Awareness) then + chipCount = chipCount + 1 + end + end + if weaponCount > 0 and XDataCenter.EquipManager.CheckBagCount(weaponCount, XEquipConfig.Classify.Weapon) == false or + chipCount > 0 and XDataCenter.EquipManager.CheckBagCount(chipCount, XEquipConfig.Classify.Awareness) == false then + return + end + + if self.EffectFinish then + self.EffectFinish.gameObject:SetActiveEx(false) + self.EffectFinish.gameObject:SetActiveEx(true) + end + + XDataCenter.TaskManager.FinishTask(self.Data.Id, function(rewardGoodsList) + XUiManager.OpenUiObtain(rewardGoodsList) + end) +end + +function XDynamicActivityTask:UpdateProgress(data) + self.RImgTaskType.gameObject:SetActiveEx(data.IsMark) + self.RImgTaskTypeNa.gameObject:SetActiveEx(not data.IsMark) + self.RImgTaskTypeFihsh.gameObject:SetActiveEx(false) + self.RImgTaskTypeNaFinsh.gameObject:SetActiveEx(false) + + self.BtnFinish.gameObject:SetActiveEx(false) + if self.Data.State == XDataCenter.TaskManager.TaskState.Achieved then + self.RImgTaskType.gameObject:SetActiveEx(false) + self.RImgTaskTypeNa.gameObject:SetActiveEx(false) + + self.RImgTaskTypeFihsh.gameObject:SetActiveEx(data.IsMark) + self.RImgTaskTypeNaFinsh.gameObject:SetActiveEx(not data.IsMark) + + self.BtnFinish.gameObject:SetActiveEx(true) + end + + local markNum = data.IsMark and 1 or 0 + if not self.OldMark or self.OldMark ~= markNum then + if data.IsMark then + if self.EffectNor then self.EffectNor.gameObject:SetActiveEx(false) end + if self.EffectVip then self.EffectVip.gameObject:SetActiveEx(true) end + else + if self.EffectVip then self.EffectVip.gameObject:SetActiveEx(false) end + if self.EffectNor then self.EffectNor.gameObject:SetActiveEx(true) end + end + self.OldMark = data.IsMark and 1 or 0 + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTask/XDynamicDailyTask.lua b/Resources/Scripts/XUi/XUiTask/XDynamicDailyTask.lua new file mode 100644 index 00000000..8425b7cb --- /dev/null +++ b/Resources/Scripts/XUi/XUiTask/XDynamicDailyTask.lua @@ -0,0 +1,336 @@ +XDynamicDailyTask = XClass(nil, "XDynamicDailyTask") + +-- 每日任务为时间段的condition类型,除了这些类型其他任务有效时间都是一天 +local TimePeriodConditionType = { + [1] = 10102 +} +local A_DAY = 24 * 60 * 60 +local A_HOUR = 60 * 60 +local A_MIN = 60 + +function XDynamicDailyTask:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RewardPanelList = {} + + XTool.InitUiObject(self) + self.GridCommon.gameObject:SetActive(false) + self.ImgComplete.gameObject:SetActive(false) + self.PanelAnimation.gameObject:SetActive(true) + + self.BtnFinish.CallBack = function() self:OnBtnFinishClick() end + self.BtnSkip.CallBack = function() self:OnBtnSkipClick() end +end + +function XDynamicDailyTask:PlayAnimation() + if self.IsAnimation then + return + end + + self.IsAnimation = true + self.GridTaskTimeline:PlayTimelineAnimation() +end + +function XDynamicDailyTask:ResetData(data) + self.Data = data + + local config = XDataCenter.TaskManager.GetTaskTemplate(self.Data.Id) + self.tableData = config + self.TxtTaskName.text = config.Title + self.TxtTaskDescribe.text = config.Desc + self.TxtSubTypeTip.text = config.Suffix or "" + self.RImgTaskType:SetRawImage(config.Icon) + self:UpdateProgress(self.Data) + local rewards = XRewardManager.GetRewardList(config.RewardId) + for i = 1, #self.RewardPanelList do + self.RewardPanelList[i]:Refresh() + end + XScheduleManager.ScheduleOnce(function()--异形屏适配需要 + if rewards then + for i = 1, #rewards do + local panel = self.RewardPanelList[i] + if not panel then + if #self.RewardPanelList == 0 then + panel = XUiGridCommon.New(self.RootUi, self.GridCommon) + else + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommon) + ui.transform:SetParent(self.GridCommon.parent, false) + panel = XUiGridCommon.New(self.RootUi, ui) + end + table.insert(self.RewardPanelList, panel) + end + + panel:Refresh(rewards[i]) + end + end + end, 0) + + local isFinish = data.State == XDataCenter.TaskManager.TaskState.Finish + self.ImgComplete.gameObject:SetActive(isFinish) + self.PanelTime.gameObject:SetActive(not isFinish) + if not isFinish then + self:UpdateTimes() + end + if self.PanelAnimationGroup then + self.PanelAnimationGroup.alpha = 1 + end +end + +function XDynamicDailyTask:OnBtnFinishClick() + local weaponCount = 0 + local chipCount = 0 + for i = 1, #self.RewardPanelList do + local rewardsId = self.RewardPanelList[i].TemplateId + if XDataCenter.EquipManager.IsClassifyEqualByTemplateId(rewardsId, XEquipConfig.Classify.Weapon) then + weaponCount = weaponCount + 1 + elseif XDataCenter.EquipManager.IsClassifyEqualByTemplateId(rewardsId, XEquipConfig.Classify.Awareness) then + chipCount = chipCount + 1 + end + end + if weaponCount > 0 and XDataCenter.EquipManager.CheckBagCount(weaponCount, XEquipConfig.Classify.Weapon) == false or + chipCount > 0 and XDataCenter.EquipManager.CheckBagCount(chipCount, XEquipConfig.Classify.Awareness) == false then + return + end + local savedFinishedTaskId = self.Data.Id + XDataCenter.TaskManager.FinishTask(self.Data.Id, function(rewardGoodsList) + --CheckPoint: APPEVENT_WAR_AND_PAINGAGE + XAppEventManager.WeeklyRewardAppLogEvent(savedFinishedTaskId) + XUiManager.OpenUiObtain(rewardGoodsList) + end) +end + +function XDynamicDailyTask:OnBtnSkipClick() + if XDataCenter.RoomManager.RoomData ~= nil then + local title = CS.XTextManager.GetText("TipTitle") + local cancelMatchMsg = CS.XTextManager.GetText("OnlineInstanceQuitRoom") + XUiManager.DialogTip(title, cancelMatchMsg, XUiManager.DialogType.Normal, nil, function() + XLuaUiManager.RunMain() + local skipId = XDataCenter.TaskManager.GetTaskTemplate(self.Data.Id).SkipId + XFunctionManager.SkipInterface(skipId) + end) + else + local skipId = XDataCenter.TaskManager.GetTaskTemplate(self.Data.Id).SkipId + XFunctionManager.SkipInterface(skipId) + end +end + +function XDynamicDailyTask:UpdateProgress(data) + self.Data = data + local config = XDataCenter.TaskManager.GetTaskTemplate(data.Id) + if #config.Condition < 2 then--显示进度 + self.ImgProgress.transform.parent.gameObject:SetActive(true) + self.TxtTaskNumQian.gameObject:SetActive(true) + local result = config.Result > 0 and config.Result or 1 + XTool.LoopMap(self.Data.Schedule, function(_, pair) + self.ImgProgress.fillAmount = pair.Value / result + pair.Value = (pair.Value >= result) and result or pair.Value + self.TxtTaskNumQian.text = pair.Value .. "/" .. result + end) + else + self.ImgProgress.transform.parent.gameObject:SetActive(false) + self.TxtTaskNumQian.gameObject:SetActive(false) + end + + self.BtnFinish.gameObject:SetActive(false) + self.BtnSkip.gameObject:SetActive(false) + + if self.Data.State == XDataCenter.TaskManager.TaskState.Achieved then + self.BtnFinish.gameObject:SetActive(true) + elseif self.Data.State ~= XDataCenter.TaskManager.TaskState.Achieved and self.Data.State ~= XDataCenter.TaskManager.TaskState.Finish then + self.BtnSkip.gameObject:SetActive(true) + + local skipId = XDataCenter.TaskManager.GetTaskTemplate(self.Data.Id).SkipId + if skipId == nil or skipId == 0 then + self.BtnSkip:SetButtonState(CS.UiButtonState.Disable) + else + self.BtnSkip:SetButtonState(CS.UiButtonState.Normal) + end + end +end + +function XDynamicDailyTask:UpdateTimes() + if not self.Data then return end + + local taskId = self.Data.Id + local taskTemplates = XDataCenter.TaskManager.GetTaskTemplate(taskId) + if not taskTemplates then return end + + if XDataCenter.TaskManager.TaskType.Daily == taskTemplates.Type or XDataCenter.TaskManager.TaskType.DormDaily == taskTemplates.Type then + self:UpdateDailyTime() + + elseif XDataCenter.TaskManager.TaskType.Weekly == taskTemplates.Type or XDataCenter.TaskManager.TaskType.InfestorWeekly == taskTemplates.Type then + self:UpdateWeeklyTime() + + elseif XDataCenter.TaskManager.TaskType.ArenaOnlineWeekly == taskTemplates.Type then + self:UpdateArenaOnlineWeeklyTime() + + elseif XDataCenter.TaskManager.TaskType.TimeLimit == taskTemplates.Type then + if XTaskConfig.GetTimeLimitDailyTasksCheckTable()[taskId] then + self:UpdateDailyTime() + elseif XTaskConfig.GetTimeLimitWeeklyTasksCheckTable()[taskId] then + self:UpdateWeeklyTime() + else + self.PanelTime.gameObject:SetActive(false) + end + elseif XDataCenter.TaskManager.TaskType.Regression == taskTemplates.Type then + local regressionTaskType = XRegressionConfigs.GetTaskTypeById(taskId) + if regressionTaskType == XRegressionConfigs.TaskType.Day then + self:UpdateDailyTime() + elseif regressionTaskType == XRegressionConfigs.TaskType.Week then + self:UpdateWeeklyTime() + else + self.PanelTime.gameObject:SetActive(false) + end + elseif XDataCenter.TaskManager.TaskType.GuildWeekly == taskTemplates.Type then + self:UpdateGuildBossWeelyTime() + else + -- 不确定类型的默认每日 + self:UpdateDailyTime() + end +end + +function XDynamicDailyTask:UpdateDailyTime() + local taskTemplates = XDataCenter.TaskManager.GetTaskTemplate(self.Data.Id) + if not taskTemplates or not taskTemplates.Condition or not taskTemplates.Condition[1] then return end + + local conditionTemplates = XTaskConfig.GetTaskCondition(taskTemplates.Condition[1]) + if not conditionTemplates then return end + + local now = XTime.GetServerNowTimestamp() + local today_0_oclock = XTime.GetTodayTime(0, 0, 0) + local next_0_oclock = today_0_oclock + A_DAY + local beginTime + local endTime + local timeRefresh = 7 + if self:IsTimePeriodCondition(conditionTemplates.Type) then + -- 时间段限制 + beginTime = today_0_oclock + (conditionTemplates.Params[1] or 0) + endTime = today_0_oclock + (conditionTemplates.Params[2] or 0) + else + if math.abs(now - today_0_oclock) <= A_HOUR * timeRefresh then + -- 5点以前 + beginTime = today_0_oclock - A_DAY + A_HOUR * timeRefresh --昨天5点 + endTime = today_0_oclock + A_HOUR * timeRefresh --今天5点 + else + -- 5点之后 + beginTime = today_0_oclock + A_HOUR * timeRefresh --今天5点 + endTime = next_0_oclock + A_HOUR * timeRefresh --明天5点 + end + end + + if now < beginTime then + -- 距离开始 + self.PanelTime.gameObject:SetActive(true) + local totalSecond = beginTime - now + if totalSecond > A_HOUR then + self.TxtTime.text = CS.XTextManager.GetText("TaskBeginHour", tostring(math.floor(totalSecond / A_HOUR))) + else + self.TxtTime.text = CS.XTextManager.GetText("TaskBeginMin", tostring(math.ceil(totalSecond / A_MIN))) + end + self.BtnSkip:SetDisable(true, false) + self.BtnSkip:SetName(CS.XTextManager.GetText("TaskStateUnopen")) + self.BtnSkip.gameObject:SetActive(true) + self.BtnFinish.gameObject:SetActive(false) + elseif now >= beginTime and now <= endTime then + -- 剩余 + self.PanelTime.gameObject:SetActive(true) + local totalSecond = endTime - now + if totalSecond > A_HOUR then + self.TxtTime.text = CS.XTextManager.GetText("TaskLeftHour", tostring(math.floor(totalSecond / A_HOUR))) + else + self.TxtTime.text = CS.XTextManager.GetText("TaskLeftMin", tostring(math.ceil(totalSecond / A_MIN))) + end + self.BtnSkip:SetDisable(false, true) + self.BtnSkip:SetName(CS.XTextManager.GetText("TaskStateSkip")) + else + -- 超过 + self.BtnSkip:SetDisable(true, false) + self.BtnSkip:SetName(CS.XTextManager.GetText("TaskStateOverdue")) + self.BtnSkip.gameObject:SetActive(true) + self.BtnFinish.gameObject:SetActive(false) + self.PanelTime.gameObject:SetActive(false) + end + + if self.Data.State ~= XDataCenter.TaskManager.TaskState.Achieved and self.Data.State ~= XDataCenter.TaskManager.TaskState.Finish then + local skipId = XDataCenter.TaskManager.GetTaskTemplate(self.Data.Id).SkipId + if skipId == nil or skipId == 0 then + self.BtnSkip:SetButtonState(CS.UiButtonState.Disable) + end + end +end + +function XDynamicDailyTask:UpdateArenaOnlineWeeklyTime() + self.PanelTime.gameObject:SetActive(true) + + local taskTemplates = XDataCenter.TaskManager.GetTaskTemplate(self.Data.Id) + if not taskTemplates then return end + + local now = XTime.GetServerNowTimestamp() + local endTime = XDataCenter.ArenaOnlineManager.GetNextRefreshTime(); + + local needTime = endTime - now + if needTime > 0 then + if needTime > A_DAY then + self.TxtTime.text = CS.XTextManager.GetText("TaskLeftDay", tostring(math.floor(needTime / A_DAY))) + elseif needTime > A_HOUR then + self.TxtTime.text = CS.XTextManager.GetText("TaskLeftHour", tostring(math.floor(needTime / A_HOUR))) + else + self.TxtTime.text = CS.XTextManager.GetText("TaskLeftMin", tostring(math.ceil(needTime / A_MIN))) + end + else + self.PanelTime.gameObject:SetActive(false) + end +end + +function XDynamicDailyTask:UpdateWeeklyTime() + self.PanelTime.gameObject:SetActive(true) + + local taskTemplates = XDataCenter.TaskManager.GetTaskTemplate(self.Data.Id) + if not taskTemplates then return end + + local weekOfDay, epochTime = XDataCenter.TaskManager.GetWeeklyTaskRefreshTime() + local needTime = XTime.GetNextWeekOfDayStartWithMon(weekOfDay, epochTime) + if needTime > 0 then + + if needTime > A_DAY then + self.TxtTime.text = CS.XTextManager.GetText("TaskLeftDay", tostring(math.floor(needTime / A_DAY))) + elseif needTime > A_HOUR then + self.TxtTime.text = CS.XTextManager.GetText("TaskLeftHour", tostring(math.floor(needTime / A_HOUR))) + else + self.TxtTime.text = CS.XTextManager.GetText("TaskLeftMin", tostring(math.ceil(needTime / A_MIN))) + end + else + + self.PanelTime.gameObject:SetActive(false) + end +end + +function XDynamicDailyTask:UpdateGuildBossWeelyTime() + self.PanelTime.gameObject:SetActive(true) + local nowTime = XTime.GetServerNowTimestamp() + local endTime = XDataCenter.GuildBossManager.GetWeeklyTaskTime() + + local needTime = endTime - nowTime + if needTime > 0 then + + if needTime > A_DAY then + self.TxtTime.text = CS.XTextManager.GetText("TaskLeftDay", tostring(math.floor(needTime / A_DAY))) + elseif needTime > A_HOUR then + self.TxtTime.text = CS.XTextManager.GetText("TaskLeftHour", tostring(math.floor(needTime / A_HOUR))) + else + self.TxtTime.text = CS.XTextManager.GetText("TaskLeftMin", tostring(math.ceil(needTime / A_MIN))) + end + else + + self.PanelTime.gameObject:SetActive(false) + end +end + +function XDynamicDailyTask:IsTimePeriodCondition(conditionType) + for _, v in pairs(TimePeriodConditionType) do + if conditionType == v then + return true + end + end + return false +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTask/XDynamicGridTask.lua b/Resources/Scripts/XUi/XUiTask/XDynamicGridTask.lua new file mode 100644 index 00000000..76107077 --- /dev/null +++ b/Resources/Scripts/XUi/XUiTask/XDynamicGridTask.lua @@ -0,0 +1,242 @@ +XDynamicGridTask = XClass(nil, "XDynamicGridTask") + +function XDynamicGridTask:Ctor(ui,rootUi,beforeFinishCheckEvent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self.RewardPanelList = {} + self:InitAutoScript() + self.GridCommon.gameObject:SetActive(false) + self.ImgComplete.gameObject:SetActive(false) + self.PanelAnimation.gameObject:SetActive(true) + self.BeforeFinishCheckEvent = beforeFinishCheckEvent +end + +function XDynamicGridTask:PlayAnimation() + if self.IsAnimation then + return + end + + self.IsAnimation = true + self.GridTaskTimeline:PlayTimelineAnimation() +end + +function XDynamicGridTask:ResetData(data) + self.ImgComplete.gameObject:SetActive(data.State == XDataCenter.TaskManager.TaskState.Finish) + self.Data = data + + local config = XDataCenter.TaskManager.GetTaskTemplate(self.Data.Id) + self.tableData = config + self.TxtTaskName.text = config.Title + self.TxtTaskDescribe.text = config.Desc + self.TxtSubTypeTip.text = config.Suffix or "" + --self.RootUi:SetUiSprite(self.RImgTaskType, config.Icon) + self.RImgTaskType:SetRawImage(config.Icon) + self:UpdateProgress(self.Data) + local rewards = XRewardManager.GetRewardList(config.RewardId) + -- reset reward panel + for i = 1, #self.RewardPanelList do + self.RewardPanelList[i]:Refresh() + end + + if not rewards then + return + end + + for i = 1, #rewards do + + local panel = self.RewardPanelList[i] + if not panel then + if #self.RewardPanelList == 0 then + panel = XUiGridCommon.New(self.RootUi, self.GridCommon) + else + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommon) + ui.transform:SetParent(self.GridCommon.parent, false) + panel = XUiGridCommon.New(self.RootUi, ui) + end + table.insert(self.RewardPanelList, panel) + end + panel:Refresh(rewards[i]) + + end + if self.PanelAnimationGroup then + self.PanelAnimationGroup.alpha = 1 + end + + --临时修改:强制下一帧触发组件布局 + XScheduleManager.ScheduleOnce(function() + CS.UnityEngine.UI.LayoutRebuilder.ForceRebuildLayoutImmediate(self.PanelContent) + end, 0) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XDynamicGridTask:InitAutoScript() + self:AutoInitUi() + XTool.InitUiObject(self) + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XDynamicGridTask:AutoInitUi() + self.PanelAnimation = XUiHelper.TryGetComponent(self.Transform, "PanelAnimation", nil) + self.RImgTaskType = XUiHelper.TryGetComponent(self.Transform, "PanelAnimation/RImgTaskType", "RawImage") + self.ImgProgress = XUiHelper.TryGetComponent(self.Transform, "PanelAnimation/ProgressBg/ImgProgress", "Image") + self.PanelContent = XUiHelper.TryGetComponent(self.Transform, "PanelAnimation/TaskGridList/Viewport/Content", nil) + self.GridCommon = XUiHelper.TryGetComponent(self.Transform, "PanelAnimation/TaskGridList/Viewport/Content/GridCommon", nil) + self.ImgIcon = XUiHelper.TryGetComponent(self.Transform, "PanelAnimation/TaskGridList/Viewport/Content/GridCommon/ImgIcon", "Image") + self.ImgQuality = XUiHelper.TryGetComponent(self.Transform, "PanelAnimation/TaskGridList/Viewport/Content/GridCommon/ImgQuality", "Image") + self.BtnClick = XUiHelper.TryGetComponent(self.Transform, "PanelAnimation/TaskGridList/Viewport/Content/GridCommon/BtnClick", "Button") + self.TxtCount = XUiHelper.TryGetComponent(self.Transform, "PanelAnimation/TaskGridList/Viewport/Content/GridCommon/TxtCount", "Text") + self.BtnFinish = XUiHelper.TryGetComponent(self.Transform, "PanelAnimation/BtnFinish", "Button") + self.BtnSkip = XUiHelper.TryGetComponent(self.Transform, "PanelAnimation/BtnSkip", "Button") + self.TxtTaskName = XUiHelper.TryGetComponent(self.Transform, "PanelAnimation/TxtTaskName", "Text") + self.TxtTaskDescribe = XUiHelper.TryGetComponent(self.Transform, "PanelAnimation/TxtTaskDescribe", "Text") + self.TxtTaskNumQian = XUiHelper.TryGetComponent(self.Transform, "PanelAnimation/TxtTaskNumQian", "Text") + self.TxtSubTypeTip = XUiHelper.TryGetComponent(self.Transform, "PanelAnimation/TxtSubTypeTip", "Text") + self.ImgComplete = XUiHelper.TryGetComponent(self.Transform, "PanelAnimation/ImgComplete", "Image") +end + +function XDynamicGridTask:GetAutoKey(uiNode, eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XDynamicGridTask:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiGridTask:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XDynamicGridTask:AutoAddListener() + self.AutoCreateListeners = {} + + local clickXUiBtn = self.BtnClick:GetComponent("XUiButton") + if not clickXUiBtn then + XUiHelper.RegisterClickEvent(self, self.BtnClick, self.OnBtnClickClick) + else + self.BtnClick = clickXUiBtn + self.BtnClick.CallBack = function() self:OnBtnClickClick() end + end + + local finishXUiBtn = self.BtnFinish:GetComponent("XUiButton") + if not finishXUiBtn then + XUiHelper.RegisterClickEvent(self, self.BtnFinish, self.OnBtnFinishClick) + else + self.BtnFinish = finishXUiBtn + self.BtnFinish.CallBack = function() self:OnBtnFinishClick() end + end + + local skipXUiBtn = self.BtnSkip:GetComponent("XUiButton") + if not skipXUiBtn then + XUiHelper.RegisterClickEvent(self, self.BtnSkip, self.OnBtnSkipClick) + else + self.BtnSkip = skipXUiBtn + self.BtnSkip.CallBack = function() self:OnBtnSkipClick() end + end +end +-- auto +function XDynamicGridTask:OnBtnClickClick() + +end + + +function XDynamicGridTask:OnBtnFinishClick() + if self.BeforeFinishCheckEvent then + if not self.BeforeFinishCheckEvent(self.tableData) then + return + end + end + local weaponCount = 0 + local chipCount = 0 + local rewards = XRewardManager.GetRewardList(self.tableData.RewardId) + for i = 1, #rewards do + local rewardsId = self.RewardPanelList[i].TemplateId + if XDataCenter.EquipManager.IsClassifyEqualByTemplateId(rewardsId, XEquipConfig.Classify.Weapon) then + weaponCount = weaponCount + 1 + elseif XDataCenter.EquipManager.IsClassifyEqualByTemplateId(rewardsId, XEquipConfig.Classify.Awareness) then + chipCount = chipCount + 1 + end + end + if weaponCount > 0 and XDataCenter.EquipManager.CheckBagCount(weaponCount, XEquipConfig.Classify.Weapon) == false or + chipCount > 0 and XDataCenter.EquipManager.CheckBagCount(chipCount, XEquipConfig.Classify.Awareness) == false then + return + end + XDataCenter.TaskManager.FinishTask(self.Data.Id, function(rewardGoodsList) + XUiManager.OpenUiObtain(rewardGoodsList) + end) +end + +function XDynamicGridTask:OnBtnSkipClick() + if XDataCenter.RoomManager.RoomData ~= nil then + local title = CS.XTextManager.GetText("TipTitle") + local cancelMatchMsg = CS.XTextManager.GetText("OnlineInstanceQuitRoom") + XUiManager.DialogTip(title, cancelMatchMsg, XUiManager.DialogType.Normal, nil, function() + XLuaUiManager.RunMain() + local skipId = XDataCenter.TaskManager.GetTaskTemplate(self.Data.Id).SkipId + XFunctionManager.SkipInterface(skipId) + end) + else + local skipId = XDataCenter.TaskManager.GetTaskTemplate(self.Data.Id).SkipId + XFunctionManager.SkipInterface(skipId) + end +end + +function XDynamicGridTask:UpdateProgress(data) + self.Data = data + local config = XDataCenter.TaskManager.GetTaskTemplate(data.Id) + if #config.Condition < 2 then--显示进度 + self.ImgProgress.transform.parent.gameObject:SetActive(true) + self.TxtTaskNumQian.gameObject:SetActive(true) + local result = config.Result > 0 and config.Result or 1 + XTool.LoopMap(self.Data.Schedule, function(_, pair) + self.ImgProgress.fillAmount = pair.Value / result + pair.Value = (pair.Value >= result) and result or pair.Value + self.TxtTaskNumQian.text = pair.Value .. "/" .. result + end) + else + self.ImgProgress.transform.parent.gameObject:SetActive(false) + self.TxtTaskNumQian.gameObject:SetActive(false) + end + + self.BtnFinish.gameObject:SetActive(false) + self.BtnSkip.gameObject:SetActive(false) + if self.BtnReceiveHave then + self.BtnReceiveHave.gameObject:SetActive(false) + end + if self.Data.State == XDataCenter.TaskManager.TaskState.Achieved then + self.BtnFinish.gameObject:SetActive(true) + elseif self.Data.State ~= XDataCenter.TaskManager.TaskState.Achieved and self.Data.State ~= XDataCenter.TaskManager.TaskState.Finish then + self.BtnSkip.gameObject:SetActive(true) + + if self.BtnSkip["SetButtonState"] then + local skipId = XDataCenter.TaskManager.GetTaskTemplate(self.Data.Id).SkipId + if skipId == nil or skipId == 0 then + self.BtnSkip:SetButtonState(CS.UiButtonState.Disable) + else + self.BtnSkip:SetButtonState(CS.UiButtonState.Normal) + end + end + elseif self.Data.State == XDataCenter.TaskManager.TaskState.Finish then + if self.BtnReceiveHave then + self.BtnReceiveHave.gameObject:SetActive(true) + end + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTask/XTaskContainer.lua b/Resources/Scripts/XUi/XUiTask/XTaskContainer.lua new file mode 100644 index 00000000..9a4573b9 --- /dev/null +++ b/Resources/Scripts/XUi/XUiTask/XTaskContainer.lua @@ -0,0 +1,99 @@ +XTaskContainer = XClass(nil, "XTaskContainer") + +function XTaskContainer:Ctor(rootUi, container, grid, taskType, cb) + self.RootUi = rootUi + self.PanelContainer = container + self.GridTask = grid + self.TaskType = taskType + self.GridContainer = {} + self.Girds = {} + if self.TaskType == XDataCenter.TaskManager.TaskType.Daily then + self.Cb = cb + end + self.GridTask.gameObject:SetActive(false) +end + +function XTaskContainer:GetTaskList() + if self.TaskType == XDataCenter.TaskManager.TaskType.Story then + return XDataCenter.TaskManager.GetStoryTaskList() + elseif self.TaskType == XDataCenter.TaskManager.TaskType.Daily then + return XDataCenter.TaskManager.GetDailyTaskList() + elseif self.TaskType == XDataCenter.TaskManager.TaskType.Activity then + return XDataCenter.TaskManager.GetActivityTaskList() + elseif self.TaskType == XDataCenter.TaskManager.TaskType.Achievement then + return XDataCenter.TaskManager.GetAchvTaskList() + else + XLog.Error("XTaskContainer:GetTaskList error: unknown task type, task type is " .. self.TaskType) + end +end + +function XTaskContainer:Refresh() + local list = self:GetTaskList() + if not list or #list <= 0 then + return + end + + self.GridContainer = {} + + for _, var in ipairs(self.Girds) do + var.GameObject.name = "-1" + var.GameObject:SetActive(false) + end + + for i, var in ipairs(list) do + local grid = self.Girds[i] + if grid then + self.GridContainer[var.Id] = grid + grid:ResetData(var) + grid.GameObject.name = var.Id + grid.GameObject:SetActive(true) + else + self:AddItem(var) + end + end + + +end + +function XTaskContainer:AddItem(data) + local ui = CS.UnityEngine.Object.Instantiate(self.GridTask) + ui.transform:SetParent(self.PanelContainer, false) + ui.gameObject:SetActive(true) + ui.gameObject.name = data.Id + + local grid = XUiGridTask.New(self.RootUi, ui, data, function() + if self.Cb then + self.Cb() + end + end) + table.insert(self.Girds, grid) + + grid:PlayEnter() + self.GridContainer[data.Id] = grid +end + +function XTaskContainer:RemoveItem(id) + if self.TaskType ~= XDataCenter.TaskManager.TaskType.Achievement then + self.GridContainer[id].GameObject:SetActive(false) + -- CS.UnityEngine.Object.Destroy(self.GridContainer[id].GameObject) + end + self.GridContainer[id] = nil +end + +--成就列表分类显示 +function XTaskContainer:MatchType(achvtype) + + for _, var in ipairs(self.Girds) do + var.GameObject:SetActive(false) + end + + for _, v in pairs(self.GridContainer) do + if v.tableData.AchvType == achvtype then + v.GameObject.gameObject:SetActive(true) + end + end +end + +-- function XTaskContainer:UpdateTaskProgress(id, value) +-- self.GridContainer[id]:UpdateProgress(value) +-- end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTask/XUiGridCourse.lua b/Resources/Scripts/XUi/XUiTask/XUiGridCourse.lua new file mode 100644 index 00000000..59ea6520 --- /dev/null +++ b/Resources/Scripts/XUi/XUiTask/XUiGridCourse.lua @@ -0,0 +1,161 @@ +XUiGridCourse = XClass(nil, "XUiGridCourse") + +local PotPostion = { + [1] = {--有经历节点 + [1] = { x = 129, w = 248 }, + [2] = { x = 127, w = 247 }, + [3] = { x = 129, w = 250 } + }, + [2] = {--功能开启 + [1] = { x = 130, w = 240 }, + [2] = { x = 130, w = 250 }, + [3] = { x = 130, w = 255 } + }, + [3] = {--普通节点 + [1] = { x = 130, w = 245 }, + [2] = { x = 93, w = 250 }, + [3] = { x = 127, w = 245 } + } +} + +function XUiGridCourse:Ctor(rootUi, ui, stroyUi, nextCb, indexCb) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self.StroyUi = stroyUi + self.NextCallBack = nextCb + self.IndexCallBack = indexCb + self.CourseData = nil + + XTool.InitUiObject(self) + self.RectLine = self.PanelNoPassedLine + self.BtnClick.CallBack = function() self:OnBtnClickClick() end +end + +function XUiGridCourse:Refresh(courseData, lastStageId, nextChapterId) + self.CourseData = courseData + self.LastStageId = lastStageId + self.NextChapterId = nextChapterId + + local stageInfo = XDataCenter.FubenManager.GetStageInfo(courseData.StageId) + -- local isPassedLineShow = false + -- local nextStageId = stageInfo.NextStageId + -- if nextStageId and nextStageId > 0 then + -- local nextStageInfo = XDataCenter.FubenManager.GetStageInfo(nextStageId) + -- if nextStageInfo and nextStageInfo.Passed then + -- isPassedLineShow = true + -- end + -- end + -- local preStageInfo = nil + -- if courseData and #courseData.PreStageId > 0 then + -- for k, preStageId in pairs(courseData.PreStageId or {}) do + -- preStageInfo = XDataCenter.FubenManager.GetStageInfo(preStageId) + -- end + -- end + self.PanelNothing.gameObject:SetActive(true) + self.PanelCurDot.gameObject:SetActive(true) + self.PanelDot.gameObject:SetActive(false) + self.PanelReward.gameObject:SetActive(courseData.CouresType == XDataCenter.TaskManager.CourseType.Reward) + self.PanelDesc.gameObject:SetActive(courseData.CouresType == XDataCenter.TaskManager.CourseType.Function) + -- self.PanelPassedLine.gameObject:SetActive(isPassedLineShow) + -- self.PanelNoPassedLine.gameObject:SetActive(courseData.StageId ~= lastStageId) + if courseData.CouresType == XDataCenter.TaskManager.CourseType.Reward then + if stageInfo.Passed then + local canGet = XDataCenter.TaskManager.CheckCourseCanGet(courseData.StageId) + self.PanelFinish.gameObject:SetActive(not canGet) + self.PanelEffect.gameObject:SetActive(canGet) + else + self.PanelFinish.gameObject:SetActive(false) + self.PanelEffect.gameObject:SetActive(false) + end + + local data = { + TemplateId = courseData.ShowId, + Star = 0 + } + if self.CurGrid then + self.CurGrid:Refresh(data) + else + local grid = XUiGridCommon.New(self.RootUi, self.GridCommon) + grid:Refresh(data) + self.CurGrid = grid + end + elseif courseData.CouresType == XDataCenter.TaskManager.CourseType.Function then + self.PanelPassDesc.gameObject:SetActive(stageInfo.Passed) + self.PanelNoPassDesc.gameObject:SetActive(not stageInfo.Passed) + + self.TxtDesc.text = courseData.Tip + self.TxtDescEn.text = courseData.TipEn + self.TxtNoPassDesc.text = courseData.Tip + self.TxtNoPassDescEn.text = courseData.TipEn + end + + self.TxtStage.text = courseData.Name + self.TxtCurStage.text = courseData.Name + self.TxtStage.gameObject:SetActive(not stageInfo.Passed) + self.TxtCurStage.gameObject:SetActive(stageInfo.Passed) + self.EmptyRaycastClick.raycastTarget = stageInfo.Passed + + self:SetRectLine(courseData.CouresType, courseData.NextCouresType) +end + +function XUiGridCourse:SetRectLine(curType, nextType) + local h = self.RectLine.rect.height + local y, z = -68, 0 + local potPostion = PotPostion[curType][nextType] + if potPostion then + self.RectLine.sizeDelta = CS.UnityEngine.Vector2(potPostion.w, h) + self.RectLine.localPosition = CS.UnityEngine.Vector3(potPostion.x, y, z) + end +end + +function XUiGridCourse:OnBtnClickClick() + if self.CourseData.CouresType ~= XDataCenter.TaskManager.CourseType.Reward then + return + end + + local stageInfo = XDataCenter.FubenManager.GetStageInfo(self.CourseData.StageId) + + if stageInfo.Passed then + + local canGet = XDataCenter.TaskManager.CheckCourseCanGet(self.CourseData.StageId) + if canGet then + local rewardList = XRewardManager.GetRewardList(self.CourseData.RewardId) + if rewardList then + local weaponCount = 0 + local chipCount = 0 + for i = 1, #rewardList do + local id = rewardList[i].Id or rewardList[i].TemplateId + if XDataCenter.EquipManager.IsClassifyEqualByTemplateId(id, XEquipConfig.Classify.Weapon) then + weaponCount = weaponCount + 1 + elseif XDataCenter.EquipManager.IsClassifyEqualByTemplateId(id, XEquipConfig.Classify.Awareness) then + chipCount = chipCount + 1 + end + end + + if weaponCount > 0 and XDataCenter.EquipManager.CheckBagCount(weaponCount, XEquipConfig.Classify.Weapon) == false or + chipCount > 0 and XDataCenter.EquipManager.CheckBagCount(chipCount, XEquipConfig.Classify.Awareness) == false then + return + end + end + + local func = function(allRewardGet) + if self.LastStageId and self.NextChapterId then + local lastStageInfo = XDataCenter.FubenManager.GetStageInfo(self.LastStageId) + if allRewardGet and lastStageInfo.Passed then + if self.NextCallBack then + self.NextCallBack(self.NextChapterId) + return + end + end + end + if self.IndexCallBack then self.IndexCallBack() end + self.PanelFinish.gameObject:SetActive(true) + self.PanelEffect.gameObject:SetActive(false) + end + XDataCenter.TaskManager.GetCourseReward(self.CourseData.StageId, func) + else -- 已领取的奖励则弹出详情 + XUiManager.OpenUiTipRewardByRewardId(self.CourseData.RewardId) + end + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTask/XUiGridTask.lua b/Resources/Scripts/XUi/XUiTask/XUiGridTask.lua new file mode 100644 index 00000000..e5cfa58b --- /dev/null +++ b/Resources/Scripts/XUi/XUiTask/XUiGridTask.lua @@ -0,0 +1,261 @@ +XUiGridTask = XClass(nil, "XUiGridTask") + +function XUiGridTask:Ctor(rootUi, ui, data, parentCb) + self.RootUi = rootUi + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.ParentCb = parentCb or function() end + self.RewardPanelList = {} + self:InitAutoScript() + self.GridCommon.gameObject:SetActive(false) + self.ImgComplete.gameObject:SetActive(false) + self:ResetData(data) + self.PanelAnimation.gameObject:SetActive(true) +end + +function XUiGridTask:ResetData(data) + if not self.GameObject:Exist() then + return + end + + local temp = XDataCenter.TaskManager.GetTaskTemplate(data.Id) + self.ImgComplete.gameObject:SetActive(temp.Type == XDataCenter.TaskManager.TaskType.Achievement and data.State == XDataCenter.TaskManager.TaskState.Finish) + self.Data = data + local config = XDataCenter.TaskManager.GetTaskTemplate(self.Data.Id) + self.tableData = config + self.TxtTaskName.text = config.Title + self.TxtTaskDescribe.text = config.Desc + self.TxtSubTypeTip.text = config.Suffix or "" + self.RootUi:SetUiSprite(self.ImgTaskType, config.Icon) + + self:UpdateProgress(self.Data) + + local rewards = XRewardManager.GetRewardList(config.RewardId) + -- reset reward panel + for i = 1, #self.RewardPanelList do + self.RewardPanelList[i]:Refresh() + end + + if not rewards then + return + end + + for i = 1, #rewards do + local panel = self.RewardPanelList[i] + if not panel then + if #self.RewardPanelList == 0 then + panel = XUiGridCommon.New(self.RootUi, self.GridCommon) + else + local ui = CS.UnityEngine.Object.Instantiate(self.GridCommon) + ui.transform:SetParent(self.GridCommon.parent, false) + panel = XUiGridCommon.New(self.RootUi, ui) + end + table.insert(self.RewardPanelList, panel) + end + + panel:Refresh(rewards[i]) + end + +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiGridTask:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiGridTask:AutoInitUi() + self.PanelAnimation = XUiHelper.TryGetComponent(self.Transform, "PanelAnimation", nil) + self.ImgTaskType = XUiHelper.TryGetComponent(self.Transform, "PanelAnimation/ImgTaskType", "Image") + self.ImgProgress = XUiHelper.TryGetComponent(self.Transform, "PanelAnimation/ProgressBg/ImgProgress", "Image") + self.GridCommon = XUiHelper.TryGetComponent(self.Transform, "PanelAnimation/TaskGridList/Viewport/Content/GridCommon", nil) + self.ImgIcon = XUiHelper.TryGetComponent(self.Transform, "PanelAnimation/TaskGridList/Viewport/Content/GridCommon/ImgIcon", "Image") + self.ImgQuality = XUiHelper.TryGetComponent(self.Transform, "PanelAnimation/TaskGridList/Viewport/Content/GridCommon/ImgQuality", "Image") + self.BtnClick = XUiHelper.TryGetComponent(self.Transform, "PanelAnimation/TaskGridList/Viewport/Content/GridCommon/BtnClick", "Button") + self.TxtCount = XUiHelper.TryGetComponent(self.Transform, "PanelAnimation/TaskGridList/Viewport/Content/GridCommon/TxtCount", "Text") + self.BtnFinish = XUiHelper.TryGetComponent(self.Transform, "PanelAnimation/BtnFinish", "Button") + self.BtnSkip = XUiHelper.TryGetComponent(self.Transform, "PanelAnimation/BtnSkip", "Button") + self.TxtTaskName = XUiHelper.TryGetComponent(self.Transform, "PanelAnimation/TxtTaskName", "Text") + self.TxtTaskDescribe = XUiHelper.TryGetComponent(self.Transform, "PanelAnimation/TxtTaskDescribe", "Text") + self.TxtTaskNumQian = XUiHelper.TryGetComponent(self.Transform, "PanelAnimation/TxtTaskNumQian", "Text") + self.TxtSubTypeTip = XUiHelper.TryGetComponent(self.Transform, "PanelAnimation/TxtSubTypeTip", "Text") + self.ImgComplete = XUiHelper.TryGetComponent(self.Transform, "PanelAnimation/ImgComplete", "Image") +end + +function XUiGridTask:GetAutoKey(uiNode, eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiGridTask:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiGridTask:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiGridTask:AutoAddListener() + self.AutoCreateListeners = {} + XUiHelper.RegisterClickEvent(self, self.BtnClick, self.OnBtnClickClick) + XUiHelper.RegisterClickEvent(self, self.BtnFinish, self.OnBtnFinishClick) + XUiHelper.RegisterClickEvent(self, self.BtnSkip, self.OnBtnSkipClick) +end +-- auto +function XUiGridTask:OnBtnClickClick() + +end + + +function XUiGridTask:OnBtnFinishClick() + local weaponCount = 0 + local chipCount = 0 + for i = 1, #self.RewardPanelList do + local rewardsId = self.RewardPanelList[i].TemplateId + if XDataCenter.EquipManager.IsClassifyEqualByTemplateId(rewardsId, XEquipConfig.Classify.Weapon) then + weaponCount = weaponCount + 1 + elseif XDataCenter.EquipManager.IsClassifyEqualByTemplateId(rewardsId, XEquipConfig.Classify.Awareness) then + chipCount = chipCount + 1 + end + end + if weaponCount > 0 and XDataCenter.EquipManager.CheckBagCount(weaponCount, XEquipConfig.Classify.Weapon) == false or + chipCount > 0 and XDataCenter.EquipManager.CheckBagCount(chipCount, XEquipConfig.Classify.Awareness) == false then + return + end + XDataCenter.TaskManager.FinishTask(self.Data.Id, function(rewardGoodsList) + self.ImgComplete.gameObject:SetActive(true) + self.BtnFinish.gameObject:SetActive(false) + + XUiManager.OpenUiObtain(rewardGoodsList, nil, function() + self.ParentCb() + local nextId = XTaskConfig.GetNextTaskId(self.tableData.Id) + local nextTask = nextId and XDataCenter.TaskManager.GetTaskDataById(nextId) + if self.tableData.Type == XDataCenter.TaskManager.TaskType.Achievement then + if nextTask then + self.Data.State = XDataCenter.TaskManager.TaskState.Finish + -- local ui = CS.UnityEngine.Object.Instantiate(self.GameObject, self.Transform.parent) + --local grid = XUiGridTask.New(self.RootUi, ui, self.Data, self.ParentCb) + self:ResetData(nextTask) + else + local parent = self.Transform.parent + local grandParent = parent.parent + self.Transform:SetParent(grandParent) + self.Transform:SetParent(parent) + end + else + if nextTask then + self:ResetData(nextTask) + else + self.GameObject:SetActive(false) + end + end + end, nil) + end) +end + +function XUiGridTask:OnBtnSkipClick() + if XDataCenter.RoomManager.RoomData ~= nil then + local title = CS.XTextManager.GetText("TipTitle") + local cancelMatchMsg = CS.XTextManager.GetText("OnlineInstanceQuitRoom") + XUiManager.DialogTip(title, cancelMatchMsg, XUiManager.DialogType.Normal, nil, function() + XLuaUiManager.RunMain() + local skipId = XDataCenter.TaskManager.GetTaskTemplate(self.Data.Id).SkipId + XFunctionManager.SkipInterface(skipId) + end) + else + local skipId = XDataCenter.TaskManager.GetTaskTemplate(self.Data.Id).SkipId + XFunctionManager.SkipInterface(skipId) + end +end + +function XUiGridTask:UpdateProgress(data) + self.Data = data + local config = XDataCenter.TaskManager.GetTaskTemplate(data.Id) + if #config.Condition < 2 then--显示进度 + self.ImgProgress.transform.parent.gameObject:SetActive(true) + self.TxtTaskNumQian.gameObject:SetActive(true) + local result = config.Result > 0 and config.Result or 1 + XTool.LoopMap(self.Data.Schedule, function(_, pair) + self.ImgProgress.fillAmount = pair.Value / result + self.TxtTaskNumQian.text = pair.Value .. "/" .. result + end) + else + self.ImgProgress.transform.parent.gameObject:SetActive(false) + self.TxtTaskNumQian.gameObject:SetActive(false) + end + + self.BtnFinish.gameObject:SetActive(false) + self.BtnSkip.gameObject:SetActive(false) + + if self.Data.State == XDataCenter.TaskManager.TaskState.Achieved then + self.BtnFinish.gameObject:SetActive(true) + elseif self.Data.State ~= XDataCenter.TaskManager.TaskState.Achieved and self.Data.State ~= XDataCenter.TaskManager.TaskState.Finish then + self.BtnSkip.gameObject:SetActive(true) + end +end + +--==============================-- +--desc: 播放入场动画 +--@cb: 回调 +--@second: 延时回调时间,默认为动画长度 +--==============================-- +function XUiGridTask:PlayEnter(cb, second) + --XUiHelper.PlayAnimation(self.PanelAnimation, "GTEnter") + if not second then + -- local animation = self.Transform:GetComponent("Animation") + -- animation.clip = animation:GetClip("GTEnter") + second = 1 + end + + if cb then + XScheduleManager.Schedule(cb, second * 1000, 1, second * 1000) + end +end + +--==============================-- +--desc: 播放出场动画 +--@cb: 回调 +--@isDelete: 动画结束是否删除对象 +--==============================-- +function XUiGridTask:PlayExit(cb) + --XLog.Debug("XUiGridTask:PlayExit") + cb() + -- if isDelete then + -- CS.UnityEngine.Object.Destroy(self.GameObject) + -- end + -- XUiHelper.PlayAnimation(self.PanelAnimation, "GTExit", nil, function () + -- XLog.Debug("Finish") + -- if cb then + -- cb () + -- end + -- if isDelete then + -- CS.UnityEngine.Object.Destroy(self.GameObject) + -- end + -- end) +end + +function XUiGridTask:RefreshData(task) + --XLog.Debug("XUiGridTask:RefreshData:", task) + self:ResetData(task) + -- self:PlayExit(function () + -- self:ResetData(task) + -- self:PlayEnter(cb, second) + -- end) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTask/XUiPanelActive.lua b/Resources/Scripts/XUi/XUiTask/XUiPanelActive.lua new file mode 100644 index 00000000..09658b70 --- /dev/null +++ b/Resources/Scripts/XUi/XUiTask/XUiPanelActive.lua @@ -0,0 +1,58 @@ +XUiPanelActive = XClass(nil, "XUiPanelActive") + +function XUiPanelActive:Ctor(ui, rootUi, index, parent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.rootUi = rootUi + self.Parent = parent + self.index = index + XTool.InitUiObject(self) + self.BtnActive.CallBack = function() self:OnBtnActiveClick() end +end + +function XUiPanelActive:Refresh() + +end + +function XUiPanelActive:UpdateActiveness(dailyActiveness, dActiveness) + if dailyActiveness <= dActiveness then + self.rootUi:SetUiSprite(self.BtnActive.image, CS.XGame.ClientConfig:GetString("TaskDailyActiveReach" .. self.index)) + self.PanelEffect.gameObject:SetActive(not XPlayer.IsGetDailyActivenessReward(self.index)) + self.ImgRe.gameObject:SetActive(XPlayer.IsGetDailyActivenessReward(self.index)) + else + self.rootUi:SetUiSprite(self.BtnActive.image, CS.XGame.ClientConfig:GetString("TaskDailyActiveNotReach" .. self.index)) + self.PanelEffect.gameObject:SetActive(false) + self.ImgRe.gameObject:SetActive(false) + end + + self.TxtValue.text = dailyActiveness +end + +function XUiPanelActive:OnBtnActiveClick() + self:TouchDailyRewardBtn(self.index) +end + +function XUiPanelActive:TouchDailyRewardBtn(index) + local activeness = XDataCenter.ItemManager.GetDailyActiveness().Count + local dActiveness = XTaskConfig.GetDailyActiveness() + local rewardIds = XTaskConfig.GetDailyActivenessRewardIds() + local data = XRewardManager.GetRewardList(rewardIds[index]) + -- 如果已经领取过了,直接弹提示即可 + if XPlayer.IsGetDailyActivenessReward(index) then + XUiManager.OpenUiTipReward(data, CS.XTextManager.GetText("DailyActiveRewardTitle")) + return + end + if activeness >= dActiveness[index] then + XDataCenter.TaskManager.GetActivenessReward(index, rewardIds[index], XDataCenter.TaskManager.ActiveRewardType.Daily, function() + if index == 5 then + --CheckPoint: APPEVENT_DAILY_TASK + XAppEventManager.AppLogEvent(XAppEventManager.CommonEventNameConfig.Daily_Task) + end + self.Parent:UpdateActiveness() + end) + else + XUiManager.OpenUiTipReward(data, CS.XTextManager.GetText("DailyActiveRewardTitle")) + end +end + +return XUiPanelActive \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTask/XUiPanelCourse.lua b/Resources/Scripts/XUi/XUiTask/XUiPanelCourse.lua new file mode 100644 index 00000000..9af63c5d --- /dev/null +++ b/Resources/Scripts/XUi/XUiTask/XUiPanelCourse.lua @@ -0,0 +1,118 @@ +XUiPanelCourse = XClass(nil, "XUiPanelCourse") +local Vector2 = CS.UnityEngine.Vector2 +local V3Z = CS.UnityEngine.Vector3.zero +local ProTime = 2 + +function XUiPanelCourse:Ctor(rootUi, ui, chapterId, stroyUi) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self.StroyUi = stroyUi + self.GridCourseList = {} + XTool.InitUiObject(self) + + self.GridCourse.gameObject:SetActive(false) + self:RefreshCourseList(chapterId) + +end + +function XUiPanelCourse:RefreshCourse() + self:RefreshCourseList(self.ChapterId) +end +function XUiPanelCourse:RefreshCourseList(chapterId) + if not chapterId then return end + self.CourseInfo = XDataCenter.TaskManager.GetCourseInfo(chapterId) + self.ChapterId = chapterId + self.SViewCourse.horizontalNormalizedPosition = 0 + + self.CurPrIndex = 0 + local index = 0 + local list = self.CourseInfo.Courses + for i = 1, #list do + local grid = self.GridCourseList[i] + if not grid then + local ui = CS.UnityEngine.Object.Instantiate(self.GridCourse) + grid = XUiGridCourse.New(self.RootUi, ui, self.StroyUi, function(cId) + self:RefreshCourseList(cId) + end, function() + -- self:SetSViewIndex() + end) + grid.GameObject.name = list[i].StageId + grid.Transform:SetParent(self.PanelCourseContainer, false) + self.GridCourseList[i] = grid + end + + local stageInfo = XDataCenter.FubenManager.GetStageInfo(list[i].StageId) + if self:IsPass(list[i].StageId) or (stageInfo and stageInfo.Passed) then + self.CurPrIndex = index + end + + grid:Refresh(list[i], self.CourseInfo.LastStageId, self.CourseInfo.NextChapterId) + grid.GameObject:SetActive(true) + index = index + 1 + end + + for i = #list + 1, #self.GridCourseList do + self.GridCourseList[i].GameObject:SetActive(false) + end + + local prowidth = (self.GridCourse.sizeDelta.x + self.PanelCourseContainerLayout.spacing) * (index - 1) + local contentwidth = prowidth + self.GridCourse.sizeDelta.x + self.PanelCourseContainerLayout.padding.left + self.Container.sizeDelta = Vector2(contentwidth, self.GridCourse.sizeDelta.y) + self.ProgressBgRec.sizeDelta = Vector2(prowidth, self.ImgProgressRec.sizeDelta.y) + self.ImgProgressRec.sizeDelta = Vector2(prowidth, self.ImgProgressRec.sizeDelta.y) + self.ProgressBgRec:SetParent(self.GridCourseList[1].ProGo, true) + self.ProgressBgRec.localPosition = V3Z + + self:SetSViewIndex() + self:PlayImgFill() +end + +function XUiPanelCourse:IsPass(id) + if not id then + return false + end + + local result = XDataCenter.FubenManager.FubenSettleResult + return result and result.IsWin and result.StageId == id +end + +function XUiPanelCourse:SetSViewIndex() + if not self.CourseInfo then return end + local rewardIndex = XDataCenter.TaskManager.GetCourseCurRewardIndex(self.ChapterId) + local length = #self.CourseInfo.Courses or 0 + if rewardIndex then + if rewardIndex <= 1 then + rewardIndex = 0 + elseif rewardIndex >= 16 then + rewardIndex = 1 + end + + local percentage = 0 + if length > 0 then + percentage = (rewardIndex - 1) / length + end + self.SViewCourse.horizontalNormalizedPosition = percentage + CS.UnityEngine.Canvas.ForceUpdateCanvases() + end + self.CurLen = length +end + +function XUiPanelCourse:FillPro(v) + self.ImgProgress.fillAmount = v or 0 +end + +function XUiPanelCourse:PlayImgFill() + local r = 0 + if self.CurPrIndex and self.CurLen and self.CurPrIndex > 0 and self.CurLen > 1 then + r = (self.CurPrIndex) / (self.CurLen - 1) + end + + if r == self.CurRa then + return + end + + self.CurRa = r + self:FillPro() + self.ImgProgress:DOFillAmount(r, ProTime) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTask/XUiPanelCourseReward.lua b/Resources/Scripts/XUi/XUiTask/XUiPanelCourseReward.lua new file mode 100644 index 00000000..b5d98aaa --- /dev/null +++ b/Resources/Scripts/XUi/XUiTask/XUiPanelCourseReward.lua @@ -0,0 +1,45 @@ +XUiPanelCourseReward = XClass(nil, "XUiPanelCourseReward") + +function XUiPanelCourseReward:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + XTool.InitUiObject(self) + self.GridRewardList = {} + self.BtnComfirm.CallBack = function() self:OnBtnComfirmClick() end + self.GridReward.gameObject:SetActive(false) +end + +function XUiPanelCourseReward:OnBtnComfirmClick() + self:HidePanel() +end + +function XUiPanelCourseReward:ShowPanel(rewardId, name) + local rewardList = XRewardManager.GetRewardList(rewardId) + + for i = 1, #rewardList do + local grid = self.GridRewardList[i] + if not grid then + local ui = CS.UnityEngine.Object.Instantiate(self.GridReward) + grid = XUiGridCommon.New(self.RootUi, ui) + grid.Transform:SetParent(self.PanelRewardContent, false) + self.GridRewardList[i] = grid + end + + grid:Refresh(rewardList[i]) + grid.GameObject:SetActive(true) + end + + for i = #rewardList + 1, #self.GridRewardList do + self.GridRewardList[i].GameObject:SetActive(false) + end + + local text = CS.XTextManager.GetText("CoureDesc", name) + self.TxtDesc.text = text + + self.GameObject:SetActive(true) +end + +function XUiPanelCourseReward:HidePanel() + self.GameObject:SetActive(false) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTask/XUiPanelTaskActivity.lua b/Resources/Scripts/XUi/XUiTask/XUiPanelTaskActivity.lua new file mode 100644 index 00000000..308e09be --- /dev/null +++ b/Resources/Scripts/XUi/XUiTask/XUiPanelTaskActivity.lua @@ -0,0 +1,42 @@ +XUiPanelTaskActivity = XClass(nil, "XUiPanelTaskActivity") + +function XUiPanelTaskActivity:Ctor(ui, parent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Parent = parent + XTool.InitUiObject(self) + + self.DynamicTable = XDynamicTableNormal.New(self.PanelTaskActivityList) + self.DynamicTable:SetProxy(XDynamicGridTask) + self.DynamicTable:SetDelegate(self) +end + +function XUiPanelTaskActivity:ShowPanel() + self.GameObject:SetActive(true) + + self.ActivityTasks = XDataCenter.TaskManager.GetActivityTaskList() + self.PanelNoneActivityTask.gameObject:SetActive(#self.ActivityTasks <= 0) + self.DynamicTable:SetDataSource(self.ActivityTasks) + self.DynamicTable:ReloadDataASync(1) +end + +function XUiPanelTaskActivity:HidePanel() + self.GameObject:SetActive(false) +end + +function XUiPanelTaskActivity:Refresh() + self.ActivityTasks = XDataCenter.TaskManager.GetActivityTaskList() + self.PanelNoneActivityTask.gameObject:SetActive(#self.ActivityTasks <= 0) + self.DynamicTable:SetDataSource(self.ActivityTasks) + self.DynamicTable:ReloadDataASync() +end + + +--动态列表事件 +function XUiPanelTaskActivity:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.ActivityTasks[index] + grid.RootUi = self.Parent + grid:ResetData(data) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTask/XUiPanelTaskDaily.lua b/Resources/Scripts/XUi/XUiTask/XUiPanelTaskDaily.lua new file mode 100644 index 00000000..2175d8ac --- /dev/null +++ b/Resources/Scripts/XUi/XUiTask/XUiPanelTaskDaily.lua @@ -0,0 +1,179 @@ +XUiPanelTaskDaily = XClass(nil, "XUiPanelTaskDaily") + +local DailyTimeSchedule = nil +local ProTime = 2 +local GridTimeAnimation = 50 + +function XUiPanelTaskDaily:Ctor(ui, parent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Parent = parent + + XTool.InitUiObject(self) + self.BtnWeekActive.CallBack = function() self:OnBtnBackClick() end + + self.PanelActive.gameObject:SetActiveEx(false) + self:InitPanelActiveGrid() + self.ItemObjList = {} + + -- 自适应调整 + self.OriginPosition = self.PanelActiveGrids[1].Transform.localPosition + self.ActiveProgressRect = self.ImgDaylyActiveProgress:GetComponent("RectTransform") + self.ActiveProgressPosition = self.ImgDaylyActiveProgress.transform.localPosition + self.OffsetPanelPosition = self.PanelContent.localPosition + self.PanelDailyListRect = self.PanelTaskDailyList + + -- self:UpdateActiveness() + self:ShowDailyPanel() + + self.DynamicTable = XDynamicTableNormal.New(self.PanelTaskDailyList.gameObject) + self.DynamicTable:SetProxy(XDynamicDailyTask) + self.DynamicTable:SetDelegate(self) + + XRedPointManager.AddRedPointEvent(self.ImgWeek, self.CheckWeeKActiveRedDot, self, { XRedPointConditions.Types.CONDITION_TASK_WEEK_ACTIVE }) + XDataCenter.ItemManager.AddCountUpdateListener(XDataCenter.ItemManager.ItemId.DailyActiveness, function() + self:UpdateActiveness() + self.Parent:CheckDailyTask() + end, self.TxtDailyActive) +end + +--动态列表事件 +function XUiPanelTaskDaily:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.DailyTasks[index] + if data == nil then return end + grid.RootUi = self.Parent + grid:ResetData(data) + self.GridCount = self.GridCount + 1 + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_RELOAD_COMPLETED then + if not self.IsPlayAnimation then + return + end + + local grids = self.DynamicTable:GetGrids() + self.GridIndex = 1 + self.CurAnimationTimerId = XScheduleManager.Schedule(function() + local item = grids[self.GridIndex] + if item then + item.GameObject:SetActiveEx(true) + item:PlayAnimation() + end + self.GridIndex = self.GridIndex + 1 + end, GridTimeAnimation, self.GridCount, 0) + end +end + +-- +function XUiPanelTaskDaily:CheckWeeKActiveRedDot(count) + self.ImgWeek.gameObject:SetActiveEx(count >= 0) +end + +function XUiPanelTaskDaily:InitPanelActiveGrid() + self.PanelActiveGrids = {} + self.PanelActiveGridRects = {} + for i = 1, 5, 1 do + local grid = self.PanelActiveGrids[i] + if not grid then + if i == 1 then + grid = XUiPanelActive.New(self.PanelActive, self.Parent, i, self) + else + local activeGO = CS.UnityEngine.Object.Instantiate(self.PanelActive) + activeGO.transform:SetParent(self.PanelContent, false) + grid = XUiPanelActive.New(activeGO, self.Parent, i, self) + end + self.PanelActiveGrids[i] = grid + self.PanelActiveGridRects[i] = grid.Transform:GetComponent("RectTransform") + end + end +end + +function XUiPanelTaskDaily:UpdateActiveness() + local dActiveness = XDataCenter.ItemManager.GetDailyActiveness().Count + local dailyActiveness = XTaskConfig.GetDailyActiveness() + local dailyActivenessTotal = XTaskConfig.GetDailyActivenessTotal() + + if dailyActivenessTotal > 0 then + local fillAmount = dActiveness / dailyActivenessTotal + if self.Curfillamount ~= fillAmount then + self.ImgDaylyActiveProgress:DOFillAmount(fillAmount, ProTime) + self.Curfillamount = fillAmount + end + end + + self.TxtDailyActive.text = dActiveness + for i = 1, 5 do + self.PanelActiveGrids[i]:UpdateActiveness(dailyActiveness[i], dActiveness) + end + + -- 自适应 + local activeProgressRectSize = self.ActiveProgressRect.rect.size + local offsetWidth = self.OffsetPanelPosition.x - self.ActiveProgressPosition.x + local itemOffset = activeProgressRectSize.x / #self.PanelActiveGrids + for i = 1, #self.PanelActiveGrids do + local itemWidth = self.PanelActiveGridRects[i].sizeDelta.x / 2 + local adjustPosition = CS.UnityEngine.Vector3(self.ActiveProgressPosition.x + i * itemOffset - offsetWidth - itemWidth, self.OriginPosition.y, self.OriginPosition.z) + self.PanelActiveGridRects[i].anchoredPosition3D = adjustPosition + self.PanelActiveGridRects[i].gameObject:SetActiveEx(true) + end +end + +function XUiPanelTaskDaily:OnBtnBackClick() + self:ShowDailyPanel() +end + +function XUiPanelTaskDaily:ShowDailyPanel() + self.PanelDaily.gameObject:SetActiveEx(true) +end + +function XUiPanelTaskDaily:ShowPanel(isPlayAnimation) + self.GridCount = 0 + self.IsPlayAnimation = isPlayAnimation + self:StartSchedule() + self.GameObject:SetActiveEx(true) + + local tasks = XDataCenter.TaskManager.GetDailyTaskList() + self.DailyTasks = tasks + self.PanelNoneDailyTask.gameObject:SetActiveEx(#self.DailyTasks <= 0) + self.DynamicTable:SetDataSource(tasks) + self.DynamicTable:ReloadDataASync() +end + +function XUiPanelTaskDaily:HidePanel() + self.IsPlayAnimation = false + self:StopSchedule() + self.GameObject:SetActiveEx(false) +end + +function XUiPanelTaskDaily:Refresh() + local tasks = XDataCenter.TaskManager.GetDailyTaskList() + self.DailyTasks = tasks + self.PanelNoneDailyTask.gameObject:SetActiveEx(#self.DailyTasks <= 0) + self.DynamicTable:SetDataSource(tasks) + self.DynamicTable:ReloadDataSync() + self:UpdateActiveness() +end + +function XUiPanelTaskDaily:StartSchedule() + self:StopSchedule() + DailyTimeSchedule = XScheduleManager.ScheduleForever(function() + if self.DynamicTable then + for i = 1, #self.DailyTasks do + local grid = self.DynamicTable:GetGridByIndex(i) + if grid then + grid:UpdateTimes() + end + end + end + end, 1000 * 60) +end + +function XUiPanelTaskDaily:StopSchedule() + if DailyTimeSchedule then + XScheduleManager.UnSchedule(DailyTimeSchedule) + DailyTimeSchedule = nil + end + if self.CurAnimationTimerId then + XScheduleManager.UnSchedule(self.CurAnimationTimerId) + self.CurAnimationTimerId = nil + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTask/XUiPanelTaskStory.lua b/Resources/Scripts/XUi/XUiTask/XUiPanelTaskStory.lua new file mode 100644 index 00000000..6130cf39 --- /dev/null +++ b/Resources/Scripts/XUi/XUiTask/XUiPanelTaskStory.lua @@ -0,0 +1,115 @@ +XUiPanelTaskStory = XClass(nil, "XUiPanelTaskStory") +local GridTimeAnimation = 50 + +function XUiPanelTaskStory:Ctor(ui, parent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Parent = parent + + XTool.InitUiObject(self) + + local finalChapterId = XDataCenter.TaskManager.GetFinalChapterId() + local curChapterId = XDataCenter.TaskManager.GetCourseCurChapterId() or finalChapterId + self.Course = XUiPanelCourse.New(self.Parent, self.PanelCourse, curChapterId, self) + self.CourseReward = XUiPanelCourseReward.New(self.Parent, self.PanelCourseReward) + + self.DynamicTable = XDynamicTableNormal.New(self.PanelTaskStoryList.gameObject) + self.DynamicTable:SetProxy(XDynamicGridTask) + self.DynamicTable:SetDelegate(self) +end + +--动态列表事件 +function XUiPanelTaskStory:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.StoryTasks[index] + grid.RootUi = self.Parent + grid:ResetData(data) + self.GridCount = self.GridCount + 1 + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_RELOAD_COMPLETED then + if not self.IsPlayAnimation then + return + end + + local grids = self.DynamicTable:GetGrids() + self.GridIndex = 1 + self.CurAnimationTimerId = XScheduleManager.Schedule(function() + local item = grids[self.GridIndex] + if item then + item.GameObject:SetActive(true) + item:PlayAnimation() + end + self.GridIndex = self.GridIndex + 1 + end, GridTimeAnimation, self.GridCount, 0) + end +end + +function XUiPanelTaskStory:ShowPanel(isPlayAnimation) + self.GridCount = 0 + self.IsPlayAnimation = isPlayAnimation + self.GameObject:SetActive(true) + self.PanelTaskStoryList.gameObject:SetActive(true) + + self.StoryTasks = self:SortTaskByGroup(XDataCenter.TaskManager.GetStoryTaskList()) + + self.PanelNoneStoryTask.gameObject:SetActive(#self.StoryTasks <= 0) + self.DynamicTable:SetDataSource(self.StoryTasks) + self.DynamicTable:ReloadDataASync() + self.Course:SetSViewIndex() + self.Course:PlayImgFill() +end + +function XUiPanelTaskStory:HidePanel() + if self.CurAnimationTimerId then + XScheduleManager.UnSchedule(self.CurAnimationTimerId) + self.CurAnimationTimerId = nil + end + self.IsPlayAnimation = false + self.GameObject:SetActive(false) +end + +function XUiPanelTaskStory:ShowCourseReward(rewardId, name) + self.CourseReward:ShowPanel(rewardId, name) +end + +function XUiPanelTaskStory:Refresh() + self.StoryTasks = self:SortTaskByGroup(XDataCenter.TaskManager.GetStoryTaskList()) + + self.PanelNoneStoryTask.gameObject:SetActive(#self.StoryTasks <= 0) + self.DynamicTable:SetDataSource(self.StoryTasks) + self.DynamicTable:ReloadDataSync() +end + +function XUiPanelTaskStory:RefreshCourse() + self.Course:RefreshCourse() +end + +function XUiPanelTaskStory:SortTaskByGroup(tasks) + local currTaskGroupId = XDataCenter.TaskManager.GetCurrentStoryTaskGroupId() + if currTaskGroupId == nil or currTaskGroupId <= 0 then return tasks end + + local sortedTasks = {} + -- 过滤,留下组id相同,没有组id的任务 + for _, v in pairs(tasks) do + local templates = XDataCenter.TaskManager.GetTaskTemplate(v.Id) + if templates.GroupId <= 0 or templates.GroupId == currTaskGroupId then + + v.SortWeight = 1 + v.SortWeight = (templates.GroupId > 0) and 2 or v.SortWeight + v.SortWeight = (v.State == XDataCenter.TaskManager.TaskState.Achieved) and 3 or v.SortWeight + v.SortWeight = (templates.GroupTheme == 1) and 4 or v.SortWeight + table.insert(sortedTasks, v) + end + end + + -- 排序,主题任务,可领取的任务,不能领取的任务 + table.sort(sortedTasks, function(taskA, taskB) + local templatesTaskA = XDataCenter.TaskManager.GetTaskTemplate(taskA.Id) + local templatesTaskB = XDataCenter.TaskManager.GetTaskTemplate(taskB.Id) + if taskA.SortWeight == taskB.SortWeight then + return templatesTaskA.Priority > templatesTaskB.Priority + end + return taskA.SortWeight > taskB.SortWeight + end) + + return sortedTasks +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTask/XUiPanelTaskWeekly.lua b/Resources/Scripts/XUi/XUiTask/XUiPanelTaskWeekly.lua new file mode 100644 index 00000000..7ee068a4 --- /dev/null +++ b/Resources/Scripts/XUi/XUiTask/XUiPanelTaskWeekly.lua @@ -0,0 +1,46 @@ +XUiPanelTaskWeekly = XClass(nil, "XUiPanelTaskWeekly") + +function XUiPanelTaskWeekly:Ctor(ui, parent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Parent = parent + XTool.InitUiObject(self) + + self.DynamicTable = XDynamicTableNormal.New(self.PanelTaskWeeklyList) + self.DynamicTable:SetProxy(XDynamicDailyTask) + self.DynamicTable:SetDelegate(self) +end + +function XUiPanelTaskWeekly:ShowPanel() + self.GameObject:SetActive(true) + + self.WeeklyTasks = self:GetWeeklyTasks() + self.PanelNoneWeeklyTask.gameObject:SetActive(#self.WeeklyTasks <= 0) + self.DynamicTable:SetDataSource(self.WeeklyTasks) + self.DynamicTable:ReloadDataASync() +end + +function XUiPanelTaskWeekly:HidePanel() + self.GameObject:SetActive(false) +end + +function XUiPanelTaskWeekly:Refresh() + self.WeeklyTasks = self:GetWeeklyTasks() + self.PanelNoneWeeklyTask.gameObject:SetActive(#self.WeeklyTasks <= 0) + self.DynamicTable:SetDataSource(self.WeeklyTasks) + self.DynamicTable:ReloadDataSync() +end + + +--动态列表事件 +function XUiPanelTaskWeekly:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.WeeklyTasks[index] + grid.RootUi = self.Parent + grid:ResetData(data) + end +end + +function XUiPanelTaskWeekly:GetWeeklyTasks() + return XDataCenter.TaskManager.GetWeeklyTaskList() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTask/XUiTask.lua b/Resources/Scripts/XUi/XUiTask/XUiTask.lua new file mode 100644 index 00000000..09aa6582 --- /dev/null +++ b/Resources/Scripts/XUi/XUiTask/XUiTask.lua @@ -0,0 +1,279 @@ +local XUiTask = XLuaUiManager.Register(XLuaUi, "UiTask") +local MaintainerActionIcon = CS.XGame.ClientConfig:GetString("MaintainerActionIconInTaskUI") +local PANEL_INDEX = { + Story = 1, + Daily = 2, + Weekly = 3, + Activity = 4, +} + +function XUiTask:OnAwake() + self:InitBtnSound() +end + +function XUiTask:OnStart(toggleType) + local lastSelectTab = XDataCenter.TaskManager.GetNewPlayerHint(XDataCenter.TaskManager.TaskLastSelectTab, PANEL_INDEX.Story) + self.CurToggleType = toggleType or lastSelectTab + + XEventManager.AddEventListener(XEventId.EVENT_FINISH_TASK, self.OnTaskChangeSync, self) + XEventManager.AddEventListener(XEventId.EVENT_TASK_TAB_CHANGE, self.OnTaskChangeTab, self) + XEventManager.AddEventListener(XEventId.EVENT_TASK_FINISH_FAIL, self.OnTaskChangeSync, self) + + self:Init() + -- self.IsStartAnimation = true +end + +function XUiTask:OnEnable() + self:CheckTogLockStatus() + self:CheckFunctionalFilter() + self:SetupBountyTask() + self:AddRedPointEvent() + self.TabPanelGroup:SelectIndex(self.CurToggleType) + self:PlayAnimation("AnimStartEnable") + if self.TaskStoryModule then + self.TaskStoryModule:RefreshCourse() + end +end + +function XUiTask:Init() + self.AssetPanel = XUiPanelAsset.New(self, self.PanelAsset, + XDataCenter.ItemManager.ItemId.FreeGem, XDataCenter.ItemManager.ItemId.ActionPoint, XDataCenter.ItemManager.ItemId.Coin) + + self.BtnBack.CallBack = function() self:Close() end + self.BtnMainUi.CallBack = function() XLuaUiManager.RunMain() end + + + self.BtnMoneyReward.CallBack = function() self:OnBtnMoneyRewardClick() end + + self.TaskStoryModule = XUiPanelTaskStory.New(self.PanelTaskStory, self) + self.TaskDailyModule = XUiPanelTaskDaily.New(self.PanelTaskDaily, self) + self.TaskWeeklyModule = XUiPanelTaskWeekly.New(self.PanelTaskWeekly, self) + self.TaskActivityModule = XUiPanelTaskActivity.New(self.PanelTaskActivity, self) + + self.TabList = {} + table.insert(self.TabList, self.TogStory) + table.insert(self.TabList, self.TogDaily) + table.insert(self.TabList, self.TogWeekly) + table.insert(self.TabList, self.TogActivity) + self.TabPanelGroup:Init(self.TabList, function(index) self:OnTaskPanelSelect(index) end) + local lastSelectTab = XDataCenter.TaskManager.GetNewPlayerHint(XDataCenter.TaskManager.TaskLastSelectTab, PANEL_INDEX.Story) + self.CurToggleType = self.CurToggleType or lastSelectTab + + -- 红点 + self:AddRedPointEvent() +end + +function XUiTask:CheckTogLockStatus() + local dailyBtnStatus = XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.TaskDay) and CS.UiButtonState.Normal + or CS.UiButtonState.Disable + self.TogDaily:SetButtonState(dailyBtnStatus) + + local weeklyBtnStatus = XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.TaskWeekly) and CS.UiButtonState.Normal + or CS.UiButtonState.Disable + self.TogWeekly:SetButtonState(weeklyBtnStatus) + + local status = XFunctionManager.JudgeCanOpen(XFunctionManager.FunctionName.TaskActivity) and CS.UiButtonState.Normal + or CS.UiButtonState.Disable + + self.TogActivity:SetButtonState(status) +end + +function XUiTask:CheckFunctionalFilter() + self.TogStory.gameObject:SetActiveEx(not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.TaskStory)) + self.TogDaily.gameObject:SetActiveEx(not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.TaskDay)) + self.TogWeekly.gameObject:SetActiveEx(not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.TaskWeekly)) + self.TogActivity.gameObject:SetActiveEx(not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.TaskActivity)) +end + +function XUiTask:OnTaskChangeSync() + if self.CurToggleType == PANEL_INDEX.Story then + self.TaskStoryModule:Refresh() + elseif self.CurToggleType == PANEL_INDEX.Daily then + self.TaskDailyModule:Refresh() + elseif self.CurToggleType == PANEL_INDEX.Weekly then + self.TaskWeeklyModule:Refresh() + elseif self.CurToggleType == PANEL_INDEX.Activity then + self.TaskActivityModule:Refresh() + end +end + +--赏金 +function XUiTask:SetupBountyTask() + self.BtnMoneyRewardImage:SetSprite(MaintainerActionIcon) + local IsOpen = not XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.MaintainerAction) and + XFunctionManager.JudgeOpen(XFunctionManager.FunctionName.MaintainerAction) + self.BtnMoneyReward.gameObject:SetActiveEx(IsOpen) + self.ImgCompleted.gameObject:SetActiveEx(false) + local IsStart = XDataCenter.MaintainerActionManager.IsStart() + local IsShowRed = false + if IsStart then + local IsActionPointOver = XDataCenter.MaintainerActionManager.CheckIsActionPointOver() + local IsAllComplete = XDataCenter.MaintainerActionManager.CheckIsAllComplete() + IsShowRed = not IsAllComplete and not IsActionPointOver + end + self.ImgRedTag.gameObject:SetActiveEx(IsShowRed) +end + +function XUiTask:OnDisable() + self.PreToggleType = nil + self.TaskStoryModule:HidePanel() + self.TaskDailyModule:HidePanel() + self.TaskWeeklyModule:HidePanel() +end + +function XUiTask:OnDestroy() + XDataCenter.TaskManager.UpdateViewCallback = nil + XEventManager.RemoveEventListener(XEventId.EVENT_FINISH_TASK, self.OnTaskChangeSync, self) + XEventManager.RemoveEventListener(XEventId.EVENT_TASK_TAB_CHANGE, self.OnTaskChangeTab, self) + XEventManager.RemoveEventListener(XEventId.EVENT_TASK_FINISH_FAIL, self.OnTaskChangeSync, self) + self.TaskDailyModule:StopSchedule() +end + +--添加点事件 +function XUiTask:AddRedPointEvent() + XRedPointManager.AddRedPointEvent(self.ImgStoryNewTag, self.RefreshStoryTabRedDot, self, + { XRedPointConditions.Types.CONDITION_TASK_TYPE, XRedPointConditions.Types.CONDITION_TASK_COURSE }, XDataCenter.TaskManager.TaskType.Story) + + self.DailyPointId = XRedPointManager.AddRedPointEvent(self.ImgDailyNewTag, self.RefreshDailyTabRedDot, self, + { XRedPointConditions.Types.CONDITION_TASK_TYPE }, XDataCenter.TaskManager.TaskType.Daily) + + XRedPointManager.AddRedPointEvent(self.ImgWeeklyNewTag, self.RefreshWeeklyTabRedDot, self, + { XRedPointConditions.Types.CONDITION_TASK_TYPE }, {XDataCenter.TaskManager.TaskType.Weekly, XDataCenter.TaskManager.TaskType.ArenaOnlineWeekly, XDataCenter.TaskManager.TaskType.InfestorWeekly}) + + XRedPointManager.AddRedPointEvent(self.ImgActivetyNewTag, self.RefreshActivityTabRedDot, self, + { XRedPointConditions.Types.CONDITION_TASK_TYPE }, XDataCenter.TaskManager.TaskType.Activity) +end + +function XUiTask:CheckDailyTask() + if self.DailyPointId then + -- 主界面任务红点检查 + XEventManager.DispatchEvent(XEventId.EVENT_TASK_SYNC) + + -- 任务界面红点检查 + XRedPointManager.Check(self.DailyPointId, XDataCenter.TaskManager.TaskType.Daily) + end +end + +--剧情标签红点 +function XUiTask:RefreshStoryTabRedDot(count) + self.ImgStoryNewTag.gameObject:SetActive(count >= 0) +end + +--日常标签红点 +function XUiTask:RefreshDailyTabRedDot(count) + self.ImgDailyNewTag.gameObject:SetActive(count >= 0) +end + +-- 每周标签红点 +function XUiTask:RefreshWeeklyTabRedDot(count) + self.ImgWeeklyNewTag.gameObject:SetActive(count >= 0) +end + +--活动标签红点 +function XUiTask:RefreshActivityTabRedDot(count) + self.ImgActivetyNewTag.gameObject:SetActive(count >= 0) +end + +function XUiTask:GetAutoKey(uiNode, eventName) + if not uiNode then + return + end + return eventName .. uiNode:GetHashCode() +end + +function XUiTask:OnBtnMoneyRewardClick() + XDataCenter.FunctionalSkipManager.OnOpenMaintainerAction() +end + +function XUiTask:InitBtnSound() + self.SpecialSoundMap = {} + self.SpecialSoundMap[self:GetAutoKey(self.BtnBack, "onClick")] = XSoundManager.UiBasicsMusic.Return + self.SpecialSoundMap[self:GetAutoKey(self.BtnMainUi, "onClick")] = XSoundManager.UiBasicsMusic.Return +end + +function XUiTask:OnTaskChangeTab(index) + self.TabPanelGroup:SelectIndex(index) +end + +function XUiTask:OnTaskPanelSelect(index) + if self.PreToggleType == index then + return + end + + if self.IsFirstAnimation == nil then + self.IsFirstAnimation = true + else + self.IsFirstAnimation = false + end + + self.PreToggleType = index + self.CurToggleType = index + if index == PANEL_INDEX.Story then + if XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.TaskStory) then + self.TaskStoryModule:HidePanel() + return + end + + self.TaskDailyModule:HidePanel() + self.TaskWeeklyModule:HidePanel() + self.TaskActivityModule:HidePanel() + self.TaskStoryModule:ShowPanel(self.IsFirstAnimation) + + XDataCenter.TaskManager.SaveNewPlayerHint(XDataCenter.TaskManager.TaskLastSelectTab, index) + self:PlayAnimation("TaskStoryQieHuan") + + elseif index == PANEL_INDEX.Daily then + if XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.TaskDay) then + self.TaskDailyModule:HidePanel() + return + end + + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.TaskDay) then + return + end + + self.TaskStoryModule:HidePanel() + self.TaskWeeklyModule:HidePanel() + self.TaskActivityModule:HidePanel() + self.TaskDailyModule:ShowPanel(self.IsFirstAnimation) + XDataCenter.TaskManager.SaveNewPlayerHint(XDataCenter.TaskManager.TaskLastSelectTab, index) + + self:PlayAnimation("TaskDailyQieHuan", function() + self.TaskDailyModule:UpdateActiveness() + end) + + elseif index == PANEL_INDEX.Weekly then + if XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.TaskWeekly) then + self.TaskWeeklyModule:HidePanel() + return + end + + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.TaskWeekly) then + return + end + + self.TaskDailyModule:HidePanel() + self.TaskStoryModule:HidePanel() + self.TaskActivityModule:HidePanel() + self.TaskWeeklyModule:ShowPanel() + XDataCenter.TaskManager.SaveNewPlayerHint(XDataCenter.TaskManager.TaskLastSelectTab, index) + self:PlayAnimation("TaskWeeklyQieHuan") + + elseif index == PANEL_INDEX.Activity then + if XFunctionManager.CheckFunctionFitter(XFunctionManager.FunctionName.TaskActivity) then + self.TaskActivityModule:HidePanel() + return + end + + if not XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.TaskActivity) then + return + end + + self.TaskDailyModule:HidePanel() + self.TaskStoryModule:HidePanel() + self.TaskWeeklyModule:HidePanel() + self.TaskActivityModule:ShowPanel() + XDataCenter.TaskManager.SaveNewPlayerHint(XDataCenter.TaskManager.TaskLastSelectTab, index) + self:PlayAnimation("TaskActivityQieHuan") + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTest/XUiTest.lua b/Resources/Scripts/XUi/XUiTest/XUiTest.lua new file mode 100644 index 00000000..517fc36b --- /dev/null +++ b/Resources/Scripts/XUi/XUiTest/XUiTest.lua @@ -0,0 +1,67 @@ +local XUiTest = XUiManager.Register("UiTest") + +function XUiTest:OnOpen() + self:InitAutoScript() + self:Test() +end + +function XUiTest:Test() + local count = 10 + local baseItem = self.GridItem + baseItem.gameObject:SetActive(false) + + local scrollItems = {} + for i = 1, count do + local item = CS.UnityEngine.Object.Instantiate(baseItem) + table.insert(scrollItems, XScrollFlowGrid.New(item, i)) + end + + XScrollFlow.New(self.PanelScorll, scrollItems, {selectIndex = 1, moveEndCb = function(item) XLog.Debug(item.Index) end, direction = XScrollConfig.VERTICAL, offsetValue = 0.2, animSpeed = 2.0, isLoop = true}) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiTest:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiTest:AutoInitUi() + self.PanelScorll = self.Transform:Find("PanelScorll") + self.GridItem = self.Transform:Find("PanelScorll/GridItem") + self.TxtId = self.Transform:Find("PanelScorll/GridItem/TxtId"):GetComponent("Text") +end + +function XUiTest:GetAutoKey(uiNode,eventName) + if not uiNode then return end + return eventName .. uiNode:GetHashCode() +end + +function XUiTest:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then return end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiTest:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key],eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiTest:AutoAddListener() + self.AutoCreateListeners = {} +end +-- auto \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTip/XUiGridSkip.lua b/Resources/Scripts/XUi/XUiTip/XUiGridSkip.lua new file mode 100644 index 00000000..088e8301 --- /dev/null +++ b/Resources/Scripts/XUi/XUiTip/XUiGridSkip.lua @@ -0,0 +1,39 @@ +XUiGridSkip = XClass(nil, "XUiGridSkip") + +function XUiGridSkip:Ctor(rootUi, ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.RootUi = rootUi + self:InitAutoScript() +end + +function XUiGridSkip:InitAutoScript() + XTool.InitUiObject(self) + self.BtnSkip.CallBack = function() + XFunctionManager.SkipInterface(self.SkipId) + if self.SkipCb then + self.SkipCb() + end + end +end + +function XUiGridSkip:Refresh(skipId, hideSkipBtn, skipCb) + if not skipId then + self.GameObject:SetActive(false) + return + end + self.GameObject:SetActive(true) + + self.SkipId = skipId + self.SkipCb = skipCb + + local canSkip = XFunctionManager.IsCanSkip(skipId) + local template = XFunctionConfig.GetSkipList(skipId) + self.TxtNameOn.text = template.Explain + if hideSkipBtn then + self.BtnSkip.gameObject:SetActive(false) + else + self.BtnSkip.gameObject:SetActive(true) + self.BtnSkip:SetDisable(not canSkip) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTip/XUiTip.lua b/Resources/Scripts/XUi/XUiTip/XUiTip.lua new file mode 100644 index 00000000..a30edf4e --- /dev/null +++ b/Resources/Scripts/XUi/XUiTip/XUiTip.lua @@ -0,0 +1,270 @@ +local type = type + +local XUiTip = XLuaUiManager.Register(XLuaUi, "UiTip") + +function XUiTip:OnAwake() + self:InitAutoScript() +end + +function XUiTip:OnStart(data, hideSkipBtn, rootUiName) + local musicKey = self:GetAutoKey(self.BtnBack, "onClick") + self.SpecialSoundMap[musicKey] = XSoundManager.UiBasicsMusic.Return + self.HideSkipBtn = hideSkipBtn + self.RootUiName = rootUiName + self.Data = data + self:PlayAnimation("AnimStart") +end + +function XUiTip:OnEnable() + self:Refresh(self.Data) +end + + +-- auto +-- Automatic generation of code, forbid to edit +function XUiTip:InitAutoScript() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiTip:GetAutoKey(uiNode, eventName) + if not uiNode then + return + end + return eventName .. uiNode:GetHashCode() +end + +function XUiTip:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then + return + end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiTip:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiTip:AutoAddListener() + self.AutoCreateListeners = {} + self:RegisterClickEvent(self.BtnBack, self.OnBtnBackClick) + self:RegisterClickEvent(self.BtnGet, self.OnBtnGetClick) + self:RegisterClickEvent(self.BtnOk, self.OnBtnOkClick) + self:RegisterClickEvent(self.BtnTcanchaungBlack, self.OnBtnTcanchaungBlackClick) +end +-- auto +function XUiTip:OnBtnBackClick() + self:Close() +end + +function XUiTip:OnBtnGetClick() + XLuaUiManager.Open("UiSkip", self.TemplateId, function() + self:Close() + end, self.HideSkipBtn) +end + +function XUiTip:OnBtnOkClick() + self:Close() +end + +function XUiTip:OnBtnTcanchaungBlackClick() + local buyAssetTemplate = XDataCenter.ItemManager.GetBuyAssetTemplateById(self.Data.TemplateId) + + -- 判断配置表是否存在快捷购买数据 + if not buyAssetTemplate then + XUiManager.TipMsg(CS.XTextManager.GetText("ShopNoGoodsDesc"), XUiManager.UiTipType.Tip) + else + XLuaUiManager.Open("UiBuyAsset", self.Data.TemplateId) + end +end + +function XUiTip:SetUiActive(ui, active) + if not ui or not ui.gameObject then + return + end + + if ui.gameObject.activeSelf == active then + return + end + + ui.gameObject:SetActive(active) +end + +function XUiTip:ResetUi() + self:SetUiActive(self.TxtCount, false) + self:SetUiActive(self.TxtName, false) + self:SetUiActive(self.ImgQuality, false) + self:SetUiActive(self.TxtWorldDesc, false) + self:SetUiActive(self.TxtDescription, false) + self:SetUiActive(self.BtnGet, false) + self:SetUiActive(self.CountTitle, false) +end + +-- data 可以是 XItemData / XEquipData / XCharacterData / XFashionData +function XUiTip:Refresh(data) + self.Data = data + if not data then + XLog.Error("XUiTip:Refresh错误: 参数data不能为空") + return + end + + self:ResetUi() + if type(data) == "number" then + self.TemplateId = data + else + if data.IsTempItemData then self:SetTempData(data) return end + self.TemplateId = data.TemplateId and data.TemplateId or data.Id + end + + if self.TemplateId == XDataCenter.ItemManager.ItemId.AndroidHongKa or + self.TemplateId == XDataCenter.ItemManager.ItemId.IosHongKa then + self.TemplateId = XDataCenter.ItemManager.ItemId.HongKa + end + + local goodsShowParams = XGoodsCommonManager.GetGoodsShowParamsByTemplateId(self.TemplateId) + + -- 获取途径按钮 + local skipIdParams = XGoodsCommonManager.GetGoodsSkipIdParams(self.TemplateId) + if skipIdParams and #skipIdParams > 0 then + self:SetUiActive(self.BtnGet, true) + end + + -- 快捷兑换按钮 + if XDataCenter.ItemManager.IsFastTrading(self.TemplateId) and XDataCenter.ItemManager.JudjeCanFastTrading(self.RootUiName) then + self:SetUiActive(self.BtnTcanchaungBlack, true) + end + + -- 名称 + if self.TxtName and goodsShowParams.Name then + self.TxtName.text = goodsShowParams.Name + self:SetUiActive(self.TxtName, true) + end + + -- 数量 + if self.TxtCount then + local count = XGoodsCommonManager.GetGoodsCurrentCount(self.TemplateId) + self.TxtCount.text = count + self:SetUiActive(self.TxtCount, true) + self:SetUiActive(self.CountTitle, true) + end + + -- 图标 + if self.RImgIcon and self.RImgIcon:Exist() then + local icon = goodsShowParams.Icon + + if goodsShowParams.BigIcon then + icon = goodsShowParams.BigIcon + end + + if icon and #icon > 0 then + self.RImgIcon:SetRawImage(icon) + self:SetUiActive(self.RImgIcon, true) + end + end + + -- 特效 + if self.HeadIconEffect then + local effect = goodsShowParams.Effect + if effect then + self.HeadIconEffect.gameObject:LoadPrefab(effect) + self.HeadIconEffect.gameObject:SetActiveEx(true) + self.HeadIconEffect:Init() + else + self.HeadIconEffect.gameObject:SetActiveEx(false) + end + end + + -- 品质底图 + if self.ImgQuality and goodsShowParams.Quality then + XUiHelper.SetQualityIcon(self, self.ImgQuality, goodsShowParams.Quality) + self:SetUiActive(self.ImgQuality, true) + end + + -- 世界观描述 + if self.TxtWorldDesc then + local worldDesc = XGoodsCommonManager.GetGoodsWorldDesc(self.TemplateId) + if worldDesc and #worldDesc then + self.TxtWorldDesc.text = string.gsub(worldDesc, "\\n", "\n"); + self:SetUiActive(self.TxtWorldDesc, true) + end + end + + -- 描述 + if self.TxtDescription then + local desc = XGoodsCommonManager.GetGoodsDescription(self.TemplateId) + if desc and #desc > 0 then + self.TxtDescription.text = desc + self:SetUiActive(self.TxtDescription, true) + end + end +end +--=============== +--显示临时道具(非背包道具或者需要改数据的道具) +--=============== +function XUiTip:SetTempData(data) + -- 名称 + if self.TxtName and data.Name then + self.TxtName.text = data.Name + self:SetUiActive(self.TxtName, true) + end + -- 数量 + if self.TxtCount and data.Count then + -- data.Count 可能会与 XUiGridCommon 冲突 + self.TxtCount.text = data.OwnCount or data.Count + self:SetUiActive(self.TxtCount, true) + self:SetUiActive(self.CountTitle, true) + end + -- 图标 + if self.RImgIcon and self.RImgIcon:Exist() and data.Icon then + self.RImgIcon:SetRawImage(data.Icon) + self:SetUiActive(self.RImgIcon, true) + end + -- 品质底图 + if self.ImgQuality and data.Quality then + XUiHelper.SetQualityIcon(self, self.ImgQuality, data.Quality) + self:SetUiActive(self.ImgQuality, true) + end + -- 世界观描述 + if self.TxtWorldDesc and data.WorldDesc then + self.TxtWorldDesc.text = data.WorldDesc + self:SetUiActive(self.TxtWorldDesc, true) + end + -- 描述 + if self.TxtDescription and data.Description then + self.TxtDescription.text = data.Description + self:SetUiActive(self.TxtDescription, true) + end + + -- 获取途径按钮 + local skipIdParams = data.TemplateId and XGoodsCommonManager.GetGoodsSkipIdParams(data.TemplateId) + if skipIdParams and #skipIdParams > 0 then + self.TemplateId = data.TemplateId + self:SetUiActive(self.BtnGet, true) + end +end + +function XUiTip:OnGetEvents() + return { + XEventId.EVENT_ITEM_FAST_TRADING, + } +end + +function XUiTip:OnNotify(evt, ...) + if evt == XEventId.EVENT_ITEM_FAST_TRADING then + self:Refresh(self.Data) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTipReward/XUiTipReward.lua b/Resources/Scripts/XUi/XUiTipReward/XUiTipReward.lua new file mode 100644 index 00000000..c1eb6705 --- /dev/null +++ b/Resources/Scripts/XUi/XUiTipReward/XUiTipReward.lua @@ -0,0 +1,99 @@ +local XUiTipReward = XLuaUiManager.Register(XLuaUi, "UiTipReward") + +function XUiTipReward:OnAwake() + self:InitAutoScript() + self:InitBtnSound() +end + +function XUiTipReward:OnStart(rewardGoodsList, title, closecallback, surecallback) + self.GridBagItemRecycle.gameObject:SetActive(false) + self.Items = {} + self.OkCallback = surecallback + self.CancelCallback = closecallback + self:Refresh(rewardGoodsList) + if title then + self.RecycleTitle.text = title + end + CS.XAudioManager.PlaySound(XSoundManager.UiBasicsMusic.Tip_Big) +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiTipReward:InitAutoScript() + self:AutoInitUi() + self.SpecialSoundMap = {} + self:AutoAddListener() +end + +function XUiTipReward:AutoInitUi() + self.BtnBg = self.Transform:Find("SafeAreaContentPane/BtnBg"):GetComponent("Button") + self.BtnDetermine = self.Transform:Find("SafeAreaContentPane/BtnDetermine"):GetComponent("Button") + self.PanelRecycle = self.Transform:Find("SafeAreaContentPane/ViewRecycle/Viewport/PanelRecycle") + self.GridBagItemRecycle = self.Transform:Find("SafeAreaContentPane/ViewRecycle/Viewport/PanelRecycle/GridBagItemRecycle") + self.RecycleTitle = self.Transform:Find("SafeAreaContentPane/RecycleTitle/RecycleTitle1"):GetComponent("Text") +end + +function XUiTipReward:GetAutoKey(uiNode, eventName) + if not uiNode then + return + end + return eventName .. uiNode:GetHashCode() +end + +function XUiTipReward:RegisterListener(uiNode, eventName, func) + local key = self:GetAutoKey(uiNode, eventName) + if not key then + return + end + local listener = self.AutoCreateListeners[key] + if listener ~= nil then + uiNode[eventName]:RemoveListener(listener) + end + + if func ~= nil then + if type(func) ~= "function" then + XLog.Error("XUiTipReward:RegisterListener函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + listener = function(...) + XSoundManager.PlayBtnMusic(self.SpecialSoundMap[key], eventName) + func(self, ...) + end + + uiNode[eventName]:AddListener(listener) + self.AutoCreateListeners[key] = listener + end +end + +function XUiTipReward:AutoAddListener() + self.AutoCreateListeners = {} + self:RegisterClickEvent(self.BtnBg, self.OnBtnBgClick) + self:RegisterClickEvent(self.BtnDetermine, self.OnBtnDetermineClick) +end +-- auto +--初始化音效 +function XUiTipReward:InitBtnSound() + self.SpecialSoundMap[self:GetAutoKey(self.BtnBg, "onClick")] = XSoundManager.UiBasicsMusic.Return + self.SpecialSoundMap[self:GetAutoKey(self.BtnDetermine, "onClick")] = XSoundManager.UiBasicsMusic.Confirm +end + +function XUiTipReward:OnBtnBgClick() + self:Close() + if self.CancelCallback then + self.CancelCallback() + end +end + +function XUiTipReward:OnBtnDetermineClick() + self:Close() + if self.OkCallback then + self.CancelCallback() + end +end + +function XUiTipReward:Refresh(rewardGoodsList) + local onCreate = function(grid, data) + grid:Refresh(data) + end + XUiHelper.CreateTemplates(self, self.Items, rewardGoodsList, XUiGridCommon.New, self.GridBagItemRecycle, self.PanelRecycle, onCreate) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTrial/XUiGridTrialDesItem.lua b/Resources/Scripts/XUi/XUiTrial/XUiGridTrialDesItem.lua new file mode 100644 index 00000000..04a81386 --- /dev/null +++ b/Resources/Scripts/XUi/XUiTrial/XUiGridTrialDesItem.lua @@ -0,0 +1,49 @@ +local XUiGridTrialDesItem = XClass(nil, "XUiGridTrialDesItem") + +function XUiGridTrialDesItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:InitAutoScript() +end + +function XUiGridTrialDesItem:Init(uiRoot) + self.UiRoot = uiRoot +end + +function XUiGridTrialDesItem:OnRefresh(data) + self.TxtNameA.text = data +end +-- auto +-- Automatic generation of code, forbid to edit +function XUiGridTrialDesItem:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiGridTrialDesItem:AutoInitUi() + -- self.TxtNameA = self.Transform:Find("TxtName"):GetComponent("Text") +end + +function XUiGridTrialDesItem:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiGridTrialDesItem:RegisterClickEvent函数出错, 原因:点击回调函数不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiGridTrialDesItem:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiGridTrialDesItem:AutoAddListener() +end +-- auto + +return XUiGridTrialDesItem diff --git a/Resources/Scripts/XUi/XUiTrial/XUiGridTrialTypeItem.lua b/Resources/Scripts/XUi/XUiTrial/XUiGridTrialTypeItem.lua new file mode 100644 index 00000000..69c2c744 --- /dev/null +++ b/Resources/Scripts/XUi/XUiTrial/XUiGridTrialTypeItem.lua @@ -0,0 +1,55 @@ +local XUiGridTrialTypeItem = XClass(nil, "XUiGridTrialTypeItem") + +function XUiGridTrialTypeItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:InitAutoScript() +end + + +function XUiGridTrialTypeItem:Init(uiRoot) + self.UiRoot = uiRoot +end + +function XUiGridTrialTypeItem:OnRefresh(itemdata) + if not itemdata then + return + end + self.TxtName.text = itemdata.Name +end + + +-- auto +-- Automatic generation of code, forbid to edit +function XUiGridTrialTypeItem:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiGridTrialTypeItem:AutoInitUi() + -- self.TxtName = self.Transform:Find("TxtName"):GetComponent("Text") +end + +function XUiGridTrialTypeItem:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiGridTrialTypeItem:RegisterClickEvent函数出错, 原因:点击回调函数不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiGridTrialTypeItem:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiGridTrialTypeItem:AutoAddListener() +end +-- auto + +return XUiGridTrialTypeItem diff --git a/Resources/Scripts/XUi/XUiTrial/XUiPanelTrialGet.lua b/Resources/Scripts/XUi/XUiTrial/XUiPanelTrialGet.lua new file mode 100644 index 00000000..447236ba --- /dev/null +++ b/Resources/Scripts/XUi/XUiTrial/XUiPanelTrialGet.lua @@ -0,0 +1,71 @@ +local XUiPanelTrialGet = XClass(nil, "XUiPanelTrialGet") + +function XUiPanelTrialGet:Ctor(ui,uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + XTool.InitUiObject(self) + self:InitScript() +end + +function XUiPanelTrialGet:SetBtnCB(cb) + self.BtnCb = cb +end + +-- 处理特效和动画 +function XUiPanelTrialGet:SetAnimationFx() + self.FxUiPanelTrialGet01.gameObject:SetActive(true) + self.timer = XScheduleManager.ScheduleOnce(function() + self.FxUiPanelTrialGet02.gameObject:SetActive(true) + XScheduleManager.UnSchedule(self.timer) + end,200) +end + +function XUiPanelTrialGet:InitScript() + self:AddListener() +end + + +function XUiPanelTrialGet:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelTrialGet:RegisterClickEvent函数出错, 原因:点击回调函数不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelTrialGet:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelTrialGet:AddListener() + self:RegisterClickEvent(self.BtnClick, self.OnBtnClickClick) +end +-- auto + +-- 设置背景 +function XUiPanelTrialGet:SetBg(iconpath) + if not iconpath then + return + end + + self.UiRoot:SetUiSprite(self.ImgWafer,iconpath) +end + +function XUiPanelTrialGet:SetName(name) + self.TxtName.text = name or "" +end + +function XUiPanelTrialGet:OnBtnClickClick() + if not self.BtnCb then + return + end + self.BtnCb() +end + +return XUiPanelTrialGet \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTrial/XUiPanelTrialGrid.lua b/Resources/Scripts/XUi/XUiTrial/XUiPanelTrialGrid.lua new file mode 100644 index 00000000..972e2216 --- /dev/null +++ b/Resources/Scripts/XUi/XUiTrial/XUiPanelTrialGrid.lua @@ -0,0 +1,154 @@ +local XUiPanelTrialGrid = XClass(nil, "XUiPanelTrialGrid") + +function XUiPanelTrialGrid:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + self.RewardPanelList = {} + XTool.InitUiObject(self) + self:InitUiAfterAuto() + XEventManager.AddEventListener(XEventId.EVENT_TRIAL_LEVEL_FINISH, self.OnSettleTrial, self) +end + +function XUiPanelTrialGrid:InitUiAfterAuto() +end + +function XUiPanelTrialGrid:Init(uiRoot, parent) + self.UiRoot = uiRoot + self.Parent = parent + self:CloseFx() +end +-- 更新数据 +function XUiPanelTrialGrid:OnRefresh(itemData) + if not itemData then + return + end + + self.ItemData = itemData + -- 设Icon + local iconpath = self.ItemData.Picture + self.UiRoot:SetUiSprite(self.ImgIcon, iconpath) + + -- 设置状态 + self:SetTrialItemState() + + if self.IsNotFirstFx then + self:SetTrialItemRewardFx() + else + self.IsNotFirstFx = true + end + -- 设置名字 + self.TxtNameB.text = itemData.Name + + -- 推荐等级 + local stagecfg = XDataCenter.FubenManager.GetStageCfg(itemData.StageId) + local level = stagecfg.RecommandLevel or 1 + self.TxtLevel.text = CS.XTextManager.GetText("RecommendLevelDesc", level) + + -- 解锁条件 + if itemData.ConditionExplain then + local conditiontext = "" + for _, v in ipairs(itemData.ConditionExplain) do + conditiontext = conditiontext .. v .. "\n" + end + self.TxtLock.text = conditiontext + end + + -- 设置奖励 + self:SetReward(itemData) +end + +function XUiPanelTrialGrid:SetReward(itemData) + local rewards = XRewardManager.GetRewardList(itemData.RewardId) + self.RewardListData = rewards + local rewardCount = #rewards + + for i = 1, rewardCount do + local panel = self.RewardPanelList[i] + if not panel then + local ui = CS.UnityEngine.Object.Instantiate(self.PanelReward) + ui.transform:SetParent(self.UiContent, false) + ui.gameObject:SetActive(true) + ui.gameObject.name = string.format("PanelReward%d", i) + panel = XUiGridCommon.New(self.UiRoot, ui) + table.insert(self.RewardPanelList, i, panel) + end + end + + for i = 1, #self.RewardPanelList do + self.RewardPanelList[i].GameObject:SetActive(i <= rewardCount) + if i <= rewardCount then + self.RewardPanelList[i]:Refresh(rewards[i]) + end + end +end + +-- 通关改状态 +function XUiPanelTrialGrid:OnSettleTrial(res) + if res then + if self.ItemData then + local StageId = res + if self.ItemData.StageId == StageId then + XDataCenter.TrialManager.TrialLevelPassState(self.ItemData.Id) + self:SetTrialItemState() + end + end + end +end + +-- 奖励领取后改进度 +function XUiPanelTrialGrid:AfterRewardGetedPro(cb) + local prolen = XTrialConfigs.GetForTotalLength() + if self.ItemData.Id > prolen then + local index = self.ItemData.Id - prolen + self.Parent:SetTypeTrialSignlePro(index, cb) + else + self.Parent:SetTypeTrialSignlePro(self.ItemData.Id, cb) + end +end + +-- 设置状态 +function XUiPanelTrialGrid:SetTrialItemState() + local id = self.ItemData.Id + if XDataCenter.TrialManager.TrialLevelLock(id) then --解锁的 + self.ImgLock.gameObject:SetActiveEx(false) + if XDataCenter.TrialManager.TrialLevelFinished(id) then + if XDataCenter.TrialManager.TrialRewardGeted(id) then + self.ImgCanGet.gameObject:SetActiveEx(false) + self.ImgGeted.gameObject:SetActiveEx(true) + else + self.ImgCanGet.gameObject:SetActiveEx(true) + self.ImgGeted.gameObject:SetActiveEx(false) + end + else + self.ImgCanGet.gameObject:SetActiveEx(false) + self.ImgGeted.gameObject:SetActiveEx(false) + end + else + self.ImgLock.gameObject:SetActiveEx(true) + self.ImgCanGet.gameObject:SetActiveEx(false) + self.ImgGeted.gameObject:SetActiveEx(false) + end +end + +-- 关闭特效,防止特效透ui。 +function XUiPanelTrialGrid:CloseFx() + self.ImgSelect.gameObject:SetActiveEx(false) +end + +function XUiPanelTrialGrid:OpenFx() + self.ImgSelect.gameObject:SetActiveEx(true) +end + +function XUiPanelTrialGrid:SetTrialItemRewardFx() + if self.ItemData and self.ItemData.Id then + local id = self.ItemData.Id + if XDataCenter.TrialManager.TrialLevelLock(id) and XDataCenter.TrialManager.TrialLevelFinished(id) and not XDataCenter.TrialManager.TrialRewardGeted(id) then + self:OpenFx() + return + end + end + self:CloseFx() +end + +return XUiPanelTrialGrid \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTrial/XUiPanelTrialMain.lua b/Resources/Scripts/XUi/XUiTrial/XUiPanelTrialMain.lua new file mode 100644 index 00000000..d1560edf --- /dev/null +++ b/Resources/Scripts/XUi/XUiTrial/XUiPanelTrialMain.lua @@ -0,0 +1,235 @@ +local XUiPanelTrialMain = XClass(nil, "XUiPanelTrialMain") +local XUiPanelTrialTaskList = require("XUi/XUiTrial/XUiPanelTrialTaskList") +local XUiPanelTrialType = require("XUi/XUiTrial/XUiPanelTrialType") + +function XUiPanelTrialMain:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + XTool.InitUiObject(self) + self:AddListener() + self:InitUiAfterAuto() +end + +function XUiPanelTrialMain:InitUiAfterAuto() + self.TrialTaskList = XUiPanelTrialTaskList.New(self.PanelTrialTaskList, self.UiRoot, self) + self.TrialTypeList = XUiPanelTrialType.New(self.PanelTrialType, self.UiRoot, self) + self.TxtName.text = CS.XTextManager.GetText("TrialName") + self.ProForImg = {} + self.ProForImg[1] = self.ImgPro1.gameObject + self.ProForImg[2] = self.ImgPro2.gameObject + self.ProForImg[3] = self.ImgPro3.gameObject + self.ProForImg[4] = self.ImgPro4.gameObject + self.ProForImg[5] = self.ImgPro5.gameObject + + self.ProBackEndImg = {} + self.ProBackEndImg[1] = self.ImgPro1A.gameObject + self.ProBackEndImg[2] = self.ImgPro2A.gameObject + self.ProBackEndImg[3] = self.ImgPro3A.gameObject + self.ProBackEndImg[4] = self.ImgPro4A.gameObject + self.ProBackEndImg[5] = self.ImgPro5A.gameObject + + self.ProBackEndAnimation = {} + self.ProForAnimation = {} + self.ProForAnimation[1] = "AniTrialImgPro1" + self.ProForAnimation[2] = "AniTrialImgPro2" + self.ProForAnimation[3] = "AniTrialImgPro3" + self.ProForAnimation[4] = "AniTrialImgPro4" + self.ProForAnimation[5] = "AniTrialImgPro5" + + self.ProBackEndAnimation[1] = "AniTrialImgPro6" + self.ProBackEndAnimation[2] = "AniTrialImgPro7" + self.ProBackEndAnimation[3] = "AniTrialImgPro8" + self.ProBackEndAnimation[4] = "AniTrialImgPro9" + self.ProBackEndAnimation[5] = "AniTrialImgPro10" + + self.ProBackEndFx = {} + self.ProForFx = {} + self.ProForFx[1] = self.PanelFx1 + self.ProForFx[2] = self.PanelFx2 + self.ProForFx[3] = self.PanelFx3 + self.ProForFx[4] = self.PanelFx4 + self.ProForFx[5] = self.PanelFx5 + + self.ProBackEndFx[1] = self.PanelFx1A + self.ProBackEndFx[2] = self.PanelFx2A + self.ProBackEndFx[3] = self.PanelFx3A + self.ProBackEndFx[4] = self.PanelFx4A + self.ProBackEndFx[5] = self.PanelFx5A +end + +-- 重新设置list的item的状态,让特效出现。 +function XUiPanelTrialMain:SetListItemFx() + self.TrialTaskList:SetListItemFx() +end + +-- 关闭list的item的特效,防止特效透ui。 +function XUiPanelTrialMain:ClostListItemFx() + self.TrialTaskList:ClostListItemFx() +end + +-- trialtype,1:前段 2:后段 +function XUiPanelTrialMain:SeleTrialType(trialtype) + self.CurTrialType = trialtype + self.TrialTaskList:UpdateTaskList(trialtype) +end + +-- 特效播放完 +function XUiPanelTrialMain:FxFisish() + self.TrialTaskList:OpenFxFinish(true) + self.TrialTaskList:SetListItemFx() +end + +-- 打开 +function XUiPanelTrialMain:OpenView() + XDataCenter.TrialManager.UnLockRed = true + self.TrialTaskList:OpenFxFinish(false) + self.UiRoot:PlayAnimation("AnimStartEnable", function() + self.Dark.gameObject:SetActive(false) + self:FxFisish() + end) + + self:RewardGetHandle() +end + +-- 关闭 +function XUiPanelTrialMain:CloseView() + for _, v in pairs(self.ProForFx) do + v.gameObject:SetActive(false) + end + + for _, v in pairs(self.ProBackEndFx) do + v.gameObject:SetActive(false) + end +end + +-- 必须保证奖励能正确领取到 +function XUiPanelTrialMain:RewardGetHandle() + local curTrialType = XDataCenter.TrialManager.FinishTrialType() + if curTrialType == XDataCenter.TrialManager.TrialTypeCfg.TrialFor then + self.CurTrialType = curTrialType + else + if self.UiRoot.RewardUIOpen then--奖励界面还在,不需要判断。 + return + end + if XDataCenter.TrialManager.TrialRewardGetedFinish() and not XDataCenter.TrialManager.TypeRewardByTrialtype(XDataCenter.TrialManager.TrialTypeCfg.TrialFor) then + self.CurTrialType = XDataCenter.TrialManager.TrialTypeCfg.TrialFor + self.UiRoot:HandleForTrialFinish() + elseif not XDataCenter.TrialManager.TrialRewardGetedFinish() then + self.CurTrialType = XDataCenter.TrialManager.TrialTypeCfg.TrialFor + else + self.CurTrialType = curTrialType + if XDataCenter.TrialManager.TrialRewardGetedBackEndFinish() and not XDataCenter.TrialManager.TypeRewardByTrialtype(XDataCenter.TrialManager.TrialTypeCfg.TrialBackEnd) then + self.UiRoot:HandleBackFinishTips() + end + end + end + + self:SeleTrialType(self.CurTrialType) + self:SetTrialTypeNameByType(self.CurTrialType) + self:SetTypeTrialPro() + self:SetTrialBg(self.CurTrialType) +end + +--结算后重新更新数据 +function XUiPanelTrialMain:UpdateViewOnFinish() + self:SeleTrialType(self.CurTrialType) + self.TrialTypeList:SetTrialTypeNameByType(self.CurTrialType) + self:SetTypeTrialPro() +end + +-- 通过类型设置名字 +function XUiPanelTrialMain:SetTrialTypeNameByType(trialtype) + self.TrialTypeList:SetTrialTypeNameByType(trialtype) + self.TrialTypeList:InitScrollState(trialtype) +end + +-- 设置背景 +function XUiPanelTrialMain:SetTrialBg(trialtype) + self.UiRoot:SetTrialBg(trialtype) +end + +-- 设置类型关卡进度 +function XUiPanelTrialMain:SetTypeTrialPro() + if self.CurTrialType == XDataCenter.TrialManager.TrialTypeCfg.TrialFor then + local cfg = XTrialConfigs.GetForTotalData() + self.PanelForPro.gameObject:SetActive(true) + self.PanelBackEndPro.gameObject:SetActive(false) + self.ImgForPartPro.gameObject:SetActive(true) + self.ImgBackEndPartPro.gameObject:SetActive(false) + + for k, v in pairs(cfg) do + if XDataCenter.TrialManager.TrialLevelFinished(v.Id) and XDataCenter.TrialManager.TrialRewardGeted(v.Id) then + self.ProForImg[k]:SetActive(false) + else + self.ProForImg[k]:SetActive(true) + end + end + else + local cfg = XTrialConfigs.GetBackEndTotalData() + self.PanelForPro.gameObject:SetActive(false) + self.PanelBackEndPro.gameObject:SetActive(true) + self.ImgForPartPro.gameObject:SetActive(false) + self.ImgBackEndPartPro.gameObject:SetActive(true) + + for k, v in pairs(cfg) do + if XDataCenter.TrialManager.TrialLevelFinished(v.Id) and XDataCenter.TrialManager.TrialRewardGeted(v.Id) then + self.ProBackEndImg[k]:SetActive(false) + else + self.ProBackEndImg[k]:SetActive(true) + end + end + end +end + +-- 前段打完后处理 +function XUiPanelTrialMain:SetForTrialFinish(trialtype) + self:SeleTrialType(trialtype) + self:SetTrialTypeNameByType(trialtype) + self:SetTrialBg(trialtype) +end + +-- 设置单个进度 +function XUiPanelTrialMain:SetTypeTrialSignlePro(index, cb) + if self.CurTrialType == XDataCenter.TrialManager.TrialTypeCfg.TrialFor then + self.UiRoot:PlayAnimation(self.ProForAnimation[index], cb) + self.ProForFx[index].gameObject:SetActive(true) + else + self.UiRoot:PlayAnimation(self.ProBackEndAnimation[index], cb) + self.ProBackEndFx[index].gameObject:SetActive(true) + end +end + +function XUiPanelTrialMain:AddListener() + self.BtnHelp.CallBack = function() self:OnBtnHelpClick() end + self.BtnType.CallBack = function() self:OnBtnTypeClick() end +end +-- auto +function XUiPanelTrialMain:OnBtnHelpClick() + XUiManager.UiFubenDialogTip("", CS.XTextManager.GetText("TrialIllustration") or "") +end + +function XUiPanelTrialMain:OnBtnTypeClick() + if self.CurTrialType == XDataCenter.TrialManager.TrialTypeCfg.TrialFor then + + local cfg = XTrialConfigs.GetTrialTypeCfg(XDataCenter.TrialManager.TrialTypeCfg.TrialFor) + if not cfg then + return + end + + local rewards = XRewardManager.GetRewardList(cfg.RewardId) + if rewards and rewards[1] then + XLuaUiManager.Open("UiEquipDetail", rewards[1].TemplateId, true) + end + else + local cfg = XTrialConfigs.GetTrialTypeCfg(XDataCenter.TrialManager.TrialTypeCfg.TrialBackEnd) + if not cfg then + return + end + local rewards = XRewardManager.GetRewardList(cfg.RewardId) + if rewards and rewards[1] then + XLuaUiManager.Open("UiEquipDetail", rewards[1].TemplateId, true) + end + end +end +return XUiPanelTrialMain \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTrial/XUiPanelTrialSelect.lua b/Resources/Scripts/XUi/XUiTrial/XUiPanelTrialSelect.lua new file mode 100644 index 00000000..a7f106e7 --- /dev/null +++ b/Resources/Scripts/XUi/XUiTrial/XUiPanelTrialSelect.lua @@ -0,0 +1,201 @@ +local XUiPanelTrialSelect = XClass(nil, "XUiPanelTrialSelect") +local XUiGridTrialDesItem = require("XUi/XUiTrial/XUiGridTrialDesItem") + +function XUiPanelTrialSelect:Ctor(ui, uiRoot) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + self.RewardPanelList = {} + XTool.InitUiObject(self) + self:AddListener() + self:InitUiAfterAuto() +end + +function XUiPanelTrialSelect:InitUiAfterAuto() + self.DynamicDesTable = XDynamicTableNormal.New(self.SViewTrialDesList.gameObject) + self.DynamicDesTable:SetProxy(XUiGridTrialDesItem) + self.DynamicDesTable:SetDelegate(self) +end + +function XUiPanelTrialSelect:UpdateView(itemData) + if not itemData then + return + end + + -- 设置说明 + self.TxtDes.text = itemData.Explain + + -- 设置名字 + self.TxtName.text = itemData.Name + + -- 设置图片 + local iconpath = itemData.BigPicture + self.ImgIconA:SetRawImage(iconpath) + + -- 设置奖励 + local id = itemData.Id + local flag = XDataCenter.TrialManager.TrialLevelFinished(id) + if not flag or (flag and not XDataCenter.TrialManager.TrialRewardGeted(id)) then + self.UiContent.gameObject:SetActiveEx(true) + self:SetReward(itemData) + else + self.UiContent.gameObject:SetActiveEx(false) + end + + -- 设置描述 + self.Des = itemData.Des + self.DynamicDesTable:SetDataSource(itemData.Des) + self.DynamicDesTable:ReloadDataASync(1) + + -- 等级 + self.StageId = itemData.StageId + local stagecfg = XDataCenter.FubenManager.GetStageCfg(self.StageId) + local level = stagecfg.RecommandLevel or 1 + self.TxtLevel.text = level + + -- 电量 + local active = stagecfg.RequireActionPoint or 0 + self.TxtNums.text = active + + -- 设置战斗力 + self:SetAbility(itemData) + + -- 设置进度 + self:SetPro(itemData) +end + +function XUiPanelTrialSelect:SetPro(itemData) + if itemData.Type == XDataCenter.TrialManager.TrialTypeCfg.TrialFor then + self.TxtPro.text = string.format("%s/%s", itemData.Id, XTrialConfigs.GetForTotalLength()) + else + self.TxtPro.text = string.format( + "%s/%s", + itemData.Id - XTrialConfigs.GetForTotalLength(), + XTrialConfigs.GetBackEndTotalLength() + ) + end +end + +function XUiPanelTrialSelect:SetAbility(itemData) + local charlist = XDataCenter.CharacterManager.GetCharacterList() + local maxAbility = 0 + + for _, v in pairs(charlist) do + local ability = v.Ability or 0 + if ability > maxAbility then + maxAbility = ability + end + end + + local ability = itemData.AvgAbility + + if ability < maxAbility then + self.ImgEnough.gameObject:SetActive(true) + self.ImgNotEnough.gameObject:SetActive(false) + self.TxtFight.text = CS.XTextManager.GetText("AbilityCurrentSufficientTips", ability, math.floor(maxAbility)) + else + self.ImgEnough.gameObject:SetActive(false) + self.ImgNotEnough.gameObject:SetActive(true) + self.TxtFightA.text = CS.XTextManager.GetText("AbilityCurrentInSufficientTips", ability, math.floor(maxAbility)) + end +end + +function XUiPanelTrialSelect:SetReward(itemData) + local rewards = XRewardManager.GetRewardList(itemData.RewardId) + if not rewards then + return + end + + self.RewardListData = rewards + local rewardCount = #rewards + for i = 1, rewardCount do + local panel = self.RewardPanelList[i] + if not panel then + local ui = CS.UnityEngine.Object.Instantiate(self.PanelReward) + ui.transform:SetParent(self.UiContent, false) + ui.gameObject:SetActive(true) + ui.gameObject.name = string.format("PanelReward%d", i) + panel = XUiGridCommon.New(self.UiRoot, ui) + table.insert(self.RewardPanelList, i, panel) + end + end + + for i = 1, #self.RewardPanelList do + self.RewardPanelList[i].GameObject:SetActive(i <= rewardCount) + if i <= rewardCount then + self.RewardPanelList[i]:Refresh(rewards[i]) + end + end +end + + +-- [监听动态列表事件] +function XUiPanelTrialSelect:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self.UiRoot) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.Des[index] + grid:OnRefresh(data) + end +end + +-- 打开界面 +function XUiPanelTrialSelect:OpenView(data) + self.UiRoot:PlayAnimation("AniTrialDetailsOpen") + self.GameObject:SetActive(true) + self.ViewData = data + self:UpdateView(data) + self.UiRoot:CloseMainView() + self.UiRoot:ClostMainListItemFx() +end + +-- 关闭界面 +function XUiPanelTrialSelect:CloseView() + self.UiRoot:SetListItemFx() + self.GameObject:SetActive(false) + self.UiRoot:ReturnPreTrialBg() + self.UiRoot.TrialMain.GameObject:SetActive(true) +end + +function XUiPanelTrialSelect:AddListener() + self.BtnEnterB.CallBack = function() self:OnBtnEnterBClick() end +end + +function XUiPanelTrialSelect:OnSViewRewardListAClick() +end + +function XUiPanelTrialSelect:OnBtnEnterBClick() + if self.StageId then + self.UiRoot:CloseSelectView() + local Stage = XDataCenter.FubenManager.GetStageCfg(self.StageId) + CsXGameEventManager.Instance:Notify(XEventId.EVENT_FUBEN_ENTERFIGHT, Stage) + end +end + +function XUiPanelTrialSelect:OnGetEvents() + return { XEventId.EVENT_FUBEN_CLOSE_FUBENSTAGEDETAIL, XEventId.EVENT_FUBEN_ENTERFIGHT } +end +--事件监听 +function XUiPanelTrialSelect:OnNotify(evt, ...) + -- if evt == XEventId.EVENT_FUBEN_CLOSE_FUBENSTAGEDETAIL then + -- else + if evt == XEventId.EVENT_FUBEN_ENTERFIGHT then + self:EnterFight(...) + end +end + +function XUiPanelTrialSelect:EnterFight(stage) + if not XDataCenter.FubenManager.CheckPreFight(stage) then + return + end + if not XDataCenter.FubenManager.CheckPreFight(stage) then + return + end + if XDataCenter.BfrtManager.CheckStageTypeIsBfrt(stage.StageId) then + local groupId = XDataCenter.BfrtManager.GetGroupIdByBaseStage(stage.StageId) + XLuaUiManager.Open("UiBfrtDeploy", groupId) + else + XLuaUiManager.Open("UiNewRoomSingle", stage.StageId) + end +end +return XUiPanelTrialSelect \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTrial/XUiPanelTrialTaskList.lua b/Resources/Scripts/XUi/XUiTrial/XUiPanelTrialTaskList.lua new file mode 100644 index 00000000..0a5591e5 --- /dev/null +++ b/Resources/Scripts/XUi/XUiTrial/XUiPanelTrialTaskList.lua @@ -0,0 +1,160 @@ +local XUiPanelTrialTaskList = XClass(nil, "XUiPanelTrialTaskList") +local XUiPanelTrialGrid = require("XUi/XUiTrial/XUiPanelTrialGrid") + +function XUiPanelTrialTaskList:Ctor(ui, uiRoot, parent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + self.Parent = parent + self.animationunlockcb = function() self:HandleRewardTypeTips() end + XTool.InitUiObject(self) + self:InitUiAfterAuto() +end + +function XUiPanelTrialTaskList:InitUiAfterAuto() + self.DynamicTable = XDynamicTableNormal.New(self.SViewTaskList.gameObject) + self.DynamicTable:SetProxy(XUiPanelTrialGrid) + self.DynamicTable:SetDelegate(self) +end + +-- trialtype,1:前段 other:后段 +function XUiPanelTrialTaskList:UpdateTaskList(trialtype) + if self.PreTrialType == trialtype then + for i = 1, self.CurListLen do + local grid = self.DynamicTable:GetGridByIndex(i) + if grid then + local data = self.TaskListData[i] + grid:OnRefresh(data) + end + end + return + end + + if trialtype == XDataCenter.TrialManager.TrialTypeCfg.TrialFor then + self.TaskListData = XTrialConfigs.GetForTotalData() + else + self.TaskListData = XTrialConfigs.GetBackEndTotalData() + end + if not self.TaskListData then + return + end + self.PreTrialType = trialtype + self.CurListLen = #self.TaskListData + self.DynamicTable:SetDataSource(self.TaskListData) + self.DynamicTable:ReloadDataASync(1) +end + +-- 处理前段刚打完 +function XUiPanelTrialTaskList:ForTrialFinish() + if XDataCenter.TrialManager.TrialRewardGetedFinish() and not XDataCenter.TrialManager.TypeRewardByTrialtype(XDataCenter.TrialManager.TrialTypeCfg.TrialFor) then + self.UiRoot:HandleForTrialFinish() + end +end + +-- 处理后段段刚打完 +function XUiPanelTrialTaskList:BackEndTrialFinish() + if not XDataCenter.TrialManager.BackEndTrialFinishJust() or not XDataCenter.TrialManager.TrialRewardGetedBackEndFinish() then + return + end + self.UiRoot:HandleBackFinishTips() +end + +-- [监听动态列表事件] +function XUiPanelTrialTaskList:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self.UiRoot, self.Parent) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.TaskListData[index] + grid:OnRefresh(data, self.CurOpenFxState) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + if not self.CurOpenFxState then + return + end + if self.CurTipsShow then + return + end + local data = self.TaskListData[index] + local trialid = data.Id + if XDataCenter.TrialManager.TrialLevelFinished(trialid) then + if not XDataCenter.TrialManager.TrialRewardGeted(trialid) then + grid:CloseFx() + self.UiRoot:OpenRewardViewNow(true) + XDataCenter.TrialManager.OnTrialPassRewardRequest( + trialid, + function(rewardGoodsList) + self.CurTipsShow = true + XUiManager.OpenUiObtain(rewardGoodsList, nil, function() + local msg + if data.Type == XDataCenter.TrialManager.TrialTypeCfg.TrialBackEnd then + msg = CS.XTextManager.GetText("TrialLevelFinish", XDataCenter.TrialManager:TrialRewardGetedBackEndCount(), XTrialConfigs.GetBackEndTotalLength()) + else + msg = CS.XTextManager.GetText("TrialLevelFinish", XDataCenter.TrialManager:TrialRewardGetedForCount(), XTrialConfigs.GetForTotalLength()) + end + grid:SetTrialItemState() + self.UiRoot:OpenRewardViewNow(false) + XUiManager.TipMsg(msg, XUiManager.UiTipType.Success, function() + XLuaUiManager.Close("UiObtain") + self.CurTrialType = data.Type + grid:AfterRewardGetedPro(self.animationunlockcb) + end) + end + ) + end + ) + else + -- -- 提示玩家已經打完 + -- local msg = CS.XTextManager.GetText("TrialFinish") + -- XUiManager.TipMsg(msg) + self.UiRoot:OpenSelectView(data) + end + elseif not XDataCenter.TrialManager.TrialLevelLock(trialid) then + -- 提示玩家没有解锁 + local msg = CS.XTextManager.GetText("TrialUnLock") + XUiManager.TipMsg(msg) + else + self.UiRoot:OpenSelectView(data) + end + end +end +-- 动画播结束后再处理大奖的弹出tips +function XUiPanelTrialTaskList:HandleRewardTypeTips() + self.CurTipsShow = false + if not self.CurTrialType then + return + end + + if self.CurTrialType == XDataCenter.TrialManager.TrialTypeCfg.TrialFor then + self:ForTrialFinish() + else + self:BackEndTrialFinish() + end +end + +-- 重新设置list的item的状态. +function XUiPanelTrialTaskList:SetListItemFx() + for i = 1, self.CurListLen do + local grid = self.DynamicTable:GetGridByIndex(i) + if grid then + grid:SetTrialItemRewardFx() + end + end +end + +-- 关闭list的item的特效,防止特效透ui。 +function XUiPanelTrialTaskList:ClostListItemFx() + for i = 1, self.CurListLen do + local grid = self.DynamicTable:GetGridByIndex(i) + if grid then + grid:CloseFx() + end + end +end + +function XUiPanelTrialTaskList:OpenFxFinish(state) + self.CurOpenFxState = state +end + +function XUiPanelTrialTaskList:OnSViewTaskListClick() +end + +return XUiPanelTrialTaskList \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTrial/XUiPanelTrialTips.lua b/Resources/Scripts/XUi/XUiTrial/XUiPanelTrialTips.lua new file mode 100644 index 00000000..6aa27f76 --- /dev/null +++ b/Resources/Scripts/XUi/XUiTrial/XUiPanelTrialTips.lua @@ -0,0 +1,63 @@ +local XUiPanelTrialTips = XClass(nil, "XUiPanelTrialTips") + +function XUiPanelTrialTips:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self:InitAutoScript() +end + +function XUiPanelTrialTips:SetTrialType(trialtype) + if trialtype == XDataCenter.TrialManager.TrialTypeCfg.TrialFor then + self.ImgFor.gameObject:SetActive(true) + self.ImgBackEnd.gameObject:SetActive(false) + self.ImgBackEnd2.gameObject:SetActive(false) + elseif trialtype == XDataCenter.TrialManager.TrialTypeCfg.TrialBackEnd then + self.ImgFor.gameObject:SetActive(false) + self.ImgBackEnd.gameObject:SetActive(true) + self.ImgBackEnd2.gameObject:SetActive(false) + else + self.ImgFor.gameObject:SetActive(false) + self.ImgBackEnd.gameObject:SetActive(false) + self.ImgBackEnd2.gameObject:SetActive(true) + end +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelTrialTips:InitAutoScript() + self:AutoInitUi() + self:AutoAddListener() +end + +function XUiPanelTrialTips:AutoInitUi() + -- self.ImgFor = self.Transform:Find("ImgFor"):GetComponent("Image") + -- self.ImgForIcon = self.Transform:Find("ImgFor/ImgForIcon"):GetComponent("Image") + -- self.ImgBackEnd = self.Transform:Find("ImgBackEnd"):GetComponent("Image") + -- self.ImgBackEndIcon = self.Transform:Find("ImgBackEnd/ImgBackEndIcon"):GetComponent("Image") + -- self.ImgBackEnd2 = self.Transform:Find("ImgBackEnd2"):GetComponent("Image") + -- self.ImgForIconA = self.Transform:Find("ImgBackEnd2/ImgForIcon"):GetComponent("Image") +end + +function XUiPanelTrialTips:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelTrialTips:RegisterClickEvent函数出错, 原因:点击回调函数不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelTrialTips:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelTrialTips:AutoAddListener() +end +-- auto + +return XUiPanelTrialTips diff --git a/Resources/Scripts/XUi/XUiTrial/XUiPanelTrialType.lua b/Resources/Scripts/XUi/XUiTrial/XUiPanelTrialType.lua new file mode 100644 index 00000000..6f482385 --- /dev/null +++ b/Resources/Scripts/XUi/XUiTrial/XUiPanelTrialType.lua @@ -0,0 +1,121 @@ +local XUiPanelTrialType = XClass(nil, "XUiPanelTrialType") +local XUiGridTrialTypeItem = require("XUi/XUiTrial/XUiGridTrialTypeItem") +local TrialTypeCfg = { + TrialFor = 1, + TrialBackEnd = 2 +} + +function XUiPanelTrialType:Ctor(ui, uiRoot, parent) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.UiRoot = uiRoot + self.Parent = parent + XTool.InitUiObject(self) + self:InitScript() + self:InitUiAfterAuto() +end + +function XUiPanelTrialType:InitUiAfterAuto() + self.DynamicTable = XDynamicTableNormal.New(self.SViewTrialTypeList.gameObject) + self.DynamicTable:SetProxy(XUiGridTrialTypeItem) + self.DynamicTable:SetDelegate(self) + self.SViewTrialTypeList.gameObject:SetActive(true) +end + +function XUiPanelTrialType:UpdateTrialTypeList() + self.InitEd = true + self.TrialtypeListData = XTrialConfigs.GetTotalTrialTypeCfg() + self.DynamicTable:SetDataSource(self.TrialtypeListData) + self.DynamicTable:ReloadDataSync() +end + +-- [监听动态列表事件] +function XUiPanelTrialType:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_INIT then + grid:Init(self.UiRoot) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.TrialtypeListData[index] + grid:OnRefresh(data) + elseif event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_TOUCHED then + self:SetTrialTypeNameByType(index) + self.CurScrollState = false + self.SViewTrialTypeList.gameObject:SetActive(self.CurScrollState) + self.ImgArrowUp.gameObject:SetActive(self.CurScrollState) + self.ImgArrowDown.gameObject:SetActive(not self.CurScrollState) + self.Parent:SeleTrialType(index) + self.Parent:SetTrialBg(index) + self.Parent:SetTypeTrialPro() + end +end + +-- 通过类型设置名字 +function XUiPanelTrialType:SetTrialTypeNameByType(trialtype) + local cfg = XTrialConfigs.GetTrialTypeCfg(trialtype) + self.TxtTitle.text = cfg.Name + + if trialtype == TrialTypeCfg.TrialBackEnd then + self.ImgAfter.gameObject:SetActive(true) + self.ImgFront.gameObject:SetActive(false) + else + self.ImgAfter.gameObject:SetActive(false) + self.ImgFront.gameObject:SetActive(true) + end +end + +-- 初始化状态 +function XUiPanelTrialType:InitScrollState() + self.CurScrollState = false + self.SViewTrialTypeList.gameObject:SetActive(self.CurScrollState) + if XDataCenter.TrialManager.FinishTrialType() == TrialTypeCfg.TrialBackEnd and XDataCenter.TrialManager.TrialRewardGetedFinish() then + self.ImgArrowUp.gameObject:SetActive(self.CurScrollState) + self.ImgArrowDown.gameObject:SetActive(not self.CurScrollState) + else + self.ImgArrowUp.gameObject:SetActive(false) + self.ImgArrowDown.gameObject:SetActive(false) + end +end + +-- auto +-- Automatic generation of code, forbid to edit +function XUiPanelTrialType:InitScript() + self:AutoAddListener() +end + +function XUiPanelTrialType:RegisterClickEvent(uiNode, func) + if func == nil then + XLog.Error("XUiPanelTrialType:RegisterClickEvent函数出错, 原因:点击回调函数不能为空") + return + end + + if type(func) ~= "function" then + XLog.Error("XUiPanelTrialType:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func)) + end + + local listener = function(...) + func(self, ...) + end + + CsXUiHelper.RegisterClickEvent(uiNode, listener) +end + +function XUiPanelTrialType:AutoAddListener() + self:RegisterClickEvent(self.BtnClick, self.OnBtnClickClick) +end +-- auto + +function XUiPanelTrialType:OnBtnClickClick() + if XDataCenter.TrialManager.FinishTrialType() == TrialTypeCfg.TrialBackEnd and XDataCenter.TrialManager.TrialRewardGetedFinish() then + self.CurScrollState = not self.CurScrollState + self.SViewTrialTypeList.gameObject:SetActive(self.CurScrollState) + self.ImgArrowUp.gameObject:SetActive(self.CurScrollState) + self.ImgArrowDown.gameObject:SetActive(not self.CurScrollState) + if self.CurScrollState and not self.InitEd then + self:UpdateTrialTypeList() + end + else + local msg = CS.XTextManager.GetText("TrialNoFinishTips") + XUiManager.TipMsg(msg,XUiManager.UiTipType.Success) + end +end + +return XUiPanelTrialType \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiTrial/XUiTrial.lua b/Resources/Scripts/XUi/XUiTrial/XUiTrial.lua new file mode 100644 index 00000000..11e57991 --- /dev/null +++ b/Resources/Scripts/XUi/XUiTrial/XUiTrial.lua @@ -0,0 +1,234 @@ +local XUiTrial = XLuaUiManager.Register(XLuaUi, "UiTrial") +local XUiPanelTrialMain = require("XUi/XUiTrial/XUiPanelTrialMain") +local XUiPanelTrialSelect = require("XUi/XUiTrial/XUiPanelTrialSelect") +local XUiPanelTrialTips = require("XUi/XUiTrial/XUiPanelTrialTips") +local XUiPanelTrialGet = require("XUi/XUiTrial/XUiPanelTrialGet") + +local ViewTypeCfg = { + TrialMain = 1, + TrialSelect = 2 +} + +local ViewTipsTypeCfg = { + TrialFor = 1, + TrialBackEnd = 2, + TrialTypeReward = 3 +} + +function XUiTrial:OnAwake() + XTool.InitUiObject(self) + self:AddListener() + self:InitUiAfterAuto() +end + +function XUiTrial:InitUiAfterAuto() + self.AssetPanel = XUiPanelAsset.New( + self, + self.PanelAsset, + XDataCenter.ItemManager.ItemId.FreeGem, + XDataCenter.ItemManager.ItemId.ActionPoint, + XDataCenter.ItemManager.ItemId.Coin + ) + self.TrialMain = XUiPanelTrialMain.New(self.PanelTrialMain, self) + self.TrialSelect = XUiPanelTrialSelect.New(self.PanelTrialSelect, self) + self.TrialTips = XUiPanelTrialTips.New(self.PanelTrialTips, self) + self.TrialGet = XUiPanelTrialGet.New(self.PanelTrialGet, self) +end + +function XUiTrial:OnStart() + +end + +-- 刚好通关前段 +function XUiTrial:OnSettleTrial() + self.TrialTips.GameObject:SetActive(true) + self:HandleForFinishTips() +end + +-- 处理前段终结 +function XUiTrial:HandleForFinishTips() + self.TrialTips:SetTrialType(ViewTipsTypeCfg.TrialFor) + self:PlayAnimation("AniTrialTips", function() + self.AniTrialTips.gameObject:SetActiveEx(false) + self:HandleBackStartTips() + end) +end + +-- 处理后段开启 +function XUiTrial:HandleBackStartTips() + self:PlayAnimation("AniTrialTips2", function() + if self.TrialTips and not XTool.UObjIsNil(self.TrialTips.GameObject) then + self.TrialTips.GameObject:SetActive(false) + end + end) + local trialtype = XDataCenter.TrialManager.TrialTypeCfg.TrialBackEnd + self.TrialMain:SetForTrialFinish(trialtype) + self.TrialMain:SetTypeTrialPro() + self.TrialTips:SetTrialType(ViewTipsTypeCfg.TrialBackEnd) +end + +-- 处理后段终结 +function XUiTrial:HandleBackFinishTips() + self:PlayAnimation("AniTrialGet") + local cfg = XTrialConfigs.GetTrialTypeCfg(XDataCenter.TrialManager.TrialTypeCfg.TrialBackEnd) + if cfg then + self.TrialGet:SetBg(cfg.BigIcon) + local rewardIdcfg = XRewardManager.GetRewardList(cfg.RewardId)[1] + if rewardIdcfg then + local name = XGoodsCommonManager.GetGoodsName(rewardIdcfg.TemplateId) + self.TrialGet:SetName(name) + end + end + self.TrialGet.GameObject:SetActive(true) + self.TrialGet:SetAnimationFx() + local btncb = function() + self.TrialGet.GameObject:SetActive(false) + XDataCenter.TrialManager.OnTrialTypeRewardRequest( + XDataCenter.TrialManager.TrialTypeCfg.TrialBackEnd, + function(rewardGoodsList) + XUiManager.OpenUiObtain(rewardGoodsList, nil, function() + local trialtype = XDataCenter.TrialManager.TrialTypeCfg.TrialTypeReward + self.TrialTips.GameObject:SetActive(true) + self.TrialTips:SetTrialType(trialtype) + self:PlayAnimation("AniTrialTips3", function() + XLuaUiManager.Close("UiTrial") + XLuaUiManager.Open("UiMain") + end) + end) + end + ) + end + self.TrialGet:SetBtnCB(btncb) +end + +-- 处理前段完成的Tips弹出 +function XUiTrial:HandleForTrialFinish() + self:PlayAnimation("AniTrialGet") + local cfg = XTrialConfigs.GetTrialTypeCfg(XDataCenter.TrialManager.TrialTypeCfg.TrialFor) + if cfg then + self.TrialGet:SetBg(cfg.BigIcon) + local rewardIdcfg = XRewardManager.GetRewardList(cfg.RewardId)[1] + if rewardIdcfg then + local name = XGoodsCommonManager.GetGoodsName(rewardIdcfg.TemplateId) + self.TrialGet:SetName(name) + end + end + self.TrialGet.GameObject:SetActive(true) + self.TrialGet:SetAnimationFx() + + local btncb = function() + self.TrialGet.GameObject:SetActive(false) + XDataCenter.TrialManager.OnTrialTypeRewardRequest( + XDataCenter.TrialManager.TrialTypeCfg.TrialFor, + function(rewardGoodsList) + XUiManager.OpenUiObtain(rewardGoodsList, nil, function() + self:OnSettleTrial() + end) + end + ) + end + self.TrialGet:SetBtnCB(btncb) +end + +-- 关闭list的item的特效,防止特效透ui。 +function XUiTrial:SetListItemFx() + self.TrialMain:SetListItemFx() +end + +-- 重新设置list的item的状态,让特效出现。 +function XUiTrial:ClostMainListItemFx() + self.TrialMain:ClostListItemFx() +end + +function XUiTrial:OnEnable() + self:OpenMainView() +end + +function XUiTrial:OnDisable() + self.TrialMain:CloseView() +end + +function XUiTrial:OnDestroy() +end + +function XUiTrial:OnGetEvents() + return { XEventId.EVENT_FUBEN_CLOSE_FUBENSTAGEDETAIL, XEventId.EVENT_FUBEN_ENTERFIGHT } +end + +-- 打开主界面 +function XUiTrial:OpenMainView() + if self.CurTrialView == ViewTypeCfg.TrialSelect then + return + end + self.CurTrialView = ViewTypeCfg.TrialMain + self.TrialMain.GameObject:SetActive(true) + self.TrialMain:OpenView() +end + +-- 奖励界面还在打开中不? +function XUiTrial:OpenRewardViewNow(flag) + self.RewardUIOpen = flag +end + + +-- 关闭主界面 +function XUiTrial:CloseMainView() + self.TrialMain:CloseView() + self.TrialMain.GameObject:SetActive(false) +end + +-- 关闭二级界面 +function XUiTrial:CloseSelectView() + self.CurTrialView = ViewTypeCfg.TrialMain + self.TrialSelect:CloseView() +end + +-- 打开二级界面 +function XUiTrial:OpenSelectView(data) + self.CurSeleData = data + self.CurTrialView = ViewTypeCfg.TrialSelect + self.TrialSelect:OpenView(data) +end + +function XUiTrial:OnNotify(evt, ...) + self.TrialSelect:OnNotify(evt, ...) +end + +-- 设置背景 +function XUiTrial:SetTrialBg(trialtype) + if trialtype == XDataCenter.TrialManager.TrialTypeCfg.TrialFor then + self.RImgForePartBg.gameObject:SetActive(true) + self.RImgBackEndBg.gameObject:SetActive(false) + else + self.RImgForePartBg.gameObject:SetActive(false) + self.RImgBackEndBg.gameObject:SetActive(true) + end + self.PreTrialBg = trialtype +end + +-- 设置背景(二级界面关闭后设置回原来界面) +function XUiTrial:ReturnPreTrialBg() + if self.PreTrialBg then + self:SetTrialBg(self.PreTrialBg) + end +end + +function XUiTrial:AddListener() + self.BtnMainUI.CallBack = function()self:OnBtnMainUIClick()end + self.BtnReturn.CallBack = function()self:OnBtnReturnClick()end + self:BindHelpBtn(self.BtnHelp, "Trial") +end +-- auto +function XUiTrial:OnBtnMainUIClick() + XLuaUiManager.RunMain() +end + +function XUiTrial:OnBtnReturnClick() + if self.CurTrialView == ViewTypeCfg.TrialMain then + XLuaUiManager.Close("UiTrial") + else + self.Dark.gameObject:SetActiveEx(true) + self:PlayAnimation("AnimStartEnable") + self:CloseSelectView() + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiUnlockShow/XUiUnlockShow.lua b/Resources/Scripts/XUi/XUiUnlockShow/XUiUnlockShow.lua new file mode 100644 index 00000000..388f1113 --- /dev/null +++ b/Resources/Scripts/XUi/XUiUnlockShow/XUiUnlockShow.lua @@ -0,0 +1,31 @@ +local XUiUnlockShow = XLuaUiManager.Register(XLuaUi, "UiUnlockShow") + +function XUiUnlockShow:OnAwake() + self.ImgUnlockShowIcon.fillAmount = 0 +end + +function XUiUnlockShow:OnStart(characterId, closeCb) + self.CharacterId = characterId + self.CloseCb = closeCb + self:UpdateUnLockPanelInfo() +end + +function XUiUnlockShow:OnDestroy() + if self.CloseCb then self.CloseCb() end +end + +function XUiUnlockShow:UpdateUnLockPanelInfo() + local characterId = self.CharacterId + + local bigIcon = XDataCenter.CharacterManager.GetCharSmallHeadIcon(characterId) + self.RImgFashionIcon:SetRawImage(bigIcon) + + local fullName = XCharacterConfigs.GetCharacterFullNameStr(characterId) + self.TxtUnlockFashionName.text = CS.XTextManager.GetText("CharUnlockTips", fullName) + + self:PlayAnimation("AniUnlockShowBegin", function() + XDataCenter.CharacterManager.ExchangeCharacter(characterId, function() + self:Close() + end) + end) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiVideo/XUiVideoPlayer.lua b/Resources/Scripts/XUi/XUiVideo/XUiVideoPlayer.lua new file mode 100644 index 00000000..ded93179 --- /dev/null +++ b/Resources/Scripts/XUi/XUiVideo/XUiVideoPlayer.lua @@ -0,0 +1,62 @@ +local XUiVideoPlayer = XLuaUiManager.Register(XLuaUi, "UiVideoPlayer") + +function XUiVideoPlayer:OnAwake() + self.VideoPlayerUgui.ActionEnded = handler(self, self.LoopPointReached) + self.IsPause = false + self.BtnAuto.CallBack = function() self:Pause() end + self.BtnSkip.CallBack = function() self:Stop() end +end + + +function XUiVideoPlayer:OnStart(movieId, closeCb, needAuto, needSkip) + self.MovieId = movieId + self.CloseCb = closeCb + if needAuto == nil then + needAuto = true + end + if needSkip == nil then + needSkip = true + end + local config = XVideoConfig.GetMovieById(self.MovieId) + self.VideoPlayerUgui:SetVideoFromRelateUrl(config.VideoUrl) + self.VideoPlayerUgui:Play() + + self.BtnAuto.gameObject:SetActiveEx(needAuto) + self.BtnSkip.gameObject:SetActiveEx(needSkip) + + XDataCenter.VideoManager.SetVideoPlayer(self.VideoPlayerUgui) +end + +function XUiVideoPlayer:OnDestroy() + + XDataCenter.VideoManager.Stop() + + if self.CloseCb then + self.CloseCb() + end +end + + +function XUiVideoPlayer:LoopPointReached() + XDataCenter.VideoManager.Stop() + + XScheduleManager.ScheduleOnce(function() + self:Close() + end, 0) +end + + +function XUiVideoPlayer:Stop() + self.VideoPlayerUgui:Stop() + self:Close() +end + + +function XUiVideoPlayer:Pause() + self.IsPause = not self.IsPause + if self.IsPause then + self.VideoPlayerUgui:Pause() + else + self.VideoPlayerUgui:Resume() + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiWaterMask/XUiSuperWaterMarks.lua b/Resources/Scripts/XUi/XUiWaterMask/XUiSuperWaterMarks.lua new file mode 100644 index 00000000..e822fe35 --- /dev/null +++ b/Resources/Scripts/XUi/XUiWaterMask/XUiSuperWaterMarks.lua @@ -0,0 +1,19 @@ +local OBJECT_COUNT = 204 + +local XUiSuperWaterMarks = XLuaUiManager.Register(XLuaUi, "UiSuperWaterMarks") + +function XUiSuperWaterMarks:OnAwake() + self:InitUiObjects() +end + +function XUiSuperWaterMarks:OnStart() + + self.TextId.text = XPlayer.Id + + if self.ObjectPool:Exist() then + for i = 1, OBJECT_COUNT do + self.ObjectPool:Spawn() + end + end + +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiWaterMask/XUiWaterMask.lua b/Resources/Scripts/XUi/XUiWaterMask/XUiWaterMask.lua new file mode 100644 index 00000000..e6ded81d --- /dev/null +++ b/Resources/Scripts/XUi/XUiWaterMask/XUiWaterMask.lua @@ -0,0 +1,10 @@ +local XUiWaterMask = XLuaUiManager.Register(XLuaUi, "UiWaterMask") + +function XUiWaterMask:OnAwake() + self:InitUiObjects() +end + +function XUiWaterMask:OnStart() + self.TopId.text = XPlayer.Id + self.BottomId.text = XPlayer.Id +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiWindowsInlay/XUiWindowsInlay.lua b/Resources/Scripts/XUi/XUiWindowsInlay/XUiWindowsInlay.lua new file mode 100644 index 00000000..7122b312 --- /dev/null +++ b/Resources/Scripts/XUi/XUiWindowsInlay/XUiWindowsInlay.lua @@ -0,0 +1,85 @@ +local XUiWindowsInlay = XLuaUiManager.Register(XLuaUi, "UiWindowsInlay") +local XHtmlHandler = require("XUi/XUiGameNotice/XHtmlHandler") +local Object = CS.UnityEngine.Object +local textUrl = [[file://]] .. CS.UnityEngine.Application.persistentDataPath .. "/test/url.txt" ---方便测试 +function XUiWindowsInlay:OnStart() + self.ActivityList = {} + self.ActivityBtn = {} + self:SetButtonCallBack() + self:InitButton() +end + +function XUiWindowsInlay:OnEnable() + self.PanelBottomRight:SelectIndex(self.CurIndex) +end + +function XUiWindowsInlay:OnDisable() + if not XTool.UObjIsNil(self.WebViewPanel) then + CS.UnityEngine.Object.DestroyImmediate(self.WebViewPanel.gameObject) + self.WebViewPanel = nil + end +end + +function XUiWindowsInlay:SetButtonCallBack() + self.BtnBack.CallBack = function() + self:OnBtnBackClick() + end + self.BtnMainUi.CallBack = function() + self:OnBtnMainUiClick() + end +end + +function XUiWindowsInlay:InitButton() + self.ActivityList = XDataCenter.MarketingActivityManager.GetWindowsInlayInTimeActivityList() + self.BtnTabActivity.gameObject:SetActive(false) + self.CurIndex = 1 + for _, activity in pairs(self.ActivityList) do + local btn = Object.Instantiate(self.BtnTabActivity) + btn.gameObject:SetActive(true) + btn.transform:SetParent(self.PanelBottomRight.transform, false) + local btncs = btn:GetComponent("XUiButton") + local name = activity.Title + btncs:SetName(name or "Null") + table.insert(self.ActivityBtn, btncs) + end + self.PanelBottomRight:Init(self.ActivityBtn, function(index) self:SelectActivity(index) end) +end + +function XUiWindowsInlay:SelectActivity(index) + local activityInfo = self.ActivityList[index] + local url = activityInfo and activityInfo.Url or "" + local type = activityInfo and activityInfo.Type or 0 + + if type == XMarketingActivityConfigs.WebType.Normal then + self:ShowHtml(url) + elseif type == XMarketingActivityConfigs.WebType.Vote then + XDataCenter.MarketingActivityManager.RequestVoteToken(type, function () + XScheduleManager.ScheduleOnce(function() + local token = XDataCenter.MarketingActivityManager.GetWindowsInlayTokenByType(type) + self:ShowHtml(url, token) + end, 1) + end) + end + +end + +function XUiWindowsInlay:OnBtnBackClick() + self:Close() +end + +function XUiWindowsInlay:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiWindowsInlay:ShowHtml(webUrl, token) + if not XTool.UObjIsNil(self.WebViewPanel) then + CS.UnityEngine.Object.DestroyImmediate(self.WebViewPanel.gameObject) + self.WebViewPanel = nil + end + + local urlStr = token and string.format("%s?token=%s", webUrl, token) or webUrl + self.WebViewPanel = CS.UnityEngine.Object.Instantiate(self.PanelWebView, self.PanelWebView.parent) + local webView = CS.XWebView.GetWebView(self.WebViewPanel.gameObject, function() XLog.Error("XUiWindowsInlay:ShowHtml函数错误, 原因网络加载异常", url) end) + webView:LoadURL(string.gsub(urlStr, " ", XHtmlHandler.FilterSpecialSymbol("%20"))) + +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiWorldBoss/XUiChatUiWorldBoss.lua b/Resources/Scripts/XUi/XUiWorldBoss/XUiChatUiWorldBoss.lua new file mode 100644 index 00000000..98d77db3 --- /dev/null +++ b/Resources/Scripts/XUi/XUiWorldBoss/XUiChatUiWorldBoss.lua @@ -0,0 +1,65 @@ +local XUiChatUiWorldBoss = XLuaUiManager.Register(XLuaUi, "UiChatUiWorldBoss") +local XUiGridReportMsgItem = require("XUi/XUiWorldBoss/XUiGridReportMsgItem") + +function XUiChatUiWorldBoss:OnStart() + self:SetButtonCallBack() + self:InitDynamicTable() + self:UpdateReportData() +end + +function XUiChatUiWorldBoss:OnDestroy() +end + +function XUiChatUiWorldBoss:OnEnable() + XDataCenter.WorldBossManager.CheckWorldBossActivityReset() + XLuaUiManager.SetMask(true) + XEventManager.AddEventListener(XEventId.EVENT_WORLDBOSS_REPORT, self.UpdateReportData, self) + self:PlayAnimation("AnimChatEnter", function() + XLuaUiManager.SetMask(false) + end) + +end + +function XUiChatUiWorldBoss:OnDisable() + XEventManager.RemoveEventListener(XEventId.EVENT_WORLDBOSS_REPORT, self.UpdateReportData, self) +end + +function XUiChatUiWorldBoss:UpdateReportData() + self:SetupDynamicTable() +end + +function XUiChatUiWorldBoss:InitDynamicTable() + self.DynamicTable = XDynamicTableNormal.New(self.PanelChatView) + self.DynamicTable:SetProxy(XUiGridReportMsgItem) + self.GridChatItem.gameObject:SetActiveEx(false) + self.DynamicTable:SetDelegate(self) +end + +function XUiChatUiWorldBoss:SetupDynamicTable() + self.PageDatas = XDataCenter.WorldBossManager.GetWorldBossReportList() + self.DynamicTable:SetDataSource(self.PageDatas) + self.DynamicTable:ReloadDataSync(#self.PageDatas) +end + +function XUiChatUiWorldBoss:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:Refresh(self.PageDatas[index]) + end +end + +function XUiChatUiWorldBoss:SetButtonCallBack() + self.BtnClocs.CallBack = function() + self:OnBtnCloseClick() + end + self.BtnChat.CallBack = function() + self:OnBtnClocsClick() + end +end + +function XUiChatUiWorldBoss:OnBtnCloseClick() + XLuaUiManager.SetMask(true) + self:PlayAnimation("AnimChatOut", function() + XLuaUiManager.SetMask(false) + self:Close() + end) +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiWorldBoss/XUiGridAttributeChapter.lua b/Resources/Scripts/XUi/XUiWorldBoss/XUiGridAttributeChapter.lua new file mode 100644 index 00000000..f0a39e04 --- /dev/null +++ b/Resources/Scripts/XUi/XUiWorldBoss/XUiGridAttributeChapter.lua @@ -0,0 +1,113 @@ +local XUiGridAttributeStage = require("XUi/XUiWorldBoss/XUiGridAttributeStage") +local XUiGridAttributeChapter = XClass(nil, "UiGridAttributeChapter") + +local FocusTime = 0.5 +local ScaleLevel = {} +local MAX_STAGE_COUNT = 20 +function XUiGridAttributeChapter:Ctor(ui, areaId) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.AreaId = areaId + self.GridStageList = {} + ScaleLevel = { + Small = self.PanelDrag.MinScale, + Big = self.PanelDrag.MaxScale, + Normal = (self.PanelDrag.MinScale + self.PanelDrag.MaxScale) / 2, + } + self.Mask.gameObject:SetActiveEx(false) + +end + +function XUiGridAttributeChapter:GoToNearestStage() + local attributeArea = XDataCenter.WorldBossManager.GetAttributeAreaById(self.AreaId) + local stageIds = attributeArea:GetStageIds() + local canPlayList = {} + for index, stageId in pairs(stageIds) do + local stageData = attributeArea:GetStageEntityById(stageId) + if not stageData:GetIsFinish() and not stageData:GetIsLock() then + table.insert(canPlayList, index) + end + end + + if #canPlayList > 0 then + local firstCanPlayId = canPlayList[1] + local firstGridStage = self.GridStageList[firstCanPlayId] + if not firstGridStage then + XLog.Error("ExploreGroup's setting is Error by stageIndex:" .. firstCanPlayId) + return + end + + local nearestTransform = firstGridStage.Transform + local minDis = CS.UnityEngine.Vector3.Distance(nearestTransform.position, self.PanelDrag.gameObject.transform.position) + for i = 2, #canPlayList do + local canPlayId = canPlayList[i] + local gridStage = self.GridStageList[canPlayId] + if not gridStage then + XLog.Error("ExploreGroup's setting is Error by stageIndex:" .. canPlayId) + break + end + local tempDis = CS.UnityEngine.Vector3.Distance(gridStage.Transform.position, self.PanelDrag.gameObject.transform.position) + if tempDis < minDis then + nearestTransform = gridStage.Transform + minDis = tempDis + end + end + self.PanelDrag:FocusTarget(nearestTransform, ScaleLevel.Normal, FocusTime, CS.UnityEngine.Vector3.zero) + end +end + +function XUiGridAttributeChapter:UpdateStageList() + local attributeArea = XDataCenter.WorldBossManager.GetAttributeAreaById(self.AreaId) + local stageIds = attributeArea:GetStageIds() + + -- 初始化副本显示列表,i作为order id,从1开始 + for index,stageId in pairs(stageIds) do + local stageData = attributeArea:GetStageEntityById(stageId) + local stageCfg = stageData:GetStageCfg() + local parent = self.PanelStageContent.transform:Find(string.format("Stage%d", index)) + local grid = self.GridStageList[index] + + if not grid then + local uiName = "GridWorldBossStage" + uiName = stageCfg.StageGridStyle and string.format("%s%s", uiName, stageCfg.StageGridStyle) or uiName + + + local prefabName = CS.XGame.ClientConfig:GetString(uiName) + local prefab = parent:LoadPrefab(prefabName) + + grid = XUiGridAttributeStage.New(prefab, self) + grid.Parent = parent + self.GridStageList[index] = grid + end + + grid:UpdateStageGrid(stageData) + parent.gameObject:SetActiveEx(true) + end + + + for i = 1, MAX_STAGE_COUNT do + if not self.GridStageList[i] then + local parent = self.PanelStageContent.transform:Find(string.format("Stage%d", i)) + if parent then + parent.gameObject:SetActiveEx(false) + end + end + end +end + +function XUiGridAttributeChapter:MoveToStageGrid(cb) + self.Mask.gameObject:SetActiveEx(true) + XScheduleManager.ScheduleOnce(function() + self.PanelDrag:FocusTarget(self.CurStageGrid.Transform, ScaleLevel.Big, FocusTime, CS.UnityEngine.Vector3.zero, function() + if cb then cb() end + self.Mask.gameObject:SetActiveEx(false) + end) + end, 0) +end + +function XUiGridAttributeChapter:ScaleBack() + self.PanelDrag:FocusTarget(self.CurStageGrid.Transform, ScaleLevel.Normal, FocusTime, CS.UnityEngine.Vector3.zero, nil) +end + +return XUiGridAttributeChapter \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiWorldBoss/XUiGridAttributeStage.lua b/Resources/Scripts/XUi/XUiWorldBoss/XUiGridAttributeStage.lua new file mode 100644 index 00000000..e26af71d --- /dev/null +++ b/Resources/Scripts/XUi/XUiWorldBoss/XUiGridAttributeStage.lua @@ -0,0 +1,104 @@ +local stringFormat = string.format +local XUiGridAttributeStage = XClass(nil, "XUiGridAttributeStage") + +function XUiGridAttributeStage:Ctor(ui, base) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.IsSelect = false + self.Base = base + XTool.InitUiObject(self) + self:SetButtonCallBack() + self:SetSelectState(false) +end + +function XUiGridAttributeStage:SetButtonCallBack() + self.BtnStage.CallBack = function() + self:OnBtnStageClick() + end + self.BtnBuff.CallBack = function() + self:OnBtnBuffClick() + end +end + +function XUiGridAttributeStage:UpdateStageGrid(stageData) + self.StageData = stageData + if stageData then + local stageCfg = stageData:GetStageCfg() + local IsHaveBuff = false + local percent = self.StageData:GetFinishPercent() + local IsHaveRed = XDataCenter.WorldBossManager.CheckWorldBossStageRedPoint(self.Base.AreaId,stageData:GetId()) + self.StageIcon:SetRawImage(stageCfg.Icon) + self.StageName.text = stageCfg.Name + self.Schedule.fillAmount = percent + self.ScheduleNum.text = string.format("%d%s",math.floor(percent * 100),"%") + for _,buffId in pairs(stageData:GetBuffIds()) do + self.BuffData = XDataCenter.WorldBossManager.GetWorldBossBuffById(buffId) + if self.BuffData then + IsHaveBuff = true + self.BuffIcon:SetRawImage(self.BuffData:GetIcon()) + break + end + end + + self.PanelClear.gameObject:SetActiveEx(stageData:GetIsFinish()) + self.BuffLock.gameObject:SetActiveEx(not stageData:GetIsFinish()) + self.BuffActive.gameObject:SetActiveEx(stageData:GetIsFinish()) + self.PanelWorldBossRewardParent.gameObject:SetActiveEx(IsHaveBuff) + self.PanelWorldBossLockParent.gameObject:SetActiveEx(stageData:GetIsLock()) + self.PanelWorldBossIngParent.gameObject:SetActiveEx(not stageData:GetIsLock() and not stageData:GetIsFinish()) + self.BtnStage:ShowReddot(IsHaveRed) + end +end + +function XUiGridAttributeStage:SetSelectState(IsSelect) + self.ImageSelect.gameObject:SetActiveEx(IsSelect) +end + +function XUiGridAttributeStage:OnBtnStageClick() + if not self.StageData then + return + end + + if self.StageData:GetIsLock() then + XUiManager.TipMsg(self.StageData:GetLockDesc()) + return + end + + local curGrid = self.Base.CurStageGrid + if curGrid and (curGrid.StageData:GetId() == self.StageData:GetId()) then + return + end + -- 取消上一个选择 + if curGrid then + curGrid:SetSelectState(false) + end + + if not self.StageData:GetIsLock() then + local storyId = self.StageData:GetStartStoryId() + + if storyId and #storyId > 1 then + local IsCanPlay = XDataCenter.WorldBossManager.CheckIsNewStoryID(storyId) + if IsCanPlay then + XDataCenter.MovieManager.PlayMovie(storyId)--一次 + XDataCenter.WorldBossManager.MarkStoryID(storyId) + end + end + end + + self:SetSelectState(true) + self.Base.CurStageGrid = self + self.Base:MoveToStageGrid() + XLuaUiManager.Open("UiWorldBossDetail", self.StageData, self.Base.AreaId, function () + self.Base:ScaleBack() + self.Base.CurStageGrid = nil + self:SetSelectState(false) + end,function () + self:UpdateStageGrid(self.StageData) + end) +end + +function XUiGridAttributeStage:OnBtnBuffClick() + XLuaUiManager.Open("UiWorldBossTips", self.BuffData:GetId(), true) +end + +return XUiGridAttributeStage \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiWorldBoss/XUiGridBossReward.lua b/Resources/Scripts/XUi/XUiWorldBoss/XUiGridBossReward.lua new file mode 100644 index 00000000..a6db9067 --- /dev/null +++ b/Resources/Scripts/XUi/XUiWorldBoss/XUiGridBossReward.lua @@ -0,0 +1,54 @@ +local XUiGridBossReward = XClass(nil, "XUiGridBossReward") +local CSTextManagerGetText = CS.XTextManager.GetText +function XUiGridBossReward:Ctor(ui,base,areaId) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Base = base + self.AreaId = areaId + XTool.InitUiObject(self) + + self:SetButtonCallBack() +end + +function XUiGridBossReward:SetButtonCallBack() + self.BtnActive.CallBack = function() + self:OnBtnActiveClick() + end +end + + +function XUiGridBossReward:OnBtnActiveClick() + local rewardData = XRewardManager.GetRewardList(self.Data:GetRewardId()) + if self.Data:GetIsCanGet() then + if self.Data:GetIsGeted() then + return + end + if not self.AreaId then + return + end + XDataCenter.WorldBossManager.GetBossPhasesReward(self.AreaId, self.Data:GetId(),function () + self.Base:UpdatePanelPhasesReward() + end) + else + XUiManager.OpenUiTipReward(rewardData, CSTextManagerGetText("DailyActiveRewardTitle")) + end +end + +function XUiGridBossReward:UpdateData(data) + self.Data = data + if data then + if data:GetIsCanGet() then + self.ImgActive:SetSprite(CS.XGame.ClientConfig:GetString("TaskDailyActiveReach1")) + self.PanelEffect.gameObject:SetActiveEx(not data:GetIsGeted()) + self.ImgRe.gameObject:SetActiveEx(data:GetIsGeted()) + else + self.ImgActive:SetSprite(CS.XGame.ClientConfig:GetString("TaskDailyActiveNotReach1")) + self.PanelEffect.gameObject:SetActiveEx(false) + self.ImgRe.gameObject:SetActiveEx(false) + end + local hpPercent = data:GetHpPercent() + self.ScheduleCount.text = string.format("%d%s",hpPercent,"%") + end +end + +return XUiGridBossReward \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiWorldBoss/XUiGridBtnAttributeArea.lua b/Resources/Scripts/XUi/XUiWorldBoss/XUiGridBtnAttributeArea.lua new file mode 100644 index 00000000..2ecda194 --- /dev/null +++ b/Resources/Scripts/XUi/XUiWorldBoss/XUiGridBtnAttributeArea.lua @@ -0,0 +1,50 @@ +local XUiGridBtnAttributeArea = XClass(nil, "XUiGridBtnAttributeArea") +local CSTextManagerGetText = CS.XTextManager.GetText +function XUiGridBtnAttributeArea:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + self:SetButtonCallBack() +end + +function XUiGridBtnAttributeArea:SetButtonCallBack() + self.BtnArea.CallBack = function() + self:OnBtnAreaClick() + end +end + +function XUiGridBtnAttributeArea:OnBtnAreaClick() + local storyId = self.Data:GetStartStoryId() + if storyId and #storyId > 1 then + local IsCanPlay = XDataCenter.WorldBossManager.CheckIsNewStoryID(storyId) + if IsCanPlay then + XDataCenter.MovieManager.PlayMovie(storyId)--一次 + XDataCenter.WorldBossManager.MarkStoryID(storyId) + end + end + XLuaUiManager.Open("UiWorldBossAttributeArea", self.Data:GetId()) +end + +function XUiGridBtnAttributeArea:UpdateData(data) + self.Data = data + if data then + local IsHaveRed = XDataCenter.WorldBossManager.CheckWorldBossAttributeArearRedPoint(data:GetId()) + + self.ScheduleText.text = CSTextManagerGetText("WorldBossAttributeAreaSchedule") + self.NumText.text = string.format("%d/%d", data:GetFinishStageCount(), #data:GetStageIds()) + self.BtnArea:SetRawImage(data:GetAreaImg()) + self.BtnArea:SetName(data:GetEnglishName()) + + self.NumText.gameObject:SetActiveEx(data:GetFinishStageCount() ~= #data:GetStageIds()) + self.CompleteImg.gameObject:SetActiveEx(data:GetFinishStageCount() == #data:GetStageIds()) + self.ScheduleText.gameObject:SetActiveEx(data:GetFinishStageCount() ~= #data:GetStageIds()) + self.BtnArea:ShowReddot(IsHaveRed) + end +end + +function XUiGridBtnAttributeArea:ShowRedPoint(IsShow) + self.BtnBoss:ShowReddot(IsShow) +end + +return XUiGridBtnAttributeArea \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiWorldBoss/XUiGridBtnBossArea.lua b/Resources/Scripts/XUi/XUiWorldBoss/XUiGridBtnBossArea.lua new file mode 100644 index 00000000..cb62569e --- /dev/null +++ b/Resources/Scripts/XUi/XUiWorldBoss/XUiGridBtnBossArea.lua @@ -0,0 +1,69 @@ +local XUiGridBtnBossArea = XClass(nil, "XUiGridBtnBossArea") +local CSTextManagerGetText = CS.XTextManager.GetText +function XUiGridBtnBossArea:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + + self:SetButtonCallBack() +end + +function XUiGridBtnBossArea:SetButtonCallBack() + self.BtnBoss.CallBack = function() + self:OnBtnBossClick() + end +end + +function XUiGridBtnBossArea:OnBtnBossClick() + if self.Data:GetIsLock() then + local worldBossActivity = XDataCenter.WorldBossManager.GetCurWorldBossActivity() + local finishStageCount = worldBossActivity:GetFinishStageCount() + local hintText = CS.XTextManager.GetText("WorldBossBossAreaUnLockHint", finishStageCount, self.Data:GetOpenCount()) + XUiManager.TipMsg(hintText) + return + end + if not self.Data:GetIsFinish() then + local storyId = self.Data:GetStartStoryId() + if storyId and #storyId > 1 then + local IsCanPlay = XDataCenter.WorldBossManager.CheckIsNewStoryID(storyId) + if IsCanPlay then + XDataCenter.MovieManager.PlayMovie(storyId)--一次 + XDataCenter.WorldBossManager.MarkStoryID(storyId) + end + end + end + XLuaUiManager.Open("UiWorldBossBossArea", self.Data:GetId()) +end + +function XUiGridBtnBossArea:UpdateData(data) + self.Data = data + if data then + local hpPercent = data:GetHpPercent() + local IsHaveRed = XDataCenter.WorldBossManager.CheckWorldBossBossArearRedPoint(data:GetId()) + + self.Title.text = CSTextManagerGetText("WorldBossBossAreaSchedule") + local hpProcess = hpPercent * 100 -- 海外修改如果小于百分之一,向上取整 + if hpProcess > 1 then + self.PercentageText.text = string.format("%d%s",math.floor(hpProcess),"%") + else + self.PercentageText.text = string.format("%d%s",math.ceil(hpProcess),"%") + end + if data:GetIsLock() then + self.BtnBoss:SetSprite(data:GetAreaLockImg()) + else + self.BtnBoss:SetSprite(data:GetAreaImg()) + end + self.BtnBoss:SetDisable(data:GetIsLock()) + self.Handle.fillAmount = hpPercent + self.Progress.gameObject:SetActiveEx(not data:GetIsLock()) + self.BtnBoss:ShowReddot(IsHaveRed) + self.KillText.gameObject:SetActiveEx(hpPercent == 0) + self.Title.gameObject:SetActiveEx(hpPercent ~= 0) + end +end + +function XUiGridBtnBossArea:ShowRedPoint(IsShow) + self.BtnBoss:ShowReddot(IsShow) +end + +return XUiGridBtnBossArea \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiWorldBoss/XUiGridBuff.lua b/Resources/Scripts/XUi/XUiWorldBoss/XUiGridBuff.lua new file mode 100644 index 00000000..220726c5 --- /dev/null +++ b/Resources/Scripts/XUi/XUiWorldBoss/XUiGridBuff.lua @@ -0,0 +1,46 @@ +local XUiGridBuff = XClass(nil, "XUiGridBuff") + +function XUiGridBuff:Ctor(ui,IsShowCondition) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.AreaId = areaId + self.IsShowCondition = IsShowCondition + XTool.InitUiObject(self) + + self:SetButtonCallBack() +end + +function XUiGridBuff:SetButtonCallBack() + self.BtnBuff.CallBack = function() + self:OnBtnBuffClick() + end +end + +function XUiGridBuff:OnBtnBuffClick() + XLuaUiManager.Open("UiWorldBossTips",self.Data:GetId(), self.IsShowCondition) +end + +function XUiGridBuff:UpdateData(data) + self.Data = data + local lockRawImage = XUiHelper.TryGetComponent(self.Transform, "Locked", "RawImage") + if data then + if self.BuffIcon then + self.BuffIcon:SetRawImage(data:GetIcon()) + self.BuffIcon.gameObject:SetActiveEx(not data:GetIsLock() or not self.IsShowCondition) + end + if self.Locked then + self.Locked.gameObject:SetActiveEx(data:GetIsLock()) + if lockRawImage then + lockRawImage:SetRawImage(data:GetIcon()) + end + end + if self.BuffBg then + self.BuffBg.gameObject:SetActiveEx(data:GetType() == XWorldBossConfigs.BuffType.Buff) + end + if self.ImgBuff then + self.ImgBuff:SetSprite(data:GetIcon()) + end + end +end + +return XUiGridBuff \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiWorldBoss/XUiGridLevelSelect.lua b/Resources/Scripts/XUi/XUiWorldBoss/XUiGridLevelSelect.lua new file mode 100644 index 00000000..b4710bf1 --- /dev/null +++ b/Resources/Scripts/XUi/XUiWorldBoss/XUiGridLevelSelect.lua @@ -0,0 +1,36 @@ +local XUiGridLevelSelect = XClass(nil, "XUiGridLevelSelect") +local CSTextManagerGetText = CS.XTextManager.GetText +function XUiGridLevelSelect:Ctor(ui, base) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Base = base + XTool.InitUiObject(self) + + self:SetButtonCallBack() +end + +function XUiGridLevelSelect:SetButtonCallBack() + self.BtnSelect.CallBack = function() + self:OnBtnSelectClick() + end +end + +function XUiGridLevelSelect:OnBtnSelectClick() + if self.Data then + self.Base.CurBossLevel = self.Data.Id + self.Base:OnBtnCloseClick() + end +end + +function XUiGridLevelSelect:UpdateData(data) + self.Data = data + if data then + --data.Icon--可能需要追加Icon显示组件 + self.TxtDamege.text = CSTextManagerGetText("WorldBossLevelDamege",data.HurtHp) + self.TxtPower.text = CSTextManagerGetText("WorldBossLevelAdvise",data.RecommendAbility) + self.LevelText.text = data.Desc + self.LevelText.color = XUiHelper.Hexcolor2Color(data.DescColor) + end +end + +return XUiGridLevelSelect \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiWorldBoss/XUiGridReportMsgItem.lua b/Resources/Scripts/XUi/XUiWorldBoss/XUiGridReportMsgItem.lua new file mode 100644 index 00000000..ce432908 --- /dev/null +++ b/Resources/Scripts/XUi/XUiWorldBoss/XUiGridReportMsgItem.lua @@ -0,0 +1,48 @@ +local XUiGridReportMsgItem = XClass(nil, "XUiGridReportMsgItem") +local CSXGameClientConfig = CS.XGame.ClientConfig +local CSTextManagerGetText = CS.XTextManager.GetText +function XUiGridReportMsgItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiGridReportMsgItem:Refresh(reportData) + local playerInfo = reportData.PlayerInfo + local reportId = reportData.ReportId + local reportCfg = XWorldBossConfigs.GetReportTemplatesById(reportId) + local reportType = XDataCenter.WorldBossManager.GetFightReportTypeById(reportId) + local IsSystemReport = reportType == XWorldBossConfigs.ReportType.System + + self.PanelSystemMsgItem.gameObject:SetActiveEx(IsSystemReport) + self.PanelPlayerMsgItem.gameObject:SetActiveEx(not IsSystemReport) + + if IsSystemReport then + local headObj = self.PanelSystemMsgItem:GetObject("Head") + local nameObj = self.PanelSystemMsgItem:GetObject("TxtName") + local wordObj = self.PanelSystemMsgItem:GetObject("TxtWord") + + local headId = CSXGameClientConfig:GetInt("WorldBossReportHead") + local nameText = CSTextManagerGetText("WorldBossReportName") + local wordText = reportCfg.Message + + XUiPLayerHead.InitPortrait(headId, 0, headObj) + nameObj.text = nameText + wordObj.text = wordText + else + local headObj = self.PanelPlayerMsgItem:GetObject("Head") + local nameObj = self.PanelPlayerMsgItem:GetObject("TxtName") + local wordObj = self.PanelPlayerMsgItem:GetObject("TxtWord") + + local headId = playerInfo.HeadPortraitId + local headFrameId = playerInfo.HeadFrameId + local nameText = playerInfo.PlayerName + local score = playerInfo.Score + local wordText = string.format(reportCfg.Message,nameText,score) + + XUiPLayerHead.InitPortrait(headId, headFrameId, headObj) + nameObj.text = nameText + wordObj.text = wordText + end +end +return XUiGridReportMsgItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiWorldBoss/XUiGridTipsInfo.lua b/Resources/Scripts/XUi/XUiWorldBoss/XUiGridTipsInfo.lua new file mode 100644 index 00000000..a3fcf640 --- /dev/null +++ b/Resources/Scripts/XUi/XUiWorldBoss/XUiGridTipsInfo.lua @@ -0,0 +1,22 @@ +local XUiGridTipsInfo = XClass(nil, "XUiGridTipsInfo") +local CSTextManagerGetText = CS.XTextManager.GetText +local CSXGameClientConfig = CS.XGame.ClientConfig +function XUiGridTipsInfo:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) +end + +function XUiGridTipsInfo:UpdateData(data,IsShowCondition) + if data then + local infoColor = CSXGameClientConfig:GetString("WorldBossUnLockInfoColor") + self.TitleText.text = data:GetInfoTitle() + self.TxtBuffDescription.text = data:GetInfoText() + self.TxtBuffDescription.color = XUiHelper.Hexcolor2Color(IsShowCondition and data:GetInfoTextColor() or infoColor) + self.TxtBuffCondition.text = data:GetLockDesc() + self.TxtBuffCondition.color = XUiHelper.Hexcolor2Color(data:GetLockDescColor()) + self.TxtBuffCondition.gameObject:SetActiveEx(IsShowCondition) + end +end + +return XUiGridTipsInfo \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiWorldBoss/XUiGridWorldBossAreaRankItem.lua b/Resources/Scripts/XUi/XUiWorldBoss/XUiGridWorldBossAreaRankItem.lua new file mode 100644 index 00000000..92e89549 --- /dev/null +++ b/Resources/Scripts/XUi/XUiWorldBoss/XUiGridWorldBossAreaRankItem.lua @@ -0,0 +1,31 @@ +local XUiGridWorldBossTeamList = require("XUi/XUiWorldBoss/XUiGridWorldBossTeamList") +local XUiGridWorldBossAreaRankItem = XClass(nil, "XUiGridWorldBossAreaRankItem") + +function XUiGridWorldBossAreaRankItem:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.BtnDetail.CallBack = function() self:OnBtnDetailClick() end +end + +function XUiGridWorldBossAreaRankItem:Init(data) + if data then + self.Id = data.Id + self.TxtScore.text = data.Score + self.TxtName.text = data.Name + self.TxtRank.text = data.Rank + if self.Team == nil then + self.Team = XUiGridWorldBossTeamList.New(self.TeamObj) + end + XUiPLayerHead.InitPortrait(data.HeadPortraitId, data.HeadFrameId, self.UObjHead) + self.Team:Init(data.CharacterInfos) + end +end + +function XUiGridWorldBossAreaRankItem:OnBtnDetailClick() + if self.Id ~= XPlayer.Id then + XDataCenter.PersonalInfoManager.ReqShowInfoPanel(self.Id) + end +end + +return XUiGridWorldBossAreaRankItem \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiWorldBoss/XUiGridWorldBossTeamList.lua b/Resources/Scripts/XUi/XUiWorldBoss/XUiGridWorldBossTeamList.lua new file mode 100644 index 00000000..266dbc77 --- /dev/null +++ b/Resources/Scripts/XUi/XUiWorldBoss/XUiGridWorldBossTeamList.lua @@ -0,0 +1,35 @@ +local XUiGridWorldBossTeamList = XClass(nil, "XUiGridWorldBossTeamList") + +function XUiGridWorldBossTeamList:Ctor(ui) + self.GameObject = ui.gameObject + self.Transform = ui.transform + XTool.InitUiObject(self) + self.MaxHeadNum = 3 +end + +function XUiGridWorldBossTeamList:Init(data) + if not data then + return + end + for i = 1, self.MaxHeadNum do + if not data[i] or data[i].Id == 0 then + self["TeamHeadObj" .. i].gameObject:SetActiveEx(false) + else + self["TeamHeadObj" .. i].gameObject:SetActiveEx(true) + if i <= #data then + self["TryMarkObj" .. i].gameObject:SetActiveEx(false) + + local characterId = data[i].Id + local iconPath = XDataCenter.CharacterManager.GetCharSmallHeadIcon(characterId, data[i].LiberateLv, true) + + self["ImgHead" .. i]:SetRawImage(iconPath) + + self["TeamHeadObj" .. i].gameObject:SetActiveEx(true) + else + self["TeamHeadObj" .. i].gameObject:SetActiveEx(false) + end + end + end +end + +return XUiGridWorldBossTeamList \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiWorldBoss/XUiPanelDetail.lua b/Resources/Scripts/XUi/XUiWorldBoss/XUiPanelDetail.lua new file mode 100644 index 00000000..7e46bb93 --- /dev/null +++ b/Resources/Scripts/XUi/XUiWorldBoss/XUiPanelDetail.lua @@ -0,0 +1,128 @@ +local XUiPanelDetail = XClass(nil, "XUiPanelDetail") +local XUiGridBuff = require("XUi/XUiWorldBoss/XUiGridBuff") +local CSTextManagerGetText = CS.XTextManager.GetText + +function XUiPanelDetail:Ctor(ui, base, areaId) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Base = base + self.AreaId = areaId + XTool.InitUiObject(self) + self:SetButtonCallBack() + self:SetActivityInfo() +end + +function XUiPanelDetail:SetButtonCallBack() + self.BtnBoss.CallBack = function() + self:OnBtnBossClick() + end +end + +function XUiPanelDetail:UpdateActivityInfo() + local worldBossActivity = XDataCenter.WorldBossManager.GetCurWorldBossActivity() + local bossArea = worldBossActivity:GetBossAreaEntityById(self.AreaId) + local actionPointId = worldBossActivity:GetActionPointId() + local challengeCount = bossArea:GetChallengeCount() + local maxChallengeCount = bossArea:GetMaxChallengeCount() + local maxActionPoint = worldBossActivity:GetMaxActionPoint() + local powerCount = XDataCenter.ItemManager.GetCount(actionPointId) + + self.PowerText.text = CSTextManagerGetText("WorldBossActionPoint") + self.PowerCount.text = string.format("%d/%d",powerCount,maxActionPoint) + self.ChallengeText.text = CSTextManagerGetText("WorldBossBossChallengeText") + self.ChallengeCount.text = string.format("%d/%d",maxChallengeCount - challengeCount,maxChallengeCount) +end + +function XUiPanelDetail:SetActivityInfo() + local worldBossActivity = XDataCenter.WorldBossManager.GetCurWorldBossActivity() + local actionPointId = worldBossActivity:GetActionPointId() + local bossArea = worldBossActivity:GetBossAreaEntityById(self.AreaId) + local bossBuffList = worldBossActivity:GetBossBuffList() + local desc = bossArea:GetAreaDesc() + + self.TxtDesc.text = desc + + local item = XUiGridCommon.New(self, self.PowerItemGrid) + item:Refresh(actionPointId) + + local tmpGroupFlag = {} + local tmpIdFlag = {} + local buffList = {} + self.BuffItem.gameObject:SetActiveEx(false) + for _,buffId in pairs(bossBuffList) do + local buffEntity = XDataCenter.WorldBossManager.GetWorldBossBuffById(buffId) + local groupId = buffEntity:GetGroupId() + local IsNotShow = buffEntity:GetIsNotShow() + local IsGroupType = groupId and groupId > 0 + local IsCanCreate = false + + if IsGroupType then + if not tmpGroupFlag[groupId] then + IsCanCreate = true + end + tmpGroupFlag[groupId] = true + else + if not tmpIdFlag[buffId] then + IsCanCreate = true + end + tmpIdFlag[buffId] = true + end + + if IsCanCreate and IsNotShow ~= 1 then + local topLevelBuff = XDataCenter.WorldBossManager.GetSameGroupToLevelpBossBuffByGroupId(groupId) + local obj = CS.UnityEngine.Object.Instantiate(self.BuffItem, self.PanelBuffInfo) + local grid = XUiGridBuff.New(obj,true) + grid:UpdateData(topLevelBuff and topLevelBuff or buffEntity) + grid.GameObject:SetActive(true) + end + end + self.GridRewardList = {} + self.GridCommon.gameObject:SetActiveEx(false) + self:UpdateRewardList() +end + +function XUiPanelDetail:UpdateRewardList() + local worldBossActivity = XDataCenter.WorldBossManager.GetCurWorldBossActivity() + local bossArea = worldBossActivity:GetBossAreaEntityById(self.AreaId) + local level = XDataCenter.WorldBossManager.GetBossStageLevel() + local stage = XDataCenter.WorldBossManager.GetBossStageGroupByIdAndLevel(bossArea:GetStageId(),level) + local rewards = XRewardManager.GetRewardList(stage.RewardId) + + for _,grid in pairs(self.GridRewardList) do + grid.GameObject:SetActiveEx(false) + end + + if rewards then + for index, item in pairs(rewards) do + if not self.GridRewardList[index] then + local obj = CS.UnityEngine.Object.Instantiate(self.GridCommon,self.PanelDropContent) + local grid = XUiGridCommon.New(self.Base, obj) + grid:Refresh(item) + grid.GameObject:SetActive(true) + self.GridRewardList[index] = grid + else + self.GridRewardList[index]:Refresh(item) + self.GridRewardList[index].GameObject:SetActive(true) + end + end + end +end + +function XUiPanelDetail:OnBtnBossClick() + local bossArea = XDataCenter.WorldBossManager.GetBossAreaById(self.AreaId) + local challengeCount = bossArea:GetChallengeCount() + local maxChallengeCount = bossArea:GetMaxChallengeCount() + + if maxChallengeCount - challengeCount == 0 then + XUiManager.TipText("WorldBossNoChallengeCount") + return + end + local data = {WorldBossTeamDatas = bossArea:GetCharacterDatas()} + XLuaUiManager.Open("UiNewRoomSingle", bossArea:GetStageId(), data) +end + +function XUiPanelDetail:SetShow(IsShow) + self.GameObject:SetActiveEx(IsShow) +end + +return XUiPanelDetail \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiWorldBoss/XUiPanelEnter.lua b/Resources/Scripts/XUi/XUiWorldBoss/XUiPanelEnter.lua new file mode 100644 index 00000000..55feac50 --- /dev/null +++ b/Resources/Scripts/XUi/XUiWorldBoss/XUiPanelEnter.lua @@ -0,0 +1,112 @@ +local XUiPanelEnter = XClass(nil, "XUiPanelEnter") +local XUiGridBossReward = require("XUi/XUiWorldBoss/XUiGridBossReward") +local CSTextManagerGetText = CS.XTextManager.GetText +local ColorBlack = CS.XGame.ClientConfig:GetString("ShopCanBuyColor") +local ProTime = 2 +local PanelState = { + Enter = 1, + Detail = 2 +} + +function XUiPanelEnter:Ctor(ui, base, areaId) + self.GameObject = ui.gameObject + self.Transform = ui.transform + self.Base = base + self.AreaId = areaId + XTool.InitUiObject(self) + self:SetButtonCallBack() + self:SetPanelTime() + self:SetPanelLevel() + self:InitPhasesRewardGrid() +end + +function XUiPanelEnter:SetButtonCallBack() + self.BtnBoss.CallBack = function() + self:OnBtnBossClick() + end + self.BtnSwich.CallBack = function() + self:OnBtnSwichClick() + end +end + +function XUiPanelEnter:OnBtnBossClick() + self.Base:SetPanelState(PanelState.Detail) +end + +function XUiPanelEnter:OnBtnSwichClick() + local curLevel = XDataCenter.WorldBossManager.GetBossStageLevel() + local bossArea = XDataCenter.WorldBossManager.GetBossAreaById(self.AreaId) + XLuaUiManager.Open("UiWorldBossLevelSelect", bossArea:GetStageId(), curLevel, function (level) + XDataCenter.WorldBossManager.SetBossStageLevel(level) + self:SetPanelLevel() + self.Base.PanelDetail:UpdateRewardList() + end) + +end + +function XUiPanelEnter:SetPanelTime() + local worldBossActivity = XDataCenter.WorldBossManager.GetCurWorldBossActivity() + local nowTime = XTime.GetServerNowTimestamp() + self.TimeText.text = XUiHelper.GetTime(worldBossActivity:GetEndTime() - nowTime, XUiHelper.TimeFormatType.ACTIVITY) +end + +function XUiPanelEnter:SetPanelLevel() + local bossArea = XDataCenter.WorldBossManager.GetBossAreaById(self.AreaId) + local level = XDataCenter.WorldBossManager.GetBossStageLevel() + local bossStageCfg = XDataCenter.WorldBossManager.GetBossStageGroupByIdAndLevel(bossArea:GetStageId(), level) + self.LevelText.text = bossStageCfg.Desc + self.LevelText.color = XUiHelper.Hexcolor2Color(bossStageCfg.DescColor or ColorBlack) +end + +function XUiPanelEnter:InitPhasesRewardGrid() + self.PhasesRewardGrids = {} + self.PhasesRewardGridRects = {} + self.RewardItem.gameObject:SetActiveEx(false) + local bossArea = XDataCenter.WorldBossManager.GetBossAreaById(self.AreaId) + local phasesIds = bossArea:GetPhasesRewardIds() + local rewardCount = #phasesIds + for i = 1,rewardCount do + local grid = self.PhasesRewardGrids[i] + if not grid then + local obj = CS.UnityEngine.Object.Instantiate(self.RewardItem) + obj.gameObject:SetActiveEx(true) + obj.transform:SetParent(self.PanelReward, false) + grid = XUiGridBossReward.New(obj, self, bossArea:GetId()) + self.PhasesRewardGrids[i] = grid + self.PhasesRewardGridRects[i] = grid.Transform:GetComponent("RectTransform") + end + end +end + +function XUiPanelEnter:UpdatePanelPhasesReward() + local bossArea = XDataCenter.WorldBossManager.GetBossAreaById(self.AreaId) + self.ScheduleImg.fillAmount = bossArea:GetHpPercent() + local hpProcess = bossArea:GetHpPercent() * 100 -- 海外修改如果小于百分之一,向上取整 + if hpProcess > 1 then + self.TxtDailyActive.text = string.format("%d%s",math.floor(hpProcess),"%") + else + self.TxtDailyActive.text = string.format("%d%s",math.ceil(hpProcess),"%") + end + self.ScheduleText.text = CSTextManagerGetText("WorldBossBossAreaSchedule") + local phasesIds = bossArea:GetPhasesRewardIds() + local rewardCount = #phasesIds + for i = 1, rewardCount do + local reward = bossArea:GetRewardEntityById(phasesIds[i]) + self.PhasesRewardGrids[i]:UpdateData(reward) + end + + -- 自适应 + local activeProgressRectSize = self.PanelReward.rect.size + for i = 1, #self.PhasesRewardGrids do + local reward = bossArea:GetRewardEntityById(phasesIds[i]) + local valOffset = 1 - reward:GetHpPercent() * 0.01 + local adjustPosition = CS.UnityEngine.Vector3(activeProgressRectSize.x * valOffset - activeProgressRectSize.x / 2, 0, 0) + self.PhasesRewardGridRects[i].anchoredPosition3D = adjustPosition + end +end + +function XUiPanelEnter:SetShow(IsShow) + self.GameObject:SetActiveEx(IsShow) +end + +return XUiPanelEnter \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiWorldBoss/XUiSettleWinWorldBoss.lua b/Resources/Scripts/XUi/XUiWorldBoss/XUiSettleWinWorldBoss.lua new file mode 100644 index 00000000..209e272f --- /dev/null +++ b/Resources/Scripts/XUi/XUiWorldBoss/XUiSettleWinWorldBoss.lua @@ -0,0 +1,97 @@ +local XUiSettleWinWorldBoss = XLuaUiManager.Register(XLuaUi, "UiSettleWinWorldBoss") + +function XUiSettleWinWorldBoss:OnStart(data) + self:SetButtonCallback() + self:ShowPanel(data) +end + +function XUiSettleWinWorldBoss:OnEnable() + self:PlayAnimation("PanelBossSingleinfo",function () + XDataCenter.FunctionEventManager.UnLockFunctionEvent() + end) +end + +function XUiSettleWinWorldBoss:OnDestroy() + XDataCenter.AntiAddictionManager.EndFightAction() +end + +function XUiSettleWinWorldBoss:SetButtonCallback() + self.BtnCancel.CallBack = function() + self:OnBtnCancelClick() + end +end + +function XUiSettleWinWorldBoss:ShowPanel(data) + self.StageId = data.StageId + self.RewardGoodsList = data.RewardGoodsList + self.WorldBossFightResult = data.WorldBossFightResult + + local stageInfo = XDataCenter.FubenManager.GetStageInfo(data.StageId) + local time = CS.XGame.ClientConfig:GetFloat("BossSingleAnimaTime") + local stageCfg = XDataCenter.FubenManager.GetStageCfg(data.StageId) + + local totalTime = self.WorldBossFightResult.FightTime + local damageAllScore = self.WorldBossFightResult.DamageMaxScore + local allLeftHpScore = self.WorldBossFightResult.HpMaxScore + + for _,rewardGoods in pairs(self.RewardGoodsList) do + --只要第一个 + local goodsShowParams = XGoodsCommonManager.GetGoodsShowParamsByTemplateId(rewardGoods.TemplateId) + local count = rewardGoods.Count + local icon = goodsShowParams.Icon + self.AttributeMoneyImg:SetSprite(icon) + self.AttributeMoneyNum.text = count + self.BossMoneyImg:SetSprite(icon) + self.BossMoneyNum.text = count + break + end + + self.TxtDifficult.text = stageInfo.ChapterName + self.TxtDamageAllScore.text = CS.XTextManager.GetText("BossSingleAutoFightDesc10", damageAllScore) + self.TxtAllCharLeftHpScore.text = CS.XTextManager.GetText("BossSingleAutoFightDesc10", allLeftHpScore) + + self.PanelAttributeArea.gameObject:SetActiveEx(stageInfo.AreaType == XWorldBossConfigs.AreaType.Attribute) + self.PanelBossArea.gameObject:SetActiveEx(stageInfo.AreaType == XWorldBossConfigs.AreaType.Boss) + + -- 播放音效 + self.AudioInfo = CS.XAudioManager.PlaySound(XSoundManager.UiBasicsMusic.UiSettle_Win_Number) + XUiHelper.Tween(time, function(f) + if XTool.UObjIsNil(self.Transform) then + return + end + + local totalTimeText = XUiHelper.GetTime(math.floor(f * totalTime)) + local bossLoseHpText = math.floor(f * self.WorldBossFightResult.Damage) + local bossLoseHpScoreText = '+' .. math.floor(f * self.WorldBossFightResult.DamageScore) + local charLeftHpText = math.floor(f * self.WorldBossFightResult.HpLeftPer) .. "%" + local charLeftHpScoreText = '+' .. math.floor(f * self.WorldBossFightResult.HpScore) + local allScoreText = math.floor(f * (self.WorldBossFightResult.DamageScore + self.WorldBossFightResult.HpScore)) + + self.TxtStageTime.text = totalTimeText + self.TxtDamage.text = bossLoseHpText + self.TxtBossLoseHpScore.text = bossLoseHpText + self.TxtDamageScore.text = bossLoseHpScoreText + self.TxtCharLeftHp.text = charLeftHpText + self.TxtCharLeftHpScore.text = charLeftHpScoreText + self.TxtAllScore.text = allScoreText + end, function() + if XTool.UObjIsNil(self.Transform)then + return + end + self:StopAudio() + end) + + +end + +function XUiSettleWinWorldBoss:StopAudio() + if self.AudioInfo then + self.AudioInfo:Stop() + end +end + +function XUiSettleWinWorldBoss:OnBtnCancelClick() + self:StopAudio() + XLuaUiManager.Close("UiSettleWinWorldBoss") + XTipManager.Execute() +end diff --git a/Resources/Scripts/XUi/XUiWorldBoss/XUiWorldBossAreaRank.lua b/Resources/Scripts/XUi/XUiWorldBoss/XUiWorldBossAreaRank.lua new file mode 100644 index 00000000..ffb08230 --- /dev/null +++ b/Resources/Scripts/XUi/XUiWorldBoss/XUiWorldBossAreaRank.lua @@ -0,0 +1,58 @@ +--工会boss关卡排行榜页面 +local XUiGridWorldBossAreaRankItem = require("XUi/XUiWorldBoss/XUiGridWorldBossAreaRankItem") +local XUiWorldBossAreaRank = XLuaUiManager.Register(XLuaUi, "UiWorldBossAreaRank") + +function XUiWorldBossAreaRank:OnAwake() + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + self.BtnMainUi.CallBack = function() self:OnBtnMainUiClick() end + self:BindHelpBtn(self.BtnHelp, "") + self.DynamicTable = XDynamicTableNormal.New(self.BossRankList) + self.DynamicTable:SetProxy(XUiGridWorldBossAreaRankItem) + self.DynamicTable:SetDelegate(self) + self.GridAreaRank.gameObject:SetActiveEx(false) +end + +function XUiWorldBossAreaRank:OnStart(areaId) + self.AreaId = areaId + XDataCenter.WorldBossManager.GetAttributeAreaRank(areaId, function() self:UpdateInfo() end) +end + +function XUiWorldBossAreaRank:UpdateInfo() + self.RankData = XDataCenter.WorldBossManager.GetOtherAreaRankData() + self.MyRankData = XDataCenter.WorldBossManager.GetMyAreaRankData() + self.DynamicTable:SetDataSource(self.RankData) + self.DynamicTable:ReloadDataASync() + self.PanelNoRank.gameObject:SetActiveEx(#self.RankData == 0) + + if next(self.MyRankData) then + self.TxtScore.text = self.MyRankData.Score + self.TxtName.text = XPlayer.Name + + local rankRate = math.ceil(self.MyRankData.Rank / self.MyRankData.ToTalRank * 100) + if rankRate >= 100 then + rankRate = 99 + end + self.TxtRank.text = self.MyRankData.Rank <= 100 and self.MyRankData.Rank or string.format("%d%s", rankRate, "%") + + XUiPLayerHead.InitPortrait(XPlayer.CurrHeadPortraitId, XPlayer.CurrHeadFrameId, self.UObjHead) + end + self.PanelMyAreaRank.gameObject:SetActiveEx(next(self.MyRankData)) +end + +function XUiWorldBossAreaRank:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + grid:Init(self.RankData[index]) + end +end + +function XUiWorldBossAreaRank:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiWorldBossAreaRank:OnDestroy() + +end + +function XUiWorldBossAreaRank:OnBtnBackClick() + self:Close() +end diff --git a/Resources/Scripts/XUi/XUiWorldBoss/XUiWorldBossAttributeArea.lua b/Resources/Scripts/XUi/XUiWorldBoss/XUiWorldBossAttributeArea.lua new file mode 100644 index 00000000..9c5cf93c --- /dev/null +++ b/Resources/Scripts/XUi/XUiWorldBoss/XUiWorldBossAttributeArea.lua @@ -0,0 +1,227 @@ +local XUiWorldBossAttributeArea = XLuaUiManager.Register(XLuaUi, "UiWorldBossAttributeArea") +local XUiGridAttributeChapter = require("XUi/XUiWorldBoss/XUiGridAttributeChapter") +local XUiGridBuff = require("XUi/XUiWorldBoss/XUiGridBuff") +local CSTextManagerGetText = CS.XTextManager.GetText +local Normal = CS.UiButtonState.Normal +local Disable = CS.UiButtonState.Disable +function XUiWorldBossAttributeArea:OnStart(areaId) + self.AreaId = areaId + self:SetButtonCallBack() + self:InitArea() + self:InitPanelRegional() + self:InitPanelRewrd() + self:UpdatePanelRewrd() + + self.ChapterGrid:UpdateStageList() + self.ChapterGrid:GoToNearestStage() +end + +function XUiWorldBossAttributeArea:OnDestroy() + +end + +function XUiWorldBossAttributeArea:OnEnable() + XDataCenter.WorldBossManager.CheckWorldBossActivityReset() + self:UpdateArea() + self:UpdatePanelChat() + XEventManager.AddEventListener(XEventId.EVENT_WORLDBOSS_SYNCDATA, self.UpdateArea, self) + XEventManager.AddEventListener(XEventId.EVENT_WORLDBOSS_REPORT, self.UpdatePanelChat, self) +end + +function XUiWorldBossAttributeArea:OnDisable() + XEventManager.RemoveEventListener(XEventId.EVENT_WORLDBOSS_SYNCDATA, self.UpdateArea, self) + XEventManager.RemoveEventListener(XEventId.EVENT_WORLDBOSS_REPORT, self.UpdatePanelChat, self) +end + +function XUiWorldBossAttributeArea:SetButtonCallBack() + self.BtnBack.CallBack = function() + self:OnBtnBackClick() + end + + self.BtnMainUi.CallBack = function() + self:OnBtnMainUiClick() + end + + self.BtnRank.CallBack = function() + self:OnBtnRankClick() + end + + self.BtnTask.CallBack = function() + self:OnBtnTaskClick() + end + + self.PanelChat:GetObject("BtnWarReport").CallBack = function() + self:OnBtnWarReportClick() + end + + self.PanelRewrd:GetObject("BtnTreasure").CallBack = function() + self:OnBtnTreasureClick() + end + + self.PanelShop:GetObject("BtnShop").CallBack = function() + self:OnBtnShopClick() + end + self:BindHelpBtn(self.BtnActDesc, "WorldBossHelp") +end + +function XUiWorldBossAttributeArea:InitArea() + local attributeArea = XDataCenter.WorldBossManager.GetAttributeAreaById(self.AreaId) + local prefabName = attributeArea:GetPrefabName() + local gameObject = self.PanelChapter:LoadPrefab(prefabName) + if gameObject == nil or not gameObject:Exist() then + return + end + + self.ChapterGrid = XUiGridAttributeChapter.New(gameObject, self.AreaId) + self.ChapterGrid.Transform:SetParent(self.PanelChapter, false) +end + +function XUiWorldBossAttributeArea:UpdatePanelShop() + local worldBossActivity = XDataCenter.WorldBossManager.GetCurWorldBossActivity() + local shopCurrencyId = worldBossActivity:GetShopCurrencyId() + + local moneyItem = XUiGridCommon.New(self, self.PanelShop:GetObject("MoneyItemGrid")) + moneyItem:Refresh(shopCurrencyId) + local moneyCount = XDataCenter.ItemManager.GetCount(shopCurrencyId) + self.PanelShop:GetObject("MoneyNum").text = moneyCount + self.PanelShop.gameObject:SetActiveEx(false) +end + +function XUiWorldBossAttributeArea:InitPanelRegional() + local worldBossActivity = XDataCenter.WorldBossManager.GetCurWorldBossActivity() + local attributeArea = XDataCenter.WorldBossManager.GetAttributeAreaById(self.AreaId) + local nowTime = XTime.GetServerNowTimestamp() + local activityTime = XUiHelper.GetTime(worldBossActivity:GetEndTime() - nowTime, XUiHelper.TimeFormatType.ACTIVITY) + local buffParent = self.PanelRegional:GetObject("BuffContent") + local buffObj = self.PanelRegional:GetObject("BtnBossBuff") + local buffIds = attributeArea:GetBuffIds() + + self.PanelRegional:GetObject("TextTime").text = activityTime + self.PanelRegional:GetObject("TxtTName").text = attributeArea:GetName() + self.PanelRegional:GetObject("AreaDesc").text = attributeArea:GetAreaDesc() + + buffObj.gameObject:SetActiveEx(false) + + if buffIds then + for _,id in pairs(buffIds) do + local ui = CS.UnityEngine.Object.Instantiate(buffObj,buffParent) + local grid = XUiGridBuff.New(ui,false) + local buffData = XDataCenter.WorldBossManager.GetWorldBossBuffById(id) + grid:UpdateData(buffData) + grid.GameObject:SetActiveEx(true) + end + end +end + +function XUiWorldBossAttributeArea:InitPanelRewrd() + local attributeArea = XDataCenter.WorldBossManager.GetAttributeAreaById(self.AreaId) + local rewrdParent = self.PanelRewrd:GetObject("PanelBfrtRewrds") + local rewrdObj = self.PanelRewrd:GetObject("GridCommonPopUp") + local rewrdId = attributeArea:GetFinishReward() + local rewardList = XRewardManager.GetRewardList(rewrdId) + rewrdObj.gameObject:SetActiveEx(false) + + if rewardList then + for _,reward in pairs(rewardList) do + local ui = CS.UnityEngine.Object.Instantiate(rewrdObj,rewrdParent) + local grid = XUiGridCommon.New(self,ui) + + grid:Refresh(reward) + grid.GameObject:SetActiveEx(true) + end + end +end + +function XUiWorldBossAttributeArea:UpdatePanelRewrd() + local worldBossActivity = XDataCenter.WorldBossManager.GetCurWorldBossActivity() + local attributeArea = XDataCenter.WorldBossManager.GetAttributeAreaById(self.AreaId) + local IsCanGet = attributeArea:GetIsAreaFinish() + local IsGeted = attributeArea:GetIsRewardGeted() + local finishCount = attributeArea:GetFinishStageCount() + local stageCount = #attributeArea:GetStageIds() + + self.PanelRewrd:GetObject("TxtCondition").text = CSTextManagerGetText("WorldBossAttributeStageRewrdHint", finishCount, stageCount) + self.PanelRewrd:GetObject("TxtCondition").gameObject:SetActiveEx(not IsCanGet) + self.PanelRewrd:GetObject("BtnTreasure").gameObject:SetActiveEx(IsCanGet) + self.PanelRewrd:GetObject("BtnTreasure"):SetButtonState((not IsGeted and IsCanGet) and Normal or Disable) +end + +function XUiWorldBossAttributeArea:UpdatePanelChat() + local reportData = XDataCenter.WorldBossManager.GetWorldBossNewReport() + if not reportData then + return + end + local playerInfo = reportData.PlayerInfo + local reportId = reportData.ReportId + local reportCfg = XWorldBossConfigs.GetReportTemplatesById(reportId) + local reportType = XDataCenter.WorldBossManager.GetFightReportTypeById(reportId) + local IsSystemReport = reportType == XWorldBossConfigs.ReportType.System + local nameText = "" + local wordText = "" + + if IsSystemReport then + nameText = CSTextManagerGetText("WorldBossReportName") + wordText = reportCfg.Message + else + nameText = playerInfo.PlayerName + local score = playerInfo.Score + wordText = string.format(reportCfg.Message,nameText,score) + end + self.PanelChat:GetObject("TxtMessageLabel").gameObject:SetActiveEx(true) + self.PanelChat:GetObject("TxtMessageContent").text =string.format("%s:%s", nameText, wordText) +end + +function XUiWorldBossAttributeArea:UpdateArea() + self.ChapterGrid:UpdateStageList() + self:UpdatePanelRewrd() + self:UpdatePanelShop() + self:SetActivityInfo() +end + +function XUiWorldBossAttributeArea:SetActivityInfo() + local IsHaveRed = XDataCenter.WorldBossManager.CheckAnyTaskFinished() + self.BtnTask:ShowReddot(IsHaveRed) +end + + +function XUiWorldBossAttributeArea:OnBtnBackClick() + self:Close() +end + +function XUiWorldBossAttributeArea:UpdatePhasesReward() + self.UpdatePanelPhasesReward() +end + +function XUiWorldBossAttributeArea:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiWorldBossAttributeArea:OnBtnRankClick() + XLuaUiManager.Open("UiWorldBossAreaRank", self.AreaId) +end + +function XUiWorldBossAttributeArea:OnBtnTaskClick() + XLuaUiManager.Open("UiWorldBossTask") +end + +function XUiWorldBossAttributeArea:OnBtnWarReportClick() + XLuaUiManager.Open("UiChatUiWorldBoss") +end + +function XUiWorldBossAttributeArea:OnBtnTreasureClick() + local attributeArea = XDataCenter.WorldBossManager.GetAttributeAreaById(self.AreaId) + local IsCanGet = attributeArea:GetIsAreaFinish() + local IsGeted = attributeArea:GetIsRewardGeted() + if not IsCanGet or IsGeted then + return + end + XDataCenter.WorldBossManager.GetAttributeAreaReward(self.AreaId, function () + self:UpdatePanelRewrd() + end) +end + +function XUiWorldBossAttributeArea:OnBtnShopClick() + if XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.ShopCommon) then + XLuaUiManager.Open("UiShop", XShopManager.ShopType.WorldBoss) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiWorldBoss/XUiWorldBossBossArea.lua b/Resources/Scripts/XUi/XUiWorldBoss/XUiWorldBossBossArea.lua new file mode 100644 index 00000000..3baefd3e --- /dev/null +++ b/Resources/Scripts/XUi/XUiWorldBoss/XUiWorldBossBossArea.lua @@ -0,0 +1,130 @@ +local XUiWorldBossBossArea = XLuaUiManager.Register(XLuaUi, "UiWorldBossBossArea") +local XUiPanelEnter = require("XUi/XUiWorldBoss/XUiPanelEnter") +local XUiPanelDetail = require("XUi/XUiWorldBoss/XUiPanelDetail") + +local DefaultLevel = 1 +local PanelState = { + Enter = 1, + Detail = 2 +} + +local CameraIndex = { + Main = 1, + Detail = 2 +} + +function XUiWorldBossBossArea:OnAwake() + self:Init3DScene() +end + +function XUiWorldBossBossArea:OnStart(Id) + XDataCenter.WorldBossManager.SetBossStageLevel(DefaultLevel) + self.PanelEnter = XUiPanelEnter.New(self.PanelEnterObj, self, Id) + self.PanelDetail = XUiPanelDetail.New(self.PanelDetailObj, self, Id) + self:SetPanelState(PanelState.Enter) + self:SetButtonCallBack() + self:RefreshModel(Id) + self:PlayFinishStory(Id) +end + +function XUiWorldBossBossArea:OnDestroy() + +end + +function XUiWorldBossBossArea:OnEnable() + XDataCenter.WorldBossManager.CheckWorldBossActivityReset() + self.PanelEnter:UpdatePanelPhasesReward() + self.PanelDetail:UpdateActivityInfo() + XEventManager.AddEventListener(XEventId.EVENT_WORLDBOSS_SYNCDATA, self.UpdatePhasesReward, self) +end + +function XUiWorldBossBossArea:OnDisable() + XEventManager.RemoveEventListener(XEventId.EVENT_WORLDBOSS_SYNCDATA, self.UpdatePhasesReward, self) +end + +function XUiWorldBossBossArea:Init3DScene() + local root = self.UiModelGo.transform + self.RoleModelPanel = XUiPanelRoleModel.New(root:FindTransform("PanelModel"), self.Name, nil, true, nil, true) + self.CameraNear = { + [CameraIndex.Main] = root:FindTransform("NearCameraMain"), + [CameraIndex.Detail] = root:FindTransform("NearCameraDetail"), + } + self.CameraFar = { + [CameraIndex.Main] = root:FindTransform("FarCameraMain"), + [CameraIndex.Detail] = root:FindTransform("FarCameraDetail"), + } +end + +function XUiWorldBossBossArea:SetButtonCallBack() + self.BtnBack.CallBack = function() + self:OnBtnBackClick() + end + + self.BtnMainUi.CallBack = function() + self:OnBtnMainUiClick() + end + self:BindHelpBtn(self.BtnHelp, "WorldBossHelp") +end + +function XUiWorldBossBossArea:SetPanelState(state) + if state == PanelState.Enter then + self.PanelEnter:SetShow(true) + self.PanelDetail:SetShow(false) + self.CameraNear[CameraIndex.Main].gameObject:SetActiveEx(true) + self.CameraNear[CameraIndex.Detail].gameObject:SetActiveEx(false) + self.CameraFar[CameraIndex.Main].gameObject:SetActiveEx(true) + self.CameraFar[CameraIndex.Detail].gameObject:SetActiveEx(false) + self:PlayAnimation("PanelEnterAnimEnable") + elseif state == PanelState.Detail then + self.PanelEnter:SetShow(false) + self.PanelDetail:SetShow(true) + self.CameraNear[CameraIndex.Main].gameObject:SetActiveEx(false) + self.CameraNear[CameraIndex.Detail].gameObject:SetActiveEx(true) + self.CameraFar[CameraIndex.Main].gameObject:SetActiveEx(false) + self.CameraFar[CameraIndex.Detail].gameObject:SetActiveEx(true) + self:PlayAnimation("PanlDetailAnimEnable2") + end + self.CurPanelState = state +end + +function XUiWorldBossBossArea:OnBtnBackClick() + if self.CurPanelState == PanelState.Detail then + self:SetPanelState(PanelState.Enter) + else + self:Close() + end +end + +function XUiWorldBossBossArea:UpdatePhasesReward() + self.PanelEnter:UpdatePanelPhasesReward() +end + +function XUiWorldBossBossArea:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiWorldBossBossArea:OnBtnShopClick() + if XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.ShopCommon) then + XLuaUiManager.Open("UiShop", XShopManager.ShopType.WorldBoss) + end +end + +function XUiWorldBossBossArea:RefreshModel(areaId) + local bossArea = XDataCenter.WorldBossManager.GetBossAreaById(areaId) + self.RoleModelPanel:UpdateBossModel(bossArea:GetModelId(), XModelManager.MODEL_UINAME.XUiWorldBossBossArea) + self.RoleModelPanel:ShowRoleModel() +end + +function XUiWorldBossBossArea:PlayFinishStory(areaId) + local bossArea = XDataCenter.WorldBossManager.GetBossAreaById(areaId) + if bossArea:GetIsFinish() then + local storyId = bossArea:GetFinishStoryId() + if storyId and #storyId > 1 then + local IsCanPlay = XDataCenter.WorldBossManager.CheckIsNewStoryID(storyId) + if IsCanPlay then + XDataCenter.MovieManager.PlayMovie(storyId)--一次 + XDataCenter.WorldBossManager.MarkStoryID(storyId) + end + end + end +end diff --git a/Resources/Scripts/XUi/XUiWorldBoss/XUiWorldBossDetail.lua b/Resources/Scripts/XUi/XUiWorldBoss/XUiWorldBossDetail.lua new file mode 100644 index 00000000..e61f33cd --- /dev/null +++ b/Resources/Scripts/XUi/XUiWorldBoss/XUiWorldBossDetail.lua @@ -0,0 +1,285 @@ +local XUiWorldBossDetail = XLuaUiManager.Register(XLuaUi, "UiWorldBossDetail") +local XUiGridBuff = require("XUi/XUiWorldBoss/XUiGridBuff") +local CSTextManagerGetText = CS.XTextManager.GetText +local Normal = CS.UiButtonState.Normal +local Disable = CS.UiButtonState.Disable +function XUiWorldBossDetail:OnStart(stageData,areaId,cb,rwardCb) + self.GridList = {} + self.BuffGridList = {} + self.StageData = stageData + self.AreaId = areaId + self.Stage = stageData:GetStageCfg() + self.CallBack = cb + self.RwardCb = rwardCb + self:SetButtonCallBack() + self.BuffItem.gameObject:SetActiveEx(false) + self.DropGridCommon.gameObject:SetActiveEx(false) + self:InitStarPanels() +end + +function XUiWorldBossDetail:OnEnable() + XDataCenter.WorldBossManager.CheckWorldBossActivityReset() + XLuaUiManager.SetMask(true) + self:PlayAnimation("AnimBegin", handler(self, function() + XLuaUiManager.SetMask(false) + end)) + self:Refresh() +end + +function XUiWorldBossDetail:InitStarPanels() + self.GridStarList = { + XUiGridStageStar.New(self.GridStageStar1), + XUiGridStageStar.New(self.GridStageStar2), + XUiGridStageStar.New(self.GridStageStar3), + } +end + +function XUiWorldBossDetail:SetButtonCallBack() + self.BtnEnter.CallBack = function() + self:OnBtnEnterClick() + end + self.BtnMask.CallBack = function() + self:OnBtnCloseClick() + end + self.BtnFinish.CallBack = function() + self:OnBtnFinishClick() + end +end + +function XUiWorldBossDetail:OnBtnCloseClick() + XLuaUiManager.SetMask(true) + self:PlayAnimation("AnimEnd", handler(self, function() + XLuaUiManager.SetMask(false) + if XTool.UObjIsNil(self.GameObject) then + return + end + if self.CallBack then + self.CallBack() + end + self:Close() + end)) +end + +function XUiWorldBossDetail:OnBtnFinishClick() + XDataCenter.WorldBossManager.GetAttributeAreaStageReward(self.AreaId, self.Stage.StageId, function () + self:Refresh() + if self.RwardCb then + self.RwardCb() + end + + end) +end + +function XUiWorldBossDetail:OnBtnEnterClick() + local worldBossActivity = XDataCenter.WorldBossManager.GetCurWorldBossActivity() + local attributeArea = XDataCenter.WorldBossManager.GetAttributeAreaById(self.AreaId) + local actionPointId = worldBossActivity:GetActionPointId() + local challengeCount = attributeArea:GetChallengeCount() + local maxChallengeCount = attributeArea:GetMaxChallengeCount() + local usePowerCount = self.StageData:GetConsumeCount() + local powerCount = XDataCenter.ItemManager.GetCount(actionPointId) + + if self.BtnEnter.ButtonState == Disable then + XUiManager.TipMsg(self.StageData:GetLockDesc()) + return + end + + if maxChallengeCount - challengeCount == 0 then + XUiManager.TipText("WorldBossNoChallengeCount") + return + end + + if powerCount < usePowerCount then + XUiManager.TipText("WorldBossNoPower") + return + end + + if self.Stage == nil then + XLog.Error("XUiWorldBossDetail.OnBtnEnterClick: Can not find stage!") + return + end + + local attributeArea = XDataCenter.WorldBossManager.GetAttributeAreaById(self.AreaId) + local IsFinish = self.StageData:GetIsFinish() + local data = {WorldBossTeamDatas = attributeArea:GetCharacterDatas()} + if IsFinish then + self:TipDialog(nil, function () + XLuaUiManager.Open("UiNewRoomSingle", self.Stage.StageId, data) + end) + else + XLuaUiManager.Open("UiNewRoomSingle", self.Stage.StageId, data) + end + + + +end + +function XUiWorldBossDetail:TipDialog(cancelCb, confirmCb) + local tipTitle = CSTextManagerGetText("TipTitle") + local content = CSTextManagerGetText("WorldBossFinishStageFightHint") + + CsXUiManager.Instance:Open("UiDialog", tipTitle, content, XUiManager.DialogType.Normal, cancelCb, confirmCb) +end + +function XUiWorldBossDetail:Refresh() + self:UpdateCommon() + self:UpdateSchedule() + --self:UpdateBuffs() + self:UpdateRewards() + self:UpdateDrop() + self:UpdateDifficulty() + self:UpdateStageFightControl()--更新战力限制提示 + self:UpdateBtnEnter() + self:UpdateBtnFinish() +end + +function XUiWorldBossDetail:UpdateCommon() + local worldBossActivity = XDataCenter.WorldBossManager.GetCurWorldBossActivity() + local attributeArea = XDataCenter.WorldBossManager.GetAttributeAreaById(self.AreaId) + local stageCfg = XDataCenter.FubenManager.GetStageCfg(self.Stage.StageId) + local stageInfo = XDataCenter.FubenManager.GetStageInfo(self.Stage.StageId) + local stageTitle = XDataCenter.ExtraChapterManager.GetChapterDetailsStageTitle(stageInfo.ChapterId) + local actionPointId = worldBossActivity:GetActionPointId() + local maxPowerCount = worldBossActivity:GetMaxActionPoint() + local challengeCount = attributeArea:GetChallengeCount() + local maxChallengeCount = attributeArea:GetMaxChallengeCount() + local usePowerCount = self.StageData:GetConsumeCount() + + self.TxtTitle.text = self.Stage.Name + self.TxtDesc.text = self.Stage.Description + + self.ChallengText.text = CSTextManagerGetText("WorldBossAttributeChallengeText") + self.ChallengNum.text = string.format("%d/%d",maxChallengeCount - challengeCount,maxChallengeCount) + + local item = XUiGridCommon.New(self, self.PowerItemGrid) + item:Refresh(actionPointId) + local powerCount = XDataCenter.ItemManager.GetCount(actionPointId) + self.PowerText.text = CSTextManagerGetText("WorldBossActionPoint") + self.PowerNum.text = string.format("%d/%d",powerCount,maxPowerCount) + + + local useItem = XUiGridCommon.New(self, self.UsePowerItemGrid) + useItem:Refresh(actionPointId) + self.UsePowerNum.text = usePowerCount + + for i = 1, 3 do + self.GridStarList[i]:Refresh(self.Stage.StarDesc[i], true) + end +end + +function XUiWorldBossDetail:UpdateDifficulty() + local nanDuIcon = XDataCenter.FubenManager.GetDifficultIcon(self.Stage.StageId) + self.RImgNandu:SetRawImage(nanDuIcon) +end + +function XUiWorldBossDetail:UpdateSchedule() + local finishPercent = self.StageData:GetFinishPercent() + local IsLock = self.StageData:GetIsLock() + self.ScheduleImg.fillAmount = finishPercent + self.TxtScheduleNum.text = string.format("%d%s",math.floor(finishPercent * 100),"%") + self.TextScheduleName.text = CSTextManagerGetText("WorldBossExploreScheduleText") + self.PanelBossSchedule.gameObject:SetActiveEx(not IsLock) +end + +function XUiWorldBossDetail:UpdateBtnEnter() + self.BtnEnter:SetButtonState(self.StageData:GetIsLock() and Disable or Normal) +end + +function XUiWorldBossDetail:UpdateBtnFinish() + local IsGeted = self.StageData:GetIsRewardGeted() + local IsCanGet = self.StageData:GetIsFinish() + local rewardId = self.StageData:GetFinishReward() + self.RwardPanel.gameObject:SetActiveEx(rewardId ~= 0) + self.RwardEffect.gameObject:SetActiveEx(not IsGeted and IsCanGet) + self.RwardFinish.gameObject:SetActiveEx(IsGeted) + self.BtnFinish.gameObject:SetActiveEx(not IsGeted and IsCanGet) +end + +function XUiWorldBossDetail:UpdateBuffs() + local buffIds = self.StageData:GetBuffIds() + if buffIds then + for i, id in pairs(buffIds) do + local grid + if self.BuffGridList[i] then + grid = self.BuffGridList[i] + else + local ui = CS.UnityEngine.Object.Instantiate(self.BuffItem,self.PanelDropContent) + grid = XUiGridBuff.New(ui,true) + self.BuffGridList[i] = grid + end + local buffData = XDataCenter.WorldBossManager.GetWorldBossBuffById(id) + grid:UpdateData(buffData) + grid.GameObject:SetActiveEx(true) + end + end + + local buffsCount = 0 + if buffIds then + buffsCount = #buffIds + end + + for j = 1, #self.BuffGridList do + if j > buffsCount then + self.BuffGridList[j].GameObject:SetActiveEx(false) + end + end +end + +function XUiWorldBossDetail:UpdateRewards() + local rewardId = self.StageData:GetFinishReward() + if rewardId == 0 then + return + end + local rewards = XRewardManager.GetRewardList(rewardId) + if rewards then + for i, item in pairs(rewards) do + local grid = XUiGridCommon.New(self, self.RwardGridCommon) + grid:Refresh(item) + grid.GameObject:SetActiveEx(true) + break + end + end +end + +function XUiWorldBossDetail:UpdateDrop() + local stageCfg = XDataCenter.FubenManager.GetStageCfg(self.StageData:GetId()) + local rewards = XRewardManager.GetRewardListNotCount(stageCfg.FinishRewardShow) + if rewards then + for i, item in pairs(rewards) do + local grid + if self.GridList[i] then + grid = self.GridList[i] + else + local ui = CS.UnityEngine.Object.Instantiate(self.DropGridCommon,self.PanelDropContent) + grid = XUiGridCommon.New(self, ui) + self.GridList[i] = grid + end + grid:Refresh(item) + grid.GameObject:SetActiveEx(true) + end + end + + local rewardsCount = 0 + if rewards then + rewardsCount = #rewards + end + + for j = 1, #self.GridList do + if j > rewardsCount then + self.GridList[j].GameObject:SetActiveEx(false) + end + end +end + +function XUiWorldBossDetail:UpdateStageFightControl() + local stageInfo = XDataCenter.FubenManager.GetStageInfo(self.Stage.StageId) + if self.StageFightControl == nil then + self.StageFightControl = XUiStageFightControl.New(self.PanelStageFightControl, self.Stage.FightControlId) + end + if not stageInfo.Passed and stageInfo.Unlock then + self.StageFightControl.GameObject:SetActiveEx(true) + self.StageFightControl:UpdateInfo(self.Stage.FightControlId) + else + self.StageFightControl.GameObject:SetActiveEx(false) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiWorldBoss/XUiWorldBossFashion.lua b/Resources/Scripts/XUi/XUiWorldBoss/XUiWorldBossFashion.lua new file mode 100644 index 00000000..248f7078 --- /dev/null +++ b/Resources/Scripts/XUi/XUiWorldBoss/XUiWorldBossFashion.lua @@ -0,0 +1,118 @@ +local XUiWorldBossFashion = XLuaUiManager.Register(XLuaUi, "UiWorldBossFashion") +local CSTextManagerGetText = CS.XTextManager.GetText +local FashionSkipId = 20011 +local FirstIndex = 1 +local ProTime = 2 +local Normal = CS.UiButtonState.Normal +local Disable = CS.UiButtonState.Disable + +function XUiWorldBossFashion:OnStart() + self:InitDiscountGrid() + self:InitSpecialSaleInfo() + self:SetButtonCallBack() +end + +function XUiWorldBossFashion:OnEnable() + XDataCenter.WorldBossManager.CheckWorldBossActivityReset() + self:UpdateSpecialSaleInfo() + XEventManager.AddEventListener(XEventId.EVENT_WORLDBOSS_SYNCDATA, self.UpdateSpecialSaleInfo, self) +end + +function XUiWorldBossFashion:OnDisable() + XEventManager.RemoveEventListener(XEventId.EVENT_WORLDBOSS_SYNCDATA, self.UpdateSpecialSaleInfo, self) +end + +function XUiWorldBossFashion:SetButtonCallBack() + self.BtnBack.CallBack = function() + self:OnBtnCloseClick() + end + self.BtnGet.CallBack = function() + self:OnBtnGetClick() + end + self.BtnHelp.CallBack = function() + self:OnBtnHelpClick() + end +end + +function XUiWorldBossFashion:InitSpecialSaleInfo() + local specialSale = XDataCenter.WorldBossManager.GetSpecialSaleById(FirstIndex) + self.FashionImage:SetRawImage(specialSale:GetShopImg()) +end + +function XUiWorldBossFashion:InitDiscountGrid() + local specialSale = XDataCenter.WorldBossManager.GetSpecialSaleById(FirstIndex) + + self.DiscountGrids = {} + self.DiscountGridRects = {} + self.SaleItem.gameObject:SetActiveEx(false) + local discountIds = specialSale:GetDiscountIds() + local discountCount = #discountIds + for i = 1,discountCount do + local grid = self.DiscountGrids[i] + if not grid then + local obj = CS.UnityEngine.Object.Instantiate(self.SaleItem,self.PanelReward) + obj.gameObject:SetActiveEx(true) + self.DiscountGrids[i] = obj.transform:GetComponent("UiObject") + self.DiscountGridRects[i] = obj.transform:GetComponent("RectTransform") + end + end +end + +function XUiWorldBossFashion:UpdateSpecialSaleInfo() + local bossArea = XDataCenter.WorldBossManager.GetBossAreaById(FirstIndex) + self.BtnGet:SetButtonState(bossArea:GetIsFinish() and Normal or Disable) + self:UpdatePanel() +end + +function XUiWorldBossFashion:UpdatePanel() + local specialSale = XDataCenter.WorldBossManager.GetSpecialSaleById(FirstIndex) + local bossArea = XDataCenter.WorldBossManager.GetBossAreaById(FirstIndex) + local percent = bossArea:GetHpPercent() + if self.Curfillamount ~= percent then + self.ScheduleImg:DOFillAmount(1 - percent,ProTime) + self.Curfillamount = percent + end + + local hpProcess = percent * 100 -- 海外修改如果小于百分之一,向上取整 + if hpProcess > 1 then + self.TxtDailyActive.text = string.format("%d%s",math.floor(hpProcess),"%") + else + self.TxtDailyActive.text = string.format("%d%s",math.ceil(hpProcess),"%") + end + self.TitleText.text = CSTextManagerGetText("WorldBossBossAreaSchedule") + local discountIds = specialSale:GetDiscountIds() + local discountCount = #discountIds + for i = 1, discountCount do + local discountData = specialSale:GetDiscountById(discountIds[i]) + + self.DiscountGrids[i]:GetObject("TextBlue").text = discountData.DiscountText + self.DiscountGrids[i]:GetObject("SaleBlue").gameObject:SetActiveEx(percent <= discountData.HpPercent * 0.01) + + self.DiscountGrids[i]:GetObject("TextNone").text = discountData.DiscountText + self.DiscountGrids[i]:GetObject("SaleNone").gameObject:SetActiveEx(percent > discountData.HpPercent * 0.01) + end + -- 自适应 + local activeProgressRectSize = self.PanelReward.rect.size + for i = 1, #self.DiscountGrids do + local discountData = specialSale:GetDiscountById(discountIds[i]) + local valOffset = 1 - discountData.HpPercent * 0.01 + local adjustPosition = CS.UnityEngine.Vector3(activeProgressRectSize.x * valOffset, 0, 0) + self.DiscountGridRects[i].anchoredPosition3D = adjustPosition + end +end + +function XUiWorldBossFashion:OnBtnCloseClick() + self:Close() +end + +function XUiWorldBossFashion:OnBtnGetClick() + if self.BtnGet.ButtonState == Disable then + return + end + + XFunctionManager.SkipInterface(FashionSkipId) +end + +function XUiWorldBossFashion:OnBtnHelpClick() + XUiManager.UiFubenDialogTip(CS.XTextManager.GetText("WorldBossFashionHint"), CS.XTextManager.GetText("WorldBossFashionRule") or "") +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiWorldBoss/XUiWorldBossLevelSelect.lua b/Resources/Scripts/XUi/XUiWorldBoss/XUiWorldBossLevelSelect.lua new file mode 100644 index 00000000..89df6ec5 --- /dev/null +++ b/Resources/Scripts/XUi/XUiWorldBoss/XUiWorldBossLevelSelect.lua @@ -0,0 +1,36 @@ +local XUiWorldBossLevelSelect = XLuaUiManager.Register(XLuaUi, "UiWorldBossLevelSelect") +local XUiGridLevelSelect = require("XUi/XUiWorldBoss/XUiGridLevelSelect") + +function XUiWorldBossLevelSelect:OnStart(stageId, level, cb) + self.CallBack = cb + self:SetButtonCallBack() + self.CurBossLevel = level + self:InitLevelSelect(stageId) +end + +function XUiWorldBossLevelSelect:SetButtonCallBack() + self.BtnClose.CallBack = function() + self:OnBtnCloseClick() + end +end + +function XUiWorldBossLevelSelect:OnBtnCloseClick() + if self.CallBack then + self.CallBack(self.CurBossLevel) + end + self:Close() +end + +function XUiWorldBossLevelSelect:InitLevelSelect(stageId) + if not stageId then + return + end + self.GridLevel.gameObject:SetActiveEx(false) + local stageList = XDataCenter.WorldBossManager.GetBossStageGroupByIdAndLevel(stageId) + for _,stage in pairs(stageList) do + local go = CS.UnityEngine.Object.Instantiate(self.GridLevel, self.LevelContent) + local selectTtem = XUiGridLevelSelect.New(go, self) + selectTtem.GameObject:SetActiveEx(true) + selectTtem:UpdateData(stage) + end +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiWorldBoss/XUiWorldBossMain.lua b/Resources/Scripts/XUi/XUiWorldBoss/XUiWorldBossMain.lua new file mode 100644 index 00000000..6b24095f --- /dev/null +++ b/Resources/Scripts/XUi/XUiWorldBoss/XUiWorldBossMain.lua @@ -0,0 +1,224 @@ +local XUiWorldBossMain = XLuaUiManager.Register(XLuaUi, "UiWorldBossMain") +local XUiGridBtnAttributeArea = require("XUi/XUiWorldBoss/XUiGridBtnAttributeArea") +local XUiGridBtnBossArea = require("XUi/XUiWorldBoss/XUiGridBtnBossArea") + +local CSTextManagerGetText = CS.XTextManager.GetText +local SERVERDATAGETTIME = 30 + +function XUiWorldBossMain:OnStart() + self:InitArea() + self:InitAttributeArea() + self:InitBossArea() + self:SetButtonCallBack() + + self.UpdateTimer = XScheduleManager.ScheduleForever(function() + XDataCenter.WorldBossManager.GetWorldBossGlobalData() + XDataCenter.WorldBossManager.GetWorldBossReport() + end, XScheduleManager.SECOND * SERVERDATAGETTIME, 0) +end + +function XUiWorldBossMain:OnDestroy() + if self.UpdateTimer then + XScheduleManager.UnSchedule(self.UpdateTimer) + end +end + +function XUiWorldBossMain:OnEnable() + XDataCenter.WorldBossManager.CheckWorldBossActivityReset() + self:UpdateArea() + self:UpdatePanelChat() + XEventManager.AddEventListener(XEventId.EVENT_WORLDBOSS_SYNCDATA, self.UpdateArea, self) + XEventManager.AddEventListener(XEventId.EVENT_WORLDBOSS_REPORT, self.UpdatePanelChat, self) +end + +function XUiWorldBossMain:OnDisable() + XEventManager.RemoveEventListener(XEventId.EVENT_WORLDBOSS_SYNCDATA, self.UpdateArea, self) + XEventManager.RemoveEventListener(XEventId.EVENT_WORLDBOSS_REPORT, self.UpdatePanelChat, self) +end + +function XUiWorldBossMain:InitArea() + self.AttributeAreaObjList = { + self.AreaEntrance:GetObject("Area01"), + self.AreaEntrance:GetObject("Area02"), + self.AreaEntrance:GetObject("Area03"), + self.AreaEntrance:GetObject("Area04"), + self.AreaEntrance:GetObject("Area05"), + } + + self.BossAreaObjList = { + self.BossEntrance:GetObject("BossArea01"), + } +end + +function XUiWorldBossMain:InitAttributeArea() + local worldBossActivity = XDataCenter.WorldBossManager.GetCurWorldBossActivity() + if not worldBossActivity then + return + end + local attributeAreaDic = worldBossActivity:GetAttributeAreaEntityDic() + self.GridAttributeAreaDic = {} + local gridIndex = 1 + + for key,_ in pairs(attributeAreaDic) do + local attributeAreaObj = self.AttributeAreaObjList[gridIndex] + if attributeAreaObj then + local grid = XUiGridBtnAttributeArea.New(attributeAreaObj) + self.GridAttributeAreaDic[key] = grid + end + gridIndex = gridIndex + 1 + end + + local storyId = worldBossActivity:GetStartStoryId() + if storyId and #storyId > 1 then + local IsCanPlay = XDataCenter.WorldBossManager.CheckIsNewStoryID(storyId) + if IsCanPlay then + XDataCenter.MovieManager.PlayMovie(storyId)--一次 + XDataCenter.WorldBossManager.MarkStoryID(storyId) + end + end +end + +function XUiWorldBossMain:InitBossArea() + local worldBossActivity = XDataCenter.WorldBossManager.GetCurWorldBossActivity() + if not worldBossActivity then + return + end + local bossAreaDic = worldBossActivity:GetBossAreaEntityDic() + self.GridBossAreaDic = {} + local gridIndex = 1 + + for key,_ in pairs(bossAreaDic) do + local bossAreaObj = self.BossAreaObjList[gridIndex] + if bossAreaObj then + local grid = XUiGridBtnBossArea.New(bossAreaObj) + self.GridBossAreaDic[key] = grid + end + gridIndex = gridIndex + 1 + end +end + +function XUiWorldBossMain:SetButtonCallBack() + self.PanelChat:GetObject("BtnWarReport").CallBack = function() + self:OnBtnWarReportClick() + end + self.BtnTask.CallBack = function() + self:OnBtnTaskClick() + end + self.BtnFashion.CallBack = function() + self:OnBtnFashionClick() + end + self.BtnShop.CallBack = function() + self:OnBtnShopClick() + end + self.BtnBack.CallBack = function() + self:OnBtnBackClick() + end + self.BtnMainUi.CallBack = function() + self:OnBtnMainUiClick() + end + self:BindHelpBtn(self.BtnHelp, "WorldBossHelp") +end + +function XUiWorldBossMain:UpdateArea() + local worldBossActivity = XDataCenter.WorldBossManager.GetCurWorldBossActivity() + if not worldBossActivity then + return + end + local attributeAreaDic = worldBossActivity:GetAttributeAreaEntityDic() + local bossAreaDic = worldBossActivity:GetBossAreaEntityDic() + + for key,areaEneity in pairs(attributeAreaDic) do + self.GridAttributeAreaDic[key]:UpdateData(areaEneity) + end + for key,areaEneity in pairs(bossAreaDic) do + self.GridBossAreaDic[key]:UpdateData(areaEneity) + end + + self:SetActivityInfo() +end + +function XUiWorldBossMain:SetActivityInfo() + local worldBossActivity = XDataCenter.WorldBossManager.GetCurWorldBossActivity() + if not worldBossActivity then + return + end + local nowTime = XTime.GetServerNowTimestamp() + local actionPointId = worldBossActivity:GetActionPointId() + local shopCurrencyId = worldBossActivity:GetShopCurrencyId() + local specialSaleIds = worldBossActivity:GetSpecialSaleIds() + local saleEntityDic = worldBossActivity:GetSpecialSaleEntityDic() + local maxActionPointId = worldBossActivity:GetMaxActionPoint() + + local powerCount = XDataCenter.ItemManager.GetCount(actionPointId) + local item = XUiGridCommon.New(self, self.PowerItemGrid) + item:Refresh(actionPointId) + self.PowerText.text = CSTextManagerGetText("WorldBossActionPoint") + self.PowerNum.text = string.format("%d/%d",powerCount,maxActionPointId) + + local item = XUiGridCommon.New(self, self.MoneyItemGrid) + item:Refresh(shopCurrencyId) + local moneyCount = XDataCenter.ItemManager.GetCount(shopCurrencyId) + self.MoneyNum.text = moneyCount + + local firstIndex = 1 + local saleId = specialSaleIds[firstIndex] + local discountText = saleEntityDic[saleId]:GetMinDiscountText() + self.DiscointText.text = discountText + self.DiscointText.gameObject:SetActiveEx(#discountText > 0) + + self.TimeText.text = XUiHelper.GetTime(worldBossActivity:GetEndTime() - nowTime, XUiHelper.TimeFormatType.ACTIVITY) + + local IsHaveRed = XDataCenter.WorldBossManager.CheckAnyTaskFinished() + self.BtnTask:ShowReddot(IsHaveRed) +end + +function XUiWorldBossMain:UpdatePanelChat() + local reportData = XDataCenter.WorldBossManager.GetWorldBossNewReport() + if not reportData then + return + end + local playerInfo = reportData.PlayerInfo + local reportId = reportData.ReportId + local reportCfg = XWorldBossConfigs.GetReportTemplatesById(reportId) + local reportType = XDataCenter.WorldBossManager.GetFightReportTypeById(reportId) + local IsSystemReport = reportType == XWorldBossConfigs.ReportType.System + local nameText = "" + local wordText = "" + + if IsSystemReport then + nameText = CSTextManagerGetText("WorldBossReportName") + wordText = reportCfg.Message + else + nameText = playerInfo.PlayerName + local score = playerInfo.Score + wordText = string.format(reportCfg.Message,nameText,score) + end + self.PanelChat:GetObject("TxtMessageLabel").gameObject:SetActiveEx(true) + self.PanelChat:GetObject("TxtMessageContent").text =string.format("%s:%s", nameText, wordText) +end + +function XUiWorldBossMain:OnBtnBackClick() + self:Close() +end + +function XUiWorldBossMain:OnBtnMainUiClick() + XLuaUiManager.RunMain() +end + +function XUiWorldBossMain:OnBtnTaskClick() + XLuaUiManager.Open("UiWorldBossTask") +end + +function XUiWorldBossMain:OnBtnFashionClick() + XLuaUiManager.Open("UiWorldBossFashion") +end + +function XUiWorldBossMain:OnBtnShopClick() + if XFunctionManager.DetectionFunction(XFunctionManager.FunctionName.ShopCommon) then + XLuaUiManager.Open("UiShop", XShopManager.ShopType.WorldBoss) + end +end + +function XUiWorldBossMain:OnBtnWarReportClick() + XLuaUiManager.Open("UiChatUiWorldBoss") +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiWorldBoss/XUiWorldBossTask.lua b/Resources/Scripts/XUi/XUiWorldBoss/XUiWorldBossTask.lua new file mode 100644 index 00000000..84450c95 --- /dev/null +++ b/Resources/Scripts/XUi/XUiWorldBoss/XUiWorldBossTask.lua @@ -0,0 +1,70 @@ +local XUiWorldBossTask = XLuaUiManager.Register(XLuaUi, "UiWorldBossTask") + +function XUiWorldBossTask:OnAwake() + self.BtnBack.CallBack = function() self:OnBtnBackClick() end + + self.DynamicTable = XDynamicTableNormal.New(self.PanelTaskStoryList.gameObject) + self.DynamicTable:SetProxy(XDynamicGridTask) + self.DynamicTable:SetDelegate(self) + + XEventManager.AddEventListener(XEventId.EVENT_TASK_SYNC, self.OnTaskChangeSync, self) + XEventManager.AddEventListener(XEventId.EVENT_WORLDBOSS_TASK_RESET, self.OnTaskChangeSync, self) +end + +function XUiWorldBossTask:OnStart() + self:OnTaskChangeSync() +end + +function XUiWorldBossTask:OnEnable() + XDataCenter.WorldBossManager.CheckWorldBossActivityReset() +end + +function XUiWorldBossTask:OnDestroy() + self:StopCountDown() + XEventManager.RemoveEventListener(XEventId.EVENT_TASK_SYNC, self.OnTaskChangeSync, self) + XEventManager.RemoveEventListener(XEventId.EVENT_WORLDBOSS_TASK_RESET, self.OnTaskChangeSync, self) +end + +function XUiWorldBossTask:OnTaskChangeSync() + self.WorldBossTasks = XDataCenter.TaskManager.GetWorldBossFullTaskList() + for _, v in pairs(self.WorldBossTasks or {}) do + v.SortWeight = 2 + if v.State == XDataCenter.TaskManager.TaskState.Achieved then + v.SortWeight = 1 + elseif v.State == XDataCenter.TaskManager.TaskState.Finish or v.State == XDataCenter.TaskManager.TaskState.Invalid then + v.SortWeight = 3 + end + end + + table.sort(self.WorldBossTasks, function(taskA, taskB) + if taskA.SortWeight == taskB.SortWeight then + return taskA.Id < taskB.Id + end + return taskA.SortWeight < taskB.SortWeight + end) + self.DynamicTable:SetDataSource(self.WorldBossTasks) + self.DynamicTable:ReloadDataASync() +end + +--动态列表事件 +function XUiWorldBossTask:OnDynamicTableEvent(event, index, grid) + if event == DYNAMIC_DELEGATE_EVENT.DYNAMIC_GRID_ATINDEX then + local data = self.WorldBossTasks[index] + if not data then + return + end + grid.RootUi = self + grid:ResetData(data) + end +end + +function XUiWorldBossTask:StopCountDown() + if self.CountTimer ~= nil then + XScheduleManager.UnSchedule(self.CountTimer) + self.CountTimer = nil + end +end + +function XUiWorldBossTask:OnBtnBackClick() + self:Close() +end \ No newline at end of file diff --git a/Resources/Scripts/XUi/XUiWorldBoss/XUiWorldBossTips.lua b/Resources/Scripts/XUi/XUiWorldBoss/XUiWorldBossTips.lua new file mode 100644 index 00000000..b7ad7adb --- /dev/null +++ b/Resources/Scripts/XUi/XUiWorldBoss/XUiWorldBossTips.lua @@ -0,0 +1,41 @@ +local XUiWorldBossTips = XLuaUiManager.Register(XLuaUi, "UiWorldBossTips") +local XUiGridTipsInfo = require("XUi/XUiWorldBoss/XUiGridTipsInfo") +local Object = CS.UnityEngine.Object + +function XUiWorldBossTips:OnStart(id, IsShowCondition) + self.Buff = XDataCenter.WorldBossManager.GetWorldBossBuffById(id) + self.SameGroupBuff = XDataCenter.WorldBossManager.GetSameGroupBossBuffByGroupId(self.Buff:GetGroupId()) + self.SameGroupBuff = self.SameGroupBuff or {self.Buff} + self:SetBuffInfo(IsShowCondition) + self:SetButtonCallBack() +end + +function XUiWorldBossTips:InitBuffInfo() + self:Close() +end + +function XUiWorldBossTips:SetButtonCallBack() + self.BtnMask.CallBack = function() + self:OnBtnMaskClick() + end +end + +function XUiWorldBossTips:SetBuffInfo(IsShowCondition) + self.RImgBuff:SetRawImage(self.Buff:GetIcon()) + self.TxtBuffName.text = self.Buff:GetName() + self.HintText.text = self.Buff:GetHintText() + --self.HintText.gameObject:SetActiveEx(IsShowCondition) + self.TxtBuffDescription.gameObject:SetActiveEx(false) + self.BuffBg.gameObject:SetActiveEx(self.Buff:GetType() == XWorldBossConfigs.BuffType.Buff) + for _,buff in pairs(self.SameGroupBuff) do + local tmpObj = Object.Instantiate(self.TxtBuffDescription) + tmpObj.gameObject:SetActiveEx(true) + tmpObj.transform:SetParent(self.InfoContent.transform, false) + local info = XUiGridTipsInfo.New(tmpObj) + info:UpdateData(buff,IsShowCondition) + end +end + +function XUiWorldBossTips:OnBtnMaskClick() + self:Close() +end \ No newline at end of file